import{r as y,b as r,l as B,d as e,i as u,v as m,A as p,c as d,f as b,t as M,w as x,T as k}from"./index-AQkeZB82.js";import{_ as w}from"./_plugin-vue_export-helper-DlAUqK2U.js";const C={class:"modal-content"},$={class:"modal-header"},V={class:"modal-body"},c={class:"form-group"},N={class:"form-group"},D={class:"form-group"},O={class:"toggle-switch"},U={key:0,class:"form-group"},J={key:1,class:"form-group"},z={key:2,class:"form-group"},G={class:"form-group"},I={class:"toggle-switch"},T={class:"modal-footer"},A={__name:"SettingsModal",props:{settings:{type:Object,required:!0},isConnected:{type:Boolean,default:!1},isGlobal:{type:Boolean,default:!1},isCustom:{type:Boolean,default:!1}},emits:["close","save","reset"],setup(l,{emit:n}){const i=l,a=n,s=y({...i.settings});function v(){a("save",{...s.value}),a("close")}function S(){a("reset"),a("close")}return(g,t)=>(r(),B(k,{to:"body"},[e("div",{class:"settings-modal",onClick:t[9]||(t[9]=x(o=>g.$emit("close"),["self"]))},[e("div",C,[e("div",$,[t[10]||(t[10]=e("h3",null,"⚙️ 连接设置",-1)),e("button",{class:"close-btn",onClick:t[0]||(t[0]=o=>g.$emit("close"))},"×")]),e("div",V,[e("div",c,[t[11]||(t[11]=e("label",null,"Max FPS (0 为无限制):",-1)),u(e("input",{type:"number","onUpdate:modelValue":t[1]||(t[1]=o=>s.value.fps=o),min:"0",max:"120"},null,512),[[m,s.value.fps,void 0,{number:!0}]])]),e("div",N,[t[12]||(t[12]=e("label",null,"Max Size (0 为无限制):",-1)),u(e("input",{type:"number","onUpdate:modelValue":t[2]||(t[2]=o=>s.value.size=o),min:"0",step:"100"},null,512),[[m,s.value.size,void 0,{number:!0}]]),t[13]||(t[13]=e("small",{class:"hint"},"例如：1080 表示限制最长边为 1080",-1))]),e("div",D,[t[15]||(t[15]=e("label",null,"开启 BWE (动态码率):",-1)),e("div",O,[u(e("input",{type:"checkbox",id:"bwe-toggle","onUpdate:modelValue":t[3]||(t[3]=o=>s.value.bwe=o)},null,512),[[p,s.value.bwe]]),t[14]||(t[14]=e("label",{for:"bwe-toggle"},null,-1))])]),s.value.bwe?(r(),d("div",U,[t[16]||(t[16]=e("label",null,"Min Bitrate (Mbps):",-1)),u(e("input",{type:"number","onUpdate:modelValue":t[4]||(t[4]=o=>s.value.minBitrate=o),min:"1",step:"1"},null,512),[[m,s.value.minBitrate,void 0,{number:!0}]]),t[17]||(t[17]=e("small",{class:"hint"},"默认：2 Mbps",-1))])):b("",!0),s.value.bwe?(r(),d("div",J,[t[18]||(t[18]=e("label",null,"Max Bitrate (Mbps):",-1)),u(e("input",{type:"number","onUpdate:modelValue":t[5]||(t[5]=o=>s.value.maxBitrate=o),min:"1",step:"1"},null,512),[[m,s.value.maxBitrate,void 0,{number:!0}]]),t[19]||(t[19]=e("small",{class:"hint"},"默认：20 Mbps",-1))])):b("",!0),s.value.bwe?b("",!0):(r(),d("div",z,[t[20]||(t[20]=e("label",null,"Bitrate (Mbps):",-1)),u(e("input",{type:"number","onUpdate:modelValue":t[6]||(t[6]=o=>s.value.bitrate=o),min:"1",step:"1"},null,512),[[m,s.value.bitrate,void 0,{number:!0}]]),t[21]||(t[21]=e("small",{class:"hint"},"默认：4 Mbps",-1))])),e("div",G,[t[23]||(t[23]=e("label",null,"开启 Agent Debug 日志:",-1)),e("div",I,[u(e("input",{type:"checkbox",id:"debug-toggle","onUpdate:modelValue":t[7]||(t[7]=o=>s.value.debug=o)},null,512),[[p,s.value.debug]]),t[22]||(t[22]=e("label",{for:"debug-toggle"},null,-1))])])]),e("div",T,[l.isCustom?(r(),d("button",{key:0,class:"btn btn-danger",onClick:S},"恢复全局设置")):b("",!0),t[24]||(t[24]=e("div",{style:{flex:"1"}},null,-1)),e("button",{class:"btn btn-secondary",onClick:t[8]||(t[8]=o=>g.$emit("close"))},"取消"),e("button",{class:"btn btn-primary",onClick:v},M(l.isGlobal?"保存全局设置":l.isConnected?"保存并重新连接":"保存并连接"),1)])])])]))}},F=w(A,[["__scopeId","data-v-f209d6d9"]]),E={fps:0,size:0,bitrate:4,bwe:!0,minBitrate:2,maxBitrate:20,debug:!1};function f(l){return l.bitrate>1e3&&(l.bitrate=Math.max(1,Math.round(l.bitrate/1e6)),l.minBitrate>1e3&&(l.minBitrate=Math.max(1,Math.round(l.minBitrate/1e6))),l.maxBitrate>1e3&&(l.maxBitrate=Math.max(1,Math.round(l.maxBitrate/1e6)))),l}function P(l){let n={...E};try{const i=localStorage.getItem("cloudphone_settings");i&&(n={...n,...f(JSON.parse(i))},localStorage.setItem("cloudphone_settings",JSON.stringify(n)))}catch{}if(!l)return n;try{const i=localStorage.getItem(`cloudphone_settings_${l}`);if(i){const a={...n,...f(JSON.parse(i))};return localStorage.setItem(`cloudphone_settings_${l}`,JSON.stringify(a)),a}}catch{}return n}function R(l,n){l?localStorage.setItem(`cloudphone_settings_${l}`,JSON.stringify(n)):localStorage.setItem("cloudphone_settings",JSON.stringify(n))}function W(l){return l?localStorage.getItem(`cloudphone_settings_${l}`)!==null:!1}function H(l){l&&localStorage.removeItem(`cloudphone_settings_${l}`)}export{F as S,H as d,P as g,W as h,R as s};
