{"version":3,"file":"list-action.mjs","names":[],"sources":["../../src/actions/list-action.ts"],"sourcesContent":["import type { Command } from 'commander';\n\nimport { Resource, parseAllMappings } from '@4bitlabs/sci0';\nimport { readFile } from '../helpers/read-file.js';\nimport { getRootOptions } from './get-root-options.js';\n\nexport const listActionFor = (matchFn: (id: number) => boolean) =>\n  async function listAction(_: unknown, cmd: Command) {\n    const { root } = getRootOptions(cmd);\n\n    const mapping = parseAllMappings(await readFile(root, 'RESOURCE.MAP'));\n\n    const picSet = new Set<number>(\n      mapping\n        .filter((it) => matchFn(it.id))\n        .map((it) => Resource.getNumber(it.id)),\n    );\n\n    [...picSet.values()]\n      .sort((a, b) => a - b)\n      .forEach((it) => {\n        console.log(it.toString(10));\n      });\n  };\n"],"mappings":";;;;AAMA,MAAa,iBAAiB,YAC5B,eAAe,WAAW,GAAY,KAAc;CAClD,MAAM,EAAE,SAAS,eAAe,GAAG;CAEnC,MAAM,UAAU,iBAAiB,MAAM,SAAS,MAAM,cAAc,CAAC;CAQrE,CAAC,GAAG,IANe,IACjB,QACG,QAAQ,OAAO,QAAQ,GAAG,EAAE,CAAC,CAAC,CAC9B,KAAK,OAAO,SAAS,UAAU,GAAG,EAAE,CAAC,CAGjC,CAAC,CAAC,OAAO,CAAC,CAAC,CACjB,MAAM,GAAG,MAAM,IAAI,CAAC,CAAC,CACrB,SAAS,OAAO;EACf,QAAQ,IAAI,GAAG,SAAS,EAAE,CAAC;CAC7B,CAAC;AACL"}