@athenaintel/react 0.10.33 → 0.10.34
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 +466 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +466 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -47653,8 +47653,8 @@ const MentionExtension = Node$1.create({
|
|
|
47653
47653
|
};
|
|
47654
47654
|
}
|
|
47655
47655
|
});
|
|
47656
|
-
const ATHENA_APP_HOSTNAMES = /* @__PURE__ */ new Set(["app.athenaintel.com", "staging-app.athenaintel.com"]);
|
|
47657
|
-
const ATHENA_PREVIEW_HOSTNAME_SUFFIX = ".previews.athenaintel.com";
|
|
47656
|
+
const ATHENA_APP_HOSTNAMES$1 = /* @__PURE__ */ new Set(["app.athenaintel.com", "staging-app.athenaintel.com"]);
|
|
47657
|
+
const ATHENA_PREVIEW_HOSTNAME_SUFFIX$1 = ".previews.athenaintel.com";
|
|
47658
47658
|
const ATHENA_WORKSPACE_HOSTNAME_SUFFIXES = [".app.athenaintel.com", ".staging-app.athenaintel.com"];
|
|
47659
47659
|
const ASSET_TYPE_ALIASES = {
|
|
47660
47660
|
document: "document",
|
|
@@ -47674,7 +47674,7 @@ const normalizeAssetType = (value) => {
|
|
|
47674
47674
|
const normalizedValue = value.trim().replace(/^athena\//, "").toLowerCase().replace(/-/g, "_");
|
|
47675
47675
|
return ASSET_TYPE_ALIASES[normalizedValue] ?? null;
|
|
47676
47676
|
};
|
|
47677
|
-
const getOrigin = (value) => {
|
|
47677
|
+
const getOrigin$1 = (value) => {
|
|
47678
47678
|
if (!value) {
|
|
47679
47679
|
return null;
|
|
47680
47680
|
}
|
|
@@ -47698,7 +47698,7 @@ const matchesHostnameOrSubdomain = ({
|
|
|
47698
47698
|
hostname,
|
|
47699
47699
|
candidateHostname
|
|
47700
47700
|
}) => hostname === candidateHostname || hostname.endsWith(`.${candidateHostname}`);
|
|
47701
|
-
const getCurrentOrigin = () => {
|
|
47701
|
+
const getCurrentOrigin$1 = () => {
|
|
47702
47702
|
if (typeof window === "undefined") {
|
|
47703
47703
|
return null;
|
|
47704
47704
|
}
|
|
@@ -47708,7 +47708,7 @@ const parseUrl = ({
|
|
|
47708
47708
|
href,
|
|
47709
47709
|
appUrl
|
|
47710
47710
|
}) => {
|
|
47711
|
-
const fallbackBase = appUrl ?? getCurrentOrigin() ?? "https://app.athenaintel.com";
|
|
47711
|
+
const fallbackBase = appUrl ?? getCurrentOrigin$1() ?? "https://app.athenaintel.com";
|
|
47712
47712
|
try {
|
|
47713
47713
|
return new URL(href, fallbackBase);
|
|
47714
47714
|
} catch {
|
|
@@ -47720,18 +47720,18 @@ const isAthenaAppUrl = ({
|
|
|
47720
47720
|
appUrl
|
|
47721
47721
|
}) => {
|
|
47722
47722
|
const hostname = url.hostname.toLowerCase();
|
|
47723
|
-
if (ATHENA_APP_HOSTNAMES.has(hostname) || hostname.endsWith(ATHENA_PREVIEW_HOSTNAME_SUFFIX) || ATHENA_WORKSPACE_HOSTNAME_SUFFIXES.some((suffix) => hostname.endsWith(suffix))) {
|
|
47723
|
+
if (ATHENA_APP_HOSTNAMES$1.has(hostname) || hostname.endsWith(ATHENA_PREVIEW_HOSTNAME_SUFFIX$1) || ATHENA_WORKSPACE_HOSTNAME_SUFFIXES.some((suffix) => hostname.endsWith(suffix))) {
|
|
47724
47724
|
return true;
|
|
47725
47725
|
}
|
|
47726
47726
|
const configuredHostname = getHostname(appUrl);
|
|
47727
47727
|
if (configuredHostname && matchesHostnameOrSubdomain({ hostname, candidateHostname: configuredHostname })) {
|
|
47728
47728
|
return true;
|
|
47729
47729
|
}
|
|
47730
|
-
const configuredOrigin = getOrigin(appUrl);
|
|
47730
|
+
const configuredOrigin = getOrigin$1(appUrl);
|
|
47731
47731
|
if (configuredOrigin && url.origin === configuredOrigin) {
|
|
47732
47732
|
return true;
|
|
47733
47733
|
}
|
|
47734
|
-
const currentOrigin = getCurrentOrigin();
|
|
47734
|
+
const currentOrigin = getCurrentOrigin$1();
|
|
47735
47735
|
return !!currentOrigin && url.origin === currentOrigin;
|
|
47736
47736
|
};
|
|
47737
47737
|
const parseAthenaCitationLink = ({
|
|
@@ -52012,6 +52012,12 @@ function getNumberField(source, keys2) {
|
|
|
52012
52012
|
}
|
|
52013
52013
|
return null;
|
|
52014
52014
|
}
|
|
52015
|
+
function asRecord(value) {
|
|
52016
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
52017
|
+
return null;
|
|
52018
|
+
}
|
|
52019
|
+
return value;
|
|
52020
|
+
}
|
|
52015
52021
|
const PRESENTATION_CODE_SLIDE_NUMBER_KEYS = [
|
|
52016
52022
|
"slideNumber",
|
|
52017
52023
|
"slide_number",
|
|
@@ -53765,6 +53771,374 @@ const UpdateSheetRangeToolUI = memo(
|
|
|
53765
53771
|
UpdateSheetRangeToolUIImpl
|
|
53766
53772
|
);
|
|
53767
53773
|
UpdateSheetRangeToolUI.displayName = "UpdateSheetRangeToolUI";
|
|
53774
|
+
function parseJsonArray(text2) {
|
|
53775
|
+
try {
|
|
53776
|
+
const parsed = JSON.parse(text2);
|
|
53777
|
+
return Array.isArray(parsed) ? parsed : null;
|
|
53778
|
+
} catch {
|
|
53779
|
+
return null;
|
|
53780
|
+
}
|
|
53781
|
+
}
|
|
53782
|
+
function getFirstSheetCellStyle(operation) {
|
|
53783
|
+
const cells = operation.cells;
|
|
53784
|
+
const rows = typeof cells === "string" ? parseJsonArray(cells) : cells;
|
|
53785
|
+
if (!Array.isArray(rows)) {
|
|
53786
|
+
return null;
|
|
53787
|
+
}
|
|
53788
|
+
for (const row of rows) {
|
|
53789
|
+
if (!Array.isArray(row)) {
|
|
53790
|
+
continue;
|
|
53791
|
+
}
|
|
53792
|
+
for (const cell of row) {
|
|
53793
|
+
const cellRecord = asRecord(cell);
|
|
53794
|
+
const style2 = asRecord(
|
|
53795
|
+
(cellRecord == null ? void 0 : cellRecord.cellStyles) ?? (cellRecord == null ? void 0 : cellRecord.cell_styles) ?? (cellRecord == null ? void 0 : cellRecord.style)
|
|
53796
|
+
);
|
|
53797
|
+
if (style2) {
|
|
53798
|
+
return style2;
|
|
53799
|
+
}
|
|
53800
|
+
}
|
|
53801
|
+
}
|
|
53802
|
+
return null;
|
|
53803
|
+
}
|
|
53804
|
+
function summarizeSheetCellStyle(style2) {
|
|
53805
|
+
if (!style2) {
|
|
53806
|
+
return "Cell formatting";
|
|
53807
|
+
}
|
|
53808
|
+
const parts = [];
|
|
53809
|
+
const textFormat = asRecord(style2.textFormat ?? style2.text_format);
|
|
53810
|
+
if ((textFormat == null ? void 0 : textFormat.bold) === true) {
|
|
53811
|
+
parts.push("bold");
|
|
53812
|
+
}
|
|
53813
|
+
if ((textFormat == null ? void 0 : textFormat.italic) === true) {
|
|
53814
|
+
parts.push("italic");
|
|
53815
|
+
}
|
|
53816
|
+
if ((textFormat == null ? void 0 : textFormat.underline) === true) {
|
|
53817
|
+
parts.push("underline");
|
|
53818
|
+
}
|
|
53819
|
+
const fontSize = getNumberField(textFormat, ["fontSize", "font_size"]);
|
|
53820
|
+
if (fontSize != null) {
|
|
53821
|
+
parts.push(`${fontSize} pt`);
|
|
53822
|
+
}
|
|
53823
|
+
const textColor = getStringField(textFormat, [
|
|
53824
|
+
"color_hex",
|
|
53825
|
+
"colorHex",
|
|
53826
|
+
"foregroundColor_hex",
|
|
53827
|
+
"foregroundColorHex"
|
|
53828
|
+
]);
|
|
53829
|
+
if (textColor) {
|
|
53830
|
+
parts.push(`text ${textColor}`);
|
|
53831
|
+
}
|
|
53832
|
+
const fillColor = getStringField(style2, [
|
|
53833
|
+
"backgroundColor_hex",
|
|
53834
|
+
"backgroundColorHex",
|
|
53835
|
+
"background_color_hex"
|
|
53836
|
+
]);
|
|
53837
|
+
if (fillColor) {
|
|
53838
|
+
parts.push(`fill ${fillColor}`);
|
|
53839
|
+
}
|
|
53840
|
+
const numberFormat = asRecord(style2.numberFormat ?? style2.number_format);
|
|
53841
|
+
const numberPattern = getStringField(numberFormat, ["pattern"]);
|
|
53842
|
+
const numberType = getStringField(numberFormat, ["type"]);
|
|
53843
|
+
if (numberPattern) {
|
|
53844
|
+
parts.push(numberPattern);
|
|
53845
|
+
} else if (numberType) {
|
|
53846
|
+
parts.push(numberType.toLowerCase());
|
|
53847
|
+
}
|
|
53848
|
+
const horizontalAlignment = getStringField(style2, [
|
|
53849
|
+
"horizontalAlignment",
|
|
53850
|
+
"horizontal_alignment"
|
|
53851
|
+
]);
|
|
53852
|
+
if (horizontalAlignment) {
|
|
53853
|
+
parts.push(`${horizontalAlignment.toLowerCase()} align`);
|
|
53854
|
+
}
|
|
53855
|
+
return parts.length > 0 ? parts.slice(0, 5).join(", ") : "Cell formatting";
|
|
53856
|
+
}
|
|
53857
|
+
function parseSheetFormatOperations(operationsValue) {
|
|
53858
|
+
const operations = typeof operationsValue === "string" ? parseJsonArray(operationsValue) : operationsValue;
|
|
53859
|
+
if (!Array.isArray(operations)) {
|
|
53860
|
+
return [];
|
|
53861
|
+
}
|
|
53862
|
+
return operations.flatMap((operation) => {
|
|
53863
|
+
const record2 = asRecord(operation);
|
|
53864
|
+
if (!record2) {
|
|
53865
|
+
return [];
|
|
53866
|
+
}
|
|
53867
|
+
const range = getStringField(record2, ["range"]) ?? "";
|
|
53868
|
+
if (!range) {
|
|
53869
|
+
return [];
|
|
53870
|
+
}
|
|
53871
|
+
const assetId = getStringField(record2, ["asset_id", "assetId", "id"]);
|
|
53872
|
+
return [
|
|
53873
|
+
{
|
|
53874
|
+
assetId: (assetId == null ? void 0 : assetId.startsWith("asset_")) ? assetId : null,
|
|
53875
|
+
explanation: getStringField(record2, ["explanation", "summary"]),
|
|
53876
|
+
range,
|
|
53877
|
+
styleSummary: summarizeSheetCellStyle(getFirstSheetCellStyle(record2))
|
|
53878
|
+
}
|
|
53879
|
+
];
|
|
53880
|
+
});
|
|
53881
|
+
}
|
|
53882
|
+
function getSpreadsheetAssetIdFromOperations(operations) {
|
|
53883
|
+
var _a2;
|
|
53884
|
+
return ((_a2 = operations.find((operation) => operation.assetId)) == null ? void 0 : _a2.assetId) ?? null;
|
|
53885
|
+
}
|
|
53886
|
+
function getSpreadsheetAssetIdFromArgs(args) {
|
|
53887
|
+
const assetId = getStringField(args, ["asset_id", "assetId", "id"]);
|
|
53888
|
+
return (assetId == null ? void 0 : assetId.startsWith("asset_")) ? assetId : null;
|
|
53889
|
+
}
|
|
53890
|
+
function summarizeSheetRanges(ranges) {
|
|
53891
|
+
if (ranges.length === 0) {
|
|
53892
|
+
return void 0;
|
|
53893
|
+
}
|
|
53894
|
+
const visible = ranges.slice(0, 4);
|
|
53895
|
+
const remaining = ranges.length - visible.length;
|
|
53896
|
+
return remaining > 0 ? `${visible.join(", ")} +${remaining} more` : visible.join(", ");
|
|
53897
|
+
}
|
|
53898
|
+
const BulkFormatSheetRangeToolUIImpl = ({
|
|
53899
|
+
toolName,
|
|
53900
|
+
args,
|
|
53901
|
+
result,
|
|
53902
|
+
status
|
|
53903
|
+
}) => {
|
|
53904
|
+
const typedArgs = args;
|
|
53905
|
+
const data = useMemo(() => normalizeResult(result), [result]);
|
|
53906
|
+
const operations = useMemo(
|
|
53907
|
+
() => parseSheetFormatOperations(typedArgs == null ? void 0 : typedArgs.operations),
|
|
53908
|
+
[typedArgs == null ? void 0 : typedArgs.operations]
|
|
53909
|
+
);
|
|
53910
|
+
const resultAssetId = extractAssetId(result);
|
|
53911
|
+
const argsAssetId = getSpreadsheetAssetIdFromArgs(typedArgs);
|
|
53912
|
+
const operationsAssetId = getSpreadsheetAssetIdFromOperations(operations);
|
|
53913
|
+
const effectiveAssetId = resultAssetId ?? argsAssetId ?? operationsAssetId;
|
|
53914
|
+
const isRunning = (status == null ? void 0 : status.type) === "running";
|
|
53915
|
+
const isComplete = (status == null ? void 0 : status.type) === "complete";
|
|
53916
|
+
const errorMsg = (status == null ? void 0 : status.type) === "incomplete" ? status.error : null;
|
|
53917
|
+
const totalCount = getNumberField(data, ["total"]) ?? operations.length;
|
|
53918
|
+
const succeededCount = getNumberField(data, ["succeeded", "success_count", "successCount"]) ?? (isComplete && totalCount > 0 ? Math.max(totalCount - (getNumberField(data, ["failed"]) ?? 0), 0) : null);
|
|
53919
|
+
const failedCount = getNumberField(data, [
|
|
53920
|
+
"failed",
|
|
53921
|
+
"failure_count",
|
|
53922
|
+
"failureCount"
|
|
53923
|
+
]);
|
|
53924
|
+
const rangesSummary = summarizeSheetRanges(
|
|
53925
|
+
operations.map((operation) => operation.range)
|
|
53926
|
+
);
|
|
53927
|
+
const visibleOperations = operations.slice(0, 24);
|
|
53928
|
+
const openAsset = useAssetPanelStore((s) => s.openAsset);
|
|
53929
|
+
const title = isRunning ? totalCount > 0 ? `Formatting ${totalCount} sheet ${totalCount === 1 ? "range" : "ranges"}...` : "Formatting spreadsheet ranges..." : failedCount && failedCount > 0 ? `Formatted ${succeededCount ?? 0} of ${totalCount} sheet ranges` : totalCount > 0 ? `Formatted ${totalCount} sheet ${totalCount === 1 ? "range" : "ranges"}` : "Formatted spreadsheet ranges";
|
|
53930
|
+
return /* @__PURE__ */ jsxs(
|
|
53931
|
+
ToolCard,
|
|
53932
|
+
{
|
|
53933
|
+
icon: TableProperties,
|
|
53934
|
+
status: (status == null ? void 0 : status.type) ?? "complete",
|
|
53935
|
+
title: truncate(title, 80),
|
|
53936
|
+
subtitle: rangesSummary,
|
|
53937
|
+
toolName,
|
|
53938
|
+
args: typedArgs,
|
|
53939
|
+
result,
|
|
53940
|
+
badge: failedCount && failedCount > 0 ? `${failedCount} failed` : totalCount > 0 ? `${totalCount} ops` : void 0,
|
|
53941
|
+
error: errorMsg,
|
|
53942
|
+
children: [
|
|
53943
|
+
operations.length > 0 && /* @__PURE__ */ jsxs(
|
|
53944
|
+
ExpandableSection,
|
|
53945
|
+
{
|
|
53946
|
+
label: `Show formatting operations (${operations.length})`,
|
|
53947
|
+
defaultOpen: operations.length <= 6,
|
|
53948
|
+
children: [
|
|
53949
|
+
/* @__PURE__ */ jsx("div", { className: "overflow-x-auto", children: /* @__PURE__ */ jsxs("table", { className: "w-full text-[11px]", children: [
|
|
53950
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { className: "border-b border-border/40 text-left text-muted-foreground", children: [
|
|
53951
|
+
/* @__PURE__ */ jsx("th", { className: "w-20 pb-1.5 pr-3 font-medium", children: "Range" }),
|
|
53952
|
+
/* @__PURE__ */ jsx("th", { className: "pb-1.5 pr-3 font-medium", children: "Purpose" }),
|
|
53953
|
+
/* @__PURE__ */ jsx("th", { className: "pb-1.5 font-medium", children: "Style" })
|
|
53954
|
+
] }) }),
|
|
53955
|
+
/* @__PURE__ */ jsx("tbody", { children: visibleOperations.map((operation, index2) => /* @__PURE__ */ jsxs(
|
|
53956
|
+
"tr",
|
|
53957
|
+
{
|
|
53958
|
+
className: "border-t border-border/25 first:border-t-0",
|
|
53959
|
+
children: [
|
|
53960
|
+
/* @__PURE__ */ jsx("td", { className: "whitespace-nowrap py-1.5 pr-3 font-mono text-foreground/80", children: operation.range }),
|
|
53961
|
+
/* @__PURE__ */ jsx("td", { className: "max-w-[220px] py-1.5 pr-3 text-foreground/75", children: operation.explanation ? truncate(operation.explanation, 72) : /* @__PURE__ */ jsx("span", { className: "text-muted-foreground/40", children: "-" }) }),
|
|
53962
|
+
/* @__PURE__ */ jsx("td", { className: "max-w-[260px] py-1.5 text-muted-foreground", children: truncate(operation.styleSummary, 80) })
|
|
53963
|
+
]
|
|
53964
|
+
},
|
|
53965
|
+
`${operation.range}-${index2}`
|
|
53966
|
+
)) })
|
|
53967
|
+
] }) }),
|
|
53968
|
+
operations.length > visibleOperations.length && /* @__PURE__ */ jsxs("div", { className: "pt-2 text-[10px] text-muted-foreground", children: [
|
|
53969
|
+
"Showing first ",
|
|
53970
|
+
visibleOperations.length,
|
|
53971
|
+
" of ",
|
|
53972
|
+
operations.length,
|
|
53973
|
+
" operations"
|
|
53974
|
+
] })
|
|
53975
|
+
]
|
|
53976
|
+
}
|
|
53977
|
+
),
|
|
53978
|
+
effectiveAssetId && isComplete && !errorMsg && /* @__PURE__ */ jsx("div", { className: "border-t border-border/40 px-4 py-2", children: /* @__PURE__ */ jsxs(
|
|
53979
|
+
"button",
|
|
53980
|
+
{
|
|
53981
|
+
type: "button",
|
|
53982
|
+
onClick: () => openAsset(effectiveAssetId, { type: "spreadsheet" }),
|
|
53983
|
+
className: "flex items-center gap-1.5 rounded-md border border-border/60 px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",
|
|
53984
|
+
children: [
|
|
53985
|
+
/* @__PURE__ */ jsx(ExternalLink, { className: "size-3" }),
|
|
53986
|
+
"Open spreadsheet"
|
|
53987
|
+
]
|
|
53988
|
+
}
|
|
53989
|
+
) })
|
|
53990
|
+
]
|
|
53991
|
+
}
|
|
53992
|
+
);
|
|
53993
|
+
};
|
|
53994
|
+
const BulkFormatSheetRangeToolUI = memo(
|
|
53995
|
+
BulkFormatSheetRangeToolUIImpl
|
|
53996
|
+
);
|
|
53997
|
+
BulkFormatSheetRangeToolUI.displayName = "BulkFormatSheetRangeToolUI";
|
|
53998
|
+
function formatDimensionUnit(unit) {
|
|
53999
|
+
if (!unit) {
|
|
54000
|
+
return "";
|
|
54001
|
+
}
|
|
54002
|
+
const normalized = unit.toLowerCase();
|
|
54003
|
+
if (normalized === "pixels" || normalized === "pixel") {
|
|
54004
|
+
return "pixels";
|
|
54005
|
+
}
|
|
54006
|
+
if (normalized === "points" || normalized === "point") {
|
|
54007
|
+
return "points";
|
|
54008
|
+
}
|
|
54009
|
+
return unit;
|
|
54010
|
+
}
|
|
54011
|
+
function formatShortDimensionUnit(unit) {
|
|
54012
|
+
const normalized = unit == null ? void 0 : unit.toLowerCase();
|
|
54013
|
+
if (normalized === "pixels" || normalized === "pixel") {
|
|
54014
|
+
return "px";
|
|
54015
|
+
}
|
|
54016
|
+
if (normalized === "points" || normalized === "point") {
|
|
54017
|
+
return "pt";
|
|
54018
|
+
}
|
|
54019
|
+
return unit ?? "";
|
|
54020
|
+
}
|
|
54021
|
+
function parseDimensionMeasurement(value) {
|
|
54022
|
+
const record2 = asRecord(value);
|
|
54023
|
+
if (record2) {
|
|
54024
|
+
const numericValue = getNumberField(record2, ["value"]);
|
|
54025
|
+
const stringValue = getStringField(record2, ["value"]);
|
|
54026
|
+
const rawValue = numericValue != null ? String(numericValue) : stringValue ? stringValue : null;
|
|
54027
|
+
if (!rawValue) {
|
|
54028
|
+
return null;
|
|
54029
|
+
}
|
|
54030
|
+
const unit = getStringField(record2, ["type", "unit"]);
|
|
54031
|
+
const formattedUnit = formatDimensionUnit(unit);
|
|
54032
|
+
const shortUnit = formatShortDimensionUnit(unit);
|
|
54033
|
+
return {
|
|
54034
|
+
value: formattedUnit ? `${rawValue} ${formattedUnit}` : rawValue,
|
|
54035
|
+
shortValue: shortUnit ? `${rawValue} ${shortUnit}` : rawValue
|
|
54036
|
+
};
|
|
54037
|
+
}
|
|
54038
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
54039
|
+
return { value: String(value), shortValue: String(value) };
|
|
54040
|
+
}
|
|
54041
|
+
if (typeof value === "string" && value.trim()) {
|
|
54042
|
+
return { value, shortValue: value };
|
|
54043
|
+
}
|
|
54044
|
+
return null;
|
|
54045
|
+
}
|
|
54046
|
+
function getSheetDimensionSummary(args) {
|
|
54047
|
+
const width = parseDimensionMeasurement(args == null ? void 0 : args.width);
|
|
54048
|
+
if (width) {
|
|
54049
|
+
return {
|
|
54050
|
+
kind: "column width",
|
|
54051
|
+
shortValue: width.shortValue,
|
|
54052
|
+
value: width.value
|
|
54053
|
+
};
|
|
54054
|
+
}
|
|
54055
|
+
const height = parseDimensionMeasurement(args == null ? void 0 : args.height);
|
|
54056
|
+
if (height) {
|
|
54057
|
+
return {
|
|
54058
|
+
kind: "row height",
|
|
54059
|
+
shortValue: height.shortValue,
|
|
54060
|
+
value: height.value
|
|
54061
|
+
};
|
|
54062
|
+
}
|
|
54063
|
+
return {
|
|
54064
|
+
kind: "row and column dimensions",
|
|
54065
|
+
shortValue: null,
|
|
54066
|
+
value: null
|
|
54067
|
+
};
|
|
54068
|
+
}
|
|
54069
|
+
function getToolResultText(result, data) {
|
|
54070
|
+
if (typeof result === "string" && result.trim()) {
|
|
54071
|
+
return result;
|
|
54072
|
+
}
|
|
54073
|
+
return getStringField(data, ["message", "result", "summary"]);
|
|
54074
|
+
}
|
|
54075
|
+
const SetRowColumnDimensionsToolUIImpl = ({
|
|
54076
|
+
toolName,
|
|
54077
|
+
args,
|
|
54078
|
+
result,
|
|
54079
|
+
status
|
|
54080
|
+
}) => {
|
|
54081
|
+
const typedArgs = args;
|
|
54082
|
+
const data = useMemo(() => normalizeResult(result), [result]);
|
|
54083
|
+
const range = getStringField(typedArgs, ["range"]) ?? "";
|
|
54084
|
+
const dimension = getSheetDimensionSummary(typedArgs);
|
|
54085
|
+
const effectiveAssetId = extractAssetId(result) ?? getSpreadsheetAssetIdFromArgs(typedArgs);
|
|
54086
|
+
const resultText = getToolResultText(result, data);
|
|
54087
|
+
const openAsset = useAssetPanelStore((s) => s.openAsset);
|
|
54088
|
+
const isRunning = (status == null ? void 0 : status.type) === "running";
|
|
54089
|
+
const isComplete = (status == null ? void 0 : status.type) === "complete";
|
|
54090
|
+
const errorMsg = (status == null ? void 0 : status.type) === "incomplete" ? status.error : null;
|
|
54091
|
+
const title = isRunning ? `Setting ${dimension.kind}...` : range ? `Set ${dimension.kind} for ${range}` : `Set ${dimension.kind}`;
|
|
54092
|
+
return /* @__PURE__ */ jsxs(
|
|
54093
|
+
ToolCard,
|
|
54094
|
+
{
|
|
54095
|
+
icon: TableProperties,
|
|
54096
|
+
status: (status == null ? void 0 : status.type) ?? "complete",
|
|
54097
|
+
title: truncate(title, 80),
|
|
54098
|
+
subtitle: dimension.value ? `Value: ${dimension.value}` : void 0,
|
|
54099
|
+
toolName,
|
|
54100
|
+
args: typedArgs,
|
|
54101
|
+
result,
|
|
54102
|
+
badge: dimension.shortValue ?? void 0,
|
|
54103
|
+
error: errorMsg,
|
|
54104
|
+
children: [
|
|
54105
|
+
(range || dimension.value || resultText) && isComplete && /* @__PURE__ */ jsxs("div", { className: "border-t border-border/40 px-4 py-2.5", children: [
|
|
54106
|
+
/* @__PURE__ */ jsxs("dl", { className: "grid gap-2 text-[11px] sm:grid-cols-3", children: [
|
|
54107
|
+
range && /* @__PURE__ */ jsxs("div", { children: [
|
|
54108
|
+
/* @__PURE__ */ jsx("dt", { className: "font-medium text-muted-foreground", children: "Range" }),
|
|
54109
|
+
/* @__PURE__ */ jsx("dd", { className: "mt-0.5 font-mono text-foreground/80", children: range })
|
|
54110
|
+
] }),
|
|
54111
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
54112
|
+
/* @__PURE__ */ jsx("dt", { className: "font-medium text-muted-foreground", children: "Dimension" }),
|
|
54113
|
+
/* @__PURE__ */ jsx("dd", { className: "mt-0.5 text-foreground/80", children: dimension.kind })
|
|
54114
|
+
] }),
|
|
54115
|
+
dimension.value && /* @__PURE__ */ jsxs("div", { children: [
|
|
54116
|
+
/* @__PURE__ */ jsx("dt", { className: "font-medium text-muted-foreground", children: "Value" }),
|
|
54117
|
+
/* @__PURE__ */ jsx("dd", { className: "mt-0.5 text-foreground/80", children: dimension.value })
|
|
54118
|
+
] })
|
|
54119
|
+
] }),
|
|
54120
|
+
resultText && /* @__PURE__ */ jsx("p", { className: "mt-2 text-[11px] leading-relaxed text-muted-foreground", children: truncate(resultText, 160) })
|
|
54121
|
+
] }),
|
|
54122
|
+
effectiveAssetId && isComplete && !errorMsg && /* @__PURE__ */ jsx("div", { className: "border-t border-border/40 px-4 py-2", children: /* @__PURE__ */ jsxs(
|
|
54123
|
+
"button",
|
|
54124
|
+
{
|
|
54125
|
+
type: "button",
|
|
54126
|
+
onClick: () => openAsset(effectiveAssetId, { type: "spreadsheet" }),
|
|
54127
|
+
className: "flex items-center gap-1.5 rounded-md border border-border/60 px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",
|
|
54128
|
+
children: [
|
|
54129
|
+
/* @__PURE__ */ jsx(ExternalLink, { className: "size-3" }),
|
|
54130
|
+
"Open spreadsheet"
|
|
54131
|
+
]
|
|
54132
|
+
}
|
|
54133
|
+
) })
|
|
54134
|
+
]
|
|
54135
|
+
}
|
|
54136
|
+
);
|
|
54137
|
+
};
|
|
54138
|
+
const SetRowColumnDimensionsToolUI = memo(
|
|
54139
|
+
SetRowColumnDimensionsToolUIImpl
|
|
54140
|
+
);
|
|
54141
|
+
SetRowColumnDimensionsToolUI.displayName = "SetRowColumnDimensionsToolUI";
|
|
53768
54142
|
function createAssetToolUI(config2) {
|
|
53769
54143
|
const Component = (props) => /* @__PURE__ */ jsx(
|
|
53770
54144
|
CreateAssetToolUIImpl,
|
|
@@ -54186,6 +54560,8 @@ const TOOL_UI_REGISTRY = {
|
|
|
54186
54560
|
capture_moment: CaptureMomentToolUI,
|
|
54187
54561
|
capture_slide_screenshot: CaptureSlideScreenshotToolUI,
|
|
54188
54562
|
// Spreadsheet toolkit
|
|
54563
|
+
bulk_format_sheet_range: BulkFormatSheetRangeToolUI,
|
|
54564
|
+
set_row_column_dimensions: SetRowColumnDimensionsToolUI,
|
|
54189
54565
|
update_sheet_range: UpdateSheetRangeToolUI,
|
|
54190
54566
|
// Database toolkit
|
|
54191
54567
|
describe_database: DescribeDatabaseToolUI,
|
|
@@ -55879,19 +56255,93 @@ const AthenaUserMessage = ({
|
|
|
55879
56255
|
}
|
|
55880
56256
|
);
|
|
55881
56257
|
const embedCache = /* @__PURE__ */ new Map();
|
|
56258
|
+
const ATHENA_APP_HOSTNAMES = /* @__PURE__ */ new Set(["app.athenaintel.com", "staging-app.athenaintel.com"]);
|
|
56259
|
+
const ATHENA_PREVIEW_HOSTNAME_SUFFIX = ".previews.athenaintel.com";
|
|
56260
|
+
const ATHENA_WORKSPACE_HOSTNAME_PATTERN = /^.+--(\d+)\.(?:app\.athenaintel\.com|staging-app\.athenaintel\.com)$/;
|
|
56261
|
+
const OLYMPUS_WORKSPACE_PORT = "8082";
|
|
56262
|
+
const getUrl = (value) => {
|
|
56263
|
+
if (!value) {
|
|
56264
|
+
return null;
|
|
56265
|
+
}
|
|
56266
|
+
try {
|
|
56267
|
+
return new URL(value);
|
|
56268
|
+
} catch {
|
|
56269
|
+
return null;
|
|
56270
|
+
}
|
|
56271
|
+
};
|
|
56272
|
+
const getCurrentOrigin = () => {
|
|
56273
|
+
if (typeof window === "undefined") {
|
|
56274
|
+
return null;
|
|
56275
|
+
}
|
|
56276
|
+
return window.location.origin;
|
|
56277
|
+
};
|
|
56278
|
+
const getOrigin = (value) => {
|
|
56279
|
+
var _a2;
|
|
56280
|
+
return ((_a2 = getUrl(value)) == null ? void 0 : _a2.origin) ?? null;
|
|
56281
|
+
};
|
|
56282
|
+
const getAthenaWorkspacePort = (url) => {
|
|
56283
|
+
const match2 = url.hostname.toLowerCase().match(ATHENA_WORKSPACE_HOSTNAME_PATTERN);
|
|
56284
|
+
return (match2 == null ? void 0 : match2[1]) ?? null;
|
|
56285
|
+
};
|
|
56286
|
+
const isEmbedCapableAthenaHost = (url) => {
|
|
56287
|
+
const hostname = url.hostname.toLowerCase();
|
|
56288
|
+
if (ATHENA_APP_HOSTNAMES.has(hostname) || hostname.endsWith(ATHENA_PREVIEW_HOSTNAME_SUFFIX)) {
|
|
56289
|
+
return true;
|
|
56290
|
+
}
|
|
56291
|
+
return getAthenaWorkspacePort(url) === OLYMPUS_WORKSPACE_PORT;
|
|
56292
|
+
};
|
|
56293
|
+
const shouldPreferDerivedEmbedAppUrl = ({
|
|
56294
|
+
appUrl,
|
|
56295
|
+
derivedAppUrl,
|
|
56296
|
+
currentOrigin
|
|
56297
|
+
}) => {
|
|
56298
|
+
if (!derivedAppUrl) {
|
|
56299
|
+
return false;
|
|
56300
|
+
}
|
|
56301
|
+
const resolvedAppUrl = getUrl(appUrl);
|
|
56302
|
+
if (!resolvedAppUrl) {
|
|
56303
|
+
return true;
|
|
56304
|
+
}
|
|
56305
|
+
const workspacePort = getAthenaWorkspacePort(resolvedAppUrl);
|
|
56306
|
+
if (workspacePort && workspacePort !== OLYMPUS_WORKSPACE_PORT) {
|
|
56307
|
+
return true;
|
|
56308
|
+
}
|
|
56309
|
+
if (isEmbedCapableAthenaHost(resolvedAppUrl)) {
|
|
56310
|
+
return false;
|
|
56311
|
+
}
|
|
56312
|
+
const resolvedCurrentOrigin = getOrigin(currentOrigin ?? getCurrentOrigin());
|
|
56313
|
+
return !!resolvedCurrentOrigin && resolvedAppUrl.origin === resolvedCurrentOrigin;
|
|
56314
|
+
};
|
|
56315
|
+
const resolveEmbedAppUrl = ({
|
|
56316
|
+
appUrl,
|
|
56317
|
+
backendUrl,
|
|
56318
|
+
currentOrigin
|
|
56319
|
+
}) => {
|
|
56320
|
+
const derivedAppUrl = deriveAthenaAppUrl({ backendUrl });
|
|
56321
|
+
if (!appUrl) {
|
|
56322
|
+
return derivedAppUrl;
|
|
56323
|
+
}
|
|
56324
|
+
if (shouldPreferDerivedEmbedAppUrl({ appUrl, derivedAppUrl, currentOrigin })) {
|
|
56325
|
+
return derivedAppUrl;
|
|
56326
|
+
}
|
|
56327
|
+
return appUrl;
|
|
56328
|
+
};
|
|
55882
56329
|
function resolveAssetEmbedUrl({
|
|
55883
56330
|
embedUrl,
|
|
55884
|
-
appUrl
|
|
56331
|
+
appUrl,
|
|
56332
|
+
backendUrl,
|
|
56333
|
+
currentOrigin
|
|
55885
56334
|
}) {
|
|
55886
|
-
if (!appUrl) {
|
|
55887
|
-
return embedUrl;
|
|
55888
|
-
}
|
|
55889
56335
|
try {
|
|
55890
56336
|
const resolvedEmbedUrl = new URL(embedUrl);
|
|
55891
|
-
const resolvedAppUrl = new URL(appUrl);
|
|
55892
56337
|
if (!resolvedEmbedUrl.pathname.startsWith("/embed/")) {
|
|
55893
56338
|
return embedUrl;
|
|
55894
56339
|
}
|
|
56340
|
+
const embedAppUrl = resolveEmbedAppUrl({ appUrl, backendUrl, currentOrigin });
|
|
56341
|
+
if (!embedAppUrl) {
|
|
56342
|
+
return embedUrl;
|
|
56343
|
+
}
|
|
56344
|
+
const resolvedAppUrl = new URL(embedAppUrl);
|
|
55895
56345
|
resolvedEmbedUrl.protocol = resolvedAppUrl.protocol;
|
|
55896
56346
|
resolvedEmbedUrl.host = resolvedAppUrl.host;
|
|
55897
56347
|
return resolvedEmbedUrl.toString();
|
|
@@ -55926,7 +56376,7 @@ function useAssetEmbed(assetId, options = {
|
|
|
55926
56376
|
return;
|
|
55927
56377
|
}
|
|
55928
56378
|
const authContext = hasToken ? "token" : apiKey ?? "anon";
|
|
55929
|
-
const cacheKey = `${assetId}:${readOnly}:${authContext}:${appUrl ?? ""}`;
|
|
56379
|
+
const cacheKey = `${assetId}:${readOnly}:${authContext}:${backendUrl}:${appUrl ?? ""}`;
|
|
55930
56380
|
const cached2 = embedCache.get(cacheKey);
|
|
55931
56381
|
if (cached2 && cached2.expiresAt > Date.now() / 1e3) {
|
|
55932
56382
|
setEmbedUrl(cached2.url);
|
|
@@ -55966,7 +56416,8 @@ function useAssetEmbed(assetId, options = {
|
|
|
55966
56416
|
}).then((data) => {
|
|
55967
56417
|
const resolvedEmbedUrl = resolveAssetEmbedUrl({
|
|
55968
56418
|
embedUrl: data.embed_url,
|
|
55969
|
-
appUrl
|
|
56419
|
+
appUrl,
|
|
56420
|
+
backendUrl
|
|
55970
56421
|
});
|
|
55971
56422
|
embedCache.set(cacheKey, { url: resolvedEmbedUrl, expiresAt: data.expires_at });
|
|
55972
56423
|
setEmbedUrl(resolvedEmbedUrl);
|