/** * Minified by jsDelivr using Terser v5.19.2. * Original file: /npm/@deepdub/ninja-keys@1.2.11/dist/command-score.js * * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files */ const SCORE_CONTINUE_MATCH=1,SCORE_SPACE_WORD_JUMP=.9,SCORE_NON_SPACE_WORD_JUMP=.8,SCORE_CHARACTER_JUMP=.3,PENALTY_SKIPPED=.999,PENALTY_CASE_MISMATCH=.9999,PENALTY_NOT_COMPLETE=.99,IS_GAP_REGEXP=/[\\/_+.#"@[({&]/,COUNT_GAPS_REGEXP=/[\\/_+.#"@[({&]/g,IS_SPACE_REGEXP=/[\s-]/,COUNT_SPACE_REGEXP=/[\s-]/g;function commandScoreInner(E,_,P,C,e,n,t){if(n===_.length)return e===E.length?{score:SCORE_CONTINUE_MATCH,indices:[]}:{score:PENALTY_NOT_COMPLETE,indices:[]};const A=`${e},${n}`;if(void 0!==t[A])return t[A];const S=C.charAt(n);let c,r,o,O,T=P.indexOf(S,e),R=0,N=[];for(;T>=0;)O=commandScoreInner(E,_,P,C,T+1,n+1,t),c=O.score,c>R&&(T===e?c*=SCORE_CONTINUE_MATCH:IS_GAP_REGEXP.test(E.charAt(T-1))?(c*=SCORE_NON_SPACE_WORD_JUMP,r=E.slice(e,T-1).match(COUNT_GAPS_REGEXP),r&&e>0&&(c*=Math.pow(PENALTY_SKIPPED,r.length))):IS_SPACE_REGEXP.test(E.charAt(T-1))?(c*=SCORE_SPACE_WORD_JUMP,o=E.slice(e,T-1).match(COUNT_SPACE_REGEXP),o&&e>0&&(c*=Math.pow(PENALTY_SKIPPED,o.length))):(c*=SCORE_CHARACTER_JUMP,e>0&&(c*=Math.pow(PENALTY_SKIPPED,T-e))),E.charAt(T)!==_.charAt(n)&&(c*=PENALTY_CASE_MISMATCH)),c>R&&(N=[T,...O.indices],R=c),T=P.indexOf(S,T+1);return t[A]={score:R,indices:N},{score:R,indices:N}}function formatInput(E){return E.toLowerCase().replace(COUNT_SPACE_REGEXP," ")}function commandScore(E,_){return commandScoreInner(E,_,formatInput(E),formatInput(_),0,0,{})}export{commandScore};