@marketrix.ai/widget 4.0.110 → 4.0.112
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/src/components/WidgetRoot.d.ts +6 -0
- package/dist/src/components/base/Avatar.d.ts +1 -1
- package/dist/src/components/base/Button.d.ts +1 -1
- package/dist/src/components/base/Flex.d.ts +2 -1
- package/dist/src/components/base/Icon.d.ts +2 -1
- package/dist/src/components/base/IconButton.d.ts +1 -1
- package/dist/src/components/base/Spinner.d.ts +1 -1
- package/dist/src/components/base/Surface.d.ts +9 -15
- package/dist/src/components/base/Text.d.ts +1 -1
- package/dist/src/components/base/layoutProps.d.ts +10 -12
- package/dist/src/components/blocks/ChatInput.d.ts +2 -1
- package/dist/src/components/blocks/Notifications.d.ts +3 -2
- package/dist/src/components/blocks/WidgetDialog.d.ts +2 -1
- package/dist/src/components/blocks/WidgetFab.d.ts +31 -0
- package/dist/src/components/navigation/MessengerShell.d.ts +18 -0
- package/dist/src/components/views/ChatView.d.ts +38 -0
- package/dist/src/sdk/contracts/common.d.ts +29 -0
- package/dist/src/services/BrowserToolService.d.ts +1 -16
- package/dist/src/utils/dom.d.ts +19 -21
- package/dist/widget.mjs +23 -23
- package/package.json +1 -1
- package/dist/src/hooks/useDragSnap.d.ts +0 -34
- package/dist/src/hooks/useFocusTrap.d.ts +0 -25
- package/dist/src/hooks/useResize.d.ts +0 -14
- package/dist/src/hooks/useScreenShare.d.ts +0 -22
- package/dist/src/hooks/useScrollLock.d.ts +0 -1
|
@@ -16,6 +16,12 @@
|
|
|
16
16
|
* carrying every tenant token as an inline style, which is why it, not the shadow root, is the portal container —
|
|
17
17
|
* a portal landing outside it falls back to `index.css`'s hardcoded palette. `onRetry` is spread in only when
|
|
18
18
|
* `StreamClient.canReconnect()`, so a terminal failure offers no Retry button rather than one that does nothing.
|
|
19
|
+
*
|
|
20
|
+
* `useScrollLock` (below) hides `overflow` on html and body while `state.isOpen`, but only under
|
|
21
|
+
* MOBILE_MAX_WIDTH, where the open panel covers the page; on desktop the host page keeps scrolling. It
|
|
22
|
+
* restores the exact previous values on release. Hand-rolled on purpose, alongside `MessengerShell`'s
|
|
23
|
+
* `useFocusTrap`: both serve a non-modal panel that is not a Dialog, and Base UI exposes no standalone
|
|
24
|
+
* scroll-lock — reaching one by making the panel a Dialog would inert the customer's page.
|
|
19
25
|
*/
|
|
20
26
|
import React from 'react';
|
|
21
27
|
import type { ValidWidgetConfig } from '../types';
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import type { ComponentPropsWithRef } from 'react';
|
|
6
6
|
import { type RadiusToken, type ShadowToken } from '../../design-system/component-tokens';
|
|
7
7
|
type AvatarSize = 'sm' | 'md' | 'lg';
|
|
8
|
-
|
|
8
|
+
interface AvatarProps extends Omit<ComponentPropsWithRef<'img'>, 'size'> {
|
|
9
9
|
src: string;
|
|
10
10
|
alt: string;
|
|
11
11
|
elevation?: ShadowToken;
|
|
@@ -3,7 +3,7 @@ import { type ShadowToken } from '../../design-system/component-tokens';
|
|
|
3
3
|
type ButtonVariant = 'primary' | 'secondary' | 'ghost' | 'bare' | 'chip' | 'tab';
|
|
4
4
|
type ButtonSize = 'sm' | 'md';
|
|
5
5
|
type ButtonShape = 'default' | 'pill';
|
|
6
|
-
|
|
6
|
+
interface ButtonProps extends ComponentPropsWithRef<'button'> {
|
|
7
7
|
elevation?: ShadowToken;
|
|
8
8
|
size?: ButtonSize;
|
|
9
9
|
shape?: ButtonShape;
|
|
@@ -12,10 +12,11 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import { type ReactNode } from 'react';
|
|
14
14
|
import { type SurfaceProps } from './Surface';
|
|
15
|
-
|
|
15
|
+
interface FlexProps extends SurfaceProps {
|
|
16
16
|
direction?: 'row' | 'column';
|
|
17
17
|
children?: ReactNode;
|
|
18
18
|
}
|
|
19
19
|
export type StackProps = Omit<FlexProps, 'direction'>;
|
|
20
20
|
export declare const Flex: import("react").ForwardRefExoticComponent<FlexProps & import("react").RefAttributes<HTMLElement>>;
|
|
21
21
|
export declare const Stack: import("react").ForwardRefExoticComponent<StackProps & import("react").RefAttributes<HTMLElement>>;
|
|
22
|
+
export {};
|
|
@@ -12,9 +12,10 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import type { ComponentPropsWithRef } from 'react';
|
|
14
14
|
import { type IconName } from './icons';
|
|
15
|
-
|
|
15
|
+
interface IconProps extends ComponentPropsWithRef<'svg'> {
|
|
16
16
|
name: IconName;
|
|
17
17
|
size?: number;
|
|
18
18
|
className?: string;
|
|
19
19
|
}
|
|
20
20
|
export declare function Icon({ name, size, className, ref, ...props }: IconProps): import("react").JSX.Element | null;
|
|
21
|
+
export {};
|
|
@@ -6,7 +6,7 @@ import type { ComponentPropsWithRef } from 'react';
|
|
|
6
6
|
import { type TextTone } from '../../design-system/component-tokens';
|
|
7
7
|
type IconButtonVariant = 'primary' | 'secondary' | 'ghost';
|
|
8
8
|
type IconButtonSize = 'xs' | 'sm';
|
|
9
|
-
|
|
9
|
+
interface IconButtonProps extends ComponentPropsWithRef<'button'> {
|
|
10
10
|
variant?: IconButtonVariant;
|
|
11
11
|
size?: IconButtonSize;
|
|
12
12
|
tone?: TextTone;
|
|
@@ -1,27 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `Surface` is the canonical container primitive: a polymorphic `forwardRef` element (`as`, default
|
|
3
3
|
* `div`) that composes the shared layout-token vocabulary with a `background` token, a `SHADOW`
|
|
4
|
-
* `elevation` token and a `paddingPreset`, all emitted as inline style
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* `elevation` token and a `paddingPreset`, all emitted as inline style — the `default`/`none` lookup
|
|
5
|
+
* entries are empty, so a bare `Surface` is a plain element. `className` is dropped from the host
|
|
6
|
+
* attributes and re-declared because it is INTERNAL to `blocks/`: layout props are the styling API
|
|
7
|
+
* everywhere else, and the only legitimate classes are the `index.css` hooks the block components key on.
|
|
8
8
|
*
|
|
9
9
|
* `floatingCard` is a `variant` shorthand for the card-background/border/card-elevation/card-padding/xl-
|
|
10
10
|
* rounded/margin bundle both `HomeView`'s recent-conversation card and `ChatView`'s composer card use —
|
|
11
11
|
* the margin lives in `variantStyles` since both call sites want it, while `ChatView`'s extra
|
|
12
12
|
* `marginTop: 'auto'` stays an override on its own `style` prop rather than joining the preset.
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* `
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* the caller's own `style` last, so an inline style always wins. `Flex` depends on that tail
|
|
20
|
-
* position, resolving `display` itself because `resolveLayoutStyle` is applied ahead of it.
|
|
21
|
-
*
|
|
22
|
-
* `resolveLayoutStyle` is handed the whole `props` (it reads only layout keys), while the DOM spread
|
|
23
|
-
* goes through `stripLayoutProps` — a layout token left on the props bag reaches the element as an
|
|
24
|
-
* unknown attribute.
|
|
14
|
+
* Style order is fixed and load-bearing: background → padding preset → elevation → layout props → the
|
|
15
|
+
* caller's own `style` last, so an inline style always wins; `Flex` depends on that tail position,
|
|
16
|
+
* resolving `display` itself because `resolveLayoutStyle` is applied ahead of it. `resolveLayoutStyle`
|
|
17
|
+
* is handed the whole `props` (it reads only layout keys), while the DOM spread goes through
|
|
18
|
+
* `stripLayoutProps` — a layout token left on the props bag reaches the element as an unknown attribute.
|
|
25
19
|
*/
|
|
26
20
|
import { type ElementType } from 'react';
|
|
27
21
|
import { type ShadowToken } from '../../design-system/component-tokens';
|
|
@@ -21,7 +21,7 @@ type TextVariant = 'default' | 'muted' | 'faint';
|
|
|
21
21
|
type TextSize = 'xxs' | 'xs' | 'sm' | 'lg';
|
|
22
22
|
type TextWeight = 'normal' | 'medium' | 'semibold';
|
|
23
23
|
type TextAlign = 'center' | 'right';
|
|
24
|
-
|
|
24
|
+
interface TextProps extends React.HTMLAttributes<HTMLElement> {
|
|
25
25
|
as?: ElementType;
|
|
26
26
|
block?: boolean;
|
|
27
27
|
inheritColor?: boolean;
|
|
@@ -3,25 +3,23 @@
|
|
|
3
3
|
* `resolveLayoutStyle` which reduces them to a `CSSProperties` object, and `stripLayoutProps` which
|
|
4
4
|
* removes them from a props bag so the remainder can be spread onto a DOM element. `SPACING_SCALE` is
|
|
5
5
|
* the exported `SpacingToken`→pixel table, declared smallest-first so a token name orders the same way
|
|
6
|
-
* as the pixels it emits
|
|
7
|
-
* and `BORDER_SIDE` are the private lookups for the remaining token families.
|
|
6
|
+
* as the pixels it emits.
|
|
8
7
|
*
|
|
9
8
|
* Layout props resolve to a style object rather than class names: as classes they were interpolated
|
|
10
|
-
* (`p-${token}`), which no scanner could see, so a build-time safelist emitting the whole 8x7 matrix
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* (`__tests__/stylesheet-contract.test.ts` pins the pairing).
|
|
9
|
+
* (`p-${token}`), which no scanner could see, so a build-time safelist emitting the whole 8x7 matrix was
|
|
10
|
+
* the only thing keeping them alive and a missing entry failed silently at runtime. `resolveLayoutStyle`
|
|
11
|
+
* emits a property only for a prop set to a non-default value (`grow: false`, `shrink: true`, `border:
|
|
12
|
+
* false`, `rounded: false` and `animate: 'none'` deliberately emit nothing), and its `ANIMATION` values
|
|
13
|
+
* name `mtx-*` keyframes `index.css` must define.
|
|
16
14
|
*
|
|
17
15
|
* `LAYOUT_KEYS` must list every key of `LayoutProps`: `stripLayoutProps` filters by that set, so a
|
|
18
16
|
* layout prop missing from it reaches the DOM as an unknown attribute. `as` and `style` are in it
|
|
19
17
|
* because the consuming component (`Surface`) applies them itself rather than forwarding them.
|
|
20
18
|
*
|
|
21
|
-
* `withClass(base, extra)` appends an optional caller `className` to a component's fixed base class
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
19
|
+
* `withClass(base, extra)` appends an optional caller `className` to a component's fixed base class. It
|
|
20
|
+
* is NOT the banned `cn()`: there is no variant list to merge or dedup, just a plain conditional concat
|
|
21
|
+
* of one fixed string and one optional string — variants stay on `data-*` attributes per the styling
|
|
22
|
+
* rule in `../../../CLAUDE.md`.
|
|
25
23
|
*/
|
|
26
24
|
import type { CSSProperties, ElementType } from 'react';
|
|
27
25
|
import { type RadiusToken } from '../../design-system/component-tokens';
|
|
@@ -15,7 +15,7 @@ export interface ChatInputMode {
|
|
|
15
15
|
icon: IconName;
|
|
16
16
|
label: string;
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
interface ChatInputProps {
|
|
19
19
|
value: string;
|
|
20
20
|
onChange: (value: string) => void;
|
|
21
21
|
onSubmit: () => void;
|
|
@@ -28,3 +28,4 @@ export interface ChatInputProps {
|
|
|
28
28
|
ref?: React.Ref<HTMLTextAreaElement>;
|
|
29
29
|
}
|
|
30
30
|
export declare function ChatInput({ value, onChange, onSubmit, modes, activeMode, onModeChange, disabled, taskRunning, onStop, ref, }: ChatInputProps): React.JSX.Element;
|
|
31
|
+
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
2
|
+
interface NotificationProviderProps {
|
|
3
3
|
children?: React.ReactNode;
|
|
4
4
|
container?: HTMLElement | null;
|
|
5
5
|
offsetBottom?: number;
|
|
6
6
|
}
|
|
7
7
|
export declare const NotificationProvider: React.FC<NotificationProviderProps>;
|
|
8
|
-
|
|
8
|
+
interface WidgetNotificationsProps {
|
|
9
9
|
error?: string | undefined;
|
|
10
10
|
onClearError: () => void;
|
|
11
11
|
onRetry?: (() => void) | undefined;
|
|
@@ -14,3 +14,4 @@ export interface WidgetNotificationsProps {
|
|
|
14
14
|
onGreetingDismiss: () => void;
|
|
15
15
|
}
|
|
16
16
|
export declare const WidgetNotifications: React.FC<WidgetNotificationsProps>;
|
|
17
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
2
|
+
interface WidgetDialogProps {
|
|
3
3
|
open: boolean;
|
|
4
4
|
onClose: () => void;
|
|
5
5
|
title: string;
|
|
@@ -10,3 +10,4 @@ export interface WidgetDialogProps {
|
|
|
10
10
|
finalFocusRef?: React.RefObject<HTMLElement | null>;
|
|
11
11
|
}
|
|
12
12
|
export declare const WidgetDialog: React.FC<WidgetDialogProps>;
|
|
13
|
+
export {};
|
|
@@ -7,9 +7,40 @@
|
|
|
7
7
|
* Glow and activity ring are ONE class each, red or green keyed on the `data-tone` the error state
|
|
8
8
|
* picks — the same data-attribute variant convention every other component here uses. The two icon
|
|
9
9
|
* layers carry only their own transform and opacity; the transition they share is `.mtx-fab-icon-layer`.
|
|
10
|
+
*
|
|
11
|
+
* `useDragSnap` (below) drags this launcher and snaps it to the nearest corner. Pointer events are
|
|
12
|
+
* tracked in a ref; movement under DRAG_THRESHOLD_PX stays a click, beyond it the wrapper is translated
|
|
13
|
+
* on a rAF loop with velocity sampled so a flick lands where it was heading. On release
|
|
14
|
+
* `getNearestCornerByTranslation` picks the corner, the wrapper animates there for SNAP_DURATION_MS via
|
|
15
|
+
* `left`/`top` transitions, and `commitPositionAfterAnimation` calls `onPositionCommit` on
|
|
16
|
+
* `transitionend` (with a timeout fallback, since a hidden tab fires no transition events) — the
|
|
17
|
+
* committed corner is the one being animated TO, so two snaps in flight cannot commit the abandoned one
|
|
18
|
+
* (`abandonSnapRef`). `suppressUntilRef` stamps a time after which a click may open the widget again,
|
|
19
|
+
* so the pointer-up that ends a drag is not read as a tap. The wrapper is measured with a
|
|
20
|
+
* ResizeObserver in a layout effect so the pixel position is right on the first paint; preview mode
|
|
21
|
+
* disables everything. Exported so `WidgetFab.test.tsx`'s `renderHook` case can drive it directly.
|
|
10
22
|
*/
|
|
11
23
|
import React from 'react';
|
|
12
24
|
import type { WidgetPosition } from '../../types';
|
|
25
|
+
interface UseDragSnapOptions {
|
|
26
|
+
position: WidgetPosition;
|
|
27
|
+
onPositionCommit: (position: WidgetPosition) => void;
|
|
28
|
+
isPreviewMode?: boolean;
|
|
29
|
+
wrapperRef: React.RefObject<HTMLDivElement | null>;
|
|
30
|
+
}
|
|
31
|
+
interface UseDragSnapResult {
|
|
32
|
+
isDragging: boolean;
|
|
33
|
+
pixelPositionStyle: {
|
|
34
|
+
left: number;
|
|
35
|
+
top: number;
|
|
36
|
+
} | undefined;
|
|
37
|
+
onPointerDown: (event: React.PointerEvent<HTMLButtonElement>) => void;
|
|
38
|
+
onPointerMove: (event: React.PointerEvent<HTMLButtonElement>) => void;
|
|
39
|
+
onPointerUp: (event: React.PointerEvent<HTMLButtonElement>) => void;
|
|
40
|
+
onPointerCancel: (event: React.PointerEvent<HTMLButtonElement>) => void;
|
|
41
|
+
suppressUntilRef: React.RefObject<number>;
|
|
42
|
+
}
|
|
43
|
+
export declare function useDragSnap({ position, onPositionCommit, isPreviewMode, wrapperRef, }: UseDragSnapOptions): UseDragSnapResult;
|
|
13
44
|
interface WidgetFabProps {
|
|
14
45
|
onPositionCommit: (position: WidgetPosition) => void;
|
|
15
46
|
}
|
|
@@ -1,2 +1,20 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import type { MarketrixConfig, WidgetPosition } from '../../types';
|
|
3
|
+
export declare function useFocusTrap(containerRef: React.RefObject<HTMLElement | null>, isActive: boolean, options?: {
|
|
4
|
+
onEscape?: () => void;
|
|
5
|
+
focusTargetRef?: React.RefObject<HTMLElement | null> | undefined;
|
|
6
|
+
}): void;
|
|
7
|
+
export declare function useResize(settingsWidth: string | undefined, settingsHeight: string | undefined, position: WidgetPosition, config: MarketrixConfig, isPreviewMode: boolean): {
|
|
8
|
+
widthPx: string;
|
|
9
|
+
heightPx: string;
|
|
10
|
+
grip: {
|
|
11
|
+
vertical: "top" | "bottom";
|
|
12
|
+
horizontal: "left" | "right";
|
|
13
|
+
growX: number;
|
|
14
|
+
growY: number;
|
|
15
|
+
cursor: string;
|
|
16
|
+
};
|
|
17
|
+
onResizeStart: (e: React.MouseEvent) => void;
|
|
18
|
+
containerRef: React.RefObject<HTMLDivElement | null>;
|
|
19
|
+
};
|
|
2
20
|
export declare const MessengerShell: React.FC;
|
|
@@ -17,12 +17,50 @@
|
|
|
17
17
|
* injected nodes that outlive the task otherwise. `WidgetDialog` gets an explicit `finalFocusRef`
|
|
18
18
|
* since Base UI's focus restore resolves to the host page inside a closed shadow root otherwise. The
|
|
19
19
|
* transcript sits under its own `ErrorBoundary` so one unrenderable message can't take the composer down.
|
|
20
|
+
*
|
|
21
|
+
* `useScreenShare` (this file's only other consumer) owns the screen-share lifecycle: the in-transcript
|
|
22
|
+
* permission card, the browser picker, the live share message, and ending a share. `useLatest` keeps a
|
|
23
|
+
* value readable from a callback that must not be re-created (the polling interval below, mounted once).
|
|
24
|
+
* The hook returns `requestScreenAccess` — posting a request card carrying the queued turn, no-oping if
|
|
25
|
+
* one is already open — plus that card's Allow/Deny handlers, the toolbar dialog's Allow/Dismiss
|
|
26
|
+
* handlers, and `toggleScreenShareRef`, a toggle stopping a live share or opening that dialog.
|
|
27
|
+
* `beginScreenShare` opens the stream and posts the started/live messages; `stopScreenSharing`/
|
|
28
|
+
* `announceStopped` tear it down (video message → a system line); `resolveAccessRequest` stamps
|
|
29
|
+
* allowed/denied; `flushPendingMessage` sends the hold. The user can end the share from the browser's
|
|
30
|
+
* own UI, which fires no subscribable event, so a 1s interval reconciles `isScreenSharingActive()`
|
|
31
|
+
* against local state and announces the stop. `openRequest` is transcript-derived, not component state,
|
|
32
|
+
* since the request card survives an unmount/remount because it is persisted — the resolving state must
|
|
33
|
+
* be too, or the buttons stay live on a request neither Allow nor Deny can reach. Every outcome flushes
|
|
34
|
+
* the pending content (a cancel resolves `denied` like a real failure), leaving no queued turn stranded.
|
|
35
|
+
* `useScreenShare` is exported so `ChatView.test.tsx`'s `renderHook` cases can drive it directly.
|
|
20
36
|
*/
|
|
21
37
|
import React from 'react';
|
|
38
|
+
import type { InstructionType } from '../../sdk';
|
|
39
|
+
import type { ChatMessage } from '../../types';
|
|
22
40
|
interface ChatViewProps {
|
|
23
41
|
onScreenSharingChange: (isSharing: boolean) => void;
|
|
24
42
|
toggleScreenShareRef: React.MutableRefObject<(() => void) | null>;
|
|
25
43
|
messageInputRef: React.RefObject<HTMLTextAreaElement | null>;
|
|
26
44
|
}
|
|
45
|
+
export interface UseScreenShareOptions {
|
|
46
|
+
onScreenSharingChange?: (isSharing: boolean) => void;
|
|
47
|
+
toggleScreenShareRef?: React.MutableRefObject<(() => void) | null>;
|
|
48
|
+
onAddMessage: (message: ChatMessage) => void;
|
|
49
|
+
onUpdateMessage: (messageId: string, updates: Partial<ChatMessage>) => void;
|
|
50
|
+
onRemoveMessage?: (messageId: string) => void;
|
|
51
|
+
onSendMessage: (message: string, mode?: InstructionType, skipUserMessage?: boolean) => void;
|
|
52
|
+
messages: ChatMessage[];
|
|
53
|
+
}
|
|
54
|
+
interface UseScreenShareReturn {
|
|
55
|
+
isScreenSharing: boolean;
|
|
56
|
+
isAwaitingScreenAccess: boolean;
|
|
57
|
+
showScreenAccessDialog: boolean;
|
|
58
|
+
handleScreenAccessDialogAllow: () => Promise<void>;
|
|
59
|
+
handleScreenAccessDialogDismiss: () => void;
|
|
60
|
+
handleScreenAccessRequestAllow: () => Promise<void>;
|
|
61
|
+
handleScreenAccessRequestDeny: () => void;
|
|
62
|
+
requestScreenAccess: (mode: InstructionType, content: string) => void;
|
|
63
|
+
}
|
|
64
|
+
export declare function useScreenShare({ onScreenSharingChange, toggleScreenShareRef, onAddMessage, onUpdateMessage, onRemoveMessage, onSendMessage, messages, }: UseScreenShareOptions): UseScreenShareReturn;
|
|
27
65
|
export declare const ChatView: React.FC<ChatViewProps>;
|
|
28
66
|
export {};
|
|
@@ -1,3 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-domain wire primitives shared by every audience — this file is mirrored WHOLE into the widget
|
|
3
|
+
* closure, so any shape it exports republishes the widget SDK regardless of which audience actually
|
|
4
|
+
* reads it.
|
|
5
|
+
* - `unionOfRecord` builds a plain (non-discriminated) union of every variant in a
|
|
6
|
+
* `{ <discriminant value>: ZodType }` map — the shape `TriggerSourceConfigSchemas`/
|
|
7
|
+
* `WorkflowActionTargetConfigSchemas` are declared in, and the registry (`models/columnSchemas.ts`)
|
|
8
|
+
* keys by the same discriminant separately. Typed off the map's own value type rather than a bare
|
|
9
|
+
* `z.ZodType`, whose inferred output is `unknown` and would erase every variant's real shape from the
|
|
10
|
+
* union.
|
|
11
|
+
* - `ToolCallRecordSchema.params`/`.result` stay `z.record(z.string(), z.unknown())` ON PURPOSE —
|
|
12
|
+
* `models/columnSchemas.ts`'s header lists a tool call's own arguments and result as one of the few
|
|
13
|
+
* open boundaries kept opaque deliberately, since a tool's shape varies per tool name with no closed
|
|
14
|
+
* vocabulary this file (or the widget/app readers of `simulation_step.tool_calls`) can type against.
|
|
15
|
+
* - `SessionStateSchema` is `simulation.session_state` (Browserbase cookies + localStorage snapshot).
|
|
16
|
+
* Lives here rather than `models/columnSchemas.ts`, which imports FROM
|
|
17
|
+
* `contracts/foundationEntities.ts` — a leaf-shaped schema this file already is one, so
|
|
18
|
+
* `contracts/foundationEntities.ts` can type `SimulationEntitySchema`'s own `session_state` field
|
|
19
|
+
* with it without cycling back through `columnSchemas.ts`. Its `cookies` field is the other
|
|
20
|
+
* deliberately-open boundary from that same registry header: a browser cookie as the browser itself
|
|
21
|
+
* reports it, no closed shape to narrow to.
|
|
22
|
+
* - `GraphNodeSummarySchema` is the whole-graph tier — `applicationGraphGet`/`simulationGraphGet` load
|
|
23
|
+
* nodes with `readGraph`, which always resolves sections to `[]` for speed; a node's real sections
|
|
24
|
+
* are a lazy drill-in fetched one at a time by `graphNodeSectionsGet` (its own
|
|
25
|
+
* `GraphSectionSchema`-shaped output), so this tier never carries them. `sequence_ids` is DROPPED
|
|
26
|
+
* (not just unselected) — the stored `graph.graph_nodes` column stays for the agent's own write-side
|
|
27
|
+
* dedupe, but no app/widget graph or heatmap component ever read the wire field, and this file's
|
|
28
|
+
* widget-closure membership means dropping it republishes the widget.
|
|
29
|
+
*/
|
|
1
30
|
import { z } from 'zod';
|
|
2
31
|
export declare const EntityStatusSchema: z.ZodEnum<{
|
|
3
32
|
created: "created";
|
|
@@ -19,24 +19,9 @@
|
|
|
19
19
|
* protocol, an unparseable string being exactly a value that is not a URL.
|
|
20
20
|
*/
|
|
21
21
|
import type { InstructionType } from '../types';
|
|
22
|
-
|
|
22
|
+
interface TextData {
|
|
23
23
|
text: string;
|
|
24
24
|
}
|
|
25
|
-
export interface ExtractData {
|
|
26
|
-
title: string;
|
|
27
|
-
url: string;
|
|
28
|
-
text: string;
|
|
29
|
-
links: Array<{
|
|
30
|
-
text: string;
|
|
31
|
-
href: string | null;
|
|
32
|
-
}>;
|
|
33
|
-
}
|
|
34
|
-
export interface DropdownOptionsData {
|
|
35
|
-
options: Array<{
|
|
36
|
-
value: string;
|
|
37
|
-
text: string;
|
|
38
|
-
}>;
|
|
39
|
-
}
|
|
40
25
|
type ToolFailure = {
|
|
41
26
|
success: false;
|
|
42
27
|
error: string;
|
package/dist/src/utils/dom.d.ts
CHANGED
|
@@ -1,29 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Predicates the agent's element index runs against the HOST page's DOM — what counts as a control and
|
|
3
|
-
* whether it is reachable
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
3
|
+
* whether it is reachable. `TABBABLE_SELECTOR` is the one tab-order candidate query: `send_keys`'s Tab
|
|
4
|
+
* simulation walks the host page with it and `useFocusTrap` the widget's own tree, and they must agree
|
|
5
|
+
* on what the browser would focus next. `WIDGET_SHADOW_HOST_CLASS`, set by `bootstrap` on the shadow
|
|
6
|
+
* host, lets `DomService` recognise its own overlay chrome instead of reporting it as obscuring the host
|
|
7
|
+
* page.
|
|
7
8
|
*
|
|
8
|
-
* `ancestry` walks element → `parentElement`, crossing each shadow boundary at its host
|
|
9
|
-
* `parentElement` walk stops dead at a `ShadowRoot
|
|
10
|
-
*
|
|
11
|
-
* `aria-disabled`, or an `inert` ancestor) as a sentence fragment completing `DomService`'s
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* `
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* anything on it, so a poisoned element is logged with the real error and skipped rather than aborting the
|
|
19
|
-
* whole indexing pass.
|
|
9
|
+
* `ancestry` walks element → `parentElement`, crossing each shadow boundary at its host, since a bare
|
|
10
|
+
* `parentElement` walk stops dead at a `ShadowRoot` and a control inside a host-page web component would
|
|
11
|
+
* read as top-level. `disabledReason` names why an element cannot be operated (disabled control,
|
|
12
|
+
* `aria-disabled`, or an `inert` ancestor) as a sentence fragment completing `DomService`'s `Element
|
|
13
|
+
* <n> …` message — reword both together. `isIndexable` is `DomService`'s geometry-aware fallback after
|
|
14
|
+
* its cheap selector/handler checks; visibility there climbs both the `overflow: hidden|clip` chain
|
|
15
|
+
* (that walk stops at `document.body`) and the shadow-host size, since either can hide an element
|
|
16
|
+
* despite a non-zero rect. Its one `try` is deliberate — the host page owns this DOM and may have
|
|
17
|
+
* patched anything on it, so a poisoned element is logged with the real error and skipped rather than
|
|
18
|
+
* aborting the whole indexing pass.
|
|
20
19
|
*
|
|
21
20
|
* `focusablesIn` is the one home for "which `TABBABLE_SELECTOR` matches are actually reachable" —
|
|
22
|
-
* `useFocusTrap`
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* those descendants carry the attribute.
|
|
21
|
+
* `useFocusTrap` and `keySimulation`'s Tab simulation both call it so they can't re-diverge.
|
|
22
|
+
* `isAriaHidden` walks ancestors, not just the element itself, since a hidden container hides everything
|
|
23
|
+
* under it (per WAI-ARIA, `aria-hidden="true"` removes an element and its whole subtree from the
|
|
24
|
+
* accessibility tree) even though none of those descendants carry the attribute.
|
|
27
25
|
*/
|
|
28
26
|
export declare const WIDGET_SHADOW_HOST_CLASS = "marketrix-widget-container";
|
|
29
27
|
export declare const TABBABLE_SELECTOR = "a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])";
|
package/dist/widget.mjs
CHANGED
|
@@ -28,37 +28,37 @@ return new Map}function Ll(){/* @__PURE__ */
|
|
|
28
28
|
return new Set}function Fl(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function zl(e,t){return e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}var Bl=/*#__PURE__*/e.createContext(void 0);function $l(){const t=e.useContext(Bl);if(void 0===t)throw new Error(Dr(64));return t}var Wl="data-activation-direction",Ul={tabActivationDirection:e=>({[Wl]:e})},Hl=/*#__PURE__*/e.forwardRef(function(t,n){const{className:r,defaultValue:o=0,onValueChange:i,orientation:s="horizontal",render:a,value:c,style:l,...u}=t,d=void 0!==t.defaultValue,p=e.useRef([]),[h,f]=e.useState(()=>/* @__PURE__ */new Map),[m,g]=function({controlled:t,default:n,name:r,state:o="value"}){const{current:i}=e.useRef(void 0!==t),[s,a]=e.useState(n);return[i&&void 0!==t?t:s,e.useCallback(e=>{i||a(e)},[])]}({controlled:c,default:o,name:"Tabs",state:"value"}),y=void 0!==c,[v,w]=e.useState(()=>/* @__PURE__ */new Map),x=e.useRef(void 0),S=e.useCallback(e=>jl(v,e),[v]),[k,C]=e.useState(()=>({previousValue:m,tabActivationDirection:"none"})),{previousValue:E,tabActivationDirection:I}=k;let M=I,T=!1;E!==m&&(M=ql(E,m,s,v),T=null!=E&&null!=m&&null==S(m));const R=T?E:m,O=E!==R||I!==M;_r(()=>{O&&C({previousValue:R,tabActivationDirection:M})},[R,O,M]);const A=Kr((e,t)=>{t.activationDirection=ql(m,e,s,v),i?.(e,t),t.isCanceled||g(e)}),_=Kr((e,t)=>{i?.(e,Fs(t,void 0,void 0,{activationDirection:"none"}))}),D=Kr((e,t)=>(f(n=>{const r=new Map(n);return r.set(e,t),r}),()=>{f(n=>{if(n.get(e)!==t)return n;const r=new Map(n);return r.delete(e),r})})),P=e.useCallback(e=>h.get(e),[h]),N=e.useCallback(e=>{for(const t of v.values())if(e===t.value)return t.id},[v]),L=e.useMemo(()=>({getTabElementBySelectedValue:S,getTabIdByPanelValue:N,getTabPanelIdByValue:P,onValueChange:A,orientation:s,registerMountedTabPanel:D,setTabMap:w,tabActivationDirection:M,value:m}),[S,N,P,A,s,D,w,M,m]),F=e.useMemo(()=>{for(const e of v.values())if(e.value===m)return e},[v,m]),z=e.useMemo(()=>{for(const e of v.values())if(!e.disabled)return e.value},[v]),B=e.useRef(!d),$=e.useRef(o),W=e.useRef(d),U=e.useRef(!1);_r(()=>{if(y)return;function e(e,t){g(e),C({previousValue:e,tabActivationDirection:"none"}),_(e,t),B.current=!1}if(0===v.size)return void(U.current&&null!==m&&!x.current?.isConnected&&e(null,Ns));U.current=!0,x.current=v.keys().next().value;const t=F?.disabled,n=null==F&&null!==m;if(t||m!==$.current||(W.current=!1),W.current&&t&&m===$.current)return;const r=B.current;if(t||n){const n=z??null;if(m===n)return void(B.current=!1);let o=Ns;return r?o=Ls:t&&(o="disabled"),void e(n,o)}r&&null!=F&&(_(m,Ls),B.current=!1)},[z,y,_,F,g,v,m]);const H=Zi("div",t,{state:{orientation:s,tabActivationDirection:M},ref:n,props:u,stateAttributesMapping:Ul});/*#__PURE__*/
|
|
29
29
|
return b(Bl.Provider,{value:L,children:/*#__PURE__*/b(Pl,{elementsRef:p,children:H})})});function jl(e,t){for(const[n,r]of e.entries())if(t===r.value)return n;return null}function ql(e,t,n,r){if(null==e||null==t)return"none";const[o,i,s]="horizontal"===n?["left","left","right"]:["top","up","down"],a=jl(r,e),c=jl(r,t);if(null==a||null==c)return a===c||"number"!=typeof e&&"string"!=typeof e||typeof e!=typeof t?"none":t>e?s:i;const l=a.getBoundingClientRect()[o],u=c.getBoundingClientRect()[o];return u<l?i:u>l?s:"none"}function Vl(e){return ws(e,"base-ui")}var Yl="data-composite-item-active";function Kl(t={}){const{guess:n,label:r,metadata:o,textRef:i,index:s}=t,{register:a,unregister:c,subscribeMapChange:l,nextIndexRef:u}=e.useContext(Dl),d=e.useRef(-1),[p,h]=e.useState(null==s&&n?()=>{if(-1===d.current){const e=u.current;u.current+=1,d.current=e}return d.current}:-1),f=s??p,m=e.useRef(null),g=e.useCallback(e=>{const t=m.current;t&&c(t),m.current=e,e&&a(e,{metadata:o??null,index:s??null,label:r,textRef:i})},[s,a,c,o,r,i]);return _r(()=>{if(null==s)return l(e=>{const t=m.current?e.get(m.current)?.index:null;null!=t&&h(t)})},[s,l]),{ref:g,index:f}}var Xl=/*#__PURE__*/e.createContext(void 0),Gl=/*#__PURE__*/e.forwardRef(function(t,n){const{className:r,disabled:o=!1,render:i,value:s,id:a,nativeButton:c=!0,style:l,...u}=t,{value:d,getTabPanelIdByValue:p,onValueChange:h,orientation:f,tabActivationDirection:m}=$l(),{activateOnFocus:g,registerTabResizeObserverElement:y,tabsListElement:b}=function(){const t=e.useContext(Xl);if(void 0===t)throw new Error(Dr(65));return t}(),{highlightedIndex:v,onHighlightedIndexChange:w}=Ts(),x=Vl(a),S=e.useMemo(()=>({disabled:o,id:x,value:s}),[o,x,s]),{compositeProps:k,compositeRef:C,index:E}=function(t={}){const{highlightItemOnHover:n,highlightedIndex:r,onHighlightedIndexChange:o}=Ts(),{ref:i,index:s}=Kl(t),a=r===s,c=e.useRef(null),l=Ni(i,c);return{compositeProps:{tabIndex:a?0:-1,onFocus(){o(s)},onMouseMove(){const e=c.current;if(!n||!e)return;const t=e.hasAttribute("disabled")||"true"===e.ariaDisabled;a||t||e.focus()}},compositeRef:l,index:s}}({metadata:S}),I=s===d,M=e.useRef(!1),T=e.useRef(null),R=Kr(e=>{T.current?.(),T.current=e?y(e):null});_r(()=>{if(M.current)return void(M.current=!1);if(!(I&&E>-1&&v!==E))return;const e=b;if(null!=e){const t=Do(lo(e));if(t&&Po(e,t))return}o||w(E)},[I,E,v,w,o,b]);const{getButtonProps:O,buttonRef:A}=Os({disabled:o,native:c,focusableWhenDisabled:!0}),_=p(s),D=e.useRef(!1),P=e.useRef(!1);function N(e){h(s,Fs(Ps,e.nativeEvent,void 0,{activationDirection:"none"}))}return Zi("button",t,{state:{disabled:o,active:I,orientation:f,tabActivationDirection:m},ref:[n,A,C,R],props:[k,{role:"tab","aria-controls":_,"aria-selected":I,id:x,onClick:function(e){I||o||N(e)},onFocus:function(e){I||o||!g||D.current&&!P.current||N(e)},onPointerDown:function(e){if(I||o)return;D.current=!0,P.current=0===e.button;const t=lo(e.currentTarget);function n(){D.current=!1,P.current=!1,t.removeEventListener("pointerup",n),t.removeEventListener("pointercancel",n)}t.addEventListener("pointerup",n),t.addEventListener("pointercancel",n)},[Yl]:I?"":void 0,onKeyDownCapture(){M.current=!0}},u,O],stateAttributesMapping:Ul})}),Jl="data-index",Zl={...Ul,...Wo},Ql=/*#__PURE__*/e.forwardRef(function(t,n){const{className:r,value:o,render:i,keepMounted:s=!1,style:a,...c}=t,{value:l,getTabIdByPanelValue:u,orientation:d,tabActivationDirection:p,registerMountedTabPanel:h}=$l(),f=Vl(),{ref:m,index:g}=Kl(),y=o===l,{mounted:b,transitionStatus:v,setMounted:w}=va(y),x=!b,S=u(o),k={hidden:x,orientation:d,tabActivationDirection:p,transitionStatus:v},C=e.useRef(null),E=Zi("div",t,{state:k,ref:[n,m,C],props:[{"aria-labelledby":S,hidden:x,id:f,role:"tabpanel",tabIndex:y?0:-1,inert:ns(!y),[Jl]:g},c],stateAttributesMapping:Zl});return as({open:y,ref:C,onComplete(){y||w(!1)}}),_r(()=>{if(null!=f&&(!x||s))return h(o,f)},[x,s,o,f,h]),s||b?E:null}),eu="ArrowUp",tu="ArrowDown",nu="ArrowLeft",ru="ArrowRight",ou=/* @__PURE__ */new Set([eu,tu,nu,ru,"Home","End"]),iu=["Shift","Control","Alt","Meta"];function su(e){return!(!function(e){return ro(e)&&"INPUT"===e.tagName}(e)||null==e.selectionStart)||!(!ro(e)||"TEXTAREA"!==e.tagName)}function au(e,t,n,r){if(!e||!t||!t.scrollTo)return;let o=e.scrollLeft,i=e.scrollTop;const s=e.clientWidth<e.scrollWidth,a=e.clientHeight<e.scrollHeight;if(s&&"vertical"!==r){const r=cu(e,t,"left"),i=lu(e),s=lu(t);"ltr"===n&&(r+t.offsetWidth+s.scrollMarginRight>e.scrollLeft+e.clientWidth-i.scrollPaddingRight?o=r+t.offsetWidth+s.scrollMarginRight-e.clientWidth+i.scrollPaddingRight:r-s.scrollMarginLeft<e.scrollLeft+i.scrollPaddingLeft&&(o=r-s.scrollMarginLeft-i.scrollPaddingLeft)),"rtl"===n&&(r-s.scrollMarginLeft<e.scrollLeft+i.scrollPaddingLeft?o=r-s.scrollMarginLeft-i.scrollPaddingLeft:r+t.offsetWidth+s.scrollMarginRight>e.scrollLeft+e.clientWidth-i.scrollPaddingRight&&(o=r+t.offsetWidth+s.scrollMarginRight-e.clientWidth+i.scrollPaddingRight))}if(a&&"horizontal"!==r){const n=cu(e,t,"top"),r=lu(e),o=lu(t);n-o.scrollMarginTop<e.scrollTop+r.scrollPaddingTop?i=n-o.scrollMarginTop-r.scrollPaddingTop:n+t.offsetHeight+o.scrollMarginBottom>e.scrollTop+e.clientHeight-r.scrollPaddingBottom&&(i=n+t.offsetHeight+o.scrollMarginBottom-e.clientHeight+r.scrollPaddingBottom)}e.scrollTo({left:o,top:i,behavior:"auto"})}function cu(e,t,n){const r="left"===n?"offsetLeft":"offsetTop";let o=0;for(;t.offsetParent&&(o+=t[r],t.offsetParent!==e);)t=t.offsetParent;return o}function lu(e){const t=getComputedStyle(e);return{scrollMarginTop:parseFloat(t.scrollMarginTop)||0,scrollMarginRight:parseFloat(t.scrollMarginRight)||0,scrollMarginBottom:parseFloat(t.scrollMarginBottom)||0,scrollMarginLeft:parseFloat(t.scrollMarginLeft)||0,scrollPaddingTop:parseFloat(t.scrollPaddingTop)||0,scrollPaddingRight:parseFloat(t.scrollPaddingRight)||0,scrollPaddingBottom:parseFloat(t.scrollPaddingBottom)||0,scrollPaddingLeft:parseFloat(t.scrollPaddingLeft)||0}}function uu(t){const{render:n,className:r,style:o,refs:i=Mr,props:s=Mr,state:a=Tr,stateAttributesMapping:c,highlightedIndex:l,onHighlightedIndexChange:u,orientation:d,grid:p,loopFocus:h,onLoop:f,enableHomeAndEndKeys:m,onMapChange:g,stopEventPropagation:y=!0,rootRef:v,disabledIndices:w,modifierKeys:x,highlightItemOnHover:S=!1,tag:k="div",...C}=t,E=e.useContext(Ra)?.direction??"ltr",{props:I,highlightedIndex:M,onHighlightedIndexChange:T,elementsRef:R,onMapChange:O,relayKeyboardEvent:A}=function(t){const{loopFocus:n=!0,orientation:r="both",grid:o,onLoop:i,direction:s,highlightedIndex:a,onHighlightedIndexChange:c,rootRef:l,enableHomeAndEndKeys:u=!1,stopEventPropagation:d,disabledIndices:p,modifierKeys:h=Mr}=t,[f,m]=e.useState(0),g=null!=o,y=e.useRef(null),b=Ni(y,l),v=e.useRef([]),w=e.useRef(!1),x=e.useRef(null),S=a??f,k=Kr((e,t=!1)=>{if(x.current=v.current[e]??null,(c??m)(e),t){const t=v.current[e];au(y.current,t,s,r)}}),C=Kr(e=>{if(0===e.size)return;if(w.current){const e=v.current,t=e.indexOf(x.current);if(-1===t){const t=e[S];!t||si(e,S,p)?k(function(e,t){let n=-1;for(let r=0;r<e.length;r+=1){const o=e[r];if(o&&!si(e,r,t)){if(o.hasAttribute("data-composite-item-active"))return r;-1===n&&(n=r)}}return Math.max(n,0)}(e,p)):x.current=t}else t!==S&&k(t);return}w.current=!0;const t=Array.from(e.keys()),n=t.find(e=>e?.hasAttribute("data-composite-item-active"))??null,o=n?e.get(n)?.index??-1:-1;if(-1!==o)k(o);else if(si(t,S,p)){const e=ii(t,{disabledIndices:p});oi(t,e)||k(e)}au(y.current,n,s,r)});_r(()=>{if(null==p||null!=a||!w.current)return;const e=v.current;if(si(e,S,p)){const t=ii(e,{disabledIndices:p});oi(e,t)||k(t)}},[p,a,S,v,k]);const E=Kr((e,t,n)=>i?i(e,t,n,v):n),I=Kr(e=>{const t="Home"===e.key||"End"===e.key;if(!ou.has(e.key)||!u&&t)return;if(function(e,t){for(const n of iu)if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}(e,h))return;if(!y.current)return;const a="rtl"===s,c=a?nu:ru,l=a?ru:nu,f="vertical"===r?tu:c,m="vertical"===r?eu:l,b=No(e.nativeEvent);if(null!=b&&su(b)&&null!=(w=b)&&!w.hasAttribute("disabled")&&"true"!==w.getAttribute("aria-disabled")){const t=b.selectionStart,n=b.selectionEnd,r=b.value;if(null==t||e.shiftKey||t!==n)return;if(e.key!==m&&t<r.length)return;if(e.key!==f&&t>0)return}var w;let x=S;const C=function(e,t){return ii(e.current,{disabledIndices:t})}(v,p),I=function(e,t){return ii(e.current,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}(v,p);null!=o&&(x=o({disabledIndices:p,elementsRef:v,event:e,highlightedIndex:S,loopFocus:n,maxIndex:I,minIndex:C,onLoop:E,orientation:r,rtl:a}));const M="vertical"!==r&&e.key===c||"horizontal"!==r&&"ArrowDown"===e.key,T="vertical"!==r&&e.key===l||"horizontal"!==r&&"ArrowUp"===e.key;u&&("Home"===e.key?x=C:"End"===e.key&&(x=I)),x===S&&(M||T)&&(n&&x===I&&M?(x=C,i&&(x=i(e,S,x,v))):n&&x===C&&T?(x=I,i&&(x=i(e,S,x,v))):x=ii(v.current,{startingIndex:x,decrement:T,disabledIndices:p})),x===S||oi(v.current,x)||(d&&e.stopPropagation(),(g||t||M||T)&&e.preventDefault(),k(x,!0),queueMicrotask(()=>{v.current[x]?.focus()}))});return{props:{ref:b,onFocus(e){const t=y.current,n=No(e.nativeEvent);t&&null!=n&&su(n)&&n.setSelectionRange(0,n.value.length)},onKeyDown:I},highlightedIndex:S,onHighlightedIndexChange:k,elementsRef:v,onMapChange:C,relayKeyboardEvent:I}}({grid:p,loopFocus:h,onLoop:f,orientation:d,highlightedIndex:l,onHighlightedIndexChange:u,rootRef:v,stopEventPropagation:y,enableHomeAndEndKeys:m,direction:E,disabledIndices:w,modifierKeys:x}),_=Zi(k,t,{state:a,ref:i,props:[I,...s,C],stateAttributesMapping:c}),D=e.useMemo(()=>({highlightedIndex:M,onHighlightedIndexChange:T,highlightItemOnHover:S,relayKeyboardEvent:A}),[M,T,S,A]);/*#__PURE__*/
|
|
30
30
|
return b(Ms.Provider,{value:D,children:/*#__PURE__*/b(Pl,{elementsRef:R,onMapChange:e=>{g?.(e),O(e)},children:_})})}var du=/*#__PURE__*/e.forwardRef(function(t,n){const{activateOnFocus:r=!1,className:o,loopFocus:i=!0,render:s,style:a,...c}=t,{orientation:l,setTabMap:u,tabActivationDirection:d}=$l(),[p,h]=e.useState(0),[f,m]=e.useState(null),g=e.useRef(/* @__PURE__ */new Set),y=e.useRef(/* @__PURE__ */new Set),v=e.useRef(null);_r(()=>{if("undefined"==typeof ResizeObserver)return;const e=new ResizeObserver(()=>{g.current.forEach(e=>{e()})});return v.current=e,f&&e.observe(f),y.current.forEach(t=>{e.observe(t)}),()=>{e.disconnect(),v.current=null}},[f]);const w=Kr(e=>(g.current.add(e),()=>{g.current.delete(e)})),x=Kr(e=>(y.current.add(e),v.current?.observe(e),()=>{y.current.delete(e),v.current?.unobserve(e)})),S={orientation:l,tabActivationDirection:d},k={"aria-orientation":"vertical"===l?"vertical":void 0,role:"tablist"},C=e.useMemo(()=>({activateOnFocus:r,registerIndicatorUpdateListener:w,registerTabResizeObserverElement:x,tabsListElement:f}),[r,w,x,f]);/*#__PURE__*/
|
|
31
|
-
return b(Xl.Provider,{value:C,children:/*#__PURE__*/b(uu,{render:s,className:o,style:a,state:S,refs:[n,m],props:[k,c],stateAttributesMapping:Ul,highlightedIndex:p,enableHomeAndEndKeys:!0,loopFocus:i,orientation:l,onHighlightedIndexChange:h,onMapChange:u,disabledIndices:Mr})})});function pu(
|
|
32
|
-
return v("span",{className:"mtx-live-dot",style:e,children:[/* @__PURE__ */b("span",{className:"mtx-live-dot-ping"}),/* @__PURE__ */b("span",{className:"mtx-live-dot-core"})]})}var
|
|
33
|
-
return v(oc,{background:"card",rounded:"xl",border:!0,overflow:"hidden",className:"mtx-composer",children:[/* @__PURE__ */b("textarea",{ref:
|
|
34
|
-
return v("button",{type:"button",className:"mtx-mode-chip","data-active":t?"true":"false",onClick:t=>{t.preventDefault(),t.stopPropagation(),s?.(e.id)},children:[/* @__PURE__ */b(ac,{name:e.icon,size:12}),/* @__PURE__ */b(pc,{as:"span",inheritColor:!0,children:e.label})]},e.id)})}),/* @__PURE__ */b(cc,{variant:l?"secondary":"primary",size:"sm",disabled:!l&&!m,label:l?"Stop the assistant":"Send message",onClick:e=>{e.preventDefault(),e.stopPropagation(),l&&u?u():n()},children:/* @__PURE__ */b(ac,l?{name:"stop",size:14}:{name:"send",size:16})})]})]})}var
|
|
35
|
-
return b(ma,{context:p,openInteractionType:w,disabled:!m,closeOnFocusOut:!d,initialFocus:E,returnFocus:s,modal:!1!==f,restoreFocus:"popup",children:R})}),
|
|
36
|
-
return b("div",{ref:t,role:"presentation","data-base-ui-inert":"",...r,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:o}})}),Ou=/*#__PURE__*/e.forwardRef(function(e,t){const{keepMounted:n=!1,...r}=e,o=xu(),i=o.useState("mounted"),s=o.useState("modal"),a=o.useState("open");return i||n?/*#__PURE__*/b(Cu.Provider,{value:n,children:/*#__PURE__*/v(Hs,{ref:t,...r,children:[i&&!0===s&&/*#__PURE__*/b(Ru,{ref:o.context.internalBackdropRef,inert:ns(!a)}),e.children]})}):null}),Au={},_u={},Du="";function Pu(e,t){return function(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=so(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&"inline"!==o&&"contents"!==o}(e)?e:t}function Nu(e,t,n){return/hidden|clip/.test(e.getComputedStyle(Pu(t,n)).overflowY)}var Lu=new class{lockCount=0;restore=null;timeoutLock=go.create();timeoutUnlock=go.create();acquire(e){return this.lockCount+=1,1===this.lockCount&&null===this.restore&&this.timeoutLock.start(0,()=>this.lock(e)),this.release}release=()=>{this.lockCount-=1,0===this.lockCount&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{0===this.lockCount&&this.restore&&(this.restore?.(),this.restore=null)};lock(e){if(0===this.lockCount||null!==this.restore)return;const t=lo(e),n=t.documentElement,r=t.body,o=eo(n);if(Nu(o,n,r)){const t=new o.MutationObserver(()=>{Nu(o,n,r)||(t.disconnect(),this.restore=null,this.lock(e))}),i={attributes:!0};return t.observe(n,i),t.observe(r,i),void(this.restore=()=>t.disconnect())}const i=Eo||!function(e){if("undefined"==typeof document)return!1;const t=lo(e);return eo(t).innerWidth-t.documentElement.clientWidth>0}(e);this.restore=i?function(e){const t=lo(e),n=Pu(t.documentElement,t.body),r={overflowY:n.style.overflowY,overflowX:n.style.overflowX};return Object.assign(n.style,{overflowY:"hidden",overflowX:"hidden"}),()=>{Object.assign(n.style,r)}}(e):function(e){const t=lo(e),n=t.documentElement,r=t.body,o=eo(n);let i=0,s=0,a=!1;const c=fo.create();if(Oo&&1!==(o.visualViewport?.scale??1))return()=>{};function l(){const t=o.getComputedStyle(n),c=o.getComputedStyle(r),l=(t.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";i=n.scrollTop,s=n.scrollLeft,Au={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},Du=n.style.scrollBehavior,_u={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};const u=n.scrollHeight>n.clientHeight,d=n.scrollWidth>n.clientWidth,p="scroll"===t.overflowY||"scroll"===c.overflowY,h="scroll"===t.overflowX||"scroll"===c.overflowX,f=Math.max(0,o.innerWidth-r.clientWidth),m=Math.max(0,o.innerHeight-r.clientHeight),g=parseFloat(c.marginTop)+parseFloat(c.marginBottom),y=parseFloat(c.marginLeft)+parseFloat(c.marginRight),b=Pu(n,r);if(a=function(e){if("undefined"==typeof CSS||!CSS.supports||!CSS.supports("scrollbar-gutter","stable")||"undefined"==typeof document)return!1;const t=lo(e),n=t.documentElement,r=Pu(n,t.body),o=r.style.overflowY,i=n.style.scrollbarGutter;n.style.scrollbarGutter="stable",r.style.overflowY="scroll";const s=r.offsetWidth;r.style.overflowY="hidden";const a=r.offsetWidth;return r.style.overflowY=o,n.style.scrollbarGutter=i,s===a}(e),a)return n.style.scrollbarGutter=l,b.style.overflowY="hidden",void(b.style.overflowX="hidden");Object.assign(n.style,{scrollbarGutter:l,overflowY:"hidden",overflowX:"hidden"}),(u||p)&&(n.style.overflowY="scroll"),(d||h)&&(n.style.overflowX="scroll"),Object.assign(r.style,{position:"relative",height:g||m?`calc(100dvh - ${g+m}px)`:"100dvh",width:y||f?`calc(100vw - ${y+f}px)`:"100vw",boxSizing:"border-box",overflowY:"hidden",overflowX:"hidden",scrollBehavior:"unset"}),r.scrollTop=i,r.scrollLeft=s,n.setAttribute("data-base-ui-scroll-locked",""),n.style.scrollBehavior="unset"}function u(){Object.assign(n.style,Au),Object.assign(r.style,_u),a||(n.scrollTop=i,n.scrollLeft=s,n.removeAttribute("data-base-ui-scroll-locked"),n.style.scrollBehavior=Du)}l();const d=uo(o,"resize",function(){u(),c.request(l)});return()=>{c.cancel(),u(),"function"==typeof o.removeEventListener&&d()}}(e)}};function Fu({store:t,parentContext:n,isDrawer:r}){const o=t.useState("open"),i=t.useState("disablePointerDismissal"),s=t.useState("modal"),a=t.useState("popupElement"),c=t.useState("floatingRootContext"),[l,u]=e.useState(0),[d,p]=e.useState(0),h=0===l,f=function(t,n={}){const{enabled:r=!0,escapeKey:o=!0,outsidePress:i=!0,outsidePressEvent:s="sloppy",referencePress:a=ga,bubbles:c,externalTree:l}=n,u="rootStore"in t?t.rootStore:t,d=u.useState("open"),p=u.useState("floatingElement"),{dataRef:h,events:f}=u.context,m=la(l),g=Kr("function"==typeof i?i:()=>!1),y="function"==typeof i?g:i,b=!1!==y,v=Kr(()=>s),{escapeKey:w,outsidePress:x}={escapeKey:"boolean"==typeof(S=c)?S:S?.escapeKey??!1,outsidePress:"boolean"==typeof S?S:S?.outsidePress??!0};var S;const k=e.useRef(!1),C=e.useRef(!1),E=e.useRef(!1),I=e.useRef(!1),M=e.useRef(!1),T=e.useRef(""),R=e.useRef(null),O=yo(),A=yo(),_=Kr(()=>{A.clear(),h.current.insideReactTree=!1}),D=Kr(e=>{const t=h.current.floatingContext?.nodeId;return(m?ti(m.nodesRef.current,t):[]).some(t=>t.context?.open&&!t.context.dataRef.current[e])}),P=Kr(e=>Go(e,u.select("floatingElement"))||Go(e,u.select("domReferenceElement"))),N=Kr(e=>{a()&&u.setOpen(!1,Fs("trigger-press",e.nativeEvent))}),L=Kr(e=>{if(!d||!r||!o||"Escape"!==e.key)return;if(M.current)return;if(!w&&D("__escapeKeyBubbles"))return;const t=Fs("escape-key",function(e){return"nativeEvent"in e}(e)?e.nativeEvent:e);u.setOpen(!1,t),t.isCanceled||e.preventDefault(),w||t.isPropagationAllowed||e.stopPropagation()}),F=Kr(()=>{h.current.insideReactTree=!0,A.start(0,_)}),z=Kr(e=>{if(!d||!r||0!==e.button)return;const t=No(e.nativeEvent);Po(u.select("floatingElement"),t)&&(k.current||(k.current=!0,C.current=!1))}),B=Kr(e=>{d&&r&&(e.defaultPrevented||e.nativeEvent.defaultPrevented)&&k.current&&(C.current=!0)});e.useEffect(()=>{function e(e){e.open||(I.current=!1)}return f.on("openchange",e),()=>{f.off("openchange",e)}},[f]),e.useEffect(()=>{if(!d||!r)return d||(I.current=!1),_;h.current.__escapeKeyBubbles=w,h.current.__outsidePressBubbles=x;const e=new go,t=new go,n=lo(p);function i(){E.current=!0,t.start(0,()=>{E.current=!1})}function s(){k.current=!1,C.current=!1}function a(){const e=T.current,t="pen"!==e&&e?e:"mouse",n=v(),r="function"==typeof n?n():n;return"string"==typeof r?r:r[t]}function c(e){const t=h.current.floatingContext?.nodeId,n=m&&ti(m.nodesRef.current,t).some(t=>Go(e,t.context?.elements.floating));return P(e)||n}function l(e){if(function(e){const t=a();return"intentional"===t&&"click"!==e.type||"sloppy"===t&&"click"===e.type}(e))return"click"===e.type||P(e)||(t.clear(),E.current=!1),void _();if(h.current.insideReactTree)return void _();const n=No(e),r=`[${zs("inert")}]`,o=no(n)?n.getRootNode():null,i=Array.from((oo(o)?o:lo(u.select("floatingElement"))).querySelectorAll(r)),s=u.context.triggerElements;if(n&&(s.hasElement(n)||s.hasMatchingElement(e=>Po(e,n))))return;let l=no(n)?n:null;for(;l&&!io(l);){const e=ao(l);if(io(e)||!no(e))break;l=e}if(!i.length||!no(n)||n.matches("html,body")||Po(n,u.select("floatingElement"))||!i.every(e=>!Po(l,e))){if(ro(n)&&!("touches"in e)){const t=io(n),r=so(n),o=/auto|scroll/,i=t||o.test(r.overflowX),s=t||o.test(r.overflowY),a=i&&n.clientWidth>0&&n.scrollWidth>n.clientWidth,c=s&&n.clientHeight>0&&n.scrollHeight>n.clientHeight,l="rtl"===r.direction,u=c&&(l?e.offsetX<=n.offsetWidth-n.clientWidth:e.offsetX>n.clientWidth),d=a&&e.offsetY>n.clientHeight;if(u||d)return}if(!c(e)){if("intentional"===a()){if(0!==e.detail&&!ri(e)&&!I.current)return;if(E.current)return t.clear(),void(E.current=!1)}("function"!=typeof y||y(e))&&(D("__outsidePressBubbles")||(u.setOpen(!1,Fs("outside-press",e)),_()))}}}function f(e){if("sloppy"!==a()||!u.select("open")||!r||P(e))return;const t=e.touches[0];t&&(R.current={startTime:Date.now(),startX:t.clientX,startY:t.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},O.start(1e3,()=>{R.current&&(R.current.dismissOnTouchEnd=!1,R.current.dismissOnMouseDown=!1)}))}function g(e,t){const n=No(e);if(!n)return;const r=uo(n,e.type,()=>{t(e),r()})}function S(e){O.clear(),"pointerdown"===e.type&&(0===e.button&&(I.current=!0),T.current=e.pointerType),"mousedown"===e.type&&R.current&&!R.current.dismissOnMouseDown||g(e,e=>{"pointerdown"===e.type?function(e){"sloppy"===a()&&"touch"!==e.pointerType&&u.select("open")&&r&&!P(e)&&l(e)}(e):l(e)})}function A(e){if("pointercancel"===e.type&&(I.current=!1),!k.current)return;const n=C.current;s(),"intentional"===a()&&("pointercancel"!==e.type?c(e)||(n?i():("function"!=typeof y||y(e))&&(t.clear(),E.current=!0,_())):n&&i())}function N(e){if("sloppy"!==a()||!R.current||P(e))return;const t=e.touches[0];if(!t)return;const n=Math.abs(t.clientX-R.current.startX),r=Math.abs(t.clientY-R.current.startY),o=Math.sqrt(n*n+r*r);o>5&&(R.current.dismissOnTouchEnd=!0),o>10&&(l(e),O.clear(),R.current=null)}function F(e){"sloppy"===a()&&R.current&&!P(e)&&(R.current.dismissOnTouchEnd&&l(e),O.clear(),R.current=null)}const z=co(o&&co(uo(n,"keydown",L),uo(n,"compositionstart",function(){e.clear(),M.current=!0}),uo(n,"compositionend",function(){e.start(Oo?5:0,()=>{M.current=!1})})),b&&co(uo(n,"click",S,!0),uo(n,"pointerdown",S,!0),uo(n,"pointerup",A,!0),uo(n,"pointercancel",A,!0),uo(n,"mousedown",S,!0),uo(n,"mouseup",A,!0),uo(n,"touchstart",function(e){T.current="touch",g(e,f)},{capture:!0,passive:!0}),uo(n,"touchmove",function(e){g(e,N)},{capture:!0,passive:!0}),uo(n,"touchend",function(e){g(e,F)},{capture:!0,passive:!0})));return()=>{z(),e.clear(),t.clear(),s(),E.current=!1,_()}},[h,p,o,b,y,d,r,w,x,L,_,v,D,P,m,u,O]);const $=e.useMemo(()=>({onKeyDown:L,onPointerDown:N,onClick:N}),[L,N]),W=e.useMemo(()=>({onKeyDown:L,onPointerDown:B,onMouseDown:B,onClickCapture:F,onMouseDownCapture(e){F(),z(e)},onPointerDownCapture(e){F(),z(e)},onMouseUpCapture:F,onTouchEndCapture:F,onTouchMoveCapture:F}),[L,F,z,B]);return e.useMemo(()=>r?{reference:$,floating:W,trigger:$}:{},[r,$,W])}(c,{outsidePressEvent:()=>t.context.internalBackdropRef.current||t.context.backdropRef.current?"intentional":{mouse:"trap-focus"===s?"sloppy":"intentional",touch:"sloppy"},outsidePress(e){if(!t.context.outsidePressEnabledRef.current)return!1;if("button"in e&&0!==e.button)return!1;if("touches"in e)if("touchend"===e.type){if(1!==e.changedTouches.length||0!==e.touches.length)return!1}else if(1!==e.touches.length)return!1;const n=No(e);if(h&&!i){if(s){const e=t.context.internalBackdropRef.current,r=t.context.backdropRef.current;return!e&&!r||e===n||r===n||Po(n,a)&&!n?.hasAttribute("data-base-ui-portal")}return!0}return!1},escapeKey:h});return function(e=!0,t=null){_r(()=>{if(e)return Lu.acquire(t)},[e,t])}(o&&!0===s,a),t.useContextCallback("onNestedDialogOpen",(e,t)=>{u(e),p(t)}),_r(()=>(n?.onNestedDialogOpen&&(o?n.onNestedDialogOpen(l+1,d+(r?1:0)):n.onNestedDialogOpen(0,0)),()=>{n?.onNestedDialogOpen&&o&&n.onNestedDialogOpen(0,0)}),[r,o,l,d,n]),function(e,t){e.useSyncedValues(t),_r(()=>()=>{e.update({activeTriggerProps:Tr,inactiveTriggerProps:Tr,popupProps:Tr})},[e])}(t,{activeTriggerProps:f.reference,inactiveTriggerProps:f.trigger,popupProps:f.floating,nestedOpenDialogCount:l,nestedOpenDrawerCount:d}),null}var zu={...Ta,modal:e=>e.modal,nested:e=>e.nested,nestedOpenDialogCount:e=>e.nestedOpenDialogCount,nestedOpenDrawerCount:e=>e.nestedOpenDrawerCount,disablePointerDismissal:e=>e.disablePointerDismissal,openMethod:e=>e.openMethod,descriptionElementId:e=>e.descriptionElementId,titleElementId:e=>e.titleElementId,viewportElement:e=>e.viewportElement,role:e=>e.role},Bu=class extends Jr{constructor(t,n,r){const o=new Sa,i=function(e,t,n,r=!1){return{...ka(t,n,r),modal:!0,disablePointerDismissal:!1,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:"dialog",...e}}(t,o,n,r);super(i,function(t){return{popupRef:/*#__PURE__*/e.createRef(),backdropRef:/*#__PURE__*/e.createRef(),internalBackdropRef:/*#__PURE__*/e.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:t,onOpenChange:void 0,onOpenChangeComplete:void 0}}(o),zu)}setOpen=(e,t)=>{t.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},e||null!=t.trigger||null==this.state.activeTriggerId||(t.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,t),t.isCanceled||(this.state.floatingRootContext.dispatchOpenChange(e,t),this.update(function(e,t,n,r=!1){let o=e.preventUnmountingOnClose;t?o=!1:r&&(o=!0);const i=n?.id??null;let s=e.activeTriggerId,a=e.activeTriggerElement;return(i||t)&&(s=i,a=n??null),{open:t,preventUnmountingOnClose:o,activeTriggerId:s,activeTriggerElement:a}}(this.state,e,t.trigger)))}};var $u=function(e){const t=(t,n)=>{const r=Ar($r).current;let o;try{Br=r;for(const e of zr)e.before(r);o=e(t);for(const e of zr)e.after(r);r.didInitialize=!0}finally{Br=void 0}return o};return t.displayName=e.displayName||e.name,t}(function(t){return function(t,n){const{children:r,open:o,defaultOpen:i=!1,onOpenChange:s,onOpenChangeComplete:a,disablePointerDismissal:c=!1,modal:l=!0,actionsRef:u,handle:d,triggerId:p,defaultTriggerId:h=null}=n,f="drawer"===t,m="alert-dialog"===t,g=!!m||l,y=m||c,w=m?"alertdialog":"dialog",x=xu(!0),S={modal:g,disablePointerDismissal:y,nested:null!=x,role:w},k=function(t,n=!1){const r=ws(),o=null!=(e.useContext(aa)?.id||null),i=Ar(()=>t(r,o)).current;return function(t){const{popupStore:n,treatPopupAsFloatingElement:r=!1,floatingRootContext:o,floatingId:i,nested:s,onOpenChange:a}=t,c=n.useState("open"),l=n.useState("activeTriggerElement"),u=n.useState(r?"popupElement":"positionerElement"),d=n.context.triggerElements,p=a,h=e.useRef(null);void 0===o&&null===h.current&&(h.current=new ba({open:c,transitionStatus:void 0,referenceElement:l,floatingElement:u,triggerElements:d,onOpenChange:p,floatingId:i,syncOnly:!0,nested:s}));const f=o??h.current;n.useSyncedValue("floatingId",i),_r(()=>{const e={open:c,floatingId:i,referenceElement:l,floatingElement:u};no(l)&&(e.domReferenceElement=l),f.state.positionReference===f.state.referenceElement&&(e.positionReference=l),f.update(e)},[c,i,l,u,f]),f.context.onOpenChange=p,f.context.nested=s}({popupStore:i,treatPopupAsFloatingElement:n,floatingRootContext:i.state.floatingRootContext,floatingId:r,nested:o,onOpenChange:i.setOpen}),i}((e,t)=>new Bu({open:i,openProp:o,activeTriggerId:h,triggerIdProp:p,...S},e,t),!0);k.useControlledProp("openProp",o),k.useControlledProp("triggerIdProp",p),k.useSyncedValues(S),k.useContextCallback("onOpenChange",s),k.useContextCallback("onOpenChangeComplete",a);const C=k.useState("open"),E=k.useState("mounted"),I=k.useState("payload");!function(e,t){_r(()=>{t||null===e.state.openMethod||e.set("openMethod",null)},[t,e]),_r(()=>()=>{null!==e.state.openMethod&&e.set("openMethod",null)},[e])}(k,C),function(t,n={}){const{closeOnActiveTriggerUnmount:r=!1}=n,o=e.useRef(null),i=t.useState("open"),s=t.useState("triggerCount"),a=t.useState("activeTriggerId"),c=t.useState("activeTriggerElement");_r(()=>{if(!i)return o.current=null,void(0!==t.state.triggerCount&&t.set("triggerCount",0));const e=t.context.triggerElements.size,n={};t.state.triggerCount!==e&&(n.triggerCount=e);const s=t.select("activeTriggerId");let a=null;if(s){const e=t.context.triggerElements.getById(s);if(e)o.current=s,e!==t.state.activeTriggerElement&&(n.activeTriggerElement=e);else{for(const[e,r]of t.context.triggerElements.entries())if(r===t.state.activeTriggerElement){n.activeTriggerId=e,n.activeTriggerElement=r,o.current=e;break}void 0===n.activeTriggerId&&(o.current===s?a=s:o.current=null)}}else o.current=null;if(!a&&!s&&1===e){const e=t.context.triggerElements.entries().next();if(!e.done){const[t,r]=e.value;n.activeTriggerId=t,n.activeTriggerElement=r,o.current=t}}void 0===n.triggerCount&&void 0===n.activeTriggerId&&void 0===n.activeTriggerElement||t.update(n),a&&r&&queueMicrotask(()=>{if(t.select("open")&&t.select("activeTriggerId")===a&&!t.context.triggerElements.getById(a)){const e=Fs(Ps);t.setOpen(!1,e),e.isCanceled||t.update({activeTriggerId:null,activeTriggerElement:null})}})},[i,t,s,a,c,r])}(k);const{forceUnmount:M}=function(e,t){const{mounted:n,setMounted:r,transitionStatus:o}=va(e,!1,!1,void 0),i=t.useState("preventUnmountingOnClose"),s=!e&&i;t.useSyncedValues({mounted:n,transitionStatus:o,preventUnmountingOnClose:s});const a=Kr(()=>{r(!1),t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1,preventUnmountingOnClose:!1}),t.context.onOpenChangeComplete?.(!1)});return as({enabled:n&&!e&&!s,open:e,ref:t.context.popupRef,onComplete(){e||a()}}),{forceUnmount:a,transitionStatus:o}}(C,k);e.useImperativeHandle(u,()=>({unmount:M,close:()=>k.setOpen(!1,Fs("imperative-action"))}),[M,k]);const T=C||E;/*#__PURE__*/
|
|
37
|
-
return v(
|
|
38
|
-
return b(
|
|
39
|
-
/* @__PURE__ */b(
|
|
40
|
-
/* @__PURE__ */b(rc,{gap:"md",justify:"end",children:[["secondary",a,t],["primary",i,()=>o?.()]].map(([e,t,n])=>/* @__PURE__ */b(Ja,{type:"button",variant:e,size:"sm",shape:"pill",onClick:e=>{e.preventDefault(),e.stopPropagation(),n()},children:t},e))})]})]})})},
|
|
41
|
-
return v("div",{ref:n,"data-size":e,role:"status",style:{display:"inline-flex",alignItems:"center",gap:"6px",...t},children:[/* @__PURE__ */b("div",{"aria-hidden":"true",className:"mtx-spinner-ring",style:
|
|
42
|
-
/* @__PURE__ */b("video",{ref:t,autoPlay:!0,muted:!0,playsInline:!0,style:{width:"100%",height:"auto",maxHeight:"192px",objectFit:"contain",borderRadius:
|
|
43
|
-
/* @__PURE__ */b(rc,{position:"absolute",inset:"0",align:"center",justify:"center",style:{borderRadius:
|
|
31
|
+
return b(Xl.Provider,{value:C,children:/*#__PURE__*/b(uu,{render:s,className:o,style:a,state:S,refs:[n,m],props:[k,c],stateAttributesMapping:Ul,highlightedIndex:p,enableHomeAndEndKeys:!0,loopFocus:i,orientation:l,onHighlightedIndexChange:h,onMapChange:u,disabledIndices:Mr})})});function pu({style:e}){/* @__PURE__ */
|
|
32
|
+
return v("span",{className:"mtx-live-dot",style:e,children:[/* @__PURE__ */b("span",{className:"mtx-live-dot-ping"}),/* @__PURE__ */b("span",{className:"mtx-live-dot-core"})]})}var hu=({title:e,subtitle:t,onClose:n,controls:r})=>/* @__PURE__ */v(rc,{align:"center",justify:"between",paddingX:"lg",paddingY:"md",border:"bottom",shrink:!1,elevation:"section",children:[/* @__PURE__ */v(rc,{align:"center",gap:"md",minWidth:"0",grow:!0,children:[/* @__PURE__ */b(Ka,{src:Aa,alt:"",size:"md",rounded:"lg",elevation:"card"}),/* @__PURE__ */v(oc,{minWidth:"0",children:[/* @__PURE__ */b(pc,{size:"sm",weight:"semibold",truncate:!0,leading:"tight",children:e}),null!=t&&/* @__PURE__ */b(pc,{as:"p",size:"xs",variant:"muted",truncate:!0,children:t})]})]}),/* @__PURE__ */v(rc,{align:"center",gap:"2xs",shrink:!1,children:[r,/* @__PURE__ */b(cc,{size:"sm",label:"Close",onClick:n,children:/* @__PURE__ */b(ac,{name:"close",size:16})})]})]});function fu(...e){return t=>{e.forEach(e=>{"function"==typeof e?e(t):e&&(e.current=t)})}}function mu({value:e,onChange:t,onSubmit:n,modes:r=[],activeMode:o,onModeChange:s,disabled:c=!1,taskRunning:l=!1,onStop:u,ref:p}){const h=d(null);a(()=>{const e=h.current;if(!e)return;e.style.height="auto";const{scrollHeight:t}=e;e.style.height=`${Math.min(t,66)}px`,e.style.overflowY=t>66?"auto":"hidden"},[e]);const f=i(e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),n())},[n]),m=Boolean(e.trim())&&!c;/* @__PURE__ */
|
|
33
|
+
return v(oc,{background:"card",rounded:"xl",border:!0,overflow:"hidden",className:"mtx-composer",children:[/* @__PURE__ */b("textarea",{ref:fu(h,p),value:e,onChange:e=>t(e.target.value),onKeyDown:f,placeholder:"Ask anything",disabled:c,rows:1,className:"mtx-composer-input",style:{lineHeight:"20px",paddingTop:"4px",paddingBottom:"2px",minHeight:"unset"}}),/* @__PURE__ */v(rc,{align:"center",justify:"between",paddingX:"sm",paddingTop:"xs",paddingBottom:"sm",children:[/* @__PURE__ */b(rc,{align:"center",gap:"xs",children:r.map(e=>{const t=o===e.id;/* @__PURE__ */
|
|
34
|
+
return v("button",{type:"button",className:"mtx-mode-chip","data-active":t?"true":"false",onClick:t=>{t.preventDefault(),t.stopPropagation(),s?.(e.id)},children:[/* @__PURE__ */b(ac,{name:e.icon,size:12}),/* @__PURE__ */b(pc,{as:"span",inheritColor:!0,children:e.label})]},e.id)})}),/* @__PURE__ */b(cc,{variant:l?"secondary":"primary",size:"sm",disabled:!l&&!m,label:l?"Stop the assistant":"Send message",onClick:e=>{e.preventDefault(),e.stopPropagation(),l&&u?u():n()},children:/* @__PURE__ */b(ac,l?{name:"stop",size:14}:{name:"send",size:16})})]})]})}var gu=/*#__PURE__*/e.createContext(void 0);function yu(t){const n=e.useContext(gu);if(!t&&void 0===n)throw new Error(Dr(27));return n}var bu=/*#__PURE__*/e.forwardRef(function(e,t){const{render:n,className:r,style:o,forceRender:i=!1,...s}=e,a=yu(),c=a.useState("open"),l=a.useState("nested"),u=a.useState("mounted");return Zi("div",e,{state:{open:c,transitionStatus:a.useState("transitionStatus")},ref:[a.context.backdropRef,t],stateAttributesMapping:Xo,props:[{role:"presentation",hidden:!u,style:{userSelect:"none",WebkitUserSelect:"none"}},s],enabled:i||!l})}),vu=/*#__PURE__*/e.forwardRef(function(e,t){const{render:n,className:r,style:o,id:i,...s}=e,a=yu(),c=Vl(i);return a.useSyncedValueWithCleanup("descriptionElementId",c),Zi("p",e,{ref:t,props:[{id:c},s]})}),wu=/*#__PURE__*/e.createContext(void 0),xu="--nested-dialogs",Su="data-nested-dialog-open",ku={...Ko,...Wo,nestedDialogOpen:e=>e?{[Su]:""}:null},Cu=/*#__PURE__*/e.forwardRef(function(t,n){const{render:r,className:o,style:i,finalFocus:s,initialFocus:a,...c}=t,l=yu(),u=l.useState("descriptionElementId"),d=l.useState("disablePointerDismissal"),p=l.useState("floatingRootContext"),h=l.useState("popupProps"),f=l.useState("modal"),m=l.useState("mounted"),g=l.useState("nested"),y=l.useState("nestedOpenDialogCount"),v=l.useState("open"),w=l.useState("openMethod"),x=l.useState("titleElementId"),S=l.useState("transitionStatus"),k=l.useState("role"),C=p.useState("floatingId");!function(){if(void 0===e.useContext(wu))throw new Error(Dr(26))}(),as({open:v,ref:l.context.popupRef,onComplete(){v&&l.context.onOpenChangeComplete?.(!0)}});const E=void 0===a?(I=l.context.popupRef,e=>"touch"!==e||I.current):a;var I;const M=y>0,T=l.useStateSetter("popupElement"),R=Zi("div",t,{state:{open:v,nested:g,transitionStatus:S,nestedDialogOpen:M},props:[h,{id:C,"aria-labelledby":x,"aria-describedby":u,role:k,...wa,hidden:!m,onKeyDown(e){ou.has(e.key)&&e.stopPropagation()},style:{[xu]:y}},c],ref:[n,l.context.popupRef,T],stateAttributesMapping:ku});/*#__PURE__*/
|
|
35
|
+
return b(ma,{context:p,openInteractionType:w,disabled:!m,closeOnFocusOut:!d,initialFocus:E,returnFocus:s,modal:!1!==f,restoreFocus:"popup",children:R})}),Eu=/*#__PURE__*/e.forwardRef(function(e,t){const{cutout:n,...r}=e;let o;if(n){const e=n.getBoundingClientRect();o=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${e.left}px ${e.top}px,${e.left}px ${e.bottom}px,${e.right}px ${e.bottom}px,${e.right}px ${e.top}px,${e.left}px ${e.top}px)`}/*#__PURE__*/
|
|
36
|
+
return b("div",{ref:t,role:"presentation","data-base-ui-inert":"",...r,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:o}})}),Iu=/*#__PURE__*/e.forwardRef(function(e,t){const{keepMounted:n=!1,...r}=e,o=yu(),i=o.useState("mounted"),s=o.useState("modal"),a=o.useState("open");return i||n?/*#__PURE__*/b(wu.Provider,{value:n,children:/*#__PURE__*/v(Hs,{ref:t,...r,children:[i&&!0===s&&/*#__PURE__*/b(Eu,{ref:o.context.internalBackdropRef,inert:ns(!a)}),e.children]})}):null}),Mu={},Tu={},Ru="";function Ou(e,t){return function(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=so(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&"inline"!==o&&"contents"!==o}(e)?e:t}function Au(e,t,n){return/hidden|clip/.test(e.getComputedStyle(Ou(t,n)).overflowY)}var _u=new class{lockCount=0;restore=null;timeoutLock=go.create();timeoutUnlock=go.create();acquire(e){return this.lockCount+=1,1===this.lockCount&&null===this.restore&&this.timeoutLock.start(0,()=>this.lock(e)),this.release}release=()=>{this.lockCount-=1,0===this.lockCount&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{0===this.lockCount&&this.restore&&(this.restore?.(),this.restore=null)};lock(e){if(0===this.lockCount||null!==this.restore)return;const t=lo(e),n=t.documentElement,r=t.body,o=eo(n);if(Au(o,n,r)){const t=new o.MutationObserver(()=>{Au(o,n,r)||(t.disconnect(),this.restore=null,this.lock(e))}),i={attributes:!0};return t.observe(n,i),t.observe(r,i),void(this.restore=()=>t.disconnect())}const i=Eo||!function(e){if("undefined"==typeof document)return!1;const t=lo(e);return eo(t).innerWidth-t.documentElement.clientWidth>0}(e);this.restore=i?function(e){const t=lo(e),n=Ou(t.documentElement,t.body),r={overflowY:n.style.overflowY,overflowX:n.style.overflowX};return Object.assign(n.style,{overflowY:"hidden",overflowX:"hidden"}),()=>{Object.assign(n.style,r)}}(e):function(e){const t=lo(e),n=t.documentElement,r=t.body,o=eo(n);let i=0,s=0,a=!1;const c=fo.create();if(Oo&&1!==(o.visualViewport?.scale??1))return()=>{};function l(){const t=o.getComputedStyle(n),c=o.getComputedStyle(r),l=(t.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";i=n.scrollTop,s=n.scrollLeft,Mu={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},Ru=n.style.scrollBehavior,Tu={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};const u=n.scrollHeight>n.clientHeight,d=n.scrollWidth>n.clientWidth,p="scroll"===t.overflowY||"scroll"===c.overflowY,h="scroll"===t.overflowX||"scroll"===c.overflowX,f=Math.max(0,o.innerWidth-r.clientWidth),m=Math.max(0,o.innerHeight-r.clientHeight),g=parseFloat(c.marginTop)+parseFloat(c.marginBottom),y=parseFloat(c.marginLeft)+parseFloat(c.marginRight),b=Ou(n,r);if(a=function(e){if("undefined"==typeof CSS||!CSS.supports||!CSS.supports("scrollbar-gutter","stable")||"undefined"==typeof document)return!1;const t=lo(e),n=t.documentElement,r=Ou(n,t.body),o=r.style.overflowY,i=n.style.scrollbarGutter;n.style.scrollbarGutter="stable",r.style.overflowY="scroll";const s=r.offsetWidth;r.style.overflowY="hidden";const a=r.offsetWidth;return r.style.overflowY=o,n.style.scrollbarGutter=i,s===a}(e),a)return n.style.scrollbarGutter=l,b.style.overflowY="hidden",void(b.style.overflowX="hidden");Object.assign(n.style,{scrollbarGutter:l,overflowY:"hidden",overflowX:"hidden"}),(u||p)&&(n.style.overflowY="scroll"),(d||h)&&(n.style.overflowX="scroll"),Object.assign(r.style,{position:"relative",height:g||m?`calc(100dvh - ${g+m}px)`:"100dvh",width:y||f?`calc(100vw - ${y+f}px)`:"100vw",boxSizing:"border-box",overflowY:"hidden",overflowX:"hidden",scrollBehavior:"unset"}),r.scrollTop=i,r.scrollLeft=s,n.setAttribute("data-base-ui-scroll-locked",""),n.style.scrollBehavior="unset"}function u(){Object.assign(n.style,Mu),Object.assign(r.style,Tu),a||(n.scrollTop=i,n.scrollLeft=s,n.removeAttribute("data-base-ui-scroll-locked"),n.style.scrollBehavior=Ru)}l();const d=uo(o,"resize",function(){u(),c.request(l)});return()=>{c.cancel(),u(),"function"==typeof o.removeEventListener&&d()}}(e)}};function Du({store:t,parentContext:n,isDrawer:r}){const o=t.useState("open"),i=t.useState("disablePointerDismissal"),s=t.useState("modal"),a=t.useState("popupElement"),c=t.useState("floatingRootContext"),[l,u]=e.useState(0),[d,p]=e.useState(0),h=0===l,f=function(t,n={}){const{enabled:r=!0,escapeKey:o=!0,outsidePress:i=!0,outsidePressEvent:s="sloppy",referencePress:a=ga,bubbles:c,externalTree:l}=n,u="rootStore"in t?t.rootStore:t,d=u.useState("open"),p=u.useState("floatingElement"),{dataRef:h,events:f}=u.context,m=la(l),g=Kr("function"==typeof i?i:()=>!1),y="function"==typeof i?g:i,b=!1!==y,v=Kr(()=>s),{escapeKey:w,outsidePress:x}={escapeKey:"boolean"==typeof(S=c)?S:S?.escapeKey??!1,outsidePress:"boolean"==typeof S?S:S?.outsidePress??!0};var S;const k=e.useRef(!1),C=e.useRef(!1),E=e.useRef(!1),I=e.useRef(!1),M=e.useRef(!1),T=e.useRef(""),R=e.useRef(null),O=yo(),A=yo(),_=Kr(()=>{A.clear(),h.current.insideReactTree=!1}),D=Kr(e=>{const t=h.current.floatingContext?.nodeId;return(m?ti(m.nodesRef.current,t):[]).some(t=>t.context?.open&&!t.context.dataRef.current[e])}),P=Kr(e=>Go(e,u.select("floatingElement"))||Go(e,u.select("domReferenceElement"))),N=Kr(e=>{a()&&u.setOpen(!1,Fs("trigger-press",e.nativeEvent))}),L=Kr(e=>{if(!d||!r||!o||"Escape"!==e.key)return;if(M.current)return;if(!w&&D("__escapeKeyBubbles"))return;const t=Fs("escape-key",function(e){return"nativeEvent"in e}(e)?e.nativeEvent:e);u.setOpen(!1,t),t.isCanceled||e.preventDefault(),w||t.isPropagationAllowed||e.stopPropagation()}),F=Kr(()=>{h.current.insideReactTree=!0,A.start(0,_)}),z=Kr(e=>{if(!d||!r||0!==e.button)return;const t=No(e.nativeEvent);Po(u.select("floatingElement"),t)&&(k.current||(k.current=!0,C.current=!1))}),B=Kr(e=>{d&&r&&(e.defaultPrevented||e.nativeEvent.defaultPrevented)&&k.current&&(C.current=!0)});e.useEffect(()=>{function e(e){e.open||(I.current=!1)}return f.on("openchange",e),()=>{f.off("openchange",e)}},[f]),e.useEffect(()=>{if(!d||!r)return d||(I.current=!1),_;h.current.__escapeKeyBubbles=w,h.current.__outsidePressBubbles=x;const e=new go,t=new go,n=lo(p);function i(){E.current=!0,t.start(0,()=>{E.current=!1})}function s(){k.current=!1,C.current=!1}function a(){const e=T.current,t="pen"!==e&&e?e:"mouse",n=v(),r="function"==typeof n?n():n;return"string"==typeof r?r:r[t]}function c(e){const t=h.current.floatingContext?.nodeId,n=m&&ti(m.nodesRef.current,t).some(t=>Go(e,t.context?.elements.floating));return P(e)||n}function l(e){if(function(e){const t=a();return"intentional"===t&&"click"!==e.type||"sloppy"===t&&"click"===e.type}(e))return"click"===e.type||P(e)||(t.clear(),E.current=!1),void _();if(h.current.insideReactTree)return void _();const n=No(e),r=`[${zs("inert")}]`,o=no(n)?n.getRootNode():null,i=Array.from((oo(o)?o:lo(u.select("floatingElement"))).querySelectorAll(r)),s=u.context.triggerElements;if(n&&(s.hasElement(n)||s.hasMatchingElement(e=>Po(e,n))))return;let l=no(n)?n:null;for(;l&&!io(l);){const e=ao(l);if(io(e)||!no(e))break;l=e}if(!i.length||!no(n)||n.matches("html,body")||Po(n,u.select("floatingElement"))||!i.every(e=>!Po(l,e))){if(ro(n)&&!("touches"in e)){const t=io(n),r=so(n),o=/auto|scroll/,i=t||o.test(r.overflowX),s=t||o.test(r.overflowY),a=i&&n.clientWidth>0&&n.scrollWidth>n.clientWidth,c=s&&n.clientHeight>0&&n.scrollHeight>n.clientHeight,l="rtl"===r.direction,u=c&&(l?e.offsetX<=n.offsetWidth-n.clientWidth:e.offsetX>n.clientWidth),d=a&&e.offsetY>n.clientHeight;if(u||d)return}if(!c(e)){if("intentional"===a()){if(0!==e.detail&&!ri(e)&&!I.current)return;if(E.current)return t.clear(),void(E.current=!1)}("function"!=typeof y||y(e))&&(D("__outsidePressBubbles")||(u.setOpen(!1,Fs("outside-press",e)),_()))}}}function f(e){if("sloppy"!==a()||!u.select("open")||!r||P(e))return;const t=e.touches[0];t&&(R.current={startTime:Date.now(),startX:t.clientX,startY:t.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},O.start(1e3,()=>{R.current&&(R.current.dismissOnTouchEnd=!1,R.current.dismissOnMouseDown=!1)}))}function g(e,t){const n=No(e);if(!n)return;const r=uo(n,e.type,()=>{t(e),r()})}function S(e){O.clear(),"pointerdown"===e.type&&(0===e.button&&(I.current=!0),T.current=e.pointerType),"mousedown"===e.type&&R.current&&!R.current.dismissOnMouseDown||g(e,e=>{"pointerdown"===e.type?function(e){"sloppy"===a()&&"touch"!==e.pointerType&&u.select("open")&&r&&!P(e)&&l(e)}(e):l(e)})}function A(e){if("pointercancel"===e.type&&(I.current=!1),!k.current)return;const n=C.current;s(),"intentional"===a()&&("pointercancel"!==e.type?c(e)||(n?i():("function"!=typeof y||y(e))&&(t.clear(),E.current=!0,_())):n&&i())}function N(e){if("sloppy"!==a()||!R.current||P(e))return;const t=e.touches[0];if(!t)return;const n=Math.abs(t.clientX-R.current.startX),r=Math.abs(t.clientY-R.current.startY),o=Math.sqrt(n*n+r*r);o>5&&(R.current.dismissOnTouchEnd=!0),o>10&&(l(e),O.clear(),R.current=null)}function F(e){"sloppy"===a()&&R.current&&!P(e)&&(R.current.dismissOnTouchEnd&&l(e),O.clear(),R.current=null)}const z=co(o&&co(uo(n,"keydown",L),uo(n,"compositionstart",function(){e.clear(),M.current=!0}),uo(n,"compositionend",function(){e.start(Oo?5:0,()=>{M.current=!1})})),b&&co(uo(n,"click",S,!0),uo(n,"pointerdown",S,!0),uo(n,"pointerup",A,!0),uo(n,"pointercancel",A,!0),uo(n,"mousedown",S,!0),uo(n,"mouseup",A,!0),uo(n,"touchstart",function(e){T.current="touch",g(e,f)},{capture:!0,passive:!0}),uo(n,"touchmove",function(e){g(e,N)},{capture:!0,passive:!0}),uo(n,"touchend",function(e){g(e,F)},{capture:!0,passive:!0})));return()=>{z(),e.clear(),t.clear(),s(),E.current=!1,_()}},[h,p,o,b,y,d,r,w,x,L,_,v,D,P,m,u,O]);const $=e.useMemo(()=>({onKeyDown:L,onPointerDown:N,onClick:N}),[L,N]),W=e.useMemo(()=>({onKeyDown:L,onPointerDown:B,onMouseDown:B,onClickCapture:F,onMouseDownCapture(e){F(),z(e)},onPointerDownCapture(e){F(),z(e)},onMouseUpCapture:F,onTouchEndCapture:F,onTouchMoveCapture:F}),[L,F,z,B]);return e.useMemo(()=>r?{reference:$,floating:W,trigger:$}:{},[r,$,W])}(c,{outsidePressEvent:()=>t.context.internalBackdropRef.current||t.context.backdropRef.current?"intentional":{mouse:"trap-focus"===s?"sloppy":"intentional",touch:"sloppy"},outsidePress(e){if(!t.context.outsidePressEnabledRef.current)return!1;if("button"in e&&0!==e.button)return!1;if("touches"in e)if("touchend"===e.type){if(1!==e.changedTouches.length||0!==e.touches.length)return!1}else if(1!==e.touches.length)return!1;const n=No(e);if(h&&!i){if(s){const e=t.context.internalBackdropRef.current,r=t.context.backdropRef.current;return!e&&!r||e===n||r===n||Po(n,a)&&!n?.hasAttribute("data-base-ui-portal")}return!0}return!1},escapeKey:h});return function(e=!0,t=null){_r(()=>{if(e)return _u.acquire(t)},[e,t])}(o&&!0===s,a),t.useContextCallback("onNestedDialogOpen",(e,t)=>{u(e),p(t)}),_r(()=>(n?.onNestedDialogOpen&&(o?n.onNestedDialogOpen(l+1,d+(r?1:0)):n.onNestedDialogOpen(0,0)),()=>{n?.onNestedDialogOpen&&o&&n.onNestedDialogOpen(0,0)}),[r,o,l,d,n]),function(e,t){e.useSyncedValues(t),_r(()=>()=>{e.update({activeTriggerProps:Tr,inactiveTriggerProps:Tr,popupProps:Tr})},[e])}(t,{activeTriggerProps:f.reference,inactiveTriggerProps:f.trigger,popupProps:f.floating,nestedOpenDialogCount:l,nestedOpenDrawerCount:d}),null}var Pu={...Ta,modal:e=>e.modal,nested:e=>e.nested,nestedOpenDialogCount:e=>e.nestedOpenDialogCount,nestedOpenDrawerCount:e=>e.nestedOpenDrawerCount,disablePointerDismissal:e=>e.disablePointerDismissal,openMethod:e=>e.openMethod,descriptionElementId:e=>e.descriptionElementId,titleElementId:e=>e.titleElementId,viewportElement:e=>e.viewportElement,role:e=>e.role},Nu=class extends Jr{constructor(t,n,r){const o=new Sa,i=function(e,t,n,r=!1){return{...ka(t,n,r),modal:!0,disablePointerDismissal:!1,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:"dialog",...e}}(t,o,n,r);super(i,function(t){return{popupRef:/*#__PURE__*/e.createRef(),backdropRef:/*#__PURE__*/e.createRef(),internalBackdropRef:/*#__PURE__*/e.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:t,onOpenChange:void 0,onOpenChangeComplete:void 0}}(o),Pu)}setOpen=(e,t)=>{t.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},e||null!=t.trigger||null==this.state.activeTriggerId||(t.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,t),t.isCanceled||(this.state.floatingRootContext.dispatchOpenChange(e,t),this.update(function(e,t,n,r=!1){let o=e.preventUnmountingOnClose;t?o=!1:r&&(o=!0);const i=n?.id??null;let s=e.activeTriggerId,a=e.activeTriggerElement;return(i||t)&&(s=i,a=n??null),{open:t,preventUnmountingOnClose:o,activeTriggerId:s,activeTriggerElement:a}}(this.state,e,t.trigger)))}};var Lu=function(e){const t=(t,n)=>{const r=Ar($r).current;let o;try{Br=r;for(const e of zr)e.before(r);o=e(t);for(const e of zr)e.after(r);r.didInitialize=!0}finally{Br=void 0}return o};return t.displayName=e.displayName||e.name,t}(function(t){return function(t,n){const{children:r,open:o,defaultOpen:i=!1,onOpenChange:s,onOpenChangeComplete:a,disablePointerDismissal:c=!1,modal:l=!0,actionsRef:u,handle:d,triggerId:p,defaultTriggerId:h=null}=n,f="drawer"===t,m="alert-dialog"===t,g=!!m||l,y=m||c,w=m?"alertdialog":"dialog",x=yu(!0),S={modal:g,disablePointerDismissal:y,nested:null!=x,role:w},k=function(t,n=!1){const r=ws(),o=null!=(e.useContext(aa)?.id||null),i=Ar(()=>t(r,o)).current;return function(t){const{popupStore:n,treatPopupAsFloatingElement:r=!1,floatingRootContext:o,floatingId:i,nested:s,onOpenChange:a}=t,c=n.useState("open"),l=n.useState("activeTriggerElement"),u=n.useState(r?"popupElement":"positionerElement"),d=n.context.triggerElements,p=a,h=e.useRef(null);void 0===o&&null===h.current&&(h.current=new ba({open:c,transitionStatus:void 0,referenceElement:l,floatingElement:u,triggerElements:d,onOpenChange:p,floatingId:i,syncOnly:!0,nested:s}));const f=o??h.current;n.useSyncedValue("floatingId",i),_r(()=>{const e={open:c,floatingId:i,referenceElement:l,floatingElement:u};no(l)&&(e.domReferenceElement=l),f.state.positionReference===f.state.referenceElement&&(e.positionReference=l),f.update(e)},[c,i,l,u,f]),f.context.onOpenChange=p,f.context.nested=s}({popupStore:i,treatPopupAsFloatingElement:n,floatingRootContext:i.state.floatingRootContext,floatingId:r,nested:o,onOpenChange:i.setOpen}),i}((e,t)=>new Nu({open:i,openProp:o,activeTriggerId:h,triggerIdProp:p,...S},e,t),!0);k.useControlledProp("openProp",o),k.useControlledProp("triggerIdProp",p),k.useSyncedValues(S),k.useContextCallback("onOpenChange",s),k.useContextCallback("onOpenChangeComplete",a);const C=k.useState("open"),E=k.useState("mounted"),I=k.useState("payload");!function(e,t){_r(()=>{t||null===e.state.openMethod||e.set("openMethod",null)},[t,e]),_r(()=>()=>{null!==e.state.openMethod&&e.set("openMethod",null)},[e])}(k,C),function(t,n={}){const{closeOnActiveTriggerUnmount:r=!1}=n,o=e.useRef(null),i=t.useState("open"),s=t.useState("triggerCount"),a=t.useState("activeTriggerId"),c=t.useState("activeTriggerElement");_r(()=>{if(!i)return o.current=null,void(0!==t.state.triggerCount&&t.set("triggerCount",0));const e=t.context.triggerElements.size,n={};t.state.triggerCount!==e&&(n.triggerCount=e);const s=t.select("activeTriggerId");let a=null;if(s){const e=t.context.triggerElements.getById(s);if(e)o.current=s,e!==t.state.activeTriggerElement&&(n.activeTriggerElement=e);else{for(const[e,r]of t.context.triggerElements.entries())if(r===t.state.activeTriggerElement){n.activeTriggerId=e,n.activeTriggerElement=r,o.current=e;break}void 0===n.activeTriggerId&&(o.current===s?a=s:o.current=null)}}else o.current=null;if(!a&&!s&&1===e){const e=t.context.triggerElements.entries().next();if(!e.done){const[t,r]=e.value;n.activeTriggerId=t,n.activeTriggerElement=r,o.current=t}}void 0===n.triggerCount&&void 0===n.activeTriggerId&&void 0===n.activeTriggerElement||t.update(n),a&&r&&queueMicrotask(()=>{if(t.select("open")&&t.select("activeTriggerId")===a&&!t.context.triggerElements.getById(a)){const e=Fs(Ps);t.setOpen(!1,e),e.isCanceled||t.update({activeTriggerId:null,activeTriggerElement:null})}})},[i,t,s,a,c,r])}(k);const{forceUnmount:M}=function(e,t){const{mounted:n,setMounted:r,transitionStatus:o}=va(e,!1,!1,void 0),i=t.useState("preventUnmountingOnClose"),s=!e&&i;t.useSyncedValues({mounted:n,transitionStatus:o,preventUnmountingOnClose:s});const a=Kr(()=>{r(!1),t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1,preventUnmountingOnClose:!1}),t.context.onOpenChangeComplete?.(!1)});return as({enabled:n&&!e&&!s,open:e,ref:t.context.popupRef,onComplete(){e||a()}}),{forceUnmount:a,transitionStatus:o}}(C,k);e.useImperativeHandle(u,()=>({unmount:M,close:()=>k.setOpen(!1,Fs("imperative-action"))}),[M,k]);const T=C||E;/*#__PURE__*/
|
|
37
|
+
return v(gu.Provider,{value:k,children:[d&&/*#__PURE__*/b(xa,{handle:d,store:k}),T&&/*#__PURE__*/b(Du,{store:k,parentContext:x?.context,isDrawer:f}),"function"==typeof r?r({payload:I}):r]})}("dialog",t)}),Fu=/*#__PURE__*/e.forwardRef(function(e,t){const{render:n,className:r,style:o,id:i,...s}=e,a=yu(),c=Vl(i);return a.useSyncedValueWithCleanup("titleElementId",c),Zi("h2",e,{ref:t,props:[{id:c},s]})}),zu=({open:e,onClose:t,title:n,description:r,onConfirm:o,confirmLabel:i="Confirm",cancelLabel:a="Cancel",finalFocusRef:c})=>{const l=s(ul)??document.body;/* @__PURE__ */
|
|
38
|
+
return b(Lu,{open:e,onOpenChange:(e,n)=>{e||"none"===n.reason||t()},children:/* @__PURE__ */v(Iu,{container:l,children:[/* @__PURE__ */b(bu,{className:"mtx-dialog-backdrop",style:{zIndex:La}}),/* @__PURE__ */v(Cu,{className:"mtx-dialog-popup",finalFocus:c,style:{...za("panel"),zIndex:La},children:[
|
|
39
|
+
/* @__PURE__ */b(Fu,{className:"mtx-dialog-title",children:n}),null!=r&&/* @__PURE__ */b(vu,{className:"mtx-dialog-description",children:r}),
|
|
40
|
+
/* @__PURE__ */b(rc,{gap:"md",justify:"end",children:[["secondary",a,t],["primary",i,()=>o?.()]].map(([e,t,n])=>/* @__PURE__ */b(Ja,{type:"button",variant:e,size:"sm",shape:"pill",onClick:e=>{e.preventDefault(),e.stopPropagation(),n()},children:t},e))})]})]})})},Bu={sm:{width:"14px",height:"14px",borderWidth:"1.5px"},md:{width:"20px",height:"20px",borderWidth:"2px"},lg:{width:"24px",height:"24px",borderWidth:"2px"}};function $u({size:e="md",style:t,ref:n}){/* @__PURE__ */
|
|
41
|
+
return v("div",{ref:n,"data-size":e,role:"status",style:{display:"inline-flex",alignItems:"center",gap:"6px",...t},children:[/* @__PURE__ */b("div",{"aria-hidden":"true",className:"mtx-spinner-ring",style:Bu[e]}),/* @__PURE__ */b("span",{className:"mtx-visually-hidden",children:"Loading"})]})}var Wu="8px 8px 0 0",Uu=({label:e,children:t})=>/* @__PURE__ */b(rc,{position:"absolute",inset:"0",align:"center",justify:"center",style:{backgroundColor:"#111827",borderRadius:Wu,zIndex:10},children:/* @__PURE__ */v(rc,{direction:"column",align:"center",gap:"md",style:{textAlign:"center",padding:"0 16px"},children:[t,/* @__PURE__ */b(pc,{as:"span",size:"xs",weight:"medium",style:{color:"rgba(255,255,255,0.7)"},children:e})]})}),Hu=({stream:e})=>{const t=d(null),[n,r]=p(!1),[o,i]=p(!1);return a(()=>{const n=t.current;if(!n)return;r(!1),i(!1),n.srcObject=e;const o=()=>{r(!0)},s=()=>{i(!0),r(!1)};return n.addEventListener("loadedmetadata",o),n.addEventListener("error",s),n.play().catch(e=>{e instanceof Error&&"AbortError"!==e.name&&(console.error("Error playing video stream:",e),i(!0))}),()=>{n.removeEventListener("loadedmetadata",o),n.removeEventListener("error",s),n.srcObject=null}},[e]),/* @__PURE__ */v(nc,{width:"full",overflow:"hidden",position:"relative",style:{marginBottom:"4px",borderRadius:Wu,backgroundColor:"#000000",boxShadow:"0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06)"},children:[!n&&!o&&/* @__PURE__ */b(Uu,{label:"Loading stream...",children:/* @__PURE__ */b($u,{size:"lg",style:{color:"white"}})}),o&&/* @__PURE__ */b(Uu,{label:"Failed to load stream",children:/* @__PURE__ */b(ac,{name:"alertCircle",size:32,style:{color:"#9ca3af"}})}),
|
|
42
|
+
/* @__PURE__ */b("video",{ref:t,autoPlay:!0,muted:!0,playsInline:!0,style:{width:"100%",height:"auto",maxHeight:"192px",objectFit:"contain",borderRadius:Wu,transition:"opacity 500ms",opacity:n?1:0,minHeight:"120px",background:"linear-gradient(135deg, #111827 0%, #374151 100%)"}}),n&&!o&&/* @__PURE__ */v(rc,{position:"absolute",align:"center",gap:"sm",animate:"fadeIn",style:{top:"8px",right:"8px",padding:"4px 8px",borderRadius:"9999px",backgroundColor:"rgba(55,65,81,0.9)",backdropFilter:"blur(4px)",zIndex:20,boxShadow:"0 2px 8px rgba(31, 41, 55, 0.4)"},children:[/* @__PURE__ */b(pu,{style:{color:"white"}}),/* @__PURE__ */b(pc,{as:"span",size:"xs",weight:"semibold",style:{color:"white",textTransform:"uppercase",letterSpacing:"0.05em",fontSize:"10px"},children:"Live"})]}),
|
|
43
|
+
/* @__PURE__ */b(rc,{position:"absolute",inset:"0",align:"center",justify:"center",style:{borderRadius:Wu,backgroundColor:"rgba(0,0,0,0)",zIndex:30,pointerEvents:"none"},children:/* @__PURE__ */b(nc,{rounded:"lg",style:{padding:"4px 12px",backgroundColor:"rgba(0,0,0,0.7)",backdropFilter:"blur(4px)"},children:/* @__PURE__ */b(pc,{as:"div",size:"xs",weight:"medium",style:{color:"white"},children:"Screen Sharing Active"})})})]})},ju={done:{name:"checkCircle",opacity:1},failed:{name:"exclamationCircle",opacity:.75},stopped:{name:"circle",opacity:.5}},qu=({isWaitingForUser:e})=>/* @__PURE__ */v(rc,{align:"center",gap:"sm",paddingY:"2xs",children:[/* @__PURE__ */b($u,{size:"sm"}),/* @__PURE__ */b(pc,{as:"span",size:"xs",weight:"normal",variant:"faint",children:e?"Waiting for you to complete the action":"Thinking"})]}),Vu=({message:e,isLastMessage:t})=>{const{isTaskRunning:n}=kl().state,r="waiting-for-user"===e.placeholderState,o=n&&t&&("show"===e.mode||"do"===e.mode);return 0===e.parts.length?e.isPlaceholder||o?/* @__PURE__ */b(qu,{isWaitingForUser:r}):/* @__PURE__ */b(nc,{}):/* @__PURE__ */v(oc,{gap:"sm",children:[e.parts.map((e,t)=>"text"===e.type?e.content?/* @__PURE__ */b(pc,{as:"div",size:"sm",weight:"medium",style:{wordBreak:"break-word",whiteSpace:"pre-wrap",marginBottom:"4px"},children:e.content},`part-${t}`):null:"progress"===e.type?/* @__PURE__ */b(rc,{align:"start",gap:"md",children:/* @__PURE__ */b(pc,{as:"span",size:"xs",weight:"medium",style:{flex:1,whiteSpace:"pre-wrap"},children:e.content})},`part-${t}`):null),(e.isPlaceholder&&!e.parts.some(e=>"text"===e.type)||o)&&/* @__PURE__ */b(qu,{isWaitingForUser:r})]})},Yu=({message:e,isLastMessage:t,onScreenAccessAllow:n,onScreenAccessDeny:r})=>{const o=Sl().widget_accent_color;if(e.isSystemMessage)/* @__PURE__ */return b(rc,{justify:"center",align:"center",children:/* @__PURE__ */b(pc,{as:"span",variant:"faint",weight:"normal",style:{fontSize:"10px"},children:e.content})});const i="user"===e.sender,s=i?"show"===e.mode||"do"===e.mode?"mousePointerClick":void 0:e.isScreenAccessRequest||"waiting-for-user"===e.placeholderState?"checkCircle":void 0,a=!i&&e.taskStatus?ju[e.taskStatus]:void 0;/* @__PURE__ */
|
|
44
44
|
return v(oc,{style:{marginTop:"10px"},role:"article","aria-roledescription":"message","aria-label":i?"You said…":"Assistant says…",animate:t?"fadeIn":void 0,children:[/* @__PURE__ */v(rc,{align:"start",gap:"sm",width:"full",children:[
|
|
45
45
|
/* @__PURE__ */b(rc,{shrink:!1,style:{width:"20px",height:"20px",marginTop:"6px"},children:!i&&/* @__PURE__ */b(Ka,{src:"data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20id='Layer_1'%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%20viewBox='0%200%20361%20360'%3e%3cdefs%3e%3cstyle%3e%20.st0%20{%20display:%20none;%20fill:%20none;%20stroke:%20%23cdc9c2;%20stroke-width:%201.3px;%20}%20.st1%20{%20fill:%20%23fff;%20}%20.st2,%20.st3%20{%20fill:%20%237cffa6;%20}%20.st3%20{%20stroke:%20%237cffa6;%20stroke-width:%20.38px;%20}%20.st4%20{%20fill:%20%23101828;%20}%20%3c/style%3e%3c/defs%3e%3crect%20class='st4'%20x='.5'%20width='360'%20height='360'/%3e%3cpath%20class='st2'%20d='M83.37,209.58c15.35,0,27.8-12.45,27.8-27.8s-12.44-27.79-27.8-27.79-27.8,12.44-27.8,27.79,12.44,27.8,27.8,27.8Z'/%3e%3cpath%20class='st1'%20d='M85.86,68.28l152.45,223.44h67.29l-70.62-113.77,68.13-109.67h-67.29l-41.12,65.31-41.54-65.31h-67.29Z'/%3e%3cpath%20class='st3'%20d='M176.61,249.83l-35.08-51-57.82,92.71h66.85l26.05-41.7Z'/%3e%3crect%20class='st0'%20x='1.25'%20y='.65'%20width='358.7'%20height='358.7'%20rx='43.35'%20ry='43.35'/%3e%3c/svg%3e",alt:"Marketrix AI",size:20,fit:"cover",rounded:"lg",style:{border:"none",outline:"none",display:"block",backgroundColor:"transparent"}})}),
|
|
46
|
-
/* @__PURE__ */v(oc,{grow:!0,position:"relative",rounded:"lg",elevation:"card",style:{padding:e.videoStream?"0":"8px 10px",border:"1px solid transparent",backgroundColor:i?"var(--primary)":void 0,color:i?"var(--primary-foreground)":"var(--foreground)"},children:[e.videoStream&&/* @__PURE__ */b(
|
|
47
|
-
/* @__PURE__ */b(rc,{shrink:!1,style:{width:"20px"}})]}),!e.isPlaceholder&&/* @__PURE__ */b(pc,{as:"div",variant:"faint",size:"xxs",align:"right",style:{marginTop:"2px",marginRight:"26px"},children:(c=e.timestamp,(c??/* @__PURE__ */new Date).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}))})]});var c},
|
|
48
|
-
/* @__PURE__ */b(nc,{ref:e},"scroll-anchor")]},"message-list-container"),[{show:l,edge:{top:"8px"},label:"Scroll to top",icon:"arrowUp",onClick:()=>g.current?.scrollTo({top:0,behavior:"smooth"})},{show:f,edge:{bottom:"8px"},label:"Scroll to bottom",icon:"arrowDown",onClick:()=>!c&&e.current?.scrollIntoView({behavior:"smooth"})}].map(({show:e,edge:t,label:n,icon:o,onClick:i})=>e&&/* @__PURE__ */b(rc,{position:"absolute",justify:"center",style:{...t,left:0,right:0,zIndex:10,pointerEvents:"none"},children:/* @__PURE__ */b(cc,{variant:"secondary",size:"sm",label:n,onClick:i,style:
|
|
49
|
-
return v(oc,{height:"full",children:[w&&/* @__PURE__ */b(
|
|
50
|
-
/* @__PURE__ */b(oc,{grow:!0,overflow:"hidden",paddingY:"2xs",minHeight:"0",children:/* @__PURE__ */b(Ol,{label:"Chat",fallback:/* @__PURE__ */b(pc,{as:"div",size:"xs",align:"center",variant:"muted",style:{padding:"16px"},children:"Something went wrong displaying messages. Please refresh."}),children:/* @__PURE__ */b(
|
|
51
|
-
/* @__PURE__ */b(nc,{variant:"floatingCard",style:{marginTop:"auto"},children:/* @__PURE__ */b(
|
|
46
|
+
/* @__PURE__ */v(oc,{grow:!0,position:"relative",rounded:"lg",elevation:"card",style:{padding:e.videoStream?"0":"8px 10px",border:"1px solid transparent",backgroundColor:i?"var(--primary)":void 0,color:i?"var(--primary-foreground)":"var(--foreground)"},children:[e.videoStream&&/* @__PURE__ */b(Hu,{stream:e.videoStream}),!e.videoStream&&(s?/* @__PURE__ */v(rc,{align:"start",gap:"sm",children:[/* @__PURE__ */b(rc,{shrink:!1,style:{marginTop:"3px"},children:/* @__PURE__ */b(ac,{name:s,size:13})}),/* @__PURE__ */b(oc,{grow:!0,children:/* @__PURE__ */b(Vu,{message:e,isLastMessage:t})})]}):/* @__PURE__ */b(Vu,{message:e,isLastMessage:t})),e.isScreenAccessRequest&&!e.screenShareStatus&&/* @__PURE__ */v(rc,{align:"center",gap:"sm",style:{marginTop:"6px"},children:[/* @__PURE__ */b(Ja,{type:"button",variant:"primary",size:"sm",shape:"pill",onClick:()=>n?.(),children:"Yes"}),/* @__PURE__ */b(Ja,{type:"button",variant:"secondary",size:"sm",shape:"pill",onClick:()=>r?.(),children:"No"})]}),e.isScreenAccessRequest&&e.screenShareStatus&&/* @__PURE__ */b(pc,{as:"div",variant:"faint",size:"xs",italic:!0,style:{marginTop:"2px"},children:"allowed"===e.screenShareStatus?"Sure":"No"}),a&&/* @__PURE__ */b(rc,{position:"absolute",align:"center",justify:"center",style:{bottom:"4px",right:"4px"},children:/* @__PURE__ */b(ac,{name:a.name,size:14,style:{color:bl(o,a.opacity),flexShrink:0}})})]}),
|
|
47
|
+
/* @__PURE__ */b(rc,{shrink:!1,style:{width:"20px"}})]}),!e.isPlaceholder&&/* @__PURE__ */b(pc,{as:"div",variant:"faint",size:"xxs",align:"right",style:{marginTop:"2px",marginRight:"26px"},children:(c=e.timestamp,(c??/* @__PURE__ */new Date).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}))})]});var c},Ku={boxShadow:Na.button,backgroundColor:"var(--card)",border:"1px solid var(--border)",pointerEvents:"auto"},Xu=({messagesEndRef:e,onScreenAccessAllow:t,onScreenAccessDeny:n})=>{const r=Sl(),{state:o,actions:i}=kl(),{messages:s}=o,{isPreviewMode:c}=r,[l,h]=p(!1),[f,m]=p(!1),g=d(null),y=u(()=>jc(r.widget_body),[r.widget_body]),w=u(()=>[y,...s],[y,s]),x=()=>{if(g.current){const{scrollTop:e,scrollHeight:t,clientHeight:n}=g.current;h(e>200);const r=Math.abs(t-e-n)<50;m(!r&&t>n)}};a(()=>{window.requestAnimationFrame(()=>{e.current&&(!c&&e.current.scrollIntoView({behavior:"auto"}),!c&&x())})},[s.length,c]);const S=s[s.length-1]?.content?.length??0;return a(()=>{const t=g.current;t&&!c&&t.scrollHeight-t.scrollTop-t.clientHeight<120&&window.requestAnimationFrame(()=>e.current?.scrollIntoView({behavior:"auto"}))},[S,c,e]),/* @__PURE__ */v(nc,{position:"relative",height:"full",children:[/* @__PURE__ */v(nc,{ref:g,onScroll:x,role:"log","aria-relevant":"additions",height:"full",overflowY:"auto",paddingX:"lg",paddingY:"sm",style:{backgroundColor:r.widget_background_color.includes("gradient")?"transparent":r.widget_background_color,backgroundImage:vl(r.widget_background_color),scrollbarColor:`${bl(r.widget_border_color,.3)} ${bl(r.widget_border_color,.1)}`,scrollbarWidth:"thin"},children:[w.map((e,r)=>/* @__PURE__ */b(Yu,{message:e,isLastMessage:r===w.length-1,onScreenAccessAllow:t,onScreenAccessDeny:n},`message-${e.id}-${r}`)),s.length>0&&/* @__PURE__ */b(rc,{justify:"center",style:{marginTop:"12px",marginBottom:"4px"},children:/* @__PURE__ */b(Ja,{type:"button",variant:"bare",onClick:i.clearChatHistory,children:/* @__PURE__ */b(pc,{size:"xs",variant:"muted",style:{cursor:"pointer"},children:"Clear conversation"})})}),
|
|
48
|
+
/* @__PURE__ */b(nc,{ref:e},"scroll-anchor")]},"message-list-container"),[{show:l,edge:{top:"8px"},label:"Scroll to top",icon:"arrowUp",onClick:()=>g.current?.scrollTo({top:0,behavior:"smooth"})},{show:f,edge:{bottom:"8px"},label:"Scroll to bottom",icon:"arrowDown",onClick:()=>!c&&e.current?.scrollIntoView({behavior:"smooth"})}].map(({show:e,edge:t,label:n,icon:o,onClick:i})=>e&&/* @__PURE__ */b(rc,{position:"absolute",justify:"center",style:{...t,left:0,right:0,zIndex:10,pointerEvents:"none"},children:/* @__PURE__ */b(cc,{variant:"secondary",size:"sm",label:n,onClick:i,style:Ku,children:/* @__PURE__ */b(ac,{name:o,size:10,style:{color:r.widget_accent_color}})})},n))]})},Gu=[{id:"tell",icon:"chatBubble",flag:"widget_feature_tell"},{id:"show",icon:"mousePointerClick",flag:"widget_feature_show"},{id:"do",icon:"ticktick",flag:"widget_feature_do"}];function Ju(e){const t=d(e);return t.current=e,t}var Zu=({onScreenSharingChange:e,toggleScreenShareRef:t,messageInputRef:n})=>{const r=Sl(),{state:o,actions:i}=kl(),{currentMode:s,isTaskRunning:l,isAwaitingReply:u}=o,[h,f]=p(""),m=d(null),{isScreenSharing:g,isAwaitingScreenAccess:y,showScreenAccessDialog:w,handleScreenAccessDialogAllow:x,handleScreenAccessDialogDismiss:S,handleScreenAccessRequestAllow:k,handleScreenAccessRequestDeny:C,requestScreenAccess:E}=function({onScreenSharingChange:e,toggleScreenShareRef:t,onAddMessage:n,onUpdateMessage:r,onRemoveMessage:o,onSendMessage:i,messages:s}){const[l,u]=p(!1),[d,h]=p(null),[f,m]=p(!1),g=Ju(l),y=Ju(d),b=Ju(e),v=t=>{u(t),e?.(t)},w=e=>{e&&o?.(e),n(qc("Screen sharing stopped","stopped-sharing")),h(null)},x=Ju(w);a(()=>{const e=()=>{const e=null!==mr(),t=g.current,n=y.current;e!==t&&(g.current=e,u(e),b.current?.(e)),t&&!e&&n&&x.current(n)};e();const t=setInterval(e,1e3);return()=>clearInterval(t)},[]);const S=s[Fc(s,e=>!!e.isScreenAccessRequest&&!e.screenShareStatus)]??null,k=()=>{S?.pendingContent&&i(S.pendingContent,S.mode,!0)},C=e=>{S&&r(S.id,{screenShareStatus:e})},E=async()=>{try{const e=await async function(){if(!1===Fe.getContext().config?.use_screenshare)throw new Error("Screen sharing is disabled for this widget");const e=mr();if(e)return e;const t=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!1,preferCurrentTab:!0});if(!t||0===t.getVideoTracks().length)throw new Error("Screen sharing permission denied or no video track available");return fr=t,t.getVideoTracks()[0]?.addEventListener("ended",()=>{fr=null}),t}();v(!0),C("allowed"),n(qc("Screen sharing started","started-screenshare"));const t=((e,t="show")=>Uc("screenshare","user","",{mode:t,videoStream:e}))(e,"show");h(t.id),n(t)}catch(e){console.error("Failed to start screen sharing:",e),v(!1),C("denied")}k()},I=E;return c(t,()=>()=>{l?(gr(),v(!1),w(d)):m(!0)}),{isScreenSharing:l,isAwaitingScreenAccess:null!==S,showScreenAccessDialog:f,handleScreenAccessDialogAllow:async()=>{m(!1),await E()},handleScreenAccessDialogDismiss:()=>{m(!1)},handleScreenAccessRequestAllow:I,handleScreenAccessRequestDeny:()=>{C("denied"),k()},requestScreenAccess:(e,t)=>{S||n(((e,t)=>Uc("screen-access-request","agent","Can I take a look at your screen?",{mode:e,isScreenAccessRequest:!0,pendingContent:t}))(e,t))}}}({onScreenSharingChange:e,toggleScreenShareRef:t,onAddMessage:i.addMessage,onUpdateMessage:i.updateMessage,onRemoveMessage:i.removeMessage,onSendMessage:i.messageDispatch,messages:o.messages}),I=y||u;/* @__PURE__ */
|
|
49
|
+
return v(oc,{height:"full",children:[w&&/* @__PURE__ */b(zu,{open:w,onClose:S,title:"Can I take a look at your screen?",description:"By allowing screen access, Marketrix can understand your current context to guide you better and complete tasks on your behalf.",onConfirm:x,confirmLabel:"Yes",cancelLabel:"No",finalFocusRef:n}),
|
|
50
|
+
/* @__PURE__ */b(oc,{grow:!0,overflow:"hidden",paddingY:"2xs",minHeight:"0",children:/* @__PURE__ */b(Ol,{label:"Chat",fallback:/* @__PURE__ */b(pc,{as:"div",size:"xs",align:"center",variant:"muted",style:{padding:"16px"},children:"Something went wrong displaying messages. Please refresh."}),children:/* @__PURE__ */b(Xu,{messagesEndRef:m,onScreenAccessAllow:k,onScreenAccessDeny:C})})}),
|
|
51
|
+
/* @__PURE__ */b(nc,{variant:"floatingCard",style:{marginTop:"auto"},children:/* @__PURE__ */b(mu,{ref:n,value:h,onChange:f,onSubmit:()=>{if(!h.trim()||I)return;const e=h.trim();f(""),i.addMessage(Hc(e,s)),!1===r.use_screenshare||"show"!==s&&"do"!==s||g?i.messageDispatch(e,s,!0):E(s,e)},modes:Gu.filter(({flag:e})=>r[e]).map(({id:e,icon:t})=>({id:e,icon:t,label:Lc(e)})),activeMode:s,onModeChange:e=>{e!==s&&(i.addMessage(qc(`Switched to ${Lc(e)} mode`,"mode-change")),i.setMode(e))},disabled:I,taskRunning:l,onStop:()=>{Tc.cleanup(),i.stopTask()}})})]})},Qu=[{id:"show-add-product",text:"Show me how to add a new product",type:"show"},{id:"show-login",text:"Show me how to login",type:"show"},{id:"do-login",text:"Do the login process for me",type:"do"},{id:"show-revenue",text:"Show me the revenue metrics",type:"show"},{id:"tell-conversion-rate",text:"What does my conversion rate mean and how can I improve it?",type:"tell"}],ed=({onNavigateToChat:e,onChipClick:t})=>{const n=Sl(),{messages:r}=kl().state,o=function(e){const t=e.widget_chips;return t?.length?t.map((e,t)=>({id:`chip-${e.chip_text.replace(/\s+/g,"-").toLowerCase()}-${t}`,text:"show"===e.chip_mode?`Show me ${e.chip_text.replace(/^Show me\s+/i,"")}`:"do"===e.chip_mode?`Do ${e.chip_text.replace(/^Do\s+/i,"")}`:e.chip_text,type:e.chip_mode})):Qu}(n);/* @__PURE__ */
|
|
52
52
|
return v(oc,{height:"full",overflow:"hidden",children:[/* @__PURE__ */v(oc,{grow:!0,overflowY:"auto",padding:"lg",children:[/* @__PURE__ */v(nc,{style:{textAlign:"center",paddingTop:"8px",paddingBottom:"16px"},children:[/* @__PURE__ */b(pc,{as:"h2",size:"lg",weight:"semibold",children:n.widget_greeting}),/* @__PURE__ */b(pc,{as:"p",variant:"muted",size:"sm",style:{marginTop:"2px"},children:n.widget_body})]}),/* @__PURE__ */v(oc,{gap:"sm",children:[/* @__PURE__ */v(Ja,{type:"button",variant:"primary",full:!0,onClick:e,"aria-label":"Ask a question",style:{paddingTop:"10px",paddingBottom:"10px"},children:[/* @__PURE__ */b(ac,{name:"chat",size:16}),"Ask a question"]}),o.map((r,o)=>/* @__PURE__ */b(Ja,{elevation:"card",size:"sm",variant:"chip",full:!0,onClick:n=>(async(n,r)=>{r.preventDefault(),r.stopPropagation(),e(),t(n)})(r,n),style:{color:n.widget_text_color,paddingTop:"8px",paddingBottom:"8px"},children:/* @__PURE__ */b(pc,{as:"span",weight:"normal",leading:"tight",children:r.text})},`welcome-chip-${r.id}-${o}`))]})]}),r.length>0&&/* @__PURE__ */v(nc,{variant:"floatingCard",children:[
|
|
53
53
|
/* @__PURE__ */b(pc,{as:"p",size:"xs",weight:"semibold",style:{marginBottom:"2px"},children:"Recent conversation"}),
|
|
54
54
|
/* @__PURE__ */b(pc,{as:"p",size:"xs",variant:"muted",style:{display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:r[r.length-1]?.content||"Message"}),
|
|
55
|
-
/* @__PURE__ */b(pc,{as:"p",size:"xs",variant:"muted",onClick:e,style:{marginTop:"4px",cursor:"pointer"},children:"Continue conversation →"})]})]})},
|
|
55
|
+
/* @__PURE__ */b(pc,{as:"p",size:"xs",variant:"muted",onClick:e,style:{marginTop:"4px",cursor:"pointer"},children:"Continue conversation →"})]})]})},td=[{id:"home",icon:"home",label:"Home"},{id:"chat",icon:"chat",label:"Chat"}],nd=()=>/* @__PURE__ */b(du,{render:/* @__PURE__ */b(rc,{align:"center",justify:"around",shrink:!1,border:"top"}),style:{height:48},children:td.map(e=>/* @__PURE__ */v(Gl,{value:e.id,render:/* @__PURE__ */b(Ja,{stacked:!0,variant:"tab"}),children:[
|
|
56
56
|
/* @__PURE__ */b("span",{className:"mtx-tab-underline"}),
|
|
57
57
|
/* @__PURE__ */b(pc,{as:"span",inheritColor:!0,"aria-hidden":"true",children:/* @__PURE__ */b(ac,{name:e.icon,size:20})}),
|
|
58
|
-
/* @__PURE__ */b(pc,{as:"span",size:"xs",align:"center",inheritColor:!0,truncate:!0,block:!0,children:e.label})]},e.id))}),sd=()=>{const e=Sl(),{state:t,actions:n}=kl(),{isOpen:r,activeView:o}=t,{isPreviewMode:s}=e,{widthPx:c,heightPx:l,grip:h,onResizeStart:f,containerRef:m}=function(e,t,n,r,o){const s=Oe("marketrix_widget_size",r),a=d(null),c=u(()=>(e=>{const t=Il(e),n=Tl[t.vertical],r=Tl[t.horizontal];return{vertical:n,horizontal:r,growX:"left"===r?-1:1,growY:"top"===n?-1:1,cursor:"top"===n==("left"===r)?"nwse-resize":"nesw-resize"}})(n),[n]),[l,h]=p(()=>function(e){try{const t=JSON.parse(_e(e)??"null");return function(e){return"object"==typeof e&&null!==e&&"number"==typeof e.width&&"number"==typeof e.height}(t)?
|
|
58
|
+
/* @__PURE__ */b(pc,{as:"span",size:"xs",align:"center",inheritColor:!0,truncate:!0,block:!0,children:e.label})]},e.id))});function rd(e){const t=e.getRootNode();return(t instanceof ShadowRoot?t.activeElement:document.activeElement)??null}function od({width:e,height:t}){return{width:Math.min(Math.max(e,280),600),height:Math.min(Math.max(t,320),Math.floor(.85*window.innerHeight))}}function id(e,t){const n=/^\s*(\d+(?:\.\d+)?)px\s*$/.exec(e??"");return n?Number(n[1]):t}var sd=()=>{const e=Sl(),{state:t,actions:n}=kl(),{isOpen:r,activeView:o}=t,{isPreviewMode:s}=e,{widthPx:c,heightPx:l,grip:h,onResizeStart:f,containerRef:m}=function(e,t,n,r,o){const s=Oe("marketrix_widget_size",r),a=d(null),c=u(()=>(e=>{const t=Il(e),n=Tl[t.vertical],r=Tl[t.horizontal];return{vertical:n,horizontal:r,growX:"left"===r?-1:1,growY:"top"===n?-1:1,cursor:"top"===n==("left"===r)?"nwse-resize":"nesw-resize"}})(n),[n]),[l,h]=p(()=>function(e){try{const t=JSON.parse(_e(e)??"null");return function(e){return"object"==typeof e&&null!==e&&"number"==typeof e.width&&"number"==typeof e.height}(t)?od(t):null}catch(t){return console.warn("[useResize] Ignoring an unparseable stored size:",t),null}}(s)??od({width:id(e,360),height:id(t,450)})),f=d(l);f.current=l;const m=i(e=>{if(e.preventDefault(),e.stopPropagation(),o)return;const t=e.clientX,n=e.clientY,r=f.current.width,i=f.current.height,{growX:l,growY:u,cursor:d}=c;a.current&&(a.current.dataset.resizing="true");const p=e=>{const o=od({width:r+(e.clientX-t)*l,height:i+(e.clientY-n)*u});f.current=o,a.current&&(a.current.style.width=`${o.width}px`,a.current.style.height=`${o.height}px`)},m=()=>{document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",m),document.body.style.cursor="",document.body.style.userSelect="",a.current&&delete a.current.dataset.resizing,h({...f.current}),De(s,JSON.stringify(f.current))};document.body.style.cursor=d,document.body.style.userSelect="none",document.addEventListener("mousemove",p),document.addEventListener("mouseup",m)},[o,s,c]);return{widthPx:`${l.width}px`,heightPx:`${l.height}px`,grip:c,onResizeStart:m,containerRef:a}}(e.widget_width,e.widget_height,e.widget_position,e,s),g=d(null),y="chat"===o?"forward":"back";!function(e,t,n){const r=d(!1),o=d(null);a(()=>{if(!t)return r.current&&(o.current?.focus({preventScroll:!0}),o.current=null),void(r.current=!1);const i=e.current;if(!i)return;r.current||(o.current=rd(i)),r.current=!0,(n?.focusTargetRef?.current??yc(i)[0])?.focus({preventScroll:!0});const s=e=>{const t=rd(i);if(!t||!i.contains(t))return;if("Escape"===e.key)return void n?.onEscape?.();if("Tab"!==e.key)return;const r=yc(i);if(0===r.length)return;const o=r.indexOf(t);-1!==o&&(e.shiftKey?0===o&&(e.preventDefault(),r[r.length-1]?.focus()):o===r.length-1&&(e.preventDefault(),r[0]?.focus()))};return document.addEventListener("keydown",s,!0),()=>document.removeEventListener("keydown",s,!0)},[t,e,n?.focusTargetRef,n?.onEscape])}(m,r,{onEscape:n.closeWidget,focusTargetRef:"chat"===o?g:void 0});const w=Ml(e.widget_position),[x,S]=p(!1),k=d(null);if(!r)return null;const C=vl(e.widget_background_color),{vertical:E,horizontal:I}=Il(e.widget_position),M="chat"===o&&!1!==e.use_screenshare?()=>k.current?.():void 0;/* @__PURE__ */
|
|
59
59
|
return v(oc,{ref:m,position:s?"absolute":"fixed",rounded:"lg",border:!0,overflow:"hidden",style:{zIndex:e.widget_position_z_index,backgroundImage:C,transformOrigin:`${E} ${I}`,width:c,height:l,fontSize:"14px",...w,pointerEvents:"auto",scrollbarWidth:"thin",animation:"messenger-entrance 300ms cubic-bezier(0, 1.2, 1, 1)",boxShadow:Na.panel},children:[
|
|
60
|
-
/* @__PURE__ */b(
|
|
61
|
-
/* @__PURE__ */v(Hl,{value:o,onValueChange:e=>n.setActiveView(e),render:/* @__PURE__ */b(oc,{grow:!0,minHeight:"0"}),children:[/* @__PURE__ */v(oc,{grow:!0,overflow:"hidden",minHeight:"0",children:[/* @__PURE__ */b(Ql,{value:"home","data-view-transition":!0,"data-direction":y,style:{width:"100%",height:"100%"},children:/* @__PURE__ */b(
|
|
60
|
+
/* @__PURE__ */b(hu,{title:e.widget_header,subtitle:e.widget_body,onClose:n.closeWidget,controls:M&&/* @__PURE__ */v(cc,{variant:"ghost",size:"sm",label:x?"Stop screen sharing":"Start screen sharing",onClick:M,children:[x&&/* @__PURE__ */b(pu,{style:{position:"absolute",top:"2px",right:"2px"}}),/* @__PURE__ */b(ac,{name:"screenShare",size:16})]})}),
|
|
61
|
+
/* @__PURE__ */v(Hl,{value:o,onValueChange:e=>n.setActiveView(e),render:/* @__PURE__ */b(oc,{grow:!0,minHeight:"0"}),children:[/* @__PURE__ */v(oc,{grow:!0,overflow:"hidden",minHeight:"0",children:[/* @__PURE__ */b(Ql,{value:"home","data-view-transition":!0,"data-direction":y,style:{width:"100%",height:"100%"},children:/* @__PURE__ */b(ed,{onNavigateToChat:()=>n.setActiveView("chat"),onChipClick:e=>{n.addMessage(Hc(e.text,e.type,"chip-message")),n.setMode(e.type),n.messageDispatch(e.text,e.type,!0)}})}),/* @__PURE__ */b(Ql,{value:"chat","data-view-transition":!0,"data-direction":y,style:{width:"100%",height:"100%"},children:/* @__PURE__ */b(Zu,{onScreenSharingChange:S,toggleScreenShareRef:k,messageInputRef:g})})]}),/* @__PURE__ */b(nd,{})]}),!s&&/* @__PURE__ */b("div",{role:"separator","aria-label":`Resize widget from ${h.vertical} ${h.horizontal}`,title:"Drag to resize",style:{position:"absolute",[h.vertical]:0,[h.horizontal]:0,width:"20px",height:"20px",padding:"4px",touchAction:"none",zIndex:10,display:"flex",alignItems:"top"===h.vertical?"flex-start":"flex-end",justifyContent:"left"===h.horizontal?"flex-start":"flex-end",cursor:h.cursor},onMouseDown:f})]})},ad=({config:e})=>{const[t,n]=p(!1),[r,o]=p(null),{state:i,actions:s}=kl(),c=e.isPreviewMode??!1;var l;l=i.isOpen,a(()=>{if(!l)return;if(!window.matchMedia("(max-width: 767px)").matches)return;const e=document.documentElement,t=document.body,n=e.style.overflow,r=t.style.overflow;return e.style.overflow="hidden",t.style.overflow="hidden",()=>{e.style.overflow=n,t.style.overflow=r}},[l]);const[u,d]=p(e.widget_position??"bottom_right"),h=Oe("marketrix_widget_position",e);a(()=>{const t=c?null:_e(h);(e=>El.includes(e))(t)?d(t):d(e.widget_position??"bottom_right")},[c,h,e.widget_position]),a(()=>{if(i.isOpen||c||!e.widget_greeting_toast)return void n(!1);const t=setTimeout(()=>n(!0),2e3);return()=>clearTimeout(t)},[i.isOpen,c,e.widget_greeting_toast]);const f=!1===e.show_widget||"hidden"===e.widget_appearance;if(!c&&f)return null;const m=Math.max(e.widget_position_z_index??0,2147483002),g={...e,widget_position:u,widget_position_z_index:m,isPreviewMode:c},y=i.isAwaitingReply||i.isTaskRunning,w=(x=function(e={}){const t=Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e)),n={...wl,...t};return{color:{background:n.widget_background_color,foreground:n.widget_text_color,foregroundMuted:bl(n.widget_text_color,.6),foregroundFaint:bl(n.widget_text_color,.4),border:n.widget_border_color,primary:n.widget_accent_color,primaryForeground:yl(n.widget_accent_color),primaryHover:bl(n.widget_accent_color,.85),secondary:n.widget_secondary_color,secondaryForeground:"#ffffff",secondaryBg:bl(n.widget_secondary_color,.2),secondaryHover:bl(n.widget_secondary_color,.3)},radius:"12px",motion:{durationAnimation:"300ms",durationFade:"200ms"}}}(e),{"--background":x.color.background,"--foreground":x.color.foreground,"--card":x.color.background,"--card-foreground":x.color.foreground,"--primary":x.color.primary,"--foreground-muted":x.color.foregroundMuted,"--foreground-faint":x.color.foregroundFaint,"--primary-foreground":x.color.primaryForeground,"--primary-hover":x.color.primaryHover,"--secondary":x.color.secondary,"--secondary-foreground":x.color.secondaryForeground,"--secondary-bg":x.color.secondaryBg,"--secondary-hover":x.color.secondaryHover,"--border":x.color.border,"--ring":x.color.primary,"--radius":x.radius,"--duration-animation":x.motion.durationAnimation,"--duration-fade":x.motion.durationFade});var x;/* @__PURE__ */
|
|
62
62
|
return b(xl,{value:g,children:/* @__PURE__ */b(nc,{ref:o,"data-marketrix-widget":!0,position:"relative",style:{...w,...c&&{width:"100%",height:"100%"}},children:/* @__PURE__ */b(ul,{value:r,children:/* @__PURE__ */v(fc,{container:r,offsetBottom:"top"===Il(u).vertical?20:90,children:[y&&/* @__PURE__ */b(nc,{"data-screen-edge-glow":!0,position:"fixed",inset:"0",style:{boxShadow:`inset 0 0 22px 2px ${bl(g.widget_accent_color,.72)}, inset 0 0 46px 10px ${bl(g.widget_accent_color,.28)}`,pointerEvents:"none",zIndex:2147483001}}),
|
|
63
63
|
/* @__PURE__ */b(Ol,{label:"Widget",children:/* @__PURE__ */b(sd,{})}),
|
|
64
64
|
/* @__PURE__ */b(_l,{onPositionCommit:e=>{d(e),c||De(h,e)}}),
|
package/package.json
CHANGED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `useDragSnap` — drag the launcher (FAB) and snap it to the nearest corner. Pointer events are tracked
|
|
3
|
-
* in a ref; movement under DRAG_THRESHOLD_PX stays a click, beyond it the wrapper is translated on a
|
|
4
|
-
* rAF loop with velocity sampled so a flick lands where it was heading. On release
|
|
5
|
-
* `getNearestCornerByTranslation` picks the corner, the wrapper animates there for SNAP_DURATION_MS via
|
|
6
|
-
* `left`/`top` transitions, and `commitPositionAfterAnimation` calls `onPositionCommit` on
|
|
7
|
-
* `transitionend` (with a timeout fallback, since a hidden tab fires no transition events) — the
|
|
8
|
-
* committed corner is the one being animated TO, so two snaps in flight cannot commit the abandoned
|
|
9
|
-
* one (`abandonSnapRef`). `suppressUntilRef` stamps a time after which a click may open the widget
|
|
10
|
-
* again, so the pointer-up that ends a drag is not read as a tap. The wrapper is measured with a
|
|
11
|
-
* ResizeObserver in a layout effect so the pixel position is right on the first paint; preview mode
|
|
12
|
-
* disables everything.
|
|
13
|
-
*/
|
|
14
|
-
import React from 'react';
|
|
15
|
-
import type { WidgetPosition } from '../types';
|
|
16
|
-
export interface UseDragSnapOptions {
|
|
17
|
-
position: WidgetPosition;
|
|
18
|
-
onPositionCommit: (position: WidgetPosition) => void;
|
|
19
|
-
isPreviewMode?: boolean;
|
|
20
|
-
wrapperRef: React.RefObject<HTMLDivElement | null>;
|
|
21
|
-
}
|
|
22
|
-
export interface UseDragSnapResult {
|
|
23
|
-
isDragging: boolean;
|
|
24
|
-
pixelPositionStyle: {
|
|
25
|
-
left: number;
|
|
26
|
-
top: number;
|
|
27
|
-
} | undefined;
|
|
28
|
-
onPointerDown: (event: React.PointerEvent<HTMLButtonElement>) => void;
|
|
29
|
-
onPointerMove: (event: React.PointerEvent<HTMLButtonElement>) => void;
|
|
30
|
-
onPointerUp: (event: React.PointerEvent<HTMLButtonElement>) => void;
|
|
31
|
-
onPointerCancel: (event: React.PointerEvent<HTMLButtonElement>) => void;
|
|
32
|
-
suppressUntilRef: React.RefObject<number>;
|
|
33
|
-
}
|
|
34
|
-
export declare function useDragSnap({ position, onPositionCommit, isPreviewMode, wrapperRef, }: UseDragSnapOptions): UseDragSnapResult;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Focus trap for the messenger panel: while `isActive`, focus starts inside `containerRef`, Tab cycles
|
|
3
|
-
* within it, Escape calls `onEscape`, and on deactivation focus returns to whatever held it before.
|
|
4
|
-
*
|
|
5
|
-
* The tabbable candidates come from `utils/dom`'s shared `focusablesIn` (built on `TABBABLE_SELECTOR`,
|
|
6
|
-
* visibility and `aria-hidden` ancestry — the same filter `keySimulation`'s Tab simulation uses, so the
|
|
7
|
-
* widget's own tab order and the host page's can't re-diverge); `activeElementIn` reads the focused
|
|
8
|
-
* element as seen from a container's own root; and `useFocusTrap(containerRef, isActive, {onEscape,
|
|
9
|
-
* focusTargetRef})` focuses `focusTargetRef` (else the first focusable), installs one capture-phase
|
|
10
|
-
* `keydown` listener on `document`, and restores focus on the active→inactive edge.
|
|
11
|
-
*
|
|
12
|
-
* Inside the widget's closed shadow root `document.activeElement` retargets to the HOST, never naming
|
|
13
|
-
* an element of the widget's own tree; `activeElementIn` reads through `container.getRootNode()`
|
|
14
|
-
* instead and is the ONE home for that retargeting — eslint's `no-restricted-properties` bans the bare
|
|
15
|
-
* read everywhere else. Hand-rolled on purpose: `MessengerShell` is a NON-modal panel, not a Dialog,
|
|
16
|
-
* and Base UI exposes no standalone focus trap; reaching it by making the panel a Dialog would inert
|
|
17
|
-
* the customer's page. Both key arms bail unless focus is currently inside the container, since the
|
|
18
|
-
* listener sits on `document` ahead of host-page handlers and an unguarded Escape would close the
|
|
19
|
-
* widget mid-typing. Tab `preventDefault`s only at the two ends; `previousActiveRef` edge-triggers the
|
|
20
|
-
* restore once on close.
|
|
21
|
-
*/
|
|
22
|
-
export declare function useFocusTrap(containerRef: React.RefObject<HTMLElement | null>, isActive: boolean, options?: {
|
|
23
|
-
onEscape?: () => void;
|
|
24
|
-
focusTargetRef?: React.RefObject<HTMLElement | null> | undefined;
|
|
25
|
-
}): void;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { MarketrixConfig, WidgetPosition } from '../types';
|
|
2
|
-
export declare function useResize(settingsWidth: string | undefined, settingsHeight: string | undefined, position: WidgetPosition, config: MarketrixConfig, isPreviewMode: boolean): {
|
|
3
|
-
widthPx: string;
|
|
4
|
-
heightPx: string;
|
|
5
|
-
grip: {
|
|
6
|
-
vertical: "top" | "bottom";
|
|
7
|
-
horizontal: "left" | "right";
|
|
8
|
-
growX: number;
|
|
9
|
-
growY: number;
|
|
10
|
-
cursor: string;
|
|
11
|
-
};
|
|
12
|
-
onResizeStart: (e: React.MouseEvent) => void;
|
|
13
|
-
containerRef: import("react").RefObject<HTMLDivElement | null>;
|
|
14
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { InstructionType } from '../sdk';
|
|
2
|
-
import type { ChatMessage } from '../types';
|
|
3
|
-
export interface UseScreenShareOptions {
|
|
4
|
-
onScreenSharingChange?: (isSharing: boolean) => void;
|
|
5
|
-
toggleScreenShareRef?: React.MutableRefObject<(() => void) | null>;
|
|
6
|
-
onAddMessage: (message: ChatMessage) => void;
|
|
7
|
-
onUpdateMessage: (messageId: string, updates: Partial<ChatMessage>) => void;
|
|
8
|
-
onRemoveMessage?: (messageId: string) => void;
|
|
9
|
-
onSendMessage: (message: string, mode?: InstructionType, skipUserMessage?: boolean) => void;
|
|
10
|
-
messages: ChatMessage[];
|
|
11
|
-
}
|
|
12
|
-
export interface UseScreenShareReturn {
|
|
13
|
-
isScreenSharing: boolean;
|
|
14
|
-
isAwaitingScreenAccess: boolean;
|
|
15
|
-
showScreenAccessDialog: boolean;
|
|
16
|
-
handleScreenAccessDialogAllow: () => Promise<void>;
|
|
17
|
-
handleScreenAccessDialogDismiss: () => void;
|
|
18
|
-
handleScreenAccessRequestAllow: () => Promise<void>;
|
|
19
|
-
handleScreenAccessRequestDeny: () => void;
|
|
20
|
-
requestScreenAccess: (mode: InstructionType, content: string) => void;
|
|
21
|
-
}
|
|
22
|
-
export declare function useScreenShare({ onScreenSharingChange, toggleScreenShareRef, onAddMessage, onUpdateMessage, onRemoveMessage, onSendMessage, messages, }: UseScreenShareOptions): UseScreenShareReturn;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function useScrollLock(enabled: boolean): void;
|