@arbidocs/react 0.5.152 → 0.5.154

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.
Files changed (61) hide show
  1. package/dist/artifacts/index.cjs +14 -14
  2. package/dist/calls/livekit/index.cjs +48 -48
  3. package/dist/{chunk-VXFTVWEI.cjs → chunk-4VHECR5O.cjs} +44 -44
  4. package/dist/{chunk-VXFTVWEI.cjs.map → chunk-4VHECR5O.cjs.map} +1 -1
  5. package/dist/{chunk-GFX7LQGR.cjs → chunk-5LKTSVTE.cjs} +66 -66
  6. package/dist/{chunk-GFX7LQGR.cjs.map → chunk-5LKTSVTE.cjs.map} +1 -1
  7. package/dist/{chunk-P2DPOZBS.cjs → chunk-5ZNO77YB.cjs} +11 -2
  8. package/dist/chunk-5ZNO77YB.cjs.map +1 -0
  9. package/dist/{chunk-BI7HFGXF.cjs → chunk-H2TP7JWR.cjs} +10 -10
  10. package/dist/{chunk-BI7HFGXF.cjs.map → chunk-H2TP7JWR.cjs.map} +1 -1
  11. package/dist/{chunk-WJIRX5MS.cjs → chunk-XQLJSNAL.cjs} +3 -3
  12. package/dist/{chunk-WJIRX5MS.cjs.map → chunk-XQLJSNAL.cjs.map} +1 -1
  13. package/dist/{chunk-MK5L56Z3.cjs → chunk-ZBCTLPO5.cjs} +57 -57
  14. package/dist/{chunk-MK5L56Z3.cjs.map → chunk-ZBCTLPO5.cjs.map} +1 -1
  15. package/dist/{chunk-SKJWJ3OY.cjs → chunk-ZELH6W5C.cjs} +37 -37
  16. package/dist/{chunk-SKJWJ3OY.cjs.map → chunk-ZELH6W5C.cjs.map} +1 -1
  17. package/dist/datasets/aggregate-source.js +133 -0
  18. package/dist/datasets/aggregate-source.js.map +7 -0
  19. package/dist/datasets/aggregate.js +72 -22
  20. package/dist/datasets/aggregate.js.map +2 -2
  21. package/dist/datasets/index.js +32 -2
  22. package/dist/datasets/index.js.map +2 -2
  23. package/dist/datasets/pages.js +70 -7
  24. package/dist/datasets/pages.js.map +2 -2
  25. package/dist/datasets/sources/activity.js +44 -9
  26. package/dist/datasets/sources/activity.js.map +2 -2
  27. package/dist/datasets/sources/conversations.js +37 -7
  28. package/dist/datasets/sources/conversations.js.map +2 -2
  29. package/dist/datasets/sources/documents.js +44 -6
  30. package/dist/datasets/sources/documents.js.map +2 -2
  31. package/dist/datasets/sources/facts.js +31 -5
  32. package/dist/datasets/sources/facts.js.map +3 -3
  33. package/dist/datasets/sources/tags.js +37 -5
  34. package/dist/datasets/sources/tags.js.map +3 -3
  35. package/dist/datasets/sources/usage.js +29 -32
  36. package/dist/datasets/sources/usage.js.map +2 -2
  37. package/dist/datasets/sources/workflows.js +56 -22
  38. package/dist/datasets/sources/workflows.js.map +2 -2
  39. package/dist/datasets/workspace-aggregate.js +64 -0
  40. package/dist/datasets/workspace-aggregate.js.map +7 -0
  41. package/dist/document-tools/core.cjs +100 -100
  42. package/dist/document-tools/core.d.ts +2 -2
  43. package/dist/document-tools/index.cjs +102 -102
  44. package/dist/document-tools/index.d.ts +2 -2
  45. package/dist/{file-shares.d-CamKxNLC.d.ts → file-shares.d-CyTnJ2Re.d.ts} +11 -0
  46. package/dist/index.cjs +2309 -1787
  47. package/dist/index.cjs.map +1 -1
  48. package/dist/index.d.ts +196 -7
  49. package/dist/index.js +11 -2
  50. package/dist/index.js.map +2 -2
  51. package/dist/projects.js +9 -0
  52. package/dist/projects.js.map +2 -2
  53. package/dist/query-keys.js +9 -0
  54. package/dist/query-keys.js.map +2 -2
  55. package/dist/storage.js +24 -1
  56. package/dist/storage.js.map +2 -2
  57. package/dist/table-views.js +19 -1
  58. package/dist/table-views.js.map +2 -2
  59. package/dist/ui/index.cjs +168 -168
  60. package/package.json +3 -3
  61. package/dist/chunk-P2DPOZBS.cjs.map +0 -1
