@osdk/react-components 0.2.0-beta.22 → 0.2.0-beta.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.md +22 -6
- package/build/browser/action-form/FormFieldApi.js.map +1 -1
- package/build/browser/action-form/fields/DateCalendar.js +70 -0
- package/build/browser/action-form/fields/DateCalendar.js.map +1 -0
- package/build/browser/action-form/fields/DateCalendar.module.css +136 -0
- package/build/browser/action-form/fields/DateCalendar.module.css.js +22 -0
- package/build/browser/action-form/fields/DatetimePickerField.js +98 -0
- package/build/browser/action-form/fields/DatetimePickerField.js.map +1 -0
- package/build/browser/action-form/fields/DatetimePickerField.module.css +66 -0
- package/build/browser/action-form/fields/DatetimePickerField.module.css.js +10 -0
- package/build/browser/action-form/fields/FormFieldRenderer.js +10 -1
- package/build/browser/action-form/fields/FormFieldRenderer.js.map +1 -1
- package/build/browser/action-form/fields/LazyDateCalendar.js +27 -0
- package/build/browser/action-form/fields/LazyDateCalendar.js.map +1 -0
- package/build/browser/filter-list/FilterList.js +9 -5
- package/build/browser/filter-list/FilterList.js.map +1 -1
- package/build/browser/filter-list/FilterListApi.js.map +1 -1
- package/build/browser/filter-list/base/BaseFilterList.js +3 -1
- package/build/browser/filter-list/base/BaseFilterList.js.map +1 -1
- package/build/browser/filter-list/base/BaseFilterListApi.js.map +1 -1
- package/build/browser/filter-list/base/FilterListHeader.js +3 -2
- package/build/browser/filter-list/base/FilterListHeader.js.map +1 -1
- package/build/browser/filter-list/base/inputs/DateRangeInput.js +1 -1
- package/build/browser/filter-list/base/inputs/DateRangeInput.js.map +1 -1
- package/build/browser/filter-list/base/inputs/MultiDateInput.js +1 -1
- package/build/browser/filter-list/base/inputs/MultiDateInput.js.map +1 -1
- package/build/browser/filter-list/base/inputs/SingleDateInput.js +1 -1
- package/build/browser/filter-list/base/inputs/SingleDateInput.js.map +1 -1
- package/build/browser/filter-list/base/inputs/TimelineInput.js +1 -1
- package/build/browser/filter-list/base/inputs/TimelineInput.js.map +1 -1
- package/build/browser/filter-list/base/inputs/index.js +1 -1
- package/build/browser/filter-list/base/inputs/index.js.map +1 -1
- package/build/browser/filter-list/hooks/useFilterListState.js +3 -0
- package/build/browser/filter-list/hooks/useFilterListState.js.map +1 -1
- package/build/browser/filter-list/hooks/useFilterVisibility.js +7 -1
- package/build/browser/filter-list/hooks/useFilterVisibility.js.map +1 -1
- package/build/browser/filter-list/utils/filterStateToWhereClause.js +1 -1
- package/build/browser/filter-list/utils/filterStateToWhereClause.js.map +1 -1
- package/build/browser/object-table/LoadingCell.js +2 -1
- package/build/browser/object-table/LoadingCell.js.map +1 -1
- package/build/browser/object-table/LoadingCell.module.css +3 -20
- package/build/browser/object-table/LoadingCell.module.css.js +1 -2
- package/build/browser/object-table/LoadingStateTable.js +2 -1
- package/build/browser/object-table/LoadingStateTable.js.map +1 -1
- package/build/browser/pdf-viewer/PdfRenderer.js +1 -1
- package/build/browser/pdf-viewer/PdfRenderer.js.map +1 -1
- package/build/browser/pdf-viewer/PdfViewer.js +59 -118
- package/build/browser/pdf-viewer/PdfViewer.js.map +1 -1
- package/build/browser/pdf-viewer/components/PdfViewerAnnotationLayer.js.map +1 -0
- package/build/browser/pdf-viewer/components/PdfViewerAnnotationLayer.module.css.js +11 -0
- package/build/browser/pdf-viewer/components/PdfViewerContent.js +113 -0
- package/build/browser/pdf-viewer/components/PdfViewerContent.js.map +1 -0
- package/build/browser/pdf-viewer/components/PdfViewerOutlineSidebar.js +98 -0
- package/build/browser/pdf-viewer/components/PdfViewerOutlineSidebar.js.map +1 -0
- package/build/browser/pdf-viewer/components/PdfViewerOutlineSidebar.module.css +89 -0
- package/build/browser/pdf-viewer/components/PdfViewerOutlineSidebar.module.css.js +15 -0
- package/build/browser/pdf-viewer/components/PdfViewerSearchBar.js.map +1 -0
- package/build/browser/pdf-viewer/components/PdfViewerSearchBar.module.css.js +10 -0
- package/build/browser/pdf-viewer/{PdfViewerSidebar.js → components/PdfViewerSidebar.js} +9 -5
- package/build/browser/pdf-viewer/components/PdfViewerSidebar.js.map +1 -0
- package/build/{esm/pdf-viewer → browser/pdf-viewer/components}/PdfViewerSidebar.module.css +0 -9
- package/build/browser/pdf-viewer/{PdfViewerSidebar.module.css.js → components/PdfViewerSidebar.module.css.js} +5 -6
- package/build/browser/pdf-viewer/components/PdfViewerSidebarHeader.js +54 -0
- package/build/browser/pdf-viewer/components/PdfViewerSidebarHeader.js.map +1 -0
- package/build/browser/pdf-viewer/components/PdfViewerSidebarHeader.module.css +70 -0
- package/build/browser/pdf-viewer/components/PdfViewerSidebarHeader.module.css.js +8 -0
- package/build/browser/pdf-viewer/{PdfViewerThumbnail.js → components/PdfViewerThumbnail.js} +1 -1
- package/build/browser/pdf-viewer/components/PdfViewerThumbnail.js.map +1 -0
- package/build/browser/pdf-viewer/{PdfViewerThumbnail.module.css.js → components/PdfViewerThumbnail.module.css.js} +3 -3
- package/build/browser/pdf-viewer/{PdfViewerToolbar.js → components/PdfViewerToolbar.js} +39 -12
- package/build/browser/pdf-viewer/components/PdfViewerToolbar.js.map +1 -0
- package/build/browser/pdf-viewer/{PdfViewerToolbar.module.css → components/PdfViewerToolbar.module.css} +2 -2
- package/build/browser/pdf-viewer/components/PdfViewerToolbar.module.css.js +12 -0
- package/build/browser/pdf-viewer/constants.js +7 -5
- package/build/browser/pdf-viewer/constants.js.map +1 -1
- package/build/browser/pdf-viewer/hooks/usePdfDocument.js +2 -3
- package/build/browser/pdf-viewer/hooks/usePdfDocument.js.map +1 -1
- package/build/browser/pdf-viewer/hooks/usePdfOutline.js +268 -0
- package/build/browser/pdf-viewer/hooks/usePdfOutline.js.map +1 -0
- package/build/browser/pdf-viewer/hooks/usePdfViewer.js +12 -1
- package/build/browser/pdf-viewer/hooks/usePdfViewer.js.map +1 -1
- package/build/browser/pdf-viewer/hooks/usePdfViewerCore.js +80 -0
- package/build/browser/pdf-viewer/hooks/usePdfViewerCore.js.map +1 -0
- package/build/browser/pdf-viewer/hooks/usePdfViewerState.js +135 -0
- package/build/browser/pdf-viewer/hooks/usePdfViewerState.js.map +1 -0
- package/build/browser/pdf-viewer/types.js.map +1 -1
- package/build/browser/public/experimental.js +21 -2
- package/build/browser/public/experimental.js.map +1 -1
- package/build/browser/public/primitives.js +20 -0
- package/build/browser/public/primitives.js.map +1 -0
- package/build/browser/{filter-list/base/inputs → shared}/dateUtils.js +38 -2
- package/build/browser/shared/dateUtils.js.map +1 -0
- package/build/browser/styles.css +421 -74
- package/build/cjs/DateCalendar-QWGFKD6J.css +113 -0
- package/build/cjs/DateCalendar-QWGFKD6J.css.map +1 -0
- package/build/cjs/DateCalendar-R44GMN3O.cjs +67 -0
- package/build/cjs/DateCalendar-R44GMN3O.cjs.map +1 -0
- package/build/cjs/chunk-GT6IV6LV.cjs +163 -0
- package/build/cjs/chunk-GT6IV6LV.cjs.map +1 -0
- package/build/cjs/chunk-HMQTYQEX.cjs +9 -0
- package/build/cjs/chunk-HMQTYQEX.cjs.map +1 -0
- package/build/cjs/chunk-UZ2E5NRX.cjs +8 -0
- package/build/cjs/chunk-UZ2E5NRX.cjs.map +1 -0
- package/build/cjs/index.cjs +2 -0
- package/build/cjs/public/experimental.cjs +2157 -1592
- package/build/cjs/public/experimental.cjs.map +1 -1
- package/build/cjs/public/experimental.css +388 -116
- package/build/cjs/public/experimental.css.map +1 -1
- package/build/cjs/public/experimental.d.cts +273 -14
- package/build/cjs/public/primitives.cjs +25 -0
- package/build/cjs/public/primitives.cjs.map +1 -0
- package/build/cjs/public/primitives.css +154 -0
- package/build/cjs/public/primitives.css.map +1 -0
- package/build/cjs/public/primitives.d.cts +49 -0
- package/build/esm/action-form/FormFieldApi.js.map +1 -1
- package/build/esm/action-form/fields/DateCalendar.js +70 -0
- package/build/esm/action-form/fields/DateCalendar.js.map +1 -0
- package/build/esm/action-form/fields/DateCalendar.module.css +136 -0
- package/build/esm/action-form/fields/DatetimePickerField.js +98 -0
- package/build/esm/action-form/fields/DatetimePickerField.js.map +1 -0
- package/build/esm/action-form/fields/DatetimePickerField.module.css +66 -0
- package/build/esm/action-form/fields/FormFieldRenderer.js +10 -1
- package/build/esm/action-form/fields/FormFieldRenderer.js.map +1 -1
- package/build/esm/action-form/fields/LazyDateCalendar.js +27 -0
- package/build/esm/action-form/fields/LazyDateCalendar.js.map +1 -0
- package/build/esm/filter-list/FilterList.js +9 -5
- package/build/esm/filter-list/FilterList.js.map +1 -1
- package/build/esm/filter-list/FilterListApi.js.map +1 -1
- package/build/esm/filter-list/base/BaseFilterList.js +3 -1
- package/build/esm/filter-list/base/BaseFilterList.js.map +1 -1
- package/build/esm/filter-list/base/BaseFilterListApi.js.map +1 -1
- package/build/esm/filter-list/base/FilterListHeader.js +3 -2
- package/build/esm/filter-list/base/FilterListHeader.js.map +1 -1
- package/build/esm/filter-list/base/inputs/DateRangeInput.js +1 -1
- package/build/esm/filter-list/base/inputs/DateRangeInput.js.map +1 -1
- package/build/esm/filter-list/base/inputs/MultiDateInput.js +1 -1
- package/build/esm/filter-list/base/inputs/MultiDateInput.js.map +1 -1
- package/build/esm/filter-list/base/inputs/SingleDateInput.js +1 -1
- package/build/esm/filter-list/base/inputs/SingleDateInput.js.map +1 -1
- package/build/esm/filter-list/base/inputs/TimelineInput.js +1 -1
- package/build/esm/filter-list/base/inputs/TimelineInput.js.map +1 -1
- package/build/esm/filter-list/base/inputs/index.js +1 -1
- package/build/esm/filter-list/base/inputs/index.js.map +1 -1
- package/build/esm/filter-list/hooks/useFilterListState.js +3 -0
- package/build/esm/filter-list/hooks/useFilterListState.js.map +1 -1
- package/build/esm/filter-list/hooks/useFilterVisibility.js +7 -1
- package/build/esm/filter-list/hooks/useFilterVisibility.js.map +1 -1
- package/build/esm/filter-list/utils/filterStateToWhereClause.js +1 -1
- package/build/esm/filter-list/utils/filterStateToWhereClause.js.map +1 -1
- package/build/esm/object-table/LoadingCell.js +2 -1
- package/build/esm/object-table/LoadingCell.js.map +1 -1
- package/build/esm/object-table/LoadingCell.module.css +3 -20
- package/build/esm/object-table/LoadingStateTable.js +2 -1
- package/build/esm/object-table/LoadingStateTable.js.map +1 -1
- package/build/esm/pdf-viewer/PdfRenderer.js +1 -1
- package/build/esm/pdf-viewer/PdfRenderer.js.map +1 -1
- package/build/esm/pdf-viewer/PdfViewer.js +59 -118
- package/build/esm/pdf-viewer/PdfViewer.js.map +1 -1
- package/build/esm/pdf-viewer/components/PdfViewerAnnotationLayer.js.map +1 -0
- package/build/esm/pdf-viewer/components/PdfViewerContent.js +113 -0
- package/build/esm/pdf-viewer/components/PdfViewerContent.js.map +1 -0
- package/build/esm/pdf-viewer/components/PdfViewerOutlineSidebar.js +98 -0
- package/build/esm/pdf-viewer/components/PdfViewerOutlineSidebar.js.map +1 -0
- package/build/esm/pdf-viewer/components/PdfViewerOutlineSidebar.module.css +89 -0
- package/build/esm/pdf-viewer/components/PdfViewerSearchBar.js.map +1 -0
- package/build/esm/pdf-viewer/{PdfViewerSidebar.js → components/PdfViewerSidebar.js} +9 -5
- package/build/esm/pdf-viewer/components/PdfViewerSidebar.js.map +1 -0
- package/build/{browser/pdf-viewer → esm/pdf-viewer/components}/PdfViewerSidebar.module.css +0 -9
- package/build/esm/pdf-viewer/components/PdfViewerSidebarHeader.js +54 -0
- package/build/esm/pdf-viewer/components/PdfViewerSidebarHeader.js.map +1 -0
- package/build/esm/pdf-viewer/components/PdfViewerSidebarHeader.module.css +70 -0
- package/build/esm/pdf-viewer/{PdfViewerThumbnail.js → components/PdfViewerThumbnail.js} +1 -1
- package/build/esm/pdf-viewer/components/PdfViewerThumbnail.js.map +1 -0
- package/build/esm/pdf-viewer/{PdfViewerToolbar.js → components/PdfViewerToolbar.js} +39 -12
- package/build/esm/pdf-viewer/components/PdfViewerToolbar.js.map +1 -0
- package/build/esm/pdf-viewer/{PdfViewerToolbar.module.css → components/PdfViewerToolbar.module.css} +2 -2
- package/build/esm/pdf-viewer/constants.js +7 -5
- package/build/esm/pdf-viewer/constants.js.map +1 -1
- package/build/esm/pdf-viewer/hooks/usePdfDocument.js +2 -3
- package/build/esm/pdf-viewer/hooks/usePdfDocument.js.map +1 -1
- package/build/esm/pdf-viewer/hooks/usePdfOutline.js +268 -0
- package/build/esm/pdf-viewer/hooks/usePdfOutline.js.map +1 -0
- package/build/esm/pdf-viewer/hooks/usePdfViewer.js +12 -1
- package/build/esm/pdf-viewer/hooks/usePdfViewer.js.map +1 -1
- package/build/esm/pdf-viewer/hooks/usePdfViewerCore.js +80 -0
- package/build/esm/pdf-viewer/hooks/usePdfViewerCore.js.map +1 -0
- package/build/esm/pdf-viewer/hooks/usePdfViewerState.js +135 -0
- package/build/esm/pdf-viewer/hooks/usePdfViewerState.js.map +1 -0
- package/build/esm/pdf-viewer/types.js.map +1 -1
- package/build/esm/public/experimental.js +21 -2
- package/build/esm/public/experimental.js.map +1 -1
- package/build/esm/public/primitives.js +20 -0
- package/build/esm/public/primitives.js.map +1 -0
- package/build/esm/{filter-list/base/inputs → shared}/dateUtils.js +38 -2
- package/build/esm/shared/dateUtils.js.map +1 -0
- package/build/types/action-form/FormFieldApi.d.ts +21 -7
- package/build/types/action-form/FormFieldApi.d.ts.map +1 -1
- package/build/types/action-form/fields/DateCalendar.d.ts +9 -0
- package/build/types/action-form/fields/DateCalendar.d.ts.map +1 -0
- package/build/types/action-form/fields/DatetimePickerField.d.ts +3 -0
- package/build/types/action-form/fields/DatetimePickerField.d.ts.map +1 -0
- package/build/types/action-form/fields/FormFieldRenderer.d.ts.map +1 -1
- package/build/types/action-form/fields/LazyDateCalendar.d.ts +3 -0
- package/build/types/action-form/fields/LazyDateCalendar.d.ts.map +1 -0
- package/build/types/filter-list/FilterListApi.d.ts +2 -1
- package/build/types/filter-list/FilterListApi.d.ts.map +1 -1
- package/build/types/filter-list/base/BaseFilterListApi.d.ts +2 -1
- package/build/types/filter-list/base/BaseFilterListApi.d.ts.map +1 -1
- package/build/types/filter-list/base/FilterListHeader.d.ts +3 -2
- package/build/types/filter-list/base/FilterListHeader.d.ts.map +1 -1
- package/build/types/filter-list/base/inputs/DateRangeInput.d.ts.map +1 -1
- package/build/types/filter-list/base/inputs/SingleDateInput.d.ts.map +1 -1
- package/build/types/filter-list/base/inputs/index.d.ts +1 -1
- package/build/types/filter-list/base/inputs/index.d.ts.map +1 -1
- package/build/types/filter-list/hooks/useFilterVisibility.d.ts +2 -0
- package/build/types/filter-list/hooks/useFilterVisibility.d.ts.map +1 -1
- package/build/types/object-table/LoadingCell.d.ts.map +1 -1
- package/build/types/object-table/LoadingStateTable.d.ts.map +1 -1
- package/build/types/pdf-viewer/PdfRenderer.d.ts +2 -2
- package/build/types/pdf-viewer/PdfRenderer.d.ts.map +1 -1
- package/build/types/pdf-viewer/PdfViewer.d.ts +1 -1
- package/build/types/pdf-viewer/PdfViewer.d.ts.map +1 -1
- package/build/types/pdf-viewer/{PdfViewerAnnotationLayer.d.ts → components/PdfViewerAnnotationLayer.d.ts} +2 -3
- package/build/types/pdf-viewer/components/PdfViewerAnnotationLayer.d.ts.map +1 -0
- package/build/types/pdf-viewer/components/PdfViewerContent.d.ts +22 -0
- package/build/types/pdf-viewer/components/PdfViewerContent.d.ts.map +1 -0
- package/build/types/pdf-viewer/components/PdfViewerOutlineSidebar.d.ts +11 -0
- package/build/types/pdf-viewer/components/PdfViewerOutlineSidebar.d.ts.map +1 -0
- package/build/types/pdf-viewer/{PdfViewerSearchBar.d.ts → components/PdfViewerSearchBar.d.ts} +1 -2
- package/build/types/pdf-viewer/components/PdfViewerSearchBar.d.ts.map +1 -0
- package/build/types/pdf-viewer/components/PdfViewerSidebar.d.ts +12 -0
- package/build/types/pdf-viewer/components/PdfViewerSidebar.d.ts.map +1 -0
- package/build/types/pdf-viewer/components/PdfViewerSidebarHeader.d.ts +7 -0
- package/build/types/pdf-viewer/components/PdfViewerSidebarHeader.d.ts.map +1 -0
- package/build/types/pdf-viewer/{PdfViewerThumbnail.d.ts.map → components/PdfViewerThumbnail.d.ts.map} +1 -1
- package/build/types/pdf-viewer/{PdfViewerToolbar.d.ts → components/PdfViewerToolbar.d.ts} +5 -3
- package/build/types/pdf-viewer/components/PdfViewerToolbar.d.ts.map +1 -0
- package/build/types/pdf-viewer/constants.d.ts +5 -0
- package/build/types/pdf-viewer/constants.d.ts.map +1 -1
- package/build/types/pdf-viewer/hooks/usePdfDocument.d.ts.map +1 -1
- package/build/types/pdf-viewer/hooks/usePdfOutline.d.ts +3 -0
- package/build/types/pdf-viewer/hooks/usePdfOutline.d.ts.map +1 -0
- package/build/types/pdf-viewer/hooks/usePdfViewer.d.ts +1 -1
- package/build/types/pdf-viewer/hooks/usePdfViewer.d.ts.map +1 -1
- package/build/types/pdf-viewer/hooks/usePdfViewerCore.d.ts +43 -0
- package/build/types/pdf-viewer/hooks/usePdfViewerCore.d.ts.map +1 -0
- package/build/types/pdf-viewer/hooks/usePdfViewerState.d.ts +39 -0
- package/build/types/pdf-viewer/hooks/usePdfViewerState.d.ts.map +1 -0
- package/build/types/pdf-viewer/types.d.ts +42 -0
- package/build/types/pdf-viewer/types.d.ts.map +1 -1
- package/build/types/public/experimental.d.ts +17 -2
- package/build/types/public/experimental.d.ts.map +1 -1
- package/build/types/public/primitives.d.ts +3 -0
- package/build/types/public/primitives.d.ts.map +1 -0
- package/build/types/shared/dateUtils.d.ts +31 -0
- package/build/types/shared/dateUtils.d.ts.map +1 -0
- package/package.json +14 -4
- package/primitives.d.ts +17 -0
- package/build/browser/filter-list/base/inputs/dateUtils.js.map +0 -1
- package/build/browser/pdf-viewer/PdfViewerAnnotationLayer.js.map +0 -1
- package/build/browser/pdf-viewer/PdfViewerAnnotationLayer.module.css.js +0 -11
- package/build/browser/pdf-viewer/PdfViewerSearchBar.js.map +0 -1
- package/build/browser/pdf-viewer/PdfViewerSearchBar.module.css.js +0 -10
- package/build/browser/pdf-viewer/PdfViewerSidebar.js.map +0 -1
- package/build/browser/pdf-viewer/PdfViewerThumbnail.js.map +0 -1
- package/build/browser/pdf-viewer/PdfViewerToolbar.js.map +0 -1
- package/build/browser/pdf-viewer/PdfViewerToolbar.module.css.js +0 -12
- package/build/esm/filter-list/base/inputs/dateUtils.js.map +0 -1
- package/build/esm/pdf-viewer/PdfViewerAnnotationLayer.js.map +0 -1
- package/build/esm/pdf-viewer/PdfViewerSearchBar.js.map +0 -1
- package/build/esm/pdf-viewer/PdfViewerSidebar.js.map +0 -1
- package/build/esm/pdf-viewer/PdfViewerThumbnail.js.map +0 -1
- package/build/esm/pdf-viewer/PdfViewerToolbar.js.map +0 -1
- package/build/types/filter-list/base/inputs/dateUtils.d.ts +0 -17
- package/build/types/filter-list/base/inputs/dateUtils.d.ts.map +0 -1
- package/build/types/pdf-viewer/PdfViewerAnnotationLayer.d.ts.map +0 -1
- package/build/types/pdf-viewer/PdfViewerSearchBar.d.ts.map +0 -1
- package/build/types/pdf-viewer/PdfViewerSidebar.d.ts +0 -10
- package/build/types/pdf-viewer/PdfViewerSidebar.d.ts.map +0 -1
- package/build/types/pdf-viewer/PdfViewerToolbar.d.ts.map +0 -1
- /package/build/browser/pdf-viewer/{PdfViewerAnnotationLayer.js → components/PdfViewerAnnotationLayer.js} +0 -0
- /package/build/browser/pdf-viewer/{PdfViewerAnnotationLayer.module.css → components/PdfViewerAnnotationLayer.module.css} +0 -0
- /package/build/browser/pdf-viewer/{PdfViewerSearchBar.js → components/PdfViewerSearchBar.js} +0 -0
- /package/build/browser/pdf-viewer/{PdfViewerSearchBar.module.css → components/PdfViewerSearchBar.module.css} +0 -0
- /package/build/browser/pdf-viewer/{PdfViewerThumbnail.module.css → components/PdfViewerThumbnail.module.css} +0 -0
- /package/build/esm/pdf-viewer/{PdfViewerAnnotationLayer.js → components/PdfViewerAnnotationLayer.js} +0 -0
- /package/build/esm/pdf-viewer/{PdfViewerAnnotationLayer.module.css → components/PdfViewerAnnotationLayer.module.css} +0 -0
- /package/build/esm/pdf-viewer/{PdfViewerSearchBar.js → components/PdfViewerSearchBar.js} +0 -0
- /package/build/esm/pdf-viewer/{PdfViewerSearchBar.module.css → components/PdfViewerSearchBar.module.css} +0 -0
- /package/build/esm/pdf-viewer/{PdfViewerThumbnail.module.css → components/PdfViewerThumbnail.module.css} +0 -0
- /package/build/types/pdf-viewer/{PdfViewerThumbnail.d.ts → components/PdfViewerThumbnail.d.ts} +0 -0
|
@@ -14,10 +14,11 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
+
import { Button } from "@base-ui/react/button";
|
|
17
18
|
import { Input } from "@base-ui/react/input";
|
|
18
|
-
import { ChevronLeft, ChevronRight, Download, Menu, Minus, Plus, Search } from "@blueprintjs/icons";
|
|
19
|
+
import { ChevronLeft, ChevronRight, Download, Menu, Minus, Plus, RotatePage, Search } from "@blueprintjs/icons";
|
|
19
20
|
import React, { useCallback, useEffect, useState } from "react";
|
|
20
|
-
import { MAX_SCALE, MIN_SCALE, SCALE_STEP } from "
|
|
21
|
+
import { MAX_SCALE, MIN_SCALE, SCALE_STEP } from "../constants.js";
|
|
21
22
|
import styles from "./PdfViewerToolbar.module.css";
|
|
22
23
|
export function PdfViewerToolbar({
|
|
23
24
|
currentPage,
|
|
@@ -28,7 +29,10 @@ export function PdfViewerToolbar({
|
|
|
28
29
|
onScaleChange,
|
|
29
30
|
onSearchOpen,
|
|
30
31
|
onSidebarToggle,
|
|
31
|
-
onDownload
|
|
32
|
+
onDownload,
|
|
33
|
+
enableDownload,
|
|
34
|
+
onRotateLeft,
|
|
35
|
+
onRotateRight
|
|
32
36
|
}) {
|
|
33
37
|
const [pageInputValue, setPageInputValue] = useState(String(currentPage));
|
|
34
38
|
|
|
@@ -77,7 +81,7 @@ export function PdfViewerToolbar({
|
|
|
77
81
|
const scalePercent = `${Math.round(scale * 100)}%`;
|
|
78
82
|
return /*#__PURE__*/React.createElement("div", {
|
|
79
83
|
className: styles.toolbar
|
|
80
|
-
}, /*#__PURE__*/React.createElement(
|
|
84
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
81
85
|
className: styles.toolbarButton,
|
|
82
86
|
onClick: onSidebarToggle,
|
|
83
87
|
"aria-label": sidebarOpen ? "Close sidebar" : "Open sidebar",
|
|
@@ -90,7 +94,7 @@ export function PdfViewerToolbar({
|
|
|
90
94
|
className: styles.separator
|
|
91
95
|
}), /*#__PURE__*/React.createElement("div", {
|
|
92
96
|
className: styles.toolbarGroup
|
|
93
|
-
}, /*#__PURE__*/React.createElement(
|
|
97
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
94
98
|
className: styles.toolbarButton,
|
|
95
99
|
onClick: handlePrevPage,
|
|
96
100
|
disabled: currentPage <= 1,
|
|
@@ -109,7 +113,7 @@ export function PdfViewerToolbar({
|
|
|
109
113
|
"aria-label": "Page number"
|
|
110
114
|
}), /*#__PURE__*/React.createElement("span", {
|
|
111
115
|
className: styles.pageCount
|
|
112
|
-
}, "of ", numPages), /*#__PURE__*/React.createElement(
|
|
116
|
+
}, "of ", numPages), /*#__PURE__*/React.createElement(Button, {
|
|
113
117
|
className: styles.toolbarButton,
|
|
114
118
|
onClick: handleNextPage,
|
|
115
119
|
disabled: currentPage >= numPages,
|
|
@@ -122,7 +126,7 @@ export function PdfViewerToolbar({
|
|
|
122
126
|
className: styles.separator
|
|
123
127
|
}), /*#__PURE__*/React.createElement("div", {
|
|
124
128
|
className: styles.toolbarGroup
|
|
125
|
-
}, /*#__PURE__*/React.createElement(
|
|
129
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
126
130
|
className: styles.toolbarButton,
|
|
127
131
|
onClick: handleZoomOut,
|
|
128
132
|
disabled: scale <= MIN_SCALE,
|
|
@@ -133,7 +137,7 @@ export function PdfViewerToolbar({
|
|
|
133
137
|
size: 16
|
|
134
138
|
})), /*#__PURE__*/React.createElement("span", {
|
|
135
139
|
className: styles.scaleDisplay
|
|
136
|
-
}, scalePercent), /*#__PURE__*/React.createElement(
|
|
140
|
+
}, scalePercent), /*#__PURE__*/React.createElement(Button, {
|
|
137
141
|
className: styles.toolbarButton,
|
|
138
142
|
onClick: handleZoomIn,
|
|
139
143
|
disabled: scale >= MAX_SCALE,
|
|
@@ -144,7 +148,30 @@ export function PdfViewerToolbar({
|
|
|
144
148
|
size: 16
|
|
145
149
|
}))), /*#__PURE__*/React.createElement("div", {
|
|
146
150
|
className: styles.separator
|
|
147
|
-
}), /*#__PURE__*/React.createElement("
|
|
151
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
152
|
+
className: styles.toolbarGroup
|
|
153
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
154
|
+
className: styles.toolbarButton,
|
|
155
|
+
onClick: onRotateLeft,
|
|
156
|
+
"aria-label": "Rotate left",
|
|
157
|
+
title: "Rotate left",
|
|
158
|
+
type: "button"
|
|
159
|
+
}, /*#__PURE__*/React.createElement(RotatePage, {
|
|
160
|
+
size: 16
|
|
161
|
+
})), /*#__PURE__*/React.createElement(Button, {
|
|
162
|
+
className: styles.toolbarButton,
|
|
163
|
+
onClick: onRotateRight,
|
|
164
|
+
"aria-label": "Rotate right",
|
|
165
|
+
title: "Rotate right",
|
|
166
|
+
type: "button"
|
|
167
|
+
}, /*#__PURE__*/React.createElement(RotatePage, {
|
|
168
|
+
size: 16,
|
|
169
|
+
style: {
|
|
170
|
+
transform: "scaleX(-1)"
|
|
171
|
+
}
|
|
172
|
+
}))), /*#__PURE__*/React.createElement("div", {
|
|
173
|
+
className: styles.separator
|
|
174
|
+
}), /*#__PURE__*/React.createElement(Button, {
|
|
148
175
|
className: styles.toolbarButton,
|
|
149
176
|
onClick: onSearchOpen,
|
|
150
177
|
"aria-label": "Search",
|
|
@@ -152,9 +179,9 @@ export function PdfViewerToolbar({
|
|
|
152
179
|
type: "button"
|
|
153
180
|
}, /*#__PURE__*/React.createElement(Search, {
|
|
154
181
|
size: 16
|
|
155
|
-
})), /*#__PURE__*/React.createElement("div", {
|
|
182
|
+
})), enableDownload && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
156
183
|
className: styles.separator
|
|
157
|
-
}), /*#__PURE__*/React.createElement(
|
|
184
|
+
}), /*#__PURE__*/React.createElement(Button, {
|
|
158
185
|
className: styles.toolbarButton,
|
|
159
186
|
onClick: onDownload,
|
|
160
187
|
"aria-label": "Download",
|
|
@@ -162,6 +189,6 @@ export function PdfViewerToolbar({
|
|
|
162
189
|
type: "button"
|
|
163
190
|
}, /*#__PURE__*/React.createElement(Download, {
|
|
164
191
|
size: 16
|
|
165
|
-
})));
|
|
192
|
+
}))));
|
|
166
193
|
}
|
|
167
194
|
//# sourceMappingURL=PdfViewerToolbar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PdfViewerToolbar.js","names":["Button","Input","ChevronLeft","ChevronRight","Download","Menu","Minus","Plus","RotatePage","Search","React","useCallback","useEffect","useState","MAX_SCALE","MIN_SCALE","SCALE_STEP","styles","PdfViewerToolbar","currentPage","numPages","scale","sidebarOpen","onPageChange","onScaleChange","onSearchOpen","onSidebarToggle","onDownload","enableDownload","onRotateLeft","onRotateRight","pageInputValue","setPageInputValue","String","handlePrevPage","newPage","handleNextPage","handlePageInputChange","e","target","value","handlePageInputKeyDown","key","page","parseInt","isNaN","handlePageInputBlur","handleZoomIn","newScale","Math","min","handleZoomOut","max","scalePercent","round","createElement","className","toolbar","toolbarButton","onClick","title","type","size","separator","toolbarGroup","disabled","pageInput","onChange","onKeyDown","onBlur","pageCount","scaleDisplay","style","transform","Fragment"],"sources":["PdfViewerToolbar.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Button } from \"@base-ui/react/button\";\nimport { Input } from \"@base-ui/react/input\";\nimport {\n ChevronLeft,\n ChevronRight,\n Download,\n Menu,\n Minus,\n Plus,\n RotatePage,\n Search,\n} from \"@blueprintjs/icons\";\nimport React, { useCallback, useEffect, useState } from \"react\";\nimport { MAX_SCALE, MIN_SCALE, SCALE_STEP } from \"../constants.js\";\nimport styles from \"./PdfViewerToolbar.module.css\";\n\nexport interface PdfViewerToolbarProps {\n currentPage: number;\n numPages: number;\n scale: number;\n sidebarOpen: boolean;\n onPageChange: (page: number) => void;\n onScaleChange: (scale: number) => void;\n onSearchOpen: () => void;\n onSidebarToggle: () => void;\n onDownload: () => void;\n enableDownload: boolean;\n onRotateLeft: () => void;\n onRotateRight: () => void;\n}\n\nexport function PdfViewerToolbar({\n currentPage,\n numPages,\n scale,\n sidebarOpen,\n onPageChange,\n onScaleChange,\n onSearchOpen,\n onSidebarToggle,\n onDownload,\n enableDownload,\n onRotateLeft,\n onRotateRight,\n}: PdfViewerToolbarProps): React.ReactElement {\n const [pageInputValue, setPageInputValue] = useState(String(currentPage));\n\n // Sync input display when currentPage changes from scrolling\n useEffect(function syncPageInput() {\n setPageInputValue(String(currentPage));\n }, [currentPage]);\n\n const handlePrevPage = useCallback(() => {\n if (currentPage > 1) {\n const newPage = currentPage - 1;\n onPageChange(newPage);\n setPageInputValue(String(newPage));\n }\n }, [currentPage, onPageChange]);\n\n const handleNextPage = useCallback(() => {\n if (currentPage < numPages) {\n const newPage = currentPage + 1;\n onPageChange(newPage);\n setPageInputValue(String(newPage));\n }\n }, [currentPage, numPages, onPageChange]);\n\n const handlePageInputChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n setPageInputValue(e.target.value);\n },\n [],\n );\n\n const handlePageInputKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (e.key === \"Enter\") {\n const page = parseInt(pageInputValue, 10);\n if (!isNaN(page) && page >= 1 && page <= numPages) {\n onPageChange(page);\n } else {\n setPageInputValue(String(currentPage));\n }\n }\n },\n [pageInputValue, numPages, onPageChange, currentPage],\n );\n\n const handlePageInputBlur = useCallback(() => {\n setPageInputValue(String(currentPage));\n }, [currentPage]);\n\n const handleZoomIn = useCallback(() => {\n const newScale = Math.min(scale + SCALE_STEP, MAX_SCALE);\n onScaleChange(newScale);\n }, [scale, onScaleChange]);\n\n const handleZoomOut = useCallback(() => {\n const newScale = Math.max(scale - SCALE_STEP, MIN_SCALE);\n onScaleChange(newScale);\n }, [scale, onScaleChange]);\n\n const scalePercent = `${Math.round(scale * 100)}%`;\n\n return (\n <div className={styles.toolbar}>\n <Button\n className={styles.toolbarButton}\n onClick={onSidebarToggle}\n aria-label={sidebarOpen ? \"Close sidebar\" : \"Open sidebar\"}\n title={sidebarOpen ? \"Close sidebar\" : \"Open sidebar\"}\n aria-pressed={sidebarOpen}\n type=\"button\"\n >\n <Menu size={16} />\n </Button>\n\n <div className={styles.separator} />\n\n <div className={styles.toolbarGroup}>\n <Button\n className={styles.toolbarButton}\n onClick={handlePrevPage}\n disabled={currentPage <= 1}\n aria-label=\"Previous page\"\n title=\"Previous page\"\n type=\"button\"\n >\n <ChevronLeft size={16} />\n </Button>\n <Input\n className={styles.pageInput}\n type=\"text\"\n value={pageInputValue}\n onChange={handlePageInputChange}\n onKeyDown={handlePageInputKeyDown}\n onBlur={handlePageInputBlur}\n aria-label=\"Page number\"\n />\n <span className={styles.pageCount}>of {numPages}</span>\n <Button\n className={styles.toolbarButton}\n onClick={handleNextPage}\n disabled={currentPage >= numPages}\n aria-label=\"Next page\"\n title=\"Next page\"\n type=\"button\"\n >\n <ChevronRight size={16} />\n </Button>\n </div>\n\n <div className={styles.separator} />\n\n <div className={styles.toolbarGroup}>\n <Button\n className={styles.toolbarButton}\n onClick={handleZoomOut}\n disabled={scale <= MIN_SCALE}\n aria-label=\"Zoom out\"\n title=\"Zoom out\"\n type=\"button\"\n >\n <Minus size={16} />\n </Button>\n <span className={styles.scaleDisplay}>{scalePercent}</span>\n <Button\n className={styles.toolbarButton}\n onClick={handleZoomIn}\n disabled={scale >= MAX_SCALE}\n aria-label=\"Zoom in\"\n title=\"Zoom in\"\n type=\"button\"\n >\n <Plus size={16} />\n </Button>\n </div>\n\n <div className={styles.separator} />\n\n <div className={styles.toolbarGroup}>\n <Button\n className={styles.toolbarButton}\n onClick={onRotateLeft}\n aria-label=\"Rotate left\"\n title=\"Rotate left\"\n type=\"button\"\n >\n <RotatePage size={16} />\n </Button>\n <Button\n className={styles.toolbarButton}\n onClick={onRotateRight}\n aria-label=\"Rotate right\"\n title=\"Rotate right\"\n type=\"button\"\n >\n <RotatePage size={16} style={{ transform: \"scaleX(-1)\" }} />\n </Button>\n </div>\n\n <div className={styles.separator} />\n\n <Button\n className={styles.toolbarButton}\n onClick={onSearchOpen}\n aria-label=\"Search\"\n title=\"Search\"\n type=\"button\"\n >\n <Search size={16} />\n </Button>\n\n {enableDownload && (\n <>\n <div className={styles.separator} />\n\n <Button\n className={styles.toolbarButton}\n onClick={onDownload}\n aria-label=\"Download\"\n title=\"Download\"\n type=\"button\"\n >\n <Download size={16} />\n </Button>\n </>\n )}\n </div>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,MAAM,QAAQ,uBAAuB;AAC9C,SAASC,KAAK,QAAQ,sBAAsB;AAC5C,SACEC,WAAW,EACXC,YAAY,EACZC,QAAQ,EACRC,IAAI,EACJC,KAAK,EACLC,IAAI,EACJC,UAAU,EACVC,MAAM,QACD,oBAAoB;AAC3B,OAAOC,KAAK,IAAIC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC/D,SAASC,SAAS,EAAEC,SAAS,EAAEC,UAAU,QAAQ,iBAAiB;AAClE,OAAOC,MAAM,MAAM,+BAA+B;AAiBlD,OAAO,SAASC,gBAAgBA,CAAC;EAC/BC,WAAW;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aAAA,CAACnD,QAAQ;IAAC0D,IAAI,EAAE;EAAG,CAAE,CACf,CACR,CAED,CAAC;AAEV","ignoreList":[]}
|
package/build/esm/pdf-viewer/{PdfViewerToolbar.module.css → components/PdfViewerToolbar.module.css}
RENAMED
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
height: 28px;
|
|
34
34
|
border: none;
|
|
35
35
|
background: none;
|
|
36
|
-
color: var(--osdk-typography-color-
|
|
36
|
+
color: var(--osdk-typography-color-muted);
|
|
37
37
|
cursor: pointer;
|
|
38
38
|
border-radius: var(--osdk-surface-border-radius);
|
|
39
39
|
padding: 0;
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
.scaleDisplay {
|
|
82
|
-
font-size: var(--osdk-typography-size-body-
|
|
82
|
+
font-size: var(--osdk-typography-size-body-small);
|
|
83
83
|
color: var(--osdk-typography-color-muted);
|
|
84
84
|
min-width: 40px;
|
|
85
85
|
text-align: center;
|
|
@@ -28,16 +28,18 @@ export const THUMBNAIL_GAP = 12;
|
|
|
28
28
|
export const THUMBNAIL_SCALE = 0.2;
|
|
29
29
|
export const DEVICE_PIXEL_RATIO = typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1;
|
|
30
30
|
|
|
31
|
+
// Outline heading extraction
|
|
32
|
+
/** Text must be at least 15% larger than the most common font size to be considered a heading. */
|
|
33
|
+
export const OUTLINE_HEADING_SIZE_RATIO = 1.15;
|
|
34
|
+
/** Headings longer than this are likely paragraphs and are filtered out. */
|
|
35
|
+
export const OUTLINE_MAX_HEADING_LENGTH = 200;
|
|
36
|
+
|
|
31
37
|
// pdfjs EventBus event names
|
|
32
38
|
export const FIND_EVENT = "find";
|
|
33
|
-
// cspell:disable-next-line -- pdfjs EventBus event name
|
|
34
39
|
export const UPDATE_FIND_CONTROL_STATE_EVENT = "updatefindcontrolstate";
|
|
35
|
-
// cspell:disable-next-line -- pdfjs EventBus event name
|
|
36
40
|
export const UPDATE_FIND_MATCHES_COUNT_EVENT = "updatefindmatchescount";
|
|
37
|
-
// cspell:disable-next-line -- pdfjs EventBus event name
|
|
38
41
|
export const PAGE_CHANGING_EVENT = "pagechanging";
|
|
39
|
-
// cspell:disable-next-line -- pdfjs EventBus event name
|
|
40
42
|
export const SCALE_CHANGING_EVENT = "scalechanging";
|
|
41
|
-
// cspell:disable-next-line -- pdfjs EventBus event name
|
|
42
43
|
export const PAGE_RENDERED_EVENT = "pagerendered";
|
|
44
|
+
export const PAGES_LOADED_EVENT = "pagesloaded";
|
|
43
45
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":["EMPTY_ANNOTATIONS","EMPTY_ANNOTATION_ARRAY","EMPTY_STRING","SCALE_STEP","MIN_SCALE","MAX_SCALE","DEFAULT_PAGE_HEIGHT","THUMBNAIL_GAP","THUMBNAIL_SCALE","DEVICE_PIXEL_RATIO","window","devicePixelRatio","FIND_EVENT","UPDATE_FIND_CONTROL_STATE_EVENT","UPDATE_FIND_MATCHES_COUNT_EVENT","PAGE_CHANGING_EVENT","SCALE_CHANGING_EVENT","PAGE_RENDERED_EVENT"],"sources":["constants.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { PdfAnnotation } from \"./types.js\";\n\n// Default empty values (stable references to avoid re-renders)\nexport const EMPTY_ANNOTATIONS: Record<number, PdfAnnotation[]> = {};\nexport const EMPTY_ANNOTATION_ARRAY: PdfAnnotation[] = [];\nexport const EMPTY_STRING = \"\";\n\n// Scale and dimension configuration\nexport const SCALE_STEP = 0.25;\nexport const MIN_SCALE = 0.25;\nexport const MAX_SCALE = 5.0;\nexport const DEFAULT_PAGE_HEIGHT = 792;\nexport const THUMBNAIL_GAP = 12;\nexport const THUMBNAIL_SCALE = 0.2;\nexport const DEVICE_PIXEL_RATIO: number = typeof window !== \"undefined\"\n ? window.devicePixelRatio || 1\n : 1;\n\n//
|
|
1
|
+
{"version":3,"file":"constants.js","names":["EMPTY_ANNOTATIONS","EMPTY_ANNOTATION_ARRAY","EMPTY_STRING","SCALE_STEP","MIN_SCALE","MAX_SCALE","DEFAULT_PAGE_HEIGHT","THUMBNAIL_GAP","THUMBNAIL_SCALE","DEVICE_PIXEL_RATIO","window","devicePixelRatio","OUTLINE_HEADING_SIZE_RATIO","OUTLINE_MAX_HEADING_LENGTH","FIND_EVENT","UPDATE_FIND_CONTROL_STATE_EVENT","UPDATE_FIND_MATCHES_COUNT_EVENT","PAGE_CHANGING_EVENT","SCALE_CHANGING_EVENT","PAGE_RENDERED_EVENT","PAGES_LOADED_EVENT"],"sources":["constants.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { PdfAnnotation } from \"./types.js\";\n\n// Default empty values (stable references to avoid re-renders)\nexport const EMPTY_ANNOTATIONS: Record<number, PdfAnnotation[]> = {};\nexport const EMPTY_ANNOTATION_ARRAY: PdfAnnotation[] = [];\nexport const EMPTY_STRING = \"\";\n\n// Scale and dimension configuration\nexport const SCALE_STEP = 0.25;\nexport const MIN_SCALE = 0.25;\nexport const MAX_SCALE = 5.0;\nexport const DEFAULT_PAGE_HEIGHT = 792;\nexport const THUMBNAIL_GAP = 12;\nexport const THUMBNAIL_SCALE = 0.2;\nexport const DEVICE_PIXEL_RATIO: number = typeof window !== \"undefined\"\n ? window.devicePixelRatio || 1\n : 1;\n\n// Outline heading extraction\n/** Text must be at least 15% larger than the most common font size to be considered a heading. */\nexport const OUTLINE_HEADING_SIZE_RATIO = 1.15;\n/** Headings longer than this are likely paragraphs and are filtered out. */\nexport const OUTLINE_MAX_HEADING_LENGTH = 200;\n\n// pdfjs EventBus event names\nexport const FIND_EVENT = \"find\";\nexport const UPDATE_FIND_CONTROL_STATE_EVENT = \"updatefindcontrolstate\";\nexport const UPDATE_FIND_MATCHES_COUNT_EVENT = \"updatefindmatchescount\";\nexport const PAGE_CHANGING_EVENT = \"pagechanging\";\nexport const SCALE_CHANGING_EVENT = \"scalechanging\";\nexport const PAGE_RENDERED_EVENT = \"pagerendered\";\nexport const PAGES_LOADED_EVENT = \"pagesloaded\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;AACA,OAAO,MAAMA,iBAAkD,GAAG,CAAC,CAAC;AACpE,OAAO,MAAMC,sBAAuC,GAAG,EAAE;AACzD,OAAO,MAAMC,YAAY,GAAG,EAAE;;AAE9B;AACA,OAAO,MAAMC,UAAU,GAAG,IAAI;AAC9B,OAAO,MAAMC,SAAS,GAAG,IAAI;AAC7B,OAAO,MAAMC,SAAS,GAAG,GAAG;AAC5B,OAAO,MAAMC,mBAAmB,GAAG,GAAG;AACtC,OAAO,MAAMC,aAAa,GAAG,EAAE;AAC/B,OAAO,MAAMC,eAAe,GAAG,GAAG;AAClC,OAAO,MAAMC,kBAA0B,GAAG,OAAOC,MAAM,KAAK,WAAW,GACnEA,MAAM,CAACC,gBAAgB,IAAI,CAAC,GAC5B,CAAC;;AAEL;AACA;AACA,OAAO,MAAMC,0BAA0B,GAAG,IAAI;AAC9C;AACA,OAAO,MAAMC,0BAA0B,GAAG,GAAG;;AAE7C;AACA,OAAO,MAAMC,UAAU,GAAG,MAAM;AAChC,OAAO,MAAMC,+BAA+B,GAAG,wBAAwB;AACvE,OAAO,MAAMC,+BAA+B,GAAG,wBAAwB;AACvE,OAAO,MAAMC,mBAAmB,GAAG,cAAc;AACjD,OAAO,MAAMC,oBAAoB,GAAG,eAAe;AACnD,OAAO,MAAMC,mBAAmB,GAAG,cAAc;AACjD,OAAO,MAAMC,kBAAkB,GAAG,aAAa","ignoreList":[]}
|
|
@@ -15,13 +15,12 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import { getDocument, GlobalWorkerOptions } from "pdfjs-dist";
|
|
18
|
-
|
|
19
|
-
import pdfWorkerUrl from "pdfjs-dist/build/pdf.worker.min.mjs?url";
|
|
18
|
+
const pdfWorkerUrl = new URL("pdfjs-dist/build/pdf.worker.min.mjs", import.meta.url);
|
|
20
19
|
import { useEffect, useState } from "react";
|
|
21
20
|
const pdfWorker = {
|
|
22
21
|
workerInitialized: false,
|
|
23
22
|
ensureWorker() {
|
|
24
|
-
GlobalWorkerOptions.workerSrc = pdfWorkerUrl;
|
|
23
|
+
GlobalWorkerOptions.workerSrc = pdfWorkerUrl.href;
|
|
25
24
|
this.workerInitialized = true;
|
|
26
25
|
}
|
|
27
26
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePdfDocument.js","names":["getDocument","GlobalWorkerOptions","pdfWorkerUrl","useEffect","useState","pdfWorker","workerInitialized","ensureWorker","workerSrc","usePdfDocument","src","document","setDocument","undefined","numPages","setNumPages","loading","setLoading","error","setError","loadingTask","
|
|
1
|
+
{"version":3,"file":"usePdfDocument.js","names":["getDocument","GlobalWorkerOptions","pdfWorkerUrl","URL","import","meta","url","useEffect","useState","pdfWorker","workerInitialized","ensureWorker","workerSrc","href","usePdfDocument","src","document","setDocument","undefined","numPages","setNumPages","loading","setLoading","error","setError","loadingTask","data","cancelled","promise","then","pdf","err","Error","String","destroy"],"sources":["usePdfDocument.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { PDFDocumentProxy } from \"pdfjs-dist\";\nimport { getDocument, GlobalWorkerOptions } from \"pdfjs-dist\";\nconst pdfWorkerUrl = new URL(\n \"pdfjs-dist/build/pdf.worker.min.mjs\",\n import.meta.url,\n);\nimport { useEffect, useState } from \"react\";\n\nconst pdfWorker = {\n workerInitialized: false,\n ensureWorker() {\n GlobalWorkerOptions.workerSrc = pdfWorkerUrl.href;\n this.workerInitialized = true;\n },\n};\n\ninterface UsePdfDocumentResult {\n document: PDFDocumentProxy | undefined;\n numPages: number;\n loading: boolean;\n error: Error | undefined;\n}\n\nexport function usePdfDocument(\n src: string | ArrayBuffer,\n): UsePdfDocumentResult {\n const [document, setDocument] = useState<PDFDocumentProxy | undefined>(\n undefined,\n );\n const [numPages, setNumPages] = useState(0);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | undefined>(undefined);\n\n useEffect(function loadPdfDocument() {\n pdfWorker.ensureWorker();\n setLoading(true);\n setError(undefined);\n\n const loadingTask = getDocument(\n typeof src === \"string\" ? { url: src } : { data: src },\n );\n\n let cancelled = false;\n\n loadingTask.promise.then(\n (pdf) => {\n if (!cancelled) {\n setDocument(pdf);\n setNumPages(pdf.numPages);\n setLoading(false);\n }\n },\n (err: unknown) => {\n if (!cancelled) {\n setError(\n err instanceof Error ? err : new Error(String(err)),\n );\n setLoading(false);\n }\n },\n );\n\n return () => {\n cancelled = true;\n void loadingTask.destroy();\n };\n }, [src]);\n\n return { document, numPages, loading, error };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,WAAW,EAAEC,mBAAmB,QAAQ,YAAY;AAC7D,MAAMC,YAAY,GAAG,IAAIC,GAAG,CAC1B,qCAAqC,EACrCC,MAAM,CAACC,IAAI,CAACC,GACd,CAAC;AACD,SAASC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAE3C,MAAMC,SAAS,GAAG;EAChBC,iBAAiB,EAAE,KAAK;EACxBC,YAAYA,CAAA,EAAG;IACbV,mBAAmB,CAACW,SAAS,GAAGV,YAAY,CAACW,IAAI;IACjD,IAAI,CAACH,iBAAiB,GAAG,IAAI;EAC/B;AACF,CAAC;AASD,OAAO,SAASI,cAAcA,CAC5BC,GAAyB,EACH;EACtB,MAAM,CAACC,QAAQ,EAAEC,WAAW,CAAC,GAAGT,QAAQ,CACtCU,SACF,CAAC;EACD,MAAM,CAACC,QAAQ,EAAEC,WAAW,CAAC,GAAGZ,QAAQ,CAAC,CAAC,CAAC;EAC3C,MAAM,CAACa,OAAO,EAAEC,UAAU,CAAC,GAAGd,QAAQ,CAAC,IAAI,CAAC;EAC5C,MAAM,CAACe,KAAK,EAAEC,QAAQ,CAAC,GAAGhB,QAAQ,CAAoBU,SAAS,CAAC;EAEhEX,SAAS,CAAC,YAA2B;IACnCE,SAAS,CAACE,YAAY,CAAC,CAAC;IACxBW,UAAU,CAAC,IAAI,CAAC;IAChBE,QAAQ,CAACN,SAAS,CAAC;IAEnB,MAAMO,WAAW,GAAGzB,WAAW,CAC7B,OAAOe,GAAG,KAAK,QAAQ,GAAG;MAAET,GAAG,EAAES;IAAI,CAAC,GAAG;MAAEW,IAAI,EAAEX;IAAI,CACvD,CAAC;IAED,IAAIY,SAAS,GAAG,KAAK;IAErBF,WAAW,CAACG,OAAO,CAACC,IAAI,CACrBC,GAAG,IAAK;MACP,IAAI,CAACH,SAAS,EAAE;QACdV,WAAW,CAACa,GAAG,CAAC;QAChBV,WAAW,CAACU,GAAG,CAACX,QAAQ,CAAC;QACzBG,UAAU,CAAC,KAAK,CAAC;MACnB;IACF,CAAC,EACAS,GAAY,IAAK;MAChB,IAAI,CAACJ,SAAS,EAAE;QACdH,QAAQ,CACNO,GAAG,YAAYC,KAAK,GAAGD,GAAG,GAAG,IAAIC,KAAK,CAACC,MAAM,CAACF,GAAG,CAAC,CACpD,CAAC;QACDT,UAAU,CAAC,KAAK,CAAC;MACnB;IACF,CACF,CAAC;IAED,OAAO,MAAM;MACXK,SAAS,GAAG,IAAI;MAChB,KAAKF,WAAW,CAACS,OAAO,CAAC,CAAC;IAC5B,CAAC;EACH,CAAC,EAAE,CAACnB,GAAG,CAAC,CAAC;EAET,OAAO;IAAEC,QAAQ;IAAEG,QAAQ;IAAEE,OAAO;IAAEE;EAAM,CAAC;AAC/C","ignoreList":[]}
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { useEffect, useState } from "react";
|
|
18
|
+
import { OUTLINE_HEADING_SIZE_RATIO, OUTLINE_MAX_HEADING_LENGTH } from "../constants.js";
|
|
19
|
+
const EMPTY_OUTLINE = [];
|
|
20
|
+
export function usePdfOutline(document) {
|
|
21
|
+
const [outlineItems, setOutlineItems] = useState(EMPTY_OUTLINE);
|
|
22
|
+
useEffect(function () {
|
|
23
|
+
if (document == null) {
|
|
24
|
+
setOutlineItems(EMPTY_OUTLINE);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
let cancelled = false;
|
|
28
|
+
void (async () => {
|
|
29
|
+
try {
|
|
30
|
+
// Try embedded bookmarks first
|
|
31
|
+
const outline = await document.getOutline();
|
|
32
|
+
if (cancelled) return;
|
|
33
|
+
if (outline != null && outline.length > 0) {
|
|
34
|
+
const items = await resolveBookmarkOutline(document, outline);
|
|
35
|
+
if (!cancelled) {
|
|
36
|
+
setOutlineItems(items);
|
|
37
|
+
}
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Fall back to extracting headings from text content
|
|
42
|
+
const items = await extractHeadingsFromText(document);
|
|
43
|
+
if (!cancelled) {
|
|
44
|
+
setOutlineItems(items.length > 0 ? items : EMPTY_OUTLINE);
|
|
45
|
+
}
|
|
46
|
+
} catch {
|
|
47
|
+
// If extraction fails entirely, leave outline empty
|
|
48
|
+
if (!cancelled) {
|
|
49
|
+
setOutlineItems(EMPTY_OUTLINE);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
})();
|
|
53
|
+
return () => {
|
|
54
|
+
cancelled = true;
|
|
55
|
+
};
|
|
56
|
+
}, [document]);
|
|
57
|
+
return outlineItems;
|
|
58
|
+
}
|
|
59
|
+
async function resolveBookmarkOutline(document, outline) {
|
|
60
|
+
const items = [];
|
|
61
|
+
const resolveItems = async (nodes, depth) => {
|
|
62
|
+
for (const node of nodes) {
|
|
63
|
+
let pageNumber = 1;
|
|
64
|
+
try {
|
|
65
|
+
if (typeof node.dest === "string") {
|
|
66
|
+
const dest = await document.getDestination(node.dest);
|
|
67
|
+
if (dest != null) {
|
|
68
|
+
const pageIndex = await document.getPageIndex(dest[0]);
|
|
69
|
+
pageNumber = pageIndex + 1;
|
|
70
|
+
}
|
|
71
|
+
} else if (Array.isArray(node.dest) && node.dest.length > 0) {
|
|
72
|
+
const pageIndex = await document.getPageIndex(node.dest[0]);
|
|
73
|
+
pageNumber = pageIndex + 1;
|
|
74
|
+
}
|
|
75
|
+
} catch {
|
|
76
|
+
// If destination resolution fails, default to page 1
|
|
77
|
+
}
|
|
78
|
+
items.push({
|
|
79
|
+
title: node.title,
|
|
80
|
+
depth,
|
|
81
|
+
pageNumber,
|
|
82
|
+
bold: node.bold,
|
|
83
|
+
italic: node.italic
|
|
84
|
+
});
|
|
85
|
+
if (node.items.length > 0) {
|
|
86
|
+
await resolveItems(node.items, depth + 1);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
await resolveItems(outline, 0);
|
|
91
|
+
return items;
|
|
92
|
+
}
|
|
93
|
+
function isTextItem(item) {
|
|
94
|
+
return "str" in item && "transform" in item;
|
|
95
|
+
}
|
|
96
|
+
function roundFontSize(size) {
|
|
97
|
+
return Math.round(size * 10) / 10;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Extract the font size from a pdfjs TextItem.
|
|
102
|
+
* Prefer `height` when available, otherwise derive from the transform matrix.
|
|
103
|
+
* The transform is [scaleX, skewY, skewX, scaleY, translateX, translateY].
|
|
104
|
+
* Font size = sqrt(skewX² + scaleY²), which handles rotated text too.
|
|
105
|
+
*/
|
|
106
|
+
function getFontSize(item) {
|
|
107
|
+
if (item.height > 0) {
|
|
108
|
+
return item.height;
|
|
109
|
+
}
|
|
110
|
+
const transform = item.transform;
|
|
111
|
+
if (Array.isArray(transform) && transform.length >= 4) {
|
|
112
|
+
return Math.sqrt(transform[2] * transform[2] + transform[3] * transform[3]);
|
|
113
|
+
}
|
|
114
|
+
return 0;
|
|
115
|
+
}
|
|
116
|
+
async function extractHeadingsFromText(document) {
|
|
117
|
+
const numPages = document.numPages;
|
|
118
|
+
|
|
119
|
+
// Fetch all pages' text content in parallel
|
|
120
|
+
const pageContents = await Promise.all(Array.from({
|
|
121
|
+
length: numPages
|
|
122
|
+
}, (_, i) => document.getPage(i + 1).then(page => page.getTextContent())));
|
|
123
|
+
|
|
124
|
+
// Collect font size frequencies across all pages
|
|
125
|
+
const sizeCounts = new Map();
|
|
126
|
+
for (const textContent of pageContents) {
|
|
127
|
+
for (const rawItem of textContent.items) {
|
|
128
|
+
const item = rawItem;
|
|
129
|
+
if (!isTextItem(item) || item.str.trim().length === 0) {
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
const fontSize = getFontSize(item);
|
|
133
|
+
if (fontSize > 0) {
|
|
134
|
+
const rounded = roundFontSize(fontSize);
|
|
135
|
+
sizeCounts.set(rounded, (sizeCounts.get(rounded) ?? 0) + 1);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Find the most common font size (body text)
|
|
141
|
+
let bodySize = 0;
|
|
142
|
+
let maxCount = 0;
|
|
143
|
+
for (const [size, count] of sizeCounts) {
|
|
144
|
+
if (count > maxCount) {
|
|
145
|
+
maxCount = count;
|
|
146
|
+
bodySize = size;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (bodySize === 0) {
|
|
150
|
+
return [];
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Heading threshold: text significantly larger than body text
|
|
154
|
+
const headingThreshold = bodySize * OUTLINE_HEADING_SIZE_RATIO;
|
|
155
|
+
|
|
156
|
+
// Collect all unique heading sizes above threshold
|
|
157
|
+
const headingSizes = new Set();
|
|
158
|
+
for (const [size] of sizeCounts) {
|
|
159
|
+
if (size >= headingThreshold) {
|
|
160
|
+
headingSizes.add(size);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (headingSizes.size === 0) {
|
|
164
|
+
return [];
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Sort heading sizes descending (largest = depth 0)
|
|
168
|
+
const sortedSizes = [...headingSizes].sort((a, b) => b - a);
|
|
169
|
+
const sizeToDepth = new Map();
|
|
170
|
+
for (let i = 0; i < sortedSizes.length; i++) {
|
|
171
|
+
sizeToDepth.set(sortedSizes[i], i);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// Extract headings with page numbers.
|
|
175
|
+
// pdfjs splits visual lines into multiple TextItems (e.g. "1." and
|
|
176
|
+
// "Introduction" are separate items). We accumulate all items on the
|
|
177
|
+
// same visual line and treat the line as a heading if most of its
|
|
178
|
+
// content is at a heading font size.
|
|
179
|
+
const candidateHeadings = [];
|
|
180
|
+
for (let pageIdx = 0; pageIdx < pageContents.length; pageIdx++) {
|
|
181
|
+
const textContent = pageContents[pageIdx];
|
|
182
|
+
const pageNumber = pageIdx + 1;
|
|
183
|
+
let lineItems = [];
|
|
184
|
+
let linePageNumber = pageNumber;
|
|
185
|
+
let lineFontName = "";
|
|
186
|
+
let lineHeadingFontSize = 0;
|
|
187
|
+
let lastFlushWasHeading = false;
|
|
188
|
+
const flushLine = () => {
|
|
189
|
+
if (lineItems.length === 0) return;
|
|
190
|
+
|
|
191
|
+
// Check if the majority of the line's non-whitespace content is heading-sized
|
|
192
|
+
let headingChars = 0;
|
|
193
|
+
let totalChars = 0;
|
|
194
|
+
for (const li of lineItems) {
|
|
195
|
+
const len = li.text.trim().length;
|
|
196
|
+
totalChars += len;
|
|
197
|
+
if (sizeToDepth.has(roundFontSize(li.fontSize))) {
|
|
198
|
+
headingChars += len;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
if (totalChars > 0 && headingChars / totalChars > 0.5) {
|
|
202
|
+
const fullText = lineItems.map(li => li.text).join("").trim();
|
|
203
|
+
if (fullText.length > 0) {
|
|
204
|
+
candidateHeadings.push({
|
|
205
|
+
text: fullText,
|
|
206
|
+
fontSize: lineHeadingFontSize,
|
|
207
|
+
pageNumber: linePageNumber,
|
|
208
|
+
fontName: lineFontName,
|
|
209
|
+
contiguous: lastFlushWasHeading
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
lastFlushWasHeading = true;
|
|
213
|
+
} else {
|
|
214
|
+
lastFlushWasHeading = false;
|
|
215
|
+
}
|
|
216
|
+
lineItems = [];
|
|
217
|
+
lineHeadingFontSize = 0;
|
|
218
|
+
};
|
|
219
|
+
for (const rawItem of textContent.items) {
|
|
220
|
+
const item = rawItem;
|
|
221
|
+
if (!isTextItem(item)) {
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
const fontSize = getFontSize(item);
|
|
225
|
+
const rounded = roundFontSize(fontSize);
|
|
226
|
+
const isHeadingSized = sizeToDepth.has(rounded);
|
|
227
|
+
if (isHeadingSized && lineHeadingFontSize === 0) {
|
|
228
|
+
lineHeadingFontSize = rounded;
|
|
229
|
+
linePageNumber = pageNumber;
|
|
230
|
+
lineFontName = item.fontName;
|
|
231
|
+
}
|
|
232
|
+
if (lineHeadingFontSize > 0) {
|
|
233
|
+
lineItems.push({
|
|
234
|
+
text: item.str,
|
|
235
|
+
fontSize
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
if (item.hasEOL) {
|
|
239
|
+
flushLine();
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// Flush remaining items at end of page
|
|
244
|
+
flushLine();
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// Merge consecutive heading lines that were contiguous (no body text between them)
|
|
248
|
+
// and at the same font size. This joins multi-line titles that wrap in the PDF.
|
|
249
|
+
const mergedHeadings = [];
|
|
250
|
+
for (const heading of candidateHeadings) {
|
|
251
|
+
const prev = mergedHeadings[mergedHeadings.length - 1];
|
|
252
|
+
if (prev != null && heading.contiguous && Math.abs(prev.fontSize - heading.fontSize) < 0.1) {
|
|
253
|
+
prev.text += " " + heading.text;
|
|
254
|
+
} else {
|
|
255
|
+
mergedHeadings.push({
|
|
256
|
+
...heading
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
return mergedHeadings.filter(heading => heading.text.trim().length <= OUTLINE_MAX_HEADING_LENGTH).map(heading => ({
|
|
261
|
+
title: heading.text.trim(),
|
|
262
|
+
depth: sizeToDepth.get(heading.fontSize) ?? 0,
|
|
263
|
+
pageNumber: heading.pageNumber,
|
|
264
|
+
bold: false,
|
|
265
|
+
italic: false
|
|
266
|
+
}));
|
|
267
|
+
}
|
|
268
|
+
//# sourceMappingURL=usePdfOutline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePdfOutline.js","names":["useEffect","useState","OUTLINE_HEADING_SIZE_RATIO","OUTLINE_MAX_HEADING_LENGTH","EMPTY_OUTLINE","usePdfOutline","document","outlineItems","setOutlineItems","cancelled","outline","getOutline","length","items","resolveBookmarkOutline","extractHeadingsFromText","resolveItems","nodes","depth","node","pageNumber","dest","getDestination","pageIndex","getPageIndex","Array","isArray","push","title","bold","italic","isTextItem","item","roundFontSize","size","Math","round","getFontSize","height","transform","sqrt","numPages","pageContents","Promise","all","from","_","i","getPage","then","page","getTextContent","sizeCounts","Map","textContent","rawItem","str","trim","fontSize","rounded","set","get","bodySize","maxCount","count","headingThreshold","headingSizes","Set","add","sortedSizes","sort","a","b","sizeToDepth","candidateHeadings","pageIdx","lineItems","linePageNumber","lineFontName","lineHeadingFontSize","lastFlushWasHeading","flushLine","headingChars","totalChars","li","len","text","has","fullText","map","join","fontName","contiguous","isHeadingSized","hasEOL","mergedHeadings","heading","prev","abs","filter"],"sources":["usePdfOutline.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { PDFDocumentProxy } from \"pdfjs-dist\";\nimport { useEffect, useState } from \"react\";\nimport {\n OUTLINE_HEADING_SIZE_RATIO,\n OUTLINE_MAX_HEADING_LENGTH,\n} from \"../constants.js\";\nimport type { OutlineItem } from \"../types.js\";\n\nconst EMPTY_OUTLINE: OutlineItem[] = [];\n\nexport function usePdfOutline(\n document: PDFDocumentProxy | undefined,\n): OutlineItem[] {\n const [outlineItems, setOutlineItems] = useState<OutlineItem[]>(\n EMPTY_OUTLINE,\n );\n\n useEffect(\n function loadOutline() {\n if (document == null) {\n setOutlineItems(EMPTY_OUTLINE);\n return;\n }\n\n let cancelled = false;\n\n void (async () => {\n try {\n // Try embedded bookmarks first\n const outline = await document.getOutline();\n if (cancelled) return;\n\n if (outline != null && outline.length > 0) {\n const items = await resolveBookmarkOutline(document, outline);\n if (!cancelled) {\n setOutlineItems(items);\n }\n return;\n }\n\n // Fall back to extracting headings from text content\n const items = await extractHeadingsFromText(document);\n if (!cancelled) {\n setOutlineItems(items.length > 0 ? items : EMPTY_OUTLINE);\n }\n } catch {\n // If extraction fails entirely, leave outline empty\n if (!cancelled) {\n setOutlineItems(EMPTY_OUTLINE);\n }\n }\n })();\n\n return () => {\n cancelled = true;\n };\n },\n [document],\n );\n\n return outlineItems;\n}\n\ntype BookmarkNode = Awaited<ReturnType<PDFDocumentProxy[\"getOutline\"]>>[number];\n\nasync function resolveBookmarkOutline(\n document: PDFDocumentProxy,\n outline: BookmarkNode[],\n): Promise<OutlineItem[]> {\n const items: OutlineItem[] = [];\n\n const resolveItems = async (\n nodes: BookmarkNode[],\n depth: number,\n ): Promise<void> => {\n for (const node of nodes) {\n let pageNumber = 1;\n try {\n if (typeof node.dest === \"string\") {\n const dest = await document.getDestination(node.dest);\n if (dest != null) {\n const pageIndex = await document.getPageIndex(dest[0]);\n pageNumber = pageIndex + 1;\n }\n } else if (Array.isArray(node.dest) && node.dest.length > 0) {\n const pageIndex = await document.getPageIndex(node.dest[0]);\n pageNumber = pageIndex + 1;\n }\n } catch {\n // If destination resolution fails, default to page 1\n }\n\n items.push({\n title: node.title,\n depth,\n pageNumber,\n bold: node.bold,\n italic: node.italic,\n });\n\n if (node.items.length > 0) {\n await resolveItems(node.items, depth + 1);\n }\n }\n };\n\n await resolveItems(outline, 0);\n return items;\n}\n\ninterface RawHeading {\n text: string;\n fontSize: number;\n pageNumber: number;\n fontName: string;\n /** True if this heading line immediately followed another heading line (no body text in between). */\n contiguous: boolean;\n}\n\ninterface TextItemLike {\n str: string;\n height: number;\n fontName: string;\n transform: number[];\n hasEOL: boolean;\n}\n\nfunction isTextItem(\n item: Record<string, unknown>,\n): item is Record<string, unknown> & TextItemLike {\n return \"str\" in item && \"transform\" in item;\n}\n\nfunction roundFontSize(size: number): number {\n return Math.round(size * 10) / 10;\n}\n\n/**\n * Extract the font size from a pdfjs TextItem.\n * Prefer `height` when available, otherwise derive from the transform matrix.\n * The transform is [scaleX, skewY, skewX, scaleY, translateX, translateY].\n * Font size = sqrt(skewX² + scaleY²), which handles rotated text too.\n */\nfunction getFontSize(item: TextItemLike): number {\n if (item.height > 0) {\n return item.height;\n }\n const transform = item.transform;\n if (Array.isArray(transform) && transform.length >= 4) {\n return Math.sqrt(\n (transform[2]) * (transform[2])\n + (transform[3]) * (transform[3]),\n );\n }\n return 0;\n}\n\nasync function extractHeadingsFromText(\n document: PDFDocumentProxy,\n): Promise<OutlineItem[]> {\n const numPages = document.numPages;\n\n // Fetch all pages' text content in parallel\n const pageContents = await Promise.all(\n Array.from(\n { length: numPages },\n (_, i) => document.getPage(i + 1).then(page => page.getTextContent()),\n ),\n );\n\n // Collect font size frequencies across all pages\n const sizeCounts = new Map<number, number>();\n for (const textContent of pageContents) {\n for (const rawItem of textContent.items) {\n const item = rawItem as Record<string, unknown>;\n if (!isTextItem(item) || item.str.trim().length === 0) {\n continue;\n }\n const fontSize = getFontSize(item);\n if (fontSize > 0) {\n const rounded = roundFontSize(fontSize);\n sizeCounts.set(rounded, (sizeCounts.get(rounded) ?? 0) + 1);\n }\n }\n }\n\n // Find the most common font size (body text)\n let bodySize = 0;\n let maxCount = 0;\n for (const [size, count] of sizeCounts) {\n if (count > maxCount) {\n maxCount = count;\n bodySize = size;\n }\n }\n\n if (bodySize === 0) {\n return [];\n }\n\n // Heading threshold: text significantly larger than body text\n const headingThreshold = bodySize * OUTLINE_HEADING_SIZE_RATIO;\n\n // Collect all unique heading sizes above threshold\n const headingSizes = new Set<number>();\n for (const [size] of sizeCounts) {\n if (size >= headingThreshold) {\n headingSizes.add(size);\n }\n }\n\n if (headingSizes.size === 0) {\n return [];\n }\n\n // Sort heading sizes descending (largest = depth 0)\n const sortedSizes = [...headingSizes].sort((a, b) => b - a);\n const sizeToDepth = new Map<number, number>();\n for (let i = 0; i < sortedSizes.length; i++) {\n sizeToDepth.set(sortedSizes[i], i);\n }\n\n // Extract headings with page numbers.\n // pdfjs splits visual lines into multiple TextItems (e.g. \"1.\" and\n // \"Introduction\" are separate items). We accumulate all items on the\n // same visual line and treat the line as a heading if most of its\n // content is at a heading font size.\n const candidateHeadings: RawHeading[] = [];\n\n for (let pageIdx = 0; pageIdx < pageContents.length; pageIdx++) {\n const textContent = pageContents[pageIdx];\n const pageNumber = pageIdx + 1;\n\n let lineItems: Array<{ text: string; fontSize: number }> = [];\n let linePageNumber = pageNumber;\n let lineFontName = \"\";\n let lineHeadingFontSize = 0;\n let lastFlushWasHeading = false;\n\n const flushLine = (): void => {\n if (lineItems.length === 0) return;\n\n // Check if the majority of the line's non-whitespace content is heading-sized\n let headingChars = 0;\n let totalChars = 0;\n for (const li of lineItems) {\n const len = li.text.trim().length;\n totalChars += len;\n if (sizeToDepth.has(roundFontSize(li.fontSize))) {\n headingChars += len;\n }\n }\n\n if (totalChars > 0 && headingChars / totalChars > 0.5) {\n const fullText = lineItems.map((li) => li.text).join(\"\").trim();\n if (fullText.length > 0) {\n candidateHeadings.push({\n text: fullText,\n fontSize: lineHeadingFontSize,\n pageNumber: linePageNumber,\n fontName: lineFontName,\n contiguous: lastFlushWasHeading,\n });\n }\n lastFlushWasHeading = true;\n } else {\n lastFlushWasHeading = false;\n }\n\n lineItems = [];\n lineHeadingFontSize = 0;\n };\n\n for (const rawItem of textContent.items) {\n const item = rawItem as Record<string, unknown>;\n if (!isTextItem(item)) {\n continue;\n }\n\n const fontSize = getFontSize(item);\n const rounded = roundFontSize(fontSize);\n const isHeadingSized = sizeToDepth.has(rounded);\n\n if (isHeadingSized && lineHeadingFontSize === 0) {\n lineHeadingFontSize = rounded;\n linePageNumber = pageNumber;\n lineFontName = item.fontName;\n }\n\n if (lineHeadingFontSize > 0) {\n lineItems.push({ text: item.str, fontSize });\n }\n\n if (item.hasEOL) {\n flushLine();\n }\n }\n\n // Flush remaining items at end of page\n flushLine();\n }\n\n // Merge consecutive heading lines that were contiguous (no body text between them)\n // and at the same font size. This joins multi-line titles that wrap in the PDF.\n const mergedHeadings: RawHeading[] = [];\n for (const heading of candidateHeadings) {\n const prev = mergedHeadings[mergedHeadings.length - 1];\n if (\n prev != null\n && heading.contiguous\n && Math.abs(prev.fontSize - heading.fontSize) < 0.1\n ) {\n prev.text += \" \" + heading.text;\n } else {\n mergedHeadings.push({ ...heading });\n }\n }\n\n return mergedHeadings\n .filter((heading) =>\n heading.text.trim().length <= OUTLINE_MAX_HEADING_LENGTH\n )\n .map((heading) => ({\n title: heading.text.trim(),\n depth: sizeToDepth.get(heading.fontSize) ?? 0,\n pageNumber: heading.pageNumber,\n bold: false,\n italic: false,\n }));\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,SACEC,0BAA0B,EAC1BC,0BAA0B,QACrB,iBAAiB;AAGxB,MAAMC,aAA4B,GAAG,EAAE;AAEvC,OAAO,SAASC,aAAaA,CAC3BC,QA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iB,EAAE;IACvC,MAAMuB,IAAI,GAAGF,cAAc,CAACA,cAAc,CAACnF,MAAM,GAAG,CAAC,CAAC;IACtD,IACEqF,IAAI,IAAI,IAAI,IACTD,OAAO,CAACJ,UAAU,IAClBzD,IAAI,CAAC+D,GAAG,CAACD,IAAI,CAACvC,QAAQ,GAAGsC,OAAO,CAACtC,QAAQ,CAAC,GAAG,GAAG,EACnD;MACAuC,IAAI,CAACX,IAAI,IAAI,GAAG,GAAGU,OAAO,CAACV,IAAI;IACjC,CAAC,MAAM;MACLS,cAAc,CAACpE,IAAI,CAAC;QAAE,GAAGqE;MAAQ,CAAC,CAAC;IACrC;EACF;EAEA,OAAOD,cAAc,CAClBI,MAAM,CAAEH,OAAO,IACdA,OAAO,CAACV,IAAI,CAAC7B,IAAI,CAAC,CAAC,CAAC7C,MAAM,IAAIT,0BAChC,CAAC,CACAsF,GAAG,CAAEO,OAAO,KAAM;IACjBpE,KAAK,EAAEoE,OAAO,CAACV,IAAI,CAAC7B,IAAI,CAAC,CAAC;IAC1BvC,KAAK,EAAEuD,WAAW,CAACZ,GAAG,CAACmC,OAAO,CAACtC,QAAQ,CAAC,IAAI,CAAC;IAC7CtC,UAAU,EAAE4E,OAAO,CAAC5E,UAAU;IAC9BS,IAAI,EAAE,KAAK;IACXC,MAAM,EAAE;EACV,CAAC,CAAC,CAAC;AACP","ignoreList":[]}
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
|
|
17
17
|
import { EventBus, PDFFindController, PDFLinkService, PDFViewer } from "pdfjs-dist/web/pdf_viewer.mjs";
|
|
18
18
|
import { useEffect, useRef } from "react";
|
|
19
|
-
|
|
19
|
+
import { PAGES_LOADED_EVENT } from "../constants.js";
|
|
20
|
+
export function usePdfViewer(containerRef, viewerRef, document, initialScale, initialPage) {
|
|
20
21
|
const pdfViewerRef = useRef(null);
|
|
21
22
|
const eventBusRef = useRef(null);
|
|
22
23
|
const findControllerRef = useRef(null);
|
|
@@ -50,6 +51,16 @@ export function usePdfViewer(containerRef, viewerRef, document, initialScale) {
|
|
|
50
51
|
if (initialScale != null) {
|
|
51
52
|
pdfViewer.currentScale = initialScale;
|
|
52
53
|
}
|
|
54
|
+
if (initialPage != null && initialPage > 1) {
|
|
55
|
+
const onPagesLoaded = () => {
|
|
56
|
+
pdfViewer.currentPageNumber = initialPage;
|
|
57
|
+
pdfViewer.scrollPageIntoView({
|
|
58
|
+
pageNumber: initialPage
|
|
59
|
+
});
|
|
60
|
+
eventBus.off(PAGES_LOADED_EVENT, onPagesLoaded);
|
|
61
|
+
};
|
|
62
|
+
eventBus.on(PAGES_LOADED_EVENT, onPagesLoaded);
|
|
63
|
+
}
|
|
53
64
|
eventBusRef.current = eventBus;
|
|
54
65
|
findControllerRef.current = findController;
|
|
55
66
|
pdfViewerRef.current = pdfViewer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePdfViewer.js","names":["EventBus","PDFFindController","PDFLinkService","PDFViewer","useEffect","useRef","usePdfViewer","containerRef","viewerRef","document","initialScale","pdfViewerRef","eventBusRef","findControllerRef","container","current","viewer","eventBus","linkService","findController","updateMatchesCountOnProgress","pdfViewer","removePageBorders","setViewer","setDocument","currentScale","cleanup"],"sources":["usePdfViewer.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { PDFDocumentProxy } from \"pdfjs-dist\";\nimport {\n EventBus,\n PDFFindController,\n PDFLinkService,\n PDFViewer,\n} from \"pdfjs-dist/web/pdf_viewer.mjs\";\nimport type { RefObject } from \"react\";\nimport { useEffect, useRef } from \"react\";\n\nexport interface UsePdfViewerResult {\n pdfViewerRef: RefObject<PDFViewer | null>;\n eventBusRef: RefObject<EventBus | null>;\n findControllerRef: RefObject<PDFFindController | null>;\n}\n\nexport function usePdfViewer(\n containerRef: RefObject<HTMLDivElement | null>,\n viewerRef: RefObject<HTMLDivElement | null>,\n document: PDFDocumentProxy | undefined,\n initialScale?: number,\n): UsePdfViewerResult {\n const pdfViewerRef = useRef<PDFViewer | null>(null);\n const eventBusRef = useRef<EventBus | null>(null);\n const findControllerRef = useRef<PDFFindController | null>(null);\n\n useEffect(function initializePdfViewer() {\n const container = containerRef.current;\n const viewer = viewerRef.current;\n if (container == null || viewer == null || document == null) {\n return;\n }\n\n const eventBus = new EventBus();\n const linkService = new PDFLinkService({ eventBus });\n const findController = new PDFFindController({\n linkService,\n eventBus,\n updateMatchesCountOnProgress: true,\n });\n\n const pdfViewer = new PDFViewer({\n container,\n viewer,\n eventBus,\n linkService,\n findController,\n removePageBorders: true,\n });\n\n linkService.setViewer(pdfViewer);\n linkService.setDocument(document);\n findController.setDocument(document);\n pdfViewer.setDocument(document);\n\n if (initialScale != null) {\n pdfViewer.currentScale = initialScale;\n }\n\n eventBusRef.current = eventBus;\n findControllerRef.current = findController;\n pdfViewerRef.current = pdfViewer;\n\n return () => {\n pdfViewerRef.current = null;\n eventBusRef.current = null;\n findControllerRef.current = null;\n pdfViewer.cleanup();\n };\n }, [containerRef, viewerRef, document]);\n\n return { pdfViewerRef, eventBusRef, findControllerRef };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SACEA,QAAQ,EACRC,iBAAiB,EACjBC,cAAc,EACdC,SAAS,QACJ,+BAA+B;AAEtC,SAASC,SAAS,EAAEC,MAAM,QAAQ,OAAO;
|
|
1
|
+
{"version":3,"file":"usePdfViewer.js","names":["EventBus","PDFFindController","PDFLinkService","PDFViewer","useEffect","useRef","PAGES_LOADED_EVENT","usePdfViewer","containerRef","viewerRef","document","initialScale","initialPage","pdfViewerRef","eventBusRef","findControllerRef","container","current","viewer","eventBus","linkService","findController","updateMatchesCountOnProgress","pdfViewer","removePageBorders","setViewer","setDocument","currentScale","onPagesLoaded","currentPageNumber","scrollPageIntoView","pageNumber","off","on","cleanup"],"sources":["usePdfViewer.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { PDFDocumentProxy } from \"pdfjs-dist\";\nimport {\n EventBus,\n PDFFindController,\n PDFLinkService,\n PDFViewer,\n} from \"pdfjs-dist/web/pdf_viewer.mjs\";\nimport type { RefObject } from \"react\";\nimport { useEffect, useRef } from \"react\";\nimport { PAGES_LOADED_EVENT } from \"../constants.js\";\n\nexport interface UsePdfViewerResult {\n pdfViewerRef: RefObject<PDFViewer | null>;\n eventBusRef: RefObject<EventBus | null>;\n findControllerRef: RefObject<PDFFindController | null>;\n}\n\nexport function usePdfViewer(\n containerRef: RefObject<HTMLDivElement | null>,\n viewerRef: RefObject<HTMLDivElement | null>,\n document: PDFDocumentProxy | undefined,\n initialScale?: number,\n initialPage?: number,\n): UsePdfViewerResult {\n const pdfViewerRef = useRef<PDFViewer | null>(null);\n const eventBusRef = useRef<EventBus | null>(null);\n const findControllerRef = useRef<PDFFindController | null>(null);\n\n useEffect(function initializePdfViewer() {\n const container = containerRef.current;\n const viewer = viewerRef.current;\n if (container == null || viewer == null || document == null) {\n return;\n }\n\n const eventBus = new EventBus();\n const linkService = new PDFLinkService({ eventBus });\n const findController = new PDFFindController({\n linkService,\n eventBus,\n updateMatchesCountOnProgress: true,\n });\n\n const pdfViewer = new PDFViewer({\n container,\n viewer,\n eventBus,\n linkService,\n findController,\n removePageBorders: true,\n });\n\n linkService.setViewer(pdfViewer);\n linkService.setDocument(document);\n findController.setDocument(document);\n pdfViewer.setDocument(document);\n\n if (initialScale != null) {\n pdfViewer.currentScale = initialScale;\n }\n\n if (initialPage != null && initialPage > 1) {\n const onPagesLoaded = () => {\n pdfViewer.currentPageNumber = initialPage;\n pdfViewer.scrollPageIntoView({ pageNumber: initialPage });\n eventBus.off(PAGES_LOADED_EVENT, onPagesLoaded);\n };\n eventBus.on(PAGES_LOADED_EVENT, onPagesLoaded);\n }\n\n eventBusRef.current = eventBus;\n findControllerRef.current = findController;\n pdfViewerRef.current = pdfViewer;\n\n return () => {\n pdfViewerRef.current = null;\n eventBusRef.current = null;\n findControllerRef.current = null;\n pdfViewer.cleanup();\n };\n }, [containerRef, viewerRef, document]);\n\n return { pdfViewerRef, eventBusRef, findControllerRef };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SACEA,QAAQ,EACRC,iBAAiB,EACjBC,cAAc,EACdC,SAAS,QACJ,+BAA+B;AAEtC,SAASC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AACzC,SAASC,kBAAkB,QAAQ,iBAAiB;AAQpD,OAAO,SAASC,YAAYA,CAC1BC,YAA8C,EAC9CC,SAA2C,EAC3CC,QAAsC,EACtCC,YAAqB,EACrBC,WAAoB,EACA;EACpB,MAAMC,YAAY,GAAGR,MAAM,CAAmB,IAAI,CAAC;EACnD,MAAMS,WAAW,GAAGT,MAAM,CAAkB,IAAI,CAAC;EACjD,MAAMU,iBAAiB,GAAGV,MAAM,CAA2B,IAAI,CAAC;EAEhED,SAAS,CAAC,YAA+B;IACvC,MAAMY,SAAS,GAAGR,YAAY,CAACS,OAAO;IACtC,MAAMC,MA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