@fieldwangai/agentflow 0.1.141 → 0.1.143
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/lib/ui-server.mjs +651 -12
- package/bin/lib/workflow-report.mjs +127 -1
- package/builtin/web-ui/dist/assets/{WorkflowAssistantThread-ubxHcM7p.js → WorkflowAssistantThread-BttvNPJr.js} +1 -1
- package/builtin/web-ui/dist/assets/index-CtG65J3e.css +1 -0
- package/builtin/web-ui/dist/assets/index-c8AUUsSF.js +839 -0
- package/builtin/web-ui/dist/index.html +2 -2
- package/package.json +1 -1
- package/skills/agentflow-cli/SKILL.md +5 -0
- package/skills/agentflow-cli/scripts/agentflow-cli.mjs +6 -2
- package/skills/agentflow-cli/scripts/workflow-report-client.mjs +2 -1
- package/skills/agentflow-workflow-report/SKILL.md +8 -1
- package/skills/agentflow-workflow-report/references/protocol.md +138 -7
- package/builtin/pipelines/jenkins-build-notify/flow.yaml +0 -217
- package/builtin/web-ui/dist/assets/index-B6TWUomI.css +0 -1
- package/builtin/web-ui/dist/assets/index-DQzcZp7S.js +0 -590
|
@@ -11,6 +11,8 @@ const WORKFLOW_ACTION_STATUSES = new Set([
|
|
|
11
11
|
"cancelled",
|
|
12
12
|
"observed",
|
|
13
13
|
]);
|
|
14
|
+
const WORKFLOW_CHECKLIST_COMPLETION_POLICIES = new Set(["all_required", "any_required", "manual"]);
|
|
15
|
+
const WORKFLOW_CHECKLIST_ITEM_STATUSES = new Set(["pending", "passed", "failed", "blocked", "skipped"]);
|
|
14
16
|
const UNSAFE_OBJECT_KEYS = new Set(["__proto__", "prototype", "constructor"]);
|
|
15
17
|
|
|
16
18
|
function plainObject(value) {
|
|
@@ -109,6 +111,98 @@ function normalizeStringList(value, maxItems = 100) {
|
|
|
109
111
|
return uniqueValues(list.map((item) => cleanString(item, 240)).filter(Boolean)).slice(0, maxItems);
|
|
110
112
|
}
|
|
111
113
|
|
|
114
|
+
function normalizeChecklistSection(value, index = 0) {
|
|
115
|
+
const raw = plainObject(value);
|
|
116
|
+
const rawContent = raw.content ?? raw.value ?? raw.text ?? "";
|
|
117
|
+
const content = Array.isArray(rawContent)
|
|
118
|
+
? rawContent.map((item) => cleanString(item, 4000)).filter(Boolean).slice(0, 100)
|
|
119
|
+
: cleanString(rawContent, 12000);
|
|
120
|
+
return {
|
|
121
|
+
key: cleanString(raw.key || raw.id || `section-${index + 1}`, 120),
|
|
122
|
+
title: cleanString(raw.title || raw.label || `Section ${index + 1}`, 500),
|
|
123
|
+
content,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function normalizeWorkflowChecklist(value) {
|
|
128
|
+
const raw = plainObject(value);
|
|
129
|
+
const rawDocument = plainObject(raw.document);
|
|
130
|
+
const items = (Array.isArray(raw.items) ? raw.items : []).map((value, index) => {
|
|
131
|
+
const item = plainObject(value);
|
|
132
|
+
const rawDetail = item.detail;
|
|
133
|
+
const detailObject = plainObject(rawDetail);
|
|
134
|
+
const sections = Array.isArray(detailObject.sections)
|
|
135
|
+
? detailObject.sections.map((section, sectionIndex) => normalizeChecklistSection(section, sectionIndex))
|
|
136
|
+
: [];
|
|
137
|
+
const summary = typeof rawDetail === "string"
|
|
138
|
+
? cleanString(rawDetail, 4000)
|
|
139
|
+
: cleanString(detailObject.summary || detailObject.description, 4000);
|
|
140
|
+
return {
|
|
141
|
+
key: cleanString(item.key || item.id, 240),
|
|
142
|
+
title: cleanString(item.title || item.label || item.key || item.id || `Item ${index + 1}`, 500),
|
|
143
|
+
required: item.required !== false,
|
|
144
|
+
...(summary || sections.length ? { detail: { ...(summary ? { summary } : {}), ...(sections.length ? { sections } : {}) } } : {}),
|
|
145
|
+
...(item.evidenceRequired === true || item.evidence_required === true ? { evidenceRequired: true } : {}),
|
|
146
|
+
};
|
|
147
|
+
});
|
|
148
|
+
const completionPolicy = cleanString(raw.completionPolicy || raw.completion_policy || "all_required", 40).toLowerCase();
|
|
149
|
+
const documentUrl = cleanString(rawDocument.url || rawDocument.href, 4000);
|
|
150
|
+
return {
|
|
151
|
+
schemaVersion: 1,
|
|
152
|
+
completionPolicy,
|
|
153
|
+
document: {
|
|
154
|
+
title: cleanString(rawDocument.title || rawDocument.label || "Checklist 详情", 500),
|
|
155
|
+
...(rawDocument.artifactKey || rawDocument.artifact_key ? { artifactKey: cleanString(rawDocument.artifactKey || rawDocument.artifact_key, 500) } : {}),
|
|
156
|
+
...(documentUrl ? { url: documentUrl } : {}),
|
|
157
|
+
},
|
|
158
|
+
items,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function validateWorkflowChecklist(value) {
|
|
163
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return "action.checklist must be an object";
|
|
164
|
+
const raw = plainObject(value);
|
|
165
|
+
const schemaVersion = Number(raw.schemaVersion ?? raw.schema_version ?? 1);
|
|
166
|
+
if (schemaVersion !== 1) return `Unsupported action.checklist schemaVersion: ${schemaVersion}`;
|
|
167
|
+
const completionPolicy = rawString(raw.completionPolicy || raw.completion_policy || "all_required").toLowerCase();
|
|
168
|
+
if (!WORKFLOW_CHECKLIST_COMPLETION_POLICIES.has(completionPolicy)) {
|
|
169
|
+
return `Invalid action.checklist completionPolicy: ${completionPolicy}`;
|
|
170
|
+
}
|
|
171
|
+
if (!Array.isArray(raw.items) || raw.items.length === 0) return "action.checklist requires at least one item";
|
|
172
|
+
if (raw.items.length > 100) return "action.checklist supports at most 100 items";
|
|
173
|
+
const seen = new Set();
|
|
174
|
+
for (let index = 0; index < raw.items.length; index += 1) {
|
|
175
|
+
const item = raw.items[index];
|
|
176
|
+
if (!item || typeof item !== "object" || Array.isArray(item)) return `action.checklist.items[${index}] must be an object`;
|
|
177
|
+
const key = rawString(item.key || item.id);
|
|
178
|
+
if (!key || key.length > 240 || /[\0\r\n]/.test(key)) return `action.checklist.items[${index}].key is invalid`;
|
|
179
|
+
if (seen.has(key)) return `action.checklist.items[${index}].key must be unique`;
|
|
180
|
+
seen.add(key);
|
|
181
|
+
if (stringExceeds(item.title || item.label || key, 500)) return `action.checklist.items[${index}].title exceeds 500 characters`;
|
|
182
|
+
if (item.detail != null && typeof item.detail !== "string" && (!item.detail || typeof item.detail !== "object" || Array.isArray(item.detail))) {
|
|
183
|
+
return `action.checklist.items[${index}].detail must be a string or object`;
|
|
184
|
+
}
|
|
185
|
+
const detail = plainObject(item.detail);
|
|
186
|
+
if (typeof item.detail === "string" && stringExceeds(item.detail, 4000)) return `action.checklist.items[${index}].detail exceeds 4000 characters`;
|
|
187
|
+
if (stringExceeds(detail.summary || detail.description, 4000)) return `action.checklist.items[${index}].detail.summary exceeds 4000 characters`;
|
|
188
|
+
if (detail.sections != null && !Array.isArray(detail.sections)) return `action.checklist.items[${index}].detail.sections must be an array`;
|
|
189
|
+
if (Array.isArray(detail.sections) && detail.sections.length > 50) return `action.checklist.items[${index}].detail.sections supports at most 50 entries`;
|
|
190
|
+
}
|
|
191
|
+
const document = plainObject(raw.document);
|
|
192
|
+
if (stringExceeds(document.title || document.label, 500)) return "action.checklist.document.title exceeds 500 characters";
|
|
193
|
+
if (stringExceeds(document.artifactKey || document.artifact_key, 500)) return "action.checklist.document.artifactKey exceeds 500 characters";
|
|
194
|
+
const documentUrl = rawString(document.url || document.href);
|
|
195
|
+
if (documentUrl && !isSafeWorkflowUrl(documentUrl)) return "action.checklist.document.url must use http, https, or an absolute application path";
|
|
196
|
+
return "";
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export function normalizeWorkflowChecklistItemStatus(value) {
|
|
200
|
+
const raw = cleanString(value, 40).toLowerCase();
|
|
201
|
+
const aliases = { done: "passed", complete: "passed", completed: "passed", success: "passed", error: "failed", cancelled: "skipped", canceled: "skipped" };
|
|
202
|
+
const normalized = aliases[raw] || raw || "pending";
|
|
203
|
+
return WORKFLOW_CHECKLIST_ITEM_STATUSES.has(normalized) ? normalized : "pending";
|
|
204
|
+
}
|
|
205
|
+
|
|
112
206
|
function normalizeWorkflowArtifact(value, index = 0, defaultScope = "action") {
|
|
113
207
|
const raw = plainObject(value);
|
|
114
208
|
const url = cleanString(raw.url || raw.href, 4000);
|
|
@@ -347,6 +441,11 @@ export function normalizeWorkflowReport(payload = {}) {
|
|
|
347
441
|
if (stringExceeds(rawAction.issueKey || rawAction.issue_key, 240)) return { error: "Workflow action issueKey exceeds 240 characters" };
|
|
348
442
|
const rawTags = Array.isArray(rawAction.tags) ? rawAction.tags : rawAction.tags == null ? [] : [rawAction.tags];
|
|
349
443
|
if (rawTags.length > 100 || rawTags.some((tag) => stringExceeds(tag, 240))) return { error: "Workflow action tags exceed supported limits" };
|
|
444
|
+
const hasChecklist = hasOwn(rawAction, "checklist");
|
|
445
|
+
if (hasChecklist) {
|
|
446
|
+
const checklistError = validateWorkflowChecklist(rawAction.checklist);
|
|
447
|
+
if (checklistError) return { error: checklistError };
|
|
448
|
+
}
|
|
350
449
|
if (hasAction && !isKnownActionStatus(rawAction.status)) return { error: `Invalid workflow action status: ${rawAction.status}` };
|
|
351
450
|
const rawOccurredAt = rawString(rawAction.occurredAt || rawAction.occurred_at || rawAction.completedAt || rawAction.startedAt);
|
|
352
451
|
if (rawOccurredAt && !Number.isFinite(Date.parse(rawOccurredAt))) return { error: "action.occurredAt must be an ISO-compatible date" };
|
|
@@ -361,6 +460,7 @@ export function normalizeWorkflowReport(payload = {}) {
|
|
|
361
460
|
...(rawAction.platform ? { platform: cleanString(rawAction.platform, 80) } : {}),
|
|
362
461
|
...(rawAction.issueKey || rawAction.issue_key ? { issueKey: cleanString(rawAction.issueKey || rawAction.issue_key, 240) } : {}),
|
|
363
462
|
...(rawAction.tags != null ? { tags: normalizeStringList(rawAction.tags) } : {}),
|
|
463
|
+
...(hasChecklist ? { checklist: normalizeWorkflowChecklist(rawAction.checklist) } : {}),
|
|
364
464
|
occurredAt: cleanString(
|
|
365
465
|
rawAction.occurredAt ||
|
|
366
466
|
rawAction.occurred_at ||
|
|
@@ -539,6 +639,7 @@ export function normalizeWorkflowReport(payload = {}) {
|
|
|
539
639
|
...(action.platform ? { platform: action.platform } : {}),
|
|
540
640
|
...(action.issueKey ? { issueKey: action.issueKey } : {}),
|
|
541
641
|
...(action.tags ? { tags: action.tags } : {}),
|
|
642
|
+
...(action.checklist ? { checklist: action.checklist } : {}),
|
|
542
643
|
...(action.occurredAt ? { occurredAt: action.occurredAt } : {}),
|
|
543
644
|
} : {
|
|
544
645
|
title: cleanString(payload.title || "Workflow 全局状态更新", 500),
|
|
@@ -600,6 +701,24 @@ function resourceVersion(value) {
|
|
|
600
701
|
return `rv:${semanticHash(value)}`;
|
|
601
702
|
}
|
|
602
703
|
|
|
704
|
+
function actionDefinitionForVersion(event = {}) {
|
|
705
|
+
const action = plainObject(event.actionModel);
|
|
706
|
+
if (!Object.keys(action).length) return event;
|
|
707
|
+
const checklist = plainObject(action.checklist);
|
|
708
|
+
if (!Object.keys(checklist).length) return action;
|
|
709
|
+
const items = Array.isArray(checklist.items)
|
|
710
|
+
? checklist.items.map((item) => {
|
|
711
|
+
const clean = { ...plainObject(item) };
|
|
712
|
+
delete clean.state;
|
|
713
|
+
return clean;
|
|
714
|
+
})
|
|
715
|
+
: [];
|
|
716
|
+
const cleanChecklist = { ...checklist, items };
|
|
717
|
+
delete cleanChecklist.progress;
|
|
718
|
+
delete cleanChecklist.source;
|
|
719
|
+
return { ...action, checklist: cleanChecklist };
|
|
720
|
+
}
|
|
721
|
+
|
|
603
722
|
function addObjectResourceVersions(out, prefix, value, path = []) {
|
|
604
723
|
if (value === undefined) return;
|
|
605
724
|
if (path.length) out[`${prefix}:${path.join(".")}`] = resourceVersion(value);
|
|
@@ -617,8 +736,15 @@ export function workflowSnapshotResourceVersions(snapshot = {}) {
|
|
|
617
736
|
: [];
|
|
618
737
|
for (const event of runtimeEvents) {
|
|
619
738
|
const source = cleanString(event?.source || event?.producer || "agentflow", 120).toLowerCase() || "agentflow";
|
|
739
|
+
const checklistState = plainObject(event?.checklistState || event?.checklist_state);
|
|
740
|
+
const checklistSource = cleanString(checklistState.producer || checklistState.source, 120).toLowerCase();
|
|
741
|
+
const checklistActionKey = cleanString(checklistState.actionKey || checklistState.action_key, 240);
|
|
742
|
+
const checklistItemKey = cleanString(checklistState.itemKey || checklistState.item_key, 240);
|
|
743
|
+
if (checklistSource && checklistActionKey && checklistItemKey) {
|
|
744
|
+
out[`checklist:${checklistSource}:${checklistActionKey}:${checklistItemKey}`] = resourceVersion(checklistState);
|
|
745
|
+
}
|
|
620
746
|
const actionKey = cleanString(event?.actionModel?.key || event?.action || event?.actionId || event?.stageKey, 240);
|
|
621
|
-
if (actionKey && event?.auxiliary !== true) out[`action:${source}:${actionKey}`] = resourceVersion(event);
|
|
747
|
+
if (actionKey && event?.auxiliary !== true) out[`action:${source}:${actionKey}`] = resourceVersion(actionDefinitionForVersion(event));
|
|
622
748
|
for (const artifact of Array.isArray(event?.artifacts) ? event.artifacts : []) {
|
|
623
749
|
const producer = cleanString(artifact?.producer || source, 120).toLowerCase() || source;
|
|
624
750
|
const key = cleanString(artifact?.key || artifact?.artifactKey || artifact?.artifact_key, 500);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Lo=Object.defineProperty;var Vo=(t,e,s)=>e in t?Lo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var m=(t,e,s)=>Vo(t,typeof e!="symbol"?e+"":e,s);import{R as J,r as M,j as p,g as Uo,a as qo,b as Ho,M as zo}from"./index-DQzcZp7S.js";function Gt(){return Gt=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var r in s)({}).hasOwnProperty.call(s,r)&&(t[r]=s[r])}return t},Gt.apply(null,arguments)}let je=null;function Go(t,e){t.currentIndex=0,t.wipContextDeps=null,t.wipCommitCallbacks=[];const s=je;je=t;try{if(e(),t.isFirstRender=!1,t.cells.length!==t.currentIndex)throw new Error(`Rendered ${t.currentIndex} hooks but expected ${t.cells.length}. Hooks must be called in the exact same order in every render.`)}finally{je=s}}function Se(){if(!je)throw new Error("No resource fiber available");return je}function Ve(){return je}const ls=Symbol("tap.Context.defaultValue"),Ko=t=>t;let ge=new Map;const Ie=new Set,Jr=()=>new Map(ge),Ks=(t,e)=>{const s=ge;ge=t;try{return e()}finally{ge=s}},Xr=(t,e)=>{t[ls]=e},Zr=t=>typeof t=="object"&&t!==null&&ls in t,en=t=>typeof t=="object"&&t!==null&&"$$typeof"in t&&t.$$typeof===Symbol.for("react.context"),us=t=>Zr(t)||en(t),tn=t=>{if(!Zr(t)){if(en(t)){Xr(t,t._currentValue??t._currentValue2);return}throw new Error("A tap resource's `use()` only accepts a tap context.")}},sn=(t,e,s)=>{if(typeof t!="object"||t===null)throw new Error("useContextProvider only accepts a React context.");tn(t);const r=t,n=Se(),i=V(void 0),o=i.current===void 0||!Object.is(i.current.value,e);N(()=>{i.current={value:e}},[e]);const a=ge.get(r),c=a!==void 0||ge.has(r);ge.set(r,{value:e,source:n});try{return Wo(r,o,s)}finally{c?ge.set(r,a):ge.delete(r)}},Wo=(t,e,s)=>{const r=Ie.has(t);e?Ie.add(t):Ie.delete(t);try{return s()}finally{r?Ie.add(t):Ie.delete(t)}},Qo=t=>{tn(t);const e=t,s=Yo(e,t),r=Se();return(r.wipContextDeps??(r.wipContextDeps=new Map)).set(e,s.source),s.value},Yo=(t,e)=>ge.get(t)??{value:Ko(e)[ls],source:null},Jo=(t,e,s,r)=>{if(!r)return s;let n=s;for(const[i,o]of r)o===e||o===t||(n??(n=new Map)).set(i,o);return n},rn=(t,e=t.wipContextDeps)=>{const s=Ve();!s||!e||(s.wipContextDeps=Jo(s,t,s.wipContextDeps,e))},nn=()=>Ie.size>0,ds=t=>{if(!t.contextDeps||!nn())return!1;for(const e of Ie.keys())if(t.contextDeps.has(e))return!0;return!1},hs=(t,e)=>{if(t.length!==0){if(t.length===1)throw t[0];for(const s of t)console.error(s);throw new AggregateError(t,e)}},ye={HookState:0,EffectEvent:1,PassiveEffectCleanup:2,PassiveEffectSetup:3},Xo=[ye.HookState,ye.EffectEvent,ye.PassiveEffectCleanup,ye.PassiveEffectSetup];function Zo(t){const e=[];for(const s of Xo){const r=t[s];if(r!==void 0)for(let n=0;n<r.length;n++)try{r[n]()}catch(i){e.push(i)}}hs(e,"Errors during commit")}function ea(t){var s;const e=[];for(const r of t.cells)if((r==null?void 0:r.type)==="effect"&&(r.deps=null,r.cleanup))try{(s=r.cleanup)==null||s.call(r)}catch(n){e.push(n)}finally{r.cleanup=void 0}hs(e,"Errors during cleanup")}const on=t=>({version:0,committedVersion:0,context:Jr(),dispatchUpdate:t,changelog:[],rollbackCallbacks:[]}),gt=t=>{t.committedVersion=t.version,t.changelog.length=0,t.rollbackCallbacks.length=0},We=(t,e)=>{const s=t.version>e;if(t.version=e,s){for(let r=0;r<t.rollbackCallbacks.length;r++)t.rollbackCallbacks[r]();if(t.rollbackCallbacks.length=0,e<=t.committedVersion)t.committedVersion=e,t.changelog.length=0;else{for(;t.committedVersion+t.changelog.length>e;)t.changelog.pop();for(let r=0;r<t.changelog.length;r++)an(t.changelog[r]);gt(t)}}},an=t=>{var e;ln(t.fiber,t.cell),t.queued||(t.queued=!0,((e=t.cell).queue??(e.queue=[])).push(t))},Xe=(t,e,s)=>{const r=t.wipCommitCallbacks;(r[e]??(r[e]=[])).push(s)},cn=(t,e)=>{t.rollbackCallbacks.push(e)},ln=(t,e)=>{var s;e.isDirty||(e.isDirty=!0,(s=t.markDirty)==null||s.call(t),cn(t.root,()=>{if(e.queue!==null){for(const r of e.queue)r.queued=!1;e.queue=null}e.workInProgress=e.current,e.isDirty=!1}))},fs=()=>{throw new Error("Rendered more hooks than during the previous render. Hooks must be called in the exact same order in every render.")},ps=()=>{throw new Error("Hook order changed between renders")},ta=(t,e,s)=>{if(t.isNeverMounted)throw new Error("Resource updated before mount");let r=!1,n=!0;t.root.dispatchUpdate(()=>(r||(r=!0,s&&t.root.changelog.length===0&&!e.cell.isDirty&&!e.hasEagerState&&(e.eagerState=s(e.cell.workInProgress,e.action),e.hasEagerState=!0,n=!Object.is(e.cell.current,e.eagerState))),n),()=>(r=!0,n=!0,an(e),t.root.changelog.push(e),!0))},sa=(t,e,s,r,n)=>{const i=r?r(s):s,o={type:"reducer",workInProgress:i,current:i,isDirty:!1,queue:null,renderQueue:null,reducer:e,dispatch:a=>{const c=Ve();if(c!==null){if(c!==t)throw new Error("Cannot update a resource while rendering a different resource.");(t.renderPendingCells??(t.renderPendingCells=new Set)).add(o),(o.renderQueue??(o.renderQueue=[])).push(a)}else ta(t,{fiber:t,cell:o,action:a,hasEagerState:!1,eagerState:void 0,queued:!1},n?e:void 0)}};return o};function un(t,e,s,r){var l;const n=Se(),i=n.currentIndex++,o=n.cells[i],a=(()=>{if(o!==void 0)return o.type==="reducer"?o:ps();!n.isFirstRender&&i>=n.cells.length&&fs();const u=sa(n,t,e,s,r);return n.cells[i]=u,u})(),c=a.queue;if(c!==null){const u=t===a.reducer;for(let h=0;h<c.length;h++){const d=c[h];(!d.hasEagerState||!u)&&(d.eagerState=t(a.workInProgress,d.action),d.hasEagerState=!0),d.queued=!1,a.workInProgress=d.eagerState}a.queue=null}if(a.reducer=t,a.renderQueue!==null){let u=a.workInProgress;for(const h of a.renderQueue)u=t(u,h);a.renderQueue=null,(l=n.renderPendingCells)==null||l.delete(a),Object.is(u,a.workInProgress)||(ln(n,a),a.workInProgress=u)}return a.isDirty&&Xe(n,ye.HookState,()=>{a.current=a.workInProgress,a.isDirty=!1}),[a.workInProgress,a.dispatch]}function dn(t,e,s){return un(t,e,s,!1)}const ra=(t,e)=>typeof e=="function"?e(t):e,na=t=>t===void 0?void 0:typeof t=="function"?t():t;function gs(t){return un(ra,t,na,!0)}const Et=(t,e)=>{for(let s=0;s<t.length&&s<e.length;s++)if(!Object.is(t[s],e[s]))return!1;return!0},Ws=(t,e)=>{Xe(t,ye.HookState,()=>{e.current=e.wip,e.currentDeps=e.wipDeps,e.isDirty=!1})},Rt=(t,e)=>{const s=Se(),r=s.currentIndex++;let n=s.cells[r];if(n===void 0){!s.isFirstRender&&r>=s.cells.length&&fs();const a=t();return n={type:"memo",current:a,currentDeps:e,wip:a,wipDeps:e,isDirty:!1},s.cells[r]=n,a}n.type!=="memo"&&ps();const i=n;if(Et(i.wipDeps,e))return i.isDirty&&Ws(s,i),i.wip;const o=t();return i.wip=o,i.wipDeps=e,i.isDirty||(i.isDirty=!0,cn(s.root,()=>{i.wip=i.current,i.wipDeps=i.currentDeps,i.isDirty=!1})),Ws(s,i),o};function At(t){return Rt(()=>({current:t}),[])}const ms=(t,e)=>Rt(()=>t,e),ia=()=>({type:"effect",cleanup:void 0,deps:null});function Be(t,e){const s=Se(),r=s.currentIndex++,n=s.cells[r],i=n===void 0?ia():n.type==="effect"?n:ps();if(n===void 0&&(!s.isFirstRender&&r>=s.cells.length&&fs(),s.cells[r]=i),!(e&&i.deps&&Et(i.deps,e))){if(i.deps!==null&&!!e!=!!i.deps)throw new Error("useEffect called with and without dependencies across re-renders");Xe(s,ye.PassiveEffectCleanup,()=>{var o;try{(o=i.cleanup)==null||o.call(i)}finally{i.cleanup=void 0}}),Xe(s,ye.PassiveEffectSetup,()=>{try{const o=t();if(o!==void 0&&typeof o!="function")throw new Error(`An effect function must either return a cleanup function or nothing. Received: ${typeof o}`);i.cleanup=o}finally{i.deps=e}})}}function bs(t){const e=Se(),s=At(t);return s.current!==t&&Xe(e,ye.EffectEvent,()=>{s.current=t}),ms((...r)=>s.current(...r),[])}const mt=t=>{if(!us(t))throw new Error("A tap resource's `use()` only accepts a tap context.");return Qo(t)},hn=(t,e,s=e)=>{const r=At(!0),n=r.current?s():e();r.current=!1;const[,i]=gs(0),o=bs(()=>{try{if(Object.is(n,e()))return}catch{return}i(a=>a+1)});return Be(()=>(o(),t(o)),[t]),n},fn=(t,e)=>{},oa=J;function aa(t){const e=M.useRef(t);return M.useInsertionEffect(()=>{e.current=t}),M.useCallback((...s)=>e.current(...s),[])}const ca=oa.useEffectEvent??aa,ie=()=>Ve()!==null,oe=J,G=t=>ie()?gs(t):oe.useState(t),la=(t,e,s)=>ie()?dn(t,e,s):oe.useReducer(t,e,s),V=t=>ie()?At(t):oe.useRef(t),Y=(t,e)=>ie()?Rt(t,e):oe.useMemo(t,e),Qe=(t,e)=>ie()?ms(t,e):oe.useCallback(t,e),N=(t,e)=>ie()?Be(t,e):oe.useEffect(t,e),bt=(t,e)=>ie()?Be(t,e):oe.useLayoutEffect(t,e),le=t=>ie()?bs(t):ca(t),Ue=(t,e,s)=>ie()?hn(t,e,s):oe.useSyncExternalStore(t,e,s),ua=(t,e)=>ie()?fn():oe.useDebugValue(t,e),ae=t=>{const e=oe.createContext(t);return Xr(e,t),e},pn=t=>ie()&&us(t)?mt(t):oe.use(t),he=t=>ie()&&us(t)?mt(t):oe.useContext(t),gn=Symbol.for("react.memo_cache_sentinel"),mn=t=>new Array(t).fill(gn),da=(t,e)=>{const s=t.memoCache;let r=s.workInProgress;if(r===null){const o=s.current;r=o===null?[]:o.map(a=>a.slice()),s.workInProgress=r}const n=s.index++;let i=r[n];return i===void 0&&(i=mn(e),r[n]=i),i},bn=t=>da(Se(),t),ha=J,fa=t=>M.useMemo(()=>{const e=mn(t);return e[gn]=!0,e},[]);var Yr;const pa=((Yr=ha.__COMPILER_RUNTIME)==null?void 0:Yr.c)??fa,ga=()=>Ve()!==null,_=t=>ga()?bn(t):pa(t);function q(t){return(...e)=>({hook:t,args:e})}function ne(t,e,s){return typeof e=="function"?(...r)=>ne(t,e(...r)):s?{...e,key:t,deps:s}:{...e,key:t}}const ma=50;let me={schedulers:new Set([]),isScheduled:!1},_e=null;var ba=class{constructor(t){m(this,"_isDirty",!1);m(this,"_task");this._task=t}get isDirty(){return this._isDirty}markDirty(){if(_e&&(_e.get(this)??0)>=ma)throw new Error("Maximum update depth exceeded. This can happen when a resource repeatedly calls setState inside useEffect.");this._isDirty=!0,me.schedulers.add(this),_a()}runTask(){_e==null||_e.set(this,(_e.get(this)??0)+1),this._isDirty=!1,this._task()}};const _a=()=>{me.isScheduled||(me.isScheduled=!0,ya())},Kt=()=>{const t=_e;_e=new Map;try{const e=[];for(const s of me.schedulers)if(me.schedulers.delete(s),!!s.isDirty)try{s.runTask()}catch(r){e.push(r)}hs(e,"Errors occurred during flushSync")}finally{_e=t,me.schedulers.clear(),me.isScheduled=!1}},ya=(()=>{if(typeof MessageChannel<"u"){let t=null,e;return()=>{var s;if(!t){const r=new MessageChannel;r.port1.onmessage=()=>{var n;(n=t==null?void 0:t.unref)==null||n.call(t),Kt()},t=r.port1,e=r.port2}(s=t.ref)==null||s.call(t),e.postMessage(null)}}return()=>setTimeout(Kt,0)})(),Qs=t=>{const e=me;me={schedulers:new Set([]),isScheduled:!0};try{const s=t();return Kt(),s}finally{me=e}},va={useState:gs,useReducer:dn,useRef:At,useMemo:Rt,useCallback:ms,useEffect:Be,useLayoutEffect:Be,useInsertionEffect:Be,useEffectEvent:bs,useContext:mt,use:mt,useSyncExternalStore:hn,useDebugValue:fn,useMemoCache:bn},Ys=J,Te=Ys.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE??Ys.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,nt=Te==null?null:"H"in Te?{get current(){return Te.H},set current(t){Te.H=t}}:"ReactCurrentDispatcher"in Te?{get current(){return Te.ReactCurrentDispatcher.current},set current(t){Te.ReactCurrentDispatcher.current=t}}:null;function Sa(t){if(!nt)return t();const e=nt.current;nt.current=va;try{return t()}finally{nt.current=e}}function _n(t,e,s=void 0,r){return{hook:t,root:e,markDirty:s,devStrictMode:r,cells:[],contextDeps:null,wipContextDeps:null,commitCallbacks:null,wipCommitCallbacks:null,memoCache:{current:null,workInProgress:null,index:0},renderPendingCells:null,currentIndex:0,isFirstRender:!0,isMounted:!1,isNeverMounted:!0}}function Oe(t){if(!t.isMounted)throw new Error("Tried to unmount a fiber that is already unmounted");t.isMounted=!1,ea(t)}function Ee(t,e){var n;if(t.memoCache.workInProgress=null,t.renderPendingCells!==null){for(const i of t.renderPendingCells)i.renderQueue=null;t.renderPendingCells.clear()}let s=0,r;do{if(++s>25)throw new Error("Too many re-renders. tap limits the number of renders to prevent an infinite loop.");t.memoCache.index=0,Go(t,()=>{r=Sa(()=>t.hook(...e))})}while((((n=t.renderPendingCells)==null?void 0:n.size)??0)>0);return rn(t),r}function Ze(t){const e=t.wipCommitCallbacks??t.commitCallbacks??[];t.wipCommitCallbacks=null,t.commitCallbacks=e,t.isMounted=!0,t.contextDeps=t.wipContextDeps,gt(t.root),t.memoCache.workInProgress!==null&&(t.memoCache.current=t.memoCache.workInProgress,t.memoCache.workInProgress=null),t.isNeverMounted=!1,Zo(e)}const xa=()=>{const t=Se();return t.devStrictMode?t.isFirstRender?"child":"root":null},wa=()=>null,Ta=()=>wa,yn=()=>Ve()?xa:Ta(),Ca=t=>t(),Ia=t=>{const[e]=G(()=>new ba(()=>f())),[s]=G(()=>[]),r=yn(),[n]=G(()=>{const g=on((b,v)=>{if(!e.isDirty){if(!b())return;v()}We(g,g.committedVersion+g.changelog.length),s.push(v),e.markDirty()});return _n(Ca,g,void 0,r())}),i=Jr(),o=n.root.version-n.root.committedVersion,a=Ks(i,()=>Ee(n,[t])),c=V(!1),l=V([t]),u=V(a),[h]=G(()=>new Set),d=g=>{e.isDirty||u.current===g||(u.current=g,h.forEach(b=>b()))},f=le(()=>{We(n.root,n.root.committedVersion),s.forEach(b=>{b()}),We(n.root,n.root.committedVersion+n.root.changelog.length);const g=Ks(n.root.context,()=>Ee(n,l.current));if(e.isDirty)throw new Error("Scheduler is dirty, this should never happen");gt(n.root),s.length=0,c.current&&Ze(n),d(g)});return N(()=>(c.current=!0,()=>{c.current=!1,Oe(n)}),[n]),N(()=>{l.current=[t],gt(n.root),s.splice(0,o),n.root.context=i,Ze(n),d(a)}),Y(()=>({getValue:()=>u.current,subscribe:g=>(h.add(g),()=>h.delete(g))}),[h])},Ea=()=>{const t=V(0),e=t.current,s=Se();return{version:e,markDirty:Y(()=>()=>{var r;t.current++,(r=s==null?void 0:s.markDirty)==null||r.call(s)},[s]),root:s.root}},Ra=()=>{const[t]=G(()=>on((n,i)=>{let o=!1;r(a=>(o=!n(),o?a:a+1)),o||s(i)})),[e,s]=la((n,i)=>(We(t,n),n+(i()?1:0)),0),[,r]=G(0);return We(t,e),{root:t,version:e,markDirty:void 0}},_s=()=>{const t=yn(),{root:e,version:s,markDirty:r}=Ve()?Ea():Ra();return{version:s,createFiber:Qe((n,i,o)=>_n(n,e,o?()=>{o(),r==null||r()}:r,t()),[])}},vn=(t,e,s)=>{const r=V(null),n=r.current??(r.current={wipDeps:null,wip:null,currentDeps:null,current:null});return n.wipDeps=n.currentDeps,n.wip=n.current,N(()=>{n.currentDeps=n.wipDeps,n.current=n.wip}),!s&&n.currentDeps&&Et(n.currentDeps,e)?n.current:(n.wipDeps=e,n.wip=t(),n.wip)};function se(t){const{version:e,createFiber:s}=_s(),r=Y(()=>s(t.hook,t.key),[t.hook,t.key,s]),n=vn(()=>({value:Ee(r,t.args)}),[r,e,t.args],ds(r));return N(()=>()=>Oe(r),[r]),N(()=>{Ze(r)},[r,n]),n.value}const Js=(t,e)=>{const s=t.get(e);s&&(s.isDirty=!0)},Aa=(t,e)=>!t.isDirty&&!ds(t.fiber)&&e!==void 0&&t.committedDeps!==void 0&&Et(t.committedDeps,e),Ma=t=>{if(!nn())return!1;for(const{fiber:e}of t.values())if(ds(e))return!0;return!1};function Mt(t){const[e]=G(()=>new Map),{version:s,createFiber:r}=_s(),n=Ma(e),i=vn(()=>{const o=new Set,a=[];let c=0;for(let l=0;l<t.length;l++){const u=t[l],h=u.key;if(h===void 0)throw new Error(`useResources did not provide a key for array at index ${l}`);if(o.has(h))throw new Error(`Duplicate key ${h} in useResources`);o.add(h);let d=e.get(h);if(d)if(d.fiber.hook!==u.hook){const f=r(u.hook,u.key,()=>Js(e,h)),g=Ee(f,u.args);d.next={value:g,deps:u.deps,remount:f}}else if(Aa(d,u.deps))d.fiber.contextDeps&&rn(d.fiber,d.fiber.contextDeps),d.next="skip";else{const f=Ee(d.fiber,u.args);d.next={value:f,deps:u.deps}}else{const f=r(u.hook,u.key,()=>Js(e,h));d={fiber:f,next:{value:Ee(f,u.args),deps:u.deps},isDirty:!1,committedDeps:void 0,committedValue:void 0},c++,e.set(h,d)}a.push(typeof d.next=="object"?d.next.value:d.committedValue)}if(e.size>a.length-c)for(const l of e.keys())o.has(l)||(e.get(l).next="delete");return a},[t,e,r,s],n);return N(()=>()=>{for(const o of e.keys()){const a=e.get(o).fiber;Oe(a)}},[e]),N(()=>{for(const[o,a]of e.entries()){const c=a.next;c==="delete"?(a.fiber.isMounted&&Oe(a.fiber),e.delete(o)):c==="skip"||(c.remount&&(Oe(a.fiber),a.fiber=c.remount),Ze(a.fiber),a.committedDeps=c.deps,a.committedValue=c.value,a.isDirty=!1)}},[i,e]),i}const Pa=t=>t(),ka=t=>{const{createFiber:e}=_s(),s=Y(()=>e(Pa,void 0),[e]),r=Ee(s,[t]);N(()=>()=>{Oe(s)},[s]);let n=!1;const i=()=>{n&&s.isMounted||(n=!0,Ze(s))};return N(i),{value:r,effects:i}},$a=()=>{const t=_(4),[e,s]=G(ja);let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=(c,l)=>(s(u=>({...u,renderers:{...u.renderers,[c]:[...u.renderers[c]??[],l]}})),()=>{s(u=>{var h;return{...u,renderers:{...u.renderers,[c]:((h=u.renderers[c])==null?void 0:h.filter(d=>d!==l))??[]}}})}),t[0]=r):r=t[0];const n=r;let i;t[1]===Symbol.for("react.memo_cache_sentinel")?(i=c=>(s(l=>({...l,fallbacks:[...l.fallbacks,c]})),()=>{s(l=>({...l,fallbacks:l.fallbacks.filter(u=>u!==c)}))}),t[1]=i):i=t[1];const o=i;let a;return t[2]!==e?(a={getState:()=>e,setDataUI:n,setFallbackDataUI:o},t[2]=e,t[3]=a):a=t[3],a},Da=q($a);function ja(){return{renderers:{},fallbacks:[]}}const Ba=t=>{const e=Array.from(t).map(r=>r.getModelContext()).sort((r,n)=>(n.priority??0)-(r.priority??0)),s={};return e.reduce((r,n)=>{var o;const i=n.priority??0;if(n.system&&(r.system?r.system+=`
|
|
1
|
+
var Lo=Object.defineProperty;var Vo=(t,e,s)=>e in t?Lo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var m=(t,e,s)=>Vo(t,typeof e!="symbol"?e+"":e,s);import{R as J,r as M,j as p,g as Uo,a as qo,b as Ho,M as zo}from"./index-c8AUUsSF.js";function Gt(){return Gt=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var r in s)({}).hasOwnProperty.call(s,r)&&(t[r]=s[r])}return t},Gt.apply(null,arguments)}let je=null;function Go(t,e){t.currentIndex=0,t.wipContextDeps=null,t.wipCommitCallbacks=[];const s=je;je=t;try{if(e(),t.isFirstRender=!1,t.cells.length!==t.currentIndex)throw new Error(`Rendered ${t.currentIndex} hooks but expected ${t.cells.length}. Hooks must be called in the exact same order in every render.`)}finally{je=s}}function Se(){if(!je)throw new Error("No resource fiber available");return je}function Ve(){return je}const ls=Symbol("tap.Context.defaultValue"),Ko=t=>t;let ge=new Map;const Ie=new Set,Jr=()=>new Map(ge),Ks=(t,e)=>{const s=ge;ge=t;try{return e()}finally{ge=s}},Xr=(t,e)=>{t[ls]=e},Zr=t=>typeof t=="object"&&t!==null&&ls in t,en=t=>typeof t=="object"&&t!==null&&"$$typeof"in t&&t.$$typeof===Symbol.for("react.context"),us=t=>Zr(t)||en(t),tn=t=>{if(!Zr(t)){if(en(t)){Xr(t,t._currentValue??t._currentValue2);return}throw new Error("A tap resource's `use()` only accepts a tap context.")}},sn=(t,e,s)=>{if(typeof t!="object"||t===null)throw new Error("useContextProvider only accepts a React context.");tn(t);const r=t,n=Se(),i=V(void 0),o=i.current===void 0||!Object.is(i.current.value,e);N(()=>{i.current={value:e}},[e]);const a=ge.get(r),c=a!==void 0||ge.has(r);ge.set(r,{value:e,source:n});try{return Wo(r,o,s)}finally{c?ge.set(r,a):ge.delete(r)}},Wo=(t,e,s)=>{const r=Ie.has(t);e?Ie.add(t):Ie.delete(t);try{return s()}finally{r?Ie.add(t):Ie.delete(t)}},Qo=t=>{tn(t);const e=t,s=Yo(e,t),r=Se();return(r.wipContextDeps??(r.wipContextDeps=new Map)).set(e,s.source),s.value},Yo=(t,e)=>ge.get(t)??{value:Ko(e)[ls],source:null},Jo=(t,e,s,r)=>{if(!r)return s;let n=s;for(const[i,o]of r)o===e||o===t||(n??(n=new Map)).set(i,o);return n},rn=(t,e=t.wipContextDeps)=>{const s=Ve();!s||!e||(s.wipContextDeps=Jo(s,t,s.wipContextDeps,e))},nn=()=>Ie.size>0,ds=t=>{if(!t.contextDeps||!nn())return!1;for(const e of Ie.keys())if(t.contextDeps.has(e))return!0;return!1},hs=(t,e)=>{if(t.length!==0){if(t.length===1)throw t[0];for(const s of t)console.error(s);throw new AggregateError(t,e)}},ye={HookState:0,EffectEvent:1,PassiveEffectCleanup:2,PassiveEffectSetup:3},Xo=[ye.HookState,ye.EffectEvent,ye.PassiveEffectCleanup,ye.PassiveEffectSetup];function Zo(t){const e=[];for(const s of Xo){const r=t[s];if(r!==void 0)for(let n=0;n<r.length;n++)try{r[n]()}catch(i){e.push(i)}}hs(e,"Errors during commit")}function ea(t){var s;const e=[];for(const r of t.cells)if((r==null?void 0:r.type)==="effect"&&(r.deps=null,r.cleanup))try{(s=r.cleanup)==null||s.call(r)}catch(n){e.push(n)}finally{r.cleanup=void 0}hs(e,"Errors during cleanup")}const on=t=>({version:0,committedVersion:0,context:Jr(),dispatchUpdate:t,changelog:[],rollbackCallbacks:[]}),gt=t=>{t.committedVersion=t.version,t.changelog.length=0,t.rollbackCallbacks.length=0},We=(t,e)=>{const s=t.version>e;if(t.version=e,s){for(let r=0;r<t.rollbackCallbacks.length;r++)t.rollbackCallbacks[r]();if(t.rollbackCallbacks.length=0,e<=t.committedVersion)t.committedVersion=e,t.changelog.length=0;else{for(;t.committedVersion+t.changelog.length>e;)t.changelog.pop();for(let r=0;r<t.changelog.length;r++)an(t.changelog[r]);gt(t)}}},an=t=>{var e;ln(t.fiber,t.cell),t.queued||(t.queued=!0,((e=t.cell).queue??(e.queue=[])).push(t))},Xe=(t,e,s)=>{const r=t.wipCommitCallbacks;(r[e]??(r[e]=[])).push(s)},cn=(t,e)=>{t.rollbackCallbacks.push(e)},ln=(t,e)=>{var s;e.isDirty||(e.isDirty=!0,(s=t.markDirty)==null||s.call(t),cn(t.root,()=>{if(e.queue!==null){for(const r of e.queue)r.queued=!1;e.queue=null}e.workInProgress=e.current,e.isDirty=!1}))},fs=()=>{throw new Error("Rendered more hooks than during the previous render. Hooks must be called in the exact same order in every render.")},ps=()=>{throw new Error("Hook order changed between renders")},ta=(t,e,s)=>{if(t.isNeverMounted)throw new Error("Resource updated before mount");let r=!1,n=!0;t.root.dispatchUpdate(()=>(r||(r=!0,s&&t.root.changelog.length===0&&!e.cell.isDirty&&!e.hasEagerState&&(e.eagerState=s(e.cell.workInProgress,e.action),e.hasEagerState=!0,n=!Object.is(e.cell.current,e.eagerState))),n),()=>(r=!0,n=!0,an(e),t.root.changelog.push(e),!0))},sa=(t,e,s,r,n)=>{const i=r?r(s):s,o={type:"reducer",workInProgress:i,current:i,isDirty:!1,queue:null,renderQueue:null,reducer:e,dispatch:a=>{const c=Ve();if(c!==null){if(c!==t)throw new Error("Cannot update a resource while rendering a different resource.");(t.renderPendingCells??(t.renderPendingCells=new Set)).add(o),(o.renderQueue??(o.renderQueue=[])).push(a)}else ta(t,{fiber:t,cell:o,action:a,hasEagerState:!1,eagerState:void 0,queued:!1},n?e:void 0)}};return o};function un(t,e,s,r){var l;const n=Se(),i=n.currentIndex++,o=n.cells[i],a=(()=>{if(o!==void 0)return o.type==="reducer"?o:ps();!n.isFirstRender&&i>=n.cells.length&&fs();const u=sa(n,t,e,s,r);return n.cells[i]=u,u})(),c=a.queue;if(c!==null){const u=t===a.reducer;for(let h=0;h<c.length;h++){const d=c[h];(!d.hasEagerState||!u)&&(d.eagerState=t(a.workInProgress,d.action),d.hasEagerState=!0),d.queued=!1,a.workInProgress=d.eagerState}a.queue=null}if(a.reducer=t,a.renderQueue!==null){let u=a.workInProgress;for(const h of a.renderQueue)u=t(u,h);a.renderQueue=null,(l=n.renderPendingCells)==null||l.delete(a),Object.is(u,a.workInProgress)||(ln(n,a),a.workInProgress=u)}return a.isDirty&&Xe(n,ye.HookState,()=>{a.current=a.workInProgress,a.isDirty=!1}),[a.workInProgress,a.dispatch]}function dn(t,e,s){return un(t,e,s,!1)}const ra=(t,e)=>typeof e=="function"?e(t):e,na=t=>t===void 0?void 0:typeof t=="function"?t():t;function gs(t){return un(ra,t,na,!0)}const Et=(t,e)=>{for(let s=0;s<t.length&&s<e.length;s++)if(!Object.is(t[s],e[s]))return!1;return!0},Ws=(t,e)=>{Xe(t,ye.HookState,()=>{e.current=e.wip,e.currentDeps=e.wipDeps,e.isDirty=!1})},Rt=(t,e)=>{const s=Se(),r=s.currentIndex++;let n=s.cells[r];if(n===void 0){!s.isFirstRender&&r>=s.cells.length&&fs();const a=t();return n={type:"memo",current:a,currentDeps:e,wip:a,wipDeps:e,isDirty:!1},s.cells[r]=n,a}n.type!=="memo"&&ps();const i=n;if(Et(i.wipDeps,e))return i.isDirty&&Ws(s,i),i.wip;const o=t();return i.wip=o,i.wipDeps=e,i.isDirty||(i.isDirty=!0,cn(s.root,()=>{i.wip=i.current,i.wipDeps=i.currentDeps,i.isDirty=!1})),Ws(s,i),o};function At(t){return Rt(()=>({current:t}),[])}const ms=(t,e)=>Rt(()=>t,e),ia=()=>({type:"effect",cleanup:void 0,deps:null});function Be(t,e){const s=Se(),r=s.currentIndex++,n=s.cells[r],i=n===void 0?ia():n.type==="effect"?n:ps();if(n===void 0&&(!s.isFirstRender&&r>=s.cells.length&&fs(),s.cells[r]=i),!(e&&i.deps&&Et(i.deps,e))){if(i.deps!==null&&!!e!=!!i.deps)throw new Error("useEffect called with and without dependencies across re-renders");Xe(s,ye.PassiveEffectCleanup,()=>{var o;try{(o=i.cleanup)==null||o.call(i)}finally{i.cleanup=void 0}}),Xe(s,ye.PassiveEffectSetup,()=>{try{const o=t();if(o!==void 0&&typeof o!="function")throw new Error(`An effect function must either return a cleanup function or nothing. Received: ${typeof o}`);i.cleanup=o}finally{i.deps=e}})}}function bs(t){const e=Se(),s=At(t);return s.current!==t&&Xe(e,ye.EffectEvent,()=>{s.current=t}),ms((...r)=>s.current(...r),[])}const mt=t=>{if(!us(t))throw new Error("A tap resource's `use()` only accepts a tap context.");return Qo(t)},hn=(t,e,s=e)=>{const r=At(!0),n=r.current?s():e();r.current=!1;const[,i]=gs(0),o=bs(()=>{try{if(Object.is(n,e()))return}catch{return}i(a=>a+1)});return Be(()=>(o(),t(o)),[t]),n},fn=(t,e)=>{},oa=J;function aa(t){const e=M.useRef(t);return M.useInsertionEffect(()=>{e.current=t}),M.useCallback((...s)=>e.current(...s),[])}const ca=oa.useEffectEvent??aa,ie=()=>Ve()!==null,oe=J,G=t=>ie()?gs(t):oe.useState(t),la=(t,e,s)=>ie()?dn(t,e,s):oe.useReducer(t,e,s),V=t=>ie()?At(t):oe.useRef(t),Y=(t,e)=>ie()?Rt(t,e):oe.useMemo(t,e),Qe=(t,e)=>ie()?ms(t,e):oe.useCallback(t,e),N=(t,e)=>ie()?Be(t,e):oe.useEffect(t,e),bt=(t,e)=>ie()?Be(t,e):oe.useLayoutEffect(t,e),le=t=>ie()?bs(t):ca(t),Ue=(t,e,s)=>ie()?hn(t,e,s):oe.useSyncExternalStore(t,e,s),ua=(t,e)=>ie()?fn():oe.useDebugValue(t,e),ae=t=>{const e=oe.createContext(t);return Xr(e,t),e},pn=t=>ie()&&us(t)?mt(t):oe.use(t),he=t=>ie()&&us(t)?mt(t):oe.useContext(t),gn=Symbol.for("react.memo_cache_sentinel"),mn=t=>new Array(t).fill(gn),da=(t,e)=>{const s=t.memoCache;let r=s.workInProgress;if(r===null){const o=s.current;r=o===null?[]:o.map(a=>a.slice()),s.workInProgress=r}const n=s.index++;let i=r[n];return i===void 0&&(i=mn(e),r[n]=i),i},bn=t=>da(Se(),t),ha=J,fa=t=>M.useMemo(()=>{const e=mn(t);return e[gn]=!0,e},[]);var Yr;const pa=((Yr=ha.__COMPILER_RUNTIME)==null?void 0:Yr.c)??fa,ga=()=>Ve()!==null,_=t=>ga()?bn(t):pa(t);function q(t){return(...e)=>({hook:t,args:e})}function ne(t,e,s){return typeof e=="function"?(...r)=>ne(t,e(...r)):s?{...e,key:t,deps:s}:{...e,key:t}}const ma=50;let me={schedulers:new Set([]),isScheduled:!1},_e=null;var ba=class{constructor(t){m(this,"_isDirty",!1);m(this,"_task");this._task=t}get isDirty(){return this._isDirty}markDirty(){if(_e&&(_e.get(this)??0)>=ma)throw new Error("Maximum update depth exceeded. This can happen when a resource repeatedly calls setState inside useEffect.");this._isDirty=!0,me.schedulers.add(this),_a()}runTask(){_e==null||_e.set(this,(_e.get(this)??0)+1),this._isDirty=!1,this._task()}};const _a=()=>{me.isScheduled||(me.isScheduled=!0,ya())},Kt=()=>{const t=_e;_e=new Map;try{const e=[];for(const s of me.schedulers)if(me.schedulers.delete(s),!!s.isDirty)try{s.runTask()}catch(r){e.push(r)}hs(e,"Errors occurred during flushSync")}finally{_e=t,me.schedulers.clear(),me.isScheduled=!1}},ya=(()=>{if(typeof MessageChannel<"u"){let t=null,e;return()=>{var s;if(!t){const r=new MessageChannel;r.port1.onmessage=()=>{var n;(n=t==null?void 0:t.unref)==null||n.call(t),Kt()},t=r.port1,e=r.port2}(s=t.ref)==null||s.call(t),e.postMessage(null)}}return()=>setTimeout(Kt,0)})(),Qs=t=>{const e=me;me={schedulers:new Set([]),isScheduled:!0};try{const s=t();return Kt(),s}finally{me=e}},va={useState:gs,useReducer:dn,useRef:At,useMemo:Rt,useCallback:ms,useEffect:Be,useLayoutEffect:Be,useInsertionEffect:Be,useEffectEvent:bs,useContext:mt,use:mt,useSyncExternalStore:hn,useDebugValue:fn,useMemoCache:bn},Ys=J,Te=Ys.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE??Ys.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,nt=Te==null?null:"H"in Te?{get current(){return Te.H},set current(t){Te.H=t}}:"ReactCurrentDispatcher"in Te?{get current(){return Te.ReactCurrentDispatcher.current},set current(t){Te.ReactCurrentDispatcher.current=t}}:null;function Sa(t){if(!nt)return t();const e=nt.current;nt.current=va;try{return t()}finally{nt.current=e}}function _n(t,e,s=void 0,r){return{hook:t,root:e,markDirty:s,devStrictMode:r,cells:[],contextDeps:null,wipContextDeps:null,commitCallbacks:null,wipCommitCallbacks:null,memoCache:{current:null,workInProgress:null,index:0},renderPendingCells:null,currentIndex:0,isFirstRender:!0,isMounted:!1,isNeverMounted:!0}}function Oe(t){if(!t.isMounted)throw new Error("Tried to unmount a fiber that is already unmounted");t.isMounted=!1,ea(t)}function Ee(t,e){var n;if(t.memoCache.workInProgress=null,t.renderPendingCells!==null){for(const i of t.renderPendingCells)i.renderQueue=null;t.renderPendingCells.clear()}let s=0,r;do{if(++s>25)throw new Error("Too many re-renders. tap limits the number of renders to prevent an infinite loop.");t.memoCache.index=0,Go(t,()=>{r=Sa(()=>t.hook(...e))})}while((((n=t.renderPendingCells)==null?void 0:n.size)??0)>0);return rn(t),r}function Ze(t){const e=t.wipCommitCallbacks??t.commitCallbacks??[];t.wipCommitCallbacks=null,t.commitCallbacks=e,t.isMounted=!0,t.contextDeps=t.wipContextDeps,gt(t.root),t.memoCache.workInProgress!==null&&(t.memoCache.current=t.memoCache.workInProgress,t.memoCache.workInProgress=null),t.isNeverMounted=!1,Zo(e)}const xa=()=>{const t=Se();return t.devStrictMode?t.isFirstRender?"child":"root":null},wa=()=>null,Ta=()=>wa,yn=()=>Ve()?xa:Ta(),Ca=t=>t(),Ia=t=>{const[e]=G(()=>new ba(()=>f())),[s]=G(()=>[]),r=yn(),[n]=G(()=>{const g=on((b,v)=>{if(!e.isDirty){if(!b())return;v()}We(g,g.committedVersion+g.changelog.length),s.push(v),e.markDirty()});return _n(Ca,g,void 0,r())}),i=Jr(),o=n.root.version-n.root.committedVersion,a=Ks(i,()=>Ee(n,[t])),c=V(!1),l=V([t]),u=V(a),[h]=G(()=>new Set),d=g=>{e.isDirty||u.current===g||(u.current=g,h.forEach(b=>b()))},f=le(()=>{We(n.root,n.root.committedVersion),s.forEach(b=>{b()}),We(n.root,n.root.committedVersion+n.root.changelog.length);const g=Ks(n.root.context,()=>Ee(n,l.current));if(e.isDirty)throw new Error("Scheduler is dirty, this should never happen");gt(n.root),s.length=0,c.current&&Ze(n),d(g)});return N(()=>(c.current=!0,()=>{c.current=!1,Oe(n)}),[n]),N(()=>{l.current=[t],gt(n.root),s.splice(0,o),n.root.context=i,Ze(n),d(a)}),Y(()=>({getValue:()=>u.current,subscribe:g=>(h.add(g),()=>h.delete(g))}),[h])},Ea=()=>{const t=V(0),e=t.current,s=Se();return{version:e,markDirty:Y(()=>()=>{var r;t.current++,(r=s==null?void 0:s.markDirty)==null||r.call(s)},[s]),root:s.root}},Ra=()=>{const[t]=G(()=>on((n,i)=>{let o=!1;r(a=>(o=!n(),o?a:a+1)),o||s(i)})),[e,s]=la((n,i)=>(We(t,n),n+(i()?1:0)),0),[,r]=G(0);return We(t,e),{root:t,version:e,markDirty:void 0}},_s=()=>{const t=yn(),{root:e,version:s,markDirty:r}=Ve()?Ea():Ra();return{version:s,createFiber:Qe((n,i,o)=>_n(n,e,o?()=>{o(),r==null||r()}:r,t()),[])}},vn=(t,e,s)=>{const r=V(null),n=r.current??(r.current={wipDeps:null,wip:null,currentDeps:null,current:null});return n.wipDeps=n.currentDeps,n.wip=n.current,N(()=>{n.currentDeps=n.wipDeps,n.current=n.wip}),!s&&n.currentDeps&&Et(n.currentDeps,e)?n.current:(n.wipDeps=e,n.wip=t(),n.wip)};function se(t){const{version:e,createFiber:s}=_s(),r=Y(()=>s(t.hook,t.key),[t.hook,t.key,s]),n=vn(()=>({value:Ee(r,t.args)}),[r,e,t.args],ds(r));return N(()=>()=>Oe(r),[r]),N(()=>{Ze(r)},[r,n]),n.value}const Js=(t,e)=>{const s=t.get(e);s&&(s.isDirty=!0)},Aa=(t,e)=>!t.isDirty&&!ds(t.fiber)&&e!==void 0&&t.committedDeps!==void 0&&Et(t.committedDeps,e),Ma=t=>{if(!nn())return!1;for(const{fiber:e}of t.values())if(ds(e))return!0;return!1};function Mt(t){const[e]=G(()=>new Map),{version:s,createFiber:r}=_s(),n=Ma(e),i=vn(()=>{const o=new Set,a=[];let c=0;for(let l=0;l<t.length;l++){const u=t[l],h=u.key;if(h===void 0)throw new Error(`useResources did not provide a key for array at index ${l}`);if(o.has(h))throw new Error(`Duplicate key ${h} in useResources`);o.add(h);let d=e.get(h);if(d)if(d.fiber.hook!==u.hook){const f=r(u.hook,u.key,()=>Js(e,h)),g=Ee(f,u.args);d.next={value:g,deps:u.deps,remount:f}}else if(Aa(d,u.deps))d.fiber.contextDeps&&rn(d.fiber,d.fiber.contextDeps),d.next="skip";else{const f=Ee(d.fiber,u.args);d.next={value:f,deps:u.deps}}else{const f=r(u.hook,u.key,()=>Js(e,h));d={fiber:f,next:{value:Ee(f,u.args),deps:u.deps},isDirty:!1,committedDeps:void 0,committedValue:void 0},c++,e.set(h,d)}a.push(typeof d.next=="object"?d.next.value:d.committedValue)}if(e.size>a.length-c)for(const l of e.keys())o.has(l)||(e.get(l).next="delete");return a},[t,e,r,s],n);return N(()=>()=>{for(const o of e.keys()){const a=e.get(o).fiber;Oe(a)}},[e]),N(()=>{for(const[o,a]of e.entries()){const c=a.next;c==="delete"?(a.fiber.isMounted&&Oe(a.fiber),e.delete(o)):c==="skip"||(c.remount&&(Oe(a.fiber),a.fiber=c.remount),Ze(a.fiber),a.committedDeps=c.deps,a.committedValue=c.value,a.isDirty=!1)}},[i,e]),i}const Pa=t=>t(),ka=t=>{const{createFiber:e}=_s(),s=Y(()=>e(Pa,void 0),[e]),r=Ee(s,[t]);N(()=>()=>{Oe(s)},[s]);let n=!1;const i=()=>{n&&s.isMounted||(n=!0,Ze(s))};return N(i),{value:r,effects:i}},$a=()=>{const t=_(4),[e,s]=G(ja);let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=(c,l)=>(s(u=>({...u,renderers:{...u.renderers,[c]:[...u.renderers[c]??[],l]}})),()=>{s(u=>{var h;return{...u,renderers:{...u.renderers,[c]:((h=u.renderers[c])==null?void 0:h.filter(d=>d!==l))??[]}}})}),t[0]=r):r=t[0];const n=r;let i;t[1]===Symbol.for("react.memo_cache_sentinel")?(i=c=>(s(l=>({...l,fallbacks:[...l.fallbacks,c]})),()=>{s(l=>({...l,fallbacks:l.fallbacks.filter(u=>u!==c)}))}),t[1]=i):i=t[1];const o=i;let a;return t[2]!==e?(a={getState:()=>e,setDataUI:n,setFallbackDataUI:o},t[2]=e,t[3]=a):a=t[3],a},Da=q($a);function ja(){return{renderers:{},fallbacks:[]}}const Ba=t=>{const e=Array.from(t).map(r=>r.getModelContext()).sort((r,n)=>(n.priority??0)-(r.priority??0)),s={};return e.reduce((r,n)=>{var o;const i=n.priority??0;if(n.system&&(r.system?r.system+=`
|
|
2
2
|
|
|
3
3
|
${n.system}`:r.system=n.system),n.tools)for(const[a,c]of Object.entries(n.tools)){const l=(o=r.tools)==null?void 0:o[a];if(l&&l!==c){const u=s[a];if(u===i)throw new Error(`You tried to define a tool with the name ${a}, but it already exists.`);const h=u>i?l:c,d=u>i?c:l;r.tools[a]={...d,...h},s[a]=Math.max(u,i);continue}r.tools||(r.tools={}),r.tools[a]=c,s[a]??(s[a]=i)}return n.config&&(r.config={...r.config,...n.config}),n.callSettings&&(r.callSettings={...r.callSettings,...n.callSettings}),n.unstable_composerMetadata&&(r.unstable_composerMetadata={...r.unstable_composerMetadata,...n.unstable_composerMetadata}),r},{})};var Sn=class{constructor(){m(this,"_providers",new Set);m(this,"_subscribers",new Set)}getModelContext(){return Ba(this._providers)}registerModelContextProvider(t){var s;this._providers.add(t);const e=(s=t.subscribe)==null?void 0:s.call(t,()=>{this.notifySubscribers()});return this.notifySubscribers(),()=>{this._providers.delete(t),e==null||e(),this.notifySubscribers()}}notifySubscribers(){for(const t of this._subscribers)t()}subscribe(t){return this._subscribers.add(t),()=>{this._subscribers.delete(t)}}};const Wt=[],Oa={modelName:void 0,toolNames:Wt},Na=(t,e)=>t===e||t.length===e.length&&t.every((s,r)=>s===e[r]),it=(t,e)=>{var o;const s=t.getModelContext(),r=(o=s.config)==null?void 0:o.modelName,n=s.tools?Object.keys(s.tools).sort():Wt,i=n.length?n:Wt;return r===e.modelName&&Na(i,e.toolNames)?e:{modelName:r,toolNames:i}},Fa=()=>{const t=_(11);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=new Sn,t[0]=e):e=t[0];const s=e;let r;t[1]===Symbol.for("react.memo_cache_sentinel")?(r=()=>it(s,Oa),t[1]=r):r=t[1];const[n,i]=G(r);let o,a;t[2]===Symbol.for("react.memo_cache_sentinel")?(o=()=>(i(f=>it(s,f)),s.subscribe(()=>{i(f=>it(s,f))})),a=[s],t[2]=o,t[3]=a):(o=t[2],a=t[3]),N(o,a);let c;t[4]!==n?(c=()=>it(s,n),t[4]=n,t[5]=c):c=t[5];let l,u,h;t[6]===Symbol.for("react.memo_cache_sentinel")?(l=()=>s.getModelContext(),u=f=>s.subscribe(f),h=f=>s.registerModelContextProvider(f),t[6]=l,t[7]=u,t[8]=h):(l=t[6],u=t[7],h=t[8]);let d;return t[9]!==c?(d={getState:c,getModelContext:l,subscribe:u,register:h},t[9]=c,t[10]=d):d=t[10],d},xn=q(Fa),La=t=>t.display!==void 0?t.display==="standalone":t.type==="human",Va=(t,e)=>{var r,n;if(!(((r=e.status)==null?void 0:r.type)==="running"||((n=e.status)==null?void 0:n.type)==="requires-action")){const i=t.complete;return typeof i!="function"?i??null:i({args:e.args,result:e.result})}const s=t.running;return typeof s!="function"?s??null:s({args:e.args})},Ua=t=>function(s){return Va(t,s)},Qt=Symbol("assistant-ui.store.clientIndex"),qa=t=>t[Qt],wn=ae([]),ys=()=>pn(wn),Ha=(t,e)=>{const s=_(3),r=ys();let n;return s[0]!==t||s[1]!==r?(n=[...r,t],s[0]=t,s[1]=r,s[2]=n):n=s[2],sn(wn,n,e)},za=new Set(["$$typeof","nodeType","then"]),Pt=(t,e)=>{if(t===Symbol.toStringTag)return e;if(typeof t!="symbol"){if(t==="toJSON")return()=>e;if(!za.has(t))return!1}};var vs=class{getOwnPropertyDescriptor(t,e){const s=this.get(t,e);if(s!==void 0)return{value:s,writable:!1,enumerable:!0,configurable:!1}}set(){return!1}setPrototypeOf(){return!1}defineProperty(){return!1}deleteProperty(){return!1}preventExtensions(){return!1}};const _t=Symbol("assistant-ui.store.getValue"),Ga=t=>{var s;const e=t[_t];if(!e)throw new Error("Client scope contains a non-client resource. Ensure your Derived get() returns a client created with useClientResource(), not a plain resource.");return(s=e.getState)==null?void 0:s.call(e)},Xs=new Map;function Ka(t){let e=Xs.get(t);return e||(e=function(...s){if(!this||typeof this!="object")throw new Error(`Method "${String(t)}" called without proper context. This may indicate the function was called incorrectly.`);const r=this[_t];if(!r)throw new Error(`Method "${String(t)}" called on invalid client proxy. Ensure you are calling this method on a valid client instance.`);const n=r[t];if(!n)throw new Error(`Method "${String(t)}" is not implemented.`);if(typeof n!="function")throw new Error(`"${String(t)}" is not a function.`);return n(...s)},Xs.set(t,e)),e}var Wa=class extends vs{constructor(e,s){super();m(this,"boundFns");m(this,"cachedReceiver");m(this,"outputRef");m(this,"index");this.outputRef=e,this.index=s}get(e,s,r){if(s===_t)return this.outputRef.current;if(s===Qt)return this.index;const n=Pt(s,"ClientProxy");if(n!==!1)return n;const i=this.outputRef.current[s];if(typeof i=="function"){this.cachedReceiver!==r&&(this.boundFns=new Map,this.cachedReceiver=r);let o=this.boundFns.get(s);return o||(o=Ka(s).bind(r),this.boundFns.set(s,o)),o}return i}ownKeys(){return Object.keys(this.outputRef.current)}has(e,s){return s===_t||s===Qt?!0:s in this.outputRef.current}};const tt=t=>{var i;const e=V(null),s=ys().length,r=Y(()=>new Proxy({},new Wa(e,s)),[s]),n=Ha(r,function(){return se(t)});return e.current||(e.current=n),N(()=>{e.current=n}),{methods:r,state:(i=n.getState)==null?void 0:i.call(n),key:t.key}},Qa=q(tt),Ye=Symbol("assistant-ui.store.proxiedAssistantState"),Bt=t=>t==="on"||t==="subscribe"||typeof t=="symbol",Tn=t=>{class e extends vs{get(r,n){const i=Pt(n,"AssistantState");if(i!==!1)return i;const o=n;if(!Bt(o))return Ga(t[o]())}ownKeys(){return Object.keys(t).filter(r=>!Bt(r))}has(r,n){return!Bt(n)&&n in t}}return new Proxy({},new e)},Ya=t=>t[Ye],Zs=()=>()=>{},Cn=t=>{const e=()=>{throw new Error(t)};return e.source=null,e.query=null,e};var Ja=class extends vs{get(t,e){if(e==="subscribe"||e==="on")return Zs;if(e===Ye)return Xa;const s=Pt(e,"DefaultAssistantClient");return s!==!1?s:Cn("You are using a component or hook that requires an AuiProvider. Wrap your component in an <AuiProvider> component.")}ownKeys(){return["subscribe","on",Ye]}has(t,e){return e==="subscribe"||e==="on"||e===Ye}};const kt=new Proxy({},new Ja),Xa=Tn(kt),Za=()=>new Proxy({},{get(t,e){const s=Pt(e,"AssistantClient");return s!==!1?s:Cn(`The current scope does not have a "${String(e)}" property.`)}}),In=ae(kt),En=Symbol("assistant-ui.store.useEffects"),ec=()=>{},tc=t=>t[En]??ec,sc=()=>{"use no memo";const t=Rn();return N(tc(t)),null},Rn=()=>he(In),ue=({value:t,children:e})=>{"use no memo";return p.jsxs(In.Provider,{value:t,children:[p.jsx(sc,{}),e]})},Yt=t=>{throw new Error("Derived elements are config-only and must not be mounted")},re=q(Yt),Jt=Symbol("assistant-ui.transform-scopes");function An(t,e){const s=t;if(s[Jt])throw new Error("transformScopes is already attached to this resource");s[Jt]=e}function rc(t){return t[Jt]}const Mn=t=>typeof t=="string"?{scope:t.split(".")[0],event:t}:{scope:t.scope,event:t.event},Pn=ae(null),nc=(t,e)=>sn(Pn,t,e),kn=()=>{const t=pn(Pn);if(!t)throw new Error("AssistantTapContext is not available");return t},$n=()=>kn().clientRef,Ss=()=>{const t=_(3),{emit:e}=kn(),s=ys();let r;return t[0]!==s||t[1]!==e?(r=(n,i)=>{e(n,i,s)},t[0]=s,t[1]=e,t[2]=r):r=t[2],le(r)};function ic(t,e){const s={...t},r=new Set;let n=!0;for(;n;){n=!1;for(const a of Object.values(s)){if(a.hook===Yt||r.has(a.hook))continue;r.add(a.hook);const c=rc(a.hook);if(c){c(s,e),n=!0;break}}}const i={},o={};for(const[a,c]of Object.entries(s))c.hook===Yt?o[a]=c:i[a]=c;return{rootClients:i,derivedClients:o}}const er=t=>Y(()=>t,[...Object.entries(t).flat()]),oc=(t,e)=>{const s=_(6);let r;s[0]!==e||s[1]!==t?(r=ic(t,e),s[0]=e,s[1]=t,s[2]=r):r=s[2];const{rootClients:n,derivedClients:i}=r,o=er(n),a=er(i);let c;return s[3]!==o||s[4]!==a?(c={rootClients:o,derivedClients:a},s[3]=o,s[4]=a,s[5]=c):c=s[5],c},ac=()=>{const t=_(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=new Map,t[0]=e):e=t[0];const s=e;let r;t[1]===Symbol.for("react.memo_cache_sentinel")?(r=new Set,t[1]=r):r=t[1];const n=r;let i;if(t[2]===Symbol.for("react.memo_cache_sentinel")){const o=new Set;i={on(a,c){const l=c;if(a==="*")return n.add(l),()=>n.delete(l);let u=s.get(a);return u||(u=new Set,s.set(a,u)),u.add(l),()=>{u.delete(l),u.size===0&&s.delete(a)}},emit(a,c,l){const u=s.get(a);!u&&n.size===0||queueMicrotask(()=>{const h=[];if(u)for(const d of u)try{d(c,l)}catch(f){const g=f;h.push(g)}if(n.size>0){const d={event:a,payload:c};for(const f of n)try{f(d,l)}catch(g){const b=g;h.push(b)}}if(h.length>0){if(h.length===1)throw h[0];for(const d of h)console.error(d);throw new AggregateError(h,"Errors occurred during event emission")}})},subscribe(a){return o.add(a),()=>o.delete(a)},notifySubscribers(){for(const a of o)try{a()}catch(c){console.error("NotificationManager: subscriber callback error",c)}}},t[2]=i}else i=t[2];return i},cc=q(ac),Dn=t=>Y(()=>t,t),lc=({element:t,emit:e,clientRef:s})=>{const{methods:r,state:n}=nc({clientRef:s,emit:e},function(){return tt(t)});return Y(()=>({state:n,methods:r}),[r,n])},uc=({element:t,notifications:e,clientRef:s,name:r})=>{const n=Ia(function(){return lc({element:t,emit:e.emit,clientRef:s})});return N(()=>n.subscribe(e.notifySubscribers),[n,e]),Y(()=>{const i=()=>n.getValue().methods;return Object.defineProperties(i,{source:{value:"root",writable:!1},query:{value:{},writable:!1},name:{value:r,configurable:!0}}),i},[n,r])},dc=q(uc),hc=()=>{const t=_(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s={clients:e,subscribe:void 0,on:void 0},t[1]=s):s=t[1],s},fc=q(hc),pc=t=>{const e=_(14),{clients:s,clientRef:r}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=cc(),e[0]=n):n=e[0];const i=se(n);let o;e[1]!==r.parent||e[2]!==i.notifySubscribers?(o=()=>r.parent.subscribe(i.notifySubscribers),e[1]=r.parent,e[2]=i.notifySubscribers,e[3]=o):o=e[3];let a;e[4]!==r||e[5]!==i?(a=[r,i],e[4]=r,e[5]=i,e[6]=a):a=e[6],N(o,a);let c;e[7]!==r||e[8]!==s||e[9]!==i?(c=Object.keys(s).map(h=>ne(h,dc({element:s[h],notifications:i,clientRef:r,name:h}))),e[7]=r,e[8]=s,e[9]=i,e[10]=c):c=e[10];const l=Dn(Mt(c));let u;return e[11]!==i||e[12]!==l?(u={notifications:i,results:l},e[11]=i,e[12]=l,e[13]=u):u=e[13],u},gc=t=>{const{clientRef:e}=t,{notifications:s,results:r}=pc(t);return Y(()=>({clients:r,subscribe:s.subscribe,on:function(n,i){if(!this)throw new Error("const { on } = useAui() is not supported. Use aui.on() instead.");const{scope:o,event:a}=Mn(n);if(o!=="*"&&this[o].source===null)throw new Error(`Scope "${o}" is not available. Use { scope: "*", event: "${a}" } to listen globally.`);const c=s.on(a,(u,h)=>{if(o==="*"){i(u);return}const d=this[o]();d===h[qa(d)]&&i(u)});if(o!=="*"&&e.parent[o].source===null)return c;const l=e.parent.on(n,i);return()=>{c(),l()}}}),[r,s,e])},mc=q(gc),bc=({element:t,clientRef:e,name:s})=>{const r=V(t.args[0]);return r.current=t.args[0],Y(()=>{const n=()=>r.current.get(e.current);return Object.defineProperties(n,{source:{value:r.current.source},query:{value:r.current.query},name:{value:s,configurable:!0}}),n},[e,s])},_c=q(bc),yc=(t,e)=>{let s;try{const r={};for(const n of Object.keys(e.query).sort())r[n]=e.query[n];s=JSON.stringify(r)}catch{s=String(e.query)}return`${t}::${e.source}::${s}`},vc=t=>{const e=_(3),{clients:s,clientRef:r}=t;let n;return e[0]!==r||e[1]!==s?(n=Object.keys(s).map(i=>{const o=i,a=s[o];return ne(yc(o,a.args[0]),_c({element:a,clientRef:r,name:o}))}),e[0]=r,e[1]=s,e[2]=n):n=e[2],Dn(Mt(n))},Sc=t=>{const e=_(3),{rootClients:s,clientRef:r}=t;let n;return e[0]!==r||e[1]!==s?(n=Object.keys(s).length>0?mc({clients:s,clientRef:r}):fc(),e[0]=r,e[1]=s,e[2]=n):n=e[2],se(n)},xc=({parent:t,clients:e})=>{const{rootClients:s,derivedClients:r}=oc(e,t),n=V({parent:t,current:null}).current;N(()=>{n.current=a});const i=Sc({rootClients:s,clientRef:n}),o=vc({clients:r,clientRef:n}),a=Y(()=>{const c=t===kt?Za():t,l=Object.create(c);Object.assign(l,{subscribe:i.subscribe??t.subscribe,on:i.on??t.on,[Ye]:Tn(l)});for(const u of i.clients)l[u.name]=u;for(const u of o)l[u.name]=u;return l},[t,i,o]);return n.current===null&&(n.current=a),a},wc=t=>{const{value:e,effects:s}=ka(function(){return xc(t)});return e[En]=s,e};function F(t,{parent:e}={parent:Rn()}){if(t)return wc({parent:e??kt,clients:t});if(e===null)throw new Error("received null parent, this usage is not allowed");return e}const P=t=>{const e=_(6),s=F();let r;e[0]!==s?(r=Ya(s),e[0]=s,e[1]=r):r=e[1];const n=r;let i,o;e[2]!==n||e[3]!==t?(i=()=>t(n),o=()=>t(n),e[2]=n,e[3]=t,e[4]=i,e[5]=o):(i=e[4],o=e[5]);const a=Ue(s.subscribe,i,o);if(a===n)throw new Error("You tried to return the entire AssistantState. This is not supported due to technical limitations.");return ua(a),a},Tc=t=>{const e=F(),s=V(!1),r=s.current?null:t(e);return P(()=>s.current?t(e):r),()=>(s.current=!0,t(e))},Cc=Object.freeze({});function qe(t){const e=_(3),{getItemState:s,children:r}=t,n=Tc(s);let i;return e[0]!==r||e[1]!==n?(i=r(n),e[0]=r,e[1]=n,e[2]=i):i=e[2],Ic(i)}const Ic=t=>{const e=typeof t=="object"&&t!=null&&"type"in t?t:null,s=e==null?void 0:e.type,r=e==null?void 0:e.key;return Y(()=>e,[s,r,typeof(e==null?void 0:e.props)=="object"&&e.props!=null&&Object.entries(e.props).length===0?Cc:e==null?void 0:e.props])??t},Ec=J.createContext(!0);function tr(){throw new Error("A function wrapped in useEffectEvent can't be called during rendering.")}const Rc="use"in J?()=>{try{return J.use(Ec)}catch{return!1}}:()=>!1;function Ac(t){const e=J.useRef(tr);return J.useInsertionEffect(()=>{e.current=t},[t]),(...s)=>{Rc()&&tr();const r=e.current;return r(...s)}}const yt=(t,e)=>{const s=_(11),r=F(),n=Ac(e);let i;s[0]!==t?(i=Mn(t),s[0]=t,s[1]=i):i=s[1];const{scope:o,event:a}=i;let c;s[2]!==r||s[3]!==n||s[4]!==a||s[5]!==o?(c=()=>r.on({scope:o,event:a},n),s[2]=r,s[3]=n,s[4]=a,s[5]=o,s[6]=c):c=s[6];let l;s[7]!==r||s[8]!==a||s[9]!==o?(l=[r,o,a],s[7]=r,s[8]=a,s[9]=o,s[10]=l):l=s[10],N(c,l)},Mc=t=>{if(t.key===void 0)throw new Error("useClientLookup: Element has no key");return t.key};function Re(t){const e=_(15);let s;e[0]!==t?(s=t.map($c),e[0]=t,e[1]=s):s=e[1];const r=Mt(s);let n;e[2]!==r?(n=Object.keys(r),e[2]=r,e[3]=n):n=e[3];const i=n;let o;e[4]!==r?(o=r.reduce(kc,{}),e[4]=r,e[5]=o):o=e[5];const a=o;let c;e[6]!==r?(c=r.map(Pc),e[6]=r,e[7]=c):c=e[7];const l=c;let u;e[8]!==a||e[9]!==i||e[10]!==r?(u=d=>{if("index"in d){if(d.index<0||i.length===0)throw new Error(`useClientLookup: Index ${d.index} out of bounds (length: ${i.length})`);const g=Math.min(d.index,i.length-1);return g!==d.index&&console.warn(`useClientLookup: Clamped stale index ${d.index} to ${g} (length: ${i.length})`),r[g].methods}const f=a[d.key];if(f===void 0)throw new Error(`useClientLookup: Key "${d.key}" not found`);return r[f].methods},e[8]=a,e[9]=i,e[10]=r,e[11]=u):u=e[11];let h;return e[12]!==l||e[13]!==u?(h={state:l,get:u},e[12]=l,e[13]=u,e[14]=h):h=e[14],h}function Pc(t){return t.state}function kc(t,e,s){return t[e.key]=s,t}function $c(t){return ne(Mc(t),Qa(t),t.deps)}const jn=t=>{const e=_(15),{toolkit:s,mcpApp:r}=t;let n;e[0]!==r?(n=r?[ne("mcpApp",r)]:[],e[0]=r,e[1]=n):n=e[1];const i=Mt(n)[0],[o,a]=G(jc);let c;e[2]!==o?(c=Object.fromEntries(Object.entries(o).map(Oc)),e[2]=o,e[3]=c):c=e[3];let l;e[4]!==i||e[5]!==c||e[6]!==o?(l={toolUIs:o,mcpApp:i,tools:c},e[4]=i,e[5]=c,e[6]=o,e[7]=l):l=e[7];const u=l,h=$n();let d;e[8]===Symbol.for("react.memo_cache_sentinel")?(d=(x,S,T)=>{const y={render:S,standalone:(T==null?void 0:T.standalone)??!1};return a(w=>({...w,[x]:[...w[x]??[],y]})),()=>{a(w=>{var $;const C=(($=w[x])==null?void 0:$.filter(D=>D!==y))??[];if(C.length>0)return{...w,[x]:C};const I={...w};return delete I[x],I})}},e[8]=d):d=e[8];const f=d;let g,b;e[9]!==h||e[10]!==s?(g=()=>{if(!s)return;const x=[];for(const[T,y]of Object.entries(s)){const w="render"in y?y.render:void 0,C="renderText"in y?y.renderText:void 0,I=w??(C?Ua(C):void 0);I&&x.push(f(T,I,{standalone:La(y)}))}const S=Object.entries(s).reduce(Nc,{});return x.push(h.current.modelContext().register({getModelContext:()=>({tools:S})})),()=>{x.forEach(Fc)}},b=[s,f,h],e[9]=h,e[10]=s,e[11]=g,e[12]=b):(g=e[11],b=e[12]),N(g,b);let v;return e[13]!==u?(v={getState:()=>u,setToolUI:f},e[13]=u,e[14]=v):v=e[14],v},Dc=q(jn);An(jn,(t,e)=>{!t.modelContext&&e.modelContext.source===null&&(t.modelContext=xn())});function jc(){return{}}function Bc(t){return t.render}function Oc(t){const[e,s]=t;return[e,s.map(Bc)]}function Nc(t,e){const[s,r]=e;if(r.type==="mcp")return t;const{display:n,render:i,renderText:o,...a}=r;return t[s]=a,t}function Fc(t){return t()}const Pe=t=>Ue(t.subscribe,t.getState),Lc=t=>{const e=_(8),{runtime:s}=t,r=Pe(s);let n;e[0]!==r?(n=()=>r,e[0]=r,e[1]=n):n=e[1];let i;e[2]!==s?(i=()=>s,e[2]=s,e[3]=i):i=e[3];let o;return e[4]!==s.remove||e[5]!==n||e[6]!==i?(o={getState:n,remove:s.remove,__internal_getRuntime:i},e[4]=s.remove,e[5]=n,e[6]=i,e[7]=o):o=e[7],o},Bn=q(Lc),Vc=t=>{const e=_(5),{runtime:s,index:r}=t;let n;e[0]!==r||e[1]!==s?(n=s.getAttachmentByIndex(r),e[0]=r,e[1]=s,e[2]=n):n=e[2];const i=n;let o;return e[3]!==i?(o=Bn({runtime:i}),e[3]=i,e[4]=o):o=e[4],se(o)},Uc=q(Vc),qc=({item:t,onSteer:e,onRemove:s})=>({getState:()=>t,steer:e,remove:s}),Hc=q(qc),zc=t=>{const e=_(55),{threadIdRef:s,messageIdRef:r,runtime:n}=t,i=Pe(n),o=Ss();let a,c;e[0]!==o||e[1]!==r||e[2]!==n||e[3]!==s?(a=()=>{const I=[];for(const $ of["send","attachmentAdd"]){const D=n.unstable_on($,()=>{o(`composer.${$}`,{threadId:s.current,...r&&{messageId:r.current}})});I.push(D)}return I.push(n.unstable_on("attachmentAddError",$=>{o("composer.attachmentAddError",{threadId:s.current,...r&&{messageId:r.current},...$.attachmentId&&{attachmentId:$.attachmentId},reason:$.reason,message:$.message})})),()=>{for(const $ of I)$()}},c=[n,o,s,r],e[0]=o,e[1]=r,e[2]=n,e[3]=s,e[4]=a,e[5]=c):(a=e[4],c=e[5]),N(a,c);let l;if(e[6]!==n||e[7]!==i.attachments){let I;e[9]!==n?(I=($,D)=>ne($.id,Uc({runtime:n,index:D}),[n,D]),e[9]=n,e[10]=I):I=e[10],l=i.attachments.map(I),e[6]=n,e[7]=i.attachments,e[8]=l}else l=e[8];const u=Re(l),h=i.queue;let d;if(e[11]!==h||e[12]!==n){let I;e[14]!==n?(I=$=>ne($.id,Hc({item:$,onSteer:()=>n.steerQueueItem($.id),onRemove:()=>n.removeQueueItem($.id)})),e[14]=n,e[15]=I):I=e[15],d=h.map(I),e[11]=h,e[12]=n,e[13]=d}else d=e[13];const f=Re(d),g=i.type??"thread";let b;e[16]!==u.state||e[17]!==h||e[18]!==i.attachmentAccept||e[19]!==i.canCancel||e[20]!==i.canSend||e[21]!==i.dictation||e[22]!==i.isEditing||e[23]!==i.isEmpty||e[24]!==i.quote||e[25]!==i.role||e[26]!==i.runConfig||e[27]!==i.text||e[28]!==g?(b={text:i.text,role:i.role,attachments:u.state,runConfig:i.runConfig,isEditing:i.isEditing,canCancel:i.canCancel,canSend:i.canSend,attachmentAccept:i.attachmentAccept,isEmpty:i.isEmpty,type:g,dictation:i.dictation,quote:i.quote,queue:h},e[16]=u.state,e[17]=h,e[18]=i.attachmentAccept,e[19]=i.canCancel,e[20]=i.canSend,e[21]=i.dictation,e[22]=i.isEditing,e[23]=i.isEmpty,e[24]=i.quote,e[25]=i.role,e[26]=i.runConfig,e[27]=i.text,e[28]=g,e[29]=b):b=e[29];const v=b;let x;e[30]!==v?(x=()=>v,e[30]=v,e[31]=x):x=e[31];const S=n.beginEdit??Gc;let T;e[32]!==u?(T=I=>"id"in I?u.get({key:I.id}):u.get(I),e[32]=u,e[33]=T):T=e[33];let y;e[34]!==f?(y=I=>f.get(I),e[34]=f,e[35]=y):y=e[35];let w;e[36]!==n?(w=()=>n,e[36]=n,e[37]=w):w=e[37];let C;return e[38]!==n.addAttachment||e[39]!==n.cancel||e[40]!==n.clearAttachments||e[41]!==n.reset||e[42]!==n.send||e[43]!==n.setQuote||e[44]!==n.setRole||e[45]!==n.setRunConfig||e[46]!==n.setText||e[47]!==n.startDictation||e[48]!==n.stopDictation||e[49]!==y||e[50]!==w||e[51]!==x||e[52]!==S||e[53]!==T?(C={getState:x,setText:n.setText,setRole:n.setRole,setRunConfig:n.setRunConfig,addAttachment:n.addAttachment,reset:n.reset,clearAttachments:n.clearAttachments,send:n.send,cancel:n.cancel,beginEdit:S,startDictation:n.startDictation,stopDictation:n.stopDictation,setQuote:n.setQuote,attachment:T,queueItem:y,__internal_getRuntime:w},e[38]=n.addAttachment,e[39]=n.cancel,e[40]=n.clearAttachments,e[41]=n.reset,e[42]=n.send,e[43]=n.setQuote,e[44]=n.setRole,e[45]=n.setRunConfig,e[46]=n.setText,e[47]=n.startDictation,e[48]=n.stopDictation,e[49]=y,e[50]=w,e[51]=x,e[52]=S,e[53]=T,e[54]=C):C=e[54],C},On=q(zc);function Gc(){throw new Error("beginEdit is not supported in this runtime")}const Nn=t=>({get current(){return t()}}),Kc=t=>{const e=_(13),{runtime:s}=t,r=Pe(s);let n;e[0]!==r?(n=()=>r,e[0]=r,e[1]=n):n=e[1];let i,o,a,c;e[2]!==s?(i=u=>s.addToolResult(u),o=u=>s.resumeToolCall(u),a=u=>s.respondToToolApproval(u),c=()=>s,e[2]=s,e[3]=i,e[4]=o,e[5]=a,e[6]=c):(i=e[3],o=e[4],a=e[5],c=e[6]);let l;return e[7]!==n||e[8]!==i||e[9]!==o||e[10]!==a||e[11]!==c?(l={getState:n,addToolResult:i,resumeToolCall:o,respondToToolApproval:a,__internal_getRuntime:c},e[7]=n,e[8]=i,e[9]=o,e[10]=a,e[11]=c,e[12]=l):l=e[12],l},Wc=q(Kc),Qc=t=>{const e=_(5),{runtime:s,index:r}=t;let n;e[0]!==r||e[1]!==s?(n=s.getAttachmentByIndex(r),e[0]=r,e[1]=s,e[2]=n):n=e[2];const i=n;let o;return e[3]!==i?(o=Bn({runtime:i}),e[3]=i,e[4]=o):o=e[4],se(o)},Yc=q(Qc),Jc=t=>{const e=_(5),{runtime:s,index:r}=t;let n;e[0]!==r||e[1]!==s?(n=s.getMessagePartByIndex(r),e[0]=r,e[1]=s,e[2]=n):n=e[2];const i=n;let o;return e[3]!==i?(o=Wc({runtime:i}),e[3]=i,e[4]=o):o=e[4],se(o)},Xc=q(Jc),Zc=t=>{const e=_(55),{runtime:s,threadIdRef:r}=t,n=Pe(s),[i,o]=G(!1),[a,c]=G(!1);let l;e[0]!==s?(l=Nn(()=>s.getState().id),e[0]=s,e[1]=l):l=e[1];const u=l;let h;e[2]!==u||e[3]!==s.composer||e[4]!==r?(h=On({runtime:s.composer,threadIdRef:r,messageIdRef:u}),e[2]=u,e[3]=s.composer,e[4]=r,e[5]=h):h=e[5];const d=tt(h);let f;if(e[6]!==s||e[7]!==n.content){let j;e[9]!==s?(j=(U,z)=>ne("toolCallId"in U&&U.toolCallId!=null?`toolCallId-${U.toolCallId}`:`index-${z}`,Xc({runtime:s,index:z}),[s,z]),e[9]=s,e[10]=j):j=e[10],f=n.content.map(j),e[6]=s,e[7]=n.content,e[8]=f}else f=e[8];const g=Re(f);let b;e[11]!==n.attachments?(b=n.attachments??[],e[11]=n.attachments,e[12]=b):b=e[12];let v;if(e[13]!==s||e[14]!==b){let j;e[16]!==s?(j=(U,z)=>ne(U.id,Yc({runtime:s,index:z}),[s,z]),e[16]=s,e[17]=j):j=e[17],v=b.map(j),e[13]=s,e[14]=b,e[15]=v}else v=e[15];const x=Re(v),S=n;let T;e[18]!==d.state||e[19]!==i||e[20]!==a||e[21]!==g.state||e[22]!==S?(T={...S,parts:g.state,composer:d.state,isCopied:i,isHovering:a},e[18]=d.state,e[19]=i,e[20]=a,e[21]=g.state,e[22]=S,e[23]=T):T=e[23];const y=T;let w;e[24]!==y?(w=()=>y,e[24]=y,e[25]=w):w=e[25];let C;e[26]!==d.methods?(C=()=>d.methods,e[26]=d.methods,e[27]=C):C=e[27];let I,$,D,R,E,k,A;e[28]!==s?(I=()=>s.delete(),$=j=>s.reload(j),D=()=>s.speak(),R=()=>s.stopSpeaking(),E=j=>s.submitFeedback(j),k=j=>s.switchToBranch(j),A=()=>s.unstable_getCopyText(),e[28]=s,e[29]=I,e[30]=$,e[31]=D,e[32]=R,e[33]=E,e[34]=k,e[35]=A):(I=e[29],$=e[30],D=e[31],R=e[32],E=e[33],k=e[34],A=e[35]);let B;e[36]!==g?(B=j=>"index"in j?g.get({index:j.index}):g.get({key:`toolCallId-${j.toolCallId}`}),e[36]=g,e[37]=B):B=e[37];let O;e[38]!==x?(O=j=>"id"in j?x.get({key:j.id}):x.get(j),e[38]=x,e[39]=O):O=e[39];let L;e[40]!==s?(L=()=>s,e[40]=s,e[41]=L):L=e[41];let H;return e[42]!==I||e[43]!==$||e[44]!==D||e[45]!==R||e[46]!==E||e[47]!==k||e[48]!==A||e[49]!==B||e[50]!==O||e[51]!==L||e[52]!==w||e[53]!==C?(H={getState:w,composer:C,delete:I,reload:$,speak:D,stopSpeaking:R,submitFeedback:E,switchToBranch:k,getCopyText:A,part:B,attachment:O,setIsCopied:o,setIsHovering:c,__internal_getRuntime:L},e[42]=I,e[43]=$,e[44]=D,e[45]=R,e[46]=E,e[47]=k,e[48]=A,e[49]=B,e[50]=O,e[51]=L,e[52]=w,e[53]=C,e[54]=H):H=e[54],H},el=q(Zc),tl=t=>{const e=_(6),{runtime:s,id:r,threadIdRef:n}=t;let i;e[0]!==r||e[1]!==s?(i=s.getMessageById(r),e[0]=r,e[1]=s,e[2]=i):i=e[2];const o=i;let a;return e[3]!==o||e[4]!==n?(a=el({runtime:o,threadIdRef:n}),e[3]=o,e[4]=n,e[5]=a):a=e[5],se(a)},sl=q(tl),rl=t=>{const e=_(58),{runtime:s}=t,r=Pe(s),n=Ss();let i,o;e[0]!==n||e[1]!==s?(i=()=>{const w=[];for(const C of["runStart","runEnd","initialize","modelContextUpdate"]){const I=s.unstable_on(C,()=>{var D;const $=((D=s.getState())==null?void 0:D.threadId)||"unknown";n(`thread.${C}`,{threadId:$})});w.push(I)}return()=>{for(const C of w)C()}},o=[s,n],e[0]=n,e[1]=s,e[2]=i,e[3]=o):(i=e[2],o=e[3]),N(i,o);let a;e[4]!==s?(a=Nn(()=>s.getState().threadId),e[4]=s,e[5]=a):a=e[5];const c=a;let l;e[6]!==s.composer||e[7]!==c?(l=On({runtime:s.composer,threadIdRef:c}),e[6]=s.composer,e[7]=c,e[8]=l):l=e[8];const u=tt(l);let h;if(e[9]!==s||e[10]!==r.messages||e[11]!==c){let w;e[13]!==s||e[14]!==c?(w=C=>ne(C.id,sl({runtime:s,id:C.id,threadIdRef:c}),[s,C.id,c]),e[13]=s,e[14]=c,e[15]=w):w=e[15],h=r.messages.map(w),e[9]=s,e[10]=r.messages,e[11]=c,e[12]=h}else h=e[12];const d=Re(h),f=d.state.length===0&&!r.isLoading;let g;e[16]!==u.state||e[17]!==d.state||e[18]!==r.capabilities||e[19]!==r.extras||e[20]!==r.isDisabled||e[21]!==r.isLoading||e[22]!==r.isRunning||e[23]!==r.speech||e[24]!==r.state||e[25]!==r.suggestions||e[26]!==r.voice||e[27]!==f?(g={isEmpty:f,isDisabled:r.isDisabled,isLoading:r.isLoading,isRunning:r.isRunning,capabilities:r.capabilities,state:r.state,suggestions:r.suggestions,extras:r.extras,speech:r.speech,voice:r.voice,composer:u.state,messages:d.state},e[16]=u.state,e[17]=d.state,e[18]=r.capabilities,e[19]=r.extras,e[20]=r.isDisabled,e[21]=r.isLoading,e[22]=r.isRunning,e[23]=r.speech,e[24]=r.state,e[25]=r.suggestions,e[26]=r.voice,e[27]=f,e[28]=g):g=e[28];const b=g;let v;e[29]!==b?(v=()=>b,e[29]=b,e[30]=v):v=e[30];let x;e[31]!==u.methods?(x=()=>u.methods,e[31]=u.methods,e[32]=x):x=e[32];let S;e[33]!==d?(S=w=>"id"in w?d.get({key:w.id}):d.get(w),e[33]=d,e[34]=S):S=e[34];let T;e[35]!==s?(T=()=>s,e[35]=s,e[36]=T):T=e[36];let y;return e[37]!==s.append||e[38]!==s.cancelRun||e[39]!==s.connectVoice||e[40]!==s.deleteMessage||e[41]!==s.disconnectVoice||e[42]!==s.export||e[43]!==s.getModelContext||e[44]!==s.getVoiceVolume||e[45]!==s.import||e[46]!==s.muteVoice||e[47]!==s.reset||e[48]!==s.resumeRun||e[49]!==s.startRun||e[50]!==s.stopSpeaking||e[51]!==s.subscribeVoiceVolume||e[52]!==s.unmuteVoice||e[53]!==S||e[54]!==T||e[55]!==v||e[56]!==x?(y={getState:v,composer:x,append:s.append,deleteMessage:s.deleteMessage,startRun:s.startRun,resumeRun:s.resumeRun,cancelRun:s.cancelRun,getModelContext:s.getModelContext,export:s.export,import:s.import,reset:s.reset,stopSpeaking:s.stopSpeaking,connectVoice:s.connectVoice,disconnectVoice:s.disconnectVoice,getVoiceVolume:s.getVoiceVolume,subscribeVoiceVolume:s.subscribeVoiceVolume,muteVoice:s.muteVoice,unmuteVoice:s.unmuteVoice,message:S,__internal_getRuntime:T},e[37]=s.append,e[38]=s.cancelRun,e[39]=s.connectVoice,e[40]=s.deleteMessage,e[41]=s.disconnectVoice,e[42]=s.export,e[43]=s.getModelContext,e[44]=s.getVoiceVolume,e[45]=s.import,e[46]=s.muteVoice,e[47]=s.reset,e[48]=s.resumeRun,e[49]=s.startRun,e[50]=s.stopSpeaking,e[51]=s.subscribeVoiceVolume,e[52]=s.unmuteVoice,e[53]=S,e[54]=T,e[55]=v,e[56]=x,e[57]=y):y=e[57],y},nl=q(rl),il=t=>{const e=_(20),{runtime:s}=t,r=Pe(s),n=Ss();let i,o;e[0]!==n||e[1]!==s?(i=()=>{const u=[];for(const h of["switchedTo","switchedAway"]){const d=s.unstable_on(h,()=>{n(`threadListItem.${h}`,{threadId:s.getState().id})});u.push(d)}return()=>{for(const h of u)h()}},o=[s,n],e[0]=n,e[1]=s,e[2]=i,e[3]=o):(i=e[2],o=e[3]),N(i,o);let a;e[4]!==r?(a=()=>r,e[4]=r,e[5]=a):a=e[5];let c;e[6]!==s?(c=()=>s,e[6]=s,e[7]=c):c=e[7];let l;return e[8]!==s.archive||e[9]!==s.delete||e[10]!==s.detach||e[11]!==s.generateTitle||e[12]!==s.initialize||e[13]!==s.rename||e[14]!==s.switchTo||e[15]!==s.unarchive||e[16]!==s.updateCustom||e[17]!==a||e[18]!==c?(l={getState:a,switchTo:s.switchTo,rename:s.rename,updateCustom:s.updateCustom,archive:s.archive,unarchive:s.unarchive,delete:s.delete,generateTitle:s.generateTitle,initialize:s.initialize,detach:s.detach,__internal_getRuntime:c},e[8]=s.archive,e[9]=s.delete,e[10]=s.detach,e[11]=s.generateTitle,e[12]=s.initialize,e[13]=s.rename,e[14]=s.switchTo,e[15]=s.unarchive,e[16]=s.updateCustom,e[17]=a,e[18]=c,e[19]=l):l=e[19],l},ol=q(il),al=t=>{const e=_(5),{runtime:s,id:r}=t;let n;e[0]!==r||e[1]!==s?(n=s.getItemById(r),e[0]=r,e[1]=s,e[2]=n):n=e[2];const i=n;let o;return e[3]!==i?(o=ol({runtime:i}),e[3]=i,e[4]=o):o=e[4],se(o)},cl=q(al),ll=t=>{const e=_(40),{runtime:s,__internal_assistantRuntime:r}=t,n=Pe(s);let i;e[0]!==s.main?(i=nl({runtime:s.main}),e[0]=s.main,e[1]=i):i=e[1];const o=tt(i);let a;e[2]!==s||e[3]!==n.threadItems?(a=Object.keys(n.threadItems).map(C=>ne(C,cl({runtime:s,id:C}),[s,C])),e[2]=s,e[3]=n.threadItems,e[4]=a):a=e[4];const c=Re(a),l=n.newThreadId??null;let u;e[5]!==o.state||e[6]!==n.archivedThreadIds||e[7]!==n.hasMore||e[8]!==n.isLoading||e[9]!==n.isLoadingMore||e[10]!==n.mainThreadId||e[11]!==n.threadIds||e[12]!==l||e[13]!==c.state?(u={mainThreadId:n.mainThreadId,newThreadId:l,isLoading:n.isLoading,isLoadingMore:n.isLoadingMore,hasMore:n.hasMore,threadIds:n.threadIds,archivedThreadIds:n.archivedThreadIds,threadItems:c.state,main:o.state},e[5]=o.state,e[6]=n.archivedThreadIds,e[7]=n.hasMore,e[8]=n.isLoading,e[9]=n.isLoadingMore,e[10]=n.mainThreadId,e[11]=n.threadIds,e[12]=l,e[13]=c.state,e[14]=u):u=e[14];const h=u;let d;e[15]!==h?(d=()=>h,e[15]=h,e[16]=d):d=e[16];let f;e[17]!==o.methods?(f=()=>o.methods,e[17]=o.methods,e[18]=f):f=e[18];let g;e[19]!==h||e[20]!==c?(g=C=>{if(C==="main")return c.get({key:h.mainThreadId});if("id"in C)return c.get({key:C.id});const{index:I,archived:$}=C,D=$!==void 0&&$?h.archivedThreadIds[I]:h.threadIds[I];return c.get({key:D})},e[19]=h,e[20]=c,e[21]=g):g=e[21];let b,v,x,S,T;e[22]!==s?(S=async(C,I)=>{await s.switchToThread(C,I)},T=async()=>{await s.switchToNewThread()},b=()=>s.getLoadThreadsPromise(),v=()=>s.reload(),x=()=>s.loadMore(),e[22]=s,e[23]=b,e[24]=v,e[25]=x,e[26]=S,e[27]=T):(b=e[23],v=e[24],x=e[25],S=e[26],T=e[27]);let y;e[28]!==r?(y=()=>r,e[28]=r,e[29]=y):y=e[29];let w;return e[30]!==b||e[31]!==v||e[32]!==x||e[33]!==y||e[34]!==d||e[35]!==f||e[36]!==g||e[37]!==S||e[38]!==T?(w={getState:d,thread:f,item:g,switchToThread:S,switchToNewThread:T,getLoadThreadsPromise:b,reload:v,loadMore:x,__internal_getAssistantRuntime:y},e[30]=b,e[31]=v,e[32]=x,e[33]=y,e[34]=d,e[35]=f,e[36]=g,e[37]=S,e[38]=T,e[39]=w):w=e[39],w},ul=q(ll),dl=t=>({getState:()=>t}),hl=q(dl),fl=t=>{const e=_(11);let s;e[0]!==t?(s=()=>({suggestions:(t??[]).map(gl)}),e[0]=t,e[1]=s):s=e[1];const[r]=G(s);let n;e[2]!==r.suggestions?(n=r.suggestions.map(ml),e[2]=r.suggestions,e[3]=n):n=e[3];const i=Re(n);let o;e[4]!==r?(o=()=>r,e[4]=r,e[5]=o):o=e[5];let a;e[6]!==i?(a=l=>{const{index:u}=l;return i.get({index:u})},e[6]=i,e[7]=a):a=e[7];let c;return e[8]!==o||e[9]!==a?(c={getState:o,suggestion:a},e[8]=o,e[9]=a,e[10]=c):c=e[10],c},pl=q(fl);function gl(t){return typeof t=="string"?{title:t,label:"",prompt:t}:{title:t.title,label:t.label,prompt:t.prompt}}function ml(t,e){return ne(e,hl(t),[t])}const bl=(t,e)=>{t.thread??(t.thread=re({source:"threads",query:{type:"main"},get:s=>s.threads().thread("main")})),t.threadListItem??(t.threadListItem=re({source:"threads",query:{type:"main"},get:s=>s.threads().item("main")})),t.composer??(t.composer=re({source:"thread",query:{},get:s=>s.threads().thread("main").composer()})),!t.modelContext&&e.modelContext.source===null&&(t.modelContext=xn()),!t.suggestions&&e.suggestions.source===null&&(t.suggestions=pl())},Fn=t=>{const e=_(6),s=$n();let r,n;e[0]!==s||e[1]!==t?(r=()=>t.registerModelContextProvider(s.current.modelContext()),n=[t,s],e[0]=s,e[1]=t,e[2]=r,e[3]=n):(r=e[2],n=e[3]),N(r,n);let i;return e[4]!==t?(i=ul({runtime:t.threads,__internal_assistantRuntime:t}),e[4]=t,e[5]=i):i=e[5],se(i)},_l=q(Fn);An(Fn,(t,e)=>{bl(t,e),!t.tools&&e.tools.source===null&&(t.tools=Dc({})),!t.dataRenderers&&e.dataRenderers.source===null&&(t.dataRenderers=Da())});const yl=t=>{var e;return(e=t._core)==null?void 0:e.RenderComponent},vl=M.memo(({runtime:t,aui:e=null,children:s})=>{"use no memo";const r=F({threads:_l(t)},{parent:e}),n=yl(t),i=p.jsxs(ue,{value:r,children:[n&&p.jsx(n,{}),s]});return e?p.jsx(ue,{value:e,children:i}):i}),sr=t=>{let e;const s=new Set,r=(l,u)=>{const h=typeof l=="function"?l(e):l;if(!Object.is(h,e)){const d=e;e=u??(typeof h!="object"||h===null)?h:Object.assign({},e,h),s.forEach(f=>f(e,d))}},n=()=>e,a={setState:r,getState:n,getInitialState:()=>c,subscribe:l=>(s.add(l),()=>s.delete(l))},c=e=t(r,n,a);return a},Sl=t=>t?sr(t):sr,xl=t=>t;function wl(t,e=xl){const s=J.useSyncExternalStore(t.subscribe,J.useCallback(()=>e(t.getState()),[t,e]),J.useCallback(()=>e(t.getInitialState()),[t,e]));return J.useDebugValue(s),s}const rr=t=>{const e=Sl(t),s=r=>wl(e,r);return Object.assign(s,e),s},Tl=t=>t?rr(t):rr;function Z(t){return t!=null&&typeof t=="object"&&!Array.isArray(t)}function vt(t,e=0){return e>100?!1:t===null||typeof t=="string"||typeof t=="boolean"?!0:typeof t=="number"?!Number.isNaN(t)&&Number.isFinite(t):Array.isArray(t)?t.every(s=>vt(s,e+1)):Z(t)?Object.entries(t).every(([s,r])=>typeof s=="string"&&vt(r,e+1)):!1}const Cl=100,Xt=(t,e,s)=>{if(t===e)return!0;if(s>Cl||t==null||e==null)return!1;if(Array.isArray(t))return!Array.isArray(e)||t.length!==e.length?!1:t.every((i,o)=>Xt(i,e[o],s+1));if(Array.isArray(e)||!Z(t)||!Z(e))return!1;const r=Object.keys(t),n=Object.keys(e);return r.length!==n.length?!1:r.every(i=>Object.hasOwn(e,i)&&Xt(t[i],e[i],s+1))},xs=(t,e)=>!vt(t)||!vt(e)?!1:Xt(t,e,0);function Il(t){const e=t.metadata;if(!e||typeof e!="object")return;const s=e.custom;if(!s||typeof s!="object")return;const r=s.interactables;return Array.isArray(r)?r:void 0}function El(t){return`update_${t.replace(/[^a-zA-Z0-9_-]/g,"_")}`}const nr=t=>{if(!Z(t))return;const e=t.id;return typeof e=="string"||typeof e=="number"?e:void 0};function Rl(t,e,s){let r=Array.isArray(e.set)?[...e.set]:[...t];if(e.clear===!0&&(r=[]),Array.isArray(e.remove)&&e.remove.length>0){const i=new Set(e.remove);r=r.filter(o=>{const a=nr(o);return a!==void 0?!i.has(a):!i.has(o)})}const n=e.update;if(Array.isArray(n)&&n.length>0&&(r=r.map(i=>{const o=nr(i);if(o===void 0||!Z(i))return i;const a=n.find(c=>Z(c)&&c.id===o);return a?{...i,...a}:i})),Array.isArray(e.add)&&e.add.length>0){const i=s?e.add.map(o=>{if(!Z(o)||o.id!==void 0)return o;const a=s();return a===void 0?o:{...o,id:a}}):e.add;r=[...r,...i]}return r}function Ot(t,e,s){if(!Z(t)||!Z(e))return e;const r=Z(s==null?void 0:s.arrayBaseline)?s.arrayBaseline:t,n={...t};for(const[i,o]of Object.entries(e)){const a=r[i];Array.isArray(a)&&Z(o)?n[i]=Rl(a,o,s!=null&&s.idFactory&&(s.idKeyedFields===void 0||s.idKeyedFields.has(i))?()=>{var c;return(c=s.idFactory)==null?void 0:c.call(s,i)}:void 0):n[i]=o}return n}function Al(t,e){if(!Z(t)||!Z(e))return;for(const n of Object.keys(t))if(!(n in e))return;const s={};for(const[n,i]of Object.entries(e))(!(n in t)||!xs(t[n],i))&&(s[n]=i);const r=Object.keys(s).length;if(!(r===0||r===Object.keys(e).length))return s}const Ml=t=>{if(!t||typeof t!="object")return;const e=t;return e.type==="tool-call"?e:void 0},Pl=(t,e)=>{if(!t.args||typeof t.args!="object")return!1;const s=Z(t.result)?t.result:void 0;if((s==null?void 0:s.success)===!1)return!1;if(typeof(s==null?void 0:s.id)=="string")return s.id===e;const r=t.args.id;return r===e||r===void 0},kl=t=>{const e=Z(t)?t.addedItemIds:void 0;if(!Z(e))return;const s=new Map;for(const[r,n]of Object.entries(e)){if(!Array.isArray(n))continue;const i=n.filter(o=>typeof o=="string");i.length>0&&s.set(r,i)}if(s.size!==0)return r=>{var n;return(n=s.get(r))==null?void 0:n.shift()}},ir=new WeakMap;function $l(t,e,s){var l;let r=ir.get(t);r||(r=new Map,ir.set(t,r));let n=r.get(s);n||(n=new Map,r.set(s,n));const i=n.get(e);if(i)return i;const o=El(s),a=[],c=()=>a[a.length-1];for(const u of t){if(u.role==="user"){const h=(l=Il(u))==null?void 0:l.find(d=>d.id===e);if(!h)continue;if(h.partial){const d=c();d&&a.push({state:Ot(d.state,h.state),origin:"user-edit"})}else a.push({state:h.state,origin:"user-edit"});continue}if(u.role==="assistant")for(const h of u.content??[]){const d=Ml(h);if(d){if(d.toolCallId===e&&d.toolName===s)d.args&&typeof d.args=="object"&&a.push({state:d.args,origin:"create",toolCallId:e});else if(d.toolName===o&&Pl(d,e)){const f=c();if(f){const{id:g,...b}=d.args,v=kl(d.result);a.push({state:v?Ot(f.state,b,{idFactory:v}):Ot(f.state,b),origin:"update",toolCallId:d.toolCallId})}}}}}return n.set(e,a),a}function Dl(t,e,s){const r=$l(t,e,s),n=r[r.length-1];return n?{state:n.state}:void 0}function Ln(t,e){if(!t)return;const{interactables:s,...r}=t,n={...r};if(Array.isArray(s)){const i=[];for(const o of s){const a=Dl(e,o.id,o.name);if(!a){i.push({id:o.id,name:o.name,state:o.state});continue}if(xs(o.state,a.state))continue;const c=Al(a.state,o.state);i.push(c?{id:o.id,name:o.name,state:c,partial:!0}:{id:o.id,name:o.name,state:o.state})}i.length&&(n.interactables=i)}return Object.keys(n).length?n:void 0}const ws=()=>{let t,e;const s=new Promise((r,n)=>{t=r,e=n});if(!t||!e)throw new Error("Failed to create promise");return{promise:s,resolve:t,reject:e}},jl=()=>{const t=[];let e=!1,s,r;const n=i=>{i.promise||(i.promise=i.reader.read().then(({done:o,value:a})=>{i.promise=void 0,o?(t.splice(t.indexOf(i),1),e&&t.length===0&&s.close()):s.enqueue(a),r==null||r.resolve(),r=void 0}).catch(o=>{console.error(o),t.forEach(a=>{a.reader.cancel()}),t.length=0,s.error(o),r==null||r.reject(o),r=void 0}))};return{readable:new ReadableStream({start(i){s=i},pull(){return r=ws(),t.forEach(i=>{n(i)}),r.promise},cancel(){t.forEach(i=>{i.reader.cancel()}),t.length=0}}),isSealed(){return e},seal(){e=!0,t.length===0&&s.close()},addStream(i){if(e)throw new Error("Cannot add streams after the run callback has settled.");const o={reader:i.getReader()};t.push(o),n(o)},enqueue(i){this.addStream(new ReadableStream({start(o){o.enqueue(i),o.close()}}))}}};var or=class{constructor(t){m(this,"_controller");m(this,"_isClosed",!1);this._controller=t}append(t){return this._controller.enqueue({type:"text-delta",path:[],textDelta:t}),this}close(){this._isClosed||(this._isClosed=!0,this._controller.enqueue({type:"part-finish",path:[]}),this._controller.close())}};const Vn=t=>new ReadableStream({start(e){var s;return(s=t.start)==null?void 0:s.call(t,new or(e))},pull(e){var s;return(s=t.pull)==null?void 0:s.call(t,new or(e))},cancel(e){var s;return(s=t.cancel)==null?void 0:s.call(t,e)}}),ar=()=>{let t;return[Vn({start(e){t=e}}),t]};var cr=class{constructor(t){m(this,"_controller");m(this,"_isClosed",!1);m(this,"_mergeTask");m(this,"_argsTextController");this._controller=t;const e=Vn({start:r=>{this._argsTextController=r}});let s=!1;this._mergeTask=e.pipeTo(new WritableStream({write:r=>{switch(r.type){case"text-delta":s=!0,this._controller.enqueue(r);break;case"part-finish":s||this._controller.enqueue({type:"text-delta",textDelta:"{}",path:[]}),this._controller.enqueue({type:"tool-call-args-text-finish",path:[]});break;default:throw new Error(`Unexpected chunk type: ${r.type}`)}}}))}get argsText(){return this._argsTextController}async setResponse(t){this._argsTextController.close(),await Promise.resolve(),this._controller.enqueue({type:"result",path:[],...t.artifact!==void 0?{artifact:t.artifact}:{},result:t.result,isError:t.isError??!1,...t.modelContent!==void 0?{modelContent:t.modelContent}:{},...t.messages!==void 0?{messages:t.messages}:{}})}async close(){this._isClosed||(this._isClosed=!0,this._argsTextController.close(),await this._mergeTask,this._controller.enqueue({type:"part-finish",path:[]}),this._controller.close())}};const Bl=t=>new ReadableStream({start(e){var s;return(s=t.start)==null?void 0:s.call(t,new cr(e))},pull(e){var s;return(s=t.pull)==null?void 0:s.call(t,new cr(e))},cancel(e){var s;return(s=t.cancel)==null?void 0:s.call(t,e)}}),Ol=()=>{let t;return[Bl({start(e){t=e}}),t]};var Un=class{constructor(){m(this,"value",-1)}up(){return++this.value}},Nl=class extends TransformStream{constructor(t){super({transform(e,s){s.enqueue({...e,path:[t,...e.path]})}})}};(class extends TransformStream{constructor(t){super({transform(e,s){const{path:[r,...n]}=e;if(t!==r)throw new Error(`Path mismatch: expected ${t}, got ${r}`);s.enqueue({...e,path:n})}})}});var Fl=class extends TransformStream{constructor(t){const e=new Un,s=new Map;super({transform(r,n){r.type==="part-start"&&r.path.length===0&&s.set(e.up(),t.up());const[i,...o]=r.path;if(i===void 0){n.enqueue(r);return}const a=s.get(i);if(a===void 0)throw new Error("Path not found");n.enqueue({...r,path:[a,...o]})}})}},Ll=class extends TransformStream{constructor(t){super();const e=t(super.readable);Object.defineProperty(this,"readable",{value:e,writable:!1})}},qn=class extends TransformStream{constructor(){const t=[];super({transform(e,s){if(e.type==="part-start"){if(e.path.length!==0){s.error(new Error("Nested parts are not supported"));return}t.push(e.part),s.enqueue(e);return}if(e.type==="text-delta"||e.type==="result"||e.type==="part-finish"||e.type==="tool-call-args-text-finish"){if(e.path.length!==1){s.error(new Error(`${e.type} chunks must have a path of length 1`));return}const r=e.path[0];if(r<0||r>=t.length){s.error(new Error(`Invalid path index: ${r}`));return}const n=t[r];s.enqueue({...e,meta:n});return}s.enqueue(e)}})}};let Vl=(t,e=21)=>(s=e)=>{let r="",n=s|0;for(;n-- >0;)r+=t[Math.random()*t.length|0];return r};const Ul=Vl("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",7);var ql=class Hn{constructor(e){m(this,"_state");m(this,"_parentId");this._state=e||{merger:jl(),contentCounter:new Un}}get __internal_isClosed(){return this._state.merger.isSealed()}__internal_getReadable(){return this._state.merger.readable}__internal_subscribeToClose(e){this._state.closeSubscriber=e}_addPart(e,s){this._state.append&&(this._state.append.controller.close(),this._state.append=void 0),this.enqueue({type:"part-start",part:e,path:[]}),this._state.merger.addStream(s.pipeThrough(new Nl(this._state.contentCounter.value)))}merge(e){this._state.merger.addStream(e.pipeThrough(new Fl(this._state.contentCounter)))}appendText(e){var s;(((s=this._state.append)==null?void 0:s.kind)!=="text"||this._state.append.parentId!==this._parentId)&&(this._state.append={kind:"text",parentId:this._parentId,controller:this.addTextPart()}),this._state.append.controller.append(e)}appendReasoning(e){var s;(((s=this._state.append)==null?void 0:s.kind)!=="reasoning"||this._state.append.parentId!==this._parentId)&&(this._state.append={kind:"reasoning",parentId:this._parentId,controller:this.addReasoningPart()}),this._state.append.controller.append(e)}addTextPart(){const[e,s]=ar();return this._addPart(this._withParentIdOption({type:"text"}),e),s}addReasoningPart(){const[e,s]=ar();return this._addPart(this._withParentIdOption({type:"reasoning"}),e),s}addToolCallPart(e){const s=typeof e=="string"?{toolName:e}:e,r=s.toolName,n=s.toolCallId??Ul(),[i,o]=Ol();return this._addPart({type:"tool-call",toolName:r,toolCallId:n,...this._parentId&&{parentId:this._parentId}},i),s.argsText!==void 0&&(o.argsText.append(s.argsText),o.argsText.close()),s.args!==void 0&&(o.argsText.append(JSON.stringify(s.args)),o.argsText.close()),s.response!==void 0&&o.setResponse(s.response),o}_finishedPartStream(){return new ReadableStream({start(e){e.enqueue({type:"part-finish",path:[]}),e.close()}})}_withParentIdOption(e){return this._parentId?{...e,parentId:this._parentId}:e}appendSource(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}appendFile(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}appendData(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}enqueue(e){this._state.merger.enqueue(e),e.type==="part-start"&&e.path.length===0&&this._state.contentCounter.up()}withParentId(e){const s=new Hn(this._state);return s._parentId=e,s}close(){var e,s,r,n;(s=(e=this._state.append)==null?void 0:e.controller)==null||s.close(),this._state.merger.seal(),(n=(r=this._state).closeSubscriber)==null||n.call(r)}};function Hl(t){const e=new ql;return(async()=>{try{await t(e)}catch(r){throw e.__internal_isClosed||e.enqueue({type:"error",path:[],error:String(r)}),r}finally{e.__internal_isClosed||e.close()}})(),e.__internal_getReadable()}function zl(){const{resolve:t,promise:e}=ws();let s;return[Hl(r=>(s=r,s.__internal_subscribeToClose(t),e)),s]}function Gl(t){const e=["ROOT"];let s=-1,r=null;const n=[];let i;function o(){i!==void 0&&(n.push(JSON.parse(`"${i}"`)),i=void 0)}function a(h,d,f){switch(h){case'"':s=d,e.pop(),e.push(f),e.push("INSIDE_STRING"),o();break;case"f":case"t":case"n":s=d,r=d,e.pop(),e.push(f),e.push("INSIDE_LITERAL");break;case"-":e.pop(),e.push(f),e.push("INSIDE_NUMBER"),o();break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":s=d,e.pop(),e.push(f),e.push("INSIDE_NUMBER"),o();break;case"{":s=d,e.pop(),e.push(f),e.push("INSIDE_OBJECT_START"),o();break;case"[":s=d,e.pop(),e.push(f),e.push("INSIDE_ARRAY_START"),o();break}}function c(h,d){switch(h){case",":e.pop(),e.push("INSIDE_OBJECT_AFTER_COMMA");break;case"}":s=d,e.pop(),i=n.pop();break}}function l(h,d){switch(h){case",":e.pop(),e.push("INSIDE_ARRAY_AFTER_COMMA"),i=(Number(i)+1).toString();break;case"]":s=d,e.pop(),i=n.pop();break}}for(let h=0;h<t.length;h++){const d=t[h];switch(e[e.length-1]){case"ROOT":a(d,h,"FINISH");break;case"INSIDE_OBJECT_START":switch(d){case'"':e.pop(),e.push("INSIDE_OBJECT_KEY"),i="";break;case"}":s=h,e.pop(),i=n.pop();break}break;case"INSIDE_OBJECT_AFTER_COMMA":switch(d){case'"':e.pop(),e.push("INSIDE_OBJECT_KEY"),i="";break}break;case"INSIDE_OBJECT_KEY":switch(d){case'"':e.pop(),e.push("INSIDE_OBJECT_AFTER_KEY");break;case"\\":e.push("INSIDE_STRING_ESCAPE"),i+=d;break;default:i+=d;break}break;case"INSIDE_OBJECT_AFTER_KEY":switch(d){case":":e.pop(),e.push("INSIDE_OBJECT_BEFORE_VALUE");break}break;case"INSIDE_OBJECT_BEFORE_VALUE":a(d,h,"INSIDE_OBJECT_AFTER_VALUE");break;case"INSIDE_OBJECT_AFTER_VALUE":c(d,h);break;case"INSIDE_STRING":switch(d){case'"':e.pop(),s=h,i=n.pop();break;case"\\":e.push("INSIDE_STRING_ESCAPE");break;default:s=h}break;case"INSIDE_ARRAY_START":switch(d){case"]":s=h,e.pop(),i=n.pop();break;default:s=h,i="0",a(d,h,"INSIDE_ARRAY_AFTER_VALUE");break}break;case"INSIDE_ARRAY_AFTER_VALUE":switch(d){case",":e.pop(),e.push("INSIDE_ARRAY_AFTER_COMMA"),i=(Number(i)+1).toString();break;case"]":s=h,e.pop(),i=n.pop();break;default:s=h;break}break;case"INSIDE_ARRAY_AFTER_COMMA":a(d,h,"INSIDE_ARRAY_AFTER_VALUE");break;case"INSIDE_STRING_ESCAPE":e.pop(),e[e.length-1]==="INSIDE_STRING"?s=h:e[e.length-1]==="INSIDE_OBJECT_KEY"&&(i+=d);break;case"INSIDE_NUMBER":switch(d){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":s=h;break;case"e":case"E":case"-":case".":break;case",":e.pop(),i=n.pop(),e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&l(d,h),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&c(d,h);break;case"}":e.pop(),i=n.pop(),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&c(d,h);break;case"]":e.pop(),i=n.pop(),e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&l(d,h);break;default:e.pop(),i=n.pop();break}break;case"INSIDE_LITERAL":{const f=t.substring(r,h+1);!"false".startsWith(f)&&!"true".startsWith(f)&&!"null".startsWith(f)?(e.pop(),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?c(d,h):e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&l(d,h)):s=h;break}}}let u=t.slice(0,s+1);for(let h=e.length-1;h>=0;h--)switch(e[h]){case"INSIDE_STRING":u+='"';break;case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":u+="}";break;case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":u+="]";break;case"INSIDE_LITERAL":{const d=t.substring(r,t.length);"true".startsWith(d)?u+="true".slice(d.length):"false".startsWith(d)?u+="false".slice(d.length):"null".startsWith(d)&&(u+="null".slice(d.length))}}return[u,n]}var He={exports:{}};const Kl=typeof Buffer<"u",lr=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,ur=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function zn(t,e,s){s==null&&e!==null&&typeof e=="object"&&(s=e,e=void 0),Kl&&Buffer.isBuffer(t)&&(t=t.toString()),t&&t.charCodeAt(0)===65279&&(t=t.slice(1));const r=JSON.parse(t,e);if(r===null||typeof r!="object")return r;const n=s&&s.protoAction||"error",i=s&&s.constructorAction||"error";if(n==="ignore"&&i==="ignore")return r;if(n!=="ignore"&&i!=="ignore"){if(lr.test(t)===!1&&ur.test(t)===!1)return r}else if(n!=="ignore"&&i==="ignore"){if(lr.test(t)===!1)return r}else if(ur.test(t)===!1)return r;return Gn(r,{protoAction:n,constructorAction:i,safe:s&&s.safe})}function Gn(t,{protoAction:e="error",constructorAction:s="error",safe:r}={}){let n=[t];for(;n.length;){const i=n;n=[];for(const o of i){if(e!=="ignore"&&Object.prototype.hasOwnProperty.call(o,"__proto__")){if(r===!0)return null;if(e==="error")throw new SyntaxError("Object contains forbidden prototype property");delete o.__proto__}if(s!=="ignore"&&Object.prototype.hasOwnProperty.call(o,"constructor")&&o.constructor!==null&&typeof o.constructor=="object"&&Object.prototype.hasOwnProperty.call(o.constructor,"prototype")){if(r===!0)return null;if(s==="error")throw new SyntaxError("Object contains forbidden prototype property");delete o.constructor}for(const a in o){const c=o[a];c&&typeof c=="object"&&n.push(c)}}}return t}function Ts(t,e,s){const{stackTraceLimit:r}=Error;Error.stackTraceLimit=0;try{return zn(t,e,s)}finally{Error.stackTraceLimit=r}}function Wl(t,e){const{stackTraceLimit:s}=Error;Error.stackTraceLimit=0;try{return zn(t,e,{safe:!0})}catch{return}finally{Error.stackTraceLimit=s}}He.exports=Ts;He.exports.default=Ts;He.exports.parse=Ts;He.exports.safeParse=Wl;He.exports.scan=Gn;var Ql=He.exports;const Zt=Uo(Ql),ht=Symbol("aui.parse-partial-json-object.meta"),Yl=t=>t==null?void 0:t[ht],es=t=>{if(t.length===0)return{[ht]:{state:"partial",partialPath:[]}};try{const e=Zt.parse(t);if(typeof e!="object"||e===null)throw new Error("argsText is expected to be an object");return e[ht]={state:"complete",partialPath:[]},e}catch{try{const[e,s]=Gl(t),r=Zt.parse(e);if(typeof r!="object"||r===null)throw new Error("argsText is expected to be an object");return r[ht]={state:"partial",partialPath:s},r}catch{return}}},Kn=(t,e,s)=>{if(typeof t!="object"||t===null)return e.state;if(e.state==="complete")return"complete";if(s.length===0)return e.state;const[r,...n]=s;if(!Object.hasOwn(t,r))return"partial";const[i,...o]=e.partialPath;if(r!==i)return"complete";const a=t[r];return Kn(a,{state:"partial",partialPath:o},n)},Fe=(t,e)=>{const s=Yl(t);if(!s)throw new Error("unable to determine object state");return Kn(t,s,e.map(String))};async function*Jl(){const t=this.getReader();try{for(;;){const{done:e,value:s}=await t.read();if(e)break;yield s}}finally{t.releaseLock()}}function Nt(t){var e;return t[e=Symbol.asyncIterator]??(t[e]=Jl),t}const dr=Symbol.for("aui.tool-response");var ve=class ts{constructor(e){m(this,"artifact");m(this,"result");m(this,"isError");m(this,"modelContent");m(this,"messages");e.artifact!==void 0&&(this.artifact=e.artifact),this.result=e.result,this.isError=e.isError??!1,e.modelContent!==void 0&&(this.modelContent=e.modelContent),e.messages!==void 0&&(this.messages=e.messages)}get[dr](){return!0}static[Symbol.hasInstance](e){return typeof e=="object"&&e!==null&&dr in e}static toResponse(e){return e instanceof ts?e:new ts({result:e===void 0?"<no result>":e})}};function Xl(t,e,s){try{const r=t();if(typeof r=="object"&&r!==null&&"then"in r)return r.then(e,s);e(r)}catch(r){s(r)}}function Le(t,e){let s=t;for(const r of e){if(s==null)return;s=s[r]}return s}var Zl=class{constructor(t,e,s){m(this,"resolve");m(this,"reject");m(this,"disposed",!1);m(this,"fieldPath");this.resolve=t,this.reject=e,this.fieldPath=s}update(t){if(!this.disposed)try{if(Fe(t,this.fieldPath)==="complete"){const e=Le(t,this.fieldPath);e!==void 0&&(this.resolve(e),this.dispose())}}catch(e){this.reject(e),this.dispose()}}end(t){if(!this.disposed)try{const e=Le(t,this.fieldPath);this.resolve(e)}catch(e){this.reject(e)}finally{this.dispose()}}dispose(){this.disposed=!0}},eu=class{constructor(t,e){m(this,"controller");m(this,"disposed",!1);m(this,"fieldPath");this.controller=t,this.fieldPath=e}update(t){if(!this.disposed)try{const e=Le(t,this.fieldPath);e!==void 0&&this.controller.enqueue(e),Fe(t,this.fieldPath)==="complete"&&(this.controller.close(),this.dispose())}catch(e){this.controller.error(e),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},tu=class{constructor(t,e){m(this,"controller");m(this,"disposed",!1);m(this,"fieldPath");m(this,"lastValue");this.controller=t,this.fieldPath=e}update(t){var e;if(!this.disposed)try{const s=Le(t,this.fieldPath);if(s!==void 0&&typeof s=="string"){const r=s.substring(((e=this.lastValue)==null?void 0:e.length)||0);this.lastValue=s,this.controller.enqueue(r)}Fe(t,this.fieldPath)==="complete"&&(this.controller.close(),this.dispose())}catch(s){this.controller.error(s),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},su=class{constructor(t,e){m(this,"controller");m(this,"disposed",!1);m(this,"fieldPath");m(this,"processedIndexes",new Set);this.controller=t,this.fieldPath=e}update(t){if(!this.disposed)try{const e=Le(t,this.fieldPath);if(!Array.isArray(e))return;for(let s=0;s<e.length;s++)this.processedIndexes.has(s)||Fe(t,[...this.fieldPath,s])==="complete"&&(this.controller.enqueue(e[s]),this.processedIndexes.add(s));Fe(t,this.fieldPath)==="complete"&&(this.controller.close(),this.dispose())}catch(e){this.controller.error(e),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},ru=class{constructor(t){m(this,"argTextDeltas");m(this,"handles",new Set);m(this,"args",es(""));m(this,"finished",!1);this.argTextDeltas=t,this.processStream()}async processStream(){try{let t="";const e=this.argTextDeltas.getReader();for(;;){const{value:s,done:r}=await e.read();if(r)break;t+=s;const n=es(t);if(n!==void 0){this.args=n;for(const i of this.handles)i.update(n)}}}catch(t){console.error("Error processing argument stream:",t)}finally{this.finished=!0;for(const t of this.handles)t.end(this.args);this.handles.clear()}}get(...t){return new Promise((e,s)=>{const r=new Zl(e,s,t);if(this.args&&Fe(this.args,t)==="complete"){const n=Le(this.args,t);if(n!==void 0){e(n);return}}if(this.finished){r.end(this.args);return}this.handles.add(r),r.update(this.args)})}streamValues(...t){const e=t;let s;return Nt(new ReadableStream({start:r=>{s=new eu(r,e),this.finished||this.handles.add(s),s.update(this.args),this.finished&&s.end()},cancel:()=>{s&&(s.dispose(),this.handles.delete(s))}}))}streamText(...t){const e=t;let s;return Nt(new ReadableStream({start:r=>{s=new tu(r,e),this.finished||this.handles.add(s),s.update(this.args),this.finished&&s.end()},cancel:()=>{s&&(s.dispose(),this.handles.delete(s))}}))}forEach(...t){const e=t;let s;return Nt(new ReadableStream({start:r=>{s=new su(r,e),this.finished||this.handles.add(s),s.update(this.args),this.finished&&s.end()},cancel:()=>{s&&(s.dispose(),this.handles.delete(s))}}))}},nu=class{constructor(t){m(this,"promise");this.promise=t}get(){return this.promise}},iu=class{constructor(){m(this,"args");m(this,"response");m(this,"writable");m(this,"resolve");m(this,"argsText","");m(this,"result",{get:async()=>(await this.response.get()).result});const t=new TransformStream;this.writable=t.writable,this.args=new ru(t.readable);const{promise:e,resolve:s}=ws();this.resolve=s,this.response=new nu(e)}async appendArgsTextDelta(t){const e=this.writable.getWriter();try{await e.write(t)}catch(s){console.warn(s)}finally{e.releaseLock()}this.argsText+=t}async finishArgsText(){const t=this.writable.getWriter();try{await t.close()}catch(e){console.warn(e)}finally{t.releaseLock()}}setResponse(t){this.resolve(t)}},ou=class extends Ll{constructor(t){const e=new Map,s=new Map;super(r=>{const n=new TransformStream({async transform(i,o){switch((i.type!=="part-finish"||i.meta.type!=="tool-call")&&o.enqueue(i),i.type){case"part-start":if(i.part.type==="tool-call"){const a=new iu;s.set(i.part.toolCallId,a),t.streamCall({reader:a,toolCallId:i.part.toolCallId,toolName:i.part.toolName})}break;case"text-delta":if(i.meta.type==="tool-call"){const a=i.meta.toolCallId,c=s.get(a);if(!c)throw new Error("No controller found for tool call");await c.appendArgsTextDelta(i.textDelta)}break;case"result":{if(i.meta.type!=="tool-call")break;const{toolCallId:a}=i.meta,c=s.get(a);if(!c)throw new Error("No controller found for tool call");c.setResponse(new ve({result:i.result,artifact:i.artifact,isError:i.isError,modelContent:i.modelContent}));break}case"tool-call-args-text-finish":{if(i.meta.type!=="tool-call")break;const{toolCallId:a,toolName:c}=i.meta,l=s.get(a);if(!l)throw new Error("No controller found for tool call");await l.finishArgsText();let u=!1;const h=Xl(()=>{var g;let d;try{d=Zt.parse(l.argsText)}catch(b){throw new Error(`Function parameter parsing failed. ${JSON.stringify(b.message)}`)}const f=t.execute({toolCallId:a,toolName:c,args:d});return f!==void 0&&(u=!0,(g=t.onExecutionStart)==null||g.call(t,a,c)),f},d=>{var g;if(u&&((g=t.onExecutionEnd)==null||g.call(t,a,c)),d===void 0)return;const f=new ve({artifact:d.artifact,result:d.result,isError:d.isError,messages:d.messages,modelContent:d.modelContent});l.setResponse(f),o.enqueue({type:"result",path:i.path,...f})},d=>{var g;u&&((g=t.onExecutionEnd)==null||g.call(t,a,c));const f=new ve({result:String(d),isError:!0});l.setResponse(f),o.enqueue({type:"result",path:i.path,...f})});h&&e.set(a,h);break}case"part-finish":{if(i.meta.type!=="tool-call")break;const{toolCallId:a}=i.meta,c=e.get(a);c?c.then(()=>{e.delete(a),s.delete(a),o.enqueue(i)}):o.enqueue(i)}}},async flush(){await Promise.all(e.values())}});return r.pipeThrough(new qn).pipeThrough(n)})}};const au=t=>typeof t=="object"&&t!==null&&"~standard"in t&&t["~standard"].version===1;function cu(t,e,s,r){const n=t==null?void 0:t[s.toolName];return n!=null&&n.execute?(async o=>{if(e.aborted)return new ve({result:"Tool execution was cancelled.",isError:!0});let a=o;if(au(n.parameters)){let u=n.parameters["~standard"].validate(s.args);u instanceof Promise&&(u=await u),u.issues&&(a=n.experimental_onSchemaValidationError??(()=>{throw new Error(`Function parameter validation failed. ${JSON.stringify(u.issues)}`)}))}const c=new Promise(u=>{const h=()=>{queueMicrotask(()=>{queueMicrotask(()=>{u(new ve({result:"Tool execution was cancelled.",isError:!0}))})})};e.aborted?h():e.addEventListener("abort",h,{once:!0})}),l=(async()=>{const u=await a(s.args,{toolCallId:s.toolCallId,abortSignal:e,human:d=>r(s.toolCallId,d)}),h=ve.toResponse(u);if(n.toModelOutput&&!h.isError&&h.modelContent===void 0)try{const d=await n.toModelOutput({toolCallId:s.toolCallId,input:s.args,output:h.result});return new ve({result:h.result,artifact:h.artifact,isError:h.isError,messages:h.messages,modelContent:d})}catch(d){console.warn(`[assistant-stream] tool "${s.toolName}" toModelOutput threw; falling back to default projection.`,d)}return h})();return Promise.race([l,c])})(n.execute):void 0}function lu(t,e,s,r,n){var i,o;(o=(i=t==null?void 0:t[r.toolName])==null?void 0:i.streamCall)==null||o.call(i,s,{toolCallId:r.toolCallId,abortSignal:e,human:a=>n(r.toolCallId,a)})}function uu(t,e,s,r){const n=typeof t=="function"?t:()=>t,i=typeof e=="function"?e:()=>e;return new ou({execute:o=>cu(n(),i(),o,s),streamCall:({reader:o,...a})=>lu(n(),i(),o,a,s),onExecutionStart:r==null?void 0:r.onExecutionStart,onExecutionEnd:r==null?void 0:r.onExecutionEnd})}let du=(t,e=21)=>(s=e)=>{let r="",n=s|0;for(;n-- >0;)r+=t[Math.random()*t.length|0];return r};const Ae=du("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",7),Wn=t=>{const e=_(7),{index:s,children:r}=t;let n;e[0]!==s?(n=re({source:"message",query:{type:"index",index:s},get:c=>c.message().attachment({index:s})}),e[0]=s,e[1]=n):n=e[1];let i;e[2]!==n?(i={attachment:n},e[2]=n,e[3]=i):i=e[3];const o=F(i);let a;return e[4]!==o||e[5]!==r?(a=p.jsx(ue,{value:o,children:r}),e[4]=o,e[5]=r,e[6]=a):a=e[6],a},Qn=t=>{const e=_(7),{index:s,children:r}=t;let n;e[0]!==s?(n=re({source:"composer",query:{type:"index",index:s},get:c=>c.composer().attachment({index:s})}),e[0]=s,e[1]=n):n=e[1];let i;e[2]!==n?(i={attachment:n},e[2]=n,e[3]=i):i=e[3];const o=F(i);let a;return e[4]!==o||e[5]!==r?(a=p.jsx(ue,{value:o,children:r}),e[4]=o,e[5]=r,e[6]=a):a=e[6],a},Yn=t=>{const e=_(10),{index:s,children:r}=t;let n;e[0]!==s?(n=re({source:"thread",query:{type:"index",index:s},get:l=>l.thread().message({index:s})}),e[0]=s,e[1]=n):n=e[1];let i;e[2]!==s?(i=re({source:"message",query:{},get:l=>l.thread().message({index:s}).composer()}),e[2]=s,e[3]=i):i=e[3];let o;e[4]!==n||e[5]!==i?(o={message:n,composer:i},e[4]=n,e[5]=i,e[6]=o):o=e[6];const a=F(o);let c;return e[7]!==a||e[8]!==r?(c=p.jsx(ue,{value:a,children:r}),e[7]=a,e[8]=r,e[9]=c):c=e[9],c},Cs=t=>{const e=_(7),{index:s,children:r}=t;let n;e[0]!==s?(n=re({source:"message",query:{type:"index",index:s},get:c=>c.message().part({index:s})}),e[0]=s,e[1]=n):n=e[1];let i;e[2]!==n?(i={part:n},e[2]=n,e[3]=i):i=e[3];const o=F(i);let a;return e[4]!==o||e[5]!==r?(a=p.jsx(ue,{value:o,children:r}),e[4]=o,e[5]=r,e[6]=a):a=e[6],a},hu=t=>{const e=_(7),{text:s,isRunning:r}=t;let n;e[0]!==r?(n=r?{type:"running"}:{type:"complete"},e[0]=r,e[1]=n):n=e[1];let i;e[2]!==n||e[3]!==s?(i={type:"text",text:s,status:n},e[2]=n,e[3]=s,e[4]=i):i=e[4];const o=i;let a;return e[5]!==o?(a={getState:()=>o,addToolResult:pu,resumeToolCall:gu,respondToToolApproval:mu},e[5]=o,e[6]=a):a=e[6],a},fu=q(hu),Is=t=>{const e=_(8),{text:s,isRunning:r,children:n}=t,i=r===void 0?!1:r;let o;e[0]!==i||e[1]!==s?(o=fu({text:s,isRunning:i}),e[0]=i,e[1]=s,e[2]=o):o=e[2];let a;e[3]!==o?(a={part:o},e[3]=o,e[4]=a):a=e[4];const c=F(a);let l;return e[5]!==c||e[6]!==n?(l=p.jsx(ue,{value:c,children:n}),e[5]=c,e[6]=n,e[7]=l):l=e[7],l};function pu(){throw new Error("Not supported")}function gu(){throw new Error("Not supported")}function mu(){throw new Error("Not supported")}const bu=Object.freeze({type:"complete"}),_u=t=>{var h;const e=_(9),{parts:s,getMessagePart:r}=t,[n,i]=G(!0),o=((h=s[s.length-1])==null?void 0:h.status)??bu;let a;e[0]!==n||e[1]!==s||e[2]!==o?(a={parts:s,collapsed:n,status:o},e[0]=n,e[1]=s,e[2]=o,e[3]=a):a=e[3];const c=a;let l;e[4]!==c?(l=()=>c,e[4]=c,e[5]=l):l=e[5];let u;return e[6]!==r||e[7]!==l?(u={getState:l,setCollapsed:i,part:r},e[6]=r,e[7]=l,e[8]=u):u=e[8],u},yu=q(_u),vu=t=>{const e=_(5),{startIndex:s,endIndex:r,children:n}=t,i=P(Su).slice(s,r+1),o=F(),a=yu({parts:i,getMessagePart:h=>{const{index:d}=h;if(d<0||d>=i.length)throw new Error(`ChainOfThought part index ${d} is out of bounds (0..${i.length-1})`);return o.message().part({index:s+d})}});let c;e[0]!==a?(c={chainOfThought:a},e[0]=a,e[1]=c):c=e[1];const l=F(c);let u;return e[2]!==l||e[3]!==n?(u=p.jsx(ue,{value:l,children:n}),e[2]=l,e[3]=n,e[4]=u):u=e[4],u};function Su(t){return t.message.parts}const Jn=t=>{const e=_(7),{index:s,children:r}=t;let n;e[0]!==s?(n=re({source:"suggestions",query:{index:s},get:c=>c.suggestions().suggestion({index:s})}),e[0]=s,e[1]=n):n=e[1];let i;e[2]!==n?(i={suggestion:n},e[2]=n,e[3]=i):i=e[3];const o=F(i);let a;return e[4]!==o||e[5]!==r?(a=p.jsx(ue,{value:o,children:r}),e[4]=o,e[5]=r,e[6]=a):a=e[6],a},xu=t=>{const e=_(7),{index:s,children:r}=t;let n;e[0]!==s?(n=re({source:"composer",query:{index:s},get:c=>c.composer().queueItem({index:s})}),e[0]=s,e[1]=n):n=e[1];let i;e[2]!==n?(i={queueItem:n},e[2]=n,e[3]=i):i=e[3];const o=F(i);let a;return e[4]!==o||e[5]!==r?(a=p.jsx(ue,{value:o,children:r}),e[4]=o,e[5]=r,e[6]=a):a=e[6],a},Me=Symbol("innerMessage"),Ft=Symbol("innerMessages"),wu=[],Tu=(t,e)=>{Me in t||(t[Me]=e)},Cu=t=>{const e="messages"in t?t.messages:t,s=e[Ft]||e[Me];return s?Array.isArray(s)?s:(e[Ft]=[s],e[Ft]):wu},de=Symbol("skip-update");function Iu(t,e){if(t===void 0&&e===void 0)return!0;if(t===void 0||e===void 0)return!1;for(const s of Object.keys(t)){const r=t[s],n=e[s];if(!Object.is(r,n))return!1}return!0}var Eu=class{constructor(){m(this,"_subscribers",new Set)}subscribe(t){return this._subscribers.add(t),()=>this._subscribers.delete(t)}waitForUpdate(){return new Promise(t=>{const e=this.subscribe(()=>{e(),t()})})}_notifySubscribers(){const t=[];for(const e of this._subscribers)try{e()}catch(s){t.push(s)}if(t.length>0){if(t.length===1)throw t[0];for(const e of t)console.error(e);throw new AggregateError(t)}}},$t=class{constructor(){m(this,"_subscriptions",new Set);m(this,"_connection")}get isConnected(){return!!this._connection}notifySubscribers(t){for(const e of this._subscriptions)e(t)}_updateConnection(){var t;if(this._subscriptions.size>0){if(this._connection)return;this._connection=this._connect()}else(t=this._connection)==null||t.call(this),this._connection=void 0}subscribe(t){return this._subscriptions.add(t),this._updateConnection(),()=>{this._subscriptions.delete(t),this._updateConnection()}}},ce=class extends $t{constructor(e){super();m(this,"binding");m(this,"_previousState");m(this,"getState",()=>(this.isConnected||this._syncState(),this._previousState));this.binding=e;const s=e.getState();if(s===de)throw new Error("Entry not available in the store");this._previousState=s}get path(){return this.binding.path}_syncState(){const e=this.binding.getState();return e===de||Iu(e,this._previousState)?!1:(this._previousState=e,!0)}_connect(){const e=()=>{this._syncState()&&this.notifySubscribers()};return this.binding.subscribe(e)}},Es=class extends $t{constructor(e){super();m(this,"binding");m(this,"_previousStateDirty",!0);m(this,"_previousState");m(this,"getState",()=>{if(!this.isConnected||this._previousStateDirty){const e=this.binding.getState();e!==de&&(this._previousState=e),this._previousStateDirty=!1}if(this._previousState===void 0)throw new Error("Entry not available in the store");return this._previousState});this.binding=e}get path(){return this.binding.path}_connect(){const e=()=>{this._previousStateDirty=!0,this.notifySubscribers()};return this.binding.subscribe(e)}},St=class extends $t{constructor(e){super();m(this,"binding");this.binding=e}get path(){return this.binding.path}getState(){return this.binding.getState()}outerSubscribe(e){return this.binding.subscribe(e)}_connect(){const e=()=>{this.notifySubscribers()};let s=this.binding.getState(),r=s==null?void 0:s.subscribe(e);const n=()=>{const o=this.binding.getState();o!==s&&(s=o,r==null||r(),r=o==null?void 0:o.subscribe(e),e())},i=this.outerSubscribe(n);return()=>{i==null||i(),r==null||r()}}},Xn=class extends $t{constructor(e){super();m(this,"config");this.config=e}getState(){return this.config.binding.getState()}outerSubscribe(e){return this.config.binding.subscribe(e)}_connect(){const e=o=>{this.notifySubscribers(o)};let s=this.config.binding.getState(),r=s==null?void 0:s.unstable_on(this.config.event,e);const n=()=>{const o=this.config.binding.getState();o!==s&&(s=o,r==null||r(),r=o==null?void 0:o.unstable_on(this.config.event,e))},i=this.outerSubscribe(n);return()=>{i==null||i(),r==null||r()}}},Zn=class{constructor(t){m(this,"_core");this._core=t,this.__internal_bindMethods()}get path(){return this._core.path}__internal_bindMethods(){this.getState=this.getState.bind(this),this.remove=this.remove.bind(this),this.subscribe=this.subscribe.bind(this)}getState(){return this._core.getState()}subscribe(t){return this._core.subscribe(t)}},ei=class extends Zn{constructor(e,s){super(e);m(this,"_composerApi");this._composerApi=s}remove(){const e=this._composerApi.getState();if(!e)throw new Error("Composer is not available");return e.removeAttachment(this.getState().id)}},Ru=class extends ei{get source(){return"thread-composer"}},Au=class extends ei{get source(){return"edit-composer"}},Mu=class extends Zn{get source(){return"message"}remove(){throw new Error("Message attachments cannot be removed")}};const xt=Object.freeze([]),ti=Object.freeze({}),Pu=t=>Object.freeze({type:"thread",isEditing:(t==null?void 0:t.isEditing)??!1,canCancel:(t==null?void 0:t.canCancel)??!1,canSend:(t==null?void 0:t.canSend)??!1,isEmpty:(t==null?void 0:t.isEmpty)??!0,attachments:(t==null?void 0:t.attachments)??xt,text:(t==null?void 0:t.text)??"",role:(t==null?void 0:t.role)??"user",runConfig:(t==null?void 0:t.runConfig)??ti,attachmentAccept:(t==null?void 0:t.attachmentAccept)??"",dictation:t==null?void 0:t.dictation,quote:t==null?void 0:t.quote,queue:(t==null?void 0:t.queue)??xt,value:(t==null?void 0:t.text)??""}),ku=t=>Object.freeze({type:"edit",isEditing:(t==null?void 0:t.isEditing)??!1,canCancel:(t==null?void 0:t.canCancel)??!1,canSend:(t==null?void 0:t.canSend)??!1,isEmpty:(t==null?void 0:t.isEmpty)??!0,text:(t==null?void 0:t.text)??"",role:(t==null?void 0:t.role)??"user",attachments:(t==null?void 0:t.attachments)??xt,runConfig:(t==null?void 0:t.runConfig)??ti,attachmentAccept:(t==null?void 0:t.attachmentAccept)??"",dictation:t==null?void 0:t.dictation,quote:t==null?void 0:t.quote,queue:(t==null?void 0:t.queue)??xt,parentId:(t==null?void 0:t.parentId)??null,sourceId:(t==null?void 0:t.sourceId)??null,value:(t==null?void 0:t.text)??""});var si=class{constructor(t){m(this,"_core");m(this,"_eventSubscriptionSubjects",new Map);this._core=t}get path(){return this._core.path}__internal_bindMethods(){this.setText=this.setText.bind(this),this.setRunConfig=this.setRunConfig.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.addAttachment=this.addAttachment.bind(this),this.reset=this.reset.bind(this),this.clearAttachments=this.clearAttachments.bind(this),this.send=this.send.bind(this),this.cancel=this.cancel.bind(this),this.steerQueueItem=this.steerQueueItem.bind(this),this.removeQueueItem=this.removeQueueItem.bind(this),this.setRole=this.setRole.bind(this),this.getAttachmentByIndex=this.getAttachmentByIndex.bind(this),this.startDictation=this.startDictation.bind(this),this.stopDictation=this.stopDictation.bind(this),this.setQuote=this.setQuote.bind(this),this.unstable_on=this.unstable_on.bind(this)}setText(t){const e=this._core.getState();if(!e)throw new Error("Composer is not available");e.setText(t)}setRunConfig(t){const e=this._core.getState();if(!e)throw new Error("Composer is not available");e.setRunConfig(t)}addAttachment(t){const e=this._core.getState();if(!e)throw new Error("Composer is not available");return e.addAttachment(t)}reset(){const t=this._core.getState();if(!t)throw new Error("Composer is not available");return t.reset()}clearAttachments(){const t=this._core.getState();if(!t)throw new Error("Composer is not available");return t.clearAttachments()}send(t){const e=this._core.getState();if(!e)throw new Error("Composer is not available");e.send(t)}cancel(){const t=this._core.getState();if(!t)throw new Error("Composer is not available");t.cancel()}steerQueueItem(t){const e=this._core.getState();if(!e)throw new Error("Composer is not available");e.steerQueueItem(t)}removeQueueItem(t){const e=this._core.getState();if(!e)throw new Error("Composer is not available");e.removeQueueItem(t)}setRole(t){const e=this._core.getState();if(!e)throw new Error("Composer is not available");e.setRole(t)}startDictation(){const t=this._core.getState();if(!t)throw new Error("Composer is not available");t.startDictation()}stopDictation(){const t=this._core.getState();if(!t)throw new Error("Composer is not available");t.stopDictation()}setQuote(t){const e=this._core.getState();if(!e)throw new Error("Composer is not available");e.setQuote(t)}subscribe(t){return this._core.subscribe(t)}unstable_on(t,e){let s=this._eventSubscriptionSubjects.get(t);return s||(s=new Xn({event:t,binding:this._core}),this._eventSubscriptionSubjects.set(t,s)),s.subscribe(e)}},$u=class extends si{constructor(e){const s=new Es({path:e.path,getState:()=>Pu(e.getState()),subscribe:r=>e.subscribe(r)});super({path:e.path,getState:()=>e.getState(),subscribe:r=>s.subscribe(r)});m(this,"_getState");this._getState=s.getState.bind(s),this.__internal_bindMethods()}get path(){return this._core.path}get type(){return"thread"}getState(){return this._getState()}getAttachmentByIndex(e){return new Ru(new ce({path:{...this.path,attachmentSource:"thread-composer",attachmentSelector:{type:"index",index:e},ref:`${this.path.ref}.attachments[${e}]`},getState:()=>{const s=this.getState().attachments[e];return s?{...s,source:"thread-composer"}:de},subscribe:s=>this._core.subscribe(s)}),this._core)}},Du=class extends si{constructor(e,s){const r=new Es({path:e.path,getState:()=>ku(e.getState()),subscribe:n=>e.subscribe(n)});super({path:e.path,getState:()=>e.getState(),subscribe:n=>r.subscribe(n)});m(this,"_beginEdit");m(this,"_getState");this._beginEdit=s,this._getState=r.getState.bind(r),this.__internal_bindMethods()}get path(){return this._core.path}get type(){return"edit"}__internal_bindMethods(){super.__internal_bindMethods(),this.beginEdit=this.beginEdit.bind(this)}getState(){return this._getState()}beginEdit(){this._beginEdit()}getAttachmentByIndex(e){return new Au(new ce({path:{...this.path,attachmentSource:"edit-composer",attachmentSelector:{type:"index",index:e},ref:`${this.path.ref}.attachments[${e}]`},getState:()=>{const s=this.getState().attachments[e];return s?{...s,source:"edit-composer"}:de},subscribe:s=>this._core.subscribe(s)}),this._core)}};const et=t=>t.content.filter(e=>e.type==="text").map(e=>e.text).join(`
|
|
4
4
|
|