🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

rc-hooks

Package Overview
Dependencies
Maintainers
1
Versions
99
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rc-hooks - npm Package Compare versions

Comparing version
3.3.1
to
3.4.0
+91
es/useFullscreen/index.js
import { __read } from 'tslib';
import { useState, useEffect } from 'react';
import { isBrowser } from 'ut2';
import getRef from '../utils/getRef.js';
import useLatest from '../useLatest/index.js';
import useUpdateEffect from '../useUpdateEffect/index.js';
function useFullscreen(ref, options) {
var _a = options || {}, onEnter = _a.onEnter, onExit = _a.onExit;
var _b = __read(useState(false), 2), isFullscreen = _b[0], setIsFullscreen = _b[1];
var onEnterRef = useLatest(onEnter);
var onExitRef = useLatest(onExit);
var enter = function () {
var element = ref ? getRef(ref) : document.documentElement;
if (element) {
var requestFullscreen = element.requestFullscreen ||
element.webkitRequestFullscreen ||
element.mozRequestFullScreen ||
element.msRequestFullscreen;
if (requestFullscreen) {
requestFullscreen.call(element);
}
}
};
var exit = function () {
var exitFullscreen = document.exitFullscreen ||
document.webkitExitFullscreen ||
document.mozCancelFullScreen ||
document.msExitFullscreen;
if (exitFullscreen) {
exitFullscreen.call(document);
}
};
var toggle = function () {
if (isFullscreen) {
exit();
}
else {
enter();
}
};
useEffect(function () {
if (!isBrowser) {
return;
}
var checkFullscreen = function () {
var fullscreenElement = document.fullscreenElement ||
document.webkitFullscreenElement ||
document.mozFullScreenElement ||
document.msFullscreenElement;
setIsFullscreen(!!fullscreenElement);
};
var fullscreenEventName;
if ('fullscreenElement' in document) {
fullscreenEventName = 'fullscreenchange';
}
else if ('webkitFullscreenElement' in document) {
fullscreenEventName = 'webkitfullscreenchange';
}
else if ('mozFullScreenElement' in document) {
fullscreenEventName = 'mozfullscreenchange';
}
else if ('msFullscreenElement' in document) {
fullscreenEventName = 'MSFullscreenChange';
}
else {
return;
}
document.addEventListener(fullscreenEventName, checkFullscreen);
return function () {
document.removeEventListener(fullscreenEventName, checkFullscreen);
};
}, []);
useUpdateEffect(function () {
var _a, _b;
if (isFullscreen) {
(_a = onEnterRef.current) === null || _a === void 0 ? void 0 : _a.call(onEnterRef);
}
else {
(_b = onExitRef.current) === null || _b === void 0 ? void 0 : _b.call(onExitRef);
}
}, [isFullscreen]);
return {
isFullscreen: isFullscreen,
enter: enter,
exit: exit,
toggle: toggle
};
}
export { useFullscreen as default };
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var tslib = require('tslib');
var react = require('react');
var ut2 = require('ut2');
var getRef = require('../utils/getRef.js');
var index = require('../useLatest/index.js');
var index$1 = require('../useUpdateEffect/index.js');
function useFullscreen(ref, options) {
var _a = options || {}, onEnter = _a.onEnter, onExit = _a.onExit;
var _b = tslib.__read(react.useState(false), 2), isFullscreen = _b[0], setIsFullscreen = _b[1];
var onEnterRef = index.default(onEnter);
var onExitRef = index.default(onExit);
var enter = function () {
var element = ref ? getRef.default(ref) : document.documentElement;
if (element) {
var requestFullscreen = element.requestFullscreen ||
element.webkitRequestFullscreen ||
element.mozRequestFullScreen ||
element.msRequestFullscreen;
if (requestFullscreen) {
requestFullscreen.call(element);
}
}
};
var exit = function () {
var exitFullscreen = document.exitFullscreen ||
document.webkitExitFullscreen ||
document.mozCancelFullScreen ||
document.msExitFullscreen;
if (exitFullscreen) {
exitFullscreen.call(document);
}
};
var toggle = function () {
if (isFullscreen) {
exit();
}
else {
enter();
}
};
react.useEffect(function () {
if (!ut2.isBrowser) {
return;
}
var checkFullscreen = function () {
var fullscreenElement = document.fullscreenElement ||
document.webkitFullscreenElement ||
document.mozFullScreenElement ||
document.msFullscreenElement;
setIsFullscreen(!!fullscreenElement);
};
var fullscreenEventName;
if ('fullscreenElement' in document) {
fullscreenEventName = 'fullscreenchange';
}
else if ('webkitFullscreenElement' in document) {
fullscreenEventName = 'webkitfullscreenchange';
}
else if ('mozFullScreenElement' in document) {
fullscreenEventName = 'mozfullscreenchange';
}
else if ('msFullscreenElement' in document) {
fullscreenEventName = 'MSFullscreenChange';
}
else {
return;
}
document.addEventListener(fullscreenEventName, checkFullscreen);
return function () {
document.removeEventListener(fullscreenEventName, checkFullscreen);
};
}, []);
index$1.default(function () {
var _a, _b;
if (isFullscreen) {
(_a = onEnterRef.current) === null || _a === void 0 ? void 0 : _a.call(onEnterRef);
}
else {
(_b = onExitRef.current) === null || _b === void 0 ? void 0 : _b.call(onExitRef);
}
}, [isFullscreen]);
return {
isFullscreen: isFullscreen,
enter: enter,
exit: exit,
toggle: toggle
};
}
exports.default = useFullscreen;
import { RefType } from '../utils/getRef';
/**
* 管理全屏状态的 Hook。
*
* @param {Object} [ref] Dom 节点或 Ref 对象。如果不传,则默认使用 document.documentElement。
* @param {Object} [options] 配置项
* @param {Function} [options.onEnter] 进入全屏时的回调
* @param {Function} [options.onExit] 退出全屏时的回调
* @example
* const ref = React.useRef<HTMLDivElement>(null);
* const { isFullscreen, enter, exit, toggle } = useFullscreen(ref);
*
* return (
* <div ref={ref} style={{ width: '100px', height: '100px', background: '#f0f0f0' }}>
* <div style={{ marginBottom: 20 }}>点击按钮切换全屏</div>
* <button onClick={toggle}>
* {isFullscreen ? '退出全屏' : '进入全屏'}
* </button>
* </div>
* );
*/
declare function useFullscreen(ref?: RefType, options?: {
onEnter?: () => void;
onExit?: () => void;
}): {
isFullscreen: boolean;
enter: () => void;
exit: () => void;
toggle: () => void;
};
export default useFullscreen;
+1
-1

