var R=Object.defineProperty;var v=t=>{throw TypeError(t)};var U=(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)=>U(t,typeof r!="symbol"?r+"":r,e),b=(t,r,e)=>r.has(t)||v("Cannot "+e);var s=(t,r,e)=>(b(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),M=(t,r,e,o)=>(b(t,r,"write to private field"),o?o.call(t,e):r.set(t,e),e),F=(t,r,e)=>(b(t,r,"access private method"),e);import{al as q,bU as I,bg as j,bd as B}from"./D_PZV9Md.mjs";import"./E-vkuI0X.mjs";import{i as L}from"./D7QRsIUK.mjs";import{a as _,j as z}from"./BZYxBvHH.mjs";import{p as D}from"./3irscRxQ.mjs";import{W as K,Y as N}from"./Bw_OGHRt.mjs";import{eU as V,eV as Y,f3 as $}from"./CPjd1xqp.mjs";var a,u,h,l,W;const p=class p{constructor(r){d(this,l);d(this,a,new WeakMap);d(this,u);d(this,h);M(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,W).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,W=function(){var r;return(r=s(this,u))!=null?r:M(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 G=new y({box:"border-box"});function wt(t,r,e){var o=G.observe(t,()=>e(t[r]));q(()=>(I(()=>e(t[r])),o))}function bt(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 Mt(){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 H(t){return P[A.indexOf(t)]}function J(t){let r=!1;for(const e of A)r||(r=t.code.startsWith(e));return r}const Q=(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=H(t),o=r.getModifierState(e);return r.type==="keyup"?o&&r.key!==e:o},St=g("Control"),yt=g("Shift"),At=g("Alt"),m=g("Meta");function X(t){const r=f()?["^","⌥","⇧","⌘"]:[`${V()}+`,"Alt+",`${Y()}+`,"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 X(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)&&Q(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=K(document,"keydown",w,{once:!0});function w(c){n(c)?T(t,c,e,...i):J(c)||k()}}const S={target:document,event:"keydown"};function O(t,r,e=S){const{target:o=S.target,event:n=S.event}=e,[i,...k]=E(r).map(ut);function w(c){i(c)&&T(o,c,t,...k)}return K(o,n,w)}$("anki/shortcuts",{registerShortcut:O,getPlatformString:et});function Kt(t,r){j(r,!1);let e=D(r,"keyCombination",8),o=D(r,"event",8,void 0);const n=_();z(()=>O(i=>{N(i),n("action",{originalEvent:i})},e(),{event:o()})),L(),B()}export{Kt as S,At as a,wt as b,St as c,Ft as d,Pt as e,vt as f,et as g,Ct as h,f as i,Mt as j,Dt as o,bt as p,O as r,yt as s};
