@arbidocs/blocks 0.4.102 → 0.4.104

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 (84) hide show
  1. package/dist/agents/index.cjs +207 -207
  2. package/dist/agents/index.js +2 -2
  3. package/dist/{chunk-AOFATOT3.cjs → chunk-2A4MDHJR.cjs} +7 -5
  4. package/dist/chunk-2A4MDHJR.cjs.map +1 -0
  5. package/dist/{chunk-G5JH2YMQ.js → chunk-4GFB5U3K.js} +3 -3
  6. package/dist/{chunk-G5JH2YMQ.js.map → chunk-4GFB5U3K.js.map} +1 -1
  7. package/dist/chunk-5FYU7ZIU.cjs +139 -0
  8. package/dist/chunk-5FYU7ZIU.cjs.map +1 -0
  9. package/dist/{chunk-Y5XW57U4.cjs → chunk-7LLLQUM7.cjs} +5 -5
  10. package/dist/{chunk-Y5XW57U4.cjs.map → chunk-7LLLQUM7.cjs.map} +1 -1
  11. package/dist/{chunk-D3QPYKZG.js → chunk-EPHGD4YV.js} +7 -6
  12. package/dist/chunk-EPHGD4YV.js.map +1 -0
  13. package/dist/chunk-HFZ45FD3.js +133 -0
  14. package/dist/chunk-HFZ45FD3.js.map +1 -0
  15. package/dist/{chunk-5NQIBJPP.js → chunk-NJX774HB.js} +3 -3
  16. package/dist/{chunk-5NQIBJPP.js.map → chunk-NJX774HB.js.map} +1 -1
  17. package/dist/{chunk-DDYXFALG.cjs → chunk-NW3LFDZL.cjs} +3 -3
  18. package/dist/{chunk-DDYXFALG.cjs.map → chunk-NW3LFDZL.cjs.map} +1 -1
  19. package/dist/{chunk-YGREW5TZ.js → chunk-PIT2YZCK.js} +3 -3
  20. package/dist/{chunk-YGREW5TZ.js.map → chunk-PIT2YZCK.js.map} +1 -1
  21. package/dist/{chunk-Z3G65XHZ.js → chunk-S55VDTX3.js} +3 -3
  22. package/dist/{chunk-Z3G65XHZ.js.map → chunk-S55VDTX3.js.map} +1 -1
  23. package/dist/{chunk-LENXDIMY.cjs → chunk-SKSE4OT6.cjs} +22 -22
  24. package/dist/{chunk-LENXDIMY.cjs.map → chunk-SKSE4OT6.cjs.map} +1 -1
  25. package/dist/{chunk-ZT2EBBSC.cjs → chunk-TP3FAP5J.cjs} +5 -5
  26. package/dist/{chunk-ZT2EBBSC.cjs.map → chunk-TP3FAP5J.cjs.map} +1 -1
  27. package/dist/{chunk-MYALCKDR.js → chunk-W2RTZOK3.js} +1533 -263
  28. package/dist/chunk-W2RTZOK3.js.map +1 -0
  29. package/dist/{chunk-FAGQTB3D.cjs → chunk-ZWWN4CUL.cjs} +1690 -408
  30. package/dist/chunk-ZWWN4CUL.cjs.map +1 -0
  31. package/dist/connect/docx.cjs +8 -7
  32. package/dist/connect/docx.cjs.map +1 -1
  33. package/dist/connect/docx.js +6 -5
  34. package/dist/connect/docx.js.map +1 -1
  35. package/dist/connect/index.cjs +12 -11
  36. package/dist/connect/index.cjs.map +1 -1
  37. package/dist/connect/index.js +5 -4
  38. package/dist/connect/index.js.map +1 -1
  39. package/dist/docx/LinkHoverCard.d.ts +24 -0
  40. package/dist/docx/NativeDocxEditor.d.ts +6 -0
  41. package/dist/docx/RibbonMenu.d.ts +4 -1
  42. package/dist/docx/RibbonOverflow.d.ts +27 -0
  43. package/dist/docx/WordReferences.d.ts +3 -2
  44. package/dist/docx/beforeSave.d.ts +9 -0
  45. package/dist/docx/definitions/fragment.d.ts +19 -1
  46. package/dist/docx/definitions/port.d.ts +43 -11
  47. package/dist/docx/index.cjs +85 -36
  48. package/dist/docx/index.cjs.map +1 -1
  49. package/dist/docx/index.d.ts +6 -0
  50. package/dist/docx/index.js +5 -4
  51. package/dist/docx/index.js.map +1 -1
  52. package/dist/docx/noteStyles.d.ts +46 -0
  53. package/dist/docx/overflowPlan.d.ts +15 -0
  54. package/dist/docx/references/CrossReferences.d.ts +97 -0
  55. package/dist/docx/references/EditorMenus.d.ts +10 -0
  56. package/dist/docx/references/commands.d.ts +119 -0
  57. package/dist/docx/references/numbering.d.ts +49 -0
  58. package/dist/docx/references/passages.d.ts +32 -0
  59. package/dist/docx/references/port.d.ts +20 -0
  60. package/dist/facts/index.cjs +22 -129
  61. package/dist/facts/index.cjs.map +1 -1
  62. package/dist/facts/index.js +3 -125
  63. package/dist/facts/index.js.map +1 -1
  64. package/dist/files/index.cjs +1 -1
  65. package/dist/files/index.js +1 -1
  66. package/dist/home/index.cjs +1 -1
  67. package/dist/home/index.js +1 -1
  68. package/dist/index.cjs +314 -314
  69. package/dist/index.js +8 -8
  70. package/dist/shell/index.cjs +1 -1
  71. package/dist/shell/index.js +1 -1
  72. package/dist/studio/index.cjs +1 -1
  73. package/dist/studio/index.js +1 -1
  74. package/dist/tags/ooxml.d.ts +4 -0
  75. package/dist/workflow-canvas/index.cjs +9 -9
  76. package/dist/workflow-canvas/index.js +2 -2
  77. package/node_modules/@arbidocs/coedit/package.json +1 -1
  78. package/package.json +4 -4
  79. package/src/docx/README.md +32 -0
  80. package/src/docx/styles.css +73 -5
  81. package/dist/chunk-AOFATOT3.cjs.map +0 -1
  82. package/dist/chunk-D3QPYKZG.js.map +0 -1
  83. package/dist/chunk-FAGQTB3D.cjs.map +0 -1
  84. package/dist/chunk-MYALCKDR.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- export { AgentAvatarField, AgentBar, AgentBarIconButton, AgentBarMenu, AgentBarNotes, AgentBarProbeAnswer, AgentBarQueuedNote, AgentBarStatus, AgentCard, AgentCreateView, AgentCreatedView, AgentCreator, AgentEditView, AgentGallery, AgentMainView, AgentSelect, AgentTypeSelector, CapabilityGrid, CapabilityTile, ConfigField, ConfigForm, ConsentActions, ConsentBulletList, ConsentCard, ConsentFootnote, ConsentHeader, ConsentMessage, ConsentNotice, ConsentPage, ConsentPermissionList, ConsentSection, ConsentStrong, ConsentText, ConversationListView, ConversationTurnSpeaker, CopyableUrl, DEFAULT_AGENT_AVATAR_FIELD_LABELS, DEFAULT_AGENT_BAR_LABELS, DEFAULT_AGENT_CARD_LABELS, DEFAULT_AGENT_CREATOR_LABELS, DEFAULT_AGENT_GALLERY_LABELS, DEFAULT_AGENT_SELECT_LABELS, DEFAULT_AGENT_STEPS_LABELS, DEFAULT_AGENT_TYPE_SELECTOR_LABELS, DEFAULT_AUTHORIZE_AGENT_LABELS, DEFAULT_CONFIG_FIELD_LABELS, DEFAULT_CONFIG_FORM_LABELS, DEFAULT_CONSENT_ACTIONS_LABELS, DEFAULT_COPYABLE_URL_LABELS, DEFAULT_NEW_THREAD_DIALOG_LABELS, DEFAULT_PILL_SELECT_LABELS, DEFAULT_RECURRENCE, DEFAULT_RECURRENCE_BUILDER_LABELS, DEFAULT_SKILL_CARD_LABELS, DEFAULT_SKILL_EDIT_FORM_LABELS, DEFAULT_SKILL_GENERATE_FORM_LABELS, DEFAULT_SKILL_GLOBAL_BADGE_LABELS, DEFAULT_SKILL_ROW_LABELS, DEFAULT_SKILL_VIEW_TOGGLE_LABELS, DEFAULT_SUBAGENT_ROSTER_LABELS, DEFAULT_TASKS_CHROME_LABELS, DEFAULT_TASK_COMPOSER_LABELS, DEFAULT_TASK_LIST_LABELS, DEFAULT_TASK_OUTPUTS_CELL_LABELS, DEFAULT_TASK_PLAN_LABELS, DEFAULT_TASK_RUNS_DIALOG_LABELS, DEFAULT_TASK_STATUS_PILL_LABELS, DEFAULT_TASK_THREAD_CHIP_LABELS, DEFAULT_TASK_TRIGGER_CHIP_LABELS, DEFAULT_TUPLE_ARRAY_FIELD_LABELS, DEFAULT_UPLOAD_TASK_ITEM_LABELS, DEFAULT_UPLOAD_TASK_LIST_LABELS, DEFAULT_WORKFLOWS_CHROME_LABELS, DEFAULT_WORKFLOW_CONFIG_DIALOG_LABELS, DEFAULT_WORKFLOW_LIST_LABELS, DEFAULT_WORKFLOW_THREAD_STRIP_LABELS, DERIVED_NAME_WORDS, EMPTY_NEW_THREAD, GoalCriteria, MAX_TASK_DEPTH, NewThreadDialog, PersonPill, PillSelect, RecurrenceBuilder, STATUS_LABELS, STATUS_ORDER, STATUS_TONE, SkillActionButton, SkillCard, SkillDetail, SkillDetailSection, SkillEditForm, SkillFilterChips, SkillGenerateForm, SkillGlobalBadge, SkillRow, SkillTile, SkillTypeBadge, SkillViewToggle, StepDetail, StepNarration, StepOutcome, StepParams, StepRow, StepSummary, StepTrace, StepTraceSummary, SubAgentLane, SubStepGroup, SubagentRoster, TASK_COLUMN_ORDER, TRIGGER_LABELS, TaskActivityDialog, TaskComposer, TaskFlow, TaskInbox, TaskMoveDialog, TaskOutputsCell, TaskPlan, TaskRunsDialog, TaskStartDialog, TaskStatusPill, TaskTable, TaskThreadChip, TaskTriggerChip, TasksToolbar, ThreadActivity, ThreadNotifyDialog, TupleArrayField, UploadTaskItem, UploadTaskList, WEEKDAYS, WORKFLOW_COLUMN_ORDER, WorkflowConfigDialog, WorkflowDocumentsField, WorkflowLauncher, WorkflowThreadStartedBy, WorkflowThreadStrip, WorkflowsTable, WorkflowsToolbar, agentConfigSectionToValues, agentCreatorToConfigSection, asTaskStatus, authModeFor, buildRRule, buildTaskRows, buildWorkflowScopeSource, compactThreadActivity, composePersona, composerToTaskQuery, composerToWorkRequest, composerToWorkflowRequest, composerToWorkflowUpdate, createTaskColumns, createWorkflowColumns, createsWork, defaultScopeRenderer, defaultTaskComposerValues, deriveAgentName, deriveWorkflowName, descendantIds, describeRRule, filterConversationRows, firstWords, formatElapsed, goalProgress, groupThreadActivity, hasTaskFields, hasTrigger, humanizeSection, indexTasks, inferType, inputDocumentIds, isAgenticWorkflow, isOutOfBounds, isPlainTodo, isSkillRow, isValidAgentName, isoToLocalInput, linkedRunsFromActivity, localInputToIso, matchWorkflowScope, moveTargets, newThreadToRequest, nextCriterionId, ownerExtId, parseRRule, prettifyKey, resolveScopeInputs, skillSlug, stripPersonaPreamble, summarizeAgent, summarizeCapabilities, taskComposerToCreateRequest, taskComposerToUpdateRequest, taskNeedsAccess, taskToComposerValues, useWorkflowPreview, workflowFromSkillMarkdown, workflowStatus, workflowTaskFields, workflowToComposerValues, workflowToSkillMarkdown, workflowTriggerType, workflowWhen } from '../chunk-5NQIBJPP.js';
