{
  "version": 3,
  "sources": ["../../../src/components/post-list/use-notes-count.js"],
  "sourcesContent": ["import { useMemo } from '@wordpress/element';\nimport { useEntityRecords } from '@wordpress/core-data';\n\n/**\n * Hook to fetch notes counts for a list of post IDs.\n *\n * Notes are stored as comments with type 'note'.\n * This hook fetches all notes for the given posts and returns\n * a map of post ID to notes count.\n *\n * @param {number[]} postIds - Array of post IDs to fetch notes for.\n * @return {{ notesCount: Object, isResolving: boolean }} Object with notesCount map and loading state.\n */\nexport default function useNotesCount( postIds ) {\n\tconst { records: notes, isResolving } = useEntityRecords(\n\t\t'root',\n\t\t'comment',\n\t\t{\n\t\t\tpost: postIds,\n\t\t\ttype: 'note',\n\t\t\tstatus: 'all',\n\t\t\tper_page: -1,\n\t\t\t_fields: 'id,post',\n\t\t},\n\t\t{\n\t\t\tenabled: postIds?.length > 0,\n\t\t}\n\t);\n\n\tconst notesCount = useMemo( () => {\n\t\tif ( ! notes || notes.length === 0 ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tconst counts = {};\n\t\tnotes.forEach( ( note ) => {\n\t\t\tconst postId = note.post;\n\t\t\tcounts[ postId ] = ( counts[ postId ] || 0 ) + 1;\n\t\t} );\n\n\t\treturn counts;\n\t}, [ notes ] );\n\n\treturn { notesCount, isResolving };\n}\n"],
  "mappings": ";AAAA,SAAS,eAAe;AACxB,SAAS,wBAAwB;AAYlB,SAAR,cAAgC,SAAU;AAChD,QAAM,EAAE,SAAS,OAAO,YAAY,IAAI;AAAA,IACvC;AAAA,IACA;AAAA,IACA;AAAA,MACC,MAAM;AAAA,MACN,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,SAAS;AAAA,IACV;AAAA,IACA;AAAA,MACC,SAAS,SAAS,SAAS;AAAA,IAC5B;AAAA,EACD;AAEA,QAAM,aAAa,QAAS,MAAM;AACjC,QAAK,CAAE,SAAS,MAAM,WAAW,GAAI;AACpC,aAAO,CAAC;AAAA,IACT;AAEA,UAAM,SAAS,CAAC;AAChB,UAAM,QAAS,CAAE,SAAU;AAC1B,YAAM,SAAS,KAAK;AACpB,aAAQ,MAAO,KAAM,OAAQ,MAAO,KAAK,KAAM;AAAA,IAChD,CAAE;AAEF,WAAO;AAAA,EACR,GAAG,CAAE,KAAM,CAAE;AAEb,SAAO,EAAE,YAAY,YAAY;AAClC;",
  "names": []
}
