@athenaintel/react 0.10.38 → 0.10.40

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.js CHANGED
@@ -47482,6 +47482,60 @@ const ASSET_TYPE_ALIASES = {
47482
47482
  word_document: "document"
47483
47483
  };
47484
47484
  const isAthenaSpacesPath = (url) => url.pathname.replace(/\/+$/, "") === "/dashboard/spaces";
47485
+ const getFiniteNumber = (url, key) => {
47486
+ const value = url.searchParams.get(key);
47487
+ if (value === null || value.trim() === "") return null;
47488
+ const parsed = Number(value);
47489
+ return Number.isFinite(parsed) ? parsed : null;
47490
+ };
47491
+ const parseCitationReference = ({
47492
+ url,
47493
+ assetId
47494
+ }) => {
47495
+ const reference2 = { id: assetId };
47496
+ const anchorType = url.searchParams.get("anchor");
47497
+ const page = getFiniteNumber(url, "page");
47498
+ switch (anchorType) {
47499
+ case "page":
47500
+ if (page !== null) reference2.anchor = { type: anchorType, page };
47501
+ break;
47502
+ case "page_range": {
47503
+ const startPage = getFiniteNumber(url, "start_page");
47504
+ const endPage = getFiniteNumber(url, "end_page");
47505
+ if (startPage !== null && endPage !== null) {
47506
+ reference2.anchor = { type: anchorType, startPage, endPage };
47507
+ }
47508
+ break;
47509
+ }
47510
+ case "page_rect": {
47511
+ const x = getFiniteNumber(url, "x");
47512
+ const y = getFiniteNumber(url, "y");
47513
+ const width = getFiniteNumber(url, "width");
47514
+ const height = getFiniteNumber(url, "height");
47515
+ if (page !== null && x !== null && y !== null && width !== null && height !== null) {
47516
+ const unit = url.searchParams.get("unit");
47517
+ reference2.anchor = {
47518
+ type: anchorType,
47519
+ page,
47520
+ x,
47521
+ y,
47522
+ width,
47523
+ height,
47524
+ ...unit === "percent" || unit === "point" ? { unit } : {}
47525
+ };
47526
+ }
47527
+ break;
47528
+ }
47529
+ case "page_text": {
47530
+ const text2 = url.searchParams.get("text");
47531
+ if (page !== null && text2) reference2.anchor = { type: anchorType, page, text: text2 };
47532
+ break;
47533
+ }
47534
+ }
47535
+ const excerpt = url.searchParams.get("excerpt");
47536
+ if (excerpt) reference2.meta = { excerpt };
47537
+ return reference2;
47538
+ };
47485
47539
  const normalizeAssetType = (value) => {
47486
47540
  if (!value) {
47487
47541
  return null;
@@ -47570,7 +47624,8 @@ const parseAthenaCitationLink = ({
47570
47624
  url,
47571
47625
  assetId,
47572
47626
  assetIds,
47573
- assetType: normalizeAssetType(url.searchParams.get("asset_type") ?? url.searchParams.get("type"))
47627
+ assetType: normalizeAssetType(url.searchParams.get("asset_type") ?? url.searchParams.get("type")),
47628
+ reference: parseCitationReference({ url, assetId })
47574
47629
  };
47575
47630
  };
47576
47631
  const isAthenaCitationUrl = ({
@@ -56239,6 +56294,8 @@ function isAthenaAssetCitationClickEvent(value) {
56239
56294
  function isAthenaAssetCitationActionEvent(value) {
56240
56295
  return typeof value === "object" && value !== null && "type" in value && value.type === ATHENA_ASSET_CITATION_ACTION_MESSAGE && "version" in value && value.version === 1 && "action" in value && value.action === "open-in-spaces" && "reference" in value && typeof value.reference === "object" && value.reference !== null && "id" in value.reference && typeof value.reference.id === "string";
56241
56296
  }
56297
+ const DEFAULT_ASSET_EMBED_READ_ONLY = false;
56298
+ const DEFAULT_ASSET_EMBED_DISPLAY_MODE = "full";
56242
56299
  function buildAssetEmbedRequestBody({
56243
56300
  assetId,
56244
56301
  readOnly,
@@ -56414,6 +56471,9 @@ function appendCitationReferenceParams({
56414
56471
  key: "height",
56415
56472
  value: "height" in anchor ? anchor.height : void 0
56416
56473
  });
56474
+ if ("unit" in anchor && (anchor.unit === "percent" || anchor.unit === "point")) {
56475
+ params.set("unit", anchor.unit);
56476
+ }
56417
56477
  break;
56418
56478
  case "page_text":
56419
56479
  params.set("anchor", anchor.type);
@@ -56472,9 +56532,9 @@ function useAssetEmbed(assetId, options = {
56472
56532
  backendUrl: ""
56473
56533
  }) {
56474
56534
  const {
56475
- readOnly = false,
56535
+ readOnly = DEFAULT_ASSET_EMBED_READ_ONLY,
56476
56536
  expiresInSeconds = 60 * 60 * 24 * 30,
56477
- displayMode = "minimal",
56537
+ displayMode = DEFAULT_ASSET_EMBED_DISPLAY_MODE,
56478
56538
  backendUrl,
56479
56539
  appUrl,
56480
56540
  apiKey,
@@ -56567,8 +56627,8 @@ const AUTH_SYNC_INTERVAL_MS = 6e4;
56567
56627
  const AthenaAssetEmbed = ({
56568
56628
  assetId,
56569
56629
  reference: reference2,
56570
- displayMode = "full",
56571
- readOnly = true,
56630
+ displayMode = DEFAULT_ASSET_EMBED_DISPLAY_MODE,
56631
+ readOnly = DEFAULT_ASSET_EMBED_READ_ONLY,
56572
56632
  expiresInSeconds,
56573
56633
  citationBehavior,
56574
56634
  onCitationClick,