dong commited on
Commit
b93ecc4
·
0 Parent(s):

Initial commit with local project files

Browse files
.gitattributes ADDED
@@ -0,0 +1 @@
 
 
1
+ .output/** filter=lfs diff=lfs merge=lfs -text
.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ node_modules
2
+ .env
Dockerfile ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use the latest Node.js LTS version
2
+ FROM node:latest
3
+
4
+ # Install pnpm globally
5
+ RUN npm install -g pnpm
6
+
7
+ # Set working directory
8
+ WORKDIR /app
9
+
10
+ # Copy dist directory to the container
11
+ COPY dist ./dist
12
+
13
+ # Copy package.json to the container
14
+ COPY package.json ./
15
+
16
+ # Copy langgraph.json to the container
17
+ COPY langgraph.json ./
18
+
19
+ # Install dependencies using pnpm
20
+ RUN pnpm install
21
+
22
+ # Create a non-root user for security
23
+ RUN groupadd -r appuser && useradd -r -g appuser appuser
24
+ RUN chown -R appuser:appuser /app
25
+ USER appuser
26
+
27
+ # Expose the port
28
+ EXPOSE 7860
29
+
30
+ # Start the LangGraph agent server
31
+ CMD ["pnpm", "run", "start"]
README.md ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Auto Anime Agent
3
+ emoji: 🤖
4
+ colorFrom: blue
5
+ colorTo: purple
6
+ sdk: docker
7
+ pinned: false
8
+ app_file: app.py
9
+ ---
10
+
11
+ # Auto Anime Deploy
build.sh ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Set source path
4
+ SOURCE=../automotion
5
+
6
+ # Get absolute path of current script directory
7
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8
+
9
+ # Check if source directory exists
10
+ if [ ! -d "$SOURCE" ]; then
11
+ echo "Error: Source directory $SOURCE does not exist"
12
+ exit 1
13
+ fi
14
+
15
+ echo "Starting build process..."
16
+ echo "Source path: $SOURCE"
17
+ echo "Target path: $SCRIPT_DIR"
18
+
19
+ # Enter source directory
20
+ cd "$SOURCE" || {
21
+ echo "Error: Cannot enter directory $SOURCE"
22
+ exit 1
23
+ }
24
+
25
+ echo "Current directory: $(pwd)"
26
+
27
+ # Execute build script
28
+ echo "Executing bun scripts/build-langgraph.ts..."
29
+ bun scripts/build-langgraph.ts || {
30
+ echo "Error: Build script failed"
31
+ exit 1
32
+ }
33
+
34
+ # Remove existing dist directory if it exists
35
+ if [ -d "$SCRIPT_DIR/dist" ]; then
36
+ echo "Removing existing dist directory..."
37
+ rm -rf "$SCRIPT_DIR/dist" || {
38
+ echo "Error: Cannot remove existing dist directory"
39
+ exit 1
40
+ }
41
+ fi
42
+
43
+ # Copy dist/langgraph to current dist directory
44
+ if [ -d "dist/langgraph" ]; then
45
+ echo "Copying dist/langgraph to $SCRIPT_DIR/dist..."
46
+ mkdir -p "$SCRIPT_DIR"
47
+ cp -r "dist/langgraph" "$SCRIPT_DIR/dist" || {
48
+ echo "Error: Cannot copy dist/langgraph directory"
49
+ exit 1
50
+ }
51
+ echo "Copied dist/langgraph/"
52
+ else
53
+ echo "Error: dist/langgraph directory not found"
54
+ exit 1
55
+ fi
56
+
57
+ # Copy apps/web/package.json to current directory
58
+ if [ -f "apps/web/package.json" ]; then
59
+ echo "Copying apps/web/package.json..."
60
+ cp "apps/web/package.json" "$SCRIPT_DIR/" || {
61
+ echo "Error: Cannot copy package.json"
62
+ exit 1
63
+ }
64
+ echo "Copied package.json"
65
+ else
66
+ echo "Error: apps/web/package.json file not found"
67
+ exit 1
68
+ fi
69
+
70
+ echo "Build completed!"
dist/agent.mjs ADDED
The diff for this file is too large to render. See raw diff
 
dist/chunk-Dx39-ABv.mjs ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { createRequire } from "node:module";
2
+
3
+ //#region rolldown:runtime
4
+ var __create = Object.create;
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __commonJS = (cb, mod) => function() {
11
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12
+ };
13
+ var __export = (target, all) => {
14
+ for (var name in all) __defProp(target, name, {
15
+ get: all[name],
16
+ enumerable: true
17
+ });
18
+ };
19
+ var __copyProps = (to, from, except, desc) => {
20
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
21
+ key = keys[i];
22
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
23
+ get: ((k) => from[k]).bind(null, key),
24
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
25
+ });
26
+ }
27
+ return to;
28
+ };
29
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
30
+ value: mod,
31
+ enumerable: true
32
+ }) : target, mod));
33
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
34
+
35
+ //#endregion
36
+ export { __commonJS, __export, __require, __toESM };
dist/few_shot-BBzZpDUy.mjs ADDED
@@ -0,0 +1,1526 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { __export } from "./chunk-Dx39-ABv.mjs";
2
+ import { AIMessage, AIMessageChunk, BaseMessage, BaseMessageChunk, BasePromptTemplate, BaseStringPromptTemplate, ChatMessage, ChatMessageChunk, ChatPromptValue, FunctionMessage, FunctionMessageChunk, HumanMessage, HumanMessageChunk, ImagePromptValue, PromptTemplate, Runnable, RunnableLambda, SystemMessage, SystemMessageChunk, ToolMessage, ToolMessageChunk, _isMessageFieldWithRole, _mergeDicts, _mergeLists, _mergeObj, _mergeStatus, addLangChainErrorFields, checkValidTemplate, coerceMessageLikeToMessage, convertToChunk, convertToOpenAIImageBlock, convertToProviderContentBlock, getBufferString, isAIMessage, isAIMessageChunk, isBase64ContentBlock, isBaseMessage, isBaseMessageChunk, isChatMessage, isChatMessageChunk, isDataContentBlock, isFunctionMessage, isFunctionMessageChunk, isHumanMessage, isHumanMessageChunk, isIDContentBlock, isOpenAIToolCallArray, isPlainTextContentBlock, isSystemMessage, isSystemMessageChunk, isToolMessage, isToolMessageChunk, isURLContentBlock, mapChatMessagesToStoredMessages, mapStoredMessageToChatMessage, mapStoredMessagesToChatMessages, mergeContent, parseBase64DataUrl, parseFString, parseMimeType, parseMustache, parseTemplate, renderTemplate } from "./prompt-Cmq1pjHH.mjs";
3
+
4
+ //#region node_modules/.pnpm/@[email protected][email protected][email protected][email protected]_/node_modules/@langchain/core/dist/messages/modifier.js
5
+ /**
6
+ * Message responsible for deleting other messages.
7
+ */
8
+ var RemoveMessage = class extends BaseMessage {
9
+ constructor(fields) {
10
+ super({
11
+ ...fields,
12
+ content: ""
13
+ });
14
+ /**
15
+ * The ID of the message to remove.
16
+ */
17
+ Object.defineProperty(this, "id", {
18
+ enumerable: true,
19
+ configurable: true,
20
+ writable: true,
21
+ value: void 0
22
+ });
23
+ this.id = fields.id;
24
+ }
25
+ _getType() {
26
+ return "remove";
27
+ }
28
+ get _printableFields() {
29
+ return {
30
+ ...super._printableFields,
31
+ id: this.id
32
+ };
33
+ }
34
+ };
35
+
36
+ //#endregion
37
+ //#region node_modules/.pnpm/@[email protected][email protected][email protected][email protected]_/node_modules/@langchain/core/dist/messages/transformers.js
38
+ const _isMessageType = (msg, types) => {
39
+ const typesAsStrings = [...new Set(types?.map((t) => {
40
+ if (typeof t === "string") return t;
41
+ const instantiatedMsgClass = new t({});
42
+ if (!("getType" in instantiatedMsgClass) || typeof instantiatedMsgClass.getType !== "function") throw new Error("Invalid type provided.");
43
+ return instantiatedMsgClass.getType();
44
+ }))];
45
+ const msgType = msg.getType();
46
+ return typesAsStrings.some((t) => t === msgType);
47
+ };
48
+ function filterMessages(messagesOrOptions, options) {
49
+ if (Array.isArray(messagesOrOptions)) return _filterMessages(messagesOrOptions, options);
50
+ return RunnableLambda.from((input) => {
51
+ return _filterMessages(input, messagesOrOptions);
52
+ });
53
+ }
54
+ function _filterMessages(messages, options = {}) {
55
+ const { includeNames, excludeNames, includeTypes, excludeTypes, includeIds, excludeIds } = options;
56
+ const filtered = [];
57
+ for (const msg of messages) {
58
+ if (excludeNames && msg.name && excludeNames.includes(msg.name)) continue;
59
+ else if (excludeTypes && _isMessageType(msg, excludeTypes)) continue;
60
+ else if (excludeIds && msg.id && excludeIds.includes(msg.id)) continue;
61
+ if (!(includeTypes || includeIds || includeNames)) filtered.push(msg);
62
+ else if (includeNames && msg.name && includeNames.some((iName) => iName === msg.name)) filtered.push(msg);
63
+ else if (includeTypes && _isMessageType(msg, includeTypes)) filtered.push(msg);
64
+ else if (includeIds && msg.id && includeIds.some((id) => id === msg.id)) filtered.push(msg);
65
+ }
66
+ return filtered;
67
+ }
68
+ function mergeMessageRuns(messages) {
69
+ if (Array.isArray(messages)) return _mergeMessageRuns(messages);
70
+ return RunnableLambda.from(_mergeMessageRuns);
71
+ }
72
+ function _mergeMessageRuns(messages) {
73
+ if (!messages.length) return [];
74
+ const merged = [];
75
+ for (const msg of messages) {
76
+ const curr = msg;
77
+ const last = merged.pop();
78
+ if (!last) merged.push(curr);
79
+ else if (curr.getType() === "tool" || !(curr.getType() === last.getType())) merged.push(last, curr);
80
+ else {
81
+ const lastChunk = convertToChunk(last);
82
+ const currChunk = convertToChunk(curr);
83
+ const mergedChunks = lastChunk.concat(currChunk);
84
+ if (typeof lastChunk.content === "string" && typeof currChunk.content === "string") mergedChunks.content = `${lastChunk.content}\n${currChunk.content}`;
85
+ merged.push(_chunkToMsg(mergedChunks));
86
+ }
87
+ }
88
+ return merged;
89
+ }
90
+ function trimMessages(messagesOrOptions, options) {
91
+ if (Array.isArray(messagesOrOptions)) {
92
+ const messages = messagesOrOptions;
93
+ if (!options) throw new Error("Options parameter is required when providing messages.");
94
+ return _trimMessagesHelper(messages, options);
95
+ } else {
96
+ const trimmerOptions = messagesOrOptions;
97
+ return RunnableLambda.from((input) => _trimMessagesHelper(input, trimmerOptions)).withConfig({ runName: "trim_messages" });
98
+ }
99
+ }
100
+ async function _trimMessagesHelper(messages, options) {
101
+ const { maxTokens, tokenCounter, strategy = "last", allowPartial = false, endOn, startOn, includeSystem = false, textSplitter } = options;
102
+ if (startOn && strategy === "first") throw new Error("`startOn` should only be specified if `strategy` is 'last'.");
103
+ if (includeSystem && strategy === "first") throw new Error("`includeSystem` should only be specified if `strategy` is 'last'.");
104
+ let listTokenCounter;
105
+ if ("getNumTokens" in tokenCounter) listTokenCounter = async (msgs) => {
106
+ const tokenCounts = await Promise.all(msgs.map((msg) => tokenCounter.getNumTokens(msg.content)));
107
+ return tokenCounts.reduce((sum, count) => sum + count, 0);
108
+ };
109
+ else listTokenCounter = async (msgs) => tokenCounter(msgs);
110
+ let textSplitterFunc = defaultTextSplitter;
111
+ if (textSplitter) if ("splitText" in textSplitter) textSplitterFunc = textSplitter.splitText;
112
+ else textSplitterFunc = async (text) => textSplitter(text);
113
+ if (strategy === "first") return _firstMaxTokens(messages, {
114
+ maxTokens,
115
+ tokenCounter: listTokenCounter,
116
+ textSplitter: textSplitterFunc,
117
+ partialStrategy: allowPartial ? "first" : void 0,
118
+ endOn
119
+ });
120
+ else if (strategy === "last") return _lastMaxTokens(messages, {
121
+ maxTokens,
122
+ tokenCounter: listTokenCounter,
123
+ textSplitter: textSplitterFunc,
124
+ allowPartial,
125
+ includeSystem,
126
+ startOn,
127
+ endOn
128
+ });
129
+ else throw new Error(`Unrecognized strategy: '${strategy}'. Must be one of 'first' or 'last'.`);
130
+ }
131
+ async function _firstMaxTokens(messages, options) {
132
+ const { maxTokens, tokenCounter, textSplitter, partialStrategy, endOn } = options;
133
+ let messagesCopy = [...messages];
134
+ let idx = 0;
135
+ for (let i = 0; i < messagesCopy.length; i += 1) {
136
+ const remainingMessages = i > 0 ? messagesCopy.slice(0, -i) : messagesCopy;
137
+ if (await tokenCounter(remainingMessages) <= maxTokens) {
138
+ idx = messagesCopy.length - i;
139
+ break;
140
+ }
141
+ }
142
+ if (idx < messagesCopy.length - 1 && partialStrategy) {
143
+ let includedPartial = false;
144
+ if (Array.isArray(messagesCopy[idx].content)) {
145
+ const excluded = messagesCopy[idx];
146
+ if (typeof excluded.content === "string") throw new Error("Expected content to be an array.");
147
+ const numBlock = excluded.content.length;
148
+ const reversedContent = partialStrategy === "last" ? [...excluded.content].reverse() : excluded.content;
149
+ for (let i = 1; i <= numBlock; i += 1) {
150
+ const partialContent = partialStrategy === "first" ? reversedContent.slice(0, i) : reversedContent.slice(-i);
151
+ const fields = Object.fromEntries(Object.entries(excluded).filter(([k]) => k !== "type" && !k.startsWith("lc_")));
152
+ const updatedMessage = _switchTypeToMessage(excluded.getType(), {
153
+ ...fields,
154
+ content: partialContent
155
+ });
156
+ const slicedMessages = [...messagesCopy.slice(0, idx), updatedMessage];
157
+ if (await tokenCounter(slicedMessages) <= maxTokens) {
158
+ messagesCopy = slicedMessages;
159
+ idx += 1;
160
+ includedPartial = true;
161
+ } else break;
162
+ }
163
+ if (includedPartial && partialStrategy === "last") excluded.content = [...reversedContent].reverse();
164
+ }
165
+ if (!includedPartial) {
166
+ const excluded = messagesCopy[idx];
167
+ let text;
168
+ if (Array.isArray(excluded.content) && excluded.content.some((block) => typeof block === "string" || block.type === "text")) {
169
+ const textBlock = excluded.content.find((block) => block.type === "text" && block.text);
170
+ text = textBlock?.text;
171
+ } else if (typeof excluded.content === "string") text = excluded.content;
172
+ if (text) {
173
+ const splitTexts = await textSplitter(text);
174
+ const numSplits = splitTexts.length;
175
+ if (partialStrategy === "last") splitTexts.reverse();
176
+ for (let _ = 0; _ < numSplits - 1; _ += 1) {
177
+ splitTexts.pop();
178
+ excluded.content = splitTexts.join("");
179
+ if (await tokenCounter([...messagesCopy.slice(0, idx), excluded]) <= maxTokens) {
180
+ if (partialStrategy === "last") excluded.content = [...splitTexts].reverse().join("");
181
+ messagesCopy = [...messagesCopy.slice(0, idx), excluded];
182
+ idx += 1;
183
+ break;
184
+ }
185
+ }
186
+ }
187
+ }
188
+ }
189
+ if (endOn) {
190
+ const endOnArr = Array.isArray(endOn) ? endOn : [endOn];
191
+ while (idx > 0 && !_isMessageType(messagesCopy[idx - 1], endOnArr)) idx -= 1;
192
+ }
193
+ return messagesCopy.slice(0, idx);
194
+ }
195
+ async function _lastMaxTokens(messages, options) {
196
+ const { allowPartial = false, includeSystem = false, endOn, startOn,...rest } = options;
197
+ let messagesCopy = messages.map((message) => {
198
+ const fields = Object.fromEntries(Object.entries(message).filter(([k]) => k !== "type" && !k.startsWith("lc_")));
199
+ return _switchTypeToMessage(message.getType(), fields, isBaseMessageChunk(message));
200
+ });
201
+ if (endOn) {
202
+ const endOnArr = Array.isArray(endOn) ? endOn : [endOn];
203
+ while (messagesCopy.length > 0 && !_isMessageType(messagesCopy[messagesCopy.length - 1], endOnArr)) messagesCopy = messagesCopy.slice(0, -1);
204
+ }
205
+ const swappedSystem = includeSystem && messagesCopy[0]?.getType() === "system";
206
+ let reversed_ = swappedSystem ? messagesCopy.slice(0, 1).concat(messagesCopy.slice(1).reverse()) : messagesCopy.reverse();
207
+ reversed_ = await _firstMaxTokens(reversed_, {
208
+ ...rest,
209
+ partialStrategy: allowPartial ? "last" : void 0,
210
+ endOn: startOn
211
+ });
212
+ if (swappedSystem) return [reversed_[0], ...reversed_.slice(1).reverse()];
213
+ else return reversed_.reverse();
214
+ }
215
+ const _MSG_CHUNK_MAP = {
216
+ human: {
217
+ message: HumanMessage,
218
+ messageChunk: HumanMessageChunk
219
+ },
220
+ ai: {
221
+ message: AIMessage,
222
+ messageChunk: AIMessageChunk
223
+ },
224
+ system: {
225
+ message: SystemMessage,
226
+ messageChunk: SystemMessageChunk
227
+ },
228
+ developer: {
229
+ message: SystemMessage,
230
+ messageChunk: SystemMessageChunk
231
+ },
232
+ tool: {
233
+ message: ToolMessage,
234
+ messageChunk: ToolMessageChunk
235
+ },
236
+ function: {
237
+ message: FunctionMessage,
238
+ messageChunk: FunctionMessageChunk
239
+ },
240
+ generic: {
241
+ message: ChatMessage,
242
+ messageChunk: ChatMessageChunk
243
+ },
244
+ remove: {
245
+ message: RemoveMessage,
246
+ messageChunk: RemoveMessage
247
+ }
248
+ };
249
+ function _switchTypeToMessage(messageType, fields, returnChunk) {
250
+ let chunk;
251
+ let msg;
252
+ switch (messageType) {
253
+ case "human":
254
+ if (returnChunk) chunk = new HumanMessageChunk(fields);
255
+ else msg = new HumanMessage(fields);
256
+ break;
257
+ case "ai":
258
+ if (returnChunk) {
259
+ let aiChunkFields = { ...fields };
260
+ if ("tool_calls" in aiChunkFields) aiChunkFields = {
261
+ ...aiChunkFields,
262
+ tool_call_chunks: aiChunkFields.tool_calls?.map((tc) => ({
263
+ ...tc,
264
+ type: "tool_call_chunk",
265
+ index: void 0,
266
+ args: JSON.stringify(tc.args)
267
+ }))
268
+ };
269
+ chunk = new AIMessageChunk(aiChunkFields);
270
+ } else msg = new AIMessage(fields);
271
+ break;
272
+ case "system":
273
+ if (returnChunk) chunk = new SystemMessageChunk(fields);
274
+ else msg = new SystemMessage(fields);
275
+ break;
276
+ case "developer":
277
+ if (returnChunk) chunk = new SystemMessageChunk({
278
+ ...fields,
279
+ additional_kwargs: {
280
+ ...fields.additional_kwargs,
281
+ __openai_role__: "developer"
282
+ }
283
+ });
284
+ else msg = new SystemMessage({
285
+ ...fields,
286
+ additional_kwargs: {
287
+ ...fields.additional_kwargs,
288
+ __openai_role__: "developer"
289
+ }
290
+ });
291
+ break;
292
+ case "tool":
293
+ if ("tool_call_id" in fields) if (returnChunk) chunk = new ToolMessageChunk(fields);
294
+ else msg = new ToolMessage(fields);
295
+ else throw new Error("Can not convert ToolMessage to ToolMessageChunk if 'tool_call_id' field is not defined.");
296
+ break;
297
+ case "function":
298
+ if (returnChunk) chunk = new FunctionMessageChunk(fields);
299
+ else {
300
+ if (!fields.name) throw new Error("FunctionMessage must have a 'name' field");
301
+ msg = new FunctionMessage(fields);
302
+ }
303
+ break;
304
+ case "generic":
305
+ if ("role" in fields) if (returnChunk) chunk = new ChatMessageChunk(fields);
306
+ else msg = new ChatMessage(fields);
307
+ else throw new Error("Can not convert ChatMessage to ChatMessageChunk if 'role' field is not defined.");
308
+ break;
309
+ default: throw new Error(`Unrecognized message type ${messageType}`);
310
+ }
311
+ if (returnChunk && chunk) return chunk;
312
+ if (msg) return msg;
313
+ throw new Error(`Unrecognized message type ${messageType}`);
314
+ }
315
+ function _chunkToMsg(chunk) {
316
+ const chunkType = chunk.getType();
317
+ let msg;
318
+ const fields = Object.fromEntries(Object.entries(chunk).filter(([k]) => !["type", "tool_call_chunks"].includes(k) && !k.startsWith("lc_")));
319
+ if (chunkType in _MSG_CHUNK_MAP) msg = _switchTypeToMessage(chunkType, fields);
320
+ if (!msg) throw new Error(`Unrecognized message chunk class ${chunkType}. Supported classes are ${Object.keys(_MSG_CHUNK_MAP)}`);
321
+ return msg;
322
+ }
323
+ /**
324
+ * The default text splitter function that splits text by newlines.
325
+ *
326
+ * @param {string} text
327
+ * @returns A promise that resolves to an array of strings split by newlines.
328
+ */
329
+ function defaultTextSplitter(text) {
330
+ const splits = text.split("\n");
331
+ return Promise.resolve([...splits.slice(0, -1).map((s) => `${s}\n`), splits[splits.length - 1]]);
332
+ }
333
+
334
+ //#endregion
335
+ //#region node_modules/.pnpm/@[email protected][email protected][email protected][email protected]_/node_modules/@langchain/core/dist/messages/index.js
336
+ var messages_exports = {};
337
+ __export(messages_exports, {
338
+ AIMessage: () => AIMessage,
339
+ AIMessageChunk: () => AIMessageChunk,
340
+ BaseMessage: () => BaseMessage,
341
+ BaseMessageChunk: () => BaseMessageChunk,
342
+ ChatMessage: () => ChatMessage,
343
+ ChatMessageChunk: () => ChatMessageChunk,
344
+ FunctionMessage: () => FunctionMessage,
345
+ FunctionMessageChunk: () => FunctionMessageChunk,
346
+ HumanMessage: () => HumanMessage,
347
+ HumanMessageChunk: () => HumanMessageChunk,
348
+ RemoveMessage: () => RemoveMessage,
349
+ SystemMessage: () => SystemMessage,
350
+ SystemMessageChunk: () => SystemMessageChunk,
351
+ ToolMessage: () => ToolMessage,
352
+ ToolMessageChunk: () => ToolMessageChunk,
353
+ _isMessageFieldWithRole: () => _isMessageFieldWithRole,
354
+ _mergeDicts: () => _mergeDicts,
355
+ _mergeLists: () => _mergeLists,
356
+ _mergeObj: () => _mergeObj,
357
+ _mergeStatus: () => _mergeStatus,
358
+ coerceMessageLikeToMessage: () => coerceMessageLikeToMessage,
359
+ convertToChunk: () => convertToChunk,
360
+ convertToOpenAIImageBlock: () => convertToOpenAIImageBlock,
361
+ convertToProviderContentBlock: () => convertToProviderContentBlock,
362
+ defaultTextSplitter: () => defaultTextSplitter,
363
+ filterMessages: () => filterMessages,
364
+ getBufferString: () => getBufferString,
365
+ isAIMessage: () => isAIMessage,
366
+ isAIMessageChunk: () => isAIMessageChunk,
367
+ isBase64ContentBlock: () => isBase64ContentBlock,
368
+ isBaseMessage: () => isBaseMessage,
369
+ isBaseMessageChunk: () => isBaseMessageChunk,
370
+ isChatMessage: () => isChatMessage,
371
+ isChatMessageChunk: () => isChatMessageChunk,
372
+ isDataContentBlock: () => isDataContentBlock,
373
+ isFunctionMessage: () => isFunctionMessage,
374
+ isFunctionMessageChunk: () => isFunctionMessageChunk,
375
+ isHumanMessage: () => isHumanMessage,
376
+ isHumanMessageChunk: () => isHumanMessageChunk,
377
+ isIDContentBlock: () => isIDContentBlock,
378
+ isOpenAIToolCallArray: () => isOpenAIToolCallArray,
379
+ isPlainTextContentBlock: () => isPlainTextContentBlock,
380
+ isSystemMessage: () => isSystemMessage,
381
+ isSystemMessageChunk: () => isSystemMessageChunk,
382
+ isToolMessage: () => isToolMessage,
383
+ isToolMessageChunk: () => isToolMessageChunk,
384
+ isURLContentBlock: () => isURLContentBlock,
385
+ mapChatMessagesToStoredMessages: () => mapChatMessagesToStoredMessages,
386
+ mapStoredMessageToChatMessage: () => mapStoredMessageToChatMessage,
387
+ mapStoredMessagesToChatMessages: () => mapStoredMessagesToChatMessages,
388
+ mergeContent: () => mergeContent,
389
+ mergeMessageRuns: () => mergeMessageRuns,
390
+ parseBase64DataUrl: () => parseBase64DataUrl,
391
+ parseMimeType: () => parseMimeType,
392
+ trimMessages: () => trimMessages
393
+ });
394
+
395
+ //#endregion
396
+ //#region node_modules/.pnpm/@[email protected][email protected][email protected][email protected]_/node_modules/@langchain/core/dist/prompts/image.js
397
+ /**
398
+ * An image prompt template for a multimodal model.
399
+ */
400
+ var ImagePromptTemplate = class ImagePromptTemplate extends BasePromptTemplate {
401
+ static lc_name() {
402
+ return "ImagePromptTemplate";
403
+ }
404
+ constructor(input) {
405
+ super(input);
406
+ Object.defineProperty(this, "lc_namespace", {
407
+ enumerable: true,
408
+ configurable: true,
409
+ writable: true,
410
+ value: [
411
+ "langchain_core",
412
+ "prompts",
413
+ "image"
414
+ ]
415
+ });
416
+ Object.defineProperty(this, "template", {
417
+ enumerable: true,
418
+ configurable: true,
419
+ writable: true,
420
+ value: void 0
421
+ });
422
+ Object.defineProperty(this, "templateFormat", {
423
+ enumerable: true,
424
+ configurable: true,
425
+ writable: true,
426
+ value: "f-string"
427
+ });
428
+ Object.defineProperty(this, "validateTemplate", {
429
+ enumerable: true,
430
+ configurable: true,
431
+ writable: true,
432
+ value: true
433
+ });
434
+ /**
435
+ * Additional fields which should be included inside
436
+ * the message content array if using a complex message
437
+ * content.
438
+ */
439
+ Object.defineProperty(this, "additionalContentFields", {
440
+ enumerable: true,
441
+ configurable: true,
442
+ writable: true,
443
+ value: void 0
444
+ });
445
+ this.template = input.template;
446
+ this.templateFormat = input.templateFormat ?? this.templateFormat;
447
+ this.validateTemplate = input.validateTemplate ?? this.validateTemplate;
448
+ this.additionalContentFields = input.additionalContentFields;
449
+ if (this.validateTemplate) {
450
+ let totalInputVariables = this.inputVariables;
451
+ if (this.partialVariables) totalInputVariables = totalInputVariables.concat(Object.keys(this.partialVariables));
452
+ checkValidTemplate([{
453
+ type: "image_url",
454
+ image_url: this.template
455
+ }], this.templateFormat, totalInputVariables);
456
+ }
457
+ }
458
+ _getPromptType() {
459
+ return "prompt";
460
+ }
461
+ /**
462
+ * Partially applies values to the prompt template.
463
+ * @param values The values to be partially applied to the prompt template.
464
+ * @returns A new instance of ImagePromptTemplate with the partially applied values.
465
+ */
466
+ async partial(values) {
467
+ const newInputVariables = this.inputVariables.filter((iv) => !(iv in values));
468
+ const newPartialVariables = {
469
+ ...this.partialVariables ?? {},
470
+ ...values
471
+ };
472
+ const promptDict = {
473
+ ...this,
474
+ inputVariables: newInputVariables,
475
+ partialVariables: newPartialVariables
476
+ };
477
+ return new ImagePromptTemplate(promptDict);
478
+ }
479
+ /**
480
+ * Formats the prompt template with the provided values.
481
+ * @param values The values to be used to format the prompt template.
482
+ * @returns A promise that resolves to a string which is the formatted prompt.
483
+ */
484
+ async format(values) {
485
+ const formatted = {};
486
+ for (const [key, value] of Object.entries(this.template)) if (typeof value === "string") formatted[key] = renderTemplate(value, this.templateFormat, values);
487
+ else formatted[key] = value;
488
+ const url = values.url || formatted.url;
489
+ const detail = values.detail || formatted.detail;
490
+ if (!url) throw new Error("Must provide either an image URL.");
491
+ if (typeof url !== "string") throw new Error("url must be a string.");
492
+ const output = { url };
493
+ if (detail) output.detail = detail;
494
+ return output;
495
+ }
496
+ /**
497
+ * Formats the prompt given the input values and returns a formatted
498
+ * prompt value.
499
+ * @param values The input values to format the prompt.
500
+ * @returns A Promise that resolves to a formatted prompt value.
501
+ */
502
+ async formatPromptValue(values) {
503
+ const formattedPrompt = await this.format(values);
504
+ return new ImagePromptValue(formattedPrompt);
505
+ }
506
+ };
507
+
508
+ //#endregion
509
+ //#region node_modules/.pnpm/@[email protected][email protected][email protected][email protected]_/node_modules/@langchain/core/dist/prompts/dict.js
510
+ var DictPromptTemplate = class extends Runnable {
511
+ static lc_name() {
512
+ return "DictPromptTemplate";
513
+ }
514
+ constructor(fields) {
515
+ const templateFormat = fields.templateFormat ?? "f-string";
516
+ const inputVariables = _getInputVariables(fields.template, templateFormat);
517
+ super({
518
+ inputVariables,
519
+ ...fields
520
+ });
521
+ Object.defineProperty(this, "lc_namespace", {
522
+ enumerable: true,
523
+ configurable: true,
524
+ writable: true,
525
+ value: [
526
+ "langchain_core",
527
+ "prompts",
528
+ "dict"
529
+ ]
530
+ });
531
+ Object.defineProperty(this, "lc_serializable", {
532
+ enumerable: true,
533
+ configurable: true,
534
+ writable: true,
535
+ value: true
536
+ });
537
+ Object.defineProperty(this, "template", {
538
+ enumerable: true,
539
+ configurable: true,
540
+ writable: true,
541
+ value: void 0
542
+ });
543
+ Object.defineProperty(this, "templateFormat", {
544
+ enumerable: true,
545
+ configurable: true,
546
+ writable: true,
547
+ value: void 0
548
+ });
549
+ Object.defineProperty(this, "inputVariables", {
550
+ enumerable: true,
551
+ configurable: true,
552
+ writable: true,
553
+ value: void 0
554
+ });
555
+ this.template = fields.template;
556
+ this.templateFormat = templateFormat;
557
+ this.inputVariables = inputVariables;
558
+ }
559
+ async format(values) {
560
+ return _insertInputVariables(this.template, values, this.templateFormat);
561
+ }
562
+ async invoke(values) {
563
+ return await this._callWithConfig(this.format.bind(this), values, { runType: "prompt" });
564
+ }
565
+ };
566
+ function _getInputVariables(template, templateFormat) {
567
+ const inputVariables = [];
568
+ for (const v of Object.values(template)) if (typeof v === "string") parseTemplate(v, templateFormat).forEach((t) => {
569
+ if (t.type === "variable") inputVariables.push(t.name);
570
+ });
571
+ else if (Array.isArray(v)) {
572
+ for (const x of v) if (typeof x === "string") parseTemplate(x, templateFormat).forEach((t) => {
573
+ if (t.type === "variable") inputVariables.push(t.name);
574
+ });
575
+ else if (typeof x === "object") inputVariables.push(..._getInputVariables(x, templateFormat));
576
+ } else if (typeof v === "object" && v !== null) inputVariables.push(..._getInputVariables(v, templateFormat));
577
+ return Array.from(new Set(inputVariables));
578
+ }
579
+ function _insertInputVariables(template, inputs, templateFormat) {
580
+ const formatted = {};
581
+ for (const [k, v] of Object.entries(template)) if (typeof v === "string") formatted[k] = renderTemplate(v, templateFormat, inputs);
582
+ else if (Array.isArray(v)) {
583
+ const formattedV = [];
584
+ for (const x of v) if (typeof x === "string") formattedV.push(renderTemplate(x, templateFormat, inputs));
585
+ else if (typeof x === "object") formattedV.push(_insertInputVariables(x, inputs, templateFormat));
586
+ formatted[k] = formattedV;
587
+ } else if (typeof v === "object" && v !== null) formatted[k] = _insertInputVariables(v, inputs, templateFormat);
588
+ else formatted[k] = v;
589
+ return formatted;
590
+ }
591
+
592
+ //#endregion
593
+ //#region node_modules/.pnpm/@[email protected][email protected][email protected][email protected]_/node_modules/@langchain/core/dist/prompts/chat.js
594
+ /**
595
+ * Abstract class that serves as a base for creating message prompt
596
+ * templates. It defines how to format messages for different roles in a
597
+ * conversation.
598
+ */
599
+ var BaseMessagePromptTemplate = class extends Runnable {
600
+ constructor() {
601
+ super(...arguments);
602
+ Object.defineProperty(this, "lc_namespace", {
603
+ enumerable: true,
604
+ configurable: true,
605
+ writable: true,
606
+ value: [
607
+ "langchain_core",
608
+ "prompts",
609
+ "chat"
610
+ ]
611
+ });
612
+ Object.defineProperty(this, "lc_serializable", {
613
+ enumerable: true,
614
+ configurable: true,
615
+ writable: true,
616
+ value: true
617
+ });
618
+ }
619
+ /**
620
+ * Calls the formatMessages method with the provided input and options.
621
+ * @param input Input for the formatMessages method
622
+ * @param options Optional BaseCallbackConfig
623
+ * @returns Formatted output messages
624
+ */
625
+ async invoke(input, options) {
626
+ return this._callWithConfig((input$1) => this.formatMessages(input$1), input, {
627
+ ...options,
628
+ runType: "prompt"
629
+ });
630
+ }
631
+ };
632
+ /**
633
+ * Class that represents a placeholder for messages in a chat prompt. It
634
+ * extends the BaseMessagePromptTemplate.
635
+ */
636
+ var MessagesPlaceholder = class extends BaseMessagePromptTemplate {
637
+ static lc_name() {
638
+ return "MessagesPlaceholder";
639
+ }
640
+ constructor(fields) {
641
+ if (typeof fields === "string") fields = { variableName: fields };
642
+ super(fields);
643
+ Object.defineProperty(this, "variableName", {
644
+ enumerable: true,
645
+ configurable: true,
646
+ writable: true,
647
+ value: void 0
648
+ });
649
+ Object.defineProperty(this, "optional", {
650
+ enumerable: true,
651
+ configurable: true,
652
+ writable: true,
653
+ value: void 0
654
+ });
655
+ this.variableName = fields.variableName;
656
+ this.optional = fields.optional ?? false;
657
+ }
658
+ get inputVariables() {
659
+ return [this.variableName];
660
+ }
661
+ async formatMessages(values) {
662
+ const input = values[this.variableName];
663
+ if (this.optional && !input) return [];
664
+ else if (!input) {
665
+ const error = new Error(`Field "${this.variableName}" in prompt uses a MessagesPlaceholder, which expects an array of BaseMessages as an input value. Received: undefined`);
666
+ error.name = "InputFormatError";
667
+ throw error;
668
+ }
669
+ let formattedMessages;
670
+ try {
671
+ if (Array.isArray(input)) formattedMessages = input.map(coerceMessageLikeToMessage);
672
+ else formattedMessages = [coerceMessageLikeToMessage(input)];
673
+ } catch (e) {
674
+ const readableInput = typeof input === "string" ? input : JSON.stringify(input, null, 2);
675
+ const error = new Error([
676
+ `Field "${this.variableName}" in prompt uses a MessagesPlaceholder, which expects an array of BaseMessages or coerceable values as input.`,
677
+ `Received value: ${readableInput}`,
678
+ `Additional message: ${e.message}`
679
+ ].join("\n\n"));
680
+ error.name = "InputFormatError";
681
+ error.lc_error_code = e.lc_error_code;
682
+ throw error;
683
+ }
684
+ return formattedMessages;
685
+ }
686
+ };
687
+ /**
688
+ * Abstract class that serves as a base for creating message string prompt
689
+ * templates. It extends the BaseMessagePromptTemplate.
690
+ */
691
+ var BaseMessageStringPromptTemplate = class extends BaseMessagePromptTemplate {
692
+ constructor(fields) {
693
+ if (!("prompt" in fields)) fields = { prompt: fields };
694
+ super(fields);
695
+ Object.defineProperty(this, "prompt", {
696
+ enumerable: true,
697
+ configurable: true,
698
+ writable: true,
699
+ value: void 0
700
+ });
701
+ this.prompt = fields.prompt;
702
+ }
703
+ get inputVariables() {
704
+ return this.prompt.inputVariables;
705
+ }
706
+ async formatMessages(values) {
707
+ return [await this.format(values)];
708
+ }
709
+ };
710
+ /**
711
+ * Abstract class that serves as a base for creating chat prompt
712
+ * templates. It extends the BasePromptTemplate.
713
+ */
714
+ var BaseChatPromptTemplate = class extends BasePromptTemplate {
715
+ constructor(input) {
716
+ super(input);
717
+ }
718
+ async format(values) {
719
+ return (await this.formatPromptValue(values)).toString();
720
+ }
721
+ async formatPromptValue(values) {
722
+ const resultMessages = await this.formatMessages(values);
723
+ return new ChatPromptValue(resultMessages);
724
+ }
725
+ };
726
+ /**
727
+ * Class that represents a chat message prompt template. It extends the
728
+ * BaseMessageStringPromptTemplate.
729
+ */
730
+ var ChatMessagePromptTemplate = class extends BaseMessageStringPromptTemplate {
731
+ static lc_name() {
732
+ return "ChatMessagePromptTemplate";
733
+ }
734
+ constructor(fields, role) {
735
+ if (!("prompt" in fields)) fields = {
736
+ prompt: fields,
737
+ role
738
+ };
739
+ super(fields);
740
+ Object.defineProperty(this, "role", {
741
+ enumerable: true,
742
+ configurable: true,
743
+ writable: true,
744
+ value: void 0
745
+ });
746
+ this.role = fields.role;
747
+ }
748
+ async format(values) {
749
+ return new ChatMessage(await this.prompt.format(values), this.role);
750
+ }
751
+ static fromTemplate(template, role, options) {
752
+ return new this(PromptTemplate.fromTemplate(template, { templateFormat: options?.templateFormat }), role);
753
+ }
754
+ };
755
+ function isTextTemplateParam(param) {
756
+ if (param === null || typeof param !== "object" || Array.isArray(param)) return false;
757
+ return Object.keys(param).length === 1 && "text" in param && typeof param.text === "string";
758
+ }
759
+ function isImageTemplateParam(param) {
760
+ if (param === null || typeof param !== "object" || Array.isArray(param)) return false;
761
+ return "image_url" in param && (typeof param.image_url === "string" || typeof param.image_url === "object" && param.image_url !== null && "url" in param.image_url && typeof param.image_url.url === "string");
762
+ }
763
+ var _StringImageMessagePromptTemplate = class extends BaseMessagePromptTemplate {
764
+ static _messageClass() {
765
+ throw new Error("Can not invoke _messageClass from inside _StringImageMessagePromptTemplate");
766
+ }
767
+ constructor(fields, additionalOptions) {
768
+ if (!("prompt" in fields)) fields = { prompt: fields };
769
+ super(fields);
770
+ Object.defineProperty(this, "lc_namespace", {
771
+ enumerable: true,
772
+ configurable: true,
773
+ writable: true,
774
+ value: [
775
+ "langchain_core",
776
+ "prompts",
777
+ "chat"
778
+ ]
779
+ });
780
+ Object.defineProperty(this, "lc_serializable", {
781
+ enumerable: true,
782
+ configurable: true,
783
+ writable: true,
784
+ value: true
785
+ });
786
+ Object.defineProperty(this, "inputVariables", {
787
+ enumerable: true,
788
+ configurable: true,
789
+ writable: true,
790
+ value: []
791
+ });
792
+ Object.defineProperty(this, "additionalOptions", {
793
+ enumerable: true,
794
+ configurable: true,
795
+ writable: true,
796
+ value: {}
797
+ });
798
+ Object.defineProperty(this, "prompt", {
799
+ enumerable: true,
800
+ configurable: true,
801
+ writable: true,
802
+ value: void 0
803
+ });
804
+ Object.defineProperty(this, "messageClass", {
805
+ enumerable: true,
806
+ configurable: true,
807
+ writable: true,
808
+ value: void 0
809
+ });
810
+ Object.defineProperty(this, "chatMessageClass", {
811
+ enumerable: true,
812
+ configurable: true,
813
+ writable: true,
814
+ value: void 0
815
+ });
816
+ this.prompt = fields.prompt;
817
+ if (Array.isArray(this.prompt)) {
818
+ let inputVariables = [];
819
+ this.prompt.forEach((prompt) => {
820
+ if ("inputVariables" in prompt) inputVariables = inputVariables.concat(prompt.inputVariables);
821
+ });
822
+ this.inputVariables = inputVariables;
823
+ } else this.inputVariables = this.prompt.inputVariables;
824
+ this.additionalOptions = additionalOptions ?? this.additionalOptions;
825
+ }
826
+ createMessage(content) {
827
+ const constructor = this.constructor;
828
+ if (constructor._messageClass()) {
829
+ const MsgClass = constructor._messageClass();
830
+ return new MsgClass({ content });
831
+ } else if (constructor.chatMessageClass) {
832
+ const MsgClass = constructor.chatMessageClass();
833
+ return new MsgClass({
834
+ content,
835
+ role: this.getRoleFromMessageClass(MsgClass.lc_name())
836
+ });
837
+ } else throw new Error("No message class defined");
838
+ }
839
+ getRoleFromMessageClass(name) {
840
+ switch (name) {
841
+ case "HumanMessage": return "human";
842
+ case "AIMessage": return "ai";
843
+ case "SystemMessage": return "system";
844
+ case "ChatMessage": return "chat";
845
+ default: throw new Error("Invalid message class name");
846
+ }
847
+ }
848
+ static fromTemplate(template, additionalOptions) {
849
+ if (typeof template === "string") return new this(PromptTemplate.fromTemplate(template, additionalOptions));
850
+ const prompt = [];
851
+ for (const item of template) if (typeof item === "string") prompt.push(PromptTemplate.fromTemplate(item, additionalOptions));
852
+ else if (item === null) {} else if (isTextTemplateParam(item)) {
853
+ let text = "";
854
+ if (typeof item.text === "string") text = item.text ?? "";
855
+ const options = {
856
+ ...additionalOptions,
857
+ additionalContentFields: item
858
+ };
859
+ prompt.push(PromptTemplate.fromTemplate(text, options));
860
+ } else if (isImageTemplateParam(item)) {
861
+ let imgTemplate = item.image_url ?? "";
862
+ let imgTemplateObject;
863
+ let inputVariables = [];
864
+ if (typeof imgTemplate === "string") {
865
+ let parsedTemplate;
866
+ if (additionalOptions?.templateFormat === "mustache") parsedTemplate = parseMustache(imgTemplate);
867
+ else parsedTemplate = parseFString(imgTemplate);
868
+ const variables = parsedTemplate.flatMap((item$1) => item$1.type === "variable" ? [item$1.name] : []);
869
+ if ((variables?.length ?? 0) > 0) {
870
+ if (variables.length > 1) throw new Error(`Only one format variable allowed per image template.\nGot: ${variables}\nFrom: ${imgTemplate}`);
871
+ inputVariables = [variables[0]];
872
+ } else inputVariables = [];
873
+ imgTemplate = { url: imgTemplate };
874
+ imgTemplateObject = new ImagePromptTemplate({
875
+ template: imgTemplate,
876
+ inputVariables,
877
+ templateFormat: additionalOptions?.templateFormat,
878
+ additionalContentFields: item
879
+ });
880
+ } else if (typeof imgTemplate === "object") {
881
+ if ("url" in imgTemplate) {
882
+ let parsedTemplate;
883
+ if (additionalOptions?.templateFormat === "mustache") parsedTemplate = parseMustache(imgTemplate.url);
884
+ else parsedTemplate = parseFString(imgTemplate.url);
885
+ inputVariables = parsedTemplate.flatMap((item$1) => item$1.type === "variable" ? [item$1.name] : []);
886
+ } else inputVariables = [];
887
+ imgTemplateObject = new ImagePromptTemplate({
888
+ template: imgTemplate,
889
+ inputVariables,
890
+ templateFormat: additionalOptions?.templateFormat,
891
+ additionalContentFields: item
892
+ });
893
+ } else throw new Error("Invalid image template");
894
+ prompt.push(imgTemplateObject);
895
+ } else if (typeof item === "object") prompt.push(new DictPromptTemplate({
896
+ template: item,
897
+ templateFormat: additionalOptions?.templateFormat
898
+ }));
899
+ return new this({
900
+ prompt,
901
+ additionalOptions
902
+ });
903
+ }
904
+ async format(input) {
905
+ if (this.prompt instanceof BaseStringPromptTemplate) {
906
+ const text = await this.prompt.format(input);
907
+ return this.createMessage(text);
908
+ } else {
909
+ const content = [];
910
+ for (const prompt of this.prompt) {
911
+ let inputs = {};
912
+ if (!("inputVariables" in prompt)) throw new Error(`Prompt ${prompt} does not have inputVariables defined.`);
913
+ for (const item of prompt.inputVariables) {
914
+ if (!inputs) inputs = { [item]: input[item] };
915
+ inputs = {
916
+ ...inputs,
917
+ [item]: input[item]
918
+ };
919
+ }
920
+ if (prompt instanceof BaseStringPromptTemplate) {
921
+ const formatted = await prompt.format(inputs);
922
+ let additionalContentFields;
923
+ if ("additionalContentFields" in prompt) additionalContentFields = prompt.additionalContentFields;
924
+ content.push({
925
+ ...additionalContentFields,
926
+ type: "text",
927
+ text: formatted
928
+ });
929
+ } else if (prompt instanceof ImagePromptTemplate) {
930
+ const formatted = await prompt.format(inputs);
931
+ let additionalContentFields;
932
+ if ("additionalContentFields" in prompt) additionalContentFields = prompt.additionalContentFields;
933
+ content.push({
934
+ ...additionalContentFields,
935
+ type: "image_url",
936
+ image_url: formatted
937
+ });
938
+ } else if (prompt instanceof DictPromptTemplate) {
939
+ const formatted = await prompt.format(inputs);
940
+ let additionalContentFields;
941
+ if ("additionalContentFields" in prompt) additionalContentFields = prompt.additionalContentFields;
942
+ content.push({
943
+ ...additionalContentFields,
944
+ ...formatted
945
+ });
946
+ }
947
+ }
948
+ return this.createMessage(content);
949
+ }
950
+ }
951
+ async formatMessages(values) {
952
+ return [await this.format(values)];
953
+ }
954
+ };
955
+ /**
956
+ * Class that represents a human message prompt template. It extends the
957
+ * BaseMessageStringPromptTemplate.
958
+ * @example
959
+ * ```typescript
960
+ * const message = HumanMessagePromptTemplate.fromTemplate("{text}");
961
+ * const formatted = await message.format({ text: "Hello world!" });
962
+ *
963
+ * const chatPrompt = ChatPromptTemplate.fromMessages([message]);
964
+ * const formattedChatPrompt = await chatPrompt.invoke({
965
+ * text: "Hello world!",
966
+ * });
967
+ * ```
968
+ */
969
+ var HumanMessagePromptTemplate = class extends _StringImageMessagePromptTemplate {
970
+ static _messageClass() {
971
+ return HumanMessage;
972
+ }
973
+ static lc_name() {
974
+ return "HumanMessagePromptTemplate";
975
+ }
976
+ };
977
+ /**
978
+ * Class that represents an AI message prompt template. It extends the
979
+ * BaseMessageStringPromptTemplate.
980
+ */
981
+ var AIMessagePromptTemplate = class extends _StringImageMessagePromptTemplate {
982
+ static _messageClass() {
983
+ return AIMessage;
984
+ }
985
+ static lc_name() {
986
+ return "AIMessagePromptTemplate";
987
+ }
988
+ };
989
+ /**
990
+ * Class that represents a system message prompt template. It extends the
991
+ * BaseMessageStringPromptTemplate.
992
+ * @example
993
+ * ```typescript
994
+ * const message = SystemMessagePromptTemplate.fromTemplate("{text}");
995
+ * const formatted = await message.format({ text: "Hello world!" });
996
+ *
997
+ * const chatPrompt = ChatPromptTemplate.fromMessages([message]);
998
+ * const formattedChatPrompt = await chatPrompt.invoke({
999
+ * text: "Hello world!",
1000
+ * });
1001
+ * ```
1002
+ */
1003
+ var SystemMessagePromptTemplate = class extends _StringImageMessagePromptTemplate {
1004
+ static _messageClass() {
1005
+ return SystemMessage;
1006
+ }
1007
+ static lc_name() {
1008
+ return "SystemMessagePromptTemplate";
1009
+ }
1010
+ };
1011
+ function _isBaseMessagePromptTemplate(baseMessagePromptTemplateLike) {
1012
+ return typeof baseMessagePromptTemplateLike.formatMessages === "function";
1013
+ }
1014
+ function _coerceMessagePromptTemplateLike(messagePromptTemplateLike, extra) {
1015
+ if (_isBaseMessagePromptTemplate(messagePromptTemplateLike) || isBaseMessage(messagePromptTemplateLike)) return messagePromptTemplateLike;
1016
+ if (Array.isArray(messagePromptTemplateLike) && messagePromptTemplateLike[0] === "placeholder") {
1017
+ const messageContent = messagePromptTemplateLike[1];
1018
+ if (extra?.templateFormat === "mustache" && typeof messageContent === "string" && messageContent.slice(0, 2) === "{{" && messageContent.slice(-2) === "}}") {
1019
+ const variableName = messageContent.slice(2, -2);
1020
+ return new MessagesPlaceholder({
1021
+ variableName,
1022
+ optional: true
1023
+ });
1024
+ } else if (typeof messageContent === "string" && messageContent[0] === "{" && messageContent[messageContent.length - 1] === "}") {
1025
+ const variableName = messageContent.slice(1, -1);
1026
+ return new MessagesPlaceholder({
1027
+ variableName,
1028
+ optional: true
1029
+ });
1030
+ }
1031
+ throw new Error(`Invalid placeholder template for format ${extra?.templateFormat ?? `"f-string"`}: "${messagePromptTemplateLike[1]}". Expected a variable name surrounded by ${extra?.templateFormat === "mustache" ? "double" : "single"} curly braces.`);
1032
+ }
1033
+ const message = coerceMessageLikeToMessage(messagePromptTemplateLike);
1034
+ let templateData;
1035
+ if (typeof message.content === "string") templateData = message.content;
1036
+ else templateData = message.content.map((item) => {
1037
+ if ("text" in item) return {
1038
+ ...item,
1039
+ text: item.text
1040
+ };
1041
+ else if ("image_url" in item) return {
1042
+ ...item,
1043
+ image_url: item.image_url
1044
+ };
1045
+ else return item;
1046
+ });
1047
+ if (message._getType() === "human") return HumanMessagePromptTemplate.fromTemplate(templateData, extra);
1048
+ else if (message._getType() === "ai") return AIMessagePromptTemplate.fromTemplate(templateData, extra);
1049
+ else if (message._getType() === "system") return SystemMessagePromptTemplate.fromTemplate(templateData, extra);
1050
+ else if (ChatMessage.isInstance(message)) return ChatMessagePromptTemplate.fromTemplate(message.content, message.role, extra);
1051
+ else throw new Error(`Could not coerce message prompt template from input. Received message type: "${message._getType()}".`);
1052
+ }
1053
+ function isMessagesPlaceholder(x) {
1054
+ return x.constructor.lc_name() === "MessagesPlaceholder";
1055
+ }
1056
+ /**
1057
+ * Class that represents a chat prompt. It extends the
1058
+ * BaseChatPromptTemplate and uses an array of BaseMessagePromptTemplate
1059
+ * instances to format a series of messages for a conversation.
1060
+ * @example
1061
+ * ```typescript
1062
+ * const message = SystemMessagePromptTemplate.fromTemplate("{text}");
1063
+ * const chatPrompt = ChatPromptTemplate.fromMessages([
1064
+ * ["ai", "You are a helpful assistant."],
1065
+ * message,
1066
+ * ]);
1067
+ * const formattedChatPrompt = await chatPrompt.invoke({
1068
+ * text: "Hello world!",
1069
+ * });
1070
+ * ```
1071
+ */
1072
+ var ChatPromptTemplate = class ChatPromptTemplate extends BaseChatPromptTemplate {
1073
+ static lc_name() {
1074
+ return "ChatPromptTemplate";
1075
+ }
1076
+ get lc_aliases() {
1077
+ return { promptMessages: "messages" };
1078
+ }
1079
+ constructor(input) {
1080
+ super(input);
1081
+ Object.defineProperty(this, "promptMessages", {
1082
+ enumerable: true,
1083
+ configurable: true,
1084
+ writable: true,
1085
+ value: void 0
1086
+ });
1087
+ Object.defineProperty(this, "validateTemplate", {
1088
+ enumerable: true,
1089
+ configurable: true,
1090
+ writable: true,
1091
+ value: true
1092
+ });
1093
+ Object.defineProperty(this, "templateFormat", {
1094
+ enumerable: true,
1095
+ configurable: true,
1096
+ writable: true,
1097
+ value: "f-string"
1098
+ });
1099
+ if (input.templateFormat === "mustache" && input.validateTemplate === void 0) this.validateTemplate = false;
1100
+ Object.assign(this, input);
1101
+ if (this.validateTemplate) {
1102
+ const inputVariablesMessages = /* @__PURE__ */ new Set();
1103
+ for (const promptMessage of this.promptMessages) {
1104
+ if (promptMessage instanceof BaseMessage) continue;
1105
+ for (const inputVariable of promptMessage.inputVariables) inputVariablesMessages.add(inputVariable);
1106
+ }
1107
+ const totalInputVariables = this.inputVariables;
1108
+ const inputVariablesInstance = new Set(this.partialVariables ? totalInputVariables.concat(Object.keys(this.partialVariables)) : totalInputVariables);
1109
+ const difference = new Set([...inputVariablesInstance].filter((x) => !inputVariablesMessages.has(x)));
1110
+ if (difference.size > 0) throw new Error(`Input variables \`${[...difference]}\` are not used in any of the prompt messages.`);
1111
+ const otherDifference = new Set([...inputVariablesMessages].filter((x) => !inputVariablesInstance.has(x)));
1112
+ if (otherDifference.size > 0) throw new Error(`Input variables \`${[...otherDifference]}\` are used in prompt messages but not in the prompt template.`);
1113
+ }
1114
+ }
1115
+ _getPromptType() {
1116
+ return "chat";
1117
+ }
1118
+ async _parseImagePrompts(message, inputValues) {
1119
+ if (typeof message.content === "string") return message;
1120
+ const formattedMessageContent = await Promise.all(message.content.map(async (item) => {
1121
+ if (item.type !== "image_url") return item;
1122
+ let imageUrl = "";
1123
+ if (typeof item.image_url === "string") imageUrl = item.image_url;
1124
+ else imageUrl = item.image_url.url;
1125
+ const promptTemplatePlaceholder = PromptTemplate.fromTemplate(imageUrl, { templateFormat: this.templateFormat });
1126
+ const formattedUrl = await promptTemplatePlaceholder.format(inputValues);
1127
+ if (typeof item.image_url !== "string" && "url" in item.image_url) item.image_url.url = formattedUrl;
1128
+ else item.image_url = formattedUrl;
1129
+ return item;
1130
+ }));
1131
+ message.content = formattedMessageContent;
1132
+ return message;
1133
+ }
1134
+ async formatMessages(values) {
1135
+ const allValues = await this.mergePartialAndUserVariables(values);
1136
+ let resultMessages = [];
1137
+ for (const promptMessage of this.promptMessages) if (promptMessage instanceof BaseMessage) resultMessages.push(await this._parseImagePrompts(promptMessage, allValues));
1138
+ else {
1139
+ const inputValues = promptMessage.inputVariables.reduce((acc, inputVariable) => {
1140
+ if (!(inputVariable in allValues) && !(isMessagesPlaceholder(promptMessage) && promptMessage.optional)) {
1141
+ const error = addLangChainErrorFields(new Error(`Missing value for input variable \`${inputVariable.toString()}\``), "INVALID_PROMPT_INPUT");
1142
+ throw error;
1143
+ }
1144
+ acc[inputVariable] = allValues[inputVariable];
1145
+ return acc;
1146
+ }, {});
1147
+ const message = await promptMessage.formatMessages(inputValues);
1148
+ resultMessages = resultMessages.concat(message);
1149
+ }
1150
+ return resultMessages;
1151
+ }
1152
+ async partial(values) {
1153
+ const newInputVariables = this.inputVariables.filter((iv) => !(iv in values));
1154
+ const newPartialVariables = {
1155
+ ...this.partialVariables ?? {},
1156
+ ...values
1157
+ };
1158
+ const promptDict = {
1159
+ ...this,
1160
+ inputVariables: newInputVariables,
1161
+ partialVariables: newPartialVariables
1162
+ };
1163
+ return new ChatPromptTemplate(promptDict);
1164
+ }
1165
+ static fromTemplate(template, options) {
1166
+ const prompt = PromptTemplate.fromTemplate(template, options);
1167
+ const humanTemplate = new HumanMessagePromptTemplate({ prompt });
1168
+ return this.fromMessages([humanTemplate]);
1169
+ }
1170
+ /**
1171
+ * Create a chat model-specific prompt from individual chat messages
1172
+ * or message-like tuples.
1173
+ * @param promptMessages Messages to be passed to the chat model
1174
+ * @returns A new ChatPromptTemplate
1175
+ */
1176
+ static fromMessages(promptMessages, extra) {
1177
+ const flattenedMessages = promptMessages.reduce((acc, promptMessage) => acc.concat(promptMessage instanceof ChatPromptTemplate ? promptMessage.promptMessages : [_coerceMessagePromptTemplateLike(promptMessage, extra)]), []);
1178
+ const flattenedPartialVariables = promptMessages.reduce((acc, promptMessage) => promptMessage instanceof ChatPromptTemplate ? Object.assign(acc, promptMessage.partialVariables) : acc, Object.create(null));
1179
+ const inputVariables = /* @__PURE__ */ new Set();
1180
+ for (const promptMessage of flattenedMessages) {
1181
+ if (promptMessage instanceof BaseMessage) continue;
1182
+ for (const inputVariable of promptMessage.inputVariables) {
1183
+ if (inputVariable in flattenedPartialVariables) continue;
1184
+ inputVariables.add(inputVariable);
1185
+ }
1186
+ }
1187
+ return new this({
1188
+ ...extra,
1189
+ inputVariables: [...inputVariables],
1190
+ promptMessages: flattenedMessages,
1191
+ partialVariables: flattenedPartialVariables,
1192
+ templateFormat: extra?.templateFormat
1193
+ });
1194
+ }
1195
+ /** @deprecated Renamed to .fromMessages */
1196
+ static fromPromptMessages(promptMessages) {
1197
+ return this.fromMessages(promptMessages);
1198
+ }
1199
+ };
1200
+
1201
+ //#endregion
1202
+ //#region node_modules/.pnpm/@[email protected][email protected][email protected][email protected]_/node_modules/@langchain/core/dist/prompts/few_shot.js
1203
+ /**
1204
+ * Prompt template that contains few-shot examples.
1205
+ * @augments BasePromptTemplate
1206
+ * @augments FewShotPromptTemplateInput
1207
+ * @example
1208
+ * ```typescript
1209
+ * const examplePrompt = PromptTemplate.fromTemplate(
1210
+ * "Input: {input}\nOutput: {output}",
1211
+ * );
1212
+ *
1213
+ * const exampleSelector = await SemanticSimilarityExampleSelector.fromExamples(
1214
+ * [
1215
+ * { input: "happy", output: "sad" },
1216
+ * { input: "tall", output: "short" },
1217
+ * { input: "energetic", output: "lethargic" },
1218
+ * { input: "sunny", output: "gloomy" },
1219
+ * { input: "windy", output: "calm" },
1220
+ * ],
1221
+ * new OpenAIEmbeddings(),
1222
+ * HNSWLib,
1223
+ * { k: 1 },
1224
+ * );
1225
+ *
1226
+ * const dynamicPrompt = new FewShotPromptTemplate({
1227
+ * exampleSelector,
1228
+ * examplePrompt,
1229
+ * prefix: "Give the antonym of every input",
1230
+ * suffix: "Input: {adjective}\nOutput:",
1231
+ * inputVariables: ["adjective"],
1232
+ * });
1233
+ *
1234
+ * // Format the dynamic prompt with the input 'rainy'
1235
+ * console.log(await dynamicPrompt.format({ adjective: "rainy" }));
1236
+ *
1237
+ * ```
1238
+ */
1239
+ var FewShotPromptTemplate = class FewShotPromptTemplate extends BaseStringPromptTemplate {
1240
+ constructor(input) {
1241
+ super(input);
1242
+ Object.defineProperty(this, "lc_serializable", {
1243
+ enumerable: true,
1244
+ configurable: true,
1245
+ writable: true,
1246
+ value: false
1247
+ });
1248
+ Object.defineProperty(this, "examples", {
1249
+ enumerable: true,
1250
+ configurable: true,
1251
+ writable: true,
1252
+ value: void 0
1253
+ });
1254
+ Object.defineProperty(this, "exampleSelector", {
1255
+ enumerable: true,
1256
+ configurable: true,
1257
+ writable: true,
1258
+ value: void 0
1259
+ });
1260
+ Object.defineProperty(this, "examplePrompt", {
1261
+ enumerable: true,
1262
+ configurable: true,
1263
+ writable: true,
1264
+ value: void 0
1265
+ });
1266
+ Object.defineProperty(this, "suffix", {
1267
+ enumerable: true,
1268
+ configurable: true,
1269
+ writable: true,
1270
+ value: ""
1271
+ });
1272
+ Object.defineProperty(this, "exampleSeparator", {
1273
+ enumerable: true,
1274
+ configurable: true,
1275
+ writable: true,
1276
+ value: "\n\n"
1277
+ });
1278
+ Object.defineProperty(this, "prefix", {
1279
+ enumerable: true,
1280
+ configurable: true,
1281
+ writable: true,
1282
+ value: ""
1283
+ });
1284
+ Object.defineProperty(this, "templateFormat", {
1285
+ enumerable: true,
1286
+ configurable: true,
1287
+ writable: true,
1288
+ value: "f-string"
1289
+ });
1290
+ Object.defineProperty(this, "validateTemplate", {
1291
+ enumerable: true,
1292
+ configurable: true,
1293
+ writable: true,
1294
+ value: true
1295
+ });
1296
+ Object.assign(this, input);
1297
+ if (this.examples !== void 0 && this.exampleSelector !== void 0) throw new Error("Only one of 'examples' and 'example_selector' should be provided");
1298
+ if (this.examples === void 0 && this.exampleSelector === void 0) throw new Error("One of 'examples' and 'example_selector' should be provided");
1299
+ if (this.validateTemplate) {
1300
+ let totalInputVariables = this.inputVariables;
1301
+ if (this.partialVariables) totalInputVariables = totalInputVariables.concat(Object.keys(this.partialVariables));
1302
+ checkValidTemplate(this.prefix + this.suffix, this.templateFormat, totalInputVariables);
1303
+ }
1304
+ }
1305
+ _getPromptType() {
1306
+ return "few_shot";
1307
+ }
1308
+ static lc_name() {
1309
+ return "FewShotPromptTemplate";
1310
+ }
1311
+ async getExamples(inputVariables) {
1312
+ if (this.examples !== void 0) return this.examples;
1313
+ if (this.exampleSelector !== void 0) return this.exampleSelector.selectExamples(inputVariables);
1314
+ throw new Error("One of 'examples' and 'example_selector' should be provided");
1315
+ }
1316
+ async partial(values) {
1317
+ const newInputVariables = this.inputVariables.filter((iv) => !(iv in values));
1318
+ const newPartialVariables = {
1319
+ ...this.partialVariables ?? {},
1320
+ ...values
1321
+ };
1322
+ const promptDict = {
1323
+ ...this,
1324
+ inputVariables: newInputVariables,
1325
+ partialVariables: newPartialVariables
1326
+ };
1327
+ return new FewShotPromptTemplate(promptDict);
1328
+ }
1329
+ /**
1330
+ * Formats the prompt with the given values.
1331
+ * @param values The values to format the prompt with.
1332
+ * @returns A promise that resolves to a string representing the formatted prompt.
1333
+ */
1334
+ async format(values) {
1335
+ const allValues = await this.mergePartialAndUserVariables(values);
1336
+ const examples = await this.getExamples(allValues);
1337
+ const exampleStrings = await Promise.all(examples.map((example) => this.examplePrompt.format(example)));
1338
+ const template = [
1339
+ this.prefix,
1340
+ ...exampleStrings,
1341
+ this.suffix
1342
+ ].join(this.exampleSeparator);
1343
+ return renderTemplate(template, this.templateFormat, allValues);
1344
+ }
1345
+ serialize() {
1346
+ if (this.exampleSelector || !this.examples) throw new Error("Serializing an example selector is not currently supported");
1347
+ if (this.outputParser !== void 0) throw new Error("Serializing an output parser is not currently supported");
1348
+ return {
1349
+ _type: this._getPromptType(),
1350
+ input_variables: this.inputVariables,
1351
+ example_prompt: this.examplePrompt.serialize(),
1352
+ example_separator: this.exampleSeparator,
1353
+ suffix: this.suffix,
1354
+ prefix: this.prefix,
1355
+ template_format: this.templateFormat,
1356
+ examples: this.examples
1357
+ };
1358
+ }
1359
+ static async deserialize(data) {
1360
+ const { example_prompt } = data;
1361
+ if (!example_prompt) throw new Error("Missing example prompt");
1362
+ const examplePrompt = await PromptTemplate.deserialize(example_prompt);
1363
+ let examples;
1364
+ if (Array.isArray(data.examples)) examples = data.examples;
1365
+ else throw new Error("Invalid examples format. Only list or string are supported.");
1366
+ return new FewShotPromptTemplate({
1367
+ inputVariables: data.input_variables,
1368
+ examplePrompt,
1369
+ examples,
1370
+ exampleSeparator: data.example_separator,
1371
+ prefix: data.prefix,
1372
+ suffix: data.suffix,
1373
+ templateFormat: data.template_format
1374
+ });
1375
+ }
1376
+ };
1377
+ /**
1378
+ * Chat prompt template that contains few-shot examples.
1379
+ * @augments BasePromptTemplateInput
1380
+ * @augments FewShotChatMessagePromptTemplateInput
1381
+ */
1382
+ var FewShotChatMessagePromptTemplate = class FewShotChatMessagePromptTemplate extends BaseChatPromptTemplate {
1383
+ _getPromptType() {
1384
+ return "few_shot_chat";
1385
+ }
1386
+ static lc_name() {
1387
+ return "FewShotChatMessagePromptTemplate";
1388
+ }
1389
+ constructor(fields) {
1390
+ super(fields);
1391
+ Object.defineProperty(this, "lc_serializable", {
1392
+ enumerable: true,
1393
+ configurable: true,
1394
+ writable: true,
1395
+ value: true
1396
+ });
1397
+ Object.defineProperty(this, "examples", {
1398
+ enumerable: true,
1399
+ configurable: true,
1400
+ writable: true,
1401
+ value: void 0
1402
+ });
1403
+ Object.defineProperty(this, "exampleSelector", {
1404
+ enumerable: true,
1405
+ configurable: true,
1406
+ writable: true,
1407
+ value: void 0
1408
+ });
1409
+ Object.defineProperty(this, "examplePrompt", {
1410
+ enumerable: true,
1411
+ configurable: true,
1412
+ writable: true,
1413
+ value: void 0
1414
+ });
1415
+ Object.defineProperty(this, "suffix", {
1416
+ enumerable: true,
1417
+ configurable: true,
1418
+ writable: true,
1419
+ value: ""
1420
+ });
1421
+ Object.defineProperty(this, "exampleSeparator", {
1422
+ enumerable: true,
1423
+ configurable: true,
1424
+ writable: true,
1425
+ value: "\n\n"
1426
+ });
1427
+ Object.defineProperty(this, "prefix", {
1428
+ enumerable: true,
1429
+ configurable: true,
1430
+ writable: true,
1431
+ value: ""
1432
+ });
1433
+ Object.defineProperty(this, "templateFormat", {
1434
+ enumerable: true,
1435
+ configurable: true,
1436
+ writable: true,
1437
+ value: "f-string"
1438
+ });
1439
+ Object.defineProperty(this, "validateTemplate", {
1440
+ enumerable: true,
1441
+ configurable: true,
1442
+ writable: true,
1443
+ value: true
1444
+ });
1445
+ this.examples = fields.examples;
1446
+ this.examplePrompt = fields.examplePrompt;
1447
+ this.exampleSeparator = fields.exampleSeparator ?? "\n\n";
1448
+ this.exampleSelector = fields.exampleSelector;
1449
+ this.prefix = fields.prefix ?? "";
1450
+ this.suffix = fields.suffix ?? "";
1451
+ this.templateFormat = fields.templateFormat ?? "f-string";
1452
+ this.validateTemplate = fields.validateTemplate ?? true;
1453
+ if (this.examples !== void 0 && this.exampleSelector !== void 0) throw new Error("Only one of 'examples' and 'example_selector' should be provided");
1454
+ if (this.examples === void 0 && this.exampleSelector === void 0) throw new Error("One of 'examples' and 'example_selector' should be provided");
1455
+ if (this.validateTemplate) {
1456
+ let totalInputVariables = this.inputVariables;
1457
+ if (this.partialVariables) totalInputVariables = totalInputVariables.concat(Object.keys(this.partialVariables));
1458
+ checkValidTemplate(this.prefix + this.suffix, this.templateFormat, totalInputVariables);
1459
+ }
1460
+ }
1461
+ async getExamples(inputVariables) {
1462
+ if (this.examples !== void 0) return this.examples;
1463
+ if (this.exampleSelector !== void 0) return this.exampleSelector.selectExamples(inputVariables);
1464
+ throw new Error("One of 'examples' and 'example_selector' should be provided");
1465
+ }
1466
+ /**
1467
+ * Formats the list of values and returns a list of formatted messages.
1468
+ * @param values The values to format the prompt with.
1469
+ * @returns A promise that resolves to a string representing the formatted prompt.
1470
+ */
1471
+ async formatMessages(values) {
1472
+ const allValues = await this.mergePartialAndUserVariables(values);
1473
+ let examples = await this.getExamples(allValues);
1474
+ examples = examples.map((example) => {
1475
+ const result = {};
1476
+ this.examplePrompt.inputVariables.forEach((inputVariable) => {
1477
+ result[inputVariable] = example[inputVariable];
1478
+ });
1479
+ return result;
1480
+ });
1481
+ const messages = [];
1482
+ for (const example of examples) {
1483
+ const exampleMessages = await this.examplePrompt.formatMessages(example);
1484
+ messages.push(...exampleMessages);
1485
+ }
1486
+ return messages;
1487
+ }
1488
+ /**
1489
+ * Formats the prompt with the given values.
1490
+ * @param values The values to format the prompt with.
1491
+ * @returns A promise that resolves to a string representing the formatted prompt.
1492
+ */
1493
+ async format(values) {
1494
+ const allValues = await this.mergePartialAndUserVariables(values);
1495
+ const examples = await this.getExamples(allValues);
1496
+ const exampleMessages = await Promise.all(examples.map((example) => this.examplePrompt.formatMessages(example)));
1497
+ const exampleStrings = exampleMessages.flat().map((message) => message.content);
1498
+ const template = [
1499
+ this.prefix,
1500
+ ...exampleStrings,
1501
+ this.suffix
1502
+ ].join(this.exampleSeparator);
1503
+ return renderTemplate(template, this.templateFormat, allValues);
1504
+ }
1505
+ /**
1506
+ * Partially formats the prompt with the given values.
1507
+ * @param values The values to partially format the prompt with.
1508
+ * @returns A promise that resolves to an instance of `FewShotChatMessagePromptTemplate` with the given values partially formatted.
1509
+ */
1510
+ async partial(values) {
1511
+ const newInputVariables = this.inputVariables.filter((variable) => !(variable in values));
1512
+ const newPartialVariables = {
1513
+ ...this.partialVariables ?? {},
1514
+ ...values
1515
+ };
1516
+ const promptDict = {
1517
+ ...this,
1518
+ inputVariables: newInputVariables,
1519
+ partialVariables: newPartialVariables
1520
+ };
1521
+ return new FewShotChatMessagePromptTemplate(promptDict);
1522
+ }
1523
+ };
1524
+
1525
+ //#endregion
1526
+ export { AIMessagePromptTemplate, BaseChatPromptTemplate, BaseMessagePromptTemplate, BaseMessageStringPromptTemplate, ChatMessagePromptTemplate, ChatPromptTemplate, DictPromptTemplate, FewShotChatMessagePromptTemplate, FewShotPromptTemplate, HumanMessagePromptTemplate, ImagePromptTemplate, MessagesPlaceholder, SystemMessagePromptTemplate, messages_exports };
dist/few_shot-C9MZ9K-V.mjs ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ import "./prompt-Cmq1pjHH.mjs";
2
+ import { FewShotChatMessagePromptTemplate, FewShotPromptTemplate } from "./few_shot-BBzZpDUy.mjs";
3
+
4
+ export { FewShotPromptTemplate };
dist/fileFromPath-Dg7PGDJc.mjs ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { __commonJS, __require, __toESM } from "./chunk-Dx39-ABv.mjs";
2
+ import { File, isFile } from "./isFile-CMs-SNI_.mjs";
3
+ import { createReadStream, promises } from "fs";
4
+ import { basename } from "path";
5
+
6
+ //#region node_modules/.pnpm/[email protected]/node_modules/node-domexception/index.js
7
+ var require_node_domexception = __commonJS({ "node_modules/.pnpm/[email protected]/node_modules/node-domexception/index.js"(exports, module) {
8
+ /*! node-domexception. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
9
+ if (!globalThis.DOMException) try {
10
+ const { MessageChannel } = __require("worker_threads"), port = new MessageChannel().port1, ab = new ArrayBuffer();
11
+ port.postMessage(ab, [ab, ab]);
12
+ } catch (err) {
13
+ err.constructor.name === "DOMException" && (globalThis.DOMException = err.constructor);
14
+ }
15
+ module.exports = globalThis.DOMException;
16
+ } });
17
+
18
+ //#endregion
19
+ //#region node_modules/.pnpm/[email protected]/node_modules/formdata-node/lib/esm/isPlainObject.js
20
+ const getType = (value) => Object.prototype.toString.call(value).slice(8, -1).toLowerCase();
21
+ function isPlainObject(value) {
22
+ if (getType(value) !== "object") return false;
23
+ const pp = Object.getPrototypeOf(value);
24
+ if (pp === null || pp === void 0) return true;
25
+ const Ctor = pp.constructor && pp.constructor.toString();
26
+ return Ctor === Object.toString();
27
+ }
28
+ var isPlainObject_default = isPlainObject;
29
+
30
+ //#endregion
31
+ //#region node_modules/.pnpm/[email protected]/node_modules/formdata-node/lib/esm/fileFromPath.js
32
+ var import_node_domexception = __toESM(require_node_domexception(), 1);
33
+ var __classPrivateFieldSet = void 0 && (void 0).__classPrivateFieldSet || function(receiver, state, value, kind, f) {
34
+ if (kind === "m") throw new TypeError("Private method is not writable");
35
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
36
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
37
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
38
+ };
39
+ var __classPrivateFieldGet = void 0 && (void 0).__classPrivateFieldGet || function(receiver, state, kind, f) {
40
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
41
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
42
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
43
+ };
44
+ var _FileFromPath_path, _FileFromPath_start;
45
+ const MESSAGE = "The requested file could not be read, typically due to permission problems that have occurred after a reference to a file was acquired.";
46
+ var FileFromPath = class FileFromPath {
47
+ constructor(input) {
48
+ _FileFromPath_path.set(this, void 0);
49
+ _FileFromPath_start.set(this, void 0);
50
+ __classPrivateFieldSet(this, _FileFromPath_path, input.path, "f");
51
+ __classPrivateFieldSet(this, _FileFromPath_start, input.start || 0, "f");
52
+ this.name = basename(__classPrivateFieldGet(this, _FileFromPath_path, "f"));
53
+ this.size = input.size;
54
+ this.lastModified = input.lastModified;
55
+ }
56
+ slice(start, end) {
57
+ return new FileFromPath({
58
+ path: __classPrivateFieldGet(this, _FileFromPath_path, "f"),
59
+ lastModified: this.lastModified,
60
+ size: end - start,
61
+ start
62
+ });
63
+ }
64
+ async *stream() {
65
+ const { mtimeMs } = await promises.stat(__classPrivateFieldGet(this, _FileFromPath_path, "f"));
66
+ if (mtimeMs > this.lastModified) throw new import_node_domexception.default(MESSAGE, "NotReadableError");
67
+ if (this.size) yield* createReadStream(__classPrivateFieldGet(this, _FileFromPath_path, "f"), {
68
+ start: __classPrivateFieldGet(this, _FileFromPath_start, "f"),
69
+ end: __classPrivateFieldGet(this, _FileFromPath_start, "f") + this.size - 1
70
+ });
71
+ }
72
+ get [(_FileFromPath_path = /* @__PURE__ */ new WeakMap(), _FileFromPath_start = /* @__PURE__ */ new WeakMap(), Symbol.toStringTag)]() {
73
+ return "File";
74
+ }
75
+ };
76
+ function createFileFromPath(path, { mtimeMs, size }, filenameOrOptions, options = {}) {
77
+ let filename;
78
+ if (isPlainObject_default(filenameOrOptions)) [options, filename] = [filenameOrOptions, void 0];
79
+ else filename = filenameOrOptions;
80
+ const file = new FileFromPath({
81
+ path,
82
+ size,
83
+ lastModified: mtimeMs
84
+ });
85
+ if (!filename) filename = file.name;
86
+ return new File([file], filename, {
87
+ ...options,
88
+ lastModified: file.lastModified
89
+ });
90
+ }
91
+ async function fileFromPath(path, filenameOrOptions, options) {
92
+ const stats = await promises.stat(path);
93
+ return createFileFromPath(path, stats, filenameOrOptions, options);
94
+ }
95
+
96
+ //#endregion
97
+ export { fileFromPath };
dist/isFile-CMs-SNI_.mjs ADDED
@@ -0,0 +1,2250 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //#region node_modules/.pnpm/[email protected]/node_modules/web-streams-polyfill/dist/ponyfill.mjs
2
+ /**
3
+ * @license
4
+ * web-streams-polyfill v4.0.0-beta.3
5
+ * Copyright 2021 Mattias Buelens, Diwank Singh Tomer and other contributors.
6
+ * This code is released under the MIT license.
7
+ * SPDX-License-Identifier: MIT
8
+ */
9
+ const e = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? Symbol : (e$1) => `Symbol(${e$1})`;
10
+ function t() {}
11
+ function r(e$1) {
12
+ return "object" == typeof e$1 && null !== e$1 || "function" == typeof e$1;
13
+ }
14
+ const o = t;
15
+ function n(e$1, t$1) {
16
+ try {
17
+ Object.defineProperty(e$1, "name", {
18
+ value: t$1,
19
+ configurable: !0
20
+ });
21
+ } catch (e$2) {}
22
+ }
23
+ const a = Promise, i = Promise.prototype.then, l = Promise.resolve.bind(a), s = Promise.reject.bind(a);
24
+ function u(e$1) {
25
+ return new a(e$1);
26
+ }
27
+ function c(e$1) {
28
+ return l(e$1);
29
+ }
30
+ function d(e$1) {
31
+ return s(e$1);
32
+ }
33
+ function f(e$1, t$1, r$1) {
34
+ return i.call(e$1, t$1, r$1);
35
+ }
36
+ function b(e$1, t$1, r$1) {
37
+ f(f(e$1, t$1, r$1), void 0, o);
38
+ }
39
+ function h(e$1, t$1) {
40
+ b(e$1, t$1);
41
+ }
42
+ function _(e$1, t$1) {
43
+ b(e$1, void 0, t$1);
44
+ }
45
+ function p(e$1, t$1, r$1) {
46
+ return f(e$1, t$1, r$1);
47
+ }
48
+ function m(e$1) {
49
+ f(e$1, void 0, o);
50
+ }
51
+ let y = (e$1) => {
52
+ if ("function" == typeof queueMicrotask) y = queueMicrotask;
53
+ else {
54
+ const e$2 = c(void 0);
55
+ y = (t$1) => f(e$2, t$1);
56
+ }
57
+ return y(e$1);
58
+ };
59
+ function g(e$1, t$1, r$1) {
60
+ if ("function" != typeof e$1) throw new TypeError("Argument is not a function");
61
+ return Function.prototype.apply.call(e$1, t$1, r$1);
62
+ }
63
+ function w(e$1, t$1, r$1) {
64
+ try {
65
+ return c(g(e$1, t$1, r$1));
66
+ } catch (e$2) {
67
+ return d(e$2);
68
+ }
69
+ }
70
+ var S = class {
71
+ constructor() {
72
+ this._cursor = 0, this._size = 0, this._front = {
73
+ _elements: [],
74
+ _next: void 0
75
+ }, this._back = this._front, this._cursor = 0, this._size = 0;
76
+ }
77
+ get length() {
78
+ return this._size;
79
+ }
80
+ push(e$1) {
81
+ const t$1 = this._back;
82
+ let r$1 = t$1;
83
+ 16383 === t$1._elements.length && (r$1 = {
84
+ _elements: [],
85
+ _next: void 0
86
+ }), t$1._elements.push(e$1), r$1 !== t$1 && (this._back = r$1, t$1._next = r$1), ++this._size;
87
+ }
88
+ shift() {
89
+ const e$1 = this._front;
90
+ let t$1 = e$1;
91
+ const r$1 = this._cursor;
92
+ let o$1 = r$1 + 1;
93
+ const n$1 = e$1._elements, a$1 = n$1[r$1];
94
+ return 16384 === o$1 && (t$1 = e$1._next, o$1 = 0), --this._size, this._cursor = o$1, e$1 !== t$1 && (this._front = t$1), n$1[r$1] = void 0, a$1;
95
+ }
96
+ forEach(e$1) {
97
+ let t$1 = this._cursor, r$1 = this._front, o$1 = r$1._elements;
98
+ for (; !(t$1 === o$1.length && void 0 === r$1._next || t$1 === o$1.length && (r$1 = r$1._next, o$1 = r$1._elements, t$1 = 0, 0 === o$1.length));) e$1(o$1[t$1]), ++t$1;
99
+ }
100
+ peek() {
101
+ const e$1 = this._front, t$1 = this._cursor;
102
+ return e$1._elements[t$1];
103
+ }
104
+ };
105
+ const v = e("[[AbortSteps]]"), R = e("[[ErrorSteps]]"), T = e("[[CancelSteps]]"), q = e("[[PullSteps]]"), C = e("[[ReleaseSteps]]");
106
+ function E(e$1, t$1) {
107
+ e$1._ownerReadableStream = t$1, t$1._reader = e$1, "readable" === t$1._state ? O(e$1) : "closed" === t$1._state ? function(e$2) {
108
+ O(e$2), j(e$2);
109
+ }(e$1) : B(e$1, t$1._storedError);
110
+ }
111
+ function P(e$1, t$1) {
112
+ return Gt(e$1._ownerReadableStream, t$1);
113
+ }
114
+ function W(e$1) {
115
+ const t$1 = e$1._ownerReadableStream;
116
+ "readable" === t$1._state ? A(e$1, new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")) : function(e$2, t$2) {
117
+ B(e$2, t$2);
118
+ }(e$1, new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")), t$1._readableStreamController[C](), t$1._reader = void 0, e$1._ownerReadableStream = void 0;
119
+ }
120
+ function k(e$1) {
121
+ return new TypeError("Cannot " + e$1 + " a stream using a released reader");
122
+ }
123
+ function O(e$1) {
124
+ e$1._closedPromise = u((t$1, r$1) => {
125
+ e$1._closedPromise_resolve = t$1, e$1._closedPromise_reject = r$1;
126
+ });
127
+ }
128
+ function B(e$1, t$1) {
129
+ O(e$1), A(e$1, t$1);
130
+ }
131
+ function A(e$1, t$1) {
132
+ void 0 !== e$1._closedPromise_reject && (m(e$1._closedPromise), e$1._closedPromise_reject(t$1), e$1._closedPromise_resolve = void 0, e$1._closedPromise_reject = void 0);
133
+ }
134
+ function j(e$1) {
135
+ void 0 !== e$1._closedPromise_resolve && (e$1._closedPromise_resolve(void 0), e$1._closedPromise_resolve = void 0, e$1._closedPromise_reject = void 0);
136
+ }
137
+ const z = Number.isFinite || function(e$1) {
138
+ return "number" == typeof e$1 && isFinite(e$1);
139
+ }, L = Math.trunc || function(e$1) {
140
+ return e$1 < 0 ? Math.ceil(e$1) : Math.floor(e$1);
141
+ };
142
+ function F(e$1, t$1) {
143
+ if (void 0 !== e$1 && "object" != typeof (r$1 = e$1) && "function" != typeof r$1) throw new TypeError(`${t$1} is not an object.`);
144
+ var r$1;
145
+ }
146
+ function I(e$1, t$1) {
147
+ if ("function" != typeof e$1) throw new TypeError(`${t$1} is not a function.`);
148
+ }
149
+ function D(e$1, t$1) {
150
+ if (!function(e$2) {
151
+ return "object" == typeof e$2 && null !== e$2 || "function" == typeof e$2;
152
+ }(e$1)) throw new TypeError(`${t$1} is not an object.`);
153
+ }
154
+ function $(e$1, t$1, r$1) {
155
+ if (void 0 === e$1) throw new TypeError(`Parameter ${t$1} is required in '${r$1}'.`);
156
+ }
157
+ function M(e$1, t$1, r$1) {
158
+ if (void 0 === e$1) throw new TypeError(`${t$1} is required in '${r$1}'.`);
159
+ }
160
+ function Y(e$1) {
161
+ return Number(e$1);
162
+ }
163
+ function Q(e$1) {
164
+ return 0 === e$1 ? 0 : e$1;
165
+ }
166
+ function N(e$1, t$1) {
167
+ const r$1 = Number.MAX_SAFE_INTEGER;
168
+ let o$1 = Number(e$1);
169
+ if (o$1 = Q(o$1), !z(o$1)) throw new TypeError(`${t$1} is not a finite number`);
170
+ if (o$1 = function(e$2) {
171
+ return Q(L(e$2));
172
+ }(o$1), o$1 < 0 || o$1 > r$1) throw new TypeError(`${t$1} is outside the accepted range of 0 to ${r$1}, inclusive`);
173
+ return z(o$1) && 0 !== o$1 ? o$1 : 0;
174
+ }
175
+ function H(e$1) {
176
+ if (!r(e$1)) return !1;
177
+ if ("function" != typeof e$1.getReader) return !1;
178
+ try {
179
+ return "boolean" == typeof e$1.locked;
180
+ } catch (e$2) {
181
+ return !1;
182
+ }
183
+ }
184
+ function x(e$1) {
185
+ if (!r(e$1)) return !1;
186
+ if ("function" != typeof e$1.getWriter) return !1;
187
+ try {
188
+ return "boolean" == typeof e$1.locked;
189
+ } catch (e$2) {
190
+ return !1;
191
+ }
192
+ }
193
+ function V(e$1, t$1) {
194
+ if (!Vt(e$1)) throw new TypeError(`${t$1} is not a ReadableStream.`);
195
+ }
196
+ function U(e$1, t$1) {
197
+ e$1._reader._readRequests.push(t$1);
198
+ }
199
+ function G(e$1, t$1, r$1) {
200
+ const o$1 = e$1._reader._readRequests.shift();
201
+ r$1 ? o$1._closeSteps() : o$1._chunkSteps(t$1);
202
+ }
203
+ function X(e$1) {
204
+ return e$1._reader._readRequests.length;
205
+ }
206
+ function J(e$1) {
207
+ const t$1 = e$1._reader;
208
+ return void 0 !== t$1 && !!K(t$1);
209
+ }
210
+ var ReadableStreamDefaultReader = class {
211
+ constructor(e$1) {
212
+ if ($(e$1, 1, "ReadableStreamDefaultReader"), V(e$1, "First parameter"), Ut(e$1)) throw new TypeError("This stream has already been locked for exclusive reading by another reader");
213
+ E(this, e$1), this._readRequests = new S();
214
+ }
215
+ get closed() {
216
+ return K(this) ? this._closedPromise : d(ee("closed"));
217
+ }
218
+ cancel(e$1) {
219
+ return K(this) ? void 0 === this._ownerReadableStream ? d(k("cancel")) : P(this, e$1) : d(ee("cancel"));
220
+ }
221
+ read() {
222
+ if (!K(this)) return d(ee("read"));
223
+ if (void 0 === this._ownerReadableStream) return d(k("read from"));
224
+ let e$1, t$1;
225
+ const r$1 = u((r$2, o$1) => {
226
+ e$1 = r$2, t$1 = o$1;
227
+ });
228
+ return function(e$2, t$2) {
229
+ const r$2 = e$2._ownerReadableStream;
230
+ r$2._disturbed = !0, "closed" === r$2._state ? t$2._closeSteps() : "errored" === r$2._state ? t$2._errorSteps(r$2._storedError) : r$2._readableStreamController[q](t$2);
231
+ }(this, {
232
+ _chunkSteps: (t$2) => e$1({
233
+ value: t$2,
234
+ done: !1
235
+ }),
236
+ _closeSteps: () => e$1({
237
+ value: void 0,
238
+ done: !0
239
+ }),
240
+ _errorSteps: (e$2) => t$1(e$2)
241
+ }), r$1;
242
+ }
243
+ releaseLock() {
244
+ if (!K(this)) throw ee("releaseLock");
245
+ void 0 !== this._ownerReadableStream && function(e$1) {
246
+ W(e$1);
247
+ const t$1 = new TypeError("Reader was released");
248
+ Z(e$1, t$1);
249
+ }(this);
250
+ }
251
+ };
252
+ function K(e$1) {
253
+ return !!r(e$1) && !!Object.prototype.hasOwnProperty.call(e$1, "_readRequests") && e$1 instanceof ReadableStreamDefaultReader;
254
+ }
255
+ function Z(e$1, t$1) {
256
+ const r$1 = e$1._readRequests;
257
+ e$1._readRequests = new S(), r$1.forEach((e$2) => {
258
+ e$2._errorSteps(t$1);
259
+ });
260
+ }
261
+ function ee(e$1) {
262
+ return new TypeError(`ReadableStreamDefaultReader.prototype.${e$1} can only be used on a ReadableStreamDefaultReader`);
263
+ }
264
+ Object.defineProperties(ReadableStreamDefaultReader.prototype, {
265
+ cancel: { enumerable: !0 },
266
+ read: { enumerable: !0 },
267
+ releaseLock: { enumerable: !0 },
268
+ closed: { enumerable: !0 }
269
+ }), n(ReadableStreamDefaultReader.prototype.cancel, "cancel"), n(ReadableStreamDefaultReader.prototype.read, "read"), n(ReadableStreamDefaultReader.prototype.releaseLock, "releaseLock"), "symbol" == typeof e.toStringTag && Object.defineProperty(ReadableStreamDefaultReader.prototype, e.toStringTag, {
270
+ value: "ReadableStreamDefaultReader",
271
+ configurable: !0
272
+ });
273
+ var te = class {
274
+ constructor(e$1, t$1) {
275
+ this._ongoingPromise = void 0, this._isFinished = !1, this._reader = e$1, this._preventCancel = t$1;
276
+ }
277
+ next() {
278
+ const e$1 = () => this._nextSteps();
279
+ return this._ongoingPromise = this._ongoingPromise ? p(this._ongoingPromise, e$1, e$1) : e$1(), this._ongoingPromise;
280
+ }
281
+ return(e$1) {
282
+ const t$1 = () => this._returnSteps(e$1);
283
+ return this._ongoingPromise ? p(this._ongoingPromise, t$1, t$1) : t$1();
284
+ }
285
+ _nextSteps() {
286
+ if (this._isFinished) return Promise.resolve({
287
+ value: void 0,
288
+ done: !0
289
+ });
290
+ const e$1 = this._reader;
291
+ return void 0 === e$1 ? d(k("iterate")) : f(e$1.read(), (e$2) => {
292
+ var t$1;
293
+ return this._ongoingPromise = void 0, e$2.done && (this._isFinished = !0, null === (t$1 = this._reader) || void 0 === t$1 || t$1.releaseLock(), this._reader = void 0), e$2;
294
+ }, (e$2) => {
295
+ var t$1;
296
+ throw this._ongoingPromise = void 0, this._isFinished = !0, null === (t$1 = this._reader) || void 0 === t$1 || t$1.releaseLock(), this._reader = void 0, e$2;
297
+ });
298
+ }
299
+ _returnSteps(e$1) {
300
+ if (this._isFinished) return Promise.resolve({
301
+ value: e$1,
302
+ done: !0
303
+ });
304
+ this._isFinished = !0;
305
+ const t$1 = this._reader;
306
+ if (void 0 === t$1) return d(k("finish iterating"));
307
+ if (this._reader = void 0, !this._preventCancel) {
308
+ const r$1 = t$1.cancel(e$1);
309
+ return t$1.releaseLock(), p(r$1, () => ({
310
+ value: e$1,
311
+ done: !0
312
+ }));
313
+ }
314
+ return t$1.releaseLock(), c({
315
+ value: e$1,
316
+ done: !0
317
+ });
318
+ }
319
+ };
320
+ const re = {
321
+ next() {
322
+ return oe(this) ? this._asyncIteratorImpl.next() : d(ne("next"));
323
+ },
324
+ return(e$1) {
325
+ return oe(this) ? this._asyncIteratorImpl.return(e$1) : d(ne("return"));
326
+ }
327
+ };
328
+ function oe(e$1) {
329
+ if (!r(e$1)) return !1;
330
+ if (!Object.prototype.hasOwnProperty.call(e$1, "_asyncIteratorImpl")) return !1;
331
+ try {
332
+ return e$1._asyncIteratorImpl instanceof te;
333
+ } catch (e$2) {
334
+ return !1;
335
+ }
336
+ }
337
+ function ne(e$1) {
338
+ return new TypeError(`ReadableStreamAsyncIterator.${e$1} can only be used on a ReadableSteamAsyncIterator`);
339
+ }
340
+ "symbol" == typeof e.asyncIterator && Object.defineProperty(re, e.asyncIterator, {
341
+ value() {
342
+ return this;
343
+ },
344
+ writable: !0,
345
+ configurable: !0
346
+ });
347
+ const ae = Number.isNaN || function(e$1) {
348
+ return e$1 != e$1;
349
+ };
350
+ function ie(e$1, t$1, r$1, o$1, n$1) {
351
+ new Uint8Array(e$1).set(new Uint8Array(r$1, o$1, n$1), t$1);
352
+ }
353
+ function le(e$1) {
354
+ const t$1 = function(e$2, t$2, r$1) {
355
+ if (e$2.slice) return e$2.slice(t$2, r$1);
356
+ const o$1 = r$1 - t$2, n$1 = new ArrayBuffer(o$1);
357
+ return ie(n$1, 0, e$2, t$2, o$1), n$1;
358
+ }(e$1.buffer, e$1.byteOffset, e$1.byteOffset + e$1.byteLength);
359
+ return new Uint8Array(t$1);
360
+ }
361
+ function se(e$1) {
362
+ const t$1 = e$1._queue.shift();
363
+ return e$1._queueTotalSize -= t$1.size, e$1._queueTotalSize < 0 && (e$1._queueTotalSize = 0), t$1.value;
364
+ }
365
+ function ue(e$1, t$1, r$1) {
366
+ if ("number" != typeof (o$1 = r$1) || ae(o$1) || o$1 < 0 || r$1 === Infinity) throw new RangeError("Size must be a finite, non-NaN, non-negative number.");
367
+ var o$1;
368
+ e$1._queue.push({
369
+ value: t$1,
370
+ size: r$1
371
+ }), e$1._queueTotalSize += r$1;
372
+ }
373
+ function ce(e$1) {
374
+ e$1._queue = new S(), e$1._queueTotalSize = 0;
375
+ }
376
+ var ReadableStreamBYOBRequest = class {
377
+ constructor() {
378
+ throw new TypeError("Illegal constructor");
379
+ }
380
+ get view() {
381
+ if (!fe(this)) throw Be("view");
382
+ return this._view;
383
+ }
384
+ respond(e$1) {
385
+ if (!fe(this)) throw Be("respond");
386
+ if ($(e$1, 1, "respond"), e$1 = N(e$1, "First parameter"), void 0 === this._associatedReadableByteStreamController) throw new TypeError("This BYOB request has been invalidated");
387
+ this._view.buffer, function(e$2, t$1) {
388
+ const r$1 = e$2._pendingPullIntos.peek();
389
+ if ("closed" === e$2._controlledReadableByteStream._state) {
390
+ if (0 !== t$1) throw new TypeError("bytesWritten must be 0 when calling respond() on a closed stream");
391
+ } else {
392
+ if (0 === t$1) throw new TypeError("bytesWritten must be greater than 0 when calling respond() on a readable stream");
393
+ if (r$1.bytesFilled + t$1 > r$1.byteLength) throw new RangeError("bytesWritten out of range");
394
+ }
395
+ r$1.buffer = r$1.buffer, qe(e$2, t$1);
396
+ }(this._associatedReadableByteStreamController, e$1);
397
+ }
398
+ respondWithNewView(e$1) {
399
+ if (!fe(this)) throw Be("respondWithNewView");
400
+ if ($(e$1, 1, "respondWithNewView"), !ArrayBuffer.isView(e$1)) throw new TypeError("You can only respond with array buffer views");
401
+ if (void 0 === this._associatedReadableByteStreamController) throw new TypeError("This BYOB request has been invalidated");
402
+ e$1.buffer, function(e$2, t$1) {
403
+ const r$1 = e$2._pendingPullIntos.peek();
404
+ if ("closed" === e$2._controlledReadableByteStream._state) {
405
+ if (0 !== t$1.byteLength) throw new TypeError("The view's length must be 0 when calling respondWithNewView() on a closed stream");
406
+ } else if (0 === t$1.byteLength) throw new TypeError("The view's length must be greater than 0 when calling respondWithNewView() on a readable stream");
407
+ if (r$1.byteOffset + r$1.bytesFilled !== t$1.byteOffset) throw new RangeError("The region specified by view does not match byobRequest");
408
+ if (r$1.bufferByteLength !== t$1.buffer.byteLength) throw new RangeError("The buffer of view has different capacity than byobRequest");
409
+ if (r$1.bytesFilled + t$1.byteLength > r$1.byteLength) throw new RangeError("The region specified by view is larger than byobRequest");
410
+ const o$1 = t$1.byteLength;
411
+ r$1.buffer = t$1.buffer, qe(e$2, o$1);
412
+ }(this._associatedReadableByteStreamController, e$1);
413
+ }
414
+ };
415
+ Object.defineProperties(ReadableStreamBYOBRequest.prototype, {
416
+ respond: { enumerable: !0 },
417
+ respondWithNewView: { enumerable: !0 },
418
+ view: { enumerable: !0 }
419
+ }), n(ReadableStreamBYOBRequest.prototype.respond, "respond"), n(ReadableStreamBYOBRequest.prototype.respondWithNewView, "respondWithNewView"), "symbol" == typeof e.toStringTag && Object.defineProperty(ReadableStreamBYOBRequest.prototype, e.toStringTag, {
420
+ value: "ReadableStreamBYOBRequest",
421
+ configurable: !0
422
+ });
423
+ var ReadableByteStreamController = class {
424
+ constructor() {
425
+ throw new TypeError("Illegal constructor");
426
+ }
427
+ get byobRequest() {
428
+ if (!de(this)) throw Ae("byobRequest");
429
+ return function(e$1) {
430
+ if (null === e$1._byobRequest && e$1._pendingPullIntos.length > 0) {
431
+ const t$1 = e$1._pendingPullIntos.peek(), r$1 = new Uint8Array(t$1.buffer, t$1.byteOffset + t$1.bytesFilled, t$1.byteLength - t$1.bytesFilled), o$1 = Object.create(ReadableStreamBYOBRequest.prototype);
432
+ (function(e$2, t$2, r$2) {
433
+ e$2._associatedReadableByteStreamController = t$2, e$2._view = r$2;
434
+ })(o$1, e$1, r$1), e$1._byobRequest = o$1;
435
+ }
436
+ return e$1._byobRequest;
437
+ }(this);
438
+ }
439
+ get desiredSize() {
440
+ if (!de(this)) throw Ae("desiredSize");
441
+ return ke(this);
442
+ }
443
+ close() {
444
+ if (!de(this)) throw Ae("close");
445
+ if (this._closeRequested) throw new TypeError("The stream has already been closed; do not close it again!");
446
+ const e$1 = this._controlledReadableByteStream._state;
447
+ if ("readable" !== e$1) throw new TypeError(`The stream (in ${e$1} state) is not in the readable state and cannot be closed`);
448
+ (function(e$2) {
449
+ const t$1 = e$2._controlledReadableByteStream;
450
+ if (e$2._closeRequested || "readable" !== t$1._state) return;
451
+ if (e$2._queueTotalSize > 0) return void (e$2._closeRequested = !0);
452
+ if (e$2._pendingPullIntos.length > 0) {
453
+ if (e$2._pendingPullIntos.peek().bytesFilled > 0) {
454
+ const t$2 = new TypeError("Insufficient bytes to fill elements in the given buffer");
455
+ throw Pe(e$2, t$2), t$2;
456
+ }
457
+ }
458
+ Ee(e$2), Xt(t$1);
459
+ })(this);
460
+ }
461
+ enqueue(e$1) {
462
+ if (!de(this)) throw Ae("enqueue");
463
+ if ($(e$1, 1, "enqueue"), !ArrayBuffer.isView(e$1)) throw new TypeError("chunk must be an array buffer view");
464
+ if (0 === e$1.byteLength) throw new TypeError("chunk must have non-zero byteLength");
465
+ if (0 === e$1.buffer.byteLength) throw new TypeError("chunk's buffer must have non-zero byteLength");
466
+ if (this._closeRequested) throw new TypeError("stream is closed or draining");
467
+ const t$1 = this._controlledReadableByteStream._state;
468
+ if ("readable" !== t$1) throw new TypeError(`The stream (in ${t$1} state) is not in the readable state and cannot be enqueued to`);
469
+ (function(e$2, t$2) {
470
+ const r$1 = e$2._controlledReadableByteStream;
471
+ if (e$2._closeRequested || "readable" !== r$1._state) return;
472
+ const o$1 = t$2.buffer, n$1 = t$2.byteOffset, a$1 = t$2.byteLength, i$1 = o$1;
473
+ if (e$2._pendingPullIntos.length > 0) {
474
+ const t$3 = e$2._pendingPullIntos.peek();
475
+ t$3.buffer, Re(e$2), t$3.buffer = t$3.buffer, "none" === t$3.readerType && ge(e$2, t$3);
476
+ }
477
+ if (J(r$1)) if (function(e$3) {
478
+ const t$3 = e$3._controlledReadableByteStream._reader;
479
+ for (; t$3._readRequests.length > 0;) {
480
+ if (0 === e$3._queueTotalSize) return;
481
+ We(e$3, t$3._readRequests.shift());
482
+ }
483
+ }(e$2), 0 === X(r$1)) me(e$2, i$1, n$1, a$1);
484
+ else {
485
+ e$2._pendingPullIntos.length > 0 && Ce(e$2);
486
+ G(r$1, new Uint8Array(i$1, n$1, a$1), !1);
487
+ }
488
+ else Le(r$1) ? (me(e$2, i$1, n$1, a$1), Te(e$2)) : me(e$2, i$1, n$1, a$1);
489
+ be(e$2);
490
+ })(this, e$1);
491
+ }
492
+ error(e$1) {
493
+ if (!de(this)) throw Ae("error");
494
+ Pe(this, e$1);
495
+ }
496
+ [T](e$1) {
497
+ he(this), ce(this);
498
+ const t$1 = this._cancelAlgorithm(e$1);
499
+ return Ee(this), t$1;
500
+ }
501
+ [q](e$1) {
502
+ const t$1 = this._controlledReadableByteStream;
503
+ if (this._queueTotalSize > 0) return void We(this, e$1);
504
+ const r$1 = this._autoAllocateChunkSize;
505
+ if (void 0 !== r$1) {
506
+ let t$2;
507
+ try {
508
+ t$2 = new ArrayBuffer(r$1);
509
+ } catch (t$3) {
510
+ return void e$1._errorSteps(t$3);
511
+ }
512
+ const o$1 = {
513
+ buffer: t$2,
514
+ bufferByteLength: r$1,
515
+ byteOffset: 0,
516
+ byteLength: r$1,
517
+ bytesFilled: 0,
518
+ elementSize: 1,
519
+ viewConstructor: Uint8Array,
520
+ readerType: "default"
521
+ };
522
+ this._pendingPullIntos.push(o$1);
523
+ }
524
+ U(t$1, e$1), be(this);
525
+ }
526
+ [C]() {
527
+ if (this._pendingPullIntos.length > 0) {
528
+ const e$1 = this._pendingPullIntos.peek();
529
+ e$1.readerType = "none", this._pendingPullIntos = new S(), this._pendingPullIntos.push(e$1);
530
+ }
531
+ }
532
+ };
533
+ function de(e$1) {
534
+ return !!r(e$1) && !!Object.prototype.hasOwnProperty.call(e$1, "_controlledReadableByteStream") && e$1 instanceof ReadableByteStreamController;
535
+ }
536
+ function fe(e$1) {
537
+ return !!r(e$1) && !!Object.prototype.hasOwnProperty.call(e$1, "_associatedReadableByteStreamController") && e$1 instanceof ReadableStreamBYOBRequest;
538
+ }
539
+ function be(e$1) {
540
+ const t$1 = function(e$2) {
541
+ const t$2 = e$2._controlledReadableByteStream;
542
+ if ("readable" !== t$2._state) return !1;
543
+ if (e$2._closeRequested) return !1;
544
+ if (!e$2._started) return !1;
545
+ if (J(t$2) && X(t$2) > 0) return !0;
546
+ if (Le(t$2) && ze(t$2) > 0) return !0;
547
+ if (ke(e$2) > 0) return !0;
548
+ return !1;
549
+ }(e$1);
550
+ if (!t$1) return;
551
+ if (e$1._pulling) return void (e$1._pullAgain = !0);
552
+ e$1._pulling = !0;
553
+ b(e$1._pullAlgorithm(), () => (e$1._pulling = !1, e$1._pullAgain && (e$1._pullAgain = !1, be(e$1)), null), (t$2) => (Pe(e$1, t$2), null));
554
+ }
555
+ function he(e$1) {
556
+ Re(e$1), e$1._pendingPullIntos = new S();
557
+ }
558
+ function _e(e$1, t$1) {
559
+ let r$1 = !1;
560
+ "closed" === e$1._state && (r$1 = !0);
561
+ const o$1 = pe(t$1);
562
+ "default" === t$1.readerType ? G(e$1, o$1, r$1) : function(e$2, t$2, r$2) {
563
+ const o$2 = e$2._reader._readIntoRequests.shift();
564
+ r$2 ? o$2._closeSteps(t$2) : o$2._chunkSteps(t$2);
565
+ }(e$1, o$1, r$1);
566
+ }
567
+ function pe(e$1) {
568
+ const t$1 = e$1.bytesFilled, r$1 = e$1.elementSize;
569
+ return new e$1.viewConstructor(e$1.buffer, e$1.byteOffset, t$1 / r$1);
570
+ }
571
+ function me(e$1, t$1, r$1, o$1) {
572
+ e$1._queue.push({
573
+ buffer: t$1,
574
+ byteOffset: r$1,
575
+ byteLength: o$1
576
+ }), e$1._queueTotalSize += o$1;
577
+ }
578
+ function ye(e$1, t$1, r$1, o$1) {
579
+ let n$1;
580
+ try {
581
+ n$1 = t$1.slice(r$1, r$1 + o$1);
582
+ } catch (t$2) {
583
+ throw Pe(e$1, t$2), t$2;
584
+ }
585
+ me(e$1, n$1, 0, o$1);
586
+ }
587
+ function ge(e$1, t$1) {
588
+ t$1.bytesFilled > 0 && ye(e$1, t$1.buffer, t$1.byteOffset, t$1.bytesFilled), Ce(e$1);
589
+ }
590
+ function we(e$1, t$1) {
591
+ const r$1 = t$1.elementSize, o$1 = t$1.bytesFilled - t$1.bytesFilled % r$1, n$1 = Math.min(e$1._queueTotalSize, t$1.byteLength - t$1.bytesFilled), a$1 = t$1.bytesFilled + n$1, i$1 = a$1 - a$1 % r$1;
592
+ let l$1 = n$1, s$1 = !1;
593
+ i$1 > o$1 && (l$1 = i$1 - t$1.bytesFilled, s$1 = !0);
594
+ const u$1 = e$1._queue;
595
+ for (; l$1 > 0;) {
596
+ const r$2 = u$1.peek(), o$2 = Math.min(l$1, r$2.byteLength), n$2 = t$1.byteOffset + t$1.bytesFilled;
597
+ ie(t$1.buffer, n$2, r$2.buffer, r$2.byteOffset, o$2), r$2.byteLength === o$2 ? u$1.shift() : (r$2.byteOffset += o$2, r$2.byteLength -= o$2), e$1._queueTotalSize -= o$2, Se(e$1, o$2, t$1), l$1 -= o$2;
598
+ }
599
+ return s$1;
600
+ }
601
+ function Se(e$1, t$1, r$1) {
602
+ r$1.bytesFilled += t$1;
603
+ }
604
+ function ve(e$1) {
605
+ 0 === e$1._queueTotalSize && e$1._closeRequested ? (Ee(e$1), Xt(e$1._controlledReadableByteStream)) : be(e$1);
606
+ }
607
+ function Re(e$1) {
608
+ null !== e$1._byobRequest && (e$1._byobRequest._associatedReadableByteStreamController = void 0, e$1._byobRequest._view = null, e$1._byobRequest = null);
609
+ }
610
+ function Te(e$1) {
611
+ for (; e$1._pendingPullIntos.length > 0;) {
612
+ if (0 === e$1._queueTotalSize) return;
613
+ const t$1 = e$1._pendingPullIntos.peek();
614
+ we(e$1, t$1) && (Ce(e$1), _e(e$1._controlledReadableByteStream, t$1));
615
+ }
616
+ }
617
+ function qe(e$1, t$1) {
618
+ const r$1 = e$1._pendingPullIntos.peek();
619
+ Re(e$1);
620
+ "closed" === e$1._controlledReadableByteStream._state ? function(e$2, t$2) {
621
+ "none" === t$2.readerType && Ce(e$2);
622
+ const r$2 = e$2._controlledReadableByteStream;
623
+ if (Le(r$2)) for (; ze(r$2) > 0;) _e(r$2, Ce(e$2));
624
+ }(e$1, r$1) : function(e$2, t$2, r$2) {
625
+ if (Se(0, t$2, r$2), "none" === r$2.readerType) return ge(e$2, r$2), void Te(e$2);
626
+ if (r$2.bytesFilled < r$2.elementSize) return;
627
+ Ce(e$2);
628
+ const o$1 = r$2.bytesFilled % r$2.elementSize;
629
+ if (o$1 > 0) {
630
+ const t$3 = r$2.byteOffset + r$2.bytesFilled;
631
+ ye(e$2, r$2.buffer, t$3 - o$1, o$1);
632
+ }
633
+ r$2.bytesFilled -= o$1, _e(e$2._controlledReadableByteStream, r$2), Te(e$2);
634
+ }(e$1, t$1, r$1), be(e$1);
635
+ }
636
+ function Ce(e$1) {
637
+ return e$1._pendingPullIntos.shift();
638
+ }
639
+ function Ee(e$1) {
640
+ e$1._pullAlgorithm = void 0, e$1._cancelAlgorithm = void 0;
641
+ }
642
+ function Pe(e$1, t$1) {
643
+ const r$1 = e$1._controlledReadableByteStream;
644
+ "readable" === r$1._state && (he(e$1), ce(e$1), Ee(e$1), Jt(r$1, t$1));
645
+ }
646
+ function We(e$1, t$1) {
647
+ const r$1 = e$1._queue.shift();
648
+ e$1._queueTotalSize -= r$1.byteLength, ve(e$1);
649
+ const o$1 = new Uint8Array(r$1.buffer, r$1.byteOffset, r$1.byteLength);
650
+ t$1._chunkSteps(o$1);
651
+ }
652
+ function ke(e$1) {
653
+ const t$1 = e$1._controlledReadableByteStream._state;
654
+ return "errored" === t$1 ? null : "closed" === t$1 ? 0 : e$1._strategyHWM - e$1._queueTotalSize;
655
+ }
656
+ function Oe(e$1, t$1, r$1) {
657
+ const o$1 = Object.create(ReadableByteStreamController.prototype);
658
+ let n$1, a$1, i$1;
659
+ n$1 = void 0 !== t$1.start ? () => t$1.start(o$1) : () => {}, a$1 = void 0 !== t$1.pull ? () => t$1.pull(o$1) : () => c(void 0), i$1 = void 0 !== t$1.cancel ? (e$2) => t$1.cancel(e$2) : () => c(void 0);
660
+ const l$1 = t$1.autoAllocateChunkSize;
661
+ if (0 === l$1) throw new TypeError("autoAllocateChunkSize must be greater than 0");
662
+ (function(e$2, t$2, r$2, o$2, n$2, a$2, i$2) {
663
+ t$2._controlledReadableByteStream = e$2, t$2._pullAgain = !1, t$2._pulling = !1, t$2._byobRequest = null, t$2._queue = t$2._queueTotalSize = void 0, ce(t$2), t$2._closeRequested = !1, t$2._started = !1, t$2._strategyHWM = a$2, t$2._pullAlgorithm = o$2, t$2._cancelAlgorithm = n$2, t$2._autoAllocateChunkSize = i$2, t$2._pendingPullIntos = new S(), e$2._readableStreamController = t$2, b(c(r$2()), () => (t$2._started = !0, be(t$2), null), (e$3) => (Pe(t$2, e$3), null));
664
+ })(e$1, o$1, n$1, a$1, i$1, r$1, l$1);
665
+ }
666
+ function Be(e$1) {
667
+ return new TypeError(`ReadableStreamBYOBRequest.prototype.${e$1} can only be used on a ReadableStreamBYOBRequest`);
668
+ }
669
+ function Ae(e$1) {
670
+ return new TypeError(`ReadableByteStreamController.prototype.${e$1} can only be used on a ReadableByteStreamController`);
671
+ }
672
+ function je(e$1, t$1) {
673
+ e$1._reader._readIntoRequests.push(t$1);
674
+ }
675
+ function ze(e$1) {
676
+ return e$1._reader._readIntoRequests.length;
677
+ }
678
+ function Le(e$1) {
679
+ const t$1 = e$1._reader;
680
+ return void 0 !== t$1 && !!Fe(t$1);
681
+ }
682
+ Object.defineProperties(ReadableByteStreamController.prototype, {
683
+ close: { enumerable: !0 },
684
+ enqueue: { enumerable: !0 },
685
+ error: { enumerable: !0 },
686
+ byobRequest: { enumerable: !0 },
687
+ desiredSize: { enumerable: !0 }
688
+ }), n(ReadableByteStreamController.prototype.close, "close"), n(ReadableByteStreamController.prototype.enqueue, "enqueue"), n(ReadableByteStreamController.prototype.error, "error"), "symbol" == typeof e.toStringTag && Object.defineProperty(ReadableByteStreamController.prototype, e.toStringTag, {
689
+ value: "ReadableByteStreamController",
690
+ configurable: !0
691
+ });
692
+ var ReadableStreamBYOBReader = class {
693
+ constructor(e$1) {
694
+ if ($(e$1, 1, "ReadableStreamBYOBReader"), V(e$1, "First parameter"), Ut(e$1)) throw new TypeError("This stream has already been locked for exclusive reading by another reader");
695
+ if (!de(e$1._readableStreamController)) throw new TypeError("Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte source");
696
+ E(this, e$1), this._readIntoRequests = new S();
697
+ }
698
+ get closed() {
699
+ return Fe(this) ? this._closedPromise : d(De("closed"));
700
+ }
701
+ cancel(e$1) {
702
+ return Fe(this) ? void 0 === this._ownerReadableStream ? d(k("cancel")) : P(this, e$1) : d(De("cancel"));
703
+ }
704
+ read(e$1) {
705
+ if (!Fe(this)) return d(De("read"));
706
+ if (!ArrayBuffer.isView(e$1)) return d(new TypeError("view must be an array buffer view"));
707
+ if (0 === e$1.byteLength) return d(new TypeError("view must have non-zero byteLength"));
708
+ if (0 === e$1.buffer.byteLength) return d(new TypeError("view's buffer must have non-zero byteLength"));
709
+ if (e$1.buffer, void 0 === this._ownerReadableStream) return d(k("read from"));
710
+ let t$1, r$1;
711
+ const o$1 = u((e$2, o$2) => {
712
+ t$1 = e$2, r$1 = o$2;
713
+ });
714
+ return function(e$2, t$2, r$2) {
715
+ const o$2 = e$2._ownerReadableStream;
716
+ o$2._disturbed = !0, "errored" === o$2._state ? r$2._errorSteps(o$2._storedError) : function(e$3, t$3, r$3) {
717
+ const o$3 = e$3._controlledReadableByteStream;
718
+ let n$1 = 1;
719
+ t$3.constructor !== DataView && (n$1 = t$3.constructor.BYTES_PER_ELEMENT);
720
+ const a$1 = t$3.constructor, i$1 = t$3.buffer, l$1 = {
721
+ buffer: i$1,
722
+ bufferByteLength: i$1.byteLength,
723
+ byteOffset: t$3.byteOffset,
724
+ byteLength: t$3.byteLength,
725
+ bytesFilled: 0,
726
+ elementSize: n$1,
727
+ viewConstructor: a$1,
728
+ readerType: "byob"
729
+ };
730
+ if (e$3._pendingPullIntos.length > 0) return e$3._pendingPullIntos.push(l$1), void je(o$3, r$3);
731
+ if ("closed" !== o$3._state) {
732
+ if (e$3._queueTotalSize > 0) {
733
+ if (we(e$3, l$1)) {
734
+ const t$4 = pe(l$1);
735
+ return ve(e$3), void r$3._chunkSteps(t$4);
736
+ }
737
+ if (e$3._closeRequested) {
738
+ const t$4 = new TypeError("Insufficient bytes to fill elements in the given buffer");
739
+ return Pe(e$3, t$4), void r$3._errorSteps(t$4);
740
+ }
741
+ }
742
+ e$3._pendingPullIntos.push(l$1), je(o$3, r$3), be(e$3);
743
+ } else {
744
+ const e$4 = new a$1(l$1.buffer, l$1.byteOffset, 0);
745
+ r$3._closeSteps(e$4);
746
+ }
747
+ }(o$2._readableStreamController, t$2, r$2);
748
+ }(this, e$1, {
749
+ _chunkSteps: (e$2) => t$1({
750
+ value: e$2,
751
+ done: !1
752
+ }),
753
+ _closeSteps: (e$2) => t$1({
754
+ value: e$2,
755
+ done: !0
756
+ }),
757
+ _errorSteps: (e$2) => r$1(e$2)
758
+ }), o$1;
759
+ }
760
+ releaseLock() {
761
+ if (!Fe(this)) throw De("releaseLock");
762
+ void 0 !== this._ownerReadableStream && function(e$1) {
763
+ W(e$1);
764
+ const t$1 = new TypeError("Reader was released");
765
+ Ie(e$1, t$1);
766
+ }(this);
767
+ }
768
+ };
769
+ function Fe(e$1) {
770
+ return !!r(e$1) && !!Object.prototype.hasOwnProperty.call(e$1, "_readIntoRequests") && e$1 instanceof ReadableStreamBYOBReader;
771
+ }
772
+ function Ie(e$1, t$1) {
773
+ const r$1 = e$1._readIntoRequests;
774
+ e$1._readIntoRequests = new S(), r$1.forEach((e$2) => {
775
+ e$2._errorSteps(t$1);
776
+ });
777
+ }
778
+ function De(e$1) {
779
+ return new TypeError(`ReadableStreamBYOBReader.prototype.${e$1} can only be used on a ReadableStreamBYOBReader`);
780
+ }
781
+ function $e(e$1, t$1) {
782
+ const { highWaterMark: r$1 } = e$1;
783
+ if (void 0 === r$1) return t$1;
784
+ if (ae(r$1) || r$1 < 0) throw new RangeError("Invalid highWaterMark");
785
+ return r$1;
786
+ }
787
+ function Me(e$1) {
788
+ const { size: t$1 } = e$1;
789
+ return t$1 || (() => 1);
790
+ }
791
+ function Ye(e$1, t$1) {
792
+ F(e$1, t$1);
793
+ const r$1 = null == e$1 ? void 0 : e$1.highWaterMark, o$1 = null == e$1 ? void 0 : e$1.size;
794
+ return {
795
+ highWaterMark: void 0 === r$1 ? void 0 : Y(r$1),
796
+ size: void 0 === o$1 ? void 0 : Qe(o$1, `${t$1} has member 'size' that`)
797
+ };
798
+ }
799
+ function Qe(e$1, t$1) {
800
+ return I(e$1, t$1), (t$2) => Y(e$1(t$2));
801
+ }
802
+ function Ne(e$1, t$1, r$1) {
803
+ return I(e$1, r$1), (r$2) => w(e$1, t$1, [r$2]);
804
+ }
805
+ function He(e$1, t$1, r$1) {
806
+ return I(e$1, r$1), () => w(e$1, t$1, []);
807
+ }
808
+ function xe(e$1, t$1, r$1) {
809
+ return I(e$1, r$1), (r$2) => g(e$1, t$1, [r$2]);
810
+ }
811
+ function Ve(e$1, t$1, r$1) {
812
+ return I(e$1, r$1), (r$2, o$1) => w(e$1, t$1, [r$2, o$1]);
813
+ }
814
+ Object.defineProperties(ReadableStreamBYOBReader.prototype, {
815
+ cancel: { enumerable: !0 },
816
+ read: { enumerable: !0 },
817
+ releaseLock: { enumerable: !0 },
818
+ closed: { enumerable: !0 }
819
+ }), n(ReadableStreamBYOBReader.prototype.cancel, "cancel"), n(ReadableStreamBYOBReader.prototype.read, "read"), n(ReadableStreamBYOBReader.prototype.releaseLock, "releaseLock"), "symbol" == typeof e.toStringTag && Object.defineProperty(ReadableStreamBYOBReader.prototype, e.toStringTag, {
820
+ value: "ReadableStreamBYOBReader",
821
+ configurable: !0
822
+ });
823
+ const Ue = "function" == typeof AbortController;
824
+ var WritableStream = class {
825
+ constructor(e$1 = {}, t$1 = {}) {
826
+ void 0 === e$1 ? e$1 = null : D(e$1, "First parameter");
827
+ const r$1 = Ye(t$1, "Second parameter"), o$1 = function(e$2, t$2) {
828
+ F(e$2, t$2);
829
+ const r$2 = null == e$2 ? void 0 : e$2.abort, o$2 = null == e$2 ? void 0 : e$2.close, n$2 = null == e$2 ? void 0 : e$2.start, a$2 = null == e$2 ? void 0 : e$2.type, i$1 = null == e$2 ? void 0 : e$2.write;
830
+ return {
831
+ abort: void 0 === r$2 ? void 0 : Ne(r$2, e$2, `${t$2} has member 'abort' that`),
832
+ close: void 0 === o$2 ? void 0 : He(o$2, e$2, `${t$2} has member 'close' that`),
833
+ start: void 0 === n$2 ? void 0 : xe(n$2, e$2, `${t$2} has member 'start' that`),
834
+ write: void 0 === i$1 ? void 0 : Ve(i$1, e$2, `${t$2} has member 'write' that`),
835
+ type: a$2
836
+ };
837
+ }(e$1, "First parameter");
838
+ var n$1;
839
+ (n$1 = this)._state = "writable", n$1._storedError = void 0, n$1._writer = void 0, n$1._writableStreamController = void 0, n$1._writeRequests = new S(), n$1._inFlightWriteRequest = void 0, n$1._closeRequest = void 0, n$1._inFlightCloseRequest = void 0, n$1._pendingAbortRequest = void 0, n$1._backpressure = !1;
840
+ if (void 0 !== o$1.type) throw new RangeError("Invalid type is specified");
841
+ const a$1 = Me(r$1);
842
+ (function(e$2, t$2, r$2, o$2) {
843
+ const n$2 = Object.create(WritableStreamDefaultController.prototype);
844
+ let a$2, i$1, l$1, s$1;
845
+ a$2 = void 0 !== t$2.start ? () => t$2.start(n$2) : () => {};
846
+ i$1 = void 0 !== t$2.write ? (e$3) => t$2.write(e$3, n$2) : () => c(void 0);
847
+ l$1 = void 0 !== t$2.close ? () => t$2.close() : () => c(void 0);
848
+ s$1 = void 0 !== t$2.abort ? (e$3) => t$2.abort(e$3) : () => c(void 0);
849
+ (function(e$3, t$3, r$3, o$3, n$3, a$3, i$2, l$2) {
850
+ t$3._controlledWritableStream = e$3, e$3._writableStreamController = t$3, t$3._queue = void 0, t$3._queueTotalSize = void 0, ce(t$3), t$3._abortReason = void 0, t$3._abortController = function() {
851
+ if (Ue) return new AbortController();
852
+ }(), t$3._started = !1, t$3._strategySizeAlgorithm = l$2, t$3._strategyHWM = i$2, t$3._writeAlgorithm = o$3, t$3._closeAlgorithm = n$3, t$3._abortAlgorithm = a$3;
853
+ const s$2 = bt(t$3);
854
+ nt(e$3, s$2);
855
+ const u$1 = r$3();
856
+ b(c(u$1), () => (t$3._started = !0, dt(t$3), null), (r$4) => (t$3._started = !0, Ze(e$3, r$4), null));
857
+ })(e$2, n$2, a$2, i$1, l$1, s$1, r$2, o$2);
858
+ })(this, o$1, $e(r$1, 1), a$1);
859
+ }
860
+ get locked() {
861
+ if (!Ge(this)) throw _t("locked");
862
+ return Xe(this);
863
+ }
864
+ abort(e$1) {
865
+ return Ge(this) ? Xe(this) ? d(new TypeError("Cannot abort a stream that already has a writer")) : Je(this, e$1) : d(_t("abort"));
866
+ }
867
+ close() {
868
+ return Ge(this) ? Xe(this) ? d(new TypeError("Cannot close a stream that already has a writer")) : rt(this) ? d(new TypeError("Cannot close an already-closing stream")) : Ke(this) : d(_t("close"));
869
+ }
870
+ getWriter() {
871
+ if (!Ge(this)) throw _t("getWriter");
872
+ return new WritableStreamDefaultWriter(this);
873
+ }
874
+ };
875
+ function Ge(e$1) {
876
+ return !!r(e$1) && !!Object.prototype.hasOwnProperty.call(e$1, "_writableStreamController") && e$1 instanceof WritableStream;
877
+ }
878
+ function Xe(e$1) {
879
+ return void 0 !== e$1._writer;
880
+ }
881
+ function Je(e$1, t$1) {
882
+ var r$1;
883
+ if ("closed" === e$1._state || "errored" === e$1._state) return c(void 0);
884
+ e$1._writableStreamController._abortReason = t$1, null === (r$1 = e$1._writableStreamController._abortController) || void 0 === r$1 || r$1.abort(t$1);
885
+ const o$1 = e$1._state;
886
+ if ("closed" === o$1 || "errored" === o$1) return c(void 0);
887
+ if (void 0 !== e$1._pendingAbortRequest) return e$1._pendingAbortRequest._promise;
888
+ let n$1 = !1;
889
+ "erroring" === o$1 && (n$1 = !0, t$1 = void 0);
890
+ const a$1 = u((r$2, o$2) => {
891
+ e$1._pendingAbortRequest = {
892
+ _promise: void 0,
893
+ _resolve: r$2,
894
+ _reject: o$2,
895
+ _reason: t$1,
896
+ _wasAlreadyErroring: n$1
897
+ };
898
+ });
899
+ return e$1._pendingAbortRequest._promise = a$1, n$1 || et(e$1, t$1), a$1;
900
+ }
901
+ function Ke(e$1) {
902
+ const t$1 = e$1._state;
903
+ if ("closed" === t$1 || "errored" === t$1) return d(new TypeError(`The stream (in ${t$1} state) is not in the writable state and cannot be closed`));
904
+ const r$1 = u((t$2, r$2) => {
905
+ const o$2 = {
906
+ _resolve: t$2,
907
+ _reject: r$2
908
+ };
909
+ e$1._closeRequest = o$2;
910
+ }), o$1 = e$1._writer;
911
+ var n$1;
912
+ return void 0 !== o$1 && e$1._backpressure && "writable" === t$1 && Et(o$1), ue(n$1 = e$1._writableStreamController, lt, 0), dt(n$1), r$1;
913
+ }
914
+ function Ze(e$1, t$1) {
915
+ "writable" !== e$1._state ? tt(e$1) : et(e$1, t$1);
916
+ }
917
+ function et(e$1, t$1) {
918
+ const r$1 = e$1._writableStreamController;
919
+ e$1._state = "erroring", e$1._storedError = t$1;
920
+ const o$1 = e$1._writer;
921
+ void 0 !== o$1 && it(o$1, t$1), !function(e$2) {
922
+ if (void 0 === e$2._inFlightWriteRequest && void 0 === e$2._inFlightCloseRequest) return !1;
923
+ return !0;
924
+ }(e$1) && r$1._started && tt(e$1);
925
+ }
926
+ function tt(e$1) {
927
+ e$1._state = "errored", e$1._writableStreamController[R]();
928
+ const t$1 = e$1._storedError;
929
+ if (e$1._writeRequests.forEach((e$2) => {
930
+ e$2._reject(t$1);
931
+ }), e$1._writeRequests = new S(), void 0 === e$1._pendingAbortRequest) return void ot(e$1);
932
+ const r$1 = e$1._pendingAbortRequest;
933
+ if (e$1._pendingAbortRequest = void 0, r$1._wasAlreadyErroring) return r$1._reject(t$1), void ot(e$1);
934
+ b(e$1._writableStreamController[v](r$1._reason), () => (r$1._resolve(), ot(e$1), null), (t$2) => (r$1._reject(t$2), ot(e$1), null));
935
+ }
936
+ function rt(e$1) {
937
+ return void 0 !== e$1._closeRequest || void 0 !== e$1._inFlightCloseRequest;
938
+ }
939
+ function ot(e$1) {
940
+ void 0 !== e$1._closeRequest && (e$1._closeRequest._reject(e$1._storedError), e$1._closeRequest = void 0);
941
+ const t$1 = e$1._writer;
942
+ void 0 !== t$1 && St(t$1, e$1._storedError);
943
+ }
944
+ function nt(e$1, t$1) {
945
+ const r$1 = e$1._writer;
946
+ void 0 !== r$1 && t$1 !== e$1._backpressure && (t$1 ? function(e$2) {
947
+ Rt(e$2);
948
+ }(r$1) : Et(r$1)), e$1._backpressure = t$1;
949
+ }
950
+ Object.defineProperties(WritableStream.prototype, {
951
+ abort: { enumerable: !0 },
952
+ close: { enumerable: !0 },
953
+ getWriter: { enumerable: !0 },
954
+ locked: { enumerable: !0 }
955
+ }), n(WritableStream.prototype.abort, "abort"), n(WritableStream.prototype.close, "close"), n(WritableStream.prototype.getWriter, "getWriter"), "symbol" == typeof e.toStringTag && Object.defineProperty(WritableStream.prototype, e.toStringTag, {
956
+ value: "WritableStream",
957
+ configurable: !0
958
+ });
959
+ var WritableStreamDefaultWriter = class {
960
+ constructor(e$1) {
961
+ if ($(e$1, 1, "WritableStreamDefaultWriter"), function(e$2, t$2) {
962
+ if (!Ge(e$2)) throw new TypeError(`${t$2} is not a WritableStream.`);
963
+ }(e$1, "First parameter"), Xe(e$1)) throw new TypeError("This stream has already been locked for exclusive writing by another writer");
964
+ this._ownerWritableStream = e$1, e$1._writer = this;
965
+ const t$1 = e$1._state;
966
+ if ("writable" === t$1) !rt(e$1) && e$1._backpressure ? Rt(this) : qt(this), gt(this);
967
+ else if ("erroring" === t$1) Tt(this, e$1._storedError), gt(this);
968
+ else if ("closed" === t$1) qt(this), gt(r$1 = this), vt(r$1);
969
+ else {
970
+ const t$2 = e$1._storedError;
971
+ Tt(this, t$2), wt(this, t$2);
972
+ }
973
+ var r$1;
974
+ }
975
+ get closed() {
976
+ return at(this) ? this._closedPromise : d(mt("closed"));
977
+ }
978
+ get desiredSize() {
979
+ if (!at(this)) throw mt("desiredSize");
980
+ if (void 0 === this._ownerWritableStream) throw yt("desiredSize");
981
+ return function(e$1) {
982
+ const t$1 = e$1._ownerWritableStream, r$1 = t$1._state;
983
+ if ("errored" === r$1 || "erroring" === r$1) return null;
984
+ if ("closed" === r$1) return 0;
985
+ return ct(t$1._writableStreamController);
986
+ }(this);
987
+ }
988
+ get ready() {
989
+ return at(this) ? this._readyPromise : d(mt("ready"));
990
+ }
991
+ abort(e$1) {
992
+ return at(this) ? void 0 === this._ownerWritableStream ? d(yt("abort")) : function(e$2, t$1) {
993
+ return Je(e$2._ownerWritableStream, t$1);
994
+ }(this, e$1) : d(mt("abort"));
995
+ }
996
+ close() {
997
+ if (!at(this)) return d(mt("close"));
998
+ const e$1 = this._ownerWritableStream;
999
+ return void 0 === e$1 ? d(yt("close")) : rt(e$1) ? d(new TypeError("Cannot close an already-closing stream")) : Ke(this._ownerWritableStream);
1000
+ }
1001
+ releaseLock() {
1002
+ if (!at(this)) throw mt("releaseLock");
1003
+ void 0 !== this._ownerWritableStream && function(e$1) {
1004
+ const t$1 = e$1._ownerWritableStream, r$1 = new TypeError("Writer was released and can no longer be used to monitor the stream's closedness");
1005
+ it(e$1, r$1), function(e$2, t$2) {
1006
+ "pending" === e$2._closedPromiseState ? St(e$2, t$2) : function(e$3, t$3) {
1007
+ wt(e$3, t$3);
1008
+ }(e$2, t$2);
1009
+ }(e$1, r$1), t$1._writer = void 0, e$1._ownerWritableStream = void 0;
1010
+ }(this);
1011
+ }
1012
+ write(e$1) {
1013
+ return at(this) ? void 0 === this._ownerWritableStream ? d(yt("write to")) : function(e$2, t$1) {
1014
+ const r$1 = e$2._ownerWritableStream, o$1 = r$1._writableStreamController, n$1 = function(e$3, t$2) {
1015
+ try {
1016
+ return e$3._strategySizeAlgorithm(t$2);
1017
+ } catch (t$3) {
1018
+ return ft(e$3, t$3), 1;
1019
+ }
1020
+ }(o$1, t$1);
1021
+ if (r$1 !== e$2._ownerWritableStream) return d(yt("write to"));
1022
+ const a$1 = r$1._state;
1023
+ if ("errored" === a$1) return d(r$1._storedError);
1024
+ if (rt(r$1) || "closed" === a$1) return d(new TypeError("The stream is closing or closed and cannot be written to"));
1025
+ if ("erroring" === a$1) return d(r$1._storedError);
1026
+ const i$1 = function(e$3) {
1027
+ return u((t$2, r$2) => {
1028
+ const o$2 = {
1029
+ _resolve: t$2,
1030
+ _reject: r$2
1031
+ };
1032
+ e$3._writeRequests.push(o$2);
1033
+ });
1034
+ }(r$1);
1035
+ return function(e$3, t$2, r$2) {
1036
+ try {
1037
+ ue(e$3, t$2, r$2);
1038
+ } catch (t$3) {
1039
+ return void ft(e$3, t$3);
1040
+ }
1041
+ const o$2 = e$3._controlledWritableStream;
1042
+ if (!rt(o$2) && "writable" === o$2._state) nt(o$2, bt(e$3));
1043
+ dt(e$3);
1044
+ }(o$1, t$1, n$1), i$1;
1045
+ }(this, e$1) : d(mt("write"));
1046
+ }
1047
+ };
1048
+ function at(e$1) {
1049
+ return !!r(e$1) && !!Object.prototype.hasOwnProperty.call(e$1, "_ownerWritableStream") && e$1 instanceof WritableStreamDefaultWriter;
1050
+ }
1051
+ function it(e$1, t$1) {
1052
+ "pending" === e$1._readyPromiseState ? Ct(e$1, t$1) : function(e$2, t$2) {
1053
+ Tt(e$2, t$2);
1054
+ }(e$1, t$1);
1055
+ }
1056
+ Object.defineProperties(WritableStreamDefaultWriter.prototype, {
1057
+ abort: { enumerable: !0 },
1058
+ close: { enumerable: !0 },
1059
+ releaseLock: { enumerable: !0 },
1060
+ write: { enumerable: !0 },
1061
+ closed: { enumerable: !0 },
1062
+ desiredSize: { enumerable: !0 },
1063
+ ready: { enumerable: !0 }
1064
+ }), n(WritableStreamDefaultWriter.prototype.abort, "abort"), n(WritableStreamDefaultWriter.prototype.close, "close"), n(WritableStreamDefaultWriter.prototype.releaseLock, "releaseLock"), n(WritableStreamDefaultWriter.prototype.write, "write"), "symbol" == typeof e.toStringTag && Object.defineProperty(WritableStreamDefaultWriter.prototype, e.toStringTag, {
1065
+ value: "WritableStreamDefaultWriter",
1066
+ configurable: !0
1067
+ });
1068
+ const lt = {};
1069
+ var WritableStreamDefaultController = class {
1070
+ constructor() {
1071
+ throw new TypeError("Illegal constructor");
1072
+ }
1073
+ get abortReason() {
1074
+ if (!st(this)) throw pt("abortReason");
1075
+ return this._abortReason;
1076
+ }
1077
+ get signal() {
1078
+ if (!st(this)) throw pt("signal");
1079
+ if (void 0 === this._abortController) throw new TypeError("WritableStreamDefaultController.prototype.signal is not supported");
1080
+ return this._abortController.signal;
1081
+ }
1082
+ error(e$1) {
1083
+ if (!st(this)) throw pt("error");
1084
+ "writable" === this._controlledWritableStream._state && ht(this, e$1);
1085
+ }
1086
+ [v](e$1) {
1087
+ const t$1 = this._abortAlgorithm(e$1);
1088
+ return ut(this), t$1;
1089
+ }
1090
+ [R]() {
1091
+ ce(this);
1092
+ }
1093
+ };
1094
+ function st(e$1) {
1095
+ return !!r(e$1) && !!Object.prototype.hasOwnProperty.call(e$1, "_controlledWritableStream") && e$1 instanceof WritableStreamDefaultController;
1096
+ }
1097
+ function ut(e$1) {
1098
+ e$1._writeAlgorithm = void 0, e$1._closeAlgorithm = void 0, e$1._abortAlgorithm = void 0, e$1._strategySizeAlgorithm = void 0;
1099
+ }
1100
+ function ct(e$1) {
1101
+ return e$1._strategyHWM - e$1._queueTotalSize;
1102
+ }
1103
+ function dt(e$1) {
1104
+ const t$1 = e$1._controlledWritableStream;
1105
+ if (!e$1._started) return;
1106
+ if (void 0 !== t$1._inFlightWriteRequest) return;
1107
+ if ("erroring" === t$1._state) return void tt(t$1);
1108
+ if (0 === e$1._queue.length) return;
1109
+ const r$1 = e$1._queue.peek().value;
1110
+ r$1 === lt ? function(e$2) {
1111
+ const t$2 = e$2._controlledWritableStream;
1112
+ (function(e$3) {
1113
+ e$3._inFlightCloseRequest = e$3._closeRequest, e$3._closeRequest = void 0;
1114
+ })(t$2), se(e$2);
1115
+ const r$2 = e$2._closeAlgorithm();
1116
+ ut(e$2), b(r$2, () => (function(e$3) {
1117
+ e$3._inFlightCloseRequest._resolve(void 0), e$3._inFlightCloseRequest = void 0, "erroring" === e$3._state && (e$3._storedError = void 0, void 0 !== e$3._pendingAbortRequest && (e$3._pendingAbortRequest._resolve(), e$3._pendingAbortRequest = void 0)), e$3._state = "closed";
1118
+ const t$3 = e$3._writer;
1119
+ void 0 !== t$3 && vt(t$3);
1120
+ }(t$2), null), (e$3) => (function(e$4, t$3) {
1121
+ e$4._inFlightCloseRequest._reject(t$3), e$4._inFlightCloseRequest = void 0, void 0 !== e$4._pendingAbortRequest && (e$4._pendingAbortRequest._reject(t$3), e$4._pendingAbortRequest = void 0), Ze(e$4, t$3);
1122
+ }(t$2, e$3), null));
1123
+ }(e$1) : function(e$2, t$2) {
1124
+ const r$2 = e$2._controlledWritableStream;
1125
+ (function(e$3) {
1126
+ e$3._inFlightWriteRequest = e$3._writeRequests.shift();
1127
+ })(r$2);
1128
+ b(e$2._writeAlgorithm(t$2), () => {
1129
+ (function(e$3) {
1130
+ e$3._inFlightWriteRequest._resolve(void 0), e$3._inFlightWriteRequest = void 0;
1131
+ })(r$2);
1132
+ const t$3 = r$2._state;
1133
+ if (se(e$2), !rt(r$2) && "writable" === t$3) {
1134
+ const t$4 = bt(e$2);
1135
+ nt(r$2, t$4);
1136
+ }
1137
+ return dt(e$2), null;
1138
+ }, (t$3) => ("writable" === r$2._state && ut(e$2), function(e$3, t$4) {
1139
+ e$3._inFlightWriteRequest._reject(t$4), e$3._inFlightWriteRequest = void 0, Ze(e$3, t$4);
1140
+ }(r$2, t$3), null));
1141
+ }(e$1, r$1);
1142
+ }
1143
+ function ft(e$1, t$1) {
1144
+ "writable" === e$1._controlledWritableStream._state && ht(e$1, t$1);
1145
+ }
1146
+ function bt(e$1) {
1147
+ return ct(e$1) <= 0;
1148
+ }
1149
+ function ht(e$1, t$1) {
1150
+ const r$1 = e$1._controlledWritableStream;
1151
+ ut(e$1), et(r$1, t$1);
1152
+ }
1153
+ function _t(e$1) {
1154
+ return new TypeError(`WritableStream.prototype.${e$1} can only be used on a WritableStream`);
1155
+ }
1156
+ function pt(e$1) {
1157
+ return new TypeError(`WritableStreamDefaultController.prototype.${e$1} can only be used on a WritableStreamDefaultController`);
1158
+ }
1159
+ function mt(e$1) {
1160
+ return new TypeError(`WritableStreamDefaultWriter.prototype.${e$1} can only be used on a WritableStreamDefaultWriter`);
1161
+ }
1162
+ function yt(e$1) {
1163
+ return new TypeError("Cannot " + e$1 + " a stream using a released writer");
1164
+ }
1165
+ function gt(e$1) {
1166
+ e$1._closedPromise = u((t$1, r$1) => {
1167
+ e$1._closedPromise_resolve = t$1, e$1._closedPromise_reject = r$1, e$1._closedPromiseState = "pending";
1168
+ });
1169
+ }
1170
+ function wt(e$1, t$1) {
1171
+ gt(e$1), St(e$1, t$1);
1172
+ }
1173
+ function St(e$1, t$1) {
1174
+ void 0 !== e$1._closedPromise_reject && (m(e$1._closedPromise), e$1._closedPromise_reject(t$1), e$1._closedPromise_resolve = void 0, e$1._closedPromise_reject = void 0, e$1._closedPromiseState = "rejected");
1175
+ }
1176
+ function vt(e$1) {
1177
+ void 0 !== e$1._closedPromise_resolve && (e$1._closedPromise_resolve(void 0), e$1._closedPromise_resolve = void 0, e$1._closedPromise_reject = void 0, e$1._closedPromiseState = "resolved");
1178
+ }
1179
+ function Rt(e$1) {
1180
+ e$1._readyPromise = u((t$1, r$1) => {
1181
+ e$1._readyPromise_resolve = t$1, e$1._readyPromise_reject = r$1;
1182
+ }), e$1._readyPromiseState = "pending";
1183
+ }
1184
+ function Tt(e$1, t$1) {
1185
+ Rt(e$1), Ct(e$1, t$1);
1186
+ }
1187
+ function qt(e$1) {
1188
+ Rt(e$1), Et(e$1);
1189
+ }
1190
+ function Ct(e$1, t$1) {
1191
+ void 0 !== e$1._readyPromise_reject && (m(e$1._readyPromise), e$1._readyPromise_reject(t$1), e$1._readyPromise_resolve = void 0, e$1._readyPromise_reject = void 0, e$1._readyPromiseState = "rejected");
1192
+ }
1193
+ function Et(e$1) {
1194
+ void 0 !== e$1._readyPromise_resolve && (e$1._readyPromise_resolve(void 0), e$1._readyPromise_resolve = void 0, e$1._readyPromise_reject = void 0, e$1._readyPromiseState = "fulfilled");
1195
+ }
1196
+ Object.defineProperties(WritableStreamDefaultController.prototype, {
1197
+ abortReason: { enumerable: !0 },
1198
+ signal: { enumerable: !0 },
1199
+ error: { enumerable: !0 }
1200
+ }), "symbol" == typeof e.toStringTag && Object.defineProperty(WritableStreamDefaultController.prototype, e.toStringTag, {
1201
+ value: "WritableStreamDefaultController",
1202
+ configurable: !0
1203
+ });
1204
+ const Pt = "undefined" != typeof DOMException ? DOMException : void 0;
1205
+ const Wt = function(e$1) {
1206
+ if ("function" != typeof e$1 && "object" != typeof e$1) return !1;
1207
+ try {
1208
+ return new e$1(), !0;
1209
+ } catch (e$2) {
1210
+ return !1;
1211
+ }
1212
+ }(Pt) ? Pt : function() {
1213
+ const e$1 = function(e$2, t$1) {
1214
+ this.message = e$2 || "", this.name = t$1 || "Error", Error.captureStackTrace && Error.captureStackTrace(this, this.constructor);
1215
+ };
1216
+ return e$1.prototype = Object.create(Error.prototype), Object.defineProperty(e$1.prototype, "constructor", {
1217
+ value: e$1,
1218
+ writable: !0,
1219
+ configurable: !0
1220
+ }), e$1;
1221
+ }();
1222
+ function kt(e$1, t$1, r$1, o$1, n$1, a$1) {
1223
+ const i$1 = e$1.getReader(), l$1 = t$1.getWriter();
1224
+ Vt(e$1) && (e$1._disturbed = !0);
1225
+ let s$1, _$1, g$1, w$1 = !1, S$1 = !1, v$1 = "readable", R$1 = "writable", T$1 = !1, q$1 = !1;
1226
+ const C$1 = u((e$2) => {
1227
+ g$1 = e$2;
1228
+ });
1229
+ let E$1 = Promise.resolve(void 0);
1230
+ return u((P$1, W$1) => {
1231
+ let k$1;
1232
+ function O$1() {
1233
+ if (w$1) return;
1234
+ const e$2 = u((e$3, t$2) => {
1235
+ (function r$2(o$2) {
1236
+ o$2 ? e$3() : f(function() {
1237
+ if (w$1) return c(!0);
1238
+ return f(l$1.ready, () => f(i$1.read(), (e$4) => !!e$4.done || (E$1 = l$1.write(e$4.value), m(E$1), !1)));
1239
+ }(), r$2, t$2);
1240
+ })(!1);
1241
+ });
1242
+ m(e$2);
1243
+ }
1244
+ function B$1() {
1245
+ return v$1 = "closed", r$1 ? L$1() : z$1(() => (Ge(t$1) && (T$1 = rt(t$1), R$1 = t$1._state), T$1 || "closed" === R$1 ? c(void 0) : "erroring" === R$1 || "errored" === R$1 ? d(_$1) : (T$1 = !0, l$1.close())), !1, void 0), null;
1246
+ }
1247
+ function A$1(e$2) {
1248
+ return w$1 || (v$1 = "errored", s$1 = e$2, o$1 ? L$1(!0, e$2) : z$1(() => l$1.abort(e$2), !0, e$2)), null;
1249
+ }
1250
+ function j$1(e$2) {
1251
+ return S$1 || (R$1 = "errored", _$1 = e$2, n$1 ? L$1(!0, e$2) : z$1(() => i$1.cancel(e$2), !0, e$2)), null;
1252
+ }
1253
+ if (void 0 !== a$1 && (k$1 = () => {
1254
+ const e$2 = void 0 !== a$1.reason ? a$1.reason : new Wt("Aborted", "AbortError"), t$2 = [];
1255
+ o$1 || t$2.push(() => "writable" === R$1 ? l$1.abort(e$2) : c(void 0)), n$1 || t$2.push(() => "readable" === v$1 ? i$1.cancel(e$2) : c(void 0)), z$1(() => Promise.all(t$2.map((e$3) => e$3())), !0, e$2);
1256
+ }, a$1.aborted ? k$1() : a$1.addEventListener("abort", k$1)), Vt(e$1) && (v$1 = e$1._state, s$1 = e$1._storedError), Ge(t$1) && (R$1 = t$1._state, _$1 = t$1._storedError, T$1 = rt(t$1)), Vt(e$1) && Ge(t$1) && (q$1 = !0, g$1()), "errored" === v$1) A$1(s$1);
1257
+ else if ("erroring" === R$1 || "errored" === R$1) j$1(_$1);
1258
+ else if ("closed" === v$1) B$1();
1259
+ else if (T$1 || "closed" === R$1) {
1260
+ const e$2 = new TypeError("the destination writable stream closed before all data could be piped to it");
1261
+ n$1 ? L$1(!0, e$2) : z$1(() => i$1.cancel(e$2), !0, e$2);
1262
+ }
1263
+ function z$1(e$2, t$2, r$2) {
1264
+ function o$2() {
1265
+ return "writable" !== R$1 || T$1 ? n$2() : h(function() {
1266
+ let e$3;
1267
+ return c(function t$3() {
1268
+ if (e$3 !== E$1) return e$3 = E$1, p(E$1, t$3, t$3);
1269
+ }());
1270
+ }(), n$2), null;
1271
+ }
1272
+ function n$2() {
1273
+ return e$2 ? b(e$2(), () => F$1(t$2, r$2), (e$3) => F$1(!0, e$3)) : F$1(t$2, r$2), null;
1274
+ }
1275
+ w$1 || (w$1 = !0, q$1 ? o$2() : h(C$1, o$2));
1276
+ }
1277
+ function L$1(e$2, t$2) {
1278
+ z$1(void 0, e$2, t$2);
1279
+ }
1280
+ function F$1(e$2, t$2) {
1281
+ return S$1 = !0, l$1.releaseLock(), i$1.releaseLock(), void 0 !== a$1 && a$1.removeEventListener("abort", k$1), e$2 ? W$1(t$2) : P$1(void 0), null;
1282
+ }
1283
+ w$1 || (b(i$1.closed, B$1, A$1), b(l$1.closed, function() {
1284
+ return S$1 || (R$1 = "closed"), null;
1285
+ }, j$1)), q$1 ? O$1() : y(() => {
1286
+ q$1 = !0, g$1(), O$1();
1287
+ });
1288
+ });
1289
+ }
1290
+ function Ot(e$1, t$1) {
1291
+ return function(e$2) {
1292
+ try {
1293
+ return e$2.getReader({ mode: "byob" }).releaseLock(), !0;
1294
+ } catch (e$3) {
1295
+ return !1;
1296
+ }
1297
+ }(e$1) ? function(e$2) {
1298
+ let t$2, r$1, o$1, n$1, a$1, i$1 = e$2.getReader(), l$1 = !1, s$1 = !1, d$1 = !1, f$1 = !1, h$1 = !1, p$1 = !1;
1299
+ const m$1 = u((e$3) => {
1300
+ a$1 = e$3;
1301
+ });
1302
+ function y$1(e$3) {
1303
+ _(e$3.closed, (t$3) => (e$3 !== i$1 || (o$1.error(t$3), n$1.error(t$3), h$1 && p$1 || a$1(void 0)), null));
1304
+ }
1305
+ function g$1() {
1306
+ l$1 && (i$1.releaseLock(), i$1 = e$2.getReader(), y$1(i$1), l$1 = !1), b(i$1.read(), (e$3) => {
1307
+ var t$3, r$2;
1308
+ if (d$1 = !1, f$1 = !1, e$3.done) return h$1 || o$1.close(), p$1 || n$1.close(), null === (t$3 = o$1.byobRequest) || void 0 === t$3 || t$3.respond(0), null === (r$2 = n$1.byobRequest) || void 0 === r$2 || r$2.respond(0), h$1 && p$1 || a$1(void 0), null;
1309
+ const l$2 = e$3.value, u$1 = l$2;
1310
+ let c$1 = l$2;
1311
+ if (!h$1 && !p$1) try {
1312
+ c$1 = le(l$2);
1313
+ } catch (e$4) {
1314
+ return o$1.error(e$4), n$1.error(e$4), a$1(i$1.cancel(e$4)), null;
1315
+ }
1316
+ return h$1 || o$1.enqueue(u$1), p$1 || n$1.enqueue(c$1), s$1 = !1, d$1 ? S$1() : f$1 && v$1(), null;
1317
+ }, () => (s$1 = !1, null));
1318
+ }
1319
+ function w$1(t$3, r$2) {
1320
+ l$1 || (i$1.releaseLock(), i$1 = e$2.getReader({ mode: "byob" }), y$1(i$1), l$1 = !0);
1321
+ const u$1 = r$2 ? n$1 : o$1, c$1 = r$2 ? o$1 : n$1;
1322
+ b(i$1.read(t$3), (e$3) => {
1323
+ var t$4;
1324
+ d$1 = !1, f$1 = !1;
1325
+ const o$2 = r$2 ? p$1 : h$1, n$2 = r$2 ? h$1 : p$1;
1326
+ if (e$3.done) {
1327
+ o$2 || u$1.close(), n$2 || c$1.close();
1328
+ const r$3 = e$3.value;
1329
+ return void 0 !== r$3 && (o$2 || u$1.byobRequest.respondWithNewView(r$3), n$2 || null === (t$4 = c$1.byobRequest) || void 0 === t$4 || t$4.respond(0)), o$2 && n$2 || a$1(void 0), null;
1330
+ }
1331
+ const l$2 = e$3.value;
1332
+ if (n$2) o$2 || u$1.byobRequest.respondWithNewView(l$2);
1333
+ else {
1334
+ let e$4;
1335
+ try {
1336
+ e$4 = le(l$2);
1337
+ } catch (e$5) {
1338
+ return u$1.error(e$5), c$1.error(e$5), a$1(i$1.cancel(e$5)), null;
1339
+ }
1340
+ o$2 || u$1.byobRequest.respondWithNewView(l$2), c$1.enqueue(e$4);
1341
+ }
1342
+ return s$1 = !1, d$1 ? S$1() : f$1 && v$1(), null;
1343
+ }, () => (s$1 = !1, null));
1344
+ }
1345
+ function S$1() {
1346
+ if (s$1) return d$1 = !0, c(void 0);
1347
+ s$1 = !0;
1348
+ const e$3 = o$1.byobRequest;
1349
+ return null === e$3 ? g$1() : w$1(e$3.view, !1), c(void 0);
1350
+ }
1351
+ function v$1() {
1352
+ if (s$1) return f$1 = !0, c(void 0);
1353
+ s$1 = !0;
1354
+ const e$3 = n$1.byobRequest;
1355
+ return null === e$3 ? g$1() : w$1(e$3.view, !0), c(void 0);
1356
+ }
1357
+ function R$1(e$3) {
1358
+ if (h$1 = !0, t$2 = e$3, p$1) {
1359
+ const e$4 = [t$2, r$1], o$2 = i$1.cancel(e$4);
1360
+ a$1(o$2);
1361
+ }
1362
+ return m$1;
1363
+ }
1364
+ function T$1(e$3) {
1365
+ if (p$1 = !0, r$1 = e$3, h$1) {
1366
+ const e$4 = [t$2, r$1], o$2 = i$1.cancel(e$4);
1367
+ a$1(o$2);
1368
+ }
1369
+ return m$1;
1370
+ }
1371
+ const q$1 = new ReadableStream({
1372
+ type: "bytes",
1373
+ start(e$3) {
1374
+ o$1 = e$3;
1375
+ },
1376
+ pull: S$1,
1377
+ cancel: R$1
1378
+ }), C$1 = new ReadableStream({
1379
+ type: "bytes",
1380
+ start(e$3) {
1381
+ n$1 = e$3;
1382
+ },
1383
+ pull: v$1,
1384
+ cancel: T$1
1385
+ });
1386
+ return y$1(i$1), [q$1, C$1];
1387
+ }(e$1) : function(e$2, t$2) {
1388
+ const r$1 = e$2.getReader();
1389
+ let o$1, n$1, a$1, i$1, l$1, s$1 = !1, d$1 = !1, f$1 = !1, h$1 = !1;
1390
+ const p$1 = u((e$3) => {
1391
+ l$1 = e$3;
1392
+ });
1393
+ function m$1() {
1394
+ return s$1 ? (d$1 = !0, c(void 0)) : (s$1 = !0, b(r$1.read(), (e$3) => {
1395
+ if (d$1 = !1, e$3.done) return f$1 || a$1.close(), h$1 || i$1.close(), f$1 && h$1 || l$1(void 0), null;
1396
+ const t$3 = e$3.value, r$2 = t$3, o$2 = t$3;
1397
+ return f$1 || a$1.enqueue(r$2), h$1 || i$1.enqueue(o$2), s$1 = !1, d$1 && m$1(), null;
1398
+ }, () => (s$1 = !1, null)), c(void 0));
1399
+ }
1400
+ function y$1(e$3) {
1401
+ if (f$1 = !0, o$1 = e$3, h$1) {
1402
+ const e$4 = [o$1, n$1], t$3 = r$1.cancel(e$4);
1403
+ l$1(t$3);
1404
+ }
1405
+ return p$1;
1406
+ }
1407
+ function g$1(e$3) {
1408
+ if (h$1 = !0, n$1 = e$3, f$1) {
1409
+ const e$4 = [o$1, n$1], t$3 = r$1.cancel(e$4);
1410
+ l$1(t$3);
1411
+ }
1412
+ return p$1;
1413
+ }
1414
+ const w$1 = new ReadableStream({
1415
+ start(e$3) {
1416
+ a$1 = e$3;
1417
+ },
1418
+ pull: m$1,
1419
+ cancel: y$1
1420
+ }), S$1 = new ReadableStream({
1421
+ start(e$3) {
1422
+ i$1 = e$3;
1423
+ },
1424
+ pull: m$1,
1425
+ cancel: g$1
1426
+ });
1427
+ return _(r$1.closed, (e$3) => (a$1.error(e$3), i$1.error(e$3), f$1 && h$1 || l$1(void 0), null)), [w$1, S$1];
1428
+ }(e$1);
1429
+ }
1430
+ var ReadableStreamDefaultController = class {
1431
+ constructor() {
1432
+ throw new TypeError("Illegal constructor");
1433
+ }
1434
+ get desiredSize() {
1435
+ if (!Bt(this)) throw Dt("desiredSize");
1436
+ return Lt(this);
1437
+ }
1438
+ close() {
1439
+ if (!Bt(this)) throw Dt("close");
1440
+ if (!Ft(this)) throw new TypeError("The stream is not in a state that permits close");
1441
+ (function(e$1) {
1442
+ if (!Ft(e$1)) return;
1443
+ const t$1 = e$1._controlledReadableStream;
1444
+ e$1._closeRequested = !0, 0 === e$1._queue.length && (jt(e$1), Xt(t$1));
1445
+ })(this);
1446
+ }
1447
+ enqueue(e$1) {
1448
+ if (!Bt(this)) throw Dt("enqueue");
1449
+ if (!Ft(this)) throw new TypeError("The stream is not in a state that permits enqueue");
1450
+ return function(e$2, t$1) {
1451
+ if (!Ft(e$2)) return;
1452
+ const r$1 = e$2._controlledReadableStream;
1453
+ if (Ut(r$1) && X(r$1) > 0) G(r$1, t$1, !1);
1454
+ else {
1455
+ let r$2;
1456
+ try {
1457
+ r$2 = e$2._strategySizeAlgorithm(t$1);
1458
+ } catch (t$2) {
1459
+ throw zt(e$2, t$2), t$2;
1460
+ }
1461
+ try {
1462
+ ue(e$2, t$1, r$2);
1463
+ } catch (t$2) {
1464
+ throw zt(e$2, t$2), t$2;
1465
+ }
1466
+ }
1467
+ At(e$2);
1468
+ }(this, e$1);
1469
+ }
1470
+ error(e$1) {
1471
+ if (!Bt(this)) throw Dt("error");
1472
+ zt(this, e$1);
1473
+ }
1474
+ [T](e$1) {
1475
+ ce(this);
1476
+ const t$1 = this._cancelAlgorithm(e$1);
1477
+ return jt(this), t$1;
1478
+ }
1479
+ [q](e$1) {
1480
+ const t$1 = this._controlledReadableStream;
1481
+ if (this._queue.length > 0) {
1482
+ const r$1 = se(this);
1483
+ this._closeRequested && 0 === this._queue.length ? (jt(this), Xt(t$1)) : At(this), e$1._chunkSteps(r$1);
1484
+ } else U(t$1, e$1), At(this);
1485
+ }
1486
+ [C]() {}
1487
+ };
1488
+ function Bt(e$1) {
1489
+ return !!r(e$1) && !!Object.prototype.hasOwnProperty.call(e$1, "_controlledReadableStream") && e$1 instanceof ReadableStreamDefaultController;
1490
+ }
1491
+ function At(e$1) {
1492
+ const t$1 = function(e$2) {
1493
+ const t$2 = e$2._controlledReadableStream;
1494
+ if (!Ft(e$2)) return !1;
1495
+ if (!e$2._started) return !1;
1496
+ if (Ut(t$2) && X(t$2) > 0) return !0;
1497
+ if (Lt(e$2) > 0) return !0;
1498
+ return !1;
1499
+ }(e$1);
1500
+ if (!t$1) return;
1501
+ if (e$1._pulling) return void (e$1._pullAgain = !0);
1502
+ e$1._pulling = !0;
1503
+ b(e$1._pullAlgorithm(), () => (e$1._pulling = !1, e$1._pullAgain && (e$1._pullAgain = !1, At(e$1)), null), (t$2) => (zt(e$1, t$2), null));
1504
+ }
1505
+ function jt(e$1) {
1506
+ e$1._pullAlgorithm = void 0, e$1._cancelAlgorithm = void 0, e$1._strategySizeAlgorithm = void 0;
1507
+ }
1508
+ function zt(e$1, t$1) {
1509
+ const r$1 = e$1._controlledReadableStream;
1510
+ "readable" === r$1._state && (ce(e$1), jt(e$1), Jt(r$1, t$1));
1511
+ }
1512
+ function Lt(e$1) {
1513
+ const t$1 = e$1._controlledReadableStream._state;
1514
+ return "errored" === t$1 ? null : "closed" === t$1 ? 0 : e$1._strategyHWM - e$1._queueTotalSize;
1515
+ }
1516
+ function Ft(e$1) {
1517
+ return !e$1._closeRequested && "readable" === e$1._controlledReadableStream._state;
1518
+ }
1519
+ function It(e$1, t$1, r$1, o$1) {
1520
+ const n$1 = Object.create(ReadableStreamDefaultController.prototype);
1521
+ let a$1, i$1, l$1;
1522
+ a$1 = void 0 !== t$1.start ? () => t$1.start(n$1) : () => {}, i$1 = void 0 !== t$1.pull ? () => t$1.pull(n$1) : () => c(void 0), l$1 = void 0 !== t$1.cancel ? (e$2) => t$1.cancel(e$2) : () => c(void 0), function(e$2, t$2, r$2, o$2, n$2, a$2, i$2) {
1523
+ t$2._controlledReadableStream = e$2, t$2._queue = void 0, t$2._queueTotalSize = void 0, ce(t$2), t$2._started = !1, t$2._closeRequested = !1, t$2._pullAgain = !1, t$2._pulling = !1, t$2._strategySizeAlgorithm = i$2, t$2._strategyHWM = a$2, t$2._pullAlgorithm = o$2, t$2._cancelAlgorithm = n$2, e$2._readableStreamController = t$2, b(c(r$2()), () => (t$2._started = !0, At(t$2), null), (e$3) => (zt(t$2, e$3), null));
1524
+ }(e$1, n$1, a$1, i$1, l$1, r$1, o$1);
1525
+ }
1526
+ function Dt(e$1) {
1527
+ return new TypeError(`ReadableStreamDefaultController.prototype.${e$1} can only be used on a ReadableStreamDefaultController`);
1528
+ }
1529
+ function $t(e$1, t$1, r$1) {
1530
+ return I(e$1, r$1), (r$2) => w(e$1, t$1, [r$2]);
1531
+ }
1532
+ function Mt(e$1, t$1, r$1) {
1533
+ return I(e$1, r$1), (r$2) => w(e$1, t$1, [r$2]);
1534
+ }
1535
+ function Yt(e$1, t$1, r$1) {
1536
+ return I(e$1, r$1), (r$2) => g(e$1, t$1, [r$2]);
1537
+ }
1538
+ function Qt(e$1, t$1) {
1539
+ if ("bytes" !== (e$1 = `${e$1}`)) throw new TypeError(`${t$1} '${e$1}' is not a valid enumeration value for ReadableStreamType`);
1540
+ return e$1;
1541
+ }
1542
+ function Nt(e$1, t$1) {
1543
+ if ("byob" !== (e$1 = `${e$1}`)) throw new TypeError(`${t$1} '${e$1}' is not a valid enumeration value for ReadableStreamReaderMode`);
1544
+ return e$1;
1545
+ }
1546
+ function Ht(e$1, t$1) {
1547
+ F(e$1, t$1);
1548
+ const r$1 = null == e$1 ? void 0 : e$1.preventAbort, o$1 = null == e$1 ? void 0 : e$1.preventCancel, n$1 = null == e$1 ? void 0 : e$1.preventClose, a$1 = null == e$1 ? void 0 : e$1.signal;
1549
+ return void 0 !== a$1 && function(e$2, t$2) {
1550
+ if (!function(e$3) {
1551
+ if ("object" != typeof e$3 || null === e$3) return !1;
1552
+ try {
1553
+ return "boolean" == typeof e$3.aborted;
1554
+ } catch (e$4) {
1555
+ return !1;
1556
+ }
1557
+ }(e$2)) throw new TypeError(`${t$2} is not an AbortSignal.`);
1558
+ }(a$1, `${t$1} has member 'signal' that`), {
1559
+ preventAbort: Boolean(r$1),
1560
+ preventCancel: Boolean(o$1),
1561
+ preventClose: Boolean(n$1),
1562
+ signal: a$1
1563
+ };
1564
+ }
1565
+ function xt(e$1, t$1) {
1566
+ F(e$1, t$1);
1567
+ const r$1 = null == e$1 ? void 0 : e$1.readable;
1568
+ M(r$1, "readable", "ReadableWritablePair"), function(e$2, t$2) {
1569
+ if (!H(e$2)) throw new TypeError(`${t$2} is not a ReadableStream.`);
1570
+ }(r$1, `${t$1} has member 'readable' that`);
1571
+ const o$1 = null == e$1 ? void 0 : e$1.writable;
1572
+ return M(o$1, "writable", "ReadableWritablePair"), function(e$2, t$2) {
1573
+ if (!x(e$2)) throw new TypeError(`${t$2} is not a WritableStream.`);
1574
+ }(o$1, `${t$1} has member 'writable' that`), {
1575
+ readable: r$1,
1576
+ writable: o$1
1577
+ };
1578
+ }
1579
+ Object.defineProperties(ReadableStreamDefaultController.prototype, {
1580
+ close: { enumerable: !0 },
1581
+ enqueue: { enumerable: !0 },
1582
+ error: { enumerable: !0 },
1583
+ desiredSize: { enumerable: !0 }
1584
+ }), n(ReadableStreamDefaultController.prototype.close, "close"), n(ReadableStreamDefaultController.prototype.enqueue, "enqueue"), n(ReadableStreamDefaultController.prototype.error, "error"), "symbol" == typeof e.toStringTag && Object.defineProperty(ReadableStreamDefaultController.prototype, e.toStringTag, {
1585
+ value: "ReadableStreamDefaultController",
1586
+ configurable: !0
1587
+ });
1588
+ var ReadableStream = class {
1589
+ constructor(e$1 = {}, t$1 = {}) {
1590
+ void 0 === e$1 ? e$1 = null : D(e$1, "First parameter");
1591
+ const r$1 = Ye(t$1, "Second parameter"), o$1 = function(e$2, t$2) {
1592
+ F(e$2, t$2);
1593
+ const r$2 = e$2, o$2 = null == r$2 ? void 0 : r$2.autoAllocateChunkSize, n$2 = null == r$2 ? void 0 : r$2.cancel, a$1 = null == r$2 ? void 0 : r$2.pull, i$1 = null == r$2 ? void 0 : r$2.start, l$1 = null == r$2 ? void 0 : r$2.type;
1594
+ return {
1595
+ autoAllocateChunkSize: void 0 === o$2 ? void 0 : N(o$2, `${t$2} has member 'autoAllocateChunkSize' that`),
1596
+ cancel: void 0 === n$2 ? void 0 : $t(n$2, r$2, `${t$2} has member 'cancel' that`),
1597
+ pull: void 0 === a$1 ? void 0 : Mt(a$1, r$2, `${t$2} has member 'pull' that`),
1598
+ start: void 0 === i$1 ? void 0 : Yt(i$1, r$2, `${t$2} has member 'start' that`),
1599
+ type: void 0 === l$1 ? void 0 : Qt(l$1, `${t$2} has member 'type' that`)
1600
+ };
1601
+ }(e$1, "First parameter");
1602
+ var n$1;
1603
+ if ((n$1 = this)._state = "readable", n$1._reader = void 0, n$1._storedError = void 0, n$1._disturbed = !1, "bytes" === o$1.type) {
1604
+ if (void 0 !== r$1.size) throw new RangeError("The strategy for a byte stream cannot have a size function");
1605
+ Oe(this, o$1, $e(r$1, 0));
1606
+ } else {
1607
+ const e$2 = Me(r$1);
1608
+ It(this, o$1, $e(r$1, 1), e$2);
1609
+ }
1610
+ }
1611
+ get locked() {
1612
+ if (!Vt(this)) throw Kt("locked");
1613
+ return Ut(this);
1614
+ }
1615
+ cancel(e$1) {
1616
+ return Vt(this) ? Ut(this) ? d(new TypeError("Cannot cancel a stream that already has a reader")) : Gt(this, e$1) : d(Kt("cancel"));
1617
+ }
1618
+ getReader(e$1) {
1619
+ if (!Vt(this)) throw Kt("getReader");
1620
+ return void 0 === function(e$2, t$1) {
1621
+ F(e$2, t$1);
1622
+ const r$1 = null == e$2 ? void 0 : e$2.mode;
1623
+ return { mode: void 0 === r$1 ? void 0 : Nt(r$1, `${t$1} has member 'mode' that`) };
1624
+ }(e$1, "First parameter").mode ? new ReadableStreamDefaultReader(this) : function(e$2) {
1625
+ return new ReadableStreamBYOBReader(e$2);
1626
+ }(this);
1627
+ }
1628
+ pipeThrough(e$1, t$1 = {}) {
1629
+ if (!H(this)) throw Kt("pipeThrough");
1630
+ $(e$1, 1, "pipeThrough");
1631
+ const r$1 = xt(e$1, "First parameter"), o$1 = Ht(t$1, "Second parameter");
1632
+ if (this.locked) throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked ReadableStream");
1633
+ if (r$1.writable.locked) throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked WritableStream");
1634
+ return m(kt(this, r$1.writable, o$1.preventClose, o$1.preventAbort, o$1.preventCancel, o$1.signal)), r$1.readable;
1635
+ }
1636
+ pipeTo(e$1, t$1 = {}) {
1637
+ if (!H(this)) return d(Kt("pipeTo"));
1638
+ if (void 0 === e$1) return d("Parameter 1 is required in 'pipeTo'.");
1639
+ if (!x(e$1)) return d(new TypeError("ReadableStream.prototype.pipeTo's first argument must be a WritableStream"));
1640
+ let r$1;
1641
+ try {
1642
+ r$1 = Ht(t$1, "Second parameter");
1643
+ } catch (e$2) {
1644
+ return d(e$2);
1645
+ }
1646
+ return this.locked ? d(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream")) : e$1.locked ? d(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream")) : kt(this, e$1, r$1.preventClose, r$1.preventAbort, r$1.preventCancel, r$1.signal);
1647
+ }
1648
+ tee() {
1649
+ if (!H(this)) throw Kt("tee");
1650
+ if (this.locked) throw new TypeError("Cannot tee a stream that already has a reader");
1651
+ return Ot(this);
1652
+ }
1653
+ values(e$1) {
1654
+ if (!H(this)) throw Kt("values");
1655
+ return function(e$2, t$1) {
1656
+ const r$1 = e$2.getReader(), o$1 = new te(r$1, t$1), n$1 = Object.create(re);
1657
+ return n$1._asyncIteratorImpl = o$1, n$1;
1658
+ }(this, function(e$2, t$1) {
1659
+ F(e$2, t$1);
1660
+ const r$1 = null == e$2 ? void 0 : e$2.preventCancel;
1661
+ return { preventCancel: Boolean(r$1) };
1662
+ }(e$1, "First parameter").preventCancel);
1663
+ }
1664
+ };
1665
+ function Vt(e$1) {
1666
+ return !!r(e$1) && !!Object.prototype.hasOwnProperty.call(e$1, "_readableStreamController") && e$1 instanceof ReadableStream;
1667
+ }
1668
+ function Ut(e$1) {
1669
+ return void 0 !== e$1._reader;
1670
+ }
1671
+ function Gt(e$1, r$1) {
1672
+ if (e$1._disturbed = !0, "closed" === e$1._state) return c(void 0);
1673
+ if ("errored" === e$1._state) return d(e$1._storedError);
1674
+ Xt(e$1);
1675
+ const o$1 = e$1._reader;
1676
+ if (void 0 !== o$1 && Fe(o$1)) {
1677
+ const e$2 = o$1._readIntoRequests;
1678
+ o$1._readIntoRequests = new S(), e$2.forEach((e$3) => {
1679
+ e$3._closeSteps(void 0);
1680
+ });
1681
+ }
1682
+ return p(e$1._readableStreamController[T](r$1), t);
1683
+ }
1684
+ function Xt(e$1) {
1685
+ e$1._state = "closed";
1686
+ const t$1 = e$1._reader;
1687
+ if (void 0 !== t$1 && (j(t$1), K(t$1))) {
1688
+ const e$2 = t$1._readRequests;
1689
+ t$1._readRequests = new S(), e$2.forEach((e$3) => {
1690
+ e$3._closeSteps();
1691
+ });
1692
+ }
1693
+ }
1694
+ function Jt(e$1, t$1) {
1695
+ e$1._state = "errored", e$1._storedError = t$1;
1696
+ const r$1 = e$1._reader;
1697
+ void 0 !== r$1 && (A(r$1, t$1), K(r$1) ? Z(r$1, t$1) : Ie(r$1, t$1));
1698
+ }
1699
+ function Kt(e$1) {
1700
+ return new TypeError(`ReadableStream.prototype.${e$1} can only be used on a ReadableStream`);
1701
+ }
1702
+ function Zt(e$1, t$1) {
1703
+ F(e$1, t$1);
1704
+ const r$1 = null == e$1 ? void 0 : e$1.highWaterMark;
1705
+ return M(r$1, "highWaterMark", "QueuingStrategyInit"), { highWaterMark: Y(r$1) };
1706
+ }
1707
+ Object.defineProperties(ReadableStream.prototype, {
1708
+ cancel: { enumerable: !0 },
1709
+ getReader: { enumerable: !0 },
1710
+ pipeThrough: { enumerable: !0 },
1711
+ pipeTo: { enumerable: !0 },
1712
+ tee: { enumerable: !0 },
1713
+ values: { enumerable: !0 },
1714
+ locked: { enumerable: !0 }
1715
+ }), n(ReadableStream.prototype.cancel, "cancel"), n(ReadableStream.prototype.getReader, "getReader"), n(ReadableStream.prototype.pipeThrough, "pipeThrough"), n(ReadableStream.prototype.pipeTo, "pipeTo"), n(ReadableStream.prototype.tee, "tee"), n(ReadableStream.prototype.values, "values"), "symbol" == typeof e.toStringTag && Object.defineProperty(ReadableStream.prototype, e.toStringTag, {
1716
+ value: "ReadableStream",
1717
+ configurable: !0
1718
+ }), "symbol" == typeof e.asyncIterator && Object.defineProperty(ReadableStream.prototype, e.asyncIterator, {
1719
+ value: ReadableStream.prototype.values,
1720
+ writable: !0,
1721
+ configurable: !0
1722
+ });
1723
+ const er = (e$1) => e$1.byteLength;
1724
+ n(er, "size");
1725
+ var ByteLengthQueuingStrategy = class {
1726
+ constructor(e$1) {
1727
+ $(e$1, 1, "ByteLengthQueuingStrategy"), e$1 = Zt(e$1, "First parameter"), this._byteLengthQueuingStrategyHighWaterMark = e$1.highWaterMark;
1728
+ }
1729
+ get highWaterMark() {
1730
+ if (!rr(this)) throw tr("highWaterMark");
1731
+ return this._byteLengthQueuingStrategyHighWaterMark;
1732
+ }
1733
+ get size() {
1734
+ if (!rr(this)) throw tr("size");
1735
+ return er;
1736
+ }
1737
+ };
1738
+ function tr(e$1) {
1739
+ return new TypeError(`ByteLengthQueuingStrategy.prototype.${e$1} can only be used on a ByteLengthQueuingStrategy`);
1740
+ }
1741
+ function rr(e$1) {
1742
+ return !!r(e$1) && !!Object.prototype.hasOwnProperty.call(e$1, "_byteLengthQueuingStrategyHighWaterMark") && e$1 instanceof ByteLengthQueuingStrategy;
1743
+ }
1744
+ Object.defineProperties(ByteLengthQueuingStrategy.prototype, {
1745
+ highWaterMark: { enumerable: !0 },
1746
+ size: { enumerable: !0 }
1747
+ }), "symbol" == typeof e.toStringTag && Object.defineProperty(ByteLengthQueuingStrategy.prototype, e.toStringTag, {
1748
+ value: "ByteLengthQueuingStrategy",
1749
+ configurable: !0
1750
+ });
1751
+ const or = () => 1;
1752
+ n(or, "size");
1753
+ var CountQueuingStrategy = class {
1754
+ constructor(e$1) {
1755
+ $(e$1, 1, "CountQueuingStrategy"), e$1 = Zt(e$1, "First parameter"), this._countQueuingStrategyHighWaterMark = e$1.highWaterMark;
1756
+ }
1757
+ get highWaterMark() {
1758
+ if (!ar(this)) throw nr("highWaterMark");
1759
+ return this._countQueuingStrategyHighWaterMark;
1760
+ }
1761
+ get size() {
1762
+ if (!ar(this)) throw nr("size");
1763
+ return or;
1764
+ }
1765
+ };
1766
+ function nr(e$1) {
1767
+ return new TypeError(`CountQueuingStrategy.prototype.${e$1} can only be used on a CountQueuingStrategy`);
1768
+ }
1769
+ function ar(e$1) {
1770
+ return !!r(e$1) && !!Object.prototype.hasOwnProperty.call(e$1, "_countQueuingStrategyHighWaterMark") && e$1 instanceof CountQueuingStrategy;
1771
+ }
1772
+ function ir(e$1, t$1, r$1) {
1773
+ return I(e$1, r$1), (r$2) => w(e$1, t$1, [r$2]);
1774
+ }
1775
+ function lr(e$1, t$1, r$1) {
1776
+ return I(e$1, r$1), (r$2) => g(e$1, t$1, [r$2]);
1777
+ }
1778
+ function sr(e$1, t$1, r$1) {
1779
+ return I(e$1, r$1), (r$2, o$1) => w(e$1, t$1, [r$2, o$1]);
1780
+ }
1781
+ Object.defineProperties(CountQueuingStrategy.prototype, {
1782
+ highWaterMark: { enumerable: !0 },
1783
+ size: { enumerable: !0 }
1784
+ }), "symbol" == typeof e.toStringTag && Object.defineProperty(CountQueuingStrategy.prototype, e.toStringTag, {
1785
+ value: "CountQueuingStrategy",
1786
+ configurable: !0
1787
+ });
1788
+ var TransformStream = class {
1789
+ constructor(e$1 = {}, t$1 = {}, r$1 = {}) {
1790
+ void 0 === e$1 && (e$1 = null);
1791
+ const o$1 = Ye(t$1, "Second parameter"), n$1 = Ye(r$1, "Third parameter"), a$1 = function(e$2, t$2) {
1792
+ F(e$2, t$2);
1793
+ const r$2 = null == e$2 ? void 0 : e$2.flush, o$2 = null == e$2 ? void 0 : e$2.readableType, n$2 = null == e$2 ? void 0 : e$2.start, a$2 = null == e$2 ? void 0 : e$2.transform, i$2 = null == e$2 ? void 0 : e$2.writableType;
1794
+ return {
1795
+ flush: void 0 === r$2 ? void 0 : ir(r$2, e$2, `${t$2} has member 'flush' that`),
1796
+ readableType: o$2,
1797
+ start: void 0 === n$2 ? void 0 : lr(n$2, e$2, `${t$2} has member 'start' that`),
1798
+ transform: void 0 === a$2 ? void 0 : sr(a$2, e$2, `${t$2} has member 'transform' that`),
1799
+ writableType: i$2
1800
+ };
1801
+ }(e$1, "First parameter");
1802
+ if (void 0 !== a$1.readableType) throw new RangeError("Invalid readableType specified");
1803
+ if (void 0 !== a$1.writableType) throw new RangeError("Invalid writableType specified");
1804
+ const i$1 = $e(n$1, 0), l$1 = Me(n$1), s$1 = $e(o$1, 1), f$1 = Me(o$1);
1805
+ let b$1;
1806
+ (function(e$2, t$2, r$2, o$2, n$2, a$2) {
1807
+ function i$2() {
1808
+ return t$2;
1809
+ }
1810
+ function l$2(t$3) {
1811
+ return function(e$3, t$4) {
1812
+ const r$3 = e$3._transformStreamController;
1813
+ if (e$3._backpressure) return p(e$3._backpressureChangePromise, () => {
1814
+ if ("erroring" === (Ge(e$3._writable) ? e$3._writable._state : e$3._writableState)) throw Ge(e$3._writable) ? e$3._writable._storedError : e$3._writableStoredError;
1815
+ return pr(r$3, t$4);
1816
+ });
1817
+ return pr(r$3, t$4);
1818
+ }(e$2, t$3);
1819
+ }
1820
+ function s$2(t$3) {
1821
+ return function(e$3, t$4) {
1822
+ return cr(e$3, t$4), c(void 0);
1823
+ }(e$2, t$3);
1824
+ }
1825
+ function u$1() {
1826
+ return function(e$3) {
1827
+ const t$3 = e$3._transformStreamController, r$3 = t$3._flushAlgorithm();
1828
+ return hr(t$3), p(r$3, () => {
1829
+ if ("errored" === e$3._readableState) throw e$3._readableStoredError;
1830
+ gr(e$3) && wr(e$3);
1831
+ }, (t$4) => {
1832
+ throw cr(e$3, t$4), e$3._readableStoredError;
1833
+ });
1834
+ }(e$2);
1835
+ }
1836
+ function d$1() {
1837
+ return function(e$3) {
1838
+ return fr(e$3, !1), e$3._backpressureChangePromise;
1839
+ }(e$2);
1840
+ }
1841
+ function f$2(t$3) {
1842
+ return dr(e$2, t$3), c(void 0);
1843
+ }
1844
+ e$2._writableState = "writable", e$2._writableStoredError = void 0, e$2._writableHasInFlightOperation = !1, e$2._writableStarted = !1, e$2._writable = function(e$3, t$3, r$3, o$3, n$3, a$3, i$3) {
1845
+ return new WritableStream({
1846
+ start(r$4) {
1847
+ e$3._writableController = r$4;
1848
+ try {
1849
+ const t$4 = r$4.signal;
1850
+ void 0 !== t$4 && t$4.addEventListener("abort", () => {
1851
+ "writable" === e$3._writableState && (e$3._writableState = "erroring", t$4.reason && (e$3._writableStoredError = t$4.reason));
1852
+ });
1853
+ } catch (e$4) {}
1854
+ return p(t$3(), () => (e$3._writableStarted = !0, Cr(e$3), null), (t$4) => {
1855
+ throw e$3._writableStarted = !0, Rr(e$3, t$4), t$4;
1856
+ });
1857
+ },
1858
+ write: (t$4) => (function(e$4) {
1859
+ e$4._writableHasInFlightOperation = !0;
1860
+ }(e$3), p(r$3(t$4), () => (function(e$4) {
1861
+ e$4._writableHasInFlightOperation = !1;
1862
+ }(e$3), Cr(e$3), null), (t$5) => {
1863
+ throw function(e$4, t$6) {
1864
+ e$4._writableHasInFlightOperation = !1, Rr(e$4, t$6);
1865
+ }(e$3, t$5), t$5;
1866
+ })),
1867
+ close: () => (function(e$4) {
1868
+ e$4._writableHasInFlightOperation = !0;
1869
+ }(e$3), p(o$3(), () => (function(e$4) {
1870
+ e$4._writableHasInFlightOperation = !1;
1871
+ "erroring" === e$4._writableState && (e$4._writableStoredError = void 0);
1872
+ e$4._writableState = "closed";
1873
+ }(e$3), null), (t$4) => {
1874
+ throw function(e$4, t$5) {
1875
+ e$4._writableHasInFlightOperation = !1, e$4._writableState, Rr(e$4, t$5);
1876
+ }(e$3, t$4), t$4;
1877
+ })),
1878
+ abort: (t$4) => (e$3._writableState = "errored", e$3._writableStoredError = t$4, n$3(t$4))
1879
+ }, {
1880
+ highWaterMark: a$3,
1881
+ size: i$3
1882
+ });
1883
+ }(e$2, i$2, l$2, u$1, s$2, r$2, o$2), e$2._readableState = "readable", e$2._readableStoredError = void 0, e$2._readableCloseRequested = !1, e$2._readablePulling = !1, e$2._readable = function(e$3, t$3, r$3, o$3, n$3, a$3) {
1884
+ return new ReadableStream({
1885
+ start: (r$4) => (e$3._readableController = r$4, t$3().catch((t$4) => {
1886
+ Sr(e$3, t$4);
1887
+ })),
1888
+ pull: () => (e$3._readablePulling = !0, r$3().catch((t$4) => {
1889
+ Sr(e$3, t$4);
1890
+ })),
1891
+ cancel: (t$4) => (e$3._readableState = "closed", o$3(t$4))
1892
+ }, {
1893
+ highWaterMark: n$3,
1894
+ size: a$3
1895
+ });
1896
+ }(e$2, i$2, d$1, f$2, n$2, a$2), e$2._backpressure = void 0, e$2._backpressureChangePromise = void 0, e$2._backpressureChangePromise_resolve = void 0, fr(e$2, !0), e$2._transformStreamController = void 0;
1897
+ })(this, u((e$2) => {
1898
+ b$1 = e$2;
1899
+ }), s$1, f$1, i$1, l$1), function(e$2, t$2) {
1900
+ const r$2 = Object.create(TransformStreamDefaultController.prototype);
1901
+ let o$2, n$2;
1902
+ o$2 = void 0 !== t$2.transform ? (e$3) => t$2.transform(e$3, r$2) : (e$3) => {
1903
+ try {
1904
+ return _r(r$2, e$3), c(void 0);
1905
+ } catch (e$4) {
1906
+ return d(e$4);
1907
+ }
1908
+ };
1909
+ n$2 = void 0 !== t$2.flush ? () => t$2.flush(r$2) : () => c(void 0);
1910
+ (function(e$3, t$3, r$3, o$3) {
1911
+ t$3._controlledTransformStream = e$3, e$3._transformStreamController = t$3, t$3._transformAlgorithm = r$3, t$3._flushAlgorithm = o$3;
1912
+ })(e$2, r$2, o$2, n$2);
1913
+ }(this, a$1), void 0 !== a$1.start ? b$1(a$1.start(this._transformStreamController)) : b$1(void 0);
1914
+ }
1915
+ get readable() {
1916
+ if (!ur(this)) throw yr("readable");
1917
+ return this._readable;
1918
+ }
1919
+ get writable() {
1920
+ if (!ur(this)) throw yr("writable");
1921
+ return this._writable;
1922
+ }
1923
+ };
1924
+ function ur(e$1) {
1925
+ return !!r(e$1) && !!Object.prototype.hasOwnProperty.call(e$1, "_transformStreamController") && e$1 instanceof TransformStream;
1926
+ }
1927
+ function cr(e$1, t$1) {
1928
+ Sr(e$1, t$1), dr(e$1, t$1);
1929
+ }
1930
+ function dr(e$1, t$1) {
1931
+ hr(e$1._transformStreamController), function(e$2, t$2) {
1932
+ e$2._writableController.error(t$2);
1933
+ "writable" === e$2._writableState && Tr(e$2, t$2);
1934
+ }(e$1, t$1), e$1._backpressure && fr(e$1, !1);
1935
+ }
1936
+ function fr(e$1, t$1) {
1937
+ void 0 !== e$1._backpressureChangePromise && e$1._backpressureChangePromise_resolve(), e$1._backpressureChangePromise = u((t$2) => {
1938
+ e$1._backpressureChangePromise_resolve = t$2;
1939
+ }), e$1._backpressure = t$1;
1940
+ }
1941
+ Object.defineProperties(TransformStream.prototype, {
1942
+ readable: { enumerable: !0 },
1943
+ writable: { enumerable: !0 }
1944
+ }), "symbol" == typeof e.toStringTag && Object.defineProperty(TransformStream.prototype, e.toStringTag, {
1945
+ value: "TransformStream",
1946
+ configurable: !0
1947
+ });
1948
+ var TransformStreamDefaultController = class {
1949
+ constructor() {
1950
+ throw new TypeError("Illegal constructor");
1951
+ }
1952
+ get desiredSize() {
1953
+ if (!br(this)) throw mr("desiredSize");
1954
+ return vr(this._controlledTransformStream);
1955
+ }
1956
+ enqueue(e$1) {
1957
+ if (!br(this)) throw mr("enqueue");
1958
+ _r(this, e$1);
1959
+ }
1960
+ error(e$1) {
1961
+ if (!br(this)) throw mr("error");
1962
+ var t$1;
1963
+ t$1 = e$1, cr(this._controlledTransformStream, t$1);
1964
+ }
1965
+ terminate() {
1966
+ if (!br(this)) throw mr("terminate");
1967
+ (function(e$1) {
1968
+ const t$1 = e$1._controlledTransformStream;
1969
+ gr(t$1) && wr(t$1);
1970
+ const r$1 = new TypeError("TransformStream terminated");
1971
+ dr(t$1, r$1);
1972
+ })(this);
1973
+ }
1974
+ };
1975
+ function br(e$1) {
1976
+ return !!r(e$1) && !!Object.prototype.hasOwnProperty.call(e$1, "_controlledTransformStream") && e$1 instanceof TransformStreamDefaultController;
1977
+ }
1978
+ function hr(e$1) {
1979
+ e$1._transformAlgorithm = void 0, e$1._flushAlgorithm = void 0;
1980
+ }
1981
+ function _r(e$1, t$1) {
1982
+ const r$1 = e$1._controlledTransformStream;
1983
+ if (!gr(r$1)) throw new TypeError("Readable side is not in a state that permits enqueue");
1984
+ try {
1985
+ (function(e$2, t$2) {
1986
+ e$2._readablePulling = !1;
1987
+ try {
1988
+ e$2._readableController.enqueue(t$2);
1989
+ } catch (t$3) {
1990
+ throw Sr(e$2, t$3), t$3;
1991
+ }
1992
+ })(r$1, t$1);
1993
+ } catch (e$2) {
1994
+ throw dr(r$1, e$2), r$1._readableStoredError;
1995
+ }
1996
+ const o$1 = function(e$2) {
1997
+ return !function(e$3) {
1998
+ if (!gr(e$3)) return !1;
1999
+ if (e$3._readablePulling) return !0;
2000
+ if (vr(e$3) > 0) return !0;
2001
+ return !1;
2002
+ }(e$2);
2003
+ }(r$1);
2004
+ o$1 !== r$1._backpressure && fr(r$1, !0);
2005
+ }
2006
+ function pr(e$1, t$1) {
2007
+ return p(e$1._transformAlgorithm(t$1), void 0, (t$2) => {
2008
+ throw cr(e$1._controlledTransformStream, t$2), t$2;
2009
+ });
2010
+ }
2011
+ function mr(e$1) {
2012
+ return new TypeError(`TransformStreamDefaultController.prototype.${e$1} can only be used on a TransformStreamDefaultController`);
2013
+ }
2014
+ function yr(e$1) {
2015
+ return new TypeError(`TransformStream.prototype.${e$1} can only be used on a TransformStream`);
2016
+ }
2017
+ function gr(e$1) {
2018
+ return !e$1._readableCloseRequested && "readable" === e$1._readableState;
2019
+ }
2020
+ function wr(e$1) {
2021
+ e$1._readableState = "closed", e$1._readableCloseRequested = !0, e$1._readableController.close();
2022
+ }
2023
+ function Sr(e$1, t$1) {
2024
+ "readable" === e$1._readableState && (e$1._readableState = "errored", e$1._readableStoredError = t$1), e$1._readableController.error(t$1);
2025
+ }
2026
+ function vr(e$1) {
2027
+ return e$1._readableController.desiredSize;
2028
+ }
2029
+ function Rr(e$1, t$1) {
2030
+ "writable" !== e$1._writableState ? qr(e$1) : Tr(e$1, t$1);
2031
+ }
2032
+ function Tr(e$1, t$1) {
2033
+ e$1._writableState = "erroring", e$1._writableStoredError = t$1, !function(e$2) {
2034
+ return e$2._writableHasInFlightOperation;
2035
+ }(e$1) && e$1._writableStarted && qr(e$1);
2036
+ }
2037
+ function qr(e$1) {
2038
+ e$1._writableState = "errored";
2039
+ }
2040
+ function Cr(e$1) {
2041
+ "erroring" === e$1._writableState && qr(e$1);
2042
+ }
2043
+ Object.defineProperties(TransformStreamDefaultController.prototype, {
2044
+ enqueue: { enumerable: !0 },
2045
+ error: { enumerable: !0 },
2046
+ terminate: { enumerable: !0 },
2047
+ desiredSize: { enumerable: !0 }
2048
+ }), n(TransformStreamDefaultController.prototype.enqueue, "enqueue"), n(TransformStreamDefaultController.prototype.error, "error"), n(TransformStreamDefaultController.prototype.terminate, "terminate"), "symbol" == typeof e.toStringTag && Object.defineProperty(TransformStreamDefaultController.prototype, e.toStringTag, {
2049
+ value: "TransformStreamDefaultController",
2050
+ configurable: !0
2051
+ });
2052
+
2053
+ //#endregion
2054
+ //#region node_modules/.pnpm/[email protected]/node_modules/formdata-node/lib/esm/isFunction.js
2055
+ const isFunction = (value) => typeof value === "function";
2056
+
2057
+ //#endregion
2058
+ //#region node_modules/.pnpm/[email protected]/node_modules/formdata-node/lib/esm/blobHelpers.js
2059
+ const CHUNK_SIZE = 65536;
2060
+ async function* clonePart(part) {
2061
+ const end = part.byteOffset + part.byteLength;
2062
+ let position = part.byteOffset;
2063
+ while (position !== end) {
2064
+ const size = Math.min(end - position, CHUNK_SIZE);
2065
+ const chunk = part.buffer.slice(position, position + size);
2066
+ position += chunk.byteLength;
2067
+ yield new Uint8Array(chunk);
2068
+ }
2069
+ }
2070
+ async function* consumeNodeBlob(blob) {
2071
+ let position = 0;
2072
+ while (position !== blob.size) {
2073
+ const chunk = blob.slice(position, Math.min(blob.size, position + CHUNK_SIZE));
2074
+ const buffer = await chunk.arrayBuffer();
2075
+ position += buffer.byteLength;
2076
+ yield new Uint8Array(buffer);
2077
+ }
2078
+ }
2079
+ async function* consumeBlobParts(parts, clone = false) {
2080
+ for (const part of parts) if (ArrayBuffer.isView(part)) if (clone) yield* clonePart(part);
2081
+ else yield part;
2082
+ else if (isFunction(part.stream)) yield* part.stream();
2083
+ else yield* consumeNodeBlob(part);
2084
+ }
2085
+ function* sliceBlob(blobParts, blobSize, start = 0, end) {
2086
+ end !== null && end !== void 0 || (end = blobSize);
2087
+ let relativeStart = start < 0 ? Math.max(blobSize + start, 0) : Math.min(start, blobSize);
2088
+ let relativeEnd = end < 0 ? Math.max(blobSize + end, 0) : Math.min(end, blobSize);
2089
+ const span = Math.max(relativeEnd - relativeStart, 0);
2090
+ let added = 0;
2091
+ for (const part of blobParts) {
2092
+ if (added >= span) break;
2093
+ const partSize = ArrayBuffer.isView(part) ? part.byteLength : part.size;
2094
+ if (relativeStart && partSize <= relativeStart) {
2095
+ relativeStart -= partSize;
2096
+ relativeEnd -= partSize;
2097
+ } else {
2098
+ let chunk;
2099
+ if (ArrayBuffer.isView(part)) {
2100
+ chunk = part.subarray(relativeStart, Math.min(partSize, relativeEnd));
2101
+ added += chunk.byteLength;
2102
+ } else {
2103
+ chunk = part.slice(relativeStart, Math.min(partSize, relativeEnd));
2104
+ added += chunk.size;
2105
+ }
2106
+ relativeEnd -= partSize;
2107
+ relativeStart = 0;
2108
+ yield chunk;
2109
+ }
2110
+ }
2111
+ }
2112
+
2113
+ //#endregion
2114
+ //#region node_modules/.pnpm/[email protected]/node_modules/formdata-node/lib/esm/Blob.js
2115
+ /*! Based on fetch-blob. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> & David Frank */
2116
+ var __classPrivateFieldGet$1 = void 0 && (void 0).__classPrivateFieldGet || function(receiver, state, kind, f$1) {
2117
+ if (kind === "a" && !f$1) throw new TypeError("Private accessor was defined without a getter");
2118
+ if (typeof state === "function" ? receiver !== state || !f$1 : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
2119
+ return kind === "m" ? f$1 : kind === "a" ? f$1.call(receiver) : f$1 ? f$1.value : state.get(receiver);
2120
+ };
2121
+ var __classPrivateFieldSet$1 = void 0 && (void 0).__classPrivateFieldSet || function(receiver, state, value, kind, f$1) {
2122
+ if (kind === "m") throw new TypeError("Private method is not writable");
2123
+ if (kind === "a" && !f$1) throw new TypeError("Private accessor was defined without a setter");
2124
+ if (typeof state === "function" ? receiver !== state || !f$1 : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
2125
+ return kind === "a" ? f$1.call(receiver, value) : f$1 ? f$1.value = value : state.set(receiver, value), value;
2126
+ };
2127
+ var _Blob_parts, _Blob_type, _Blob_size;
2128
+ var Blob = class Blob {
2129
+ constructor(blobParts = [], options = {}) {
2130
+ _Blob_parts.set(this, []);
2131
+ _Blob_type.set(this, "");
2132
+ _Blob_size.set(this, 0);
2133
+ options !== null && options !== void 0 || (options = {});
2134
+ if (typeof blobParts !== "object" || blobParts === null) throw new TypeError("Failed to construct 'Blob': The provided value cannot be converted to a sequence.");
2135
+ if (!isFunction(blobParts[Symbol.iterator])) throw new TypeError("Failed to construct 'Blob': The object must have a callable @@iterator property.");
2136
+ if (typeof options !== "object" && !isFunction(options)) throw new TypeError("Failed to construct 'Blob': parameter 2 cannot convert to dictionary.");
2137
+ const encoder = new TextEncoder();
2138
+ for (const raw of blobParts) {
2139
+ let part;
2140
+ if (ArrayBuffer.isView(raw)) part = new Uint8Array(raw.buffer.slice(raw.byteOffset, raw.byteOffset + raw.byteLength));
2141
+ else if (raw instanceof ArrayBuffer) part = new Uint8Array(raw.slice(0));
2142
+ else if (raw instanceof Blob) part = raw;
2143
+ else part = encoder.encode(String(raw));
2144
+ __classPrivateFieldSet$1(this, _Blob_size, __classPrivateFieldGet$1(this, _Blob_size, "f") + (ArrayBuffer.isView(part) ? part.byteLength : part.size), "f");
2145
+ __classPrivateFieldGet$1(this, _Blob_parts, "f").push(part);
2146
+ }
2147
+ const type = options.type === void 0 ? "" : String(options.type);
2148
+ __classPrivateFieldSet$1(this, _Blob_type, /^[\x20-\x7E]*$/.test(type) ? type : "", "f");
2149
+ }
2150
+ static [(_Blob_parts = /* @__PURE__ */ new WeakMap(), _Blob_type = /* @__PURE__ */ new WeakMap(), _Blob_size = /* @__PURE__ */ new WeakMap(), Symbol.hasInstance)](value) {
2151
+ return Boolean(value && typeof value === "object" && isFunction(value.constructor) && (isFunction(value.stream) || isFunction(value.arrayBuffer)) && /^(Blob|File)$/.test(value[Symbol.toStringTag]));
2152
+ }
2153
+ get type() {
2154
+ return __classPrivateFieldGet$1(this, _Blob_type, "f");
2155
+ }
2156
+ get size() {
2157
+ return __classPrivateFieldGet$1(this, _Blob_size, "f");
2158
+ }
2159
+ slice(start, end, contentType) {
2160
+ return new Blob(sliceBlob(__classPrivateFieldGet$1(this, _Blob_parts, "f"), this.size, start, end), { type: contentType });
2161
+ }
2162
+ async text() {
2163
+ const decoder = new TextDecoder();
2164
+ let result = "";
2165
+ for await (const chunk of consumeBlobParts(__classPrivateFieldGet$1(this, _Blob_parts, "f"))) result += decoder.decode(chunk, { stream: true });
2166
+ result += decoder.decode();
2167
+ return result;
2168
+ }
2169
+ async arrayBuffer() {
2170
+ const view = new Uint8Array(this.size);
2171
+ let offset = 0;
2172
+ for await (const chunk of consumeBlobParts(__classPrivateFieldGet$1(this, _Blob_parts, "f"))) {
2173
+ view.set(chunk, offset);
2174
+ offset += chunk.length;
2175
+ }
2176
+ return view.buffer;
2177
+ }
2178
+ stream() {
2179
+ const iterator = consumeBlobParts(__classPrivateFieldGet$1(this, _Blob_parts, "f"), true);
2180
+ return new ReadableStream({
2181
+ async pull(controller) {
2182
+ const { value, done } = await iterator.next();
2183
+ if (done) return queueMicrotask(() => controller.close());
2184
+ controller.enqueue(value);
2185
+ },
2186
+ async cancel() {
2187
+ await iterator.return();
2188
+ }
2189
+ });
2190
+ }
2191
+ get [Symbol.toStringTag]() {
2192
+ return "Blob";
2193
+ }
2194
+ };
2195
+ Object.defineProperties(Blob.prototype, {
2196
+ type: { enumerable: true },
2197
+ size: { enumerable: true },
2198
+ slice: { enumerable: true },
2199
+ stream: { enumerable: true },
2200
+ text: { enumerable: true },
2201
+ arrayBuffer: { enumerable: true }
2202
+ });
2203
+
2204
+ //#endregion
2205
+ //#region node_modules/.pnpm/[email protected]/node_modules/formdata-node/lib/esm/File.js
2206
+ var __classPrivateFieldSet = void 0 && (void 0).__classPrivateFieldSet || function(receiver, state, value, kind, f$1) {
2207
+ if (kind === "m") throw new TypeError("Private method is not writable");
2208
+ if (kind === "a" && !f$1) throw new TypeError("Private accessor was defined without a setter");
2209
+ if (typeof state === "function" ? receiver !== state || !f$1 : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
2210
+ return kind === "a" ? f$1.call(receiver, value) : f$1 ? f$1.value = value : state.set(receiver, value), value;
2211
+ };
2212
+ var __classPrivateFieldGet = void 0 && (void 0).__classPrivateFieldGet || function(receiver, state, kind, f$1) {
2213
+ if (kind === "a" && !f$1) throw new TypeError("Private accessor was defined without a getter");
2214
+ if (typeof state === "function" ? receiver !== state || !f$1 : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
2215
+ return kind === "m" ? f$1 : kind === "a" ? f$1.call(receiver) : f$1 ? f$1.value : state.get(receiver);
2216
+ };
2217
+ var _File_name, _File_lastModified;
2218
+ var File = class extends Blob {
2219
+ constructor(fileBits, name, options = {}) {
2220
+ super(fileBits, options);
2221
+ _File_name.set(this, void 0);
2222
+ _File_lastModified.set(this, 0);
2223
+ if (arguments.length < 2) throw new TypeError(`Failed to construct 'File': 2 arguments required, but only ${arguments.length} present.`);
2224
+ __classPrivateFieldSet(this, _File_name, String(name), "f");
2225
+ const lastModified = options.lastModified === void 0 ? Date.now() : Number(options.lastModified);
2226
+ if (!Number.isNaN(lastModified)) __classPrivateFieldSet(this, _File_lastModified, lastModified, "f");
2227
+ }
2228
+ static [(_File_name = /* @__PURE__ */ new WeakMap(), _File_lastModified = /* @__PURE__ */ new WeakMap(), Symbol.hasInstance)](value) {
2229
+ return value instanceof Blob && value[Symbol.toStringTag] === "File" && typeof value.name === "string";
2230
+ }
2231
+ get name() {
2232
+ return __classPrivateFieldGet(this, _File_name, "f");
2233
+ }
2234
+ get lastModified() {
2235
+ return __classPrivateFieldGet(this, _File_lastModified, "f");
2236
+ }
2237
+ get webkitRelativePath() {
2238
+ return "";
2239
+ }
2240
+ get [Symbol.toStringTag]() {
2241
+ return "File";
2242
+ }
2243
+ };
2244
+
2245
+ //#endregion
2246
+ //#region node_modules/.pnpm/[email protected]/node_modules/formdata-node/lib/esm/isFile.js
2247
+ const isFile = (value) => value instanceof File;
2248
+
2249
+ //#endregion
2250
+ export { Blob, File, isFile, isFunction };
dist/prompt-Cmq1pjHH.mjs ADDED
The diff for this file is too large to render. See raw diff
 
dist/prompt-DoC83bWw.mjs ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ import { PromptTemplate } from "./prompt-Cmq1pjHH.mjs";
2
+
3
+ export { PromptTemplate };
langgraph.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "node_version": "20",
3
+ "dockerfile_lines": ["RUN npm i -g corepack@latest"],
4
+ "dependencies": ["."],
5
+ "graphs": {
6
+ "auto-anime-agent": "./dist/agent.mjs:graph"
7
+ },
8
+ "env": ".env"
9
+ }
package.json ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@autoanim/web",
3
+ "private": true,
4
+ "sideEffects": false,
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev:web": "vite dev",
8
+ "dev:agent:langgraph": "pnpx @langchain/langgraph-cli dev --port 8123",
9
+ "dev:agent:mastra": "mastra dev --dir src/agent/mastra",
10
+ "build:web": "vite build",
11
+ "build:agent:langgraph": "pnpx @langchain/langgraph-cli build --dir src/agent/langgraph",
12
+ "start": "vite start",
13
+ "typecheck": "tsc --noEmit",
14
+ "shadcn": "pnpm dlx shadcn@latest"
15
+ },
16
+ "dependencies": {
17
+ "@ag-ui/client": "^0.0.28",
18
+ "@ag-ui/core": "^0.0.28",
19
+ "@ag-ui/encoder": "^0.0.28",
20
+ "@ai-sdk/openai": "^1.3.22",
21
+ "@ai-sdk/react": "^1.2.12",
22
+ "@aws-sdk/client-s3": "^3.826.0",
23
+ "@codemirror/lang-python": "^6.2.1",
24
+ "@codemirror/state": "^6.5.2",
25
+ "@codemirror/theme-one-dark": "^6.1.2",
26
+ "@codemirror/view": "^6.37.1",
27
+ "@copilotkit/react-core": "1.8.14",
28
+ "@copilotkit/react-ui": "1.8.14",
29
+ "@copilotkit/runtime": "1.8.14",
30
+ "@copilotkit/runtime-client-gql": "^1.8.14",
31
+ "@copilotkit/sdk-js": "^1.8.14",
32
+ "@copilotkit/shared": "1.8.14",
33
+ "@diffusionstudio/core": "^3.8.3",
34
+ "@dnd-kit/core": "^6.3.1",
35
+ "@dnd-kit/modifiers": "^9.0.0",
36
+ "@dotenvx/dotenvx": "^1.44.1",
37
+ "@faker-js/faker": "^9.8.0",
38
+ "@fal-ai/client": "^1.5.0",
39
+ "@hono/standard-validator": "^0.1.2",
40
+ "@hookform/resolvers": "^5.0.1",
41
+ "@langchain/core": "^0.3.57",
42
+ "@langchain/langgraph": "^0.3.1",
43
+ "@langchain/openai": "^0.5.12",
44
+ "@legendapp/state": "3.0.0-beta.31",
45
+ "@mastra/agui": "1.0.2",
46
+ "@mastra/client-js": "^0.10.2",
47
+ "@mastra/core": "^0.10.3",
48
+ "@mastra/libsql": "^0.10.1",
49
+ "@mastra/loggers": "^0.10.1",
50
+ "@mastra/mcp": "^0.10.2",
51
+ "@mastra/memory": "^0.10.2",
52
+ "@notionhq/client": "^3.1.3",
53
+ "@openrouter/ai-sdk-provider": "^0.7.1",
54
+ "@radix-ui/react-accordion": "^1.2.11",
55
+ "@radix-ui/react-alert-dialog": "^1.1.14",
56
+ "@radix-ui/react-aspect-ratio": "^1.1.7",
57
+ "@radix-ui/react-avatar": "^1.1.10",
58
+ "@radix-ui/react-checkbox": "^1.3.2",
59
+ "@radix-ui/react-collapsible": "^1.1.11",
60
+ "@radix-ui/react-context-menu": "^2.2.15",
61
+ "@radix-ui/react-dialog": "^1.1.14",
62
+ "@radix-ui/react-dropdown-menu": "^2.1.15",
63
+ "@radix-ui/react-hover-card": "^1.1.14",
64
+ "@radix-ui/react-label": "^2.1.7",
65
+ "@radix-ui/react-menubar": "^1.1.15",
66
+ "@radix-ui/react-navigation-menu": "^1.2.13",
67
+ "@radix-ui/react-popover": "^1.1.14",
68
+ "@radix-ui/react-progress": "^1.1.7",
69
+ "@radix-ui/react-radio-group": "^1.3.7",
70
+ "@radix-ui/react-scroll-area": "^1.2.9",
71
+ "@radix-ui/react-select": "^2.2.5",
72
+ "@radix-ui/react-separator": "^1.1.7",
73
+ "@radix-ui/react-slider": "^1.3.5",
74
+ "@radix-ui/react-slot": "^1.2.3",
75
+ "@radix-ui/react-switch": "^1.2.5",
76
+ "@radix-ui/react-tabs": "^1.1.12",
77
+ "@radix-ui/react-toggle": "^1.1.9",
78
+ "@radix-ui/react-toggle-group": "^1.1.10",
79
+ "@radix-ui/react-tooltip": "^1.2.7",
80
+ "@stepperize/react": "^5.1.6",
81
+ "@tanstack/react-query": "^5.80.6",
82
+ "@tanstack/react-query-devtools": "^5.80.6",
83
+ "@tanstack/react-router": "1.121.0-alpha.22",
84
+ "@tanstack/react-router-devtools": "1.121.0-alpha.22",
85
+ "@tanstack/react-router-with-query": "1.121.0-alpha.22",
86
+ "@tanstack/react-start": "1.121.0-alpha.26",
87
+ "@tanstack/react-table": "^8.21.3",
88
+ "@tavily/core": "^0.5.6",
89
+ "ai": "^4.3.16",
90
+ "arktype": "^2.1.20",
91
+ "class-variance-authority": "^0.7.1",
92
+ "clsx": "^2.1.1",
93
+ "cmdk": "^1.1.1",
94
+ "codemirror": "^6.0.1",
95
+ "confbox": "^0.2.2",
96
+ "date-fns": "^4.1.0",
97
+ "decode-formdata": "^0.9.0",
98
+ "drizzle-orm": "^0.44.2",
99
+ "embla-carousel": "^8.6.0",
100
+ "embla-carousel-react": "^8.6.0",
101
+ "fast-deep-equal": "^3.1.3",
102
+ "fetch-event-stream": "^0.1.5",
103
+ "framer-motion": "^12.16.0",
104
+ "hono": "^4.7.11",
105
+ "html-to-text": "^9.0.5",
106
+ "input-otp": "^1.4.2",
107
+ "lodash-es": "^4.17.21",
108
+ "lucide-react": "^0.514.0",
109
+ "mastra": "^0.10.3",
110
+ "media-chrome": "^4.11.0",
111
+ "motion": "^12.16.0",
112
+ "openai": "^5.3.0",
113
+ "papaparse": "^5.5.3",
114
+ "postgres": "^3.4.7",
115
+ "prosemirror-example-setup": "^1.2.3",
116
+ "prosemirror-inputrules": "^1.5.0",
117
+ "prosemirror-markdown": "^1.13.2",
118
+ "prosemirror-model": "^1.25.1",
119
+ "prosemirror-schema-basic": "^1.2.4",
120
+ "prosemirror-schema-list": "^1.5.1",
121
+ "prosemirror-state": "^1.4.3",
122
+ "prosemirror-view": "^1.40.0",
123
+ "react": "^19.0.0",
124
+ "react-data-grid": "7.0.0-beta.56",
125
+ "react-day-picker": "8.10.1",
126
+ "react-dom": "^19.0.0",
127
+ "react-dropzone": "^14.3.8",
128
+ "react-hook-form": "^7.57.0",
129
+ "react-markdown": "^10.1.0",
130
+ "react-medium-image-zoom": "^5.2.14",
131
+ "react-resizable-panels": "^3.0.2",
132
+ "recharts": "^2.15.3",
133
+ "redaxios": "^0.5.1",
134
+ "redis": "^5.5.6",
135
+ "remark-gfm": "^4.0.1",
136
+ "resumable-stream": "^2.2.0",
137
+ "rxjs": "^7.8.2",
138
+ "shosho": "^1.4.3",
139
+ "sonner": "^2.0.5",
140
+ "tailwind-merge": "^3.3.0",
141
+ "ulid": "^3.0.1",
142
+ "usehooks-ts": "^3.1.1",
143
+ "vaul": "^1.1.2",
144
+ "zod": "^3.25.57"
145
+ },
146
+ "devDependencies": {
147
+ "@types/html-to-text": "^9.0.4",
148
+ "@types/lodash-es": "^4.17.12",
149
+ "@types/node": "^22.15.30",
150
+ "@types/papaparse": "^5.3.16",
151
+ "@types/react": "^19.1.6",
152
+ "@types/react-dom": "^19.1.6",
153
+ "tw-animate-css": "^1.3.4"
154
+ }
155
+ }
pnpm-lock.yaml ADDED
The diff for this file is too large to render. See raw diff
 
release.sh ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ set -e # Exit on any error
4
+
5
+ echo "Starting release process..."
6
+
7
+ # Execute build script
8
+ echo "Running build script..."
9
+ ./build.sh
10
+
11
+ # Check if build was successful
12
+ if [ $? -ne 0 ]; then
13
+ echo "Error: Build failed, aborting release"
14
+ exit 1
15
+ fi
16
+
17
+ echo "Build completed successfully, preparing git operations..."
18
+
19
+ # Add all new build artifacts
20
+ echo "Adding build artifacts to git..."
21
+ git add .output/
22
+ git add .env 2>/dev/null || echo "No .env file to add"
23
+ git add .env.example 2>/dev/null || echo "No .env.example file to add"
24
+
25
+ # Check if there are any changes to commit
26
+ if git diff --staged --quiet; then
27
+ echo "No changes to commit, release process completed"
28
+ exit 0
29
+ fi
30
+
31
+ # Get current timestamp for commit message
32
+ TIMESTAMP=$(date '+%Y-%m-%d %H:%M:%S')
33
+
34
+ # Commit changes
35
+ echo "Committing changes..."
36
+ git commit -m "chore: update build artifacts - $TIMESTAMP"
37
+
38
+ # Push changes
39
+ echo "Pushing changes to remote..."
40
+ git push
41
+
42
+ # Get git remote URL and generate HF Space short link
43
+ echo "Generating Hugging Face Space link..."
44
+ GIT_URL=$(git remote get-url origin)
45
+ echo "Git remote URL: $GIT_URL"
46
+
47
+ # Extract repo path from HF Space URL and generate short link
48
+ if [[ $GIT_URL == *"huggingface.co"* ]]; then
49
+ # Extract the repo path (remove .git suffix if present)
50
+ REPO_PATH=$(echo "$GIT_URL" | sed -E 's|.*huggingface\.co/spaces/([^/]+/[^/]+)(\.git)?.*|\1|')
51
+ HF_SHORT_LINK="https://hf.co/spaces/$REPO_PATH"
52
+ echo "🚀 Hugging Face Space: $HF_SHORT_LINK"
53
+ else
54
+ echo "Note: This doesn't appear to be a Hugging Face Space repository"
55
+ fi
56
+
57
+ echo "Release completed successfully!"
58
+ echo "Build artifacts have been committed and pushed to remote repository"