2
+ export { AgentAvatarField, AgentBar, AgentBarIconButton, AgentBarMenu, AgentBarNotes, AgentBarProbeAnswer, AgentBarQueuedNote, AgentBarStatus, AgentCard, AgentCreateView, AgentCreatedView, AgentCreator, AgentEditView, AgentGallery, AgentMainView, AgentSelect, AgentTypeSelector, CapabilityGrid, CapabilityTile, ConfigField, ConfigForm, ConsentActions, ConsentBulletList, ConsentCard, ConsentFootnote, ConsentHeader, ConsentMessage, ConsentNotice, ConsentPage, ConsentPermissionList, ConsentSection, ConsentStrong, ConsentText, ConversationListView, ConversationTurnSpeaker, CopyableUrl, DEFAULT_AGENT_AVATAR_FIELD_LABELS, DEFAULT_AGENT_BAR_LABELS, DEFAULT_AGENT_CARD_LABELS, DEFAULT_AGENT_CREATOR_LABELS, DEFAULT_AGENT_GALLERY_LABELS, DEFAULT_AGENT_SELECT_LABELS, DEFAULT_AGENT_STEPS_LABELS, DEFAULT_AGENT_TYPE_SELECTOR_LABELS, DEFAULT_AUTHORIZE_AGENT_LABELS, DEFAULT_CONFIG_FIELD_LABELS, DEFAULT_CONFIG_FORM_LABELS, DEFAULT_CONSENT_ACTIONS_LABELS, DEFAULT_COPYABLE_URL_LABELS, DEFAULT_NEW_THREAD_DIALOG_LABELS, DEFAULT_PILL_SELECT_LABELS, DEFAULT_RECURRENCE, DEFAULT_RECURRENCE_BUILDER_LABELS, DEFAULT_SKILL_CARD_LABELS, DEFAULT_SKILL_EDIT_FORM_LABELS, DEFAULT_SKILL_GENERATE_FORM_LABELS, DEFAULT_SKILL_GLOBAL_BADGE_LABELS, DEFAULT_SKILL_ROW_LABELS, DEFAULT_SKILL_VIEW_TOGGLE_LABELS, DEFAULT_SUBAGENT_ROSTER_LABELS, DEFAULT_TASKS_CHROME_LABELS, DEFAULT_TASK_COMPOSER_LABELS, DEFAULT_TASK_LIST_LABELS, DEFAULT_TASK_OUTPUTS_CELL_LABELS, DEFAULT_TASK_PLAN_LABELS, DEFAULT_TASK_RUNS_DIALOG_LABELS, DEFAULT_TASK_STATUS_PILL_LABELS, DEFAULT_TASK_THREAD_CHIP_LABELS, DEFAULT_TASK_TRIGGER_CHIP_LABELS, DEFAULT_TUPLE_ARRAY_FIELD_LABELS, DEFAULT_UPLOAD_TASK_ITEM_LABELS, DEFAULT_UPLOAD_TASK_LIST_LABELS, DEFAULT_WORKFLOWS_CHROME_LABELS, DEFAULT_WORKFLOW_CONFIG_DIALOG_LABELS, DEFAULT_WORKFLOW_LIST_LABELS, DEFAULT_WORKFLOW_THREAD_STRIP_LABELS, DERIVED_NAME_WORDS, EMPTY_NEW_THREAD, GoalCriteria, MAX_TASK_DEPTH, NewThreadDialog, PersonPill, PillSelect, RecurrenceBuilder, STATUS_LABELS, STATUS_ORDER, STATUS_TONE, SkillActionButton, SkillCard, SkillDetail, SkillDetailSection, SkillEditForm, SkillFilterChips, SkillGenerateForm, SkillGlobalBadge, SkillRow, SkillTile, SkillTypeBadge, SkillViewToggle, StepDetail, StepNarration, StepOutcome, StepParams, StepRow, StepSummary, StepTrace, StepTraceSummary, SubAgentLane, SubStepGroup, SubagentRoster, TASK_COLUMN_ORDER, TRIGGER_LABELS, TaskActivityDialog, TaskComposer, TaskFlow, TaskInbox, TaskMoveDialog, TaskOutputsCell, TaskPlan, TaskRunsDialog, TaskStartDialog, TaskStatusPill, TaskTable, TaskThreadChip, TaskTriggerChip, TasksToolbar, ThreadActivity, ThreadNotifyDialog, TupleArrayField, UploadTaskItem, UploadTaskList, WEEKDAYS, WORKFLOW_COLUMN_ORDER, WorkflowConfigDialog, WorkflowDocumentsField, WorkflowLauncher, WorkflowThreadStartedBy, WorkflowThreadStrip, WorkflowsTable, WorkflowsToolbar, agentConfigSectionToValues, agentCreatorToConfigSection, asTaskStatus, authModeFor, buildRRule, buildTaskRows, buildWorkflowScopeSource, compactThreadActivity, composePersona, composerToTaskQuery, composerToWorkRequest, composerToWorkflowRequest, composerToWorkflowUpdate, createTaskColumns, createWorkflowColumns, createsWork, defaultScopeRenderer, defaultTaskComposerValues, deriveAgentName, deriveWorkflowName, descendantIds, describeRRule, filterConversationRows, firstWords, formatElapsed, goalProgress, groupThreadActivity, hasTaskFields, hasTrigger, humanizeSection, indexTasks, inferType, inputDocumentIds, isAgenticWorkflow, isOutOfBounds, isPlainTodo, isSkillRow, isValidAgentName, isoToLocalInput, linkedRunsFromActivity, localInputToIso, matchWorkflowScope, moveTargets, newThreadToRequest, nextCriterionId, ownerExtId, parseRRule, prettifyKey, resolveScopeInputs, skillSlug, stripPersonaPreamble, summarizeAgent, summarizeCapabilities, taskComposerToCreateRequest, taskComposerToUpdateRequest, taskNeedsAccess, taskToComposerValues, useWorkflowPreview, workflowFromSkillMarkdown, workflowStatus, workflowTaskFields, workflowToComposerValues, workflowToSkillMarkdown, workflowTriggerType, workflowWhen } from '../chunk-NJX774HB.js';
3
3
  import '../chunk-4XJZ6AAY.js';
4
4
  import '../chunk-P6GHJSLR.js';
5
5
  export { ActionStepBody, ApprovalEvidence, AssigneeLine, DEFAULT_ASSIGNEE_WORDING, DEFAULT_SCHEMA_FORM_LABELS, DEFAULT_STEP_BAR_LABELS, DEFAULT_TASK_ACTIVITY_LABELS, DEFAULT_WORKFLOW_RUNNER_LABELS, DEFAULT_WORKFLOW_STEP_PARTS_LABELS, EMPTY_WORKFLOW_SCOPE, SKILL_PROMPT_FALLBACK_PLACEHOLDER, SKILL_PROMPT_LABEL, SchemaForm, SendBackControl, TaskActivityTimeline, WorkflowRunner, activeStepId, assigneeName, buildLaunch, canAssign, composeStepPrompt, composeWorkflowPrompt, defaultInputs, dependsOn, fieldToFrontmatter, fillRunText, fillStepInputs, fromPlanAssignee, fromPlanDocumentRef, fromPlanSteps, initialRunInputs, inputsFromContext, isEmptyWorkflowScope, isIncompleteSignal, isPersonAction, isPersonStep, isRunFinished, isSteppedWorkflow, isWorkflowScope, layoutFromPlanSteps, nextAction, orderSteps, promptFieldName, reviewInstructions, runFields, runFieldsOf, runThreadTitle, sendBackTargets, skillToWorkflow, splitDocRef, stepConfigProblems, stepDependencies, stepFields, stepLevels, stepPhase, stepStatesFromActivity, stepWindow, taskActivityHeadline, toPlanAssignee, toPlanDocumentRef, toPlanSteps, upstreamSteps, useWorkflowView, validateInputs, validateStep, validateWorkflowGraph, workflowAccepts, workflowFromFrontmatter, workflowSteps, workflowsAccepting, workflowsForHost } from '../chunk-PGDL26TQ.js';
@@ -14,10 +14,10 @@ import '../chunk-YU2KUMGE.js';
14
14
  import '../chunk-DDF5GPIJ.js';
15
15
  import '../chunk-XD2M6LIG.js';
16
16
  import '../chunk-S7PSMMRG.js';
17
+ import '../chunk-76JDDMSP.js';
17
18
  import '../chunk-HOXKR26S.js';
18
19
  import '../chunk-AA3PT6KR.js';
19
20
  import '../chunk-NPLYHR2E.js';
20
- import '../chunk-76JDDMSP.js';
21
21
  import '../chunk-OXF2IFXG.js';
22
22
  import '../chunk-TX2ZICS7.js';
23
23
  import '../chunk-ZPLG7QYF.js';
@@ -152,8 +152,9 @@ var CONTENT_TYPES = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
152
152
  <Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/><Override PartName="/word/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml"/><Override PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml"/></Types>`;
153
153
  var ROOT_RELS = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
