@athenaintel/react 0.10.28 → 0.10.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +692 -864
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +35 -25
- package/dist/index.js +693 -865
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -169,6 +169,10 @@ function isTrustedOrigin({
|
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
const BRIDGE_TIMEOUT_MS = 2e3;
|
|
172
|
+
const TOKEN_REFRESH_BUFFER_MS = 5 * 60 * 1e3;
|
|
173
|
+
const TOKEN_REFRESH_RETRY_BASE_MS = 60 * 1e3;
|
|
174
|
+
const TOKEN_REFRESH_RETRY_MAX_MS = 5 * 60 * 1e3;
|
|
175
|
+
const DEFAULT_TOKEN_REFRESH_MS = 55 * 60 * 1e3;
|
|
172
176
|
const EMPTY_TRUSTED_ORIGINS = [];
|
|
173
177
|
const normalizeOrigin = (value) => {
|
|
174
178
|
try {
|
|
@@ -177,6 +181,20 @@ const normalizeOrigin = (value) => {
|
|
|
177
181
|
return null;
|
|
178
182
|
}
|
|
179
183
|
};
|
|
184
|
+
const getTokenRefreshDelay = (expiresAt, nowMs) => {
|
|
185
|
+
if (typeof expiresAt !== "string") {
|
|
186
|
+
return DEFAULT_TOKEN_REFRESH_MS;
|
|
187
|
+
}
|
|
188
|
+
const expiresAtMs = Date.parse(expiresAt);
|
|
189
|
+
if (!Number.isFinite(expiresAtMs)) {
|
|
190
|
+
return DEFAULT_TOKEN_REFRESH_MS;
|
|
191
|
+
}
|
|
192
|
+
return Math.max(TOKEN_REFRESH_RETRY_BASE_MS, expiresAtMs - nowMs - TOKEN_REFRESH_BUFFER_MS);
|
|
193
|
+
};
|
|
194
|
+
const getAuthRetryDelay = (retryAttempt) => {
|
|
195
|
+
const safeAttempt = Number.isFinite(retryAttempt) ? Math.max(0, Math.floor(retryAttempt)) : 0;
|
|
196
|
+
return Math.min(TOKEN_REFRESH_RETRY_MAX_MS, TOKEN_REFRESH_RETRY_BASE_MS * 2 ** safeAttempt);
|
|
197
|
+
};
|
|
180
198
|
function useParentBridge({
|
|
181
199
|
trustedOrigins = EMPTY_TRUSTED_ORIGINS
|
|
182
200
|
} = {}) {
|
|
@@ -199,8 +217,7 @@ function useParentBridge({
|
|
|
199
217
|
apiUrl: null,
|
|
200
218
|
backendUrl: null,
|
|
201
219
|
appUrl: null,
|
|
202
|
-
|
|
203
|
-
ready: !isInIframe
|
|
220
|
+
ready: false
|
|
204
221
|
});
|
|
205
222
|
const readySignalSent = React.useRef(false);
|
|
206
223
|
const configReceived = React.useRef(false);
|
|
@@ -227,7 +244,6 @@ function useParentBridge({
|
|
|
227
244
|
setState((prev) => ({
|
|
228
245
|
...prev,
|
|
229
246
|
token: event.data.token,
|
|
230
|
-
// If we got a token, we're ready even without config
|
|
231
247
|
ready: true
|
|
232
248
|
}));
|
|
233
249
|
}
|
|
@@ -245,6 +261,105 @@ function useParentBridge({
|
|
|
245
261
|
clearTimeout(timer);
|
|
246
262
|
};
|
|
247
263
|
}, [isInIframe, runtimeTrustedOrigins]);
|
|
264
|
+
React.useEffect(() => {
|
|
265
|
+
if (isInIframe) return;
|
|
266
|
+
if (typeof window === "undefined") return;
|
|
267
|
+
let cancelled = false;
|
|
268
|
+
let requestTimer = null;
|
|
269
|
+
let refreshTimer = null;
|
|
270
|
+
let controller = null;
|
|
271
|
+
let retryAttempt = 0;
|
|
272
|
+
const clearRequestTimer = () => {
|
|
273
|
+
if (requestTimer) {
|
|
274
|
+
clearTimeout(requestTimer);
|
|
275
|
+
requestTimer = null;
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
const clearRefreshTimer = () => {
|
|
279
|
+
if (refreshTimer) {
|
|
280
|
+
clearTimeout(refreshTimer);
|
|
281
|
+
refreshTimer = null;
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
const markReady = () => {
|
|
285
|
+
if (cancelled) return;
|
|
286
|
+
setState((prev) => prev.ready ? prev : { ...prev, ready: true });
|
|
287
|
+
};
|
|
288
|
+
const scheduleRefresh = (expiresAt) => {
|
|
289
|
+
clearRefreshTimer();
|
|
290
|
+
retryAttempt = 0;
|
|
291
|
+
const delay = getTokenRefreshDelay(expiresAt, Date.now());
|
|
292
|
+
refreshTimer = setTimeout(() => {
|
|
293
|
+
void fetchAuth({ markReadyOnFailure: false });
|
|
294
|
+
}, delay);
|
|
295
|
+
};
|
|
296
|
+
const scheduleRetry = () => {
|
|
297
|
+
clearRefreshTimer();
|
|
298
|
+
const delay = getAuthRetryDelay(retryAttempt);
|
|
299
|
+
retryAttempt += 1;
|
|
300
|
+
refreshTimer = setTimeout(() => {
|
|
301
|
+
void fetchAuth({ markReadyOnFailure: false });
|
|
302
|
+
}, delay);
|
|
303
|
+
};
|
|
304
|
+
const fetchAuth = async ({
|
|
305
|
+
markReadyOnFailure
|
|
306
|
+
}) => {
|
|
307
|
+
controller == null ? void 0 : controller.abort();
|
|
308
|
+
controller = new AbortController();
|
|
309
|
+
clearRequestTimer();
|
|
310
|
+
requestTimer = setTimeout(() => {
|
|
311
|
+
controller == null ? void 0 : controller.abort();
|
|
312
|
+
if (markReadyOnFailure) {
|
|
313
|
+
markReady();
|
|
314
|
+
}
|
|
315
|
+
}, BRIDGE_TIMEOUT_MS);
|
|
316
|
+
try {
|
|
317
|
+
const resp = await fetch("/_athena/auth", {
|
|
318
|
+
credentials: "include",
|
|
319
|
+
headers: { Accept: "application/json" },
|
|
320
|
+
signal: controller.signal
|
|
321
|
+
});
|
|
322
|
+
if (cancelled) return;
|
|
323
|
+
if (!resp.ok) {
|
|
324
|
+
if (resp.status === 404) {
|
|
325
|
+
markReady();
|
|
326
|
+
} else if (markReadyOnFailure) {
|
|
327
|
+
markReady();
|
|
328
|
+
scheduleRetry();
|
|
329
|
+
} else {
|
|
330
|
+
scheduleRetry();
|
|
331
|
+
}
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
const data = await resp.json();
|
|
335
|
+
if (cancelled) return;
|
|
336
|
+
setState({
|
|
337
|
+
token: typeof data.token === "string" ? data.token : null,
|
|
338
|
+
apiUrl: typeof data.apiUrl === "string" ? data.apiUrl : null,
|
|
339
|
+
backendUrl: typeof data.backendUrl === "string" ? data.backendUrl : null,
|
|
340
|
+
appUrl: typeof data.appUrl === "string" ? data.appUrl : null,
|
|
341
|
+
ready: true
|
|
342
|
+
});
|
|
343
|
+
scheduleRefresh(data.expires_at);
|
|
344
|
+
} catch {
|
|
345
|
+
if (markReadyOnFailure) {
|
|
346
|
+
markReady();
|
|
347
|
+
}
|
|
348
|
+
if (!cancelled) {
|
|
349
|
+
scheduleRetry();
|
|
350
|
+
}
|
|
351
|
+
} finally {
|
|
352
|
+
clearRequestTimer();
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
void fetchAuth({ markReadyOnFailure: true });
|
|
356
|
+
return () => {
|
|
357
|
+
cancelled = true;
|
|
358
|
+
controller == null ? void 0 : controller.abort();
|
|
359
|
+
clearRequestTimer();
|
|
360
|
+
clearRefreshTimer();
|
|
361
|
+
};
|
|
362
|
+
}, [isInIframe]);
|
|
248
363
|
return state;
|
|
249
364
|
}
|
|
250
365
|
function useParentAuth() {
|
|
@@ -3933,7 +4048,7 @@ const twMerge = /* @__PURE__ */ createTailwindMerge(getDefaultConfig);
|
|
|
3933
4048
|
function cn(...inputs) {
|
|
3934
4049
|
return twMerge(clsx(inputs));
|
|
3935
4050
|
}
|
|
3936
|
-
function isRecord(value) {
|
|
4051
|
+
function isRecord$1(value) {
|
|
3937
4052
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3938
4053
|
}
|
|
3939
4054
|
function $constructor(name, initializer2, params) {
|
|
@@ -8317,10 +8432,10 @@ const autoCloseInFlightSubgraphMessages = (msgs) => {
|
|
|
8317
8432
|
const beginIds = /* @__PURE__ */ new Set();
|
|
8318
8433
|
const endIds = /* @__PURE__ */ new Set();
|
|
8319
8434
|
for (const message of msgs) {
|
|
8320
|
-
if (!isRecord(message)) continue;
|
|
8435
|
+
if (!isRecord$1(message)) continue;
|
|
8321
8436
|
if (message.type === "ai" && Array.isArray(message.tool_calls)) {
|
|
8322
8437
|
for (const toolCall of message.tool_calls) {
|
|
8323
|
-
if (!isRecord(toolCall)) continue;
|
|
8438
|
+
if (!isRecord$1(toolCall)) continue;
|
|
8324
8439
|
const id = toolCall.id;
|
|
8325
8440
|
if (typeof id === "string") beginIds.add(id);
|
|
8326
8441
|
}
|
|
@@ -8386,7 +8501,7 @@ const contentToParts = (content) => {
|
|
|
8386
8501
|
const getNumberAtPath = (value, path) => {
|
|
8387
8502
|
let current = value;
|
|
8388
8503
|
for (const segment of path) {
|
|
8389
|
-
if (!isRecord(current)) {
|
|
8504
|
+
if (!isRecord$1(current)) {
|
|
8390
8505
|
return void 0;
|
|
8391
8506
|
}
|
|
8392
8507
|
current = current[segment];
|
|
@@ -8407,7 +8522,7 @@ const buildCustomMetadata = ({
|
|
|
8407
8522
|
}) => {
|
|
8408
8523
|
const customMetadata = additionalKwargs ? { ...additionalKwargs } : {};
|
|
8409
8524
|
const reasoningTokens = extractReasoningTokens({ usageMetadata, responseMetadata });
|
|
8410
|
-
const existingAthenaMetadata = isRecord(customMetadata._athena) ? customMetadata._athena : void 0;
|
|
8525
|
+
const existingAthenaMetadata = isRecord$1(customMetadata._athena) ? customMetadata._athena : void 0;
|
|
8411
8526
|
const athenaMetadata = {
|
|
8412
8527
|
...existingAthenaMetadata ?? {}
|
|
8413
8528
|
};
|
|
@@ -8426,9 +8541,9 @@ const buildCustomMetadata = ({
|
|
|
8426
8541
|
return Object.keys(customMetadata).length > 0 ? customMetadata : void 0;
|
|
8427
8542
|
};
|
|
8428
8543
|
const getSubgraphMessages = (artifact) => {
|
|
8429
|
-
if (!isRecord(artifact)) return void 0;
|
|
8544
|
+
if (!isRecord$1(artifact)) return void 0;
|
|
8430
8545
|
const subgraphState = artifact.subgraph_state;
|
|
8431
|
-
if (!isRecord(subgraphState)) return void 0;
|
|
8546
|
+
if (!isRecord$1(subgraphState)) return void 0;
|
|
8432
8547
|
const messages = subgraphState.messages;
|
|
8433
8548
|
return Array.isArray(messages) && messages.length > 0 ? messages : void 0;
|
|
8434
8549
|
};
|
|
@@ -9084,7 +9199,7 @@ const useAthenaRuntime = (config2) => {
|
|
|
9084
9199
|
if (status.isRunning) {
|
|
9085
9200
|
try {
|
|
9086
9201
|
const lastMessageId = ((_b = runtime.thread.getState().messages.at(-1)) == null ? void 0 : _b.id) ?? null;
|
|
9087
|
-
runtime.thread.
|
|
9202
|
+
runtime.thread.resumeRun({ parentId: lastMessageId });
|
|
9088
9203
|
} catch (resumeErr) {
|
|
9089
9204
|
if (IS_DEV) {
|
|
9090
9205
|
console.error("[AthenaSDK] Failed to resume running thread:", resumeErr);
|
|
@@ -9137,12 +9252,12 @@ function useComposedRefs(...refs) {
|
|
|
9137
9252
|
return React__namespace.useCallback(composeRefs(...refs), refs);
|
|
9138
9253
|
}
|
|
9139
9254
|
// @__NO_SIDE_EFFECTS__
|
|
9140
|
-
function createSlot
|
|
9141
|
-
const SlotClone = /* @__PURE__ */ createSlotClone
|
|
9255
|
+
function createSlot(ownerName) {
|
|
9256
|
+
const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
|
|
9142
9257
|
const Slot2 = React__namespace.forwardRef((props, forwardedRef) => {
|
|
9143
9258
|
const { children, ...slotProps } = props;
|
|
9144
9259
|
const childrenArray = React__namespace.Children.toArray(children);
|
|
9145
|
-
const slottable = childrenArray.find(isSlottable
|
|
9260
|
+
const slottable = childrenArray.find(isSlottable);
|
|
9146
9261
|
if (slottable) {
|
|
9147
9262
|
const newElement = slottable.props.children;
|
|
9148
9263
|
const newChildren = childrenArray.map((child) => {
|
|
@@ -9160,13 +9275,14 @@ function createSlot$7(ownerName) {
|
|
|
9160
9275
|
Slot2.displayName = `${ownerName}.Slot`;
|
|
9161
9276
|
return Slot2;
|
|
9162
9277
|
}
|
|
9278
|
+
var Slot = /* @__PURE__ */ createSlot("Slot");
|
|
9163
9279
|
// @__NO_SIDE_EFFECTS__
|
|
9164
|
-
function createSlotClone
|
|
9280
|
+
function createSlotClone(ownerName) {
|
|
9165
9281
|
const SlotClone = React__namespace.forwardRef((props, forwardedRef) => {
|
|
9166
9282
|
const { children, ...slotProps } = props;
|
|
9167
9283
|
if (React__namespace.isValidElement(children)) {
|
|
9168
|
-
const childrenRef = getElementRef$
|
|
9169
|
-
const props2 = mergeProps
|
|
9284
|
+
const childrenRef = getElementRef$1(children);
|
|
9285
|
+
const props2 = mergeProps(slotProps, children.props);
|
|
9170
9286
|
if (children.type !== React__namespace.Fragment) {
|
|
9171
9287
|
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
9172
9288
|
}
|
|
@@ -9177,11 +9293,21 @@ function createSlotClone$7(ownerName) {
|
|
|
9177
9293
|
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
9178
9294
|
return SlotClone;
|
|
9179
9295
|
}
|
|
9180
|
-
var SLOTTABLE_IDENTIFIER
|
|
9181
|
-
|
|
9182
|
-
|
|
9296
|
+
var SLOTTABLE_IDENTIFIER = Symbol("radix.slottable");
|
|
9297
|
+
// @__NO_SIDE_EFFECTS__
|
|
9298
|
+
function createSlottable(ownerName) {
|
|
9299
|
+
const Slottable2 = ({ children }) => {
|
|
9300
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
|
|
9301
|
+
};
|
|
9302
|
+
Slottable2.displayName = `${ownerName}.Slottable`;
|
|
9303
|
+
Slottable2.__radixId = SLOTTABLE_IDENTIFIER;
|
|
9304
|
+
return Slottable2;
|
|
9305
|
+
}
|
|
9306
|
+
var Slottable$1 = /* @__PURE__ */ createSlottable("Slottable");
|
|
9307
|
+
function isSlottable(child) {
|
|
9308
|
+
return React__namespace.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
|
|
9183
9309
|
}
|
|
9184
|
-
function mergeProps
|
|
9310
|
+
function mergeProps(slotProps, childProps) {
|
|
9185
9311
|
const overrideProps = { ...childProps };
|
|
9186
9312
|
for (const propName in childProps) {
|
|
9187
9313
|
const slotPropValue = slotProps[propName];
|
|
@@ -9205,7 +9331,7 @@ function mergeProps$7(slotProps, childProps) {
|
|
|
9205
9331
|
}
|
|
9206
9332
|
return { ...slotProps, ...overrideProps };
|
|
9207
9333
|
}
|
|
9208
|
-
function getElementRef$
|
|
9334
|
+
function getElementRef$1(element) {
|
|
9209
9335
|
var _a2, _b;
|
|
9210
9336
|
let getter = (_a2 = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a2.get;
|
|
9211
9337
|
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
@@ -9239,7 +9365,7 @@ var NODES$6 = [
|
|
|
9239
9365
|
"ul"
|
|
9240
9366
|
];
|
|
9241
9367
|
var Primitive$6 = NODES$6.reduce((primitive, node) => {
|
|
9242
|
-
const Slot2 = /* @__PURE__ */ createSlot
|
|
9368
|
+
const Slot2 = /* @__PURE__ */ createSlot(`Primitive.${node}`);
|
|
9243
9369
|
const Node4 = React__namespace.forwardRef((props, forwardedRef) => {
|
|
9244
9370
|
const { asChild, ...primitiveProps } = props;
|
|
9245
9371
|
const Comp = asChild ? Slot2 : node;
|
|
@@ -9414,89 +9540,6 @@ function composeContextScopes$2(...scopes) {
|
|
|
9414
9540
|
createScope.scopeName = baseScope.scopeName;
|
|
9415
9541
|
return createScope;
|
|
9416
9542
|
}
|
|
9417
|
-
// @__NO_SIDE_EFFECTS__
|
|
9418
|
-
function createSlot$6(ownerName) {
|
|
9419
|
-
const SlotClone = /* @__PURE__ */ createSlotClone$6(ownerName);
|
|
9420
|
-
const Slot2 = React__namespace.forwardRef((props, forwardedRef) => {
|
|
9421
|
-
const { children, ...slotProps } = props;
|
|
9422
|
-
const childrenArray = React__namespace.Children.toArray(children);
|
|
9423
|
-
const slottable = childrenArray.find(isSlottable$6);
|
|
9424
|
-
if (slottable) {
|
|
9425
|
-
const newElement = slottable.props.children;
|
|
9426
|
-
const newChildren = childrenArray.map((child) => {
|
|
9427
|
-
if (child === slottable) {
|
|
9428
|
-
if (React__namespace.Children.count(newElement) > 1) return React__namespace.Children.only(null);
|
|
9429
|
-
return React__namespace.isValidElement(newElement) ? newElement.props.children : null;
|
|
9430
|
-
} else {
|
|
9431
|
-
return child;
|
|
9432
|
-
}
|
|
9433
|
-
});
|
|
9434
|
-
return /* @__PURE__ */ jsxRuntime.jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React__namespace.isValidElement(newElement) ? React__namespace.cloneElement(newElement, void 0, newChildren) : null });
|
|
9435
|
-
}
|
|
9436
|
-
return /* @__PURE__ */ jsxRuntime.jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
9437
|
-
});
|
|
9438
|
-
Slot2.displayName = `${ownerName}.Slot`;
|
|
9439
|
-
return Slot2;
|
|
9440
|
-
}
|
|
9441
|
-
// @__NO_SIDE_EFFECTS__
|
|
9442
|
-
function createSlotClone$6(ownerName) {
|
|
9443
|
-
const SlotClone = React__namespace.forwardRef((props, forwardedRef) => {
|
|
9444
|
-
const { children, ...slotProps } = props;
|
|
9445
|
-
if (React__namespace.isValidElement(children)) {
|
|
9446
|
-
const childrenRef = getElementRef$7(children);
|
|
9447
|
-
const props2 = mergeProps$6(slotProps, children.props);
|
|
9448
|
-
if (children.type !== React__namespace.Fragment) {
|
|
9449
|
-
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
9450
|
-
}
|
|
9451
|
-
return React__namespace.cloneElement(children, props2);
|
|
9452
|
-
}
|
|
9453
|
-
return React__namespace.Children.count(children) > 1 ? React__namespace.Children.only(null) : null;
|
|
9454
|
-
});
|
|
9455
|
-
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
9456
|
-
return SlotClone;
|
|
9457
|
-
}
|
|
9458
|
-
var SLOTTABLE_IDENTIFIER$6 = Symbol("radix.slottable");
|
|
9459
|
-
function isSlottable$6(child) {
|
|
9460
|
-
return React__namespace.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER$6;
|
|
9461
|
-
}
|
|
9462
|
-
function mergeProps$6(slotProps, childProps) {
|
|
9463
|
-
const overrideProps = { ...childProps };
|
|
9464
|
-
for (const propName in childProps) {
|
|
9465
|
-
const slotPropValue = slotProps[propName];
|
|
9466
|
-
const childPropValue = childProps[propName];
|
|
9467
|
-
const isHandler = /^on[A-Z]/.test(propName);
|
|
9468
|
-
if (isHandler) {
|
|
9469
|
-
if (slotPropValue && childPropValue) {
|
|
9470
|
-
overrideProps[propName] = (...args) => {
|
|
9471
|
-
const result = childPropValue(...args);
|
|
9472
|
-
slotPropValue(...args);
|
|
9473
|
-
return result;
|
|
9474
|
-
};
|
|
9475
|
-
} else if (slotPropValue) {
|
|
9476
|
-
overrideProps[propName] = slotPropValue;
|
|
9477
|
-
}
|
|
9478
|
-
} else if (propName === "style") {
|
|
9479
|
-
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
9480
|
-
} else if (propName === "className") {
|
|
9481
|
-
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
9482
|
-
}
|
|
9483
|
-
}
|
|
9484
|
-
return { ...slotProps, ...overrideProps };
|
|
9485
|
-
}
|
|
9486
|
-
function getElementRef$7(element) {
|
|
9487
|
-
var _a2, _b;
|
|
9488
|
-
let getter = (_a2 = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a2.get;
|
|
9489
|
-
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
9490
|
-
if (mayWarn) {
|
|
9491
|
-
return element.ref;
|
|
9492
|
-
}
|
|
9493
|
-
getter = (_b = Object.getOwnPropertyDescriptor(element, "ref")) == null ? void 0 : _b.get;
|
|
9494
|
-
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
9495
|
-
if (mayWarn) {
|
|
9496
|
-
return element.props.ref;
|
|
9497
|
-
}
|
|
9498
|
-
return element.props.ref || element.ref;
|
|
9499
|
-
}
|
|
9500
9543
|
var NODES$5 = [
|
|
9501
9544
|
"a",
|
|
9502
9545
|
"button",
|
|
@@ -9517,7 +9560,7 @@ var NODES$5 = [
|
|
|
9517
9560
|
"ul"
|
|
9518
9561
|
];
|
|
9519
9562
|
var Primitive$5 = NODES$5.reduce((primitive, node) => {
|
|
9520
|
-
const Slot2 = /* @__PURE__ */ createSlot
|
|
9563
|
+
const Slot2 = /* @__PURE__ */ createSlot(`Primitive.${node}`);
|
|
9521
9564
|
const Node4 = React__namespace.forwardRef((props, forwardedRef) => {
|
|
9522
9565
|
const { asChild, ...primitiveProps } = props;
|
|
9523
9566
|
const Comp = asChild ? Slot2 : node;
|
|
@@ -9539,7 +9582,7 @@ var Presence = (props) => {
|
|
|
9539
9582
|
const { present, children } = props;
|
|
9540
9583
|
const presence = usePresence(present);
|
|
9541
9584
|
const child = typeof children === "function" ? children({ present: presence.isPresent }) : React__namespace.Children.only(children);
|
|
9542
|
-
const ref = useComposedRefs(presence.ref, getElementRef
|
|
9585
|
+
const ref = useComposedRefs(presence.ref, getElementRef(child));
|
|
9543
9586
|
const forceMount = typeof children === "function";
|
|
9544
9587
|
return forceMount || presence.isPresent ? React__namespace.cloneElement(child, { ref }) : null;
|
|
9545
9588
|
};
|
|
@@ -9638,7 +9681,7 @@ function usePresence(present) {
|
|
|
9638
9681
|
function getAnimationName(styles) {
|
|
9639
9682
|
return (styles == null ? void 0 : styles.animationName) || "none";
|
|
9640
9683
|
}
|
|
9641
|
-
function getElementRef
|
|
9684
|
+
function getElementRef(element) {
|
|
9642
9685
|
var _a2, _b;
|
|
9643
9686
|
let getter = (_a2 = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a2.get;
|
|
9644
9687
|
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
@@ -9791,89 +9834,6 @@ function getState(open) {
|
|
|
9791
9834
|
return open ? "open" : "closed";
|
|
9792
9835
|
}
|
|
9793
9836
|
var Root$1 = Collapsible$1;
|
|
9794
|
-
// @__NO_SIDE_EFFECTS__
|
|
9795
|
-
function createSlot$5(ownerName) {
|
|
9796
|
-
const SlotClone = /* @__PURE__ */ createSlotClone$5(ownerName);
|
|
9797
|
-
const Slot2 = React__namespace.forwardRef((props, forwardedRef) => {
|
|
9798
|
-
const { children, ...slotProps } = props;
|
|
9799
|
-
const childrenArray = React__namespace.Children.toArray(children);
|
|
9800
|
-
const slottable = childrenArray.find(isSlottable$5);
|
|
9801
|
-
if (slottable) {
|
|
9802
|
-
const newElement = slottable.props.children;
|
|
9803
|
-
const newChildren = childrenArray.map((child) => {
|
|
9804
|
-
if (child === slottable) {
|
|
9805
|
-
if (React__namespace.Children.count(newElement) > 1) return React__namespace.Children.only(null);
|
|
9806
|
-
return React__namespace.isValidElement(newElement) ? newElement.props.children : null;
|
|
9807
|
-
} else {
|
|
9808
|
-
return child;
|
|
9809
|
-
}
|
|
9810
|
-
});
|
|
9811
|
-
return /* @__PURE__ */ jsxRuntime.jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React__namespace.isValidElement(newElement) ? React__namespace.cloneElement(newElement, void 0, newChildren) : null });
|
|
9812
|
-
}
|
|
9813
|
-
return /* @__PURE__ */ jsxRuntime.jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
9814
|
-
});
|
|
9815
|
-
Slot2.displayName = `${ownerName}.Slot`;
|
|
9816
|
-
return Slot2;
|
|
9817
|
-
}
|
|
9818
|
-
// @__NO_SIDE_EFFECTS__
|
|
9819
|
-
function createSlotClone$5(ownerName) {
|
|
9820
|
-
const SlotClone = React__namespace.forwardRef((props, forwardedRef) => {
|
|
9821
|
-
const { children, ...slotProps } = props;
|
|
9822
|
-
if (React__namespace.isValidElement(children)) {
|
|
9823
|
-
const childrenRef = getElementRef$5(children);
|
|
9824
|
-
const props2 = mergeProps$5(slotProps, children.props);
|
|
9825
|
-
if (children.type !== React__namespace.Fragment) {
|
|
9826
|
-
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
9827
|
-
}
|
|
9828
|
-
return React__namespace.cloneElement(children, props2);
|
|
9829
|
-
}
|
|
9830
|
-
return React__namespace.Children.count(children) > 1 ? React__namespace.Children.only(null) : null;
|
|
9831
|
-
});
|
|
9832
|
-
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
9833
|
-
return SlotClone;
|
|
9834
|
-
}
|
|
9835
|
-
var SLOTTABLE_IDENTIFIER$5 = Symbol("radix.slottable");
|
|
9836
|
-
function isSlottable$5(child) {
|
|
9837
|
-
return React__namespace.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER$5;
|
|
9838
|
-
}
|
|
9839
|
-
function mergeProps$5(slotProps, childProps) {
|
|
9840
|
-
const overrideProps = { ...childProps };
|
|
9841
|
-
for (const propName in childProps) {
|
|
9842
|
-
const slotPropValue = slotProps[propName];
|
|
9843
|
-
const childPropValue = childProps[propName];
|
|
9844
|
-
const isHandler = /^on[A-Z]/.test(propName);
|
|
9845
|
-
if (isHandler) {
|
|
9846
|
-
if (slotPropValue && childPropValue) {
|
|
9847
|
-
overrideProps[propName] = (...args) => {
|
|
9848
|
-
const result = childPropValue(...args);
|
|
9849
|
-
slotPropValue(...args);
|
|
9850
|
-
return result;
|
|
9851
|
-
};
|
|
9852
|
-
} else if (slotPropValue) {
|
|
9853
|
-
overrideProps[propName] = slotPropValue;
|
|
9854
|
-
}
|
|
9855
|
-
} else if (propName === "style") {
|
|
9856
|
-
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
9857
|
-
} else if (propName === "className") {
|
|
9858
|
-
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
9859
|
-
}
|
|
9860
|
-
}
|
|
9861
|
-
return { ...slotProps, ...overrideProps };
|
|
9862
|
-
}
|
|
9863
|
-
function getElementRef$5(element) {
|
|
9864
|
-
var _a2, _b;
|
|
9865
|
-
let getter = (_a2 = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a2.get;
|
|
9866
|
-
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
9867
|
-
if (mayWarn) {
|
|
9868
|
-
return element.ref;
|
|
9869
|
-
}
|
|
9870
|
-
getter = (_b = Object.getOwnPropertyDescriptor(element, "ref")) == null ? void 0 : _b.get;
|
|
9871
|
-
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
9872
|
-
if (mayWarn) {
|
|
9873
|
-
return element.props.ref;
|
|
9874
|
-
}
|
|
9875
|
-
return element.props.ref || element.ref;
|
|
9876
|
-
}
|
|
9877
9837
|
var NODES$4 = [
|
|
9878
9838
|
"a",
|
|
9879
9839
|
"button",
|
|
@@ -9894,7 +9854,7 @@ var NODES$4 = [
|
|
|
9894
9854
|
"ul"
|
|
9895
9855
|
];
|
|
9896
9856
|
var Primitive$4 = NODES$4.reduce((primitive, node) => {
|
|
9897
|
-
const Slot2 = /* @__PURE__ */ createSlot
|
|
9857
|
+
const Slot2 = /* @__PURE__ */ createSlot(`Primitive.${node}`);
|
|
9898
9858
|
const Node4 = React__namespace.forwardRef((props, forwardedRef) => {
|
|
9899
9859
|
const { asChild, ...primitiveProps } = props;
|
|
9900
9860
|
const Comp = asChild ? Slot2 : node;
|
|
@@ -10132,89 +10092,6 @@ function handleAndDispatchCustomEvent(name, handler, detail, { discrete }) {
|
|
|
10132
10092
|
target.dispatchEvent(event);
|
|
10133
10093
|
}
|
|
10134
10094
|
}
|
|
10135
|
-
// @__NO_SIDE_EFFECTS__
|
|
10136
|
-
function createSlot$4(ownerName) {
|
|
10137
|
-
const SlotClone = /* @__PURE__ */ createSlotClone$4(ownerName);
|
|
10138
|
-
const Slot2 = React__namespace.forwardRef((props, forwardedRef) => {
|
|
10139
|
-
const { children, ...slotProps } = props;
|
|
10140
|
-
const childrenArray = React__namespace.Children.toArray(children);
|
|
10141
|
-
const slottable = childrenArray.find(isSlottable$4);
|
|
10142
|
-
if (slottable) {
|
|
10143
|
-
const newElement = slottable.props.children;
|
|
10144
|
-
const newChildren = childrenArray.map((child) => {
|
|
10145
|
-
if (child === slottable) {
|
|
10146
|
-
if (React__namespace.Children.count(newElement) > 1) return React__namespace.Children.only(null);
|
|
10147
|
-
return React__namespace.isValidElement(newElement) ? newElement.props.children : null;
|
|
10148
|
-
} else {
|
|
10149
|
-
return child;
|
|
10150
|
-
}
|
|
10151
|
-
});
|
|
10152
|
-
return /* @__PURE__ */ jsxRuntime.jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React__namespace.isValidElement(newElement) ? React__namespace.cloneElement(newElement, void 0, newChildren) : null });
|
|
10153
|
-
}
|
|
10154
|
-
return /* @__PURE__ */ jsxRuntime.jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
10155
|
-
});
|
|
10156
|
-
Slot2.displayName = `${ownerName}.Slot`;
|
|
10157
|
-
return Slot2;
|
|
10158
|
-
}
|
|
10159
|
-
// @__NO_SIDE_EFFECTS__
|
|
10160
|
-
function createSlotClone$4(ownerName) {
|
|
10161
|
-
const SlotClone = React__namespace.forwardRef((props, forwardedRef) => {
|
|
10162
|
-
const { children, ...slotProps } = props;
|
|
10163
|
-
if (React__namespace.isValidElement(children)) {
|
|
10164
|
-
const childrenRef = getElementRef$4(children);
|
|
10165
|
-
const props2 = mergeProps$4(slotProps, children.props);
|
|
10166
|
-
if (children.type !== React__namespace.Fragment) {
|
|
10167
|
-
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
10168
|
-
}
|
|
10169
|
-
return React__namespace.cloneElement(children, props2);
|
|
10170
|
-
}
|
|
10171
|
-
return React__namespace.Children.count(children) > 1 ? React__namespace.Children.only(null) : null;
|
|
10172
|
-
});
|
|
10173
|
-
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
10174
|
-
return SlotClone;
|
|
10175
|
-
}
|
|
10176
|
-
var SLOTTABLE_IDENTIFIER$4 = Symbol("radix.slottable");
|
|
10177
|
-
function isSlottable$4(child) {
|
|
10178
|
-
return React__namespace.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER$4;
|
|
10179
|
-
}
|
|
10180
|
-
function mergeProps$4(slotProps, childProps) {
|
|
10181
|
-
const overrideProps = { ...childProps };
|
|
10182
|
-
for (const propName in childProps) {
|
|
10183
|
-
const slotPropValue = slotProps[propName];
|
|
10184
|
-
const childPropValue = childProps[propName];
|
|
10185
|
-
const isHandler = /^on[A-Z]/.test(propName);
|
|
10186
|
-
if (isHandler) {
|
|
10187
|
-
if (slotPropValue && childPropValue) {
|
|
10188
|
-
overrideProps[propName] = (...args) => {
|
|
10189
|
-
const result = childPropValue(...args);
|
|
10190
|
-
slotPropValue(...args);
|
|
10191
|
-
return result;
|
|
10192
|
-
};
|
|
10193
|
-
} else if (slotPropValue) {
|
|
10194
|
-
overrideProps[propName] = slotPropValue;
|
|
10195
|
-
}
|
|
10196
|
-
} else if (propName === "style") {
|
|
10197
|
-
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
10198
|
-
} else if (propName === "className") {
|
|
10199
|
-
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
10200
|
-
}
|
|
10201
|
-
}
|
|
10202
|
-
return { ...slotProps, ...overrideProps };
|
|
10203
|
-
}
|
|
10204
|
-
function getElementRef$4(element) {
|
|
10205
|
-
var _a2, _b;
|
|
10206
|
-
let getter = (_a2 = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a2.get;
|
|
10207
|
-
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
10208
|
-
if (mayWarn) {
|
|
10209
|
-
return element.ref;
|
|
10210
|
-
}
|
|
10211
|
-
getter = (_b = Object.getOwnPropertyDescriptor(element, "ref")) == null ? void 0 : _b.get;
|
|
10212
|
-
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
10213
|
-
if (mayWarn) {
|
|
10214
|
-
return element.props.ref;
|
|
10215
|
-
}
|
|
10216
|
-
return element.props.ref || element.ref;
|
|
10217
|
-
}
|
|
10218
10095
|
var NODES$3 = [
|
|
10219
10096
|
"a",
|
|
10220
10097
|
"button",
|
|
@@ -10235,7 +10112,7 @@ var NODES$3 = [
|
|
|
10235
10112
|
"ul"
|
|
10236
10113
|
];
|
|
10237
10114
|
var Primitive$3 = NODES$3.reduce((primitive, node) => {
|
|
10238
|
-
const Slot2 = /* @__PURE__ */ createSlot
|
|
10115
|
+
const Slot2 = /* @__PURE__ */ createSlot(`Primitive.${node}`);
|
|
10239
10116
|
const Node4 = React__namespace.forwardRef((props, forwardedRef) => {
|
|
10240
10117
|
const { asChild, ...primitiveProps } = props;
|
|
10241
10118
|
const Comp = asChild ? Slot2 : node;
|
|
@@ -10257,100 +10134,6 @@ var Portal$1 = React__namespace.forwardRef((props, forwardedRef) => {
|
|
|
10257
10134
|
return container ? ReactDOM.createPortal(/* @__PURE__ */ jsxRuntime.jsx(Primitive$3.div, { ...portalProps, ref: forwardedRef }), container) : null;
|
|
10258
10135
|
});
|
|
10259
10136
|
Portal$1.displayName = PORTAL_NAME$1;
|
|
10260
|
-
// @__NO_SIDE_EFFECTS__
|
|
10261
|
-
function createSlot$3(ownerName) {
|
|
10262
|
-
const SlotClone = /* @__PURE__ */ createSlotClone$3(ownerName);
|
|
10263
|
-
const Slot2 = React__namespace.forwardRef((props, forwardedRef) => {
|
|
10264
|
-
const { children, ...slotProps } = props;
|
|
10265
|
-
const childrenArray = React__namespace.Children.toArray(children);
|
|
10266
|
-
const slottable = childrenArray.find(isSlottable$3);
|
|
10267
|
-
if (slottable) {
|
|
10268
|
-
const newElement = slottable.props.children;
|
|
10269
|
-
const newChildren = childrenArray.map((child) => {
|
|
10270
|
-
if (child === slottable) {
|
|
10271
|
-
if (React__namespace.Children.count(newElement) > 1) return React__namespace.Children.only(null);
|
|
10272
|
-
return React__namespace.isValidElement(newElement) ? newElement.props.children : null;
|
|
10273
|
-
} else {
|
|
10274
|
-
return child;
|
|
10275
|
-
}
|
|
10276
|
-
});
|
|
10277
|
-
return /* @__PURE__ */ jsxRuntime.jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React__namespace.isValidElement(newElement) ? React__namespace.cloneElement(newElement, void 0, newChildren) : null });
|
|
10278
|
-
}
|
|
10279
|
-
return /* @__PURE__ */ jsxRuntime.jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
10280
|
-
});
|
|
10281
|
-
Slot2.displayName = `${ownerName}.Slot`;
|
|
10282
|
-
return Slot2;
|
|
10283
|
-
}
|
|
10284
|
-
var Slot = /* @__PURE__ */ createSlot$3("Slot");
|
|
10285
|
-
// @__NO_SIDE_EFFECTS__
|
|
10286
|
-
function createSlotClone$3(ownerName) {
|
|
10287
|
-
const SlotClone = React__namespace.forwardRef((props, forwardedRef) => {
|
|
10288
|
-
const { children, ...slotProps } = props;
|
|
10289
|
-
if (React__namespace.isValidElement(children)) {
|
|
10290
|
-
const childrenRef = getElementRef$3(children);
|
|
10291
|
-
const props2 = mergeProps$3(slotProps, children.props);
|
|
10292
|
-
if (children.type !== React__namespace.Fragment) {
|
|
10293
|
-
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
10294
|
-
}
|
|
10295
|
-
return React__namespace.cloneElement(children, props2);
|
|
10296
|
-
}
|
|
10297
|
-
return React__namespace.Children.count(children) > 1 ? React__namespace.Children.only(null) : null;
|
|
10298
|
-
});
|
|
10299
|
-
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
10300
|
-
return SlotClone;
|
|
10301
|
-
}
|
|
10302
|
-
var SLOTTABLE_IDENTIFIER$3 = Symbol("radix.slottable");
|
|
10303
|
-
// @__NO_SIDE_EFFECTS__
|
|
10304
|
-
function createSlottable$1(ownerName) {
|
|
10305
|
-
const Slottable2 = ({ children }) => {
|
|
10306
|
-
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
|
|
10307
|
-
};
|
|
10308
|
-
Slottable2.displayName = `${ownerName}.Slottable`;
|
|
10309
|
-
Slottable2.__radixId = SLOTTABLE_IDENTIFIER$3;
|
|
10310
|
-
return Slottable2;
|
|
10311
|
-
}
|
|
10312
|
-
var Slottable$1 = /* @__PURE__ */ createSlottable$1("Slottable");
|
|
10313
|
-
function isSlottable$3(child) {
|
|
10314
|
-
return React__namespace.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER$3;
|
|
10315
|
-
}
|
|
10316
|
-
function mergeProps$3(slotProps, childProps) {
|
|
10317
|
-
const overrideProps = { ...childProps };
|
|
10318
|
-
for (const propName in childProps) {
|
|
10319
|
-
const slotPropValue = slotProps[propName];
|
|
10320
|
-
const childPropValue = childProps[propName];
|
|
10321
|
-
const isHandler = /^on[A-Z]/.test(propName);
|
|
10322
|
-
if (isHandler) {
|
|
10323
|
-
if (slotPropValue && childPropValue) {
|
|
10324
|
-
overrideProps[propName] = (...args) => {
|
|
10325
|
-
const result = childPropValue(...args);
|
|
10326
|
-
slotPropValue(...args);
|
|
10327
|
-
return result;
|
|
10328
|
-
};
|
|
10329
|
-
} else if (slotPropValue) {
|
|
10330
|
-
overrideProps[propName] = slotPropValue;
|
|
10331
|
-
}
|
|
10332
|
-
} else if (propName === "style") {
|
|
10333
|
-
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
10334
|
-
} else if (propName === "className") {
|
|
10335
|
-
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
10336
|
-
}
|
|
10337
|
-
}
|
|
10338
|
-
return { ...slotProps, ...overrideProps };
|
|
10339
|
-
}
|
|
10340
|
-
function getElementRef$3(element) {
|
|
10341
|
-
var _a2, _b;
|
|
10342
|
-
let getter = (_a2 = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a2.get;
|
|
10343
|
-
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
10344
|
-
if (mayWarn) {
|
|
10345
|
-
return element.ref;
|
|
10346
|
-
}
|
|
10347
|
-
getter = (_b = Object.getOwnPropertyDescriptor(element, "ref")) == null ? void 0 : _b.get;
|
|
10348
|
-
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
10349
|
-
if (mayWarn) {
|
|
10350
|
-
return element.props.ref;
|
|
10351
|
-
}
|
|
10352
|
-
return element.props.ref || element.ref;
|
|
10353
|
-
}
|
|
10354
10137
|
var shim$1 = { exports: {} };
|
|
10355
10138
|
var useSyncExternalStoreShim_production = {};
|
|
10356
10139
|
/**
|
|
@@ -12443,89 +12226,6 @@ const arrow$2 = (options, deps) => {
|
|
|
12443
12226
|
options: [options, deps]
|
|
12444
12227
|
};
|
|
12445
12228
|
};
|
|
12446
|
-
// @__NO_SIDE_EFFECTS__
|
|
12447
|
-
function createSlot$2(ownerName) {
|
|
12448
|
-
const SlotClone = /* @__PURE__ */ createSlotClone$2(ownerName);
|
|
12449
|
-
const Slot2 = React__namespace.forwardRef((props, forwardedRef) => {
|
|
12450
|
-
const { children, ...slotProps } = props;
|
|
12451
|
-
const childrenArray = React__namespace.Children.toArray(children);
|
|
12452
|
-
const slottable = childrenArray.find(isSlottable$2);
|
|
12453
|
-
if (slottable) {
|
|
12454
|
-
const newElement = slottable.props.children;
|
|
12455
|
-
const newChildren = childrenArray.map((child) => {
|
|
12456
|
-
if (child === slottable) {
|
|
12457
|
-
if (React__namespace.Children.count(newElement) > 1) return React__namespace.Children.only(null);
|
|
12458
|
-
return React__namespace.isValidElement(newElement) ? newElement.props.children : null;
|
|
12459
|
-
} else {
|
|
12460
|
-
return child;
|
|
12461
|
-
}
|
|
12462
|
-
});
|
|
12463
|
-
return /* @__PURE__ */ jsxRuntime.jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React__namespace.isValidElement(newElement) ? React__namespace.cloneElement(newElement, void 0, newChildren) : null });
|
|
12464
|
-
}
|
|
12465
|
-
return /* @__PURE__ */ jsxRuntime.jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
12466
|
-
});
|
|
12467
|
-
Slot2.displayName = `${ownerName}.Slot`;
|
|
12468
|
-
return Slot2;
|
|
12469
|
-
}
|
|
12470
|
-
// @__NO_SIDE_EFFECTS__
|
|
12471
|
-
function createSlotClone$2(ownerName) {
|
|
12472
|
-
const SlotClone = React__namespace.forwardRef((props, forwardedRef) => {
|
|
12473
|
-
const { children, ...slotProps } = props;
|
|
12474
|
-
if (React__namespace.isValidElement(children)) {
|
|
12475
|
-
const childrenRef = getElementRef$2(children);
|
|
12476
|
-
const props2 = mergeProps$2(slotProps, children.props);
|
|
12477
|
-
if (children.type !== React__namespace.Fragment) {
|
|
12478
|
-
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
12479
|
-
}
|
|
12480
|
-
return React__namespace.cloneElement(children, props2);
|
|
12481
|
-
}
|
|
12482
|
-
return React__namespace.Children.count(children) > 1 ? React__namespace.Children.only(null) : null;
|
|
12483
|
-
});
|
|
12484
|
-
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
12485
|
-
return SlotClone;
|
|
12486
|
-
}
|
|
12487
|
-
var SLOTTABLE_IDENTIFIER$2 = Symbol("radix.slottable");
|
|
12488
|
-
function isSlottable$2(child) {
|
|
12489
|
-
return React__namespace.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER$2;
|
|
12490
|
-
}
|
|
12491
|
-
function mergeProps$2(slotProps, childProps) {
|
|
12492
|
-
const overrideProps = { ...childProps };
|
|
12493
|
-
for (const propName in childProps) {
|
|
12494
|
-
const slotPropValue = slotProps[propName];
|
|
12495
|
-
const childPropValue = childProps[propName];
|
|
12496
|
-
const isHandler = /^on[A-Z]/.test(propName);
|
|
12497
|
-
if (isHandler) {
|
|
12498
|
-
if (slotPropValue && childPropValue) {
|
|
12499
|
-
overrideProps[propName] = (...args) => {
|
|
12500
|
-
const result = childPropValue(...args);
|
|
12501
|
-
slotPropValue(...args);
|
|
12502
|
-
return result;
|
|
12503
|
-
};
|
|
12504
|
-
} else if (slotPropValue) {
|
|
12505
|
-
overrideProps[propName] = slotPropValue;
|
|
12506
|
-
}
|
|
12507
|
-
} else if (propName === "style") {
|
|
12508
|
-
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
12509
|
-
} else if (propName === "className") {
|
|
12510
|
-
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
12511
|
-
}
|
|
12512
|
-
}
|
|
12513
|
-
return { ...slotProps, ...overrideProps };
|
|
12514
|
-
}
|
|
12515
|
-
function getElementRef$2(element) {
|
|
12516
|
-
var _a2, _b;
|
|
12517
|
-
let getter = (_a2 = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a2.get;
|
|
12518
|
-
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
12519
|
-
if (mayWarn) {
|
|
12520
|
-
return element.ref;
|
|
12521
|
-
}
|
|
12522
|
-
getter = (_b = Object.getOwnPropertyDescriptor(element, "ref")) == null ? void 0 : _b.get;
|
|
12523
|
-
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
12524
|
-
if (mayWarn) {
|
|
12525
|
-
return element.props.ref;
|
|
12526
|
-
}
|
|
12527
|
-
return element.props.ref || element.ref;
|
|
12528
|
-
}
|
|
12529
12229
|
var NODES$2 = [
|
|
12530
12230
|
"a",
|
|
12531
12231
|
"button",
|
|
@@ -12546,7 +12246,7 @@ var NODES$2 = [
|
|
|
12546
12246
|
"ul"
|
|
12547
12247
|
];
|
|
12548
12248
|
var Primitive$2 = NODES$2.reduce((primitive, node) => {
|
|
12549
|
-
const Slot2 = /* @__PURE__ */ createSlot
|
|
12249
|
+
const Slot2 = /* @__PURE__ */ createSlot(`Primitive.${node}`);
|
|
12550
12250
|
const Node4 = React__namespace.forwardRef((props, forwardedRef) => {
|
|
12551
12251
|
const { asChild, ...primitiveProps } = props;
|
|
12552
12252
|
const Comp = asChild ? Slot2 : node;
|
|
@@ -12635,89 +12335,6 @@ function composeContextScopes$1(...scopes) {
|
|
|
12635
12335
|
createScope.scopeName = baseScope.scopeName;
|
|
12636
12336
|
return createScope;
|
|
12637
12337
|
}
|
|
12638
|
-
// @__NO_SIDE_EFFECTS__
|
|
12639
|
-
function createSlot$1(ownerName) {
|
|
12640
|
-
const SlotClone = /* @__PURE__ */ createSlotClone$1(ownerName);
|
|
12641
|
-
const Slot2 = React__namespace.forwardRef((props, forwardedRef) => {
|
|
12642
|
-
const { children, ...slotProps } = props;
|
|
12643
|
-
const childrenArray = React__namespace.Children.toArray(children);
|
|
12644
|
-
const slottable = childrenArray.find(isSlottable$1);
|
|
12645
|
-
if (slottable) {
|
|
12646
|
-
const newElement = slottable.props.children;
|
|
12647
|
-
const newChildren = childrenArray.map((child) => {
|
|
12648
|
-
if (child === slottable) {
|
|
12649
|
-
if (React__namespace.Children.count(newElement) > 1) return React__namespace.Children.only(null);
|
|
12650
|
-
return React__namespace.isValidElement(newElement) ? newElement.props.children : null;
|
|
12651
|
-
} else {
|
|
12652
|
-
return child;
|
|
12653
|
-
}
|
|
12654
|
-
});
|
|
12655
|
-
return /* @__PURE__ */ jsxRuntime.jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React__namespace.isValidElement(newElement) ? React__namespace.cloneElement(newElement, void 0, newChildren) : null });
|
|
12656
|
-
}
|
|
12657
|
-
return /* @__PURE__ */ jsxRuntime.jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
12658
|
-
});
|
|
12659
|
-
Slot2.displayName = `${ownerName}.Slot`;
|
|
12660
|
-
return Slot2;
|
|
12661
|
-
}
|
|
12662
|
-
// @__NO_SIDE_EFFECTS__
|
|
12663
|
-
function createSlotClone$1(ownerName) {
|
|
12664
|
-
const SlotClone = React__namespace.forwardRef((props, forwardedRef) => {
|
|
12665
|
-
const { children, ...slotProps } = props;
|
|
12666
|
-
if (React__namespace.isValidElement(children)) {
|
|
12667
|
-
const childrenRef = getElementRef$1(children);
|
|
12668
|
-
const props2 = mergeProps$1(slotProps, children.props);
|
|
12669
|
-
if (children.type !== React__namespace.Fragment) {
|
|
12670
|
-
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
12671
|
-
}
|
|
12672
|
-
return React__namespace.cloneElement(children, props2);
|
|
12673
|
-
}
|
|
12674
|
-
return React__namespace.Children.count(children) > 1 ? React__namespace.Children.only(null) : null;
|
|
12675
|
-
});
|
|
12676
|
-
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
12677
|
-
return SlotClone;
|
|
12678
|
-
}
|
|
12679
|
-
var SLOTTABLE_IDENTIFIER$1 = Symbol("radix.slottable");
|
|
12680
|
-
function isSlottable$1(child) {
|
|
12681
|
-
return React__namespace.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER$1;
|
|
12682
|
-
}
|
|
12683
|
-
function mergeProps$1(slotProps, childProps) {
|
|
12684
|
-
const overrideProps = { ...childProps };
|
|
12685
|
-
for (const propName in childProps) {
|
|
12686
|
-
const slotPropValue = slotProps[propName];
|
|
12687
|
-
const childPropValue = childProps[propName];
|
|
12688
|
-
const isHandler = /^on[A-Z]/.test(propName);
|
|
12689
|
-
if (isHandler) {
|
|
12690
|
-
if (slotPropValue && childPropValue) {
|
|
12691
|
-
overrideProps[propName] = (...args) => {
|
|
12692
|
-
const result = childPropValue(...args);
|
|
12693
|
-
slotPropValue(...args);
|
|
12694
|
-
return result;
|
|
12695
|
-
};
|
|
12696
|
-
} else if (slotPropValue) {
|
|
12697
|
-
overrideProps[propName] = slotPropValue;
|
|
12698
|
-
}
|
|
12699
|
-
} else if (propName === "style") {
|
|
12700
|
-
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
12701
|
-
} else if (propName === "className") {
|
|
12702
|
-
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
12703
|
-
}
|
|
12704
|
-
}
|
|
12705
|
-
return { ...slotProps, ...overrideProps };
|
|
12706
|
-
}
|
|
12707
|
-
function getElementRef$1(element) {
|
|
12708
|
-
var _a2, _b;
|
|
12709
|
-
let getter = (_a2 = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a2.get;
|
|
12710
|
-
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
12711
|
-
if (mayWarn) {
|
|
12712
|
-
return element.ref;
|
|
12713
|
-
}
|
|
12714
|
-
getter = (_b = Object.getOwnPropertyDescriptor(element, "ref")) == null ? void 0 : _b.get;
|
|
12715
|
-
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
12716
|
-
if (mayWarn) {
|
|
12717
|
-
return element.props.ref;
|
|
12718
|
-
}
|
|
12719
|
-
return element.props.ref || element.ref;
|
|
12720
|
-
}
|
|
12721
12338
|
var NODES$1 = [
|
|
12722
12339
|
"a",
|
|
12723
12340
|
"button",
|
|
@@ -12738,7 +12355,7 @@ var NODES$1 = [
|
|
|
12738
12355
|
"ul"
|
|
12739
12356
|
];
|
|
12740
12357
|
var Primitive$1 = NODES$1.reduce((primitive, node) => {
|
|
12741
|
-
const Slot2 = /* @__PURE__ */ createSlot
|
|
12358
|
+
const Slot2 = /* @__PURE__ */ createSlot(`Primitive.${node}`);
|
|
12742
12359
|
const Node4 = React__namespace.forwardRef((props, forwardedRef) => {
|
|
12743
12360
|
const { asChild, ...primitiveProps } = props;
|
|
12744
12361
|
const Comp = asChild ? Slot2 : node;
|
|
@@ -13080,98 +12697,6 @@ function composeContextScopes(...scopes) {
|
|
|
13080
12697
|
createScope.scopeName = baseScope.scopeName;
|
|
13081
12698
|
return createScope;
|
|
13082
12699
|
}
|
|
13083
|
-
// @__NO_SIDE_EFFECTS__
|
|
13084
|
-
function createSlot(ownerName) {
|
|
13085
|
-
const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
|
|
13086
|
-
const Slot2 = React__namespace.forwardRef((props, forwardedRef) => {
|
|
13087
|
-
const { children, ...slotProps } = props;
|
|
13088
|
-
const childrenArray = React__namespace.Children.toArray(children);
|
|
13089
|
-
const slottable = childrenArray.find(isSlottable);
|
|
13090
|
-
if (slottable) {
|
|
13091
|
-
const newElement = slottable.props.children;
|
|
13092
|
-
const newChildren = childrenArray.map((child) => {
|
|
13093
|
-
if (child === slottable) {
|
|
13094
|
-
if (React__namespace.Children.count(newElement) > 1) return React__namespace.Children.only(null);
|
|
13095
|
-
return React__namespace.isValidElement(newElement) ? newElement.props.children : null;
|
|
13096
|
-
} else {
|
|
13097
|
-
return child;
|
|
13098
|
-
}
|
|
13099
|
-
});
|
|
13100
|
-
return /* @__PURE__ */ jsxRuntime.jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React__namespace.isValidElement(newElement) ? React__namespace.cloneElement(newElement, void 0, newChildren) : null });
|
|
13101
|
-
}
|
|
13102
|
-
return /* @__PURE__ */ jsxRuntime.jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
13103
|
-
});
|
|
13104
|
-
Slot2.displayName = `${ownerName}.Slot`;
|
|
13105
|
-
return Slot2;
|
|
13106
|
-
}
|
|
13107
|
-
// @__NO_SIDE_EFFECTS__
|
|
13108
|
-
function createSlotClone(ownerName) {
|
|
13109
|
-
const SlotClone = React__namespace.forwardRef((props, forwardedRef) => {
|
|
13110
|
-
const { children, ...slotProps } = props;
|
|
13111
|
-
if (React__namespace.isValidElement(children)) {
|
|
13112
|
-
const childrenRef = getElementRef(children);
|
|
13113
|
-
const props2 = mergeProps(slotProps, children.props);
|
|
13114
|
-
if (children.type !== React__namespace.Fragment) {
|
|
13115
|
-
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
13116
|
-
}
|
|
13117
|
-
return React__namespace.cloneElement(children, props2);
|
|
13118
|
-
}
|
|
13119
|
-
return React__namespace.Children.count(children) > 1 ? React__namespace.Children.only(null) : null;
|
|
13120
|
-
});
|
|
13121
|
-
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
13122
|
-
return SlotClone;
|
|
13123
|
-
}
|
|
13124
|
-
var SLOTTABLE_IDENTIFIER = Symbol("radix.slottable");
|
|
13125
|
-
// @__NO_SIDE_EFFECTS__
|
|
13126
|
-
function createSlottable(ownerName) {
|
|
13127
|
-
const Slottable2 = ({ children }) => {
|
|
13128
|
-
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
|
|
13129
|
-
};
|
|
13130
|
-
Slottable2.displayName = `${ownerName}.Slottable`;
|
|
13131
|
-
Slottable2.__radixId = SLOTTABLE_IDENTIFIER;
|
|
13132
|
-
return Slottable2;
|
|
13133
|
-
}
|
|
13134
|
-
function isSlottable(child) {
|
|
13135
|
-
return React__namespace.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
|
|
13136
|
-
}
|
|
13137
|
-
function mergeProps(slotProps, childProps) {
|
|
13138
|
-
const overrideProps = { ...childProps };
|
|
13139
|
-
for (const propName in childProps) {
|
|
13140
|
-
const slotPropValue = slotProps[propName];
|
|
13141
|
-
const childPropValue = childProps[propName];
|
|
13142
|
-
const isHandler = /^on[A-Z]/.test(propName);
|
|
13143
|
-
if (isHandler) {
|
|
13144
|
-
if (slotPropValue && childPropValue) {
|
|
13145
|
-
overrideProps[propName] = (...args) => {
|
|
13146
|
-
const result = childPropValue(...args);
|
|
13147
|
-
slotPropValue(...args);
|
|
13148
|
-
return result;
|
|
13149
|
-
};
|
|
13150
|
-
} else if (slotPropValue) {
|
|
13151
|
-
overrideProps[propName] = slotPropValue;
|
|
13152
|
-
}
|
|
13153
|
-
} else if (propName === "style") {
|
|
13154
|
-
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
13155
|
-
} else if (propName === "className") {
|
|
13156
|
-
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
13157
|
-
}
|
|
13158
|
-
}
|
|
13159
|
-
return { ...slotProps, ...overrideProps };
|
|
13160
|
-
}
|
|
13161
|
-
function getElementRef(element) {
|
|
13162
|
-
var _a2, _b;
|
|
13163
|
-
let getter = (_a2 = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a2.get;
|
|
13164
|
-
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
13165
|
-
if (mayWarn) {
|
|
13166
|
-
return element.ref;
|
|
13167
|
-
}
|
|
13168
|
-
getter = (_b = Object.getOwnPropertyDescriptor(element, "ref")) == null ? void 0 : _b.get;
|
|
13169
|
-
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
13170
|
-
if (mayWarn) {
|
|
13171
|
-
return element.props.ref;
|
|
13172
|
-
}
|
|
13173
|
-
return element.props.ref || element.ref;
|
|
13174
|
-
}
|
|
13175
12700
|
var NODES = [
|
|
13176
12701
|
"a",
|
|
13177
12702
|
"button",
|
|
@@ -13713,190 +13238,6 @@ function TooltipContent({
|
|
|
13713
13238
|
}
|
|
13714
13239
|
) });
|
|
13715
13240
|
}
|
|
13716
|
-
const AthenaContext = React.createContext(null);
|
|
13717
|
-
function useAthenaConfig() {
|
|
13718
|
-
const ctx = React.useContext(AthenaContext);
|
|
13719
|
-
if (!ctx) {
|
|
13720
|
-
throw new Error("[AthenaSDK] useAthenaConfig must be used within <AthenaProvider>");
|
|
13721
|
-
}
|
|
13722
|
-
return ctx;
|
|
13723
|
-
}
|
|
13724
|
-
const AthenaThreadIdContext = React.createContext(void 0);
|
|
13725
|
-
function useAthenaThreadId() {
|
|
13726
|
-
return React.useContext(AthenaThreadIdContext);
|
|
13727
|
-
}
|
|
13728
|
-
function useAthenaThreadListAdapter(config2) {
|
|
13729
|
-
const configRef = React.useRef(config2);
|
|
13730
|
-
configRef.current = config2;
|
|
13731
|
-
const auth = React.useMemo(
|
|
13732
|
-
() => ({ apiKey: config2.apiKey, token: config2.token }),
|
|
13733
|
-
[config2.apiKey, config2.token]
|
|
13734
|
-
);
|
|
13735
|
-
const unstable_Provider = React.useCallback(
|
|
13736
|
-
function AthenaThreadProvider({ children }) {
|
|
13737
|
-
const remoteId = react$1.useAuiState(
|
|
13738
|
-
(s) => {
|
|
13739
|
-
var _a2;
|
|
13740
|
-
return (_a2 = s.threadListItem) == null ? void 0 : _a2.remoteId;
|
|
13741
|
-
}
|
|
13742
|
-
);
|
|
13743
|
-
return /* @__PURE__ */ jsxRuntime.jsx(AthenaThreadIdContext.Provider, { value: remoteId, children });
|
|
13744
|
-
},
|
|
13745
|
-
[]
|
|
13746
|
-
);
|
|
13747
|
-
return React.useMemo(() => ({
|
|
13748
|
-
async list() {
|
|
13749
|
-
if (!auth.token && !auth.apiKey) {
|
|
13750
|
-
return { threads: [] };
|
|
13751
|
-
}
|
|
13752
|
-
try {
|
|
13753
|
-
const { threads } = await listThreads(configRef.current.backendUrl, auth, {
|
|
13754
|
-
...configRef.current.appId ? { app_id: configRef.current.appId } : {}
|
|
13755
|
-
});
|
|
13756
|
-
return {
|
|
13757
|
-
threads: threads.map((t) => ({
|
|
13758
|
-
status: "regular",
|
|
13759
|
-
remoteId: t.thread_id,
|
|
13760
|
-
title: t.title || void 0
|
|
13761
|
-
}))
|
|
13762
|
-
};
|
|
13763
|
-
} catch (err) {
|
|
13764
|
-
console.error("[AthenaSDK] adapter.list() failed:", err);
|
|
13765
|
-
return { threads: [] };
|
|
13766
|
-
}
|
|
13767
|
-
},
|
|
13768
|
-
async initialize(_threadId) {
|
|
13769
|
-
const remoteId = typeof crypto !== "undefined" && "randomUUID" in crypto ? crypto.randomUUID() : `thread_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
|
|
13770
|
-
return { remoteId, externalId: void 0 };
|
|
13771
|
-
},
|
|
13772
|
-
async rename(_remoteId, _newTitle) {
|
|
13773
|
-
},
|
|
13774
|
-
async archive(remoteId) {
|
|
13775
|
-
await archiveThread(configRef.current.backendUrl, auth, remoteId);
|
|
13776
|
-
},
|
|
13777
|
-
async unarchive(_remoteId) {
|
|
13778
|
-
},
|
|
13779
|
-
async delete(remoteId) {
|
|
13780
|
-
await archiveThread(configRef.current.backendUrl, auth, remoteId);
|
|
13781
|
-
},
|
|
13782
|
-
async generateTitle(_remoteId, _messages) {
|
|
13783
|
-
return new ReadableStream({ start(c) {
|
|
13784
|
-
c.close();
|
|
13785
|
-
} });
|
|
13786
|
-
},
|
|
13787
|
-
async fetch(remoteId) {
|
|
13788
|
-
return {
|
|
13789
|
-
status: "regular",
|
|
13790
|
-
remoteId
|
|
13791
|
-
};
|
|
13792
|
-
},
|
|
13793
|
-
unstable_Provider
|
|
13794
|
-
}), [auth, unstable_Provider]);
|
|
13795
|
-
}
|
|
13796
|
-
const ThreadListRefreshContext = React.createContext(null);
|
|
13797
|
-
function useRefreshThreadList() {
|
|
13798
|
-
return React.useContext(ThreadListRefreshContext);
|
|
13799
|
-
}
|
|
13800
|
-
const LOCAL_ID_PREFIX = "__LOCALID_";
|
|
13801
|
-
const isLocalPlaceholder = (id) => !!id && id.startsWith(LOCAL_ID_PREFIX);
|
|
13802
|
-
function useAthenaThreadManager() {
|
|
13803
|
-
const runtime = react$1.useAssistantRuntime({ optional: true });
|
|
13804
|
-
const remoteId = react$1.useThread({
|
|
13805
|
-
optional: true,
|
|
13806
|
-
selector: (s) => {
|
|
13807
|
-
var _a2;
|
|
13808
|
-
const id = (_a2 = s.metadata) == null ? void 0 : _a2.remoteId;
|
|
13809
|
-
return isLocalPlaceholder(id) ? void 0 : id;
|
|
13810
|
-
}
|
|
13811
|
-
});
|
|
13812
|
-
const isThreadLoading = react$1.useThread({ optional: true, selector: (s) => s.isLoading }) ?? false;
|
|
13813
|
-
const isListLoading = react$1.useThreadList({ optional: true, selector: (s) => s.isLoading });
|
|
13814
|
-
const runtimeRef = React.useRef(runtime);
|
|
13815
|
-
runtimeRef.current = runtime;
|
|
13816
|
-
const switchToThread = React.useCallback(
|
|
13817
|
-
(id) => runtimeRef.current.threads.switchToThread(id),
|
|
13818
|
-
[]
|
|
13819
|
-
);
|
|
13820
|
-
const switchToNewThread = React.useCallback(
|
|
13821
|
-
() => runtimeRef.current.threads.switchToNewThread(),
|
|
13822
|
-
[]
|
|
13823
|
-
);
|
|
13824
|
-
const activeThreadId = remoteId ?? null;
|
|
13825
|
-
return React.useMemo(() => {
|
|
13826
|
-
if (!runtime || isListLoading == null) {
|
|
13827
|
-
return null;
|
|
13828
|
-
}
|
|
13829
|
-
return {
|
|
13830
|
-
activeThreadId,
|
|
13831
|
-
isListLoading,
|
|
13832
|
-
isThreadLoading,
|
|
13833
|
-
switchToThread,
|
|
13834
|
-
switchToNewThread
|
|
13835
|
-
};
|
|
13836
|
-
}, [runtime, activeThreadId, isListLoading, isThreadLoading, switchToThread, switchToNewThread]);
|
|
13837
|
-
}
|
|
13838
|
-
const POLL_DELAY_MS = 5e3;
|
|
13839
|
-
const POLL_INTERVAL_MS = 1e3;
|
|
13840
|
-
const POLL_MAX_DURATION_MS = 6e4;
|
|
13841
|
-
function useThreadTitlePolling(refresh) {
|
|
13842
|
-
const threadKey = react$1.useThread({
|
|
13843
|
-
optional: true,
|
|
13844
|
-
selector: (s) => {
|
|
13845
|
-
var _a2, _b;
|
|
13846
|
-
return ((_a2 = s.metadata) == null ? void 0 : _a2.remoteId) ?? ((_b = s.metadata) == null ? void 0 : _b.id) ?? s.threadId;
|
|
13847
|
-
}
|
|
13848
|
-
}) ?? null;
|
|
13849
|
-
const hasMessages = react$1.useThread({
|
|
13850
|
-
optional: true,
|
|
13851
|
-
selector: (s) => s.messages.length > 0
|
|
13852
|
-
}) ?? false;
|
|
13853
|
-
const currentTitle = react$1.useThreadList({
|
|
13854
|
-
optional: true,
|
|
13855
|
-
selector: (s) => {
|
|
13856
|
-
const main = s.threadItems[s.mainThreadId];
|
|
13857
|
-
return (main == null ? void 0 : main.title) ?? "";
|
|
13858
|
-
}
|
|
13859
|
-
}) ?? "";
|
|
13860
|
-
const hasTitle = currentTitle.trim().length > 0;
|
|
13861
|
-
const polledThreadsRef = React.useRef(/* @__PURE__ */ new Set());
|
|
13862
|
-
const refreshRef = React.useRef(refresh);
|
|
13863
|
-
refreshRef.current = refresh;
|
|
13864
|
-
React.useEffect(() => {
|
|
13865
|
-
if (!threadKey || hasTitle || !hasMessages) {
|
|
13866
|
-
return;
|
|
13867
|
-
}
|
|
13868
|
-
if (polledThreadsRef.current.has(threadKey)) {
|
|
13869
|
-
return;
|
|
13870
|
-
}
|
|
13871
|
-
polledThreadsRef.current.add(threadKey);
|
|
13872
|
-
let stopped = false;
|
|
13873
|
-
let intervalId = null;
|
|
13874
|
-
let maxTimeoutId = null;
|
|
13875
|
-
const stop = () => {
|
|
13876
|
-
stopped = true;
|
|
13877
|
-
if (intervalId !== null) {
|
|
13878
|
-
clearInterval(intervalId);
|
|
13879
|
-
intervalId = null;
|
|
13880
|
-
}
|
|
13881
|
-
if (maxTimeoutId !== null) {
|
|
13882
|
-
clearTimeout(maxTimeoutId);
|
|
13883
|
-
maxTimeoutId = null;
|
|
13884
|
-
}
|
|
13885
|
-
};
|
|
13886
|
-
const startTimeoutId = setTimeout(() => {
|
|
13887
|
-
if (stopped) return;
|
|
13888
|
-
refreshRef.current();
|
|
13889
|
-
intervalId = setInterval(() => {
|
|
13890
|
-
refreshRef.current();
|
|
13891
|
-
}, POLL_INTERVAL_MS);
|
|
13892
|
-
maxTimeoutId = setTimeout(stop, POLL_MAX_DURATION_MS - POLL_DELAY_MS);
|
|
13893
|
-
}, POLL_DELAY_MS);
|
|
13894
|
-
return () => {
|
|
13895
|
-
clearTimeout(startTimeoutId);
|
|
13896
|
-
stop();
|
|
13897
|
-
};
|
|
13898
|
-
}, [threadKey, hasTitle, hasMessages]);
|
|
13899
|
-
}
|
|
13900
13241
|
const createStoreImpl = (createState) => {
|
|
13901
13242
|
let state;
|
|
13902
13243
|
const listeners = /* @__PURE__ */ new Set();
|
|
@@ -14239,6 +13580,398 @@ const useAssetPanelStore = create()(
|
|
|
14239
13580
|
}
|
|
14240
13581
|
)
|
|
14241
13582
|
);
|
|
13583
|
+
function getAssetInfo(assetId) {
|
|
13584
|
+
return { name: assetId || "Document", icon: "doc" };
|
|
13585
|
+
}
|
|
13586
|
+
function tryParseJson$2(text2) {
|
|
13587
|
+
try {
|
|
13588
|
+
const p = JSON.parse(text2);
|
|
13589
|
+
return typeof p === "object" && p !== null ? p : null;
|
|
13590
|
+
} catch {
|
|
13591
|
+
return null;
|
|
13592
|
+
}
|
|
13593
|
+
}
|
|
13594
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
13595
|
+
const normalizeResult$2 = (result) => {
|
|
13596
|
+
if (!result) return null;
|
|
13597
|
+
if (typeof result === "string") {
|
|
13598
|
+
const parsed = tryParseJson$2(result);
|
|
13599
|
+
if (isRecord(parsed)) return parsed;
|
|
13600
|
+
return null;
|
|
13601
|
+
}
|
|
13602
|
+
if (isRecord(result)) {
|
|
13603
|
+
const inner = result.result;
|
|
13604
|
+
if (typeof inner === "string") {
|
|
13605
|
+
const parsed = tryParseJson$2(inner);
|
|
13606
|
+
if (isRecord(parsed)) return parsed;
|
|
13607
|
+
} else if (isRecord(inner)) {
|
|
13608
|
+
return inner;
|
|
13609
|
+
}
|
|
13610
|
+
return result;
|
|
13611
|
+
}
|
|
13612
|
+
return null;
|
|
13613
|
+
};
|
|
13614
|
+
const pickAssetId = (...candidates) => {
|
|
13615
|
+
for (const candidate of candidates) {
|
|
13616
|
+
if (typeof candidate === "string" && candidate.startsWith("asset_")) {
|
|
13617
|
+
return candidate;
|
|
13618
|
+
}
|
|
13619
|
+
}
|
|
13620
|
+
return null;
|
|
13621
|
+
};
|
|
13622
|
+
const pickNumber = (...candidates) => {
|
|
13623
|
+
for (const candidate of candidates) {
|
|
13624
|
+
if (typeof candidate === "number" && Number.isFinite(candidate)) {
|
|
13625
|
+
return candidate;
|
|
13626
|
+
}
|
|
13627
|
+
}
|
|
13628
|
+
return void 0;
|
|
13629
|
+
};
|
|
13630
|
+
const autoOpen = (assetId, options = {}) => {
|
|
13631
|
+
const store = useAssetPanelStore.getState();
|
|
13632
|
+
if (!store.markAutoOpened(assetId)) return;
|
|
13633
|
+
const existing = store.tabs.find((tab) => tab.id === assetId);
|
|
13634
|
+
const keepCurrentSlide = options.preserveExistingSlide && existing;
|
|
13635
|
+
store.openAsset(assetId, {
|
|
13636
|
+
type: options.type ?? "unknown",
|
|
13637
|
+
...keepCurrentSlide || options.slideNumber === void 0 ? {} : { slideNumber: options.slideNumber }
|
|
13638
|
+
});
|
|
13639
|
+
};
|
|
13640
|
+
const openOnResult = (type, extra) => ({
|
|
13641
|
+
streamCall: async (reader) => {
|
|
13642
|
+
const { result } = await reader.response.get();
|
|
13643
|
+
const data = normalizeResult$2(result);
|
|
13644
|
+
const assetId = pickAssetId(
|
|
13645
|
+
data == null ? void 0 : data.asset_id,
|
|
13646
|
+
data == null ? void 0 : data.assetId,
|
|
13647
|
+
data == null ? void 0 : data.id
|
|
13648
|
+
);
|
|
13649
|
+
if (!assetId) return;
|
|
13650
|
+
let slideNumber;
|
|
13651
|
+
if ((extra == null ? void 0 : extra.slideNumberFrom) !== "args") {
|
|
13652
|
+
slideNumber = pickNumber(
|
|
13653
|
+
data == null ? void 0 : data.slide_number,
|
|
13654
|
+
data == null ? void 0 : data.slideNumber,
|
|
13655
|
+
data == null ? void 0 : data.targetSlideNumber,
|
|
13656
|
+
data == null ? void 0 : data.target_slide_number
|
|
13657
|
+
);
|
|
13658
|
+
}
|
|
13659
|
+
if (slideNumber === void 0 && (extra == null ? void 0 : extra.slideNumberFrom) !== "result") {
|
|
13660
|
+
const args = await reader.args.get().catch(() => null);
|
|
13661
|
+
slideNumber = pickNumber(
|
|
13662
|
+
args == null ? void 0 : args.slide_number,
|
|
13663
|
+
args == null ? void 0 : args.slideNumber,
|
|
13664
|
+
args == null ? void 0 : args.targetSlideNumber,
|
|
13665
|
+
args == null ? void 0 : args.target_slide_number
|
|
13666
|
+
);
|
|
13667
|
+
}
|
|
13668
|
+
autoOpen(assetId, {
|
|
13669
|
+
type,
|
|
13670
|
+
slideNumber,
|
|
13671
|
+
preserveExistingSlide: extra == null ? void 0 : extra.preserveExistingSlide
|
|
13672
|
+
});
|
|
13673
|
+
}
|
|
13674
|
+
});
|
|
13675
|
+
const openFromArgs = (type) => ({
|
|
13676
|
+
streamCall: async (reader) => {
|
|
13677
|
+
await reader.response.get();
|
|
13678
|
+
const args = await reader.args.get().catch(() => null);
|
|
13679
|
+
const assetId = pickAssetId(args == null ? void 0 : args.asset_id, args == null ? void 0 : args.assetId);
|
|
13680
|
+
if (!assetId) return;
|
|
13681
|
+
autoOpen(assetId, { type });
|
|
13682
|
+
}
|
|
13683
|
+
});
|
|
13684
|
+
const DEFAULT_AUTO_OPEN_TOOLS = {
|
|
13685
|
+
// Top-level asset creators
|
|
13686
|
+
create_new_document: openOnResult("document"),
|
|
13687
|
+
create_document_from_markdown: openOnResult("document"),
|
|
13688
|
+
create_new_sheet: openOnResult("spreadsheet"),
|
|
13689
|
+
create_powerpoint_deck: openOnResult("presentation"),
|
|
13690
|
+
create_new_notebook: openOnResult("notebook"),
|
|
13691
|
+
// Open / read existing assets
|
|
13692
|
+
open_asset_in_workspace: openFromArgs("unknown"),
|
|
13693
|
+
// Code execution that lands on a deck/slide
|
|
13694
|
+
execute_presentation_code: openOnResult("presentation"),
|
|
13695
|
+
// Media capture
|
|
13696
|
+
capture_moment: openOnResult("unknown"),
|
|
13697
|
+
// Studio PTC sub-calls (nested SDK commands)
|
|
13698
|
+
CreateWorkbook: openOnResult("spreadsheet"),
|
|
13699
|
+
AddSheet: openOnResult("spreadsheet"),
|
|
13700
|
+
OpenWorkbook: openOnResult("spreadsheet"),
|
|
13701
|
+
CreatePresentation: openOnResult("presentation"),
|
|
13702
|
+
OpenPresentation: openOnResult("presentation", { preserveExistingSlide: true }),
|
|
13703
|
+
AddSlide: openOnResult("presentation"),
|
|
13704
|
+
CreateDocument: openOnResult("document"),
|
|
13705
|
+
CreateParagraph: openOnResult("document"),
|
|
13706
|
+
OpenDocument: openOnResult("document")
|
|
13707
|
+
};
|
|
13708
|
+
const AthenaContext = React.createContext(null);
|
|
13709
|
+
function useAthenaConfig() {
|
|
13710
|
+
const ctx = React.useContext(AthenaContext);
|
|
13711
|
+
if (!ctx) {
|
|
13712
|
+
throw new Error("[AthenaSDK] useAthenaConfig must be used within <AthenaProvider>");
|
|
13713
|
+
}
|
|
13714
|
+
return ctx;
|
|
13715
|
+
}
|
|
13716
|
+
const AthenaThreadIdContext = React.createContext(void 0);
|
|
13717
|
+
function selectThreadListItemRemoteId(state) {
|
|
13718
|
+
var _a2;
|
|
13719
|
+
return (_a2 = state.threadListItem) == null ? void 0 : _a2.remoteId;
|
|
13720
|
+
}
|
|
13721
|
+
function useAthenaAuiThreadRemoteId() {
|
|
13722
|
+
return react$1.useAuiState(selectThreadListItemRemoteId);
|
|
13723
|
+
}
|
|
13724
|
+
function useAthenaThreadId() {
|
|
13725
|
+
return React.useContext(AthenaThreadIdContext);
|
|
13726
|
+
}
|
|
13727
|
+
function useAthenaThreadListAdapter(config2) {
|
|
13728
|
+
const configRef = React.useRef(config2);
|
|
13729
|
+
configRef.current = config2;
|
|
13730
|
+
const auth = React.useMemo(
|
|
13731
|
+
() => ({ apiKey: config2.apiKey, token: config2.token }),
|
|
13732
|
+
[config2.apiKey, config2.token]
|
|
13733
|
+
);
|
|
13734
|
+
const unstable_Provider = React.useCallback(
|
|
13735
|
+
function AthenaThreadProvider({ children }) {
|
|
13736
|
+
const remoteId = useAthenaAuiThreadRemoteId();
|
|
13737
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AthenaThreadIdContext.Provider, { value: remoteId, children });
|
|
13738
|
+
},
|
|
13739
|
+
[]
|
|
13740
|
+
);
|
|
13741
|
+
return React.useMemo(() => ({
|
|
13742
|
+
async list() {
|
|
13743
|
+
if (!auth.token && !auth.apiKey) {
|
|
13744
|
+
return { threads: [] };
|
|
13745
|
+
}
|
|
13746
|
+
try {
|
|
13747
|
+
const { threads } = await listThreads(configRef.current.backendUrl, auth, {
|
|
13748
|
+
...configRef.current.appId ? { app_id: configRef.current.appId } : {}
|
|
13749
|
+
});
|
|
13750
|
+
return {
|
|
13751
|
+
threads: threads.map((t) => ({
|
|
13752
|
+
status: "regular",
|
|
13753
|
+
remoteId: t.thread_id,
|
|
13754
|
+
title: t.title || void 0
|
|
13755
|
+
}))
|
|
13756
|
+
};
|
|
13757
|
+
} catch (err) {
|
|
13758
|
+
console.error("[AthenaSDK] adapter.list() failed:", err);
|
|
13759
|
+
return { threads: [] };
|
|
13760
|
+
}
|
|
13761
|
+
},
|
|
13762
|
+
async initialize(_threadId) {
|
|
13763
|
+
const remoteId = typeof crypto !== "undefined" && "randomUUID" in crypto ? crypto.randomUUID() : `thread_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
|
|
13764
|
+
return { remoteId, externalId: void 0 };
|
|
13765
|
+
},
|
|
13766
|
+
async rename(_remoteId, _newTitle) {
|
|
13767
|
+
},
|
|
13768
|
+
async archive(remoteId) {
|
|
13769
|
+
await archiveThread(configRef.current.backendUrl, auth, remoteId);
|
|
13770
|
+
},
|
|
13771
|
+
async unarchive(_remoteId) {
|
|
13772
|
+
},
|
|
13773
|
+
async delete(remoteId) {
|
|
13774
|
+
await archiveThread(configRef.current.backendUrl, auth, remoteId);
|
|
13775
|
+
},
|
|
13776
|
+
async generateTitle(_remoteId, _messages) {
|
|
13777
|
+
return new ReadableStream({ start(c) {
|
|
13778
|
+
c.close();
|
|
13779
|
+
} });
|
|
13780
|
+
},
|
|
13781
|
+
async fetch(remoteId) {
|
|
13782
|
+
return {
|
|
13783
|
+
status: "regular",
|
|
13784
|
+
remoteId
|
|
13785
|
+
};
|
|
13786
|
+
},
|
|
13787
|
+
unstable_Provider
|
|
13788
|
+
}), [auth, unstable_Provider]);
|
|
13789
|
+
}
|
|
13790
|
+
const ThreadListRefreshContext = React.createContext(null);
|
|
13791
|
+
function useRefreshThreadList() {
|
|
13792
|
+
return React.useContext(ThreadListRefreshContext);
|
|
13793
|
+
}
|
|
13794
|
+
const LOCAL_ID_PREFIX$1 = "__LOCALID_";
|
|
13795
|
+
const isLocalPlaceholder$1 = (id) => !!id && id.startsWith(LOCAL_ID_PREFIX$1);
|
|
13796
|
+
const selectHydratableThreadId = (state) => {
|
|
13797
|
+
var _a2;
|
|
13798
|
+
const remoteId = ((_a2 = state.metadata) == null ? void 0 : _a2.remoteId) ?? state.threadId;
|
|
13799
|
+
return isLocalPlaceholder$1(remoteId) ? null : remoteId;
|
|
13800
|
+
};
|
|
13801
|
+
const createHydrationKey = ({
|
|
13802
|
+
backendUrl,
|
|
13803
|
+
threadId,
|
|
13804
|
+
apiKey,
|
|
13805
|
+
token
|
|
13806
|
+
}) => {
|
|
13807
|
+
const authMode = token ? "bearer" : apiKey ? "api-key" : "none";
|
|
13808
|
+
return `${backendUrl}::${authMode}::${threadId}`;
|
|
13809
|
+
};
|
|
13810
|
+
function useActiveThreadStateHydration({
|
|
13811
|
+
backendUrl,
|
|
13812
|
+
apiKey,
|
|
13813
|
+
token
|
|
13814
|
+
}) {
|
|
13815
|
+
const runtime = react$1.useAssistantRuntime({ optional: true });
|
|
13816
|
+
const threadId = react$1.useThread({
|
|
13817
|
+
optional: true,
|
|
13818
|
+
selector: selectHydratableThreadId
|
|
13819
|
+
}) ?? null;
|
|
13820
|
+
const messageCount = react$1.useThread({
|
|
13821
|
+
optional: true,
|
|
13822
|
+
selector: (state) => state.messages.length
|
|
13823
|
+
}) ?? 0;
|
|
13824
|
+
const isRunning = react$1.useThread({
|
|
13825
|
+
optional: true,
|
|
13826
|
+
selector: (state) => state.isRunning
|
|
13827
|
+
}) ?? false;
|
|
13828
|
+
const activeThreadIdRef = React.useRef(threadId);
|
|
13829
|
+
activeThreadIdRef.current = threadId;
|
|
13830
|
+
const hydratedKeysRef = React.useRef(/* @__PURE__ */ new Set());
|
|
13831
|
+
React.useEffect(() => {
|
|
13832
|
+
if (!runtime || !threadId || isRunning || messageCount > 0) {
|
|
13833
|
+
return;
|
|
13834
|
+
}
|
|
13835
|
+
if (!token && !apiKey) {
|
|
13836
|
+
return;
|
|
13837
|
+
}
|
|
13838
|
+
const hydrationKey = createHydrationKey({
|
|
13839
|
+
backendUrl,
|
|
13840
|
+
threadId,
|
|
13841
|
+
apiKey,
|
|
13842
|
+
token
|
|
13843
|
+
});
|
|
13844
|
+
if (hydratedKeysRef.current.has(hydrationKey)) {
|
|
13845
|
+
return;
|
|
13846
|
+
}
|
|
13847
|
+
let cancelled = false;
|
|
13848
|
+
(async () => {
|
|
13849
|
+
try {
|
|
13850
|
+
const state = await getThreadState(backendUrl, { apiKey, token }, threadId);
|
|
13851
|
+
if (cancelled || activeThreadIdRef.current !== threadId) {
|
|
13852
|
+
return;
|
|
13853
|
+
}
|
|
13854
|
+
if (runtime.thread.getState().messages.length > 0) {
|
|
13855
|
+
return;
|
|
13856
|
+
}
|
|
13857
|
+
runtime.thread.importExternalState(state);
|
|
13858
|
+
hydratedKeysRef.current.add(hydrationKey);
|
|
13859
|
+
} catch (error2) {
|
|
13860
|
+
console.warn("[AthenaSDK] Failed to hydrate active thread state:", error2);
|
|
13861
|
+
}
|
|
13862
|
+
})();
|
|
13863
|
+
return () => {
|
|
13864
|
+
cancelled = true;
|
|
13865
|
+
};
|
|
13866
|
+
}, [apiKey, backendUrl, isRunning, messageCount, runtime, threadId, token]);
|
|
13867
|
+
}
|
|
13868
|
+
const LOCAL_ID_PREFIX = "__LOCALID_";
|
|
13869
|
+
const isLocalPlaceholder = (id) => !!id && id.startsWith(LOCAL_ID_PREFIX);
|
|
13870
|
+
const selectActiveThreadRemoteId = (state) => {
|
|
13871
|
+
const { mainThreadId, threadItems } = state;
|
|
13872
|
+
if (!mainThreadId) {
|
|
13873
|
+
return null;
|
|
13874
|
+
}
|
|
13875
|
+
const item = threadItems[mainThreadId];
|
|
13876
|
+
const remoteId = item ? item.remoteId ?? null : mainThreadId;
|
|
13877
|
+
return isLocalPlaceholder(remoteId) ? null : remoteId;
|
|
13878
|
+
};
|
|
13879
|
+
function useAthenaThreadManager() {
|
|
13880
|
+
const runtime = react$1.useAssistantRuntime({ optional: true });
|
|
13881
|
+
const activeThreadId = react$1.useThreadList({
|
|
13882
|
+
optional: true,
|
|
13883
|
+
selector: selectActiveThreadRemoteId
|
|
13884
|
+
}) ?? null;
|
|
13885
|
+
const isThreadLoading = react$1.useThread({ optional: true, selector: (s) => s.isLoading }) ?? false;
|
|
13886
|
+
const isListLoading = react$1.useThreadList({
|
|
13887
|
+
optional: true,
|
|
13888
|
+
selector: (s) => s.isLoading
|
|
13889
|
+
});
|
|
13890
|
+
const runtimeRef = React.useRef(runtime);
|
|
13891
|
+
runtimeRef.current = runtime;
|
|
13892
|
+
const switchToThread = React.useCallback(
|
|
13893
|
+
(id) => runtimeRef.current.threads.switchToThread(id),
|
|
13894
|
+
[]
|
|
13895
|
+
);
|
|
13896
|
+
const switchToNewThread = React.useCallback(
|
|
13897
|
+
() => runtimeRef.current.threads.switchToNewThread(),
|
|
13898
|
+
[]
|
|
13899
|
+
);
|
|
13900
|
+
return React.useMemo(() => {
|
|
13901
|
+
if (!runtime || isListLoading == null) {
|
|
13902
|
+
return null;
|
|
13903
|
+
}
|
|
13904
|
+
return {
|
|
13905
|
+
activeThreadId,
|
|
13906
|
+
isListLoading,
|
|
13907
|
+
isThreadLoading,
|
|
13908
|
+
switchToThread,
|
|
13909
|
+
switchToNewThread
|
|
13910
|
+
};
|
|
13911
|
+
}, [runtime, activeThreadId, isListLoading, isThreadLoading, switchToThread, switchToNewThread]);
|
|
13912
|
+
}
|
|
13913
|
+
const POLL_DELAY_MS = 5e3;
|
|
13914
|
+
const POLL_INTERVAL_MS = 1e3;
|
|
13915
|
+
const POLL_MAX_DURATION_MS = 6e4;
|
|
13916
|
+
function useThreadTitlePolling(refresh) {
|
|
13917
|
+
const threadKey = react$1.useThread({
|
|
13918
|
+
optional: true,
|
|
13919
|
+
selector: (s) => {
|
|
13920
|
+
var _a2, _b;
|
|
13921
|
+
return ((_a2 = s.metadata) == null ? void 0 : _a2.remoteId) ?? ((_b = s.metadata) == null ? void 0 : _b.id) ?? s.threadId;
|
|
13922
|
+
}
|
|
13923
|
+
}) ?? null;
|
|
13924
|
+
const hasMessages = react$1.useThread({
|
|
13925
|
+
optional: true,
|
|
13926
|
+
selector: (s) => s.messages.length > 0
|
|
13927
|
+
}) ?? false;
|
|
13928
|
+
const currentTitle = react$1.useThreadList({
|
|
13929
|
+
optional: true,
|
|
13930
|
+
selector: (s) => {
|
|
13931
|
+
const main = s.threadItems[s.mainThreadId];
|
|
13932
|
+
return (main == null ? void 0 : main.title) ?? "";
|
|
13933
|
+
}
|
|
13934
|
+
}) ?? "";
|
|
13935
|
+
const hasTitle = currentTitle.trim().length > 0;
|
|
13936
|
+
const polledThreadsRef = React.useRef(/* @__PURE__ */ new Set());
|
|
13937
|
+
const refreshRef = React.useRef(refresh);
|
|
13938
|
+
refreshRef.current = refresh;
|
|
13939
|
+
React.useEffect(() => {
|
|
13940
|
+
if (!threadKey || hasTitle || !hasMessages) {
|
|
13941
|
+
return;
|
|
13942
|
+
}
|
|
13943
|
+
if (polledThreadsRef.current.has(threadKey)) {
|
|
13944
|
+
return;
|
|
13945
|
+
}
|
|
13946
|
+
polledThreadsRef.current.add(threadKey);
|
|
13947
|
+
let stopped = false;
|
|
13948
|
+
let intervalId = null;
|
|
13949
|
+
let maxTimeoutId = null;
|
|
13950
|
+
const stop = () => {
|
|
13951
|
+
stopped = true;
|
|
13952
|
+
if (intervalId !== null) {
|
|
13953
|
+
clearInterval(intervalId);
|
|
13954
|
+
intervalId = null;
|
|
13955
|
+
}
|
|
13956
|
+
if (maxTimeoutId !== null) {
|
|
13957
|
+
clearTimeout(maxTimeoutId);
|
|
13958
|
+
maxTimeoutId = null;
|
|
13959
|
+
}
|
|
13960
|
+
};
|
|
13961
|
+
const startTimeoutId = setTimeout(() => {
|
|
13962
|
+
if (stopped) return;
|
|
13963
|
+
refreshRef.current();
|
|
13964
|
+
intervalId = setInterval(() => {
|
|
13965
|
+
refreshRef.current();
|
|
13966
|
+
}, POLL_INTERVAL_MS);
|
|
13967
|
+
maxTimeoutId = setTimeout(stop, POLL_MAX_DURATION_MS - POLL_DELAY_MS);
|
|
13968
|
+
}, POLL_DELAY_MS);
|
|
13969
|
+
return () => {
|
|
13970
|
+
clearTimeout(startTimeoutId);
|
|
13971
|
+
stop();
|
|
13972
|
+
};
|
|
13973
|
+
}, [threadKey, hasTitle, hasMessages]);
|
|
13974
|
+
}
|
|
14242
13975
|
const THEME_TO_CSS = {
|
|
14243
13976
|
primary: "--primary",
|
|
14244
13977
|
primaryForeground: "--primary-foreground",
|
|
@@ -14557,7 +14290,7 @@ function AthenaStandalone({
|
|
|
14557
14290
|
return /* @__PURE__ */ jsxRuntime.jsx(react$1.AssistantRuntimeProvider, { aui, runtime, children: /* @__PURE__ */ jsxRuntime.jsx(AthenaContext.Provider, { value: athenaConfig, children: /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children }) }) });
|
|
14558
14291
|
}
|
|
14559
14292
|
function useAthenaRuntimeHook(config2) {
|
|
14560
|
-
const remoteId =
|
|
14293
|
+
const remoteId = useAthenaAuiThreadRemoteId();
|
|
14561
14294
|
return useAthenaRuntime({
|
|
14562
14295
|
apiUrl: config2.apiUrl,
|
|
14563
14296
|
backendUrl: config2.backendUrl,
|
|
@@ -14636,7 +14369,7 @@ function AthenaWithThreadList({
|
|
|
14636
14369
|
() => useAthenaRuntimeHook(runtimeConfigRef.current),
|
|
14637
14370
|
[]
|
|
14638
14371
|
);
|
|
14639
|
-
const runtime = react$1.
|
|
14372
|
+
const runtime = react$1.useRemoteThreadListRuntime({
|
|
14640
14373
|
runtimeHook,
|
|
14641
14374
|
adapter
|
|
14642
14375
|
});
|
|
@@ -14672,11 +14405,27 @@ function AthenaWithThreadList({
|
|
|
14672
14405
|
citationLinks
|
|
14673
14406
|
});
|
|
14674
14407
|
return /* @__PURE__ */ jsxRuntime.jsx(react$1.AssistantRuntimeProvider, { aui, runtime, children: /* @__PURE__ */ jsxRuntime.jsx(AthenaContext.Provider, { value: athenaConfig, children: /* @__PURE__ */ jsxRuntime.jsx(ThreadListRefreshContext.Provider, { value: handleRefresh, children: /* @__PURE__ */ jsxRuntime.jsxs(TooltipProvider, { children: [
|
|
14408
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
14409
|
+
ActiveThreadStateHydrator,
|
|
14410
|
+
{
|
|
14411
|
+
backendUrl,
|
|
14412
|
+
apiKey,
|
|
14413
|
+
token
|
|
14414
|
+
}
|
|
14415
|
+
),
|
|
14675
14416
|
/* @__PURE__ */ jsxRuntime.jsx(AssetPanelThreadSync, {}),
|
|
14676
14417
|
/* @__PURE__ */ jsxRuntime.jsx(ThreadTitlePoller, { refresh: handleRefresh }),
|
|
14677
14418
|
children
|
|
14678
14419
|
] }) }) }) });
|
|
14679
14420
|
}
|
|
14421
|
+
function ActiveThreadStateHydrator({
|
|
14422
|
+
backendUrl,
|
|
14423
|
+
apiKey,
|
|
14424
|
+
token
|
|
14425
|
+
}) {
|
|
14426
|
+
useActiveThreadStateHydration({ backendUrl, apiKey, token });
|
|
14427
|
+
return null;
|
|
14428
|
+
}
|
|
14680
14429
|
function AssetPanelThreadSync() {
|
|
14681
14430
|
const threads = useAthenaThreadManager();
|
|
14682
14431
|
const setCurrentThread = useAssetPanelStore((s) => s.setCurrentThread);
|
|
@@ -14699,6 +14448,7 @@ function AthenaProvider({
|
|
|
14699
14448
|
model,
|
|
14700
14449
|
tools = [],
|
|
14701
14450
|
frontendTools = {},
|
|
14451
|
+
disableAutoOpen = false,
|
|
14702
14452
|
apiUrl,
|
|
14703
14453
|
backendUrl,
|
|
14704
14454
|
appUrl,
|
|
@@ -14716,6 +14466,10 @@ function AthenaProvider({
|
|
|
14716
14466
|
posthog: posthogProp
|
|
14717
14467
|
}) {
|
|
14718
14468
|
const frontendToolNames = React.useMemo(() => Object.keys(frontendTools), [frontendTools]);
|
|
14469
|
+
const effectiveFrontendTools = React.useMemo(
|
|
14470
|
+
() => disableAutoOpen ? frontendTools : { ...DEFAULT_AUTO_OPEN_TOOLS, ...frontendTools },
|
|
14471
|
+
[disableAutoOpen, frontendTools]
|
|
14472
|
+
);
|
|
14719
14473
|
const themeStyleVars = React.useMemo(() => theme ? themeToStyleVars(theme) : void 0, [theme]);
|
|
14720
14474
|
const configuredEnvironment = (config2 == null ? void 0 : config2.environment) ?? environment;
|
|
14721
14475
|
const environmentUrls = React.useMemo(
|
|
@@ -14755,7 +14509,7 @@ function AthenaProvider({
|
|
|
14755
14509
|
agent: agent2,
|
|
14756
14510
|
tools,
|
|
14757
14511
|
frontendToolIds: frontendToolNames,
|
|
14758
|
-
frontendTools,
|
|
14512
|
+
frontendTools: effectiveFrontendTools,
|
|
14759
14513
|
workbench,
|
|
14760
14514
|
knowledgeBase,
|
|
14761
14515
|
systemPrompt,
|
|
@@ -14779,7 +14533,7 @@ function AthenaProvider({
|
|
|
14779
14533
|
agent: agent2,
|
|
14780
14534
|
tools,
|
|
14781
14535
|
frontendToolIds: frontendToolNames,
|
|
14782
|
-
frontendTools,
|
|
14536
|
+
frontendTools: effectiveFrontendTools,
|
|
14783
14537
|
workbench,
|
|
14784
14538
|
knowledgeBase,
|
|
14785
14539
|
systemPrompt,
|
|
@@ -46402,7 +46156,7 @@ const DEFAULT_PILL_STYLE = "border-gray-300 bg-gray-50 text-gray-800 dark:border
|
|
|
46402
46156
|
function MentionNodeView({ node }) {
|
|
46403
46157
|
const { type, name, params } = node.attrs;
|
|
46404
46158
|
const config2 = getMentionConfig(type);
|
|
46405
|
-
const icon = isRecord(params) && typeof params.icon === "string" ? params.icon : (config2 == null ? void 0 : config2.style.icon) ?? "📎";
|
|
46159
|
+
const icon = isRecord$1(params) && typeof params.icon === "string" ? params.icon : (config2 == null ? void 0 : config2.style.icon) ?? "📎";
|
|
46406
46160
|
const pillStyle = PILL_STYLES[type] ?? DEFAULT_PILL_STYLE;
|
|
46407
46161
|
return /* @__PURE__ */ jsxRuntime.jsx(NodeViewWrapper, { as: "span", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
46408
46162
|
"span",
|
|
@@ -49668,7 +49422,7 @@ function getToolMeta(toolName) {
|
|
|
49668
49422
|
const displayName = toolName.replace(/_/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
|
|
49669
49423
|
return { displayName, icon: Wrench };
|
|
49670
49424
|
}
|
|
49671
|
-
function tryParseJson$
|
|
49425
|
+
function tryParseJson$1(text2) {
|
|
49672
49426
|
try {
|
|
49673
49427
|
const parsed = JSON.parse(text2);
|
|
49674
49428
|
if (typeof parsed === "object" && parsed !== null) return parsed;
|
|
@@ -49678,7 +49432,7 @@ function tryParseJson$2(text2) {
|
|
|
49678
49432
|
}
|
|
49679
49433
|
function extractResultMessage(result) {
|
|
49680
49434
|
if (typeof result === "string") {
|
|
49681
|
-
const parsed = tryParseJson$
|
|
49435
|
+
const parsed = tryParseJson$1(result);
|
|
49682
49436
|
if (parsed && typeof parsed.message === "string") return parsed.message;
|
|
49683
49437
|
return null;
|
|
49684
49438
|
}
|
|
@@ -49690,7 +49444,7 @@ function extractResultMessage(result) {
|
|
|
49690
49444
|
}
|
|
49691
49445
|
function isResultSuccess(result) {
|
|
49692
49446
|
if (typeof result === "string") {
|
|
49693
|
-
const parsed = tryParseJson$
|
|
49447
|
+
const parsed = tryParseJson$1(result);
|
|
49694
49448
|
if (parsed) return parsed.success === true;
|
|
49695
49449
|
}
|
|
49696
49450
|
if (typeof result === "object" && result !== null) {
|
|
@@ -49712,7 +49466,7 @@ function extractAssetId$1(result) {
|
|
|
49712
49466
|
}
|
|
49713
49467
|
function extractAssetIdFromArgs(argsText) {
|
|
49714
49468
|
if (!argsText) return null;
|
|
49715
|
-
const parsed = tryParseJson$
|
|
49469
|
+
const parsed = tryParseJson$1(argsText);
|
|
49716
49470
|
if (!parsed) return null;
|
|
49717
49471
|
const id = parsed.asset_id ?? parsed.assetId;
|
|
49718
49472
|
if (typeof id === "string" && id.startsWith("asset_")) return id;
|
|
@@ -49742,7 +49496,7 @@ function isAssetTool(toolName, result) {
|
|
|
49742
49496
|
}
|
|
49743
49497
|
function extractTitle(argsText, result) {
|
|
49744
49498
|
if (argsText) {
|
|
49745
|
-
const args = tryParseJson$
|
|
49499
|
+
const args = tryParseJson$1(argsText);
|
|
49746
49500
|
if (args) {
|
|
49747
49501
|
const t = args.title ?? args.name ?? args.filename ?? args.sheet_name;
|
|
49748
49502
|
if (t) return t;
|
|
@@ -49823,7 +49577,7 @@ function ToolFallbackTrigger({
|
|
|
49823
49577
|
const success = isComplete && isResultSuccess(result);
|
|
49824
49578
|
const summary = React.useMemo(() => {
|
|
49825
49579
|
if (isRunning || !meta.describer || !argsText) return null;
|
|
49826
|
-
const parsed = tryParseJson$
|
|
49580
|
+
const parsed = tryParseJson$1(argsText);
|
|
49827
49581
|
if (!parsed) return null;
|
|
49828
49582
|
const desc = meta.describer(parsed);
|
|
49829
49583
|
return desc || null;
|
|
@@ -49932,7 +49686,7 @@ function ToolFallbackArgs({
|
|
|
49932
49686
|
...props
|
|
49933
49687
|
}) {
|
|
49934
49688
|
if (!argsText) return null;
|
|
49935
|
-
const parsed = tryParseJson$
|
|
49689
|
+
const parsed = tryParseJson$1(argsText);
|
|
49936
49690
|
if (!parsed) {
|
|
49937
49691
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("px-3", className), ...props, children: /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "whitespace-pre-wrap text-xs text-muted-foreground", children: argsText }) });
|
|
49938
49692
|
}
|
|
@@ -49956,7 +49710,7 @@ function ToolFallbackResult({
|
|
|
49956
49710
|
const displayValue = React.useMemo(() => {
|
|
49957
49711
|
if (result === void 0) return "";
|
|
49958
49712
|
if (typeof result === "string") {
|
|
49959
|
-
const parsed = tryParseJson$
|
|
49713
|
+
const parsed = tryParseJson$1(result);
|
|
49960
49714
|
return parsed ? JSON.stringify(parsed, null, 2) : result;
|
|
49961
49715
|
}
|
|
49962
49716
|
return JSON.stringify(result, null, 2);
|
|
@@ -50000,12 +49754,12 @@ function CopyToolSpec({
|
|
|
50000
49754
|
const handleCopy = React.useCallback(() => {
|
|
50001
49755
|
const spec = { tool_name: toolName };
|
|
50002
49756
|
if (argsText) {
|
|
50003
|
-
const parsed = tryParseJson$
|
|
49757
|
+
const parsed = tryParseJson$1(argsText);
|
|
50004
49758
|
spec.arguments = parsed ?? argsText;
|
|
50005
49759
|
}
|
|
50006
49760
|
if (result !== void 0) {
|
|
50007
49761
|
if (typeof result === "string") {
|
|
50008
|
-
const parsed = tryParseJson$
|
|
49762
|
+
const parsed = tryParseJson$1(result);
|
|
50009
49763
|
spec.result = parsed ?? result;
|
|
50010
49764
|
} else {
|
|
50011
49765
|
spec.result = result;
|
|
@@ -50194,17 +49948,6 @@ ToolFallback.Content = ToolFallbackContent;
|
|
|
50194
49948
|
ToolFallback.Args = ToolFallbackArgs;
|
|
50195
49949
|
ToolFallback.Result = ToolFallbackResult;
|
|
50196
49950
|
ToolFallback.Error = ToolFallbackError;
|
|
50197
|
-
function getAssetInfo(assetId) {
|
|
50198
|
-
return { name: assetId || "Document", icon: "doc" };
|
|
50199
|
-
}
|
|
50200
|
-
function tryParseJson$1(text2) {
|
|
50201
|
-
try {
|
|
50202
|
-
const p = JSON.parse(text2);
|
|
50203
|
-
return typeof p === "object" && p !== null ? p : null;
|
|
50204
|
-
} catch {
|
|
50205
|
-
return null;
|
|
50206
|
-
}
|
|
50207
|
-
}
|
|
50208
49951
|
const markdownPreviewExtensions = [
|
|
50209
49952
|
StarterKit.configure({
|
|
50210
49953
|
codeBlock: {
|
|
@@ -50253,10 +49996,10 @@ const AppendDocumentToolUIImpl = ({
|
|
|
50253
49996
|
const typedArgs = args;
|
|
50254
49997
|
const resultData = React.useMemo(() => {
|
|
50255
49998
|
if (!result) return null;
|
|
50256
|
-
if (typeof result === "string") return tryParseJson$
|
|
49999
|
+
if (typeof result === "string") return tryParseJson$2(result);
|
|
50257
50000
|
if (typeof result === "object") {
|
|
50258
50001
|
const obj = result;
|
|
50259
|
-
if (typeof obj.result === "string") return tryParseJson$
|
|
50002
|
+
if (typeof obj.result === "string") return tryParseJson$2(obj.result) ?? obj;
|
|
50260
50003
|
return obj;
|
|
50261
50004
|
}
|
|
50262
50005
|
return null;
|
|
@@ -50338,11 +50081,11 @@ const AppendDocumentToolUI = React.memo(
|
|
|
50338
50081
|
);
|
|
50339
50082
|
AppendDocumentToolUI.displayName = "AppendDocumentToolUI";
|
|
50340
50083
|
function normalizeResult$1(result) {
|
|
50341
|
-
if (typeof result === "string") return tryParseJson$
|
|
50084
|
+
if (typeof result === "string") return tryParseJson$2(result) ?? result;
|
|
50342
50085
|
if (typeof result === "object" && result !== null) {
|
|
50343
50086
|
const obj = result;
|
|
50344
50087
|
if (typeof obj.result === "string")
|
|
50345
|
-
return tryParseJson$
|
|
50088
|
+
return tryParseJson$2(obj.result) ?? obj.result;
|
|
50346
50089
|
return obj;
|
|
50347
50090
|
}
|
|
50348
50091
|
return result;
|
|
@@ -53584,7 +53327,7 @@ const useAthenaChatDefaultComponents = () => {
|
|
|
53584
53327
|
return value;
|
|
53585
53328
|
};
|
|
53586
53329
|
const AthenaDefaultAssistantMessage = () => {
|
|
53587
|
-
const { toolUIs, TextComponent, ReasoningComponent, EmptyComponent: EmptyComponent2, ActionBarComponent } = useAthenaChatDefaultComponents();
|
|
53330
|
+
const { toolUIs, TextComponent, ReasoningComponent, EmptyComponent: EmptyComponent2, ActionBarComponent, groupToolCalls } = useAthenaChatDefaultComponents();
|
|
53588
53331
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
53589
53332
|
AthenaAssistantMessage,
|
|
53590
53333
|
{
|
|
@@ -53592,7 +53335,8 @@ const AthenaDefaultAssistantMessage = () => {
|
|
|
53592
53335
|
TextComponent,
|
|
53593
53336
|
ReasoningComponent,
|
|
53594
53337
|
EmptyComponent: EmptyComponent2,
|
|
53595
|
-
ActionBarComponent
|
|
53338
|
+
ActionBarComponent,
|
|
53339
|
+
groupToolCalls
|
|
53596
53340
|
}
|
|
53597
53341
|
);
|
|
53598
53342
|
};
|
|
@@ -53601,15 +53345,15 @@ const AthenaDefaultUserMessage = () => {
|
|
|
53601
53345
|
return /* @__PURE__ */ jsxRuntime.jsx(AthenaUserMessage, { TextComponent });
|
|
53602
53346
|
};
|
|
53603
53347
|
const getReasoningTokensFromMetadata = (metadata) => {
|
|
53604
|
-
if (!isRecord(metadata)) {
|
|
53348
|
+
if (!isRecord$1(metadata)) {
|
|
53605
53349
|
return void 0;
|
|
53606
53350
|
}
|
|
53607
53351
|
const customMetadata = metadata.custom;
|
|
53608
|
-
if (!isRecord(customMetadata)) {
|
|
53352
|
+
if (!isRecord$1(customMetadata)) {
|
|
53609
53353
|
return void 0;
|
|
53610
53354
|
}
|
|
53611
53355
|
const athenaMetadata = customMetadata._athena;
|
|
53612
|
-
if (!isRecord(athenaMetadata)) {
|
|
53356
|
+
if (!isRecord$1(athenaMetadata)) {
|
|
53613
53357
|
return void 0;
|
|
53614
53358
|
}
|
|
53615
53359
|
const reasoningTokens = athenaMetadata.reasoningTokens;
|
|
@@ -53658,7 +53402,8 @@ const AthenaChat = ({
|
|
|
53658
53402
|
toolUIs,
|
|
53659
53403
|
mentionTools,
|
|
53660
53404
|
welcomeSuggestions = DEFAULT_SUGGESTIONS,
|
|
53661
|
-
components
|
|
53405
|
+
components,
|
|
53406
|
+
groupToolCalls = false
|
|
53662
53407
|
}) => {
|
|
53663
53408
|
var _a2, _b, _c;
|
|
53664
53409
|
const athenaConfig = useAthenaConfig();
|
|
@@ -53696,9 +53441,10 @@ const AthenaChat = ({
|
|
|
53696
53441
|
TextComponent: textComponent,
|
|
53697
53442
|
ReasoningComponent: reasoningComponent,
|
|
53698
53443
|
EmptyComponent: emptyComponent,
|
|
53699
|
-
ActionBarComponent: actionBarComponent
|
|
53444
|
+
ActionBarComponent: actionBarComponent,
|
|
53445
|
+
groupToolCalls
|
|
53700
53446
|
}),
|
|
53701
|
-
[actionBarComponent, emptyComponent, mergedToolUIs, reasoningComponent, textComponent]
|
|
53447
|
+
[actionBarComponent, emptyComponent, groupToolCalls, mergedToolUIs, reasoningComponent, textComponent]
|
|
53702
53448
|
);
|
|
53703
53449
|
const AssistantMessageComponent = (components == null ? void 0 : components.AssistantMessage) ?? AthenaDefaultAssistantMessage;
|
|
53704
53450
|
const UserMessageComponent = (components == null ? void 0 : components.UserMessage) ?? AthenaDefaultUserMessage;
|
|
@@ -53972,17 +53718,20 @@ const AthenaReasoningPart = ({
|
|
|
53972
53718
|
]
|
|
53973
53719
|
}
|
|
53974
53720
|
) }),
|
|
53975
|
-
/* @__PURE__ */ jsxRuntime.jsx(CollapsibleContent, { className: "pt-3", children: isRunning && !hasText ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "shimmer text-[13px] text-muted-foreground", children: "Analyzing..." }) :
|
|
53721
|
+
/* @__PURE__ */ jsxRuntime.jsx(CollapsibleContent, { className: "pt-3", children: isRunning && !hasText ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "shimmer text-[13px] text-muted-foreground", children: "Analyzing..." }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "aui-assistant-reasoning-body text-[13px] leading-relaxed", children: /* @__PURE__ */ jsxRuntime.jsx(EffectiveTextComponent, { ...reasoningTextProps }) }) })
|
|
53976
53722
|
]
|
|
53977
53723
|
}
|
|
53978
53724
|
);
|
|
53979
53725
|
};
|
|
53726
|
+
const groupAdjacentToolCalls = (part) => part.type === "tool-call" ? ["group-tool"] : null;
|
|
53727
|
+
const noToolGrouping = () => null;
|
|
53980
53728
|
const AthenaAssistantMessage = ({
|
|
53981
53729
|
toolUIs,
|
|
53982
53730
|
TextComponent = TiptapText,
|
|
53983
53731
|
ReasoningComponent,
|
|
53984
53732
|
EmptyComponent: EmptyComponent2 = AthenaAssistantMessageEmpty,
|
|
53985
|
-
ActionBarComponent = AthenaAssistantActionBar
|
|
53733
|
+
ActionBarComponent = AthenaAssistantActionBar,
|
|
53734
|
+
groupToolCalls = false
|
|
53986
53735
|
}) => {
|
|
53987
53736
|
const effectiveReasoningComponent = ReasoningComponent ?? AthenaReasoningPart;
|
|
53988
53737
|
const toolUIsWithNestedMessages = React.useMemo(() => {
|
|
@@ -53992,7 +53741,7 @@ const AthenaAssistantMessage = ({
|
|
|
53992
53741
|
}
|
|
53993
53742
|
return wrappedToolUIs;
|
|
53994
53743
|
}, [toolUIs]);
|
|
53995
|
-
const
|
|
53744
|
+
const nestedPtcComponents = React.useMemo(
|
|
53996
53745
|
() => ({
|
|
53997
53746
|
Text: TextComponent,
|
|
53998
53747
|
Reasoning: effectiveReasoningComponent,
|
|
@@ -54011,7 +53760,31 @@ const AthenaAssistantMessage = ({
|
|
|
54011
53760
|
"data-role": "assistant",
|
|
54012
53761
|
children: [
|
|
54013
53762
|
/* @__PURE__ */ jsxRuntime.jsx(AthenaReasoningTextComponentContext.Provider, { value: TextComponent, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "aui-assistant-message-content wrap-break-word px-2 text-foreground leading-relaxed", children: [
|
|
54014
|
-
/* @__PURE__ */ jsxRuntime.jsx(NestedPtcComponentsProvider, { components:
|
|
53763
|
+
/* @__PURE__ */ jsxRuntime.jsx(NestedPtcComponentsProvider, { components: nestedPtcComponents, children: /* @__PURE__ */ jsxRuntime.jsx(react$1.MessagePrimitive.GroupedParts, { groupBy: groupToolCalls ? groupAdjacentToolCalls : noToolGrouping, children: ({ part, children }) => {
|
|
53764
|
+
var _a2, _b;
|
|
53765
|
+
switch (part.type) {
|
|
53766
|
+
case "group-tool":
|
|
53767
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AthenaToolGroup, { count: ((_a2 = part.indices) == null ? void 0 : _a2.length) ?? 0, children });
|
|
53768
|
+
case "tool-call": {
|
|
53769
|
+
const ToolUI = toolUIsWithNestedMessages[part.toolName];
|
|
53770
|
+
const toolProps = part;
|
|
53771
|
+
return ToolUI ? /* @__PURE__ */ jsxRuntime.jsx(ToolUI, { ...toolProps }) : /* @__PURE__ */ jsxRuntime.jsx(ToolFallback, { ...toolProps });
|
|
53772
|
+
}
|
|
53773
|
+
case "reasoning": {
|
|
53774
|
+
const ReasoningRenderer = effectiveReasoningComponent;
|
|
53775
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ReasoningRenderer, { ...part });
|
|
53776
|
+
}
|
|
53777
|
+
case "text": {
|
|
53778
|
+
const textPart = part;
|
|
53779
|
+
if (textPart.text === "" && ((_b = textPart.status) == null ? void 0 : _b.type) === "running") {
|
|
53780
|
+
return /* @__PURE__ */ jsxRuntime.jsx(EmptyComponent2, { status: textPart.status });
|
|
53781
|
+
}
|
|
53782
|
+
return /* @__PURE__ */ jsxRuntime.jsx(TextComponent, { ...textPart });
|
|
53783
|
+
}
|
|
53784
|
+
default:
|
|
53785
|
+
return null;
|
|
53786
|
+
}
|
|
53787
|
+
} }) }),
|
|
54015
53788
|
/* @__PURE__ */ jsxRuntime.jsx(MessageError, {})
|
|
54016
53789
|
] }) }),
|
|
54017
53790
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "aui-assistant-message-footer mt-1 ml-2 flex", children: /* @__PURE__ */ jsxRuntime.jsx(ActionBarComponent, {}) })
|
|
@@ -54019,6 +53792,38 @@ const AthenaAssistantMessage = ({
|
|
|
54019
53792
|
}
|
|
54020
53793
|
);
|
|
54021
53794
|
};
|
|
53795
|
+
const AthenaToolGroup = ({ children, count: count2 }) => {
|
|
53796
|
+
const [expanded, setExpanded] = React.useState(false);
|
|
53797
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "my-3 w-full overflow-hidden rounded-xl border border-border/60 bg-background shadow-sm", children: [
|
|
53798
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
53799
|
+
"button",
|
|
53800
|
+
{
|
|
53801
|
+
type: "button",
|
|
53802
|
+
onClick: () => setExpanded((v) => !v),
|
|
53803
|
+
className: "flex w-full items-center gap-3 px-4 py-3 text-left transition-colors hover:bg-muted/20",
|
|
53804
|
+
"aria-expanded": expanded,
|
|
53805
|
+
children: [
|
|
53806
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex size-8 shrink-0 items-center justify-center rounded-lg bg-muted/60 text-muted-foreground", children: /* @__PURE__ */ jsxRuntime.jsx(Layers, { className: "size-4" }) }),
|
|
53807
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-[13px] font-medium text-foreground", children: [
|
|
53808
|
+
count2,
|
|
53809
|
+
" tool ",
|
|
53810
|
+
count2 === 1 ? "call" : "calls"
|
|
53811
|
+
] }) }),
|
|
53812
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
53813
|
+
ChevronDown,
|
|
53814
|
+
{
|
|
53815
|
+
className: cn(
|
|
53816
|
+
"size-4 shrink-0 text-muted-foreground transition-transform duration-200",
|
|
53817
|
+
!expanded && "-rotate-90"
|
|
53818
|
+
)
|
|
53819
|
+
}
|
|
53820
|
+
)
|
|
53821
|
+
]
|
|
53822
|
+
}
|
|
53823
|
+
),
|
|
53824
|
+
expanded && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-t border-border/40 bg-muted/5 px-3 pt-1 pb-2 [&>*]:my-2", children })
|
|
53825
|
+
] });
|
|
53826
|
+
};
|
|
54022
53827
|
const AthenaAssistantActionBar = ({ className }) => {
|
|
54023
53828
|
const threadId = useAthenaThreadId();
|
|
54024
53829
|
const { appUrl } = useAthenaConfig();
|
|
@@ -54204,7 +54009,7 @@ function buildPresentationNavigationMessage({
|
|
|
54204
54009
|
assetType,
|
|
54205
54010
|
slideNumber
|
|
54206
54011
|
}) {
|
|
54207
|
-
if (assetType !== "presentation" || typeof slideNumber !== "number" || !Number.isInteger(slideNumber) || slideNumber < 1) {
|
|
54012
|
+
if (!assetId.trim() || assetType !== "presentation" || typeof slideNumber !== "number" || !Number.isInteger(slideNumber) || slideNumber < 1) {
|
|
54208
54013
|
return null;
|
|
54209
54014
|
}
|
|
54210
54015
|
return {
|
|
@@ -54231,13 +54036,24 @@ const AssetIframe = React.memo(
|
|
|
54231
54036
|
apiKey,
|
|
54232
54037
|
token
|
|
54233
54038
|
});
|
|
54039
|
+
const initialSlideRef = React.useRef({
|
|
54040
|
+
assetId: tab.id,
|
|
54041
|
+
slideNumber: tab.slideNumber
|
|
54042
|
+
});
|
|
54043
|
+
if (initialSlideRef.current.assetId !== tab.id) {
|
|
54044
|
+
initialSlideRef.current = {
|
|
54045
|
+
assetId: tab.id,
|
|
54046
|
+
slideNumber: tab.slideNumber
|
|
54047
|
+
};
|
|
54048
|
+
}
|
|
54049
|
+
const initialSlideNumber = initialSlideRef.current.slideNumber;
|
|
54234
54050
|
const iframeSrc = React.useMemo(
|
|
54235
54051
|
() => embedUrl ? buildAssetIframeSrc({
|
|
54236
54052
|
embedUrl,
|
|
54237
54053
|
assetType: tab.type,
|
|
54238
|
-
slideNumber:
|
|
54054
|
+
slideNumber: initialSlideNumber
|
|
54239
54055
|
}) : null,
|
|
54240
|
-
[embedUrl,
|
|
54056
|
+
[embedUrl, initialSlideNumber, tab.type]
|
|
54241
54057
|
);
|
|
54242
54058
|
const navigationMessage = React.useMemo(
|
|
54243
54059
|
() => buildPresentationNavigationMessage({
|
|
@@ -54247,11 +54063,22 @@ const AssetIframe = React.memo(
|
|
|
54247
54063
|
}),
|
|
54248
54064
|
[tab.id, tab.slideNumber, tab.type]
|
|
54249
54065
|
);
|
|
54066
|
+
const navigationTargetOrigin = React.useMemo(() => {
|
|
54067
|
+
if (!iframeSrc) return null;
|
|
54068
|
+
try {
|
|
54069
|
+
return new URL(iframeSrc, window.location.href).origin;
|
|
54070
|
+
} catch {
|
|
54071
|
+
return null;
|
|
54072
|
+
}
|
|
54073
|
+
}, [iframeSrc]);
|
|
54250
54074
|
const postNavigationMessage = React.useCallback(() => {
|
|
54251
54075
|
var _a2, _b;
|
|
54252
|
-
if (!navigationMessage) return;
|
|
54253
|
-
(_b = (_a2 = iframeRef.current) == null ? void 0 : _a2.contentWindow) == null ? void 0 : _b.postMessage(
|
|
54254
|
-
|
|
54076
|
+
if (!navigationMessage || !navigationTargetOrigin) return;
|
|
54077
|
+
(_b = (_a2 = iframeRef.current) == null ? void 0 : _a2.contentWindow) == null ? void 0 : _b.postMessage(
|
|
54078
|
+
navigationMessage,
|
|
54079
|
+
navigationTargetOrigin
|
|
54080
|
+
);
|
|
54081
|
+
}, [navigationMessage, navigationTargetOrigin]);
|
|
54255
54082
|
React.useEffect(() => {
|
|
54256
54083
|
postNavigationMessage();
|
|
54257
54084
|
}, [postNavigationMessage]);
|
|
@@ -54606,6 +54433,7 @@ exports.CreatePresentationToolUI = CreatePresentationToolUI;
|
|
|
54606
54433
|
exports.CreateSheetToolUI = CreateSheetToolUI;
|
|
54607
54434
|
exports.DEFAULT_API_URL = DEFAULT_API_URL;
|
|
54608
54435
|
exports.DEFAULT_APP_URL = DEFAULT_APP_URL;
|
|
54436
|
+
exports.DEFAULT_AUTO_OPEN_TOOLS = DEFAULT_AUTO_OPEN_TOOLS;
|
|
54609
54437
|
exports.DEFAULT_BACKEND_URL = DEFAULT_BACKEND_URL;
|
|
54610
54438
|
exports.DescribeDatabaseToolUI = DescribeDatabaseToolUI;
|
|
54611
54439
|
exports.EmailSearchToolUI = EmailSearchToolUI;
|
|
@@ -54659,7 +54487,7 @@ exports.resetAssetAutoOpen = resetAssetAutoOpen;
|
|
|
54659
54487
|
exports.themeToStyleVars = themeToStyleVars;
|
|
54660
54488
|
exports.themes = themes;
|
|
54661
54489
|
exports.truncate = truncate;
|
|
54662
|
-
exports.tryParseJson = tryParseJson$
|
|
54490
|
+
exports.tryParseJson = tryParseJson$2;
|
|
54663
54491
|
exports.useAppendToComposer = useAppendToComposer;
|
|
54664
54492
|
exports.useAssetEmbed = useAssetEmbed;
|
|
54665
54493
|
exports.useAssetPanelStore = useAssetPanelStore;
|