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