UNPKG

zjdz-hooks

Version:

Vue3的实用Hooks集合

2 lines (1 loc) 36.9 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("vue"),require("process")):"function"==typeof define&&define.amd?define(["exports","vue","process"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["dz-hooks"]={},t.Vue,t.process)}(this,(function(t,e,n){"use strict";function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}var o=function(){return o=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},o.apply(this,arguments)};function u(t,e,n,r){return new(n||(n=Promise))((function(o,u){function i(t){try{c(r.next(t))}catch(t){u(t)}}function a(t){try{c(r.throw(t))}catch(t){u(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(i,a)}c((r=r.apply(t,e||[])).next())}))}function i(t,e){var n,r,o,u,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return u={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function a(u){return function(a){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,a])}}}function a(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,u=n.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(r=u.next()).done;)i.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=u.return)&&n.call(u)}finally{if(o)throw o.error}}return i}function c(t,e,n){if(n||2===arguments.length)for(var r,o=0,u=e.length;o<u;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))}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var f={exports:{}};!function(t,e){t.exports=function(){var t=1e3,e=6e4,n=36e5,o="millisecond",u="second",i="minute",a="hour",c="day",f="week",l="month",s="quarter",v="year",d="date",h="Invalid Date",p=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,m={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_")},g=function(t,e,n){var r=String(t);return!r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},w={s:g,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),o=n%60;return(e<=0?"+":"-")+g(r,2,"0")+":"+g(o,2,"0")},m:function t(e,n){if(e.date()<n.date())return-t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),o=e.clone().add(r,l),u=n-o<0,i=e.clone().add(r+(u?-1:1),l);return+(-(r+(n-o)/(u?o-i:i-o))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return{M:l,y:v,w:f,d:c,D:d,h:a,m:i,s:u,ms:o,Q:s}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},b="en",O={};O[b]=m;var S=function(t){return t instanceof T},x=function(t,e,n){var r;if(!t)return b;if("string"==typeof t)O[t]&&(r=t),e&&(O[t]=e,r=t);else{var o=t.name;O[o]=t,r=o}return!n&&r&&(b=r),r||!n&&b},$=function(t,e){if(S(t))return t.clone();var n="object"==r(e)?e:{};return n.date=t,n.args=arguments,new T(n)},E=w;E.l=x,E.i=S,E.w=function(t,e){return $(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var T=function(){function r(t){this.$L=x(t.locale,null,!0),this.parse(t)}var m=r.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(E.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match(p);if(r){var o=r[2]-1||0,u=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],o,r[3]||1,r[4]||0,r[5]||0,r[6]||0,u)):new Date(r[1],o,r[3]||1,r[4]||0,r[5]||0,r[6]||0,u)}}return new Date(e)}(t),this.$x=t.x||{},this.init()},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},m.$utils=function(){return E},m.isValid=function(){return!(this.$d.toString()===h)},m.isSame=function(t,e){var n=$(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return $(t)<this.startOf(e)},m.isBefore=function(t,e){return this.endOf(e)<$(t)},m.$g=function(t,e,n){return E.u(t)?this[e]:this.set(n,t)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(t,e){var n=this,r=!!E.u(e)||e,o=E.p(t),s=function(t,e){var o=E.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return r?o:o.endOf(c)},h=function(t,e){return E.w(n.toDate()[t].apply(n.toDate("s"),(r?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},p=this.$W,y=this.$M,m=this.$D,g="set"+(this.$u?"UTC":"");switch(o){case v:return r?s(1,0):s(31,11);case l:return r?s(1,y):s(0,y+1);case f:var w=this.$locale().weekStart||0,b=(p<w?p+7:p)-w;return s(r?m-b:m+(6-b),y);case c:case d:return h(g+"Hours",0);case a:return h(g+"Minutes",1);case i:return h(g+"Seconds",2);case u:return h(g+"Milliseconds",3);default:return this.clone()}},m.endOf=function(t){return this.startOf(t,!1)},m.$set=function(t,e){var n,r=E.p(t),f="set"+(this.$u?"UTC":""),s=(n={},n[c]=f+"Date",n[d]=f+"Date",n[l]=f+"Month",n[v]=f+"FullYear",n[a]=f+"Hours",n[i]=f+"Minutes",n[u]=f+"Seconds",n[o]=f+"Milliseconds",n)[r],h=r===c?this.$D+(e-this.$W):e;if(r===l||r===v){var p=this.clone().set(d,1);p.$d[s](h),p.init(),this.$d=p.set(d,Math.min(this.$D,p.daysInMonth())).$d}else s&&this.$d[s](h);return this.init(),this},m.set=function(t,e){return this.clone().$set(t,e)},m.get=function(t){return this[E.p(t)]()},m.add=function(r,o){var s,d=this;r=Number(r);var h=E.p(o),p=function(t){var e=$(d);return E.w(e.date(e.date()+Math.round(t*r)),d)};if(h===l)return this.set(l,this.$M+r);if(h===v)return this.set(v,this.$y+r);if(h===c)return p(1);if(h===f)return p(7);var y=(s={},s[i]=e,s[a]=n,s[u]=t,s)[h]||1,m=this.$d.getTime()+r*y;return E.w(m,this)},m.subtract=function(t,e){return this.add(-1*t,e)},m.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||h;var r=t||"YYYY-MM-DDTHH:mm:ssZ",o=E.z(this),u=this.$H,i=this.$m,a=this.$M,c=n.weekdays,f=n.months,l=function(t,n,o,u){return t&&(t[n]||t(e,r))||o[n].substr(0,u)},s=function(t){return E.s(u%12||12,t,"0")},v=n.meridiem||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r},d={YY:String(this.$y).slice(-2),YYYY:this.$y,M:a+1,MM:E.s(a+1,2,"0"),MMM:l(n.monthsShort,a,f,3),MMMM:l(f,a),D:this.$D,DD:E.s(this.$D,2,"0"),d:String(this.$W),dd:l(n.weekdaysMin,this.$W,c,2),ddd:l(n.weekdaysShort,this.$W,c,3),dddd:c[this.$W],H:String(u),HH:E.s(u,2,"0"),h:s(1),hh:s(2),a:v(u,i,!0),A:v(u,i,!1),m:String(i),mm:E.s(i,2,"0"),s:String(this.$s),ss:E.s(this.$s,2,"0"),SSS:E.s(this.$ms,3,"0"),Z:o};return r.replace(y,(function(t,e){return e||d[t]||o.replace(":","")}))},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(r,o,d){var h,p=E.p(o),y=$(r),m=(y.utcOffset()-this.utcOffset())*e,g=this-y,w=E.m(this,y);return w=(h={},h[v]=w/12,h[l]=w,h[s]=w/3,h[f]=(g-m)/6048e5,h[c]=(g-m)/864e5,h[a]=g/n,h[i]=g/e,h[u]=g/t,h)[p]||g,d?w:E.a(w)},m.daysInMonth=function(){return this.endOf(l).$D},m.$locale=function(){return O[this.$L]},m.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=x(t,e,!0);return r&&(n.$L=r),n},m.clone=function(){return E.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},r}(),D=T.prototype;return $.prototype=D,[["$ms",o],["$s",u],["$m",i],["$H",a],["$W",c],["$M",l],["$y",v],["$D",d]].forEach((function(t){D[t[1]]=function(e){return this.$g(e,t[0],t[1])}})),$.extend=function(t,e){return t.$i||(t(e,T,$),t.$i=!0),$},$.locale=x,$.isDayjs=S,$.unix=function(t){return $(1e3*t)},$.en=O[b],$.Ls=O,$.p={},$}()}(f);var l=f.exports,s={format:"YYYY-MM-DD HH:mm:ss",method:"format"};var v=function(t,e){var n=function(t,e){var n=null;return function(){for(var r=this,o=[],u=0;u<arguments.length;u++)o[u]=arguments[u];n&&clearTimeout(n),n=setTimeout((function(){t.call.apply(t,c([r],a(o),!1))}),e)}}(t,"number"==typeof e?e:1e3);return{run:n}},d=function(t,e){var n=function(t,e){var n=Date.now();return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];var u=Date.now();u-n<e||(n=u,t.call.apply(t,c([this],a(r),!1)))}}(t,"number"==typeof e?e:1e3);return{run:n}};function h(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function p(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function y(t,e){return y=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},y(t,e)}function m(t,e){if(e&&("object"===r(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function g(t){return g=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},g(t)}function w(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function b(t,e,n){return b=w()?Reflect.construct:function(t,e,n){var r=[null];r.push.apply(r,e);var o=new(Function.bind.apply(t,r));return n&&y(o,n.prototype),o},b.apply(null,arguments)}function O(t){var e="function"==typeof Map?new Map:void 0;return O=function(t){if(null===t||(n=t,-1===Function.toString.call(n).indexOf("[native code]")))return t;var n;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return b(t,arguments,g(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),y(r,t)},O(t)}function S(t,e,n,r,o,u,i){try{var a=t[u](i),c=a.value}catch(t){return void n(t)}a.done?e(c):Promise.resolve(c).then(r,o)}function x(t){return function(){var e=this,n=arguments;return new Promise((function(r,o){var u=t.apply(e,n);function i(t){S(u,r,o,i,a,"next",t)}function a(t){S(u,r,o,i,a,"throw",t)}i(void 0)}))}}function $(t){return function(t){if(Array.isArray(t))return h(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return h(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?h(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function E(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var T={exports:{}};!function(t){var e=function(t){var e,n=Object.prototype,o=n.hasOwnProperty,u="function"==typeof Symbol?Symbol:{},i=u.iterator||"@@iterator",a=u.asyncIterator||"@@asyncIterator",c=u.toStringTag||"@@toStringTag";function f(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{f({},"")}catch(t){f=function(t,e,n){return t[e]=n}}function l(t,e,n,r){var o=e&&e.prototype instanceof m?e:m,u=Object.create(o.prototype),i=new L(r||[]);return u._invoke=function(t,e,n){var r=v;return function(o,u){if(r===h)throw new Error("Generator is already running");if(r===p){if("throw"===o)throw u;return j()}for(n.method=o,n.arg=u;;){var i=n.delegate;if(i){var a=T(i,n);if(a){if(a===y)continue;return a}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(r===v)throw r=p,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r=h;var c=s(t,e,n);if("normal"===c.type){if(r=n.done?p:d,c.arg===y)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(r=p,n.method="throw",n.arg=c.arg)}}}(t,n,i),u}function s(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=l;var v="suspendedStart",d="suspendedYield",h="executing",p="completed",y={};function m(){}function g(){}function w(){}var b={};f(b,i,(function(){return this}));var O=Object.getPrototypeOf,S=O&&O(O(_([])));S&&S!==n&&o.call(S,i)&&(b=S);var x=w.prototype=m.prototype=Object.create(b);function $(t){["next","throw","return"].forEach((function(e){f(t,e,(function(t){return this._invoke(e,t)}))}))}function E(t,e){function n(u,i,a,c){var f=s(t[u],t,i);if("throw"!==f.type){var l=f.arg,v=l.value;return v&&"object"===r(v)&&o.call(v,"__await")?e.resolve(v.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(v).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(f.arg)}var u;this._invoke=function(t,r){function o(){return new e((function(e,o){n(t,r,e,o)}))}return u=u?u.then(o,o):o()}}function T(t,n){var r=t.iterator[n.method];if(r===e){if(n.delegate=null,"throw"===n.method){if(t.iterator.return&&(n.method="return",n.arg=e,T(t,n),"throw"===n.method))return y;n.method="throw",n.arg=new TypeError("The iterator does not provide a 'throw' method")}return y}var o=s(r,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,y;var u=o.arg;return u?u.done?(n[t.resultName]=u.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,y):u:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,y)}function D(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function M(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function L(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(D,this),this.reset(!0)}function _(t){if(t){var n=t[i];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,u=function n(){for(;++r<t.length;)if(o.call(t,r))return n.value=t[r],n.done=!1,n;return n.value=e,n.done=!0,n};return u.next=u}}return{next:j}}function j(){return{value:e,done:!0}}return g.prototype=w,f(x,"constructor",w),f(w,"constructor",g),g.displayName=f(w,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,f(t,c,"GeneratorFunction")),t.prototype=Object.create(x),t},t.awrap=function(t){return{__await:t}},$(E.prototype),f(E.prototype,a,(function(){return this})),t.AsyncIterator=E,t.async=function(e,n,r,o,u){void 0===u&&(u=Promise);var i=new E(l(e,n,r,o),u);return t.isGeneratorFunction(n)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},$(x),f(x,c,"Generator"),f(x,i,(function(){return this})),f(x,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var n in t)e.push(n);return e.reverse(),function n(){for(;e.length;){var r=e.pop();if(r in t)return n.value=r,n.done=!1,n}return n.done=!0,n}},t.values=_,L.prototype={constructor:L,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(M),!t)for(var n in this)"t"===n.charAt(0)&&o.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function r(r,o){return a.type="throw",a.arg=t,n.next=r,o&&(n.method="next",n.arg=e),!!o}for(var u=this.tryEntries.length-1;u>=0;--u){var i=this.tryEntries[u],a=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var c=o.call(i,"catchLoc"),f=o.call(i,"finallyLoc");if(c&&f){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!f)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&o.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var u=r;break}}u&&("break"===t||"continue"===t)&&u.tryLoc<=e&&e<=u.finallyLoc&&(u=null);var i=u?u.completion:{};return i.type=t,i.arg=e,u?(this.method="next",this.next=u.finallyLoc,y):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),y},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),M(n),y}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;M(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:_(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),y}},t}(t.exports);try{regeneratorRuntime=e}catch(t){"object"===("undefined"==typeof globalThis?"undefined":r(globalThis))?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}}(T);var D=T.exports;function M(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=g(t);if(e){var o=g(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return m(this,n)}}function L(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function _(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?L(Object(n),!0).forEach((function(e){E(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):L(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var j={},A=Symbol("GLOBAL_OPTIONS_PROVIDE_KEY"),P=function(){return j},k=function(t){return null!==t&&"object"===r(t)},R=function(t){return t instanceof Function},C=function(t){return null==t},I="undefined"==typeof window,N=function(){var t;return!(!I&&!C(null===(t=window.document)||void 0===t?void 0:t.visibilityState))||"visible"===window.document.visibilityState},F=function(){return new Promise((function(){}))},B=function(t){return e.isRef(t)?t.value:t},Y=new Map;function z(t,e,n){var r,o,u,i,a,c,f=0,l=!1,s=!1,v=!0,d=!e&&0!==e&&"function"==typeof window.requestAnimationFrame;if("function"!=typeof t)throw new TypeError("Expected a function");function h(e){var n=r,u=o;return r=o=void 0,f=e,i=t.apply(u,n)}function p(t,e){return d?(window.cancelAnimationFrame(a),window.requestAnimationFrame(t)):setTimeout(t,e)}function y(t){return f=t,a=p(g,e),l?h(t):i}function m(t){var n=t-c;return void 0===c||n>=e||n<0||s&&t-f>=u}function g(){var t=Date.now();if(m(t))return w(t);a=p(g,function(t){var n=t-f,r=e-(t-c);return s?Math.min(r,u-n):r}(t))}function w(t){return a=void 0,v&&r?h(t):(r=o=void 0,i)}function b(){for(var t=Date.now(),n=m(t),u=arguments.length,f=new Array(u),l=0;l<u;l++)f[l]=arguments[l];if(r=f,o=this,c=t,n){if(void 0===a)return y(c);if(s)return a=p(g,e),h(c)}return void 0===a&&(a=p(g,e)),i}return e=+e||0,k(n)&&(l=!!n.leading,u=(s="maxWait"in n)?Math.max(+n.maxWait||0,e):u,v="trailing"in n?!!n.trailing:v),b.cancel=function(){void 0!==a&&function(t){if(d)return window.cancelAnimationFrame(t);clearTimeout(t)}(a),f=0,r=c=o=a=void 0},b.flush=function(){return void 0===a?i:w(Date.now())},b.pending=function(){return void 0!==a},b}var H=function(t,n){var r=n.debounceInterval,o=n.debounceOptions,u=n.manual,i=e.ref(!1),a=e.ref(),c=e.computed((function(){return o})),f=e.computed((function(){return B(r)})),l=e.ref(t.context.runAsync);return u||(i.value=!0),e.watchEffect((function(e){C(f.value)||(a.value=z((function(t){return t()}),f.value,c.value),t.context.runAsync=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return new Promise((function(t,n){i.value?(i.value=!1,l.value.apply(l,e).then(t).catch(n)):a.value((function(){l.value.apply(l,e).then(t).catch(n)}))}))},e((function(){var e;null===(e=a.value)||void 0===e||e.cancel(),t.context.runAsync=l.value})))})),{onCancel:function(){var t;null===(t=a.value)||void 0===t||t.cancel()}}},W=function(t,n){var r=n.errorRetryCount,o=void 0===r?0:r,u=n.errorRetryInterval,i=void 0===u?0:u,a=e.ref(),c=e.ref(0),f=e.computed((function(){return B(o)})),l=e.computed((function(){return B(i)})),s=!1,v=function(){c.value=0},d=e.computed((function(){if(l.value)return l.value;return 1e3*Math.floor(Math.random()*Math.pow(2,Math.min(c.value,9))+1)})),h=function(){a.value&&a.value()};return{onBefore:function(){s||v(),s=!1,h()},onSuccess:function(){v()},onError:function(){var e,n,r;a.value=(n=-1===f.value,r=c.value<f.value,(n||r)&&(n||(c.value+=1),e=setTimeout((function(){s=!0,t.context.refresh()}),d.value)),function(){return e&&clearTimeout(e)})},onCancel:function(){v(),h()}}},U=function(t,n){var r=n.ready,o=void 0===r?e.ref(!0):r,u=n.manual,i=n.defaultParams,a=void 0===i?[]:i;return e.watch(o,(function(e){var n;!u&&e&&(n=t.context).run.apply(n,$(a))}),{flush:"sync"}),{onBefore:function(){if(!o.value)return t.loading.value=!1,{isBreak:!0}}}},q=function(t,n){var r=n.refreshDeps,o=void 0===r?[]:r,u=n.refreshDepsAction,i=n.manual;return null!=o&&o.length&&e.watch(o,(function(){u?u():!i&&t.context.refresh()})),{}},G=function(t,n){var r=n.throttleInterval,o=n.throttleOptions,u=e.ref(),i=e.computed((function(){return B(r)})),a=e.computed((function(){return o})),c=e.ref(t.context.runAsync);return e.watchEffect((function(e){if(C(r))return{};u.value=function(t,e,n){var r=!0,o=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return k(n)&&(r="leading"in n?!!n.leading:r,o="trailing"in n?!!n.trailing:o),z(t,e,{leading:r,trailing:o,maxWait:e})}((function(t){return t()}),i.value,a.value),t.context.runAsync=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return new Promise((function(t,n){u.value((function(){c.value.apply(c,e).then(t).catch(n)}))}))},e((function(){var e;null===(e=u.value)||void 0===e||e.cancel(),t.context.runAsync=c.value}))})),{onCancel:function(){var t;null===(t=u.value)||void 0===t||t.cancel()}}},V=function(t,e){return function(){for(var n=e,r=t.length;r-- >0;)n=t[r](n);return n()}},K=function(t,n,r){var o,u,i,a,c=n.initialData,f=n.onSuccess,l=n.onError,s=n.onBefore,v=n.onAfter,d=e.ref(null!==(o=null==r?void 0:r.loading)&&void 0!==o&&o),h=e.shallowRef(null!==(u=null==r?void 0:r.data)&&void 0!==u?u:c),p=e.shallowRef(null==r?void 0:r.error),y=e.ref(null==r?void 0:r.params),m=e.ref([]),g=e.shallowRef("pending"),w={},b=(i={status:g,loading:d,data:h,error:p,params:y},a=[],function(t){Object.keys(t).forEach((function(e){i[e].value=t[e]})),a.forEach((function(t){return t(i)}))}),O=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];if("onQuery"===t){var o=m.value.map((function(t){return t.onQuery})).filter(Boolean);return{servicePromise:V(o,n[0])()}}var u=m.value.map((function(e){var r,o;return null===(o=e[t])||void 0===o?void 0:(r=o).call.apply(r,[e].concat(n))}));return Object.assign.apply(Object,[{}].concat($(u)))},S=e.ref(0);return w.runAsync=x(D.mark((function e(){var n,r,o,u,i,a,c,d,h,p,m,g,w=arguments;return D.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(n=w.length,r=new Array(n),o=0;o<n;o++)r[o]=w[o];if(b({loading:!0,params:r,status:"pending"}),S.value+=1,u=S.value,i=O("onBefore",r),a=i.isBreak,c=i.breakResult,d=void 0===c?F():c,!a){e.next=8;break}return b({status:"settled"}),e.abrupt("return",d);case 8:return null==s||s(r),e.prev=9,p=O("onQuery",h=function(){return new Promise((function(e){return e(t.apply(void 0,$(y.value)))}))}),(m=p.servicePromise)||(m=h()),e.next=15,m;case 15:if(g=e.sent,u===S.value){e.next=18;break}return e.abrupt("return",F());case 18:return b({data:g,loading:!1,error:void 0,status:"settled"}),O("onSuccess",g,r),null==f||f(g,r),O("onAfter",r,g,void 0),null==v||v(r),e.abrupt("return",g);case 26:if(e.prev=26,e.t0=e.catch(9),u===S.value){e.next=30;break}return e.abrupt("return",F());case 30:throw b({loading:!1,error:e.t0,status:"settled"}),O("onError",e.t0,r),null==l||l(e.t0,r),O("onAfter",r,void 0,e.t0),null==v||v(r),e.t0;case 36:case"end":return e.stop()}}),e,null,[[9,26]])}))),w.run=x(D.mark((function t(){var e=arguments;return D.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:w.runAsync.apply(w,e).catch((function(t){l||console.error(t)}));case 1:case"end":return t.stop()}}),t)}))),w.cancel=function(){S.value+=1,b({loading:!1}),O("onCancel")},w.refresh=function(){w.run.apply(w,$(y.value||[]))},w.refreshAsync=function(){return w.runAsync.apply(w,$(y.value||[]))},w.mutate=function(t){var e=R(t)?t(h.value):t,n=k(e)?Object.assign({},e):e;b({data:n}),O("onMutate",n)},{status:g,loading:d,data:h,error:p,params:y,plugins:m,context:w}};var Q=new Map,J=new Map,Z=function(t,n){var r=n.cacheKey,o=n.cacheTime,u=void 0===o?6e5:o,i=n.staleTime,a=void 0===i?0:i,c=n.getCache,f=n.setCache;if(!r)return{};var l,s=R(r)?r:function(){return r},v=e.ref((function(){})),d=function(t){return c?c(t):function(t){if(!C(t))return Y.get(t)}(t)},h=function(t,e,n){f?f(t,n):function(t,e,n){var r=Y.get(t);null!=r&&r.timer&&clearTimeout(r.timer);var o=setTimeout((function(){return Y.delete(t)}),e);Y.set(t,_(_({},n),{},{timer:o}))}(t,e,n),function(t,e){J.has(t)&&J.get(t).forEach((function(t){return t(e)}))}(t,n.data)},p=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},y=function(e){var n,r,o=s(e);return n=o,r=function(e){t.data.value=e},J.has(n)?J.get(n).push(r):J.set(n,[r]),function(){var t=J.get(n).indexOf(r);J.get(n).splice(t,1)}},m=s(),g=d(m);return g&&p(g,"data")&&(t.data.value=g.data,t.params.value=g.params),m&&(v.value=y()),e.onUnmounted((function(){v.value()})),{onBefore:function(e){var n,r=s(e),o=d(r);return o&&p(o,"data")?(n=o.time,-1===a||n+a>(new Date).getTime()?(t.data.value=o.data,t.loading.value=!1,{isBreak:!0,breakResult:o.data}):void(t.data.value=o.data)):{}},onQuery:function(e){var n=t.params.value,r=s(n),o=function(t){return Q.get(t)}(r);return o&&o!==l||(o=e(),l=o,function(t,e){Q.set(t,e),e.then((function(e){return Q.delete(t),e})).catch((function(){Q.delete(t)}))}(r,o)),function(){return o}},onSuccess:function(t,e){var n=s(e);n&&(v.value(),h(n,u,{data:t,params:e,time:(new Date).getTime()}),v.value=y(e))},onMutate:function(e){var n=s(t.params.value);n&&(v.value(),h(n,u,{data:e,params:t.params.value,time:(new Date).getTime()}),v.value=y(t.params.value))}}};function X(t){var e,n;return new(function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&y(t,e)}(a,t);var r,o,u,i=M(a);function a(t){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,a),(r=i.call(this,t)).cancel=function(){n(),clearTimeout(e)},r}return r=a,o&&p(r.prototype,o),u&&p(r,u),Object.defineProperty(r,"prototype",{writable:!1}),r}(O(Promise)))((function(r){n=r,e=setTimeout(n,t)}))}function tt(){return(new Date).getTime()}var et,nt=function(t,n){var r=n.loadingDelay,o=void 0===r?0:r,u=n.loadingKeep,i=void 0===u?0:u,a=e.ref((function(){})),c=e.computed((function(){return B(o)})),f=e.computed((function(){return B(i)})),l=tt(),s={};return{onBefore:function(){var e;t.loading.value=!c.value,a.value(),a.value=(c.value&&(e=setTimeout((function(){"pending"===t.status.value&&(t.loading.value=!0)}),c.value)),function(){return e&&clearTimeout(e)}),l=tt()},onQuery:function(t){if(!f.value)return function(){return t()};s=X(f.value+c.value);var e=Promise.allSettled([t().finally((function(){tt()-l<=c.value&&s.cancel()})),s]).then((function(t){var e=t[0];return"fulfilled"===e.status?e.value:Promise.reject(e.reason)}));return function(){return e}},onCancel:function(){a.value()},onAfter:function(){a.value()}}},rt=new Set,ot=new Set,ut=new Set,it=function(t,e){var n;switch(t){case"FOCUS_LISTENER":n=rt;break;case"RECONNECT_LISTENER":n=ut;break;case"VISIBLE_LISTENER":n=ot}if(!n.has(e))return n.add(e),function(){n.delete(e)}},at=function(t){t.forEach((function(t){t()}))};!I&&null!==(et=window)&&void 0!==et&&et.addEventListener&&(window.addEventListener("visibilitychange",(function(){N()&&at(ot)}),!1),window.addEventListener("focus",(function(){return at(rt)}),!1),window.addEventListener("online",(function(){return at(ut)}),!1));var ct=function(t,n){var r=n.pollingInterval,o=n.pollingWhenHidden,u=void 0!==o&&o,i=n.pollingWhenOffline,a=void 0!==i&&i,c=n.errorRetryCount,f=void 0===c?0:c,l=e.ref(),s=e.ref(!1),v=e.computed((function(){return B(r)})),d=e.computed((function(){return B(f)})),h=[],p=function(t){t&&h.push(t)},y=function(){return(u||N())&&(a||null===(t=!I&&(null===(e=window.navigator)||void 0===e?void 0:e.onLine))||void 0===t||t);var t,e},m=function(e){if(!t.error.value||0===d.value){var n;if(!C(v.value)&&v.value>=0){if(!y())return void(s.value=!0);n=setTimeout(e,v.value)}return function(){return n&&clearTimeout(n)}}},g=function(){s.value&&y()&&(t.context.refresh(),s.value=!1)};return e.watch(v,(function(){l.value&&(l.value(),l.value=m((function(){return t.context.refresh()})))})),u||p(it("VISIBLE_LISTENER",g)),a||p(it("RECONNECT_LISTENER",g)),e.onUnmounted((function(){h.forEach((function(t){return t()}))})),{onBefore:function(){var t;null===(t=l.value)||void 0===t||t.call(l)},onCancel:function(){var t;null===(t=l.value)||void 0===t||t.call(l)},onAfter:function(){l.value=m((function(){return t.context.refresh()}))}}},ft=function(t,n){var r=n.refreshOnWindowFocus,o=void 0!==r&&r,u=n.refocusTimespan,i=void 0===u?5e3:u,a=e.computed((function(){return B(o)})),c=e.computed((function(){return B(i)})),f=[],l=function(t){t&&f.push(t)},s=function(){f.forEach((function(t){return t()}))};return e.watchEffect((function(){if(s(),a.value){var e=(n=t.context.refresh,r=c.value,o=!1,function(){o||(o=!0,n.apply(void 0,arguments),setTimeout((function(){o=!1}),r))});l(it("VISIBLE_LISTENER",e)),l(it("FOCUS_LISTENER",e))}var n,r,o})),e.onUnmounted((function(){s()})),{}};var lt;"undefined"!=typeof window&&(null==(lt=null==window?void 0:window.navigator)?void 0:lt.userAgent)&&/iP(ad|hone|od)/.test(window.navigator.userAgent);var st=function(t){var r,u,i,a,c,f,l=e.ref(t.pageNum),s=e.ref(t.pageSize),v=e.ref(null!==(u=t.listKey)&&void 0!==u?u:"records"),d=e.ref(null!==(i=t.pageNumSendKey)&&void 0!==i?i:"pageNum"),h=e.ref(null!==(a=t.pageSizeKey)&&void 0!==a?a:"size"),p=e.ref(null!==(c=t.totalKey)&&void 0!==c?c:"total"),y=e.ref(0),m=e.ref(null===(f=t.doFirstLoad)||void 0===f||f),g=e.reactive(t.defaultParams?t.defaultParams:{}),w=e.reactive(o(o({},e.toRefs(g)),((r={})[d.value]=l.value,r.pageSize=s.value,r)));e.watch((function(){return l.value}),(function(t){w[d.value]=t})),e.watch((function(){return s.value}),(function(t){w.pageSize=t}));var b=e.ref({loading:!1,data:void 0}),O=function(){t.requestList&&"function"==typeof t.requestList||console.error("请定义一个函数用于获取列表数据"),console.log(999,w),b.value.loading=!0,t.requestList(w).then((function(t){b.value.loading=!1,b.value.data=t[v.value],s.value=t[h.value],y.value=t[p.value]})).catch((function(t){console.error(t),b.value.loading=!1}))};m.value&&O();return{pageNum:l,pageSize:s,total:y,onCurrentChange:function(t){l.value=t,n.nextTick((function(){O()}))},onSizeChange:function(t){l.value=1,s.value=t,n.nextTick((function(){O()}))},fetchData:O,pageDatas:b}};t.useBoolean=function(t){var n=a(function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=n.truthyValue,o=void 0===r||r,u=n.falsyValue,i=void 0!==u&&u,a=e.isRef(t),c=e.ref(t);function f(t){return arguments.length?(c.value=t,c.value):(c.value=c.value===e.unref(o)?e.unref(i):e.unref(o),c.value)}return a?f:[c,f]}(),2),r=n[0],o=n[1];r.value=t||false;var u={toggle:function(){o()},setTrue:function(){r.value=!0},setFalse:function(){r.value=!1}};return[r,u]},t.useDate=function(t,n){var r=e.ref(),u=t||+new Date,i=o(o({},s),n),a=i.format,c=i.method,f=i.methodParam,v=function(t){switch(console.log(t),u=t||+new Date,c){case"format":r.value=l(u).format(a);break;case void 0:break;default:var e=l(u);f&&(e=e[c](f),n&&n.format&&(e=e.format(a))),r.value=e}};return v(),{data:e.readonly(r),refresh:v}},t.useDebounce=function(t,n){n=n||1e3;var r=e.ref(t.value),o=v((function(){return r.value=t.value}),n).run;return e.watch(t,(function(){return o()}),{deep:!0}),r},t.useDebounceFn=v,t.useFormTable=function(t){var n=t.formRef,r=st(t),o=r.pageNum,u=r.pageSize,i=r.total,a=r.onCurrentChange,c=r.onSizeChange,f=r.fetchData,l=r.pageDatas;return{pageNum:o,pageSize:u,total:i,reset:function(){var r=void 0===t.doFirstLoad||t.doFirstLoad;n.value&&(n.value.resetFields(),o.value=t.pageNum,u.value=t.pageSize,r&&e.nextTick((function(){f()})))},onCurrentChange:a,onSizeChange:c,fetchData:f,pageDatas:l}},t.useModalFn=function(){var t=this,n=e.ref(!1),r=e.ref(),o=function(){n.value=!1,r.value=void 0};return{editId:r,visible:n,openModal:function(t){n.value=!0,r.value=t||void 0},closeModal:o,onCancel:function(e){return u(t,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return e&&"function"==typeof e?[4,e()]:(console.error("请定义一个函数用于退出弹窗回调"),[2]);case 1:return t.sent(),o(),[2]}}))}))},onOk:function(e){return u(t,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return e&&"function"==typeof e?[4,e()]:(console.error("请定义一个函数用于确认弹窗回调"),[2]);case 1:return t.sent(),o(),[2]}}))}))}}},t.usePagination=st,t.useRequest=function(t,n){return function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2?arguments[2]:void 0,o=e.inject(A,{}),u=_(_(_({},P()),o),n),i=u.manual,a=void 0!==i&&i,c=u.defaultParams,f=void 0===c?[]:c,l=K(t,u);if(l.plugins.value=r.map((function(t){return t(l,u)})),!a){var s,v=l.params.value||f;(s=l.context).run.apply(s,$(v))}return e.onUnmounted((function(){l.context.cancel()})),{loading:l.loading,data:l.data,error:l.error,params:l.params,cancel:l.context.cancel,refresh:l.context.refresh,refreshAsync:l.context.refreshAsync,mutate:l.context.mutate,run:l.context.run,runAsync:l.context.runAsync}}(t,n,[nt,W,H,ct,G,ft,q,U,Z])},t.useRequestProvider=function(t){e.provide(A,t)},t.useThrottle=function(t,n){n=n||1e3;var r=e.ref(t.value),o=d((function(){return r.value=t.value}),n).run;return e.watch(t,(function(){return o()}),{deep:!0}),r},t.useThrottleFn=d,Object.defineProperty(t,"__esModule",{value:!0})}));