@singlebase/elements 0.3.0 → 0.5.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/README.md +2 -0
- package/dist/{display-8HEcKYR4.js → authui-display-BCZBP7HR.js} +11 -10
- package/dist/authui-display-BCZBP7HR.js.map +1 -0
- package/dist/{display-CLDNNZQy.cjs → authui-display-CLGFSqRi.cjs} +21 -21
- package/dist/authui-display-CLGFSqRi.cjs.map +1 -0
- package/dist/authui.cjs +1 -1
- package/dist/authui.d.ts +9 -9
- package/dist/authui.js +2 -2
- package/dist/chat-DRenTJlI.cjs +3001 -0
- package/dist/chat-DRenTJlI.cjs.map +1 -0
- package/dist/chat-bXaRWel7.js +4926 -0
- package/dist/chat-bXaRWel7.js.map +1 -0
- package/dist/chat-messages.d.ts +109 -0
- package/dist/chat.cjs +2 -0
- package/dist/chat.cjs.map +1 -0
- package/dist/chat.d.ts +10 -0
- package/dist/chat.js +13 -0
- package/dist/chat.js.map +1 -0
- package/dist/elements/{account-screen.d.ts → authui-account.d.ts} +1 -1
- package/dist/elements/{buttons.d.ts → authui-buttons.d.ts} +1 -1
- package/dist/elements/{display.d.ts → authui-display.d.ts} +1 -1
- package/dist/elements/{form-base.d.ts → authui-form-base.d.ts} +1 -1
- package/dist/elements/{guard.d.ts → authui-guard.d.ts} +1 -1
- package/dist/elements/{auth-screen.d.ts → authui.d.ts} +3 -3
- package/dist/elements/chat.d.ts +312 -0
- package/dist/files-BOwtpYyQ.js +168 -0
- package/dist/files-BOwtpYyQ.js.map +1 -0
- package/dist/files-DW8A4Jl-.cjs +38 -0
- package/dist/files-DW8A4Jl-.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +36 -25
- package/dist/index.js.map +1 -1
- package/dist/singlebase-elements.min.js +6841 -1824
- package/dist/singlebase-elements.min.js.map +1 -1
- package/dist/styles/chat.d.ts +6 -0
- package/dist/styles/tokens.d.ts +1 -1
- package/dist/{uploader-eFYKpk8b.cjs → uploader-DGV2y9uT.cjs} +41 -77
- package/dist/uploader-DGV2y9uT.cjs.map +1 -0
- package/dist/{uploader-D-Da1trc.js → uploader-abQoem5q.js} +309 -463
- package/dist/uploader-abQoem5q.js.map +1 -0
- package/dist/uploader.cjs +1 -1
- package/dist/uploader.js +5 -4
- package/dist/uploader.js.map +1 -1
- package/dist/utils/markdown.d.ts +108 -0
- package/package.json +13 -5
- package/dist/display-8HEcKYR4.js.map +0 -1
- package/dist/display-CLDNNZQy.cjs.map +0 -1
- package/dist/uploader-D-Da1trc.js.map +0 -1
- package/dist/uploader-eFYKpk8b.cjs.map +0 -1
- /package/dist/elements/{base.d.ts → authui-base.d.ts} +0 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default copy for <singlebase-chat>. Same contract as the auth and upload
|
|
3
|
+
* bags: flat strings, overridable in whole or in part through `.messages`.
|
|
4
|
+
*
|
|
5
|
+
* `{name}`, `{n}` and `{query}` are filled in by `fill()` from upload-messages.
|
|
6
|
+
*/
|
|
7
|
+
export interface SinglebaseChatMessages {
|
|
8
|
+
eyebrowChat: string;
|
|
9
|
+
eyebrowRag: string;
|
|
10
|
+
eyebrowRich: string;
|
|
11
|
+
headingChat: string;
|
|
12
|
+
headingRag: string;
|
|
13
|
+
headingRich: string;
|
|
14
|
+
descriptionChat: string;
|
|
15
|
+
descriptionRag: string;
|
|
16
|
+
descriptionRich: string;
|
|
17
|
+
placeholderChat: string;
|
|
18
|
+
placeholderRag: string;
|
|
19
|
+
placeholderRich: string;
|
|
20
|
+
footnote: string;
|
|
21
|
+
attach: string;
|
|
22
|
+
send: string;
|
|
23
|
+
stop: string;
|
|
24
|
+
removeFile: string;
|
|
25
|
+
dropTitle: string;
|
|
26
|
+
dropSub: string;
|
|
27
|
+
thinking: string;
|
|
28
|
+
searching: string;
|
|
29
|
+
building: string;
|
|
30
|
+
chats: string;
|
|
31
|
+
newChat: string;
|
|
32
|
+
searchChats: string;
|
|
33
|
+
groupBookmarked: string;
|
|
34
|
+
groupToday: string;
|
|
35
|
+
groupYesterday: string;
|
|
36
|
+
groupWeek: string;
|
|
37
|
+
groupOlder: string;
|
|
38
|
+
noChats: string;
|
|
39
|
+
noMatch: string;
|
|
40
|
+
loadingChats: string;
|
|
41
|
+
showChats: string;
|
|
42
|
+
hideSidebar: string;
|
|
43
|
+
untitled: string;
|
|
44
|
+
renameChat: string;
|
|
45
|
+
bookmarkChat: string;
|
|
46
|
+
unbookmarkChat: string;
|
|
47
|
+
exportChat: string;
|
|
48
|
+
deleteChat: string;
|
|
49
|
+
expand: string;
|
|
50
|
+
restore: string;
|
|
51
|
+
minimize: string;
|
|
52
|
+
exportHeading: string;
|
|
53
|
+
exportMarkdown: string;
|
|
54
|
+
exportJson: string;
|
|
55
|
+
exportText: string;
|
|
56
|
+
exportCopy: string;
|
|
57
|
+
copy: string;
|
|
58
|
+
copied: string;
|
|
59
|
+
edit: string;
|
|
60
|
+
saveResend: string;
|
|
61
|
+
cancel: string;
|
|
62
|
+
regenerate: string;
|
|
63
|
+
helpful: string;
|
|
64
|
+
notHelpful: string;
|
|
65
|
+
markedHelpful: string;
|
|
66
|
+
thanksFeedback: string;
|
|
67
|
+
bookmarkMessage: string;
|
|
68
|
+
unbookmarkMessage: string;
|
|
69
|
+
deleteMessage: string;
|
|
70
|
+
saved: string;
|
|
71
|
+
stopped: string;
|
|
72
|
+
emptyReply: string;
|
|
73
|
+
newReply: string;
|
|
74
|
+
you: string;
|
|
75
|
+
sourcesCited: string;
|
|
76
|
+
sourcesRetrieved: string;
|
|
77
|
+
searchedSources: string;
|
|
78
|
+
sourceLabel: string;
|
|
79
|
+
openSource: string;
|
|
80
|
+
citedPassage: string;
|
|
81
|
+
copyReference: string;
|
|
82
|
+
alsoCited: string;
|
|
83
|
+
close: string;
|
|
84
|
+
undo: string;
|
|
85
|
+
chatDeleted: string;
|
|
86
|
+
messageDeleted: string;
|
|
87
|
+
messageBookmarked: string;
|
|
88
|
+
bookmarkRemoved: string;
|
|
89
|
+
chatBookmarked: string;
|
|
90
|
+
chatUnbookmarked: string;
|
|
91
|
+
exported: string;
|
|
92
|
+
copiedMarkdown: string;
|
|
93
|
+
fileTooLarge: string;
|
|
94
|
+
fileType: string;
|
|
95
|
+
tooManyFiles: string;
|
|
96
|
+
errGeneric: string;
|
|
97
|
+
errNotFound: string;
|
|
98
|
+
errNoClient: string;
|
|
99
|
+
errLoad: string;
|
|
100
|
+
retry: string;
|
|
101
|
+
offline: string;
|
|
102
|
+
bubbleText: string;
|
|
103
|
+
openChat: string;
|
|
104
|
+
closeChat: string;
|
|
105
|
+
dismiss: string;
|
|
106
|
+
brandingLabel: string;
|
|
107
|
+
}
|
|
108
|
+
export declare const defaultChatMessages: SinglebaseChatMessages;
|
|
109
|
+
export declare function resolveChatMessages(overrides: Partial<SinglebaseChatMessages> | undefined): SinglebaseChatMessages;
|
package/dist/chat.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chat-DRenTJlI.cjs");Object.defineProperty(exports,"SinglebaseChat",{enumerable:!0,get:()=>e.SinglebaseChat});exports.adaptBlocks=e.adaptBlocks;exports.citedNumbers=e.citedNumbers;exports.defaultChatMessages=e.defaultChatMessages;exports.describeSource=e.describeSource;exports.parseInline=e.parseInline;exports.parseMarkdown=e.parseMarkdown;exports.resolveChatMessages=e.resolveChatMessages;exports.splitFollowups=e.splitFollowups;
|
|
2
|
+
//# sourceMappingURL=chat.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/chat.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@singlebase/elements/chat` — <singlebase-chat> on its own, without the
|
|
3
|
+
* authentication elements or the uploader. Importing it registers the tag.
|
|
4
|
+
*/
|
|
5
|
+
export { SinglebaseChat, describeSource } from "./elements/chat.js";
|
|
6
|
+
export type { ChatAttachment, ChatClient, ChatConfig, ChatEmbed, ChatExportFormat, ChatGlow, ChatMessage, ChatMode, ChatPrompt, ChatSummary } from "./elements/chat.js";
|
|
7
|
+
export { adaptBlocks, citedNumbers, parseInline, parseMarkdown, splitFollowups } from "./utils/markdown.js";
|
|
8
|
+
export type { Block, ChartSpec, RenderAs, Segment } from "./utils/markdown.js";
|
|
9
|
+
export { defaultChatMessages, resolveChatMessages } from "./chat-messages.js";
|
|
10
|
+
export type { SinglebaseChatMessages } from "./chat-messages.js";
|
package/dist/chat.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { S as e, a as r, c as l, d as o, b as t, p, e as d, r as c, s as i } from "./chat-bXaRWel7.js";
|
|
2
|
+
export {
|
|
3
|
+
e as SinglebaseChat,
|
|
4
|
+
r as adaptBlocks,
|
|
5
|
+
l as citedNumbers,
|
|
6
|
+
o as defaultChatMessages,
|
|
7
|
+
t as describeSource,
|
|
8
|
+
p as parseInline,
|
|
9
|
+
d as parseMarkdown,
|
|
10
|
+
c as resolveChatMessages,
|
|
11
|
+
i as splitFollowups
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=chat.js.map
|
package/dist/chat.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type PropertyValues } from "lit";
|
|
2
2
|
import { type AuthSettings } from "@singlebase/singlebase-sdk";
|
|
3
|
-
import { SinglebaseFormBase } from "./form-base.js";
|
|
3
|
+
import { SinglebaseFormBase } from "./authui-form-base.js";
|
|
4
4
|
import "./uploader.js";
|
|
5
5
|
/**
|
|
6
6
|
* The authenticated account view, laid out exactly as the design mock's
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { nothing, type PropertyValues } from "lit";
|
|
2
2
|
import type { AuthSettings, OAuthIntent } from "@singlebase/singlebase-sdk";
|
|
3
|
-
import { SinglebaseFormBase } from "./form-base.js";
|
|
3
|
+
import { SinglebaseFormBase } from "./authui-form-base.js";
|
|
4
4
|
export type ButtonsType = "signout" | "oauth" | "link";
|
|
5
5
|
/**
|
|
6
6
|
* The widget's action buttons, selected with `type`:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Predicate } from "@singlebase/core";
|
|
2
|
-
import { SinglebaseElementBase } from "./base.js";
|
|
2
|
+
import { SinglebaseElementBase } from "./authui-base.js";
|
|
3
3
|
export type GuardState = "loading" | "authenticated" | "unauthenticated";
|
|
4
4
|
/**
|
|
5
5
|
* Renders content conditionally on auth state, and optionally on a predicate
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { nothing, type PropertyValues } from "lit";
|
|
2
2
|
import { type AuthSettings } from "@singlebase/singlebase-sdk";
|
|
3
|
-
import { SinglebaseElementBase } from "./base.js";
|
|
4
|
-
import "./account
|
|
5
|
-
import "./buttons.js";
|
|
3
|
+
import { SinglebaseElementBase } from "./authui-base.js";
|
|
4
|
+
import "./authui-account.js";
|
|
5
|
+
import "./authui-buttons.js";
|
|
6
6
|
/** Screens a signed-out visitor may reach. */
|
|
7
7
|
export type GuestScreen = "signin" | "signup" | "forgot" | "verify" | "otp" | "newpass" | "invite";
|
|
8
8
|
/** Screens that require a live session. */
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import { LitElement, type PropertyValues, type TemplateResult } from "lit";
|
|
2
|
+
import { type SinglebaseChatMessages } from "../chat-messages.js";
|
|
3
|
+
import { type RenderAs } from "../utils/markdown.js";
|
|
4
|
+
export type ChatMode = "chat" | "rag" | "rich";
|
|
5
|
+
export type ChatEmbed = "page" | "inline" | "launcher";
|
|
6
|
+
export type ChatGlow = "subtle" | "vivid" | "off";
|
|
7
|
+
export type ChatExportFormat = "md" | "txt" | "json" | "copy";
|
|
8
|
+
/** What the chat needs from a client: `llm.call`, and nothing else. */
|
|
9
|
+
export type ChatClient = {
|
|
10
|
+
llm: {
|
|
11
|
+
call<T = unknown>(method: string, payload?: unknown, options?: {
|
|
12
|
+
signal?: AbortSignal;
|
|
13
|
+
}): Promise<T>;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
/** A row of `llm.list_chats`. */
|
|
17
|
+
export interface ChatSummary {
|
|
18
|
+
_id: string;
|
|
19
|
+
title: string | null;
|
|
20
|
+
bookmarked?: boolean;
|
|
21
|
+
message_count?: number;
|
|
22
|
+
_created_at?: string;
|
|
23
|
+
_modified_at?: string;
|
|
24
|
+
}
|
|
25
|
+
/** A text file attached to one message, sent to the model as retrieval. */
|
|
26
|
+
export interface ChatAttachment {
|
|
27
|
+
name: string;
|
|
28
|
+
size: number;
|
|
29
|
+
content: string;
|
|
30
|
+
}
|
|
31
|
+
export interface ChatMessage {
|
|
32
|
+
/** Local identity, stable across renders. */
|
|
33
|
+
key: string;
|
|
34
|
+
/** The server's message id, once known. Bookmark and delete need it. */
|
|
35
|
+
id: string | null;
|
|
36
|
+
role: "user" | "assistant";
|
|
37
|
+
/** The text. For replies, the FOLLOWUPS tail is already split off. */
|
|
38
|
+
content: string;
|
|
39
|
+
at: number;
|
|
40
|
+
bookmarked: boolean;
|
|
41
|
+
/** Retrieved documents the reply used, as the server recorded them. */
|
|
42
|
+
sources: Record<string, unknown>[];
|
|
43
|
+
followups: string[];
|
|
44
|
+
phase: "pending" | "streaming" | "done" | "error";
|
|
45
|
+
error?: string;
|
|
46
|
+
stopped?: boolean;
|
|
47
|
+
feedback?: "up" | "down";
|
|
48
|
+
attachments?: ChatAttachment[];
|
|
49
|
+
execTime?: number;
|
|
50
|
+
model?: string;
|
|
51
|
+
}
|
|
52
|
+
export interface ChatPrompt {
|
|
53
|
+
label?: string;
|
|
54
|
+
text: string;
|
|
55
|
+
}
|
|
56
|
+
/** Every setting in one object, keyed by property name. */
|
|
57
|
+
export interface ChatConfig {
|
|
58
|
+
embed: ChatEmbed;
|
|
59
|
+
mode: ChatMode;
|
|
60
|
+
renderAs: RenderAs;
|
|
61
|
+
glow: ChatGlow;
|
|
62
|
+
position: "right" | "left";
|
|
63
|
+
sidebar: boolean | undefined;
|
|
64
|
+
showTitle: boolean;
|
|
65
|
+
assistantName: string;
|
|
66
|
+
logoUrl: string;
|
|
67
|
+
heading: string;
|
|
68
|
+
description: string;
|
|
69
|
+
prompts: string | (string | ChatPrompt)[];
|
|
70
|
+
bubbleText: string;
|
|
71
|
+
greetingBubble: boolean;
|
|
72
|
+
unreadBadge: boolean;
|
|
73
|
+
allowUpload: boolean;
|
|
74
|
+
allowExport: boolean;
|
|
75
|
+
branding: boolean;
|
|
76
|
+
followups: boolean;
|
|
77
|
+
autoTitle: boolean;
|
|
78
|
+
model: string;
|
|
79
|
+
params: Record<string, unknown>;
|
|
80
|
+
systemMessage: string;
|
|
81
|
+
retrieval: Record<string, unknown>[];
|
|
82
|
+
metadata: Record<string, unknown>;
|
|
83
|
+
messages: Partial<SinglebaseChatMessages>;
|
|
84
|
+
theme: "light" | "dark";
|
|
85
|
+
}
|
|
86
|
+
/** A readable view of whatever shape the server recorded for a source. */
|
|
87
|
+
export declare function describeSource(source: Record<string, unknown>, n: number): {
|
|
88
|
+
n: number;
|
|
89
|
+
title: string;
|
|
90
|
+
path: string;
|
|
91
|
+
collection: string;
|
|
92
|
+
updated: string;
|
|
93
|
+
text: string;
|
|
94
|
+
score: number | null;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* An AI chat workspace backed by the `llm.*` service.
|
|
98
|
+
*
|
|
99
|
+
* <singlebase-chat></singlebase-chat>
|
|
100
|
+
* <singlebase-chat embed="inline" mode="rag" retrieval='[{"type":"kdb","namespace":"docs"}]'></singlebase-chat>
|
|
101
|
+
* <singlebase-chat embed="launcher" greeting-bubble unread-badge></singlebase-chat>
|
|
102
|
+
*
|
|
103
|
+
* Conversations live on the server, scoped to the signed-in user: the list
|
|
104
|
+
* comes from `llm.list_chats`, a thread from `llm.get_chat`, and each turn is
|
|
105
|
+
* one `llm.chat`. Titles and follow-up questions never add turns to the
|
|
106
|
+
* conversation — titles come from `llm.generate`, follow-ups from the reply.
|
|
107
|
+
*/
|
|
108
|
+
export declare class SinglebaseChat extends LitElement {
|
|
109
|
+
static styles: import("lit").CSSResult[];
|
|
110
|
+
/** An explicit client. Omit it and the page's SinglebaseClient() is used. */
|
|
111
|
+
accessor client: ChatClient | null;
|
|
112
|
+
accessor messages: Partial<SinglebaseChatMessages>;
|
|
113
|
+
accessor theme: "light" | "dark" | undefined;
|
|
114
|
+
/** `chat` free-form, `rag` grounded with citations, `rich` charts and tables. */
|
|
115
|
+
accessor mode: ChatMode;
|
|
116
|
+
/** How replies display. Copy and export always use the original text. */
|
|
117
|
+
accessor renderAs: RenderAs;
|
|
118
|
+
accessor glow: ChatGlow;
|
|
119
|
+
/** Ask for follow-up questions with each reply. */
|
|
120
|
+
accessor followups: boolean;
|
|
121
|
+
/** Replace the provisional title with a model-written one after the first reply. */
|
|
122
|
+
accessor autoTitle: boolean;
|
|
123
|
+
/** Model for new turns; empty uses the chat's, then the project default. */
|
|
124
|
+
accessor model: string;
|
|
125
|
+
accessor params: Record<string, unknown>;
|
|
126
|
+
/** Extra instructions, sent when a chat is created. */
|
|
127
|
+
accessor systemMessage: string;
|
|
128
|
+
/** Retrieval sources sent with every turn: `[{"type":"kdb","namespace":"docs"}]`. */
|
|
129
|
+
accessor retrieval: Record<string, unknown>[];
|
|
130
|
+
/** Stored on each user message. Never sent to the model. */
|
|
131
|
+
accessor metadata: Record<string, unknown>;
|
|
132
|
+
accessor embed: ChatEmbed;
|
|
133
|
+
/** Launcher side. */
|
|
134
|
+
accessor position: "right" | "left";
|
|
135
|
+
/** Force the chat list open or closed. Unset, it docks when there's room. */
|
|
136
|
+
accessor sidebar: boolean | undefined;
|
|
137
|
+
accessor showTitle: boolean;
|
|
138
|
+
/** Opens this chat on load. */
|
|
139
|
+
accessor chatIdAttr: string;
|
|
140
|
+
/** Used in placeholders, exports and labels. Never shown above messages. */
|
|
141
|
+
accessor assistantName: string;
|
|
142
|
+
accessor logoUrl: string;
|
|
143
|
+
accessor heading: string;
|
|
144
|
+
accessor description: string;
|
|
145
|
+
/** Suggested prompts: `|`-separated in markup, an array in JavaScript. */
|
|
146
|
+
accessor prompts: string | (string | ChatPrompt)[];
|
|
147
|
+
accessor bubbleText: string;
|
|
148
|
+
accessor greetingBubble: boolean;
|
|
149
|
+
accessor unreadBadge: boolean;
|
|
150
|
+
accessor allowUpload: boolean;
|
|
151
|
+
accessor allowExport: boolean;
|
|
152
|
+
/** The "Chat by Singlebase" credit. A plain link — it makes no request. */
|
|
153
|
+
accessor branding: boolean;
|
|
154
|
+
private accessor chatList;
|
|
155
|
+
private accessor listState;
|
|
156
|
+
private accessor activeId;
|
|
157
|
+
private accessor chatTitle;
|
|
158
|
+
private accessor bookmarked;
|
|
159
|
+
private accessor msgs;
|
|
160
|
+
private accessor loadingThread;
|
|
161
|
+
private accessor threadError;
|
|
162
|
+
private accessor busy;
|
|
163
|
+
private accessor draft;
|
|
164
|
+
private accessor files;
|
|
165
|
+
private accessor search;
|
|
166
|
+
private accessor sidebarOpen;
|
|
167
|
+
private accessor width;
|
|
168
|
+
private accessor panel;
|
|
169
|
+
private accessor menuOpen;
|
|
170
|
+
private accessor editingKey;
|
|
171
|
+
private accessor editDraft;
|
|
172
|
+
private accessor editingTitle;
|
|
173
|
+
private accessor renamingId;
|
|
174
|
+
private accessor toast;
|
|
175
|
+
private accessor copiedKey;
|
|
176
|
+
private accessor retrievalOpen;
|
|
177
|
+
private accessor arrivedKey;
|
|
178
|
+
private accessor dragging;
|
|
179
|
+
private accessor showJump;
|
|
180
|
+
private accessor offline;
|
|
181
|
+
private accessor isOpen;
|
|
182
|
+
private accessor expanded;
|
|
183
|
+
private accessor bubble;
|
|
184
|
+
private accessor seen;
|
|
185
|
+
private accessor mobile;
|
|
186
|
+
private run;
|
|
187
|
+
private abort;
|
|
188
|
+
private revealTimer;
|
|
189
|
+
private timers;
|
|
190
|
+
private toastTimer;
|
|
191
|
+
private stick;
|
|
192
|
+
private renamed;
|
|
193
|
+
private observer;
|
|
194
|
+
private observed;
|
|
195
|
+
private media;
|
|
196
|
+
private focusNext;
|
|
197
|
+
private bubbleScheduled;
|
|
198
|
+
get msg(): SinglebaseChatMessages;
|
|
199
|
+
/** An explicit `.client`, else the page default. */
|
|
200
|
+
get resolvedClient(): ChatClient | null;
|
|
201
|
+
/** The open conversation's id, or null for a new chat. */
|
|
202
|
+
get chatId(): string | null;
|
|
203
|
+
/** The open conversation's messages. */
|
|
204
|
+
get thread(): readonly ChatMessage[];
|
|
205
|
+
/** The loaded chat list. */
|
|
206
|
+
get chats(): readonly ChatSummary[];
|
|
207
|
+
set config(value: Partial<ChatConfig>);
|
|
208
|
+
get config(): Partial<ChatConfig>;
|
|
209
|
+
connectedCallback(): void;
|
|
210
|
+
disconnectedCallback(): void;
|
|
211
|
+
willUpdate(changed: PropertyValues<this>): void;
|
|
212
|
+
firstUpdated(): void;
|
|
213
|
+
updated(): void;
|
|
214
|
+
private onNetwork;
|
|
215
|
+
private onMedia;
|
|
216
|
+
private later;
|
|
217
|
+
private emit;
|
|
218
|
+
private get docked();
|
|
219
|
+
private get panelDocked();
|
|
220
|
+
/** Starts a new, empty conversation. */
|
|
221
|
+
newChat(): void;
|
|
222
|
+
/** Opens a saved conversation. */
|
|
223
|
+
openChat(id: string): Promise<void>;
|
|
224
|
+
/** Sends a message; with no argument, sends the composer's text. */
|
|
225
|
+
send(text?: string): Promise<void>;
|
|
226
|
+
/** Stops waiting for, or revealing, the current reply. */
|
|
227
|
+
stop(): void;
|
|
228
|
+
/** Downloads the open conversation, or copies it as Markdown. */
|
|
229
|
+
exportChat(format?: ChatExportFormat): void;
|
|
230
|
+
/** Inline and launcher: fill the window. */
|
|
231
|
+
expand(): void;
|
|
232
|
+
collapse(): void;
|
|
233
|
+
/** Launcher: open the panel. */
|
|
234
|
+
open(): void;
|
|
235
|
+
/** Launcher: close the panel. */
|
|
236
|
+
close(): void;
|
|
237
|
+
private userMessage;
|
|
238
|
+
private systemPrompt;
|
|
239
|
+
private payloadFor;
|
|
240
|
+
private runTurn;
|
|
241
|
+
private failTurn;
|
|
242
|
+
/**
|
|
243
|
+
* The service answers in one piece; this reveals it progressively so it
|
|
244
|
+
* reads like a stream. Capped at about a second and a half.
|
|
245
|
+
*/
|
|
246
|
+
private reveal;
|
|
247
|
+
/** Cancels any request or reveal in flight. */
|
|
248
|
+
private halt;
|
|
249
|
+
private retitle;
|
|
250
|
+
private applyTitle;
|
|
251
|
+
/**
|
|
252
|
+
* Enter and blur both land here. Saving on Enter directly (not via blur())
|
|
253
|
+
* matters: blur never fires on an input that doesn't have focus.
|
|
254
|
+
*/
|
|
255
|
+
private commitTitle;
|
|
256
|
+
private commitRename;
|
|
257
|
+
private renameChat;
|
|
258
|
+
private fromServer;
|
|
259
|
+
private loadChats;
|
|
260
|
+
private upsertChat;
|
|
261
|
+
private touchChat;
|
|
262
|
+
private resetViewState;
|
|
263
|
+
private deleteOnServer;
|
|
264
|
+
private regenerate;
|
|
265
|
+
private retry;
|
|
266
|
+
private saveEdit;
|
|
267
|
+
private copy;
|
|
268
|
+
private toggleMessageBookmark;
|
|
269
|
+
private toggleChatBookmark;
|
|
270
|
+
/** Removed at once; the server call waits out the undo window. */
|
|
271
|
+
private deleteMessage;
|
|
272
|
+
private deleteChat;
|
|
273
|
+
private feedback;
|
|
274
|
+
private showToast;
|
|
275
|
+
/** Ends the current toast, committing whatever it was holding back. */
|
|
276
|
+
private flushToast;
|
|
277
|
+
private undo;
|
|
278
|
+
private addFiles;
|
|
279
|
+
private scrollToBottom;
|
|
280
|
+
private onScroll;
|
|
281
|
+
private jumpToLatest;
|
|
282
|
+
private onKeydown;
|
|
283
|
+
private onComposerKey;
|
|
284
|
+
private onComposerInput;
|
|
285
|
+
private onDragEnter;
|
|
286
|
+
private onDragLeave;
|
|
287
|
+
private onDrop;
|
|
288
|
+
render(): TemplateResult<1>;
|
|
289
|
+
private renderLauncher;
|
|
290
|
+
private renderWorkspace;
|
|
291
|
+
private renderSidebar;
|
|
292
|
+
private renderThreadRow;
|
|
293
|
+
private renderHeader;
|
|
294
|
+
private renderExportMenu;
|
|
295
|
+
private promptList;
|
|
296
|
+
private renderWelcome;
|
|
297
|
+
private renderThread;
|
|
298
|
+
private renderUser;
|
|
299
|
+
private pillLabel;
|
|
300
|
+
private renderBot;
|
|
301
|
+
private renderAnswer;
|
|
302
|
+
private renderInline;
|
|
303
|
+
private renderBlock;
|
|
304
|
+
private renderChart;
|
|
305
|
+
private renderPanel;
|
|
306
|
+
private renderComposer;
|
|
307
|
+
}
|
|
308
|
+
declare global {
|
|
309
|
+
interface HTMLElementTagNameMap {
|
|
310
|
+
"singlebase-chat": SinglebaseChat;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { unsafeCSS as i, css as c } from "lit";
|
|
2
|
+
const d = {
|
|
3
|
+
font: '"Geist", -apple-system, "Segoe UI", Helvetica, sans-serif',
|
|
4
|
+
mono: '"Geist Mono", ui-monospace, monospace',
|
|
5
|
+
accent: "#111111",
|
|
6
|
+
onAccent: "#ffffff",
|
|
7
|
+
radius: "4px",
|
|
8
|
+
surface: "#ffffff",
|
|
9
|
+
surfaceAlt: "#fafafa",
|
|
10
|
+
ink: "#16181a",
|
|
11
|
+
mutedInk: "#61666c",
|
|
12
|
+
border: "#e4e6e9",
|
|
13
|
+
borderStrong: "#cdd1d6",
|
|
14
|
+
danger: "#b4231a",
|
|
15
|
+
dangerBg: "#fdf1f0",
|
|
16
|
+
dangerBorder: "#f3d6d3",
|
|
17
|
+
dangerOutline: "#e8c4c0",
|
|
18
|
+
dangerPanelBorder: "#efd9d6",
|
|
19
|
+
dangerPanelBg: "#fdf7f6",
|
|
20
|
+
ok: "#0f6b4a",
|
|
21
|
+
okBg: "#f0f7f3",
|
|
22
|
+
okBorder: "#cfe5da",
|
|
23
|
+
gap: "16px",
|
|
24
|
+
pad: "20px",
|
|
25
|
+
fieldPad: "11px 13px"
|
|
26
|
+
}, u = c`
|
|
27
|
+
:host {
|
|
28
|
+
display: block;
|
|
29
|
+
box-sizing: border-box;
|
|
30
|
+
font-family: var(--sb-font, ${i(d.font)});
|
|
31
|
+
color: var(--sb-ink, ${i(d.ink)});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
:host([theme="dark"]) {
|
|
35
|
+
/* The light default accent is near-black, which disappears on a dark
|
|
36
|
+
surface — primary buttons and links both use it. A host that sets its
|
|
37
|
+
own --sb-accent still wins: outer-page declarations beat :host rules. */
|
|
38
|
+
--sb-accent: #f3f4f5;
|
|
39
|
+
--sb-on-accent: #17181b;
|
|
40
|
+
--sb-surface: #17181b;
|
|
41
|
+
--sb-surface-alt: #202226;
|
|
42
|
+
--sb-ink: #f3f4f5;
|
|
43
|
+
--sb-muted-ink: #a2a8ae;
|
|
44
|
+
--sb-border: #2c2f34;
|
|
45
|
+
--sb-border-strong: #3a3e44;
|
|
46
|
+
--sb-danger: #f08379;
|
|
47
|
+
--sb-danger-bg: rgba(240, 131, 121, 0.1);
|
|
48
|
+
--sb-danger-border: rgba(240, 131, 121, 0.3);
|
|
49
|
+
--sb-danger-outline: rgba(240, 131, 121, 0.4);
|
|
50
|
+
--sb-danger-panel-border: rgba(240, 131, 121, 0.3);
|
|
51
|
+
--sb-danger-panel-bg: rgba(240, 131, 121, 0.06);
|
|
52
|
+
--sb-ok: #6fd1a6;
|
|
53
|
+
--sb-ok-bg: rgba(111, 209, 166, 0.1);
|
|
54
|
+
--sb-ok-border: rgba(111, 209, 166, 0.28);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
:host([density="compact"]) {
|
|
58
|
+
--sb-gap: 12px;
|
|
59
|
+
--sb-pad: 16px;
|
|
60
|
+
--sb-field-pad: 9px 11px;
|
|
61
|
+
}
|
|
62
|
+
`, f = {
|
|
63
|
+
heading: "Upload files",
|
|
64
|
+
description: "Add one or more files. You can review the list before uploading.",
|
|
65
|
+
dropTitle: "Drag and drop files here",
|
|
66
|
+
dropSub: "or browse from your device",
|
|
67
|
+
hintUpTo: "up to {size} each",
|
|
68
|
+
chooseFiles: "Choose files",
|
|
69
|
+
chooseFile: "Choose file",
|
|
70
|
+
addMore: "+ Add more files",
|
|
71
|
+
remove: "Remove",
|
|
72
|
+
rename: "Rename",
|
|
73
|
+
retry: "Retry",
|
|
74
|
+
uploadCtaOne: "Upload {n} file",
|
|
75
|
+
uploadCtaMany: "Upload {n} files",
|
|
76
|
+
attachments: "Attachments",
|
|
77
|
+
dropOrChoose: "Drop files or choose",
|
|
78
|
+
checking: "Checking…",
|
|
79
|
+
pagesLabel: "{n} pages",
|
|
80
|
+
countOne: "{n} file of {max}",
|
|
81
|
+
countMany: "{n} files of {max}",
|
|
82
|
+
uploading: "Uploading…",
|
|
83
|
+
uploaded: "Uploaded",
|
|
84
|
+
failedLabel: "Failed",
|
|
85
|
+
errTooMany: "You can upload up to {max} files.",
|
|
86
|
+
errTooLarge: "{name} is larger than {size}.",
|
|
87
|
+
errTooSmall: "{name} is smaller than {size}.",
|
|
88
|
+
errDuplicate: "{name} is already in the list.",
|
|
89
|
+
errType: "{name} isn't an accepted file type.",
|
|
90
|
+
errNoClient: "No Singlebase client found on this page.",
|
|
91
|
+
errUpload: "Upload failed.",
|
|
92
|
+
errProtected: "{name} is password protected.",
|
|
93
|
+
errTooManyPages: "{name} has {pages} pages; the limit is {max}.",
|
|
94
|
+
brandingLabel: "Files by Singlebase"
|
|
95
|
+
};
|
|
96
|
+
function g(e) {
|
|
97
|
+
return e ? { ...f, ...e } : f;
|
|
98
|
+
}
|
|
99
|
+
function m(e, r) {
|
|
100
|
+
return e.replace(
|
|
101
|
+
/\{(\w+)\}/g,
|
|
102
|
+
(a, n) => n in r ? String(r[n]) : a
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
const l = {
|
|
106
|
+
b: 1,
|
|
107
|
+
kb: 1024,
|
|
108
|
+
mb: 1024 * 1024,
|
|
109
|
+
gb: 1024 * 1024 * 1024
|
|
110
|
+
};
|
|
111
|
+
function h(e) {
|
|
112
|
+
if (typeof e == "number") return e > 0 ? e : 0;
|
|
113
|
+
if (!e) return 0;
|
|
114
|
+
const r = String(e).trim().toLowerCase().match(/^([\d.]+)\s*(b|kb|mb|gb)?$/);
|
|
115
|
+
if (!r) return 0;
|
|
116
|
+
const a = Number.parseFloat(r[1]);
|
|
117
|
+
return !Number.isFinite(a) || a <= 0 ? 0 : Math.round(a * (l[r[2] ?? "b"] ?? 1));
|
|
118
|
+
}
|
|
119
|
+
function x(e) {
|
|
120
|
+
return e < 1024 ? `${e} B` : e < 1024 * 1024 ? `${Math.round(e / 1024)} KB` : e < 1024 * 1024 * 1024 ? `${(e / (1024 * 1024)).toFixed(1)} MB` : `${(e / (1024 * 1024 * 1024)).toFixed(1)} GB`;
|
|
121
|
+
}
|
|
122
|
+
function p(e) {
|
|
123
|
+
const r = e.lastIndexOf(".");
|
|
124
|
+
return r <= 0 || r === e.length - 1 ? "" : e.slice(r + 1).toLowerCase();
|
|
125
|
+
}
|
|
126
|
+
function k(e) {
|
|
127
|
+
return p(e).toUpperCase().slice(0, 4);
|
|
128
|
+
}
|
|
129
|
+
function C(e, r, a) {
|
|
130
|
+
const n = e.split(",").map((t) => t.trim().toLowerCase()).filter(Boolean);
|
|
131
|
+
if (!n.length) return !0;
|
|
132
|
+
const o = r.toLowerCase(), s = (a || "").toLowerCase();
|
|
133
|
+
return n.some((t) => t.startsWith(".") ? o.endsWith(t) : t.endsWith("/*") ? s.startsWith(t.slice(0, -1)) : s === t);
|
|
134
|
+
}
|
|
135
|
+
function w(e) {
|
|
136
|
+
const r = e.split(",").map((a) => a.trim()).filter(Boolean).map((a) => {
|
|
137
|
+
if (a.startsWith(".")) return a.slice(1).toUpperCase();
|
|
138
|
+
if (a.endsWith("/*")) return a.slice(0, -2).toUpperCase();
|
|
139
|
+
const n = a.indexOf("/");
|
|
140
|
+
return (n >= 0 ? a.slice(n + 1) : a).toUpperCase();
|
|
141
|
+
});
|
|
142
|
+
return [...new Set(r)].join(", ");
|
|
143
|
+
}
|
|
144
|
+
function U(e) {
|
|
145
|
+
return `${e.name}:${e.size}:${e.lastModified ?? 0}`;
|
|
146
|
+
}
|
|
147
|
+
function S(e, r) {
|
|
148
|
+
const a = r.trim().replace(/[/\\]/g, "");
|
|
149
|
+
if (!a) return e;
|
|
150
|
+
const n = e.lastIndexOf("."), o = n > 0 ? e.slice(n) : "";
|
|
151
|
+
return o ? a.toLowerCase().endsWith(o.toLowerCase()) ? a : a + o : a;
|
|
152
|
+
}
|
|
153
|
+
export {
|
|
154
|
+
d as T,
|
|
155
|
+
x as a,
|
|
156
|
+
p as b,
|
|
157
|
+
C as c,
|
|
158
|
+
f as d,
|
|
159
|
+
U as e,
|
|
160
|
+
m as f,
|
|
161
|
+
S as g,
|
|
162
|
+
w as h,
|
|
163
|
+
k as i,
|
|
164
|
+
h as p,
|
|
165
|
+
g as r,
|
|
166
|
+
u as t
|
|
167
|
+
};
|
|
168
|
+
//# sourceMappingURL=files-BOwtpYyQ.js.map
|