co-utils-vue
Version:
工具库
2 lines (1 loc) • 25.4 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("vue-demi")):"function"==typeof define&&define.amd?define(["exports","vue-demi"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["co-utils-vue"]={},t.VueDemi)}(this,(function(t,e){"use strict";var r=function(t){return null===t?"[object Null]":toString.call(t)},n=function(t,e){return e?e.split(".").reduce((function(t,e){return(t||{})[e]}),t||{}):e},o=function(t){return/^(?:[a-z][a-zA-Z0-9]*|[A-Z][a-zA-Z0-9]*)$/.test(t)};function i(t){return i="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},i(t)}var a=function(t){return"object"===i(t)&&null!==t},u=function(t){return"number"==typeof t||a(t)&&"[object Number]"===r(t)},c=function(t){return u(t)?u(t):"symbol"!==i(t)&&/^[-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?$/.test(t)},l=function(t){return/^1[3,4,5,6,7,8,9][0-9]{9}$/.test(t)},f=function(t){return/^[1-9]\d{5}(19|20)\d{2}((0[1-9]|1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/.test(t)},s=function(t){return"function"==typeof t},p=function(t){return t&&Array.isArray(t)},v=function(t){var e=i(t);return"string"===e||"object"===e&&null!==t&&!p(t)&&"[object String]"===r(t)},d=function(t){return/^[a-z]+(-[a-z]+)*$/.test(t)};function y(t,e,r,n,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}function h(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var g={exports:{}},b={exports:{}};!function(t){function e(r){return t.exports=e="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},t.exports.__esModule=!0,t.exports.default=t.exports,e(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports}(b);var m=b.exports;!function(t){var e=m.default;function r(){t.exports=r=function(){return n},t.exports.__esModule=!0,t.exports.default=t.exports;var n={},o=Object.prototype,i=o.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},u="function"==typeof Symbol?Symbol:{},c=u.iterator||"@@iterator",l=u.asyncIterator||"@@asyncIterator",f=u.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function p(t,e,r,n){var o=Object.create((e&&e.prototype instanceof y?e:y).prototype),i=new M(n||[]);return a(o,"_invoke",{value:x(t,r,i)}),o}function v(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}n.wrap=p;var d={};function y(){}function h(){}function g(){}var b={};s(b,c,(function(){return this}));var m=Object.getPrototypeOf,w=m&&m(m(L([])));w&&w!==o&&i.call(w,c)&&(b=w);var j=g.prototype=y.prototype=Object.create(b);function O(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function S(t,r){function n(o,a,u,c){var l=v(t[o],t,a);if("throw"!==l.type){var f=l.arg,s=f.value;return s&&"object"==e(s)&&i.call(s,"__await")?r.resolve(s.__await).then((function(t){n("next",t,u,c)}),(function(t){n("throw",t,u,c)})):r.resolve(s).then((function(t){f.value=t,u(f)}),(function(t){return n("throw",t,u,c)}))}c(l.arg)}var o;a(this,"_invoke",{value:function(t,e){function i(){return new r((function(r,o){n(t,e,r,o)}))}return o=o?o.then(i,i):i()}})}function x(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var u=A(a,r);if(u){if(u===d)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=v(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===d)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function A(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,A(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),d;var o=v(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,d;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,d):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,d)}function E(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function M(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(E,this),this.reset(!0)}function L(t){if(t||""===t){var r=t[c];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(i.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}throw new TypeError(e(t)+" is not iterable")}return h.prototype=g,a(j,"constructor",{value:g,configurable:!0}),a(g,"constructor",{value:h,configurable:!0}),h.displayName=s(g,f,"GeneratorFunction"),n.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},n.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,g):(t.__proto__=g,s(t,f,"GeneratorFunction")),t.prototype=Object.create(j),t},n.awrap=function(t){return{__await:t}},O(S.prototype),s(S.prototype,l,(function(){return this})),n.AsyncIterator=S,n.async=function(t,e,r,o,i){void 0===i&&(i=Promise);var a=new S(p(t,e,r,o),i);return n.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},O(j),s(j,f,"Generator"),s(j,c,(function(){return this})),s(j,"toString",(function(){return"[object Generator]"})),n.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},n.values=L,M.prototype={constructor:M,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(P),!t)for(var e in this)"t"===e.charAt(0)&&i.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},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 e=this;function r(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n],a=o.completion;if("root"===o.tryLoc)return r("end");if(this.prev>=o.tryLoc){var u=i.call(o,"catchLoc"),c=i.call(o,"finallyLoc");if(u&&c){if(o.catchLoc>this.prev)return r(o.catchLoc,!0);if(o.finallyLoc>this.prev)return r(o.finallyLoc)}else if(u){if(o.catchLoc>this.prev)return r(o.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(o.finallyLoc>this.prev)return r(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(this.prev>=n.tryLoc&&i.call(n,"finallyLoc")&&n.finallyLoc>this.prev){var o=n;break}}o&&("break"===t||"continue"===t)&&e>=o.tryLoc&&o.finallyLoc>=e&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,d):this.complete(a)},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),d},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),P(r),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;P(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:L(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),d}},n}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}(g);var w=(0,g.exports)(),j=w;try{regeneratorRuntime=w}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=w:Function("r","regeneratorRuntime = r")(w)}var O=h(j),S=function(t){return function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new WeakMap;if(!a(e))return e;if(r.has(e))return r.get(e);if(e instanceof Date||e instanceof Function)return e;if(e instanceof RegExp)return RegExp(e.source,e.flags);var n=Array.isArray(e)?[]:{};if(Array.isArray(e))return r.set(e,n),e.forEach((function(e,o){n[o]=t(e,r)})),n;var o=Object.getOwnPropertySymbols(e);if(o.length)return o.forEach((function(o){n[o]=t(e[o],r)})),n;if(a(e)){for(var i in r.set(e,n=Object.create(Object.getPrototypeOf(e))),e)e.hasOwnProperty.call(e,i)&&(n[i]=t(e[i],r));return n}return e}(t)};function x(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);e>r;r++)n[r]=t[r];return n}function A(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],c=!0,l=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(t){l=!0,o=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}(t,e)||function(t,e){if(t){if("string"==typeof t)return x(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?x(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var E=function(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"yyyy-MM-dd";if(!t)return"".concat(t);if("string"==typeof t){var n=t.match(/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2}):(\d{4})/);if(n){var o=A(n,8),i=o[2],a=o[3],u=o[4],c=o[5],l=o[6],f=o[7];e=new Date(Number(o[1]),Number(i)-1,Number(a),Number(u),Number(c),Number(l),Number(f))}else e=new Date(t)}else e=new Date(t);var s={yyyy:"".concat(e.getFullYear()),yy:"".concat(e.getFullYear()%100),YYYY:"".concat(e.getFullYear()),YY:"".concat(e.getFullYear()%100),M:"".concat(e.getMonth()+1),d:"".concat(e.getDate()),H:"".concat(e.getHours()),m:"".concat(e.getMinutes()),s:"".concat(e.getSeconds()),MM:"".concat(e.getMonth()+101).substring(1),dd:"".concat(e.getDate()+100).substring(1),HH:"".concat(e.getHours()+100).substring(1),mm:"".concat(e.getMinutes()+100).substring(1),ss:"".concat(e.getSeconds()+100).substring(1),SS:"".concat(e.getMilliseconds())};return r.replace(/(yyyy|YYYY|YY|yy)|MM?|dd?|HH?|mm?|ss?|SS?/g,(function(){for(var t=arguments.length,e=Array(t),r=0;t>r;r++)e[r]=arguments[r];return s[e[0]]}))};function P(t){return t.replace(/^[a-z]/,(function(t){return t.toUpperCase()}))}var M=function(t){if(!c(t))return 0;var e=+t,r=e%1;return r?e-r:e},L=function t(e){for(var r=arguments.length,n=Array(r>1?r-1:0),o=1;r>o;o++)n[o-1]=arguments[o];if(!n.length)return e;var i=n.shift();if(i&&a(i))for(var u in i)i.hasOwnProperty(u)&&(i[u]&&a(i[u])&&!Array.isArray(i[u])?(e[u]&&a(e[u])||(e[u]={}),t(e[u],i[u])):e[u]=i[u]);return t.apply(void 0,[e].concat(n))},T=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,r=2>=arguments.length||void 0===arguments[2]||arguments[2];if(!c(t))return t;var n=Math.pow(10,e);return r?Math.round(t*n)/n:Math.floor(t*n)/n};function F(t){var e=function(t,e){if("object"!==i(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!==i(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===i(e)?e:e+""}function N(t,e,r){return(e=F(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function D(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return _(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return _(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return t.length>n?{done:!1,value:t[n++]}:{done:!0}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function _(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);e>r;r++)n[r]=t[r];return n}function C(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function k(t){for(var e=1;arguments.length>e;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?C(Object(r),!0).forEach((function(e){N(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):C(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function I(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function K(t){for(var e=1;arguments.length>e;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?I(Object(r),!0).forEach((function(e){N(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):I(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}t.deepObjectValue=n,t.getTag=r,t.isArray=p,t.isBoolean=function(t){return!0===t||!1===t||a(t)&&"[object Boolean]"===r(t)},t.isCamelCase=o,t.isEmpty=function(t){if(null==t)return!0;if(Array.isArray(t)||"string"==typeof t)return!t.length;var e=r(t);return"[object Map]"===e||"[object Set]"===e?!t.size:!Reflect.ownKeys(t).length},t.isFunction=s,t.isIdCard=f,t.isKebabCase=d,t.isNumber=u,t.isNumeric=c,t.isObject=function(t){var e=i(t);return null!==t&&("object"===e||"function"===e)},t.isObjectLike=a,t.isPhone=l,t.isString=v,t.passwordLevel=function(t){return t.length>=8&&/[a-z]/.test(t)&&/[A-Z]/.test(t)&&/\d/.test(t)&&/[!@#$%^&*()\-=_+[\]{}|;:',.<>/?]/.test(t)?12>t.length?2:3:1},t.useBeforeDate=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",n=E(t,"yyyy-MM-dd HH:mm:ss"),o=new Date(n).getTime(),i=0;if(e){var a=E(e,"yyyy-MM-dd HH:mm:ss");i=new Date(a).getTime()}else i=(new Date).getTime();var u=6e4,c=36e5,l=864e5,f=7*l,s=30*l,p=12*s,v=i-o;return 0>v?r:1>v/p?1>v/s?1>v/f?1>v/l?1>v/c?1>v/u?"".concat(parseInt("".concat(v/1e3),10),"秒前"):"".concat(parseInt("".concat(v/u),10),"分钟前"):"".concat(parseInt("".concat(v/c),10),"小时前"):"".concat(parseInt("".concat(v/l),10),"天前"):"".concat(parseInt("".concat(v/f),10),"周前"):"".concat(parseInt("".concat(v/s),10),"个月前"):"".concat(parseInt("".concat(v/p),10),"年前")},t.useCamel2kebab=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"-";if(!o(t))return t;var r=(t=P(t)).replace(/[A-Z]/g,(function(t){return e+t.toLowerCase()}));return r.startsWith(e)?r.slice(1):r},t.useCamelize=function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!d(t))return t;var r=t.replace(/-(\w)/g,(function(t,e){return e.toUpperCase()}));return e?P(r):r},t.useChunk=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(!p(t))return[];if(e!==1/0&&e!==-1/0||(e=e===1/0?1:-1),!Array.isArray(t)||!c(e))return[];var r=M(+e);if(1>Math.max(r,0))return[];for(var n=Array(Math.ceil(t.length/e)),o=0,i=0;t.length>o;)n[i++]=t.slice(o,o+=e);return n},t.useCloneDeep=S,t.useDebounce=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3,r=null;return function(){for(var n=this,o=arguments.length,i=Array(o),a=0;o>a;a++)i[a]=arguments[a];null!==r&&(clearTimeout(r),r=null),r=setTimeout((function(){t.call.apply(t,[n].concat(i))}),e)}},t.useDebounceRef=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3,n=null;return null===r?e.ref(t):e.customRef((function(e,o){return{get:function(){return e(),t},set:function(e){n&&clearTimeout(n),n=null,n=setTimeout((function(){t=e,o()}),r)}}}))},t.useDeepOmit=function(t,e){return function t(e,r){if(Array.isArray(e))return e.map((function(e){return t(e,r)}));if(a(e)){var n={};for(var o in e)e.hasOwnProperty(o)&&!r.includes(o)&&(n[o]=t(e[o],r));return n}return e}(S(t),e)},t.useEmptyObject=function(t,e){return function e(r,n){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new WeakSet;if(o.has(r))return t;var i={};return o.add(r),Object.keys(r).forEach((function(t){var u,c=r[t];a(c)?i[t]=e(c,null==n?void 0:n[t],o):i[t]=null!==(u=null==n?void 0:n[t])&&void 0!==u?u:function(t){return"string"==typeof t?"":"number"==typeof t?0:"boolean"!=typeof t&&(p(t)?[]:null)}(c)})),i}(t,e)},t.useEncCard=function(t){return f(t)?t.replace(/^(.{6})(?:\d+)(.{4})$/,"$1****$2"):t},t.useEncPhone=function(t){return l(t)?t.replace(/^(.{3})(?:\d+)(.{4})$/,"$1****$2"):t},t.useFirstToUpper=P,t.useFormValueWatcher=function(t,e){return function t(e,r){if(v(e)||u(e)){if((v(r)||u(r))&&(Number.isNaN(+e)?e:+e)!==(Number.isNaN(+r)?r:+r))return!0}else if("[object Date]"===toString.call(e)){if("[object Date]"!==toString.call(r)||e!==r)return!0}else if("[object Boolean]"===toString.call(e)){if("[object Boolean]"!==toString.call(r)||e!==r)return!0}else if(Array.isArray(e)||"[object Object]"===toString.call(e)){if(Array.isArray(e)){if(!Array.isArray(r))return!0;if(e.length!==r.length)return!0}if("[object Object]"===toString.call(e)&&"[object Object]"!==toString.call(r))return!0;for(var n in e)if(t(e[n],r[n]))return!0}return!1}(t,e)},t.useFormatBytes=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;if(!c(t))return t;var r=+t;if(0>=r)return"0 Bytes";var n=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],o=0>e?0:e,i=Math.floor(Math.log(r)/Math.log(1024));return 9>i?parseFloat((r/Math.pow(1024,i)).toFixed(o))+" "+n[i]:"Number too large"},t.useFormatDate=E,t.useLabelByVal=function(t,e,r){var n=r||{},o=n.valueKey,i=void 0===o?"value":o,a=n.labelKey,u=void 0===a?"label":a;return(t.find((function(t){return t[i]+""==e+""}))||{})[u]||""},t.useMerge=L,t.useOmit=function(t,e){var r={},n=new Set(e);for(var o in t)n.has(o)||(r[o]=t[o]);return r},t.usePick=function(t,e){return e.reduce((function(e,r){return Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]),e}),{})},t.usePriceToThousand=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:",",n=3>=arguments.length||void 0===arguments[3]||arguments[3];if(c(+t)&&isFinite(+t)){c(e)&&isFinite(e)||(e=2);for(var o="".concat(T(+t,e,n)).split("."),i=/(-?\d+)(\d{3})/;i.test(o[0]);)o[0]=o[0].replace(i,"$1"+r+"$2");return Math.abs(e)>(o[1]||"").length&&(o[1]=o[1]||"",o[1]+=Array(Math.abs(e)-o[1].length+1).join("0")),o.join(".")}return"00.00"},t.useSFCWithInstall=function(t){return t.install=function(e){e.component(t.name,t)},t},t.useSFCWithInstallFunction=function(t,e){return t.install=function(r){t._context=r._context,r.config.globalProperties[e]=t},t},t.useSort=function(t,e){var r=L({order:"dec"},e||{});return t.sort((function(t,n){if(s(null==e?void 0:e.compareFn))return r.compareFn?null==r?void 0:r.compareFn(t,n):0;var o=a(t)?t[r.key]:t,i=a(n)?n[r.key]:n;return c(o)&&c(i)?"asc"===r.order?+o-+i:+i-+o:v(o)&&v(i)?"asc"===r.order?o.localeCompare(i):i.localeCompare(o):0}))},t.useTableList=function(t){var r=t.request.params,o=void 0===r?{}:r,i=S(t),a=i.request,u=a.pageNumKey,c=void 0===u?"pageNum":u,l=a.pageSizeKey,f=void 0===l?"pageSize":l,p=a.api,v=a.handleParams,d=i.response||{},h=d.listKey,g=void 0===h?"list":h,b=d.totalKey,m=void 0===b?"total":b,w=e.ref([]),j=e.ref(0),x=e.ref(!1),A=e.ref(S(o)),E=function(){var t,e=(t=O.mark((function t(){var e,r,o=arguments;return O.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=o.length>0&&void 0!==o[0]?o[0]:1,s(v)&&(A.value=v(S(A.value))),c in A&&(A.value[c]=e),t.prev=3,x.value=!0,t.next=7,p(A.value);case 7:w.value=n(r=t.sent,g),j.value=n(r,m),t.next=15;break;case 12:return t.prev=12,t.t0=t.catch(3),t.abrupt("return",Promise.reject(t.t0));case 15:return t.prev=15,x.value=!1,t.finish(15);case 18:return t.abrupt("return",Promise.resolve());case 19:case"end":return t.stop()}}),t,null,[[3,12,15,18]])})),function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){y(i,n,o,a,u,"next",t)}function u(t){y(i,n,o,a,u,"throw",t)}a(void 0)}))});return function(){return e.apply(this,arguments)}}();return{params:A,tableData:w,tableTotal:j,tableLoading:x,handleSearch:E,handleReset:function(){return A.value=S(o),E()},handleSizeChange:function(t){return f in A.value&&(A.value[f]=t),E(1)},handleCurrentChange:function(t){return E(t)}}},t.useToFixedFix=T,t.useToInteger=M,t.useTransformList=function(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{children:"children",pidKey:"id",parentKey:"parent",pidValue:null,pidFlag:!0},n=r.children,o=void 0===n?"children":n,i=r.pidKey,a=void 0===i?"id":i,u=r.parentKey,c=void 0===u?"parent":u,l=r.pidValue,f=void 0===l?null:l,s=r.pidFlag,p=void 0===s||s,v=[],d=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=p?k(k({},e),{},N({},c,r)):k({},e);if(delete n[o],v.push(n),e[o]&&e[o].length){var i,u=D(e[o]);try{for(u.s();!(i=u.n()).done;){t(i.value,e[a])}}catch(t){u.e(t)}finally{u.f()}}},y=D(t);try{for(y.s();!(e=y.n()).done;){d(e.value,f)}}catch(t){y.e(t)}finally{y.f()}return v},t.useTransformTree=function t(e,r){var n=[],o=L({parentKey:"parent",pidKey:"id",pidValue:null},r||{});return e.forEach((function(r){if(r[o.parentKey]===o.pidValue){var i=t(e.filter((function(t){var e;return t[null!==(e=o.parentKey)&&void 0!==e?e:"parent"]!==o.pidValue})),{parentKey:o.parentKey,pidKey:o.pidKey,pidValue:r[o.pidKey]});n.push(K(K({},r),{},i.length?{children:i}:{children:[]}))}})),n},t.useValPassword=function(t,e,r){var n,o;return 2===arguments.length?(n=e,o=1):3===arguments.length?(o=e,n=r):(n=16,o=6),RegExp("^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]{".concat(o,",").concat(n,"}$")).test(t)},t.useWebSocket=function(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=n.onOpen,i=n.onClose,a=n.onFailed,u=n.onError,l=n.onMessage,f=n.beforeMessage,p=n.heartMessage,v=void 0===p?"ping":p,d=n.heartTime,y=void 0===d?5e3:d,h=n.reconnectCount,g=void 0===h?-1:h,b=n.reconnectTime,m=void 0===b?5e3:b,w=n.isReconnect,j=void 0===w||w,O=n.autoClose,S=void 0===O||O,x=n.protocols,A=void 0===x?[]:x,E=e.ref(),P=e.ref(null),M=[],L=0,T=!1,F=function(){r&&clearInterval(r),r=void 0},N=function(){M.forEach((function(t){var e;null===(e=E.value)||void 0===e||e.send(t)})),M=[]},D=function(t){var e,r,n;return E.value&&(null===(e=E.value)||void 0===e?void 0:e.readyState)===(null===(r=E.value)||void 0===r?void 0:r.OPEN)?(N(),null===(n=E.value)||void 0===n||n.send(t),!0):((1>=arguments.length||void 0===arguments[1]||arguments[1])&&M.push(t),!1)},_=function(){F(),j&&(r=setInterval((function(){D(v,!1)}),y))},C=function e(){if(!E.value){var r=new WebSocket(t,A);E.value=r,r.onopen=function(){s(o)&&(null==o||o(r)),_(),N()},r.onclose=function(t){E.value=void 0,s(i)&&(null==i||i(r,t)),!T&&j&&(L+=1,c(g)&&(0>+g||+g>L)||"function"==typeof g&&g()?setTimeout(e,m):(F(),s(a)&&(null==a||a())))},r.onerror=function(t){s(u)&&(null==u||u(r,t))},r.onmessage=function(t){j&&(_(),t.data===v)||(P.value=s(f)?null==f?void 0:f(t.data):t.data,s(l)&&(null==l||l(r,t)))}}},k=function(t,e){var r;E.value&&(T=!0,F(),E.value&&(null===(r=E.value)||void 0===r||r.close(t||1e3,e)))};return S&&(window.addEventListener("beforeunload",(function(){return k()})),e.getCurrentScope()&&e.onScopeDispose(k)),{data:P,send:D,close:k,websocketOpen:function(){k(),T=!1,L=0,C()},ws:E}}}));