koishi-plugin-pm2 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +110 -0
- package/dist/style.css +1 -0
- package/lib/api.d.ts +9 -0
- package/lib/index.d.ts +164 -0
- package/lib/index.js +496 -0
- package/lib/utils.d.ts +17 -0
- package/package.json +49 -0
- package/readme.md +5 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import{icons as no,VirtualList as or,Schema as re,store as rr,useContext as sr,useConfig as ar,useColorMode as ir,send as me,receive as lr}from"@koishijs/client";import{createElementBlock as I,openBlock as m,createElementVNode as S,defineComponent as H,warn as ur,computed as y,getCurrentInstance as Ce,watch as ne,unref as d,onMounted as Ee,watchEffect as cr,onBeforeUnmount as it,inject as ae,ref as B,isRef as oo,onScopeDispose as dr,shallowRef as wt,provide as nn,renderSlot as te,mergeProps as Ze,toRef as Et,onUnmounted as ro,useAttrs as fr,useSlots as so,nextTick as ce,createCommentVNode as P,Fragment as Ae,normalizeClass as M,createBlock as F,withCtx as w,resolveDynamicComponent as de,withModifiers as je,createVNode as k,toDisplayString as D,normalizeStyle as tt,Transition as on,withDirectives as Je,vShow as Qe,Text as pr,reactive as ao,h as vr,shallowReactive as hr,isVNode as Bt,render as xt,toRefs as mr,resolveComponent as Y,withKeys as vt,createTextVNode as K,renderList as Yt}from"vue";import{isClient as he,useEventListener as io,useResizeObserver as lo,useTimeoutFn as gr}from"@vueuse/core";const lt=(e,t)=>{const n=e.__vccOpts||e;for(const[o,r]of t)n[o]=r;return n},br={},yr={class:"k-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 96 96"};function _r(e,t){return m(),I("svg",yr,[...t[0]||(t[0]=[S("path",{fill:"currentColor",d:"m65.3613 9.47461-3.4351 5.88909c-.3921.6723-1.0988 1.047-1.8255 1.047-.3609 0-.7272-.0923-1.0618-.2876-1.0069-.5874-1.3468-1.8803-.7594-2.8873l2.1938-3.76119h-6.1682c.0005.35992-.0818.72409-.275 1.05759l-9.4898 16.3906c-2.3272 4.036-7.3208 6.3756-11.2034 6.3756l-3.0383 0c-1.1657 0-2.1109-.9451-2.1109-2.1109s.9452-2.111 2.1109-2.111h3.0383c2.7519 0 5.9054-1.9558 7.4717-4.129 1.0442-1.4488 4.0291-6.6065 8.9547-15.47289h-5.6067C35.299 28.5488 30.0216 24.8546 14.1893 24.8546c-1.0481 1.5874-2.102 3.1807-3.1326 4.7497h11.0488c1.1657 0 2.1109.9451 2.1109 2.1109s-.9452 2.111-2.1109 2.111H8.30449c-.94201 1.4618-1.83759 2.8725-2.65823 4.2013l34.68264-.2438-1.5521.0011c2.1004.0427 5.498-1.1869 7.143-3.7729l8.1773-12.9249c.6233-.9853 1.9268-1.2787 2.9126-.6549.9848.6233 1.2782 1.9268.655 2.9126l-8.18 12.9297c-2.4661 3.8747-7.134 5.7935-10.7696 5.7318l-35.57561.2607c-1.64919 2.9664-2.13911 4.9044-2.11836 5.8083H48.1796l24.0613-36.9419c-1.5188-.8755-3.6942-1.58322-6.478-1.65869h-.4016Z"},null,-1),S("path",{fill:"currentColor",d:"M48.1794 48.0752H1.02044c-.151466 2.2366.54602 4.5597 1.85851 6.601l1.17389 0H34.4526c4.9127-.5396 9.2716 1.5035 13.0765 6.1292l7.9178 12.8003c.6217.9864.3251 2.2899-.6612 2.9111-.3494.22-.7383.3251-1.1225.3251-.7019 0-1.3875-.3494-1.7885-.9869-4.8819-7.9131-7.8546-12.3891-8.9181-13.4281-1.5954-1.5584-3.6388-3.5166-8.504-3.5166H5.53051l2.81709 4.4736h11.2741c1.1658 0 2.111.9452 2.111 2.111 0 1.1658-.9452 2.111-2.111 2.111h-8.6159l2.6556 4.2177c18.9987 0 21.6374 2.1109 28.1603 14.7014h5.5344c-4.7264-8.4403-7.7129-13.4191-8.9596-14.9365-1.8701-2.276-4.3902-3.9826-7.6529-3.9826h-2.9287c-1.1658 0-2.1109-.9452-2.1109-2.111 0-1.1658.9451-2.111 2.1109-2.111h2.9287c4.4763 0 9.4991 2.8757 11.3124 6.3757l10.0176 16.3906c.0702.1213.1256.2469.1694.3748h7.5473l-2.4113-4.1339c-.5879-1.007-.2475-2.2994.7594-2.8873.3346-.1948.7009-.2876 1.0618-.2876.7262 0 1.4334.3747 1.8255 1.0475l3.6525 6.2613h1.8569c1.4708.0046 2.5484-.1519 4.6501-1.5079L48.1794 48.0752Z"},null,-1),S("path",{fill:"currentColor",d:"m72.241 11.1333-2.9322 4.4621 3.633 5.4494c.6465.97.3847 2.2809-.5858 2.9274-.3594.2401-.7663.3546-1.1684.3546-.6824 0-1.3521-.3298-1.7585-.9399l-2.6392-3.9586-2.9142 4.4341 10.4108 17.0392c2.4339 3.9824 2.4223 8.9231-.0296 12.8948-.0316.0502-.0649.0998-.1002.1478l-1.2751 1.721c-.4142.5583-1.0523.8539-1.6977.8539-.437 0-.8777-.1351-1.2555-.4148-.9368-.6945-1.1331-2.0165-.4391-2.9533l1.2191-1.6444c1.5679-2.5981 1.5605-5.8099-.0243-8.4038L61.312 27.764 47.9648 48.0752 58.4611 32.253l5.1835 8.0079c2.6598 4.1096 2.6492 9.4007-.0269 13.5002l-6.1535 9.4265-9.4994-15.1124L60.1763 67.503l5.6262-7.5014c.6998-.932 2.0223-1.1209 2.9554-.4216.9325.6992 1.1214 2.0228.4221 2.9553l-6.5972 8.7964 3.2086 5.1043 15.5531-24.5568c1.7737-2.8002 1.7943-6.4322.0522-9.2519l-7.5219-12.1776c-.6121-.9916-.305-2.2925.6872-2.9052.9926-.6127 2.2925-.3051 2.9052.6866l7.5213 12.1776c2.5849 4.185 2.5543 9.5738-.077 13.7297l-16.4286 25.939c-.066.1045-.142.1979-.2222.2866l2.9232 4.6531c1.2737-1.0062 2.1804-1.8512 2.7202-2.5349 6.1947-7.8462 12.6421-17.273 19.342-28.2804 2.2942-3.7693 2.3543-8.4397.0845-12.1977-8.635-14.2955-18.2282-29.4527-21.0896-30.8708Z"},null,-1)])])}const wr=lt(br,[["render",_r]]),Sr={},Cr={class:"k-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 384 512"};function Er(e,t){return m(),I("svg",Cr,[...t[0]||(t[0]=[S("path",{fill:"currentColor",d:"M304 336h-128C167.2 336 160 343.2 160 352s7.156 16 16 16h128c8.844 0 16-7.156 16-16S312.8 336 304 336zM304 240h-96C199.2 240 192 247.2 192 256s7.156 16 16 16h96C312.8 272 320 264.8 320 256S312.8 240 304 240zM96 328c-13.25 0-24 10.74-24 24c0 13.25 10.75 24 24 24c13.26 0 24-10.75 24-24C120 338.7 109.3 328 96 328zM320 64c-8.844 0-16 7.156-16 16S311.2 96 320 96c17.64 0 32 14.34 32 32v320c0 17.66-14.36 32-32 32H64c-17.64 0-32-14.34-32-32V128c0-17.66 14.36-32 32-32c8.844 0 16-7.156 16-16S72.84 64 64 64C28.7 64 0 92.72 0 128v320c0 35.28 28.7 64 64 64h256c35.3 0 64-28.72 64-64V128C384 92.72 355.3 64 320 64zM112 128h160C280.8 128 288 120.8 288 112S280.8 96 272 96h-24.88C252.6 86.55 256 75.72 256 64c0-35.35-28.65-64-64-64S128 28.65 128 64c0 11.72 3.379 22.55 8.877 32H112C103.2 96 96 103.2 96 112S103.2 128 112 128zM192 32c17.64 0 32 14.36 32 32s-14.36 32-32 32S160 81.64 160 64S174.4 32 192 32zM68.25 229.2c-6 6.5-5.594 16.59 .9062 22.59l34.66 32C106.9 286.6 110.8 288 114.7 288c4.203 0 8.406-1.656 11.55-4.938l61.33-64c6.125-6.375 5.906-16.5-.4844-22.62c-6.359-6.094-16.48-5.906-22.61 .5L113.1 249.6L90.84 228.3C84.39 222.3 74.22 222.6 68.25 229.2z"},null,-1)])])}const xr=lt(Sr,[["render",Er]]);no.register("pm2:icon",wr);no.register("pm2:logs",xr);const Tr='a[href],button:not([disabled]),button:not([hidden]),:not([tabindex="-1"]),input:not([disabled]),input:not([type="hidden"]),select:not([disabled]),textarea:not([disabled])',kr=e=>getComputedStyle(e).position==="fixed"?false:e.offsetParent!==null,Tn=e=>Array.from(e.querySelectorAll(Tr)).filter(t=>Ir(t)&&kr(t)),Ir=e=>{if(e.tabIndex>0||e.tabIndex===0&&e.getAttribute("tabIndex")!==null)return true;if(e.disabled)return false;switch(e.nodeName){case"A":return!!e.href&&e.rel!=="ignore";case"INPUT":return!(e.type==="hidden"||e.type==="file");case"BUTTON":case"SELECT":case"TEXTAREA":return true;default:return false}},Mr=()=>he&&/firefox/i.test(window.navigator.userAgent);/**
|
|
2
|
+
* @vue/shared v3.5.26
|
|
3
|
+
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
|
+
* @license MIT
|
|
5
|
+
**/const et=()=>{},$r=Object.prototype.hasOwnProperty,Tt=(e,t)=>$r.call(e,t),Re=e=>typeof e=="function",ye=e=>typeof e=="string",nt=e=>e!==null&&typeof e=="object",Ar=e=>{const t=Object.create(null);return n=>t[n]||(t[n]=e(n))},Or=/-\w/g,Br=Ar(e=>e.replace(Or,t=>t.slice(1).toUpperCase()));var Lr=typeof global=="object"&&global&&global.Object===Object&&global,Nr=typeof self=="object"&&self&&self.Object===Object&&self,rn=Lr||Nr||Function("return this")(),Oe=rn.Symbol,uo=Object.prototype,Pr=uo.hasOwnProperty,Fr=uo.toString,Xe=Oe?Oe.toStringTag:void 0;function Rr(e){var t=Pr.call(e,Xe),n=e[Xe];try{e[Xe]=void 0;var o=true}catch{}var r=Fr.call(e);return o&&(t?e[Xe]=n:delete e[Xe]),r}var zr=Object.prototype,Hr=zr.toString;function Vr(e){return Hr.call(e)}var Dr="[object Null]",jr="[object Undefined]",kn=Oe?Oe.toStringTag:void 0;function sn(e){return e==null?e===void 0?jr:Dr:kn&&kn in Object(e)?Rr(e):Vr(e)}function an(e){return e!=null&&typeof e=="object"}var Ur="[object Symbol]";function ln(e){return typeof e=="symbol"||an(e)&&sn(e)==Ur}function Kr(e,t){for(var n=-1,o=e==null?0:e.length,r=Array(o);++n<o;)r[n]=t(e[n],n,e);return r}var ut=Array.isArray,In=Oe?Oe.prototype:void 0,Mn=In?In.toString:void 0;function co(e){if(typeof e=="string")return e;if(ut(e))return Kr(e,co)+"";if(ln(e))return Mn?Mn.call(e):"";var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function kt(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}function Gr(e){return e}var qr="[object AsyncFunction]",Yr="[object Function]",Wr="[object GeneratorFunction]",Xr="[object Proxy]";function Zr(e){if(!kt(e))return false;var t=sn(e);return t==Yr||t==Wr||t==qr||t==Xr}var Vt=rn["__core-js_shared__"],$n=function(){var e=/[^.]+$/.exec(Vt&&Vt.keys&&Vt.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function Jr(e){return!!$n&&$n in e}var Qr=Function.prototype,es=Qr.toString;function ts(e){if(e!=null){try{return es.call(e)}catch{}try{return e+""}catch{}}return""}var ns=/[\\^$.*+?()[\]{}|]/g,os=/^\[object .+?Constructor\]$/,rs=Function.prototype,ss=Object.prototype,as=rs.toString,is=ss.hasOwnProperty,ls=RegExp("^"+as.call(is).replace(ns,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function us(e){if(!kt(e)||Jr(e))return false;var t=Zr(e)?ls:os;return t.test(ts(e))}function cs(e,t){return e==null?void 0:e[t]}function un(e,t){var n=cs(e,t);return us(n)?n:void 0}function ds(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}var fs=800,ps=16,vs=Date.now;function hs(e){var t=0,n=0;return function(){var o=vs(),r=ps-(o-n);if(n=o,r>0){if(++t>=fs)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}function ms(e){return function(){return e}}var It=function(){try{var e=un(Object,"defineProperty");return e({},"",{}),e}catch{}}(),gs=It?function(e,t){return It(e,"toString",{configurable:true,enumerable:false,value:ms(t),writable:true})}:Gr,bs=hs(gs),ys=9007199254740991,_s=/^(?:0|[1-9]\d*)$/;function fo(e,t){var n=typeof e;return t=t??ys,!!t&&(n=="number"||n!="symbol"&&_s.test(e))&&e>-1&&e%1==0&&e<t}function ws(e,t,n){t=="__proto__"&&It?It(e,t,{configurable:true,enumerable:true,value:n,writable:true}):e[t]=n}function po(e,t){return e===t||e!==e&&t!==t}var Ss=Object.prototype,Cs=Ss.hasOwnProperty;function Es(e,t,n){var o=e[t];(!(Cs.call(e,t)&&po(o,n))||n===void 0&&!(t in e))&&ws(e,t,n)}var An=Math.max;function xs(e,t,n){return t=An(t===void 0?e.length-1:t,0),function(){for(var o=arguments,r=-1,s=An(o.length-t,0),a=Array(s);++r<s;)a[r]=o[t+r];r=-1;for(var l=Array(t+1);++r<t;)l[r]=o[r];return l[t]=n(a),ds(e,this,l)}}var Ts=9007199254740991;function ks(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=Ts}var Is="[object Arguments]";function On(e){return an(e)&&sn(e)==Is}var vo=Object.prototype,Ms=vo.hasOwnProperty,$s=vo.propertyIsEnumerable,ho=On(function(){return arguments}())?On:function(e){return an(e)&&Ms.call(e,"callee")&&!$s.call(e,"callee")},As=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Os=/^\w*$/;function Bs(e,t){if(ut(e))return false;var n=typeof e;return n=="number"||n=="symbol"||n=="boolean"||e==null||ln(e)?true:Os.test(e)||!As.test(e)||t!=null&&e in Object(t)}var ot=un(Object,"create");function Ls(){this.__data__=ot?ot(null):{},this.size=0}function Ns(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var Ps="__lodash_hash_undefined__",Fs=Object.prototype,Rs=Fs.hasOwnProperty;function zs(e){var t=this.__data__;if(ot){var n=t[e];return n===Ps?void 0:n}return Rs.call(t,e)?t[e]:void 0}var Hs=Object.prototype,Vs=Hs.hasOwnProperty;function Ds(e){var t=this.__data__;return ot?t[e]!==void 0:Vs.call(t,e)}var js="__lodash_hash_undefined__";function Us(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=ot&&t===void 0?js:t,this}function ze(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var o=e[t];this.set(o[0],o[1])}}ze.prototype.clear=Ls;ze.prototype.delete=Ns;ze.prototype.get=zs;ze.prototype.has=Ds;ze.prototype.set=Us;function Ks(){this.__data__=[],this.size=0}function Lt(e,t){for(var n=e.length;n--;)if(po(e[n][0],t))return n;return-1}var Gs=Array.prototype,qs=Gs.splice;function Ys(e){var t=this.__data__,n=Lt(t,e);if(n<0)return false;var o=t.length-1;return n==o?t.pop():qs.call(t,n,1),--this.size,true}function Ws(e){var t=this.__data__,n=Lt(t,e);return n<0?void 0:t[n][1]}function Xs(e){return Lt(this.__data__,e)>-1}function Zs(e,t){var n=this.__data__,o=Lt(n,e);return o<0?(++this.size,n.push([e,t])):n[o][1]=t,this}function Ke(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var o=e[t];this.set(o[0],o[1])}}Ke.prototype.clear=Ks;Ke.prototype.delete=Ys;Ke.prototype.get=Ws;Ke.prototype.has=Xs;Ke.prototype.set=Zs;var Js=un(rn,"Map");function Qs(){this.size=0,this.__data__={hash:new ze,map:new(Js||Ke),string:new ze}}function ea(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function Nt(e,t){var n=e.__data__;return ea(t)?n[typeof t=="string"?"string":"hash"]:n.map}function ta(e){var t=Nt(this,e).delete(e);return this.size-=t?1:0,t}function na(e){return Nt(this,e).get(e)}function oa(e){return Nt(this,e).has(e)}function ra(e,t){var n=Nt(this,e),o=n.size;return n.set(e,t),this.size+=n.size==o?0:1,this}function Ve(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var o=e[t];this.set(o[0],o[1])}}Ve.prototype.clear=Qs;Ve.prototype.delete=ta;Ve.prototype.get=na;Ve.prototype.has=oa;Ve.prototype.set=ra;var sa="Expected a function";function cn(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(sa);var n=function(){var o=arguments,r=t?t.apply(this,o):o[0],s=n.cache;if(s.has(r))return s.get(r);var a=e.apply(this,o);return n.cache=s.set(r,a)||s,a};return n.cache=new(cn.Cache||Ve),n}cn.Cache=Ve;var aa=500;function ia(e){var t=cn(e,function(o){return n.size===aa&&n.clear(),o}),n=t.cache;return t}var la=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ua=/\\(\\)?/g,ca=ia(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(la,function(n,o,r,s){t.push(r?s.replace(ua,"$1"):o||n)}),t});function da(e){return e==null?"":co(e)}function Pt(e,t){return ut(e)?e:Bs(e,t)?[e]:ca(da(e))}function dn(e){if(typeof e=="string"||ln(e))return e;var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function mo(e,t){t=Pt(t,e);for(var n=0,o=t.length;e!=null&&n<o;)e=e[dn(t[n++])];return n&&n==o?e:void 0}function fa(e,t,n){var o=e==null?void 0:mo(e,t);return o===void 0?n:o}function pa(e,t){for(var n=-1,o=t.length,r=e.length;++n<o;)e[r+n]=t[n];return e}var Bn=Oe?Oe.isConcatSpreadable:void 0;function va(e){return ut(e)||ho(e)||!!(Bn&&e&&e[Bn])}function ha(e,t,n,o,r){var s=-1,a=e.length;for(n||(n=va),r||(r=[]);++s<a;){var l=e[s];n(l)?pa(r,l):r[r.length]=l}return r}function ma(e){var t=e==null?0:e.length;return t?ha(e):[]}function ga(e){return bs(xs(e,void 0,ma),e+"")}function ba(e,t){return e!=null&&t in Object(e)}function ya(e,t,n){t=Pt(t,e);for(var o=-1,r=t.length,s=false;++o<r;){var a=dn(t[o]);if(!(s=e!=null&&n(e,a)))break;e=e[a]}return s||++o!=r?s:(r=e==null?0:e.length,!!r&&ks(r)&&fo(a,r)&&(ut(e)||ho(e)))}function _a(e,t){return e!=null&&ya(e,t,ba)}function go(e){for(var t=-1,n=e==null?0:e.length,o={};++t<n;){var r=e[t];o[r[0]]=r[1]}return o}function bo(e){return e==null}function wa(e,t,n,o){if(!kt(e))return e;t=Pt(t,e);for(var r=-1,s=t.length,a=s-1,l=e;l!=null&&++r<s;){var i=dn(t[r]),u=n;if(i==="__proto__"||i==="constructor"||i==="prototype")return e;if(r!=a){var p=l[i];u=void 0,u===void 0&&(u=kt(p)?p:fo(t[r+1])?[]:{})}Es(l,i,u),l=l[i]}return e}function Sa(e,t,n){for(var o=-1,r=t.length,s={};++o<r;){var a=t[o],l=mo(e,a);n(l,a)&&wa(s,Pt(a,e),l)}return s}function Ca(e,t){return Sa(e,t,function(n,o){return _a(e,o)})}var Ea=ga(function(e,t){return e==null?{}:Ca(e,t)});const yo=e=>e===void 0,He=e=>typeof e=="number",Wt=e=>typeof Element>"u"?false:e instanceof Element,xa=e=>ye(e)?!Number.isNaN(Number(e)):false,Ln=e=>Object.keys(e);class Ta extends Error{constructor(t){super(t),this.name="ElementPlusError"}}function ka(e,t){throw new Ta(`[${e}] ${t}`)}const _o=(e="")=>e.split(" ").filter(t=>!!t.trim()),Nn=(e,t)=>{if(!e||!t)return false;if(t.includes(" "))throw new Error("className should not contain space.");return e.classList.contains(t)},Ia=(e,t)=>{!e||!t.trim()||e.classList.add(..._o(t))},Ma=(e,t)=>{!e||!t.trim()||e.classList.remove(..._o(t))},$a=(e,t)=>{var n;if(!he||!e||!t)return"";let o=Br(t);o==="float"&&(o="cssFloat");try{const r=e.style[o];if(r)return r;const s=(n=document.defaultView)==null?void 0:n.getComputedStyle(e,"");return s?s[o]:""}catch{return e.style[o]}};function rt(e,t="px"){if(!e)return"";if(He(e)||xa(e))return`${e}${t}`;if(ye(e))return e}let ht;const Aa=e=>{var t;if(!he)return 0;if(ht!==void 0)return ht;const n=document.createElement("div");n.className=`${e}-scrollbar__wrap`,n.style.visibility="hidden",n.style.width="100px",n.style.position="absolute",n.style.top="-9999px",document.body.appendChild(n);const o=n.offsetWidth;n.style.overflow="scroll";const r=document.createElement("div");r.style.width="100%",n.appendChild(r);const s=r.offsetWidth;return(t=n.parentNode)==null||t.removeChild(n),ht=o-s,ht};/*! Element Plus Icons Vue v2.3.2 */var Oa=H({name:"CircleCheck",__name:"circle-check",setup(e){return(t,n)=>(m(),I("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[S("path",{fill:"currentColor",d:"M512 896a384 384 0 1 0 0-768 384 384 0 0 0 0 768m0 64a448 448 0 1 1 0-896 448 448 0 0 1 0 896"}),S("path",{fill:"currentColor",d:"M745.344 361.344a32 32 0 0 1 45.312 45.312l-288 288a32 32 0 0 1-45.312 0l-160-160a32 32 0 1 1 45.312-45.312L480 626.752z"})]))}}),Ba=Oa,La=H({name:"CircleCloseFilled",__name:"circle-close-filled",setup(e){return(t,n)=>(m(),I("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[S("path",{fill:"currentColor",d:"M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896m0 393.664L407.936 353.6a38.4 38.4 0 1 0-54.336 54.336L457.664 512 353.6 616.064a38.4 38.4 0 1 0 54.336 54.336L512 566.336 616.064 670.4a38.4 38.4 0 1 0 54.336-54.336L566.336 512 670.4 407.936a38.4 38.4 0 1 0-54.336-54.336z"})]))}}),wo=La,Na=H({name:"CircleClose",__name:"circle-close",setup(e){return(t,n)=>(m(),I("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[S("path",{fill:"currentColor",d:"m466.752 512-90.496-90.496a32 32 0 0 1 45.248-45.248L512 466.752l90.496-90.496a32 32 0 1 1 45.248 45.248L557.248 512l90.496 90.496a32 32 0 1 1-45.248 45.248L512 557.248l-90.496 90.496a32 32 0 0 1-45.248-45.248z"}),S("path",{fill:"currentColor",d:"M512 896a384 384 0 1 0 0-768 384 384 0 0 0 0 768m0 64a448 448 0 1 1 0-896 448 448 0 0 1 0 896"})]))}}),So=Na,Pa=H({name:"Close",__name:"close",setup(e){return(t,n)=>(m(),I("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[S("path",{fill:"currentColor",d:"M764.288 214.592 512 466.88 259.712 214.592a31.936 31.936 0 0 0-45.12 45.12L466.752 512 214.528 764.224a31.936 31.936 0 1 0 45.12 45.184L512 557.184l252.288 252.288a31.936 31.936 0 0 0 45.12-45.12L557.12 512.064l252.288-252.352a31.936 31.936 0 1 0-45.12-45.184z"})]))}}),Fa=Pa,Ra=H({name:"Hide",__name:"hide",setup(e){return(t,n)=>(m(),I("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[S("path",{fill:"currentColor",d:"M876.8 156.8c0-9.6-3.2-16-9.6-22.4s-12.8-9.6-22.4-9.6-16 3.2-22.4 9.6L736 220.8c-64-32-137.6-51.2-224-60.8-160 16-288 73.6-377.6 176S0 496 0 512s48 73.6 134.4 176c22.4 25.6 44.8 48 73.6 67.2l-86.4 89.6c-6.4 6.4-9.6 12.8-9.6 22.4s3.2 16 9.6 22.4 12.8 9.6 22.4 9.6 16-3.2 22.4-9.6l704-710.4c3.2-6.4 6.4-12.8 6.4-22.4m-646.4 528Q115.2 579.2 76.8 512q43.2-72 153.6-172.8C304 272 400 230.4 512 224c64 3.2 124.8 19.2 176 44.8l-54.4 54.4C598.4 300.8 560 288 512 288c-64 0-115.2 22.4-160 64s-64 96-64 160c0 48 12.8 89.6 35.2 124.8L256 707.2c-9.6-6.4-19.2-16-25.6-22.4m140.8-96Q352 555.2 352 512c0-44.8 16-83.2 48-112s67.2-48 112-48c28.8 0 54.4 6.4 73.6 19.2zM889.599 336c-12.8-16-28.8-28.8-41.6-41.6l-48 48c73.6 67.2 124.8 124.8 150.4 169.6q-43.2 72-153.6 172.8c-73.6 67.2-172.8 108.8-284.8 115.2-51.2-3.2-99.2-12.8-140.8-28.8l-48 48c57.6 22.4 118.4 38.4 188.8 44.8 160-16 288-73.6 377.6-176S1024 528 1024 512s-48.001-73.6-134.401-176"}),S("path",{fill:"currentColor",d:"M511.998 672c-12.8 0-25.6-3.2-38.4-6.4l-51.2 51.2c28.8 12.8 57.6 19.2 89.6 19.2 64 0 115.2-22.4 160-64 41.6-41.6 64-96 64-160 0-32-6.4-64-19.2-89.6l-51.2 51.2c3.2 12.8 6.4 25.6 6.4 38.4 0 44.8-16 83.2-48 112s-67.2 48-112 48"})]))}}),za=Ra,Ha=H({name:"InfoFilled",__name:"info-filled",setup(e){return(t,n)=>(m(),I("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[S("path",{fill:"currentColor",d:"M512 64a448 448 0 1 1 0 896.064A448 448 0 0 1 512 64m67.2 275.072c33.28 0 60.288-23.104 60.288-57.344s-27.072-57.344-60.288-57.344c-33.28 0-60.16 23.104-60.16 57.344s26.88 57.344 60.16 57.344M590.912 699.2c0-6.848 2.368-24.64 1.024-34.752l-52.608 60.544c-10.88 11.456-24.512 19.392-30.912 17.28a12.99 12.99 0 0 1-8.256-14.72l87.68-276.992c7.168-35.136-12.544-67.2-54.336-71.296-44.096 0-108.992 44.736-148.48 101.504 0 6.784-1.28 23.68.064 33.792l52.544-60.608c10.88-11.328 23.552-19.328 29.952-17.152a12.8 12.8 0 0 1 7.808 16.128L388.48 728.576c-10.048 32.256 8.96 63.872 55.04 71.04 67.84 0 107.904-43.648 147.456-100.416z"})]))}}),Co=Ha,Va=H({name:"Loading",__name:"loading",setup(e){return(t,n)=>(m(),I("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[S("path",{fill:"currentColor",d:"M512 64a32 32 0 0 1 32 32v192a32 32 0 0 1-64 0V96a32 32 0 0 1 32-32m0 640a32 32 0 0 1 32 32v192a32 32 0 1 1-64 0V736a32 32 0 0 1 32-32m448-192a32 32 0 0 1-32 32H736a32 32 0 1 1 0-64h192a32 32 0 0 1 32 32m-640 0a32 32 0 0 1-32 32H96a32 32 0 0 1 0-64h192a32 32 0 0 1 32 32M195.2 195.2a32 32 0 0 1 45.248 0L376.32 331.008a32 32 0 0 1-45.248 45.248L195.2 240.448a32 32 0 0 1 0-45.248m452.544 452.544a32 32 0 0 1 45.248 0L828.8 783.552a32 32 0 0 1-45.248 45.248L647.744 692.992a32 32 0 0 1 0-45.248M828.8 195.264a32 32 0 0 1 0 45.184L692.992 376.32a32 32 0 0 1-45.248-45.248l135.808-135.808a32 32 0 0 1 45.248 0m-452.544 452.48a32 32 0 0 1 0 45.248L240.448 828.8a32 32 0 0 1-45.248-45.248l135.808-135.808a32 32 0 0 1 45.248 0"})]))}}),Mt=Va,Da=H({name:"SuccessFilled",__name:"success-filled",setup(e){return(t,n)=>(m(),I("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[S("path",{fill:"currentColor",d:"M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896m-55.808 536.384-99.52-99.584a38.4 38.4 0 1 0-54.336 54.336l126.72 126.72a38.27 38.27 0 0 0 54.336 0l262.4-262.464a38.4 38.4 0 1 0-54.272-54.336z"})]))}}),Eo=Da,ja=H({name:"View",__name:"view",setup(e){return(t,n)=>(m(),I("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[S("path",{fill:"currentColor",d:"M512 160c320 0 512 352 512 352S832 864 512 864 0 512 0 512s192-352 512-352m0 64c-225.28 0-384.128 208.064-436.8 288 52.608 79.872 211.456 288 436.8 288 225.28 0 384.128-208.064 436.8-288-52.608-79.872-211.456-288-436.8-288m0 64a224 224 0 1 1 0 448 224 224 0 0 1 0-448m0 64a160.19 160.19 0 0 0-160 160c0 88.192 71.744 160 160 160s160-71.808 160-160-71.744-160-160-160"})]))}}),Ua=ja,Ka=H({name:"WarningFilled",__name:"warning-filled",setup(e){return(t,n)=>(m(),I("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[S("path",{fill:"currentColor",d:"M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896m0 192a58.43 58.43 0 0 0-58.24 63.744l23.36 256.384a35.072 35.072 0 0 0 69.76 0l23.296-256.384A58.43 58.43 0 0 0 512 256m0 512a51.2 51.2 0 1 0 0-102.4 51.2 51.2 0 0 0 0 102.4"})]))}}),xo=Ka;const To="__epPropKey",J=e=>e,Ga=e=>nt(e)&&!!e[To],ko=(e,t)=>{if(!nt(e)||Ga(e))return e;const{values:n,required:o,default:r,type:s,validator:a}=e,i={type:s,required:!!o,validator:n||a?u=>{let p=false,f=[];if(n&&(f=Array.from(n),Tt(e,"default")&&f.push(r),p||(p=f.includes(u))),a&&(p||(p=a(u))),!p&&f.length>0){const g=[...new Set(f)].map(x=>JSON.stringify(x)).join(", ");ur(`Invalid prop: validation failed${t?` for prop "${t}"`:""}. Expected one of [${g}], got value ${JSON.stringify(u)}.`)}return p}:void 0,[To]:true};return Tt(e,"default")&&(i.default=r),i},xe=e=>go(Object.entries(e).map(([t,n])=>[t,ko(n,t)])),st=J([String,Object,Function]),Io={Close:Fa,SuccessFilled:Eo,InfoFilled:Co,WarningFilled:xo,CircleCloseFilled:wo},$t={success:Eo,warning:xo,error:wo,info:Co},qa={validating:Mt,success:Ba,error:So},Ft=(e,t)=>{if(e.install=n=>{for(const o of[e,...Object.values(t??{})])n.component(o.name,o)},t)for(const[n,o]of Object.entries(t))e[n]=o;return e},Ya=(e,t)=>(e.install=n=>{e._context=n._context,n.config.globalProperties[t]=e},e),Wa=e=>(e.install=et,e),Rt={tab:"Tab",esc:"Escape"},Xt="update:modelValue",Mo=["","default","small","large"],Xa=e=>["",...Mo].includes(e);var St=(e=>(e[e.TEXT=1]="TEXT",e[e.CLASS=2]="CLASS",e[e.STYLE=4]="STYLE",e[e.PROPS=8]="PROPS",e[e.FULL_PROPS=16]="FULL_PROPS",e[e.HYDRATE_EVENTS=32]="HYDRATE_EVENTS",e[e.STABLE_FRAGMENT=64]="STABLE_FRAGMENT",e[e.KEYED_FRAGMENT=128]="KEYED_FRAGMENT",e[e.UNKEYED_FRAGMENT=256]="UNKEYED_FRAGMENT",e[e.NEED_PATCH=512]="NEED_PATCH",e[e.DYNAMIC_SLOTS=1024]="DYNAMIC_SLOTS",e[e.HOISTED=-1]="HOISTED",e[e.BAIL=-2]="BAIL",e))(St||{});const Za=e=>/([\uAC00-\uD7AF\u3130-\u318F])+/gi.test(e),$o=e=>e,Ja=["class","style"],Qa=/^on[A-Z]/,ei=(e={})=>{const{excludeListeners:t=false,excludeKeys:n}=e,o=y(()=>((n==null?void 0:n.value)||[]).concat(Ja)),r=Ce();return r?y(()=>{var s;return go(Object.entries((s=r.proxy)==null?void 0:s.$attrs).filter(([a])=>!o.value.includes(a)&&!(t&&Qa.test(a))))}):y(()=>({}))},At=({from:e,replacement:t,scope:n,version:o,ref:r,type:s="API"},a)=>{ne(()=>d(a),l=>{},{immediate:true})},ti=(e,t,n,o)=>{let r={offsetX:0,offsetY:0};const s=i=>{const u=i.clientX,p=i.clientY,{offsetX:f,offsetY:g}=r,x=e.value.getBoundingClientRect(),v=x.left,c=x.top,_=x.width,T=x.height,L=document.documentElement.clientWidth,W=document.documentElement.clientHeight,j=-v+f,G=-c+g,ie=L-v-_+f,A=W-c-T+g,q=oe=>{let X=f+oe.clientX-u,U=g+oe.clientY-p;o!=null&&o.value||(X=Math.min(Math.max(X,j),ie),U=Math.min(Math.max(U,G),A)),r={offsetX:X,offsetY:U},e.value&&(e.value.style.transform=`translate(${rt(X)}, ${rt(U)})`)},le=()=>{document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",le)};document.addEventListener("mousemove",q),document.addEventListener("mouseup",le)},a=()=>{t.value&&e.value&&t.value.addEventListener("mousedown",s)},l=()=>{t.value&&e.value&&t.value.removeEventListener("mousedown",s)};Ee(()=>{cr(()=>{n.value?a():l()})}),it(()=>{l()})};var ni={name:"en",el:{breadcrumb:{label:"Breadcrumb"},colorpicker:{confirm:"OK",clear:"Clear",defaultLabel:"color picker",description:"current color is {color}. press enter to select a new color."},datepicker:{now:"Now",today:"Today",cancel:"Cancel",clear:"Clear",confirm:"OK",dateTablePrompt:"Use the arrow keys and enter to select the day of the month",monthTablePrompt:"Use the arrow keys and enter to select the month",yearTablePrompt:"Use the arrow keys and enter to select the year",selectedDate:"Selected date",selectDate:"Select date",selectTime:"Select time",startDate:"Start Date",startTime:"Start Time",endDate:"End Date",endTime:"End Time",prevYear:"Previous Year",nextYear:"Next Year",prevMonth:"Previous Month",nextMonth:"Next Month",year:"",month1:"January",month2:"February",month3:"March",month4:"April",month5:"May",month6:"June",month7:"July",month8:"August",month9:"September",month10:"October",month11:"November",month12:"December",week:"week",weeks:{sun:"Sun",mon:"Mon",tue:"Tue",wed:"Wed",thu:"Thu",fri:"Fri",sat:"Sat"},weeksFull:{sun:"Sunday",mon:"Monday",tue:"Tuesday",wed:"Wednesday",thu:"Thursday",fri:"Friday",sat:"Saturday"},months:{jan:"Jan",feb:"Feb",mar:"Mar",apr:"Apr",may:"May",jun:"Jun",jul:"Jul",aug:"Aug",sep:"Sep",oct:"Oct",nov:"Nov",dec:"Dec"}},inputNumber:{decrease:"decrease number",increase:"increase number"},select:{loading:"Loading",noMatch:"No matching data",noData:"No data",placeholder:"Select"},dropdown:{toggleDropdown:"Toggle Dropdown"},cascader:{noMatch:"No matching data",loading:"Loading",placeholder:"Select",noData:"No data"},pagination:{goto:"Go to",pagesize:"/page",total:"Total {total}",pageClassifier:"",page:"Page",prev:"Go to previous page",next:"Go to next page",currentPage:"page {pager}",prevPages:"Previous {pager} pages",nextPages:"Next {pager} pages",deprecationWarning:"Deprecated usages detected, please refer to the el-pagination documentation for more details"},dialog:{close:"Close this dialog"},drawer:{close:"Close this dialog"},messagebox:{title:"Message",confirm:"OK",cancel:"Cancel",error:"Illegal input",close:"Close this dialog"},upload:{deleteTip:"press delete to remove",delete:"Delete",preview:"Preview",continue:"Continue"},slider:{defaultLabel:"slider between {min} and {max}",defaultRangeStartLabel:"pick start value",defaultRangeEndLabel:"pick end value"},table:{emptyText:"No Data",confirmFilter:"Confirm",resetFilter:"Reset",clearFilter:"All",sumText:"Sum"},tour:{next:"Next",previous:"Previous",finish:"Finish"},tree:{emptyText:"No Data"},transfer:{noMatch:"No matching data",noData:"No data",titles:["List 1","List 2"],filterPlaceholder:"Enter keyword",noCheckedFormat:"{total} items",hasCheckedFormat:"{checked}/{total} checked"},image:{error:"FAILED"},pageHeader:{title:"Back"},popconfirm:{confirmButtonText:"Yes",cancelButtonText:"No"},carousel:{leftArrow:"Carousel arrow left",rightArrow:"Carousel arrow right",indicator:"Carousel switch to index {index}"}}};const oi=e=>(t,n)=>ri(t,n,d(e)),ri=(e,t,n)=>fa(n,e,e).replace(/\{(\w+)\}/g,(o,r)=>{var s;return`${(s=t==null?void 0:t[r])!=null?s:`{${r}}`}`}),si=e=>{const t=y(()=>d(e).name),n=oo(e)?e:B(e);return{lang:t,locale:n,t:oi(e)}},Ao=Symbol("localeContextKey"),ai=e=>{const t=e||ae(Ao,B());return si(y(()=>t.value||ni))},Ct="el",ii="is-",Ne=(e,t,n,o,r)=>{let s=`${e}-${t}`;return n&&(s+=`-${n}`),o&&(s+=`__${o}`),r&&(s+=`--${r}`),s},Oo=Symbol("namespaceContextKey"),Bo=e=>{const t=e||(Ce()?ae(Oo,B(Ct)):B(Ct));return y(()=>d(t)||Ct)},_e=(e,t)=>{const n=Bo(t);return{namespace:n,b:(c="")=>Ne(n.value,e,c,"",""),e:c=>c?Ne(n.value,e,"",c,""):"",m:c=>c?Ne(n.value,e,"","",c):"",be:(c,_)=>c&&_?Ne(n.value,e,c,_,""):"",em:(c,_)=>c&&_?Ne(n.value,e,"",c,_):"",bm:(c,_)=>c&&_?Ne(n.value,e,c,"",_):"",bem:(c,_,T)=>c&&_&&T?Ne(n.value,e,c,_,T):"",is:(c,..._)=>{const T=_.length>=1?_[0]:true;return c&&T?`${ii}${c}`:""},cssVar:c=>{const _={};for(const T in c)c[T]&&(_[`--${n.value}-${T}`]=c[T]);return _},cssVarName:c=>`--${n.value}-${c}`,cssVarBlock:c=>{const _={};for(const T in c)c[T]&&(_[`--${n.value}-${e}-${T}`]=c[T]);return _},cssVarBlockName:c=>`--${n.value}-${e}-${c}`}},li=(e,t={})=>{oo(e)||ka("[useLockscreen]","You need to pass a ref param to this function");const n=t.ns||_e("popup"),o=y(()=>n.bm("parent","hidden"));if(!he||Nn(document.body,o.value))return;let r=0,s=false,a="0";const l=()=>{setTimeout(()=>{Ma(document==null?void 0:document.body,o.value),s&&document&&(document.body.style.width=a)},200)};ne(e,i=>{if(!i){l();return}s=!Nn(document.body,o.value),s&&(a=document.body.style.width),r=Aa(n.namespace.value);const u=document.documentElement.clientHeight<document.body.scrollHeight,p=$a(document.body,"overflowY");r>0&&(u||p==="scroll")&&s&&(document.body.style.width=`calc(100% - ${r}px)`),Ia(document.body,o.value)}),dr(()=>l())},Lo=e=>{const t=Ce();return y(()=>{var n,o;return(o=(n=t==null?void 0:t.proxy)==null?void 0:n.$props)==null?void 0:o[e]})},No=e=>{if(!e)return{onClick:et,onMousedown:et,onMouseup:et};let t=false,n=false;return{onClick:a=>{t&&n&&e(a),t=n=false},onMousedown:a=>{t=a.target===a.currentTarget},onMouseup:a=>{n=a.target===a.currentTarget}}},Pn={prefix:Math.floor(Math.random()*1e4),current:0},ui=Symbol("elIdInjection"),ci=()=>Ce()?ae(ui,Pn):Pn,Zt=e=>{const t=ci(),n=Bo();return y(()=>d(e)||`${n.value}-id-${t.prefix}-${t.current++}`)};let De=[];const Fn=e=>{const t=e;t.key===Rt.esc&&De.forEach(n=>n(t))},di=e=>{Ee(()=>{De.length===0&&document.addEventListener("keydown",Fn),he&&De.push(e)}),it(()=>{De=De.filter(t=>t!==e),De.length===0&&he&&document.removeEventListener("keydown",Fn)})},Rn={current:0},zn=B(0),Po=2e3,Hn=Symbol("elZIndexContextKey"),Fo=Symbol("zIndexContextKey"),fi=e=>{const t=Ce()?ae(Hn,Rn):Rn,n=e||(Ce()?ae(Fo,void 0):void 0),o=y(()=>{const a=d(n);return He(a)?a:Po}),r=y(()=>o.value+zn.value),s=()=>(t.current++,zn.value=t.current,r.value);return!he&&ae(Hn),{initialZIndex:o,currentZIndex:r,nextZIndex:s}};function pi(e){const t=B();function n(){if(e.value==null)return;const{selectionStart:r,selectionEnd:s,value:a}=e.value;if(r==null||s==null)return;const l=a.slice(0,Math.max(0,r)),i=a.slice(Math.max(0,s));t.value={selectionStart:r,selectionEnd:s,value:a,beforeTxt:l,afterTxt:i}}function o(){if(e.value==null||t.value==null)return;const{value:r}=e.value,{beforeTxt:s,afterTxt:a,selectionStart:l}=t.value;if(s==null||a==null||l==null)return;let i=r.length;if(r.endsWith(a))i=r.length-a.length;else if(r.startsWith(s))i=s.length;else{const u=s[l-1],p=r.indexOf(u,l-1);p!==-1&&(i=p+1)}e.value.setSelectionRange(i,i)}return[n,o]}const fn=ko({type:String,values:Mo,required:false}),Ro=Symbol("size"),vi=()=>{const e=ae(Ro,{});return y(()=>d(e.size)||"")};function hi(e,{afterFocus:t,beforeBlur:n,afterBlur:o}={}){const r=Ce(),{emit:s}=r,a=wt(),l=B(false),i=f=>{l.value||(l.value=true,s("focus",f),t==null||t())},u=f=>{var g;Re(n)&&n(f)||f.relatedTarget&&((g=a.value)!=null&&g.contains(f.relatedTarget))||(l.value=false,s("blur",f),o==null||o())},p=()=>{var f;(f=e.value)==null||f.focus()};return ne(a,f=>{f&&f.setAttribute("tabindex","-1")}),io(a,"click",p),{wrapperRef:a,isFocused:l,handleFocus:i,handleBlur:u}}const mi=Symbol("emptyValuesContextKey"),gi=xe({emptyValues:Array,valueOnClear:{type:[String,Number,Boolean,Function],default:void 0,validator:e=>Re(e)?!e():!e}}),bi=xe({ariaLabel:String,ariaOrientation:{type:String,values:["horizontal","vertical","undefined"]},ariaControls:String}),yi=e=>Ea(bi,e),zo=Symbol(),Ot=B();function pn(e,t=void 0){const n=Ce()?ae(zo,Ot):Ot;return e?y(()=>{var o,r;return(r=(o=n.value)==null?void 0:o[e])!=null?r:t}):n}function Ho(e,t){const n=pn(),o=_e(e,y(()=>{var l;return((l=n.value)==null?void 0:l.namespace)||Ct})),r=ai(y(()=>{var l;return(l=n.value)==null?void 0:l.locale})),s=fi(y(()=>{var l;return((l=n.value)==null?void 0:l.zIndex)||Po})),a=y(()=>{var l;return d(t)||((l=n.value)==null?void 0:l.size)||""});return Vo(y(()=>d(n)||{})),{ns:o,locale:r,zIndex:s,size:a}}const Vo=(e,t,n=false)=>{var o;const r=!!Ce(),s=r?pn():void 0,a=(o=void 0)!=null?o:r?nn:void 0;if(!a)return;const l=y(()=>{const i=d(e);return s!=null&&s.value?_i(s.value,i):i});return a(zo,l),a(Ao,y(()=>l.value.locale)),a(Oo,y(()=>l.value.namespace)),a(Fo,y(()=>l.value.zIndex)),a(Ro,{size:y(()=>l.value.size||"")}),a(mi,y(()=>({emptyValues:l.value.emptyValues,valueOnClear:l.value.valueOnClear}))),(n||!Ot.value)&&(Ot.value=l.value),l},_i=(e,t)=>{const n=[...new Set([...Ln(e),...Ln(t)])],o={};for(const r of n)o[r]=t[r]!==void 0?t[r]:e[r];return o},wi=xe({a11y:{type:Boolean,default:true},locale:{type:J(Object)},size:fn,button:{type:J(Object)},experimentalFeatures:{type:J(Object)},keyboardNavigation:{type:Boolean,default:true},message:{type:J(Object)},zIndex:Number,namespace:{type:String,default:"el"},...gi}),Jt={};H({name:"ElConfigProvider",props:wi,setup(e,{slots:t}){ne(()=>e.message,o=>{Object.assign(Jt,o??{})},{immediate:true,deep:true});const n=Vo(e);return()=>te(t,"default",{config:n==null?void 0:n.value})}});var Be=(e,t)=>{const n=e.__vccOpts||e;for(const[o,r]of t)n[o]=r;return n};const Si=xe({size:{type:J([Number,String])},color:{type:String}}),Ci=H({name:"ElIcon",inheritAttrs:false}),Ei=H({...Ci,props:Si,setup(e){const t=e,n=_e("icon"),o=y(()=>{const{size:r,color:s}=t;return!r&&!s?{}:{fontSize:yo(r)?void 0:rt(r),"--color":s}});return(r,s)=>(m(),I("i",Ze({class:d(n).b(),style:d(o)},r.$attrs),[te(r.$slots,"default")],16))}});var xi=Be(Ei,[["__file","icon.vue"]]);const be=Ft(xi),vn=Symbol("formContextKey"),Do=Symbol("formItemContextKey"),jo=(e,t={})=>{const n=B(void 0),o=t.prop?n:Lo("size"),r=t.global?n:vi(),s=t.form?{size:void 0}:ae(vn,void 0),a=t.formItem?{size:void 0}:ae(Do,void 0);return y(()=>o.value||d(e)||(a==null?void 0:a.size)||(s==null?void 0:s.size)||r.value||"")},hn=e=>{const t=Lo("disabled"),n=ae(vn,void 0);return y(()=>t.value||d(e)||(n==null?void 0:n.disabled)||false)},Uo=()=>{const e=ae(vn,void 0),t=ae(Do,void 0);return{form:e,formItem:t}},Ti=(e,{formItemContext:t,disableIdGeneration:n,disableIdManagement:o})=>{n||(n=B(false)),o||(o=B(false));const r=B();let s;const a=y(()=>{var l;return!!(!(e.label||e.ariaLabel)&&t&&t.inputIds&&((l=t.inputIds)==null?void 0:l.length)<=1)});return Ee(()=>{s=ne([Et(e,"id"),n],([l,i])=>{const u=l??(i?void 0:Zt().value);u!==r.value&&(t!=null&&t.removeInputId&&(r.value&&t.removeInputId(r.value),!(o!=null&&o.value)&&!i&&u&&t.addInputId(u)),r.value=u)},{immediate:true})}),ro(()=>{s&&s(),t!=null&&t.removeInputId&&r.value&&t.removeInputId(r.value)}),{isLabeledByFormItem:a,inputId:r}};let fe;const ki=`
|
|
6
|
+
height:0 !important;
|
|
7
|
+
visibility:hidden !important;
|
|
8
|
+
${Mr()?"":"overflow:hidden !important;"}
|
|
9
|
+
position:absolute !important;
|
|
10
|
+
z-index:-1000 !important;
|
|
11
|
+
top:0 !important;
|
|
12
|
+
right:0 !important;
|
|
13
|
+
`,Ii=["letter-spacing","line-height","padding-top","padding-bottom","font-family","font-weight","font-size","text-rendering","text-transform","width","text-indent","padding-left","padding-right","border-width","box-sizing"];function Mi(e){const t=window.getComputedStyle(e),n=t.getPropertyValue("box-sizing"),o=Number.parseFloat(t.getPropertyValue("padding-bottom"))+Number.parseFloat(t.getPropertyValue("padding-top")),r=Number.parseFloat(t.getPropertyValue("border-bottom-width"))+Number.parseFloat(t.getPropertyValue("border-top-width"));return{contextStyle:Ii.map(a=>`${a}:${t.getPropertyValue(a)}`).join(";"),paddingSize:o,borderSize:r,boxSizing:n}}function Vn(e,t=1,n){var o;fe||(fe=document.createElement("textarea"),document.body.appendChild(fe));const{paddingSize:r,borderSize:s,boxSizing:a,contextStyle:l}=Mi(e);fe.setAttribute("style",`${l};${ki}`),fe.value=e.value||e.placeholder||"";let i=fe.scrollHeight;const u={};a==="border-box"?i=i+s:a==="content-box"&&(i=i-r),fe.value="";const p=fe.scrollHeight-r;if(He(t)){let f=p*t;a==="border-box"&&(f=f+r+s),i=Math.max(f,i),u.minHeight=`${f}px`}if(He(n)){let f=p*n;a==="border-box"&&(f=f+r+s),i=Math.min(f,i)}return u.height=`${i}px`,(o=fe.parentNode)==null||o.removeChild(fe),fe=void 0,u}const $i=xe({id:{type:String,default:void 0},size:fn,disabled:Boolean,modelValue:{type:J([String,Number,Object]),default:""},maxlength:{type:[String,Number]},minlength:{type:[String,Number]},type:{type:String,default:"text"},resize:{type:String,values:["none","both","horizontal","vertical"]},autosize:{type:J([Boolean,Object]),default:false},autocomplete:{type:String,default:"off"},formatter:{type:Function},parser:{type:Function},placeholder:{type:String},form:{type:String},readonly:{type:Boolean,default:false},clearable:{type:Boolean,default:false},showPassword:{type:Boolean,default:false},showWordLimit:{type:Boolean,default:false},suffixIcon:{type:st},prefixIcon:{type:st},containerRole:{type:String,default:void 0},label:{type:String,default:void 0},tabindex:{type:[String,Number],default:0},validateEvent:{type:Boolean,default:true},inputStyle:{type:J([Object,Array,String]),default:()=>$o({})},autofocus:{type:Boolean,default:false},...yi(["ariaLabel"])}),Ai={[Xt]:e=>ye(e),input:e=>ye(e),change:e=>ye(e),focus:e=>e instanceof FocusEvent,blur:e=>e instanceof FocusEvent,clear:()=>true,mouseleave:e=>e instanceof MouseEvent,mouseenter:e=>e instanceof MouseEvent,keydown:e=>e instanceof Event,compositionstart:e=>e instanceof CompositionEvent,compositionupdate:e=>e instanceof CompositionEvent,compositionend:e=>e instanceof CompositionEvent},Oi=["role"],Bi=["id","minlength","maxlength","type","disabled","readonly","autocomplete","tabindex","aria-label","placeholder","form","autofocus"],Li=["id","minlength","maxlength","tabindex","disabled","readonly","autocomplete","aria-label","placeholder","form","autofocus"],Ni=H({name:"ElInput",inheritAttrs:false}),Pi=H({...Ni,props:$i,emits:Ai,setup(e,{expose:t,emit:n}){const o=e,r=fr(),s=so(),a=y(()=>{const h={};return o.containerRole==="combobox"&&(h["aria-haspopup"]=r["aria-haspopup"],h["aria-owns"]=r["aria-owns"],h["aria-expanded"]=r["aria-expanded"]),h}),l=y(()=>[o.type==="textarea"?_.b():c.b(),c.m(x.value),c.is("disabled",v.value),c.is("exceed",O.value),{[c.b("group")]:s.prepend||s.append,[c.m("prefix")]:s.prefix||o.prefixIcon,[c.m("suffix")]:s.suffix||o.suffixIcon||o.clearable||o.showPassword,[c.bm("suffix","password-clear")]:Le.value&&qe.value,[c.b("hidden")]:o.type==="hidden"},r.class]),i=y(()=>[c.e("wrapper"),c.is("focus",oe.value)]),u=ei({excludeKeys:y(()=>Object.keys(a.value))}),{form:p,formItem:f}=Uo(),{inputId:g}=Ti(o,{formItemContext:f}),x=jo(),v=hn(),c=_e("input"),_=_e("textarea"),T=wt(),L=wt(),W=B(false),j=B(false),G=B(false),ie=B(),A=wt(o.inputStyle),q=y(()=>T.value||L.value),{wrapperRef:le,isFocused:oe,handleFocus:X,handleBlur:U}=hi(q,{afterBlur(){var h;o.validateEvent&&((h=f==null?void 0:f.validate)==null||h.call(f,"blur").catch(R=>void 0))}}),C=y(()=>{var h;return(h=p==null?void 0:p.statusIcon)!=null?h:false}),b=y(()=>(f==null?void 0:f.validateState)||""),$=y(()=>b.value&&qa[b.value]),E=y(()=>G.value?Ua:za),N=y(()=>[r.style]),V=y(()=>[o.inputStyle,A.value,{resize:o.resize}]),se=y(()=>bo(o.modelValue)?"":String(o.modelValue)),Le=y(()=>o.clearable&&!v.value&&!o.readonly&&!!se.value&&(oe.value||W.value)),qe=y(()=>o.showPassword&&!v.value&&!o.readonly&&!!se.value&&(!!se.value||oe.value)),Te=y(()=>o.showWordLimit&&!!o.maxlength&&(o.type==="text"||o.type==="textarea")&&!v.value&&!o.readonly&&!o.showPassword),Ye=y(()=>se.value.length),O=y(()=>!!Te.value&&Ye.value>Number(o.maxlength)),we=y(()=>!!s.suffix||!!o.suffixIcon||Le.value||o.showPassword||Te.value||!!b.value&&C.value),[ct,dt]=pi(T);lo(L,h=>{if(Zo(),!Te.value||o.resize!=="both")return;const R=h[0],{width:Z}=R.contentRect;ie.value={right:`calc(100% - ${Z+15+6}px)`}});const z=()=>{const{type:h,autosize:R}=o;if(!(!he||h!=="textarea"||!L.value))if(R){const Z=nt(R)?R.minRows:void 0,pt=nt(R)?R.maxRows:void 0,xn=Vn(L.value,Z,pt);A.value={overflowY:"hidden",...xn},ce(()=>{L.value.offsetHeight,A.value=xn})}else A.value={minHeight:Vn(L.value).minHeight}},Zo=(h=>{let R=false;return()=>{var Z;if(R||!o.autosize)return;((Z=L.value)==null?void 0:Z.offsetParent)===null||(h(),R=true)}})(z),We=()=>{const h=q.value,R=o.formatter?o.formatter(se.value):se.value;!h||h.value===R||(h.value=R)},Ht=async h=>{ct();let{value:R}=h.target;if(o.formatter&&(R=o.parser?o.parser(R):R),!j.value){if(R===se.value){We();return}n(Xt,R),n("input",R),await ce(),We(),dt()}},bn=h=>{n("change",h.target.value)},yn=h=>{n("compositionstart",h),j.value=true},_n=h=>{var R;n("compositionupdate",h);const Z=(R=h.target)==null?void 0:R.value,pt=Z[Z.length-1]||"";j.value=!Za(pt)},wn=h=>{n("compositionend",h),j.value&&(j.value=false,Ht(h))},Jo=()=>{G.value=!G.value,Sn()},Sn=async()=>{var h;await ce(),(h=q.value)==null||h.focus()},Qo=()=>{var h;return(h=q.value)==null?void 0:h.blur()},er=h=>{W.value=false,n("mouseleave",h)},tr=h=>{W.value=true,n("mouseenter",h)},Cn=h=>{n("keydown",h)},nr=()=>{var h;(h=q.value)==null||h.select()},En=()=>{n(Xt,""),n("change",""),n("clear"),n("input","")};return ne(()=>o.modelValue,()=>{var h;ce(()=>z()),o.validateEvent&&((h=f==null?void 0:f.validate)==null||h.call(f,"change").catch(R=>void 0))}),ne(se,()=>We()),ne(()=>o.type,async()=>{await ce(),We(),z()}),Ee(()=>{!o.formatter&&o.parser,We(),ce(z)}),At({from:"label",replacement:"aria-label",version:"2.8.0",scope:"el-input",ref:"https://element-plus.org/en-US/component/input.html"},y(()=>!!o.label)),t({input:T,textarea:L,ref:q,textareaStyle:V,autosize:Et(o,"autosize"),focus:Sn,blur:Qo,select:nr,clear:En,resizeTextarea:z}),(h,R)=>(m(),I("div",Ze(d(a),{class:[d(l),{[d(c).bm("group","append")]:h.$slots.append,[d(c).bm("group","prepend")]:h.$slots.prepend}],style:d(N),role:h.containerRole,onMouseenter:tr,onMouseleave:er}),[P(" input "),h.type!=="textarea"?(m(),I(Ae,{key:0},[P(" prepend slot "),h.$slots.prepend?(m(),I("div",{key:0,class:M(d(c).be("group","prepend"))},[te(h.$slots,"prepend")],2)):P("v-if",true),S("div",{ref_key:"wrapperRef",ref:le,class:M(d(i))},[P(" prefix slot "),h.$slots.prefix||h.prefixIcon?(m(),I("span",{key:0,class:M(d(c).e("prefix"))},[S("span",{class:M(d(c).e("prefix-inner"))},[te(h.$slots,"prefix"),h.prefixIcon?(m(),F(d(be),{key:0,class:M(d(c).e("icon"))},{default:w(()=>[(m(),F(de(h.prefixIcon)))]),_:1},8,["class"])):P("v-if",true)],2)],2)):P("v-if",true),S("input",Ze({id:d(g),ref_key:"input",ref:T,class:d(c).e("inner")},d(u),{minlength:h.minlength,maxlength:h.maxlength,type:h.showPassword?G.value?"text":"password":h.type,disabled:d(v),readonly:h.readonly,autocomplete:h.autocomplete,tabindex:h.tabindex,"aria-label":h.label||h.ariaLabel,placeholder:h.placeholder,style:h.inputStyle,form:h.form,autofocus:h.autofocus,onCompositionstart:yn,onCompositionupdate:_n,onCompositionend:wn,onInput:Ht,onFocus:R[0]||(R[0]=(...Z)=>d(X)&&d(X)(...Z)),onBlur:R[1]||(R[1]=(...Z)=>d(U)&&d(U)(...Z)),onChange:bn,onKeydown:Cn}),null,16,Bi),P(" suffix slot "),d(we)?(m(),I("span",{key:1,class:M(d(c).e("suffix"))},[S("span",{class:M(d(c).e("suffix-inner"))},[!d(Le)||!d(qe)||!d(Te)?(m(),I(Ae,{key:0},[te(h.$slots,"suffix"),h.suffixIcon?(m(),F(d(be),{key:0,class:M(d(c).e("icon"))},{default:w(()=>[(m(),F(de(h.suffixIcon)))]),_:1},8,["class"])):P("v-if",true)],64)):P("v-if",true),d(Le)?(m(),F(d(be),{key:1,class:M([d(c).e("icon"),d(c).e("clear")]),onMousedown:je(d(et),["prevent"]),onClick:En},{default:w(()=>[k(d(So))]),_:1},8,["class","onMousedown"])):P("v-if",true),d(qe)?(m(),F(d(be),{key:2,class:M([d(c).e("icon"),d(c).e("password")]),onClick:Jo},{default:w(()=>[(m(),F(de(d(E))))]),_:1},8,["class"])):P("v-if",true),d(Te)?(m(),I("span",{key:3,class:M(d(c).e("count"))},[S("span",{class:M(d(c).e("count-inner"))},D(d(Ye))+" / "+D(h.maxlength),3)],2)):P("v-if",true),d(b)&&d($)&&d(C)?(m(),F(d(be),{key:4,class:M([d(c).e("icon"),d(c).e("validateIcon"),d(c).is("loading",d(b)==="validating")])},{default:w(()=>[(m(),F(de(d($))))]),_:1},8,["class"])):P("v-if",true)],2)],2)):P("v-if",true)],2),P(" append slot "),h.$slots.append?(m(),I("div",{key:1,class:M(d(c).be("group","append"))},[te(h.$slots,"append")],2)):P("v-if",true)],64)):(m(),I(Ae,{key:1},[P(" textarea "),S("textarea",Ze({id:d(g),ref_key:"textarea",ref:L,class:[d(_).e("inner"),d(c).is("focus",d(oe))]},d(u),{minlength:h.minlength,maxlength:h.maxlength,tabindex:h.tabindex,disabled:d(v),readonly:h.readonly,autocomplete:h.autocomplete,style:d(V),"aria-label":h.label||h.ariaLabel,placeholder:h.placeholder,form:h.form,autofocus:h.autofocus,onCompositionstart:yn,onCompositionupdate:_n,onCompositionend:wn,onInput:Ht,onFocus:R[2]||(R[2]=(...Z)=>d(X)&&d(X)(...Z)),onBlur:R[3]||(R[3]=(...Z)=>d(U)&&d(U)(...Z)),onChange:bn,onKeydown:Cn}),null,16,Li),d(Te)?(m(),I("span",{key:0,style:tt(ie.value),class:M(d(c).e("count"))},D(d(Ye))+" / "+D(h.maxlength),7)):P("v-if",true)],64))],16,Oi))}});var Fi=Be(Pi,[["__file","input.vue"]]);const Ri=Ft(Fi),Dt="focus-trap.focus-after-trapped",jt="focus-trap.focus-after-released",zi="focus-trap.focusout-prevented",Dn={cancelable:true,bubbles:false},Hi={cancelable:true,bubbles:false},jn="focusAfterTrapped",Un="focusAfterReleased",Vi=Symbol("elFocusTrap"),mn=B(),zt=B(0),gn=B(0);let mt=0;const Ko=e=>{const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:o=>{const r=o.tagName==="INPUT"&&o.type==="hidden";return o.disabled||o.hidden||r?NodeFilter.FILTER_SKIP:o.tabIndex>=0||o===document.activeElement?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t},Kn=(e,t)=>{for(const n of e)if(!Di(n,t))return n},Di=(e,t)=>{if(getComputedStyle(e).visibility==="hidden")return true;for(;e;){if(t&&e===t)return false;if(getComputedStyle(e).display==="none")return true;e=e.parentElement}return false},ji=e=>{const t=Ko(e),n=Kn(t,e),o=Kn(t.reverse(),e);return[n,o]},Ui=e=>e instanceof HTMLInputElement&&"select"in e,Ie=(e,t)=>{if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:true}),gn.value=window.performance.now(),e!==n&&Ui(e)&&t&&e.select()}};function Gn(e,t){const n=[...e],o=e.indexOf(t);return o!==-1&&n.splice(o,1),n}const Ki=()=>{let e=[];return{push:o=>{const r=e[0];r&&o!==r&&r.pause(),e=Gn(e,o),e.unshift(o)},remove:o=>{var r,s;e=Gn(e,o),(s=(r=e[0])==null?void 0:r.resume)==null||s.call(r)}}},Gi=(e,t=false)=>{const n=document.activeElement;for(const o of e)if(Ie(o,t),document.activeElement!==n)return},qn=Ki(),qi=()=>zt.value>gn.value,gt=()=>{mn.value="pointer",zt.value=window.performance.now()},Yn=()=>{mn.value="keyboard",zt.value=window.performance.now()},Yi=()=>(Ee(()=>{mt===0&&(document.addEventListener("mousedown",gt),document.addEventListener("touchstart",gt),document.addEventListener("keydown",Yn)),mt++}),it(()=>{mt--,mt<=0&&(document.removeEventListener("mousedown",gt),document.removeEventListener("touchstart",gt),document.removeEventListener("keydown",Yn))}),{focusReason:mn,lastUserFocusTimestamp:zt,lastAutomatedFocusTimestamp:gn}),bt=e=>new CustomEvent(zi,{...Hi,detail:e}),Wi=H({name:"ElFocusTrap",inheritAttrs:false,props:{loop:Boolean,trapped:Boolean,focusTrapEl:Object,focusStartEl:{type:[Object,String],default:"first"}},emits:[jn,Un,"focusin","focusout","focusout-prevented","release-requested"],setup(e,{emit:t}){const n=B();let o,r;const{focusReason:s}=Yi();di(v=>{e.trapped&&!a.paused&&t("release-requested",v)});const a={paused:false,pause(){this.paused=true},resume(){this.paused=false}},l=v=>{if(!e.loop&&!e.trapped||a.paused)return;const{key:c,altKey:_,ctrlKey:T,metaKey:L,currentTarget:W,shiftKey:j}=v,{loop:G}=e,ie=c===Rt.tab&&!_&&!T&&!L,A=document.activeElement;if(ie&&A){const q=W,[le,oe]=ji(q);if(le&&oe){if(!j&&A===oe){const U=bt({focusReason:s.value});t("focusout-prevented",U),U.defaultPrevented||(v.preventDefault(),G&&Ie(le,true))}else if(j&&[le,q].includes(A)){const U=bt({focusReason:s.value});t("focusout-prevented",U),U.defaultPrevented||(v.preventDefault(),G&&Ie(oe,true))}}else if(A===q){const U=bt({focusReason:s.value});t("focusout-prevented",U),U.defaultPrevented||v.preventDefault()}}};nn(Vi,{focusTrapRef:n,onKeydown:l}),ne(()=>e.focusTrapEl,v=>{v&&(n.value=v)},{immediate:true}),ne([n],([v],[c])=>{v&&(v.addEventListener("keydown",l),v.addEventListener("focusin",p),v.addEventListener("focusout",f)),c&&(c.removeEventListener("keydown",l),c.removeEventListener("focusin",p),c.removeEventListener("focusout",f))});const i=v=>{t(jn,v)},u=v=>t(Un,v),p=v=>{const c=d(n);if(!c)return;const _=v.target,T=v.relatedTarget,L=_&&c.contains(_);e.trapped||T&&c.contains(T)||(o=T),L&&t("focusin",v),!a.paused&&e.trapped&&(L?r=_:Ie(r,true))},f=v=>{const c=d(n);if(!(a.paused||!c))if(e.trapped){const _=v.relatedTarget;!bo(_)&&!c.contains(_)&&setTimeout(()=>{if(!a.paused&&e.trapped){const T=bt({focusReason:s.value});t("focusout-prevented",T),T.defaultPrevented||Ie(r,true)}},0)}else{const _=v.target;_&&c.contains(_)||t("focusout",v)}};async function g(){await ce();const v=d(n);if(v){qn.push(a);const c=v.contains(document.activeElement)?o:document.activeElement;if(o=c,!v.contains(c)){const T=new Event(Dt,Dn);v.addEventListener(Dt,i),v.dispatchEvent(T),T.defaultPrevented||ce(()=>{let L=e.focusStartEl;ye(L)||(Ie(L),document.activeElement!==L&&(L="first")),L==="first"&&Gi(Ko(v),true),(document.activeElement===c||L==="container")&&Ie(v)})}}}function x(){const v=d(n);if(v){v.removeEventListener(Dt,i);const c=new CustomEvent(jt,{...Dn,detail:{focusReason:s.value}});v.addEventListener(jt,u),v.dispatchEvent(c),!c.defaultPrevented&&(s.value=="keyboard"||!qi()||v.contains(document.activeElement))&&Ie(o??document.body),v.removeEventListener(jt,u),qn.remove(a)}}return Ee(()=>{e.trapped&&g(),ne(()=>e.trapped,v=>{v?g():x()})}),it(()=>{e.trapped&&x()}),{onKeydown:l}}});function Xi(e,t,n,o,r,s){return te(e.$slots,"default",{handleKeydown:e.onKeydown})}var Zi=Be(Wi,[["render",Xi],["__file","focus-trap.vue"]]);const Ji=xe({value:{type:[String,Number],default:""},max:{type:Number,default:99},isDot:Boolean,hidden:Boolean,type:{type:String,values:["primary","success","warning","info","danger"],default:"danger"},showZero:{type:Boolean,default:true},color:String,dotStyle:{type:J([String,Object,Array])},badgeStyle:{type:J([String,Object,Array])},offset:{type:J(Array),default:[0,0]},dotClass:{type:String},badgeClass:{type:String}}),Qi=["textContent"],el=H({name:"ElBadge"}),tl=H({...el,props:Ji,setup(e,{expose:t}){const n=e,o=_e("badge"),r=y(()=>n.isDot?"":He(n.value)&&He(n.max)?n.max<n.value?`${n.max}+`:n.value===0&&!n.showZero?"":`${n.value}`:`${n.value}`),s=y(()=>{var a,l,i,u,p,f;return[{backgroundColor:n.color,marginRight:rt(-((l=(a=n.offset)==null?void 0:a[0])!=null?l:0)),marginTop:rt((u=(i=n.offset)==null?void 0:i[1])!=null?u:0)},(p=n.dotStyle)!=null?p:{},(f=n.badgeStyle)!=null?f:{}]});return At({from:"dot-style",replacement:"badge-style",version:"2.8.0",scope:"el-badge",ref:"https://element-plus.org/en-US/component/badge.html"},y(()=>!!n.dotStyle)),At({from:"dot-class",replacement:"badge-class",version:"2.8.0",scope:"el-badge",ref:"https://element-plus.org/en-US/component/badge.html"},y(()=>!!n.dotClass)),t({content:r}),(a,l)=>(m(),I("div",{class:M(d(o).b())},[te(a.$slots,"default"),k(on,{name:`${d(o).namespace.value}-zoom-in-center`,persisted:""},{default:w(()=>[Je(S("sup",{class:M([d(o).e("content"),d(o).em("content",a.type),d(o).is("fixed",!!a.$slots.default),d(o).is("dot",a.isDot),a.dotClass,a.badgeClass]),style:tt(d(s)),textContent:D(d(r))},null,14,Qi),[[Qe,!a.hidden&&(d(r)||a.isDot)]])]),_:1},8,["name"])],2))}});var nl=Be(tl,[["__file","badge.vue"]]);const ol=Ft(nl),Go=Symbol("buttonGroupContextKey"),rl=(e,t)=>{At({from:"type.text",replacement:"link",version:"3.0.0",scope:"props",ref:"https://element-plus.org/en-US/component/button.html#button-attributes"},y(()=>e.type==="text"));const n=ae(Go,void 0),o=pn("button"),{form:r}=Uo(),s=jo(y(()=>n==null?void 0:n.size)),a=hn(),l=B(),i=so(),u=y(()=>e.type||(n==null?void 0:n.type)||""),p=y(()=>{var v,c,_;return(_=(c=e.autoInsertSpace)!=null?c:(v=o.value)==null?void 0:v.autoInsertSpace)!=null?_:false}),f=y(()=>e.tag==="button"?{ariaDisabled:a.value||e.loading,disabled:a.value||e.loading,autofocus:e.autofocus,type:e.nativeType}:{}),g=y(()=>{var v;const c=(v=i.default)==null?void 0:v.call(i);if(p.value&&(c==null?void 0:c.length)===1){const _=c[0];if((_==null?void 0:_.type)===pr){const T=_.children;return new RegExp("^\\p{Unified_Ideograph}{2}$","u").test(T.trim())}}return false});return{_disabled:a,_size:s,_type:u,_ref:l,_props:f,shouldAddSpace:g,handleClick:v=>{e.nativeType==="reset"&&(r==null||r.resetFields()),t("click",v)}}},sl=["default","primary","success","warning","info","danger","text",""],al=["button","submit","reset"],Qt=xe({size:fn,disabled:Boolean,type:{type:String,values:sl,default:""},icon:{type:st},nativeType:{type:String,values:al,default:"button"},loading:Boolean,loadingIcon:{type:st,default:()=>Mt},plain:Boolean,text:Boolean,link:Boolean,bg:Boolean,autofocus:Boolean,round:Boolean,circle:Boolean,color:String,dark:Boolean,autoInsertSpace:{type:Boolean,default:void 0},tag:{type:J([String,Object]),default:"button"}}),il={click:e=>e instanceof MouseEvent};function Q(e,t){ll(e)&&(e="100%");var n=ul(e);return e=t===360?e:Math.min(t,Math.max(0,parseFloat(e))),n&&(e=parseInt(String(e*t),10)/100),Math.abs(e-t)<1e-6?1:(t===360?e=(e<0?e%t+t:e%t)/parseFloat(String(t)):e=e%t/parseFloat(String(t)),e)}function yt(e){return Math.min(1,Math.max(0,e))}function ll(e){return typeof e=="string"&&e.indexOf(".")!==-1&&parseFloat(e)===1}function ul(e){return typeof e=="string"&&e.indexOf("%")!==-1}function qo(e){return e=parseFloat(e),(isNaN(e)||e<0||e>1)&&(e=1),e}function _t(e){return e<=1?"".concat(Number(e)*100,"%"):e}function Pe(e){return e.length===1?"0"+e:String(e)}function cl(e,t,n){return{r:Q(e,255)*255,g:Q(t,255)*255,b:Q(n,255)*255}}function Wn(e,t,n){e=Q(e,255),t=Q(t,255),n=Q(n,255);var o=Math.max(e,t,n),r=Math.min(e,t,n),s=0,a=0,l=(o+r)/2;if(o===r)a=0,s=0;else{var i=o-r;switch(a=l>.5?i/(2-o-r):i/(o+r),o){case e:s=(t-n)/i+(t<n?6:0);break;case t:s=(n-e)/i+2;break;case n:s=(e-t)/i+4;break}s/=6}return{h:s,s:a,l}}function Ut(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*(6*n):n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function dl(e,t,n){var o,r,s;if(e=Q(e,360),t=Q(t,100),n=Q(n,100),t===0)r=n,s=n,o=n;else{var a=n<.5?n*(1+t):n+t-n*t,l=2*n-a;o=Ut(l,a,e+1/3),r=Ut(l,a,e),s=Ut(l,a,e-1/3)}return{r:o*255,g:r*255,b:s*255}}function Xn(e,t,n){e=Q(e,255),t=Q(t,255),n=Q(n,255);var o=Math.max(e,t,n),r=Math.min(e,t,n),s=0,a=o,l=o-r,i=o===0?0:l/o;if(o===r)s=0;else{switch(o){case e:s=(t-n)/l+(t<n?6:0);break;case t:s=(n-e)/l+2;break;case n:s=(e-t)/l+4;break}s/=6}return{h:s,s:i,v:a}}function fl(e,t,n){e=Q(e,360)*6,t=Q(t,100),n=Q(n,100);var o=Math.floor(e),r=e-o,s=n*(1-t),a=n*(1-r*t),l=n*(1-(1-r)*t),i=o%6,u=[n,a,s,s,l,n][i],p=[l,n,n,a,s,s][i],f=[s,s,l,n,n,a][i];return{r:u*255,g:p*255,b:f*255}}function Zn(e,t,n,o){var r=[Pe(Math.round(e).toString(16)),Pe(Math.round(t).toString(16)),Pe(Math.round(n).toString(16))];return o&&r[0].startsWith(r[0].charAt(1))&&r[1].startsWith(r[1].charAt(1))&&r[2].startsWith(r[2].charAt(1))?r[0].charAt(0)+r[1].charAt(0)+r[2].charAt(0):r.join("")}function pl(e,t,n,o,r){var s=[Pe(Math.round(e).toString(16)),Pe(Math.round(t).toString(16)),Pe(Math.round(n).toString(16)),Pe(vl(o))];return r&&s[0].startsWith(s[0].charAt(1))&&s[1].startsWith(s[1].charAt(1))&&s[2].startsWith(s[2].charAt(1))&&s[3].startsWith(s[3].charAt(1))?s[0].charAt(0)+s[1].charAt(0)+s[2].charAt(0)+s[3].charAt(0):s.join("")}function vl(e){return Math.round(parseFloat(e)*255).toString(16)}function Jn(e){return ue(e)/255}function ue(e){return parseInt(e,16)}function hl(e){return{r:e>>16,g:(e&65280)>>8,b:e&255}}var en={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",goldenrod:"#daa520",gold:"#ffd700",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavenderblush:"#fff0f5",lavender:"#e6e6fa",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};function ml(e){var t={r:0,g:0,b:0},n=1,o=null,r=null,s=null,a=false,l=false;return typeof e=="string"&&(e=yl(e)),typeof e=="object"&&(Se(e.r)&&Se(e.g)&&Se(e.b)?(t=cl(e.r,e.g,e.b),a=true,l=String(e.r).substr(-1)==="%"?"prgb":"rgb"):Se(e.h)&&Se(e.s)&&Se(e.v)?(o=_t(e.s),r=_t(e.v),t=fl(e.h,o,r),a=true,l="hsv"):Se(e.h)&&Se(e.s)&&Se(e.l)&&(o=_t(e.s),s=_t(e.l),t=dl(e.h,o,s),a=true,l="hsl"),Object.prototype.hasOwnProperty.call(e,"a")&&(n=e.a)),n=qo(n),{ok:a,format:e.format||l,r:Math.min(255,Math.max(t.r,0)),g:Math.min(255,Math.max(t.g,0)),b:Math.min(255,Math.max(t.b,0)),a:n}}var gl="[-\\+]?\\d+%?",bl="[-\\+]?\\d*\\.\\d+%?",$e="(?:".concat(bl,")|(?:").concat(gl,")"),Kt="[\\s|\\(]+(".concat($e,")[,|\\s]+(").concat($e,")[,|\\s]+(").concat($e,")\\s*\\)?"),Gt="[\\s|\\(]+(".concat($e,")[,|\\s]+(").concat($e,")[,|\\s]+(").concat($e,")[,|\\s]+(").concat($e,")\\s*\\)?"),pe={CSS_UNIT:new RegExp($e),rgb:new RegExp("rgb"+Kt),rgba:new RegExp("rgba"+Gt),hsl:new RegExp("hsl"+Kt),hsla:new RegExp("hsla"+Gt),hsv:new RegExp("hsv"+Kt),hsva:new RegExp("hsva"+Gt),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/};function yl(e){if(e=e.trim().toLowerCase(),e.length===0)return false;var t=false;if(en[e])e=en[e],t=true;else if(e==="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var n=pe.rgb.exec(e);return n?{r:n[1],g:n[2],b:n[3]}:(n=pe.rgba.exec(e),n?{r:n[1],g:n[2],b:n[3],a:n[4]}:(n=pe.hsl.exec(e),n?{h:n[1],s:n[2],l:n[3]}:(n=pe.hsla.exec(e),n?{h:n[1],s:n[2],l:n[3],a:n[4]}:(n=pe.hsv.exec(e),n?{h:n[1],s:n[2],v:n[3]}:(n=pe.hsva.exec(e),n?{h:n[1],s:n[2],v:n[3],a:n[4]}:(n=pe.hex8.exec(e),n?{r:ue(n[1]),g:ue(n[2]),b:ue(n[3]),a:Jn(n[4]),format:t?"name":"hex8"}:(n=pe.hex6.exec(e),n?{r:ue(n[1]),g:ue(n[2]),b:ue(n[3]),format:t?"name":"hex"}:(n=pe.hex4.exec(e),n?{r:ue(n[1]+n[1]),g:ue(n[2]+n[2]),b:ue(n[3]+n[3]),a:Jn(n[4]+n[4]),format:t?"name":"hex8"}:(n=pe.hex3.exec(e),n?{r:ue(n[1]+n[1]),g:ue(n[2]+n[2]),b:ue(n[3]+n[3]),format:t?"name":"hex"}:false)))))))))}function Se(e){return!!pe.CSS_UNIT.exec(String(e))}var _l=function(){function e(t,n){t===void 0&&(t=""),n===void 0&&(n={});var o;if(t instanceof e)return t;typeof t=="number"&&(t=hl(t)),this.originalInput=t;var r=ml(t);this.originalInput=t,this.r=r.r,this.g=r.g,this.b=r.b,this.a=r.a,this.roundA=Math.round(100*this.a)/100,this.format=(o=n.format)!==null&&o!==void 0?o:r.format,this.gradientType=n.gradientType,this.r<1&&(this.r=Math.round(this.r)),this.g<1&&(this.g=Math.round(this.g)),this.b<1&&(this.b=Math.round(this.b)),this.isValid=r.ok}return e.prototype.isDark=function(){return this.getBrightness()<128},e.prototype.isLight=function(){return!this.isDark()},e.prototype.getBrightness=function(){var t=this.toRgb();return(t.r*299+t.g*587+t.b*114)/1e3},e.prototype.getLuminance=function(){var t=this.toRgb(),n,o,r,s=t.r/255,a=t.g/255,l=t.b/255;return s<=.03928?n=s/12.92:n=Math.pow((s+.055)/1.055,2.4),a<=.03928?o=a/12.92:o=Math.pow((a+.055)/1.055,2.4),l<=.03928?r=l/12.92:r=Math.pow((l+.055)/1.055,2.4),.2126*n+.7152*o+.0722*r},e.prototype.getAlpha=function(){return this.a},e.prototype.setAlpha=function(t){return this.a=qo(t),this.roundA=Math.round(100*this.a)/100,this},e.prototype.isMonochrome=function(){var t=this.toHsl().s;return t===0},e.prototype.toHsv=function(){var t=Xn(this.r,this.g,this.b);return{h:t.h*360,s:t.s,v:t.v,a:this.a}},e.prototype.toHsvString=function(){var t=Xn(this.r,this.g,this.b),n=Math.round(t.h*360),o=Math.round(t.s*100),r=Math.round(t.v*100);return this.a===1?"hsv(".concat(n,", ").concat(o,"%, ").concat(r,"%)"):"hsva(".concat(n,", ").concat(o,"%, ").concat(r,"%, ").concat(this.roundA,")")},e.prototype.toHsl=function(){var t=Wn(this.r,this.g,this.b);return{h:t.h*360,s:t.s,l:t.l,a:this.a}},e.prototype.toHslString=function(){var t=Wn(this.r,this.g,this.b),n=Math.round(t.h*360),o=Math.round(t.s*100),r=Math.round(t.l*100);return this.a===1?"hsl(".concat(n,", ").concat(o,"%, ").concat(r,"%)"):"hsla(".concat(n,", ").concat(o,"%, ").concat(r,"%, ").concat(this.roundA,")")},e.prototype.toHex=function(t){return t===void 0&&(t=false),Zn(this.r,this.g,this.b,t)},e.prototype.toHexString=function(t){return t===void 0&&(t=false),"#"+this.toHex(t)},e.prototype.toHex8=function(t){return t===void 0&&(t=false),pl(this.r,this.g,this.b,this.a,t)},e.prototype.toHex8String=function(t){return t===void 0&&(t=false),"#"+this.toHex8(t)},e.prototype.toHexShortString=function(t){return t===void 0&&(t=false),this.a===1?this.toHexString(t):this.toHex8String(t)},e.prototype.toRgb=function(){return{r:Math.round(this.r),g:Math.round(this.g),b:Math.round(this.b),a:this.a}},e.prototype.toRgbString=function(){var t=Math.round(this.r),n=Math.round(this.g),o=Math.round(this.b);return this.a===1?"rgb(".concat(t,", ").concat(n,", ").concat(o,")"):"rgba(".concat(t,", ").concat(n,", ").concat(o,", ").concat(this.roundA,")")},e.prototype.toPercentageRgb=function(){var t=function(n){return"".concat(Math.round(Q(n,255)*100),"%")};return{r:t(this.r),g:t(this.g),b:t(this.b),a:this.a}},e.prototype.toPercentageRgbString=function(){var t=function(n){return Math.round(Q(n,255)*100)};return this.a===1?"rgb(".concat(t(this.r),"%, ").concat(t(this.g),"%, ").concat(t(this.b),"%)"):"rgba(".concat(t(this.r),"%, ").concat(t(this.g),"%, ").concat(t(this.b),"%, ").concat(this.roundA,")")},e.prototype.toName=function(){if(this.a===0)return"transparent";if(this.a<1)return false;for(var t="#"+Zn(this.r,this.g,this.b,false),n=0,o=Object.entries(en);n<o.length;n++){var r=o[n],s=r[0],a=r[1];if(t===a)return s}return false},e.prototype.toString=function(t){var n=!!t;t=t??this.format;var o=false,r=this.a<1&&this.a>=0,s=!n&&r&&(t.startsWith("hex")||t==="name");return s?t==="name"&&this.a===0?this.toName():this.toRgbString():(t==="rgb"&&(o=this.toRgbString()),t==="prgb"&&(o=this.toPercentageRgbString()),(t==="hex"||t==="hex6")&&(o=this.toHexString()),t==="hex3"&&(o=this.toHexString(true)),t==="hex4"&&(o=this.toHex8String(true)),t==="hex8"&&(o=this.toHex8String()),t==="name"&&(o=this.toName()),t==="hsl"&&(o=this.toHslString()),t==="hsv"&&(o=this.toHsvString()),o||this.toHexString())},e.prototype.toNumber=function(){return(Math.round(this.r)<<16)+(Math.round(this.g)<<8)+Math.round(this.b)},e.prototype.clone=function(){return new e(this.toString())},e.prototype.lighten=function(t){t===void 0&&(t=10);var n=this.toHsl();return n.l+=t/100,n.l=yt(n.l),new e(n)},e.prototype.brighten=function(t){t===void 0&&(t=10);var n=this.toRgb();return n.r=Math.max(0,Math.min(255,n.r-Math.round(255*-(t/100)))),n.g=Math.max(0,Math.min(255,n.g-Math.round(255*-(t/100)))),n.b=Math.max(0,Math.min(255,n.b-Math.round(255*-(t/100)))),new e(n)},e.prototype.darken=function(t){t===void 0&&(t=10);var n=this.toHsl();return n.l-=t/100,n.l=yt(n.l),new e(n)},e.prototype.tint=function(t){return t===void 0&&(t=10),this.mix("white",t)},e.prototype.shade=function(t){return t===void 0&&(t=10),this.mix("black",t)},e.prototype.desaturate=function(t){t===void 0&&(t=10);var n=this.toHsl();return n.s-=t/100,n.s=yt(n.s),new e(n)},e.prototype.saturate=function(t){t===void 0&&(t=10);var n=this.toHsl();return n.s+=t/100,n.s=yt(n.s),new e(n)},e.prototype.greyscale=function(){return this.desaturate(100)},e.prototype.spin=function(t){var n=this.toHsl(),o=(n.h+t)%360;return n.h=o<0?360+o:o,new e(n)},e.prototype.mix=function(t,n){n===void 0&&(n=50);var o=this.toRgb(),r=new e(t).toRgb(),s=n/100,a={r:(r.r-o.r)*s+o.r,g:(r.g-o.g)*s+o.g,b:(r.b-o.b)*s+o.b,a:(r.a-o.a)*s+o.a};return new e(a)},e.prototype.analogous=function(t,n){t===void 0&&(t=6),n===void 0&&(n=30);var o=this.toHsl(),r=360/n,s=[this];for(o.h=(o.h-(r*t>>1)+720)%360;--t;)o.h=(o.h+r)%360,s.push(new e(o));return s},e.prototype.complement=function(){var t=this.toHsl();return t.h=(t.h+180)%360,new e(t)},e.prototype.monochromatic=function(t){t===void 0&&(t=6);for(var n=this.toHsv(),o=n.h,r=n.s,s=n.v,a=[],l=1/t;t--;)a.push(new e({h:o,s:r,v:s})),s=(s+l)%1;return a},e.prototype.splitcomplement=function(){var t=this.toHsl(),n=t.h;return[this,new e({h:(n+72)%360,s:t.s,l:t.l}),new e({h:(n+216)%360,s:t.s,l:t.l})]},e.prototype.onBackground=function(t){var n=this.toRgb(),o=new e(t).toRgb(),r=n.a+o.a*(1-n.a);return new e({r:(n.r*n.a+o.r*o.a*(1-n.a))/r,g:(n.g*n.a+o.g*o.a*(1-n.a))/r,b:(n.b*n.a+o.b*o.a*(1-n.a))/r,a:r})},e.prototype.triad=function(){return this.polyad(3)},e.prototype.tetrad=function(){return this.polyad(4)},e.prototype.polyad=function(t){for(var n=this.toHsl(),o=n.h,r=[this],s=360/t,a=1;a<t;a++)r.push(new e({h:(o+a*s)%360,s:n.s,l:n.l}));return r},e.prototype.equals=function(t){return this.toRgbString()===new e(t).toRgbString()},e}();function ke(e,t=20){return e.mix("#141414",t).toString()}function wl(e){const t=hn(),n=_e("button");return y(()=>{let o={},r=e.color;if(r){const s=r.match(/var\((.*?)\)/);s&&(r=window.getComputedStyle(window.document.documentElement).getPropertyValue(s[1]));const a=new _l(r),l=e.dark?a.tint(20).toString():ke(a,20);if(e.plain)o=n.cssVarBlock({"bg-color":e.dark?ke(a,90):a.tint(90).toString(),"text-color":r,"border-color":e.dark?ke(a,50):a.tint(50).toString(),"hover-text-color":`var(${n.cssVarName("color-white")})`,"hover-bg-color":r,"hover-border-color":r,"active-bg-color":l,"active-text-color":`var(${n.cssVarName("color-white")})`,"active-border-color":l}),t.value&&(o[n.cssVarBlockName("disabled-bg-color")]=e.dark?ke(a,90):a.tint(90).toString(),o[n.cssVarBlockName("disabled-text-color")]=e.dark?ke(a,50):a.tint(50).toString(),o[n.cssVarBlockName("disabled-border-color")]=e.dark?ke(a,80):a.tint(80).toString());else{const i=e.dark?ke(a,30):a.tint(30).toString(),u=a.isDark()?`var(${n.cssVarName("color-white")})`:`var(${n.cssVarName("color-black")})`;if(o=n.cssVarBlock({"bg-color":r,"text-color":u,"border-color":r,"hover-bg-color":i,"hover-text-color":u,"hover-border-color":i,"active-bg-color":l,"active-border-color":l}),t.value){const p=e.dark?ke(a,50):a.tint(50).toString();o[n.cssVarBlockName("disabled-bg-color")]=p,o[n.cssVarBlockName("disabled-text-color")]=e.dark?"rgba(255, 255, 255, 0.5)":`var(${n.cssVarName("color-white")})`,o[n.cssVarBlockName("disabled-border-color")]=p}}}return o})}const Sl=H({name:"ElButton"}),Cl=H({...Sl,props:Qt,emits:il,setup(e,{expose:t,emit:n}){const o=e,r=wl(o),s=_e("button"),{_ref:a,_size:l,_type:i,_disabled:u,_props:p,shouldAddSpace:f,handleClick:g}=rl(o,n),x=y(()=>[s.b(),s.m(i.value),s.m(l.value),s.is("disabled",u.value),s.is("loading",o.loading),s.is("plain",o.plain),s.is("round",o.round),s.is("circle",o.circle),s.is("text",o.text),s.is("link",o.link),s.is("has-bg",o.bg)]);return t({ref:a,size:l,type:i,disabled:u,shouldAddSpace:f}),(v,c)=>(m(),F(de(v.tag),Ze({ref_key:"_ref",ref:a},d(p),{class:d(x),style:d(r),onClick:d(g)}),{default:w(()=>[v.loading?(m(),I(Ae,{key:0},[v.$slots.loading?te(v.$slots,"loading",{key:0}):(m(),F(d(be),{key:1,class:M(d(s).is("loading"))},{default:w(()=>[(m(),F(de(v.loadingIcon)))]),_:1},8,["class"]))],64)):v.icon||v.$slots.icon?(m(),F(d(be),{key:1},{default:w(()=>[v.icon?(m(),F(de(v.icon),{key:0})):te(v.$slots,"icon",{key:1})]),_:3})):P("v-if",true),v.$slots.default?(m(),I("span",{key:2,class:M({[d(s).em("text","expand")]:d(f)})},[te(v.$slots,"default")],2)):P("v-if",true)]),_:3},16,["class","style","onClick"]))}});var El=Be(Cl,[["__file","button.vue"]]);const xl={size:Qt.size,type:Qt.type},Tl=H({name:"ElButtonGroup"}),kl=H({...Tl,props:xl,setup(e){const t=e;nn(Go,ao({size:Et(t,"size"),type:Et(t,"type")}));const n=_e("button");return(o,r)=>(m(),I("div",{class:M(`${d(n).b("group")}`)},[te(o.$slots,"default")],2))}});var Yo=Be(kl,[["__file","button-group.vue"]]);const Il=Ft(El,{ButtonGroup:Yo});Wa(Yo);var Ml=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function $l(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}const tn="_trap-focus-children",Fe=[],Qn=e=>{if(Fe.length===0)return;const t=Fe[Fe.length-1][tn];if(t.length>0&&e.code===Rt.tab){if(t.length===1){e.preventDefault(),document.activeElement!==t[0]&&t[0].focus();return}const n=e.shiftKey,o=e.target===t[0],r=e.target===t[t.length-1];o&&n&&(e.preventDefault(),t[t.length-1].focus()),r&&!n&&(e.preventDefault(),t[0].focus())}},Al={beforeMount(e){e[tn]=Tn(e),Fe.push(e),Fe.length<=1&&document.addEventListener("keydown",Qn)},updated(e){ce(()=>{e[tn]=Tn(e)})},unmounted(){Fe.shift(),Fe.length===0&&document.removeEventListener("keydown",Qn)}},Ol=xe({mask:{type:Boolean,default:true},customMaskEvent:{type:Boolean,default:false},overlayClass:{type:J([String,Array,Object])},zIndex:{type:J([String,Number])}}),Bl={click:e=>e instanceof MouseEvent},Ll="overlay";var Nl=H({name:"ElOverlay",props:Ol,emits:Bl,setup(e,{slots:t,emit:n}){const o=_e(Ll),r=i=>{n("click",i)},{onClick:s,onMousedown:a,onMouseup:l}=No(e.customMaskEvent?void 0:r);return()=>e.mask?k("div",{class:[o.b(),e.overlayClass],style:{zIndex:e.zIndex},onClick:s,onMousedown:a,onMouseup:l},[te(t,"default")],St.STYLE|St.CLASS|St.PROPS,["onClick","onMouseup","onMousedown"]):vr("div",{class:e.overlayClass,style:{zIndex:e.zIndex,position:"fixed",top:"0px",right:"0px",bottom:"0px",left:"0px"}},[te(t,"default")])}});const Pl=Nl,Wo=["success","info","warning","error"],ee=$o({customClass:"",center:false,dangerouslyUseHTMLString:false,duration:3e3,icon:void 0,id:"",message:"",onClose:void 0,showClose:false,type:"info",plain:false,offset:16,zIndex:0,grouping:false,repeatNum:1,appendTo:he?document.body:void 0}),Fl=xe({customClass:{type:String,default:ee.customClass},center:{type:Boolean,default:ee.center},dangerouslyUseHTMLString:{type:Boolean,default:ee.dangerouslyUseHTMLString},duration:{type:Number,default:ee.duration},icon:{type:st,default:ee.icon},id:{type:String,default:ee.id},message:{type:J([String,Object,Function]),default:ee.message},onClose:{type:J(Function),default:ee.onClose},showClose:{type:Boolean,default:ee.showClose},type:{type:String,values:Wo,default:ee.type},plain:{type:Boolean,default:ee.plain},offset:{type:Number,default:ee.offset},zIndex:{type:Number,default:ee.zIndex},grouping:{type:Boolean,default:ee.grouping},repeatNum:{type:Number,default:ee.repeatNum}}),Rl={destroy:()=>true},ve=hr([]),zl=e=>{const t=ve.findIndex(r=>r.id===e),n=ve[t];let o;return t>0&&(o=ve[t-1]),{current:n,prev:o}},Hl=e=>{const{prev:t}=zl(e);return t?t.vm.exposed.bottom.value:0},Vl=(e,t)=>ve.findIndex(o=>o.id===e)>0?16:t,Dl=["id"],jl=["innerHTML"],Ul=H({name:"ElMessage"}),Kl=H({...Ul,props:Fl,emits:Rl,setup(e,{expose:t}){const n=e,{Close:o}=Io,{ns:r,zIndex:s}=Ho("message"),{currentZIndex:a,nextZIndex:l}=s,i=B(),u=B(false),p=B(0);let f;const g=y(()=>n.type?n.type==="error"?"danger":n.type:"info"),x=y(()=>{const A=n.type;return{[r.bm("icon",A)]:A&&$t[A]}}),v=y(()=>n.icon||$t[n.type]||""),c=y(()=>Hl(n.id)),_=y(()=>Vl(n.id,n.offset)+c.value),T=y(()=>p.value+_.value),L=y(()=>({top:`${_.value}px`,zIndex:a.value}));function W(){n.duration!==0&&({stop:f}=gr(()=>{G()},n.duration))}function j(){f==null||f()}function G(){u.value=false}function ie({code:A}){A===Rt.esc&&G()}return Ee(()=>{W(),l(),u.value=true}),ne(()=>n.repeatNum,()=>{j(),W()}),io(document,"keydown",ie),lo(i,()=>{p.value=i.value.getBoundingClientRect().height}),t({visible:u,bottom:T,close:G}),(A,q)=>(m(),F(on,{name:d(r).b("fade"),onBeforeLeave:A.onClose,onAfterLeave:q[0]||(q[0]=le=>A.$emit("destroy")),persisted:""},{default:w(()=>[Je(S("div",{id:A.id,ref_key:"messageRef",ref:i,class:M([d(r).b(),{[d(r).m(A.type)]:A.type},d(r).is("center",A.center),d(r).is("closable",A.showClose),d(r).is("plain",A.plain),A.customClass]),style:tt(d(L)),role:"alert",onMouseenter:j,onMouseleave:W},[A.repeatNum>1?(m(),F(d(ol),{key:0,value:A.repeatNum,type:d(g),class:M(d(r).e("badge"))},null,8,["value","type","class"])):P("v-if",true),d(v)?(m(),F(d(be),{key:1,class:M([d(r).e("icon"),d(x)])},{default:w(()=>[(m(),F(de(d(v))))]),_:1},8,["class"])):P("v-if",true),te(A.$slots,"default",{},()=>[A.dangerouslyUseHTMLString?(m(),I(Ae,{key:1},[P(" Caution here, message could've been compromised, never use user's input as message "),S("p",{class:M(d(r).e("content")),innerHTML:A.message},null,10,jl)],2112)):(m(),I("p",{key:0,class:M(d(r).e("content"))},D(A.message),3))]),A.showClose?(m(),F(d(be),{key:2,class:M(d(r).e("closeBtn")),onClick:je(G,["stop"])},{default:w(()=>[k(d(o))]),_:1},8,["class","onClick"])):P("v-if",true)],46,Dl),[[Qe,u.value]])]),_:3},8,["name","onBeforeLeave"]))}});var Gl=Be(Kl,[["__file","message.vue"]]);let ql=1;const Xo=e=>{const t=!e||ye(e)||Bt(e)||Re(e)?{message:e}:e,n={...ee,...t};if(!n.appendTo)n.appendTo=document.body;else if(ye(n.appendTo)){let o=document.querySelector(n.appendTo);Wt(o)||(o=document.body),n.appendTo=o}return n},Yl=e=>{const t=ve.indexOf(e);if(t===-1)return;ve.splice(t,1);const{handler:n}=e;n.close()},Wl=({appendTo:e,...t},n)=>{const o=`message_${ql++}`,r=t.onClose,s=document.createElement("div"),a={...t,id:o,onClose:()=>{r==null||r(),Yl(p)},onDestroy:()=>{xt(null,s)}},l=k(Gl,a,Re(a.message)||Bt(a.message)?{default:Re(a.message)?a.message:()=>a.message}:null);l.appContext=n||Ue._context,xt(l,s),e.appendChild(s.firstElementChild);const i=l.component,p={id:o,vnode:l,vm:i,handler:{close:()=>{i.exposed.visible.value=false}},props:l.component.props};return p},Ue=(e={},t)=>{if(!he)return{close:()=>{}};if(He(Jt.max)&&ve.length>=Jt.max)return{close:()=>{}};const n=Xo(e);if(n.grouping&&ve.length){const r=ve.find(({vnode:s})=>{var a;return((a=s.props)==null?void 0:a.message)===n.message});if(r)return r.props.repeatNum+=1,r.props.type=n.type,r.handler}const o=Wl(n,t);return ve.push(o),o.handler};Wo.forEach(e=>{Ue[e]=(t={},n)=>{const o=Xo(t);return Ue({...o,type:e},n)}});function Xl(e){for(const t of ve)(!e||e===t.props.type)&&t.handler.close()}Ue.closeAll=Xl;Ue._context=null;const ge=Ya(Ue,"$message"),Zl=H({name:"ElMessageBox",directives:{TrapFocus:Al},components:{ElButton:Il,ElFocusTrap:Zi,ElInput:Ri,ElOverlay:Pl,ElIcon:be,...Io},inheritAttrs:false,props:{buttonSize:{type:String,validator:Xa},modal:{type:Boolean,default:true},lockScroll:{type:Boolean,default:true},showClose:{type:Boolean,default:true},closeOnClickModal:{type:Boolean,default:true},closeOnPressEscape:{type:Boolean,default:true},closeOnHashChange:{type:Boolean,default:true},center:Boolean,draggable:Boolean,overflow:Boolean,roundButton:{default:false,type:Boolean},container:{type:String,default:"body"},boxType:{type:String,default:""}},emits:["vanish","action"],setup(e,{emit:t}){const{locale:n,zIndex:o,ns:r,size:s}=Ho("message-box",y(()=>e.buttonSize)),{t:a}=n,{nextZIndex:l}=o,i=B(false),u=ao({autofocus:true,beforeClose:null,callback:null,cancelButtonText:"",cancelButtonClass:"",confirmButtonText:"",confirmButtonClass:"",customClass:"",customStyle:{},dangerouslyUseHTMLString:false,distinguishCancelAndClose:false,icon:"",inputPattern:null,inputPlaceholder:"",inputType:"text",inputValue:null,inputValidator:null,inputErrorMessage:"",message:null,modalFade:true,modalClass:"",showCancelButton:false,showConfirmButton:true,type:"",title:void 0,showInput:false,action:"",confirmButtonLoading:false,cancelButtonLoading:false,confirmButtonLoadingIcon:Mt,cancelButtonLoadingIcon:Mt,confirmButtonDisabled:false,editorErrorMessage:"",validateError:false,zIndex:l()}),p=y(()=>{const E=u.type;return{[r.bm("icon",E)]:E&&$t[E]}}),f=Zt(),g=Zt(),x=y(()=>u.icon||$t[u.type]||""),v=y(()=>!!u.message),c=B(),_=B(),T=B(),L=B(),W=B(),j=y(()=>u.confirmButtonClass);ne(()=>u.inputValue,async E=>{await ce(),e.boxType==="prompt"&&E!==null&&U()},{immediate:true}),ne(()=>i.value,E=>{var N,V;E&&(e.boxType!=="prompt"&&(u.autofocus?T.value=(V=(N=W.value)==null?void 0:N.$el)!=null?V:c.value:T.value=c.value),u.zIndex=l()),e.boxType==="prompt"&&(E?ce().then(()=>{var se;L.value&&L.value.$el&&(u.autofocus?T.value=(se=C())!=null?se:c.value:T.value=c.value)}):(u.editorErrorMessage="",u.validateError=false))});const G=y(()=>e.draggable),ie=y(()=>e.overflow);ti(c,_,G,ie),Ee(async()=>{await ce(),e.closeOnHashChange&&window.addEventListener("hashchange",A)}),it(()=>{e.closeOnHashChange&&window.removeEventListener("hashchange",A)});function A(){i.value&&(i.value=false,ce(()=>{u.action&&t("action",u.action)}))}const q=()=>{e.closeOnClickModal&&X(u.distinguishCancelAndClose?"close":"cancel")},le=No(q),oe=E=>{if(u.inputType!=="textarea")return E.preventDefault(),X("confirm")},X=E=>{var N;e.boxType==="prompt"&&E==="confirm"&&!U()||(u.action=E,u.beforeClose?(N=u.beforeClose)==null||N.call(u,E,u,A):A())},U=()=>{if(e.boxType==="prompt"){const E=u.inputPattern;if(E&&!E.test(u.inputValue||""))return u.editorErrorMessage=u.inputErrorMessage||a("el.messagebox.error"),u.validateError=true,false;const N=u.inputValidator;if(typeof N=="function"){const V=N(u.inputValue);if(V===false)return u.editorErrorMessage=u.inputErrorMessage||a("el.messagebox.error"),u.validateError=true,false;if(typeof V=="string")return u.editorErrorMessage=V,u.validateError=true,false}}return u.editorErrorMessage="",u.validateError=false,true},C=()=>{const E=L.value.$refs;return E.input||E.textarea},b=()=>{X("close")},$=()=>{e.closeOnPressEscape&&b()};return e.lockScroll&&li(i),{...mr(u),ns:r,overlayEvent:le,visible:i,hasMessage:v,typeClass:p,contentId:f,inputId:g,btnSize:s,iconComponent:x,confirmButtonClasses:j,rootRef:c,focusStartRef:T,headerRef:_,inputRef:L,confirmRef:W,doClose:A,handleClose:b,onCloseRequested:$,handleWrapperClick:q,handleInputEnter:oe,handleAction:X,t:a}}}),Jl=["aria-label","aria-describedby"],Ql=["aria-label"],eu=["id"];function tu(e,t,n,o,r,s){const a=Y("el-icon"),l=Y("close"),i=Y("el-input"),u=Y("el-button"),p=Y("el-focus-trap"),f=Y("el-overlay");return m(),F(on,{name:"fade-in-linear",onAfterLeave:t[11]||(t[11]=g=>e.$emit("vanish")),persisted:""},{default:w(()=>[Je(k(f,{"z-index":e.zIndex,"overlay-class":[e.ns.is("message-box"),e.modalClass],mask:e.modal},{default:w(()=>[S("div",{role:"dialog","aria-label":e.title,"aria-modal":"true","aria-describedby":e.showInput?void 0:e.contentId,class:M(`${e.ns.namespace.value}-overlay-message-box`),onClick:t[8]||(t[8]=(...g)=>e.overlayEvent.onClick&&e.overlayEvent.onClick(...g)),onMousedown:t[9]||(t[9]=(...g)=>e.overlayEvent.onMousedown&&e.overlayEvent.onMousedown(...g)),onMouseup:t[10]||(t[10]=(...g)=>e.overlayEvent.onMouseup&&e.overlayEvent.onMouseup(...g))},[k(p,{loop:"",trapped:e.visible,"focus-trap-el":e.rootRef,"focus-start-el":e.focusStartRef,onReleaseRequested:e.onCloseRequested},{default:w(()=>[S("div",{ref:"rootRef",class:M([e.ns.b(),e.customClass,e.ns.is("draggable",e.draggable),{[e.ns.m("center")]:e.center}]),style:tt(e.customStyle),tabindex:"-1",onClick:t[7]||(t[7]=je(()=>{},["stop"]))},[e.title!==null&&e.title!==void 0?(m(),I("div",{key:0,ref:"headerRef",class:M([e.ns.e("header"),{"show-close":e.showClose}])},[S("div",{class:M(e.ns.e("title"))},[e.iconComponent&&e.center?(m(),F(a,{key:0,class:M([e.ns.e("status"),e.typeClass])},{default:w(()=>[(m(),F(de(e.iconComponent)))]),_:1},8,["class"])):P("v-if",true),S("span",null,D(e.title),1)],2),e.showClose?(m(),I("button",{key:0,type:"button",class:M(e.ns.e("headerbtn")),"aria-label":e.t("el.messagebox.close"),onClick:t[0]||(t[0]=g=>e.handleAction(e.distinguishCancelAndClose?"close":"cancel")),onKeydown:t[1]||(t[1]=vt(je(g=>e.handleAction(e.distinguishCancelAndClose?"close":"cancel"),["prevent"]),["enter"]))},[k(a,{class:M(e.ns.e("close"))},{default:w(()=>[k(l)]),_:1},8,["class"])],42,Ql)):P("v-if",true)],2)):P("v-if",true),S("div",{id:e.contentId,class:M(e.ns.e("content"))},[S("div",{class:M(e.ns.e("container"))},[e.iconComponent&&!e.center&&e.hasMessage?(m(),F(a,{key:0,class:M([e.ns.e("status"),e.typeClass])},{default:w(()=>[(m(),F(de(e.iconComponent)))]),_:1},8,["class"])):P("v-if",true),e.hasMessage?(m(),I("div",{key:1,class:M(e.ns.e("message"))},[te(e.$slots,"default",{},()=>[e.dangerouslyUseHTMLString?(m(),F(de(e.showInput?"label":"p"),{key:1,for:e.showInput?e.inputId:void 0,innerHTML:e.message},null,8,["for","innerHTML"])):(m(),F(de(e.showInput?"label":"p"),{key:0,for:e.showInput?e.inputId:void 0},{default:w(()=>[K(D(e.dangerouslyUseHTMLString?"":e.message),1)]),_:1},8,["for"]))])],2)):P("v-if",true)],2),Je(S("div",{class:M(e.ns.e("input"))},[k(i,{id:e.inputId,ref:"inputRef",modelValue:e.inputValue,"onUpdate:modelValue":t[2]||(t[2]=g=>e.inputValue=g),type:e.inputType,placeholder:e.inputPlaceholder,"aria-invalid":e.validateError,class:M({invalid:e.validateError}),onKeydown:vt(e.handleInputEnter,["enter"])},null,8,["id","modelValue","type","placeholder","aria-invalid","class","onKeydown"]),S("div",{class:M(e.ns.e("errormsg")),style:tt({visibility:e.editorErrorMessage?"visible":"hidden"})},D(e.editorErrorMessage),7)],2),[[Qe,e.showInput]])],10,eu),S("div",{class:M(e.ns.e("btns"))},[e.showCancelButton?(m(),F(u,{key:0,loading:e.cancelButtonLoading,"loading-icon":e.cancelButtonLoadingIcon,class:M([e.cancelButtonClass]),round:e.roundButton,size:e.btnSize,onClick:t[3]||(t[3]=g=>e.handleAction("cancel")),onKeydown:t[4]||(t[4]=vt(je(g=>e.handleAction("cancel"),["prevent"]),["enter"]))},{default:w(()=>[K(D(e.cancelButtonText||e.t("el.messagebox.cancel")),1)]),_:1},8,["loading","loading-icon","class","round","size"])):P("v-if",true),Je(k(u,{ref:"confirmRef",type:"primary",loading:e.confirmButtonLoading,"loading-icon":e.confirmButtonLoadingIcon,class:M([e.confirmButtonClasses]),round:e.roundButton,disabled:e.confirmButtonDisabled,size:e.btnSize,onClick:t[5]||(t[5]=g=>e.handleAction("confirm")),onKeydown:t[6]||(t[6]=vt(je(g=>e.handleAction("confirm"),["prevent"]),["enter"]))},{default:w(()=>[K(D(e.confirmButtonText||e.t("el.messagebox.confirm")),1)]),_:1},8,["loading","loading-icon","class","round","disabled","size"]),[[Qe,e.showConfirmButton]])],2)],6)]),_:3},8,["trapped","focus-trap-el","focus-start-el","onReleaseRequested"])],42,Jl)]),_:3},8,["z-index","overlay-class","mask"]),[[Qe,e.visible]])]),_:3})}var nu=Be(Zl,[["render",tu],["__file","index.vue"]]);const at=new Map,ou=e=>{let t=document.body;return e.appendTo&&(ye(e.appendTo)&&(t=document.querySelector(e.appendTo)),Wt(e.appendTo)&&(t=e.appendTo),Wt(t)||(t=document.body)),t},ru=(e,t,n=null)=>{const o=k(nu,e,Re(e.message)||Bt(e.message)?{default:Re(e.message)?e.message:()=>e.message}:null);return o.appContext=n,xt(o,t),ou(e).appendChild(t.firstElementChild),o.component},su=()=>document.createElement("div"),au=(e,t)=>{const n=su();e.onVanish=()=>{xt(null,n),at.delete(r)},e.onAction=s=>{const a=at.get(r);let l;e.showInput?l={value:r.inputValue,action:s}:l=s,e.callback?e.callback(l,o.proxy):s==="cancel"||s==="close"?e.distinguishCancelAndClose&&s!=="cancel"?a.reject("close"):a.reject("cancel"):a.resolve(l)};const o=ru(e,n,t),r=o.proxy;for(const s in e)Tt(e,s)&&!Tt(r.$props,s)&&(r[s]=e[s]);return r.visible=true,r};function Ge(e,t=null){if(!he)return Promise.reject();let n;return ye(e)||Bt(e)?e={message:e}:n=e.callback,new Promise((o,r)=>{const s=au(e,t??Ge._context);at.set(s,{options:e,callback:n,resolve:o,reject:r})})}const iu=["alert","confirm","prompt"],lu={alert:{closeOnPressEscape:false,closeOnClickModal:false},confirm:{showCancelButton:true},prompt:{showCancelButton:true,showInput:true}};iu.forEach(e=>{Ge[e]=uu(e)});function uu(e){return(t,n,o,r)=>{let s="";return nt(n)?(o=n,s=""):yo(n)?s="":s=n,Ge(Object.assign({title:s,message:t,type:"",...lu[e]},o,{boxType:e}),r)}}Ge.close=()=>{at.forEach((e,t)=>{t.doClose()}),at.clear()};Ge._context=null;const Me=Ge;Me.install=e=>{Me._context=e._context,e.config.globalProperties.$msgbox=Me,e.config.globalProperties.$messageBox=Me,e.config.globalProperties.$alert=Me.alert,e.config.globalProperties.$confirm=Me.confirm,e.config.globalProperties.$prompt=Me.prompt};const cu=Me;var qt={},eo;function du(){return eo||(eo=1,function(e){(function(t,n){if(typeof e.nodeName!="string")n(e);else{var o={};n(o),t.AnsiUp=o.default}})(Ml,function(t){var n=this&&this.__makeTemplateObject||function(l,i){return Object.defineProperty?Object.defineProperty(l,"raw",{value:i}):l.raw=i,l},o;(function(l){l[l.EOS=0]="EOS",l[l.Text=1]="Text",l[l.Incomplete=2]="Incomplete",l[l.ESC=3]="ESC",l[l.Unknown=4]="Unknown",l[l.SGR=5]="SGR",l[l.OSCURL=6]="OSCURL"})(o||(o={}));var r=function(){function l(){this.VERSION="5.2.1",this.setup_palettes(),this._use_classes=false,this.bold=false,this.italic=false,this.underline=false,this.fg=this.bg=null,this._buffer="",this._url_whitelist={http:1,https:1},this._escape_html=true}return Object.defineProperty(l.prototype,"use_classes",{get:function(){return this._use_classes},set:function(i){this._use_classes=i},enumerable:false,configurable:true}),Object.defineProperty(l.prototype,"url_whitelist",{get:function(){return this._url_whitelist},set:function(i){this._url_whitelist=i},enumerable:false,configurable:true}),Object.defineProperty(l.prototype,"escape_html",{get:function(){return this._escape_html},set:function(i){this._escape_html=i},enumerable:false,configurable:true}),l.prototype.setup_palettes=function(){var i=this;this.ansi_colors=[[{rgb:[0,0,0],class_name:"ansi-black"},{rgb:[187,0,0],class_name:"ansi-red"},{rgb:[0,187,0],class_name:"ansi-green"},{rgb:[187,187,0],class_name:"ansi-yellow"},{rgb:[0,0,187],class_name:"ansi-blue"},{rgb:[187,0,187],class_name:"ansi-magenta"},{rgb:[0,187,187],class_name:"ansi-cyan"},{rgb:[255,255,255],class_name:"ansi-white"}],[{rgb:[85,85,85],class_name:"ansi-bright-black"},{rgb:[255,85,85],class_name:"ansi-bright-red"},{rgb:[0,255,0],class_name:"ansi-bright-green"},{rgb:[255,255,85],class_name:"ansi-bright-yellow"},{rgb:[85,85,255],class_name:"ansi-bright-blue"},{rgb:[255,85,255],class_name:"ansi-bright-magenta"},{rgb:[85,255,255],class_name:"ansi-bright-cyan"},{rgb:[255,255,255],class_name:"ansi-bright-white"}]],this.palette_256=[],this.ansi_colors.forEach(function(T){T.forEach(function(L){i.palette_256.push(L)})});for(var u=[0,95,135,175,215,255],p=0;p<6;++p)for(var f=0;f<6;++f)for(var g=0;g<6;++g){var x={rgb:[u[p],u[f],u[g]],class_name:"truecolor"};this.palette_256.push(x)}for(var v=8,c=0;c<24;++c,v+=10){var _={rgb:[v,v,v],class_name:"truecolor"};this.palette_256.push(_)}},l.prototype.escape_txt_for_html=function(i){return this._escape_html?i.replace(/[&<>"']/gm,function(u){if(u==="&")return"&";if(u==="<")return"<";if(u===">")return">";if(u==='"')return""";if(u==="'")return"'"}):i},l.prototype.append_buffer=function(i){var u=this._buffer+i;this._buffer=u},l.prototype.get_next_packet=function(){var i={kind:o.EOS,text:"",url:""},u=this._buffer.length;if(u==0)return i;var p=this._buffer.indexOf("\x1B");if(p==-1)return i.kind=o.Text,i.text=this._buffer,this._buffer="",i;if(p>0)return i.kind=o.Text,i.text=this._buffer.slice(0,p),this._buffer=this._buffer.slice(p),i;if(p==0){if(u<3)return i.kind=o.Incomplete,i;var f=this._buffer.charAt(1);if(f!="["&&f!="]"&&f!="(")return i.kind=o.ESC,i.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),i;if(f=="["){this._csi_regex||(this._csi_regex=s(n([`
|
|
14
|
+
^ # beginning of line
|
|
15
|
+
#
|
|
16
|
+
# First attempt
|
|
17
|
+
(?: # legal sequence
|
|
18
|
+
\x1B[ # CSI
|
|
19
|
+
([<-?]?) # private-mode char
|
|
20
|
+
([d;]*) # any digits or semicolons
|
|
21
|
+
([ -/]? # an intermediate modifier
|
|
22
|
+
[@-~]) # the command
|
|
23
|
+
)
|
|
24
|
+
| # alternate (second attempt)
|
|
25
|
+
(?: # illegal sequence
|
|
26
|
+
\x1B[ # CSI
|
|
27
|
+
[ -~]* # anything legal
|
|
28
|
+
([\0-:]) # anything illegal
|
|
29
|
+
)
|
|
30
|
+
`],[`
|
|
31
|
+
^ # beginning of line
|
|
32
|
+
#
|
|
33
|
+
# First attempt
|
|
34
|
+
(?: # legal sequence
|
|
35
|
+
\\x1b\\[ # CSI
|
|
36
|
+
([\\x3c-\\x3f]?) # private-mode char
|
|
37
|
+
([\\d;]*) # any digits or semicolons
|
|
38
|
+
([\\x20-\\x2f]? # an intermediate modifier
|
|
39
|
+
[\\x40-\\x7e]) # the command
|
|
40
|
+
)
|
|
41
|
+
| # alternate (second attempt)
|
|
42
|
+
(?: # illegal sequence
|
|
43
|
+
\\x1b\\[ # CSI
|
|
44
|
+
[\\x20-\\x7e]* # anything legal
|
|
45
|
+
([\\x00-\\x1f:]) # anything illegal
|
|
46
|
+
)
|
|
47
|
+
`])));var g=this._buffer.match(this._csi_regex);if(g===null)return i.kind=o.Incomplete,i;if(g[4])return i.kind=o.ESC,i.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),i;g[1]!=""||g[3]!="m"?i.kind=o.Unknown:i.kind=o.SGR,i.text=g[2];var x=g[0].length;return this._buffer=this._buffer.slice(x),i}else if(f=="]"){if(u<4)return i.kind=o.Incomplete,i;if(this._buffer.charAt(2)!="8"||this._buffer.charAt(3)!=";")return i.kind=o.ESC,i.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),i;this._osc_st||(this._osc_st=a(n([`
|
|
48
|
+
(?: # legal sequence
|
|
49
|
+
(\x1B\\) # ESC | # alternate
|
|
50
|
+
(\x07) # BEL (what xterm did)
|
|
51
|
+
)
|
|
52
|
+
| # alternate (second attempt)
|
|
53
|
+
( # illegal sequence
|
|
54
|
+
[\0-] # anything illegal
|
|
55
|
+
| # alternate
|
|
56
|
+
[\b-] # anything illegal
|
|
57
|
+
| # alternate
|
|
58
|
+
[-] # anything illegal
|
|
59
|
+
)
|
|
60
|
+
`],[`
|
|
61
|
+
(?: # legal sequence
|
|
62
|
+
(\\x1b\\\\) # ESC \\
|
|
63
|
+
| # alternate
|
|
64
|
+
(\\x07) # BEL (what xterm did)
|
|
65
|
+
)
|
|
66
|
+
| # alternate (second attempt)
|
|
67
|
+
( # illegal sequence
|
|
68
|
+
[\\x00-\\x06] # anything illegal
|
|
69
|
+
| # alternate
|
|
70
|
+
[\\x08-\\x1a] # anything illegal
|
|
71
|
+
| # alternate
|
|
72
|
+
[\\x1c-\\x1f] # anything illegal
|
|
73
|
+
)
|
|
74
|
+
`]))),this._osc_st.lastIndex=0;{var v=this._osc_st.exec(this._buffer);if(v===null)return i.kind=o.Incomplete,i;if(v[3])return i.kind=o.ESC,i.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),i}{var c=this._osc_st.exec(this._buffer);if(c===null)return i.kind=o.Incomplete,i;if(c[3])return i.kind=o.ESC,i.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),i}this._osc_regex||(this._osc_regex=s(n([`
|
|
75
|
+
^ # beginning of line
|
|
76
|
+
#
|
|
77
|
+
\x1B]8; # OSC Hyperlink
|
|
78
|
+
[ -:<-~]* # params (excluding ;)
|
|
79
|
+
; # end of params
|
|
80
|
+
([!-~]{0,512}) # URL capture
|
|
81
|
+
(?: # ST
|
|
82
|
+
(?:\x1B\\) # ESC | # alternate
|
|
83
|
+
(?:\x07) # BEL (what xterm did)
|
|
84
|
+
)
|
|
85
|
+
([ -~]+) # TEXT capture
|
|
86
|
+
\x1B]8;; # OSC Hyperlink End
|
|
87
|
+
(?: # ST
|
|
88
|
+
(?:\x1B\\) # ESC | # alternate
|
|
89
|
+
(?:\x07) # BEL (what xterm did)
|
|
90
|
+
)
|
|
91
|
+
`],[`
|
|
92
|
+
^ # beginning of line
|
|
93
|
+
#
|
|
94
|
+
\\x1b\\]8; # OSC Hyperlink
|
|
95
|
+
[\\x20-\\x3a\\x3c-\\x7e]* # params (excluding ;)
|
|
96
|
+
; # end of params
|
|
97
|
+
([\\x21-\\x7e]{0,512}) # URL capture
|
|
98
|
+
(?: # ST
|
|
99
|
+
(?:\\x1b\\\\) # ESC \\
|
|
100
|
+
| # alternate
|
|
101
|
+
(?:\\x07) # BEL (what xterm did)
|
|
102
|
+
)
|
|
103
|
+
([\\x20-\\x7e]+) # TEXT capture
|
|
104
|
+
\\x1b\\]8;; # OSC Hyperlink End
|
|
105
|
+
(?: # ST
|
|
106
|
+
(?:\\x1b\\\\) # ESC \\
|
|
107
|
+
| # alternate
|
|
108
|
+
(?:\\x07) # BEL (what xterm did)
|
|
109
|
+
)
|
|
110
|
+
`])));var g=this._buffer.match(this._osc_regex);if(g===null)return i.kind=o.ESC,i.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),i;i.kind=o.OSCURL,i.url=g[1],i.text=g[2];var x=g[0].length;return this._buffer=this._buffer.slice(x),i}else if(f=="(")return i.kind=o.Unknown,this._buffer=this._buffer.slice(3),i}},l.prototype.ansi_to_html=function(i){this.append_buffer(i);for(var u=[];;){var p=this.get_next_packet();if(p.kind==o.EOS||p.kind==o.Incomplete)break;p.kind==o.ESC||p.kind==o.Unknown||(p.kind==o.Text?u.push(this.transform_to_html(this.with_state(p))):p.kind==o.SGR?this.process_ansi(p):p.kind==o.OSCURL&&u.push(this.process_hyperlink(p)))}return u.join("")},l.prototype.with_state=function(i){return{bold:this.bold,italic:this.italic,underline:this.underline,fg:this.fg,bg:this.bg,text:i.text}},l.prototype.process_ansi=function(i){for(var u=i.text.split(";");u.length>0;){var p=u.shift(),f=parseInt(p,10);if(isNaN(f)||f===0)this.fg=this.bg=null,this.bold=false,this.italic=false,this.underline=false;else if(f===1)this.bold=true;else if(f===3)this.italic=true;else if(f===4)this.underline=true;else if(f===22)this.bold=false;else if(f===23)this.italic=false;else if(f===24)this.underline=false;else if(f===39)this.fg=null;else if(f===49)this.bg=null;else if(f>=30&&f<38)this.fg=this.ansi_colors[0][f-30];else if(f>=40&&f<48)this.bg=this.ansi_colors[0][f-40];else if(f>=90&&f<98)this.fg=this.ansi_colors[1][f-90];else if(f>=100&&f<108)this.bg=this.ansi_colors[1][f-100];else if((f===38||f===48)&&u.length>0){var g=f===38,x=u.shift();if(x==="5"&&u.length>0){var v=parseInt(u.shift(),10);v>=0&&v<=255&&(g?this.fg=this.palette_256[v]:this.bg=this.palette_256[v])}if(x==="2"&&u.length>2){var c=parseInt(u.shift(),10),_=parseInt(u.shift(),10),T=parseInt(u.shift(),10);if(c>=0&&c<=255&&_>=0&&_<=255&&T>=0&&T<=255){var L={rgb:[c,_,T],class_name:"truecolor"};g?this.fg=L:this.bg=L}}}}},l.prototype.transform_to_html=function(i){var u=i.text;if(u.length===0||(u=this.escape_txt_for_html(u),!i.bold&&!i.italic&&!i.underline&&i.fg===null&&i.bg===null))return u;var p=[],f=[],g=i.fg,x=i.bg;i.bold&&p.push("font-weight:bold"),i.italic&&p.push("font-style:italic"),i.underline&&p.push("text-decoration:underline"),this._use_classes?(g&&(g.class_name!=="truecolor"?f.push(g.class_name+"-fg"):p.push("color:rgb("+g.rgb.join(",")+")")),x&&(x.class_name!=="truecolor"?f.push(x.class_name+"-bg"):p.push("background-color:rgb("+x.rgb.join(",")+")"))):(g&&p.push("color:rgb("+g.rgb.join(",")+")"),x&&p.push("background-color:rgb("+x.rgb+")"));var v="",c="";return f.length&&(v=' class="'+f.join(" ")+'"'),p.length&&(c=' style="'+p.join(";")+'"'),"<span"+c+v+">"+u+"</span>"},l.prototype.process_hyperlink=function(i){var u=i.url.split(":");if(u.length<1||!this._url_whitelist[u[0]])return"";var p='<a href="'+this.escape_txt_for_html(i.url)+'">'+this.escape_txt_for_html(i.text)+"</a>";return p},l}();function s(l){var i=l.raw[0],u=/^\s+|\s+\n|\s*#[\s\S]*?\n|\n/gm,p=i.replace(u,"");return new RegExp(p)}function a(l){var i=l.raw[0],u=/^\s+|\s+\n|\s*#[\s\S]*?\n|\n/gm,p=i.replace(u,"");return new RegExp(p,"g")}Object.defineProperty(t,"__esModule",{value:true}),t.default=r})}(qt)),qt}var fu=du();const to=$l(fu),pu=["innerHTML"],vu=H({__name:"logs",props:{visible:{type:Boolean},process:{},logs:{},maxHeight:{}},emits:["update:visible"],setup(e,{emit:t}){const n=e,o=t,r=y({get:()=>n.visible,set:i=>o("update:visible",i)}),s=new(to.default||to);function a(i){return i.data===""}function l(i){return s.ansi_to_html(i.data)}return(i,u)=>{var f;const p=Y("el-dialog");return m(),F(p,{modelValue:r.value,"onUpdate:modelValue":u[0]||(u[0]=g=>r.value=g),title:`Log · ${((f=e.process)==null?void 0:f.name)||""}`,width:"80%"},{default:w(()=>[k(d(or),{class:"log-list k-text-selectable",data:e.logs,count:300,"max-height":e.maxHeight},{default:w(g=>[S("div",{class:M({line:true,start:a(g)})},[S("code",{innerHTML:l(g)},null,8,pu)],2)]),_:1},8,["data","max-height"])]),_:1},8,["modelValue","title"])}}}),hu=lt(vu,[["__scopeId","data-v-95c3a303"]]),mu={class:"alert-dialog-actions"},gu=H({__name:"alert",props:{visible:{type:Boolean},process:{},initial:{}},emits:["update:visible","submit"],setup(e,{emit:t}){const n=e,o=t,r=y(()=>{var u;return re.object({name:re.string().description("The name of the process. Use `*` to match all processes.").required(false).hidden(),event:re.union(["restart","delete","stop","reload","graceful reload","start","exit","online","restart overlimit",re.object({type:re.const("exit").default("exit").hidden(),eq:re.number().required(false),neq:re.number().required(false)}).description("exit(code)")]).description("The type of process:event.").default("exit"),sid:re.union(["auto",...Object.keys(((u=rr.status)==null?void 0:u.bots)||{})]).description("platform:selfId").default("auto"),cid:re.string().description("platform:channelId").required(),message:re.string().description("The custom i18n message to send with the notification.").required(false)})}),s=B({});ne(()=>({initial:n.initial,visible:n.visible}),u=>{u.initial&&(s.value=r.value(u.initial))},{immediate:true});const a=y({get:()=>n.visible,set:u=>o("update:visible",u)}),l=y(()=>n.initial||s.value),i=()=>{var p;let u;try{u=r.value(s.value)}catch(f){ge.error(`Invalid configuration: ${f.message}`);return}o("submit",{...u,name:((p=n.process)==null?void 0:p.name)||"*"}),a.value=false};return(u,p)=>{var v;const f=Y("k-schema"),g=Y("el-button"),x=Y("el-dialog");return m(),F(x,{modelValue:a.value,"onUpdate:modelValue":p[2]||(p[2]=c=>a.value=c),title:`Alert · ${n.initial?"Edit":"Add"} · ${((v=n.process)==null?void 0:v.name)||""}`,"close-on-click-modal":false,width:"60%"},{default:w(()=>[k(f,{schema:r.value,initial:l.value,modelValue:s.value,"onUpdate:modelValue":p[0]||(p[0]=c=>s.value=c)},null,8,["schema","initial","modelValue"]),S("div",mu,[k(g,{type:"primary",onClick:i},{default:w(()=>[...p[3]||(p[3]=[K("Save",-1)])]),_:1}),k(g,{onClick:p[1]||(p[1]=c=>a.value=false)},{default:w(()=>[...p[4]||(p[4]=[K("Cancel",-1)])]),_:1})])]),_:1},8,["modelValue","title"])}}}),bu={key:0,class:"action-dialog-loading"},yu={key:1,class:"action-result-list"},_u={class:"action-result-meta"},wu={key:0},Su=["innerHTML"],Cu={key:1,class:"section-empty"},Eu=H({__name:"action",props:{visible:{type:Boolean},process:{},action:{},results:{},loading:{type:Boolean}},emits:["update:visible"],setup(e,{emit:t}){const n=e,o=t,r=y({get:()=>n.visible,set:l=>o("update:visible",l)}),s=l=>l.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),a=l=>{var u;const i=((u=l==null?void 0:l.data)==null?void 0:u.return)??(l==null?void 0:l.data);if(i==null)return"<em>No response received.</em>";if(typeof i=="string")return i;try{const p=JSON.stringify(i,null,2);return`<pre>${s(p)}</pre>`}catch{return`<pre>${s(String(i))}</pre>`}};return(l,i)=>{var f,g;const u=Y("el-skeleton"),p=Y("el-dialog");return m(),F(p,{modelValue:r.value,"onUpdate:modelValue":i[0]||(i[0]=x=>r.value=x),title:`Actions · ${((f=e.process)==null?void 0:f.name)??""} · ${((g=e.action)==null?void 0:g.name)??""}`,width:"80%"},{default:w(()=>{var x;return[e.loading?(m(),I("div",bu,[k(u,{rows:3,animated:""})])):(m(),I("div",yu,[(x=e.results)!=null&&x.length?(m(true),I(Ae,{key:0},Yt(e.results,(v,c)=>{var _,T,L,W,j,G;return m(),I("div",{key:`${((_=v.process)==null?void 0:_.pm_id)??"unknown"}-${((T=v.process)==null?void 0:T.name)??c}`,class:"action-result-row"},[S("div",_u,[K(" ["+D(((L=v.process)==null?void 0:L.name)??"unknown")+":"+D(((W=v.process)==null?void 0:W.pm_id)??"?")+" ",1),(j=v.process)!=null&&j.namespace?(m(),I("span",wu,"/"+D((G=v.process)==null?void 0:G.namespace),1)):P("v-if",true),i[1]||(i[1]=K("] ",-1))]),S("div",{class:"action-result-payload",innerHTML:a(v)},null,8,Su)])}),128)):(m(),I("p",Cu,"No response received."))]))]}),_:1},8,["modelValue","title"])}}}),xu=lt(Eu,[["__scopeId","data-v-10832b55"]]),Tu={key:0,class:"expand-section"},ku={class:"metrics-container"},Iu={class:"metric-name"},Mu={class:"metric-value"},$u={key:0,class:"metric-unit"},Au={key:1,class:"expand-section"},Ou={class:"actions-container"},Bu={class:"action-name"},Lu={class:"expand-section"},Nu={class:"expand-header"},Pu={class:"expand-actions"},Fu={key:0,class:"alert-message"},Ru={key:1,class:"alert-message placeholder"},zu={class:"alert-row-actions"},Hu={key:1,class:"section-empty"},Vu={class:"status-cell"},Du={class:"status-badges"},ju=H({__name:"dashboard",setup(e){const t=sr(),n=ar(),o=ir(),r=B([]),s=B(),a=B(false),l=B([]),i=B(false),u=B(false),p=B(),f=B([]),g=B(false),x=B();let v;const c=(C,b)=>{var $,E;Object.assign(C,b),C.metrics=Object.entries((($=b.pm2_env)==null?void 0:$.axm_monitor)||{}).map(([N,V])=>({name:N,value:V.value,unit:V.unit||""})),C.actions=Object.entries(((E=b.pm2_env)==null?void 0:E.axm_actions)||{}).filter(([N,V])=>(V==null?void 0:V.action_type)==="custom").map(([N,V])=>({name:V.action_name,type:V.action_type,arity:V.arity||0}))},_=async()=>{const C=await me("pm2/list");if(!C||!C.length)return;const b=new Map(C.map(E=>[E.pm_id,E])),$=new Map(r.value.map(E=>[E.pm_id,E]));for(const E of C){const N=$.get(E.pm_id);if(N)c(N,E);else{const V={...E};c(V,E),r.value.push(V)}}for(let E=r.value.length-1;E>=0;E--){const N=r.value[E];b.has(N.pm_id)||r.value.splice(E,1)}};Ee(async()=>{var C;await _(),v=window.setInterval(_,((C=n.value.pm2)==null?void 0:C.refreshInterval)||2e3)}),ro(()=>{clearInterval(v)});const T=C=>{switch(C){case"online":return"success";case"stopping":return"warning";case"stopped":return"info";case"waiting restart":return"warning";case"launching":return"info";case"errored":return"danger";default:return"info"}},L=C=>{if(!C)return"-";const $=Date.now()-C,E=Math.floor($/(1e3*60*60*24));if(E)return`${E}d`;const N=Math.floor($/(1e3*60*60))%24;if(N)return`${N}h`;const V=Math.floor($/(1e3*60))%60;return V?`${V}m`:`${Math.floor($/1e3)%60}s`},W=C=>C<1024?`${C} B`:C<1024*1024?`${(C/1024).toFixed(2)} KB`:`${(C/1024/1024/1024).toFixed(2)} GB`,j=async(C,b)=>{var $,E;if(((E=($=n.value.pm2)==null?void 0:$.enableConfirm)==null?void 0:E.includes(b))??true)try{await cu.confirm(`Are you sure you want to ${b} ${C.name}?`,"Confirm Action",{confirmButtonText:"Confirm",cancelButtonText:"Cancel",type:b==="delete"?"warning":"info"})}catch{return}await me("pm2/action",C.pm_id,b),await _()},G=async(C,b)=>{s.value=C,p.value=b,i.value=true,u.value=true;try{const $=await me("pm2/trigger-action",C.pm_id??C.name,b.name);f.value=$||[]}catch($){f.value=[],console.error("Failed to trigger PM2 monitor action",C.pm_id,b.name,$),ge.error(`Failed to trigger ${b.name}`)}finally{u.value=false}};t.action("pm2.log",{action:()=>ie()});const ie=async C=>{C?(s.value=C,l.value=await me("pm2/start-log",C.pm_id).then(b=>b.map($=>({data:$}))),a.value=true):(s.value={name:"PM2"},l.value=await me("pm2/start-log","PM2").then(b=>b.map($=>({data:$}))),a.value=true)};lr("pm2/patch-log",C=>{const[b,$]=C;l.value.push(...$.map(E=>({data:E})))});const A=C=>{s.value=C,x.value=void 0,g.value=true},q=(C,b)=>{s.value=C,x.value=b,g.value=true},le=async C=>{try{x.value?await me("pm2/edit-alert",x.value,C):await me("pm2/add-alert",C),await _(),ge.success(x.value?"Alert updated successfully":"Alert added successfully")}catch(b){console.error("Failed to save alert",b),ge.error(x.value?"Failed to update alert":"Failed to add alert")}finally{x.value=void 0}},oe=(C,b)=>{const $=b.name??C.name,E={...b,name:$};me("pm2/remove-alert",E).then(()=>{ge.success("Alert removed successfully"),_()}).catch(N=>{console.error("Failed to remove alert",N),ge.error("Failed to remove alert")})},X=(C,b)=>{me("pm2/test-alert",b).then(()=>{ge.success("Test alert sent")}).catch($=>{console.error("Failed to send test alert",$),ge.error("Failed to send test alert")})},U=C=>{me("pm2/clear-alerts",C.name).then(()=>{ge.success("All alerts cleared successfully"),_()}).catch(b=>{console.error("Failed to clear alerts",b),ge.error("Failed to clear alerts")})};return ne(g,C=>{C||(x.value=void 0)}),(C,b)=>{const $=Y("el-button"),E=Y("el-popconfirm"),N=Y("el-table-column"),V=Y("el-table"),se=Y("el-tag"),Le=Y("el-tooltip"),qe=Y("el-button-group"),Te=Y("el-scrollbar"),Ye=Y("k-layout");return m(),F(Ye,{menu:"pm2"},{default:w(()=>[k(Te,{class:"process-scroll"},{default:w(()=>[k(V,{data:r.value,style:{width:"100%"},"row-key":"pm_id"},{default:w(()=>[k(N,{type:"expand"},{default:w(({row:O})=>{var we,ct,dt;return[(we=O.metrics)!=null&&we.length?(m(),I("div",Tu,[b[3]||(b[3]=S("h4",{class:"expand-title"},"Metrics",-1)),S("div",ku,[(m(true),I(Ae,null,Yt(O.metrics,z=>(m(),I("div",{key:z.name,class:"metric-card"},[S("div",Iu,D(z.name),1),S("div",Mu,[K(D(z.value)+" ",1),z.unit?(m(),I("span",$u,D(z.unit),1)):P("v-if",true)])]))),128))])])):P("v-if",true),(ct=O.actions)!=null&&ct.length?(m(),I("div",Au,[b[4]||(b[4]=S("h4",{class:"expand-title"},"Actions",-1)),S("div",Ou,[(m(true),I(Ae,null,Yt(O.actions,z=>(m(),F($,{key:z.name,size:"small",class:"action-chip",plain:"",onClick:ft=>G(O,z)},{default:w(()=>[S("span",Bu,D(z.name),1)]),_:2},1032,["onClick"]))),128))])])):P("v-if",true),S("div",Lu,[S("div",Nu,[b[7]||(b[7]=S("h4",{class:"expand-title"},"Alerts",-1)),S("div",Pu,[k($,{size:"small",type:"primary",onClick:z=>A(O)},{default:w(()=>[...b[5]||(b[5]=[K("Add Alert",-1)])]),_:1},8,["onClick"]),k(E,{title:"Clear all alerts?",description:`Target: ${O.name}`,"confirm-button-text":"Confirm","cancel-button-text":"Cancel",width:"260",onConfirm:z=>U(O)},{reference:w(()=>[k($,{size:"small",type:"danger"},{default:w(()=>[...b[6]||(b[6]=[K("Clear Alerts",-1)])]),_:1})]),_:1},8,["description","onConfirm"])])]),(dt=O.alerts)!=null&&dt.length?(m(),F(V,{key:0,data:O.alerts,size:"small",border:"",class:"alert-table"},{default:w(()=>[k(N,{prop:"event",label:"Event","min-width":"120"},{default:w(({row:z})=>[S("span",null,D(z.event.type??z.event),1)]),_:1}),k(N,{prop:"sid",label:"From","min-width":"160"}),k(N,{prop:"cid",label:"To","min-width":"160"}),k(N,{label:"Message","min-width":"320"},{default:w(({row:z})=>[z.message?(m(),I("span",Fu,D(z.message),1)):(m(),I("span",Ru,"Default template"))]),_:1}),k(N,{label:"Actions","min-width":"150",align:"center"},{default:w(({row:z})=>[S("div",zu,[k($,{size:"small",text:"",title:"Send test alert","aria-label":"Send test alert",onClick:ft=>X(O,z)},{default:w(()=>[...b[8]||(b[8]=[K(" 🔔 ",-1)])]),_:1},8,["onClick"]),k($,{size:"small",text:"",title:"Edit alert","aria-label":"Edit alert",onClick:ft=>q(O,z)},{default:w(()=>[...b[9]||(b[9]=[K(" ✎ ",-1)])]),_:1},8,["onClick"]),k(E,{title:`Remove ${z.event.type??z.event} alert?`,description:z.name==="*"?"Alert applies to all processes.":`Target: ${z.name??O.name}`,"confirm-button-text":"Delete","cancel-button-text":"Cancel",width:"260",onConfirm:ft=>oe(O,z)},{reference:w(()=>[k($,{size:"small",type:"danger",text:"",title:"Delete alert","aria-label":"Delete alert"},{default:w(()=>[...b[10]||(b[10]=[K(" ✖ ",-1)])]),_:1})]),_:1},8,["title","description","onConfirm"])])]),_:2},1024)]),_:2},1032,["data"])):(m(),I("p",Hu,"No alerts configured for this process."))])]}),_:1}),P(' <el-table-column prop="pm_id" label="ID" /> '),k(N,{prop:"name",label:"Name"}),k(N,{prop:"pm2_env.status",label:"Status","min-width":"160"},{default:w(({row:O})=>[S("div",Vu,[k(se,{type:T(O.pm2_env.status),effect:d(o)},{default:w(()=>[K(D(O.pm2_env.status),1)]),_:2},1032,["type","effect"]),S("div",Du,[O.pm2_env.autorestart?(m(),F(Le,{key:0,content:"Auto restart enabled",placement:"top"},{default:w(()=>[...b[11]||(b[11]=[S("span",{class:"status-badge auto","aria-label":"Auto restart enabled"},"↻",-1)])]),_:1})):P("v-if",true),O.pm2_env.cron_restart&&O.pm2_env.cron_restart!=0?(m(),F(Le,{key:1,content:"Cron restart configured",placement:"top"},{default:w(()=>[...b[12]||(b[12]=[S("span",{class:"status-badge cron","aria-label":"Cron restart configured"},"⏰︎",-1)])]),_:1})):P("v-if",true)])])]),_:1}),k(N,{prop:"pm2_env.pm_uptime",label:"Uptime"},{default:w(({row:O})=>[K(D(O.pm2_env.status==="online"?L(O.pm2_env.pm_uptime):0),1)]),_:1}),k(N,{prop:"pm2_env.restart_time",label:"Restarts"}),k(N,{prop:"monit.cpu",label:"CPU"},{default:w(({row:O})=>[K(D(O.monit.cpu)+"% ",1)]),_:1}),k(N,{prop:"monit.memory",label:"Memory"},{default:w(({row:O})=>[K(D(W(O.monit.memory)),1)]),_:1}),k(N,{label:"Actions"},{default:w(({row:O})=>[k(qe,null,{default:w(()=>[k($,{size:"small",title:"Restart","aria-label":"Restart",onClick:we=>j(O,"restart")},{default:w(()=>[...b[13]||(b[13]=[K("↻",-1)])]),_:1},8,["onClick"]),k($,{size:"small",title:"Reload","aria-label":"Reload",onClick:we=>j(O,"reload")},{default:w(()=>[...b[14]||(b[14]=[K("↺",-1)])]),_:1},8,["onClick"]),k($,{size:"small",title:"Stop","aria-label":"Stop",onClick:we=>j(O,"stop")},{default:w(()=>[...b[15]||(b[15]=[K("■",-1)])]),_:1},8,["onClick"]),k($,{size:"small",type:"danger",title:"Delete","aria-label":"Delete",onClick:we=>j(O,"delete")},{default:w(()=>[...b[16]||(b[16]=[K("✖",-1)])]),_:1},8,["onClick"]),k($,{size:"small",title:"Logs","aria-label":"Logs",onClick:we=>ie(O)},{default:w(()=>[...b[17]||(b[17]=[K("📋",-1)])]),_:1},8,["onClick"])]),_:2},1024)]),_:1})]),_:1},8,["data"])]),_:1}),k(hu,{visible:a.value,"onUpdate:visible":b[0]||(b[0]=O=>a.value=O),process:s.value,logs:l.value,"max-height":"60vh"},null,8,["visible","process","logs"]),k(xu,{visible:i.value,"onUpdate:visible":b[1]||(b[1]=O=>i.value=O),process:s.value,action:p.value,results:f.value,loading:u.value},null,8,["visible","process","action","results","loading"]),k(gu,{visible:g.value,"onUpdate:visible":b[2]||(b[2]=O=>g.value=O),process:s.value,initial:x.value,onSubmit:le},null,8,["visible","process","initial"])]),_:1})}}}),Uu=lt(ju,[["__scopeId","data-v-1b700a1c"]]),Yu=e=>{e.page({name:"PM2 Dashboard",path:"/pm2",icon:"pm2:icon",component:Uu,authority:4}),e.menu("pm2",[{id:".log",icon:"pm2:logs",label:"Daemon Logs"}]);const t=re.object({pm2:re.object({enableConfirm:re.array(re.union(["restart","reload","stop","delete"])).description("Enable confirmation for process actions.").default(["restart","reload","stop","delete"]).role("checkbox"),refreshInterval:re.number().description("The interval (in milliseconds) to refresh the process list.").default(2e3).min(1e3)})});e.settings({id:"pm2",title:"PM2 Settings",schema:t})};export{Yu as default};
|
package/dist/style.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.log-list[data-v-95c3a303]{color:var(--terminal-fg);background-color:var(--terminal-bg)}.log-list[data-v-95c3a303] .el-scrollbar__view{padding:1rem}.log-list .line.start[data-v-95c3a303]{margin-top:1rem}.log-list .line.start[data-v-95c3a303]:before{content:"";position:absolute;left:0;right:0;top:-.5rem;border-top:1px solid var(--terminal-separator)}.log-list .line[data-v-95c3a303]:first-child{margin-top:0}.log-list .line[data-v-95c3a303]:first-child:before{display:none}.log-list .line[data-v-95c3a303]{padding:0 .5rem;border-radius:2px;font-size:14px;line-height:20px;white-space:pre-wrap;word-break:break-all;position:relative}.log-list .line[data-v-95c3a303]:hover{color:var(--terminal-fg-hover);background-color:var(--terminal-bg-hover)}.log-list .line[data-v-95c3a303] ::selection{background-color:var(--terminal-bg-selection)}.alert-dialog-actions{margin-top:20px;display:flex;justify-content:center}.action-dialog-loading[data-v-10832b55]{padding:24px 0}.action-result-list[data-v-10832b55]{display:flex;flex-direction:column;gap:12px;max-height:60vh;overflow-y:auto}.action-result-row[data-v-10832b55]{border:var(--fg2) 1px solid;border-radius:4px;padding:12px 14px}.action-result-meta[data-v-10832b55]{font-size:12px;color:var(--fg2);margin-bottom:6px}.action-result-payload[data-v-10832b55]{margin:0;font-family:Fira Code,SFMono-Regular,Consolas,monospace;font-size:13px;white-space:pre-wrap;word-break:break-word}.expand-section[data-v-1b700a1c]{padding:10px 20px;border-top:var(--k-status-divider, var(--k-color-divider-dark)) 1px solid}.expand-section[data-v-1b700a1c]:first-of-type{border-top:none}.expand-title[data-v-1b700a1c]{margin:4px 0;font-size:14px;font-weight:600;text-transform:uppercase;letter-spacing:.05em}.expand-header[data-v-1b700a1c]{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:8px}.expand-actions[data-v-1b700a1c]{display:flex;gap:8px}.section-empty[data-v-1b700a1c]{margin:10px 0 0;color:var(--fg2);font-size:13px}.metrics-container[data-v-1b700a1c]{display:flex;flex-wrap:wrap;gap:10px}.metric-card[data-v-1b700a1c]{border:var(--fg3) 1px solid;border-radius:4px;padding:10px;flex:1 1 150px;box-sizing:border-box;text-align:center;max-width:200px}.metric-name[data-v-1b700a1c]{font-size:12px;color:var(--fg2)}.metric-value[data-v-1b700a1c]{font-size:16px;font-weight:700;display:flex;justify-content:center;gap:4px}.metric-unit[data-v-1b700a1c]{font-size:16px;color:var(--fg2)}.actions-container[data-v-1b700a1c]{display:flex;flex-wrap:wrap;gap:8px}[data-v-1b700a1c] .actions-container .el-button+.el-button{margin-left:0}.action-chip[data-v-1b700a1c]{border:var(--fg3) 1px solid;display:inline-flex;align-items:center;gap:6px}.action-name[data-v-1b700a1c]{font-weight:600;margin-right:6px}.status-cell[data-v-1b700a1c]{display:flex;align-items:center;gap:8px}.status-badges[data-v-1b700a1c]{display:inline-flex;align-items:center;gap:4px}.status-badge[data-v-1b700a1c]{display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;border:var(--fg4, var(--k-color-border)) 1px solid;border-radius:999px;font-size:14px;color:var(--fg2)}.status-badge.auto[data-v-1b700a1c],.status-badge.cron[data-v-1b700a1c]{color:var(--k-color-success, var(--k-color-primary));border-color:currentColor}.alert-row-actions[data-v-1b700a1c]{display:inline-flex;align-items:center;justify-content:center;flex-wrap:wrap;gap:6px;width:100%}.alert-row-actions[data-v-1b700a1c] .el-button{min-width:32px;padding:4px 6px}.alert-table[data-v-1b700a1c]{width:100%;margin-bottom:8px}.alert-message[data-v-1b700a1c]{display:inline-block;max-width:100%;white-space:pre-wrap;word-break:break-word}.alert-message.placeholder[data-v-1b700a1c]{color:var(--fg2);font-style:italic}.log-view[data-v-1b700a1c]{padding:1rem;max-height:60vh;overflow-y:auto;white-space:pre-wrap;word-break:break-all}.process-scroll[data-v-1b700a1c] .el-scrollbar__wrap{overflow-x:hidden}.el-button--danger[data-v-1b700a1c]{--el-button-hover-text-color: var(--k-color-danger);--el-button-hover-border-color: var(--k-color-danger)}
|
package/lib/api.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare namespace LogUtils {
|
|
2
|
+
interface AppEntry {
|
|
3
|
+
app_name: string;
|
|
4
|
+
path: string;
|
|
5
|
+
type: 'out' | 'err' | 'PM2';
|
|
6
|
+
}
|
|
7
|
+
function format(entry: AppEntry, line: string): string;
|
|
8
|
+
function tail(entries: AppEntry[], lines: number, raw: boolean): Promise<string[]>;
|
|
9
|
+
}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { Context, Schema, Service } from 'koishi';
|
|
2
|
+
import EventEmitter from 'events';
|
|
3
|
+
import API from 'pm2/lib/API';
|
|
4
|
+
import { LogUtils } from './api';
|
|
5
|
+
declare module '@koishijs/console' {
|
|
6
|
+
interface Events {
|
|
7
|
+
'pm2/list'(): Promise<PM2.Process[]>;
|
|
8
|
+
'pm2/action'(id: number | string, action: string): Promise<void>;
|
|
9
|
+
'pm2/trigger-action'(id: number | string, action: string): Promise<PM2.MonitorActionResult[]>;
|
|
10
|
+
'pm2/start-log'(id: number | string): Promise<string[]>;
|
|
11
|
+
'pm2/stop-log'(id: number | string): Promise<void>;
|
|
12
|
+
'pm2/add-alert'(alert: PM2.Alert): Promise<void>;
|
|
13
|
+
'pm2/edit-alert'(original: PM2.Alert, alert: PM2.Alert): Promise<void>;
|
|
14
|
+
'pm2/test-alert'(alert: PM2.Alert): Promise<void>;
|
|
15
|
+
'pm2/remove-alert'(alert: PM2.Alert): Promise<void>;
|
|
16
|
+
'pm2/clear-alerts'(name: string, events?: string[]): Promise<void>;
|
|
17
|
+
'pm2/patch-log'(id: number | string, logs: string[]): void;
|
|
18
|
+
}
|
|
19
|
+
interface Client {
|
|
20
|
+
pm2?: {
|
|
21
|
+
lastHeartbeat?: number;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
declare module 'koishi' {
|
|
26
|
+
interface Context {
|
|
27
|
+
pm2: PM2;
|
|
28
|
+
}
|
|
29
|
+
interface Events {
|
|
30
|
+
'pm2/process-event'(event: string, env: PM2.Env, manually: boolean): void;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
declare class LogManager {
|
|
34
|
+
protected ctx: Context;
|
|
35
|
+
protected pm2: PM2;
|
|
36
|
+
private buffers;
|
|
37
|
+
private listeners;
|
|
38
|
+
private broadcasters;
|
|
39
|
+
constructor(ctx: Context, pm2: PM2);
|
|
40
|
+
init(): Promise<void>;
|
|
41
|
+
pushEntry(entries: LogUtils.AppEntry[], entry: LogUtils.AppEntry): void;
|
|
42
|
+
start(id: number | string, cid: string, exclusive?: 'out' | 'err'): Promise<string[]>;
|
|
43
|
+
stop(id: number | string, cid: string): void;
|
|
44
|
+
stopAll(cid: string): void;
|
|
45
|
+
}
|
|
46
|
+
export declare class PM2 extends Service {
|
|
47
|
+
protected ctx: Context;
|
|
48
|
+
config: PM2.Config;
|
|
49
|
+
static name: string;
|
|
50
|
+
api: API;
|
|
51
|
+
bus: EventEmitter | null;
|
|
52
|
+
logs: LogManager;
|
|
53
|
+
list: () => Promise<PM2.Process[]>;
|
|
54
|
+
trigger: (id: number | string, actionName: string) => Promise<PM2.MonitorActionResult[]>;
|
|
55
|
+
constructor(ctx: Context, config: PM2.Config);
|
|
56
|
+
_list(): Promise<PM2.Process[]>;
|
|
57
|
+
_trigger(id: number | string, actionName: string): Promise<any[]>;
|
|
58
|
+
alert(alert: PM2.Alert, env: PM2.Env & {
|
|
59
|
+
event: string;
|
|
60
|
+
manually: boolean;
|
|
61
|
+
}): Promise<string[]>;
|
|
62
|
+
}
|
|
63
|
+
export declare namespace PM2 {
|
|
64
|
+
const inject: {
|
|
65
|
+
required: string[];
|
|
66
|
+
optional: string[];
|
|
67
|
+
};
|
|
68
|
+
interface Alert {
|
|
69
|
+
name: string;
|
|
70
|
+
event: 'restart' | 'delete' | 'stop' | 'reload' | 'graceful reload' | 'start' | 'exit' | 'online' | 'restart overlimit' | {
|
|
71
|
+
type: 'exit';
|
|
72
|
+
eq?: number;
|
|
73
|
+
neq?: number;
|
|
74
|
+
};
|
|
75
|
+
sid?: string;
|
|
76
|
+
cid: string;
|
|
77
|
+
message?: string;
|
|
78
|
+
}
|
|
79
|
+
interface Config {
|
|
80
|
+
alerts: Alert[];
|
|
81
|
+
logSyncInterval: number;
|
|
82
|
+
listSyncInterval: number;
|
|
83
|
+
actionTimeout: number;
|
|
84
|
+
logTailLines: number;
|
|
85
|
+
}
|
|
86
|
+
const Config: Schema<Config>;
|
|
87
|
+
interface Env {
|
|
88
|
+
/** Process name */
|
|
89
|
+
name: string;
|
|
90
|
+
/** Namespace */
|
|
91
|
+
namespace?: string;
|
|
92
|
+
/** Process ID */
|
|
93
|
+
pm_id: number;
|
|
94
|
+
/** Process status */
|
|
95
|
+
status: string;
|
|
96
|
+
/** Restart time */
|
|
97
|
+
restart_time: number;
|
|
98
|
+
/** Execution path */
|
|
99
|
+
pm_exec_path?: string;
|
|
100
|
+
/** Cron restart pattern */
|
|
101
|
+
cron_restart?: string;
|
|
102
|
+
/** Wait for ready signal */
|
|
103
|
+
wait_ready?: boolean;
|
|
104
|
+
/** last uptime */
|
|
105
|
+
pm_uptime?: number;
|
|
106
|
+
/** AXM monitor data */
|
|
107
|
+
axm_monitor?: {
|
|
108
|
+
[key: string]: {
|
|
109
|
+
type: string;
|
|
110
|
+
value: number | string;
|
|
111
|
+
unit?: string;
|
|
112
|
+
historic?: boolean;
|
|
113
|
+
[key: string]: any;
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
/** AXM actions */
|
|
117
|
+
axm_actions?: {
|
|
118
|
+
[key: string]: {
|
|
119
|
+
action_name: string;
|
|
120
|
+
action_type: string;
|
|
121
|
+
arity?: number;
|
|
122
|
+
[key: string]: any;
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
[key: string]: any;
|
|
126
|
+
}
|
|
127
|
+
interface Process {
|
|
128
|
+
/** Process ID */
|
|
129
|
+
pm_id: number;
|
|
130
|
+
/** Process name */
|
|
131
|
+
name: string;
|
|
132
|
+
/** Process namespace */
|
|
133
|
+
namespace?: string;
|
|
134
|
+
/** PM2 environment */
|
|
135
|
+
pm2_env: Env & {
|
|
136
|
+
/** Environment variables */
|
|
137
|
+
env?: {
|
|
138
|
+
[key: string]: any;
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
/** Process PID */
|
|
142
|
+
pid?: number;
|
|
143
|
+
/** CPU usage */
|
|
144
|
+
monit?: {
|
|
145
|
+
cpu: number;
|
|
146
|
+
memory: number;
|
|
147
|
+
};
|
|
148
|
+
alerts?: Alert[];
|
|
149
|
+
}
|
|
150
|
+
interface MonitorActionResult {
|
|
151
|
+
process: {
|
|
152
|
+
name?: string;
|
|
153
|
+
pm_id?: number;
|
|
154
|
+
namespace?: string;
|
|
155
|
+
};
|
|
156
|
+
data?: {
|
|
157
|
+
return?: string | any;
|
|
158
|
+
action_name?: string;
|
|
159
|
+
at?: number;
|
|
160
|
+
};
|
|
161
|
+
at: number;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
export default PM2;
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,496 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
PM2: () => PM2,
|
|
34
|
+
default: () => index_default
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(index_exports);
|
|
37
|
+
var import_koishi = require("koishi");
|
|
38
|
+
var import_path = require("path");
|
|
39
|
+
var import_API = __toESM(require("pm2/lib/API"));
|
|
40
|
+
|
|
41
|
+
// src/api.ts
|
|
42
|
+
var import_kleur = __toESM(require("kleur"));
|
|
43
|
+
var import_fs = __toESM(require("fs"));
|
|
44
|
+
var DEFAULT_PADDING = " ";
|
|
45
|
+
function pad(pad2, str, padLeft) {
|
|
46
|
+
if (typeof str === "undefined") return pad2;
|
|
47
|
+
if (padLeft) {
|
|
48
|
+
return (pad2 + str).slice(-pad2.length);
|
|
49
|
+
} else {
|
|
50
|
+
return (str + pad2).substring(0, pad2.length);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
__name(pad, "pad");
|
|
54
|
+
var LogUtils;
|
|
55
|
+
((LogUtils2) => {
|
|
56
|
+
function format(entry, line) {
|
|
57
|
+
let header = "";
|
|
58
|
+
if (entry.type === "out") {
|
|
59
|
+
header = import_kleur.default.green(pad(DEFAULT_PADDING, entry.app_name) + " | ");
|
|
60
|
+
} else if (entry.type === "err") {
|
|
61
|
+
header = import_kleur.default.red(pad(DEFAULT_PADDING, entry.app_name) + " | ");
|
|
62
|
+
} else {
|
|
63
|
+
header = import_kleur.default.cyan(pad(DEFAULT_PADDING, "PM2") + " | ");
|
|
64
|
+
}
|
|
65
|
+
return header + line;
|
|
66
|
+
}
|
|
67
|
+
LogUtils2.format = format;
|
|
68
|
+
__name(format, "format");
|
|
69
|
+
async function tail(entries, lines, raw) {
|
|
70
|
+
if (lines === 0 || entries.length === 0) return [];
|
|
71
|
+
const getLastLines = /* @__PURE__ */ __name(async function(filename, lines2) {
|
|
72
|
+
return new Promise(function(resolve2) {
|
|
73
|
+
let chunk = "";
|
|
74
|
+
const size = Math.max(0, import_fs.default.statSync(filename).size - lines2 * 200);
|
|
75
|
+
const fd = import_fs.default.createReadStream(filename, { start: size });
|
|
76
|
+
fd.on("data", function(data) {
|
|
77
|
+
chunk += data.toString();
|
|
78
|
+
});
|
|
79
|
+
fd.on("end", function() {
|
|
80
|
+
const chunks = chunk.split("\n").slice(-(lines2 + 1));
|
|
81
|
+
chunks.pop();
|
|
82
|
+
resolve2(chunks);
|
|
83
|
+
});
|
|
84
|
+
fd.on("error", function() {
|
|
85
|
+
resolve2([]);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
}, "getLastLines");
|
|
89
|
+
entries.sort(function(a, b) {
|
|
90
|
+
return (import_fs.default.existsSync(a.path) ? import_fs.default.statSync(a.path).mtime.valueOf() : 0) - (import_fs.default.existsSync(b.path) ? import_fs.default.statSync(b.path).mtime.valueOf() : 0);
|
|
91
|
+
});
|
|
92
|
+
const output = [];
|
|
93
|
+
for (const app of entries) {
|
|
94
|
+
if (!import_fs.default.existsSync(app.path || "")) continue;
|
|
95
|
+
const lastLines = await getLastLines(app.path, lines);
|
|
96
|
+
lastLines.forEach((line) => output.push(raw ? line : format(app, line)));
|
|
97
|
+
if (lastLines.length) output.push("");
|
|
98
|
+
}
|
|
99
|
+
return output;
|
|
100
|
+
}
|
|
101
|
+
LogUtils2.tail = tail;
|
|
102
|
+
__name(tail, "tail");
|
|
103
|
+
})(LogUtils || (LogUtils = {}));
|
|
104
|
+
|
|
105
|
+
// src/utils.ts
|
|
106
|
+
function noop() {
|
|
107
|
+
}
|
|
108
|
+
__name(noop, "noop");
|
|
109
|
+
var Lock = class {
|
|
110
|
+
static {
|
|
111
|
+
__name(this, "Lock");
|
|
112
|
+
}
|
|
113
|
+
tip;
|
|
114
|
+
constructor() {
|
|
115
|
+
this.tip = Promise.resolve(void 0);
|
|
116
|
+
}
|
|
117
|
+
async acquire() {
|
|
118
|
+
const oldTip = this.tip;
|
|
119
|
+
let resolver = noop;
|
|
120
|
+
const promise = new Promise((resolve2) => {
|
|
121
|
+
resolver = resolve2;
|
|
122
|
+
});
|
|
123
|
+
this.tip = oldTip.then(() => promise);
|
|
124
|
+
return oldTip.then(() => resolver);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
function serialized(ctx, callback) {
|
|
128
|
+
const lock = new Lock();
|
|
129
|
+
const wrapper = /* @__PURE__ */ __name(async (...args) => {
|
|
130
|
+
const release = await lock.acquire();
|
|
131
|
+
ctx.scope.assertActive();
|
|
132
|
+
try {
|
|
133
|
+
return await callback(...args);
|
|
134
|
+
} finally {
|
|
135
|
+
release();
|
|
136
|
+
}
|
|
137
|
+
}, "wrapper");
|
|
138
|
+
return wrapper;
|
|
139
|
+
}
|
|
140
|
+
__name(serialized, "serialized");
|
|
141
|
+
function throttle(ctx, callback, delay, noTrailing) {
|
|
142
|
+
const inner = ctx.throttle(((...args) => {
|
|
143
|
+
inner.result = callback(...args);
|
|
144
|
+
}), delay, noTrailing);
|
|
145
|
+
const wrapper = /* @__PURE__ */ __name((...args) => {
|
|
146
|
+
inner(...args);
|
|
147
|
+
return inner.result;
|
|
148
|
+
}, "wrapper");
|
|
149
|
+
return wrapper;
|
|
150
|
+
}
|
|
151
|
+
__name(throttle, "throttle");
|
|
152
|
+
function parsePlatform(target) {
|
|
153
|
+
const index = target.indexOf(":");
|
|
154
|
+
const platform = target.slice(0, index);
|
|
155
|
+
const id = target.slice(index + 1);
|
|
156
|
+
return [platform, id];
|
|
157
|
+
}
|
|
158
|
+
__name(parsePlatform, "parsePlatform");
|
|
159
|
+
|
|
160
|
+
// src/locales/en-US.yml
|
|
161
|
+
var en_US_default = { pm2: { alerts: { restart: "[PM2] Process {name} restarted.", delete: "[PM2] Process {name} deleted.", stop: "[PM2] Process {name} stopped.", reload: "[PM2] Process {name} reloaded.", "graceful reload": "[PM2] Process {name} gracefully reloaded.", start: "[PM2] Process {name} started.", exit: "[PM2] Process {name} exited.", online: "[PM2] Process {name} is online.", "restart-overlimit": "[PM2] Process {name} reached restart overlimit." } }, commands: { "pm2.list": { description: "Display the list of PM2 processes.", messages: { output: "- PM2 Process List\n{context.map(proc => '[' + String(proc.pm_id) + '] ' + proc.name + ' ' + proc.pm2_env.status + (proc.pm2_env.status === 'online' ? ' ' + String(Math.floor((Date.now() - proc.pm2_env.pm_uptime) / 1000 / 60 / 60 / 24)) + 'd' : '')).join('\\n')}\n" } }, "pm2.start": { description: "Start a PM2 process by id or name.", messages: { output: "Process {name} started.", "not-found": "Process {id} not found." } }, "pm2.restart": { description: "Restart a PM2 process by id or name.", messages: { output: "Process {name} restarted.", "not-found": "Process {id} not found." } }, "pm2.reload": { description: "Reload a PM2 process by id or name.", messages: { output: "Process {name} reloaded.", "not-found": "Process {id} not found." } }, "pm2.stop": { description: "Stop a PM2 process by id or name.", messages: { output: "Process {name} stopped.", "not-found": "Process {id} not found." } }, "pm2.delete": { description: "Delete a PM2 process by id or name.", messages: { output: "Process {name} deleted.", "not-found": "Process {id} not found." } } } };
|
|
162
|
+
|
|
163
|
+
// src/index.ts
|
|
164
|
+
var LogManager = class {
|
|
165
|
+
constructor(ctx, pm2) {
|
|
166
|
+
this.ctx = ctx;
|
|
167
|
+
this.pm2 = pm2;
|
|
168
|
+
}
|
|
169
|
+
static {
|
|
170
|
+
__name(this, "LogManager");
|
|
171
|
+
}
|
|
172
|
+
buffers = {};
|
|
173
|
+
listeners = {};
|
|
174
|
+
broadcasters = {};
|
|
175
|
+
async init() {
|
|
176
|
+
const onLog = /* @__PURE__ */ __name((packet, type) => {
|
|
177
|
+
const id = packet.process.pm_id ?? "PM2";
|
|
178
|
+
if (!this.listeners[id]) return;
|
|
179
|
+
const data = packet.data.replace(/\n$/, "");
|
|
180
|
+
this.buffers[id].push(LogUtils.format({
|
|
181
|
+
app_name: packet.process.pm_id + "|" + packet.process.name,
|
|
182
|
+
type,
|
|
183
|
+
path: ""
|
|
184
|
+
}, data));
|
|
185
|
+
this.broadcasters[id]();
|
|
186
|
+
}, "onLog");
|
|
187
|
+
this.pm2.bus.on("log:out", (packet) => onLog(packet, "out"));
|
|
188
|
+
this.pm2.bus.on("log:err", (packet) => onLog(packet, "err"));
|
|
189
|
+
this.pm2.bus.on("log:PM2", (packet) => onLog(packet, "PM2"));
|
|
190
|
+
}
|
|
191
|
+
pushEntry(entries, entry) {
|
|
192
|
+
if (entry.path.toLowerCase && entry.path.toLowerCase() !== "/dev/null") {
|
|
193
|
+
if (entries.find((file) => file.path === entry.path)) return;
|
|
194
|
+
entries.push(entry);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
async start(id, cid, exclusive) {
|
|
198
|
+
this.listeners[id] ||= /* @__PURE__ */ new Set();
|
|
199
|
+
if (!this.listeners[id].size) {
|
|
200
|
+
this.buffers[id] = [];
|
|
201
|
+
this.broadcasters[id] = this.ctx.throttle(() => {
|
|
202
|
+
if (!this.buffers[id].length) return;
|
|
203
|
+
const buffer = this.buffers[id].splice(0);
|
|
204
|
+
const toRemoved = [];
|
|
205
|
+
Object.values(this.ctx.console.clients).filter((client) => this.listeners[id].has(client.id)).forEach((client) => {
|
|
206
|
+
if (client.pm2?.lastHeartbeat && Date.now() - client.pm2.lastHeartbeat > 3e4) {
|
|
207
|
+
toRemoved.push(client.id);
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
client.send({
|
|
211
|
+
type: "pm2/patch-log",
|
|
212
|
+
body: [id, buffer]
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
toRemoved.forEach((cid2) => this.stopAll(cid2));
|
|
216
|
+
}, 200);
|
|
217
|
+
}
|
|
218
|
+
this.listeners[id].add(cid);
|
|
219
|
+
if (this.pm2.config.logTailLines) {
|
|
220
|
+
const entries = [];
|
|
221
|
+
if (id === "PM2" || id === "pm2") {
|
|
222
|
+
this.pushEntry(entries, {
|
|
223
|
+
path: this.pm2.api.pm2_home + "/pm2.log",
|
|
224
|
+
app_name: "PM2",
|
|
225
|
+
type: "PM2"
|
|
226
|
+
});
|
|
227
|
+
} else {
|
|
228
|
+
const procs = await new Promise((resolve2, reject) => {
|
|
229
|
+
this.pm2.api.describe(id, (err, desc) => {
|
|
230
|
+
if (err) return reject(err);
|
|
231
|
+
resolve2(desc);
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
for (const proc of procs) {
|
|
235
|
+
if (proc.pm2_env && (id === "all" || proc.pm2_env.name === id || proc.pm2_env.pm_id === id)) {
|
|
236
|
+
if (proc.pm2_env.pm_out_log_path && exclusive !== "err") {
|
|
237
|
+
this.pushEntry(entries, {
|
|
238
|
+
path: proc.pm2_env.pm_out_log_path,
|
|
239
|
+
app_name: proc.pm2_env.pm_id + "|" + proc.pm2_env.name,
|
|
240
|
+
type: "out"
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
if (proc.pm2_env.pm_err_log_path && exclusive !== "out") {
|
|
244
|
+
this.pushEntry(entries, {
|
|
245
|
+
path: proc.pm2_env.pm_err_log_path,
|
|
246
|
+
app_name: proc.pm2_env.pm_id + "|" + proc.pm2_env.name,
|
|
247
|
+
type: "err"
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
return await LogUtils.tail(entries, this.pm2.config.logTailLines, false);
|
|
254
|
+
} else {
|
|
255
|
+
return [];
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
stop(id, cid) {
|
|
259
|
+
this.listeners[id]?.delete(cid);
|
|
260
|
+
if (this.listeners[id]?.size === 0) {
|
|
261
|
+
delete this.listeners[id];
|
|
262
|
+
delete this.buffers[id];
|
|
263
|
+
delete this.broadcasters[id];
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
stopAll(cid) {
|
|
267
|
+
for (const id in this.listeners) {
|
|
268
|
+
this.stop(Number(id), cid);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
var PM2 = class extends import_koishi.Service {
|
|
273
|
+
constructor(ctx, config) {
|
|
274
|
+
super(ctx, "pm2");
|
|
275
|
+
this.ctx = ctx;
|
|
276
|
+
this.config = config;
|
|
277
|
+
ctx.i18n.define("en-US", en_US_default);
|
|
278
|
+
this.api = new import_API.default();
|
|
279
|
+
this.logs = new LogManager(ctx, this);
|
|
280
|
+
this.list = throttle(ctx, this._list.bind(this), 1e3);
|
|
281
|
+
this.trigger = serialized(ctx, this._trigger.bind(this));
|
|
282
|
+
const that = this;
|
|
283
|
+
ctx.console.addEntry({
|
|
284
|
+
dev: (0, import_path.resolve)(__dirname, "../client/index.ts"),
|
|
285
|
+
prod: (0, import_path.resolve)(__dirname, "../dist")
|
|
286
|
+
});
|
|
287
|
+
ctx.on("ready", async () => {
|
|
288
|
+
try {
|
|
289
|
+
await new Promise((resolve2, reject) => {
|
|
290
|
+
this.api.connect((err) => {
|
|
291
|
+
if (err) return reject(err);
|
|
292
|
+
resolve2();
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
this.bus = await new Promise((resolve2, reject) => {
|
|
296
|
+
this.api.launchBus((err, bus) => {
|
|
297
|
+
if (err) return reject(err);
|
|
298
|
+
resolve2(bus);
|
|
299
|
+
});
|
|
300
|
+
});
|
|
301
|
+
await that.logs.init();
|
|
302
|
+
this.bus.on("process:event", (packet) => {
|
|
303
|
+
this.ctx.emit(packet, "pm2/process-event", packet.event, packet.process, packet.manually);
|
|
304
|
+
});
|
|
305
|
+
ctx.logger.info("connected to pm2");
|
|
306
|
+
} catch (err) {
|
|
307
|
+
ctx.logger.warn("failed to connect to pm2:", err);
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
ctx.on("dispose", () => this.api.close());
|
|
311
|
+
ctx.on("pm2/process-event", async (event, env, manually) => {
|
|
312
|
+
for (const alert of this.config.alerts) {
|
|
313
|
+
if ((alert.name === env.name || alert.name === "*") && (alert.event["type"] ?? alert.event) === event) {
|
|
314
|
+
if (event === "exit" && typeof alert.event === "object") {
|
|
315
|
+
if (!(0, import_koishi.isNullable)(alert.event.eq) && env.exit_code !== alert.event.eq) continue;
|
|
316
|
+
if (!(0, import_koishi.isNullable)(alert.event.neq) && env.exit_code === alert.event.neq) continue;
|
|
317
|
+
}
|
|
318
|
+
this.alert(alert, { ...env, event, manually }).catch((err) => {
|
|
319
|
+
ctx.logger.warn("failed to deliver pm2 alert:", err);
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
const addListener = /* @__PURE__ */ __name((event, callback, options) => {
|
|
325
|
+
return ctx.console.addListener(event, callback, { authority: options?.authority ?? 4 });
|
|
326
|
+
}, "addListener");
|
|
327
|
+
addListener("pm2/list", async function() {
|
|
328
|
+
;
|
|
329
|
+
(this.pm2 ??= {}).lastHeartbeat = Date.now();
|
|
330
|
+
return that.list().then((list) => list.map((proc) => {
|
|
331
|
+
delete proc.pm2_env.env;
|
|
332
|
+
proc.alerts = (that.config.alerts || []).filter((alert) => alert.name === proc.name || alert.name === "*");
|
|
333
|
+
return proc;
|
|
334
|
+
}));
|
|
335
|
+
});
|
|
336
|
+
addListener("pm2/action", (id, action) => {
|
|
337
|
+
return new Promise((resolve2, reject) => {
|
|
338
|
+
const target = ["restart", "reload", "stop", "delete", "reset"];
|
|
339
|
+
if (!target.includes(action)) return reject(new Error(`Unsupported action: ${action}`));
|
|
340
|
+
that.api[action](id, (err) => {
|
|
341
|
+
if (err) return reject(err);
|
|
342
|
+
resolve2();
|
|
343
|
+
});
|
|
344
|
+
});
|
|
345
|
+
});
|
|
346
|
+
addListener("pm2/trigger-action", (id, actionName) => this.trigger(id, actionName));
|
|
347
|
+
addListener("pm2/start-log", async function(id) {
|
|
348
|
+
return that.logs.start(id, this.id);
|
|
349
|
+
});
|
|
350
|
+
addListener("pm2/stop-log", async function(id) {
|
|
351
|
+
return that.logs.stop(id, this.id);
|
|
352
|
+
});
|
|
353
|
+
addListener("pm2/add-alert", async (alert) => {
|
|
354
|
+
that.config.alerts.push(alert);
|
|
355
|
+
that.ctx.scope.update(that.config, false);
|
|
356
|
+
});
|
|
357
|
+
addListener("pm2/edit-alert", async (original, alert) => {
|
|
358
|
+
const index = that.config.alerts.findIndex((item) => (0, import_koishi.deepEqual)((0, import_koishi.omit)(item, ["message"]), (0, import_koishi.omit)(original, ["message"])));
|
|
359
|
+
if (index === -1) return;
|
|
360
|
+
that.config.alerts[index] = alert;
|
|
361
|
+
that.ctx.scope.update(that.config, false);
|
|
362
|
+
});
|
|
363
|
+
addListener("pm2/test-alert", async (alert) => {
|
|
364
|
+
const proc = await that.list().then((procs) => procs.find((p) => p.name === alert.name || alert.name === "*"));
|
|
365
|
+
await that.alert(alert, { ...proc.pm2_env, event: alert.event["type"] ?? alert.event, manually: true });
|
|
366
|
+
});
|
|
367
|
+
addListener("pm2/remove-alert", async (alert) => {
|
|
368
|
+
if (!alert?.name) return;
|
|
369
|
+
that.config.alerts = that.config.alerts.filter((item) => !(0, import_koishi.deepEqual)((0, import_koishi.omit)(item, ["message"]), (0, import_koishi.omit)(alert, ["message"])));
|
|
370
|
+
that.ctx.scope.update(that.config, false);
|
|
371
|
+
});
|
|
372
|
+
addListener("pm2/clear-alerts", async (name, events) => {
|
|
373
|
+
if (!name) return;
|
|
374
|
+
that.config.alerts = that.config.alerts.filter((item) => {
|
|
375
|
+
if (item.name !== name) return true;
|
|
376
|
+
if (events && !events.includes(item.event["type"] ?? item.event)) return true;
|
|
377
|
+
return false;
|
|
378
|
+
});
|
|
379
|
+
that.ctx.scope.update(that.config, false);
|
|
380
|
+
});
|
|
381
|
+
ctx.on("console/connection", (client) => {
|
|
382
|
+
if (!(client.id in ctx.console.clients)) {
|
|
383
|
+
that.logs.stopAll(client.id);
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
ctx.command("pm2", { authority: 4 });
|
|
387
|
+
ctx.command("pm2.list").action(async ({ session }) => {
|
|
388
|
+
const list = await that.list();
|
|
389
|
+
return session.text(".output", list);
|
|
390
|
+
});
|
|
391
|
+
for (const action of ["start", "restart", "reload", "stop", "delete"]) {
|
|
392
|
+
ctx.command(`pm2.${action} <id>`).action(async ({ session }, id) => {
|
|
393
|
+
const procs = await new Promise((resolve2, reject) => {
|
|
394
|
+
that.api[action](id, (err, res) => {
|
|
395
|
+
if (err) return reject(err);
|
|
396
|
+
resolve2(res);
|
|
397
|
+
});
|
|
398
|
+
});
|
|
399
|
+
if (procs.length) {
|
|
400
|
+
return session.text(".output", procs[0]);
|
|
401
|
+
} else {
|
|
402
|
+
return session.text(".not-found", { id });
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
static name = "pm2";
|
|
408
|
+
api;
|
|
409
|
+
bus = null;
|
|
410
|
+
logs;
|
|
411
|
+
list;
|
|
412
|
+
trigger;
|
|
413
|
+
async _list() {
|
|
414
|
+
return await new Promise((resolve2, reject) => {
|
|
415
|
+
this.api.list((err, list) => {
|
|
416
|
+
if (err) return reject(err);
|
|
417
|
+
resolve2(list);
|
|
418
|
+
});
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
async _trigger(id, actionName) {
|
|
422
|
+
return new Promise((resolve2, reject) => {
|
|
423
|
+
let counter = 0, processCount = 0, timeout = null;
|
|
424
|
+
const results = [];
|
|
425
|
+
const listener = /* @__PURE__ */ __name((ret) => {
|
|
426
|
+
if (ret.process.name === id || ret.process.pm_id === id || ret.process.namespace === id || id === "all") {
|
|
427
|
+
results.push(ret);
|
|
428
|
+
if (++counter === processCount) {
|
|
429
|
+
this.bus.off("axm:reply", listener);
|
|
430
|
+
timeout?.();
|
|
431
|
+
resolve2(results);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
}, "listener");
|
|
435
|
+
this.bus.on("axm:reply", listener);
|
|
436
|
+
timeout = this.ctx.setTimeout(() => {
|
|
437
|
+
this.bus.off("axm:reply", listener);
|
|
438
|
+
reject(new Error(`PM2 action "${actionName}" timed out.`));
|
|
439
|
+
}, this.config.actionTimeout);
|
|
440
|
+
this.api.Client.executeRemote("msgProcess", {
|
|
441
|
+
msg: actionName,
|
|
442
|
+
...isNaN(id) ? { name: id } : { id }
|
|
443
|
+
}, function(err, data) {
|
|
444
|
+
if (err) return reject(err);
|
|
445
|
+
if (!data?.process_count) reject(new Error("No process received command."));
|
|
446
|
+
processCount = data.process_count;
|
|
447
|
+
});
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
async alert(alert, env) {
|
|
451
|
+
const [platform, channelId] = parsePlatform(alert.cid);
|
|
452
|
+
const bot = this.ctx.bots[alert.sid] ?? this.ctx.bots.find((bot2) => bot2.platform === platform);
|
|
453
|
+
if (!bot) {
|
|
454
|
+
this.ctx.logger.warn(`Cannot find bot for PM2 alert: ${alert.name}/${alert.event["type"] ?? alert.event} to ${alert.cid}`);
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
if (alert.message) {
|
|
458
|
+
return bot.sendMessage(channelId, import_koishi.h.parse(alert.message, env));
|
|
459
|
+
} else {
|
|
460
|
+
const locales = [];
|
|
461
|
+
if (this.ctx.get("database")) {
|
|
462
|
+
locales.push(...await this.ctx.get("database").getChannel(platform, channelId, ["locales"]).then((channel) => channel?.locales ?? []));
|
|
463
|
+
}
|
|
464
|
+
const message = this.ctx.i18n.render(locales, [`pm2.alerts.${alert.event["type"] ?? alert.event}`], env);
|
|
465
|
+
return bot.sendMessage(channelId, message);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
|
+
((PM22) => {
|
|
470
|
+
PM22.inject = {
|
|
471
|
+
required: ["console"],
|
|
472
|
+
optional: ["database", "console.services.status"]
|
|
473
|
+
};
|
|
474
|
+
PM22.Config = import_koishi.Schema.object({
|
|
475
|
+
alerts: import_koishi.Schema.array(import_koishi.Schema.object({
|
|
476
|
+
name: import_koishi.Schema.string().description("The name of the process. Use `*` to match all processes."),
|
|
477
|
+
event: import_koishi.Schema.union(["restart", "delete", "stop", "reload", "graceful reload", "start", "exit", "online", "restart overlimit", import_koishi.Schema.object({
|
|
478
|
+
type: import_koishi.Schema.const("exit").default("exit").hidden(),
|
|
479
|
+
eq: import_koishi.Schema.number().required(false),
|
|
480
|
+
neq: import_koishi.Schema.number().required(false)
|
|
481
|
+
}).description("exit(code)")]).description("The type of process:event."),
|
|
482
|
+
sid: import_koishi.Schema.string().description("platform:selfId").required(false),
|
|
483
|
+
cid: import_koishi.Schema.string().description("platform:channelId"),
|
|
484
|
+
message: import_koishi.Schema.string().description("The custom i18n message to send with the notification.").required(false)
|
|
485
|
+
})).description("PM2 process event notifications.").default([]).hidden(),
|
|
486
|
+
logSyncInterval: import_koishi.Schema.number().description("The interval (in milliseconds) to sync logs from PM2.").default(200),
|
|
487
|
+
listSyncInterval: import_koishi.Schema.number().description("The interval (in milliseconds) to sync process list from PM2.").default(1e3),
|
|
488
|
+
actionTimeout: import_koishi.Schema.number().description("The timeout (in milliseconds) for PM2 monitor actions.").default(1e4),
|
|
489
|
+
logTailLines: import_koishi.Schema.number().description("The number of log lines to tail when starting log streaming.").default(100)
|
|
490
|
+
});
|
|
491
|
+
})(PM2 || (PM2 = {}));
|
|
492
|
+
var index_default = PM2;
|
|
493
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
494
|
+
0 && (module.exports = {
|
|
495
|
+
PM2
|
|
496
|
+
});
|
package/lib/utils.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Context } from 'koishi';
|
|
2
|
+
export declare class Resolver<T> {
|
|
3
|
+
readonly promise: Promise<T>;
|
|
4
|
+
private resolver;
|
|
5
|
+
private rejecter;
|
|
6
|
+
constructor();
|
|
7
|
+
get resolve(): (result?: T | PromiseLike<T>) => void;
|
|
8
|
+
get reject(): (reason: any | PromiseLike<any>) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare class Lock {
|
|
11
|
+
private tip;
|
|
12
|
+
constructor();
|
|
13
|
+
acquire(): Promise<() => void>;
|
|
14
|
+
}
|
|
15
|
+
export declare function serialized<T, F extends (...args: any[]) => Promise<T>>(ctx: Context, callback: F): F;
|
|
16
|
+
export declare function throttle<T, F extends (...args: any[]) => Promise<T>>(ctx: Context, callback: F, delay: number, noTrailing?: boolean): F;
|
|
17
|
+
export declare function parsePlatform(target: string): [platform: string, id: string];
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "koishi-plugin-pm2",
|
|
3
|
+
"description": "PM2 process manager dashboard",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"typings": "lib/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"lib",
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"author": "Hieuzest <girkirin@hotmail.com>",
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"keywords": [
|
|
14
|
+
"chatbot",
|
|
15
|
+
"koishi",
|
|
16
|
+
"plugin",
|
|
17
|
+
"pm2"
|
|
18
|
+
],
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/koikirin/koishi-plugin-pm2.git"
|
|
22
|
+
},
|
|
23
|
+
"homepage": "https://github.com/koikirin/koishi-plugin-pm2",
|
|
24
|
+
"koishi": {
|
|
25
|
+
"description": {
|
|
26
|
+
"en": "PM2 process manager",
|
|
27
|
+
"zh": "PM2 进程管理"
|
|
28
|
+
},
|
|
29
|
+
"service": {
|
|
30
|
+
"required": [
|
|
31
|
+
"console"
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"@koishijs/plugin-console": "^5.30.11",
|
|
37
|
+
"koishi": "^4.18.10"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"kleur": "^4.1.5",
|
|
41
|
+
"pm2": "^6.0.14"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@hieuzest/koishi-buildtools": "^1.0.2",
|
|
45
|
+
"@koishijs/client": "^5.30.11",
|
|
46
|
+
"@koishijs/plugin-console": "^5.30.11",
|
|
47
|
+
"ansi_up": "^5.2.1"
|
|
48
|
+
}
|
|
49
|
+
}
|