@@ -1,2 +0,2 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).rcHooks={},t.React)}(this,(function(t,e){"use strict";var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},n(t,e)};var r=function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)};function o(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n}function i(t,e,n,r){return new(n||(n=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(u,c)}a((r=r.apply(t,e||[])).next())}))}function u(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return u.next=c(0),u.throw=c(1),u.return=c(2),"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function c(c){return function(a){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;u&&(u=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=e.call(t,i)}catch(t){c=[6,t],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}}function c(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)u.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return u}"function"==typeof SuppressedError&&SuppressedError;var a=void 0,s="undefined",l=Object.prototype,f=l.toString,h=l.hasOwnProperty,p="[object ",d=p+"String]",v=p+"Symbol]",y=p+"Window]";function g(t){return null!==t&&"object"==typeof t}function m(t){return f.call(t)}var b=/^0b[01]+$/i,w=/^0o[0-7]+$/i,_=/^[-+]0x[0-9a-f]+$/i;function S(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||m(t)===v}(t))return NaN;if(function(t){return"function"==typeof t||g(t)}(t)&&(t=Number(t)),"string"!=typeof t)return 0===t?t:+t;t=t.trim();var e=b.test(t);return e||w.test(t)?parseInt(t.slice(2),e?2:8):_.test(t)?NaN:+t}function k(t){return Array.isArray(t)}function E(t,e,n){return void 0===n&&(n=!1),t===e?!n||(0!==t||1/t==1/e):t!=t&&e!=e}var T=typeof window!==s&&g(window)&&typeof document!==s&&g(document)&&window.document===document;m(function(){return arguments}());function O(t){return t===a}function C(t,e,n,r){if(void 0===r&&(r=!1),"function"!=typeof t)throw new TypeError("Expected a function");var o,i,u,c,s,l,f,h;function p(e){return u=e,l=t.apply(s,c),s=c=a,l}function d(){for(var t=[],f=0;f<arguments.length;f++)t[f]=arguments[f];s=this,c=t;var h=Date.now(),d=function(t){if(i===a)return!0;var n=t-i;return n>=e||n<0||r&&t-u>=e}(h),v=r?d||i===a||o!==a?e:e-(h-i):e;return i=h,d&&n&&o===a?p(h):(o===a||r||(clearTimeout(o),o=a),o===a&&(o=setTimeout((function(){o=a,p(Date.now())}),v)),l)}return f=S(e),h=0,e=null==f||f!=f?h:f,d.cancel=function(){o!==a&&(clearTimeout(o),o=a),i=o=c=s=a},d.flush=function(){return o!==a?(clearTimeout(o),o=a,p(Date.now())):l},d.pending=function(){return o!==a},d}function L(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=!1),C(t,e,n)}function R(t,e){var n=!1;return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];n||(n=!0,t.apply(void 0,function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))}([],c(r),!1)),setTimeout((function(){n=!1}),e))}}function I(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=!0),C(t,e,n,!0)}function P(t){return g(t)&&m(t)===y}function j(t){return arguments.length?k(t)?t:[t]:[]}function x(){}function D(t){var n=e.useRef(t);return n.current=t,n}function N(t){var n=D(t),r=e.useCallback((function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=n.current;return null==r?void 0:r.apply(void 0,t)}),[]);return r}var V=function(t,n){var r=e.useRef(!1);e.useEffect((function(){if(r.current)return t();r.current=!0}),n)},F=function(){var t=e.useRef(!1);return e.useEffect((function(){return t.current=!1,function(){t.current=!0}}),[]),t},A=function(){function t(){this.handlers={}}return t.prototype.eventNames=function(){var t,e=(null===(t=Object.getOwnPropertySymbols)||void 0===t?void 0:t.call(Object,this.handlers))||[];return Object.keys(this.handlers).concat(e)},t.prototype.rawListeners=function(t){var e=this.handlers[t];return e?e.map((function(t){return t.raw})):[]},t.prototype.listeners=function(t){var e=this.handlers[t];return e?e.map((function(t){return t.wrap})):[]},t.prototype.hasListener=function(t,e){return this.rawListeners(t).some((function(t){return t===e}))},t.prototype._on=function(t,e,n,r,o){void 0===r&&(r=null),void 0===o&&(o=1);var i={raw:e,wrap:n,context:r};if(this.handlers[t]){var u=1===o?"push":"unshift";this.handlers[t][u](i)}else this.handlers[t]=[i];return this},t.prototype.prependListener=function(t,e,n){return this._on(t,e,e,n,0)},t.prototype.on=function(t,e,n){return this._on(t,e,e,n)},t.prototype._wrapOnce=function(t,e,n){var r=this;void 0===n&&(n=null);var o=function(){for(var i=[],u=0;u<arguments.length;u++)i[u]=arguments[u];e.apply(n,i),r.off(t,o)};return o},t.prototype.once=function(t,e,n){var r=this._wrapOnce(t,e,n);return this._on(t,e,r,n)},t.prototype.prependOnceListener=function(t,e,n){var r=this._wrapOnce(t,e,n);return this._on(t,e,r,n,0)},t.prototype.off=function(t,e){var n=this.handlers[t];if(n)if(e){var r=n.findIndex((function(t){return t.wrap===e||t.raw===e}));-1!==r&&n.splice(r,1)}else delete this.handlers[t];return this},t.prototype.offAll=function(){return this.handlers={},this},t.prototype.emit=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var r=this.handlers[t];return!!(r&&r.length>0)&&(r.forEach((function(t){t.wrap.apply(t.context,e)})),!0)},t}(),M="cache2",W="".concat(M,"_"),z="default";var K={},H=function(){function t(t){void 0===t&&(t=z),this.scope=t,K[this.scope]||(K[this.scope]={}),this.data=K[this.scope]}return t.prototype.getItem=function(t){return t in this.data?this.data[t]:null},t.prototype.setItem=function(t,e){this.data[t]=e},t.prototype.removeItem=function(t){delete this.data[t]},t.prototype.clear=function(){K[this.scope]={},this.data=K[this.scope]},t}(),U=function(){function t(t,e){void 0===e&&(e={});var n=!!t&&function(t){try{var e="object"==typeof t&&null!==t&&!!t.setItem&&!!t.getItem&&!!t.removeItem;if(e){var n=Math.random().toString(16).substring(2,8),r="___".concat(M,"_test_").concat(n,"_").concat(Date.now(),"___");t.setItem(r,"1"),t.removeItem(r)}return e}catch(t){return console.error("[".concat(M,"] Storage operation failed:"),t instanceof Error?t.message:t),console.warn("[".concat(M,"] The default memory cache will be used.")),!1}}(t);this.options=r({needParsed:n,prefix:""},e),this.storage=n?t:new H(this.options.memoryScope)}return t.prototype.getKey=function(t){return this.options.prefix+t},t.prototype.get=function(t){var e=this.storage.getItem(this.getKey(t));return this.options.needParsed?function(t,e){try{return JSON.parse(t,e)}catch(e){return console.warn("[".concat(M,"] JSON parse failed, returning original value:"),e instanceof Error?e.message:e),t}}(e,this.options.reviver):e},t.prototype.set=function(t,e){this.storage.setItem(this.getKey(t),this.options.needParsed?function(t,e){try{return JSON.stringify(t,e)}catch(t){throw console.error("[".concat(M,"] JSON stringify failed:"),t instanceof Error?t.message:t),t}}(e,this.options.replacer):e)},t.prototype.del=function(t){this.storage.removeItem(this.getKey(t))},t.prototype.clear=function(){"function"==typeof this.storage.clear&&this.storage.clear()},t}(),B=function(t){function e(e,n){var o,i=t.call(this)||this,u=z;return"string"==typeof e?u=e||z:"object"==typeof e&&(o=e),o||"object"!=typeof n||(o=n),i.options=r({max:-1,stdTTL:0,maxStrategy:"limited",checkperiod:0,prefix:W},o),i.storage=new U(i.options.storage,r({memoryScope:u},i.options)),i.cacheKey=u,i.startCheckperiod(),i}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}(e,t),e.prototype._check=function(t,e){var n=!0;return 0!==e.t&&e.t<Date.now()&&(n=!1,this.del(t),this.emit("expired",t,e.v)),n},e.prototype._wrap=function(t,e){var n=Date.now(),r="number"==typeof e?e:this.options.stdTTL;return{v:t,t:r>0?n+r:0,n:n}},e.prototype._isLimited=function(t){return this.options.max>-1&&t>=this.options.max},e.prototype._getReplaceKey=function(t,e){var n=t[0];return t.forEach((function(t){e[n].n>e[t].n&&(n=t)})),n},Object.defineProperty(e.prototype,"cacheValues",{get:function(){return this.storage.get(this.cacheKey)||{}},enumerable:!1,configurable:!0}),e.prototype.setCacheValues=function(t){this.storage.set(this.cacheKey,t)},e.prototype._getData=function(t,e){var n=e[t];if(n&&this._check(t,n))return n},e.prototype.get=function(t){var e=this._getData(t,this.cacheValues);return null==e?void 0:e.v},e.prototype.mget=function(t){var e=this,n={};if(!Array.isArray(t))return n;var r=this.cacheValues;return t.forEach((function(t){var o=e._getData(t,r);o&&(n[t]=o.v)})),n},e.prototype.getAll=function(){var t=Object.keys(this.cacheValues);return this.mget(t)},e.prototype.set=function(t,e,n){if(0===this.options.max)return!1;var r=this.cacheValues,o=Object.keys(r);if(!r[t]&&this._isLimited(o.length)){var i=this.keys();if(this._isLimited(i.length)){if("replaced"!==this.options.maxStrategy)return!1;var u=this._getReplaceKey(i,r);this.del(u)}}return r[t]=this._wrap(e,n),this.setCacheValues(r),this.emit("set",t,r[t].v),!0},e.prototype.mset=function(t){var e=this,n=!0;return t.forEach((function(t){var r=e.set(t.key,t.value,t.ttl);n&&!r&&(n=!1)})),n},e.prototype.del=function(t){var e=this,n=this.cacheValues,r=0;return(Array.isArray(t)?t:[t]).forEach((function(t){if(n[t]){r++;var o=n[t];delete n[t],e.emit("del",t,o.v)}})),r>0&&this.setCacheValues(n),r},e.prototype.clear=function(){this.storage.del(this.cacheKey)},e.prototype.keys=function(){var t=this,e=this.cacheValues;return Object.keys(e).filter((function(n){return t._check(n,e[n])}))},e.prototype.has=function(t){return!!this._getData(t,this.cacheValues)},e.prototype.take=function(t){var e,n=this._getData(t,this.cacheValues);return n&&(e=n.v,this.del(t)),e},e.prototype.ttl=function(t,e){var n=this._getData(t,this.cacheValues);return!!n&&this.set(t,n.v,e)},e.prototype.getTtl=function(t){var e=this._getData(t,this.cacheValues);return null==e?void 0:e.t},e.prototype.getLastModified=function(t){var e=this._getData(t,this.cacheValues);return null==e?void 0:e.n},e.prototype.startCheckperiod=function(){var t=this;this.keys(),this.options.checkperiod>0&&(clearTimeout(this._checkTimeout),this._checkTimeout=setTimeout((function(){t.startCheckperiod()}),this.options.checkperiod))},e.prototype.stopCheckperiod=function(){clearTimeout(this._checkTimeout)},e}(A),J=function(){function t(t,e){void 0===e&&(e="uh_async_memo"),this.promiseCache={},this.cache=new B(e,t)}return t.prototype.run=function(t,e,n){var o,i=this;if(!e||"string"!=typeof(o=e)&&m(o)!==d)return t();var u=r({persisted:!0},n);if(u.persisted){var c=this.cache.get(e);if(c)return Promise.resolve(c)}return this.promiseCache[e]||(this.promiseCache[e]=t().then((function(t){return delete i.promiseCache[e],i.cache.set(e,t,u.ttl),t})).catch((function(t){return delete i.promiseCache[e],Promise.reject(t)}))),this.promiseCache[e]},t}();function $(){return"undefined"==typeof document||void 0===document.visibilityState||"hidden"!==document.visibilityState}var q=[];var G=!1;if("undefined"!=typeof window&&window.addEventListener&&!G){window.addEventListener("visibilitychange",(function(){if($())for(var t=0;t<q.length;t++){(0,q[t])()}}),!1),G=!0}var Y=[];var Q=!1;if("undefined"!=typeof window&&window.addEventListener&&!Q){var X=function(){if($()&&("undefined"==typeof navigator||void 0===navigator.onLine||navigator.onLine))for(var t=0;t<Y.length;t++){(0,Y[t])()}};window.addEventListener("visibilitychange",X,!1),window.addEventListener("focus",X,!1),Q=!0}var Z="rc-hooks",tt=new J({prefix:Z,stdTTL:3e5});function et(t){return tt.cache.get(t)}var nt=function(){function t(t,e){this.params=[],this.pollingWhenVisibleFlag=!1,this.pollingTimer=null,this.counter=1,this.destroyed=!1,this.async=t,this.options=r({cacheTime:3e5,persisted:!1,pollingWhenHidden:!0,refreshOnWindowFocus:!1,focusTimespan:5e3},e),this.unsubscribes=[],this.init()}return t.prototype.init=function(){var t,e=this.options,n=e.pollingInterval,r=e.refreshOnWindowFocus,o=e.focusTimespan;if(this.updateDebounce(),n&&this.unsubscribes.push((t=this.rePolling.bind(this),q.push(t),function(){var e=q.indexOf(t);q.splice(e,1)})),r){var i=R(this.refresh.bind(this),o);this.unsubscribes.push(function(t){return Y.push(t),function(){var e=Y.indexOf(t);Y.splice(e,1)}}(i))}},t.prototype.updateDebounce=function(){var t=this.options,e=t.debounceInterval,n=t.throttleInterval;this.debounce="number"==typeof e&&e>0?L(this._wraprun,e):void 0,this.throttle="number"==typeof n&&n>0?I(this._wraprun,n):void 0},t.prototype.rePolling=function(){this.pollingWhenVisibleFlag&&(this.pollingWhenVisibleFlag=!1,this.refresh())},t.prototype.afterUpdateOptions=function(t,e){void 0===e&&(e={}),("debounceInterval"in e&&e.debounceInterval!==t.debounceInterval||"throttleInterval"in e&&e.throttleInterval!==t.throttleInterval)&&this.updateDebounce()},t.prototype.updateOptions=function(t){var e=this.options,n=r(r({},this.options),t);this.options=n,this.afterUpdateOptions(e,n)},t.prototype._run=function(){for(var t=this,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];this.pollingTimer&&clearTimeout(this.pollingTimer);var r=this.counter;this.params=e;var o=this.options,i=o.cacheKey,u=o.cacheTime,c=o.persisted,a=o.formatResult,s=o.onSuccess,l=o.onError,f=o.onFinally,h=o.onBefore,p=o.pollingWhenHidden,d=o.pollingInterval;return null==h||h(e),new Promise((function(n,o){tt.run((function(){return t.async.apply(t,e).then((function(t){return"function"==typeof a?a(t,e):t}))}),i,{persisted:c,ttl:u}).then((function(o){r===t.counter&&(null==s||s(o,e),n(o))})).catch((function(n){r===t.counter&&(null==l||l(n,e),o(n))})).finally((function(){if(r===t.counter&&(null==f||f(),d)){if(!$()&&!p)return void(t.pollingWhenVisibleFlag=!0);t.pollingTimer=setTimeout((function(){t.run.apply(t,e)}),d)}}))}))},t.prototype._wraprun=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return this.counter+=1,this._run.apply(this,t)},t.prototype.run=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return this.debounce?(this.debounce.apply(this,t),Promise.resolve(null)):this.throttle?(this.throttle.apply(this,t),Promise.resolve(null)):this._wraprun.apply(this,t)},t.prototype.refresh=function(){return this.run.apply(this,this.params)},t.prototype.cancel=function(){this.debounce&&this.debounce.cancel(),this.throttle&&this.throttle.cancel(),this.pollingTimer&&(clearTimeout(this.pollingTimer),this.pollingTimer=null),this.counter+=1},t.prototype.destroy=function(t){void 0===t&&(t=!0),t&&this.cancel(),this.destroyed||(this.destroyed=!0,this.unsubscribes.forEach((function(t){return t()})),this.unsubscribes=[])},t.prototype.resume=function(){this.destroyed&&(this.destroyed=!1,this.init())},t}(),rt=function(t,n){var o=n||{},i=o.autoRun,u=void 0===i||i,a=o.refreshDeps,s=void 0===a?[]:a,l=o.defaultParams,f=o.loadingDelay,p=o.__INTERNAL_FORMAT__,d=o.defaultLoading,v=o.initialData,y=o.cacheKey,g=void 0===y?"":y,m=o.cacheTime,b=void 0===m?3e5:m,w=o.persisted,_=void 0!==w&&w,S=o.onSuccess,T=void 0===S?x:S,C=o.onError,L=void 0===C?x:C,R=o.onFinally,I=void 0===R?x:R,P=o.onBefore,j=void 0===P?x:P,A=o.pollingInterval,M=void 0===A?0:A,W=o.pollingWhenHidden,z=void 0===W||W,K=o.refreshOnWindowFocus,H=void 0!==K&&K,U=o.focusTimespan,B=void 0===U?5e3:U,J=o.debounceInterval,$=o.throttleInterval,q=c(e.useState((function(){return{params:[],loading:!!(O(d)?u&&!f:d),error:null,data:g?et(g):v}})),2),G=q[0],Y=q[1],Q=F(),X=e.useRef(null),Z=N(t),tt=N(T),rt=N(L),ot=N(I),it=N(j),ut=D(p),ct=e.useCallback((function(t){it(t),X.current&&clearTimeout(X.current),(g?et(g):void 0)&&_||(Y((function(e){var n=!function(t,e,n){if(void 0===n&&(n=!0),E(t,e,n))return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;var r=Object.keys(t),o=Object.keys(e);if(r.length!==o.length)return!1;for(var i=0;i<r.length;i++){var u=r[i];if(!h.call(e,u)||!E(t[u],e[u],n))return!1}return!0}(e.params,t);return e.loading!==!f||n?r(r({},e),{loading:!f,params:t}):e})),f&&(X.current=setTimeout((function(){Q.current||Y((function(t){return r(r({},t),{loading:!0})}))}),f)))}),[g,f,it,_,Q]),at=e.useCallback((function(t,e){X.current&&clearTimeout(X.current),Y((function(e){return r(r({},e),{data:t,error:null,loading:!1})})),tt(t,e)}),[tt]),st=e.useCallback((function(t,e){X.current&&clearTimeout(X.current),Y((function(e){return r(r({},e),{error:t,loading:!1})})),rt(t,e)}),[rt]),lt=e.useRef(void 0);lt.current||(lt.current=new nt(Z,{cacheKey:g,cacheTime:b,persisted:_,formatResult:ut.current,onSuccess:at,onError:st,onFinally:ot,onBefore:ct,debounceInterval:J,throttleInterval:$,pollingInterval:M,pollingWhenHidden:z,refreshOnWindowFocus:H,focusTimespan:B})),V((function(){lt.current.updateOptions({cacheKey:g,cacheTime:b,persisted:_,formatResult:ut.current,onSuccess:at,onError:st,onFinally:ot,onBefore:ct,debounceInterval:J,throttleInterval:$,pollingInterval:M,pollingWhenHidden:z,refreshOnWindowFocus:H,focusTimespan:B})}),[tt,rt,g,b,_,J,$,ot,it,M,z,H,B,at,st,ct]);var ft=e.useCallback((function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return lt.current.run.apply(lt.current,t)}),[]),ht=e.useCallback((function(){return lt.current.refresh()}),[]),pt=e.useCallback((function(){lt.current.cancel(),X.current&&clearTimeout(X.current),Y((function(t){return r(r({},t),{loading:!1})}))}),[]);return V((function(){u&&k(s)&&s.length>0&&ht()}),[u].concat(s)),e.useEffect((function(){if(u){var t=k(l)?l:void 0!==l?[l]:[];ft.apply(void 0,t)}return lt.current.resume(),function(){pt(),lt.current.destroy(!1)}}),[]),r(r({},G),{run:ft,cancel:pt,mutate:function(t){Y("function"==typeof t?function(e){return r(r({},e),{data:t(G.data)})}:function(e){return r(r({},e),{data:t})})},refresh:ht})};function ot(t){return"function"==typeof t?t():t}var it=function(t){var n=void 0===t?{}:t,r=n.target,o=n.threshold,i=void 0===o?100:o,u=n.onScrollLower,c=N(void 0===u?function(){}:u),a=e.useCallback((function(){if(r){var t,e=ot(r);if(e)void 0===(t=e)&&(t=window),(T&&t?P(t)?document.documentElement.scrollHeight:t.scrollHeight:0)-function(t){return void 0===t&&(t=window),T&&t?P(t)?window.scrollY:t.scrollTop:0}(e)<=function(t){return void 0===t&&(t=window),T&&t?P(t)?document.documentElement.clientHeight:t.clientHeight:0}(e)+i&&c()}}),[c,r,i]);e.useEffect((function(){if(r){var t=ot(r);if(t)return t.addEventListener("scroll",a),function(){t.removeEventListener("scroll",a)}}}),[r,a])};var ut=function(t){var n=D(t);e.useEffect((function(){return function(){return n.current()}}),[])};function ct(t,n,r){void 0===n&&(n=0),void 0===r&&(r=!1);var o=D(t),i=e.useRef(void 0);return i.current||(i.current=L((function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return o.current.apply(void 0,t)}),n,r)),ut((function(){i.current.cancel()})),{run:i.current,cancel:i.current.cancel,flush:i.current.flush}}function at(t,n,r){void 0===n&&(n=0),void 0===r&&(r=!0);var o=D(t),i=e.useRef(void 0);return i.current||(i.current=I((function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return o.current.apply(void 0,t)}),n,r)),ut((function(){i.current.cancel()})),{run:i.current,cancel:i.current.cancel,flush:i.current.flush}}var st=Z+"_useCacheState";function lt(t){return new B(st,{storage:t})}var ft=function(){var t=e.useRef(!1);return e.useEffect((function(){return t.current=!0,function(){t.current=!1}}),[]),t};function ht(t){var n=F(),r=c(e.useState(t),2),o=r[0],i=r[1];return[o,e.useCallback((function(t){n.current||i(t)}),[])]}function pt(t){return"function"==typeof t?t():"object"==typeof t&&t&&"current"in t?t.current:t}var dt=Object.prototype.hasOwnProperty;var vt=["top","right","bottom","left","width","height","size","weight"],yt={characterData:!0,childList:!0,attributes:!0,subtree:!0},gt=function(t){var e=this;this.refresh=function(){e.targetNode&&e.callback([{target:e.targetNode}],{})},this.onTransitionEnd_=function(t){var n=t.propertyName,r=void 0===n?"":n;vt.some((function(t){return r.indexOf(t)>-1}))&&e.throttleRefresh()},this.observe=function(t,n){T&&(e.targetNode=t,document.addEventListener("transitionend",e.onTransitionEnd_),window.addEventListener("resize",e.throttleRefresh),e.observer.observe(document,r(r({},yt),n)))},this.disconnect=function(){T&&(e.throttleRefresh.cancel(),e.targetNode=null,document.removeEventListener("transitionend",e.onTransitionEnd_),window.removeEventListener("resize",e.throttleRefresh),e.observer.disconnect())},this.throttleRefresh=I(this.refresh,50),this.targetNode=null,this.callback=t,this.observer=new MutationObserver(this.throttleRefresh)};t.clearCache=function(t){t?tt.cache.del(t):tt.cache.clear()},t.clearCacheState=function(t,e){var n=lt(t);e?n.del(e):n.clear()},t.useAsync=rt,t.useCacheState=function(t,n,r){void 0===r&&(r={});var o=r.ttl,i=r.storage,u=e.useMemo((function(){return lt(i)}),[i]),a=c(e.useState((function(){var e=u.get(t);return O(e)?n:e})),2),s=a[0],l=a[1];return[s,e.useCallback((function(e){l((function(n){var r=e instanceof Function?e(n):e;return u.set(t,r,o),r}))}),[u,t,o])]},t.useClickAway=function(t,n,r){void 0===r&&(r="click");var o=j(t),i=D(o),u=o.every((function(t){return"function"==typeof t})),c=u?i:o,a=D(n),s=j(r),l=D(s),f=s.join("");e.useEffect((function(){var t=function(t){var e;(u?c.current:c).some((function(e){var n=pt(e);return!n||(null==n?void 0:n.contains(t.target))}))||null===(e=a.current)||void 0===e||e.call(a,t)},e=j(l.current);return e.forEach((function(e){document.addEventListener(e,t)})),function(){e.forEach((function(e){document.removeEventListener(e,t)}))}}),[c,u,f])},t.useControllableValue=function(t,n){void 0===t&&(t={}),void 0===n&&(n={});var r=n.defaultValue,o=n.defaultValuePropName,i=void 0===o?"defaultValue":o,u=n.valuePropName,a=void 0===u?"value":u,s=n.trigger,l=void 0===s?"onChange":s,f=dt.call(t,a),h=c(e.useState((function(){return f?t[a]:dt.call(t,i)?t[i]:r})),2),p=h[0],d=h[1],v=e.useCallback((function(e){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];f||d(e),t[l]&&t[l].apply(t,[e].concat(n))}),[f,t,l]);return[f?t[a]:p,v]},t.useDebounce=function(t,n,r){void 0===n&&(n=0),void 0===r&&(r=!1);var o=c(e.useState(t),2),i=o[0],u=ct(o[1],n,r).run;return e.useEffect((function(){u(t)}),[u,t]),i},t.useDebounceFn=ct,t.useLatest=D,t.useLimitList=function(t,n){void 0===n&&(n={});var r=n||{},o=r.count,i=void 0===o?3:o,u=r.defaultLimited,a=void 0===u||u,s=c(e.useState(a),2),l=s[0],f=s[1],h=e.useMemo((function(){return k(t)&&t.length>i?l?t.slice(0,i):t:t||[]}),[l,t,i]);return{limited:l,canLimit:k(t)&&t.length>i,data:h,toggle:function(){f(!l)}}},t.useLoadMore=function(t,n){var a=this,s=n||{},l=s.threshold,f=void 0===l?100:l,h=s.target,p=s.isNoMore,d=void 0===p?function(){return!1}:p,v=s.refreshDeps,y=void 0===v?[]:v,g=s.autoRun,m=void 0===g||g,b=o(s,["threshold","target","isNoMore","refreshDeps","autoRun"]),w=e.useRef([]),_=e.useRef(1),S=rt(t,r(r({defaultParams:[{current:_.current}],autoRun:m},b),{onError:function(t,e){var n;_.current>1&&(_.current-=1),null===(n=null==b?void 0:b.onError)||void 0===n||n.call(b,t,e)},__INTERNAL_FORMAT__:function(t){return w.current=1===_.current?t.list:w.current.concat(t.list),r(r({},t),{list:w.current})}})),E=S.run,T=S.data,O=S.loading,C=S.cancel,L=S.params,R=S.mutate,I=o(S,["run","data","loading","cancel","params","mutate"]),P=!!d&&(!O&&d(T)),j=c(L||[]),x=j[0],D=j.slice(1),N=e.useCallback((function(){return E.apply(void 0,[{current:_.current}].concat(D))}),[D,E]),F=e.useCallback((function(){O&&_.current>1&&(_.current-=1),C()}),[C,O]),A=e.useCallback((function(){return i(a,void 0,void 0,(function(){return u(this,(function(t){return O||P?[2]:(_.current+=1,[2,N()])}))}))}),[O,P,N]),M=e.useCallback((function(t){var e="function"==typeof t?t(T):t;w.current=(null==e?void 0:e.list)||[],R(e)}),[T,R]),W=e.useCallback((function(){return F(),_.current=1,M((function(t){return r(r({},t),{list:[]})})),N()}),[F,N,M]),z=e.useCallback((function(){if(!O&&h)return A()}),[A,h,O]);return it({target:h,threshold:f,onScrollLower:z}),V((function(){m&&k(y)&&y.length>0&&W()}),y),r(r({},I),{loading:O,data:T,run:E,refresh:W,cancel:F,mutate:M,params:[r(r({},x),{current:_.current})].concat(D),loadMore:A,loadingMore:O&&_.current>1,noMore:P})},t.useMount=function(t){e.useEffect((function(){t()}),[])},t.useMountedRef=ft,t.usePagination=function(t,n){var i=n||{},u=i.defaultPageSize,a=void 0===u?10:u,s=i.refreshDeps,l=void 0===s?[]:s,f=i.defaultParams,h=i.autoRun,p=void 0===h||h,d=o(i,["defaultPageSize","refreshDeps","defaultParams","autoRun"]),v=e.useMemo((function(){return f||[{current:1,pageSize:a}]}),[a,f]),y=rt(t,r({defaultParams:v,autoRun:p},d)),g=y.run,m=y.data,b=y.params,w=y.loading,_=o(y,["run","data","params","loading"]),S=b&&b[0]?b[0]:v[0],E=S.current,T=S.pageSize,O=(null==m?void 0:m.total)||0,C=e.useCallback((function(t){var e=c(b),n=e[0],o=e.slice(1);return g.apply(void 0,[r(r({},n),t)].concat(o))}),[b,g]),L=e.useCallback((function(){return C({current:E,pageSize:T})}),[C,E,T]),R=e.useCallback((function(t,e){var n=t<=0?1:t,r=e<=0?1:e,o=Math.ceil(O/r);n>o&&o>0&&(n=o),C({current:n,pageSize:r})}),[C,O]),I=e.useCallback((function(t){R(t,T)}),[R,T]),P=e.useCallback((function(t){R(E,t)}),[E,R]),j=e.useCallback((function(t,e,n,r){C({current:null==t?void 0:t.current,pageSize:null==t?void 0:t.pageSize,filters:e,sorter:n,extra:r})}),[C]);return V((function(){p&&k(l)&&l.length>0&&I(1)}),l),r(r({},_),{data:m,run:g,refresh:L,loading:w,params:b,pagination:{current:E,pageSize:T,total:O,onChange:R,changeCurrent:I,changePageSize:P},tableProps:{dataSource:(null==m?void 0:m.list)||[],loading:w,onChange:j,pagination:{total:O,current:E,pageSize:T}}})},t.usePersistFn=N,t.usePrevious=function(t){var n=ft(),r=e.useRef(void 0),o=e.useRef(t);return n.current&&o.current!==t&&(r.current=o.current,o.current=t),r.current},t.useSafeState=ht,t.useSetState=function(t){var n=c(e.useState(t),2),o=n[0],i=n[1];return[o,e.useCallback((function(t){i((function(e){var n=t instanceof Function?t(e):t;return n instanceof Object?r(r({},e),n):e}))}),[])]},t.useSize=function(t){var n=D(t),r=c(e.useState((function(){var e=pt(t);return{width:null==e?void 0:e.clientWidth,height:null==e?void 0:e.clientHeight}})),2),o=r[0],i=r[1],u=D(o);return e.useEffect((function(){var t=pt(n.current);function e(t){var e=null==t?void 0:t.clientWidth,n=null==t?void 0:t.clientHeight;e===u.current.width&&n===u.current.height||i({width:e,height:n})}if(!t)return function(){};e(t);var r=new gt((function(t){t.forEach((function(t){e(t.target)}))}));return r.observe(t),function(){r.disconnect()}}),[n,u]),o},t.useThrottle=function(t,n,r){void 0===n&&(n=0),void 0===r&&(r=!0);var o=c(e.useState(t),2),i=o[0],u=at(o[1],n,r).run;return e.useEffect((function(){u(t)}),[u,t]),i},t.useThrottleFn=at,t.useUnmount=ut,t.useUnmountedRef=F,t.useUpdate=function(){var t=c(ht(0),2)[1];return e.useCallback((function(){t((function(t){return t+1}))}),[])},t.useUpdateEffect=V,t.useUpdateLayoutEffect=function(t,n){var r=e.useRef(!1);e.useLayoutEffect((function(){if(r.current)return t();r.current=!0}),n)}}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).rcHooks={},t.React)}(this,(function(t,e){"use strict";var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},n(t,e)};var r=function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)};function o(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n}function i(t,e,n,r){return new(n||(n=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(u,c)}a((r=r.apply(t,e||[])).next())}))}function u(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return u.next=c(0),u.throw=c(1),u.return=c(2),"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function c(c){return function(a){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;u&&(u=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=e.call(t,i)}catch(t){c=[6,t],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}}function c(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)u.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return u}"function"==typeof SuppressedError&&SuppressedError;var a=void 0,s="undefined",l=Object.prototype,f=l.toString,h=l.hasOwnProperty,p="[object ",d=p+"String]",v=p+"Symbol]",y=p+"Window]";function m(t){return null!==t&&"object"==typeof t}function g(t){return f.call(t)}var b=/^0b[01]+$/i,w=/^0o[0-7]+$/i,E=/^[-+]0x[0-9a-f]+$/i;function _(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||g(t)===v}(t))return NaN;if(function(t){return"function"==typeof t||m(t)}(t)&&(t=Number(t)),"string"!=typeof t)return 0===t?t:+t;t=t.trim();var e=b.test(t);return e||w.test(t)?parseInt(t.slice(2),e?2:8):E.test(t)?NaN:+t}function S(t){return Array.isArray(t)}function k(t,e,n){return void 0===n&&(n=!1),t===e?!n||(0!==t||1/t==1/e):t!=t&&e!=e}var T=typeof window!==s&&m(window)&&typeof document!==s&&m(document)&&window.document===document;g(function(){return arguments}());function O(t){return t===a}function C(t,e,n,r){if(void 0===r&&(r=!1),"function"!=typeof t)throw new TypeError("Expected a function");var o,i,u,c,s,l,f,h;function p(e){return u=e,l=t.apply(s,c),s=c=a,l}function d(){for(var t=[],f=0;f<arguments.length;f++)t[f]=arguments[f];s=this,c=t;var h=Date.now(),d=function(t){if(i===a)return!0;var n=t-i;return n>=e||n<0||r&&t-u>=e}(h),v=r?d||i===a||o!==a?e:e-(h-i):e;return i=h,d&&n&&o===a?p(h):(o===a||r||(clearTimeout(o),o=a),o===a&&(o=setTimeout((function(){o=a,p(Date.now())}),v)),l)}return f=_(e),h=0,e=null==f||f!=f?h:f,d.cancel=function(){o!==a&&(clearTimeout(o),o=a),i=o=c=s=a},d.flush=function(){return o!==a?(clearTimeout(o),o=a,p(Date.now())):l},d.pending=function(){return o!==a},d}function L(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=!1),C(t,e,n)}function R(t,e){var n=!1;return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];n||(n=!0,t.apply(void 0,function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))}([],c(r),!1)),setTimeout((function(){n=!1}),e))}}function x(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=!0),C(t,e,n,!0)}function F(t){return m(t)&&g(t)===y}function I(t){return arguments.length?S(t)?t:[t]:[]}function P(){}function j(t){var n=e.useRef(t);return n.current=t,n}function D(t){var n=j(t),r=e.useCallback((function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=n.current;return null==r?void 0:r.apply(void 0,t)}),[]);return r}var N=function(t,n){var r=e.useRef(!1);e.useEffect((function(){if(r.current)return t();r.current=!0}),n)},V=function(){var t=e.useRef(!1);return e.useEffect((function(){return t.current=!1,function(){t.current=!0}}),[]),t},z=function(){function t(){this.handlers={}}return t.prototype.eventNames=function(){var t,e=(null===(t=Object.getOwnPropertySymbols)||void 0===t?void 0:t.call(Object,this.handlers))||[];return Object.keys(this.handlers).concat(e)},t.prototype.rawListeners=function(t){var e=this.handlers[t];return e?e.map((function(t){return t.raw})):[]},t.prototype.listeners=function(t){var e=this.handlers[t];return e?e.map((function(t){return t.wrap})):[]},t.prototype.hasListener=function(t,e){return this.rawListeners(t).some((function(t){return t===e}))},t.prototype._on=function(t,e,n,r,o){void 0===r&&(r=null),void 0===o&&(o=1);var i={raw:e,wrap:n,context:r};if(this.handlers[t]){var u=1===o?"push":"unshift";this.handlers[t][u](i)}else this.handlers[t]=[i];return this},t.prototype.prependListener=function(t,e,n){return this._on(t,e,e,n,0)},t.prototype.on=function(t,e,n){return this._on(t,e,e,n)},t.prototype._wrapOnce=function(t,e,n){var r=this;void 0===n&&(n=null);var o=function(){for(var i=[],u=0;u<arguments.length;u++)i[u]=arguments[u];e.apply(n,i),r.off(t,o)};return o},t.prototype.once=function(t,e,n){var r=this._wrapOnce(t,e,n);return this._on(t,e,r,n)},t.prototype.prependOnceListener=function(t,e,n){var r=this._wrapOnce(t,e,n);return this._on(t,e,r,n,0)},t.prototype.off=function(t,e){var n=this.handlers[t];if(n)if(e){var r=n.findIndex((function(t){return t.wrap===e||t.raw===e}));-1!==r&&n.splice(r,1)}else delete this.handlers[t];return this},t.prototype.offAll=function(){return this.handlers={},this},t.prototype.emit=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var r=this.handlers[t];return!!(r&&r.length>0)&&(r.forEach((function(t){t.wrap.apply(t.context,e)})),!0)},t}(),M="cache2",A="".concat(M,"_"),W="default";var K={},H=function(){function t(t){void 0===t&&(t=W),this.scope=t,K[this.scope]||(K[this.scope]={}),this.data=K[this.scope]}return t.prototype.getItem=function(t){return t in this.data?this.data[t]:null},t.prototype.setItem=function(t,e){this.data[t]=e},t.prototype.removeItem=function(t){delete this.data[t]},t.prototype.clear=function(){K[this.scope]={},this.data=K[this.scope]},t}(),U=function(){function t(t,e){void 0===e&&(e={});var n=!!t&&function(t){try{var e="object"==typeof t&&null!==t&&!!t.setItem&&!!t.getItem&&!!t.removeItem;if(e){var n=Math.random().toString(16).substring(2,8),r="___".concat(M,"_test_").concat(n,"_").concat(Date.now(),"___");t.setItem(r,"1"),t.removeItem(r)}return e}catch(t){return console.error("[".concat(M,"] Storage operation failed:"),t instanceof Error?t.message:t),console.warn("[".concat(M,"] The default memory cache will be used.")),!1}}(t);this.options=r({needParsed:n,prefix:""},e),this.storage=n?t:new H(this.options.memoryScope)}return t.prototype.getKey=function(t){return this.options.prefix+t},t.prototype.get=function(t){var e=this.storage.getItem(this.getKey(t));return this.options.needParsed?function(t,e){try{return JSON.parse(t,e)}catch(e){return console.warn("[".concat(M,"] JSON parse failed, returning original value:"),e instanceof Error?e.message:e),t}}(e,this.options.reviver):e},t.prototype.set=function(t,e){this.storage.setItem(this.getKey(t),this.options.needParsed?function(t,e){try{return JSON.stringify(t,e)}catch(t){throw console.error("[".concat(M,"] JSON stringify failed:"),t instanceof Error?t.message:t),t}}(e,this.options.replacer):e)},t.prototype.del=function(t){this.storage.removeItem(this.getKey(t))},t.prototype.clear=function(){"function"==typeof this.storage.clear&&this.storage.clear()},t}(),q=function(t){function e(e,n){var o,i=t.call(this)||this,u=W;return"string"==typeof e?u=e||W:"object"==typeof e&&(o=e),o||"object"!=typeof n||(o=n),i.options=r({max:-1,stdTTL:0,maxStrategy:"limited",checkperiod:0,prefix:A},o),i.storage=new U(i.options.storage,r({memoryScope:u},i.options)),i.cacheKey=u,i.startCheckperiod(),i}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}(e,t),e.prototype._check=function(t,e){var n=!0;return 0!==e.t&&e.t<Date.now()&&(n=!1,this.del(t),this.emit("expired",t,e.v)),n},e.prototype._wrap=function(t,e){var n=Date.now(),r="number"==typeof e?e:this.options.stdTTL;return{v:t,t:r>0?n+r:0,n:n}},e.prototype._isLimited=function(t){return this.options.max>-1&&t>=this.options.max},e.prototype._getReplaceKey=function(t,e){var n=t[0];return t.forEach((function(t){e[n].n>e[t].n&&(n=t)})),n},Object.defineProperty(e.prototype,"cacheValues",{get:function(){return this.storage.get(this.cacheKey)||{}},enumerable:!1,configurable:!0}),e.prototype.setCacheValues=function(t){this.storage.set(this.cacheKey,t)},e.prototype._getData=function(t,e){var n=e[t];if(n&&this._check(t,n))return n},e.prototype.get=function(t){var e=this._getData(t,this.cacheValues);return null==e?void 0:e.v},e.prototype.mget=function(t){var e=this,n={};if(!Array.isArray(t))return n;var r=this.cacheValues;return t.forEach((function(t){var o=e._getData(t,r);o&&(n[t]=o.v)})),n},e.prototype.getAll=function(){var t=Object.keys(this.cacheValues);return this.mget(t)},e.prototype.set=function(t,e,n){if(0===this.options.max)return!1;var r=this.cacheValues,o=Object.keys(r);if(!r[t]&&this._isLimited(o.length)){var i=this.keys();if(this._isLimited(i.length)){if("replaced"!==this.options.maxStrategy)return!1;var u=this._getReplaceKey(i,r);this.del(u)}}return r[t]=this._wrap(e,n),this.setCacheValues(r),this.emit("set",t,r[t].v),!0},e.prototype.mset=function(t){var e=this,n=!0;return t.forEach((function(t){var r=e.set(t.key,t.value,t.ttl);n&&!r&&(n=!1)})),n},e.prototype.del=function(t){var e=this,n=this.cacheValues,r=0;return(Array.isArray(t)?t:[t]).forEach((function(t){if(n[t]){r++;var o=n[t];delete n[t],e.emit("del",t,o.v)}})),r>0&&this.setCacheValues(n),r},e.prototype.clear=function(){this.storage.del(this.cacheKey)},e.prototype.keys=function(){var t=this,e=this.cacheValues;return Object.keys(e).filter((function(n){return t._check(n,e[n])}))},e.prototype.has=function(t){return!!this._getData(t,this.cacheValues)},e.prototype.take=function(t){var e,n=this._getData(t,this.cacheValues);return n&&(e=n.v,this.del(t)),e},e.prototype.ttl=function(t,e){var n=this._getData(t,this.cacheValues);return!!n&&this.set(t,n.v,e)},e.prototype.getTtl=function(t){var e=this._getData(t,this.cacheValues);return null==e?void 0:e.t},e.prototype.getLastModified=function(t){var e=this._getData(t,this.cacheValues);return null==e?void 0:e.n},e.prototype.startCheckperiod=function(){var t=this;this.keys(),this.options.checkperiod>0&&(clearTimeout(this._checkTimeout),this._checkTimeout=setTimeout((function(){t.startCheckperiod()}),this.options.checkperiod))},e.prototype.stopCheckperiod=function(){clearTimeout(this._checkTimeout)},e}(z),B=function(){function t(t,e){void 0===e&&(e="uh_async_memo"),this.promiseCache={},this.cache=new q(e,t)}return t.prototype.run=function(t,e,n){var o,i=this;if(!e||"string"!=typeof(o=e)&&g(o)!==d)return t();var u=r({persisted:!0},n);if(u.persisted){var c=this.cache.get(e);if(c)return Promise.resolve(c)}return this.promiseCache[e]||(this.promiseCache[e]=t().then((function(t){return delete i.promiseCache[e],i.cache.set(e,t,u.ttl),t})).catch((function(t){return delete i.promiseCache[e],Promise.reject(t)}))),this.promiseCache[e]},t}();function J(){return"undefined"==typeof document||void 0===document.visibilityState||"hidden"!==document.visibilityState}var $=[];var G=!1;if("undefined"!=typeof window&&window.addEventListener&&!G){window.addEventListener("visibilitychange",(function(){if(J())for(var t=0;t<$.length;t++){(0,$[t])()}}),!1),G=!0}var Y=[];var Q=!1;if("undefined"!=typeof window&&window.addEventListener&&!Q){var X=function(){if(J()&&("undefined"==typeof navigator||void 0===navigator.onLine||navigator.onLine))for(var t=0;t<Y.length;t++){(0,Y[t])()}};window.addEventListener("visibilitychange",X,!1),window.addEventListener("focus",X,!1),Q=!0}var Z="rc-hooks",tt=new B({prefix:Z,stdTTL:3e5});function et(t){return tt.cache.get(t)}var nt=function(){function t(t,e){this.params=[],this.pollingWhenVisibleFlag=!1,this.pollingTimer=null,this.counter=1,this.destroyed=!1,this.async=t,this.options=r({cacheTime:3e5,persisted:!1,pollingWhenHidden:!0,refreshOnWindowFocus:!1,focusTimespan:5e3},e),this.unsubscribes=[],this.init()}return t.prototype.init=function(){var t,e=this.options,n=e.pollingInterval,r=e.refreshOnWindowFocus,o=e.focusTimespan;if(this.updateDebounce(),n&&this.unsubscribes.push((t=this.rePolling.bind(this),$.push(t),function(){var e=$.indexOf(t);$.splice(e,1)})),r){var i=R(this.refresh.bind(this),o);this.unsubscribes.push(function(t){return Y.push(t),function(){var e=Y.indexOf(t);Y.splice(e,1)}}(i))}},t.prototype.updateDebounce=function(){var t=this.options,e=t.debounceInterval,n=t.throttleInterval;this.debounce="number"==typeof e&&e>0?L(this._wraprun,e):void 0,this.throttle="number"==typeof n&&n>0?x(this._wraprun,n):void 0},t.prototype.rePolling=function(){this.pollingWhenVisibleFlag&&(this.pollingWhenVisibleFlag=!1,this.refresh())},t.prototype.afterUpdateOptions=function(t,e){void 0===e&&(e={}),("debounceInterval"in e&&e.debounceInterval!==t.debounceInterval||"throttleInterval"in e&&e.throttleInterval!==t.throttleInterval)&&this.updateDebounce()},t.prototype.updateOptions=function(t){var e=this.options,n=r(r({},this.options),t);this.options=n,this.afterUpdateOptions(e,n)},t.prototype._run=function(){for(var t=this,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];this.pollingTimer&&clearTimeout(this.pollingTimer);var r=this.counter;this.params=e;var o=this.options,i=o.cacheKey,u=o.cacheTime,c=o.persisted,a=o.formatResult,s=o.onSuccess,l=o.onError,f=o.onFinally,h=o.onBefore,p=o.pollingWhenHidden,d=o.pollingInterval;return null==h||h(e),new Promise((function(n,o){tt.run((function(){return t.async.apply(t,e).then((function(t){return"function"==typeof a?a(t,e):t}))}),i,{persisted:c,ttl:u}).then((function(o){r===t.counter&&(null==s||s(o,e),n(o))})).catch((function(n){r===t.counter&&(null==l||l(n,e),o(n))})).finally((function(){if(r===t.counter&&(null==f||f(),d)){if(!J()&&!p)return void(t.pollingWhenVisibleFlag=!0);t.pollingTimer=setTimeout((function(){t.run.apply(t,e)}),d)}}))}))},t.prototype._wraprun=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return this.counter+=1,this._run.apply(this,t)},t.prototype.run=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return this.debounce?(this.debounce.apply(this,t),Promise.resolve(null)):this.throttle?(this.throttle.apply(this,t),Promise.resolve(null)):this._wraprun.apply(this,t)},t.prototype.refresh=function(){return this.run.apply(this,this.params)},t.prototype.cancel=function(){this.debounce&&this.debounce.cancel(),this.throttle&&this.throttle.cancel(),this.pollingTimer&&(clearTimeout(this.pollingTimer),this.pollingTimer=null),this.counter+=1},t.prototype.destroy=function(t){void 0===t&&(t=!0),t&&this.cancel(),this.destroyed||(this.destroyed=!0,this.unsubscribes.forEach((function(t){return t()})),this.unsubscribes=[])},t.prototype.resume=function(){this.destroyed&&(this.destroyed=!1,this.init())},t}(),rt=function(t,n){var o=n||{},i=o.autoRun,u=void 0===i||i,a=o.refreshDeps,s=void 0===a?[]:a,l=o.defaultParams,f=o.loadingDelay,p=o.__INTERNAL_FORMAT__,d=o.defaultLoading,v=o.initialData,y=o.cacheKey,m=void 0===y?"":y,g=o.cacheTime,b=void 0===g?3e5:g,w=o.persisted,E=void 0!==w&&w,_=o.onSuccess,T=void 0===_?P:_,C=o.onError,L=void 0===C?P:C,R=o.onFinally,x=void 0===R?P:R,F=o.onBefore,I=void 0===F?P:F,z=o.pollingInterval,M=void 0===z?0:z,A=o.pollingWhenHidden,W=void 0===A||A,K=o.refreshOnWindowFocus,H=void 0!==K&&K,U=o.focusTimespan,q=void 0===U?5e3:U,B=o.debounceInterval,J=o.throttleInterval,$=c(e.useState((function(){return{params:[],loading:!!(O(d)?u&&!f:d),error:null,data:m?et(m):v}})),2),G=$[0],Y=$[1],Q=V(),X=e.useRef(null),Z=D(t),tt=D(T),rt=D(L),ot=D(x),it=D(I),ut=j(p),ct=e.useCallback((function(t){it(t),X.current&&clearTimeout(X.current),(m?et(m):void 0)&&E||(Y((function(e){var n=!function(t,e,n){if(void 0===n&&(n=!0),k(t,e,n))return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;var r=Object.keys(t),o=Object.keys(e);if(r.length!==o.length)return!1;for(var i=0;i<r.length;i++){var u=r[i];if(!h.call(e,u)||!k(t[u],e[u],n))return!1}return!0}(e.params,t);return e.loading!==!f||n?r(r({},e),{loading:!f,params:t}):e})),f&&(X.current=setTimeout((function(){Q.current||Y((function(t){return r(r({},t),{loading:!0})}))}),f)))}),[m,f,it,E,Q]),at=e.useCallback((function(t,e){X.current&&clearTimeout(X.current),Y((function(e){return r(r({},e),{data:t,error:null,loading:!1})})),tt(t,e)}),[tt]),st=e.useCallback((function(t,e){X.current&&clearTimeout(X.current),Y((function(e){return r(r({},e),{error:t,loading:!1})})),rt(t,e)}),[rt]),lt=e.useRef(void 0);lt.current||(lt.current=new nt(Z,{cacheKey:m,cacheTime:b,persisted:E,formatResult:ut.current,onSuccess:at,onError:st,onFinally:ot,onBefore:ct,debounceInterval:B,throttleInterval:J,pollingInterval:M,pollingWhenHidden:W,refreshOnWindowFocus:H,focusTimespan:q})),N((function(){lt.current.updateOptions({cacheKey:m,cacheTime:b,persisted:E,formatResult:ut.current,onSuccess:at,onError:st,onFinally:ot,onBefore:ct,debounceInterval:B,throttleInterval:J,pollingInterval:M,pollingWhenHidden:W,refreshOnWindowFocus:H,focusTimespan:q})}),[tt,rt,m,b,E,B,J,ot,it,M,W,H,q,at,st,ct]);var ft=e.useCallback((function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return lt.current.run.apply(lt.current,t)}),[]),ht=e.useCallback((function(){return lt.current.refresh()}),[]),pt=e.useCallback((function(){lt.current.cancel(),X.current&&clearTimeout(X.current),Y((function(t){return r(r({},t),{loading:!1})}))}),[]);return N((function(){u&&S(s)&&s.length>0&&ht()}),[u].concat(s)),e.useEffect((function(){if(u){var t=S(l)?l:void 0!==l?[l]:[];ft.apply(void 0,t)}return lt.current.resume(),function(){pt(),lt.current.destroy(!1)}}),[]),r(r({},G),{run:ft,cancel:pt,mutate:function(t){Y("function"==typeof t?function(e){return r(r({},e),{data:t(G.data)})}:function(e){return r(r({},e),{data:t})})},refresh:ht})};function ot(t){return"function"==typeof t?t():t}var it=function(t){var n=void 0===t?{}:t,r=n.target,o=n.threshold,i=void 0===o?100:o,u=n.onScrollLower,c=D(void 0===u?function(){}:u),a=e.useCallback((function(){if(r){var t,e=ot(r);if(e)void 0===(t=e)&&(t=window),(T&&t?F(t)?document.documentElement.scrollHeight:t.scrollHeight:0)-function(t){return void 0===t&&(t=window),T&&t?F(t)?window.scrollY:t.scrollTop:0}(e)<=function(t){return void 0===t&&(t=window),T&&t?F(t)?document.documentElement.clientHeight:t.clientHeight:0}(e)+i&&c()}}),[c,r,i]);e.useEffect((function(){if(r){var t=ot(r);if(t)return t.addEventListener("scroll",a),function(){t.removeEventListener("scroll",a)}}}),[r,a])};var ut=function(t){var n=j(t);e.useEffect((function(){return function(){return n.current()}}),[])};function ct(t,n,r){void 0===n&&(n=0),void 0===r&&(r=!1);var o=j(t),i=e.useRef(void 0);return i.current||(i.current=L((function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return o.current.apply(void 0,t)}),n,r)),ut((function(){i.current.cancel()})),{run:i.current,cancel:i.current.cancel,flush:i.current.flush}}function at(t,n,r){void 0===n&&(n=0),void 0===r&&(r=!0);var o=j(t),i=e.useRef(void 0);return i.current||(i.current=x((function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return o.current.apply(void 0,t)}),n,r)),ut((function(){i.current.cancel()})),{run:i.current,cancel:i.current.cancel,flush:i.current.flush}}var st=Z+"_useCacheState";function lt(t){return new q(st,{storage:t})}var ft=function(){var t=e.useRef(!1);return e.useEffect((function(){return t.current=!0,function(){t.current=!1}}),[]),t};function ht(t){var n=V(),r=c(e.useState(t),2),o=r[0],i=r[1];return[o,e.useCallback((function(t){n.current||i(t)}),[])]}function pt(t){return"function"==typeof t?t():"object"==typeof t&&t&&"current"in t?t.current:t}var dt=Object.prototype.hasOwnProperty;var vt=["top","right","bottom","left","width","height","size","weight"],yt={characterData:!0,childList:!0,attributes:!0,subtree:!0},mt=function(t){var e=this;this.refresh=function(){e.targetNode&&e.callback([{target:e.targetNode}],{})},this.onTransitionEnd_=function(t){var n=t.propertyName,r=void 0===n?"":n;vt.some((function(t){return r.indexOf(t)>-1}))&&e.throttleRefresh()},this.observe=function(t,n){T&&(e.targetNode=t,document.addEventListener("transitionend",e.onTransitionEnd_),window.addEventListener("resize",e.throttleRefresh),e.observer.observe(document,r(r({},yt),n)))},this.disconnect=function(){T&&(e.throttleRefresh.cancel(),e.targetNode=null,document.removeEventListener("transitionend",e.onTransitionEnd_),window.removeEventListener("resize",e.throttleRefresh),e.observer.disconnect())},this.throttleRefresh=x(this.refresh,50),this.targetNode=null,this.callback=t,this.observer=new MutationObserver(this.throttleRefresh)};t.clearCache=function(t){t?tt.cache.del(t):tt.cache.clear()},t.clearCacheState=function(t,e){var n=lt(t);e?n.del(e):n.clear()},t.useAsync=rt,t.useCacheState=function(t,n,r){void 0===r&&(r={});var o=r.ttl,i=r.storage,u=e.useMemo((function(){return lt(i)}),[i]),a=c(e.useState((function(){var e=u.get(t);return O(e)?n:e})),2),s=a[0],l=a[1];return[s,e.useCallback((function(e){l((function(n){var r=e instanceof Function?e(n):e;return u.set(t,r,o),r}))}),[u,t,o])]},t.useClickAway=function(t,n,r){void 0===r&&(r="click");var o=I(t),i=j(o),u=o.every((function(t){return"function"==typeof t})),c=u?i:o,a=j(n),s=I(r),l=j(s),f=s.join("");e.useEffect((function(){var t=function(t){var e;(u?c.current:c).some((function(e){var n=pt(e);return!n||(null==n?void 0:n.contains(t.target))}))||null===(e=a.current)||void 0===e||e.call(a,t)},e=I(l.current);return e.forEach((function(e){document.addEventListener(e,t)})),function(){e.forEach((function(e){document.removeEventListener(e,t)}))}}),[c,u,f])},t.useControllableValue=function(t,n){void 0===t&&(t={}),void 0===n&&(n={});var r=n.defaultValue,o=n.defaultValuePropName,i=void 0===o?"defaultValue":o,u=n.valuePropName,a=void 0===u?"value":u,s=n.trigger,l=void 0===s?"onChange":s,f=dt.call(t,a),h=c(e.useState((function(){return f?t[a]:dt.call(t,i)?t[i]:r})),2),p=h[0],d=h[1],v=e.useCallback((function(e){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];f||d(e),t[l]&&t[l].apply(t,[e].concat(n))}),[f,t,l]);return[f?t[a]:p,v]},t.useDebounce=function(t,n,r){void 0===n&&(n=0),void 0===r&&(r=!1);var o=c(e.useState(t),2),i=o[0],u=ct(o[1],n,r).run;return e.useEffect((function(){u(t)}),[u,t]),i},t.useDebounceFn=ct,t.useFullscreen=function(t,n){var r=n||{},o=r.onEnter,i=r.onExit,u=c(e.useState(!1),2),a=u[0],s=u[1],l=j(o),f=j(i),h=function(){var e=t?pt(t):document.documentElement;if(e){var n=e.requestFullscreen||e.webkitRequestFullscreen||e.mozRequestFullScreen||e.msRequestFullscreen;n&&n.call(e)}},p=function(){var t=document.exitFullscreen||document.webkitExitFullscreen||document.mozCancelFullScreen||document.msExitFullscreen;t&&t.call(document)};return e.useEffect((function(){if(T){var t,e=function(){var t=document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement;s(!!t)};if("fullscreenElement"in document)t="fullscreenchange";else if("webkitFullscreenElement"in document)t="webkitfullscreenchange";else if("mozFullScreenElement"in document)t="mozfullscreenchange";else{if(!("msFullscreenElement"in document))return;t="MSFullscreenChange"}return document.addEventListener(t,e),function(){document.removeEventListener(t,e)}}}),[]),N((function(){var t,e;a?null===(t=l.current)||void 0===t||t.call(l):null===(e=f.current)||void 0===e||e.call(f)}),[a]),{isFullscreen:a,enter:h,exit:p,toggle:function(){a?p():h()}}},t.useLatest=j,t.useLimitList=function(t,n){void 0===n&&(n={});var r=n||{},o=r.count,i=void 0===o?3:o,u=r.defaultLimited,a=void 0===u||u,s=c(e.useState(a),2),l=s[0],f=s[1],h=e.useMemo((function(){return S(t)&&t.length>i?l?t.slice(0,i):t:t||[]}),[l,t,i]);return{limited:l,canLimit:S(t)&&t.length>i,data:h,toggle:function(){f(!l)}}},t.useLoadMore=function(t,n){var a=this,s=n||{},l=s.threshold,f=void 0===l?100:l,h=s.target,p=s.isNoMore,d=void 0===p?function(){return!1}:p,v=s.refreshDeps,y=void 0===v?[]:v,m=s.autoRun,g=void 0===m||m,b=o(s,["threshold","target","isNoMore","refreshDeps","autoRun"]),w=e.useRef([]),E=e.useRef(1),_=rt(t,r(r({defaultParams:[{current:E.current}],autoRun:g},b),{onError:function(t,e){var n;E.current>1&&(E.current-=1),null===(n=null==b?void 0:b.onError)||void 0===n||n.call(b,t,e)},__INTERNAL_FORMAT__:function(t){return w.current=1===E.current?t.list:w.current.concat(t.list),r(r({},t),{list:w.current})}})),k=_.run,T=_.data,O=_.loading,C=_.cancel,L=_.params,R=_.mutate,x=o(_,["run","data","loading","cancel","params","mutate"]),F=!!d&&(!O&&d(T)),I=c(L||[]),P=I[0],j=I.slice(1),D=e.useCallback((function(){return k.apply(void 0,[{current:E.current}].concat(j))}),[j,k]),V=e.useCallback((function(){O&&E.current>1&&(E.current-=1),C()}),[C,O]),z=e.useCallback((function(){return i(a,void 0,void 0,(function(){return u(this,(function(t){return O||F?[2]:(E.current+=1,[2,D()])}))}))}),[O,F,D]),M=e.useCallback((function(t){var e="function"==typeof t?t(T):t;w.current=(null==e?void 0:e.list)||[],R(e)}),[T,R]),A=e.useCallback((function(){return V(),E.current=1,M((function(t){return r(r({},t),{list:[]})})),D()}),[V,D,M]),W=e.useCallback((function(){if(!O&&h)return z()}),[z,h,O]);return it({target:h,threshold:f,onScrollLower:W}),N((function(){g&&S(y)&&y.length>0&&A()}),y),r(r({},x),{loading:O,data:T,run:k,refresh:A,cancel:V,mutate:M,params:[r(r({},P),{current:E.current})].concat(j),loadMore:z,loadingMore:O&&E.current>1,noMore:F})},t.useMount=function(t){e.useEffect((function(){t()}),[])},t.useMountedRef=ft,t.usePagination=function(t,n){var i=n||{},u=i.defaultPageSize,a=void 0===u?10:u,s=i.refreshDeps,l=void 0===s?[]:s,f=i.defaultParams,h=i.autoRun,p=void 0===h||h,d=o(i,["defaultPageSize","refreshDeps","defaultParams","autoRun"]),v=e.useMemo((function(){return f||[{current:1,pageSize:a}]}),[a,f]),y=rt(t,r({defaultParams:v,autoRun:p},d)),m=y.run,g=y.data,b=y.params,w=y.loading,E=o(y,["run","data","params","loading"]),_=b&&b[0]?b[0]:v[0],k=_.current,T=_.pageSize,O=(null==g?void 0:g.total)||0,C=e.useCallback((function(t){var e=c(b),n=e[0],o=e.slice(1);return m.apply(void 0,[r(r({},n),t)].concat(o))}),[b,m]),L=e.useCallback((function(){return C({current:k,pageSize:T})}),[C,k,T]),R=e.useCallback((function(t,e){var n=t<=0?1:t,r=e<=0?1:e,o=Math.ceil(O/r);n>o&&o>0&&(n=o),C({current:n,pageSize:r})}),[C,O]),x=e.useCallback((function(t){R(t,T)}),[R,T]),F=e.useCallback((function(t){R(k,t)}),[k,R]),I=e.useCallback((function(t,e,n,r){C({current:null==t?void 0:t.current,pageSize:null==t?void 0:t.pageSize,filters:e,sorter:n,extra:r})}),[C]);return N((function(){p&&S(l)&&l.length>0&&x(1)}),l),r(r({},E),{data:g,run:m,refresh:L,loading:w,params:b,pagination:{current:k,pageSize:T,total:O,onChange:R,changeCurrent:x,changePageSize:F},tableProps:{dataSource:(null==g?void 0:g.list)||[],loading:w,onChange:I,pagination:{total:O,current:k,pageSize:T}}})},t.usePersistFn=D,t.usePrevious=function(t){var n=ft(),r=e.useRef(void 0),o=e.useRef(t);return n.current&&o.current!==t&&(r.current=o.current,o.current=t),r.current},t.useSafeState=ht,t.useSetState=function(t){var n=c(e.useState(t),2),o=n[0],i=n[1];return[o,e.useCallback((function(t){i((function(e){var n=t instanceof Function?t(e):t;return n instanceof Object?r(r({},e),n):e}))}),[])]},t.useSize=function(t){var n=j(t),r=c(e.useState((function(){var e=pt(t);return{width:null==e?void 0:e.clientWidth,height:null==e?void 0:e.clientHeight}})),2),o=r[0],i=r[1],u=j(o);return e.useEffect((function(){var t=pt(n.current);function e(t){var e=null==t?void 0:t.clientWidth,n=null==t?void 0:t.clientHeight;e===u.current.width&&n===u.current.height||i({width:e,height:n})}if(!t)return function(){};e(t);var r=new mt((function(t){t.forEach((function(t){e(t.target)}))}));return r.observe(t),function(){r.disconnect()}}),[n,u]),o},t.useThrottle=function(t,n,r){void 0===n&&(n=0),void 0===r&&(r=!0);var o=c(e.useState(t),2),i=o[0],u=at(o[1],n,r).run;return e.useEffect((function(){u(t)}),[u,t]),i},t.useThrottleFn=at,t.useUnmount=ut,t.useUnmountedRef=V,t.useUpdate=function(){var t=c(ht(0),2)[1];return e.useCallback((function(){t((function(t){return t+1}))}),[])},t.useUpdateEffect=N,t.useUpdateLayoutEffect=function(t,n){var r=e.useRef(!1);e.useLayoutEffect((function(){if(r.current)return t();r.current=!0}),n)}}));
//# sourceMappingURL=rcHooks.min.js.map

