@yee94/qk80mk2 0.0.0-stage โ 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/LICENSE +25 -0
- package/README.md +280 -2
- package/THIRD_PARTY_NOTICES.md +36 -0
- package/package.json +22 -4
- package/reference/LICENSE.via-app +674 -0
- package/reference/manifest.json +24 -0
- package/reference/official-assets/configs.json +1286 -0
- package/reference/official-assets/index.js +2509 -0
- package/reference/official-assets/kbres.wasm +0 -0
- package/scripts/verify-assets.js +11 -0
- package/scripts/verify-official.js +42 -0
- package/src/cli.js +66 -0
- package/src/image.js +32 -0
- package/src/index.js +2 -0
- package/src/protocol.js +55 -0
- package/src/serial.js +85 -0
|
@@ -0,0 +1,2509 @@
|
|
|
1
|
+
var js=Object.defineProperty;var Fs=(e,t,r)=>t in e?js(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var ie=(e,t,r)=>(Fs(e,typeof t!="symbol"?t+"":t,r),r);import{j as jsxRuntimeExports,u as useSelector,a as useDispatch,r as reactExports,d as dist,b as defaultsDeep,c as createSlice,D,C as Color,p as partition,e as createSelector,l as lodashExports,f as del,g as update,s as setMany,h as entries,i as styled,k as useTranslation,m as useCombobox,R as React,S as Select,n as dist$1,F as FontAwesomeIcon,o as useLocation,q as shallowEqual,t as faLightbulb,v as faHeadphones,w as faDisplay,x as faGear,y as createListenerMiddleware,z as captureException,A as createReduxEnhancer,B as configureStore,E as faBook,G as faSquare,H as faCircle,I as faUndo,J as faSave,K as faTrash,L as faCompress,M as faExpand,N as faMagicWandSparkles,O as faStopwatch,P as faXmarkCircle,Q as ReactTextareaAutocomplete,T as faClapperboard,U as faCode,V as faFloppyDisk,W as stringify,_ as __vitePreload,X as faCopy,Y as faAdd,Z as faMinus,$ as faRotateLeft,a0 as faImage,a1 as faVideo,a2 as faStop,a3 as faPlay,a4 as faFileImport,a5 as faDownload,a6 as faShare,a7 as SketchPicker,a8 as faWarning,a9 as Draggable,aa as keyframes,ab as faMicrochip,ac as faAngleDown,ad as faPlus,ae as faUpload,af as faXmark,ag as faToolbox,ah as useProgress,ai as faCircleQuestion,aj as Link$1,ak as faComputer,al as faCancel,am as faKeyboard,an as faStethoscope,ao as faBrush,ap as faBug,aq as faSatelliteDish,ar as faDiscord,as as faGithub,at as faLanguage,au as useResizeObserver,av as useThree,aw as J,ax as useFrame,ay as PerspectiveCamera,az as Shape,aA as E,aB as Html,aC as useGLTF,aD as Segments,aE as Segment,aF as PresentationControls,aG as BufferAttribute,aH as Object3D,aI as SpotLight,aJ as mt,aK as Canvas,aL as OrbitControls,aM as faUnlock,aN as faSpinner,aO as faCheck,aP as createGlobalStyle,aQ as Route,aR as ErrorBoundary,aS as Router,aT as useLocationProperty,aU as navigate,aV as Provider,aW as instance,aX as Browser$1,aY as initReactI18next,aZ as resourcesToBackend,a_ as createRoot}from"./vendor-57900590.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const l of a)if(l.type==="childList")for(const c of l.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function r(a){const l={};return a.integrity&&(l.integrity=a.integrity),a.referrerPolicy&&(l.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?l.credentials="include":a.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function s(a){if(a.ep)return;a.ep=!0;const l=r(a);fetch(a.href,l)}})();const __variableDynamicImportRuntimeHelper=(e,t)=>{const r=e[t];return r?typeof r=="function"?r():Promise.resolve(r):new Promise((s,a)=>{(typeof queueMicrotask=="function"?queueMicrotask:setTimeout)(a.bind(null,new Error("Unknown variable dynamic import: "+t)))})},Fragment=jsxRuntimeExports.Fragment,jsx=jsxRuntimeExports.jsx,jsxs=jsxRuntimeExports.jsxs,style="";var TestKeyState=(e=>(e[e.Initial=0]="Initial",e[e.KeyDown=1]="KeyDown",e[e.KeyUp=2]="KeyUp",e))(TestKeyState||{}),DKSPoint=(e=>(e[e.Hold=0]="Hold",e[e.Down=1]="Down",e[e.Up=2]="Up",e[e.Single=3]="Single",e))(DKSPoint||{});const ATBG="IAMT",ATFG="IAFT";let globalAudioContext,globalAmp,globalAmpGain=1;const ampGain=.25,ampAttack=.05,ampDecay=.05,ampSustain=1,ampRelease=.05;function getAudioContext(){return globalAudioContext===void 0&&(globalAudioContext=new AudioContext),globalAudioContext}function getGlobalAmp(){if(globalAmp===void 0){const e=getAudioContext();globalAmp=e.createGain(),globalAmp.gain.value=globalAmpGain,globalAmp.connect(e.destination)}return globalAmp}function setGlobalAmpGain(e){globalAmpGain=e,globalAmp!==void 0&&(globalAmp.gain.setValueAtTime(globalAmp.gain.value,getAudioContext().currentTime),globalAmp.gain.linearRampToValueAtTime(globalAmpGain,getAudioContext().currentTime+.2))}function midiNoteToFrequency(e){let t=440;return Math.pow(2,(e-69)/12)*t}class Note{constructor(t,r){ie(this,"audioContext");ie(this,"osc");ie(this,"amp");ie(this,"ampSustainTime");ie(this,"midiNote");this.midiNote=t,this.audioContext=getAudioContext(),this.osc=new OscillatorNode(this.audioContext,{type:r,frequency:midiNoteToFrequency(this.midiNote)}),this.ampSustainTime=0,this.amp=this.audioContext.createGain(),this.amp.gain.value=0,this.amp.connect(getGlobalAmp()),this.osc.connect(this.amp)}noteOn(){const t=this.audioContext.currentTime;this.osc.start(t),this.ampSustainTime=t+ampAttack+ampDecay,this.amp.gain.linearRampToValueAtTime(ampGain,t+ampAttack),this.amp.gain.linearRampToValueAtTime(ampGain*ampSustain,this.ampSustainTime)}noteOff(){this.audioContext.currentTime>=this.ampSustainTime&&this.amp.gain.setValueAtTime(ampGain*ampSustain,this.audioContext.currentTime);const t=Math.max(this.audioContext.currentTime,this.ampSustainTime)+ampRelease;this.osc.stop(t),this.amp.gain.linearRampToValueAtTime(0,t)}}const useAppSelector=useSelector,useAppDispatch=useDispatch;var TestKeyboardSoundsMode=(e=>(e[e.Random=0]="Random",e[e.WickiHayden=1]="WickiHayden",e[e.Chromatic=2]="Chromatic",e))(TestKeyboardSoundsMode||{});let lastPressedKeys=[],notes={};const baseSeed=Math.floor(Math.random()*1e3),seededRandom=e=>((baseSeed+e)*9301+49297)%233280/233280,calculateMidiNote=(e,t,r,s,a)=>{const l=Math.min(4,r-s-1)+Math.max(0,5-r);switch(e){case 1:return[-18,-19,-14,-9,-4][l]+72+t+a*2;case 2:return[-15,-12,-7,-1,4][l]+72+t+a;case 0:default:return 72+t+Math.floor(seededRandom(s*1e3+a)*24)-12}},turnOffAllTheNotes=()=>{Object.values(notes).forEach(e=>e==null?void 0:e.noteOff())},TestKeyboardSounds=({pressedKeys:e})=>{const{waveform:t,volume:r,mode:s,transpose:a}=useAppSelector(getTestKeyboardSoundsSettings);return reactExports.useEffect(()=>{setGlobalAmpGain(r/100)},[r]),reactExports.useEffect(()=>{if(e.length===0)turnOffAllTheNotes();else{const l=e.length;lastPressedKeys=e.reduce((c,d,p)=>[...c,d.reduce((f,m,y)=>{var M,b;const K=`${p},${y}`,x=((M=lastPressedKeys==null?void 0:lastPressedKeys.at(p))==null?void 0:M.at(y))??TestKeyState.KeyUp,v=m??TestKeyState.KeyUp;if(v!=x)if(v==TestKeyState.KeyDown){const R=calculateMidiNote(s,a,l,p,y);notes[K]=new Note(R,t),notes[K].noteOn()}else v==TestKeyState.KeyUp&&((b=notes[K])==null||b.noteOff());return[...f,m]},[])],[])}},[e]),reactExports.useEffect(()=>()=>{turnOffAllTheNotes()},[]),null},THEMES={OLIVIA_DARK:{alpha:{c:"#363434",t:"#E8C4B8"},mod:{c:"#363434",t:"#E8C4B8"},accent:{c:"#E8C4B8",t:"#363434"}},OLIVE:{alpha:{t:"#66665A",c:"#D9D7C4"},mod:{c:"#66665A",t:"#9DA183"},accent:{c:"#9DA183",t:"#66665A"}},OLIVE_DARK:{alpha:{c:"#66665A",t:"#9DA183"},mod:{c:"#66665A",t:"#9DA183"},accent:{c:"#9DA183",t:"#66665A"}},OLNY:{alpha:{c:"#c20018",t:"#cfa174"},mod:{c:"#c20018",t:"#cfa174"},accent:{t:"#c20018",c:"#cfa174"}},GREG:{alpha:{c:"#f8c200",t:"#393b3b"},mod:{c:"#f7f2ea",t:"#393b3b"},accent:{c:"#171718",t:"#393b3b"}},CARBON_BLACK_A:{alpha:{c:"#788194",t:"#f3f3f3"},mod:{c:"#3b3b3e",t:"#f3f3f3"},accent:{c:"#e66b67",t:"#f3f3f3"}},CARBON_BLACK_B:{alpha:{c:"#3b3b3e",t:"#f3f3f3"},mod:{c:"#788194",t:"#f3f3f3"},accent:{c:"#e66b67",t:"#f3f3f3"}},SILVER_GREY_A:{alpha:{c:"#b2b3b8",t:"#f3f3f3"},mod:{c:"#838589",t:"#f3f3f3"},accent:{c:"#e8db5d",t:"#3d3125"}},SILVER_GREY_B:{alpha:{c:"#838589",t:"#f3f3f3"},mod:{c:"#b2b3b8",t:"#f3f3f3"},accent:{c:"#e8db5d",t:"#3d3125"}},NAVY_BLUE_A:{alpha:{c:"#547be8",t:"#f3f3f3"},mod:{c:"#49599f",t:"#f3f3f3"},accent:{c:"#4dcfe0",t:"#f3f3f3"}},NAVY_BLUE_B:{alpha:{c:"#49599f",t:"#f3f3f3"},mod:{c:"#547be8",t:"#f3f3f3"},accent:{c:"#4dcfe0",t:"#f3f3f3"}},FENDAI:{alpha:{c:"#f0ebec",t:"#07010f"},mod:{c:"#f0ebec",t:"#56395c"},accent:{c:"#fc5d75",t:"#56395c"}},HONEY_MILK:{alpha:{c:"#fffff8",t:"#07010f"},mod:{c:"#fffff8",t:"#07010f"},accent:{c:"#f8b140",t:"#07010f"}},MATCHA:{alpha:{c:"#e8e8df",t:"#4e475c"},mod:{c:"#828572",t:"#4e475c"},accent:{c:"#828572",t:"#4e475c"}},BLACK_GREY:{alpha:{c:"#7e8293",t:"#a5cbe6"},mod:{c:"#364352",t:"#eff3f2"},accent:{c:"#364352",t:"#eff3f2"}},WHITE_GREEN:{alpha:{c:"#fefefe",t:"#272727"},mod:{c:"#275c65",t:"#d0eae8"},accent:{c:"#275c65",t:"#d0eae8"}},WHITE:{alpha:{c:"#fefefe",t:"#272727"},mod:{c:"#fefefe",t:"#272727"},accent:{c:"#fefefe",t:"#272727"}},BLACK:{alpha:{c:"#272727",t:"#fefefe"},mod:{c:"#272727",t:"#fefefe"},accent:{c:"#272727",t:"#fefefe"}},BLACK_AND_WHITE:{alpha:{c:"#fefefe",t:"#272727"},mod:{c:"#272727",t:"#fefefe"},accent:{c:"#272727",t:"#fefefe"}},CLASSIC_GREY:{alpha:{c:"#fcfcfc",t:"#1a1a1a"},mod:{c:"#a0a0a0",t:"#1a1a1a"},accent:{c:"#a0a0a0",t:"#1a1a1a"}},...dist.THEMES};class Store{constructor(t){ie(this,"store");const r=localStorage.getItem("via-app-store");this.store=r?defaultsDeep(JSON.parse(r),t):t}get(t){return this.store[t]}set(t,r){const s={...this.store,[t]:{...r}};this.store=s,setTimeout(()=>{localStorage.setItem("via-app-store",JSON.stringify(s))},0)}}const entryLog=[],logCommand=(e,t,r)=>{entryLog.push({kbAddr:e,request:t,response:r,ts:Date.now()})},getLog=window.__getLogs=()=>entryLog;window.addEventListener("message",e=>{e.data.command==="fetchLogs"&&window.postMessage({command:"getLogs",payload:getLog()},"*")});const useRetry=(e,t)=>async()=>{let s=0;for(;s<=t.retries;)try{await e();break}catch(a){if(s===t.retries)throw console.debug("Retry limit exceeded",s),a;s++,console.debug(a,"retry",s,"after",t.delay),await new Promise(l=>setTimeout(l,t.delay))}},globalBuffer={},eventWaitBuffer={},filterHIDDevices=e=>e.filter(t=>{var r;return(r=t.collections)==null?void 0:r.some(s=>s.usage===97&&s.usagePage===65376)}),getVIAPathIdentifier=()=>self.crypto&&self.crypto.randomUUID&&self.crypto.randomUUID()||`via-path:${Math.random()}`,tagDevice=e=>{const t=e.__path||getVIAPathIdentifier();e.__path=t;const r={_device:e,usage:97,usagePage:65376,interface:1,vendorId:e.vendorId??-1,productId:e.productId??-1,path:t,productName:e.productName};return ExtendedHID._cache[t]=r},tryForgetDevice=e=>{const t=ExtendedHID._cache[e.path];if(t)return t._device.forget()},ExtendedHID={_cache:{},requestDevice:async()=>{const e=await navigator.hid.requestDevice({filters:[{usagePage:65376,usage:97}]});return e.forEach(tagDevice),e[0]},getFilteredDevices:async()=>{try{return filterHIDDevices(await navigator.hid.getDevices())}catch{return[]}},devices:async(e=!1)=>{let t=await ExtendedHID.getFilteredDevices();if(t.length===0||e){try{await ExtendedHID.requestDevice()}catch{return[]}t=await ExtendedHID.getFilteredDevices()}return t.map(tagDevice)},HID:class{constructor(t){ie(this,"_hidDevice");ie(this,"interface",-1);ie(this,"vendorId",-1);ie(this,"productId",-1);ie(this,"productName","");ie(this,"path","");ie(this,"openPromise",Promise.resolve());ie(this,"readP",promisify(t=>this.read(t)));if(this._hidDevice=ExtendedHID._cache[t],this._hidDevice)this.vendorId=this._hidDevice.vendorId,this.productId=this._hidDevice.productId,this.path=this._hidDevice.path,this.interface=this._hidDevice.interface,this.productName=this._hidDevice.productName,globalBuffer[this.path]=globalBuffer[this.path]||[],eventWaitBuffer[this.path]=eventWaitBuffer[this.path]||[],this._hidDevice._device.opened||this.open();else throw new Error("Missing hid device in cache")}async open(){return this._hidDevice&&!this._hidDevice._device.opened&&(this.openPromise=this._hidDevice._device.open(),this.setupListeners(),await this.openPromise),Promise.resolve()}setupListeners(){this._hidDevice&&this._hidDevice._device.addEventListener("inputreport",t=>{eventWaitBuffer[this.path].length!==0?eventWaitBuffer[this.path].shift()(new Uint8Array(t.data.buffer)):globalBuffer[this.path].push({currTime:Date.now(),message:new Uint8Array(t.data.buffer)})})}read(t){var r;this.fastForwardGlobalBuffer(Date.now()),globalBuffer[this.path].length>0?t(void 0,(r=globalBuffer[this.path].shift())==null?void 0:r.message):eventWaitBuffer[this.path].push(s=>t(void 0,s))}fastForwardGlobalBuffer(t){let r=globalBuffer[this.path].length;for(;r&&(r--,globalBuffer[this.path][0].currTime<t);)globalBuffer[this.path].shift()}async write(t){var s;await this.openPromise;const r=new Uint8Array(t.slice(1));(s=this._hidDevice)==null||s._device.sendReport(0,r)}async send(t){await this.openPromise;const r=new Uint8Array(t.slice(1)),s=Date.now();return await useRetry(async()=>{var c;await((c=this._hidDevice)==null?void 0:c._device.sendReport(0,r))},{retries:3,delay:0})(),new Promise(c=>{var d;this.fastForwardGlobalBuffer(s),globalBuffer[this.path].length>0?c((d=globalBuffer[this.path].shift())==null?void 0:d.message):eventWaitBuffer[this.path].push(p=>c(p))})}}},promisify=e=>()=>new Promise((t,r)=>{e((s,a)=>{s?r(s):t(a)})}),HID=ExtendedHID,Ue=class Ue{static startMonitoring(){this.shouldMonitor=!0,!this.hasMonitored&&navigator.hid&&(navigator.hid.addEventListener("connect",Ue.onConnect),navigator.hid.addEventListener("disconnect",Ue.onDisconnect))}static stopMonitoring(){this.shouldMonitor=!1}static on(t,r){this._listeners[t]=[...this._listeners[t],r]}static off(t,r){this._listeners[t]=this._listeners[t].filter(s=>s!==r)}};ie(Ue,"_listeners",{change:[],remove:[]}),ie(Ue,"shouldMonitor",!1),ie(Ue,"hasMonitored",!1),ie(Ue,"onConnect",({device:t})=>{console.log("Detected Connection"),Ue.shouldMonitor&&Ue._listeners.change.forEach(r=>r(t))}),ie(Ue,"onDisconnect",({device:t})=>{console.log("Detected Disconnection"),Ue.shouldMonitor&&(Ue._listeners.change.forEach(r=>r(t)),Ue._listeners.remove.forEach(r=>r(t)))});let usbDetect=Ue;async function scanDevices(e){return HID.devices(e)}function initAndConnectDevice({path:e}){return new HID.HID(e)}function startMonitoring(){usbDetect.startMonitoring()}const extractDeviceInfo=e=>({productId:e.productId,vendorId:e.vendorId,productName:e.productName,protocol:e.protocol}),initialState$c={appErrors:[]},getErrorTimestamp=()=>{const e=new Date;return`${e.toLocaleTimeString([],{hour12:!1})}.${e.getMilliseconds().toString().padStart(3,"0")}`},extractMessageFromKeyboardAPIError=e=>`Command Name: ${e.commandName}
|
|
2
|
+
Command: ${formatBytes(e.commandBytes)}
|
|
3
|
+
Response: ${formatBytes(e.responseBytes)}`,getMessageFromError=e=>e.stack||e.message,formatBytes=e=>e.join(" "),errorsSlice=createSlice({name:"errors",initialState:initialState$c,reducers:{logAppError:(e,t)=>{e.appErrors.push({...t.payload,timestamp:getErrorTimestamp()})},logKeyboardAPIError:(e,t)=>{const{deviceInfo:r}=t.payload;e.appErrors.push({timestamp:getErrorTimestamp(),message:extractMessageFromKeyboardAPIError(t.payload),deviceInfo:r})},clearAppErrors:e=>{e.appErrors=[]}}}),{logKeyboardAPIError,logAppError,clearAppErrors}=errorsSlice.actions,errorsReducer=errorsSlice.reducer,getAppErrors=e=>e.errors.appErrors,maxBitSize=5,packBits=e=>e.reduce((t,[r,s])=>t<<minBitSize(s)|r,0)>>>0,numIntoBytes=e=>[e>>24,e>>16,e>>8,e].map(t=>t&255),bytesIntoNum=e=>(e[0]<<24|e[1]<<16|e[2]<<8|e[3])>>>0,unpackBits=(e,t)=>t.reverse().reduce(({res:r,bits:s},a)=>({bits:s>>minBitSize(a),res:[s&(1<<minBitSize(a))-1,...r]}),{bits:e,res:[]}).res,minBitSize=e=>1+Array(maxBitSize).fill(0).findIndex((t,r)=>2<<r>=e),COMMAND_START=0,PER_KEY_RGB_CHANNEL_COMMAND=[0,1];var APICommand=(e=>(e[e.GET_PROTOCOL_VERSION=1]="GET_PROTOCOL_VERSION",e[e.GET_KEYBOARD_VALUE=2]="GET_KEYBOARD_VALUE",e[e.SET_KEYBOARD_VALUE=3]="SET_KEYBOARD_VALUE",e[e.DYNAMIC_KEYMAP_GET_KEYCODE=4]="DYNAMIC_KEYMAP_GET_KEYCODE",e[e.DYNAMIC_KEYMAP_SET_KEYCODE=5]="DYNAMIC_KEYMAP_SET_KEYCODE",e[e.CUSTOM_MENU_SET_VALUE=7]="CUSTOM_MENU_SET_VALUE",e[e.CUSTOM_MENU_GET_VALUE=8]="CUSTOM_MENU_GET_VALUE",e[e.CUSTOM_MENU_SAVE=9]="CUSTOM_MENU_SAVE",e[e.EEPROM_RESET=10]="EEPROM_RESET",e[e.BOOTLOADER_JUMP=11]="BOOTLOADER_JUMP",e[e.DYNAMIC_KEYMAP_MACRO_GET_COUNT=12]="DYNAMIC_KEYMAP_MACRO_GET_COUNT",e[e.DYNAMIC_KEYMAP_MACRO_GET_BUFFER_SIZE=13]="DYNAMIC_KEYMAP_MACRO_GET_BUFFER_SIZE",e[e.DYNAMIC_KEYMAP_MACRO_GET_BUFFER=14]="DYNAMIC_KEYMAP_MACRO_GET_BUFFER",e[e.DYNAMIC_KEYMAP_MACRO_SET_BUFFER=15]="DYNAMIC_KEYMAP_MACRO_SET_BUFFER",e[e.DYNAMIC_KEYMAP_MACRO_RESET=16]="DYNAMIC_KEYMAP_MACRO_RESET",e[e.DYNAMIC_KEYMAP_GET_LAYER_COUNT=17]="DYNAMIC_KEYMAP_GET_LAYER_COUNT",e[e.DYNAMIC_KEYMAP_GET_BUFFER=18]="DYNAMIC_KEYMAP_GET_BUFFER",e[e.DYNAMIC_KEYMAP_SET_BUFFER=19]="DYNAMIC_KEYMAP_SET_BUFFER",e[e.DYNAMIC_KEYMAP_GET_ENCODER=20]="DYNAMIC_KEYMAP_GET_ENCODER",e[e.DYNAMIC_KEYMAP_SET_ENCODER=21]="DYNAMIC_KEYMAP_SET_ENCODER",e[e.BACKLIGHT_CONFIG_SET_VALUE=7]="BACKLIGHT_CONFIG_SET_VALUE",e[e.BACKLIGHT_CONFIG_GET_VALUE=8]="BACKLIGHT_CONFIG_GET_VALUE",e[e.BACKLIGHT_CONFIG_SAVE=9]="BACKLIGHT_CONFIG_SAVE",e[e.TAB_CDC_SUPPORT=191]="TAB_CDC_SUPPORT",e[e.TAB_ACTUATION=208]="TAB_ACTUATION",e[e.TAB_BLOCKS=209]="TAB_BLOCKS",e))(APICommand||{});const APICommandValueToName=Object.entries(APICommand).reduce((e,[t,r])=>({...e,[r]:t}),{});var KeyboardValue=(e=>(e[e.UPTIME=1]="UPTIME",e[e.LAYOUT_OPTIONS=2]="LAYOUT_OPTIONS",e[e.SWITCH_MATRIX_STATE=3]="SWITCH_MATRIX_STATE",e[e.FIRMWARE_VERSION=4]="FIRMWARE_VERSION",e[e.DEVICE_INDICATION=5]="DEVICE_INDICATION",e))(KeyboardValue||{});const BACKLIGHT_BRIGHTNESS=9,BACKLIGHT_EFFECT=10,BACKLIGHT_COLOR_1=12,BACKLIGHT_COLOR_2=13,BACKLIGHT_CUSTOM_COLOR=23,PROTOCOL_ALPHA=7,PROTOCOL_BETA=8,PROTOCOL_GAMMA=9,cache$1={},eqArr=(e,t)=>e.length!==t.length?!1:e.every((r,s)=>t[s]===r),shiftTo16Bit=([e,t])=>e<<8|t,shiftFrom16Bit=e=>[e>>8,e&255],shiftBufferTo16Bit=e=>{const t=[];for(let r=0;r<e.length;r+=2)t.push(shiftTo16Bit([e[r],e[r+1]]));return t},shiftBufferFrom16Bit=e=>e.map(shiftFrom16Bit).flatMap(t=>t),globalCommandQueue={},canConnect=e=>{try{return new KeyboardAPI(e.path),!0}catch(t){return console.error("Skipped ",e,t),!1}};class KeyboardAPI{constructor(t){ie(this,"kbAddr");if(this.kbAddr=t,!cache$1[t]){const r=initAndConnectDevice({path:t});cache$1[t]={hid:r}}}async init(){}refresh(t){this.kbAddr=t,cache$1[t]={...cache$1[t],hid:initAndConnectDevice({path:t})}}async getByteBuffer(){return this.getHID().readP()}async getProtocolVersion(){try{const[,t,r]=await this.hidCommand(1);return shiftTo16Bit([t,r])}catch{return-1}}async getFirmwareVersion(){try{const t=await this.getKeyboardValue(4,[],4);return bytesIntoNum(t)}catch{return 0}}async getKey(t,r,s){const a=await this.hidCommand(4,[t,r,s]);return shiftTo16Bit([a[4],a[5]])}async getLayerCount(){if(await this.getProtocolVersion()>=PROTOCOL_BETA){const[,r]=await this.hidCommand(17);return r}return 4}async readRawMatrix(t,r){const s=await this.getProtocolVersion();if(s>=PROTOCOL_BETA)return this.fastReadRawMatrix(t,r);if(s===PROTOCOL_ALPHA)return this.slowReadRawMatrix(t,r);throw new Error("Unsupported protocol version")}async getKeymapBuffer(t,r){if(r>28)throw new Error("Max data length is 28");return[...await this.hidCommand(18,[...shiftFrom16Bit(t),r])].slice(4,r+4)}async fastReadRawMatrix({rows:t,cols:r},s){const a=t*r,l=14,c=new Array(Math.ceil(a/l)).fill(0),{res:d}=c.reduce(({res:f,remaining:m})=>m<l?{res:[...f,this.getKeymapBuffer(s*a*2+2*(a-m),m*2)],remaining:0}:{res:[...f,this.getKeymapBuffer(s*a*2+2*(a-m),l*2)],remaining:m-l},{res:[],remaining:a});return(await Promise.all(d)).flatMap(shiftBufferTo16Bit)}async slowReadRawMatrix({rows:t,cols:r},s){const a=t*r,l=new Array(a).fill(0).map((c,d)=>this.getKey(s,~~(d/r),d%r));return Promise.all(l)}async writeRawMatrix(t,r){const s=await this.getProtocolVersion();if(s>=PROTOCOL_BETA)return this.fastWriteRawMatrix(r);if(s===PROTOCOL_ALPHA)return this.slowWriteRawMatrix(t,r)}async slowWriteRawMatrix({cols:t},r){r.forEach(async(s,a)=>s.forEach(async(l,c)=>{await this.setKey(a,~~(c/t),c%t,l)}))}async fastWriteRawMatrix(t){const r=t.flatMap(l=>l.map(c=>c)),s=shiftBufferFrom16Bit(r),a=28;for(let l=0;l<s.length;l+=a){const c=s.slice(l,l+a);await this.hidCommand(19,[...shiftFrom16Bit(l),c.length,...c])}}async getKeyboardValue(t,r,s=1){const a=[t,...r];return(await this.hidCommand(2,a)).slice(1+a.length,1+a.length+s)}async setKeyboardValue(t,...r){const s=[t,...r];await this.hidCommand(3,s)}async getEncoderValue(t,r,s){const a=[t,r,+s],l=await this.hidCommand(20,a);return shiftTo16Bit([l[4],l[5]])}async setEncoderValue(t,r,s,a){const l=[t,r,+s,...shiftFrom16Bit(a)];await this.hidCommand(21,l)}async getCustomMenuValue(t){return(await this.hidCommand(8,t)).slice(0+t.length)}async setCustomMenuValue(...t){await this.hidCommand(7,t)}async getPerKeyRGBMatrix(t){return(await Promise.all(t.map(s=>this.hidCommand(8,[...PER_KEY_RGB_CHANNEL_COMMAND,s,1])))).map(s=>[...s.slice(5,7)])}async setPerKeyRGBMatrix(t,r,s){await this.hidCommand(7,[...PER_KEY_RGB_CHANNEL_COMMAND,t,1,r,s])}async getBacklightValue(t,r=1){const s=[t];return(await this.hidCommand(8,s)).slice(2,2+r)}async setBacklightValue(t,...r){const s=[t,...r];await this.hidCommand(7,s)}async getRGBMode(){const t=[BACKLIGHT_EFFECT],[,,r]=await this.hidCommand(8,t);return r}async getBrightness(){const t=[BACKLIGHT_BRIGHTNESS],[,,r]=await this.hidCommand(8,t);return r}async getColor(t){const r=[t===1?BACKLIGHT_COLOR_1:BACKLIGHT_COLOR_2],[,,s,a]=await this.hidCommand(8,r);return{hue:s,sat:a}}async setColor(t,r,s){const a=[t===1?BACKLIGHT_COLOR_1:BACKLIGHT_COLOR_2,r,s];await this.hidCommand(7,a)}async getCustomColor(t){const r=[BACKLIGHT_CUSTOM_COLOR,t],[,,,s,a]=await this.hidCommand(8,r);return{hue:s,sat:a}}async setCustomColor(t,r,s){const a=[BACKLIGHT_CUSTOM_COLOR,t,r,s];await this.hidCommand(7,a)}async setRGBMode(t){const r=[BACKLIGHT_EFFECT,t];await this.hidCommand(7,r)}async commitCustomMenu(t){await this.hidCommand(9,[t])}async saveLighting(){await this.hidCommand(9)}async resetEEPROM(){await this.hidCommand(10)}async jumpToBootloader(){await this.hidCommand(11)}async setKey(t,r,s,a){const l=await this.hidCommand(5,[t,r,s,...shiftFrom16Bit(a)]);return shiftTo16Bit([l[4],l[5]])}async getMacroCount(){const[,t]=await this.hidCommand(12);return t}async getMacroBufferSize(){const[,t,r]=await this.hidCommand(13);return shiftTo16Bit([t,r])}async getMacroBytes(){const t=await this.getMacroBufferSize(),r=28,s=[];for(let l=0;l<t;l+=28)s.push(this.hidCommand(14,[...shiftFrom16Bit(l),r]));return(await Promise.all(s)).flatMap(l=>l.slice(4))}async setMacroBytes(t){const r=await this.getMacroBufferSize(),s=t.length;if(s>r)throw new Error(`Macro size (${s}) exceeds buffer size (${r})`);const a=r-1,l=shiftFrom16Bit(a);await this.resetMacros();try{await this.hidCommand(15,[...shiftFrom16Bit(a),1,255]);const c=28;for(let d=0;d<t.length;d+=c){const p=t.slice(d,d+c);await this.hidCommand(15,[...shiftFrom16Bit(d),p.length,...p])}}finally{await this.hidCommand(15,[...l,1,0])}}async resetMacros(){await this.hidCommand(16)}async getMatrixLightingTexts(t,r){const a=[];for(let f=0;f<t;f++)for(let m=0;m<r;m+=26)a.push(this.hidCommand(8,[26,5,f,m,Math.min(r-m,26)]));const c=(await Promise.all(a)).flatMap(f=>f.slice(6,6+26)),d=Math.ceil(r/26),p=[];for(let f=0;f<t;f++){let m="";for(let y=0;y<r;y++){const K=c[f*26*d+y];K!==0&&(m=m+String.fromCharCode(K))}p[f]=m}return p}async setMatrixLightingTexts(t,r,s){const a=[],c=[...s[t]].map(d=>d.charCodeAt(0));for(let d=0;d<r;d+=26){const p=Math.min(r-d,26),f=c.slice(d,d+p);a.push(this.hidCommand(7,[26,5,t,d,p,...f]))}await Promise.all(a)}async getMatrixLightingInfoContent(){const[,,,t]=await this.hidCommand(8,[26,6]);return t}async setMatrixLightingInfoContent(t){return this.hidCommand(7,[26,6,t])}async getCDCSupport(){try{const[,t]=await this.hidCommand(191);return t===void 0?t:!!t}catch{return}}async setMatrixLighting(t,r,s,a,l){const c=await this.hidCommand(209,[48,t,r,s,a]);if(c&&c[c.length-1]){const p=new Error("Error: "+c[c.length-1]);throw p.cause=c[c.length-1],p}const d=25;for(let p=0;p<l.length;p+=d){const f=l.slice(p,p+d);await this.hidCommand(209,[49,...numIntoBytes(p),f.length,...f])}}async setTabFile(t,r,s){const a=await this.hidCommand(209,[32,...t.slice(0,20)]);if(a&&a[a.length-1]){const c=new Error("Error: "+a[a.length-1]);throw c.cause=a[a.length-1],c}const l=25;for(let c=0;c<t.length;c+=l){const d=t.slice(c,c+l);if(await this.hidCommand(209,[33,...numIntoBytes(c),d.length,...d]),s&&s()){await this.hidCommand(209,[34]);return}r&&r(c+d.length)}}async setTabFirmwareInfo(t,r){if(bytesIntoNum(r.slice(0,4).reverse())!==171066965&&bytesIntoNum(r.slice(4,8).reverse())!==2656915799)return console.log("invalid file"),[!1,0];const s=r.slice(3*4,3*4+4),a=r.slice(4*4,4*4+4),l=r.slice(6*4,6*4+4),c=r.slice(7*4,7*4+4),d=[16,...numIntoBytes(t),...s,...a,...l,...c],p=await this._hidCommand(209,d);return p&&p[p.length-1]?[!1,0]:[!0,0]}async setTabFirmwareBuffer(t,r,s,a){for(let c=0;c<t.length;c+=16){const d=t.slice(c,c+16);if(await this.hidCommand(209,[17,...numIntoBytes(c),d.length,...d]),s&&s())return;r&&r(c+d.length)}}async actuationCommand(t,r=[]){return await this.hidCommand(208,[t,...r])}get commandQueueWrapper(){return globalCommandQueue[this.kbAddr]?globalCommandQueue[this.kbAddr]:(globalCommandQueue[this.kbAddr]={isFlushing:!1,commandQueue:[]},globalCommandQueue[this.kbAddr])}async timeout(t){return new Promise((r,s)=>{this.commandQueueWrapper.commandQueue.push({res:r,rej:s,args:()=>new Promise(a=>setTimeout(()=>{a(),r(void 0)},t))}),this.commandQueueWrapper.isFlushing||this.flushQueue()})}async hidCommand(t,r=[]){return new Promise((s,a)=>{this.commandQueueWrapper.commandQueue.push({res:s,rej:a,args:[t,r]}),this.commandQueueWrapper.isFlushing||this.flushQueue()})}async flushQueue(){if(this.commandQueueWrapper.isFlushing!==!0){for(this.commandQueueWrapper.isFlushing=!0;this.commandQueueWrapper.commandQueue.length!==0;){const{res:t,rej:r,args:s}=this.commandQueueWrapper.commandQueue.shift();if(typeof s=="function")await s(),t();else try{const a=await this._hidCommand(...s);t(a)}catch(a){const l=extractDeviceInfo(this.getHID());store.dispatch(logAppError({message:getMessageFromError(a),deviceInfo:l})),r(a)}}this.commandQueueWrapper.isFlushing=!1}}getHID(){return cache$1[this.kbAddr].hid}async _hidCommand(t,r=[]){const s=[COMMAND_START,t,...r],a=new Array(33).fill(0);s.forEach((p,f)=>{a[f]=p});const l=await this.getHID().send(a),c=Array.from(l),d=c.slice(0,s.length-1);if(logCommand(this.kbAddr,s,c),([8,7,9].includes(t)&&r[0]===66||[208,191].includes(t))&&eqArr([255],c.slice(0,1))&&eqArr(s.slice(2),d.slice(1)))return console.debug(`Command for ${this.kbAddr}`,s,"Bad Resp:",c),[];if(!eqArr(s.slice(1),d)){console.error(`Command for ${this.kbAddr}:`,s,"Bad Resp:",c);const p=extractDeviceInfo(this.getHID()),f=APICommandValueToName[t];throw store.dispatch(logKeyboardAPIError({commandName:f,commandBytes:s.slice(1),responseBytes:c,deviceInfo:p})),new Error("Receiving incorrect response for command")}return t===208&&console.debug(`Command for ${this.kbAddr}`,s,"Correct Resp:",c),c}}function getVendorProductId(e,t){return e*65536+t}const idExists=({productId:e,vendorId:t},r)=>r[getVendorProductId(t,e)],getRecognisedDevices=async(e,t=!1)=>(await scanDevices(t)).filter(s=>idExists(s,e)&&canConnect(s));let deviceStore;const defaultStoreData={definitionIndex:{generatedAt:-1,hash:"",version:"2.0.0",theme:dist.getTheme(),accentColor:"#ad7070",supportedVendorProductIdMap:{}},definitions:{},settings:{showDesignTab:!1,disableFastRemap:!1,renderMode:"2D",themeMode:"dark",designDefinitionVersion:"v3",themeName:"OLIVIA_DARK",macroEditor:{smartOptimizeEnabled:!0,recordDelaysEnabled:!1,tapEnterAtEOMEnabled:!1},testKeyboardSoundsSettings:{isEnabled:!0,volume:100,waveform:"sine",mode:TestKeyboardSoundsMode.WickiHayden,transpose:0}}};function initDeviceStore(){deviceStore=new Store(defaultStoreData)}initDeviceStore();async function syncStore(){var t;const e=deviceStore.get("definitionIndex");try{const r=((t=document.getElementById("definition_hash"))==null?void 0:t.dataset.hash)||"";if(r===e.hash)return e;const s={...defaultStoreData.definitionIndex,hash:r};return deviceStore.set("definitionIndex",s),deviceStore.set("definitions",{}),s}catch(r){console.warn(r)}return e}const getMissingDefinition=async(e,t)=>{const r=getVendorProductId(e.vendorId,e.productId),s=`/definitions/${t}/${r}.json`,l=await(await fetch(s)).json();let c=deviceStore.get("definitions");const d={...c,[r]:{...c[r],[t]:l}};try{deviceStore.set("definitions",d)}catch{localStorage.clear(),initDeviceStore(),c=deviceStore.get("definitions"),deviceStore.set("definitions",{...c,[r]:{...c[r],[t]:l}})}return[l,t]},getSupportedIdsFromStore=()=>{var e;return(e=deviceStore.get("definitionIndex"))==null?void 0:e.supportedVendorProductIdMap},getDefinitionsFromStore=()=>deviceStore.get("definitions"),getThemeModeFromStore=()=>{var e;return(e=deviceStore.get("settings"))==null?void 0:e.themeMode},getThemeNameFromStore=()=>{var e;return(e=deviceStore.get("settings"))==null?void 0:e.themeName},getSettings=()=>deviceStore.get("settings"),setSettings=e=>{deviceStore.set("settings",D(e))},quantumRangesKeys=["_QK_MODS","_QK_MODS_MAX","_QK_MOD_TAP","_QK_MOD_TAP_MAX","_QK_LAYER_TAP","_QK_LAYER_TAP_MAX","_QK_LAYER_MOD","_QK_LAYER_MOD_MAX","_QK_TO","_QK_TO_MAX","_QK_MOMENTARY","_QK_MOMENTARY_MAX","_QK_DEF_LAYER","_QK_DEF_LAYER_MAX","_QK_TOGGLE_LAYER","_QK_TOGGLE_LAYER_MAX","_QK_ONE_SHOT_LAYER","_QK_ONE_SHOT_LAYER_MAX","_QK_ONE_SHOT_MOD","_QK_ONE_SHOT_MOD_MAX","_QK_LAYER_TAP_TOGGLE","_QK_LAYER_TAP_TOGGLE_MAX","_QK_KB","_QK_KB_MAX","_QK_MACRO","_QK_MACRO_MAX","_QK_TAP_DANCE","_QK_TAP_DANCE_MAX"],quantumRanges=e=>Object.keys(e).reduce((t,r)=>quantumRangesKeys.includes(r)?{...t,[r]:e[r]}:t,{}),modCodes={QK_LCTL:256,QK_LSFT:512,QK_LALT:1024,QK_LGUI:2048,QK_RMODS_MIN:4096,QK_RCTL:4352,QK_RSFT:4608,QK_RALT:5120,QK_RGUI:6144},modMasks={MOD_LCTL:1,MOD_LSFT:2,MOD_LALT:4,MOD_LGUI:8,MOD_RCTL:17,MOD_RSFT:18,MOD_RALT:20,MOD_RGUI:24,MOD_HYPR:15,MOD_MEH:7},topLevelMacroToValue={MT:"_QK_MOD_TAP",LT:"_QK_LAYER_TAP",LM:"_QK_LAYER_MOD",TO:"_QK_TO",MO:"_QK_MOMENTARY",DF:"_QK_DEF_LAYER",TG:"_QK_TOGGLE_LAYER",OSL:"_QK_ONE_SHOT_LAYER",OSM:"_QK_ONE_SHOT_MOD",TT:"_QK_LAYER_TAP_TOGGLE",CUSTOM:"_QK_KB",MACRO:"_QK_MACRO",TD:"_QK_TAP_DANCE"},modifierKeyToValue={LCTL:modCodes.QK_LCTL,C:modCodes.QK_LCTL,LSFT:modCodes.QK_LSFT,S:modCodes.QK_LSFT,LALT:modCodes.QK_LALT,A:modCodes.QK_LALT,LGUI:modCodes.QK_LGUI,LCMD:modCodes.QK_LGUI,LWIN:modCodes.QK_LGUI,G:modCodes.QK_LGUI,RCTL:modCodes.QK_RCTL,RSFT:modCodes.QK_RSFT,ALGR:modCodes.QK_RALT,RALT:modCodes.QK_RALT,RCMD:modCodes.QK_RGUI,RWIN:modCodes.QK_RGUI,RGUI:modCodes.QK_RGUI,SCMD:modCodes.QK_LSFT|modCodes.QK_LGUI,SWIN:modCodes.QK_LSFT|modCodes.QK_LGUI,SGUI:modCodes.QK_LSFT|modCodes.QK_LGUI,LSG:modCodes.QK_LSFT|modCodes.QK_LGUI,LAG:modCodes.QK_LALT|modCodes.QK_LGUI,RSG:modCodes.QK_RSFT|modCodes.QK_RGUI,RAG:modCodes.QK_RALT|modCodes.QK_RGUI,LCA:modCodes.QK_LCTL|modCodes.QK_LALT,LSA:modCodes.QK_LSFT|modCodes.QK_LALT,SAGR:modCodes.QK_RSFT|modCodes.QK_RALT,RSA:modCodes.QK_RSFT|modCodes.QK_RALT,RCS:modCodes.QK_RCTL|modCodes.QK_RSFT,LCAG:modCodes.QK_LCTL|modCodes.QK_LALT|modCodes.QK_LGUI,MEH:modCodes.QK_LCTL|modCodes.QK_LALT|modCodes.QK_LSFT,HYPR:modCodes.QK_LCTL|modCodes.QK_LALT|modCodes.QK_LSFT|modCodes.QK_LGUI},modifierValueToKey=Object.entries(modifierKeyToValue).reduce((e,[t,r])=>({...e,[r]:t}),{}),leftModifierValueToKey=Object.entries(modifierKeyToValue).filter(([e,t])=>Object.values(modCodes).includes(t)&&t<modCodes.QK_RMODS_MIN).reduce((e,[t,r])=>({...e,[r]:t}),{}),rightModifierValueToKey=Object.entries(modifierKeyToValue).filter(([e,t])=>Object.values(modCodes).includes(t)&&t>=modCodes.QK_RMODS_MIN).reduce((e,[t,r])=>({...e,[r]:t}),{}),topLevelValueToMacro=e=>Object.entries(topLevelMacroToValue).reduce((t,[r,s])=>({...t,[e[s]]:r}),{}),advancedStringToKeycode=(e,t)=>{const s=e.toUpperCase().split(/\(|\)/).map(a=>a.trim());return Object.keys(topLevelMacroToValue).includes(s[0])?parseTopLevelMacro(s,t):Object.keys(modifierKeyToValue).includes(s[0])?parseModifierCode(s,t):0},advancedKeycodeToString=(e,t,r)=>{let s=Object.entries(quantumRanges(t)).map(([K,x])=>[x,K]).sort((K,x)=>K[0]-x[0]),a=null,l=-1;for(let K=0;K<s.length;K+=2)e>=s[K][0]&&e<=s[K+1][0]&&(a=s[K][1],l=+s[K][0]);if(["_QK_MODS"].includes(a))return topLevelModToString(e,r);let d=topLevelValueToMacro(t)[l]+"(",p=e&~l,f=0,m="",y=0;switch(a){case"_QK_KB":case"_QK_MACRO":case"_QK_TAP_DANCE":d+=e-l+")";break;case"_QK_MOMENTARY":case"_QK_DEF_LAYER":case"_QK_TOGGLE_LAYER":case"_QK_ONE_SHOT_LAYER":case"_QK_LAYER_TAP_TOGGLE":case"_QK_TO":d+=p+")";break;case"_QK_LAYER_TAP":f=p>>8,m=r[p&255],d+=f+","+m+")";break;case"_QK_ONE_SHOT_MOD":d+=modValueToString(p)+")";break;case"_QK_LAYER_MOD":let K=t._QK_LAYER_MOD_MASK,x=Math.log2(K+1);f=p>>x,y=p&K,d+=f+","+modValueToString(y)+")";break;case"_QK_MOD_TAP":y=p>>8&31,m=r[p&255],d+=modValueToString(y)+","+m+")";break;default:d=null}return d},modValueToString=e=>{const t=["MOD_HYPR","MOD_MEH"];return Object.entries(modMasks).filter(s=>!t.includes(s[0])&&(s[1]&e)===s[1]).map(s=>s[0]).join(" | ")},topLevelModToString=(e,t)=>{const r=t[e&255],s=e&7936,a=modifierValueToKey[s];if(a!=null)return a+"("+r+")";const l=Object.entries(s&modCodes.QK_RMODS_MIN?rightModifierValueToKey:leftModifierValueToKey).filter(c=>{const d=Number.parseInt(c[0]);return(d&s)===d}).map(c=>c[1]);return l.join("(")+"("+r+")".repeat(l.length)},parseTopLevelMacro=(e,t)=>{const r=e[0],s=e[1]??"";let[a,l]=["",""],c=0,d=0;switch(r){case"MO":case"DF":case"TG":case"OSL":case"TT":case"TO":return c=Number.parseInt(s),c<0?0:t[topLevelMacroToValue[r]]|c&255;case"OSM":return d=parseMods(s),d===0?0:t[topLevelMacroToValue[r]]|d&255;case"LM":[a,l]=s.split(",").map(m=>m.trim());let p=t._QK_LAYER_MOD_MASK,f=Math.log2(p+1);return c=Number.parseInt(a),d=parseMods(l),c<0||d===0?0:t[topLevelMacroToValue[r]]|(c&15)<<f|d&p;case"LT":return[a,l]=s.split(",").map(m=>m.trim()),c=Number.parseInt(a),c<0||!t.hasOwnProperty(l)?0:t[topLevelMacroToValue[r]]|(c&15)<<8|t[l];case"MT":return[a,l]=s.split(",").map(m=>m.trim()),d=parseMods(a),d===0||!t.hasOwnProperty(l)?0:t[topLevelMacroToValue[r]]|(d&31)<<8|t[l]&255;case"CUSTOM":{const m=Number.parseInt(s),y=t._QK_KB_MAX-t._QK_KB;return m>=0&&m<=y?t[topLevelMacroToValue[r]]+m:0}case"MACRO":{const m=Number.parseInt(s),y=t._QK_MACRO_MAX-t._QK_MACRO;return m>=0&&m<=y?t[topLevelMacroToValue[r]]+m:0}case"TD":{const m=Number.parseInt(s),y=t._QK_TAP_DANCE_MAX-t._QK_TAP_DANCE;return m>=0&&m<=y?t[topLevelMacroToValue[r]]+m:0}default:return 0}},parseMods=(e="")=>{const t=e.split("|").map(r=>r.trim());return t.reduce((r,s)=>r&&modMasks.hasOwnProperty(s),!0)?t.reduce((r,s)=>r|modMasks[s],0):0},parseModifierCode=(e,t)=>{const r=e.filter(a=>a.length!==0),s=r.map((a,l)=>l===r.length-1?t.hasOwnProperty(a)?t[a]:null:modifierKeyToValue.hasOwnProperty(a)?modifierKeyToValue[a]:null);return s.find(a=>a===null)?0:s.reduce((a,l)=>a|l,0)},anyKeycodeToString=(e,t,r)=>{let s="";const a=advancedKeycodeToString(e,t,r);return r[e]&&!r[e].startsWith("_QK")?s=r[e]:a!==null&&(s=a),s};function isAlpha(e){return/[A-Za-z]/.test(e)&&e.length===1}function isNumpadNumber(e){return/['0-9]/.test(e)&&e.length===1}function isArrowKey(e){return/[๐ ๐ ๐ ๐ โโโโ]$/.test(e)}function isNumpadSymbol(e){const t="-+.รทร".split("");return e.length===1&&t.includes(e[0])}function isMultiLegend(e){const t='~!@#$%^&*()_+|{}:"<>?'.split("");return e.length!==1&&t.includes(e[0])}function getByteForCode(e,t){const r=t[e];if(r!==void 0)return r;if(isLayerCode(e))return getByteForLayerCode(e,t);if(advancedStringToKeycode(e,t)!==null)return advancedStringToKeycode(e,t);throw`Could not find byte for ${e}`}function isLayerCode(e){return/([A-Za-z]+)\((\d+)\)/.test(e)}function getByteForLayerCode(e,t){const r=e.match(/([A-Za-z]+)\((\d+)\)/);if(r){const[,s,a]=r,l=parseInt(a);switch(s){case"TO":return Math.min(t._QK_TO+l,t._QK_TO_MAX);case"MO":return Math.min(t._QK_MOMENTARY+l,t._QK_MOMENTARY_MAX);case"DF":return Math.min(t._QK_DEF_LAYER+l,t._QK_DEF_LAYER_MAX);case"TG":return Math.min(t._QK_TOGGLE_LAYER+l,t._QK_TOGGLE_LAYER_MAX);case"OSL":return Math.min(t._QK_ONE_SHOT_LAYER+l,t._QK_ONE_SHOT_LAYER_MAX);case"TT":return Math.min(t._QK_LAYER_TAP_TOGGLE+l,t._QK_LAYER_TAP_TOGGLE_MAX);case"CUSTOM":return Math.min(t._QK_KB+l,t._QK_KB_MAX);case"MACRO":return Math.min(t._QK_MACRO+l,t._QK_MACRO_MAX);case"TD":return Math.min(t._QK_TAP_DANCE+l,t._QK_TAP_DANCE_MAX);default:throw new Error("Incorrect code")}}throw new Error("No match found")}function getCodeForLayerByte(e,t){if(t._QK_TO<=e&&t._QK_TO_MAX>=e)return`TO(${e-t._QK_TO})`;if(t._QK_MOMENTARY<=e&&t._QK_MOMENTARY_MAX>=e)return`MO(${e-t._QK_MOMENTARY})`;if(t._QK_DEF_LAYER<=e&&t._QK_DEF_LAYER_MAX>=e)return`DF(${e-t._QK_DEF_LAYER})`;if(t._QK_TOGGLE_LAYER<=e&&t._QK_TOGGLE_LAYER_MAX>=e)return`TG(${e-t._QK_TOGGLE_LAYER})`;if(t._QK_ONE_SHOT_LAYER<=e&&t._QK_ONE_SHOT_LAYER_MAX>=e)return`OSL(${e-t._QK_ONE_SHOT_LAYER})`;if(t._QK_LAYER_TAP_TOGGLE<=e&&t._QK_LAYER_TAP_TOGGLE_MAX>=e)return`TT(${e-t._QK_LAYER_TAP_TOGGLE})`;if(t._QK_KB<=e&&t._QK_KB_MAX>=e)return`CUSTOM(${e-t._QK_KB})`;if(t._QK_MACRO<=e&&t._QK_MACRO_MAX>=e)return`MACRO(${e-t._QK_MACRO})`}const keycodesList=getKeycodes().reduce((e,t)=>e.concat(t.keycodes),[]),getByteToKey=e=>Object.keys(e).reduce((t,r)=>{const s=e[r];if(s in t){const a=keycodesList.find(({code:l})=>l===r);return a?{...t,[s]:a.code}:t}return{...t,[s]:r}},{});function isLayerKey(e,t){return[[t._QK_TO,t._QK_TO_MAX],[t._QK_MOMENTARY,t._QK_MOMENTARY_MAX],[t._QK_DEF_LAYER,t._QK_DEF_LAYER_MAX],[t._QK_TOGGLE_LAYER,t._QK_TOGGLE_LAYER_MAX],[t._QK_ONE_SHOT_LAYER,t._QK_ONE_SHOT_LAYER_MAX],[t._QK_LAYER_TAP_TOGGLE,t._QK_LAYER_TAP_TOGGLE_MAX],[t._QK_KB,t._QK_KB_MAX],[t._QK_MACRO,t._QK_MACRO_MAX]].some(r=>e>=r[0]&&e<=r[1])}function getCodeForByte(e,t,r){const s=r[e];return s&&!s.startsWith("_QK")?s:isLayerKey(e,t)?getCodeForLayerByte(e,t):advancedKeycodeToString(e,t,r)!==null?advancedKeycodeToString(e,t,r):"0x"+Number(e).toString(16)}function keycodeInMaster(e,t){return e in t||isLayerCode(e)||advancedStringToKeycode(e,t)!==null}function shorten(e){return e.split(" ").map(t=>t.slice(0,1)+t.slice(1).replace(/[aeiou ]/gi,"")).join("")}function isCustomKeycodeByte(e,t){return e>=t._QK_KB&&e<=t._QK_KB_MAX}function getCustomKeycodeIndex(e,t){return e-t._QK_KB}function isTapDanceByte(e,t){return e>=t._QK_TAP_DANCE&&e<=t._QK_TAP_DANCE_MAX}function getTapDanceIndex(e,t){return e-t._QK_TAP_DANCE}function isMacroKeycodeByte(e,t){return e>=t._QK_MACRO&&e<=t._QK_MACRO_MAX}function getMacroKeycodeIndex(e,t){return e-t._QK_MACRO}function getLabelForByte(e,t=100,r,s){const a=getCodeForByte(e,r,s),l=keycodesList.find(({code:c})=>c===a);return l?getShortNameForKeycode(l,t):a}function getShortNameForKeycode(e,t=100){const{code:r,name:s,shortName:a}=e;if(t<=150&&a)return a;if(t===100&&s.length>5){const l=shorten(s);if(r){const c=r.replace("KC_","").replace("_"," ");return l.length>4&&c.length<l.length?c:l}return l}return s}function getOtherMenu(e){return{id:"other",label:"Other",keycodes:Object.keys(e).filter(r=>!r.startsWith("_QK")).filter(r=>!keycodesList.map(({code:s})=>s).includes(r)).map(r=>({name:r.replace("KC_","").replace(/_/g," "),code:r}))}}function buildLayerMenu(){const e=[{name:`Fn1
|
|
4
|
+
(Fn3)`,code:"FN_MO13",title:"Hold = Layer 1, Hold with Fn2 = Layer 3",shortName:"Fn1(3)"},{name:`Fn2
|
|
5
|
+
(Fn3)`,code:"FN_MO23",title:"Hold = Layer 2, Hold with Fn1 = Layer 3",shortName:"Fn2(3)"},{name:"Space Fn1",code:"LT(1,KC_SPC)",title:"Hold = Layer 1, Tap = Space",shortName:"Spc Fn1"},{name:"Space Fn2",code:"LT(2,KC_SPC)",title:"Hold = Layer 2, Tap = Space",shortName:"Spc Fn2"},{name:"Space Fn3",code:"LT(3,KC_SPC)",title:"Hold = Layer 3, Tap = Space",shortName:"Spc Fn3"}],t={id:"layers",label:"Layers",width:"label",keycodes:[{name:"MO",code:"MO(layer)",type:"layer",layer:0,title:"Momentary turn layer on"},{name:"TG",code:"TG(layer)",type:"layer",layer:0,title:"Toggle layer on/off"},{name:"TT",code:"TT(layer)",type:"layer",layer:0,title:"Normally acts like MO unless it's tapped multple times which toggles layer on"},{name:"OSL",code:"OSL(layer)",type:"layer",layer:0,title:"Switch to layer for one keypress"},{name:"TO",code:"TO(layer)",type:"layer",layer:0,title:"Turn on layer when pressed"},{name:"DF",code:"DF(layer)",type:"layer",layer:0,title:"Sets the default layer"}]};return{...t,keycodes:[...e,...t.keycodes.flatMap(r=>{let s=[];for(let a=0;a<10;a++){const l=(r.title||"").replace("layer",`layer ${a}`),c=r.code.replace("layer",`${a}`),d=r.name+`(${a})`;s=[...s,{...r,name:d,title:l,code:c}]}return s})]}}function generateMacros(e=16){let t=[];for(let r=0;r<e;r++){const s=`M${r}`,a=`MACRO(${r})`,l=`Macro ${r}`;t=[...t,{name:s,title:l,code:a}]}return t}function getKeycodes(e=16){return[{id:"basic",label:"Basic",keycodes:[{name:"",code:"KC_NO",title:"Nothing"},{name:"โฝ",code:"KC_TRNS",title:"Pass-through"},{name:"Esc",code:"KC_ESC",keys:"esc"},{name:"A",code:"KC_A",keys:"a"},{name:"B",code:"KC_B",keys:"b"},{name:"C",code:"KC_C",keys:"c"},{name:"D",code:"KC_D",keys:"d"},{name:"E",code:"KC_E",keys:"e"},{name:"F",code:"KC_F",keys:"f"},{name:"G",code:"KC_G",keys:"g"},{name:"H",code:"KC_H",keys:"h"},{name:"I",code:"KC_I",keys:"i"},{name:"J",code:"KC_J",keys:"j"},{name:"K",code:"KC_K",keys:"k"},{name:"L",code:"KC_L",keys:"l"},{name:"M",code:"KC_M",keys:"m"},{name:"N",code:"KC_N",keys:"n"},{name:"O",code:"KC_O",keys:"o"},{name:"P",code:"KC_P",keys:"p"},{name:"Q",code:"KC_Q",keys:"q"},{name:"R",code:"KC_R",keys:"r"},{name:"S",code:"KC_S",keys:"s"},{name:"T",code:"KC_T",keys:"t"},{name:"U",code:"KC_U",keys:"u"},{name:"V",code:"KC_V",keys:"v"},{name:"W",code:"KC_W",keys:"w"},{name:"X",code:"KC_X",keys:"x"},{name:"Y",code:"KC_Y",keys:"y"},{name:"Z",code:"KC_Z",keys:"z"},{name:`!
|
|
6
|
+
1`,code:"KC_1",keys:"1"},{name:`@
|
|
7
|
+
2`,code:"KC_2",keys:"2"},{name:`#
|
|
8
|
+
3`,code:"KC_3",keys:"3"},{name:`$
|
|
9
|
+
4`,code:"KC_4",keys:"4"},{name:`%
|
|
10
|
+
5`,code:"KC_5",keys:"5"},{name:`^
|
|
11
|
+
6`,code:"KC_6",keys:"6"},{name:`&
|
|
12
|
+
7`,code:"KC_7",keys:"7"},{name:`*
|
|
13
|
+
8`,code:"KC_8",keys:"8"},{name:`(
|
|
14
|
+
9`,code:"KC_9",keys:"9"},{name:`)
|
|
15
|
+
0`,code:"KC_0",keys:"0"},{name:`_
|
|
16
|
+
-`,code:"KC_MINS",keys:"-"},{name:`+
|
|
17
|
+
=`,code:"KC_EQL",keys:"="},{name:"~\n`",code:"KC_GRV",keys:"`"},{name:`{
|
|
18
|
+
[`,code:"KC_LBRC",keys:"["},{name:`}
|
|
19
|
+
]`,code:"KC_RBRC",keys:"]"},{name:`|
|
|
20
|
+
\\`,code:"KC_BSLS",keys:"\\",width:1500},{name:`:
|
|
21
|
+
;`,code:"KC_SCLN",keys:";"},{name:`"
|
|
22
|
+
'`,code:"KC_QUOT",keys:"'"},{name:`<
|
|
23
|
+
,`,code:"KC_COMM",keys:","},{name:`>
|
|
24
|
+
.`,code:"KC_DOT",keys:"."},{name:`?
|
|
25
|
+
/`,code:"KC_SLSH",keys:"/"},{name:"=",code:"KC_PEQL"},{name:",",code:"KC_PCMM"},{name:"F1",code:"KC_F1"},{name:"F2",code:"KC_F2"},{name:"F3",code:"KC_F3"},{name:"F4",code:"KC_F4"},{name:"F5",code:"KC_F5"},{name:"F6",code:"KC_F6"},{name:"F7",code:"KC_F7"},{name:"F8",code:"KC_F8"},{name:"F9",code:"KC_F9"},{name:"F10",code:"KC_F10"},{name:"F11",code:"KC_F11"},{name:"F12",code:"KC_F12"},{name:"Print Screen",code:"KC_PSCR",shortName:"Print"},{name:"Scroll Lock",code:"KC_SLCK",shortName:"Scroll"},{name:"Pause",code:"KC_PAUS"},{name:"Tab",code:"KC_TAB",keys:"tab",width:1500},{name:"Backspace",code:"KC_BSPC",keys:"backspace",width:2e3,shortName:"Bksp"},{name:"Insert",code:"KC_INS",keys:"insert",shortName:"Ins"},{name:"Del",code:"KC_DEL",keys:"delete"},{name:"Home",code:"KC_HOME",keys:"home"},{name:"End",code:"KC_END",keys:"end"},{name:"Page Up",code:"KC_PGUP",keys:"pageup",shortName:"PgUp"},{name:"Page Down",code:"KC_PGDN",keys:"pagedown",shortName:"PgDn"},{name:`Num
|
|
26
|
+
Lock`,code:"KC_NLCK",keys:"num",shortName:"N.Lck"},{name:"Caps Lock",code:"KC_CAPS",keys:"caps_lock",width:1750},{name:"Enter",code:"KC_ENT",keys:"enter",width:2250},{name:"1",code:"KC_P1",keys:"num_1",title:"Numpad 1"},{name:"2",code:"KC_P2",keys:"num_2",title:"Numpad 2"},{name:"3",code:"KC_P3",keys:"num_3",title:"Numpad 3"},{name:"4",code:"KC_P4",keys:"num_4",title:"Numpad 4"},{name:"5",code:"KC_P5",keys:"num_5",title:"Numpad 5"},{name:"6",code:"KC_P6",keys:"num_6",title:"Numpad 6"},{name:"7",code:"KC_P7",keys:"num_7",title:"Numpad 7"},{name:"8",code:"KC_P8",keys:"num_8",title:"Numpad 8"},{name:"9",code:"KC_P9",keys:"num_9",title:"Numpad 9"},{name:"0",code:"KC_P0",width:2e3,keys:"num_0",title:"Numpad 0"},{name:"รท",code:"KC_PSLS",keys:"num_divide",title:"Numpad รท"},{name:"ร",code:"KC_PAST",keys:"num_multiply",title:"Numpad ร"},{name:"-",code:"KC_PMNS",keys:"num_subtract",title:"Numpad -"},{name:"+",code:"KC_PPLS",keys:"num_add",title:"Numpad +"},{name:".",code:"KC_PDOT",keys:"num_decimal",title:"Numpad ."},{name:`Num
|
|
27
|
+
Enter`,code:"KC_PENT",shortName:"N.Ent",title:"Numpad Enter"},{name:"Left Shift",code:"KC_LSFT",keys:"shift",width:2250,shortName:"LShft"},{name:"Right Shift",code:"KC_RSFT",width:2750,shortName:"RShft"},{name:"Left Ctrl",code:"KC_LCTL",keys:"ctrl",width:1250},{name:"Right Ctrl",code:"KC_RCTL",width:1250,shortName:"RCtl"},{name:"Left Win",code:"KC_LGUI",keys:"cmd",width:1250,shortName:"LWin"},{name:"Right Win",code:"KC_RGUI",width:1250,shortName:"RWin"},{name:"Left Alt",code:"KC_LALT",keys:"alt",width:1250,shortName:"LAlt"},{name:"Right Alt",code:"KC_RALT",width:1250,shortName:"RAlt"},{name:"Space",code:"KC_SPC",keys:"space",width:6250},{name:"Menu",code:"KC_APP",width:1250,shortName:"RApp"},{name:"Left",code:"KC_LEFT",keys:"left",shortName:"โ"},{name:"Down",code:"KC_DOWN",keys:"down",shortName:"โ"},{name:"Up",code:"KC_UP",keys:"up",shortName:"โ"},{name:"Right",code:"KC_RGHT",keys:"right",shortName:"โ"}]},{id:"wt_lighting",label:"Lighting",width:"label",keycodes:[{name:"Bright -",code:"BR_DEC",title:"Brightness -",shortName:"BR -"},{name:"Bright +",code:"BR_INC",title:"Brightness +",shortName:"BR +"},{name:"Effect -",code:"EF_DEC",title:"Effect -",shortName:"EF -"},{name:"Effect +",code:"EF_INC",title:"Effect +",shortName:"EF +"},{name:"Effect Speed -",code:"ES_DEC",title:"Effect Speed -",shortName:"ES -"},{name:"Effect Speed +",code:"ES_INC",title:"Effect Speed +",shortName:"ES +"},{name:"Color1 Hue -",code:"H1_DEC",title:"Color1 Hue -",shortName:"H1 -"},{name:"Color1 Hue +",code:"H1_INC",title:"Color1 Hue +",shortName:"H1 +"},{name:"Color2 Hue -",code:"H2_DEC",title:"Color2 Hue -",shortName:"H2 -"},{name:"Color2 Hue +",code:"H2_INC",title:"Color2 Hue +",shortName:"H2 +"},{name:"Color1 Sat -",code:"S1_DEC",title:"Color1 Sat -",shortName:"S1 -"},{name:"Color1 Sat +",code:"S1_INC",title:"Color1 Sat +",shortName:"S1 +"},{name:"Color2 Sat -",code:"S2_DEC",title:"Color2 Sat -",shortName:"S2 -"},{name:"Color2 Sat +",code:"S2_INC",title:"Color2 Sat +",shortName:"S2 +"}]},{id:"media",label:"Media",width:"label",keycodes:[{name:"Vol -",code:"KC_VOLD",title:"Volume Down"},{name:"Vol +",code:"KC_VOLU",title:"Volume Up"},{name:"Mute",code:"KC_MUTE",title:"Mute Audio"},{name:"Play",code:"KC_MPLY",title:"Play/Pause"},{name:"Media Stop",code:"KC_MSTP",title:"Media Stop"},{name:"Previous",code:"KC_MPRV",title:"Media Previous"},{name:"Next",code:"KC_MNXT",title:"Media Next"},{name:"Rewind",code:"KC_MRWD",title:"Rewind"},{name:"Fast Forward",code:"KC_MFFD",title:"Fast Forward"},{name:"Select",code:"KC_MSEL",title:"Media Select"},{name:"Eject",code:"KC_EJCT",title:"Media Eject"}]},{id:"macro",label:"Macro",width:"label",keycodes:generateMacros(e)},buildLayerMenu(),{id:"special",label:"Special",width:"label",keycodes:[{name:"~",code:"S(KC_GRV)",keys:"`",title:"Shift + `"},{name:"!",code:"S(KC_1)",keys:"!",title:"Shift + 1"},{name:"@",code:"S(KC_2)",keys:"@",title:"Shift + 2"},{name:"#",code:"S(KC_3)",keys:"#",title:"Shift + 3"},{name:"$",code:"S(KC_4)",keys:"$",title:"Shift + 4"},{name:"%",code:"S(KC_5)",keys:"%",title:"Shift + 5"},{name:"^",code:"S(KC_6)",keys:"^",title:"Shift + 6"},{name:"&",code:"S(KC_7)",keys:"&",title:"Shift + 7"},{name:"*",code:"S(KC_8)",keys:"*",title:"Shift + 8"},{name:"(",code:"S(KC_9)",keys:"(",title:"Shift + 9"},{name:")",code:"S(KC_0)",keys:")",title:"Shift + 0"},{name:"_",code:"S(KC_MINS)",keys:"_",title:"Shift + -"},{name:"+",code:"S(KC_EQL)",keys:"+",title:"Shift + ="},{name:"{",code:"S(KC_LBRC)",keys:"{",title:"Shift + ["},{name:"}",code:"S(KC_RBRC)",keys:"}",title:"Shift + ]"},{name:"|",code:"S(KC_BSLS)",keys:"|",title:"Shift + \\"},{name:":",code:"S(KC_SCLN)",keys:":",title:"Shift + /"},{name:'"',code:"S(KC_QUOT)",keys:'"',title:"Shift + '"},{name:"<",code:"S(KC_COMM)",keys:"<",title:"Shift + ,"},{name:">",code:"S(KC_DOT)",keys:">",title:"Shift + ."},{name:"?",code:"S(KC_SLSH)",keys:"?",title:"Shift + /"},{name:"NUHS",code:"KC_NUHS",title:"Non-US # and ~"},{name:"NUBS",code:"KC_NUBS",title:"Non-US \\ and |"},{name:"Ro",code:"KC_RO",title:"JIS \\ and |"},{name:"ยฅ",code:"KC_JYEN",title:"JPN Yen"},{name:"็กๅคๆ",code:"KC_MHEN",title:"JIS Muhenkan"},{name:"ๆผขๅญ",code:"KC_HANJ",title:"Hanja"},{name:"ํ์",code:"KC_HAEN",title:"HanYeong"},{name:"ๅคๆ",code:"KC_HENK",title:"JIS Henkan"},{name:"ใใช",code:"KC_KANA",title:"JIS Katakana/Hiragana"},{name:"Esc `",code:"KC_GESC",title:"Esc normally, but ` when Shift or Win is pressed"},{name:"LS (",code:"KC_LSPO",title:"Left Shift when held, ( when tapped"},{name:"RS )",code:"KC_RSPC",title:"Right Shift when held, ) when tapped"},{name:"LC (",code:"KC_LCPO",title:"Left Control when held, ( when tapped"},{name:"RC )",code:"KC_RCPC",title:"Right Control when held, ) when tapped"},{name:"LA (",code:"KC_LAPO",title:"Left Alt when held, ( when tapped"},{name:"RA )",code:"KC_RAPC",title:"Right Alt when held, ) when tapped"},{name:"SftEnt",code:"KC_SFTENT",title:"Right Shift when held, Enter when tapped"},{name:"Reset",code:"RESET",title:"Reset the keyboard"},{name:"Debug",code:"DEBUG",title:"Toggle debug mode"},{name:"Toggle NKRO",code:"MAGIC_TOGGLE_NKRO",shortName:"NKRO",title:"Toggle NKRO"},{name:"Locking Num Lock",code:"KC_LNUM"},{name:"Locking Caps Lock",code:"KC_LCAP"},{name:"Locking Scroll Lock",code:"KC_LSCR"},{name:"Power",code:"KC_PWR"},{name:"Power OSX",code:"KC_POWER"},{name:"Sleep",code:"KC_SLEP"},{name:"Wake",code:"KC_WAKE"},{name:"Calc",code:"KC_CALC"},{name:"Mail",code:"KC_MAIL"},{name:"Help",code:"KC_HELP"},{name:"Stop",code:"KC_STOP"},{name:"Alt Erase",code:"KC_ERAS"},{name:"Again",code:"KC_AGAIN"},{name:"Menu",code:"KC_MENU"},{name:"Undo",code:"KC_UNDO"},{name:"Select",code:"KC_SELECT"},{name:"Exec",code:"KC_EXECUTE"},{name:"Cut",code:"KC_CUT"},{name:"Copy",code:"KC_COPY"},{name:"Paste",code:"KC_PASTE"},{name:"Find",code:"KC_FIND"},{name:"My Comp",code:"KC_MYCM"},{name:"Home",code:"KC_WWW_HOME"},{name:"Back",code:"KC_WWW_BACK"},{name:"Forward",code:"KC_WWW_FORWARD"},{name:"Stop",code:"KC_WWW_STOP"},{name:"Refresh",code:"KC_WWW_REFRESH"},{name:"Favorites",code:"KC_WWW_FAVORITES"},{name:"Search",code:"KC_WWW_SEARCH"},{name:"Screen +",code:"KC_BRIU",shortName:"Scr +",title:"Screen Brightness Up"},{name:"Screen -",code:"KC_BRID",shortName:"Scr -",title:"Screen Brightness Down"},{name:"F13",code:"KC_F13"},{name:"F14",code:"KC_F14"},{name:"F15",code:"KC_F15"},{name:"F16",code:"KC_F16"},{name:"F17",code:"KC_F17"},{name:"F18",code:"KC_F18"},{name:"F19",code:"KC_F19"},{name:"F20",code:"KC_F20"},{name:"F21",code:"KC_F21"},{name:"F22",code:"KC_F22"},{name:"F23",code:"KC_F23"},{name:"F24",code:"KC_F24"},{name:"Mouse โ",code:"KC_MS_UP"},{name:"Mouse โ",code:"KC_MS_DOWN"},{name:"Mouse โ",code:"KC_MS_LEFT"},{name:"Mouse โ",code:"KC_MS_RIGHT"},{name:"Mouse Btn1",code:"KC_MS_BTN1"},{name:"Mouse Btn2",code:"KC_MS_BTN2"},{name:"Mouse Btn3",code:"KC_MS_BTN3"},{name:"Mouse Btn4",code:"KC_MS_BTN4"},{name:"Mouse Btn5",code:"KC_MS_BTN5"},{name:"Mouse Btn6",code:"KC_MS_BTN6"},{name:"Mouse Btn7",code:"KC_MS_BTN7"},{name:"Mouse Btn8",code:"KC_MS_BTN8"},{name:"Mouse Wh โ",code:"KC_MS_WH_UP"},{name:"Mouse Wh โ",code:"KC_MS_WH_DOWN"},{name:"Mouse Wh โ",code:"KC_MS_WH_LEFT"},{name:"Mouse Wh โ",code:"KC_MS_WH_RIGHT"},{name:"Mouse Acc0",code:"KC_MS_ACCEL0"},{name:"Mouse Acc1",code:"KC_MS_ACCEL1"},{name:"Mouse Acc2",code:"KC_MS_ACCEL2"},{name:"Audio On",code:"AU_ON"},{name:"Audio Off",code:"AU_OFF"},{name:"Audio Toggle",code:"AU_TOG"},{name:"Clicky Toggle",code:"CLICKY_TOGGLE"},{name:"Clicky Enable",code:"CLICKY_ENABLE"},{name:"Clicky Disable",code:"CLICKY_DISABLE"},{name:"Clicky Up",code:"CLICKY_UP"},{name:"Clicky Down",code:"CLICKY_DOWN"},{name:"Clicky Reset",code:"CLICKY_RESET"},{name:"Music On",code:"MU_ON"},{name:"Music Off",code:"MU_OFF"},{name:"Music Toggle",code:"MU_TOG"},{name:"Music Mode",code:"MU_MOD"},{name:"Toggle GUI Status",code:"GU_TOGG"},{name:"Toggle Alt/GUI",code:"AG_TOGG"}]},{id:"qmk_lighting",label:"Lighting",width:"label",keycodes:[{name:"BL Toggle",code:"BL_TOGG"},{name:"BL On",code:"BL_ON"},{name:"BL Off",code:"BL_OFF",shortName:"BL Off"},{name:"BL -",code:"BL_DEC"},{name:"BL +",code:"BL_INC"},{name:"BL Cycle",code:"BL_STEP"},{name:"BR Toggle",code:"BL_BRTG"},{name:"RGB Toggle",code:"RGB_TOG"},{name:"RGB Mode -",code:"RGB_RMOD"},{name:"RGB Mode +",code:"RGB_MOD"},{name:"Hue -",code:"RGB_HUD"},{name:"Hue +",code:"RGB_HUI"},{name:"Sat -",code:"RGB_SAD"},{name:"Sat +",code:"RGB_SAI"},{name:"Bright -",code:"RGB_VAD"},{name:"Bright +",code:"RGB_VAI"},{name:"Effect Speed-",code:"RGB_SPD"},{name:"Effect Speed+",code:"RGB_SPI"},{name:"RGB Mode P",code:"RGB_M_P",title:"Plain"},{name:"RGB Mode B",code:"RGB_M_B",title:"Breathe"},{name:"RGB Mode R",code:"RGB_M_R",title:"Rainbow"},{name:"RGB Mode SW",code:"RGB_M_SW",title:"Swirl"},{name:"RGB Mode SN",code:"RGB_M_SN",title:"Snake"},{name:"RGB Mode K",code:"RGB_M_K",title:"Knight"},{name:"RGB Mode X",code:"RGB_M_X",title:"Xmas"},{name:"RGB Mode G",code:"RGB_M_G",title:"Gradient"}]},{id:"custom",label:"Custom",width:"label",keycodes:[{name:"CUSTOM(0)",code:"CUSTOM(0)",title:"Custom Keycode 0"},{name:"CUSTOM(1)",code:"CUSTOM(1)",title:"Custom Keycode 1"},{name:"CUSTOM(2)",code:"CUSTOM(2)",title:"Custom Keycode 2"},{name:"CUSTOM(3)",code:"CUSTOM(3)",title:"Custom Keycode 3"},{name:"CUSTOM(4)",code:"CUSTOM(4)",title:"Custom Keycode 4"},{name:"CUSTOM(5)",code:"CUSTOM(5)",title:"Custom Keycode 5"},{name:"CUSTOM(6)",code:"CUSTOM(6)",title:"Custom Keycode 6"},{name:"CUSTOM(7)",code:"CUSTOM(7)",title:"Custom Keycode 7"},{name:"CUSTOM(8)",code:"CUSTOM(8)",title:"Custom Keycode 8"},{name:"CUSTOM(9)",code:"CUSTOM(9)",title:"Custom Keycode 9"},{name:"CUSTOM(10)",code:"CUSTOM(10)",title:"Custom Keycode 10"},{name:"CUSTOM(11)",code:"CUSTOM(11)",title:"Custom Keycode 11"},{name:"CUSTOM(12)",code:"CUSTOM(12)",title:"Custom Keycode 12"},{name:"CUSTOM(13)",code:"CUSTOM(13)",title:"Custom Keycode 13"},{name:"CUSTOM(14)",code:"CUSTOM(14)",title:"Custom Keycode 14"},{name:"CUSTOM(15)",code:"CUSTOM(15)",title:"Custom Keycode 15"}]}]}const categoriesForKeycodeModule=e=>({default:["basic","media","macro","layers","special"],[dist.BuiltInKeycodeModule.WTLighting]:["wt_lighting"],[dist.BuiltInKeycodeModule.QMKLighting]:["qmk_lighting"]})[e],getKeycodesForKeyboard=e=>{let t=[];if("lighting"in e){const{keycodes:r}=dist.getLightingDefinition(e.lighting);t=categoriesForKeycodeModule("default").concat(r===dist.KeycodeType.None?[]:r===dist.KeycodeType.QMK?categoriesForKeycodeModule(dist.BuiltInKeycodeModule.QMKLighting):categoriesForKeycodeModule(dist.BuiltInKeycodeModule.WTLighting))}else{const{keycodes:r}=e;t=r.flatMap(categoriesForKeycodeModule)}return getKeycodes().flatMap(r=>t.includes(r.id)?r.keycodes:[]).sort((r,s)=>r.code<=s.code?-1:1)},CSSVarObject={keyWidth:52,keyXSpacing:2,keyHeight:54,keyYSpacing:2,keyXPos:52+2,keyYPos:54+2,faceXPadding:[6,6],faceYPadding:[2,10],insideBorder:10},KeycapMetric={keyWidth:18.1,keyXSpacing:1.05,keyHeight:18.1,keyYSpacing:1.05,keyXPos:19.15,keyYPos:19.15},getComboKeyProps=e=>{if(e.w2===void 0||e.h2===void 0)return{clipPath:null,normalizedRects:null};const{x:t,y:r,x2:s=0,y2:a=0,w:l,w2:c,h:d,h2:p}=e,f=Math.max(e.w,e.w2),m=Math.max(e.h,e.h2),y=Math.min(t,t+s),K=Math.min(r,r+a),[x,v,M,b,R,O,I,k]=l===f?[t+s-y,t-y,r+a-K,r-K,c,l,p,d]:[t-y,t+s-y,r-K,r+a-K,l,c,d,p],F=$=>`polygon(${$.map(z=>`${100*z[0]}% ${100*z[1]}%`).join(",")})`,V=[[v/f,b/m],[x/f,b/m],[x/f,M/m],[(x+R)/f,M/m],[(x+R)/f,b/m],[(v+O)/f,b/m],[(v+O)/f,(b+k)/m],[(x+R)/f,(b+k)/m],[(x+R)/f,(M+I)/m],[x/f,(M+I)/m],[x/f,(b+k)/m],[v/f,(b+k)/m]];return{clipPath:F(V),normalizedRects:[[x,M,R,I],[v,b,O,k]]}};function calculatePointPosition({x:e=0,x2:t=0,y:r=0,r:s=0,rx:a=0,ry:l=0,w:c=0,w2:d=0,h:p=0}){const f=s*(2*Math.PI)/360,m=Math.cos(f),y=Math.sin(f),K=CSSVarObject.keyXPos*a,x=CSSVarObject.keyYPos*l,v=CSSVarObject.keyXPos*(e+t)+Math.max(d,c)*CSSVarObject.keyWidth/2+(Math.max(d,c)-1)*CSSVarObject.keyXSpacing/2,M=CSSVarObject.keyYPos*r+p*CSSVarObject.keyHeight/2+(p-1)*CSSVarObject.keyYSpacing/2,b=v*m-M*y-K*m+x*y+K,R=v*y+M*m-K*y-x*m+x;return[b,R]}const sortByX=(e,t)=>{const r=calculatePointPosition(e),s=calculatePointPosition(t);return r[0]-s[0]},sortByYX=(e,t)=>{const r=calculatePointPosition(e),s=calculatePointPosition(t);return r[1]-s[1]===0?r[0]-s[0]:r[1]-s[1]},withinChain=(e,t)=>{const r=calculatePointPosition(e),s=calculatePointPosition(t);return Math.abs(r[1]-s[1])<CSSVarObject.keyYPos*.9},getTraversalOrder=e=>{const[t,...r]=[...e].sort(sortByYX);if(t===void 0)return r;{const[s,a]=partition([...e],l=>withinChain(t,l));return[...s.sort(sortByX),...getTraversalOrder(a)]}},widthProfiles={1:[1,2,3,4],1.25:[4],1.5:[2,4],1.75:[3,4],2:[1,4],2.25:[3,4],2.75:[4],3:[4],6.25:[4],7:[4]},getRowForKey=(e,t)=>e.h!==1?t:widthProfiles[e.w]?widthProfiles[e.w].includes(t)?t:widthProfiles[e.w][0]:4,getRowProfiles=e=>{switch(!e.some(r=>r.some(s=>s.w!==1||s.h!==1))||e.length){case 8:return[1,1,1,1,2,3,4,4];case 7:return[1,1,1,2,3,4,4];case 6:return[1,1,2,3,4,4];case 5:return[1,2,3,4,4];case 4:return[2,3,4,4];case 3:return[2,3,4];default:return Array(e.length).fill(1)}},getKeyId=e=>`${e.w}-${e.h}-${e.col}-${e.row}-${e.w2}-${e.h2}`,getKeyboardRowPartitions=e=>{const{partitionedKeys:t}=getTraversalOrder(e).reduce(({prevX:s,partitionedKeys:a},l)=>{const[c]=calculatePointPosition(l);return s>=c&&a.push([]),a[a.length-1].push(l),{partitionedKeys:a,prevX:c}},{partitionedKeys:[],prevX:1/0}),r=getRowProfiles(t);return{rowMap:t.reduce((s,a,l)=>a.reduce((c,d)=>({...c,[getKeyId(d)]:getRowForKey(d,r[l])}),s),{}),partitionedKeys:t}},getNextKey=(e,t)=>{const r=t.filter(c=>!c.d),s=t[e],a=getTraversalOrder([...r]),l=a.indexOf(s);return l===a.length-1?null:t.indexOf(a[(l+1)%a.length])},makeSRGBTheme=e=>Object.entries(e).reduce((t,[r,s])=>{const a=`#${new Color(s.c).convertSRGBToLinear().getHexString()}`,l=`#${new Color(s.t).convertSRGBToLinear().getHexString()}`;return{...t,[r]:{c:a,t:l}}},{}),calculateKeyboardFrameDimensions=e=>{const t=e.map(dist.getBoundingBox),r=Math.min(...t.map(c=>c.xStart)),s=Math.min(...t.map(c=>c.yStart)),a=Math.max(...t.map(c=>c.xEnd))-r,l=Math.max(...t.map(c=>c.yEnd))-s;return{width:a,height:l}},getMeshName=(e,t,r)=>{if(e.ei!==void 0)return"E-100";if(e.h===2&&e.w===1)return`K-R${t}V-200`;if(e.w===1.25&&e.w2===1.5)return"K-R2-ISO";if(e.w===1.5&&e.w2===2.25)return"K-R2-BAE";if(e.h>1)return r?"K-R4C-100":"K-R4-100";if(!r)switch(e.w){case 1.25:case 1.5:case 1.75:case 1:case 2:case 2.25:case 2.75:return`K-R${t}-${e.w*100}`;case 3:case 6:case 6.25:case 6.5:case 7:return`K-R4C-${e.w*100}`;default:return"K-R4C-100"}switch(e.w){case 1:case 1.25:case 1.5:case 1.75:return`K-R${t}-${e.w*100}`;case 2:case 2.25:case 2.75:case 3:case 6:case 6.25:case 6.5:case 7:return`K-R4C-${e.w*100}`;default:return"K-R4C-100"}},getScale=(e,t)=>{if(e.ei!==void 0)return t;if(e.h===2&&e.w===1)return[1,1,1];if(e.w===1.25&&e.w2===1.5)return[1,1,1];if(e.w===1.5&&e.w2===2.25)return[1,1,1];if(e.h>1)return t;if(e.h==1)switch(e.w){case 1.25:case 1.5:case 1.75:case 2:case 2.25:case 2.75:case 3:case 6:case 6.25:case 6.5:case 7:return[1,1,1];case 1:return[1,1,1];default:return t}return t},getLabelOffsets=(e,t)=>{let r=0,s=0;return e.length==1&&'^*"'.split("").includes(e[0])&&(r=.2),t.length==1&&(",.".split("").includes(t[0])?s=.4:"/\\;'[]".split("").includes(t[0])?s=.3:"-".split("").includes(t[0])&&(s=.1)),[r,s]},getLabel=(e,t,r,s,a,l,c)=>{let d="",p=1,f=[0,0],m="";if(isCustomKeycodeByte(e,a)&&(s!=null&&s.customKeycodes)&&s.customKeycodes[getCustomKeycodeIndex(e,a)]!==void 0){const K=getCustomKeycodeIndex(e,a);d=getShortNameForKeycode(s.customKeycodes[K]),m=getShortNameForKeycode(s.customKeycodes[K],700)}else if(isTapDanceByte(e,a)&&c[getTapDanceIndex(e,a)]!==void 0){const K=getTapDanceIndex(e,a);d=getShortNameForKeycode(c[K]),m=getShortNameForKeycode(c[K],700)}else e&&(d=getLabelForByte(e,t*100,a,l)??"",m=getLabelForByte(e,700,a,l)??"");let y;if(isMacroKeycodeByte(e,a)){const K=getMacroKeycodeIndex(e,a);y=r[K],m=y||""}if(isAlpha(d)||isNumpadNumber(d))return d&&{label:d.toUpperCase(),macroExpression:y,key:(d||"")+(y||""),size:p,offset:f};if(isMultiLegend(d)){const K=d[0],x=d[d.length-1];return x&&{topLabel:K,bottomLabel:x,macroExpression:y,key:(d||"")+(y||""),size:p,offset:getLabelOffsets(K,x)}}else return isNumpadSymbol(d)&&(p=2),isArrowKey(d)&&(p=1.5),{label:d,centerLabel:d,tooltipLabel:m,macroExpression:y,key:(d||"")+(y||""),size:p,offset:f}},updateCSSVariables=e=>{const t=THEMES[e]||THEMES.OLIVIA_DARK;document.documentElement.style.setProperty("--color_accent",t.accent.c),document.documentElement.style.setProperty("--color_inside-accent",t.accent.t)};function getRGBPrime(e,t,r){if(e>=0&&e<60)return[t,r,0];if(e>=60&&e<120)return[r,t,0];if(e>=120&&e<180)return[0,t,r];if(e>=180&&e<240)return[0,r,t];if(e>=240&&e<300)return[r,0,t];if(e>=300&&e<360)return[t,0,r];if(e===360)return[t,r,0];throw new Error("Invalid hue")}const getColorByte=e=>{const t=e.replace("#",""),r=parseInt(t[0],16)*16+parseInt(t[1],16),s=parseInt(t[2],16)*16+parseInt(t[3],16),a=parseInt(t[4],16)*16+parseInt(t[5],16);return[r,s,a]},getDarkenedColor=(e,t=.8)=>{const[r,s,a]=getColorByte(e),l=Math.round(r*t).toString(16),c=Math.round(s*t).toString(16),d=Math.round(a*t).toString(16);return`#${l.padStart(2,"0")}${c.padStart(2,"0")}${d.padStart(2,"0")}`},get256HSV=e=>{const[t,r,s]=getHSV(e);return[Math.round(255*t/360),Math.round(255*r),Math.round(255*s)]},getHSV=e=>{const[t,r,s]=(typeof e=="string"?getColorByte(e):e).map(m=>m/255),[a,l]=[Math.max(t,r,s),Math.min(t,r,s)],c=a-l;let d=60,p=0,f=a;return c===0?d=d*0:a===t?d=d*((r-s)/c%6):a===r?d=d*((s-t)/c+2):a===s&&(d=d*((t-r)/c+4)),a!==0&&(p=c/a),[(d+360)%360,p,f]},getHSVFrom256=e=>[Math.round(360*e[0]/255),Math.round(e[1]/255),1];function getRGB({hue:e,sat:t}){t=t/255,e=Math.round(360*e)/255;const r=t,s=r*(1-Math.abs(e/60%2-1)),a=1-r,[l,c,d]=getRGBPrime(e,r,s).map(p=>Math.round(255*(a+p)));return`rgba(${l},${c},${d},1)`}function toDegrees(e){return e*(180/Math.PI)}function calcRadialHue(e,t){if(e<200&&t<200){const r=200-e,s=200-t;return 2*Math.PI-Math.atan(r/s)}else if(e>200&&t<200){const r=e-200,s=200-t;return Math.atan(r/s)}else if(e<200&&t>200){const r=200-e,s=t-200;return Math.PI+Math.atan(r/s)}else if(e>200&&t>200){const r=e-200,s=t-200;return .5*Math.PI+Math.atan(s/r)}else{if(e===200)return t>200?Math.PI:0;if(t===200)return e>=200?.5*Math.PI:1.5*Math.PI}}function calcRadialMagnitude(e,t){if(e<200&&t<200){const r=200-e,s=200-t;return Math.sqrt(r*r+s*s)/200}else if(e>200&&t<200){const r=e-200,s=200-t;return Math.sqrt(r*r+s*s)/200}else if(e<200&&t>200){const r=200-e,s=t-200;return Math.sqrt(r*r+s*s)/200}else if(e>200&&t>200){const r=e-200,s=t-200;return Math.sqrt(r*r+s*s)/200}else{if(e===200)return t>200?(t-200)/200:(200-t)/200;if(t===200)return e>200?(e-200)/200:(200-e)/200}}function hsToRgb({hue:e,sat:t}){t=t/255,e=Math.round(360*e)/255;const r=t,s=r*(1-Math.abs(e/60%2-1)),a=1-r,[l,c,d]=getRGBPrime(e,r,s).map(p=>Math.round(255*(a+p)));return[l,c,d]}function getHex({hue:e,sat:t}){let[r,s,a]=hsToRgb({hue:e,sat:t}).map(l=>l.toString(16));return r.length==1&&(r="0"+r),s.length==1&&(s="0"+s),a.length==1&&(a="0"+a),"#"+r+s+a}function isWebGLAvailable(){try{const e=document.createElement("canvas");return!!(window.WebGLRenderingContext&&(e.getContext("webgl")||e.getContext("experimental-webgl")))}catch{return!1}}const webGLIsAvailable=isWebGLAvailable(),initialState$b={...getSettings(),isTestMatrixEnabled:!1,restartRequired:!1,allowGlobalHotKeys:!1},toggleBool=(e,t)=>{e[t]=!e[t],setSettings(e)},settingsSlice=createSlice({name:"settings",initialState:initialState$b,reducers:{toggleFastRemap:e=>{toggleBool(e,"disableFastRemap")},toggleCreatorMode:e=>{toggleBool(e,"showDesignTab")},toggleThemeMode:e=>{const t=e.themeMode==="light"?"dark":"light";document.documentElement.dataset.themeMode=t,e.themeMode=t,setSettings(e)},updateRenderMode:(e,t)=>{e.renderMode=t.payload,setSettings(e)},updateDesignDefinitionVersion:(e,t)=>{e.designDefinitionVersion=t.payload,setSettings(e)},updateThemeName:(e,t)=>{e.themeName=t.payload,updateCSSVariables(e.themeName),setSettings(e)},setTestMatrixEnabled:(e,t)=>{e.isTestMatrixEnabled=t.payload},setMacroEditorSettings:(e,t)=>{const r={...e.macroEditor,...t.payload};e.macroEditor=r,setSettings(e)},setTestKeyboardSoundsSettings:(e,t)=>{const r={...e.testKeyboardSoundsSettings,...t.payload};e.testKeyboardSoundsSettings=r,setSettings(e)},disableGlobalHotKeys:e=>{e.allowGlobalHotKeys=!1},enableGlobalHotKeys:e=>{e.allowGlobalHotKeys=!0}}}),{toggleFastRemap,toggleCreatorMode,setTestMatrixEnabled,setTestKeyboardSoundsSettings,setMacroEditorSettings,toggleThemeMode,disableGlobalHotKeys,enableGlobalHotKeys,updateRenderMode,updateThemeName,updateDesignDefinitionVersion}=settingsSlice.actions,settingsReducer=settingsSlice.reducer,getDesignDefinitionVersion=e=>e.settings.designDefinitionVersion,getDisableFastRemap=e=>e.settings.disableFastRemap,getShowDesignTab=e=>e.settings.showDesignTab,getIsTestMatrixEnabled=e=>e.settings.isTestMatrixEnabled,getMacroEditorSettings=e=>e.settings.macroEditor,getTestKeyboardSoundsSettings=e=>e.settings.testKeyboardSoundsSettings,getRenderMode=e=>webGLIsAvailable?e.settings.renderMode:"2D",getThemeMode=e=>e.settings.themeMode,getThemeName=e=>e.settings.themeName,getSelectedTheme=createSelector(getThemeName,e=>THEMES[e]),getSelectedSRGBTheme=createSelector(getSelectedTheme,e=>makeSRGBTheme(e)),basicKeyToByte={_QK_MODS:256,_QK_MODS_MAX:8191,_QK_MOD_TAP:24576,_QK_MOD_TAP_MAX:32767,_QK_LAYER_TAP:16384,_QK_LAYER_TAP_MAX:20479,_QK_LAYER_MOD:22784,_QK_LAYER_MOD_MAX:23039,_QK_TO:20496,_QK_TO_MAX:20511,_QK_MOMENTARY:20736,_QK_MOMENTARY_MAX:20767,_QK_DEF_LAYER:20992,_QK_DEF_LAYER_MAX:21023,_QK_TOGGLE_LAYER:21248,_QK_TOGGLE_LAYER_MAX:21279,_QK_ONE_SHOT_LAYER:21504,_QK_ONE_SHOT_LAYER_MAX:21535,_QK_ONE_SHOT_MOD:21760,_QK_ONE_SHOT_MOD_MAX:22015,_QK_LAYER_TAP_TOGGLE:22528,_QK_LAYER_TAP_TOGGLE_MAX:22559,_QK_LAYER_MOD_MASK:15,_QK_MACRO:24338,_QK_MACRO_MAX:24353,_QK_KB:24448,_QK_KB_MAX:24463,KC_NO:0,KC_TRNS:1,KC_A:4,KC_B:5,KC_C:6,KC_D:7,KC_E:8,KC_F:9,KC_G:10,KC_H:11,KC_I:12,KC_J:13,KC_K:14,KC_L:15,KC_M:16,KC_N:17,KC_O:18,KC_P:19,KC_Q:20,KC_R:21,KC_S:22,KC_T:23,KC_U:24,KC_V:25,KC_W:26,KC_X:27,KC_Y:28,KC_Z:29,KC_1:30,KC_2:31,KC_3:32,KC_4:33,KC_5:34,KC_6:35,KC_7:36,KC_8:37,KC_9:38,KC_0:39,KC_ENT:40,KC_ESC:41,KC_BSPC:42,KC_TAB:43,KC_SPC:44,KC_MINS:45,KC_EQL:46,KC_LBRC:47,KC_RBRC:48,KC_BSLS:49,KC_NUHS:50,KC_SCLN:51,KC_QUOT:52,KC_GRV:53,KC_COMM:54,KC_DOT:55,KC_SLSH:56,KC_CAPS:57,KC_F1:58,KC_F2:59,KC_F3:60,KC_F4:61,KC_F5:62,KC_F6:63,KC_F7:64,KC_F8:65,KC_F9:66,KC_F10:67,KC_F11:68,KC_F12:69,KC_PSCR:70,KC_SLCK:71,KC_PAUS:72,KC_INS:73,KC_HOME:74,KC_PGUP:75,KC_DEL:76,KC_END:77,KC_PGDN:78,KC_RGHT:79,KC_LEFT:80,KC_DOWN:81,KC_UP:82,KC_NLCK:83,KC_PSLS:84,KC_PAST:85,KC_PMNS:86,KC_PPLS:87,KC_PENT:88,KC_P1:89,KC_P2:90,KC_P3:91,KC_P4:92,KC_P5:93,KC_P6:94,KC_P7:95,KC_P8:96,KC_P9:97,KC_P0:98,KC_PDOT:99,KC_NUBS:100,KC_APP:101,KC_POWER:102,KC_PEQL:103,KC_F13:104,KC_F14:105,KC_F15:106,KC_F16:107,KC_F17:108,KC_F18:109,KC_F19:110,KC_F20:111,KC_F21:112,KC_F22:113,KC_F23:114,KC_F24:115,KC_EXECUTE:116,KC_HELP:117,KC_MENU:118,KC_SELECT:119,KC_STOP:120,KC_AGAIN:121,KC_UNDO:122,KC_CUT:123,KC_COPY:124,KC_PASTE:125,KC_FIND:126,KC_LCAP:130,KC_LNUM:131,KC_LSCR:132,KC_PCMM:133,KC_KP_EQUAL_AS400:134,KC_RO:135,KC_KANA:136,KC_JYEN:137,KC_HENK:138,KC_MHEN:139,KC_INT6:140,KC_INT7:141,KC_INT8:142,KC_INT9:143,KC_HAEN:144,KC_HANJ:145,KC_LANG3:146,KC_LANG4:147,KC_LANG5:148,KC_LANG6:149,KC_LANG7:150,KC_LANG8:151,KC_LANG9:152,KC_ERAS:153,KC_SYSREQ:154,KC_CANCEL:155,KC_CLR:156,KC_CLEAR:156,KC_PRIOR:157,KC_OUT:160,KC_OPER:161,KC_CLEAR_AGAIN:162,KC_CRSEL:163,KC_EXSEL:164,KC_PWR:165,KC_SLEP:166,KC_WAKE:167,KC_MUTE:168,KC_VOLU:169,KC_VOLD:170,KC_MNXT:171,KC_MPRV:172,KC_MSTP:173,KC_MPLY:174,KC_MSEL:175,KC_EJCT:176,KC_MAIL:177,KC_CALC:178,KC_MYCM:179,KC_WWW_SEARCH:180,KC_WWW_HOME:181,KC_WWW_BACK:182,KC_WWW_FORWARD:183,KC_WWW_STOP:184,KC_WWW_REFRESH:185,KC_WWW_FAVORITES:186,KC_MFFD:187,KC_MRWD:188,KC_BRIU:189,KC_BRID:190,KC_LCTL:224,KC_LSFT:225,KC_LALT:226,KC_LGUI:227,KC_RCTL:228,KC_RSFT:229,KC_RALT:230,KC_RGUI:231,KC_MS_UP:240,KC_MS_DOWN:241,KC_MS_LEFT:242,KC_MS_RIGHT:243,KC_MS_BTN1:244,KC_MS_BTN2:245,KC_MS_BTN3:246,KC_MS_BTN4:247,KC_MS_BTN5:248,KC_MS_WH_UP:249,KC_MS_WH_DOWN:250,KC_MS_WH_LEFT:251,KC_MS_WH_RIGHT:252,KC_MS_ACCEL0:253,KC_MS_ACCEL1:254,KC_MS_ACCEL2:255,RESET:23552,DEBUG:23553,MAGIC_TOGGLE_NKRO:23572,KC_GESC:23574,AU_ON:23581,AU_OFF:23582,AU_TOG:23583,CLICKY_TOGGLE:23584,CLICKY_ENABLE:23585,CLICKY_DISABLE:23586,CLICKY_UP:23587,CLICKY_DOWN:23588,CLICKY_RESET:23589,MU_ON:23590,MU_OFF:23591,MU_TOG:23592,MU_MOD:23593,BL_ON:23739,BL_OFF:23740,BL_DEC:23741,BL_INC:23742,BL_TOGG:23743,BL_STEP:23744,BL_BRTG:23745,RGB_TOG:23746,RGB_MOD:23747,RGB_RMOD:23748,RGB_HUI:23749,RGB_HUD:23750,RGB_SAI:23751,RGB_SAD:23752,RGB_VAI:23753,RGB_VAD:23754,RGB_SPI:23755,RGB_SPD:23756,RGB_M_P:23757,RGB_M_B:23758,RGB_M_R:23759,RGB_M_SW:23760,RGB_M_SN:23761,RGB_M_K:23762,RGB_M_X:23763,RGB_M_G:23764,KC_LSPO:23767,KC_RSPC:23768,KC_SFTENT:23769,KC_LCPO:23795,KC_RCPC:23796,KC_LAPO:23797,KC_RAPC:23798,BR_INC:24320,BR_DEC:24321,EF_INC:24322,EF_DEC:24323,ES_INC:24324,ES_DEC:24325,H1_INC:24326,H1_DEC:24327,S1_INC:24328,S1_DEC:24329,H2_INC:24330,H2_DEC:24331,S2_INC:24332,S2_DEC:24333,FN_MO13:24336,FN_MO23:24337},v10BasicKeyToByte={_QK_MODS:256,_QK_MODS_MAX:8191,_QK_MOD_TAP:24576,_QK_MOD_TAP_MAX:32767,_QK_LAYER_TAP:16384,_QK_LAYER_TAP_MAX:20479,_QK_LAYER_MOD:22784,_QK_LAYER_MOD_MAX:23039,_QK_TO:20480,_QK_TO_MAX:20511,_QK_MOMENTARY:20736,_QK_MOMENTARY_MAX:20767,_QK_DEF_LAYER:20992,_QK_DEF_LAYER_MAX:21023,_QK_TOGGLE_LAYER:21248,_QK_TOGGLE_LAYER_MAX:21279,_QK_ONE_SHOT_LAYER:21504,_QK_ONE_SHOT_LAYER_MAX:21535,_QK_ONE_SHOT_MOD:21760,_QK_ONE_SHOT_MOD_MAX:22015,_QK_LAYER_TAP_TOGGLE:22528,_QK_LAYER_TAP_TOGGLE_MAX:22559,_QK_LAYER_MOD_MASK:15,_QK_MACRO:24338,_QK_MACRO_MAX:24353,_QK_KB:24448,_QK_KB_MAX:24463,KC_NO:0,KC_TRNS:1,KC_A:4,KC_B:5,KC_C:6,KC_D:7,KC_E:8,KC_F:9,KC_G:10,KC_H:11,KC_I:12,KC_J:13,KC_K:14,KC_L:15,KC_M:16,KC_N:17,KC_O:18,KC_P:19,KC_Q:20,KC_R:21,KC_S:22,KC_T:23,KC_U:24,KC_V:25,KC_W:26,KC_X:27,KC_Y:28,KC_Z:29,KC_1:30,KC_2:31,KC_3:32,KC_4:33,KC_5:34,KC_6:35,KC_7:36,KC_8:37,KC_9:38,KC_0:39,KC_ENT:40,KC_ESC:41,KC_BSPC:42,KC_TAB:43,KC_SPC:44,KC_MINS:45,KC_EQL:46,KC_LBRC:47,KC_RBRC:48,KC_BSLS:49,KC_NUHS:50,KC_SCLN:51,KC_QUOT:52,KC_GRV:53,KC_COMM:54,KC_DOT:55,KC_SLSH:56,KC_CAPS:57,KC_F1:58,KC_F2:59,KC_F3:60,KC_F4:61,KC_F5:62,KC_F6:63,KC_F7:64,KC_F8:65,KC_F9:66,KC_F10:67,KC_F11:68,KC_F12:69,KC_PSCR:70,KC_SLCK:71,KC_PAUS:72,KC_INS:73,KC_HOME:74,KC_PGUP:75,KC_DEL:76,KC_END:77,KC_PGDN:78,KC_RGHT:79,KC_LEFT:80,KC_DOWN:81,KC_UP:82,KC_NLCK:83,KC_PSLS:84,KC_PAST:85,KC_PMNS:86,KC_PPLS:87,KC_PENT:88,KC_P1:89,KC_P2:90,KC_P3:91,KC_P4:92,KC_P5:93,KC_P6:94,KC_P7:95,KC_P8:96,KC_P9:97,KC_P0:98,KC_PDOT:99,KC_NUBS:100,KC_APP:101,KC_POWER:102,KC_PEQL:103,KC_F13:104,KC_F14:105,KC_F15:106,KC_F16:107,KC_F17:108,KC_F18:109,KC_F19:110,KC_F20:111,KC_F21:112,KC_F22:113,KC_F23:114,KC_F24:115,KC_EXECUTE:116,KC_HELP:117,KC_MENU:118,KC_SELECT:119,KC_STOP:120,KC_AGAIN:121,KC_UNDO:122,KC_CUT:123,KC_COPY:124,KC_PASTE:125,KC_FIND:126,KC_LCAP:130,KC_LNUM:131,KC_LSCR:132,KC_PCMM:133,KC_KP_EQUAL_AS400:134,KC_RO:135,KC_KANA:136,KC_JYEN:137,KC_HENK:138,KC_MHEN:139,KC_INT6:140,KC_INT7:141,KC_INT8:142,KC_INT9:143,KC_HAEN:144,KC_HANJ:145,KC_LANG3:146,KC_LANG4:147,KC_LANG5:148,KC_LANG6:149,KC_LANG7:150,KC_LANG8:151,KC_LANG9:152,KC_ERAS:153,KC_SYSREQ:154,KC_CANCEL:155,KC_CLR:156,KC_CLEAR:156,KC_PRIOR:157,KC_OUT:160,KC_OPER:161,KC_CLEAR_AGAIN:162,KC_CRSEL:163,KC_EXSEL:164,KC_PWR:165,KC_SLEP:166,KC_WAKE:167,KC_MUTE:168,KC_VOLU:169,KC_VOLD:170,KC_MNXT:171,KC_MPRV:172,KC_MSTP:173,KC_MPLY:174,KC_MSEL:175,KC_EJCT:176,KC_MAIL:177,KC_CALC:178,KC_MYCM:179,KC_WWW_SEARCH:180,KC_WWW_HOME:181,KC_WWW_BACK:182,KC_WWW_FORWARD:183,KC_WWW_STOP:184,KC_WWW_REFRESH:185,KC_WWW_FAVORITES:186,KC_MFFD:187,KC_MRWD:188,KC_BRIU:189,KC_BRID:190,KC_LCTL:224,KC_LSFT:225,KC_LALT:226,KC_LGUI:227,KC_RCTL:228,KC_RSFT:229,KC_RALT:230,KC_RGUI:231,KC_MS_UP:240,KC_MS_DOWN:241,KC_MS_LEFT:242,KC_MS_RIGHT:243,KC_MS_BTN1:244,KC_MS_BTN2:245,KC_MS_BTN3:246,KC_MS_BTN4:247,KC_MS_BTN5:248,KC_MS_WH_UP:249,KC_MS_WH_DOWN:250,KC_MS_WH_LEFT:251,KC_MS_WH_RIGHT:252,KC_MS_ACCEL0:253,KC_MS_ACCEL1:254,KC_MS_ACCEL2:255,RESET:23552,DEBUG:23553,MAGIC_TOGGLE_NKRO:23572,KC_GESC:23574,AU_ON:23581,AU_OFF:23582,AU_TOG:23583,CLICKY_TOGGLE:23584,CLICKY_ENABLE:23585,CLICKY_DISABLE:23586,CLICKY_UP:23587,CLICKY_DOWN:23588,CLICKY_RESET:23589,MU_ON:23590,MU_OFF:23591,MU_TOG:23592,MU_MOD:23593,BL_ON:23739,BL_OFF:23740,BL_DEC:23741,BL_INC:23742,BL_TOGG:23743,BL_STEP:23744,BL_BRTG:23745,RGB_TOG:23746,RGB_MOD:23747,RGB_RMOD:23748,RGB_HUI:23749,RGB_HUD:23750,RGB_SAI:23751,RGB_SAD:23752,RGB_VAI:23753,RGB_VAD:23754,RGB_SPI:23755,RGB_SPD:23756,RGB_M_P:23757,RGB_M_B:23758,RGB_M_R:23759,RGB_M_SW:23760,RGB_M_SN:23761,RGB_M_K:23762,RGB_M_X:23763,RGB_M_G:23764,KC_LSPO:23767,KC_RSPC:23768,KC_SFTENT:23769,KC_LCPO:23795,KC_RCPC:23796,KC_LAPO:23797,KC_RAPC:23798,BR_INC:24320,BR_DEC:24321,EF_INC:24322,EF_DEC:24323,ES_INC:24324,ES_DEC:24325,H1_INC:24326,H1_DEC:24327,S1_INC:24328,S1_DEC:24329,H2_INC:24330,H2_DEC:24331,S2_INC:24332,S2_DEC:24333,FN_MO13:24336,FN_MO23:24337},v11BasicKeyToByte={_QK_MODS:256,_QK_MODS_MAX:8191,_QK_MOD_TAP:8192,_QK_MOD_TAP_MAX:16383,_QK_LAYER_TAP:16384,_QK_LAYER_TAP_MAX:20479,_QK_LAYER_MOD:20480,_QK_LAYER_MOD_MAX:20991,_QK_TO:20992,_QK_TO_MAX:21023,_QK_MOMENTARY:21024,_QK_MOMENTARY_MAX:21055,_QK_DEF_LAYER:21056,_QK_DEF_LAYER_MAX:21087,_QK_TOGGLE_LAYER:21088,_QK_TOGGLE_LAYER_MAX:21119,_QK_ONE_SHOT_LAYER:21120,_QK_ONE_SHOT_LAYER_MAX:21151,_QK_ONE_SHOT_MOD:21152,_QK_ONE_SHOT_MOD_MAX:21183,_QK_LAYER_TAP_TOGGLE:21184,_QK_LAYER_TAP_TOGGLE_MAX:21215,_QK_LAYER_MOD_MASK:31,_QK_MACRO:30466,_QK_MACRO_MAX:30481,_QK_KB:32512,_QK_KB_MAX:32767,KC_NO:0,KC_TRNS:1,KC_A:4,KC_B:5,KC_C:6,KC_D:7,KC_E:8,KC_F:9,KC_G:10,KC_H:11,KC_I:12,KC_J:13,KC_K:14,KC_L:15,KC_M:16,KC_N:17,KC_O:18,KC_P:19,KC_Q:20,KC_R:21,KC_S:22,KC_T:23,KC_U:24,KC_V:25,KC_W:26,KC_X:27,KC_Y:28,KC_Z:29,KC_1:30,KC_2:31,KC_3:32,KC_4:33,KC_5:34,KC_6:35,KC_7:36,KC_8:37,KC_9:38,KC_0:39,KC_ENT:40,KC_ESC:41,KC_BSPC:42,KC_TAB:43,KC_SPC:44,KC_MINS:45,KC_EQL:46,KC_LBRC:47,KC_RBRC:48,KC_BSLS:49,KC_NUHS:50,KC_SCLN:51,KC_QUOT:52,KC_GRV:53,KC_COMM:54,KC_DOT:55,KC_SLSH:56,KC_CAPS:57,KC_F1:58,KC_F2:59,KC_F3:60,KC_F4:61,KC_F5:62,KC_F6:63,KC_F7:64,KC_F8:65,KC_F9:66,KC_F10:67,KC_F11:68,KC_F12:69,KC_PSCR:70,KC_SLCK:71,KC_PAUS:72,KC_INS:73,KC_HOME:74,KC_PGUP:75,KC_DEL:76,KC_END:77,KC_PGDN:78,KC_RGHT:79,KC_LEFT:80,KC_DOWN:81,KC_UP:82,KC_NLCK:83,KC_PSLS:84,KC_PAST:85,KC_PMNS:86,KC_PPLS:87,KC_PENT:88,KC_P1:89,KC_P2:90,KC_P3:91,KC_P4:92,KC_P5:93,KC_P6:94,KC_P7:95,KC_P8:96,KC_P9:97,KC_P0:98,KC_PDOT:99,KC_NUBS:100,KC_APP:101,KC_POWER:102,KC_PEQL:103,KC_F13:104,KC_F14:105,KC_F15:106,KC_F16:107,KC_F17:108,KC_F18:109,KC_F19:110,KC_F20:111,KC_F21:112,KC_F22:113,KC_F23:114,KC_F24:115,KC_EXECUTE:116,KC_HELP:117,KC_MENU:118,KC_SELECT:119,KC_STOP:120,KC_AGAIN:121,KC_UNDO:122,KC_CUT:123,KC_COPY:124,KC_PASTE:125,KC_FIND:126,KC_LCAP:130,KC_LNUM:131,KC_LSCR:132,KC_PCMM:133,KC_KP_EQUAL_AS400:134,KC_RO:135,KC_KANA:136,KC_JYEN:137,KC_HENK:138,KC_MHEN:139,KC_INT6:140,KC_INT7:141,KC_INT8:142,KC_INT9:143,KC_HAEN:144,KC_HANJ:145,KC_LANG3:146,KC_LANG4:147,KC_LANG5:148,KC_LANG6:149,KC_LANG7:150,KC_LANG8:151,KC_LANG9:152,KC_ERAS:153,KC_SYSREQ:154,KC_CANCEL:155,KC_CLR:156,KC_CLEAR:156,KC_PRIOR:157,KC_OUT:160,KC_OPER:161,KC_CLEAR_AGAIN:162,KC_CRSEL:163,KC_EXSEL:164,KC_PWR:165,KC_SLEP:166,KC_WAKE:167,KC_MUTE:168,KC_VOLU:169,KC_VOLD:170,KC_MNXT:171,KC_MPRV:172,KC_MSTP:173,KC_MPLY:174,KC_MSEL:175,KC_EJCT:176,KC_MAIL:177,KC_CALC:178,KC_MYCM:179,KC_WWW_SEARCH:180,KC_WWW_HOME:181,KC_WWW_BACK:182,KC_WWW_FORWARD:183,KC_WWW_STOP:184,KC_WWW_REFRESH:185,KC_WWW_FAVORITES:186,KC_MFFD:187,KC_MRWD:188,KC_BRIU:189,KC_BRID:190,KC_MS_UP:205,KC_MS_DOWN:206,KC_MS_LEFT:207,KC_MS_RIGHT:208,KC_MS_BTN1:209,KC_MS_BTN2:210,KC_MS_BTN3:211,KC_MS_BTN4:212,KC_MS_BTN5:213,KC_MS_BTN6:214,KC_MS_BTN7:215,KC_MS_BTN8:216,KC_MS_WH_UP:217,KC_MS_WH_DOWN:218,KC_MS_WH_LEFT:219,KC_MS_WH_RIGHT:220,KC_MS_ACCEL0:221,KC_MS_ACCEL1:222,KC_MS_ACCEL2:223,KC_LCTL:224,KC_LSFT:225,KC_LALT:226,KC_LGUI:227,KC_RCTL:228,KC_RSFT:229,KC_RALT:230,KC_RGUI:231,RESET:31744,DEBUG:31746,MAGIC_TOGGLE_NKRO:28691,KC_GESC:31766,KC_ASUP:31761,KC_ASDN:31760,KC_ASRP:31762,KC_ASTG:31765,KC_ASON:31763,KC_ASOFF:31764,AU_ON:29824,AU_OFF:29825,AU_TOG:29826,CLICKY_TOGGLE:29834,CLICKY_ENABLE:29835,CLICKY_DISABLE:29836,CLICKY_UP:29837,CLICKY_DOWN:29838,CLICKY_RESET:29839,MU_ON:29840,MU_OFF:29841,MU_TOG:29842,MU_MOD:29843,MI_ON:28928,MI_OFF:28929,MI_TOG:28930,MI_C:28944,MI_Cs:28945,MI_D:28946,MI_Ds:28947,MI_E:28948,MI_F:28949,MI_Fs:28950,MI_G:28951,MI_Gs:28952,MI_A:28953,MI_As:28954,MI_B:28955,MI_C_1:28960,MI_Cs_1:28961,MI_D_1:28962,MI_Ds_1:28963,MI_E_1:28964,MI_F_1:28965,MI_Fs_1:28966,MI_G_1:28967,MI_Gs_1:28968,MI_A_1:28969,MI_As_1:28970,MI_B_1:28971,MI_C_2:28976,MI_Cs_2:28977,MI_D_2:28978,MI_Ds_2:28979,MI_E_2:28980,MI_F_2:28981,MI_Fs_2:28982,MI_G_2:28983,MI_Gs_2:28984,MI_A_2:28985,MI_As_2:28986,MI_B_2:28987,MI_C_3:28992,MI_Cs_3:28993,MI_D_3:28994,MI_Ds_3:28995,MI_E_3:28996,MI_F_3:28997,MI_Fs_3:28998,MI_G_3:28999,MI_Gs_3:29e3,MI_A_3:29001,MI_As_3:29002,MI_B_3:29003,MI_C_4:29008,MI_Cs_4:29009,MI_D_4:29010,MI_Ds_4:29011,MI_E_4:29012,MI_F_4:29013,MI_Fs_4:29014,MI_G_4:29015,MI_Gs_4:29016,MI_A_4:29017,MI_As_4:29018,MI_B_4:29019,MI_C_5:29024,MI_Cs_5:29025,MI_D_5:29026,MI_Ds_5:29027,MI_E_5:29028,MI_F_5:29029,MI_Fs_5:29030,MI_G_5:29031,MI_Gs_5:29032,MI_A_5:29033,MI_As_5:29034,MI_B_5:29035,MI_OCT_N2:29040,MI_OCT_N1:29041,MI_OCT_0:29042,MI_OCT_1:29043,MI_OCT_2:29044,MI_OCT_3:29045,MI_OCT_4:29046,MI_OCT_5:29047,MI_OCT_6:29048,MI_OCT_7:29049,MI_OCTD:29050,MI_OCTU:29051,MI_TRNS_N6:29056,MI_TRNS_N5:29057,MI_TRNS_N4:29058,MI_TRNS_N3:29059,MI_TRNS_N2:29060,MI_TRNS_N1:29061,MI_TRNS_0:29062,MI_TRNS_1:29063,MI_TRNS_2:29064,MI_TRNS_3:29065,MI_TRNS_4:29066,MI_TRNS_5:29067,MI_TRNS_6:29068,MI_TRNSD:29069,MI_TRNSU:29070,MI_VEL_0:29072,MI_VEL_1:29073,MI_VEL_2:29074,MI_VEL_3:29075,MI_VEL_4:29076,MI_VEL_5:29077,MI_VEL_6:29078,MI_VEL_7:29079,MI_VEL_8:29080,MI_VEL_9:29081,MI_VEL_10:29082,MI_VELD:29083,MI_VELU:29084,MI_CH1:29088,MI_CH2:29089,MI_CH3:29090,MI_CH4:29091,MI_CH5:29092,MI_CH6:29093,MI_CH7:29094,MI_CH8:29095,MI_CH9:29096,MI_CH10:29097,MI_CH11:29098,MI_CH12:29099,MI_CH13:29100,MI_CH14:29101,MI_CH15:29102,MI_CH16:29103,MI_CHD:29104,MI_CHU:29105,MI_ALLOFF:29120,MI_SUST:29121,MI_PORT:29122,MI_SOST:29123,MI_SOFT:29124,MI_LEG:29125,MI_MOD:29126,MI_MODSD:29127,MI_MODSU:29128,MI_BENDD:29129,MI_BENDU:29130,BL_ON:30720,BL_OFF:30721,BL_DEC:30723,BL_INC:30724,BL_TOGG:30722,BL_STEP:30725,BL_BRTG:30726,RGB_TOG:30752,RGB_MOD:30753,RGB_RMOD:30754,RGB_HUI:30755,RGB_HUD:30756,RGB_SAI:30757,RGB_SAD:30758,RGB_VAI:30759,RGB_VAD:30760,RGB_SPI:30761,RGB_SPD:30762,RGB_M_P:30763,RGB_M_B:30764,RGB_M_R:30765,RGB_M_SW:30766,RGB_M_SN:30767,RGB_M_K:30768,RGB_M_X:30769,RGB_M_G:30770,RGB_MODE_RGBTEST:30771,VLK_TOG:31767,KC_LSPO:31770,KC_RSPC:31771,KC_SFTENT:31774,OUT_AUTO:31776,OUT_USB:31777,QK_CLEAR_EEPROM:31747,HPT_ON:31808,HPT_OFF:31809,HPT_TOG:31810,HPT_RST:31811,HPT_FBK:31812,HPT_BUZ:31813,HPT_MODI:31814,HPT_MODD:31815,HPT_CONT:31816,HPT_CONI:31817,HPT_COND:31818,HPT_DWLI:31819,HPT_DWLD:31820,KC_LCPO:31768,KC_RCPC:31769,KC_LAPO:31772,KC_RAPC:31773,CMB_ON:31824,CMB_OFF:31825,CMB_TOG:31826,MAGIC_SWAP_LCTL_LGUI:28695,MAGIC_SWAP_RCTL_RGUI:28697,MAGIC_UNSWAP_LCTL_LGUI:28696,MAGIC_UNSWAP_RCTL_RGUI:28698,MAGIC_SWAP_CTL_GUI:28699,MAGIC_UNSWAP_CTL_GUI:28700,MAGIC_TOGGLE_CTL_GUI:28701,MAGIC_EE_HANDS_LEFT:28702,MAGIC_EE_HANDS_RIGHT:28703,DYN_REC_START1:31827,DYN_REC_START2:31828,DYN_REC_STOP:31829,DYN_MACRO_PLAY1:31830,DYN_MACRO_PLAY2:31831,FN_MO13:30464,FN_MO23:30465},v12BasicKeyToByte={_QK_MODS:256,_QK_MODS_MAX:8191,_QK_MOD_TAP:8192,_QK_MOD_TAP_MAX:16383,_QK_LAYER_TAP:16384,_QK_LAYER_TAP_MAX:20479,_QK_LAYER_MOD:20480,_QK_LAYER_MOD_MAX:20991,_QK_TO:20992,_QK_TO_MAX:21023,_QK_MOMENTARY:21024,_QK_MOMENTARY_MAX:21055,_QK_DEF_LAYER:21056,_QK_DEF_LAYER_MAX:21087,_QK_TOGGLE_LAYER:21088,_QK_TOGGLE_LAYER_MAX:21119,_QK_ONE_SHOT_LAYER:21120,_QK_ONE_SHOT_LAYER_MAX:21151,_QK_ONE_SHOT_MOD:21152,_QK_ONE_SHOT_MOD_MAX:21183,_QK_LAYER_TAP_TOGGLE:21184,_QK_LAYER_TAP_TOGGLE_MAX:21215,_QK_LAYER_MOD_MASK:31,_QK_TAP_DANCE:22272,_QK_TAP_DANCE_MAX:22527,_QK_MACRO:30464,_QK_MACRO_MAX:30591,_QK_KB:32256,_QK_KB_MAX:32511,KC_NO:0,KC_TRNS:1,KC_A:4,KC_B:5,KC_C:6,KC_D:7,KC_E:8,KC_F:9,KC_G:10,KC_H:11,KC_I:12,KC_J:13,KC_K:14,KC_L:15,KC_M:16,KC_N:17,KC_O:18,KC_P:19,KC_Q:20,KC_R:21,KC_S:22,KC_T:23,KC_U:24,KC_V:25,KC_W:26,KC_X:27,KC_Y:28,KC_Z:29,KC_1:30,KC_2:31,KC_3:32,KC_4:33,KC_5:34,KC_6:35,KC_7:36,KC_8:37,KC_9:38,KC_0:39,KC_ENT:40,KC_ESC:41,KC_BSPC:42,KC_TAB:43,KC_SPC:44,KC_MINS:45,KC_EQL:46,KC_LBRC:47,KC_RBRC:48,KC_BSLS:49,KC_NUHS:50,KC_SCLN:51,KC_QUOT:52,KC_GRV:53,KC_COMM:54,KC_DOT:55,KC_SLSH:56,KC_CAPS:57,KC_F1:58,KC_F2:59,KC_F3:60,KC_F4:61,KC_F5:62,KC_F6:63,KC_F7:64,KC_F8:65,KC_F9:66,KC_F10:67,KC_F11:68,KC_F12:69,KC_PSCR:70,KC_SLCK:71,KC_PAUS:72,KC_INS:73,KC_HOME:74,KC_PGUP:75,KC_DEL:76,KC_END:77,KC_PGDN:78,KC_RGHT:79,KC_LEFT:80,KC_DOWN:81,KC_UP:82,KC_NLCK:83,KC_PSLS:84,KC_PAST:85,KC_PMNS:86,KC_PPLS:87,KC_PENT:88,KC_P1:89,KC_P2:90,KC_P3:91,KC_P4:92,KC_P5:93,KC_P6:94,KC_P7:95,KC_P8:96,KC_P9:97,KC_P0:98,KC_PDOT:99,KC_NUBS:100,KC_APP:101,KC_POWER:102,KC_PEQL:103,KC_F13:104,KC_F14:105,KC_F15:106,KC_F16:107,KC_F17:108,KC_F18:109,KC_F19:110,KC_F20:111,KC_F21:112,KC_F22:113,KC_F23:114,KC_F24:115,KC_EXECUTE:116,KC_HELP:117,KC_MENU:118,KC_SELECT:119,KC_STOP:120,KC_AGAIN:121,KC_UNDO:122,KC_CUT:123,KC_COPY:124,KC_PASTE:125,KC_FIND:126,KC_LCAP:130,KC_LNUM:131,KC_LSCR:132,KC_PCMM:133,KC_KP_EQUAL_AS400:134,KC_RO:135,KC_KANA:136,KC_JYEN:137,KC_HENK:138,KC_MHEN:139,KC_INT6:140,KC_INT7:141,KC_INT8:142,KC_INT9:143,KC_HAEN:144,KC_HANJ:145,KC_LANG3:146,KC_LANG4:147,KC_LANG5:148,KC_LANG6:149,KC_LANG7:150,KC_LANG8:151,KC_LANG9:152,KC_ERAS:153,KC_SYSREQ:154,KC_CANCEL:155,KC_CLR:156,KC_CLEAR:156,KC_PRIOR:157,KC_OUT:160,KC_OPER:161,KC_CLEAR_AGAIN:162,KC_CRSEL:163,KC_EXSEL:164,KC_PWR:165,KC_SLEP:166,KC_WAKE:167,KC_MUTE:168,KC_VOLU:169,KC_VOLD:170,KC_MNXT:171,KC_MPRV:172,KC_MSTP:173,KC_MPLY:174,KC_MSEL:175,KC_EJCT:176,KC_MAIL:177,KC_CALC:178,KC_MYCM:179,KC_WWW_SEARCH:180,KC_WWW_HOME:181,KC_WWW_BACK:182,KC_WWW_FORWARD:183,KC_WWW_STOP:184,KC_WWW_REFRESH:185,KC_WWW_FAVORITES:186,KC_MFFD:187,KC_MRWD:188,KC_BRIU:189,KC_BRID:190,KC_MS_UP:205,KC_MS_DOWN:206,KC_MS_LEFT:207,KC_MS_RIGHT:208,KC_MS_BTN1:209,KC_MS_BTN2:210,KC_MS_BTN3:211,KC_MS_BTN4:212,KC_MS_BTN5:213,KC_MS_BTN6:214,KC_MS_BTN7:215,KC_MS_BTN8:216,KC_MS_WH_UP:217,KC_MS_WH_DOWN:218,KC_MS_WH_LEFT:219,KC_MS_WH_RIGHT:220,KC_MS_ACCEL0:221,KC_MS_ACCEL1:222,KC_MS_ACCEL2:223,KC_LCTL:224,KC_LSFT:225,KC_LALT:226,KC_LGUI:227,KC_RCTL:228,KC_RSFT:229,KC_RALT:230,KC_RGUI:231,CL_SWAP:28672,CL_NORM:28673,CL_TOGG:28674,CL_CAPS:28675,CL_CTRL:28676,AG_LSWP:28677,AG_LNRM:28678,AG_RSWP:28679,AG_RNRM:28680,GU_ON:28681,GU_OFF:28682,GU_TOGG:28683,GE_SWAP:28684,GE_NORM:28685,BS_SWAP:28686,BS_NORM:28687,BS_TOGG:28688,NK_ON:28689,NK_OFF:28690,NK_TOGG:28691,AG_SWAP:28692,AG_NORM:28693,AG_TOGG:28694,CG_LSWP:28695,CG_LNRM:28696,CG_RSWP:28697,CG_RNRM:28698,CG_SWAP:28699,CG_NORM:28700,CG_TOGG:28701,EH_LEFT:28702,EH_RGHT:28703,EC_SWAP:28704,EC_NORM:28705,EC_TOGG:28706,RESET:31744,DEBUG:31746,MAGIC_TOGGLE_NKRO:28691,KC_GESC:31766,KC_ASUP:31761,KC_ASDN:31760,KC_ASRP:31762,KC_ASTG:31765,KC_ASON:31763,KC_ASOFF:31764,AU_ON:29824,AU_OFF:29825,AU_TOG:29826,CLICKY_TOGGLE:29834,CLICKY_ENABLE:29835,CLICKY_DISABLE:29836,CLICKY_UP:29837,CLICKY_DOWN:29838,CLICKY_RESET:29839,MU_ON:29840,MU_OFF:29841,MU_TOG:29842,MU_MOD:29843,MI_ON:28928,MI_OFF:28929,MI_TOG:28930,MI_C:28944,MI_Cs:28945,MI_D:28946,MI_Ds:28947,MI_E:28948,MI_F:28949,MI_Fs:28950,MI_G:28951,MI_Gs:28952,MI_A:28953,MI_As:28954,MI_B:28955,MI_C_1:28960,MI_Cs_1:28961,MI_D_1:28962,MI_Ds_1:28963,MI_E_1:28964,MI_F_1:28965,MI_Fs_1:28966,MI_G_1:28967,MI_Gs_1:28968,MI_A_1:28969,MI_As_1:28970,MI_B_1:28971,MI_C_2:28976,MI_Cs_2:28977,MI_D_2:28978,MI_Ds_2:28979,MI_E_2:28980,MI_F_2:28981,MI_Fs_2:28982,MI_G_2:28983,MI_Gs_2:28984,MI_A_2:28985,MI_As_2:28986,MI_B_2:28987,MI_C_3:28992,MI_Cs_3:28993,MI_D_3:28994,MI_Ds_3:28995,MI_E_3:28996,MI_F_3:28997,MI_Fs_3:28998,MI_G_3:28999,MI_Gs_3:29e3,MI_A_3:29001,MI_As_3:29002,MI_B_3:29003,MI_C_4:29008,MI_Cs_4:29009,MI_D_4:29010,MI_Ds_4:29011,MI_E_4:29012,MI_F_4:29013,MI_Fs_4:29014,MI_G_4:29015,MI_Gs_4:29016,MI_A_4:29017,MI_As_4:29018,MI_B_4:29019,MI_C_5:29024,MI_Cs_5:29025,MI_D_5:29026,MI_Ds_5:29027,MI_E_5:29028,MI_F_5:29029,MI_Fs_5:29030,MI_G_5:29031,MI_Gs_5:29032,MI_A_5:29033,MI_As_5:29034,MI_B_5:29035,MI_OCT_N2:29040,MI_OCT_N1:29041,MI_OCT_0:29042,MI_OCT_1:29043,MI_OCT_2:29044,MI_OCT_3:29045,MI_OCT_4:29046,MI_OCT_5:29047,MI_OCT_6:29048,MI_OCT_7:29049,MI_OCTD:29050,MI_OCTU:29051,MI_TRNS_N6:29056,MI_TRNS_N5:29057,MI_TRNS_N4:29058,MI_TRNS_N3:29059,MI_TRNS_N2:29060,MI_TRNS_N1:29061,MI_TRNS_0:29062,MI_TRNS_1:29063,MI_TRNS_2:29064,MI_TRNS_3:29065,MI_TRNS_4:29066,MI_TRNS_5:29067,MI_TRNS_6:29068,MI_TRNSD:29069,MI_TRNSU:29070,MI_VEL_0:29072,MI_VEL_1:29073,MI_VEL_2:29074,MI_VEL_3:29075,MI_VEL_4:29076,MI_VEL_5:29077,MI_VEL_6:29078,MI_VEL_7:29079,MI_VEL_8:29080,MI_VEL_9:29081,MI_VEL_10:29082,MI_VELD:29083,MI_VELU:29084,MI_CH1:29088,MI_CH2:29089,MI_CH3:29090,MI_CH4:29091,MI_CH5:29092,MI_CH6:29093,MI_CH7:29094,MI_CH8:29095,MI_CH9:29096,MI_CH10:29097,MI_CH11:29098,MI_CH12:29099,MI_CH13:29100,MI_CH14:29101,MI_CH15:29102,MI_CH16:29103,MI_CHD:29104,MI_CHU:29105,MI_ALLOFF:29120,MI_SUST:29121,MI_PORT:29122,MI_SOST:29123,MI_SOFT:29124,MI_LEG:29125,MI_MOD:29126,MI_MODSD:29127,MI_MODSU:29128,MI_BENDD:29129,MI_BENDU:29130,BL_ON:30720,BL_OFF:30721,BL_DEC:30723,BL_INC:30724,BL_TOGG:30722,BL_STEP:30725,BL_BRTG:30726,RGB_TOG:30752,RGB_MOD:30753,RGB_RMOD:30754,RGB_HUI:30755,RGB_HUD:30756,RGB_SAI:30757,RGB_SAD:30758,RGB_VAI:30759,RGB_VAD:30760,RGB_SPI:30761,RGB_SPD:30762,RGB_M_P:30763,RGB_M_B:30764,RGB_M_R:30765,RGB_M_SW:30766,RGB_M_SN:30767,RGB_M_K:30768,RGB_M_X:30769,RGB_M_G:30770,RGB_MODE_RGBTEST:30771,VLK_TOG:31767,KC_LSPO:31770,KC_RSPC:31771,KC_SFTENT:31774,OUT_AUTO:31776,OUT_USB:31777,QK_CLEAR_EEPROM:31747,HPT_ON:31808,HPT_OFF:31809,HPT_TOG:31810,HPT_RST:31811,HPT_FBK:31812,HPT_BUZ:31813,HPT_MODI:31814,HPT_MODD:31815,HPT_CONT:31816,HPT_CONI:31817,HPT_COND:31818,HPT_DWLI:31819,HPT_DWLD:31820,KC_LCPO:31768,KC_RCPC:31769,KC_LAPO:31772,KC_RAPC:31773,CMB_ON:31824,CMB_OFF:31825,CMB_TOG:31826,MAGIC_SWAP_LCTL_LGUI:28695,MAGIC_SWAP_RCTL_RGUI:28697,MAGIC_UNSWAP_LCTL_LGUI:28696,MAGIC_UNSWAP_RCTL_RGUI:28698,MAGIC_SWAP_CTL_GUI:28699,MAGIC_UNSWAP_CTL_GUI:28700,MAGIC_TOGGLE_CTL_GUI:28701,MAGIC_EE_HANDS_LEFT:28702,MAGIC_EE_HANDS_RIGHT:28703,DYN_REC_START1:31827,DYN_REC_START2:31828,DYN_REC_STOP:31829,DYN_MACRO_PLAY1:31830,DYN_MACRO_PLAY2:31831,FN_MO13:31863,FN_MO23:31864};function getBasicKeyDict(e){switch(e){case 13:case 12:return v12BasicKeyToByte;case 11:return v11BasicKeyToByte;case 10:return v10BasicKeyToByte;default:return basicKeyToByte}}const autocompleteKeycodes={KC_NO:!0,KC_A:!0,KC_B:!0,KC_C:!0,KC_D:!0,KC_E:!0,KC_F:!0,KC_G:!0,KC_H:!0,KC_I:!0,KC_J:!0,KC_K:!0,KC_L:!0,KC_M:!0,KC_N:!0,KC_O:!0,KC_P:!0,KC_Q:!0,KC_R:!0,KC_S:!0,KC_T:!0,KC_U:!0,KC_V:!0,KC_W:!0,KC_X:!0,KC_Y:!0,KC_Z:!0,KC_1:!0,KC_2:!0,KC_3:!0,KC_4:!0,KC_5:!0,KC_6:!0,KC_7:!0,KC_8:!0,KC_9:!0,KC_0:!0,KC_ENT:!0,KC_ESC:!0,KC_BSPC:!0,KC_TAB:!0,KC_SPC:!0,KC_MINS:!0,KC_EQL:!0,KC_LBRC:!0,KC_RBRC:!0,KC_BSLS:!0,KC_NUHS:!0,KC_SCLN:!0,KC_QUOT:!0,KC_GRV:!0,KC_COMM:!0,KC_DOT:!0,KC_SLSH:!0,KC_CAPS:!0,KC_F1:!0,KC_F2:!0,KC_F3:!0,KC_F4:!0,KC_F5:!0,KC_F6:!0,KC_F7:!0,KC_F8:!0,KC_F9:!0,KC_F10:!0,KC_F11:!0,KC_F12:!0,KC_PSCR:!0,KC_SLCK:!0,KC_PAUS:!0,KC_INS:!0,KC_HOME:!0,KC_PGUP:!0,KC_DEL:!0,KC_END:!0,KC_PGDN:!0,KC_RGHT:!0,KC_LEFT:!0,KC_DOWN:!0,KC_UP:!0,KC_NLCK:!0,KC_PSLS:!0,KC_KP_ASTERISK:!0,KC_PAST:!0,KC_PPLS:!0,KC_PMNS:!0,KC_PENT:!0,KC_P1:!0,KC_P2:!0,KC_P3:!0,KC_P4:!0,KC_P5:!0,KC_P6:!0,KC_P7:!0,KC_P8:!0,KC_P9:!0,KC_P0:!0,KC_PDOT:!0,KC_NUBS:!0,KC_APP:!0,KC_POWER:!0,KC_PEQL:!0,KC_F13:!0,KC_F14:!0,KC_F15:!0,KC_F16:!0,KC_F17:!0,KC_F18:!0,KC_F19:!0,KC_F20:!0,KC_F21:!0,KC_F22:!0,KC_F23:!0,KC_F24:!0,KC_EXECUTE:!0,KC_HELP:!0,KC_MENU:!0,KC_SELECT:!0,KC_STOP:!0,KC_AGAIN:!0,KC_UNDO:!0,KC_CUT:!0,KC_COPY:!0,KC_PASTE:!0,KC_FIND:!0,KC_LCAP:!0,KC_LNUM:!0,KC_LSCR:!0,KC_PCMM:!0,KC_KP_EQUAL_AS400:!0,KC_RO:!0,KC_KANA:!0,KC_JYEN:!0,KC_HENK:!0,KC_MHEN:!0,KC_INT6:!0,KC_INT7:!0,KC_INT8:!0,KC_INT9:!0,KC_HAEN:!0,KC_HANJ:!0,KC_LANG3:!0,KC_LANG4:!0,KC_LANG5:!0,KC_LANG6:!0,KC_LANG7:!0,KC_LANG8:!0,KC_LANG9:!0,KC_SYSREQ:!0,KC_CANCEL:!0,KC_CLEAR:!0,KC_PRIOR:!0,KC_OUT:!0,KC_OPER:!0,KC_CLEAR_AGAIN:!0,KC_CRSEL:!0,KC_EXSEL:!0,KC_LCTL:!0,KC_LSFT:!0,KC_LALT:!0,KC_LGUI:!0,KC_RCTL:!0,KC_RSFT:!0,KC_RALT:!0,KC_RGUI:!0,KC_PWR:!0,KC_SLEP:!0,KC_WAKE:!0,KC_MUTE:!0,KC_VOLU:!0,KC_VOLD:!0,KC_MNXT:!0,KC_MPRV:!0,KC_MSTP:!0,KC_MPLY:!0,KC_MSEL:!0,KC_EJCT:!0,KC_MAIL:!0,KC_CALC:!0,KC_MYCM:!0,KC_WWW_SEARCH:!0,KC_WWW_HOME:!0,KC_WWW_BACK:!0,KC_WWW_FORWARD:!0,KC_WWW_STOP:!0,KC_WWW_REFRESH:!0,KC_WWW_FAVORITES:!0,KC_MFFD:!0,KC_MRWD:!0,KC_MS_UP:!0,KC_MS_DOWN:!0,KC_MS_LEFT:!0,KC_MS_RIGHT:!0,KC_MS_BTN1:!0,KC_MS_BTN2:!0,KC_MS_BTN3:!0,KC_MS_BTN4:!0,KC_MS_BTN5:!0,KC_MS_BTN6:!0,KC_MS_BTN7:!0,KC_MS_BTN8:!0,KC_MS_WH_UP:!0,KC_MS_WH_DOWN:!0,KC_MS_WH_LEFT:!0,KC_MS_WH_RIGHT:!0,KC_MS_ACCEL0:!0,KC_MS_ACCEL1:!0,KC_MS_ACCEL2:!0},getAutocompleteKeycodes=()=>keycodesList.filter(e=>!!autocompleteKeycodes[e.code]);function isAutocompleteKeycode(e){const t=e.toUpperCase();return!!autocompleteKeycodes[t]}var RawKeycodeSequenceAction=(e=>(e[e.Tap=1]="Tap",e[e.Down=2]="Down",e[e.Up=3]="Up",e[e.Delay=4]="Delay",e[e.CharacterStream=5]="CharacterStream",e))(RawKeycodeSequenceAction||{}),GroupedKeycodeSequenceAction=(e=>(e[e.Chord=6]="Chord",e))(GroupedKeycodeSequenceAction||{}),KeyAction=(e=>(e[e.Tap=1]="Tap",e[e.Down=2]="Down",e[e.Up=3]="Up",e[e.Delay=4]="Delay",e))(KeyAction||{});const KeyActionPrefix=1,DelayTerminator=124,MacroTerminator=0;function splitExpression(expression){let regex;try{return regex=eval("/(?<!\\\\)({.*?})/g"),expression.split(regex).filter(e=>e.length)}catch(e){return console.error("Lookbehind is not supported in this browser."),[]}}function optimizedSequenceToRawSequence(e){return e.flatMap(t=>{if(t[0]==GroupedKeycodeSequenceAction.Chord){const r=s=>a=>[s,a];return[...t[1]].map(r(RawKeycodeSequenceAction.Down)).concat([...t[1]].reverse().map(r(RawKeycodeSequenceAction.Up)))}else return[t]})}function rawSequenceToOptimizedSequence(e){let t=[];return t=convertToTapsAndChords(e),t}function convertToTapsAndChords(e){let t=[],r=[],s=0;const a=e.reduce((d,p)=>p[0]===RawKeycodeSequenceAction.Tap?[...d,[RawKeycodeSequenceAction.Down,p[1]],[RawKeycodeSequenceAction.Up,p[1]]]:[...d,p],[]);let l=[];a.forEach((d,p)=>{let f=!1;if(t.push(d),d[0]===RawKeycodeSequenceAction.Down)s==r.length&&(r.push(d[1]),s++,f=!0);else if(d[0]===RawKeycodeSequenceAction.Up){const m=d[1];r.length>0&&m===r[s-1]&&(s--,s==0?(r.length===1?l.push([RawKeycodeSequenceAction.Tap,r[0]]):l.push([GroupedKeycodeSequenceAction.Chord,r]),t=[]):f=!0)}p===a.length-1&&(f=!1),f||(l.push(...t),t=[],r=[],s=0)});let c=[];for(let d=0;d<l.length;d++)d+1<l.length&&l[d][0]==RawKeycodeSequenceAction.Down&&l[d+1][0]==RawKeycodeSequenceAction.Up&&l[d][1]===l[d+1][1]?(c.push([RawKeycodeSequenceAction.Tap,l[d][1]]),d++):c.push(l[d]);return c}const mapKeycodeToCharacterStream={KC_A:["a","A"],KC_B:["b","B"],KC_C:["c","C"],KC_D:["d","D"],KC_E:["e","E"],KC_F:["f","F"],KC_G:["g","G"],KC_H:["h","H"],KC_I:["i","I"],KC_J:["j","J"],KC_K:["k","K"],KC_L:["l","L"],KC_M:["m","M"],KC_N:["n","N"],KC_O:["o","O"],KC_P:["p","P"],KC_Q:["q","Q"],KC_R:["r","R"],KC_S:["s","S"],KC_T:["t","T"],KC_U:["u","U"],KC_V:["v","V"],KC_W:["w","W"],KC_X:["x","X"],KC_Y:["y","Y"],KC_Z:["z","Z"],KC_1:["1","!"],KC_2:["2","@"],KC_3:["3","#"],KC_4:["4","$"],KC_5:["5","%"],KC_6:["6","^"],KC_7:["7","&"],KC_8:["8","*"],KC_9:["9","("],KC_0:["0",")"],KC_SPC:[" "," "],KC_MINS:["-","_"],KC_EQL:["=","+"],KC_LBRC:["[","{"],KC_RBRC:["]","}"],KC_BSLS:["\\","|"],KC_SCLN:[";",":"],KC_QUOT:["'",'"'],KC_GRV:["`","~"],KC_COMM:[",","<"],KC_DOT:[".",">"],KC_SLSH:["/","?"]},mapCharToShiftedChar=Object.values(mapKeycodeToCharacterStream).reduce((e,[t,r])=>({...e,[t]:r}),{});function convertCharacterTaps(e){return e.reduce((r,s)=>s[0]==RawKeycodeSequenceAction.Down&&s[1]in mapKeycodeToCharacterStream?[...r,[RawKeycodeSequenceAction.Tap,s[1]]]:s[0]==RawKeycodeSequenceAction.Up&&s[1]in mapKeycodeToCharacterStream?r:[...r,s],[])}function trimLastWait(e){return e[e.length-1]&&e[e.length-1][0]===RawKeycodeSequenceAction.Delay?e.slice(0,-1):e}function mergeConsecutiveWaits(e){return e.reduce((t,r)=>(t[t.length-1]&&t[t.length-1][0]===RawKeycodeSequenceAction.Delay&&r[0]===RawKeycodeSequenceAction.Delay?t.splice(-1,1,[RawKeycodeSequenceAction.Delay,Number(t[t.length-1][1])+Number(r[1])]):t.push(r),t),[])}function foldKeydownKeyupKeys(e){return e.reduce((t,r)=>(t[t.length-1]&&t[t.length-1][0]===RawKeycodeSequenceAction.Down&&r[0]===RawKeycodeSequenceAction.Up&&t[t.length-1][1]===r[1]?t.splice(-1,1,[RawKeycodeSequenceAction.Tap,r[1]]):t.push(r),t),[])}function convertToCharacterStreams(e){let t=e.reduce((a,l)=>{if(l[0]==RawKeycodeSequenceAction.Tap&&l[1]in mapKeycodeToCharacterStream){const c=mapKeycodeToCharacterStream[l[1]][0];return a[a.length-1]!==void 0&&a[a.length-1][0]===RawKeycodeSequenceAction.CharacterStream?[...a.slice(0,-1),[RawKeycodeSequenceAction.CharacterStream,a[a.length-1][1]+c]]:[...a,[RawKeycodeSequenceAction.CharacterStream,c]]}else return[...a,l]},[]),r=[];for(let a=0;a<t.length;a++)if(a+2<t.length&&t[a][0]===RawKeycodeSequenceAction.Down&&t[a+1][0]===RawKeycodeSequenceAction.CharacterStream&&t[a+2][0]===RawKeycodeSequenceAction.Up&&t[a][1]===t[a+2][1]&&(t[a][1]==="KC_LSFT"||t[a][1]==="KC_RSFT")){const l=t[a+1][1].split("").map(c=>mapCharToShiftedChar[c]).join("");r.push([RawKeycodeSequenceAction.CharacterStream,l]),a+=2}else r.push(t[a]);return r.reduce((a,l)=>l[0]===RawKeycodeSequenceAction.CharacterStream&&a[a.length-1]!==void 0&&a[a.length-1][0]===RawKeycodeSequenceAction.CharacterStream?(a[a.length-1][1]=a[a.length-1][1].concat(l[1]),a):[...a,l],[])}function sequenceToExpression(e){let t=[];return e.forEach(r=>{switch(r[0]){case RawKeycodeSequenceAction.Tap:t.push("{"+r[1]+"}");break;case RawKeycodeSequenceAction.Down:t.push("{+"+r[1]+"}");break;case RawKeycodeSequenceAction.Up:t.push("{-"+r[1]+"}");break;case RawKeycodeSequenceAction.Delay:t.push("{"+r[1]+"}");break;case GroupedKeycodeSequenceAction.Chord:t.push("{"+r[1].join(",")+"}");break;case RawKeycodeSequenceAction.CharacterStream:t.push(r[1].replace(/{/g,"\\{"))}}),t.join("")}function expressionToSequence(e){let t=splitExpression(e),r=[];return t.forEach(s=>{if(/^{.*}$/.test(s))if(s=s.slice(1,-1),/^\d+$/.test(s))r.push([RawKeycodeSequenceAction.Delay,parseInt(s)]);else{const a=/^[+-]/.test(s)?s.slice(0,1):null,l=s.replace(/^[+-]/,"").split(",").map(c=>c.trim().toUpperCase()).filter(c=>c.length);if(l.length>0)if(a==null)l.length==1?r.push([RawKeycodeSequenceAction.Tap,l[0]]):r.push([GroupedKeycodeSequenceAction.Chord,l]);else{const c=a=="+"?RawKeycodeSequenceAction.Down:RawKeycodeSequenceAction.Up;r.push([c,l[0]])}}else s=s.replace(/\\{/g,"{"),r.push([RawKeycodeSequenceAction.CharacterStream,s])}),r}function validateMacroExpression(expression){let unclosedBlockRegex,keycodeBlockRegex;try{unclosedBlockRegex=eval("/(?<!\\\\){(?![^{]*})/"),keycodeBlockRegex=eval("/(?<!\\\\){(.*?)}/g")}catch(e){return console.error("Lookbehind is not supported in this browser."),{isValid:!1,errorMessage:"Lookbehind is not supported in this browser."}}if(expression.match(unclosedBlockRegex))return{isValid:!1,errorMessage:"Looks like a keycode block - {} - is unclosed! Are you missing an '}'?"};let groups=null;for(;groups=keycodeBlockRegex.exec(expression);){const e=groups[1].replace(/\s+/g,"");if(!e.length)return{isValid:!1,errorMessage:"Sorry, I can't handle empty {}. Fill them up with keycodes or use \\{} to tell the macro to literally type {}"};const t=e.split(",").filter(r=>r.trim().length&&!isAutocompleteKeycode(r));if(t.length)return{isValid:!1,errorMessage:`Whoops! Invalid keycodes detected inside {}: ${t.join(", ")}`}}return{isValid:!0,errorMessage:void 0}}class MacroAPI{constructor(t,r,s){this.keyboardApi=t,this.basicKeyToByte=r,this.byteToKey=s}async readRawKeycodeSequences(){const t=await this.keyboardApi.getMacroBytes(),r=await this.keyboardApi.getMacroCount();let s=0,a=0;const l=[];let c=[];if(r===0)throw Error("Macros are disabled");for(;a<t.length&&s<r;){let d=t[a];switch(d){case MacroTerminator:l[s]=c,s++,c=[];break;case KeyAction.Tap:d=t[++a],c.push([RawKeycodeSequenceAction.Tap,this.byteToKey[d]]);break;case KeyAction.Down:d=t[++a],c.push([RawKeycodeSequenceAction.Down,this.byteToKey[d]]);break;case KeyAction.Up:d=t[++a],c.push([RawKeycodeSequenceAction.Up,this.byteToKey[d]]);break;default:{const p=String.fromCharCode(d);c.length&&c[c.length-1][0]===RawKeycodeSequenceAction.CharacterStream?c[c.length-1]=[RawKeycodeSequenceAction.CharacterStream,c[c.length-1][1]+p]:c.push([RawKeycodeSequenceAction.CharacterStream,p]);break}}a++}return l}rawKeycodeSequencesToMacroBytes(t){return t.flatMap(r=>{const s=[];return r.forEach(a=>{switch(a[0]){case RawKeycodeSequenceAction.Tap:s.push(KeyAction.Tap,this.basicKeyToByte[a[1]]);break;case RawKeycodeSequenceAction.Up:s.push(KeyAction.Up,this.basicKeyToByte[a[1]]);break;case RawKeycodeSequenceAction.Down:s.push(KeyAction.Down,this.basicKeyToByte[a[1]]);break;case RawKeycodeSequenceAction.Delay:break;case RawKeycodeSequenceAction.CharacterStream:s.push(...a[1].split("").map(l=>l.charCodeAt(0)));break}}),s.push(MacroTerminator),s})}async writeRawKeycodeSequences(t){const r=this.rawKeycodeSequencesToMacroBytes(t);await this.keyboardApi.setMacroBytes(r)}}function validateMacroExpressionV11(expression){let unclosedBlockRegex,keycodeBlockRegex;try{unclosedBlockRegex=eval("/(?<!\\\\){(?![^{]*})/"),keycodeBlockRegex=eval("/(?<!\\\\){(.*?)}/g")}catch(e){return console.error("Lookbehind is not supported in this browser."),{isValid:!1,errorMessage:"Lookbehind is not supported in this browser."}}if(expression.match(unclosedBlockRegex))return{isValid:!1,errorMessage:"Looks like a keycode block - {} - is unclosed! Are you missing an '}'?"};let groups=null;for(;groups=keycodeBlockRegex.exec(expression);){const e=groups[1].replace(/\s+/g,"");if(!e.length)return{isValid:!1,errorMessage:"Sorry, I can't handle empty {}. Fill them up with keycodes or use \\{} to tell the macro to literally type {}"};if(/^\d+$/.test(e)){if(/\d{5,}/.test(e))return{isValid:!1,errorMessage:`Invalid delay: ${e}. Please use a delay value of 9999 or less.`}}else{const t=e.replace(/^[-+]/,"").split(",").filter(r=>r.trim().length&&!isAutocompleteKeycode(r));if(t.length)return{isValid:!1,errorMessage:`Whoops! Invalid keycodes detected inside {}: ${t.join(", ")}`}}}return{isValid:!0,errorMessage:void 0}}class MacroAPIV11{constructor(t,r,s){this.keyboardApi=t,this.basicKeyToByte=r,this.byteToKey=s}async readRawKeycodeSequences(){const t=await this.keyboardApi.getMacroBytes(),r=await this.keyboardApi.getMacroCount();let s=0,a=0;const l=[];let c=[];if(r===0)throw Error("Macros are disabled");for(;a<t.length&&s<r;){let d=t[a];switch(d){case MacroTerminator:l[s]=c,s++,c=[];break;case KeyActionPrefix:switch(d=t[++a],d){case KeyAction.Tap:d=t[++a],c.push([RawKeycodeSequenceAction.Tap,this.byteToKey[d]]);break;case KeyAction.Down:d=t[++a],c.push([RawKeycodeSequenceAction.Down,this.byteToKey[d]]);break;case KeyAction.Up:d=t[++a],c.push([RawKeycodeSequenceAction.Up,this.byteToKey[d]]);break;case KeyAction.Delay:let p=[];for(d=t[++a];d!==DelayTerminator&&a<t.length;)p.push(d),d=t[++a];const f=p.reduce((m,y)=>(m+=String.fromCharCode(y),m),"");c.push([RawKeycodeSequenceAction.Delay,parseInt(f)]);break;default:throw`Expected a KeyAction to follow the KeyActionPrefix. Received ${d} instead.`}break;default:{const p=String.fromCharCode(d);c.length&&c[c.length-1][0]===RawKeycodeSequenceAction.CharacterStream?c[c.length-1]=[RawKeycodeSequenceAction.CharacterStream,c[c.length-1][1]+p]:c.push([RawKeycodeSequenceAction.CharacterStream,p]);break}}a++}return l}rawKeycodeSequencesToMacroBytes(t){return t.flatMap(r=>{const s=[];return r.forEach(a=>{switch(a[0]){case RawKeycodeSequenceAction.Tap:s.push(KeyActionPrefix,KeyAction.Tap,this.basicKeyToByte[a[1]]);break;case RawKeycodeSequenceAction.Down:s.push(KeyActionPrefix,KeyAction.Down,this.basicKeyToByte[a[1]]);break;case RawKeycodeSequenceAction.Up:s.push(KeyActionPrefix,KeyAction.Up,this.basicKeyToByte[a[1]]);break;case RawKeycodeSequenceAction.Delay:let l=`${a[1]}`;s.push(KeyActionPrefix,KeyAction.Delay,...l.split("").map(c=>c.charCodeAt(0)),DelayTerminator);break;case RawKeycodeSequenceAction.CharacterStream:s.push(...a[1].split("").map(c=>c.charCodeAt(0)));break}}),s.push(MacroTerminator),s})}async writeRawKeycodeSequences(t){const r=this.rawKeycodeSequencesToMacroBytes(t);await this.keyboardApi.setMacroBytes(r)}}const getMacroAPI=(e,t)=>{const r=getBasicKeyDict(e),s=getByteToKey(getBasicKeyDict(e));return e>=11?new MacroAPIV11(t,r,s):new MacroAPI(t,r,s)},getMacroValidator=e=>e>=11?validateMacroExpressionV11:validateMacroExpression,isDelaySupported=e=>e>=11,BAUD=115200,BUFFER_SIZE=64,getSerialPort=async e=>{let t=await getFilteredPort(e);if(!t){const r=e.map(s=>({usbVendorId:s.vendorId,usbProductId:s.productId}));t=await navigator.serial.requestPort({filters:r})}if(!t)throw new Error("no serial port");return t},getFilteredPort=async e=>(await navigator.serial.getPorts()).find(s=>{const a=s.getInfo();return e.find(l=>a.usbVendorId===l.vendorId&&a.usbProductId===l.productId)}),cache={};class TabKeyboardAPI{constructor(t,r){ie(this,"device");ie(this,"devices");ie(this,"getPort",async()=>{if(this.device&&this.device.path in cache)return cache[this.device.path];const t=await getSerialPort(this.devices?this.devices:this.device?[this.device]:[]);try{await t.open({baudRate:BAUD,bufferSize:64})}catch(r){console.log(r)}if(!this.device&&this.devices){const r=t.getInfo().usbVendorId,s=t.getInfo().usbProductId;this.device=this.devices.find(a=>a.vendorId===r&&a.productId===s)}return this.device&&(cache[this.device.path]=t),t});this.device=t,this.devices=r}async init(){}async setMatrixLighting(t,r,s,a,l){const c=await this.seriaCommandWithResponse(192,[t,r,s,a]);if(c&&c[5]===238){const f=new Error("Error: "+c[5]);throw f.cause=c[5],f}const d=!!c[6],p=BUFFER_SIZE-8;for(let f=0;f<l.length;f+=p){const m=l.slice(f,f+p);d?await this.seriaCommandWithResponse(193,[...numIntoBytes(f),m.length,...m]):await this.seriaCommand(193,[...numIntoBytes(f),m.length,...m])}}async setTabFile(t,r,s){const a=await this.seriaCommandWithResponse(224,t.slice(0,20));if(a&&a[21]===238){const c=new Error("Error: "+a[21]);throw c.cause=a[21],c}const l=!!a[22];return this.setTabBuffer(225,t,r,s,l)}async setTabFirmwareBuffer(t,r,s,a){return this.setTabBuffer(241,t,r,s,a)}async setTabFirmwareInfo(t,r){const s=[...numIntoBytes(t),...r],a=await this.seriaCommandWithResponse(240,s);return a&&a[s.length+1]===238?[!1,a[s.length+2]]:[!0,a[s.length+2]]}async firmwareQuery(){return await this.seriaCommandWithResponse(239,[])}async setTabBuffer(t,r,s,a,l){const c=BUFFER_SIZE-8;for(let d=0;d<r.length;d+=c){const p=r.slice(d,d+c);if(l?await this.seriaCommandWithResponse(t,[...numIntoBytes(d),p.length,...p]):await this.seriaCommand(t,[...numIntoBytes(d),p.length,...p]),a&&a()){await this.seriaCommand(226);return}s&&s(d+p.length)}}async seriaCommand(t,r=[]){const s=[t,...r],a=new Array(BUFFER_SIZE).fill(0);s.forEach((c,d)=>{a[d]=c});const l=await this.getPort();if(l.writable){const c=l.writable.getWriter();console.debug("CDC",a),await c.write(new Uint8Array(a)),c.releaseLock()}}async seriaCommandWithResponse(t,r=[]){await this.seriaCommand(t,r);const s=await this.getPort();let a=[];if(s.readable){const l=s.readable.getReader();try{for(;;){const{value:c,done:d}=await l.read();if(console.debug("CDC read",c,d),c&&(a=[...a,...Array.from(c)],a.length===BUFFER_SIZE)){console.debug("done...");break}if(d){console.debug("done");break}}}catch(c){throw console.log(c),c}finally{l.releaseLock()}if(!lodashExports.isEqual(r,a.slice(1,r.length+1)))throw console.error("Command for CDC:",r,"Bad Resp:",a),new Error("Receiving incorrect response for command")}return a}}const initialState$a={selectedDevicePath:null,connectedDevicePaths:{},supportedIds:{},forceAuthorize:!1},deviceSlice=createSlice({name:"devices",initialState:initialState$a,reducers:{selectDevice:(e,t)=>{t.payload?e.selectedDevicePath=t.payload.path:e.selectedDevicePath=null},setForceAuthorize:(e,t)=>{e.forceAuthorize=t.payload},updateConnectedDevices:(e,t)=>{e.connectedDevicePaths=t.payload},clearAllDevices:e=>{e.selectedDevicePath=null,e.connectedDevicePaths={}},updateSupportedIds:(e,t)=>{e.supportedIds=t.payload},ensureSupportedIds:(e,t)=>{const{productIds:r,version:s}=t.payload;r.forEach(a=>{e.supportedIds[a]=e.supportedIds[a]??{},e.supportedIds[a][s]=!0})}}}),{clearAllDevices,selectDevice,updateConnectedDevices,updateSupportedIds,ensureSupportedIds,setForceAuthorize}=deviceSlice.actions,devicesReducer=deviceSlice.reducer,getForceAuthorize=e=>e.devices.forceAuthorize,getConnectedDevices=e=>e.devices.connectedDevicePaths,getSelectedDevicePath=e=>e.devices.selectedDevicePath,getSupportedIds=e=>e.devices.supportedIds,getSelectedConnectedDevice=createSelector(getConnectedDevices,getSelectedDevicePath,(e,t)=>t&&e[t]),getSelectedKeyboardAPI=createSelector(getSelectedDevicePath,e=>e&&new KeyboardAPI(e)),getTabFileAPI=createSelector(getSelectedConnectedDevice,e=>{if(e)return e.cdcSupport===void 0||e.cdcSupport===!0?new TabKeyboardAPI(e):new KeyboardAPI(e.path)}),macrosInitialState={ast:[],macroBufferSize:0,macroCount:0,isFeatureSupported:!0},macrosSlice=createSlice({name:"macros",initialState:macrosInitialState,reducers:{loadMacrosSuccess:(e,t)=>{e.ast=t.payload.ast,e.macroBufferSize=t.payload.macroBufferSize,e.macroCount=t.payload.macroCount},saveMacrosSuccess:(e,t)=>{e.ast=t.payload.ast},setMacrosNotSupported:e=>{e.isFeatureSupported=!1}}}),{loadMacrosSuccess,saveMacrosSuccess,setMacrosNotSupported}=macrosSlice.actions,macrosReducer=macrosSlice.reducer,loadMacros=e=>async(t,r)=>{const{protocol:s}=e;if(s<8)t(setMacrosNotSupported());else try{const a=r(),l=getSelectedKeyboardAPI(a),c=getMacroAPI(s,l);if(c){const d=await c.readRawKeycodeSequences(),p=await l.getMacroBufferSize(),f=await l.getMacroCount();t(loadMacrosSuccess({ast:d,macroBufferSize:p,macroCount:f}))}}catch{t(setMacrosNotSupported())}},saveMacros=(e,t)=>async(r,s)=>{const a=s(),l=getSelectedKeyboardAPI(a),{protocol:c}=e,d=getMacroAPI(c,l);if(d){const p=t.map(f=>{const m=expressionToSequence(f);return optimizedSequenceToRawSequence(m)});await d.writeRawKeycodeSequences(p),r(saveMacrosSuccess({ast:p}))}},getIsMacroFeatureSupported=e=>e.macros.isFeatureSupported,getAST=e=>e.macros.ast,getMacroBufferSize=e=>e.macros.macroBufferSize,getMacroCount=e=>e.macros.macroCount,getExpressions=createSelector(getAST,e=>e.map(t=>{const r=rawSequenceToOptimizedSequence(t);return sequenceToExpression(r)})),getIsDelaySupported=createSelector(getSelectedConnectedDevice,e=>!!e&&isDelaySupported(e.protocol));function isFulfilledPromise(e){return e.status==="fulfilled"}function isAuthorizedDeviceConnected(e,t){return t&&t[e.vendorProductId]&&t[e.vendorProductId][e.requiredDefinitionVersion]}const initialState$9={definitions:{},customDefinitions:{},layoutOptionsMap:{}},definitionsSlice=createSlice({name:"definitions",initialState:initialState$9,reducers:{updateDefinitions:(e,t)=>{e.definitions={...e.definitions,...t.payload}},loadInitialCustomDefinitions:(e,t)=>{e.customDefinitions=t.payload},unloadCustomDefinition:(e,t)=>{const{version:r,id:s}=t.payload,a=e.customDefinitions[s];Object.keys(a).length===1?(delete e.customDefinitions[s],del(s)):(delete a[r],update(s,l=>(delete l[r],l))),e.customDefinitions={...e.customDefinitions}},loadCustomDefinitions:(e,t)=>{const{version:r,definitions:s}=t.payload;s.forEach(a=>{const l=e.customDefinitions[a.vendorProductId]??{};l[r]=a,e.customDefinitions[a.vendorProductId]=l})},updateLayoutOptions:(e,t)=>{e.layoutOptionsMap={...e.layoutOptionsMap,...t.payload}}}}),{loadCustomDefinitions,loadInitialCustomDefinitions,updateDefinitions,unloadCustomDefinition,updateLayoutOptions}=definitionsSlice.actions,definitionsReducer=definitionsSlice.reducer,getBaseDefinitions=e=>e.definitions.definitions,getCustomDefinitions=e=>e.definitions.customDefinitions,getLayoutOptionsMap=e=>e.definitions.layoutOptionsMap,getDefinitions=createSelector(getBaseDefinitions,getCustomDefinitions,(e,t)=>Object.entries(t).reduce((r,[s,a])=>({...r,[s]:{...r[s],...a}}),e)),getSelectedDefinition=createSelector(getDefinitions,getSelectedConnectedDevice,(e,t)=>t&&e&&e[t.vendorProductId]&&e[t.vendorProductId][t.requiredDefinitionVersion]),getBasicKeyToByte=createSelector(getSelectedConnectedDevice,e=>{const t=getBasicKeyDict(e?e.protocol:0);return{basicKeyToByte:t,byteToKey:getByteToKey(t)}}),getSelectedLayoutOptions=createSelector(getSelectedDefinition,getLayoutOptionsMap,getSelectedDevicePath,(e,t,r)=>r&&t[r]||e&&e.layouts.labels&&e.layouts.labels.map(s=>0)||[]),getSelectedOptionKeys=createSelector(getSelectedLayoutOptions,getSelectedDefinition,(e,t)=>t?e.flatMap((r,s)=>t.layouts.optionKeys[s]&&t.layouts.optionKeys[s][r]||[]):[]),getSelectedKeyDefinitions=createSelector(getSelectedDefinition,getSelectedOptionKeys,(e,t)=>e&&t?e.layouts.keys.concat(t):[]),getLightingSupport=createSelector(getSelectedDefinition,e=>e?!!("keycodes"in e&&typeof e.keycodes=="object"&&e.keycodes.find(t=>t.toLowerCase().includes("lighting"))||"menus"in e&&typeof e.menus=="object"&&e.menus.find(t=>t==null?void 0:t.label.toLowerCase().includes("lighting"))):!1),updateLayoutOption=(e,t)=>async(r,s)=>{const a=s(),l=getSelectedDefinition(a),c=getSelectedKeyboardAPI(a),d=getSelectedDevicePath(a);if(!l||!c||!d||!l.layouts.labels)return;const p=l.layouts.labels.map(y=>Array.isArray(y)?y.slice(1).length:2),f=[...getSelectedLayoutOptions(a)];f[e]=t;const m=numIntoBytes(packBits(f.map((y,K)=>[y,p[K]])));try{await c.setKeyboardValue(KeyboardValue.LAYOUT_OPTIONS,...m)}catch{console.warn("Setting layout option command not working")}r(updateLayoutOptions({[d]:f}))},storeCustomDefinitions=({definitions:e,version:t})=>async(r,s)=>{try{const a=getCustomDefinitions(s()),l=e.map(c=>[c.vendorProductId,{...a[c.vendorProductId],[t]:c}]);return setMany(l)}catch(a){throw console.error(a),a}},loadTabkbIds=()=>async(e,t)=>{const s=await(await fetch("/tabkb/supported_kbs.json",{cache:"reload"})).json();e(ensureSupportedIds({productIds:s.v2,version:"v2"})),e(ensureSupportedIds({productIds:s.v3,version:"v3"}))},loadStoredCustomDefinitions=()=>async(e,t)=>{try{const r=await entries(),s=r.filter(([c])=>["string","number"].includes(typeof c)).reduce((c,d)=>({...c,[d[0]]:d[1]}),{});e(loadInitialCustomDefinitions(s));const[a,l]=r.reduce(([c,d],[p,f])=>[f.v2?[...c,Number(p)]:c,f.v3?[...d,Number(p)]:d],[[],[]]);e(ensureSupportedIds({productIds:a,version:"v2"})),e(ensureSupportedIds({productIds:l,version:"v3"}))}catch(r){console.error(r)}},loadLayoutOptions=()=>async(e,t)=>{const r=t(),s=getSelectedDefinition(r),a=getSelectedConnectedDevice(r),l=getSelectedKeyboardAPI(r);if(!a||!s||!s.layouts.labels||!l)return;const{path:c}=a;try{const d=await l.getKeyboardValue(KeyboardValue.LAYOUT_OPTIONS,[],4),p=unpackBits(bytesIntoNum(d),s.layouts.labels.map(f=>Array.isArray(f)?f.slice(1).length:2));e(updateLayoutOptions({[c]:p}))}catch{console.warn("Getting layout options command not working")}},reloadDefinitions=e=>async(t,r)=>{const s=r(),a=getBaseDefinitions(s),l=getDefinitions(s),c=e.filter(({vendorProductId:f,requiredDefinitionVersion:m})=>!l||!l[f]||!l[f][m]),d=await Promise.allSettled(c.map(f=>getMissingDefinition(f,f.requiredDefinitionVersion)));d.forEach((f,m)=>{const y=c[m];if(f.status==="rejected"){const K=extractDeviceInfo(y);t(logAppError({message:`Fetching ${y.requiredDefinitionVersion} definition failed`,deviceInfo:K}))}});const p=d.filter(isFulfilledPromise).map(f=>f.value);p.length&&t(updateDefinitions(p.reduce((f,[m,y])=>({...f,[m.vendorProductId]:{...f[m.vendorProductId],[y]:m}}),a)))},initialState$8={rawDeviceMap:{},numberOfLayers:4,selectedLayerIndex:0,selectedKey:null,selectedKeys:null,configureKeyboardIsSelectable:!1,selectedPaletteColor:[0,0],multiSelectAble:!1,showLabelControl:!0},keymapSlice=createSlice({name:"keymap",initialState:initialState$8,reducers:{setSelectedPaletteColor:(e,t)=>{e.selectedPaletteColor=t.payload},setNumberOfLayers:(e,t)=>{e.numberOfLayers=t.payload},setConfigureKeyboardIsSelectable:(e,t)=>{e.configureKeyboardIsSelectable=t.payload},loadLayerSuccess:(e,t)=>{const{layerIndex:r,keymap:s,devicePath:a}=t.payload;e.rawDeviceMap[a]=e.rawDeviceMap[a]||Array(e.numberOfLayers).fill({keymap:[],isLoaded:!1}),e.rawDeviceMap[a][r]={keymap:s,isLoaded:!0}},setLayer:(e,t)=>{e.selectedLayerIndex=t.payload},clearSelectedKey:e=>{e.selectedKey=null},updateSelectedKey:(e,t)=>{e.selectedKey=t.payload},clearSelectedKeys:e=>{e.selectedKeys=null},toggleSelectedKey:(e,t)=>{e.selectedKeys=e.selectedKeys||[],e.selectedKeys.includes(t.payload)?e.selectedKeys=e.selectedKeys.filter(r=>r!==t.payload):e.selectedKeys=[...e.selectedKeys,t.payload]},updateSelectedKeys:(e,t)=>{e.selectedKeys=[...t.payload]},addSelectedKey:(e,t)=>{e.selectedKeys=e.selectedKeys||[],!e.selectedKeys.includes(t.payload)&&(e.selectedKeys=[...e.selectedKeys,t.payload])},removeSelectedKey:(e,t)=>{e.selectedKeys=e.selectedKeys||[],e.selectedKeys=e.selectedKeys.filter(r=>r!==t.payload)},saveKeymapSuccess:(e,t)=>{const{layers:r,devicePath:s}=t.payload;e.rawDeviceMap[s]=r},setKey:(e,t)=>{const{keymapIndex:r,value:s,devicePath:a}=t.payload,{selectedLayerIndex:l}=e;e.rawDeviceMap[a][l].keymap[r]=s},updateMultiSelectAble:(e,t)=>{e.multiSelectAble=t.payload},updateShowLayerControl:(e,t)=>{e.showLabelControl=t.payload}},extraReducers:e=>{e.addCase(selectDevice,t=>{t.selectedKey=null,t.selectedKeys=[],t.multiSelectAble=!1})}}),{setNumberOfLayers,setLayer,loadLayerSuccess,clearSelectedKey,setKey,updateSelectedKey,saveKeymapSuccess,setConfigureKeyboardIsSelectable,setSelectedPaletteColor,toggleSelectedKey,clearSelectedKeys,addSelectedKey,removeSelectedKey,updateSelectedKeys,updateMultiSelectAble,updateShowLayerControl}=keymapSlice.actions,keymapReducer=keymapSlice.reducer,loadKeymapFromDevice=e=>async(t,r)=>{const s=r();if(getLoadProgress(s)===1)return;const{path:a,vendorProductId:l,requiredDefinitionVersion:c}=e,d=getSelectedKeyboardAPI(s),p=await d.getLayerCount();t(setNumberOfLayers(p));const{matrix:f}=getDefinitions(s)[l][c];for(var m=0;m<p;m++){const y=await d.readRawMatrix(f,m);t(loadLayerSuccess({layerIndex:m,keymap:y,devicePath:a}))}},saveRawKeymapToDevice=(e,t)=>async(r,s)=>{const a=s(),{path:l}=t,c=getSelectedKeyboardAPI(a),d=getSelectedDefinition(a);if(!l||!d||!c)return;const{matrix:p}=d;await c.writeRawMatrix(p,e);const f=e.map(m=>({keymap:m,isLoaded:!0}));r(saveKeymapSuccess({layers:f,devicePath:l}))},updateKey=(e,t)=>async(r,s)=>{const a=s(),l=getSelectedKeyDefinitions(a),c=getSelectedConnectedDevice(a),d=getSelectedKeyboardAPI(a),p=getSelectedDefinition(a);if(!c||!l||!p||!d)return;const f=getSelectedLayerIndex(a),{path:m}=c,{row:y,col:K}=l[e];await d.setKey(f,y,K,t);const{matrix:x}=p,v=y*x.cols+K;r(setKey({keymapIndex:v,value:t,devicePath:m}))},getConfigureKeyboardIsSelectable=e=>e.keymap.configureKeyboardIsSelectable,getSelectedKey=e=>e.keymap.selectedKey,getRawDeviceMap=e=>e.keymap.rawDeviceMap,getNumberOfLayers=e=>e.keymap.numberOfLayers,getSelectedLayerIndex=e=>e.keymap.selectedLayerIndex,getSelected256PaletteColor=e=>e.keymap.selectedPaletteColor,getSelectedPaletteColor=createSelector(getSelected256PaletteColor,([e,t])=>[360*e/255,t/255]),getSelectedKeys=e=>e.keymap.selectedKeys,getMultiSelectAble=e=>e.keymap.multiSelectAble,getShowLayerControl=e=>e.keymap.showLabelControl,getSelectedRawLayers=createSelector(getRawDeviceMap,getSelectedDevicePath,(e,t)=>t&&e[t]||[]),getLoadProgress=createSelector(getSelectedRawLayers,getNumberOfLayers,(e,t)=>e&&e.filter(r=>r.isLoaded).length/t);createSelector(getSelectedRawLayers,getSelectedLayerIndex,(e,t)=>e&&e[t]);const getSelectedKeymaps=createSelector(getSelectedKeyDefinitions,getSelectedDefinition,getSelectedRawLayers,(e,t,r)=>{if(t&&r){const s=r.map(l=>l.keymap),{matrix:{cols:a}}=t;return s.map(l=>e.map(({row:c,col:d})=>l[c*a+d]))}}),getSelectedKeymap=createSelector(getSelectedKeymaps,getSelectedLayerIndex,(e,t)=>e&&e[t]);createSelector(getSelectedKeyDefinitions,getSelectedDefinition,(e,t)=>{if(e&&t){const{matrix:{cols:r}}=t;return e.map(({row:s,col:a})=>s*r+a)}return[]});const commandParamLengths={[dist.LightingValue.BACKLIGHT_COLOR_1]:2,[dist.LightingValue.BACKLIGHT_COLOR_2]:2,[dist.LightingValue.QMK_RGBLIGHT_COLOR]:2,[dist.LightingValue.BACKLIGHT_CUSTOM_COLOR]:2,[dist.LightingValue.BACKLIGHT_CAPS_LOCK_INDICATOR_COLOR]:2,[dist.LightingValue.BACKLIGHT_CAPS_LOCK_INDICATOR_ROW_COL]:2,[dist.LightingValue.BACKLIGHT_LAYER_1_INDICATOR_COLOR]:2,[dist.LightingValue.BACKLIGHT_LAYER_2_INDICATOR_COLOR]:2,[dist.LightingValue.BACKLIGHT_LAYER_3_INDICATOR_COLOR]:2,[dist.LightingValue.BACKLIGHT_LAYER_1_INDICATOR_ROW_COL]:2,[dist.LightingValue.BACKLIGHT_LAYER_2_INDICATOR_ROW_COL]:2,[dist.LightingValue.BACKLIGHT_LAYER_3_INDICATOR_ROW_COL]:2,[dist.LightingValue.BACKLIGHT_EFFECT_SPEED]:1,[dist.LightingValue.BACKLIGHT_USE_7U_SPACEBAR]:1,[dist.LightingValue.BACKLIGHT_USE_ISO_ENTER]:1,[dist.LightingValue.BACKLIGHT_USE_SPLIT_BACKSPACE]:1,[dist.LightingValue.BACKLIGHT_USE_SPLIT_LEFT_SHIFT]:1,[dist.LightingValue.BACKLIGHT_USE_SPLIT_RIGHT_SHIFT]:1,[dist.LightingValue.BACKLIGHT_DISABLE_AFTER_TIMEOUT]:1,[dist.LightingValue.BACKLIGHT_DISABLE_HHKB_BLOCKER_LEDS]:1,[dist.LightingValue.BACKLIGHT_DISABLE_WHEN_USB_SUSPENDED]:1},initialState$7={lightingMap:{}},lightingSlice$1=createSlice({name:"lighting",initialState:initialState$7,reducers:{updateSelectedLightingData:(e,t)=>{const{lightingData:r,devicePath:s}=t.payload;e.lightingMap[s]=r},updateLighting:(e,t)=>{e.lightingMap={...e.lightingMap,...t.payload}}}}),{updateLighting,updateSelectedLightingData}=lightingSlice$1.actions,lightingReducer=lightingSlice$1.reducer,updateBacklightValue=(e,...t)=>async(r,s)=>{const a=s(),l=getSelectedConnectedDevice(a);if(!l)return;const d={...getSelectedLightingData(a),[e]:[...t]},{path:p}=l;r(updateSelectedLightingData({lightingData:d,devicePath:p}));const f=getSelectedKeyboardAPI(a);await f.setBacklightValue(e,...t),await f.saveLighting()},updateCustomColor=(e,t,r)=>async(s,a)=>{const l=a(),c=getSelectedConnectedDevice(l),d=getSelectedKeyboardAPI(l),p=getSelectedLightingData(l);if(!c||!p||!d)return;const f=[...p.customColors||[]];f[e]={hue:t,sat:r};const m={...p,customColors:f},{path:y}=c;s(updateSelectedLightingData({lightingData:m,devicePath:y})),d.setCustomColor(e,t,r),await d.saveLighting()},updateLightingData=e=>async(t,r)=>{const s=r(),a=getSelectedDefinition(s),l=getSelectedKeyboardAPI(s);if(!a||!l)return;const{path:c}=e;if(!dist.isVIADefinitionV2(a))throw new Error("This method is only compatible with v2 definitions");const{lighting:d}=a,{supportedLightingValues:p,effects:f}=dist.getLightingDefinition(d);if(p.length!==0){let m={};if(p.indexOf(dist.LightingValue.BACKLIGHT_CUSTOM_COLOR)!==-1){const x=await Array(Math.max(...f.map(([M,b])=>b))).fill(0).map((M,b)=>l.getCustomColor(b));m={customColors:await Promise.all(x)}}const y=p.map(x=>({command:x,promise:l.getBacklightValue(+x,commandParamLengths[x])})),K=await Promise.all(y.map(x=>x.promise));m=y.reduce(({res:x,ref:v},M,b)=>({ref:v,res:{...x,[M.command]:v[b]}}),{res:m,ref:K}).res,t(updateLighting({[c]:{...m}}))}},getLightingMap=e=>e.lighting.lightingMap,getSelectedLightingData=createSelector(getLightingMap,getSelectedDevicePath,(e,t)=>t&&e[t]);function getIconColor(e){return{style:{color:e?"var(--bg_icon-highlighted)":"var(--bg_control)"}}}const Grid=styled.div`
|
|
28
|
+
height: 100%;
|
|
29
|
+
width: 100%;
|
|
30
|
+
display: grid;
|
|
31
|
+
grid-template-columns: min-content min-content minmax(0, 1fr);
|
|
32
|
+
> div {
|
|
33
|
+
pointer-events: all;
|
|
34
|
+
}
|
|
35
|
+
`,Cell=styled.div`
|
|
36
|
+
border-right: 1px solid var(--border_color_cell);
|
|
37
|
+
`,MenuCell=styled(Cell)`
|
|
38
|
+
background: var(--bg_menu);
|
|
39
|
+
border-top: 1px solid var(--border_color_cell);
|
|
40
|
+
`,OverflowCell=styled(Cell)`
|
|
41
|
+
border-top: 1px solid var(--border_color_cell);
|
|
42
|
+
overflow: auto;
|
|
43
|
+
`,SpanOverflowCell=styled(Cell)`
|
|
44
|
+
border-top: 1px solid var(--border_color_cell);
|
|
45
|
+
overflow: auto;
|
|
46
|
+
grid-column: span 2;
|
|
47
|
+
`,SubmenuCell=styled(Cell)`
|
|
48
|
+
border-top: 1px solid var(--border_color_cell);
|
|
49
|
+
background: var(--bg_control);
|
|
50
|
+
`,SubmenuOverflowCell=styled(SubmenuCell)`
|
|
51
|
+
min-width: 80px;
|
|
52
|
+
overflow: auto;
|
|
53
|
+
`,SinglePaneFlexCell=styled(Cell)`
|
|
54
|
+
display: flex;
|
|
55
|
+
overflow: hidden;
|
|
56
|
+
flex-direction: column;
|
|
57
|
+
justify-content: center;
|
|
58
|
+
align-items: center;
|
|
59
|
+
position: relative;
|
|
60
|
+
`,ConfigureFlexCell=styled(SinglePaneFlexCell)`
|
|
61
|
+
pointer-events: none;
|
|
62
|
+
height: 500px;
|
|
63
|
+
`,CategoryIconContainer=styled.span`
|
|
64
|
+
position: relative;
|
|
65
|
+
color: var(--color_inside-accent);
|
|
66
|
+
height: 35px;
|
|
67
|
+
cursor: pointer;
|
|
68
|
+
display: flex;
|
|
69
|
+
align-items: center;
|
|
70
|
+
justify-content: center;
|
|
71
|
+
background: ${e=>e.$selected?"var(--color_accent)":"transparent"};
|
|
72
|
+
border-radius: 10px;
|
|
73
|
+
width: 40px;
|
|
74
|
+
&:hover {
|
|
75
|
+
color: ${e=>e.$selected?"var(--color_inside-accent)":"var(--color_accent)"};
|
|
76
|
+
& .tooltip {
|
|
77
|
+
transform: scale(1) translateX(0px);
|
|
78
|
+
opacity: 1;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
.tooltip {
|
|
82
|
+
transform: translateX(-5px) scale(0.6);
|
|
83
|
+
opacity: 0;
|
|
84
|
+
}
|
|
85
|
+
`,IconContainer=styled.span`
|
|
86
|
+
display: inline-block;
|
|
87
|
+
text-align: center;
|
|
88
|
+
width: 35px;
|
|
89
|
+
position: relative;
|
|
90
|
+
&:hover > span > div {
|
|
91
|
+
background-color: red;
|
|
92
|
+
}
|
|
93
|
+
`,ControlRow=styled.div`
|
|
94
|
+
position: relative;
|
|
95
|
+
width: 100%;
|
|
96
|
+
max-width: 960px;
|
|
97
|
+
border-bottom: 1px solid var(--border_color_cell);
|
|
98
|
+
font-size: 20px;
|
|
99
|
+
justify-content: space-between;
|
|
100
|
+
display: flex;
|
|
101
|
+
line-height: 50px;
|
|
102
|
+
min-height: 50px;
|
|
103
|
+
box-sizing: border-box;
|
|
104
|
+
padding-left: 5px;
|
|
105
|
+
padding-right: 5px;
|
|
106
|
+
`,IndentedControlRow=styled(ControlRow)`
|
|
107
|
+
padding-left: 17px;
|
|
108
|
+
`,Label$1=styled.label`
|
|
109
|
+
color: var(--color_label);
|
|
110
|
+
font-weight: 400;
|
|
111
|
+
`,SubLabel=styled(Label$1)`
|
|
112
|
+
font-size: 18px;
|
|
113
|
+
font-style: italic;
|
|
114
|
+
font-weight: 400;
|
|
115
|
+
`,Detail=styled.span`
|
|
116
|
+
color: var(--color_accent);
|
|
117
|
+
display: flex;
|
|
118
|
+
align-items: center;
|
|
119
|
+
`,Row=styled.div`
|
|
120
|
+
cursor: pointer;
|
|
121
|
+
white-space: nowrap;
|
|
122
|
+
margin-bottom: 15px;
|
|
123
|
+
font-size: 20px;
|
|
124
|
+
line-height: 20px;
|
|
125
|
+
text-transform: uppercase;
|
|
126
|
+
color: ${e=>getIconColor(e.$selected).style.color};
|
|
127
|
+
border-left: 2px solid transparent;
|
|
128
|
+
|
|
129
|
+
svg {
|
|
130
|
+
height: 20px;
|
|
131
|
+
vertical-align: middle;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
&:hover {
|
|
135
|
+
color: var(--color_label-highlighted);
|
|
136
|
+
& .tooltip {
|
|
137
|
+
transform: scale(1) translateX(0px);
|
|
138
|
+
opacity: 1;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
.tooltip {
|
|
142
|
+
transform: translateX(-5px) scale(0.6);
|
|
143
|
+
opacity: 0;
|
|
144
|
+
}
|
|
145
|
+
`,SubmenuRow=styled(Row)`
|
|
146
|
+
background: ${e=>e.$selected?"var(--bg_icon)":"inherit"};
|
|
147
|
+
padding: 4px 8px;
|
|
148
|
+
font-weight: 400;
|
|
149
|
+
min-width: min-content;
|
|
150
|
+
border-color: transparent;
|
|
151
|
+
margin-bottom: 11px;
|
|
152
|
+
color: ${e=>e.$selected?"var(--color_label-highlighted)":"var(--color_label)"};
|
|
153
|
+
border-radius: 12px;
|
|
154
|
+
`,Pane$c=styled.div`
|
|
155
|
+
background: var(--gradient);
|
|
156
|
+
display: flex;
|
|
157
|
+
flex: 1;
|
|
158
|
+
flex-direction: column;
|
|
159
|
+
height: 100%;
|
|
160
|
+
overflow: hidden;
|
|
161
|
+
background: var(--gradient);
|
|
162
|
+
`,CenterPane=styled(Pane$c)`
|
|
163
|
+
overflow: auto;
|
|
164
|
+
display: block;
|
|
165
|
+
`,ConfigureBasePane=styled(Pane$c)`
|
|
166
|
+
flex-direction: column;
|
|
167
|
+
align-items: center;
|
|
168
|
+
justify-content: space-evenly;
|
|
169
|
+
background: transparent;
|
|
170
|
+
pointer-events: none;
|
|
171
|
+
z-index: 3;
|
|
172
|
+
`,SvgIcLightbulbOutline24Px=e=>jsx("svg",{width:11.9,height:17,...e,children:jsx("path",{d:"M3.4 16.15a.853.853 0 00.85.85h3.4a.852.852 0 00.85-.85v-.85H3.4zM5.95 0a5.947 5.947 0 00-3.4 10.829v1.921a.852.852 0 00.85.85h5.1a.852.852 0 00.85-.85v-1.921A5.947 5.947 0 005.95 0zm2.422 9.435l-.722.51V11.9h-3.4V9.945l-.722-.51a4.25 4.25 0 114.845 0z",fill:"currentColor"})}),title$7="Lighting",component$4=SvgIcLightbulbOutline24Px,AccentButtonBase=styled.button`
|
|
173
|
+
height: 40px;
|
|
174
|
+
padding: 0 15px;
|
|
175
|
+
line-height: 40px;
|
|
176
|
+
min-width: 100px;
|
|
177
|
+
text-align: center;
|
|
178
|
+
outline: none;
|
|
179
|
+
font-size: 20px;
|
|
180
|
+
border-radius: 5px;
|
|
181
|
+
color: var(--color_accent);
|
|
182
|
+
border: 1px solid var(--color_accent);
|
|
183
|
+
display: inline-block;
|
|
184
|
+
box-sizing: border-box;
|
|
185
|
+
pointer-events: ${e=>e.disabled?"none":"auto"};
|
|
186
|
+
position: relative;
|
|
187
|
+
cursor: ${e=>e.disabled?"not-allowed":"pointer"};
|
|
188
|
+
|
|
189
|
+
&:hover {
|
|
190
|
+
border: 1px solid var(--color_accent);
|
|
191
|
+
}
|
|
192
|
+
`,AccentButton=styled(AccentButtonBase)`
|
|
193
|
+
background-color: ${e=>e.disabled?"var(--bg_control-disabled)":"var(--bg_outside-accent)"};
|
|
194
|
+
color: ${e=>e.disabled?"var(--bg_control)":"var(--color_accent)"};
|
|
195
|
+
border-color: ${e=>e.disabled?"var(--bg_control)":"var(--color_accent)"};
|
|
196
|
+
|
|
197
|
+
&:hover {
|
|
198
|
+
filter: brightness(0.7);
|
|
199
|
+
}
|
|
200
|
+
`,AccentButtonLarge=styled(AccentButton)`
|
|
201
|
+
font-size: 24px;
|
|
202
|
+
line-height: 60px;
|
|
203
|
+
height: 60px;
|
|
204
|
+
`,PrimaryAccentButton=styled(AccentButtonBase)`
|
|
205
|
+
color: ${e=>e.disabled?"var(--bg_control)":"var(--color_inside-accent)"};
|
|
206
|
+
border-color: ${e=>e.disabled?"var(--bg_control)":"var(--color_accent)"};
|
|
207
|
+
background-color: ${e=>e.disabled?"transparent":"var(--color_accent)"};
|
|
208
|
+
&:hover {
|
|
209
|
+
filter: brightness(0.7);
|
|
210
|
+
}
|
|
211
|
+
`,Keycode$2=styled.span`
|
|
212
|
+
color: var(--color_accent);
|
|
213
|
+
display: flex;
|
|
214
|
+
padding-left: 10px;
|
|
215
|
+
`,KeycodeLabel=styled.span`
|
|
216
|
+
color: var(--color_label);
|
|
217
|
+
display: flex;
|
|
218
|
+
`,Item=styled.div`
|
|
219
|
+
box-sizing: border-box;
|
|
220
|
+
min-width: 200px;
|
|
221
|
+
padding: 5px 10px;
|
|
222
|
+
display: flex;
|
|
223
|
+
justify-content: space-between;
|
|
224
|
+
background-color: ${e=>e.$selected?"var(--bg_control)":"var(--bg_menu)"};
|
|
225
|
+
|
|
226
|
+
&:hover {
|
|
227
|
+
background-color: var(--bg_control);
|
|
228
|
+
}
|
|
229
|
+
`,AutocompleteItem=({selected:e,entity:{label:t,code:r}})=>jsxs(Item,{$selected:e,children:[jsx(KeycodeLabel,{children:t})," ",jsx(Keycode$2,{children:r})]}),AutocompleteLoading=()=>jsx("div",{children:"Loading"}),findKeycodes=e=>{const t=e.toUpperCase();return getAutocompleteKeycodes().filter(({name:r,title:s,code:a})=>s?s.toUpperCase().indexOf(t)>-1:r.toUpperCase().indexOf(t)>-1||a.toUpperCase().indexOf(t)>-1).slice(0,10).map(({name:r,code:s,title:a})=>({label:a||r,code:s}))},TextInput=styled.input`
|
|
230
|
+
background: none;
|
|
231
|
+
border: none;
|
|
232
|
+
border-bottom: 1px solid var(--color_accent);
|
|
233
|
+
filter: brightness(0.7);
|
|
234
|
+
color: var(--color_accent);
|
|
235
|
+
font-size: 1.2rem;
|
|
236
|
+
margin-bottom: 1.5rem;
|
|
237
|
+
padding: 0.5rem;
|
|
238
|
+
transition: all 0.2s ease-out;
|
|
239
|
+
|
|
240
|
+
&:focus {
|
|
241
|
+
filter: brightness(1);
|
|
242
|
+
color: var(--color_accent);
|
|
243
|
+
outline: none;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
&::placeholder {
|
|
247
|
+
color: var(--color_control);
|
|
248
|
+
}
|
|
249
|
+
`,ModalBackground=styled.div`
|
|
250
|
+
position: fixed;
|
|
251
|
+
top: 0;
|
|
252
|
+
left: 0;
|
|
253
|
+
background: rgba(0, 0, 0, 0.75);
|
|
254
|
+
width: 100%;
|
|
255
|
+
height: 100%;
|
|
256
|
+
display: flex;
|
|
257
|
+
justify-content: center;
|
|
258
|
+
align-items: center;
|
|
259
|
+
z-index: 4;
|
|
260
|
+
`,ModalContainer=styled.div`
|
|
261
|
+
border: 2px solid var(--color_accent);
|
|
262
|
+
min-width: 460px;
|
|
263
|
+
max-width: 550px;
|
|
264
|
+
min-height: 170px;
|
|
265
|
+
gap: 20px;
|
|
266
|
+
background-color: var(--bg_menu);
|
|
267
|
+
border-radius: 6px;
|
|
268
|
+
display: flex;
|
|
269
|
+
justify-content: center;
|
|
270
|
+
align-items: center;
|
|
271
|
+
flex-direction: column;
|
|
272
|
+
padding: 20px;
|
|
273
|
+
box-sizing: border-box;
|
|
274
|
+
position: relative;
|
|
275
|
+
`,PromptText=styled.div`
|
|
276
|
+
font-weight: 500;
|
|
277
|
+
user-select: none;
|
|
278
|
+
color: var(--color_label);
|
|
279
|
+
font-size: 20px;
|
|
280
|
+
text-align: center;
|
|
281
|
+
`,RowDiv$1=styled.div`
|
|
282
|
+
display: flex;
|
|
283
|
+
justify-content: center;
|
|
284
|
+
align-items: center;
|
|
285
|
+
width: 220px;
|
|
286
|
+
gap: 20px;
|
|
287
|
+
`,AutocompleteContainer=styled.ul`
|
|
288
|
+
position: fixed;
|
|
289
|
+
background-color: var(--bg_menu);
|
|
290
|
+
max-height: 210px;
|
|
291
|
+
overflow: auto;
|
|
292
|
+
border: 1px solid var(--bg_control);
|
|
293
|
+
margin: 0;
|
|
294
|
+
padding: 0;
|
|
295
|
+
width: auto;
|
|
296
|
+
margin-top: -24px;
|
|
297
|
+
line-height: normal;
|
|
298
|
+
`,AutocompleteItemRow=styled.li`
|
|
299
|
+
&:not(:last-child) {
|
|
300
|
+
border-bottom: 1px solid var(--bg_control);
|
|
301
|
+
}
|
|
302
|
+
`;function isHex(e){const t=e.toLowerCase();return`0x${parseInt(t,16).toString(16).toLowerCase()}`===t}function inputIsBasicByte(e,t){return e.trim().toUpperCase()in t}function basicByteFromInput(e,t){const r=e.trim().toUpperCase();return t[r]}function inputIsAdvancedKeyCode(e,t){const r=e.trim().toUpperCase();return advancedStringToKeycode(r,t)!==0}function advancedKeyCodeFromInput(e,t){const r=e.trim().toUpperCase();return advancedStringToKeycode(r,t)}function inputIsHex(e){return isHex(e.trim())}function hexFromInput(e){const t=e.toLowerCase();return parseInt(t,16)}function inputIsValid(e,t){return inputIsBasicByte(e,t)||inputIsAdvancedKeyCode(e,t)||inputIsHex(e)}function keycodeFromInput(e,t){return inputIsBasicByte(e,t)?basicByteFromInput(e,t):inputIsAdvancedKeyCode(e,t)?advancedKeyCodeFromInput(e,t):inputIsHex(e)?hexFromInput(e):null}const getInputItems=e=>e.map(t=>({code:t.code,label:t.title??t.name})),KeycodeModal=e=>{const{t}=useTranslation(),r=useAppSelector(getSelectedDefinition),{basicKeyToByte:s,byteToKey:a}=useAppSelector(getBasicKeyToByte);if(!r)return null;const l=getInputItems(getKeycodesForKeyboard(r)),[c,d]=reactExports.useState(l),p=anyKeycodeToString(e.defaultValue,s,a),{getMenuProps:f,getInputProps:m,highlightedIndex:y,inputValue:K,getItemProps:x,isOpen:v}=useCombobox({items:c,initialIsOpen:p==="",defaultInputValue:p,itemToString:b=>(b==null?void 0:b.code)??"",onInputValueChange:({inputValue:b})=>{d(l.filter(({label:R,code:O})=>[R,O].flatMap(I=>I.split(/\s+/)).map(I=>I.toLowerCase()).some(I=>I.startsWith((b??"").toLowerCase()))))}}),M=inputIsValid(K,s);return jsx(ModalBackground,{children:jsxs(ModalContainer,{children:[jsxs(PromptText,{children:[t("Please enter your desired QMK keycode or hex code"),":"]}),jsxs("div",{children:[jsx("div",{children:jsx(TextInput,{...m(),type:"text",placeholder:p||"KC_NO, 0xFF, etc."})}),jsx(AutocompleteContainer,{...f(),style:{display:v&&c.length?"block":"none"},children:v&&c.map((b,R)=>reactExports.createElement(AutocompleteItemRow,{...x({item:b,index:R}),key:b.code},jsx(AutocompleteItem,{selected:y===R,entity:b},b.code)))})]}),jsxs(RowDiv$1,{children:[jsx(AccentButton,{onClick:e.onExit,children:t("Cancel")}),jsx(PrimaryAccentButton,{disabled:!M,onClick:()=>{e.onConfirm(keycodeFromInput(K,s))},children:t("Confirm")})]})]})})},PelpiKeycodeInput=e=>{const[t,r]=React.useState(!1),{basicKeyToByte:s,byteToKey:a}=useAppSelector(getBasicKeyToByte);return jsxs(Fragment,{children:[jsx(AccentButton,{onClick:()=>r(!0),children:anyKeycodeToString(e.value,s,a)}),t&&jsx(KeycodeModal,{defaultValue:e.value,onChange:e.setValue,onConfirm:l=>{e.setValue(l),r(!1)},onExit:()=>r(!1)})]})},HiddenInput$3=styled.input`
|
|
303
|
+
opacity: 0;
|
|
304
|
+
width: 0;
|
|
305
|
+
height: 0;
|
|
306
|
+
`,Switch=styled.label`
|
|
307
|
+
position: relative;
|
|
308
|
+
display: inline-block;
|
|
309
|
+
width: 60px;
|
|
310
|
+
height: 34px;
|
|
311
|
+
`,Slider$1=styled.span`
|
|
312
|
+
position: absolute;
|
|
313
|
+
cursor: ${e=>e.$disabled?"default":"pointer"};
|
|
314
|
+
top: 0;
|
|
315
|
+
left: 0;
|
|
316
|
+
right: 0;
|
|
317
|
+
bottom: 0;
|
|
318
|
+
background-color: ${e=>e.$ischecked&&!e.$disabled?"var(--color_accent)":"var(--bg_control)"};
|
|
319
|
+
-webkit-transition: 0.4s;
|
|
320
|
+
transition: 0.4s;
|
|
321
|
+
border-radius: 4px;
|
|
322
|
+
&:before {
|
|
323
|
+
position: absolute;
|
|
324
|
+
content: '';
|
|
325
|
+
height: 26px;
|
|
326
|
+
width: 26px;
|
|
327
|
+
left: 4px;
|
|
328
|
+
bottom: 4px;
|
|
329
|
+
border-radius: 4px;
|
|
330
|
+
background-color: ${e=>e.$ischecked?"var(--color_inside-accent)":"var(--bg_icon)"};
|
|
331
|
+
-webkit-transition: 0.4s;
|
|
332
|
+
transition: 0.4s;
|
|
333
|
+
${e=>e.$ischecked?"transform: translateX(26px)":""};
|
|
334
|
+
}
|
|
335
|
+
`;function AccentSlider(e){const{isChecked:t,onChange:r,disabled:s}=e,[a,l]=React.useState(t),c=reactExports.useRef(null);return React.useEffect(()=>{l(t)},[t]),jsxs(Switch,{children:[jsx(HiddenInput$3,{ref:c,type:"checkbox",checked:a,onChange:()=>{if(s)return;const p=!t;l(p),r(p),c.current&&c.current.blur()}}),jsx(Slider$1,{$ischecked:a,$disabled:s})]})}const customStyles={option:(e,t)=>({...e,"&:hover":{backgroundColor:t.isSelected?"var(--color_accent)":"var(--bg_control)"},":active":{backgroundColor:"var(--bg_control)"},background:t.isSelected?"var(--color_accent)":t.isFocused?"var(--bg_control)":"var(--bg_menu)",color:t.isSelected?"var(--color_inside-accent)":(t.isFocused,"var(--color_accent)")}),container:e=>({...e,lineHeight:"initial",flex:1}),input:e=>({...e,color:"var(--color_accent)",opacity:.5}),singleValue:e=>({...e,color:"var(--color_accent)"}),dropdownIndicator:e=>({...e,color:"var(--color_accent)"}),indicatorSeparator:e=>({...e,backgroundColor:"var(--color_accent)"}),menuList:e=>({...e,borderColor:"var(--color_accent)",backgroundColor:"var(--bg_menu)"}),placeholder:e=>({...e,color:"var(--color_accent)"}),valueContainer:e=>({...e,":active":{backgroundColor:"var(--bg_control)",borderColor:"var(--color_accent)"},"&:hover":{borderColor:"var(--color_accent)"},color:"var(--color_accent)",background:"var(--bg_menu)"}),control:(e,t)=>({...e,boxShadow:"none",":active":{backgroundColor:"transparent",borderColor:"var(--color_accent)"},"&:hover":{borderColor:"var(--color_accent)"},color:"var(--color_accent)",borderColor:"1px solid var(--color_accent)",background:"var(--bg_menu)",overflow:"hidden",width:t.selectProps.width||250})},AccentSelect=e=>jsx(Select,{...e,styles:customStyles}),Container$n=styled.span`
|
|
336
|
+
display: inline-flex;
|
|
337
|
+
align-items: center;
|
|
338
|
+
line-height: initial;
|
|
339
|
+
column-gap: 5px;
|
|
340
|
+
min-width: 200px;
|
|
341
|
+
`,SliderInput=styled.input.attrs({type:"range"})`
|
|
342
|
+
accent-color: var(--color_accent);
|
|
343
|
+
width: 200px;
|
|
344
|
+
`,AccentRange=e=>{const{showLabel:t,...r}=e;return jsxs(Container$n,{children:[e.showLabel&&jsxs("span",{children:[e.value??e.defaultValue,e.percent&&"%"]}),jsx(SliderInput,{...r,onChange:s=>{e.onChange&&e.onChange(+s.target.value)}})]})},ColorPickerContainer=styled.div`
|
|
345
|
+
display: flex;
|
|
346
|
+
align-items: center;
|
|
347
|
+
`,ColorLens=styled.div`
|
|
348
|
+
position: absolute;
|
|
349
|
+
width: 10px;
|
|
350
|
+
height: 10px;
|
|
351
|
+
border-radius: 50%;
|
|
352
|
+
border: 2px solid black;
|
|
353
|
+
opacity: 0.7;
|
|
354
|
+
background: rgba(255, 255, 255, 0.2);
|
|
355
|
+
pointer-events: none;
|
|
356
|
+
box-sizing: border-box;
|
|
357
|
+
transform: translate3d(195px, 195px, 0);
|
|
358
|
+
`,ColorInner=styled.div`
|
|
359
|
+
width: 100%;
|
|
360
|
+
height: 100%;
|
|
361
|
+
background: linear-gradient(to top, white, rgba(0, 0, 0, 0));
|
|
362
|
+
`,ColorOuter=styled.div`
|
|
363
|
+
width: 100%;
|
|
364
|
+
height: 100%;
|
|
365
|
+
background: linear-gradient(
|
|
366
|
+
to right,
|
|
367
|
+
red,
|
|
368
|
+
yellow,
|
|
369
|
+
lime,
|
|
370
|
+
aqua,
|
|
371
|
+
blue,
|
|
372
|
+
magenta,
|
|
373
|
+
red
|
|
374
|
+
);
|
|
375
|
+
`,ColorThumbnail=styled.div`
|
|
376
|
+
display: inline-block;
|
|
377
|
+
height: 25px;
|
|
378
|
+
width: 25px;
|
|
379
|
+
border-radius: 50%;
|
|
380
|
+
border: 4px solid var(--border_color_cell);
|
|
381
|
+
cursor: pointer;
|
|
382
|
+
&:hover {
|
|
383
|
+
opacity: 0.8;
|
|
384
|
+
}
|
|
385
|
+
`,Container$m=styled.div`
|
|
386
|
+
border: 4px solid var(--border_color_cell);
|
|
387
|
+
width: 180px;
|
|
388
|
+
height: 180px;
|
|
389
|
+
position: relative;
|
|
390
|
+
`,PickerContainer$1=styled.div`
|
|
391
|
+
position: relative;
|
|
392
|
+
display: flex;
|
|
393
|
+
justify-content: center;
|
|
394
|
+
align-items: center;
|
|
395
|
+
flex-direction: column;
|
|
396
|
+
z-index: 1;
|
|
397
|
+
box-shadow: rgba(0, 0, 0, 0.11) 0 1px 1px 1px;
|
|
398
|
+
position: absolute;
|
|
399
|
+
transform: translate3d(-205px, 50px, 0);
|
|
400
|
+
|
|
401
|
+
&::after {
|
|
402
|
+
content: '';
|
|
403
|
+
position: absolute;
|
|
404
|
+
width: 0px;
|
|
405
|
+
height: 0px;
|
|
406
|
+
border: 11px solid var(--border_color_cell);
|
|
407
|
+
border-top-color: transparent;
|
|
408
|
+
border-bottom-color: transparent;
|
|
409
|
+
border-right-color: transparent;
|
|
410
|
+
right: -22px;
|
|
411
|
+
top: 66px;
|
|
412
|
+
}
|
|
413
|
+
`,ColorPreview$2=styled.div`
|
|
414
|
+
width: 180px;
|
|
415
|
+
height: 24px;
|
|
416
|
+
border: 4px solid var(--border_color_cell);
|
|
417
|
+
border-bottom: none;
|
|
418
|
+
`,ColorHexContainer=styled.div`
|
|
419
|
+
border: 4px solid var(--border_color_cell);
|
|
420
|
+
border-bottom: none;
|
|
421
|
+
width: 180px;
|
|
422
|
+
height: 32px;
|
|
423
|
+
line-height: 32px;
|
|
424
|
+
text-align: center;
|
|
425
|
+
background: var(--bg_menu);
|
|
426
|
+
`,ColorHexInput=styled.input`
|
|
427
|
+
text-align: center;
|
|
428
|
+
border: none;
|
|
429
|
+
color: var(--color_accent);
|
|
430
|
+
background: var(--bg_menu);
|
|
431
|
+
font-size: 20px;
|
|
432
|
+
font-weight: 300;
|
|
433
|
+
padding: 0;
|
|
434
|
+
width: 100%;
|
|
435
|
+
&:focus {
|
|
436
|
+
outline: none;
|
|
437
|
+
color: var(--color_accent);
|
|
438
|
+
border-color: var(--color_accent);
|
|
439
|
+
}
|
|
440
|
+
`;let ColorPicker$2=class extends reactExports.Component{constructor(){super(...arguments);ie(this,"ref",null);ie(this,"refWidth",0);ie(this,"refHeight",0);ie(this,"mouseDown",!1);ie(this,"state",{lensTransform:"",showPicker:!1,offset:[5,5],hexColorCode:getHex(this.props.color)});ie(this,"onMouseMove",r=>{if(this.mouseDown){const{offsetX:s,offsetY:a}=r.nativeEvent,l=`translate3d(${s-5}px, ${a-5}px, 0)`,c=[s,a],{hue:d,sat:p}=this.getLinearHueSat(c),f=getHex(this.props.color);this.props.setColor(Math.round(255*(d/360)),Math.round(255*p)),this.setState({lensTransform:l,offset:c,hexColorCode:f})}});ie(this,"onMouseDown",r=>{this.mouseDown=!0,this.onMouseMove(r),this.ref&&(this.ref.style.cursor="pointer")});ie(this,"onMouseUp",()=>{if(this.mouseDown=!1,this.ref&&(this.ref.style.cursor="auto"),this.props.onMouseUp){const{hue:r,sat:s}=this.getLinearHueSat(this.state.offset);this.props.onMouseUp(r,s)}});ie(this,"onThumbnailClick",()=>{this.props.onOpen&&this.props.onOpen(),this.setState({showPicker:!0})});ie(this,"pickerContainer",React.createRef());ie(this,"colorThumbnail",React.createRef());ie(this,"onDocumentClick",r=>{if(this.state.showPicker&&this.pickerContainer.current&&!this.pickerContainer.current.contains(r.target)&&this.colorThumbnail.current&&!this.colorThumbnail.current.contains(r.target)&&!this.mouseDown){if(this.props.onClose){const{hue:s,sat:a}=this.getLinearHueSat(this.state.offset);this.props.onClose(s,a)}this.mouseDown=!1,this.setState({showPicker:!1,hexColorCode:getHex(this.props.color)})}else this.mouseDown&&this.state.showPicker&&this.pickerContainer.current&&!this.pickerContainer.current.contains(r.target)&&this.colorThumbnail.current&&!this.colorThumbnail.current.contains(r.target)&&this.onMouseUp()});ie(this,"handleHexChange",r=>{let s=r.target.value;s=s.replace(/[^A-Fa-f0-9]/g,""),s.length>0&&s[0]!=="#"&&(s=`#${s}`),s.length>7&&(s=s.substring(0,7)),this.setState({hexColorCode:s})});ie(this,"handleHexBlur",r=>{this.setState({hexColorCode:getHex(this.props.color)})});ie(this,"handleHexSubmit",r=>{if(r.key==="Enter"){if(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(this.state.hexColorCode)){var s=this.state.hexColorCode.replace("#","");s.length==3&&(s=`${s.split("").map(d=>d+d).join("")}`);const[l,c]=getHSV(s);this.props.setColor(Math.round(255*(l/360)),Math.round(255*c))}this.setState({hexColorCode:getHex(this.props.color)})}})}componentWillUnmount(){document.removeEventListener("mousedown",this.onDocumentClick),document.removeEventListener("click",this.onDocumentClick)}componentDidUpdate({color:r},s){if(this.ref&&this.state.showPicker&&(!s.showPicker||r!==this.props.color)){const{width:a,height:l}=this.ref.getBoundingClientRect();this.refWidth=a,this.refHeight=l;const{hue:c,sat:d}=this.props.color,p=a*c/255,f=l*(1-d/255),m=`translate3d(${p-5}px, ${f-5}px, 0)`;this.setState({lensTransform:m,offset:[p,f]})}}componentDidMount(){document.addEventListener("click",this.onDocumentClick),document.addEventListener("mousedown",this.onDocumentClick)}getRadialHueSat(r){const{offsetX:s,offsetY:a}=r.nativeEvent,l=toDegrees(calcRadialHue(s,a)??0),c=Math.min(1,calcRadialMagnitude(s,a)??0);return{hue:l,sat:c}}getLinearHueSat([r,s]){const a=this.refWidth,l=this.refHeight,[c,d]=[Math.max(0,r),Math.max(0,s)],p=360*Math.min(1,c/a),f=1-Math.min(1,d/l);return{hue:p,sat:f}}render(){const r=getRGB(this.props.color),{isSelected:s=!1}=this.props,{offset:a}=this.state,l=`translate3d(${a[0]-5}px, ${a[1]-5}px, 0)`;return jsx(Fragment,{children:jsxs(ColorPickerContainer,{children:[jsx(ColorThumbnail,{ref:this.colorThumbnail,onClick:this.onThumbnailClick,style:{background:r,borderColor:s?"var(--color_accent)":"var(--border_color_cell)"}}),this.state.showPicker&&jsxs(PickerContainer$1,{ref:this.pickerContainer,onMouseUp:this.onMouseUp,children:[jsx(ColorHexContainer,{children:jsx(ColorHexInput,{type:"text",value:this.state.hexColorCode,onChange:this.handleHexChange,onBlur:this.handleHexBlur,onKeyDown:this.handleHexSubmit})}),jsx(ColorPreview$2,{style:{background:getRGB(this.props.color)}}),jsx(Container$m,{children:jsx(ColorOuter,{onMouseDown:this.onMouseDown,onMouseMove:this.onMouseMove,ref:c=>this.ref=c,children:jsx(ColorInner,{children:jsx(ColorLens,{style:{transform:l}})})})})]})]})})}};const ArrayColorPicker=e=>{const{color:t,setColor:r}=e;return jsx(ColorPicker$2,{color:{hue:t[0],sat:t[1]},setColor:r})},ColorPalettePickerContainer=styled.div`
|
|
441
|
+
display: flex;
|
|
442
|
+
align-items: center;
|
|
443
|
+
column-gap: 10px;
|
|
444
|
+
`,PreviousColorContainer=styled.div`
|
|
445
|
+
display: flex;
|
|
446
|
+
background: var(--bg_control);
|
|
447
|
+
border-radius: 15px;
|
|
448
|
+
`,PreviousColorOption=styled.div`
|
|
449
|
+
display: inline-block;
|
|
450
|
+
height: 25px;
|
|
451
|
+
width: 25px;
|
|
452
|
+
border-radius: 50%;
|
|
453
|
+
border: 4px solid var(--border_color_cell);
|
|
454
|
+
cursor: pointer;
|
|
455
|
+
transition: transform 0.2s ease-out;
|
|
456
|
+
&:hover {
|
|
457
|
+
opacity: 0.8;
|
|
458
|
+
}
|
|
459
|
+
transform: ${e=>e.$selected?"scale(0.8)":"scale(0.6)"};
|
|
460
|
+
border-color: ${e=>e.$selected?"var(--color_accent)":"var(--border_color_cell)"};
|
|
461
|
+
`,ConnectedColorPalettePicker=()=>{const e=useDispatch(),t=reactExports.useCallback((r,s)=>e(setSelectedPaletteColor([r,s])),[e]);return reactExports.useEffect(()=>(e(updateShowKeyPainter(!0)),()=>{e(updateShowKeyPainter(!1))})),jsx(ColorPalettePicker,{color:[0,0],setColor:t})},ColorPalettePicker=e=>{const{color:t,setColor:r}=e,[s,a]=reactExports.useState(t),[l,c]=reactExports.useState(t),d=reactExports.useMemo(()=>Array(9).fill(0).map((p,f)=>[Math.round(f*255/10),255,255]),[]);return jsxs(ColorPalettePickerContainer,{children:[jsx(PreviousColorContainer,{children:d.map((p,f)=>{const m=s[0]===p[0]&&s[1]===p[1];return jsx(PreviousColorOption,{$selected:m,style:{background:getRGB({hue:p[0]??0,sat:p[1]??0})},onClick:()=>{a(p),r(p[0],p[1])}},f)})}),jsx(ColorPicker$2,{isSelected:l[0]===s[0]&&l[1]===s[1],color:{hue:l[0],sat:l[1]},setColor:(p,f)=>{a([p,f]),c([p,f])},onOpen:()=>{a([l[0],l[1]]),r(l[0],l[1])},onMouseUp:()=>{a([l[0],l[1]]),r(l[0],l[1])}})]})},VIACustomItem=React.memo(e=>{const{t}=useTranslation();return e.value.length===0?jsx(Fragment,{}):jsxs(ControlRow,{id:e._id,children:[jsx(Label$1,{children:t(e.label)}),jsx(Detail,{children:"type"in e?jsx(VIACustomControl,{...e,value:e.value&&Array.from(e.value)}):e.content})]})}),boxOrArr=e=>Array.isArray(e)?e:[e],valueIsChecked=(e,t)=>boxOrArr(e).every((r,s)=>r==t[s]),getRangeValue=(e,t)=>t>255?shiftTo16Bit([e[0],e[1]]):e[0],getRangeBytes=(e,t)=>t>255?shiftFrom16Bit(e):[e],VIACustomControl=e=>{const{t}=useTranslation(),{content:r,type:s,options:a,value:l}=e,[c,...d]=r;switch(s){case"button":{const p=a||[1];return jsx(AccentButton,{onClick:()=>e.updateValue(c,...d,p[0]),children:t("Click")})}case"range":return jsx(AccentRange,{showLabel:!0,min:a[0],max:a[1],percent:a[1]&&a[1]===100,defaultValue:getRangeValue(e.value,a[1]),onChange:p=>e.updateValue(c,...d,...getRangeBytes(p,a[1]))});case"keycode":return jsx(PelpiKeycodeInput,{value:shiftTo16Bit([e.value[0],e.value[1]]),meta:{},setValue:p=>e.updateValue(c,...d,...shiftFrom16Bit(p))});case"toggle":{const p=a||[0,1];return jsx(AccentSlider,{isChecked:valueIsChecked(p[1],e.value),onChange:f=>e.updateValue(c,...d,...boxOrArr(p[+f]))})}case"dropdown":{const p=a.map((f,m)=>{const[y,K]=typeof f=="string"?[f,m]:f;return{value:K||m,label:t(y)}});return jsx(AccentSelect,{onChange:f=>f&&e.updateValue(c,...d,+f.value),options:p,defaultValue:p.find(f=>l[0]===f.value),value:p.find(f=>l[0]===f.value)})}case"color":return jsx(ArrayColorPicker,{color:e.value,setColor:(p,f)=>e.updateValue(c,...d,p,f)});case"color-palette":return jsx(ConnectedColorPalettePicker,{})}return null},CustomPane=styled(CenterPane)`
|
|
462
|
+
height: 100%;
|
|
463
|
+
background: var(--color_dark_grey);
|
|
464
|
+
`,Container$l=styled.div`
|
|
465
|
+
display: flex;
|
|
466
|
+
align-items: center;
|
|
467
|
+
flex-direction: column;
|
|
468
|
+
padding: 0 12px;
|
|
469
|
+
`;function categoryGenerator(e){return e.viaMenu.content.flatMap(t=>submenuGenerator(t,e))}function itemGenerator(e,t){return"showIf"in e&&!dist$1.evalExpr(e.showIf,t.selectedCustomMenuData)?[]:"label"in e?{...e,key:e._id}:e.content.flatMap(r=>itemGenerator(r,t))}const TimeSyncItem=()=>{const{t}=useTranslation(),r=useAppSelector(getSelectedKeyboardAPI),s=reactExports.useRef(),[a,l]=reactExports.useState(new Date),c=a.toLocaleDateString(void 0,{hour:"2-digit",hour12:!1,minute:"2-digit",second:"2-digit"});return reactExports.useEffect(()=>(s.current=setInterval(()=>{l(new Date)},1e3),()=>{clearInterval(s.current)}),[]),jsxs(ControlRow,{children:[jsx(Label$1,{children:c}),jsx(Detail,{children:jsx(AccentButton,{onClick:()=>{if(!r)return;const p=~~(a.getTime()/1e3)-a.getTimezoneOffset()*60;r.setCustomMenuValue(25,...numIntoBytes(p)),r.commitCustomMenu(25)},children:t("Time Sync")})})]})},MenuComponent=React.memo(e=>jsxs(Fragment,{children:[e.elem.content.flatMap(t=>itemGenerator(t,e)).map(t=>jsx(VIACustomItem,{...t,updateValue:e.updateCustomMenuValue,value:e.selectedCustomMenuData[t.content[0]]})),e.elem.label=="Date Time"&&jsx(TimeSyncItem,{})]})),MenuBuilder=e=>t=>reactExports.createElement(MenuComponent,{...t,key:e._id,elem:e});function submenuGenerator(e,t){return"showIf"in e&&!dist$1.evalExpr(e.showIf,t.selectedCustomMenuData)?[]:"label"in e?{label:e.label,Menu:MenuBuilder(e)}:e.content.flatMap(r=>submenuGenerator(r,t))}const Pane$b=e=>{const{t}=useTranslation(),[,r]=useLocation(),s=useAppDispatch(),a=categoryGenerator(e),[l,c]=reactExports.useState(a[0]||{label:"",Menu:()=>jsx("div",{})}),d=l.Menu,p=useAppSelector(getSelectedDefinition),f=useAppSelector(getSelectedCustomMenuData),m=useAppSelector(getSelectedConnectedDevice),y={...e,selectedDefinition:p,selectedCustomMenuData:f,updateCustomMenuValue:(K,...x)=>{s(updateCustomMenuValue(K,...x)),K==="id_cp_connect_dfu"&&shallowEqual([18,5,1],x.slice(0,3))&&setTimeout(()=>{r("/boot")},3e3)}};return!p||!f||!m?null:jsxs(Fragment,{children:[jsx(SubmenuCell,{children:jsx(MenuContainer$6,{children:a.map(K=>jsx(SubmenuRow,{$selected:l.label===K.label,onClick:()=>c(K),children:t(K.label)},K.label))})}),jsx(OverflowCell,{children:jsx(CustomPane,{children:jsx(Container$l,{children:d(y)})})})]})},MenuContainer$6=styled.div`
|
|
470
|
+
padding: 15px 10px 20px 10px;
|
|
471
|
+
`,iconKeywords=[{icon:faLightbulb,keywords:["light","rgb"]},{icon:faHeadphones,keywords:["audio","sound"]},{icon:faDisplay,keywords:["display","oled","lcd"]}],getIconFromLabel=e=>{const t=e.label.toLowerCase(),r={icon:faGear};return(iconKeywords.find(s=>s.keywords.some(a=>t.includes(a)))||r).icon},makeCustomMenu=(e,t)=>({Title:e.label,Icon:()=>jsx(FontAwesomeIcon,{icon:getIconFromLabel(e)}),Pane:r=>reactExports.createElement(Pane$b,{...r,key:`${e.label}-${t}`,viaMenu:e})}),makeCustomMenus=e=>e.map(makeCustomMenu),initialState$6={customMenuDataMap:{},commonMenusMap:{},showKeyPainter:!1,selectedRowTitle:void 0},menusSlice=createSlice({name:"menus",initialState:initialState$6,reducers:{updateShowKeyPainter:(e,t)=>{e.showKeyPainter=t.payload},updateSelectedCustomMenuData:(e,t)=>{const{devicePath:r,menuData:s}=t.payload;e.customMenuDataMap[r]=s},updateCommonMenus:(e,t)=>{const{commonMenuMap:r}=t.payload;e.commonMenusMap=r},updateCustomMenuData:(e,t)=>{e.customMenuDataMap={...e.customMenuDataMap,...t.payload}},updateSelectedRowTitle:(e,t)=>{e.selectedRowTitle=t.payload}}}),{updateShowKeyPainter,updateSelectedCustomMenuData,updateCustomMenuData,updateSelectedRowTitle}=menusSlice.actions,menusReducer=menusSlice.reducer,updateCustomMenuValue=(e,...t)=>async(r,s)=>{const a=s(),l=getSelectedConnectedDevice(a);if(!l)return;const c=getSelectedCustomMenuData(a),d=getCustomCommands(a),p={...c,[e]:[...t.slice(d[e].length)]},{path:f}=l;r(updateSelectedCustomMenuData({menuData:p,devicePath:f}));const m=getSelectedKeyboardAPI(a);m.setCustomMenuValue(...t.slice(0));const y=t[0];m.commitCustomMenu(y)},tryResolveCommonMenu=e=>typeof e=="string"?dist.commonMenus[e]:e,updateV3MenuData=e=>async(t,r)=>{const s=r(),a=getSelectedDefinition(s),l=getSelectedKeyboardAPI(s);if(!dist.isVIADefinitionV3(a))throw new Error("V3 menus are only compatible with V3 VIA definitions.");const d=getV3Menus(s).flatMap(extractCommands),{protocol:p,path:f}=e;if(d.length!==0&&p>=11){let m={};const y=d.map(([v,M,...b])=>({command:v,promise:l.getCustomMenuValue([M].concat(b))})),K=await Promise.all(y.map(v=>v.promise));m=y.reduce(({res:v,ref:M},b,R)=>({ref:M,res:{...v,[b.command]:M[R].slice(1)}}),{res:m,ref:K}).res;const x=Math.max(...a.layouts.keys.map(v=>v.li??-1));if(console.debug(x,"maxLedIndex"),x>=0){const v=await l.getPerKeyRGBMatrix(Array(x+1).fill(0).map((M,b)=>b));m.__perKeyRGB=v}t(updateSelectedCustomMenuData({devicePath:f,menuData:{...m}}))}},extractCommands=e=>typeof e=="string"?[]:"type"in e?[e.content]:"content"in e&&typeof e.content!="string"?e.content.flatMap(extractCommands):[],getShowKeyPainter=e=>e.menus.showKeyPainter,getCustomMenuDataMap=e=>e.menus.customMenuDataMap,getSelectedCustomMenuData=createSelector(getCustomMenuDataMap,getSelectedDevicePath,(e,t)=>t&&e[t]),getSelectedRowTitle=e=>e.menus.selectedRowTitle,getV3Menus=createSelector(getSelectedDefinition,e=>!e||!dist.isVIADefinitionV3(e)?[]:(e.menus||[]).flatMap(tryResolveCommonMenu).map((t,r)=>dist.isVIAMenu(t)?compileMenu("custom_menu",3,t,r):t)),getV3MenuComponents=createSelector(getSelectedDefinition,e=>!e||!dist.isVIADefinitionV3(e)?[]:(e.menus||[]).flatMap(tryResolveCommonMenu).map((t,r)=>dist.isVIAMenu(t)?makeCustomMenu(compileMenu("custom_menu",3,t,r),r):t)),getCustomCommands=createSelector(getSelectedDefinition,getV3Menus,(e,t)=>{if(!e)return[];const r=dist.isVIADefinitionV2(e)?e.customMenus:t;return r===void 0?[]:r.flatMap(extractCommands).reduce((s,a)=>({...s,[a[0]]:a.slice(1)}),{})}),compileMenu=(e,t=0,r,s)=>t===0?r:{...r,_id:`${e}_${s}`,content:r.label!==void 0?typeof r.content=="string"?r.content:r.content.map((a,l)=>compileMenu(`${e}_${l}`,t-1,a,s)):r.content.map((a,l)=>compileMenu(`${e}_${l}`,t,a,s))},initialState$5={showMatrix:!1,selectedOptionKeys:[],selectedDefinitionIndex:0},designSlice=createSlice({name:"design",initialState:initialState$5,reducers:{updateSelectedDefinitionIndex:(e,t)=>{e.selectedDefinitionIndex=t.payload},updateSelectedOptionKeys:(e,t)=>{e.selectedOptionKeys=t.payload},updateShowMatrix:(e,t)=>{e.showMatrix=t.payload}}}),{updateSelectedDefinitionIndex,updateSelectedOptionKeys,updateShowMatrix}=designSlice.actions,designReducer=designSlice.reducer,getSelectedDefinitionIndex=e=>e.design.selectedDefinitionIndex,getDesignSelectedOptionKeys=e=>e.design.selectedOptionKeys,getShowMatrix=e=>e.design.showMatrix,tabkbConfigSlice=createSlice({name:"tabkbconfig",initialState:{configs:{}},reducers:{setTabkbConfigs(e,t){e.configs=t.payload}}}),{setTabkbConfigs}=tabkbConfigSlice.actions,tabkbconfigReducer=tabkbConfigSlice.reducer,loadTabkbConfigs=()=>async(e,t)=>{const s=await(await fetch("/tabkb/configs.json",{cache:"reload"})).json();let a={};for(const l of s){if(!l.vendorId||!l.productId)continue;const c=getVendorProductId(parseInt(l.vendorId),parseInt(l.productId));a[c]=l}e(setTabkbConfigs(a))},getConfigs=e=>e.tabkbconfig.configs,getSelectedTabkbConfig=createSelector([getConfigs,getSelectedDefinition],(e,t)=>{if(!(!t||!e[t.vendorProductId]))return e[t.vendorProductId]}),getTapDanceKeycodes=createSelector(getSelectedTabkbConfig,e=>!e||!e.tapDance?[]:e.tapDance),getCDCMacIssue=createSelector(getSelectedTabkbConfig,e=>!!(e!=null&&e.cdcMacIssue)),mlHeader=[...new TextEncoder().encode("tabml")],mlHeaderSize=32,DefaultMaxFrame=200,initMatrix=(e,t,r={r:0,g:0,b:0})=>Array(e).fill("").map(()=>Array(t).fill(r)),initialState$4={color:{r:255,g:255,b:255},rows:0,cols:0,fps:10,matrixIdx:0,matrixList:[],saving:!1,texts:[],infoContent:0},lightingSlice=createSlice({name:"matrixlighting",initialState:initialState$4,reducers:{updateColor(e,t){e.color=t.payload},updateMatrix(e,t){const{row:r,col:s}=t.payload;r>e.rows-1||s>e.cols-1||(e.matrixList[e.matrixIdx][r][s]=e.color)},setMatrix(e,t){e.matrixList[e.matrixIdx]=t.payload},updateMatrixIndex(e,t){t.payload!==void 0&&(e.matrixIdx=t.payload)},resetMatrix(e){e.matrixIdx=0,e.matrixList=[initMatrix(e.rows,e.cols)]},addMatrix(e){e.matrixList=[...e.matrixList.slice(0,e.matrixIdx+1),initMatrix(e.rows,e.cols),...e.matrixList.slice(e.matrixIdx+1)],e.matrixIdx+=1},deleteMatrix(e){if(e.matrixList.length===1){e.matrixList[0]=initMatrix(e.rows,e.cols);return}e.matrixList.splice(e.matrixIdx,1),e.matrixIdx>=e.matrixList.length&&(e.matrixIdx-=1)},nextMatrix(e){let t=e.matrixIdx+1;t>=e.matrixList.length&&(t=0),e.matrixIdx=t},copyMatrix(e){e.matrixList=[...e.matrixList.slice(0,e.matrixIdx+1),e.matrixList[e.matrixIdx],...e.matrixList.slice(e.matrixIdx+1)],e.matrixIdx+=1},setMatrixList(e,t){e.matrixList=t.payload,e.matrixIdx=0},shiftLeft(e){const t=e.matrixList[e.matrixIdx],r=initMatrix(e.rows,e.cols);for(let s=0;s<e.rows;s++)for(let a=0;a<e.cols;a++)a>0?r[s][a-1]=t[s][a]:r[s][e.cols-1]=t[s][a];e.matrixList[e.matrixIdx]=r},shiftRight(e){const t=e.matrixList[e.matrixIdx],r=initMatrix(e.rows,e.cols);for(let s=0;s<e.rows;s++)for(let a=0;a<e.cols;a++)a<e.cols-1?r[s][a+1]=t[s][a]:r[s][0]=t[s][a];e.matrixList[e.matrixIdx]=r},shiftUp(e){const t=e.matrixList[e.matrixIdx],r=initMatrix(e.rows,e.cols);for(let s=0;s<e.rows;s++)for(let a=0;a<e.cols;a++)s>0?r[s-1][a]=t[s][a]:r[e.rows-1][a]=t[s][a];e.matrixList[e.matrixIdx]=r},shiftDown(e){const t=e.matrixList[e.matrixIdx],r=initMatrix(e.rows,e.cols);for(let s=0;s<e.rows;s++)for(let a=0;a<e.cols;a++)s<e.rows-1?r[s+1][a]=t[s][a]:r[0][a]=t[s][a];e.matrixList[e.matrixIdx]=r},fillMatrix(e){e.matrixList[e.matrixIdx]=initMatrix(e.rows,e.cols)},sortMatrixByIndex(e,t){const{newIndex:r}=t.payload;if(e.matrixIdx===r)return;const[s]=e.matrixList.splice(e.matrixIdx,1);e.matrixList.splice(r,0,s),e.matrixIdx=r},setRows:(e,t)=>{e.rows=t.payload},setCols:(e,t)=>{e.cols=t.payload},setFps:(e,t)=>{e.fps=t.payload},setSaving:(e,t)=>{e.saving=t.payload},loadFile:(e,t)=>{const r=e.rows,s=e.cols,{frames:a,fps:l,data:c}=t.payload,d=s*r*3,p=Array(a).fill(0).map(()=>Array(r).fill(0).map(()=>Array(s).fill({r:0,g:0,b:0})));for(let f=0;f<c.length;f+=3){const m=~~(f/d),y=f%d/3,K=~~(y/s),x=y%s,v={r:c[f],g:c[f+1],b:c[f+2]};p[m][K][x]=v}e.fps=l,e.matrixIdx=0,e.matrixList=p},updateTexts:(e,t)=>{e.texts=t.payload},updateInfoContent:(e,t)=>{e.infoContent=t.payload}},extraReducers(e){e.addCase(selectDevice,t=>{t.saving=!1})}}),{updateColor,updateMatrix,resetMatrix,addMatrix,deleteMatrix,updateMatrixIndex,nextMatrix,copyMatrix,setMatrix,setMatrixList,fillMatrix,sortMatrixByIndex,setRows,setCols,setFps,setSaving,loadFile,shiftLeft,shiftRight,shiftUp,shiftDown,updateTexts,updateInfoContent}=lightingSlice.actions,matrixlightingReducer=lightingSlice.reducer,saveToKeyboard=()=>async(e,t)=>{const r=t(),s=getTabFileAPI(r),a=getSaving(r);if(!s||a)return;const l=getRows(r),c=getCols(r),d=getFrames(r),p=getFps(r),f=getKBMatrixData(r);e(setSaving(!0)),await s.setMatrixLighting(d,p,l,c,f).finally(()=>{e(setSaving(!1))})},loadMatrixLighintConfig=()=>async(e,t)=>{const r=t(),s=getSelectedTabkbConfig(r);if(!(s!=null&&s.matrixLighting))return;const{cols:a,rows:l}=s.matrixLighting;if(e(setCols(a)),e(setRows(l)),e(setMatrixList([initMatrix(l,a)])),s.matrixLighting.texts){const c=s.matrixLighting.texts,d=getSelectedKeyboardAPI(r);if(!d){e(updateTexts(Array(c.count).fill("")));return}const p=await d.getMatrixLightingTexts(c.count,c.length);e(updateTexts(p))}if(s.matrixLighting.info){const c=getSelectedKeyboardAPI(r);if(!c)return;const d=await c.getMatrixLightingInfoContent();e(updateInfoContent(d))}},saveTexts=e=>async(t,r)=>{const s=r(),a=getSelectedKeyboardAPI(s),l=getTextsConfig(s);if(!a||!l)return;const c=getTexts(s);for(let d=0;d<l.count;d++)c[d]!==e[d]&&await a.setMatrixLightingTexts(d,l.length,e);t(updateTexts(e))},saveInfoContent=e=>async(t,r)=>{const s=r(),a=getSelectedKeyboardAPI(s);a&&(await a.setMatrixLightingInfoContent(e),t(updateInfoContent(e)))},getActiveColor=e=>e.matrixlighting.color,getRows=e=>e.matrixlighting.rows,getCols=e=>e.matrixlighting.cols,getMatrixList=e=>e.matrixlighting.matrixList,getMatrixIdx=e=>e.matrixlighting.matrixIdx,getFps=e=>e.matrixlighting.fps,getSaving=e=>e.matrixlighting.saving,getFrames=e=>e.matrixlighting.matrixList.length,getTexts=e=>e.matrixlighting.texts,getInfoContent=e=>e.matrixlighting.infoContent,getMaxFrame=createSelector(getSelectedTabkbConfig,e=>e?(e==null?void 0:e.matrixLighting.maxFrame)??DefaultMaxFrame:DefaultMaxFrame),getImportEnable=createSelector(getSelectedTabkbConfig,e=>e?!!(e!=null&&e.matrixLighting.importEnable):!1),getTextsConfig=createSelector(getSelectedTabkbConfig,e=>{var t;return(t=e==null?void 0:e.matrixLighting)==null?void 0:t.texts}),getActiveMatrix=createSelector(getMatrixList,getMatrixIdx,(e,t)=>e[t]?e[t]:[]),getKBMatrixData=createSelector(getMatrixList,e=>e.flatMap(t=>t.flatMap(r=>r.flatMap(s=>get256HSV([s.r,s.g,s.b]))))),getMatrixData$1=createSelector(getMatrixList,e=>e.flatMap(t=>t.flatMap(r=>r.flatMap(s=>[s.r,s.g,s.b])))),getFileContent=createSelector(getFrames,getRows,getCols,getFps,getMatrixData$1,(e,t,r,s,a)=>{const l=Array(mlHeaderSize).fill(0);return[...mlHeader,e,s,t,r].forEach((d,p)=>{l[p]=d}),[...l,...a]}),MIN_KB_ACTUATION=0,MAX_KB_ACTUATION=400,MIN_ACTUATION=0,MAX_ACTUATION=4,ACTUATION_MULTIPLE=(MAX_KB_ACTUATION-MIN_KB_ACTUATION)/(MAX_ACTUATION-MIN_ACTUATION),actuationFromKeyboard=e=>e===void 0?0:shiftTo16Bit(e)/ACTUATION_MULTIPLE,actuationToKeyboard=e=>e===void 0?[0,0]:shiftFrom16Bit(~~(e*ACTUATION_MULTIPLE));class ActuationApi{constructor(t){this.keyboardApi=t}async getTestActuation(){const[,,t,r]=await this.keyboardApi.actuationCommand(173);return actuationFromKeyboard([t,r])}async getSelfCheckResult(){const[,,t]=await this.keyboardApi.actuationCommand(161);return!!t}async selfCheck(){await this.keyboardApi.actuationCommand(162)}async getAPEnabled(){const[,,t]=await this.keyboardApi.actuationCommand(163);return!!t}async setAPEnabled(t){await this.keyboardApi.actuationCommand(164,[Number(t)])}async setRTEnabled(t){await this.keyboardApi.actuationCommand(168,[Number(t)])}async getAPDefault(){const[,,t,r,s,a,l,c]=await this.keyboardApi.actuationCommand(172),d=actuationFromKeyboard([t,r]),p=actuationFromKeyboard([s,a]),f=actuationFromKeyboard([l,c]);return{ap:d,dzt:p,dzb:f}}async getAPKeySize(){const[,,t]=await this.keyboardApi.actuationCommand(169);return t}async getAPData(t){const r=await this.getAPKeySize(),s=Math.floor(28/r),a=[];for(let p=0;p<t;p+=s)a.push(this.keyboardApi.actuationCommand(170,[p,Math.min(t-p,s)]));const c=(await Promise.all(a)).flatMap(p=>p.slice(4,4+s*r)),d=[];for(let p=0;p<t;p++){const f=c[p*r],m=c[p*r+1],y=c[p*r+2],K=c[p*r+3],x=c[p*r+4],v=c[p*r+5],M=f!==void 0&&m!==void 0?actuationFromKeyboard([f,m]):0,b=y!==void 0&&K!==void 0?actuationFromKeyboard([y,K]):0,R=x!==void 0&&v!==void 0?actuationFromKeyboard([x,v]):0;d[p]={ap:M,dzt:b,dzb:R}}return d}async setAPValue(t,r,s){await this.keyboardApi.actuationCommand(171,[t,r,...actuationToKeyboard(s.ap),...actuationToKeyboard(s.dzt),...actuationToKeyboard(s.dzb)])}async getRTDefault(){const[,,t,r,s,a,l,c]=await this.keyboardApi.actuationCommand(196),d=actuationFromKeyboard([s,a]),p=actuationFromKeyboard([l,c]);return{enabled:!!t,crtEnabled:!!r,rt1:d,rt2:p}}async getRTKeySize(){const[,,t]=await this.keyboardApi.actuationCommand(193);return t}async getRTData(t){const r=await this.getRTKeySize(),s=Math.floor(28/r),a=[];for(let p=0;p<t;p+=s)a.push(this.keyboardApi.actuationCommand(194,[p,Math.min(t-p,s)]));const c=(await Promise.all(a)).flatMap(p=>p.slice(4,4+s*r)),d=[];for(let p=0;p<t;p++){const f=!!c[p*r],m=!!c[p*r+1],y=c[p*r+2],K=c[p*r+3],x=c[p*r+4],v=c[p*r+5],M=y!==void 0&&K!==void 0?actuationFromKeyboard([y,K]):0,b=x!==void 0&&v!==void 0?actuationFromKeyboard([x,v]):0;d[p]={enabled:f,crtEnabled:m,rt1:M,rt2:b}}return d}async setRTValue(t,r,s){await this.keyboardApi.actuationCommand(195,[t,r,Number(s.enabled),Number(s.crtEnabled),...actuationToKeyboard(s.rt1),...actuationToKeyboard(s.rt2)])}async getDKSActuation(){const[,,t,r,s,a,l,c,d,p]=await this.keyboardApi.actuationCommand(208);return[actuationFromKeyboard([t,r]),actuationFromKeyboard([s,a]),actuationFromKeyboard([l,c]),actuationFromKeyboard([d,p])]}async getDKSCount(){const[,,t,r]=await this.keyboardApi.actuationCommand(209);return shiftTo16Bit([t,r])}async getDKSValues(){const t=await this.getDKSCount();if(t===0)return[];const r=[];for(let a=0;a<t;a++)r.push(this.keyboardApi.actuationCommand(210,shiftFrom16Bit(a)));return(await Promise.all(r)).map(a=>{const[,,,,l,c,d,p,f,m,y,K,x,v,M,...b]=a,R=[];for(let I=0;I<4;I++){const[k,F,V]=b.slice(I*3,I*3+3);R.push({key:shiftTo16Bit([k,F]),points:[V>>6&3,V>>4&3,V>>2&3,V&3]})}const O={actuation:[actuationFromKeyboard([p,f]),actuationFromKeyboard([m,y]),actuationFromKeyboard([K,x]),actuationFromKeyboard([v,M])],actions:R};return console.debug(JSON.stringify({layer:l,row:c,col:d,dks:O})),{layer:l,row:c,col:d,dks:O}})}async setDksValue(t,r,s,a){if(a===null){await this.keyboardApi.actuationCommand(212,[t,r,s]);return}const l=a.actions.flatMap(d=>[...shiftFrom16Bit(d.key),d.points.map((p,f)=>p<<(3-f)*2).reduce((p,f)=>f|=p,0)]);console.debug(JSON.stringify({layer:t,row:r,col:s,actuation:a.actuation,keyActionBytes:l}));const c=[t,r,s,...actuationToKeyboard(a.actuation[0]),...actuationToKeyboard(a.actuation[1]),...actuationToKeyboard(a.actuation[2]),...actuationToKeyboard(a.actuation[3]),...l];await this.keyboardApi.actuationCommand(211,c)}async timeout(t){return this.keyboardApi.timeout(t)}}const getActuationApi=e=>new ActuationApi(e),defaultDKSActuation=.7,defaultDKS2ndActuation=3.5,initialState$3={enableAP:!1,apDefault:{ap:0,dzt:0,dzb:0},rtDefault:{enabled:!1,crtEnabled:!1,rt1:0,rt2:0},actuationMap:{},actuationMenu:"AP",selfChecked:!1,selfCheckStartTimeout:0,dksActionIndex:null,dksmap:{},dksActuations:[defaultDKSActuation,defaultDKS2ndActuation,defaultDKS2ndActuation,defaultDKSActuation]},actuationSlice=createSlice({name:"actuation",initialState:initialState$3,reducers:{setAPDefault:(e,t)=>{e.apDefault=t.payload},setRTDefault:(e,t)=>{e.rtDefault=t.payload},setActuation:(e,t)=>{const{devicePath:r,keymapIdxes:s,actuation:a}=t.payload;e.actuationMap[r]=e.actuationMap[r]||[],s.map(l=>{e.actuationMap[r][l]=e.actuationMap[r][l]||{},e.actuationMap[r][l]={...e.actuationMap[r][l],...a}})},resetActuation:(e,t)=>{e.actuationMap[t.payload]=[]},updateMenu:(e,t)=>{e.actuationMenu=t.payload},setEnableAP:(e,t)=>{e.enableAP=t.payload},updateSelfChecked:(e,t)=>{e.selfChecked=t.payload},updateSelfCheckTimeout:(e,t)=>{e.selfCheckStartTimeout=t.payload},updateDksAction:(e,t)=>{e.dksActionIndex=t.payload},setDksData:(e,t)=>{const{keymapIndex:r,value:s,devicePath:a,selectedLayerIndex:l}=t.payload;e.dksmap[a]=e.dksmap[a]||[],e.dksmap[a][l]=e.dksmap[a][l]||[],e.dksmap[a][l][r]=s},resetDksData:(e,t)=>{e.dksmap[t.payload]=[]},deleteDksBaseLayerData:(e,t)=>{var a;const{path:r,keymapIndexes:s}=t.payload;(a=e.dksmap[r])!=null&&a[0]&&s.forEach(l=>{e.dksmap[r][0][l]=null})},setDKSActuations:(e,t)=>{e.dksActuations=t.payload}},extraReducers(e){e.addCase(selectDevice,t=>{t.selfChecked=!1})}}),{setActuation,setAPDefault,setRTDefault,updateMenu,setEnableAP,updateSelfChecked,updateSelfCheckTimeout,updateDksAction,deleteDksBaseLayerData,setDksData,setDKSActuations,resetActuation,resetDksData}=actuationSlice.actions,actuationReducer=actuationSlice.reducer;lodashExports.debounce((e,t,r,s,a,l,c)=>{const d=[],p=[];for(const f of r){const{row:m,col:y}=l[f],K=m*c.cols+y;d.push(K),p.push(t.setAPValue(m,y,s))}Promise.all(p),e(setActuation({devicePath:a,keymapIdxes:d,actuation:{apData:s}}))},100);lodashExports.debounce((e,t,r,s,a,l,c)=>{const d=[],p=[];for(const f of r){const{row:m,col:y}=l[f],K=m*c.cols+y;d.push(K),p.push(t.setRTValue(m,y,s))}Promise.all(p),e(setActuation({devicePath:a,keymapIdxes:d,actuation:{rtData:s}}))},100);const updateEnableAP=e=>async(t,r)=>{const s=r(),a=getSelectedKeyboardAPI(s);if(!a)return;await getActuationApi(a).setAPEnabled(e),t(setEnableAP(e))},saveConfigToDevice=e=>async(t,r)=>{const s=r(),a=getSelectedKeyboardAPI(s),l=getSelectedDevicePath(s),c=getSelectedDefinition(s),d=getNumberOfLayers(s),p=getAPDefault(s),f=getRTDefault(s);if(!c||!a||!l)return;const m=getActuationApi(a);t(updateEnableAP(!!e.apEnabled));const{matrix:{cols:y,rows:K}}=c,x=y*K,v=[],M=[],b=[],R=[],O=[],I=[];e.ap&&e.ap.map(([k,F,V,$])=>{const z={ap:F,dzt:V,dzb:$};v[k]=m.setAPValue(~~(k/y),k%y,z),R.push({devicePath:l,keymapIdxes:[k],actuation:{apData:z}})}),e.rt&&e.rt.map(([k,F,V,$,z])=>{const X={enabled:!!F,crtEnabled:!!V,rt1:$,rt2:z};M[k]=m.setRTValue(~~(k/y),k%y,X),O.push({devicePath:l,keymapIdxes:[k],actuation:{rtData:X}})}),e.dks&&e.dks.map(([k,F,V,$,z,X,...L])=>{const H=[];for(let Q=0;Q<4;Q++){const[q,T,j,te,re]=L.slice(Q*5,(Q+1)*5);H.push({key:q,points:[T,j,te,re]})}const B={actuation:[V,$,z,X],actions:H};b[k*F+F]=m.setDksValue(k,~~(F/y),F%y,B),I.push({devicePath:l,selectedLayerIndex:k,keymapIndex:F,value:B})});for(let k=0;k<d;k++)for(let F=0;F<x;F++)k===0&&(v[F]||(v[F]=m.setAPValue(~~(F/y),F%y,p)),M[F]||(M[F]=m.setRTValue(~~(F/y),F%y,f))),b[k*F+F]=m.setDksValue(k,~~(F/y),F%y,null);await Promise.all([Promise.all(v),Promise.all(M),Promise.all(b)]),t(resetActuation(l)),R.map(k=>t(setActuation(k))),O.map(k=>t(setActuation(k))),t(resetDksData(l)),I.map(k=>t(setDksData(k)))},getActuationMap=e=>e.actuation.actuationMap,getMenu=e=>e.actuation.actuationMenu,getEnableAP=e=>e.actuation.enableAP,getSelfChecked=e=>e.actuation.selfChecked,getAPDefault=e=>e.actuation.apDefault,getRTDefault=e=>e.actuation.rtDefault,getDksmap=e=>e.actuation.dksmap,getDKSActuations=e=>e.actuation.dksActuations,getSelectedPerKeyActuation=createSelector(getActuationMap,getSelectedDevicePath,(e,t)=>{if(t&&e[t])return e[t]}),getSelectedActuationMap=createSelector(getSelectedKeyDefinitions,getSelectedDefinition,getSelectedPerKeyActuation,getSelectedLayerIndex,getEnableAP,getRTDefault,getAPDefault,(e,t,r,s,a,l,c)=>{if(s===0&&t){const{matrix:{cols:d}}=t;return e.map(({col:p,row:f})=>{let m={...r&&r[f*d+p]||{apData:c,rtData:l}};return a||(m.apData=c),m})}}),getSelectedDksmap=createSelector(getSelectedKeyDefinitions,getSelectedDefinition,getSelectedDevicePath,getSelectedLayerIndex,getDksmap,(e,t,r,s,a)=>{var l;if(t&&r&&((l=a[r])!=null&&l[s])){const{matrix:{cols:c}}=t;return e.map(({row:d,col:p})=>a[r][s][d*c+p])}}),getSelectedDksRawMap=createSelector(getDksmap,getSelectedDevicePath,(e,t)=>{if(t&&e[t])return e[t]}),getDefaultDksData=createSelector(getSelectedKey,getSelectedKeymap,getDKSActuations,(e,t,r)=>({actuation:r,actions:Array(4).fill(0).map((a,l)=>({key:0,points:[DKSPoint.Hold,DKSPoint.Hold,DKSPoint.Hold,DKSPoint.Hold]}))}));createSelector(getSelectedKey,getSelectedDksmap,getDefaultDksData,(e,t,r)=>e!==null&&t&&t[e]||r);const getActiveMenu=createSelector(getSelfChecked,getMenu,(e,t)=>e?t:"SELF CHECK");createSelector(getSelectedDksRawMap,e=>{if(!e)return[];const t=[];return e.forEach((r,s)=>{r.forEach((a,l)=>{a!==null&&t.push({layerIdx:s,key:l,data:a})})}),t});const KBRE_FLAGS_SWAP_BIT=1,KBRE_FLAGS_ALPHA=2,KBRE_FLAGS_REFPS=8,initialState$2={selectedTool:"video",toolConfigs:{},state:"waiting",bytesSended:0,bufferSize:0,started:0,lastUpdate:0,sendSpeed:0},screenSlice=createSlice({name:"screen",initialState:initialState$2,reducers:{updateTool:(e,t)=>{e.selectedTool=t.payload},updateState(e,t){e.bytesSended=0,e.state=t.payload},updateBytesSended:(e,t)=>{const r=t.payload-e.bytesSended;e.bytesSended=t.payload;const s=Date.now();e.sendSpeed=~~(r/((s-e.lastUpdate)/1e3)),e.lastUpdate=s},updateStarted:e=>{const t=Date.now();e.started=t,e.lastUpdate=t,e.sendSpeed=0,e.state="saving"},initSendState:(e,t)=>{const{size:r}=t.payload;e.bufferSize=r,e.state="waiting",e.bytesSended=0}},extraReducers(e){e.addCase(selectDevice,t=>{t.state="waiting",t.bytesSended=0})}}),{updateTool,updateBytesSended:updateBytesSended$2,updateStarted:updateStarted$2,updateState:updateState$2,initSendState}=screenSlice.actions,screenReducer=screenSlice.reducer,saveTabFile=(e,t)=>async(r,s)=>{const a=s();if(!getSelectedConnectedDevice(a)||getSavingState$2(a)==="saving")return;const c=getTabFileAPI(a);if(!c)return;const d=lodashExports.throttle(p=>{r(updateBytesSended$2(p))},1e3);lodashExports.isArray(e)||(e=[e]);try{r(updateStarted$2());let p=0;for(let f=0;f<e.length;f++){const m=e[f];await c.setTabFile(Array.from(m),y=>{d(p+y)},()=>getSavingState$2(s())==="canceled"),p+=m.length}getSavingState$2(s())!=="canceled"&&r(updateState$2("completed"))}catch(p){console.log(p),t(!1),r(updateState$2("failed"))}finally{d.cancel()}},getSelectedTool=e=>e.screen.selectedTool,getBytesSended$2=e=>e.screen.bytesSended,getBufferSize$2=e=>e.screen.bufferSize,getSendSpeed$2=e=>e.screen.sendSpeed,getSavingState$2=e=>e.screen.state,getDeviceConfig=createSelector(getSelectedTabkbConfig,e=>{if(!(!e||!e.screen))return e.screen}),getExportOptions=createSelector(getDeviceConfig,getSelectedTool,(e,t)=>{if(e&&e.fileTypes){const r=e.fileTypes;switch(t){case"image":return r.filter(s=>s.type==="image");case"video":return r.filter(s=>s.type==="video");case"slider":return r.filter(s=>s.type==="slider");case"theme":return r.filter(s=>s.type==="theme")}}}),getDefaultArea=createSelector(getSelectedTool,getExportOptions,(e,t)=>{if(t!==void 0)return t[0]}),getScreenMenus=createSelector(getDeviceConfig,e=>e&&e.menus?e.menus:[]),getKbresFlags=createSelector(getDeviceConfig,e=>{if(!e)return 0;let t=0;return e.swapBit&&(t|=KBRE_FLAGS_SWAP_BIT),t}),getMaxOutputSize=createSelector(getDeviceConfig,e=>e?e.maxOutputSize??-1:-1),getMaxFgFileCount=createSelector(getDeviceConfig,e=>e?e.maxFgFileCount??0:0),initialState$1={bytesSended:0,bufferSize:0,started:0,lastUpdate:0,sendSpeed:0,state:"waiting"},firmwareSlice=createSlice({name:"firmware",initialState:initialState$1,reducers:{updateState(e,t){e.bytesSended=0,e.state=t.payload},updateBytesSended:(e,t)=>{const r=t.payload-e.bytesSended;e.bytesSended=t.payload;const s=Date.now();e.sendSpeed=~~(r/((s-e.lastUpdate)/1e3)),e.lastUpdate=s},updateStarted:(e,t)=>{const{size:r}=t.payload,s=Date.now();e.started=s,e.lastUpdate=s,e.sendSpeed=0,e.state="saving",e.bytesSended=0,e.bufferSize=r},setFirmwareOptions:(e,t)=>{e.options=t.payload}},extraReducers(e){e.addCase(selectDevice,t=>{t.options||(t.state="waiting",t.bytesSended=0)})}}),{updateState:updateState$1,updateBytesSended:updateBytesSended$1,updateStarted:updateStarted$1,setFirmwareOptions}=firmwareSlice.actions,firmwareReducer=firmwareSlice.reducer,saveTabFirmware$1=e=>async(t,r)=>{const s=r();if(getSavingState$1(s)==="saving"||!getSelectedConnectedDevice(s))return;const l=getTabFileAPI(s);if(!l)return;const c=lodashExports.throttle(p=>{t(updateBytesSended$1(p))},1e3),d=Array.from(e);try{t(updateStarted$1({size:e.length}));const[p,f]=await l.setTabFirmwareInfo(e.length,d.slice(0,32));if(!p){t(updateState$1("failed"));return}await l.setTabFirmwareBuffer(d,m=>{c(m)},()=>getSavingState$1(r())==="canceled",!!f),getSavingState$1(r())!=="canceled"&&t(updateState$1("completed"))}catch(p){console.log(p),t(updateState$1("failed"))}finally{c.cancel()}},getBytesSended$1=e=>e.firmware.bytesSended,getBufferSize$1=e=>e.firmware.bufferSize,getSendSpeed$1=e=>e.firmware.sendSpeed,getSavingState$1=e=>e.firmware.state,getFirmwareOptions=e=>e.firmware.options,parseVersionStr=e=>{const t=e.split(".");return t.length!==3?0:parseInt(t[0])<<8|parseInt(t[1])<<4|parseInt(t[2])},getSelectedDeviceFirmwareVersion=createSelector(getSelectedConnectedDevice,e=>e&&e.firmware?`${e.firmware>>8&255}.${e.firmware>>4&15}.${e.firmware&15}`:""),getCfgFirmwareVersion=createSelector(getSelectedTabkbConfig,e=>!e||!e.firmware||!e.firmware.version?"0.0.0":e.firmware.version),getCfgFirmwareVerNum=createSelector(getCfgFirmwareVersion,e=>parseVersionStr(e)),getCfgFirmwareFile=createSelector(getSelectedTabkbConfig,e=>e&&e.firmware&&e.firmware.file?e.firmware.file:[]);createSelector(getSelectedTabkbConfig,e=>e&&e.firmware&&e.firmware.changeLog?e.firmware.changeLog:{});const getCfgFirmwareBoot=createSelector(getSelectedTabkbConfig,e=>e&&e.firmware&&e.firmware.masterBoot?e.firmware.masterBoot.map(t=>parseInt(t,16)):void 0),getFirmwareNeedUpdate=createSelector(getSelectedConnectedDevice,getCfgFirmwareVerNum,getCfgFirmwareFile,(e,t,r)=>!e||!r||!t||!e.firmware?!1:e.firmware<t),devices=[{path:"54ab4254",vendorId:"0x54ab",productId:"0x4254"},{path:"98x_receiver_boot",vendorId:"0xe560",productId:"0xcc85"},{path:"106_receiver_boot",vendorId:"0x534b",productId:"0xcc85"},{path:"qk65_reciever_boot",vendorId:"0x514b",productId:"0x4d08"},{path:"evo104_reciever_boot",vendorId:"0xE560",productId:"0xCC85"}],recievers=devices?devices.map(e=>({...e,vendorId:parseInt(e.vendorId,16),productId:parseInt(e.productId,16)})):[],initialState={bytesSended:0,bufferSize:0,started:0,lastUpdate:0,sendSpeed:0,state:"waiting"},bootSlice=createSlice({name:"boot",initialState,reducers:{updateState(e,t){e.bytesSended=0,e.state=t.payload},updateBytesSended:(e,t)=>{const r=t.payload-e.bytesSended;e.bytesSended=t.payload;const s=Date.now();e.sendSpeed=~~(r/((s-e.lastUpdate)/1e3)),e.lastUpdate=s},updateStarted:(e,t)=>{const{size:r}=t.payload,s=Date.now();e.started=s,e.lastUpdate=s,e.sendSpeed=0,e.state="saving",e.bytesSended=0,e.bufferSize=r}},extraReducers(e){e.addCase(selectDevice,t=>{})}}),{updateState,updateBytesSended,updateStarted}=bootSlice.actions,bootReducer=bootSlice.reducer,saveTabFirmware=(e,t,r)=>async(s,a)=>{const l=a();if(getSavingState(l)==="saving")return;s(updateState("waiting"));const c=r?[{path:`${r[0],r[1]}`,vendorId:r[0],productId:r[1]}]:recievers,d=new TabKeyboardAPI(void 0,c);if(!d)return;const p=lodashExports.throttle(m=>{s(updateBytesSended(m))},1e3),f=Array.from(e);try{s(updateStarted({size:e.length})),t&&await d.firmwareQuery();const[m,y]=await d.setTabFirmwareInfo(e.length,f.slice(0,32));if(!m){s(updateState("failed"));return}await d.setTabFirmwareBuffer(f,K=>{p(K)},()=>getSavingState(a())==="canceled",!!y),getSavingState(a())!=="canceled"&&s(updateState("completed"))}catch(m){console.log(m),s(updateState("failed"))}finally{p.cancel()}},getBytesSended=e=>e.boot.bytesSended,getBufferSize=e=>e.boot.bufferSize,getSendSpeed=e=>e.boot.sendSpeed,getSavingState=e=>e.boot.state,formatNumberAsHex=(e,t)=>`0x${e.toString(16).padStart(t,"0").toUpperCase()}`,errorsListenerMiddleware=createListenerMiddleware(),captureError=(e,t)=>{captureException(new Error(e),{tags:{productName:t.productName,vendorId:formatNumberAsHex(t.vendorId,4),protocol:t.protocol},extra:{deviceInfo:t}})};errorsListenerMiddleware.startListening({actionCreator:logAppError,effect:async({payload:{message:e,deviceInfo:t}},r)=>{captureError(e,t)}});errorsListenerMiddleware.startListening({actionCreator:logKeyboardAPIError,effect:async({payload:e},t)=>{captureError(extractMessageFromKeyboardAPIError(e),e.deviceInfo)}});const sentryEnhancer=createReduxEnhancer({}),store=configureStore({reducer:{settings:settingsReducer,macros:macrosReducer,devices:devicesReducer,keymap:keymapReducer,definitions:definitionsReducer,lighting:lightingReducer,menus:menusReducer,design:designReducer,errors:errorsReducer,matrixlighting:matrixlightingReducer,actuation:actuationReducer,screen:screenReducer,tabkbconfig:tabkbconfigReducer,firmware:firmwareReducer,boot:bootReducer},enhancers:[sentryEnhancer],middleware:e=>e().prepend(errorsListenerMiddleware.middleware)}),imgSrc="/assets/chippy_600-902171c5.png",defaultChippy={width:300,height:300,src:imgSrc},LoaderContainer=styled.div`
|
|
472
|
+
width: 100%;
|
|
473
|
+
display: flex;
|
|
474
|
+
justify-content: center;
|
|
475
|
+
align-items: center;
|
|
476
|
+
`,CircleContainer=styled.div`
|
|
477
|
+
border-radius: 50%;
|
|
478
|
+
background-color: var(--bg_icon);
|
|
479
|
+
height: ${e=>e.$containerHeight}px;
|
|
480
|
+
width: ${e=>e.$containerWidth}px;
|
|
481
|
+
position: relative;
|
|
482
|
+
overflow: hidden;
|
|
483
|
+
box-sizing: border-box;
|
|
484
|
+
display: flex;
|
|
485
|
+
align-items: center;
|
|
486
|
+
justify-content: center;
|
|
487
|
+
|
|
488
|
+
animation-duration: 1.5s;
|
|
489
|
+
animation-name: roll;
|
|
490
|
+
animation-iteration-count: infinite;
|
|
491
|
+
animation-direction: alternate;
|
|
492
|
+
animation-timing-function: ease-in-out;
|
|
493
|
+
|
|
494
|
+
&::after {
|
|
495
|
+
height: ${e=>e.$containerHeight}px;
|
|
496
|
+
width: ${e=>e.$containerWidth}px;
|
|
497
|
+
position: absolute;
|
|
498
|
+
content: '';
|
|
499
|
+
background-color: ${e=>e.$progressColor};
|
|
500
|
+
top: ${e=>e.$containerHeight+1}px;
|
|
501
|
+
left: 0;
|
|
502
|
+
right: 0;
|
|
503
|
+
transition: transform 0.4s ease-out;
|
|
504
|
+
transform: translate3d(
|
|
505
|
+
0,
|
|
506
|
+
${e=>-(e.$progress||0)*e.$containerHeight}px,
|
|
507
|
+
0
|
|
508
|
+
);
|
|
509
|
+
}
|
|
510
|
+
`,SvgComponent=e=>{const{theme:t}=e,r=getDarkenedColor(t.accent.c,.8),s={"upper-body":t.mod.t,"lower-body":t.mod.c,accent:r,bowtie:r,pins:r,feet:"#000"};return jsxs("svg",{id:"Layer_1",xmlns:"http://www.w3.org/2000/svg",x:0,y:0,viewBox:"0 0 600 600",style:{enableBackground:"new 0 0 600 600"},xmlSpace:"preserve",...e,children:[jsx("style",{children:`.st3{fill:#fdfefe}.st4{fill:${s.bowtie}}.st5{fill-rule:evenodd;clip-rule:evenodd;fill:${s.accent}}.st7,.st9{fill-rule:evenodd;clip-rule:evenodd}.st10,.st9{fill:#fff}`}),jsxs("g",{id:"Layer_2_00000088814685506851870240000015950599998114990989_",children:[jsx("g",{id:"Feet",children:jsx("path",{d:"M169.7 432.1c28.3 0 51.5 23.3 51.5 51.5s-23.3 51.5-51.5 51.5-51.5-23.3-51.5-51.5 23.2-51.5 51.5-51.5zM425.8 432.1c28.3 0 51.5 23.3 51.5 51.5s-23.3 51.5-51.5 51.5-51.5-23.3-51.5-51.5 23.2-51.5 51.5-51.5z"})}),jsxs("g",{id:"Body",children:[jsx("path",{d:"M26.7 66.8h546.2c9.8 0 17.7 7.9 17.7 17.7v273.3H9V84.6c0-9.8 7.9-17.8 17.7-17.8z",style:{fill:s["upper-body"]}}),jsx("path",{d:"M9 357.4h581.6v113.7c0 8.4-6.9 15.3-15.3 15.3h-551c-8.4 0-15.3-6.9-15.3-15.3V357.4z",style:{fill:s["lower-body"]}})]}),jsx("path",{d:"M229.4 262.8s33.5 19.4 66.3 19.4c33.5 0 66.3-19.4 66.3-19.4",style:{fill:"none",stroke:"#000",strokeWidth:6.8265,strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:2.0408},id:"Smile"}),jsxs("g",{id:"Eyes",children:[jsx("path",{d:"M417.1 132.4c26.5 0 48 26.4 48 59.1s-21.4 59.1-48 59.1-48-26.4-48-59.1 21.5-59.1 48-59.1zM175.3 132.4c26.5 0 48 26.4 48 59.1s-21.4 59.1-48 59.1-48-26.4-48-59.1 21.5-59.1 48-59.1z"}),jsx("path",{className:"st3",d:"M422.7 210.7c4.2 0 7.7 3.5 7.7 7.7s-3.5 7.7-7.7 7.7-7.7-3.5-7.7-7.7 3.5-7.7 7.7-7.7zM418.2 159.7c9.5 0 17.3 7.8 17.3 17.3s-7.8 17.3-17.3 17.3-17.3-7.8-17.3-17.3c-.1-9.5 7.7-17.3 17.3-17.3zM179.9 210.7c4.2 0 7.7 3.5 7.7 7.7s-3.5 7.7-7.7 7.7-7.7-3.5-7.7-7.7 3.5-7.7 7.7-7.7zM175.3 159.7c9.5 0 17.3 7.8 17.3 17.3s-7.8 17.3-17.3 17.3S158 186.5 158 177c-.1-9.5 7.8-17.3 17.3-17.3z"})]}),jsx("g",{id:"Pins",children:jsx("path",{className:"st4",d:"M12.6 276h17.5c5.8 0 10.5 6.9 10.5 15.3V324c0 8.4-4.7 15.3-10.5 15.3H12.6C6.7 339.3 2 332.4 2 324v-32.7c0-8.4 4.7-15.3 10.6-15.3zM12.6 190.3h17.5c5.8 0 10.5 6.9 10.5 15.3v32.7c0 8.4-4.7 15.3-10.5 15.3H12.6c-5.8 0-10.5-6.9-10.5-15.3v-32.7c-.1-8.4 4.6-15.3 10.5-15.3zM12.6 102.6h17.5c5.8 0 10.5 6.9 10.5 15.3v32.7c0 8.4-4.7 15.3-10.5 15.3H12.6C6.7 165.8 2 159 2 150.5v-32.7c0-8.4 4.7-15.2 10.6-15.2zM569.6 276h17.5c5.8 0 10.5 6.9 10.5 15.3V324c0 8.4-4.7 15.3-10.5 15.3h-17.5c-5.8 0-10.5-6.9-10.5-15.3v-32.7c0-8.4 4.7-15.3 10.5-15.3zM569.6 190.3h17.5c5.8 0 10.5 6.9 10.5 15.3v32.7c0 8.4-4.7 15.3-10.5 15.3h-17.5c-5.8 0-10.5-6.9-10.5-15.3v-32.7c0-8.4 4.7-15.3 10.5-15.3zM569.6 102.6h17.5c5.8 0 10.5 6.9 10.5 15.3v32.7c0 8.4-4.7 15.3-10.5 15.3h-17.5c-5.8 0-10.5-6.9-10.5-15.3v-32.7c0-8.5 4.7-15.3 10.5-15.3z"})}),jsx("g",{id:"Cheeks",children:jsxs("g",{id:"Layer_8",children:[jsx("ellipse",{transform:"rotate(120 89.724 277.697)",className:"st5",cx:68.5,cy:243.9,rx:12.9,ry:29.3}),jsx("ellipse",{transform:"rotate(150 447.814 278.705)",className:"st5",cx:430.5,cy:271.6,rx:29.3,ry:12.9})]})}),jsx("g",{id:"Bowties",children:jsx("path",{className:"st4",d:"m293.7 356.6 73.5-33.7v67.3l-73.5-33.6zM293.7 356.6l-73.5 33.7V323l73.5 33.6z"})})]}),jsxs("g",{id:"Layer2",style:{opacity:.15},children:[jsx("path",{className:"st7",d:"M6.7 105.2c2.5-2.6 5.8-2.5 5.8-2.5v63.2s-3.9.4-7.1-4c-.7-.7-3.4-5.1-3.4-11.3v-32.4c0-7 2.7-11 4.7-13z"}),jsx("path",{d:"M112.4 486.3H24c-13 0-14.8-14.5-14.8-14.5S9 332.7 9 353.4c0 20.8 79.5 132.9 103.4 132.9z",style:{fillRule:"evenodd",clipRule:"evenodd",fill:"#180000"}}),jsx("path",{className:"st9",d:"M35.9 105.1c-2.5-2.6-5.8-2.5-5.8-2.5v63.2s3.9.4 7.1-4c.7-.7 3.4-5.1 3.4-11.3v-32.4c0-7-2.8-11-4.7-13z"}),jsx("path",{className:"st7",d:"M6.7 192.9c2.5-2.6 5.8-2.5 5.8-2.5v63.2s-3.9.4-7.1-4c-.7-.7-3.4-5.1-3.4-11.3v-32.4c0-7 2.7-11 4.7-13z"}),jsx("path",{className:"st9",d:"M35.9 192.8c-2.5-2.6-5.8-2.5-5.8-2.5v63.2s3.9.4 7.1-4c.7-.7 3.4-5.1 3.4-11.3v-32.4c0-7-2.8-11-4.7-13z"}),jsx("path",{className:"st7",d:"M6.7 278.6c2.5-2.6 5.8-2.5 5.8-2.5v63.2s-3.9.4-7.1-4c-.7-.7-3.4-5.1-3.4-11.3v-32.4c0-6.9 2.7-10.9 4.7-13z"}),jsx("path",{className:"st9",d:"M35.9 278.5c-2.5-2.6-5.8-2.5-5.8-2.5v63.2s3.9.4 7.1-4c.7-.7 3.4-5.1 3.4-11.3v-32.4c0-7-2.8-11-4.7-13z"}),jsx("path",{className:"st7",d:"M563.7 105.2c2.5-2.6 5.8-2.5 5.8-2.5v63.2s-3.9.4-7.1-4c-.7-.7-3.4-5.1-3.4-11.3v-32.4c0-7 2.7-11 4.7-13z"}),jsx("path",{className:"st9",d:"M592.9 105.1c-2.5-2.6-5.8-2.5-5.8-2.5v63.2s3.9.4 7.1-4c.7-.7 3.4-5.1 3.4-11.3v-32.4c0-7-2.7-11-4.7-13z"}),jsx("path",{className:"st7",d:"M563.7 192.9c2.5-2.6 5.8-2.5 5.8-2.5v63.2s-3.9.4-7.1-4c-.7-.7-3.4-5.1-3.4-11.3v-32.4c0-7 2.7-11 4.7-13z"}),jsx("path",{className:"st9",d:"M592.9 192.8c-2.5-2.6-5.8-2.5-5.8-2.5v63.2s3.9.4 7.1-4c.7-.7 3.4-5.1 3.4-11.3v-32.4c0-7-2.7-11-4.7-13z"}),jsx("path",{className:"st7",d:"M563.7 278.6c2.5-2.6 5.8-2.5 5.8-2.5v63.2s-3.9.4-7.1-4c-.7-.7-3.4-5.1-3.4-11.3v-32.4c0-6.9 2.7-10.9 4.7-13z"}),jsx("path",{className:"st9",d:"M592.9 278.5c-2.5-2.6-5.8-2.5-5.8-2.5v63.2s3.9.4 7.1-4c.7-.7 3.4-5.1 3.4-11.3v-32.4c0-7-2.7-11-4.7-13z"}),jsx("path",{className:"st10",d:"M220.2 323.1v34.2l73.4-.6zM293.7 356.6l73.5-33.6v34.3"})]})]})};function ChippyLoader(e){const t=e.width||defaultChippy.width,r=e.width||defaultChippy.height,s=t*.25,[a,l]=[r+s*2,t+s*2],c=useAppSelector(getSelectedTheme);return jsx(LoaderContainer,{children:jsx(CircleContainer,{$progress:e.progress,$progressColor:getDarkenedColor(c.accent.c,.9),$containerHeight:a,$containerWidth:l,children:jsx("div",{style:{zIndex:1,width:t},children:jsx(SvgComponent,{theme:e.theme})})})})}const LoadingText=styled.div`
|
|
511
|
+
font-size: 30px;
|
|
512
|
+
color: var(--color_label-highlighted);
|
|
513
|
+
`;function LoadingText$1(e){const{t}=useTranslation();return jsx(LoadingText,{"data-tid":"loading-message",children:t(e.isSearching?"Searching for devices...":"Loading...")})}const Button=styled.div`
|
|
514
|
+
display: flex;
|
|
515
|
+
transition: transform 0.2s ease-out;
|
|
516
|
+
user-select: none;
|
|
517
|
+
color: #717070;
|
|
518
|
+
border: 1px #717070 solid;
|
|
519
|
+
width: 45px;
|
|
520
|
+
height: 45px;
|
|
521
|
+
padding: 2px;
|
|
522
|
+
margin: 2px;
|
|
523
|
+
text-overflow: ellipsis;
|
|
524
|
+
overflow: hidden;
|
|
525
|
+
cursor: pointer;
|
|
526
|
+
font-size: 12px;
|
|
527
|
+
text-align: center;
|
|
528
|
+
border-radius: 4px;
|
|
529
|
+
justify-content: center;
|
|
530
|
+
align-items: center;
|
|
531
|
+
white-space: pre-wrap;
|
|
532
|
+
box-shadow: #8c8c8c 0 1px 0 0;
|
|
533
|
+
&:hover {
|
|
534
|
+
transform: translate3d(0, -2px, 0);
|
|
535
|
+
}
|
|
536
|
+
`,title$6="Keymap",component$3=e=>jsx(FontAwesomeIcon,{icon:faBook}),Message$1=styled.span`
|
|
537
|
+
font-size: 18px;
|
|
538
|
+
margin: 8px;
|
|
539
|
+
text-align: center;
|
|
540
|
+
`,ErrorMessage=styled(Message$1)`
|
|
541
|
+
color: #d15e5e;
|
|
542
|
+
`,SuccessMessage=styled(Message$1)`
|
|
543
|
+
color: #9ab46a;
|
|
544
|
+
`,Encoder=styled(CenterPane)`
|
|
545
|
+
height: 100%;
|
|
546
|
+
background: var(--color_dark_grey);
|
|
547
|
+
`,Container$k=styled.div`
|
|
548
|
+
display: flex;
|
|
549
|
+
align-items: center;
|
|
550
|
+
flex-direction: column;
|
|
551
|
+
padding: 0 12px;
|
|
552
|
+
`,renderEncoderError=()=>jsx(ErrorMessage,{children:"Your current firmware does not support rotary encoders. Install the latest firmware for your device."}),Pane$a=()=>{const[e,t]=reactExports.useState(),[r,s]=reactExports.useState(),a=useAppSelector(getSelectedKey),l=useAppDispatch(),c=useAppSelector(getSelectedKeyDefinitions),d=useAppSelector(b=>getSelectedKeymap(b)||[]),p=useAppSelector(getSelectedLayerIndex),f=useAppSelector(getSelectedConnectedDevice),m=useAppSelector(getSelectedKeyboardAPI),y=d[a??-1],K=c[a??-1],x=!!K&&K.col!==-1&&K.row!==-1,v=(b,R)=>{if(m&&a!==null&&K&&K.ei!==void 0){const O=+K.ei;switch(b){case"ccw":{m.setEncoderValue(p,O,!1,R),s(R);break}case"cw":{m.setEncoderValue(p,O,!0,R),t(R);break}case"click":{l(updateKey(a,R));break}}}},M=async(b,R,O)=>{const I=await O.getEncoderValue(b,R,!0),k=await O.getEncoderValue(b,R,!1);t(I),s(k)};return reactExports.useEffect(()=>{if(f&&f.protocol>=10&&K!==void 0&&K.ei!==void 0&&m){const b=+K.ei;M(p,b,m)}},[K,f,p]),K===void 0||f&&f.protocol<10||r===void 0||e===void 0?jsx(SpanOverflowCell,{children:renderEncoderError()}):jsx(SpanOverflowCell,{children:jsx(Encoder,{children:jsxs(Container$k,{children:[jsxs(ControlRow,{children:[jsx(Label$1,{children:"Rotate Counterclockwise"}),jsx(Detail,{children:jsx(PelpiKeycodeInput,{value:r,meta:{},setValue:b=>v("ccw",b)})})]}),jsxs(ControlRow,{children:[jsx(Label$1,{children:"Rotate Clockwise"}),jsx(Detail,{children:jsx(PelpiKeycodeInput,{value:e,meta:{},setValue:b=>v("cw",b)})})]}),x&&jsxs(ControlRow,{children:[jsx(Label$1,{children:"Press Encoder"}),jsx(Detail,{children:jsx(PelpiKeycodeInput,{value:y,meta:{},setValue:b=>v("click",b)})})]})]})})})},KeycodeList=styled.div`
|
|
553
|
+
display: grid;
|
|
554
|
+
grid-template-columns: repeat(auto-fill, 64px);
|
|
555
|
+
grid-auto-rows: 64px;
|
|
556
|
+
justify-content: center;
|
|
557
|
+
grid-gap: 10px;
|
|
558
|
+
`,MenuContainer$5=styled.div`
|
|
559
|
+
padding: 15px 20px 20px 10px;
|
|
560
|
+
`,Keycode=styled(Button)`
|
|
561
|
+
width: 50px;
|
|
562
|
+
height: 50px;
|
|
563
|
+
line-height: 18px;
|
|
564
|
+
border-radius: 64px;
|
|
565
|
+
font-size: 14px;
|
|
566
|
+
border: 4px solid var(--border_color_icon);
|
|
567
|
+
background: var(--bg_control);
|
|
568
|
+
color: var(--color_label-highlighted);
|
|
569
|
+
margin: 0;
|
|
570
|
+
box-shadow: none;
|
|
571
|
+
position: relative;
|
|
572
|
+
border-radius: 10px;
|
|
573
|
+
&:hover {
|
|
574
|
+
border-color: var(--color_accent);
|
|
575
|
+
transform: translate3d(0, -2px, 0);
|
|
576
|
+
}
|
|
577
|
+
${e=>e.disabled&&"cursor:not-allowed;filter:opacity(50%);"}
|
|
578
|
+
`,KeycodeContent=styled.div`
|
|
579
|
+
text-overflow: ellipsis;
|
|
580
|
+
overflow: hidden;
|
|
581
|
+
text-transform: capitalize;
|
|
582
|
+
`,CustomKeycode=styled(Button)`
|
|
583
|
+
width: 50px;
|
|
584
|
+
height: 50px;
|
|
585
|
+
line-height: 18px;
|
|
586
|
+
border-radius: 10px;
|
|
587
|
+
font-size: 14px;
|
|
588
|
+
border: 4px solid var(--border_color_icon);
|
|
589
|
+
background: var(--color_accent);
|
|
590
|
+
border-color: var(--color_inside_accent);
|
|
591
|
+
color: var(--color_inside_accent);
|
|
592
|
+
margin: 0;
|
|
593
|
+
`,KeycodeContainer=styled.div`
|
|
594
|
+
padding: 12px;
|
|
595
|
+
padding-bottom: 30px;
|
|
596
|
+
`,KeycodeDesc=styled.div`
|
|
597
|
+
position: fixed;
|
|
598
|
+
bottom: 0;
|
|
599
|
+
background: #d9d9d97a;
|
|
600
|
+
box-sizing: border-box;
|
|
601
|
+
transition: opacity 0.4s ease-out;
|
|
602
|
+
height: 25px;
|
|
603
|
+
width: 100%;
|
|
604
|
+
line-height: 14px;
|
|
605
|
+
padding: 5px;
|
|
606
|
+
font-size: 14px;
|
|
607
|
+
opacity: 1;
|
|
608
|
+
pointer-events: none;
|
|
609
|
+
&:empty {
|
|
610
|
+
opacity: 0;
|
|
611
|
+
}
|
|
612
|
+
`,generateKeycodeCategories=(e,t=16)=>getKeycodes(t).concat(getOtherMenu(e)),maybeFilter=(e,t)=>e?()=>!0:t,Pane$9=()=>{const e=useAppSelector(getSelectedKey),t=useAppDispatch(),r=useAppSelector(getSelectedKeyDefinitions);return reactExports.useEffect(()=>()=>{t(updateSelectedKey(null))},[]),e!==null&&r[e].ei!==void 0?jsx(Pane$a,{}):jsx(KeycodePane,{})},KeycodePane=()=>{var q;const{t:e}=useTranslation(),t=useAppDispatch(),r=useAppSelector(T=>T.macros),s=useAppSelector(getSelectedDefinition),a=useAppSelector(getSelectedConnectedDevice),l=useAppSelector(getSelectedKeymap),c=useAppSelector(getSelectedKey),d=useAppSelector(getDisableFastRemap),p=useAppSelector(getSelectedKeyDefinitions),{basicKeyToByte:f}=useAppSelector(getBasicKeyToByte),m=useAppSelector(getMacroCount),y=useAppSelector(getTapDanceKeycodes),K=reactExports.useMemo(()=>generateKeycodeCategories(f,m),[f,m]);if(!s||!a||!l)return null;const[x,v]=reactExports.useState(K[0].id),[M,b]=reactExports.useState(null),[R,O]=reactExports.useState(!1),I=()=>{if(dist.isVIADefinitionV3(s))return k(s);const{lighting:T,customKeycodes:j}=s,{keycodes:te}=dist.getLightingDefinition(T);return K.filter(maybeFilter(te===dist.KeycodeType.QMK,({id:re})=>re!=="qmk_lighting")).filter(maybeFilter(te===dist.KeycodeType.WT,({id:re})=>re!=="lighting")).filter(maybeFilter(typeof j<"u",({id:re})=>re!=="custom"))},k=T=>{const te=["default",...T.keycodes||[]].flatMap(re=>categoriesForKeycodeModule(re));return(s.customKeycodes||[]).length!==0&&te.push("custom"),K.filter(re=>te.includes(re.id))},F=()=>jsx(ErrorMessage,{children:e("Your current firmware does not support macros. Install the latest firmware for your device.")}),V=()=>{const{t:T}=useTranslation();return jsx(MenuContainer$5,{children:I().map(({id:j,label:te})=>jsx(SubmenuRow,{$selected:j===x,onClick:()=>v(j),children:T(te)},j))})},$=()=>(t(disableGlobalHotKeys()),jsx(KeycodeModal,{defaultValue:c!==null?l[c]:void 0,onExit:()=>{t(enableGlobalHotKeys()),O(!1)},onConfirm:T=>{t(enableGlobalHotKeys()),z(T),O(!1)}})),z=T=>{c!==null&&(t(updateKey(c,T)),t(updateSelectedKey(d||!p?null:getNextKey(c,p))))},X=(T,j)=>{if(T=="text")O(!0);else return keycodeInMaster(T,f)&&z(getByteForCode(T,f))},L=(T,j)=>{const{code:te,title:re,name:de}=T;return jsx(Keycode,{disabled:!keycodeInMaster(te,f)&&te!="text",onClick:()=>X(te),onMouseOver:()=>b(re?`${te}: ${re}`:te),onMouseOut:()=>b(null),children:jsx(KeycodeContent,{children:de})},te)},H=()=>jsx(CustomKeycode,{onClick:()=>c!==null&&X("text"),onMouseOver:()=>b("Enter any QMK Keycode"),onMouseOut:()=>b(null),children:"Any"},"customKeycode"),B=(T,j)=>{const{t:te}=useTranslation(),re=T.map((de,fe)=>L(de));switch(j){case"macro":return r.isFeatureSupported?jsx(KeycodeList,{children:re}):F();case"special":return jsx(KeycodeList,{children:re.concat(H())});case"custom":return!dist.isVIADefinitionV2(s)&&!dist.isVIADefinitionV3(s)||!s.customKeycodes&&y.length==0?null:jsxs(KeycodeList,{children:[s.customKeycodes&&s.customKeycodes.map((de,fe)=>L({...de,title:te(de.title),code:`CUSTOM(${fe})`})),y.map((de,fe)=>L({...de,title:de.title?te(de.title):de.title,code:`TD(${fe})`}))]});default:return jsx(KeycodeList,{children:re})}},Q=(q=K.find(({id:T})=>T===x))==null?void 0:q.keycodes;return jsxs(Fragment,{children:[jsx(SubmenuOverflowCell,{children:V()}),jsxs(OverflowCell,{children:[jsx(KeycodeContainer,{children:B(Q,x)}),jsx(KeycodeDesc,{children:M}),R&&$()]})]})},Icon$8=component$3,Title$a=title$6,Keycode$1=Object.freeze(Object.defineProperty({__proto__:null,Icon:Icon$8,KeycodePane,Pane:Pane$9,Title:Title$a},Symbol.toStringTag,{value:"Module"})),LightingControl=e=>{const t=useAppDispatch(),r=useAppSelector(getSelectedLightingData),s=useAppSelector(getSelectedDefinition),[a,l,c]=e.meta,d=r&&r[a];if(!d||!s)return null;const p=typeof l=="string"?l:l(e);switch(c.type){case"slider":return jsxs(ControlRow,{children:[jsx(Label$1,{children:p}),jsx(Detail,{children:jsx(AccentSlider,{isChecked:!!d[0],onChange:f=>t(updateBacklightValue(a,+f))})})]});case"range":return jsxs(ControlRow,{children:[jsx(Label$1,{children:p}),jsx(Detail,{children:jsx(AccentRange,{max:c.max,min:c.min,defaultValue:d[0],onChange:f=>t(updateBacklightValue(a,f))})})]});case"color":return jsxs(ControlRow,{children:[jsx(Label$1,{children:p}),jsx(Detail,{children:jsx(ArrayColorPicker,{color:d,setColor:(f,m)=>t(updateBacklightValue(a,f,m))})})]});case"select":{const f=c.getOptions(s).map((m,y)=>({value:y,label:m}));return jsxs(ControlRow,{children:[jsx(Label$1,{children:p}),jsx(Detail,{children:jsx(AccentSelect,{onChange:m=>{m&&t(updateBacklightValue(a,+m.value))},options:f,defaultValue:f.find(m=>d[0]===m.value)})})]})}case"row_col":return jsxs(ControlRow,{children:[jsx(Label$1,{children:p}),jsx(Detail,{children:jsx(AccentSlider,{isChecked:d[0]!==255,onChange:f=>{t(updateBacklightValue(a,...f?[254,254]:[255,255]))}})})]})}return null},BacklightControls=[[dist.LightingValue.BACKLIGHT_BRIGHTNESS,"Brightness",{type:"range",min:0,max:255}],[dist.LightingValue.BACKLIGHT_EFFECT,"Effect",{type:"select",getOptions:e=>dist.isVIADefinitionV2(e)&&dist.getLightingDefinition(e.lighting).effects.map(([t])=>t)}],[dist.LightingValue.BACKLIGHT_EFFECT_SPEED,"Effect Speed",{type:"range",min:0,max:3}]],UnderglowControls=[[dist.LightingValue.QMK_RGBLIGHT_BRIGHTNESS,"Underglow Brightness",{type:"range",min:0,max:255}],[dist.LightingValue.QMK_RGBLIGHT_EFFECT,"Underglow Effect",{type:"select",getOptions:e=>dist.isVIADefinitionV2(e)&&dist.getLightingDefinition(e.lighting).underglowEffects.map(([t])=>t)}],[dist.LightingValue.QMK_RGBLIGHT_EFFECT_SPEED,"Underglow Effect Speed",{type:"range",min:0,max:3}]],GeneralPane=()=>{const e=useAppDispatch(),t=useAppSelector(getSelectedLightingData),r=useAppSelector(getSelectedDefinition);if(!t)return null;if(!dist.isVIADefinitionV2(r))throw new Error("This lighting component is only compatible with v2 definitions");const s=dist.getLightingDefinition(r.lighting),{supportedLightingValues:a}=s;if(s.supportedLightingValues.length!==0){const l=s.effects.map(([x,v])=>v),c=s.underglowEffects.map(([x,v])=>v),d=t[dist.LightingValue.BACKLIGHT_EFFECT],p=t[dist.LightingValue.QMK_RGBLIGHT_EFFECT],f=d&&l[d[0]]||0,m=p&&c[p[0]]===1,K=!!t.customColors&&f>2;return jsxs(Fragment,{children:[BacklightControls.filter(x=>a.indexOf(x[0])!==-1).map(x=>jsx(LightingControl,{meta:x})),UnderglowControls.filter(x=>a.indexOf(x[0])!==-1).map(x=>jsx(LightingControl,{meta:x})),new Array(f).fill(1).map((x,v)=>x+v).map(x=>{let v,M;const b=x===1?dist.LightingValue.BACKLIGHT_COLOR_1:dist.LightingValue.BACKLIGHT_COLOR_2,R=t[b];if(K&&t.customColors)[v,M]=[t.customColors[x-1],(O,I)=>e(updateCustomColor(x-1,O,I))];else if(R)[v,M]=[{hue:R[0],sat:R[1]},(O,I)=>e(updateBacklightValue(b,O,I))];else return null;return jsxs(ControlRow,{children:[jsxs(Label$1,{children:["Color ",x]}),jsx(Detail,{children:jsx(ColorPicker$2,{color:v,setColor:M})})]},x)}),m&&jsx(LightingControl,{meta:[dist.LightingValue.QMK_RGBLIGHT_COLOR,"Underglow Color",{type:"color"}]})]})}return null},LayoutConfigValues=[dist.LightingValue.BACKLIGHT_USE_7U_SPACEBAR,dist.LightingValue.BACKLIGHT_USE_ISO_ENTER,dist.LightingValue.BACKLIGHT_USE_SPLIT_BACKSPACE,dist.LightingValue.BACKLIGHT_USE_SPLIT_LEFT_SHIFT,dist.LightingValue.BACKLIGHT_USE_SPLIT_RIGHT_SHIFT,dist.LightingValue.BACKLIGHT_DISABLE_HHKB_BLOCKER_LEDS],BooleanControls=[[dist.LightingValue.BACKLIGHT_USE_7U_SPACEBAR,"Use 7U Spacebar LEDs"],[dist.LightingValue.BACKLIGHT_USE_ISO_ENTER,"Use ISO Enter LEDs"],[dist.LightingValue.BACKLIGHT_USE_SPLIT_BACKSPACE,"Use Split Backspace LEDs"],[dist.LightingValue.BACKLIGHT_USE_SPLIT_LEFT_SHIFT,"Use Split Left Shift LEDs"],[dist.LightingValue.BACKLIGHT_USE_SPLIT_RIGHT_SHIFT,"Use Split Right Shift LEDs"],[dist.LightingValue.BACKLIGHT_DISABLE_HHKB_BLOCKER_LEDS,"Disable HHKB Blocker LEDs"]],Pane$8=()=>{const e=useAppDispatch(),t=useAppSelector(getSelectedLightingData),r=useAppSelector(getSelectedDefinition);if(!t)return null;if(!dist.isVIADefinitionV2(r))throw new Error("This lighting component is only compatible with v2 definitions");const s=dist.getLightingDefinition(r.lighting);if(s.supportedLightingValues.length!==0){const a=BooleanControls.filter(l=>s.supportedLightingValues.indexOf(l[0])!==-1);return jsx(Fragment,{children:a.map(([l,c])=>{const d=t&&t[l],p=d&&d[0];return jsxs(ControlRow,{children:[jsx(Label$1,{children:c}),jsx(Detail,{children:jsx(AccentSlider,{isChecked:!!p,onChange:f=>e(updateBacklightValue(l,+f))})})]},l)})})}return null},AdvancedLightingValues=[dist.LightingValue.BACKLIGHT_DISABLE_WHEN_USB_SUSPENDED,dist.LightingValue.BACKLIGHT_DISABLE_AFTER_TIMEOUT,dist.LightingValue.BACKLIGHT_CAPS_LOCK_INDICATOR_COLOR,dist.LightingValue.BACKLIGHT_CAPS_LOCK_INDICATOR_ROW_COL,dist.LightingValue.BACKLIGHT_LAYER_1_INDICATOR_COLOR,dist.LightingValue.BACKLIGHT_LAYER_1_INDICATOR_ROW_COL,dist.LightingValue.BACKLIGHT_LAYER_2_INDICATOR_COLOR,dist.LightingValue.BACKLIGHT_LAYER_2_INDICATOR_ROW_COL,dist.LightingValue.BACKLIGHT_LAYER_3_INDICATOR_COLOR,dist.LightingValue.BACKLIGHT_LAYER_3_INDICATOR_ROW_COL],AccentText=styled.span`
|
|
613
|
+
color: var(--color_accent);
|
|
614
|
+
`,RGBControls=[[dist.LightingValue.BACKLIGHT_DISABLE_WHEN_USB_SUSPENDED,"Disable LEDs when USB is suspended",{type:"slider"}],[dist.LightingValue.BACKLIGHT_DISABLE_AFTER_TIMEOUT,()=>{const e=useAppSelector(getSelectedLightingData),t=e&&e[dist.LightingValue.BACKLIGHT_DISABLE_AFTER_TIMEOUT];return t?jsxs("span",{children:["LED Sleep Timeout:"," ",jsx(AccentText,{children:t[0]?`After ${t[0]} mins`:"Never"})]}):null},{type:"range",min:0,max:255}],[dist.LightingValue.BACKLIGHT_CAPS_LOCK_INDICATOR_COLOR,"Caps Lock indicator color",{type:"color"}],[dist.LightingValue.BACKLIGHT_CAPS_LOCK_INDICATOR_ROW_COL,"Caps Lock indicator",{type:"row_col"}],[dist.LightingValue.BACKLIGHT_LAYER_1_INDICATOR_COLOR,"Layer 1 indicator color",{type:"color"}],[dist.LightingValue.BACKLIGHT_LAYER_1_INDICATOR_ROW_COL,"Layer 1 indicator",{type:"row_col"}],[dist.LightingValue.BACKLIGHT_LAYER_2_INDICATOR_COLOR,"Layer 2 indicator color",{type:"color"}],[dist.LightingValue.BACKLIGHT_LAYER_2_INDICATOR_ROW_COL,"Layer 2 indicator",{type:"row_col"}],[dist.LightingValue.BACKLIGHT_LAYER_3_INDICATOR_COLOR,"Layer 3 indicator color",{type:"color"}],[dist.LightingValue.BACKLIGHT_LAYER_3_INDICATOR_ROW_COL,"Layer 3 indicator",{type:"row_col"}]],AdvancedPane=()=>{const e=useAppSelector(getSelectedLightingData),t=useAppSelector(getSelectedDefinition);if(dist.isVIADefinitionV2(t)&&e){const{supportedLightingValues:r}=dist.getLightingDefinition(t.lighting);return jsx(Fragment,{children:RGBControls.filter(s=>r.indexOf(s[0])!==-1).map(s=>jsx(LightingControl,{meta:s}))})}return null},Category={General:{label:"General",Menu:GeneralPane},Layout:{label:"Layout",Menu:Pane$8},Advanced:{label:"Advanced",Menu:AdvancedPane}},LightingPane=styled(CenterPane)`
|
|
615
|
+
height: 100%;
|
|
616
|
+
background: var(--color_dark_grey);
|
|
617
|
+
`,Container$j=styled.div`
|
|
618
|
+
display: flex;
|
|
619
|
+
align-items: center;
|
|
620
|
+
flex-direction: column;
|
|
621
|
+
padding: 0 12px;
|
|
622
|
+
`,MenuContainer$4=styled.div`
|
|
623
|
+
padding: 15px 20px 20px 10px;
|
|
624
|
+
`,Pane$7=()=>{const e=useAppSelector(getSelectedDefinition),[t,r]=reactExports.useState(Category.General);return jsxs(Fragment,{children:[jsx(SubmenuCell,{children:jsx(MenuContainer$4,{children:(()=>{if(!dist.isVIADefinitionV2(e))throw new Error("This lighting component is only compatible with v2 definitions");const a=LayoutConfigValues.some(c=>dist.getLightingDefinition(e.lighting).supportedLightingValues.indexOf(c)!==-1),l=AdvancedLightingValues.some(c=>dist.getLightingDefinition(e.lighting).supportedLightingValues.indexOf(c)!==-1);return[Category.General,...a?[Category.Layout]:[],...l?[Category.Advanced]:[]].filter(({Menu:c})=>!!c)})().map(a=>jsx(SubmenuRow,{$selected:t===a,onClick:()=>r(a),children:a.label},a.label))})}),jsx(OverflowCell,{children:jsx(LightingPane,{children:jsx(Container$j,{children:jsx(t.Menu,{})})})})]})},Icon$7=component$4,Title$9=title$7,Lighting$1=Object.freeze(Object.defineProperty({__proto__:null,Category,Icon:Icon$7,Pane:Pane$7,Title:Title$9},Symbol.toStringTag,{value:"Module"})),SvgIcAdjust24Px=e=>jsx("svg",{width:16.571,height:16.571,...e,children:jsx("path",{d:"M8.285 0a8.285 8.285 0 108.285 8.285A8.3 8.3 0 008.285 0zm0 14.914a6.628 6.628 0 116.628-6.628 6.637 6.637 0 01-6.628 6.628zm2.486-6.628A2.486 2.486 0 118.285 5.8a2.482 2.482 0 012.486 2.485z",fill:"currentColor"})}),title$5="Macros",component$2=SvgIcAdjust24Px,matrixKeycodes=[basicKeyToByte.KC_ESC,basicKeyToByte.KC_F1,basicKeyToByte.KC_F2,basicKeyToByte.KC_F3,basicKeyToByte.KC_F4,basicKeyToByte.KC_F5,basicKeyToByte.KC_F6,basicKeyToByte.KC_F7,basicKeyToByte.KC_F8,basicKeyToByte.KC_F9,basicKeyToByte.KC_F10,basicKeyToByte.KC_F11,basicKeyToByte.KC_F12,basicKeyToByte.KC_PSCR,basicKeyToByte.KC_SLCK,basicKeyToByte.KC_PAUS,basicKeyToByte.KC_SLEP,basicKeyToByte.KC_MUTE,basicKeyToByte.KC_VOLD,basicKeyToByte.KC_VOLU,basicKeyToByte.KC_GRV,basicKeyToByte.KC_1,basicKeyToByte.KC_2,basicKeyToByte.KC_3,basicKeyToByte.KC_4,basicKeyToByte.KC_5,basicKeyToByte.KC_6,basicKeyToByte.KC_7,basicKeyToByte.KC_8,basicKeyToByte.KC_9,basicKeyToByte.KC_0,basicKeyToByte.KC_MINS,basicKeyToByte.KC_EQL,basicKeyToByte.KC_BSPC,basicKeyToByte.KC_INS,basicKeyToByte.KC_HOME,basicKeyToByte.KC_PGUP,basicKeyToByte.KC_NLCK,basicKeyToByte.KC_PSLS,basicKeyToByte.KC_PAST,basicKeyToByte.KC_PMNS,basicKeyToByte.KC_TAB,basicKeyToByte.KC_Q,basicKeyToByte.KC_W,basicKeyToByte.KC_E,basicKeyToByte.KC_R,basicKeyToByte.KC_T,basicKeyToByte.KC_Y,basicKeyToByte.KC_U,basicKeyToByte.KC_I,basicKeyToByte.KC_O,basicKeyToByte.KC_P,basicKeyToByte.KC_LBRC,basicKeyToByte.KC_RBRC,basicKeyToByte.KC_BSLS,basicKeyToByte.KC_DEL,basicKeyToByte.KC_END,basicKeyToByte.KC_PGDN,basicKeyToByte.KC_P7,basicKeyToByte.KC_P8,basicKeyToByte.KC_P9,basicKeyToByte.KC_PPLS,basicKeyToByte.KC_CAPS,basicKeyToByte.KC_A,basicKeyToByte.KC_S,basicKeyToByte.KC_D,basicKeyToByte.KC_F,basicKeyToByte.KC_G,basicKeyToByte.KC_H,basicKeyToByte.KC_J,basicKeyToByte.KC_K,basicKeyToByte.KC_L,basicKeyToByte.KC_SCLN,basicKeyToByte.KC_QUOT,basicKeyToByte.KC_ENT,basicKeyToByte.KC_P4,basicKeyToByte.KC_P5,basicKeyToByte.KC_P6,basicKeyToByte.KC_LSFT,basicKeyToByte.KC_Z,basicKeyToByte.KC_X,basicKeyToByte.KC_C,basicKeyToByte.KC_V,basicKeyToByte.KC_B,basicKeyToByte.KC_N,basicKeyToByte.KC_M,basicKeyToByte.KC_COMM,basicKeyToByte.KC_DOT,basicKeyToByte.KC_SLSH,basicKeyToByte.KC_RSFT,basicKeyToByte.KC_UP,basicKeyToByte.KC_P1,basicKeyToByte.KC_P2,basicKeyToByte.KC_P3,basicKeyToByte.KC_PENT,basicKeyToByte.KC_LCTL,basicKeyToByte.KC_LGUI,basicKeyToByte.KC_LALT,basicKeyToByte.KC_SPC,basicKeyToByte.KC_RALT,basicKeyToByte.KC_RGUI,basicKeyToByte.KC_MENU,basicKeyToByte.KC_RCTL,basicKeyToByte.KC_LEFT,basicKeyToByte.KC_DOWN,basicKeyToByte.KC_RGHT,basicKeyToByte.KC_P0,basicKeyToByte.KC_PDOT],evtToKeyByte={Digit1:basicKeyToByte.KC_1,Digit2:basicKeyToByte.KC_2,Digit3:basicKeyToByte.KC_3,Digit4:basicKeyToByte.KC_4,Digit5:basicKeyToByte.KC_5,Digit6:basicKeyToByte.KC_6,Digit7:basicKeyToByte.KC_7,Digit8:basicKeyToByte.KC_8,Digit9:basicKeyToByte.KC_9,Digit0:basicKeyToByte.KC_0,KeyA:basicKeyToByte.KC_A,KeyB:basicKeyToByte.KC_B,KeyC:basicKeyToByte.KC_C,KeyD:basicKeyToByte.KC_D,KeyE:basicKeyToByte.KC_E,KeyF:basicKeyToByte.KC_F,KeyG:basicKeyToByte.KC_G,KeyH:basicKeyToByte.KC_H,KeyI:basicKeyToByte.KC_I,KeyJ:basicKeyToByte.KC_J,KeyK:basicKeyToByte.KC_K,KeyL:basicKeyToByte.KC_L,KeyM:basicKeyToByte.KC_M,KeyN:basicKeyToByte.KC_N,KeyO:basicKeyToByte.KC_O,KeyP:basicKeyToByte.KC_P,KeyQ:basicKeyToByte.KC_Q,KeyR:basicKeyToByte.KC_R,KeyS:basicKeyToByte.KC_S,KeyT:basicKeyToByte.KC_T,KeyU:basicKeyToByte.KC_U,KeyV:basicKeyToByte.KC_V,KeyW:basicKeyToByte.KC_W,KeyX:basicKeyToByte.KC_X,KeyY:basicKeyToByte.KC_Y,KeyZ:basicKeyToByte.KC_Z,Comma:basicKeyToByte.KC_COMM,Period:basicKeyToByte.KC_DOT,Semicolon:basicKeyToByte.KC_SCLN,Quote:basicKeyToByte.KC_QUOT,BracketLeft:basicKeyToByte.KC_LBRC,BracketRight:basicKeyToByte.KC_RBRC,Backspace:basicKeyToByte.KC_BSPC,Backquote:basicKeyToByte.KC_GRV,Slash:basicKeyToByte.KC_SLSH,Backslash:basicKeyToByte.KC_BSLS,Minus:basicKeyToByte.KC_MINS,Equal:basicKeyToByte.KC_EQL,IntlRo:basicKeyToByte.KC_RO,IntlYen:basicKeyToByte.KC_JYEN,AltLeft:basicKeyToByte.KC_LALT,AltRight:basicKeyToByte.KC_RALT,CapsLock:basicKeyToByte.KC_CAPS,ControlLeft:basicKeyToByte.KC_LCTL,ControlRight:basicKeyToByte.KC_RCTL,MetaLeft:basicKeyToByte.KC_LGUI,MetaRight:basicKeyToByte.KC_RGUI,OSLeft:basicKeyToByte.KC_LGUI,OSRight:basicKeyToByte.KC_RGUI,ShiftLeft:basicKeyToByte.KC_LSFT,ShiftRight:basicKeyToByte.KC_RSFT,ContextMenu:basicKeyToByte.KC_APP,Enter:basicKeyToByte.KC_ENT,Space:basicKeyToByte.KC_SPC,Tab:basicKeyToByte.KC_TAB,Delete:basicKeyToByte.KC_DEL,End:basicKeyToByte.KC_END,Help:basicKeyToByte.KC_HELP,Home:basicKeyToByte.KC_HOME,Insert:basicKeyToByte.KC_INS,PageDown:basicKeyToByte.KC_PGDN,PageUp:basicKeyToByte.KC_PGUP,ArrowDown:basicKeyToByte.KC_DOWN,ArrowLeft:basicKeyToByte.KC_LEFT,ArrowRight:basicKeyToByte.KC_RGHT,ArrowUp:basicKeyToByte.KC_UP,Escape:basicKeyToByte.KC_ESC,PrintScreen:basicKeyToByte.KC_PSCR,ScrollLock:basicKeyToByte.KC_SLCK,AudioVolumeUp:basicKeyToByte.KC_VOLU,AudioVolumeDown:basicKeyToByte.KC_VOLD,AudioVolumeMute:basicKeyToByte.KC_MUTE,Pause:basicKeyToByte.KC_PAUS,F1:basicKeyToByte.KC_F1,F2:basicKeyToByte.KC_F2,F3:basicKeyToByte.KC_F3,F4:basicKeyToByte.KC_F4,F5:basicKeyToByte.KC_F5,F6:basicKeyToByte.KC_F6,F7:basicKeyToByte.KC_F7,F8:basicKeyToByte.KC_F8,F9:basicKeyToByte.KC_F9,F10:basicKeyToByte.KC_F10,F11:basicKeyToByte.KC_F11,F12:basicKeyToByte.KC_F12,F13:basicKeyToByte.KC_F13,F14:basicKeyToByte.KC_F14,F15:basicKeyToByte.KC_F15,F16:basicKeyToByte.KC_F16,F17:basicKeyToByte.KC_F17,F18:basicKeyToByte.KC_F18,F19:basicKeyToByte.KC_F19,F20:basicKeyToByte.KC_F20,F21:basicKeyToByte.KC_F21,F22:basicKeyToByte.KC_F22,F23:basicKeyToByte.KC_F23,F24:basicKeyToByte.KC_F24,NumLock:basicKeyToByte.KC_NLCK,Numpad0:basicKeyToByte.KC_P0,Numpad1:basicKeyToByte.KC_P1,Numpad2:basicKeyToByte.KC_P2,Numpad3:basicKeyToByte.KC_P3,Numpad4:basicKeyToByte.KC_P4,Numpad5:basicKeyToByte.KC_P5,Numpad6:basicKeyToByte.KC_P6,Numpad7:basicKeyToByte.KC_P7,Numpad8:basicKeyToByte.KC_P8,Numpad9:basicKeyToByte.KC_P9,NumpadAdd:basicKeyToByte.KC_PPLS,NumpadComma:basicKeyToByte.KC_COMM,NumpadDecimal:basicKeyToByte.KC_PDOT,NumpadDivide:basicKeyToByte.KC_PSLS,NumpadEnter:basicKeyToByte.KC_PENT,NumpadEqual:basicKeyToByte.KC_PEQL,NumpadMultiply:basicKeyToByte.KC_PAST,NumpadSubtract:basicKeyToByte.KC_PMNS};function getIndexByEvent(e){const t=e.code,r=evtToKeyByte[t]||evtToKeyByte[e.key];return r?matrixKeycodes.indexOf(r):-1}function mapEvtToKeycode(e){switch(e.code){case"Digit1":return"KC_1";case"Digit2":return"KC_2";case"Digit3":return"KC_3";case"Digit4":return"KC_4";case"Digit5":return"KC_5";case"Digit6":return"KC_6";case"Digit7":return"KC_7";case"Digit8":return"KC_8";case"Digit9":return"KC_9";case"Digit0":return"KC_0";case"KeyA":return"KC_A";case"KeyB":return"KC_B";case"KeyC":return"KC_C";case"KeyD":return"KC_D";case"KeyE":return"KC_E";case"KeyF":return"KC_F";case"KeyG":return"KC_G";case"KeyH":return"KC_H";case"KeyI":return"KC_I";case"KeyJ":return"KC_J";case"KeyK":return"KC_K";case"KeyL":return"KC_L";case"KeyM":return"KC_M";case"KeyN":return"KC_N";case"KeyO":return"KC_O";case"KeyP":return"KC_P";case"KeyQ":return"KC_Q";case"KeyR":return"KC_R";case"KeyS":return"KC_S";case"KeyT":return"KC_T";case"KeyU":return"KC_U";case"KeyV":return"KC_V";case"KeyW":return"KC_W";case"KeyX":return"KC_X";case"KeyY":return"KC_Y";case"KeyZ":return"KC_Z";case"Comma":return"KC_COMM";case"Period":return"KC_DOT";case"Semicolon":return"KC_SCLN";case"Quote":return"KC_QUOT";case"BracketLeft":return"KC_LBRC";case"BracketRight":return"KC_RBRC";case"Backquote":return"KC_GRV";case"Slash":return"KC_SLSH";case"Backspace":return"KC_BSPC";case"Backslash":return"KC_BSLS";case"Minus":return"KC_MINS";case"Equal":return"KC_EQL";case"IntlRo":return"KC_RO";case"IntlYen":return"KC_JYEN";case"AltLeft":return"KC_LALT";case"AltRight":return"KC_RALT";case"CapsLock":return"KC_CAPS";case"ControlLeft":return"KC_LCTL";case"ControlRight":return"KC_RCTL";case"MetaLeft":return"KC_LGUI";case"MetaRight":return"KC_RGUI";case"OSLeft":return"KC_LGUI";case"OSRight":return"KC_RGUI";case"ShiftLeft":return"KC_LSFT";case"ShiftRight":return"KC_RSFT";case"ContextMenu":return"KC_APP";case"Apps":return"KC_APP";case"Enter":return"KC_ENT";case"Space":return"KC_SPC";case"Tab":return"KC_TAB";case"Delete":return"KC_DEL";case"End":return"KC_END";case"Help":return"KC_HELP";case"Home":return"KC_HOME";case"Insert":return"KC_INS";case"PageDown":return"KC_PGDN";case"PageUp":return"KC_PGUP";case"ArrowDown":return"KC_DOWN";case"ArrowLeft":return"KC_LEFT";case"ArrowRight":return"KC_RGHT";case"ArrowUp":return"KC_UP";case"Escape":return"KC_ESC";case"PrintScreen":return"KC_PSCR";case"ScrollLock":return"KC_SLCK";case"Pause":return"KC_PAUS";case"F1":return"KC_F1";case"F2":return"KC_F2";case"F3":return"KC_F3";case"F4":return"KC_F4";case"F5":return"KC_F5";case"F6":return"KC_F6";case"F7":return"KC_F7";case"F8":return"KC_F8";case"F9":return"KC_F9";case"F10":return"KC_F10";case"F11":return"KC_F11";case"F12":return"KC_F12";case"F13":return"KC_F13";case"F14":return"KC_F14";case"F15":return"KC_F15";case"F16":return"KC_F16";case"F17":return"KC_F17";case"F18":return"KC_F18";case"F19":return"KC_F19";case"F20":return"KC_F20";case"F21":return"KC_F21";case"F22":return"KC_F22";case"F23":return"KC_F23";case"F24":return"KC_F24";case"NumLock":return"KC_NLCK";case"Numpad0":return"KC_P0";case"Numpad1":return"KC_P1";case"Numpad2":return"KC_P2";case"Numpad3":return"KC_P3";case"Numpad4":return"KC_P4";case"Numpad5":return"KC_P5";case"Numpad6":return"KC_P6";case"Numpad7":return"KC_P7";case"Numpad8":return"KC_P8";case"Numpad9":return"KC_P9";case"NumpadAdd":return"KC_PPLS";case"NumpadComma":return"KC_COMM";case"NumpadDecimal":return"KC_PDOT";case"NumpadDivide":return"KC_PSLS";case"NumpadEnter":return"KC_PENT";case"NumpadEqual":return"KC_PEQL";case"NumpadMultiply":return"KC_PAST";case"NumpadSubtract":return"KC_PMNS";case"AudioVolumeUp":return"KC_VOLU";case"AudioVolumeDown":return"KC_VOLD";case"AudioVolumeMute":return"KC_MUTE";default:console.error("Unreacheable keydown code",e)}}let heldKeys={},lastEvtTime=0;const useKeycodeRecorder=(e,t)=>{const r=reactExports.useState([]),[,s]=r,a=reactExports.useMemo(()=>getKeycodes().flatMap(p=>p.keycodes),[]),l=reactExports.useCallback((p,f)=>{p.preventDefault(),e&&!p.repeat&&s(m=>{const y=a.find(v=>v.code===mapEvtToKeycode(p)),K=Date.now(),x=y==null?void 0:y.code;return m.length&&t&&m.push([RawKeycodeSequenceAction.Delay,K-lastEvtTime]),x&&m.push([f,x]),lastEvtTime=K,[...m]})},[e,t]),c=reactExports.useCallback(p=>{p.repeat||(heldKeys[p.code]=!0,l(p,RawKeycodeSequenceAction.Down))},[e]),d=reactExports.useCallback(p=>{heldKeys[p.code]=!1,l(p,RawKeycodeSequenceAction.Up)},[e]);return reactExports.useEffect(()=>(heldKeys={},e&&(window.addEventListener("keydown",c),window.addEventListener("keyup",d)),()=>{heldKeys={},window.removeEventListener("keydown",c),window.removeEventListener("keyup",d)}),[e]),r};styled.div`
|
|
625
|
+
border: 2px solid var(--bg_control);
|
|
626
|
+
transition: border-color 0.2s ease-in-out;
|
|
627
|
+
margin: 15px 0px;
|
|
628
|
+
display: inline-block;
|
|
629
|
+
&:focus-within {
|
|
630
|
+
border-color: var(--color_accent);
|
|
631
|
+
}
|
|
632
|
+
border-radius: 4px;
|
|
633
|
+
font-size: 16px;
|
|
634
|
+
`;const KeycodeSequenceLabel=styled.div`
|
|
635
|
+
display: inline-flex;
|
|
636
|
+
user-select: none;
|
|
637
|
+
color: #717070;
|
|
638
|
+
padding: 6px 4px;
|
|
639
|
+
text-overflow: ellipsis;
|
|
640
|
+
min-width: 30px;
|
|
641
|
+
font-size: 12px;
|
|
642
|
+
text-align: center;
|
|
643
|
+
border-radius: 4px;
|
|
644
|
+
justify-content: center;
|
|
645
|
+
align-items: center;
|
|
646
|
+
white-space: pre-wrap;
|
|
647
|
+
font-size: 16px;
|
|
648
|
+
border: 2px solid var(--border_color_icon);
|
|
649
|
+
background: var(--bg_control);
|
|
650
|
+
color: var(--color_label-highlighted);
|
|
651
|
+
margin: 0;
|
|
652
|
+
box-shadow: none;
|
|
653
|
+
position: relative;
|
|
654
|
+
border-radius: 2px;
|
|
655
|
+
white-space: nowrap;
|
|
656
|
+
position: relative;
|
|
657
|
+
margin: 15px 0px;
|
|
658
|
+
`,KeycodeDownLabel=styled(KeycodeSequenceLabel)`
|
|
659
|
+
&::after {
|
|
660
|
+
border-style: solid;
|
|
661
|
+
border-color: transparent;
|
|
662
|
+
content: '';
|
|
663
|
+
border-left: 6px solid transparent;
|
|
664
|
+
border-right: 6px solid transparent;
|
|
665
|
+
border-top: 6px solid var(--color_accent);
|
|
666
|
+
position: absolute;
|
|
667
|
+
margin-top: 55px;
|
|
668
|
+
width: 0;
|
|
669
|
+
}
|
|
670
|
+
`,SequenceLabelSeparator=styled.div`
|
|
671
|
+
width: 20px;
|
|
672
|
+
display: inline-flex;
|
|
673
|
+
vertical-align: middle;
|
|
674
|
+
border: 1px solid var(--color_accent);
|
|
675
|
+
`,CharacterStreamLabel=styled(KeycodeSequenceLabel)`
|
|
676
|
+
border-color: var(--border_color_cell);
|
|
677
|
+
background: var(--bg_menu);
|
|
678
|
+
white-space: pre-wrap;
|
|
679
|
+
min-height: 1.25em;
|
|
680
|
+
letter-spacing: 2px;
|
|
681
|
+
`,KeycodePressLabel=styled(KeycodeSequenceLabel)`
|
|
682
|
+
border-color: var(--color_accent);
|
|
683
|
+
`,KeycodeUpLabel=styled(KeycodeSequenceLabel)`
|
|
684
|
+
&::after {
|
|
685
|
+
content: '';
|
|
686
|
+
border-style: solid;
|
|
687
|
+
margin-top: -55px;
|
|
688
|
+
border-color: transparent;
|
|
689
|
+
border-left: 6px solid transparent;
|
|
690
|
+
border-right: 6px solid transparent;
|
|
691
|
+
border-bottom: 6px solid var(--color_accent);
|
|
692
|
+
position: absolute;
|
|
693
|
+
width: 0;
|
|
694
|
+
}
|
|
695
|
+
`,KeycodeSequenceWait=styled.div`
|
|
696
|
+
display: inline-flex;
|
|
697
|
+
font-weight: bold;
|
|
698
|
+
user-select: none;
|
|
699
|
+
color: #717070;
|
|
700
|
+
text-overflow: ellipsis;
|
|
701
|
+
min-width: 30px;
|
|
702
|
+
text-align: center;
|
|
703
|
+
justify-content: center;
|
|
704
|
+
align-items: center;
|
|
705
|
+
white-space: pre-wrap;
|
|
706
|
+
font-size: 16px;
|
|
707
|
+
color: var(--color_label-highlighted);
|
|
708
|
+
box-shadow: none;
|
|
709
|
+
position: relative;
|
|
710
|
+
white-space: nowrap;
|
|
711
|
+
position: relative;
|
|
712
|
+
margin: 15px 0px;
|
|
713
|
+
box-sizing: border-box;
|
|
714
|
+
border: 2px solid;
|
|
715
|
+
padding: 4px 4px;
|
|
716
|
+
border-color: var(--color_accent);
|
|
717
|
+
border-radius: 2px;
|
|
718
|
+
`,NumberInput=styled.input.attrs({type:"number",placeholder:"XXXXX"})`
|
|
719
|
+
appearance: none;
|
|
720
|
+
background: none;
|
|
721
|
+
border: none;
|
|
722
|
+
border-bottom: 1px solid;
|
|
723
|
+
color: var(--color_label);
|
|
724
|
+
width: 45px;
|
|
725
|
+
text-align: center;
|
|
726
|
+
font-family: inherit;
|
|
727
|
+
font-size: inherit;
|
|
728
|
+
color: var(--color_label-highlighted);
|
|
729
|
+
margin: 0 5px 0 0;
|
|
730
|
+
&:focus {
|
|
731
|
+
color: var(--color_accent);
|
|
732
|
+
}
|
|
733
|
+
&::-webkit-inner-spin-button {
|
|
734
|
+
appearance: none;
|
|
735
|
+
display: none;
|
|
736
|
+
}
|
|
737
|
+
&:invalid {
|
|
738
|
+
color: red;
|
|
739
|
+
}
|
|
740
|
+
&:placeholder-shown {
|
|
741
|
+
color: red;
|
|
742
|
+
}
|
|
743
|
+
`,WaitInput=e=>{const t=reactExports.useRef(null),r=a=>{(!a.data||!/^\d$/.test(a.data))&&a.preventDefault()},s=a=>{+a.target.value>0&&+a.target.value<1e5&&e.updateValue(e.index,+a.target.value)};return jsxs(KeycodeSequenceWait,{children:[jsx(NumberInput,{ref:t,onBeforeInput:r,value:e.value,onChange:s}),"ms"]})},getSequenceItemComponent=e=>e===RawKeycodeSequenceAction.Down?KeycodeDownLabel:e===RawKeycodeSequenceAction.Up?KeycodeUpLabel:e===RawKeycodeSequenceAction.CharacterStream?CharacterStreamLabel:KeycodePressLabel;function capitalize(e){return e[0].toUpperCase()+e.slice(1)}const getSequenceLabel=e=>{const t=(e==null?void 0:e.keys)??(e==null?void 0:e.shortName)??(e==null?void 0:e.name)??"";return t.length>1?capitalize(t):t},SimpleIconButton=styled.button`
|
|
744
|
+
appearance: none;
|
|
745
|
+
position: relative;
|
|
746
|
+
display: inline-block;
|
|
747
|
+
background: transparent;
|
|
748
|
+
border: none;
|
|
749
|
+
cursor: pointer;
|
|
750
|
+
line-height: initial;
|
|
751
|
+
font-size: initial;
|
|
752
|
+
padding: 0;
|
|
753
|
+
&:disabled {
|
|
754
|
+
cursor: not-allowed;
|
|
755
|
+
cursor: not-allowed;
|
|
756
|
+
}
|
|
757
|
+
svg {
|
|
758
|
+
color: ${e=>e.disabled?"var(--bg_control)":"var(--border_color_icon);"};
|
|
759
|
+
}
|
|
760
|
+
&:hover {
|
|
761
|
+
svg {
|
|
762
|
+
color: ${e=>e.disabled?"var(--bg_control)":"var(--color_accent)"};
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
`,IconButton=styled.button`
|
|
766
|
+
appearance: none;
|
|
767
|
+
width: 40px;
|
|
768
|
+
position: relative;
|
|
769
|
+
display: inline-block;
|
|
770
|
+
background: transparent;
|
|
771
|
+
border: none;
|
|
772
|
+
cursor: pointer;
|
|
773
|
+
padding: 10px 10px;
|
|
774
|
+
line-height: initial;
|
|
775
|
+
font-size: initial;
|
|
776
|
+
color: ${e=>e.disabled?"var(--bg_control)":"var(--color_accent)"};
|
|
777
|
+
border-color: ${e=>e.disabled?"var(--bg_control)":"var(--color_accent)"};
|
|
778
|
+
&:disabled {
|
|
779
|
+
cursor: not-allowed;
|
|
780
|
+
border-right: 1px solid var(--border_color_icon);
|
|
781
|
+
cursor: not-allowed;
|
|
782
|
+
background: var(--bg_menu);
|
|
783
|
+
}
|
|
784
|
+
&:hover {
|
|
785
|
+
color: ${e=>e.disabled?"var(--bg_control)":"var(--color_inside-accent)"};
|
|
786
|
+
border-color: ${e=>e.disabled?"var(--bg_control)":"var(--color_accent)"};
|
|
787
|
+
border-right: 1px solid var(--border_color_icon);
|
|
788
|
+
background-color: ${e=>e.disabled?"var(--bg_menu)":"var(--color_accent)"};
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
svg {
|
|
792
|
+
color: ${e=>e.disabled?"var(--bg_control)":"var(--color_accent)"};
|
|
793
|
+
}
|
|
794
|
+
&:hover {
|
|
795
|
+
svg {
|
|
796
|
+
color: ${e=>e.disabled?"var(--bg_control)":"var(--color_inside-accent)"};
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
color: var(--color_label-highlighted);
|
|
800
|
+
& .tooltip {
|
|
801
|
+
transform: scale(1) translateX(0px);
|
|
802
|
+
opacity: 1;
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
.tooltip {
|
|
806
|
+
transform: translateX(-5px) scale(0.6);
|
|
807
|
+
opacity: 0;
|
|
808
|
+
}
|
|
809
|
+
`,IconButtonUnfilledContainer=styled(IconButton)`
|
|
810
|
+
cursor: pointer;
|
|
811
|
+
background: inherit;
|
|
812
|
+
border: 1px solid var(--color_accent);
|
|
813
|
+
width: 30px;
|
|
814
|
+
height: 30px;
|
|
815
|
+
justify-content: center;
|
|
816
|
+
display: inline-flex;
|
|
817
|
+
align-items: center;
|
|
818
|
+
`,IconButtonContainer=styled(IconButton)`
|
|
819
|
+
cursor: pointer;
|
|
820
|
+
background: var(--bg_control);
|
|
821
|
+
border-right: 1px solid var(--border_color_icon);
|
|
822
|
+
`,IconToggleContainer=styled(IconButton)`
|
|
823
|
+
cursor: pointer;
|
|
824
|
+
transition: all 0.4s ease;
|
|
825
|
+
background: ${e=>e.$selected?"var(--color_accent)":"var(--bg_menu)"};
|
|
826
|
+
svg {
|
|
827
|
+
color: ${e=>e.$selected?"var(--color_inside-accent)":"var(--bg_icon)"};
|
|
828
|
+
}
|
|
829
|
+
&:hover {
|
|
830
|
+
background: ${e=>e.$selected?"var(--color_accent)":"var(--bg_menu)"};
|
|
831
|
+
svg {
|
|
832
|
+
color: ${e=>e.$selected?"var(--color_inside-accent)":"var(--bg_icon)"};
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
border-right: 1px solid var(--border_color_icon);
|
|
836
|
+
`,Keycap2DTooltip=e=>{const t=reactExports.useMemo(()=>({containerStyles:{position:"absolute",left:"50%",transformOrigin:"left",transition:"all 0.1s ease-in-out",top:0,marginTop:-40,zIndex:4,pointerEvents:"none",filter:"drop-shadow(0px 0px 1px white)"},contentStyles:{padding:"5px 8px",borderRadius:10,background:"var(--color_accent)",color:"var(--color_inside-accent)",fontFamily:"'Fira Sans Condensed', Helvetica, Helvetica Neue, Arial, serif",fontSize:16,fontWeight:500,whiteSpace:"nowrap",display:"flex",justifyContent:"center",alignItems:"center",textTransform:"uppercase",zIndex:5,transform:"translateX(-50%)"},pointerStyles:{borderStyle:"solid",borderColor:"transparent",borderLeft:"6px solid transparent",borderRight:"6px solid transparent",borderTop:"6px solid var(--color_accent)",position:"absolute",marginLeft:-6,width:0}}),[]);return jsx(Tooltip,{...e,containerStyles:t.containerStyles,contentStyles:t.contentStyles,pointerStyles:t.pointerStyles})},KeycapTooltip=e=>{const t=reactExports.useMemo(()=>({containerStyles:{display:"flex",justifyContent:"center",alignItems:"center",flexDirection:"column",marginTop:-800},contentStyles:{padding:"70px 70px",background:"var(--color_accent)",color:"var(--color_inside-accent)",borderRadius:100,fontSize:200,fontFamily:"'Fira Sans', Helvetica, Helvetica Neue, Arial, serif",whiteSpace:"nowrap",letterSpacing:1,display:"flex",justifyContent:"center",alignItems:"center",fontWeight:"bold"},pointerStyles:{height:150,width:150,marginTop:-100,transform:"rotate(45deg)",background:"var(--color_accent)"}}),[]);return jsx(Tooltip,{...e,containerStyles:t.containerStyles,contentStyles:t.contentStyles,pointerStyles:t.pointerStyles})},CategoryMenuTooltip=e=>{const t=reactExports.useMemo(()=>({containerStyles:{position:"absolute",top:45,left:0,transformOrigin:"left",transition:"all 0.1s ease-in-out",marginTop:0,zIndex:4,pointerEvents:"none"},contentStyles:{padding:"5px 10px",borderRadius:10,background:"var(--color_accent)",color:"var(--color_inside-accent)",fontFamily:"'Fira Sans Condensed', Helvetica, Helvetica Neue, Arial, serif",fontSize:18,fontWeight:500,whiteSpace:"nowrap",display:"flex",justifyContent:"center",alignItems:"center",textTransform:"uppercase",zIndex:5,transform:"translateX(-50%)",marginLeft:18},pointerStyles:{borderStyle:"solid",borderColor:"transparent",borderLeft:"6px solid transparent",borderRight:"6px solid transparent",borderBottom:"6px solid var(--color_accent)",position:"absolute",marginLeft:15,marginTop:-41,width:0}}),[]);return jsx(Tooltip,{...e,containerStyles:t.containerStyles,contentStyles:t.contentStyles,pointerStyles:t.pointerStyles})},ProgressBarTooltip=e=>{const t=reactExports.useMemo(()=>({containerStyles:{position:"absolute",left:"50%",transformOrigin:"left",transition:"all 0.1s ease-in-out",top:0,marginTop:-40,zIndex:4,pointerEvents:"none"},contentStyles:{padding:"5px 10px",borderRadius:10,background:"var(--color_inside-accent)",color:"var(--color_accent)",fontFamily:"'Fira Sans Condensed', Helvetica, Helvetica Neue, Arial, serif",fontSize:18,fontWeight:500,whiteSpace:"nowrap",display:"flex",justifyContent:"center",alignItems:"center",textTransform:"uppercase",zIndex:5,transform:"translateX(-50%)"},pointerStyles:{borderStyle:"solid",borderColor:"transparent",borderLeft:"6px solid transparent",borderRight:"6px solid transparent",borderTop:"6px solid var(--color_inside-accent)",position:"absolute",marginLeft:-6,width:0}}),[]);return jsx(Tooltip,{...e,containerStyles:t.containerStyles,contentStyles:t.contentStyles,pointerStyles:t.pointerStyles})},IconButtonTooltip=e=>{const t=reactExports.useMemo(()=>({containerStyles:{position:"absolute",top:50,left:0,transformOrigin:"left",transition:"all 0.1s ease-in-out",marginTop:0,zIndex:4,pointerEvents:"none"},contentStyles:{padding:"5px 10px",borderRadius:10,background:"var(--color_inside-accent)",color:"var(--color_accent)",fontFamily:"'Fira Sans Condensed', Helvetica, Helvetica Neue, Arial, serif",fontSize:18,fontWeight:500,whiteSpace:"nowrap",display:"flex",justifyContent:"center",alignItems:"center",textTransform:"uppercase",zIndex:5,transform:"translateX(-50%)",marginLeft:18},pointerStyles:{borderStyle:"solid",borderColor:"transparent",borderLeft:"6px solid transparent",borderRight:"6px solid transparent",borderBottom:"6px solid var(--color_inside-accent)",position:"absolute",marginLeft:15,marginTop:-41,width:0}}),[]);return jsx(Tooltip,{...e,containerStyles:t.containerStyles,contentStyles:t.contentStyles,pointerStyles:t.pointerStyles})},MenuTooltip=e=>{const t=reactExports.useMemo(()=>({containerStyles:{position:"absolute",top:0,left:45,transformOrigin:"left",transition:"all 0.1s ease-in-out",marginTop:-5,zIndex:4,pointerEvents:"none"},contentStyles:{padding:"5px 5px",background:"var(--color_inside-accent)",color:"var(--color_accent)",borderRadius:10,fontFamily:"'Fira Sans Condensed', Helvetica, Helvetica Neue, Arial, serif",fontWeight:400,whiteSpace:"nowrap",display:"flex",justifyContent:"center",alignItems:"center",zIndex:5},pointerStyles:{borderStyle:"solid",borderColor:"transparent",borderTop:"6px solid transparent",borderBottom:"6px solid transparent",borderRight:"6px solid var(--color_inside-accent)",position:"absolute",marginLeft:-9,marginTop:-21,width:0}}),[]);return jsx(Tooltip,{...e,containerStyles:t.containerStyles,contentStyles:t.contentStyles,pointerStyles:t.pointerStyles})},Tooltip=e=>{const{containerStyles:t,contentStyles:r,pointerStyles:s}=e;return jsxs("div",{style:t,className:"tooltip",children:[jsx("div",{style:r,children:e.children}),jsx("div",{style:s})]})},MacroEditControlsContainer=styled.div`
|
|
837
|
+
background: var(--bg_menu);
|
|
838
|
+
display: inline-flex;
|
|
839
|
+
align-items: center;
|
|
840
|
+
padding: 0 10px;
|
|
841
|
+
`,MacroControlGroupContainer=styled.div`
|
|
842
|
+
border-radius: 2px;
|
|
843
|
+
border: 1px solid var(--border_color_icon);
|
|
844
|
+
display: inline-flex;
|
|
845
|
+
> button:last-child {
|
|
846
|
+
border: none;
|
|
847
|
+
}
|
|
848
|
+
`,MacroControlGroupDivider=styled.div`
|
|
849
|
+
background: var(--border_color_icon);
|
|
850
|
+
width: 1px;
|
|
851
|
+
height: 80%;
|
|
852
|
+
margin: 0 10px;
|
|
853
|
+
`,MacroEditControls=({isFullscreen:e,isRecording:t,recordingToggleChange:r,hasUnsavedChanges:s,undoChanges:a,saveChanges:l,recordDelays:c,toggleRecordDelays:d,optimizeRecording:p,toggleOptimizeRecording:f,isEmpty:m,deleteMacro:y,toggleFullscreen:K,isDelaySupported:x})=>{const{t:v}=useTranslation(),M=jsxs(IconButtonContainer,{onClick:()=>{r(!t)},disabled:!e,children:[jsx(FontAwesomeIcon,{size:"sm",color:"var(--color_label)",icon:t?faSquare:faCircle}),jsx(IconButtonTooltip,{children:v(e?t?"Stop Recording":"Record Keystrokes":"Can only record when fullscreen")})]});return jsxs(MacroEditControlsContainer,{children:[s?jsx(Fragment,{children:t?null:jsxs(Fragment,{children:[jsxs(MacroControlGroupContainer,{children:[jsxs(IconButtonContainer,{disabled:!s||t,onClick:a,children:[jsx(FontAwesomeIcon,{size:"sm",color:"var(--color_label)",icon:faUndo}),jsx(IconButtonTooltip,{children:v("Undo Changes")})]}),jsxs(IconButtonContainer,{disabled:!s||t,onClick:()=>l(),children:[jsx(FontAwesomeIcon,{size:"sm",color:"var(--color_label)",icon:faSave}),jsx(IconButtonTooltip,{children:v("Save Changes")})]})]}),jsx(MacroControlGroupDivider,{})]})}):m?jsx(Fragment,{}):jsxs(Fragment,{children:[jsx(MacroControlGroupContainer,{children:jsxs(IconButtonContainer,{disabled:s||t,onClick:y,children:[jsx(FontAwesomeIcon,{size:"sm",color:"var(--color_label)",icon:faTrash}),jsx(IconButtonTooltip,{children:v("Delete Macro")})]})}),jsx(MacroControlGroupDivider,{})]}),jsxs(MacroControlGroupContainer,{children:[M,jsxs(IconButtonContainer,{onClick:K,children:[jsx(FontAwesomeIcon,{size:"sm",color:"var(--color_label)",icon:e?faCompress:faExpand}),jsx(IconButtonTooltip,{children:v(e?"Exit Fullscreen":"Fullscreen")})]})]}),t?null:jsxs(Fragment,{children:[jsx(MacroControlGroupDivider,{}),jsxs(MacroControlGroupContainer,{children:[jsxs(IconToggleContainer,{$selected:p,onClick:f,children:[jsx(FontAwesomeIcon,{size:"sm",icon:faMagicWandSparkles}),jsx(IconButtonTooltip,{children:v(p?"Skip Smart Optimization":"Use Smart Optimization")})]}),jsxs(IconToggleContainer,{disabled:!x,$selected:c,onClick:d,children:[jsx(FontAwesomeIcon,{size:"sm",icon:faStopwatch,className:"fa-stack-1x"}),jsx(IconButtonTooltip,{children:v(x?c?"Skip Recording Delays":"Record Delays":"Upgrade firmware to use delays")})]})]})]})]})},DeletableContainer=styled.div`
|
|
854
|
+
display: inline-flex;
|
|
855
|
+
vertical-align: middle;
|
|
856
|
+
position: relative;
|
|
857
|
+
svg {
|
|
858
|
+
color: var(--bg_icon-highlighted);
|
|
859
|
+
position: absolute;
|
|
860
|
+
right: -5px;
|
|
861
|
+
top: 6px;
|
|
862
|
+
opacity: 0;
|
|
863
|
+
cursor: pointer;
|
|
864
|
+
transition: transform 0.2s ease-in-out;
|
|
865
|
+
background: var(--bg_icon);
|
|
866
|
+
border-radius: 50%;
|
|
867
|
+
transform: scale(0.8);
|
|
868
|
+
}
|
|
869
|
+
&:hover svg {
|
|
870
|
+
opacity: 1;
|
|
871
|
+
transform: scale(1);
|
|
872
|
+
}
|
|
873
|
+
`,Deletable=e=>jsxs(DeletableContainer,{style:{pointerEvents:e.disabled?"none":"all"},children:[e.children,jsx(FontAwesomeIcon,{icon:faXmarkCircle,size:"lg",onClick:()=>e.deleteItem(e.index)})]}),pipeline=(e,...t)=>t.reduce((r,s)=>s(r),e),NoMacroRecorded=styled.div`
|
|
874
|
+
font-style: italic;
|
|
875
|
+
color: var(--color_label-highlighted);
|
|
876
|
+
`,MacroSequenceContainer=styled.div`
|
|
877
|
+
max-width: 960px;
|
|
878
|
+
width: 100%;
|
|
879
|
+
display: block;
|
|
880
|
+
border: 1px solid var(--border_color_cell);
|
|
881
|
+
border-style: ${e=>e.$isModified?"dashed":"solid"};
|
|
882
|
+
padding: 30px 20px;
|
|
883
|
+
border-radius: 15px;
|
|
884
|
+
margin-top: 10px;
|
|
885
|
+
box-sizing: border-box;
|
|
886
|
+
}
|
|
887
|
+
`,componentJoin=(e,t)=>e.reduce((r,s,a)=>(a&&r.push({...t,key:a}),r.push(s),r),[]),KeycodeMap=getKeycodes().flatMap(e=>e.keycodes).reduce((e,t)=>({...e,[t.code]:t}),{}),optimizeKeycodeSequence=e=>pipeline(e,convertCharacterTaps,trimLastWait,mergeConsecutiveWaits,foldKeydownKeyupKeys,convertToCharacterStreams),cleanKeycodeSequence=e=>pipeline(e,mergeConsecutiveWaits),MacroRecorder=({selectedMacro:e,setUnsavedMacro:t,saveMacro:r,undoMacro:s,isDelaySupported:a})=>{const{t:l}=useTranslation(),[c,d]=reactExports.useState(!0),[p,f]=reactExports.useState(!1),[m,y]=reactExports.useState(!1),[K,x]=reactExports.useState(!!document.fullscreenElement),{smartOptimizeEnabled:v,recordDelaysEnabled:M}=useAppSelector(getMacroEditorSettings),b=useDispatch(),[R,O]=useKeycodeRecorder(p,M),I=reactExports.useRef(null),k=reactExports.useCallback(async q=>{f(q),q?(await navigator.keyboard.lock(),O([]),d(!1),y(!0)):(navigator.keyboard.unlock(),v&&O(optimizeKeycodeSequence(R)),y(!1))},[R,f]),F=reactExports.useCallback(()=>{r(""),d(!0),y(!1)},[O,r]),V=reactExports.useCallback(()=>{s(),O([]),d(!0),y(!1)},[s]);reactExports.useEffect(()=>{d(!0),y(!1),O([])},[e]);const $=()=>[...c?e??[]:R],z=reactExports.useMemo(()=>{let q,T=$();return c||!m||!v?q=T:q=optimizeKeycodeSequence(T),q},[R,c,v,m,e]);reactExports.useEffect(()=>{z&&t(sequenceToExpression(z))},[z]);const X=reactExports.useCallback(()=>{c&&d(!1)},[c]),L=reactExports.useCallback(q=>{const T=$();T.splice(q,1),O(cleanKeycodeSequence(T)),X()},[z,e,R,c]),H=reactExports.useCallback((q,T)=>{const j=$();j.splice(q,1,[RawKeycodeSequenceAction.Delay,T]),O(cleanKeycodeSequence(j)),X()},[z,e,R,c]),B=reactExports.useMemo(()=>componentJoin(z.map(([q,T],j)=>{const te=getSequenceItemComponent(q);return jsx(Deletable,{index:j,deleteItem:L,disabled:p,children:RawKeycodeSequenceAction.Delay!==q?jsx(te,{children:q===RawKeycodeSequenceAction.CharacterStream?componentJoin(String(T).split(" ").map((re,de)=>jsx("span",{children:re},de)),jsx("span",{style:{fontFamily:"fantasy, cursive, monospace"},children:"โฃ"})):Array.isArray(T)?T.map(re=>getSequenceLabel(KeycodeMap[re])??re).join(" + "):getSequenceLabel(KeycodeMap[T])}):jsx(WaitInput,{index:j,value:Number(T),updateValue:H})},`${j}-${q}`)}),jsx(SequenceLabelSeparator,{})),[z]);reactExports.useEffect(()=>{const q=()=>{x(!!document.fullscreenElement)};return document.documentElement.addEventListener("fullscreenchange",q),()=>{k(!1),document.documentElement.removeEventListener("fullscreenchange",q)}},[x]);const Q=reactExports.useCallback(()=>{document.fullscreenElement?document.exitFullscreen&&(k(!1),document.exitFullscreen()):document.documentElement.requestFullscreen()},[k]);return jsxs(Fragment,{children:[jsx(MacroSequenceContainer,{ref:I,$isModified:!c,children:B.length?B:jsx(NoMacroRecorded,{children:l("No macro recorded yet...")})}),jsx("div",{style:{border:"none",maxWidth:960,width:"100%",display:"flex",justifyContent:"center",transform:"translate(-0px, -21px)"},children:jsx(MacroEditControls,{isFullscreen:K,isEmpty:!e||!e.length,optimizeRecording:v,recordDelays:M,isRecording:p,addText:()=>{},deleteMacro:F,toggleOptimizeRecording:()=>{b(setMacroEditorSettings({smartOptimizeEnabled:!v}))},toggleRecordDelays:()=>{b(setMacroEditorSettings({recordDelaysEnabled:!M}))},toggleFullscreen:Q,undoChanges:V,saveChanges:()=>r(),hasUnsavedChanges:!c,recordingToggleChange:k,isDelaySupported:a})})]})},TextArea=styled.textarea`
|
|
888
|
+
box-sizing: border-box;
|
|
889
|
+
background: var(--bg_control);
|
|
890
|
+
padding: 5px 10px;
|
|
891
|
+
border-color: var(--border_color_icon);
|
|
892
|
+
color: var(--color_label);
|
|
893
|
+
width: 100%;
|
|
894
|
+
height: 200px;
|
|
895
|
+
font-size: 16px;
|
|
896
|
+
line-height: 18px;
|
|
897
|
+
resize: none;
|
|
898
|
+
font-family: 'Source Code Pro';
|
|
899
|
+
font-weight: 500;
|
|
900
|
+
&::placeholder {
|
|
901
|
+
color: var(--color_label);
|
|
902
|
+
}
|
|
903
|
+
&:focus {
|
|
904
|
+
color: var(--color_accent);
|
|
905
|
+
outline-color: var(--color_accent);
|
|
906
|
+
}
|
|
907
|
+
`,ToastErrorMessage=styled(ErrorMessage)`
|
|
908
|
+
margin: 0;
|
|
909
|
+
width: 100%;
|
|
910
|
+
font-size: 14px;
|
|
911
|
+
display: block;
|
|
912
|
+
&:empty {
|
|
913
|
+
display: none;
|
|
914
|
+
}
|
|
915
|
+
`,Message=styled.div`
|
|
916
|
+
color: var(--color_accent);
|
|
917
|
+
`,Link=styled.a`
|
|
918
|
+
font-size: 18x !important;
|
|
919
|
+
color: var(--color_accent);
|
|
920
|
+
text-decoration: underline;
|
|
921
|
+
`,DescriptionLabel=styled(Label$1)`
|
|
922
|
+
margin: 1em 0;
|
|
923
|
+
font-size: 14px;
|
|
924
|
+
line-height: 18px;
|
|
925
|
+
font-style: oblique;
|
|
926
|
+
padding-left: 5px;
|
|
927
|
+
`,AutoHeightRow=styled(ControlRow)`
|
|
928
|
+
height: auto;
|
|
929
|
+
`,ScriptMode=({macro:e,protocol:t,setUnsavedMacro:r,saveMacros:s,macroIndex:a,isDelaySupported:l})=>{const{t:c}=useTranslation(),d=e.trimEnd(),[p,f]=React.useState(d),[m,y]=React.useState(void 0);reactExports.useEffect(()=>{r(p)},[p]);const K=()=>{const M=getMacroValidator(t)(p);M.isValid?(s(p),y(void 0)):y(M.errorMessage)};return jsxs(Fragment,{children:[jsx(AutoHeightRow,{children:jsx(ReactTextareaAutocomplete,{value:p,onChange:v=>f(v.target.value),loadingComponent:AutocompleteLoading,style:{fontSize:"16px",lineHeight:"18px",width:"100%",height:"140px",fontFamily:"monospace",resize:"none",borderColor:m!==void 0?"var(--color_error)":"var(--border_color_icon)"},containerStyle:{border:"none",lineHeight:"20px"},itemStyle:{borderColor:"var(--border_color_cell)",backgroundColor:"var(--bg_menu)"},dropdownStyle:{zIndex:999,backgroundColor:"var(--bg_menu)"},listStyle:{position:"fixed",backgroundColor:"var(--bg_menu)",maxHeight:"210px",overflow:"auto",border:"1px solid var(--border_color_cell)"},minChar:0,textAreaComponent:TextArea,movePopupAsYouType:!0,placeholder:`Enter the macro you want M${a} to execute...`,trigger:{"?":{dataProvider:findKeycodes,component:AutocompleteItem,output:v=>({text:v.code,caretPosition:"end"})},"{":{dataProvider:findKeycodes,component:AutocompleteItem,output:v=>({text:`{${v.code},`,caretPosition:"end"})},",":{dataProvider:findKeycodes,component:AutocompleteItem,output:v=>({text:`,${v.code},`,caretPosition:"end"})}}})}),jsxs(AutoHeightRow,{children:[jsxs(DescriptionLabel,{children:[jsx(ToastErrorMessage,{children:m}),jsxs(Message,{children:[c("Enter text directly, or wrap")," ",jsx(Link,{href:"https://docs.qmk.fm/#/keycodes_basic",target:"_blank",children:c("Basic Keycodes")})," ",c("in")," ","{}"]}),jsxs(Message,{children:[c("Single tap"),": ","{KC_XXX}"]}),jsxs(Message,{children:[c("Chord"),": ","{KC_XXX, KC_YYY, KC_ZZZ}"]}),jsxs(Message,{children:[c("Keydown"),": ","{+KC_XXX}"]}),jsxs(Message,{children:[c("Keyup"),": ","{-KC_XXX}"]}),l?jsxs(Message,{children:[c("Delay")," (ms): ","{NNNN}"," "]}):"Upgrade firmware to use delays",jsx(Message,{children:c("Type ? to search for keycodes")})]}),jsx(Detail,{children:jsx(AccentButton,{disabled:e===p,onClick:K,children:"Save"})})]})]})},ProgressBarContainer$1=styled.div`
|
|
930
|
+
position: relative;
|
|
931
|
+
margin-top: 10px;
|
|
932
|
+
&:hover {
|
|
933
|
+
& .tooltip {
|
|
934
|
+
transform: scale(1) translateY(0px);
|
|
935
|
+
opacity: 1;
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
.tooltip {
|
|
939
|
+
transform: translateY(5px) scale(0.6);
|
|
940
|
+
opacity: 0;
|
|
941
|
+
}
|
|
942
|
+
`,ProgressBar$1=styled.div`
|
|
943
|
+
background: var(--bg_control);
|
|
944
|
+
position: relative;
|
|
945
|
+
padding: 5px;
|
|
946
|
+
border-radius: 5px;
|
|
947
|
+
overflow: hidden;
|
|
948
|
+
margin-bottom: 10px;
|
|
949
|
+
cursor: pointer;
|
|
950
|
+
width: 250px;
|
|
951
|
+
|
|
952
|
+
> span {
|
|
953
|
+
content: '';
|
|
954
|
+
position: absolute;
|
|
955
|
+
left: 0;
|
|
956
|
+
top: 0;
|
|
957
|
+
background: var(--color_accent);
|
|
958
|
+
height: 10px;
|
|
959
|
+
width: 100%;
|
|
960
|
+
transform: scaleX(0.1);
|
|
961
|
+
transform-origin: left;
|
|
962
|
+
transition: transform 0.4s ease-in-out;
|
|
963
|
+
}
|
|
964
|
+
`,MacroTab=styled.span`
|
|
965
|
+
display: inline-flex;
|
|
966
|
+
border: 1px solid;
|
|
967
|
+
line-height: initial;
|
|
968
|
+
border-top: none;
|
|
969
|
+
padding: 8px;
|
|
970
|
+
border-bottom-left-radius: 6px;
|
|
971
|
+
border-bottom-right-radius: 6px;
|
|
972
|
+
min-width: 38px;
|
|
973
|
+
justify-content: center;
|
|
974
|
+
box-sizing: border-box;
|
|
975
|
+
color: ${e=>e.$selected?"var(--color_accent)":"var(--bg_icon)"};
|
|
976
|
+
cursor: pointer;
|
|
977
|
+
&:hover {
|
|
978
|
+
color: ${e=>e.$selected?"var(--color_accent)":"var(--bg_icon-highlighted)"};
|
|
979
|
+
}
|
|
980
|
+
`,TabBar=styled.div`
|
|
981
|
+
display: flex;
|
|
982
|
+
column-gap: 10px;
|
|
983
|
+
`,TabContainer=styled.div`
|
|
984
|
+
display: flex;
|
|
985
|
+
margin-bottom: 10px;
|
|
986
|
+
width: 100%;
|
|
987
|
+
max-width: 960px;
|
|
988
|
+
`,CenterTabContainer=styled(TabContainer)`
|
|
989
|
+
justify-content: center;
|
|
990
|
+
`,printBytesUsed=(e,t)=>{const{t:r}=useTranslation(),s=["Bytes","kB","MB","GB"],a=Math.floor(Math.log10(t)/3),l=s[a],c=a===0?1:Math.pow(1e3,a),d=e/c,p=t/c;return`${d.toFixed(a)} / ${p.toFixed(a)} ${l} ${r("space used")}`},BufferSizeUsage=()=>{const e=useAppSelector(d=>d.macros.ast),t=useAppSelector(getMacroBufferSize),r=useAppSelector(getSelectedConnectedDevice),s=useAppSelector(getSelectedKeyboardAPI);if(!r||!s)return null;const{protocol:a}=r,c=getMacroAPI(a,s).rawKeycodeSequencesToMacroBytes(e).length;return jsxs(ProgressBarContainer$1,{children:[jsx(ProgressBar$1,{children:jsx("span",{style:{transform:`scaleX(${c/t})`}})}),jsx(ProgressBarTooltip,{children:printBytesUsed(c,t)})]})},MacroDetailPane=e=>{const t=e.macroExpressions[e.selectedMacro]||"",[r,s]=React.useState(!1),a=useAppSelector(m=>m.macros.ast),l=useAppSelector(getIsDelaySupported),[c,d]=reactExports.useState(t);reactExports.useEffect(()=>{d(t)},[t]);const p=reactExports.useCallback(()=>{d(t)},[t]),f=reactExports.useCallback(m=>{m!==void 0?(e.saveMacros(""),d("")):c!==t&&(e.saveMacros(c),d(c))},[c]);return jsxs(Fragment,{children:[jsx(CenterTabContainer,{children:jsxs(TabBar,{children:[jsx(MacroTab,{$selected:!r,onClick:()=>s(!1),children:jsx(FontAwesomeIcon,{icon:faClapperboard})}),jsx(MacroTab,{$selected:r,onClick:()=>s(!0),children:jsx(FontAwesomeIcon,{icon:faCode})})]})}),jsx(BufferSizeUsage,{}),r?jsx(ScriptMode,{macro:t,macroIndex:e.selectedMacro,protocol:e.protocol,isDelaySupported:l,setUnsavedMacro:d,saveMacros:e.saveMacros},e.selectedMacro):jsx(MacroRecorder,{selectedMacro:a[e.selectedMacro],setUnsavedMacro:d,undoMacro:p,saveMacro:f,isDelaySupported:l})]})},MacroPane=styled(CenterPane)`
|
|
991
|
+
height: 100%;
|
|
992
|
+
background: var(--color_dark_grey);
|
|
993
|
+
`,Container$i=styled.div`
|
|
994
|
+
display: flex;
|
|
995
|
+
align-items: center;
|
|
996
|
+
flex-direction: column;
|
|
997
|
+
padding: 12px;
|
|
998
|
+
padding-top: 0;
|
|
999
|
+
`,MenuContainer$3=styled.div`
|
|
1000
|
+
padding: 15px 10px 20px 10px;
|
|
1001
|
+
`,Pane$6=()=>{const e=useAppDispatch(),t=useAppSelector(getSelectedConnectedDevice),r=useAppSelector(getExpressions),s=useAppSelector(getMacroCount),[a,l]=reactExports.useState(0),c=reactExports.useCallback(async p=>{if(!t)return;const f=r.map((m,y)=>y===a?p:m);e(saveMacros(t,f))},[r,saveMacros,e,t,a]),d=reactExports.useMemo(()=>Array(s).fill(0).map((p,f)=>f).map(p=>jsx(SubmenuRow,{$selected:a===p,onClick:()=>l(p),style:{borderWidth:0,textAlign:"center"},children:`M${p}`},p)),[a,s]);return t?jsxs(Fragment,{children:[jsx(SubmenuOverflowCell,{children:jsx(MenuContainer$3,{children:d})}),jsx(OverflowCell,{children:jsx(MacroPane,{children:jsx(Container$i,{children:jsx(MacroDetailPane,{macroExpressions:r,selectedMacro:a,saveMacros:c,protocol:t?t.protocol:-1})})})})]}):null},Icon$6=component$2,Title$8=title$5,Macros=Object.freeze(Object.defineProperty({__proto__:null,Icon:Icon$6,Pane:Pane$6,Title:Title$8},Symbol.toStringTag,{value:"Module"}));function AccentUploadButton(e){const t=e.inputRef||React.useRef();function r(s){e.onLoad(s.target.files),t.current.value=null}return jsxs(AccentButton,{onClick:()=>t.current&&t.current.click(),children:[e.children,jsx("input",{ref:t,type:"file",multiple:e.multiple,accept:"application/json",style:{display:"none"},onChange:r})]})}const deprecatedKeycodes={KC_TILD:"S(KC_GRV)",KC_EXLM:"S(KC_1)",KC_AT:"S(KC_2)",KC_HASH:"S(KC_3)",KC_DLR:"S(KC_4)",KC_PERC:"S(KC_5)",KC_CIRC:"S(KC_6)",KC_AMPR:"S(KC_7)",KC_ASTR:"S(KC_8)",KC_LPRN:"S(KC_9)",KC_RPRN:"S(KC_0)",KC_UNDS:"S(KC_MINS)",KC_PLUS:"S(KC_EQL)",KC_LCBR:"S(KC_LBRC)",KC_RCBR:"S(KC_RBRC)",KC_PIPE:"S(KC_BSLS)",KC_COLN:"S(KC_SCLN)",KC_DQUO:"S(KC_QUOT)",KC_LT:"S(KC_COMM)",KC_GT:"S(KC_DOT)",KC_QUES:"S(KC_SLSH)",SPC_FN1:"LT(1,KC_SPC)",SPC_FN2:"LT(2,KC_SPC)",SPC_FN3:"LT(3,KC_SPC)",MACRO00:"MACRO(0)",MACRO01:"MACRO(1)",MACRO02:"MACRO(2)",MACRO03:"MACRO(3)",MACRO04:"MACRO(4)",MACRO05:"MACRO(5)",MACRO06:"MACRO(6)",MACRO07:"MACRO(7)",MACRO08:"MACRO(8)",MACRO09:"MACRO(9)",MACRO10:"MACRO(10)",MACRO11:"MACRO(11)",MACRO12:"MACRO(12)",MACRO13:"MACRO(13)",MACRO14:"MACRO(14)",MACRO15:"MACRO(15)",USER00:"CUSTOM(0)",USER01:"CUSTOM(1)",USER02:"CUSTOM(2)",USER03:"CUSTOM(3)",USER04:"CUSTOM(4)",USER05:"CUSTOM(5)",USER06:"CUSTOM(6)",USER07:"CUSTOM(7)",USER08:"CUSTOM(8)",USER09:"CUSTOM(9)",USER10:"CUSTOM(10)",USER11:"CUSTOM(11)",USER12:"CUSTOM(12)",USER13:"CUSTOM(13)",USER14:"CUSTOM(14)",USER15:"CUSTOM(15)"},title$4="Save + Load",component$1=()=>jsx(FontAwesomeIcon,{icon:faFloppyDisk}),isViaSaveFile=e=>e&&e.name&&e.layers&&e.vendorProductId,SaveLoadPane=styled(CenterPane)`
|
|
1002
|
+
height: 100%;
|
|
1003
|
+
background: var(--color_dark_grey);
|
|
1004
|
+
`,Container$h=styled.div`
|
|
1005
|
+
display: flex;
|
|
1006
|
+
align-items: center;
|
|
1007
|
+
flex-direction: column;
|
|
1008
|
+
padding: 0 12px;
|
|
1009
|
+
`,Pane$5=()=>{var V;const{t:e}=useTranslation(),t=useAppDispatch(),r=useAppSelector(getSelectedDefinition),s=useAppSelector(getSelectedConnectedDevice),a=useAppSelector(getSelectedKeyboardAPI),l=useAppSelector(getSelectedRawLayers),c=useAppSelector($=>$.macros),d=useAppSelector(getExpressions),{basicKeyToByte:p,byteToKey:f}=useAppSelector(getBasicKeyToByte),m=useAppSelector(getSelectedDevicePath),y=(V=useAppSelector(getSelectedTabkbConfig))==null?void 0:V.actuation,K=useAppSelector(getActuationMap),x=useAppSelector(getDksmap),v=useAppSelector(getEnableAP);if(!r||!s||!a||!m)return null;const[M,b]=reactExports.useState(null),[R,O]=reactExports.useState(null),I=async()=>{const{layouts:$}=r,{keys:z,optionKeys:X}=$,L=[...z,...Object.values(X).flatMap(H=>Object.values(H)).flat()].filter(H=>"ei"in H).map(H=>H.ei);if(L.length>0){const H=Math.max(...L)+1,B=l.length;return await Promise.all(Array(H).fill(0).map((q,T)=>Promise.all(Array(B).fill(0).map((j,te)=>Promise.all([a.getEncoderValue(te,T,!1),a.getEncoderValue(te,T,!0)]).then(re=>re.map(de=>getCodeForByte(de,p,f)||""))))))}else return[]},k=async()=>{const{name:$,vendorProductId:z}=r,X=$.replace(/[^a-zA-Z0-9]/g,"_").toLowerCase()+".layout.json";try{const L=await window.showSaveFilePicker({suggestedName:X}),H=await I(),B={name:$,vendorProductId:z,macros:[...d],layers:l.map(j=>j.keymap.map(te=>getCodeForByte(te,p,f)||"")),encoders:H};y&&(B.actuation={apEnabled:v,ap:K[m]?K[m].map((j,te)=>j.apData?[te,j.apData.ap,j.apData.dzt,j.apData.dzb]:null).filter(j=>j!==null):[],rt:K[m]?K[m].map((j,te)=>j.rtData?[te,Number(j.rtData.enabled),Number(j.rtData.crtEnabled),j.rtData.rt1,j.rtData.rt2]:null).filter(j=>j!==null):[],dks:x[m]?x[m].flatMap((j,te)=>j===null?null:j.map((re,de)=>re===null?null:[te,de,...re.actuation,...re.actions.flatMap(fe=>[fe.key,...fe.points.map(Ee=>Ee)])]).filter(re=>re!==null)).filter(j=>j!==null):[]});const Q=stringify(B),q=new Blob([Q],{type:"application/json"}),T=await L.createWritable();await T.write(q),await T.close()}catch{console.log("User cancelled save file request")}},F=([$])=>{b(null),O(null);const z=new FileReader;z.onabort=()=>b(e("File reading was cancelled.")),z.onerror=()=>b(e("Failed to read file.")),z.onload=async()=>{const X=JSON.parse(z.result.toString());if(!isViaSaveFile(X)){b(e("Could not load file: invalid data."));return}if(X.vendorProductId!==r.vendorProductId){b(`${e("Could not import layout. This file was created for a different keyboard")}: ${X.name}`);return}if(X.layers.findIndex((H,B)=>H.length!==l[B].keymap.length)>-1){b(e("Could not import layout: incorrect number of keys in one or more layers."));return}if(c.isFeatureSupported&&X.macros){if(X.macros.length!==d.length){b(e("Could not import layout: incorrect number of macros."));return}t(saveMacros(s,X.macros))}y&&X.actuation&&await t(saveConfigToDevice(X.actuation));const L=X.layers.map(H=>H.map(B=>getByteForCode(`${deprecatedKeycodes[B]??B}`,p)));await t(saveRawKeymapToDevice(L,s)),X.encoders&&await Promise.all(X.encoders.map((H,B)=>Promise.all(H.map((Q,q)=>Promise.all([a.setEncoderValue(q,B,!1,getByteForCode(`${deprecatedKeycodes[Q[0]]??Q[0]}`,p)),a.setEncoderValue(q,B,!0,getByteForCode(`${deprecatedKeycodes[Q[1]]??Q[1]}`,p))]))))),O(e("Successfully updated layout!"))},z.readAsBinaryString($)};return jsx(SpanOverflowCell,{children:jsx(SaveLoadPane,{children:jsxs(Container$h,{children:[jsxs(ControlRow,{children:[jsx(Label$1,{children:e("Save Current Layout")}),jsx(Detail,{children:jsx(AccentButton,{onClick:k,children:e("Save")})})]}),jsxs(ControlRow,{children:[jsx(Label$1,{children:e("Load Saved Layout")}),jsx(Detail,{children:jsx(AccentUploadButton,{onLoad:F,children:e("Load")})})]}),M?jsx(ErrorMessage,{children:M}):null,R?jsx(SuccessMessage,{children:R}):null]})})})},Icon$5=component$1,Title$7=title$4,SaveLoad=Object.freeze(Object.defineProperty({__proto__:null,Icon:Icon$5,Pane:Pane$5,Title:Title$7},Symbol.toStringTag,{value:"Module"})),SvgIcKeyboard24Px=e=>jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",children:[jsx("path",{d:"M0 0h24v24H0z",fill:"none"}),jsx("path",{d:"M3 13h8V3H3v10zm0 8h8v-6H3v6zm10 0h8V11h-8v10zm0-18v6h8V3h-8z",fill:"currentColor"})]}),title$3="Layouts",component=SvgIcKeyboard24Px,LayoutControl=e=>{const{t}=useTranslation(),{onChange:r,meta:s}=e,{labels:a,selectedOption:l}=s;if(Array.isArray(a)){const[c,...d]=a,p=d.map((f,m)=>({label:t(f),value:`${m}`}));return jsxs(ControlRow,{children:[jsx(Label$1,{children:t(c)}),jsx(Detail,{children:jsx(AccentSelect,{defaultValue:p[l],options:p,onChange:f=>{f&&r(+f.value)}})})]})}else return jsxs(ControlRow,{children:[jsx(Label$1,{children:t(a)}),jsx(Detail,{children:jsx(AccentSlider,{isChecked:!!l,onChange:c=>r(+c)})})]})},ContainerPane=styled(CenterPane)`
|
|
1010
|
+
height: 100%;
|
|
1011
|
+
background: var(--color_dark_grey);
|
|
1012
|
+
`,Container$g=styled.div`
|
|
1013
|
+
display: flex;
|
|
1014
|
+
align-items: center;
|
|
1015
|
+
flex-direction: column;
|
|
1016
|
+
padding: 0 12px;
|
|
1017
|
+
`,Pane$4=()=>{const e=useAppDispatch(),t=useAppSelector(getSelectedDefinition),r=useAppSelector(getSelectedLayoutOptions);if(!t||!r)return null;const{layouts:s}=t,a=s.labels||[];return jsx(SpanOverflowCell,{children:jsx(ContainerPane,{children:jsx(Container$g,{children:a.map((l,c)=>jsx(LayoutControl,{onChange:d=>e(updateLayoutOption(c,d)),meta:{labels:l,selectedOption:r[c]}},c))})})})},Title$6=title$3,Icon$4=component,Layouts$1=Object.freeze(Object.defineProperty({__proto__:null,Icon:Icon$4,Pane:Pane$4,Title:Title$6},Symbol.toStringTag,{value:"Module"})),GET_KEYBOARD_VALUE=2,SET_KEYBOARD_VALUE=3,KB_VALUES={ENABLED_ENCODER_MODES:128,OLED_DEFAULT_MODE:129,ENCODER_CUSTOM:130,OLED_MODE:131},getEncoderModes=async e=>{const t=[KB_VALUES.ENABLED_ENCODER_MODES],[,,r]=await e.hidCommand(GET_KEYBOARD_VALUE,t);return r},setEncoderModes=async(e,t)=>{const r=[KB_VALUES.ENABLED_ENCODER_MODES,t];await e.hidCommand(SET_KEYBOARD_VALUE,r)},getDefaultOLED=async e=>{const t=[KB_VALUES.OLED_DEFAULT_MODE],[,,r]=await e.hidCommand(GET_KEYBOARD_VALUE,t);return r},setDefaultOLED=async(e,t)=>{const r=[KB_VALUES.OLED_DEFAULT_MODE,t];await e.hidCommand(SET_KEYBOARD_VALUE,r)},getOLEDMode=async e=>{const t=[KB_VALUES.OLED_MODE],[,,r]=await e.hidCommand(GET_KEYBOARD_VALUE,t);return r},setOLEDMode=async(e,t)=>{const r=[KB_VALUES.OLED_MODE,t];await e.hidCommand(SET_KEYBOARD_VALUE,r)},getCustomEncoderConfig=async(e,t)=>{const r=[KB_VALUES.ENCODER_CUSTOM,t],s=await e.hidCommand(GET_KEYBOARD_VALUE,r),[,,,a,l,c,d,p,f]=s;return[a<<8|l,c<<8|d,p<<8|f]},setCustomEncoderConfig=async(e,t,r,s)=>{const a=(s&65280)>>8,l=s&255,c=[KB_VALUES.ENCODER_CUSTOM,t,r,a,l];await e.hidCommand(SET_KEYBOARD_VALUE,c)},MODES={ENC_MODE_VOLUME:0,ENC_MODE_MEDIA:1,ENC_MODE_SCROLL:2,ENC_MODE_BRIGHTNESS:3,ENC_MODE_BACKLIGHT:4,ENC_MODE_CUSTOM0:5,ENC_MODE_CUSTOM1:6,ENC_MODE_CUSTOM2:7},MODE_LABELS={ENC_MODE_VOLUME:"Volume",ENC_MODE_MEDIA:"Media",ENC_MODE_SCROLL:"Scroll",ENC_MODE_BRIGHTNESS:"Brightness",ENC_MODE_BACKLIGHT:"Backlight",ENC_MODE_CUSTOM0:"Custom 0",ENC_MODE_CUSTOM1:"Custom 1",ENC_MODE_CUSTOM2:"Custom 2"},CenteredColumnDiv=styled.div`
|
|
1018
|
+
display: flex;
|
|
1019
|
+
flex-direction: column;
|
|
1020
|
+
align-items: center;
|
|
1021
|
+
`,ColumnDiv=styled.div`
|
|
1022
|
+
display: flex;
|
|
1023
|
+
flex-direction: column;
|
|
1024
|
+
`;class EncoderModeToggle extends React.Component{constructor(){super(...arguments);ie(this,"handleInputChange",r=>{const{enabledModes:s,onChange:a}=this.props,{target:{checked:l,name:c}}=r,d=1<<MODES[c],p=l?s|d:s&~d;a(p)});ie(this,"isChecked",r=>(1<<r&this.props.enabledModes)>0)}render(){return jsxs(CenteredColumnDiv,{children:[jsx("h3",{children:"Enabled Encoder Modes:"}),jsx("p",{children:"Only the selected encoder modes will be available on the keyboard"}),jsx(ColumnDiv,{children:Object.entries(MODES).map(([r,s])=>jsxs("label",{htmlFor:MODE_LABELS[r],children:[jsx("input",{name:r,id:MODE_LABELS[r],type:"checkbox",checked:this.isChecked(s),onChange:this.handleInputChange},s),MODE_LABELS[r]]},s))})]})}}const NormalInput=styled.input`
|
|
1025
|
+
border: none;
|
|
1026
|
+
border-bottom: 1px solid var(--bg_control);
|
|
1027
|
+
color: var(--color_accent);
|
|
1028
|
+
background: var(--bg_menu);
|
|
1029
|
+
transition: all 0.4s ease-out;
|
|
1030
|
+
font-size: 18px;
|
|
1031
|
+
margin-bottom: 25px;
|
|
1032
|
+
height: 30px;
|
|
1033
|
+
padding: 0 5px;
|
|
1034
|
+
&:focus {
|
|
1035
|
+
outline: none;
|
|
1036
|
+
color: var(--color_accent);
|
|
1037
|
+
border-color: var(--color_accent);
|
|
1038
|
+
}
|
|
1039
|
+
&::placeholder {
|
|
1040
|
+
color: var(--bg_control);
|
|
1041
|
+
}
|
|
1042
|
+
`,ErrorInput=styled(NormalInput)`
|
|
1043
|
+
border-color: #d15e5e;
|
|
1044
|
+
color: #d15e5e;
|
|
1045
|
+
`;class KeycodeTextInput extends React.Component{constructor(r){super(r);ie(this,"handleChange",r=>{const s=r.target.value;this.setState({currentValue:s})});ie(this,"handleBlur",r=>{const{onBlur:s,basicKeyToByte:a}=this.props,{lastDefault:l}=this.state,c=r.target.value.trim().toUpperCase(),d=advancedStringToKeycode(c,a);Object.keys(a).includes(c)?(l!==a[c]&&s(a[c]),this.setState({isError:!1})):d!==0?(l!==d&&s(d),this.setState({isError:!1})):new RegExp(/^0x[0-9A-Fa-f]{1,4}$/g).test(r.target.value.trim())?(s(parseInt(r.target.value.trim(),16)),this.setState({isError:!1})):this.setState({isError:!0})});const{defaultValue:s,basicKeyToByte:a,byteToKey:l}=r;let c=anyKeycodeToString(s,a,l);this.state={lastDefault:s,defaultValueAsString:c,currentParsed:s,currentValue:c,isError:!1}}static getDerivedStateFromProps(r,s){return s.lastDefault!==r.defaultValue&&s.currentParsed!==r.defaultValue?{...s,currentValue:anyKeycodeToString(r.defaultValue,r.basicKeyToByte,r.byteToKey),currentParsed:r.defaultValue,lastDefault:r.defaultValue}:s}render(){const{currentValue:r,isError:s}=this.state;return jsx(s?ErrorInput:NormalInput,{type:"text",placeholder:this.props.defaultValue?this.state.defaultValueAsString:"KC_NO, 0xFF, etc.",value:r,onChange:this.handleChange,onBlur:this.handleBlur,className:this.props.className})}}const RowDiv=styled.div`
|
|
1046
|
+
display: flex;
|
|
1047
|
+
flex-direction: row;
|
|
1048
|
+
margin-top: 4px;
|
|
1049
|
+
`,LabelText$1=styled.span`
|
|
1050
|
+
font-weight: 650;
|
|
1051
|
+
margin-right: 8px;
|
|
1052
|
+
width: 80px;
|
|
1053
|
+
`,KeyInput=styled(KeycodeTextInput)`
|
|
1054
|
+
width: 64px;
|
|
1055
|
+
margin-right: 8px;
|
|
1056
|
+
`,EncoderCustomConfig=e=>{const{encoderIdx:t,onChange:r,title:s,behaviors:[a,l,c]}=e,{basicKeyToByte:d,byteToKey:p}=useAppSelector(getBasicKeyToByte),f=(m,y)=>{r(t,y,m)};return jsxs(RowDiv,{children:[jsx(LabelText$1,{children:s}),jsx(KeyInput,{defaultValue:a,basicKeyToByte:d,byteToKey:p,onBlur:m=>f(m,0)}),jsx(KeyInput,{defaultValue:l,basicKeyToByte:d,byteToKey:p,onBlur:m=>f(m,1)}),jsx(KeyInput,{defaultValue:c,basicKeyToByte:d,byteToKey:p,onBlur:m=>f(m,2)})]})},MenuContainer$2=styled.div`
|
|
1057
|
+
display: flex;
|
|
1058
|
+
color: #717070;
|
|
1059
|
+
padding: 24px;
|
|
1060
|
+
font-family: GothamRounded;
|
|
1061
|
+
h3 {
|
|
1062
|
+
margin: 4px 0;
|
|
1063
|
+
}
|
|
1064
|
+
p {
|
|
1065
|
+
margin: 4px 0 8px 0;
|
|
1066
|
+
width: 288px;
|
|
1067
|
+
font-size: 13px;
|
|
1068
|
+
text-align: center;
|
|
1069
|
+
}
|
|
1070
|
+
`,SectionContainer=styled.div`
|
|
1071
|
+
display: flex;
|
|
1072
|
+
flex: 1;
|
|
1073
|
+
flex-direction: column;
|
|
1074
|
+
align-items: center;
|
|
1075
|
+
`,OLEDSelectContainer=styled.div`
|
|
1076
|
+
width: 156px;
|
|
1077
|
+
margin-bottom: 12px;
|
|
1078
|
+
`,CustomEncoderContainer=styled.div`
|
|
1079
|
+
padding-left: 112px;
|
|
1080
|
+
display: flex;
|
|
1081
|
+
flex-direction: row;
|
|
1082
|
+
`,LabelText=styled.span`
|
|
1083
|
+
font-weight: 650;
|
|
1084
|
+
margin-right: 8px;
|
|
1085
|
+
width: 64px;
|
|
1086
|
+
`,OLED_OPTIONS=[{value:0,label:"Default"},{value:1,label:"Time"},{value:2,label:"Off"}],SatisfactionMenu=()=>{const e=useAppSelector(getSelectedKeyboardAPI);return e?jsx(BaseSatisfactionMenu,{api:e}):null};class BaseSatisfactionMenu extends reactExports.Component{constructor(){super(...arguments);ie(this,"state",{enabledModes:31,defaultOLEDMode:0,currOLEDMode:0,encoderBehaviors:[[0,0,0],[0,0,0],[0,0,0]]});ie(this,"fetchDataAndSet",async()=>{const{api:r}=this.props,s=[getEncoderModes(r),getDefaultOLED(r),getOLEDMode(r),getCustomEncoderConfig(r,0),getCustomEncoderConfig(r,1),getCustomEncoderConfig(r,2)],[a,l,c,d,p,f]=await Promise.all(s);this.setState({enabledModes:a,defaultOLEDMode:l,currOLEDMode:c,encoderBehaviors:[d,p,f]})});ie(this,"onEncoderModeChange",r=>{const{api:s}=this.props,{enabledModes:a}=this.state;a!==r&&(this.setState({enabledModes:r}),setEncoderModes(s,r))});ie(this,"onEncoderCustomConfigChange",(r,s,a)=>{const{api:l}=this.props,c=[...this.state.encoderBehaviors];c[r][s]=a,this.setState({encoderBehaviors:c}),setCustomEncoderConfig(l,r,s,a)});ie(this,"onOLEDDefaultChange",r=>{const{value:s}=r,{api:a}=this.props,{defaultOLEDMode:l}=this.state;l!==s&&(this.setState({defaultOLEDMode:s}),setDefaultOLED(a,s))});ie(this,"onOLEDChange",r=>{const{value:s}=r,{api:a}=this.props,{currOLEDMode:l}=this.state;l!==s&&(this.setState({currOLEDMode:s}),setOLEDMode(a,s))})}componentDidMount(){this.fetchDataAndSet()}render(){const{api:r}=this.props,{enabledModes:s,defaultOLEDMode:a,currOLEDMode:l,encoderBehaviors:c}=this.state;return r?jsxs(MenuContainer$2,{children:[jsx(SectionContainer,{children:jsx(EncoderModeToggle,{onChange:this.onEncoderModeChange,enabledModes:s})}),jsxs(SectionContainer,{children:[jsx("h3",{children:"Default OLED Mode:"}),jsx("p",{children:"This is the OLED mode that will be selected by default when you plug in your keyboard."}),jsx(OLEDSelectContainer,{children:jsx(Select,{value:OLED_OPTIONS.find(d=>d.value===a),onChange:this.onOLEDDefaultChange,options:OLED_OPTIONS})}),jsx("h3",{children:"Current OLED Mode:"}),jsxs("p",{children:["Change your ","keyboard's"," current OLED mode"]}),jsx(OLEDSelectContainer,{children:jsx(Select,{value:OLED_OPTIONS.find(d=>d.value===l),onChange:this.onOLEDChange,options:OLED_OPTIONS,menuPlacement:"top"})})]}),jsxs(SectionContainer,{children:[jsx("h3",{children:"Custom Encoder Configuration:"}),jsx("p",{children:"Configure the behavior of encoder custom modes"}),jsxs(CustomEncoderContainer,{children:[jsx(LabelText,{children:"CW"}),jsx(LabelText,{children:"CCW"}),jsx(LabelText,{children:"Press"})]}),jsx(EncoderCustomConfig,{title:"Custom 0",encoderIdx:0,behaviors:c[0],onChange:this.onEncoderCustomConfigChange}),jsx(EncoderCustomConfig,{title:"Custom 1",encoderIdx:1,behaviors:c[1],onChange:this.onEncoderCustomConfigChange}),jsx(EncoderCustomConfig,{title:"Custom 2",encoderIdx:2,behaviors:c[2],onChange:this.onEncoderCustomConfigChange})]})]}):null}}const size$1=16.187,SvgIcMemory24Px=e=>jsx("svg",{width:size$1,height:size$1,...e,children:jsx("path",{d:"M10.791 5.4H5.4v5.4h5.4zM8.991 9h-1.8V7.2h1.8zm7.194-1.8V5.4h-1.8V3.6a1.8 1.8 0 00-1.8-1.8h-1.8V0h-1.8v1.8h-1.8V0H5.4v1.8H3.6a1.8 1.8 0 00-1.8 1.8v1.8H0v1.8h1.8V9H0v1.8h1.8v1.8a1.8 1.8 0 001.8 1.8h1.8v1.8h1.8v-1.8H9v1.8h1.8v-1.8h1.8a1.8 1.8 0 001.8-1.8v-1.8h1.8V9h-1.8V7.2zm-3.6 5.4H3.6v-9h8.99z",fill:"currentColor"})}),Pane$3=SatisfactionMenu,Title$5="Custom Features",Icon$3=SvgIcMemory24Px,RotaryEncoder=Object.freeze(Object.defineProperty({__proto__:null,Icon:Icon$3,Pane:Pane$3,Title:Title$5},Symbol.toStringTag,{value:"Module"})),pixleImg=(e,t,r)=>{const s=document.createElement("canvas");s.width=e.width,s.height=e.height;const a=e.width*.2,l=e.height*.2,c=s.getContext("2d");c.drawImage(e,0,0,a,l),c.imageSmoothingEnabled=!1;const d=document.createElement("canvas");d.width=t,d.height=r;const p=d.getContext("2d",{willReadFrequently:!0});p.imageSmoothingEnabled=!1;const f=t/r;let m,y,K,x,v;return v=a/l,v<=f?(K=a,x=K/f,m=0,y=(l-x)/2):(x=l,K=x*f,m=(a-K)/2,y=0),p.drawImage(s,m,y,K,x,0,0,d.width,d.height),Uint8Array.from(p.getImageData(0,0,t,r,{colorSpace:"srgb"}).data)};var createModule=(()=>{var e=import.meta.url;return async function(t={}){var r=t,s,a;r.ready=new Promise((o,n)=>{s=o,a=n}),["_memory","___indirect_function_table","_ff_h264_cabac_tables","___set_stack_limits","onRuntimeInitialized"].forEach(o=>{Object.getOwnPropertyDescriptor(r.ready,o)||Object.defineProperty(r.ready,o,{get:()=>pe("You are getting "+o+" on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js"),set:()=>pe("You are setting "+o+" on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")})});var l=Object.assign({},r),c="./this.program",d=typeof window=="object",p=typeof importScripts=="function",f=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",m=!d&&!f&&!p;if(r.ENVIRONMENT)throw new Error("Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)");var y="";function K(o){return r.locateFile?r.locateFile(o,y):y+o}var x,v,M;if(f){if(typeof process>"u"||!process.release||process.release.name!=="node")throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");var b=process.versions.node,R=b.split(".").slice(0,3);if(R=R[0]*1e4+R[1]*100+R[2].split("-")[0]*1,R<16e4)throw new Error("This emscripten-generated code requires node v16.0.0 (detected v"+b+")");const{createRequire:o}=await __vitePreload(()=>import("./__vite-browser-external-b25bb000.js"),[]);var O=o(import.meta.url),I=O("fs"),k=O("path");p?y=k.dirname(y)+"/":y=O("url").fileURLToPath(new URL("./",self.location)),x=(n,i)=>(n=He(n)?new URL(n):k.normalize(n),I.readFileSync(n,i?void 0:"utf8")),M=n=>{var i=x(n,!0);return i.buffer||(i=new Uint8Array(i)),L(i.buffer),i},v=(n,i,u,h=!0)=>{n=He(n)?new URL(n):k.normalize(n),I.readFile(n,h?void 0:"utf8",(g,C)=>{g?u(g):i(h?C.buffer:C)})},!r.thisProgram&&process.argv.length>1&&(c=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2)}else if(m){if(typeof process=="object"&&typeof O=="function"||typeof window=="object"||typeof importScripts=="function")throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");typeof read<"u"&&(x=read),M=o=>{if(typeof readbuffer=="function")return new Uint8Array(readbuffer(o));let n=read(o,"binary");return L(typeof n=="object"),n},v=(o,n,i)=>{setTimeout(()=>n(M(o)))},typeof clearTimeout>"u"&&(globalThis.clearTimeout=o=>{}),typeof setTimeout>"u"&&(globalThis.setTimeout=o=>typeof o=="function"?o():pe()),typeof scriptArgs<"u"&&scriptArgs,typeof print<"u"&&(typeof console>"u"&&(console={}),console.log=print,console.warn=console.error=typeof printErr<"u"?printErr:print)}else if(d||p){if(p?y=self.location.href:typeof document<"u"&&document.currentScript&&(y=document.currentScript.src),e&&(y=e),y.startsWith("blob:")?y="":y=y.substr(0,y.replace(/[?#].*/,"").lastIndexOf("/")+1),!(typeof window=="object"||typeof importScripts=="function"))throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");x=o=>{var n=new XMLHttpRequest;return n.open("GET",o,!1),n.send(null),n.responseText},p&&(M=o=>{var n=new XMLHttpRequest;return n.open("GET",o,!1),n.responseType="arraybuffer",n.send(null),new Uint8Array(n.response)}),v=(o,n,i)=>{var u=new XMLHttpRequest;u.open("GET",o,!0),u.responseType="arraybuffer",u.onload=()=>{if(u.status==200||u.status==0&&u.response){n(u.response);return}i()},u.onerror=i,u.send(null)}}else throw new Error("environment detection error");var F=r.print||console.log.bind(console),V=r.printErr||console.error.bind(console);Object.assign(r,l),l=null,Ts(),r.arguments&&r.arguments,et("arguments","arguments_"),r.thisProgram&&(c=r.thisProgram),et("thisProgram","thisProgram"),r.quit&&r.quit,et("quit","quit_"),L(typeof r.memoryInitializerPrefixURL>"u","Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead"),L(typeof r.pthreadMainPrefixURL>"u","Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead"),L(typeof r.cdInitializerPrefixURL>"u","Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead"),L(typeof r.filePackagePrefixURL>"u","Module.filePackagePrefixURL option was removed, use Module.locateFile instead"),L(typeof r.read>"u","Module.read option was removed (modify read_ in JS)"),L(typeof r.readAsync>"u","Module.readAsync option was removed (modify readAsync in JS)"),L(typeof r.readBinary>"u","Module.readBinary option was removed (modify readBinary in JS)"),L(typeof r.setWindowTitle>"u","Module.setWindowTitle option was removed (modify emscripten_set_window_title in JS)"),L(typeof r.TOTAL_MEMORY>"u","Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY"),et("asm","wasmExports"),et("read","read_"),et("readAsync","readAsync"),et("readBinary","readBinary"),et("setWindowTitle","setWindowTitle"),L(!m,"shell environment detected but not enabled at build time. Add `shell` to `-sENVIRONMENT` to enable.");var $;r.wasmBinary&&($=r.wasmBinary),et("wasmBinary","wasmBinary"),typeof WebAssembly!="object"&&pe("no native wasm support detected");var z,X=!1;function L(o,n){o||pe("Assertion failed"+(n?": "+n:""))}var H,B,Q,q,T,j,te,re;function de(){var o=z.buffer;r.HEAP8=H=new Int8Array(o),r.HEAP16=Q=new Int16Array(o),r.HEAPU8=B=new Uint8Array(o),r.HEAPU16=q=new Uint16Array(o),r.HEAP32=T=new Int32Array(o),r.HEAPU32=j=new Uint32Array(o),r.HEAPF32=te=new Float32Array(o),r.HEAPF64=re=new Float64Array(o)}L(!r.STACK_SIZE,"STACK_SIZE can no longer be set at runtime. Use -sSTACK_SIZE at link time"),L(typeof Int32Array<"u"&&typeof Float64Array<"u"&&Int32Array.prototype.subarray!=null&&Int32Array.prototype.set!=null,"JS engine does not provide full typed array support"),L(!r.wasmMemory,"Use of `wasmMemory` detected. Use -sIMPORTED_MEMORY to define wasmMemory externally"),L(!r.INITIAL_MEMORY,"Detected runtime INITIAL_MEMORY setting. Use -sIMPORTED_MEMORY to define wasmMemory dynamically");function fe(){var o=Ut();L((o&3)==0),o==0&&(o+=4),j[o>>2]=34821223,Y(34821223),j[o+4>>2]=2310721022,Y(2310721022),j[0]=1668509029,Y(1668509029)}function Ee(){if(!X){var o=Ut();o==0&&(o+=4);var n=j[o>>2],i=j[o+4>>2];(n!=34821223||i!=2310721022)&&pe(`Stack overflow! Stack cookie has been overwritten at ${ct(o)}, expected hex dwords 0x89BACDFE and 0x2135467, but received ${ct(i)} ${ct(n)}`),j[0]!=1668509029&&pe("Runtime error: The application has corrupted its heap memory area (address zero)!")}}(function(){var o=new Int16Array(1),n=new Int8Array(o.buffer);if(o[0]=25459,n[0]!==115||n[1]!==99)throw"Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)"})();var $e=[],Qe=[],Xe=[],_e=!1;function Pe(){if(r.preRun)for(typeof r.preRun=="function"&&(r.preRun=[r.preRun]);r.preRun.length;)ne(r.preRun.shift());ur($e)}function ot(){L(!_e),_e=!0,Ee(),go(),Le.root=_.mount(Le,{},null),!r.noFSInit&&!_.init.initialized&&_.init(),_.ignorePermissions=!1,ur(Qe)}function qe(){if(Ee(),r.postRun)for(typeof r.postRun=="function"&&(r.postRun=[r.postRun]);r.postRun.length;)Me(r.postRun.shift());ur(Xe)}function ne(o){$e.unshift(o)}function se(o){Qe.unshift(o)}function Me(o){Xe.unshift(o)}L(Math.imul,"This browser does not support Math.imul(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),L(Math.fround,"This browser does not support Math.fround(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),L(Math.clz32,"This browser does not support Math.clz32(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),L(Math.trunc,"This browser does not support Math.trunc(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill");var ge=0,ue=null,me=null,ke={};function Ne(o){for(var n=o;;){if(!ke[o])return o;o=n+Math.random()}}function Te(o){var n;ge++,(n=r.monitorRunDependencies)==null||n.call(r,ge),o?(L(!ke[o]),ke[o]=1,ue===null&&typeof setInterval<"u"&&(ue=setInterval(()=>{if(X){clearInterval(ue),ue=null;return}var i=!1;for(var u in ke)i||(i=!0,V("still waiting on run dependencies:")),V(`dependency: ${u}`);i&&V("(end of list)")},1e4))):V("warning: run dependency added without ID")}function Ve(o){var i;if(ge--,(i=r.monitorRunDependencies)==null||i.call(r,ge),o?(L(ke[o]),delete ke[o]):V("warning: run dependency removed without ID"),ge==0&&(ue!==null&&(clearInterval(ue),ue=null),me)){var n=me;me=null,n()}}function pe(o){var i;(i=r.onAbort)==null||i.call(r,o),o="Aborted("+o+")",V(o),X=!0;var n=new WebAssembly.RuntimeError(o);throw a(n),n}var be="data:application/octet-stream;base64,",it=o=>o.startsWith(be),He=o=>o.startsWith("file://");function Ce(o){return(...n)=>{L(_e,`native function \`${o}\` called before runtime initialization`);var i=pt[o];return L(i,`exported native function \`${o}\` not found`),i(...n)}}var Be;r.locateFile?(Be="kbres.wasm",it(Be)||(Be=K(Be))):Be=new URL("/assets/kbres-20adae5e.wasm",self.location).href;function Je(o){if(o==Be&&$)return new Uint8Array($);if(M)return M(o);throw"both async and sync fetching of the wasm failed"}function Ze(o){if(!$&&(d||p)){if(typeof fetch=="function"&&!He(o))return fetch(o,{credentials:"same-origin"}).then(n=>{if(!n.ok)throw`failed to load wasm binary file at '${o}'`;return n.arrayBuffer()}).catch(()=>Je(o));if(v)return new Promise((n,i)=>{v(o,u=>n(new Uint8Array(u)),i)})}return Promise.resolve().then(()=>Je(o))}function Fe(o,n,i){return Ze(o).then(u=>WebAssembly.instantiate(u,n)).then(i,u=>{V(`failed to asynchronously prepare wasm: ${u}`),He(Be)&&V(`warning: Loading from a file URI (${Be}) is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing`),pe(u)})}function ht(o,n,i,u){return!o&&typeof WebAssembly.instantiateStreaming=="function"&&!it(n)&&!He(n)&&!f&&typeof fetch=="function"?fetch(n,{credentials:"same-origin"}).then(h=>{var g=WebAssembly.instantiateStreaming(h,i);return g.then(u,function(C){return V(`wasm streaming compile failed: ${C}`),V("falling back to ArrayBuffer instantiation"),Fe(n,i,u)})}):Fe(n,i,u)}function Lt(){var o={env:lo,wasi_snapshot_preview1:lo};function n(h,g){return pt=h.exports,z=pt.memory,L(z,"memory not found in wasm exports"),de(),nr=pt.__indirect_function_table,L(nr,"table not found in wasm exports"),se(pt.__wasm_call_ctors),Ve("wasm-instantiate"),pt}Te("wasm-instantiate");var i=r;function u(h){L(r===i,"the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?"),i=null,n(h.instance)}if(r.instantiateWasm)try{return r.instantiateWasm(o,n)}catch(h){V(`Module.instantiateWasm callback failed with error: ${h}`),a(h)}return ht($,Be,o,u).catch(a),{}}var Z,he;function et(o,n,i=!0){Object.getOwnPropertyDescriptor(r,o)||Object.defineProperty(r,o,{configurable:!0,get(){let u=i?" (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)":"";pe(`\`Module.${o}\` has been replaced by \`${n}\``+u)}})}function Vt(o){Object.getOwnPropertyDescriptor(r,o)&&pe(`\`Module.${o}\` was supplied but \`${o}\` not included in INCOMING_MODULE_JS_API`)}function Dt(o){return o==="FS_createPath"||o==="FS_createDataFile"||o==="FS_createPreloadedFile"||o==="FS_unlink"||o==="addRunDependency"||o==="FS_createLazyFile"||o==="FS_createDevice"||o==="removeRunDependency"}function Rt(o,n){typeof globalThis<"u"&&Object.defineProperty(globalThis,o,{configurable:!0,get(){lt(`\`${o}\` is not longer defined by emscripten. ${n}`)}})}Rt("buffer","Please use HEAP8.buffer or wasmMemory.buffer"),Rt("asm","Please use wasmExports instead");function Ht(o){typeof globalThis<"u"&&!Object.getOwnPropertyDescriptor(globalThis,o)&&Object.defineProperty(globalThis,o,{configurable:!0,get(){var n=`\`${o}\` is a library symbol and not included by default; add it to your library.js __deps or to DEFAULT_LIBRARY_FUNCS_TO_INCLUDE on the command line`,i=o;i.startsWith("_")||(i="$"+o),n+=` (e.g. -sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE='${i}')`,Dt(o)&&(n+=". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you"),lt(n)}}),oe(o)}function oe(o){Object.getOwnPropertyDescriptor(r,o)||Object.defineProperty(r,o,{configurable:!0,get(){var n=`'${o}' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ)`;Dt(o)&&(n+=". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you"),pe(n)}})}var Ke=2**8-1,Ae=2**16-1,je=2**32-1,tt=2**64-1,ft=-(2**(8-1))+1,_t=-(2**(16-1))+1,bt=-(2**(32-1))+1,It=-(2**(64-1))+1;function nt(o,n,i,u){L(Number.isInteger(Number(o)),`attempt to write non-integer (${o}) into integer heap`),L(o<=u,`value (${o}) too large to write as ${n}-bit value`),L(o>=i,`value (${o}) too small to write as ${n}-bit value`)}var yt=o=>nt(o,8,ft,Ke),rt=o=>nt(o,16,_t,Ae),Y=o=>nt(o,32,bt,je),st=o=>nt(o,64,It,tt);function _o(...o){console.warn(...o)}var ur=o=>{for(;o.length>0;)o.shift()(r)};r.noExitRuntime;var ct=o=>(L(typeof o=="number"),o>>>=0,"0x"+o.toString(16).padStart(8,"0")),go=()=>{var o=Lr(),n=Ut();Is(o,n)},lt=o=>{lt.shown||(lt.shown={}),lt.shown[o]||(lt.shown[o]=1,f&&(o="warning: "+o),V(o))},Rr=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,vt=(o,n,i)=>{for(var u=n+i,h=n;o[h]&&!(h>=u);)++h;if(h-n>16&&o.buffer&&Rr)return Rr.decode(o.subarray(n,h));for(var g="";n<h;){var C=o[n++];if(!(C&128)){g+=String.fromCharCode(C);continue}var S=o[n++]&63;if((C&224)==192){g+=String.fromCharCode((C&31)<<6|S);continue}var w=o[n++]&63;if((C&240)==224?C=(C&15)<<12|S<<6|w:((C&248)!=240&<("Invalid UTF-8 leading byte "+ct(C)+" encountered when deserializing a UTF-8 string in wasm memory to a JS string!"),C=(C&7)<<18|S<<12|w<<6|o[n++]&63),C<65536)g+=String.fromCharCode(C);else{var A=C-65536;g+=String.fromCharCode(55296|A>>10,56320|A&1023)}}return g},at=(o,n)=>(L(typeof o=="number",`UTF8ToString expects a number (got ${typeof o})`),o?vt(B,o,n):""),mo=(o,n,i,u)=>{pe(`Assertion failed: ${at(o)}, at: `+[n?at(n):"unknown filename",i,u?at(u):"unknown function"])};class Co{constructor(n){this.excPtr=n,this.ptr=n-24}set_type(n){j[this.ptr+4>>2]=n}get_type(){return j[this.ptr+4>>2]}set_destructor(n){j[this.ptr+8>>2]=n}get_destructor(){return j[this.ptr+8>>2]}set_caught(n){n=n?1:0,H[this.ptr+12]=n,yt(n)}get_caught(){return H[this.ptr+12]!=0}set_rethrown(n){n=n?1:0,H[this.ptr+13]=n,yt(n)}get_rethrown(){return H[this.ptr+13]!=0}init(n,i){this.set_adjusted_ptr(0),this.set_type(n),this.set_destructor(i)}set_adjusted_ptr(n){j[this.ptr+16>>2]=n}get_adjusted_ptr(){return j[this.ptr+16>>2]}get_exception_ptr(){var n=Rs(this.get_type());if(n)return j[this.excPtr>>2];var i=this.get_adjusted_ptr();return i!==0?i:this.excPtr}}var yo=(o,n,i)=>{var u=new Co(o);u.init(n,i),L(!1,"Exception thrown, but exception catching is not enabled. Compile with -sNO_DISABLE_EXCEPTION_CATCHING or -sEXCEPTION_CATCHING_ALLOWED=[..] to catch.")},So=o=>{var n=Lr(),i=Ut();pe(`stack overflow (Attempt to set SP to ${ct(o)}, with stack limits [${ct(i)} - ${ct(n)}]). If you require more stack space build with -sSTACK_SIZE=<bytes>`)},xo=()=>{if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return u=>crypto.getRandomValues(u);if(f)try{var o=O("crypto"),n=o.randomFillSync;if(n)return u=>o.randomFillSync(u);var i=o.randomBytes;return u=>(u.set(i(u.byteLength)),u)}catch{}pe("no cryptographic support found for randomDevice. consider polyfilling it if you want to use something insecure like Math.random(), e.g. put this in a --pre-js: var crypto = { getRandomValues: (array) => { for (var i = 0; i < array.length; i++) array[i] = (Math.random()*256)|0 } };")},Ir=o=>(Ir=xo())(o),ve={isAbs:o=>o.charAt(0)==="/",splitPath:o=>{var n=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return n.exec(o).slice(1)},normalizeArray:(o,n)=>{for(var i=0,u=o.length-1;u>=0;u--){var h=o[u];h==="."?o.splice(u,1):h===".."?(o.splice(u,1),i++):i&&(o.splice(u,1),i--)}if(n)for(;i;i--)o.unshift("..");return o},normalize:o=>{var n=ve.isAbs(o),i=o.substr(-1)==="/";return o=ve.normalizeArray(o.split("/").filter(u=>!!u),!n).join("/"),!o&&!n&&(o="."),o&&i&&(o+="/"),(n?"/":"")+o},dirname:o=>{var n=ve.splitPath(o),i=n[0],u=n[1];return!i&&!u?".":(u&&(u=u.substr(0,u.length-1)),i+u)},basename:o=>{if(o==="/")return"/";o=ve.normalize(o),o=o.replace(/\/$/,"");var n=o.lastIndexOf("/");return n===-1?o:o.substr(n+1)},join:(...o)=>ve.normalize(o.join("/")),join2:(o,n)=>ve.normalize(o+"/"+n)},dt={resolve:(...o)=>{for(var n="",i=!1,u=o.length-1;u>=-1&&!i;u--){var h=u>=0?o[u]:_.cwd();if(typeof h!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!h)return"";n=h+"/"+n,i=ve.isAbs(h)}return n=ve.normalizeArray(n.split("/").filter(g=>!!g),!i).join("/"),(i?"/":"")+n||"."},relative:(o,n)=>{o=dt.resolve(o).substr(1),n=dt.resolve(n).substr(1);function i(A){for(var P=0;P<A.length&&A[P]==="";P++);for(var N=A.length-1;N>=0&&A[N]==="";N--);return P>N?[]:A.slice(P,N-P+1)}for(var u=i(o.split("/")),h=i(n.split("/")),g=Math.min(u.length,h.length),C=g,S=0;S<g;S++)if(u[S]!==h[S]){C=S;break}for(var w=[],S=C;S<u.length;S++)w.push("..");return w=w.concat(h.slice(C)),w.join("/")}},pr=[],zt=o=>{for(var n=0,i=0;i<o.length;++i){var u=o.charCodeAt(i);u<=127?n++:u<=2047?n+=2:u>=55296&&u<=57343?(n+=4,++i):n+=3}return n},hr=(o,n,i,u)=>{if(L(typeof o=="string",`stringToUTF8Array expects a string (got ${typeof o})`),!(u>0))return 0;for(var h=i,g=i+u-1,C=0;C<o.length;++C){var S=o.charCodeAt(C);if(S>=55296&&S<=57343){var w=o.charCodeAt(++C);S=65536+((S&1023)<<10)|w&1023}if(S<=127){if(i>=g)break;n[i++]=S}else if(S<=2047){if(i+1>=g)break;n[i++]=192|S>>6,n[i++]=128|S&63}else if(S<=65535){if(i+2>=g)break;n[i++]=224|S>>12,n[i++]=128|S>>6&63,n[i++]=128|S&63}else{if(i+3>=g)break;S>1114111&<("Invalid Unicode code point "+ct(S)+" encountered when serializing a JS string to a UTF-8 string in wasm memory! (Valid unicode code points should be in range 0-0x10FFFF)."),n[i++]=240|S>>18,n[i++]=128|S>>12&63,n[i++]=128|S>>6&63,n[i++]=128|S&63}}return n[i]=0,i-h};function Wt(o,n,i){var u=i>0?i:zt(o)+1,h=new Array(u),g=hr(o,h,0,h.length);return n&&(h.length=g),h}var Ko=()=>{if(!pr.length){var o=null;if(f){var n=256,i=Buffer.alloc(n),u=0,h=process.stdin.fd;try{u=I.readSync(h,i)}catch(g){if(g.toString().includes("EOF"))u=0;else throw g}u>0?o=i.slice(0,u).toString("utf-8"):o=null}else typeof window<"u"&&typeof window.prompt=="function"?(o=window.prompt("Input: "),o!==null&&(o+=`
|
|
1087
|
+
`)):typeof readline=="function"&&(o=readline(),o!==null&&(o+=`
|
|
1088
|
+
`));if(!o)return null;pr=Wt(o,!0)}return pr.shift()},St={ttys:[],init(){},shutdown(){},register(o,n){St.ttys[o]={input:[],output:[],ops:n},_.registerDevice(o,St.stream_ops)},stream_ops:{open(o){var n=St.ttys[o.node.rdev];if(!n)throw new _.ErrnoError(43);o.tty=n,o.seekable=!1},close(o){o.tty.ops.fsync(o.tty)},fsync(o){o.tty.ops.fsync(o.tty)},read(o,n,i,u,h){if(!o.tty||!o.tty.ops.get_char)throw new _.ErrnoError(60);for(var g=0,C=0;C<u;C++){var S;try{S=o.tty.ops.get_char(o.tty)}catch{throw new _.ErrnoError(29)}if(S===void 0&&g===0)throw new _.ErrnoError(6);if(S==null)break;g++,n[i+C]=S}return g&&(o.node.timestamp=Date.now()),g},write(o,n,i,u,h){if(!o.tty||!o.tty.ops.put_char)throw new _.ErrnoError(60);try{for(var g=0;g<u;g++)o.tty.ops.put_char(o.tty,n[i+g])}catch{throw new _.ErrnoError(29)}return u&&(o.node.timestamp=Date.now()),g}},default_tty_ops:{get_char(o){return Ko()},put_char(o,n){n===null||n===10?(F(vt(o.output,0)),o.output=[]):n!=0&&o.output.push(n)},fsync(o){o.output&&o.output.length>0&&(F(vt(o.output,0)),o.output=[])},ioctl_tcgets(o){return{c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},ioctl_tcsets(o,n,i){return 0},ioctl_tiocgwinsz(o){return[24,80]}},default_tty1_ops:{put_char(o,n){n===null||n===10?(V(vt(o.output,0)),o.output=[]):n!=0&&o.output.push(n)},fsync(o){o.output&&o.output.length>0&&(V(vt(o.output,0)),o.output=[])}}},Or=(o,n)=>(B.fill(0,o,o+n),o),Pr=o=>{pe("internal error: mmapAlloc called but `emscripten_builtin_memalign` native symbol not exported")},le={ops_table:null,mount(o){return le.createNode(null,"/",16895,0)},createNode(o,n,i,u){if(_.isBlkdev(i)||_.isFIFO(i))throw new _.ErrnoError(63);le.ops_table||(le.ops_table={dir:{node:{getattr:le.node_ops.getattr,setattr:le.node_ops.setattr,lookup:le.node_ops.lookup,mknod:le.node_ops.mknod,rename:le.node_ops.rename,unlink:le.node_ops.unlink,rmdir:le.node_ops.rmdir,readdir:le.node_ops.readdir,symlink:le.node_ops.symlink},stream:{llseek:le.stream_ops.llseek}},file:{node:{getattr:le.node_ops.getattr,setattr:le.node_ops.setattr},stream:{llseek:le.stream_ops.llseek,read:le.stream_ops.read,write:le.stream_ops.write,allocate:le.stream_ops.allocate,mmap:le.stream_ops.mmap,msync:le.stream_ops.msync}},link:{node:{getattr:le.node_ops.getattr,setattr:le.node_ops.setattr,readlink:le.node_ops.readlink},stream:{}},chrdev:{node:{getattr:le.node_ops.getattr,setattr:le.node_ops.setattr},stream:_.chrdev_stream_ops}});var h=_.createNode(o,n,i,u);return _.isDir(h.mode)?(h.node_ops=le.ops_table.dir.node,h.stream_ops=le.ops_table.dir.stream,h.contents={}):_.isFile(h.mode)?(h.node_ops=le.ops_table.file.node,h.stream_ops=le.ops_table.file.stream,h.usedBytes=0,h.contents=null):_.isLink(h.mode)?(h.node_ops=le.ops_table.link.node,h.stream_ops=le.ops_table.link.stream):_.isChrdev(h.mode)&&(h.node_ops=le.ops_table.chrdev.node,h.stream_ops=le.ops_table.chrdev.stream),h.timestamp=Date.now(),o&&(o.contents[n]=h,o.timestamp=h.timestamp),h},getFileDataAsTypedArray(o){return o.contents?o.contents.subarray?o.contents.subarray(0,o.usedBytes):new Uint8Array(o.contents):new Uint8Array(0)},expandFileStorage(o,n){var i=o.contents?o.contents.length:0;if(!(i>=n)){var u=1024*1024;n=Math.max(n,i*(i<u?2:1.125)>>>0),i!=0&&(n=Math.max(n,256));var h=o.contents;o.contents=new Uint8Array(n),o.usedBytes>0&&o.contents.set(h.subarray(0,o.usedBytes),0)}},resizeFileStorage(o,n){if(o.usedBytes!=n)if(n==0)o.contents=null,o.usedBytes=0;else{var i=o.contents;o.contents=new Uint8Array(n),i&&o.contents.set(i.subarray(0,Math.min(n,o.usedBytes))),o.usedBytes=n}},node_ops:{getattr(o){var n={};return n.dev=_.isChrdev(o.mode)?o.id:1,n.ino=o.id,n.mode=o.mode,n.nlink=1,n.uid=0,n.gid=0,n.rdev=o.rdev,_.isDir(o.mode)?n.size=4096:_.isFile(o.mode)?n.size=o.usedBytes:_.isLink(o.mode)?n.size=o.link.length:n.size=0,n.atime=new Date(o.timestamp),n.mtime=new Date(o.timestamp),n.ctime=new Date(o.timestamp),n.blksize=4096,n.blocks=Math.ceil(n.size/n.blksize),n},setattr(o,n){n.mode!==void 0&&(o.mode=n.mode),n.timestamp!==void 0&&(o.timestamp=n.timestamp),n.size!==void 0&&le.resizeFileStorage(o,n.size)},lookup(o,n){throw _.genericErrors[44]},mknod(o,n,i,u){return le.createNode(o,n,i,u)},rename(o,n,i){if(_.isDir(o.mode)){var u;try{u=_.lookupNode(n,i)}catch{}if(u)for(var h in u.contents)throw new _.ErrnoError(55)}delete o.parent.contents[o.name],o.parent.timestamp=Date.now(),o.name=i,n.contents[i]=o,n.timestamp=o.parent.timestamp,o.parent=n},unlink(o,n){delete o.contents[n],o.timestamp=Date.now()},rmdir(o,n){var i=_.lookupNode(o,n);for(var u in i.contents)throw new _.ErrnoError(55);delete o.contents[n],o.timestamp=Date.now()},readdir(o){var n=[".",".."];for(var i of Object.keys(o.contents))n.push(i);return n},symlink(o,n,i){var u=le.createNode(o,n,41471,0);return u.link=i,u},readlink(o){if(!_.isLink(o.mode))throw new _.ErrnoError(28);return o.link}},stream_ops:{read(o,n,i,u,h){var g=o.node.contents;if(h>=o.node.usedBytes)return 0;var C=Math.min(o.node.usedBytes-h,u);if(L(C>=0),C>8&&g.subarray)n.set(g.subarray(h,h+C),i);else for(var S=0;S<C;S++)n[i+S]=g[h+S];return C},write(o,n,i,u,h,g){if(L(!(n instanceof ArrayBuffer)),n.buffer===H.buffer&&(g=!1),!u)return 0;var C=o.node;if(C.timestamp=Date.now(),n.subarray&&(!C.contents||C.contents.subarray)){if(g)return L(h===0,"canOwn must imply no weird position inside the file"),C.contents=n.subarray(i,i+u),C.usedBytes=u,u;if(C.usedBytes===0&&h===0)return C.contents=n.slice(i,i+u),C.usedBytes=u,u;if(h+u<=C.usedBytes)return C.contents.set(n.subarray(i,i+u),h),u}if(le.expandFileStorage(C,h+u),C.contents.subarray&&n.subarray)C.contents.set(n.subarray(i,i+u),h);else for(var S=0;S<u;S++)C.contents[h+S]=n[i+S];return C.usedBytes=Math.max(C.usedBytes,h+u),u},llseek(o,n,i){var u=n;if(i===1?u+=o.position:i===2&&_.isFile(o.node.mode)&&(u+=o.node.usedBytes),u<0)throw new _.ErrnoError(28);return u},allocate(o,n,i){le.expandFileStorage(o.node,n+i),o.node.usedBytes=Math.max(o.node.usedBytes,n+i)},mmap(o,n,i,u,h){if(!_.isFile(o.node.mode))throw new _.ErrnoError(43);var g,C,S=o.node.contents;if(!(h&2)&&S.buffer===H.buffer)C=!1,g=S.byteOffset;else{if((i>0||i+n<S.length)&&(S.subarray?S=S.subarray(i,i+n):S=Array.prototype.slice.call(S,i,i+n)),C=!0,g=Pr(),!g)throw new _.ErrnoError(48);H.set(S,g)}return{ptr:g,allocated:C}},msync(o,n,i,u,h){return le.stream_ops.write(o,n,0,u,i,!1),0}}},bo=(o,n,i,u)=>{var h=u?"":Ne(`al ${o}`);v(o,g=>{L(g,`Loading data file "${o}" failed (no arrayBuffer).`),n(new Uint8Array(g)),h&&Ve(h)},g=>{if(i)i();else throw`Loading data file "${o}" failed.`}),h&&Te(h)},vo=(o,n,i,u,h,g)=>{_.createDataFile(o,n,i,u,h,g)},wo=r.preloadPlugins||[],Eo=(o,n,i,u)=>{typeof Browser<"u"&&Browser.init();var h=!1;return wo.forEach(g=>{h||g.canHandle(n)&&(g.handle(o,n,i,u),h=!0)}),h},Mo=(o,n,i,u,h,g,C,S,w,A)=>{var P=n?dt.resolve(ve.join2(o,n)):o,N=Ne(`cp ${P}`);function U(W){function ae(we){A==null||A(),S||vo(o,n,we,u,h,w),g==null||g(),Ve(N)}Eo(W,P,ae,()=>{C==null||C(),Ve(N)})||ae(W)}Te(N),typeof i=="string"?bo(i,U,C):U(i)},To=o=>{var n={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},i=n[o];if(typeof i>"u")throw new Error(`Unknown file open mode: ${o}`);return i},fr=(o,n)=>{var i=0;return o&&(i|=365),n&&(i|=146),i},Re={dbs:{},indexedDB:()=>{if(typeof indexedDB<"u")return indexedDB;var o=null;return typeof window=="object"&&(o=window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB),L(o,"IDBFS used, but indexedDB not supported"),o},DB_VERSION:21,DB_STORE_NAME:"FILE_DATA",mount:(...o)=>le.mount(...o),syncfs:(o,n,i)=>{Re.getLocalSet(o,(u,h)=>{if(u)return i(u);Re.getRemoteSet(o,(g,C)=>{if(g)return i(g);var S=n?C:h,w=n?h:C;Re.reconcile(S,w,i)})})},quit:()=>{Object.values(Re.dbs).forEach(o=>o.close()),Re.dbs={}},getDB:(o,n)=>{var i=Re.dbs[o];if(i)return n(null,i);var u;try{u=Re.indexedDB().open(o,Re.DB_VERSION)}catch(h){return n(h)}if(!u)return n("Unable to connect to IndexedDB");u.onupgradeneeded=h=>{var g=h.target.result,C=h.target.transaction,S;g.objectStoreNames.contains(Re.DB_STORE_NAME)?S=C.objectStore(Re.DB_STORE_NAME):S=g.createObjectStore(Re.DB_STORE_NAME),S.indexNames.contains("timestamp")||S.createIndex("timestamp","timestamp",{unique:!1})},u.onsuccess=()=>{i=u.result,Re.dbs[o]=i,n(null,i)},u.onerror=h=>{n(h.target.error),h.preventDefault()}},getLocalSet:(o,n)=>{var i={};function u(w){return w!=="."&&w!==".."}function h(w){return A=>ve.join2(w,A)}for(var g=_.readdir(o.mountpoint).filter(u).map(h(o.mountpoint));g.length;){var C=g.pop(),S;try{S=_.stat(C)}catch(w){return n(w)}_.isDir(S.mode)&&g.push(..._.readdir(C).filter(u).map(h(C))),i[C]={timestamp:S.mtime}}return n(null,{type:"local",entries:i})},getRemoteSet:(o,n)=>{var i={};Re.getDB(o.mountpoint,(u,h)=>{if(u)return n(u);try{var g=h.transaction([Re.DB_STORE_NAME],"readonly");g.onerror=w=>{n(w.target.error),w.preventDefault()};var C=g.objectStore(Re.DB_STORE_NAME),S=C.index("timestamp");S.openKeyCursor().onsuccess=w=>{var A=w.target.result;if(!A)return n(null,{type:"remote",db:h,entries:i});i[A.primaryKey]={timestamp:A.key},A.continue()}}catch(w){return n(w)}})},loadLocalEntry:(o,n)=>{var i,u;try{var h=_.lookupPath(o);u=h.node,i=_.stat(o)}catch(g){return n(g)}return _.isDir(i.mode)?n(null,{timestamp:i.mtime,mode:i.mode}):_.isFile(i.mode)?(u.contents=le.getFileDataAsTypedArray(u),n(null,{timestamp:i.mtime,mode:i.mode,contents:u.contents})):n(new Error("node type not supported"))},storeLocalEntry:(o,n,i)=>{try{if(_.isDir(n.mode))_.mkdirTree(o,n.mode);else if(_.isFile(n.mode))_.writeFile(o,n.contents,{canOwn:!0});else return i(new Error("node type not supported"));_.chmod(o,n.mode),_.utime(o,n.timestamp,n.timestamp)}catch(u){return i(u)}i(null)},removeLocalEntry:(o,n)=>{try{var i=_.stat(o);_.isDir(i.mode)?_.rmdir(o):_.isFile(i.mode)&&_.unlink(o)}catch(u){return n(u)}n(null)},loadRemoteEntry:(o,n,i)=>{var u=o.get(n);u.onsuccess=h=>i(null,h.target.result),u.onerror=h=>{i(h.target.error),h.preventDefault()}},storeRemoteEntry:(o,n,i,u)=>{try{var h=o.put(i,n)}catch(g){u(g);return}h.onsuccess=g=>u(),h.onerror=g=>{u(g.target.error),g.preventDefault()}},removeRemoteEntry:(o,n,i)=>{var u=o.delete(n);u.onsuccess=h=>i(),u.onerror=h=>{i(h.target.error),h.preventDefault()}},reconcile:(o,n,i)=>{var u=0,h=[];Object.keys(o.entries).forEach(function(N){var U=o.entries[N],W=n.entries[N];(!W||U.timestamp.getTime()!=W.timestamp.getTime())&&(h.push(N),u++)});var g=[];if(Object.keys(n.entries).forEach(function(N){o.entries[N]||(g.push(N),u++)}),!u)return i(null);var C=!1,S=o.type==="remote"?o.db:n.db,w=S.transaction([Re.DB_STORE_NAME],"readwrite"),A=w.objectStore(Re.DB_STORE_NAME);function P(N){if(N&&!C)return C=!0,i(N)}w.onerror=w.onabort=N=>{P(N.target.error),N.preventDefault()},w.oncomplete=N=>{C||i(null)},h.sort().forEach(N=>{n.type==="local"?Re.loadRemoteEntry(A,N,(U,W)=>{if(U)return P(U);Re.storeLocalEntry(N,W,P)}):Re.loadLocalEntry(N,(U,W)=>{if(U)return P(U);Re.storeRemoteEntry(A,N,W,P)})}),g.sort().reverse().forEach(N=>{n.type==="local"?Re.removeLocalEntry(N,P):Re.removeRemoteEntry(A,N,P)})}},Ao={0:"Success",1:"Arg list too long",2:"Permission denied",3:"Address already in use",4:"Address not available",5:"Address family not supported by protocol family",6:"No more processes",7:"Socket already connected",8:"Bad file number",9:"Trying to read unreadable message",10:"Mount device busy",11:"Operation canceled",12:"No children",13:"Connection aborted",14:"Connection refused",15:"Connection reset by peer",16:"File locking deadlock error",17:"Destination address required",18:"Math arg out of domain of func",19:"Quota exceeded",20:"File exists",21:"Bad address",22:"File too large",23:"Host is unreachable",24:"Identifier removed",25:"Illegal byte sequence",26:"Connection already in progress",27:"Interrupted system call",28:"Invalid argument",29:"I/O error",30:"Socket is already connected",31:"Is a directory",32:"Too many symbolic links",33:"Too many open files",34:"Too many links",35:"Message too long",36:"Multihop attempted",37:"File or path name too long",38:"Network interface is not configured",39:"Connection reset by network",40:"Network is unreachable",41:"Too many open files in system",42:"No buffer space available",43:"No such device",44:"No such file or directory",45:"Exec format error",46:"No record locks available",47:"The link has been severed",48:"Not enough core",49:"No message of desired type",50:"Protocol not available",51:"No space left on device",52:"Function not implemented",53:"Socket is not connected",54:"Not a directory",55:"Directory not empty",56:"State not recoverable",57:"Socket operation on non-socket",59:"Not a typewriter",60:"No such device or address",61:"Value too large for defined data type",62:"Previous owner died",63:"Not super-user",64:"Broken pipe",65:"Protocol error",66:"Unknown protocol",67:"Protocol wrong type for socket",68:"Math result not representable",69:"Read only file system",70:"Illegal seek",71:"No such process",72:"Stale file handle",73:"Connection timed out",74:"Text file busy",75:"Cross-device link",100:"Device not a stream",101:"Bad font file fmt",102:"Invalid slot",103:"Invalid request code",104:"No anode",105:"Block device required",106:"Channel number out of range",107:"Level 3 halted",108:"Level 3 reset",109:"Link number out of range",110:"Protocol driver not attached",111:"No CSI structure available",112:"Level 2 halted",113:"Invalid exchange",114:"Invalid request descriptor",115:"Exchange full",116:"No data (for no delay io)",117:"Timer expired",118:"Out of streams resources",119:"Machine is not on the network",120:"Package not installed",121:"The object is remote",122:"Advertise error",123:"Srmount error",124:"Communication error on send",125:"Cross mount point (not really error)",126:"Given log. name not unique",127:"f.d. invalid for this operation",128:"Remote address changed",129:"Can access a needed shared lib",130:"Accessing a corrupted shared lib",131:".lib section in a.out corrupted",132:"Attempting to link in too many libs",133:"Attempting to exec a shared library",135:"Streams pipe error",136:"Too many users",137:"Socket type not supported",138:"Not supported",139:"Protocol family not supported",140:"Can't send after socket shutdown",141:"Too many references",142:"Host is down",148:"No medium (in tape drive)",156:"Level 2 not synchronized"},kr={EPERM:63,ENOENT:44,ESRCH:71,EINTR:27,EIO:29,ENXIO:60,E2BIG:1,ENOEXEC:45,EBADF:8,ECHILD:12,EAGAIN:6,EWOULDBLOCK:6,ENOMEM:48,EACCES:2,EFAULT:21,ENOTBLK:105,EBUSY:10,EEXIST:20,EXDEV:75,ENODEV:43,ENOTDIR:54,EISDIR:31,EINVAL:28,ENFILE:41,EMFILE:33,ENOTTY:59,ETXTBSY:74,EFBIG:22,ENOSPC:51,ESPIPE:70,EROFS:69,EMLINK:34,EPIPE:64,EDOM:18,ERANGE:68,ENOMSG:49,EIDRM:24,ECHRNG:106,EL2NSYNC:156,EL3HLT:107,EL3RST:108,ELNRNG:109,EUNATCH:110,ENOCSI:111,EL2HLT:112,EDEADLK:16,ENOLCK:46,EBADE:113,EBADR:114,EXFULL:115,ENOANO:104,EBADRQC:103,EBADSLT:102,EDEADLOCK:16,EBFONT:101,ENOSTR:100,ENODATA:116,ETIME:117,ENOSR:118,ENONET:119,ENOPKG:120,EREMOTE:121,ENOLINK:47,EADV:122,ESRMNT:123,ECOMM:124,EPROTO:65,EMULTIHOP:36,EDOTDOT:125,EBADMSG:9,ENOTUNIQ:126,EBADFD:127,EREMCHG:128,ELIBACC:129,ELIBBAD:130,ELIBSCN:131,ELIBMAX:132,ELIBEXEC:133,ENOSYS:52,ENOTEMPTY:55,ENAMETOOLONG:37,ELOOP:32,EOPNOTSUPP:138,EPFNOSUPPORT:139,ECONNRESET:15,ENOBUFS:42,EAFNOSUPPORT:5,EPROTOTYPE:67,ENOTSOCK:57,ENOPROTOOPT:50,ESHUTDOWN:140,ECONNREFUSED:14,EADDRINUSE:3,ECONNABORTED:13,ENETUNREACH:40,ENETDOWN:38,ETIMEDOUT:73,EHOSTDOWN:142,EHOSTUNREACH:23,EINPROGRESS:26,EALREADY:7,EDESTADDRREQ:17,EMSGSIZE:35,EPROTONOSUPPORT:66,ESOCKTNOSUPPORT:137,EADDRNOTAVAIL:4,ENETRESET:39,EISCONN:30,ENOTCONN:53,ETOOMANYREFS:141,EUSERS:136,EDQUOT:19,ESTALE:72,ENOTSUP:138,ENOMEDIUM:148,EILSEQ:25,EOVERFLOW:61,ECANCELED:11,ENOTRECOVERABLE:56,EOWNERDEAD:62,ESTRPIPE:135},_={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,ErrnoError:class extends Error{constructor(o){super(Ao[o]),this.name="ErrnoError",this.errno=o;for(var n in kr)if(kr[n]===o){this.code=n;break}}},genericErrors:{},filesystems:null,syncFSRequests:0,lookupPath(o,n={}){if(o=dt.resolve(o),!o)return{path:"",node:null};var i={follow_mount:!0,recurse_count:0};if(n=Object.assign(i,n),n.recurse_count>8)throw new _.ErrnoError(32);for(var u=o.split("/").filter(N=>!!N),h=_.root,g="/",C=0;C<u.length;C++){var S=C===u.length-1;if(S&&n.parent)break;if(h=_.lookupNode(h,u[C]),g=ve.join2(g,u[C]),_.isMountpoint(h)&&(!S||S&&n.follow_mount)&&(h=h.mounted.root),!S||n.follow)for(var w=0;_.isLink(h.mode);){var A=_.readlink(g);g=dt.resolve(ve.dirname(g),A);var P=_.lookupPath(g,{recurse_count:n.recurse_count+1});if(h=P.node,w++>40)throw new _.ErrnoError(32)}}return{path:g,node:h}},getPath(o){for(var n;;){if(_.isRoot(o)){var i=o.mount.mountpoint;return n?i[i.length-1]!=="/"?`${i}/${n}`:i+n:i}n=n?`${o.name}/${n}`:o.name,o=o.parent}},hashName(o,n){for(var i=0,u=0;u<n.length;u++)i=(i<<5)-i+n.charCodeAt(u)|0;return(o+i>>>0)%_.nameTable.length},hashAddNode(o){var n=_.hashName(o.parent.id,o.name);o.name_next=_.nameTable[n],_.nameTable[n]=o},hashRemoveNode(o){var n=_.hashName(o.parent.id,o.name);if(_.nameTable[n]===o)_.nameTable[n]=o.name_next;else for(var i=_.nameTable[n];i;){if(i.name_next===o){i.name_next=o.name_next;break}i=i.name_next}},lookupNode(o,n){var i=_.mayLookup(o);if(i)throw new _.ErrnoError(i);for(var u=_.hashName(o.id,n),h=_.nameTable[u];h;h=h.name_next){var g=h.name;if(h.parent.id===o.id&&g===n)return h}return _.lookup(o,n)},createNode(o,n,i,u){L(typeof o=="object");var h=new _.FSNode(o,n,i,u);return _.hashAddNode(h),h},destroyNode(o){_.hashRemoveNode(o)},isRoot(o){return o===o.parent},isMountpoint(o){return!!o.mounted},isFile(o){return(o&61440)===32768},isDir(o){return(o&61440)===16384},isLink(o){return(o&61440)===40960},isChrdev(o){return(o&61440)===8192},isBlkdev(o){return(o&61440)===24576},isFIFO(o){return(o&61440)===4096},isSocket(o){return(o&49152)===49152},flagsToPermissionString(o){var n=["r","w","rw"][o&3];return o&512&&(n+="w"),n},nodePermissions(o,n){return _.ignorePermissions?0:n.includes("r")&&!(o.mode&292)||n.includes("w")&&!(o.mode&146)||n.includes("x")&&!(o.mode&73)?2:0},mayLookup(o){if(!_.isDir(o.mode))return 54;var n=_.nodePermissions(o,"x");return n||(o.node_ops.lookup?0:2)},mayCreate(o,n){try{var i=_.lookupNode(o,n);return 20}catch{}return _.nodePermissions(o,"wx")},mayDelete(o,n,i){var u;try{u=_.lookupNode(o,n)}catch(g){return g.errno}var h=_.nodePermissions(o,"wx");if(h)return h;if(i){if(!_.isDir(u.mode))return 54;if(_.isRoot(u)||_.getPath(u)===_.cwd())return 10}else if(_.isDir(u.mode))return 31;return 0},mayOpen(o,n){return o?_.isLink(o.mode)?32:_.isDir(o.mode)&&(_.flagsToPermissionString(n)!=="r"||n&512)?31:_.nodePermissions(o,_.flagsToPermissionString(n)):44},MAX_OPEN_FDS:4096,nextfd(){for(var o=0;o<=_.MAX_OPEN_FDS;o++)if(!_.streams[o])return o;throw new _.ErrnoError(33)},getStreamChecked(o){var n=_.getStream(o);if(!n)throw new _.ErrnoError(8);return n},getStream:o=>_.streams[o],createStream(o,n=-1){return _.FSStream||(_.FSStream=function(){this.shared={}},_.FSStream.prototype={},Object.defineProperties(_.FSStream.prototype,{object:{get(){return this.node},set(i){this.node=i}},isRead:{get(){return(this.flags&2097155)!==1}},isWrite:{get(){return(this.flags&2097155)!==0}},isAppend:{get(){return this.flags&1024}},flags:{get(){return this.shared.flags},set(i){this.shared.flags=i}},position:{get(){return this.shared.position},set(i){this.shared.position=i}}})),o=Object.assign(new _.FSStream,o),n==-1&&(n=_.nextfd()),o.fd=n,_.streams[n]=o,o},closeStream(o){_.streams[o]=null},chrdev_stream_ops:{open(o){var i,u;var n=_.getDevice(o.node.rdev);o.stream_ops=n.stream_ops,(u=(i=o.stream_ops).open)==null||u.call(i,o)},llseek(){throw new _.ErrnoError(70)}},major:o=>o>>8,minor:o=>o&255,makedev:(o,n)=>o<<8|n,registerDevice(o,n){_.devices[o]={stream_ops:n}},getDevice:o=>_.devices[o],getMounts(o){for(var n=[],i=[o];i.length;){var u=i.pop();n.push(u),i.push(...u.mounts)}return n},syncfs(o,n){typeof o=="function"&&(n=o,o=!1),_.syncFSRequests++,_.syncFSRequests>1&&V(`warning: ${_.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var i=_.getMounts(_.root.mount),u=0;function h(C){return L(_.syncFSRequests>0),_.syncFSRequests--,n(C)}function g(C){if(C)return g.errored?void 0:(g.errored=!0,h(C));++u>=i.length&&h(null)}i.forEach(C=>{if(!C.type.syncfs)return g(null);C.type.syncfs(C,o,g)})},mount(o,n,i){if(typeof o=="string")throw o;var u=i==="/",h=!i,g;if(u&&_.root)throw new _.ErrnoError(10);if(!u&&!h){var C=_.lookupPath(i,{follow_mount:!1});if(i=C.path,g=C.node,_.isMountpoint(g))throw new _.ErrnoError(10);if(!_.isDir(g.mode))throw new _.ErrnoError(54)}var S={type:o,opts:n,mountpoint:i,mounts:[]},w=o.mount(S);return w.mount=S,S.root=w,u?_.root=w:g&&(g.mounted=S,g.mount&&g.mount.mounts.push(S)),w},unmount(o){var n=_.lookupPath(o,{follow_mount:!1});if(!_.isMountpoint(n.node))throw new _.ErrnoError(28);var i=n.node,u=i.mounted,h=_.getMounts(u);Object.keys(_.nameTable).forEach(C=>{for(var S=_.nameTable[C];S;){var w=S.name_next;h.includes(S.mount)&&_.destroyNode(S),S=w}}),i.mounted=null;var g=i.mount.mounts.indexOf(u);L(g!==-1),i.mount.mounts.splice(g,1)},lookup(o,n){return o.node_ops.lookup(o,n)},mknod(o,n,i){var u=_.lookupPath(o,{parent:!0}),h=u.node,g=ve.basename(o);if(!g||g==="."||g==="..")throw new _.ErrnoError(28);var C=_.mayCreate(h,g);if(C)throw new _.ErrnoError(C);if(!h.node_ops.mknod)throw new _.ErrnoError(63);return h.node_ops.mknod(h,g,n,i)},create(o,n){return n=n!==void 0?n:438,n&=4095,n|=32768,_.mknod(o,n,0)},mkdir(o,n){return n=n!==void 0?n:511,n&=1023,n|=16384,_.mknod(o,n,0)},mkdirTree(o,n){for(var i=o.split("/"),u="",h=0;h<i.length;++h)if(i[h]){u+="/"+i[h];try{_.mkdir(u,n)}catch(g){if(g.errno!=20)throw g}}},mkdev(o,n,i){return typeof i>"u"&&(i=n,n=438),n|=8192,_.mknod(o,n,i)},symlink(o,n){if(!dt.resolve(o))throw new _.ErrnoError(44);var i=_.lookupPath(n,{parent:!0}),u=i.node;if(!u)throw new _.ErrnoError(44);var h=ve.basename(n),g=_.mayCreate(u,h);if(g)throw new _.ErrnoError(g);if(!u.node_ops.symlink)throw new _.ErrnoError(63);return u.node_ops.symlink(u,h,o)},rename(o,n){var i=ve.dirname(o),u=ve.dirname(n),h=ve.basename(o),g=ve.basename(n),C,S,w;if(C=_.lookupPath(o,{parent:!0}),S=C.node,C=_.lookupPath(n,{parent:!0}),w=C.node,!S||!w)throw new _.ErrnoError(44);if(S.mount!==w.mount)throw new _.ErrnoError(75);var A=_.lookupNode(S,h),P=dt.relative(o,u);if(P.charAt(0)!==".")throw new _.ErrnoError(28);if(P=dt.relative(n,i),P.charAt(0)!==".")throw new _.ErrnoError(55);var N;try{N=_.lookupNode(w,g)}catch{}if(A!==N){var U=_.isDir(A.mode),W=_.mayDelete(S,h,U);if(W)throw new _.ErrnoError(W);if(W=N?_.mayDelete(w,g,U):_.mayCreate(w,g),W)throw new _.ErrnoError(W);if(!S.node_ops.rename)throw new _.ErrnoError(63);if(_.isMountpoint(A)||N&&_.isMountpoint(N))throw new _.ErrnoError(10);if(w!==S&&(W=_.nodePermissions(S,"w"),W))throw new _.ErrnoError(W);_.hashRemoveNode(A);try{S.node_ops.rename(A,w,g)}catch(ae){throw ae}finally{_.hashAddNode(A)}}},rmdir(o){var n=_.lookupPath(o,{parent:!0}),i=n.node,u=ve.basename(o),h=_.lookupNode(i,u),g=_.mayDelete(i,u,!0);if(g)throw new _.ErrnoError(g);if(!i.node_ops.rmdir)throw new _.ErrnoError(63);if(_.isMountpoint(h))throw new _.ErrnoError(10);i.node_ops.rmdir(i,u),_.destroyNode(h)},readdir(o){var n=_.lookupPath(o,{follow:!0}),i=n.node;if(!i.node_ops.readdir)throw new _.ErrnoError(54);return i.node_ops.readdir(i)},unlink(o){var n=_.lookupPath(o,{parent:!0}),i=n.node;if(!i)throw new _.ErrnoError(44);var u=ve.basename(o),h=_.lookupNode(i,u),g=_.mayDelete(i,u,!1);if(g)throw new _.ErrnoError(g);if(!i.node_ops.unlink)throw new _.ErrnoError(63);if(_.isMountpoint(h))throw new _.ErrnoError(10);i.node_ops.unlink(i,u),_.destroyNode(h)},readlink(o){var n=_.lookupPath(o),i=n.node;if(!i)throw new _.ErrnoError(44);if(!i.node_ops.readlink)throw new _.ErrnoError(28);return dt.resolve(_.getPath(i.parent),i.node_ops.readlink(i))},stat(o,n){var i=_.lookupPath(o,{follow:!n}),u=i.node;if(!u)throw new _.ErrnoError(44);if(!u.node_ops.getattr)throw new _.ErrnoError(63);return u.node_ops.getattr(u)},lstat(o){return _.stat(o,!0)},chmod(o,n,i){var u;if(typeof o=="string"){var h=_.lookupPath(o,{follow:!i});u=h.node}else u=o;if(!u.node_ops.setattr)throw new _.ErrnoError(63);u.node_ops.setattr(u,{mode:n&4095|u.mode&-4096,timestamp:Date.now()})},lchmod(o,n){_.chmod(o,n,!0)},fchmod(o,n){var i=_.getStreamChecked(o);_.chmod(i.node,n)},chown(o,n,i,u){var h;if(typeof o=="string"){var g=_.lookupPath(o,{follow:!u});h=g.node}else h=o;if(!h.node_ops.setattr)throw new _.ErrnoError(63);h.node_ops.setattr(h,{timestamp:Date.now()})},lchown(o,n,i){_.chown(o,n,i,!0)},fchown(o,n,i){var u=_.getStreamChecked(o);_.chown(u.node,n,i)},truncate(o,n){if(n<0)throw new _.ErrnoError(28);var i;if(typeof o=="string"){var u=_.lookupPath(o,{follow:!0});i=u.node}else i=o;if(!i.node_ops.setattr)throw new _.ErrnoError(63);if(_.isDir(i.mode))throw new _.ErrnoError(31);if(!_.isFile(i.mode))throw new _.ErrnoError(28);var h=_.nodePermissions(i,"w");if(h)throw new _.ErrnoError(h);i.node_ops.setattr(i,{size:n,timestamp:Date.now()})},ftruncate(o,n){var i=_.getStreamChecked(o);if(!(i.flags&2097155))throw new _.ErrnoError(28);_.truncate(i.node,n)},utime(o,n,i){var u=_.lookupPath(o,{follow:!0}),h=u.node;h.node_ops.setattr(h,{timestamp:Math.max(n,i)})},open(o,n,i){if(o==="")throw new _.ErrnoError(44);n=typeof n=="string"?To(n):n,i=typeof i>"u"?438:i,n&64?i=i&4095|32768:i=0;var u;if(typeof o=="object")u=o;else{o=ve.normalize(o);try{var h=_.lookupPath(o,{follow:!(n&131072)});u=h.node}catch{}}var g=!1;if(n&64)if(u){if(n&128)throw new _.ErrnoError(20)}else u=_.mknod(o,i,0),g=!0;if(!u)throw new _.ErrnoError(44);if(_.isChrdev(u.mode)&&(n&=-513),n&65536&&!_.isDir(u.mode))throw new _.ErrnoError(54);if(!g){var C=_.mayOpen(u,n);if(C)throw new _.ErrnoError(C)}n&512&&!g&&_.truncate(u,0),n&=-131713;var S=_.createStream({node:u,path:_.getPath(u),flags:n,seekable:!0,position:0,stream_ops:u.stream_ops,ungotten:[],error:!1});return S.stream_ops.open&&S.stream_ops.open(S),r.logReadFiles&&!(n&1)&&(_.readFiles||(_.readFiles={}),o in _.readFiles||(_.readFiles[o]=1)),S},close(o){if(_.isClosed(o))throw new _.ErrnoError(8);o.getdents&&(o.getdents=null);try{o.stream_ops.close&&o.stream_ops.close(o)}catch(n){throw n}finally{_.closeStream(o.fd)}o.fd=null},isClosed(o){return o.fd===null},llseek(o,n,i){if(_.isClosed(o))throw new _.ErrnoError(8);if(!o.seekable||!o.stream_ops.llseek)throw new _.ErrnoError(70);if(i!=0&&i!=1&&i!=2)throw new _.ErrnoError(28);return o.position=o.stream_ops.llseek(o,n,i),o.ungotten=[],o.position},read(o,n,i,u,h){if(L(i>=0),u<0||h<0)throw new _.ErrnoError(28);if(_.isClosed(o))throw new _.ErrnoError(8);if((o.flags&2097155)===1)throw new _.ErrnoError(8);if(_.isDir(o.node.mode))throw new _.ErrnoError(31);if(!o.stream_ops.read)throw new _.ErrnoError(28);var g=typeof h<"u";if(!g)h=o.position;else if(!o.seekable)throw new _.ErrnoError(70);var C=o.stream_ops.read(o,n,i,u,h);return g||(o.position+=C),C},write(o,n,i,u,h,g){if(L(i>=0),u<0||h<0)throw new _.ErrnoError(28);if(_.isClosed(o))throw new _.ErrnoError(8);if(!(o.flags&2097155))throw new _.ErrnoError(8);if(_.isDir(o.node.mode))throw new _.ErrnoError(31);if(!o.stream_ops.write)throw new _.ErrnoError(28);o.seekable&&o.flags&1024&&_.llseek(o,0,2);var C=typeof h<"u";if(!C)h=o.position;else if(!o.seekable)throw new _.ErrnoError(70);var S=o.stream_ops.write(o,n,i,u,h,g);return C||(o.position+=S),S},allocate(o,n,i){if(_.isClosed(o))throw new _.ErrnoError(8);if(n<0||i<=0)throw new _.ErrnoError(28);if(!(o.flags&2097155))throw new _.ErrnoError(8);if(!_.isFile(o.node.mode)&&!_.isDir(o.node.mode))throw new _.ErrnoError(43);if(!o.stream_ops.allocate)throw new _.ErrnoError(138);o.stream_ops.allocate(o,n,i)},mmap(o,n,i,u,h){if(u&2&&!(h&2)&&(o.flags&2097155)!==2)throw new _.ErrnoError(2);if((o.flags&2097155)===1)throw new _.ErrnoError(2);if(!o.stream_ops.mmap)throw new _.ErrnoError(43);return o.stream_ops.mmap(o,n,i,u,h)},msync(o,n,i,u,h){return L(i>=0),o.stream_ops.msync?o.stream_ops.msync(o,n,i,u,h):0},munmap:o=>0,ioctl(o,n,i){if(!o.stream_ops.ioctl)throw new _.ErrnoError(59);return o.stream_ops.ioctl(o,n,i)},readFile(o,n={}){if(n.flags=n.flags||0,n.encoding=n.encoding||"binary",n.encoding!=="utf8"&&n.encoding!=="binary")throw new Error(`Invalid encoding type "${n.encoding}"`);var i,u=_.open(o,n.flags),h=_.stat(o),g=h.size,C=new Uint8Array(g);return _.read(u,C,0,g,0),n.encoding==="utf8"?i=vt(C,0):n.encoding==="binary"&&(i=C),_.close(u),i},writeFile(o,n,i={}){i.flags=i.flags||577;var u=_.open(o,i.flags,i.mode);if(typeof n=="string"){var h=new Uint8Array(zt(n)+1),g=hr(n,h,0,h.length);_.write(u,h,0,g,void 0,i.canOwn)}else if(ArrayBuffer.isView(n))_.write(u,n,0,n.byteLength,void 0,i.canOwn);else throw new Error("Unsupported data type");_.close(u)},cwd:()=>_.currentPath,chdir(o){var n=_.lookupPath(o,{follow:!0});if(n.node===null)throw new _.ErrnoError(44);if(!_.isDir(n.node.mode))throw new _.ErrnoError(54);var i=_.nodePermissions(n.node,"x");if(i)throw new _.ErrnoError(i);_.currentPath=n.path},createDefaultDirectories(){_.mkdir("/tmp"),_.mkdir("/home"),_.mkdir("/home/web_user")},createDefaultDevices(){_.mkdir("/dev"),_.registerDevice(_.makedev(1,3),{read:()=>0,write:(u,h,g,C,S)=>C}),_.mkdev("/dev/null",_.makedev(1,3)),St.register(_.makedev(5,0),St.default_tty_ops),St.register(_.makedev(6,0),St.default_tty1_ops),_.mkdev("/dev/tty",_.makedev(5,0)),_.mkdev("/dev/tty1",_.makedev(6,0));var o=new Uint8Array(1024),n=0,i=()=>(n===0&&(n=Ir(o).byteLength),o[--n]);_.createDevice("/dev","random",i),_.createDevice("/dev","urandom",i),_.mkdir("/dev/shm"),_.mkdir("/dev/shm/tmp")},createSpecialDirectories(){_.mkdir("/proc");var o=_.mkdir("/proc/self");_.mkdir("/proc/self/fd"),_.mount({mount(){var n=_.createNode(o,"fd",16895,73);return n.node_ops={lookup(i,u){var h=+u,g=_.getStreamChecked(h),C={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>g.path}};return C.parent=C,C}},n}},{},"/proc/self/fd")},createStandardStreams(){r.stdin?_.createDevice("/dev","stdin",r.stdin):_.symlink("/dev/tty","/dev/stdin"),r.stdout?_.createDevice("/dev","stdout",null,r.stdout):_.symlink("/dev/tty","/dev/stdout"),r.stderr?_.createDevice("/dev","stderr",null,r.stderr):_.symlink("/dev/tty1","/dev/stderr");var o=_.open("/dev/stdin",0),n=_.open("/dev/stdout",1),i=_.open("/dev/stderr",1);L(o.fd===0,`invalid handle for stdin (${o.fd})`),L(n.fd===1,`invalid handle for stdout (${n.fd})`),L(i.fd===2,`invalid handle for stderr (${i.fd})`)},staticInit(){[44].forEach(o=>{_.genericErrors[o]=new _.ErrnoError(o),_.genericErrors[o].stack="<generic error, no stack>"}),_.nameTable=new Array(4096),_.mount(le,{},"/"),_.createDefaultDirectories(),_.createDefaultDevices(),_.createSpecialDirectories(),_.filesystems={MEMFS:le,IDBFS:Re}},init(o,n,i){L(!_.init.initialized,"FS.init was previously called. If you want to initialize later with custom parameters, remove any earlier calls (note that one is automatically added to the generated code)"),_.init.initialized=!0,r.stdin=o||r.stdin,r.stdout=n||r.stdout,r.stderr=i||r.stderr,_.createStandardStreams()},quit(){_.init.initialized=!1,As(0);for(var o=0;o<_.streams.length;o++){var n=_.streams[o];n&&_.close(n)}},findObject(o,n){var i=_.analyzePath(o,n);return i.exists?i.object:null},analyzePath(o,n){try{var i=_.lookupPath(o,{follow:!n});o=i.path}catch{}var u={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var i=_.lookupPath(o,{parent:!0});u.parentExists=!0,u.parentPath=i.path,u.parentObject=i.node,u.name=ve.basename(o),i=_.lookupPath(o,{follow:!n}),u.exists=!0,u.path=i.path,u.object=i.node,u.name=i.node.name,u.isRoot=i.path==="/"}catch(h){u.error=h.errno}return u},createPath(o,n,i,u){o=typeof o=="string"?o:_.getPath(o);for(var h=n.split("/").reverse();h.length;){var g=h.pop();if(g){var C=ve.join2(o,g);try{_.mkdir(C)}catch{}o=C}}return C},createFile(o,n,i,u,h){var g=ve.join2(typeof o=="string"?o:_.getPath(o),n),C=fr(u,h);return _.create(g,C)},createDataFile(o,n,i,u,h,g){var C=n;o&&(o=typeof o=="string"?o:_.getPath(o),C=n?ve.join2(o,n):o);var S=fr(u,h),w=_.create(C,S);if(i){if(typeof i=="string"){for(var A=new Array(i.length),P=0,N=i.length;P<N;++P)A[P]=i.charCodeAt(P);i=A}_.chmod(w,S|146);var U=_.open(w,577);_.write(U,i,0,i.length,0,g),_.close(U),_.chmod(w,S)}},createDevice(o,n,i,u){var h=ve.join2(typeof o=="string"?o:_.getPath(o),n),g=fr(!!i,!!u);_.createDevice.major||(_.createDevice.major=64);var C=_.makedev(_.createDevice.major++,0);return _.registerDevice(C,{open(S){S.seekable=!1},close(S){var w;(w=u==null?void 0:u.buffer)!=null&&w.length&&u(10)},read(S,w,A,P,N){for(var U=0,W=0;W<P;W++){var ae;try{ae=i()}catch{throw new _.ErrnoError(29)}if(ae===void 0&&U===0)throw new _.ErrnoError(6);if(ae==null)break;U++,w[A+W]=ae}return U&&(S.node.timestamp=Date.now()),U},write(S,w,A,P,N){for(var U=0;U<P;U++)try{u(w[A+U])}catch{throw new _.ErrnoError(29)}return P&&(S.node.timestamp=Date.now()),U}}),_.mkdev(h,g,C)},forceLoadFile(o){if(o.isDevice||o.isFolder||o.link||o.contents)return!0;if(typeof XMLHttpRequest<"u")throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");if(x)try{o.contents=Wt(x(o.url),!0),o.usedBytes=o.contents.length}catch{throw new _.ErrnoError(29)}else throw new Error("Cannot load without read() or XMLHttpRequest.")},createLazyFile(o,n,i,u,h){function g(){this.lengthKnown=!1,this.chunks=[]}if(g.prototype.get=function(W){if(!(W>this.length-1||W<0)){var ae=W%this.chunkSize,we=W/this.chunkSize|0;return this.getter(we)[ae]}},g.prototype.setDataGetter=function(W){this.getter=W},g.prototype.cacheLength=function(){var W=new XMLHttpRequest;if(W.open("HEAD",i,!1),W.send(null),!(W.status>=200&&W.status<300||W.status===304))throw new Error("Couldn't load "+i+". Status: "+W.status);var ae=Number(W.getResponseHeader("Content-length")),we,De=(we=W.getResponseHeader("Accept-Ranges"))&&we==="bytes",Ie=(we=W.getResponseHeader("Content-Encoding"))&&we==="gzip",G=1024*1024;De||(G=ae);var ee=(xe,Ge)=>{if(xe>Ge)throw new Error("invalid range ("+xe+", "+Ge+") or no bytes requested!");if(Ge>ae-1)throw new Error("only "+ae+" bytes available! programmer error!");var Oe=new XMLHttpRequest;if(Oe.open("GET",i,!1),ae!==G&&Oe.setRequestHeader("Range","bytes="+xe+"-"+Ge),Oe.responseType="arraybuffer",Oe.overrideMimeType&&Oe.overrideMimeType("text/plain; charset=x-user-defined"),Oe.send(null),!(Oe.status>=200&&Oe.status<300||Oe.status===304))throw new Error("Couldn't load "+i+". Status: "+Oe.status);return Oe.response!==void 0?new Uint8Array(Oe.response||[]):Wt(Oe.responseText||"",!0)},Se=this;Se.setDataGetter(xe=>{var Ge=xe*G,Oe=(xe+1)*G-1;if(Oe=Math.min(Oe,ae-1),typeof Se.chunks[xe]>"u"&&(Se.chunks[xe]=ee(Ge,Oe)),typeof Se.chunks[xe]>"u")throw new Error("doXHR failed!");return Se.chunks[xe]}),(Ie||!ae)&&(G=ae=1,ae=this.getter(0).length,G=ae,F("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=ae,this._chunkSize=G,this.lengthKnown=!0},typeof XMLHttpRequest<"u"){if(!p)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var C=new g;Object.defineProperties(C,{length:{get:function(){return this.lengthKnown||this.cacheLength(),this._length}},chunkSize:{get:function(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}});var S={isDevice:!1,contents:C}}else var S={isDevice:!1,url:i};var w=_.createFile(o,n,S,u,h);S.contents?w.contents=S.contents:S.url&&(w.contents=null,w.url=S.url),Object.defineProperties(w,{usedBytes:{get:function(){return this.contents.length}}});var A={},P=Object.keys(w.stream_ops);P.forEach(U=>{var W=w.stream_ops[U];A[U]=(...ae)=>(_.forceLoadFile(w),W(...ae))});function N(U,W,ae,we,De){var Ie=U.node.contents;if(De>=Ie.length)return 0;var G=Math.min(Ie.length-De,we);if(L(G>=0),Ie.slice)for(var ee=0;ee<G;ee++)W[ae+ee]=Ie[De+ee];else for(var ee=0;ee<G;ee++)W[ae+ee]=Ie.get(De+ee);return G}return A.read=(U,W,ae,we,De)=>(_.forceLoadFile(w),N(U,W,ae,we,De)),A.mmap=(U,W,ae,we,De)=>{_.forceLoadFile(w);var Ie=Pr();if(!Ie)throw new _.ErrnoError(48);return N(U,H,Ie,W,ae),{ptr:Ie,allocated:!0}},w.stream_ops=A,w},absolutePath(){pe("FS.absolutePath has been removed; use PATH_FS.resolve instead")},createFolder(){pe("FS.createFolder has been removed; use FS.mkdir instead")},createLink(){pe("FS.createLink has been removed; use FS.symlink instead")},joinPath(){pe("FS.joinPath has been removed; use PATH.join instead")},mmapAlloc(){pe("FS.mmapAlloc has been replaced by the top level function mmapAlloc")},standardizePath(){pe("FS.standardizePath has been removed; use PATH.normalize instead")}},Le={mount(o){return r.websocket=r.websocket&&typeof r.websocket=="object"?r.websocket:{},r.websocket._callbacks={},r.websocket.on=function(n,i){return typeof i=="function"&&(this._callbacks[n]=i),this},r.websocket.emit=function(n,i){typeof this._callbacks[n]=="function"&&this._callbacks[n].call(this,i)},_.createNode(null,"/",16895,0)},createSocket(o,n,i){n&=-526337;var u=n==1;if(u&&i&&i!=6)throw new _.ErrnoError(66);var h={family:o,type:n,protocol:i,server:null,error:null,peers:{},pending:[],recv_queue:[],sock_ops:Le.websocket_sock_ops},g=Le.nextname(),C=_.createNode(Le.root,g,49152,0);C.sock=h;var S=_.createStream({path:g,node:C,flags:2,seekable:!1,stream_ops:Le.stream_ops});return h.stream=S,h},getSocket(o){var n=_.getStream(o);return!n||!_.isSocket(n.node.mode)?null:n.node.sock},stream_ops:{poll(o){var n=o.node.sock;return n.sock_ops.poll(n)},ioctl(o,n,i){var u=o.node.sock;return u.sock_ops.ioctl(u,n,i)},read(o,n,i,u,h){var g=o.node.sock,C=g.sock_ops.recvmsg(g,u);return C?(n.set(C.buffer,i),C.buffer.length):0},write(o,n,i,u,h){var g=o.node.sock;return g.sock_ops.sendmsg(g,n,i,u)},close(o){var n=o.node.sock;n.sock_ops.close(n)}},nextname(){return Le.nextname.current||(Le.nextname.current=0),"socket["+Le.nextname.current+++"]"},websocket_sock_ops:{createPeer(o,n,i){var u;if(typeof n=="object"&&(u=n,n=null,i=null),u)if(u._socket)n=u._socket.remoteAddress,i=u._socket.remotePort;else{var h=/ws[s]?:\/\/([^:]+):(\d+)/.exec(u.url);if(!h)throw new Error("WebSocket URL must be in the format ws(s)://address:port");n=h[1],i=parseInt(h[2],10)}else try{var g=r.websocket&&typeof r.websocket=="object",C="ws:#".replace("#","//");if(g&&typeof r.websocket.url=="string"&&(C=r.websocket.url),C==="ws://"||C==="wss://"){var S=n.split("/");C=C+S[0]+":"+i+"/"+S.slice(1).join("/")}var w="binary";g&&typeof r.websocket.subprotocol=="string"&&(w=r.websocket.subprotocol);var A=void 0;w!=="null"&&(w=w.replace(/^ +| +$/g,"").split(/ *, */),A=w),g&&r.websocket.subprotocol===null&&(w="null",A=void 0);var P;f?P=O("ws"):P=WebSocket,u=new P(C,A),u.binaryType="arraybuffer"}catch{throw new _.ErrnoError(23)}var N={addr:n,port:i,socket:u,dgram_send_queue:[]};return Le.websocket_sock_ops.addPeer(o,N),Le.websocket_sock_ops.handlePeerEvents(o,N),o.type===2&&typeof o.sport<"u"&&N.dgram_send_queue.push(new Uint8Array([255,255,255,255,"p".charCodeAt(0),"o".charCodeAt(0),"r".charCodeAt(0),"t".charCodeAt(0),(o.sport&65280)>>8,o.sport&255])),N},getPeer(o,n,i){return o.peers[n+":"+i]},addPeer(o,n){o.peers[n.addr+":"+n.port]=n},removePeer(o,n){delete o.peers[n.addr+":"+n.port]},handlePeerEvents(o,n){var i=!0,u=function(){r.websocket.emit("open",o.stream.fd);try{for(var g=n.dgram_send_queue.shift();g;)n.socket.send(g),g=n.dgram_send_queue.shift()}catch{n.socket.close()}};function h(g){if(typeof g=="string"){var C=new TextEncoder;g=C.encode(g)}else{if(L(g.byteLength!==void 0),g.byteLength==0)return;g=new Uint8Array(g)}var S=i;if(i=!1,S&&g.length===10&&g[0]===255&&g[1]===255&&g[2]===255&&g[3]===255&&g[4]==="p".charCodeAt(0)&&g[5]==="o".charCodeAt(0)&&g[6]==="r".charCodeAt(0)&&g[7]==="t".charCodeAt(0)){var w=g[8]<<8|g[9];Le.websocket_sock_ops.removePeer(o,n),n.port=w,Le.websocket_sock_ops.addPeer(o,n);return}o.recv_queue.push({addr:n.addr,port:n.port,data:g}),r.websocket.emit("message",o.stream.fd)}f?(n.socket.on("open",u),n.socket.on("message",function(g,C){C&&h(new Uint8Array(g).buffer)}),n.socket.on("close",function(){r.websocket.emit("close",o.stream.fd)}),n.socket.on("error",function(g){o.error=14,r.websocket.emit("error",[o.stream.fd,o.error,"ECONNREFUSED: Connection refused"])})):(n.socket.onopen=u,n.socket.onclose=function(){r.websocket.emit("close",o.stream.fd)},n.socket.onmessage=function(C){h(C.data)},n.socket.onerror=function(g){o.error=14,r.websocket.emit("error",[o.stream.fd,o.error,"ECONNREFUSED: Connection refused"])})},poll(o){if(o.type===1&&o.server)return o.pending.length?65:0;var n=0,i=o.type===1?Le.websocket_sock_ops.getPeer(o,o.daddr,o.dport):null;return(o.recv_queue.length||!i||i&&i.socket.readyState===i.socket.CLOSING||i&&i.socket.readyState===i.socket.CLOSED)&&(n|=65),(!i||i&&i.socket.readyState===i.socket.OPEN)&&(n|=4),(i&&i.socket.readyState===i.socket.CLOSING||i&&i.socket.readyState===i.socket.CLOSED)&&(n|=16),n},ioctl(o,n,i){switch(n){case 21531:var u=0;return o.recv_queue.length&&(u=o.recv_queue[0].data.length),T[i>>2]=u,Y(u),0;default:return 28}},close(o){if(o.server){try{o.server.close()}catch{}o.server=null}for(var n=Object.keys(o.peers),i=0;i<n.length;i++){var u=o.peers[n[i]];try{u.socket.close()}catch{}Le.websocket_sock_ops.removePeer(o,u)}return 0},bind(o,n,i){if(typeof o.saddr<"u"||typeof o.sport<"u")throw new _.ErrnoError(28);if(o.saddr=n,o.sport=i,o.type===2){o.server&&(o.server.close(),o.server=null);try{o.sock_ops.listen(o,0)}catch(u){if(u.name!=="ErrnoError"||u.errno!==138)throw u}}},connect(o,n,i){if(o.server)throw new _.ErrnoError(138);if(typeof o.daddr<"u"&&typeof o.dport<"u"){var u=Le.websocket_sock_ops.getPeer(o,o.daddr,o.dport);if(u)throw u.socket.readyState===u.socket.CONNECTING?new _.ErrnoError(7):new _.ErrnoError(30)}var h=Le.websocket_sock_ops.createPeer(o,n,i);throw o.daddr=h.addr,o.dport=h.port,new _.ErrnoError(26)},listen(o,n){if(!f)throw new _.ErrnoError(138);if(o.server)throw new _.ErrnoError(28);var i=O("ws").Server,u=o.saddr;o.server=new i({host:u,port:o.sport}),r.websocket.emit("listen",o.stream.fd),o.server.on("connection",function(h){if(o.type===1){var g=Le.createSocket(o.family,o.type,o.protocol),C=Le.websocket_sock_ops.createPeer(g,h);g.daddr=C.addr,g.dport=C.port,o.pending.push(g),r.websocket.emit("connection",g.stream.fd)}else Le.websocket_sock_ops.createPeer(o,h),r.websocket.emit("connection",o.stream.fd)}),o.server.on("close",function(){r.websocket.emit("close",o.stream.fd),o.server=null}),o.server.on("error",function(h){o.error=23,r.websocket.emit("error",[o.stream.fd,o.error,"EHOSTUNREACH: Host is unreachable"])})},accept(o){if(!o.server||!o.pending.length)throw new _.ErrnoError(28);var n=o.pending.shift();return n.stream.flags=o.stream.flags,n},getname(o,n){var i,u;if(n){if(o.daddr===void 0||o.dport===void 0)throw new _.ErrnoError(53);i=o.daddr,u=o.dport}else i=o.saddr||0,u=o.sport||0;return{addr:i,port:u}},sendmsg(o,n,i,u,h,g){if(o.type===2){if((h===void 0||g===void 0)&&(h=o.daddr,g=o.dport),h===void 0||g===void 0)throw new _.ErrnoError(17)}else h=o.daddr,g=o.dport;var C=Le.websocket_sock_ops.getPeer(o,h,g);if(o.type===1){if(!C||C.socket.readyState===C.socket.CLOSING||C.socket.readyState===C.socket.CLOSED)throw new _.ErrnoError(53);if(C.socket.readyState===C.socket.CONNECTING)throw new _.ErrnoError(6)}ArrayBuffer.isView(n)&&(i+=n.byteOffset,n=n.buffer);var S;if(S=n.slice(i,i+u),o.type===2&&(!C||C.socket.readyState!==C.socket.OPEN))return(!C||C.socket.readyState===C.socket.CLOSING||C.socket.readyState===C.socket.CLOSED)&&(C=Le.websocket_sock_ops.createPeer(o,h,g)),C.dgram_send_queue.push(S),u;try{return C.socket.send(S),u}catch{throw new _.ErrnoError(28)}},recvmsg(o,n){if(o.type===1&&o.server)throw new _.ErrnoError(53);var i=o.recv_queue.shift();if(!i){if(o.type===1){var u=Le.websocket_sock_ops.getPeer(o,o.daddr,o.dport);if(!u)throw new _.ErrnoError(53);if(u.socket.readyState===u.socket.CLOSING||u.socket.readyState===u.socket.CLOSED)return null;throw new _.ErrnoError(6)}throw new _.ErrnoError(6)}var h=i.data.byteLength||i.data.length,g=i.data.byteOffset||0,C=i.data.buffer||i.data,S=Math.min(n,h),w={buffer:new Uint8Array(C,g,S),addr:i.addr,port:i.port};if(o.type===1&&S<h){var A=h-S;i.data=new Uint8Array(C,g+S,A),o.recv_queue.unshift(i)}return w}}},wt=o=>{var n=Le.getSocket(o);if(!n)throw new _.ErrnoError(8);return n},_r=o=>(o&255)+"."+(o>>8&255)+"."+(o>>16&255)+"."+(o>>24&255),jr=o=>{var n="",i=0,u=0,h=0,g=0,C=0,S=0,w=[o[0]&65535,o[0]>>16,o[1]&65535,o[1]>>16,o[2]&65535,o[2]>>16,o[3]&65535,o[3]>>16],A=!0,P="";for(S=0;S<5;S++)if(w[S]!==0){A=!1;break}if(A){if(P=_r(w[6]|w[7]<<16),w[5]===-1)return n="::ffff:",n+=P,n;if(w[5]===0)return n="::",P==="0.0.0.0"&&(P=""),P==="0.0.0.1"&&(P="1"),n+=P,n}for(i=0;i<8;i++)w[i]===0&&(i-h>1&&(C=0),h=i,C++),C>u&&(u=C,g=i-u+1);for(i=0;i<8;i++){if(u>1&&w[i]===0&&i>=g&&i<g+u){i===g&&(n+=":",g===0&&(n+=":"));continue}n+=Number(uo(w[i]&65535)).toString(16),n+=i<7?":":""}return n},Fr=(o,n)=>{var i=Q[o>>1],u=uo(q[o+2>>1]),h;switch(i){case 2:if(n!==16)return{errno:28};h=T[o+4>>2],h=_r(h);break;case 10:if(n!==28)return{errno:28};h=[T[o+8>>2],T[o+12>>2],T[o+16>>2],T[o+20>>2]],h=jr(h);break;default:return{errno:5}}return{family:i,addr:h,port:u}},Yt=o=>{for(var n=o.split("."),i=0;i<4;i++){var u=Number(n[i]);if(isNaN(u))return null;n[i]=u}return(n[0]|n[1]<<8|n[2]<<16|n[3]<<24)>>>0},Qt=o=>parseInt(o),gr=o=>{var n,i,u,h,g=/^((?=.*::)(?!.*::.+::)(::)?([\dA-F]{1,4}:(:|\b)|){5}|([\dA-F]{1,4}:){6})((([\dA-F]{1,4}((?!\3)::|:\b|$))|(?!\2\3)){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4})$/i,C=[];if(!g.test(o))return null;if(o==="::")return[0,0,0,0,0,0,0,0];for(o.startsWith("::")?o=o.replace("::","Z:"):o=o.replace("::",":Z:"),o.indexOf(".")>0?(o=o.replace(new RegExp("[.]","g"),":"),n=o.split(":"),n[n.length-4]=Qt(n[n.length-4])+Qt(n[n.length-3])*256,n[n.length-3]=Qt(n[n.length-2])+Qt(n[n.length-1])*256,n=n.slice(0,n.length-2)):n=o.split(":"),u=0,h=0,i=0;i<n.length;i++)if(typeof n[i]=="string")if(n[i]==="Z"){for(h=0;h<8-n.length+1;h++)C[i+h]=0;u=h-1}else C[i+u]=Gt(parseInt(n[i],16));else C[i+u]=n[i];return[C[1]<<16|C[0],C[3]<<16|C[2],C[5]<<16|C[4],C[7]<<16|C[6]]},ze={address_map:{id:1,addrs:{},names:{}},lookup_name(o){var n=Yt(o);if(n!==null||(n=gr(o),n!==null))return o;var i;if(ze.address_map.addrs[o])i=ze.address_map.addrs[o];else{var u=ze.address_map.id++;L(u<65535,"exceeded max address mappings of 65535"),i="172.29."+(u&255)+"."+(u&65280),ze.address_map.names[i]=o,ze.address_map.addrs[o]=i}return i},lookup_addr(o){return ze.address_map.names[o]?ze.address_map.names[o]:null}},mr=(o,n,i)=>{if(i&&o===0)return null;var u=Fr(o,n);if(u.errno)throw new _.ErrnoError(u.errno);return u.addr=ze.lookup_addr(u.addr)||u.addr,u};function Lo(o,n,i,u,h,g){try{var C=wt(o),S=mr(n,i);return C.sock_ops.bind(C,S.addr,S.port),0}catch(w){if(typeof _>"u"||w.name!=="ErrnoError")throw w;return-w.errno}}function Do(o,n,i,u,h,g){try{var C=wt(o),S=mr(n,i);return C.sock_ops.connect(C,S.addr,S.port),0}catch(w){if(typeof _>"u"||w.name!=="ErrnoError")throw w;return-w.errno}}var ce={DEFAULT_POLLMASK:5,calculateAt(o,n,i){if(ve.isAbs(n))return n;var u;if(o===-100)u=_.cwd();else{var h=ce.getStreamFromFD(o);u=h.path}if(n.length==0){if(!i)throw new _.ErrnoError(44);return u}return ve.join2(u,n)},doStat(o,n,i){var u=o(n);T[i>>2]=u.dev,Y(u.dev),T[i+4>>2]=u.mode,Y(u.mode),j[i+8>>2]=u.nlink,Y(u.nlink),T[i+12>>2]=u.uid,Y(u.uid),T[i+16>>2]=u.gid,Y(u.gid),T[i+20>>2]=u.rdev,Y(u.rdev),he=[u.size>>>0,(Z=u.size,+Math.abs(Z)>=1?Z>0?+Math.floor(Z/4294967296)>>>0:~~+Math.ceil((Z-+(~~Z>>>0))/4294967296)>>>0:0)],T[i+24>>2]=he[0],T[i+28>>2]=he[1],st(u.size),T[i+32>>2]=4096,Y(4096),T[i+36>>2]=u.blocks,Y(u.blocks);var h=u.atime.getTime(),g=u.mtime.getTime(),C=u.ctime.getTime();return he=[Math.floor(h/1e3)>>>0,(Z=Math.floor(h/1e3),+Math.abs(Z)>=1?Z>0?+Math.floor(Z/4294967296)>>>0:~~+Math.ceil((Z-+(~~Z>>>0))/4294967296)>>>0:0)],T[i+40>>2]=he[0],T[i+44>>2]=he[1],st(Math.floor(h/1e3)),j[i+48>>2]=h%1e3*1e3,Y(h%1e3*1e3),he=[Math.floor(g/1e3)>>>0,(Z=Math.floor(g/1e3),+Math.abs(Z)>=1?Z>0?+Math.floor(Z/4294967296)>>>0:~~+Math.ceil((Z-+(~~Z>>>0))/4294967296)>>>0:0)],T[i+56>>2]=he[0],T[i+60>>2]=he[1],st(Math.floor(g/1e3)),j[i+64>>2]=g%1e3*1e3,Y(g%1e3*1e3),he=[Math.floor(C/1e3)>>>0,(Z=Math.floor(C/1e3),+Math.abs(Z)>=1?Z>0?+Math.floor(Z/4294967296)>>>0:~~+Math.ceil((Z-+(~~Z>>>0))/4294967296)>>>0:0)],T[i+72>>2]=he[0],T[i+76>>2]=he[1],st(Math.floor(C/1e3)),j[i+80>>2]=C%1e3*1e3,Y(C%1e3*1e3),he=[u.ino>>>0,(Z=u.ino,+Math.abs(Z)>=1?Z>0?+Math.floor(Z/4294967296)>>>0:~~+Math.ceil((Z-+(~~Z>>>0))/4294967296)>>>0:0)],T[i+88>>2]=he[0],T[i+92>>2]=he[1],st(u.ino),0},doMsync(o,n,i,u,h){if(!_.isFile(n.node.mode))throw new _.ErrnoError(43);if(u&2)return 0;var g=B.slice(o,o+i);_.msync(n,g,h,i,u)},varargs:void 0,get(){L(ce.varargs!=null);var o=T[+ce.varargs>>2];return ce.varargs+=4,o},getp(){return ce.get()},getStr(o){var n=at(o);return n},getStreamFromFD(o){var n=_.getStreamChecked(o);return n}};function Ro(o,n,i,u){try{if(n=ce.getStr(n),L(u===0),n=ce.calculateAt(o,n),i&-8)return-28;var h=_.lookupPath(n,{follow:!0}),g=h.node;if(!g)return-44;var C="";return i&4&&(C+="r"),i&2&&(C+="w"),i&1&&(C+="x"),C&&_.nodePermissions(g,C)?-2:0}catch(S){if(typeof _>"u"||S.name!=="ErrnoError")throw S;return-S.errno}}function Io(o,n,i){ce.varargs=i;try{var u=ce.getStreamFromFD(o);switch(n){case 0:{var h=ce.get();if(h<0)return-28;for(;_.streams[h];)h++;var g;return g=_.createStream(u,h),g.fd}case 1:case 2:return 0;case 3:return u.flags;case 4:{var h=ce.get();return u.flags|=h,0}case 12:{var h=ce.getp(),C=0;return Q[h+C>>1]=2,rt(2),0}case 13:case 14:return 0}return-28}catch(S){if(typeof _>"u"||S.name!=="ErrnoError")throw S;return-S.errno}}function Oo(o,n){try{var i=ce.getStreamFromFD(o);return ce.doStat(_.stat,i.path,n)}catch(u){if(typeof _>"u"||u.name!=="ErrnoError")throw u;return-u.errno}}var Ot=(o,n,i)=>(L(typeof i=="number","stringToUTF8(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!"),hr(o,B,n,i));function Po(o,n,i){try{var u=ce.getStreamFromFD(o);u.getdents||(u.getdents=_.readdir(u.path));for(var h=280,g=0,C=_.llseek(u,0,1),S=Math.floor(C/h);S<u.getdents.length&&g+h<=i;){var w,A,P=u.getdents[S];if(P===".")w=u.node.id,A=4;else if(P===".."){var N=_.lookupPath(u.path,{parent:!0});w=N.node.id,A=4}else{var U=_.lookupNode(u.node,P);w=U.id,A=_.isChrdev(U.mode)?2:_.isDir(U.mode)?4:_.isLink(U.mode)?10:8}L(w),he=[w>>>0,(Z=w,+Math.abs(Z)>=1?Z>0?+Math.floor(Z/4294967296)>>>0:~~+Math.ceil((Z-+(~~Z>>>0))/4294967296)>>>0:0)],T[n+g>>2]=he[0],T[n+g+4>>2]=he[1],st(w),he=[(S+1)*h>>>0,(Z=(S+1)*h,+Math.abs(Z)>=1?Z>0?+Math.floor(Z/4294967296)>>>0:~~+Math.ceil((Z-+(~~Z>>>0))/4294967296)>>>0:0)],T[n+g+8>>2]=he[0],T[n+g+12>>2]=he[1],st((S+1)*h),Q[n+g+16>>1]=280,rt(280),H[n+g+18]=A,yt(A),Ot(P,n+g+19,256),g+=h,S+=1}return _.llseek(u,S*h,0),g}catch(W){if(typeof _>"u"||W.name!=="ErrnoError")throw W;return-W.errno}}var Cr=(o,n,i,u,h)=>{switch(n){case 2:i=Yt(i),Or(o,16),h&&(T[h>>2]=16,Y(16)),Q[o>>1]=n,rt(n),T[o+4>>2]=i,Y(i),Q[o+2>>1]=Gt(u),rt(Gt(u));break;case 10:i=gr(i),Or(o,28),h&&(T[h>>2]=28,Y(28)),T[o>>2]=n,Y(n),T[o+8>>2]=i[0],Y(i[0]),T[o+12>>2]=i[1],Y(i[1]),T[o+16>>2]=i[2],Y(i[2]),T[o+20>>2]=i[3],Y(i[3]),Q[o+2>>1]=Gt(u),rt(Gt(u));break;default:return 5}return 0};function ko(o,n,i,u,h,g){try{var C=wt(o),S=Cr(n,C.family,ze.lookup_name(C.saddr||"0.0.0.0"),C.sport,i);return L(!S),0}catch(w){if(typeof _>"u"||w.name!=="ErrnoError")throw w;return-w.errno}}function jo(o,n,i,u,h,g){try{var C=wt(o);return n===1&&i===4?(T[u>>2]=C.error,Y(C.error),T[h>>2]=4,Y(4),C.error=null,0):-50}catch(S){if(typeof _>"u"||S.name!=="ErrnoError")throw S;return-S.errno}}function Fo(o,n,i){ce.varargs=i;try{var u=ce.getStreamFromFD(o);switch(n){case 21509:return u.tty?0:-59;case 21505:{if(!u.tty)return-59;if(u.tty.ops.ioctl_tcgets){var h=u.tty.ops.ioctl_tcgets(u),g=ce.getp();T[g>>2]=h.c_iflag||0,Y(h.c_iflag||0),T[g+4>>2]=h.c_oflag||0,Y(h.c_oflag||0),T[g+8>>2]=h.c_cflag||0,Y(h.c_cflag||0),T[g+12>>2]=h.c_lflag||0,Y(h.c_lflag||0);for(var C=0;C<32;C++)H[g+C+17]=h.c_cc[C]||0,yt(h.c_cc[C]||0);return 0}return 0}case 21510:case 21511:case 21512:return u.tty?0:-59;case 21506:case 21507:case 21508:{if(!u.tty)return-59;if(u.tty.ops.ioctl_tcsets){for(var g=ce.getp(),S=T[g>>2],w=T[g+4>>2],A=T[g+8>>2],P=T[g+12>>2],N=[],C=0;C<32;C++)N.push(H[g+C+17]);return u.tty.ops.ioctl_tcsets(u.tty,n,{c_iflag:S,c_oflag:w,c_cflag:A,c_lflag:P,c_cc:N})}return 0}case 21519:{if(!u.tty)return-59;var g=ce.getp();return T[g>>2]=0,Y(0),0}case 21520:return u.tty?-28:-59;case 21531:{var g=ce.getp();return _.ioctl(u,n,g)}case 21523:{if(!u.tty)return-59;if(u.tty.ops.ioctl_tiocgwinsz){var U=u.tty.ops.ioctl_tiocgwinsz(u.tty),g=ce.getp();Q[g>>1]=U[0],rt(U[0]),Q[g+2>>1]=U[1],rt(U[1])}return 0}case 21524:return u.tty?0:-59;case 21515:return u.tty?0:-59;default:return-28}}catch(W){if(typeof _>"u"||W.name!=="ErrnoError")throw W;return-W.errno}}function Bo(o,n){try{return o=ce.getStr(o),ce.doStat(_.lstat,o,n)}catch(i){if(typeof _>"u"||i.name!=="ErrnoError")throw i;return-i.errno}}function No(o,n,i,u){try{n=ce.getStr(n);var h=u&256,g=u&4096;return u=u&-6401,L(!u,`unknown flags in __syscall_newfstatat: ${u}`),n=ce.calculateAt(o,n,g),ce.doStat(h?_.lstat:_.stat,n,i)}catch(C){if(typeof _>"u"||C.name!=="ErrnoError")throw C;return-C.errno}}function $o(o,n,i,u){ce.varargs=u;try{n=ce.getStr(n),n=ce.calculateAt(o,n);var h=u?ce.get():0;return _.open(n,i,h).fd}catch(g){if(typeof _>"u"||g.name!=="ErrnoError")throw g;return-g.errno}}function Go(o,n,i){try{for(var u=0,h=0;h<n;h++){var g=o+8*h,C=T[g>>2],S=Q[g+4>>1],w=32,A=_.getStream(C);A&&(w=ce.DEFAULT_POLLMASK,A.stream_ops.poll&&(w=A.stream_ops.poll(A,-1))),w&=S|8|16,w&&u++,Q[g+6>>1]=w,rt(w)}return u}catch(P){if(typeof _>"u"||P.name!=="ErrnoError")throw P;return-P.errno}}function Uo(o,n,i,u,h,g){try{var C=wt(o),S=C.sock_ops.recvmsg(C,i);if(!S)return 0;if(h){var w=Cr(h,C.family,ze.lookup_name(S.addr),S.port,g);L(!w)}return B.set(S.buffer,n),S.buffer.byteLength}catch(A){if(typeof _>"u"||A.name!=="ErrnoError")throw A;return-A.errno}}function Vo(o,n,i,u){try{return n=ce.getStr(n),u=ce.getStr(u),n=ce.calculateAt(o,n),u=ce.calculateAt(i,u),_.rename(n,u),0}catch(h){if(typeof _>"u"||h.name!=="ErrnoError")throw h;return-h.errno}}function Ho(o){try{return o=ce.getStr(o),_.rmdir(o),0}catch(n){if(typeof _>"u"||n.name!=="ErrnoError")throw n;return-n.errno}}function zo(o,n,i,u,h,g){try{var C=wt(o),S=mr(h,g,!0);return S?C.sock_ops.sendmsg(C,H,n,i,S.addr,S.port):_.write(C.stream,H,n,i)}catch(w){if(typeof _>"u"||w.name!=="ErrnoError")throw w;return-w.errno}}function Wo(o,n,i){try{var u=Le.createSocket(o,n,i);return L(u.stream.fd<64),u.stream.fd}catch(h){if(typeof _>"u"||h.name!=="ErrnoError")throw h;return-h.errno}}function Yo(o,n){try{return o=ce.getStr(o),ce.doStat(_.stat,o,n)}catch(i){if(typeof _>"u"||i.name!=="ErrnoError")throw i;return-i.errno}}function Qo(o,n,i){try{return n=ce.getStr(n),n=ce.calculateAt(o,n),i===0?_.unlink(n):i===512?_.rmdir(n):pe("Invalid flags passed to unlinkat"),0}catch(u){if(typeof _>"u"||u.name!=="ErrnoError")throw u;return-u.errno}}var Xo=(o,n,i,u,h)=>{},qo=()=>{for(var o=new Array(256),n=0;n<256;++n)o[n]=String.fromCharCode(n);Br=o},Br,We=o=>{for(var n="",i=o;B[i];)n+=Br[B[i++]];return n},Et={},xt={},Xt={},Mt,ye=o=>{throw new Mt(o)},Nr,qt=o=>{throw new Nr(o)},Tt=(o,n,i)=>{o.forEach(function(S){Xt[S]=n});function u(S){var w=i(S);w.length!==o.length&&qt("Mismatched type converter count");for(var A=0;A<o.length;++A)ut(o[A],w[A])}var h=new Array(n.length),g=[],C=0;n.forEach((S,w)=>{xt.hasOwnProperty(S)?h[w]=xt[S]:(g.push(S),Et.hasOwnProperty(S)||(Et[S]=[]),Et[S].push(()=>{h[w]=xt[S],++C,C===g.length&&u(h)}))}),g.length===0&&u(h)};function Jo(o,n,i={}){var u=n.name;if(o||ye(`type "${u}" must have a positive integer typeid pointer`),xt.hasOwnProperty(o)){if(i.ignoreDuplicateRegistrations)return;ye(`Cannot register type '${u}' twice`)}if(xt[o]=n,delete Xt[o],Et.hasOwnProperty(o)){var h=Et[o];delete Et[o],h.forEach(g=>g())}}function ut(o,n,i={}){if(!("argPackAdvance"in n))throw new TypeError("registerType registeredInstance requires argPackAdvance");return Jo(o,n,i)}var gt=8,Zo=(o,n,i,u)=>{n=We(n),ut(o,{name:n,fromWireType:function(h){return!!h},toWireType:function(h,g){return g?i:u},argPackAdvance:gt,readValueFromPointer:function(h){return this.fromWireType(B[h])},destructorFunction:null})},en=o=>({count:o.count,deleteScheduled:o.deleteScheduled,preservePointerOnDelete:o.preservePointerOnDelete,ptr:o.ptr,ptrType:o.ptrType,smartPtr:o.smartPtr,smartPtrType:o.smartPtrType}),yr=o=>{function n(i){return i.$$.ptrType.registeredClass.name}ye(n(o)+" instance already deleted")},Sr=!1,$r=o=>{},tn=o=>{o.smartPtr?o.smartPtrType.rawDestructor(o.smartPtr):o.ptrType.registeredClass.rawDestructor(o.ptr)},Gr=o=>{o.count.value-=1;var n=o.count.value===0;n&&tn(o)},Ur=(o,n,i)=>{if(n===i)return o;if(i.baseClass===void 0)return null;var u=Ur(o,n,i.baseClass);return u===null?null:i.downcast(u)},Vr={},rn=()=>Object.keys(jt).length,on=()=>{var o=[];for(var n in jt)jt.hasOwnProperty(n)&&o.push(jt[n]);return o},Pt=[],xr=()=>{for(;Pt.length;){var o=Pt.pop();o.$$.deleteScheduled=!1,o.delete()}},kt,nn=o=>{kt=o,Pt.length&&kt&&kt(xr)},sn=()=>{r.getInheritedInstanceCount=rn,r.getLiveInheritedInstances=on,r.flushPendingDeletes=xr,r.setDelayFunction=nn},jt={},an=(o,n)=>{for(n===void 0&&ye("ptr should not be undefined");o.baseClass;)n=o.upcast(n),o=o.baseClass;return n},cn=(o,n)=>(n=an(o,n),jt[n]),Jt=(o,n)=>{(!n.ptrType||!n.ptr)&&qt("makeClassHandle requires ptr and ptrType");var i=!!n.smartPtrType,u=!!n.smartPtr;return i!==u&&qt("Both smartPtrType and smartPtr must be specified"),n.count={value:1},Ft(Object.create(o,{$$:{value:n,writable:!0}}))};function Hr(o){var n=this.getPointee(o);if(!n)return this.destructor(o),null;var i=cn(this.registeredClass,n);if(i!==void 0){if(i.$$.count.value===0)return i.$$.ptr=n,i.$$.smartPtr=o,i.clone();var u=i.clone();return this.destructor(o),u}function h(){return this.isSmartPointer?Jt(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:n,smartPtrType:this,smartPtr:o}):Jt(this.registeredClass.instancePrototype,{ptrType:this,ptr:o})}var g=this.registeredClass.getActualType(n),C=Vr[g];if(!C)return h.call(this);var S;this.isConst?S=C.constPointerType:S=C.pointerType;var w=Ur(n,this.registeredClass,S.registeredClass);return w===null?h.call(this):this.isSmartPointer?Jt(S.registeredClass.instancePrototype,{ptrType:S,ptr:w,smartPtrType:this,smartPtr:o}):Jt(S.registeredClass.instancePrototype,{ptrType:S,ptr:w})}var Ft=o=>typeof FinalizationRegistry>"u"?(Ft=n=>n,o):(Sr=new FinalizationRegistry(n=>{console.warn(n.leakWarning.stack.replace(/^Error: /,"")),Gr(n.$$)}),Ft=n=>{var i=n.$$,u=!!i.smartPtr;if(u){var h={$$:i},g=i.ptrType.registeredClass;h.leakWarning=new Error(`Embind found a leaked C++ instance ${g.name} <${ct(i.ptr)}>.
|
|
1089
|
+
We'll free it automatically in this case, but this functionality is not reliable across various environments.
|
|
1090
|
+
Make sure to invoke .delete() manually once you're done with the instance instead.
|
|
1091
|
+
Originally allocated`),"captureStackTrace"in Error&&Error.captureStackTrace(h.leakWarning,Hr),Sr.register(n,h,n)}return n},$r=n=>Sr.unregister(n),Ft(o)),ln=()=>{Object.assign(Zt.prototype,{isAliasOf(o){if(!(this instanceof Zt)||!(o instanceof Zt))return!1;var n=this.$$.ptrType.registeredClass,i=this.$$.ptr;o.$$=o.$$;for(var u=o.$$.ptrType.registeredClass,h=o.$$.ptr;n.baseClass;)i=n.upcast(i),n=n.baseClass;for(;u.baseClass;)h=u.upcast(h),u=u.baseClass;return n===u&&i===h},clone(){if(this.$$.ptr||yr(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var o=Ft(Object.create(Object.getPrototypeOf(this),{$$:{value:en(this.$$)}}));return o.$$.count.value+=1,o.$$.deleteScheduled=!1,o},delete(){this.$$.ptr||yr(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&ye("Object already scheduled for deletion"),$r(this),Gr(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)},isDeleted(){return!this.$$.ptr},deleteLater(){return this.$$.ptr||yr(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&ye("Object already scheduled for deletion"),Pt.push(this),Pt.length===1&&kt&&kt(xr),this.$$.deleteScheduled=!0,this}})};function Zt(){}var er=(o,n)=>Object.defineProperty(n,"name",{value:o}),zr=(o,n,i)=>{if(o[n].overloadTable===void 0){var u=o[n];o[n]=function(...h){return o[n].overloadTable.hasOwnProperty(h.length)||ye(`Function '${i}' called with an invalid number of arguments (${h.length}) - expects one of (${o[n].overloadTable})!`),o[n].overloadTable[h.length].apply(this,h)},o[n].overloadTable=[],o[n].overloadTable[u.argCount]=u}},Wr=(o,n,i)=>{r.hasOwnProperty(o)?((i===void 0||r[o].overloadTable!==void 0&&r[o].overloadTable[i]!==void 0)&&ye(`Cannot register public name '${o}' twice`),zr(r,o,o),r.hasOwnProperty(i)&&ye(`Cannot register multiple overloads of a function with the same number of arguments (${i})!`),r[o].overloadTable[i]=n):(r[o]=n,i!==void 0&&(r[o].numArguments=i))},dn=48,un=57,pn=o=>{if(o===void 0)return"_unknown";o=o.replace(/[^a-zA-Z0-9_]/g,"$");var n=o.charCodeAt(0);return n>=dn&&n<=un?`_${o}`:o};function hn(o,n,i,u,h,g,C,S){this.name=o,this.constructor=n,this.instancePrototype=i,this.rawDestructor=u,this.baseClass=h,this.getActualType=g,this.upcast=C,this.downcast=S,this.pureVirtualFunctions=[]}var Kr=(o,n,i)=>{for(;n!==i;)n.upcast||ye(`Expected null or instance of ${i.name}, got an instance of ${n.name}`),o=n.upcast(o),n=n.baseClass;return o};function fn(o,n){if(n===null)return this.isReference&&ye(`null is not a valid ${this.name}`),0;n.$$||ye(`Cannot pass "${At(n)}" as a ${this.name}`),n.$$.ptr||ye(`Cannot pass deleted object as a pointer of type ${this.name}`);var i=n.$$.ptrType.registeredClass,u=Kr(n.$$.ptr,i,this.registeredClass);return u}function _n(o,n){var i;if(n===null)return this.isReference&&ye(`null is not a valid ${this.name}`),this.isSmartPointer?(i=this.rawConstructor(),o!==null&&o.push(this.rawDestructor,i),i):0;(!n||!n.$$)&&ye(`Cannot pass "${At(n)}" as a ${this.name}`),n.$$.ptr||ye(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&n.$$.ptrType.isConst&&ye(`Cannot convert argument of type ${n.$$.smartPtrType?n.$$.smartPtrType.name:n.$$.ptrType.name} to parameter type ${this.name}`);var u=n.$$.ptrType.registeredClass;if(i=Kr(n.$$.ptr,u,this.registeredClass),this.isSmartPointer)switch(n.$$.smartPtr===void 0&&ye("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:n.$$.smartPtrType===this?i=n.$$.smartPtr:ye(`Cannot convert argument of type ${n.$$.smartPtrType?n.$$.smartPtrType.name:n.$$.ptrType.name} to parameter type ${this.name}`);break;case 1:i=n.$$.smartPtr;break;case 2:if(n.$$.smartPtrType===this)i=n.$$.smartPtr;else{var h=n.clone();i=this.rawShare(i,ar.toHandle(()=>h.delete())),o!==null&&o.push(this.rawDestructor,i)}break;default:ye("Unsupporting sharing policy")}return i}function gn(o,n){if(n===null)return this.isReference&&ye(`null is not a valid ${this.name}`),0;n.$$||ye(`Cannot pass "${At(n)}" as a ${this.name}`),n.$$.ptr||ye(`Cannot pass deleted object as a pointer of type ${this.name}`),n.$$.ptrType.isConst&&ye(`Cannot convert argument of type ${n.$$.ptrType.name} to parameter type ${this.name}`);var i=n.$$.ptrType.registeredClass,u=Kr(n.$$.ptr,i,this.registeredClass);return u}function tr(o){return this.fromWireType(j[o>>2])}var mn=()=>{Object.assign(rr.prototype,{getPointee(o){return this.rawGetPointee&&(o=this.rawGetPointee(o)),o},destructor(o){var n;(n=this.rawDestructor)==null||n.call(this,o)},argPackAdvance:gt,readValueFromPointer:tr,fromWireType:Hr})};function rr(o,n,i,u,h,g,C,S,w,A,P){this.name=o,this.registeredClass=n,this.isReference=i,this.isConst=u,this.isSmartPointer=h,this.pointeeType=g,this.sharingPolicy=C,this.rawGetPointee=S,this.rawConstructor=w,this.rawShare=A,this.rawDestructor=P,!h&&n.baseClass===void 0?u?(this.toWireType=fn,this.destructorFunction=null):(this.toWireType=gn,this.destructorFunction=null):this.toWireType=_n}var Yr=(o,n,i)=>{r.hasOwnProperty(o)||qt("Replacing nonexistant public symbol"),r[o].overloadTable!==void 0&&i!==void 0?r[o].overloadTable[i]=n:(r[o]=n,r[o].argCount=i)},Cn=(o,n,i)=>{L("dynCall_"+o in r,`bad function pointer type - dynCall function not found for sig '${o}'`),i!=null&&i.length?L(i.length===o.substring(1).replace(/j/g,"--").length):L(o.length==1);var u=r["dynCall_"+o];return u(n,...i)},or=[],nr,br=o=>{var n=or[o];return n||(o>=or.length&&(or.length=o+1),or[o]=n=nr.get(o)),L(nr.get(o)==n,"JavaScript-side Wasm function table mirror is out of date!"),n},yn=(o,n,i=[])=>{if(o.includes("j"))return Cn(o,n,i);L(br(n),`missing table entry in dynCall: ${n}`);var u=br(n)(...i);return u},Sn=(o,n)=>(L(o.includes("j")||o.includes("p"),"getDynCaller should only be called with i64 sigs"),(...i)=>yn(o,n,i)),Kt=(o,n)=>{o=We(o);function i(){return o.includes("j")?Sn(o,n):br(n)}var u=i();return typeof u!="function"&&ye(`unknown function pointer with signature ${o}: ${n}`),u},xn=(o,n)=>{var i=er(n,function(u){this.name=n,this.message=u;var h=new Error(u).stack;h!==void 0&&(this.stack=this.toString()+`
|
|
1092
|
+
`+h.replace(/^Error(:[^\n]*)?\n/,""))});return i.prototype=Object.create(o.prototype),i.prototype.constructor=i,i.prototype.toString=function(){return this.message===void 0?this.name:`${this.name}: ${this.message}`},i},Qr,Xr=o=>{var n=Ls(o),i=We(n);return Ct(n),i},sr=(o,n)=>{var i=[],u={};function h(g){if(!u[g]&&!xt[g]){if(Xt[g]){Xt[g].forEach(h);return}i.push(g),u[g]=!0}}throw n.forEach(h),new Qr(`${o}: `+i.map(Xr).join([", "]))},Kn=(o,n,i,u,h,g,C,S,w,A,P,N,U)=>{P=We(P),g=Kt(h,g),S&&(S=Kt(C,S)),A&&(A=Kt(w,A)),U=Kt(N,U);var W=pn(P);Wr(W,function(){sr(`Cannot construct ${P} due to unbound types`,[u])}),Tt([o,n,i],u?[u]:[],ae=>{var Oe;ae=ae[0];var we,De;u?(we=ae.registeredClass,De=we.instancePrototype):De=Zt.prototype;var Ie=er(P,function(...Dr){if(Object.getPrototypeOf(this)!==G)throw new Mt("Use 'new' to construct "+P);if(ee.constructor_body===void 0)throw new Mt(P+" has no accessible constructor");var fo=ee.constructor_body[Dr.length];if(fo===void 0)throw new Mt(`Tried to invoke ctor of ${P} with invalid number of parameters (${Dr.length}) - expected (${Object.keys(ee.constructor_body).toString()}) parameters instead!`);return fo.apply(this,Dr)}),G=Object.create(De,{constructor:{value:Ie}});Ie.prototype=G;var ee=new hn(P,Ie,G,U,we,g,S,A);ee.baseClass&&((Oe=ee.baseClass).__derivedClasses??(Oe.__derivedClasses=[]),ee.baseClass.__derivedClasses.push(ee));var Se=new rr(P,ee,!0,!1,!1),xe=new rr(P+"*",ee,!1,!1,!1),Ge=new rr(P+" const*",ee,!1,!0,!1);return Vr[o]={pointerType:xe,constPointerType:Ge},Yr(W,Ie),[Se,xe,Ge]})},vr=(o,n)=>{for(var i=[],u=0;u<o;u++)i.push(j[n+u*4>>2]);return i},bn=o=>{for(;o.length;){var n=o.pop(),i=o.pop();i(n)}};function qr(o){for(var n=1;n<o.length;++n)if(o[n]!==null&&o[n].destructorFunction===void 0)return!0;return!1}function vn(o,n){if(!(o instanceof Function))throw new TypeError(`new_ called with constructor type ${typeof o} which is not a function`);var i=er(o.name||"unknownFunctionName",function(){});i.prototype=o.prototype;var u=new i,h=o.apply(u,n);return h instanceof Object?h:u}function wn(o,n,i,u){for(var h=qr(o),g=o.length,C="",S="",w=0;w<g-2;++w)C+=(w!==0?", ":"")+"arg"+w,S+=(w!==0?", ":"")+"arg"+w+"Wired";var A=`
|
|
1093
|
+
return function (${C}) {
|
|
1094
|
+
if (arguments.length !== ${g-2}) {
|
|
1095
|
+
throwBindingError('function ' + humanName + ' called with ' + arguments.length + ' arguments, expected ${g-2}');
|
|
1096
|
+
}`;h&&(A+=`var destructors = [];
|
|
1097
|
+
`);var P=h?"destructors":"null",N=["humanName","throwBindingError","invoker","fn","runDestructors","retType","classParam"];n&&(A+="var thisWired = classParam['toWireType']("+P+`, this);
|
|
1098
|
+
`);for(var w=0;w<g-2;++w)A+="var arg"+w+"Wired = argType"+w+"['toWireType']("+P+", arg"+w+`);
|
|
1099
|
+
`,N.push("argType"+w);if(n&&(S="thisWired"+(S.length>0?", ":"")+S),A+=(i||u?"var rv = ":"")+"invoker(fn"+(S.length>0?", ":"")+S+`);
|
|
1100
|
+
`,h)A+=`runDestructors(destructors);
|
|
1101
|
+
`;else for(var w=n?1:2;w<o.length;++w){var U=w===1?"thisWired":"arg"+(w-2)+"Wired";o[w].destructorFunction!==null&&(A+=`${U}_dtor(${U});
|
|
1102
|
+
`,N.push(`${U}_dtor`))}return i&&(A+=`var ret = retType['fromWireType'](rv);
|
|
1103
|
+
return ret;
|
|
1104
|
+
`),A+=`}
|
|
1105
|
+
`,A=`if (arguments.length !== ${N.length}){ throw new Error(humanName + "Expected ${N.length} closure arguments " + arguments.length + " given."); }
|
|
1106
|
+
${A}`,[N,A]}function wr(o,n,i,u,h,g){var C=n.length;C<2&&ye("argTypes array size mismatch! Must at least get return value and 'this' types!"),L(!g,"Async bindings are only supported with JSPI.");for(var S=n[1]!==null&&i!==null,w=qr(n),A=n[0].name!=="void",P=[o,ye,u,h,bn,n[0],n[1]],N=0;N<C-2;++N)P.push(n[N+2]);if(!w)for(var N=S?1:2;N<n.length;++N)n[N].destructorFunction!==null&&P.push(n[N].destructorFunction);let[U,W]=wn(n,S,A,g);U.push(W);var ae=vn(Function,U)(...P);return er(o,ae)}var En=(o,n,i,u,h,g)=>{L(n>0);var C=vr(n,i);h=Kt(u,h),Tt([],[o],S=>{S=S[0];var w=`constructor ${S.name}`;if(S.registeredClass.constructor_body===void 0&&(S.registeredClass.constructor_body=[]),S.registeredClass.constructor_body[n-1]!==void 0)throw new Mt(`Cannot register multiple constructors with identical number of parameters (${n-1}) for class '${S.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return S.registeredClass.constructor_body[n-1]=()=>{sr(`Cannot construct ${S.name} due to unbound types`,C)},Tt([],C,A=>(A.splice(1,0,null),S.registeredClass.constructor_body[n-1]=wr(w,A,null,h,g),[])),[]})},Jr=o=>{o=o.trim();const n=o.indexOf("(");return n!==-1?(L(o[o.length-1]==")","Parentheses for argument names should match."),o.substr(0,n)):o},Mn=(o,n,i,u,h,g,C,S,w)=>{var A=vr(i,u);n=We(n),n=Jr(n),g=Kt(h,g),Tt([],[o],P=>{P=P[0];var N=`${P.name}.${n}`;n.startsWith("@@")&&(n=Symbol[n.substring(2)]),S&&P.registeredClass.pureVirtualFunctions.push(n);function U(){sr(`Cannot call ${N} due to unbound types`,A)}var W=P.registeredClass.instancePrototype,ae=W[n];return ae===void 0||ae.overloadTable===void 0&&ae.className!==P.name&&ae.argCount===i-2?(U.argCount=i-2,U.className=P.name,W[n]=U):(zr(W,n,N),W[n].overloadTable[i-2]=U),Tt([],A,we=>{var De=wr(N,we,P,g,C,w);return W[n].overloadTable===void 0?(De.argCount=i-2,W[n]=De):W[n].overloadTable[i-2]=De,[]}),[]})},Er=[],Ye=[],Zr=o=>{o>9&&--Ye[o+1]===0&&(L(Ye[o]!==void 0,"Decref for unallocated handle."),Ye[o]=void 0,Er.push(o))},Tn=()=>Ye.length/2-5-Er.length,An=()=>{Ye.push(0,1,void 0,1,null,1,!0,1,!1,1),L(Ye.length===5*2),r.count_emval_handles=Tn},ar={toValue:o=>(o||ye("Cannot use deleted val. handle = "+o),L(o===2||Ye[o]!==void 0&&o%2===0,`invalid handle: ${o}`),Ye[o]),toHandle:o=>{switch(o){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:{const n=Er.pop()||Ye.length;return Ye[n]=o,Ye[n+1]=1,n}}}},Ln={name:"emscripten::val",fromWireType:o=>{var n=ar.toValue(o);return Zr(o),n},toWireType:(o,n)=>ar.toHandle(n),argPackAdvance:gt,readValueFromPointer:tr,destructorFunction:null},eo=o=>ut(o,Ln),At=o=>{if(o===null)return"null";var n=typeof o;return n==="object"||n==="array"||n==="function"?o.toString():""+o},Dn=(o,n)=>{switch(n){case 4:return function(i){return this.fromWireType(te[i>>2])};case 8:return function(i){return this.fromWireType(re[i>>3])};default:throw new TypeError(`invalid float width (${n}): ${o}`)}},Rn=(o,n,i)=>{n=We(n),ut(o,{name:n,fromWireType:u=>u,toWireType:(u,h)=>{if(typeof h!="number"&&typeof h!="boolean")throw new TypeError(`Cannot convert ${At(h)} to ${this.name}`);return h},argPackAdvance:gt,readValueFromPointer:Dn(n,i),destructorFunction:null})},In=(o,n,i,u,h,g,C)=>{var S=vr(n,i);o=We(o),o=Jr(o),h=Kt(u,h),Wr(o,function(){sr(`Cannot call ${o} due to unbound types`,S)},n-1),Tt([],S,w=>{var A=[w[0],null].concat(w.slice(1));return Yr(o,wr(o,A,null,h,g,C),n-1),[]})},On=(o,n,i)=>{switch(n){case 1:return i?u=>H[u]:u=>B[u];case 2:return i?u=>Q[u>>1]:u=>q[u>>1];case 4:return i?u=>T[u>>2]:u=>j[u>>2];default:throw new TypeError(`invalid integer width (${n}): ${o}`)}},Pn=(o,n,i,u,h)=>{n=We(n),h===-1&&(h=4294967295);var g=P=>P;if(u===0){var C=32-8*i;g=P=>P<<C>>>C}var S=n.includes("unsigned"),w=(P,N)=>{if(typeof P!="number"&&typeof P!="boolean")throw new TypeError(`Cannot convert "${At(P)}" to ${N}`);if(P<u||P>h)throw new TypeError(`Passing a number "${At(P)}" from JS side to C/C++ side to an argument of type "${n}", which is outside the valid range [${u}, ${h}]!`)},A;S?A=function(P,N){return w(N,this.name),N>>>0}:A=function(P,N){return w(N,this.name),N},ut(o,{name:n,fromWireType:g,toWireType:A,argPackAdvance:gt,readValueFromPointer:On(n,i,u!==0),destructorFunction:null})},kn=(o,n,i)=>{var u=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],h=u[n];function g(C){var S=j[C>>2],w=j[C+4>>2];return new h(H.buffer,w,S)}i=We(i),ut(o,{name:i,fromWireType:g,argPackAdvance:gt,readValueFromPointer:g},{ignoreDuplicateRegistrations:!0})},jn=(o,n)=>{eo(o)},Fn=(o,n)=>{n=We(n);var i=n==="std::string";ut(o,{name:n,fromWireType(u){var h=j[u>>2],g=u+4,C;if(i)for(var S=g,w=0;w<=h;++w){var A=g+w;if(w==h||B[A]==0){var P=A-S,N=at(S,P);C===void 0?C=N:(C+=String.fromCharCode(0),C+=N),S=A+1}}else{for(var U=new Array(h),w=0;w<h;++w)U[w]=String.fromCharCode(B[g+w]);C=U.join("")}return Ct(u),C},toWireType(u,h){h instanceof ArrayBuffer&&(h=new Uint8Array(h));var g,C=typeof h=="string";C||h instanceof Uint8Array||h instanceof Uint8ClampedArray||h instanceof Int8Array||ye("Cannot pass non-string to std::string"),i&&C?g=zt(h):g=h.length;var S=$t(4+g+1),w=S+4;if(j[S>>2]=g,Y(g),i&&C)Ot(h,w,g+1);else if(C)for(var A=0;A<g;++A){var P=h.charCodeAt(A);P>255&&(Ct(w),ye("String has UTF-16 code units that do not fit in 8 bits")),B[w+A]=P}else for(var A=0;A<g;++A)B[w+A]=h[A];return u!==null&&u.push(Ct,S),S},argPackAdvance:gt,readValueFromPointer:tr,destructorFunction(u){Ct(u)}})},to=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0,Bn=(o,n)=>{L(o%2==0,"Pointer passed to UTF16ToString must be aligned to two bytes!");for(var i=o,u=i>>1,h=u+n/2;!(u>=h)&&q[u];)++u;if(i=u<<1,i-o>32&&to)return to.decode(B.subarray(o,i));for(var g="",C=0;!(C>=n/2);++C){var S=Q[o+C*2>>1];if(S==0)break;g+=String.fromCharCode(S)}return g},Nn=(o,n,i)=>{if(L(n%2==0,"Pointer passed to stringToUTF16 must be aligned to two bytes!"),L(typeof i=="number","stringToUTF16(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!"),i??(i=2147483647),i<2)return 0;i-=2;for(var u=n,h=i<o.length*2?i/2:o.length,g=0;g<h;++g){var C=o.charCodeAt(g);Q[n>>1]=C,rt(C),n+=2}return Q[n>>1]=0,rt(0),n-u},$n=o=>o.length*2,Gn=(o,n)=>{L(o%4==0,"Pointer passed to UTF32ToString must be aligned to four bytes!");for(var i=0,u="";!(i>=n/4);){var h=T[o+i*4>>2];if(h==0)break;if(++i,h>=65536){var g=h-65536;u+=String.fromCharCode(55296|g>>10,56320|g&1023)}else u+=String.fromCharCode(h)}return u},Un=(o,n,i)=>{if(L(n%4==0,"Pointer passed to stringToUTF32 must be aligned to four bytes!"),L(typeof i=="number","stringToUTF32(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!"),i??(i=2147483647),i<4)return 0;for(var u=n,h=u+i-4,g=0;g<o.length;++g){var C=o.charCodeAt(g);if(C>=55296&&C<=57343){var S=o.charCodeAt(++g);C=65536+((C&1023)<<10)|S&1023}if(T[n>>2]=C,Y(C),n+=4,n+4>h)break}return T[n>>2]=0,Y(0),n-u},Vn=o=>{for(var n=0,i=0;i<o.length;++i){var u=o.charCodeAt(i);u>=55296&&u<=57343&&++i,n+=4}return n},Hn=(o,n,i)=>{i=We(i);var u,h,g,C;n===2?(u=Bn,h=Nn,C=$n,g=S=>q[S>>1]):n===4&&(u=Gn,h=Un,C=Vn,g=S=>j[S>>2]),ut(o,{name:i,fromWireType:S=>{for(var w=j[S>>2],A,P=S+4,N=0;N<=w;++N){var U=S+4+N*n;if(N==w||g(U)==0){var W=U-P,ae=u(P,W);A===void 0?A=ae:(A+=String.fromCharCode(0),A+=ae),P=U+n}}return Ct(S),A},toWireType:(S,w)=>{typeof w!="string"&&ye(`Cannot pass non-string to C++ string type ${i}`);var A=C(w),P=$t(4+A+n);return j[P>>2]=A/n,Y(A/n),h(w,P+4,A+n),S!==null&&S.push(Ct,P),P},argPackAdvance:gt,readValueFromPointer:tr,destructorFunction(S){Ct(S)}})},zn=(o,n)=>{n=We(n),ut(o,{isVoid:!0,name:n,argPackAdvance:0,fromWireType:()=>{},toWireType:(i,u)=>{}})},Wn=1,Yn=()=>Wn,Qn=o=>{o>9&&(Ye[o+1]+=1)},Xn=(o,n)=>{var i=xt[o];return i===void 0&&ye(`${n} has unknown type ${Xr(o)}`),i},qn=(o,n)=>{o=Xn(o,"_emval_take_value");var i=o.readValueFromPointer(n);return ar.toHandle(i)},Mr=(o,n)=>(L(o==o>>>0||o==(o|0)),L(n===(n|0)),n+2097152>>>0<4194305-!!o?(o>>>0)+n*4294967296:NaN);function Jn(o,n,i){var u=Mr(o,n),h=new Date(u*1e3);T[i>>2]=h.getUTCSeconds(),Y(h.getUTCSeconds()),T[i+4>>2]=h.getUTCMinutes(),Y(h.getUTCMinutes()),T[i+8>>2]=h.getUTCHours(),Y(h.getUTCHours()),T[i+12>>2]=h.getUTCDate(),Y(h.getUTCDate()),T[i+16>>2]=h.getUTCMonth(),Y(h.getUTCMonth()),T[i+20>>2]=h.getUTCFullYear()-1900,Y(h.getUTCFullYear()-1900),T[i+24>>2]=h.getUTCDay(),Y(h.getUTCDay());var g=Date.UTC(h.getUTCFullYear(),0,1,0,0,0,0),C=(h.getTime()-g)/(1e3*60*60*24)|0;T[i+28>>2]=C,Y(C)}var Bt=o=>o%4===0&&(o%100!==0||o%400===0),Zn=[0,31,60,91,121,152,182,213,244,274,305,335],es=[0,31,59,90,120,151,181,212,243,273,304,334],ro=o=>{var n=Bt(o.getFullYear()),i=n?Zn:es,u=i[o.getMonth()]+o.getDate()-1;return u};function ts(o,n,i){var u=Mr(o,n),h=new Date(u*1e3);T[i>>2]=h.getSeconds(),Y(h.getSeconds()),T[i+4>>2]=h.getMinutes(),Y(h.getMinutes()),T[i+8>>2]=h.getHours(),Y(h.getHours()),T[i+12>>2]=h.getDate(),Y(h.getDate()),T[i+16>>2]=h.getMonth(),Y(h.getMonth()),T[i+20>>2]=h.getFullYear()-1900,Y(h.getFullYear()-1900),T[i+24>>2]=h.getDay(),Y(h.getDay());var g=ro(h)|0;T[i+28>>2]=g,Y(g),T[i+36>>2]=-(h.getTimezoneOffset()*60),Y(-(h.getTimezoneOffset()*60));var C=new Date(h.getFullYear(),0,1),S=new Date(h.getFullYear(),6,1).getTimezoneOffset(),w=C.getTimezoneOffset(),A=(S!=w&&h.getTimezoneOffset()==Math.min(w,S))|0;T[i+32>>2]=A,Y(A)}var rs=function(o){var n=(()=>{var i=new Date(T[o+20>>2]+1900,T[o+16>>2],T[o+12>>2],T[o+8>>2],T[o+4>>2],T[o>>2],0),u=T[o+32>>2],h=i.getTimezoneOffset(),g=new Date(i.getFullYear(),0,1),C=new Date(i.getFullYear(),6,1).getTimezoneOffset(),S=g.getTimezoneOffset(),w=Math.min(S,C);if(u<0)T[o+32>>2]=+(C!=S&&w==h),Y(+(C!=S&&w==h));else if(u>0!=(w==h)){var A=Math.max(S,C),P=u>0?w:A;i.setTime(i.getTime()+(P-h)*6e4)}T[o+24>>2]=i.getDay(),Y(i.getDay());var N=ro(i)|0;T[o+28>>2]=N,Y(N),T[o>>2]=i.getSeconds(),Y(i.getSeconds()),T[o+4>>2]=i.getMinutes(),Y(i.getMinutes()),T[o+8>>2]=i.getHours(),Y(i.getHours()),T[o+12>>2]=i.getDate(),Y(i.getDate()),T[o+16>>2]=i.getMonth(),Y(i.getMonth()),T[o+20>>2]=i.getYear(),Y(i.getYear());var U=i.getTime();return isNaN(U)?-1:U/1e3})();return Ds((Z=n,+Math.abs(Z)>=1?Z>0?+Math.floor(Z/4294967296)>>>0:~~+Math.ceil((Z-+(~~Z>>>0))/4294967296)>>>0:0)),n>>>0},oo=o=>{var n=zt(o)+1,i=$t(n);return i&&Ot(o,i,n),i},os=(o,n,i)=>{var u=new Date().getFullYear(),h=new Date(u,0,1),g=new Date(u,6,1),C=h.getTimezoneOffset(),S=g.getTimezoneOffset(),w=Math.max(C,S);j[o>>2]=w*60,Y(w*60),T[n>>2]=+(C!=S),Y(+(C!=S));function A(ae){var we=ae.toTimeString().match(/\(([A-Za-z ]+)\)$/);return we?we[1]:"GMT"}var P=A(h),N=A(g),U=oo(P),W=oo(N);S<C?(j[i>>2]=U,Y(U),j[i+4>>2]=W,Y(W)):(j[i>>2]=W,Y(W),j[i+4>>2]=U,Y(U))},ns=()=>{pe("native code called abort()")},ss=()=>Date.now(),as=o=>V(at(o)),no=()=>2147483648,is=()=>no(),ir;ir=()=>performance.now();var cs=(o,n,i)=>B.copyWithin(o,n,n+i),ls=o=>{var n=z.buffer,i=(o-n.byteLength+65535)/65536;try{return z.grow(i),de(),1}catch(u){V(`growMemory: Attempted to grow heap from ${n.byteLength} bytes to ${o} bytes, but got error: ${u}`)}},ds=o=>{var n=B.length;o>>>=0,L(o>n);var i=no();if(o>i)return V(`Cannot enlarge memory, requested ${o} bytes, but the limit is ${i} bytes!`),!1;for(var u=(P,N)=>P+(N-P%N)%N,h=1;h<=4;h*=2){var g=n*(1+.2/h);g=Math.min(g,o+100663296);var C=Math.min(i,u(Math.max(o,g),65536)),S=ir(),w=ls(C),A=ir();if(_o(`Heap resize call from ${n} to ${C} took ${A-S} msecs. Success: ${!!w}`),w)return!0}return V(`Failed to grow the heap from ${n} bytes to ${C} bytes, not enough memory!`),!1},Tr={},us=()=>c||"./this.program",Nt=()=>{if(!Nt.strings){var o=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",n={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:o,_:us()};for(var i in Tr)Tr[i]===void 0?delete n[i]:n[i]=Tr[i];var u=[];for(var i in n)u.push(`${i}=${n[i]}`);Nt.strings=u}return Nt.strings},ps=(o,n)=>{for(var i=0;i<o.length;++i)L(o.charCodeAt(i)===(o.charCodeAt(i)&255)),H[n++]=o.charCodeAt(i),yt(o.charCodeAt(i));H[n]=0,yt(0)},hs=(o,n)=>{var i=0;return Nt().forEach((u,h)=>{var g=n+i;j[o+h*4>>2]=g,Y(g),ps(u,g),i+=u.length+1}),0},fs=(o,n)=>{var i=Nt();j[o>>2]=i.length,Y(i.length);var u=0;return i.forEach(h=>u+=h.length+1),j[n>>2]=u,Y(u),0};function _s(o){try{var n=ce.getStreamFromFD(o);return _.close(n),0}catch(i){if(typeof _>"u"||i.name!=="ErrnoError")throw i;return i.errno}}function gs(o,n){try{var i=0,u=0,h=0,g=ce.getStreamFromFD(o),C=g.tty?2:_.isDir(g.mode)?3:_.isLink(g.mode)?7:4;return H[n]=C,yt(C),Q[n+2>>1]=h,rt(h),he=[i>>>0,(Z=i,+Math.abs(Z)>=1?Z>0?+Math.floor(Z/4294967296)>>>0:~~+Math.ceil((Z-+(~~Z>>>0))/4294967296)>>>0:0)],T[n+8>>2]=he[0],T[n+12>>2]=he[1],st(i),he=[u>>>0,(Z=u,+Math.abs(Z)>=1?Z>0?+Math.floor(Z/4294967296)>>>0:~~+Math.ceil((Z-+(~~Z>>>0))/4294967296)>>>0:0)],T[n+16>>2]=he[0],T[n+20>>2]=he[1],st(u),0}catch(S){if(typeof _>"u"||S.name!=="ErrnoError")throw S;return S.errno}}var ms=(o,n,i,u)=>{for(var h=0,g=0;g<i;g++){var C=j[n>>2],S=j[n+4>>2];n+=8;var w=_.read(o,H,C,S,u);if(w<0)return-1;if(h+=w,w<S)break;typeof u<"u"&&(u+=w)}return h};function Cs(o,n,i,u){try{var h=ce.getStreamFromFD(o),g=ms(h,n,i);return j[u>>2]=g,Y(g),0}catch(C){if(typeof _>"u"||C.name!=="ErrnoError")throw C;return C.errno}}function ys(o,n,i,u,h){var g=Mr(n,i);try{if(isNaN(g))return 61;var C=ce.getStreamFromFD(o);return _.llseek(C,g,u),he=[C.position>>>0,(Z=C.position,+Math.abs(Z)>=1?Z>0?+Math.floor(Z/4294967296)>>>0:~~+Math.ceil((Z-+(~~Z>>>0))/4294967296)>>>0:0)],T[h>>2]=he[0],T[h+4>>2]=he[1],st(C.position),C.getdents&&g===0&&u===0&&(C.getdents=null),0}catch(S){if(typeof _>"u"||S.name!=="ErrnoError")throw S;return S.errno}}var Ss=(o,n,i,u)=>{for(var h=0,g=0;g<i;g++){var C=j[n>>2],S=j[n+4>>2];n+=8;var w=_.write(o,H,C,S,u);if(w<0)return-1;h+=w,typeof u<"u"&&(u+=w)}return h};function xs(o,n,i,u){try{var h=ce.getStreamFromFD(o),g=Ss(h,n,i);return j[u>>2]=g,Y(g),0}catch(C){if(typeof _>"u"||C.name!=="ErrnoError")throw C;return C.errno}}var Ks=(o,n,i,u)=>{var h=0,g=0,C=0,S=0,w=0,A=0,P;function N(U,W,ae,we,De,Ie){var G,ee,Se,xe;return ee=U===10?28:16,De=U===10?jr(De):_r(De),G=$t(ee),xe=Cr(G,U,De,Ie),L(!xe),Se=$t(32),T[Se+4>>2]=U,Y(U),T[Se+8>>2]=W,Y(W),T[Se+12>>2]=ae,Y(ae),j[Se+24>>2]=we,j[Se+20>>2]=G,U===10?(T[Se+16>>2]=28,Y(28)):(T[Se+16>>2]=16,Y(16)),T[Se+28>>2]=0,Y(0),Se}if(i&&(C=T[i>>2],S=T[i+4>>2],w=T[i+8>>2],A=T[i+12>>2]),w&&!A&&(A=w===2?17:6),!w&&A&&(w=A===17?2:1),A===0&&(A=6),w===0&&(w=1),!o&&!n)return-2;if(C&-1088||i!==0&&T[i>>2]&2&&!o)return-1;if(C&32)return-2;if(w!==0&&w!==1&&w!==2)return-7;if(S!==0&&S!==2&&S!==10)return-6;if(n&&(n=at(n),g=parseInt(n,10),isNaN(g)))return C&1024?-2:-8;if(!o)return S===0&&(S=2),C&1||(S===2?h=Ar(2130706433):h=[0,0,0,1]),P=N(S,w,A,null,h,g),j[u>>2]=P,0;if(o=at(o),h=Yt(o),h!==null)if(S===0||S===2)S=2;else if(S===10&&C&8)h=[0,0,Ar(65535),h],S=10;else return-2;else if(h=gr(o),h!==null)if(S===0||S===10)S=10;else return-2;return h!=null?(P=N(S,w,A,o,h,g),j[u>>2]=P,0):C&4?-2:(o=ze.lookup_name(o),h=Yt(o),S===0?S=2:S===10&&(h=[0,0,Ar(65535),h]),P=N(S,w,A,null,h,g),j[u>>2]=P,0)},bs=(o,n,i,u,h,g,C)=>{var S=Fr(o,n);if(S.errno)return-6;var w=S.port,A=S.addr,P=!1;if(i&&u){var N;if(C&1||!(N=ze.lookup_addr(A))){if(C&8)return-2}else A=N;var U=Ot(A,i,u);U+1>=u&&(P=!0)}if(h&&g){w=""+w;var U=Ot(w,h,g);U+1>=g&&(P=!0)}return P?-12:0},vs=(o,n)=>{for(var i=0,u=0;u<=n;i+=o[u++]);return i},so=[31,29,31,30,31,30,31,31,30,31,30,31],ao=[31,28,31,30,31,30,31,31,30,31,30,31],ws=(o,n)=>{for(var i=new Date(o.getTime());n>0;){var u=Bt(i.getFullYear()),h=i.getMonth(),g=(u?so:ao)[h];if(n>g-i.getDate())n-=g-i.getDate()+1,i.setDate(1),h<11?i.setMonth(h+1):(i.setMonth(0),i.setFullYear(i.getFullYear()+1));else return i.setDate(i.getDate()+n),i}return i},Es=(o,n)=>{L(o.length>=0,"writeArrayToMemory array must have a length (should be an array or typed array)"),H.set(o,n)},io=(o,n,i,u)=>{var h=j[u+40>>2],g={tm_sec:T[u>>2],tm_min:T[u+4>>2],tm_hour:T[u+8>>2],tm_mday:T[u+12>>2],tm_mon:T[u+16>>2],tm_year:T[u+20>>2],tm_wday:T[u+24>>2],tm_yday:T[u+28>>2],tm_isdst:T[u+32>>2],tm_gmtoff:T[u+36>>2],tm_zone:h?at(h):""},C=at(i),S={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var w in S)C=C.replace(new RegExp(w,"g"),S[w]);var A=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],P=["January","February","March","April","May","June","July","August","September","October","November","December"];function N(G,ee,Se){for(var xe=typeof G=="number"?G.toString():G||"";xe.length<ee;)xe=Se[0]+xe;return xe}function U(G,ee){return N(G,ee,"0")}function W(G,ee){function Se(Ge){return Ge<0?-1:Ge>0?1:0}var xe;return(xe=Se(G.getFullYear()-ee.getFullYear()))===0&&(xe=Se(G.getMonth()-ee.getMonth()))===0&&(xe=Se(G.getDate()-ee.getDate())),xe}function ae(G){switch(G.getDay()){case 0:return new Date(G.getFullYear()-1,11,29);case 1:return G;case 2:return new Date(G.getFullYear(),0,3);case 3:return new Date(G.getFullYear(),0,2);case 4:return new Date(G.getFullYear(),0,1);case 5:return new Date(G.getFullYear()-1,11,31);case 6:return new Date(G.getFullYear()-1,11,30)}}function we(G){var ee=ws(new Date(G.tm_year+1900,0,1),G.tm_yday),Se=new Date(ee.getFullYear(),0,4),xe=new Date(ee.getFullYear()+1,0,4),Ge=ae(Se),Oe=ae(xe);return W(Ge,ee)<=0?W(Oe,ee)<=0?ee.getFullYear()+1:ee.getFullYear():ee.getFullYear()-1}var De={"%a":G=>A[G.tm_wday].substring(0,3),"%A":G=>A[G.tm_wday],"%b":G=>P[G.tm_mon].substring(0,3),"%B":G=>P[G.tm_mon],"%C":G=>{var ee=G.tm_year+1900;return U(ee/100|0,2)},"%d":G=>U(G.tm_mday,2),"%e":G=>N(G.tm_mday,2," "),"%g":G=>we(G).toString().substring(2),"%G":we,"%H":G=>U(G.tm_hour,2),"%I":G=>{var ee=G.tm_hour;return ee==0?ee=12:ee>12&&(ee-=12),U(ee,2)},"%j":G=>U(G.tm_mday+vs(Bt(G.tm_year+1900)?so:ao,G.tm_mon-1),3),"%m":G=>U(G.tm_mon+1,2),"%M":G=>U(G.tm_min,2),"%n":()=>`
|
|
1107
|
+
`,"%p":G=>G.tm_hour>=0&&G.tm_hour<12?"AM":"PM","%S":G=>U(G.tm_sec,2),"%t":()=>" ","%u":G=>G.tm_wday||7,"%U":G=>{var ee=G.tm_yday+7-G.tm_wday;return U(Math.floor(ee/7),2)},"%V":G=>{var ee=Math.floor((G.tm_yday+7-(G.tm_wday+6)%7)/7);if((G.tm_wday+371-G.tm_yday-2)%7<=2&&ee++,ee){if(ee==53){var xe=(G.tm_wday+371-G.tm_yday)%7;xe!=4&&(xe!=3||!Bt(G.tm_year))&&(ee=1)}}else{ee=52;var Se=(G.tm_wday+7-G.tm_yday-1)%7;(Se==4||Se==5&&Bt(G.tm_year%400-1))&&ee++}return U(ee,2)},"%w":G=>G.tm_wday,"%W":G=>{var ee=G.tm_yday+7-(G.tm_wday+6)%7;return U(Math.floor(ee/7),2)},"%y":G=>(G.tm_year+1900).toString().substring(2),"%Y":G=>G.tm_year+1900,"%z":G=>{var ee=G.tm_gmtoff,Se=ee>=0;return ee=Math.abs(ee)/60,ee=ee/60*100+ee%60,(Se?"+":"-")+("0000"+ee).slice(-4)},"%Z":G=>G.tm_zone,"%%":()=>"%"};C=C.replace(/%%/g,"\0\0");for(var w in De)C.includes(w)&&(C=C.replace(new RegExp(w,"g"),De[w](g)));C=C.replace(/\0\0/g,"%");var Ie=Wt(C,!1);return Ie.length>n?0:(Es(Ie,o),Ie.length-1)},Ms=(o,n,i,u,h)=>io(o,n,i,u),co=function(o,n,i,u){o||(o=this),this.parent=o,this.mount=o.mount,this.mounted=null,this.id=_.nextInode++,this.name=n,this.mode=i,this.node_ops={},this.stream_ops={},this.rdev=u},cr=365,lr=146;Object.defineProperties(co.prototype,{read:{get:function(){return(this.mode&cr)===cr},set:function(o){o?this.mode|=cr:this.mode&=~cr}},write:{get:function(){return(this.mode&lr)===lr},set:function(o){o?this.mode|=lr:this.mode&=~lr}},isFolder:{get:function(){return _.isDir(this.mode)}},isDevice:{get:function(){return _.isChrdev(this.mode)}}}),_.FSNode=co,_.createPreloadedFile=Mo,_.staticInit(),r.FS_createPath=_.createPath,r.FS_createDataFile=_.createDataFile,r.FS_createPreloadedFile=_.createPreloadedFile,r.FS_unlink=_.unlink,r.FS_createLazyFile=_.createLazyFile,r.FS_createDevice=_.createDevice,qo(),Mt=r.BindingError=class extends Error{constructor(n){super(n),this.name="BindingError"}},Nr=r.InternalError=class extends Error{constructor(n){super(n),this.name="InternalError"}},ln(),sn(),mn(),Qr=r.UnboundTypeError=xn(Error,"UnboundTypeError"),An();function Ts(){Vt("fetchSettings")}var lo={__assert_fail:mo,__cxa_throw:yo,__handle_stack_overflow:So,__syscall_bind:Lo,__syscall_connect:Do,__syscall_faccessat:Ro,__syscall_fcntl64:Io,__syscall_fstat64:Oo,__syscall_getdents64:Po,__syscall_getsockname:ko,__syscall_getsockopt:jo,__syscall_ioctl:Fo,__syscall_lstat64:Bo,__syscall_newfstatat:No,__syscall_openat:$o,__syscall_poll:Go,__syscall_recvfrom:Uo,__syscall_renameat:Vo,__syscall_rmdir:Ho,__syscall_sendto:zo,__syscall_socket:Wo,__syscall_stat64:Yo,__syscall_unlinkat:Qo,_embind_register_bigint:Xo,_embind_register_bool:Zo,_embind_register_class:Kn,_embind_register_class_constructor:En,_embind_register_class_function:Mn,_embind_register_emval:eo,_embind_register_float:Rn,_embind_register_function:In,_embind_register_integer:Pn,_embind_register_memory_view:kn,_embind_register_optional:jn,_embind_register_std_string:Fn,_embind_register_std_wstring:Hn,_embind_register_void:zn,_emscripten_get_now_is_monotonic:Yn,_emval_decref:Zr,_emval_incref:Qn,_emval_take_value:qn,_gmtime_js:Jn,_localtime_js:ts,_mktime_js:rs,_tzset_js:os,abort:ns,emscripten_date_now:ss,emscripten_err:as,emscripten_get_heap_max:is,emscripten_get_now:ir,emscripten_memcpy_js:cs,emscripten_resize_heap:ds,environ_get:hs,environ_sizes_get:fs,fd_close:_s,fd_fdstat_get:gs,fd_read:Cs,fd_seek:ys,fd_write:xs,getaddrinfo:Ks,getnameinfo:bs,strftime:io,strftime_l:Ms},pt=Lt(),$t=Ce("malloc"),Ct=Ce("free"),As=Ce("fflush"),Ls=Ce("__getTypeName"),Ar=Ce("htonl"),Gt=Ce("htons"),uo=Ce("ntohs"),Ds=Ce("setTempRet0"),po=()=>(po=pt.emscripten_stack_init)(),Lr=()=>(Lr=pt.emscripten_stack_get_base)(),Ut=()=>(Ut=pt.emscripten_stack_get_end)(),Rs=Ce("__cxa_is_pointer_type"),Is=r.___set_stack_limits=Ce("__set_stack_limits");r.dynCall_jiji=Ce("dynCall_jiji"),r.dynCall_iiiji=Ce("dynCall_iiiji"),r.dynCall_iiijjji=Ce("dynCall_iiijjji"),r.dynCall_jiiij=Ce("dynCall_jiiij"),r.dynCall_iiiiij=Ce("dynCall_iiiiij"),r.dynCall_iiiiiij=Ce("dynCall_iiiiiij"),r.dynCall_jiiji=Ce("dynCall_jiiji"),r.dynCall_ijii=Ce("dynCall_ijii"),r.dynCall_viiiiij=Ce("dynCall_viiiiij"),r.dynCall_iiij=Ce("dynCall_iiij"),r.dynCall_iiijiiii=Ce("dynCall_iiijiiii"),r.dynCall_ji=Ce("dynCall_ji"),r.dynCall_viijii=Ce("dynCall_viijii"),r.dynCall_iiiiijj=Ce("dynCall_iiiiijj"),r.dynCall_iiiiiijj=Ce("dynCall_iiiiiijj"),r._ff_h264_cabac_tables=806268,r.addRunDependency=Te,r.removeRunDependency=Ve,r.FS_createPath=_.createPath,r.FS_createLazyFile=_.createLazyFile,r.FS_createDevice=_.createDevice,r.FS_createPreloadedFile=_.createPreloadedFile,r.FS=_,r.FS_createDataFile=_.createDataFile,r.FS_unlink=_.unlink;var Os=["writeI53ToI64","writeI53ToI64Clamped","writeI53ToI64Signaling","writeI53ToU64Clamped","writeI53ToU64Signaling","readI53FromI64","readI53FromU64","convertI32PairToI53","convertU32PairToI53","exitJS","getCallstack","emscriptenLog","convertPCtoSourceLocation","readEmAsmArgs","listenOnce","autoResumeAudioContext","handleException","keepRuntimeAlive","runtimeKeepalivePush","runtimeKeepalivePop","callUserCallback","maybeExit","asmjsMangle","HandleAllocator","getNativeTypeSize","STACK_SIZE","STACK_ALIGN","POINTER_SIZE","ASSERTIONS","getCFunc","ccall","cwrap","uleb128Encode","sigToWasmTypes","generateFuncType","convertJsFunctionToWasm","getEmptyTableSlot","updateTableMap","getFunctionAddress","addFunction","removeFunction","reallyNegative","unSign","strLen","reSign","formatString","intArrayToString","AsciiToString","stringToUTF8OnStack","registerKeyEventCallback","maybeCStringToJsString","findEventTarget","getBoundingClientRect","fillMouseEventData","registerMouseEventCallback","registerWheelEventCallback","registerUiEventCallback","registerFocusEventCallback","fillDeviceOrientationEventData","registerDeviceOrientationEventCallback","fillDeviceMotionEventData","registerDeviceMotionEventCallback","screenOrientation","fillOrientationChangeEventData","registerOrientationChangeEventCallback","fillFullscreenChangeEventData","registerFullscreenChangeEventCallback","JSEvents_requestFullscreen","JSEvents_resizeCanvasForFullscreen","registerRestoreOldStyle","hideEverythingExceptGivenElement","restoreHiddenElements","setLetterbox","softFullscreenResizeWebGLRenderTarget","doRequestFullscreen","fillPointerlockChangeEventData","registerPointerlockChangeEventCallback","registerPointerlockErrorEventCallback","requestPointerLock","fillVisibilityChangeEventData","registerVisibilityChangeEventCallback","registerTouchEventCallback","fillGamepadEventData","registerGamepadEventCallback","registerBeforeUnloadEventCallback","fillBatteryEventData","battery","registerBatteryEventCallback","setCanvasElementSize","getCanvasElementSize","jsStackTrace","stackTrace","checkWasiClock","wasiRightsToMuslOFlags","wasiOFlagsToMuslOFlags","createDyncallWrapper","safeSetTimeout","setImmediateWrapped","clearImmediateWrapped","polyfillSetImmediate","getPromise","makePromise","idsToPromises","makePromiseCallback","findMatchingCatch","Browser_asyncPrepareDataCounter","setMainLoop","FS_mkdirTree","_setNetworkCallback","heapObjectForWebGLType","toTypedArrayIndex","webgl_enable_ANGLE_instanced_arrays","webgl_enable_OES_vertex_array_object","webgl_enable_WEBGL_draw_buffers","webgl_enable_WEBGL_multi_draw","emscriptenWebGLGet","computeUnpackAlignedImageSize","colorChannelsInGlTextureFormat","emscriptenWebGLGetTexPixelData","emscriptenWebGLGetUniform","webglGetUniformLocation","webglPrepareUniformLocationsBeforeFirstUse","webglGetLeftBracePos","emscriptenWebGLGetVertexAttrib","__glGetActiveAttribOrUniform","writeGLArray","registerWebGlEventCallback","runAndAbortIfError","SDL_unicode","SDL_ttfContext","SDL_audio","ALLOC_NORMAL","ALLOC_STACK","allocate","writeStringToMemory","writeAsciiToMemory","setErrNo","demangle","getFunctionArgsName","createJsInvokerSignature","registerInheritedInstance","unregisterInheritedInstance","enumReadValueFromPointer","validateThis","getStringOrSymbol","emval_get_global","emval_returnValue","emval_lookupTypes","emval_addMethodCaller"];Os.forEach(Ht);var Ps=["run","addOnPreRun","addOnInit","addOnPreMain","addOnExit","addOnPostRun","FS_createFolder","FS_createLink","FS_readFile","out","err","callMain","abort","wasmMemory","wasmExports","stackAlloc","stackSave","stackRestore","getTempRet0","setTempRet0","writeStackCookie","checkStackCookie","convertI32PairToI53Checked","ptrToString","zeroMemory","getHeapMax","growMemory","ENV","setStackLimits","MONTH_DAYS_REGULAR","MONTH_DAYS_LEAP","MONTH_DAYS_REGULAR_CUMULATIVE","MONTH_DAYS_LEAP_CUMULATIVE","isLeapYear","ydayFromDate","arraySum","addDays","ERRNO_CODES","ERRNO_MESSAGES","inetPton4","inetNtop4","inetPton6","inetNtop6","readSockaddr","writeSockaddr","DNS","Protocols","Sockets","initRandomFill","randomFill","timers","warnOnce","UNWIND_CACHE","readEmAsmArgsArray","jstoi_q","jstoi_s","getExecutableName","dynCallLegacy","getDynCaller","dynCall","asyncLoad","alignMemory","mmapAlloc","wasmTable","noExitRuntime","freeTableIndexes","functionsInTableMap","setValue","getValue","PATH","PATH_FS","UTF8Decoder","UTF8ArrayToString","UTF8ToString","stringToUTF8Array","stringToUTF8","lengthBytesUTF8","intArrayFromString","stringToAscii","UTF16Decoder","UTF16ToString","stringToUTF16","lengthBytesUTF16","UTF32ToString","stringToUTF32","lengthBytesUTF32","stringToNewUTF8","writeArrayToMemory","JSEvents","specialHTMLTargets","findCanvasEventTarget","currentFullscreenStrategy","restoreOldWindowedStyle","ExitStatus","getEnvStrings","doReadv","doWritev","promiseMap","uncaughtExceptionCount","exceptionLast","exceptionCaught","ExceptionInfo","Browser","getPreloadedImageData__data","wget","SYSCALLS","getSocketFromFD","getSocketAddress","preloadPlugins","FS_modeStringToFlags","FS_getMode","FS_stdin_getChar_buffer","FS_stdin_getChar","MEMFS","TTY","PIPEFS","SOCKFS","tempFixedLengthArray","miniTempWebGLFloatBuffers","miniTempWebGLIntBuffers","GL","AL","GLUT","EGL","GLEW","IDBStore","SDL","SDL_gfx","allocateUTF8","allocateUTF8OnStack","InternalError","BindingError","throwInternalError","throwBindingError","registeredTypes","awaitingDependencies","typeDependencies","tupleRegistrations","structRegistrations","sharedRegisterType","whenDependentTypesAreResolved","embind_charCodes","embind_init_charCodes","readLatin1String","getTypeName","getFunctionName","heap32VectorToArray","requireRegisteredType","usesDestructorStack","createJsInvoker","UnboundTypeError","PureVirtualError","GenericWireTypeSize","EmValType","init_embind","throwUnboundTypeError","ensureOverloadTable","exposePublicSymbol","replacePublicSymbol","extendError","createNamedFunction","embindRepr","registeredInstances","getBasestPointer","getInheritedInstance","getInheritedInstanceCount","getLiveInheritedInstances","registeredPointers","registerType","integerReadValueFromPointer","floatReadValueFromPointer","readPointer","runDestructors","newFunc","craftInvokerFunction","embind__requireFunction","genericPointerToWireType","constNoSmartPtrRawPointerToWireType","nonConstNoSmartPtrRawPointerToWireType","init_RegisteredPointer","RegisteredPointer","RegisteredPointer_fromWireType","runDestructor","releaseClassHandle","finalizationRegistry","detachFinalizer_deps","detachFinalizer","attachFinalizer","makeClassHandle","init_ClassHandle","ClassHandle","throwInstanceAlreadyDeleted","deletionQueue","flushPendingDeletes","delayFunction","setDelayFunction","RegisteredClass","shallowCopyInternalPointer","downcastPointer","upcastPointer","char_0","char_9","makeLegalFunctionName","emval_freelist","emval_handles","emval_symbols","init_emval","count_emval_handles","Emval","emval_methodCallers","reflectConstruct","IDBFS"];Ps.forEach(oe);var dr;me=function o(){dr||ho(),dr||(me=o)};function ks(){po(),fe()}function ho(){if(ge>0||(ks(),Pe(),ge>0))return;function o(){dr||(dr=!0,r.calledRun=!0,!X&&(ot(),s(r),r.onRuntimeInitialized&&r.onRuntimeInitialized(),L(!r._main,'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]'),qe()))}r.setStatus?(r.setStatus("Running..."),setTimeout(function(){setTimeout(function(){r.setStatus("")},1),o()},1)):o(),Ee()}if(r.preInit)for(typeof r.preInit=="function"&&(r.preInit=[r.preInit]);r.preInit.length>0;)r.preInit.pop()();return ho(),t.ready}})();let module,loading=!1;const useKbres=()=>{const[e,t]=reactExports.useState(null),[r,s]=reactExports.useState(!1),a=reactExports.useRef();return reactExports.useEffect(()=>{if(loading){a.current=setInterval(()=>{module!==void 0&&(s(!0),t(module),clearInterval(a.current))},1e3);return}if(module!==void 0){s(!0),t(module);return}return loading=!0,console.log("kbres loading"),createModule().then(l=>{module=l,s(!0),t(l)}).catch(l=>{console.log(l)}).finally(()=>{loading=!1,console.log("kbres load ended")}),()=>{clearInterval(a.current)}},[]),{kbres:e,loaded:r}},title$2="Matrix Lighting",MatrixLightingPane=styled(CenterPane)`
|
|
1108
|
+
height: 100%;
|
|
1109
|
+
overflow: auto;
|
|
1110
|
+
grid-column: span 2;
|
|
1111
|
+
`,Container$f=styled.div`
|
|
1112
|
+
display: flex;
|
|
1113
|
+
align-items: center;
|
|
1114
|
+
padding: 16px;
|
|
1115
|
+
flex-direction: column;
|
|
1116
|
+
`,MatrixEditor=styled.div`
|
|
1117
|
+
display: flex;
|
|
1118
|
+
// align-items: flex-end;
|
|
1119
|
+
justify-content: center;
|
|
1120
|
+
width: 100%;
|
|
1121
|
+
max-width: 960px;
|
|
1122
|
+
`,MatrixConfigure=styled.div`
|
|
1123
|
+
margin-left: 20px;
|
|
1124
|
+
display: flex;
|
|
1125
|
+
flex-direction: column;
|
|
1126
|
+
justify-content: space-between;
|
|
1127
|
+
`,MatrixControlRows=styled.div`
|
|
1128
|
+
width: 400px;
|
|
1129
|
+
`,MatrixIndex=styled.div`
|
|
1130
|
+
font-size: 14px;
|
|
1131
|
+
color: var(--color_label);
|
|
1132
|
+
`,MatrixWrapper=styled.div`
|
|
1133
|
+
border: 1px solid var(--border_color_cell);
|
|
1134
|
+
display: flex;
|
|
1135
|
+
flex-direction: column;
|
|
1136
|
+
align-items: center;
|
|
1137
|
+
justify-content: center;
|
|
1138
|
+
border-radius: 5px;
|
|
1139
|
+
padding: 1px;
|
|
1140
|
+
background: var(--bg_menu);
|
|
1141
|
+
height: fit-content;
|
|
1142
|
+
`,Light=styled.div.attrs(({$color:e})=>({style:{background:`rgb(${e.r},${e.g},${e.b})`,boxShadow:`rgba(0, 0, 0, 0.15) 0px 0px 0px 1px inset, rgb(${e.r},${e.g},${e.b}) 0px 0px 3px`}}))`
|
|
1143
|
+
width: 20px;
|
|
1144
|
+
height: 20px;
|
|
1145
|
+
display: inline-block;
|
|
1146
|
+
border-radius: 50%;
|
|
1147
|
+
cursor: pointer;
|
|
1148
|
+
margin: 1px;
|
|
1149
|
+
`,ColorPicker$1=styled(SketchPicker)`
|
|
1150
|
+
line-height: 1;
|
|
1151
|
+
input {
|
|
1152
|
+
color: var(--color_accent);
|
|
1153
|
+
background: none;
|
|
1154
|
+
border: none !important;
|
|
1155
|
+
border-bottom: 1px solid var(--color_accent) !important;
|
|
1156
|
+
box-shadow: none !important;
|
|
1157
|
+
text-align: center;
|
|
1158
|
+
}
|
|
1159
|
+
label {
|
|
1160
|
+
color: var(--color_accent) !important;
|
|
1161
|
+
}
|
|
1162
|
+
.flexbox-fix {
|
|
1163
|
+
border: none !important;
|
|
1164
|
+
}
|
|
1165
|
+
position: absolute;
|
|
1166
|
+
transform: translate3d(14px, -22px, 0);
|
|
1167
|
+
z-index: 1;
|
|
1168
|
+
&::after {
|
|
1169
|
+
content: '';
|
|
1170
|
+
position: absolute;
|
|
1171
|
+
width: 0px;
|
|
1172
|
+
height: 0px;
|
|
1173
|
+
border: 11px solid var(--border_color_cell);
|
|
1174
|
+
border-top-color: transparent;
|
|
1175
|
+
border-bottom-color: transparent;
|
|
1176
|
+
border-left-color: transparent;
|
|
1177
|
+
top: 12px;
|
|
1178
|
+
left: -22px;
|
|
1179
|
+
pointer-events: none;
|
|
1180
|
+
}
|
|
1181
|
+
`,ColorPreview$1=styled.div`
|
|
1182
|
+
width: 20px;
|
|
1183
|
+
height: 20px;
|
|
1184
|
+
border-radius: 20px;
|
|
1185
|
+
background: ${e=>`rgb(${e.$color.r},${e.$color.g},${e.$color.b})`};
|
|
1186
|
+
border: 1px solid var(--color_accent);
|
|
1187
|
+
cursor: pointer;
|
|
1188
|
+
margin-left: 5px;
|
|
1189
|
+
`,MatrixList=styled.div`
|
|
1190
|
+
margin-top: 20px;
|
|
1191
|
+
display: flex;
|
|
1192
|
+
width: 100%;
|
|
1193
|
+
border-top: 1px solid var(--border_color_cell);
|
|
1194
|
+
padding-top: 10px;
|
|
1195
|
+
flex-wrap: wrap;
|
|
1196
|
+
& > div {
|
|
1197
|
+
margin: 0 6px 6px 0;
|
|
1198
|
+
}
|
|
1199
|
+
`,MatrixButtons=styled.div`
|
|
1200
|
+
border-radius: 2px;
|
|
1201
|
+
border: 1px solid var(--border_color_icon);
|
|
1202
|
+
display: inline-flex;
|
|
1203
|
+
> button:last-child {
|
|
1204
|
+
border: none;
|
|
1205
|
+
}
|
|
1206
|
+
`,FpsSelect=styled(AccentSelect)`
|
|
1207
|
+
> div[class*='-control'] {
|
|
1208
|
+
width: 100%;
|
|
1209
|
+
}
|
|
1210
|
+
`,FlexLabel$1=styled.div`
|
|
1211
|
+
color: var(--color_label);
|
|
1212
|
+
font-weight: 400;
|
|
1213
|
+
display: inline-flex;
|
|
1214
|
+
align-items: center;
|
|
1215
|
+
`,HiddenInput$2=styled.input`
|
|
1216
|
+
display: none;
|
|
1217
|
+
`,MainMatrixContainer=styled.div`
|
|
1218
|
+
display: flex;
|
|
1219
|
+
flex-direction: column;
|
|
1220
|
+
justify-content: center;
|
|
1221
|
+
align-items: center;
|
|
1222
|
+
`,getMatrixData=(e,t,r,s,a)=>{const l=r*s*a,c=Array(s).fill(0).map(()=>Array(r).fill({r:0,g:0,b:0}));for(let d=t;d<t+l;d+=a){const p=d%l/a,f=~~(p/r),m=p%r,[y,K,x]=[e[d],e[d+1],e[d+2]];c[f][m]={r:y,g:K,b:x}}return c},Lighting=reactExports.memo(({color:e,row:t,col:r,changing:s})=>{const a=useAppDispatch(),l=f=>{f.button===0&&(s.current=!0,a(updateMatrix({row:t,col:r})),window.addEventListener("pointerup",d))},c=()=>{s.current&&a(updateMatrix({row:t,col:r}))},d=()=>{s.current=!1,window.removeEventListener("pointerup",d)};return jsx(Light,{onContextMenu:f=>{f.preventDefault(),a(updateColor(e))},onPointerDown:l,onPointerOver:c,$color:e})},shallowEqual),MatrixFrame=reactExports.memo(({matrix:e,index:t,active:r})=>{const s=useAppDispatch(),a=reactExports.useRef(null),l=e.length,c=e[0].length,d=c*5,p=l*5,f=x=>{x.preventDefault()},m=x=>{s(updateMatrixIndex(t))},y=x=>{t!==void 0&&s(sortMatrixByIndex({newIndex:t}))},K=reactExports.useCallback(()=>{if(!a.current)return;const x=a.current;x.width=10*c,x.height=10*l;const v=x.getContext("2d");for(let M=0;M<l;M++)for(let b=0;b<c;b++){const R=e[M][b];v.beginPath(),v.arc(b*10+5,M*10+5,4,0,Math.PI*2),v.fillStyle=`rgb(${R.r}, ${R.g}, ${R.b})`,v.shadowOffsetX=0,v.shadowOffsetY=0,v.shadowBlur=5,v.shadowColor=`rgb(${R.r}, ${R.g}, ${R.b})`,v.fill()}},[e]);return reactExports.useEffect(K,[e]),jsx("div",{style:{width:d,height:p,background:"#000",border:r?"1px solid var(--color_accent)":"1px solid var(--border_color_cell)",borderRadius:5,cursor:"pointer"},draggable:!0,onDragStart:m,onDragOver:f,onDragEnter:y,onClick:()=>s(updateMatrixIndex(t)),children:jsx("canvas",{style:{width:"100%",height:"100%"},ref:a})})},shallowEqual),MatrixPane=reactExports.memo(({matrix:e})=>{const t=reactExports.useRef(!1);return jsx(MatrixWrapper,{children:e.map((r,s)=>jsx("div",{style:{display:"flex"},children:r.map((a,l)=>jsx(Lighting,{color:a,row:s,col:l,changing:t},l))},s))})},shallowEqual),Pane$2=()=>{var Vt,Dt,Rt,Ht;const{t:e,i18n:t}=useTranslation(),r=useAppDispatch(),{kbres:s}=useKbres(),a=useAppSelector(getActiveColor),l=useAppSelector(getMatrixList),c=useAppSelector(getMatrixIdx),d=useAppSelector(getActiveMatrix),p=useAppSelector(getFps),f=useAppSelector(getSaving),m=useAppSelector(getFileContent),y=useAppSelector(getRows),K=useAppSelector(getCols),x=useAppSelector(getTextsConfig),v=(Dt=(Vt=useAppSelector(getSelectedTabkbConfig))==null?void 0:Vt.matrixLighting)==null?void 0:Dt.info,[M,b]=reactExports.useState(!1),[R,O]=reactExports.useState(null),[I,k]=reactExports.useState(null),[F,V]=reactExports.useState(!1),[$,z]=reactExports.useState(!1),X=useAppSelector(getImportEnable),L=useAppSelector(getMaxFrame),H=useAppSelector(getCDCMacIssue),B=useAppSelector(getSelectedConnectedDevice),Q=(Ht=(Rt=useAppSelector(getSelectedTabkbConfig))==null?void 0:Rt.matrixLighting)==null?void 0:Ht.shareApi,q=reactExports.useMemo(()=>[5,10,15,20].map(oe=>({label:oe+" "+e("FPS"),value:oe})),[t.language]),T=q.find(oe=>oe.value===p),j=reactExports.useRef(null),te=reactExports.useRef(null),re=reactExports.useRef(null),de=reactExports.useRef(null),fe=reactExports.useRef(null),Ee=reactExports.useRef(),$e={default:{picker:{background:"var(--border_color_cell)"}}},Qe=["#000","#fff","#f00","#0f0","#00f","#ff0","#f0f","#0ff"],Xe=oe=>{!F||!j.current||!te.current||oe.target!==te.current&&!j.current.contains(oe.target)&&V(!1)},_e=oe=>{if(!oe.target.files)return;const Ke=new Image,Ae=URL.createObjectURL(oe.target.files[0]);Ke.onload=()=>{const je=pixleImg(Ke,K,y);r(setMatrix(getMatrixData(je,0,K,y,4))),URL.revokeObjectURL(Ae),re.current&&(re.current.value="")},Ke.src=Ae},Pe=async oe=>{if(!oe.target.files||!s||M)return;b(!0);const Ke="pixel.out",Ae=oe.target.files[0],je=await Ae.arrayBuffer(),tt=new Uint8Array(je);s.FS.writeFile(Ae.name,tt);const ft=new s.IntVec;ft.push_back(K),ft.push_back(y),s.pixelit(Ae.name,Ke,ft,L);const _t=s.FS.readFile(Ke),bt=[],It=y*K*3;for(let nt=0;nt<_t.length;nt+=It)bt.push(getMatrixData(_t,nt,K,y,3));r(setMatrixList(bt)),de.current&&(de.current.value=""),b(!1)},ot=async oe=>{if(O(null),!oe.target.files)return;const Ke=oe.target.files[0];if(!Ke)return;const Ae=new FileReader;Ae.onabort=()=>O(e("File reading was cancelled.")),Ae.onerror=()=>O(e("Failed to read file.")),Ae.onload=()=>{if(Ae.result){const je=Array.from(new Uint8Array(Ae.result)),tt=je.slice(0,mlHeaderSize),ft=je.slice(mlHeaderSize);if(!lodashExports.isEqual(mlHeader,tt.slice(0,mlHeader.length))){O(e("Could not load file: invalid data."));return}const[_t,bt,It,nt]=tt.slice(mlHeader.length);if(_t===0||y!==It||K!==nt||K*y*3*_t!==ft.length){O(e("Could not load file: invalid data."));return}r(loadFile({frames:_t,fps:bt,data:ft}))}},Ae.readAsArrayBuffer(Ke),fe.current&&(fe.current.value="")},qe=async()=>{try{await r(saveToKeyboard())}catch{O(e("Failed to save."))}},ne=()=>{var oe;(oe=fe.current)==null||oe.click()},se=async()=>{const oe=`via_lighting_${K}_${y}.tabml`;try{const Ke=await window.showSaveFilePicker({suggestedName:oe}),Ae=new Blob([Uint8Array.from(m)],{type:"octet/stream"}),je=await Ke.createWritable();await je.write(Ae),await je.close()}catch(Ke){console.log(Ke)}},[Me,ge]=reactExports.useState(!1),ue=()=>{if(Me||!Q)return;const oe=new AbortController,Ke=oe.signal;let Ae=new FormData;Ae.append("file",new Blob([Uint8Array.from(m)])),O(null),ge(!0),fetch(Q,{method:"POST",body:Ae,signal:Ke}).then(je=>{if(je.status!==200){console.log(je.status),O(e("Sharing failed"));return}je.json().then(tt=>{tt.error?(console.log(tt.error),O(e("Sharing failed"))):k(e("Sharing success")),setTimeout(()=>{k(null)},3e3)})}).catch(je=>{console.log(je),O(e("Sharing failed"))}).finally(()=>{ge(!1)}),setTimeout(()=>{oe.abort(),ge(!1)},60*1e3)};reactExports.useEffect(()=>(document.addEventListener("click",Xe),()=>{document.removeEventListener("click",Xe)}),[F]),reactExports.useEffect(()=>(clearInterval(Ee.current),$&&(Ee.current=setInterval(()=>{r(nextMatrix())},1e3/p)),()=>{clearInterval(Ee.current)}),[$,p]);const me=oe=>{oe.key==="ArrowRight"?r(shiftRight()):oe.key==="ArrowLeft"?r(shiftLeft()):oe.key==="ArrowUp"?r(shiftUp()):oe.key==="ArrowDown"&&r(shiftDown())};reactExports.useEffect(()=>(window.addEventListener("keyup",me),()=>{window.removeEventListener("keyup",me)}),[]);const Ne=navigator.userAgent.includes("Mac")&&H,[Te,Ve]=reactExports.useState("frames"),pe=useAppSelector(getTexts),[be,it]=reactExports.useState(pe),He=oe=>{(!oe.data||!/^[\x20-\x7E]+$/.test(oe.data))&&oe.preventDefault()},Ce=(oe,Ke)=>{const Ae=be.map((je,tt)=>tt===Ke?`${oe.target.value}`.toUpperCase():je);it(Ae)},Be=()=>{r(saveTexts(be))},Je=useAppSelector(getInfoContent),Ze=[{label:e("Time"),value:0},{label:e("Connection Status"),value:1}],Fe=Ze.find(oe=>oe.value===Je),ht=B&&B.vendorId===58720&&B.productId===57604,Lt=parseVersionStr("1.1.3"),Z=parseVersionStr("1.2.0"),he=v&&(ht?B.firmware<Lt||B.firmware>=Z:!0),et=ht?B.firmware>=Z:!0;return jsxs(Fragment,{children:[x||he?jsx(SubmenuOverflowCell,{children:jsxs(MenuContainer$6,{children:[jsx(SubmenuRow,{$selected:Te==="frames",onClick:()=>Ve("frames"),children:e("MATRIX_LED_FRAMES")}),x&&jsx(SubmenuRow,{$selected:Te==="texts",onClick:()=>Ve("texts"),children:e("MATRIX_LED_DANMAKU")}),he&&jsx(SubmenuRow,{$selected:Te==="info",onClick:()=>Ve("info"),children:e("MATRIX_LED_INFO")})]})}):jsx("div",{}),jsxs(OverflowCell,{children:[jsx(MatrixLightingPane,{style:{height:Te==="frames"?"100%":0},onDragOver:oe=>{oe.preventDefault()},children:jsxs(Container$f,{children:[jsxs(MatrixEditor,{children:[jsxs(MainMatrixContainer,{children:[jsx(MatrixPane,{matrix:d}),jsxs(MatrixIndex,{children:[c+1,"/",l.length]})]}),jsx(MatrixConfigure,{children:jsxs(MatrixControlRows,{children:[jsxs(ControlRow,{style:{pointerEvents:$?"none":"auto"},children:[jsxs(FlexLabel$1,{children:[jsx(ColorPreview$1,{ref:te,onMouseOver:()=>V(!0),$color:a}),F&&jsx("div",{ref:j,children:jsx(ColorPicker$1,{styles:$e,presetColors:Qe,disableAlpha:!0,color:a,onChange:oe=>{r(updateColor(oe.rgb))}})}),jsx(Fragment,{})]}),jsx(Detail,{children:jsx(MatrixButtons,{children:jsxs(IconButtonContainer,{onClick:()=>r(resetMatrix()),children:[jsx(FontAwesomeIcon,{size:"sm",icon:faTrash}),jsx(IconButtonTooltip,{children:e("Delete All")})]})})})]}),jsxs(ControlRow,{style:{pointerEvents:$?"none":"auto"},children:[jsx(FlexLabel$1,{children:jsxs(MatrixButtons,{children:[jsxs(IconButtonContainer,{disabled:l.length>=L,onClick:()=>r(copyMatrix()),children:[jsx(FontAwesomeIcon,{size:"sm",icon:faCopy}),jsx(IconButtonTooltip,{children:e("Copy")})]}),jsxs(IconButtonContainer,{disabled:l.length>=L,onClick:()=>r(addMatrix()),children:[jsx(FontAwesomeIcon,{size:"sm",icon:faAdd}),jsx(IconButtonTooltip,{children:e("Add")})]}),jsxs(IconButtonContainer,{onClick:()=>r(deleteMatrix()),children:[jsx(FontAwesomeIcon,{size:"sm",icon:faMinus}),jsx(IconButtonTooltip,{children:e("Delete")})]}),jsxs(IconButtonContainer,{onClick:()=>r(fillMatrix()),children:[jsx(FontAwesomeIcon,{size:"sm",icon:faRotateLeft}),jsx(IconButtonTooltip,{children:e("Reset")})]}),X&&jsxs(Fragment,{children:[jsxs(IconButtonContainer,{onClick:()=>{var oe;return(oe=re.current)==null?void 0:oe.click()},children:[jsx(FontAwesomeIcon,{size:"sm",icon:faImage}),jsx(IconButtonTooltip,{children:e("Import Image")})]}),jsxs(IconButtonContainer,{onClick:()=>{var oe;return(oe=de.current)==null?void 0:oe.click()},children:[jsx(FontAwesomeIcon,{size:"sm",icon:faVideo}),jsx(IconButtonTooltip,{children:e("Import Video")})]})]})]})}),jsxs(Detail,{children:[jsx(HiddenInput$2,{accept:"image/*",onChange:_e,type:"file",ref:re}),jsx(HiddenInput$2,{accept:"video/mp4,image/gif",onChange:Pe,type:"file",ref:de})]})]}),jsxs(ControlRow,{children:[jsx(FlexLabel$1,{children:jsx(Detail,{children:jsx(FpsSelect,{value:T,onChange:oe=>r(setFps(oe.value)),options:q})})}),jsx(Detail,{children:jsx(MatrixButtons,{children:jsxs(IconButtonContainer,{onClick:()=>z(!$),children:[jsx(FontAwesomeIcon,{size:"sm",icon:$?faStop:faPlay}),jsx(IconButtonTooltip,{children:e($?"Stop":"Play")})]})})})]}),jsxs(ControlRow,{children:[jsx(FlexLabel$1,{children:jsxs(MatrixButtons,{children:[jsxs(IconButtonContainer,{onClick:ne,children:[jsx(FontAwesomeIcon,{size:"sm",icon:faFileImport}),jsx(IconButtonTooltip,{children:e("Import File")})]}),jsx(HiddenInput$2,{accept:".tabml",onChange:ot,type:"file",ref:fe}),jsxs(IconButtonContainer,{onClick:se,children:[jsx(FontAwesomeIcon,{size:"sm",icon:faDownload}),jsx(IconButtonTooltip,{children:e("Download File")})]}),Q&&jsxs(IconButtonContainer,{onClick:ue,children:[jsx(FontAwesomeIcon,{size:"sm",icon:faShare}),jsx(IconButtonTooltip,{children:e("Share")})]})]})}),jsx(Detail,{children:jsx(AccentButton,{disabled:f||Ne,onClick:qe,children:e("Save")})})]}),R?jsx(ErrorMessage,{onClick:()=>O(null),children:R}):null,I?jsx(SuccessMessage,{onClick:()=>k(null),children:I}):null]})})]}),Ne&&jsx("div",{style:{padding:"20px 0 0",color:"var(--color_label)"},children:e("MATRIX_LED_MAC_NOTSUPPORT")}),jsx("div",{style:{padding:"20px 0 0",color:"var(--color_label)",fontSize:16},children:e("MATRIX_LED_TIPS")}),jsx(MatrixList,{children:l.map((oe,Ke)=>jsx(MatrixFrame,{matrix:oe,index:Ke,active:Ke===c},Ke))})]})}),x&&jsx(MatrixLightingPane,{style:{height:Te==="texts"?"100%":0},children:jsxs(Container$f,{style:{},children:[Array(x.count).fill(0).map((oe,Ke)=>{var Ae;return jsxs(ControlRow,{style:{height:40,lineHeight:"40px",border:"none"},children:[jsx(Label$1,{style:{lineHeight:"50px",marginRight:10},children:Ke+1}),jsxs(Detail,{style:{flex:1},children:[jsx(TextInput,{placeholder:Ke===0&&x.default?x.default:"",maxLength:x.length,onBeforeInput:He,value:be[Ke],onChange:je=>Ce(je,Ke),style:{width:"100%",marginBottom:0,padding:"0.1em"},spellCheck:"false",type:"text"}),jsx("span",{style:{fontSize:14},children:`${(Ae=be[Ke])==null?void 0:Ae.length}/${x.length}`})]})]},Ke)}),jsxs(ControlRow,{style:{border:"none"},children:[jsx(Label$1,{}),jsx(Detail,{children:jsx(AccentButton,{onClick:Be,children:e("Save")})})]})]})}),he&&jsx(MatrixLightingPane,{children:jsxs(Container$f,{style:{},children:[jsx(TimeSyncItem,{}),et&&jsxs(ControlRow,{children:[jsxs(Label$1,{children:[e("Display Content"),":"]}),jsx(Detail,{children:jsx(AccentSelect,{value:Fe,onChange:oe=>r(saveInfoContent(oe.value)),options:Ze})})]}),jsx(ControlRow,{children:jsx(Label$1,{style:{fontSize:16},children:e("MATRIX_LED_INFO_TIPS")})})]})})]})]})},Icon$2=()=>jsx("svg",{viewBox:"-1 -1 18 18",fill:"currentColor",children:jsx("path",{d:"M3.5 2.25a1.25 1.25 0 11-2.5 0 1.25 1.25 0 012.5 0zm11.5 0a1.25 1.25 0 11-2.5 0 1.25 1.25 0 012.5 0zm-1.25 7a1.25 1.25 0 100-2.5 1.25 1.25 0 000 2.5zm1.25 4.5a1.25 1.25 0 11-2.5 0 1.25 1.25 0 012.5 0zM2.25 9.25a1.25 1.25 0 100-2.5 1.25 1.25 0 000 2.5zm7-1.25a1.25 1.25 0 11-2.5 0 1.25 1.25 0 012.5 0zM8 15a1.25 1.25 0 100-2.5A1.25 1.25 0 008 15zM9.25 2.25a1.25 1.25 0 11-2.5 0 1.25 1.25 0 012.5 0zM2.25 15a1.25 1.25 0 100-2.5 1.25 1.25 0 000 2.5z"})}),Title$4=title$2,MatrixLighting=Object.freeze(Object.defineProperty({__proto__:null,Icon:Icon$2,Pane:Pane$2,Title:Title$4},Symbol.toStringTag,{value:"Module"}));var ThemeAnim=(e=>(e[e.ANIM_NONE=0]="ANIM_NONE",e[e.ANIM_A=1]="ANIM_A",e[e.ANIM_B=2]="ANIM_B",e))(ThemeAnim||{});const ProgressBarContainer=styled.div`
|
|
1223
|
+
position: relative;
|
|
1224
|
+
margin-top: 10px;
|
|
1225
|
+
line-height: 1;
|
|
1226
|
+
&:hover {
|
|
1227
|
+
& .tooltip {
|
|
1228
|
+
transform: scale(1) translateY(0px);
|
|
1229
|
+
opacity: 1;
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
.tooltip {
|
|
1233
|
+
transform: translateY(5px) scale(0.6);
|
|
1234
|
+
opacity: 0;
|
|
1235
|
+
}
|
|
1236
|
+
`,ProgressBar=styled.div`
|
|
1237
|
+
background: var(--bg_control);
|
|
1238
|
+
position: relative;
|
|
1239
|
+
padding: 5px;
|
|
1240
|
+
border-radius: 5px;
|
|
1241
|
+
overflow: hidden;
|
|
1242
|
+
margin-bottom: 10px;
|
|
1243
|
+
cursor: pointer;
|
|
1244
|
+
width: 250px;
|
|
1245
|
+
|
|
1246
|
+
> span {
|
|
1247
|
+
content: '';
|
|
1248
|
+
position: absolute;
|
|
1249
|
+
left: 0;
|
|
1250
|
+
top: 0;
|
|
1251
|
+
background: var(--color_accent);
|
|
1252
|
+
height: 10px;
|
|
1253
|
+
width: 100%;
|
|
1254
|
+
transform: scaleX(0.01);
|
|
1255
|
+
transform-origin: left;
|
|
1256
|
+
transition: transform 0.4s ease-in-out;
|
|
1257
|
+
}
|
|
1258
|
+
`,HiddenInput$1=styled.input`
|
|
1259
|
+
display: none;
|
|
1260
|
+
`,MediaRow=styled.div`
|
|
1261
|
+
max-width: 960px;
|
|
1262
|
+
width: 100%;
|
|
1263
|
+
display: flex;
|
|
1264
|
+
flex-direction: column;
|
|
1265
|
+
border: 1px solid var(--border_color_cell);
|
|
1266
|
+
border-style: dashed;
|
|
1267
|
+
justify-content: center;
|
|
1268
|
+
align-items: center;
|
|
1269
|
+
padding: 10px;
|
|
1270
|
+
border-radius: 15px;
|
|
1271
|
+
min-height: 100px;
|
|
1272
|
+
margin-bottom: 10px;
|
|
1273
|
+
box-sizing: border-box;
|
|
1274
|
+
text-align: center;
|
|
1275
|
+
color: var(--color_label-highlighted);
|
|
1276
|
+
`,FlexLabel=styled.div`
|
|
1277
|
+
color: var(--color_label);
|
|
1278
|
+
font-weight: 400;
|
|
1279
|
+
display: inline-flex;
|
|
1280
|
+
align-items: center;
|
|
1281
|
+
position: relative;
|
|
1282
|
+
`,getScreenFiles=e=>{const t=s=>new Promise((a,l)=>{const c=document.createElement("video");c.onloadedmetadata=()=>{a([c.videoWidth,c.videoHeight])},c.src=s,c.load()}),r=s=>new Promise((a,l)=>{const c=document.createElement("img");c.onload=()=>{a([c.width,c.height])},c.src=s});return Promise.all(e.map(async s=>{const a=URL.createObjectURL(s),l=await s.arrayBuffer(),c=new Uint8Array(l);let d=0,p=0;return s.type.startsWith("video")?[d,p]=await t(a):s.type.startsWith("image")&&([d,p]=await r(a)),{name:s.name,type:s.type,src:a,width:d,height:p,byteArray:c}}))},ExportSelect=({area:e,onChange:t})=>{const{t:r}=useTranslation(),s=useAppSelector(getSelectedTool),a=useAppSelector(getExportOptions),l=useAppSelector(getSelectedConnectedDevice),c=l?l.vendorProductId:-1;if(!a)return null;const d=a.map(f=>({label:`${r(f.label)} (${f.owidth}x${f.oheight})`,value:f})),p=d.find(f=>f.value===e);return jsx(Fragment,{children:jsx(AccentSelect,{onChange:t,value:p,options:d},c+s)})},printBytes=e=>{if(e===0)return 0;const t=["Bytes","kB","MB","GB"],r=Math.floor(Math.log10(e)/3),s=t[r],a=r===0?1:Math.pow(1e3,r);return`${(e/a).toFixed(r)} ${s}`},SavingStatus=styled.div`
|
|
1283
|
+
margin-left: 10px;
|
|
1284
|
+
`,printTime=e=>{e=~~e;const t=~~(e/60),r=e%60;return`${t}:${r<10?"0":""}${r}`},SavingProgress=({bufferSize:e,bytesSended:t,sendSpeed:r})=>{const{t:s}=useTranslation();return jsxs(Fragment,{children:[jsxs(ProgressBarContainer,{children:[jsx(ProgressBar,{children:jsx("span",{style:{transform:`scaleX(${t/e})`}})}),jsxs(ProgressBarTooltip,{children:[printBytes(r),"/s,"," ",` -${printTime((e-t)/r)}`]})]}),jsxs(SavingStatus,{children:[~~(t/e*100)," % (",printBytes(t)," /"," ",printBytes(e),")"," ",t===0&&s("Initializing")]})]})},Dialog=e=>{const{t}=useTranslation(),r=e.cancelText??"Cancel",s=e.confirmText??"Confirm";return jsx(ModalBackground,{children:jsxs(ModalContainer,{children:[jsx(PromptText,{children:e.text&&e.text}),jsxs(RowDiv$1,{children:[jsx(AccentButton,{onClick:e.onExit,children:t(r)}),jsx(PrimaryAccentButton,{onClick:e.onConfirm,children:t(s)})]})]})})},FileSaveControl=({area:e,setArea:t,generate:r,disabled:s,wasmLoaded:a})=>{const{t:l}=useTranslation(),c=useAppDispatch(),d=useAppSelector(getSavingState$2),[p,f]=reactExports.useState(""),m=useAppSelector(getBufferSize$2),y=useAppSelector(getBytesSended$2),K=useAppSelector(getSendSpeed$2),[x,v]=reactExports.useState(!1),[M,b]=reactExports.useState(!1),R=useAppSelector(getSelectedTool),O=useAppSelector(getLightingSupport),I=async()=>{f(""),v(!0);const k=async()=>{let F=null;try{F=r()}catch($){console.log($)}if(v(!1),F==null){f(l("Failed to process."));return}let V=lodashExports.isArray(F)?F.reduce(($,z)=>$+z.length,0):F.length;await c(initSendState({size:V})),c(saveTabFile(F,$=>{$||f(l("Failed to save."))}))};setTimeout(()=>{k()},300)};return reactExports.useEffect(()=>{d!=="saving"&&b(!1)},[d]),jsxs(Fragment,{children:[e&&t&&jsxs(ControlRow,{children:[jsxs(Label$1,{children:[l("Type"),"๏ผ"]}),jsx(Detail,{children:jsx(ExportSelect,{area:e,onChange:k=>t(k.value)})})]}),jsxs(ControlRow,{children:[jsxs(FlexLabel,{children:[p&&jsxs(Fragment,{children:[jsx(FontAwesomeIcon,{icon:faWarning,size:"xs",style:{color:"gold",marginRight:5}}),p]})," ",x&&l("Processing"),d==="saving"&&jsx(SavingProgress,{bufferSize:m,sendSpeed:K,bytesSended:y})]}),jsxs(Detail,{children:[d==="saving"&&y>0&&jsxs(Fragment,{children:[jsx(AccentButton,{onClick:()=>b(!0),children:l("Cancel")}),M&&d==="saving"&&y>0&&jsx(Dialog,{text:l(`Cancel transfer will revert to factory default ${R}, confirm cancel?`),cancelText:"No",confirmText:"Yes",onConfirm:()=>{c(updateState$2("canceled")),b(!1)},onExit:()=>b(!1)})]}),d!=="saving"&&jsx(Fragment,{children:jsx(AccentButton,{onClick:I,disabled:s||!a,children:l("Save")})})]})]}),O&&jsx(ControlRow,{children:jsx(Label$1,{style:{fontSize:16},children:l(a?"To boost the data transfer speed, the backlight will shut off during transfer period and resume afterwards.":"Loading resources...")})}),jsx(ControlRow,{children:jsx(Label$1,{style:{fontSize:16},children:l("TRANS_TIP")})})]})},MediaContainer$1=styled.div.attrs(({$width:e,$height:t})=>({style:{width:e,height:t,display:e>0&&t>0?"block":"none"}}))`
|
|
1285
|
+
position: relative;
|
|
1286
|
+
`,Dragger$1=styled.div`
|
|
1287
|
+
top: 0;
|
|
1288
|
+
left: 0;
|
|
1289
|
+
position: absolute;
|
|
1290
|
+
cursor: move;
|
|
1291
|
+
cursor: grab;
|
|
1292
|
+
transition: all 0.3s;
|
|
1293
|
+
z-index: 1;
|
|
1294
|
+
&.react-draggable-dragging {
|
|
1295
|
+
transition: none;
|
|
1296
|
+
cursor: grabbing;
|
|
1297
|
+
}
|
|
1298
|
+
`,getDimension$1=(e,t)=>{if(e&&t){const[r,s]=[t.width,t.height],[a,l]=[e.owidth,e.oheight],c=r/s,d=a/l;return c>d?[~~(c*l),l]:[a,~~(a/c)]}return[0,0]},CropTool=reactExports.memo(()=>{const{t:e}=useTranslation(),t=useAppSelector(getSelectedTool),r=useAppSelector(getDefaultArea),s=useAppSelector(getKbresFlags);if(!r)return null;const[a,l]=reactExports.useState([]),[c,d]=reactExports.useState(r),p=a[0],f=reactExports.useRef(null),[m,y]=getDimension$1(c,p),[K,x]=reactExports.useState(Math.floor((m-c.owidth)/2)),[v,M]=reactExports.useState(Math.floor((y-c.oheight)/2)),b={left:0,top:0,right:m-c.owidth,bottom:y-c.oheight},R=t==="video"?"image/gif,video/mp4":"image/png,image/jpeg,image/bmp",O=()=>{var H;(H=f.current)==null||H.click()},{kbres:I,loaded:k}=useKbres(),F=async H=>{H.target.files&&l(await getScreenFiles(Array.from(H.target.files)))},V=(H,B)=>{x(B.x),M(B.y)},$=reactExports.useRef(null),z=reactExports.useRef(0),X=()=>{if(!$.current){z.current=0;return}const H=$.current,B=H.getContext("2d");B.clearRect(0,0,H.width,H.height);const Q=5;B.setLineDash([Q,Q]),B.lineDashOffset=z.current,B.strokeStyle="white",B.beginPath(),B.rect(0,0,H.width,H.height),B.stroke(),B.lineDashOffset=z.current+Q,B.strokeStyle="black",B.beginPath(),B.rect(0,0,H.width,H.height),B.stroke(),z.current+=3,setTimeout(X,200)};reactExports.useEffect(()=>{setTimeout(()=>{x(Math.floor((m-c.owidth)/2)),M(Math.floor((y-c.oheight)/2)),z.current===0&&X()},0)},[c,m,y]);const L=()=>{if(!I)return null;const H="/tabkb";try{I.FS.stat(H)}catch{I.FS.mkdir(H)}const B=`${c.format}`,Q=H+"/"+p.name;I.FS.writeFile(Q,p.byteArray);const q=new I.IntVec;q.push_back(c.owidth),q.push_back(c.oheight);const T=new I.IntVec;T.push_back(m),T.push_back(y);const j=new I.IntVec;j.push_back(K),j.push_back(v),console.debug(Q,B,c.orientations,[c.owidth,c.oheight],[m,y],[K,v],c.format,c.animFramesLimit,s);let te=0;return t==="image"?te=I.convert_image_ext(Q,B,c.orientations,q,T,j,c.format,s,new I.U8Vec):te=I.convert_video_ext(Q,B,c.orientations,q,T,j,c.format,c.animFramesLimit,s,new I.U8Vec),I.FS.unlink(Q),te===0?I.FS.readFile(B):null};return jsxs(Fragment,{children:[jsx(MediaRow,{children:jsxs(MediaContainer$1,{$width:m,$height:y,children:[jsx(Media,{type:p==null?void 0:p.type,src:p==null?void 0:p.src,width:m,height:y}),jsx(Draggable,{position:{x:K,y:v},onStop:V,bounds:b,children:jsx(Dragger$1,{children:p&&jsx("canvas",{ref:$,width:c.owidth,height:c.oheight})})})]})}),jsxs(ControlRow,{children:[jsxs(Label$1,{children:[e("File"),"๏ผ",p==null?void 0:p.name]}),jsxs(Detail,{children:[jsx(AccentButton,{onClick:O,children:e("Import "+(t==="video"?"Video":"Image"))}),jsx(HiddenInput$1,{accept:R,onChange:F,type:"file",ref:f})]})]}),jsx(ControlRow,{children:jsxs(Label$1,{children:[e("Original Size"),": ",(p==null?void 0:p.width)||0," x ",(p==null?void 0:p.height)||0]})}),jsx(FileSaveControl,{area:c,setArea:d,generate:L,disabled:!p,wasmLoaded:k})]})},shallowEqual),Slider=styled.div.attrs(e=>({style:{width:e.$width,height:e.$height}}))`
|
|
1299
|
+
position: relative;
|
|
1300
|
+
overflow: hidden;
|
|
1301
|
+
`,upAnima=keyframes`
|
|
1302
|
+
0% {
|
|
1303
|
+
transform: translateY(0);
|
|
1304
|
+
}
|
|
1305
|
+
100% {
|
|
1306
|
+
transform: translateY(-100%);
|
|
1307
|
+
}
|
|
1308
|
+
`,downAnim=keyframes`
|
|
1309
|
+
0% {
|
|
1310
|
+
transform: translateY(0);
|
|
1311
|
+
}
|
|
1312
|
+
100% {
|
|
1313
|
+
transform: translateY(100%);
|
|
1314
|
+
}
|
|
1315
|
+
`,leftAnim=keyframes`
|
|
1316
|
+
0% {
|
|
1317
|
+
transform: translateX(0);
|
|
1318
|
+
}
|
|
1319
|
+
100% {
|
|
1320
|
+
transform: translateX(-100%);
|
|
1321
|
+
}
|
|
1322
|
+
`,rightAnim=keyframes`
|
|
1323
|
+
0% {
|
|
1324
|
+
transform: translateX(0);
|
|
1325
|
+
}
|
|
1326
|
+
100% {
|
|
1327
|
+
transform: translateX(100%);
|
|
1328
|
+
}
|
|
1329
|
+
`,SliderImage=styled.img.attrs(e=>{let t="0",r="0";if(e.$isNext)switch(e.$anim){case 3:r="100%";break;case 2:r="-100%";break;case 5:t="100%";break;case 4:t="-100%";break}return{style:{width:e.$width,height:e.$height,left:t,top:r,zIndex:e.$anim!==1||e.$isNext?0:1}}})`
|
|
1330
|
+
background: #000;
|
|
1331
|
+
object-fit: cover;
|
|
1332
|
+
position: absolute;
|
|
1333
|
+
animation-name: ${e=>{if(!e.$isNext)return"";switch(e.$anim){case 3:return upAnima;case 2:return downAnim;case 5:return leftAnim;case 4:return rightAnim;default:return""}}};
|
|
1334
|
+
animation-delay: ${e=>(e.$interval||1)-.3}s;
|
|
1335
|
+
animation-duration: 0.3s;
|
|
1336
|
+
animation-fill-mode: forwards;
|
|
1337
|
+
animation-timing-function: linear;
|
|
1338
|
+
pointer-events: none;
|
|
1339
|
+
`,SliderTool=()=>{var z,X;const{t:e,i18n:t}=useTranslation(),r=useAppSelector(getDefaultArea),s=useAppSelector(getKbresFlags);if(!r)return null;const a=reactExports.useMemo(()=>[5,10,15,30].map(L=>({label:L+" "+e("S"),value:L})),[t.language]),l=reactExports.useMemo(()=>[{label:e("None"),value:1},{label:e("Top to bottom"),value:2},{label:e("Bottom to top"),value:3},{label:e("Left to right"),value:4},{label:e("Right to left"),value:5}],[t.language]),[c,d]=reactExports.useState(r),p=reactExports.useRef(null),[f,m]=reactExports.useState([]),[y,K]=reactExports.useState(0),x=f.length<=1||y===f.length-1?0:y+1,[v,M]=reactExports.useState(a[0].value),[b,R]=reactExports.useState(l[0].value),O=reactExports.useRef(null),{kbres:I,loaded:k}=useKbres(),F=()=>{var L;(L=p.current)==null||L.click()},V=async L=>{if(L.target.files){const H=Array.from(L.target.files).filter(Q=>["image/jpeg","image/png","image/bmp"].includes(Q.type)),B=lodashExports.sortBy(await getScreenFiles(H),[Q=>Q.name]);m(B),K(0)}};reactExports.useEffect(()=>{p.current!==null&&(p.current.setAttribute("directory",""),p.current.setAttribute("webkitdirectory",""))},[p]),reactExports.useEffect(()=>{if(f.length!==0)return O.current=setInterval(()=>{K(L=>L===f.length-1?0:L+1)},v*1e3),()=>{O.current&&(clearInterval(O.current),K(0))}},[c,b,v,f]);const $=()=>{if(!I)return null;const L="/tabkb";try{I.FS.stat(L)}catch{I.FS.mkdir(L)}const H=c.format,B=c.format,Q=new I.StrVec;for(const j of f)I.FS.writeFile(L+"/"+j.name,j.byteArray),Q.push_back(L+"/"+j.name);const q=new I.IntVec;q.push_back(c.owidth),q.push_back(c.oheight),console.debug(L,H,c.orientations,v,b,[c.owidth,c.oheight],B,s);const T=I.convert_image_folder_ext(Q,H,c.orientations,v,b,q,B,s);for(let j=0;j<Q.size();j++){const te=Q.get(j);I.FS.unlink(te)}return T===0?I.FS.readFile(H):null};return jsxs(Fragment,{children:[jsx(MediaRow,{children:jsxs(Slider,{$width:c.owidth,$height:c.oheight,children:[f.length>0&&jsx(SliderImage,{$interval:v,$anim:b,src:(z=f[y])==null?void 0:z.src,$width:c.owidth,$height:c.oheight}),f.length>1&&jsx(SliderImage,{$interval:v,$anim:b,$isNext:!0,src:(X=f[x])==null?void 0:X.src,$width:c.owidth,$height:c.oheight})]},y)}),jsxs(ControlRow,{children:[jsxs(Label$1,{children:[e("image"),": ",f.length===0?0:y+1," / ",f.length," ",f.length===0?"":`( ${f[y].name} )`]}),jsxs(Detail,{children:[jsx(AccentButton,{onClick:F,children:e("Import From Album")}),jsx(HiddenInput$1,{onChange:V,type:"file",ref:p})]})]}),jsxs(ControlRow,{children:[jsxs(Label$1,{children:[e("Interval"),": "]}),jsx(Detail,{children:jsx(AccentSelect,{onChange:L=>M(L.value),value:a.find(L=>L.value===v),options:a})})]}),jsxs(ControlRow,{children:[jsxs(Label$1,{children:[e("Transition Animation"),": "]}),jsx(Detail,{children:jsx(AccentSelect,{onChange:L=>R(L.value),value:l.find(L=>L.value===b),options:l})})]}),jsx(FileSaveControl,{area:c,setArea:d,generate:$,disabled:f.length===0,wasmLoaded:k})]})},Container$e=styled.div`
|
|
1340
|
+
position: absolute;
|
|
1341
|
+
z-index: 3;
|
|
1342
|
+
`,MediaResizer=({file:e,x:t,y:r,width:s,height:a,onChange:l})=>{const c=reactExports.useRef(null),d=reactExports.useRef(0),p=()=>{if(!c.current){d.current=0;return}const I=c.current,k=I.getContext("2d");k.clearRect(0,0,I.width,I.height);const F=5;k.setLineDash([F,F]),k.lineDashOffset=d.current,k.strokeStyle="white",k.beginPath(),k.rect(0,0,I.width,I.height),k.stroke(),k.lineDashOffset=d.current+F,k.strokeStyle="black",k.beginPath(),k.rect(0,0,I.width,I.height),k.stroke(),d.current+=3,setTimeout(p,200)},f=e.dw/e.dh,[m,y]=reactExports.useState(null),[K,x]=reactExports.useState(null),v=[{name:"bottom-right",style:{right:-5,bottom:-5,cursor:"nwse-resize"}}],M=I=>{y({x:I.clientX,y:I.clientY}),x(null)},b=()=>{y(null),x(null)},R=(I,k)=>{k.stopPropagation(),x({x:k.clientX,y:k.clientY,point:I})},O=I=>{if(m){const k=e.dx+(I.clientX-m.x),F=e.dy+(I.clientY-m.y),V=Math.max(Math.min(k,s-e.dw),0),$=Math.max(Math.min(F,a-e.dh),0);l({dw:e.dw,dh:e.dh,dx:V,dy:$})}if(K){const k=I.clientX-K.x,F=K.point==="top-left"||K.point==="bottom-left"?-k:k,V=e.dw+F;let $=Math.max(Math.min(V,s-e.dx),10),z=Math.max(Math.min($/f,a-e.dy),10);$=z*f,l({dx:e.dx,dy:e.dy,dw:$,dh:z})}};return reactExports.useEffect(()=>(window.addEventListener("mousemove",O),window.addEventListener("mouseup",b),()=>{window.removeEventListener("mousemove",O),window.removeEventListener("mouseup",b)}),[m,K]),reactExports.useEffect(()=>{d.current===0&&p()},[]),jsxs(Container$e,{style:{top:r+e.dy,left:t+e.dx,cursor:m?"grabbing":"grab",width:e.dw,height:e.dh},onMouseDown:M,children:[jsx(Media,{type:e.type,src:e.src,width:e.dw,height:e.dh}),jsx("canvas",{style:{position:"absolute",left:0,top:0},ref:c,width:e.dw,height:e.dh}),v.map(I=>jsx("div",{onMouseDown:k=>R(I.name,k),style:{position:"absolute",width:"10px",height:"10px",border:"1px solid #fff",...I.style}},I.name))]})},MediaContainer=styled.div.attrs(({$width:e,$height:t})=>({style:{width:e,height:t,display:e>0&&t>0?"block":"none"}}))`
|
|
1343
|
+
position: relative;
|
|
1344
|
+
`,Dragger=styled.div`
|
|
1345
|
+
top: 0;
|
|
1346
|
+
left: 0;
|
|
1347
|
+
position: absolute;
|
|
1348
|
+
cursor: move;
|
|
1349
|
+
cursor: grab;
|
|
1350
|
+
transition: all 0.3s;
|
|
1351
|
+
z-index: 1;
|
|
1352
|
+
&.react-draggable-dragging {
|
|
1353
|
+
transition: none;
|
|
1354
|
+
cursor: grabbing;
|
|
1355
|
+
}
|
|
1356
|
+
`,FgFileList=styled.div`
|
|
1357
|
+
margin-top: 10px;
|
|
1358
|
+
display: flex;
|
|
1359
|
+
column-gap: 5px;
|
|
1360
|
+
flex-wrap: wrap;
|
|
1361
|
+
`,FgMedia=styled.div`
|
|
1362
|
+
border: ${e=>e.$active?"1px solid var(--color_accent)":"1px solid rgba(0,0,0,0)"};
|
|
1363
|
+
|
|
1364
|
+
cursor: pointer;
|
|
1365
|
+
width: fit-content;
|
|
1366
|
+
height: fit-content;
|
|
1367
|
+
position: relative;
|
|
1368
|
+
svg {
|
|
1369
|
+
color: var(--bg_icon-highlighted);
|
|
1370
|
+
position: absolute;
|
|
1371
|
+
right: -6px;
|
|
1372
|
+
top: -6px;
|
|
1373
|
+
opacity: 0;
|
|
1374
|
+
cursor: pointer;
|
|
1375
|
+
transition: transform 0.2s ease-in-out;
|
|
1376
|
+
background: var(--bg_icon);
|
|
1377
|
+
border-radius: 50%;
|
|
1378
|
+
transform: scale(0.8);
|
|
1379
|
+
}
|
|
1380
|
+
&:hover svg {
|
|
1381
|
+
opacity: 1;
|
|
1382
|
+
transform: scale(1);
|
|
1383
|
+
}
|
|
1384
|
+
`;function calculateDestDimensions(e,t,r,s){const a=r/e,l=s/t,c=Math.min(a,l),d=e*c/2,p=t*c/2,f=(r-d)/2,m=(s-p)/2;return{dx:f,dy:m,dw:d,dh:p}}const isVideo=e=>e.type==="video/mp4"||e.type==="image/gif",hasAlpha=e=>e.type==="image/png"||e.type==="image/gif",getDimension=(e,t)=>{if(e&&t){const[r,s]=[t.width,t.height],[a,l]=[e.owidth,e.oheight],c=r/s,d=a/l;return c>d?[~~(c*l),l]:[a,~~(a/c)]}return[0,0]},ThemeTool=reactExports.memo(()=>{const{t:e}=useTranslation(),t=useAppSelector(getKbresFlags),r=useAppSelector(getMaxOutputSize),s=useAppSelector(getMaxFgFileCount),a=useAppSelector(getExportOptions),l=a==null?void 0:a.find(ne=>ne.format===ATBG),c=a==null?void 0:a.find(ne=>ne.format===ATFG);if(!l)return null;const d=l,[p,f]=reactExports.useState(),m=reactExports.useRef(null),[y,K]=reactExports.useState([]),x=reactExports.useRef(null),[v,M]=reactExports.useState(0),b=y[v],[R,O]=getDimension(d,p),[I,k]=reactExports.useState(Math.floor((R-d.owidth)/2)),[F,V]=reactExports.useState(Math.floor((O-d.oheight)/2)),$={left:0,top:0,right:R-d.owidth,bottom:O-d.oheight},z="image/gif,video/mp4",X="image/gif,video/mp4,image/jpeg,image/png,image/bmp",L=()=>{var ne;(ne=m.current)==null||ne.click()},H=()=>{var ne;(ne=x.current)==null||ne.click()},{kbres:B,loaded:Q}=useKbres(),[q,T]=reactExports.useState(0),j=reactExports.useMemo(()=>y.reduce((ne,se)=>ne+se.outputSize,0)+q,[q,y]),te=(ne,se,Me,ge)=>{if(!B)return{size:0,alpha:0,frames:0};const ue="/tabkb";try{B.FS.stat(ue)}catch{B.FS.mkdir(ue)}const me=`info_${d.format}`,ke=ue+"/info_"+ne.name;B.FS.writeFile(ke,ne.byteArray);const Ne=new B.IntVec;Ne.push_back(se[0]),Ne.push_back(se[1]),ge|=KBRE_FLAGS_REFPS;const Te=B.media_info(ke,me,isVideo(ne)?1:0,Ne,Me,ge),pe=new TextDecoder().decode(B.FS.readFile(me)).trim().split(" ");return B.FS.unlink(ke),{size:Te,alpha:parseInt(pe[0]),frames:parseInt(pe[1])}},re=async ne=>{if(ne.target.files){const se=await getScreenFiles(Array.from(ne.target.files)),{size:Me}=te(se[0],[d.owidth,d.oheight],d.animFramesLimit,t);T(Me),f(se[0])}},de=async ne=>{if(ne.target.files){const Me=(await getScreenFiles(Array.from(ne.target.files))).map(ge=>{const ue=calculateDestDimensions(ge.width,ge.height,d.owidth,d.oheight);let me=t;hasAlpha(ge)&&(me|=KBRE_FLAGS_ALPHA);const{size:ke,frames:Ne,alpha:Te}=te(ge,[ue.dw,ue.dh],(c==null?void 0:c.animFramesLimit)||-1,me);return{...ge,...ue,animation:ThemeAnim.ANIM_NONE,outputSize:ke,frames:Ne,alpha:Te}});if(Me.length>0){const ge=[...y,...Me].slice(0,s);K(ge),M(y.length)}}},fe=(ne,se)=>{k(se.x),V(se.y)},Ee=reactExports.useRef(null),$e=reactExports.useRef(0),Qe=()=>{if(!Ee.current){$e.current=0;return}const ne=Ee.current,se=ne.getContext("2d");se.clearRect(0,0,ne.width,ne.height);const Me=5;se.setLineDash([Me,Me]),se.lineDashOffset=$e.current,se.strokeStyle="white",se.beginPath(),se.rect(0,0,ne.width,ne.height),se.stroke(),se.lineDashOffset=$e.current+Me,se.strokeStyle="black",se.beginPath(),se.rect(0,0,ne.width,ne.height),se.stroke(),$e.current+=3,setTimeout(Qe,200)};reactExports.useEffect(()=>{setTimeout(()=>{k(Math.floor((R-d.owidth)/2)),V(Math.floor((O-d.oheight)/2)),$e.current===0&&Qe()},0)},[d,R,O]);const Xe=()=>{if(!B||!p)return null;let ne=t|KBRE_FLAGS_REFPS;const se="/tabkb";try{B.FS.stat(se)}catch{B.FS.mkdir(se)}let Me=[];const ge=`${d.format}`,ue=se+"/"+p.name;B.FS.writeFile(ue,p.byteArray);const me=new B.IntVec;me.push_back(d.owidth),me.push_back(d.oheight);const ke=new B.IntVec;ke.push_back(R),ke.push_back(O);const Ne=new B.IntVec;Ne.push_back(I),Ne.push_back(F);const Te=new B.U8Vec;Te.push_back(y.length);for(let pe=0;pe<y.length;pe++){const be=y[pe];Te.push_back(be.dw&255),Te.push_back(be.dw>>8),Te.push_back(be.dh&255),Te.push_back(be.dh>>8),Te.push_back(be.alpha),Te.push_back(0),Te.push_back(be.frames&255),Te.push_back(be.frames>>8)}console.debug(ue,ge,d.orientations,[me.get(0),me.get(1)],[ke.get(0),ke.get(1)],[Ne.get(0),Ne.get(1)],d.format,d.animFramesLimit,ne);let Ve=0;if(Ve=B.convert_video_extf(ue,ge,d.orientations,me,ke,Ne,d.format,d.animFramesLimit,ne,Te),B.FS.unlink(ue),Ve!==0)return null;if(Me=[B.FS.readFile(ge)],c&&y.length>0)for(let pe=0;pe<y.length;pe++){const be=y[pe],it=`${c.format}`,He=se+"/"+be.name;let Ce=ne;hasAlpha(be)&&(Ce|=KBRE_FLAGS_ALPHA),B.FS.writeFile(He,be.byteArray);const Be=new B.IntVec;Be.push_back(~~be.dw),Be.push_back(~~be.dh);const Je=new B.IntVec;Je.push_back(~~be.dw),Je.push_back(~~be.dh);const Ze=new B.IntVec;Ze.push_back(0),Ze.push_back(0);const Fe=new B.U8Vec;Fe.push_back(be.dx&255),Fe.push_back(be.dx>>8),Fe.push_back(be.dy&255),Fe.push_back(be.dy>>8),Fe.push_back(be.animation&255),Fe.push_back(be.animation>>8),console.debug(He,it,c.orientations,[Be.get(0),Be.get(1)],[Je.get(0),Je.get(1)],[Ze.get(0),Ze.get(1)],c.format,c.animFramesLimit,Ce,[Fe.get(0),Fe.get(1),Fe.get(2),Fe.get(3),Fe.get(4),Fe.get(5)]);let ht=0;if(isVideo(be)?ht=B.convert_video_extf(He,it,c.orientations,Be,Je,Ze,c.format,c.animFramesLimit,Ce,Fe):ht=B.convert_image_ext(He,it,c.orientations,Be,Je,Ze,c.format,Ce,Fe),B.FS.unlink(He),ht!==0)return null;const Lt=B.FS.readFile(it);Me.push(Lt)}return Me},_e=ne=>{K(y.map((se,Me)=>{if(Me!==v)return se;let ge=se.outputSize;if(se.dh!==ne.dh||se.dw!=ne.dw){let ue=t;hasAlpha(se)&&(ue|=KBRE_FLAGS_ALPHA);const{size:me}=te(se,[ne.dw,ne.dh],(c==null?void 0:c.animFramesLimit)||-1,ue);ge=me}return{...se,...ne,outputSize:ge}}))},Pe=[{label:e("None"),value:ThemeAnim.ANIM_NONE},{label:e("Anim A"),value:ThemeAnim.ANIM_A},{label:e("Anim B"),value:ThemeAnim.ANIM_B}],ot=Pe.find(ne=>{var se;return ne.value===((se=y[v])==null?void 0:se.animation)})||Pe[0],qe=ne=>{K(y.map((se,Me)=>Me!==v?se:{...se,animation:ne}))};return jsxs(Fragment,{children:[jsxs(MediaRow,{children:[jsxs(MediaContainer,{$width:R,$height:O,children:[p&&jsx(Media,{type:p==null?void 0:p.type,src:p==null?void 0:p.src,width:R,height:O}),jsx(Draggable,{position:{x:I,y:F},onStop:fe,bounds:$,children:jsx(Dragger,{children:p&&jsx("canvas",{ref:Ee,width:d.owidth,height:d.oheight})})}),p&&b&&jsx(MediaResizer,{file:b,x:I,y:F,width:d.owidth,height:d.oheight,onChange:_e})]}),jsx(FgFileList,{children:y.map((ne,se)=>jsxs(FgMedia,{$active:v===se,onClick:()=>M(se),children:[jsx(Media,{type:ne.type,src:ne.src,width:"auto",height:60}),jsx(FontAwesomeIcon,{icon:faXmarkCircle,size:"lg",onClick:Me=>{Me.stopPropagation(),K(ue=>ue.filter((me,ke)=>se!==ke));const ge=v>=se?v===0?0:v-1:v;M(ge)}})]},se))})]}),jsxs(ControlRow,{children:[jsx(Label$1,{children:e("Background")}),jsxs(Detail,{children:[jsx(AccentButton,{onClick:L,disabled:!Q,children:e("Import Background")}),jsx(HiddenInput$1,{accept:z,onChange:re,type:"file",ref:m})]})]}),c&&jsxs(Fragment,{children:[jsxs(ControlRow,{children:[jsx(Label$1,{children:e("Foreground")}),jsxs(Detail,{children:[jsx(AccentButton,{onClick:H,disabled:!Q||y.length>=s,children:e("Import Foreground")}),jsx(HiddenInput$1,{multiple:!0,accept:X,onChange:de,type:"file",ref:x})]})]}),y.length>0&&jsxs(ControlRow,{children:[jsx(Label$1,{children:e("Foreground Animation")}),jsx(Detail,{children:jsx(AccentSelect,{onChange:ne=>{qe(ne.value)},value:ot,options:Pe})})]})]}),jsxs(ControlRow,{children:[jsx(FlexLabel,{children:jsx("span",{style:{marginLeft:10,fontSize:16,color:j>r?"#d15e5e":"inherit"},children:printBytesUsed(j,r)})}),jsx(Detail,{})]}),jsx(FileSaveControl,{generate:Xe,disabled:!p||j>r,wasmLoaded:Q})]})},shallowEqual),CHANEL=66,CMD1=20,CMD2=21,PickerContainer=styled.div`
|
|
1385
|
+
display: flex;
|
|
1386
|
+
align-items: center;
|
|
1387
|
+
`,ColorPreview=styled.div`
|
|
1388
|
+
width: 20px;
|
|
1389
|
+
height: 20px;
|
|
1390
|
+
border-radius: 20px;
|
|
1391
|
+
background: ${e=>`rgb(${e.$color.r},${e.$color.g},${e.$color.b})`};
|
|
1392
|
+
border: 1px solid var(--color_accent);
|
|
1393
|
+
cursor: pointer;
|
|
1394
|
+
margin-left: 5px;
|
|
1395
|
+
`,ColorPicker=styled(SketchPicker)`
|
|
1396
|
+
line-height: 1;
|
|
1397
|
+
input {
|
|
1398
|
+
color: var(--color_accent);
|
|
1399
|
+
background: none;
|
|
1400
|
+
border: none !important;
|
|
1401
|
+
border-bottom: 1px solid var(--color_accent) !important;
|
|
1402
|
+
box-shadow: none !important;
|
|
1403
|
+
text-align: center;
|
|
1404
|
+
}
|
|
1405
|
+
label {
|
|
1406
|
+
color: var(--color_accent) !important;
|
|
1407
|
+
}
|
|
1408
|
+
.flexbox-fix {
|
|
1409
|
+
border: none !important;
|
|
1410
|
+
}
|
|
1411
|
+
position: absolute;
|
|
1412
|
+
transform: translate3d(14px, -22px, 0);
|
|
1413
|
+
z-index: 1;
|
|
1414
|
+
&::after {
|
|
1415
|
+
content: '';
|
|
1416
|
+
position: absolute;
|
|
1417
|
+
width: 0px;
|
|
1418
|
+
height: 0px;
|
|
1419
|
+
border: 11px solid var(--border_color_cell);
|
|
1420
|
+
border-top-color: transparent;
|
|
1421
|
+
border-bottom-color: transparent;
|
|
1422
|
+
border-left-color: transparent;
|
|
1423
|
+
top: 12px;
|
|
1424
|
+
left: -22px;
|
|
1425
|
+
pointer-events: none;
|
|
1426
|
+
}
|
|
1427
|
+
`,Picker=e=>{const t={default:{picker:{background:"var(--border_color_cell)"}}},r=reactExports.useRef(null),s=reactExports.useRef(null),{color:a,onChange:l}=e,[c,d]=reactExports.useState(!1),p=m=>{!c||!r.current||!s.current||m.target!==s.current&&!r.current.contains(m.target)&&d(!1)};return reactExports.useEffect(()=>(document.addEventListener("click",p),()=>{document.removeEventListener("click",p)}),[c]),jsxs(PickerContainer,{children:[jsx(ColorPreview,{ref:s,onClick:()=>d(!0),$color:a}),c&&jsx("div",{ref:r,children:jsx(ColorPicker,{styles:t,disableAlpha:!0,presetColors:["#000","#fff","#f00","#0f0","#00f","#ff0","#f0f","#0ff"],color:a,onChange:m=>{l(m.rgb)}})})]})},ThemeColorTool=reactExports.memo(()=>{const{t:e}=useTranslation(),t=useAppSelector(getSelectedKeyboardAPI),[r,s]=reactExports.useState({r:0,g:0,b:0}),[a,l]=reactExports.useState({r:0,g:0,b:0}),c=async()=>{if(!t)return;const[,f,m,y]=await t.getCustomMenuValue([CHANEL,CMD1]),[,K,x,v]=await t.getCustomMenuValue([CHANEL,CMD2]);s({r:f,g:m,b:y}),l({r:K,g:x,b:v})},d=f=>{t&&(t.setCustomMenuValue(CHANEL,CMD1,f.r,f.g,f.b),s(f))},p=f=>{t&&(t.setCustomMenuValue(CHANEL,CMD2,f.r,f.g,f.b),l(f))};return reactExports.useEffect(()=>{t&&c()},[t]),t?jsxs(Fragment,{children:[jsxs(ControlRow,{children:[jsxs(Label$1,{children:[e("Color")," 1"]}),jsx(Detail,{children:jsx(Picker,{color:r,onChange:f=>{d(f)}})})]}),jsxs(ControlRow,{children:[jsxs(Label$1,{children:[e("Color")," 2"]}),jsx(Detail,{children:jsx(Picker,{color:a,onChange:f=>{p(f)}})})]})]}):jsx(Fragment,{})},shallowEqual),title$1="Screen",ScreenPane=styled(CenterPane)`
|
|
1428
|
+
height: 100%;
|
|
1429
|
+
`,MenuContainer$1=styled.div`
|
|
1430
|
+
padding: 15px 10px 20px 10px;
|
|
1431
|
+
pointer-events: ${e=>e.$disabled?"none":"auto"};
|
|
1432
|
+
`,Container$d=styled.div`
|
|
1433
|
+
display: flex;
|
|
1434
|
+
align-items: center;
|
|
1435
|
+
flex-direction: column;
|
|
1436
|
+
padding: 12px;
|
|
1437
|
+
`,Media=reactExports.memo(({type:e,src:t,width:r,height:s})=>jsxs("div",{style:{pointerEvents:"none",lineHeight:0},children:[(e==null?void 0:e.startsWith("image"))&&jsx("img",{src:t,style:{width:r,height:s}}),(e==null?void 0:e.startsWith("video"))&&jsx("video",{style:{width:r,height:s},muted:!0,autoPlay:!0,loop:!0,src:t})]}),shallowEqual),Pane$1=()=>{const{t:e}=useTranslation(),t=useDispatch(),r=useAppSelector(getSelectedTool),s=useAppSelector(getSavingState$2),a=useAppSelector(getScreenMenus),l=useAppSelector(getDeviceConfig),c=a.map(p=>jsx(SubmenuRow,{$selected:r===p,onClick:()=>t(updateTool(p)),style:{borderWidth:0,textAlign:"center"},children:e(p)},p));return jsxs(Fragment,{children:[jsx(SubmenuOverflowCell,{children:jsx(MenuContainer$1,{$disabled:s==="saving",children:c})}),jsx(OverflowCell,{children:jsx(ScreenPane,{children:jsx(Container$d,{children:(()=>{if(!l)return jsx(Fragment,{});switch(r){case"video":return jsx(CropTool,{},"video");case"image":return jsx(CropTool,{},"image");case"slider":return jsx(SliderTool,{},"slider");case"theme":return jsx(ThemeTool,{},"theme");case"theme-color":return jsx(ThemeColorTool,{},"theme-color")}})()})})})]})},Icon$1=()=>jsx("svg",{viewBox:"1 1 22 22",fill:"currentColor",children:jsx("path",{d:"M6.25,4 L17.75,4 C19.4830315,4 20.8992459,5.35645477 20.9948552,7.06557609 L21,7.25 L21,16.75 C21,18.4830315 19.6435452,19.8992459 17.9344239,19.9948552 L17.75,20 L6.25,20 C4.51696854,20 3.10075407,18.6435452 3.00514479,16.9344239 L3,16.75 L3,7.25 C3,5.51696854 4.35645477,4.10075407 6.06557609,4.00514479 L6.25,4 L17.75,4 L6.25,4 Z M17.75,5.5 L6.25,5.5 C5.3318266,5.5 4.57880766,6.20711027 4.5058012,7.10647279 L4.5,7.25 L4.5,16.75 C4.5,17.6681734 5.20711027,18.4211923 6.10647279,18.4941988 L6.25,18.5 L17.75,18.5 C18.6681734,18.5 19.4211923,17.7928897 19.4941988,16.8935272 L19.5,16.75 L19.5,7.25 C19.5,6.3318266 18.7928897,5.57880766 17.8935272,5.5058012 L17.75,5.5 Z M10.0527864,9.5854102 C10.1625594,9.3658642 10.4120593,9.26236922 10.639617,9.328815 L10.7236068,9.3618034 L15.1055728,11.5527864 C15.2023365,11.6011683 15.2807978,11.6796295 15.3291796,11.7763932 C15.4389526,11.9959392 15.3720486,12.2576361 15.1823574,12.3998148 L15.1055728,12.4472136 L10.7236068,14.6381966 C10.6541791,14.6729105 10.5776225,14.690983 10.5,14.690983 C10.2545401,14.690983 10.0503916,14.5141078 10.0080557,14.2808586 L10,14.190983 L10,9.80901699 C10,9.73139445 10.0180725,9.65483791 10.0527864,9.5854102 Z"})}),Title$3=title$1,Screen=Object.freeze(Object.defineProperty({__proto__:null,Icon:Icon$1,Media,Pane:Pane$1,Title:Title$3},Symbol.toStringTag,{value:"Module"})),FirmwarePane=styled(CenterPane)`
|
|
1438
|
+
grid-column: span 2;
|
|
1439
|
+
`,Container$c=styled.div`
|
|
1440
|
+
display: flex;
|
|
1441
|
+
align-items: center;
|
|
1442
|
+
flex-direction: column;
|
|
1443
|
+
padding: 0 12px;
|
|
1444
|
+
`,HiddenInput=styled.input`
|
|
1445
|
+
display: none;
|
|
1446
|
+
`;styled.div`
|
|
1447
|
+
position: absolute;
|
|
1448
|
+
background: rgb(220 53 69);
|
|
1449
|
+
padding: 3px;
|
|
1450
|
+
border-radius: 50%;
|
|
1451
|
+
right: 0;
|
|
1452
|
+
top: 0;
|
|
1453
|
+
`;const TextBadge=styled.span`
|
|
1454
|
+
position: absolute;
|
|
1455
|
+
top: -4px;
|
|
1456
|
+
right: -4px;
|
|
1457
|
+
display: inline-block;
|
|
1458
|
+
background: rgb(220 53 69);
|
|
1459
|
+
line-height: 1em;
|
|
1460
|
+
color: #fff;
|
|
1461
|
+
font-size: 12px;
|
|
1462
|
+
margin-left: 6px;
|
|
1463
|
+
padding: 3px;
|
|
1464
|
+
vertical-align: middle;
|
|
1465
|
+
border-radius: 5px;
|
|
1466
|
+
`,Notice=styled(Label$1)`
|
|
1467
|
+
color: var(--color_accent);
|
|
1468
|
+
font-size: 16px;
|
|
1469
|
+
`,Pane=()=>{const{t:e}=useTranslation(),t=useAppDispatch(),r=useAppSelector(getSavingState$1),s=useAppSelector(getBufferSize$1),a=useAppSelector(getBytesSended$1),l=useAppSelector(getSendSpeed$1),c=useAppSelector(getFirmwareNeedUpdate),d=useAppSelector(getSelectedDeviceFirmwareVersion);useAppSelector(getCfgFirmwareVersion);const p=useAppSelector(getCfgFirmwareFile),f=useAppSelector(getSelectedConnectedDevice),m=useAppSelector(getSelectedKeyboardAPI),[y,K]=reactExports.useState([]),x=useAppSelector(getCDCMacIssue),v=useAppSelector(getCfgFirmwareBoot),M=useAppSelector(getFirmwareOptions);reactExports.useState(null);const[b,R]=reactExports.useState(),O=reactExports.useRef(null),I=()=>{var T;(T=O.current)==null||T.click()},k=async T=>{var j;if((j=T.target.files)!=null&&j[0]){const te=T.target.files[0],re=te.name,de=await te.arrayBuffer(),fe=new Uint8Array(de);R({name:re,byteArray:fe}),t(updateState$1("waiting"))}else R(null)},F=()=>{f&&t(setFirmwareOptions({vidPid:[f.vendorId,f.productId],files:p,bootVidPid:v,needUpdate:c}))},V=()=>{f&&t(setFirmwareOptions({vidPid:[f.vendorId,f.productId],files:[],bootVidPid:v,needUpdate:!1}))},$=()=>{b&&t(saveTabFirmware$1(b.byteArray))},z=async()=>{if(!m)return;const T=re=>`${re>>8&255}.${re>>4&15}.${re&15}`,j=(await m.getCustomMenuValue([66,100])).slice(1),te=j[0];if(te){const re=[];for(let de=0;de<te;de++){const fe=bytesIntoNum(j.slice(1+de*4,5+de*4));re.push(T(fe))}K(re)}};reactExports.useEffect(()=>{z()},[]);const X=reactExports.useMemo(()=>{switch(y.length){case 3:return` (Host: v${y[0]} Left: v${y[1]} Right: v${y[2]})`;case 1:return` (PLC: v${y[0]})`;default:return""}},[y]),L=f&&f.vendorId===20311&&f.productId===16656&&f.firmware>=parseVersionStr("1.0.5"),B=navigator.userAgent.includes("Mac")&&x&&!L,q=f&&f.vendorId===58720&&f.productId===57604;return jsx(FirmwarePane,{children:jsxs(Container$c,{children:[d&&jsx(ControlRow,{children:jsxs(Label$1,{children:[e("Current Version"),": v",d," ",jsx("span",{style:{fontSize:14},children:X})]})}),B?jsx(ControlRow,{children:jsx(Label$1,{style:{fontSize:16},children:e("FIRMWARE_MAC_NOTSUPPORT")})}):jsxs(Fragment,{children:[p.length>0&&jsxs(ControlRow,{children:[jsx(Label$1,{children:e("Online Upgrade")}),jsx(Detail,{children:jsxs(AccentButton,{onClick:F,disabled:r==="saving",children:[c&&jsx(Fragment,{children:jsx(TextBadge,{})}),e("Check for Updates")]})})]}),v?jsxs(ControlRow,{children:[jsx(Label$1,{children:e("Local Upgrade")}),jsx(Detail,{children:jsx(AccentButton,{onClick:V,disabled:r==="saving",children:e("Firmware")})})]}):jsxs(Fragment,{children:[jsxs(ControlRow,{children:[jsxs(Label$1,{children:[e("Firmware"),"๏ผ",b==null?void 0:b.name]}),jsxs(Detail,{children:[jsx(AccentButton,{disabled:r==="saving",onClick:I,children:e("Open")}),jsx(HiddenInput,{accept:".uf2",onChange:k,type:"file",ref:O})]})]}),jsxs(ControlRow,{children:[jsxs(FlexLabel,{children:[r==="failed"&&jsxs(Fragment,{children:[jsx(FontAwesomeIcon,{icon:faWarning,size:"xs",style:{color:"gold",marginRight:5}}),e("Failed to flash.")]}),r==="completed"&&e("Flash successful.")," ",r==="saving"&&!M&&jsx(SavingProgress,{bufferSize:s,sendSpeed:l,bytesSended:a})]}),jsx(Detail,{children:jsx(AccentButton,{onClick:$,disabled:!b||r==="saving",children:e("Flash")})})]})]}),jsx(ControlRow,{children:jsx(Notice,{style:{fontSize:16},children:e("FIRMWARE_TRANS_NOTICE")})}),jsx(ControlRow,{children:jsx(Notice,{style:{fontSize:16},children:e("Please DO NOT disconnect or switch modes during the upgrade until the keyboard auto-reboot finishes.")})}),q&&jsx(ControlRow,{children:jsx(Notice,{style:{fontSize:16},children:e("FIRMWARE_DUAL_CHIPS")})})]})]})})},Icon=()=>(useAppSelector(getFirmwareNeedUpdate),jsx("div",{style:{position:"relative"},children:jsx(FontAwesomeIcon,{icon:faMicrochip})})),Title$2="Firmware",Firmware$1=Object.freeze(Object.defineProperty({__proto__:null,Icon,Pane,Title:Title$2},Symbol.toStringTag,{value:"Module"})),Container$b=styled.div`
|
|
1470
|
+
position: absolute;
|
|
1471
|
+
left: 15px;
|
|
1472
|
+
font-weight: 400;
|
|
1473
|
+
top: 10px;
|
|
1474
|
+
`,Label=styled.label`
|
|
1475
|
+
font-size: 20px;
|
|
1476
|
+
text-transform: uppercase;
|
|
1477
|
+
color: var(--color_label-highlighted);
|
|
1478
|
+
margin-right: 6px;
|
|
1479
|
+
`,LayerButton=styled.button`
|
|
1480
|
+
outline: none;
|
|
1481
|
+
font-variant-numeric: tabular-nums;
|
|
1482
|
+
border: none;
|
|
1483
|
+
background: ${e=>e.$selected?"var(--color_accent)":"transparent"};
|
|
1484
|
+
color: ${e=>e.$selected?"var(--color_inside-accent)":"var(--color_label-highlighted)"};
|
|
1485
|
+
cursor: pointer;
|
|
1486
|
+
font-size: 20px;
|
|
1487
|
+
font-weight: 400;
|
|
1488
|
+
&:hover {
|
|
1489
|
+
border: none;
|
|
1490
|
+
background: ${e=>e.$selected?"auto":"var(--bg_menu)"};
|
|
1491
|
+
color: ${e=>e.$selected?"auto":"var(--color_label-highlighted)"};
|
|
1492
|
+
}
|
|
1493
|
+
`,LayerControl=()=>{const{t:e}=useTranslation(),t=useDispatch(),r=useAppSelector(getNumberOfLayers),s=useAppSelector(getSelectedLayerIndex),a=reactExports.useMemo(()=>new Array(r).fill(0).map((l,c)=>c).map(l=>jsx(LayerButton,{$selected:l===s,onClick:()=>t(setLayer(l)),children:l},l)),[r,s]);return jsxs(Container$b,{children:[jsx(Label,{children:e("Layer")}),a]})},createRetry=(e,t)=>{const r={retriesLeft:e,timeoutWait:t};return{retry:c=>{r.retriesLeft=r.retriesLeft-1,r.retriesLeft<=0?console.error("Exhausted all retries"):(console.log(`Retrying after waiting ${r.timeoutWait}`),setTimeout(c,r.timeoutWait),r.timeoutWait=r.timeoutWait*2)},clear:()=>{console.log("Clearing retries back to:",e),r.retriesLeft=e,r.timeoutWait=t},retriesLeft:()=>r.retriesLeft>=1}},selectConnectedDeviceRetry=createRetry(8,100),selectConnectedDeviceByPath=e=>async(t,r)=>{await t(reloadConnectedDevices());const s=getConnectedDevices(r())[e];s&&t(selectConnectedDevice(s))},selectConnectedDevice=e=>async t=>{const r=extractDeviceInfo(e);try{t(selectDevice(e)),await t(loadMacros(e)),await t(loadLayoutOptions()),await t(loadMatrixLighintConfig());const{protocol:s}=e;try{s<11?await t(updateLightingData(e)):s>=11&&await t(updateV3MenuData(e))}catch{t(logAppError({message:"Loading lighting/menu data failed",deviceInfo:r}))}await t(loadKeymapFromDevice(e)),selectConnectedDeviceRetry.clear()}catch(s){selectConnectedDeviceRetry.retriesLeft()?(t(logAppError({message:"Loading device failed - retrying",deviceInfo:r})),selectConnectedDeviceRetry.retry(()=>{t(selectConnectedDevice(e))})):(t(logAppError({message:"All retries failed for attempting connection with device",deviceInfo:r})),console.log("Hard resetting device store:",s),t(clearAllDevices()))}},reloadConnectedDevices=()=>async(e,t)=>{const r=t(),s=getSelectedDevicePath(r),a=getForceAuthorize(r),l=getSupportedIds(r),c=r.firmware.options?[]:await getRecognisedDevices(l,a),d=await Promise.all(c.map(M=>new KeyboardAPI(M.path).getProtocolVersion())),p=await Promise.all(c.map(M=>new KeyboardAPI(M.path).getFirmwareVersion())),f=await Promise.all(c.map(M=>new KeyboardAPI(M.path).getCDCSupport())),m=c.filter((M,b)=>d[b]===-1);m.length&&m.forEach(M=>{const b=extractDeviceInfo(M);e(logAppError({message:"Received invalid protocol version from device",deviceInfo:b}))});const y=c.filter((M,b)=>d[b]!==-1).map((M,b)=>{const{path:R,productId:O,vendorId:I,productName:k}=M,F=d[b],V=p[b];return{path:R,productId:O,vendorId:I,protocol:F,firmware:V,productName:k,hasResolvedDefinition:!1,requiredDefinitionVersion:F>=11?"v3":"v2",vendorProductId:getVendorProductId(M.vendorId,M.productId),cdcSupport:f[b]}});await e(reloadDefinitions(y));const K=getDefinitions(t()),x=y.filter((M,b)=>isAuthorizedDeviceConnected(M,K)).reduce((M,b,R)=>(M[b.path]={...b,hasResolvedDefinition:!0},M),{});y.filter(M=>!isAuthorizedDeviceConnected(M,K)).forEach(tryForgetDevice);const v=Object.entries(x);if(v.forEach(([M,b])=>{console.info("Setting connected device:",b.protocol,M,b)}),e(updateConnectedDevices(x)),(!s||!x[s])&&v.length>0){const M=v[0][1];e(selectConnectedDevice(M))}else v.length===0&&e(selectDevice(null))},loadSupportedIds=()=>async e=>{await syncStore(),e(updateSupportedIds(getSupportedIdsFromStore())),await e(loadTabkbIds()),await e(updateDefinitions(getDefinitionsFromStore())),e(loadStoredCustomDefinitions()),e(reloadConnectedDevices())},isElectron=/Electron/.test(navigator.userAgent),Container$a=styled.div`
|
|
1494
|
+
position: absolute;
|
|
1495
|
+
right: 15px;
|
|
1496
|
+
top: 0px;
|
|
1497
|
+
font-size: 18px;
|
|
1498
|
+
pointer-events: none;
|
|
1499
|
+
font-weight: 400;
|
|
1500
|
+
`,KeyboardTitle=styled.label`
|
|
1501
|
+
pointer-events: all;
|
|
1502
|
+
display: inline-block;
|
|
1503
|
+
background: var(--color_accent);
|
|
1504
|
+
border-bottom-left-radius: 6px;
|
|
1505
|
+
border-bottom-right-radius: 6px;
|
|
1506
|
+
font-size: 18px;
|
|
1507
|
+
text-transform: uppercase;
|
|
1508
|
+
color: var(--color_inside-accent);
|
|
1509
|
+
padding: 1px 10px;
|
|
1510
|
+
margin-right: 10px;
|
|
1511
|
+
border: solid 1px var(--bg_control);
|
|
1512
|
+
border-top: none;
|
|
1513
|
+
cursor: pointer;
|
|
1514
|
+
transition: all 0.1s ease-out;
|
|
1515
|
+
&:hover {
|
|
1516
|
+
filter: brightness(0.7);
|
|
1517
|
+
}
|
|
1518
|
+
`,KeyboardList=styled.ul`
|
|
1519
|
+
padding: 0;
|
|
1520
|
+
border: 1px solid var(--bg_control);
|
|
1521
|
+
width: 160px;
|
|
1522
|
+
border-radius: 6px;
|
|
1523
|
+
background-color: var(--bg_menu);
|
|
1524
|
+
margin: 0;
|
|
1525
|
+
margin-top: 5px;
|
|
1526
|
+
right: 10px;
|
|
1527
|
+
position: absolute;
|
|
1528
|
+
pointer-events: ${e=>e.$show?"all":"none"};
|
|
1529
|
+
transition: all 0.2s ease-out;
|
|
1530
|
+
z-index: 11;
|
|
1531
|
+
opacity: ${e=>e.$show?1:0};
|
|
1532
|
+
overflow: hidden;
|
|
1533
|
+
transform: ${e=>e.$show?0:"translateY(-5px)"};
|
|
1534
|
+
`,KeyboardButton=styled.button`
|
|
1535
|
+
display: block;
|
|
1536
|
+
text-align: center;
|
|
1537
|
+
outline: none;
|
|
1538
|
+
font-variant-numeric: tabular-nums;
|
|
1539
|
+
white-space: nowrap;
|
|
1540
|
+
overflow: hidden;
|
|
1541
|
+
text-overflow: ellipsis;
|
|
1542
|
+
width: 100%;
|
|
1543
|
+
border: none;
|
|
1544
|
+
background: ${e=>e.$selected?"var(--bg_icon-highlighted)":"transparent"};
|
|
1545
|
+
color: ${e=>e.$selected?"var(--color_icon_highlighted)":"var(--color_label-highlighted)"};
|
|
1546
|
+
cursor: pointer;
|
|
1547
|
+
text-align: left;
|
|
1548
|
+
font-size: 14px;
|
|
1549
|
+
text-transform: uppercase;
|
|
1550
|
+
padding: 5px 10px;
|
|
1551
|
+
&:hover {
|
|
1552
|
+
border: none;
|
|
1553
|
+
background: ${e=>e.$selected?"var(--bg_icon-highlighted)":"var(--bg_control)"};
|
|
1554
|
+
color: ${e=>e.$selected?"var(--color_control-highlighted)":"var(--color_label-highlighted)"};
|
|
1555
|
+
}
|
|
1556
|
+
`,ClickCover$2=styled.div`
|
|
1557
|
+
position: fixed;
|
|
1558
|
+
z-index: 10;
|
|
1559
|
+
pointer-events: all;
|
|
1560
|
+
top: 0;
|
|
1561
|
+
left: 0;
|
|
1562
|
+
right: 0;
|
|
1563
|
+
bottom: 0;
|
|
1564
|
+
opacity: 0.4;
|
|
1565
|
+
background: rgba(0, 0, 0, 0.75);
|
|
1566
|
+
`,KeyboardSelectors=e=>{const{t}=useTranslation(),r=async()=>{const s=await HID.requestDevice();s&&e.selectKeyboard(s.__path)};return jsxs(Fragment,{children:[e.show&&jsx(ClickCover$2,{onClick:e.onClickOut}),jsxs(KeyboardList,{$show:e.show,children:[e.keyboards.map(([s,a])=>jsx(KeyboardButton,{$selected:s===e.selectedPath,onClick:()=>e.selectKeyboard(s),children:a.name},s)),!isElectron&&jsxs(KeyboardButton,{onClick:r,children:[t("Authorize New"),jsx(FontAwesomeIcon,{icon:faPlus,style:{marginLeft:"10px"}})]})]})]})},Badge=()=>{const e=useAppDispatch(),t=useAppSelector(getDefinitions),r=useAppSelector(getSelectedDefinition),s=useAppSelector(getConnectedDevices),a=useAppSelector(getSelectedDevicePath),[l,c]=reactExports.useState(!1),d=reactExports.useMemo(()=>Object.entries(s).map(([p,f])=>[p,t[f.vendorProductId]&&t[f.vendorProductId][f.requiredDefinitionVersion]]).filter(p=>p[1]),[s,t]);return!r||!a?null:jsx(Fragment,{children:jsxs(Container$a,{children:[jsxs(KeyboardTitle,{onClick:()=>c(!l),children:[r.name,jsx(FontAwesomeIcon,{icon:faAngleDown,style:{transform:l?"rotate(180deg)":"",transition:"transform 0.2s ease-out",marginLeft:"5px"}})]}),jsx(KeyboardSelectors,{show:l,selectedPath:a,keyboards:d,onClickOut:()=>c(!1),selectKeyboard:p=>{e(selectConnectedDeviceByPath(p)),c(!1)}})]})})},MenuContainer=styled.div`
|
|
1567
|
+
padding: 15px 10px 20px 10px;
|
|
1568
|
+
`;[...makeCustomMenus([])];function getCustomPanes(e){return e.find(t=>t===dist.CustomFeaturesV2.RotaryEncoder)?[RotaryEncoder]:[]}const getRowsForKeyboard=()=>{const e=useAppSelector(getIsMacroFeatureSupported),t=useAppSelector(getV3MenuComponents),r=useAppSelector(getSelectedDefinition),s=useAppSelector(getNumberOfLayers),a=useAppSelector(getSelectedTabkbConfig);return r?dist.isVIADefinitionV2(r)?getRowsForKeyboardV2(r,e,s):dist.isVIADefinitionV3(r)?[...filterInferredRows(r,e,s,[Keycode$1,Layouts$1,Macros,SaveLoad]),...t,...filterTabRows(a,[MatrixLighting,Screen,Firmware$1])]:[]:[]},filterTabRows=(e,t)=>{if(!e)return[];let r=[];return e.screen||(r=[...r,Screen]),e.matrixLighting||(r=[...r,MatrixLighting]),e.firmware||(r=[...r,Firmware$1]),t.filter(s=>!r.includes(s))},filterInferredRows=(e,t,r,s)=>{const{layouts:a}=e;let l=[];return a.optionKeys&&Object.entries(a.optionKeys).length!==0||(l=[...l,Layouts$1]),r===0&&(l=[...l,Keycode$1,SaveLoad]),t||(l=[...l,Macros]),s.filter(d=>!l.includes(d))},getRowsForKeyboardV2=(e,t,r)=>{let s=[Keycode$1,Layouts$1,Macros,SaveLoad];if(dist.isVIADefinitionV2(e)){const{lighting:a,customFeatures:l}=e,{supportedLightingValues:c}=dist.getLightingDefinition(a);c.length!==0&&(s=[...s,Lighting$1]),l&&(s=[...s,...getCustomPanes(l)])}return filterInferredRows(e,t,r,s)},Loader=e=>{const{t}=useTranslation(),{loadProgress:r,selectedDefinition:s}=e,a=useAppDispatch(),l=useAppSelector(getSelectedTheme),c=useAppSelector(getConnectedDevices),d=useAppSelector(getSupportedIds),p=!Object.values(d).length,f=!Object.values(c).length,[m,y]=reactExports.useState(!1);return reactExports.useEffect(()=>{const K=setTimeout(()=>{s||y(!0)},3e3);return()=>clearTimeout(K)},[s]),jsxs(LoaderPane,{children:[jsx(ChippyLoader,{theme:l,progress:r||null}),(m||f)&&!p&&!isElectron?jsxs(AccentButtonLarge,{onClick:()=>a(reloadConnectedDevices()),children:[t("Authorize device"),jsx(FontAwesomeIcon,{style:{marginLeft:"10px"},icon:faPlus})]}):jsx(LoadingText$1,{isSearching:!s})]})},LoaderPane=styled(CenterPane)`
|
|
1569
|
+
display: flex;
|
|
1570
|
+
align-items: center;
|
|
1571
|
+
justify-content: center;
|
|
1572
|
+
row-gap: 50px;
|
|
1573
|
+
position: absolute;
|
|
1574
|
+
bottom: 50px;
|
|
1575
|
+
top: 50px;
|
|
1576
|
+
left: 0;
|
|
1577
|
+
right: 0;
|
|
1578
|
+
z-index: 4;
|
|
1579
|
+
`,ConfigurePane=()=>{const e=useAppSelector(getSelectedDefinition),t=useAppSelector(getLoadProgress),r=useAppSelector(getRenderMode);return!e||t!==1?r==="2D"?jsx(Loader,{selectedDefinition:e||null,loadProgress:t}):null:jsx(ConfigureBasePane,{children:jsx(ConfigureGrid,{})})},ConfigureGrid=()=>{var p,f;const{t:e}=useTranslation(),t=useDispatch(),[r,s]=reactExports.useState(0),a=getRowsForKeyboard(),l=(p=a[r])==null?void 0:p.Pane,c=(f=a[r])==null?void 0:f.Title,d=useAppSelector(getShowLayerControl);return reactExports.useEffect(()=>(c==="Keymap"&&t(setConfigureKeyboardIsSelectable(!0)),t(updateSelectedRowTitle(c)),()=>{t(setConfigureKeyboardIsSelectable(!1))}),[c]),jsxs(Fragment,{children:[jsx(ConfigureFlexCell,{onClick:m=>{m.target.nodeName!=="CANVAS"&&t(clearSelectedKey())},style:{pointerEvents:"none",position:"absolute",top:50,left:0,right:0},children:jsxs("div",{style:{pointerEvents:"all"},children:[d&&jsx(LayerControl,{}),jsx(Badge,{})]})}),jsxs(Grid,{style:{pointerEvents:"none"},children:[jsx(MenuCell,{style:{pointerEvents:"all"},children:jsx(MenuContainer,{children:(a||[]).map(({Icon:m,Title:y},K)=>jsx(Row,{onClick:x=>s(K),$selected:r===K,children:jsxs(IconContainer,{children:[jsx(m,{}),jsx(MenuTooltip,{children:e(y)})]})},K))})}),l&&jsx(l,{})]})]})};function Layouts({definition:e,onLayoutChange:t,RowComponent:r=IndentedControlRow}){const s=useAppSelector(getDesignSelectedOptionKeys),a=useDispatch();if(React.useEffect(()=>{a(updateSelectedOptionKeys([]))},[e]),React.useEffect(()=>{t(s)},[s]),!e.layouts.labels)return null;const l=e.layouts.labels.map((c,d)=>{const p=e.layouts.optionKeys[d];if(Array.isArray(c)){const f=c[0],m=c.slice(1),y=m.map((K,x)=>({label:K,value:p[x]}));return jsxs(r,{children:[jsx(Label$1,{children:f}),jsx(Detail,{children:jsx(AccentSelect,{onChange:K=>{if(K&&K.label){const x=m.indexOf(K.label),v=Array.from(s).map(M=>M||0);v[d]=x,a(updateSelectedOptionKeys(v))}},value:s[d]?y[s[d]]:y[0],options:y})})]},`${d}-${f}`)}return typeof c=="string"?jsxs(r,{children:[jsx(Label$1,{children:c}),jsx(Detail,{children:jsx(AccentSlider,{isChecked:!!s[d],onChange:f=>{const m=Array.from(s).map(y=>y||0);m[d]=Number(f),a(updateSelectedOptionKeys(m))}})})]},`${d}-${c}`):null});return jsx(Fragment,{children:l})}const Container$9=styled.div`
|
|
1580
|
+
display: flex;
|
|
1581
|
+
align-items: center;
|
|
1582
|
+
flex-direction: column;
|
|
1583
|
+
padding: 0 12px;
|
|
1584
|
+
`,ControlGroup=styled.div`
|
|
1585
|
+
margin-bottom: 0.75rem;
|
|
1586
|
+
padding-bottom: 0.75rem;
|
|
1587
|
+
width: 100%;
|
|
1588
|
+
|
|
1589
|
+
&:last-child {
|
|
1590
|
+
padding-bottom: 0;
|
|
1591
|
+
}
|
|
1592
|
+
`,ControlGroupHeader=styled.div`
|
|
1593
|
+
font-size: 1.5rem;
|
|
1594
|
+
font-weight: 600;
|
|
1595
|
+
margin: 0;
|
|
1596
|
+
margin-bottom: 0.5rem;
|
|
1597
|
+
`,TestControls=()=>{const[e,t]=reactExports.useState(!0),[r,s]=reactExports.useState(0),[a,l]=reactExports.useState([0,0]),[c,d]=reactExports.useState(0),[p,f]=reactExports.useState(0),{basicKeyToByte:m,byteToKey:y}=useAppSelector(getBasicKeyToByte),K=useAppSelector(getSelected256PaletteColor),x=useDispatch(),v=[{label:"Option 1",value:"0"},{label:"Option 2",value:"1"}];return jsxs(ControlGroup,{children:[jsx(ControlGroupHeader,{children:"Controls"}),jsxs(ControlRow,{children:[jsx(Label$1,{children:"Button"}),jsx(Detail,{children:jsx(AccentButton,{children:"Click"})})]}),jsxs(ControlRow,{children:[jsx(Label$1,{children:"Disabled Button"}),jsx(Detail,{children:jsx(AccentButton,{disabled:!0,children:"Disabled"})})]}),jsxs(ControlRow,{children:[jsx(Label$1,{children:"Text Input"}),jsx(Detail,{children:jsx(TextInput,{})})]}),jsxs(ControlRow,{children:[jsxs(Label$1,{children:[p," / ",anyKeycodeToString(p,m,y)]}),jsx(Detail,{children:jsx(PelpiKeycodeInput,{value:p,setValue:f,meta:{}})})]}),jsxs(ControlRow,{children:[jsxs(Label$1,{children:[a[0],", ",a[1]]}),jsx(Detail,{children:jsx(ArrayColorPicker,{color:a,setColor:(M,b)=>l([M,b])})})]}),jsxs(ControlRow,{children:[jsxs(Label$1,{children:[K[0],", ",K[1]]}),jsx(Detail,{children:jsx(ColorPalettePicker,{color:K,setColor:(M,b)=>x(setSelectedPaletteColor([M,b]))})})]}),jsxs(ControlRow,{children:[jsx(Label$1,{children:r}),jsx(Detail,{children:jsx(AccentRange,{max:100,min:0,defaultValue:r,onChange:s})})]}),jsxs(ControlRow,{children:[jsx(Label$1,{children:+e}),jsx(Detail,{children:jsx(AccentSlider,{isChecked:e,onChange:t})})]}),jsxs(ControlRow,{children:[jsx(Label$1,{children:+c}),jsx(Detail,{children:jsx(AccentSelect,{defaultValue:v[c],options:v,onChange:M=>{M&&d(+M.value)}})})]}),jsx(MacroRecorder,{selectedMacro:[[RawKeycodeSequenceAction.Delay,4]],setUnsavedMacro:M=>M,undoMacro:()=>null,saveMacro:()=>null,isDelaySupported:!0}),jsx(MacroRecorder,{setUnsavedMacro:M=>M,undoMacro:()=>null,saveMacro:()=>null,isDelaySupported:!0})]})},Debug=()=>{const e=useAppSelector(getSelectedKeyboardAPI),t=useAppSelector(getConnectedDevices),r=Object.entries(useAppSelector(getDefinitions)).flatMap(([M,b])=>[[M,b.v2],[M,b.v3]]).filter(([M,b])=>b!==void 0),s=Object.entries(useAppSelector(getBaseDefinitions)).flatMap(([M,b])=>[[M,b.v2],[M,b.v3]]).filter(([M,b])=>b!==void 0),a=Object.entries(useAppSelector(getCustomDefinitions)).flatMap(([M,b])=>[[M,b.v2],[M,b.v3]]).filter(([M,b])=>b!==void 0),[l,c]=reactExports.useState(0),[d,p]=reactExports.useState([]),[f,m]=reactExports.useState(0),[y,K]=reactExports.useState(!1),x=r.map(([,M],b)=>({label:M.name,value:`${b}`})),v=r[l];return jsx(Pane$c,{children:jsx(OverflowCell,{children:jsxs(Container$9,{children:[jsxs(ControlGroup,{children:[jsx(ControlGroupHeader,{children:"Key Testing"}),jsxs(ControlRow,{children:[jsx(Label$1,{children:"Show Matrix"}),jsx(Detail,{children:jsx(AccentSlider,{isChecked:y,onChange:M=>K(M)})})]}),jsxs(ControlRow,{children:[jsx(Label$1,{children:"Set next key"}),jsx(Detail,{children:jsx(AccentButton,{onClick:()=>{const{keys:M,optionKeys:b}=v[1].layouts,R=b?Object.entries(b).flatMap(([I,k])=>k[0]):[],O=[...M,...R];f!==void 0&&m(getNextKey(f,O)||0)},children:"Next"})})]})]}),x&&jsxs(ControlGroup,{children:[jsx(ControlGroupHeader,{children:"Layout Testing"}),jsxs(ControlRow,{children:[jsx(Label$1,{children:"Dummy Keyboard"}),jsx(Detail,{children:jsx(AccentSelect,{onChange:M=>M&&c(+M.value),defaultValue:x[0],options:x})})]})]}),v&&jsx(Layouts,{definition:v[1],onLayoutChange:M=>{p(M)}}),e&&jsxs(ControlGroup,{children:[jsx(ControlGroupHeader,{children:"Connected Device Debugging"}),jsxs(ControlRow,{children:[jsx(Label$1,{children:"EEPROM Reset"}),jsx(Detail,{children:jsx(AccentButton,{onClick:()=>e.resetEEPROM(),children:"Reset"})})]}),jsxs(ControlRow,{children:[jsx(Label$1,{children:"Bootloader Jump"}),jsx(Detail,{children:jsx(AccentButton,{onClick:()=>e.jumpToBootloader(),children:"Jump"})})]}),jsxs(ControlRow,{children:[jsx(Label$1,{children:"Clear all macros"}),jsx(Detail,{children:jsx(AccentButton,{onClick:()=>e.resetMacros(),children:"Clear"})})]}),jsxs(ControlRow,{children:[jsx(Label$1,{children:"Benchmark Switch State Query Speed"}),jsx(Detail,{children:jsx(AccentButton,{onClick:async()=>{const M=performance.now();await Array(1e3).fill(0).map(b=>e.getKeyboardValue(KeyboardValue.SWITCH_MATRIX_STATE,[],20)),console.info("1000 commands in ",performance.now()-M,"ms")},children:"Benchmark"})})]})]}),jsxs(ControlGroup,{children:[jsx(ControlGroupHeader,{children:"Device IDs"}),jsxs(ControlRow,{children:[jsx(Label$1,{children:"Connected Devices"}),jsxs(Detail,{children:[Object.values(t).length," Devices"]})]}),Object.values(t).map(M=>{const b=r.find(([R])=>R===M.vendorProductId.toString());return b?jsxs(IndentedControlRow,{children:[jsx(SubLabel,{children:b[1].name}),jsxs(Detail,{children:["0x",M.vendorProductId.toString(16).toUpperCase()]})]},M.path):null}),jsxs(ControlRow,{children:[jsx(Label$1,{children:"Local definitions"}),jsxs(Detail,{children:[Object.values(a).length," Definitions"]})]}),Object.values(a).map(([M,b],R)=>jsxs(IndentedControlRow,{children:[jsx(SubLabel,{children:b.name}),jsxs(Detail,{children:["0x",parseInt(M).toString(16).toUpperCase()]})]},R)),jsx(ControlRow,{children:jsxs("details",{children:[jsxs("summary",{children:[jsx(Label$1,{children:"Remote definitions"}),jsxs(Detail,{children:[Object.values(s).length," Definitions"]})]}),Object.values(s).map(([M,b],R)=>jsxs(IndentedControlRow,{children:[jsx(SubLabel,{children:b.name}),jsxs(Detail,{children:["0x",parseInt(M).toString(16).toUpperCase()]})]},R))]})})]}),jsx(TestControls,{})]})})})},MessageDialogContainer=styled.dialog`
|
|
1598
|
+
padding: 0;
|
|
1599
|
+
border-width: 0;
|
|
1600
|
+
|
|
1601
|
+
background: transparent;
|
|
1602
|
+
&::backdrop {
|
|
1603
|
+
background: rgba(0, 0, 0, 0.75);
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
& > div {
|
|
1607
|
+
transition: transform 0.2s ease-out;
|
|
1608
|
+
transform: translateY(-20px);
|
|
1609
|
+
}
|
|
1610
|
+
|
|
1611
|
+
&[open] > div {
|
|
1612
|
+
transform: translateY(0px);
|
|
1613
|
+
}
|
|
1614
|
+
`,Controls=styled.div`
|
|
1615
|
+
display: flex;
|
|
1616
|
+
justify-content: center;
|
|
1617
|
+
align-items: center;
|
|
1618
|
+
`,MessageDialog=e=>{const t=reactExports.useRef(null),r=reactExports.useCallback(()=>{t.current&&t.current.close(),e.onClose&&e.onClose()},[t.current,e.onClose]);return reactExports.useEffect(()=>(t.current&&(e.isOpen?t.current.showModal():t.current.close()),()=>{r()}),[e.isOpen]),jsx(MessageDialogContainer,{ref:t,children:jsxs(ModalContainer,{children:[jsx(PromptText,{children:e.children}),jsx(Controls,{children:jsx(AccentButton,{onClick:r,children:"Confirm"})})]})})};let designWarningSeen=Number(localStorage.getItem("designWarningSeen")||0),hideDesignWarning=sessionStorage.getItem("hideDesignWarning")||designWarningSeen>4;const DesignErrorMessage=styled(ErrorMessage)`
|
|
1619
|
+
margin: 0;
|
|
1620
|
+
font-style: italic;
|
|
1621
|
+
`,Container$8=styled.div`
|
|
1622
|
+
display: flex;
|
|
1623
|
+
align-items: center;
|
|
1624
|
+
flex-direction: column;
|
|
1625
|
+
padding: 0 12px;
|
|
1626
|
+
`,DesignPane=styled(Pane$c)`
|
|
1627
|
+
display: grid;
|
|
1628
|
+
max-width: 100vw;
|
|
1629
|
+
grid-template-columns: 100vw;
|
|
1630
|
+
grid-template-rows: min-content;
|
|
1631
|
+
`,UploadIcon=styled.div`
|
|
1632
|
+
height: 200px;
|
|
1633
|
+
width: 50%;
|
|
1634
|
+
cursor: pointer;
|
|
1635
|
+
max-width: 560px;
|
|
1636
|
+
border-radius: 6px;
|
|
1637
|
+
margin: 50px 10px;
|
|
1638
|
+
animation-duration: 1.5s;
|
|
1639
|
+
animation-name: border-glow;
|
|
1640
|
+
animation-iteration-count: infinite;
|
|
1641
|
+
animation-direction: alternate;
|
|
1642
|
+
animation-timing-function: ease-in-out;
|
|
1643
|
+
position: relative;
|
|
1644
|
+
display: flex;
|
|
1645
|
+
align-items: center;
|
|
1646
|
+
justify-content: center;
|
|
1647
|
+
svg {
|
|
1648
|
+
color: transparent;
|
|
1649
|
+
stroke-width: 8px;
|
|
1650
|
+
animation-duration: 1.5s;
|
|
1651
|
+
animation-name: text-glow;
|
|
1652
|
+
animation-iteration-count: infinite;
|
|
1653
|
+
animation-direction: alternate;
|
|
1654
|
+
animation-timing-function: ease-in-out;
|
|
1655
|
+
font-size: 100px;
|
|
1656
|
+
}
|
|
1657
|
+
`,makeReaderPromise=e=>new Promise((t,r)=>{const s=new FileReader;s.onload=()=>{if(!s.result)return r();t([e.name,s.result.toString()])},s.onerror=r,s.onabort=r,s.readAsBinaryString(e)}),isVIADefinition=e=>dist.isVIADefinitionV2(e)||dist.isVIADefinitionV3(e);function importDefinitions(e,t,r,s){Promise.all(e.map(makeReaderPromise)).then(a=>{let l=[];s([]);const c=a.map(([d,p])=>{if(l.length>0)return null;try{const f=JSON.parse(p.toString());if(t==="v2"?dist.isKeyboardDefinitionV2(f)||dist.isVIADefinitionV2(f):dist.isKeyboardDefinitionV3(f)||dist.isVIADefinitionV3(f))return t==="v2"?dist.isVIADefinitionV2(f)?f:dist.keyboardDefinitionV2ToVIADefinitionV2(f):dist.isVIADefinitionV3(f)?f:dist.keyboardDefinitionV3ToVIADefinitionV3(f);l=(t==="v2"?dist.isKeyboardDefinitionV2.errors||dist.isVIADefinitionV2.errors||[]:dist.isKeyboardDefinitionV3.errors||dist.isVIADefinitionV3.errors||[]).map(y=>`${d} ${y.dataPath?y.dataPath+": ":"Object: "}${y.message}`)}catch(f){f.name?l.push(`${f.name}: ${f.message}`):l.push(`${f}`)}}).filter(isVIADefinition);l.length?s(l):(r(loadCustomDefinitions({definitions:c,version:t})),r(storeCustomDefinitions({definitions:c,version:t})),r(ensureSupportedIds({productIds:c.map(d=>d.vendorProductId),version:t})),r(selectDevice(null)),r(reloadConnectedDevices()))})}function onDrop(e,t,r,s){e.preventDefault();const{dataTransfer:a}=e;if(a!=null&&a.items){const l=Array.from(a.items).filter(c=>c.kind==="file"&&c.type==="application/json").map(c=>c.getAsFile()).filter(c=>c!==null);l.length&&importDefinitions(l,t,r,s)}}const DesignTab=()=>{const{t:e}=useTranslation(),t=useDispatch(),r=Object.values(useAppSelector(getCustomDefinitions)),s=useAppSelector(getDesignDefinitionVersion),a=useAppSelector(getSelectedDefinitionIndex),l=useAppSelector(getShowMatrix),[c,d]=reactExports.useState([]),p=reactExports.useMemo(()=>r.filter(x=>x[s]),[r,s]),f=p.map((x,v)=>({label:x[s].name,value:v.toString()})),m=reactExports.useRef(null),y=p[a]&&p[a][s],K=reactExports.useRef();return jsxs(DesignPane,{onDragOver:x=>{x.dataTransfer.effectAllowed="copyMove",x.dataTransfer.dropEffect="none",x.preventDefault(),x.stopPropagation()},children:[jsx(MessageDialog,{isOpen:!hideDesignWarning,onClose:()=>{sessionStorage.setItem("hideDesignWarning","1"),hideDesignWarning="1",designWarningSeen=designWarningSeen+1,localStorage.setItem("designWarningSeen",`${designWarningSeen}`)},children:"This feature is intended for development purposes. If your keyboard is not recognized automatically by VIA, please contact your keyboard's manufacturer or vendor."}),jsx(SinglePaneFlexCell,{ref:m,children:!y&&jsx(UploadIcon,{onClick:()=>{K.current&&K.current.click()},onDrop:x=>onDrop(x,s,t,d),onDragOver:x=>{x.dataTransfer.effectAllowed="copyMove",x.dataTransfer.dropEffect="copy",x.preventDefault(),x.stopPropagation()},children:jsx(FontAwesomeIcon,{icon:faUpload})})}),jsxs(Grid,{style:{overflow:"hidden"},children:[jsx(MenuCell,{style:{pointerEvents:"all"},children:jsx(MenuContainer$6,{children:jsx(Row,{$selected:!0,children:jsxs(IconContainer,{children:[jsx(FontAwesomeIcon,{icon:faBook}),jsx(MenuTooltip,{children:e("Add Definition")})]})})})}),jsx(SpanOverflowCell,{children:jsxs(Container$8,{children:[jsxs(ControlRow,{children:[jsx(Label$1,{children:e("Load Draft Definition")}),jsx(Detail,{children:jsx(AccentUploadButton,{multiple:!0,inputRef:K,onLoad:x=>{importDefinitions(Array.from(x),s,t,d)},children:e("Load")})})]}),jsxs(ControlRow,{children:[jsx(Label$1,{children:e("Use V2 definitions (deprecated)")}),jsx(Detail,{children:jsx(AccentSlider,{isChecked:s==="v2",onChange:x=>t(updateDesignDefinitionVersion(x?"v2":"v3"))})})]}),y&&jsx(Fragment,{children:jsxs(ControlRow,{children:[jsx(Label$1,{children:e("Shown Keyboard Definition")}),jsx(Detail,{children:jsx(AccentSelect,{onChange:x=>{t(updateSelectedOptionKeys([])),x&&t(updateSelectedDefinitionIndex(+x.value))},value:f[a],options:f})})]})}),y&&jsx(Layouts,{definition:y,onLayoutChange:x=>{t(updateSelectedOptionKeys(x))}}),y&&jsxs(ControlRow,{children:[jsx(Label$1,{children:e("Show Matrix")}),jsx(Detail,{children:jsx(AccentSlider,{isChecked:l,onChange:x=>{t(updateShowMatrix(x))}})})]}),c.map(x=>jsx(IndentedControlRow,{children:jsx(DesignErrorMessage,{children:x})})),jsxs(ControlRow,{children:[jsx(Label$1,{children:e("Draft Definitions")}),jsxs(Detail,{children:[Object.values(p).length," ",e("Definitions")]})]}),p.map(x=>jsxs(IndentedControlRow,{children:[jsx(SubLabel,{children:x[s].name}),jsxs(Detail,{children:[formatNumberAsHex(x[s].vendorProductId,8),jsx(IconButtonUnfilledContainer,{onClick:()=>{t(unloadCustomDefinition({id:x[s].vendorProductId,version:s}))},style:{marginLeft:10,borderRadius:4},children:jsx(FontAwesomeIcon,{icon:faXmark,size:"lg"})})]})]},`${s}-${x[s].vendorProductId}`))]})})]})]})},Container$7=styled.div`
|
|
1658
|
+
display: flex;
|
|
1659
|
+
align-items: center;
|
|
1660
|
+
flex-direction: column;
|
|
1661
|
+
padding: 0 12px;
|
|
1662
|
+
`,DiagnosticContainer=styled(Container$7)`
|
|
1663
|
+
margin-top: 20px;
|
|
1664
|
+
padding-top: 20px;
|
|
1665
|
+
`,SettingsErrorMessage=styled(ErrorMessage)`
|
|
1666
|
+
margin: 0;
|
|
1667
|
+
font-style: italic;
|
|
1668
|
+
`,Settings=()=>{const{t:e}=useTranslation(),t=useDispatch(),r=useAppSelector(getShowDesignTab),s=useAppSelector(getDisableFastRemap),a=useAppSelector(getThemeMode),l=useAppSelector(getThemeName),c=useAppSelector(getRenderMode),d=useAppSelector(getSelectedConnectedDevice),p=useAppSelector(getSelectedDeviceFirmwareVersion),[f,m]=reactExports.useState(!1),y=Object.keys(THEMES).map(M=>({label:M.replaceAll("_"," "),value:M})),K=y.find(M=>M.value===l),x=webGLIsAvailable?[{label:"2D",value:"2D"},{label:"3D",value:"3D"}]:[{label:"2D",value:"2D"}],v=x.find(M=>M.value===c);return jsx(Pane$c,{children:jsxs(Grid,{style:{overflow:"hidden"},children:[jsx(MenuCell,{style:{pointerEvents:"all",borderTop:"none"},children:jsx(MenuContainer$6,{children:jsx(Row,{$selected:!0,children:jsxs(IconContainer,{children:[jsx(FontAwesomeIcon,{icon:faToolbox}),jsx(MenuTooltip,{children:e("General")})]})})})}),jsxs(SpanOverflowCell,{style:{flex:1,borderWidth:0},children:[jsxs(Container$7,{children:[jsxs(ControlRow,{children:[jsx(Label$1,{children:e("Show Design tab")}),jsx(Detail,{children:jsx(AccentSlider,{onChange:()=>t(toggleCreatorMode()),isChecked:r})})]}),jsxs(ControlRow,{children:[jsx(Label$1,{children:e("Fast Key Mapping")}),jsx(Detail,{children:jsx(AccentSlider,{onChange:()=>t(toggleFastRemap()),isChecked:!s})})]}),jsxs(ControlRow,{children:[jsx(Label$1,{children:e("Light Mode")}),jsx(Detail,{children:jsx(AccentSlider,{onChange:()=>t(toggleThemeMode()),isChecked:a==="light"})})]}),jsxs(ControlRow,{children:[jsx(Label$1,{children:e("Keycap Theme")}),jsx(Detail,{children:jsx(AccentSelect,{defaultValue:K,options:y,onChange:M=>{M&&t(updateThemeName(M.value))}})})]}),jsxs(ControlRow,{children:[jsx(Label$1,{children:e("Render Mode")}),jsx(Detail,{children:jsx(AccentSelect,{defaultValue:v,options:x,onChange:M=>{M&&t(updateRenderMode(M.value))}})})]}),jsxs(ControlRow,{children:[jsx(Label$1,{children:e("Show Diagnostic Information")}),jsx(Detail,{children:d?jsx(AccentSlider,{onChange:()=>m(!f),isChecked:f}):jsx(SettingsErrorMessage,{children:e("Requires connected device")})})]})]}),f&&d?jsxs(DiagnosticContainer,{children:[jsxs(ControlRow,{children:[jsx(Label$1,{children:e("VIA Firmware Protocol")}),jsx(Detail,{children:d.protocol})]}),!!p&&jsxs(ControlRow,{children:[jsx(Label$1,{children:e("VIA Firmware Version")}),jsx(Detail,{children:p})]})]}):null]})]})})},name="Tester",lighting="none",layouts={width:22.5,height:6.25,optionKeys:{},keys:[{row:0,col:0,x:0,y:0,r:0,rx:0,ry:0,h:1,w:1,color:"accent"},{row:0,col:1,x:2,y:0,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:2,x:3,y:0,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:3,x:4,y:0,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:4,x:5,y:0,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:5,x:6.5,y:0,r:0,rx:0,ry:0,h:1,w:1,color:"mod"},{row:0,col:6,x:7.5,y:0,r:0,rx:0,ry:0,h:1,w:1,color:"mod"},{row:0,col:7,x:8.5,y:0,r:0,rx:0,ry:0,h:1,w:1,color:"mod"},{row:0,col:8,x:9.5,y:0,r:0,rx:0,ry:0,h:1,w:1,color:"mod"},{row:0,col:9,x:11,y:0,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:10,x:12,y:0,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:11,x:13,y:0,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:12,x:14,y:0,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:13,x:15.25,y:0,r:0,rx:0,ry:0,h:1,w:1,color:"mod"},{row:0,col:14,x:16.25,y:0,r:0,rx:0,ry:0,h:1,w:1,color:"mod"},{row:0,col:15,x:17.25,y:0,r:0,rx:0,ry:0,h:1,w:1,color:"mod"},{row:0,col:16,x:18.5,y:0,r:0,rx:0,ry:0,h:1,w:1,color:"mod"},{row:0,col:17,x:19.5,y:0,r:0,rx:0,ry:0,h:1,w:1,color:"mod"},{row:0,col:18,x:20.5,y:0,r:0,rx:0,ry:0,h:1,w:1,color:"mod"},{row:0,col:19,x:21.5,y:0,r:0,rx:0,ry:0,h:1,w:1,color:"mod"},{row:0,col:20,x:0,y:1.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:21,x:1,y:1.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:22,x:2,y:1.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:23,x:3,y:1.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:24,x:4,y:1.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:25,x:5,y:1.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:26,x:6,y:1.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:27,x:7,y:1.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:28,x:8,y:1.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:29,x:9,y:1.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:30,x:10,y:1.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:31,x:11,y:1.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:32,x:12,y:1.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:33,x:13,y:1.25,r:0,rx:0,ry:0,h:1,w:2,color:"mod"},{row:0,col:34,x:15.25,y:1.25,r:0,rx:0,ry:0,h:1,w:1,color:"mod"},{row:0,col:35,x:16.25,y:1.25,r:0,rx:0,ry:0,h:1,w:1,color:"mod"},{row:0,col:36,x:17.25,y:1.25,r:0,rx:0,ry:0,h:1,w:1,color:"mod"},{row:0,col:37,x:18.5,y:1.25,r:0,rx:0,ry:0,h:1,w:1,color:"mod"},{row:0,col:38,x:19.5,y:1.25,r:0,rx:0,ry:0,h:1,w:1,color:"mod"},{row:0,col:39,x:20.5,y:1.25,r:0,rx:0,ry:0,h:1,w:1,color:"mod"},{row:0,col:40,x:21.5,y:1.25,r:0,rx:0,ry:0,h:1,w:1,color:"mod"},{row:0,col:41,x:0,y:2.25,r:0,rx:0,ry:0,h:1,w:1.5,color:"mod"},{row:0,col:42,x:1.5,y:2.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:43,x:2.5,y:2.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:44,x:3.5,y:2.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:45,x:4.5,y:2.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:46,x:5.5,y:2.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:47,x:6.5,y:2.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:48,x:7.5,y:2.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:49,x:8.5,y:2.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:50,x:9.5,y:2.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:51,x:10.5,y:2.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:52,x:11.5,y:2.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:53,x:12.5,y:2.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:54,x:13.5,y:2.25,r:0,rx:0,ry:0,h:1,w:1.5,color:"alpha"},{row:0,col:55,x:15.25,y:2.25,r:0,rx:0,ry:0,h:1,w:1,color:"mod"},{row:0,col:56,x:16.25,y:2.25,r:0,rx:0,ry:0,h:1,w:1,color:"mod"},{row:0,col:57,x:17.25,y:2.25,r:0,rx:0,ry:0,h:1,w:1,color:"mod"},{row:0,col:58,x:18.5,y:2.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:59,x:19.5,y:2.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:60,x:20.5,y:2.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:61,x:21.5,y:2.25,r:0,rx:0,ry:0,h:2,w:1,color:"mod"},{row:0,col:62,x:0,y:3.25,r:0,rx:0,ry:0,h:1,w:1.75,color:"mod"},{row:0,col:63,x:1.75,y:3.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:64,x:2.75,y:3.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:65,x:3.75,y:3.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:66,x:4.75,y:3.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:67,x:5.75,y:3.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:68,x:6.75,y:3.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:69,x:7.75,y:3.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:70,x:8.75,y:3.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:71,x:9.75,y:3.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:72,x:10.75,y:3.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:73,x:11.75,y:3.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:74,x:12.75,y:3.25,r:0,rx:0,ry:0,h:1,w:2.25,color:"accent"},{row:0,col:75,x:18.5,y:3.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:76,x:19.5,y:3.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:77,x:20.5,y:3.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:78,x:0,y:4.25,r:0,rx:0,ry:0,h:1,w:2.25,color:"mod"},{row:0,col:79,x:2.25,y:4.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:80,x:3.25,y:4.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:81,x:4.25,y:4.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:82,x:5.25,y:4.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:83,x:6.25,y:4.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:84,x:7.25,y:4.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:85,x:8.25,y:4.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:86,x:9.25,y:4.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:87,x:10.25,y:4.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:88,x:11.25,y:4.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:89,x:12.25,y:4.25,r:0,rx:0,ry:0,h:1,w:2.75,color:"mod"},{row:0,col:90,x:16.25,y:4.25,r:0,rx:0,ry:0,h:1,w:1,color:"mod"},{row:0,col:91,x:18.5,y:4.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:92,x:19.5,y:4.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:93,x:20.5,y:4.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"},{row:0,col:94,x:21.5,y:4.25,r:0,rx:0,ry:0,h:2,w:1,color:"accent"},{row:0,col:95,x:0,y:5.25,r:0,rx:0,ry:0,h:1,w:1.25,color:"mod"},{row:0,col:96,x:1.25,y:5.25,r:0,rx:0,ry:0,h:1,w:1.25,color:"mod"},{row:0,col:97,x:2.5,y:5.25,r:0,rx:0,ry:0,h:1,w:1.25,color:"mod"},{row:0,col:98,x:3.75,y:5.25,r:0,rx:0,ry:0,h:1,w:6.25,color:"alpha"},{row:0,col:99,x:10,y:5.25,r:0,rx:0,ry:0,h:1,w:1.25,color:"mod"},{row:0,col:100,x:11.25,y:5.25,r:0,rx:0,ry:0,h:1,w:1.25,color:"mod"},{row:0,col:101,x:12.5,y:5.25,r:0,rx:0,ry:0,h:1,w:1.25,color:"mod"},{row:0,col:102,x:13.75,y:5.25,r:0,rx:0,ry:0,h:1,w:1.25,color:"mod"},{row:0,col:103,x:15.25,y:5.25,r:0,rx:0,ry:0,h:1,w:1,color:"mod"},{row:0,col:104,x:16.25,y:5.25,r:0,rx:0,ry:0,h:1,w:1,color:"mod"},{row:0,col:105,x:17.25,y:5.25,r:0,rx:0,ry:0,h:1,w:1,color:"mod"},{row:0,col:106,x:18.5,y:5.25,r:0,rx:0,ry:0,h:1,w:2,color:"alpha"},{row:0,col:107,x:20.5,y:5.25,r:0,rx:0,ry:0,h:1,w:1,color:"alpha"}]},matrix={rows:1,cols:108},vendorProductId=0,fullKeyboardDefinition={name,lighting,layouts,matrix,vendorProductId},Container$6=styled.div`
|
|
1669
|
+
display: flex;
|
|
1670
|
+
align-items: center;
|
|
1671
|
+
flex-direction: column;
|
|
1672
|
+
padding: 0 12px;
|
|
1673
|
+
`,TestPane=styled(Pane$c)`
|
|
1674
|
+
display: flex;
|
|
1675
|
+
height: 100%;
|
|
1676
|
+
max-width: 100vw;
|
|
1677
|
+
flex-direction: column;
|
|
1678
|
+
`,TestContext=React.createContext([{clearTestKeys:()=>{}},(...e)=>{}]),Test$1=()=>{const{t:e}=useTranslation(),t=useDispatch(),r=useAppSelector(getSelectedConnectedDevice),s=useAppSelector(getSelectedDefinition),a=useAppSelector(getSelectedKeyDefinitions),l=useAppSelector(getIsTestMatrixEnabled),c=useAppSelector(getTestKeyboardSoundsSettings),[d]=reactExports.useContext(TestContext),{progress:p}=useProgress(),m=r&&s&&a&&PROTOCOL_GAMMA<=r.protocol,y=l?s:fullKeyboardDefinition;if(!y||typeof y=="string")return null;const K=[{label:"Sine",value:"sine"},{label:"Triangle",value:"triangle"},{label:"Sawtooth",value:"sawtooth"},{label:"Square",value:"square"}],x=K.find(b=>b.value===c.waveform),v=[{label:"Wicki-Hayden",value:TestKeyboardSoundsMode.WickiHayden},{label:"Chromatic",value:TestKeyboardSoundsMode.Chromatic},{label:"Random",value:TestKeyboardSoundsMode.Random}],M=v.find(b=>b.value===c.mode);return p!==100?null:jsx(TestPane,{children:jsxs(Grid,{children:[jsx(MenuCell,{style:{pointerEvents:"all"},children:jsx(MenuContainer$6,{children:jsx(Row,{$selected:!0,children:jsxs(IconContainer,{children:[jsx(FontAwesomeIcon,{icon:faCircleQuestion}),jsx(MenuTooltip,{children:e("Check Key")})]})})})}),jsx(SpanOverflowCell,{children:jsxs(Container$6,{children:[jsxs(ControlRow,{children:[jsx(Label$1,{children:e("Reset Keyboard")}),jsx(Detail,{children:jsx(AccentButton,{onClick:d.clearTestKeys,children:e("Reset")})})]}),m&&s?jsxs(ControlRow,{children:[jsx(Label$1,{children:e("Test Matrix")}),jsx(Detail,{children:jsx(AccentSlider,{isChecked:l,onChange:b=>{t(setTestMatrixEnabled(b)),d.clearTestKeys()}})})]}):null,jsxs(ControlRow,{children:[jsx(Label$1,{children:e("Key Sounds")}),jsx(Detail,{children:jsx(AccentSlider,{isChecked:c.isEnabled,onChange:b=>{t(setTestKeyboardSoundsSettings({isEnabled:b}))}})})]}),jsxs(ControlRow,{children:[jsx(Label$1,{children:e("Volume")}),jsx(Detail,{children:jsx(AccentRange,{max:100,min:0,defaultValue:c.volume,onChange:b=>{t(setTestKeyboardSoundsSettings({volume:b}))}})})]}),jsxs(ControlRow,{children:[jsx(Label$1,{children:e("Transpose")}),jsx(Detail,{children:jsx(AccentRange,{max:24,min:-24,defaultValue:c.transpose,onChange:b=>{t(setTestKeyboardSoundsSettings({transpose:b}))}})})]}),jsxs(ControlRow,{children:[jsx(Label$1,{children:e("Waveform")}),jsx(Detail,{children:jsx(AccentSelect,{isSearchable:!1,defaultValue:x,options:K,onChange:b=>{b&&t(setTestKeyboardSoundsSettings({waveform:b.value}))}})})]}),jsxs(ControlRow,{children:[jsx(Label$1,{children:e("Mode")}),jsx(Detail,{children:jsx(AccentSelect,{isSearchable:!1,defaultValue:M,options:v,onChange:b=>{b&&t(setTestKeyboardSoundsSettings({mode:b.value}))}})})]})]})})]})})},Container$5=styled.div`
|
|
1679
|
+
display: flex;
|
|
1680
|
+
flex-direction: column;
|
|
1681
|
+
padding: 16px;
|
|
1682
|
+
user-select: text;
|
|
1683
|
+
border-top: 1px solid var(--color_accent);
|
|
1684
|
+
&:last-of-type {
|
|
1685
|
+
border-bottom: 1px solid var(--color_accent);
|
|
1686
|
+
}
|
|
1687
|
+
`,printId=e=>formatNumberAsHex(e,4),ErrorListContainer=e=>{const{t}=useTranslation(),{clear:r,save:s,hasErrors:a}=e;return jsxs(Fragment,{children:[jsxs(IconButtonGroupContainer,{style:{margin:"10px 15px"},children:[jsxs(IconButtonContainer,{onClick:r,disabled:!a,children:[jsx(FontAwesomeIcon,{size:"sm",color:"var(--color_label)",icon:faCancel}),jsx(IconButtonTooltip,{children:t("Clear")})]}),jsxs(IconButtonContainer,{onClick:s,disabled:!a,children:[jsx(FontAwesomeIcon,{size:"sm",color:"var(--color_label)",icon:faDownload}),jsx(IconButtonTooltip,{children:t("Download")})]})]}),e.children]})},AppErrors=({})=>{const e=useAppSelector(getAppErrors),t=useDispatch();return jsx(ErrorListContainer,{clear:()=>t(clearAppErrors()),save:()=>saveAppErrors(e),hasErrors:!!e.length,children:e.map(({timestamp:r,deviceInfo:{productId:s,productName:a,vendorId:l},message:c})=>jsxs(Container$5,{children:[r,jsx("ul",{children:c==null?void 0:c.split(`
|
|
1688
|
+
`).map(d=>jsx("li",{children:d}))}),jsxs("ul",{children:[jsxs("li",{children:["Device: ",a]}),jsxs("li",{children:["Vid: ",printId(l)]}),jsxs("li",{children:["Pid: ",printId(s)]})]})]},r))})};async function saveErrors(e,t,r,s){try{const a=await window.showSaveFilePicker({suggestedName:`${r}.csv`}),l=[t.join(", ")],c=e.map(s),d=l.concat(...c).join(`
|
|
1689
|
+
`),p=new Blob([d],{type:"text/csv"}),f=await a.createWritable();await f.write(p),await f.close()}catch{console.log("User cancelled save errors request")}}const saveAppErrors=async e=>saveErrors(e,["timestamp","productName","vendorId","productId","message"],"VIA-app-errors",({timestamp:t,deviceInfo:{productName:r,vendorId:s,productId:a},message:l})=>`${t}, ${r}, ${printId(s)}, ${printId(a)}, "${l}"`),IconButtonGroupContainer=styled.div`
|
|
1690
|
+
border-radius: 2px;
|
|
1691
|
+
border: 1px solid var(--border_color_icon);
|
|
1692
|
+
display: inline-flex;
|
|
1693
|
+
> button:last-child {
|
|
1694
|
+
border: none;
|
|
1695
|
+
}
|
|
1696
|
+
`,ErrorPanes=[[1,AppErrors,faComputer,"App"]],Errors=()=>{const[e,t]=reactExports.useState(0),r=(ErrorPanes.find(([s])=>e===s)||ErrorPanes[0])[1];return jsx(Pane$c,{children:jsxs(Grid,{style:{overflow:"hidden"},children:[jsx(MenuCell,{style:{pointerEvents:"all",borderTop:"none"},children:jsx(MenuContainer$6,{children:ErrorPanes.map(([s,a,l,c])=>jsx(Row,{$selected:e===s,onClick:()=>{t(s)},children:jsxs(IconContainer,{children:[jsx(FontAwesomeIcon,{icon:l}),jsx(MenuTooltip,{children:c})]})},s))})}),jsx(SpanOverflowCell,{style:{flex:1,borderWidth:0},children:jsx(r,{})})]})})},ErrorLink=()=>{const e=useAppSelector(getAppErrors),[t]=useLocation(),r=t==="/errors";return e.length?jsx(Link$1,{to:"/errors",children:jsxs(CategoryIconContainer,{$selected:r,children:[jsx(FontAwesomeIcon,{size:"xl",icon:ErrorsPaneConfig.icon,color:r?"inherit":"gold"}),jsxs(CategoryMenuTooltip,{children:[e.length," error",e.length>1?"s":""]})]})}):null},ErrorsPaneConfig={component:Errors,path:"/errors",icon:faWarning,key:"errors",title:"Errors"},Container$4=styled.div`
|
|
1697
|
+
padding-top: 20px;
|
|
1698
|
+
width: 100%;
|
|
1699
|
+
display: flex;
|
|
1700
|
+
flex-direction: column;
|
|
1701
|
+
align-items: center;
|
|
1702
|
+
`,Boot=()=>{const{t:e}=useTranslation(),t=useAppDispatch(),r=useAppSelector(getSavingState),s=useAppSelector(getBufferSize),a=useAppSelector(getBytesSended),l=useAppSelector(getSendSpeed),c=reactExports.useRef(null),[d,p]=reactExports.useState(),f=()=>{var K;(K=c.current)==null||K.click()},m=async K=>{var x;if((x=K.target.files)!=null&&x[0]){const v=K.target.files[0],M=v.name,b=await v.arrayBuffer(),R=new Uint8Array(b);p({name:M,byteArray:R}),t(updateState("waiting"))}else p(null)},y=()=>{d&&t(saveTabFirmware(d.byteArray))};return jsx(Pane$c,{children:jsxs(Container$4,{children:[jsxs(ControlRow,{children:[jsxs(Label$1,{children:[e("Firmware"),"๏ผ",d==null?void 0:d.name]}),jsxs(Detail,{children:[jsx(AccentButton,{disabled:r==="saving",onClick:f,children:e("Open")}),jsx(HiddenInput$3,{accept:".uf2",onChange:m,type:"file",ref:c})]})]}),jsxs(ControlRow,{children:[jsxs(FlexLabel,{children:[r==="failed"&&jsxs(Fragment,{children:[jsx(FontAwesomeIcon,{icon:faWarning,size:"xs",style:{color:"gold",marginRight:5}}),e("Failed to flash.")]}),r==="completed"&&e("Flash successful.")," ",r==="saving"&&jsx(SavingProgress,{bufferSize:s,sendSpeed:l,bytesSended:a})]}),jsx(Detail,{children:jsx(AccentButton,{onClick:y,disabled:!d||r==="saving",children:e("Flash")})})]})]})})},Container$3=styled.div`
|
|
1703
|
+
padding-top: 20px;
|
|
1704
|
+
width: 100%;
|
|
1705
|
+
display: flex;
|
|
1706
|
+
flex-direction: column;
|
|
1707
|
+
align-items: center;
|
|
1708
|
+
`,Boot2=()=>{const{t:e}=useTranslation(),t=useAppDispatch(),r=useAppSelector(getSavingState),s=useAppSelector(getBufferSize),a=useAppSelector(getBytesSended),l=useAppSelector(getSendSpeed),c=reactExports.useRef(null),[d,p]=reactExports.useState(),f=()=>{var K;(K=c.current)==null||K.click()},m=async K=>{var x;if((x=K.target.files)!=null&&x[0]){const v=K.target.files[0],M=v.name,b=await v.arrayBuffer(),R=new Uint8Array(b);p({name:M,byteArray:R}),t(updateState("waiting"))}else p(null)},y=()=>{d&&t(saveTabFirmware(d.byteArray,!0))};return jsx(Pane$c,{children:jsxs(Container$3,{children:[jsxs(ControlRow,{children:[jsxs(Label$1,{children:[e("Firmware"),"๏ผ",d==null?void 0:d.name]}),jsxs(Detail,{children:[jsx(AccentButton,{disabled:r==="saving",onClick:f,children:e("Open")}),jsx(HiddenInput$3,{accept:".uf2",onChange:m,type:"file",ref:c})]})]}),jsxs(ControlRow,{children:[jsxs(FlexLabel,{children:[r==="failed"&&jsxs(Fragment,{children:[jsx(FontAwesomeIcon,{icon:faWarning,size:"xs",style:{color:"gold",marginRight:5}}),e("Failed to flash.")]}),r==="completed"&&e("Flash successful.")," ",r==="saving"&&jsx(SavingProgress,{bufferSize:s,sendSpeed:l,bytesSended:a})]}),jsx(Detail,{children:jsx(AccentButton,{onClick:y,disabled:!d||r==="saving",children:e("Flash")})})]})]})})},PANES=[{key:"default",component:ConfigurePane,icon:faKeyboard,title:"Configure",path:"/"},{key:"test",component:Test$1,icon:faStethoscope,path:"/test",title:"Key Tester"},{key:"design",component:DesignTab,icon:faBrush,path:"/design",title:"Design"},{key:"settings",component:Settings,icon:faGear,path:"/settings",title:"Settings"},{key:"debug",icon:faBug,component:Debug,path:"/debug",title:"Debug"},{key:"boot",icon:faSatelliteDish,component:Boot,path:"/boot",title:"2.4G boot"},{key:"boot2",icon:faSatelliteDish,component:Boot2,path:"/boot2",title:"boot2"},ErrorsPaneConfig],VIALogo=e=>jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 525.74 268.41",...e,children:[jsx("defs",{children:jsx("style",{children:".cls-1{fill:currentColor}"})}),jsx("g",{id:"Layer_2","data-name":"Layer 2",children:jsx("g",{id:"Layer_2-2","data-name":"Layer 2",children:jsx("path",{className:"cls-1",d:"M524.6 237.33 459.25 37.88C451.73 14.93 432.81.12 411 .12h-.13c-21.87.06-40.79 15-48.21 38.11l-64 199.23a22.93 22.93 0 0 0 43.66 14l18.74-58.35h100.81l19.13 58.5a22.93 22.93 0 0 0 43.58-14.28Zm-145-90a2.78 2.78 0 0 1-2.65-3.63l29.37-91.41C407.82 47.68 410 46 411 46c1 0 3.17 1.68 4.65 6.19l30 91.49a2.78 2.78 0 0 1-2.64 3.64ZM212.25 1.21A22.93 22.93 0 0 0 183.41 16l-64 199.23c-1.47 4.57-3.66 6.28-4.69 6.29-1 0-3.17-1.68-4.64-6.19L44.72 15.91A22.92 22.92 0 1 0 1.15 30.18l65.34 199.45c7.52 23 26.44 37.77 48.22 37.77h.14c21.86-.06 40.78-15 48.2-38.11l64-199.23a22.93 22.93 0 0 0-14.8-28.85ZM306.09 1.1a22.93 22.93 0 0 0-28.84 14.82l-71.5 222.54a22.93 22.93 0 1 0 43.66 14l71.5-222.55A22.93 22.93 0 0 0 306.09 1.1Zm-78.17 255.45a12.5 12.5 0 1 1 12.5-12.5 12.5 12.5 0 0 1-12.5 12.5Zm70.7-220.91a12.5 12.5 0 1 1 12.5-12.5 12.5 12.5 0 0 1-12.5 12.5Z"})})})]}),ExternalLinkContainer=styled.span`
|
|
1709
|
+
position: absolute;
|
|
1710
|
+
right: 1em;
|
|
1711
|
+
display: flex;
|
|
1712
|
+
gap: 1em;
|
|
1713
|
+
`,ExternalLinks=()=>jsxs(ExternalLinkContainer,{children:[jsx("a",{href:"https://caniusevia.com/",target:"_blank",children:jsxs(CategoryIconContainer,{children:[jsx(VIALogo,{height:"25px",fill:"currentColor"}),jsx(CategoryMenuTooltip,{children:"Firmware + Docs"})]})}),jsx("a",{href:"https://discord.gg/NStTR5YaPB",target:"_blank",children:jsxs(CategoryIconContainer,{children:[jsx(FontAwesomeIcon,{size:"xl",icon:faDiscord}),jsx(CategoryMenuTooltip,{children:"Discord"})]})}),jsx("a",{href:"https://github.com/tabkb/via-app",target:"_blank",children:jsxs(CategoryIconContainer,{children:[jsx(FontAwesomeIcon,{size:"xl",icon:faGithub}),jsx(CategoryMenuTooltip,{children:"Github"})]})})]}),Container$2=styled.div`
|
|
1714
|
+
position: absolute;
|
|
1715
|
+
right: 200px;
|
|
1716
|
+
font-size: 18px;
|
|
1717
|
+
`,LanguageList=styled.ul`
|
|
1718
|
+
padding: 0;
|
|
1719
|
+
border: 1px solid var(--bg_control);
|
|
1720
|
+
width: 160px;
|
|
1721
|
+
border-radius: 6px;
|
|
1722
|
+
background-color: var(--bg_menu);
|
|
1723
|
+
margin: 0;
|
|
1724
|
+
margin-top: 5px;
|
|
1725
|
+
top: 30px;
|
|
1726
|
+
right: 0px;
|
|
1727
|
+
position: absolute;
|
|
1728
|
+
pointer-events: ${e=>e.$show?"all":"none"};
|
|
1729
|
+
transition: all 0.2s ease-out;
|
|
1730
|
+
z-index: 11;
|
|
1731
|
+
opacity: ${e=>e.$show?1:0};
|
|
1732
|
+
overflow: hidden;
|
|
1733
|
+
transform: ${e=>e.$show?0:"translateY(-5px)"};
|
|
1734
|
+
`,LanugaeButton=styled.button`
|
|
1735
|
+
display: block;
|
|
1736
|
+
text-align: center;
|
|
1737
|
+
outline: none;
|
|
1738
|
+
font-variant-numeric: tabular-nums;
|
|
1739
|
+
white-space: nowrap;
|
|
1740
|
+
overflow: hidden;
|
|
1741
|
+
text-overflow: ellipsis;
|
|
1742
|
+
width: 100%;
|
|
1743
|
+
border: none;
|
|
1744
|
+
background: ${e=>e.$selected?"var(--bg_icon-highlighted)":"transparent"};
|
|
1745
|
+
color: ${e=>e.$selected?"var(--color_icon_highlighted)":"var(--color_label-highlighted)"};
|
|
1746
|
+
cursor: pointer;
|
|
1747
|
+
text-align: left;
|
|
1748
|
+
font-size: 14px;
|
|
1749
|
+
text-transform: uppercase;
|
|
1750
|
+
padding: 5px 10px;
|
|
1751
|
+
&:hover {
|
|
1752
|
+
border: none;
|
|
1753
|
+
background: ${e=>e.$selected?"var(--bg_icon-highlighted)":"var(--bg_control)"};
|
|
1754
|
+
color: ${e=>e.$selected?"var(--color_control-highlighted)":"var(--color_label-highlighted)"};
|
|
1755
|
+
}
|
|
1756
|
+
`,ClickCover$1=styled.div`
|
|
1757
|
+
position: fixed;
|
|
1758
|
+
z-index: 10;
|
|
1759
|
+
pointer-events: all;
|
|
1760
|
+
top: 0;
|
|
1761
|
+
left: 0;
|
|
1762
|
+
right: 0;
|
|
1763
|
+
bottom: 0;
|
|
1764
|
+
opacity: 0.4;
|
|
1765
|
+
background: rgba(0, 0, 0, 0.75);
|
|
1766
|
+
`,LanguageSelectors=e=>{const t=[{code:"en",lang:"English"},{code:"zh",lang:"ไธญๆ"},{code:"ko",lang:"ํ๊ตญ์ด"},{code:"ja",lang:"ๆฅๆฌ่ช"}],{i18n:r}=useTranslation(),s=l=>{r.changeLanguage(l),e.onClickOut()},a=reactExports.useMemo(()=>r.resolvedLanguage?r.resolvedLanguage:r.languages[r.languages.length-1],[r.resolvedLanguage,r.languages]);return jsxs(Fragment,{children:[e.show&&jsx(ClickCover$1,{onClick:e.onClickOut}),jsx(LanguageList,{$show:e.show,children:t.map(({lang:l,code:c})=>jsx(LanugaeButton,{$selected:c===a,onClick:()=>s(c),children:l},c))})]})},LanguageSelect=()=>{const[e,t]=reactExports.useState(!1);return jsxs(Container$2,{children:[jsx(CategoryIconContainer,{children:jsx(FontAwesomeIcon,{size:"xl",icon:faLanguage,onClick:()=>t(!0)})}),jsx(LanguageSelectors,{show:e,onClickOut:()=>t(!1)})]})},Container$1=styled.div`
|
|
1767
|
+
width: 100vw;
|
|
1768
|
+
height: 25px;
|
|
1769
|
+
padding: 12px 0;
|
|
1770
|
+
border-bottom: 1px solid var(--border_color_cell);
|
|
1771
|
+
display: flex;
|
|
1772
|
+
align-items: center;
|
|
1773
|
+
justify-content: center;
|
|
1774
|
+
`,{DEBUG_PROD,MODE,DEV}={BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1},showDebugPane=MODE==="development"||DEBUG_PROD==="true"||DEV,GlobalContainer=styled(Container$1)`
|
|
1775
|
+
background: var(--bg_outside-accent);
|
|
1776
|
+
column-gap: 20px;
|
|
1777
|
+
`,UnconnectedGlobalMenu=()=>{var c;const{t:e,i18n:t}=useTranslation(),r=useAppSelector(getShowDesignTab),s=(c=useAppSelector(getSelectedTabkbConfig))==null?void 0:c.g24boot,[a]=useLocation(),l=reactExports.useMemo(()=>PANES.filter(d=>d.key!==ErrorsPaneConfig.key).map(d=>d.key==="boot"&&!s||d.key==="boot2"&&!s||d.key==="design"&&!r||d.key==="debug"&&!showDebugPane?null:jsx(Link$1,{to:d.path,children:jsxs(CategoryIconContainer,{$selected:d.path===a,children:[jsx(FontAwesomeIcon,{size:"xl",icon:d.icon}),jsx(CategoryMenuTooltip,{children:e(d.title)})]})},d.key)),[a,r,t.language,s]);return jsx(React.Fragment,{children:jsxs(GlobalContainer,{children:[jsx(ErrorLink,{}),l,jsx(LanguageSelect,{}),jsx(ExternalLinks,{})]})})},overrideParam=new URL(window.location.href).searchParams.get("override_hid_check");overrideParam!==null&&localStorage.setItem("override_hid_check",overrideParam);const overrideHidCheck=localStorage.getItem("override_hid_check")||"false",OVERRIDE_HID_CHECK=!!JSON.parse(overrideHidCheck),ErrorHome=styled.div`
|
|
1778
|
+
background: var(--bg_gradient);
|
|
1779
|
+
display: flex;
|
|
1780
|
+
flex-direction: column;
|
|
1781
|
+
flex-grow: 1;
|
|
1782
|
+
height: 100%;
|
|
1783
|
+
overflow: hidden;
|
|
1784
|
+
height: auto;
|
|
1785
|
+
left: 0;
|
|
1786
|
+
right: 0;
|
|
1787
|
+
bottom: 0;
|
|
1788
|
+
padding-top: 24px;
|
|
1789
|
+
position: absolute;
|
|
1790
|
+
border-top: 1px solid var(--border_color_cell);
|
|
1791
|
+
`,UsbError=styled.div`
|
|
1792
|
+
align-items: center;
|
|
1793
|
+
display: flex;
|
|
1794
|
+
color: var(--color_label);
|
|
1795
|
+
flex-direction: column;
|
|
1796
|
+
height: 100%;
|
|
1797
|
+
justify-content: center;
|
|
1798
|
+
margin: 0 auto;
|
|
1799
|
+
max-width: 650px;
|
|
1800
|
+
text-align: center;
|
|
1801
|
+
`,UsbErrorIcon=styled.div`
|
|
1802
|
+
font-size: 2rem;
|
|
1803
|
+
`,UsbErrorHeading=styled.h1`
|
|
1804
|
+
margin: 1rem 0 0;
|
|
1805
|
+
`,UsbErrorWebHIDLink=styled.a`
|
|
1806
|
+
text-decoration: underline;
|
|
1807
|
+
color: var(--color_label-highlighted);
|
|
1808
|
+
`,timeoutRepeater=(e,t,r=0)=>()=>setTimeout(()=>{e(),r>0&&timeoutRepeater(e,t,r-1)()},t),Home=e=>{const{t}=useTranslation(),{hasHIDSupport:r}=e,s=useAppDispatch();useAppSelector(getSelectedKey),useAppSelector(getSelectedDefinition),useAppSelector(getConnectedDevices),useAppSelector(getSelectedLayerIndex),useAppSelector(getSelectedKeyDefinitions),useAppSelector(getDisableFastRemap),useAppSelector(getBasicKeyToByte);const a=useAppSelector(getSelectedKeyboardAPI),l=timeoutRepeater(()=>{s(reloadConnectedDevices())},500,1),c=reactExports.createRef();return reactExports.useEffect(()=>{if(r)return c.current&&c.current.focus(),startMonitoring(),usbDetect.on("change",l),s(loadSupportedIds()),s(loadTabkbConfigs()),()=>{usbDetect.off("change",l)}},[]),reactExports.useEffect(()=>{s(updateSelectedKey(null))},[a]),!r&&!OVERRIDE_HID_CHECK?jsx(ErrorHome,{ref:c,tabIndex:0,children:jsxs(UsbError,{children:[jsx(UsbErrorIcon,{children:"โ"}),jsx(UsbErrorHeading,{children:t("USB Detection Error")}),jsxs("p",{children:["Looks like there was a problem getting USB detection working. Right now, we only support"," ",jsx(UsbErrorWebHIDLink,{href:"https://caniuse.com/?search=webhid",target:"_blank",children:"browsers that have WebHID enabled"}),", so make sure yours is compatible before trying again."]})]})}):jsx(Fragment,{children:e.children})},useSize=e=>{const[t,r]=reactExports.useState();return reactExports.useLayoutEffect(()=>{e.current&&r(e.current.getBoundingClientRect())},[e]),useResizeObserver(e,s=>r(s.contentRect)),t},ZOOM=5.5*.8,Camera=()=>{const{progress:e}=useProgress(),t=useThree(l=>l.camera),[r,s]=[7,7],a=J({config:{duration:800},from:{x:r}});return React.useEffect(()=>{e===100&&(console.debug("lets animate"),a.x.start(s))},[e]),React.useEffect(()=>(console.debug("mounting"),()=>{console.debug("unmounting")}),[]),useFrame(()=>{a.x.isAnimating&&(t.position.setZ(a.x.get()),t.position.setY(.4*Math.pow(a.x.get()-s,1)),t.updateProjectionMatrix()),t.zoom!==ZOOM&&(t.zoom=ZOOM,t.updateProjectionMatrix())}),jsx(PerspectiveCamera,{"position-z":r,makeDefault:!0,fov:25})},CaseGroup=styled.div``,OuterCase=styled.div`
|
|
1809
|
+
background: ${e=>e.background};
|
|
1810
|
+
width: ${e=>e.width}px;
|
|
1811
|
+
height: ${e=>e.height}px;
|
|
1812
|
+
`,InnerCase=styled.div`
|
|
1813
|
+
background: ${e=>e.background};
|
|
1814
|
+
top: 0;
|
|
1815
|
+
left: 0;
|
|
1816
|
+
position: absolute;
|
|
1817
|
+
width: ${e=>e.width}px;
|
|
1818
|
+
height: ${e=>e.height}px;
|
|
1819
|
+
`,CaseInsideBorder=10,Case$1=React.memo(e=>{const t=useAppSelector(getSelectedTheme),r=reactExports.useMemo(()=>t[dist.KeyColorType.Accent].c,[t]),s=e.width*CSSVarObject.keyXPos-CSSVarObject.keyXSpacing,a=CSSVarObject.keyYPos*e.height-CSSVarObject.keyYSpacing,l=CSSVarObject.insideBorder,c=s+l*1,d=s+l*3,[p,f]=[a+l,a+l*3],[m,y,K]=[.15,.25,.2].map(x=>getDarkenedColor(r,x));return jsxs(CaseGroup,{children:[jsx(OuterCase,{background:r,width:d,height:f,style:{borderRadius:8,boxShadow:"var(--box-shadow-keyboard)"}}),jsx(InnerCase,{background:`linear-gradient(200deg,${m} 40%,${y},${K} 80%)`,width:c,height:p,style:{transform:`translate( ${c-s}px,
|
|
1820
|
+
${p-a}px)`,boxShadow:"var(--box-shadow-keyboard)",borderRadius:8}})]})},shallowEqual);var DisplayMode=(e=>(e[e.Test=1]="Test",e[e.Configure=2]="Configure",e[e.Design=3]="Design",e[e.ConfigureColors=4]="ConfigureColors",e[e.ConfigureDKS=5]="ConfigureDKS",e[e.ConfigureAP=6]="ConfigureAP",e[e.ConfigureRT=7]="ConfigureRT",e))(DisplayMode||{}),KeycapState=(e=>(e[e.Pressed=1]="Pressed",e[e.Unpressed=2]="Unpressed",e))(KeycapState||{});const KeycapContainer=styled.div`
|
|
1821
|
+
position: absolute;
|
|
1822
|
+
left: 0;
|
|
1823
|
+
top: 0;
|
|
1824
|
+
width: 52px;
|
|
1825
|
+
height: 54px;
|
|
1826
|
+
&:hover {
|
|
1827
|
+
z-index: 1;
|
|
1828
|
+
& .tooltip {
|
|
1829
|
+
transform: scale(1) translateY(0px);
|
|
1830
|
+
opacity: 1;
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
.tooltip {
|
|
1834
|
+
transform: translateY(5px) scale(0.6);
|
|
1835
|
+
opacity: 0;
|
|
1836
|
+
}
|
|
1837
|
+
`,TooltipContainer=styled.div`
|
|
1838
|
+
position: absolute;
|
|
1839
|
+
transform: rotate(${e=>e.$rotate}rad);
|
|
1840
|
+
width: 100%;
|
|
1841
|
+
height: 100%;
|
|
1842
|
+
bottom: 0;
|
|
1843
|
+
`,TestOverlay=styled.div`
|
|
1844
|
+
transition: all 0.2s ease-out;
|
|
1845
|
+
position: absolute;
|
|
1846
|
+
left: 0;
|
|
1847
|
+
top: 0;
|
|
1848
|
+
right: 0;
|
|
1849
|
+
bottom: 0;
|
|
1850
|
+
`,CanvasContainerBG=styled.div``,CanvasContainer=styled.div`
|
|
1851
|
+
box-shadow: inset -1px -1px 0 rgb(0 0 0 / 20%),
|
|
1852
|
+
inset 1px 1px 0 rgb(255 255 255 / 10%);
|
|
1853
|
+
`,ComboKeycap=e=>{const{normalizedRects:t,clipPath:r,overflowsTexture:s,macroData:a,label:l,canvasRef:c,onClick:d,onPointerDown:p,onPointerOver:f,onPointerOut:m,disabled:y,...K}=e,[x,v]=t;return jsx(Fragment,{children:jsxs(KeycapContainer,{...K,children:[jsxs(ComboKeyBoundingContainer,{$selected:e.selected,onClick:d,onPointerDown:p,onPointerOver:f,onPointerOut:m,style:{cursor:y?"initial":"pointer",position:"relative",animation:e.disabled?"initial":e.selected?".75s infinite alternate select-glow":"",transform:`translateX(${-Math.abs(x[0]-v[0])*CSSVarObject.keyXPos/2}px) perspective(100px) translateZ(${e.keycapZ}px)`,width:Math.max(x[2],v[2])*CSSVarObject.keyXPos-CSSVarObject.keyXSpacing,height:Math.max(x[3],v[3])*CSSVarObject.keyYPos-CSSVarObject.keyYSpacing,clipPath:r},children:[jsx(ComboKeyRectContainer,{style:{position:"absolute",borderRadius:3,background:getDarkenedColor(e.color.c,.8),transform:`translate(${CSSVarObject.keyXPos*x[0]}px,${CSSVarObject.keyYPos*x[1]}px)`,width:x[2]*CSSVarObject.keyXPos-CSSVarObject.keyXSpacing,height:x[3]*CSSVarObject.keyYPos-CSSVarObject.keyYSpacing}}),jsx(ComboKeyRectContainer,{style:{position:"absolute",borderRadius:3,transform:`translate(${CSSVarObject.keyXPos*v[0]}px,${CSSVarObject.keyYPos*v[1]}px)`,background:getDarkenedColor(e.color.c,.8),width:v[2]*CSSVarObject.keyXPos-CSSVarObject.keyXSpacing,height:v[3]*CSSVarObject.keyYPos-CSSVarObject.keyYSpacing}}),jsx(ComboKeyBGContainer,{style:{position:"absolute",borderRadius:3,background:getDarkenedColor(e.color.c,.8),transform:`translate(${CSSVarObject.keyXPos*x[0]+1}px,${1+CSSVarObject.keyYPos*x[1]}px)`,width:x[2]*CSSVarObject.keyXPos-CSSVarObject.keyXSpacing-2,height:x[3]*CSSVarObject.keyYPos-CSSVarObject.keyYSpacing-2}}),jsx(CanvasContainer,{style:{borderRadius:4,background:e.color.c,position:"absolute",transform:`translate(${CSSVarObject.keyXPos*x[0]+CSSVarObject.faceXPadding[0]}px,${CSSVarObject.faceYPadding[0]+CSSVarObject.keyYPos*x[1]}px)`,width:x[2]*CSSVarObject.keyXPos-CSSVarObject.keyXSpacing-CSSVarObject.faceXPadding[0]-CSSVarObject.faceXPadding[1],height:x[3]*CSSVarObject.keyYPos-CSSVarObject.keyYSpacing-CSSVarObject.faceYPadding[0]-CSSVarObject.faceYPadding[1]}}),jsx(CanvasContainer,{style:{borderRadius:4,background:e.color.c,position:"absolute",transform:`translate(${CSSVarObject.keyXPos*v[0]+CSSVarObject.faceXPadding[0]}px,${CSSVarObject.faceYPadding[0]+CSSVarObject.keyYPos*v[1]}px)`,width:v[2]*CSSVarObject.keyXPos-CSSVarObject.keyXSpacing-CSSVarObject.faceXPadding[0]-CSSVarObject.faceXPadding[1],height:v[3]*CSSVarObject.keyYPos-CSSVarObject.keyYSpacing-CSSVarObject.faceYPadding[0]-CSSVarObject.faceYPadding[1]}}),jsx(CanvasContainerBG,{style:{borderRadius:4,background:e.color.c,position:"absolute",transform:`translate(${1+CSSVarObject.keyXPos*x[0]+CSSVarObject.faceXPadding[0]}px,${1+CSSVarObject.faceYPadding[0]+CSSVarObject.keyYPos*x[1]}px)`,width:x[2]*CSSVarObject.keyXPos-CSSVarObject.keyXSpacing-CSSVarObject.faceXPadding[0]-CSSVarObject.faceXPadding[1]-2,height:x[3]*CSSVarObject.keyYPos-CSSVarObject.keyYSpacing-CSSVarObject.faceYPadding[0]-CSSVarObject.faceYPadding[1]-2},children:jsx("canvas",{ref:c,style:{}})}),DisplayMode.Test===e.mode?jsx(TestOverlay,{style:{background:e.keycapColor,opacity:e.keycapOpacity}}):null]}),(e.macroData||e.overflowsTexture)&&jsx(TooltipContainer,{$rotate:e.rotation[2],children:jsx(Keycap2DTooltip,{children:e.macroData||e.label&&e.label.tooltipLabel})})]})})},ComboKeyBoundingContainer=styled.div`
|
|
1854
|
+
box-sizing: border-box;
|
|
1855
|
+
transition: transform 0.2s ease-out;
|
|
1856
|
+
animation: ${e=>e.$selected?".75s infinite alternate select-glow":"initial"};
|
|
1857
|
+
&:hover {
|
|
1858
|
+
transform: perspective(100px) translateZ(-5px);
|
|
1859
|
+
animation: 0.5s 1 forwards select-glow;
|
|
1860
|
+
}
|
|
1861
|
+
`,ComboKeyRectContainer=styled.div`
|
|
1862
|
+
box-sizing: border-box;
|
|
1863
|
+
padding: 2px 6px 10px 6px;
|
|
1864
|
+
box-shadow: inset -1px -1px 0 rgb(0 0 0 / 20%),
|
|
1865
|
+
inset 1px 1px 0 rgb(255 255 255 / 20%);
|
|
1866
|
+
`,ComboKeyBGContainer=styled.div`
|
|
1867
|
+
box-sizing: border-box;
|
|
1868
|
+
padding: 3px 7px 10px 6px;
|
|
1869
|
+
`,EncoderKeyContainer=styled.div`
|
|
1870
|
+
position: absolute;
|
|
1871
|
+
left: 0;
|
|
1872
|
+
top: 0;
|
|
1873
|
+
width: 52px;
|
|
1874
|
+
opacity: 1;
|
|
1875
|
+
height: 52px;
|
|
1876
|
+
&:hover {
|
|
1877
|
+
z-index: 1;
|
|
1878
|
+
animation: 0.75s infinite alternate select-glow;
|
|
1879
|
+
}
|
|
1880
|
+
`,EncoderKeyContent2=styled.div`
|
|
1881
|
+
--inner-padding: ${e=>e.$innerPadding}px;
|
|
1882
|
+
--size: ${e=>e.$size}px;
|
|
1883
|
+
--inner-size: ${e=>e.$size-e.$innerPadding*2}px;
|
|
1884
|
+
--half-size: ${e=>(e.$size-e.$innerPadding*2)/2}px;
|
|
1885
|
+
--half-size-p1: ${e=>1+(e.$size-e.$innerPadding*2)/2}px;
|
|
1886
|
+
--half-size-p05p: ${e=>e.$innerPadding/2+(e.$size-e.$innerPadding*2)/2}px;
|
|
1887
|
+
background-color: currentColor;
|
|
1888
|
+
padding: var(--inner-padding);
|
|
1889
|
+
min-width: var(--size);
|
|
1890
|
+
min-height: var(--size);
|
|
1891
|
+
clip-path: polygon(
|
|
1892
|
+
50% 0%,
|
|
1893
|
+
46.93% 3.1%,
|
|
1894
|
+
43.47% 0.43%,
|
|
1895
|
+
40.83% 3.9%,
|
|
1896
|
+
37.06% 1.7%,
|
|
1897
|
+
34.89% 5.49%,
|
|
1898
|
+
30.87% 3.81%,
|
|
1899
|
+
29.21% 7.85%,
|
|
1900
|
+
25% 6.7%,
|
|
1901
|
+
23.89% 10.92%,
|
|
1902
|
+
19.56% 10.33%,
|
|
1903
|
+
19.01% 14.66%,
|
|
1904
|
+
14.64% 14.64%,
|
|
1905
|
+
14.66% 19.01%,
|
|
1906
|
+
10.33% 19.56%,
|
|
1907
|
+
10.92% 23.89%,
|
|
1908
|
+
6.7% 25%,
|
|
1909
|
+
7.85% 29.21%,
|
|
1910
|
+
3.81% 30.87%,
|
|
1911
|
+
5.49% 34.89%,
|
|
1912
|
+
1.7% 37.06%,
|
|
1913
|
+
3.9% 40.83%,
|
|
1914
|
+
0.43% 43.47%,
|
|
1915
|
+
3.1% 46.93%,
|
|
1916
|
+
0% 50%,
|
|
1917
|
+
3.1% 53.07%,
|
|
1918
|
+
0.43% 56.53%,
|
|
1919
|
+
3.9% 59.17%,
|
|
1920
|
+
1.7% 62.94%,
|
|
1921
|
+
5.49% 65.11%,
|
|
1922
|
+
3.81% 69.13%,
|
|
1923
|
+
7.85% 70.79%,
|
|
1924
|
+
6.7% 75%,
|
|
1925
|
+
10.92% 76.11%,
|
|
1926
|
+
10.33% 80.44%,
|
|
1927
|
+
14.66% 80.99%,
|
|
1928
|
+
14.64% 85.36%,
|
|
1929
|
+
19.01% 85.34%,
|
|
1930
|
+
19.56% 89.67%,
|
|
1931
|
+
23.89% 89.08%,
|
|
1932
|
+
25% 93.3%,
|
|
1933
|
+
29.21% 92.15%,
|
|
1934
|
+
30.87% 96.19%,
|
|
1935
|
+
34.89% 94.51%,
|
|
1936
|
+
37.06% 98.3%,
|
|
1937
|
+
40.83% 96.1%,
|
|
1938
|
+
43.47% 99.57%,
|
|
1939
|
+
46.93% 96.9%,
|
|
1940
|
+
50% 100%,
|
|
1941
|
+
53.07% 96.9%,
|
|
1942
|
+
56.53% 99.57%,
|
|
1943
|
+
59.17% 96.1%,
|
|
1944
|
+
62.94% 98.3%,
|
|
1945
|
+
65.11% 94.51%,
|
|
1946
|
+
69.13% 96.19%,
|
|
1947
|
+
70.79% 92.15%,
|
|
1948
|
+
75% 93.3%,
|
|
1949
|
+
76.11% 89.08%,
|
|
1950
|
+
80.44% 89.67%,
|
|
1951
|
+
80.99% 85.34%,
|
|
1952
|
+
85.36% 85.36%,
|
|
1953
|
+
85.34% 80.99%,
|
|
1954
|
+
89.67% 80.44%,
|
|
1955
|
+
89.08% 76.11%,
|
|
1956
|
+
93.3% 75%,
|
|
1957
|
+
92.15% 70.79%,
|
|
1958
|
+
96.19% 69.13%,
|
|
1959
|
+
94.51% 65.11%,
|
|
1960
|
+
98.3% 62.94%,
|
|
1961
|
+
96.1% 59.17%,
|
|
1962
|
+
99.57% 56.53%,
|
|
1963
|
+
96.9% 53.07%,
|
|
1964
|
+
100% 50%,
|
|
1965
|
+
96.9% 46.93%,
|
|
1966
|
+
99.57% 43.47%,
|
|
1967
|
+
96.1% 40.83%,
|
|
1968
|
+
98.3% 37.06%,
|
|
1969
|
+
94.51% 34.89%,
|
|
1970
|
+
96.19% 30.87%,
|
|
1971
|
+
92.15% 29.21%,
|
|
1972
|
+
93.3% 25%,
|
|
1973
|
+
89.08% 23.89%,
|
|
1974
|
+
89.67% 19.56%,
|
|
1975
|
+
85.34% 19.01%,
|
|
1976
|
+
85.36% 14.64%,
|
|
1977
|
+
80.99% 14.66%,
|
|
1978
|
+
80.44% 10.33%,
|
|
1979
|
+
76.11% 10.92%,
|
|
1980
|
+
75% 6.7%,
|
|
1981
|
+
70.79% 7.85%,
|
|
1982
|
+
69.13% 3.81%,
|
|
1983
|
+
65.11% 5.49%,
|
|
1984
|
+
62.94% 1.7%,
|
|
1985
|
+
59.17% 3.9%,
|
|
1986
|
+
56.53% 0.43%,
|
|
1987
|
+
53.07% 3.1%
|
|
1988
|
+
);
|
|
1989
|
+
|
|
1990
|
+
background-image: radial-gradient(
|
|
1991
|
+
currentColor var(--half-size),
|
|
1992
|
+
transparent var(--half-size-p1)
|
|
1993
|
+
),
|
|
1994
|
+
radial-gradient(
|
|
1995
|
+
rgba(255, 255, 255, 0.6) var(--half-size),
|
|
1996
|
+
transparent var(--half-size-p1)
|
|
1997
|
+
),
|
|
1998
|
+
radial-gradient(
|
|
1999
|
+
rgba(0, 0, 0, 0.2) var(--half-size),
|
|
2000
|
+
transparent var(--half-size-p05p)
|
|
2001
|
+
),
|
|
2002
|
+
radial-gradient(
|
|
2003
|
+
rgba(0, 0, 0, 0.2) var(--half-size),
|
|
2004
|
+
transparent var(--half-size-p05p)
|
|
2005
|
+
);
|
|
2006
|
+
background-size: var(--size) var(--size);
|
|
2007
|
+
background-position: 0px 0px, -0.5px -0.5px, 0px 0px,
|
|
2008
|
+
calc(var(--inner-padding) / 2) calc(var(--inner-padding) / 2);
|
|
2009
|
+
background-repeat: repeat;
|
|
2010
|
+
|
|
2011
|
+
transition: transform 0.5s ease-out;
|
|
2012
|
+
transform: rotate(0);
|
|
2013
|
+
box-sizing: border-box;
|
|
2014
|
+
&:hover {
|
|
2015
|
+
transform: rotate(450deg);
|
|
2016
|
+
}
|
|
2017
|
+
`,EncoderKey=e=>jsx(EncoderKeyContainer,{onClick:e.onClick,style:e.style,children:jsx(EncoderKeyContent2,{$size:e.size&&+e.size,$innerPadding:5*e.size/52})}),getMacroData$1=({macroExpression:e,label:t})=>t&&t.length>15?t:e&&e.length?e:null,paintKeycapLabel$1=(e,t,r,s,a,l)=>{const c=e.getContext("2d");if(c==null)return;const d=devicePixelRatio,[p,f]=[e.width,e.height];e.width=p*d,e.height=f*d,e.style.width=`${p}px`,e.style.height=`${f}px`,c.scale(d,d);const m="Fira Sans, Arial Rounded MT, Arial Rounded MT Bold, Arial",y={x:4,y:4},K={x:4,y:4},x={x:3,y:0},v={x:4,y:4};if(c.beginPath(),c.moveTo(0,0),c.lineTo(e.width,0),c.lineTo(e.width,e.height),c.lineTo(0,e.height),c.lineTo(0,0),c.clip(),c.fillStyle=t,DisplayMode.ConfigureAP===s||DisplayMode.ConfigureRT===s||DisplayMode.ConfigureDKS===s){let b=10,R=.75*b,O=f/2;const I=Math.min(p-1,120),k=R+2,F=f-3;c.font=`${b}px ${m}`,c.textAlign="right";const V=(a==null?void 0:a.apData)!==void 0,$=(a==null?void 0:a.rtData)!==void 0&&a.rtData.enabled;if(DisplayMode.ConfigureAP===s&&(l?c.fillText("DKS",I,F):V&&c.fillText(a.apData.ap.toFixed(2),I,F)),DisplayMode.ConfigureRT===s&&(l?c.fillText("DKS",I,F):(c.textAlign="right",$&&c.fillText(a.rtData.rt1.toFixed(2),I,k),c.textAlign="right",$&&c.fillText(a.rtData.rt2.toFixed(2),I,F))),DisplayMode.ConfigureDKS===s)if(l)c.fillText("DKS",I,F);else{const X=[];$&&X.push("RT"),$&&c.fillText(X.join(","),I,k)}c.textAlign="start",b=13*r.size,R=.75*b,c.font=`bold ${b}px ${m}`;const z=r.label||r.key;return c.fillText(z,x.x,O+.5*R),c.measureText(z).width>p-x.x}if(r!==void 0){if(r.topLabel&&r.bottomLabel){let b=16,R=.75*b,O=r.offset[0]*R,I=r.offset[1]*R;c.font=`bold ${b}px ${m}`,c.fillText(r.topLabel,y.x,y.y+O+R),c.fillText(r.bottomLabel,K.x,f-K.y-I)}else if(r.centerLabel){let b=13*r.size,R=.75*b,O=f/2;return c.font=`bold ${b}px ${m}`,c.fillText(r.label,x.x,O+.5*R),c.measureText(r.centerLabel).width>p-x.x}else if(typeof r.label=="string"){let b=22,R=.75*b;c.font=`bold ${b}px ${m}`,c.fillText(r.label,v.x,v.y+R)}}},paintKeycap$1=(e,t,r,s,a,l,c,d)=>{const[p,f]=[CSSVarObject.keyWidth,CSSVarObject.keyHeight];if(e.width=p*t-CSSVarObject.faceXPadding.reduce((y,K)=>y+K,0),e.height=f*r-CSSVarObject.faceYPadding.reduce((y,K)=>y+K,0),e.getContext("2d")!=null)return paintKeycapLabel$1(e,s,a,l,c,d)},Keycap$1=React.memo(e=>{const{label:t,scale:r,color:s,selected:a,multiSelected:l,disabled:c,mode:d,rotation:p,keyState:f,shouldRotate:m,textureWidth:y,textureHeight:K,skipFontCheck:x,idx:v,actuation:M,dksData:b,multiSelect:R}=e,O=t&&getMacroData$1(t),[I,k]=reactExports.useState(!1),[F,V]=reactExports.useState(!1),$=reactExports.useRef(null),z=React.useCallback(()=>{if($.current&&s&&t&&(document.fonts.check('bold 16px "Fira Sans"',t.label)||x)){const fe=paintKeycap$1($.current,y,K,s.t,t,d,M,b);k(!!fe)}},[$.current,y,t&&t.key,r[0],r[1],s&&s.t,s&&s.c,m,d,M,b]);reactExports.useEffect(z,[t&&t.key,x,s&&s.c,s&&s.t,d,M,b]),reactExports.useEffect(()=>(document.fonts.addEventListener("loadingdone",z),()=>{document.fonts.removeEventListener("loadingdone",z)}),[]);const[X,L]=[-8,0],H=DisplayMode.Test===d?TestKeyState.KeyDown===f?KeycapState.Pressed:KeycapState.Unpressed:F||a?KeycapState.Pressed:KeycapState.Unpressed,[B]=H===KeycapState.Pressed?[X,p[2]]:[L,p[2]+Math.PI*Number(m)],Q=f===TestKeyState.KeyUp,q=DisplayMode.Test===d?H===KeycapState.Unpressed?Q?"mediumvioletred":"lightgrey":"mediumvioletred":(H===KeycapState.Unpressed,"lightgrey"),T=H===KeycapState.Unpressed?Q?.4:0:.6,[j,te,re,de]=reactExports.useMemo(()=>{const fe=()=>{};return c?[fe,fe,fe,fe]:e.mode===DisplayMode.ConfigureColors?[fe,Ee=>{e.onPointerOver&&e.onPointerOver(Ee,v)},fe,Ee=>{e.onPointerDown&&e.onPointerDown(Ee,v)}]:[Ee=>e.onClick(Ee,v),Ee=>{e.onPointerOver&&e.onPointerOver(Ee,v),V(!0)},()=>V(!1),Ee=>{e.onPointerDown&&e.onPointerDown(Ee,v)}]},[c,e.onClick,e.onPointerDown,e.onPointerOver,V,v,d,R]);return m?jsx(EncoderKey,{onClick:j,size:y*CSSVarObject.keyWidth,style:{transform:`translate(${e.position[0]-(CSSVarObject.keyWidth*y-CSSVarObject.keyWidth)/2}px,${y*(CSSVarObject.keyHeight-CSSVarObject.keyWidth)/2+e.position[1]-(CSSVarObject.keyHeight*K-CSSVarObject.keyHeight)/2}px) rotate(${-e.rotation[2]}rad)`,borderRadius:3,color:e.color.c}}):e.clipPath?jsx(ComboKeycap,{...e,onClick:j,onPointerDown:de,onPointerOver:te,onPointerOut:re,keycapZ:B,keycapOpacity:T,keycapColor:q,canvasRef:$,macroData:O,overflowsTexture:I,style:{transform:`translate(${CSSVarObject.keyWidth/2+e.position[0]-(CSSVarObject.keyXPos*y-CSSVarObject.keyXSpacing)/2}px,${CSSVarObject.keyHeight/2+e.position[1]-(CSSVarObject.keyYPos*K-CSSVarObject.keyYSpacing)/2}px) rotate(${-e.rotation[2]}rad)`,width:y*CSSVarObject.keyXPos-CSSVarObject.keyXSpacing,height:K*CSSVarObject.keyYPos-CSSVarObject.keyYSpacing}}):jsx(Fragment,{children:jsxs(KeycapContainer,{onClick:j,onPointerDown:de,onPointerOver:te,onPointerOut:re,style:{transform:`translate(${CSSVarObject.keyWidth/2+e.position[0]-(CSSVarObject.keyXPos*y-CSSVarObject.keyXSpacing)/2}px,${CSSVarObject.keyHeight/2+e.position[1]-(CSSVarObject.keyYPos*K-CSSVarObject.keyYSpacing)/2}px) rotate(${-e.rotation[2]}rad)`,width:y*CSSVarObject.keyXPos-CSSVarObject.keyXSpacing,height:K*CSSVarObject.keyYPos-CSSVarObject.keyYSpacing,cursor:c?"initial":"pointer"},children:[jsxs(GlowContainer,{$selected:a,$multiSelected:R&&l,style:{animation:c?"initial":a?".75s infinite alternate select-glow":"",background:getDarkenedColor(e.color.c,.8),transform:`perspective(100px) translateZ(${B}px)`,borderRadius:3,width:y*CSSVarObject.keyXPos-CSSVarObject.keyXSpacing,height:K*CSSVarObject.keyYPos-CSSVarObject.keyYSpacing},children:[DisplayMode.Test===d?jsx(TestOverlay,{style:{background:q,opacity:T}}):null,jsx(CanvasContainer,{style:{borderRadius:4,background:e.color.c,height:"100%"},children:jsx("canvas",{ref:$,style:{}})})]}),(O||I)&&jsx(TooltipContainer,{$rotate:p[2],children:jsx(Keycap2DTooltip,{children:O||t&&t.tooltipLabel})})]})})},shallowEqual),GlowContainer=styled.div`
|
|
2018
|
+
box-sizing: border-box;
|
|
2019
|
+
padding: 2px 6px 10px 6px;
|
|
2020
|
+
transition: transform 0.2s ease-out;
|
|
2021
|
+
box-shadow: ${e=>e.$multiSelected?"inset -2px -2px 0 rgb(199 21 133 / 80%), inset 2px 2px 0 rgb(199 21 133 / 90%)":"inset -1px -1px 0 rgb(0 0 0 / 20%), inset 1px 1px 0 rgb(255 255 255 / 20%)"};
|
|
2022
|
+
animation: ${e=>e.$selected?".75s infinite alternate select-glow":"initial"};
|
|
2023
|
+
&:hover {
|
|
2024
|
+
transform: perspective(100px) translateZ(-5px);
|
|
2025
|
+
animation: 0.5s 1 forwards select-glow;
|
|
2026
|
+
}
|
|
2027
|
+
`;function getKeycapSharedProps(e,t,r,s,a,l,c,d,p,f){const{position:m,rotation:y,scale:K,color:x,idx:v,onClick:M,onPointerDown:b,onPointerOver:R}=s.coords[t],O=e.ei!==void 0;return{mode:r.mode,position:m,rotation:y,scale:getScale(e,K),textureWidth:e.w,textureHeight:e.h,textureOffsetX:e.w2?Math.abs(e.w2-e.w):0,color:x,shouldRotate:O,onPointerDown:b,onPointerOver:R,keyState:r.pressedKeys?r.pressedKeys[t]:-1,disabled:!r.selectable&&!r.multiSelect,selected:t===a,multiSelected:l!==null&&l.includes(t),idx:v,label:c[t],onClick:M,key:s.indices[t],skipFontCheck:d,dksData:p[t],actuation:f[t],multiSelect:!!r.multiSelect}}const getKeysKeysIndices=e=>(t,r)=>{const s=t.ei!==void 0;return`${e}-${r}-${t.w}-${t.h}-${s}`};function getLabels(e,t,r,s,a){return e.matrixKeycodes.length?e.keys.map((l,c)=>getLabel(e.matrixKeycodes[c],l.w,t,e.definition,r,s,a)):[]}function getKeysKeys(e,t,r,s){const{keys:a}=e,{rowMap:l}=getKeyboardRowPartitions(a),c=a.map(dist.getBoundingBox),[d,p]=[Math.min(...c.map(m=>m.xStart)),Math.min(...c.map(m=>m.yStart))],f=a.map(m=>{const y={...m};return d<0&&(y.x=y.x-d),p<0&&(y.y=y.y-p),y}).map(calculatePointPosition);return{indices:a.map(getKeysKeysIndices(e.definition.vendorProductId)),coords:a.map((m,y)=>{const[K,x]=f[y],v=m.r*(2*Math.PI)/360,M=KeycapMetric.keyXSpacing/KeycapMetric.keyWidth,b=KeycapMetric.keyYSpacing/KeycapMetric.keyHeight,R=(1+M)*(m.w2||m.w)-M,O=m.h*(1+b)-b,I=getMeshName(m,l[getKeyId(m)],!1),k=e.keyColors?y:m.color,F=t[k];return{position:s(K+d,x+p),rotation:[0,0,-v],scale:[R,O,1],color:F,meshKey:I,idx:y,onClick:(V,$)=>{V.stopPropagation(),!e.multiSelect&&r(updateSelectedKey($))},onPointerDown:e.onKeycapPointerDown,onPointerOver:e.onKeycapPointerOver}})}}function useSkipFontCheck(){const[e,t]=reactExports.useState(!1),r=reactExports.useCallback(()=>{t(!1)},[]),s=reactExports.useCallback(()=>{t(!0)},[]);return reactExports.useEffect(()=>{document.fonts.load("Fira Sans").then(r,s)},[]),e}const KeyGroupContainer=styled.div`
|
|
2028
|
+
position: absolute;
|
|
2029
|
+
top: ${e=>CaseInsideBorder*1.5}px;
|
|
2030
|
+
left: ${e=>CaseInsideBorder*1.5}px;
|
|
2031
|
+
`,getPosition$1=(e,t)=>[e-CSSVarObject.keyWidth/2,t-CSSVarObject.keyHeight/2,0],getRGBArray=e=>e.map(([t,r])=>{const s=getRGB({hue:Math.round(255*t/360),sat:Math.round(255*r)}),a=`#${new Color(s).getHexString()}`;return{c:a,t:a}}),KeyGroup$1=e=>{const t=useAppDispatch(),r=useAppSelector(getSelectedKey),s=useAppSelector(getSelectedKeys),a=useAppSelector(getSelectedTheme),l=useAppSelector(getExpressions),c=useSkipFontCheck(),d=e.keyColors?getRGBArray(e.keyColors):a,{basicKeyToByte:p,byteToKey:f}=useAppSelector(getBasicKeyToByte),m=useAppSelector(V=>V.macros),{keys:y,selectedKey:K}=e,x=K===void 0?r:K,v=reactExports.useMemo(()=>getKeysKeys(e,d,t,getPosition$1),[y,d,e.onKeycapPointerDown,e.onKeycapPointerOver]),M=useAppSelector(getSelectedDksmap)||[],b=useAppSelector(getSelectedActuationMap)||[],R=useAppSelector(getTapDanceKeycodes),O=reactExports.useMemo(()=>getLabels(e,l,p,f,R),[y,e.matrixKeycodes,m,e.definition,R]),{width:I,height:k}=calculateKeyboardFrameDimensions(y),F=reactExports.useMemo(()=>e.keys.map((V,$)=>V.d?null:jsx(Keycap$1,{...getComboKeyProps(V),...getKeycapSharedProps(V,$,e,v,x,s,O,c,M,b)})),[y,x,s,O,e.pressedKeys,e.selectable,d,e.definition.vendorProductId,c,e.mode,M,b,e.multiSelect]);return jsx(KeyGroupContainer,{height:k,width:I,style:{pointerEvents:e.selectable||e.multiSelect?"all":"none"},children:F})},generateRowColArray=(e,t,r)=>{const s=e.filter(c=>c.ei===void 0&&!c.d),a=s.reduce((c,d)=>(c[d.row][d.col]=calculatePointPosition(d),c),Array(t).fill(0).map(()=>Array(r).fill(0))).map(c=>c.sort((d,p)=>d[0]-p[0])),l=s.reduce((c,d)=>(c[d.col][d.row]=calculatePointPosition(d),c),Array(r).fill(0).map(()=>Array(t).fill(0))).map(c=>c.sort((d,p)=>d[1]-p[1]));return{rowKeys:a,colKeys:l}},Matrix=({rowKeys:e,colKeys:t})=>jsxs(SVG,{style:{position:"absolute",top:CSSVarObject.insideBorder,left:CSSVarObject.insideBorder},children:[e.map((r,s)=>jsx(RowLine,{points:r.map(a=>(a||[]).join(",")).join(" ")},s)),t.map((r,s)=>jsx(ColLine,{points:r.map(a=>(a||[]).join(",")).join(" ")},s))]}),SVG=styled.svg`
|
|
2032
|
+
transform: rotateZ(0);
|
|
2033
|
+
width: 100%;
|
|
2034
|
+
height: 100%;
|
|
2035
|
+
`,RowLine=styled.polyline`
|
|
2036
|
+
stroke: var(--color_accent);
|
|
2037
|
+
stroke-width: 3;
|
|
2038
|
+
fill-opacity: 0;
|
|
2039
|
+
stroke-opacity: 0.4;
|
|
2040
|
+
stroke-linecap: round;
|
|
2041
|
+
`,ColLine=styled.polyline`
|
|
2042
|
+
stroke: var(--color_light-grey);
|
|
2043
|
+
stroke-width: 3;
|
|
2044
|
+
fill-opacity: 0;
|
|
2045
|
+
stroke-opacity: 0.4;
|
|
2046
|
+
stroke-linecap: round;
|
|
2047
|
+
`,MatrixLines$1=({keys:e,rows:t,cols:r,width:s,height:a})=>{const{rowKeys:l,colKeys:c}=generateRowColArray(e,t,r);return jsx(Matrix,{rowKeys:l,colKeys:c})},KeyboardCanvas$1=e=>{const{containerDimensions:t,shouldHide:r,...s}=e,{width:a,height:l}=reactExports.useMemo(()=>calculateKeyboardFrameDimensions(s.keys),[s.keys]),c=t.height,d=35,p=Math.min(Math.min(1,t&&t.width/((CSSVarObject.keyWidth+CSSVarObject.keyXSpacing)*a-CSSVarObject.keyXSpacing+d*2)),c/((CSSVarObject.keyHeight+CSSVarObject.keyYSpacing)*l-CSSVarObject.keyYSpacing+d*2))||1;return jsx("div",{style:{transform:`scale(${p}, ${p})`,opacity:r?0:1,position:"absolute",pointerEvents:r?"none":"all"},children:jsx(KeyboardCanvasContent$1,{...s,width:a,height:l})})},KeyboardGroup$2=styled.div`
|
|
2048
|
+
position: relative;
|
|
2049
|
+
`,KeyboardCanvasContent$1=React.memo(e=>{const{matrixKeycodes:t,keys:r,definition:s,pressedKeys:a,mode:l,showMatrix:c,selectable:d,width:p,height:f}=e;return jsxs(KeyboardGroup$2,{children:[jsx(Case$1,{width:p,height:f}),jsx(KeyGroup$1,{...e,keys:r,mode:l,matrixKeycodes:t,selectable:d,definition:s,pressedKeys:a}),c&&jsx(MatrixLines$1,{keys:r,rows:s.matrix.rows,cols:s.matrix.cols,width:p,height:f})]})},shallowEqual),Heart=React.memo(e=>{const t=Math.atan(2/e.caseWidth),r=(80+-30)/2,s=2,a=1,c=-(-e.caseWidth-a*2-s*2)/Math.cos(t),d=.1*c/22,p=95,f=95*d,m=(c-f)/2,y=reactExports.useMemo(()=>{const x=new Shape;return x.moveTo(d*(25-r),d*(25-p)),x.bezierCurveTo(d*(25-r),d*(25-p),d*(20-r),d*(0-p),d*(0-r),d*(0-p)),x.bezierCurveTo(d*(-30-r),d*(0-p),d*(-30-r),d*(35-p),d*(-30-r),d*(35-p)),x.bezierCurveTo(d*(-30-r),d*(55-p),d*(-10-r),d*(77-p),d*(25-r),d*(95-p)),x.bezierCurveTo(d*(60-r),d*(77-p),d*(80-r),d*(55-p),d*(80-r),d*(35-p)),x.bezierCurveTo(d*(80-r),d*(35-p),d*(80-r),d*(0-p),d*(50-r),d*(0-p)),x.bezierCurveTo(d*(35-r),d*(0-p),d*(25-r),d*(25-p),d*(25-r),d*(25-p)),x},[e.caseWidth,e.caseHeight,e.color]),K={depth:4,bevelEnabled:!0,bevelSegments:10,bevelSize:1,bevelThickness:1};return jsxs("mesh",{position:[-c+m,s*2+a*2+e.caseHeight/2,0],scale:1,rotation:[Math.PI/2,t,Math.PI/2],children:[jsx("extrudeGeometry",{attach:"geometry",args:[y,K]}),jsx("meshPhongMaterial",{color:e.color,transparent:!0,opacity:1})]})},shallowEqual),makeShape2=e=>{const t=Math.tan(Math.PI*7.5/180),r=10,s=r+t*e,a=e/2,l=new Shape;let c=2,d=Math.PI/2;return l.moveTo(-s,a),l.absarc(-s-c,a-c,c,d*1+d,d*1,!0),l.absarc(-c,a,c,d*1,d*1-d,!0),l.absarc(-c,-a,c,d*3+d,d*3,!0),l.absarc(-r-c,-a-c,c,d*2+d,d*2,!0),l},Case=React.memo(e=>{const t=useAppSelector(getSelectedTheme),r=reactExports.useMemo(()=>t[dist.KeyColorType.Accent].c,[t]),s="#212020",a=reactExports.useMemo(()=>t[dist.KeyColorType.Accent].t,[t]),l=e.width*KeycapMetric.keyXPos-KeycapMetric.keyXSpacing,c=KeycapMetric.keyYPos*e.height-KeycapMetric.keyYSpacing,d=4,p=l+d*1,f=l+d*2.5,[m,y]=reactExports.useMemo(()=>[c+d,c+d*2].map(makeShape2),[c]),K=1,x=10,b=10+Math.tan(Math.PI*7.5/180)*(c+d*2);return jsxs("group",{scale:1,"position-z":-K*2,"rotation-y":-Math.PI/2,children:[jsx(Heart,{caseWidth:b,caseHeight:c,color:a}),jsxs("mesh",{position:[-K,0,-f/2],castShadow:!0,children:[jsx("extrudeGeometry",{attach:"geometry",args:[y,{depth:f,bevelEnabled:!0,bevelSize:K,bevelThickness:K,bevelSegments:x}]}),jsx("meshPhongMaterial",{color:r,shininess:100,reflectivity:1,specular:getDarkenedColor(r,.2)})]}),jsxs("mesh",{position:[0,0,-p/2],castShadow:!0,children:[jsx("extrudeGeometry",{attach:"geometry",args:[m,{depth:p,bevelEnabled:!0,bevelSize:K/2,bevelThickness:K,bevelSegments:x}]}),jsx("meshPhongMaterial",{color:s,shininess:100,reflectivity:1,specular:getDarkenedColor(r,.2)})]})]})}),getMacroData=({macroExpression:e,label:t})=>t&&t.length>15?t:e&&e.length?e:null,paintEncoder=(e,[t,r],s,a)=>{const[d,p]=[512*t,512*r];e.width=d,e.height=p;const f=e.getContext("2d"),m=2.6;if(f){f.fillStyle=s,f.clearRect(0,0,e.width,e.height),f.fillRect(0,0,e.width,e.height),f.fill(),f.fillStyle=a;const y=.4*d/m;f.ellipse(.5*d/m,2.1*p/m,y,y,Math.PI/4,0,2*Math.PI),f.fill()}},paintKeycapLabel=(e,t,r,s,a,l,c)=>{const d=e.getContext("2d");if(d==null)return;const p="Fira Sans, Arial Rounded MT, Arial Rounded MT Bold, Arial",f={x:.015,y:.02},m={x:.01,y:-.01},y={x:.01,y:.02};if(d.beginPath(),d.moveTo(t.bl.x*e.width,(1-t.bl.y)*e.height),d.lineTo(t.bl.x*e.width,(1-t.tr.y)*e.height),d.lineTo(t.tr.x*e.width,(1-t.tr.y)*e.height),d.lineTo(t.tr.x*e.width,(1-t.bl.y)*e.height),d.lineTo(t.bl.x*e.width,(1-t.bl.y)*e.height),d.clip(),d.fillStyle=r,DisplayMode.ConfigureAP===a||DisplayMode.ConfigureRT===a||DisplayMode.ConfigureDKS===a){let x=30,v=.75*x/e.height,M=(t.tr.y+t.bl.y)/2;t.bl.x*e.width;const b=t.tr.x*e.width,R=(1-(t.tr.y-v-.01))*e.height,O=(1-(t.bl.y+.015))*e.height;d.font=`${x}px ${p}`,d.textAlign="right";const I=(l==null?void 0:l.apData)!==void 0,k=(l==null?void 0:l.rtData)!==void 0&&l.rtData.enabled;if(DisplayMode.ConfigureAP===a&&(c?d.fillText("DKS",b,O):I&&d.fillText(l.apData.ap.toFixed(2),b,O)),DisplayMode.ConfigureRT===a&&(c?d.fillText("DKS",b,O):(d.textAlign="right",k&&d.fillText(l.rtData.rt1.toFixed(2),b,R),d.textAlign="right",k&&d.fillText(l.rtData.rt2.toFixed(2),b,O))),DisplayMode.ConfigureDKS===a)if(c)d.fillText("DKS",b,O);else{const V=[];k&&V.push("RT"),k&&d.fillText(V.join(","),b,R)}x=37.5*s.size,v=.75*x/e.height,d.textAlign="start",d.font=`bold ${x}px ${p}`;const F=s.label||s.key;return d.fillText(F,(t.bl.x+m.x)*e.width,(1-(M-.5*v-m.y))*e.height),d.measureText(F).width>(t.tr.x-(t.bl.x+m.x))*e.width}if(d.textAlign="left",s!==void 0){if(s.topLabel&&s.bottomLabel){let x=52,v=.75*x/e.height,M=s.offset[0]*v,b=s.offset[1]*v;d.font=`bold ${x}px ${p}`,d.fillText(s.topLabel,(t.bl.x+f.x)*e.width,(1-(t.tr.y-v-f.y-M))*e.height),d.fillText(s.bottomLabel,(t.bl.x+f.x)*e.width,(1-(t.bl.y+f.y+b))*e.height)}else if(s.centerLabel){let x=37.5*s.size,v=.75*x/e.height,M=(t.tr.y+t.bl.y)/2;return d.font=`bold ${x}px ${p}`,d.fillText(s.label,(t.bl.x+m.x)*e.width,(1-(M-.5*v-m.y))*e.height),d.measureText(s.centerLabel).width>(t.tr.x-(t.bl.x+m.x))*e.width}else if(typeof s.label=="string"){let x=75,v=.75*x/e.height;d.font=`bold ${x}px ${p}`,d.fillText(s.label,(t.bl.x+y.x)*e.width,(1-(t.tr.y-v-y.y))*e.height)}}},calculateTextureRects=(e,t,r,s,a)=>{const l=.3846153846153846,p=.445/19.05*l;let f=Math.min(2.75,r),m=Math.min(2.75,s);(e>1||t>1)&&(f=1,m=1);let y={bl:{x:p,y:p},tr:{x:f*l-p,y:m*l-p}},K={bl:{x:y.bl.x+.07,y:y.bl.y+.08},tr:{x:y.tr.x-.07,y:y.tr.y-.0146}};return a>0&&(K.bl.x+=a*l,K.tr.x+=a*l,y.bl.x+=a*l,y.tr.x+=a*l),{keycapRect:y,faceRect:K}},paintKeycap=(e,[t,r],s,a,l,c,d,p,f,m,y)=>{const K=calculateTextureRects(t,r,s,a,p),x=512;e.width=x*t,e.height=x*r;const v=e.getContext("2d");if(v!=null)return v.fillStyle=l,v.fillRect(0,0,e.width,e.height),paintKeycapLabel(e,K.faceRect,c,d,f,m,y)},Keycap=React.memo(e=>{const{label:t,scale:r,color:s,onClick:a,selected:l,multiSelected:c,disabled:d,mode:p,rotation:f,keyState:m,shouldRotate:y,keycapGeometry:K,textureOffsetX:x,textureWidth:v,textureHeight:M,onPointerOver:b,onPointerDown:R,idx:O,actuation:I,multiSelect:k,dksData:F}=e,V=reactExports.useRef(),$=t&&getMacroData(t),[z,X]=reactExports.useState(!1),[L,H]=reactExports.useState(!1),B=reactExports.useRef(),Q=reactExports.useRef(document.createElement("canvas")),q=React.useCallback(()=>{if(Q.current&&s){if(y)paintEncoder(Q.current,[r[0],r[1]],s.c,s.t);else{const ue=paintKeycap(Q.current,[r[0],r[1]],v,M,s.c,s.t,t,x,p,I,F);X(!!ue)}B.current.needsUpdate=!0}},[Q.current,v,t&&t.key,r[0],r[1],s&&s.t,s&&s.c,y,p,I,F]);reactExports.useEffect(q,[t&&t.key,s&&s.c,s&&s.t,p,I,F]);const T=J({config:{duration:800},from:{x:0,y:"#f4a0a0"},loop:l?{reverse:!0}:!1,to:{x:100,y:"#b49999"}});let j=K.boundingBox.max.z;const[te,re]=[j,j+8],de=DisplayMode.Test===p?TestKeyState.KeyDown===m?KeycapState.Pressed:KeycapState.Unpressed:L||l?KeycapState.Unpressed:KeycapState.Pressed,[fe,Ee]=de===KeycapState.Pressed?[te,f[2]]:[re,f[2]+Math.PI*Number(y)],$e=m===TestKeyState.KeyUp,Qe=DisplayMode.Test===p?de===KeycapState.Unpressed?$e?"palevioletred":"lightgrey":"pink":(de===KeycapState.Unpressed,"lightgrey"),{z:Xe,b:_e,rotateZ:Pe,tooltipScale:ot}=J({config:{duration:100},z:fe,b:Qe,rotateZ:Ee,tooltipScale:L?1:0}),[qe,ne,se,Me]=reactExports.useMemo(()=>{const ue=()=>{};return d?[ue,ue,ue,ue]:e.mode===DisplayMode.ConfigureColors?[ue,me=>{b&&b(me,O)},ue,me=>{R&&R(me,O)}]:[me=>a(me,O),me=>{b&&b(me,O),H(!0)},()=>H(!1),me=>{R&&R(me,O)}]},[d,a,R,b,H,O,p,k]),ge=E.meshPhongMaterial;return jsxs(Fragment,{children:[jsx(E.mesh,{...e,ref:V,"position-z":Xe,"rotation-z":Pe,onClick:qe,onPointerDown:Me,onPointerOver:ne,onPointerOut:se,geometry:K,children:jsx(ge,{attach:"material",color:l?T.y:k&&c?"palevioletred":_e,children:jsx("canvasTexture",{ref:B,attach:"map",image:Q.current})})}),($||z)&&jsx(React.Suspense,{fallback:null,children:jsx(E.group,{position:e.position,"position-z":20,scale:ot,children:jsx(Html,{transform:!0,style:{pointerEvents:"none"},children:jsx(KeycapTooltip,{children:$||t&&t.tooltipLabel})})})})]})},shallowEqual),glbSrc="/assets/keyboard_components-1a09821a.glb",getSRGBArray=e=>e.map(([t,r])=>{const s=getRGB({hue:Math.round(255*t/360),sat:Math.round(255*r)}),a=`#${new Color(s).convertSRGBToLinear().getHexString()}`;return{c:a,t:a}}),getPosition=(e,t)=>[KeycapMetric.keyXPos*e/CSSVarObject.keyXPos,-t*KeycapMetric.keyYPos/CSSVarObject.keyYPos,0],KeyGroup=e=>{const t=useAppDispatch(),r=useGLTF(glbSrc,!0).scene,s=useAppSelector(getSelectedKey),a=useAppSelector(getSelectedKeys),l=useAppSelector(getSelectedSRGBTheme),c=useAppSelector(getExpressions),d=useSkipFontCheck(),p=e.keyColors?getSRGBArray(e.keyColors):l,{basicKeyToByte:f,byteToKey:m}=useAppSelector(getBasicKeyToByte),y=useAppSelector($=>$.macros),{keys:K,selectedKey:x}=e,v=x===void 0?s:x,M=reactExports.useMemo(()=>getKeysKeys(e,p,t,getPosition),[K,p,e.onKeycapPointerDown,e.onKeycapPointerOver]),b=useAppSelector(getSelectedDksmap)||[],R=useAppSelector(getSelectedActuationMap)||[],O=useAppSelector(getTapDanceKeycodes),I=reactExports.useMemo(()=>getLabels(e,c,f,m,O),[K,e.matrixKeycodes,y,e.definition]),{width:k,height:F}=calculateKeyboardFrameDimensions(K),V=reactExports.useMemo(()=>e.keys.map(($,z)=>{const{meshKey:X}=M.coords[z];return $.d?null:jsx(Keycap,{keycapGeometry:(r.getObjectByName(X)||r.getObjectByName("K-R1-100")).geometry,...getKeycapSharedProps($,z,e,M,v,a,I,d,b,R)})}),[K,v,a,I,e.pressedKeys,e.selectable,p,e.definition.vendorProductId,d,e.mode,b,R,e.multiSelect]);return jsx("group",{scale:1,position:[(-k*KeycapMetric.keyXPos+KeycapMetric.keyXSpacing)/2,(KeycapMetric.keyYPos*F-KeycapMetric.keyYSpacing)/2,0],children:V})},MatrixLines=({keys:e,rows:t,cols:r,width:s,height:a})=>{const[l,c]=["lightpink","lightgrey"],{rowKeys:d,colKeys:p}=generateRowColArray(e,t,r);return jsx("group",{scale:.35,rotation:[Math.PI,0,0],position:[-s*KeycapMetric.keyXPos/2,(a+.4)*KeycapMetric.keyYPos/2,11],children:jsxs(Segments,{lineWidth:1,children:[d.flatMap(f=>{const m=f.filter(y=>y);return m.length>=2?m.reduce((y,K,x)=>y.prev===null?{res:[],prev:K}:{res:[...y.res,jsx(Segment,{start:[y.prev[0],y.prev[1],0],end:[K[0],K[1],0],color:l},`row-${x}`)],prev:K},{res:[],prev:null}).res:[]}),p.flatMap(f=>{const m=f.filter(y=>y);return m.length>=2?m.reduce((y,K,x)=>y.prev===null?{res:[],prev:K}:{res:[...y.res,jsx(Segment,{start:[y.prev[0],y.prev[1],0],end:[K[0],K[1],0],color:c},`col-${x}`)],prev:K},{res:[],prev:null}).res:[]})]})},`${t}-${r}-${s}-${a}`)},KeyboardCanvas=e=>{const{containerDimensions:t,shouldHide:r,...s}=e,{width:a,height:l}=reactExports.useMemo(()=>calculateKeyboardFrameDimensions(s.keys),[s.keys]),[c,d]=reactExports.useState(!1),{verticalPostion:p,tilt:f}=J({config:{tension:35,friction:5,mass:.3},verticalPostion:c?1:-3,tilt:c?-.15:0});reactExports.useEffect(()=>{const y=document.querySelector("canvas");y&&(y.addEventListener("mouseenter",()=>{d(!0)}),y.addEventListener("mouseleave",()=>{d(!1)}))},[]);const m=Math.min(Math.min(1,t&&t.width/((CSSVarObject.keyWidth+CSSVarObject.keyXSpacing)*a-CSSVarObject.keyXSpacing+70)),500/((CSSVarObject.keyHeight+CSSVarObject.keyYSpacing)*l-CSSVarObject.keyYSpacing+70))||1;return jsx("group",{position:[0,-0,-19],scale:.015*m,visible:!r,children:jsx(KeyboardCanvasContent,{...s,width:a,height:l,verticalPostion:p,tilt:f})})},KeyboardCanvasContent=React.memo(e=>{const{matrixKeycodes:t,keys:r,definition:s,pressedKeys:a,mode:l,showMatrix:c,selectable:d,width:p,height:f,verticalPostion:m,tilt:y}=e;return jsx(E.group,{"position-y":m,"rotation-x":y,children:jsxs(PresentationControls,{enabled:e.mode!==DisplayMode.ConfigureColors,global:!0,snap:!0,speed:1,zoom:1,polar:[-Math.PI/10,Math.PI/10],azimuth:[-Math.PI/16,Math.PI/16],config:{mass:1,tension:170,friction:26},children:[jsx(Case,{width:p,height:f}),jsx(KeyGroup,{...e,keys:r,mode:l,matrixKeycodes:t,selectable:d,definition:s,pressedKeys:a}),c&&jsx(MatrixLines,{keys:r,rows:s.matrix.rows,cols:s.matrix.cols,width:p,height:f})]})})},shallowEqual),useGlobalKeys=e=>{const t=!e,r=reactExports.useState({}),[s,a]=r;function l(d){d.preventDefault(),!t&&!d.repeat&&s[getIndexByEvent(d)??-1]!==TestKeyState.KeyDown&&a(p=>({...p,[getIndexByEvent(d)]:TestKeyState.KeyDown}))}const c=d=>{d.preventDefault(),!t&&s[getIndexByEvent(d)]!==TestKeyState.KeyUp&&a(p=>({...p,[getIndexByEvent(d)]:TestKeyState.KeyUp}))};return reactExports.useEffect(()=>(e&&(window.addEventListener("keydown",l),window.addEventListener("keyup",c)),()=>{window.removeEventListener("keydown",l),window.removeEventListener("keyup",c)}),[e]),r},invertTestKeyState=e=>e===TestKeyState.KeyDown?TestKeyState.KeyUp:TestKeyState.KeyDown,useMatrixTest=(e,t,r,s)=>{const a=reactExports.useState([]),[,l]=a,c=useDispatch(),d=reactExports.useRef(e);reactExports.useEffect(()=>{let m=[];const y=()=>{d.current=!1},K=async(x,v,M,b)=>{if(e&&x&&M){const{cols:R,rows:O}=M.matrix,I=Math.ceil(R/8),k=Math.floor(28/I);try{let F=[];for(let $=0;$<O;$+=k){const z=Math.min(O*I-F.length,I*k);F.push(...await x.getKeyboardValue(KeyboardValue.SWITCH_MATRIX_STATE,v>=12?[$]:[],z))}if(!F.some(($,z)=>$^(b[z]||0))){await x.timeout(20),d.current&&K(x,v,M,b);return}l($=>F.reduce((z,X,L)=>{const H=X^(b[L]||0);if(H===0)return z;const B=~~(L/I),Q=8*(I-1-L%I);return Array(Math.max(0,Math.min(8,R-Q))).fill(0).reduce((q,T,j)=>{const te=R*B+j+Q;return q[te]=(H>>j&1)===1?invertTestKeyState(q[te]):q[te],q},z)},Array.isArray($)&&$.length===O*R?[...$]:Array(O*R).fill(TestKeyState.Initial))),await x.timeout(20),d.current&&K(x,v,M,F)}catch{d.current=!1,c(setTestMatrixEnabled(!1))}}};return e&&t&&r&&s&&(d.current=!0,K(t,r.protocol,s,m)),()=>{y()}},[e,s,t]);const p=m=>{m.preventDefault()},f=m=>{m.preventDefault()};return reactExports.useEffect(()=>(e&&(window.addEventListener("keydown",p),window.addEventListener("keyup",f)),()=>{window.removeEventListener("keydown",p),window.removeEventListener("keyup",f)}),[e]),a},useColorPainter=(e,t)=>{const r=useAppSelector(getSelectedConnectedDevice),s=useAppSelector(getSelectedKeyboardAPI),a=useAppSelector(getSelectedCustomMenuData)||{__perKeyRGB:[]},[l,c]=reactExports.useState([]);reactExports.useEffect(()=>{const p=a.__perKeyRGB??[],m=(e.find(y=>"li"in y)?e.map(y=>y.li??-1):[]).map(y=>{const K=p[y??-1];if(K)return getHSVFrom256(K)});c(m)},[a.__perKeyRGB&&a.__perKeyRGB.length,e]);const d=reactExports.useCallback((p,f)=>{if(p.buttons===1&&s){const m=Math.round(t[0]*255/360),y=Math.round(t[1]*255),K=e[f].li;K!==void 0&&(s.setPerKeyRGBMatrix(K,m,y),s.commitCustomMenu(0),c(x=>(x[f]=t,[...x])))}},[c,t,e,r]);return{keyColors:l,onKeycapPointerDown:d,onKeycapPointerOver:d}};styled.div`
|
|
2050
|
+
display: flex;
|
|
2051
|
+
margin-left: 50px;
|
|
2052
|
+
margin-bottom: 10px;
|
|
2053
|
+
font-size: 12px;
|
|
2054
|
+
`;styled.div`
|
|
2055
|
+
width: 30px;
|
|
2056
|
+
height: 30px;
|
|
2057
|
+
border: 2px solid var(--color_accent);
|
|
2058
|
+
border-radius: 5px;
|
|
2059
|
+
color: var(--color_accent);
|
|
2060
|
+
`;styled.div`
|
|
2061
|
+
width: 100px;
|
|
2062
|
+
display: flex;
|
|
2063
|
+
flex-direction: column;
|
|
2064
|
+
align-items: center;
|
|
2065
|
+
`;styled.div`
|
|
2066
|
+
padding: 5px 0;
|
|
2067
|
+
text-decoration: ${e=>e.$enable?"underline":"none"};
|
|
2068
|
+
cursor: ${e=>e.$enable?"pointer":"default"};
|
|
2069
|
+
color: var(--color_label-highlighted);
|
|
2070
|
+
pointer-events: ${e=>e.$enable?"auto":"none"};
|
|
2071
|
+
`;styled.dialog`
|
|
2072
|
+
padding: 0;
|
|
2073
|
+
border-width: 0;
|
|
2074
|
+
|
|
2075
|
+
background: transparent;
|
|
2076
|
+
&::backdrop {
|
|
2077
|
+
background: rgba(0, 0, 0, 0.75);
|
|
2078
|
+
}
|
|
2079
|
+
|
|
2080
|
+
& > div {
|
|
2081
|
+
transition: transform 0.2s ease-out;
|
|
2082
|
+
transform: translateY(-20px);
|
|
2083
|
+
}
|
|
2084
|
+
|
|
2085
|
+
&[open] > div {
|
|
2086
|
+
transform: translateY(0px);
|
|
2087
|
+
}
|
|
2088
|
+
`;styled.div`
|
|
2089
|
+
display: flex;
|
|
2090
|
+
justify-content: center;
|
|
2091
|
+
align-items: center;
|
|
2092
|
+
`;styled(AccentRange)`
|
|
2093
|
+
transform: rotate(90deg);
|
|
2094
|
+
transform-origin: center;
|
|
2095
|
+
height: 150px;
|
|
2096
|
+
width: 150px;
|
|
2097
|
+
`;styled.div`
|
|
2098
|
+
position: relative;
|
|
2099
|
+
`;styled.div.attrs(e=>e.$max===e.$min?{}:{style:{top:134/(e.$max-e.$min)*(e.$value-e.$min)+4}})`
|
|
2100
|
+
position: absolute;
|
|
2101
|
+
left: 100px;
|
|
2102
|
+
font-size: 12px;
|
|
2103
|
+
color: var(--color_accent);
|
|
2104
|
+
`;styled.div`
|
|
2105
|
+
position: absolute;
|
|
2106
|
+
top: -2px;
|
|
2107
|
+
font-size: 12px;
|
|
2108
|
+
left: 10px;
|
|
2109
|
+
color: var(--color_accent);
|
|
2110
|
+
`;styled.div`
|
|
2111
|
+
position: absolute;
|
|
2112
|
+
bottom: 2px;
|
|
2113
|
+
font-size: 12px;
|
|
2114
|
+
left: 10px;
|
|
2115
|
+
color: var(--color_accent);
|
|
2116
|
+
`;const size=100,minSize=24;styled.div.attrs(e=>({style:{width:e.$width+"px"}}))`
|
|
2117
|
+
position: absolute;
|
|
2118
|
+
z-index: 1;
|
|
2119
|
+
top: 0;
|
|
2120
|
+
left: 0;
|
|
2121
|
+
background: var(--color_accent);
|
|
2122
|
+
border-radius: ${minSize}px;
|
|
2123
|
+
height: ${minSize}px;
|
|
2124
|
+
cursor: pointer;
|
|
2125
|
+
`;styled.div`
|
|
2126
|
+
width: ${minSize}px;
|
|
2127
|
+
height: ${minSize}px;
|
|
2128
|
+
display: flex;
|
|
2129
|
+
justify-content: center;
|
|
2130
|
+
align-items: center;
|
|
2131
|
+
color: var(--color_label-highlighted);
|
|
2132
|
+
border-radius: ${minSize}px;
|
|
2133
|
+
background: var(--bg_control);
|
|
2134
|
+
`;styled.div.attrs(e=>({style:{left:size*e.$index+"px"}}))`
|
|
2135
|
+
position: absolute;
|
|
2136
|
+
height: ${minSize}px;
|
|
2137
|
+
`;styled.div.attrs(e=>({style:{left:e.$width>0?e.$width-minSize/2+minSize/4+"px":"0px",cursor:e.$width>0?"ew-resize":"pointer",width:e.$width>0?minSize/2+"px":minSize+"px"}}))`
|
|
2138
|
+
position: absolute;
|
|
2139
|
+
z-index: 2;
|
|
2140
|
+
height: ${minSize}px;
|
|
2141
|
+
top: 0;
|
|
2142
|
+
`;styled.div`
|
|
2143
|
+
border: 4px solid
|
|
2144
|
+
${e=>e.$active?"var(--color_accent)":"var(--border_color_icon)"};
|
|
2145
|
+
width: 50px;
|
|
2146
|
+
height: 50px;
|
|
2147
|
+
border-radius: 10px;
|
|
2148
|
+
background: var(--bg_control);
|
|
2149
|
+
margin-right: 30px;
|
|
2150
|
+
cursor: pointer;
|
|
2151
|
+
text-align: center;
|
|
2152
|
+
line-height: 18px;
|
|
2153
|
+
display: flex;
|
|
2154
|
+
justify-content: center;
|
|
2155
|
+
align-items: center;
|
|
2156
|
+
font-size: 14px;
|
|
2157
|
+
// position: relative;
|
|
2158
|
+
// padding: 0;
|
|
2159
|
+
// &:hover {
|
|
2160
|
+
// background: var(--bg_control);
|
|
2161
|
+
// border: 4px solid
|
|
2162
|
+
// ${e=>e.$active?"var(--color_accent)":"var(--border_color_icon)"};
|
|
2163
|
+
// }
|
|
2164
|
+
`;styled.div`
|
|
2165
|
+
white-space: pre-wrap;
|
|
2166
|
+
text-overflow: ellipsis;
|
|
2167
|
+
overflow: hidden;
|
|
2168
|
+
user-select: none;
|
|
2169
|
+
color: var(--color_label-highlighted);
|
|
2170
|
+
`;styled.div`
|
|
2171
|
+
padding: 5px 0;
|
|
2172
|
+
display: flex;
|
|
2173
|
+
align-items: center;
|
|
2174
|
+
`;styled.div`
|
|
2175
|
+
width: 330px;
|
|
2176
|
+
display: flex;
|
|
2177
|
+
align-items: center;
|
|
2178
|
+
overflow: hidden;
|
|
2179
|
+
position: relative;
|
|
2180
|
+
height: 24px;
|
|
2181
|
+
`;styled.div``;styled.div`
|
|
2182
|
+
display: grid;
|
|
2183
|
+
grid-template-columns: repeat(auto-fill, 64px);
|
|
2184
|
+
grid-auto-rows: 64px;
|
|
2185
|
+
justify-content: center;
|
|
2186
|
+
grid-gap: 10px;
|
|
2187
|
+
`;styled.div`
|
|
2188
|
+
padding: 10px 10px 0;
|
|
2189
|
+
display: flex;
|
|
2190
|
+
`;styled(Button)`
|
|
2191
|
+
width: 50px;
|
|
2192
|
+
height: 50px;
|
|
2193
|
+
line-height: 18px;
|
|
2194
|
+
border-radius: 64px;
|
|
2195
|
+
font-size: 14px;
|
|
2196
|
+
border: 4px solid var(--border_color_icon);
|
|
2197
|
+
background: var(--bg_control);
|
|
2198
|
+
color: var(--color_label-highlighted);
|
|
2199
|
+
margin: 0;
|
|
2200
|
+
box-shadow: none;
|
|
2201
|
+
position: relative;
|
|
2202
|
+
border-radius: 10px;
|
|
2203
|
+
&:hover {
|
|
2204
|
+
border-color: var(--color_accent);
|
|
2205
|
+
transform: translate3d(0, -2px, 0);
|
|
2206
|
+
}
|
|
2207
|
+
${e=>e.disabled&&"cursor:not-allowed;filter:opacity(50%);"}
|
|
2208
|
+
`;styled.div`
|
|
2209
|
+
text-overflow: ellipsis;
|
|
2210
|
+
overflow: hidden;
|
|
2211
|
+
`;styled(Button)`
|
|
2212
|
+
width: 50px;
|
|
2213
|
+
height: 50px;
|
|
2214
|
+
line-height: 18px;
|
|
2215
|
+
border-radius: 10px;
|
|
2216
|
+
font-size: 14px;
|
|
2217
|
+
border: 4px solid var(--border_color_icon);
|
|
2218
|
+
background: var(--color_accent);
|
|
2219
|
+
border-color: var(--color_inside_accent);
|
|
2220
|
+
color: var(--color_inside_accent);
|
|
2221
|
+
margin: 0;
|
|
2222
|
+
`;styled.div`
|
|
2223
|
+
padding: 12px;
|
|
2224
|
+
padding-bottom: 30px;
|
|
2225
|
+
`;styled.div`
|
|
2226
|
+
position: fixed;
|
|
2227
|
+
bottom: 0;
|
|
2228
|
+
background: #d9d9d97a;
|
|
2229
|
+
box-sizing: border-box;
|
|
2230
|
+
transition: opacity 0.4s ease-out;
|
|
2231
|
+
height: 25px;
|
|
2232
|
+
width: 100%;
|
|
2233
|
+
line-height: 14px;
|
|
2234
|
+
padding: 5px;
|
|
2235
|
+
font-size: 14px;
|
|
2236
|
+
opacity: 1;
|
|
2237
|
+
pointer-events: none;
|
|
2238
|
+
&:empty {
|
|
2239
|
+
opacity: 0;
|
|
2240
|
+
}
|
|
2241
|
+
`;styled.div`
|
|
2242
|
+
display: flex;
|
|
2243
|
+
width: 100%;
|
|
2244
|
+
`;styled.div`
|
|
2245
|
+
width: 450px;
|
|
2246
|
+
margin-right: 10px;
|
|
2247
|
+
flex-shrink: 0;
|
|
2248
|
+
padding-top: 10px;
|
|
2249
|
+
`;styled.div`
|
|
2250
|
+
width: 100%;
|
|
2251
|
+
display: block;
|
|
2252
|
+
border: 1px solid var(--border_color_cell);
|
|
2253
|
+
border-style: dashed;
|
|
2254
|
+
padding: 20px 20px;
|
|
2255
|
+
border-radius: 15px;
|
|
2256
|
+
box-sizing: border-box;
|
|
2257
|
+
text-align: center;
|
|
2258
|
+
color: var(--color_label-highlighted);
|
|
2259
|
+
`;styled.div`
|
|
2260
|
+
height: calc(100vh - 580px);
|
|
2261
|
+
padding-left: 10px;
|
|
2262
|
+
overflow-y: auto;
|
|
2263
|
+
width: 100%;
|
|
2264
|
+
border-left: 1px solid var(--border_color_cell);
|
|
2265
|
+
`;styled.div`
|
|
2266
|
+
height: calc(100vh - 600px);
|
|
2267
|
+
overflow-y: auto;
|
|
2268
|
+
padding-left: 10px;
|
|
2269
|
+
color: var(--color_label);
|
|
2270
|
+
`;styled.div`
|
|
2271
|
+
flex-wrap: wrap;
|
|
2272
|
+
display: flex;
|
|
2273
|
+
margin-top: 20px;
|
|
2274
|
+
`;styled.div`
|
|
2275
|
+
padding: 0 20px;
|
|
2276
|
+
cursor: pointer;
|
|
2277
|
+
`;const DksBindingKey=styled.div`
|
|
2278
|
+
width: 50px;
|
|
2279
|
+
height: 50px;
|
|
2280
|
+
border-radius: 10px;
|
|
2281
|
+
background: var(--bg_control);
|
|
2282
|
+
margin-right: 30px;
|
|
2283
|
+
cursor: pointer;
|
|
2284
|
+
text-align: center;
|
|
2285
|
+
line-height: 18px;
|
|
2286
|
+
display: flex;
|
|
2287
|
+
justify-content: center;
|
|
2288
|
+
align-items: center;
|
|
2289
|
+
font-size: 14px;
|
|
2290
|
+
border: 2px solid var(--border_color_icon);
|
|
2291
|
+
margin-right: 10px;
|
|
2292
|
+
& > span {
|
|
2293
|
+
white-space: pre-wrap;
|
|
2294
|
+
text-overflow: ellipsis;
|
|
2295
|
+
overflow: hidden;
|
|
2296
|
+
user-select: none;
|
|
2297
|
+
color: var(--color_label-highlighted);
|
|
2298
|
+
}
|
|
2299
|
+
`;styled.div`
|
|
2300
|
+
display: flex;
|
|
2301
|
+
align-items: center;
|
|
2302
|
+
margin-bottom: 10px;
|
|
2303
|
+
& > button {
|
|
2304
|
+
margin-left: 10px;
|
|
2305
|
+
}
|
|
2306
|
+
&:hover ${DksBindingKey} {
|
|
2307
|
+
border-color: var(--color_accent);
|
|
2308
|
+
}
|
|
2309
|
+
`;styled.div`
|
|
2310
|
+
display: flex;
|
|
2311
|
+
cursor: pointer;
|
|
2312
|
+
`;styled.div`
|
|
2313
|
+
position: relative;
|
|
2314
|
+
height: 24px;
|
|
2315
|
+
padding-bottom: 15px;
|
|
2316
|
+
border-bottom: 1px solid var(--border_color_cell);
|
|
2317
|
+
text-align: center;
|
|
2318
|
+
color: var(--color_label);
|
|
2319
|
+
> span {
|
|
2320
|
+
color: var(--color_accent);
|
|
2321
|
+
}
|
|
2322
|
+
margin-bottom: 10px;
|
|
2323
|
+
${SimpleIconButton} {
|
|
2324
|
+
position: absolute;
|
|
2325
|
+
padding: 0 10px;
|
|
2326
|
+
font-size: 16px;
|
|
2327
|
+
left: 0px;
|
|
2328
|
+
top: 2px;
|
|
2329
|
+
}
|
|
2330
|
+
`;styled.div`
|
|
2331
|
+
display: flex;
|
|
2332
|
+
align-items: center;
|
|
2333
|
+
justify-content: space-between;
|
|
2334
|
+
`;styled.div`
|
|
2335
|
+
position: relative;
|
|
2336
|
+
width: 120px;
|
|
2337
|
+
padding-top: 15px;
|
|
2338
|
+
`;styled.div`
|
|
2339
|
+
background: var(--bg_control);
|
|
2340
|
+
position: relative;
|
|
2341
|
+
border-radius: 5px;
|
|
2342
|
+
width: 28px;
|
|
2343
|
+
height: 165px;
|
|
2344
|
+
overflow: hidden;
|
|
2345
|
+
> span {
|
|
2346
|
+
content: '';
|
|
2347
|
+
position: absolute;
|
|
2348
|
+
left: 0;
|
|
2349
|
+
top: 0;
|
|
2350
|
+
background: var(--color_accent);
|
|
2351
|
+
height: 100%;
|
|
2352
|
+
width: 28px;
|
|
2353
|
+
transform-origin: top;
|
|
2354
|
+
transition: transform 0.1s ease-in-out;
|
|
2355
|
+
}
|
|
2356
|
+
`;styled.div`
|
|
2357
|
+
width: 28px;
|
|
2358
|
+
height: 165px;
|
|
2359
|
+
margin: 0 auto;
|
|
2360
|
+
position: relative;
|
|
2361
|
+
`;styled.div`
|
|
2362
|
+
position: absolute;
|
|
2363
|
+
top: 0;
|
|
2364
|
+
left: 0;
|
|
2365
|
+
height: 165px;
|
|
2366
|
+
width: 28px;
|
|
2367
|
+
z-index: 1;
|
|
2368
|
+
`;styled.div`
|
|
2369
|
+
font-size: 10px;
|
|
2370
|
+
/* font-weight: bold; */
|
|
2371
|
+
height: 1px;
|
|
2372
|
+
width: 100%;
|
|
2373
|
+
display: flex;
|
|
2374
|
+
align-items: center;
|
|
2375
|
+
color: var(--color_accent);
|
|
2376
|
+
position: absolute;
|
|
2377
|
+
& > span {
|
|
2378
|
+
line-height: normal;
|
|
2379
|
+
margin-left: -36px;
|
|
2380
|
+
}
|
|
2381
|
+
&::before,
|
|
2382
|
+
&::after {
|
|
2383
|
+
background: var(--color_accent);
|
|
2384
|
+
content: '';
|
|
2385
|
+
display: block;
|
|
2386
|
+
position: absolute;
|
|
2387
|
+
width: 10px;
|
|
2388
|
+
height: 1px;
|
|
2389
|
+
border-radius: 1px;
|
|
2390
|
+
}
|
|
2391
|
+
&::before {
|
|
2392
|
+
left: -14px;
|
|
2393
|
+
}
|
|
2394
|
+
&::after {
|
|
2395
|
+
right: -14px;
|
|
2396
|
+
}
|
|
2397
|
+
`;styled.div`
|
|
2398
|
+
height: 1px;
|
|
2399
|
+
width: 100%;
|
|
2400
|
+
display: flex;
|
|
2401
|
+
align-items: center;
|
|
2402
|
+
color: var(--color_accent);
|
|
2403
|
+
position: absolute;
|
|
2404
|
+
&::before,
|
|
2405
|
+
&::after {
|
|
2406
|
+
background: var(--color_accent);
|
|
2407
|
+
content: '';
|
|
2408
|
+
display: block;
|
|
2409
|
+
position: absolute;
|
|
2410
|
+
width: 5px;
|
|
2411
|
+
height: 1px;
|
|
2412
|
+
border-radius: 1px;
|
|
2413
|
+
}
|
|
2414
|
+
&::before {
|
|
2415
|
+
left: -9px;
|
|
2416
|
+
}
|
|
2417
|
+
&::after {
|
|
2418
|
+
right: -9px;
|
|
2419
|
+
}
|
|
2420
|
+
`;styled.div`
|
|
2421
|
+
line-height: 3em;
|
|
2422
|
+
font-size: 16px;
|
|
2423
|
+
text-align: right;
|
|
2424
|
+
margin-right: 20px;
|
|
2425
|
+
`;styled.div`
|
|
2426
|
+
padding: 20px 0;
|
|
2427
|
+
width: 100%;
|
|
2428
|
+
/* border: 1px solid #ccc; */
|
|
2429
|
+
margin-left: -100px;
|
|
2430
|
+
margin-right: 0px;
|
|
2431
|
+
overflow: hidden;
|
|
2432
|
+
display: flex;
|
|
2433
|
+
justify-content: flex-end;
|
|
2434
|
+
column-gap: 10px;
|
|
2435
|
+
`;const title="Actuation";styled.div`
|
|
2436
|
+
padding: 15px 10px 20px 10px;
|
|
2437
|
+
`;styled(CenterPane)`
|
|
2438
|
+
height: 100%;
|
|
2439
|
+
`;styled.div`
|
|
2440
|
+
display: flex;
|
|
2441
|
+
align-items: center;
|
|
2442
|
+
flex-direction: column;
|
|
2443
|
+
padding: 12px;
|
|
2444
|
+
`;const Title$1=title,useMultiSelect=()=>{const e=useDispatch(),t=reactExports.useRef(!1),r=()=>{window.removeEventListener("pointerup",r),t.current=!1};return{onMultiPointerDown:(l,c)=>{window.addEventListener("pointerup",r),e(toggleSelectedKey(c)),t.current=!0},onMultiPointerOver:(l,c)=>{t.current&&e(addSelectedKey(c))}}},getKeyboardCanvas=e=>e==="2D"?KeyboardCanvas$1:KeyboardCanvas,ConfigureKeyboard=e=>{const{selectable:t,dimensions:r}=e,s=useAppSelector(k=>getSelectedKeymap(k)||[]),a=useAppSelector(getSelectedKeyDefinitions),l=useAppSelector(getSelectedDefinition),c=useAppSelector(getShowKeyPainter),d=useAppSelector(getSelectedPaletteColor),{keyColors:p,onKeycapPointerDown:f,onKeycapPointerOver:m}=useColorPainter(a,d),[y,K]=reactExports.useMemo(()=>p&&a?[a.filter((k,F)=>p[F]&&p[F].length),p.filter(k=>k&&k.length)]:[null,null],[a,p]),x=useAppSelector(getSelectedRowTitle),{onMultiPointerDown:v,onMultiPointerOver:M}=useMultiSelect(),b=useAppSelector(getMultiSelectAble),R=useAppSelector(getActiveMenu);let O=DisplayMode.Configure;if(R==="DKS"?O=DisplayMode.ConfigureDKS:R==="RT"?O=DisplayMode.ConfigureRT:R==="AP"&&(O=DisplayMode.ConfigureAP),!l||!r)return null;const I=getKeyboardCanvas(e.nDimension);return jsxs(Fragment,{children:[x===Title$1?jsx(I,{matrixKeycodes:s,keys:a,selectable:!b&&!!t,multiSelect:b,definition:l,containerDimensions:r,mode:O,onKeycapPointerDown:b?v:void 0,onKeycapPointerOver:b?M:void 0}):jsx(I,{matrixKeycodes:s,keys:a,selectable:!!t,definition:l,containerDimensions:r,mode:DisplayMode.Configure,shouldHide:c}),y&&y.length&&K&&K.length?jsx(I,{matrixKeycodes:s,keys:y,selectable:c,definition:l,containerDimensions:r,mode:DisplayMode.ConfigureColors,keyColors:K,onKeycapPointerDown:f,onKeycapPointerOver:m,shouldHide:!c}):null]})},TestKeyboard=e=>{const{selectable:t,containerDimensions:r,matrixKeycodes:s,keys:a,pressedKeys:l,definition:c,nDimension:d}=e;if(!r)return null;const p=getKeyboardCanvas(d);return jsx(p,{matrixKeycodes:s,keys:a,selectable:!!t,definition:c,pressedKeys:l,containerDimensions:r,mode:DisplayMode.Test})},DesignKeyboard=e=>{const{containerDimensions:t,showMatrix:r,definition:s,selectedOptionKeys:a}=e,{keys:l,optionKeys:c}=s.layouts;if(!t)return null;const d=reactExports.useMemo(()=>c?Object.entries(c).flatMap(([m,y])=>{const K=parseInt(m);return a[K]?y[a[K]]:y[0]}):[],[c,a]),p=reactExports.useMemo(()=>[...l,...d],[l,d]),f=getKeyboardCanvas(e.nDimension);return jsx(f,{matrixKeycodes:EMPTY_ARR,keys:p,selectable:!1,definition:s,containerDimensions:t,mode:DisplayMode.Design,showMatrix:r})},Design=e=>{const t=Object.values(useAppSelector(getCustomDefinitions)),r=useAppSelector(getDesignDefinitionVersion),s=useAppSelector(getSelectedDefinitionIndex),a=useAppSelector(getDesignSelectedOptionKeys),l=useAppSelector(getShowMatrix),c=reactExports.useMemo(()=>t.filter(p=>p[r]),[t,r]),d=c[s]&&c[s][r];return d&&jsx(DesignKeyboard,{containerDimensions:e.dimensions,definition:d,selectedOptionKeys:a,showMatrix:l,nDimension:e.nDimension})},EMPTY_ARR=[],Test=e=>{const t=useAppDispatch(),[r]=useLocation(),s=r==="/test",a=useAppSelector(getSelectedKeyboardAPI),l=useAppSelector(getSelectedConnectedDevice),c=useAppSelector(getSelectedDefinition),d=useAppSelector(getSelectedKeyDefinitions),p=useAppSelector(getIsTestMatrixEnabled),f=useAppSelector(getTestKeyboardSoundsSettings),m=useAppSelector(z=>getSelectedKeymap(z)||[]),[y,K]=useGlobalKeys(!p&&s),[x,v]=useMatrixTest(p&&s,a,l,c),M=reactExports.useCallback(()=>{K(EMPTY_ARR),v(EMPTY_ARR)},[K,v]),b=reactExports.useContext(TestContext);reactExports.useEffect(()=>{b[0].clearTestKeys!==M&&b[1]({clearTestKeys:M})},[b,M]),reactExports.useEffect(()=>{r!=="/test"&&(t(setTestMatrixEnabled(!1)),b[0].clearTestKeys()),r!=="/"&&t(setLayer(0))},[r]);const R=p&&d?d.map(({row:z,col:X})=>c&&x[z*c.matrix.cols+X]):[],O=p?c:fullKeyboardDefinition,I=p?d:fullKeyboardDefinition.layouts.keys;if(!O||typeof O=="string")return null;const k=p?R:y,{partitionedKeys:F}=reactExports.useMemo(()=>getKeyboardRowPartitions(I),[I]),V=p?x:y,$=F.map(z=>z.map(({row:X,col:L})=>V[X*O.matrix.cols+L]));return jsxs(Fragment,{children:[jsx(TestKeyboard,{definition:O,keys:I,pressedKeys:k,matrixKeycodes:p?m:matrixKeycodes,containerDimensions:e.dimensions,nDimension:e.nDimension}),$&&f.isEnabled&&jsx(TestKeyboardSounds,{pressedKeys:$})]})},UpdateUVMaps=()=>{const e=useGLTF(glbSrc,!0).scene;return reactExports.useEffect(()=>{Object.values(e.children).forEach(t=>{if(t.isGroup)return;const r=t,s=1/2.6,a=r.geometry,{min:l}=a.boundingBox,c=19.05,d=.445,p=r.geometry.attributes.position;r.geometry.attributes.uv||r.geometry.setAttribute("uv",new BufferAttribute(new Float32Array(p.count*2),2,!1));const f=r.geometry.attributes.uv,m=new Float32Array(f.count*2);for(let y=0;y<r.geometry.attributes.uv.count;y++)m[2*y]=s*(p.array[y*3]-l.x+d)/c,m[2*y+1]=s*(p.array[y*3+1]-l.y+d)/c;f.copyArray(m),a.center(),f.needsUpdate=!0})},[e]),null},cubeySrc="/assets/cubey-495d68a6.glb",LoaderCubey=React.memo(({visible:e,theme:t})=>{const r=useGLTF(cubeySrc);console.debug(r,"cubey");const s=reactExports.useRef(),a=e?-.3:10,l=getDarkenedColor(t.accent.c,.8),c={"upper-body":new Color(t.mod.c),"lower-body":new Color(t.mod.t),accent:new Color(l),bowtie:new Color(l)};return r.scene.children.forEach(d=>{const p=d.name.split("_")[0],f=c[p];f&&(d.material.color=f)}),useFrame(({clock:d})=>{e&&(s.current.rotation.z=Math.sin(d.elapsedTime)*(Math.PI/40),s.current.rotation.y=Math.PI+Math.sin(.6*d.elapsedTime)*(Math.PI/16),s.current.position.y=a+.2*Math.sin(d.elapsedTime))}),jsx(Fragment,{children:jsx("group",{scale:.6,position:[0,a,-19],children:jsx(PresentationControls,{enabled:!0,global:!0,snap:!0,speed:1,zoom:1,rotation:[0,0,0],polar:[-Math.PI/3,Math.PI/3],config:{mass:2,tension:200,friction:14},children:jsx("group",{ref:s,children:jsx("primitive",{object:r.scene})})})})})},shallowEqual);useGLTF.preload(cubeySrc);useGLTF.preload(glbSrc);const KeyboardBG$1=React.memo(e=>{const{onClick:t,visible:r,color:s}=e;return jsxs("mesh",{receiveShadow:!0,position:[0,-5.75,0],rotation:[-Math.PI/2+Math.PI/14,0,0],onClick:t,visible:r,children:[jsx("planeGeometry",{args:[100,100]}),jsx("meshStandardMaterial",{color:s})]})},shallowEqual),CanvasRouter$1=()=>{const[e]=useLocation(),t=reactExports.useRef(document.body),r=reactExports.useRef(null),s=useAppSelector(getLoadProgress),{progress:a}=useProgress(),l=useAppDispatch(),c=useSize(t),d=Object.values(useAppSelector(getCustomDefinitions)),p=useAppSelector(getSelectedDefinition),f=useAppSelector(getDesignDefinitionVersion),m=useAppSelector(getSelectedTheme),y=reactExports.useMemo(()=>m[dist.KeyColorType.Accent].c,[m]),[K,x]=reactExports.useState(!1),v=e==="/"&&(!p||s!==1),M=reactExports.useMemo(()=>d.filter($=>$[f]),[d,f]),b=e==="/design"&&!M.length,R=e==="/"&&(!p||(s+a/100)/2!==1),O=reactExports.useCallback(()=>{l(updateSelectedKey(null))},[l]),I="hid"in navigator||OVERRIDE_HID_CHECK,k=!I||["/settings","/errors","/boot","/boot2"].includes(e)||b||R,F=useAppSelector(getConfigureKeyboardIsSelectable),V=v;return reactExports.useEffect(()=>{document.fonts.load("bold 16px Fira Sans").finally(()=>{x(!0)})},[]),jsxs(Fragment,{children:[jsx(UpdateUVMaps,{}),jsx("div",{style:{height:500,width:"100%",top:0,transform:k?V?c?`translateY(${-300+c.height/2}px)`:"":"translateY(-500px)":"",position:k&&!V?"absolute":"relative",overflow:"visible",zIndex:0,visibility:k&&!V?"hidden":"visible"},ref:r,children:jsxs(Canvas,{flat:!0,shadows:!0,style:{overflow:"visible"},children:[jsx(Lights,{}),jsx(KeyboardBG$1,{onClick:O,color:y,visible:!V}),jsx(OrbitControls,{enabled:!1}),jsx(Camera,{}),jsx(LoaderCubey,{theme:m,visible:V&&!p}),jsx(Html,{center:!0,position:[0,V?p?0:-1:10,-19],children:I?p?jsx(Fragment,{children:jsx("div",{style:{textAlign:"center",color:"var(--color_accent)",fontSize:60},children:jsx(FontAwesomeIcon,{spinPulse:!0,icon:faSpinner})})}):jsxs(AccentButtonLarge,{onClick:()=>l(reloadConnectedDevices()),style:{width:"max-content"},children:["Authorize device",jsx(FontAwesomeIcon,{style:{marginLeft:"10px"},icon:faUnlock})]}):null}),K?jsx(KeyboardGroup$1,{containerRef:r,configureKeyboardIsSelectable:F,loadProgress:s}):null]})})]})},Lights=React.memo(()=>{const l=reactExports.useRef(null);reactExports.useEffect(()=>{l.current&&(l.current.shadow.mapSize.width=2048,l.current.shadow.mapSize.height=2048)},[l.current]);const c=React.useMemo(()=>{const p=new Object3D;return p.position.set(0,0,-19),p.updateMatrixWorld(),p},[]);return!0?jsxs(Fragment,{children:[jsx("ambientLight",{intensity:0}),jsx(SpotLight,{ref:l,distance:12+3,position:[0,12,-19+2],angle:Math.PI/5,attenuation:5,target:c,intensity:10,castShadow:!0,anglePower:5}),jsx("pointLight",{position:[3,.5,-15],intensity:.8}),jsx("pointLight",{position:[-3,.5,-15],intensity:.8})]}):jsxs(Fragment,{children:[jsx("ambientLight",{intensity:.4}),jsx("pointLight",{position:[-.5,.5,-15],intensity:1.5})]})},shallowEqual),getRouteX$1=e=>{switch(e){case"/debug":return-60;case"/design":return-40;case"/test":return-20;case"/":return 0;default:return-60}},KeyboardGroup$1=React.memo(e=>{const{loadProgress:t,configureKeyboardIsSelectable:r}=e,[s]=useLocation(),a=getRouteX$1(s),l=J({config:mt.stiff,x:a}),c=useSize(e.containerRef);return jsx(E.group,{"position-x":l.x,children:jsx(Keyboards$1,{configureKeyboardIsSelectable:r,loadProgress:t,dimensions:c})})},shallowEqual),Keyboards$1=React.memo(e=>{const{loadProgress:t,dimensions:r,configureKeyboardIsSelectable:s}=e,a=-getRouteX$1("/test"),l=-getRouteX$1("/design"),c=-getRouteX$1("/debug");return jsxs(Fragment,{children:[jsx("group",{visible:t===1,children:jsx(ConfigureKeyboard,{dimensions:r,selectable:s,nDimension:"3D"})}),jsx("group",{"position-x":a,children:jsx(Test,{dimensions:r,nDimension:"3D"})}),jsx("group",{"position-x":l,children:jsx(Design,{dimensions:r,nDimension:"3D"})}),jsx("group",{"position-x":c})]})},shallowEqual),KeyboardBG=styled.div`
|
|
2445
|
+
position: absolute;
|
|
2446
|
+
top: 0;
|
|
2447
|
+
right: 0;
|
|
2448
|
+
bottom: 0;
|
|
2449
|
+
left: 0;
|
|
2450
|
+
background: ${e=>`linear-gradient(30deg, rgba(150,150,150,1) 10%,${getDarkenedColor(e.$color)} 50%, rgba(150,150,150,1) 90%)`};
|
|
2451
|
+
opacity: ${e=>e.$visible?1:0};
|
|
2452
|
+
`,KeyboardRouteGroup=styled.div`
|
|
2453
|
+
position: absolute;
|
|
2454
|
+
left: 0;
|
|
2455
|
+
transform: translateX(${e=>e.$position*100}vw);
|
|
2456
|
+
height: 100%;
|
|
2457
|
+
width: 100vw;
|
|
2458
|
+
display: inline-flex;
|
|
2459
|
+
flex-direction: column;
|
|
2460
|
+
align-items: center;
|
|
2461
|
+
justify-content: center;
|
|
2462
|
+
`,CanvasRouter=()=>{const[e]=useLocation(),t=reactExports.useRef(document.body),r=reactExports.useRef(null),s=useAppSelector(getLoadProgress),{progress:a}=useProgress(),l=useAppDispatch(),c=useSize(r),d=useSize(t),p=Object.values(useAppSelector(getCustomDefinitions)),f=useAppSelector(getSelectedDefinition),m=useAppSelector(getDesignDefinitionVersion),y=useAppSelector(getSelectedTheme),K=reactExports.useMemo(()=>y[dist.KeyColorType.Accent].c,[y]),x=e==="/"&&(!f||s!==1),v=reactExports.useMemo(()=>p.filter(V=>V[m]),[p,m]),M=e==="/design"&&!v.length,b=e==="/"&&(!f||(s+a/100)/2!==1),R=reactExports.useCallback(()=>{l(updateSelectedKey(null))},[l]),I=!("hid"in navigator||OVERRIDE_HID_CHECK)||["/settings","/errors","/boot","/boot2"].includes(e)||M||b,k=useAppSelector(getConfigureKeyboardIsSelectable),F=x;return jsx(Fragment,{children:jsx("div",{style:{height:500,width:"100%",top:0,transform:I?F?d?`translateY(${-300+d.height/2}px)`:"":"translateY(-500px)":"",position:I&&!F?"absolute":"relative",overflow:"visible",zIndex:2,visibility:I&&!F?"hidden":"visible"},onClick:V=>{V.target.nodeName!=="CANVAS"&&l(clearSelectedKey())},ref:r,children:I?null:jsxs(Fragment,{children:[jsx(KeyboardBG,{onClick:R,$color:K,$visible:!F}),jsx(KeyboardGroup,{containerDimensions:c,configureKeyboardIsSelectable:k,loadProgress:s})]})})})},getRouteX=e=>{switch(e){case"/debug":return-300;case"/design":return-200;case"/test":return-100;case"/":return 0;default:return-300}},KeyboardGroupContainer=styled.div`
|
|
2463
|
+
z-index: 2;
|
|
2464
|
+
display: block;
|
|
2465
|
+
white-space: nowrap;
|
|
2466
|
+
height: 100%;
|
|
2467
|
+
background: linear-gradient(90deg, red, blue);
|
|
2468
|
+
width: max-content;
|
|
2469
|
+
position: absolute;
|
|
2470
|
+
top: 0;
|
|
2471
|
+
left: 0;
|
|
2472
|
+
`,KeyboardGroup=React.memo(e=>{const t=useDispatch(),{loadProgress:r,configureKeyboardIsSelectable:s,containerDimensions:a}=e,[l]=useLocation(),c=reactExports.useRef(null),d=getRouteX(l),p={transition:"transform 0.25s ease-in-out",transform:`translate(${d}vw, 0px)`},f=reactExports.useCallback(()=>{c.current&&(c.current.style.transition=p.transition)},[c.current]),m=reactExports.useCallback(()=>{c.current&&(c.current.style.transition="")},[c.current]);return reactExports.useEffect(()=>(c.current&&(c.current.addEventListener("transitionend",m),c.current.style.transform=p.transform),()=>{var y;c.current&&((y=c.current)==null||y.removeEventListener("transitionend",m))}),[]),reactExports.useEffect(()=>{c.current&&c.current.style.transform!==p.transform&&(f(),c.current.style.transform=p.transform)},[d]),jsx(KeyboardGroupContainer,{onClick:y=>{var K;((K=y.target)==null?void 0:K.parentNode)===c.current&&t(updateSelectedKeys([]))},ref:c,children:jsx(Keyboards,{configureKeyboardIsSelectable:s,loadProgress:r,dimensions:a})})},shallowEqual),Keyboards=React.memo(e=>{const{dimensions:t,configureKeyboardIsSelectable:r}=e;return jsxs(Fragment,{children:[jsx(KeyboardRouteGroup,{$position:0,children:jsx(ConfigureKeyboard,{dimensions:t,selectable:r,nDimension:"2D"})}),jsx(KeyboardRouteGroup,{$position:1,children:jsx(Test,{dimensions:t,nDimension:"2D"})}),jsx(KeyboardRouteGroup,{$position:2,children:jsx(Design,{dimensions:t,nDimension:"2D"})}),jsx(KeyboardRouteGroup,{$position:3})]})},shallowEqual),Container=styled.div`
|
|
2473
|
+
position: fixed;
|
|
2474
|
+
top: 0;
|
|
2475
|
+
left: 0;
|
|
2476
|
+
width: 100%;
|
|
2477
|
+
height: 100%;
|
|
2478
|
+
display: flex;
|
|
2479
|
+
justify-content: center;
|
|
2480
|
+
align-items: center;
|
|
2481
|
+
z-index: 11;
|
|
2482
|
+
`,ClickCover=styled.div`
|
|
2483
|
+
position: fixed;
|
|
2484
|
+
z-index: 10;
|
|
2485
|
+
pointer-events: all;
|
|
2486
|
+
top: 0;
|
|
2487
|
+
left: 0;
|
|
2488
|
+
right: 0;
|
|
2489
|
+
bottom: 0;
|
|
2490
|
+
background: rgba(0, 0, 0, 0.75);
|
|
2491
|
+
`,Title=styled.div`
|
|
2492
|
+
width: 100%;
|
|
2493
|
+
font-size: 18px;
|
|
2494
|
+
color: var(--color_accent);
|
|
2495
|
+
text-align: left;
|
|
2496
|
+
`,Loading=styled.div`
|
|
2497
|
+
position: absolute;
|
|
2498
|
+
width: 100%;
|
|
2499
|
+
height: 100%;
|
|
2500
|
+
display: flex;
|
|
2501
|
+
align-items: center;
|
|
2502
|
+
justify-content: center;
|
|
2503
|
+
background: #222;
|
|
2504
|
+
z-index: 12;
|
|
2505
|
+
`,Online=e=>{const{options:t}=e,{t:r}=useTranslation(),s=useAppDispatch(),a=reactExports.useRef(new AbortController),l=useAppSelector(getBufferSize$1),c=useAppSelector(getBytesSended$1),d=useAppSelector(getSendSpeed$1),p=useAppSelector(getSavingState$1),f=useAppSelector(getBufferSize),m=useAppSelector(getBytesSended),y=useAppSelector(getSendSpeed),K=useAppSelector(getSavingState),[x,v]=reactExports.useState(!1),[M,b]=reactExports.useState(!1),[R,O]=reactExports.useState(!1),[I,k]=reactExports.useState(!1),[F,V]=reactExports.useState([]),[$,z]=reactExports.useState(0),[X,L]=reactExports.useState(null),[H,B]=reactExports.useState(!0),Q=useAppSelector(getSelectedKeyboardAPI),q=t.files.flatMap((_e,Pe)=>/plc/i.test(_e)?[Pe]:[]),T=t.files.findIndex(_e=>/master/i.test(_e)),j=F.filter((_e,Pe)=>q.includes(Pe)),te=F[T],re=t.files,de=t.needUpdate,fe=async()=>{if(re.length===0)return;a.current.abort(),a.current=new AbortController;const _e=[];for(let Pe=0;Pe<re.length;Pe++){const ot=re[Pe],qe=await fetch(ot,{cache:"reload",signal:a.current.signal});if(qe.status!==200){console.log(ot+": "+qe.statusText);return}const ne=await qe.arrayBuffer(),se=new Uint8Array(ne);_e.push(se)}return _e},Ee=async()=>{if(!I&&de){k(!0);const _e=await fe();k(!1),!_e||_e.length!==re.length?B(!1):V(_e)}},$e=async()=>{L("normal"),z(0);for(let _e=0;_e<F.length;_e++)z(_e),await s(saveTabFirmware$1(F[_e])),await new Promise(Pe=>{setTimeout(()=>{Pe(!0)},1e3)})},Qe=async()=>{L("plc"),z(0);for(let _e=0;_e<j.length;_e++)z(_e),await s(saveTabFirmware$1(j[_e])),await new Promise(Pe=>{setTimeout(()=>{Pe(!0)},1e3)})},Xe=async()=>{L("master"),t.bootVidPid?(Q&&(Q.setCustomMenuValue(16,10,1),await new Promise(_e=>{setTimeout(()=>{_e(!0)},1e3)})),await s(saveTabFirmware(te,!1,t.bootVidPid))):await s(saveTabFirmware$1(te))};return reactExports.useEffect(()=>{p==="completed"&&X==="plc"&&$===q.length-1&&(v(!0),L(null),s(updateState$1("waiting"))),p==="completed"&&X==="master"&&(b(!0),setTimeout(()=>{s(setFirmwareOptions())},1e3)),p==="completed"&&X==="normal"&&$===F.length-1&&(O(!0),setTimeout(()=>{s(setFirmwareOptions())},1e3)),p==="failed"&&L(null)},[p,X,$]),reactExports.useEffect(()=>{K==="completed"&&X==="master"&&(b(!0),setTimeout(()=>{s(setFirmwareOptions())},1e3)),K==="failed"&&L(null)},[K,X]),reactExports.useEffect(()=>(L(null),v(!1),b(!1),O(!1),V([]),z(0),B(!0),s(updateState("waiting")),t.files&&Ee(),()=>{a.current.abort()}),[t]),de?jsxs(Fragment,{children:[(I||!H)&&jsx(Loading,{children:jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",rowGap:50},children:[jsxs("div",{style:{color:"var(--color_accent)",fontSize:20},children:[I&&r("Loading..."),!H&&r("Download Failed")]}),jsx(AccentButton,{disabled:!!X,onClick:()=>s(setFirmwareOptions()),children:r("Cancel")})]})}),jsxs(Title,{children:[r("Online Upgrade"),": "]}),q.length>0&&jsxs(ControlRow,{children:[jsxs(Label$1,{children:["PLC"," ",q.length>1&&jsx("span",{style:{marginLeft:10},children:`( ${$+1} / ${q.length} )`})]}),jsx(Detail,{children:x?jsx(FontAwesomeIcon,{icon:faCheck}):jsx(AccentButton,{disabled:!!X||x||!Q,onClick:Qe,children:r("Update")})})]}),T!==-1&&jsxs(ControlRow,{children:[jsx(Label$1,{children:"Master"}),jsx(Detail,{children:M?jsx(FontAwesomeIcon,{icon:faCheck}):jsx(AccentButton,{disabled:!!X||q.length>0&&!x,onClick:Xe,children:r("Update")})})]}),q.length===0&&T===-1&&t.files.length>0&&jsxs(ControlRow,{children:[jsx(Label$1,{children:`${$+1} / ${t.files.length}`}),jsx(Detail,{children:R?jsx(FontAwesomeIcon,{icon:faCheck}):jsx(AccentButton,{disabled:!!X,onClick:$e,children:r("Update")})})]}),p==="saving"&&jsx(SavingProgress,{bufferSize:l,sendSpeed:d,bytesSended:c}),K==="saving"&&jsx(SavingProgress,{bufferSize:f,sendSpeed:y,bytesSended:m}),!X&&jsx("div",{children:jsx(AccentButton,{onClick:()=>s(setFirmwareOptions()),children:r("Cancel")})})]}):jsxs(Fragment,{children:[jsxs("div",{children:[r("Already the latest version"),"!"]}),jsx(AccentButton,{onClick:()=>s(setFirmwareOptions()),disabled:x,children:r("Confirm")})]})},Local=e=>{const{options:t}=e,{t:r}=useTranslation(),s=useAppDispatch(),a=useAppSelector(getSelectedKeyboardAPI),l=useAppSelector(getBufferSize$1),c=useAppSelector(getBytesSended$1),d=useAppSelector(getSendSpeed$1),p=useAppSelector(getSavingState$1),f=useAppSelector(getBufferSize),m=useAppSelector(getBytesSended),y=useAppSelector(getSendSpeed),K=useAppSelector(getSavingState),x=reactExports.useRef(null),[v,M]=reactExports.useState(),b=()=>{var I;(I=x.current)==null||I.click()},R=async I=>{var k;if((k=I.target.files)!=null&&k[0]){const F=I.target.files[0],V=F.name,$=await F.arrayBuffer(),z=new Uint8Array($);M({name:V,byteArray:z}),s(updateState$1("waiting")),s(updateState("waiting"))}else M(null)},O=async()=>{v&&(/master/i.test(v.name)&&t.bootVidPid?(a&&(a.setCustomMenuValue(16,10,1),await new Promise(I=>{setTimeout(()=>{I(!0)},1e3)})),s(saveTabFirmware(v.byteArray,!1,t.bootVidPid))):s(saveTabFirmware$1(v.byteArray)))};return reactExports.useEffect(()=>{v&&K==="completed"&&/master/i.test(v.name)&&setTimeout(()=>{s(setFirmwareOptions())},1e3)},[K,v]),reactExports.useEffect(()=>{M(null),s(updateState("waiting")),s(updateState$1("waiting"))},[t]),jsxs(Fragment,{children:[jsxs(Title,{children:[r("Local Upgrade"),": "]}),jsxs(ControlRow,{children:[jsxs(Label$1,{style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap"},children:[r("Firmware"),"๏ผ",v==null?void 0:v.name]}),jsxs(Detail,{children:[jsx(AccentButton,{disabled:K==="saving"||p==="saving",onClick:b,children:r("Open")}),jsx(HiddenInput$3,{accept:".uf2",onChange:R,type:"file",ref:x})]})]}),jsxs(ControlRow,{children:[jsx(FlexLabel,{children:(p==="failed"||K==="failed")&&jsxs(Fragment,{children:[jsx(FontAwesomeIcon,{icon:faWarning,size:"xs",style:{color:"gold",marginRight:5}}),r("Failed to flash.")]})}),jsx(Detail,{children:jsx(AccentButton,{onClick:O,disabled:!v||p==="saving"||K==="saving",children:r("Flash")})})]}),p==="saving"&&jsx(SavingProgress,{bufferSize:l,sendSpeed:d,bytesSended:c}),K==="saving"&&jsx(SavingProgress,{bufferSize:f,sendSpeed:y,bytesSended:m}),p!=="saving"&&K!=="saving"&&jsx("div",{children:jsx(AccentButton,{onClick:()=>s(setFirmwareOptions()),children:r("Cancel")})})]})},Firmware=()=>{const e=useAppSelector(getFirmwareOptions),t=e&&e.files.length>0;return e?jsxs(Fragment,{children:[jsx(ClickCover,{}),jsx(Container,{children:jsx(ModalContainer,{children:t?jsx(Online,{options:e}):jsx(Local,{options:e})})})]}):jsx(Fragment,{})},GlobalStyle=createGlobalStyle`
|
|
2506
|
+
*:focus {
|
|
2507
|
+
outline: none;
|
|
2508
|
+
}
|
|
2509
|
+
`,hashLocation=()=>window.location.hash.replace(/^#/,"")||"/",hashNavigate=e=>navigate("#"+e),useHashLocation=(...e)=>[useLocationProperty(hashLocation),hashNavigate],Routes=()=>{const e="hid"in navigator||OVERRIDE_HID_CHECK,t=useAppSelector(getRenderMode),r=reactExports.useMemo(()=>PANES.map(l=>jsx(Route,{component:l.component,path:l.path},l.key)),[]),s=t==="2D"?CanvasRouter:CanvasRouter$1,a=reactExports.useState({clearTestKeys:()=>{}});return jsx(Fragment,{children:jsx(ErrorBoundary,{showDialog:!0,children:jsx(Router,{hook:useHashLocation,children:jsxs(TestContext.Provider,{value:a,children:[jsx(GlobalStyle,{}),e&&jsx(UnconnectedGlobalMenu,{}),jsx(s,{}),jsx(Firmware,{}),jsx(Home,{hasHIDSupport:e,children:r})]})})})})},Root=()=>jsx(Provider,{store,children:jsx(Routes,{})}),app_global="";instance.use(Browser$1).use(initReactI18next).use(resourcesToBackend(e=>__variableDynamicImportRuntimeHelper(Object.assign({"./locales/en.json":()=>__vitePreload(()=>import("./en-f1cf1f03.js"),[]),"./locales/ja.json":()=>__vitePreload(()=>import("./ja-019eaf22.js"),[]),"./locales/ko.json":()=>__vitePreload(()=>import("./ko-ea23bc7a.js"),[]),"./locales/zh.json":()=>__vitePreload(()=>import("./zh-7a38233d.js"),[])}),`./locales/${e}.json`))).init({fallbackLng:"en",debug:!1,interpolation:{escapeValue:!1}});const elem=document.getElementById("root");elem&&(createRoot(elem).render(jsx(Root,{})),document.documentElement.dataset.themeMode=getThemeModeFromStore(),updateCSSVariables(getThemeNameFromStore()));
|