@zeke-02/docx-editor-agents 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +126 -0
- package/dist/agent-types-C8RvQB7n.d.mts +36 -0
- package/dist/agent-types-C8RvQB7n.d.ts +36 -0
- package/dist/ai-sdk/react.d.mts +57 -0
- package/dist/ai-sdk/react.d.ts +57 -0
- package/dist/ai-sdk/react.js +1 -0
- package/dist/ai-sdk/react.mjs +1 -0
- package/dist/ai-sdk/server.d.mts +80 -0
- package/dist/ai-sdk/server.d.ts +80 -0
- package/dist/ai-sdk/server.js +1 -0
- package/dist/ai-sdk/server.mjs +1 -0
- package/dist/ai-sdk/vue.d.ts +32 -0
- package/dist/ai-sdk/vue.js +1 -0
- package/dist/ai-sdk/vue.mjs +28 -0
- package/dist/bridge.d.mts +19 -0
- package/dist/bridge.d.ts +19 -0
- package/dist/bridge.js +1 -0
- package/dist/bridge.mjs +1 -0
- package/dist/chunk-24MVJKCP.mjs +8 -0
- package/dist/chunk-2RGRAPLW.js +5 -0
- package/dist/chunk-53PAUP4S.js +2 -0
- package/dist/chunk-AU3KR5IN.mjs +5 -0
- package/dist/chunk-KMEZXSKR.mjs +2 -0
- package/dist/chunk-RI5S75JY.js +8 -0
- package/dist/chunk-UNUH3LRU.mjs +1 -0
- package/dist/chunk-VXAJD6QK.js +1 -0
- package/dist/docx-editor-agents.css +2 -0
- package/dist/index.d.mts +178 -0
- package/dist/index.d.ts +178 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -0
- package/dist/mcp.d.mts +200 -0
- package/dist/mcp.d.ts +200 -0
- package/dist/mcp.js +4 -0
- package/dist/mcp.mjs +4 -0
- package/dist/react.d.mts +251 -0
- package/dist/react.d.ts +251 -0
- package/dist/react.js +9 -0
- package/dist/react.mjs +9 -0
- package/dist/server-uWvnaIh-.d.mts +620 -0
- package/dist/server-uWvnaIh-.d.ts +620 -0
- package/dist/server.d.mts +35 -0
- package/dist/server.d.ts +35 -0
- package/dist/server.js +1 -0
- package/dist/server.mjs +1 -0
- package/dist/vue/components/AIContextMenu.d.ts +33 -0
- package/dist/vue/components/AIResponsePreview.d.ts +40 -0
- package/dist/vue/components/AgentChatLog.d.ts +37 -0
- package/dist/vue/components/AgentComposer.d.ts +30 -0
- package/dist/vue/components/AgentPanel.d.ts +49 -0
- package/dist/vue/components/AgentSuggestionChip.d.ts +10 -0
- package/dist/vue/components/AgentTimeline.d.ts +19 -0
- package/dist/vue/composables/useAgentBridge.d.ts +19 -0
- package/dist/vue/types.d.ts +5 -0
- package/dist/vue.d.ts +72 -0
- package/dist/vue.js +20 -0
- package/dist/vue.mjs +2026 -0
- package/package.json +157 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export interface AIContextMenuLabels {
|
|
2
|
+
header?: string;
|
|
3
|
+
rewrite?: string;
|
|
4
|
+
expand?: string;
|
|
5
|
+
summarize?: string;
|
|
6
|
+
fixGrammar?: string;
|
|
7
|
+
makeFormal?: string;
|
|
8
|
+
makeCasual?: string;
|
|
9
|
+
translate?: string;
|
|
10
|
+
explain?: string;
|
|
11
|
+
customPlaceholder?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface AIContextMenuProps {
|
|
14
|
+
isOpen: boolean;
|
|
15
|
+
position: {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
};
|
|
19
|
+
selectedText: string;
|
|
20
|
+
showCustomPrompt?: boolean;
|
|
21
|
+
labels?: AIContextMenuLabels;
|
|
22
|
+
}
|
|
23
|
+
declare const _default: import('vue').DefineComponent<AIContextMenuProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
24
|
+
close: () => any;
|
|
25
|
+
action: (action: string, customPrompt?: string | undefined) => any;
|
|
26
|
+
}, string, import('vue').PublicProps, Readonly<AIContextMenuProps> & Readonly<{
|
|
27
|
+
onClose?: (() => any) | undefined;
|
|
28
|
+
onAction?: ((action: string, customPrompt?: string | undefined) => any) | undefined;
|
|
29
|
+
}>, {
|
|
30
|
+
showCustomPrompt: boolean;
|
|
31
|
+
labels: AIContextMenuLabels;
|
|
32
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
33
|
+
export default _default;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface AIResponsePreviewLabels {
|
|
2
|
+
loading?: string;
|
|
3
|
+
original?: string;
|
|
4
|
+
suggested?: string;
|
|
5
|
+
edit?: string;
|
|
6
|
+
discard?: string;
|
|
7
|
+
accept?: string;
|
|
8
|
+
retry?: string;
|
|
9
|
+
close?: string;
|
|
10
|
+
/** Per-action title overrides (e.g. `{ rewrite: 'Перефразировать' }`). */
|
|
11
|
+
actionTitles?: Partial<Record<string, string>>;
|
|
12
|
+
}
|
|
13
|
+
export interface AIResponsePreviewProps {
|
|
14
|
+
isVisible: boolean;
|
|
15
|
+
originalText: string;
|
|
16
|
+
responseText: string;
|
|
17
|
+
action: string;
|
|
18
|
+
isLoading: boolean;
|
|
19
|
+
error?: string;
|
|
20
|
+
allowEdit?: boolean;
|
|
21
|
+
showDiff?: boolean;
|
|
22
|
+
showRetry?: boolean;
|
|
23
|
+
labels?: AIResponsePreviewLabels;
|
|
24
|
+
}
|
|
25
|
+
declare const _default: import('vue').DefineComponent<AIResponsePreviewProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
26
|
+
accept: (text: string) => any;
|
|
27
|
+
reject: () => any;
|
|
28
|
+
retry: () => any;
|
|
29
|
+
}, string, import('vue').PublicProps, Readonly<AIResponsePreviewProps> & Readonly<{
|
|
30
|
+
onAccept?: ((text: string) => any) | undefined;
|
|
31
|
+
onReject?: (() => any) | undefined;
|
|
32
|
+
onRetry?: (() => any) | undefined;
|
|
33
|
+
}>, {
|
|
34
|
+
error: string;
|
|
35
|
+
labels: AIResponsePreviewLabels;
|
|
36
|
+
allowEdit: boolean;
|
|
37
|
+
showDiff: boolean;
|
|
38
|
+
showRetry: boolean;
|
|
39
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
40
|
+
export default _default;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { AgentMessage } from '../../agent-types';
|
|
2
|
+
export interface AgentChatLogProps {
|
|
3
|
+
messages: AgentMessage[];
|
|
4
|
+
loading?: boolean;
|
|
5
|
+
error?: string | null;
|
|
6
|
+
thinkingLabel?: string;
|
|
7
|
+
workingLabel?: (count: number) => string;
|
|
8
|
+
summaryLabel?: (count: number) => string;
|
|
9
|
+
earlierLabel?: (count: number) => string;
|
|
10
|
+
autoScroll?: boolean;
|
|
11
|
+
humanizeToolName?: (name: string) => string;
|
|
12
|
+
maxVisibleCalls?: number;
|
|
13
|
+
className?: string;
|
|
14
|
+
}
|
|
15
|
+
declare var __VLS_1: {};
|
|
16
|
+
type __VLS_Slots = {} & {
|
|
17
|
+
empty?: (props: typeof __VLS_1) => any;
|
|
18
|
+
};
|
|
19
|
+
declare const __VLS_component: import('vue').DefineComponent<AgentChatLogProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<AgentChatLogProps> & Readonly<{}>, {
|
|
20
|
+
className: string;
|
|
21
|
+
error: string | null;
|
|
22
|
+
maxVisibleCalls: number;
|
|
23
|
+
workingLabel: (count: number) => string;
|
|
24
|
+
summaryLabel: (count: number) => string;
|
|
25
|
+
earlierLabel: (count: number) => string;
|
|
26
|
+
loading: boolean;
|
|
27
|
+
thinkingLabel: string;
|
|
28
|
+
autoScroll: boolean;
|
|
29
|
+
humanizeToolName: (name: string) => string;
|
|
30
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
31
|
+
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
32
|
+
export default _default;
|
|
33
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
34
|
+
new (): {
|
|
35
|
+
$slots: S;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface AgentComposerProps {
|
|
2
|
+
modelValue: string;
|
|
3
|
+
disabled?: boolean;
|
|
4
|
+
placeholder?: string;
|
|
5
|
+
sendLabel?: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
declare var __VLS_1: {};
|
|
9
|
+
type __VLS_Slots = {} & {
|
|
10
|
+
footnote?: (props: typeof __VLS_1) => any;
|
|
11
|
+
};
|
|
12
|
+
declare const __VLS_component: import('vue').DefineComponent<AgentComposerProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
13
|
+
submit: () => any;
|
|
14
|
+
"update:modelValue": (next: string) => any;
|
|
15
|
+
}, string, import('vue').PublicProps, Readonly<AgentComposerProps> & Readonly<{
|
|
16
|
+
onSubmit?: (() => any) | undefined;
|
|
17
|
+
"onUpdate:modelValue"?: ((next: string) => any) | undefined;
|
|
18
|
+
}>, {
|
|
19
|
+
className: string;
|
|
20
|
+
disabled: boolean;
|
|
21
|
+
placeholder: string;
|
|
22
|
+
sendLabel: string;
|
|
23
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
24
|
+
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
25
|
+
export default _default;
|
|
26
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
27
|
+
new (): {
|
|
28
|
+
$slots: S;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export interface AgentPanelProps {
|
|
2
|
+
title?: string;
|
|
3
|
+
closeLabel?: string;
|
|
4
|
+
resizeHandleLabel?: string;
|
|
5
|
+
width?: number;
|
|
6
|
+
defaultWidth?: number;
|
|
7
|
+
minWidth?: number;
|
|
8
|
+
maxWidth?: number;
|
|
9
|
+
closed?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Show the header close button. Vue parity for React's
|
|
12
|
+
* `onClose=undefined → no button` pattern: pass `:closable="false"` to
|
|
13
|
+
* hide. Defaults to `true` because Vue's `defineEmits` always declares
|
|
14
|
+
* the `close` event regardless of whether the parent attached `@close`.
|
|
15
|
+
*/
|
|
16
|
+
closable?: boolean;
|
|
17
|
+
className?: string;
|
|
18
|
+
}
|
|
19
|
+
declare var __VLS_1: {}, __VLS_3: {};
|
|
20
|
+
type __VLS_Slots = {} & {
|
|
21
|
+
icon?: (props: typeof __VLS_1) => any;
|
|
22
|
+
} & {
|
|
23
|
+
default?: (props: typeof __VLS_3) => any;
|
|
24
|
+
};
|
|
25
|
+
declare const __VLS_component: import('vue').DefineComponent<AgentPanelProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
26
|
+
close: () => any;
|
|
27
|
+
"update:width": (w: number) => any;
|
|
28
|
+
}, string, import('vue').PublicProps, Readonly<AgentPanelProps> & Readonly<{
|
|
29
|
+
onClose?: (() => any) | undefined;
|
|
30
|
+
"onUpdate:width"?: ((w: number) => any) | undefined;
|
|
31
|
+
}>, {
|
|
32
|
+
title: string;
|
|
33
|
+
closeLabel: string;
|
|
34
|
+
resizeHandleLabel: string;
|
|
35
|
+
width: number;
|
|
36
|
+
defaultWidth: number;
|
|
37
|
+
minWidth: number;
|
|
38
|
+
maxWidth: number;
|
|
39
|
+
closed: boolean;
|
|
40
|
+
closable: boolean;
|
|
41
|
+
className: string;
|
|
42
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
43
|
+
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
44
|
+
export default _default;
|
|
45
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
46
|
+
new (): {
|
|
47
|
+
$slots: S;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface AgentSuggestionChipProps {
|
|
2
|
+
label: string;
|
|
3
|
+
disabled?: boolean;
|
|
4
|
+
}
|
|
5
|
+
declare const _default: import('vue').DefineComponent<AgentSuggestionChipProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
6
|
+
click: () => any;
|
|
7
|
+
}, string, import('vue').PublicProps, Readonly<AgentSuggestionChipProps> & Readonly<{
|
|
8
|
+
onClick?: (() => any) | undefined;
|
|
9
|
+
}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AgentToolCall } from '../../agent-types';
|
|
2
|
+
export interface AgentTimelineProps {
|
|
3
|
+
toolCalls: AgentToolCall[];
|
|
4
|
+
streaming?: boolean;
|
|
5
|
+
maxVisibleCalls?: number;
|
|
6
|
+
humanizeName?: (name: string) => string;
|
|
7
|
+
workingLabel?: (count: number) => string;
|
|
8
|
+
summaryLabel?: (count: number) => string;
|
|
9
|
+
earlierLabel?: (count: number) => string;
|
|
10
|
+
}
|
|
11
|
+
declare const _default: import('vue').DefineComponent<AgentTimelineProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<AgentTimelineProps> & Readonly<{}>, {
|
|
12
|
+
streaming: boolean;
|
|
13
|
+
maxVisibleCalls: number;
|
|
14
|
+
humanizeName: (name: string) => string;
|
|
15
|
+
workingLabel: (count: number) => string;
|
|
16
|
+
summaryLabel: (count: number) => string;
|
|
17
|
+
earlierLabel: (count: number) => string;
|
|
18
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
19
|
+
export default _default;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { MaybeRef, Ref } from 'vue';
|
|
2
|
+
import { EditorRefLike } from '../../bridge';
|
|
3
|
+
import { getToolSchemas, AgentToolResult } from '../../tools';
|
|
4
|
+
export interface UseAgentBridgeOptions {
|
|
5
|
+
/** Vue ref pointing at the DocxEditor instance (must match `EditorRefLike`). */
|
|
6
|
+
editorRef: Ref<EditorRefLike | null | undefined>;
|
|
7
|
+
/**
|
|
8
|
+
* Default author for comments and tracked changes. Accepts a plain
|
|
9
|
+
* string or a `Ref<string>`/computed — bridge rebuilds when the value
|
|
10
|
+
* changes (matches React's `useMemo([editorRef, author])` shape).
|
|
11
|
+
* Defaults to `'AI'`.
|
|
12
|
+
*/
|
|
13
|
+
author?: MaybeRef<string>;
|
|
14
|
+
}
|
|
15
|
+
export interface UseAgentBridgeReturn {
|
|
16
|
+
executeToolCall: (toolName: string, input: Record<string, unknown>) => AgentToolResult;
|
|
17
|
+
toolSchemas: ReturnType<typeof getToolSchemas>;
|
|
18
|
+
}
|
|
19
|
+
export declare function useAgentBridge(options: UseAgentBridgeOptions): UseAgentBridgeReturn;
|
package/dist/vue.d.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @zeke-02/docx-editor-agents/vue
|
|
3
|
+
*
|
|
4
|
+
* Vue entry. Components and composables that need Vue as a peer dependency.
|
|
5
|
+
*
|
|
6
|
+
* Parity with the React adapter: same prop and event names where possible.
|
|
7
|
+
* Where React passes `ReactNode` props (`icon`, `emptyState`, `footnote`),
|
|
8
|
+
* the Vue components use idiomatic named slots. See each component's JSDoc
|
|
9
|
+
* for the slot list. `AgentComposer` follows the standard Vue 3 v-model
|
|
10
|
+
* contract (`modelValue` / `update:modelValue`).
|
|
11
|
+
*
|
|
12
|
+
* Editor i18n: `<DocxEditor :i18n="..." />` does NOT translate agent UI
|
|
13
|
+
* strings. These components own their own English defaults from
|
|
14
|
+
* `packages/agents/i18n/en.json`. Wire your `t()` results to the
|
|
15
|
+
* `*Label` / `labels` props for translation:
|
|
16
|
+
*
|
|
17
|
+
* ```vue
|
|
18
|
+
* <AgentPanel :title="t('agentPanel.defaultTitle')" :close-label="t('agentPanel.close')" />
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```vue
|
|
23
|
+
* <script setup lang="ts">
|
|
24
|
+
* import { ref } from 'vue';
|
|
25
|
+
* import {
|
|
26
|
+
* AgentPanel,
|
|
27
|
+
* AgentChatLog,
|
|
28
|
+
* AgentComposer,
|
|
29
|
+
* useAgentBridge,
|
|
30
|
+
* } from '@zeke-02/docx-editor-agents/vue';
|
|
31
|
+
*
|
|
32
|
+
* const input = ref('');
|
|
33
|
+
* const messages = ref([]);
|
|
34
|
+
* const loading = ref(false);
|
|
35
|
+
* const closed = ref(false);
|
|
36
|
+
*
|
|
37
|
+
* function send() {
|
|
38
|
+
* // ... post `input.value` to your transport, push reply onto messages
|
|
39
|
+
* }
|
|
40
|
+
* </script>
|
|
41
|
+
*
|
|
42
|
+
* <template>
|
|
43
|
+
* <AgentPanel :closed="closed" @close="closed = true">
|
|
44
|
+
* <AgentChatLog :messages="messages" :loading="loading" />
|
|
45
|
+
* <AgentComposer v-model="input" @submit="send" />
|
|
46
|
+
* </AgentPanel>
|
|
47
|
+
* </template>
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @packageDocumentation
|
|
51
|
+
* @public
|
|
52
|
+
*/
|
|
53
|
+
export { default as AgentPanel } from './vue/components/AgentPanel';
|
|
54
|
+
export type { AgentPanelProps } from './vue/components/AgentPanel';
|
|
55
|
+
export { default as AgentChatLog } from './vue/components/AgentChatLog';
|
|
56
|
+
export type { AgentChatLogProps } from './vue/components/AgentChatLog';
|
|
57
|
+
export { default as AgentComposer } from './vue/components/AgentComposer';
|
|
58
|
+
export type { AgentComposerProps } from './vue/components/AgentComposer';
|
|
59
|
+
export { default as AgentSuggestionChip } from './vue/components/AgentSuggestionChip';
|
|
60
|
+
export type { AgentSuggestionChipProps } from './vue/components/AgentSuggestionChip';
|
|
61
|
+
export { default as AgentTimeline } from './vue/components/AgentTimeline';
|
|
62
|
+
export type { AgentTimelineProps } from './vue/components/AgentTimeline';
|
|
63
|
+
export { default as AIContextMenu } from './vue/components/AIContextMenu';
|
|
64
|
+
export type { AIContextMenuProps } from './vue/components/AIContextMenu';
|
|
65
|
+
export { default as AIResponsePreview } from './vue/components/AIResponsePreview';
|
|
66
|
+
export type { AIResponsePreviewProps } from './vue/components/AIResponsePreview';
|
|
67
|
+
export type { AgentMessage, AgentToolCall } from './vue/types';
|
|
68
|
+
export { useAgentBridge } from './vue/composables/useAgentBridge';
|
|
69
|
+
export type { UseAgentBridgeOptions, UseAgentBridgeReturn } from './vue/composables/useAgentBridge';
|
|
70
|
+
export type { EditorRefLike } from './bridge';
|
|
71
|
+
export type { AgentToolDefinition, AgentToolResult } from './tools';
|
|
72
|
+
export { getToolDisplayName } from './tools';
|
package/dist/vue.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`vue`);var t={_lang:`en`,agentPanel:{defaultTitle:`Assistant`,close:`Close panel`,resizeHandle:`Resize agent panel`,thinking:`Assistant is thinking`,composerPlaceholder:`Ask the assistant…`,send:`Send`,timeline:{working:`Working… {count, plural, one {# step} other {# steps}}`,summary:`{count, plural, one {# step} other {# steps}}`,earlier:`+ {count, plural, one {# earlier step} other {# earlier steps}}`}},aiActions:{header:`AI Actions`,askAi:`Ask AI`,rewrite:`Rewrite`,expand:`Expand`,summarize:`Summarize`,translate:`Translate`,explain:`Explain`,fixGrammar:`Fix grammar`,makeFormal:`Make formal`,makeCasual:`Make casual`,custom:`Custom`,customPlaceholder:`Custom prompt…`},aiPreview:{defaultTitle:`AI Response`,labels:{rewrite:`Rewrite`,expand:`Expand`,summarize:`Summary`,translate:`Translation`,explain:`Explanation`,fixGrammar:`Grammar Fix`,makeFormal:`Formal Version`,makeCasual:`Casual Version`,custom:`AI Response`,askAi:`AI Response`},loading:`Processing…`,original:`Original:`,suggested:`Suggested:`,edit:`Edit`,discard:`Discard`,accept:`Accept`,retry:`Retry`,close:`Close`}},n=[`aria-hidden`,`aria-label`,`data-state`],r=[`aria-label`,`aria-valuenow`,`aria-valuemin`,`aria-valuemax`,`aria-valuetext`],i=[`aria-label`,`title`],a=`eigenpal:docx-editor:agentPanelWidth`,o=(0,e.defineComponent)({__name:`AgentPanel`,props:{title:{default:()=>t.agentPanel.defaultTitle},closeLabel:{default:()=>t.agentPanel.close},resizeHandleLabel:{default:()=>t.agentPanel.resizeHandle},width:{default:void 0},defaultWidth:{default:360},minWidth:{default:280},maxWidth:{default:600},closed:{type:Boolean,default:!1},closable:{type:Boolean,default:!0},className:{default:``}},emits:[`close`,`update:width`],setup(t,{emit:o}){let s=t,c=o,l=(0,e.computed)(()=>s.width!==void 0);function u(){if(typeof window>`u`)return s.defaultWidth;try{let e=window.localStorage.getItem(a);if(e){let t=Number(e);if(Number.isFinite(t)&&t>=s.minWidth&&t<=s.maxWidth)return t}}catch{}return s.defaultWidth}let d=(0,e.ref)(l.value?s.width:u()),f=(0,e.computed)(()=>l.value?s.width:d.value),p=(0,e.ref)(!1),m=null;(0,e.watch)(()=>s.closed,()=>{m!==null&&window.clearTimeout(m),p.value=!0,m=window.setTimeout(()=>{p.value=!1,m=null},260)},{flush:`post`});let h=null;function g(e){if(!h)return;let t=h.startX-e.clientX,n=Math.min(s.maxWidth,Math.max(s.minWidth,h.startWidth+t));h.lastWidth=n,l.value||(d.value=n),c(`update:width`,n)}function _(){if(!h)return;let e=h.lastWidth;if(h=null,document.removeEventListener(`pointermove`,g),document.removeEventListener(`pointerup`,_),!l.value)try{window.localStorage.setItem(a,String(e))}catch{}}function v(e){e.preventDefault(),h={startX:e.clientX,startWidth:f.value,lastWidth:f.value},document.addEventListener(`pointermove`,g),document.addEventListener(`pointerup`,_)}function y(e){s.closable&&(e.stopPropagation(),c(`close`))}function b(e){let t=0,n=null,r=e.shiftKey?64:16;switch(e.key){case`ArrowLeft`:t=r;break;case`ArrowRight`:t=-r;break;case`Home`:n=s.maxWidth;break;case`End`:n=s.minWidth;break;default:return}e.preventDefault();let i=n===null?Math.min(s.maxWidth,Math.max(s.minWidth,f.value+t)):n;if(l.value||(d.value=i),c(`update:width`,i),!l.value)try{window.localStorage.setItem(a,String(i))}catch{}}(0,e.onBeforeUnmount)(()=>{document.removeEventListener(`pointermove`,g),document.removeEventListener(`pointerup`,_),m!==null&&window.clearTimeout(m)});let x=(0,e.computed)(()=>({width:s.closed?`0px`:`${f.value}px`,flex:s.closed?`0 0 0px`:`0 0 ${f.value}px`,height:`calc(100% - 16px)`,margin:s.closed?`8px 0 8px 0`:`8px 8px 8px 12px`,display:`flex`,flexDirection:`column`,background:`#ffffff`,border:s.closed?`1px solid transparent`:`1px solid #e3e3e3`,borderRadius:`16px`,boxShadow:s.closed?`none`:`0 1px 2px rgba(60,64,67,0.05), 0 4px 12px rgba(60,64,67,0.08)`,opacity:+!s.closed,pointerEvents:s.closed?`none`:`auto`,position:`relative`,boxSizing:`border-box`,minWidth:s.closed?0:`${s.minWidth}px`,overflow:`hidden`,fontFamily:`'Google Sans', 'Google Sans Text', system-ui, -apple-system, sans-serif`,transition:p.value?`flex-basis 220ms cubic-bezier(0.4, 0, 0.2, 1), width 220ms cubic-bezier(0.4, 0, 0.2, 1), margin 220ms cubic-bezier(0.4, 0, 0.2, 1), opacity 180ms ease, box-shadow 220ms ease, border-color 220ms ease`:`opacity 180ms ease, box-shadow 220ms ease, border-color 220ms ease`})),S={position:`absolute`,left:`-3px`,top:0,bottom:0,width:`6px`,cursor:`col-resize`,touchAction:`none`,zIndex:1},C={display:`flex`,alignItems:`center`,gap:`10px`,padding:`14px 16px 10px`,flex:`0 0 auto`,background:`#ffffff`},w={display:`inline-flex`,alignItems:`center`,color:`#0b57d0`},T={flex:1,fontSize:`15px`,fontWeight:500,color:`#1f1f1f`,letterSpacing:`0.1px`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},E={border:`none`,background:`transparent`,padding:`6px`,cursor:`pointer`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,color:`#444746`,borderRadius:`999px`,transition:`background 0.15s`},D={flex:1,minHeight:0,overflow:`hidden`,display:`flex`,flexDirection:`column`};function O(e,t){let n=t.currentTarget;n&&(n.style.background=e?`#f1f3f4`:`transparent`)}return(a,o)=>((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{class:(0,e.normalizeClass)([`ep-agent-panel`,t.className]),style:(0,e.normalizeStyle)(x.value),"aria-hidden":t.closed,"aria-label":t.title,role:`complementary`,"data-testid":`agent-panel`,"data-state":t.closed?`closed`:`open`,onKeydown:(0,e.withKeys)(y,[`esc`])},[(0,e.createElementVNode)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":t.resizeHandleLabel,"aria-valuenow":f.value,"aria-valuemin":t.minWidth,"aria-valuemax":t.maxWidth,"aria-valuetext":`${f.value} pixels wide`,tabindex:`0`,style:S,"data-testid":`agent-panel-resize-handle`,onPointerdown:v,onKeydown:b},null,40,r),(0,e.createElementVNode)(`div`,{style:C},[(0,e.createElementVNode)(`span`,{style:w},[(0,e.renderSlot)(a.$slots,`icon`,{},()=>[o[3]||=(0,e.createElementVNode)(`svg`,{viewBox:`0 -960 960 960`,width:`22`,height:`22`,fill:`currentColor`,"aria-hidden":`true`},[(0,e.createElementVNode)(`path`,{d:`m760-600-50-110-110-50 110-50 50-110 50 110 110 50-110 50-50 110Zm0 560-50-110-110-50 110-50 50-110 50 110 110 50-110 50-50 110ZM360-160 260-380 40-480l220-100 100-220 100 220 220 100-220 100-100 220Zm0-194 40-86 86-40-86-40-40-86-40 86-86 40 86 40 40 86Zm0-126Z`})],-1)])]),(0,e.createElementVNode)(`span`,{style:T},(0,e.toDisplayString)(t.title),1),t.closable?((0,e.openBlock)(),(0,e.createElementBlock)(`button`,{key:0,type:`button`,"aria-label":t.closeLabel,title:t.closeLabel,"data-testid":`agent-panel-close`,style:E,onClick:o[0]||=e=>c(`close`),onMouseenter:o[1]||=e=>O(!0,e),onMouseleave:o[2]||=e=>O(!1,e)},[...o[4]||=[(0,e.createElementVNode)(`svg`,{viewBox:`0 -960 960 960`,width:`18`,height:`18`,fill:`currentColor`,"aria-hidden":`true`},[(0,e.createElementVNode)(`path`,{d:`m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z`})],-1)]],40,i)):(0,e.createCommentVNode)(``,!0)]),(0,e.createElementVNode)(`div`,{style:D},[(0,e.renderSlot)(a.$slots,`default`)])],46,n))}});function s(e){let t={},n=/(=\d+|\w+)\s*\{([^}]*)\}/g,r;for(;(r=n.exec(e))!==null;)t[r[1]]=r[2];return t}function c(e,t,n=`en`){return t?e.replace(/\{(\w+),\s*plural,\s*((?:[^{}]|\{[^{}]*\})*)\}/g,(e,r,i)=>{let a=Number(t[r]);if(isNaN(a))return e;let o=s(i),c=o[`=${a}`];if(c!==void 0)return c.replace(/#/g,String(a));let l;try{l=new Intl.PluralRules(n).select(a)}catch{l=a===1?`one`:`other`}return(o[l]??o.other??``).replace(/#/g,String(a))}).replace(/\{(\w+)\}/g,(e,n)=>{let r=t[n];return r===void 0?`{${n}}`:String(r)}):e}function l(e){let t=e.replace(/_/g,` `);return t.charAt(0).toUpperCase()+t.slice(1)}var u=[`aria-expanded`],d={key:1,style:{marginRight:`6px`,display:`inline-flex`},"aria-hidden":`true`},f=(0,e.defineComponent)({__name:`AgentTimeline`,props:{toolCalls:{},streaming:{type:Boolean,default:!1},maxVisibleCalls:{default:3},humanizeName:{type:Function,default:void 0},workingLabel:{type:Function,default:void 0},summaryLabel:{type:Function,default:void 0},earlierLabel:{type:Function,default:void 0}},setup(n){let r=n,i=(0,e.ref)(null),a=(0,e.computed)(()=>i.value===null?!!r.streaming:i.value),o=e=>(r.humanizeName??l)(e),s=e=>(r.earlierLabel??(e=>c(t.agentPanel.timeline.earlier,{count:e})))(e),f=(0,e.computed)(()=>{let e=r.toolCalls.length;return r.streaming?(r.workingLabel??(e=>c(t.agentPanel.timeline.working,{count:e})))(e):(r.summaryLabel??(e=>c(t.agentPanel.timeline.summary,{count:e})))(e)}),p=(0,e.computed)(()=>r.toolCalls.slice(-r.maxVisibleCalls)),m=(0,e.computed)(()=>Math.max(0,r.toolCalls.length-p.value.length)),h=(0,e.computed)(()=>({fontSize:`12px`,color:`#5f6368`,transition:`transform 0.15s ease`,marginLeft:`8px`,display:`inline-block`,transform:a.value?`rotate(180deg)`:`rotate(0deg)`}));function g(e=!1){return{marginRight:e?0:`6px`,display:`inline-flex`,animation:`epAgentSpin 0.8s linear infinite`,flexShrink:0}}let _={timelineWrap:{alignSelf:`flex-start`,maxWidth:`92%`,background:`#fff`,border:`1px solid #e1e3e6`,borderRadius:`12px`,overflow:`hidden`,fontFamily:`'Google Sans Text', system-ui, sans-serif`},timelineHeader:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,width:`100%`,padding:`8px 12px`,background:`transparent`,border:`none`,cursor:`pointer`,fontSize:`12.5px`,color:`#1f1f1f`,fontFamily:`inherit`},timelineSummary:{display:`inline-flex`,alignItems:`center`,fontWeight:500},timelineList:{listStyle:`none`,margin:0,padding:`4px 12px 10px 12px`,display:`flex`,flexDirection:`column`,gap:`6px`,borderTop:`1px solid #ececf0`},timelineItem:{display:`flex`,alignItems:`center`,gap:`8px`,fontSize:`12px`,color:`#444746`},timelineDot:{width:`6px`,height:`6px`,borderRadius:`50%`,flexShrink:0},timelineCall:{display:`inline-flex`,flexDirection:`column`,minWidth:0},timelineCallName:{color:`#1f1f1f`},timelineError:{color:`#d93025`,fontSize:`11px`},timelineMore:{fontSize:`11px`,color:`#5f6368`,fontStyle:`italic`,paddingLeft:`14px`}};return(t,r)=>n.toolCalls.length>0?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:0,style:(0,e.normalizeStyle)(_.timelineWrap),"data-testid":`agent-timeline`},[(0,e.createElementVNode)(`button`,{type:`button`,"aria-expanded":a.value,style:(0,e.normalizeStyle)(_.timelineHeader),"data-testid":`agent-timeline-toggle`,onClick:r[0]||=e=>i.value=!a.value},[(0,e.createElementVNode)(`span`,{style:(0,e.normalizeStyle)(_.timelineSummary)},[n.streaming?((0,e.openBlock)(),(0,e.createElementBlock)(`span`,{key:0,style:(0,e.normalizeStyle)(g()),"aria-hidden":`true`},[...r[1]||=[(0,e.createElementVNode)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`},[(0,e.createElementVNode)(`circle`,{cx:`12`,cy:`12`,r:`9`,stroke:`#dadce0`,"stroke-width":`3`,fill:`none`}),(0,e.createElementVNode)(`path`,{d:`M21 12a9 9 0 0 0-9-9`,stroke:`#0b57d0`,"stroke-width":`3`,"stroke-linecap":`round`})],-1)]],4)):((0,e.openBlock)(),(0,e.createElementBlock)(`span`,d,[...r[2]||=[(0,e.createElementVNode)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`},[(0,e.createElementVNode)(`path`,{d:`M5 13l4 4L19 7`,stroke:`#1e8e3e`,"stroke-width":`2.5`,"stroke-linecap":`round`,"stroke-linejoin":`round`})],-1)]])),(0,e.createTextVNode)(` `+(0,e.toDisplayString)(f.value),1)],4),(0,e.createElementVNode)(`span`,{style:(0,e.normalizeStyle)(h.value),"aria-hidden":`true`},`▾`,4)],12,u),a.value?((0,e.openBlock)(),(0,e.createElementBlock)(`ol`,{key:0,style:(0,e.normalizeStyle)(_.timelineList)},[m.value>0?((0,e.openBlock)(),(0,e.createElementBlock)(`li`,{key:0,style:(0,e.normalizeStyle)(_.timelineMore),"data-testid":`agent-timeline-earlier`},(0,e.toDisplayString)(s(m.value)),5)):(0,e.createCommentVNode)(``,!0),((0,e.openBlock)(!0),(0,e.createElementBlock)(e.Fragment,null,(0,e.renderList)(p.value,t=>((0,e.openBlock)(),(0,e.createElementBlock)(`li`,{key:t.id,style:(0,e.normalizeStyle)(_.timelineItem)},[t.status===`running`?((0,e.openBlock)(),(0,e.createElementBlock)(`span`,{key:0,style:(0,e.normalizeStyle)(g(!0)),"aria-hidden":`true`},[...r[3]||=[(0,e.createElementVNode)(`svg`,{width:`10`,height:`10`,viewBox:`0 0 24 24`,fill:`none`},[(0,e.createElementVNode)(`circle`,{cx:`12`,cy:`12`,r:`9`,stroke:`#dadce0`,"stroke-width":`3`,fill:`none`}),(0,e.createElementVNode)(`path`,{d:`M21 12a9 9 0 0 0-9-9`,stroke:`#0b57d0`,"stroke-width":`3`,"stroke-linecap":`round`})],-1)]],4)):((0,e.openBlock)(),(0,e.createElementBlock)(`span`,{key:1,style:(0,e.normalizeStyle)({..._.timelineDot,background:t.status===`error`?`#d93025`:`#1e8e3e`}),"aria-hidden":`true`},null,4)),(0,e.createElementVNode)(`span`,{style:(0,e.normalizeStyle)(_.timelineCall)},[(0,e.createElementVNode)(`span`,{style:(0,e.normalizeStyle)(_.timelineCallName)},(0,e.toDisplayString)(o(t.name)),5),t.error?((0,e.openBlock)(),(0,e.createElementBlock)(`span`,{key:0,style:(0,e.normalizeStyle)(_.timelineError)},(0,e.toDisplayString)(t.error),5)):(0,e.createCommentVNode)(``,!0)],4)],4))),128))],4)):(0,e.createCommentVNode)(``,!0)],4)):(0,e.createCommentVNode)(``,!0)}}),p=[`data-role`],m=[`aria-label`],h=`ep-agent-chat-keyframes`,g=(0,e.defineComponent)({__name:`AgentChatLog`,props:{messages:{},loading:{type:Boolean,default:!1},error:{default:null},thinkingLabel:{default:()=>t.agentPanel.thinking},workingLabel:{type:Function,default:void 0},summaryLabel:{type:Function,default:void 0},earlierLabel:{type:Function,default:void 0},autoScroll:{type:Boolean,default:!0},humanizeToolName:{type:Function,default:void 0},maxVisibleCalls:{default:3},className:{default:``}},setup(t){let n=t,r=(0,e.ref)(null),i=(0,e.computed)(()=>n.messages.length===0&&!n.loading&&!n.error);function a(){if(!n.autoScroll)return;let e=n.messages[n.messages.length-1]?.status===`streaming`;r.value?.scrollIntoView({behavior:e||n.loading?`auto`:`smooth`,block:`end`})}(0,e.onMounted)(()=>{(0,e.nextTick)(a),o()}),(0,e.watch)([()=>n.messages.length,()=>n.messages[n.messages.length-1]?.toolCalls?.length??0,()=>n.loading,()=>n.messages[n.messages.length-1]?.status===`streaming`],a,{flush:`post`});function o(){if(typeof document>`u`||document.getElementById(h))return;let e=document.createElement(`style`);e.id=h,e.textContent=`
|
|
2
|
+
@keyframes epAgentDot {
|
|
3
|
+
0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
|
|
4
|
+
40% { transform: scale(1); opacity: 1; }
|
|
5
|
+
}
|
|
6
|
+
@keyframes epAgentSpin {
|
|
7
|
+
to { transform: rotate(360deg); }
|
|
8
|
+
}
|
|
9
|
+
`,document.head.appendChild(e)}let s={flex:1,overflow:`auto`,padding:`16px 14px 8px`,display:`flex`,flexDirection:`column`,gap:`10px`},c={messageGroup:{display:`flex`,flexDirection:`column`,gap:`6px`,width:`100%`},userBubble:{background:`#0b57d0`,color:`#fff`,padding:`10px 14px`,borderRadius:`20px 20px 4px 20px`,fontSize:`13.5px`,lineHeight:1.5,alignSelf:`flex-end`,maxWidth:`88%`,whiteSpace:`pre-wrap`,wordBreak:`break-word`,fontFamily:`'Google Sans', 'Google Sans Text', system-ui, -apple-system, sans-serif`},assistantBubble:{background:`#f0f4f9`,color:`#1f1f1f`,padding:`12px 16px`,borderRadius:`20px 20px 20px 4px`,fontSize:`13.5px`,lineHeight:1.55,alignSelf:`flex-start`,maxWidth:`92%`,whiteSpace:`pre-wrap`,wordBreak:`break-word`,fontFamily:`'Google Sans', 'Google Sans Text', system-ui, -apple-system, sans-serif`},thinkingBubble:{background:`#f0f4f9`,padding:`12px 16px`,borderRadius:`20px 20px 20px 4px`,alignSelf:`flex-start`,display:`flex`,gap:`4px`,alignItems:`center`},dot:{width:`6px`,height:`6px`,borderRadius:`50%`,background:`#5f6368`,display:`inline-block`,animation:`epAgentDot 1.4s infinite ease-in-out`},errorBubble:{background:`#fce8e6`,color:`#b3261e`,padding:`10px 14px`,borderRadius:`16px`,fontSize:`12.5px`,alignSelf:`flex-start`,maxWidth:`92%`,whiteSpace:`pre-wrap`,fontFamily:`'Google Sans Text', system-ui, sans-serif`}};return(n,a)=>((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{class:(0,e.normalizeClass)([`ep-agent-chat-log`,t.className]),style:s,role:`log`,"aria-live":`polite`,"aria-atomic":`false`},[i.value?(0,e.renderSlot)(n.$slots,`empty`,{key:0}):(0,e.createCommentVNode)(``,!0),((0,e.openBlock)(!0),(0,e.createElementBlock)(e.Fragment,null,(0,e.renderList)(t.messages,n=>((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:n.id,style:(0,e.normalizeStyle)(c.messageGroup),"data-role":n.role},[n.role===`assistant`&&n.toolCalls&&n.toolCalls.length>0?((0,e.openBlock)(),(0,e.createBlock)(f,{key:0,"tool-calls":n.toolCalls,streaming:n.status===`streaming`,"humanize-name":t.humanizeToolName,"max-visible-calls":t.maxVisibleCalls,"working-label":t.workingLabel,"summary-label":t.summaryLabel,"earlier-label":t.earlierLabel},null,8,[`tool-calls`,`streaming`,`humanize-name`,`max-visible-calls`,`working-label`,`summary-label`,`earlier-label`])):(0,e.createCommentVNode)(``,!0),n.text.length>0?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:1,style:(0,e.normalizeStyle)(n.role===`user`?c.userBubble:c.assistantBubble)},(0,e.toDisplayString)(n.text),5)):(0,e.createCommentVNode)(``,!0)],12,p))),128)),t.loading?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:1,style:(0,e.normalizeStyle)(c.thinkingBubble),"aria-label":t.thinkingLabel},[(0,e.createElementVNode)(`span`,{style:(0,e.normalizeStyle)({...c.dot,animationDelay:`0s`})},null,4),(0,e.createElementVNode)(`span`,{style:(0,e.normalizeStyle)({...c.dot,animationDelay:`0.15s`})},null,4),(0,e.createElementVNode)(`span`,{style:(0,e.normalizeStyle)({...c.dot,animationDelay:`0.3s`})},null,4)],12,m)):(0,e.createCommentVNode)(``,!0),t.error?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:2,style:(0,e.normalizeStyle)(c.errorBubble),role:`alert`},(0,e.toDisplayString)(t.error),5)):(0,e.createCommentVNode)(``,!0),(0,e.createElementVNode)(`div`,{ref_key:`endEl`,ref:r},null,512)],2))}}),_=[`value`,`placeholder`,`disabled`],v=[`aria-label`,`disabled`],y=(0,e.defineComponent)({__name:`AgentComposer`,props:{modelValue:{},disabled:{type:Boolean,default:!1},placeholder:{default:()=>t.agentPanel.composerPlaceholder},sendLabel:{default:()=>t.agentPanel.send},className:{default:``}},emits:[`update:modelValue`,`submit`],setup(t,{emit:n}){let r=t,i=n,a=(0,e.computed)(()=>r.modelValue.trim().length>0&&!r.disabled);function o(){a.value&&i(`submit`)}let s=(0,e.computed)(()=>({width:`36px`,height:`36px`,borderRadius:`50%`,border:`none`,background:`#0b57d0`,color:`#fff`,flexShrink:0,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,transition:`background 0.15s, opacity 0.15s, transform 0.15s`,opacity:a.value?1:.35,cursor:a.value?`pointer`:`not-allowed`})),c={composerWrap:{padding:`8px 12px 14px`,background:`#fff`,flex:`0 0 auto`},composerShell:{display:`flex`,alignItems:`center`,gap:`4px`,padding:`6px 6px 6px 18px`,background:`#fff`,border:`1px solid #c4c7c5`,borderRadius:`28px`,boxShadow:`0 1px 2px rgba(60,64,67,0.04)`,transition:`border-color 0.15s, box-shadow 0.15s`,fontFamily:`'Google Sans Text', system-ui, sans-serif`},composerInput:{flex:1,padding:`8px 0`,fontSize:`14px`,border:`none`,outline:`none`,background:`transparent`,fontFamily:`inherit`,color:`#1f1f1f`},footnote:{fontSize:`11px`,color:`#5f6368`,textAlign:`center`,marginTop:`10px`,fontFamily:`'Google Sans Text', system-ui, sans-serif`}};return(n,r)=>((0,e.openBlock)(),(0,e.createElementBlock)(`form`,{class:(0,e.normalizeClass)([`ep-agent-composer`,t.className]),style:(0,e.normalizeStyle)(c.composerWrap),onSubmit:(0,e.withModifiers)(o,[`prevent`])},[(0,e.createElementVNode)(`div`,{style:(0,e.normalizeStyle)(c.composerShell)},[(0,e.createElementVNode)(`input`,{style:(0,e.normalizeStyle)(c.composerInput),value:t.modelValue,placeholder:t.placeholder,disabled:t.disabled,onInput:r[0]||=e=>i(`update:modelValue`,e.target.value)},null,44,_),(0,e.createElementVNode)(`button`,{type:`submit`,"aria-label":t.sendLabel,disabled:!a.value,style:(0,e.normalizeStyle)(s.value)},[...r[1]||=[(0,e.createElementVNode)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,"aria-hidden":`true`},[(0,e.createElementVNode)(`path`,{d:`M12 19V5M5 12l7-7 7 7`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`})],-1)]],12,v)],4),n.$slots.footnote?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:0,style:(0,e.normalizeStyle)(c.footnote)},[(0,e.renderSlot)(n.$slots,`footnote`)],4)):(0,e.createCommentVNode)(``,!0)],38))}}),b=[`disabled`],x=(0,e.defineComponent)({__name:`AgentSuggestionChip`,props:{label:{},disabled:{type:Boolean}},emits:[`click`],setup(t,{emit:n}){let r=n,i={textAlign:`left`,background:`#fff`,border:`1px solid #dadce0`,borderRadius:`18px`,padding:`10px 14px`,fontSize:`13px`,color:`#1f1f1f`,cursor:`pointer`,fontFamily:`'Google Sans Text', system-ui, sans-serif`,lineHeight:1.4,transition:`background 0.15s, border-color 0.15s, box-shadow 0.15s`,width:`100%`};return(n,a)=>((0,e.openBlock)(),(0,e.createElementBlock)(`button`,{type:`button`,style:i,disabled:t.disabled,onClick:a[0]||=e=>r(`click`)},(0,e.toDisplayString)(t.label),9,b))}}),S=[`aria-label`],C={class:`ai-ctx-menu__header`,"aria-hidden":`true`},w=[`onMousedown`],T=[`innerHTML`],E={class:`ai-ctx-menu__label`},D={key:0,class:`ai-ctx-menu__custom`},O=[`placeholder`],k=(0,e.defineComponent)({__name:`AIContextMenu`,props:{isOpen:{type:Boolean},position:{},selectedText:{},showCustomPrompt:{type:Boolean,default:!0},labels:{default:()=>({})}},emits:[`close`,`action`],setup(n,{emit:r}){let i=n,a=r,o=(0,e.ref)(``),s=(0,e.ref)([]);(0,e.watch)(()=>i.isOpen,t=>{t&&(0,e.nextTick)(()=>s.value[0]?.focus())},{immediate:!0});let c=[{id:`rewrite`,icon:`✍`},{id:`expand`,icon:`↔`},{id:`summarize`,icon:`📝`},{id:`fixGrammar`,icon:`✔`},{id:`makeFormal`,icon:`👔`},{id:`makeCasual`,icon:`😊`},{id:`translate`,icon:`🌐`},{id:`explain`,icon:`💡`}],l=(0,e.computed)(()=>i.labels?.header??t.aiActions.header),u=(0,e.computed)(()=>i.labels?.customPlaceholder??t.aiActions.customPlaceholder);function d(e){return i.labels?.[e]||(t.aiActions[e]??e)}let f=(0,e.computed)(()=>{let e=i.position.x,t=i.position.y;return typeof window<`u`&&(e+220+10>window.innerWidth&&(e=window.innerWidth-220-10),t+360+10>window.innerHeight&&(t=window.innerHeight-360-10)),{position:`fixed`,left:`${e}px`,top:`${t}px`,zIndex:500}});function p(e){a(`action`,e,e===`custom`?o.value:void 0),o.value=``,a(`close`)}return(t,r)=>((0,e.openBlock)(),(0,e.createBlock)(e.Teleport,{to:`body`},[n.isOpen?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:0,class:`ai-ctx-backdrop`,onMousedown:r[0]||=e=>a(`close`),onContextmenu:r[1]||=(0,e.withModifiers)(e=>a(`close`),[`prevent`])},null,32)):(0,e.createCommentVNode)(``,!0),n.isOpen?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:1,class:`ai-ctx-menu`,"aria-label":l.value,style:(0,e.normalizeStyle)(f.value),tabindex:`-1`,onContextmenu:r[4]||=(0,e.withModifiers)(()=>{},[`prevent`]),onKeydown:r[5]||=(0,e.withKeys)((0,e.withModifiers)(e=>a(`close`),[`stop`]),[`esc`])},[(0,e.createElementVNode)(`div`,C,(0,e.toDisplayString)(l.value),1),((0,e.openBlock)(),(0,e.createElementBlock)(e.Fragment,null,(0,e.renderList)(c,t=>(0,e.createElementVNode)(`button`,{key:t.id,ref_for:!0,ref_key:`itemRefs`,ref:s,class:`ai-ctx-menu__item`,onMousedown:(0,e.withModifiers)(e=>p(t.id),[`prevent`])},[(0,e.createElementVNode)(`span`,{class:`ai-ctx-menu__icon`,innerHTML:t.icon},null,8,T),(0,e.createElementVNode)(`span`,E,(0,e.toDisplayString)(d(t.id)),1)],40,w)),64)),r[6]||=(0,e.createElementVNode)(`div`,{class:`ai-ctx-menu__divider`},null,-1),n.showCustomPrompt?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,D,[(0,e.withDirectives)((0,e.createElementVNode)(`input`,{"onUpdate:modelValue":r[2]||=e=>o.value=e,class:`ai-ctx-menu__input`,placeholder:u.value,onKeydown:r[3]||=(0,e.withKeys)((0,e.withModifiers)(e=>p(`custom`),[`prevent`]),[`enter`])},null,40,O),[[e.vModelText,o.value]])])):(0,e.createCommentVNode)(``,!0)],44,S)):(0,e.createCommentVNode)(``,!0)]))}}),A=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n},j=A(k,[[`__scopeId`,`data-v-c30da7a7`]]),M=[`aria-label`],N={class:`ai-preview__header`},ee={class:`ai-preview__title`},te=[`aria-label`],ne={key:0,class:`ai-preview__loading`},re={key:1,class:`ai-preview__error`},ie={key:2,class:`ai-preview__content`},ae={key:0,class:`ai-preview__diff`},oe={class:`ai-preview__diff-label`},se={class:`ai-preview__diff-text ai-preview__diff-text--old`},ce={class:`ai-preview__diff-label`},le={class:`ai-preview__diff-text ai-preview__diff-text--new`},ue={key:1,class:`ai-preview__result`},de={key:3,class:`ai-preview__footer`},fe=A((0,e.defineComponent)({__name:`AIResponsePreview`,props:{isVisible:{type:Boolean},originalText:{},responseText:{},action:{},isLoading:{type:Boolean},error:{default:void 0},allowEdit:{type:Boolean,default:!0},showDiff:{type:Boolean,default:!0},showRetry:{type:Boolean,default:!0},labels:{default:()=>({})}},emits:[`accept`,`reject`,`retry`],setup(n,{emit:r}){let i=n,a=r,o=(0,e.ref)(!1),s=(0,e.ref)(``),c=(0,e.computed)(()=>({loading:i.labels?.loading??t.aiPreview.loading,original:i.labels?.original??t.aiPreview.original,suggested:i.labels?.suggested??t.aiPreview.suggested,edit:i.labels?.edit??t.aiPreview.edit,discard:i.labels?.discard??t.aiPreview.discard,accept:i.labels?.accept??t.aiPreview.accept,retry:i.labels?.retry??t.aiPreview.retry,close:i.labels?.close??t.aiPreview.close})),l=(0,e.computed)(()=>i.labels?.actionTitles?.[i.action]||(t.aiPreview.labels[i.action]??t.aiPreview.defaultTitle));(0,e.watch)(()=>i.responseText,e=>{s.value=e,o.value=!1});function u(){a(`accept`,o.value?s.value:i.responseText)}return(t,r)=>n.isVisible?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:0,class:`ai-preview`,role:`region`,"aria-label":l.value,tabindex:`-1`,onKeydown:r[5]||=(0,e.withKeys)((0,e.withModifiers)(e=>a(`reject`),[`stop`]),[`esc`])},[(0,e.createElementVNode)(`div`,N,[(0,e.createElementVNode)(`span`,ee,(0,e.toDisplayString)(l.value),1),(0,e.createElementVNode)(`button`,{class:`ai-preview__close`,"aria-label":c.value.close,onClick:r[0]||=e=>a(`reject`)},` ✕ `,8,te)]),n.isLoading?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,ne,[r[6]||=(0,e.createElementVNode)(`span`,{class:`ai-preview__spinner`},null,-1),(0,e.createElementVNode)(`span`,null,(0,e.toDisplayString)(c.value.loading),1)])):n.error?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,re,[(0,e.createElementVNode)(`span`,null,(0,e.toDisplayString)(n.error),1),n.showRetry?((0,e.openBlock)(),(0,e.createElementBlock)(`button`,{key:0,class:`ai-preview__retry`,onMousedown:r[1]||=(0,e.withModifiers)(e=>a(`retry`),[`prevent`])},(0,e.toDisplayString)(c.value.retry),33)):(0,e.createCommentVNode)(``,!0)])):((0,e.openBlock)(),(0,e.createElementBlock)(`div`,ie,[n.showDiff?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,ae,[(0,e.createElementVNode)(`div`,oe,(0,e.toDisplayString)(c.value.original),1),(0,e.createElementVNode)(`div`,se,(0,e.toDisplayString)(n.originalText),1),(0,e.createElementVNode)(`div`,ce,(0,e.toDisplayString)(c.value.suggested),1),(0,e.createElementVNode)(`div`,le,(0,e.toDisplayString)(n.responseText),1)])):((0,e.openBlock)(),(0,e.createElementBlock)(`div`,ue,(0,e.toDisplayString)(n.responseText),1)),n.allowEdit&&o.value?(0,e.withDirectives)(((0,e.openBlock)(),(0,e.createElementBlock)(`textarea`,{key:2,"onUpdate:modelValue":r[2]||=e=>s.value=e,class:`ai-preview__textarea`,rows:`4`},null,512)),[[e.vModelText,s.value]]):(0,e.createCommentVNode)(``,!0)])),!n.isLoading&&!n.error?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,de,[n.allowEdit&&!o.value?((0,e.openBlock)(),(0,e.createElementBlock)(`button`,{key:0,class:`ai-preview__btn`,onMousedown:r[3]||=(0,e.withModifiers)(e=>o.value=!0,[`prevent`])},(0,e.toDisplayString)(c.value.edit),33)):(0,e.createCommentVNode)(``,!0),(0,e.createElementVNode)(`button`,{class:`ai-preview__btn`,onMousedown:r[4]||=(0,e.withModifiers)(e=>a(`reject`),[`prevent`])},(0,e.toDisplayString)(c.value.discard),33),(0,e.createElementVNode)(`button`,{class:`ai-preview__btn ai-preview__btn--primary`,onMousedown:(0,e.withModifiers)(u,[`prevent`])},(0,e.toDisplayString)(c.value.accept),33)])):(0,e.createCommentVNode)(``,!0)],40,M)):(0,e.createCommentVNode)(``,!0)}}),[[`__scopeId`,`data-v-1226b741`]]),P=[`single`,`words`,`double`,`thick`,`dotted`,`dottedHeavy`,`dash`,`dashedHeavy`,`dashLong`,`dashLongHeavy`,`dotDash`,`dashDotHeavy`,`dotDotDash`,`dashDotDotHeavy`,`wave`,`wavyHeavy`,`wavyDouble`,`none`],F=[`black`,`blue`,`cyan`,`darkBlue`,`darkCyan`,`darkGray`,`darkGreen`,`darkMagenta`,`darkRed`,`darkYellow`,`green`,`lightGray`,`magenta`,`red`,`white`,`yellow`,`none`],I=[{name:`read_document`,displayName:`Reading document`,description:'Read the document content. Returns lines tagged with a stable paragraph id, e.g. "[2A1F3B] First paragraph". Use the bracketed id as `paraId` when commenting or suggesting changes — it survives edits, unlike ordinal indices. Returns the vanilla document (the doc as it exists right now, before any tracked suggestions are accepted): pending insertions are HIDDEN, pending deletions are shown as plain text (still part of the document until accepted), and comment markers are stripped. Use read_changes / read_comments to inspect what is pending.',inputSchema:{type:`object`,properties:{fromIndex:{type:`number`,description:`Start ordinal index (inclusive). Optional.`},toIndex:{type:`number`,description:`End ordinal index (inclusive). Optional.`}}},handler:(e,t)=>({success:!0,data:t.getContentAsText({fromIndex:e.fromIndex,toIndex:e.toIndex,includeTrackedChanges:!1,includeCommentAnchors:!1})})},{name:`read_selection`,displayName:`Reading selection`,description:`Read the user's current cursor or selection. Returns the selected text, the paragraph it lives in, and that paragraph's \`paraId\`. Use this when the user asks "fix this" or "review what I have selected".`,inputSchema:{type:`object`,properties:{}},handler:(e,t)=>{let n=t.getSelection();return n?{success:!0,data:n}:{success:!1,error:`No selection (editor not focused).`}}},{name:`read_page`,displayName:`Reading page`,description:`Read the contents of one rendered page (1-indexed). Returns paragraphs on the page, each tagged with its stable paraId. Use this when the user asks "summarize page 3" or "comment on what's on this page".`,inputSchema:{type:`object`,properties:{pageNumber:{type:`number`,description:`1-indexed page number.`}},required:[`pageNumber`]},handler:(e,t)=>{let n=t.getPage(e.pageNumber);if(!n){let n=t.getTotalPages();return n===0?{success:!1,error:`No pages rendered (headless mode or empty document).`}:{success:!1,error:`Page ${e.pageNumber} does not exist (document has ${n} page${n===1?``:`s`}).`}}return{success:!0,data:n.text||`(empty page)`}}},{name:`read_pages`,displayName:`Reading pages`,description:`Read a contiguous range of rendered pages (1-indexed, inclusive). Returns paragraphs across the range, each tagged with paraId. Cheaper than calling read_page repeatedly — single round-trip.`,inputSchema:{type:`object`,properties:{from:{type:`number`,description:`1-indexed start page (inclusive).`},to:{type:`number`,description:`1-indexed end page (inclusive).`}},required:[`from`,`to`]},handler:(e,t)=>{let n=t.getPages({from:e.from,to:e.to});if(n.length===0){let n=t.getTotalPages();return n===0?{success:!1,error:`No pages rendered (headless mode or empty document).`}:{success:!1,error:`No pages in range ${e.from}–${e.to} (document has ${n} page${n===1?``:`s`}).`}}return{success:!0,data:n.map(e=>`--- Page ${e.pageNumber} ---\n${e.text||`(empty page)`}`).join(`
|
|
10
|
+
|
|
11
|
+
`)}}},{name:`find_text`,displayName:`Finding text`,description:"Locate paragraphs containing `query`. Returns up to `limit` handles, each with `paraId`, the matched substring, and surrounding context. Pass any returned `paraId` (and the `match` as `search`) to add_comment / suggest_change.",inputSchema:{type:`object`,properties:{query:{type:`string`,description:`Text to find (substring match).`},caseSensitive:{type:`boolean`,description:`Default: false.`},limit:{type:`number`,description:`Max paragraphs to return. Default: 20.`}},required:[`query`]},handler:(e,t)=>{let n=t.findText(e.query,{caseSensitive:e.caseSensitive,limit:e.limit});return n.length===0?{success:!0,data:`No matches.`}:{success:!0,data:n}}},{name:`read_comments`,displayName:`Reading comments`,description:`List all comments in the document with their paragraph anchors.`,inputSchema:{type:`object`,properties:{}},handler:(e,t)=>{let n=t.getComments();return n.length===0?{success:!0,data:`No comments.`}:{success:!0,data:n.map(e=>`[Comment #${e.id}] ${e.author}: "${e.text}"`+(e.anchoredText?` (anchored to: "${e.anchoredText}")`:``)+(e.replies.length>0?`
|
|
12
|
+
`+e.replies.map(e=>` Reply by ${e.author}: "${e.text}"`).join(`
|
|
13
|
+
`):``)).join(`
|
|
14
|
+
`)}}},{name:`read_changes`,displayName:`Reading changes`,description:`List tracked changes (insertions / deletions) currently in the document.`,inputSchema:{type:`object`,properties:{}},handler:(e,t)=>{let n=t.getChanges();return n.length===0?{success:!0,data:`No tracked changes.`}:{success:!0,data:n.map(e=>`[Change #${e.id}] ${e.type} by ${e.author}: "${e.text}"`).join(`
|
|
15
|
+
`)}}},{name:`add_comment`,displayName:`Adding comment`,description:`Attach a comment to a paragraph, optionally anchored to a unique phrase within it. The user sees it instantly in the comments sidebar.`,inputSchema:{type:`object`,properties:{paraId:{type:`string`,description:`Paragraph id from read_document / find_text.`},text:{type:`string`,description:`Comment body.`},search:{type:`string`,description:`Optional: anchor to this exact phrase within the paragraph. Must be unique.`}},required:[`paraId`,`text`]},handler:(e,t)=>{let n=t.addComment({paraId:e.paraId,text:e.text,search:e.search});return n===null?{success:!1,error:"Could not add comment. The paraId may not exist, or `search` is missing / ambiguous."}:{success:!0,data:`Comment ${n} added on ${e.paraId}.`}}},{name:`suggest_change`,displayName:`Suggesting change`,description:"Suggest a tracked change. Three modes: (1) replacement — `search` non-empty, `replaceWith` non-empty; (2) deletion — `search` non-empty, `replaceWith` empty; (3) insertion at paragraph end — `search` empty, `replaceWith` non-empty. The user can accept or reject in the editor UI.",inputSchema:{type:`object`,properties:{paraId:{type:`string`,description:`Paragraph id from read_document / find_text.`},search:{type:`string`,description:`Phrase to find (must be unique). Empty string = insert at paragraph end.`},replaceWith:{type:`string`,description:`Replacement text. Empty string = delete the matched phrase.`}},required:[`paraId`,`search`,`replaceWith`]},handler:(e,t)=>t.proposeChange({paraId:e.paraId,search:e.search,replaceWith:e.replaceWith})?e.search?e.replaceWith?{success:!0,data:`Replacement proposed: "${e.search}" → "${e.replaceWith}" on ${e.paraId}.`}:{success:!0,data:`Deletion proposed: "${e.search}" on ${e.paraId}.`}:{success:!0,data:`Insertion proposed on ${e.paraId}.`}:{success:!1,error:`Could not propose change. Possible causes: paraId not found; search missing or ambiguous; or the target overlaps an existing tracked change.`}},{name:`apply_formatting`,displayName:`Applying formatting`,description:'Apply character formatting (bold, italic, underline, strike, color, highlight, font size, font family) to a paragraph or to a unique phrase within it. Pass `search` to scope the change to part of the paragraph; omit it to format the whole paragraph. Direct edit — does not create a tracked change. Pass `false` to clear a mark; omit a key to leave it untouched. Color uses `{rgb: "FF0000"}` (no hash) or `{themeColor: "accent1"}`. Font size is in points. Font family takes `{ascii, hAnsi}`.',inputSchema:{type:`object`,properties:{paraId:{type:`string`,description:`Paragraph id from read_document / find_text.`},search:{type:`string`,description:`Optional: format only this exact phrase within the paragraph (must be unique).`},marks:{type:`object`,description:`Marks to set or clear. Omit a key to leave it untouched.`,properties:{bold:{type:`boolean`},italic:{type:`boolean`},underline:{description:`true → single underline; false → clear; or { style: "single"|"double"|"thick"|"dotted"|"dottedHeavy"|"dash"|"dashedHeavy"|"dashLong"|"dashLongHeavy"|"dotDash"|"dashDotHeavy"|"dotDotDash"|"dashDotDotHeavy"|"wave"|"wavyHeavy"|"wavyDouble"|"words"|"none" }. Other values are rejected.`},strike:{type:`boolean`},color:{type:`object`,description:`Either {rgb: "RRGGBB"} (no hash) or {themeColor: "accent1"|"text1"|...}.`,properties:{rgb:{type:`string`},themeColor:{type:`string`}}},highlight:{type:`string`,enum:[...F],description:`Highlight color — must be one of the Word-supported names: `+F.join(`, `)+`. Pass "none" to clear. Hex values are rejected (Word does not accept hex for <w:highlight>).`},fontSize:{type:`number`,description:`Size in points (e.g. 12, 14, 24).`},fontFamily:{type:`object`,properties:{ascii:{type:`string`},hAnsi:{type:`string`}}}}}},required:[`paraId`,`marks`]},handler:(e,t)=>{if(!e.marks||Object.keys(e.marks).length===0)return{success:!1,error:`No marks provided. Specify at least one of bold/italic/etc.`};let n=typeof e.marks.underline==`object`&&e.marks.underline!==null?e.marks.underline.style:void 0;if(n&&!P.includes(n))return{success:!1,error:`Invalid underline.style "${n}". Must be one of: ${P.join(`, `)}.`};let r=typeof e.marks.highlight==`string`?e.marks.highlight:void 0;if(r&&!F.includes(r))return{success:!1,error:`Invalid highlight "${r}". Must be one of: ${F.join(`, `)}. Hex values are not supported by Word's highlight attribute.`};let i=r===`none`?{...e.marks,highlight:``}:e.marks;return t.applyFormatting({paraId:e.paraId,search:e.search,marks:i})?{success:!0,data:`Formatting applied to ${e.search?`"${e.search}" in ${e.paraId}`:e.paraId}.`}:{success:!1,error:"Could not apply formatting. The paraId may not exist, or `search` is missing / ambiguous."}}},{name:`set_paragraph_style`,displayName:`Setting paragraph style`,description:`Apply a paragraph style by id (e.g. "Heading1", "Heading2", "Title", "Quote", "Normal"). The styleId must exist in the document's style definitions — unknown ids are no-ops. Direct edit, not a tracked change.`,inputSchema:{type:`object`,properties:{paraId:{type:`string`,description:`Paragraph id from read_document / find_text.`},styleId:{type:`string`,description:`Style id (e.g. "Heading1", "Title", "Quote", "Normal").`}},required:[`paraId`,`styleId`]},handler:(e,t)=>t.setParagraphStyle({paraId:e.paraId,styleId:e.styleId})?{success:!0,data:`Style "${e.styleId}" applied to ${e.paraId}.`}:{success:!1,error:`Could not set style. paraId "${e.paraId}" not found, or styleId "${e.styleId}" is not defined.`}},{name:`reply_comment`,displayName:`Replying to comment`,description:`Reply to an existing comment by id. Threaded under the original.`,inputSchema:{type:`object`,properties:{commentId:{type:`number`,description:`Comment id from read_comments.`},text:{type:`string`,description:`Reply body.`}},required:[`commentId`,`text`]},handler:(e,t)=>{let n=t.replyTo(e.commentId,{text:e.text});return n===null?{success:!1,error:`Comment #${e.commentId} not found.`}:{success:!0,data:`Reply ${n} added to comment ${e.commentId}.`}}},{name:`resolve_comment`,displayName:`Resolving comment`,description:`Mark a comment as resolved (done).`,inputSchema:{type:`object`,properties:{commentId:{type:`number`,description:`Comment id from read_comments.`}},required:[`commentId`]},handler:(e,t)=>(t.resolveComment(e.commentId),{success:!0,data:`Comment ${e.commentId} resolved.`})},{name:`scroll`,displayName:`Scrolling`,description:`Scroll the editor to a paragraph by paraId. Does not move the user's cursor.`,inputSchema:{type:`object`,properties:{paraId:{type:`string`,description:`Paragraph id from read_document / find_text.`}},required:[`paraId`]},handler:(e,t)=>t.scrollTo(e.paraId)?{success:!0,data:`Scrolled to ${e.paraId}.`}:{success:!1,error:`paraId ${e.paraId} not found.`}}];function L(e,t,n){let r=I.find(t=>t.name===e);if(!r)return{success:!1,error:`Unknown tool: ${e}`};try{return r.handler(t,n)}catch(e){return{success:!1,error:e instanceof Error?e.message:String(e)}}}function R(e){let t=I.find(t=>t.name===e);if(t?.displayName)return t.displayName;let n=e.replace(/_/g,` `);return n.charAt(0).toUpperCase()+n.slice(1)}function z(){return I.map(e=>({type:`function`,function:{name:e.name,description:e.description,parameters:e.inputSchema}}))}function B(e){return e.content.filter(e=>e.type===`text`).map(e=>e.text).join(``)}function V(e){let t=[];for(let n of e.children)n.type===`run`&&t.push(B(n));return t.join(``)}function pe(e){return e?e.toLowerCase().includes(`heading`):!1}function me(e){if(!e)return;let t=e.match(/heading\s*(\d)/i);if(t)return parseInt(t[1],10)}function H(e){return e.type===`insertion`||e.type===`deletion`||e.type===`moveFrom`||e.type===`moveTo`}function U(e){let t=[];for(let n of e)n.type===`run`?t.push(B(n)):n.type===`hyperlink`&&t.push(V(n));return t.join(``)}function W(e,t){let n=0;for(let r of e.content)if(r.type===`paragraph`){if(t(r,n)===!1)return;n++}else if(r.type===`table`){for(let e of r.rows)for(let r of e.cells)for(let e of r.content)if(e.type===`paragraph`){if(t(e,n)===!1)return;n++}}else n++}function G(e,t={}){let{fromIndex:n,toIndex:r,includeTrackedChanges:i=!0,includeCommentAnchors:a=!0}=t,o=[],s=0;for(let t of e.content)if(t.type===`paragraph`)K(s,n,r)&&o.push(he(t,s,i,a)),s++;else if(t.type===`table`){K(s,n,r)&&o.push(ge(t,s,i,a));for(let e of t.rows)for(let t of e.cells)for(let e of t.content)e.type===`paragraph`&&s++}else s++;return o}function K(e,t,n){return(t===void 0||e>=t)&&(n===void 0||e<=n)}function he(e,t,n,r){let i=q(e,n,r),a=e.formatting?.styleId,o=e.paraId;return pe(a)?{type:`heading`,index:t,paraId:o,level:me(a)??1,text:i}:e.listRendering?{type:`list-item`,index:t,paraId:o,text:i,listLevel:e.listRendering.level??0,listType:e.listRendering.isBullet?`bullet`:`number`}:{type:`paragraph`,index:t,paraId:o,text:i}}function ge(e,t,n,r){let i=[],a=[];for(let t of e.rows){let e=[],o=[];for(let i of t.cells){let t=[],a;for(let e of i.content)e.type===`paragraph`&&(a===void 0&&(a=e.paraId),t.push(q(e,n,r)));e.push(t.join(`
|
|
16
|
+
`)),o.push(a)}i.push(e),a.push(o)}return{type:`table`,index:t,rows:i,cellParaIds:a}}function _e(e){let t=[],n=e=>e.paraId?e.paraId:String(e.index);for(let r of e)switch(r.type){case`heading`:t.push(`[${n(r)}] (h${r.level}) ${r.text}`);break;case`paragraph`:t.push(`[${n(r)}] ${r.text}`);break;case`list-item`:{let e=` `.repeat(r.listLevel),i=r.listType===`bullet`?`•`:`-`;t.push(`[${n(r)}] ${e}${i} ${r.text}`);break}case`table`:{let e=r.index;for(let n=0;n<r.rows.length;n++)for(let i=0;i<r.rows[n].length;i++){let a=r.rows[n][i].split(`
|
|
17
|
+
`),o=r.cellParaIds?.[n]?.[i];for(let r=0;r<a.length;r++){let s=r===0&&o?o:String(e);t.push(`[${s}] (table, row ${n+1}, col ${i+1}) ${a[r]}`),e++}}break}}return t.join(`
|
|
18
|
+
`)}function q(e,t,n){let r=[],i=new Set;for(let a of e.content){if(a.type===`commentRangeStart`&&n){i.add(a.id),r.push(`[comment:${a.id}]`);continue}if(a.type===`commentRangeEnd`&&n){i.has(a.id)&&(i.delete(a.id),r.push(`[/comment]`));continue}if(a.type===`run`)r.push(B(a));else if(a.type===`hyperlink`)r.push(V(a));else if(H(a)){let e=U(a.content);a.type===`insertion`||a.type===`moveTo`?t&&r.push(`[+${e}+]{by:${a.info.author}}`):t?r.push(`[-${e}-]{by:${a.info.author}}`):r.push(e)}}return r.join(``)}function ve(e){let t=[],n=0;for(let r=0;r<e.content.length;r++){let i=e.content[r];if(i.type===`run`){let e=B(i);t.push({contentIndex:r,run:i,text:e,startPos:n}),n+=e.length}else if(i.type===`hyperlink`)for(let e=0;e<i.children.length;e++){let a=i.children[e];if(a.type===`run`){let e=B(a);t.push({contentIndex:r,run:a,text:e,startPos:n}),n+=e.length}}else if(H(i)){if(i.type===`insertion`||i.type===`moveTo`)continue;for(let e=0;e<i.content.length;e++){let a=i.content[e];if(a.type===`run`){let e=B(a);t.push({contentIndex:r,run:a,text:e,startPos:n}),n+=e.length}else if(a.type===`hyperlink`){for(let e of a.children)if(e.type===`run`){let i=B(e);t.push({contentIndex:r,run:e,text:i,startPos:n}),n+=i.length}}}}}return t}function J(e){return ve(e).map(e=>e.text).join(``)}function Y(e,t){let n=new Map;return W(e,(e,t)=>{let r=null;for(let i of e.content)if(H(i)){r===null&&(r=J(e));let a=U(i.content),o=i.info.id,s=n.get(o);s&&s.paragraphIndex===t?s.text+=a:n.set(o,{id:o,type:i.type,author:i.info.author,date:i.info.date??null,text:a,context:r,paragraphIndex:t})}}),Array.from(n.values()).filter(e=>!(t?.author&&e.author!==t.author||t?.type&&e.type!==t.type))}function X(e,t){let n=e.comments??[];if(n.length===0)return[];let r=ye(e),i=[],a=new Map;for(let e of n)if(e.parentId!==void 0){let t=a.get(e.parentId)??[];t.push(e),a.set(e.parentId,t)}else i.push(e);return i.map(e=>{let t=r.get(e.id),n=(a.get(e.id)??[]).map(e=>({id:e.id,author:e.author,date:e.date??null,text:Z(e)}));return{id:e.id,author:e.author,date:e.date??null,text:Z(e),anchoredText:t?.text??``,paragraphIndex:t?.paragraphIndex??-1,replies:n,done:e.done??!1}}).filter(e=>!(t?.author&&e.author!==t.author||t?.done!==void 0&&e.done!==t.done))}function Z(e){return e.content.map(e=>J(e)).join(`
|
|
19
|
+
`)}function ye(e){let t=new Map,n=new Map;return W(e,(e,r)=>{for(let i of e.content)if(i.type===`commentRangeStart`)n.set(i.id,{paragraphIndex:r,parts:[]});else if(i.type===`commentRangeEnd`){let e=n.get(i.id);e&&(t.set(i.id,{text:e.parts.join(``),paragraphIndex:e.paragraphIndex}),n.delete(i.id))}else if(i.type===`run`){let e=B(i);for(let t of n.values())t.parts.push(e)}else if(i.type===`hyperlink`){let e=i.children.filter(e=>e.type===`run`).map(B).join(``);for(let t of n.values())t.parts.push(e)}else if(H(i)){if(i.type===`insertion`||i.type===`moveTo`)continue;let e=U(i.content);for(let t of n.values())t.parts.push(e)}}),t}function Q(e){return!e||e.length===0?``:e.map(e=>{let t=e;return t?.content?t.content.map(e=>e.content?.map(e=>e.text||``).join(``)||``).join(``):``}).join(`
|
|
20
|
+
`)}function $(e){let t=e.getEditorRef();if(t){let e=t.getDocument();if(e?.package?.document)return e.package.document}return e.getDocument()?.package?.document??null}function be(e,t=`AI`){function n(e){return e??t}return{getContentAsText(t){let n=$(e);return n?_e(G(n,t)):``},getContent(t){let n=$(e);return n?G(n,t):[]},getComments(t){let n=$(e);if(!n)return[];let r=X(n,t);if(r.length>0)return r;let i=e.getComments();if(i.length===0)return[];let a=new Map,o=[];for(let e of i)if(e.parentId){let t=a.get(e.parentId);t?t.push(e):a.set(e.parentId,[e])}else o.push(e);let s=[];for(let e of o){if(t?.author&&e.author!==t.author||t?.done!==void 0&&(e.done??!1)!==t.done)continue;let n=a.get(e.id)??[];s.push({id:e.id,author:e.author,date:e.date??null,text:Q(e.content),anchoredText:``,paragraphIndex:-1,replies:n.map(e=>({id:e.id,author:e.author,date:e.date??null,text:Q(e.content)})),done:e.done??!1})}return s},getChanges(t){let n=$(e);return n?Y(n,t):[]},findText(t,n){return e.findInDocument(t,n)},getSelection(){return e.getSelectionInfo()},addComment(t){return e.addComment({paraId:t.paraId,text:t.text,author:n(t.author),search:t.search})},replyTo(t,r){return e.replyToComment(t,r.text,n(r.author))},resolveComment(t){e.resolveComment(t)},proposeChange(t){return e.proposeChange({paraId:t.paraId,search:t.search,replaceWith:t.replaceWith,author:n(t.author)})},applyFormatting(t){return e.applyFormatting({paraId:t.paraId,search:t.search,marks:t.marks})},setParagraphStyle(t){return e.setParagraphStyle({paraId:t.paraId,styleId:t.styleId})},getPage(t){return e.getPageContent(t)},getPages(t){let n=e.getTotalPages(),r=Math.max(1,Math.min(t.from,n)),i=Math.max(r,Math.min(t.to,n)),a=[];for(let t=r;t<=i;t++){let n=e.getPageContent(t);n&&a.push(n)}return a},getTotalPages(){return e.getTotalPages()},getCurrentPage(){return e.getCurrentPage()},scrollTo(t){return e.scrollToParaId(t)},onContentChange(t){return e.onContentChange(()=>{let n=$(e),r=n?X(n):[],i=n?Y(n):[];try{t({commentCount:r.length,changeCount:i.length,comments:r,changes:i})}catch(e){console.error(`onContentChange listener threw:`,e)}})},onSelectionChange(t){return e.onSelectionChange(()=>{try{t(e.getSelectionInfo())}catch(e){console.error(`onSelectionChange listener threw:`,e)}})}}}var xe=z();function Se(t){let{editorRef:n,author:r=`AI`}=t,i=(0,e.computed)(()=>n.value?be(n.value,(0,e.unref)(r)):null);function a(e,t){let n=i.value;return n?L(e,t,n):{success:!1,error:`Editor not ready`}}return{executeToolCall:a,toolSchemas:xe}}exports.AIContextMenu=j,exports.AIResponsePreview=fe,exports.AgentChatLog=g,exports.AgentComposer=y,exports.AgentPanel=o,exports.AgentSuggestionChip=x,exports.AgentTimeline=f,exports.getToolDisplayName=R,exports.useAgentBridge=Se;
|