Peach: Local-first video metadata scraper and media manager.
import{f as e}from"./predicate-DSCS8XT4.js";import{A as t,S as n,k as r}from"./volume-DmN9I9eo.js";import{t as i}from"./listen-4VrUltMW.js";import{t as a}from"./interaction-lock-DKc9gO7E.js";function o(){return typeof navigator<`u`&&/mac/i.test(navigator.userAgent)}const s={shift:`Shift`,ctrl:`Control`,alt:`Alt`,meta:`Meta`},c={shift:`Shift`,ctrl:`Ctrl`,alt:`Alt`,meta:`Meta`},l=[`ctrl`,`shift`,`alt`,`meta`];function u(e){return e.map(e=>{let t=[];for(let n of l)e.modifiers.has(n)&&t.push(s[n]);return t.push(e.originalKey),t.join(`+`)}).join(` `)}function d(e){let t=[];for(let n of l)e.modifiers.has(n)&&t.push(c[n]);return t.push(f(e.originalKey)),t.join(`+`)}function f(e){return e.length===1?e.toUpperCase():e}var p=class{#e;#t=[];#n=0;#r=null;#i=null;#a=/* @__PURE__ */ new Set;#o=/* @__PURE__ */ new Set;#s=!1;constructor(e){this.#e=e}subscribe(e){return this.#a.add(e),()=>this.#a.delete(e)}subscribeShortcutChanges(e){return this.#o.add(e),()=>this.#o.delete(e)}add(e){let t={parsed:h(e.keys),options:e,id:this.#n++};this.#t.push(t),this.#c(),e.target===`document`?this.#u():this.#l(),this.#h();let n=!1;return()=>{if(n)return;n=!0;let e=this.#t.indexOf(t);e!==-1&&this.#t.splice(e,1),this.#d(),this.#h()}}getAriaKeys(e){return this.getShortcut(e).aria}getShortcut(e,t){let n=this.#p(e,t);if(!n.length)return{};let r=n.flatMap(e=>e.parsed),i=n[n.length-1];return{aria:u(r),shortcut:this.#m(i)}}destroy(){this.#s||(this.#s=!0,this.#r?.abort(),this.#r=null,this.#i?.abort(),this.#i=null,this.#t=[],this.#h(),this.#a.clear(),this.#o.clear())}#c(){this.#t.sort((e,t)=>{let n=t.parsed[0].modifiers.size-e.parsed[0].modifiers.size;return n===0?e.id-t.id:n})}#l(){this.#r||(this.#r=new AbortController,i(this.#e,`keydown`,this.#f,{signal:this.#r.signal}))}#u(){this.#i||(this.#i=new AbortController,i(document,`keydown`,this.#f,{signal:this.#i.signal}))}#d(){let e=this.#t.some(e=>e.options.target!==`document`),t=this.#t.some(e=>e.options.target===`document`);e||(this.#r?.abort(),this.#r=null),t||(this.#i?.abort(),this.#i=null)}#f=e=>{if(a(this.#e)||e.key===`Unidentified`||t(e)||e.defaultPrevented)return;let n=r(e);for(let t of this.#t){let{options:r,parsed:i}=t;if(!r.disabled&&!(e.repeat&&r.repeatable===!1)&&r.target===`document`==(e.currentTarget===document)){for(let t of i)if(_(t,e)&&!(n&&t.modifiers.size===0)){if(this.#a.size>0){let t={source:`hotkey`,action:r.action,value:r.value,event:e};for(let e of this.#a)try{e(t)}catch{}}e.preventDefault(),r.onActivate(e,t.originalKey);return}}}};#p(t,n){return this.#t.filter(r=>r.options.disabled||r.options.action!==t?!1:e(n)?!0:r.options.value===n).sort((e,t)=>e.id-t.id)}#m(e){return e.options.keys===`0-9`?e.options.keys:d(e.parsed[0])}#h(){for(let e of this.#o)e()}};const m=/* @__PURE__ */ new Set([`shift`,`ctrl`,`alt`,`meta`]);function h(e){if(e===`0-9`)return Array.from({length:10},(e,t)=>({modifiers:/* @__PURE__ */ new Set,key:String(t),originalKey:String(t)}));let t=e.split(`+`),n=t.pop(),r=/* @__PURE__ */ new Set;for(let e of t){let t=e.toLowerCase();t===`mod`?r.add(o()?`meta`:`ctrl`):m.has(t)&&r.add(t)}return[{modifiers:r,key:n===`Space`?` `:n.toLowerCase(),originalKey:n}]}function g(e){return e.length===1&&!/[a-z]/i.test(e)}function _(e,t){if(t.key===`Unidentified`||t.key.toLowerCase()!==e.key)return!1;let n=g(t.key),r=n?t.shiftKey&&e.modifiers.has(`shift`):t.shiftKey,i=n?t.altKey&&e.modifiers.has(`alt`):t.altKey;return r===e.modifiers.has(`shift`)&&t.ctrlKey===e.modifiers.has(`ctrl`)&&i===e.modifiers.has(`alt`)&&t.metaKey===e.modifiers.has(`meta`)}const v=/* @__PURE__ */ new WeakMap;function y(e){let t=v.get(e);return t||(t=new p(e),v.set(e,t)),t}function b(e,t){let r=y(e),i=h(t.keys)[0]?.originalKey;return r.add({...t,value:n(t.action??``,i,t.value)})}export{y as n,b as t};
//# sourceMappingURL=hotkey-Cc9a0Omj.js.map