{"version":3,"sources":["../index.ts"],"sourcesContent":["import Note from \"@tonaljs/note\";\n\n// A function that decides which of a set of voicings is picked as a follow up to lastVoicing.\nexport declare type VoiceLeadingFunction = (\n  voicings: string[][],\n  lastVoicing: string[],\n) => string[];\n\nexport const topNoteDiff: VoiceLeadingFunction = (voicings, lastVoicing) => {\n  if (!lastVoicing || !lastVoicing.length) {\n    return voicings[0];\n  }\n  const topNoteMidi = (voicing: string[]) =>\n    Note.midi(voicing[voicing.length - 1]) || 0;\n  const diff = (voicing: string[]) =>\n    Math.abs(topNoteMidi(lastVoicing) - topNoteMidi(voicing));\n  return voicings.sort((a, b) => diff(a) - diff(b))[0];\n};\n\n/** @deprecated */\nexport default {\n  topNoteDiff,\n};\n"],"mappings":";AAAA,OAAO,UAAU;AAQV,IAAM,cAAoC,CAAC,UAAU,gBAAgB;AAC1E,MAAI,CAAC,eAAe,CAAC,YAAY,QAAQ;AACvC,WAAO,SAAS,CAAC;AAAA,EACnB;AACA,QAAM,cAAc,CAAC,YACnB,KAAK,KAAK,QAAQ,QAAQ,SAAS,CAAC,CAAC,KAAK;AAC5C,QAAM,OAAO,CAAC,YACZ,KAAK,IAAI,YAAY,WAAW,IAAI,YAAY,OAAO,CAAC;AAC1D,SAAO,SAAS,KAAK,CAAC,GAAG,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC;AACrD;AAGA,IAAO,gBAAQ;AAAA,EACb;AACF;","names":[]}