@embedpdf/viewer-chrome 3.0.0-next.13 → 3.0.0-next.15

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 (157) hide show
  1. package/README.md +175 -132
  2. package/dist/annotation-fonts-BqoLZ4Mp.js +80 -0
  3. package/dist/annotation-fonts-BqoLZ4Mp.js.map +1 -0
  4. package/dist/annotation-fonts-Dt0IQXhz.cjs +91 -0
  5. package/dist/annotation-fonts-Dt0IQXhz.cjs.map +1 -0
  6. package/dist/annotation-style--rPIZsuP.js +879 -0
  7. package/dist/annotation-style--rPIZsuP.js.map +1 -0
  8. package/dist/annotation-style-Bzvvp8-N.cjs +879 -0
  9. package/dist/annotation-style-Bzvvp8-N.cjs.map +1 -0
  10. package/dist/ar-D9XKAmDx.js +567 -0
  11. package/dist/ar-D9XKAmDx.js.map +1 -0
  12. package/dist/ar-DnEj5vbP.cjs +567 -0
  13. package/dist/ar-DnEj5vbP.cjs.map +1 -0
  14. package/dist/chrome.cjs +378 -221
  15. package/dist/chrome.cjs.map +1 -1
  16. package/dist/chrome.d.cts +5 -34
  17. package/dist/chrome.d.ts +5 -34
  18. package/dist/chrome.js +377 -218
  19. package/dist/chrome.js.map +1 -1
  20. package/dist/commands-BmgxhJ8B.js +953 -0
  21. package/dist/commands-BmgxhJ8B.js.map +1 -0
  22. package/dist/commands-CYt4SFUX.cjs +1060 -0
  23. package/dist/commands-CYt4SFUX.cjs.map +1 -0
  24. package/dist/commands.cjs +12 -595
  25. package/dist/commands.d.cts +29 -4
  26. package/dist/commands.d.ts +29 -4
  27. package/dist/commands.js +2 -593
  28. package/dist/comments-panel-MUVgLCBI.js +514 -0
  29. package/dist/comments-panel-MUVgLCBI.js.map +1 -0
  30. package/dist/comments-panel-pEcQg4Vs.cjs +514 -0
  31. package/dist/comments-panel-pEcQg4Vs.cjs.map +1 -0
  32. package/dist/de-Bdr4aWzm.js +566 -0
  33. package/dist/de-Bdr4aWzm.js.map +1 -0
  34. package/dist/de-Dv6zvbnd.cjs +566 -0
  35. package/dist/de-Dv6zvbnd.cjs.map +1 -0
  36. package/dist/dialog-B5GBisKv.js +55 -0
  37. package/dist/dialog-B5GBisKv.js.map +1 -0
  38. package/dist/dialog-t8F13BL_.cjs +60 -0
  39. package/dist/dialog-t8F13BL_.cjs.map +1 -0
  40. package/dist/es-BP09DR9w.cjs +566 -0
  41. package/dist/es-BP09DR9w.cjs.map +1 -0
  42. package/dist/es-BSXz5tBv.js +566 -0
  43. package/dist/es-BSXz5tBv.js.map +1 -0
  44. package/dist/form-design-panel-B5MXTZ96.cjs +418 -0
  45. package/dist/form-design-panel-B5MXTZ96.cjs.map +1 -0
  46. package/dist/form-design-panel-vWWU9uB-.js +418 -0
  47. package/dist/form-design-panel-vWWU9uB-.js.map +1 -0
  48. package/dist/fr-BBQQn7tJ.cjs +566 -0
  49. package/dist/fr-BBQQn7tJ.cjs.map +1 -0
  50. package/dist/fr-Ckn3K9v1.js +566 -0
  51. package/dist/fr-Ckn3K9v1.js.map +1 -0
  52. package/dist/he-DRsG7bH7.cjs +567 -0
  53. package/dist/he-DRsG7bH7.cjs.map +1 -0
  54. package/dist/he-wdGU5PkU.js +567 -0
  55. package/dist/he-wdGU5PkU.js.map +1 -0
  56. package/dist/icons-BrK5iVL8.js +856 -0
  57. package/dist/icons-BrK5iVL8.js.map +1 -0
  58. package/dist/icons-x0Tc05bs.cjs +1010 -0
  59. package/dist/icons-x0Tc05bs.cjs.map +1 -0
  60. package/dist/index.cjs +3162 -5106
  61. package/dist/index.cjs.map +1 -1
  62. package/dist/index.d.cts +636 -143
  63. package/dist/index.d.ts +636 -143
  64. package/dist/index.js +3083 -4975
  65. package/dist/index.js.map +1 -1
  66. package/dist/it-BuP4o0xQ.cjs +566 -0
  67. package/dist/it-BuP4o0xQ.cjs.map +1 -0
  68. package/dist/it-Us-VmvIu.js +566 -0
  69. package/dist/it-Us-VmvIu.js.map +1 -0
  70. package/dist/ja-Cizj0-5O.js +566 -0
  71. package/dist/ja-Cizj0-5O.js.map +1 -0
  72. package/dist/ja-DovEd6ts.cjs +566 -0
  73. package/dist/ja-DovEd6ts.cjs.map +1 -0
  74. package/dist/ko-B-qJEol2.cjs +566 -0
  75. package/dist/ko-B-qJEol2.cjs.map +1 -0
  76. package/dist/ko-DlrXliE1.js +566 -0
  77. package/dist/ko-DlrXliE1.js.map +1 -0
  78. package/dist/labels-BiM9wp9K.cjs +21 -0
  79. package/dist/labels-BiM9wp9K.cjs.map +1 -0
  80. package/dist/labels-C6_i87Oj.js +16 -0
  81. package/dist/labels-C6_i87Oj.js.map +1 -0
  82. package/dist/link-editor-CSjqPnj1.cjs +125 -0
  83. package/dist/link-editor-CSjqPnj1.cjs.map +1 -0
  84. package/dist/link-editor-SxM1nnJU.js +125 -0
  85. package/dist/link-editor-SxM1nnJU.js.map +1 -0
  86. package/dist/measurement-Bs61XWbJ.js +325 -0
  87. package/dist/measurement-Bs61XWbJ.js.map +1 -0
  88. package/dist/measurement-CcCsHPOX.cjs +326 -0
  89. package/dist/measurement-CcCsHPOX.cjs.map +1 -0
  90. package/dist/nl-0aF7M_0h.js +566 -0
  91. package/dist/nl-0aF7M_0h.js.map +1 -0
  92. package/dist/nl-D3KZDDiJ.cjs +566 -0
  93. package/dist/nl-D3KZDDiJ.cjs.map +1 -0
  94. package/dist/pl-BW--AaCI.js +566 -0
  95. package/dist/pl-BW--AaCI.js.map +1 -0
  96. package/dist/pl-DSFhAUqx.cjs +566 -0
  97. package/dist/pl-DSFhAUqx.cjs.map +1 -0
  98. package/dist/pt-C5S-8MC5.cjs +566 -0
  99. package/dist/pt-C5S-8MC5.cjs.map +1 -0
  100. package/dist/pt-DIhpU5pT.js +566 -0
  101. package/dist/pt-DIhpU5pT.js.map +1 -0
  102. package/dist/redact-confirm-B6j36TPw.js +83 -0
  103. package/dist/redact-confirm-B6j36TPw.js.map +1 -0
  104. package/dist/redact-confirm-CX_SY2ZN.cjs +83 -0
  105. package/dist/redact-confirm-CX_SY2ZN.cjs.map +1 -0
  106. package/dist/redaction-panel-BmoIl-Ll.cjs +96 -0
  107. package/dist/redaction-panel-BmoIl-Ll.cjs.map +1 -0
  108. package/dist/redaction-panel-IJDshSJI.js +96 -0
  109. package/dist/redaction-panel-IJDshSJI.js.map +1 -0
  110. package/dist/search-panel-HfIhJm1M.js +249 -0
  111. package/dist/search-panel-HfIhJm1M.js.map +1 -0
  112. package/dist/search-panel-s9IoiOtv.cjs +249 -0
  113. package/dist/search-panel-s9IoiOtv.cjs.map +1 -0
  114. package/dist/sheet-BDsa_Sup.cjs +442 -0
  115. package/dist/sheet-BDsa_Sup.cjs.map +1 -0
  116. package/dist/sheet-R6XDgyEf.js +365 -0
  117. package/dist/sheet-R6XDgyEf.js.map +1 -0
  118. package/dist/sign-dialog-CgnR7akj.cjs +155 -0
  119. package/dist/sign-dialog-CgnR7akj.cjs.map +1 -0
  120. package/dist/sign-dialog-GDqCoQhA.js +155 -0
  121. package/dist/sign-dialog-GDqCoQhA.js.map +1 -0
  122. package/dist/signature-inspector-DyO313Qf.cjs +166 -0
  123. package/dist/signature-inspector-DyO313Qf.cjs.map +1 -0
  124. package/dist/signature-inspector-okFz8do6.js +166 -0
  125. package/dist/signature-inspector-okFz8do6.js.map +1 -0
  126. package/dist/signature-maker-BhCmYyHD.js +393 -0
  127. package/dist/signature-maker-BhCmYyHD.js.map +1 -0
  128. package/dist/signature-maker-BoYa8vgA.cjs +393 -0
  129. package/dist/signature-maker-BoYa8vgA.cjs.map +1 -0
  130. package/dist/signatures-panel-B56PC6d9.cjs +300 -0
  131. package/dist/signatures-panel-B56PC6d9.cjs.map +1 -0
  132. package/dist/signatures-panel-CgnFfhFm.js +300 -0
  133. package/dist/signatures-panel-CgnFfhFm.js.map +1 -0
  134. package/dist/stamp-store-BHvRs-Do.cjs +147 -0
  135. package/dist/stamp-store-BHvRs-Do.cjs.map +1 -0
  136. package/dist/stamp-store-WuF-L3Jj.js +112 -0
  137. package/dist/stamp-store-WuF-L3Jj.js.map +1 -0
  138. package/dist/stamps-panel-B9NYGayn.cjs +231 -0
  139. package/dist/stamps-panel-B9NYGayn.cjs.map +1 -0
  140. package/dist/stamps-panel-CDO0FPyK.js +231 -0
  141. package/dist/stamps-panel-CDO0FPyK.js.map +1 -0
  142. package/dist/toolbar-CJu2wKTU.cjs +1659 -0
  143. package/dist/toolbar-CJu2wKTU.cjs.map +1 -0
  144. package/dist/toolbar-z9od3tKl.js +1564 -0
  145. package/dist/toolbar-z9od3tKl.js.map +1 -0
  146. package/dist/zh-cn-3tmMeHqv.cjs +566 -0
  147. package/dist/zh-cn-3tmMeHqv.cjs.map +1 -0
  148. package/dist/zh-cn-CxkUUBct.js +566 -0
  149. package/dist/zh-cn-CxkUUBct.js.map +1 -0
  150. package/package.json +6 -4
  151. package/src/styles.css +153 -89
  152. package/dist/commands.cjs.map +0 -1
  153. package/dist/commands.js.map +0 -1
  154. package/dist/es-DYwzfxyt.cjs +0 -293
  155. package/dist/es-DYwzfxyt.cjs.map +0 -1
  156. package/dist/es-sN6uqBgD.js +0 -293
  157. package/dist/es-sN6uqBgD.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toolbar-CJu2wKTU.cjs","names":["StageToken","Icon","StageToken","useStampSettings","InteractionToken","quickStampAssetIdOf","DEFAULT_LIBRARY_ID","ensureDefaultLibrary","resolveStampsLocale","AnnotationToken","SignatureToken","FormToken","PageEditToken","RedactionToken","Icon","useLayoutEnv","useLayoutEnv","Sheet","Icon","ShellToken","useMenu","Icon","TOOLBAR_ITEM_ATTRIBUTE","ShellToken","StageToken","VIEW_MODE_COMMAND","Toolbar"],"sources":["../src/features.ts","../src/ui/bar-edge.tsx","../src/ui/measurement-scale.tsx","../src/ui/page-number.tsx","../src/ui/quick-stamps.tsx","../src/ui/view-only.tsx","../src/ui/item-context.ts","../src/ui/slotted-edges.ts","../src/ui/item-socket.tsx","../src/ui/menu-placement.ts","../src/ui/menu.tsx","../src/ui/toolbar.tsx"],"sourcesContent":["/**\n * The viewer's features, and what `disable` and `readOnly` turn off.\n *\n * A feature is a command category: `annotations`, or one of its parts, `annotations.highlight`.\n * Turning a feature off turns off everything under it (the commands plugin matches whole dotted\n * segments). `disable` lists features and single commands in one list, told apart by the colon\n * every command id has; `readOnly` adds the features that change the document. A feature that's\n * off also stops people changing by hand what it made: the annotations and fields already in the\n * document (the annotation plugin's `editable` and the form plugin's `fillable` settings).\n */\nimport type { EditableKind, EditableKinds } from '@embedpdf/react/annotation';\nimport type { FillableFields, FormFieldFamily } from '@embedpdf/react/form';\n\n/** Every built-in feature and its parts: the names `disable` takes, as All features lists them. */\nexport const FEATURE_PARTS = {\n annotations: ['highlight', 'markup', 'drawing', 'text', 'notes', 'links'],\n shapes: [],\n stamps: [],\n comments: ['writing'],\n forms: ['filling', 'building'],\n signatures: ['signing', 'checking'],\n redaction: [],\n measurement: [],\n pages: [],\n attachments: ['adding'],\n text: ['selection', 'copy'],\n search: [],\n thumbnails: [],\n outline: [],\n documents: ['open', 'download', 'print', 'tabs'],\n} as const;\n\ntype FeatureParts = typeof FEATURE_PARTS;\n\n/** A built-in feature, or a part of one: `'annotations'`, `'annotations.highlight'`. */\nexport type Feature = {\n [Name in keyof FeatureParts]: Name | `${Name}.${FeatureParts[Name][number]}`;\n}[keyof FeatureParts];\n\n/** What `readOnly` keeps on: every feature it would turn off, minus these. */\nexport interface ReadOnlyExceptions {\n readonly except: readonly (Feature | (string & {}))[];\n}\n\n/** The features that change the document: what `readOnly` turns off. */\nexport const READ_ONLY_FEATURES: readonly Feature[] = [\n 'annotations',\n 'shapes',\n 'stamps',\n 'comments.writing',\n 'forms',\n 'signatures.signing',\n 'redaction',\n 'measurement',\n 'pages',\n 'attachments.adding',\n];\n\nconst isInside = (feature: string, outer: string): boolean =>\n feature === outer || feature.startsWith(`${outer}.`);\n\n/**\n * Whether nothing that changes the document is left, `isOff` saying which features are off (the\n * commands plugin's `isCategoryDisabled`): what the View only label shows for.\n */\nexport const leavesNothingToChange = (isOff: (feature: string) => boolean): boolean =>\n READ_ONLY_FEATURES.every(isOff);\n\n/**\n * The annotations each feature makes, by the names the annotation plugin's `editable` setting\n * takes: a subtype, or a measurement's intent. Every subtype people can change is here; a popup\n * or an unsupported annotation is never changed by hand. A signature placed off a field is a\n * stamp; one drawn into a field is the field's value.\n */\nconst FEATURE_ANNOTATIONS: Readonly<Record<string, readonly EditableKind[]>> = {\n 'annotations.highlight': ['highlight'],\n 'annotations.markup': ['underline', 'strikeout', 'squiggly'],\n 'annotations.drawing': ['ink'],\n 'annotations.text': ['free-text', 'caret'],\n 'annotations.notes': ['text'],\n 'annotations.links': ['link'],\n shapes: ['square', 'circle', 'line', 'polygon', 'polyline'],\n stamps: ['stamp'],\n redaction: ['redact'],\n measurement: ['line-dimension', 'polyline-dimension', 'polygon-dimension'],\n 'attachments.adding': ['file-attachment'],\n // A field's boxes, moved and resized in the Form mode.\n 'forms.building': ['widget'],\n};\n\n/** The fields each feature fills in, by the families the form plugin's `fillable` setting takes. */\nconst FEATURE_FIELDS: Readonly<Record<string, readonly FormFieldFamily[]>> = {\n 'forms.filling': ['text', 'checkbox', 'radio', 'combobox', 'listbox', 'pushbutton'],\n 'signatures.signing': ['signature'],\n};\n\n/** `true` while no feature of `table` is off, `false` once every one is, else what the ones on hold. */\nfunction stillOn<Name>(\n table: Readonly<Record<string, readonly Name[]>>,\n off: readonly string[],\n): boolean | Name[] {\n const features = Object.keys(table);\n const on = features.filter((feature) => !off.some((name) => isInside(feature, name)));\n if (on.length === features.length) return true;\n if (on.length === 0) return false;\n return on.flatMap((feature) => table[feature]!);\n}\n\nconst partsOf = (feature: string): readonly string[] =>\n (FEATURE_PARTS as Readonly<Record<string, readonly string[]>>)[feature] ?? [];\n\n/**\n * The features `readOnly` turns off, minus `except`. An exception inside a feature splits it\n * into its parts, so `except: ['forms.filling']` leaves `forms.building` off.\n */\nfunction readOnlyFeaturesOf(readOnly: boolean | ReadOnlyExceptions | undefined): string[] {\n if (!readOnly) return [];\n const except = readOnly === true ? [] : readOnly.except;\n const off: string[] = [];\n const subtract = (feature: string): void => {\n if (except.some((kept) => isInside(feature, kept))) return;\n const parts = partsOf(feature);\n if (parts.length === 0 || !except.some((kept) => isInside(kept, feature))) {\n off.push(feature);\n return;\n }\n for (const part of parts) subtract(`${feature}.${part}`);\n };\n for (const feature of READ_ONLY_FEATURES) subtract(feature);\n return off;\n}\n\n/** The features `disable` and `readOnly` turn off: the names without a colon, and `readOnly`'s. */\nfunction featuresOffOf(\n disable: readonly string[] | undefined,\n readOnly: boolean | ReadOnlyExceptions | undefined,\n): string[] {\n const features = (disable ?? []).filter((name) => !name.includes(':'));\n return [...new Set([...features, ...readOnlyFeaturesOf(readOnly)])];\n}\n\n/** What the commands plugin turns off: its `disabledCategories` and `disabledCommands` settings. */\nexport interface DisabledSettings {\n readonly disabledCategories: readonly string[];\n readonly disabledCommands: readonly string[];\n}\n\n/**\n * The commands plugin's settings for a `disable` list and a `readOnly` value: the names with a\n * colon are command ids, the rest features, and `readOnly` adds its own features.\n */\nexport function disabledSettingsOf(\n disable: readonly string[] | undefined,\n readOnly: boolean | ReadOnlyExceptions | undefined,\n): DisabledSettings {\n const commands = new Set((disable ?? []).filter((name) => name.includes(':')));\n return { disabledCategories: featuresOffOf(disable, readOnly), disabledCommands: [...commands] };\n}\n\n/** What people may change by hand: the annotation plugin's `editable` and the form plugin's `fillable`. */\nexport interface ByHandSettings {\n readonly editable: EditableKinds;\n readonly fillable: FillableFields;\n}\n\n/**\n * What people may still change by hand for a `disable` list and a `readOnly` value: the\n * annotations and fields of the features left on. A single command turned off leaves them.\n */\nexport function byHandSettingsOf(\n disable: readonly string[] | undefined,\n readOnly: boolean | ReadOnlyExceptions | undefined,\n): ByHandSettings {\n const off = featuresOffOf(disable, readOnly);\n return { editable: stillOn(FEATURE_ANNOTATIONS, off), fillable: stillOn(FEATURE_FIELDS, off) };\n}\n\n/**\n * What two `editable` or `fillable` values both allow: `true` is everything, `false` nothing,\n * and a list its names, in the order of `left`. The viewer's own value and the app's setting\n * meet here, so each can only take away.\n */\nexport function bothAllow<Name extends string>(\n left: boolean | readonly Name[],\n right: boolean | readonly Name[],\n): boolean | readonly Name[] {\n if (left === true) return right;\n if (right === true) return left;\n if (left === false || right === false) return false;\n return left.filter((name) => right.includes(name));\n}\n\n/** Whether two `editable` or `fillable` values say the same. */\nexport const sameByHand = (\n left: boolean | readonly string[],\n right: boolean | readonly string[],\n): boolean =>\n typeof left === 'boolean' || typeof right === 'boolean'\n ? left === right\n : left.length === right.length && left.every((name, index) => name === right[index]);\n","/**\n * Where a bar is, for what opens from it. The shell wraps each bar it draws in\n * a `BarEdgeProvider` naming the viewer edge the bar sits on; a menu (and the\n * toolbar's own \"More\") reads it with `useBarEdge()` and opens away from that\n * edge: a bottom bar's menus open upward, a start bar's to the side, a\n * floating bar's toward the middle of the viewer.\n *\n * A floating bar names the half of the viewer it floats in (`float-top`,\n * `float-bottom`), since its menus open toward the other half; a bar over a\n * selection says `selection`, and its menus open on the side the bar sits,\n * above or below what's selected, away from it. Outside any provider the edge\n * is `'top'`, the main bar's.\n */\nimport { createContext, useContext } from 'react';\n\n/** The viewer edge a bar sits on; a floating bar names the half it floats in. */\nexport type BarEdge =\n | 'top'\n | 'bottom'\n | 'start'\n | 'end'\n | 'float-top'\n | 'float-bottom'\n | 'selection';\n\nexport const BarEdgeContext = createContext<BarEdge>('top');\n\n/** Names the edge of the bar drawn inside it. */\nexport const BarEdgeProvider = BarEdgeContext.Provider;\n\n/** The edge of the bar this component is drawn in (`'top'` outside any bar). */\nexport function useBarEdge(): BarEdge {\n return useContext(BarEdgeContext);\n}\n","/**\n * The Measure bar's scale button: the current page's drawing scale, which opens the measurement\n * panel. Apart from the panel and the calibration dialog (measurement.tsx), so the bar draws it\n * without loading them.\n */\nimport { useT } from '@embedpdf/react/i18n';\nimport { usePageScale } from '@embedpdf/react/measurement';\nimport { useSelector } from '@embedpdf/react/runtime';\nimport { useSurface } from '@embedpdf/react/shell';\nimport { StageToken } from '@embedpdf/react/stage';\n\nimport { Icon } from './icons';\n\nconst button =\n 'border-border text-fg hover:bg-hover rounded-md border px-3 py-1.5 text-sm disabled:opacity-50';\n\nexport function MeasurementScaleButton() {\n const t = useT();\n\n const page = useSelector(StageToken, (stage) => stage.getCurrentPage());\n const scale = usePageScale(page);\n\n const surface = useSurface('measurement');\n return (\n <button\n part=\"toolbar-button\"\n className={`${button} inline-flex items-center gap-1.5 whitespace-nowrap`}\n onClick={() => surface.open()}\n title={t('measurement.title')}\n >\n <Icon name=\"updateScale\" size={20} className=\"shrink-0\" />\n <span>\n {t('measurement.scale')}:{' '}\n {scale?.measure?.subtype === 'rectilinear'\n ? (scale.measure.ratio ?? t('measurement.custom'))\n : t('measurement.unavailable')}\n </span>\n </button>\n );\n}\n","/**\n * The page number and the page count: the `{ custom: 'page-number' }` item, in the `pager` bar\n * floating over the pages by default. The number is a button; pressing it turns it into a field,\n * where Enter goes to the page typed and Escape, or leaving the field, keeps the page. Without a\n * document it draws nothing.\n */\nimport { useT } from '@embedpdf/react/i18n';\nimport { useOptionalCapability } from '@embedpdf/react/runtime';\nimport { StageToken, useStageState } from '@embedpdf/react/stage';\nimport { useEffect, useRef, useState } from 'react';\n\n/**\n * Stands in for the number while the sentence around it is translated, so it can split there:\n * a private-use character no language writes, spelled as an escape so no tool drops it.\n */\nexport const NUMBER_SLOT = '\\uE000';\n\nexport function PageNumber() {\n const t = useT();\n const stage = useOptionalCapability(StageToken);\n // The Stage cursor is a 0-based display index; people count from 1.\n const current = useStageState((state) => state.currentPageIndex + 1);\n const total = useStageState((state) => state.pageCount);\n /** What the field holds while it is open, or `null` while the number shows. */\n const [draft, setDraft] = useState<string | null>(null);\n const field = useRef<HTMLInputElement>(null);\n const button = useRef<HTMLButtonElement>(null);\n /** Whether the field closed from the keyboard, so focus goes back to the number. */\n const refocus = useRef(false);\n const editing = draft !== null;\n\n useEffect(() => {\n if (editing) {\n field.current?.focus();\n field.current?.select();\n } else if (refocus.current) {\n refocus.current = false;\n button.current?.focus();\n }\n }, [editing]);\n\n if (!total) return null;\n\n /** Closes the field from the keyboard: focus goes back to the number. */\n const close = () => {\n refocus.current = true;\n setDraft(null);\n };\n const go = () => {\n const page = Number.parseInt(draft ?? '', 10);\n if (Number.isFinite(page)) stage?.goToPage(Math.min(Math.max(page, 1), total) - 1);\n close();\n };\n const [before, after = ''] = t('demo.page', {\n params: { current: NUMBER_SLOT, total },\n }).split(NUMBER_SLOT);\n\n return (\n <span className=\"text-fg-secondary block whitespace-nowrap px-3.5 text-sm leading-7\">\n {before}\n {editing ? (\n <input\n ref={field}\n type=\"text\"\n inputMode=\"numeric\"\n aria-label={t('demo.goToPage')}\n value={draft}\n onChange={(event) => setDraft(event.target.value.replace(/[^0-9]/g, ''))}\n onKeyDown={(event) => {\n if (event.key === 'Enter') {\n event.preventDefault();\n go();\n } else if (event.key === 'Escape') {\n event.preventDefault();\n close();\n }\n }}\n // Leaving the field keeps the page; removing the field after Enter or Escape blurs it\n // too, and must not cancel the focus going back to the number.\n onBlur={() => setDraft(null)}\n // Room for the longest number, and one more digit's worth for the caret.\n style={{ width: `${String(total).length + 1}ch` }}\n className=\"bg-hover ring-accent text-fg rounded text-center tabular-nums outline-none ring-1\"\n />\n ) : (\n <button\n ref={button}\n type=\"button\"\n title={t('demo.goToPage')}\n onClick={() => setDraft(String(current))}\n className=\"hover:bg-hover hover:text-fg -mx-0.5 cursor-pointer rounded px-0.5 tabular-nums\"\n >\n {current}\n </button>\n )}\n {after}\n </span>\n );\n}\n","/**\n * Quick marks in the toolbar: a row of stamp thumbnails that arm on click —\n * the checkmark, the cross, whatever the embedder configured\n * (`plugins.stamp.quick`: `library:name`, `standard` for the standard stamps). The hover ghost and\n * the click placement are the annotation plugin's, exactly as from the\n * sidebar; only the picker moved. Renders nothing until the assets exist.\n * Lives in the workspace toolbar, so it reads the active document's tool.\n */\nimport { useEffect } from 'react';\nimport { InteractionToken } from '@embedpdf/react/interaction';\nimport { useI18nState, useT } from '@embedpdf/react/i18n';\nimport { useDocumentId, useOptionalSelector } from '@embedpdf/react/runtime';\nimport {\n useStamp,\n useStampAssetPreviewUrl,\n useStampAssets,\n useStampState,\n type StampAsset,\n} from '@embedpdf/react/stamp';\nimport { useStampSettings } from '../config-context';\nimport {\n DEFAULT_LIBRARY_ID,\n ensureDefaultLibrary,\n quickStampAssetIdOf,\n resolveStampsLocale,\n} from '../config/default-stamps';\nimport { restoreStampLibrariesOnce } from './stamp-store';\nimport { buttonClass, buttonPart } from './toolbar';\n\nexport function QuickStamps() {\n const t = useT();\n const stamp = useStamp();\n const { standard, quick } = useStampSettings();\n const { locale } = useI18nState();\n const assets = useStampAssets();\n const documentId = useDocumentId();\n const activeToolId = useOptionalSelector(\n InteractionToken,\n (interaction) => interaction.getActiveToolId(),\n null,\n );\n const armedId = useStampState((state) => state.armedAsset?.id ?? null);\n const ids = (quick ?? []).map(quickStampAssetIdOf);\n\n // A quick mark from the built-in library needs that library loaded — the\n // one case the toolbar pays for it at boot. The user's own libraries are\n // restored by the workspace store.\n const wantsDefault = ids.some((id) => id.startsWith(`${DEFAULT_LIBRARY_ID}:`));\n useEffect(() => {\n if (!wantsDefault) return;\n restoreStampLibrariesOnce(stamp)\n .then(() => ensureDefaultLibrary(stamp, resolveStampsLocale(locale), standard))\n .catch((error) => console.error('[embedpdf] quick stamps failed:', error));\n // `standard` is read once; only the locale re-runs this.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [stamp, locale, wantsDefault]);\n\n const shown = ids\n .map((id) => assets.find((asset) => asset.id === id))\n .filter((asset): asset is StampAsset => !!asset);\n if (shown.length === 0 || !documentId) return null;\n return (\n <div className=\"flex items-center gap-1\" role=\"group\" aria-label={t('demo.quickStampsLabel')}>\n {shown.map((asset) => (\n <QuickStampButton\n key={asset.id}\n asset={asset}\n active={activeToolId === 'stamp' && armedId === asset.id}\n onArm={() =>\n void stamp\n .armAsset(asset.id)\n .catch((error) => console.error('[embedpdf] arm failed', error))\n }\n />\n ))}\n </div>\n );\n}\n\nfunction QuickStampButton({\n asset,\n active,\n onArm,\n}: {\n asset: StampAsset;\n active: boolean;\n onArm: () => void;\n}) {\n const url = useStampAssetPreviewUrl(asset.id);\n return (\n <button\n type=\"button\"\n onClick={onArm}\n title={asset.label}\n aria-label={asset.label}\n aria-pressed={active || undefined}\n part={buttonPart(active)}\n className={buttonClass(active, true)}\n >\n {url ? (\n <img src={url} alt=\"\" className=\"h-5 w-5 object-contain\" draggable={false} />\n ) : (\n <span className=\"text-xs\">{asset.label}</span>\n )}\n </button>\n );\n}\n","/**\n * The View only label: the `{ custom: 'view-only' }` item, in the main bar by default. It says why\n * the tools are gone, while nothing that changes the document is on (`readOnly`, or `disable`\n * naming every such feature), or while the scope lets this user change nothing in the open\n * document. Otherwise it draws nothing.\n */\nimport { useOptionalCapability, useOptionalSelector } from '@embedpdf/react/runtime';\nimport { AnnotationToken, type AnnotationCapability } from '@embedpdf/react/annotation';\nimport { useCommands, useCommandsSettings } from '@embedpdf/react/commands';\nimport { FormToken, type FormCapability } from '@embedpdf/react/form';\nimport { PageEditToken } from '@embedpdf/react/page-edit';\nimport { RedactionToken } from '@embedpdf/react/redaction';\nimport { SignatureToken, type SignatureCapability } from '@embedpdf/react/signature';\nimport { useT } from '@embedpdf/react/i18n';\n\nimport { leavesNothingToChange } from '../features';\nimport { Icon } from './icons';\n\n/** Whether the scope lets this user change an annotation: make one, or change or delete one there. */\nfunction mayChangeAnnotations(annotation: AnnotationCapability): boolean {\n if (annotation.canCreate()) return true;\n return annotation\n .list()\n .some(({ ref }) => annotation.canUpdate(ref) || annotation.canDelete(ref));\n}\n\n/** Whether the scope lets this user change the form: its fields, a value, or a signature. */\nfunction mayChangeForm(form: FormCapability, signature: SignatureCapability | null): boolean {\n if (form.canDesign()) return true;\n return form\n .list()\n .some((field) =>\n field.family === 'signature'\n ? (signature?.canSign(field.ref) ?? false)\n : form.canFill(field.ref),\n );\n}\n\n/**\n * Whether the scope lets this user change nothing in the open document: no annotation to make,\n * change or delete (comments included), no field to fill in, sign or design, no page to edit and\n * no redaction to apply. Asked of the plugins' `can*` twins; `false` while no document is open.\n */\nfunction useNothingAllowed(): boolean {\n const open = useOptionalCapability(AnnotationToken) !== null;\n const signature = useOptionalCapability(SignatureToken);\n const annotates = useOptionalSelector(AnnotationToken, mayChangeAnnotations, false);\n const fills = useOptionalSelector(FormToken, (form) => mayChangeForm(form, signature), false);\n const editsPages = useOptionalSelector(PageEditToken, (pageEdit) => pageEdit.canEdit(), false);\n const redacts = useOptionalSelector(RedactionToken, (redaction) => redaction.canApply(), false);\n return open && !annotates && !fills && !editsPages && !redacts;\n}\n\n/**\n * The label; `compact` draws its icon alone (a narrow bar, or a vertical one), its words still\n * there for a screen reader. Plain text, not a live region: it says what the viewer is, and the\n * refusal notice stays the viewer's one status message. Its tooltip says why.\n */\nexport function ViewOnlyLabel({ compact = false }: { compact?: boolean }) {\n const t = useT();\n const commands = useCommands();\n // Read again whenever what's turned off changes.\n useCommandsSettings((settings) => settings.disabledCategories);\n const turnedOff = leavesNothingToChange((feature) => commands.isCategoryDisabled(feature));\n const nothingAllowed = useNothingAllowed();\n if (!turnedOff && !nothingAllowed) return null;\n return (\n <span\n title={t(turnedOff ? 'viewOnly.turnedOff' : 'viewOnly.notAllowed')}\n className=\"bg-hover text-fg-secondary flex h-7 shrink-0 select-none items-center gap-1.5 whitespace-nowrap rounded-full px-2.5 text-xs font-medium\"\n >\n <Icon name=\"eye\" size={16} className=\"shrink-0\" />\n <span className={compact ? 'sr-only' : undefined}>{t('viewOnly.label')}</span>\n </span>\n );\n}\n","/**\n * Where your own toolbar item sits, as the viewer tells it: which way its bar\n * runs, the bar's place, the variant the toolbar picked, and the viewer's\n * size. The viewer writes it on the element you slot in, as `data-orientation`,\n * `data-edge`, `data-variant` and `data-size`, and keeps it there while the\n * bar moves and the viewer resizes; page CSS reads those, and so do the\n * framework wrappers (`useToolbarItem()`).\n */\nimport type { ViewerSize } from '@embedpdf/core-ui';\n\nimport type { BarEdge } from './bar-edge';\n\n/** The place of the bar an item sits in: an edge, floating over the pages, or over a selection. */\nexport type ToolbarItemEdge = 'top' | 'bottom' | 'start' | 'end' | 'float' | 'selection';\n\n/** Where your own toolbar item sits. */\nexport interface ToolbarItemContext {\n /** Which way the bar runs. */\n readonly orientation: 'horizontal' | 'vertical';\n /** The bar's place. */\n readonly edge: ToolbarItemEdge;\n /** Which of the item's `variants` the toolbar picked, or null for an item without its own. */\n readonly variant: string | null;\n /** The viewer's size. */\n readonly size: ViewerSize;\n}\n\n/** The attribute each field of a {@link ToolbarItemContext} is written to. */\nexport const TOOLBAR_ITEM_CONTEXT_ATTRIBUTES = {\n orientation: 'data-orientation',\n edge: 'data-edge',\n variant: 'data-variant',\n size: 'data-size',\n} as const satisfies Record<keyof ToolbarItemContext, string>;\n\n/** The public place of a bar on `edge`: a floating bar is `float`, whichever half it floats in. */\nexport const toolbarItemEdgeOf = (edge: BarEdge): ToolbarItemEdge =>\n edge === 'float-top' || edge === 'float-bottom' ? 'float' : edge;\n\n/** Write `context` on `element`, changing only the attributes that differ. */\nexport function writeToolbarItemContext(element: Element, context: ToolbarItemContext): void {\n for (const [field, attribute] of Object.entries(TOOLBAR_ITEM_CONTEXT_ATTRIBUTES)) {\n const value = context[field as keyof ToolbarItemContext];\n if (value === null) element.removeAttribute(attribute);\n else if (element.getAttribute(attribute) !== value) element.setAttribute(attribute, value);\n }\n}\n","/**\n * The edge of the bar each slotted toolbar item is in, by the element slotted\n * there, for the viewer's own components inside it: they're drawn apart from\n * the bar (`placed-components.tsx`), and a menu among them opens away from\n * the bar's edge like the bar's own. The item sockets write it\n * (`item-socket.tsx`); outside any item, a component opens its menus like the\n * main bar's.\n */\nimport { createContext, useContext } from 'react';\n\nimport type { BarEdge } from './bar-edge';\n\nexport interface SlottedEdges {\n /** Says `element` is slotted into an item of a bar on `edge`. */\n set(element: Element, edge: BarEdge): void;\n /** The edge of the item `element` is in: its own, or its nearest ancestor's; else `'top'`. */\n edgeOf(element: Element): BarEdge;\n /** Calls `listener` when an edge changes. */\n subscribe(listener: () => void): () => void;\n /** A number that changes with every edge that changes. */\n version(): number;\n}\n\n/** The element `node` is a child of: its parent, or the host of the shadow root it is in. */\nconst parentOf = (node: Element): Element | null =>\n node.parentElement ?? (node.getRootNode() as Partial<ShadowRoot>).host ?? null;\n\nexport function createSlottedEdges(): SlottedEdges {\n const edges = new WeakMap<Element, BarEdge>();\n const listeners = new Set<() => void>();\n let version = 0;\n return {\n set(element, edge) {\n if (edges.get(element) === edge) return;\n edges.set(element, edge);\n version += 1;\n for (const listener of [...listeners]) listener();\n },\n edgeOf(element) {\n for (let node: Element | null = element; node; node = parentOf(node)) {\n const edge = edges.get(node);\n if (edge) return edge;\n }\n return 'top';\n },\n subscribe(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n version: () => version,\n };\n}\n\nconst SlottedEdgesContext = createContext<SlottedEdges>(createSlottedEdges());\n\n/** Gives the item sockets and the viewer's own components inside it one {@link SlottedEdges}. */\nexport const SlottedEdgesProvider = SlottedEdgesContext.Provider;\n\nexport function useSlottedEdges(): SlottedEdges {\n return useContext(SlottedEdgesContext);\n}\n","/**\n * Your own toolbar item, in its bar: a `<slot name=\"item:<id>\">` the browser\n * shows your element in, with what the item stands for when nothing is\n * slotted (its command's button). What's slotted lives in the page, so the\n * socket is measured where it renders; the toolbar's measurement layer can't\n * hold it. It tells what's slotted where it sits (`item-context.ts`), and the\n * viewer's own components inside it learn the bar's edge from it, so their\n * menus open away from the bar.\n */\nimport { useLayoutEffect, useRef, type ReactNode } from 'react';\n\nimport { useLayoutEnv } from '../config-context';\nimport { useBarEdge } from './bar-edge';\nimport { toolbarItemEdgeOf, writeToolbarItemContext } from './item-context';\nimport { useSlottedEdges } from './slotted-edges';\n\n/** The socket's box: a row of what's slotted, at its own size along the bar. */\nconst SOCKET_STYLE = { display: 'inline-flex', alignItems: 'center', flexShrink: 0 } as const;\n\nexport function ItemSocket({\n id,\n variant,\n orientation,\n measure,\n children,\n}: {\n /** The item's id: `{ custom: id }` in the layout. */\n id: string;\n /** The variant the toolbar picked, or null for an item without variants of its own. */\n variant: string | null;\n orientation: 'horizontal' | 'vertical';\n /** Reports the socket's length along the bar. */\n measure: (length: number) => void;\n /** What shows while nothing is slotted. */\n children?: ReactNode;\n}) {\n const slot = useRef<HTMLSlotElement>(null);\n const edge = useBarEdge();\n const { size } = useLayoutEnv();\n const edges = useSlottedEdges();\n const report = useRef(measure);\n report.current = measure;\n\n // A child slotted in or out resizes the socket's box, so one observer covers both.\n const resizes = useRef<ResizeObserver | null>(null);\n const hasVariants = variant !== null;\n useLayoutEffect(() => {\n const element = slot.current;\n if (!element) return;\n const side = orientation === 'vertical' ? 'height' : 'width';\n const measureNow = () => report.current(element.getBoundingClientRect()[side]);\n // Measured before the first paint, unless what's slotted is about to draw its variant.\n if (!hasVariants) measureNow();\n const observer = new ResizeObserver(measureNow);\n observer.observe(element);\n resizes.current = observer;\n return () => {\n observer.disconnect();\n resizes.current = null;\n };\n }, [orientation, hasVariants]);\n // At another variant, what's slotted draws itself again first: its length is taken once the\n // browser has laid that out (an observer's first call), and counts for the new variant.\n useLayoutEffect(() => {\n const element = slot.current;\n const observer = resizes.current;\n if (!element || !observer) return;\n observer.unobserve(element);\n observer.observe(element);\n }, [variant]);\n\n useLayoutEffect(() => {\n const element = slot.current;\n if (!element) return;\n const context = { orientation, edge: toolbarItemEdgeOf(edge), variant, size };\n const tell = () => {\n for (const slotted of element.assignedElements()) {\n writeToolbarItemContext(slotted, context);\n edges.set(slotted, edge);\n }\n };\n tell();\n element.addEventListener('slotchange', tell);\n return () => element.removeEventListener('slotchange', tell);\n }, [orientation, edge, variant, size, edges]);\n\n return (\n <slot ref={slot} name={`item:${id}`} style={SOCKET_STYLE}>\n {children}\n </slot>\n );\n}\n","/**\n * Where a menu opens, as a placement for `@embedpdf/web`'s `fitAnchoredRect`:\n * away from the edge its bar sits on, toward the pages, and a submenu beside\n * its row. Placements are physical sides, so the bar's edge and the menu's\n * alignment are read through the writing direction: a start bar is on the\n * right in a right-to-left language. When the side asked for has no room,\n * the fit opens the menu on the other.\n */\nimport type { AnchoredPlacement } from '@embedpdf/web';\n\nimport type { BarEdge } from './bar-edge';\n\n/** The writing direction the menu opens in. */\nexport type MenuDirection = 'ltr' | 'rtl';\n\n/**\n * How a menu lines up with its button along the bar: by the edges the bar\n * starts from (`'start'`), or by the edges it ends at (`'end'`, the \"More\"\n * menu at a bar's end).\n */\nexport type MenuAlign = 'start' | 'end';\n\n/**\n * Where a bar over a selection sits: above what's selected, or below it when\n * there's no room above.\n */\nexport type SelectionBarSide = 'above' | 'below';\n\n/**\n * The placement of a menu opened from a button in a bar on `edge`: below a\n * top bar's button, above a bottom bar's, beside a start or end bar's (on the\n * side of the pages), toward the middle from a floating bar, and from a bar\n * over a selection on the side the bar sits (`selectionBar`), away from\n * what's selected.\n */\nexport function menuPlacementOf(\n edge: BarEdge,\n direction: MenuDirection,\n align: MenuAlign = 'start',\n selectionBar: SelectionBarSide = 'above',\n): AnchoredPlacement {\n if (edge === 'start' || edge === 'end') {\n // A vertical bar: its start is its top in either direction.\n const onLeft = (edge === 'start') === (direction === 'ltr');\n return `${onLeft ? 'right' : 'left'}-${align}`;\n }\n const opensUp =\n edge === 'bottom' ||\n edge === 'float-bottom' ||\n (edge === 'selection' && selectionBar === 'above');\n const side = opensUp ? 'top' : 'bottom';\n // A horizontal bar starts on the left, or on the right in a right-to-left language.\n const physical = (align === 'start') === (direction === 'ltr') ? 'start' : 'end';\n return `${side}-${physical}`;\n}\n\n/** The placement of a submenu: beside its row, on the side the text runs toward, tops lined up. */\nexport function submenuPlacementOf(direction: MenuDirection): AnchoredPlacement {\n return direction === 'ltr' ? 'right-start' : 'left-start';\n}\n\n/** The key that opens a submenu from its row, and the one that closes it again. */\nexport function submenuKeysOf(direction: MenuDirection): { open: string; close: string } {\n return direction === 'ltr'\n ? { open: 'ArrowRight', close: 'ArrowLeft' }\n : { open: 'ArrowLeft', close: 'ArrowRight' };\n}\n","/**\n * The chrome's menus: a layout menu (sections of command ids) and the menus\n * the toolbar derives (the \"More\" menu, a folded group's), drawn as rows in a\n * popover that opens away from its bar's edge (`menu-placement.ts`). The\n * popover is in the browser's top layer, so no bar, panel or the viewer's own\n * box clips it, and it takes the menu keys from `@embedpdf/web`. Rows resolve\n * live through the command registry: label, icon, shortcut, whether it's the\n * current choice, enabled state; a row whose command isn't visible is gone, and a section\n * with none left goes with its line. A row whose command opens a menu opens\n * it beside it. On a phone (a compact viewer) every menu is a sheet from the\n * bottom of the viewer instead, and a submenu slides in over the menu it\n * opened from, with a row that goes back.\n */\nimport { formatShortcut, useCommand, useCommands } from '@embedpdf/react/commands';\nimport type { ResolvedCommand } from '@embedpdf/react/commands';\nimport { useT } from '@embedpdf/react/i18n';\nimport { useDocumentId, useKernelValue, useOptionalCapability } from '@embedpdf/react/runtime';\nimport { ShellToken, useShellState } from '@embedpdf/react/shell';\nimport type { OverflowMenuView } from '@embedpdf/react/toolbar';\nimport {\n anchoredViewOf,\n attachMenuKeys,\n directionOf,\n fitAnchoredRect,\n isUnavailable,\n observeClientGeometry,\n observeOutsidePress,\n type AnchoredPlacement,\n type AnchoredRect,\n} from '@embedpdf/web';\nimport {\n createContext,\n useContext,\n useId,\n useLayoutEffect,\n useReducer,\n useRef,\n useState,\n type ReactNode,\n} from 'react';\n\nimport { useBarEdge } from './bar-edge';\nimport { Icon } from './icons';\nimport {\n menuPlacementOf,\n submenuKeysOf,\n submenuPlacementOf,\n type MenuAlign,\n type MenuDirection,\n type SelectionBarSide,\n} from './menu-placement';\nimport { Sheet } from './sheet';\nimport { useLayoutEnv, useMenu } from '../config-context';\n\n// ── the popover ──────────────────────────────────────────────────────────────\n\n/** Px between a menu and its button, and between a menu and the window's edges. */\nconst MENU_GAP_PX = 4;\n\n/** The `popover` attribute, which React's types don't list yet. */\nconst POPOVER = { popover: 'manual' } as Record<string, string>;\n\n/** The rows of a menu, the elements the menu keys move between. */\nconst MENU_ITEM_SELECTOR = '[role=\"menuitem\"], [role=\"menuitemradio\"], [role=\"menuitemcheckbox\"]';\n\n/** A copy no one can use: the toolbar's hidden measurement layer draws every button twice. */\nconst HIDDEN_COPY_SELECTOR = '[inert], [aria-hidden=\"true\"]';\n\n/** Inside a menu, a menu is a submenu: it opens beside its row. */\nconst InMenuContext = createContext(false);\n\n/** The rows of `menu` itself, not those of a submenu open inside it. */\nconst itemsOf = (menu: HTMLElement): HTMLElement[] =>\n [...menu.querySelectorAll<HTMLElement>(MENU_ITEM_SELECTOR)].filter(\n (item) => item.closest('[role=\"menu\"]') === menu,\n );\n\n/** The button that opens the menu: the one beside it that says it has a popup. */\nconst triggerOf = (holder: HTMLElement, menu: HTMLElement): HTMLElement | null =>\n [...holder.querySelectorAll<HTMLElement>('[aria-haspopup]')].find(\n (candidate) => !menu.contains(candidate),\n ) ?? null;\n\n/**\n * Where the bar over a selection that `element` is in sits now: its anchored wrapper says so\n * in `data-placement` (`Anchored` in `@embedpdf/react`), `bottom…` once it went below.\n */\nconst selectionBarSideOf = (element: Element): SelectionBarSide =>\n element.closest('[data-placement]')?.getAttribute('data-placement')?.startsWith('bottom')\n ? 'below'\n : 'above';\n\nconst boxOf = (element: Element): AnchoredRect => {\n const rect = element.getBoundingClientRect();\n return { x: rect.left, y: rect.top, width: rect.width, height: rect.height };\n};\n\n/**\n * What a submenu opens beside: its row, across the whole width of the menu\n * the row is in, and raised by the submenu's own padding so its first row\n * lines up with the row that opened it.\n */\nfunction submenuBoxOf(holder: HTMLElement, submenu: HTMLElement): AnchoredRect {\n const row = boxOf(holder);\n const parent = holder.closest('[role=\"menu\"]');\n const across = parent ? boxOf(parent) : row;\n const inset = submenu.clientTop + parseFloat(getComputedStyle(submenu).paddingTop || '0');\n return { x: across.x, y: row.y - inset, width: across.width, height: row.height };\n}\n\n/**\n * Place `menu` around `box` in the window: on the side `placement` asks for,\n * or the other side when that has no room, moved to stay on screen, and never\n * taller than the window.\n */\nfunction placeMenu(\n menu: HTMLElement,\n box: AnchoredRect,\n placement: AnchoredPlacement,\n gap: number,\n): void {\n const view = anchoredViewOf(menu, 'client');\n if (!view) return;\n menu.style.maxHeight = `${Math.max(0, view.height - 2 * MENU_GAP_PX)}px`;\n const size = { width: menu.offsetWidth, height: menu.offsetHeight };\n const { left, top } = fitAnchoredRect(box, placement, gap, { size, view });\n menu.style.left = `${left}px`;\n menu.style.top = `${top}px`;\n // Without the top layer, `position: fixed` starts at the viewer's box (its `contain`):\n // move by however far from the window's origin the menu landed.\n const landed = menu.getBoundingClientRect();\n if (Math.abs(landed.left - left) > 0.5 || Math.abs(landed.top - top) > 0.5) {\n menu.style.left = `${2 * left - landed.left}px`;\n menu.style.top = `${2 * top - landed.top}px`;\n }\n}\n\n/**\n * Open `menu` from the button beside it in `holder`: show it in the top layer,\n * place it and keep it placed, close it on a press outside it and its button,\n * and drive it from the keyboard (a submenu's row also opens it with the arrow\n * toward it, and the arrow back closes it). Returns the close.\n */\nfunction openMenu(\n menu: HTMLElement,\n holder: HTMLElement,\n options: {\n readonly placement: (direction: MenuDirection) => AnchoredPlacement;\n readonly nested: boolean;\n readonly close: () => void;\n },\n): () => void {\n const { nested, close } = options;\n const trigger = triggerOf(holder, menu);\n const direction = directionOf(holder);\n const placement = options.placement(direction);\n // The menu is named after its button.\n const name =\n trigger?.getAttribute('aria-label') ||\n trigger?.getAttribute('title') ||\n trigger?.textContent?.trim();\n if (name) menu.setAttribute('aria-label', name);\n\n if (typeof menu.showPopover === 'function') menu.showPopover();\n const place = () =>\n placeMenu(\n menu,\n nested ? submenuBoxOf(holder, menu) : boxOf(holder),\n placement,\n nested ? 0 : MENU_GAP_PX,\n );\n place();\n const resizes = new ResizeObserver(place);\n resizes.observe(menu);\n resizes.observe(holder);\n const stopGeometry = observeClientGeometry(place);\n\n // A press on the button is the button's own toggle.\n const stopOutside = observeOutsidePress(menu, (event) => {\n if (!trigger || !event.composedPath().includes(trigger)) close();\n });\n const detachKeys = attachMenuKeys(menu, { trigger, close, items: () => itemsOf(menu) });\n\n const keys = submenuKeysOf(direction);\n const onKeyDown = (event: KeyboardEvent) => {\n const item = event.target as HTMLElement;\n // A key the menu keys took is theirs.\n const free = !event.defaultPrevented;\n const opensMenu = item.getAttribute('aria-haspopup') === 'menu';\n if (free && event.key === keys.open && opensMenu && itemsOf(menu).includes(item)) {\n event.preventDefault();\n // Open the row's submenu, or go into it when it's open already.\n if (item.getAttribute('aria-expanded') !== 'true') item.click();\n else {\n const submenu = item.parentElement?.querySelector<HTMLElement>('[role=\"menu\"]');\n if (submenu) itemsOf(submenu)[0]?.focus();\n }\n } else if (free && event.key === keys.close && nested) {\n event.preventDefault();\n close();\n trigger?.focus();\n }\n // A submenu's keys stay out of the menu it opened from; Tab closes them all.\n if (nested && event.key !== 'Tab') event.stopPropagation();\n };\n menu.addEventListener('keydown', onKeyDown);\n\n return () => {\n menu.removeEventListener('keydown', onKeyDown);\n detachKeys();\n stopOutside();\n stopGeometry();\n resizes.disconnect();\n if (typeof menu.hidePopover === 'function' && menu.matches(':popover-open')) {\n menu.hidePopover();\n }\n };\n}\n\ninterface MenuPopoverProps {\n children: ReactNode;\n onClose: () => void;\n /** How the menu lines up with its button along the bar. Default `'start'`. */\n align?: MenuAlign;\n}\n\n/**\n * A menu's surface, opened by the button beside it in the same parent (the\n * one with `aria-haspopup`). It opens away from its bar's edge, or beside its\n * row in another menu, and closes on Escape, Tab or a press anywhere outside\n * it and its button. In a compact viewer it opens as a sheet.\n */\nexport function MenuPopover(props: MenuPopoverProps) {\n const probe = useRef<HTMLSpanElement>(null);\n const [usable, setUsable] = useState(false);\n const compact = useLayoutEnv().size === 'compact';\n useLayoutEffect(() => {\n const holder = probe.current?.parentElement;\n if (holder && !holder.closest(HIDDEN_COPY_SELECTOR)) setUsable(true);\n }, []);\n if (!usable) return <span ref={probe} hidden />;\n return compact ? <MenuSheet {...props} /> : <OpenMenu {...props} />;\n}\n\nfunction OpenMenu({ children, onClose, align = 'start' }: MenuPopoverProps) {\n const surface = useRef<HTMLDivElement>(null);\n const edge = useBarEdge();\n const nested = useContext(InMenuContext);\n const close = useRef(onClose);\n close.current = onClose;\n useLayoutEffect(() => {\n const menu = surface.current;\n const holder = menu?.parentElement;\n if (!menu || !holder) return;\n return openMenu(menu, holder, {\n placement: (direction) =>\n nested\n ? submenuPlacementOf(direction)\n : menuPlacementOf(\n edge,\n direction,\n align,\n edge === 'selection' ? selectionBarSideOf(holder) : undefined,\n ),\n nested,\n close: () => close.current(),\n });\n // The menu opens once, from where its button is then; it closes by unmounting.\n }, []);\n return (\n <div\n ref={surface}\n {...POPOVER}\n role=\"menu\"\n part=\"menu\"\n className=\"border-border-subtle bg-elevated text-fg z-50 overflow-y-auto rounded-lg border shadow-xl\"\n style={{ position: 'fixed', right: 'auto', bottom: 'auto', margin: 0 }}\n >\n <InMenuContext.Provider value={true}>{children}</InMenuContext.Provider>\n </div>\n );\n}\n\n// ── on a phone: the menu as a sheet ──────────────────────────────────────────\n\n/** A submenu open in a menu's sheet, over the menu its row is in. */\ninterface SheetSubmenu {\n readonly menuId: string;\n readonly label: string;\n /** The row that opened it: it has focus again when the submenu goes. */\n readonly opener: HTMLElement;\n /** Runs when a row in it is picked, as in the menu it opened from. */\n readonly onRun?: () => void;\n}\n\n/** In a menu's sheet: how a row opens its submenu, over the menu. Null outside a sheet. */\nconst MenuSheetContext = createContext<((submenu: SheetSubmenu) => void) | null>(null);\n\n/** The button a menu's sheet opened from: the one beside the sheet that says it has a popup. */\nfunction sheetTriggerOf(menu: HTMLElement): HTMLElement | null {\n const layer = menu.closest<HTMLElement>('[data-epdf-layer]');\n const holder = layer?.parentElement;\n return layer && holder ? triggerOf(holder, layer) : null;\n}\n\n/**\n * A menu as a sheet: its rows in a sheet from the bottom of the viewer, which closes on a tap\n * above it, Escape or a pick. A row that opens a menu slides that menu in over this one, with a\n * row (or the arrow key back) that goes back to where it was.\n */\nfunction MenuSheet({ children, onClose }: MenuPopoverProps) {\n const [submenus, setSubmenus] = useState<readonly SheetSubmenu[]>([]);\n const current = useRef(submenus);\n current.current = submenus;\n /** The row to give focus back to once the submenu over it has gone. */\n const refocus = useRef<HTMLElement | null>(null);\n const close = useRef(onClose);\n close.current = onClose;\n\n const open = (submenu: SheetSubmenu) => setSubmenus([...current.current, submenu]);\n const back = () => {\n const shown = current.current;\n if (shown.length === 0) return;\n refocus.current = shown[shown.length - 1]!.opener;\n setSubmenus(shown.slice(0, -1));\n };\n // After the menu under it stops being inert (its own layout effect runs first).\n useLayoutEffect(() => {\n refocus.current?.focus();\n refocus.current = null;\n }, [submenus]);\n\n return (\n // The menus in it are named after their buttons; the sheet holds no focus of its own.\n <Sheet label=\"\" onClose={onClose} trapFocus={false}>\n <MenuSheetContext.Provider value={open}>\n <div className=\"grid\">\n <SheetMenu covered={submenus.length > 0} close={() => close.current()}>\n {children}\n </SheetMenu>\n {submenus.map((submenu, i) => (\n <SheetMenu\n key={i}\n covered={i < submenus.length - 1}\n close={back}\n opener={submenu.opener}\n label={submenu.label}\n onBack={back}\n >\n <MenuBody menuId={submenu.menuId} onRun={submenu.onRun} />\n </SheetMenu>\n ))}\n </div>\n </MenuSheetContext.Provider>\n </Sheet>\n );\n}\n\n/**\n * One menu in a menu's sheet: the first one, or a submenu over it with a row that goes back.\n * It takes the menu keys while it's on top; covered, it can't take focus or presses.\n */\nfunction SheetMenu({\n covered,\n close,\n opener,\n label,\n onBack,\n children,\n}: {\n covered: boolean;\n close: () => void;\n /** A submenu's row in the menu under it; the first menu's opener is the sheet's button. */\n opener?: HTMLElement;\n label?: string;\n onBack?: () => void;\n children: ReactNode;\n}) {\n const t = useT();\n const menu = useRef<HTMLDivElement>(null);\n const actions = useRef({ close, onBack });\n actions.current = { close, onBack };\n useLayoutEffect(() => {\n const element = menu.current;\n if (!element) return;\n const trigger = opener ?? sheetTriggerOf(element);\n const name = label ?? (trigger?.getAttribute('aria-label') || trigger?.getAttribute('title'));\n if (name) element.setAttribute('aria-label', name);\n const detachKeys = attachMenuKeys(element, {\n trigger,\n close: () => actions.current.close(),\n items: () => itemsOf(element),\n initialFocus: 'none',\n });\n // The first row takes focus once the sheet is showing: the sheet shows itself after this.\n queueMicrotask(() => {\n if (element.isConnected && !element.inert) {\n itemsOf(element)\n .find((item) => !isUnavailable(item))\n ?.focus();\n }\n });\n const keys = submenuKeysOf(directionOf(element));\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.defaultPrevented) return;\n const item = event.target as HTMLElement;\n if (event.key === keys.open && item.getAttribute('aria-haspopup') === 'menu') {\n event.preventDefault();\n item.click();\n } else if (event.key === keys.close && actions.current.onBack) {\n event.preventDefault();\n actions.current.onBack();\n }\n };\n element.addEventListener('keydown', onKeyDown);\n return () => {\n element.removeEventListener('keydown', onKeyDown);\n detachKeys();\n };\n // A menu in the sheet opens once; it goes by unmounting.\n }, []);\n useLayoutEffect(() => {\n if (menu.current) menu.current.inert = covered;\n }, [covered]);\n return (\n <div\n ref={menu}\n role=\"menu\"\n part=\"menu\"\n className={`bg-elevated col-start-1 row-start-1 min-w-0 ${\n onBack\n ? 'starting:translate-x-full rtl:starting:-translate-x-full transition-[translate] duration-200 ease-out motion-reduce:transition-none'\n : ''\n }`}\n >\n {onBack && (\n <div className=\"p-1 pb-0\">\n <button\n type=\"button\"\n tabIndex={-1}\n role=\"menuitem\"\n part=\"menu-item\"\n data-epdf-menu-back=\"\"\n onClick={onBack}\n className={ROW_CLASS}\n >\n <Icon name=\"chevronLeft\" size={16} className=\"text-fg-muted rtl:-scale-x-100\" />\n <span className=\"flex-1 truncate\">{t('menu.back')}</span>\n </button>\n {label && <div className=\"text-fg px-2.5 pb-1 pt-2 text-sm font-semibold\">{label}</div>}\n </div>\n )}\n <InMenuContext.Provider value={true}>{children}</InMenuContext.Provider>\n </div>\n );\n}\n\n// ── the button a layout menu opens from ──────────────────────────────────────\n\n/**\n * Which button each open menu opened from, per viewer (its shell). The shell\n * keeps a menu open by its id, and several buttons can name one (the zoom menu\n * in the main bar and in a floating bar): it opens at the button pressed, or\n * at the first one drawn when code opened it.\n */\nconst openers = new WeakMap<object, Map<string, Element>>();\n\nfunction openersOf(shell: object): Map<string, Element> {\n let byMenu = openers.get(shell);\n if (!byMenu) {\n byMenu = new Map();\n openers.set(shell, byMenu);\n }\n return byMenu;\n}\n\n/**\n * A button that opens the layout menu `menuId`, and the menu when it's open\n * there. `children` draws the button, told whether its menu is open at it; the\n * menu lines up with this wrapper (`className`), so it can hold more than the\n * button, like the zoom field around its chevron.\n */\nexport function MenuAnchor({\n menuId,\n className = 'relative inline-flex',\n children,\n}: {\n menuId: string;\n className?: string;\n children: (open: boolean) => ReactNode;\n}) {\n const shell = useOptionalCapability(ShellToken);\n const open = useShellState((state) => state.openMenus.includes(menuId));\n const anchor = useRef<HTMLSpanElement>(null);\n const [, claim] = useReducer((count: number) => count + 1, 0);\n const opener = shell ? openersOf(shell).get(menuId) : undefined;\n const openHere = open && opener !== undefined && opener === anchor.current;\n\n useLayoutEffect(() => {\n const element = anchor.current;\n if (!shell || !element) return;\n const byMenu = openersOf(shell);\n const current = byMenu.get(menuId);\n if (!open) {\n if (current === element) byMenu.delete(menuId);\n return;\n }\n // Opened from code, or from a button that's gone: the first usable button takes it.\n if (!current?.isConnected && !element.closest(HIDDEN_COPY_SELECTOR)) {\n byMenu.set(menuId, element);\n claim();\n }\n });\n\n return (\n <span\n ref={anchor}\n className={className}\n // Before the button's own click opens the menu, so the menu opens here.\n onClickCapture={(event) => {\n const target = event.target as Element;\n const pressedButton = target.closest('[aria-haspopup]') && !target.closest('[role=\"menu\"]');\n if (shell && anchor.current && pressedButton) openersOf(shell).set(menuId, anchor.current);\n }}\n >\n {children(openHere)}\n {openHere && (\n <MenuPopover onClose={() => shell?.closeMenu(menuId)}>\n <MenuBody menuId={menuId} onRun={() => shell?.closeMenu(menuId)} />\n </MenuPopover>\n )}\n </span>\n );\n}\n\n// ── rows ─────────────────────────────────────────────────────────────────────\n\n/**\n * What the active rows of a section mean: nothing when none of its commands\n * is active, one choice of several (radio) when exactly one is, and a switch\n * per row otherwise (a lone switch, or several that are on together).\n */\ntype Choice = 'none' | 'radio' | 'checkbox';\n\nconst choiceOf = (rows: readonly ResolvedCommand[]): Choice => {\n const choosable = rows.filter((row) => !row.menu);\n const active = choosable.filter((row) => row.active).length;\n if (active === 0) return 'none';\n return active === 1 && choosable.length > 1 ? 'radio' : 'checkbox';\n};\n\nconst ROLE_OF: Readonly<Record<Choice, string>> = {\n none: 'menuitem',\n radio: 'menuitemradio',\n checkbox: 'menuitemcheckbox',\n};\n\nconst ROW_BASE =\n 'flex w-full items-center gap-3 rounded-md px-2.5 py-1.5 text-start text-sm outline-none transition-colors aria-disabled:cursor-not-allowed aria-disabled:opacity-40';\n\n/** A row, the pointer over it and the keyboard on it: the neutral hover look. */\nconst ROW_CLASS = `${ROW_BASE} text-fg-secondary hover:bg-hover focus-visible:bg-hover aria-disabled:hover:bg-transparent`;\n\n/**\n * The current choice: the accent look of an active toolbar button, so \"on\" reads the same\n * everywhere and never looks like the row the keyboard is on. The keyboard on it adds an inset\n * ring; with forced colors, where backgrounds go, an outline marks it.\n */\nconst CHOSEN_ROW_CLASS = `${ROW_BASE} bg-selected text-accent focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-accent forced-colors:outline-2 forced-colors:outline-solid forced-colors:-outline-offset-2`;\n\n/**\n * One row: the command's icon, label and shortcut, in the accent look when it\n * is the current choice. A row that can't run says why in its tooltip, and\n * stays where it is, greyed out.\n */\nexport function MenuItem({\n command,\n choice,\n onSelect,\n}: {\n command: ResolvedCommand;\n choice: Choice;\n onSelect: () => void;\n}) {\n const checked = choice !== 'none' && command.active;\n const [shortcut] = command.shortcuts;\n return (\n <button\n type=\"button\"\n tabIndex={-1}\n role={ROLE_OF[choice]}\n aria-checked={choice === 'none' ? undefined : command.active}\n aria-disabled={command.enabled ? undefined : true}\n title={command.enabled ? undefined : command.disabledReason}\n part={checked ? 'menu-item menu-item-active' : 'menu-item'}\n onClick={() => {\n if (command.enabled) onSelect();\n }}\n className={checked ? CHOSEN_ROW_CLASS : ROW_CLASS}\n >\n {command.icon && (\n <Icon\n name={command.icon}\n size={16}\n accent={command.iconAccent}\n className={checked ? 'text-accent' : 'text-fg-muted'}\n />\n )}\n <span className=\"flex-1 truncate\">{command.label}</span>\n {shortcut && <span className=\"text-fg-muted ms-4 text-xs\">{formatShortcut(shortcut)}</span>}\n </button>\n );\n}\n\n/**\n * A row whose command opens a menu: it opens that menu beside it, with a\n * click or the arrow key toward it. Picking a row in there runs `onRun` too,\n * so the whole menu closes.\n */\nfunction SubmenuItem({\n command,\n menuId,\n onRun,\n}: {\n command: ResolvedCommand;\n menuId: string;\n onRun?: () => void;\n}) {\n const [open, setOpen] = useState(false);\n const openInSheet = useContext(MenuSheetContext);\n return (\n <div role=\"none\" className=\"relative\">\n <button\n type=\"button\"\n tabIndex={-1}\n role=\"menuitem\"\n aria-haspopup=\"menu\"\n aria-expanded={open}\n aria-disabled={command.enabled ? undefined : true}\n title={command.enabled ? undefined : command.disabledReason}\n part=\"menu-item\"\n onClick={(event) => {\n if (!command.enabled) return;\n // In a sheet, the submenu slides in over this menu.\n if (openInSheet) {\n openInSheet({ menuId, label: command.label, opener: event.currentTarget, onRun });\n } else setOpen((previous) => !previous);\n }}\n className={`${ROW_CLASS} ${open ? 'bg-hover' : ''}`}\n >\n {command.icon && (\n <Icon\n name={command.icon}\n size={16}\n accent={command.iconAccent}\n className=\"text-fg-muted\"\n />\n )}\n <span className=\"flex-1 truncate\">{command.label}</span>\n <Icon name=\"chevronRight\" size={16} className=\"text-fg-muted rtl:-scale-x-100\" />\n </button>\n {open && (\n <MenuPopover onClose={() => setOpen(false)}>\n <MenuBody menuId={menuId} onRun={onRun} />\n </MenuPopover>\n )}\n </div>\n );\n}\n\n/** A layout menu's row, by command id. */\nfunction MenuRow({\n commandId,\n choice,\n onRun,\n}: {\n commandId: string;\n choice: Choice;\n onRun?: () => void;\n}) {\n const command = useCommand(commandId);\n if (!command.visible) return null;\n if (command.menu) {\n return <SubmenuItem command={command} menuId={command.menu} onRun={onRun} />;\n }\n return (\n <MenuItem\n command={command}\n choice={choice}\n onSelect={() => {\n void command.run();\n onRun?.();\n }}\n />\n );\n}\n\n// ── sections ─────────────────────────────────────────────────────────────────\n\n/** A section: its rows as a group named by its title, after a line when it isn't the first. */\nfunction MenuGroup({\n title,\n first,\n children,\n}: {\n title?: string;\n first: boolean;\n children: ReactNode;\n}) {\n const titleId = useId();\n return (\n <>\n {!first && <div role=\"separator\" className=\"bg-border-subtle my-1 h-px\" />}\n <div role=\"group\" aria-labelledby={title ? titleId : undefined}>\n {title && (\n <div\n id={titleId}\n className=\"text-fg-muted px-2.5 pb-1 pt-1.5 text-[11px] font-semibold uppercase tracking-wide\"\n >\n {title}\n </div>\n )}\n {children}\n </div>\n </>\n );\n}\n\nconst sameChoices = (left: readonly (Choice | null)[], right: readonly (Choice | null)[]) =>\n left.length === right.length && left.every((choice, i) => choice === right[i]);\n\n/** One section-separated menu, by its id in the layout. */\nexport function MenuBody({ menuId, onRun }: { menuId: string; onRun?: () => void }) {\n const t = useT();\n const menu = useMenu(menuId);\n const commands = useCommands();\n const documentId = useDocumentId() ?? undefined;\n // Per section, what its active rows mean, or null when it has no visible row: an empty\n // section doesn't leave its title and line behind.\n const choices = useKernelValue(\n () =>\n (menu ?? []).map((section) => {\n const rows = section.items\n .map((id) => commands.resolveCommand(id, documentId))\n .filter((command): command is ResolvedCommand => command?.visible === true);\n return rows.length === 0 ? null : choiceOf(rows);\n }),\n sameChoices,\n );\n if (!menu) return null;\n const shown = menu.flatMap((section, i) => {\n const choice = choices[i];\n return choice ? [{ section, choice }] : [];\n });\n if (shown.length === 0) return null;\n return (\n <div className=\"min-w-52 p-1\">\n {shown.map(({ section, choice }, i) => (\n <MenuGroup\n key={i}\n first={i === 0}\n title={section.title ?? (section.titleKey ? t(section.titleKey) : undefined)}\n >\n {section.items.map((id) => (\n <MenuRow key={id} commandId={id} choice={choice} onRun={onRun} />\n ))}\n </MenuGroup>\n ))}\n </div>\n );\n}\n\n/**\n * A menu the toolbar derives (the \"More\" menu, a folded group's): its\n * sections in bar order, the bar's groups as titled sections, and a row for\n * each command; a command that opens a menu opens it beside its row.\n */\nexport function ToolbarMenu({ view, align }: { view: OverflowMenuView; align?: MenuAlign }) {\n const t = useT();\n if (!view.isOpen) return null;\n const sections = view.sections.map((section) => {\n const rows = section.rows.flatMap((row) => {\n const command = view.resolve(row.command);\n return command ? [{ row, command }] : [];\n });\n const choice: Choice =\n section.role === 'radio' ? 'radio' : choiceOf(rows.map(({ command }) => command));\n return { section, rows, choice };\n });\n return (\n <MenuPopover onClose={view.close} align={align}>\n <div className=\"min-w-56 p-1\">\n {sections.map(({ section, rows, choice }, i) => (\n <MenuGroup\n key={i}\n first={i === 0}\n title={section.labelKey ? t(section.labelKey) : undefined}\n >\n {rows.map(({ row, command }) =>\n row.type === 'submenu' ? (\n <SubmenuItem\n key={row.command}\n command={command}\n menuId={row.menu}\n onRun={view.close}\n />\n ) : (\n <MenuItem\n key={row.command}\n command={command}\n choice={choice}\n onSelect={() => {\n view.execute(row.command);\n view.close();\n }}\n />\n ),\n )}\n </MenuGroup>\n ))}\n </div>\n </MenuPopover>\n );\n}\n","/**\n * The app's toolbar look — Tailwind render props over the headless <Toolbar>.\n * The app owns the pixels; ui-core owns the physics (measure → solve →\n * overflow). Nothing here knows about breakpoints or widths.\n */\nimport { MeasurementScaleButton } from './measurement-scale';\nimport { useEffect, useState } from 'react';\nimport { VIEW_MODE_COMMAND, groupMenuView, type CustomItem } from '@embedpdf/core-ui';\nimport { useOptionalCapability, useOptionalSelector } from '@embedpdf/react/runtime';\nimport { Toolbar } from '@embedpdf/react/toolbar';\nimport type {\n BarSchema,\n CollapsedGroupView,\n CustomSlotCtx,\n GroupDisclosureView,\n OverflowMenuView,\n} from '@embedpdf/react/toolbar';\nimport { useCommand, useCommands } from '@embedpdf/react/commands';\nimport type { ResolvedCommand } from '@embedpdf/react/commands';\nimport { TOOLBAR_ITEM_ATTRIBUTE } from '@embedpdf/web';\nimport { PageNumber } from './page-number';\nimport { QuickStamps } from './quick-stamps';\nimport { ViewOnlyLabel } from './view-only';\nimport { ShellToken } from '@embedpdf/react/shell';\nimport { useT } from '@embedpdf/react/i18n';\nimport { StageToken } from '@embedpdf/react/stage';\nimport { Icon } from './icons';\nimport { ItemSocket } from './item-socket';\nimport { MenuAnchor, ToolbarMenu } from './menu';\n\n// ── the Button recipe ─────────────────────────────────────────────────────────\nconst BTN_BASE =\n 'flex h-8 w-auto min-w-8 cursor-pointer items-center justify-center rounded-md p-[5px] transition-colors';\nconst BTN_HOVER = 'hover:bg-hover hover:ring hover:ring-accent';\nconst BTN_ACTIVE = 'border-none bg-selected text-accent shadow ring ring-accent';\nconst BTN_DISABLED = 'cursor-not-allowed opacity-50 hover:bg-transparent hover:ring-0';\n\nexport const buttonClass = (active: boolean, enabled = true): string =>\n `${BTN_BASE} ${active ? BTN_ACTIVE : BTN_HOVER} ${enabled ? '' : BTN_DISABLED}`;\n\n/**\n * The part name of a button in a bar, for page CSS through `::part()`: `toolbar-button`, and\n * `toolbar-button-active` too while it's pressed or its menu is open. Part names are public, as\n * the Theming page lists them.\n */\nexport const buttonPart = (active: boolean): string =>\n active ? 'toolbar-button toolbar-button-active' : 'toolbar-button';\n\n/** The part name of a mode tab: `mode-tab`, and `mode-tab-active` too for the open mode. */\nconst modeTabPart = (active: boolean): string => (active ? 'mode-tab mode-tab-active' : 'mode-tab');\n\n// ── the TabButton recipe (the underline) ──────────────────────────────────────\nconst TAB_BASE =\n 'flex h-8 w-auto min-w-8 cursor-pointer items-center justify-center rounded-none border-b-2 px-2 py-1 text-sm transition-colors hover:bg-transparent hover:border-b-fg-muted';\nconst TAB_ACTIVE = 'border-b-accent text-accent hover:border-b-accent';\nconst TAB_INACTIVE = 'border-b-transparent';\n\nconst tabClass = (active: boolean, enabled = true): string =>\n `${TAB_BASE} ${active ? TAB_ACTIVE : TAB_INACTIVE} ${enabled ? '' : 'cursor-not-allowed opacity-50'}`;\n\n// ── a single command button (icon / icon+label / label=tab) ──────────────────\nexport function CommandButton({\n cmd,\n variant,\n run,\n}: {\n cmd: ResolvedCommand;\n variant: string;\n run: () => void;\n}) {\n const isTab = variant === 'label';\n\n // Buttons carry no caret — a menu command is a plain icon button; the\n // `menu:` declaration still drives aria-haspopup and the anchored popover.\n // A menu command is active while its menu is open at this button: it says it's expanded.\n const draw = (active: boolean) => (\n <button\n type=\"button\"\n onClick={run}\n disabled={!cmd.enabled}\n aria-pressed={cmd.menu ? undefined : active || undefined}\n aria-haspopup={cmd.menu ? 'menu' : undefined}\n aria-expanded={cmd.menu ? active : undefined}\n aria-label={cmd.label}\n // A command the scope doesn't allow, shown under `notAllowed: 'disable'`, says why.\n title={cmd.disabledReason ?? cmd.label}\n part={isTab ? modeTabPart(active) : buttonPart(active)}\n className={isTab ? tabClass(active, cmd.enabled) : buttonClass(active, cmd.enabled)}\n >\n {isTab ? (\n <span className=\"whitespace-nowrap px-1\">{cmd.label}</span>\n ) : variant === 'icon+label' ? (\n <span className=\"flex items-center whitespace-nowrap text-sm\">\n {cmd.icon && (\n <Icon name={cmd.icon} size={20} accent={cmd.iconAccent} className=\"me-1.5 shrink-0\" />\n )}\n <span>{cmd.label}</span>\n </span>\n ) : cmd.icon ? (\n <Icon name={cmd.icon} size={20} accent={cmd.iconAccent} />\n ) : (\n <span className=\"text-sm\">{cmd.label}</span>\n )}\n </button>\n );\n\n if (!cmd.menu) return draw(cmd.active);\n return <MenuAnchor menuId={cmd.menu}>{draw}</MenuAnchor>;\n}\n\n// ── the inline zoom widget ───────────────────────────────────────────────────\n\n/**\n * Makes a control inside an item one more stop of the toolbar's arrow keys: the zoom field's\n * buttons are reached with the arrows, like the bar's own, and the bar stays one Tab stop.\n */\nconst ARROW_STOP = { [TOOLBAR_ITEM_ATTRIBUTE]: '', className: 'contents' } as Record<\n string,\n string\n>;\n\nfunction ZoomControls() {\n const t = useT();\n const commands = useCommands();\n const zoomIn = useCommand('zoom:in');\n const zoomOut = useCommand('zoom:out');\n const zoomMenu = useCommand('menu:zoom');\n const shell = useOptionalCapability(ShellToken);\n const stage = useOptionalCapability(StageToken);\n // Null-safe: the zoom strip is main-toolbar chrome, mounted before any\n // document exists — it reads 100% until a Stage is there to ask.\n const level = useOptionalSelector(StageToken, (stage) => stage.getZoomLevel(), 1);\n const pct = Math.round((level ?? 1) * 100);\n const [inputValue, setInputValue] = useState(String(pct));\n useEffect(() => setInputValue(String(pct)), [pct]);\n\n const submit = (event: React.FormEvent) => {\n event.preventDefault();\n const value = parseFloat(inputValue);\n if (!isNaN(value) && value > 0) stage?.zoomTo({ level: value / 100 });\n };\n\n // The zoom menu lines up with the whole field.\n return (\n <MenuAnchor menuId=\"zoom\" className=\"relative block\">\n {(zoomOpen) => (\n <div className=\"bg-hover flex items-center rounded\">\n {/* editable zoom percentage */}\n <form\n onSubmit={submit}\n className=\"flex min-w-0 flex-nowrap items-center overflow-hidden whitespace-nowrap\"\n >\n <input\n name=\"zoom\"\n type=\"text\"\n inputMode=\"numeric\"\n pattern=\"\\d*\"\n aria-label={t('commands.zoom.level')}\n className=\"h-6 w-8 min-w-0 shrink border-0 bg-transparent p-0 text-end text-sm outline-none focus:outline-none\"\n value={inputValue}\n onChange={(event) => setInputValue(event.target.value.replace(/[^0-9]/g, ''))}\n onBlur={() => {\n if (!inputValue || parseFloat(inputValue) <= 0) setInputValue(String(pct));\n }}\n />\n <span className=\"shrink-0 text-sm\">%</span>\n </form>\n {/* zoom menu chevron */}\n <span {...ARROW_STOP}>\n <button\n type=\"button\"\n aria-haspopup=\"menu\"\n aria-expanded={zoomOpen}\n title={zoomMenu.label}\n part={buttonPart(false)}\n className={buttonClass(false)}\n onClick={() => shell?.toggleMenu('zoom')}\n >\n <Icon name=\"chevronDown\" size={20} />\n </button>\n </span>\n <span {...ARROW_STOP}>\n <button\n type=\"button\"\n title={zoomOut.label}\n part={buttonPart(false)}\n className={buttonClass(false)}\n onClick={() => commands.execute('zoom:out')}\n >\n <Icon name=\"zoomOut\" size={20} />\n </button>\n </span>\n <span {...ARROW_STOP}>\n <button\n type=\"button\"\n title={zoomIn.label}\n part={buttonPart(false)}\n className={buttonClass(false)}\n onClick={() => commands.execute('zoom:in')}\n >\n <Icon name=\"zoomIn\" size={20} />\n </button>\n </span>\n </div>\n )}\n </MenuAnchor>\n );\n}\n\n/** The 'button' variant of the zoom slot — a single icon that opens the menu. */\nfunction ZoomButton() {\n const shell = useOptionalCapability(ShellToken);\n const zoomMenu = useCommand('menu:zoom');\n return (\n <MenuAnchor menuId=\"zoom\">\n {(zoomOpen) => (\n <button\n type=\"button\"\n title={zoomMenu.label}\n aria-haspopup=\"menu\"\n aria-expanded={zoomOpen}\n part={buttonPart(zoomOpen)}\n className={buttonClass(zoomOpen)}\n onClick={() => shell?.toggleMenu('zoom')}\n >\n <Icon name=\"zoomIn\" size={20} />\n </button>\n )}\n </MenuAnchor>\n );\n}\n\n// ── a shed group's in-strip disclosure (derived) ─────────────────────────────\nfunction GroupTrigger({ view }: { view: GroupDisclosureView }) {\n const [open, setOpen] = useState(false);\n // The active tab may be hiding behind the chevron — hint at it, tab-style.\n const activeHidden = view.commands.some((command) => command.active);\n return (\n <span className=\"relative inline-flex\">\n <button\n type=\"button\"\n onClick={() => setOpen((previous) => !previous)}\n aria-haspopup=\"menu\"\n aria-expanded={open}\n // The chevron the trailing mode tabs fold behind is a tab too; another group's is a button.\n part={view.id === 'modes' ? modeTabPart(activeHidden) : buttonPart(open)}\n className={tabClass(activeHidden)}\n >\n <Icon name=\"chevronDown\" size={18} />\n </button>\n <ToolbarMenu view={groupMenuView(view, open, () => setOpen(false))} />\n </span>\n );\n}\n\n// ── the collapsed modes group ────────────────────────────────────────────────\nfunction CollapsedModes({ view }: { view: CollapsedGroupView }) {\n const [open, setOpen] = useState(false);\n const active = view.commands.find((command) => command.active) ?? view.commands[0];\n // The control highlights whenever a non-default mode is active.\n const isActive = Boolean(active?.active && active.id !== VIEW_MODE_COMMAND);\n return (\n <div style={{ width: 100 }} className=\"relative\">\n <button\n type=\"button\"\n onClick={() => setOpen((previous) => !previous)}\n aria-haspopup=\"menu\"\n aria-expanded={open}\n part={buttonPart(open)}\n className=\"bg-surface hover:bg-hover flex w-full cursor-pointer appearance-none items-center rounded-md py-1.5 pe-2 ps-3 text-[13px] transition-colors\"\n >\n <span\n className={`min-w-0 flex-1 truncate text-start ${isActive ? 'text-accent' : 'text-fg'}`}\n >\n {active?.label}\n </span>\n <Icon\n name=\"chevronDown\"\n size={16}\n className={isActive ? 'text-accent' : 'text-fg-secondary'}\n />\n </button>\n <ToolbarMenu view={groupMenuView(view, open, () => setOpen(false))} />\n </div>\n );\n}\n\n// ── a group folded into one menu button (`collapse: 'menu'`) ─────────────────\nfunction CollapsedMenu({ view }: { view: CollapsedGroupView }) {\n const t = useT();\n const [open, setOpen] = useState(false);\n // The button shows the group's current choice, else its first command.\n const shown = view.commands.find((command) => command.active) ?? view.commands[0];\n const label = view.labelKey ? t(view.labelKey) : shown?.label;\n return (\n <span className=\"relative inline-flex\">\n <button\n type=\"button\"\n onClick={() => setOpen((previous) => !previous)}\n aria-haspopup=\"menu\"\n aria-expanded={open}\n aria-label={label}\n title={label}\n part={buttonPart(open)}\n className={buttonClass(open)}\n >\n {shown?.icon ? (\n <Icon name={shown.icon} size={20} accent={shown.iconAccent} />\n ) : (\n <span className=\"whitespace-nowrap px-1 text-sm\">{label}</span>\n )}\n <Icon name=\"chevronDown\" size={14} className=\"text-fg-secondary\" />\n </button>\n <ToolbarMenu view={groupMenuView(view, open, () => setOpen(false))} />\n </span>\n );\n}\n\n// ── the derived overflow menu ────────────────────────────────────────────────\nfunction OverflowMenu({ view }: { view: OverflowMenuView }) {\n // The \"More\" button is at the bar's end: the menu lines up with it there.\n return <ToolbarMenu view={view} align=\"end\" />;\n}\n\nfunction OverflowTrigger({ isOpen, toggle }: { isOpen: boolean; toggle: () => void }) {\n const t = useT();\n return (\n <button\n type=\"button\"\n onClick={toggle}\n aria-haspopup=\"menu\"\n aria-expanded={isOpen}\n title={t('demo.more')}\n part={buttonPart(isOpen)}\n className={buttonClass(isOpen)}\n >\n <Icon name=\"dots\" size={20} />\n </button>\n );\n}\n\n// ── your own items ───────────────────────────────────────────────────────────\n\n/** The custom items in `bar`, in order. */\nfunction customItemsOf(bar: BarSchema): CustomItem[] {\n const groups = [\n ...(bar.sections.start ?? []),\n ...(bar.sections.center ?? []),\n ...(bar.sections.end ?? []),\n ];\n return groups.flatMap((group) =>\n group.items.filter(\n (child): child is CustomItem => typeof child === 'object' && 'slot' in child,\n ),\n );\n}\n\n/** What your item stands for while nothing is slotted into it: its command's button. */\nfunction StandIn({ commandId }: { commandId: string }) {\n const command = useCommand(commandId);\n if (!command.visible) return null;\n return <CommandButton cmd={command} variant=\"icon\" run={() => void command.run()} />;\n}\n\n// ── the assembled toolbar ────────────────────────────────────────────────────\nexport function AppToolbar({\n bar,\n orientation = 'horizontal',\n className,\n}: {\n bar: BarSchema;\n /** A vertical toolbar (a bar at the start or end edge) draws its commands as icons. */\n orientation?: 'horizontal' | 'vertical';\n className?: string;\n}) {\n const vertical = orientation === 'vertical';\n // The custom items the viewer draws itself.\n const builtIn: Record<string, (variant: string) => React.ReactNode> = {\n 'measurement-scale': () => <MeasurementScaleButton />,\n // The zoom field, or its button when there's no room; the field runs across a bar, so a\n // vertical one draws the button.\n zoom: (variant) => (variant === 'button' || vertical ? <ZoomButton /> : <ZoomControls />),\n 'quick-stamps': () => <QuickStamps />,\n 'page-number': () => <PageNumber />,\n 'view-only': (variant) => <ViewOnlyLabel compact={variant === 'icon' || vertical} />,\n };\n // Every other one is yours, slotted in, so the measurement layer can't hold it: its socket is\n // measured where it renders.\n const yours = Object.fromEntries(\n customItemsOf(bar)\n .filter((item) => !Object.prototype.hasOwnProperty.call(builtIn, item.slot))\n .map((item) => [\n item.slot,\n (variant: string, ctx: CustomSlotCtx) =>\n ctx.layer === 'measure' ? null : (\n <ItemSocket\n id={item.slot}\n variant={item.variants ? variant : null}\n orientation={orientation}\n measure={ctx.measure}\n >\n {item.terminal ? <StandIn commandId={item.terminal} /> : null}\n </ItemSocket>\n ),\n ]),\n );\n return (\n <Toolbar\n bar={bar}\n orientation={orientation}\n gap={8} // Tailwind's gap-2\n separatorWidth={1}\n className={className}\n renderCommand={(cmd, variant, run) => <CommandButton cmd={cmd} variant={variant} run={run} />}\n renderCustom={{ ...yours, ...builtIn }}\n renderCollapsed={(view) =>\n view.id === 'modes' ? (\n <CollapsedModes view={view} />\n ) : view.collapse === 'menu' ? (\n <CollapsedMenu view={view} />\n ) : undefined\n }\n renderGroupTrigger={(view) => <GroupTrigger view={view} />}\n renderSeparator={() => (\n <span className={`bg-border self-center ${vertical ? 'h-px w-6' : 'h-6 w-px'}`} />\n )}\n renderOverflowTrigger={(isOpen, toggle) => (\n <OverflowTrigger isOpen={isOpen} toggle={toggle} />\n )}\n renderOverflowMenu={(view) => <OverflowMenu view={view} />}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAcA,MAAa,gBAAgB;CAC3B,aAAa;EAAC;EAAa;EAAU;EAAW;EAAQ;EAAS;CAAO;CACxE,QAAQ,CAAC;CACT,QAAQ,CAAC;CACT,UAAU,CAAC,SAAS;CACpB,OAAO,CAAC,WAAW,UAAU;CAC7B,YAAY,CAAC,WAAW,UAAU;CAClC,WAAW,CAAC;CACZ,aAAa,CAAC;CACd,OAAO,CAAC;CACR,aAAa,CAAC,QAAQ;CACtB,MAAM,CAAC,aAAa,MAAM;CAC1B,QAAQ,CAAC;CACT,YAAY,CAAC;CACb,SAAS,CAAC;CACV,WAAW;EAAC;EAAQ;EAAY;EAAS;CAAM;AACjD;;AAeA,MAAa,qBAAyC;CACpD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,YAAY,SAAiB,UACjC,YAAY,SAAS,QAA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