154
154
  <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/><Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/></Relationships>`;
155
- var DOCUMENT_RELS = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
156
- <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/></Relationships>`;
155
+ var documentRels = (more = "") => `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
156
+ <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/>${more}</Relationships>`;
157
+ var hyperlinkRelationship = (id, url) => `<Relationship Id="${esc(id)}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" Target="${esc(url)}" TargetMode="External"/>`;
157
158
  var coreXml = (title, at) => `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
158
159
  <cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><dc:title>${esc(
159
160
  title
@@ -166,7 +167,7 @@ function docxPackage(parts) {
166
167
  "docProps/core.xml": fflate.strToU8(coreXml(parts.title, at)),
167
168
  "word/document.xml": fflate.strToU8(parts.document),
168
169
  "word/styles.xml": fflate.strToU8(parts.styles),
169
- "word/_rels/document.xml.rels": fflate.strToU8(DOCUMENT_RELS)
170
+ "word/_rels/document.xml.rels": fflate.strToU8(documentRels(parts.relationships))
170
171
  });
171
172
  }
172
173
 
@@ -185,6 +186,7 @@ exports.docxPackage = docxPackage;
185
186
  exports.esc = esc;
186
187
  exports.filterTermGroups = filterTermGroups;
187
188
  exports.groupDefinitions = groupDefinitions;
189
+ exports.hyperlinkRelationship = hyperlinkRelationship;
188
190
  exports.minuteUtc = minuteUtc;
189
191
  exports.page = page;
190
192
  exports.paragraph = paragraph;
@@ -192,5 +194,5 @@ exports.parseDefinition = parseDefinition;
192
194
  exports.stylesXml = stylesXml;
193
195
  exports.termKey = termKey;
194
196
  exports.toDefinition = toDefinition;
195
- //# sourceMappingURL=chunk-AOFATOT3.cjs.map
196
- //# sourceMappingURL=chunk-AOFATOT3.cjs.map
197
+ //# sourceMappingURL=chunk-2A4MDHJR.cjs.map
198
+ //# sourceMappingURL=chunk-2A4MDHJR.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/tags/definitions.ts","../src/tags/ooxml.ts"],"names":["decodeWhitespaceEntities","zipSync","strToU8"],"mappings":";;;;;;AAWO,IAAM,iBAAA,GAAoB;AAkDjC,IAAM,MAAA,GAAS,CAAA,0DAAA,CAAA;AACf,IAAM,UAAA,GAAqC;AAAA,EACzC,GAAA,EAAK,GAAA;AAAA,EACL,QAAA,EAAK,QAAA;AAAA,EACL,QAAA,EAAK,QAAA;AAAA,EACL,QAAA,EAAK,QAAA;AAAA,EACL,GAAA,EAAK,GAAA;AAAA,EACL,QAAA,EAAK,QAAA;AAAA,EACL,QAAA,EAAK,QAAA;AAAA,EACL,QAAA,EAAK,QAAA;AAAA,EACL,MAAA,EAAK;AACP,CAAA;AACA,IAAM,QAAA,GAAW,iBAAA;AAEjB,IAAM,UAAA,GACJ,yJAAA;AACF,IAAM,eAAA,GAAkB,EAAA;AACxB,IAAM,cAAA,GAAiB,EAAA;AAGvB,SAAS,MAAM,IAAA,EAAsB;AACnC,EAAA,OAAOA,0CAAA,CAAyB,IAAI,CAAA,CACjC,OAAA,CAAQ,+BAA+B,IAAI,CAAA,CAC3C,OAAA,CAAQ,mBAAA,EAAqB,IAAI,CAAA,CACjC,OAAA,CAAQ,MAAA,EAAQ,GAAG,EACnB,IAAA,EAAK;AACV;AAGO,SAAS,QAAQ,IAAA,EAAsB;AAC5C,EAAA,OAAO,MAAM,IAAI,CAAA,CACd,QAAQ,IAAI,MAAA,CAAO,IAAI,MAAM,C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AA,CAAA;AAIlB,IAAM,YAAA,GAAe,CAAC,IAAA,GAAO,EAAA,KAAO,CAAA;AAAA,mNAAA,EACiL,IAAI,CAAA,gBAAA,CAAA;AAGlN,IAAM,qBAAA,GAAwB,CAAC,EAAA,EAAY,GAAA,KAChD,CAAA,kBAAA,EAAqB,GAAA,CAAI,EAAE,CAAC,CAAA,+FAAA,EAAkG,GAAA,CAAI,GAAG,CAAC,CAAA,yBAAA;AAExI,IAAM,OAAA,GAAU,CACd,KAAA,EACA,EAAA,KACG,CAAA;AAAA,4PAAA,EACyP,GAAA;AAAA,EAC5P;AACF,CAAC,CAAA,sDAAA,EAAyD,EAAE,CAAA,8DAAA,EAAiE,EAAE,CAAA,uCAAA,CAAA;AAGxH,SAAS,YAAY,KAAA,EAQb;AACb,EAAA,MAAM,EAAA,GAAK,IAAI,IAAA,CAAK,KAAA,CAAM,EAAA,IAAM,IAAA,CAAK,GAAA,EAAK,CAAA,CAAE,WAAA,EAAY,CAAE,OAAA,CAAQ,aAAa,GAAG,CAAA;AAClF,EAAA,OAAOC,cAAA,CAAQ;AAAA,IACb,qBAAA,EAAuBC,eAAQ,aAAa,CAAA;AAAA,IAC5C,aAAA,EAAeA,eAAQ,SAAS,CAAA;AAAA,IAChC,qBAAqBA,cAAA,CAAQ,OAAA,CAAQ,KAAA,CAAM,KAAA,EAAO,EAAE,CAAC,CAAA;AAAA,IACrD,mBAAA,EAAqBA,cAAA,CAAQ,KAAA,CAAM,QAAQ,CAAA;AAAA,IAC3C,iBAAA,EAAmBA,cAAA,CAAQ,KAAA,CAAM,MAAM,CAAA;AAAA,IACvC,8BAAA,EAAgCA,cAAA,CAAQ,YAAA,CAAa,KAAA,CAAM,aAAa,CAAC;AAAA,GAC1E,CAAA;AACH","file":"chunk-2A4MDHJR.cjs","sourcesContent":["/**\n * Defined terms. A definition is an ordinary fact carrying the workspace's \"Definitions\" label; its\n * TERM is read from the start of its text — `\"Shares\" means …`, `**Business Day** shall mean …`,\n * `Completion: the date …` — and facts defining the same term (one per agreement, say) are grouped,\n * a confirmed one preferred over the rest, then the most recent. Pure helpers, no React: the Word\n * editor inserts terms with them and the Tags page prints the glossary with them.\n */\n\nimport { decodeWhitespaceEntities } from '../facts/fact-text'\n\n/** The label that marks a fact as a definition. */\nexport const DEFINITIONS_LABEL = 'Definitions'\n\n/** A label on a definition other than {@link DEFINITIONS_LABEL} (e.g. the agreement it is from). */\nexport interface DefinitionLabel {\n id: string\n name: string\n}\n\n/** A definition fact, as the host reads it. */\nexport interface DefinitionSource {\n /** The fact's id (`fct-…`). */\n id: string\n /** The fact text, as written (it may be Markdown). */\n text: string\n /** A human vouched for it: preferred over unconfirmed definitions of the same term. */\n confirmed?: boolean\n /** ISO time it was last written; the most recent wins between equals. */\n updatedAt?: string\n /** Where it comes from: the cited document's name. */\n source?: string\n /** Its other labels, e.g. the agreement (\"SPA\") it defines a term of. */\n labels?: DefinitionLabel[]\n}\n\n/** A definition's text split into its term and the rest. */\nexport interface ParsedDefinition {\n /** The term as written, without quotes or emphasis (`Business Day`). */\n term: string\n /** What follows the term, its connecting word included (`means a day …`, `: the date …`). */\n rest: string\n /** Just the meaning, the connecting word dropped (`a day …`). */\n meaning: string\n}\n\n/** A parsed definition fact. */\nexport interface Definition extends DefinitionSource, ParsedDefinition {\n /** The term's matching key (case and whitespace folded). */\n key: string\n}\n\n/** Every definition of one term, the preferred one first. */\nexport interface DefinedTermGroup {\n key: string\n /** The term as the preferred definition writes it. */\n term: string\n /** The preferred definition (first of {@link DefinedTermGroup.definitions}). */\n preferred: Definition\n definitions: Definition[]\n}\n\nconst QUOTES = `\"“”„‟'‘’‚‛«»`\nconst OPEN_CLOSE: Record<string, string> = {\n '\"': '\"',\n '“': '”',\n '„': '“',\n '‟': '”',\n \"'\": \"'\",\n '‘': '’',\n '‚': '‘',\n '‛': '’',\n '«': '»',\n}\nconst EMPHASIS = /^(\\*\\*|__|\\*|_)/\n/** The words (or punctuation) joining a term to its meaning, longest first. */\nconst CONNECTORS =\n /^(?:shall\\s+(?:have\\s+the\\s+meaning|mean|include)s?|ha(?:s|ve)\\s+the\\s+meanings?|means?\\s+and\\s+includes?|means|mean|includes|include|[:—–]|\\s-\\s|-\\s)/i\nconst MAX_TERM_LENGTH = 80\nconst MAX_TERM_WORDS = 10\n\n/** Markdown emphasis and escapes dropped, entity-encoded whitespace decoded, whitespace collapsed. */\nfunction plain(text: string): string {\n return decodeWhitespaceEntities(text)\n .replace(/\\\\([\\\\`*_{}[\\]()#+\\-.!\"'])/g, '$1')\n .replace(/(\\*\\*|__)(.+?)\\1/g, '$2')\n .replace(/\\s+/g, ' ')\n .trim()\n}\n\n/** The matching key of a term: case and whitespace folded, quotes and emphasis dropped. */\nexport function termKey(term: string): string {\n return plain(term)\n .replace(new RegExp(`[${QUOTES}*_]`, 'g'), '')\n .replace(/\\s+/g, ' ')\n .trim()\n .toLowerCase()\n}\n\nconst validTerm = (term: string) =>\n term.length > 0 &&\n term.length <= MAX_TERM_LENGTH &&\n term.split(/\\s+/).length <= MAX_TERM_WORDS &&\n /\\p{L}/u.test(term)\n\n/** A connector at the start of `rest` (after optional whitespace): its length, or 0. */\nfunction connectorAt(rest: string): number {\n const lead = rest.length - rest.trimStart().length\n // A spaced hyphen needs its leading space, so try the raw text before the trimmed one.\n const spaced = /^\\s-\\s/.exec(rest)\n if (spaced) return spaced[0].length\n const match = CONNECTORS.exec(rest.slice(lead))\n return match ? lead + match[0].length : 0\n}\n\n/**\n * Read a definition's term from the start of its text, or `null` when it does not start with one.\n *\n * Optional straight or curly quotes and bold markers around the term are dropped; the term is what\n * comes before \"means\", \"shall mean\", \"includes\", \"has the meaning\", a colon, or a dash. A quoted\n * term is taken whole, so `\"Long-Stop Date\" means …` keeps its hyphen.\n */\nexport function parseDefinition(text: string): ParsedDefinition | null {\n let s = plain(text)\n // Leading emphasis markers (`**\"Shares\"** means`), any order with the opening quote.\n for (let i = 0; i < 3; i++) s = s.replace(EMPHASIS, '').trimStart()\n let term: string\n let rest: string\n const open = s[0]\n const close = open ? OPEN_CLOSE[open] : undefined\n if (close) {\n const end = s.indexOf(close, 1)\n if (end < 0) return null\n term = s.slice(1, end)\n rest = s.slice(end + 1)\n // Emphasis or a closing quote between the term and its connector (`\"Shares\"**`, `**\"X**\"`).\n rest = rest.replace(new RegExp(`^(?:\\\\*\\\\*|__|\\\\*|_|[${QUOTES}])+`), '')\n } else {\n // Unquoted: the term runs up to the first connector.\n const match =\n /^(.+?)(\\s+(?:shall\\s+(?:have\\s+the\\s+meaning|mean|include)s?|ha(?:s|ve)\\s+the\\s+meanings?|means?\\s+and\\s+includes?|means|includes)\\b|\\s*[:—–]|\\s+-\\s)/i.exec(\n s\n )\n if (!match) return null\n term = match[1]\n rest = s.slice(match[1].length)\n }\n term = term.replace(/(\\*\\*|__|\\*|_)/g, '').trim()\n const joint = connectorAt(rest)\n if (!joint || !validTerm(term)) return null\n const meaning = rest.slice(joint).trim()\n if (!meaning) return null\n return { term, rest: rest.replace(/^\\s+/, ' ').replace(/^ (?=[:—–])/, ''), meaning }\n}\n\n/** A definition parsed, or `null` when its text names no term. */\nexport function toDefinition(source: DefinitionSource): Definition | null {\n const parsed = parseDefinition(source.text)\n return parsed ? { ...source, ...parsed, key: termKey(parsed.term) } : null\n}\n\nconst time = (iso?: string) => (iso ? Date.parse(iso) || 0 : 0)\n\n/** Preferred first: confirmed, then most recently written, then by id (stable). */\nexport function compareDefinitions(a: DefinitionSource, b: DefinitionSource): number {\n return (\n Number(!!b.confirmed) - Number(!!a.confirmed) ||\n time(b.updatedAt) - time(a.updatedAt) ||\n a.id.localeCompare(b.id)\n )\n}\n\n/** Alphabetical order of terms, as a reader sorts a glossary (case and accents folded). */\nexport const compareTerms = (a: string, b: string) =>\n a.localeCompare(b, undefined, { sensitivity: 'base', numeric: true })\n\n/**\n * Definitions grouped by term, alphabetically, each group's preferred definition first. Facts whose\n * text names no term are returned apart (`unparsed`), so a host can say how many it could not read.\n * With `labelId`, only definitions carrying that label (one agreement's, say) are kept.\n */\nexport function groupDefinitions(\n sources: readonly DefinitionSource[],\n options: { labelId?: string | null } = {}\n): { groups: DefinedTermGroup[]; unparsed: DefinitionSource[] } {\n const byKey = new Map<string, Definition[]>()\n const unparsed: DefinitionSource[] = []\n for (const source of sources) {\n if (options.labelId && !source.labels?.some((l) => l.id === options.labelId)) continue\n const definition = toDefinition(source)\n if (!definition) {\n unparsed.push(source)\n continue\n }\n const list = byKey.get(definition.key) ?? []\n list.push(definition)\n byKey.set(definition.key, list)\n }\n const groups = [...byKey.entries()].map(([key, list]) => {\n const definitions = [...list].sort(compareDefinitions)\n return { key, term: definitions[0].term, preferred: definitions[0], definitions }\n })\n groups.sort((a, b) => compareTerms(a.term, b.term))\n return { groups, unparsed }\n}\n\n/** The labels (agreements) definitions carry besides the Definitions label, by name. */\nexport function definitionLabels(sources: readonly DefinitionSource[]): DefinitionLabel[] {\n const byId = new Map<string, DefinitionLabel>()\n for (const s of sources) for (const l of s.labels ?? []) byId.set(l.id, l)\n return [...byId.values()].sort((a, b) => compareTerms(a.name, b.name))\n}\n\n/** Groups whose term matches a typed query: prefix matches first, then any word, then anywhere. */\nexport function filterTermGroups(\n groups: readonly DefinedTermGroup[],\n query: string\n): DefinedTermGroup[] {\n const q = termKey(query)\n if (!q) return [...groups]\n const rank = (g: DefinedTermGroup) =>\n g.key.startsWith(q) ? 0 : g.key.split(' ').some((w) => w.startsWith(q)) ? 1 : 2\n return groups\n .filter((g) => g.key.includes(q))\n .map((g) => ({ g, r: rank(g) }))\n .sort((a, b) => a.r - b.r || compareTerms(a.g.term, b.g.term))\n .map(({ g }) => g)\n}\n\n/** Prefix of every bookmark a defined term links to: hidden in Word (leading underscore). */\nexport const DEFINITION_BOOKMARK_PREFIX = '_dt_'\nconst MAX_BOOKMARK_LENGTH = 40\n\n/**\n * The Word bookmark of a definition: `_dt_` and the fact id in valid bookmark characters\n * (`fct-AbC12345` → `_dt_fct_AbC12345`), at most 40 characters as Word requires.\n */\nexport function definitionBookmark(factId: string): string {\n return (DEFINITION_BOOKMARK_PREFIX + factId.replace(/[^A-Za-z0-9_]/g, '_')).slice(\n 0,\n MAX_BOOKMARK_LENGTH\n )\n}\n\n/** The fact id a definition bookmark names, or `null` for any other bookmark. */\nexport function definitionIdOfBookmark(name: string): string | null {\n const match = /^_dt_([a-z]{3})_([A-Za-z0-9]+)$/.exec(name)\n return match ? `${match[1]}-${match[2]}` : null\n}\n","/**\n * The small WordprocessingML vocabulary the tags exports write: escaped runs, paragraphs, table\n * cells, an A4 page, and the minimal package around a `word/document.xml`. Zipped with `fflate`, so\n * the result opens in the native Word editor and in Word without pulling the editor engine in.\n */\n\nimport { strToU8, zipSync } from 'fflate'\n\nexport const DOCX_MIME_TYPE =\n 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'\n\nexport const W_NAMESPACES =\n 'xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"'\n\n// Text that is not allowed in XML 1.0 at all (control characters) is dropped, not escaped.\n// eslint-disable-next-line no-control-regex\nconst INVALID_XML = /[\\u0000-\\u0008\\u000B\\u000C\\u000E-\\u001F￾￿]/g\n\n/** Text as XML character data or an attribute value. */\nexport const esc = (text: string) =>\n text\n .replace(INVALID_XML, '')\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;')\n\nexport interface Run {\n text: string\n bold?: boolean\n italic?: boolean\n muted?: boolean\n}\n\nexport const run = ({ text, bold, italic, muted }: Run) => {\n const props = [bold && '<w:b/>', italic && '<w:i/>', muted && '<w:color w:val=\"595959\"/>']\n .filter(Boolean)\n .join('')\n // Line breaks inside a value become Word line breaks rather than being lost.\n const body = text\n .split(/\\r?\\n/)\n .map((line) => `<w:t xml:space=\"preserve\">${esc(line)}</w:t>`)\n .join('<w:br/>')\n return `<w:r>${props ? `<w:rPr>${props}</w:rPr>` : ''}${body}</w:r>`\n}\n\nexport const paragraph = (runs: Run[], style?: string) =>\n `<w:p>${style ? `<w:pPr><w:pStyle w:val=\"${style}\"/></w:pPr>` : ''}${runs.map(run).join('')}</w:p>`\n\n/** A table cell: its paragraphs (a cell must hold at least one), shaded when given a fill. */\nexport const cell = (paragraphs: string[], width: number, fill?: string) =>\n `<w:tc><w:tcPr><w:tcW w:w=\"${width}\" w:type=\"dxa\"/>${\n fill ? `<w:shd w:val=\"clear\" w:color=\"auto\" w:fill=\"${fill}\"/>` : ''\n }</w:tcPr>${paragraphs.length ? paragraphs.join('') : '<w:p/>'}</w:tc>`\n\n/** Page geometry in twips (A4), turned for landscape. */\nexport function page(landscape: boolean) {\n const [short, long] = [11906, 16838]\n const margin = landscape ? 1080 : 1440\n const width = landscape ? long : short\n return {\n margin,\n textWidth: width - 2 * margin,\n sectPr: `<w:sectPr><w:pgSz w:w=\"${landscape ? long : short}\" w:h=\"${landscape ? short : long}\"${\n landscape ? ' w:orient=\"landscape\"' : ''\n }/><w:pgMar w:top=\"${margin}\" w:right=\"${margin}\" w:bottom=\"${margin}\" w:left=\"${margin}\" w:header=\"708\" w:footer=\"708\" w:gutter=\"0\"/></w:sectPr>`,\n }\n}\n\n/** `YYYY-MM-DD HH:MM` (UTC) of an ISO time, for a \"taken at\" line. */\nexport const minuteUtc = (at: string) => new Date(at).toISOString().slice(0, 16).replace('T', ' ')\n\n/** A `word/document.xml` around body content (paragraphs, tables, then the section). */\nexport const documentXml = (body: string) =>\n `<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<w:document ${W_NAMESPACES}><w:body>${body}</w:body></w:document>`\n\n/** `word/styles.xml` holding the given style definitions. */\nexport const stylesXml = (defaults: string, styles: string) =>\n `<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<w:styles xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\">${defaults}${styles}</w:styles>`\n\n/** Calibri 11pt (en-GB), 8pt after each paragraph: the document defaults the exports share. */\nexport const DOC_DEFAULTS = `<w:docDefaults><w:rPrDefault><w:rPr><w:rFonts w:ascii=\"Calibri\" w:hAnsi=\"Calibri\" w:eastAsia=\"Calibri\" w:cs=\"Calibri\"/><w:sz w:val=\"22\"/><w:szCs w:val=\"22\"/><w:lang w:val=\"en-GB\"/></w:rPr></w:rPrDefault><w:pPrDefault><w:pPr><w:spacing w:after=\"160\" w:line=\"259\" w:lineRule=\"auto\"/></w:pPr></w:pPrDefault></w:docDefaults>`\n\n/**\n * Styles of a document that is a title and a table: `Title`, the compact `TagTableCell` paragraph\n * and the bordered `TagTableGrid` table.\n */\nexport const TABLE_DOCUMENT_STYLES = stylesXml(\n DOC_DEFAULTS,\n `<w:style w:type=\"paragraph\" w:default=\"1\" w:styleId=\"Normal\"><w:name w:val=\"Normal\"/><w:qFormat/></w:style><w:style w:type=\"paragraph\" w:styleId=\"Title\"><w:name w:val=\"Title\"/><w:basedOn w:val=\"Normal\"/><w:next w:val=\"Normal\"/><w:qFormat/><w:pPr><w:spacing w:after=\"80\" w:line=\"240\" w:lineRule=\"auto\"/></w:pPr><w:rPr><w:sz w:val=\"48\"/><w:szCs w:val=\"48\"/></w:rPr></w:style><w:style w:type=\"paragraph\" w:customStyle=\"1\" w:styleId=\"TagTableCell\"><w:name w:val=\"Tag Table Cell\"/><w:basedOn w:val=\"Normal\"/><w:qFormat/><w:pPr><w:spacing w:after=\"40\" w:line=\"240\" w:lineRule=\"auto\"/></w:pPr><w:rPr><w:sz w:val=\"18\"/><w:szCs w:val=\"18\"/></w:rPr></w:style><w:style w:type=\"table\" w:default=\"1\" w:styleId=\"TableNormal\"><w:name w:val=\"Normal Table\"/><w:tblPr><w:tblInd w:w=\"0\" w:type=\"dxa\"/><w:tblCellMar><w:top w:w=\"0\" w:type=\"dxa\"/><w:left w:w=\"108\" w:type=\"dxa\"/><w:bottom w:w=\"0\" w:type=\"dxa\"/><w:right w:w=\"108\" w:type=\"dxa\"/></w:tblCellMar></w:tblPr></w:style><w:style w:type=\"table\" w:customStyle=\"1\" w:styleId=\"TagTableGrid\"><w:name w:val=\"Tag Table\"/><w:basedOn w:val=\"TableNormal\"/><w:tblPr><w:tblBorders><w:top w:val=\"single\" w:sz=\"4\" w:space=\"0\" w:color=\"BFBFBF\"/><w:left w:val=\"single\" w:sz=\"4\" w:space=\"0\" w:color=\"BFBFBF\"/><w:bottom w:val=\"single\" w:sz=\"4\" w:space=\"0\" w:color=\"BFBFBF\"/><w:right w:val=\"single\" w:sz=\"4\" w:space=\"0\" w:color=\"BFBFBF\"/><w:insideH w:val=\"single\" w:sz=\"4\" w:space=\"0\" w:color=\"BFBFBF\"/><w:insideV w:val=\"single\" w:sz=\"4\" w:space=\"0\" w:color=\"BFBFBF\"/></w:tblBorders><w:tblCellMar><w:top w:w=\"60\" w:type=\"dxa\"/><w:left w:w=\"100\" w:type=\"dxa\"/><w:bottom w:w=\"60\" w:type=\"dxa\"/><w:right w:w=\"100\" w:type=\"dxa\"/></w:tblCellMar></w:tblPr></w:style>`\n)\n\nconst CONTENT_TYPES = `<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\"><Default Extension=\"rels\" ContentType=\"application/vnd.openxmlformats-package.relationships+xml\"/><Default Extension=\"xml\" ContentType=\"application/xml\"/><Override PartName=\"/word/document.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml\"/><Override PartName=\"/word/styles.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml\"/><Override PartName=\"/docProps/core.xml\" ContentType=\"application/vnd.openxmlformats-package.core-properties+xml\"/></Types>`\n\nconst ROOT_RELS = `<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\"><Relationship Id=\"rId1\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument\" Target=\"word/document.xml\"/><Relationship Id=\"rId2\" Type=\"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties\" Target=\"docProps/core.xml\"/></Relationships>`\n\n/** `word/_rels/document.xml.rels`: the styles part, then any further relationships given. */\nconst documentRels = (more = '') => `<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\"><Relationship Id=\"rId1\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles\" Target=\"styles.xml\"/>${more}</Relationships>`\n\n/** A relationship to an external hyperlink target, for `w:hyperlink r:id`. */\nexport const hyperlinkRelationship = (id: string, url: string) =>\n `<Relationship Id=\"${esc(id)}\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink\" Target=\"${esc(url)}\" TargetMode=\"External\"/>`\n\nconst coreXml = (\n title: string,\n at: string\n) => `<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<cp:coreProperties xmlns:cp=\"http://schemas.openxmlformats.org/package/2006/metadata/core-properties\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:dcterms=\"http://purl.org/dc/terms/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><dc:title>${esc(\n title\n)}</dc:title><dcterms:created xsi:type=\"dcterms:W3CDTF\">${at}</dcterms:created><dcterms:modified xsi:type=\"dcterms:W3CDTF\">${at}</dcterms:modified></cp:coreProperties>`\n\n/** The minimal `.docx` package: a document, its styles, and its title and time. */\nexport function docxPackage(parts: {\n document: string\n styles: string\n title: string\n /** ISO time; default now. */\n at?: string\n /** Further `word/document.xml` relationships (e.g. {@link hyperlinkRelationship}). */\n relationships?: string\n}): Uint8Array {\n const at = new Date(parts.at ?? Date.now()).toISOString().replace(/\\.\\d{3}Z$/, 'Z')\n return zipSync({\n '[Content_Types].xml': strToU8(CONTENT_TYPES),\n '_rels/.rels': strToU8(ROOT_RELS),\n 'docProps/core.xml': strToU8(coreXml(parts.title, at)),\n 'word/document.xml': strToU8(parts.document),\n 'word/styles.xml': strToU8(parts.styles),\n 'word/_rels/document.xml.rels': strToU8(documentRels(parts.relationships)),\n })\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { useConnection } from './chunk-OYMWV45N.js';
3
- import { NativeDocxEditor, loadDocxFonts } from './chunk-MYALCKDR.js';
3
+ import { NativeDocxEditor, loadDocxFonts } from './chunk-W2RTZOK3.js';
4
4
  import { useMemo } from 'react';
5
5
  import { useQueryClient, useQuery } from '@tanstack/react-query';
6
6
  import { useArbi, notify, arbiQueryKeys } from '@arbidocs/react';
@@ -88,5 +88,5 @@ function useConnectedNativeDocxAdapter(fontBaseUrl = "/native-docx/fonts") {
88
88
  }
89
89
 
90
90
  export { ConnectedNativeDocxEditor, useConnectedNativeDocxAdapter };
91
- //# sourceMappingURL=chunk-G5JH2YMQ.js.map
92
- //# sourceMappingURL=chunk-G5JH2YMQ.js.map
91
+ //# sourceMappingURL=chunk-4GFB5U3K.js.map
92
+ //# sourceMappingURL=chunk-4GFB5U3K.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/connection/ConnectedNativeDocxEditor.tsx"],"names":[],"mappings":";;;;;;;AAYO,SAAS,yBAAA,CAA0B;AAAA,EACxC,WAAA,GAAc,oBAAA;AAAA,EACd,GAAG;AACL,CAAA,EAAsE;AACpE,EAAA,MAAM,OAAA,GAAU,8BAA8B,WAAW,CAAA;AACzD,EAAA,uBAAO,GAAA,CAAC,gBAAA,EAAA,EAAkB,GAAG,KAAA,EAAO,OAAA,EAAkB,CAAA;AACxD;AAEO,SAAS,6BAAA,CAA8B,cAAc,oBAAA,EAAsB;AAChF,EAAA,MAAM,OAAO,OAAA,EAAQ;AACrB,EAAA,MAAM,EAAE,WAAA,EAAa,MAAA,EAAQ,IAAA,EAAM,mBAAA,KAAwB,aAAA,EAAc;AACzE,EAAA,MAAM,UAAU,cAAA,EAAe;AAC/B,EA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AA,CAAW,MAAM,IAAI,OAAA,GAAU;AAAA,OAC1D,CAAE,CAAA;AAAA,MACF,YAAA,EAAc,OAAO,EAAA,EAAI,OAAA,KAAY;AACnC,QAAA,MAAM,QAAA,GAAW,MAAM,IAAA,CAAK,MAAA,CAAO,QAAQ,CAAA,CAAA,EAAI,kBAAA,CAAmB,EAAE,CAAC,CAAA,SAAA,CAAA,EAAa;AAAA,UAChF,MAAA,EAAQ,MAAA;AAAA,UACR,OAAA,EAAS,EAAE,cAAA,EAAgB,kBAAA,EAAmB;AAAA,UAC9C,IAAA,EAAM,KAAK,SAAA,CAAU;AAAA,YACnB,YAAY,OAAA,CAAQ,SAAA;AAAA,YACpB,aAAa,OAAA,CAAQ,WAAA;AAAA,YACrB,YAAY,OAAA,CAAQ,SAAA;AAAA,YACpB,eAAe,OAAA,CAAQ;AAAA,WACxB;AAAA,SACF,CAAA;AACD,QAAA,MAAM,QAAA,GAAY,MAAM,QAAA,CAAS,IAAA,EAAK;AACtC,QAAA,MAAA,CAAO,QAAQ,oBAAoB,CAAA;AACnC,QAAA,OAAO,EAAE,WAAA,EAAa,QAAA,CAAS,YAAA,IAAgB,EAAC,EAAE;AAAA,MACpD,CAAA;AAAA,MACA,cAAA,EAAgB,OAAO,UAAA,KAAA,CAAgB,MAAM,KAAK,SAAA,CAAU,WAAA,CAAY,UAAU,CAAA,EAAG;AAAA,KACvF,CAAA;AAAA,IACA,CAAC,MAAM,MAAA,EAAQ,IAAA,EAAM,MAAM,OAAA,EAAS,mBAAA,EAAqB,WAAA,EAAa,OAAA,EAAS,WAAW;AAAA,GAC5F;AACA,EAAA,OAAO,OAAA;AACT","file":"chunk-G5JH2YMQ.js","sourcesContent":["import { useMemo } from 'react'\nimport { useQuery, useQueryClient } from '@tanstack/react-query'\nimport { useArbi, notify, arbiQueryKeys } from '@arbidocs/react'\nimport { useConnection } from './ConnectionProvider'\nimport {\n NativeDocxEditor,\n type NativeDocxAdapter,\n type NativeDocxEditorProps,\n} from '../docx/NativeDocxEditor'\nimport { loadDocxFonts } from '../docx/fonts'\n\n/** Native Word widget bound to the standard blocks connection and SDK session. */\nexport function ConnectedNativeDocxEditor({\n fontBaseUrl = '/native-docx/fonts',\n ...props\n}: Omit<NativeDocxEditorProps, 'adapter'> & { fontBaseUrl?: string }) {\n const adapter = useConnectedNativeDocxAdapter(fontBaseUrl)\n return <NativeDocxEditor {...props} adapter={adapter} />\n}\n\nexport function useConnectedNativeDocxAdapter(fontBaseUrl = '/native-docx/fonts') {\n const arbi = useArbi()\n const { workspaceId, apiUrl, user, ensureWorkspaceOpen } = useConnection()\n const queries = useQueryClient()\n const { data: members } = useQuery({\n queryKey: ['native-docx-members', apiUrl, user?.externalId, workspaceId],\n enabled: arbi.isLoggedIn && !!workspaceId,\n queryFn: async () => {\n await ensureWorkspaceOpen()\n return arbi.workspaces.listUsers()\n },\n })\n const adapter = useMemo<NativeDocxAdapter>(\n () => ({\n request: async (path, options) => {\n await ensureWorkspaceOpen()\n return arbi.editor.request(path, options)\n },\n open: async (id) => {\n await ensureWorkspaceOpen()\n return (\n await arbi.editor.request(`/${encodeURIComponent(id)}/session`, { method: 'POST' })\n ).json()\n },\n save: async (id, state) =>\n (\n await arbi.editor.request(`/${encodeURIComponent(id)}/save`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ state }),\n })\n ).json(),\n loadFonts: () => loadDocxFonts(fontBaseUrl),\n baseUrl: apiUrl,\n author: user?.name || 'You',\n onVersionSaved: async (id) => {\n if (!workspaceId) return\n const key = arbiQueryKeys.documents(workspaceId)\n try {\n const documents = await arbi.documents.get([id])\n if (!documents.length) throw new Error('The saved version is not available yet.')\n queries.setQueryData<Awaited<ReturnType<typeof arbi.documents.list>>>(key, (previous) => [\n ...documents,\n ...(previous || []).filter(\n (doc) => !documents.some((saved) => saved.external_id === doc.external_id)\n ),\n ])\n } catch {\n await queries.invalidateQueries({ queryKey: key })\n }\n },\n notify: (message, kind) => notify[kind](message),\n mentions: members?.map(({ user: member }) => ({\n id: member.external_id,\n name: [member.given_name, member.family_name].filter(Boolean).join(' '),\n kind: member.external_id.startsWith('agt-') ? 'agent' : 'human',\n })),\n requestAgent: async (id, request) => {\n const response = await arbi.editor.request(`/${encodeURIComponent(id)}/mentions`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n comment_id: request.commentId,\n instruction: request.instruction,\n request_id: request.requestId,\n recipient_ids: request.recipientIds,\n }),\n })\n const delivery = (await response.json()) as { response_ids: string[] }\n notify.success('Mention delivered.')\n return { responseIds: delivery.response_ids || [] }\n },\n getAgentStatus: async (responseId) => (await arbi.assistant.getResponse(responseId)).status,\n }),\n [arbi, apiUrl, user?.name, members, ensureWorkspaceOpen, fontBaseUrl, queries, workspaceId]\n )\n return adapter\n}\n"]}
1
+ {"version":3,"sources":["../src/connection/ConnectedNativeDocxEditor.tsx"],"names":[],"mappings":";;;;;;;AAYO,SAAS,yBAAA,CAA0B;AAAA,EACxC,WAAA,GAAc,oBAAA;AAAA,EACd,GAAG;AACL,CAAA,EAAsE;AACpE,EAAA,MAAM,OAAA,GAAU,8BAA8B,WAAW,CAAA;AACzD,EAAA,uBAAO,GAAA,CAAC,gBAAA,EAAA,EAAkB,GAAG,KAAA,EAAO,OAAA,EAAkB,CAAA;AACxD;AAEO,SAAS,6BAAA,CAA8B,cAAc,oBAAA,EAAsB;AAChF,EAAA,MAAM,OAAO,OAAA,EAAQ;AACrB,EAAA,MAAM,EAAE,WAAA,EAAa,MAAA,EAAQ,IAAA,EAAM,mBAAA,KAAwB,aAAA,EAAc;AACzE,EAAA,MAAM,UAAU,cAAA,EAAe;AAC/B,EAAA,MAAM,EAAE,IAAA,EAAM,OAAA,EAAQ,GAAI,QAAA,CAAS;AAAA,IACjC,UAAU,CAAC,qBAAA,EAAuB,MAAA,EAAQ,IAAA,EAAM,YAAY,WAAW,CAAA;AAAA,IACvE,OAAA,EAAS,IAAA,CAAK,UAAA,IAAc,CAAC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AI,kBAAA,CAAmB,EAAE,CAAC,CAAA,SAAA,CAAA,EAAa;AAAA,UAChF,MAAA,EAAQ,MAAA;AAAA,UACR,OAAA,EAAS,EAAE,cAAA,EAAgB,kBAAA,EAAmB;AAAA,UAC9C,IAAA,EAAM,KAAK,SAAA,CAAU;AAAA,YACnB,YAAY,OAAA,CAAQ,SAAA;AAAA,YACpB,aAAa,OAAA,CAAQ,WAAA;AAAA,YACrB,YAAY,OAAA,CAAQ,SAAA;AAAA,YACpB,eAAe,OAAA,CAAQ;AAAA,WACxB;AAAA,SACF,CAAA;AACD,QAAA,MAAM,QAAA,GAAY,MAAM,QAAA,CAAS,IAAA,EAAK;AACtC,QAAA,MAAA,CAAO,QAAQ,oBAAoB,CAAA;AACnC,QAAA,OAAO,EAAE,WAAA,EAAa,QAAA,CAAS,YAAA,IAAgB,EAAC,EAAE;AAAA,MACpD,CAAA;AAAA,MACA,cAAA,EAAgB,OAAO,UAAA,KAAA,CAAgB,MAAM,KAAK,SAAA,CAAU,WAAA,CAAY,UAAU,CAAA,EAAG;AAAA,KACvF,CAAA;AAAA,IACA,CAAC,MAAM,MAAA,EAAQ,IAAA,EAAM,MAAM,OAAA,EAAS,mBAAA,EAAqB,WAAA,EAAa,OAAA,EAAS,WAAW;AAAA,GAC5F;AACA,EAAA,OAAO,OAAA;AACT","file":"chunk-4GFB5U3K.js","sourcesContent":["import { useMemo } from 'react'\nimport { useQuery, useQueryClient } from '@tanstack/react-query'\nimport { useArbi, notify, arbiQueryKeys } from '@arbidocs/react'\nimport { useConnection } from './ConnectionProvider'\nimport {\n NativeDocxEditor,\n type NativeDocxAdapter,\n type NativeDocxEditorProps,\n} from '../docx/NativeDocxEditor'\nimport { loadDocxFonts } from '../docx/fonts'\n\n/** Native Word widget bound to the standard blocks connection and SDK session. */\nexport function ConnectedNativeDocxEditor({\n fontBaseUrl = '/native-docx/fonts',\n ...props\n}: Omit<NativeDocxEditorProps, 'adapter'> & { fontBaseUrl?: string }) {\n const adapter = useConnectedNativeDocxAdapter(fontBaseUrl)\n return <NativeDocxEditor {...props} adapter={adapter} />\n}\n\nexport function useConnectedNativeDocxAdapter(fontBaseUrl = '/native-docx/fonts') {\n const arbi = useArbi()\n const { workspaceId, apiUrl, user, ensureWorkspaceOpen } = useConnection()\n const queries = useQueryClient()\n const { data: members } = useQuery({\n queryKey: ['native-docx-members', apiUrl, user?.externalId, workspaceId],\n enabled: arbi.isLoggedIn && !!workspaceId,\n queryFn: async () => {\n await ensureWorkspaceOpen()\n return arbi.workspaces.listUsers()\n },\n })\n const adapter = useMemo<NativeDocxAdapter>(\n () => ({\n request: async (path, options) => {\n await ensureWorkspaceOpen()\n return arbi.editor.request(path, options)\n },\n open: async (id) => {\n await ensureWorkspaceOpen()\n return (\n await arbi.editor.request(`/${encodeURIComponent(id)}/session`, { method: 'POST' })\n ).json()\n },\n save: async (id, state) =>\n (\n await arbi.editor.request(`/${encodeURIComponent(id)}/save`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ state }),\n })\n ).json(),\n loadFonts: () => loadDocxFonts(fontBaseUrl),\n baseUrl: apiUrl,\n author: user?.name || 'You',\n onVersionSaved: async (id) => {\n if (!workspaceId) return\n const key = arbiQueryKeys.documents(workspaceId)\n try {\n const documents = await arbi.documents.get([id])\n if (!documents.length) throw new Error('The saved version is not available yet.')\n queries.setQueryData<Awaited<ReturnType<typeof arbi.documents.list>>>(key, (previous) => [\n ...documents,\n ...(previous || []).filter(\n (doc) => !documents.some((saved) => saved.external_id === doc.external_id)\n ),\n ])\n } catch {\n await queries.invalidateQueries({ queryKey: key })\n }\n },\n notify: (message, kind) => notify[kind](message),\n mentions: members?.map(({ user: member }) => ({\n id: member.external_id,\n name: [member.given_name, member.family_name].filter(Boolean).join(' '),\n kind: member.external_id.startsWith('agt-') ? 'agent' : 'human',\n })),\n requestAgent: async (id, request) => {\n const response = await arbi.editor.request(`/${encodeURIComponent(id)}/mentions`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n comment_id: request.commentId,\n instruction: request.instruction,\n request_id: request.requestId,\n recipient_ids: request.recipientIds,\n }),\n })\n const delivery = (await response.json()) as { response_ids: string[] }\n notify.success('Mention delivered.')\n return { responseIds: delivery.response_ids || [] }\n },\n getAgentStatus: async (responseId) => (await arbi.assistant.getResponse(responseId)).status,\n }),\n [arbi, apiUrl, user?.name, members, ensureWorkspaceOpen, fontBaseUrl, queries, workspaceId]\n )\n return adapter\n}\n"]}
@@ -0,0 +1,139 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var chunkMHVNT4J3_cjs = require('./chunk-MHVNT4J3.cjs');
5
+ var lucideReact = require('lucide-react');
6
+ var ui = require('@arbidocs/react/ui');
7
+ var jsxRuntime = require('react/jsx-runtime');
8
+
9
+ var DEFAULT_FACT_PASSAGES_LABELS = {
10
+ loading: "Loading passage\u2026",
11
+ close: "Close"
12
+ };
13
+ function toPreviewLine(md) {
14
+ return md.replace(/`{1,3}([^`]*)`{1,3}/g, "$1").replace(/!\[[^\]]*\]\([^)]*\)/g, "").replace(/\[([^\]]*)\]\([^)]*\)/g, "$1").replace(/^[>\s]*#{1,6}\s*/gm, "").replace(/^[>\s]*[-*+]\s+/gm, "").replace(/[*_~]/g, "").replace(/\|/g, " ").replace(/\s+/g, " ").trim();
15
+ }
16
+ var SUP_SUB_RE = /<(sup|sub)>([\s\S]*?)<\/\1>/gi;
17
+ var STRAY_SUP_SUB_RE = /<\/?(?:sup|sub)>/gi;
18
+ var stripStrayTags = (s) => s.replace(STRAY_SUP_SUB_RE, "");
19
+ function renderPreviewInline(line) {
20
+ const nodes = [];
21
+ let last = 0;
22
+ let key = 0;
23
+ for (const m of line.matchAll(SUP_SUB_RE)) {
24
+ const start = m.index ?? 0;
25
+ if (start > last) nodes.push(stripStrayTags(line.slice(last, start)));
26
+ const inner = stripStrayTags(m[2]);
27
+ nodes.push(
28
+ m[1].toLowerCase() === "sup" ? /* @__PURE__ */ jsxRuntime.jsx("sup", { children: inner }, key++) : /* @__PURE__ */ jsxRuntime.jsx("sub", { children: inner }, key++)
29
+ );
30
+ last = start + m[0].length;
31
+ }
32
+ if (last < line.length) nodes.push(stripStrayTags(line.slice(last)));
33
+ return nodes;
34
+ }
35
+ function FactPassageItem({
36
+ index,
37
+ page,
38
+ excerpt,
39
+ isViewing,
40
+ onSelect,
41
+ testId,
42
+ className,
43
+ labels
44
+ }) {
45
+ const l = { ...DEFAULT_FACT_PASSAGES_LABELS, ...labels };
46
+ return /* @__PURE__ */ jsxRuntime.jsxs(
47
+ "button",
48
+ {
49
+ type: "button",
50
+ onClick: onSelect,
51
+ "data-testid": chunkMHVNT4J3_cjs.testIdOr(testId, { testId: "fact-source-passage" }),
52
+ "aria-current": isViewing || void 0,
53
+ className: ui.cn(
54
+ "flex w-full items-start gap-2 rounded px-2 py-1.5 text-left text-xs transition-colors pointer-coarse:min-h-11",
55
+ isViewing ? "bg-ai-soft text-foreground ring-1 ring-ai-accent/40" : "bg-ai-soft/60 text-foreground hover:bg-ai-soft",
56
+ className
57
+ ),
58
+ children: [
59
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "mt-0.5 shrink-0 rounded bg-muted px-1 py-0.5 font-mono text-xs text-muted-foreground", children: [
60
+ index + 1,
61
+ "."
62
+ ] }),
63
+ page != null && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "mt-0.5 shrink-0 rounded-full bg-muted px-1.5 py-0.5 font-mono text-xs text-muted-foreground", children: [
64
+ "p.",
65
+ page
66
+ ] }),
67
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap", children: excerpt ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
68
+ "\u201C",
69
+ renderPreviewInline(toPreviewLine(excerpt)),
70
+ "\u201D"
71
+ ] }) : l.loading })
72
+ ]
73
+ }
74
+ );
75
+ }
76
+ function FactSourcesPanel({
77
+ title,
78
+ onClose,
79
+ container,
80
+ children,
81
+ labels,
82
+ testIds
83
+ }) {
84
+ const l = { ...DEFAULT_FACT_PASSAGES_LABELS, ...labels };
85
+ return /* @__PURE__ */ jsxRuntime.jsxs(
86
+ ui.PopoverContent,
87
+ {
88
+ align: "start",
89
+ side: "bottom",
90
+ sideOffset: 4,
91
+ collisionPadding: 16,
92
+ container,
93
+ collisionBoundary: container ?? void 0,
94
+ onInteractOutside: (e) => {
95
+ const target = e.detail.originalEvent.target;
96
+ if (target?.closest(
97
+ '[data-testid="parsed-viewer"], [role="dialog"], [data-radix-popper-content-wrapper]'
98
+ )) {
99
+ e.preventDefault();
100
+ }
101
+ },
102
+ className: "w-[34rem] max-w-[var(--radix-popover-content-available-width)] p-0 data-[state=closed]:animate-none",
103
+ "data-testid": chunkMHVNT4J3_cjs.testIdOr(testIds?.popover, { testId: "fact-sources-popover" }),
104
+ "data-slot": "fact-sources-panel",
105
+ children: [
106
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sticky top-0 z-10 flex items-center justify-between gap-2 border-b border-border bg-popover px-3 py-2", children: [
107
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs font-semibold text-muted-foreground", children: title }),
108
+ /* @__PURE__ */ jsxRuntime.jsx(
109
+ "button",
110
+ {
111
+ type: "button",
112
+ "aria-label": l.close,
113
+ "data-testid": chunkMHVNT4J3_cjs.testIdOr(testIds?.close, { testId: "fact-sources-close" }),
114
+ onClick: onClose,
115
+ className: "-m-1.5 flex shrink-0 items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground pointer-coarse:p-3",
116
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "size-3.5" })
117
+ }
118
+ )
119
+ ] }),
120
+ /* @__PURE__ */ jsxRuntime.jsx(
121
+ "div",
122
+ {
123
+ className: "flex max-h-[min(60vh,var(--radix-popover-content-available-height))] flex-col gap-2 overflow-y-auto p-1.5",
124
+ "data-testid": chunkMHVNT4J3_cjs.testIdOr(testIds?.list, { testId: "fact-sources-list" }),
125
+ children
126
+ }
127
+ )
128
+ ]
129
+ }
130
+ );
131
+ }
132
+
133
+ exports.DEFAULT_FACT_PASSAGES_LABELS = DEFAULT_FACT_PASSAGES_LABELS;
134
+ exports.FactPassageItem = FactPassageItem;
135
+ exports.FactSourcesPanel = FactSourcesPanel;
136
+ exports.renderPreviewInline = renderPreviewInline;
137
+ exports.toPreviewLine = toPreviewLine;
138
+ //# sourceMappingURL=chunk-5FYU7ZIU.cjs.map
139
+ //# sourceMappingURL=chunk-5FYU7ZIU.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/facts/FactPassages.tsx"],"names":["jsx","jsxs","testIdOr","cn","Fragment","PopoverContent","X"],"mappings":";;;;;;;AAUO,IAAM,4BAAA,GAAmD;AAAA,EAC9D,OAAA,EAAS,uBAAA;AAAA,EACT,KAAA,EAAO;AACT;AAYO,SAAS,cAAc,EAAA,EAAoB;AAChD,EAAA,OAAO,EAAA,CACJ,OAAA,CAAQ,sBAAA,EAAwB,IAAI,EACpC,OAAA,CAAQ,uBAAA,EAAyB,EAAE,CAAA,CACnC,OAAA,CAAQ,wBAAA,EAA0B,IAAI,CAAA,CACtC,QAAQ,oBAAA,EAAsB,EAAE,CAAA,CAChC,OAAA,CAAQ,mBAAA,EAAqB,EAAE,CAAA,CAC/B,OAAA,CAAQ,UAAU,EAAE,CAAA,CACpB,OAAA,CAAQ,KAAA,EAAO,GAAG,CAAA,CAClB,OAAA,CAAQ,MAAA,EAAQ,GAAG,EACnB,IAAA,EAAK;AACV;AAGA,IAAM,UAAA,GAAa,+BAAA;AACnB,IAAM,gBAAA,GAAmB,oBAAA;AAEzB,IAAM,iBAAiB,CAAC,CAAA,KAAsB,CAAA,CAAE,OAAA,CAAQ,kBAAkB,EAAE,CAAA;AAMrE,SAAS,oBAAoB,IAAA,EAAyB;AAC3D,EAAA,MAAM,QAAqB,EAAC;AAC5B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H;AAAA;AAAA,GACF;AAEJ","file":"chunk-5FYU7ZIU.cjs","sourcesContent":["import type { ReactNode } from 'react'\nimport { X } from 'lucide-react'\nimport { PopoverContent, cn } from '@arbidocs/react/ui'\nimport { testIdOr } from '../chat/test-id'\n\nexport interface FactPassagesLabels {\n loading: string\n close: string\n}\n\nexport const DEFAULT_FACT_PASSAGES_LABELS: FactPassagesLabels = {\n loading: 'Loading passage…',\n close: 'Close',\n}\n\nexport interface FactSourcesPanelTestIds {\n popover: string\n close: string\n list: string\n}\n\n/**\n * Flatten a passage's markdown to one readable line for a list preview: headings, bullets,\n * emphasis, links and table pipes only add noise on a single truncated line.\n */\nexport function toPreviewLine(md: string): string {\n return md\n .replace(/`{1,3}([^`]*)`{1,3}/g, '$1') // inline / fenced code -> its content\n .replace(/!\\[[^\\]]*\\]\\([^)]*\\)/g, '') // images out\n .replace(/\\[([^\\]]*)\\]\\([^)]*\\)/g, '$1') // links -> their text\n .replace(/^[>\\s]*#{1,6}\\s*/gm, '') // heading markers\n .replace(/^[>\\s]*[-*+]\\s+/gm, '') // list bullets\n .replace(/[*_~]/g, '') // emphasis marks\n .replace(/\\|/g, ' ') // table pipes\n .replace(/\\s+/g, ' ') // collapse whitespace/newlines\n .trim()\n}\n\n/** Inline `<sup>`/`<sub>` (footnote markers) kept by the flatten above, plus stray tag fragments. */\nconst SUP_SUB_RE = /<(sup|sub)>([\\s\\S]*?)<\\/\\1>/gi\nconst STRAY_SUP_SUB_RE = /<\\/?(?:sup|sub)>/gi\n\nconst stripStrayTags = (s: string): string => s.replace(STRAY_SUP_SUB_RE, '')\n\n/**\n * Render a flattened preview line with real super/subscripts: `<sup>15</sup>` shows as a\n * superscript 15, not literal tag text. Unpaired tag fragments are dropped.\n */\nexport function renderPreviewInline(line: string): ReactNode {\n const nodes: ReactNode[] = []\n let last = 0\n let key = 0\n for (const m of line.matchAll(SUP_SUB_RE)) {\n const start = m.index ?? 0\n if (start > last) nodes.push(stripStrayTags(line.slice(last, start)))\n const inner = stripStrayTags(m[2])\n nodes.push(\n m[1].toLowerCase() === 'sup' ? <sup key={key++}>{inner}</sup> : <sub key={key++}>{inner}</sub>\n )\n last = start + m[0].length\n }\n if (last < line.length) nodes.push(stripStrayTags(line.slice(last)))\n return nodes\n}\n\nexport interface FactPassageItemProps {\n /** Zero-based position in the list (shown as `n.`). */\n index: number\n page?: number | null\n /** The passage excerpt (markdown), or null/undefined while it loads. */\n excerpt?: string | null\n /** This passage is the one open in the viewer. */\n isViewing?: boolean\n onSelect: () => void\n testId?: string\n className?: string\n labels?: Partial<FactPassagesLabels>\n}\n\n/** One cited passage: index badge, page pill and a single quoted line. */\nexport function FactPassageItem({\n index,\n page,\n excerpt,\n isViewing,\n onSelect,\n testId,\n className,\n labels,\n}: FactPassageItemProps) {\n const l = { ...DEFAULT_FACT_PASSAGES_LABELS, ...labels }\n return (\n <button\n type=\"button\"\n onClick={onSelect}\n data-testid={testIdOr(testId, { testId: 'fact-source-passage' })}\n aria-current={isViewing || undefined}\n className={cn(\n 'flex w-full items-start gap-2 rounded px-2 py-1.5 text-left text-xs transition-colors pointer-coarse:min-h-11',\n isViewing\n ? 'bg-ai-soft text-foreground ring-1 ring-ai-accent/40'\n : 'bg-ai-soft/60 text-foreground hover:bg-ai-soft',\n className\n )}\n >\n <span className=\"mt-0.5 shrink-0 rounded bg-muted px-1 py-0.5 font-mono text-xs text-muted-foreground\">\n {index + 1}.\n </span>\n {page != null && (\n <span className=\"mt-0.5 shrink-0 rounded-full bg-muted px-1.5 py-0.5 font-mono text-xs text-muted-foreground\">\n p.{page}\n </span>\n )}\n <span className=\"block min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap\">\n {excerpt ? <>“{renderPreviewInline(toPreviewLine(excerpt))}”</> : l.loading}\n </span>\n </button>\n )\n}\n\nexport interface FactSourcesPanelProps {\n /** Header caption, e.g. \"Sources (2 documents)\". */\n title: string\n onClose: () => void\n /** The fact section the panel is portalled INTO and fenced WITHIN. */\n container?: HTMLElement | null\n children: ReactNode\n labels?: Partial<FactPassagesLabels>\n testIds?: Partial<FactSourcesPanelTestIds>\n}\n\n/**\n * Popover panel shell for a fact's sources: sticky header with a close control and a scrolling\n * list. Must sit inside a `Popover`. Stays open while the user works in the document viewer\n * (clicks inside the viewer, dialogs or other popper layers do not dismiss it).\n */\nexport function FactSourcesPanel({\n title,\n onClose,\n container,\n children,\n labels,\n testIds,\n}: FactSourcesPanelProps) {\n const l = { ...DEFAULT_FACT_PASSAGES_LABELS, ...labels }\n return (\n <PopoverContent\n align=\"start\"\n side=\"bottom\"\n sideOffset={4}\n collisionPadding={16}\n container={container}\n collisionBoundary={container ?? undefined}\n onInteractOutside={(e) => {\n const target = e.detail.originalEvent.target as Element | null\n if (\n target?.closest(\n '[data-testid=\"parsed-viewer\"], [role=\"dialog\"], [data-radix-popper-content-wrapper]'\n )\n ) {\n e.preventDefault()\n }\n }}\n // No exit animation: removing the last source unmounts the anchor in the same click, and an\n // animating popover would linger anchorless at the page's top-left.\n className=\"w-[34rem] max-w-[var(--radix-popover-content-available-width)] p-0 data-[state=closed]:animate-none\"\n data-testid={testIdOr(testIds?.popover, { testId: 'fact-sources-popover' })}\n data-slot=\"fact-sources-panel\"\n >\n <div className=\"sticky top-0 z-10 flex items-center justify-between gap-2 border-b border-border bg-popover px-3 py-2\">\n <span className=\"text-xs font-semibold text-muted-foreground\">{title}</span>\n <button\n type=\"button\"\n aria-label={l.close}\n data-testid={testIdOr(testIds?.close, { testId: 'fact-sources-close' })}\n onClick={onClose}\n className=\"-m-1.5 flex shrink-0 items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground pointer-coarse:p-3\"\n >\n <X className=\"size-3.5\" />\n </button>\n </div>\n <div\n className=\"flex max-h-[min(60vh,var(--radix-popover-content-available-height))] flex-col gap-2 overflow-y-auto p-1.5\"\n data-testid={testIdOr(testIds?.list, { testId: 'fact-sources-list' })}\n >\n {children}\n </div>\n </PopoverContent>\n )\n}\n"]}
@@ -2,7 +2,7 @@
2
2
  'use strict';
3
3
 
4
4
  var chunkMUMH3Z6K_cjs = require('./chunk-MUMH3Z6K.cjs');
5
- var chunkFAGQTB3D_cjs = require('./chunk-FAGQTB3D.cjs');
5
+ var chunkZWWN4CUL_cjs = require('./chunk-ZWWN4CUL.cjs');
6
6
  var react$1 = require('react');
7
7
  var reactQuery = require('@tanstack/react-query');
8
8
  var react = require('@arbidocs/react');
@@ -13,7 +13,7 @@ function ConnectedNativeDocxEditor({
13
13
  ...props
14
14
  }) {
15
15
  const adapter = useConnectedNativeDocxAdapter(fontBaseUrl);
16
- return /* @__PURE__ */ jsxRuntime.jsx(chunkFAGQTB3D_cjs.NativeDocxEditor, { ...props, adapter });
16
+ return /* @__PURE__ */ jsxRuntime.jsx(chunkZWWN4CUL_cjs.NativeDocxEditor, { ...props, adapter });
17
17
  }
18
18
  function useConnectedNativeDocxAdapter(fontBaseUrl = "/native-docx/fonts") {
19
19
  const arbi = react.useArbi();
@@ -42,7 +42,7 @@ function useConnectedNativeDocxAdapter(fontBaseUrl = "/native-docx/fonts") {
42
42
  headers: { "Content-Type": "application/json" },
43
43
  body: JSON.stringify({ state })
44
44
  })).json(),
45
- loadFonts: () => chunkFAGQTB3D_cjs.loadDocxFonts(fontBaseUrl),
45
+ loadFonts: () => chunkZWWN4CUL_cjs.loadDocxFonts(fontBaseUrl),
46
46
  baseUrl: apiUrl,
47
47
  author: user?.name || "You",
48
48
  onVersionSaved: async (id) => {
@@ -91,5 +91,5 @@ function useConnectedNativeDocxAdapter(fontBaseUrl = "/native-docx/fonts") {
91
91
 
92
92
  exports.ConnectedNativeDocxEditor = ConnectedNativeDocxEditor;
93
93
  exports.useConnectedNativeDocxAdapter = useConnectedNativeDocxAdapter;
94
- //# sourceMappingURL=chunk-Y5XW57U4.cjs.map
95
- //# sourceMappingURL=chunk-Y5XW57U4.cjs.map
94
+ //# sourceMappingURL=chunk-7LLLQUM7.cjs.map
95
+ //# sourceMappingURL=chunk-7LLLQUM7.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/connection/ConnectedNativeDocxEditor.tsx"],"names":["jsx","NativeDocxEditor","useArbi","useConnection","useQueryClient","useQuery","useMemo","loadDocxFonts","arbiQueryKeys","notify"],"mappings":";;;;;;;;;AAYO,SAAS,yBAAA,CAA0B;AAAA,EACxC,WAAA,GAAc,oBAAA;AAAA,EACd,GAAG;AACL,CAAA,EAAsE;AACpE,EAAA,MAAM,OAAA,GAAU,8BAA8B,WAAW,CAAA;AACzD,EAAA,uBAAOA,cAAA,CAACC,kCAAA,EAAA,EAAkB,GAAG,KAAA,EAAO,OAAA,EAAkB,CAAA;AACxD;AAEO,SAAS,6BAAA,CAA8B,cAAc,oBAAA,EAAsB;AAChF,EAAA,MAAM,OAAOC,aAAA,EAAQ;AACrB,EAAA,MAAM,EAAE,WAAA,EAAa,MAAA,EAAQ,IAAA,EAAM,mBAAA,KAAwBC,+BAAA,EAAc;AACzE,EAAA,MAAM,UAAUC,yBAAA,EAAe;AAC/B,EAAA,MAAM,EAAE,IAAA,EAAM,OAAA,EAAQ,GAAIC,mBAAA,CAAS;AAAA,IACjC,UAAU,CAAC,qBAAA,EAAuB,MAAA,EAAQ,IAAA,EAAM,YAAY,WAAW,CAAA;AAAA,IACvE,OAAA,EAAS,IAAA,CAAK,UAAA,IAAc,CAAC,CAAC,WAAA;AAAA,IAC9B,SAAS,YAAY;AACnB,MAAA,MAAM,mBAAA,EAAoB;AAC1B,MAAA,OAAO,IAAA,CAAK,WAAW,SAAA,EAAU;AAAA,IACnC;AAAA,GACD,CAAA;AACD,EAAA,MAAM,OAAA,GAAUC,eAAA;AAAA,IACd,OAAO;AAAA,MACL,OAAA,EAAS,OAAO,IAAA,EAAM,OAAA,KAAY;AAChC,QAAA,MAAM,mBAAA,EAAoB;AAC1B,QAAA,OAAO,IAAA,CAAK,MAAA,CAAO,OAAA,CAAQ,IAAA,EAAM,OAAO,CAAA;AAAA,MAC1C,CAAA;AA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Y,MAAM,QAAA,CAAS,IAAA,EAAK;AACtC,QAAAA,YAAA,CAAO,QAAQ,oBAAoB,CAAA;AACnC,QAAA,OAAO,EAAE,WAAA,EAAa,QAAA,CAAS,YAAA,IAAgB,EAAC,EAAE;AAAA,MACpD,CAAA;AAAA,MACA,cAAA,EAAgB,OAAO,UAAA,KAAA,CAAgB,MAAM,KAAK,SAAA,CAAU,WAAA,CAAY,UAAU,CAAA,EAAG;AAAA,KACvF,CAAA;AAAA,IACA,CAAC,MAAM,MAAA,EAAQ,IAAA,EAAM,MAAM,OAAA,EAAS,mBAAA,EAAqB,WAAA,EAAa,OAAA,EAAS,WAAW;AAAA,GAC5F;AACA,EAAA,OAAO,OAAA;AACT","file":"chunk-Y5XW57U4.cjs","sourcesContent":["import { useMemo } from 'react'\nimport { useQuery, useQueryClient } from '@tanstack/react-query'\nimport { useArbi, notify, arbiQueryKeys } from '@arbidocs/react'\nimport { useConnection } from './ConnectionProvider'\nimport {\n NativeDocxEditor,\n type NativeDocxAdapter,\n type NativeDocxEditorProps,\n} from '../docx/NativeDocxEditor'\nimport { loadDocxFonts } from '../docx/fonts'\n\n/** Native Word widget bound to the standard blocks connection and SDK session. */\nexport function ConnectedNativeDocxEditor({\n fontBaseUrl = '/native-docx/fonts',\n ...props\n}: Omit<NativeDocxEditorProps, 'adapter'> & { fontBaseUrl?: string }) {\n const adapter = useConnectedNativeDocxAdapter(fontBaseUrl)\n return <NativeDocxEditor {...props} adapter={adapter} />\n}\n\nexport function useConnectedNativeDocxAdapter(fontBaseUrl = '/native-docx/fonts') {\n const arbi = useArbi()\n const { workspaceId, apiUrl, user, ensureWorkspaceOpen } = useConnection()\n const queries = useQueryClient()\n const { data: members } = useQuery({\n queryKey: ['native-docx-members', apiUrl, user?.externalId, workspaceId],\n enabled: arbi.isLoggedIn && !!workspaceId,\n queryFn: async () => {\n await ensureWorkspaceOpen()\n return arbi.workspaces.listUsers()\n },\n })\n const adapter = useMemo<NativeDocxAdapter>(\n () => ({\n request: async (path, options) => {\n await ensureWorkspaceOpen()\n return arbi.editor.request(path, options)\n },\n open: async (id) => {\n await ensureWorkspaceOpen()\n return (\n await arbi.editor.request(`/${encodeURIComponent(id)}/session`, { method: 'POST' })\n ).json()\n },\n save: async (id, state) =>\n (\n await arbi.editor.request(`/${encodeURIComponent(id)}/save`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ state }),\n })\n ).json(),\n loadFonts: () => loadDocxFonts(fontBaseUrl),\n baseUrl: apiUrl,\n author: user?.name || 'You',\n onVersionSaved: async (id) => {\n if (!workspaceId) return\n const key = arbiQueryKeys.documents(workspaceId)\n try {\n const documents = await arbi.documents.get([id])\n if (!documents.length) throw new Error('The saved version is not available yet.')\n queries.setQueryData<Awaited<ReturnType<typeof arbi.documents.list>>>(key, (previous) => [\n ...documents,\n ...(previous || []).filter(\n (doc) => !documents.some((saved) => saved.external_id === doc.external_id)\n ),\n ])\n } catch {\n await queries.invalidateQueries({ queryKey: key })\n }\n },\n notify: (message, kind) => notify[kind](message),\n mentions: members?.map(({ user: member }) => ({\n id: member.external_id,\n name: [member.given_name, member.family_name].filter(Boolean).join(' '),\n kind: member.external_id.startsWith('agt-') ? 'agent' : 'human',\n })),\n requestAgent: async (id, request) => {\n const response = await arbi.editor.request(`/${encodeURIComponent(id)}/mentions`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n comment_id: request.commentId,\n instruction: request.instruction,\n request_id: request.requestId,\n recipient_ids: request.recipientIds,\n }),\n })\n const delivery = (await response.json()) as { response_ids: string[] }\n notify.success('Mention delivered.')\n return { responseIds: delivery.response_ids || [] }\n },\n getAgentStatus: async (responseId) => (await arbi.assistant.getResponse(responseId)).status,\n }),\n [arbi, apiUrl, user?.name, members, ensureWorkspaceOpen, fontBaseUrl, queries, workspaceId]\n )\n return adapter\n}\n"]}
1
+ {"version":3,"sources":["../src/connection/ConnectedNativeDocxEditor.tsx"],"names":["jsx","Native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EAAE,WAAA,EAAa,QAAA,CAAS,YAAA,IAAgB,EAAC,EAAE;AAAA,MACpD,CAAA;AAAA,MACA,cAAA,EAAgB,OAAO,UAAA,KAAA,CAAgB,MAAM,KAAK,SAAA,CAAU,WAAA,CAAY,UAAU,CAAA,EAAG;AAAA,KACvF,CAAA;AAAA,IACA,CAAC,MAAM,MAAA,EAAQ,IAAA,EAAM,MAAM,OAAA,EAAS,mBAAA,EAAqB,WAAA,EAAa,OAAA,EAAS,WAAW;AAAA,GAC5F;AACA,EAAA,OAAO,OAAA;AACT","file":"chunk-7LLLQUM7.cjs","sourcesContent":["import { useMemo } from 'react'\nimport { useQuery, useQueryClient } from '@tanstack/react-query'\nimport { useArbi, notify, arbiQueryKeys } from '@arbidocs/react'\nimport { useConnection } from './ConnectionProvider'\nimport {\n NativeDocxEditor,\n type NativeDocxAdapter,\n type NativeDocxEditorProps,\n} from '../docx/NativeDocxEditor'\nimport { loadDocxFonts } from '../docx/fonts'\n\n/** Native Word widget bound to the standard blocks connection and SDK session. */\nexport function ConnectedNativeDocxEditor({\n fontBaseUrl = '/native-docx/fonts',\n ...props\n}: Omit<NativeDocxEditorProps, 'adapter'> & { fontBaseUrl?: string }) {\n const adapter = useConnectedNativeDocxAdapter(fontBaseUrl)\n return <NativeDocxEditor {...props} adapter={adapter} />\n}\n\nexport function useConnectedNativeDocxAdapter(fontBaseUrl = '/native-docx/fonts') {\n const arbi = useArbi()\n const { workspaceId, apiUrl, user, ensureWorkspaceOpen } = useConnection()\n const queries = useQueryClient()\n const { data: members } = useQuery({\n queryKey: ['native-docx-members', apiUrl, user?.externalId, workspaceId],\n enabled: arbi.isLoggedIn && !!workspaceId,\n queryFn: async () => {\n await ensureWorkspaceOpen()\n return arbi.workspaces.listUsers()\n },\n })\n const adapter = useMemo<NativeDocxAdapter>(\n () => ({\n request: async (path, options) => {\n await ensureWorkspaceOpen()\n return arbi.editor.request(path, options)\n },\n open: async (id) => {\n await ensureWorkspaceOpen()\n return (\n await arbi.editor.request(`/${encodeURIComponent(id)}/session`, { method: 'POST' })\n ).json()\n },\n save: async (id, state) =>\n (\n await arbi.editor.request(`/${encodeURIComponent(id)}/save`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ state }),\n })\n ).json(),\n loadFonts: () => loadDocxFonts(fontBaseUrl),\n baseUrl: apiUrl,\n author: user?.name || 'You',\n onVersionSaved: async (id) => {\n if (!workspaceId) return\n const key = arbiQueryKeys.documents(workspaceId)\n try {\n const documents = await arbi.documents.get([id])\n if (!documents.length) throw new Error('The saved version is not available yet.')\n queries.setQueryData<Awaited<ReturnType<typeof arbi.documents.list>>>(key, (previous) => [\n ...documents,\n ...(previous || []).filter(\n (doc) => !documents.some((saved) => saved.external_id === doc.external_id)\n ),\n ])\n } catch {\n await queries.invalidateQueries({ queryKey: key })\n }\n },\n notify: (message, kind) => notify[kind](message),\n mentions: members?.map(({ user: member }) => ({\n id: member.external_id,\n name: [member.given_name, member.family_name].filter(Boolean).join(' '),\n kind: member.external_id.startsWith('agt-') ? 'agent' : 'human',\n })),\n requestAgent: async (id, request) => {\n const response = await arbi.editor.request(`/${encodeURIComponent(id)}/mentions`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n comment_id: request.commentId,\n instruction: request.instruction,\n request_id: request.requestId,\n recipient_ids: request.recipientIds,\n }),\n })\n const delivery = (await response.json()) as { response_ids: string[] }\n notify.success('Mention delivered.')\n return { responseIds: delivery.response_ids || [] }\n },\n getAgentStatus: async (responseId) => (await arbi.assistant.getResponse(responseId)).status,\n }),\n [arbi, apiUrl, user?.name, members, ensureWorkspaceOpen, fontBaseUrl, queries, workspaceId]\n )\n return adapter\n}\n"]}
@@ -150,8 +150,9 @@ var CONTENT_TYPES = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
150
150
  <Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/><Override PartName="/word/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml"/><Override PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml"/></Types>`;
151
151
  var ROOT_RELS = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
152
152
  <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/><Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/></Relationships>`;
153
- var DOCUMENT_RELS = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
154
- <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/></Relationships>`;
153
+ var documentRels = (more = "") => `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
154
+ <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/>${more}</Relationships>`;
155
+ var hyperlinkRelationship = (id, url) => `<Relationship Id="${esc(id)}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" Target="${esc(url)}" TargetMode="External"/>`;
155
156
  var coreXml = (title, at) => `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
156
157
  <cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><dc:title>${esc(
157
158
  title
@@ -164,10 +165,10 @@ function docxPackage(parts) {
164
165
  "docProps/core.xml": strToU8(coreXml(parts.title, at)),
165
166
  "word/document.xml": strToU8(parts.document),
166
167
  "word/styles.xml": strToU8(parts.styles),
167
- "word/_rels/document.xml.rels": strToU8(DOCUMENT_RELS)
168
+ "word/_rels/document.xml.rels": strToU8(documentRels(parts.relationships))
168
169
  });
169
170
  }
170
171
 
171
- export { DEFINITIONS_LABEL, DEFINITION_BOOKMARK_PREFIX, DOCX_MIME_TYPE, TABLE_DOCUMENT_STYLES, cell, compareDefinitions, compareTerms, definitionBookmark, definitionIdOfBookmark, definitionLabels, documentXml, docxPackage, esc, filterTermGroups, groupDefinitions, minuteUtc, page, paragraph, parseDefinition, stylesXml, termKey, toDefinition };
172
- //# sourceMappingURL=chunk-D3QPYKZG.js.map
173
- //# sourceMappingURL=chunk-D3QPYKZG.js.map
172
+ export { DEFINITIONS_LABEL, DEFINITION_BOOKMARK_PREFIX, DOCX_MIME_TYPE, TABLE_DOCUMENT_STYLES, cell, compareDefinitions, compareTerms, definitionBookmark, definitionIdOfBookmark, definitionLabels, documentXml, docxPackage, esc, filterTermGroups, groupDefinitions, hyperlinkRelationship, minuteUtc, page, paragraph, parseDefinition, stylesXml, termKey, toDefinition };
173
+ //# sourceMappingURL=chunk-EPHGD4YV.js.map
174
+ //# sourceMappingURL=chunk-EPHGD4YV.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/tags/definitions.ts","../src/tags/ooxml.ts"],"names":[],"mappings":";;;;AAWO,IAAM,iBAAA,GAAoB;AAkDjC,IAAM,MAAA,GAAS,CAAA,0DAAA,CAAA;AACf,IAAM,UAAA,GAAqC;AAAA,EACzC,GAAA,EAAK,GAAA;AAAA,EACL,QAAA,EAAK,QAAA;AAAA,EACL,QAAA,EAAK,QAAA;AAAA,EACL,QAAA,EAAK,QAAA;AAAA,EACL,GAAA,EAAK,GAAA;AAAA,EACL,QAAA,EAAK,QAAA;AAAA,EACL,QAAA,EAAK,QAAA;AAAA,EACL,QAAA,EAAK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,aAAA,EAAe,QAAQ,SAAS,CAAA;AAAA,IAChC,qBAAqB,OAAA,CAAQ,OAAA,CAAQ,KAAA,CAAM,KAAA,EAAO,EAAE,CAAC,CAAA;AAAA,IACrD,mBAAA,EAAqB,OAAA,CAAQ,KAAA,CAAM,QAAQ,CAAA;AAAA,IAC3C,iBAAA,EAAmB,OAAA,CAAQ,KAAA,CAAM,MAAM,CAAA;AAAA,IACvC,8BAAA,EAAgC,OAAA,CAAQ,YAAA,CAAa,KAAA,CAAM,aAAa,CAAC;AAAA,GAC1E,CAAA;AACH","file":"chunk-EPHGD4YV.js","sourcesContent":["/**\n * Defined terms. A definition is an ordinary fact carrying the workspace's \"Definitions\" label; its\n * TERM is read from the start of its text — `\"Shares\" means …`, `**Business Day** shall mean …`,\n * `Completion: the date …` — and facts defining the same term (one per agreement, say) are grouped,\n * a confirmed one preferred over the rest, then the most recent. Pure helpers, no React: the Word\n * editor inserts terms with them and the Tags page prints the glossary with them.\n */\n\nimport { decodeWhitespaceEntities } from '../facts/fact-text'\n\n/** The label that marks a fact as a definition. */\nexport const DEFINITIONS_LABEL = 'Definitions'\n\n/** A label on a definition other than {@link DEFINITIONS_LABEL} (e.g. the agreement it is from). */\nexport interface DefinitionLabel {\n id: string\n name: string\n}\n\n/** A definition fact, as the host reads it. */\nexport interface DefinitionSource {\n /** The fact's id (`fct-…`). */\n id: string\n /** The fact text, as written (it may be Markdown). */\n text: string\n /** A human vouched for it: preferred over unconfirmed definitions of the same term. */\n confirmed?: boolean\n /** ISO time it was last written; the most recent wins between equals. */\n updatedAt?: string\n /** Where it comes from: the cited document's name. */\n source?: string\n /** Its other labels, e.g. the agreement (\"SPA\") it defines a term of. */\n labels?: DefinitionLabel[]\n}\n\n/** A definition's text split into its term and the rest. */\nexport interface ParsedDefinition {\n /** The term as written, without quotes or emphasis (`Business Day`). */\n term: string\n /** What follows the term, its connecting word included (`means a day …`, `: the date …`). */\n rest: string\n /** Just the meaning, the connecting word dropped (`a day …`). */\n meaning: string\n}\n\n/** A parsed definition fact. */\nexport interface Definition extends DefinitionSource, ParsedDefinition {\n /** The term's matching key (case and whitespace folded). */\n key: string\n}\n\n/** Every definition of one term, the preferred one first. */\nexport interface DefinedTermGroup {\n key: string\n /** The term as the preferred definition writes it. */\n term: string\n /** The preferred definition (first of {@link DefinedTermGroup.definitions}). */\n preferred: Definition\n definitions: Definition[]\n}\n\nconst QUOTES = `\"“”„‟'‘’‚‛«»`\nconst OPEN_CLOSE: Record<string, string> = {\n '\"': '\"',\n '“': '”',\n '„': '“',\n '‟': '”',\n \"'\": \"'\",\n '‘': '’',\n '‚': '‘',\n '‛': '’',\n '«': '»',\n}\nconst EMPHASIS = /^(\\*\\*|__|\\*|_)/\n/** The words (or punctuation) joining a term to its meaning, longest first. */\nconst CONNECTORS =\n /^(?:shall\\s+(?:have\\s+the\\s+meaning|mean|include)s?|ha(?:s|ve)\\s+the\\s+meanings?|means?\\s+and\\s+includes?|means|mean|includes|include|[:—–]|\\s-\\s|-\\s)/i\nconst MAX_TERM_LENGTH = 80\nconst MAX_TERM_WORDS = 10\n\n/** Markdown emphasis and escapes dropped, entity-encoded whitespace decoded, whitespace collapsed. */\nfunction plain(text: string): string {\n return decodeWhitespaceEntities(text)\n .replace(/\\\\([\\\\`*_{}[\\]()#+\\-.!\"'])/g, '$1')\n .replace(/(\\*\\*|__)(.+?)\\1/g, '$2')\n .replace(/\\s+/g, ' ')\n .trim()\n}\n\n/** The matching key of a term: case and whitespace folded, quotes and emphasis dropped. */\nexport function termKey(term: string): string {\n return plain(term)\n .replace(new RegExp(`[${QUOTES}*_]`, 'g'), '')\n .replace(/\\s+/g, ' ')\n .trim()\n .toLowerCase()\n}\n\nconst validTerm = (term: string) =>\n term.length > 0 &&\n term.length <= MAX_TERM_LENGTH &&\n term.split(/\\s+/).length <= MAX_TERM_WORDS &&\n /\\p{L}/u.test(term)\n\n/** A connector at the start of `rest` (after optional whitespace): its length, or 0. */\nfunction connectorAt(rest: string): number {\n const lead = rest.length - rest.trimStart().length\n // A spaced hyphen needs its leading space, so try the raw text before the trimmed one.\n const spaced = /^\\s-\\s/.exec(rest)\n if (spaced) return spaced[0].length\n const match = CONNECTORS.exec(rest.slice(lead))\n return match ? lead + match[0].length : 0\n}\n\n/**\n * Read a definition's term from the start of its text, or `null` when it does not start with one.\n *\n * Optional straight or curly quotes and bold markers around the term are dropped; the term is what\n * comes before \"means\", \"shall mean\", \"includes\", \"has the meaning\", a colon, or a dash. A quoted\n * term is taken whole, so `\"Long-Stop Date\" means …` keeps its hyphen.\n */\nexport function parseDefinition(text: string): ParsedDefinition | null {\n let s = plain(text)\n // Leading emphasis markers (`**\"Shares\"** means`), any order with the opening quote.\n for (let i = 0; i < 3; i++) s = s.replace(EMPHASIS, '').trimStart()\n let term: string\n let rest: string\n const open = s[0]\n const close = open ? OPEN_CLOSE[open] : undefined\n if (close) {\n const end = s.indexOf(close, 1)\n if (end < 0) return null\n term = s.slice(1, end)\n rest = s.slice(end + 1)\n // Emphasis or a closing quote between the term and its connector (`\"Shares\"**`, `**\"X**\"`).\n rest = rest.replace(new RegExp(`^(?:\\\\*\\\\*|__|\\\\*|_|[${QUOTES}])+`), '')\n } else {\n // Unquoted: the term runs up to the first connector.\n const match =\n /^(.+?)(\\s+(?:shall\\s+(?:have\\s+the\\s+meaning|mean|include)s?|ha(?:s|ve)\\s+the\\s+meanings?|means?\\s+and\\s+includes?|means|includes)\\b|\\s*[:—–]|\\s+-\\s)/i.exec(\n s\n )\n if (!match) return null\n term = match[1]\n rest = s.slice(match[1].length)\n }\n term = term.replace(/(\\*\\*|__|\\*|_)/g, '').trim()\n const joint = connectorAt(rest)\n if (!joint || !validTerm(term)) return null\n const meaning = rest.slice(joint).trim()\n if (!meaning) return null\n return { term, rest: rest.replace(/^\\s+/, ' ').replace(/^ (?=[:—–])/, ''), meaning }\n}\n\n/** A definition parsed, or `null` when its text names no term. */\nexport function toDefinition(source: DefinitionSource): Definition | null {\n const parsed = parseDefinition(source.text)\n return parsed ? { ...source, ...parsed, key: termKey(parsed.term) } : null\n}\n\nconst time = (iso?: string) => (iso ? Date.parse(iso) || 0 : 0)\n\n/** Preferred first: confirmed, then most recently written, then by id (stable). */\nexport function compareDefinitions(a: DefinitionSource, b: DefinitionSource): number {\n return (\n Number(!!b.confirmed) - Number(!!a.confirmed) ||\n time(b.updatedAt) - time(a.updatedAt) ||\n a.id.localeCompare(b.id)\n )\n}\n\n/** Alphabetical order of terms, as a reader sorts a glossary (case and accents folded). */\nexport const compareTerms = (a: string, b: string) =>\n a.localeCompare(b, undefined, { sensitivity: 'base', numeric: true })\n\n/**\n * Definitions grouped by term, alphabetically, each group's preferred definition first. Facts whose\n * text names no term are returned apart (`unparsed`), so a host can say how many it could not read.\n * With `labelId`, only definitions carrying that label (one agreement's, say) are kept.\n */\nexport function groupDefinitions(\n sources: readonly DefinitionSource[],\n options: { labelId?: string | null } = {}\n): { groups: DefinedTermGroup[]; unparsed: DefinitionSource[] } {\n const byKey = new Map<string, Definition[]>()\n const unparsed: DefinitionSource[] = []\n for (const source of sources) {\n if (options.labelId && !source.labels?.some((l) => l.id === options.labelId)) continue\n const definition = toDefinition(source)\n if (!definition) {\n unparsed.push(source)\n continue\n }\n const list = byKey.get(definition.key) ?? []\n list.push(definition)\n byKey.set(definition.key, list)\n }\n const groups = [...byKey.entries()].map(([key, list]) => {\n const definitions = [...list].sort(compareDefinitions)\n return { key, term: definitions[0].term, preferred: definitions[0], definitions }\n })\n groups.sort((a, b) => compareTerms(a.term, b.term))\n return { groups, unparsed }\n}\n\n/** The labels (agreements) definitions carry besides the Definitions label, by name. */\nexport function definitionLabels(sources: readonly DefinitionSource[]): DefinitionLabel[] {\n const byId = new Map<string, DefinitionLabel>()\n for (const s of sources) for (const l of s.labels ?? []) byId.set(l.id, l)\n return [...byId.values()].sort((a, b) => compareTerms(a.name, b.name))\n}\n\n/** Groups whose term matches a typed query: prefix matches first, then any word, then anywhere. */\nexport function filterTermGroups(\n groups: readonly DefinedTermGroup[],\n query: string\n): DefinedTermGroup[] {\n const q = termKey(query)\n if (!q) return [...groups]\n const rank = (g: DefinedTermGroup) =>\n g.key.startsWith(q) ? 0 : g.key.split(' ').some((w) => w.startsWith(q)) ? 1 : 2\n return groups\n .filter((g) => g.key.includes(q))\n .map((g) => ({ g, r: rank(g) }))\n .sort((a, b) => a.r - b.r || compareTerms(a.g.term, b.g.term))\n .map(({ g }) => g)\n}\n\n/** Prefix of every bookmark a defined term links to: hidden in Word (leading underscore). */\nexport const DEFINITION_BOOKMARK_PREFIX = '_dt_'\nconst MAX_BOOKMARK_LENGTH = 40\n\n/**\n * The Word bookmark of a definition: `_dt_` and the fact id in valid bookmark characters\n * (`fct-AbC12345` → `_dt_fct_AbC12345`), at most 40 characters as Word requires.\n */\nexport function definitionBookmark(factId: string): string {\n return (DEFINITION_BOOKMARK_PREFIX + factId.replace(/[^A-Za-z0-9_]/g, '_')).slice(\n 0,\n MAX_BOOKMARK_LENGTH\n )\n}\n\n/** The fact id a definition bookmark names, or `null` for any other bookmark. */\nexport function definitionIdOfBookmark(name: string): string | null {\n const match = /^_dt_([a-z]{3})_([A-Za-z0-9]+)$/.exec(name)\n return match ? `${match[1]}-${match[2]}` : null\n}\n","/**\n * The small WordprocessingML vocabulary the tags exports write: escaped runs, paragraphs, table\n * cells, an A4 page, and the minimal package around a `word/document.xml`. Zipped with `fflate`, so\n * the result opens in the native Word editor and in Word without pulling the editor engine in.\n */\n\nimport { strToU8, zipSync } from 'fflate'\n\nexport const DOCX_MIME_TYPE =\n 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'\n\nexport const W_NAMESPACES =\n 'xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"'\n\n// Text that is not allowed in XML 1.0 at all (control characters) is dropped, not escaped.\n// eslint-disable-next-line no-control-regex\nconst INVALID_XML = /[\\u0000-\\u0008\\u000B\\u000C\\u000E-\\u001F￾￿]/g\n\n/** Text as XML character data or an attribute value. */\nexport const esc = (text: string) =>\n text\n .replace(INVALID_XML, '')\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;')\n\nexport interface Run {\n text: string\n bold?: boolean\n italic?: boolean\n muted?: boolean\n}\n\nexport const run = ({ text, bold, italic, muted }: Run) => {\n const props = [bold && '<w:b/>', italic && '<w:i/>', muted && '<w:color w:val=\"595959\"/>']\n .filter(Boolean)\n .join('')\n // Line breaks inside a value become Word line breaks rather than being lost.\n const body = text\n .split(/\\r?\\n/)\n .map((line) => `<w:t xml:space=\"preserve\">${esc(line)}</w:t>`)\n .join('<w:br/>')\n return `<w:r>${props ? `<w:rPr>${props}</w:rPr>` : ''}${body}</w:r>`\n}\n\nexport const paragraph = (runs: Run[], style?: string) =>\n `<w:p>${style ? `<w:pPr><w:pStyle w:val=\"${style}\"/></w:pPr>` : ''}${runs.map(run).join('')}</w:p>`\n\n/** A table cell: its paragraphs (a cell must hold at least one), shaded when given a fill. */\nexport const cell = (paragraphs: string[], width: number, fill?: string) =>\n `<w:tc><w:tcPr><w:tcW w:w=\"${width}\" w:type=\"dxa\"/>${\n fill ? `<w:shd w:val=\"clear\" w:color=\"auto\" w:fill=\"${fill}\"/>` : ''\n }</w:tcPr>${paragraphs.length ? paragraphs.join('') : '<w:p/>'}</w:tc>`\n\n/** Page geometry in twips (A4), turned for landscape. */\nexport function page(landscape: boolean) {\n const [short, long] = [11906, 16838]\n const margin = landscape ? 1080 : 1440\n const width = landscape ? long : short\n return {\n margin,\n textWidth: width - 2 * margin,\n sectPr: `<w:sectPr><w:pgSz w:w=\"${landscape ? long : short}\" w:h=\"${landscape ? short : long}\"${\n landscape ? ' w:orient=\"landscape\"' : ''\n }/><w:pgMar w:top=\"${margin}\" w:right=\"${margin}\" w:bottom=\"${margin}\" w:left=\"${margin}\" w:header=\"708\" w:footer=\"708\" w:gutter=\"0\"/></w:sectPr>`,\n }\n}\n\n/** `YYYY-MM-DD HH:MM` (UTC) of an ISO time, for a \"taken at\" line. */\nexport const minuteUtc = (at: string) => new Date(at).toISOString().slice(0, 16).replace('T', ' ')\n\n/** A `word/document.xml` around body content (paragraphs, tables, then the section). */\nexport const documentXml = (body: string) =>\n `<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<w:document ${W_NAMESPACES}><w:body>${body}</w:body></w:document>`\n\n/** `word/styles.xml` holding the given style definitions. */\nexport const stylesXml = (defaults: string, styles: string) =>\n `<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<w:styles xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\">${defaults}${styles}</w:styles>`\n\n/** Calibri 11pt (en-GB), 8pt after each paragraph: the document defaults the exports share. */\nexport const DOC_DEFAULTS = `<w:docDefaults><w:rPrDefault><w:rPr><w:rFonts w:ascii=\"Calibri\" w:hAnsi=\"Calibri\" w:eastAsia=\"Calibri\" w:cs=\"Calibri\"/><w:sz w:val=\"22\"/><w:szCs w:val=\"22\"/><w:lang w:val=\"en-GB\"/></w:rPr></w:rPrDefault><w:pPrDefault><w:pPr><w:spacing w:after=\"160\" w:line=\"259\" w:lineRule=\"auto\"/></w:pPr></w:pPrDefault></w:docDefaults>`\n\n/**\n * Styles of a document that is a title and a table: `Title`, the compact `TagTableCell` paragraph\n * and the bordered `TagTableGrid` table.\n */\nexport const TABLE_DOCUMENT_STYLES = stylesXml(\n DOC_DEFAULTS,\n `<w:style w:type=\"paragraph\" w:default=\"1\" w:styleId=\"Normal\"><w:name w:val=\"Normal\"/><w:qFormat/></w:style><w:style w:type=\"paragraph\" w:styleId=\"Title\"><w:name w:val=\"Title\"/><w:basedOn w:val=\"Normal\"/><w:next w:val=\"Normal\"/><w:qFormat/><w:pPr><w:spacing w:after=\"80\" w:line=\"240\" w:lineRule=\"auto\"/></w:pPr><w:rPr><w:sz w:val=\"48\"/><w:szCs w:val=\"48\"/></w:rPr></w:style><w:style w:type=\"paragraph\" w:customStyle=\"1\" w:styleId=\"TagTableCell\"><w:name w:val=\"Tag Table Cell\"/><w:basedOn w:val=\"Normal\"/><w:qFormat/><w:pPr><w:spacing w:after=\"40\" w:line=\"240\" w:lineRule=\"auto\"/></w:pPr><w:rPr><w:sz w:val=\"18\"/><w:szCs w:val=\"18\"/></w:rPr></w:style><w:style w:type=\"table\" w:default=\"1\" w:styleId=\"TableNormal\"><w:name w:val=\"Normal Table\"/><w:tblPr><w:tblInd w:w=\"0\" w:type=\"dxa\"/><w:tblCellMar><w:top w:w=\"0\" w:type=\"dxa\"/><w:left w:w=\"108\" w:type=\"dxa\"/><w:bottom w:w=\"0\" w:type=\"dxa\"/><w:right w:w=\"108\" w:type=\"dxa\"/></w:tblCellMar></w:tblPr></w:style><w:style w:type=\"table\" w:customStyle=\"1\" w:styleId=\"TagTableGrid\"><w:name w:val=\"Tag Table\"/><w:basedOn w:val=\"TableNormal\"/><w:tblPr><w:tblBorders><w:top w:val=\"single\" w:sz=\"4\" w:space=\"0\" w:color=\"BFBFBF\"/><w:left w:val=\"single\" w:sz=\"4\" w:space=\"0\" w:color=\"BFBFBF\"/><w:bottom w:val=\"single\" w:sz=\"4\" w:space=\"0\" w:color=\"BFBFBF\"/><w:right w:val=\"single\" w:sz=\"4\" w:space=\"0\" w:color=\"BFBFBF\"/><w:insideH w:val=\"single\" w:sz=\"4\" w:space=\"0\" w:color=\"BFBFBF\"/><w:insideV w:val=\"single\" w:sz=\"4\" w:space=\"0\" w:color=\"BFBFBF\"/></w:tblBorders><w:tblCellMar><w:top w:w=\"60\" w:type=\"dxa\"/><w:left w:w=\"100\" w:type=\"dxa\"/><w:bottom w:w=\"60\" w:type=\"dxa\"/><w:right w:w=\"100\" w:type=\"dxa\"/></w:tblCellMar></w:tblPr></w:style>`\n)\n\nconst CONTENT_TYPES = `<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\"><Default Extension=\"rels\" ContentType=\"application/vnd.openxmlformats-package.relationships+xml\"/><Default Extension=\"xml\" ContentType=\"application/xml\"/><Override PartName=\"/word/document.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml\"/><Override PartName=\"/word/styles.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml\"/><Override PartName=\"/docProps/core.xml\" ContentType=\"application/vnd.openxmlformats-package.core-properties+xml\"/></Types>`\n\nconst ROOT_RELS = `<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\"><Relationship Id=\"rId1\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument\" Target=\"word/document.xml\"/><Relationship Id=\"rId2\" Type=\"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties\" Target=\"docProps/core.xml\"/></Relationships>`\n\n/** `word/_rels/document.xml.rels`: the styles part, then any further relationships given. */\nconst documentRels = (more = '') => `<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\"><Relationship Id=\"rId1\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles\" Target=\"styles.xml\"/>${more}</Relationships>`\n\n/** A relationship to an external hyperlink target, for `w:hyperlink r:id`. */\nexport const hyperlinkRelationship = (id: string, url: string) =>\n `<Relationship Id=\"${esc(id)}\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink\" Target=\"${esc(url)}\" TargetMode=\"External\"/>`\n\nconst coreXml = (\n title: string,\n at: string\n) => `<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<cp:coreProperties xmlns:cp=\"http://schemas.openxmlformats.org/package/2006/metadata/core-properties\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:dcterms=\"http://purl.org/dc/terms/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><dc:title>${esc(\n title\n)}</dc:title><dcterms:created xsi:type=\"dcterms:W3CDTF\">${at}</dcterms:created><dcterms:modified xsi:type=\"dcterms:W3CDTF\">${at}</dcterms:modified></cp:coreProperties>`\n\n/** The minimal `.docx` package: a document, its styles, and its title and time. */\nexport function docxPackage(parts: {\n document: string\n styles: string\n title: string\n /** ISO time; default now. */\n at?: string\n /** Further `word/document.xml` relationships (e.g. {@link hyperlinkRelationship}). */\n relationships?: string\n}): Uint8Array {\n const at = new Date(parts.at ?? Date.now()).toISOString().replace(/\\.\\d{3}Z$/, 'Z')\n return zipSync({\n '[Content_Types].xml': strToU8(CONTENT_TYPES),\n '_rels/.rels': strToU8(ROOT_RELS),\n 'docProps/core.xml': strToU8(coreXml(parts.title, at)),\n 'word/document.xml': strToU8(parts.document),\n 'word/styles.xml': strToU8(parts.styles),\n 'word/_rels/document.xml.rels': strToU8(documentRels(parts.relationships)),\n })\n}\n"]}