2 lines
64 KiB
JavaScript
2 lines
64 KiB
JavaScript
|
import{s as ae,e as H,i as N,d as m,A as ie,B as er,C as q,D as se,r as be,f as G,g as U,h as D,E as ze,F as Gr,G as Z,u as me,v as pe,w as he,H as Ur,I as Or,J as Ir,K as F,p as $r,L as Wr,M as Cr,a as $,c as W,N as Me,x,l as L,m as S,j as R,n as we,O as Ge,P as Ue,Q as Kr,R as Pr,S as Xe,z as $e,k as rr,y as ke}from"../chunks/scheduler.8df65e6b.js";import{S as ue,i as de,a as _,g as te,t as w,c as oe,f as We,b as K,d as P,m as B,e as V}from"../chunks/index.fcb0c12b.js";import{w as Tr}from"../chunks/index.7d4c7b1f.js";function Oe(t){return(t==null?void 0:t.length)!==void 0?t:Array.from(t)}function Ce(t,e){const r={},o={},n={$$scope:1};let l=t.length;for(;l--;){const a=t[l],i=e[l];if(i){for(const c in a)c in i||(o[c]=1);for(const c in i)n[c]||(r[c]=i[c],n[c]=1);t[l]=i}else for(const c in a)n[c]=1}for(const a in o)a in r||(r[a]=void 0);return r}function xr(t){return typeof t=="object"&&t!==null?t:{}}const Br=!1,Vr=!1,$o=Object.freeze(Object.defineProperty({__proto__:null,prerender:Br,ssr:Vr},Symbol.toStringTag,{value:"Module"})),Ne=Tr("DISCONNECTED"),Se=Tr(["","","",""]),Rr="941758d2-eae2-0697-9944-f9fbb0",jr=Rr+"000000",Ye=Rr+"01",Be=Ye+"0000",Lr=new TextDecoder("utf-8"),Ke=["","","",""];let ge,De,ve={d1l1:void 0,d1l2:void 0,d2l1:void 0,d2l2:void 0,buttons:void 0};async function Yr(){Ne.set("CONNECTING");try{ge=await navigator.bluetooth.requestDevice({filters:[{services:[jr]},{services:[Be]}],optionalServices:[Be]})}catch{Ne.set("DISCONNECTED");return}console.log("> Requested "+ge.name+" ("+ge.id+")");let t;try{t=await ge.gatt.connect()}catch{console.log("> Error connecting to "+ge.name+" ("+ge.id+")"),Ne.set("DISCONNECTED");return}ge.addEventListener("gattserverdisconnected",Hr),De=await t.getPrimaryService(Be);let e=[];for(let r=0;r<4;r++)e.push(await De.getCharacteristic(Ye+"000"+(r+1))),Ke[r]=await e[r].readValue().then(o=>Lr.decode(o)),await e[r].startNotifications(),e[r].addEventListener("characteristicvaluechanged",qr);ve.d1l1=e[0],ve.d1l2=e[1],ve.d2l1=e[2],ve.d2l2=e[3],ve.buttons=await De.getCharacteristic(Ye+"0005"),Se.set(Ke),Ne.set("CONNECTED")}function Hr(){console.log("> Bluetooth Device disconnected"),ge=void 0,De=void 0,Ne.set("DISCONNECTED")}function qr(t){if(!t.target)return;const e=t.target,r=Lr.decode(e.value),o=parseInt(e.uuid.slice(-1))-1;Ke[o]=r;const[n,l,a,i]=Ke;Se.set([n,l,a,i])}function Xr(t){switch(t){case"OK":return 0;case"ESC":return 1;case"+":return 2;case"-":return 3;case"RDY":return 4;case"RST":return 6;case"FULL_RESET":return 5}}async function re(t){if(ve.buttons===void 0)return!1;const e=new ArrayBuffer(1),r=new Int8Array(e),o=Xr(t);return r[0]=o,console.log("Writing buttons: ",o),await ve.buttons.writeValueWithResponse(e),!0}function Jr(){for(var t=0,e,r,o="";t<arguments.length;)(e=arguments[t++])&&(r=Sr(e))&&(o&&(o+=" "),o+=r);return o}function Sr(t){if(typeof t=="string")return t;for(var e,r="",o=0;o<t.length;o++)t[o]&&(e=Sr(t[o]))&&(r&&(r+=" "),r+=e);return r}var Je="-";function Zr(t){var e=et(t),r=t.conflictingClassGroups,o=t.conflictingClassGroupModifiers,n=o===void 0?{}:o;function l(i){var c=i.split(Je);return c[0]===""&&c.length!==1&&c.shift(),Ar(c,e)||Qr(i)}function a(i,c){var f=r[i]||[];return c&&n[i]?[].concat(f,n[i]):f}return{getClassGroupId:l,getConflictingClassGroupIds:a}}function Ar(t,e){var a;if(t.length===0)return e.classGroupId;var r=t[0],o=e.nextPart.get(r),n=o?Ar(t.slice(1),o):void 0;if(n)return n;if(e.validators.length!==0){var l=t.join(Je);return(a=e.validators.find(function(i){var c=i.validator;return c(l)}))==null?void 0:a.classGroupId}}var tr=/^\[(.+)\]$/;function Qr(t){if(tr.test(t)){var e=tr.exec(t)[1],r=e==null?void 0:e.substring(0,e.indexOf(":"));if(r)return"arbitrary.."+r}}function et(t){var e=t.theme,r=t.prefix,o={nextPart:new Map,validators:[]},n=tt(Object.entries(t.classGroups),r);return n.forEach(function(l){var a=l[0],i=l[1];He(i,o,a,e)}),o}function He(t,e,r,o){t.forEach(function(n){if(typeof n=="string"){var l=n===""?e:or(e,n);l.classGroupId=r;return}if(typeof n=="function"){if(rt(n)){He(n(o),e,r,o);return}e.validators.push({validator:n,classGroupId:r}
|