import{c as z,d as N,u as Z,w as pe,a as fe,b as l,n as M,e as F,f as G,g as K,m as be,t as ee,r as y,h as I,I as ge,i as j,j as te,p as ke,k as ye,l as ae,o as Ce,q as P,s as R,v as we,x as H,y as T,z as u,A as L,B as $e,C as _e,D as V,E as $,F as E,G as Se,H as xe,J as Pe,K as D,P as Ve,L as Ie}from"./index-CriPLLD7.js";import{s as O,C as Te,a as Be,B as Re}from"./index-Df5zok-J.js";import{P as De}from"./index-WY9jkSm6.js";import{S as Ne}from"./index-B87rnfS9.js";const[le,Ae]=z("radio-group"),Ee={shape:String,disabled:Boolean,iconSize:M,direction:String,modelValue:F,checkedColor:String},oe=Symbol(le);var ze=N({name:le,props:Ee,emits:["change","update:modelValue"],setup(e,{emit:p,slots:c}){const{linkChildren:m}=Z(oe),d=n=>p("update:modelValue",n);return pe(()=>e.modelValue,n=>p("change",n)),m({props:e,updateValue:d}),fe(()=>e.modelValue),()=>{var n;return l("div",{class:Ae([e.direction]),role:"radiogroup"},[(n=c.default)==null?void 0:n.call(c)])}}});const Ge=G(ze),ne={name:F,disabled:Boolean,iconSize:M,modelValue:F,checkedColor:String,labelPosition:String,labelDisabled:Boolean};var Ue=N({props:K({},ne,{bem:be(Function),role:String,shape:String,parent:Object,checked:Boolean,bindGroup:ee,indeterminate:{type:Boolean,default:null}}),emits:["click","toggle"],setup(e,{emit:p,slots:c}){const m=y(),d=r=>{if(e.parent&&e.bindGroup)return e.parent.props[r]},n=I(()=>{if(e.parent&&e.bindGroup){const r=d("disabled")||e.disabled;if(e.role==="checkbox"){const C=d("modelValue").length,k=d("max"),_=k&&C>=+k;return r||_&&!e.checked}return r}return e.disabled}),b=I(()=>d("direction")),o=I(()=>{const r=e.checkedColor||d("checkedColor");if(r&&e.checked&&!n.value)return{borderColor:r,backgroundColor:r}}),s=I(()=>e.shape||d("shape")||"round"),i=r=>{const{target:C}=r,k=m.value,_=k===C||(k==null?void 0:k.contains(C));!n.value&&(_||!e.labelDisabled)&&p("toggle"),p("click",r)},h=()=>{var r,C;const{bem:k,checked:_,indeterminate:A}=e,w=e.iconSize||d("iconSize");return l("div",{ref:m,class:k("icon",[s.value,{disabled:n.value,checked:_,indeterminate:A}]),style:s.value!=="dot"?{fontSize:j(w)}:{width:j(w),height:j(w),borderColor:(r=o.value)==null?void 0:r.borderColor}},[c.icon?c.icon({checked:_,disabled:n.value}):s.value!=="dot"?l(ge,{name:A?"minus":"success",style:o.value},null):l("div",{class:k("icon--dot__icon"),style:{backgroundColor:(C=o.value)==null?void 0:C.backgroundColor}},null)])},v=()=>{const{checked:r}=e;if(c.default)return l("span",{class:e.bem("label",[e.labelPosition,{disabled:n.value}])},[c.default({checked:r,disabled:n.value})])};return()=>{const r=e.labelPosition==="left"?[v(),h()]:[h(),v()];return l("div",{role:e.role,class:e.bem([{disabled:n.value,"label-disabled":e.labelDisabled},b.value]),tabindex:n.value?void 0:0,"aria-checked":e.checked,onClick:i},[r])}}});const je=K({},ne,{shape:String}),[He,Le]=z("radio");var Oe=N({name:He,props:je,emits:["update:modelValue"],setup(e,{emit:p,slots:c}){const{parent:m}=te(oe),d=()=>(m?m.props.modelValue:e.modelValue)===e.name,n=()=>{m?m.updateValue(e.name):p("update:modelValue",e.name)};return()=>l(Ue,ye({bem:Le,role:"radio",parent:m,checked:d(),onToggle:n},e),ke(c,["default","icon"]))}});const Fe=G(Oe),[se,Me]=z("row"),ue=Symbol(se),Ke={tag:ae("div"),wrap:ee,align:String,gutter:{type:[String,Number,Array],default:0},justify:String};var qe=N({name:se,props:Ke,setup(e,{slots:p}){const{children:c,linkChildren:m}=Z(ue),d=I(()=>{const o=[[]];let s=0;return c.forEach((i,h)=>{s+=Number(i.span),s>24?(o.push([h]),s-=24):o[o.length-1].push(h)}),o}),n=I(()=>{let o=0;Array.isArray(e.gutter)?o=Number(e.gutter[0])||0:o=Number(e.gutter);const s=[];return o&&d.value.forEach(i=>{const h=o*(i.length-1)/i.length;i.forEach((v,r)=>{if(r===0)s.push({right:h});else{const C=o-s[v-1].right,k=h-C;s.push({left:C,right:k})}})}),s}),b=I(()=>{const{gutter:o}=e,s=[];if(Array.isArray(o)&&o.length>1){const i=Number(o[1])||0;if(i<=0)return s;d.value.forEach((h,v)=>{v!==d.value.length-1&&h.forEach(()=>{s.push({bottom:i})})})}return s});return m({spaces:n,verticalSpaces:b}),()=>{const{tag:o,wrap:s,align:i,justify:h}=e;return l(o,{class:Me({[`align-${i}`]:i,[`justify-${h}`]:h,nowrap:!s})},{default:()=>{var v;return[(v=p.default)==null?void 0:v.call(p)]}})}}});const[Xe,Ye]=z("col"),Je={tag:ae("div"),span:Ce(0),offset:M};var We=N({name:Xe,props:Je,setup(e,{slots:p}){const{parent:c,index:m}=te(ue),d=I(()=>{if(!c)return;const{spaces:n,verticalSpaces:b}=c;let o={};if(n&&n.value&&n.value[m.value]){const{left:i,right:h}=n.value[m.value];o={paddingLeft:i?`${i}px`:null,paddingRight:h?`${h}px`:null}}const{bottom:s}=b.value[m.value]||{};return K(o,{marginBottom:s?`${s}px`:null})});return()=>{const{tag:n,span:b,offset:o}=e;return l(n,{style:d.value,class:Ye({[b]:b,[`offset-${o}`]:o})},{default:()=>{var s;return[(s=p.default)==null?void 0:s.call(p)]}})}}});const Qe=G(We),Ze=G(qe),et={class:"stdout"},tt="/data/adb/modules/xray4magisk/module.prop",ut={__name:"Dashboard",props:["theme"],setup(e){const p=y(!1),c=y(!1),m=y(!1),d=y(!1),n=y(!1),b=y(!1),o=y(""),s=y({result:[]}),i=y(P.global.t("common.waiting-text")),h=y(""),v=y({api:"",coreType:"xray",pid:"",method:"",dataDir:""}),r=y(P.global.t("dashboard.status-core-status-stopped")),C=[{text:"start",value:"start"},{text:"stop",value:"stop"},{text:"restart",value:"restart"},{text:"status",value:"status"}],k=a=>{d.value=!0,c.value=!0,setTimeout(()=>{D("service "+a.value).then(t=>{a.value==="start"||a.value==="restart"?D("proxy refresh").then(g=>{i.value=t+`
`+g}):a.value==="stop"&&D("proxy disable").then(g=>{i.value=t+`
`+g}),i.value=t})},300)},_=[{text:"enable",value:"enable"},{text:"disable",value:"disable"},{text:"refresh",value:"refresh"}],A=a=>{d.value=!0,c.value=!0,setTimeout(()=>{D("proxy "+a.value).then(t=>{i.value=t})},300)},w=a=>{d.value=!0,c.value=!0,setTimeout(()=>{D("update "+a).then(t=>{i.value=t})},300)},ie=async a=>{c.value=!0,b.value=!0,n.value=a,s.value=await H("get switch");let t=localStorage.getItem("switchIdx");typeof t<"u"&&t!=null?o.value=t:o.value=""},re=(a,t)=>{let g=a?`set switch custom ${t}`:`set switch ${t}`;H(g).then(B=>{b.value=!1,a?(localStorage.setItem("switchCustomIdx",t),localStorage.removeItem("switchIdx")):(localStorage.setItem("switchIdx",t),localStorage.removeItem("switchCustomIdx")),B.ok?O(P.global.t("dashboard.tool-switch-success")):O(P.global.t("dashboard.tool-switch-failed"))})},U=()=>{h.value="",v.value={api:"",coreType:"xray",pid:"",method:"",dataDir:""},m.value=!1,r.value=P.global.t("dashboard.status-core-status-stopped"),i.value=P.global.t("common.waiting-text"),c.value=!1,q(),X()},de=()=>{setTimeout(()=>{U(),p.value=!1},500)},q=()=>{we("grep version= "+tt).then(a=>{h.value=a.split("=")[1]})},X=()=>{H("get status").then(a=>{v.value=a,v.value.pid.length>0&&(m.value=!0,r.value=P.global.t("dashboard.status-core-status-running"))}).catch(a=>{O(P.global.t("dashboard.status-get-failed")+a)})};return q(),X(),(a,t)=>{const g=Te,B=Be,Y=Ve,J=Ne,S=Re,x=Qe,ce=Ze,ve=Fe,me=Ge,W=Ie,he=De;return T(),R(he,{modelValue:p.value,"onUpdate:modelValue":t[11]||(t[11]=f=>p.value=f),disabled:c.value,onRefresh:de,"pulling-text":a.$t("common.pulling-text"),"loosing-text":a.$t("common.loosing-text"),"loading-text":a.$t("common.loading-text")},{default:u(()=>[l(B,{title:a.$t("dashboard.version"),inset:""},{default:u(()=>[l(g,{title:a.$t("dashboard.version-module"),"title-style":"max-width:35%;",value:h.value,url:"https://github.com/Asterisk4Magisk/Xray4Magisk",clickable:""},null,8,["title","value"]),l(g,{title:a.$t("dashboard.version-dashboard"),"title-style":"max-width:35%;",value:a.$t("common.dashboard-version"),url:"https://github.com/Asterisk4Magisk/xray4magisk-ksu-webui",clickable:""},null,8,["title","value"])]),_:1},8,["title"]),l(B,{title:a.$t("dashboard.status"),inset:""},{default:u(()=>[l(g,{title:a.$t("dashboard.status-core-type"),"title-style":"max-width:35%;",value:v.value.coreType},null,8,["title","value"]),l(Y,{actions:C,onSelect:k,placement:"bottom-end"},{reference:u(()=>[l(g,{title:a.$t("dashboard.status-core-status"),"title-style":"max-width:35%;",value:r.value,clickable:""},null,8,["title","value"]),t[12]||(t[12]=L("div",null,null,-1))]),_:1}),$e(l(g,{title:a.$t("dashboard.status-core-pid"),"title-style":"max-width:35%;",value:v.value.pid},null,8,["title","value"]),[[_e,m.value]]),l(Y,{actions:_,onSelect:A,placement:"bottom-end"},{reference:u(()=>[l(g,{title:a.$t("dashboard.status-method"),"title-style":"max-width:35%;",value:v.value.method,clickable:""},null,8,["title","value"])]),_:1})]),_:1},8,["title"]),l(B,{title:a.$t("dashboard.tool"),inset:""},{default:u(()=>[l(J),l(ce,{gutter:[0,11],justify:"space-around"},{default:u(()=>[l(x,{span:"11"},{default:u(()=>[l(S,{plain:"",hairline:"",type:"default",block:"",onClick:t[0]||(t[0]=f=>w("core"))},{default:u(()=>[V($(a.$t("dashboard.tool-update-core")),1)]),_:1})]),_:1}),l(x,{span:"11"},{default:u(()=>[l(S,{plain:"",hairline:"",type:"default",block:"",onClick:t[1]||(t[1]=f=>w("adghome"))},{default:u(()=>[V($(a.$t("dashboard.tool-update-adghome")),1)]),_:1})]),_:1}),v.value.coreType==="v2ray"||v.value.coreType==="xray"?(T(),R(x,{key:0,span:"11"},{default:u(()=>[l(S,{plain:"",hairline:"",type:"default",block:"",onClick:t[2]||(t[2]=f=>w("geodata"))},{default:u(()=>[V($(a.$t("dashboard.tool-update-geodata")),1)]),_:1})]),_:1})):E("",!0),l(x,{span:"11"},{default:u(()=>[l(S,{plain:"",hairline:"",type:"default",block:"",onClick:t[3]||(t[3]=f=>w("subscribe"))},{default:u(()=>[V($(a.$t("dashboard.tool-update-subscribe")),1)]),_:1})]),_:1}),v.value.coreType==="mihomo"?(T(),R(x,{key:1,span:"11"},{default:u(()=>[l(S,{plain:"",hairline:"",type:"default",block:"",onClick:t[4]||(t[4]=f=>w("yacd-meta"))},{default:u(()=>[V($(a.$t("dashboard.tool-update-yacd-meta")),1)]),_:1})]),_:1})):E("",!0),v.value.coreType==="mihomo"?(T(),R(x,{key:2,span:"11"},{default:u(()=>[l(S,{plain:"",hairline:"",type:"default",block:"",onClick:t[5]||(t[5]=f=>w("metacubexd"))},{default:u(()=>[V($(a.$t("dashboard.tool-update-metacubexd")),1)]),_:1})]),_:1})):E("",!0),l(x,{span:"11"},{default:u(()=>[l(S,{plain:"",hairline:"",type:"default",block:"",onClick:t[6]||(t[6]=f=>w("tun2socks"))},{default:u(()=>[V($(a.$t("dashboard.tool-update-tun2socks")),1)]),_:1})]),_:1}),v.value.coreType==="mihomo"?(T(),R(x,{key:3,span:"11"},{default:u(()=>[l(S,{plain:"",hairline:"",type:"default",block:"",onClick:t[7]||(t[7]=f=>ie(!1))},{default:u(()=>[V($(a.$t("dashboard.tool-switch")),1)]),_:1})]),_:1})):E("",!0)]),_:1}),l(J)]),_:1},8,["title"]),l(W,{show:b.value,"onUpdate:show":t[9]||(t[9]=f=>b.value=f),round:"",style:{width:"90%",maxHeight:"85%"},onClosed:U},{default:u(()=>[l(me,{modelValue:o.value,"onUpdate:modelValue":t[8]||(t[8]=f=>o.value=f)},{default:u(()=>[l(B,{inset:""},{default:u(()=>[(T(!0),Se(Pe,null,xe(s.value.result,(f,Q)=>(T(),R(g,{title:f,clickable:"",onClick:at=>re(n.value,Q)},{"right-icon":u(()=>[l(ve,{name:Q.toString()},null,8,["name"])]),_:2},1032,["title","onClick"]))),256))]),_:1})]),_:1},8,["modelValue"])]),_:1},8,["show"]),l(W,{show:d.value,"onUpdate:show":t[10]||(t[10]=f=>d.value=f),round:"",style:{width:"90%",minHeight:"35%",maxHeight:"85%"},onClosed:U},{default:u(()=>[l(g,{title:a.$t("common.stdout"),"title-style":"max-width:100%;",size:"large"},null,8,["title"]),L("div",et,[L("p",null,$(i.value),1)])]),_:1},8,["show"])]),_:1},8,["modelValue","disabled","pulling-text","loosing-text","loading-text"])}}};export{ut as default};