@@ -94,6 +94,8 @@ var arbiQueryKeys = {
94
94
  workspaceActivity: (workspaceId, limit) => limit === void 0 ? ["arbi", "workspaceActivity", workspaceId] : ["arbi", "workspaceActivity", workspaceId, limit],
95
95
  projects: () => ["arbi", "projects"],
96
96
  projectUsage: (projectExtId, monthsBack) => ["arbi", "projectUsage", projectExtId, monthsBack],
97
+ /** The usage of every project the user owns, in one read (under `projectUsage`'s prefix). */
98
+ ownedProjectsUsage: (monthsBack) => ["arbi", "projectUsage", "owned", monthsBack],
97
99
  projectConversationUsage: (projectExtId, monthsBack) => ["arbi", "projectUsage", projectExtId, "byConversation", monthsBack],
98
100
  projectInvoices: (projectExtId) => ["arbi", "projectInvoices", projectExtId],
99
101
  /** The plans and add-ons on sale. */
@@ -185,6 +187,13 @@ var arbiQueryKeys = {
185
187
  * no target: every table's; no workspace: every workspace's.
186
188
  */
187
189
  tableViews: (workspaceId, target) => workspaceId === void 0 ? ["arbi", "table-views"] : target === void 0 ? ["arbi", "table-views", workspaceId] : ["arbi", "table-views", workspaceId, target],
190
+ /**
191
+ * A view's rows with its database (a page's table block), under `databaseRows`' prefix so every
192
+ * row write refreshes it: the database is the view's, unknown until read.
193
+ */
194
+ tableViewRows: (workspaceId, viewId) => ["arbi", "databases", "rows", workspaceId, "", { view: viewId }],
195
+ /** A workspace's items counted on the server (a chart); no workspace: every workspace's. */
196
+ workspaceAggregate: (workspaceId, query) => workspaceId === void 0 ? ["arbi", "workspaceAggregate"] : ["arbi", "workspaceAggregate", workspaceId, query ?? {}],
188
197
  /** A database's rows grouped and measured (a chart); no workspace: every database's. */
189
198
  databaseAggregate: (workspaceId, databaseId, request) => workspaceId === void 0 ? ["arbi", "databases", "aggregate"] : ["arbi", "databases", "aggregate", workspaceId, databaseId ?? "", request ?? {}],
190
199
  // ── Configs, health ─────────────────────────────────────────────────────────────────────────
@@ -370,5 +379,5 @@ exports.mailQueryKeys = mailQueryKeys;
370
379
  exports.useArbi = useArbi;
371
380
  exports.useArbiHost = useArbiHost;
372
381
  exports.useDeploymentDomain = useDeploymentDomain;
373
- //# sourceMappingURL=chunk-P2DPOZBS.cjs.map
374
- //# sourceMappingURL=chunk-P2DPOZBS.cjs.map
382
+ //# sourceMappingURL=chunk-5ZNO77YB.cjs.map
383
+ //# sourceMappingURL=chunk-5ZNO77YB.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/host/config.ts","../src/useArbi.ts","../src/query-keys.ts"],"names":["useContext","ArbiHostContext"],"mappings":";;;;;AA4HO,SAAS,WAAA,GAA8B;AAC5C,EAAA,OAAOA,iBAAWC,iCAAe,CAAA;AACnC;;;ACvHO,SAAS,OAAA,GAAgB;AAC9B,EAAA,MAAM,EAAE,IAAA,EAAK,GAAI,WAAA,EAAY;AAC7B,EAAA,IAAI,CAAC,IAAA,EAAM;AACT,IAAA,MAAM,IAAI,MAAM,0DAA0D,CAAA;AAAA,EAC5E;AACA,EAAA,OAAO,IAAA;AACT;AAOO,SAAS,mBAAA,GAA0C;AACxD,EAAA,OAAO,WAAA,EAAY,CAAE,IAAA,EAAM,mBAAA,EAAoB;AACjD;;;ACNO,IAAM,aAAA,GAAgB;AAAA,EAC3B,UAAA,EAAY,MAAM,CAAC,MAAA,EAAQ,YAAY,CAAA;AAAA,EACvC,WAAW,CAAC,EAAA,KAAe,CAAC,MAAA,EAAQ,aAAa,EAAE,CAAA;AAAA,EACnD,YAAA,EAAc,CAAC,EAAA,EAAY,MAAA,KAAoB,CAAC,MAAA,EAAQ,cAAA,EAAgB,IAAI,MAAM,CAAA;AAAA,EAClF,UAAA,EAAY,MAAM,CAAC,MAAA,EAAQ,YAAY,CAAA;AAAA;AAAA,EAEvC,iBAAA,EAAmB,MAAM,CAAC,MAAA,EAAQ,gBAAgB,CAAA;AAAA,EAClD,gBAAgB,CAAC,WAAA,KAAwB,CAAC,MAAA,EAAQ,kBAAkB,WAAW,CAAA;AAAA;AAAA,EAE/E,YAAA,EAAc,MAAM,CAAC,MAAA,EAAQ,WAAW,CAAA;AAAA,EACxC,WAAW,CAAC,WAAA,KAAwB,CAAC,MAAA,EAAQ,aAAa,WAAW,CAAA;AAAA;AAAA,EAErE,UAAU,CAAC,KAAA,K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A,EAAQ,MAAA,EAAQ,UAAU,QAAQ,CAAA;AAAA;AAAA,EAEvD,SAAA,EAAW,MAAM,CAAC,MAAA,EAAQ,QAAQ,QAAQ,CAAA;AAAA,EAC1C,QAAQ,CAAC,SAAA,EAA+B,UAAA,EAAsB,SAAA,KAC5D,CAAC,MAAA,EAAQ,MAAA,EAAQ,QAAA,EAAU,SAAA,EAAW,WAAW,IAAA,CAAK,GAAG,GAAG,SAAA,CAAU,IAAA,CAAK,GAAG,CAAC,CAAA;AAAA;AAAA;AAAA,EAGjF,YAAA,EAAc,MAAM,CAAC,MAAA,EAAQ,oBAAoB,CAAA;AAAA;AAAA,EAEjD,QAAA,EAAU,MAAM,CAAC,MAAA,EAAQ,QAAQ,UAAU,CAAA;AAAA;AAAA,EAE3C,YAAA,EAAc,CAAC,SAAA,EAA+B,OAAA,KAC5C,CAAC,MAAA,EAAQ,MAAA,EAAQ,eAAA,EAAiB,SAAA,EAAW,OAAO,CAAA;AAAA,EACtD,cAAA,EAAgB,CAAC,SAAA,EAAmB,SAAA,EAAmB,YAAA,KACrD,CAAC,MAAA,EAAQ,MAAA,EAAQ,iBAAA,EAAmB,SAAA,EAAW,SAAA,EAAW,YAAY;AAC1E;AAMO,IAAM,mBAAmB,CAC9B,WAAA,EACA,SACA,IAAA,KAEA,OAAA,KAAY,SACP,CAAC,MAAA,EAAQ,eAAA,EAAiB,WAAW,IACrC,CAAC,MAAA,EAAQ,iBAAiB,WAAA,EAAa,OAAA,EAAS,QAAQ,KAAK;AAG7D,SAAS,eAAA,CAAgB,UAA8B,MAAA,EAAqC;AACjG,EAAA,OAAO,MAAA,CAAO,MAAM,CAAC,IAAA,EAAM,MAAM,QAAA,CAAS,CAAC,MAAM,IAAI,CAAA;AACvD","file":"chunk-5ZNO77YB.cjs","sourcesContent":["/**\n * What a host hands the `@arbidocs/react` hooks, as one configuration (`<ArbiHost config>`). Every\n * field is optional: without one the hooks use their own default. `@arbidocs/blocks` extends it\n * with the blocks domains (environment, billing, viewer, …).\n *\n * A field whose value lives in the host's state is a hook (`use…`), called by the hooks and kits\n * that need it, so the configuration itself stays one stable object for the host's life.\n */\n\nimport { useContext } from 'react'\nimport type { Arbi } from '@arbidocs/sdk/browser'\nimport type { AccountClient } from '../account/client'\nimport type { CalendarSupport } from '../calendar/support'\nimport type { MeetingChatRef } from '../calls/meeting-chat'\nimport type { ActiveCall } from '../calls/session'\nimport type { ArbiChatHost } from '../chat/host'\nimport type { DocumentsSupport } from '../documents/support'\nimport type { MailClient } from '../mail/client'\nimport type { ArbiSessionStore } from '../session/store'\nimport type { DictateContextValue } from '../ui/DictateContext'\nimport type { EntityVocabulary } from '../entities/vocabulary'\nimport type { ArbiHostConnection } from './ArbiHost'\nimport type { ArbiFeatures } from './features'\nimport { ArbiHostContext } from './context'\nimport type { DashboardsHost } from '../datasets/registry'\n\n/** The mail client, and whether mail is on for the signed-in user. */\nexport interface MailHost {\n client: MailClient\n /**\n * Whether mail reads run (signed in and entitled), and the server session the mailbox is\n * unlocked for: unlocking runs again when it changes (`null`: none yet, nothing is unlocked).\n * Absent: on, for one session.\n */\n useStatus?: () => { enabled: boolean; sessionKey: string | null }\n /**\n * The mail waiting in this device's Outbox (written offline), by status, while `enabled` (Mail\n * switched on); the offline status counts it as waiting work. Absent: no Outbox.\n */\n useOutbox?: (enabled: boolean) => ReadonlyArray<{ status: string }>\n /** The Outbox's folder, opened through `openMail({ folder })`. */\n outboxFolder?: string\n}\n\n/** The account client of the settings kits, and whether account reads run (signed in). */\nexport interface AccountHost {\n client: AccountClient\n /** Absent: always. */\n useEnabled?: () => boolean\n}\n\n/** Where the call panel goes in the host's layout. */\nexport type CallSlotMode = 'docked' | 'main'\n\n/** What the calls need from the host: navigation and layout are the host's. */\nexport interface CallsHost {\n /**\n * Show a call's meeting chat: an end-to-end chat, or a workspace meeting thread. Absent: the\n * in-call \"Open meeting chat\" does nothing.\n */\n openMeetingChat?: (ref: MeetingChatRef) => void\n /**\n * Once connected, show the call's conversation (its chat and live transcript) beside the call.\n * Absent: nothing is shown.\n */\n showConversation?: (call: ActiveCall) => void | Promise<void>\n /**\n * The element whose box the shown call fills: the right-hand dock, or (a webinar's audience) the\n * main area. The host claims its slot while `shown` and calls `onLost` when another panel takes\n * it (the call then minimises). Absent: the call floats at the right edge.\n */\n useSlot?: (mode: CallSlotMode, shown: boolean, onLost: () => void) => HTMLElement | null\n}\n\nexport interface ArbiHostConfig {\n /**\n * The SDK on the signed-in session. A host with its own login passes one on its session\n * (`new Arbi({ url, session })`); a blocks-only site gets one from `defaultHost`. A new instance (a\n * new session, a newly opened workspace) re-renders every hook.\n */\n arbi?: Arbi\n /** The session state the kits share. Absent: an in-memory one per top-level host. */\n session?: ArbiSessionStore\n /** Live processing, uploads and the host's document actions. Absent: the package's own. */\n documents?: DocumentsSupport\n /** The calendar kept on this device and account OAuth. Absent: online only, the user's connectors. */\n calendar?: CalendarSupport\n /** Absent: mail on the `arbi` session. */\n mail?: MailHost\n /** Absent: the account on the `arbi` session. */\n account?: AccountHost\n /** Absent: calls open no meeting chat from the room. */\n calls?: CallsHost\n /**\n * The parts of the product the user switches on or off, and where each switch is kept (the user's\n * settings, or this device), read with `useFeature(name)`. The call UI also follows the `calls`\n * feature, on top of the server's calls config. Absent, or a feature not listed: on.\n */\n features?: ArbiFeatures\n /** Dictation for every `dictate` field. Absent: no mic button. */\n dictate?: DictateContextValue\n /** The sign-in layer of a blocks-only site (`defaultHost` in `@arbidocs/blocks/connect`). */\n connection?: ArbiHostConnection\n /** Where the chat engine's side effects go (documents shown, mail drafts, used-up quota). */\n chat?: ArbiChatHost\n /**\n * The site's words for the entities (`{ PROJECT: 'Matter' }`), read by every kit through\n * `getEntityLabel`. Absent: the registry's (\"Project\", \"Workspace\", \"Thread\", …).\n */\n vocabulary?: EntityVocabulary\n /**\n * What the site calls its assistant where people address it: the `@<name>` offered in a chat's\n * mention menu, the draft a shared thread starts with, and the name a message is routed to the\n * assistant on. Absent: \"ARBI\".\n */\n assistantName?: string\n /**\n * Charts and dashboards: more data sources (an external feed, a source relabelled in the site's\n * words). Pages themselves are the workspace's (`/v1/pages`). Absent: the built-in sources.\n */\n dashboards?: DashboardsHost\n}\n\n/** The host configuration in scope (`{}` outside an `<ArbiHost>`). */\nexport function useArbiHost(): ArbiHostConfig {\n return useContext(ArbiHostContext) as ArbiHostConfig\n}\n","/**\n * The `Arbi` of the host configuration (`<ArbiHost config={{ arbi }}>`).\n */\n\nimport type { Arbi } from '@arbidocs/sdk/browser'\nimport { useArbiHost } from './host/config'\n\nexport function useArbi(): Arbi {\n const { arbi } = useArbiHost()\n if (!arbi) {\n throw new Error('useArbi() needs an <ArbiHost> whose config has an `arbi`')\n }\n return arbi\n}\n\n/**\n * The deployment domain the user's keys are derived for, as the host's `Arbi` computes it\n * (`deploymentDomain`, else the API URL's hostname). `undefined` without one. The document tools\n * default their `deploymentDomain` (needed for e-signing) to it.\n */\nexport function useDeploymentDomain(): string | undefined {\n return useArbiHost().arbi?.getDeploymentDomain()\n}\n","/**\n * The one query-key factory of the ARBI front end: every React Query key and mutation key the\n * packages and the app use is built here, under `['arbi', …]`. Literal key arrays anywhere else\n * fail the `arbi/query-keys-from-factory` lint rule and `query-keys.guard.test.ts`, so a key can't\n * drift from the queries it names (a stale literal reads or invalidates nothing, silently).\n *\n * Dependency-free on purpose (types only): e2e helpers import it and pass keys into the page.\n */\n\nimport type {\n CalendarWindow,\n ListEventsParams,\n OverlayLayerName,\n RoomQuery,\n} from '@arbidocs/sdk/browser'\n\nexport const arbiQueryKeys = {\n fileShares: () => ['arbi', 'fileShares'] as const,\n fileShare: (id: string) => ['arbi', 'fileShare', id] as const,\n fileSharePdf: (id: string, status?: string) => ['arbi', 'fileSharePdf', id, status] as const,\n workspaces: () => ['arbi', 'workspaces'] as const,\n /** Every workspace's member list: what a workspace switch drops. */\n allWorkspaceUsers: () => ['arbi', 'workspaceUsers'] as const,\n workspaceUsers: (workspaceId: string) => ['arbi', 'workspaceUsers', workspaceId] as const,\n /** Every workspace's documents list: the prefix a write patches when it does not know the workspace. */\n allDocuments: () => ['arbi', 'documents'] as const,\n documents: (workspaceId: string) => ['arbi', 'documents', workspaceId] as const,\n /** One document (a viewer's); writes keep it current next to the list. */\n document: (docId: string) => ['arbi', 'document', docId] as const,\n documentsById: (docIds: string[]) =>\n ['arbi', 'documentsById', [...docIds].sort().join(',')] as const,\n /** Every workspace's near-duplicate pairs. */\n allSimilarDocuments: () => ['arbi', 'similarDocuments'] as const,\n similarDocuments: (workspaceId: string, threshold: number) =>\n ['arbi', 'similarDocuments', workspaceId, threshold] as const,\n /** Every version list: the prefix a new version invalidates. */\n allDocumentVersions: () => ['arbi', 'documentVersions'] as const,\n documentVersions: (docId: string) => ['arbi', 'documentVersions', docId] as const,\n conversations: (workspaceId: string) => ['arbi', 'conversations', workspaceId] as const,\n /** Every workspace's conversation list (and threads): the prefix a conversation write invalidates. */\n allConversations: () => ['arbi', 'conversations'] as const,\n /** A conversation's threads, under the conversations prefix (ids are unique across workspaces). */\n conversationThreads: (conversationId: string) =>\n ['arbi', 'conversations', conversationId, 'threads'] as const,\n /** One stored message with everything the server keeps on it (its trace and metadata). */\n messageDetails: (messageId: string) => ['arbi', 'messageDetails', messageId] as const,\n /** The backend's built-in slash commands. */\n assistantCommands: () => ['arbi', 'assistantCommands'] as const,\n /** Every workspace's tags (lists, tables and kinds): what a cross-workspace change refreshes. */\n allTags: () => ['arbi', 'tags'] as const,\n tags: (workspaceId: string) => ['arbi', 'tags', workspaceId] as const,\n /** Under the workspace's tags: the kinds' fields (refreshed with the tags). */\n tagKinds: (workspaceId: string) => ['arbi', 'tags', workspaceId, 'kinds'] as const,\n /** Every filtered list (a table of tags): what a tag write refreshes, the whole list aside. */\n tagLists: (workspaceId: string) => ['arbi', 'tags', workspaceId, 'list'] as const,\n /** Under the workspace's tags: a tag, doctag or fact write that invalidates `tags` refreshes it. */\n tagList: (workspaceId: string, query: string) =>\n ['arbi', 'tags', workspaceId, 'list', query] as const,\n /** A kind's fields, under the workspace's tags. */\n tagKind: (workspaceId: string, kind: string) =>\n ['arbi', 'tags', workspaceId, 'kind', kind] as const,\n /** A task's history, under the conversations prefix: every conversation write refreshes it. */\n conversationActivity: (conversationId: string) =>\n ['arbi', 'conversations', conversationId, 'activity'] as const,\n thumbnails: (docIds: string[]) => ['arbi', 'thumbnails', [...docIds].sort().join(',')] as const,\n /** Every stage of a document's parsed content. */\n parsedDocument: (docId: string) => ['arbi', 'parsedDoc', docId] as const,\n parsedDoc: (docId: string, stage: string) => ['arbi', 'parsedDoc', docId, stage] as const,\n agents: () => ['arbi', 'agents'] as const,\n sessions: () => ['arbi', 'sessions'] as const,\n health: () => ['arbi', 'health'] as const,\n workflows: () => ['arbi', 'workflows'] as const,\n /** Under `workflows()`: a workflow write or run refreshes its runs too. */\n workflowRuns: (workflowId: string) => ['arbi', 'workflows', workflowId, 'runs'] as const,\n /** Under `workflows()`: one workflow with its steps. */\n workflow: (workflowId: string) => ['arbi', 'workflows', workflowId] as const,\n /** Every workspace's facts: the prefix a fact write invalidates. */\n allFacts: () => ['arbi', 'facts'] as const,\n facts: (workspaceId: string) => ['arbi', 'facts', workspaceId] as const,\n configs: () => ['arbi', 'configs'] as const,\n activity: () => ['arbi', 'activity'] as const,\n /** Every transfer query (jobs, lists, plans): what a finished job refreshes. */\n allWorkspaceTransfers: () => ['arbi', 'workspaceTransfers'] as const,\n /** The caller's recent transfer jobs out of a workspace. */\n workspaceTransfers: (workspaceId: string) =>\n ['arbi', 'workspaceTransfers', 'list', workspaceId] as const,\n /** One transfer job's progress. */\n workspaceTransfer: (transferId: string) =>\n ['arbi', 'workspaceTransfers', 'job', transferId] as const,\n /** What a scope (serialised) would take in a workspace, for a mode. */\n workspaceTransferPlan: (workspaceId: string, scope: string, mode: string) =>\n ['arbi', 'workspaceTransfers', 'plan', workspaceId, scope, mode] as const,\n /**\n * A workspace's activity feed (all its pages), read `limit` entries a page (absent: the server's\n * default): each page size is its own entry, under the workspace's key.\n */\n workspaceActivity: (workspaceId: string, limit?: number) =>\n limit === undefined\n ? (['arbi', 'workspaceActivity', workspaceId] as const)\n : (['arbi', 'workspaceActivity', workspaceId, limit] as const),\n projects: () => ['arbi', 'projects'] as const,\n projectUsage: (projectExtId: string, monthsBack: number) =>\n ['arbi', 'projectUsage', projectExtId, monthsBack] as const,\n /** The usage of every project the user owns, in one read (under `projectUsage`'s prefix). */\n ownedProjectsUsage: (monthsBack: number) =>\n ['arbi', 'projectUsage', 'owned', monthsBack] as const,\n projectConversationUsage: (projectExtId: string, monthsBack: number) =>\n ['arbi', 'projectUsage', projectExtId, 'byConversation', monthsBack] as const,\n projectInvoices: (projectExtId: string) => ['arbi', 'projectInvoices', projectExtId] as const,\n /** The plans and add-ons on sale. */\n products: () => ['arbi', 'products'] as const,\n /** Prices of a purchase or a change (quotes, previews); nothing is bought. */\n billingQuotes: () => ['arbi', 'billingQuote'] as const,\n userUsageToday: () => ['arbi', 'userUsageToday'] as const,\n currentUser: () => ['arbi', 'currentUser'] as const,\n firmPool: () => ['arbi', 'firmPool'] as const,\n contacts: () => ['arbi', 'contacts'] as const,\n /** Every chat query (the list and each open thread). */\n chats: () => ['arbi', 'chats'] as const,\n /** My chats, raw (titles and last messages are ciphertext), most recently active first. */\n chatList: () => ['arbi', 'chats', 'list'] as const,\n /** One thread's loaded messages, decrypted, oldest first (`ChatThreadData`). */\n chatThread: (chatExtId: string) => ['arbi', 'chats', 'thread', chatExtId] as const,\n /** My own agent's progress on my last message to it (`agent_dm_status`), per agent. */\n agentDmStatus: (agentExtId: string) => ['arbi', 'chats', 'agentStatus', agentExtId] as const,\n /** The paid features this person may use (`/v1/user/entitlements`). */\n entitlements: () => ['arbi', 'entitlements'] as const,\n skills: () => ['arbi', 'skills'] as const,\n /** A skill's main file (SKILL.md), as text. */\n skillSource: (docExtId: string) => ['arbi', 'skills', 'source', docExtId] as const,\n /** An agent's pinned config; `undefined` = the library default config. */\n agentConfig: (agentExtId?: string) => ['arbi', 'agentConfig', agentExtId ?? 'default'] as const,\n agentWorkspaces: (agentExtId: string) => ['arbi', 'agentWorkspaces', agentExtId] as const,\n /** An agent's own login, polled while its controls are open. */\n agentSession: (agentExtId: string) => ['arbi', 'agentSession', agentExtId] as const,\n agentChats: (agentExtId: string) => ['arbi', 'agentChats', agentExtId] as const,\n authorizeLimits: () => ['arbi', 'authorizeLimits'] as const,\n mcpTools: () => ['arbi', 'mcpTools'] as const,\n models: () => ['arbi', 'models'] as const,\n availableModels: () => ['arbi', 'availableModels'] as const,\n /** The workspace Assistant's brief. */\n assistantBrief: (workspaceId: string) => ['arbi', 'assistantBrief', workspaceId] as const,\n /** Whether the workspace Assistant is waiting, working or idle. */\n assistantStatus: (workspaceId: string) => ['arbi', 'assistantStatus', workspaceId] as const,\n /** What the workspace Assistant did with each arrival. */\n assistantArrivals: (workspaceId: string) => ['arbi', 'assistantArrivals', workspaceId] as const,\n modelConnections: (userId?: string) => ['arbi', 'modelConnections', userId] as const,\n directModelUsage: (userId?: string) => ['arbi', 'directModelUsage', userId] as const,\n /** The signed-in user's own profile (name, picture, email). */\n profile: () => ['arbi', 'profile'] as const,\n identity: () => ['arbi', 'identity'] as const,\n /** The signed-in user's settings record (notification preferences, flags). */\n userSettings: () => ['arbi', 'userSettings'] as const,\n /** Every notification list: the prefix a delete, a read receipt or an arrival invalidates. */\n allSupportTickets: () => ['arbi', 'support'] as const,\n supportTickets: () => ['arbi', 'support', 'tickets'] as const,\n supportTicket: (id: number) => ['arbi', 'support', 'tickets', id] as const,\n allNotifications: () => ['arbi', 'notifications'] as const,\n /** The newest `limit` notifications, received and sent. */\n notifications: (limit: number) => ['arbi', 'notifications', limit] as const,\n /** The documents a workspace may use as its Word house template. */\n houseTemplateCandidates: (workspaceId: string) =>\n ['arbi', 'houseTemplateCandidates', workspaceId] as const,\n // ── Storage, archive ────────────────────────────────────────────────────────────────────────\n /** Every storage view (projects, items, names, Recently deleted): what a restore or delete refreshes. */\n storage: () => ['arbi', 'storage'] as const,\n /** What each project stores; no params: every such list. */\n storageProjects: (params?: object) =>\n params === undefined\n ? (['arbi', 'storage', 'projects'] as const)\n : (['arbi', 'storage', 'projects', params] as const),\n /** The largest items stored; no params: every such list. */\n storageItems: (params?: object) =>\n params === undefined\n ? (['arbi', 'storage', 'items'] as const)\n : (['arbi', 'storage', 'items', params] as const),\n /** Decrypted document names of storage items. */\n storageItemNames: (params?: object) =>\n params === undefined\n ? (['arbi', 'storage', 'names'] as const)\n : (['arbi', 'storage', 'names', params] as const),\n /** The deployment's storage day by day. */\n storageSnapshots: (params?: object) =>\n params === undefined\n ? (['arbi', 'storage', 'snapshots'] as const)\n : (['arbi', 'storage', 'snapshots', params] as const),\n /** A workspace's Recently deleted documents; no id: every workspace's. */\n workspaceTrash: (workspaceId?: string) =>\n workspaceId === undefined\n ? (['arbi', 'storage', 'workspaceTrash'] as const)\n : (['arbi', 'storage', 'workspaceTrash', workspaceId] as const),\n /** A workspace's archive state; no id: every workspace's. */\n workspaceArchive: (workspaceId?: string) =>\n workspaceId === undefined\n ? (['arbi', 'workspaceArchive'] as const)\n : (['arbi', 'workspaceArchive', workspaceId] as const),\n // ── Databases ───────────────────────────────────────────────────────────────────────────────\n // Every key below names its workspace right after its kind: a list read in one workspace is never\n // served, or overwritten, in another (the list is the session's open workspace on the server).\n /** Every database query of every workspace (what a write or a switch refreshes). */\n databases: () => ['arbi', 'databases'] as const,\n /** A workspace's databases; no id: every workspace's. */\n databaseList: (workspaceId?: string) =>\n workspaceId === undefined\n ? (['arbi', 'databases', 'list'] as const)\n : (['arbi', 'databases', 'list', workspaceId] as const),\n /** One database of a workspace; no workspace: every one read. */\n database: (workspaceId?: string, databaseId?: string) =>\n workspaceId === undefined\n ? (['arbi', 'databases', 'one'] as const)\n : (['arbi', 'databases', 'one', workspaceId, databaseId ?? ''] as const),\n /**\n * A database's rows (a search); no workspace: every database's, no params: every search of one.\n * `['arbi', 'databases', 'rows', workspaceId, databaseId, params]`.\n */\n databaseRows: (workspaceId?: string, databaseId?: string, params?: object) =>\n workspaceId === undefined\n ? (['arbi', 'databases', 'rows'] as const)\n : params === undefined\n ? (['arbi', 'databases', 'rows', workspaceId, databaseId ?? ''] as const)\n : (['arbi', 'databases', 'rows', workspaceId, databaseId ?? '', params] as const),\n /** A workspace's pages; no id: every workspace's. */\n pages: (workspaceId?: string) =>\n workspaceId === undefined\n ? (['arbi', 'pages'] as const)\n : (['arbi', 'pages', workspaceId] as const),\n /**\n * Saved table views a workspace's session sees: of one table (a database id or `documents`);\n * no target: every table's; no workspace: every workspace's.\n */\n tableViews: (workspaceId?: string, target?: string) =>\n workspaceId === undefined\n ? (['arbi', 'table-views'] as const)\n : target === undefined\n ? (['arbi', 'table-views', workspaceId] as const)\n : (['arbi', 'table-views', workspaceId, target] as const),\n /**\n * A view's rows with its database (a page's table block), under `databaseRows`' prefix so every\n * row write refreshes it: the database is the view's, unknown until read.\n */\n tableViewRows: (workspaceId: string, viewId: string) =>\n ['arbi', 'databases', 'rows', workspaceId, '', { view: viewId }] as const,\n /** A workspace's items counted on the server (a chart); no workspace: every workspace's. */\n workspaceAggregate: (workspaceId?: string, query?: object) =>\n workspaceId === undefined\n ? (['arbi', 'workspaceAggregate'] as const)\n : (['arbi', 'workspaceAggregate', workspaceId, query ?? {}] as const),\n /** A database's rows grouped and measured (a chart); no workspace: every database's. */\n databaseAggregate: (workspaceId?: string, databaseId?: string, request?: object) =>\n workspaceId === undefined\n ? (['arbi', 'databases', 'aggregate'] as const)\n : (['arbi', 'databases', 'aggregate', workspaceId, databaseId ?? '', request ?? {}] as const),\n // ── Configs, health ─────────────────────────────────────────────────────────────────────────\n /** Under `configs()`: the saved configuration versions. */\n configVersions: () => ['arbi', 'configs', 'versions'] as const,\n /** Under `configs()`: the JSON schema of every config model. */\n configSchema: () => ['arbi', 'configs', 'schema'] as const,\n /** Under `configs()`: one configuration. */\n config: (configId: string) => ['arbi', 'configs', 'one', configId] as const,\n /** The remote model providers' health. */\n remoteModels: () => ['arbi', 'remoteModels'] as const,\n // ── Conversations ───────────────────────────────────────────────────────────────────────────\n /** Under the conversations prefix: what a parked run waits for the owner to allow. */\n conversationPendingAuth: (conversationId: string) =>\n ['arbi', 'conversations', conversationId, 'pending-auth'] as const,\n // ── Document tools ──────────────────────────────────────────────────────────────────────────\n /** Signatures on a document (a version); no id: every document's. */\n documentSignatures: (docId?: string, version?: number | null) =>\n docId === undefined\n ? (['arbi', 'documentSignatures'] as const)\n : (['arbi', 'documentSignatures', docId, version ?? null] as const),\n /** The certificate of a signature reference. */\n signatureVerification: (reference: string) =>\n ['arbi', 'signatureVerification', reference] as const,\n /** Every signature request list: what a request write refreshes. */\n signatureRequests: () => ['arbi', 'signatureRequests'] as const,\n signatureRequestsForDocument: (docId: string) =>\n ['arbi', 'signatureRequests', 'document', docId] as const,\n /** Who may sign in a workspace; no id: every workspace's. */\n signatureCandidates: (workspaceId?: string) =>\n workspaceId === undefined\n ? (['arbi', 'signatureRequests', 'candidates'] as const)\n : (['arbi', 'signatureRequests', 'candidates', workspaceId] as const),\n /** The user's saved (informal) signature. */\n savedSignature: () => ['arbi', 'savedSignature'] as const,\n /** An html/react artifact's source. */\n artifactSource: (docId: string) => ['arbi', 'artifactSource', docId] as const,\n /** An artifact's text, under its parsed content (refreshed with it). */\n artifactText: (docId: string) => ['arbi', 'parsedDoc', docId, 'marker', 'artifact-text'] as const,\n /** An image document's bytes as an object URL. */\n assetImage: (docId: string) => ['arbi', 'assetImage', docId] as const,\n // ── Misc ────────────────────────────────────────────────────────────────────────────────────\n /** An agent config's model tier (the builder's badge). */\n agentConfigModel: (configId: string) => ['arbi', 'agentConfigModel', configId] as const,\n /** Under `billingQuotes()`: the price of a plan change. */\n billingPreview: (projectExtId: string, change: unknown) =>\n ['arbi', 'billingQuote', 'preview', projectExtId, change] as const,\n billingPlanQuote: (projectExtId: string | null, body: unknown) =>\n ['arbi', 'billingQuote', 'plan', projectExtId, body] as const,\n billingAddonQuote: (projectExtId: string, kind: string) =>\n ['arbi', 'billingQuote', 'addon', projectExtId, kind] as const,\n /** Under `contacts()`: a search of the people one can reach. */\n contactSearch: (term: string) => ['arbi', 'contacts', 'search', term] as const,\n /** Under the workspace's facts: a filtered list. */\n factList: (workspaceId: string, filter: unknown) =>\n ['arbi', 'facts', workspaceId, filter] as const,\n /**\n * Under `skills()`: a workspace's list, hidden ones included or not. Without a marketplace the\n * server lists the open workspace's skills, so the list is kept per workspace.\n */\n skillList: (workspaceId: string, includeHidden: boolean) =>\n ['arbi', 'skills', 'list', workspaceId, includeHidden] as const,\n /** Under the project's events: one kind, one page size. */\n projectEventList: (projectExtId: string, kind: string, limit: number | 'default') =>\n ['arbi', 'projects', projectExtId, 'events', kind, limit] as const,\n /** The documents pinned for offline reading on this device. */\n offlineDocuments: () => ['arbi', 'offlineDocuments'] as const,\n /** Notifications of one kind for a deployment's user (polled). */\n typedNotifications: (kind: string, apiUrl: string, userId: string | undefined) =>\n ['arbi', 'typedNotifications', kind, apiUrl, userId ?? ''] as const,\n}\n\n/**\n * Keys of the mutations a host may need to follow (its own caches outside these hooks), e.g. with\n * a `MutationCache` subscription: a workflow run creates a task in the host's own task list.\n */\nexport const arbiMutationKeys = {\n /** A member's role changed. */\n setWorkspaceMemberRoles: () => ['arbi', 'workspaces', 'roles'] as const,\n runWorkflow: () => ['arbi', 'workflows', 'run'] as const,\n startWorkflow: () => ['arbi', 'workflows', 'start'] as const,\n updateTagKindSchema: () => ['arbi', 'tags', 'kinds', 'update'] as const,\n createTag: () => ['arbi', 'tags', 'create'] as const,\n updateTag: () => ['arbi', 'tags', 'update'] as const,\n deleteTag: () => ['arbi', 'tags', 'delete'] as const,\n extractEntities: () => ['arbi', 'tags', 'entities', 'extract'] as const,\n updateDocuments: () => ['arbi', 'documents', 'update'] as const,\n deleteDocuments: () => ['arbi', 'documents', 'delete'] as const,\n uploadDocuments: () => ['arbi', 'documents', 'upload'] as const,\n uploadUrls: () => ['arbi', 'documents', 'uploadUrls'] as const,\n assignDocTags: () => ['arbi', 'doctags', 'assign'] as const,\n removeDocTags: () => ['arbi', 'doctags', 'remove'] as const,\n updateDocTag: () => ['arbi', 'doctags', 'update'] as const,\n generateDocTags: () => ['arbi', 'doctags', 'generate'] as const,\n /** Members added to or removed from a workspace (leaving included). */\n workspaceMembership: () => ['arbi', 'workspaces', 'members'] as const,\n /** A chat turn being sent (the app's send pipeline). */\n sendMessage: () => ['arbi', 'conversations', 'send'] as const,\n}\n\n/**\n * Query keys of the calendar hooks, all under `['arbi', 'calendar']`. The calendar is the user's,\n * not a workspace's; only the overlays carry the open workspace.\n */\nexport const calendarQueryKeys = {\n all: () => ['arbi', 'calendar'] as const,\n settings: () => ['arbi', 'calendar', 'settings'] as const,\n calendars: () => ['arbi', 'calendar', 'calendars'] as const,\n /** Every event list: the prefix an event write invalidates. */\n events: () => ['arbi', 'calendar', 'events'] as const,\n eventList: (p: ListEventsParams) =>\n [\n 'arbi',\n 'calendar',\n 'events',\n { start: p.start, end: p.end, calendars: p.calendars?.join(',') ?? null },\n ] as const,\n /** Every single event read. */\n eventDetails: () => ['arbi', 'calendar', 'event'] as const,\n event: (id: string, recurrenceId?: string | null) =>\n ['arbi', 'calendar', 'event', id, recurrenceId ?? null] as const,\n shares: (calId: string) => ['arbi', 'calendar', 'shares', calId] as const,\n invitations: () => ['arbi', 'calendar', 'invitations'] as const,\n holidayCountries: () => ['arbi', 'calendar', 'holiday-countries'] as const,\n allRooms: () => ['arbi', 'calendar', 'rooms'] as const,\n rooms: (q: RoomQuery) => ['arbi', 'calendar', 'rooms', q] as const,\n freebusy: (attendees: string[], start: string, end: string) =>\n ['arbi', 'calendar', 'freebusy', attendees.join(','), start, end] as const,\n allLookups: () => ['arbi', 'calendar', 'lookup'] as const,\n lookup: (uid: string) => ['arbi', 'calendar', 'lookup', uid] as const,\n overlays: (workspaceId: string | null, w?: CalendarWindow, layers?: OverlayLayerName[]) =>\n [\n 'arbi',\n 'calendar',\n 'overlays',\n workspaceId,\n w ? { start: w.start, end: w.end, layers: layers?.join(',') } : null,\n ] as const,\n accounts: () => ['arbi', 'calendar', 'accounts'] as const,\n caldavProfiles: () => ['arbi', 'calendar', 'caldav-profiles'] as const,\n bookingPages: () => ['arbi', 'calendar', 'booking-pages'] as const,\n /** The offline outbox (writes made offline, not yet sent). */\n outbox: () => ['arbi', 'calendar', 'outbox'] as const,\n}\n\n/** Query keys of the call hooks, all under `['arbi', 'calls']`. Calls are the user's, not a workspace's. */\nexport const callQueryKeys = {\n all: () => ['arbi', 'calls'] as const,\n config: () => ['arbi', 'calls', 'config'] as const,\n call: (callExtId: string) => ['arbi', 'calls', 'call', callExtId] as const,\n /** Everything about a call's recordings: the prefix a recording event invalidates. */\n recordingsOf: (callExtId: string) => ['arbi', 'calls', 'recordings', callExtId] as const,\n recordings: (callExtId: string) => ['arbi', 'calls', 'recordings', callExtId, 'list'] as const,\n recording: (callExtId: string, recordingExtId: string) =>\n ['arbi', 'calls', 'recordings', callExtId, 'one', recordingExtId] as const,\n inviteLinks: (callExtId: string) => ['arbi', 'calls', 'invite-links', callExtId] as const,\n}\n\nexport const connectorQueryKeys = {\n all: () => ['arbi', 'connectors'] as const,\n catalog: () => ['arbi', 'connectors', 'catalog'] as const,\n mine: () => ['arbi', 'connectors', 'mine'] as const,\n mailboxFolders: (vendor: string) => ['arbi', 'connectors', 'folders', vendor] as const,\n mailboxSyncProgress: (vendor: string, workspaceExtId: string) =>\n ['arbi', 'connectors', 'sync-progress', vendor, workspaceExtId] as const,\n allMailboxSyncProgress: () => ['arbi', 'connectors', 'sync-progress'] as const,\n driveFolders: (vendor: string) => ['arbi', 'connectors', 'drive-folders', vendor] as const,\n driveFolderChildren: (vendor: string, itemId: string) =>\n ['arbi', 'connectors', 'drive-folder-children', vendor, itemId] as const,\n driveFolderDocCount: (vendor: string, itemId: string) =>\n ['arbi', 'connectors', 'drive-folder-doc-count', vendor, itemId] as const,\n driveSyncEstimate: (vendor: string) =>\n ['arbi', 'connectors', 'drive-sync-estimate', vendor] as const,\n driveSyncProgress: (vendor: string) =>\n ['arbi', 'connectors', 'drive-sync-progress', vendor] as const,\n allDriveSyncProgress: () => ['arbi', 'connectors', 'drive-sync-progress'] as const,\n slack: () => ['arbi', 'connectors', 'slack'] as const,\n}\n\nexport const mailQueryKeys = {\n all: () => ['arbi', 'mail'] as const,\n policy: () => ['arbi', 'mail', 'policy'] as const,\n accounts: () => ['arbi', 'mail', 'accounts'] as const,\n unlock: (accountId: string | undefined, sessionKey: string | null) =>\n ['arbi', 'mail', 'unlock', accountId, sessionKey ?? ''] as const,\n allFolders: () => ['arbi', 'mail', 'folders'] as const,\n folders: (accountId: string | undefined) => ['arbi', 'mail', 'folders', accountId] as const,\n allMessages: () => ['arbi', 'mail', 'messages'] as const,\n messages: (\n accountId: string | undefined,\n folderId: string | undefined,\n query: string,\n cursor: string | null\n ) => ['arbi', 'mail', 'messages', accountId, folderId, query, cursor] as const,\n message: (accountId: string | undefined, messageId: string | null | undefined) =>\n ['arbi', 'mail', 'message', accountId, messageId] as const,\n /** Every conversation list: the prefix a flag or move patches or refreshes. */\n allConversations: () => ['arbi', 'mail', 'conversations'] as const,\n conversations: (\n accountId: string | undefined,\n folderId: string | undefined,\n query: string,\n cursor: string | null\n ) => ['arbi', 'mail', 'conversations', accountId, folderId, query, cursor] as const,\n /** Every thread read of an account. */\n accountThreads: (accountId: string) => ['arbi', 'mail', 'thread', accountId] as const,\n thread: (\n accountId: string | undefined,\n threadId: string | null | undefined,\n folderId: string | undefined\n ) => ['arbi', 'mail', 'thread', accountId, threadId, folderId] as const,\n /** Where the ARBI mailbox files mail (folders and conversations, per workspace). */\n nativeFiling: () => ['arbi', 'mail', 'filing', 'native'] as const,\n /** Every filing lookup: refreshed after mail is added to a workspace or a rule is stopped. */\n allFiling: () => ['arbi', 'mail', 'filing'] as const,\n filing: (accountId: string | undefined, messageIds: string[], threadIds: string[]) =>\n ['arbi', 'mail', 'filing', accountId, messageIds.join(' '), threadIds.join(' ')] as const,\n /** The key the user's client keys older native mail with: outside the `['arbi', 'mail']` prefix, so\n * refreshing mail never fetches it again. */\n threadSecret: () => ['arbi', 'mail-thread-secret'] as const,\n /** The projects an email's AI work can be billed to. */\n projects: () => ['arbi', 'mail', 'projects'] as const,\n /** A saved draft prepared for editing. */\n draftCompose: (accountId: string | undefined, draftId: string | undefined) =>\n ['arbi', 'mail', 'draft-compose', accountId, draftId] as const,\n attachmentText: (accountId: string, messageId: string, attachmentId: string) =>\n ['arbi', 'mail', 'attachment-text', accountId, messageId, attachmentId] as const,\n}\n\n/** `pdf`: the document as a PDF; `original`: the stored file (an image, a recording, a sheet). */\nexport type DocumentBytesKind = 'pdf' | 'original'\n\n/** Every version and kind of a document's bytes: the prefix a new version invalidates. */\nexport const documentBytesKey = (\n documentRef: string,\n version?: number | null,\n kind?: DocumentBytesKind\n) =>\n version === undefined\n ? (['arbi', 'documentBytes', documentRef] as const)\n : (['arbi', 'documentBytes', documentRef, version, kind ?? 'pdf'] as const)\n\n/** Whether `queryKey` lies under `prefix` (a factory key): React Query's own prefix match. */\nexport function isUnderQueryKey(queryKey: readonly unknown[], prefix: readonly unknown[]): boolean {\n return prefix.every((part, i) => queryKey[i] === part)\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkP2DPOZBS_cjs = require('./chunk-P2DPOZBS.cjs');
3
+ var chunk5ZNO77YB_cjs = require('./chunk-5ZNO77YB.cjs');
4
4
  var chunkKULS4YWP_cjs = require('./chunk-KULS4YWP.cjs');
5
5
  var react = require('react');
6
6
  var jsxRuntime = require('react/jsx-runtime');
@@ -49,7 +49,7 @@ function certificateLink(signature, certificateUrl) {
49
49
  }
50
50
  var DocumentToolsContext = react.createContext(null);
51
51
  function DocumentToolsProvider({ children, ...env }) {
52
- const arbiDeploymentDomain = chunkP2DPOZBS_cjs.useDeploymentDomain();
52
+ const arbiDeploymentDomain = chunk5ZNO77YB_cjs.useDeploymentDomain();
53
53
  const guards = react.useRef(/* @__PURE__ */ new Map());
54
54
  const pendingFlushes = react.useRef(/* @__PURE__ */ new Map());
55
55
  const registerBeforeFileShare = react.useCallback((id, flush) => {
@@ -275,7 +275,7 @@ function useDocumentSignatures(documentId, enabled = true) {
275
275
  const { client } = useDocumentTools();
276
276
  const { docId, version } = chunkKULS4YWP_cjs.parseVersionRef(documentId);
277
277
  return reactQuery.useQuery({
278
- queryKey: chunkP2DPOZBS_cjs.arbiQueryKeys.documentSignatures(docId ?? "", version),
278
+ queryKey: chunk5ZNO77YB_cjs.arbiQueryKeys.documentSignatures(docId ?? "", version),
279
279
  queryFn: () => fetchDocumentSignatures(client, documentId),
280
280
  enabled: enabled && !!docId,
281
281
  staleTime: 6e4
@@ -349,7 +349,7 @@ function useSignDocument() {
349
349
  },
350
350
  onSuccess: async (result) => {
351
351
  await env.onDocumentsChanged?.([result.doc_ext_id], "signed");
352
- await queryClient.invalidateQueries({ queryKey: chunkP2DPOZBS_cjs.arbiQueryKeys.documentSignatures() });
352
+ await queryClient.invalidateQueries({ queryKey: chunk5ZNO77YB_cjs.arbiQueryKeys.documentSignatures() });
353
353
  }
354
354
  });
355
355
  }
@@ -427,14 +427,14 @@ async function signFileShare(client$1, domain, vars) {
427
427
  }
428
428
  function useFileShare(client, shareId, signing) {
429
429
  return reactQuery.useQuery({
430
- queryKey: chunkP2DPOZBS_cjs.arbiQueryKeys.fileShare(shareId),
430
+ queryKey: chunk5ZNO77YB_cjs.arbiQueryKeys.fileShare(shareId),
431
431
  queryFn: () => getFileShare(client, shareId),
432
432
  refetchInterval: signing ? false : 5e3
433
433
  });
434
434
  }
435
435
  function useFileSharePdf(client, shareId, share) {
436
436
  return reactQuery.useQuery({
437
- queryKey: chunkP2DPOZBS_cjs.arbiQueryKeys.fileSharePdf(shareId, share?.status),
437
+ queryKey: chunk5ZNO77YB_cjs.arbiQueryKeys.fileSharePdf(shareId, share?.status),
438
438
  queryFn: () => fileShareBytes(client, shareId, share?.status === "completed" ? "signed" : "view"),
439
439
  enabled: !!share?.can_preview,
440
440
  staleTime: Infinity
@@ -442,7 +442,7 @@ function useFileSharePdf(client, shareId, share) {
442
442
  }
443
443
  function useFileShares(client) {
444
444
  return reactQuery.useQuery({
445
- queryKey: chunkP2DPOZBS_cjs.arbiQueryKeys.fileShares(),
445
+ queryKey: chunk5ZNO77YB_cjs.arbiQueryKeys.fileShares(),
446
446
  queryFn: async () => {
447
447
  const result = await client?.GET("/v1/file-shares");
448
448
  if (!result?.data) throw new Error("Could not load shared files");
@@ -454,7 +454,7 @@ function useFileShares(client) {
454
454
  function useRefreshFileShares() {
455
455
  const queryClient = reactQuery.useQueryClient();
456
456
  return react.useCallback(
457
- () => queryClient.invalidateQueries({ queryKey: chunkP2DPOZBS_cjs.arbiQueryKeys.fileShares() }),
457
+ () => queryClient.invalidateQueries({ queryKey: chunk5ZNO77YB_cjs.arbiQueryKeys.fileShares() }),
458
458
  [queryClient]
459
459
  );
460
460
  }
@@ -503,5 +503,5 @@ exports.useFileShares = useFileShares;
503
503
  exports.useOptionalDocumentTools = useOptionalDocumentTools;
504
504
  exports.useRefreshFileShares = useRefreshFileShares;
505
505
  exports.useSignDocument = useSignDocument;
506
- //# sourceMappingURL=chunk-BI7HFGXF.cjs.map
507
- //# sourceMappingURL=chunk-BI7HFGXF.cjs.map
506
+ //# sourceMappingURL=chunk-H2TP7JWR.cjs.map
507
+ //# sourceMappingURL=chunk-H2TP7JWR.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/document-tools/environment.tsx","../src/document-tools/document-pdf.ts","../src/document-tools/markup-download.ts","../src/document-tools/signing.ts","../src/document-tools/file-shares.ts"],"names":["createContext","useDeploymentDomain","useRef","useCallback","useMemo","jsx","useContext","parseVersionRef","useQuery","arbiQueryKeys","client","unlockIdentityWithPassword","signMessage","useQueryClient","useMutation"],"mappings":";;;;;;;;;AAmEO,SAAS,kBAAkB,KAAA,EAAoC;AACpE,EAAA,MAAM,MAAA,GAAS,IAAI,eAAA,EAAgB;AACnC,EAAA,K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AA,IACA,EAAE,MAAA,EAAQ,EAAE,IAAA,EAAM,EAAE,eAAA,EAAiB,KAAA,CAAM,eAAA,EAAiB,QAAA,EAAU,KAAA,CAAM,WAAA,EAAY,EAAE;AAAE,GAC9F;AACA,EAAA,IAAI,CAAC,MAAA,CAAO,IAAA,EAAM,MAAM,IAAI,MAAM,oDAAoD,CAAA;AACtF,EAAA,OAAO,MAAA,CAAO,IAAA;AAChB","file":"chunk-BI7HFGXF.cjs","sourcesContent":["/**\n * The host app's side of the document tools (markup, freeze, e-signing, versions): the one place\n * the tools reach the app. They never import a store, a router, a toast library or app API code;\n * the host passes what it has to `<DocumentToolsProvider>` and every optional field has a default.\n *\n * `client` is an openapi-fetch client for the ARBI API (`ArbiClient['fetch']` from\n * `@arbidocs/client`, or `arbi.getClient().fetch` from an `@arbidocs/sdk` `Arbi`), signed in with the\n * user's session; it carries the auth.\n */\n\nimport { createContext, useCallback, useContext, useMemo, useRef, type ReactNode } from 'react'\nimport type { ArbiClient, operations } from '@arbidocs/client'\nimport { useDeploymentDomain } from '../useArbi'\n\nexport type DocumentToolsClient = ArbiClient['fetch']\n\nexport type DocumentToolsNoticeKind = 'success' | 'error' | 'info' | 'warning'\n\nexport interface DocumentToolsNoticeOptions {\n /** A second line under the message. */\n description?: string\n /** One action button on the notice (\"Email it\"). */\n action?: { label: string; onClick: () => void }\n}\n\nexport type DocumentToolsNotify = (\n message: string,\n kind: DocumentToolsNoticeKind,\n options?: DocumentToolsNoticeOptions\n) => void\n\nexport interface DocumentToolsUser {\n /** The name marks are authored as and the signer's name is prefilled with. */\n name: string\n /** The sign-in email: signing re-derives the user's key from it and the password. */\n email?: string | null\n /** The user's id (usr-*): which fields of a signature request are theirs. */\n externalId?: string | null\n}\n\n/** What changed about a document, so the host can refresh its own lists and caches. */\nexport type DocumentChange =\n /** A version's markup got its first mark or lost its last one. */\n | 'markup'\n /** A signature was added: the document has a new current version. */\n | 'signed'\n /** A new document was made from it (a frozen copy). The ids are the NEW documents. */\n | 'copy'\n /** A new version was saved (the Word editor's Save version): the document's current version. */\n | 'version'\n\n/**\n * The `/v1/document/upload` query, typed from the API schema: `derived_from` is a list (a\n * production set is derived from every document in it), `shared` a boolean.\n */\nexport type DocumentUploadQuery = NonNullable<operations['upload_documents']['parameters']['query']>\n\nexport interface DocumentUploadRequest {\n file: File\n /** `/v1/document/upload` query: `derived_from`, `derived_role`, `shared`, `folder`. */\n query: DocumentUploadQuery\n}\n\n/**\n * The upload query as a URL query string, for a host that posts the upload itself (an XHR with\n * progress): a list repeats its key (`derived_from=a&derived_from=b`), empty values are left out.\n */\nexport function uploadQueryString(query: DocumentUploadQuery): string {\n const params = new URLSearchParams()\n for (const [key, value] of Object.entries(query)) {\n if (value === null || value === undefined) continue\n for (const item of Array.isArray(value) ? value : [value]) params.append(key, String(item))\n }\n return params.toString()\n}\n\nexport interface DocumentToolsEnvironment {\n client: DocumentToolsClient\n /**\n * The deployment domain the user's keys are derived for. Needed for signing. Default: the one\n * the host's `Arbi` computes (`arbi.getDeploymentDomain()`), if any.\n */\n deploymentDomain?: string\n /** The signed-in user; marks are authored as \"You\" without one, and signing is unavailable. */\n user?: DocumentToolsUser | null\n /** Surface a transient message. Default: none (errors still show inline where they can). */\n notify?: DocumentToolsNotify\n /** Open a document or a version reference (`doc-…@v2`): the copy just made, the signed copy. */\n openDocument?: (documentRef: string) => void\n /**\n * Documents changed on the server (see {@link DocumentChange}); refresh the host's lists. The\n * tools wait for it before opening the document, so a copy is listed when it opens.\n */\n onDocumentsChanged?: (documentIds: string[], change: DocumentChange) => void | Promise<void>\n /** Upload a derived copy. Default: `POST /v1/document/upload` through `client`. */\n uploadDocument?: (\n request: DocumentUploadRequest\n ) => Promise<{ doc_ext_ids?: string[] } | undefined>\n /** Save a file to the user's computer. Default: a temporary download link. */\n saveFile?: (blob: Blob, fileName: string) => void\n /** Email a document (offered once it is signed). Omitted: no \"Email it\". */\n emailDocument?: (documentRef: string) => void\n /**\n * The public page that checks a signature (the certificate) in this app. When given, \"View\n * certificate\" opens it in preference to the backend's `certificate_url` (which is on the\n * deployment domain, like the link embedded in the signed PDF). Without it: the backend's\n * `certificate_url`, else `/verify/{reference}` on this origin.\n */\n certificateUrl?: (reference: string) => string\n}\n\n/** The environment with every default filled in. */\nexport interface ResolvedDocumentToolsEnvironment extends DocumentToolsEnvironment {\n prepareFileShare: (documentId: string) => Promise<void>\n registerBeforeFileShare: (documentId: string, flush: () => Promise<void>) => () => void\n notify: DocumentToolsNotify\n saveFile: (blob: Blob, fileName: string) => void\n uploadDocument: (\n request: DocumentUploadRequest\n ) => Promise<{ doc_ext_ids?: string[] } | undefined>\n}\n\n/**\n * Save a blob through a temporary `<a download>`. The object URL is revoked a minute later, not at\n * once: revoking straight after `click()` can cancel the download (Safari, and large files\n * elsewhere) before the browser has read the blob.\n */\nexport function downloadBlob(blob: Blob, fileName: string): void {\n const url = URL.createObjectURL(blob)\n const a = document.createElement('a')\n a.href = url\n a.download = fileName\n document.body.appendChild(a)\n a.click()\n a.remove()\n setTimeout(() => URL.revokeObjectURL(url), 60_000)\n}\n\n/** The default upload: multipart `files` to `/v1/document/upload` through the API client. */\nexport function clientUpload(client: DocumentToolsClient) {\n return async ({ file, query }: DocumentUploadRequest) => {\n const formData = new FormData()\n formData.append('files', file)\n const { data, response } = await client.POST('/v1/document/upload', {\n params: { query },\n // The schema types the multipart body as `{ files: string[] }`; the FormData is sent as is.\n body: formData as unknown as { files: string[] },\n bodySerializer: () => formData,\n })\n if (!response.ok) throw new Error(`Upload failed with status ${response.status}`)\n return data\n }\n}\n\nexport function defaultCertificateUrl(reference: string): string {\n const origin = typeof location === 'undefined' ? '' : location.origin\n return `${origin}/verify/${encodeURIComponent(reference)}`\n}\n\n/**\n * Where \"View certificate\" goes for a signature: the host's `certificateUrl(reference)` when it\n * gives one, else the `certificate_url` the backend returned, else `/verify/{reference}` here.\n */\nexport function certificateLink(\n signature: { reference: string; certificate_url?: string | null },\n certificateUrl?: (reference: string) => string\n): string {\n if (certificateUrl) return certificateUrl(signature.reference)\n return signature.certificate_url || defaultCertificateUrl(signature.reference)\n}\n\nconst DocumentToolsContext = createContext<ResolvedDocumentToolsEnvironment | null>(null)\n\nexport interface DocumentToolsProviderProps extends DocumentToolsEnvironment {\n children: ReactNode\n}\n\nexport function DocumentToolsProvider({ children, ...env }: DocumentToolsProviderProps) {\n const arbiDeploymentDomain = useDeploymentDomain()\n const guards = useRef(new Map<string, () => Promise<void>>())\n const pendingFlushes = useRef(new Map<string, Promise<void>>())\n const registerBeforeFileShare = useCallback((id: string, flush: () => Promise<void>) => {\n guards.current.set(id, flush)\n return () => {\n if (guards.current.get(id) !== flush) return\n guards.current.delete(id)\n const pending = flush()\n pendingFlushes.current.set(id, pending)\n void pending.then(\n () => {\n if (pendingFlushes.current.get(id) === pending) pendingFlushes.current.delete(id)\n },\n () => {}\n )\n }\n }, [])\n const prepareFileShare = useCallback(async (id: string) => {\n const guard = guards.current.get(id)\n if (guard) {\n await guard()\n pendingFlushes.current.delete(id)\n } else await pendingFlushes.current.get(id)\n }, [])\n const {\n client,\n deploymentDomain,\n user,\n notify,\n openDocument,\n onDocumentsChanged,\n uploadDocument,\n saveFile,\n emailDocument,\n certificateUrl,\n } = env\n const value = useMemo<ResolvedDocumentToolsEnvironment>(\n () => ({\n client,\n prepareFileShare,\n registerBeforeFileShare,\n deploymentDomain: deploymentDomain ?? arbiDeploymentDomain,\n user,\n openDocument,\n onDocumentsChanged,\n emailDocument,\n notify: notify ?? (() => {}),\n saveFile: saveFile ?? downloadBlob,\n uploadDocument: uploadDocument ?? clientUpload(client),\n certificateUrl,\n }),\n [\n client,\n prepareFileShare,\n registerBeforeFileShare,\n deploymentDomain,\n arbiDeploymentDomain,\n user,\n notify,\n openDocument,\n onDocumentsChanged,\n uploadDocument,\n saveFile,\n emailDocument,\n certificateUrl,\n ]\n )\n return <DocumentToolsContext.Provider value={value}>{children}</DocumentToolsContext.Provider>\n}\n\n/** The host's environment, or `null` outside a `<DocumentToolsProvider>`. */\nexport function useOptionalDocumentTools(): ResolvedDocumentToolsEnvironment | null {\n return useContext(DocumentToolsContext)\n}\n\n/** The host's environment; throws outside a `<DocumentToolsProvider>`. */\nexport function useDocumentTools(): ResolvedDocumentToolsEnvironment {\n const env = useContext(DocumentToolsContext)\n if (!env) throw new Error('The document tools must be used within a <DocumentToolsProvider>')\n return env\n}\n","/**\n * A document's bytes, through the host's API client: the PDF the viewer and the tools draw on\n * (`/view`: the file itself for a PDF, its PDF rendering for a Word or text file) and the stored\n * file (`/download`). Either takes a document id or a version reference `doc-…@v{n}`.\n */\n\nimport { parseVersionRef } from '../artifacts/versions'\nimport type { DocumentToolsClient } from './environment'\n\nexport interface DocumentFetchOptions {\n /** The version to fetch. Default: the one `documentRef` names, else the current version. */\n version?: number | null\n workspaceExtId?: string\n signal?: AbortSignal\n}\n\n/** A document's bytes could not be fetched; `status` is the HTTP status. */\nexport class DocumentFetchError extends Error {\n readonly status: number\n constructor(message: string, status: number) {\n super(message)\n this.name = 'DocumentFetchError'\n this.status = status\n }\n}\n\nasync function fetchDocumentBytes(\n client: DocumentToolsClient,\n endpoint: '/v1/document/{document_ext_id}/view' | '/v1/document/{document_ext_id}/download',\n documentRef: string,\n options: DocumentFetchOptions,\n headers: Record<string, string>,\n what: string\n): Promise<{ blob: Blob; response: Response }> {\n const ref = parseVersionRef(documentRef)\n const version = options.version ?? ref.version\n const { data, response } = await client.GET(endpoint, {\n params: {\n path: { document_ext_id: ref.docId },\n query: {\n ...(version ? { version } : {}),\n ...(options.workspaceExtId ? { workspace_ext_id: options.workspaceExtId } : {}),\n },\n },\n headers,\n parseAs: 'blob',\n signal: options.signal,\n })\n if (!response.ok || !(data instanceof Blob)) {\n throw new DocumentFetchError(\n `${what} could not be loaded (${response.status})`,\n response.status\n )\n }\n return { blob: data, response }\n}\n\n/**\n * The file name a `Content-Disposition` header gives, or `undefined`. Prefers the RFC 5987\n * `filename*=UTF-8''…` form (percent-encoded, any script) over the plain `filename=`.\n */\nexport function contentDispositionFileName(header: string | null | undefined): string | undefined {\n if (!header) return undefined\n const extended = /filename\\*\\s*=\\s*(?:[\\w-]+)?'[^']*'([^;]+)/i.exec(header)\n if (extended) {\n try {\n return decodeURIComponent(extended[1].trim().replace(/^\"|\"$/g, '')) || undefined\n } catch {\n // A malformed escape: fall back to the plain parameter.\n }\n }\n const plain = /filename\\s*=\\s*(\"((?:[^\"\\\\]|\\\\.)*)\"|[^;]+)/i.exec(header)\n if (!plain) return undefined\n const name = plain[2] !== undefined ? plain[2].replace(/\\\\(.)/g, '$1') : plain[1].trim()\n return name || undefined\n}\n\n/**\n * The PDF of a document version: `GET /v1/document/{id}/view?version=` with\n * `Accept: application/pdf`. Throws a {@link DocumentFetchError} when there is none (yet).\n */\nexport async function fetchDocumentPdf(\n client: DocumentToolsClient,\n documentRef: string,\n options: DocumentFetchOptions = {}\n): Promise<Blob> {\n const { blob } = await fetchDocumentBytes(\n client,\n '/v1/document/{document_ext_id}/view',\n documentRef,\n options,\n { Accept: 'application/pdf' },\n 'The PDF'\n )\n return blob\n}\n\n/**\n * The stored file of a document version, as uploaded: `GET /v1/document/{id}/download`. When the\n * server names the file (`Content-Disposition`), the result is a `File` carrying that name.\n */\nexport async function fetchDocumentFile(\n client: DocumentToolsClient,\n documentRef: string,\n options: DocumentFetchOptions = {}\n): Promise<Blob | File> {\n const { blob, response } = await fetchDocumentBytes(\n client,\n '/v1/document/{document_ext_id}/download',\n documentRef,\n options,\n {},\n 'The file'\n )\n const name = contentDispositionFileName(response.headers.get('Content-Disposition'))\n return name ? new File([blob], name, { type: blob.type }) : blob\n}\n","/**\n * \"Download with markup\": a document version's markup PDF, the PDF with its annotations as native\n * PDF annotations (comments, highlights, stamps, unapplied redactions), which Acrobat and Preview\n * show. The plain Download serves the original. Kept apart from the annotation layer code so a\n * documents list can offer it without loading the annotation tools.\n *\n * A SIGNED version is locked: nothing but a further signature changes it. Its markup stays in the\n * separate markup layer (a title beside the signature, say) and is never written into its PDF, so\n * it has no \"Download with markup\"; the plain Download is the signed file as it is.\n */\n\nimport type { DocumentToolsClient } from './environment'\n\ninterface DocumentVersions {\n current_version?: number | null\n versions?: Array<{ n: number; markup_count?: number | null; reason?: string | null }> | null\n}\n\n/** Why \"Download with markup\" is off for a signed version. */\nexport const SIGNED_LOCKED_REASON =\n \"Signed documents can't be changed — download the signed file instead\"\n\n/** Whether a version (default: the current one) is a signed copy, per its version entry. */\nexport function isSignedVersion(doc: DocumentVersions, version?: number): boolean {\n const n = version ?? doc.current_version ?? 1\n return (doc.versions ?? []).some((v) => v.n === n && v.reason === 'signed')\n}\n\nexport class MarkupDownloadError extends Error {\n constructor(\n message: string,\n readonly status?: number\n ) {\n super(message)\n this.name = 'MarkupDownloadError'\n }\n}\n\n/** Whether a document's current version has markup (per its version entries). */\nexport function currentHasMarkup(doc: DocumentVersions): boolean {\n const n = doc.current_version ?? 1\n return (doc.versions ?? []).some((v) => v.n === n && (v.markup_count ?? 0) > 0)\n}\n\n/** Fetch a version's markup PDF (default: the current version's). */\nexport async function fetchMarkupPdf(\n client: DocumentToolsClient,\n documentId: string,\n version?: number,\n workspaceExtId?: string\n): Promise<{ blob: Blob; fileName: string }> {\n const { data, response } = await client.GET('/v1/document/{document_ext_id}/markup/pdf', {\n params: {\n path: { document_ext_id: documentId },\n query: {\n ...(version ? { version } : {}),\n ...(workspaceExtId ? { workspace_ext_id: workspaceExtId } : {}),\n },\n },\n parseAs: 'blob',\n })\n if (!response.ok || !data) {\n throw new MarkupDownloadError(\n response.status === 404\n ? 'This document has no markup yet'\n : // The server refuses a signed version: its PDF takes no more changes.\n response.status === 409\n ? SIGNED_LOCKED_REASON\n : 'The markup could not be downloaded',\n response.status\n )\n }\n const disposition = response.headers.get('content-disposition') ?? ''\n const utf8 = /filename\\*=UTF-8''([^;]+)/i.exec(disposition)?.[1]\n const plain = /filename=\"([^\"]+)\"/i.exec(disposition)?.[1]\n const fileName = utf8 ? decodeURIComponent(utf8) : (plain ?? 'markup.pdf')\n return { blob: data as Blob, fileName }\n}\n","/**\n * Electronic signing. The backend (`src/core/esign.py` in ARBI) defines what a signature binds;\n * the helpers mirror the two pieces the browser must reproduce exactly: the statement of intent\n * shown to the signer, and the SHA-256 of the PDF the viewer displayed.\n */\n\nimport { signMessage, unlockIdentityWithPassword, type components } from '@arbidocs/client'\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'\nimport { parseVersionRef } from '../artifacts/versions'\nimport { useDocumentTools, type DocumentToolsClient } from './environment'\nimport { arbiQueryKeys } from '../query-keys'\n\n/**\n * Who signs: the name only. A role, a firm or a place go on the page as ordinary annotation text,\n * which is not part of the signature.\n */\nexport type SignerDetails = components['schemas']['SignerDetails']\n\n/** Same sentence as `esign.intent_text`; the dialog refuses to sign if the server's differs. */\nexport function intentText(signer: SignerDetails): string {\n return `I, ${signer.name.trim()}, sign this document electronically. I intend this electronic signature to have the same effect as my handwritten signature.`\n}\n\nexport async function sha256Hex(blob: Blob): Promise<string> {\n const digest = await crypto.subtle.digest('SHA-256', new Uint8Array(await blob.arrayBuffer()))\n return Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, '0')).join('')\n}\n\n/** A signature box drawn on the annotation overlay, as the signing API's placement. */\nexport function toAppearance(box: {\n page: number\n rect: { x: number; y: number; w: number; h: number }\n}): { page: number; x: number; y: number; width: number; height: number } {\n // The layer counts pages from 1, the signing API from 0. Both use fractions of the page as\n // displayed, origin top-left.\n return { page: box.page - 1, x: box.rect.x, y: box.rect.y, width: box.rect.w, height: box.rect.h }\n}\n\n/**\n * The smallest box the backend can draw a legible signature in: the signer's name and the\n * details line shrink to fit, so a box under these fractions of the page is shrunk to near\n * unreadable size. The backend's own default box is 0.40 x 0.10.\n */\nconst MIN_SIGNATURE_BOX = { width: 0.3, height: 0.07 }\n\nexport function isLegibleSignatureBox(rect: { w: number; h: number }): boolean {\n return rect.w >= MIN_SIGNATURE_BOX.width && rect.h >= MIN_SIGNATURE_BOX.height\n}\n\n// ── Signing through the API ─────────────────────────────────────────────────────────────────\n\nexport type SignatureAppearance = components['schemas']['SignatureAppearance']\nexport type SignatureStatusResponse = components['schemas']['SignatureStatusResponse']\nexport type SignatureRecord = components['schemas']['SignatureRecord']\nexport type SignDocumentResponse = components['schemas']['SignDocumentResponse']\n\nconst SIGNATURES_PATH = '/v1/document/{document_ext_id}/signatures'\n/**\n * The same key openapi-react-query gives this request (`['get', path, init]`), so a host that\n * reads or persists the API cache by path treats it like its own queries.\n */\n\nfunction errorDetail(error: unknown, fallback: string): string {\n const detail = (error as { detail?: unknown } | undefined)?.detail\n return typeof detail === 'string' ? detail : fallback\n}\n\n/** Whether a document version is a signed copy, and its signatures. */\nexport async function fetchDocumentSignatures(\n client: DocumentToolsClient,\n documentRef: string\n): Promise<SignatureStatusResponse> {\n const { docId, version } = parseVersionRef(documentRef)\n const { data, error } = await client.GET(SIGNATURES_PATH, {\n params: { path: { document_ext_id: docId }, ...(version ? { query: { version } } : {}) },\n })\n if (!data) throw new Error(errorDetail(error, 'The signatures could not be read'))\n return data\n}\n\n/**\n * Is a document version a signed copy? `documentId` is a document id (its current version) or a\n * version reference `doc-…@v{n}`. Needs a React Query `QueryClientProvider`.\n */\nexport function useDocumentSignatures(documentId: string | null | undefined, enabled = true) {\n const { client } = useDocumentTools()\n const { docId, version } = parseVersionRef(documentId)\n return useQuery({\n queryKey: arbiQueryKeys.documentSignatures(docId ?? '', version),\n queryFn: () => fetchDocumentSignatures(client, documentId!),\n enabled: enabled && !!docId,\n staleTime: 60_000,\n })\n}\n\n/**\n * Why the server would not sign: the PDF of a Word or text document is still being rendered\n * (`preparing`, worth another try in a moment), or the version on screen is no longer the current\n * one (`stale`: only the current version can be signed, so the signer reopens it).\n */\nexport type SigningErrorReason = 'preparing' | 'stale' | 'failed'\n\nexport class SigningError extends Error {\n readonly reason: SigningErrorReason\n constructor(message: string, reason: SigningErrorReason) {\n super(message)\n this.name = 'SigningError'\n this.reason = reason\n }\n}\n\n/** The 409s the backend's signing router raises, told apart by their wording. */\nfunction signingErrorReason(detail: string): SigningErrorReason {\n if (/still being prepared/i.test(detail)) return 'preparing'\n if (/no longer the current version/i.test(detail)) return 'stale'\n return 'failed'\n}\n\nfunction signingError(error: unknown, fallback: string): SigningError {\n const detail = errorDetail(error, fallback)\n return new SigningError(detail, signingErrorReason(detail))\n}\n\n/** How often, and how long apart, a prepare is retried while the PDF is still being rendered. */\nexport const PREPARE_RETRIES = 3\nconst PREPARE_RETRY_DELAY_MS = 1500\n\nconst wait = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))\n\nexport interface SignDocumentVars {\n documentId: string\n /**\n * The PDF bytes the viewer is showing (`GET /view?version=`, never the original's download): the\n * signer signs exactly these.\n */\n pdfBlob: Blob\n /**\n * The version `pdfBlob` is of. The server signs only the current version and refuses\n * (`SigningError` `stale`) when this one has been superseded. Omitted = the current version.\n */\n version?: number\n email: string\n password: string\n signer: SignerDetails\n /** Where the signature goes; omitted = the backend default (bottom of the last page). */\n appearance?: SignatureAppearance\n /** Draw the signing date under the signature. Default off: only the signature is drawn. */\n includeDate?: boolean\n}\n\n/**\n * Sign a document: the server prepares the statement, the browser checks that it covers the PDF\n * on screen under the wording the signer read, re-derives the user's Ed25519 key from their\n * password and signs it, and the server seals the signed copy as a new version.\n *\n * What is drawn on the page is only the signature (the signer's name as the signature mark) and,\n * with `includeDate`, the date; anyone can click it to open its certificate. A role, a firm or a\n * place go on the page as ordinary annotation text, which is not part of the signature.\n */\nexport async function signDocument(\n client: DocumentToolsClient,\n deploymentDomain: string,\n {\n documentId,\n pdfBlob,\n email,\n password,\n signer,\n appearance,\n includeDate = false,\n version,\n }: SignDocumentVars\n): Promise<SignDocumentResponse> {\n const path = { document_ext_id: documentId }\n // One body for both calls: the server refuses a /sign whose include_date (or placement) differs\n // from what was prepared, since what the signature shows is part of what is signed.\n const body = {\n signer: { name: signer.name },\n ...(appearance ? { appearance } : {}),\n include_date: includeDate,\n ...(version ? { version } : {}),\n }\n\n // A Word or text document's PDF is rendered after upload: while it is, prepare says so, and a\n // short wait usually sees it ready.\n const prepare = () =>\n client.POST('/v1/document/{document_ext_id}/sign/prepare', { params: { path }, body })\n let prepared = await prepare()\n for (let attempt = 0; !prepared.data && attempt < PREPARE_RETRIES; attempt++) {\n if (signingError(prepared.error, '').reason !== 'preparing') break\n await wait(PREPARE_RETRY_DELAY_MS)\n prepared = await prepare()\n }\n if (!prepared.data) throw signingError(prepared.error, 'Could not prepare signing')\n const { statement, intent, source_sha256, timestamp } = prepared.data\n // Sign only what was on screen, under the wording the signer read.\n if ((await sha256Hex(pdfBlob)) !== source_sha256) {\n throw new Error('The document changed since it was opened. Reopen it and sign again.')\n }\n if (intent !== intentText(signer)) throw new Error('Signing statement mismatch; not signed.')\n\n // The re-typed password must open the session's identity, which is the key the server verifies.\n const identity = await unlockIdentityWithPassword(email, password, deploymentDomain)\n const signed = await client.POST('/v1/document/{document_ext_id}/sign', {\n params: { path },\n body: { ...body, timestamp, signature: signMessage(statement, identity) },\n })\n if (!signed.data) throw signingError(signed.error, 'Signing failed')\n return signed.data\n}\n\n/** The signing mutation. On success the host hears the document changed (`'signed'`). */\nexport function useSignDocument() {\n const env = useDocumentTools()\n const queryClient = useQueryClient()\n return useMutation({\n mutationFn: (vars: SignDocumentVars) => {\n if (!env.deploymentDomain) throw new Error('Signing is not set up: no deployment domain')\n return signDocument(env.client, env.deploymentDomain, vars)\n },\n onSuccess: async (result) => {\n // The signed copy is the document's new current version: the host refreshes its row,\n // versions and rendered PDF, and the signature badge reads again.\n await env.onDocumentsChanged?.([result.doc_ext_id], 'signed')\n await queryClient.invalidateQueries({ queryKey: arbiQueryKeys.documentSignatures() })\n },\n })\n}\n","import { useCallback } from 'react'\nimport { useQuery, useQueryClient } from '@tanstack/react-query'\nimport { arbiQueryKeys } from '../query-keys'\n/** Share one immutable file version with named recipients, independently of workspace membership. */\nimport { signMessage, unlockIdentityWithPassword, type components } from '@arbidocs/client'\nimport type { DocumentToolsClient } from './environment'\nimport { intentText, sha256Hex } from './signing'\nimport type {\n SignatureRequest,\n SignRequestVars,\n SignRequestSignResponse,\n} from './signature-requests'\n\nexport type FileShare = components['schemas']['FileShareResponse']\nexport type CreateFileShare = components['schemas']['CreateFileShare']\n\nfunction failure(error: unknown): Error {\n const detail = (error as { detail?: unknown } | undefined)?.detail\n return new Error(typeof detail === 'string' ? detail : 'The shared file request failed')\n}\n\nexport async function createFileShare(\n client: DocumentToolsClient,\n documentId: string,\n body: CreateFileShare\n) {\n const result = await client.POST('/v1/document/{document_ext_id}/file-shares', {\n params: { path: { document_ext_id: documentId } },\n body,\n })\n if (!result.data) throw failure(result.error)\n return result.data\n}\n\nexport async function getFileShare(client: DocumentToolsClient, id: string): Promise<FileShare> {\n const result = await client.GET('/v1/file-shares/{share_id}', {\n params: { path: { share_id: id } },\n })\n if (!result.data) throw failure(result.error)\n return result.data\n}\n\nexport async function fileShareBytes(\n client: DocumentToolsClient,\n id: string,\n kind: 'view' | 'original' | 'signed'\n) {\n const result = await client.GET('/v1/file-shares/{share_id}/file', {\n params: { path: { share_id: id }, query: { kind } },\n parseAs: 'blob',\n })\n if (!result.data) throw failure(result.error)\n return result.data\n}\n\n/** Adapt only the guided viewer's presentation data; sharing uses its own authorization endpoints. */\nexport function fileShareSigningRequest(share: FileShare): SignatureRequest {\n return {\n external_id: share.external_id,\n doc_ext_id: share.document_ext_id,\n version: share.version,\n source_sha256: share.source_sha256,\n fields: share.fields,\n message: share.message,\n status:\n share.status === 'signing' ? 'sent' : share.status === 'completed' ? 'completed' : 'voided',\n signers: share.recipients\n .filter((r) => r.permission === 'sign')\n .map((r) => ({\n external_id: r.email,\n email: r.email,\n name: r.email,\n status: r.status === 'signed' ? 'signed' : 'pending',\n progress: r.status === 'signed' ? 'signed' : 'registered',\n fields: share.fields.filter((f) => f.signer === r.email).length,\n })),\n created_at: new Date(0).toISOString(),\n stale: false,\n }\n}\n\nexport async function signFileShare(\n client: DocumentToolsClient,\n domain: string,\n vars: SignRequestVars\n): Promise<SignRequestSignResponse> {\n const path = { share_id: vars.request.external_id }\n const body = { adopted: vars.adopted, fields: vars.fields }\n const prepared = await client.POST('/v1/file-shares/{share_id}/sign/prepare', {\n params: { path },\n body,\n })\n if (!prepared.data) throw failure(prepared.error)\n const { statement, timestamp, source_sha256, intent } = prepared.data\n if (\n source_sha256 !== vars.request.source_sha256 ||\n (await sha256Hex(vars.pdfBlob)) !== source_sha256\n )\n throw new Error('The shared file changed. Ask the sender for a new request.')\n if (intent !== intentText({ name: vars.adopted.name }))\n throw new Error('Signing statement mismatch')\n const identity = await unlockIdentityWithPassword(vars.email, vars.password, domain)\n const result = await client.POST('/v1/file-shares/{share_id}/sign', {\n params: { path },\n body: { ...body, timestamp, signature: signMessage(statement, identity) },\n })\n if (!result.data) throw failure(result.error)\n return {\n request: fileShareSigningRequest(result.data),\n completed: result.data.status === 'completed',\n }\n}\n\nexport function useFileShare(client: DocumentToolsClient, shareId: string, signing: boolean) {\n return useQuery({\n queryKey: arbiQueryKeys.fileShare(shareId),\n queryFn: () => getFileShare(client, shareId),\n refetchInterval: signing ? false : 5000,\n })\n}\n\nexport function useFileSharePdf(client: DocumentToolsClient, shareId: string, share?: FileShare) {\n return useQuery({\n queryKey: arbiQueryKeys.fileSharePdf(shareId, share?.status),\n queryFn: () =>\n fileShareBytes(client, shareId, share?.status === 'completed' ? 'signed' : 'view'),\n enabled: !!share?.can_preview,\n staleTime: Infinity,\n })\n}\n\n/** The shares I created or was invited to (revoked and expired ones are not listed). Listing does\n * not open a share, so it never starts a recipient's access window. Null client: not loaded. */\nexport function useFileShares(client: DocumentToolsClient | null) {\n return useQuery({\n queryKey: arbiQueryKeys.fileShares(),\n queryFn: async () => {\n const result = await client?.GET('/v1/file-shares')\n if (!result?.data) throw new Error('Could not load shared files')\n return result.data\n },\n enabled: !!client,\n })\n}\n\n/** Read the share list again (after a change made to a share: signed, declined, saved, revoked). */\nexport function useRefreshFileShares(): () => Promise<void> {\n const queryClient = useQueryClient()\n return useCallback(\n () => queryClient.invalidateQueries({ queryKey: arbiQueryKeys.fileShares() }),\n [queryClient]\n )\n}\n\n/**\n * Save a completed share's signed PDF as its document's next version, in the share's workspace\n * (its key must be on the session: open that workspace first).\n */\nexport async function publishFileShare(client: DocumentToolsClient, share: FileShare) {\n const result = await client.POST(\n '/v1/document/{document_ext_id}/file-shares/{share_id}/publish',\n { params: { path: { document_ext_id: share.document_ext_id, share_id: share.external_id } } }\n )\n if (!result.data) throw new Error('Could not save the signed version to its workspace')\n return result.data\n}\n"]}
1
+ {"version":3,"sources":["../src/document-tools/environment.tsx","../src/document-tools/document-pdf.ts","../src/document-tools/markup-download.ts","../src/document-tools/signing.ts","../src/document-tools/file-shares.ts"],"names":["createContext","useDeploymentDomain","useRef","useCallback","useMemo","jsx","useContext","parseVersionRef","useQuery","arbiQueryKeys","client","unlockIdentityWithPassword","signMessage","useQueryClient","useMutation"],"mappings":";;;;;;;;;AAmEO,SAAS,kBAAkB,KAAA,EAAoC;AACpE,EAAA,MAAM,MAAA,GAAS,IAAI,eAAA,EAAgB;AACnC,EAAA,KAAA,MAAW,CAAC,GAAA,EAAK,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,KAAK,CAAA,EAAG;AAChD,IAAA,IAAI,KAAA,KAAU,IAAA,IAAQ,KAAA,KAAU,MAAA,EAAW;AAC3C,IAAA,KAAA,MAAW,IAAA,IAAQ,KAAA,CAAM,OAAA,CAAQ,KAAK,IAAI,KAAA,GAAQ,CAAC,KAAK,CAAA,EAAG,MAAA,CAAO,MAAA,CAAO,GAAA,EAAK,MAAA,CAAO,IAAI,CAAC,CAAA;AAAA,EAC5F;AACA,EAAA,OAAO,OAAO,QAAA,EAAS;AACzB;AAqDO,SAAS,YAAA,CAAa,MAAY,QAAA,EAAwB;AAC/D,EAAA,MAAM,GAAA,GAAM,GAAA,CAAI,eAAA,CAAgB,IAAI,CAAA;AACpC,EAAA,MAAM,CAAA,GAAI,QAAA,CAAS,aAAA,C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AAS;AAAA,IACd,QAAA,EAAUC,gCAAc,UAAA,EAAW;AAAA,IACnC,SAAS,YAAY;AACnB,MAAA,MAAM,MAAA,GAAS,MAAM,MAAA,EAAQ,GAAA,CAAI,iBAAiB,CAAA;AAClD,MAAA,IAAI,CAAC,MAAA,EAAQ,IAAA,EAAM,MAAM,IAAI,MAAM,6BAA6B,CAAA;AAChE,MAAA,OAAO,MAAA,CAAO,IAAA;AAAA,IAChB,CAAA;AAAA,IACA,OAAA,EAAS,CAAC,CAAC;AAAA,GACZ,CAAA;AACH;AAGO,SAAS,oBAAA,GAA4C;AAC1D,EAAA,MAAM,cAAcI,yBAAAA,EAAe;AACnC,EAAA,OAAOV,iBAAAA;AAAA,IACL,MAAM,YAAY,iBAAA,CAAkB,EAAE,UAAUM,+BAAA,CAAc,UAAA,IAAc,CAAA;AAAA,IAC5E,CAAC,WAAW;AAAA,GACd;AACF;AAMA,eAAsB,gBAAA,CAAiB,QAA6B,KAAA,EAAkB;AACpF,EAAA,MAAM,MAAA,GAAS,MAAM,MAAA,CAAO,IAAA;AAAA,IAC1B,+DAAA;AAAA,IACA,EAAE,MAAA,EAAQ,EAAE,IAAA,EAAM,EAAE,eAAA,EAAiB,KAAA,CAAM,eAAA,EAAiB,QAAA,EAAU,KAAA,CAAM,WAAA,EAAY,EAAE;AAAE,GAC9F;AACA,EAAA,IAAI,CAAC,MAAA,CAAO,IAAA,EAAM,MAAM,IAAI,MAAM,oDAAoD,CAAA;AACtF,EAAA,OAAO,MAAA,CAAO,IAAA;AAChB","file":"chunk-H2TP7JWR.cjs","sourcesContent":["/**\n * The host app's side of the document tools (markup, freeze, e-signing, versions): the one place\n * the tools reach the app. They never import a store, a router, a toast library or app API code;\n * the host passes what it has to `<DocumentToolsProvider>` and every optional field has a default.\n *\n * `client` is an openapi-fetch client for the ARBI API (`ArbiClient['fetch']` from\n * `@arbidocs/client`, or `arbi.getClient().fetch` from an `@arbidocs/sdk` `Arbi`), signed in with the\n * user's session; it carries the auth.\n */\n\nimport { createContext, useCallback, useContext, useMemo, useRef, type ReactNode } from 'react'\nimport type { ArbiClient, operations } from '@arbidocs/client'\nimport { useDeploymentDomain } from '../useArbi'\n\nexport type DocumentToolsClient = ArbiClient['fetch']\n\nexport type DocumentToolsNoticeKind = 'success' | 'error' | 'info' | 'warning'\n\nexport interface DocumentToolsNoticeOptions {\n /** A second line under the message. */\n description?: string\n /** One action button on the notice (\"Email it\"). */\n action?: { label: string; onClick: () => void }\n}\n\nexport type DocumentToolsNotify = (\n message: string,\n kind: DocumentToolsNoticeKind,\n options?: DocumentToolsNoticeOptions\n) => void\n\nexport interface DocumentToolsUser {\n /** The name marks are authored as and the signer's name is prefilled with. */\n name: string\n /** The sign-in email: signing re-derives the user's key from it and the password. */\n email?: string | null\n /** The user's id (usr-*): which fields of a signature request are theirs. */\n externalId?: string | null\n}\n\n/** What changed about a document, so the host can refresh its own lists and caches. */\nexport type DocumentChange =\n /** A version's markup got its first mark or lost its last one. */\n | 'markup'\n /** A signature was added: the document has a new current version. */\n | 'signed'\n /** A new document was made from it (a frozen copy). The ids are the NEW documents. */\n | 'copy'\n /** A new version was saved (the Word editor's Save version): the document's current version. */\n | 'version'\n\n/**\n * The `/v1/document/upload` query, typed from the API schema: `derived_from` is a list (a\n * production set is derived from every document in it), `shared` a boolean.\n */\nexport type DocumentUploadQuery = NonNullable<operations['upload_documents']['parameters']['query']>\n\nexport interface DocumentUploadRequest {\n file: File\n /** `/v1/document/upload` query: `derived_from`, `derived_role`, `shared`, `folder`. */\n query: DocumentUploadQuery\n}\n\n/**\n * The upload query as a URL query string, for a host that posts the upload itself (an XHR with\n * progress): a list repeats its key (`derived_from=a&derived_from=b`), empty values are left out.\n */\nexport function uploadQueryString(query: DocumentUploadQuery): string {\n const params = new URLSearchParams()\n for (const [key, value] of Object.entries(query)) {\n if (value === null || value === undefined) continue\n for (const item of Array.isArray(value) ? value : [value]) params.append(key, String(item))\n }\n return params.toString()\n}\n\nexport interface DocumentToolsEnvironment {\n client: DocumentToolsClient\n /**\n * The deployment domain the user's keys are derived for. Needed for signing. Default: the one\n * the host's `Arbi` computes (`arbi.getDeploymentDomain()`), if any.\n */\n deploymentDomain?: string\n /** The signed-in user; marks are authored as \"You\" without one, and signing is unavailable. */\n user?: DocumentToolsUser | null\n /** Surface a transient message. Default: none (errors still show inline where they can). */\n notify?: DocumentToolsNotify\n /** Open a document or a version reference (`doc-…@v2`): the copy just made, the signed copy. */\n openDocument?: (documentRef: string) => void\n /**\n * Documents changed on the server (see {@link DocumentChange}); refresh the host's lists. The\n * tools wait for it before opening the document, so a copy is listed when it opens.\n */\n onDocumentsChanged?: (documentIds: string[], change: DocumentChange) => void | Promise<void>\n /** Upload a derived copy. Default: `POST /v1/document/upload` through `client`. */\n uploadDocument?: (\n request: DocumentUploadRequest\n ) => Promise<{ doc_ext_ids?: string[] } | undefined>\n /** Save a file to the user's computer. Default: a temporary download link. */\n saveFile?: (blob: Blob, fileName: string) => void\n /** Email a document (offered once it is signed). Omitted: no \"Email it\". */\n emailDocument?: (documentRef: string) => void\n /**\n * The public page that checks a signature (the certificate) in this app. When given, \"View\n * certificate\" opens it in preference to the backend's `certificate_url` (which is on the\n * deployment domain, like the link embedded in the signed PDF). Without it: the backend's\n * `certificate_url`, else `/verify/{reference}` on this origin.\n */\n certificateUrl?: (reference: string) => string\n}\n\n/** The environment with every default filled in. */\nexport interface ResolvedDocumentToolsEnvironment extends DocumentToolsEnvironment {\n prepareFileShare: (documentId: string) => Promise<void>\n registerBeforeFileShare: (documentId: string, flush: () => Promise<void>) => () => void\n notify: DocumentToolsNotify\n saveFile: (blob: Blob, fileName: string) => void\n uploadDocument: (\n request: DocumentUploadRequest\n ) => Promise<{ doc_ext_ids?: string[] } | undefined>\n}\n\n/**\n * Save a blob through a temporary `<a download>`. The object URL is revoked a minute later, not at\n * once: revoking straight after `click()` can cancel the download (Safari, and large files\n * elsewhere) before the browser has read the blob.\n */\nexport function downloadBlob(blob: Blob, fileName: string): void {\n const url = URL.createObjectURL(blob)\n const a = document.createElement('a')\n a.href = url\n a.download = fileName\n document.body.appendChild(a)\n a.click()\n a.remove()\n setTimeout(() => URL.revokeObjectURL(url), 60_000)\n}\n\n/** The default upload: multipart `files` to `/v1/document/upload` through the API client. */\nexport function clientUpload(client: DocumentToolsClient) {\n return async ({ file, query }: DocumentUploadRequest) => {\n const formData = new FormData()\n formData.append('files', file)\n const { data, response } = await client.POST('/v1/document/upload', {\n params: { query },\n // The schema types the multipart body as `{ files: string[] }`; the FormData is sent as is.\n body: formData as unknown as { files: string[] },\n bodySerializer: () => formData,\n })\n if (!response.ok) throw new Error(`Upload failed with status ${response.status}`)\n return data\n }\n}\n\nexport function defaultCertificateUrl(reference: string): string {\n const origin = typeof location === 'undefined' ? '' : location.origin\n return `${origin}/verify/${encodeURIComponent(reference)}`\n}\n\n/**\n * Where \"View certificate\" goes for a signature: the host's `certificateUrl(reference)` when it\n * gives one, else the `certificate_url` the backend returned, else `/verify/{reference}` here.\n */\nexport function certificateLink(\n signature: { reference: string; certificate_url?: string | null },\n certificateUrl?: (reference: string) => string\n): string {\n if (certificateUrl) return certificateUrl(signature.reference)\n return signature.certificate_url || defaultCertificateUrl(signature.reference)\n}\n\nconst DocumentToolsContext = createContext<ResolvedDocumentToolsEnvironment | null>(null)\n\nexport interface DocumentToolsProviderProps extends DocumentToolsEnvironment {\n children: ReactNode\n}\n\nexport function DocumentToolsProvider({ children, ...env }: DocumentToolsProviderProps) {\n const arbiDeploymentDomain = useDeploymentDomain()\n const guards = useRef(new Map<string, () => Promise<void>>())\n const pendingFlushes = useRef(new Map<string, Promise<void>>())\n const registerBeforeFileShare = useCallback((id: string, flush: () => Promise<void>) => {\n guards.current.set(id, flush)\n return () => {\n if (guards.current.get(id) !== flush) return\n guards.current.delete(id)\n const pending = flush()\n pendingFlushes.current.set(id, pending)\n void pending.then(\n () => {\n if (pendingFlushes.current.get(id) === pending) pendingFlushes.current.delete(id)\n },\n () => {}\n )\n }\n }, [])\n const prepareFileShare = useCallback(async (id: string) => {\n const guard = guards.current.get(id)\n if (guard) {\n await guard()\n pendingFlushes.current.delete(id)\n } else await pendingFlushes.current.get(id)\n }, [])\n const {\n client,\n deploymentDomain,\n user,\n notify,\n openDocument,\n onDocumentsChanged,\n uploadDocument,\n saveFile,\n emailDocument,\n certificateUrl,\n } = env\n const value = useMemo<ResolvedDocumentToolsEnvironment>(\n () => ({\n client,\n prepareFileShare,\n registerBeforeFileShare,\n deploymentDomain: deploymentDomain ?? arbiDeploymentDomain,\n user,\n openDocument,\n onDocumentsChanged,\n emailDocument,\n notify: notify ?? (() => {}),\n saveFile: saveFile ?? downloadBlob,\n uploadDocument: uploadDocument ?? clientUpload(client),\n certificateUrl,\n }),\n [\n client,\n prepareFileShare,\n registerBeforeFileShare,\n deploymentDomain,\n arbiDeploymentDomain,\n user,\n notify,\n openDocument,\n onDocumentsChanged,\n uploadDocument,\n saveFile,\n emailDocument,\n certificateUrl,\n ]\n )\n return <DocumentToolsContext.Provider value={value}>{children}</DocumentToolsContext.Provider>\n}\n\n/** The host's environment, or `null` outside a `<DocumentToolsProvider>`. */\nexport function useOptionalDocumentTools(): ResolvedDocumentToolsEnvironment | null {\n return useContext(DocumentToolsContext)\n}\n\n/** The host's environment; throws outside a `<DocumentToolsProvider>`. */\nexport function useDocumentTools(): ResolvedDocumentToolsEnvironment {\n const env = useContext(DocumentToolsContext)\n if (!env) throw new Error('The document tools must be used within a <DocumentToolsProvider>')\n return env\n}\n","/**\n * A document's bytes, through the host's API client: the PDF the viewer and the tools draw on\n * (`/view`: the file itself for a PDF, its PDF rendering for a Word or text file) and the stored\n * file (`/download`). Either takes a document id or a version reference `doc-…@v{n}`.\n */\n\nimport { parseVersionRef } from '../artifacts/versions'\nimport type { DocumentToolsClient } from './environment'\n\nexport interface DocumentFetchOptions {\n /** The version to fetch. Default: the one `documentRef` names, else the current version. */\n version?: number | null\n workspaceExtId?: string\n signal?: AbortSignal\n}\n\n/** A document's bytes could not be fetched; `status` is the HTTP status. */\nexport class DocumentFetchError extends Error {\n readonly status: number\n constructor(message: string, status: number) {\n super(message)\n this.name = 'DocumentFetchError'\n this.status = status\n }\n}\n\nasync function fetchDocumentBytes(\n client: DocumentToolsClient,\n endpoint: '/v1/document/{document_ext_id}/view' | '/v1/document/{document_ext_id}/download',\n documentRef: string,\n options: DocumentFetchOptions,\n headers: Record<string, string>,\n what: string\n): Promise<{ blob: Blob; response: Response }> {\n const ref = parseVersionRef(documentRef)\n const version = options.version ?? ref.version\n const { data, response } = await client.GET(endpoint, {\n params: {\n path: { document_ext_id: ref.docId },\n query: {\n ...(version ? { version } : {}),\n ...(options.workspaceExtId ? { workspace_ext_id: options.workspaceExtId } : {}),\n },\n },\n headers,\n parseAs: 'blob',\n signal: options.signal,\n })\n if (!response.ok || !(data instanceof Blob)) {\n throw new DocumentFetchError(\n `${what} could not be loaded (${response.status})`,\n response.status\n )\n }\n return { blob: data, response }\n}\n\n/**\n * The file name a `Content-Disposition` header gives, or `undefined`. Prefers the RFC 5987\n * `filename*=UTF-8''…` form (percent-encoded, any script) over the plain `filename=`.\n */\nexport function contentDispositionFileName(header: string | null | undefined): string | undefined {\n if (!header) return undefined\n const extended = /filename\\*\\s*=\\s*(?:[\\w-]+)?'[^']*'([^;]+)/i.exec(header)\n if (extended) {\n try {\n return decodeURIComponent(extended[1].trim().replace(/^\"|\"$/g, '')) || undefined\n } catch {\n // A malformed escape: fall back to the plain parameter.\n }\n }\n const plain = /filename\\s*=\\s*(\"((?:[^\"\\\\]|\\\\.)*)\"|[^;]+)/i.exec(header)\n if (!plain) return undefined\n const name = plain[2] !== undefined ? plain[2].replace(/\\\\(.)/g, '$1') : plain[1].trim()\n return name || undefined\n}\n\n/**\n * The PDF of a document version: `GET /v1/document/{id}/view?version=` with\n * `Accept: application/pdf`. Throws a {@link DocumentFetchError} when there is none (yet).\n */\nexport async function fetchDocumentPdf(\n client: DocumentToolsClient,\n documentRef: string,\n options: DocumentFetchOptions = {}\n): Promise<Blob> {\n const { blob } = await fetchDocumentBytes(\n client,\n '/v1/document/{document_ext_id}/view',\n documentRef,\n options,\n { Accept: 'application/pdf' },\n 'The PDF'\n )\n return blob\n}\n\n/**\n * The stored file of a document version, as uploaded: `GET /v1/document/{id}/download`. When the\n * server names the file (`Content-Disposition`), the result is a `File` carrying that name.\n */\nexport async function fetchDocumentFile(\n client: DocumentToolsClient,\n documentRef: string,\n options: DocumentFetchOptions = {}\n): Promise<Blob | File> {\n const { blob, response } = await fetchDocumentBytes(\n client,\n '/v1/document/{document_ext_id}/download',\n documentRef,\n options,\n {},\n 'The file'\n )\n const name = contentDispositionFileName(response.headers.get('Content-Disposition'))\n return name ? new File([blob], name, { type: blob.type }) : blob\n}\n","/**\n * \"Download with markup\": a document version's markup PDF, the PDF with its annotations as native\n * PDF annotations (comments, highlights, stamps, unapplied redactions), which Acrobat and Preview\n * show. The plain Download serves the original. Kept apart from the annotation layer code so a\n * documents list can offer it without loading the annotation tools.\n *\n * A SIGNED version is locked: nothing but a further signature changes it. Its markup stays in the\n * separate markup layer (a title beside the signature, say) and is never written into its PDF, so\n * it has no \"Download with markup\"; the plain Download is the signed file as it is.\n */\n\nimport type { DocumentToolsClient } from './environment'\n\ninterface DocumentVersions {\n current_version?: number | null\n versions?: Array<{ n: number; markup_count?: number | null; reason?: string | null }> | null\n}\n\n/** Why \"Download with markup\" is off for a signed version. */\nexport const SIGNED_LOCKED_REASON =\n \"Signed documents can't be changed — download the signed file instead\"\n\n/** Whether a version (default: the current one) is a signed copy, per its version entry. */\nexport function isSignedVersion(doc: DocumentVersions, version?: number): boolean {\n const n = version ?? doc.current_version ?? 1\n return (doc.versions ?? []).some((v) => v.n === n && v.reason === 'signed')\n}\n\nexport class MarkupDownloadError extends Error {\n constructor(\n message: string,\n readonly status?: number\n ) {\n super(message)\n this.name = 'MarkupDownloadError'\n }\n}\n\n/** Whether a document's current version has markup (per its version entries). */\nexport function currentHasMarkup(doc: DocumentVersions): boolean {\n const n = doc.current_version ?? 1\n return (doc.versions ?? []).some((v) => v.n === n && (v.markup_count ?? 0) > 0)\n}\n\n/** Fetch a version's markup PDF (default: the current version's). */\nexport async function fetchMarkupPdf(\n client: DocumentToolsClient,\n documentId: string,\n version?: number,\n workspaceExtId?: string\n): Promise<{ blob: Blob; fileName: string }> {\n const { data, response } = await client.GET('/v1/document/{document_ext_id}/markup/pdf', {\n params: {\n path: { document_ext_id: documentId },\n query: {\n ...(version ? { version } : {}),\n ...(workspaceExtId ? { workspace_ext_id: workspaceExtId } : {}),\n },\n },\n parseAs: 'blob',\n })\n if (!response.ok || !data) {\n throw new MarkupDownloadError(\n response.status === 404\n ? 'This document has no markup yet'\n : // The server refuses a signed version: its PDF takes no more changes.\n response.status === 409\n ? SIGNED_LOCKED_REASON\n : 'The markup could not be downloaded',\n response.status\n )\n }\n const disposition = response.headers.get('content-disposition') ?? ''\n const utf8 = /filename\\*=UTF-8''([^;]+)/i.exec(disposition)?.[1]\n const plain = /filename=\"([^\"]+)\"/i.exec(disposition)?.[1]\n const fileName = utf8 ? decodeURIComponent(utf8) : (plain ?? 'markup.pdf')\n return { blob: data as Blob, fileName }\n}\n","/**\n * Electronic signing. The backend (`src/core/esign.py` in ARBI) defines what a signature binds;\n * the helpers mirror the two pieces the browser must reproduce exactly: the statement of intent\n * shown to the signer, and the SHA-256 of the PDF the viewer displayed.\n */\n\nimport { signMessage, unlockIdentityWithPassword, type components } from '@arbidocs/client'\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'\nimport { parseVersionRef } from '../artifacts/versions'\nimport { useDocumentTools, type DocumentToolsClient } from './environment'\nimport { arbiQueryKeys } from '../query-keys'\n\n/**\n * Who signs: the name only. A role, a firm or a place go on the page as ordinary annotation text,\n * which is not part of the signature.\n */\nexport type SignerDetails = components['schemas']['SignerDetails']\n\n/** Same sentence as `esign.intent_text`; the dialog refuses to sign if the server's differs. */\nexport function intentText(signer: SignerDetails): string {\n return `I, ${signer.name.trim()}, sign this document electronically. I intend this electronic signature to have the same effect as my handwritten signature.`\n}\n\nexport async function sha256Hex(blob: Blob): Promise<string> {\n const digest = await crypto.subtle.digest('SHA-256', new Uint8Array(await blob.arrayBuffer()))\n return Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, '0')).join('')\n}\n\n/** A signature box drawn on the annotation overlay, as the signing API's placement. */\nexport function toAppearance(box: {\n page: number\n rect: { x: number; y: number; w: number; h: number }\n}): { page: number; x: number; y: number; width: number; height: number } {\n // The layer counts pages from 1, the signing API from 0. Both use fractions of the page as\n // displayed, origin top-left.\n return { page: box.page - 1, x: box.rect.x, y: box.rect.y, width: box.rect.w, height: box.rect.h }\n}\n\n/**\n * The smallest box the backend can draw a legible signature in: the signer's name and the\n * details line shrink to fit, so a box under these fractions of the page is shrunk to near\n * unreadable size. The backend's own default box is 0.40 x 0.10.\n */\nconst MIN_SIGNATURE_BOX = { width: 0.3, height: 0.07 }\n\nexport function isLegibleSignatureBox(rect: { w: number; h: number }): boolean {\n return rect.w >= MIN_SIGNATURE_BOX.width && rect.h >= MIN_SIGNATURE_BOX.height\n}\n\n// ── Signing through the API ─────────────────────────────────────────────────────────────────\n\nexport type SignatureAppearance = components['schemas']['SignatureAppearance']\nexport type SignatureStatusResponse = components['schemas']['SignatureStatusResponse']\nexport type SignatureRecord = components['schemas']['SignatureRecord']\nexport type SignDocumentResponse = components['schemas']['SignDocumentResponse']\n\nconst SIGNATURES_PATH = '/v1/document/{document_ext_id}/signatures'\n/**\n * The same key openapi-react-query gives this request (`['get', path, init]`), so a host that\n * reads or persists the API cache by path treats it like its own queries.\n */\n\nfunction errorDetail(error: unknown, fallback: string): string {\n const detail = (error as { detail?: unknown } | undefined)?.detail\n return typeof detail === 'string' ? detail : fallback\n}\n\n/** Whether a document version is a signed copy, and its signatures. */\nexport async function fetchDocumentSignatures(\n client: DocumentToolsClient,\n documentRef: string\n): Promise<SignatureStatusResponse> {\n const { docId, version } = parseVersionRef(documentRef)\n const { data, error } = await client.GET(SIGNATURES_PATH, {\n params: { path: { document_ext_id: docId }, ...(version ? { query: { version } } : {}) },\n })\n if (!data) throw new Error(errorDetail(error, 'The signatures could not be read'))\n return data\n}\n\n/**\n * Is a document version a signed copy? `documentId` is a document id (its current version) or a\n * version reference `doc-…@v{n}`. Needs a React Query `QueryClientProvider`.\n */\nexport function useDocumentSignatures(documentId: string | null | undefined, enabled = true) {\n const { client } = useDocumentTools()\n const { docId, version } = parseVersionRef(documentId)\n return useQuery({\n queryKey: arbiQueryKeys.documentSignatures(docId ?? '', version),\n queryFn: () => fetchDocumentSignatures(client, documentId!),\n enabled: enabled && !!docId,\n staleTime: 60_000,\n })\n}\n\n/**\n * Why the server would not sign: the PDF of a Word or text document is still being rendered\n * (`preparing`, worth another try in a moment), or the version on screen is no longer the current\n * one (`stale`: only the current version can be signed, so the signer reopens it).\n */\nexport type SigningErrorReason = 'preparing' | 'stale' | 'failed'\n\nexport class SigningError extends Error {\n readonly reason: SigningErrorReason\n constructor(message: string, reason: SigningErrorReason) {\n super(message)\n this.name = 'SigningError'\n this.reason = reason\n }\n}\n\n/** The 409s the backend's signing router raises, told apart by their wording. */\nfunction signingErrorReason(detail: string): SigningErrorReason {\n if (/still being prepared/i.test(detail)) return 'preparing'\n if (/no longer the current version/i.test(detail)) return 'stale'\n return 'failed'\n}\n\nfunction signingError(error: unknown, fallback: string): SigningError {\n const detail = errorDetail(error, fallback)\n return new SigningError(detail, signingErrorReason(detail))\n}\n\n/** How often, and how long apart, a prepare is retried while the PDF is still being rendered. */\nexport const PREPARE_RETRIES = 3\nconst PREPARE_RETRY_DELAY_MS = 1500\n\nconst wait = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))\n\nexport interface SignDocumentVars {\n documentId: string\n /**\n * The PDF bytes the viewer is showing (`GET /view?version=`, never the original's download): the\n * signer signs exactly these.\n */\n pdfBlob: Blob\n /**\n * The version `pdfBlob` is of. The server signs only the current version and refuses\n * (`SigningError` `stale`) when this one has been superseded. Omitted = the current version.\n */\n version?: number\n email: string\n password: string\n signer: SignerDetails\n /** Where the signature goes; omitted = the backend default (bottom of the last page). */\n appearance?: SignatureAppearance\n /** Draw the signing date under the signature. Default off: only the signature is drawn. */\n includeDate?: boolean\n}\n\n/**\n * Sign a document: the server prepares the statement, the browser checks that it covers the PDF\n * on screen under the wording the signer read, re-derives the user's Ed25519 key from their\n * password and signs it, and the server seals the signed copy as a new version.\n *\n * What is drawn on the page is only the signature (the signer's name as the signature mark) and,\n * with `includeDate`, the date; anyone can click it to open its certificate. A role, a firm or a\n * place go on the page as ordinary annotation text, which is not part of the signature.\n */\nexport async function signDocument(\n client: DocumentToolsClient,\n deploymentDomain: string,\n {\n documentId,\n pdfBlob,\n email,\n password,\n signer,\n appearance,\n includeDate = false,\n version,\n }: SignDocumentVars\n): Promise<SignDocumentResponse> {\n const path = { document_ext_id: documentId }\n // One body for both calls: the server refuses a /sign whose include_date (or placement) differs\n // from what was prepared, since what the signature shows is part of what is signed.\n const body = {\n signer: { name: signer.name },\n ...(appearance ? { appearance } : {}),\n include_date: includeDate,\n ...(version ? { version } : {}),\n }\n\n // A Word or text document's PDF is rendered after upload: while it is, prepare says so, and a\n // short wait usually sees it ready.\n const prepare = () =>\n client.POST('/v1/document/{document_ext_id}/sign/prepare', { params: { path }, body })\n let prepared = await prepare()\n for (let attempt = 0; !prepared.data && attempt < PREPARE_RETRIES; attempt++) {\n if (signingError(prepared.error, '').reason !== 'preparing') break\n await wait(PREPARE_RETRY_DELAY_MS)\n prepared = await prepare()\n }\n if (!prepared.data) throw signingError(prepared.error, 'Could not prepare signing')\n const { statement, intent, source_sha256, timestamp } = prepared.data\n // Sign only what was on screen, under the wording the signer read.\n if ((await sha256Hex(pdfBlob)) !== source_sha256) {\n throw new Error('The document changed since it was opened. Reopen it and sign again.')\n }\n if (intent !== intentText(signer)) throw new Error('Signing statement mismatch; not signed.')\n\n // The re-typed password must open the session's identity, which is the key the server verifies.\n const identity = await unlockIdentityWithPassword(email, password, deploymentDomain)\n const signed = await client.POST('/v1/document/{document_ext_id}/sign', {\n params: { path },\n body: { ...body, timestamp, signature: signMessage(statement, identity) },\n })\n if (!signed.data) throw signingError(signed.error, 'Signing failed')\n return signed.data\n}\n\n/** The signing mutation. On success the host hears the document changed (`'signed'`). */\nexport function useSignDocument() {\n const env = useDocumentTools()\n const queryClient = useQueryClient()\n return useMutation({\n mutationFn: (vars: SignDocumentVars) => {\n if (!env.deploymentDomain) throw new Error('Signing is not set up: no deployment domain')\n return signDocument(env.client, env.deploymentDomain, vars)\n },\n onSuccess: async (result) => {\n // The signed copy is the document's new current version: the host refreshes its row,\n // versions and rendered PDF, and the signature badge reads again.\n await env.onDocumentsChanged?.([result.doc_ext_id], 'signed')\n await queryClient.invalidateQueries({ queryKey: arbiQueryKeys.documentSignatures() })\n },\n })\n}\n","import { useCallback } from 'react'\nimport { useQuery, useQueryClient } from '@tanstack/react-query'\nimport { arbiQueryKeys } from '../query-keys'\n/** Share one immutable file version with named recipients, independently of workspace membership. */\nimport { signMessage, unlockIdentityWithPassword, type components } from '@arbidocs/client'\nimport type { DocumentToolsClient } from './environment'\nimport { intentText, sha256Hex } from './signing'\nimport type {\n SignatureRequest,\n SignRequestVars,\n SignRequestSignResponse,\n} from './signature-requests'\n\nexport type FileShare = components['schemas']['FileShareResponse']\nexport type CreateFileShare = components['schemas']['CreateFileShare']\n\nfunction failure(error: unknown): Error {\n const detail = (error as { detail?: unknown } | undefined)?.detail\n return new Error(typeof detail === 'string' ? detail : 'The shared file request failed')\n}\n\nexport async function createFileShare(\n client: DocumentToolsClient,\n documentId: string,\n body: CreateFileShare\n) {\n const result = await client.POST('/v1/document/{document_ext_id}/file-shares', {\n params: { path: { document_ext_id: documentId } },\n body,\n })\n if (!result.data) throw failure(result.error)\n return result.data\n}\n\nexport async function getFileShare(client: DocumentToolsClient, id: string): Promise<FileShare> {\n const result = await client.GET('/v1/file-shares/{share_id}', {\n params: { path: { share_id: id } },\n })\n if (!result.data) throw failure(result.error)\n return result.data\n}\n\nexport async function fileShareBytes(\n client: DocumentToolsClient,\n id: string,\n kind: 'view' | 'original' | 'signed'\n) {\n const result = await client.GET('/v1/file-shares/{share_id}/file', {\n params: { path: { share_id: id }, query: { kind } },\n parseAs: 'blob',\n })\n if (!result.data) throw failure(result.error)\n return result.data\n}\n\n/** Adapt only the guided viewer's presentation data; sharing uses its own authorization endpoints. */\nexport function fileShareSigningRequest(share: FileShare): SignatureRequest {\n return {\n external_id: share.external_id,\n doc_ext_id: share.document_ext_id,\n version: share.version,\n source_sha256: share.source_sha256,\n fields: share.fields,\n message: share.message,\n status:\n share.status === 'signing' ? 'sent' : share.status === 'completed' ? 'completed' : 'voided',\n signers: share.recipients\n .filter((r) => r.permission === 'sign')\n .map((r) => ({\n external_id: r.email,\n email: r.email,\n name: r.email,\n status: r.status === 'signed' ? 'signed' : 'pending',\n progress: r.status === 'signed' ? 'signed' : 'registered',\n fields: share.fields.filter((f) => f.signer === r.email).length,\n })),\n created_at: new Date(0).toISOString(),\n stale: false,\n }\n}\n\nexport async function signFileShare(\n client: DocumentToolsClient,\n domain: string,\n vars: SignRequestVars\n): Promise<SignRequestSignResponse> {\n const path = { share_id: vars.request.external_id }\n const body = { adopted: vars.adopted, fields: vars.fields }\n const prepared = await client.POST('/v1/file-shares/{share_id}/sign/prepare', {\n params: { path },\n body,\n })\n if (!prepared.data) throw failure(prepared.error)\n const { statement, timestamp, source_sha256, intent } = prepared.data\n if (\n source_sha256 !== vars.request.source_sha256 ||\n (await sha256Hex(vars.pdfBlob)) !== source_sha256\n )\n throw new Error('The shared file changed. Ask the sender for a new request.')\n if (intent !== intentText({ name: vars.adopted.name }))\n throw new Error('Signing statement mismatch')\n const identity = await unlockIdentityWithPassword(vars.email, vars.password, domain)\n const result = await client.POST('/v1/file-shares/{share_id}/sign', {\n params: { path },\n body: { ...body, timestamp, signature: signMessage(statement, identity) },\n })\n if (!result.data) throw failure(result.error)\n return {\n request: fileShareSigningRequest(result.data),\n completed: result.data.status === 'completed',\n }\n}\n\nexport function useFileShare(client: DocumentToolsClient, shareId: string, signing: boolean) {\n return useQuery({\n queryKey: arbiQueryKeys.fileShare(shareId),\n queryFn: () => getFileShare(client, shareId),\n refetchInterval: signing ? false : 5000,\n })\n}\n\nexport function useFileSharePdf(client: DocumentToolsClient, shareId: string, share?: FileShare) {\n return useQuery({\n queryKey: arbiQueryKeys.fileSharePdf(shareId, share?.status),\n queryFn: () =>\n fileShareBytes(client, shareId, share?.status === 'completed' ? 'signed' : 'view'),\n enabled: !!share?.can_preview,\n staleTime: Infinity,\n })\n}\n\n/** The shares I created or was invited to (revoked and expired ones are not listed). Listing does\n * not open a share, so it never starts a recipient's access window. Null client: not loaded. */\nexport function useFileShares(client: DocumentToolsClient | null) {\n return useQuery({\n queryKey: arbiQueryKeys.fileShares(),\n queryFn: async () => {\n const result = await client?.GET('/v1/file-shares')\n if (!result?.data) throw new Error('Could not load shared files')\n return result.data\n },\n enabled: !!client,\n })\n}\n\n/** Read the share list again (after a change made to a share: signed, declined, saved, revoked). */\nexport function useRefreshFileShares(): () => Promise<void> {\n const queryClient = useQueryClient()\n return useCallback(\n () => queryClient.invalidateQueries({ queryKey: arbiQueryKeys.fileShares() }),\n [queryClient]\n )\n}\n\n/**\n * Save a completed share's signed PDF as its document's next version, in the share's workspace\n * (its key must be on the session: open that workspace first).\n */\nexport async function publishFileShare(client: DocumentToolsClient, share: FileShare) {\n const result = await client.POST(\n '/v1/document/{document_ext_id}/file-shares/{share_id}/publish',\n { params: { path: { document_ext_id: share.document_ext_id, share_id: share.external_id } } }\n )\n if (!result.data) throw new Error('Could not save the signed version to its workspace')\n return result.data\n}\n"]}
@@ -2,8 +2,8 @@
2
2
 
3
3
  var chunkEEIYXVM4_cjs = require('./chunk-EEIYXVM4.cjs');
4
4
  var chunkEM6DP62E_cjs = require('./chunk-EM6DP62E.cjs');
5
- var chunkWYZJLZ67_cjs = require('./chunk-WYZJLZ67.cjs');
6
5
  var chunkKC474WVG_cjs = require('./chunk-KC474WVG.cjs');
6
+ var chunkWYZJLZ67_cjs = require('./chunk-WYZJLZ67.cjs');
7
7
  var chunkHJDR5HEO_cjs = require('./chunk-HJDR5HEO.cjs');
8
8
  var chunk5NOZDH3F_cjs = require('./chunk-5NOZDH3F.cjs');
9
9
  var chunkS6A6FSG7_cjs = require('./chunk-S6A6FSG7.cjs');
@@ -5334,5 +5334,5 @@ exports.toggleVariants = toggleVariants;
5334
5334
  exports.useAudioRecorder = useAudioRecorder;
5335
5335
  exports.useDictateContext = useDictateContext;
5336
5336
  exports.usesOriginalBytesForViewer = usesOriginalBytesForViewer;
5337
- //# sourceMappingURL=chunk-WJIRX5MS.cjs.map
5338
- //# sourceMappingURL=chunk-WJIRX5MS.cjs.map
5337
+ //# sourceMappingURL=chunk-XQLJSNAL.cjs.map
5338
+ //# sourceMappingURL=chunk-XQLJSNAL.cjs.map