@behindthemusictree/app-kit 33.0.0 → 33.1.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.
@@ -66,6 +66,7 @@ __export(genre_tree_exports, {
66
66
  TrackMinimumSchema: () => TrackMinimumSchema,
67
67
  UuidResourceSchema: () => UuidResourceSchema,
68
68
  YOUTUBE_UNPLAYABLE_REASON_LABELS: () => YOUTUBE_UNPLAYABLE_REASON_LABELS,
69
+ YoutubeAvailabilitySchema: () => YoutubeAvailabilitySchema,
69
70
  artistEndpoints: () => artistEndpoints,
70
71
  artistQueryKeys: () => artistQueryKeys,
71
72
  capitalizeFirstLetter: () => capitalizeFirstLetter,
@@ -118,19 +119,36 @@ __export(genre_tree_exports, {
118
119
  module.exports = __toCommonJS(genre_tree_exports);
119
120
 
120
121
  // src/genre-tree/useGenre.ts
121
- var import_zod22 = require("zod");
122
+ var import_zod23 = require("zod");
122
123
  var import_react_query5 = require("@tanstack/react-query");
123
- var import_react5 = require("react");
124
+ var import_react6 = require("react");
125
+
126
+ // src/transport/PlaybackContext.tsx
127
+ var import_react = require("react");
128
+ var import_zod = require("zod");
129
+ var import_jsx_runtime = require("react/jsx-runtime");
130
+ var PlaybackContextSchema = import_zod.z.object({ country: import_zod.z.string().regex(/^[A-Z]{2}$/).nullable() });
131
+ var unmanaged = {
132
+ country: null,
133
+ key: null,
134
+ ready: true,
135
+ error: null,
136
+ isCurrent: (_key) => true,
137
+ snapshot: () => ({ key: null, country: null }),
138
+ refresh: async (_force = false) => null
139
+ };
140
+ var PlaybackContext = (0, import_react.createContext)(unmanaged);
141
+ var usePlaybackContext = () => (0, import_react.useContext)(PlaybackContext);
124
142
 
125
143
  // src/transport/useFetchWrapper.ts
126
- var import_react3 = require("react");
144
+ var import_react4 = require("react");
127
145
 
128
146
  // src/transport/connectivity-error-context.tsx
129
- var import_react = require("react");
130
- var import_jsx_runtime = require("react/jsx-runtime");
131
- var ConnectivityErrorContext = (0, import_react.createContext)(void 0);
147
+ var import_react2 = require("react");
148
+ var import_jsx_runtime2 = require("react/jsx-runtime");
149
+ var ConnectivityErrorContext = (0, import_react2.createContext)(void 0);
132
150
  function useConnectivityError() {
133
- const context = (0, import_react.useContext)(ConnectivityErrorContext);
151
+ const context = (0, import_react2.useContext)(ConnectivityErrorContext);
134
152
  if (context === void 0) {
135
153
  throw new Error("useConnectivityError must be used within a ConnectivityErrorProvider");
136
154
  }
@@ -138,7 +156,7 @@ function useConnectivityError() {
138
156
  }
139
157
 
140
158
  // src/auth/SessionContext.tsx
141
- var import_react2 = require("react");
159
+ var import_react3 = require("react");
142
160
 
143
161
  // src/transport/query-client.ts
144
162
  var import_react_query = require("@tanstack/react-query");
@@ -153,10 +171,10 @@ var queryClient = new import_react_query.QueryClient({
153
171
  });
154
172
 
155
173
  // src/auth/SessionContext.tsx
156
- var import_jsx_runtime2 = require("react/jsx-runtime");
157
- var SessionContext = (0, import_react2.createContext)(void 0);
174
+ var import_jsx_runtime3 = require("react/jsx-runtime");
175
+ var SessionContext = (0, import_react3.createContext)(void 0);
158
176
  function useSession() {
159
- const context = (0, import_react2.useContext)(SessionContext);
177
+ const context = (0, import_react3.useContext)(SessionContext);
160
178
  if (context === void 0) {
161
179
  throw new Error("useSession must be used within a SessionProvider");
162
180
  }
@@ -480,7 +498,7 @@ var assertWellFormedRequest = (url, options) => {
480
498
  }
481
499
  };
482
500
  var isCallerAbort = (error, signal) => !!signal?.aborted && error?.name !== "TimeoutError";
483
- var fetchWrapper = async (url, requiresAuth, options = {}, accessToken, queryParams, handleMissingRequiredSession, handleError, expectBinary = false, backendBaseUrl) => {
501
+ var fetchWrapper = async (url, requiresAuth, options = {}, accessToken, queryParams, handleMissingRequiredSession, handleError, expectBinary = false, backendBaseUrl, onResponse) => {
484
502
  const urlWithParams = queryParams ? `${url}${url.includes("?") ? "&" : "?"}${new URLSearchParams(
485
503
  Object.entries(queryParams).map(([key, value]) => [key, String(value)])
486
504
  ).toString()}` : url;
@@ -498,9 +516,16 @@ var fetchWrapper = async (url, requiresAuth, options = {}, accessToken, queryPar
498
516
  handleMissingRequiredSession?.();
499
517
  return null;
500
518
  }
519
+ let responseHookFailed = false;
501
520
  try {
502
521
  assertWellFormedRequest(finalUrl, finalOptions);
503
522
  const result = await fetchWithNetworkRetry(finalUrl, finalOptions);
523
+ try {
524
+ await onResponse?.(result);
525
+ } catch (error) {
526
+ responseHookFailed = true;
527
+ throw error;
528
+ }
504
529
  if (!result.ok) {
505
530
  const appError = await createAppErrorFromResult(result, backendBaseUrl);
506
531
  throw appError;
@@ -514,7 +539,7 @@ var fetchWrapper = async (url, requiresAuth, options = {}, accessToken, queryPar
514
539
  return result.json();
515
540
  }
516
541
  } catch (caughtError) {
517
- if (isCallerAbort(caughtError, finalOptions.signal)) throw caughtError;
542
+ if (responseHookFailed || isCallerAbort(caughtError, finalOptions.signal)) throw caughtError;
518
543
  let appError = null;
519
544
  if (caughtError instanceof AppError) {
520
545
  appError = caughtError;
@@ -531,9 +556,10 @@ var fetchWrapper = async (url, requiresAuth, options = {}, accessToken, queryPar
531
556
 
532
557
  // src/transport/useFetchWrapper.ts
533
558
  var useFetchWrapper = (getBackendBaseUrl) => {
559
+ const playback = usePlaybackContext();
534
560
  const { setConnectivityError } = useConnectivityError();
535
561
  const { clearSession, session, sessionRestored } = useSession();
536
- const handleError = (0, import_react3.useCallback)((error) => {
562
+ const handleError = (0, import_react4.useCallback)((error) => {
537
563
  if (error instanceof ConnectivityError) {
538
564
  const authDetailErrors = [
539
565
  "BAC4011" /* BACKEND_GOOGLE_OAUTH_CODE_INVALID_OR_EXPIRED */,
@@ -560,37 +586,64 @@ var useFetchWrapper = (getBackendBaseUrl) => {
560
586
  if (!sessionRestored) return;
561
587
  setConnectivityError(createAppErrorFromErrorCode("SES4012" /* SESSION_REQUIRED */));
562
588
  };
563
- const fetch2 = (0, import_react3.useCallback)((backendEndpointOrUrl, fromBackend = true, requiresAuth = true, options = {}, queryParams, expectBinary = false, skipGlobalError = false) => {
589
+ const fetch2 = (0, import_react4.useCallback)((backendEndpointOrUrl, fromBackend = true, requiresAuth = true, options = {}, queryParams, expectBinary = false, skipGlobalError = false, acceptRefreshedContext = false) => {
564
590
  const baseUrl = getBackendBaseUrl().replace(/\/+$/, "");
565
591
  const endpointPath = String(backendEndpointOrUrl);
566
592
  if (fromBackend && endpointPath.startsWith("/")) {
567
593
  throw new Error(`Endpoint path must be relative (no leading slash). Got: "${endpointPath}".`);
568
594
  }
569
595
  const url = fromBackend ? endpointPath ? `${baseUrl}/${endpointPath}` : baseUrl : backendEndpointOrUrl;
570
- return fetchWrapper(
571
- url,
572
- requiresAuth,
573
- options,
574
- session?.accessToken || void 0,
575
- queryParams,
576
- handleMissingRequiredSession,
577
- skipGlobalError ? void 0 : handleError,
578
- expectBinary,
579
- baseUrl
580
- );
581
- }, [session?.accessToken, handleError, getBackendBaseUrl, sessionRestored, setConnectivityError]);
596
+ const perform = async (retryContextChange) => {
597
+ const contextual = playback.key !== null && fromBackend && /^(?:me\/)?(library\/songs|genre-playlists|playlists|manual-playlists)\//.test(endpointPath);
598
+ let requestContext = { key: playback.key, country: playback.country };
599
+ if (contextual) {
600
+ await playback.refresh();
601
+ if (acceptRefreshedContext) requestContext = playback.snapshot();
602
+ if (!playback.isCurrent(requestContext.key)) throw new DOMException("Playback context changed", "AbortError");
603
+ }
604
+ try {
605
+ const result = await fetchWrapper(
606
+ url,
607
+ requiresAuth,
608
+ options,
609
+ session?.accessToken || void 0,
610
+ queryParams,
611
+ handleMissingRequiredSession,
612
+ skipGlobalError ? void 0 : handleError,
613
+ expectBinary,
614
+ baseUrl,
615
+ contextual ? async (response) => {
616
+ const responseCountry = response.headers.get("x-playback-country");
617
+ if (responseCountry !== null && responseCountry !== (requestContext.country ?? "unknown")) {
618
+ await playback.refresh(true);
619
+ throw new DOMException("Playback context changed", "AbortError");
620
+ }
621
+ if (!playback.isCurrent(requestContext.key)) throw new DOMException("Playback context changed", "AbortError");
622
+ } : void 0
623
+ );
624
+ if (contextual && !playback.isCurrent(requestContext.key)) throw new DOMException("Playback context changed", "AbortError");
625
+ return result;
626
+ } catch (error) {
627
+ if (retryContextChange && contextual && error instanceof DOMException && error.name === "AbortError" && !playback.isCurrent(requestContext.key)) {
628
+ return perform(false);
629
+ }
630
+ throw error;
631
+ }
632
+ };
633
+ return perform(acceptRefreshedContext);
634
+ }, [session?.accessToken, handleError, getBackendBaseUrl, sessionRestored, setConnectivityError, playback]);
582
635
  return { fetch: fetch2 };
583
636
  };
584
637
 
585
638
  // src/genre-tree/useGenrePlaylist.ts
586
- var import_zod8 = require("zod");
639
+ var import_zod9 = require("zod");
587
640
  var import_react_query3 = require("@tanstack/react-query");
588
641
 
589
642
  // src/transport/lib/use-query-with-parse.ts
590
643
  var import_react_query2 = require("@tanstack/react-query");
591
644
 
592
645
  // src/transport/lib/parse-with-log.ts
593
- var import_zod = require("zod");
646
+ var import_zod2 = require("zod");
594
647
  function parseWithLog(schema, data, context) {
595
648
  const result = schema.safeParse(data);
596
649
  if (!result.success) {
@@ -598,7 +651,7 @@ function parseWithLog(schema, data, context) {
598
651
  if (data == null) {
599
652
  throw new Error(`${prefix} received null response before schema validation`);
600
653
  }
601
- console.error(`${prefix} schema validation failed`, import_zod.z.flattenError(result.error));
654
+ console.error(`${prefix} schema validation failed`, import_zod2.z.flattenError(result.error));
602
655
  throw result.error;
603
656
  }
604
657
  return result.data;
@@ -621,47 +674,47 @@ function useQueryWithParse({
621
674
  }
622
675
 
623
676
  // src/genre-tree/schemas/criteria-playlist/simple.ts
624
- var import_zod6 = require("zod");
677
+ var import_zod7 = require("zod");
625
678
 
626
679
  // src/genre-tree/schemas/criteria-playlist/detailed.ts
627
- var import_zod5 = require("zod");
680
+ var import_zod6 = require("zod");
628
681
 
629
682
  // src/genre-tree/schemas/ids.ts
630
- var import_zod2 = require("zod");
631
- var GenreUuidSchema = import_zod2.z.string().uuid().brand();
632
- var GenrePlaylistUuidSchema = import_zod2.z.string().uuid().brand();
683
+ var import_zod3 = require("zod");
684
+ var GenreUuidSchema = import_zod3.z.string().uuid().brand();
685
+ var GenrePlaylistUuidSchema = import_zod3.z.string().uuid().brand();
633
686
 
634
687
  // src/genre-tree/schemas/criteria/minimum.ts
635
- var import_zod3 = require("zod");
636
- var CriteriaMinimumSchema = import_zod3.z.object({
688
+ var import_zod4 = require("zod");
689
+ var CriteriaMinimumSchema = import_zod4.z.object({
637
690
  uuid: GenreUuidSchema,
638
- name: import_zod3.z.string(),
639
- side: import_zod3.z.enum(["core", "pop"]).nullable().optional(),
640
- wikidataId: import_zod3.z.string().nullable().optional()
691
+ name: import_zod4.z.string(),
692
+ side: import_zod4.z.enum(["core", "pop"]).nullable().optional(),
693
+ wikidataId: import_zod4.z.string().nullable().optional()
641
694
  });
642
695
 
643
696
  // src/genre-tree/schemas/criteria-playlist/minimum.ts
644
- var import_zod4 = require("zod");
645
- var CriteriaPlaylistMinimumSchema = import_zod4.z.object({
697
+ var import_zod5 = require("zod");
698
+ var CriteriaPlaylistMinimumSchema = import_zod5.z.object({
646
699
  uuid: GenrePlaylistUuidSchema,
647
- name: import_zod4.z.string()
700
+ name: import_zod5.z.string()
648
701
  });
649
702
 
650
703
  // src/genre-tree/schemas/criteria-playlist/detailed.ts
651
- var CriteriaPlaylistDetailedSchema = import_zod5.z.object({
704
+ var CriteriaPlaylistDetailedSchema = import_zod6.z.object({
652
705
  uuid: GenrePlaylistUuidSchema,
653
- name: import_zod5.z.string(),
654
- tracksCount: import_zod5.z.number(),
706
+ name: import_zod6.z.string(),
707
+ tracksCount: import_zod6.z.number(),
655
708
  // Summed YouTube views of the same songs as `tracksCount`. Optional: hear-api has no view counts.
656
- viewsCount: import_zod5.z.number().optional(),
657
- durationInSec: import_zod5.z.number().min(0).nullable().optional(),
658
- durationStrInHourMinSec: import_zod5.z.string().nullable().optional(),
709
+ viewsCount: import_zod6.z.number().optional(),
710
+ durationInSec: import_zod6.z.number().min(0).nullable().optional(),
711
+ durationStrInHourMinSec: import_zod6.z.string().nullable().optional(),
659
712
  // Nullable: the "Genreless" root playlist has no criteria attached and is never updated.
660
713
  criteria: CriteriaMinimumSchema.nullable(),
661
714
  parent: CriteriaPlaylistMinimumSchema.nullable(),
662
715
  root: CriteriaPlaylistMinimumSchema,
663
- createdOn: import_zod5.z.string(),
664
- updatedOn: import_zod5.z.string().nullable()
716
+ createdOn: import_zod6.z.string(),
717
+ updatedOn: import_zod6.z.string().nullable()
665
718
  });
666
719
 
667
720
  // src/genre-tree/schemas/criteria-playlist/simple.ts
@@ -677,23 +730,23 @@ var CriteriaPlaylistSimpleSchema = CriteriaPlaylistDetailedSchema.pick({
677
730
  updatedOn: true
678
731
  }).extend({
679
732
  // Only on the tree/list payloads, not the detail endpoint — hence not on the detailed schema.
680
- isUnacceptedRoot: import_zod6.z.boolean(),
733
+ isUnacceptedRoot: import_zod7.z.boolean(),
681
734
  // Optional: a backend that does not curate umbrella genres omits it.
682
- isUmbrella: import_zod6.z.boolean().optional(),
735
+ isUmbrella: import_zod7.z.boolean().optional(),
683
736
  // Optional: only the grow tree payload carries it; null when the genre has no scene.
684
- scene: import_zod6.z.enum(["commercial", "underground"]).nullable().optional()
737
+ scene: import_zod7.z.enum(["commercial", "underground"]).nullable().optional()
685
738
  });
686
739
 
687
740
  // src/transport/lib/paginated-response.ts
688
- var import_zod7 = require("zod");
689
- var PaginatedResponseSchema = (itemSchema) => import_zod7.z.object({
690
- overallTotal: import_zod7.z.number(),
691
- next: import_zod7.z.string().url().nullable(),
692
- previous: import_zod7.z.string().url().nullable(),
693
- results: import_zod7.z.array(itemSchema),
694
- page: import_zod7.z.number(),
695
- pageSize: import_zod7.z.number(),
696
- totalPages: import_zod7.z.number()
741
+ var import_zod8 = require("zod");
742
+ var PaginatedResponseSchema = (itemSchema) => import_zod8.z.object({
743
+ overallTotal: import_zod8.z.number(),
744
+ next: import_zod8.z.string().url().nullable(),
745
+ previous: import_zod8.z.string().url().nullable(),
746
+ results: import_zod8.z.array(itemSchema),
747
+ page: import_zod8.z.number(),
748
+ pageSize: import_zod8.z.number(),
749
+ totalPages: import_zod8.z.number()
697
750
  });
698
751
 
699
752
  // src/genre-tree/api/genre-playlists/queryKeys.ts
@@ -821,7 +874,7 @@ var useListFullGenrePlaylists = (scope, getBackendBaseUrl) => {
821
874
  { page, pageSize: FULL_LIST_PAGE_SIZE, treeName: "canonical" }
822
875
  )
823
876
  ),
824
- schema: import_zod8.z.array(CriteriaPlaylistSimpleSchema),
877
+ schema: import_zod9.z.array(CriteriaPlaylistSimpleSchema),
825
878
  context: "useListFullGenrePlaylists",
826
879
  enabled: scope === "reference" || sessionRestored && !!session?.accessToken
827
880
  });
@@ -856,15 +909,15 @@ var useInvalidateAllGenrePlaylistQueries = () => {
856
909
 
857
910
  // src/transport/lib/use-validated-mutation.ts
858
911
  var import_react_query4 = require("@tanstack/react-query");
859
- var import_react4 = require("react");
860
- var import_zod9 = require("zod");
912
+ var import_react5 = require("react");
913
+ var import_zod10 = require("zod");
861
914
  function useValidatedMutation({
862
915
  inputSchema,
863
916
  outputSchema,
864
917
  mutationFn,
865
918
  ...options
866
919
  }) {
867
- const [formErrors, setFormErrors] = (0, import_react4.useState)([]);
920
+ const [formErrors, setFormErrors] = (0, import_react5.useState)([]);
868
921
  const validatedMutation = (0, import_react_query4.useMutation)({
869
922
  ...options,
870
923
  mutationFn: async (data) => {
@@ -890,9 +943,9 @@ function useValidatedMutation({
890
943
  } catch (error) {
891
944
  if (error instanceof Error && "json" in error) {
892
945
  try {
893
- const errorResponse = import_zod9.z.object({
894
- details: import_zod9.z.object({
895
- fieldErrors: import_zod9.z.record(import_zod9.z.string(), import_zod9.z.array(import_zod9.z.object({ message: import_zod9.z.string() })))
946
+ const errorResponse = import_zod10.z.object({
947
+ details: import_zod10.z.object({
948
+ fieldErrors: import_zod10.z.record(import_zod10.z.string(), import_zod10.z.array(import_zod10.z.object({ message: import_zod10.z.string() })))
896
949
  })
897
950
  }).parse(error.json);
898
951
  setFormErrors(
@@ -916,46 +969,46 @@ function useValidatedMutation({
916
969
  }
917
970
 
918
971
  // src/genre-tree/schemas/criteria/detailed.ts
919
- var import_zod16 = require("zod");
972
+ var import_zod17 = require("zod");
920
973
 
921
974
  // src/genre-tree/schemas/track/base.ts
922
- var import_zod13 = require("zod");
975
+ var import_zod14 = require("zod");
923
976
 
924
977
  // src/genre-tree/schemas/artist-minimum.ts
925
- var import_zod10 = require("zod");
926
- var ArtistMinimumSchema = import_zod10.z.object({
927
- uuid: import_zod10.z.string().uuid(),
928
- name: import_zod10.z.string(),
929
- isSpecialPurpose: import_zod10.z.boolean().optional()
930
- });
931
-
932
- // src/genre-tree/schemas/album-minimum.ts
933
978
  var import_zod11 = require("zod");
934
- var AlbumMinimumSchema = import_zod11.z.object({
979
+ var ArtistMinimumSchema = import_zod11.z.object({
935
980
  uuid: import_zod11.z.string().uuid(),
936
981
  name: import_zod11.z.string(),
937
- albumArtists: import_zod11.z.array(ArtistMinimumSchema).nullable().optional()
982
+ isSpecialPurpose: import_zod11.z.boolean().optional()
938
983
  });
939
984
 
940
- // src/genre-tree/schemas/uuid-resource.ts
985
+ // src/genre-tree/schemas/album-minimum.ts
941
986
  var import_zod12 = require("zod");
942
- var UuidResourceSchema = import_zod12.z.object({
943
- uuid: import_zod12.z.string().uuid()
987
+ var AlbumMinimumSchema = import_zod12.z.object({
988
+ uuid: import_zod12.z.string().uuid(),
989
+ name: import_zod12.z.string(),
990
+ albumArtists: import_zod12.z.array(ArtistMinimumSchema).nullable().optional()
991
+ });
992
+
993
+ // src/genre-tree/schemas/uuid-resource.ts
994
+ var import_zod13 = require("zod");
995
+ var UuidResourceSchema = import_zod13.z.object({
996
+ uuid: import_zod13.z.string().uuid()
944
997
  });
945
998
 
946
999
  // src/genre-tree/schemas/track/base.ts
947
1000
  var TrackBaseSchema = UuidResourceSchema.extend({
948
- title: import_zod13.z.string(),
949
- artists: import_zod13.z.array(ArtistMinimumSchema).nullable().optional(),
1001
+ title: import_zod14.z.string(),
1002
+ artists: import_zod14.z.array(ArtistMinimumSchema).nullable().optional(),
950
1003
  album: AlbumMinimumSchema.nullable().optional(),
951
- trackNumber: import_zod13.z.number().nullable().optional(),
1004
+ trackNumber: import_zod14.z.number().nullable().optional(),
952
1005
  // null for a song not yet linked to a genre.
953
1006
  genre: CriteriaMinimumSchema.nullable(),
954
- rating: import_zod13.z.number().min(0).max(10).nullable().optional(),
955
- language: import_zod13.z.string().nullable().optional(),
956
- playCount: import_zod13.z.number().min(0),
957
- createdOn: import_zod13.z.string().datetime(),
958
- updatedOn: import_zod13.z.string().datetime().nullable().optional()
1007
+ rating: import_zod14.z.number().min(0).max(10).nullable().optional(),
1008
+ language: import_zod14.z.string().nullable().optional(),
1009
+ playCount: import_zod14.z.number().min(0),
1010
+ createdOn: import_zod14.z.string().datetime(),
1011
+ updatedOn: import_zod14.z.string().datetime().nullable().optional()
959
1012
  });
960
1013
 
961
1014
  // src/genre-tree/schemas/track/minimum.ts
@@ -966,80 +1019,80 @@ var TrackMinimumSchema = TrackBaseSchema.pick({
966
1019
  });
967
1020
 
968
1021
  // src/genre-tree/schemas/criteria/lineage-rel/without-ascendant.ts
969
- var import_zod14 = require("zod");
970
- var CriteriaLineageRelWithoutAscendantSchema = import_zod14.z.object({
1022
+ var import_zod15 = require("zod");
1023
+ var CriteriaLineageRelWithoutAscendantSchema = import_zod15.z.object({
971
1024
  descendant: CriteriaMinimumSchema,
972
- degree: import_zod14.z.number()
1025
+ degree: import_zod15.z.number()
973
1026
  });
974
1027
 
975
1028
  // src/genre-tree/schemas/criteria/lineage-rel/without-descendant.ts
976
- var import_zod15 = require("zod");
977
- var CriteriaLineageRelWithoutDescendantSchema = import_zod15.z.object({
1029
+ var import_zod16 = require("zod");
1030
+ var CriteriaLineageRelWithoutDescendantSchema = import_zod16.z.object({
978
1031
  ascendant: CriteriaMinimumSchema,
979
- degree: import_zod15.z.number()
1032
+ degree: import_zod16.z.number()
980
1033
  });
981
1034
 
982
1035
  // src/genre-tree/schemas/criteria/detailed.ts
983
- var CriteriaDetailedSchema = import_zod16.z.object({
1036
+ var CriteriaDetailedSchema = import_zod17.z.object({
984
1037
  uuid: GenreUuidSchema,
985
- name: import_zod16.z.string(),
986
- summary: import_zod16.z.string().nullable(),
1038
+ name: import_zod17.z.string(),
1039
+ summary: import_zod17.z.string().nullable(),
987
1040
  // Optional until every deployed API serves it.
988
- wikidataId: import_zod16.z.string().nullable().optional(),
1041
+ wikidataId: import_zod17.z.string().nullable().optional(),
989
1042
  parent: CriteriaMinimumSchema.nullable(),
990
- ascendants: import_zod16.z.array(CriteriaLineageRelWithoutDescendantSchema),
991
- descendants: import_zod16.z.array(CriteriaLineageRelWithoutAscendantSchema),
1043
+ ascendants: import_zod17.z.array(CriteriaLineageRelWithoutDescendantSchema),
1044
+ descendants: import_zod17.z.array(CriteriaLineageRelWithoutAscendantSchema),
992
1045
  root: CriteriaMinimumSchema,
993
- children: import_zod16.z.array(CriteriaMinimumSchema),
1046
+ children: import_zod17.z.array(CriteriaMinimumSchema),
994
1047
  criteriaPlaylist: CriteriaPlaylistMinimumSchema,
995
- tracks: import_zod16.z.array(TrackMinimumSchema),
996
- essentialSongs: import_zod16.z.array(TrackMinimumSchema),
997
- tracksCount: import_zod16.z.number(),
998
- updatedOn: import_zod16.z.string().datetime().nullable()
1048
+ tracks: import_zod17.z.array(TrackMinimumSchema),
1049
+ essentialSongs: import_zod17.z.array(TrackMinimumSchema),
1050
+ tracksCount: import_zod17.z.number(),
1051
+ updatedOn: import_zod17.z.string().datetime().nullable()
999
1052
  });
1000
1053
 
1001
1054
  // src/genre-tree/schemas/criteria/overview.ts
1002
- var import_zod18 = require("zod");
1055
+ var import_zod19 = require("zod");
1003
1056
 
1004
1057
  // src/genre-tree/schemas/http-url.ts
1005
- var import_zod17 = require("zod");
1006
- var HttpUrlSchema = import_zod17.z.url({ protocol: /^https?$/ });
1058
+ var import_zod18 = require("zod");
1059
+ var HttpUrlSchema = import_zod18.z.url({ protocol: /^https?$/ });
1007
1060
 
1008
1061
  // src/genre-tree/schemas/criteria/overview.ts
1009
- var CriteriaOverviewSchema = import_zod18.z.object({
1062
+ var CriteriaOverviewSchema = import_zod19.z.object({
1010
1063
  uuid: GenreUuidSchema,
1011
- name: import_zod18.z.string(),
1012
- summary: import_zod18.z.string().nullable(),
1013
- description: import_zod18.z.string().nullable(),
1064
+ name: import_zod19.z.string(),
1065
+ summary: import_zod19.z.string().nullable(),
1066
+ description: import_zod19.z.string().nullable(),
1014
1067
  summarySourceUrl: HttpUrlSchema.nullable(),
1015
- essentialSongs: import_zod18.z.array(TrackMinimumSchema).optional()
1068
+ essentialSongs: import_zod19.z.array(TrackMinimumSchema).optional()
1016
1069
  });
1017
1070
 
1018
1071
  // src/genre-tree/schemas/criteria/simple.ts
1019
- var import_zod19 = require("zod");
1020
- var CriteriaSimpleSchema = import_zod19.z.object({
1072
+ var import_zod20 = require("zod");
1073
+ var CriteriaSimpleSchema = import_zod20.z.object({
1021
1074
  uuid: GenreUuidSchema,
1022
- name: import_zod19.z.string(),
1075
+ name: import_zod20.z.string(),
1023
1076
  parent: CriteriaMinimumSchema.nullable(),
1024
- createdOn: import_zod19.z.string().datetime(),
1025
- summary: import_zod19.z.string().nullable()
1077
+ createdOn: import_zod20.z.string().datetime(),
1078
+ summary: import_zod20.z.string().nullable()
1026
1079
  });
1027
1080
 
1028
1081
  // src/genre-tree/schemas/criteria/creation.ts
1029
- var import_zod20 = require("zod");
1030
- var CriteriaCreationSchema = import_zod20.z.object({
1031
- name: import_zod20.z.string().min(1, "Name is required"),
1082
+ var import_zod21 = require("zod");
1083
+ var CriteriaCreationSchema = import_zod21.z.object({
1084
+ name: import_zod21.z.string().min(1, "Name is required"),
1032
1085
  parent: GenreUuidSchema.optional(),
1033
- essentialSongs: import_zod20.z.array(import_zod20.z.string().uuid()).optional()
1086
+ essentialSongs: import_zod21.z.array(import_zod21.z.string().uuid()).optional()
1034
1087
  });
1035
1088
 
1036
1089
  // src/genre-tree/schemas/criteria/update.ts
1037
- var import_zod21 = require("zod");
1038
- var CriteriaUpdateSchema = import_zod21.z.object({
1039
- name: import_zod21.z.string().optional(),
1090
+ var import_zod22 = require("zod");
1091
+ var CriteriaUpdateSchema = import_zod22.z.object({
1092
+ name: import_zod22.z.string().optional(),
1040
1093
  parent: GenreUuidSchema.nullable().optional(),
1041
- essentialSongs: import_zod21.z.array(import_zod21.z.string().uuid()).optional(),
1042
- side: import_zod21.z.enum(["core", "pop"]).optional()
1094
+ essentialSongs: import_zod22.z.array(import_zod22.z.string().uuid()).optional(),
1095
+ side: import_zod22.z.enum(["core", "pop"]).optional()
1043
1096
  });
1044
1097
 
1045
1098
  // src/genre-tree/api/genres/queryKeys.ts
@@ -1090,7 +1143,7 @@ function useListGenres(page = 1, pageSize = 50, scope, getBackendBaseUrl) {
1090
1143
  }
1091
1144
  function useFetchGenre(scope, getBackendBaseUrl) {
1092
1145
  const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
1093
- return (0, import_react5.useCallback)(
1146
+ return (0, import_react6.useCallback)(
1094
1147
  async (id) => {
1095
1148
  const endpoint = scope === "reference" ? genreEndpoints.reference.detail(id) : genreEndpoints.me.detail(id);
1096
1149
  const response = await fetch2(endpoint, true, scope === "me");
@@ -1129,7 +1182,7 @@ function useGenreByWikidataId(qid, scope, getBackendBaseUrl) {
1129
1182
  var GENRE_OVERVIEW_STALE_TIME_MS = 6e4;
1130
1183
  function useGenreOverviewQueryOptions(scope, getBackendBaseUrl, schema) {
1131
1184
  const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
1132
- return (0, import_react5.useCallback)(
1185
+ return (0, import_react6.useCallback)(
1133
1186
  (id) => {
1134
1187
  const queryKeys = scope === "reference" ? genreQueryKeys.reference : genreQueryKeys.me;
1135
1188
  const endpoints = scope === "reference" ? genreEndpoints.reference : genreEndpoints.me;
@@ -1149,7 +1202,7 @@ function useFetchGenreOverview(id, scope, getBackendBaseUrl, schema = CriteriaOv
1149
1202
  function usePrefetchGenreOverview(scope, getBackendBaseUrl, schema = CriteriaOverviewSchema) {
1150
1203
  const queryClient2 = (0, import_react_query5.useQueryClient)();
1151
1204
  const queryOptions = useGenreOverviewQueryOptions(scope, getBackendBaseUrl, schema);
1152
- return (0, import_react5.useCallback)((id) => queryClient2.prefetchQuery(queryOptions(id)), [queryClient2, queryOptions]);
1205
+ return (0, import_react6.useCallback)((id) => queryClient2.prefetchQuery(queryOptions(id)), [queryClient2, queryOptions]);
1153
1206
  }
1154
1207
  function useRefreshGenreTree(scope) {
1155
1208
  const queryClient2 = (0, import_react_query5.useQueryClient)();
@@ -1188,7 +1241,7 @@ function useUpdateGenre(scope, getBackendBaseUrl) {
1188
1241
  const refreshGenreTree = useRefreshGenreTree(scope);
1189
1242
  const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
1190
1243
  const { mutate, mutateAsync, isPending, formErrors } = useValidatedMutation({
1191
- inputSchema: import_zod22.z.object({
1244
+ inputSchema: import_zod23.z.object({
1192
1245
  uuid: GenreUuidSchema,
1193
1246
  data: CriteriaUpdateSchema
1194
1247
  }),
@@ -1218,8 +1271,8 @@ function useDeleteGenre(scope, getBackendBaseUrl) {
1218
1271
  const refreshGenreTree = useRefreshGenreTree(scope);
1219
1272
  const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
1220
1273
  return useValidatedMutation({
1221
- inputSchema: import_zod22.z.object({ uuid: GenreUuidSchema }),
1222
- outputSchema: import_zod22.z.null(),
1274
+ inputSchema: import_zod23.z.object({ uuid: GenreUuidSchema }),
1275
+ outputSchema: import_zod23.z.null(),
1223
1276
  mutationFn: async ({ uuid }) => {
1224
1277
  const endpoint = scope === "reference" ? genreEndpoints.reference.delete(uuid) : genreEndpoints.me.delete(uuid);
1225
1278
  return fetch2(endpoint, true, scope === "me", { method: "DELETE" }, void 0, false, true);
@@ -1229,16 +1282,16 @@ function useDeleteGenre(scope, getBackendBaseUrl) {
1229
1282
  }
1230
1283
 
1231
1284
  // src/genre-tree/useArtist.ts
1232
- var import_zod24 = require("zod");
1285
+ var import_zod25 = require("zod");
1233
1286
 
1234
1287
  // src/genre-tree/schemas/artist-detailed.ts
1235
- var import_zod23 = require("zod");
1236
- var ArtistMembershipSchema = import_zod23.z.object({
1288
+ var import_zod24 = require("zod");
1289
+ var ArtistMembershipSchema = import_zod24.z.object({
1237
1290
  artist: ArtistMinimumSchema,
1238
- beginYear: import_zod23.z.number().int().nullable(),
1239
- endYear: import_zod23.z.number().int().nullable(),
1240
- ended: import_zod23.z.boolean(),
1241
- roles: import_zod23.z.array(import_zod23.z.string())
1291
+ beginYear: import_zod24.z.number().int().nullable(),
1292
+ endYear: import_zod24.z.number().int().nullable(),
1293
+ ended: import_zod24.z.boolean(),
1294
+ roles: import_zod24.z.array(import_zod24.z.string())
1242
1295
  });
1243
1296
  var ARTIST_LINK_KINDS = [
1244
1297
  "official",
@@ -1251,35 +1304,35 @@ var ARTIST_LINK_KINDS = [
1251
1304
  "discogs",
1252
1305
  "social"
1253
1306
  ];
1254
- var ArtistImageSchema = import_zod23.z.object({
1307
+ var ArtistImageSchema = import_zod24.z.object({
1255
1308
  url: HttpUrlSchema,
1256
1309
  pageUrl: HttpUrlSchema,
1257
- author: import_zod23.z.string().nullable(),
1258
- license: import_zod23.z.string(),
1310
+ author: import_zod24.z.string().nullable(),
1311
+ license: import_zod24.z.string(),
1259
1312
  licenseUrl: HttpUrlSchema.nullable()
1260
1313
  });
1261
- var ArtistDetailedSchema = import_zod23.z.object({
1262
- uuid: import_zod23.z.string().uuid(),
1263
- name: import_zod23.z.string(),
1264
- musicbrainzArtistId: import_zod23.z.string().uuid().nullable(),
1265
- type: import_zod23.z.enum(["person", "group", "orchestra", "choir", "character", "other"]).nullable(),
1266
- country: import_zod23.z.string().nullable(),
1267
- beginYear: import_zod23.z.number().int().nullable(),
1268
- endYear: import_zod23.z.number().int().nullable(),
1269
- ended: import_zod23.z.boolean(),
1270
- links: import_zod23.z.array(import_zod23.z.object({ kind: import_zod23.z.enum(ARTIST_LINK_KINDS), url: HttpUrlSchema })),
1271
- members: import_zod23.z.array(ArtistMembershipSchema),
1272
- memberOf: import_zod23.z.array(ArtistMembershipSchema),
1273
- albums: import_zod23.z.array(
1274
- import_zod23.z.object({
1275
- uuid: import_zod23.z.string().uuid(),
1276
- name: import_zod23.z.string(),
1277
- year: import_zod23.z.string().nullable(),
1278
- primaryType: import_zod23.z.string().nullable(),
1279
- secondaryTypes: import_zod23.z.array(import_zod23.z.string())
1314
+ var ArtistDetailedSchema = import_zod24.z.object({
1315
+ uuid: import_zod24.z.string().uuid(),
1316
+ name: import_zod24.z.string(),
1317
+ musicbrainzArtistId: import_zod24.z.string().uuid().nullable(),
1318
+ type: import_zod24.z.enum(["person", "group", "orchestra", "choir", "character", "other"]).nullable(),
1319
+ country: import_zod24.z.string().nullable(),
1320
+ beginYear: import_zod24.z.number().int().nullable(),
1321
+ endYear: import_zod24.z.number().int().nullable(),
1322
+ ended: import_zod24.z.boolean(),
1323
+ links: import_zod24.z.array(import_zod24.z.object({ kind: import_zod24.z.enum(ARTIST_LINK_KINDS), url: HttpUrlSchema })),
1324
+ members: import_zod24.z.array(ArtistMembershipSchema),
1325
+ memberOf: import_zod24.z.array(ArtistMembershipSchema),
1326
+ albums: import_zod24.z.array(
1327
+ import_zod24.z.object({
1328
+ uuid: import_zod24.z.string().uuid(),
1329
+ name: import_zod24.z.string(),
1330
+ year: import_zod24.z.string().nullable(),
1331
+ primaryType: import_zod24.z.string().nullable(),
1332
+ secondaryTypes: import_zod24.z.array(import_zod24.z.string())
1280
1333
  })
1281
1334
  ),
1282
- tracksCount: import_zod23.z.number().int(),
1335
+ tracksCount: import_zod24.z.number().int(),
1283
1336
  image: ArtistImageSchema.nullable()
1284
1337
  });
1285
1338
 
@@ -1302,7 +1355,7 @@ var artistEndpoints = {
1302
1355
  var isNotFound = (error) => error instanceof AppError && error.code === "BAC4040" /* BACKEND_NOT_FOUND */;
1303
1356
  function useArtist(uuid, getBackendBaseUrl) {
1304
1357
  const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
1305
- const isUuid = uuid !== null && import_zod24.z.string().uuid().safeParse(uuid).success;
1358
+ const isUuid = uuid !== null && import_zod25.z.string().uuid().safeParse(uuid).success;
1306
1359
  const { data, isPending, error } = useQueryWithParse({
1307
1360
  queryKey: artistQueryKeys.detail(uuid),
1308
1361
  // A missing artist is shown in the panel, not raised as an app-wide connectivity error.
@@ -1321,22 +1374,22 @@ function useArtist(uuid, getBackendBaseUrl) {
1321
1374
 
1322
1375
  // src/genre-tree/useArtistSearch.ts
1323
1376
  var import_react_query6 = require("@tanstack/react-query");
1324
- var import_react6 = require("react");
1377
+ var import_react7 = require("react");
1325
1378
 
1326
1379
  // src/genre-tree/schemas/artist-search.ts
1327
- var import_zod25 = require("zod");
1328
- var ArtistSearchResultSchema = import_zod25.z.object({
1329
- uuid: import_zod25.z.string().uuid(),
1330
- name: import_zod25.z.string(),
1331
- disambiguation: import_zod25.z.string().nullable(),
1332
- type: import_zod25.z.enum(["person", "group", "orchestra", "choir", "character", "other"]).nullable(),
1333
- country: import_zod25.z.string().nullable(),
1334
- beginYear: import_zod25.z.number().int().nullable(),
1335
- endYear: import_zod25.z.number().int().nullable(),
1336
- matchedAlias: import_zod25.z.string().nullable(),
1337
- recordingCount: import_zod25.z.number().int()
1380
+ var import_zod26 = require("zod");
1381
+ var ArtistSearchResultSchema = import_zod26.z.object({
1382
+ uuid: import_zod26.z.string().uuid(),
1383
+ name: import_zod26.z.string(),
1384
+ disambiguation: import_zod26.z.string().nullable(),
1385
+ type: import_zod26.z.enum(["person", "group", "orchestra", "choir", "character", "other"]).nullable(),
1386
+ country: import_zod26.z.string().nullable(),
1387
+ beginYear: import_zod26.z.number().int().nullable(),
1388
+ endYear: import_zod26.z.number().int().nullable(),
1389
+ matchedAlias: import_zod26.z.string().nullable(),
1390
+ recordingCount: import_zod26.z.number().int()
1338
1391
  });
1339
- var ArtistSearchResultsSchema = import_zod25.z.array(ArtistSearchResultSchema);
1392
+ var ArtistSearchResultsSchema = import_zod26.z.array(ArtistSearchResultSchema);
1340
1393
 
1341
1394
  // src/genre-tree/useArtistSearch.ts
1342
1395
  var DEBOUNCE_MS = 250;
@@ -1345,8 +1398,8 @@ var RESULT_LIMIT = 8;
1345
1398
  function useArtistSearch(getBackendBaseUrl, text) {
1346
1399
  const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
1347
1400
  const trimmed = text.trim();
1348
- const [query, setQuery] = (0, import_react6.useState)("");
1349
- (0, import_react6.useEffect)(() => {
1401
+ const [query, setQuery] = (0, import_react7.useState)("");
1402
+ (0, import_react7.useEffect)(() => {
1350
1403
  const timer = setTimeout(() => setQuery(trimmed), DEBOUNCE_MS);
1351
1404
  return () => clearTimeout(timer);
1352
1405
  }, [trimmed]);
@@ -1370,10 +1423,10 @@ function useArtistSearch(getBackendBaseUrl, text) {
1370
1423
  }
1371
1424
 
1372
1425
  // src/genre-tree/useSong.ts
1373
- var import_zod27 = require("zod");
1426
+ var import_zod28 = require("zod");
1374
1427
 
1375
1428
  // src/genre-tree/schemas/song/detailed.ts
1376
- var import_zod26 = require("zod");
1429
+ var import_zod27 = require("zod");
1377
1430
  var YOUTUBE_UNPLAYABLE_REASON_LABELS = {
1378
1431
  not_found: "Video unavailable",
1379
1432
  not_embeddable: "Embedding disabled",
@@ -1382,17 +1435,23 @@ var YOUTUBE_UNPLAYABLE_REASON_LABELS = {
1382
1435
  region_whitelisted: "Region restricted"
1383
1436
  };
1384
1437
  var YOUTUBE_UNPLAYABLE_REASONS = Object.keys(YOUTUBE_UNPLAYABLE_REASON_LABELS);
1438
+ var YoutubeAvailabilitySchema = import_zod27.z.object({
1439
+ status: import_zod27.z.enum(["eligible", "blocked", "unknown"]),
1440
+ reason: import_zod27.z.string().nullable(),
1441
+ country: import_zod27.z.string().nullable()
1442
+ });
1385
1443
  var SongDetailedSchema = TrackBaseSchema.extend({
1386
- youtubeVideo: import_zod26.z.object({
1387
- id: import_zod26.z.string(),
1444
+ youtubeVideo: import_zod27.z.object({
1445
+ id: import_zod27.z.string(),
1446
+ availability: YoutubeAvailabilitySchema.optional(),
1388
1447
  // null = playable
1389
- unplayableReason: import_zod26.z.enum(YOUTUBE_UNPLAYABLE_REASONS).nullable(),
1390
- viewCount: import_zod26.z.number().int().nullable().optional()
1448
+ unplayableReason: import_zod27.z.enum(YOUTUBE_UNPLAYABLE_REASONS).nullable(),
1449
+ viewCount: import_zod27.z.number().int().nullable().optional()
1391
1450
  }).nullable(),
1392
1451
  // null for hand-made/admin songs
1393
- musicbrainzRecordingId: import_zod26.z.string().uuid().nullable(),
1394
- firstReleaseYear: import_zod26.z.number().int().nullable().optional(),
1395
- essentialGenres: import_zod26.z.array(CriteriaMinimumSchema).optional()
1452
+ musicbrainzRecordingId: import_zod27.z.string().uuid().nullable(),
1453
+ firstReleaseYear: import_zod27.z.number().int().nullable().optional(),
1454
+ essentialGenres: import_zod27.z.array(CriteriaMinimumSchema).optional()
1396
1455
  });
1397
1456
  var NO_VIDEO_LABEL = "No video available";
1398
1457
  function isSong(track) {
@@ -1400,6 +1459,7 @@ function isSong(track) {
1400
1459
  }
1401
1460
  function songUnplayableReason(song) {
1402
1461
  if (!song.youtubeVideo) return NO_VIDEO_LABEL;
1462
+ if (song.youtubeVideo.availability?.status === "blocked" && song.youtubeVideo.availability.reason === "region_blocked") return "Unavailable in your country";
1403
1463
  const reason = song.youtubeVideo.unplayableReason;
1404
1464
  return reason ? YOUTUBE_UNPLAYABLE_REASON_LABELS[reason] : null;
1405
1465
  }
@@ -1410,14 +1470,15 @@ function musicBrainzRecordingUrl(song) {
1410
1470
  // src/genre-tree/useSong.ts
1411
1471
  var isNotFound2 = (error) => error instanceof AppError && error.code === "BAC4040" /* BACKEND_NOT_FOUND */;
1412
1472
  function useSong(uuid, getBackendBaseUrl) {
1473
+ const playback = usePlaybackContext();
1413
1474
  const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
1414
- const isUuid = uuid !== null && import_zod27.z.string().uuid().safeParse(uuid).success;
1475
+ const isUuid = uuid !== null && import_zod28.z.string().uuid().safeParse(uuid).success;
1415
1476
  const { data, isPending, error } = useQueryWithParse({
1416
- queryKey: libraryQueryKeys.reference.songs.detail(uuid),
1477
+ queryKey: [...libraryQueryKeys.reference.songs.detail(uuid), ...playback.key ? [playback.key] : []],
1417
1478
  // A missing song is shown in the panel, not raised as an app-wide connectivity error.
1418
1479
  queryFn: ({ signal }) => fetch2(libraryEndpoints.reference.songs.detail(uuid), true, false, { signal }, void 0, false, true),
1419
1480
  schema: SongDetailedSchema,
1420
- enabled: isUuid,
1481
+ enabled: isUuid && playback.ready,
1421
1482
  retry: (failureCount, retryError) => !isNotFound2(retryError) && failureCount < 3,
1422
1483
  context: "useSong"
1423
1484
  });
@@ -1429,16 +1490,16 @@ function useSong(uuid, getBackendBaseUrl) {
1429
1490
  }
1430
1491
 
1431
1492
  // src/genre-tree/schemas/song-history.ts
1432
- var import_zod28 = require("zod");
1433
- var SongHistoryEntrySchema = import_zod28.z.object({
1434
- uuid: import_zod28.z.string().uuid(),
1435
- action: import_zod28.z.string(),
1436
- actorPseudo: import_zod28.z.string().nullable(),
1437
- oldValue: import_zod28.z.string().nullable(),
1438
- newValue: import_zod28.z.string().nullable(),
1439
- createdOn: import_zod28.z.string()
1493
+ var import_zod29 = require("zod");
1494
+ var SongHistoryEntrySchema = import_zod29.z.object({
1495
+ uuid: import_zod29.z.string().uuid(),
1496
+ action: import_zod29.z.string(),
1497
+ actorPseudo: import_zod29.z.string().nullable(),
1498
+ oldValue: import_zod29.z.string().nullable(),
1499
+ newValue: import_zod29.z.string().nullable(),
1500
+ createdOn: import_zod29.z.string()
1440
1501
  });
1441
- var SongHistorySchema = import_zod28.z.array(SongHistoryEntrySchema);
1502
+ var SongHistorySchema = import_zod29.z.array(SongHistoryEntrySchema);
1442
1503
 
1443
1504
  // src/genre-tree/useSongHistory.ts
1444
1505
  function useSongHistory(uuid, getBackendBaseUrl, enabled) {
@@ -1459,23 +1520,23 @@ function useSongHistory(uuid, getBackendBaseUrl, enabled) {
1459
1520
 
1460
1521
  // src/genre-tree/useSongSearch.ts
1461
1522
  var import_react_query7 = require("@tanstack/react-query");
1462
- var import_react7 = require("react");
1523
+ var import_react8 = require("react");
1463
1524
 
1464
1525
  // src/genre-tree/schemas/song-search.ts
1465
- var import_zod29 = require("zod");
1466
- var SongSearchResultSchema = import_zod29.z.object({
1467
- uuid: import_zod29.z.string().uuid(),
1468
- title: import_zod29.z.string(),
1469
- artists: import_zod29.z.array(ArtistMinimumSchema),
1526
+ var import_zod30 = require("zod");
1527
+ var SongSearchResultSchema = import_zod30.z.object({
1528
+ uuid: import_zod30.z.string().uuid(),
1529
+ title: import_zod30.z.string(),
1530
+ artists: import_zod30.z.array(ArtistMinimumSchema),
1470
1531
  // null for songs not yet linked to a genre.
1471
1532
  genre: CriteriaMinimumSchema.nullable(),
1472
- youtubeVideo: import_zod29.z.object({
1473
- id: import_zod29.z.string(),
1474
- unplayableReason: import_zod29.z.string().nullable()
1533
+ youtubeVideo: import_zod30.z.object({
1534
+ id: import_zod30.z.string(),
1535
+ unplayableReason: import_zod30.z.string().nullable()
1475
1536
  }).nullable(),
1476
- firstReleaseYear: import_zod29.z.number().int().nullable()
1537
+ firstReleaseYear: import_zod30.z.number().int().nullable()
1477
1538
  });
1478
- var SongSearchResultsSchema = import_zod29.z.array(SongSearchResultSchema);
1539
+ var SongSearchResultsSchema = import_zod30.z.array(SongSearchResultSchema);
1479
1540
  function isSongSearchResultPlayable(result) {
1480
1541
  return result.youtubeVideo !== null && result.youtubeVideo.unplayableReason === null;
1481
1542
  }
@@ -1485,21 +1546,22 @@ var DEBOUNCE_MS2 = 250;
1485
1546
  var MIN_QUERY_LENGTH2 = 2;
1486
1547
  var RESULT_LIMIT2 = 8;
1487
1548
  function useSongSearch(getBackendBaseUrl, text) {
1549
+ const playback = usePlaybackContext();
1488
1550
  const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
1489
1551
  const trimmed = text.trim();
1490
- const [query, setQuery] = (0, import_react7.useState)("");
1491
- (0, import_react7.useEffect)(() => {
1552
+ const [query, setQuery] = (0, import_react8.useState)("");
1553
+ (0, import_react8.useEffect)(() => {
1492
1554
  const timer = setTimeout(() => setQuery(trimmed), DEBOUNCE_MS2);
1493
1555
  return () => clearTimeout(timer);
1494
1556
  }, [trimmed]);
1495
- const enabled = query.length >= MIN_QUERY_LENGTH2;
1557
+ const enabled = query.length >= MIN_QUERY_LENGTH2 && playback.ready;
1496
1558
  const { data, isFetching, isError } = useQueryWithParse({
1497
- queryKey: libraryQueryKeys.reference.songs.search({ q: query, limit: RESULT_LIMIT2 }),
1559
+ queryKey: [...libraryQueryKeys.reference.songs.search({ q: query, limit: RESULT_LIMIT2 }), ...playback.key ? [playback.key] : []],
1498
1560
  queryFn: ({ signal }) => fetch2(libraryEndpoints.reference.songs.search(), true, false, { signal }, { q: query, limit: RESULT_LIMIT2 }),
1499
1561
  schema: SongSearchResultsSchema,
1500
1562
  context: "useSongSearch",
1501
1563
  enabled,
1502
- placeholderData: import_react_query7.keepPreviousData
1564
+ placeholderData: playback.key === null ? import_react_query7.keepPreviousData : void 0
1503
1565
  });
1504
1566
  const settled = enabled && !isFetching && query === trimmed;
1505
1567
  const failed = enabled && isError;
@@ -1513,16 +1575,16 @@ function useSongSearch(getBackendBaseUrl, text) {
1513
1575
 
1514
1576
  // src/genre-tree/useArtistGenreCounts.ts
1515
1577
  var import_react_query8 = require("@tanstack/react-query");
1516
- var import_zod31 = require("zod");
1578
+ var import_zod32 = require("zod");
1517
1579
 
1518
1580
  // src/genre-tree/schemas/artist-genre-count.ts
1519
- var import_zod30 = require("zod");
1520
- var ArtistGenreCountSchema = import_zod30.z.object({
1581
+ var import_zod31 = require("zod");
1582
+ var ArtistGenreCountSchema = import_zod31.z.object({
1521
1583
  genrePlaylist: GenrePlaylistUuidSchema,
1522
1584
  /** All the artist's songs in the genre playlist's subtree; drives pruning. */
1523
- songsCount: import_zod30.z.number().int().nonnegative(),
1585
+ songsCount: import_zod31.z.number().int().nonnegative(),
1524
1586
  /** The playable ones among them; drives node size and the play button. */
1525
- tracksCount: import_zod30.z.number().int().nonnegative()
1587
+ tracksCount: import_zod31.z.number().int().nonnegative()
1526
1588
  });
1527
1589
 
1528
1590
  // src/genre-tree/useArtistGenreCounts.ts
@@ -1533,7 +1595,7 @@ function useArtistGenreCounts(artistUuid, getBackendBaseUrl) {
1533
1595
  queryKey: artistQueryKeys.genreCounts(getBackendBaseUrl(), artistUuid),
1534
1596
  // A missing artist is shown in the artist panel, not raised as an app-wide connectivity error.
1535
1597
  queryFn: () => fetch2(artistEndpoints.genreCounts(artistUuid), true, false, void 0, void 0, false, true),
1536
- schema: import_zod31.z.array(ArtistGenreCountSchema),
1598
+ schema: import_zod32.z.array(ArtistGenreCountSchema),
1537
1599
  enabled: artistUuid !== null,
1538
1600
  placeholderData: import_react_query8.keepPreviousData,
1539
1601
  retry: (failureCount, error) => !isNotFound3(error) && failureCount < 3,
@@ -1542,7 +1604,7 @@ function useArtistGenreCounts(artistUuid, getBackendBaseUrl) {
1542
1604
  }
1543
1605
 
1544
1606
  // src/genre-tree/useGenreSearch.ts
1545
- var import_react8 = require("react");
1607
+ var import_react9 = require("react");
1546
1608
 
1547
1609
  // src/genre-tree/lib/genre-search.ts
1548
1610
  var searchGenrePlaylistsByName = (genrePlaylists, query) => {
@@ -1560,8 +1622,8 @@ function useGenreSearch({
1560
1622
  selectedName = null,
1561
1623
  onClear
1562
1624
  }) {
1563
- const [query, setQuery] = (0, import_react8.useState)(selectedName ?? "");
1564
- const [prevSelectedName, setPrevSelectedName] = (0, import_react8.useState)(selectedName);
1625
+ const [query, setQuery] = (0, import_react9.useState)(selectedName ?? "");
1626
+ const [prevSelectedName, setPrevSelectedName] = (0, import_react9.useState)(selectedName);
1565
1627
  if (selectedName !== prevSelectedName) {
1566
1628
  setPrevSelectedName(selectedName);
1567
1629
  setQuery(selectedName ?? "");
@@ -1584,10 +1646,10 @@ function useGenreSearch({
1584
1646
  }
1585
1647
 
1586
1648
  // src/genre-tree/useGenreTreeViewState.ts
1587
- var import_react10 = require("react");
1649
+ var import_react11 = require("react");
1588
1650
 
1589
1651
  // src/genre-tree/useVisibleGenrePlaylists.ts
1590
- var import_react9 = require("react");
1652
+ var import_react10 = require("react");
1591
1653
 
1592
1654
  // src/genre-tree/lib/prune-genre-playlists-for-artist.ts
1593
1655
  var POP_ROOT_NAME = "Mainstream Pop";
@@ -1619,7 +1681,7 @@ function useVisibleGenrePlaylists({ scope, getBackendBaseUrl, artistUuid = null
1619
1681
  const counts = useArtistGenreCounts(artistUuid, getBackendBaseUrl);
1620
1682
  const artistCounts = artistUuid !== null ? counts.data : void 0;
1621
1683
  const isCountsLoading = artistUuid !== null && (counts.isPending || counts.isPlaceholderData);
1622
- const genrePlaylists = (0, import_react9.useMemo)(() => {
1684
+ const genrePlaylists = (0, import_react10.useMemo)(() => {
1623
1685
  if (!tree) return [];
1624
1686
  return artistCounts ? pruneGenrePlaylistsForArtist(tree, artistCounts) : tree;
1625
1687
  }, [tree, artistCounts]);
@@ -1647,12 +1709,12 @@ function useGenreTreeViewState({
1647
1709
  onSelectedNodeIdChange,
1648
1710
  criteriaOverviewSchema
1649
1711
  }) {
1650
- const [internalViewMode, setInternalViewMode] = (0, import_react10.useState)("pop-core");
1651
- const [allowWheelRotation, setAllowWheelRotation] = (0, import_react10.useState)(false);
1652
- const [internalSelectedNodeId, setInternalSelectedNodeId] = (0, import_react10.useState)(null);
1712
+ const [internalViewMode, setInternalViewMode] = (0, import_react11.useState)("pop-core");
1713
+ const [allowWheelRotation, setAllowWheelRotation] = (0, import_react11.useState)(false);
1714
+ const [internalSelectedNodeId, setInternalSelectedNodeId] = (0, import_react11.useState)(null);
1653
1715
  const isSelectionControlled = controlledSelectedNodeId !== void 0;
1654
1716
  const requestedSelectedNodeId = isSelectionControlled ? controlledSelectedNodeId : internalSelectedNodeId;
1655
- const setSelectedNodeId = (0, import_react10.useCallback)(
1717
+ const setSelectedNodeId = (0, import_react11.useCallback)(
1656
1718
  (nodeId) => {
1657
1719
  if (!isSelectionControlled) setInternalSelectedNodeId(nodeId);
1658
1720
  onSelectedNodeIdChange?.(nodeId);
@@ -1660,35 +1722,35 @@ function useGenreTreeViewState({
1660
1722
  [isSelectionControlled, onSelectedNodeIdChange]
1661
1723
  );
1662
1724
  const { isLoading, isFetching, genrePlaylists } = useVisibleGenrePlaylists({ scope, getBackendBaseUrl, artistUuid });
1663
- const genrePlaylistByNodeId = (0, import_react10.useMemo)(() => new Map(genrePlaylists.map((gp) => [gp.uuid, gp])), [genrePlaylists]);
1664
- const selectedGenrePlaylist = (0, import_react10.useMemo)(
1725
+ const genrePlaylistByNodeId = (0, import_react11.useMemo)(() => new Map(genrePlaylists.map((gp) => [gp.uuid, gp])), [genrePlaylists]);
1726
+ const selectedGenrePlaylist = (0, import_react11.useMemo)(
1665
1727
  () => genrePlaylists.find((gp) => gp.uuid === requestedSelectedNodeId) ?? // Older shared links stored the criteria UUID in `genre`; resolve that alias while preserving
1666
1728
  // the playlist UUID as the canonical tree selection identity.
1667
1729
  genrePlaylists.find((gp) => gp.criteria?.uuid === requestedSelectedNodeId),
1668
1730
  [genrePlaylists, requestedSelectedNodeId]
1669
1731
  );
1670
1732
  const selectedNodeId = selectedGenrePlaylist?.uuid ?? requestedSelectedNodeId;
1671
- (0, import_react10.useEffect)(() => {
1733
+ (0, import_react11.useEffect)(() => {
1672
1734
  if (!isSelectionControlled || requestedSelectedNodeId == null || selectedGenrePlaylist == null || requestedSelectedNodeId === selectedGenrePlaylist.uuid) {
1673
1735
  return;
1674
1736
  }
1675
1737
  onSelectedNodeIdChange?.(selectedGenrePlaylist.uuid);
1676
1738
  }, [isSelectionControlled, onSelectedNodeIdChange, requestedSelectedNodeId, selectedGenrePlaylist]);
1677
- const selectNode = (0, import_react10.useCallback)((node) => setSelectedNodeId(node?.id ?? null), [setSelectedNodeId]);
1678
- const clearSelection = (0, import_react10.useCallback)(() => setSelectedNodeId(null), [setSelectedNodeId]);
1679
- const selectGenrePlaylist = (0, import_react10.useCallback)(
1739
+ const selectNode = (0, import_react11.useCallback)((node) => setSelectedNodeId(node?.id ?? null), [setSelectedNodeId]);
1740
+ const clearSelection = (0, import_react11.useCallback)(() => setSelectedNodeId(null), [setSelectedNodeId]);
1741
+ const selectGenrePlaylist = (0, import_react11.useCallback)(
1680
1742
  (genrePlaylist) => setSelectedNodeId(genrePlaylist.uuid),
1681
1743
  [setSelectedNodeId]
1682
1744
  );
1683
1745
  const prefetchGenreOverview = usePrefetchGenreOverview(scope, getBackendBaseUrl, criteriaOverviewSchema);
1684
- const hoverPrefetchTimerRef = (0, import_react10.useRef)(null);
1685
- (0, import_react10.useEffect)(
1746
+ const hoverPrefetchTimerRef = (0, import_react11.useRef)(null);
1747
+ (0, import_react11.useEffect)(
1686
1748
  () => () => {
1687
1749
  if (hoverPrefetchTimerRef.current) clearTimeout(hoverPrefetchTimerRef.current);
1688
1750
  },
1689
1751
  []
1690
1752
  );
1691
- const onNodeHover = (0, import_react10.useCallback)(
1753
+ const onNodeHover = (0, import_react11.useCallback)(
1692
1754
  (node) => {
1693
1755
  if (hoverPrefetchTimerRef.current) clearTimeout(hoverPrefetchTimerRef.current);
1694
1756
  const genreUuid = genrePlaylistByNodeId.get(node.id)?.criteria?.uuid;
@@ -1699,8 +1761,8 @@ function useGenreTreeViewState({
1699
1761
  },
1700
1762
  [genrePlaylistByNodeId, prefetchGenreOverview]
1701
1763
  );
1702
- const groupedGenrePlaylistsByRoot = (0, import_react10.useMemo)(() => getGenrePlaylistsGroupedByRoot(genrePlaylists), [genrePlaylists]);
1703
- const canShowPopCore = (0, import_react10.useMemo)(
1764
+ const groupedGenrePlaylistsByRoot = (0, import_react11.useMemo)(() => getGenrePlaylistsGroupedByRoot(genrePlaylists), [genrePlaylists]);
1765
+ const canShowPopCore = (0, import_react11.useMemo)(
1704
1766
  () => hasMainstreamPopRoot(
1705
1767
  genrePlaylists.map((genrePlaylist) => ({
1706
1768
  parentId: genrePlaylist.parent?.uuid ?? null,
@@ -1709,14 +1771,14 @@ function useGenreTreeViewState({
1709
1771
  ),
1710
1772
  [genrePlaylists]
1711
1773
  );
1712
- (0, import_react10.useEffect)(() => {
1774
+ (0, import_react11.useEffect)(() => {
1713
1775
  if (!isLoading && needsPopCore(internalViewMode) && !canShowPopCore) {
1714
1776
  setInternalViewMode("wheel");
1715
1777
  }
1716
1778
  }, [isLoading, canShowPopCore, internalViewMode]);
1717
1779
  const selectedViewMode = controlledViewMode ?? internalViewMode;
1718
1780
  const viewMode = needsPopCore(selectedViewMode) && !canShowPopCore ? "wheel" : selectedViewMode;
1719
- const visibleGenrePlaylists = (0, import_react10.useMemo)(() => {
1781
+ const visibleGenrePlaylists = (0, import_react11.useMemo)(() => {
1720
1782
  if (viewMode === "stacked") return genrePlaylists;
1721
1783
  const unacceptedRootUuids = new Set(genrePlaylists.filter((gp) => gp.isUnacceptedRoot).map((gp) => gp.uuid));
1722
1784
  const accepted = genrePlaylists.filter((gp) => !gp.isUnacceptedRoot && !unacceptedRootUuids.has(gp.root.uuid));
@@ -1745,13 +1807,13 @@ function useGenreTreeViewState({
1745
1807
  }
1746
1808
 
1747
1809
  // src/genre-tree/TrackListContext.tsx
1748
- var import_react13 = require("react");
1810
+ var import_react14 = require("react");
1749
1811
 
1750
1812
  // src/genre-tree/schemas/track-playlist-rel/without-playlist.ts
1751
- var import_zod32 = require("zod");
1752
- var makeTrackPlaylistRelSchema = (trackSchema) => import_zod32.z.object({
1813
+ var import_zod33 = require("zod");
1814
+ var makeTrackPlaylistRelSchema = (trackSchema) => import_zod33.z.object({
1753
1815
  track: trackSchema,
1754
- position: import_zod32.z.number().min(0)
1816
+ position: import_zod33.z.number().min(0)
1755
1817
  });
1756
1818
  var makeTrackPlaylistRelPageSchema = (trackSchema) => PaginatedResponseSchema(makeTrackPlaylistRelSchema(trackSchema));
1757
1819
 
@@ -1855,11 +1917,16 @@ var TrackListOriginFromArtist = class extends TrackListOrigin {
1855
1917
  };
1856
1918
 
1857
1919
  // src/player/PlayerContext.tsx
1858
- var import_react11 = require("react");
1859
- var import_jsx_runtime3 = require("react/jsx-runtime");
1860
- var PlayerContext = (0, import_react11.createContext)(void 0);
1920
+ var import_react12 = require("react");
1921
+
1922
+ // src/player/PlaybackFailures.ts
1923
+ var TTL_MS = 10 * 6e4;
1924
+
1925
+ // src/player/PlayerContext.tsx
1926
+ var import_jsx_runtime4 = require("react/jsx-runtime");
1927
+ var PlayerContext = (0, import_react12.createContext)(void 0);
1861
1928
  function usePlayer() {
1862
- const context = (0, import_react11.useContext)(PlayerContext);
1929
+ const context = (0, import_react12.useContext)(PlayerContext);
1863
1930
  if (context === void 0) {
1864
1931
  throw new Error("usePlayer must be used within a PlayerProvider");
1865
1932
  }
@@ -1867,21 +1934,21 @@ function usePlayer() {
1867
1934
  }
1868
1935
 
1869
1936
  // src/genre-tree/TrackListSidebarVisibilityContext.tsx
1870
- var import_react12 = require("react");
1871
- var import_jsx_runtime4 = require("react/jsx-runtime");
1872
- var TrackListSidebarVisibilityContext = (0, import_react12.createContext)(void 0);
1937
+ var import_react13 = require("react");
1938
+ var import_jsx_runtime5 = require("react/jsx-runtime");
1939
+ var TrackListSidebarVisibilityContext = (0, import_react13.createContext)(void 0);
1873
1940
  function TrackListSidebarVisibilityProvider({ children }) {
1874
- const [isTrackListSidebarVisible, setIsTrackListSidebarVisible] = (0, import_react12.useState)(false);
1875
- const toggleTrackListSidebar = (0, import_react12.useCallback)(() => {
1941
+ const [isTrackListSidebarVisible, setIsTrackListSidebarVisible] = (0, import_react13.useState)(false);
1942
+ const toggleTrackListSidebar = (0, import_react13.useCallback)(() => {
1876
1943
  setIsTrackListSidebarVisible((prev) => !prev);
1877
1944
  }, []);
1878
- const showTrackListSidebar = (0, import_react12.useCallback)(() => {
1945
+ const showTrackListSidebar = (0, import_react13.useCallback)(() => {
1879
1946
  setIsTrackListSidebarVisible(true);
1880
1947
  }, []);
1881
- const hideTrackListSidebar = (0, import_react12.useCallback)(() => {
1948
+ const hideTrackListSidebar = (0, import_react13.useCallback)(() => {
1882
1949
  setIsTrackListSidebarVisible(false);
1883
1950
  }, []);
1884
- const value = (0, import_react12.useMemo)(
1951
+ const value = (0, import_react13.useMemo)(
1885
1952
  () => ({
1886
1953
  isTrackListSidebarVisible,
1887
1954
  toggleTrackListSidebar,
@@ -1890,10 +1957,10 @@ function TrackListSidebarVisibilityProvider({ children }) {
1890
1957
  }),
1891
1958
  [isTrackListSidebarVisible, toggleTrackListSidebar, showTrackListSidebar, hideTrackListSidebar]
1892
1959
  );
1893
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(TrackListSidebarVisibilityContext.Provider, { value, children });
1960
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(TrackListSidebarVisibilityContext.Provider, { value, children });
1894
1961
  }
1895
1962
  function useTrackListSidebarVisibility() {
1896
- const context = (0, import_react12.useContext)(TrackListSidebarVisibilityContext);
1963
+ const context = (0, import_react13.useContext)(TrackListSidebarVisibilityContext);
1897
1964
  if (context === void 0) {
1898
1965
  throw new Error("useTrackListSidebarVisibility must be used within a TrackListSidebarVisibilityProvider");
1899
1966
  }
@@ -1901,56 +1968,67 @@ function useTrackListSidebarVisibility() {
1901
1968
  }
1902
1969
 
1903
1970
  // src/genre-tree/TrackListContext.tsx
1904
- var import_jsx_runtime5 = require("react/jsx-runtime");
1971
+ var import_jsx_runtime6 = require("react/jsx-runtime");
1905
1972
  var TRACKS_PAGE_SIZE = 100;
1906
1973
  var AUTO_LOAD_REMAINING_TRACKS = 10;
1907
1974
  var AUTO_SKIP_DELAY_MS = 1e3;
1908
- function isTrackPlayable(track, runtimeUnplayableTrackIds) {
1909
- return !runtimeUnplayableTrackIds.has(track.uuid) && (!isSong(track) || songUnplayableReason(track) === null);
1975
+ function isTrackPlayable(track, runtimeUnplayableTrackIds, hasPlaybackFailure) {
1976
+ return !runtimeUnplayableTrackIds.has(track.uuid) && (!isSong(track) || songUnplayableReason(track) === null && (!track.youtubeVideo || !hasPlaybackFailure(track.youtubeVideo.id)));
1910
1977
  }
1911
1978
  function useListTracks(scope, getBackendBaseUrl, schema, listEndpoint, listQueryKey, page = 1, pageSize = 50) {
1979
+ const playback = usePlaybackContext();
1912
1980
  const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
1913
1981
  const { session, sessionRestored } = useSession();
1914
1982
  return useQueryWithParse({
1915
- queryKey: listQueryKey(page),
1983
+ queryKey: [...listQueryKey(page), ...playback.key ? [playback.key] : []],
1916
1984
  queryFn: async () => {
1917
1985
  if (scope == null) return null;
1918
1986
  return fetch2(listEndpoint(page), true, scope === "me", {}, { page, pageSize });
1919
1987
  },
1920
1988
  schema: PaginatedResponseSchema(schema),
1921
1989
  context: "useListTracks",
1922
- enabled: scope != null && (scope === "reference" || sessionRestored && !!session?.accessToken)
1990
+ enabled: playback.ready && scope != null && (scope === "reference" || sessionRestored && !!session?.accessToken)
1923
1991
  });
1924
1992
  }
1925
- var TrackListContext = (0, import_react13.createContext)(void 0);
1993
+ var TrackListContext = (0, import_react14.createContext)(void 0);
1926
1994
  function TrackListProvider({
1927
1995
  children,
1928
1996
  getBackendBaseUrl,
1929
1997
  schema
1930
1998
  }) {
1931
- const [trackList, setTrackList] = (0, import_react13.useState)(null);
1932
- const [selectedTrack, setSelectedTrack] = (0, import_react13.useState)(null);
1933
- const [autoAdvanceScrollRequest, setAutoAdvanceScrollRequest] = (0, import_react13.useState)(null);
1934
- const [runtimeUnplayableTrackIds, setRuntimeUnplayableTrackIds] = (0, import_react13.useState)(() => /* @__PURE__ */ new Set());
1935
- const { loadTrackForPlayer, setOnTrackEnd } = usePlayer();
1999
+ const [trackList, setTrackList] = (0, import_react14.useState)(null);
2000
+ const [selectedTrack, setSelectedTrack] = (0, import_react14.useState)(null);
2001
+ const [autoAdvanceScrollRequest, setAutoAdvanceScrollRequest] = (0, import_react14.useState)(null);
2002
+ const { loadTrackForPlayer, setOnTrackEnd, hasPlaybackFailure, playerTrackObject } = usePlayer();
2003
+ const [failureClock, setFailureClock] = (0, import_react14.useState)(0);
2004
+ (0, import_react14.useEffect)(() => {
2005
+ const timer = setInterval(() => setFailureClock((tick) => tick + 1), 3e4);
2006
+ return () => clearInterval(timer);
2007
+ }, []);
2008
+ const runtimeUnplayableTrackIds = (0, import_react14.useMemo)(() => new Set(
2009
+ (trackList?.tracks ?? []).filter((track) => isSong(track) && track.youtubeVideo && hasPlaybackFailure(track.youtubeVideo.id)).map((track) => track.uuid)
2010
+ ), [trackList, hasPlaybackFailure, playerTrackObject, failureClock]);
1936
2011
  const { showTrackListSidebar } = useTrackListSidebarVisibility();
2012
+ const playback = usePlaybackContext();
1937
2013
  const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
1938
- const pageSchema = (0, import_react13.useMemo)(() => makeTrackPlaylistRelPageSchema(schema), [schema]);
1939
- const latestPlayRequestRef = (0, import_react13.useRef)(0);
1940
- const autoAdvanceScrollRequestIdRef = (0, import_react13.useRef)(0);
1941
- const delayedTrackLoadRef = (0, import_react13.useRef)(null);
1942
- const loadingOriginRef = (0, import_react13.useRef)(null);
1943
- const pendingAdvanceRef = (0, import_react13.useRef)(null);
1944
- const clearDelayedTrackLoad = (0, import_react13.useCallback)(() => {
2014
+ const pageSchema = (0, import_react14.useMemo)(() => makeTrackPlaylistRelPageSchema(schema), [schema]);
2015
+ const latestPlayRequestRef = (0, import_react14.useRef)(0);
2016
+ const startingPlaybackRef = (0, import_react14.useRef)(false);
2017
+ const loadedContextRef = (0, import_react14.useRef)(playback.key);
2018
+ const autoAdvanceScrollRequestIdRef = (0, import_react14.useRef)(0);
2019
+ const delayedTrackLoadRef = (0, import_react14.useRef)(null);
2020
+ const loadingOriginRef = (0, import_react14.useRef)(null);
2021
+ const pendingAdvanceRef = (0, import_react14.useRef)(null);
2022
+ const clearDelayedTrackLoad = (0, import_react14.useCallback)(() => {
1945
2023
  if (delayedTrackLoadRef.current !== null) {
1946
2024
  clearTimeout(delayedTrackLoadRef.current);
1947
2025
  delayedTrackLoadRef.current = null;
1948
2026
  }
1949
2027
  }, []);
1950
- const requestAutoAdvanceScroll = (0, import_react13.useCallback)((trackUuid) => {
2028
+ const requestAutoAdvanceScroll = (0, import_react14.useCallback)((trackUuid) => {
1951
2029
  setAutoAdvanceScrollRequest({ id: ++autoAdvanceScrollRequestIdRef.current, trackUuid });
1952
2030
  }, []);
1953
- const loadTrackAfterSkipDelay = (0, import_react13.useCallback)(
2031
+ const loadTrackAfterSkipDelay = (0, import_react14.useCallback)(
1954
2032
  (trackUuid) => {
1955
2033
  clearDelayedTrackLoad();
1956
2034
  delayedTrackLoadRef.current = setTimeout(() => {
@@ -1960,11 +2038,11 @@ function TrackListProvider({
1960
2038
  },
1961
2039
  [clearDelayedTrackLoad, loadTrackForPlayer]
1962
2040
  );
1963
- const fetchTracksPage = (0, import_react13.useCallback)(
2041
+ const fetchTracksPage = (0, import_react14.useCallback)(
1964
2042
  async (uuid, scope, page, from) => {
1965
2043
  const endpoint = genrePlaylistEndpoints[scope].tracks(uuid);
1966
2044
  const params = { page, pageSize: TRACKS_PAGE_SIZE, ...from && { from } };
1967
- const response = await fetch2(endpoint, true, scope === "me", {}, params);
2045
+ const response = await fetch2(endpoint, true, scope === "me", {}, params, false, !!from, page === 1);
1968
2046
  const parsed = parseWithLog(pageSchema, response, "fetchGenrePlaylistTracksPage");
1969
2047
  return {
1970
2048
  tracks: parsed.results.map((rel) => rel.track),
@@ -1974,8 +2052,8 @@ function TrackListProvider({
1974
2052
  },
1975
2053
  [fetch2, pageSchema]
1976
2054
  );
1977
- const artistPageSchema = (0, import_react13.useMemo)(() => PaginatedResponseSchema(schema), [schema]);
1978
- const fetchArtistTracksPage = (0, import_react13.useCallback)(
2055
+ const artistPageSchema = (0, import_react14.useMemo)(() => PaginatedResponseSchema(schema), [schema]);
2056
+ const fetchArtistTracksPage = (0, import_react14.useCallback)(
1979
2057
  async (origin, page) => {
1980
2058
  const params = {
1981
2059
  artist: origin.uuid,
@@ -1994,26 +2072,26 @@ function TrackListProvider({
1994
2072
  params,
1995
2073
  false,
1996
2074
  // A start song that isn't playable 404s; surface it as a rejection, not the global error.
1997
- page === 1 && !!origin.from
2075
+ page === 1 && !!origin.from,
2076
+ page === 1
1998
2077
  );
1999
2078
  const parsed = parseWithLog(artistPageSchema, response, "fetchArtistTracksPage");
2000
2079
  return { tracks: parsed.results, total: parsed.overallTotal, nextPage: parsed.next ? parsed.page + 1 : null };
2001
2080
  },
2002
2081
  [fetch2, artistPageSchema]
2003
2082
  );
2004
- const advanceAfterTrackEnd = (0, import_react13.useCallback)(
2083
+ const advanceAfterTrackEnd = (0, import_react14.useCallback)(
2005
2084
  (event) => {
2006
2085
  const completedTrackId = event?.trackId ?? selectedTrack?.uuid;
2007
2086
  if (!completedTrackId || !trackList) return;
2008
2087
  if (selectedTrack && selectedTrack.uuid !== completedTrackId) return;
2009
- const isEmbeddingBlocked = event?.error?.code === 101 || event?.error?.code === 150;
2088
+ const isEmbeddingBlocked = event?.error?.code === 100 || event?.error?.code === 101 || event?.error?.code === 150;
2010
2089
  if (event?.error) {
2011
- setRuntimeUnplayableTrackIds((previous) => new Set(previous).add(completedTrackId));
2012
2090
  if (!isEmbeddingBlocked) return;
2013
2091
  }
2014
2092
  const currentIndex = trackList.tracks.findIndex((track) => track.uuid === completedTrackId);
2015
2093
  if (currentIndex === -1) return;
2016
- const nextTrack2 = trackList.tracks.slice(currentIndex + 1).find((track) => isTrackPlayable(track, runtimeUnplayableTrackIds));
2094
+ const nextTrack2 = trackList.tracks.slice(currentIndex + 1).find((track) => isTrackPlayable(track, runtimeUnplayableTrackIds, hasPlaybackFailure));
2017
2095
  if (!nextTrack2) {
2018
2096
  pendingAdvanceRef.current = trackList.nextPage === null ? null : { trackId: completedTrackId, origin: trackList.origin, delayLoad: isEmbeddingBlocked };
2019
2097
  return;
@@ -2030,14 +2108,15 @@ function TrackListProvider({
2030
2108
  loadTrackForPlayer,
2031
2109
  requestAutoAdvanceScroll,
2032
2110
  runtimeUnplayableTrackIds,
2111
+ hasPlaybackFailure,
2033
2112
  selectedTrack
2034
2113
  ]
2035
2114
  );
2036
- (0, import_react13.useEffect)(() => {
2115
+ (0, import_react14.useEffect)(() => {
2037
2116
  setOnTrackEnd(trackList && selectedTrack ? advanceAfterTrackEnd : null);
2038
2117
  return () => setOnTrackEnd(null);
2039
2118
  }, [advanceAfterTrackEnd, trackList, selectedTrack, setOnTrackEnd]);
2040
- const toTrackAtPosition = (0, import_react13.useCallback)(
2119
+ const toTrackAtPosition = (0, import_react14.useCallback)(
2041
2120
  (position) => {
2042
2121
  if (trackList && position >= 0 && position < trackList.tracks.length) {
2043
2122
  clearDelayedTrackLoad();
@@ -2047,9 +2126,11 @@ function TrackListProvider({
2047
2126
  },
2048
2127
  [clearDelayedTrackLoad, trackList]
2049
2128
  );
2050
- const playNewTrackListFromTrackUuid = (0, import_react13.useCallback)(
2129
+ const playNewTrackListFromTrackUuid = (0, import_react14.useCallback)(
2051
2130
  (track, scope) => {
2052
2131
  latestPlayRequestRef.current++;
2132
+ startingPlaybackRef.current = false;
2133
+ loadedContextRef.current = playback.snapshot().key;
2053
2134
  clearDelayedTrackLoad();
2054
2135
  setAutoAdvanceScrollRequest(null);
2055
2136
  const origin = new TrackListOriginFromTrack(track, scope);
@@ -2061,19 +2142,23 @@ function TrackListProvider({
2061
2142
  },
2062
2143
  [clearDelayedTrackLoad, showTrackListSidebar, loadTrackForPlayer]
2063
2144
  );
2064
- const playNewTrackListFromGenrePlaylist = (0, import_react13.useCallback)(
2145
+ const playNewTrackListFromGenrePlaylist = (0, import_react14.useCallback)(
2065
2146
  async (genrePlaylist, scope, options) => {
2066
2147
  clearDelayedTrackLoad();
2067
2148
  const request = ++latestPlayRequestRef.current;
2149
+ startingPlaybackRef.current = true;
2068
2150
  const from = options?.startSongUuid;
2069
2151
  let page;
2070
2152
  try {
2071
2153
  page = await fetchTracksPage(genrePlaylist.uuid, scope, 1, from);
2072
2154
  } catch (error) {
2073
2155
  if (request !== latestPlayRequestRef.current) return;
2156
+ startingPlaybackRef.current = false;
2074
2157
  throw error;
2075
2158
  }
2076
2159
  if (request !== latestPlayRequestRef.current) return;
2160
+ startingPlaybackRef.current = false;
2161
+ loadedContextRef.current = playback.snapshot().key;
2077
2162
  const startTrack = page.tracks[0];
2078
2163
  if (from && startTrack?.uuid !== from) {
2079
2164
  throw new Error(`Genre playlist ${genrePlaylist.uuid} did not start at track ${from}`);
@@ -2091,11 +2176,12 @@ function TrackListProvider({
2091
2176
  },
2092
2177
  [clearDelayedTrackLoad, fetchTracksPage, showTrackListSidebar, loadTrackForPlayer]
2093
2178
  );
2094
- const playNewTrackListFromArtist = (0, import_react13.useCallback)(
2179
+ const playNewTrackListFromArtist = (0, import_react14.useCallback)(
2095
2180
  async (artist, scope, options) => {
2096
2181
  if (scope !== "reference") throw new Error("Artist track lists only support the reference scope");
2097
2182
  clearDelayedTrackLoad();
2098
2183
  const request = ++latestPlayRequestRef.current;
2184
+ startingPlaybackRef.current = true;
2099
2185
  const from = options.startSongUuid;
2100
2186
  const origin = new TrackListOriginFromArtist(artist, scope, options.ordering, from, options.genreUuid);
2101
2187
  let page;
@@ -2103,9 +2189,12 @@ function TrackListProvider({
2103
2189
  page = await fetchArtistTracksPage(origin, 1);
2104
2190
  } catch (error) {
2105
2191
  if (request !== latestPlayRequestRef.current) return;
2192
+ startingPlaybackRef.current = false;
2106
2193
  throw error;
2107
2194
  }
2108
2195
  if (request !== latestPlayRequestRef.current) return;
2196
+ startingPlaybackRef.current = false;
2197
+ loadedContextRef.current = playback.snapshot().key;
2109
2198
  const startTrack = page.tracks[0];
2110
2199
  if (from && startTrack?.uuid !== from) {
2111
2200
  throw new Error(`Artist ${artist.uuid} did not start at song ${from}`);
@@ -2122,7 +2211,52 @@ function TrackListProvider({
2122
2211
  },
2123
2212
  [clearDelayedTrackLoad, fetchArtistTracksPage, showTrackListSidebar, loadTrackForPlayer]
2124
2213
  );
2125
- const updateTrack = (0, import_react13.useCallback)((track) => {
2214
+ const contextKeyRef = (0, import_react14.useRef)(playback.key);
2215
+ (0, import_react14.useEffect)(() => {
2216
+ if (contextKeyRef.current === playback.key) return;
2217
+ contextKeyRef.current = playback.key;
2218
+ if (loadedContextRef.current === playback.key) return;
2219
+ if (startingPlaybackRef.current) {
2220
+ pendingAdvanceRef.current = null;
2221
+ clearDelayedTrackLoad();
2222
+ setTrackList(null);
2223
+ setSelectedTrack(null);
2224
+ return;
2225
+ }
2226
+ const origin = trackList?.origin;
2227
+ const selected = selectedTrack;
2228
+ latestPlayRequestRef.current++;
2229
+ pendingAdvanceRef.current = null;
2230
+ clearDelayedTrackLoad();
2231
+ setTrackList(null);
2232
+ setSelectedTrack(null);
2233
+ if (origin instanceof TrackListOriginFromCriteriaPlaylist) {
2234
+ void playNewTrackListFromGenrePlaylist(origin.criteriaPlaylist, origin.scope, { startSongUuid: selected?.uuid }).catch((error) => {
2235
+ if (error instanceof BackendError && error.code === "BAC4040" /* BACKEND_NOT_FOUND */) {
2236
+ return playNewTrackListFromGenrePlaylist(origin.criteriaPlaylist, origin.scope).catch(() => {
2237
+ });
2238
+ }
2239
+ });
2240
+ } else if (origin instanceof TrackListOriginFromArtist) {
2241
+ const options = { ordering: origin.ordering, genreUuid: origin.genreUuid };
2242
+ void playNewTrackListFromArtist(origin.artist, origin.scope, { ...options, startSongUuid: selected?.uuid }).catch((error) => {
2243
+ if (error instanceof BackendError && error.code === "BAC4040" /* BACKEND_NOT_FOUND */) {
2244
+ return playNewTrackListFromArtist(origin.artist, origin.scope, options).catch(() => {
2245
+ });
2246
+ }
2247
+ });
2248
+ } else if (origin instanceof TrackListOriginFromTrack && selected) {
2249
+ const request = latestPlayRequestRef.current;
2250
+ void (async () => {
2251
+ const track = isSong(selected) && origin.scope === "reference" ? parseWithLog(schema, await fetch2(libraryEndpoints.reference.songs.detail(selected.uuid), true, false), "refreshSelectedTrack") : selected;
2252
+ if (request !== latestPlayRequestRef.current) return;
2253
+ setTrackList(new TrackListFromTrack([track], new TrackListOriginFromTrack(track, origin.scope)));
2254
+ setSelectedTrack(track);
2255
+ })().catch(() => {
2256
+ });
2257
+ }
2258
+ }, [playback.key, trackList, selectedTrack, clearDelayedTrackLoad, playNewTrackListFromGenrePlaylist, playNewTrackListFromArtist, schema, fetch2]);
2259
+ const updateTrack = (0, import_react14.useCallback)((track) => {
2126
2260
  setTrackList((prev) => {
2127
2261
  if (!prev || !prev.tracks.some((listed) => listed.uuid === track.uuid)) return prev;
2128
2262
  const tracks = prev.tracks.map((listed) => listed.uuid === track.uuid ? track : listed);
@@ -2130,7 +2264,7 @@ function TrackListProvider({
2130
2264
  });
2131
2265
  setSelectedTrack((prev) => prev?.uuid === track.uuid ? track : prev);
2132
2266
  }, []);
2133
- const loadMore = (0, import_react13.useCallback)(async () => {
2267
+ const loadMore = (0, import_react14.useCallback)(async () => {
2134
2268
  if (!trackList || trackList.nextPage === null) return;
2135
2269
  const origin = trackList.origin;
2136
2270
  if (!(origin instanceof TrackListOriginFromCriteriaPlaylist || origin instanceof TrackListOriginFromArtist)) return;
@@ -2150,11 +2284,11 @@ function TrackListProvider({
2150
2284
  }
2151
2285
  }, [trackList, fetchTracksPage, fetchArtistTracksPage]);
2152
2286
  const selectedTrackIndex = trackList?.tracks.findIndex((track) => track.uuid === selectedTrack?.uuid) ?? -1;
2153
- const nextTrack = trackList && selectedTrackIndex >= 0 ? trackList.tracks.slice(selectedTrackIndex + 1).find((track) => isTrackPlayable(track, runtimeUnplayableTrackIds)) ?? null : null;
2154
- const previousTrack = trackList && selectedTrackIndex > 0 ? trackList.tracks.slice(0, selectedTrackIndex).reverse().find((track) => isTrackPlayable(track, runtimeUnplayableTrackIds)) ?? null : null;
2287
+ const nextTrack = trackList && selectedTrackIndex >= 0 ? trackList.tracks.slice(selectedTrackIndex + 1).find((track) => isTrackPlayable(track, runtimeUnplayableTrackIds, hasPlaybackFailure)) ?? null : null;
2288
+ const previousTrack = trackList && selectedTrackIndex > 0 ? trackList.tracks.slice(0, selectedTrackIndex).reverse().find((track) => isTrackPlayable(track, runtimeUnplayableTrackIds, hasPlaybackFailure)) ?? null : null;
2155
2289
  const hasNextTrack = nextTrack !== null || selectedTrackIndex >= 0 && trackList?.nextPage != null;
2156
2290
  const hasPreviousTrack = previousTrack !== null;
2157
- const playNextTrack = (0, import_react13.useCallback)(() => {
2291
+ const playNextTrack = (0, import_react14.useCallback)(() => {
2158
2292
  if (!trackList || !selectedTrack || selectedTrackIndex < 0) return;
2159
2293
  clearDelayedTrackLoad();
2160
2294
  if (nextTrack) {
@@ -2171,7 +2305,7 @@ function TrackListProvider({
2171
2305
  console.error("Failed to load more tracks:", error);
2172
2306
  });
2173
2307
  }, [clearDelayedTrackLoad, trackList, loadMore, loadTrackForPlayer, nextTrack, selectedTrack, selectedTrackIndex]);
2174
- const playPreviousTrack = (0, import_react13.useCallback)(() => {
2308
+ const playPreviousTrack = (0, import_react14.useCallback)(() => {
2175
2309
  if (!previousTrack) return;
2176
2310
  clearDelayedTrackLoad();
2177
2311
  pendingAdvanceRef.current = null;
@@ -2179,7 +2313,7 @@ function TrackListProvider({
2179
2313
  setSelectedTrack(previousTrack);
2180
2314
  loadTrackForPlayer(previousTrack.uuid);
2181
2315
  }, [clearDelayedTrackLoad, loadTrackForPlayer, previousTrack, requestAutoAdvanceScroll]);
2182
- (0, import_react13.useEffect)(() => {
2316
+ (0, import_react14.useEffect)(() => {
2183
2317
  const pending = pendingAdvanceRef.current;
2184
2318
  if (!pending) return;
2185
2319
  if (!trackList || trackList.origin !== pending.origin || selectedTrack?.uuid !== pending.trackId) {
@@ -2191,7 +2325,7 @@ function TrackListProvider({
2191
2325
  pendingAdvanceRef.current = null;
2192
2326
  return;
2193
2327
  }
2194
- const nextTrack2 = trackList.tracks.slice(currentIndex + 1).find((track) => isTrackPlayable(track, runtimeUnplayableTrackIds));
2328
+ const nextTrack2 = trackList.tracks.slice(currentIndex + 1).find((track) => isTrackPlayable(track, runtimeUnplayableTrackIds, hasPlaybackFailure));
2195
2329
  if (nextTrack2) {
2196
2330
  pendingAdvanceRef.current = null;
2197
2331
  requestAutoAdvanceScroll(nextTrack2.uuid);
@@ -2210,17 +2344,18 @@ function TrackListProvider({
2210
2344
  loadTrackForPlayer,
2211
2345
  requestAutoAdvanceScroll,
2212
2346
  runtimeUnplayableTrackIds,
2347
+ hasPlaybackFailure,
2213
2348
  selectedTrack
2214
2349
  ]);
2215
- (0, import_react13.useEffect)(() => clearDelayedTrackLoad, [clearDelayedTrackLoad]);
2216
- (0, import_react13.useEffect)(() => {
2350
+ (0, import_react14.useEffect)(() => clearDelayedTrackLoad, [clearDelayedTrackLoad]);
2351
+ (0, import_react14.useEffect)(() => {
2217
2352
  if (!trackList || trackList.nextPage === null || !selectedTrack) return;
2218
2353
  const index = trackList.tracks.findIndex((track) => track.uuid === selectedTrack.uuid);
2219
2354
  if (index !== -1 && trackList.tracks.length - index <= AUTO_LOAD_REMAINING_TRACKS) {
2220
2355
  loadMore().catch((error) => console.error("Failed to load more tracks:", error));
2221
2356
  }
2222
2357
  }, [trackList, selectedTrack, loadMore]);
2223
- const value = (0, import_react13.useMemo)(
2358
+ const value = (0, import_react14.useMemo)(
2224
2359
  () => ({
2225
2360
  trackList,
2226
2361
  selectedTrack,
@@ -2257,10 +2392,10 @@ function TrackListProvider({
2257
2392
  updateTrack
2258
2393
  ]
2259
2394
  );
2260
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(TrackListContext.Provider, { value, children });
2395
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(TrackListContext.Provider, { value, children });
2261
2396
  }
2262
2397
  function useTrackList() {
2263
- const context = (0, import_react13.useContext)(TrackListContext);
2398
+ const context = (0, import_react14.useContext)(TrackListContext);
2264
2399
  if (!context) {
2265
2400
  throw new Error("useTrackList must be used within a TrackListProvider");
2266
2401
  }
@@ -2268,38 +2403,38 @@ function useTrackList() {
2268
2403
  }
2269
2404
 
2270
2405
  // src/genre-tree/ArtistNames.tsx
2271
- var import_react14 = require("react");
2272
- var import_jsx_runtime6 = require("react/jsx-runtime");
2406
+ var import_react15 = require("react");
2407
+ var import_jsx_runtime7 = require("react/jsx-runtime");
2273
2408
  function ArtistNames({
2274
2409
  artists,
2275
2410
  renderArtistLink
2276
2411
  }) {
2277
- if (!renderArtistLink) return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, { children: artists.map((artist) => artist.name).join(", ") });
2278
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, { children: artists.map((artist, index) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_react14.Fragment, { children: [
2412
+ if (!renderArtistLink) return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx_runtime7.Fragment, { children: artists.map((artist) => artist.name).join(", ") });
2413
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx_runtime7.Fragment, { children: artists.map((artist, index) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_react15.Fragment, { children: [
2279
2414
  index > 0 && ", ",
2280
2415
  renderArtistLink(artist)
2281
2416
  ] }, artist.uuid)) });
2282
2417
  }
2283
2418
 
2284
2419
  // src/genre-tree/schemas/mb-artist.ts
2285
- var import_zod33 = require("zod");
2286
- var MbArtistDetailedSchema = import_zod33.z.object({
2287
- musicbrainzId: import_zod33.z.string().uuid(),
2288
- name: import_zod33.z.string(),
2420
+ var import_zod34 = require("zod");
2421
+ var MbArtistDetailedSchema = import_zod34.z.object({
2422
+ musicbrainzId: import_zod34.z.string().uuid(),
2423
+ name: import_zod34.z.string(),
2289
2424
  musicbrainzLink: HttpUrlSchema
2290
2425
  });
2291
2426
 
2292
2427
  // src/genre-tree/schemas/mb-recording.ts
2293
- var import_zod34 = require("zod");
2294
- var MbRecordingDetailedSchema = import_zod34.z.object({
2295
- musicbrainzId: import_zod34.z.string().uuid(),
2296
- title: import_zod34.z.string(),
2297
- score: import_zod34.z.number(),
2298
- musicbrainzArtists: import_zod34.z.array(MbArtistDetailedSchema),
2428
+ var import_zod35 = require("zod");
2429
+ var MbRecordingDetailedSchema = import_zod35.z.object({
2430
+ musicbrainzId: import_zod35.z.string().uuid(),
2431
+ title: import_zod35.z.string(),
2432
+ score: import_zod35.z.number(),
2433
+ musicbrainzArtists: import_zod35.z.array(MbArtistDetailedSchema),
2299
2434
  musicbrainzLink: HttpUrlSchema,
2300
- durationInSec: import_zod34.z.number().min(0).nullable().optional(),
2301
- durationStrInHourMinSec: import_zod34.z.string().nullable().optional(),
2302
- releaseDate: import_zod34.z.union([import_zod34.z.string().datetime(), import_zod34.z.string()]).transform((val) => {
2435
+ durationInSec: import_zod35.z.number().min(0).nullable().optional(),
2436
+ durationStrInHourMinSec: import_zod35.z.string().nullable().optional(),
2437
+ releaseDate: import_zod35.z.union([import_zod35.z.string().datetime(), import_zod35.z.string()]).transform((val) => {
2303
2438
  try {
2304
2439
  const date = new Date(val);
2305
2440
  if (isNaN(date.getTime())) {
@@ -2411,6 +2546,7 @@ function editGenreSongPages(data, edit) {
2411
2546
  TrackMinimumSchema,
2412
2547
  UuidResourceSchema,
2413
2548
  YOUTUBE_UNPLAYABLE_REASON_LABELS,
2549
+ YoutubeAvailabilitySchema,
2414
2550
  artistEndpoints,
2415
2551
  artistQueryKeys,
2416
2552
  capitalizeFirstLetter,