@@ -23,4 +23,5 @@ export { default as useAsync } from './useAsync/index.js';

export { default as useControllableValue } from './useControllableValue/index.js';
export { default as useFullscreen } from './useFullscreen/index.js';
export { default as usePersistFn } from './usePersistFn/index.js';
export { default as useSize } from './useSize/index.js';
export { clearCache } from './useAsync/Async.js';
'use strict';
var index$1 = require('./useAsync/index.js');
var index$8 = require('./useLoadMore/index.js');
var index$b = require('./usePagination/index.js');
var index$9 = require('./useLoadMore/index.js');
var index$c = require('./usePagination/index.js');
var index$5 = require('./useDebounceFn/index.js');
var index$4 = require('./useDebounce/index.js');
var index$i = require('./useThrottleFn/index.js');
var index$h = require('./useThrottle/index.js');
var index$j = require('./useThrottleFn/index.js');
var index$i = require('./useThrottle/index.js');
var index = require('./useCacheState/index.js');
var index$6 = require('./useLatest/index.js');
var index$7 = require('./useLimitList/index.js');
var index$f = require('./useSetState/index.js');
var index$d = require('./usePrevious/index.js');
var index$e = require('./useSafeState/index.js');
var index$9 = require('./useMount/index.js');
var index$a = require('./useMountedRef/index.js');
var index$j = require('./useUnmount/index.js');
var index$k = require('./useUnmountedRef/index.js');
var index$l = require('./useUpdate/index.js');
var index$m = require('./useUpdateEffect/index.js');
var index$n = require('./useUpdateLayoutEffect/index.js');
var index$7 = require('./useLatest/index.js');
var index$8 = require('./useLimitList/index.js');
var index$g = require('./useSetState/index.js');
var index$e = require('./usePrevious/index.js');
var index$f = require('./useSafeState/index.js');
var index$a = require('./useMount/index.js');
var index$b = require('./useMountedRef/index.js');
var index$k = require('./useUnmount/index.js');
var index$l = require('./useUnmountedRef/index.js');
var index$m = require('./useUpdate/index.js');
var index$n = require('./useUpdateEffect/index.js');
var index$o = require('./useUpdateLayoutEffect/index.js');
var index$2 = require('./useClickAway/index.js');
var index$3 = require('./useControllableValue/index.js');
var index$c = require('./usePersistFn/index.js');
var index$g = require('./useSize/index.js');
var index$6 = require('./useFullscreen/index.js');
var index$d = require('./usePersistFn/index.js');
var index$h = require('./useSize/index.js');
var Async = require('./useAsync/Async.js');

