Files
corner/assets/utils-ca06b521.js
T

2 lines
1.2 KiB
JavaScript

var o=Object.defineProperty;var f=(t,n,e)=>n in t?o(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e;var s=(t,n,e)=>(f(t,typeof n!="symbol"?n+"":n,e),e);import{V as u}from"./index-c3a466b6.js";function l(t,n,e=1){const i=n!==void 0?t:0;if(n=n!==void 0?n:t,n==i)return[];const r=n>i?1:-1;return[...Array(Math.floor(Math.abs(n-i)/e))].map((h,d)=>i+d*e*r)}function y(t,n,e){return t>e?e:t<n?n:t}class k extends u{constructor(){super(...arguments);s(this,"keybinds",{});s(this,"_keybinds",{})}initKeybinds(){}mounted(){document.addEventListener("keydown",this.keyListener),this.initKeybinds(),Object.keys(this.keybinds).forEach(e=>this._keybinds[e.toLowerCase()]=this.keybinds[e])}unmounted(){document.removeEventListener("keydown",this.keyListener)}keyListener(e){let i=e.key;e.shiftKey&&(i="Shift"+i),e.altKey&&(i="Alt"+i),e.ctrlKey&&(i="Ctrl"+i),e.metaKey&&(i="Cmd"+i),i=i.toLowerCase(),console.log(i),i in this._keybinds&&this._keybinds[i](e)!==!1&&e.preventDefault()}}function m(t){return t.charAt(0).toUpperCase()+t.slice(1)}function b(t){let n=t.length,e;for(;n!=0;)e=Math.floor(Math.random()*n),n--,[t[n],t[e]]=[t[e],t[n]];return t}export{k as K,m as c,y as m,l as r,b as s};