react-iiif-vault 0.9.11 → 0.9.12

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 (90) hide show
  1. package/.build/types/canvas-panel/Viewer.d.ts +13 -0
  2. package/.build/types/canvas-panel/index.d.ts +18 -0
  3. package/.build/types/canvas-panel/render/Annotation.d.ts +8 -0
  4. package/.build/types/canvas-panel/render/AnnotationPage.d.ts +6 -0
  5. package/.build/types/canvas-panel/render/Audio.d.ts +6 -0
  6. package/.build/types/canvas-panel/render/Canvas.d.ts +23 -0
  7. package/.build/types/canvas-panel/render/DefaultCanvasFallback.d.ts +5 -0
  8. package/.build/types/canvas-panel/render/Image.d.ts +13 -0
  9. package/.build/types/canvas-panel/render/Model.d.ts +3 -0
  10. package/.build/types/canvas-panel/render/Video.d.ts +6 -0
  11. package/.build/types/context/AnnotationContext.d.ts +5 -0
  12. package/.build/types/context/CanvasContext.d.ts +5 -0
  13. package/.build/types/context/CollectionContext.d.ts +5 -0
  14. package/.build/types/context/ContextBridge.d.ts +22 -0
  15. package/.build/types/context/ImageServiceLoaderContext.d.ts +4 -0
  16. package/.build/types/context/ManifestContext.d.ts +5 -0
  17. package/.build/types/context/MediaContext.d.ts +17 -0
  18. package/.build/types/context/PortalContext.d.ts +7 -0
  19. package/.build/types/context/RangeContext.d.ts +5 -0
  20. package/.build/types/context/ResourceContext.d.ts +14 -0
  21. package/.build/types/context/VaultContext.d.ts +14 -0
  22. package/.build/types/context/ViewerPresetContext.d.ts +3 -0
  23. package/.build/types/context/VisibleCanvasContext.d.ts +4 -0
  24. package/.build/types/demo/demo.d.ts +1 -0
  25. package/.build/types/demo/media-controls.d.ts +1 -0
  26. package/.build/types/demo/viewer-controls.d.ts +1 -0
  27. package/.build/types/features/rendering-strategy/3d-strategy.d.ts +13 -0
  28. package/.build/types/features/rendering-strategy/audio-strategy.d.ts +3 -0
  29. package/.build/types/features/rendering-strategy/choice-types.d.ts +15 -0
  30. package/.build/types/features/rendering-strategy/image-strategy.d.ts +13 -0
  31. package/.build/types/features/rendering-strategy/rendering-utils.d.ts +21 -0
  32. package/.build/types/features/rendering-strategy/resource-types.d.ts +42 -0
  33. package/.build/types/features/rendering-strategy/selector-extensions.d.ts +53 -0
  34. package/.build/types/features/rendering-strategy/strategies.d.ts +22 -0
  35. package/.build/types/features/rendering-strategy/video-strategy.d.ts +3 -0
  36. package/.build/types/hooks/useAnnotation.d.ts +8 -0
  37. package/.build/types/hooks/useAnnotationPageManager.d.ts +10 -0
  38. package/.build/types/hooks/useAnnotationsAtTime.d.ts +4 -0
  39. package/.build/types/hooks/useCanvas.d.ts +8 -0
  40. package/.build/types/hooks/useCanvasClock.d.ts +1 -0
  41. package/.build/types/hooks/useCanvasSelector.d.ts +0 -0
  42. package/.build/types/hooks/useCanvasTimeline.d.ts +0 -0
  43. package/.build/types/hooks/useCollection.d.ts +8 -0
  44. package/.build/types/hooks/useDispatch.d.ts +2 -0
  45. package/.build/types/hooks/useEnabledAnnotationPageIds.d.ts +1 -0
  46. package/.build/types/hooks/useEventListener.d.ts +4 -0
  47. package/.build/types/hooks/useExistingVault.d.ts +1 -0
  48. package/.build/types/hooks/useExternalCollection.d.ts +13 -0
  49. package/.build/types/hooks/useExternalManifest.d.ts +13 -0
  50. package/.build/types/hooks/useExternalResource.d.ts +16 -0
  51. package/.build/types/hooks/useImageService.d.ts +9 -0
  52. package/.build/types/hooks/useImageTile.d.ts +11 -0
  53. package/.build/types/hooks/useLoadImageService.d.ts +6 -0
  54. package/.build/types/hooks/useManifest.d.ts +8 -0
  55. package/.build/types/hooks/usePaintables.d.ts +8 -0
  56. package/.build/types/hooks/usePaintingAnnotations.d.ts +4 -0
  57. package/.build/types/hooks/useRange.d.ts +8 -0
  58. package/.build/types/hooks/useRenderingStrategy.d.ts +14 -0
  59. package/.build/types/hooks/useResourceEvents.d.ts +3 -0
  60. package/.build/types/hooks/useResources.d.ts +1 -0
  61. package/.build/types/hooks/useSearchService.d.ts +2 -0
  62. package/.build/types/hooks/useSimpleMediaPlayer.d.ts +32 -0
  63. package/.build/types/hooks/useStyleHelper.d.ts +1 -0
  64. package/.build/types/hooks/useStyles.d.ts +3 -0
  65. package/.build/types/hooks/useThumbnail.d.ts +5 -0
  66. package/.build/types/hooks/useVault.d.ts +2 -0
  67. package/.build/types/hooks/useVaultEffect.d.ts +2 -0
  68. package/.build/types/hooks/useVaultSelector.d.ts +2 -0
  69. package/.build/types/hooks/useVirtualAnnotationPage.d.ts +13 -0
  70. package/.build/types/hooks/useVirtualAnnotationPageContext.d.ts +9 -0
  71. package/.build/types/hooks/useVirtualCanvas.d.ts +0 -0
  72. package/.build/types/index.d.ts +56 -0
  73. package/.build/types/utility/expand-target.d.ts +19 -0
  74. package/.build/types/utility/flatten-annotation-page-ids.d.ts +7 -0
  75. package/.build/types/utility/parse-selector.d.ts +7 -0
  76. package/.build/types/viewers/SimpleViewerContext.d.ts +18 -0
  77. package/.build/types/viewers/SingleCanvasContext.d.ts +1 -0
  78. package/dist/bundle/cjs/index.js +36 -0
  79. package/dist/bundle/cjs/index.js.map +1 -0
  80. package/dist/{esm → bundle/esm}/index.mjs +720 -790
  81. package/dist/bundle/esm/index.mjs.map +1 -0
  82. package/dist/canvas-panel/cjs/canvas-panel.js +36 -0
  83. package/dist/canvas-panel/cjs/canvas-panel.js.map +1 -0
  84. package/dist/canvas-panel/esm/canvas-panel.mjs +2024 -0
  85. package/dist/canvas-panel/esm/canvas-panel.mjs.map +1 -0
  86. package/dist/index.umd.js +121 -31744
  87. package/dist/index.umd.js.map +1 -0
  88. package/package.json +38 -28
  89. package/dist/cjs/index.js +0 -2538
  90. package/dist/index.d.ts +0 -619
