{"version":3,"file":"functions.mjs","sources":["../../../lib/ui/filters/functions.ts"],"sourcesContent":["/*!\n * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\n\nimport type { IFileListFilter } from './listFilters.ts'\n\nimport { scopedGlobals } from '../../globalScope.ts'\nimport { getRegistry } from '../registry.ts'\n\n/**\n * Register a new filter on the file list\n *\n * This only must be called once to register the filter,\n * when the filter state changes you need to call `filterUpdated` on the filter instead.\n *\n * @param filter The filter to register on the file list\n */\nexport function registerFileListFilter(filter: IFileListFilter): void {\n\tscopedGlobals.fileListFilters ??= new Map<string, IFileListFilter>()\n\tif (scopedGlobals.fileListFilters.has(filter.id)) {\n\t\tthrow new Error(`File list filter \"${filter.id}\" already registered`)\n\t}\n\n\tscopedGlobals.fileListFilters.set(filter.id, filter)\n\tgetRegistry()\n\t\t.dispatchTypedEvent('register:listFilter', new CustomEvent('register:listFilter', { detail: filter }))\n}\n\n/**\n * Remove a registered filter from the file list\n *\n * @param filterId The unique ID of the filter to remove\n */\nexport function unregisterFileListFilter(filterId: string): void {\n\tif (scopedGlobals.fileListFilters && scopedGlobals.fileListFilters.has(filterId)) {\n\t\tscopedGlobals.fileListFilters.delete(filterId)\n\t\tgetRegistry()\n\t\t\t.dispatchTypedEvent('unregister:listFilter', new CustomEvent('unregister:listFilter', { detail: filterId }))\n\t}\n}\n\n/**\n * Get all registered file list filters\n */\nexport function getFileListFilters(): IFileListFilter[] {\n\tif (scopedGlobals.fileListFilters) {\n\t\treturn [...scopedGlobals.fileListFilters.values()]\n\t}\n\treturn []\n}\n"],"names":[],"mappings":";;AAAA;AAAA;AAAA;AAAA;AAkBO,SAAS,uBAAuB,QAA+B;AACrE,gBAAc,wCAAwB,IAAA;AACtC,MAAI,cAAc,gBAAgB,IAAI,OAAO,EAAE,GAAG;AACjD,UAAM,IAAI,MAAM,qBAAqB,OAAO,EAAE,sBAAsB;AAAA,EACrE;AAEA,gBAAc,gBAAgB,IAAI,OAAO,IAAI,MAAM;AACnD,cAAA,EACE,mBAAmB,uBAAuB,IAAI,YAAY,uBAAuB,EAAE,QAAQ,OAAA,CAAQ,CAAC;AACvG;AAOO,SAAS,yBAAyB,UAAwB;AAChE,MAAI,cAAc,mBAAmB,cAAc,gBAAgB,IAAI,QAAQ,GAAG;AACjF,kBAAc,gBAAgB,OAAO,QAAQ;AAC7C,gBAAA,EACE,mBAAmB,yBAAyB,IAAI,YAAY,yBAAyB,EAAE,QAAQ,SAAA,CAAU,CAAC;AAAA,EAC7G;AACD;AAKO,SAAS,qBAAwC;AACvD,MAAI,cAAc,iBAAiB;AAClC,WAAO,CAAC,GAAG,cAAc,gBAAgB,QAAQ;AAAA,EAClD;AACA,SAAO,CAAA;AACR;"}