import { jsxs, jsx } from "react/jsx-runtime";
import { useSearchParams, Link, useParams, useLocation, Outlet, useRoutes } from "react-router-dom";
import { m as message, ah as MenuTrigger, I as IconButton, B as Button, T as Trans, ai as Menu, h as Item, b2 as useCookie, ae as SiteConfigContext, c as createSvgIcon, i as useTrans, t as toast, b3 as FacebookIcon, b4 as TwitterIcon, aF as FormattedRelativeTime, b5 as LockIcon, o as opacityAnimation, R as FormattedDate, K as KeyboardArrowLeftIcon, ad as LinkStyle, w as IllustratedMessage, x as SvgImage, af as getBootstrapData, b as apiClient, aa as useNavigate, aO as ComboBoxForwardRef, k as SearchIcon, N as Navbar, V as Tooltip, aW as lazyLoader, u as useSettings, b6 as useAuth, b1 as Footer, aP as PageMetaTags, aD as PageStatus, e as useIsMobileMediaQuery, D as DialogTrigger, X as ButtonBase, b7 as useImageSrc, J as Form, L as FormTextField, n as showHttpErrorToast, r as ConfirmationDialog, a2 as Skeleton, d as useLocalStorage, Q as Chip, q as queryClient, M as CheckIcon, b8 as FormattedCurrency, j as TextField, b9 as useDarkThemeVariables, aN as PageErrorMessage, p as useDialogContext, l as StaticPageTitle, O as CloseIcon, G as onFormQueryError, _ as useValueLists, y as Dialog, z as DialogHeader, A as DialogBody, a7 as FileUploadProvider, Z as FormImageSelector, a4 as FormSelect, F as DialogFooter, az as isAbsoluteUrl, aX as AuthRoute, b0 as NotFoundPage } from "../server-entry.mjs";
import { b9 as useChannelQueryParams, aN as useInfiniteData, ba as channelQueryKey, bb as channelEndpoint, X as channelContentConfig, bc as Sort, aM as SortIcon, K as KeyboardArrowRightIcon, bd as GridViewIcon, ab as UserAvatar, be as BaseMediaLink, bf as getBaseMediaLink, u as useBackendFilterUrlParams, av as useTitleIndexFilters, A as AddFilterButton, w as TuneIcon, c as FilterListSkeleton, e as FilterList, _ as TITLE_MODEL, $ as MOVIE_MODEL, a0 as SERIES_MODEL, a$ as FormattedDateTimeRange, a8 as NewsArticleImage, a9 as NewsArticleLink, ae as BulletSeparatedItems, ai as TitlePoster, at as TitleLink, ad as TitleRating, aK as TitleBackdrop, bg as NEWS_ARTICLE_MODEL, aX as PERSON_MODEL, aT as PersonPoster, aV as PersonLink, aF as InfiniteScrollSentinel, bh as useChannelContent, bi as PaginationControls, R as ChevronLeftIcon, aO as MediaPlayIcon, aj as getWatchLink, aW as KnownForCompact, bj as FormattedDuration, bk as InteractableRating, bl as CHANNEL_MODEL, a_ as todoImage, bm as getPersonLink, az as getTitleLink, aA as useScrollToTop, W as useChannel, O as ImageZoomDialog, bn as ArrowForwardIcon, aH as useTitleSeasons, aI as SeasonPoster, aJ as SeasonLink, bo as useCreateReview, Q as Avatar, af as StarSelector, bp as useAuthClickCapture, ac as useDeleteReviews, M as MoreVertIcon, bq as useReviews, ah as ReviewListSortButton, br as getEpisodeLink, bs as VideoGrid, aD as useSeasonEpisodes, ak as CompactSeasonEpisode, b3 as EpisodePoster, o as ChipList, g as AddIcon, aw as useTitle, aB as useSeason, aE as EpisodeListItem, bt as getSeasonLink, aS as useEpisode, al as FormattedNumber, aa as useDeleteComments, b5 as EpisodeLink, bu as VideoGridItemSkeleton, bv as VideoGridItem, bw as EpisodeSelector, bx as MediaEpisodesIcon, ar as SiteVideoPlayer, aq as VideoPlayerSkeleton, aP as VideoThumbnail, q as Accordion, r as AccordionItem, aY as usePerson, aZ as useNewsArticle, H as Tabs, I as TabList, J as Tab, b6 as TitleLinkWithEpisodeNumber, by as StarIcon, b4 as UserProfileLink, b7 as CreateUserListPage, b8 as EditUserListPage } from "./user-profile-link-0bca566c.mjs";
import { useContext, useMemo, Fragment, memo, useRef, useState, useCallback, useEffect, useId, forwardRef, useImperativeHandle, Children } from "react";
import clsx from "clsx";
import { AnimatePresence, m } from "framer-motion";
import { L as LockOpenIcon, S as ShareIcon, E as ExpandMoreIcon, T as ThumbUpIcon, a as ThumbDownIcon, R as ReplyIcon, C as CommentIcon, F as FlagIcon, b as ListAltIcon, c as RateReviewIcon, B as BookmarkBorderIcon } from "./BookmarkBorder-2c120ae6.mjs";
import useClipboard from "react-use-clipboard";
import debounce from "just-debounce-it";
import { useLayoutEffect, getScrollParent, useObjectRef } from "@react-aria/utils";
import { C as ChevronRightIcon, O as OpenInNewIcon, E as EditIcon, B as Breadcrumb, a as BreadcrumbItem } from "./OpenInNew-3b47a656.mjs";
import { useQuery, keepPreviousData, useMutation, useQueryClient } from "@tanstack/react-query";
import dot from "dot-object";
import linkifyStr from "linkify-string";
import { useForm, useFieldArray } from "react-hook-form";
import memoize from "nano-memoize";
import "react-dom/server";
import "process";
import "http";
import "axios";
import "react-router-dom/server.mjs";
import "slugify";
import "deepmerge";
import "@internationalized/date";
import "zustand";
import "zustand/middleware/immer";
import "nanoid";
import "@react-aria/focus";
import "@floating-ui/react-dom";
import "react-merge-refs";
import "react-dom";
import "@internationalized/number";
import "@react-stately/utils";
import "@react-aria/ssr";
import "immer";
import "axios-retry";
import "tus-js-client";
import "react-use-cookie";
import "mime-match";
import "fscreen";
import "zustand/middleware";
import "zustand/traditional";
import "@react-aria/interactions";
function useInfiniteChannelContent(channel) {
const queryParams = useChannelQueryParams(channel);
return useInfiniteData({
willSortOrFilter: true,
initialPage: channel.content,
queryKey: channelQueryKey(channel.id),
endpoint: channelEndpoint(channel.id),
queryParams: {
returnContentOnly: "true",
...queryParams
}
});
}
function ChannelSortButton({
channel
}) {
var _a;
const config = channelContentConfig.models[channel.config.contentModel];
const sortMethods = (config == null ? void 0 : config.sortMethods.map((method) => ({
key: method,
label: channelContentConfig.sortingMethods[method].label
}))) || [];
if (channel.config.contentType === "manual") {
sortMethods.unshift({
key: Sort.curated,
label: message("Default order")
});
}
const [searchParams, setSearchParams] = useSearchParams();
const selectedValue = searchParams.get("order") || channel.config.contentOrder;
if ((sortMethods == null ? void 0 : sortMethods.length) < 2) {
return null;
}
const label = (_a = sortMethods == null ? void 0 : sortMethods.find(
(method) => method.key === selectedValue
)) == null ? void 0 : _a.label;
return /* @__PURE__ */ jsxs(
MenuTrigger,
{
selectionMode: "single",
showCheckmark: true,
selectedValue,
onSelectionChange: (newValue) => {
if (newValue === Sort.recent && channel.config.contentType === "manual") {
newValue = "channelables.created_at:desc";
}
setSearchParams(
(prev) => {
prev.set("order", newValue);
return prev;
},
{
replace: true
}
);
},
children: [
/* @__PURE__ */ jsxs("span", { role: "button", "aria-label": "Toggle menu", children: [
/* @__PURE__ */ jsx(IconButton, { className: "md:hidden", role: "presentation", children: /* @__PURE__ */ jsx(SortIcon, {}) }),
/* @__PURE__ */ jsx(
Button,
{
startIcon: /* @__PURE__ */ jsx(SortIcon, {}),
className: "max-md:hidden",
role: "presentation",
children: label ? /* @__PURE__ */ jsx(Trans, { ...label }) : /* @__PURE__ */ jsx(Trans, { message: "Popularity" })
}
)
] }),
/* @__PURE__ */ jsx(Menu, { children: sortMethods == null ? void 0 : sortMethods.map((method) => /* @__PURE__ */ jsx(Item, { value: method.key, children: /* @__PURE__ */ jsx(Trans, { ...method.label }) }, method.key)) })
]
}
);
}
function SiteSectionHeading({
children,
titleAppend,
link,
fontSize = "text-2xl md:text-3xl",
fontWeight = "font-bold",
margin = "mb-20",
className: className2,
headingType: HeadingType = "h2",
description,
descriptionFontSize = "text-base",
actions,
hideBorder
}) {
const title = link ? /* @__PURE__ */ jsx(
Link,
{
to: link,
className: "rounded outline-none transition-colors hover:underline focus-visible:ring-2 focus-visible:ring-offset-2",
children
}
) : children;
return /* @__PURE__ */ jsxs("section", { className: clsx(className2, margin), children: [
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-44 max-md:overflow-x-auto", children: [
/* @__PURE__ */ jsx("div", { className: "flex-auto", children: /* @__PURE__ */ jsxs(
"div",
{
className: clsx(
"relative flex items-center gap-4",
!hideBorder && "pl-14 before:absolute before:left-0 before:h-5/6 before:w-4 before:rounded before:bg-primary"
),
children: [
/* @__PURE__ */ jsx(HeadingType, { className: clsx(fontSize, fontWeight), children: title }),
titleAppend && /* @__PURE__ */ jsx("span", { className: "pt-4 text-base text-muted", children: titleAppend }),
link && /* @__PURE__ */ jsx(
IconButton,
{
elementType: Link,
to: link,
size: "sm",
iconSize: "lg",
className: "mt-4 max-md:hidden",
children: /* @__PURE__ */ jsx(KeyboardArrowRightIcon, {})
}
)
]
}
) }),
actions && /* @__PURE__ */ jsx("div", { className: "flex flex-shrink-0 items-center gap-4", children: actions })
] }),
description && /* @__PURE__ */ jsx("div", { className: clsx("mt-6", descriptionFontSize), children: description })
] });
}
function useChannelLayouts(channel) {
const config = channelContentConfig.models[channel.config.contentModel];
const availableLayouts = config == null ? void 0 : config.layoutMethods.filter((m2) => channelContentConfig.userSelectableLayouts.includes(m2)).map((method) => ({
key: method,
label: channelContentConfig.layoutMethods[method].label,
icon: channelContentConfig.layoutMethods[method].icon
}));
const [selectedLayout, setSelectedLayout] = useCookie(
`channel-layout-${channel.config.contentModel}`,
channel.config.selectedLayout || channel.config.layout
);
return { selectedLayout, setSelectedLayout, availableLayouts };
}
function ChannelLayoutButton({ channel }) {
const { selectedLayout, setSelectedLayout, availableLayouts } = useChannelLayouts(channel);
if ((availableLayouts == null ? void 0 : availableLayouts.length) < 2) {
return null;
}
const layoutConfig = availableLayouts == null ? void 0 : availableLayouts.find(
(method) => method.key === selectedLayout
);
return /* @__PURE__ */ jsxs(
MenuTrigger,
{
selectionMode: "single",
showCheckmark: true,
selectedValue: selectedLayout,
onSelectionChange: (newValue) => setSelectedLayout(newValue),
children: [
/* @__PURE__ */ jsxs("span", { role: "button", "aria-label": "Toggle menu", children: [
/* @__PURE__ */ jsx(IconButton, { className: "md:hidden", role: "presentation", children: (layoutConfig == null ? void 0 : layoutConfig.icon) || /* @__PURE__ */ jsx(GridViewIcon, {}) }),
/* @__PURE__ */ jsx(
Button,
{
role: "presentation",
className: "max-md:hidden",
startIcon: (layoutConfig == null ? void 0 : layoutConfig.icon) || /* @__PURE__ */ jsx(GridViewIcon, {}),
children: (layoutConfig == null ? void 0 : layoutConfig.label) ? /* @__PURE__ */ jsx(Trans, { ...layoutConfig.label }) : /* @__PURE__ */ jsx(Trans, { message: "Popularity" })
}
)
] }),
/* @__PURE__ */ jsx(Menu, { children: availableLayouts == null ? void 0 : availableLayouts.map((method) => /* @__PURE__ */ jsx(Item, { value: method.key, children: /* @__PURE__ */ jsx(Trans, { ...method.label }) }, method.key)) })
]
}
);
}
function UserListByline({ user }) {
const { auth } = useContext(SiteConfigContext);
return /* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 flex items-center gap-8 mr-24", children: [
/* @__PURE__ */ jsx(UserAvatar, { user, circle: true, size: "sm" }),
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
Trans,
{
message: "List by :name",
values: {
a: () => /* @__PURE__ */ jsx(
Link,
{
to: auth.getUserProfileLink(user),
className: "font-bold hover:underline",
children: user.display_name
}
)
}
}
) })
] });
}
function shareLinkSocially(network, link, name, image) {
const url = generateShareUrl(network, link, name, image);
if (network === "mail") {
window.location.href = url;
} else {
openNewWindow(url);
}
}
function openNewWindow(url) {
const width = 575, height = 400, left = (window.innerWidth - width) / 2, top = (window.innerHeight - height) / 2, opts = "status=1, scrollbars=1,width=" + width + ",height=" + height + ",top=" + top + ",left=" + left;
window.open(url, "share", opts);
}
function generateShareUrl(type, link, name, image) {
switch (type) {
case "facebook":
return "https://www.facebook.com/sharer/sharer.php?u=" + link;
case "twitter":
return `https://twitter.com/intent/tweet?text=${name}&url=${link}`;
case "pinterest":
return "https://pinterest.com/pin/create/button/?url=" + link + "&media=" + image;
case "tumblr":
const base = "https://www.tumblr.com/widgets/share/tool?shareSource=legacy&canonicalUrl=&posttype=photo&title=&caption=";
return base + name + "&content=" + image + "&url=" + link;
case "blogger":
return "https://www.blogger.com/blog_this.pyra?t&u=" + link + "&n=" + name;
case "mail":
return `mailto:?subject=Check out this link.&body=${link}`;
}
}
const CopyLinkIcon = createSvgIcon(
/* @__PURE__ */ jsx("path", { d: "M 4 2 C 2.895 2 2 2.895 2 4 L 2 18 L 4 18 L 4 4 L 18 4 L 18 2 L 4 2 z M 8 6 C 6.895 6 6 6.895 6 8 L 6 20 C 6 21.105 6.895 22 8 22 L 20 22 C 21.105 22 22 21.105 22 20 L 22 8 C 22 6.895 21.105 6 20 6 L 8 6 z M 8 8 L 20 8 L 20 20 L 8 20 L 8 8 z M 16 9.0058594 C 15.230215 9.0058594 14.460443 9.2973698 13.878906 9.8789062 L 12.607422 11.150391 L 14.021484 12.564453 L 12.556641 14.029297 L 11.142578 12.615234 L 9.8789062 13.878906 C 8.7158332 15.041979 8.7158332 16.958021 9.8789062 18.121094 C 10.460397 18.702585 11.234094 19 12 19 C 12.765906 19 13.539603 18.702585 14.121094 18.121094 L 15.384766 16.857422 L 13.970703 15.443359 L 15.457031 13.957031 L 14.042969 12.542969 L 15.292969 11.292969 C 15.691896 10.894042 16.308104 10.894042 16.707031 11.292969 C 17.105958 11.691896 17.105958 12.308104 16.707031 12.707031 L 15.464844 13.949219 L 16.878906 15.363281 L 18.121094 14.121094 C 19.284167 12.958021 19.284167 11.041979 18.121094 9.8789062 C 17.539557 9.2973698 16.769785 9.0058594 16 9.0058594 z M 12.542969 14.042969 L 13.957031 15.457031 L 12.707031 16.707031 C 12.506522 16.90754 12.258094 17 12 17 C 11.741906 17 11.493478 16.90754 11.292969 16.707031 C 10.894042 16.308104 10.894042 15.691896 11.292969 15.292969 L 12.542969 14.042969 z" })
);
function ShareMenuTrigger({ link, children }) {
const { trans } = useTrans();
const [, setUrlCopied] = useClipboard(link);
return /* @__PURE__ */ jsxs(MenuTrigger, { children: [
children,
/* @__PURE__ */ jsxs(Menu, { children: [
/* @__PURE__ */ jsx(
Item,
{
value: "clipboard",
startIcon: /* @__PURE__ */ jsx(CopyLinkIcon, {}),
onSelected: () => {
setUrlCopied();
toast.positive(message("Copied link to clipboard"));
},
children: /* @__PURE__ */ jsx(Trans, { message: "Copy to clipboard" })
}
),
/* @__PURE__ */ jsx(
Item,
{
value: "facebook",
startIcon: /* @__PURE__ */ jsx(FacebookIcon, {}),
onClick: () => {
shareLinkSocially(
"facebook",
link,
trans(message("Check out this link"))
);
},
children: /* @__PURE__ */ jsx(Trans, { message: "Share to facebook" })
}
),
/* @__PURE__ */ jsx(
Item,
{
value: "twitter",
startIcon: /* @__PURE__ */ jsx(TwitterIcon, {}),
onClick: () => {
shareLinkSocially(
"twitter",
link,
trans(message("Check out this link"))
);
},
children: /* @__PURE__ */ jsx(Trans, { message: "Share to twitter" })
}
)
] })
] });
}
function UserListLink({ list, children, ...linkProps }) {
const link = useMemo(() => {
return getUserListLink(list);
}, [list]);
let content2;
if (children) {
content2 = children;
} else if (list.internal && list.name === "watchlist") {
return /* @__PURE__ */ jsx(Trans, { message: "Watchlist" });
} else {
content2 = list.name;
}
return /* @__PURE__ */ jsx(BaseMediaLink, { ...linkProps, link, children: content2 });
}
function getUserListLink(list, { absolute } = {}) {
return getBaseMediaLink(`/lists/${list.id}`, {
absolute
});
}
function UserListDetails({
list,
className: className2,
showShareButton,
showVisibility = true
}) {
return /* @__PURE__ */ jsxs(
"div",
{
className: clsx(
"flex flex-shrink-0 items-center gap-4 whitespace-nowrap text-muted",
className2
),
children: [
showShareButton && /* @__PURE__ */ jsxs(Fragment, { children: [
/* @__PURE__ */ jsx(ShareButton$4, { list }),
/* @__PURE__ */ jsx(Divider, { marginLeft: "ml-2" })
] }),
list.items_count ? /* @__PURE__ */ jsxs(Fragment, { children: [
/* @__PURE__ */ jsx(Trans, { message: ":count items", values: { count: list.items_count } }),
/* @__PURE__ */ jsx(Divider, {})
] }) : null,
/* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(
Trans,
{
message: "Updated :date",
values: {
date: /* @__PURE__ */ jsx(FormattedRelativeTime, { date: list.updated_at })
}
}
) }),
showVisibility && /* @__PURE__ */ jsxs(Fragment, { children: [
/* @__PURE__ */ jsx(Divider, {}),
list.public ? /* @__PURE__ */ jsx(LockOpenIcon, { size: "sm" }) : /* @__PURE__ */ jsx(LockIcon, { size: "sm" }),
/* @__PURE__ */ jsx("div", { children: list.public ? /* @__PURE__ */ jsx(Trans, { message: "Public" }) : /* @__PURE__ */ jsx(Trans, { message: "Private" }) })
] })
]
}
);
}
function ShareButton$4({ list }) {
const link = getUserListLink(list, { absolute: true });
return /* @__PURE__ */ jsx(ShareMenuTrigger, { link, children: /* @__PURE__ */ jsx(Button, { startIcon: /* @__PURE__ */ jsx(ShareIcon, {}), sizeClassName: "px-10 py-6", children: /* @__PURE__ */ jsx(Trans, { message: "Share" }) }) });
}
function Divider({ marginLeft = "ml-12" }) {
return /* @__PURE__ */ jsx("div", { className: clsx("mr-10 h-20 w-1 bg-divider", marginLeft) });
}
const FilterModelTypes = [TITLE_MODEL, MOVIE_MODEL, SERIES_MODEL];
function ChannelHeader({
channel,
isNested,
actions,
margin = isNested ? "mb-16 md:mb-30" : "mb-20 md:mb-40"
}) {
const shouldShowFilterButton = !isNested && FilterModelTypes.includes(channel.config.contentModel) && channel.config.contentType === "listAll";
const { encodedFilters } = useBackendFilterUrlParams();
const { filters, filtersLoading } = useTitleIndexFilters({
disabled: !shouldShowFilterButton
});
if (channel.config.hideTitle) {
return null;
}
return /* @__PURE__ */ jsxs("section", { className: clsx(margin), children: [
/* @__PURE__ */ jsx(
ChannelTitle,
{
channel,
isNested,
actions: /* @__PURE__ */ jsxs(Fragment, { children: [
actions,
!isNested && /* @__PURE__ */ jsx(ChannelSortButton, { channel }),
shouldShowFilterButton && /* @__PURE__ */ jsx(
AddFilterButton,
{
icon: /* @__PURE__ */ jsx(TuneIcon, {}),
color: null,
variant: "text",
disabled: filtersLoading,
filters
}
),
!isNested && /* @__PURE__ */ jsx(ChannelLayoutButton, { channel })
] })
}
),
shouldShowFilterButton && /* @__PURE__ */ jsx("div", { className: "mt-14", children: /* @__PURE__ */ jsx(AnimatePresence, { initial: false, mode: "wait", children: filtersLoading && encodedFilters ? /* @__PURE__ */ jsx(FilterListSkeleton, {}) : /* @__PURE__ */ jsx(m.div, { ...opacityAnimation, children: /* @__PURE__ */ jsx(FilterList, { filters }) }, "filter-list") }) })
] });
}
function ChannelTitle({ channel, isNested, actions }) {
const { restriction: urlParam } = useParams();
if (channel.config.hideTitle) {
return null;
}
const link = channel.config.restriction && urlParam ? `/${channel.slug}/${urlParam}` : `/${channel.slug}`;
return /* @__PURE__ */ jsx(
SiteSectionHeading,
{
className: "flex-auto",
margin: "m-0",
description: /* @__PURE__ */ jsx(ChannelDescription, { channel }),
actions,
headingType: isNested ? "h2" : "h1",
descriptionFontSize: isNested ? "text-sm" : void 0,
fontWeight: isNested ? "font-normal" : void 0,
link: isNested ? link : void 0,
children: /* @__PURE__ */ jsx(Trans, { message: channel.name })
}
);
}
function ChannelDescription({ channel }) {
if (channel.type === "channel") {
return /* @__PURE__ */ jsx(Fragment, { children: channel.description });
}
return /* @__PURE__ */ jsxs("div", { className: "mt-18 items-center text-sm md:flex", children: [
channel.user && /* @__PURE__ */ jsx(UserListByline, { user: channel.user }),
/* @__PURE__ */ jsx(
UserListDetails,
{
list: channel,
className: "ml-auto max-md:mt-14",
showShareButton: true
}
)
] });
}
function ContentGridLayout({
children,
className: className2,
variant,
gridCols = "grid-cols-[repeat(var(--nVisibleItems),minmax(0,1fr))]"
}) {
return /* @__PURE__ */ jsx(
"div",
{
className: clsx(
"grid gap-24",
gridCols,
className2,
variant === "landscape" ? "content-grid-landscape" : "content-grid-portrait"
),
children
}
);
}
const PersonAge = memo(({ person, showRange }) => {
if (showRange && person.birth_date && person.death_date) {
return /* @__PURE__ */ jsx(
FormattedDateTimeRange,
{
start: person.birth_date,
end: person.death_date,
options: { year: "numeric" }
}
);
}
if (person.birth_date) {
return /* @__PURE__ */ jsx(Fragment, { children: calculateAgeFromBirthDate(person.birth_date, person.death_date) });
}
return null;
});
function calculateAgeFromBirthDate(_birthDate, _deathDate) {
const until = _deathDate ? new Date(_deathDate) : /* @__PURE__ */ new Date();
const birthDate = new Date(_birthDate);
let age = until.getFullYear() - birthDate.getFullYear();
const m2 = until.getMonth() - birthDate.getMonth();
if (m2 < 0 || m2 === 0 && until.getDate() < birthDate.getDate()) {
age--;
}
return age;
}
function NewsArticleGridItem({ article }) {
return /* @__PURE__ */ jsxs("div", { className: "items-start gap-14 lg:flex", children: [
/* @__PURE__ */ jsx(
NewsArticleImage,
{
article,
className: "aspect-poster max-w-90 max-md:hidden"
}
),
/* @__PURE__ */ jsxs("div", { className: "min-w-0 overflow-hidden overflow-ellipsis text-base md:mt-24 lg:mt-6", children: [
/* @__PURE__ */ jsx(NewsArticleLink, { article, className: "font-medium" }),
/* @__PURE__ */ jsxs(BulletSeparatedItems, { className: "mt-10 min-w-0 overflow-hidden overflow-ellipsis text-xs", children: [
/* @__PURE__ */ jsx(FormattedDate, { date: article.created_at }),
/* @__PURE__ */ jsx("div", { className: "overflow-hidden overflow-ellipsis whitespace-nowrap", children: article.source })
] })
] })
] });
}
function TitlePortraitGridItem({
item,
rating,
description
}) {
return /* @__PURE__ */ jsxs("div", { children: [
/* @__PURE__ */ jsx("div", { className: "relative", children: /* @__PURE__ */ jsx(TitlePoster, { title: item, srcSize: "md", showPlayButton: true }) }),
/* @__PURE__ */ jsxs("div", { className: "mt-10 text-sm", children: [
/* @__PURE__ */ jsx(RatingOrReleaseDate, { title: item, rating, className: "mb-4" }),
/* @__PURE__ */ jsx(TitleLink, { title: item, className: "block text-base font-medium" }),
description ? /* @__PURE__ */ jsx("div", { className: "mt-4", children: description }) : null
] })
] });
}
function TitleLandscapeGridItem({ item }) {
return /* @__PURE__ */ jsxs("div", { children: [
/* @__PURE__ */ jsx(
TitleBackdrop,
{
title: item,
srcSize: "lg",
size: "w-full",
className: "rounded",
wrapWithLink: true,
showPlayButton: true
}
),
/* @__PURE__ */ jsxs("div", { className: "mt-10 text-sm", children: [
/* @__PURE__ */ jsx(
TitleLink,
{
title: item,
className: "mb-4 block text-base font-semibold"
}
),
/* @__PURE__ */ jsxs(BulletSeparatedItems, { className: "mb-4", children: [
item.release_date && /* @__PURE__ */ jsx(FormattedDate, { date: item.release_date }),
item.certification && /* @__PURE__ */ jsx("div", { className: "uppercase", children: item.certification })
] }),
/* @__PURE__ */ jsx(TitleRating, { score: item.rating, className: "mb-4" })
] })
] });
}
function RatingOrReleaseDate({
title,
rating,
className: className2
}) {
if (!rating) {
rating = title.rating;
}
if (rating) {
return /* @__PURE__ */ jsx(TitleRating, { score: rating, className: className2 });
}
if (title.release_date) {
return /* @__PURE__ */ jsx("div", { className: className2, children: /* @__PURE__ */ jsx(FormattedDate, { date: title.release_date }) });
}
return null;
}
function ChannelContentGridItem({ item, variant }) {
switch (item.model_type) {
case TITLE_MODEL:
return variant === "landscape" ? /* @__PURE__ */ jsx(TitleLandscapeGridItem, { item }) : /* @__PURE__ */ jsx(TitlePortraitGridItem, { item });
case PERSON_MODEL:
return /* @__PURE__ */ jsx(PersonGridItem, { item });
case NEWS_ARTICLE_MODEL:
return /* @__PURE__ */ jsx(NewsArticleGridItem, { article: item });
default:
return null;
}
}
function PersonGridItem({ item }) {
return /* @__PURE__ */ jsxs("div", { children: [
/* @__PURE__ */ jsx(PersonPoster, { person: item, srcSize: "md", size: "w-full", rounded: true }),
/* @__PURE__ */ jsxs("div", { className: "mt-10 text-center text-sm", children: [
/* @__PURE__ */ jsx(PersonLink, { person: item, className: "block text-base font-medium" }),
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(PersonAge, { person: item, showRange: true }) })
] })
] });
}
function ChannelContentGrid(props) {
const isInfiniteScroll = !props.isNested && (!props.channel.config.paginationType || props.channel.config.paginationType === "infiniteScroll");
return /* @__PURE__ */ jsxs(Fragment, { children: [
/* @__PURE__ */ jsx(ChannelHeader, { ...props }),
isInfiniteScroll ? /* @__PURE__ */ jsx(InfiniteScrollGrid, { ...props }) : /* @__PURE__ */ jsx(PaginatedGrid, { ...props })
] });
}
function InfiniteScrollGrid({ channel, variant }) {
const query = useInfiniteChannelContent(channel);
return /* @__PURE__ */ jsxs(
"div",
{
className: clsx("transition-opacity", query.isReloading && "opacity-70"),
children: [
/* @__PURE__ */ jsx(ContentGrid, { content: query.items, variant }),
/* @__PURE__ */ jsx(InfiniteScrollSentinel, { query })
]
}
);
}
function PaginatedGrid({ channel, variant, isNested }) {
var _a;
const shouldPaginate = !isNested;
const query = useChannelContent(channel, null, { paginate: shouldPaginate });
return /* @__PURE__ */ jsxs(
"div",
{
className: clsx(
"transition-opacity",
query.isPlaceholderData && "opacity-70"
),
children: [
shouldPaginate && /* @__PURE__ */ jsx(
PaginationControls,
{
pagination: query.data,
type: channel.config.paginationType,
className: "mb-24"
}
),
/* @__PURE__ */ jsx(ContentGrid, { content: (_a = query.data) == null ? void 0 : _a.data, variant }),
shouldPaginate && /* @__PURE__ */ jsx(
PaginationControls,
{
pagination: query.data,
type: channel.config.paginationType,
className: "mt-24",
scrollToTop: true
}
)
]
}
);
}
function ContentGrid({ content: content2 = [], variant }) {
return /* @__PURE__ */ jsx(ContentGridLayout, { variant, children: content2.map((item) => /* @__PURE__ */ jsx(
ChannelContentGridItem,
{
item,
variant
},
`${item.id}-${item.model_type}`
)) });
}
const containerClassName = "content-carousel content-grid relative w-full grid grid-flow-col grid-rows-[auto] overflow-x-auto overflow-y-hidden gap-24 snap-always snap-x snap-mandatory hidden-scrollbar scroll-smooth";
const itemClassName = "snap-start snap-normal";
function useCarousel({ rotate = false } = {}) {
const scrollContainerRef = useRef(null);
const itemWidth = useRef(0);
const perPage = useRef(5);
const [canScrollBackward, setCanScrollBackward] = useState(rotate);
const [canScrollForward, setCanScrollForward] = useState(true);
const [activePage, setActivePage] = useState(0);
const updateNavStatus = useCallback(() => {
const el = scrollContainerRef.current;
if (el && itemWidth.current) {
if (!rotate) {
setCanScrollForward(
el.scrollWidth - 1 > el.scrollLeft + el.clientWidth
);
setCanScrollBackward(el.scrollLeft > 0);
}
const pageWidth = el.clientWidth;
const activePage2 = Math.round(el.scrollLeft / pageWidth);
setActivePage(activePage2);
}
}, [rotate]);
useEffect(() => {
const el = scrollContainerRef.current;
const handleScroll = debounce(() => updateNavStatus(), 100);
if (el) {
el.addEventListener("scroll", handleScroll);
}
return () => el == null ? void 0 : el.removeEventListener("scroll", handleScroll);
}, [updateNavStatus]);
useLayoutEffect(() => {
const el = scrollContainerRef.current;
if (el) {
perPage.current = Number(
getComputedStyle(el).getPropertyValue("--nVisibleItems")
);
const firstGridItem = el.children.item(0);
const observer = new ResizeObserver((entries) => {
itemWidth.current = entries[0].contentRect.width;
updateNavStatus();
});
if (firstGridItem) {
observer.observe(firstGridItem);
}
return () => observer.unobserve(el);
}
}, [updateNavStatus]);
const scrollToIndex = useCallback((index) => {
if (scrollContainerRef.current) {
setActivePage(index);
const amount = itemWidth.current * index;
scrollContainerRef.current.scrollTo({ left: amount });
}
}, []);
const scrollToPreviousPage = useCallback(() => {
if (scrollContainerRef.current) {
const pageWidth = scrollContainerRef.current.clientWidth;
const currentScroll = scrollContainerRef.current.scrollLeft;
const scrollLeft = !currentScroll && rotate ? scrollContainerRef.current.scrollWidth - pageWidth : currentScroll - pageWidth;
scrollContainerRef.current.scrollTo({
left: scrollLeft
});
}
}, [rotate]);
const scrollToNextPage = useCallback(() => {
if (scrollContainerRef.current) {
const pageWidth = scrollContainerRef.current.clientWidth;
const currentScroll = scrollContainerRef.current.scrollLeft;
const scrollLeft = rotate && currentScroll + pageWidth >= scrollContainerRef.current.scrollWidth ? 0 : (activePage + 1) * pageWidth;
scrollContainerRef.current.scrollTo({ left: scrollLeft });
}
}, [activePage, rotate]);
return {
scrollContainerRef,
scrollToIndex,
scrollToPreviousPage,
scrollToNextPage,
canScrollForward,
canScrollBackward,
activePage,
containerClassName,
itemClassName
};
}
function ChannelContentCarousel(props) {
var _a;
const { channel, variant } = props;
const {
scrollContainerRef,
canScrollForward,
canScrollBackward,
scrollToPreviousPage,
scrollToNextPage,
containerClassName: containerClassName2,
itemClassName: itemClassName2
} = useCarousel();
const gridClassName = variant === "landscape" ? "content-grid-landscape" : "content-grid-portrait";
return /* @__PURE__ */ jsxs("div", { children: [
/* @__PURE__ */ jsx(
ChannelHeader,
{
...props,
actions: /* @__PURE__ */ jsxs(Fragment, { children: [
/* @__PURE__ */ jsx(
IconButton,
{
disabled: !canScrollBackward,
onClick: () => scrollToPreviousPage(),
"aria-label": "Previous page",
children: /* @__PURE__ */ jsx(KeyboardArrowLeftIcon, {})
}
),
/* @__PURE__ */ jsx(
IconButton,
{
disabled: !canScrollForward,
onClick: () => scrollToNextPage(),
"aria-label": "Next page",
children: /* @__PURE__ */ jsx(KeyboardArrowRightIcon, {})
}
)
] })
}
),
/* @__PURE__ */ jsx(
"div",
{
ref: scrollContainerRef,
className: clsx(containerClassName2, gridClassName),
children: (_a = channel.content) == null ? void 0 : _a.data.map((item) => /* @__PURE__ */ jsx("div", { className: itemClassName2, children: /* @__PURE__ */ jsx(ChannelContentGridItem, { item, variant }) }, `${item.id}-${item.model_type}`))
}
)
] });
}
function ChannelContentSlider({
channel,
isNested
}) {
const {
scrollContainerRef,
activePage,
canScrollBackward,
canScrollForward,
scrollToNextPage,
scrollToPreviousPage
} = useCarousel({ rotate: true });
const { data: pagination } = useChannelContent(channel);
return /* @__PURE__ */ jsxs(Fragment, { children: [
/* @__PURE__ */ jsx(
ChannelHeader,
{
channel,
isNested,
margin: "mb-18"
}
),
/* @__PURE__ */ jsxs("div", { className: "gap-24 md:flex", children: [
/* @__PURE__ */ jsxs("div", { className: "relative flex-auto", children: [
/* @__PURE__ */ jsx(
"div",
{
ref: scrollContainerRef,
className: "hidden-scrollbar flex h-full select-none snap-x snap-mandatory snap-always items-center overflow-x-auto",
children: pagination == null ? void 0 : pagination.data.map((item, index) => /* @__PURE__ */ jsx(Slide, { item, index }, item.id))
}
),
/* @__PURE__ */ jsxs("div", { className: "absolute top-10 z-20 w-full md:top-[170px]", children: [
/* @__PURE__ */ jsx("div", { className: "absolute left-8 hidden md:left-14 md:block", children: /* @__PURE__ */ jsx(
IconButton,
{
variant: "outline",
size: "lg",
color: "white",
disabled: !canScrollBackward,
onClick: () => scrollToPreviousPage(),
children: /* @__PURE__ */ jsx(ChevronLeftIcon, {})
}
) }),
/* @__PURE__ */ jsx("div", { className: "absolute right-8 hidden md:right-14 md:block", children: /* @__PURE__ */ jsx(
IconButton,
{
variant: "outline",
size: "lg",
color: "white",
disabled: !canScrollForward,
onClick: () => scrollToNextPage(),
children: /* @__PURE__ */ jsx(ChevronRightIcon, {})
}
) })
] })
] }),
/* @__PURE__ */ jsx(UpNext, { titles: (pagination == null ? void 0 : pagination.data) ?? [], activePage })
] })
] });
}
function Slide({ item, index }) {
return /* @__PURE__ */ jsxs("div", { className: "relative h-full w-full flex-shrink-0 snap-start snap-normal overflow-hidden rounded", children: [
/* @__PURE__ */ jsx(
TitleBackdrop,
{
title: item,
lazy: index > 0,
className: "min-h-240 md:min-h-0",
wrapperClassName: "h-full"
}
),
/* @__PURE__ */ jsxs("div", { className: "absolute inset-0 isolate flex h-full w-full items-center justify-start gap-24 rounded p-30 text-white md:items-end", children: [
/* @__PURE__ */ jsx("div", { className: "absolute left-0 h-full w-full bg-gradient-to-b from-black/40 max-md:top-0 md:bottom-0 md:h-3/4 md:bg-gradient-to-t md:from-black/100" }),
/* @__PURE__ */ jsx(
TitlePoster,
{
title: item,
size: "max-h-320",
srcSize: "md",
className: "z-10 shadow-md max-md:hidden"
}
),
/* @__PURE__ */ jsxs("div", { className: "z-10 text-lg md:max-w-620", children: [
/* @__PURE__ */ jsx(TitleRating, { score: item.rating }),
/* @__PURE__ */ jsx("div", { className: "my-8 text-2xl md:text-5xl", children: /* @__PURE__ */ jsx(TitleLink, { title: item }) }),
item.description && /* @__PURE__ */ jsx("p", { className: "max-md:hidden", children: item.description }),
item.primary_video && /* @__PURE__ */ jsx(
Button,
{
variant: "flat",
color: "primary",
startIcon: /* @__PURE__ */ jsx(MediaPlayIcon, {}),
radius: "rounded-full",
className: "mt-24 md:min-h-42 md:min-w-144",
elementType: Link,
to: getWatchLink(item.primary_video),
children: item.primary_video.category === "full" ? /* @__PURE__ */ jsx(Trans, { message: "Watch now" }) : /* @__PURE__ */ jsx(Trans, { message: "Play trailer" })
}
)
] })
] })
] });
}
function UpNext({ titles, activePage }) {
const itemCount = titles.length;
const start = activePage + 1;
const end = start + 3;
const items = titles.slice(start, end);
if (end > itemCount) {
items.push(...titles.slice(0, end - itemCount));
}
return /* @__PURE__ */ jsx(AnimatePresence, { initial: false, mode: "wait", children: /* @__PURE__ */ jsxs("div", { className: "w-1/4 max-w-200 flex-shrink-0 max-md:hidden", children: [
/* @__PURE__ */ jsx("div", { className: "mb-12 text-lg font-semibold", children: /* @__PURE__ */ jsx(Trans, { message: "Up next" }) }),
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-24", children: items.map((item) => /* @__PURE__ */ jsxs(
m.div,
{
className: "relative flex-auto",
initial: { opacity: 0 },
animate: { opacity: 1 },
exit: { opacity: 0 },
transition: { duration: 0.2 },
children: [
/* @__PURE__ */ jsx(
TitleBackdrop,
{
title: item,
className: "mb-6 rounded",
size: "w-full",
srcSize: "md",
wrapWithLink: true,
showPlayButton: true
}
),
/* @__PURE__ */ jsx("div", { className: "mb-2 overflow-hidden overflow-ellipsis whitespace-nowrap text-sm", children: /* @__PURE__ */ jsx(TitleLink, { title: item, className: "text-base font-medium" }) }),
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(TitleRating, { score: item.rating, className: "text-sm" }) })
]
},
item.id
)) })
] }) });
}
function NewsArticleSourceLink({ article, className: className2 }) {
return /* @__PURE__ */ jsxs("div", { className: clsx("flex items-center gap-4 text-primary", className2), children: [
/* @__PURE__ */ jsx(OpenInNewIcon, { size: "xs", className: "flex-shrink-0" }),
/* @__PURE__ */ jsx(
"a",
{
href: article.source_url,
target: "_blank",
rel: "noreferrer",
className: clsx(
LinkStyle,
"whitespace-nowrap overflow-hidden overflow-ellipsis"
),
children: article.source
}
)
] });
}
function NewsArticleByline({ article }) {
return article.byline ? /* @__PURE__ */ jsx("span", { className: "whitespace-nowrap", children: /* @__PURE__ */ jsx(Trans, { message: "By :name", values: { name: article.byline } }) }) : null;
}
function ChannelContentNews({
channel,
isNested
}) {
var _a, _b;
const shouldPaginate = !isNested;
const query = useChannelContent(
channel,
null,
{
paginate: shouldPaginate
}
);
return /* @__PURE__ */ jsxs("div", { children: [
/* @__PURE__ */ jsx(ChannelHeader, { channel, isNested }),
shouldPaginate && /* @__PURE__ */ jsx(
PaginationControls,
{
pagination: query.data,
type: channel.config.paginationType,
className: "mb-34"
}
),
/* @__PURE__ */ jsxs("div", { className: "flex gap-34", children: [
/* @__PURE__ */ jsx("div", { className: "w-240 flex-shrink-0", children: (_a = query.data) == null ? void 0 : _a.data.slice(0, 3).map((article) => /* @__PURE__ */ jsx(
LeftColArticle,
{
article,
className: "mb-14"
},
article.id
)) }),
/* @__PURE__ */ jsx("div", { className: "flex-auto", children: (_b = query.data) == null ? void 0 : _b.data.slice(3, 12).map((article) => /* @__PURE__ */ jsxs("div", { className: "mb-12 flex items-center gap-14", children: [
/* @__PURE__ */ jsx(NewsArticleImage, { article, size: "w-84 h-84" }),
/* @__PURE__ */ jsxs("div", { className: "flex-auto", children: [
/* @__PURE__ */ jsx(NewsArticleLink, { article, className: "font-semibold" }),
/* @__PURE__ */ jsxs(BulletSeparatedItems, { className: "text-sm", children: [
/* @__PURE__ */ jsx(FormattedDate, { date: article.created_at }),
/* @__PURE__ */ jsx(NewsArticleByline, { article }),
/* @__PURE__ */ jsx(NewsArticleSourceLink, { article })
] })
] })
] }, article.id)) })
] }),
shouldPaginate && /* @__PURE__ */ jsx(
PaginationControls,
{
pagination: query.data,
type: channel.config.paginationType,
className: "mt-34",
scrollToTop: true
}
)
] });
}
function LeftColArticle({ article, className: className2 }) {
return /* @__PURE__ */ jsxs("div", { className: className2, children: [
/* @__PURE__ */ jsx(NewsArticleImage, { article, size: "aspect-video w-full" }),
/* @__PURE__ */ jsx(
NewsArticleLink,
{
article,
className: "mt-10 block text-sm font-semibold"
}
),
/* @__PURE__ */ jsxs("div", { className: "mt-8 text-xs text-muted", children: [
/* @__PURE__ */ jsx(NewsArticleByline, { article }),
/* @__PURE__ */ jsx(NewsArticleSourceLink, { article, className: "mt-4" })
] })
] });
}
function ChannelContentListItem({ item }) {
switch (item.model_type) {
case TITLE_MODEL:
return /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-24 mb-24", children: [
/* @__PURE__ */ jsx(TitlePoster, { title: item, srcSize: "md", size: "w-128", showPlayButton: true }),
/* @__PURE__ */ jsxs("div", { className: "flex-auto min-w-0 pt-12", children: [
/* @__PURE__ */ jsx(TitleLink, { title: item, className: "font-medium" }),
/* @__PURE__ */ jsxs(BulletSeparatedItems, { className: "text-sm mt-4", children: [
item.runtime ? /* @__PURE__ */ jsx(FormattedDuration, { minutes: item.runtime, verbose: true }) : null,
item.certification && /* @__PURE__ */ jsx("span", { className: "uppercase", children: item.certification })
] }),
item.rating && item.status !== "upcoming" ? /* @__PURE__ */ jsx(InteractableRating, { size: "md", title: item, className: "my-12" }) : /* @__PURE__ */ jsx("div", { className: "my-12", children: /* @__PURE__ */ jsx(FormattedDate, { date: item.release_date }) }),
item.description ? /* @__PURE__ */ jsx("p", { className: "text-sm", children: item.description }) : null
] })
] });
case PERSON_MODEL:
return /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-24 mb-24", children: [
/* @__PURE__ */ jsx(PersonPoster, { person: item, srcSize: "md", size: "w-128" }),
/* @__PURE__ */ jsxs("div", { className: "flex-auto min-w-0 pt-12", children: [
/* @__PURE__ */ jsx(PersonLink, { person: item, className: "block font-medium text-lg" }),
item.primary_credit ? /* @__PURE__ */ jsx("div", { className: "text-sm mt-4", children: /* @__PURE__ */ jsx(KnownForCompact, { person: item }) }) : null,
/* @__PURE__ */ jsx("p", { className: "text-sm mt-12", children: item.description })
] })
] });
case NEWS_ARTICLE_MODEL:
return /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-14 mb-44", children: [
/* @__PURE__ */ jsx(NewsArticleImage, { article: item, className: "aspect-poster max-w-90" }),
/* @__PURE__ */ jsxs("div", { className: "mt-6 text-base", children: [
/* @__PURE__ */ jsx(NewsArticleLink, { article: item, className: "font-medium" }),
/* @__PURE__ */ jsx("p", { className: "text-sm mt-10", children: item.body }),
/* @__PURE__ */ jsxs(BulletSeparatedItems, { className: "text-xs mt-10", children: [
/* @__PURE__ */ jsx(FormattedDate, { date: item.created_at }),
/* @__PURE__ */ jsx(NewsArticleSourceLink, { article: item })
] })
] })
] });
default:
return null;
}
}
function ChannelContentList(props) {
const isInfiniteScroll = !props.isNested && (!props.channel.config.paginationType || props.channel.config.paginationType === "infiniteScroll");
return /* @__PURE__ */ jsxs(Fragment, { children: [
/* @__PURE__ */ jsx(ChannelHeader, { ...props }),
isInfiniteScroll ? /* @__PURE__ */ jsx(InfiniteScrollList, { ...props }) : /* @__PURE__ */ jsx(PaginatedList, { ...props })
] });
}
function InfiniteScrollList({ channel }) {
const query = useInfiniteChannelContent(channel);
return /* @__PURE__ */ jsx(
Content$1,
{
content: query.items,
className: clsx("transition-opacity", query.isReloading && "opacity-70"),
children: /* @__PURE__ */ jsx(InfiniteScrollSentinel, { query })
}
);
}
function PaginatedList({ channel, isNested }) {
var _a;
const shouldPaginate = !isNested;
const query = useChannelContent(channel, null, { paginate: shouldPaginate });
return /* @__PURE__ */ jsxs(
"div",
{
className: clsx(
"transition-opacity",
query.isPlaceholderData && "opacity-70"
),
children: [
shouldPaginate && /* @__PURE__ */ jsx(
PaginationControls,
{
pagination: query.data,
type: channel.config.paginationType,
className: "mb-24"
}
),
/* @__PURE__ */ jsx(Content$1, { content: (_a = query.data) == null ? void 0 : _a.data }),
shouldPaginate && /* @__PURE__ */ jsx(
PaginationControls,
{
pagination: query.data,
type: channel.config.paginationType,
className: "mt-24",
scrollToTop: true
}
)
]
}
);
}
function Content$1({ content: content2 = [], children, className: className2 }) {
return /* @__PURE__ */ jsxs("div", { className: className2, children: [
content2.map((item) => /* @__PURE__ */ jsx(
ChannelContentListItem,
{
item
},
`${item.id}-${item.model_type}`
)),
children
] });
}
function ChannelContent(props) {
var _a;
if (props.isNested && !((_a = props.channel.content) == null ? void 0 : _a.data.length)) {
return null;
}
if (props.channel.config.contentModel === CHANNEL_MODEL) {
return /* @__PURE__ */ jsx(NestedChannels, { ...props });
} else {
return /* @__PURE__ */ jsxs(Fragment, { children: [
/* @__PURE__ */ jsx(ChannelLayout, { ...props }),
/* @__PURE__ */ jsx(NoResultsMessage, { channel: props.channel })
] });
}
}
function NoResultsMessage({ channel }) {
var _a;
if (((_a = channel.content) == null ? void 0 : _a.data.length) === 0) {
return /* @__PURE__ */ jsx(
IllustratedMessage,
{
className: "mt-60",
image: /* @__PURE__ */ jsx(SvgImage, { src: todoImage }),
title: channel.type === "list" ? /* @__PURE__ */ jsx(Trans, { message: "This list does not have any content yet." }) : /* @__PURE__ */ jsx(Trans, { message: "This channel does not have any content yet." })
}
);
}
return null;
}
function ChannelLayout(props) {
const { channel, isNested } = props;
const { selectedLayout } = useChannelLayouts(channel);
const layout = isNested ? channel.config.nestedLayout : selectedLayout;
switch (layout) {
case "grid":
return /* @__PURE__ */ jsx(ChannelContentGrid, { ...props, variant: "portrait" });
case "landscapeGrid":
return /* @__PURE__ */ jsx(ChannelContentGrid, { ...props, variant: "landscape" });
case "list":
return /* @__PURE__ */ jsx(ChannelContentList, { ...props });
case "carousel":
return /* @__PURE__ */ jsx(ChannelContentCarousel, { ...props, variant: "portrait" });
case "landscapeCarousel":
return /* @__PURE__ */ jsx(ChannelContentCarousel, { ...props, variant: "landscape" });
case "slider":
return /* @__PURE__ */ jsx(ChannelContentSlider, { ...props });
case "news":
return /* @__PURE__ */ jsx(ChannelContentNews, { ...props });
default:
return null;
}
}
function NestedChannels({ channel, isNested }) {
var _a;
return /* @__PURE__ */ jsxs(Fragment, { children: [
/* @__PURE__ */ jsx(ChannelHeader, { channel, isNested }),
(_a = channel.content) == null ? void 0 : _a.data.map((nestedChannel) => /* @__PURE__ */ jsx("div", { className: "mb-40 md:mb-50", children: /* @__PURE__ */ jsx(
ChannelContent,
{
channel: nestedChannel,
isNested: true
}
) }, nestedChannel.id))
] });
}
function useSearchResults(loader, query = "") {
query = query.trim();
if (query === ".") {
query = "";
}
return useQuery({
queryKey: ["search", query, "loader"],
queryFn: ({ signal }) => search(loader, query, signal),
enabled: !!query,
placeholderData: !!query ? keepPreviousData : void 0,
initialData: () => {
var _a;
const data = (_a = getBootstrapData().loaders) == null ? void 0 : _a[loader];
if (query && (data == null ? void 0 : data.query) == query) {
return data;
}
}
});
}
async function search(loader, query, signal) {
await new Promise((resolve) => setTimeout(resolve, 300));
return apiClient.get(`search/${encodeURIComponent(query)}`, {
params: { loader },
signal
}).then((response) => response.data);
}
function SearchAutocomplete({ className: className2 }) {
const { searchQuery } = useParams();
const { trans } = useTrans();
const navigate = useNavigate();
const [query, setQuery] = useState(searchQuery || "");
const [isOpen, setIsOpen] = useState(false);
const { isFetching, data } = useSearchResults("searchAutocomplete", query);
return /* @__PURE__ */ jsx(
"form",
{
onSubmit: (e) => {
e.preventDefault();
if (query.trim().length) {
setIsOpen(false);
navigate(`/search/${encodeURIComponent(query.trim())}`);
}
},
className: clsx(
"flex max-w-580 flex-auto items-center rounded bg-chip/40 text",
className2
),
children: /* @__PURE__ */ jsx(
ComboBoxForwardRef,
{
size: "sm",
startAdornment: /* @__PURE__ */ jsx("button", { type: "submit", "aria-label": trans(message("Search")), children: /* @__PURE__ */ jsx(SearchIcon, { className: "flex-shrink-0 text-muted" }) }),
className: "w-full",
offset: 6,
inputClassName: "w-full outline-none text-sm placeholder:text-muted",
isAsync: true,
hideEndAdornment: true,
placeholder: trans(
message("Search for movies, tv shows and people...")
),
isLoading: isFetching,
inputValue: query,
onInputValueChange: setQuery,
clearInputOnItemSelection: true,
blurReferenceOnItemSelection: true,
selectionMode: "none",
openMenuOnFocus: true,
floatingMaxHeight: 670,
isOpen,
onOpenChange: setIsOpen,
autoFocusFirstItem: false,
children: data == null ? void 0 : data.results.map((result) => {
switch (result.model_type) {
case TITLE_MODEL:
return /* @__PURE__ */ jsx(
Item,
{
value: result.id,
onSelected: () => {
navigate(getTitleLink(result));
},
startIcon: /* @__PURE__ */ jsx(TitlePoster, { title: result, srcSize: "sm", size: "w-46" }),
description: /* @__PURE__ */ jsxs("div", { children: [
/* @__PURE__ */ jsx("div", { className: "mb-4", children: result.year }),
/* @__PURE__ */ jsx("div", { children: result.is_series ? /* @__PURE__ */ jsx(Trans, { message: "Tv series" }) : /* @__PURE__ */ jsx(Trans, { message: "Movie" }) })
] }),
textLabel: result.name,
children: result.name
},
result.id
);
case PERSON_MODEL:
return /* @__PURE__ */ jsx(
Item,
{
value: result.id,
onSelected: () => {
navigate(getPersonLink(result));
},
startIcon: /* @__PURE__ */ jsx(
PersonPoster,
{
person: result,
srcSize: "sm",
className: "w-56"
}
),
description: /* @__PURE__ */ jsx(KnownForCompact, { person: result }),
textLabel: result.name,
children: result.name
},
result.id
);
}
})
}
)
}
);
}
function MainNavbar({ position = "relative" }) {
return /* @__PURE__ */ jsxs(
Navbar,
{
size: "md",
menuPosition: "primary",
className: clsx(position, "z-40 w-full flex-shrink-0"),
border: "border-none",
alwaysDarkMode: true,
children: [
/* @__PURE__ */ jsx(Tooltip, { label: /* @__PURE__ */ jsx(Trans, { message: "Search" }), children: /* @__PURE__ */ jsx(IconButton, { elementType: Link, to: "/search", className: "md:hidden", children: /* @__PURE__ */ jsx(SearchIcon, {}) }) }),
/* @__PURE__ */ jsx(SearchAutocomplete, { className: "max-md:hidden" })
]
}
);
}
function AdHost({ slot, className: className2 }) {
var _a;
const settings = useSettings();
const { isSubscribed } = useAuth();
const adCode2 = useMemo(() => {
return dot.pick(`ads.${slot}`, settings);
}, [slot, settings]);
if (((_a = settings.ads) == null ? void 0 : _a.disable) || isSubscribed || !adCode2)
return null;
return /* @__PURE__ */ jsx(InvariantAd, { className: className2, slot, adCode: adCode2 });
}
const InvariantAd = memo(
({ slot, adCode: adCode2, className: className2 }) => {
const ref = useRef(null);
const id2 = useId();
useEffect(() => {
if (ref.current) {
loadAdScripts(adCode2, ref.current).then(() => {
executeAdJavascript(adCode2, id2);
});
}
return () => {
delete window["google_ad_modifications"];
};
}, [adCode2, id2]);
useEffect(() => {
if (ref.current) {
const scrollParent = getScrollParent(ref.current);
if (scrollParent) {
const observer = new MutationObserver(function() {
scrollParent.style.height = "";
scrollParent.style.minHeight = "";
});
observer.observe(scrollParent, {
attributes: true,
attributeFilter: ["style"]
});
return () => observer.disconnect();
}
}
}, []);
return /* @__PURE__ */ jsx(
"div",
{
ref,
id: id2,
className: clsx(
"ad-host flex max-h-[600px] min-h-90 w-full max-w-full items-center justify-center overflow-hidden",
`${slot.replace(/\./g, "-")}-host`,
className2
),
dangerouslySetInnerHTML: { __html: getAdHtml(adCode2) }
}
);
},
() => {
return false;
}
);
function getAdHtml(adCode2) {
return adCode2 == null ? void 0 : adCode2.replace(/