@@ -0,0 +1,8 @@
1
+ import { RangeNormalized } from '@iiif/presentation-3';
2
+ export declare function useRange(options?: {
3
+ id: string;
4
+ }): RangeNormalized | undefined;
5
+ export declare function useRange<T>(options?: {
6
+ id: string;
7
+ selector: (range: RangeNormalized) => T;
8
+ }, deps?: any[]): T | undefined;
@@ -0,0 +1,14 @@
1
+ import { RenderingStrategy } from '../features/rendering-strategy/strategies';
2
+ export declare type StrategyActions = {
3
+ makeChoice: (id: string, options?: {
4
+ deselectOthers?: boolean;
5
+ deselect?: boolean;
6
+ }) => void;
7
+ };
8
+ export declare type UseRenderingStrategy = [RenderingStrategy, StrategyActions];
9
+ export declare type UseRenderingStrategyOptions = {
10
+ strategies?: Array<RenderingStrategy['type']>;
11
+ annotationPageManagerId?: string;
12
+ defaultChoices?: string[];
13
+ };
14
+ export declare function useRenderingStrategy(options?: UseRenderingStrategyOptions): UseRenderingStrategy;
@@ -0,0 +1,3 @@
1
+ import { NormalizedEntity } from '@iiif/vault';
2
+ import { Reference } from '@iiif/presentation-3';
3
+ export declare function useResourceEvents<T extends NormalizedEntity>(resource?: Reference, scope?: string[]): any;
@@ -0,0 +1 @@
1
+ export declare function useResources<Type>(ids: string[], type: string): Type[];
@@ -0,0 +1,2 @@
1
+ import { SearchService } from '@iiif/presentation-3';
2
+ export declare function useSearchService(): SearchService | undefined;
@@ -0,0 +1,32 @@
1
+ import { RefObject } from 'react';
2
+ export declare type MediaPlayerState = {
3
+ isPlaying: boolean;
4
+ isMuted: boolean;
5
+ playRequested: boolean;
6
+ volume: number;
7
+ isFinished: boolean;
8
+ duration: number;
9
+ };
10
+ export declare type MediaPlayerActions = {
11
+ play(): void;
12
+ pause(): void;
13
+ playPause(): void;
14
+ mute(): void;
15
+ unmute(): void;
16
+ toggleMute(): void;
17
+ setVolume(volume: number): void;
18
+ setDurationPercent(percent: number): void;
19
+ setTime(time: number): void;
20
+ };
21
+ export declare function formatTime(time: number): string;
22
+ export declare function useSimpleMediaPlayer(props: {
23
+ duration: number;
24
+ }): readonly [
25
+ {
26
+ element: RefObject<HTMLAudioElement | HTMLVideoElement>;
27
+ currentTime: RefObject<HTMLDivElement>;
28
+ progress: RefObject<HTMLDivElement>;
29
+ },
30
+ MediaPlayerState,
31
+ MediaPlayerActions
32
+ ];
@@ -0,0 +1 @@
1
+ export declare function useStyleHelper(): import("@iiif/vault-helpers/styles").StyledHelper<import("@iiif/vault-helpers/styles").StyleDefinition>;
@@ -0,0 +1,3 @@
1
+ import { Reference } from '@iiif/presentation-3';
2
+ export declare function useStyles<Style extends Record<string, Record<string, any>>>(resource: undefined | Reference<any>): Style;
3
+ export declare function useStyles<Style extends Record<string, any>>(resource: undefined | Reference<any>, scope: string): Style;
@@ -0,0 +1,5 @@
1
+ import { ImageCandidate, ImageCandidateRequest } from '@atlas-viewer/iiif-image-api';
2
+ export declare function useThumbnail(request: ImageCandidateRequest, dereference?: boolean, { canvasId, manifestId }?: {
3
+ canvasId?: string;
4
+ manifestId?: string;
5
+ }): ImageCandidate | undefined;
@@ -0,0 +1,2 @@
1
+ import { Vault } from '@iiif/vault';
2
+ export declare const useVault: () => Vault;
@@ -0,0 +1,2 @@
1
+ import { Vault } from '@iiif/vault';
2
+ export declare const useVaultEffect: (callback: (vault: Vault) => void, deps?: any[]) => void;
@@ -0,0 +1,2 @@
1
+ import { IIIFStore, Vault } from '@iiif/vault';
2
+ export declare function useVaultSelector<T>(selector: (state: IIIFStore, vault: Vault) => T, deps?: any[]): T;
@@ -0,0 +1,13 @@
1
+ import { Annotation, AnnotationNormalized, AnnotationPageNormalized } from '@iiif/presentation-3';
2
+ import { Vault } from '@iiif/vault';
3
+ export interface VaultActivatedAnnotation {
4
+ __vault?: Vault;
5
+ bindToVault(vault: Vault): void;
6
+ source: string | {
7
+ id: string;
8
+ };
9
+ }
10
+ export declare function useVirtualAnnotationPage(): readonly [AnnotationPageNormalized | null, {
11
+ readonly addAnnotation: (id: string | Annotation | VaultActivatedAnnotation | AnnotationNormalized, atIndex?: number) => void;
12
+ readonly removeAnnotation: (id: string | Annotation | VaultActivatedAnnotation | AnnotationNormalized) => void;
13
+ }];
@@ -0,0 +1,9 @@
1
+ import { Annotation, AnnotationNormalized, AnnotationPageNormalized } from '@iiif/presentation-3';
2
+ import { VaultActivatedAnnotation } from './useVirtualAnnotationPage';
3
+ export declare function useVirtualAnnotationPageContext(): readonly [AnnotationPageNormalized | null, {
4
+ readonly addAnnotation: (id: string | AnnotationNormalized | VaultActivatedAnnotation | Annotation, atIndex?: number | undefined) => void;
5
+ readonly removeAnnotation: (id: string | AnnotationNormalized | VaultActivatedAnnotation | Annotation) => void;
6
+ }];
7
+ export declare function VirtualAnnotationProvider({ children }: {
8
+ children: any;
9
+ }): JSX.Element;
File without changes
@@ -0,0 +1,56 @@
1
+ export * from './canvas-panel';
2
+ export * from './context/AnnotationContext';
3
+ export * from './context/CanvasContext';
4
+ export * from './context/CollectionContext';
5
+ export * from './context/ManifestContext';
6
+ export * from './context/MediaContext';
7
+ export * from './context/PortalContext';
8
+ export * from './context/RangeContext';
9
+ export * from './context/VaultContext';
10
+ export * from './context/ResourceContext';
11
+ export * from './context/ContextBridge';
12
+ export * from './context/VisibleCanvasContext';
13
+ export * from './context/ViewerPresetContext';
14
+ export * from './context/ImageServiceLoaderContext';
15
+ export * from './features/rendering-strategy/choice-types';
16
+ export * from './features/rendering-strategy/image-strategy';
17
+ export * from './features/rendering-strategy/rendering-utils';
18
+ export * from './features/rendering-strategy/resource-types';
19
+ export * from './features/rendering-strategy/selector-extensions';
20
+ export * from './features/rendering-strategy/strategies';
21
+ export * from './hooks/useAnnotation';
22
+ export * from './hooks/useAnnotationPageManager';
23
+ export * from './hooks/useAnnotationsAtTime';
24
+ export * from './hooks/useCanvas';
25
+ export * from './hooks/useCanvasClock';
26
+ export * from './hooks/useCollection';
27
+ export * from './hooks/useDispatch';
28
+ export * from './hooks/useEventListener';
29
+ export * from './hooks/useExistingVault';
30
+ export * from './hooks/useExternalCollection';
31
+ export * from './hooks/useExternalManifest';
32
+ export * from './hooks/useExternalResource';
33
+ export * from './hooks/useImageService';
34
+ export * from './hooks/useImageTile';
35
+ export * from './hooks/useManifest';
36
+ export * from './hooks/usePaintables';
37
+ export * from './hooks/usePaintingAnnotations';
38
+ export * from './hooks/useRange';
39
+ export * from './hooks/useResourceEvents';
40
+ export * from './hooks/useResources';
41
+ export * from './hooks/useSearchService';
42
+ export * from './hooks/useStyleHelper';
43
+ export * from './hooks/useSimpleMediaPlayer';
44
+ export * from './hooks/useStyles';
45
+ export * from './hooks/useThumbnail';
46
+ export * from './hooks/useLoadImageService';
47
+ export * from './hooks/useVault';
48
+ export * from './hooks/useVaultEffect';
49
+ export * from './hooks/useVaultSelector';
50
+ export * from './hooks/useVirtualAnnotationPage';
51
+ export * from './hooks/useVirtualAnnotationPageContext';
52
+ export * from './hooks/useRenderingStrategy';
53
+ export * from './utility/expand-target';
54
+ export * from './utility/flatten-annotation-page-ids';
55
+ export * from './utility/parse-selector';
56
+ export * from './viewers/SimpleViewerContext';
@@ -0,0 +1,19 @@
1
+ import { ExternalWebResource, W3CAnnotationTarget } from '@iiif/presentation-3';
2
+ import { SupportedSelectors } from '../features/rendering-strategy/selector-extensions';
3
+ export declare type SupportedTarget = {
4
+ type: 'SpecificResource';
5
+ source: ExternalWebResource | {
6
+ id: string;
7
+ type: 'Unknown' | 'Canvas' | 'Range' | 'Manifest';
8
+ partOf?: Array<{
9
+ id: string;
10
+ type: string;
11
+ }>;
12
+ };
13
+ purpose?: string;
14
+ selector: SupportedSelectors | null;
15
+ selectors: SupportedSelectors[];
16
+ };
17
+ export declare function expandTarget(target: W3CAnnotationTarget | W3CAnnotationTarget[], options?: {
18
+ typeMap?: Record<string, string>;
19
+ }): SupportedTarget;
@@ -0,0 +1,7 @@
1
+ import { CanvasNormalized, ManifestNormalized } from '@iiif/presentation-3';
2
+ export declare function flattenAnnotationPageIds({ canvas, manifest, all, canvases, }: {
3
+ manifest?: ManifestNormalized;
4
+ canvas?: CanvasNormalized;
5
+ canvases?: CanvasNormalized[];
6
+ all?: boolean;
7
+ }): string[];
@@ -0,0 +1,7 @@
1
+ import { SupportedSelectors } from '../features/rendering-strategy/selector-extensions';
2
+ import { Selector } from '@iiif/presentation-3';
3
+ export declare type ParsedSelector = {
4
+ selector: SupportedSelectors | null;
5
+ selectors: SupportedSelectors[];
6
+ };
7
+ export declare function parseSelector(source: Selector | Selector[]): ParsedSelector;
@@ -0,0 +1,18 @@
1
+ import React, { ReactNode } from 'react';
2
+ declare type SimpleViewerContext = {
3
+ setCurrentCanvasId: (newId: string | ((prev: string) => string)) => void;
4
+ setCurrentCanvasIndex: (newId: number | ((prev: number) => number)) => void;
5
+ currentCanvasIndex: number;
6
+ pagingView: boolean;
7
+ totalCanvases: number;
8
+ nextCanvas: () => void;
9
+ previousCanvas: () => void;
10
+ };
11
+ export declare const SimpleViewerReactContext: React.Context<SimpleViewerContext>;
12
+ export declare function SimpleViewerProvider(props: {
13
+ manifest: string;
14
+ pagingEnabled?: boolean;
15
+ children: ReactNode;
16
+ }): JSX.Element;
17
+ export declare function useSimpleViewer(): SimpleViewerContext;
18
+ export {};
@@ -0,0 +1 @@
1
+ export declare const SingleCanvasProvider: null;
@@ -0,0 +1,36 @@
1
+ "use strict";var at=Object.defineProperty,st=Object.defineProperties;var ct=Object.getOwnPropertyDescriptors;var $=Object.getOwnPropertySymbols;var ge=Object.prototype.hasOwnProperty,he=Object.prototype.propertyIsEnumerable;var me=(e,t,r)=>t in e?at(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,y=(e,t)=>{for(var r in t||(t={}))ge.call(t,r)&&me(e,r,t[r]);if($)for(var r of $(t))he.call(t,r)&&me(e,r,t[r]);return e},x=(e,t)=>st(e,ct(t));var ve=(e,t)=>{var r={};for(var n in e)ge.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&$)for(var n of $(e))t.indexOf(n)<0&&he.call(e,n)&&(r[n]=e[n]);return r};Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var c=require("react"),z=require("@atlas-viewer/atlas"),Q=require("@iiif/vault"),P=require("typesafe-actions"),ut=require("react-dom"),k=require("@atlas-viewer/iiif-image-api");function Ee(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}function lt(e){if(e&&e.__esModule)return e;var t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});return e&&Object.keys(e).forEach(function(r){if(r!=="default"){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,Object.freeze(t)}var te=lt(c),V=Ee(c),dt=Ee(ut);function re(e,t){return re=Object.setPrototypeOf||function(n,a){return n.__proto__=a,n},re(e,t)}function ft(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,re(e,t)}var pt=function(t,r){return t===void 0&&(t=[]),r===void 0&&(r=[]),t.length!==r.length||t.some(function(n,a){return!Object.is(n,r[a])})},ye={error:null},mt=function(e){ft(t,e);function t(){for(var n,a=arguments.length,i=new Array(a),o=0;o<a;o++)i[o]=arguments[o];return n=e.call.apply(e,[this].concat(i))||this,n.state=ye,n.resetErrorBoundary=function(){for(var s,u=arguments.length,l=new Array(u),d=0;d<u;d++)l[d]=arguments[d];n.props.onReset==null||(s=n.props).onReset.apply(s,l),n.reset()},n}t.getDerivedStateFromError=function(a){return{error:a}};var r=t.prototype;return r.reset=function(){this.setState(ye)},r.componentDidCatch=function(a,i){var o,s;(o=(s=this.props).onError)==null||o.call(s,a,i)},r.componentDidUpdate=function(a,i){var o=this.state.error,s=this.props.resetKeys;if(o!==null&&i.error!==null&&pt(a.resetKeys,s)){var u,l;(u=(l=this.props).onResetKeysChange)==null||u.call(l,a.resetKeys,s),this.reset()}},r.render=function(){var a=this.state.error,i=this.props,o=i.fallbackRender,s=i.FallbackComponent,u=i.fallback;if(a!==null){var l={error:a,resetErrorBoundary:this.resetErrorBoundary};if(te.isValidElement(u))return u;if(typeof o=="function")return o(l);if(s)return te.createElement(s,l);throw new Error("react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop")}return this.props.children},t}(te.Component),K={exports:{}},W={};/**
2
+ * @license React
3
+ * react-jsx-runtime.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var gt=V.default,ht=Symbol.for("react.element"),vt=Symbol.for("react.fragment"),yt=Object.prototype.hasOwnProperty,St=gt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Et={key:!0,ref:!0,__self:!0,__source:!0};function Ce(e,t,r){var n,a={},i=null,o=null;r!==void 0&&(i=""+r),t.key!==void 0&&(i=""+t.key),t.ref!==void 0&&(o=t.ref);for(n in t)yt.call(t,n)&&!Et.hasOwnProperty(n)&&(a[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps,t)a[n]===void 0&&(a[n]=t[n]);return{$$typeof:ht,type:e,key:i,ref:o,props:a,_owner:St.current}}W.Fragment=vt;W.jsx=Ce;W.jsxs=Ce;K.exports=W;const m=K.exports.jsx,T=K.exports.jsxs,D=K.exports.Fragment,Ct={collection:void 0,manifest:void 0,range:void 0,canvas:void 0,annotation:void 0},J=V.default.createContext(Ct),L=()=>c.useContext(J);function F({value:e,children:t}){const r=L(),n=c.useMemo(()=>y(y({},r),e),[e,r]);return m(J.Provider,{value:n,children:t})}const B=V.default.createContext({vault:null,setVaultInstance:e=>{}});function xe({vault:e,vaultOptions:t,useGlobal:r,resources:n,children:a}){const[i,o]=c.useState(()=>e||(r?Q.globalVault(t):t?new Q.Vault(t):new Q.Vault));return m(B.Provider,{value:{vault:i,setVaultInstance:o},children:m(F,{value:n||{},children:a})})}const A=()=>{const{vault:e}=c.useContext(B);if(e===null)throw new Error("Vault not found. Ensure you have your provider set up correctly.");return e};function ae(e,{noCache:t=!1}={}){const r=typeof e=="string"?e:e.id,n=A(),[a,i]=c.useState(r),[o,s]=c.useState(void 0),u=c.useMemo(()=>n.get(r,{skipSelfReturn:!0})||void 0,[r,n]),[l,d]=c.useState(u);return c.useEffect(()=>{(async()=>{try{const f=u&&!t?u:await n.load(r),h=f?f.id||f["@id"]:null;f&&a!==h&&i(h),d(f)}catch(f){s(f)}})()},[r,t]),{isLoaded:!!l,id:a,requestId:r,error:o,resource:l,cached:!!(l&&l===u)}}function Re(e,t){const{id:r,isLoaded:n,error:a,resource:i,requestId:o,cached:s}=ae(e,t);return{id:r,isLoaded:n,error:a,manifest:i,requestId:o,cached:s}}function we({manifest:e,children:t}){return m(F,{value:{manifest:e},children:t})}function se({canvas:e,children:t}){return m(F,{value:{canvas:e},children:t})}function b(e,t=[]){const r=A(),[n,a]=c.useState(()=>e(r.getState(),r));return c.useEffect(()=>r.subscribe(i=>e(i,r),i=>{a(i)},!1),t),n}const j=V.default.createContext([]);function Ae(){const e=c.useContext(j);return b(t=>e.map(r=>t.iiif.entities.Canvas[r]).filter(Boolean),[e])}const q=()=>{},H=c.createContext({setCurrentCanvasId:q,setCurrentCanvasIndex:q,nextCanvas:q,previousCanvas:q,currentCanvasIndex:-1,totalCanvases:0,pagingView:!0});function xt(e){const t=Re(e.manifest),[r,n]=c.useState(""),[a,i]=c.useState([]),o=(typeof e.pagingEnabled=="undefined"||e.pagingEnabled)&&t.manifest&&t.manifest.behavior&&t.manifest.behavior.includes("paged");c.useEffect(()=>{var g,p;t.manifest&&(n((g=t.manifest.items[0])==null?void 0:g.id),i([(p=t.manifest.items[0])==null?void 0:p.id]))},[t.manifest,e.manifest]);const s=c.useMemo(()=>{var g;return((g=t.manifest)==null?void 0:g.items.map(p=>p.id))||[]},[t.manifest,e.manifest]),u=c.useMemo(()=>s.indexOf(r),[s,r]),l=c.useCallback(()=>{if(s.length&&r){if(u===-1||(s[u+2]?u+2===s.length:u===s.length))return;const g=o&&u!==0?s[u+2]:s[u+1],p=o?u!==0?s[u+3]:s[u+2]:null;g&&(n(g),i(p?[g,p]:[g]))}},[o,s,r,u]),d=c.useCallback(()=>{if(s.length&&r){if(u===0||u===-1)return;const g=o&&u!==1?s[u-2]:s[u-1],p=o&&u!==1?s[u-1]:null;g&&(n(g),i(p?[g,p]:[g]))}},[o,s,r,u]),f=c.useCallback(g=>{const p=o&&g%2===1?g-1:g,S=s[p],C=o&&p!==0?s[p+1]:null;S&&(n(S),i(E=>{const R=C?[S,C]:[S];if(E.length===E.length){for(let M=0;M<E.length;M++)if(E[M]!==R[M])return R;return E}return R}))},[o,s]),h=c.useCallback(g=>{const p=s.indexOf(g);p!==-1&&f(p)},[s,f]),v=c.useMemo(()=>({setCurrentCanvasId:h,nextCanvas:l,previousCanvas:d,currentCanvasIndex:u,totalCanvases:s.length,setCurrentCanvasIndex:f,pagingView:!0}),[l,d,u,s,f,h]);return t.manifest?t.isLoaded?m(H.Provider,{value:v,children:m(j.Provider,{value:a,children:m(we,{manifest:t.manifest.id,children:m(se,{canvas:r,children:e.children})})})}):m("div",{children:"Loading..."}):(console.warn("The manifest passed to the provider is not a valid IIIF manifest."),m("div",{children:"Sorry, something went wrong."}))}function Rt(){return c.useContext(H)}function Pe(){return{VaultContext:c.useContext(B),ResourceContext:c.useContext(J),SimpleViewerReactContext:c.useContext(H),VisibleCanvasReactContext:c.useContext(j)}}function be(e){return m(xe,{vault:e.bridge.VaultContext.vault||void 0,resources:e.bridge.ResourceContext,children:m(j.Provider,{value:e.bridge.VisibleCanvasReactContext,children:m(H.Provider,{value:e.bridge.SimpleViewerReactContext,children:e.children})})})}const wt="@iiif/IMPORT_ENTITIES",At="@iiif/MODIFY_ENTITY_FIELD",Pt="@iiif/REORDER_ENTITY_FIELD",bt="@iiif/ADD_REFERENCE",Mt="@iiif/REMOVE_REFERENCE",Tt=P.createAction(wt)(),It=P.createAction(At)(),_t=P.createAction(Pt)(),Ot=P.createAction(bt)(),kt=P.createAction(Mt)(),ne={importEntities:Tt,modifyEntityField:It,reorderEntityField:_t,addReference:Ot,removeReference:kt},Vt="@iiif/ADD_MAPPING",Lt="@iiif/ADD_MAPPINGS";P.createAction(Vt)();P.createAction(Lt)();const Ft="@iiif/SET_META_VALUE",Ut="@iiif/SET_META_VALUE_DYNAMIC",Dt="@iiif/UNSET_META_VALUE";P.createAction(Ft)();P.createAction(Ut)();P.createAction(Dt)();const Nt="@iiif/REQUEST_RESOURCE",Bt="@iiif/REQUEST_ERROR",jt="@iiif/REQUEST_MISMATCH",Ht="@iiif/REQUEST_COMPLETE",Yt="@iiif/REQUEST_OFFLINE_RESOURCE";P.createAction(Nt)();P.createAction(Bt)();P.createAction(jt)();P.createAction(Ht)();P.createAction(Yt)();const $t="@iiif/BATCH",qt="@iiif/BATCH_IMPORT";P.createAction($t)();P.createAction(qt)();function Me(){const t=A().getStore();return c.useMemo(()=>r=>t.dispatch(r),[t])}function Se(e){return typeof e!="string"&&e&&e.bindToVault}function Te(){const e=A(),t=c.useRef([]),r=Me(),n=c.useMemo(()=>`vault://annotation-page/${new Date().getTime()}/${Math.round(Math.random()*1e9).toString(16)}`,[]);c.useLayoutEffect(()=>{const s={id:n,type:"AnnotationPage",behavior:[],motivation:null,label:null,thumbnail:[],summary:null,requiredStatement:null,metadata:[],rights:null,provider:[],items:[],seeAlso:[],homepage:[],logo:[],rendering:[],service:[]};r(ne.importEntities({entities:{AnnotationPage:{[s.id]:s}}}))},[n]);const a=b(s=>n?s.iiif.entities.AnnotationPage[n]:null,[n]),i=c.useCallback((s,u)=>{if(n){if(Se(s)){const f=s;f.__vault||f.bindToVault(e),s=typeof f.source=="string"?f.source:f.source.id,t.current[s]=f}else typeof s!="string"&&(s=s.id);const l=e.get({id:n,type:"AnnotationPage"}),d=e.get({id:s,type:"Annotation"});l&&d&&(l.items.find(f=>f.id===d.id)||r(ne.addReference({id:n,type:"AnnotationPage",key:"items",reference:{id:s,type:"Annotation"},index:u})))}},[n]),o=c.useCallback(s=>{n&&(Se(s)?s=typeof s.source=="string"?s.source:s.source.id:typeof s!="string"&&(s=s.id),t.current[s]&&t.current[s].beforeRemove(),e.get({id:n,type:"AnnotationPage"})&&r(ne.removeReference({id:n,type:"AnnotationPage",key:"items",reference:{id:s,type:"Annotation"}})))},[n]);return[a,{addAnnotation:i,removeAnnotation:o}]}const Ie=c.createContext(null);function _e(){const e=c.useContext(Ie);return[e.fullPage,{addAnnotation:e.addAnnotation,removeAnnotation:e.removeAnnotation}]}function Oe({children:e}){const[t,{addAnnotation:r,removeAnnotation:n}]=Te();return m(Ie.Provider,{value:c.useMemo(()=>({fullPage:t,addAnnotation:r,removeAnnotation:n}),[t]),children:e})}function Qt({width:e,style:t,height:r}){return m("div",{style:x(y({width:e,height:r,minHeight:500},t||{}),{background:"#f9f9f9"}),children:"Unknown error"})}var ke,zt=dt.default;ke=zt.createRoot;const X=c.createContext(null);function Ve(){return c.useContext(X)}const ce=V.default.createContext(null),ue=V.default.createContext(null);function U({children:e,overlay:t}){const r=c.useContext(t?ue:ce),n=c.useRef(null),a=Ve();return c.useLayoutEffect(()=>{n.current||(n.current=r?ke(r):null)},[]),c.useLayoutEffect(()=>()=>{var i;(i=n.current)==null||i.unmount(),n.current=null},[]),c.useLayoutEffect(()=>{n.current&&n.current.render(m(X.Provider,{value:a,children:e}))},[e,a]),null}function Gt(a){var i=a,{children:e,errorFallback:t,outerContainerProps:r={}}=i,n=ve(i,["children","errorFallback","outerContainerProps"]);const o=c.useRef(null),[s,u]=c.useState(),[l,d]=c.useState(),f=c.useRef(null),[h,v]=c.useState(),g=Pe(),p=t||Qt;return c.useLayoutEffect(()=>{u(o.current),v(f.current)},[]),T(mt,{fallbackRender:()=>m(p,y({},n)),children:[m(z.AtlasAuto,x(y({},n),{containerProps:y({style:{position:"relative"}},n.containerProps||{}),htmlChildren:m("div",{ref:f}),onCreated:S=>{d(S),n.onCreated&&n.onCreated(S)},children:m(X.Provider,{value:l,children:m(ce.Provider,{value:s,children:m(ue.Provider,{value:h,children:m(be,{bridge:g,children:m(Oe,{children:e})})})})})})),m("div",{ref:o})]})}function Le(e){return{addEventListener(t,r,n,a){if(!!t)return e.setMetaValue([t.id,"eventManager",r],i=>{const o=i||[];for(const s of o)if(s.callback===n)return o;return[...o,{callback:n,scope:a}]}),n},removeEventListener(t,r,n){!t||e.setMetaValue([t.id,"eventManager",r],a=>(a||[]).filter(i=>i.callback!==n))},getListenersAsProps(t,r){const n=typeof t=="string"?{id:t}:t;if(!n||!n.id)return{};const a=e.getResourceMeta(n.id,"eventManager"),i={};if(a&&n)for(const o of Object.keys(a))i[o]=s=>{const u=e.get(n);for(const{callback:l,scope:d}of a[o]||[])(!d||r&&d.indexOf(r)!==-1)&&l(s,u)};return i}}}function le(e,t){const r=A(),n=c.useMemo(()=>Le(r),[r]),a=b(()=>e&&e.id?r.getResourceMeta(e.id,"eventManager"):null,[e]);return c.useMemo(()=>e?n.getListenersAsProps(e,t):{},[a,e,r,t])}function de(e){return{applyStyles(t,r,n){const a=typeof t=="string"?t:t.id;return e.setMetaValue([a,"styles",r],n)},getAppliedStyles(t){const r=typeof t=="string"?t:t.id;return e.getResourceMeta(r,"styles")}}}function N(e,t){const r=A(),n=c.useMemo(()=>de(r),[r]);return b(()=>{if(!e)return null;const a=n.getAppliedStyles(e.id);return a?t?a[t]:a:void 0},[e,t])}const Kt=/&?(xywh=)?(pixel:|percent:|pct:)?([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?)/,Wt=/&?(t=)(npt:)?([0-9]+(.[0-9]+)?)?(,([0-9]+(.[0-9]+)?))?/;function G(e){if(Array.isArray(e))return e.reduce((t,r)=>{const{selector:n,selectors:a}=G(r);return n&&(t.selector||(t.selector=n),t.selectors.push(...a)),t},{selector:null,selectors:[]});if(!e)return{selector:null,selectors:[]};if(typeof e=="string"){const[t,r]=e.split("#");return r?G({type:"FragmentSelector",value:r}):{selector:null,selectors:[]}}if(e.type==="PointSelector"&&(e.t||e.t===0)){const t={type:"TemporalSelector",temporal:{startTime:e.t}};return{selector:t,selectors:[t]}}if(e.type==="FragmentSelector"){const t=Kt.exec(e.value);if(t){const n={type:"BoxSelector",spatial:{unit:t[2]==="percent:"||t[2]==="pct:"?"percent":"pixel",x:parseFloat(t[3]),y:parseFloat(t[4]),width:parseFloat(t[5]),height:parseFloat(t[6])}};return{selector:n,selectors:[n]}}const r=e.value.match(Wt);if(r){const n={type:"TemporalSelector",temporal:{startTime:r[4]?parseFloat(r[4]):0,endTime:r[7]?parseFloat(r[7]):void 0}};return{selector:n,selectors:[n]}}return{selector:null,selectors:[]}}return{selector:null,selectors:[]}}function _(e,t={}){if(Array.isArray(e))return _(e[0]);if(typeof e=="string"){const[r,n]=e.split("#");return n?_({type:"SpecificResource",source:{id:r,type:"Unknown"},selector:{type:"FragmentSelector",value:n}}):{type:"SpecificResource",source:{id:r,type:t.typeMap&&t.typeMap[r]||"Unknown"},selector:null,selectors:[]}}if(e.type==="Choice"||e.type==="List"||e.type==="Composite"||e.type==="Independents")return _(e.items[0]);if(e.type==="SpecificResource"){e.source.type==="Canvas"&&e.source.partOf&&typeof e.source.partOf=="string"&&(e.source.partOf=[{id:e.source.partOf,type:"Manifest"}]);const{selector:r,selectors:n}=e.selector?G(e.selector):{selector:null,selectors:[]};return{type:"SpecificResource",source:e.source,selector:r,selectors:n}}if(e.id){e.type==="Canvas"&&e.partOf&&typeof e.partOf=="string"&&(e.partOf=[{id:e.partOf,type:"Manifest"}]);const[r,n]=e.id.split("#");return n?_({type:"SpecificResource",source:x(y({},e),{id:r}),selector:{type:"FragmentSelector",value:n}}):{type:"SpecificResource",source:x(y({},e),{id:r}),selector:null,selectors:[]}}return{type:"SpecificResource",source:e,selector:null,selectors:[]}}function Fe(e={},t=[]){const{id:r,selector:n}=e,a=L(),i=A(),o=r||a.annotation,s=b(l=>o?l.iiif.entities.Annotation[o]:void 0,[o]),u=b(l=>s&&s.body?s.body.map(d=>d?l.iiif.entities[d.type][d.id]:null).filter(Boolean):[],[s]);return c.useMemo(()=>{if(!s)return;const l=x(y({},s),{body:u,target:_(s.target,{typeMap:i.getState().iiif.mapping})});return n?n(l):l},[s,n,u,...t])}function O(e={},t=[]){const{id:r,selector:n}=e,a=L(),i=r||a.canvas,o=b(s=>i?s.iiif.entities.Canvas[i]:void 0,[i]);return c.useMemo(()=>{if(!!o)return n?n(o):o},[o,n,...t])}const Ue=({id:e,style:t,className:r,interactive:n})=>{const a=Fe({id:e}),i=N(a,"atlas"),o=N(a,"html"),s=le(a,["atlas"]),u=O(),l=c.useMemo(()=>z.mergeStyles(t,i),[t,i]);return u&&a&&a.target&&a.target.selector&&a.target.selector.type==="BoxSelector"&&a.target.source&&a.target.source.id===u.id?m(z.RegionHighlight,y({id:a.id,isEditing:!0,region:a.target.selector.spatial,style:l,className:(o==null?void 0:o.className)||r,interactive:!!((o==null?void 0:o.href)||n),href:(o==null?void 0:o.href)||null,title:(o==null?void 0:o.title)||null,hrefTarget:(o==null?void 0:o.target)||null},s)):null},oe=({className:e,page:t})=>{var a;const r=N(t,"atlas"),n=N(t,"html");return b(i=>t.id?i.iiif.entities.AnnotationPage[t.id]:null,[]),m(c.Fragment,{children:(a=t.items)==null?void 0:a.map(i=>m(Ue,{id:i.id,style:r,className:(n==null?void 0:n.className)||e},i.id))})};function De({id:e,image:t,thumbnail:r,isStatic:n,x:a=0,y:i=0,annotations:o,children:s}){var u,l,d,f;return m(c.Fragment,{children:t.service?T(c.Fragment,{children:[m(z.TileSet,{tiles:{id:t.service.id||t.service["@id"]||"unknown",height:t.height,width:t.width,imageService:t.service,thumbnail:r&&r.type==="fixed"?r:void 0},x:((u=t.target)==null?void 0:u.spatial.x)+a,y:((l=t.target)==null?void 0:l.spatial.y)+i,width:(d=t.target)==null?void 0:d.spatial.width,height:(f=t.target)==null?void 0:f.spatial.height}),o,s]},"service"):T(c.Fragment,{children:[m("world-image",{uri:t.id,target:t.target.spatial,display:t.width&&t.height?{width:t.width,height:t.height}:void 0}),o,s]},"no-service")},e)}function Ne(e){return e.type==="SpecificResource"?[e.source,{selector:e.selector}]:[e,{selector:null}]}function Be(e,t,r){const n=[];let a=null;const i=[];for(const o of t){const s=e.get(o.body);for(const u of s){const[l,{selector:d}]=Ne(u),f=(l.type||"unknown").toLowerCase();if(f==="choice"){const h=e.get(l.items),v=r.length?r.map(g=>h.find(p=>p.id===g)).filter(Boolean):[h[0]];v.length===0&&v.push(h[0]),a={type:"single-choice",items:h.map(g=>({id:g.id,label:g.label,selected:v.indexOf(g)!==-1})),label:u.label},s.push(...v);continue}n.indexOf(f)===-1&&n.push(f),i.push({type:f,resource:l,target:o.target,selector:d})}}return{types:n,items:i,choice:a}}const je={makeChoice:()=>{}},ie={type:"unknown"},w=e=>({type:"unknown",reason:e,annotations:{pages:[]}});function Y(e={},t=[]){const{id:r,selector:n}=e,a=L();A();const i=r||a.manifest,o=b(s=>i?s.iiif.entities.Manifest[i]:void 0,[i]);return c.useMemo(()=>{if(!!o)return n?n(o):o},[o,n,...t])}function Jt(e,t){var n;const r=(n=e==null?void 0:e.iiif)==null?void 0:n.meta[t];return r?r.annotationPageManager:null}function Xt(e,t){return b(r=>{const n=[];if(!e)return n;const a=Object.keys(r.iiif.entities.AnnotationPage);for(const i of a)if(!t||t.indexOf(i)!==-1){const o=Jt(r,i);o&&o.views&&o.views[e]&&n.push(i)}return n},[e,t])}function He({canvas:e,manifest:t,all:r,canvases:n}){const a=[];if(t)for(const i of t.annotations)a.indexOf(i.id)===-1&&a.push(i.id);if(r){if(n&&n.length)for(const i of n)for(const o of i.annotations)a.indexOf(o.id)===-1&&a.push(o.id)}else if(e)for(const i of e.annotations)a.indexOf(i.id)===-1&&a.push(i.id);return a}function Zt(e,t){var n;const r=(n=e==null?void 0:e.iiif)==null?void 0:n.meta[t];return r?r.annotationPageManager:null}function Ye(e,t={}){const r=A(),n=Y(),a=O(),i=Ae(),o=c.useMemo(()=>He({all:t.all,manifest:n,canvas:a,canvases:i}),[t.all,a,i,n]),s=Xt(e,t.all?void 0:o),u=c.useCallback(d=>{!e||r.setMetaValue([d,"annotationPageManager","views"],f=>f&&!f[e]?f:x(y({},f||{}),{[e]:!1}))},[e,r]),l=c.useCallback((d,f={})=>{if(!e)return;const h=r.getState(),v=[];if(f!=null&&f.deselectOthers){const g=Object.keys(h.iiif.entities.AnnotationPage);for(const p of g){const S=Zt(h,p);S&&S.views&&S.views[e]&&v.push(p)}}for(const g of v)u(g);r.setMetaValue([d,"annotationPageManager","views"],g=>g&&g[e]?g:x(y({},g||{}),{[e]:!0}))},[e,u,r]);return{availablePageIds:o,enabledPageIds:s,setPageEnabled:l,setPageDisabled:u}}function $e(e,t){return b((r,n)=>n.get(e.map(a=>({id:a,type:t}))),[e,t])}const qe=V.default.createContext(new k.ImageServiceLoader);function Z(){return c.useContext(qe)}function Qe(){const e=Z(),[t,r]=c.useState({}),n=c.useRef(!1);return c.useEffect(()=>()=>{n.current=!0},[]),[c.useCallback((i,{height:o,width:s})=>{if(i){const u=i.id||i["@id"],l=e.loadServiceSync({id:u,width:i.width||s,height:i.height||o,source:i});l?i=l:t[u]||(n.current||r(d=>x(y({},d),{[u]:"loading"})),e.loadService({id:u,width:i.width||s,height:i.height||o}).then(()=>{n.current||r(d=>x(y({},d),{[u]:"done"}))}))}return i},[e,t]),t]}function ee(e={}){const t=O(e.canvasId?{id:e.canvasId}:void 0);return b((r,n)=>{if(!t)return[];const a=n.get(t.items),i=[];for(const o of a)i.push(...n.get(o.items));return i},[t])}function ze(e,t=[]){const r=A(),n=ee(),[a,i]=c.useState((e==null?void 0:e.defaultChoices)||[]),o=c.useMemo(()=>Be(r,n,a),[r,n,a,...t]),u={makeChoice:c.useCallback((l,{deselectOthers:d=!0,deselect:f=!1}={})=>{if(o.choice){if(o.choice.type!=="single-choice")throw new Error("Complex choice not supported yet");i(h=>{if(f){const g=h.filter(p=>p!==l);if(g.length===0){const p=o.items[0].resource.id;return p?[p]:[]}return g}if(d)return[l];const v=[...h];if(v.length===0&&o.items.length){const g=o.items[0].resource.id;g&&v.push(g)}return h.indexOf(l)!==-1?h:[...h,l]})}},[o.choice])};return[o,u]}function Ge(e,t,r){const n=[];for(const a of t.items){const i=a.resource&&a.resource.type==="SpecificResource"?a.resource.source:a.resource;if(!i.id)return w("No resource Identifier");let o;if(i.service){const p=k.getImageServices(i);p[0]&&(o=r(p[0],e))}const{selector:s,source:u}=_(a.target);if(u.id!==e.id)continue;const l={type:"BoxSelector",spatial:{x:0,y:0,width:e.width,height:e.height}},d=s?s.type==="TemporalSelector"?{type:"TemporalBoxSelector",temporal:s.temporal,spatial:l.spatial}:s:null,f={type:"BoxSelector",spatial:{x:0,y:0,width:e.width,height:e.height}},h=a.resource.type==="SpecificResource"?_(a.resource):null,v=h&&h.selector&&(h.selector.type==="BoxSelector"||h.selector.type==="TemporalBoxSelector")?{type:"BoxSelector",spatial:{x:h.selector.spatial.x,y:h.selector.spatial.y,width:h.selector.spatial.width,height:h.selector.spatial.height}}:f;o&&!o.id&&(o.id=o["@id"]);const g={id:i.id,type:"Image",width:d?i.width:e.width,height:d?i.height:e.height,service:o,sizes:o&&o.sizes?o.sizes:i.width&&i.height?[{width:i.width,height:i.height}]:[],target:d&&d.type!=="PointSelector"?d:l,selector:v};n.push(g)}return{type:"images",image:n[0],images:n,choice:t.choice}}const en=["model/gltf-binary"];function tn(e,t){const n=t.items[0].resource;return n.format?en.indexOf(n.format)===-1?w(`3D format: ${n.format} is unsupported`):{type:"3d-model",model:n}:w("Unknown format")}function nn(e,t){var n;if(!e.duration)return w("No duration on canvas");if(t.items.length>1)return w("Only one audio source supported");const r=(n=t.items[0])==null?void 0:n.resource;return r?r.format?{type:"media",media:{duration:e.duration,url:r.id,type:"Sound",target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:r.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},annotations:{pages:[]}}:w("Audio does not have format"):w("Unknown audio")}function rn(e,t){var a;const r=t.items.filter(i=>i.type==="video");if(!e.duration)return w("No duration on canvas");if(r.length>1)return w("Only one video source supported");const n=(a=r[0])==null?void 0:a.resource;return n?n.format?{type:"media",media:{duration:e.duration,url:n.id,type:"Video",items:[],target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:n.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},annotations:{pages:[]}}:w("Video does not have format"):w("Unknown video")}function Ke(e){const t=Y(),r=O(),n=A(),[a,i]=Qe(),{enabledPageIds:o}=Ye((e==null?void 0:e.annotationPageManagerId)||(t==null?void 0:t.id)||(r==null?void 0:r.id),{all:!1}),s=$e(o,"AnnotationPage"),u=(e==null?void 0:e.strategies)||["images","media","complex-timeline"],[l,d]=ze(e,[i]),f=c.useMemo(()=>{if(!r||l.types.length===0)return ie;if(l.types.length!==1)if(l.types.length===2&&l.types.indexOf("text")!==-1)l.types=l.types.filter(v=>v!=="text");else return u.indexOf("complex-timeline")===-1?w("Complex timeline not supported"):w("ComplexTimelineStrategy not yet supported");const h=l.types[0];return h==="image"?u.indexOf("images")===-1?w("Image not supported"):Ge(r,l,a):h==="Model"||h==="model"?u.indexOf("3d-model")===-1?w("3D not supported"):tn(r,l):h==="sound"||h==="audio"?u.indexOf("media")===-1?w("Media not supported"):nn(r,l):h==="video"?u.indexOf("media")===-1?w("Media not supported"):rn(r,l):ie},[r,l,n,d.makeChoice]);return c.useMemo(()=>f.type==="unknown"?[f,je]:[x(y({},f),{annotations:{pages:s}}),d],[f,s])}const We=(e,t=[])=>{const r=A();c.useEffect(()=>{e(r)},[r,...t])};function on(e,t={}){const r=t.imageServiceLoader||new k.ImageServiceLoader;async function n(a,i,o,s=[],u){if(typeof a=="string")return{best:k.getFixedSizeFromImage(a),fallback:[],log:[]};const l=e.get(a);if(typeof l=="string")return{best:k.getFixedSizeFromImage(l),fallback:[],log:[]};switch(l.type){case"Annotation":{const d=l.body,f=e.get(d[0]);return u&&!f.width&&(f.width=u.width,f.height=u.height),await r.getThumbnailFromResource(f,i,o,s)}case"Canvas":{const d=l;if(d.thumbnail&&d.thumbnail.length){const f=e.get(d.thumbnail[0]),h=await r.getImageCandidates(f,o);h&&h.length&&s.push(...h)}return n(d.items[0],i,o,s,{width:d.width,height:d.height})}case"AnnotationPage":return n(l.items[0],i,o,s,u);case"Choice":return n(l.items[0],i,o,s,u);case"Collection":{const f=l.items[0];return n(f,i,o,s,u)}case"Manifest":{const f=l.items[0];return n(f,i,o,s,u)}case"SpecificResource":case"Image":case"Dataset":case"Sound":case"Text":case"TextualBody":case"Video":return u&&!l.width&&(l.width=u.width,l.height=u.height),r.getThumbnailFromResource(l,i,o,s);case"Service":case"Range":case"AnnotationCollection":case"CanvasReference":case"ContentResource":return{best:void 0,fallback:[],log:[]}}return{best:void 0,fallback:[],log:[]}}return{getBestThumbnailAtSize:n}}function Je(e,t,{canvasId:r,manifestId:n}={}){const a=A(),i=Z(),o=c.useMemo(()=>on(a,{imageServiceLoader:i}),[a,i]),[s,u]=c.useState(),l=Y(n?{id:n}:void 0),d=O(r?{id:r}:void 0),f=d||l,h=c.useRef(!1);if(c.useEffect(()=>()=>{h.current=!0},[]),!f)throw new Error("Must be called under a manifest or canvas context.");return We(v=>{o.getBestThumbnailAtSize(f,e,t).then(g=>{g.best&&!h.current&&u(g.best)})},[f]),s}function an(e){return{isMuted:!1,playRequested:!1,isPlaying:!1,isFinished:!1,volume:100,duration:e}}function sn(e,t){switch(t.type){case"FINISHED":return x(y({},e),{isFinished:!0,isPlaying:!1,playRequested:!1});case"PLAY_PAUSE":return x(y({},e),{isFinished:!1,isPlaying:!e.isPlaying});case"PLAY_REQUESTED":return x(y({},e),{isFinished:!1,playRequested:!0});case"PAUSE":return x(y({},e),{isPlaying:!1});case"PLAY":return x(y({},e),{isFinished:!1,playRequested:!1,isPlaying:!0});case"MUTE":return x(y({},e),{isMuted:!0});case"SET_VOLUME":return x(y({},e),{volume:t.volume,isMuted:t.volume===0});case"TOGGLE_MUTE":return x(y({},e),{isMuted:!e.isMuted});case"UNMUTE":return x(y({},e),{isMuted:!1})}return e}function Xe(e){const t=Math.round(e);return`${Math.floor(t/60)}:${`${t%60}`.padStart(2,"0")}`}function fe(e){const[t,r]=c.useReducer(sn,an(e.duration)),n=c.useRef(null),a=c.useRef(null),i=c.useRef(null),o=c.useRef(!1),s=c.useCallback(()=>{a.current&&n.current&&(a.current.innerHTML=Xe(n.current.currentTime),i.current&&(i.current.style.width=`${n.current.currentTime/e.duration*100}%`),o.current!==n.current.muted&&(o.current=n.current.muted,r(n.current.muted?{type:"MUTE"}:{type:"UNMUTE"})))},[e.duration]),u=c.useCallback(()=>{n.current&&(r({type:"PLAY_REQUESTED"}),n.current.play().then(()=>{r({type:"PLAY"})}),s())},[s]),l=c.useCallback(()=>{n.current&&(n.current.duration>0&&n.current.paused?u():d())},[s]),d=c.useCallback(()=>{n.current&&(n.current.pause(),r({type:"PAUSE"}),s())},[s]),f=c.useCallback(()=>{n.current&&(n.current.muted=!n.current.muted,r(n.current.muted?{type:"MUTE"}:{type:"UNMUTE"}))},[]),h=c.useCallback(()=>{n.current&&(n.current.muted=!0,r({type:"MUTE"}))},[]),v=c.useCallback(()=>{n.current&&(n.current.muted=!1,r({type:"UNMUTE"}))},[]),g=c.useCallback(C=>{n.current&&(n.current.muted=!1,n.current.volume=C/100,r({type:"SET_VOLUME",volume:C}))},[]),p=c.useCallback(C=>{n.current&&(n.current.currentTime=Math.max(0,Math.min(C*e.duration,e.duration)),s())},[]),S=c.useCallback(C=>{n.current&&(n.current.currentTime=Math.max(0,Math.min(C,e.duration)),s())},[]);return c.useEffect(()=>{const C=setInterval(()=>{s()},350);return()=>clearInterval(C)},[s,e.duration]),c.useEffect(()=>{const C=()=>{r({type:"FINISHED"})},E=n.current;return E==null||E.addEventListener("ended",C),()=>E==null?void 0:E.removeEventListener("ended",C)},[]),[{element:n,currentTime:a,progress:i},t,{play:u,pause:d,playPause:l,mute:h,unmute:v,toggleMute:f,setVolume:g,setDurationPercent:p,setTime:S}]}const Ze=c.createContext(null),et=c.createContext(null),tt=c.createContext(null);function cn(){const e=c.useContext(Ze);if(!e)throw new Error("Ctx not found");return e}function un(){const e=c.useContext(et);if(!e)throw new Error("Ctx not found");return e}function ln(){const e=c.useContext(tt);if(!e)throw new Error("Ctx not found");return e}function pe({actions:e,state:t,children:r,currentTime:n,progress:a,element:i}){return m(tt.Provider,{value:{currentTime:n,progress:a,element:i},children:m(et.Provider,{value:e,children:m(Ze.Provider,{value:t,children:r})})})}function dn({media:e,children:t}){const[{element:r,currentTime:n,progress:a},i,o]=fe({duration:e.duration});return m(D,{children:m(U,{children:T(pe,{state:i,actions:o,currentTime:n,progress:a,element:r,children:[m("audio",{ref:r,src:e.url}),t]})})})}function fn({media:e,children:t}){const[{element:r,currentTime:n,progress:a},i,o]=fe({duration:e.duration});return T(D,{children:[T(U,{overlay:!0,children:[m("style",{children:`
10
+ .video-container {
11
+ position: absolute;
12
+ top: 0;
13
+ bottom: 0;
14
+ left: 0;
15
+ right: 0;
16
+ background: #000;
17
+ z-index: 13;
18
+ display: flex;
19
+ justify-content: center;
20
+ pointer-events: visible;
21
+ }
22
+ `}),m("div",{className:"video-container",part:"video-container",onClick:()=>o.playPause(),children:m("video",{ref:r,src:e.url,style:{width:"100%",objectFit:"contain"}})})]}),m(U,{children:m(pe,{state:i,actions:o,currentTime:n,progress:a,element:r,children:t})})]})}function pn({model:e}){return T(U,{overlay:!0,children:[m("style",{children:`
23
+ .model-container {
24
+ position: absolute;
25
+ top: 0;
26
+ bottom: 0;
27
+ left: 0;
28
+ right: 0;
29
+ background: #000;
30
+ z-index: 13;
31
+ display: flex;
32
+ justify-content: center;
33
+ pointer-events: visible;
34
+ }
35
+ `}),m("div",{className:"model-container",children:m("model-viewer",{"interaction-prompt":"none",style:{width:"100%",height:"100%"},"camera-controls":"","ar-status":"not-presenting",src:e.id})})]})}function nt({x:e,y:t,onChoiceChange:r,registerActions:n,defaultChoices:a,isStatic:i,renderViewerControls:o,renderMediaControls:s,strategies:u,children:l}){const d=O(),f=le(d,["deep-zoom"]),[h]=_e(),v=A(),g=c.useMemo(()=>de(v),[v]),[p,S]=Ke({strategies:u||["images"],defaultChoices:a==null?void 0:a.map(({id:I})=>I)}),C=p.type==="images"?p.choice:void 0;c.useEffect(()=>{n&&n(S)},[p.annotations]),c.useEffect(()=>{if(a)for(const I of a)typeof I.opacity!="undefined"&&g.applyStyles({id:I.id},"atlas",{opacity:I.opacity})},[a]),c.useLayoutEffect(()=>{r&&r(C)},[C]);const E=Je({maxWidth:256,maxHeight:256});if(!d)return null;const R=d.accompanyingCanvas,M=E&&E.type==="fixed"?m("world-object",{height:d.height,width:d.width,x:e,y:t,children:m("world-image",{uri:E.id,target:{x:0,y:0,width:d.width,height:d.height},display:E.width&&E.height?{width:E.width,height:E.height}:void 0})}):null;if(p.type==="unknown"){if(M)return M;throw new Error(p.reason||"Unknown image strategy")}const ot=T(c.Fragment,{children:[h?m(oe,{page:h}):null,p.annotations&&p.annotations.pages?p.annotations.pages.map(I=>m(oe,{page:I},I.id)):null,l]});return T(D,{children:[T("world-object",x(y({height:d.height,width:d.width,x:e,y:t},f),{children:[p.type==="images"?T(D,{children:[p.images.map((I,it)=>m(De,{isStatic:i,image:I,id:I.id,thumbnail:it===0?E:void 0,annotations:ot},I.id)),o?m(U,{overlay:!0,children:o(p)}):null]}):null,p.type==="3d-model"?m(pn,{model:p.model}):null,p.type==="media"?m(D,{children:p.media.type==="Sound"?T(dn,{media:p.media,children:[M,s?s(p):null]}):p.media.type==="Video"?T(fn,{media:p.media,children:[M,s?s(p):null]}):null}):null]}),p.type),p.type==="media"&&p.media.type==="Sound"&&R?m(se,{canvas:R.id,children:m(nt,{renderViewerControls:o})}):null]})}const mn={RenderImage:De,RenderCanvas:nt,RenderAnnotationPage:oe,RenderAnnotation:Ue,Viewer:Gt};function gn({annotation:e,children:t}){return m(F,{value:{annotation:e},children:t})}function hn({collection:e,children:t}){return m(F,{value:{collection:e},children:t})}function vn({range:e,children:t}){return m(F,{value:{range:e},children:t})}function yn(e,t={}){return ee(t)}function Sn(e,t=!1){}function En(e,t=[]){const{id:r,selector:n}=e,a=L(),i=r||a.collection,o=b(s=>i?s.iiif.entities.Collection[i]:void 0,[i]);return c.useMemo(()=>{if(!!o)return n?n(o):o},[o,n,...t])}function Cn(e,t,r,n,a=[]){const i=A(),o=c.useMemo(()=>Le(i),[i]);c.useEffect(()=>{const s=e;return s?(o.addEventListener(s,t,r,n),()=>{o.removeEventListener(s,t,r)}):()=>{}},[o,e,t,...a])}function xn(){const e=c.useContext(B);return e&&e.vault?e.vault:Q.globalVault()}function Rn(e,t){const{id:r,isLoaded:n,error:a,resource:i,requestId:o,cached:s}=ae(e,t);return{id:r,isLoaded:n,error:a,manifest:i,requestId:o,cached:s}}function rt({cacheKey:e}={}){const t=O(),r=ee(),n=A(),a=Z(),[i,o]=c.useState(void 0),[s,u]=c.useState(!1),[l,d]=c.useState("idle"),[f,h]=c.useState(void 0),v=t?t.id:"undefined",g=c.useMemo(()=>{try{if(t&&r.length){const S=r[0],C=n.get(S.body[0]),R=k.getImageServices(C)[0];return R&&a.loadServiceSync({id:R.id||R["@id"],width:R.width||t.width,height:R.height||t.height})||void 0}}catch(S){console.error(S)}},[v,e,t]),p=l==="success"&&i?i:g;return c.useEffect(()=>{(async()=>{try{if(t&&r.length){const S=r[0],C=n.get(S.body[0]),R=k.getImageServices(C)[0];if(!R)return;u(!0),d("loading");try{const M=await a.loadService({id:R.id||R["@id"],width:R.width||t.width,height:R.height||t.height})||void 0;o(M),d("success"),u(!1)}catch(M){d("error"),h(M)}}}catch(S){d("error"),h(S)}})()},[v,e]),c.useMemo(()=>({data:p,isFetching:s,status:l,error:f}),[p,s,l,f])}function wn(){const e=rt();return{isLoading:e.isFetching,tile:e.data?{id:e.data.id||e.data["@id"],width:e.data.width,height:e.data.height,imageService:e.data,thumbnail:void 0}:null}}function An(e={},t=[]){const{id:r,selector:n}=e,a=L(),i=r||a.range,o=b(s=>i?s.iiif.entities.Range[i]:void 0,[i]);return c.useMemo(()=>{if(!!o)return n?n(o):o},[o,n,...t])}function Pn(){const e=Y();return e?e.service.find(t=>t.profile==="SearchService1"||t.profile==="http://iiif.io/api/search/1/search"):void 0}function bn(){const e=A();return c.useMemo(()=>de(e),[e])}exports.AnnotationContext=gn;exports.CanvasContext=se;exports.CanvasPanel=mn;exports.CanvasPortal=U;exports.CollectionContext=hn;exports.ContextBridge=be;exports.ImageServiceLoaderContext=qe;exports.ManifestContext=we;exports.MediaPlayerProvider=pe;exports.OverlayPortalContext=ue;exports.PortalContext=ce;exports.RangeContext=vn;exports.ReactVaultContext=B;exports.ResourceProvider=F;exports.ResourceReactContext=J;exports.SimpleViewerProvider=xt;exports.SimpleViewerReactContext=H;exports.VaultProvider=xe;exports.ViewerPresetContext=X;exports.VirtualAnnotationProvider=Oe;exports.VisibleCanvasReactContext=j;exports.emptyActions=je;exports.expandTarget=_;exports.flattenAnnotationPageIds=He;exports.formatTime=Xe;exports.getImageStrategy=Ge;exports.getPaintables=Be;exports.parseSelector=G;exports.parseSpecificResource=Ne;exports.unknownResponse=ie;exports.unsupportedStrategy=w;exports.useAnnotation=Fe;exports.useAnnotationPageManager=Ye;exports.useAnnotationsAtTime=yn;exports.useCanvas=O;exports.useCanvasClock=Sn;exports.useCollection=En;exports.useContextBridge=Pe;exports.useDispatch=Me;exports.useEventListener=Cn;exports.useExistingVault=xn;exports.useExternalCollection=Rn;exports.useExternalManifest=Re;exports.useExternalResource=ae;exports.useImageService=rt;exports.useImageServiceLoader=Z;exports.useImageTile=wn;exports.useLoadImageService=Qe;exports.useManifest=Y;exports.useMediaActions=un;exports.useMediaElements=ln;exports.useMediaState=cn;exports.usePaintables=ze;exports.usePaintingAnnotations=ee;exports.useRange=An;exports.useRenderingStrategy=Ke;exports.useResourceContext=L;exports.useResourceEvents=le;exports.useResources=$e;exports.useSearchService=Pn;exports.useSimpleMediaPlayer=fe;exports.useSimpleViewer=Rt;exports.useStyleHelper=bn;exports.useStyles=N;exports.useThumbnail=Je;exports.useVault=A;exports.useVaultEffect=We;exports.useVaultSelector=b;exports.useViewerPreset=Ve;exports.useVirtualAnnotationPage=Te;exports.useVirtualAnnotationPageContext=_e;exports.useVisibleCanvases=Ae;
36
+ //# sourceMappingURL=index.js.map