ai-ax 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/ui.d.ts +253 -248
- package/dist/client/ui.js +5 -5
- package/package.json +1 -1
package/dist/client/ui.d.ts
CHANGED
|
@@ -55,25 +55,21 @@ interface Storage {
|
|
|
55
55
|
text: string;
|
|
56
56
|
}
|
|
57
57
|
//#endregion
|
|
58
|
-
//#region src/client/ui/share/
|
|
58
|
+
//#region src/client/ui/share/client.d.ts
|
|
59
59
|
interface PopProps {
|
|
60
|
-
items
|
|
60
|
+
items?: Item[];
|
|
61
61
|
value?: string;
|
|
62
|
-
pick
|
|
62
|
+
pick?: (item: Item) => void;
|
|
63
63
|
align?: 'left' | 'right';
|
|
64
64
|
cls?: string;
|
|
65
65
|
point?: Point | null;
|
|
66
|
-
check
|
|
66
|
+
check?: string;
|
|
67
|
+
children?: ReactNode;
|
|
67
68
|
}
|
|
68
|
-
declare const Pop: ({ cls, items, value, pick, style, check }: {
|
|
69
|
-
cls: string;
|
|
70
|
-
items: Item[];
|
|
71
|
-
value?: string;
|
|
72
|
-
pick: (m: Item) => void;
|
|
69
|
+
declare const Pop: ({ cls, items, value, pick, style, check, children }: PopProps & {
|
|
73
70
|
style?: any;
|
|
74
|
-
check: string;
|
|
75
71
|
}) => import("react").JSX.Element;
|
|
76
|
-
declare const Drop: ({ items, value, pick, align, cls, point, check }: PopProps) => import("react").JSX.Element;
|
|
72
|
+
declare const Drop: ({ items, value, pick, align, cls, point, check, children }: PopProps) => import("react").JSX.Element;
|
|
77
73
|
//#endregion
|
|
78
74
|
//#region src/client/ui/share/place.d.ts
|
|
79
75
|
declare const place: (anchorEl?: Element | null, boxEl?: Element | null, input?: PlaceInput) => Placed | null;
|
|
@@ -127,19 +123,19 @@ interface Dropped {
|
|
|
127
123
|
//#region src/client/ui/gesture/drop/drop.d.ts
|
|
128
124
|
declare const createFileDrop: (zone: string, onDrop: (items: Dropped[], drop: string) => void, canDrop?: () => boolean) => (el: Element | null) => void;
|
|
129
125
|
//#endregion
|
|
130
|
-
//#region src/client/ui/gesture/utils.d.ts
|
|
126
|
+
//#region src/client/ui/gesture/utils/utils.d.ts
|
|
131
127
|
declare const vec2: (x?: number, y?: number, out?: any[] | Float32Array<ArrayBuffer>) => Vec2;
|
|
132
128
|
type Vec2 = [x: number, y: number];
|
|
133
129
|
//#endregion
|
|
134
|
-
//#region src/client/ui/gesture/drag.d.ts
|
|
130
|
+
//#region src/client/ui/gesture/utils/drag.d.ts
|
|
135
131
|
declare const dragEvent: <El extends Element = Element>(onDrag?: () => void, canStart?: (event: Event) => boolean) => any;
|
|
136
132
|
type DragState = ReturnType<typeof dragEvent>;
|
|
137
133
|
//#endregion
|
|
138
|
-
//#region src/client/ui/gesture/drop.d.ts
|
|
134
|
+
//#region src/client/ui/gesture/utils/drop.d.ts
|
|
139
135
|
declare const dropEvent: <El extends Element = Element>(onDrop?: () => void, canStart?: (event: DragEvent) => boolean) => any;
|
|
140
136
|
type DropState = ReturnType<typeof dropEvent>;
|
|
141
137
|
//#endregion
|
|
142
|
-
//#region src/client/ui/gesture/over/
|
|
138
|
+
//#region src/client/ui/gesture/over/utils.d.ts
|
|
143
139
|
type Skip = (el: Element, drop: string) => boolean;
|
|
144
140
|
//#endregion
|
|
145
141
|
//#region src/client/ui/gesture/over/over.d.ts
|
|
@@ -163,197 +159,7 @@ type Ghost = ReturnType<typeof createGhost>;
|
|
|
163
159
|
declare const createGrab: (id: string, zone: string, ghost: Ghost, over: Over, done: (drop: string) => void) => (el: Element | null) => undefined;
|
|
164
160
|
type Grab = ReturnType<typeof createGrab>;
|
|
165
161
|
//#endregion
|
|
166
|
-
//#region src/client/ui/
|
|
167
|
-
declare const AiChatButton: () => import("react").JSX.Element;
|
|
168
|
-
declare const AiChat: () => import("react").JSX.Element | null;
|
|
169
|
-
//#endregion
|
|
170
|
-
//#region src/client/ui/chat/clicks.d.ts
|
|
171
|
-
declare const openChat: () => void;
|
|
172
|
-
declare const closeChat: () => void;
|
|
173
|
-
declare const toggleChat: () => void;
|
|
174
|
-
//#endregion
|
|
175
|
-
//#region src/client/ui/chat/types.d.ts
|
|
176
|
-
interface ChatTool {
|
|
177
|
-
icon?: string;
|
|
178
|
-
label: string;
|
|
179
|
-
}
|
|
180
|
-
interface ChatMsg {
|
|
181
|
-
role: 'agent' | 'user';
|
|
182
|
-
text: string;
|
|
183
|
-
tools?: ChatTool[];
|
|
184
|
-
}
|
|
185
|
-
interface ChatPrompt {
|
|
186
|
-
icon?: string;
|
|
187
|
-
color?: string;
|
|
188
|
-
label: string;
|
|
189
|
-
prompt?: string;
|
|
190
|
-
}
|
|
191
|
-
interface ChatHello {
|
|
192
|
-
greet: string;
|
|
193
|
-
title: string;
|
|
194
|
-
desc: string;
|
|
195
|
-
prompts: ChatPrompt[];
|
|
196
|
-
}
|
|
197
|
-
interface ChatMenu {
|
|
198
|
-
useOpen: () => string;
|
|
199
|
-
flip: (id: string) => (e: any) => void;
|
|
200
|
-
close: () => void;
|
|
201
|
-
}
|
|
202
|
-
interface ChatCommand {
|
|
203
|
-
name: string;
|
|
204
|
-
desc: string;
|
|
205
|
-
label?: string;
|
|
206
|
-
run: () => any;
|
|
207
|
-
}
|
|
208
|
-
interface ChatStreamTool {
|
|
209
|
-
server: string;
|
|
210
|
-
name: string;
|
|
211
|
-
}
|
|
212
|
-
interface ChatStreamItem {
|
|
213
|
-
text: string;
|
|
214
|
-
tools: ChatStreamTool[];
|
|
215
|
-
error?: boolean;
|
|
216
|
-
}
|
|
217
|
-
interface ChatStreamSend {
|
|
218
|
-
prompt: string;
|
|
219
|
-
path?: string;
|
|
220
|
-
model?: string;
|
|
221
|
-
messages?: any[];
|
|
222
|
-
headers?: Record<string, string>;
|
|
223
|
-
}
|
|
224
|
-
interface ChatStreamUpdate {
|
|
225
|
-
items: ChatStreamItem[];
|
|
226
|
-
delta: string;
|
|
227
|
-
raw: string;
|
|
228
|
-
}
|
|
229
|
-
interface ChatStream {
|
|
230
|
-
parse: (raw: string) => ChatStreamItem[];
|
|
231
|
-
send: (input: ChatStreamSend, update?: (u: ChatStreamUpdate) => void) => Promise<ChatStreamItem[]>;
|
|
232
|
-
}
|
|
233
|
-
interface ChatConfig {
|
|
234
|
-
send: (input: {
|
|
235
|
-
prompt: string;
|
|
236
|
-
}) => Promise<string>;
|
|
237
|
-
stream: ChatStream;
|
|
238
|
-
icon: string;
|
|
239
|
-
path: string;
|
|
240
|
-
headers: Record<string, string>;
|
|
241
|
-
hello: () => ChatHello;
|
|
242
|
-
menu: ChatMenu;
|
|
243
|
-
commands: () => ChatCommand[];
|
|
244
|
-
hints: (msgs: ChatMsg[]) => ChatCommand[];
|
|
245
|
-
}
|
|
246
|
-
//#endregion
|
|
247
|
-
//#region src/client/ui/chat/config.d.ts
|
|
248
|
-
declare const config: ChatConfig;
|
|
249
|
-
declare const configure: (next: Partial<ChatConfig>) => undefined;
|
|
250
|
-
//#endregion
|
|
251
|
-
//#region src/client/ui/chat/stream.d.ts
|
|
252
|
-
declare const toMsg: (it: ChatStreamItem) => ChatMsg;
|
|
253
|
-
declare const restoreChat: (talks: {
|
|
254
|
-
prompt: string;
|
|
255
|
-
reply: string;
|
|
256
|
-
tools: string[];
|
|
257
|
-
}[]) => void;
|
|
258
|
-
declare const runChat: (prompt: string) => Promise<string>;
|
|
259
|
-
//#endregion
|
|
260
|
-
//#region src/client/ui/chat/utils/commands/types.d.ts
|
|
261
|
-
interface Command {
|
|
262
|
-
name: string;
|
|
263
|
-
desc: string;
|
|
264
|
-
label?: string;
|
|
265
|
-
run: () => any;
|
|
266
|
-
}
|
|
267
|
-
interface Habit {
|
|
268
|
-
name: string;
|
|
269
|
-
part: number;
|
|
270
|
-
after: string;
|
|
271
|
-
count: number;
|
|
272
|
-
}
|
|
273
|
-
interface CommandConfig {
|
|
274
|
-
store: {
|
|
275
|
-
list: () => Promise<Habit[]>;
|
|
276
|
-
save: (habit: {
|
|
277
|
-
name: string;
|
|
278
|
-
part: number;
|
|
279
|
-
after: string;
|
|
280
|
-
}) => any;
|
|
281
|
-
};
|
|
282
|
-
deck: Command[];
|
|
283
|
-
greet: {
|
|
284
|
-
greet: string;
|
|
285
|
-
title: string;
|
|
286
|
-
desc: string;
|
|
287
|
-
};
|
|
288
|
-
starters: () => string[];
|
|
289
|
-
pinned: () => string[];
|
|
290
|
-
hinted: (msgs: any[]) => string[];
|
|
291
|
-
}
|
|
292
|
-
//#endregion
|
|
293
|
-
//#region src/client/ui/chat/utils/commands/index.d.ts
|
|
294
|
-
declare const createCommands: (config: CommandConfig) => {
|
|
295
|
-
commands: () => Command[];
|
|
296
|
-
hello: () => {
|
|
297
|
-
greet: string;
|
|
298
|
-
title: string;
|
|
299
|
-
desc: string;
|
|
300
|
-
prompts: {
|
|
301
|
-
label: string;
|
|
302
|
-
prompt: string;
|
|
303
|
-
}[];
|
|
304
|
-
};
|
|
305
|
-
hints: (msgs: any[]) => Command[];
|
|
306
|
-
prime: () => Promise<void>;
|
|
307
|
-
};
|
|
308
|
-
//#endregion
|
|
309
|
-
//#region src/client/ui/chat/utils/history/types.d.ts
|
|
310
|
-
interface HistoryTalk {
|
|
311
|
-
prompt: string;
|
|
312
|
-
reply: string;
|
|
313
|
-
tools: string[];
|
|
314
|
-
}
|
|
315
|
-
interface HistoryStore {
|
|
316
|
-
list: () => Promise<any[]>;
|
|
317
|
-
load: (chatId: string) => Promise<{
|
|
318
|
-
talks: any[];
|
|
319
|
-
tools: any[];
|
|
320
|
-
}>;
|
|
321
|
-
save: (chatId: string, body: any) => any;
|
|
322
|
-
}
|
|
323
|
-
interface HistoryConfig {
|
|
324
|
-
store: HistoryStore;
|
|
325
|
-
show: (talks: HistoryTalk[]) => void;
|
|
326
|
-
}
|
|
327
|
-
//#endregion
|
|
328
|
-
//#region src/client/ui/chat/utils/history/index.d.ts
|
|
329
|
-
declare const createHistory: (config: HistoryConfig) => {
|
|
330
|
-
wrap: <T extends {
|
|
331
|
-
send: any;
|
|
332
|
-
}>(base: T) => T;
|
|
333
|
-
reset: () => void;
|
|
334
|
-
load: (id: string) => Promise<void>;
|
|
335
|
-
list: () => Promise<any[]>;
|
|
336
|
-
};
|
|
337
|
-
type History = ReturnType<typeof createHistory>;
|
|
338
|
-
//#endregion
|
|
339
|
-
//#region src/client/ui/chat/utils/markdown.d.ts
|
|
340
|
-
declare const markdown: {
|
|
341
|
-
render: (text: string) => string;
|
|
342
|
-
plain: (text: string) => string;
|
|
343
|
-
};
|
|
344
|
-
//#endregion
|
|
345
|
-
//#region src/client/ui/chat/state.d.ts
|
|
346
|
-
declare const isChatBusy: () => boolean;
|
|
347
|
-
declare const useChatBusy: () => boolean;
|
|
348
|
-
//#endregion
|
|
349
|
-
//#region src/client/ui/chat/const.d.ts
|
|
350
|
-
declare const models: {
|
|
351
|
-
id: string;
|
|
352
|
-
label: string;
|
|
353
|
-
desc: string;
|
|
354
|
-
}[];
|
|
355
|
-
//#endregion
|
|
356
|
-
//#region src/client/ui/shell/band.d.ts
|
|
162
|
+
//#region src/client/ui/shell/atoms/band.d.ts
|
|
357
163
|
interface CardItem extends Item {
|
|
358
164
|
menu?: boolean;
|
|
359
165
|
}
|
|
@@ -372,21 +178,7 @@ declare const Strip: ({ count, min, cls, children }: {
|
|
|
372
178
|
declare const Cards: ({ cards, click, popup, count }: BandProps) => import("react").JSX.Element;
|
|
373
179
|
declare const Band: (props: BandProps) => import("react").JSX.Element;
|
|
374
180
|
//#endregion
|
|
375
|
-
//#region src/client/ui/shell/
|
|
376
|
-
interface AppProps {
|
|
377
|
-
drawer: boolean;
|
|
378
|
-
close: () => void;
|
|
379
|
-
dropRef?: any;
|
|
380
|
-
children: ReactNode;
|
|
381
|
-
}
|
|
382
|
-
declare const Frame: ({ drawer, close, dropRef, children }: AppProps) => import("react").JSX.Element;
|
|
383
|
-
declare const Main: ({ drop, from, children }: {
|
|
384
|
-
drop?: string;
|
|
385
|
-
from?: string;
|
|
386
|
-
children: ReactNode;
|
|
387
|
-
}) => import("react").JSX.Element;
|
|
388
|
-
//#endregion
|
|
389
|
-
//#region src/client/ui/shell/head.d.ts
|
|
181
|
+
//#region src/client/ui/shell/atoms/head.d.ts
|
|
390
182
|
interface SpHeadProps {
|
|
391
183
|
icon: string;
|
|
392
184
|
color: string;
|
|
@@ -424,31 +216,21 @@ declare const SpBtn: ({ icon, size, click, children }: {
|
|
|
424
216
|
}) => import("react").JSX.Element;
|
|
425
217
|
declare const MoreIcon: string;
|
|
426
218
|
//#endregion
|
|
427
|
-
//#region src/client/ui/shell/
|
|
428
|
-
interface
|
|
429
|
-
icon: string;
|
|
430
|
-
color: string;
|
|
431
|
-
label: string;
|
|
432
|
-
click: () => void;
|
|
433
|
-
}
|
|
434
|
-
interface SideProps {
|
|
435
|
-
brand: BrandProps;
|
|
436
|
-
bar: boolean;
|
|
219
|
+
//#region src/client/ui/shell/atoms/main.d.ts
|
|
220
|
+
interface AppProps {
|
|
437
221
|
drawer: boolean;
|
|
438
|
-
fold: () => void;
|
|
439
222
|
close: () => void;
|
|
440
|
-
|
|
441
|
-
storage: Storage;
|
|
442
|
-
upgrade: () => void;
|
|
443
|
-
menu?: ReactNode;
|
|
444
|
-
more: (e: any) => void;
|
|
223
|
+
dropRef?: any;
|
|
445
224
|
children: ReactNode;
|
|
446
225
|
}
|
|
447
|
-
declare const
|
|
448
|
-
declare const
|
|
449
|
-
|
|
226
|
+
declare const Frame: ({ drawer, close, dropRef, children }: AppProps) => import("react").JSX.Element;
|
|
227
|
+
declare const Main: ({ drop, from, children }: {
|
|
228
|
+
drop?: string;
|
|
229
|
+
from?: string;
|
|
230
|
+
children: ReactNode;
|
|
231
|
+
}) => import("react").JSX.Element;
|
|
450
232
|
//#endregion
|
|
451
|
-
//#region src/client/ui/shell/row.d.ts
|
|
233
|
+
//#region src/client/ui/shell/atoms/row.d.ts
|
|
452
234
|
interface RowProps {
|
|
453
235
|
depth?: number;
|
|
454
236
|
on?: boolean;
|
|
@@ -473,6 +255,30 @@ declare const Fold: ({ open, turn }: {
|
|
|
473
255
|
}) => import("react").JSX.Element;
|
|
474
256
|
declare const Row: ({ depth, on, open, turn, icon, color, label, drop, mark, from, click, dclick, rclick, dragRef, children }: RowProps) => import("react").JSX.Element;
|
|
475
257
|
//#endregion
|
|
258
|
+
//#region src/client/ui/shell/atoms/side.d.ts
|
|
259
|
+
interface BrandProps {
|
|
260
|
+
icon: string;
|
|
261
|
+
color: string;
|
|
262
|
+
label: string;
|
|
263
|
+
click: () => void;
|
|
264
|
+
}
|
|
265
|
+
interface SideProps {
|
|
266
|
+
brand: BrandProps;
|
|
267
|
+
bar: boolean;
|
|
268
|
+
drawer: boolean;
|
|
269
|
+
fold: () => void;
|
|
270
|
+
close: () => void;
|
|
271
|
+
press: (e: any) => void;
|
|
272
|
+
storage: Storage;
|
|
273
|
+
upgrade: () => void;
|
|
274
|
+
menu?: ReactNode;
|
|
275
|
+
more: (e: any) => void;
|
|
276
|
+
children: ReactNode;
|
|
277
|
+
}
|
|
278
|
+
declare const Brand: ({ icon, color, label, click }: BrandProps) => import("react").JSX.Element;
|
|
279
|
+
declare const Storage_: ({ storage, upgrade, menu, more }: Pick<SideProps, 'storage' | 'upgrade' | 'menu' | 'more'>) => import("react").JSX.Element;
|
|
280
|
+
declare const Side: ({ brand, bar, drawer, fold, close, press, storage, upgrade, menu, more, children }: SideProps) => import("react").JSX.Element;
|
|
281
|
+
//#endregion
|
|
476
282
|
//#region src/client/ui/drive/types.d.ts
|
|
477
283
|
interface Obj {
|
|
478
284
|
path: string;
|
|
@@ -500,7 +306,7 @@ interface DriveConfig {
|
|
|
500
306
|
editors: string[];
|
|
501
307
|
}
|
|
502
308
|
//#endregion
|
|
503
|
-
//#region src/client/ui/shell/tree.d.ts
|
|
309
|
+
//#region src/client/ui/shell/atoms/tree.d.ts
|
|
504
310
|
interface TreeProps {
|
|
505
311
|
files: Entry[];
|
|
506
312
|
parent: string;
|
|
@@ -520,17 +326,25 @@ interface TreeProps {
|
|
|
520
326
|
}
|
|
521
327
|
declare const DriveTree: (props: TreeProps) => any;
|
|
522
328
|
//#endregion
|
|
329
|
+
//#region src/client/ui/shell/atoms.d.ts
|
|
330
|
+
declare const drawerAtom: {
|
|
331
|
+
value: boolean;
|
|
332
|
+
listeners: Set<(v: boolean) => void>;
|
|
333
|
+
};
|
|
334
|
+
declare const pointAtom: {
|
|
335
|
+
value: Point | null;
|
|
336
|
+
listeners: Set<(v: Point | null) => void>;
|
|
337
|
+
};
|
|
338
|
+
declare const isDrawerOpen: () => boolean;
|
|
339
|
+
declare const useDrawer: () => boolean;
|
|
340
|
+
declare const usePoint: () => Point | null;
|
|
341
|
+
//#endregion
|
|
523
342
|
//#region src/client/ui/shell/clicks.d.ts
|
|
524
343
|
declare const openDrawer: (e: any) => void;
|
|
525
344
|
declare const closeDrawer: () => void;
|
|
526
345
|
declare const atPoint: (e: any) => void;
|
|
527
346
|
declare const noPoint: () => void;
|
|
528
347
|
//#endregion
|
|
529
|
-
//#region src/client/ui/shell/state.d.ts
|
|
530
|
-
declare const isDrawerOpen: () => boolean;
|
|
531
|
-
declare const useDrawer: () => boolean;
|
|
532
|
-
declare const usePoint: () => Point | null;
|
|
533
|
-
//#endregion
|
|
534
348
|
//#region src/client/ui/shell/const.d.ts
|
|
535
349
|
declare const storageName = "STORAGE";
|
|
536
350
|
declare const upgradeLabel = "アップグレード";
|
|
@@ -539,6 +353,7 @@ declare const emptyTrashAsk = "ゴミ箱を空にしますか?中のアイテ
|
|
|
539
353
|
declare const storageMenu: Item[];
|
|
540
354
|
declare const pageMenu: Item[];
|
|
541
355
|
declare const spMenu: Item[];
|
|
356
|
+
declare const bandIcon: string;
|
|
542
357
|
declare const moreItems: (on: boolean, label: string, items: Item[]) => Item[];
|
|
543
358
|
//#endregion
|
|
544
359
|
//#region src/client/ui/shell/icons.d.ts
|
|
@@ -648,4 +463,194 @@ declare const renameFile: ({ id, name }: {
|
|
|
648
463
|
declare const emptyTrash: (_input: any, ai: any) => Promise<string>;
|
|
649
464
|
declare const usedBytes: (ai: any) => number;
|
|
650
465
|
//#endregion
|
|
651
|
-
|
|
466
|
+
//#region src/client/ui/chat/client.d.ts
|
|
467
|
+
declare const AiChatButton: () => import("react").JSX.Element;
|
|
468
|
+
declare const AiChat: () => import("react").JSX.Element | null;
|
|
469
|
+
//#endregion
|
|
470
|
+
//#region src/client/ui/chat/clicks.d.ts
|
|
471
|
+
declare const openChat: () => void;
|
|
472
|
+
declare const closeChat: () => void;
|
|
473
|
+
declare const toggleChat: () => void;
|
|
474
|
+
//#endregion
|
|
475
|
+
//#region src/client/ui/chat/types.d.ts
|
|
476
|
+
interface ChatTool {
|
|
477
|
+
icon?: string;
|
|
478
|
+
label: string;
|
|
479
|
+
}
|
|
480
|
+
interface ChatMsg {
|
|
481
|
+
role: 'agent' | 'user';
|
|
482
|
+
text: string;
|
|
483
|
+
tools?: ChatTool[];
|
|
484
|
+
}
|
|
485
|
+
interface ChatPrompt {
|
|
486
|
+
icon?: string;
|
|
487
|
+
color?: string;
|
|
488
|
+
label: string;
|
|
489
|
+
prompt?: string;
|
|
490
|
+
}
|
|
491
|
+
interface ChatHello {
|
|
492
|
+
greet: string;
|
|
493
|
+
title: string;
|
|
494
|
+
desc: string;
|
|
495
|
+
prompts: ChatPrompt[];
|
|
496
|
+
}
|
|
497
|
+
interface ChatMenu {
|
|
498
|
+
useOpen: () => string;
|
|
499
|
+
flip: (id: string) => (e: any) => void;
|
|
500
|
+
close: () => void;
|
|
501
|
+
}
|
|
502
|
+
interface ChatCommand {
|
|
503
|
+
name: string;
|
|
504
|
+
desc: string;
|
|
505
|
+
label?: string;
|
|
506
|
+
run: () => any;
|
|
507
|
+
}
|
|
508
|
+
interface ChatStreamTool {
|
|
509
|
+
server: string;
|
|
510
|
+
name: string;
|
|
511
|
+
}
|
|
512
|
+
interface ChatStreamItem {
|
|
513
|
+
text: string;
|
|
514
|
+
tools: ChatStreamTool[];
|
|
515
|
+
error?: boolean;
|
|
516
|
+
}
|
|
517
|
+
interface ChatStreamSend {
|
|
518
|
+
prompt: string;
|
|
519
|
+
path?: string;
|
|
520
|
+
model?: string;
|
|
521
|
+
messages?: any[];
|
|
522
|
+
headers?: Record<string, string>;
|
|
523
|
+
}
|
|
524
|
+
interface ChatStreamUpdate {
|
|
525
|
+
items: ChatStreamItem[];
|
|
526
|
+
delta: string;
|
|
527
|
+
raw: string;
|
|
528
|
+
}
|
|
529
|
+
interface ChatStream {
|
|
530
|
+
parse: (raw: string) => ChatStreamItem[];
|
|
531
|
+
send: (input: ChatStreamSend, update?: (u: ChatStreamUpdate) => void) => Promise<ChatStreamItem[]>;
|
|
532
|
+
}
|
|
533
|
+
interface ChatConfig {
|
|
534
|
+
send: (input: {
|
|
535
|
+
prompt: string;
|
|
536
|
+
}) => Promise<string>;
|
|
537
|
+
stream: ChatStream;
|
|
538
|
+
icon: string;
|
|
539
|
+
path: string;
|
|
540
|
+
headers: Record<string, string>;
|
|
541
|
+
hello: () => ChatHello;
|
|
542
|
+
menu: ChatMenu;
|
|
543
|
+
commands: () => ChatCommand[];
|
|
544
|
+
hints: (msgs: ChatMsg[]) => ChatCommand[];
|
|
545
|
+
}
|
|
546
|
+
//#endregion
|
|
547
|
+
//#region src/client/ui/chat/config.d.ts
|
|
548
|
+
declare const config: ChatConfig;
|
|
549
|
+
declare const configure: (next: Partial<ChatConfig>) => undefined;
|
|
550
|
+
//#endregion
|
|
551
|
+
//#region src/client/ui/chat/stream.d.ts
|
|
552
|
+
declare const toMsg: (it: ChatStreamItem) => ChatMsg;
|
|
553
|
+
declare const restoreChat: (talks: {
|
|
554
|
+
prompt: string;
|
|
555
|
+
reply: string;
|
|
556
|
+
tools: string[];
|
|
557
|
+
}[]) => void;
|
|
558
|
+
declare const runChat: (prompt: string) => Promise<string>;
|
|
559
|
+
//#endregion
|
|
560
|
+
//#region src/client/ui/chat/utils/commands/types.d.ts
|
|
561
|
+
interface Command {
|
|
562
|
+
name: string;
|
|
563
|
+
desc: string;
|
|
564
|
+
label?: string;
|
|
565
|
+
run: () => any;
|
|
566
|
+
}
|
|
567
|
+
interface Habit {
|
|
568
|
+
name: string;
|
|
569
|
+
part: number;
|
|
570
|
+
after: string;
|
|
571
|
+
count: number;
|
|
572
|
+
}
|
|
573
|
+
interface CommandConfig {
|
|
574
|
+
store: {
|
|
575
|
+
list: () => Promise<Habit[]>;
|
|
576
|
+
save: (habit: {
|
|
577
|
+
name: string;
|
|
578
|
+
part: number;
|
|
579
|
+
after: string;
|
|
580
|
+
}) => any;
|
|
581
|
+
};
|
|
582
|
+
deck: Command[];
|
|
583
|
+
greet: {
|
|
584
|
+
greet: string;
|
|
585
|
+
title: string;
|
|
586
|
+
desc: string;
|
|
587
|
+
};
|
|
588
|
+
starters: () => string[];
|
|
589
|
+
pinned: () => string[];
|
|
590
|
+
hinted: (msgs: any[]) => string[];
|
|
591
|
+
}
|
|
592
|
+
//#endregion
|
|
593
|
+
//#region src/client/ui/chat/utils/commands/index.d.ts
|
|
594
|
+
declare const createCommands: (config: CommandConfig) => {
|
|
595
|
+
commands: () => Command[];
|
|
596
|
+
hello: () => {
|
|
597
|
+
greet: string;
|
|
598
|
+
title: string;
|
|
599
|
+
desc: string;
|
|
600
|
+
prompts: {
|
|
601
|
+
label: string;
|
|
602
|
+
prompt: string;
|
|
603
|
+
}[];
|
|
604
|
+
};
|
|
605
|
+
hints: (msgs: any[]) => Command[];
|
|
606
|
+
prime: () => Promise<void>;
|
|
607
|
+
};
|
|
608
|
+
//#endregion
|
|
609
|
+
//#region src/client/ui/chat/utils/history/types.d.ts
|
|
610
|
+
interface HistoryTalk {
|
|
611
|
+
prompt: string;
|
|
612
|
+
reply: string;
|
|
613
|
+
tools: string[];
|
|
614
|
+
}
|
|
615
|
+
interface HistoryStore {
|
|
616
|
+
list: () => Promise<any[]>;
|
|
617
|
+
load: (chatId: string) => Promise<{
|
|
618
|
+
talks: any[];
|
|
619
|
+
tools: any[];
|
|
620
|
+
}>;
|
|
621
|
+
save: (chatId: string, body: any) => any;
|
|
622
|
+
}
|
|
623
|
+
interface HistoryConfig {
|
|
624
|
+
store: HistoryStore;
|
|
625
|
+
show: (talks: HistoryTalk[]) => void;
|
|
626
|
+
}
|
|
627
|
+
//#endregion
|
|
628
|
+
//#region src/client/ui/chat/utils/history/index.d.ts
|
|
629
|
+
declare const createHistory: (config: HistoryConfig) => {
|
|
630
|
+
wrap: <T extends {
|
|
631
|
+
send: any;
|
|
632
|
+
}>(base: T) => T;
|
|
633
|
+
reset: () => void;
|
|
634
|
+
load: (id: string) => Promise<void>;
|
|
635
|
+
list: () => Promise<any[]>;
|
|
636
|
+
};
|
|
637
|
+
type History = ReturnType<typeof createHistory>;
|
|
638
|
+
//#endregion
|
|
639
|
+
//#region src/client/ui/chat/utils/markdown.d.ts
|
|
640
|
+
declare const markdown: {
|
|
641
|
+
render: (text: string) => string;
|
|
642
|
+
plain: (text: string) => string;
|
|
643
|
+
};
|
|
644
|
+
//#endregion
|
|
645
|
+
//#region src/client/ui/chat/atoms.d.ts
|
|
646
|
+
declare const isChatBusy: () => boolean;
|
|
647
|
+
declare const useChatBusy: () => boolean;
|
|
648
|
+
//#endregion
|
|
649
|
+
//#region src/client/ui/chat/const.d.ts
|
|
650
|
+
declare const models: {
|
|
651
|
+
id: string;
|
|
652
|
+
label: string;
|
|
653
|
+
desc: string;
|
|
654
|
+
}[];
|
|
655
|
+
//#endregion
|
|
656
|
+
export { AiChat, AiChatButton, AppProps, Band, BandProps, Brand, BrandProps, CardItem, Cards, type ChatCommand, type ChatConfig, type ChatHello, type ChatMsg, type ChatPrompt, type ChatTool, type Command, type CommandConfig, type DragState, type DriveConfig, DriveTree, Drop, type DropState, type Dropped, type Entry, Fold, Frame, GB, type Grab, type Habit, HeadBtn, type History, type HistoryConfig, type HistoryStore, type HistoryTalk, Icon, type Item, KB, MB, Main, MainHead, MainHeadProps, MoreIcon, type Obj, type Over, type PlaceInput, type Placed, type Point, Pop, Row, RowProps, SP_BREAK, type Service, Side, SideProps, type Skip, Slot, SpBtn, SpHead, SpHeadProps, type Storage, Storage_, Strip, TreeProps, ago, ancestors, atPoint, band, bandIcon, blue, config as chatConfig, closeChat, closeDrawer, configure as configureChat, configure$1 as configureDrive, createCommands, createFileDrag, createFileDrop, createHistory, createOver, crumbSegs, dragEvent, drawerAtom, config$1 as driveConfig, dropEvent, edge, emptyTrash, emptyTrashAsk, entryOf, extOf, fill, folderRows, freeName, grid, icons, idOf, ink, isChatBusy, isDrawerOpen, isFolder, kindOf, kindRows, line, markdown, mirrorFile, mkdirp, models, moreItems, moveFile, mute, noPoint, openChat, openDrawer, pageMenu, pale, parentOf, pathname, place, pointAtom, prev, quota, r2, recentRows, removeFile, renameFile, restoreChat, restoreFile, rowCls, runChat, saveFile, side, sizeOf, spMenu, stamp, stop, storageMenu, storageName, storageRows, storeFiles, syncFiles, toMsg, toggleChat, trashRows, treeOf, unique, upgradeLabel, upgradeUrl, uploadAlert, uploadMax, url, usageOf, useChatBusy, useDrawer, usePoint, usedBytes, usedOf, vec2 };
|
package/dist/client/ui.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{atom as e,setAtom as t,useAtomValue as n}from"./react.js";import{useEffect as r,useLayoutEffect as i,useRef as a,useState as o}from"react";import{Fragment as s,jsx as c,jsxs as l}from"react/jsx-runtime";import u from"@material-symbols/svg-400/outlined/support_agent.svg?raw";import d from"@material-symbols/svg-400/outlined/drag_indicator.svg?raw";import f,{default as p}from"@material-symbols/svg-400/outlined/close.svg?raw";import m,{default as h}from"@material-symbols/svg-400/outlined/search.svg?raw";import ee from"@material-symbols/svg-400/outlined/mic.svg?raw";import te from"@material-symbols/svg-400/outlined/send.svg?raw";import ne from"@material-symbols/svg-400/outlined/stop_circle.svg?raw";import re from"@material-symbols/svg-400/outlined/graphic_eq.svg?raw";import ie from"@material-symbols/svg-400/outlined/attach_file_add.svg?raw";import ae from"@material-symbols/svg-400/outlined/keyboard_arrow_down.svg?raw";import oe from"@material-symbols/svg-400/outlined/more_horiz.svg?raw";import se,{default as ce}from"@material-symbols/svg-400/outlined/check.svg?raw";import le from"markdown-it";import ue from"@material-symbols/svg-400/outlined/add.svg?raw";import de from"@material-symbols/svg-400/outlined/arrow_back.svg?raw";import fe from"@material-symbols/svg-400/outlined/arrow_drop_down.svg?raw";import pe from"@material-symbols/svg-400/outlined/chevron_right.svg?raw";import me from"@material-symbols/svg-400/outlined/cloud.svg?raw";import he from"@material-symbols/svg-400/outlined/delete.svg?raw";import ge from"@material-symbols/svg-400/outlined/folder.svg?raw";import _e from"@material-symbols/svg-400/outlined/home.svg?raw";import ve from"@material-symbols/svg-400/outlined/keep.svg?raw";import ye from"@material-symbols/svg-400/outlined/keep-fill.svg?raw";import be from"@material-symbols/svg-400/outlined/left_panel_close.svg?raw";import xe from"@material-symbols/svg-400/outlined/left_panel_open.svg?raw";import Se from"@material-symbols/svg-400/outlined/menu.svg?raw";import Ce from"@material-symbols/svg-400/outlined/more_vert.svg?raw";import we from"@material-symbols/svg-400/outlined/redo.svg?raw";import Te from"@material-symbols/svg-400/outlined/schedule.svg?raw";import Ee from"@material-symbols/svg-400/outlined/settings.svg?raw";import De from"@material-symbols/svg-400/outlined/help.svg?raw";import Oe from"@material-symbols/svg-400/outlined/keyboard.svg?raw";import ke from"@material-symbols/svg-400/outlined/sync.svg?raw";import Ae from"@material-symbols/svg-400/outlined/undo.svg?raw";import je from"@material-symbols/svg-400/outlined/unfold_more.svg?raw";import Me from"@material-symbols/svg-400/outlined/visibility_off.svg?raw";import Ne from"@material-symbols/svg-400/outlined/create_new_folder.svg?raw";import Pe from"@material-symbols/svg-400/outlined/upload_file.svg?raw";import Fe from"@material-symbols/svg-400/outlined/drive_folder_upload.svg?raw";import Ie from"@material-symbols/svg-400/outlined/edit.svg?raw";import Le from"@material-symbols/svg-400/outlined/download.svg?raw";import Re from"@material-symbols/svg-400/outlined/info.svg?raw";import ze from"@material-symbols/svg-400/outlined/open_in_new.svg?raw";import Be from"@material-symbols/svg-400/outlined/restore_from_trash.svg?raw";import Ve from"@material-symbols/svg-400/outlined/description.svg?raw";const g=({name:e,size:t=20,color:n,className:r=``})=>c(`span`,{className:`inline-block shrink-0 [&>svg]:h-full [&>svg]:w-full [&>svg]:fill-current ${r}`,style:{width:t,height:t,color:n},dangerouslySetInnerHTML:{__html:e}}),He=e=>e.stopPropagation(),Ue=e=>e.preventDefault(),We=({show:e,children:t})=>e?c(s,{children:t}):null,Ge=(e,t,n={})=>{let{align:r=`right`,point:i=null,gap:a=4,margin:o=8}=n,s=e?.getBoundingClientRect(),c=t?.getBoundingClientRect(),l=i?{left:i.x,right:i.x,top:i.y,bottom:i.y}:s;if(!l||!c)return null;let u=window.innerWidth,d=window.innerHeight,f=Math.min(c.height,d-o*2),p=i||r===`left`?l.left:l.right-c.width,m=Math.min(Math.max(o,p),Math.max(o,u-c.width-o)),h=l.bottom+a;return{x:m,y:h+f>d-o?Math.max(o,l.top-f-a):h,h:f}},Ke=({m:e,value:t,check:n})=>l(s,{children:[l(`span`,{className:`flex min-w-0 flex-1 flex-col items-start`,children:[c(`span`,{className:`truncate`,children:e.label}),c(`span`,{className:`truncate text-[12px] text-mute`,children:e.desc})]}),t===e.id&&c(g,{name:n,size:18,color:`#4185f4`})]}),qe=({m:e,value:t,check:n})=>l(s,{children:[t===e.id&&c(g,{name:n,size:18}),t!==e.id&&e.icon&&c(g,{name:e.icon,size:18,color:e.color,className:e.color?``:`text-mute`}),t!==e.id&&!e.icon&&c(`span`,{className:`w-[18px] shrink-0`}),c(`span`,{className:`truncate`,children:e.label})]}),Je=({cls:e,items:t,value:n,pick:r,style:i,check:a})=>c(`div`,{className:`absolute z-50 rounded-xl border border-line bg-white py-2 shadow-[0_8px_24px_rgba(0,0,0,0.12)] ${e}`,style:i,onClick:He,children:t.map(e=>c(`div`,{className:e.top?`mt-2 border-t border-line pt-2`:``,children:c(`button`,{onClick:()=>r(e),className:`flex w-full items-center gap-3 px-4 text-left hover:bg-pale ${e.desc?`py-2`:`h-11`}`,children:e.desc?c(Ke,{m:e,value:n,check:a}):c(qe,{m:e,value:n,check:a})})},e.id))}),Ye=({items:e,value:t,pick:n,align:r=`right`,cls:u=`w-72`,point:d,check:f})=>{let p=a(null),m=a(null),[h,ee]=o(null);return i(()=>ee(Ge(p.current?.parentElement,m.current?.firstElementChild,{align:r,point:d})),[]),l(s,{children:[c(`span`,{ref:p,className:`absolute h-0 w-0`}),c(`div`,{ref:m,className:`fixed z-50`,style:h?{left:h.x,top:h.y}:{left:0,top:0,visibility:`hidden`},children:c(Je,{cls:`left-0 top-0 overflow-y-auto ${u}`,style:{maxHeight:h?.h??window.innerHeight-16},items:e,value:t,pick:n,check:f})})]})},Xe=`#1f1f21`,Ze=`#8b8b8b`,Qe=`#ececec`,$e=`#d9d9d9`,et=`#fafafa`,tt=`#f1f1f1`,nt=`#202020`,rt=`#4185f4`,_={row:36,indent:20,slot:20,icon:20,gap:8,brand:22,width:233},it={card:200,suggest:264},at=15360,ot=104857600,st=`ファイルサイズが大きすぎます (上限 100 MB)`,ct=768,lt=1073741824,ut=1048576,dt=1024,ft=e=>String(e).padStart(2,`0`),pt=e=>{let t=new Date(e),n=new Date;return t.toDateString()===n.toDateString()?`${t.getHours()}:${ft(t.getMinutes())}`:t.getFullYear()===n.getFullYear()?`${t.getMonth()+1}月${t.getDate()}日`:`${t.getFullYear()}/${ft(t.getMonth()+1)}/${ft(t.getDate())}`},mt=e=>e>=1048576?`${(e/ut).toFixed(1)} MB`:e>=1024?`${Math.round(e/dt)} KB`:`${e} B`,ht=e=>e>=1073741824?`${(e/lt).toFixed(2)} GB`:`${Math.round(e/ut)} MB`,gt=e=>{let t=Math.max(0,(Date.now()-new Date(e).getTime())/1e3);return t<60?`たった今`:t<3600?`${Math.floor(t/60)} 分前`:t<86400?`${Math.floor(t/3600)} 時間前`:`${Math.floor(t/86400)} 日前`},_t=(e,t)=>{if(!t.has(e))return e;let n=e.lastIndexOf(`.`),r=n>0?e.slice(0,n):e,i=n>0?e.slice(n):``,a=1;for(;t.has(`${r}(${a})${i}`);)a++;return`${r}(${a})${i}`},vt={position:`fixed`,left:`0`,top:`0`,zIndex:`60`,overflow:`hidden`,pointerEvents:`none`,background:`#fff`,transition:`width 0.16s ease, height 0.16s ease, left 0.16s ease, top 0.16s ease`},yt={width:`100%`,height:`100%`},bt={width:`264px`,height:`62px`,borderRadius:`12px`,boxShadow:`0 8px 24px rgba(0, 0, 0, 0.12)`},xt={display:`flex`,alignItems:`center`,padding:`12px`,border:`1px solid ${$e}`,borderRadius:`12px`,background:`#fff`},v=(e,t)=>Object.assign(e.style,t),St=()=>{let e=null,t=0,n=0;return{start(r,i,a){if(!r||e)return;let o=r.getBoundingClientRect(),s=r.cloneNode(!0);t=i??o.left,n=a??o.top,e=document.createElement(`div`),v(e,vt),v(s,yt),e.appendChild(s),e.style.left=`${o.left}px`,e.style.top=`${o.top}px`,e.style.width=`${o.width}px`,e.style.height=`${o.height}px`,document.body.appendChild(e),requestAnimationFrame(()=>{e&&(v(e,bt),v(s,xt),s.querySelectorAll(`[data-ghost-hide]`).forEach(e=>v(e,{display:`none`})),e.style.left=`${t}px`,e.style.top=`${n}px`)})},move(r,i){e&&(e.style.transform=`translate(${r-t}px, ${i-n}px)`)},end(){e?.remove(),e=null}}},Ct=(e,t)=>{let n=e.getAttribute(`data-drop-from`);return n===null||n.split(` `).includes(t)},wt=(e,t,n,r)=>{let i=document.elementFromPoint(e,t),a=i?.closest(`[data-drop]`),o=a?.getAttribute(`data-drop`);return!i||!a||typeof o!=`string`||!Ct(a,n)||r(i,o)?null:a},Tt=e=>{let t=e.closest(`[data-drop-scope]`)??document,n=Array.from(t.querySelectorAll(`[data-drop-mark="${CSS.escape(e.getAttribute(`data-drop`))}"]`));return n.length>0?n:e.hasAttribute(`data-drop-scope`)?[]:[e]},Et=[`outline-2`,`-outline-offset-2`,`rounded-lg`,`outline-ink`],Dt=()=>{let e=``,t=()=>!1,n=null,r=[];return{begin(n,r=()=>!1){e=n,t=r},move(i,a){let o=wt(i,a,e,t);o!==n&&(r.forEach(e=>e.classList.remove(...Et)),n=o,r=o?Tt(o):[],r.forEach(e=>e.classList.add(...Et)))},read(){return n?.getAttribute(`data-drop`)??null},end(){r.forEach(e=>e.classList.remove(...Et)),r=[],n=null}}},Ot=typeof Float32Array<`u`?Float32Array:Array,y=(e=0,t=0,n=new Ot(2))=>(n[0]=e,n[1]=t,n),kt=(e,t,n=y())=>(n[0]=e[0]+t[0],n[1]=e[1]+t[1],n),At=(e,t,n=y())=>(n[0]=e[0]-t[0],n[1]=e[1]-t[1],n),jt=(e,t=y())=>(t[0]=e[0],t[1]=e[1],t),b=typeof window<`u`&&!!window.document&&!!window.document.createElement,Mt=()=>b&&`ontouchstart`in window,Nt=()=>Mt()||b&&window.navigator.maxTouchPoints>1,Pt=()=>b&&`onpointerdown`in window,Ft=()=>b&&`exitPointerLock`in window.document,It=()=>{try{return`constructor`in GestureEvent}catch{return!1}},x={isBrowser:b,get gesture(){return x._gesture??=It()},get touch(){return x._touch??=Mt()},get touchscreen(){return x._touchscreen??=Nt()},get pointer(){return x._pointer??=Pt()},get pointerLock(){return x._pointerLock??=Ft()}},Lt=(e=!1)=>e&&x.pointerLock?`mouse`:x.pointer?`pointer`:x.touch?`touch`:`mouse`,Rt=(e,t,n)=>{if(t!==`touch`)return y(e.clientX,e.clientY,n);let[r]=e.changedTouches;return y(r.clientX,r.clientY,n)},zt={touch:{start:`touchstart`,move:`touchmove`,end:`touchend`,up:`touchcancel`},pointer:{start:`pointerdown`,move:`pointermove`,end:`pointerup`,up:`pointercancel`},mouse:{start:`mousedown`,move:`mousemove`,end:`mouseup`,up:`mousecancel`}};let S=null;const Bt=(e,t=()=>!0)=>{let n=()=>{y(0,0,r.value),y(0,0,r._value),y(0,0,r.delta),y(0,0,r.movement)},r={_active:!1,active:!1,pointerId:null,device:Lt(),_value:y(0,0),value:y(0,0),delta:y(0,0),offset:y(0,0),movement:y(0,0),target:null,event:null,memo:{},isDragStart:!1,isDragging:!1,isDragEnd:!1,drag:()=>{let t=r._active;r.isDragStart=r.active&&!t,r.isDragging=r.active&&t,r.isDragEnd=!r.active&&t,e?.(),r._active=r.active},dragStart:e=>{r.active||S&&S!==r||t(e)&&(e.stopPropagation(),S=r,r.pointerId=e.pointerId??null,r.event=e,r._active=!1,r.active=!0,n(),Rt(e,r.device,r.value),r.target.setPointerCapture&&`pointerId`in e&&r.target.setPointerCapture(e.pointerId),r.drag(r))},dragging:e=>{r.event=e,!(r.active&&r.pointerId!==null&&e.pointerId!==r.pointerId)&&(r.active&&e.cancelable&&e.preventDefault(),r.active&&e.stopPropagation(),jt(r.value,r._value),Rt(e,r.device,r.value),r.active&&(At(r.value,r._value,r.delta),kt(r.offset,r.delta,r.offset),kt(r.movement,r.delta,r.movement)),r.drag(r))},dragEnd:e=>{r.active&&r.pointerId!==null&&e.pointerId!==r.pointerId||(S===r&&(S=null),r.event=e,r.active=!1,n(),r.pointerId=null,r.target.releasePointerCapture&&`pointerId`in e&&r.target.releasePointerCapture(e.pointerId),r.drag(r))},mount:e=>{r.target=e;let{start:t,move:n,end:i,up:a}=zt[r.device];e.addEventListener(t,r.dragStart),e.addEventListener(n,r.dragging,{passive:!1}),e.addEventListener(i,r.dragEnd),e.addEventListener(a,r.dragEnd)},clean:()=>{let e=r.target;if(!e)return;let{start:t,move:n,end:i,up:a}=zt[r.device];e.removeEventListener(t,r.dragStart),e.removeEventListener(n,r.dragging),e.removeEventListener(i,r.dragEnd),e.removeEventListener(a,r.dragEnd),S===r&&(S=null)},ref:e=>{e?r.mount(e):r.clean(null)}};return r},Vt=[`select-none`,`cursor-grabbing`],Ht=e=>{e.preventDefault(),e.stopPropagation()},Ut=(e,t,n,r,i)=>{let a=()=>{u.memo.moved=!0,navigator.vibrate?.(15),document.body.classList.add(...Vt),n.start(u.target,u.value[0],u.value[1]),r.begin(t,(t,n)=>u.target.contains(t)||n===e||n.startsWith(`${e}/`))},o=()=>{clearTimeout(u.memo.timer),u.memo.moved=!1,u.memo.touch=u.event?.pointerType===`touch`,u.memo.touch&&(u.memo.timer=setTimeout(()=>{u.active&&a()},300))},s=()=>{let e=Math.hypot(u.movement[0],u.movement[1])>8;if(u.memo.touch&&!u.memo.moved){e&&clearTimeout(u.memo.timer);return}!u.memo.moved&&!e||(u.memo.moved||a(),n.move(u.value[0],u.value[1]),r.move(u.value[0],u.value[1]))},c=()=>{let e=u.memo.moved?r.read():null;r.end(),n.end(),document.body.classList.remove(...Vt),u.memo.moved&&(window.addEventListener(`click`,Ht,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener(`click`,Ht,{capture:!0}),0)),e!==null&&i(e)},l=e=>{if(u.active){if(e.type===`contextmenu`&&u.memo.touch)return Ht(e);u.memo.moved&&e.preventDefault()}},u=Bt(()=>{u.isDragStart&&o(),u.isDragging&&s(),u.isDragEnd&&c()},e=>e.button===0&&!e.target?.closest?.(`button, a, input, label`));return e=>{if(!e){clearTimeout(u.memo.timer),u.clean();return}u.mount(e),e.addEventListener(`contextmenu`,l),e.addEventListener(`touchmove`,l,{passive:!1})}},Wt=e=>{let t=St(),n=Dt(),r=new Map;return(i,a=``)=>{let o=`${a}:${i}`;return r.has(o)||r.set(o,Ut(i,a,t,n,t=>e(i,t))),r.get(o)}},Gt={start:`dragenter`,move:`dragover`,leave:`dragleave`,end:`drop`},Kt=(e,t=()=>!0)=>{let n={_active:!1,active:!1,depth:0,value:y(0,0),target:null,event:null,memo:{},isDropStart:!1,isDropping:!1,isDropEnd:!1,drop:()=>{let t=n._active;n.isDropStart=n.active&&!t,n.isDropping=n.active&&t,n.isDropEnd=!n.active&&t,e?.(),n._active=n.active},dropStart:e=>{n.depth++,!n.active&&t(e)&&(e.preventDefault(),n.event=e,n._active=!1,n.active=!0,y(e.clientX,e.clientY,n.value),n.drop(n))},dropping:e=>{n.active&&(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`copy`),n.event=e,y(e.clientX,e.clientY,n.value),n.drop(n))},dropLeave:e=>{n.depth>0&&n.depth--,!(n.depth>0||!n.active)&&(n.event=e,n.active=!1,n.drop(n))},dropEnd:e=>{n.depth=0,n.active&&(e.preventDefault(),n.event=e,n.active=!1,y(e.clientX,e.clientY,n.value),n.drop(n))},mount:e=>{n.target=e;let{start:t,move:r,leave:i,end:a}=Gt;e.addEventListener(t,n.dropStart),e.addEventListener(r,n.dropping),e.addEventListener(i,n.dropLeave),e.addEventListener(a,n.dropEnd)},clean:()=>{let e=n.target;if(!e)return;let{start:t,move:r,leave:i,end:a}=Gt;e.removeEventListener(t,n.dropStart),e.removeEventListener(r,n.dropping),e.removeEventListener(i,n.dropLeave),e.removeEventListener(a,n.dropEnd),n.depth=0,n.active=!1},ref:e=>{if(e)return void n.mount(e);n.clean()}};return n},qt=e=>!!e.dataTransfer?.types.includes(`Files`),Jt=e=>new Promise(t=>e.readEntries(t)),Yt=async e=>{let t=e.createReader(),n=[],r=await Jt(t);for(;r.length>0;)n.push(...r),r=await Jt(t);return n},Xt=e=>new Promise(t=>e.file(t)),Zt=async(e,t,n)=>{let r=t===``?e.name:`${t}/${e.name}`;if(e.isFile)return void n.push({path:r,file:await Xt(e)});n.push({path:r,file:null});for(let t of await Yt(e))await Zt(t,r,n)},Qt=async e=>{let t=Array.from(e?.items??[]).map(e=>e.webkitGetAsEntry()).filter(e=>!!e),n=[];for(let e of t)await Zt(e,``,n);return n},$t=(e,t,n=()=>!0)=>{let r=Dt(),i=()=>r.begin(e,()=>!n()),a=()=>r.move(s.value[0],s.value[1]),o=()=>{let e=s.event.type===`drop`?r.read():null;r.end(),e!==null&&Qt(s.event.dataTransfer).then(n=>t(n,e))},s=Kt(()=>{s.isDropStart&&i(),s.isDropping&&a(),s.isDropEnd&&o()},qt);return s.ref},C={ask:`Ask me anything...`,brand:`Claude`,voice:`音声モード`,file:`ファイル`},w=[{id:`claude-fable-5`,label:`Fable 5`,desc:`最も困難な課題に`},{id:`claude-opus-5`,label:`Opus 5`,desc:`複雑なタスク向け`},{id:`claude-sonnet-5`,label:`Sonnet 5`,desc:`日常のタスクに最適`},{id:`claude-haiku-4-5`,label:`Haiku 4.5`,desc:`素早い回答に最適`}],T={w:376,left:12,top:12,bottom:16,minH:180},E=e(``),D={send:async()=>``,stream:{parse:()=>[],send:async()=>[]},icon:``,path:``,headers:{},hello:()=>({greet:``,title:``,desc:``,prompts:[]}),commands:()=>[],hints:()=>[],menu:{useOpen:()=>n(E),flip:e=>n=>{n.stopPropagation(),t(E,E.value===e?``:e)},close:()=>t(E,``)}},en=e=>void Object.assign(D,e),tn=(e,t=20,n=6)=>{let r=a(null);return i(()=>{let e=r.current;if(!e)return;e.style.height=`${t}px`;let i=Math.max(1,Math.round(e.scrollHeight/t));e.style.height=`${Math.min(i,n)*t}px`},[e]),r},nn=(()=>{let e=new le({linkify:!0,breaks:!0}),t=t=>e.render(t);return{render:t,plain:e=>{let n=document.createElement(`div`);return n.innerHTML=t(e),n.textContent?.trim()??``}}})(),O=e(!1),k=e([]),A=e(``),j=e([0,0]),rn=e(w[0].id),M=e(!1),N=e(!1),P=e(!1);let F=null;const an=()=>{let e=window.SpeechRecognition??window.webkitSpeechRecognition;if(!e)return null;let n=new e;return n.lang=`ja-JP`,n.continuous=!0,n.interimResults=!1,n.onresult=e=>{let n=``;for(let t=e.resultIndex;t<e.results.length;t++)e.results[t].isFinal&&(n+=e.results[t][0].transcript);n!==``&&t(A,A.value+n)},n.onend=()=>t(P,!1),n},on=()=>{if(P.value)return void F?.stop();F??=an(),F&&(F.start(),t(P,!0))};let I=[0,0,28,28];const sn=(e,t,n)=>Math.min(Math.max(e,t),Math.max(t,n)),cn=()=>{let[e,t]=j.value,n=L.target.getBoundingClientRect();I=[n.left-e,n.top-t,n.width,n.height]},ln=()=>{let e=sn(L.offset[0],-I[0],window.innerWidth-I[2]-I[0]),n=sn(L.offset[1],-I[1],window.innerHeight-I[3]-I[1]);y(e,n,L.offset),t(j,[e,n])},L=Bt(()=>{L.isDragStart&&cn(),ln()}),un=()=>{y(0,0,L.offset),t(j,[0,0])},dn=()=>{let e=L.target;!e||!e.isConnected||(cn(),ln())},fn=()=>{r(()=>(dn(),window.addEventListener(`resize`,dn),()=>window.removeEventListener(`resize`,dn)),[])},pn=e=>`calc(max(${T.left}px, 100vw - ${T.w+T.left}px) + ${e}px)`,mn=e=>T.top+e,hn=e=>`max(${T.minH}px, min(calc(100dvh - ${T.top+T.left}px), calc(100dvh - ${T.top+T.bottom+e}px)))`,R=e(null),z=e(0),gn=(e,t)=>{if(t)return t;if(!e.startsWith(`/`))return[];let n=e.slice(1).trim().toLowerCase();return D.commands().filter(e=>e.name.toLowerCase().startsWith(n))},B=()=>{t(R,null),t(z,0)},V=async e=>{t(A,``),B();let n=await e.run();Array.isArray(n)&&t(R,n)},_n=e=>{if(!e.startsWith(`/`))return;let t=e.slice(1).trim().toLowerCase();return D.commands().find(e=>e.name.toLowerCase()===t)??gn(e,null)[0]},vn=e=>{if(e.nativeEvent?.isComposing)return!1;let n=gn(A.value,R.value);if(n.length===0)return!1;let r=z.value%n.length;return e.key===`ArrowDown`?(e.preventDefault(),t(z,(r+1)%n.length),!0):e.key===`ArrowUp`?(e.preventDefault(),t(z,(r-1+n.length)%n.length),!0):e.key===`Escape`?(e.preventDefault(),t(A,``),B(),!0):e.key===`Enter`&&(e.preventDefault(),V(n[r]),!0)},yn=(()=>{let e=e=>e.replace(/[^0-9A-Za-zぁ-んァ-ヴー一-龠々\s]/g,` `).replace(/\s+/g,` `).trim(),t=e=>{let t=document.createElement(`div`);return t.innerHTML=nn.render(e),t.querySelectorAll(`pre`).forEach(e=>e.remove()),t.textContent??``};return{lines:n=>t(n).split(`
|
|
2
|
-
`).map(e).filter(e=>e!==``)}})();let
|
|
1
|
+
import{atom as e,setAtom as t,useAtomValue as n}from"./react.js";import{useEffect as r,useLayoutEffect as i,useRef as a,useState as o}from"react";import{Fragment as s,jsx as c,jsxs as l}from"react/jsx-runtime";import u from"@material-symbols/svg-400/outlined/add.svg?raw";import d from"@material-symbols/svg-400/outlined/arrow_back.svg?raw";import f from"@material-symbols/svg-400/outlined/arrow_drop_down.svg?raw";import p,{default as m}from"@material-symbols/svg-400/outlined/check.svg?raw";import h from"@material-symbols/svg-400/outlined/chevron_right.svg?raw";import g,{default as ee}from"@material-symbols/svg-400/outlined/close.svg?raw";import te from"@material-symbols/svg-400/outlined/cloud.svg?raw";import ne from"@material-symbols/svg-400/outlined/delete.svg?raw";import re from"@material-symbols/svg-400/outlined/folder.svg?raw";import ie from"@material-symbols/svg-400/outlined/home.svg?raw";import ae from"@material-symbols/svg-400/outlined/keep.svg?raw";import oe from"@material-symbols/svg-400/outlined/keep-fill.svg?raw";import se from"@material-symbols/svg-400/outlined/left_panel_close.svg?raw";import ce from"@material-symbols/svg-400/outlined/left_panel_open.svg?raw";import le from"@material-symbols/svg-400/outlined/menu.svg?raw";import ue from"@material-symbols/svg-400/outlined/more_vert.svg?raw";import de from"@material-symbols/svg-400/outlined/redo.svg?raw";import fe from"@material-symbols/svg-400/outlined/schedule.svg?raw";import pe,{default as me}from"@material-symbols/svg-400/outlined/search.svg?raw";import he from"@material-symbols/svg-400/outlined/settings.svg?raw";import ge from"@material-symbols/svg-400/outlined/help.svg?raw";import _e from"@material-symbols/svg-400/outlined/keyboard.svg?raw";import ve from"@material-symbols/svg-400/outlined/sync.svg?raw";import ye from"@material-symbols/svg-400/outlined/undo.svg?raw";import be from"@material-symbols/svg-400/outlined/unfold_more.svg?raw";import xe from"@material-symbols/svg-400/outlined/visibility_off.svg?raw";import Se from"@material-symbols/svg-400/outlined/create_new_folder.svg?raw";import Ce from"@material-symbols/svg-400/outlined/upload_file.svg?raw";import we from"@material-symbols/svg-400/outlined/drive_folder_upload.svg?raw";import Te from"@material-symbols/svg-400/outlined/edit.svg?raw";import Ee from"@material-symbols/svg-400/outlined/download.svg?raw";import De from"@material-symbols/svg-400/outlined/info.svg?raw";import Oe from"@material-symbols/svg-400/outlined/open_in_new.svg?raw";import ke from"@material-symbols/svg-400/outlined/restore_from_trash.svg?raw";import Ae from"@material-symbols/svg-400/outlined/description.svg?raw";import je from"@material-symbols/svg-400/outlined/support_agent.svg?raw";import Me from"@material-symbols/svg-400/outlined/drag_indicator.svg?raw";import Ne from"@material-symbols/svg-400/outlined/mic.svg?raw";import Pe from"@material-symbols/svg-400/outlined/send.svg?raw";import Fe from"@material-symbols/svg-400/outlined/stop_circle.svg?raw";import Ie from"@material-symbols/svg-400/outlined/graphic_eq.svg?raw";import Le from"@material-symbols/svg-400/outlined/attach_file_add.svg?raw";import Re from"@material-symbols/svg-400/outlined/keyboard_arrow_down.svg?raw";import ze from"@material-symbols/svg-400/outlined/more_horiz.svg?raw";import Be from"markdown-it";const _=({name:e,size:t=20,color:n,className:r=``})=>c(`span`,{className:`inline-block shrink-0 [&>svg]:h-full [&>svg]:w-full [&>svg]:fill-current ${r}`,style:{width:t,height:t,color:n},dangerouslySetInnerHTML:{__html:e}}),Ve=e=>e.stopPropagation(),He=e=>e.preventDefault(),Ue=({show:e,children:t})=>e?c(s,{children:t}):null,We=(e,t,n={})=>{let{align:r=`right`,point:i=null,gap:a=4,margin:o=8}=n,s=e?.getBoundingClientRect(),c=t?.getBoundingClientRect(),l=i?{left:i.x,right:i.x,top:i.y,bottom:i.y}:s;if(!l||!c)return null;let u=window.innerWidth,d=window.innerHeight,f=Math.min(c.height,d-o*2),p=i||r===`left`?l.left:l.right-c.width,m=Math.min(Math.max(o,p),Math.max(o,u-c.width-o)),h=l.bottom+a;return{x:m,y:h+f>d-o?Math.max(o,l.top-f-a):h,h:f}},Ge=({m:e,value:t,check:n})=>l(s,{children:[l(`span`,{className:`flex min-w-0 flex-1 flex-col items-start`,children:[c(`span`,{className:`truncate`,children:e.label}),c(`span`,{className:`truncate text-[12px] text-mute`,children:e.desc})]}),t===e.id&&c(_,{name:n,size:18,color:`#4185f4`})]}),Ke=({m:e,value:t,check:n})=>l(s,{children:[t===e.id&&c(_,{name:n,size:18}),t!==e.id&&e.icon&&c(_,{name:e.icon,size:18,color:e.color,className:e.color?``:`text-mute`}),t!==e.id&&!e.icon&&c(`span`,{className:`w-[18px] shrink-0`}),c(`span`,{className:`truncate`,children:e.label})]}),qe=({cls:e=``,items:t=[],value:n,pick:r,style:i,check:a=``,children:o})=>c(`div`,{className:`absolute z-50 rounded-xl border border-line bg-white py-2 shadow-[0_8px_24px_rgba(0,0,0,0.12)] ${e}`,style:i,onClick:Ve,children:o??t.map(e=>c(`div`,{className:e.top?`mt-2 border-t border-line pt-2`:``,children:c(`button`,{onClick:()=>r?.(e),className:`flex w-full items-center gap-3 px-4 text-left hover:bg-pale ${e.desc?`py-2`:`h-11`}`,children:e.desc?c(Ge,{m:e,value:n,check:a}):c(Ke,{m:e,value:n,check:a})})},e.id))}),Je=({items:e,value:t,pick:n,align:r=`right`,cls:u=`w-72`,point:d,check:f,children:p})=>{let m=a(null),h=a(null),[g,ee]=o(null);return i(()=>ee(We(m.current?.parentElement,h.current?.firstElementChild,{align:r,point:d})),[]),l(s,{children:[c(`span`,{ref:m,className:`absolute h-0 w-0`}),c(`div`,{ref:h,className:`fixed z-50`,style:g?{left:g.x,top:g.y}:{left:0,top:0,visibility:`hidden`},children:c(qe,{cls:`left-0 top-0 overflow-y-auto ${u}`,style:{maxHeight:g?.h??window.innerHeight-16},items:e,value:t,pick:n,check:f,children:p})})]})},Ye=`#1f1f21`,Xe=`#8b8b8b`,Ze=`#ececec`,Qe=`#d9d9d9`,$e=`#fafafa`,et=`#f1f1f1`,tt=`#202020`,nt=`#4185f4`,v={row:36,indent:20,slot:20,icon:20,gap:8,brand:22,width:233},rt={card:200,suggest:264},it=15360,at=104857600,ot=`ファイルサイズが大きすぎます (上限 100 MB)`,st=768,ct=1073741824,lt=1048576,ut=1024,dt=e=>String(e).padStart(2,`0`),ft=e=>{let t=new Date(e),n=new Date;return t.toDateString()===n.toDateString()?`${t.getHours()}:${dt(t.getMinutes())}`:t.getFullYear()===n.getFullYear()?`${t.getMonth()+1}月${t.getDate()}日`:`${t.getFullYear()}/${dt(t.getMonth()+1)}/${dt(t.getDate())}`},pt=e=>e>=1048576?`${(e/lt).toFixed(1)} MB`:e>=1024?`${Math.round(e/ut)} KB`:`${e} B`,mt=e=>e>=1073741824?`${(e/ct).toFixed(2)} GB`:`${Math.round(e/lt)} MB`,ht=e=>{let t=Math.max(0,(Date.now()-new Date(e).getTime())/1e3);return t<60?`たった今`:t<3600?`${Math.floor(t/60)} 分前`:t<86400?`${Math.floor(t/3600)} 時間前`:`${Math.floor(t/86400)} 日前`},gt=(e,t)=>{if(!t.has(e))return e;let n=e.lastIndexOf(`.`),r=n>0?e.slice(0,n):e,i=n>0?e.slice(n):``,a=1;for(;t.has(`${r}(${a})${i}`);)a++;return`${r}(${a})${i}`},_t={position:`fixed`,left:`0`,top:`0`,zIndex:`60`,overflow:`hidden`,pointerEvents:`none`,background:`#fff`,transition:`width 0.16s ease, height 0.16s ease, left 0.16s ease, top 0.16s ease`},vt={width:`100%`,height:`100%`},yt={width:`264px`,height:`62px`,borderRadius:`12px`,boxShadow:`0 8px 24px rgba(0, 0, 0, 0.12)`},bt={display:`flex`,alignItems:`center`,padding:`12px`,border:`1px solid ${Qe}`,borderRadius:`12px`,background:`#fff`},y=(e,t)=>Object.assign(e.style,t),xt=()=>{let e=null,t=0,n=0;return{start(r,i,a){if(!r||e)return;let o=r.getBoundingClientRect(),s=r.cloneNode(!0);t=i??o.left,n=a??o.top,e=document.createElement(`div`),y(e,_t),y(s,vt),e.appendChild(s),e.style.left=`${o.left}px`,e.style.top=`${o.top}px`,e.style.width=`${o.width}px`,e.style.height=`${o.height}px`,document.body.appendChild(e),requestAnimationFrame(()=>{e&&(y(e,yt),y(s,bt),s.querySelectorAll(`[data-ghost-hide]`).forEach(e=>y(e,{display:`none`})),e.style.left=`${t}px`,e.style.top=`${n}px`)})},move(r,i){e&&(e.style.transform=`translate(${r-t}px, ${i-n}px)`)},end(){e?.remove(),e=null}}},St=(e,t)=>{let n=e.getAttribute(`data-drop-from`);return n===null||n.split(` `).includes(t)},Ct=(e,t,n,r)=>{let i=document.elementFromPoint(e,t),a=i?.closest(`[data-drop]`),o=a?.getAttribute(`data-drop`);return!i||!a||typeof o!=`string`||!St(a,n)||r(i,o)?null:a},wt=e=>{let t=e.closest(`[data-drop-scope]`)??document,n=Array.from(t.querySelectorAll(`[data-drop-mark="${CSS.escape(e.getAttribute(`data-drop`))}"]`));return n.length>0?n:e.hasAttribute(`data-drop-scope`)?[]:[e]},Tt=[`outline-2`,`-outline-offset-2`,`rounded-lg`,`outline-ink`],Et=()=>{let e=``,t=()=>!1,n=null,r=[];return{begin(n,r=()=>!1){e=n,t=r},move(i,a){let o=Ct(i,a,e,t);o!==n&&(r.forEach(e=>e.classList.remove(...Tt)),n=o,r=o?wt(o):[],r.forEach(e=>e.classList.add(...Tt)))},read(){return n?.getAttribute(`data-drop`)??null},end(){r.forEach(e=>e.classList.remove(...Tt)),r=[],n=null}}},Dt=typeof Float32Array<`u`?Float32Array:Array,b=(e=0,t=0,n=new Dt(2))=>(n[0]=e,n[1]=t,n),Ot=(e,t,n=b())=>(n[0]=e[0]+t[0],n[1]=e[1]+t[1],n),kt=(e,t,n=b())=>(n[0]=e[0]-t[0],n[1]=e[1]-t[1],n),At=(e,t=b())=>(t[0]=e[0],t[1]=e[1],t),x=typeof window<`u`&&!!window.document&&!!window.document.createElement,jt=()=>x&&`ontouchstart`in window,Mt=()=>jt()||x&&window.navigator.maxTouchPoints>1,Nt=()=>x&&`onpointerdown`in window,Pt=()=>x&&`exitPointerLock`in window.document,Ft=()=>{try{return`constructor`in GestureEvent}catch{return!1}},S={isBrowser:x,get gesture(){return S._gesture??=Ft()},get touch(){return S._touch??=jt()},get touchscreen(){return S._touchscreen??=Mt()},get pointer(){return S._pointer??=Nt()},get pointerLock(){return S._pointerLock??=Pt()}},It=(e=!1)=>e&&S.pointerLock?`mouse`:S.pointer?`pointer`:S.touch?`touch`:`mouse`,Lt=(e,t,n)=>{if(t!==`touch`)return b(e.clientX,e.clientY,n);let[r]=e.changedTouches;return b(r.clientX,r.clientY,n)},Rt={touch:{start:`touchstart`,move:`touchmove`,end:`touchend`,up:`touchcancel`},pointer:{start:`pointerdown`,move:`pointermove`,end:`pointerup`,up:`pointercancel`},mouse:{start:`mousedown`,move:`mousemove`,end:`mouseup`,up:`mousecancel`}};let C=null;const zt=(e,t=()=>!0)=>{let n=()=>{b(0,0,r.value),b(0,0,r._value),b(0,0,r.delta),b(0,0,r.movement)},r={_active:!1,active:!1,pointerId:null,device:It(),_value:b(0,0),value:b(0,0),delta:b(0,0),offset:b(0,0),movement:b(0,0),target:null,event:null,memo:{},isDragStart:!1,isDragging:!1,isDragEnd:!1,drag:()=>{let t=r._active;r.isDragStart=r.active&&!t,r.isDragging=r.active&&t,r.isDragEnd=!r.active&&t,e?.(),r._active=r.active},dragStart:e=>{r.active||C&&C!==r||t(e)&&(e.stopPropagation(),C=r,r.pointerId=e.pointerId??null,r.event=e,r._active=!1,r.active=!0,n(),Lt(e,r.device,r.value),r.target.setPointerCapture&&`pointerId`in e&&r.target.setPointerCapture(e.pointerId),r.drag(r))},dragging:e=>{r.event=e,!(r.active&&r.pointerId!==null&&e.pointerId!==r.pointerId)&&(r.active&&e.cancelable&&e.preventDefault(),r.active&&e.stopPropagation(),At(r.value,r._value),Lt(e,r.device,r.value),r.active&&(kt(r.value,r._value,r.delta),Ot(r.offset,r.delta,r.offset),Ot(r.movement,r.delta,r.movement)),r.drag(r))},dragEnd:e=>{r.active&&r.pointerId!==null&&e.pointerId!==r.pointerId||(C===r&&(C=null),r.event=e,r.active=!1,n(),r.pointerId=null,r.target.releasePointerCapture&&`pointerId`in e&&r.target.releasePointerCapture(e.pointerId),r.drag(r))},mount:e=>{r.target=e;let{start:t,move:n,end:i,up:a}=Rt[r.device];e.addEventListener(t,r.dragStart),e.addEventListener(n,r.dragging,{passive:!1}),e.addEventListener(i,r.dragEnd),e.addEventListener(a,r.dragEnd)},clean:()=>{let e=r.target;if(!e)return;let{start:t,move:n,end:i,up:a}=Rt[r.device];e.removeEventListener(t,r.dragStart),e.removeEventListener(n,r.dragging),e.removeEventListener(i,r.dragEnd),e.removeEventListener(a,r.dragEnd),C===r&&(C=null)},ref:e=>{e?r.mount(e):r.clean(null)}};return r},Bt=[`select-none`,`cursor-grabbing`],Vt=e=>{e.preventDefault(),e.stopPropagation()},Ht=(e,t,n,r,i)=>{let a=()=>{u.memo.moved=!0,navigator.vibrate?.(15),document.body.classList.add(...Bt),n.start(u.target,u.value[0],u.value[1]),r.begin(t,(t,n)=>u.target.contains(t)||n===e||n.startsWith(`${e}/`))},o=()=>{clearTimeout(u.memo.timer),u.memo.moved=!1,u.memo.touch=u.event?.pointerType===`touch`,u.memo.touch&&(u.memo.timer=setTimeout(()=>{u.active&&a()},300))},s=()=>{let e=Math.hypot(u.movement[0],u.movement[1])>8;if(u.memo.touch&&!u.memo.moved){e&&clearTimeout(u.memo.timer);return}!u.memo.moved&&!e||(u.memo.moved||a(),n.move(u.value[0],u.value[1]),r.move(u.value[0],u.value[1]))},c=()=>{let e=u.memo.moved?r.read():null;r.end(),n.end(),document.body.classList.remove(...Bt),u.memo.moved&&(window.addEventListener(`click`,Vt,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener(`click`,Vt,{capture:!0}),0)),e!==null&&i(e)},l=e=>{if(u.active){if(e.type===`contextmenu`&&u.memo.touch)return Vt(e);u.memo.moved&&e.preventDefault()}},u=zt(()=>{u.isDragStart&&o(),u.isDragging&&s(),u.isDragEnd&&c()},e=>e.button===0&&!e.target?.closest?.(`button, a, input, label`));return e=>{if(!e){clearTimeout(u.memo.timer),u.clean();return}u.mount(e),e.addEventListener(`contextmenu`,l),e.addEventListener(`touchmove`,l,{passive:!1})}},Ut=e=>{let t=xt(),n=Et(),r=new Map;return(i,a=``)=>{let o=`${a}:${i}`;return r.has(o)||r.set(o,Ht(i,a,t,n,t=>e(i,t))),r.get(o)}},Wt={start:`dragenter`,move:`dragover`,leave:`dragleave`,end:`drop`},Gt=(e,t=()=>!0)=>{let n={_active:!1,active:!1,depth:0,value:b(0,0),target:null,event:null,memo:{},isDropStart:!1,isDropping:!1,isDropEnd:!1,drop:()=>{let t=n._active;n.isDropStart=n.active&&!t,n.isDropping=n.active&&t,n.isDropEnd=!n.active&&t,e?.(),n._active=n.active},dropStart:e=>{n.depth++,!n.active&&t(e)&&(e.preventDefault(),n.event=e,n._active=!1,n.active=!0,b(e.clientX,e.clientY,n.value),n.drop(n))},dropping:e=>{n.active&&(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`copy`),n.event=e,b(e.clientX,e.clientY,n.value),n.drop(n))},dropLeave:e=>{n.depth>0&&n.depth--,!(n.depth>0||!n.active)&&(n.event=e,n.active=!1,n.drop(n))},dropEnd:e=>{n.depth=0,n.active&&(e.preventDefault(),n.event=e,n.active=!1,b(e.clientX,e.clientY,n.value),n.drop(n))},mount:e=>{n.target=e;let{start:t,move:r,leave:i,end:a}=Wt;e.addEventListener(t,n.dropStart),e.addEventListener(r,n.dropping),e.addEventListener(i,n.dropLeave),e.addEventListener(a,n.dropEnd)},clean:()=>{let e=n.target;if(!e)return;let{start:t,move:r,leave:i,end:a}=Wt;e.removeEventListener(t,n.dropStart),e.removeEventListener(r,n.dropping),e.removeEventListener(i,n.dropLeave),e.removeEventListener(a,n.dropEnd),n.depth=0,n.active=!1},ref:e=>{if(e)return void n.mount(e);n.clean()}};return n},Kt=e=>!!e.dataTransfer?.types.includes(`Files`),qt=e=>new Promise(t=>e.readEntries(t)),Jt=async e=>{let t=e.createReader(),n=[],r=await qt(t);for(;r.length>0;)n.push(...r),r=await qt(t);return n},Yt=e=>new Promise(t=>e.file(t)),Xt=async(e,t,n)=>{let r=t===``?e.name:`${t}/${e.name}`;if(e.isFile)return void n.push({path:r,file:await Yt(e)});n.push({path:r,file:null});for(let t of await Jt(e))await Xt(t,r,n)},Zt=async e=>{let t=Array.from(e?.items??[]).map(e=>e.webkitGetAsEntry()).filter(e=>!!e),n=[];for(let e of t)await Xt(e,``,n);return n},Qt=(e,t,n=()=>!0)=>{let r=Et(),i=()=>r.begin(e,()=>!n()),a=()=>r.move(s.value[0],s.value[1]),o=()=>{let e=s.event.type===`drop`?r.read():null;r.end(),e!==null&&Zt(s.event.dataTransfer).then(n=>t(n,e))},s=Gt(()=>{s.isDropStart&&i(),s.isDropping&&a(),s.isDropEnd&&o()},Kt);return s.ref},w={add:u,arrowBack:d,arrowDropDown:f,check:p,chevronRight:h,closeIcon:g,cloud:te,deleteIcon:ne,folder:re,home:ie,keep:ae,keepFill:oe,leftPanelClose:se,leftPanelOpen:ce,menuIcon:le,moreVert:ue,redoIcon:de,schedule:fe,searchIcon:pe,settings:he,help:ge,keyboard:_e,sync:ve,undoIcon:ye,unfoldMore:be,visibilityOff:xe,createNewFolder:Se,uploadFile:Ce,driveFolderUpload:we,edit:Te,download:Ee,info:De,openInNew:Oe,restoreFromTrash:ke,description:Ae},$t=({count:e,min:t,cls:n=``,children:r})=>c(`div`,{className:`grid gap-4 overflow-x-auto ${n}`,style:{gridTemplateColumns:`repeat(${e}, minmax(${t}px, 1fr))`},children:r}),en=({c:e,click:t})=>l(`button`,{onClick:t,className:`relative flex h-full w-full cursor-pointer flex-col items-start rounded-xl border border-edge bg-white p-3 text-left hover:bg-pale`,children:[c(`span`,{className:`flex h-[30px] w-[30px] items-center justify-center rounded-md bg-band`,children:c(_,{name:e.icon??``,size:18,color:e.color})}),c(_,{name:w.add,size:16,className:`absolute right-3 top-3 text-mute`}),c(`span`,{className:`mt-2 w-full truncate text-[14px] leading-[17px]`,children:e.label})]}),tn=({c:e,click:t})=>l(`button`,{onClick:t,className:`flex h-12 w-full cursor-pointer items-center gap-3 rounded-xl border border-edge bg-white px-4 text-left hover:bg-pale`,children:[c(_,{name:e.icon??``,size:18,color:e.color}),c(`span`,{className:`truncate`,children:e.label}),c(_,{name:w.add,size:16,className:`ml-auto shrink-0 text-mute`})]}),nn=({cards:e,click:t,popup:n,count:r=4})=>l(s,{children:[c($t,{count:r,min:rt.card,cls:`hidden md:grid`,children:e.map(e=>l(`div`,{className:`relative`,children:[c(en,{c:e,click:t(e)}),n(e)]},e.id))}),c(`div`,{className:`flex flex-col gap-2 md:hidden`,children:e.map(e=>l(`div`,{className:`relative`,children:[c(tn,{c:e,click:t(e)}),n(e)]},e.id))})]}),rn=e=>c(`section`,{className:`relative shrink-0 px-4 pt-3 md:pl-7 md:pr-9`,children:c(nn,{...e})}),an=`flex h-9 w-9 shrink-0 items-center justify-center rounded-full text-mute hover:bg-band hover:text-ink`,on=`flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-full text-mute hover:bg-band hover:text-ink`,sn=({icon:e,color:t,label:n,home:r,actions:i,drawer:a})=>l(`header`,{className:`fixed inset-x-0 top-0 z-20 flex h-14 items-center gap-1 bg-white pl-4 pr-3 md:hidden`,children:[l(`button`,{onClick:r,className:`flex min-w-0 flex-1 cursor-pointer items-center gap-3`,children:[c(_,{name:e,size:24,color:t}),c(`span`,{className:`truncate text-sm font-bold`,children:n})]}),l(`div`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:[i,c(`button`,{onClick:a,className:an,children:c(_,{name:w.menuIcon,size:22})})]})]}),cn=({bar:e,open:t,title:n,back:r,expand:i,actions:a})=>l(`div`,{className:`mt-2.5 flex h-8 shrink-0 items-center gap-2 px-4 md:pl-7 md:pr-9`,children:[!e&&c(`button`,{onClick:t,className:`${on} hidden md:flex`,children:c(_,{name:w.leftPanelOpen,size:20})}),!r&&c(`h1`,{className:`min-w-0 truncate font-bold`,children:n}),r&&l(`button`,{onClick:r,className:`flex min-w-0 cursor-pointer items-center gap-2 font-bold`,children:[c(_,{name:w.arrowBack,size:20,className:`text-mute`}),c(`span`,{className:`truncate`,children:n})]}),l(`div`,{className:`relative ml-auto flex shrink-0 items-center gap-1`,children:[i&&l(`button`,{onClick:i.click,className:`flex h-8 cursor-pointer items-center gap-1 rounded-lg px-2 hover:bg-band ${i.on?`text-ink`:`text-mute`}`,children:[c(`span`,{className:`hidden md:inline`,children:i.label}),c(_,{name:i.icon||w.unfoldMore,size:18})]}),a]})]}),ln=({icon:e,size:t=20,click:n,children:r})=>l(`span`,{className:`relative hidden md:flex`,children:[c(`button`,{onClick:n,className:on,children:c(_,{name:e,size:t})}),r]}),un=({icon:e,size:t=20,click:n,children:r})=>l(`span`,{className:`relative flex`,children:[c(`button`,{onClick:n,className:an,children:c(_,{name:e,size:t})}),r]}),dn=w.moreVert,fn=({drawer:e,close:t,dropRef:n,children:r})=>l(`div`,{ref:n,onClick:t,className:`flex h-dvh overflow-hidden bg-white font-medium text-ink`,children:[e&&c(`div`,{className:`fixed inset-0 z-30 bg-black/30 md:hidden`,onClick:t}),r]}),pn=({drop:e,from:t,children:n})=>c(`main`,{"data-drop":e,"data-drop-from":t,"data-drop-scope":``,className:`flex min-w-0 flex-1 flex-col overflow-y-auto pt-14 md:pt-0`,children:n}),mn=e=>`flex w-full cursor-pointer items-center rounded-lg text-left text-[14px] text-mute ${e?`bg-band`:`hover:bg-band`}`,hn=({open:e,turn:t})=>t?c(`button`,{onClick:t,className:`flex shrink-0 items-center justify-center`,style:{width:v.slot,height:v.slot},children:c(_,{name:w.chevronRight,size:v.slot,className:e?`rotate-90`:``})}):c(`span`,{className:`shrink-0`,style:{width:v.slot}}),gn=({depth:e=0,on:t=!1,open:n,turn:r,icon:i,color:a,label:o,drop:s,mark:u,from:d,click:f,dclick:p,rclick:m,dragRef:h,children:g})=>l(`div`,{ref:h,"data-drop":s,"data-drop-mark":u,"data-drop-from":d,onClick:e=>(f?.(e),r?.(e)),onDoubleClick:p,onContextMenu:m,className:mn(t),style:{height:v.row,paddingLeft:e*v.indent},children:[c(hn,{open:n,turn:r}),c(_,{name:i,size:v.icon,color:a}),c(`span`,{className:`min-w-0 flex-1 truncate ${t?`text-ink`:``}`,style:{marginLeft:v.gap},children:o}),g]}),_n=`STORAGE`,vn=`アップグレード`,yn=`https://stripe.com`,bn=`ゴミ箱を空にしますか?中のアイテムは完全に削除されます`,xn=[{id:`manage`,icon:w.cloud,label:`保存容量を管理`},{id:`empty`,icon:w.deleteIcon,label:`ゴミ箱を空にする`},{id:`refresh`,icon:w.sync,label:`使用状況を更新`}],Sn=[{id:`undo`,icon:w.undoIcon,label:`直前の操作を元に戻す`},{id:`redo`,icon:w.redoIcon,label:`最後に元に戻した操作をやり直す`},{id:`settings`,icon:w.settings,label:`設定`,top:!0},{id:`help`,icon:w.help,label:`ヘルプ`},{id:`shortcuts`,icon:w.keyboard,label:`キーボードショートカット`}],Cn=Sn.slice(2).map(e=>({...e,top:!1})),wn=w.visibilityOff,Tn=(e,t,n)=>[{id:`band`,icon:wn,label:e?`すべての${t}を非表示`:`すべての${t}を表示`},...n.map((e,t)=>t===0?{...e,top:!0}:e)],En=`flex h-9 w-9 shrink-0 items-center justify-center rounded-full text-mute hover:bg-band hover:text-ink`,Dn=({icon:e,color:t,label:n,click:r})=>l(`button`,{onClick:r,className:`flex min-w-0 flex-1 cursor-pointer items-center gap-3`,children:[c(_,{name:e,size:24,color:t}),c(`span`,{className:`truncate text-sm font-bold`,children:n})]}),On=({storage:e,upgrade:t,menu:n,more:r})=>l(`div`,{className:`relative shrink-0 border-t border-line px-4 pb-4 pt-3`,children:[l(`div`,{className:`flex h-6 items-center gap-2 text-mute`,children:[c(_,{name:w.cloud,size:18}),c(`span`,{className:`tracking-wider`,children:_n}),l(`span`,{className:`relative ml-auto flex`,children:[c(`button`,{onClick:r,className:`flex h-6 w-6 items-center justify-center rounded-full text-mute hover:bg-band`,children:c(_,{name:w.moreVert,size:16})}),n]})]}),c(`div`,{className:`mt-1.5 h-2 overflow-hidden rounded-full bg-line`,children:c(`div`,{className:`h-full rounded-full bg-fill`,style:{width:`${Math.min(100,e.used/e.total*100)}%`}})}),c(`p`,{className:`mt-1.5`,children:e.text}),c(`button`,{onClick:t,className:`mt-2.5 h-9 w-full cursor-pointer rounded-full border border-ink font-bold hover:bg-band`,children:vn})]}),kn=({brand:e,bar:t,drawer:n,fold:r,close:i,press:a,storage:o,upgrade:s,menu:u,more:d,children:f})=>l(`nav`,{"data-drop-scope":``,onClick:a,className:`fixed inset-y-0 left-0 z-40 flex shrink-0 flex-col border-r border-line bg-pale transition-transform md:static md:translate-x-0 ${n?`translate-x-0`:`-translate-x-full`} ${t?``:`md:hidden`}`,style:{width:v.width},children:[l(`div`,{className:`flex h-15 shrink-0 items-center gap-1 pr-2 text-[14px]`,style:{paddingLeft:v.brand},children:[c(Dn,{...e}),c(`button`,{onClick:r,className:`${En} hidden md:flex`,children:c(_,{name:w.leftPanelClose,size:20})}),c(`button`,{onClick:i,className:`${En} md:hidden`,children:c(_,{name:w.leftPanelClose,size:20})})]}),c(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-2 pb-4`,children:f}),c(On,{storage:o,upgrade:s,menu:u,more:d})]}),T={base:`/api/v1/storage`,trash:`.trash`,editors:[]},An=e=>void Object.assign(T,e),E=e=>e.kind.startsWith(`folder`),jn=(e,t)=>e.name.localeCompare(t.name),Mn=(e,t)=>t.iso.localeCompare(e.iso),Nn=(e,t)=>{let n=e.filter(e=>e.parent===t&&!e.trashed);return[...n.filter(E).sort(jn),...n.filter(e=>!E(e)).sort(jn)]},Pn=(e,t)=>e.filter(e=>!e.trashed&&e.kind===t).sort(Mn),Fn=e=>e.filter(e=>!e.trashed&&!E(e)).sort(Mn).slice(0,12),In=e=>e.filter(e=>e.trashed),Ln=e=>e.filter(e=>!e.trashed&&!E(e)).sort((e,t)=>t.bytes-e.bytes),Rn=(e,t)=>e.filter(e=>!e.trashed&&e.parent===t),zn=e=>{let t=e.split(`/`).filter(Boolean);return t.map((e,n)=>({name:n===0&&e===T.trash?`ゴミ箱`:e,path:t.slice(0,n+1).join(`/`)}))},Bn=e=>e.filter(e=>!E(e)).reduce((e,t)=>e+t.bytes,0),Vn=e=>{let{files:t,parent:n,depth:r,expand:i,active:a,kinds:o,fold:u,enter:d,open:f,menu:p,rclick:m,drag:h}=e;return c(s,{children:Nn(t,n).map(t=>{let n=(o[t.kind]??o.file).icon;return E(t)?l(`div`,{children:[c(gn,{depth:r,on:a===t.id,open:i.includes(t.id),turn:u(t.id),icon:o.folder.icon,label:t.name,drop:t.id,mark:t.id,click:d(t.id),rclick:m(t),dragRef:h(t.id,`tree`),children:p(t)}),i.includes(t.id)&&c(Vn,{...e,parent:t.id,depth:r+1})]},t.id):c(gn,{depth:r,icon:n,label:t.name,drop:t.parent,click:d(t.parent),dclick:f(t),rclick:m(t),dragRef:h(t.id,`tree`),children:p(t)},t.id)})})},D=e(!1),O=e(null),Hn=()=>D.value,Un=()=>n(D),Wn=()=>n(O),Gn=e=>{e.stopPropagation(),t(D,!0)},Kn=()=>t(D,!1),qn=e=>t(O,{x:e.clientX,y:e.clientY}),Jn=()=>t(O,null),Yn=e=>e.split(`/`).map(encodeURIComponent).join(`/`),Xn=(e,t)=>e.then(e=>e.ok?e.json():t).catch(()=>t),k=e=>`${T.base}/${Yn(e)}`,A={list(e=``){return Xn(fetch(`${T.base}?prefix=${encodeURIComponent(e)}`),[])},get(e){return fetch(k(e))},put(e,t,n={}){let r=`?kind=${encodeURIComponent(n.kind??``)}&site=${encodeURIComponent(n.site??``)}`;return Xn(fetch(k(e)+r,{method:`POST`,headers:n.type?{"Content-Type":n.type}:void 0,body:t}),{path:e,size:0,date:new Date().toISOString()})},move(e,t){return fetch(`${k(e)}?to=${encodeURIComponent(t)}`,{method:`PUT`})},remove(e){return fetch(k(e),{method:`DELETE`})}},j=(e,t)=>t===``?e:`${t}/${e}`,Zn=e=>e.split(`/`).slice(0,-1).join(`/`),Qn=e=>e.path.endsWith(`/`)?e.path.slice(0,-1):e.path,$n=e=>e.split(`/`).slice(0,-1).map((e,t,n)=>n.slice(0,t+1).join(`/`)).filter(e=>e!==T.trash),er=e=>e.includes(`.`)?(e.split(`.`).pop()??``).toLowerCase():``,tr=e=>{let t=er(e);return t===`pdf`?`pdf`:t===`mp4`||t===`mov`||t===`webm`?`mp4`:t===`jpg`||t===`jpeg`||t===`png`||t===`gif`?`jpg`:t===`xlsx`||t===`xls`||t===`csv`?`xlsx`:`file`},nr=(e,t)=>{let n=Qn(e),r=n.startsWith(`${T.trash}/`),i=r?n.slice(T.trash.length+1):n,a=i.split(`/`).pop(),o=e.kind??t?.kind??(e.path.endsWith(`/`)?`folder`:tr(a)),s=o.startsWith(`folder`)?`—`:pt(e.size);return{owner:`自分`,...t,id:n,name:a,kind:o,date:ft(e.date),iso:e.date,size:s,bytes:e.size,parent:Zn(i),trashed:r}},M=(e,t,n,r=!1)=>gt(e,new Set(t.filter(e=>e.parent===n&&!!e.trashed===r).map(e=>e.name))),N=e=>e.scan(`files/`),rr=(e,t)=>{let n=nr(t,e[`files/${Qn(t)}`]);return e[`files/${n.id}`]=n,$n(n.id).forEach(n=>{e[`files/${n}`]||(e[`files/${n}`]=nr({path:`${n}/`,size:0,date:t.date}))}),n},ir=async(e,t,n,r,i,a)=>{let o=M(n.replace(/^\.+/,``)||`無題のファイル`,N(e),r),s=j(o,r),c={path:t.startsWith(`folder`)?`${s}/`:s,size:i?.size??0,date:new Date().toISOString(),kind:t};return rr(e,c),rr(e,await A.put(c.path,i,{kind:t,site:a,type:i?.type}))},P=async(e,t,n=``)=>{let r=n;for(let n of t.split(`/`).filter(Boolean)){let t=e[`files/${j(n,r)}`];r=t?.kind.startsWith(`folder`)?t.id:(await ir(e,`folder`,n,r,``)).id}return r},ar=async(e,t,n)=>{for(let{path:r,file:i}of t){let t=r.split(`/`).filter(Boolean),a=t.pop(),o=await P(e,t.join(`/`),n);i||await P(e,a,o),i&&await ir(e,tr(a),a,o,i)}},or=async(e,t)=>{let n=await A.list(),r=new Set;for(let e of n){let n=rr(t,e);r.add(n.id),$n(n.id).forEach(e=>r.add(e))}N(t).forEach(e=>!r.has(e.id)&&delete t[`files/${e.id}`]);let i=n.reduce((e,t)=>e+t.size,0);return t.storage={used:i/1048576,total:it,text:`15 GB 中 ${mt(i)} を使用`},`synced ${n.length} objects`},sr=async({id:e,dir:t},n)=>{let r=n[`files/${e}`];if(!r||r.trashed)return`not found: ${e}`;if(r.parent===t)return`already in ${t===``?`root`:t}`;if(r.kind.startsWith(`folder`)&&(t===e||t.startsWith(`${e}/`)))return`cannot move ${r.name} into itself`;let i=M(r.name,N(n),t),a=j(i,t);return await A.move(e,a),delete n[`files/${e}`],n[`files/${a}`]={...r,id:a,name:i,parent:t},N(n).forEach(t=>{if(!t.id.startsWith(`${e}/`))return;delete n[`files/${t.id}`];let r={...t,id:a+t.id.slice(e.length),parent:a+t.parent.slice(e.length)};n[`files/${r.id}`]=r}),`moved ${i} to ${t===``?`root`:t}`},cr=async({id:e},t)=>{let n=t[`files/${e}`];if(!n)return`not found: ${e}`;if(n.trashed)return delete t[`files/${e}`],N(t).forEach(n=>n.id.startsWith(`${e}/`)&&delete t[`files/${n.id}`]),await A.remove(e),`deleted ${n.name}`;let r=M(n.name,N(t),n.parent,!0),i=j(r,n.parent);return await A.move(e,`${T.trash}/${i}`),delete t[`files/${e}`],t[`files/${T.trash}/${i}`]={...n,id:`${T.trash}/${i}`,name:r,trashed:!0},N(t).forEach(n=>{if(!n.id.startsWith(`${e}/`))return;delete t[`files/${n.id}`];let r={...n,id:`${T.trash}/${i}${n.id.slice(e.length)}`,parent:i+n.parent.slice(e.length),trashed:!0};t[`files/${r.id}`]=r}),`trashed ${n.name}`},lr=async({id:e},t)=>{let n=t[`files/${e}`];if(!n?.trashed)return`not trashed: ${e}`;let r=await P(t,n.parent),i=M(n.name,N(t),r),a=j(i,r);await A.move(e,a),delete t[`files/${e}`];let o={...n,id:a,name:i,parent:r};return delete o.trashed,t[`files/${a}`]=o,`restored ${i}`},ur=async({id:e,name:t},n)=>{let r=n[`files/${e}`];if(!r)return`not found: ${e}`;let i=t.replace(/^\.+/,``)||r.name,a=M(i,N(n),r.parent),o=j(a,r.parent);return await A.move(e,o),delete n[`files/${e}`],n[`files/${o}`]={...r,id:o,name:a},N(n).forEach(t=>{if(!t.id.startsWith(`${e}/`))return;delete n[`files/${t.id}`];let r={...t,id:o+t.id.slice(e.length),parent:o+t.parent.slice(e.length)};n[`files/${r.id}`]=r}),`renamed to ${a}`},dr=async(e,t)=>{let n=N(t).filter(e=>e.trashed);n.forEach(e=>delete t[`files/${e.id}`]);let r=await A.list(`${T.trash}/`);return await Promise.all(r.map(e=>A.remove(e.path))),`emptied ${n.length} items`},fr=e=>Bn(N(e)),F={ask:`Ask me anything...`,brand:`Claude`,voice:`音声モード`,file:`ファイル`},I=[{id:`claude-fable-5`,label:`Fable 5`,desc:`最も困難な課題に`},{id:`claude-opus-5`,label:`Opus 5`,desc:`複雑なタスク向け`},{id:`claude-sonnet-5`,label:`Sonnet 5`,desc:`日常のタスクに最適`},{id:`claude-haiku-4-5`,label:`Haiku 4.5`,desc:`素早い回答に最適`}],L={w:376,left:12,top:12,bottom:16,minH:180},R=e(``),z={send:async()=>``,stream:{parse:()=>[],send:async()=>[]},icon:``,path:``,headers:{},hello:()=>({greet:``,title:``,desc:``,prompts:[]}),commands:()=>[],hints:()=>[],menu:{useOpen:()=>n(R),flip:e=>n=>{n.stopPropagation(),t(R,R.value===e?``:e)},close:()=>t(R,``)}},pr=e=>void Object.assign(z,e),mr=(e,t=20,n=6)=>{let r=a(null);return i(()=>{let e=r.current;if(!e)return;e.style.height=`${t}px`;let i=Math.max(1,Math.round(e.scrollHeight/t));e.style.height=`${Math.min(i,n)*t}px`},[e]),r},hr=(()=>{let e=new Be({linkify:!0,breaks:!0}),t=t=>e.render(t);return{render:t,plain:e=>{let n=document.createElement(`div`);return n.innerHTML=t(e),n.textContent?.trim()??``}}})(),B=e(!1),V=e([]),H=e(``),U=e([0,0]),gr=e(I[0].id),W=e(!1),G=e(!1),_r=()=>W.value,vr=()=>n(W),K=e(!1);let q=null;const yr=()=>{let e=window.SpeechRecognition??window.webkitSpeechRecognition;if(!e)return null;let n=new e;return n.lang=`ja-JP`,n.continuous=!0,n.interimResults=!1,n.onresult=e=>{let n=``;for(let t=e.resultIndex;t<e.results.length;t++)e.results[t].isFinal&&(n+=e.results[t][0].transcript);n!==``&&t(H,H.value+n)},n.onend=()=>t(K,!1),n},br=()=>{if(K.value)return void q?.stop();q??=yr(),q&&(q.start(),t(K,!0))};let J=[0,0,28,28];const xr=(e,t,n)=>Math.min(Math.max(e,t),Math.max(t,n)),Sr=()=>{let[e,t]=U.value,n=Y.target.getBoundingClientRect();J=[n.left-e,n.top-t,n.width,n.height]},Cr=()=>{let e=xr(Y.offset[0],-J[0],window.innerWidth-J[2]-J[0]),n=xr(Y.offset[1],-J[1],window.innerHeight-J[3]-J[1]);b(e,n,Y.offset),t(U,[e,n])},Y=zt(()=>{Y.isDragStart&&Sr(),Cr()}),wr=()=>{b(0,0,Y.offset),t(U,[0,0])},Tr=()=>{let e=Y.target;!e||!e.isConnected||(Sr(),Cr())},Er=()=>{r(()=>(Tr(),window.addEventListener(`resize`,Tr),()=>window.removeEventListener(`resize`,Tr)),[])},Dr=e=>`calc(max(${L.left}px, 100vw - ${L.w+L.left}px) + ${e}px)`,Or=e=>L.top+e,kr=e=>`max(${L.minH}px, min(calc(100dvh - ${L.top+L.left}px), calc(100dvh - ${L.top+L.bottom+e}px)))`,X=e(null),Z=e(0),Ar=(e,t)=>{if(t)return t;if(!e.startsWith(`/`))return[];let n=e.slice(1).trim().toLowerCase();return z.commands().filter(e=>e.name.toLowerCase().startsWith(n))},jr=()=>{t(X,null),t(Z,0)},Q=async e=>{t(H,``),jr();let n=await e.run();Array.isArray(n)&&t(X,n)},Mr=e=>{if(!e.startsWith(`/`))return;let t=e.slice(1).trim().toLowerCase();return z.commands().find(e=>e.name.toLowerCase()===t)??Ar(e,null)[0]},Nr=e=>{if(e.nativeEvent?.isComposing)return!1;let n=Ar(H.value,X.value);if(n.length===0)return!1;let r=Z.value%n.length;return e.key===`ArrowDown`?(e.preventDefault(),t(Z,(r+1)%n.length),!0):e.key===`ArrowUp`?(e.preventDefault(),t(Z,(r-1+n.length)%n.length),!0):e.key===`Escape`?(e.preventDefault(),t(H,``),jr(),!0):e.key===`Enter`&&(e.preventDefault(),Q(n[r]),!0)},Pr=(()=>{let e=e=>e.replace(/[^0-9A-Za-zぁ-んァ-ヴー一-龠々\s]/g,` `).replace(/\s+/g,` `).trim(),t=e=>{let t=document.createElement(`div`);return t.innerHTML=hr.render(e),t.querySelectorAll(`pre`).forEach(e=>e.remove()),t.textContent??``};return{lines:n=>t(n).split(`
|
|
2
|
+
`).map(e).filter(e=>e!==``)}})();let $=0,Fr=[];const Ir=[`Kyoko`,`O-Ren`,`Nanami`,`Ayumi`,`Haruka`,`Sayaka`,`Samantha`,`Zira`,`Aria`,`Jenny`,`Ava`,`Sonia`,`Google 日本語`,`Google US English`],Lr=[`Otoya`,`Ichiro`,`Keita`,`David`,`Mark`,`Guy`,`Alex`,`Daniel`,`Fred`,`Andrew`,`Brian`],Rr=()=>Fr=speechSynthesis.getVoices(),zr=e=>{Fr.length===0&&Rr();let t=Fr.filter(t=>t.lang.replace(`_`,`-`).startsWith(e.slice(0,2)));return t.find(e=>Ir.some(t=>e.name.includes(t)))??t.find(e=>!Lr.some(t=>e.name.includes(t)))??t[0]??null},Br=e=>{(e.match(/[A-Za-z][0-9A-Za-z]*(?: (?:[0-9]+ )*[A-Za-z][0-9A-Za-z]*)*|(?:(?![A-Za-z]).)+/g)??[]).forEach(e=>{if(e.trim()===``)return;let t=new SpeechSynthesisUtterance(e);t.lang=/^[A-Za-z]/.test(e)?`en-US`:`ja-JP`,t.voice=zr(t.lang),speechSynthesis.speak(t)})};speechSynthesis.addEventListener(`voiceschanged`,Rr);const Vr=e=>{if(!G.value)return;let t=e.split(`
|
|
3
3
|
`).slice(0,-1).join(`
|
|
4
|
-
`),n=
|
|
5
|
-
`),
|
|
4
|
+
`),n=Pr.lines(t);n.slice($).forEach(Br),$=n.length},Hr=e=>{G.value&&Pr.lines(e).slice($).forEach(Br),$=0},Ur=()=>{$=0,speechSynthesis.cancel()},Wr=()=>t(B,!0),Gr=()=>{wr(),Ur(),jr(),t(B,!1)},Kr=()=>{if(B.value)return Gr();Wr()},qr=e=>{jr(),t(H,e.target.value)},Jr=()=>{let e=H.value.trim();if(e===``||W.value)return;let n=Mr(e);if(n)return void Q(n);t(H,``),z.send({prompt:e})},Yr=e=>{Nr(e)||e.key!==`Enter`||e.nativeEvent?.isComposing||e.shiftKey||(e.preventDefault(),Jr())},Xr=e=>()=>{let t=Mr(e);if(t)return void Q(t);z.send({prompt:e})},Zr=()=>{G.value&&Ur(),t(G,!G.value)},Qr=e=>{z.menu.close(),t(gr,e.id)},$r=()=>l(`div`,{className:`flex shrink-0 items-start justify-between px-2`,children:[c(_,{name:je,size:50,className:`text-mute`}),l(`div`,{className:`flex items-center gap-2`,children:[c(`button`,{ref:Y.ref,className:`flex h-7 w-7 cursor-grab touch-none select-none items-center justify-center rounded-full text-mute hover:bg-band hover:text-ink active:cursor-grabbing`,children:c(_,{name:Me,size:20})}),c(`button`,{onClick:Gr,className:`flex h-7 w-7 cursor-pointer items-center justify-center rounded-full text-mute hover:bg-band hover:text-ink`,children:c(_,{name:ee,size:20})})]})]}),ei=()=>{let e=z.hello();return l(`div`,{className:`flex h-full flex-col items-center justify-center px-3 text-center`,children:[c(_,{name:je,size:56,className:`mb-5 text-mute`}),c(`p`,{className:`text-mute`,children:e.greet}),c(`p`,{className:`mt-1 font-bold leading-[26px]`,children:e.title}),c(`p`,{className:`mt-3 text-mute`,children:e.desc}),c(`div`,{className:`-mx-6 mt-6 flex flex-wrap justify-center gap-1.5`,children:e.prompts.map(e=>l(`button`,{onClick:Xr(e.prompt??e.label),className:`flex cursor-pointer items-center gap-1 whitespace-nowrap rounded-full border border-edge bg-white px-2.5 py-1 text-[12px] leading-[16px] hover:bg-pale`,children:[e.icon&&c(_,{name:e.icon,size:14,color:e.color}),e.label]},e.label))})]})},ti=({t:e})=>l(`div`,{className:`-mt-4 ml-3 flex max-w-full items-center rounded-lg border border-edge bg-band p-2`,children:[e.icon&&c(_,{name:e.icon,size:16}),c(`span`,{className:`mx-2 truncate text-[12px]`,children:e.label}),c(`button`,{className:`hidden ml-1 flex h-5 w-5 shrink-0 cursor-pointer items-center justify-center rounded-full text-mute hover:bg-line`,children:c(_,{name:ze,size:16})})]}),ni=({m:e})=>l(`div`,{className:`mr-7 flex flex-col items-start ${e.tools?.length?`mb-6`:``}`,children:[c(`div`,{className:`chat-md w-full rounded-xl border border-edge bg-white p-3 ${e.tools?.length?`pb-5`:``}`,dangerouslySetInnerHTML:{__html:hr.render(e.text)}}),e.tools?.map((e,t)=>c(ti,{t:e},t))]}),ri=({m:e})=>c(`div`,{className:`ml-7 min-w-0 whitespace-pre-wrap [overflow-wrap:anywhere] rounded-2xl border border-edge bg-band p-3`,children:e.text}),ii=()=>c(`div`,{className:`flex w-fit items-center rounded-lg border border-edge bg-white px-2 py-1 text-mute`,children:c(_,{name:ze,size:20,className:`animate-pulse`})}),ai=()=>{let e=n(V),t=n(W),i=a(null);return r(()=>void i.current?.scrollTo(0,9e9),[e]),c(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:l(`div`,{ref:i,className:`flex h-full flex-col gap-5 overflow-y-auto px-2 pb-4 pt-10 text-[14px] leading-[22px]`,children:[e.length===0&&c(ei,{}),e.map((e,t)=>e.role===`user`?c(ri,{m:e},t):c(ni,{m:e},t)),t&&e[e.length-1]?.role===`user`&&c(ii,{})]})})},oi=()=>{let e=n(H);return n(K)?c(`button`,{onClick:br,className:`flex h-5 w-5 shrink-0 cursor-pointer items-center justify-center text-[#EA4335]`,children:c(_,{name:Fe,size:20})}):e.trim()===``?c(`button`,{onClick:br,className:`flex h-5 w-5 shrink-0 cursor-pointer items-center justify-center text-mute hover:text-ink`,children:c(_,{name:Ne,size:20})}):c(`button`,{onClick:Jr,className:`flex h-5 w-5 shrink-0 cursor-pointer items-center justify-center text-ink hover:text-[#4185F4]`,children:c(_,{name:Pe,size:20})})},si=()=>{let e=n(H),t=n(X),r=n(Z),i=Ar(e,t);return i.length===0?null:c(`div`,{className:`absolute inset-x-0 bottom-full z-10 mb-2 max-h-56 overflow-y-auto rounded-xl border border-edge bg-white py-1 shadow-[0_8px_24px_rgba(0,0,0,0.12)]`,children:i.map((e,n)=>l(`button`,{onClick:()=>void Q(e),className:`flex w-full cursor-pointer items-center gap-3 px-3 py-1.5 text-left text-[12px] leading-[16px] ${n===r%i.length?`bg-band`:`hover:bg-pale`}`,children:[c(`span`,{className:`shrink-0 font-bold`,children:t?e.label??e.name:`/${e.name}`}),c(`span`,{className:`min-w-0 flex-1 truncate text-right text-mute`,children:e.desc})]},`${e.name}-${n}`))})},ci=()=>{let e=n(V),t=n(W)?[]:z.hints(e);return t.length===0?null:c(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-1.5 pb-2`,children:t.map(e=>c(`button`,{onClick:()=>void Q(e),className:`cursor-pointer rounded-full border border-edge bg-white px-2.5 py-1 text-[12px] leading-[16px] hover:bg-pale`,children:e.label??e.name},e.name))})},li=()=>{let e=n(H),t=n(gr),r=n(G),i=z.menu.useOpen(),a=mr(e),o=I.find(e=>e.id===t)??I[0];return l(`div`,{className:`relative shrink-0 rounded-xl border border-edge`,children:[c(si,{}),l(`label`,{className:`flex items-start gap-2 px-3 pb-7 pt-3`,children:[c(_,{name:me,size:20,className:`text-mute`}),c(`textarea`,{ref:a,rows:1,value:e,onChange:qr,onKeyDown:Yr,placeholder:F.ask,className:`min-w-0 flex-1 resize-none overflow-y-auto bg-transparent text-[14px] leading-[20px] outline-none placeholder:text-mute`}),c(oi,{})]}),l(`div`,{className:`flex h-9 items-center border-t border-line px-3 text-[12px]`,children:[l(`span`,{className:`relative flex`,children:[l(`button`,{onClick:z.menu.flip(`chat-model`),className:`flex cursor-pointer items-center gap-1`,children:[F.brand,` `,o.label,c(_,{name:Re,size:16,className:`text-mute`})]}),i===`chat-model`&&c(Je,{align:`left`,cls:`w-64`,items:I,value:t,pick:Qr,check:m})]}),l(`div`,{className:`ml-auto flex items-center gap-3`,children:[l(`button`,{onClick:Zr,className:`flex cursor-pointer items-center gap-1 ${r?`text-[#4185F4]`:``}`,children:[c(_,{name:Ie,size:18}),F.voice]}),l(`button`,{className:`flex cursor-pointer items-center gap-1`,children:[c(_,{name:Le,size:18}),F.file]})]})]})]})},ui=()=>c(`button`,{onClick:Kr,className:`flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-full text-mute hover:bg-band hover:text-ink`,children:c(_,{name:je,size:22})}),di=()=>{Er();let[e,t]=n(U);return l(`div`,{className:`fixed z-50 flex w-[376px] max-w-[calc(100vw-24px)] flex-col rounded-2xl border border-line bg-white p-3 text-ink shadow-[0_8px_24px_rgba(0,0,0,0.12)]`,style:{left:Dr(e),top:Or(t),height:kr(t)},children:[c($r,{}),c(ai,{}),c(ci,{}),c(li,{})]})},fi=()=>n(B)?c(di,{}):null,pi=e=>({role:`agent`,text:e.text,tools:e.tools.map(e=>({icon:z.icon,label:`${e.server?`${e.server} - `:``}${e.name} (MCP)`}))}),mi=e=>t(V,e.flatMap(e=>[{role:`user`,text:e.prompt},pi({text:e.reply,tools:e.tools.map(e=>({server:``,name:e}))})])),hi=e=>e.map(e=>e.tools.length?`${e.text}\n`:e.text).join(`
|
|
5
|
+
`),gi=async e=>{if(W.value)return`busy: previous chat is still running`;let n=[...V.value,{role:`user`,text:e}];Ur(),t(V,n),t(W,!0);let r=await z.stream.send({prompt:e,path:z.path,model:gr.value,headers:z.headers},e=>{t(V,[...n,...e.items.map(pi)]),Vr(hi(e.items))});return Hr(hi(r)),t(W,!1),`chat sent: ${e}`},_i=e=>{let t=[],n=``,r=[],i=()=>Math.floor(new Date().getHours()/6),a=r=>{let a=i(),o=n,s=t.find(e=>e.name===r&&e.part===a&&e.after===o);s&&(s.count+=1),s||t.push({name:r,part:a,after:o,count:1}),n=r,e.store.save({name:r,part:a,after:o})},o=e=>t.reduce((t,r)=>r.name===e?t+r.count*(r.part===i()?2:1)*(r.after===n?2:1):t,0),s=e=>[...e].sort((e,t)=>o(t.name)-o(e.name)),c=()=>(r.length===0&&(r=e.deck.map(e=>({...e,run:()=>(a(e.name),e.run())}))),s(r));return{commands:c,hello:()=>{let t=c(),n=t.filter(t=>e.starters().includes(t.name)),r=[...new Set([...e.pinned(),...n.map(e=>e.name)])].flatMap(e=>t.filter(t=>t.name===e));return{...e.greet,prompts:r.map(e=>({label:e.label??e.name,prompt:`/${e.name}`}))}},hints:t=>e.hinted(t).flatMap(e=>c().filter(t=>t.name===e)),prime:async()=>{t=await e.store.list()}}},vi=(e,t)=>e.map((n,r)=>{let i=e[r+1]?.seq??1/0;return{...n,names:t.filter(e=>e.seq>n.seq&&e.seq<i).map(e=>e.name)}}),yi=e=>e.replace(/\s+/g,` `).trim().slice(0,40),bi=e=>{let t=Math.max(0,(Date.now()-new Date(e).getTime())/1e3);return t<60?`たった今`:t<3600?`${Math.floor(t/60)} 分前`:t<86400?`${Math.floor(t/3600)} 時間前`:`${Math.floor(t/86400)} 日前`},xi=e=>{let t=crypto.randomUUID(),n=0,r=[],i=()=>{t=crypto.randomUUID(),n=0,r=[],e.show([])},a=async()=>(await e.store.list()).map(e=>({...e,when:bi(e.updatedAt)})),o=async i=>{let a=await e.store.load(i),o=vi(a.talks,a.tools).map(e=>({prompt:e.prompt,reply:e.reply,tools:e.names}));t=i,n=[...a.talks,...a.tools].reduce((e,t)=>Math.max(e,t.seq),0),r=o.flatMap(e=>[{role:`user`,content:e.prompt},{role:`assistant`,content:e.reply}]),e.show(o)},s=(i,a,o=``)=>{let s=a.filter(e=>!e.error),c=s.map(e=>e.text).filter(e=>e!==``).join(`
|
|
6
6
|
|
|
7
|
-
`);if(c===``)return;let l=s.flatMap(e=>e.tools.map(e=>e.name));r=[...r,{role:`user`,content:i},{role:`assistant`,content:c}];let u=n+1;n=u+l.length,e.store.save(t,{title:ir(i),seq:u,prompt:i,reply:c,model:o,tools:l.map((e,t)=>({seq:u+1+t,name:e}))})};return{wrap:e=>({...e,send:async(t,n)=>{let i=await e.send({...t,messages:r.slice(-40)},n);return s(t.prompt,i,t.model),i}}),reset:i,load:o,list:a}},sr=()=>M.value,cr=()=>n(M),U={add:ue,arrowBack:de,arrowDropDown:fe,check:se,chevronRight:pe,closeIcon:f,cloud:me,deleteIcon:he,folder:ge,home:_e,keep:ve,keepFill:ye,leftPanelClose:be,leftPanelOpen:xe,menuIcon:Se,moreVert:Ce,redoIcon:we,schedule:Te,searchIcon:m,settings:Ee,help:De,keyboard:Oe,sync:ke,undoIcon:Ae,unfoldMore:je,visibilityOff:Me,createNewFolder:Ne,uploadFile:Pe,driveFolderUpload:Fe,edit:Ie,download:Le,info:Re,openInNew:ze,restoreFromTrash:Be,description:Ve},lr=({count:e,min:t,cls:n=``,children:r})=>c(`div`,{className:`grid gap-4 overflow-x-auto ${n}`,style:{gridTemplateColumns:`repeat(${e}, minmax(${t}px, 1fr))`},children:r}),ur=({c:e,click:t})=>l(`button`,{onClick:t,className:`relative flex h-full w-full cursor-pointer flex-col items-start rounded-xl border border-edge bg-white p-3 text-left hover:bg-pale`,children:[c(`span`,{className:`flex h-[30px] w-[30px] items-center justify-center rounded-md bg-band`,children:c(g,{name:e.icon??``,size:18,color:e.color})}),c(g,{name:U.add,size:16,className:`absolute right-3 top-3 text-mute`}),c(`span`,{className:`mt-2 w-full truncate text-[14px] leading-[17px]`,children:e.label})]}),dr=({c:e,click:t})=>l(`button`,{onClick:t,className:`flex h-12 w-full cursor-pointer items-center gap-3 rounded-xl border border-edge bg-white px-4 text-left hover:bg-pale`,children:[c(g,{name:e.icon??``,size:18,color:e.color}),c(`span`,{className:`truncate`,children:e.label}),c(g,{name:U.add,size:16,className:`ml-auto shrink-0 text-mute`})]}),fr=({cards:e,click:t,popup:n,count:r=4})=>l(s,{children:[c(lr,{count:r,min:it.card,cls:`hidden md:grid`,children:e.map(e=>l(`div`,{className:`relative`,children:[c(ur,{c:e,click:t(e)}),n(e)]},e.id))}),c(`div`,{className:`flex flex-col gap-2 md:hidden`,children:e.map(e=>l(`div`,{className:`relative`,children:[c(dr,{c:e,click:t(e)}),n(e)]},e.id))})]}),pr=e=>c(`section`,{className:`relative shrink-0 px-4 pt-3 md:pl-7 md:pr-9`,children:c(fr,{...e})}),mr=({drawer:e,close:t,dropRef:n,children:r})=>l(`div`,{ref:n,onClick:t,className:`flex h-dvh overflow-hidden bg-white font-medium text-ink`,children:[e&&c(`div`,{className:`fixed inset-0 z-30 bg-black/30 md:hidden`,onClick:t}),r]}),hr=({drop:e,from:t,children:n})=>c(`main`,{"data-drop":e,"data-drop-from":t,"data-drop-scope":``,className:`flex min-w-0 flex-1 flex-col overflow-y-auto pt-14 md:pt-0`,children:n}),gr=`flex h-9 w-9 shrink-0 items-center justify-center rounded-full text-mute hover:bg-band hover:text-ink`,_r=`flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-full text-mute hover:bg-band hover:text-ink`,vr=({icon:e,color:t,label:n,home:r,actions:i,drawer:a})=>l(`header`,{className:`fixed inset-x-0 top-0 z-20 flex h-14 items-center gap-1 bg-white pl-4 pr-3 md:hidden`,children:[l(`button`,{onClick:r,className:`flex min-w-0 flex-1 cursor-pointer items-center gap-3`,children:[c(g,{name:e,size:24,color:t}),c(`span`,{className:`truncate text-sm font-bold`,children:n})]}),l(`div`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:[i,c(`button`,{onClick:a,className:gr,children:c(g,{name:U.menuIcon,size:22})})]})]}),yr=({bar:e,open:t,title:n,back:r,expand:i,actions:a})=>l(`div`,{className:`mt-2.5 flex h-8 shrink-0 items-center gap-2 px-4 md:pl-7 md:pr-9`,children:[!e&&c(`button`,{onClick:t,className:`${_r} hidden md:flex`,children:c(g,{name:U.leftPanelOpen,size:20})}),!r&&c(`h1`,{className:`min-w-0 truncate font-bold`,children:n}),r&&l(`button`,{onClick:r,className:`flex min-w-0 cursor-pointer items-center gap-2 font-bold`,children:[c(g,{name:U.arrowBack,size:20,className:`text-mute`}),c(`span`,{className:`truncate`,children:n})]}),l(`div`,{className:`relative ml-auto flex shrink-0 items-center gap-1`,children:[i&&l(`button`,{onClick:i.click,className:`flex h-8 cursor-pointer items-center gap-1 rounded-lg px-2 hover:bg-band ${i.on?`text-ink`:`text-mute`}`,children:[c(`span`,{className:`hidden md:inline`,children:i.label}),c(g,{name:i.icon||U.unfoldMore,size:18})]}),a]})]}),br=({icon:e,size:t=20,click:n,children:r})=>l(`span`,{className:`relative hidden md:flex`,children:[c(`button`,{onClick:n,className:_r,children:c(g,{name:e,size:t})}),r]}),xr=({icon:e,size:t=20,click:n,children:r})=>l(`span`,{className:`relative flex`,children:[c(`button`,{onClick:n,className:gr,children:c(g,{name:e,size:t})}),r]}),Sr=U.moreVert,Cr=`STORAGE`,wr=`アップグレード`,Tr=`https://stripe.com`,Er=`ゴミ箱を空にしますか?中のアイテムは完全に削除されます`,Dr=[{id:`manage`,icon:U.cloud,label:`保存容量を管理`},{id:`empty`,icon:U.deleteIcon,label:`ゴミ箱を空にする`},{id:`refresh`,icon:U.sync,label:`使用状況を更新`}],Or=[{id:`undo`,icon:U.undoIcon,label:`直前の操作を元に戻す`},{id:`redo`,icon:U.redoIcon,label:`最後に元に戻した操作をやり直す`},{id:`settings`,icon:U.settings,label:`設定`,top:!0},{id:`help`,icon:U.help,label:`ヘルプ`},{id:`shortcuts`,icon:U.keyboard,label:`キーボードショートカット`}],kr=Or.slice(2).map(e=>({...e,top:!1})),Ar=U.visibilityOff,jr=(e,t,n)=>[{id:`band`,icon:Ar,label:e?`すべての${t}を非表示`:`すべての${t}を表示`},...n.map((e,t)=>t===0?{...e,top:!0}:e)],Mr=`flex h-9 w-9 shrink-0 items-center justify-center rounded-full text-mute hover:bg-band hover:text-ink`,Nr=({icon:e,color:t,label:n,click:r})=>l(`button`,{onClick:r,className:`flex min-w-0 flex-1 cursor-pointer items-center gap-3`,children:[c(g,{name:e,size:24,color:t}),c(`span`,{className:`truncate text-sm font-bold`,children:n})]}),Pr=({storage:e,upgrade:t,menu:n,more:r})=>l(`div`,{className:`relative shrink-0 border-t border-line px-4 pb-4 pt-3`,children:[l(`div`,{className:`flex h-6 items-center gap-2 text-mute`,children:[c(g,{name:U.cloud,size:18}),c(`span`,{className:`tracking-wider`,children:Cr}),l(`span`,{className:`relative ml-auto flex`,children:[c(`button`,{onClick:r,className:`flex h-6 w-6 items-center justify-center rounded-full text-mute hover:bg-band`,children:c(g,{name:U.moreVert,size:16})}),n]})]}),c(`div`,{className:`mt-1.5 h-2 overflow-hidden rounded-full bg-line`,children:c(`div`,{className:`h-full rounded-full bg-fill`,style:{width:`${Math.min(100,e.used/e.total*100)}%`}})}),c(`p`,{className:`mt-1.5`,children:e.text}),c(`button`,{onClick:t,className:`mt-2.5 h-9 w-full cursor-pointer rounded-full border border-ink font-bold hover:bg-band`,children:wr})]}),Fr=({brand:e,bar:t,drawer:n,fold:r,close:i,press:a,storage:o,upgrade:s,menu:u,more:d,children:f})=>l(`nav`,{"data-drop-scope":``,onClick:a,className:`fixed inset-y-0 left-0 z-40 flex shrink-0 flex-col border-r border-line bg-pale transition-transform md:static md:translate-x-0 ${n?`translate-x-0`:`-translate-x-full`} ${t?``:`md:hidden`}`,style:{width:_.width},children:[l(`div`,{className:`flex h-15 shrink-0 items-center gap-1 pr-2 text-[14px]`,style:{paddingLeft:_.brand},children:[c(Nr,{...e}),c(`button`,{onClick:r,className:`${Mr} hidden md:flex`,children:c(g,{name:U.leftPanelClose,size:20})}),c(`button`,{onClick:i,className:`${Mr} md:hidden`,children:c(g,{name:U.leftPanelClose,size:20})})]}),c(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-2 pb-4`,children:f}),c(Pr,{storage:o,upgrade:s,menu:u,more:d})]}),Ir=e=>`flex w-full cursor-pointer items-center rounded-lg text-left text-[14px] text-mute ${e?`bg-band`:`hover:bg-band`}`,Lr=({open:e,turn:t})=>t?c(`button`,{onClick:t,className:`flex shrink-0 items-center justify-center`,style:{width:_.slot,height:_.slot},children:c(g,{name:U.chevronRight,size:_.slot,className:e?`rotate-90`:``})}):c(`span`,{className:`shrink-0`,style:{width:_.slot}}),Rr=({depth:e=0,on:t=!1,open:n,turn:r,icon:i,color:a,label:o,drop:s,mark:u,from:d,click:f,dclick:p,rclick:m,dragRef:h,children:ee})=>l(`div`,{ref:h,"data-drop":s,"data-drop-mark":u,"data-drop-from":d,onClick:e=>(f?.(e),r?.(e)),onDoubleClick:p,onContextMenu:m,className:Ir(t),style:{height:_.row,paddingLeft:e*_.indent},children:[c(Lr,{open:n,turn:r}),c(g,{name:i,size:_.icon,color:a}),c(`span`,{className:`min-w-0 flex-1 truncate ${t?`text-ink`:``}`,style:{marginLeft:_.gap},children:o}),ee]}),W={base:`/api/v1/storage`,trash:`.trash`,editors:[]},zr=e=>void Object.assign(W,e),G=e=>e.kind.startsWith(`folder`),Br=(e,t)=>e.name.localeCompare(t.name),Vr=(e,t)=>t.iso.localeCompare(e.iso),Hr=(e,t)=>{let n=e.filter(e=>e.parent===t&&!e.trashed);return[...n.filter(G).sort(Br),...n.filter(e=>!G(e)).sort(Br)]},Ur=(e,t)=>e.filter(e=>!e.trashed&&e.kind===t).sort(Vr),Wr=e=>e.filter(e=>!e.trashed&&!G(e)).sort(Vr).slice(0,12),Gr=e=>e.filter(e=>e.trashed),Kr=e=>e.filter(e=>!e.trashed&&!G(e)).sort((e,t)=>t.bytes-e.bytes),qr=(e,t)=>e.filter(e=>!e.trashed&&e.parent===t),Jr=e=>{let t=e.split(`/`).filter(Boolean);return t.map((e,n)=>({name:n===0&&e===W.trash?`ゴミ箱`:e,path:t.slice(0,n+1).join(`/`)}))},Yr=e=>e.filter(e=>!G(e)).reduce((e,t)=>e+t.bytes,0),Xr=e=>{let{files:t,parent:n,depth:r,expand:i,active:a,kinds:o,fold:u,enter:d,open:f,menu:p,rclick:m,drag:h}=e;return c(s,{children:Hr(t,n).map(t=>{let n=(o[t.kind]??o.file).icon;return G(t)?l(`div`,{children:[c(Rr,{depth:r,on:a===t.id,open:i.includes(t.id),turn:u(t.id),icon:o.folder.icon,label:t.name,drop:t.id,mark:t.id,click:d(t.id),rclick:m(t),dragRef:h(t.id,`tree`),children:p(t)}),i.includes(t.id)&&c(Xr,{...e,parent:t.id,depth:r+1})]},t.id):c(Rr,{depth:r,icon:n,label:t.name,drop:t.parent,click:d(t.parent),dclick:f(t),rclick:m(t),dragRef:h(t.id,`tree`),children:p(t)},t.id)})})},K=e(!1),Zr=e(null),Qr=e=>{e.stopPropagation(),t(K,!0)},$r=()=>t(K,!1),ei=e=>t(Zr,{x:e.clientX,y:e.clientY}),ti=()=>t(Zr,null),ni=()=>K.value,ri=()=>n(K),ii=()=>n(Zr),ai=e=>e.split(`/`).map(encodeURIComponent).join(`/`),oi=(e,t)=>e.then(e=>e.ok?e.json():t).catch(()=>t),q=e=>`${W.base}/${ai(e)}`,J={list(e=``){return oi(fetch(`${W.base}?prefix=${encodeURIComponent(e)}`),[])},get(e){return fetch(q(e))},put(e,t,n={}){let r=`?kind=${encodeURIComponent(n.kind??``)}&site=${encodeURIComponent(n.site??``)}`;return oi(fetch(q(e)+r,{method:`POST`,headers:n.type?{"Content-Type":n.type}:void 0,body:t}),{path:e,size:0,date:new Date().toISOString()})},move(e,t){return fetch(`${q(e)}?to=${encodeURIComponent(t)}`,{method:`PUT`})},remove(e){return fetch(q(e),{method:`DELETE`})}},Y=(e,t)=>t===``?e:`${t}/${e}`,si=e=>e.split(`/`).slice(0,-1).join(`/`),ci=e=>e.path.endsWith(`/`)?e.path.slice(0,-1):e.path,li=e=>e.split(`/`).slice(0,-1).map((e,t,n)=>n.slice(0,t+1).join(`/`)).filter(e=>e!==W.trash),ui=e=>e.includes(`.`)?(e.split(`.`).pop()??``).toLowerCase():``,di=e=>{let t=ui(e);return t===`pdf`?`pdf`:t===`mp4`||t===`mov`||t===`webm`?`mp4`:t===`jpg`||t===`jpeg`||t===`png`||t===`gif`?`jpg`:t===`xlsx`||t===`xls`||t===`csv`?`xlsx`:`file`},fi=(e,t)=>{let n=ci(e),r=n.startsWith(`${W.trash}/`),i=r?n.slice(W.trash.length+1):n,a=i.split(`/`).pop(),o=e.kind??t?.kind??(e.path.endsWith(`/`)?`folder`:di(a)),s=o.startsWith(`folder`)?`—`:mt(e.size);return{owner:`自分`,...t,id:n,name:a,kind:o,date:pt(e.date),iso:e.date,size:s,bytes:e.size,parent:si(i),trashed:r}},X=(e,t,n,r=!1)=>_t(e,new Set(t.filter(e=>e.parent===n&&!!e.trashed===r).map(e=>e.name))),Z=e=>e.scan(`files/`),Q=(e,t)=>{let n=fi(t,e[`files/${ci(t)}`]);return e[`files/${n.id}`]=n,li(n.id).forEach(n=>{e[`files/${n}`]||(e[`files/${n}`]=fi({path:`${n}/`,size:0,date:t.date}))}),n},pi=async(e,t,n,r,i,a)=>{let o=X(n.replace(/^\.+/,``)||`無題のファイル`,Z(e),r),s=Y(o,r),c={path:t.startsWith(`folder`)?`${s}/`:s,size:i?.size??0,date:new Date().toISOString(),kind:t};return Q(e,c),Q(e,await J.put(c.path,i,{kind:t,site:a,type:i?.type}))},$=async(e,t,n=``)=>{let r=n;for(let n of t.split(`/`).filter(Boolean)){let t=e[`files/${Y(n,r)}`];r=t?.kind.startsWith(`folder`)?t.id:(await pi(e,`folder`,n,r,``)).id}return r},mi=async(e,t,n)=>{for(let{path:r,file:i}of t){let t=r.split(`/`).filter(Boolean),a=t.pop(),o=await $(e,t.join(`/`),n);i||await $(e,a,o),i&&await pi(e,di(a),a,o,i)}},hi=async(e,t)=>{let n=await J.list(),r=new Set;for(let e of n){let n=Q(t,e);r.add(n.id),li(n.id).forEach(e=>r.add(e))}Z(t).forEach(e=>!r.has(e.id)&&delete t[`files/${e.id}`]);let i=n.reduce((e,t)=>e+t.size,0);return t.storage={used:i/1048576,total:at,text:`15 GB 中 ${ht(i)} を使用`},`synced ${n.length} objects`},gi=async({id:e,dir:t},n)=>{let r=n[`files/${e}`];if(!r||r.trashed)return`not found: ${e}`;if(r.parent===t)return`already in ${t===``?`root`:t}`;if(r.kind.startsWith(`folder`)&&(t===e||t.startsWith(`${e}/`)))return`cannot move ${r.name} into itself`;let i=X(r.name,Z(n),t),a=Y(i,t);return await J.move(e,a),delete n[`files/${e}`],n[`files/${a}`]={...r,id:a,name:i,parent:t},Z(n).forEach(t=>{if(!t.id.startsWith(`${e}/`))return;delete n[`files/${t.id}`];let r={...t,id:a+t.id.slice(e.length),parent:a+t.parent.slice(e.length)};n[`files/${r.id}`]=r}),`moved ${i} to ${t===``?`root`:t}`},_i=async({id:e},t)=>{let n=t[`files/${e}`];if(!n)return`not found: ${e}`;if(n.trashed)return delete t[`files/${e}`],Z(t).forEach(n=>n.id.startsWith(`${e}/`)&&delete t[`files/${n.id}`]),await J.remove(e),`deleted ${n.name}`;let r=X(n.name,Z(t),n.parent,!0),i=Y(r,n.parent);return await J.move(e,`${W.trash}/${i}`),delete t[`files/${e}`],t[`files/${W.trash}/${i}`]={...n,id:`${W.trash}/${i}`,name:r,trashed:!0},Z(t).forEach(n=>{if(!n.id.startsWith(`${e}/`))return;delete t[`files/${n.id}`];let r={...n,id:`${W.trash}/${i}${n.id.slice(e.length)}`,parent:i+n.parent.slice(e.length),trashed:!0};t[`files/${r.id}`]=r}),`trashed ${n.name}`},vi=async({id:e},t)=>{let n=t[`files/${e}`];if(!n?.trashed)return`not trashed: ${e}`;let r=await $(t,n.parent),i=X(n.name,Z(t),r),a=Y(i,r);await J.move(e,a),delete t[`files/${e}`];let o={...n,id:a,name:i,parent:r};return delete o.trashed,t[`files/${a}`]=o,`restored ${i}`},yi=async({id:e,name:t},n)=>{let r=n[`files/${e}`];if(!r)return`not found: ${e}`;let i=t.replace(/^\.+/,``)||r.name,a=X(i,Z(n),r.parent),o=Y(a,r.parent);return await J.move(e,o),delete n[`files/${e}`],n[`files/${o}`]={...r,id:o,name:a},Z(n).forEach(t=>{if(!t.id.startsWith(`${e}/`))return;delete n[`files/${t.id}`];let r={...t,id:o+t.id.slice(e.length),parent:o+t.parent.slice(e.length)};n[`files/${r.id}`]=r}),`renamed to ${a}`},bi=async(e,t)=>{let n=Z(t).filter(e=>e.trashed);n.forEach(e=>delete t[`files/${e.id}`]);let r=await J.list(`${W.trash}/`);return await Promise.all(r.map(e=>J.remove(e.path))),`emptied ${n.length} items`},xi=e=>Yr(Z(e));export{Zn as AiChat,Yn as AiChatButton,pr as Band,Nr as Brand,fr as Cards,Xr as DriveTree,Ye as Drop,Lr as Fold,mr as Frame,lt as GB,br as HeadBtn,g as Icon,dt as KB,ut as MB,hr as Main,yr as MainHead,Sr as MoreIcon,Je as Pop,Rr as Row,ct as SP_BREAK,Fr as Side,We as Slot,xr as SpBtn,vr as SpHead,Pr as StorageBox,lr as Strip,gt as ago,li as ancestors,ei as atPoint,tt as band,rt as blue,D as chatConfig,An as closeChat,$r as closeDrawer,en as configureChat,zr as configureDrive,nr as createCommands,Wt as createFileDrag,$t as createFileDrop,or as createHistory,Dt as createOver,Jr as crumbSegs,Bt as dragEvent,W as driveConfig,Kt as dropEvent,$e as edge,bi as emptyTrash,Er as emptyTrashAsk,fi as entryOf,ui as extOf,nt as fill,qr as folderRows,X as freeName,it as grid,U as icons,ci as idOf,Xe as ink,sr as isChatBusy,ni as isDrawerOpen,G as isFolder,di as kindOf,Ur as kindRows,Qe as line,nn as markdown,Q as mirrorFile,$ as mkdirp,w as models,jr as moreItems,gi as moveFile,Ze as mute,ti as noPoint,kn as openChat,Qr as openDrawer,Or as pageMenu,et as pale,si as parentOf,Y as pathname,Ge as place,Ue as prev,at as quota,J as r2,Wr as recentRows,_i as removeFile,yi as renameFile,$n as restoreChat,vi as restoreFile,Ir as rowCls,tr as runChat,pi as saveFile,_ as side,mt as sizeOf,kr as spMenu,pt as stamp,He as stop,Dr as storageMenu,Cr as storageName,Kr as storageRows,mi as storeFiles,hi as syncFiles,Qn as toMsg,jn as toggleChat,Gr as trashRows,Hr as treeOf,_t as unique,wr as upgradeLabel,Tr as upgradeUrl,st as uploadAlert,ot as uploadMax,q as url,ht as usageOf,cr as useChatBusy,ri as useDrawer,ii as usePoint,xi as usedBytes,Yr as usedOf,y as vec2};
|
|
7
|
+
`);if(c===``)return;let l=s.flatMap(e=>e.tools.map(e=>e.name));r=[...r,{role:`user`,content:i},{role:`assistant`,content:c}];let u=n+1;n=u+l.length,e.store.save(t,{title:yi(i),seq:u,prompt:i,reply:c,model:o,tools:l.map((e,t)=>({seq:u+1+t,name:e}))})};return{wrap:e=>({...e,send:async(t,n)=>{let i=await e.send({...t,messages:r.slice(-40)},n);return s(t.prompt,i,t.model),i}}),reset:i,load:o,list:a}};export{fi as AiChat,ui as AiChatButton,rn as Band,Dn as Brand,nn as Cards,Vn as DriveTree,Je as Drop,hn as Fold,fn as Frame,ct as GB,ln as HeadBtn,_ as Icon,ut as KB,lt as MB,pn as Main,cn as MainHead,dn as MoreIcon,qe as Pop,gn as Row,st as SP_BREAK,kn as Side,Ue as Slot,un as SpBtn,sn as SpHead,On as Storage_,$t as Strip,ht as ago,$n as ancestors,qn as atPoint,et as band,wn as bandIcon,nt as blue,z as chatConfig,Gr as closeChat,Kn as closeDrawer,pr as configureChat,An as configureDrive,_i as createCommands,Ut as createFileDrag,Qt as createFileDrop,xi as createHistory,Et as createOver,zn as crumbSegs,zt as dragEvent,D as drawerAtom,T as driveConfig,Gt as dropEvent,Qe as edge,dr as emptyTrash,bn as emptyTrashAsk,nr as entryOf,er as extOf,tt as fill,Rn as folderRows,M as freeName,rt as grid,w as icons,Qn as idOf,Ye as ink,_r as isChatBusy,Hn as isDrawerOpen,E as isFolder,tr as kindOf,Pn as kindRows,Ze as line,hr as markdown,rr as mirrorFile,P as mkdirp,I as models,Tn as moreItems,sr as moveFile,Xe as mute,Jn as noPoint,Wr as openChat,Gn as openDrawer,Sn as pageMenu,$e as pale,Zn as parentOf,j as pathname,We as place,O as pointAtom,He as prev,it as quota,A as r2,Fn as recentRows,cr as removeFile,ur as renameFile,mi as restoreChat,lr as restoreFile,mn as rowCls,gi as runChat,ir as saveFile,v as side,pt as sizeOf,Cn as spMenu,ft as stamp,Ve as stop,xn as storageMenu,_n as storageName,Ln as storageRows,ar as storeFiles,or as syncFiles,pi as toMsg,Kr as toggleChat,In as trashRows,Nn as treeOf,gt as unique,vn as upgradeLabel,yn as upgradeUrl,ot as uploadAlert,at as uploadMax,k as url,mt as usageOf,vr as useChatBusy,Un as useDrawer,Wn as usePoint,fr as usedBytes,Bn as usedOf,b as vec2};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai-ax",
|
|
3
3
|
"author": "tseijp",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.10.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "AI Agent Experience (AI/AX) library for Hono + Cloudflare. One act surface for both human UI/UX and LLM MCP tools, with authentication, authorization, realtime sync and Claude API relay.",
|
|
7
7
|
"keywords": [
|