var R=Object.defineProperty;var v=t=>{throw TypeError(t)};var q=(t,r,e)=>r in t?R(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e;var C=(t,r,e)=>q(t,typeof r!="symbol"?r+"":r,e),M=(t,r,e)=>r.has(t)||v("Cannot "+e);var s=(t,r,e)=>(M(t,r,"read from private field"),e?e.call(t):r.get(t)),d=(t,r,e)=>r.has(t)?v("Cannot add the same private member more than once"):r instanceof WeakSet?r.add(t):r.set(t,e),S=(t,r,e,o)=>(M(t,r,"write to private field"),o?o.call(t,e):r.set(t,e),e),F=(t,r,e)=>(M(t,r,"access private method"),e);import{W as I,u as B,p as L,d as U}from"./CcSQ4gIZ.mjs";import"./E-vkuI0X.mjs";import{i as _}from"./ClvfIese.mjs";import{c as j,o as z}from"./Ds880vvq.mjs";import{p as D}from"./Bqtw3-M2.mjs";import{o as W,p as N}from"./CP9u1sU-.mjs";import{W as X,X as $,r as G}from"./Bv5e84VY.mjs";var a,u,h,l,K;const p=class p{constructor(r){d(this,l);d(this,a,new WeakMap);d(this,u);d(this,h);S(this,h,r)}observe(r,e){var o=s(this,a).get(r)||new Set;return o.add(e),s(this,a).set(r,o),F(this,l,K).call(this).observe(r,s(this,h)),()=>{var n=s(this,a).get(r);n.delete(e),n.size===0&&(s(this,a).delete(r),s(this,u).unobserve(r))}}};a=new WeakMap,u=new WeakMap,h=new WeakMap,l=new WeakSet,K=function(){var r;return(r=s(this,u))!=null?r:S(this,u,new ResizeObserver(e=>{for(var o of e){p.entries.set(o.target,o);for(var n of s(this,a).get(o.target)||[])n(o)}}))},C(p,"entries",new WeakMap);let y=p;var H=new y({box:"border-box"});function wt(t,r,e){var o=H.observe(t,()=>e(t[r]));I(()=>(B(()=>e(t[r])),o))}function Mt(t){return function(...r){var e=r[0];return e.preventDefault(),t==null?void 0:t.apply(this,r)}}function f(){const t=window.navigator.platform;return t.startsWith("Mac")||t.startsWith("iP")}function St(){return!/iphone|ipad|ipod|android/i.test(window.navigator.userAgent)}const A=["Control","Alt","Shift","Meta"],P=f()?["Meta","Alt","Shift","Control"]:["Control","Alt","Shift","OS"];function J(t){return P[A.indexOf(t)]}function Q(t){let r=!1;for(const e of A)r||(r=t.code.startsWith(e));return r}const V=(t,r=[])=>e=>A.reduce((o,n,i)=>o&&(r.includes(n)||e.getModifierState(P[i])===t.includes(n)),!0),g=t=>r=>{const e=J(t),o=r.getModifierState(e);return r.type==="keyup"?o&&r.key!==e:o},bt=g("Control"),yt=g("Shift"),At=g("Alt"),m=g("Meta");function Y(t){const r=f()?["^","⌥","⇧","⌘"]:[`${X()}+`,"Alt+",`${$()}+`,"Win+"];let e="";for(const o of t)e+=r[P.indexOf(o)];return e}function Z(t){switch(t){case"Backspace":return"⌫";case"Delete":return"⌦";case"Escape":return"⎋";default:return t}}function Pt(t){return t.key==="ArrowLeft"?!0:f()&&m(t)&&t.code==="KeyB"}function vt(t){return t.key==="ArrowRight"?!0:f()&&m(t)&&t.code==="KeyF"}function Ct(t){return t.key==="ArrowUp"?!0:f()&&m(t)&&t.code==="KeyP"}function Ft(t){return t.key==="ArrowDown"?!0:f()&&m(t)&&t.code==="KeyN"}function Dt(t){return r=>{switch(r.code){case"Enter":case"Space":t();break}}}const tt={Backspace:8,Delete:46,Tab:9,Enter:13,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,"=":187,"-":189,"[":219,"]":221,"\\":220,";":186,"'":222,",":188,".":190,"/":191,"`":192};function x(t){return!t.endsWith("?")}function E(t){return t.split(", ").map(r=>r.split("+"))}function rt(t){return Y(t.slice(0,-1).filter(x))+Z(t[t.length-1])}function et(t){return E(t).map(rt).join(", ")}function ot(t,r){return t.which===r}function nt(t,r){const e=[],o=[];return r.forEach(n=>{(t(n)?e:o).push(n)}),[e,o]}function it(t){return t.substring(0,t.length-1)}function st(t){const[r,e]=nt(x,t),o=e.map(it);return[r,o]}const at=(t,r,e)=>o=>ot(o,t)&&V(r,e)(o);function ct(t){return tt[t]||t.toUpperCase().charCodeAt(0)}function ut(t){const r=ct(t[t.length-1]),[e,o]=st(t.slice(0,-1));return at(r,e,o)}function T(t,r,e,...o){if(o.length===0)return e(r);const[n,...i]=o,k=W(document,"keydown",w,{once:!0});function w(c){n(c)?T(t,c,e,...i):Q(c)||k()}}const b={target:document,event:"keydown"};function O(t,r,e=b){const{target:o=b.target,event:n=b.event}=e,[i,...k]=E(r).map(ut);function w(c){i(c)&&T(o,c,t,...k)}return W(o,n,w)}G("anki/shortcuts",{registerShortcut:O,getPlatformString:et});function Wt(t,r){L(r,!1);let e=D(r,"keyCombination",8),o=D(r,"event",8,void 0);const n=j();z(()=>O(i=>{N(i),n("action",{originalEvent:i})},e(),{event:o()})),_(),U()}export{Wt as S,Ct as a,wt as b,At as c,Pt as d,vt as e,bt as f,et as g,f as h,Ft as i,St as j,Dt as o,Mt as p,O as r,yt as s};
