import{d as _,u as l,s as c,a as h,ad as m}from"./app-CPb3bToC.js";const p=_("model_ms_sle_basic",{state:()=>({version:1,password:16,work_mode:1,connect_status:1,battery:0,profile:17,max_report:4,sensor_info:1,max_dpi:519,macro_size:1}),actions:{load_profile(t){this.version=t.version,this.password=t.password,this.work_mode=t.work_mode,this.battery=t.battery,this.profile=t.profile,this.max_report=t.max_report,this.sensor_info=t.sensor_info,this.max_dpi=t.max_dpi,this.macro_size=t.macro_size},default(){return{version:1,password:16,work_mode:1,connect_status:1,battery:0,profile:17,max_report:4,sensor_info:1,max_dpi:519,macro_size:1}},async sync(){try{return(await l().controller).set_basic_info(this)}catch{return!1}},async fetch(){try{let e=await(await l().controller).get_basic_info();if(e===null)return!1;this.version=e[0];let s=0;return s+=e[2]*Math.pow(256,0),s+=e[3]*Math.pow(256,1),s+=e[4]*Math.pow(256,2),s+=e[5]*Math.pow(256,3),s+=e[6]*Math.pow(256,4),s+=e[7]*Math.pow(256,5),this.work_mode=e[8],this.connect_status=e[9],this.battery=e[10],this.profile=e[11],this.max_report=e[12],this.sensor_info=e[13],this.max_dpi=e[14]+e[15]*256,this.macro_size=e[16],!0}catch{return!1}},get_battery(){let t=!1;t=(this.battery&128)>>7===1;let a=0;return a=Math.round(this.battery&127),{charging:t,level:a}}},persist:!0}),u=_("model_kb_by_v2_basic",{state:()=>({battery_status:0,battery_level:12,light_params:[],light_mode:0,low_latency:!1,mac_mode:!1,polling_level:3,sleep_level:6,win_lock:!1}),actions:{load_profile(t){this.battery_status=t.battery_status,this.battery_level=t.battery_level,this.light_params=JSON.parse(JSON.stringify(t.light_params)),this.light_mode=t.light_mode,this.low_latency=t.low_latency,this.mac_mode=t.mac_mode,this.polling_level=t.polling_level,this.sleep_level=t.sleep_level,this.win_lock=t.win_lock},default(){return{battery_status:0,battery_level:12,light_params:c(),light_mode:0,low_latency:!1,mac_mode:!1,polling_level:3,sleep_level:6,win_lock:!1}},set_light_params(t,a,e,s){for(let r=0;r<this.light_params.length;r++)if(Number(this.light_params[r].light_mode)===Number(t)){s==="default"?(this.light_params[r].bright=a,this.light_params[r].speed=e*256+7,this.light_params[r].color={r:255,g:255,b:255}):(this.light_params[r].bright=a,this.light_params[r].speed=e*256+0,this.light_params[r].color={r:s.r,g:s.g,b:s.b});break}},get_current_light_params(){for(let t=0;t<this.light_params.length;t++)if(Number(this.light_params[t].light_mode)===Number(this.light_mode))return this.light_params[t];return{light_mode:277,bright:0,speed:0}},setup(){this.light_params.length===0&&(this.light_params=c())},async sync(){try{return await(await l().controller).set_basic_info(this)}catch{return!1}},async sync_light_color(){try{return await(await l().controller).set_light_color(this)}catch{return!1}},async fetch(){try{const e=await(await l().controller).get_basic_info();if(e===null)return!1;this.mac_mode=e[0]===1,this.polling_level=e[1],this.low_latency=e[3]===3;let s=0;s+=e[9]*256,s+=e[10],this.light_mode=s,this.win_lock=e[15]===1,this.sleep_level=e[24];let r=h(),i=m(r.current_device.product_name);for(let o=0;o<this.light_params.length;o++)this.light_params[o].bright=e[i+o*2+0],this.light_params[o].speed=e[i+o*2+1];return!0}catch{return!1}},async fetch_light_color(){try{const e=await(await l().controller).get_light_color();for(let s=0;s<this.light_params.length;s++)if(Number(this.light_params[s].offset_color)!==0){const r=Number(this.light_params[s].offset_color)-7;let i=e[r+0],o=e[r+1],n=e[r+2];this.light_params[s].color={r:i,g:o,b:n}}return!0}catch{return!1}},async fetch_battery(){try{const e=await(await l().controller).get_battery();return this.battery_level=e[0],this.battery_status=e[1],!0}catch{return!1}}},persist:!0}),d=_("model_ms_pix_basic",{state:()=>({version:1,password:16,work_mode:1,connect_status:1,battery:0,profile:17,max_report:4,sensor_info:1,max_dpi:519,macro_size:1}),actions:{load_profile(t){this.version=t.version,this.password=t.password,this.work_mode=t.work_mode,this.battery=t.battery,this.profile=t.profile,this.max_report=t.max_report,this.sensor_info=t.sensor_info,this.max_dpi=t.max_dpi,this.macro_size=t.macro_size},default(){return{version:1,password:16,work_mode:1,connect_status:1,battery:0,profile:17,max_report:4,sensor_info:1,max_dpi:519,macro_size:1}},async sync(){try{return(await l().controller).set_basic_info(this)}catch{return!1}},async fetch(){try{let e=await(await l().controller).get_basic_info();return e.length===0?!1:(this.battery=e[5],this.max_report=e[7],this.sensor_info=e[8],this.max_dpi=e[9]+e[10]*255,this.macro_size=e[11],!0)}catch{return!1}},get_battery(){return{charging:!1,level:this.battery}}},persist:!0});export{d as a,p as b,u as m};