@@ -32,26 +33,27 @@

exports.useAsync = index$1.default;
exports.useLoadMore = index$8.default;
exports.usePagination = index$b.default;
exports.useLoadMore = index$9.default;
exports.usePagination = index$c.default;
exports.useDebounceFn = index$5.default;
exports.useDebounce = index$4.default;
exports.useThrottleFn = index$i.default;
exports.useThrottle = index$h.default;
exports.useThrottleFn = index$j.default;
exports.useThrottle = index$i.default;
exports.clearCacheState = index.clearCacheState;
exports.useCacheState = index.default;
exports.useLatest = index$6.default;
exports.useLimitList = index$7.default;
exports.useSetState = index$f.default;
exports.usePrevious = index$d.default;
exports.useSafeState = index$e.default;
exports.useMount = index$9.default;
exports.useMountedRef = index$a.default;
exports.useUnmount = index$j.default;
exports.useUnmountedRef = index$k.default;
exports.useUpdate = index$l.default;
exports.useUpdateEffect = index$m.default;
exports.useUpdateLayoutEffect = index$n.default;
exports.useLatest = index$7.default;
exports.useLimitList = index$8.default;
exports.useSetState = index$g.default;
exports.usePrevious = index$e.default;
exports.useSafeState = index$f.default;
exports.useMount = index$a.default;
exports.useMountedRef = index$b.default;
exports.useUnmount = index$k.default;
exports.useUnmountedRef = index$l.default;
exports.useUpdate = index$m.default;
exports.useUpdateEffect = index$n.default;
exports.useUpdateLayoutEffect = index$o.default;
exports.useClickAway = index$2.default;
exports.useControllableValue = index$3.default;
exports.usePersistFn = index$c.default;
exports.useSize = index$g.default;
exports.useFullscreen = index$6.default;
exports.usePersistFn = index$d.default;
exports.useSize = index$h.default;
exports.clearCache = Async.clearCache;
{
"name": "rc-hooks",
"version": "3.3.1",
"version": "3.4.0",
"description": "React Hooks Library.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -58,2 +58,3 @@ # rc-hooks

- [useControllableValue] - 便于管理 `受控/非受控` 状态
- [useFullscreen] - 全屏管理
- [usePersistFn] - 持久化 function

@@ -87,3 +88,4 @@ - [useSize] - 获取并监听 dom 节点的宽高

[usecontrollablevalue]: https://doly-dev.github.io/rc-hooks/latest/index.html#/hooks/use-controllable-value
[usefullscreen]: https://doly-dev.github.io/rc-hooks/latest/index.html#/hooks/use-fullscreen
[npm]: https://img.shields.io/npm/v/rc-hooks.svg
[npm-url]: https://npmjs.com/package/rc-hooks

@@ -26,3 +26,4 @@ export { default as useAsync } from './useAsync';

export { default as useControllableValue } from './useControllableValue';
export { default as useFullscreen } from './useFullscreen';
export { default as usePersistFn } from './usePersistFn';
export { default as useSize } from './useSize';

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display