import{aU as l}from"./index-Dg4NaXsE.js";const d="/sl/projection/reflection";function p(){return{fields:[],status:[],methods:[]}}function f(){return{car:p(),site:p(),track:p()}}const y=f;async function s(e){const{data:t}=await l.get(`${d}${e}`);if(!t?.success)throw new Error(t?.message??`reflection ${e} failed`);return t.data}async function n(e,t){const{data:o}=await l.post(`${d}${e}`,null,{params:t});if(!o?.success)throw new Error(o?.message??`reflection ${e} failed`);return o.data}async function g(e){const{data:t}=await l.delete(`${d}${e}`);if(!t?.success)throw new Error(t?.message??`reflection ${e} failed`);return t.data}async function u(e,t){const{data:o}=await l.patch(`${d}${e}`,t);if(!o?.success)throw new Error(o?.message??`reflection PATCH ${e} failed`);return o.data}const A={listKinds:()=>s("/kinds"),listAssemblies:()=>s("/assemblies"),listObjects:e=>s(`/objects/${e}`),listCreatableTypes:e=>s(`/types/${e}`),createObject:(e,t,o)=>{const r={};if(t&&(r.typeName=t),o)for(const[c,a]of Object.entries(o))a==null||a===""||(r[c]=a);return n(`/objects/${e}`,r)},deleteObject:(e,t)=>g(`/objects/${e}/${t}`),reloadPlugins:()=>n("/plugins/reload"),listPlugins:()=>s("/plugins"),unloadPlugin:e=>n(`/plugins/${encodeURIComponent(e)}/unload`),listMethods:(e,t)=>s(`/methods/${e}/${t}`),listMethodsByType:e=>s(`/methods-by-type/${e}`),getStatus:(e,t)=>s(`/status/${e}/${t}`),getFields:(e,t)=>s(`/fields/${e}/${t}`),setField:(e,t,o,r)=>n(`/fields/${e}/${t}/${encodeURIComponent(o)}`,{value:r}),deleteField:(e,t,o)=>g(`/fields/${e}/${t}/${encodeURIComponent(o)}`),getBundle:(e,t)=>s(`/bundle/${e}/${t}`),execute:(e,t,o,r)=>n(`/execute/${e}/${t}/${encodeURIComponent(o)}`,r),gotoCarSite:(e,t)=>n(`/car/${e}/goto-site`,{siteId:t}),getScriptSource:e=>s(`/scripts/${e}/source`),getScriptExceptionStatus:e=>s(`/scripts/${e}/exception-status`),getMonitorConfig:()=>s("/monitor-config"),saveMonitorConfig:async e=>{const{data:t}=await l.post(`${d}/monitor-config`,e);if(!t?.success)throw new Error(t?.message??"saveMonitorConfig failed");return t.data},getSelection:()=>s("/selection"),setSelection:(e,t)=>n("/selection",{kind:e,id:t}),clearSelection:()=>n("/selection/clear"),getProjectFields:()=>s("/project/fields"),setProjectField:(e,t)=>n(`/project/fields/${encodeURIComponent(e)}`,{value:t}),saveProject:e=>n("/project/save",e?{path:e}:void 0),getAppConfigFields:()=>s("/app-config/fields"),setAppConfigField:(e,t)=>n(`/app-config/fields/${encodeURIComponent(e)}`,{value:t}),saveAppConfig:()=>n("/app-config/save"),getViewportStyle:()=>s("/viewport-style"),patchViewportStyle:e=>u("/viewport-style",b(e)),getCarStyleTypes:()=>s("/car-style/types"),getCarStyle:e=>s(`/car-style/${encodeURIComponent(e)}`),putCarStyle:async(e,t)=>{const{data:o}=await l.post(`${d}/car-style/${encodeURIComponent(e)}`,t);if(!o?.success)throw new Error(o?.message??"putCarStyle failed");return o.data},deleteCarStyle:e=>g(`/car-style/${encodeURIComponent(e)}`),getAlarmColors:()=>s("/car-style/alarm-colors"),putAlarmColors:async e=>{const{data:t}=await l.post(`${d}/car-style/alarm-colors`,e);if(!t?.success)throw new Error(t?.message??"putAlarmColors failed");return t.data},saveCarStyle:()=>n("/car-style/save")};function i(e){return Number.isFinite(e)?e>>>0:0}function C(e){const t=i(e),o=t>>>24&255,r=t>>>16&255,c=t>>>8&255,a=t&255;return o>=255?`#${r.toString(16).padStart(2,"0")}${c.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}`:`#${o.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${c.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}`}function w(e){const t=e.replace("#","").trim();if(t.length===6){const o=parseInt(t.slice(0,2),16),r=parseInt(t.slice(2,4),16),c=parseInt(t.slice(4,6),16);return i(255<<24|o<<16|r<<8|c)}if(t.length===8){const o=parseInt(t.slice(0,2),16),r=parseInt(t.slice(2,4),16),c=parseInt(t.slice(4,6),16),a=parseInt(t.slice(6,8),16);return i(o<<24|r<<16|c<<8|a)}return 4294967295}const $=["colorNormalArgb","colorSelectedArgb","labelColorNormalArgb","labelColorSelectedArgb"],m=["colorNormalArgb","colorSelectedArgb"];function b(e){const t={};if(e.site){const o={...e.site};for(const r of $)o[r]!=null&&(o[r]=i(o[r]));t.site=o}if(e.track){const o={...e.track};for(const r of m)o[r]!=null&&(o[r]=i(o[r]));t.track=o}return t}function I(e){return{site:{...e.site,colorNormalArgb:i(e.site.colorNormalArgb),colorSelectedArgb:i(e.site.colorSelectedArgb),labelColorNormalArgb:i(e.site.labelColorNormalArgb),labelColorSelectedArgb:i(e.site.labelColorSelectedArgb)},track:{...e.track,colorNormalArgb:i(e.track.colorNormalArgb),colorSelectedArgb:i(e.track.colorSelectedArgb)}}}export{C as a,f as b,y as e,w as h,I as n,A as r};
