@sesionario/blocks 1.6.0 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -85,6 +85,15 @@ type ConfirmDestructiveDialogProps = {
85
85
  */
86
86
  declare function ConfirmDestructiveDialog({ open, onOpenChange, title, description, confirmLabel, cancelLabel, onConfirm, }: ConfirmDestructiveDialogProps): React.JSX.Element;
87
87
 
88
+ type ExpandableTextProps = {
89
+ children: ReactNode;
90
+ expandLabel: string;
91
+ collapseLabel: string;
92
+ className?: string;
93
+ textClassName?: string;
94
+ };
95
+ declare function ExpandableText({ children, expandLabel, collapseLabel, className, textClassName, }: ExpandableTextProps): React.JSX.Element;
96
+
88
97
  declare function Empty({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
89
98
  declare function EmptyHeader({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
90
99
  declare const emptyMediaVariants: (props?: ({
@@ -95,6 +104,26 @@ declare function EmptyTitle({ className, ...props }: React.ComponentProps<"div">
95
104
  declare function EmptyDescription({ className, ...props }: React.ComponentProps<"p">): React.JSX.Element;
96
105
  declare function EmptyContent({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
97
106
 
107
+ type ImageLightboxLabels = {
108
+ ariaLabel?: string;
109
+ close?: string;
110
+ previous?: string;
111
+ next?: string;
112
+ };
113
+ type ImageLightboxProps = {
114
+ images: string[];
115
+ index: number;
116
+ onIndexChange: (index: number) => void;
117
+ onClose: () => void;
118
+ labels?: ImageLightboxLabels;
119
+ };
120
+ /**
121
+ * Fullscreen image gallery viewer. Portal overlay with Esc/click-to-close,
122
+ * arrow-key navigation, wheel/pinch zoom, and pan when zoomed. Locks page
123
+ * scroll while mounted.
124
+ */
125
+ declare function ImageLightbox({ images, index, onIndexChange, onClose, labels, }: ImageLightboxProps): React.ReactPortal;
126
+
98
127
  type ThemeSwitcherLabels = {
99
128
  /** Tooltip label for the theme switcher */
100
129
  theme?: string;
@@ -939,4 +968,4 @@ declare function useSupportConversation({ client, getWsUrl, conversationId: conv
939
968
 
940
969
  declare function cn(...inputs: ClassValue[]): string;
941
970
 
942
- export { type AutoplayState, AvatarEditor, AvatarEditorDialog, type AvatarEditorDialogProps, type AvatarEditorProps, type BlocksLanguage, Bubble, BubbleContent, BubbleGroup, BubbleReactions, type ChatListMessage, ChatMessageList, type ChatMessageListProps, ConfirmDestructiveDialog, type ConfirmDestructiveDialogProps, type ConversationKind, type DescribedPlaybackError, type EmojiCategoryData, type EmojiCategoryKey, type EmojiDatum, EmojiInput, type EmojiInputProps, EmojiPicker, type EmojiPickerLabels, type EmojiPickerLocale, EmojiPickerPopover, type EmojiPickerPopoverProps, type EmojiPickerProps, type EmojiSkinTone, EmojiTextarea, type EmojiTextareaProps, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyState, type EmptyStateProps, EmptyTitle, ErrorState, type FeatureEntry, type FindOrCreateConversationInput, type HlsPlayerMode, type Language, LanguageContext, type LanguageContextValue, LanguageSwitcher, type LanguageSwitcherLabels, type LanguageSwitcherProps, LoadingState, MEXICO_STATES, MEXICO_STATE_PATHS, Marker, MarkerContent, MarkerIcon, Message, MessageAvatar, MessageContent, MessageFooter, MessageGroup, MessageHeader, MessageScroller, MessageScrollerButton, MessageScrollerContent, MessageScrollerItem, MessageScrollerProvider, MessageScrollerViewport, MexicoMap, type MexicoMapProps, type MexicoState, type MexicoStateId, type OpenThreadRequest, OrgSwitcher, type OrgSwitcherLabels, type OrgSwitcherProps, type OrgSwitcherTenant, PhoneInput, type PhoneInputProps, type PlaybackErrorContext, type PlaybackErrorDetail, type PlaybackErrorKind, type PlaybackState, type PlaybackStats, type ProfessionalVerificationStatus, type QualityLevel, SearchCommand, type SearchCommandLabels, type SearchCommandProps, type SearchCommandSelection, type SearchHit, type SupportChatClient, type SupportConversation, type SupportMessage, type SupportMessengerItem, type SupportMessengerLabels, SupportMessengerProvider, type SupportMessengerProviderProps, type SupportMessengerTab, ThemeSwitcher, type ThemeSwitcherLabels, type ThemeSwitcherProps, type UseHlsPlaybackOptions, type UseHlsPlaybackResult, type UsePlaybackStatsOptions, type UseSearchHotkeyOptions, type UseSearchHotkeyResult, type UseSupportConversationOptions, type UseSupportConversationResult, VerifiedProfessionalBadge, type VerifiedProfessionalBadgeProps, VideoPlayer, type VideoPlayerLabels, type VideoPlayerProps, bubbleVariants, cn, createLiveHlsConfig, createSupportChatClient, createVodHlsConfig, defaultLanguages, describePlaybackError, fuzzyMatch, insertAtCaret, markerVariants, normalizeEmojiQuery, shouldRetryLiveEdge404, useDebouncedValue, useDebouncedValueStrict, useHlsPlayback, useLanguageContext, usePlaybackStats, useSearchHotkey, useSupportConversation, useSupportMessenger, useSupportMessengerOptional };
971
+ export { type AutoplayState, AvatarEditor, AvatarEditorDialog, type AvatarEditorDialogProps, type AvatarEditorProps, type BlocksLanguage, Bubble, BubbleContent, BubbleGroup, BubbleReactions, type ChatListMessage, ChatMessageList, type ChatMessageListProps, ConfirmDestructiveDialog, type ConfirmDestructiveDialogProps, type ConversationKind, type DescribedPlaybackError, type EmojiCategoryData, type EmojiCategoryKey, type EmojiDatum, EmojiInput, type EmojiInputProps, EmojiPicker, type EmojiPickerLabels, type EmojiPickerLocale, EmojiPickerPopover, type EmojiPickerPopoverProps, type EmojiPickerProps, type EmojiSkinTone, EmojiTextarea, type EmojiTextareaProps, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyState, type EmptyStateProps, EmptyTitle, ErrorState, ExpandableText, type ExpandableTextProps, type FeatureEntry, type FindOrCreateConversationInput, type HlsPlayerMode, ImageLightbox, type ImageLightboxLabels, type ImageLightboxProps, type Language, LanguageContext, type LanguageContextValue, LanguageSwitcher, type LanguageSwitcherLabels, type LanguageSwitcherProps, LoadingState, MEXICO_STATES, MEXICO_STATE_PATHS, Marker, MarkerContent, MarkerIcon, Message, MessageAvatar, MessageContent, MessageFooter, MessageGroup, MessageHeader, MessageScroller, MessageScrollerButton, MessageScrollerContent, MessageScrollerItem, MessageScrollerProvider, MessageScrollerViewport, MexicoMap, type MexicoMapProps, type MexicoState, type MexicoStateId, type OpenThreadRequest, OrgSwitcher, type OrgSwitcherLabels, type OrgSwitcherProps, type OrgSwitcherTenant, PhoneInput, type PhoneInputProps, type PlaybackErrorContext, type PlaybackErrorDetail, type PlaybackErrorKind, type PlaybackState, type PlaybackStats, type ProfessionalVerificationStatus, type QualityLevel, SearchCommand, type SearchCommandLabels, type SearchCommandProps, type SearchCommandSelection, type SearchHit, type SupportChatClient, type SupportConversation, type SupportMessage, type SupportMessengerItem, type SupportMessengerLabels, SupportMessengerProvider, type SupportMessengerProviderProps, type SupportMessengerTab, ThemeSwitcher, type ThemeSwitcherLabels, type ThemeSwitcherProps, type UseHlsPlaybackOptions, type UseHlsPlaybackResult, type UsePlaybackStatsOptions, type UseSearchHotkeyOptions, type UseSearchHotkeyResult, type UseSupportConversationOptions, type UseSupportConversationResult, VerifiedProfessionalBadge, type VerifiedProfessionalBadgeProps, VideoPlayer, type VideoPlayerLabels, type VideoPlayerProps, bubbleVariants, cn, createLiveHlsConfig, createSupportChatClient, createVodHlsConfig, defaultLanguages, describePlaybackError, fuzzyMatch, insertAtCaret, markerVariants, normalizeEmojiQuery, shouldRetryLiveEdge404, useDebouncedValue, useDebouncedValueStrict, useHlsPlayback, useLanguageContext, usePlaybackStats, useSearchHotkey, useSupportConversation, useSupportMessenger, useSupportMessengerOptional };
package/dist/index.d.ts CHANGED
@@ -85,6 +85,15 @@ type ConfirmDestructiveDialogProps = {
85
85
  */
86
86
  declare function ConfirmDestructiveDialog({ open, onOpenChange, title, description, confirmLabel, cancelLabel, onConfirm, }: ConfirmDestructiveDialogProps): React.JSX.Element;
87
87
 
88
+ type ExpandableTextProps = {
89
+ children: ReactNode;
90
+ expandLabel: string;
91
+ collapseLabel: string;
92
+ className?: string;
93
+ textClassName?: string;
94
+ };
95
+ declare function ExpandableText({ children, expandLabel, collapseLabel, className, textClassName, }: ExpandableTextProps): React.JSX.Element;
96
+
88
97
  declare function Empty({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
89
98
  declare function EmptyHeader({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
90
99
  declare const emptyMediaVariants: (props?: ({
@@ -95,6 +104,26 @@ declare function EmptyTitle({ className, ...props }: React.ComponentProps<"div">
95
104
  declare function EmptyDescription({ className, ...props }: React.ComponentProps<"p">): React.JSX.Element;
96
105
  declare function EmptyContent({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
97
106
 
107
+ type ImageLightboxLabels = {
108
+ ariaLabel?: string;
109
+ close?: string;
110
+ previous?: string;
111
+ next?: string;
112
+ };
113
+ type ImageLightboxProps = {
114
+ images: string[];
115
+ index: number;
116
+ onIndexChange: (index: number) => void;
117
+ onClose: () => void;
118
+ labels?: ImageLightboxLabels;
119
+ };
120
+ /**
121
+ * Fullscreen image gallery viewer. Portal overlay with Esc/click-to-close,
122
+ * arrow-key navigation, wheel/pinch zoom, and pan when zoomed. Locks page
123
+ * scroll while mounted.
124
+ */
125
+ declare function ImageLightbox({ images, index, onIndexChange, onClose, labels, }: ImageLightboxProps): React.ReactPortal;
126
+
98
127
  type ThemeSwitcherLabels = {
99
128
  /** Tooltip label for the theme switcher */
100
129
  theme?: string;
@@ -939,4 +968,4 @@ declare function useSupportConversation({ client, getWsUrl, conversationId: conv
939
968
 
940
969
  declare function cn(...inputs: ClassValue[]): string;
941
970
 
942
- export { type AutoplayState, AvatarEditor, AvatarEditorDialog, type AvatarEditorDialogProps, type AvatarEditorProps, type BlocksLanguage, Bubble, BubbleContent, BubbleGroup, BubbleReactions, type ChatListMessage, ChatMessageList, type ChatMessageListProps, ConfirmDestructiveDialog, type ConfirmDestructiveDialogProps, type ConversationKind, type DescribedPlaybackError, type EmojiCategoryData, type EmojiCategoryKey, type EmojiDatum, EmojiInput, type EmojiInputProps, EmojiPicker, type EmojiPickerLabels, type EmojiPickerLocale, EmojiPickerPopover, type EmojiPickerPopoverProps, type EmojiPickerProps, type EmojiSkinTone, EmojiTextarea, type EmojiTextareaProps, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyState, type EmptyStateProps, EmptyTitle, ErrorState, type FeatureEntry, type FindOrCreateConversationInput, type HlsPlayerMode, type Language, LanguageContext, type LanguageContextValue, LanguageSwitcher, type LanguageSwitcherLabels, type LanguageSwitcherProps, LoadingState, MEXICO_STATES, MEXICO_STATE_PATHS, Marker, MarkerContent, MarkerIcon, Message, MessageAvatar, MessageContent, MessageFooter, MessageGroup, MessageHeader, MessageScroller, MessageScrollerButton, MessageScrollerContent, MessageScrollerItem, MessageScrollerProvider, MessageScrollerViewport, MexicoMap, type MexicoMapProps, type MexicoState, type MexicoStateId, type OpenThreadRequest, OrgSwitcher, type OrgSwitcherLabels, type OrgSwitcherProps, type OrgSwitcherTenant, PhoneInput, type PhoneInputProps, type PlaybackErrorContext, type PlaybackErrorDetail, type PlaybackErrorKind, type PlaybackState, type PlaybackStats, type ProfessionalVerificationStatus, type QualityLevel, SearchCommand, type SearchCommandLabels, type SearchCommandProps, type SearchCommandSelection, type SearchHit, type SupportChatClient, type SupportConversation, type SupportMessage, type SupportMessengerItem, type SupportMessengerLabels, SupportMessengerProvider, type SupportMessengerProviderProps, type SupportMessengerTab, ThemeSwitcher, type ThemeSwitcherLabels, type ThemeSwitcherProps, type UseHlsPlaybackOptions, type UseHlsPlaybackResult, type UsePlaybackStatsOptions, type UseSearchHotkeyOptions, type UseSearchHotkeyResult, type UseSupportConversationOptions, type UseSupportConversationResult, VerifiedProfessionalBadge, type VerifiedProfessionalBadgeProps, VideoPlayer, type VideoPlayerLabels, type VideoPlayerProps, bubbleVariants, cn, createLiveHlsConfig, createSupportChatClient, createVodHlsConfig, defaultLanguages, describePlaybackError, fuzzyMatch, insertAtCaret, markerVariants, normalizeEmojiQuery, shouldRetryLiveEdge404, useDebouncedValue, useDebouncedValueStrict, useHlsPlayback, useLanguageContext, usePlaybackStats, useSearchHotkey, useSupportConversation, useSupportMessenger, useSupportMessengerOptional };
971
+ export { type AutoplayState, AvatarEditor, AvatarEditorDialog, type AvatarEditorDialogProps, type AvatarEditorProps, type BlocksLanguage, Bubble, BubbleContent, BubbleGroup, BubbleReactions, type ChatListMessage, ChatMessageList, type ChatMessageListProps, ConfirmDestructiveDialog, type ConfirmDestructiveDialogProps, type ConversationKind, type DescribedPlaybackError, type EmojiCategoryData, type EmojiCategoryKey, type EmojiDatum, EmojiInput, type EmojiInputProps, EmojiPicker, type EmojiPickerLabels, type EmojiPickerLocale, EmojiPickerPopover, type EmojiPickerPopoverProps, type EmojiPickerProps, type EmojiSkinTone, EmojiTextarea, type EmojiTextareaProps, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyState, type EmptyStateProps, EmptyTitle, ErrorState, ExpandableText, type ExpandableTextProps, type FeatureEntry, type FindOrCreateConversationInput, type HlsPlayerMode, ImageLightbox, type ImageLightboxLabels, type ImageLightboxProps, type Language, LanguageContext, type LanguageContextValue, LanguageSwitcher, type LanguageSwitcherLabels, type LanguageSwitcherProps, LoadingState, MEXICO_STATES, MEXICO_STATE_PATHS, Marker, MarkerContent, MarkerIcon, Message, MessageAvatar, MessageContent, MessageFooter, MessageGroup, MessageHeader, MessageScroller, MessageScrollerButton, MessageScrollerContent, MessageScrollerItem, MessageScrollerProvider, MessageScrollerViewport, MexicoMap, type MexicoMapProps, type MexicoState, type MexicoStateId, type OpenThreadRequest, OrgSwitcher, type OrgSwitcherLabels, type OrgSwitcherProps, type OrgSwitcherTenant, PhoneInput, type PhoneInputProps, type PlaybackErrorContext, type PlaybackErrorDetail, type PlaybackErrorKind, type PlaybackState, type PlaybackStats, type ProfessionalVerificationStatus, type QualityLevel, SearchCommand, type SearchCommandLabels, type SearchCommandProps, type SearchCommandSelection, type SearchHit, type SupportChatClient, type SupportConversation, type SupportMessage, type SupportMessengerItem, type SupportMessengerLabels, SupportMessengerProvider, type SupportMessengerProviderProps, type SupportMessengerTab, ThemeSwitcher, type ThemeSwitcherLabels, type ThemeSwitcherProps, type UseHlsPlaybackOptions, type UseHlsPlaybackResult, type UsePlaybackStatsOptions, type UseSearchHotkeyOptions, type UseSearchHotkeyResult, type UseSupportConversationOptions, type UseSupportConversationResult, VerifiedProfessionalBadge, type VerifiedProfessionalBadgeProps, VideoPlayer, type VideoPlayerLabels, type VideoPlayerProps, bubbleVariants, cn, createLiveHlsConfig, createSupportChatClient, createVodHlsConfig, defaultLanguages, describePlaybackError, fuzzyMatch, insertAtCaret, markerVariants, normalizeEmojiQuery, shouldRetryLiveEdge404, useDebouncedValue, useDebouncedValueStrict, useHlsPlayback, useLanguageContext, usePlaybackStats, useSearchHotkey, useSupportConversation, useSupportMessenger, useSupportMessengerOptional };
package/dist/index.js CHANGED
@@ -1,13 +1,14 @@
1
1
  "use client";
2
2
  import * as React6 from 'react';
3
- import { createContext, useContext, useState, useCallback, useEffect, useRef, useMemo } from 'react';
4
- import { ChevronsUpDown, CheckIcon, Smile, SearchIcon, Search, Clock, Flag, Hash, Lightbulb, Trophy, Plane, Apple, Leaf, Hand, Loader2, AlertTriangle, Inbox, Monitor, Sun, Moon, Building2, Check, Plus, Languages, Upload, Move, ZoomOut, ZoomIn, RotateCcw, RotateCw, Grid3X3, RefreshCw, X, User, Pencil, Play, AlertCircle, VolumeX, Pause, Volume1, Volume2, Settings, PictureInPicture2, Minimize, Maximize, BadgeCheck, ArrowDownIcon, MessageCircleDashedIcon, MessageCircle, XIcon, ChevronLeft } from 'lucide-react';
3
+ import { createContext, useContext, useState, useRef, useEffect, useLayoutEffect, useCallback, useMemo } from 'react';
4
+ import { ChevronsUpDown, CheckIcon, Smile, SearchIcon, Search, Clock, Flag, Hash, Lightbulb, Trophy, Plane, Apple, Leaf, Hand, Loader2, AlertTriangle, Inbox, X, ChevronLeft, ChevronRight, Monitor, Sun, Moon, Building2, Check, Plus, Languages, Upload, Move, ZoomOut, ZoomIn, RotateCcw, RotateCw, Grid3X3, RefreshCw, User, Pencil, Play, AlertCircle, VolumeX, Pause, Volume1, Volume2, Settings, PictureInPicture2, Minimize, Maximize, BadgeCheck, ArrowDownIcon, MessageCircleDashedIcon, MessageCircle, XIcon } from 'lucide-react';
5
5
  import { clsx } from 'clsx';
6
6
  import { twMerge } from 'tailwind-merge';
7
7
  import { cva } from 'class-variance-authority';
8
8
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
9
9
  import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';
10
10
  import { Slot } from '@radix-ui/react-slot';
11
+ import { createPortal } from 'react-dom';
11
12
  import { useTheme } from 'next-themes';
12
13
  import { useReducedMotion, AnimatePresence, motion } from 'framer-motion';
13
14
  import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
@@ -424,6 +425,363 @@ function ConfirmDestructiveDialog({
424
425
  ] })
425
426
  ] }) });
426
427
  }
428
+ var COLLAPSED_MAX_HEIGHT_REM = 11;
429
+ function ExpandableText({
430
+ children,
431
+ expandLabel,
432
+ collapseLabel,
433
+ className,
434
+ textClassName
435
+ }) {
436
+ const [expanded, setExpanded] = useState(false);
437
+ const [overflowing, setOverflowing] = useState(false);
438
+ const contentRef = useRef(null);
439
+ useEffect(() => {
440
+ setExpanded(false);
441
+ }, [children]);
442
+ useLayoutEffect(() => {
443
+ const el = contentRef.current;
444
+ if (!el) return;
445
+ const measure = () => {
446
+ const rootFontSize = Number.parseFloat(
447
+ getComputedStyle(document.documentElement).fontSize
448
+ );
449
+ const maxPx = COLLAPSED_MAX_HEIGHT_REM * (rootFontSize || 16);
450
+ setOverflowing(el.scrollHeight > maxPx + 1);
451
+ };
452
+ measure();
453
+ const observer = new ResizeObserver(measure);
454
+ observer.observe(el);
455
+ return () => observer.disconnect();
456
+ }, [children]);
457
+ const collapsed = !expanded && overflowing;
458
+ return /* @__PURE__ */ jsxs("div", { className: cn("space-y-1", className), children: [
459
+ /* @__PURE__ */ jsx(
460
+ "div",
461
+ {
462
+ className: cn(
463
+ collapsed && "max-h-[11rem] overflow-hidden scroll-fade-b"
464
+ ),
465
+ children: /* @__PURE__ */ jsx(
466
+ "p",
467
+ {
468
+ ref: contentRef,
469
+ className: cn(
470
+ "whitespace-pre-wrap text-sm leading-relaxed",
471
+ textClassName
472
+ ),
473
+ children
474
+ }
475
+ )
476
+ }
477
+ ),
478
+ overflowing ? /* @__PURE__ */ jsx(
479
+ "button",
480
+ {
481
+ type: "button",
482
+ className: "text-sm font-medium text-primary underline-offset-4 hover:underline focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 rounded-sm",
483
+ "aria-expanded": expanded,
484
+ onClick: () => setExpanded((prev) => !prev),
485
+ children: expanded ? collapseLabel : expandLabel
486
+ }
487
+ ) : null
488
+ ] });
489
+ }
490
+ var MIN_SCALE = 1;
491
+ var MAX_SCALE = 4;
492
+ var DOUBLE_TAP_MS = 300;
493
+ var IDENTITY = { scale: 1, tx: 0, ty: 0 };
494
+ function clamp(value, min, max) {
495
+ return Math.min(max, Math.max(min, value));
496
+ }
497
+ function zoomToward(prev, nextScale, originX, originY) {
498
+ const scale = clamp(nextScale, MIN_SCALE, MAX_SCALE);
499
+ if (scale === MIN_SCALE) return IDENTITY;
500
+ const ratio = scale / prev.scale;
501
+ return {
502
+ scale,
503
+ tx: originX - (originX - prev.tx) * ratio,
504
+ ty: originY - (originY - prev.ty) * ratio
505
+ };
506
+ }
507
+ function pointerDistance(a, b) {
508
+ return Math.hypot(b.x - a.x, b.y - a.y);
509
+ }
510
+ function ImageLightbox({
511
+ images,
512
+ index,
513
+ onIndexChange,
514
+ onClose,
515
+ labels
516
+ }) {
517
+ const ariaLabel = labels?.ariaLabel ?? "Visor de im\xE1genes";
518
+ const closeLabel = labels?.close ?? "Cerrar";
519
+ const previousLabel = labels?.previous ?? "Anterior";
520
+ const nextLabel = labels?.next ?? "Siguiente";
521
+ const hasMultiple = images.length > 1;
522
+ const [transform, setTransform] = useState(IDENTITY);
523
+ const transformRef = useRef(transform);
524
+ transformRef.current = transform;
525
+ const stageRef = useRef(null);
526
+ const pointersRef = useRef(/* @__PURE__ */ new Map());
527
+ const pinchStartRef = useRef(null);
528
+ const panRef = useRef(null);
529
+ const lastTapRef = useRef(
530
+ null
531
+ );
532
+ const resetZoom = useCallback(() => {
533
+ setTransform(IDENTITY);
534
+ }, []);
535
+ useEffect(() => {
536
+ resetZoom();
537
+ }, [index, images[index], resetZoom]);
538
+ function goPrev() {
539
+ onIndexChange((index - 1 + images.length) % images.length);
540
+ }
541
+ function goNext() {
542
+ onIndexChange((index + 1) % images.length);
543
+ }
544
+ useEffect(() => {
545
+ function handleKeyDown(e) {
546
+ if (e.key === "Escape") {
547
+ onClose();
548
+ return;
549
+ }
550
+ if (!hasMultiple) return;
551
+ if (e.key === "ArrowLeft") {
552
+ onIndexChange((index - 1 + images.length) % images.length);
553
+ } else if (e.key === "ArrowRight") {
554
+ onIndexChange((index + 1) % images.length);
555
+ }
556
+ }
557
+ window.addEventListener("keydown", handleKeyDown);
558
+ return () => window.removeEventListener("keydown", handleKeyDown);
559
+ }, [index, images.length, hasMultiple, onClose, onIndexChange]);
560
+ useEffect(() => {
561
+ const previousOverflow = document.body.style.overflow;
562
+ document.body.style.overflow = "hidden";
563
+ return () => {
564
+ document.body.style.overflow = previousOverflow;
565
+ };
566
+ }, []);
567
+ const stageOrigin = useCallback((clientX, clientY) => {
568
+ const stage = stageRef.current;
569
+ if (!stage) return { x: 0, y: 0 };
570
+ const rect = stage.getBoundingClientRect();
571
+ return {
572
+ x: clientX - rect.left - rect.width / 2,
573
+ y: clientY - rect.top - rect.height / 2
574
+ };
575
+ }, []);
576
+ useEffect(() => {
577
+ const stage = stageRef.current;
578
+ if (!stage) return;
579
+ const handleWheel = (e) => {
580
+ e.preventDefault();
581
+ e.stopPropagation();
582
+ const prev = transformRef.current;
583
+ const factor = e.deltaY > 0 ? 0.9 : 1.1;
584
+ const { x, y } = stageOrigin(e.clientX, e.clientY);
585
+ setTransform(zoomToward(prev, prev.scale * factor, x, y));
586
+ };
587
+ stage.addEventListener("wheel", handleWheel, { passive: false });
588
+ return () => stage.removeEventListener("wheel", handleWheel);
589
+ }, [stageOrigin]);
590
+ function beginPinch() {
591
+ const pts = [...pointersRef.current.values()];
592
+ const [a, b] = pts;
593
+ if (!a || !b) return;
594
+ const midX = (a.x + b.x) / 2;
595
+ const midY = (a.y + b.y) / 2;
596
+ const { x, y } = stageOrigin(midX, midY);
597
+ pinchStartRef.current = {
598
+ distance: Math.max(pointerDistance(a, b), 1),
599
+ originX: x,
600
+ originY: y,
601
+ transform: { ...transformRef.current }
602
+ };
603
+ panRef.current = null;
604
+ }
605
+ function onPointerDown(e) {
606
+ e.stopPropagation();
607
+ const stage = stageRef.current;
608
+ if (!stage) return;
609
+ stage.setPointerCapture(e.pointerId);
610
+ pointersRef.current.set(e.pointerId, { x: e.clientX, y: e.clientY });
611
+ if (pointersRef.current.size === 2) {
612
+ beginPinch();
613
+ return;
614
+ }
615
+ if (transformRef.current.scale > MIN_SCALE) {
616
+ panRef.current = {
617
+ pointerId: e.pointerId,
618
+ startX: e.clientX,
619
+ startY: e.clientY,
620
+ originTx: transformRef.current.tx,
621
+ originTy: transformRef.current.ty,
622
+ moved: false
623
+ };
624
+ }
625
+ }
626
+ function onPointerMove(e) {
627
+ if (!pointersRef.current.has(e.pointerId)) return;
628
+ pointersRef.current.set(e.pointerId, { x: e.clientX, y: e.clientY });
629
+ const pinchStart = pinchStartRef.current;
630
+ if (pointersRef.current.size >= 2 && pinchStart) {
631
+ const pts = [...pointersRef.current.values()];
632
+ const [a, b] = pts;
633
+ if (!a || !b) return;
634
+ const distance = Math.max(pointerDistance(a, b), 1);
635
+ const nextScale = pinchStart.transform.scale * (distance / pinchStart.distance);
636
+ setTransform(
637
+ zoomToward(
638
+ pinchStart.transform,
639
+ nextScale,
640
+ pinchStart.originX,
641
+ pinchStart.originY
642
+ )
643
+ );
644
+ return;
645
+ }
646
+ const pan = panRef.current;
647
+ if (pan && pan.pointerId === e.pointerId) {
648
+ const dx = e.clientX - pan.startX;
649
+ const dy = e.clientY - pan.startY;
650
+ if (Math.abs(dx) > 2 || Math.abs(dy) > 2) pan.moved = true;
651
+ setTransform((prev) => ({
652
+ ...prev,
653
+ tx: pan.originTx + dx,
654
+ ty: pan.originTy + dy
655
+ }));
656
+ }
657
+ }
658
+ function onPointerUp(e) {
659
+ const stage = stageRef.current;
660
+ if (stage?.hasPointerCapture(e.pointerId)) {
661
+ stage.releasePointerCapture(e.pointerId);
662
+ }
663
+ pointersRef.current.delete(e.pointerId);
664
+ if (pointersRef.current.size < 2) {
665
+ pinchStartRef.current = null;
666
+ }
667
+ if (pointersRef.current.size === 1) {
668
+ const remaining = [...pointersRef.current.entries()][0];
669
+ if (remaining && transformRef.current.scale > MIN_SCALE) {
670
+ const [pointerId, point] = remaining;
671
+ panRef.current = {
672
+ pointerId,
673
+ startX: point.x,
674
+ startY: point.y,
675
+ originTx: transformRef.current.tx,
676
+ originTy: transformRef.current.ty,
677
+ moved: true
678
+ };
679
+ }
680
+ }
681
+ const pan = panRef.current;
682
+ if (pan && pan.pointerId === e.pointerId) {
683
+ const wasMoved = pan.moved;
684
+ panRef.current = null;
685
+ if (wasMoved) return;
686
+ }
687
+ if (pointersRef.current.size === 0 && e.button === 0) {
688
+ const now = Date.now();
689
+ const last = lastTapRef.current;
690
+ if (last && now - last.time < DOUBLE_TAP_MS && Math.hypot(e.clientX - last.x, e.clientY - last.y) < 24) {
691
+ lastTapRef.current = null;
692
+ resetZoom();
693
+ return;
694
+ }
695
+ lastTapRef.current = { time: now, x: e.clientX, y: e.clientY };
696
+ }
697
+ }
698
+ function stopDialogClose(e) {
699
+ e.stopPropagation();
700
+ }
701
+ const { scale, tx, ty } = transform;
702
+ return createPortal(
703
+ /* @__PURE__ */ jsxs(
704
+ "div",
705
+ {
706
+ className: "fixed inset-x-0 top-0 z-50 flex h-dvh items-center justify-center bg-black/90 p-4",
707
+ onClick: onClose,
708
+ role: "dialog",
709
+ "aria-modal": "true",
710
+ "aria-label": ariaLabel,
711
+ children: [
712
+ /* @__PURE__ */ jsx(
713
+ "button",
714
+ {
715
+ type: "button",
716
+ onClick: onClose,
717
+ "aria-label": closeLabel,
718
+ className: "absolute right-4 top-4 z-10 rounded-full bg-black/50 p-2 text-white transition-colors hover:bg-black/70",
719
+ children: /* @__PURE__ */ jsx(X, { className: "h-5 w-5" })
720
+ }
721
+ ),
722
+ hasMultiple && /* @__PURE__ */ jsx(
723
+ "button",
724
+ {
725
+ type: "button",
726
+ onClick: (e) => {
727
+ e.stopPropagation();
728
+ goPrev();
729
+ },
730
+ "aria-label": previousLabel,
731
+ className: "absolute left-4 top-1/2 z-10 -translate-y-1/2 rounded-full bg-black/50 p-2 text-white transition-colors hover:bg-black/70",
732
+ children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-6 w-6" })
733
+ }
734
+ ),
735
+ /* @__PURE__ */ jsx(
736
+ "div",
737
+ {
738
+ ref: stageRef,
739
+ className: "relative flex max-h-full max-w-full touch-none items-center justify-center",
740
+ "data-scale": scale,
741
+ onClick: stopDialogClose,
742
+ onPointerDown,
743
+ onPointerMove,
744
+ onPointerUp,
745
+ onPointerCancel: onPointerUp,
746
+ children: /* @__PURE__ */ jsx(
747
+ "img",
748
+ {
749
+ src: images[index],
750
+ alt: "",
751
+ draggable: false,
752
+ className: "max-h-[calc(100dvh-2rem)] max-w-full select-none rounded-lg object-contain",
753
+ style: {
754
+ transform: `translate(${tx}px, ${ty}px) scale(${scale})`,
755
+ cursor: scale > MIN_SCALE ? "grab" : "default"
756
+ }
757
+ }
758
+ )
759
+ }
760
+ ),
761
+ hasMultiple && /* @__PURE__ */ jsx(
762
+ "button",
763
+ {
764
+ type: "button",
765
+ onClick: (e) => {
766
+ e.stopPropagation();
767
+ goNext();
768
+ },
769
+ "aria-label": nextLabel,
770
+ className: "absolute right-4 top-1/2 z-10 -translate-y-1/2 rounded-full bg-black/50 p-2 text-white transition-colors hover:bg-black/70",
771
+ children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-6 w-6" })
772
+ }
773
+ ),
774
+ hasMultiple && /* @__PURE__ */ jsxs("div", { className: "absolute bottom-4 left-1/2 z-10 -translate-x-1/2 rounded-full bg-black/50 px-3 py-1 text-xs text-white", children: [
775
+ index + 1,
776
+ " / ",
777
+ images.length
778
+ ] })
779
+ ]
780
+ }
781
+ ),
782
+ document.body
783
+ );
784
+ }
427
785
  var miniMenuContentClassName = "max-h-none overflow-x-visible overflow-y-visible";
428
786
  var miniMenuContentDefaults = {
429
787
  sideOffset: 8,
@@ -5670,6 +6028,6 @@ function createSupportChatClient(basePath = "/api/chat-svc") {
5670
6028
  };
5671
6029
  }
5672
6030
 
5673
- export { AvatarEditor, AvatarEditorDialog, Bubble, BubbleContent, BubbleGroup, BubbleReactions, ChatMessageList, ConfirmDestructiveDialog, EmojiInput, EmojiPicker, EmojiPickerPopover, EmojiTextarea, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyState, EmptyTitle, ErrorState, LanguageContext, LanguageSwitcher, LoadingState, MEXICO_STATES, MEXICO_STATE_PATHS, Marker, MarkerContent, MarkerIcon, Message, MessageAvatar, MessageContent, MessageFooter, MessageGroup, MessageHeader, MessageScroller, MessageScrollerButton, MessageScrollerContent, MessageScrollerItem, MessageScrollerProvider, MessageScrollerViewport, MexicoMap, OrgSwitcher, PhoneInput, SearchCommand, SupportMessengerProvider, ThemeSwitcher, VerifiedProfessionalBadge, VideoPlayer, avatarFallbackStyle, bubbleVariants, cn, createLiveHlsConfig, createSupportChatClient, createVodHlsConfig, defaultLanguages, describePlaybackError, fuzzyMatch, getAvatarColors, getInitials, insertAtCaret, markerVariants, normalizeEmojiQuery, shouldRetryLiveEdge404, useDebouncedValue, useDebouncedValueStrict, useHlsPlayback, useLanguageContext, usePlaybackStats, useSearchHotkey, useSupportConversation, useSupportMessenger, useSupportMessengerOptional };
6031
+ export { AvatarEditor, AvatarEditorDialog, Bubble, BubbleContent, BubbleGroup, BubbleReactions, ChatMessageList, ConfirmDestructiveDialog, EmojiInput, EmojiPicker, EmojiPickerPopover, EmojiTextarea, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyState, EmptyTitle, ErrorState, ExpandableText, ImageLightbox, LanguageContext, LanguageSwitcher, LoadingState, MEXICO_STATES, MEXICO_STATE_PATHS, Marker, MarkerContent, MarkerIcon, Message, MessageAvatar, MessageContent, MessageFooter, MessageGroup, MessageHeader, MessageScroller, MessageScrollerButton, MessageScrollerContent, MessageScrollerItem, MessageScrollerProvider, MessageScrollerViewport, MexicoMap, OrgSwitcher, PhoneInput, SearchCommand, SupportMessengerProvider, ThemeSwitcher, VerifiedProfessionalBadge, VideoPlayer, avatarFallbackStyle, bubbleVariants, cn, createLiveHlsConfig, createSupportChatClient, createVodHlsConfig, defaultLanguages, describePlaybackError, fuzzyMatch, getAvatarColors, getInitials, insertAtCaret, markerVariants, normalizeEmojiQuery, shouldRetryLiveEdge404, useDebouncedValue, useDebouncedValueStrict, useHlsPlayback, useLanguageContext, usePlaybackStats, useSearchHotkey, useSupportConversation, useSupportMessenger, useSupportMessengerOptional };
5674
6032
  //# sourceMappingURL=index.js.map
5675
6033
  //# sourceMappingURL=index.js.map