@behindthemusictree/app-kit 33.3.0 → 34.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -56,6 +56,10 @@ __export(src_exports, {
56
56
  FORM_RATING_NULL_VALUE: () => FORM_RATING_NULL_VALUE,
57
57
  FUZZY_MIN_SIMILARITY: () => FUZZY_MIN_SIMILARITY,
58
58
  GOOGLE_EXCHANGE_CONFIG: () => GOOGLE_EXCHANGE_CONFIG,
59
+ GenreCatalogueCountsSchema: () => GenreCatalogueCountsSchema,
60
+ GenreCountsSchema: () => GenreCountsSchema,
61
+ GenreCoverageSchema: () => GenreCoverageSchema,
62
+ GenrePlaylistSummarySchema: () => GenrePlaylistSummarySchema,
59
63
  GenrePlaylistUuidSchema: () => GenrePlaylistUuidSchema,
60
64
  GenreSearchResultSchema: () => GenreSearchResultSchema,
61
65
  GenreSearchResultsSchema: () => GenreSearchResultsSchema,
@@ -73,6 +77,8 @@ __export(src_exports, {
73
77
  PlayerProvider: () => PlayerProvider,
74
78
  PlayerVideoSurface: () => PlayerVideoSurface,
75
79
  PopupProvider: () => PopupProvider,
80
+ ReferenceGenreDetailedSchema: () => ReferenceGenreDetailedSchema,
81
+ ReferenceGenrePlaylistSchema: () => ReferenceGenrePlaylistSchema,
76
82
  RegionGenreLexiconEntrySchema: () => RegionGenreLexiconEntrySchema,
77
83
  RegionGenreLexiconSchema: () => RegionGenreLexiconSchema,
78
84
  SEARCH_DEBOUNCE_MS: () => SEARCH_DEBOUNCE_MS,
@@ -85,6 +91,8 @@ __export(src_exports, {
85
91
  SongHistorySchema: () => SongHistorySchema,
86
92
  SongSearchResultSchema: () => SongSearchResultSchema,
87
93
  SongSearchResultsSchema: () => SongSearchResultsSchema,
94
+ SubgenreCountsSchema: () => SubgenreCountsSchema,
95
+ SubgenreScopeSchema: () => SubgenreScopeSchema,
88
96
  TrackBaseSchema: () => TrackBaseSchema,
89
97
  TrackList: () => TrackList,
90
98
  TrackListFromArtist: () => TrackListFromArtist,
@@ -93,6 +101,7 @@ __export(src_exports, {
93
101
  TrackListOrigin: () => TrackListOrigin,
94
102
  TrackListOriginFromArtist: () => TrackListOriginFromArtist,
95
103
  TrackListOriginFromCriteriaPlaylist: () => TrackListOriginFromCriteriaPlaylist,
104
+ TrackListOriginFromGenreCatalogue: () => TrackListOriginFromGenreCatalogue,
96
105
  TrackListOriginFromTrack: () => TrackListOriginFromTrack,
97
106
  TrackListOriginType: () => TrackListOriginType,
98
107
  TrackListProvider: () => TrackListProvider,
@@ -115,14 +124,19 @@ __export(src_exports, {
115
124
  createAppErrorFromResult: () => createAppErrorFromResult,
116
125
  createLogout: () => createLogout,
117
126
  createNetworkOrBackendError: () => createNetworkOrBackendError,
127
+ defaultGenreMusicSelection: () => defaultGenreMusicSelection,
118
128
  editGenreSongPages: () => editGenreSongPages,
119
129
  exchangeCodeWithBackend: () => exchangeCodeWithBackend,
120
130
  fetchWrapper: () => fetchWrapper,
121
131
  foldSearchText: () => foldSearchText,
122
132
  formatTime: () => formatTime,
123
133
  genreEndpoints: () => genreEndpoints,
134
+ genreMusicCount: () => genreMusicCount,
135
+ genreMusicQueryParams: () => genreMusicQueryParams,
136
+ genreMusicSelectionKey: () => genreMusicSelectionKey,
124
137
  genrePlaylistEndpoints: () => genrePlaylistEndpoints,
125
138
  genrePlaylistQueryKeys: () => genrePlaylistQueryKeys,
139
+ genrePlaylistTrackCount: () => genrePlaylistTrackCount,
126
140
  genreQueryKeys: () => genreQueryKeys,
127
141
  genreSearchQueryKeys: () => genreSearchQueryKeys,
128
142
  genreUpdateMutationKey: () => genreUpdateMutationKey,
@@ -1980,56 +1994,159 @@ function useCurrentTime() {
1980
1994
  }
1981
1995
 
1982
1996
  // src/genre-tree/useGenre.ts
1983
- var import_zod23 = require("zod");
1984
- var import_react_query5 = require("@tanstack/react-query");
1985
- var import_react13 = require("react");
1997
+ var import_zod24 = require("zod");
1986
1998
 
1987
- // src/genre-tree/useGenrePlaylist.ts
1988
- var import_zod10 = require("zod");
1989
- var import_react_query4 = require("@tanstack/react-query");
1999
+ // src/genre-tree/schemas/criteria/detailed.ts
2000
+ var import_zod15 = require("zod");
1990
2001
 
1991
- // src/genre-tree/schemas/criteria-playlist/simple.ts
1992
- var import_zod9 = require("zod");
2002
+ // src/genre-tree/schemas/genre-music.ts
2003
+ var import_zod7 = require("zod");
1993
2004
 
1994
- // src/genre-tree/schemas/criteria-playlist/detailed.ts
1995
- var import_zod8 = require("zod");
2005
+ // src/genre-tree/schemas/criteria-playlist/minimum.ts
2006
+ var import_zod6 = require("zod");
1996
2007
 
1997
2008
  // src/genre-tree/schemas/ids.ts
1998
2009
  var import_zod5 = require("zod");
1999
2010
  var GenreUuidSchema = import_zod5.z.string().uuid().brand();
2000
2011
  var GenrePlaylistUuidSchema = import_zod5.z.string().uuid().brand();
2001
2012
 
2013
+ // src/genre-tree/schemas/criteria-playlist/minimum.ts
2014
+ var CriteriaPlaylistMinimumSchema = import_zod6.z.object({
2015
+ uuid: GenrePlaylistUuidSchema,
2016
+ name: import_zod6.z.string()
2017
+ });
2018
+
2019
+ // src/genre-tree/schemas/genre-music.ts
2020
+ var CountSchema = import_zod7.z.number().int().nonnegative();
2021
+ var SubgenreCountsSchema = import_zod7.z.union([
2022
+ import_zod7.z.object({ canonical: CountSchema, regional: CountSchema, all: CountSchema }).strict(),
2023
+ import_zod7.z.object({ all: CountSchema }).strict()
2024
+ ]).refine(
2025
+ (counts) => !("canonical" in counts) || counts.all >= counts.canonical && counts.all >= counts.regional,
2026
+ "The combined count must include both scoped selections"
2027
+ );
2028
+ var GenreCountsSchema = import_zod7.z.object({
2029
+ genreOnlyTracksCount: CountSchema,
2030
+ genreAndSubgenresTracksCount: SubgenreCountsSchema
2031
+ });
2032
+ var includesDirectSongs = (counts) => Object.values(counts.genreAndSubgenresTracksCount).every((count) => count >= counts.genreOnlyTracksCount);
2033
+ var GenreCatalogueCountsSchema = GenreCountsSchema.refine(includesDirectSongs, "Every inclusive count must include the genre itself").brand();
2034
+ var GenrePlaylistSummarySchema = CriteriaPlaylistMinimumSchema.extend(GenreCountsSchema.shape).refine(includesDirectSongs, "Every inclusive count must include the genre itself").brand();
2035
+ var GenreCoverageSchema = import_zod7.z.enum(["genreOnly", "genreAndSubgenres"]);
2036
+ var SubgenreScopeSchema = import_zod7.z.enum(["canonical", "regional", "all"]);
2037
+
2002
2038
  // src/genre-tree/schemas/criteria/minimum.ts
2003
- var import_zod6 = require("zod");
2004
- var CriteriaMinimumSchema = import_zod6.z.object({
2039
+ var import_zod8 = require("zod");
2040
+ var CriteriaMinimumSchema = import_zod8.z.object({
2005
2041
  uuid: GenreUuidSchema,
2006
- name: import_zod6.z.string(),
2007
- side: import_zod6.z.enum(["core", "pop"]).nullable().optional(),
2008
- wikidataId: import_zod6.z.string().nullable().optional()
2042
+ name: import_zod8.z.string(),
2043
+ side: import_zod8.z.enum(["core", "pop"]).nullable().optional(),
2044
+ wikidataId: import_zod8.z.string().nullable().optional()
2009
2045
  });
2010
2046
 
2011
- // src/genre-tree/schemas/criteria-playlist/minimum.ts
2012
- var import_zod7 = require("zod");
2013
- var CriteriaPlaylistMinimumSchema = import_zod7.z.object({
2014
- uuid: GenrePlaylistUuidSchema,
2015
- name: import_zod7.z.string()
2047
+ // src/genre-tree/schemas/track/base.ts
2048
+ var import_zod12 = require("zod");
2049
+
2050
+ // src/genre-tree/schemas/artist-minimum.ts
2051
+ var import_zod9 = require("zod");
2052
+ var ArtistMinimumSchema = import_zod9.z.object({
2053
+ uuid: import_zod9.z.string().uuid(),
2054
+ name: import_zod9.z.string(),
2055
+ isSpecialPurpose: import_zod9.z.boolean().optional()
2056
+ });
2057
+
2058
+ // src/genre-tree/schemas/album-minimum.ts
2059
+ var import_zod10 = require("zod");
2060
+ var AlbumMinimumSchema = import_zod10.z.object({
2061
+ uuid: import_zod10.z.string().uuid(),
2062
+ name: import_zod10.z.string(),
2063
+ albumArtists: import_zod10.z.array(ArtistMinimumSchema).nullable().optional()
2064
+ });
2065
+
2066
+ // src/genre-tree/schemas/uuid-resource.ts
2067
+ var import_zod11 = require("zod");
2068
+ var UuidResourceSchema = import_zod11.z.object({
2069
+ uuid: import_zod11.z.string().uuid()
2070
+ });
2071
+
2072
+ // src/genre-tree/schemas/track/base.ts
2073
+ var TrackBaseSchema = UuidResourceSchema.extend({
2074
+ title: import_zod12.z.string(),
2075
+ artists: import_zod12.z.array(ArtistMinimumSchema).nullable().optional(),
2076
+ album: AlbumMinimumSchema.nullable().optional(),
2077
+ trackNumber: import_zod12.z.number().nullable().optional(),
2078
+ // null for a song not yet linked to a genre.
2079
+ genre: CriteriaMinimumSchema.nullable(),
2080
+ rating: import_zod12.z.number().min(0).max(10).nullable().optional(),
2081
+ language: import_zod12.z.string().nullable().optional(),
2082
+ playCount: import_zod12.z.number().min(0),
2083
+ createdOn: import_zod12.z.string().datetime(),
2084
+ updatedOn: import_zod12.z.string().datetime().nullable().optional()
2085
+ });
2086
+
2087
+ // src/genre-tree/schemas/track/minimum.ts
2088
+ var TrackMinimumSchema = TrackBaseSchema.pick({
2089
+ uuid: true,
2090
+ title: true,
2091
+ artists: true
2092
+ });
2093
+
2094
+ // src/genre-tree/schemas/criteria/lineage-rel/without-ascendant.ts
2095
+ var import_zod13 = require("zod");
2096
+ var CriteriaLineageRelWithoutAscendantSchema = import_zod13.z.object({
2097
+ descendant: CriteriaMinimumSchema,
2098
+ degree: import_zod13.z.number()
2099
+ });
2100
+
2101
+ // src/genre-tree/schemas/criteria/lineage-rel/without-descendant.ts
2102
+ var import_zod14 = require("zod");
2103
+ var CriteriaLineageRelWithoutDescendantSchema = import_zod14.z.object({
2104
+ ascendant: CriteriaMinimumSchema,
2105
+ degree: import_zod14.z.number()
2016
2106
  });
2017
2107
 
2108
+ // src/genre-tree/schemas/criteria/detailed.ts
2109
+ var CriteriaDetailedSchema = import_zod15.z.object({
2110
+ uuid: GenreUuidSchema,
2111
+ name: import_zod15.z.string(),
2112
+ summary: import_zod15.z.string().nullable(),
2113
+ // Optional until every deployed API serves it.
2114
+ wikidataId: import_zod15.z.string().nullable().optional(),
2115
+ parent: CriteriaMinimumSchema.nullable(),
2116
+ ascendants: import_zod15.z.array(CriteriaLineageRelWithoutDescendantSchema),
2117
+ descendants: import_zod15.z.array(CriteriaLineageRelWithoutAscendantSchema),
2118
+ root: CriteriaMinimumSchema,
2119
+ children: import_zod15.z.array(CriteriaMinimumSchema),
2120
+ catalogue: GenreCatalogueCountsSchema.optional(),
2121
+ criteriaPlaylist: import_zod15.z.union([GenrePlaylistSummarySchema, CriteriaPlaylistMinimumSchema]),
2122
+ tracks: import_zod15.z.array(TrackMinimumSchema),
2123
+ essentialSongs: import_zod15.z.array(TrackMinimumSchema),
2124
+ tracksCount: import_zod15.z.number(),
2125
+ updatedOn: import_zod15.z.string().datetime().nullable()
2126
+ });
2127
+
2128
+ // src/genre-tree/schemas/criteria-playlist/simple.ts
2129
+ var import_zod17 = require("zod");
2130
+
2018
2131
  // src/genre-tree/schemas/criteria-playlist/detailed.ts
2019
- var CriteriaPlaylistDetailedSchema = import_zod8.z.object({
2132
+ var import_zod16 = require("zod");
2133
+ var CriteriaPlaylistDetailedSchema = import_zod16.z.object({
2020
2134
  uuid: GenrePlaylistUuidSchema,
2021
- name: import_zod8.z.string(),
2022
- tracksCount: import_zod8.z.number(),
2135
+ name: import_zod16.z.string(),
2136
+ tracksCount: import_zod16.z.number(),
2137
+ genreOnlyTracksCount: GenreCountsSchema.shape.genreOnlyTracksCount.optional(),
2138
+ genreAndSubgenresTracksCount: GenreCountsSchema.shape.genreAndSubgenresTracksCount.optional(),
2139
+ catalogue: GenreCatalogueCountsSchema.optional(),
2023
2140
  // Summed YouTube views of the same songs as `tracksCount`. Optional: hear-api has no view counts.
2024
- viewsCount: import_zod8.z.number().optional(),
2025
- durationInSec: import_zod8.z.number().min(0).nullable().optional(),
2026
- durationStrInHourMinSec: import_zod8.z.string().nullable().optional(),
2141
+ viewsCount: import_zod16.z.number().optional(),
2142
+ durationInSec: import_zod16.z.number().min(0).nullable().optional(),
2143
+ durationStrInHourMinSec: import_zod16.z.string().nullable().optional(),
2027
2144
  // Nullable: the "Genreless" root playlist has no criteria attached and is never updated.
2028
2145
  criteria: CriteriaMinimumSchema.nullable(),
2029
2146
  parent: CriteriaPlaylistMinimumSchema.nullable(),
2030
2147
  root: CriteriaPlaylistMinimumSchema,
2031
- createdOn: import_zod8.z.string(),
2032
- updatedOn: import_zod8.z.string().nullable()
2148
+ createdOn: import_zod16.z.string(),
2149
+ updatedOn: import_zod16.z.string().nullable()
2033
2150
  });
2034
2151
 
2035
2152
  // src/genre-tree/schemas/criteria-playlist/simple.ts
@@ -2040,18 +2157,42 @@ var CriteriaPlaylistSimpleSchema = CriteriaPlaylistDetailedSchema.pick({
2040
2157
  parent: true,
2041
2158
  root: true,
2042
2159
  tracksCount: true,
2160
+ genreOnlyTracksCount: true,
2161
+ genreAndSubgenresTracksCount: true,
2162
+ catalogue: true,
2043
2163
  viewsCount: true,
2044
2164
  createdOn: true,
2045
2165
  updatedOn: true
2046
2166
  }).extend({
2047
2167
  // Only on the tree/list payloads, not the detail endpoint — hence not on the detailed schema.
2048
- isUnacceptedRoot: import_zod9.z.boolean(),
2168
+ isUnacceptedRoot: import_zod17.z.boolean(),
2049
2169
  // Optional: a backend that does not curate umbrella genres omits it.
2050
- isUmbrella: import_zod9.z.boolean().optional(),
2170
+ isUmbrella: import_zod17.z.boolean().optional(),
2051
2171
  // Optional: only the grow tree payload carries it; null when the genre has no scene.
2052
- scene: import_zod9.z.enum(["commercial", "underground"]).nullable().optional()
2172
+ scene: import_zod17.z.enum(["commercial", "underground"]).nullable().optional()
2173
+ });
2174
+
2175
+ // src/genre-tree/schemas/reference-genre.ts
2176
+ var ReferenceGenreDetailedSchema = CriteriaDetailedSchema.extend({
2177
+ catalogue: GenreCatalogueCountsSchema,
2178
+ criteriaPlaylist: GenrePlaylistSummarySchema
2179
+ });
2180
+ var ReferenceGenrePlaylistSchema = CriteriaPlaylistSimpleSchema.extend({
2181
+ ...GenreCountsSchema.shape,
2182
+ catalogue: GenreCatalogueCountsSchema
2183
+ }).superRefine((playlist, ctx) => {
2184
+ const counts = GenreCatalogueCountsSchema.safeParse(playlist);
2185
+ if (!counts.success) for (const issue of counts.error.issues) ctx.addIssue({ code: "custom", path: issue.path, message: issue.message });
2053
2186
  });
2054
2187
 
2188
+ // src/genre-tree/useGenre.ts
2189
+ var import_react_query5 = require("@tanstack/react-query");
2190
+ var import_react13 = require("react");
2191
+
2192
+ // src/genre-tree/useGenrePlaylist.ts
2193
+ var import_zod18 = require("zod");
2194
+ var import_react_query4 = require("@tanstack/react-query");
2195
+
2055
2196
  // src/genre-tree/api/genre-playlists/queryKeys.ts
2056
2197
  var genrePlaylistQueryKeys = {
2057
2198
  me: {
@@ -2087,6 +2228,30 @@ var genrePlaylistEndpoints = {
2087
2228
  reference: { ...makeGenrePlaylistEndpoints(""), tree: () => "genre-playlists/tree/" }
2088
2229
  };
2089
2230
 
2231
+ // src/genre-tree/lib/genre-music-selection.ts
2232
+ function defaultGenreMusicSelection(counts) {
2233
+ return { coverage: "genreAndSubgenres", subgenres: "canonical" in counts.genreAndSubgenresTracksCount ? "canonical" : "all" };
2234
+ }
2235
+ function genreMusicCount(counts, selection = defaultGenreMusicSelection(counts)) {
2236
+ if (selection.coverage === "genreOnly") return counts.genreOnlyTracksCount;
2237
+ const scopes = counts.genreAndSubgenresTracksCount;
2238
+ if (selection.subgenres === "all") return scopes.all;
2239
+ if (!("canonical" in scopes)) throw new Error("Regional genres only support all subgenres");
2240
+ return scopes[selection.subgenres];
2241
+ }
2242
+ function genreMusicQueryParams(selection) {
2243
+ if (!selection) return {};
2244
+ return selection.coverage === "genreOnly" ? { coverage: "genre_only" } : { coverage: "genre_and_subgenres", subgenres: selection.subgenres };
2245
+ }
2246
+ function genreMusicSelectionKey(selection) {
2247
+ return selection ? [selection.coverage, ...selection.coverage === "genreAndSubgenres" ? [selection.subgenres] : []] : [];
2248
+ }
2249
+ function genrePlaylistTrackCount(playlist) {
2250
+ if (playlist.genreOnlyTracksCount === void 0 && playlist.genreAndSubgenresTracksCount === void 0) return playlist.tracksCount;
2251
+ if (playlist.genreOnlyTracksCount === void 0 || playlist.genreAndSubgenresTracksCount === void 0) throw new Error("Incomplete genre playlist counts");
2252
+ return genreMusicCount({ genreOnlyTracksCount: playlist.genreOnlyTracksCount, genreAndSubgenresTracksCount: playlist.genreAndSubgenresTracksCount });
2253
+ }
2254
+
2090
2255
  // src/genre-tree/api/library/songs/queryKeys.ts
2091
2256
  var makeSongQueryKeys = (prefix) => ({
2092
2257
  all: [`${prefix}Songs`],
@@ -2095,7 +2260,7 @@ var makeSongQueryKeys = (prefix) => ({
2095
2260
  history: (uuid) => [`${prefix}Songs`, "history", uuid],
2096
2261
  search: (params) => [`${prefix}Songs`, "search", params],
2097
2262
  // baseUrl keeps distinct backends sharing a scope (e.g. grow and its prototype proxy) apart.
2098
- byGenre: (baseUrl, genreUuid) => [`${prefix}Songs`, baseUrl, "genre", genreUuid]
2263
+ byGenre: (baseUrl, genreUuid, selection) => [`${prefix}Songs`, baseUrl, "genre", genreUuid, ...genreMusicSelectionKey(selection)]
2099
2264
  });
2100
2265
 
2101
2266
  // src/genre-tree/api/library/songs/endpoints.ts
@@ -2165,7 +2330,7 @@ var useListFullGenrePlaylists = (scope, getBackendBaseUrl) => {
2165
2330
  const queryClient2 = (0, import_react_query4.useQueryClient)();
2166
2331
  const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
2167
2332
  const { session, sessionRestored } = useSession();
2168
- const queryKey = scope === "reference" ? genrePlaylistQueryKeys.reference.full(getBackendBaseUrl()) : genrePlaylistQueryKeys.me.full;
2333
+ const queryKey = scope === "reference" ? [...genrePlaylistQueryKeys.reference.full(getBackendBaseUrl()), "genreMusicV1"] : genrePlaylistQueryKeys.me.full;
2169
2334
  const query = useQueryWithParse({
2170
2335
  queryKey,
2171
2336
  queryFn: () => scope === "reference" ? fetch2(genrePlaylistEndpoints.reference.tree(), true, false, {}, { treeName: "canonical" }) : fetchAllPages(
@@ -2177,7 +2342,7 @@ var useListFullGenrePlaylists = (scope, getBackendBaseUrl) => {
2177
2342
  { page, pageSize: FULL_LIST_PAGE_SIZE, treeName: "canonical" }
2178
2343
  )
2179
2344
  ),
2180
- schema: import_zod10.z.array(CriteriaPlaylistSimpleSchema),
2345
+ schema: scope === "reference" ? import_zod18.z.array(ReferenceGenrePlaylistSchema) : import_zod18.z.array(CriteriaPlaylistSimpleSchema),
2181
2346
  context: "useListFullGenrePlaylists",
2182
2347
  enabled: scope === "reference" || sessionRestored && !!session?.accessToken
2183
2348
  });
@@ -2210,131 +2375,48 @@ var useInvalidateAllGenrePlaylistQueries = () => {
2210
2375
  ]);
2211
2376
  };
2212
2377
 
2213
- // src/genre-tree/schemas/criteria/detailed.ts
2214
- var import_zod17 = require("zod");
2215
-
2216
- // src/genre-tree/schemas/track/base.ts
2217
- var import_zod14 = require("zod");
2218
-
2219
- // src/genre-tree/schemas/artist-minimum.ts
2220
- var import_zod11 = require("zod");
2221
- var ArtistMinimumSchema = import_zod11.z.object({
2222
- uuid: import_zod11.z.string().uuid(),
2223
- name: import_zod11.z.string(),
2224
- isSpecialPurpose: import_zod11.z.boolean().optional()
2225
- });
2226
-
2227
- // src/genre-tree/schemas/album-minimum.ts
2228
- var import_zod12 = require("zod");
2229
- var AlbumMinimumSchema = import_zod12.z.object({
2230
- uuid: import_zod12.z.string().uuid(),
2231
- name: import_zod12.z.string(),
2232
- albumArtists: import_zod12.z.array(ArtistMinimumSchema).nullable().optional()
2233
- });
2234
-
2235
- // src/genre-tree/schemas/uuid-resource.ts
2236
- var import_zod13 = require("zod");
2237
- var UuidResourceSchema = import_zod13.z.object({
2238
- uuid: import_zod13.z.string().uuid()
2239
- });
2240
-
2241
- // src/genre-tree/schemas/track/base.ts
2242
- var TrackBaseSchema = UuidResourceSchema.extend({
2243
- title: import_zod14.z.string(),
2244
- artists: import_zod14.z.array(ArtistMinimumSchema).nullable().optional(),
2245
- album: AlbumMinimumSchema.nullable().optional(),
2246
- trackNumber: import_zod14.z.number().nullable().optional(),
2247
- // null for a song not yet linked to a genre.
2248
- genre: CriteriaMinimumSchema.nullable(),
2249
- rating: import_zod14.z.number().min(0).max(10).nullable().optional(),
2250
- language: import_zod14.z.string().nullable().optional(),
2251
- playCount: import_zod14.z.number().min(0),
2252
- createdOn: import_zod14.z.string().datetime(),
2253
- updatedOn: import_zod14.z.string().datetime().nullable().optional()
2254
- });
2255
-
2256
- // src/genre-tree/schemas/track/minimum.ts
2257
- var TrackMinimumSchema = TrackBaseSchema.pick({
2258
- uuid: true,
2259
- title: true,
2260
- artists: true
2261
- });
2262
-
2263
- // src/genre-tree/schemas/criteria/lineage-rel/without-ascendant.ts
2264
- var import_zod15 = require("zod");
2265
- var CriteriaLineageRelWithoutAscendantSchema = import_zod15.z.object({
2266
- descendant: CriteriaMinimumSchema,
2267
- degree: import_zod15.z.number()
2268
- });
2269
-
2270
- // src/genre-tree/schemas/criteria/lineage-rel/without-descendant.ts
2271
- var import_zod16 = require("zod");
2272
- var CriteriaLineageRelWithoutDescendantSchema = import_zod16.z.object({
2273
- ascendant: CriteriaMinimumSchema,
2274
- degree: import_zod16.z.number()
2275
- });
2276
-
2277
- // src/genre-tree/schemas/criteria/detailed.ts
2278
- var CriteriaDetailedSchema = import_zod17.z.object({
2279
- uuid: GenreUuidSchema,
2280
- name: import_zod17.z.string(),
2281
- summary: import_zod17.z.string().nullable(),
2282
- // Optional until every deployed API serves it.
2283
- wikidataId: import_zod17.z.string().nullable().optional(),
2284
- parent: CriteriaMinimumSchema.nullable(),
2285
- ascendants: import_zod17.z.array(CriteriaLineageRelWithoutDescendantSchema),
2286
- descendants: import_zod17.z.array(CriteriaLineageRelWithoutAscendantSchema),
2287
- root: CriteriaMinimumSchema,
2288
- children: import_zod17.z.array(CriteriaMinimumSchema),
2289
- criteriaPlaylist: CriteriaPlaylistMinimumSchema,
2290
- tracks: import_zod17.z.array(TrackMinimumSchema),
2291
- essentialSongs: import_zod17.z.array(TrackMinimumSchema),
2292
- tracksCount: import_zod17.z.number(),
2293
- updatedOn: import_zod17.z.string().datetime().nullable()
2294
- });
2295
-
2296
2378
  // src/genre-tree/schemas/criteria/overview.ts
2297
- var import_zod19 = require("zod");
2379
+ var import_zod20 = require("zod");
2298
2380
 
2299
2381
  // src/genre-tree/schemas/http-url.ts
2300
- var import_zod18 = require("zod");
2301
- var HttpUrlSchema = import_zod18.z.url({ protocol: /^https?$/ });
2382
+ var import_zod19 = require("zod");
2383
+ var HttpUrlSchema = import_zod19.z.url({ protocol: /^https?$/ });
2302
2384
 
2303
2385
  // src/genre-tree/schemas/criteria/overview.ts
2304
- var CriteriaOverviewSchema = import_zod19.z.object({
2386
+ var CriteriaOverviewSchema = import_zod20.z.object({
2305
2387
  uuid: GenreUuidSchema,
2306
- name: import_zod19.z.string(),
2307
- summary: import_zod19.z.string().nullable(),
2308
- description: import_zod19.z.string().nullable(),
2388
+ name: import_zod20.z.string(),
2389
+ summary: import_zod20.z.string().nullable(),
2390
+ description: import_zod20.z.string().nullable(),
2309
2391
  summarySourceUrl: HttpUrlSchema.nullable(),
2310
- essentialSongs: import_zod19.z.array(TrackMinimumSchema).optional()
2392
+ essentialSongs: import_zod20.z.array(TrackMinimumSchema).optional()
2311
2393
  });
2312
2394
 
2313
2395
  // src/genre-tree/schemas/criteria/simple.ts
2314
- var import_zod20 = require("zod");
2315
- var CriteriaSimpleSchema = import_zod20.z.object({
2396
+ var import_zod21 = require("zod");
2397
+ var CriteriaSimpleSchema = import_zod21.z.object({
2316
2398
  uuid: GenreUuidSchema,
2317
- name: import_zod20.z.string(),
2399
+ name: import_zod21.z.string(),
2318
2400
  parent: CriteriaMinimumSchema.nullable(),
2319
- createdOn: import_zod20.z.string().datetime(),
2320
- summary: import_zod20.z.string().nullable()
2401
+ createdOn: import_zod21.z.string().datetime(),
2402
+ summary: import_zod21.z.string().nullable()
2321
2403
  });
2322
2404
 
2323
2405
  // src/genre-tree/schemas/criteria/creation.ts
2324
- var import_zod21 = require("zod");
2325
- var CriteriaCreationSchema = import_zod21.z.object({
2326
- name: import_zod21.z.string().min(1, "Name is required"),
2406
+ var import_zod22 = require("zod");
2407
+ var CriteriaCreationSchema = import_zod22.z.object({
2408
+ name: import_zod22.z.string().min(1, "Name is required"),
2327
2409
  parent: GenreUuidSchema.optional(),
2328
- essentialSongs: import_zod21.z.array(import_zod21.z.string().uuid()).optional()
2410
+ essentialSongs: import_zod22.z.array(import_zod22.z.string().uuid()).optional()
2329
2411
  });
2330
2412
 
2331
2413
  // src/genre-tree/schemas/criteria/update.ts
2332
- var import_zod22 = require("zod");
2333
- var CriteriaUpdateSchema = import_zod22.z.object({
2334
- name: import_zod22.z.string().optional(),
2414
+ var import_zod23 = require("zod");
2415
+ var CriteriaUpdateSchema = import_zod23.z.object({
2416
+ name: import_zod23.z.string().optional(),
2335
2417
  parent: GenreUuidSchema.nullable().optional(),
2336
- essentialSongs: import_zod22.z.array(import_zod22.z.string().uuid()).optional(),
2337
- side: import_zod22.z.enum(["core", "pop"]).optional()
2418
+ essentialSongs: import_zod23.z.array(import_zod23.z.string().uuid()).optional(),
2419
+ side: import_zod23.z.enum(["core", "pop"]).optional()
2338
2420
  });
2339
2421
 
2340
2422
  // src/genre-tree/api/genres/queryKeys.ts
@@ -2395,18 +2477,18 @@ function useFetchGenre(scope, getBackendBaseUrl) {
2395
2477
  async (id) => {
2396
2478
  const endpoint = scope === "reference" ? genreEndpoints.reference.detail(id) : genreEndpoints.me.detail(id);
2397
2479
  const response = await fetch2(endpoint, true, scope === "me");
2398
- return parseWithLog(CriteriaDetailedSchema, response, "useFetchGenre");
2480
+ return parseWithLog(scope === "reference" ? ReferenceGenreDetailedSchema : CriteriaDetailedSchema, response, "useFetchGenre");
2399
2481
  },
2400
2482
  [fetch2, scope]
2401
2483
  );
2402
2484
  }
2403
- function useFetchGenreDetail(id, scope, getBackendBaseUrl, schema = CriteriaDetailedSchema) {
2485
+ function useFetchGenreDetail(id, scope, getBackendBaseUrl, schema = scope === "reference" ? ReferenceGenreDetailedSchema : CriteriaDetailedSchema) {
2404
2486
  const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
2405
2487
  const queryKeys = scope === "reference" ? genreQueryKeys.reference : genreQueryKeys.me;
2406
2488
  const endpoints = scope === "reference" ? genreEndpoints.reference : genreEndpoints.me;
2407
2489
  const genreUuid = id ?? "";
2408
2490
  return useQueryWithParse({
2409
- queryKey: queryKeys.detail(genreUuid),
2491
+ queryKey: scope === "reference" ? [...queryKeys.detail(genreUuid), getBackendBaseUrl(), "genreMusicV1"] : queryKeys.detail(genreUuid),
2410
2492
  queryFn: () => fetch2(endpoints.detail(genreUuid), true, scope === "me"),
2411
2493
  schema,
2412
2494
  context: "useFetchGenreDetail",
@@ -2489,7 +2571,7 @@ function useUpdateGenre(scope, getBackendBaseUrl) {
2489
2571
  const refreshGenreTree = useRefreshGenreTree(scope);
2490
2572
  const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
2491
2573
  const { mutate, mutateAsync, isPending, formErrors } = useValidatedMutation({
2492
- inputSchema: import_zod23.z.object({
2574
+ inputSchema: import_zod24.z.object({
2493
2575
  uuid: GenreUuidSchema,
2494
2576
  data: CriteriaUpdateSchema
2495
2577
  }),
@@ -2519,8 +2601,8 @@ function useDeleteGenre(scope, getBackendBaseUrl) {
2519
2601
  const refreshGenreTree = useRefreshGenreTree(scope);
2520
2602
  const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
2521
2603
  return useValidatedMutation({
2522
- inputSchema: import_zod23.z.object({ uuid: GenreUuidSchema }),
2523
- outputSchema: import_zod23.z.null(),
2604
+ inputSchema: import_zod24.z.object({ uuid: GenreUuidSchema }),
2605
+ outputSchema: import_zod24.z.null(),
2524
2606
  mutationFn: async ({ uuid }) => {
2525
2607
  const endpoint = scope === "reference" ? genreEndpoints.reference.delete(uuid) : genreEndpoints.me.delete(uuid);
2526
2608
  return fetch2(endpoint, true, scope === "me", { method: "DELETE" }, void 0, false, true);
@@ -2530,16 +2612,16 @@ function useDeleteGenre(scope, getBackendBaseUrl) {
2530
2612
  }
2531
2613
 
2532
2614
  // src/genre-tree/useArtist.ts
2533
- var import_zod25 = require("zod");
2615
+ var import_zod26 = require("zod");
2534
2616
 
2535
2617
  // src/genre-tree/schemas/artist-detailed.ts
2536
- var import_zod24 = require("zod");
2537
- var ArtistMembershipSchema = import_zod24.z.object({
2618
+ var import_zod25 = require("zod");
2619
+ var ArtistMembershipSchema = import_zod25.z.object({
2538
2620
  artist: ArtistMinimumSchema,
2539
- beginYear: import_zod24.z.number().int().nullable(),
2540
- endYear: import_zod24.z.number().int().nullable(),
2541
- ended: import_zod24.z.boolean(),
2542
- roles: import_zod24.z.array(import_zod24.z.string())
2621
+ beginYear: import_zod25.z.number().int().nullable(),
2622
+ endYear: import_zod25.z.number().int().nullable(),
2623
+ ended: import_zod25.z.boolean(),
2624
+ roles: import_zod25.z.array(import_zod25.z.string())
2543
2625
  });
2544
2626
  var ARTIST_LINK_KINDS = [
2545
2627
  "official",
@@ -2552,35 +2634,35 @@ var ARTIST_LINK_KINDS = [
2552
2634
  "discogs",
2553
2635
  "social"
2554
2636
  ];
2555
- var ArtistImageSchema = import_zod24.z.object({
2637
+ var ArtistImageSchema = import_zod25.z.object({
2556
2638
  url: HttpUrlSchema,
2557
2639
  pageUrl: HttpUrlSchema,
2558
- author: import_zod24.z.string().nullable(),
2559
- license: import_zod24.z.string(),
2640
+ author: import_zod25.z.string().nullable(),
2641
+ license: import_zod25.z.string(),
2560
2642
  licenseUrl: HttpUrlSchema.nullable()
2561
2643
  });
2562
- var ArtistDetailedSchema = import_zod24.z.object({
2563
- uuid: import_zod24.z.string().uuid(),
2564
- name: import_zod24.z.string(),
2565
- musicbrainzArtistId: import_zod24.z.string().uuid().nullable(),
2566
- type: import_zod24.z.enum(["person", "group", "orchestra", "choir", "character", "other"]).nullable(),
2567
- country: import_zod24.z.string().nullable(),
2568
- beginYear: import_zod24.z.number().int().nullable(),
2569
- endYear: import_zod24.z.number().int().nullable(),
2570
- ended: import_zod24.z.boolean(),
2571
- links: import_zod24.z.array(import_zod24.z.object({ kind: import_zod24.z.enum(ARTIST_LINK_KINDS), url: HttpUrlSchema })),
2572
- members: import_zod24.z.array(ArtistMembershipSchema),
2573
- memberOf: import_zod24.z.array(ArtistMembershipSchema),
2574
- albums: import_zod24.z.array(
2575
- import_zod24.z.object({
2576
- uuid: import_zod24.z.string().uuid(),
2577
- name: import_zod24.z.string(),
2578
- year: import_zod24.z.string().nullable(),
2579
- primaryType: import_zod24.z.string().nullable(),
2580
- secondaryTypes: import_zod24.z.array(import_zod24.z.string())
2644
+ var ArtistDetailedSchema = import_zod25.z.object({
2645
+ uuid: import_zod25.z.string().uuid(),
2646
+ name: import_zod25.z.string(),
2647
+ musicbrainzArtistId: import_zod25.z.string().uuid().nullable(),
2648
+ type: import_zod25.z.enum(["person", "group", "orchestra", "choir", "character", "other"]).nullable(),
2649
+ country: import_zod25.z.string().nullable(),
2650
+ beginYear: import_zod25.z.number().int().nullable(),
2651
+ endYear: import_zod25.z.number().int().nullable(),
2652
+ ended: import_zod25.z.boolean(),
2653
+ links: import_zod25.z.array(import_zod25.z.object({ kind: import_zod25.z.enum(ARTIST_LINK_KINDS), url: HttpUrlSchema })),
2654
+ members: import_zod25.z.array(ArtistMembershipSchema),
2655
+ memberOf: import_zod25.z.array(ArtistMembershipSchema),
2656
+ albums: import_zod25.z.array(
2657
+ import_zod25.z.object({
2658
+ uuid: import_zod25.z.string().uuid(),
2659
+ name: import_zod25.z.string(),
2660
+ year: import_zod25.z.string().nullable(),
2661
+ primaryType: import_zod25.z.string().nullable(),
2662
+ secondaryTypes: import_zod25.z.array(import_zod25.z.string())
2581
2663
  })
2582
2664
  ),
2583
- tracksCount: import_zod24.z.number().int(),
2665
+ tracksCount: import_zod25.z.number().int(),
2584
2666
  image: ArtistImageSchema.nullable()
2585
2667
  });
2586
2668
 
@@ -2603,7 +2685,7 @@ var artistEndpoints = {
2603
2685
  var isNotFound = (error) => error instanceof AppError && error.code === "BAC4040" /* BACKEND_NOT_FOUND */;
2604
2686
  function useArtist(uuid, getBackendBaseUrl) {
2605
2687
  const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
2606
- const isUuid = uuid !== null && import_zod25.z.string().uuid().safeParse(uuid).success;
2688
+ const isUuid = uuid !== null && import_zod26.z.string().uuid().safeParse(uuid).success;
2607
2689
  const { data, isPending, error } = useQueryWithParse({
2608
2690
  queryKey: artistQueryKeys.detail(uuid),
2609
2691
  // A missing artist is shown in the panel, not raised as an app-wide connectivity error.
@@ -2621,19 +2703,19 @@ function useArtist(uuid, getBackendBaseUrl) {
2621
2703
  }
2622
2704
 
2623
2705
  // src/genre-tree/schemas/artist-search.ts
2624
- var import_zod26 = require("zod");
2625
- var ArtistSearchResultSchema = import_zod26.z.object({
2626
- uuid: import_zod26.z.string().uuid(),
2627
- name: import_zod26.z.string(),
2628
- disambiguation: import_zod26.z.string().nullable(),
2629
- type: import_zod26.z.enum(["person", "group", "orchestra", "choir", "character", "other"]).nullable(),
2630
- country: import_zod26.z.string().nullable(),
2631
- beginYear: import_zod26.z.number().int().nullable(),
2632
- endYear: import_zod26.z.number().int().nullable(),
2633
- matchedAlias: import_zod26.z.string().nullable(),
2634
- recordingCount: import_zod26.z.number().int()
2706
+ var import_zod27 = require("zod");
2707
+ var ArtistSearchResultSchema = import_zod27.z.object({
2708
+ uuid: import_zod27.z.string().uuid(),
2709
+ name: import_zod27.z.string(),
2710
+ disambiguation: import_zod27.z.string().nullable(),
2711
+ type: import_zod27.z.enum(["person", "group", "orchestra", "choir", "character", "other"]).nullable(),
2712
+ country: import_zod27.z.string().nullable(),
2713
+ beginYear: import_zod27.z.number().int().nullable(),
2714
+ endYear: import_zod27.z.number().int().nullable(),
2715
+ matchedAlias: import_zod27.z.string().nullable(),
2716
+ recordingCount: import_zod27.z.number().int()
2635
2717
  });
2636
- var ArtistSearchResultsSchema = import_zod26.z.array(ArtistSearchResultSchema);
2718
+ var ArtistSearchResultsSchema = import_zod27.z.array(ArtistSearchResultSchema);
2637
2719
 
2638
2720
  // src/genre-tree/useRemoteSearch.ts
2639
2721
  var import_react_query6 = require("@tanstack/react-query");
@@ -2687,10 +2769,10 @@ function useArtistSearch(getBackendBaseUrl, text) {
2687
2769
  }
2688
2770
 
2689
2771
  // src/genre-tree/useSong.ts
2690
- var import_zod28 = require("zod");
2772
+ var import_zod29 = require("zod");
2691
2773
 
2692
2774
  // src/genre-tree/schemas/song/detailed.ts
2693
- var import_zod27 = require("zod");
2775
+ var import_zod28 = require("zod");
2694
2776
  var YOUTUBE_UNPLAYABLE_REASON_LABELS = {
2695
2777
  not_found: "Video unavailable",
2696
2778
  not_embeddable: "Embedding disabled",
@@ -2699,23 +2781,23 @@ var YOUTUBE_UNPLAYABLE_REASON_LABELS = {
2699
2781
  region_whitelisted: "Region restricted"
2700
2782
  };
2701
2783
  var YOUTUBE_UNPLAYABLE_REASONS = Object.keys(YOUTUBE_UNPLAYABLE_REASON_LABELS);
2702
- var YoutubeAvailabilitySchema = import_zod27.z.object({
2703
- status: import_zod27.z.enum(["eligible", "blocked", "unknown"]),
2704
- reason: import_zod27.z.string().nullable(),
2705
- country: import_zod27.z.string().nullable()
2784
+ var YoutubeAvailabilitySchema = import_zod28.z.object({
2785
+ status: import_zod28.z.enum(["eligible", "blocked", "unknown"]),
2786
+ reason: import_zod28.z.string().nullable(),
2787
+ country: import_zod28.z.string().nullable()
2706
2788
  });
2707
2789
  var SongDetailedSchema = TrackBaseSchema.extend({
2708
- youtubeVideo: import_zod27.z.object({
2709
- id: import_zod27.z.string(),
2790
+ youtubeVideo: import_zod28.z.object({
2791
+ id: import_zod28.z.string(),
2710
2792
  availability: YoutubeAvailabilitySchema.optional(),
2711
2793
  // null = playable
2712
- unplayableReason: import_zod27.z.enum(YOUTUBE_UNPLAYABLE_REASONS).nullable(),
2713
- viewCount: import_zod27.z.number().int().nullable().optional()
2794
+ unplayableReason: import_zod28.z.enum(YOUTUBE_UNPLAYABLE_REASONS).nullable(),
2795
+ viewCount: import_zod28.z.number().int().nullable().optional()
2714
2796
  }).nullable(),
2715
2797
  // null for hand-made/admin songs
2716
- musicbrainzRecordingId: import_zod27.z.string().uuid().nullable(),
2717
- firstReleaseYear: import_zod27.z.number().int().nullable().optional(),
2718
- essentialGenres: import_zod27.z.array(CriteriaMinimumSchema).optional()
2798
+ musicbrainzRecordingId: import_zod28.z.string().uuid().nullable(),
2799
+ firstReleaseYear: import_zod28.z.number().int().nullable().optional(),
2800
+ essentialGenres: import_zod28.z.array(CriteriaMinimumSchema).optional()
2719
2801
  });
2720
2802
  var NO_VIDEO_LABEL = "No video available";
2721
2803
  function isSong(track) {
@@ -2736,7 +2818,7 @@ var isNotFound2 = (error) => error instanceof AppError && error.code === "BAC404
2736
2818
  function useSong(uuid, getBackendBaseUrl) {
2737
2819
  const playback = usePlaybackContext();
2738
2820
  const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
2739
- const isUuid = uuid !== null && import_zod28.z.string().uuid().safeParse(uuid).success;
2821
+ const isUuid = uuid !== null && import_zod29.z.string().uuid().safeParse(uuid).success;
2740
2822
  const { data, isPending, error } = useQueryWithParse({
2741
2823
  queryKey: [...libraryQueryKeys.reference.songs.detail(uuid), ...playback.key ? [playback.key] : []],
2742
2824
  // A missing song is shown in the panel, not raised as an app-wide connectivity error.
@@ -2754,16 +2836,16 @@ function useSong(uuid, getBackendBaseUrl) {
2754
2836
  }
2755
2837
 
2756
2838
  // src/genre-tree/schemas/song-history.ts
2757
- var import_zod29 = require("zod");
2758
- var SongHistoryEntrySchema = import_zod29.z.object({
2759
- uuid: import_zod29.z.string().uuid(),
2760
- action: import_zod29.z.string(),
2761
- actorPseudo: import_zod29.z.string().nullable(),
2762
- oldValue: import_zod29.z.string().nullable(),
2763
- newValue: import_zod29.z.string().nullable(),
2764
- createdOn: import_zod29.z.string()
2839
+ var import_zod30 = require("zod");
2840
+ var SongHistoryEntrySchema = import_zod30.z.object({
2841
+ uuid: import_zod30.z.string().uuid(),
2842
+ action: import_zod30.z.string(),
2843
+ actorPseudo: import_zod30.z.string().nullable(),
2844
+ oldValue: import_zod30.z.string().nullable(),
2845
+ newValue: import_zod30.z.string().nullable(),
2846
+ createdOn: import_zod30.z.string()
2765
2847
  });
2766
- var SongHistorySchema = import_zod29.z.array(SongHistoryEntrySchema);
2848
+ var SongHistorySchema = import_zod30.z.array(SongHistoryEntrySchema);
2767
2849
 
2768
2850
  // src/genre-tree/useSongHistory.ts
2769
2851
  function useSongHistory(uuid, getBackendBaseUrl, enabled) {
@@ -2783,20 +2865,20 @@ function useSongHistory(uuid, getBackendBaseUrl, enabled) {
2783
2865
  }
2784
2866
 
2785
2867
  // src/genre-tree/schemas/song-search.ts
2786
- var import_zod30 = require("zod");
2787
- var SongSearchResultSchema = import_zod30.z.object({
2788
- uuid: import_zod30.z.string().uuid(),
2789
- title: import_zod30.z.string(),
2790
- artists: import_zod30.z.array(ArtistMinimumSchema),
2868
+ var import_zod31 = require("zod");
2869
+ var SongSearchResultSchema = import_zod31.z.object({
2870
+ uuid: import_zod31.z.string().uuid(),
2871
+ title: import_zod31.z.string(),
2872
+ artists: import_zod31.z.array(ArtistMinimumSchema),
2791
2873
  // null for songs not yet linked to a genre.
2792
2874
  genre: CriteriaMinimumSchema.nullable(),
2793
- youtubeVideo: import_zod30.z.object({
2794
- id: import_zod30.z.string(),
2795
- unplayableReason: import_zod30.z.string().nullable()
2875
+ youtubeVideo: import_zod31.z.object({
2876
+ id: import_zod31.z.string(),
2877
+ unplayableReason: import_zod31.z.string().nullable()
2796
2878
  }).nullable(),
2797
- firstReleaseYear: import_zod30.z.number().int().nullable()
2879
+ firstReleaseYear: import_zod31.z.number().int().nullable()
2798
2880
  });
2799
- var SongSearchResultsSchema = import_zod30.z.array(SongSearchResultSchema);
2881
+ var SongSearchResultsSchema = import_zod31.z.array(SongSearchResultSchema);
2800
2882
  function isSongSearchResultPlayable(result) {
2801
2883
  return result.youtubeVideo !== null && result.youtubeVideo.unplayableReason === null;
2802
2884
  }
@@ -2822,16 +2904,25 @@ function useSongSearch(getBackendBaseUrl, text, options = {}) {
2822
2904
 
2823
2905
  // src/genre-tree/useArtistGenreCounts.ts
2824
2906
  var import_react_query7 = require("@tanstack/react-query");
2825
- var import_zod32 = require("zod");
2907
+ var import_zod33 = require("zod");
2826
2908
 
2827
2909
  // src/genre-tree/schemas/artist-genre-count.ts
2828
- var import_zod31 = require("zod");
2829
- var ArtistGenreCountSchema = import_zod31.z.object({
2910
+ var import_zod32 = require("zod");
2911
+ var ArtistGenreCountSchema = import_zod32.z.object({
2912
+ ...GenreCountsSchema.shape,
2913
+ catalogue: GenreCatalogueCountsSchema,
2830
2914
  genrePlaylist: GenrePlaylistUuidSchema,
2831
- /** All the artist's songs in the genre playlist's subtree; drives pruning. */
2832
- songsCount: import_zod31.z.number().int().nonnegative(),
2833
- /** The playable ones among them; drives node size and the play button. */
2834
- tracksCount: import_zod31.z.number().int().nonnegative()
2915
+ /** Legacy catalogue count for the default selection. */
2916
+ songsCount: import_zod32.z.number().int().nonnegative(),
2917
+ /** Legacy playlist count for the default selection. */
2918
+ tracksCount: import_zod32.z.number().int().nonnegative()
2919
+ }).superRefine((row, ctx) => {
2920
+ const counts = GenreCatalogueCountsSchema.safeParse(row);
2921
+ if (!counts.success) {
2922
+ for (const issue of counts.error.issues) {
2923
+ ctx.addIssue({ code: "custom", path: issue.path, message: issue.message });
2924
+ }
2925
+ }
2835
2926
  });
2836
2927
 
2837
2928
  // src/genre-tree/useArtistGenreCounts.ts
@@ -2839,10 +2930,10 @@ var isNotFound3 = (error) => error instanceof AppError && error.code === "BAC404
2839
2930
  function useArtistGenreCounts(artistUuid, getBackendBaseUrl) {
2840
2931
  const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
2841
2932
  return useQueryWithParse({
2842
- queryKey: artistQueryKeys.genreCounts(getBackendBaseUrl(), artistUuid),
2933
+ queryKey: [...artistQueryKeys.genreCounts(getBackendBaseUrl(), artistUuid), "genreMusicV1"],
2843
2934
  // A missing artist is shown in the artist panel, not raised as an app-wide connectivity error.
2844
2935
  queryFn: () => fetch2(artistEndpoints.genreCounts(artistUuid), true, false, void 0, void 0, false, true),
2845
- schema: import_zod32.z.array(ArtistGenreCountSchema),
2936
+ schema: import_zod33.z.array(ArtistGenreCountSchema),
2846
2937
  enabled: artistUuid !== null,
2847
2938
  placeholderData: import_react_query7.keepPreviousData,
2848
2939
  retry: (failureCount, error) => !isNotFound3(error) && failureCount < 3,
@@ -2946,32 +3037,32 @@ function useGenreSearch({
2946
3037
  }
2947
3038
 
2948
3039
  // src/genre-tree/schemas/genre-search.ts
2949
- var import_zod33 = require("zod");
2950
- var GenreSearchTreeNameSchema = import_zod33.z.enum(["canonical", "regional"]);
2951
- var GenreSearchResultSchema = import_zod33.z.object({
3040
+ var import_zod34 = require("zod");
3041
+ var GenreSearchTreeNameSchema = import_zod34.z.enum(["canonical", "regional"]);
3042
+ var GenreSearchResultSchema = import_zod34.z.object({
2952
3043
  /** Criteria (genre) uuid. */
2953
3044
  uuid: GenreUuidSchema,
2954
- name: import_zod33.z.string(),
3045
+ name: import_zod34.z.string(),
2955
3046
  /** Null for app-created genres, which the Wikidata-keyed region index does not reference. */
2956
- wikidataId: import_zod33.z.string().nullable(),
2957
- treeName: import_zod33.z.string(),
3047
+ wikidataId: import_zod34.z.string().nullable(),
3048
+ treeName: import_zod34.z.string(),
2958
3049
  /** Null when the genre has no playlist in the tree, so it cannot be opened there. */
2959
3050
  genrePlaylistUuid: GenrePlaylistUuidSchema.nullable(),
2960
- root: import_zod33.z.object({ uuid: GenreUuidSchema, name: import_zod33.z.string() }),
2961
- isUmbrella: import_zod33.z.boolean(),
2962
- viewsCount: import_zod33.z.number().int()
3051
+ root: import_zod34.z.object({ uuid: GenreUuidSchema, name: import_zod34.z.string() }),
3052
+ isUmbrella: import_zod34.z.boolean(),
3053
+ viewsCount: import_zod34.z.number().int()
2963
3054
  });
2964
- var GenreSearchResultsSchema = import_zod33.z.array(GenreSearchResultSchema);
2965
- var RegionGenreLexiconEntrySchema = import_zod33.z.object({
2966
- wikidataId: import_zod33.z.string(),
3055
+ var GenreSearchResultsSchema = import_zod34.z.array(GenreSearchResultSchema);
3056
+ var RegionGenreLexiconEntrySchema = import_zod34.z.object({
3057
+ wikidataId: import_zod34.z.string(),
2967
3058
  uuid: GenreUuidSchema,
2968
- name: import_zod33.z.string(),
2969
- treeName: import_zod33.z.string(),
3059
+ name: import_zod34.z.string(),
3060
+ treeName: import_zod34.z.string(),
2970
3061
  genrePlaylistUuid: GenrePlaylistUuidSchema.nullable(),
2971
- isUmbrella: import_zod33.z.boolean(),
2972
- viewsCount: import_zod33.z.number().int()
3062
+ isUmbrella: import_zod34.z.boolean(),
3063
+ viewsCount: import_zod34.z.number().int()
2973
3064
  });
2974
- var RegionGenreLexiconSchema = import_zod33.z.array(RegionGenreLexiconEntrySchema);
3065
+ var RegionGenreLexiconSchema = import_zod34.z.array(RegionGenreLexiconEntrySchema);
2975
3066
 
2976
3067
  // src/genre-tree/useGenreRemoteSearch.ts
2977
3068
  var DEFAULT_RESULT_LIMIT2 = 8;
@@ -3018,7 +3109,7 @@ var pruneGenrePlaylistsForArtist = (playlists, counts) => {
3018
3109
  const kept = /* @__PURE__ */ new Set();
3019
3110
  for (const playlist of playlists) {
3020
3111
  const isPopRoot = playlist.parent === null && playlist.name === POP_ROOT_NAME;
3021
- if (isPopRoot || (countByPlaylist.get(playlist.uuid)?.songsCount ?? 0) > 0) kept.add(playlist.uuid);
3112
+ if (isPopRoot || (countByPlaylist.get(playlist.uuid)?.catalogue.genreAndSubgenresTracksCount.all ?? 0) > 0) kept.add(playlist.uuid);
3022
3113
  }
3023
3114
  const coreElectronicUuids = new Set(
3024
3115
  playlists.filter((playlist) => playlist.name === CORE_ELECTRONIC_NAME && kept.has(playlist.uuid)).map((p) => p.uuid)
@@ -3026,12 +3117,22 @@ var pruneGenrePlaylistsForArtist = (playlists, counts) => {
3026
3117
  for (const playlist of playlists) {
3027
3118
  if (playlist.parent && coreElectronicUuids.has(playlist.parent.uuid)) kept.add(playlist.uuid);
3028
3119
  }
3029
- return playlists.filter((playlist) => kept.has(playlist.uuid)).map((playlist) => ({
3030
- ...playlist,
3031
- tracksCount: countByPlaylist.get(playlist.uuid)?.tracksCount ?? 0,
3032
- // Per-artist view totals are not served, so the views metric is unavailable on a pruned tree.
3033
- viewsCount: 0
3034
- }));
3120
+ return playlists.filter((playlist) => kept.has(playlist.uuid)).map((playlist) => {
3121
+ const count = countByPlaylist.get(playlist.uuid);
3122
+ const catalogue = GenreCatalogueCountsSchema.parse(playlist.catalogue);
3123
+ const scopes = playlist.genreAndSubgenresTracksCount;
3124
+ if (!scopes) throw new Error("Artist projections require a reference genre summary");
3125
+ const zero = { genreOnlyTracksCount: 0, genreAndSubgenresTracksCount: "canonical" in scopes ? { canonical: 0, regional: 0, all: 0 } : { all: 0 } };
3126
+ return {
3127
+ ...playlist,
3128
+ genreOnlyTracksCount: count?.genreOnlyTracksCount ?? 0,
3129
+ genreAndSubgenresTracksCount: count?.genreAndSubgenresTracksCount ?? zero.genreAndSubgenresTracksCount,
3130
+ catalogue: count?.catalogue ?? { ...catalogue, ...zero },
3131
+ tracksCount: count ? genreMusicCount(count) : 0,
3132
+ // Artist view totals are not served.
3133
+ viewsCount: void 0
3134
+ };
3135
+ });
3035
3136
  };
3036
3137
 
3037
3138
  // src/genre-tree/useVisibleGenrePlaylists.ts
@@ -3169,10 +3270,10 @@ function useGenreTreeViewState({
3169
3270
  var import_react19 = require("react");
3170
3271
 
3171
3272
  // src/genre-tree/schemas/track-playlist-rel/without-playlist.ts
3172
- var import_zod34 = require("zod");
3173
- var makeTrackPlaylistRelSchema = (trackSchema) => import_zod34.z.object({
3273
+ var import_zod35 = require("zod");
3274
+ var makeTrackPlaylistRelSchema = (trackSchema) => import_zod35.z.object({
3174
3275
  track: trackSchema,
3175
- position: import_zod34.z.number().min(0)
3276
+ position: import_zod35.z.number().min(0)
3176
3277
  });
3177
3278
  var makeTrackPlaylistRelPageSchema = (trackSchema) => PaginatedResponseSchema(makeTrackPlaylistRelSchema(trackSchema));
3178
3279
 
@@ -3221,6 +3322,7 @@ var TrackListFromArtist = class extends TrackList {
3221
3322
  var TrackListOriginType = /* @__PURE__ */ ((TrackListOriginType2) => {
3222
3323
  TrackListOriginType2["TRACK"] = "TRACK";
3223
3324
  TrackListOriginType2["GENRE_PLAYLIST"] = "GENRE_PLAYLIST";
3325
+ TrackListOriginType2["GENRE_CATALOGUE"] = "GENRE_CATALOGUE";
3224
3326
  TrackListOriginType2["ARTIST"] = "ARTIST";
3225
3327
  return TrackListOriginType2;
3226
3328
  })(TrackListOriginType || {});
@@ -3252,27 +3354,48 @@ var TrackListOriginFromTrack = class extends TrackListOrigin {
3252
3354
  };
3253
3355
  var TrackListOriginFromCriteriaPlaylist = class extends TrackListOrigin {
3254
3356
  /** `from`: the track the list starts at (server-side `?from=`), kept so later pages use it too. */
3255
- constructor(criteriaPlaylist, scope, from) {
3357
+ constructor(criteriaPlaylist, scope, from, selection, artistUuid) {
3256
3358
  super("GENRE_PLAYLIST" /* GENRE_PLAYLIST */, criteriaPlaylist.name, criteriaPlaylist.uuid, scope);
3257
3359
  this.criteriaPlaylist = criteriaPlaylist;
3258
3360
  this.from = from;
3361
+ this.selection = selection;
3362
+ this.artistUuid = artistUuid;
3259
3363
  }
3260
3364
  criteriaPlaylist;
3261
3365
  from;
3366
+ selection;
3367
+ artistUuid;
3262
3368
  };
3263
3369
  var TrackListOriginFromArtist = class extends TrackListOrigin {
3264
3370
  /** `ordering`/`from`: kept so later pages use the same order and start track. */
3265
- constructor(artist, scope, ordering, from, genreUuid) {
3371
+ constructor(artist, scope, ordering, from, genreUuid, selection) {
3266
3372
  super("ARTIST" /* ARTIST */, artist.name, artist.uuid, scope);
3267
3373
  this.artist = artist;
3268
3374
  this.ordering = ordering;
3269
3375
  this.from = from;
3270
3376
  this.genreUuid = genreUuid;
3377
+ this.selection = selection;
3271
3378
  }
3272
3379
  artist;
3273
3380
  ordering;
3274
3381
  from;
3275
3382
  genreUuid;
3383
+ selection;
3384
+ };
3385
+ var TrackListOriginFromGenreCatalogue = class extends TrackListOrigin {
3386
+ constructor(genre, scope, from, selection) {
3387
+ super("GENRE_CATALOGUE" /* GENRE_CATALOGUE */, genre.name, genre.uuid, scope);
3388
+ this.genre = genre;
3389
+ this.from = from;
3390
+ this.selection = selection;
3391
+ }
3392
+ genre;
3393
+ from;
3394
+ selection;
3395
+ ordering = "title";
3396
+ get genreUuid() {
3397
+ return this.genre.uuid;
3398
+ }
3276
3399
  };
3277
3400
 
3278
3401
  // src/genre-tree/TrackListSidebarVisibilityContext.tsx
@@ -3381,9 +3504,10 @@ function TrackListProvider({
3381
3504
  [clearDelayedTrackLoad, loadTrackForPlayer]
3382
3505
  );
3383
3506
  const fetchTracksPage = (0, import_react19.useCallback)(
3384
- async (uuid, scope, page, from) => {
3507
+ async (uuid, scope, page, from, selection, artistUuid) => {
3385
3508
  const endpoint = genrePlaylistEndpoints[scope].tracks(uuid);
3386
- const params = { page, pageSize: TRACKS_PAGE_SIZE, ...from && { from } };
3509
+ if (scope === "me" && (selection || artistUuid)) throw new Error("Genre selections require reference scope");
3510
+ const params = { page, pageSize: TRACKS_PAGE_SIZE, ...from && { from }, ...genreMusicQueryParams(selection), ...artistUuid && { artist: artistUuid } };
3387
3511
  const response = await fetch2(endpoint, true, scope === "me", {}, params, false, !!from, page === 1);
3388
3512
  const parsed = parseWithLog(pageSchema, response, "fetchGenrePlaylistTracksPage");
3389
3513
  return {
@@ -3394,17 +3518,18 @@ function TrackListProvider({
3394
3518
  },
3395
3519
  [fetch2, pageSchema]
3396
3520
  );
3397
- const artistPageSchema = (0, import_react19.useMemo)(() => PaginatedResponseSchema(schema), [schema]);
3398
- const fetchArtistTracksPage = (0, import_react19.useCallback)(
3521
+ const cataloguePageSchema = (0, import_react19.useMemo)(() => PaginatedResponseSchema(schema), [schema]);
3522
+ const fetchCatalogueTracksPage = (0, import_react19.useCallback)(
3399
3523
  async (origin, page) => {
3400
3524
  const params = {
3401
- artist: origin.uuid,
3525
+ ...origin instanceof TrackListOriginFromArtist && { artist: origin.uuid },
3402
3526
  playable: true,
3403
3527
  ordering: origin.ordering,
3404
3528
  page,
3405
3529
  pageSize: TRACKS_PAGE_SIZE,
3406
3530
  ...origin.from && { from: origin.from },
3407
- ...origin.genreUuid && { genre: origin.genreUuid }
3531
+ ...origin.genreUuid && { genre: origin.genreUuid },
3532
+ ...genreMusicQueryParams(origin.selection)
3408
3533
  };
3409
3534
  const response = await fetch2(
3410
3535
  libraryEndpoints.reference.songs.list(),
@@ -3417,10 +3542,10 @@ function TrackListProvider({
3417
3542
  page === 1 && !!origin.from,
3418
3543
  page === 1
3419
3544
  );
3420
- const parsed = parseWithLog(artistPageSchema, response, "fetchArtistTracksPage");
3545
+ const parsed = parseWithLog(cataloguePageSchema, response, "fetchCatalogueTracksPage");
3421
3546
  return { tracks: parsed.results, total: parsed.overallTotal, nextPage: parsed.next ? parsed.page + 1 : null };
3422
3547
  },
3423
- [fetch2, artistPageSchema]
3548
+ [fetch2, cataloguePageSchema]
3424
3549
  );
3425
3550
  const advanceAfterTrackEnd = (0, import_react19.useCallback)(
3426
3551
  (event) => {
@@ -3492,7 +3617,7 @@ function TrackListProvider({
3492
3617
  const from = options?.startSongUuid;
3493
3618
  let page;
3494
3619
  try {
3495
- page = await fetchTracksPage(genrePlaylist.uuid, scope, 1, from);
3620
+ page = await fetchTracksPage(genrePlaylist.uuid, scope, 1, from, options?.selection, options?.artistUuid);
3496
3621
  } catch (error) {
3497
3622
  if (request !== latestPlayRequestRef.current) return;
3498
3623
  startingPlaybackRef.current = false;
@@ -3509,7 +3634,7 @@ function TrackListProvider({
3509
3634
  console.warn("No playable tracks found in genre playlist");
3510
3635
  return;
3511
3636
  }
3512
- const origin = new TrackListOriginFromCriteriaPlaylist(genrePlaylist, scope, from);
3637
+ const origin = new TrackListOriginFromCriteriaPlaylist(genrePlaylist, scope, from, options?.selection, options?.artistUuid);
3513
3638
  setAutoAdvanceScrollRequest(null);
3514
3639
  setTrackList(new TrackListFromCriteriaPlaylist(page.tracks, origin, page.total, page.nextPage));
3515
3640
  setSelectedTrack(startTrack);
@@ -3518,17 +3643,15 @@ function TrackListProvider({
3518
3643
  },
3519
3644
  [clearDelayedTrackLoad, fetchTracksPage, showTrackListSidebar, loadTrackForPlayer]
3520
3645
  );
3521
- const playNewTrackListFromArtist = (0, import_react19.useCallback)(
3522
- async (artist, scope, options) => {
3523
- if (scope !== "reference") throw new Error("Artist track lists only support the reference scope");
3646
+ const playCatalogue = (0, import_react19.useCallback)(
3647
+ async (origin) => {
3524
3648
  clearDelayedTrackLoad();
3525
3649
  const request = ++latestPlayRequestRef.current;
3526
3650
  startingPlaybackRef.current = true;
3527
- const from = options.startSongUuid;
3528
- const origin = new TrackListOriginFromArtist(artist, scope, options.ordering, from, options.genreUuid);
3651
+ const from = origin.from;
3529
3652
  let page;
3530
3653
  try {
3531
- page = await fetchArtistTracksPage(origin, 1);
3654
+ page = await fetchCatalogueTracksPage(origin, 1);
3532
3655
  } catch (error) {
3533
3656
  if (request !== latestPlayRequestRef.current) return;
3534
3657
  startingPlaybackRef.current = false;
@@ -3539,19 +3662,34 @@ function TrackListProvider({
3539
3662
  loadedContextRef.current = playback.snapshot().key;
3540
3663
  const startTrack = page.tracks[0];
3541
3664
  if (from && startTrack?.uuid !== from) {
3542
- throw new Error(`Artist ${artist.uuid} did not start at song ${from}`);
3665
+ throw new Error(`${origin instanceof TrackListOriginFromArtist ? "Artist" : "Catalogue"} ${origin.uuid} did not start at song ${from}`);
3543
3666
  }
3544
3667
  if (!startTrack) {
3545
- console.warn("No playable songs found for artist");
3668
+ console.warn("No playable songs found in catalogue");
3546
3669
  return;
3547
3670
  }
3548
- setTrackList(new TrackListFromArtist(page.tracks, origin, page.total, page.nextPage));
3671
+ setTrackList(origin instanceof TrackListOriginFromArtist ? new TrackListFromArtist(page.tracks, origin, page.total, page.nextPage) : new TrackList(page.tracks, origin, page.total, page.nextPage));
3549
3672
  setAutoAdvanceScrollRequest(null);
3550
3673
  setSelectedTrack(startTrack);
3551
3674
  showTrackListSidebar();
3552
3675
  loadTrackForPlayer(startTrack.uuid);
3553
3676
  },
3554
- [clearDelayedTrackLoad, fetchArtistTracksPage, showTrackListSidebar, loadTrackForPlayer]
3677
+ [clearDelayedTrackLoad, fetchCatalogueTracksPage, showTrackListSidebar, loadTrackForPlayer]
3678
+ );
3679
+ const playNewTrackListFromArtist = (0, import_react19.useCallback)(
3680
+ async (artist, scope, options) => {
3681
+ if (scope !== "reference") throw new Error("Artist track lists only support the reference scope");
3682
+ if (options.selection && !options.genreUuid) throw new Error("A genre selection requires a genre");
3683
+ return playCatalogue(new TrackListOriginFromArtist(artist, scope, options.ordering, options.startSongUuid, options.genreUuid, options.selection));
3684
+ },
3685
+ [playCatalogue]
3686
+ );
3687
+ const playNewTrackListFromGenreCatalogue = (0, import_react19.useCallback)(
3688
+ async (genre, scope, options) => {
3689
+ if (scope !== "reference") throw new Error("Genre catalogues only support the reference scope");
3690
+ return playCatalogue(new TrackListOriginFromGenreCatalogue(genre, scope, options?.startSongUuid, options?.selection));
3691
+ },
3692
+ [playCatalogue]
3555
3693
  );
3556
3694
  const contextKeyRef = (0, import_react19.useRef)(playback.key);
3557
3695
  (0, import_react19.useEffect)(() => {
@@ -3573,20 +3711,28 @@ function TrackListProvider({
3573
3711
  setTrackList(null);
3574
3712
  setSelectedTrack(null);
3575
3713
  if (origin instanceof TrackListOriginFromCriteriaPlaylist) {
3576
- void playNewTrackListFromGenrePlaylist(origin.criteriaPlaylist, origin.scope, { startSongUuid: selected?.uuid }).catch((error) => {
3714
+ void playNewTrackListFromGenrePlaylist(origin.criteriaPlaylist, origin.scope, { startSongUuid: selected?.uuid, selection: origin.selection, artistUuid: origin.artistUuid }).catch((error) => {
3577
3715
  if (error instanceof BackendError && error.code === "BAC4040" /* BACKEND_NOT_FOUND */) {
3578
- return playNewTrackListFromGenrePlaylist(origin.criteriaPlaylist, origin.scope).catch(() => {
3716
+ return playNewTrackListFromGenrePlaylist(origin.criteriaPlaylist, origin.scope, { selection: origin.selection, artistUuid: origin.artistUuid }).catch(() => {
3579
3717
  });
3580
3718
  }
3581
3719
  });
3582
3720
  } else if (origin instanceof TrackListOriginFromArtist) {
3583
- const options = { ordering: origin.ordering, genreUuid: origin.genreUuid };
3721
+ const options = { ordering: origin.ordering, genreUuid: origin.genreUuid, selection: origin.selection };
3584
3722
  void playNewTrackListFromArtist(origin.artist, origin.scope, { ...options, startSongUuid: selected?.uuid }).catch((error) => {
3585
3723
  if (error instanceof BackendError && error.code === "BAC4040" /* BACKEND_NOT_FOUND */) {
3586
3724
  return playNewTrackListFromArtist(origin.artist, origin.scope, options).catch(() => {
3587
3725
  });
3588
3726
  }
3589
3727
  });
3728
+ } else if (origin instanceof TrackListOriginFromGenreCatalogue) {
3729
+ const options = { selection: origin.selection };
3730
+ void playNewTrackListFromGenreCatalogue(origin.genre, origin.scope, { ...options, startSongUuid: selected?.uuid }).catch((error) => {
3731
+ if (error instanceof BackendError && error.code === "BAC4040" /* BACKEND_NOT_FOUND */) {
3732
+ return playNewTrackListFromGenreCatalogue(origin.genre, origin.scope, options).catch(() => {
3733
+ });
3734
+ }
3735
+ });
3590
3736
  } else if (origin instanceof TrackListOriginFromTrack && selected) {
3591
3737
  const request = latestPlayRequestRef.current;
3592
3738
  void (async () => {
@@ -3597,7 +3743,7 @@ function TrackListProvider({
3597
3743
  })().catch(() => {
3598
3744
  });
3599
3745
  }
3600
- }, [playback.key, trackList, selectedTrack, clearDelayedTrackLoad, playNewTrackListFromGenrePlaylist, playNewTrackListFromArtist, schema, fetch2]);
3746
+ }, [playback.key, trackList, selectedTrack, clearDelayedTrackLoad, playNewTrackListFromGenrePlaylist, playNewTrackListFromArtist, playNewTrackListFromGenreCatalogue, schema, fetch2]);
3601
3747
  const updateTrack = (0, import_react19.useCallback)((track) => {
3602
3748
  setTrackList((prev) => {
3603
3749
  if (!prev || !prev.tracks.some((listed) => listed.uuid === track.uuid)) return prev;
@@ -3609,22 +3755,22 @@ function TrackListProvider({
3609
3755
  const loadMore = (0, import_react19.useCallback)(async () => {
3610
3756
  if (!trackList || trackList.nextPage === null) return;
3611
3757
  const origin = trackList.origin;
3612
- if (!(origin instanceof TrackListOriginFromCriteriaPlaylist || origin instanceof TrackListOriginFromArtist)) return;
3758
+ if (!(origin instanceof TrackListOriginFromCriteriaPlaylist || origin instanceof TrackListOriginFromArtist || origin instanceof TrackListOriginFromGenreCatalogue)) return;
3613
3759
  if (loadingOriginRef.current === origin) return;
3614
3760
  const requestedPage = trackList.nextPage;
3615
3761
  loadingOriginRef.current = origin;
3616
3762
  try {
3617
- const page = origin instanceof TrackListOriginFromArtist ? await fetchArtistTracksPage(origin, requestedPage) : await fetchTracksPage(origin.criteriaPlaylist.uuid, origin.scope, requestedPage, origin.from);
3763
+ const page = origin instanceof TrackListOriginFromArtist || origin instanceof TrackListOriginFromGenreCatalogue ? await fetchCatalogueTracksPage(origin, requestedPage) : await fetchTracksPage(origin.criteriaPlaylist.uuid, origin.scope, requestedPage, origin.from, origin.selection, origin.artistUuid);
3618
3764
  setTrackList((prev) => {
3619
3765
  if (prev?.origin !== origin || prev.nextPage !== requestedPage) return prev;
3620
3766
  const loaded = new Set(prev.tracks.map((track) => track.uuid));
3621
3767
  const tracks = [...prev.tracks, ...page.tracks.filter((track) => !loaded.has(track.uuid))];
3622
- return origin instanceof TrackListOriginFromArtist ? new TrackListFromArtist(tracks, origin, page.total, page.nextPage) : new TrackListFromCriteriaPlaylist(tracks, origin, page.total, page.nextPage);
3768
+ return origin instanceof TrackListOriginFromArtist ? new TrackListFromArtist(tracks, origin, page.total, page.nextPage) : origin instanceof TrackListOriginFromGenreCatalogue ? new TrackList(tracks, origin, page.total, page.nextPage) : new TrackListFromCriteriaPlaylist(tracks, origin, page.total, page.nextPage);
3623
3769
  });
3624
3770
  } finally {
3625
3771
  if (loadingOriginRef.current === origin) loadingOriginRef.current = null;
3626
3772
  }
3627
- }, [trackList, fetchTracksPage, fetchArtistTracksPage]);
3773
+ }, [trackList, fetchTracksPage, fetchCatalogueTracksPage]);
3628
3774
  const selectedTrackIndex = trackList?.tracks.findIndex((track) => track.uuid === selectedTrack?.uuid) ?? -1;
3629
3775
  const nextTrack = trackList && selectedTrackIndex >= 0 ? trackList.tracks.slice(selectedTrackIndex + 1).find((track) => isTrackPlayable(track, runtimeUnplayableTrackIds, hasPlaybackFailure)) ?? null : null;
3630
3776
  const previousTrack = trackList && selectedTrackIndex > 0 ? trackList.tracks.slice(0, selectedTrackIndex).reverse().find((track) => isTrackPlayable(track, runtimeUnplayableTrackIds, hasPlaybackFailure)) ?? null : null;
@@ -3712,6 +3858,7 @@ function TrackListProvider({
3712
3858
  playNewTrackListFromTrackUuid,
3713
3859
  playNewTrackListFromGenrePlaylist,
3714
3860
  playNewTrackListFromArtist,
3861
+ playNewTrackListFromGenreCatalogue,
3715
3862
  fetchGenrePlaylistTracksPage: fetchTracksPage,
3716
3863
  loadMore,
3717
3864
  updateTrack
@@ -3729,6 +3876,7 @@ function TrackListProvider({
3729
3876
  playNewTrackListFromTrackUuid,
3730
3877
  playNewTrackListFromGenrePlaylist,
3731
3878
  playNewTrackListFromArtist,
3879
+ playNewTrackListFromGenreCatalogue,
3732
3880
  fetchTracksPage,
3733
3881
  loadMore,
3734
3882
  updateTrack
@@ -3759,24 +3907,24 @@ function ArtistNames({
3759
3907
  }
3760
3908
 
3761
3909
  // src/genre-tree/schemas/mb-artist.ts
3762
- var import_zod35 = require("zod");
3763
- var MbArtistDetailedSchema = import_zod35.z.object({
3764
- musicbrainzId: import_zod35.z.string().uuid(),
3765
- name: import_zod35.z.string(),
3910
+ var import_zod36 = require("zod");
3911
+ var MbArtistDetailedSchema = import_zod36.z.object({
3912
+ musicbrainzId: import_zod36.z.string().uuid(),
3913
+ name: import_zod36.z.string(),
3766
3914
  musicbrainzLink: HttpUrlSchema
3767
3915
  });
3768
3916
 
3769
3917
  // src/genre-tree/schemas/mb-recording.ts
3770
- var import_zod36 = require("zod");
3771
- var MbRecordingDetailedSchema = import_zod36.z.object({
3772
- musicbrainzId: import_zod36.z.string().uuid(),
3773
- title: import_zod36.z.string(),
3774
- score: import_zod36.z.number(),
3775
- musicbrainzArtists: import_zod36.z.array(MbArtistDetailedSchema),
3918
+ var import_zod37 = require("zod");
3919
+ var MbRecordingDetailedSchema = import_zod37.z.object({
3920
+ musicbrainzId: import_zod37.z.string().uuid(),
3921
+ title: import_zod37.z.string(),
3922
+ score: import_zod37.z.number(),
3923
+ musicbrainzArtists: import_zod37.z.array(MbArtistDetailedSchema),
3776
3924
  musicbrainzLink: HttpUrlSchema,
3777
- durationInSec: import_zod36.z.number().min(0).nullable().optional(),
3778
- durationStrInHourMinSec: import_zod36.z.string().nullable().optional(),
3779
- releaseDate: import_zod36.z.union([import_zod36.z.string().datetime(), import_zod36.z.string()]).transform((val) => {
3925
+ durationInSec: import_zod37.z.number().min(0).nullable().optional(),
3926
+ durationStrInHourMinSec: import_zod37.z.string().nullable().optional(),
3927
+ releaseDate: import_zod37.z.union([import_zod37.z.string().datetime(), import_zod37.z.string()]).transform((val) => {
3780
3928
  try {
3781
3929
  const date = new Date(val);
3782
3930
  if (isNaN(date.getTime())) {
@@ -3878,6 +4026,10 @@ function editGenreSongPages(data, edit) {
3878
4026
  FORM_RATING_NULL_VALUE,
3879
4027
  FUZZY_MIN_SIMILARITY,
3880
4028
  GOOGLE_EXCHANGE_CONFIG,
4029
+ GenreCatalogueCountsSchema,
4030
+ GenreCountsSchema,
4031
+ GenreCoverageSchema,
4032
+ GenrePlaylistSummarySchema,
3881
4033
  GenrePlaylistUuidSchema,
3882
4034
  GenreSearchResultSchema,
3883
4035
  GenreSearchResultsSchema,
@@ -3895,6 +4047,8 @@ function editGenreSongPages(data, edit) {
3895
4047
  PlayerProvider,
3896
4048
  PlayerVideoSurface,
3897
4049
  PopupProvider,
4050
+ ReferenceGenreDetailedSchema,
4051
+ ReferenceGenrePlaylistSchema,
3898
4052
  RegionGenreLexiconEntrySchema,
3899
4053
  RegionGenreLexiconSchema,
3900
4054
  SEARCH_DEBOUNCE_MS,
@@ -3907,6 +4061,8 @@ function editGenreSongPages(data, edit) {
3907
4061
  SongHistorySchema,
3908
4062
  SongSearchResultSchema,
3909
4063
  SongSearchResultsSchema,
4064
+ SubgenreCountsSchema,
4065
+ SubgenreScopeSchema,
3910
4066
  TrackBaseSchema,
3911
4067
  TrackList,
3912
4068
  TrackListFromArtist,
@@ -3915,6 +4071,7 @@ function editGenreSongPages(data, edit) {
3915
4071
  TrackListOrigin,
3916
4072
  TrackListOriginFromArtist,
3917
4073
  TrackListOriginFromCriteriaPlaylist,
4074
+ TrackListOriginFromGenreCatalogue,
3918
4075
  TrackListOriginFromTrack,
3919
4076
  TrackListOriginType,
3920
4077
  TrackListProvider,
@@ -3937,14 +4094,19 @@ function editGenreSongPages(data, edit) {
3937
4094
  createAppErrorFromResult,
3938
4095
  createLogout,
3939
4096
  createNetworkOrBackendError,
4097
+ defaultGenreMusicSelection,
3940
4098
  editGenreSongPages,
3941
4099
  exchangeCodeWithBackend,
3942
4100
  fetchWrapper,
3943
4101
  foldSearchText,
3944
4102
  formatTime,
3945
4103
  genreEndpoints,
4104
+ genreMusicCount,
4105
+ genreMusicQueryParams,
4106
+ genreMusicSelectionKey,
3946
4107
  genrePlaylistEndpoints,
3947
4108
  genrePlaylistQueryKeys,
4109
+ genrePlaylistTrackCount,
3948
4110
  genreQueryKeys,
3949
4111
  genreSearchQueryKeys,
3950
4112
  genreUpdateMutationKey,