react-iiif-vault 0.9.14 → 0.9.17

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 (36) hide show
  1. package/.build/types/canvas-panel/Viewer.d.ts +1 -1
  2. package/.build/types/canvas-panel/index.d.ts +2 -0
  3. package/.build/types/canvas-panel/render/Canvas.d.ts +8 -3
  4. package/.build/types/canvas-panel/render/CanvasBackground.d.ts +4 -0
  5. package/.build/types/canvas-panel/render/Image.d.ts +2 -2
  6. package/.build/types/context/AnnotationPageContext.d.ts +5 -0
  7. package/.build/types/context/ContextBridge.d.ts +1 -9
  8. package/.build/types/context/PortalContext.d.ts +3 -2
  9. package/.build/types/context/ResourceContext.d.ts +1 -0
  10. package/.build/types/features/rendering-strategy/3d-strategy.d.ts +1 -1
  11. package/.build/types/features/rendering-strategy/rendering-utils.d.ts +5 -1
  12. package/.build/types/features/rendering-strategy/resource-types.d.ts +3 -0
  13. package/.build/types/features/rendering-strategy/strategies.d.ts +10 -1
  14. package/.build/types/features/rendering-strategy/textual-content-strategy.d.ts +17 -0
  15. package/.build/types/future-helpers/ranges.d.ts +6 -0
  16. package/.build/types/future-helpers/sequences.d.ts +6 -0
  17. package/.build/types/hooks/useCanvasSubset.d.ts +2 -0
  18. package/.build/types/index.d.ts +6 -0
  19. package/.build/types/viewers/SimpleViewerContext.d.ts +4 -16
  20. package/.build/types/viewers/SimpleViewerContext.hooks.d.ts +14 -0
  21. package/.build/types/viewers/SimpleViewerContext.types.d.ts +42 -0
  22. package/dist/bundle/cjs/index.js +5 -3
  23. package/dist/bundle/cjs/index.js.map +1 -1
  24. package/dist/bundle/esm/index.mjs +1028 -210
  25. package/dist/bundle/esm/index.mjs.map +1 -1
  26. package/dist/canvas-panel/cjs/canvas-panel.js +5 -3
  27. package/dist/canvas-panel/cjs/canvas-panel.js.map +1 -1
  28. package/dist/canvas-panel/esm/canvas-panel.mjs +731 -95
  29. package/dist/canvas-panel/esm/canvas-panel.mjs.map +1 -1
  30. package/dist/index.umd.js +22 -20
  31. package/dist/index.umd.js.map +1 -1
  32. package/dist/react17/cjs/index.js +30 -0
  33. package/dist/react17/cjs/index.js.map +1 -0
  34. package/dist/react17/esm/index.mjs +3198 -0
  35. package/dist/react17/esm/index.mjs.map +1 -0
  36. package/package.json +17 -11
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- import { AtlasProps } from '@atlas-viewer/atlas/dist/types/modules/react-reconciler/Atlas';
2
+ import { AtlasProps } from '@atlas-viewer/atlas';
3
3
  export declare function Viewer({ children, errorFallback, outerContainerProps, ...props }: AtlasProps & {
4
4
  height?: number | string;
5
5
  width?: number | string;
@@ -1,6 +1,7 @@
1
1
  import { Viewer } from './Viewer';
2
2
  import { RenderCanvas } from './render/Canvas';
3
3
  import { RenderImage } from './render/Image';
4
+ import { CanvasBackground } from './render/CanvasBackground';
4
5
  export declare const CanvasPanel: {
5
6
  RenderImage: typeof RenderImage;
6
7
  RenderCanvas: typeof RenderCanvas;
@@ -15,4 +16,5 @@ export declare const CanvasPanel: {
15
16
  interactive?: boolean | undefined;
16
17
  }>;
17
18
  Viewer: typeof Viewer;
19
+ CanvasBackground: typeof CanvasBackground;
18
20
  };
@@ -1,8 +1,10 @@
1
1
  import { ReactNode } from 'react';
2
+ import { BoxStyle } from '@atlas-viewer/atlas';
2
3
  import { ChoiceDescription } from '../../features/rendering-strategy/choice-types';
3
4
  import { StrategyActions } from '../../hooks/useRenderingStrategy';
4
- import { MediaStrategy, RenderingStrategy } from '../../features/rendering-strategy/strategies';
5
+ import { EmptyStrategy, MediaStrategy, RenderingStrategy } from '../../features/rendering-strategy/strategies';
5
6
  import { SingleImageStrategy } from '../../features/rendering-strategy/image-strategy';
7
+ import { ImageWithOptionalService } from '../../features/rendering-strategy/resource-types';
6
8
  declare type CanvasProps = {
7
9
  x?: number;
8
10
  y?: number;
@@ -15,9 +17,12 @@ declare type CanvasProps = {
15
17
  }>;
16
18
  isStatic?: boolean;
17
19
  children?: ReactNode;
18
- renderViewerControls?: (strategy: SingleImageStrategy) => ReactNode;
20
+ renderViewerControls?: (strategy: SingleImageStrategy | EmptyStrategy) => ReactNode;
19
21
  renderMediaControls?: (strategy: MediaStrategy) => ReactNode;
20
22
  strategies?: Array<RenderingStrategy['type']>;
23
+ backgroundStyle?: BoxStyle;
24
+ alwaysShowBackground?: boolean;
25
+ onClickPaintingAnnotation?: (id: string, image: ImageWithOptionalService, e: any) => void;
21
26
  };
22
- export declare function RenderCanvas({ x, y, onChoiceChange, registerActions, defaultChoices, isStatic, renderViewerControls, renderMediaControls, strategies, children, }: CanvasProps): JSX.Element | null;
27
+ export declare function RenderCanvas({ x, y, onChoiceChange, registerActions, defaultChoices, isStatic, renderViewerControls, renderMediaControls, strategies, backgroundStyle, alwaysShowBackground, onClickPaintingAnnotation, children, }: CanvasProps): JSX.Element | null;
23
28
  export {};
@@ -0,0 +1,4 @@
1
+ import { BoxStyle } from '@atlas-viewer/atlas';
2
+ export declare function CanvasBackground({ style }: {
3
+ style?: BoxStyle;
4
+ }): JSX.Element | null;
@@ -1,13 +1,13 @@
1
1
  import { ImageCandidate } from '@atlas-viewer/iiif-image-api';
2
2
  import { ReactNode } from 'react';
3
3
  import { ImageWithOptionalService } from '../../features/rendering-strategy/resource-types';
4
- export declare function RenderImage({ id, image, thumbnail, isStatic, x, y, annotations, children, }: {
4
+ export declare function RenderImage({ id, image, thumbnail, isStatic, x, y, children, onClick, }: {
5
5
  id: string;
6
6
  image: ImageWithOptionalService;
7
7
  thumbnail?: ImageCandidate;
8
8
  isStatic?: boolean;
9
9
  x?: number;
10
10
  y?: number;
11
- annotations?: ReactNode;
12
11
  children?: ReactNode;
12
+ onClick?: (e: any) => void;
13
13
  }): JSX.Element;
@@ -0,0 +1,5 @@
1
+ import { ReactNode } from 'react';
2
+ export declare function AnnotationPageContext({ annotationPage, children }: {
3
+ annotationPage: string;
4
+ children: ReactNode;
5
+ }): JSX.Element;
@@ -5,15 +5,7 @@ export declare function useContextBridge(): {
5
5
  setVaultInstance: (vault: import("@iiif/vault/*").Vault) => void;
6
6
  };
7
7
  ResourceContext: import("./ResourceContext").ResourceContextType;
8
- SimpleViewerReactContext: {
9
- setCurrentCanvasId: (newId: string | ((prev: string) => string)) => void;
10
- setCurrentCanvasIndex: (newId: number | ((prev: number) => number)) => void;
11
- currentCanvasIndex: number;
12
- pagingView: boolean;
13
- totalCanvases: number;
14
- nextCanvas: () => void;
15
- previousCanvas: () => void;
16
- };
8
+ SimpleViewerReactContext: import("..").SimpleViewerContext;
17
9
  VisibleCanvasReactContext: string[];
18
10
  };
19
11
  export declare function ContextBridge(props: {
@@ -1,6 +1,7 @@
1
1
  import React, { ReactNode } from 'react';
2
- export declare const PortalContext: React.Context<HTMLDivElement | null>;
3
- export declare const OverlayPortalContext: React.Context<HTMLDivElement | null>;
2
+ import { Root } from 'react-dom/client';
3
+ export declare const PortalContext: React.Context<Root | null>;
4
+ export declare const OverlayPortalContext: React.Context<Root | null>;
4
5
  export declare function CanvasPortal({ children, overlay }: {
5
6
  children: ReactNode;
6
7
  overlay?: boolean;
@@ -5,6 +5,7 @@ export declare type ResourceContextType = {
5
5
  range?: string;
6
6
  canvas?: string;
7
7
  annotation?: string;
8
+ annotationPage?: string;
8
9
  };
9
10
  export declare const ResourceReactContext: React.Context<ResourceContextType>;
10
11
  export declare const useResourceContext: () => ResourceContextType;
@@ -2,7 +2,7 @@ import { CanvasNormalized } from '@iiif/presentation-3';
2
2
  import { Paintables } from './rendering-utils';
3
3
  import { AnnotationPageDescription } from './resource-types';
4
4
  import { ChoiceDescription } from './choice-types';
5
- import { ExternalWebResource } from '@iiif/presentation-3/resources/annotation';
5
+ import { ExternalWebResource } from '@iiif/presentation-3';
6
6
  import { RenderingStrategy } from './strategies';
7
7
  export declare type Single3DModelStrategy = {
8
8
  type: '3d-model';
@@ -1,12 +1,14 @@
1
- import { AnnotationNormalized, ContentResource, IIIFExternalWebResource, SpecificResource } from '@iiif/presentation-3';
1
+ import { AnnotationNormalized, CanvasNormalized, ContentResource, IIIFExternalWebResource, PointSelector, SpecificResource, W3CAnnotationTarget } from '@iiif/presentation-3';
2
2
  import { Vault } from '@iiif/vault';
3
3
  import { ChoiceDescription } from './choice-types';
4
4
  import { UseRenderingStrategy } from '../../hooks/useRenderingStrategy';
5
+ import { BoxSelector, SupportedTarget, TemporalBoxSelector } from '@iiif/vault-helpers';
5
6
  export declare function parseSpecificResource(resource: ContentResource): any[];
6
7
  export interface Paintables {
7
8
  choice: ChoiceDescription | null;
8
9
  types: string[];
9
10
  items: Array<{
11
+ annotationId: string;
10
12
  type: string;
11
13
  resource: IIIFExternalWebResource | SpecificResource;
12
14
  target: any;
@@ -14,8 +16,10 @@ export interface Paintables {
14
16
  }>;
15
17
  }
16
18
  export declare function getPaintables(vault: Vault, paintingAnnotations: AnnotationNormalized[], enabledChoices: string[]): Paintables;
19
+ export declare function getParsedTargetSelector(canvas: CanvasNormalized, target: W3CAnnotationTarget | W3CAnnotationTarget[]): [TemporalBoxSelector | BoxSelector | PointSelector | null, SupportedTarget['source']];
17
20
  export declare const emptyActions: {
18
21
  makeChoice: () => void;
19
22
  };
20
23
  export declare const unknownResponse: UseRenderingStrategy[0];
21
24
  export declare const unsupportedStrategy: (reason: string) => UseRenderingStrategy[0];
25
+ export declare const emptyStrategy: (width: number, height: number) => UseRenderingStrategy[0];
@@ -2,6 +2,7 @@ import { AnnotationPageNormalized, ImageService } from '@iiif/presentation-3';
2
2
  import { BoxSelector, TemporalBoxSelector, TemporalSelector } from '@iiif/vault-helpers/annotation-targets';
3
3
  export declare type ImageWithOptionalService = {
4
4
  id: string;
5
+ annotationId: string;
5
6
  type: 'Image';
6
7
  service?: ImageService;
7
8
  width?: number;
@@ -15,6 +16,7 @@ export declare type ImageWithOptionalService = {
15
16
  };
16
17
  export declare type SingleAudio = {
17
18
  type: 'Sound';
19
+ annotationId: string;
18
20
  url: string;
19
21
  format: string;
20
22
  duration: number;
@@ -23,6 +25,7 @@ export declare type SingleAudio = {
23
25
  };
24
26
  export declare type SingleVideo = {
25
27
  type: 'Video';
28
+ annotationId: string;
26
29
  url: string;
27
30
  format: string;
28
31
  duration: number;
@@ -2,6 +2,7 @@ import { AnnotationPageDescription, AudioSequence, ImageWithOptionalService, Sin
2
2
  import { ChoiceDescription } from './choice-types';
3
3
  import { SingleImageStrategy } from './image-strategy';
4
4
  import { Single3DModelStrategy } from './3d-strategy';
5
+ import { TextualContentStrategy } from './textual-content-strategy';
5
6
  export declare type MediaStrategy = {
6
7
  type: 'media';
7
8
  media: SingleAudio | SingleVideo | AudioSequence | VideoSequence;
@@ -14,9 +15,17 @@ export declare type ComplexTimelineStrategy = {
14
15
  choice?: ChoiceDescription;
15
16
  annotations?: AnnotationPageDescription;
16
17
  };
18
+ export declare type EmptyStrategy = {
19
+ type: 'empty';
20
+ image: null;
21
+ images: [];
22
+ height: number;
23
+ width: number;
24
+ annotations?: AnnotationPageDescription;
25
+ };
17
26
  export declare type UnknownStrategy = {
18
27
  type: 'unknown';
19
28
  reason?: string;
20
29
  annotations?: AnnotationPageDescription;
21
30
  };
22
- export declare type RenderingStrategy = SingleImageStrategy | MediaStrategy | ComplexTimelineStrategy | Single3DModelStrategy | UnknownStrategy;
31
+ export declare type RenderingStrategy = SingleImageStrategy | MediaStrategy | ComplexTimelineStrategy | Single3DModelStrategy | TextualContentStrategy | UnknownStrategy | EmptyStrategy;
@@ -0,0 +1,17 @@
1
+ import { CanvasNormalized, InternationalString } from '@iiif/presentation-3';
2
+ import { ChoiceDescription } from './choice-types';
3
+ import { AnnotationPageDescription } from './resource-types';
4
+ import { Paintables } from './rendering-utils';
5
+ import { RenderingStrategy } from './strategies';
6
+ import { SupportedTarget } from '@iiif/vault-helpers';
7
+ export declare type TextualContentStrategy = {
8
+ type: 'textual-content';
9
+ items: {
10
+ annotationId: string;
11
+ text: InternationalString;
12
+ target: SupportedTarget | null;
13
+ }[];
14
+ choice?: ChoiceDescription;
15
+ annotations?: AnnotationPageDescription;
16
+ };
17
+ export declare function getTextualContentStrategy(canvas: CanvasNormalized, paintables: Paintables): RenderingStrategy;
@@ -0,0 +1,6 @@
1
+ import { Vault } from '@iiif/vault';
2
+ import { ManifestNormalized, RangeNormalized, Reference } from '@iiif/presentation-3';
3
+ export declare function findFirstCanvasFromRange(vault: Vault, range: RangeNormalized): null | Reference<'Canvas'>;
4
+ export declare function findAllCanvasesInRange(vault: Vault, range: RangeNormalized): Array<Reference<'Canvas'>>;
5
+ export declare function findManifestSelectedRange(vault: Vault, manifest: ManifestNormalized, canvasId: string): null | RangeNormalized;
6
+ export declare function findSelectedRange(vault: Vault, range: RangeNormalized, canvasId: string): null | RangeNormalized;
@@ -0,0 +1,6 @@
1
+ import { ManifestNormalized, RangeNormalized, Reference } from '@iiif/presentation-3';
2
+ import { Vault } from '@iiif/vault';
3
+ export declare function getVisibleCanvasesFromCanvasId(vault: Vault, manifestOrRange: ManifestNormalized | RangeNormalized, canvasId: string | null, preventPaged?: boolean): Reference<'Canvas'>[];
4
+ export declare function getManifestSequence(vault: Vault, manifestOrRange: ManifestNormalized | RangeNormalized, { disablePaging }?: {
5
+ disablePaging?: boolean;
6
+ }): [Reference<'Canvas'>[], number[][]];
@@ -0,0 +1,2 @@
1
+ import { Reference } from '@iiif/presentation-3';
2
+ export declare function useCanvasSubset(idsOrRefs?: Array<string | Reference>): Reference<"Canvas">[];
@@ -1,5 +1,6 @@
1
1
  export * from './canvas-panel';
2
2
  export * from './context/AnnotationContext';
3
+ export * from './context/AnnotationPageContext';
3
4
  export * from './context/CanvasContext';
4
5
  export * from './context/CollectionContext';
5
6
  export * from './context/ManifestContext';
@@ -22,6 +23,7 @@ export * from './hooks/useAnnotationPageManager';
22
23
  export * from './hooks/useAnnotationsAtTime';
23
24
  export * from './hooks/useCanvas';
24
25
  export * from './hooks/useCanvasClock';
26
+ export * from './hooks/useCanvasSubset';
25
27
  export * from './hooks/useCollection';
26
28
  export * from './hooks/useDispatch';
27
29
  export * from './hooks/useEventListener';
@@ -52,3 +54,7 @@ export * from './hooks/useRenderingStrategy';
52
54
  export * from '@iiif/vault-helpers/annotation-targets';
53
55
  export * from './utility/flatten-annotation-page-ids';
54
56
  export * from './viewers/SimpleViewerContext';
57
+ export * from './viewers/SimpleViewerContext.hooks';
58
+ export * from './viewers/SimpleViewerContext.types';
59
+ export * from './future-helpers/sequences';
60
+ export * from './future-helpers/ranges';
@@ -1,18 +1,6 @@
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
- };
1
+ import React from 'react';
2
+ import { SimpleViewerContext, SimpleViewerProps } from './SimpleViewerContext.types';
11
3
  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;
4
+ export declare function InnerViewerProvider(props: SimpleViewerProps): JSX.Element;
5
+ export declare function SimpleViewerProvider(props: SimpleViewerProps): JSX.Element;
17
6
  export declare function useSimpleViewer(): SimpleViewerContext;
18
- export {};
@@ -0,0 +1,14 @@
1
+ export declare function useCanvasSequence({ startCanvas, disablePaging }: {
2
+ startCanvas?: string;
3
+ disablePaging?: boolean;
4
+ }): {
5
+ visibleItems: string[];
6
+ cursor: number;
7
+ items: import("@iiif/presentation-3").Reference<"Canvas">[];
8
+ sequence: number[][];
9
+ setSequenceIndex: import("react").Dispatch<import("react").SetStateAction<number>>;
10
+ setCanvasIndex: (index: number) => void;
11
+ setCanvasId: (id: string) => void;
12
+ next: () => void;
13
+ previous: () => void;
14
+ };
@@ -0,0 +1,42 @@
1
+ import { Reference } from '@iiif/presentation-3';
2
+ import { ReactNode } from 'react';
3
+ export declare type SimpleViewerContext = {
4
+ items: Reference<'Canvas'>[];
5
+ sequence: number[][];
6
+ setSequenceIndex: (newId: number) => void;
7
+ setCurrentCanvasId: (newId: string) => void;
8
+ setCurrentCanvasIndex: (newId: number) => void;
9
+ currentSequenceIndex: number;
10
+ nextCanvas: () => void;
11
+ previousCanvas: () => void;
12
+ };
13
+ export declare type SimpleViewerProps = {
14
+ manifest: string;
15
+ pagingEnabled?: boolean;
16
+ children: ReactNode;
17
+ startCanvas?: string;
18
+ rangeId?: string;
19
+ };
20
+ export declare type SimpleViewerReducerState = {
21
+ sequence: number[][];
22
+ availableCanvases: Reference<'Canvas'>[];
23
+ visibleCanvases: Reference<'Canvas'>[];
24
+ currentCanvas: string | null;
25
+ isPaged: boolean;
26
+ rangeId: string | null;
27
+ };
28
+ export interface SimpleViewerActions {
29
+ setCurrentCanvasId(newId: string): void;
30
+ setCurrentCanvasIndex(newId: number): void;
31
+ nextCanvas(): void;
32
+ previousCanvas(): void;
33
+ setCurrentRange(newId: string): void;
34
+ clearRange(): void;
35
+ setPagingEnabled(isEnabled: boolean): void;
36
+ }
37
+ export declare type SimpleViewerActionsType = {
38
+ [T in keyof SimpleViewerActions]: {
39
+ type: T;
40
+ payload: Parameters<SimpleViewerActions[T]>[0];
41
+ };
42
+ }[keyof SimpleViewerActions];
@@ -1,4 +1,4 @@
1
- "use strict";var ot=Object.defineProperty,st=Object.defineProperties;var at=Object.getOwnPropertyDescriptors;var H=Object.getOwnPropertySymbols;var de=Object.prototype.hasOwnProperty,fe=Object.prototype.propertyIsEnumerable;var le=(e,t,r)=>t in e?ot(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,y=(e,t)=>{for(var r in t||(t={}))de.call(t,r)&&le(e,r,t[r]);if(H)for(var r of H(t))fe.call(t,r)&&le(e,r,t[r]);return e},C=(e,t)=>st(e,at(t));var pe=(e,t)=>{var r={};for(var n in e)de.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&H)for(var n of H(e))t.indexOf(n)<0&&fe.call(e,n)&&(r[n]=e[n]);return r};Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var c=require("react"),Q=require("@atlas-viewer/atlas"),f=require("react/jsx-runtime"),q=require("@iiif/vault"),A=require("typesafe-actions"),ct=require("react-dom"),_=require("@atlas-viewer/iiif-image-api");function Se(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}function ut(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 X=ut(c),k=Se(c),lt=Se(ct);function Z(e,t){return Z=Object.setPrototypeOf||function(n,a){return n.__proto__=a,n},Z(e,t)}function dt(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,Z(e,t)}var ft=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])})},me={error:null},pt=function(e){dt(t,e);function t(){for(var n,a=arguments.length,o=new Array(a),i=0;i<a;i++)o[i]=arguments[i];return n=e.call.apply(e,[this].concat(o))||this,n.state=me,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(me)},r.componentDidCatch=function(a,o){var i,s;(i=(s=this.props).onError)==null||i.call(s,a,o)},r.componentDidUpdate=function(a,o){var i=this.state.error,s=this.props.resetKeys;if(i!==null&&o.error!==null&&ft(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,o=this.props,i=o.fallbackRender,s=o.FallbackComponent,u=o.fallback;if(a!==null){var l={error:a,resetErrorBoundary:this.resetErrorBoundary};if(X.isValidElement(u))return u;if(typeof i=="function")return i(l);if(s)return X.createElement(s,l);throw new Error("react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop")}return this.props.children},t}(X.Component);const mt={collection:void 0,manifest:void 0,range:void 0,canvas:void 0,annotation:void 0},$=k.default.createContext(mt),O=()=>c.useContext($);function V({value:e,children:t}){const r=O(),n=c.useMemo(()=>y(y({},r),e),[e,r]);return f.jsx($.Provider,{value:n,children:t})}const U=k.default.createContext({vault:null,setVaultInstance:e=>{}});function Ee({vault:e,vaultOptions:t,useGlobal:r,resources:n,children:a}){const[o,i]=c.useState(()=>e||(r?q.globalVault(t):t?new q.Vault(t):new q.Vault));return f.jsx(U.Provider,{value:{vault:o,setVaultInstance:i},children:f.jsx(V,{value:n||{},children:a})})}const w=()=>{const{vault:e}=c.useContext(U);if(e===null)throw new Error("Vault not found. Ensure you have your provider set up correctly.");return e};function ne(e,{noCache:t=!1}={}){const r=typeof e=="string"?e:e.id,n=w(),[a,o]=c.useState(r),[i,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 p=u&&!t?u:await n.load(r),h=p?p.id||p["@id"]:null;p&&a!==h&&o(h),d(p)}catch(p){s(p)}})()},[r,t]),{isLoaded:!!l,id:a,requestId:r,error:i,resource:l,cached:!!(l&&l===u)}}function Ce(e,t){const{id:r,isLoaded:n,error:a,resource:o,requestId:i,cached:s}=ne(e,t);return{id:r,isLoaded:n,error:a,manifest:o,requestId:i,cached:s}}function Pe({manifest:e,children:t}){return f.jsx(V,{value:{manifest:e},children:t})}function re({canvas:e,children:t}){return f.jsx(V,{value:{canvas:e},children:t})}function b(e,t=[]){const r=w(),[n,a]=c.useState(()=>e(r.getState(),r));return c.useEffect(()=>r.subscribe(o=>e(o,r),o=>{a(o)},!1),t),n}const D=k.default.createContext([]);function Re(){const e=c.useContext(D);return b(t=>e.map(r=>t.iiif.entities.Canvas[r]).filter(Boolean),[e])}const Y=()=>{},N=c.createContext({setCurrentCanvasId:Y,setCurrentCanvasIndex:Y,nextCanvas:Y,previousCanvas:Y,currentCanvasIndex:-1,totalCanvases:0,pagingView:!0});function gt(e){const t=Ce(e.manifest),[r,n]=c.useState(""),[a,o]=c.useState([]),i=(typeof e.pagingEnabled=="undefined"||e.pagingEnabled)&&t.manifest&&t.manifest.behavior&&t.manifest.behavior.includes("paged");c.useEffect(()=>{var g,m;t.manifest&&(n((g=t.manifest.items[0])==null?void 0:g.id),o([(m=t.manifest.items[0])==null?void 0:m.id]))},[t.manifest,e.manifest]);const s=c.useMemo(()=>{var g;return((g=t.manifest)==null?void 0:g.items.map(m=>m.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=i&&u!==0?s[u+2]:s[u+1],m=i?u!==0?s[u+3]:s[u+2]:null;g&&(n(g),o(m?[g,m]:[g]))}},[i,s,r,u]),d=c.useCallback(()=>{if(s.length&&r){if(u===0||u===-1)return;const g=i&&u!==1?s[u-2]:s[u-1],m=i&&u!==1?s[u-1]:null;g&&(n(g),o(m?[g,m]:[g]))}},[i,s,r,u]),p=c.useCallback(g=>{const m=i&&g%2===1?g-1:g,x=s[m],E=i&&m!==0?s[m+1]:null;x&&(n(x),o(S=>{const P=E?[x,E]:[x];if(S.length===S.length){for(let M=0;M<S.length;M++)if(S[M]!==P[M])return P;return S}return P}))},[i,s]),h=c.useCallback(g=>{const m=s.indexOf(g);m!==-1&&p(m)},[s,p]),v=c.useMemo(()=>({setCurrentCanvasId:h,nextCanvas:l,previousCanvas:d,currentCanvasIndex:u,totalCanvases:s.length,setCurrentCanvasIndex:p,pagingView:!0}),[l,d,u,s,p,h]);return t.manifest?t.isLoaded?f.jsx(N.Provider,{value:v,children:f.jsx(D.Provider,{value:a,children:f.jsx(Pe,{manifest:t.manifest.id,children:f.jsx(re,{canvas:r,children:e.children})})})}):f.jsx("div",{children:"Loading..."}):(console.warn("The manifest passed to the provider is not a valid IIIF manifest."),f.jsx("div",{children:"Sorry, something went wrong."}))}function ht(){return c.useContext(N)}function we(){return{VaultContext:c.useContext(U),ResourceContext:c.useContext($),SimpleViewerReactContext:c.useContext(N),VisibleCanvasReactContext:c.useContext(D)}}function Ae(e){return f.jsx(Ee,{vault:e.bridge.VaultContext.vault||void 0,resources:e.bridge.ResourceContext,children:f.jsx(D.Provider,{value:e.bridge.VisibleCanvasReactContext,children:f.jsx(N.Provider,{value:e.bridge.SimpleViewerReactContext,children:e.children})})})}const vt="@iiif/IMPORT_ENTITIES",yt="@iiif/MODIFY_ENTITY_FIELD",xt="@iiif/REORDER_ENTITY_FIELD",St="@iiif/ADD_REFERENCE",Et="@iiif/REMOVE_REFERENCE",Ct=A.createAction(vt)(),Pt=A.createAction(yt)(),Rt=A.createAction(xt)(),wt=A.createAction(St)(),At=A.createAction(Et)(),J={importEntities:Ct,modifyEntityField:Pt,reorderEntityField:Rt,addReference:wt,removeReference:At},bt="@iiif/ADD_MAPPING",Mt="@iiif/ADD_MAPPINGS";A.createAction(bt)();A.createAction(Mt)();const Tt="@iiif/SET_META_VALUE",It="@iiif/SET_META_VALUE_DYNAMIC",jt="@iiif/UNSET_META_VALUE";A.createAction(Tt)();A.createAction(It)();A.createAction(jt)();const _t="@iiif/REQUEST_RESOURCE",Ot="@iiif/REQUEST_ERROR",Vt="@iiif/REQUEST_MISMATCH",Lt="@iiif/REQUEST_COMPLETE",kt="@iiif/REQUEST_OFFLINE_RESOURCE";A.createAction(_t)();A.createAction(Ot)();A.createAction(Vt)();A.createAction(Lt)();A.createAction(kt)();const Ft="@iiif/BATCH",Ut="@iiif/BATCH_IMPORT";A.createAction(Ft)();A.createAction(Ut)();function be(){const t=w().getStore();return c.useMemo(()=>r=>t.dispatch(r),[t])}function ge(e){return typeof e!="string"&&e&&e.bindToVault}function Me(){const e=w(),t=c.useRef([]),r=be(),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(J.importEntities({entities:{AnnotationPage:{[s.id]:s}}}))},[n]);const a=b(s=>n?s.iiif.entities.AnnotationPage[n]:null,[n]),o=c.useCallback((s,u)=>{if(n){if(ge(s)){const p=s;p.__vault||p.bindToVault(e),s=typeof p.source=="string"?p.source:p.source.id,t.current[s]=p}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(p=>p.id===d.id)||r(J.addReference({id:n,type:"AnnotationPage",key:"items",reference:{id:s,type:"Annotation"},index:u})))}},[n]),i=c.useCallback(s=>{n&&(ge(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(J.removeReference({id:n,type:"AnnotationPage",key:"items",reference:{id:s,type:"Annotation"}})))},[n]);return[a,{addAnnotation:o,removeAnnotation:i}]}const Te=c.createContext(null);function Ie(){const e=c.useContext(Te);return[e.fullPage,{addAnnotation:e.addAnnotation,removeAnnotation:e.removeAnnotation}]}function je({children:e}){const[t,{addAnnotation:r,removeAnnotation:n}]=Me();return f.jsx(Te.Provider,{value:c.useMemo(()=>({fullPage:t,addAnnotation:r,removeAnnotation:n}),[t]),children:e})}function Dt({width:e,style:t,height:r}){return f.jsx("div",{style:C(y({width:e,height:r,minHeight:500},t||{}),{background:"#f9f9f9"}),children:"Unknown error"})}var _e,Nt=lt.default;_e=Nt.createRoot;const G=c.createContext(null);function Oe(){return c.useContext(G)}const ie=k.default.createContext(null),oe=k.default.createContext(null);function L({children:e,overlay:t}){const r=c.useContext(t?oe:ie),n=c.useRef(null),a=Oe();return c.useLayoutEffect(()=>{n.current||(n.current=r?_e(r):null)},[]),c.useLayoutEffect(()=>()=>{var o;(o=n.current)==null||o.unmount(),n.current=null},[]),c.useLayoutEffect(()=>{n.current&&n.current.render(f.jsx(G.Provider,{value:a,children:e}))},[e,a]),null}function Bt(a){var o=a,{children:e,errorFallback:t,outerContainerProps:r={}}=o,n=pe(o,["children","errorFallback","outerContainerProps"]);const i=c.useRef(null),[s,u]=c.useState(),[l,d]=c.useState(),p=c.useRef(null),[h,v]=c.useState(),g=we(),m=t||Dt;return c.useLayoutEffect(()=>{u(i.current),v(p.current)},[]),f.jsxs(pt,{fallbackRender:()=>f.jsx(m,y({},n)),children:[f.jsx(Q.AtlasAuto,C(y({},n),{containerProps:y({style:{position:"relative"}},n.containerProps||{}),htmlChildren:f.jsx("div",{ref:p}),onCreated:x=>{d(x),n.onCreated&&n.onCreated(x)},children:f.jsx(G.Provider,{value:l,children:f.jsx(ie.Provider,{value:s,children:f.jsx(oe.Provider,{value:h,children:f.jsx(Ae,{bridge:g,children:f.jsx(je,{children:e})})})})})})),f.jsx("div",{ref:i})]})}function Ve(e){return{addEventListener(t,r,n,a){if(!!t)return e.setMetaValue([t.id,"eventManager",r],o=>{const i=o||[];for(const s of i)if(s.callback===n)return i;return[...i,{callback:n,scope:a}]}),n},removeEventListener(t,r,n){!t||e.setMetaValue([t.id,"eventManager",r],a=>(a||[]).filter(o=>o.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"),o={};if(a&&n)for(const i of Object.keys(a))o[i]=s=>{const u=e.get(n);for(const{callback:l,scope:d}of a[i]||[])(!d||r&&d.indexOf(r)!==-1)&&l(s,u)};return o}}}function se(e,t){const r=w(),n=c.useMemo(()=>Ve(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 ae(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 F(e,t){const r=w(),n=c.useMemo(()=>ae(r),[r]);return b(()=>{if(!e)return null;const a=n.getAppliedStyles(e.id);return a?t?a[t]:a:void 0},[e,t])}var Ht=Object.defineProperty,Yt=Object.defineProperties,qt=Object.getOwnPropertyDescriptors,he=Object.getOwnPropertySymbols,Qt=Object.prototype.hasOwnProperty,zt=Object.prototype.propertyIsEnumerable,ve=(e,t,r)=>t in e?Ht(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ye=(e,t)=>{for(var r in t||(t={}))Qt.call(t,r)&&ve(e,r,t[r]);if(he)for(var r of he(t))zt.call(t,r)&&ve(e,r,t[r]);return e},xe=(e,t)=>Yt(e,qt(t));const $t=/&?(xywh=)?(pixel:|percent:|pct:)?([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?)/,Gt=/&?(t=)(npt:)?([0-9]+(.[0-9]+)?)?(,([0-9]+(.[0-9]+)?))?/;function z(e){if(Array.isArray(e))return e.reduce((t,r)=>{const{selector:n,selectors:a}=z(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?z({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=$t.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(Gt);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 I(e,t={}){if(Array.isArray(e))return I(e[0]);if(typeof e=="string"){const[r,n]=e.split("#");return n?I({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 I(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?z(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?I({type:"SpecificResource",source:xe(ye({},e),{id:r}),selector:{type:"FragmentSelector",value:n}}):{type:"SpecificResource",source:xe(ye({},e),{id:r}),selector:null,selectors:[]}}return{type:"SpecificResource",source:e,selector:null,selectors:[]}}function Le(e={},t=[]){const{id:r,selector:n}=e,a=O(),o=w(),i=r||a.annotation,s=b(l=>i?l.iiif.entities.Annotation[i]:void 0,[i]),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=C(y({},s),{body:u,target:I(s.target,{typeMap:o.getState().iiif.mapping})});return n?n(l):l},[s,n,u,...t])}function j(e={},t=[]){const{id:r,selector:n}=e,a=O(),o=r||a.canvas,i=b(s=>o?s.iiif.entities.Canvas[o]:void 0,[o]);return c.useMemo(()=>{if(!!i)return n?n(i):i},[i,n,...t])}const ke=({id:e,style:t,className:r,interactive:n})=>{const a=Le({id:e}),o=F(a,"atlas"),i=F(a,"html"),s=se(a,["atlas"]),u=j(),l=c.useMemo(()=>Q.mergeStyles(t,o),[t,o]);return u&&a&&a.target&&a.target.selector&&a.target.selector.type==="BoxSelector"&&a.target.source&&a.target.source.id===u.id?f.jsx(Q.RegionHighlight,y({id:a.id,isEditing:!0,region:a.target.selector.spatial,style:l,className:(i==null?void 0:i.className)||r,interactive:!!((i==null?void 0:i.href)||n),href:(i==null?void 0:i.href)||null,title:(i==null?void 0:i.title)||null,hrefTarget:(i==null?void 0:i.target)||null},s)):null},ee=({className:e,page:t})=>{var a;const r=F(t,"atlas"),n=F(t,"html");return b(o=>t.id?o.iiif.entities.AnnotationPage[t.id]:null,[]),f.jsx(c.Fragment,{children:(a=t.items)==null?void 0:a.map(o=>f.jsx(ke,{id:o.id,style:r,className:(n==null?void 0:n.className)||e},o.id))})};function Fe({id:e,image:t,thumbnail:r,isStatic:n,x:a=0,y:o=0,annotations:i,children:s}){var u,l,d,p;return f.jsx(c.Fragment,{children:t.service?f.jsxs(c.Fragment,{children:[f.jsx(Q.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)+o,width:(d=t.target)==null?void 0:d.spatial.width,height:(p=t.target)==null?void 0:p.spatial.height}),i,s]},"service"):f.jsxs(c.Fragment,{children:[f.jsx("world-image",{uri:t.id,target:t.target.spatial,display:t.width&&t.height?{width:t.width,height:t.height}:void 0}),i,s]},"no-service")},e)}function Ue(e){return e.type==="SpecificResource"?[e.source,{selector:e.selector}]:[e,{selector:null}]}function De(e,t,r){const n=[];let a=null;const o=[];for(const i of t){const s=e.get(i.body);for(const u of s){const[l,{selector:d}]=Ue(u),p=(l.type||"unknown").toLowerCase();if(p==="choice"){const h=e.get(l.items),v=r.length?r.map(g=>h.find(m=>m.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(p)===-1&&n.push(p),o.push({type:p,resource:l,target:i.target,selector:d})}}return{types:n,items:o,choice:a}}const Ne={makeChoice:()=>{}},te={type:"unknown"},R=e=>({type:"unknown",reason:e,annotations:{pages:[]}});function B(e={},t=[]){const{id:r,selector:n}=e,a=O();w();const o=r||a.manifest,i=b(s=>o?s.iiif.entities.Manifest[o]:void 0,[o]);return c.useMemo(()=>{if(!!i)return n?n(i):i},[i,n,...t])}function Kt(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 Wt(e,t){return b(r=>{const n=[];if(!e)return n;const a=Object.keys(r.iiif.entities.AnnotationPage);for(const o of a)if(!t||t.indexOf(o)!==-1){const i=Kt(r,o);i&&i.views&&i.views[e]&&n.push(o)}return n},[e,t])}function Be({canvas:e,manifest:t,all:r,canvases:n}){const a=[];if(t)for(const o of t.annotations)a.indexOf(o.id)===-1&&a.push(o.id);if(r){if(n&&n.length)for(const o of n)for(const i of o.annotations)a.indexOf(i.id)===-1&&a.push(i.id)}else if(e)for(const o of e.annotations)a.indexOf(o.id)===-1&&a.push(o.id);return a}function Xt(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 He(e,t={}){const r=w(),n=B(),a=j(),o=Re(),i=c.useMemo(()=>Be({all:t.all,manifest:n,canvas:a,canvases:o}),[t.all,a,o,n]),s=Wt(e,t.all?void 0:i),u=c.useCallback(d=>{!e||r.setMetaValue([d,"annotationPageManager","views"],p=>p&&!p[e]?p:C(y({},p||{}),{[e]:!1}))},[e,r]),l=c.useCallback((d,p={})=>{if(!e)return;const h=r.getState(),v=[];if(p!=null&&p.deselectOthers){const g=Object.keys(h.iiif.entities.AnnotationPage);for(const m of g){const x=Xt(h,m);x&&x.views&&x.views[e]&&v.push(m)}}for(const g of v)u(g);r.setMetaValue([d,"annotationPageManager","views"],g=>g&&g[e]?g:C(y({},g||{}),{[e]:!0}))},[e,u,r]);return{availablePageIds:i,enabledPageIds:s,setPageEnabled:l,setPageDisabled:u}}function Ye(e,t){return b((r,n)=>n.get(e.map(a=>({id:a,type:t}))),[e,t])}const qe=k.default.createContext(new _.ImageServiceLoader);function K(){return c.useContext(qe)}function Qe(){const e=K(),[t,r]=c.useState({}),n=c.useRef(!1);return c.useEffect(()=>()=>{n.current=!0},[]),[c.useCallback((o,{height:i,width:s})=>{if(o){const u=o.id||o["@id"],l=e.loadServiceSync({id:u,width:o.width||s,height:o.height||i,source:o});l?o=l:t[u]||(n.current||r(d=>C(y({},d),{[u]:"loading"})),e.loadService({id:u,width:o.width||s,height:o.height||i}).then(()=>{n.current||r(d=>C(y({},d),{[u]:"done"}))}))}return o},[e,t]),t]}function W(e={}){const t=j(e.canvasId?{id:e.canvasId}:void 0);return b((r,n)=>{if(!t)return[];const a=n.get(t.items),o=[];for(const i of a)o.push(...n.get(i.items));return o},[t])}function ze(e,t=[]){const r=w(),n=W(),[a,o]=c.useState((e==null?void 0:e.defaultChoices)||[]),i=c.useMemo(()=>De(r,n,a),[r,n,a,...t]),u={makeChoice:c.useCallback((l,{deselectOthers:d=!0,deselect:p=!1}={})=>{if(i.choice){if(i.choice.type!=="single-choice")throw new Error("Complex choice not supported yet");o(h=>{if(p){const g=h.filter(m=>m!==l);if(g.length===0){const m=i.items[0].resource.id;return m?[m]:[]}return g}if(d)return[l];const v=[...h];if(v.length===0&&i.items.length){const g=i.items[0].resource.id;g&&v.push(g)}return h.indexOf(l)!==-1?h:[...h,l]})}},[i.choice])};return[i,u]}function $e(e,t,r){const n=[];for(const a of t.items){const o=a.resource&&a.resource.type==="SpecificResource"?a.resource.source:a.resource;if(!o.id)return R("No resource Identifier");let i;if(o.service){const m=_.getImageServices(o);m[0]&&(i=r(m[0],e))}const{selector:s,source:u}=I(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,p={type:"BoxSelector",spatial:{x:0,y:0,width:e.width,height:e.height}},h=a.resource.type==="SpecificResource"?I(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}}:p;i&&!i.id&&(i.id=i["@id"]);const g={id:o.id,type:"Image",width:d?o.width:e.width,height:d?o.height:e.height,service:i,sizes:i&&i.sizes?i.sizes:o.width&&o.height?[{width:o.width,height:o.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 Jt=["model/gltf-binary"];function Zt(e,t){const n=t.items[0].resource;return n.format?Jt.indexOf(n.format)===-1?R(`3D format: ${n.format} is unsupported`):{type:"3d-model",model:n}:R("Unknown format")}function en(e,t){var n;if(!e.duration)return R("No duration on canvas");if(t.items.length>1)return R("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:[]}}:R("Audio does not have format"):R("Unknown audio")}function tn(e,t){var a;const r=t.items.filter(o=>o.type==="video");if(!e.duration)return R("No duration on canvas");if(r.length>1)return R("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:[]}}:R("Video does not have format"):R("Unknown video")}function Ge(e){const t=B(),r=j(),n=w(),[a,o]=Qe(),{enabledPageIds:i}=He((e==null?void 0:e.annotationPageManagerId)||(t==null?void 0:t.id)||(r==null?void 0:r.id),{all:!1}),s=Ye(i,"AnnotationPage"),u=(e==null?void 0:e.strategies)||["images","media","complex-timeline"],[l,d]=ze(e,[o]),p=c.useMemo(()=>{if(!r||l.types.length===0)return te;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?R("Complex timeline not supported"):R("ComplexTimelineStrategy not yet supported");const h=l.types[0];return h==="image"?u.indexOf("images")===-1?R("Image not supported"):$e(r,l,a):h==="Model"||h==="model"?u.indexOf("3d-model")===-1?R("3D not supported"):Zt(r,l):h==="sound"||h==="audio"?u.indexOf("media")===-1?R("Media not supported"):en(r,l):h==="video"?u.indexOf("media")===-1?R("Media not supported"):tn(r,l):te},[r,l,n,d.makeChoice]);return c.useMemo(()=>p.type==="unknown"?[p,Ne]:[C(y({},p),{annotations:{pages:s}}),d],[p,s])}const Ke=(e,t=[])=>{const r=w();c.useEffect(()=>{e(r)},[r,...t])};function nn(e,t={}){const r=t.imageServiceLoader||new _.ImageServiceLoader;async function n(a,o,i,s=[],u){if(typeof a=="string")return{best:_.getFixedSizeFromImage(a),fallback:[],log:[]};const l=e.get(a);if(typeof l=="string")return{best:_.getFixedSizeFromImage(l),fallback:[],log:[]};switch(l.type){case"Annotation":{const d=l.body,p=e.get(d[0]);return u&&!p.width&&(p.width=u.width,p.height=u.height),await r.getThumbnailFromResource(p,o,i,s)}case"Canvas":{const d=l;if(d.thumbnail&&d.thumbnail.length){const p=e.get(d.thumbnail[0]),h=await r.getImageCandidates(p,i);h&&h.length&&s.push(...h)}return n(d.items[0],o,i,s,{width:d.width,height:d.height})}case"AnnotationPage":return n(l.items[0],o,i,s,u);case"Choice":return n(l.items[0],o,i,s,u);case"Collection":{const p=l.items[0];return n(p,o,i,s,u)}case"Manifest":{const p=l.items[0];return n(p,o,i,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,o,i,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 We(e,t,{canvasId:r,manifestId:n}={}){const a=w(),o=K(),i=c.useMemo(()=>nn(a,{imageServiceLoader:o}),[a,o]),[s,u]=c.useState(),l=B(n?{id:n}:void 0),d=j(r?{id:r}:void 0),p=d||l,h=c.useRef(!1);if(c.useEffect(()=>()=>{h.current=!0},[]),!p)throw new Error("Must be called under a manifest or canvas context.");return Ke(v=>{i.getBestThumbnailAtSize(p,e,t).then(g=>{g.best&&!h.current&&u(g.best)})},[p]),s}function rn(e){return{isMuted:!1,playRequested:!1,isPlaying:!1,isFinished:!1,volume:100,duration:e}}function on(e,t){switch(t.type){case"FINISHED":return C(y({},e),{isFinished:!0,isPlaying:!1,playRequested:!1});case"PLAY_PAUSE":return C(y({},e),{isFinished:!1,isPlaying:!e.isPlaying});case"PLAY_REQUESTED":return C(y({},e),{isFinished:!1,playRequested:!0});case"PAUSE":return C(y({},e),{isPlaying:!1});case"PLAY":return C(y({},e),{isFinished:!1,playRequested:!1,isPlaying:!0});case"MUTE":return C(y({},e),{isMuted:!0});case"SET_VOLUME":return C(y({},e),{volume:t.volume,isMuted:t.volume===0});case"TOGGLE_MUTE":return C(y({},e),{isMuted:!e.isMuted});case"UNMUTE":return C(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 ce(e){const[t,r]=c.useReducer(on,rn(e.duration)),n=c.useRef(null),a=c.useRef(null),o=c.useRef(null),i=c.useRef(!1),s=c.useCallback(()=>{a.current&&n.current&&(a.current.innerHTML=Xe(n.current.currentTime),o.current&&(o.current.style.width=`${n.current.currentTime/e.duration*100}%`),i.current!==n.current.muted&&(i.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]),p=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(E=>{n.current&&(n.current.muted=!1,n.current.volume=E/100,r({type:"SET_VOLUME",volume:E}))},[]),m=c.useCallback(E=>{n.current&&(n.current.currentTime=Math.max(0,Math.min(E*e.duration,e.duration)),s())},[]),x=c.useCallback(E=>{n.current&&(n.current.currentTime=Math.max(0,Math.min(E,e.duration)),s())},[]);return c.useEffect(()=>{const E=setInterval(()=>{s()},350);return()=>clearInterval(E)},[s,e.duration]),c.useEffect(()=>{const E=()=>{r({type:"FINISHED"})},S=n.current;return S==null||S.addEventListener("ended",E),()=>S==null?void 0:S.removeEventListener("ended",E)},[]),[{element:n,currentTime:a,progress:o},t,{play:u,pause:d,playPause:l,mute:h,unmute:v,toggleMute:p,setVolume:g,setDurationPercent:m,setTime:x}]}const Je=c.createContext(null),Ze=c.createContext(null),et=c.createContext(null);function sn(){const e=c.useContext(Je);if(!e)throw new Error("Ctx not found");return e}function an(){const e=c.useContext(Ze);if(!e)throw new Error("Ctx not found");return e}function cn(){const e=c.useContext(et);if(!e)throw new Error("Ctx not found");return e}function ue({actions:e,state:t,children:r,currentTime:n,progress:a,element:o}){return f.jsx(et.Provider,{value:{currentTime:n,progress:a,element:o},children:f.jsx(Ze.Provider,{value:e,children:f.jsx(Je.Provider,{value:t,children:r})})})}function un({media:e,children:t}){const[{element:r,currentTime:n,progress:a},o,i]=ce({duration:e.duration});return f.jsx(f.Fragment,{children:f.jsx(L,{children:f.jsxs(ue,{state:o,actions:i,currentTime:n,progress:a,element:r,children:[f.jsx("audio",{ref:r,src:e.url}),t]})})})}function ln({media:e,children:t}){const[{element:r,currentTime:n,progress:a},o,i]=ce({duration:e.duration}),s="div";return f.jsxs(f.Fragment,{children:[f.jsxs(L,{overlay:!0,children:[f.jsx("style",{children:`
1
+ "use strict";var Vt=Object.defineProperty,kt=Object.defineProperties;var Nt=Object.getOwnPropertyDescriptors;var W=Object.getOwnPropertySymbols;var Ie=Object.prototype.hasOwnProperty,Re=Object.prototype.propertyIsEnumerable;var we=(e,t,n)=>t in e?Vt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,S=(e,t)=>{for(var n in t||(t={}))Ie.call(t,n)&&we(e,n,t[n]);if(W)for(var n of W(t))Re.call(t,n)&&we(e,n,t[n]);return e},b=(e,t)=>kt(e,Nt(t));var Ae=(e,t)=>{var n={};for(var r in e)Ie.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&W)for(var r of W(e))t.indexOf(r)<0&&Re.call(e,r)&&(n[r]=e[r]);return n};Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var c=require("react"),z=require("@atlas-viewer/atlas"),d=require("react/jsx-runtime"),X=require("@iiif/vault"),R=require("typesafe-actions"),Me=require("react-dom/client"),Ut=require("@iiif/vault-helpers"),U=require("@atlas-viewer/iiif-image-api");function Dt(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}function Bt(e){if(e&&e.__esModule)return e;var t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});return e&&Object.keys(e).forEach(function(n){if(n!=="default"){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,Object.freeze(t)}var ae=Bt(c),D=Dt(c);function le(e,t){return le=Object.setPrototypeOf||function(r,o){return r.__proto__=o,r},le(e,t)}function Ht(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,le(e,t)}var qt=function(t,n){return t===void 0&&(t=[]),n===void 0&&(n=[]),t.length!==n.length||t.some(function(r,o){return!Object.is(r,n[o])})},Te={error:null},$t=function(e){Ht(t,e);function t(){for(var r,o=arguments.length,s=new Array(o),i=0;i<o;i++)s[i]=arguments[i];return r=e.call.apply(e,[this].concat(s))||this,r.state=Te,r.resetErrorBoundary=function(){for(var a,l=arguments.length,u=new Array(l),p=0;p<l;p++)u[p]=arguments[p];r.props.onReset==null||(a=r.props).onReset.apply(a,u),r.reset()},r}t.getDerivedStateFromError=function(o){return{error:o}};var n=t.prototype;return n.reset=function(){this.setState(Te)},n.componentDidCatch=function(o,s){var i,a;(i=(a=this.props).onError)==null||i.call(a,o,s)},n.componentDidUpdate=function(o,s){var i=this.state.error,a=this.props.resetKeys;if(i!==null&&s.error!==null&&qt(o.resetKeys,a)){var l,u;(l=(u=this.props).onResetKeysChange)==null||l.call(u,o.resetKeys,a),this.reset()}},n.render=function(){var o=this.state.error,s=this.props,i=s.fallbackRender,a=s.FallbackComponent,l=s.fallback;if(o!==null){var u={error:o,resetErrorBoundary:this.resetErrorBoundary};if(ae.isValidElement(l))return l;if(typeof i=="function")return i(u);if(a)return ae.createElement(a,u);throw new Error("react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop")}return this.props.children},t}(ae.Component);const zt={collection:void 0,manifest:void 0,range:void 0,canvas:void 0,annotation:void 0,annotationPage:void 0},ne=D.default.createContext(zt),L=()=>c.useContext(ne);function F({value:e,children:t}){const n=L(),r=c.useMemo(()=>S(S({},n),e),[e,n]);return d.jsx(ne.Provider,{value:r,children:t})}const Q=D.default.createContext({vault:null,setVaultInstance:e=>{}});function He({vault:e,vaultOptions:t,useGlobal:n,resources:r,children:o}){const[s,i]=c.useState(()=>e||(n?X.globalVault(t):t?new X.Vault(t):new X.Vault));return d.jsx(Q.Provider,{value:{vault:s,setVaultInstance:i},children:d.jsx(F,{value:r||{},children:o})})}const I=()=>{const{vault:e}=c.useContext(Q);if(e===null)throw new Error("Vault not found. Ensure you have your provider set up correctly.");return e};function pe(e,{noCache:t=!1}={}){const n=typeof e=="string"?e:e.id,r=I(),[o,s]=c.useState(n),[i,a]=c.useState(void 0),l=c.useMemo(()=>r.get(n,{skipSelfReturn:!0})||void 0,[n,r]),[u,p]=c.useState(l);return c.useEffect(()=>{(async()=>{try{const f=l&&!t?l:await r.load(n),g=f?f.id||f["@id"]:null;f&&o!==g&&s(g),p(f)}catch(f){a(f)}})()},[n,t]),{isLoaded:!!u,id:o,requestId:n,error:i,resource:u,cached:!!(u&&u===l)}}function qe(e,t){const{id:n,isLoaded:r,error:o,resource:s,requestId:i,cached:a}=pe(e,t);return{id:n,isLoaded:r,error:o,manifest:s,requestId:i,cached:a}}function $e({manifest:e,children:t}){return d.jsx(F,{value:{manifest:e},children:t})}function ge({canvas:e,children:t}){return d.jsx(F,{value:{canvas:e},children:t})}function A(e,t=[]){const n=I(),[r,o]=c.useState(()=>e(n.getState(),n));return c.useEffect(()=>n.subscribe(s=>e(s,n),s=>{o(s)},!1),t),r}const G=D.default.createContext([]);function ze(){const e=c.useContext(G);return A(t=>e.map(n=>t.iiif.entities.Canvas[n]).filter(Boolean),[e])}function B(e={},t=[]){const{id:n,selector:r}=e,o=L();I();const s=n||o.manifest,i=A(a=>s?a.iiif.entities.Manifest[s]:void 0,[s]);return c.useMemo(()=>{if(!!i)return r?r(i):i},[i,r,...t])}function Ye({range:e,children:t}){return d.jsx(F,{value:{range:e},children:t})}function Qe(e,t){for(const n of t.items){if(n.type==="Canvas")return n;if(n.type==="Range"){const r=Qe(e,e.get(n));if(r)return r}}return null}function he(e,t){const n=[];for(const r of t.items)if(r.type==="Canvas"&&(r.id.indexOf("#")!==-1?n.push({id:r.id.split("#")[0],type:"Canvas"}):n.push(r)),r.type==="Range"&&n.push(...he(e,e.get(r))),r.type==="SpecificResource"){const o=typeof r.source=="string"?r.source:r.source.id;n.push({id:o,type:"Canvas"})}return n}function Yt(e,t,n){for(const r of t.structures){const o=ve(e,e.get(r),n);if(o)return o}return null}function ve(e,t,n){var r;for(const o of t.items){const s=(r=o.id)==null?void 0:r.split("#")[0];if(o.type==="SpecificResource"&&o.source===n||o.type==="Canvas"&&n===s)return t;if(o.type==="Range"){const i=ve(e,e.get(o),n);if(i)return i}}return null}function Qt(e,t,n,r=!1){const o=t.behavior,s=n?e.get(n):null;if(!s)return[];const i=s.behavior,a=r?!1:o.includes("paged"),l=a?!1:o.includes("continuous"),u=a||l?!1:o.includes("individuals"),p=i.includes("facing-pages"),f=i.includes("non-paged");if(p||f||u||r)return[{id:s.id,type:"Canvas"}];const[g,v]=me(e,t);if(l)return g;const h=g.findIndex(y=>y.id===n);if(h===-1)return[];for(const y of v)if(y.includes(h))return y.map(x=>g[x]);return[{id:s.id,type:"Canvas"}]}function me(e,t,{disablePaging:n}={}){const r=t.behavior,o=r.includes("paged"),s=o?!1:r.includes("continuous"),i=o||s?!1:r.includes("individuals"),a=t.type==="Manifest"?t.items:he(e,t);if(s)return[a,[a.map((f,g)=>g)]];if(i||!o||n)return[a,a.map((f,g)=>[g])];const l=[];let u=[];const p=()=>{u.length&&(l.push([...u]),u=[])};for(let f=0;f<a.length;f++){const g=e.get(a[f]);if(f===0||g.behavior.includes("facing-pages")){p(),l.push([f]);continue}g.behavior.includes("non-paged")||(u.push(f),u.length>1&&p())}return u.length&&p(),[a,l]}function Ge(e={},t=[]){const{id:n,selector:r}=e,o=L(),s=n||o.range,i=A(a=>s?a.iiif.entities.Range[s]:void 0,[s]);return c.useMemo(()=>{if(!!i)return r?r(i):i},[i,r,...t])}function Ke({startCanvas:e,disablePaging:t}){var h;const n=I(),r=B(),o=Ge(),[s,i]=c.useState(void 0),a=o||r;if(!a)throw new Error("Nothing selected");const[l,u]=c.useMemo(()=>me(n,a,{disablePaging:t}),[n,a]),p=c.useCallback(y=>{const x=u.findIndex(C=>C.includes(y));i(x===-1?0:x)},[l,u]),f=c.useCallback(y=>{const x=l.findIndex(C=>C.id===y);x!==-1?p(x):i(0)},[l,u]),g=c.useCallback(()=>{i(y=>y>=u.length?y:y+1)},[u]),v=c.useCallback(()=>{i(y=>y<=0?0:y-1)},[u]);return typeof s=="undefined"&&(e?f(e):i(0)),{visibleItems:((h=u[s])==null?void 0:h.map(y=>l[y].id))||[],cursor:s,items:l,sequence:u,setSequenceIndex:i,setCanvasIndex:p,setCanvasId:f,next:g,previous:v}}const $=()=>{},K=c.createContext({setCurrentCanvasId:$,setCurrentCanvasIndex:$,nextCanvas:$,previousCanvas:$,items:[],sequence:[],setSequenceIndex:$,currentSequenceIndex:0});function We(e){const t=B(),{cursor:n,visibleItems:r,next:o,sequence:s,items:i,setCanvasIndex:a,setCanvasId:l,previous:u,setSequenceIndex:p}=Ke({startCanvas:e.startCanvas,disablePaging:e.pagingEnabled===!1}),f=c.useMemo(()=>({sequence:s,items:i,setCurrentCanvasId:l,nextCanvas:o,previousCanvas:u,totalCanvases:i.length,setCurrentCanvasIndex:a,setSequenceIndex:p,currentSequenceIndex:n}),[s,i,l,o,u,i,a,p,n]);return t?d.jsx(K.Provider,{value:f,children:d.jsx(G.Provider,{value:r,children:d.jsx(ge,{canvas:r[0],children:e.children})})}):(console.warn("The manifest passed to the provider is not a valid IIIF manifest."),d.jsx("div",{children:"Sorry, something went wrong."}))}function Gt(e){const t=qe(e.manifest);if(!t)return console.warn("The manifest passed to the provider is not a valid IIIF manifest."),d.jsx("div",{children:"Sorry, something went wrong."});if(!t.isLoaded)return d.jsx("div",{children:"Loading..."});const n=d.jsx(We,b(S({},e),{children:e.children}));return d.jsx($e,{manifest:t.id,children:e.rangeId?d.jsx(Ye,{range:e.rangeId,children:n}):n})}function Kt(){return c.useContext(K)}function Xe(){return{VaultContext:c.useContext(Q),ResourceContext:c.useContext(ne),SimpleViewerReactContext:c.useContext(K),VisibleCanvasReactContext:c.useContext(G)}}function Je(e){return d.jsx(He,{vault:e.bridge.VaultContext.vault||void 0,resources:e.bridge.ResourceContext,children:d.jsx(G.Provider,{value:e.bridge.VisibleCanvasReactContext,children:d.jsx(K.Provider,{value:e.bridge.SimpleViewerReactContext,children:e.children})})})}const Wt="@iiif/IMPORT_ENTITIES",Xt="@iiif/MODIFY_ENTITY_FIELD",Jt="@iiif/REORDER_ENTITY_FIELD",Zt="@iiif/ADD_REFERENCE",en="@iiif/REMOVE_REFERENCE",tn=R.createAction(Wt)(),nn=R.createAction(Xt)(),rn=R.createAction(Jt)(),on=R.createAction(Zt)(),sn=R.createAction(en)(),ce={importEntities:tn,modifyEntityField:nn,reorderEntityField:rn,addReference:on,removeReference:sn},an="@iiif/ADD_MAPPING",cn="@iiif/ADD_MAPPINGS";R.createAction(an)();R.createAction(cn)();const un="@iiif/SET_META_VALUE",ln="@iiif/SET_META_VALUE_DYNAMIC",fn="@iiif/UNSET_META_VALUE";R.createAction(un)();R.createAction(ln)();R.createAction(fn)();const dn="@iiif/REQUEST_RESOURCE",pn="@iiif/REQUEST_ERROR",gn="@iiif/REQUEST_MISMATCH",hn="@iiif/REQUEST_COMPLETE",vn="@iiif/REQUEST_OFFLINE_RESOURCE";R.createAction(dn)();R.createAction(pn)();R.createAction(gn)();R.createAction(hn)();R.createAction(vn)();const mn="@iiif/BATCH",yn="@iiif/BATCH_IMPORT";R.createAction(mn)();R.createAction(yn)();function Ze(){const t=I().getStore();return c.useMemo(()=>n=>t.dispatch(n),[t])}function Oe(e){return typeof e!="string"&&e&&e.bindToVault}function et(){const e=I(),t=c.useRef([]),n=Ze(),r=c.useMemo(()=>`vault://annotation-page/${new Date().getTime()}/${Math.round(Math.random()*1e9).toString(16)}`,[]);c.useLayoutEffect(()=>{const a={id:r,type:"AnnotationPage",behavior:[],motivation:null,label:null,thumbnail:[],summary:null,requiredStatement:null,metadata:[],rights:null,provider:[],items:[],seeAlso:[],homepage:[],logo:[],rendering:[],service:[]};n(ce.importEntities({entities:{AnnotationPage:{[a.id]:a}}}))},[r]);const o=A(a=>r?a.iiif.entities.AnnotationPage[r]:null,[r]),s=c.useCallback((a,l)=>{if(r){if(Oe(a)){const f=a;f.__vault||f.bindToVault(e),a=typeof f.source=="string"?f.source:f.source.id,t.current[a]=f}else typeof a!="string"&&(a=a.id);const u=e.get({id:r,type:"AnnotationPage"}),p=e.get({id:a,type:"Annotation"});u&&p&&(u.items.find(f=>f.id===p.id)||n(ce.addReference({id:r,type:"AnnotationPage",key:"items",reference:{id:a,type:"Annotation"},index:l})))}},[r]),i=c.useCallback(a=>{r&&(Oe(a)?a=typeof a.source=="string"?a.source:a.source.id:typeof a!="string"&&(a=a.id),t.current[a]&&t.current[a].beforeRemove(),e.get({id:r,type:"AnnotationPage"})&&n(ce.removeReference({id:r,type:"AnnotationPage",key:"items",reference:{id:a,type:"Annotation"}})))},[r]);return[o,{addAnnotation:s,removeAnnotation:i}]}const tt=c.createContext(null);function nt(){const e=c.useContext(tt);return[e.fullPage,{addAnnotation:e.addAnnotation,removeAnnotation:e.removeAnnotation}]}function rt({children:e}){const[t,{addAnnotation:n,removeAnnotation:r}]=et();return d.jsx(tt.Provider,{value:c.useMemo(()=>({fullPage:t,addAnnotation:n,removeAnnotation:r}),[t]),children:e})}function xn({width:e,style:t,height:n}){return d.jsx("div",{style:b(S({width:e,height:n,minHeight:500},t||{}),{background:"#f9f9f9"}),children:"Unknown error"})}const re=c.createContext(null);function it(){return c.useContext(re)}const ye=D.default.createContext(null),xe=D.default.createContext(null);function H({children:e,overlay:t}){const n=c.useContext(t?xe:ye),r=it();return c.useLayoutEffect(()=>{if(n)try{n.render(d.jsx(re.Provider,{value:r,children:e}))}catch{}},[e,r]),null}function Sn(o){var s=o,{children:e,errorFallback:t,outerContainerProps:n={}}=s,r=Ae(s,["children","errorFallback","outerContainerProps"]);const i=c.useRef(null),[a,l]=c.useState(),[u,p]=c.useState(),f=c.useRef(null),[g,v]=c.useState(),h=Xe(),y=t||xn;return c.useLayoutEffect(()=>{const x={};if(i.current){const C=document.createElement("div");i.current.appendChild(C),x.portal=Me.createRoot(C),l(x.portal)}if(f.current){const C=document.createElement("div");f.current.appendChild(C),x.overlayPortal=Me.createRoot(C),v(x.overlayPortal)}return()=>{l(null),v(null),setTimeout(()=>{x.portal&&x.portal.unmount(),x.overlayPortal&&x.overlayPortal.unmount()},0)}},[]),d.jsxs($t,{fallbackRender:()=>d.jsx(y,S({},r)),children:[d.jsx(z.AtlasAuto,b(S({},r),{containerProps:S({style:{position:"relative"}},r.containerProps||{}),htmlChildren:d.jsx("div",{ref:f}),onCreated:x=>{p(x),r.onCreated&&r.onCreated(x)},children:d.jsx(re.Provider,{value:u,children:d.jsx(ye.Provider,{value:a,children:d.jsx(xe.Provider,{value:g,children:d.jsx(Je,{bridge:h,children:d.jsx(rt,{children:e})})})})})})),d.jsx("div",{ref:i})]})}function ot(e){return{addEventListener(t,n,r,o){if(!!t)return e.setMetaValue([t.id,"eventManager",n],s=>{const i=s||[];for(const a of i)if(a.callback===r)return i;return[...i,{callback:r,scope:o}]}),r},removeEventListener(t,n,r){!t||e.setMetaValue([t.id,"eventManager",n],o=>(o||[]).filter(s=>s.callback!==r))},getListenersAsProps(t,n){const r=typeof t=="string"?{id:t}:t;if(!r||!r.id)return{};const o=e.getResourceMeta(r.id,"eventManager"),s={};if(o&&r)for(const i of Object.keys(o))s[i]=a=>{const l=e.get(r);for(const{callback:u,scope:p}of o[i]||[])(!p||n&&p.indexOf(n)!==-1)&&u(a,l)};return s}}}function Se(e,t){const n=I(),r=c.useMemo(()=>ot(n),[n]),o=A(()=>e&&e.id?n.getResourceMeta(e.id,"eventManager"):null,[e]);return c.useMemo(()=>e?r.getListenersAsProps(e,t):{},[o,e,n,t])}function Ce(e){return{applyStyles(t,n,r){const o=typeof t=="string"?t:t.id;return e.setMetaValue([o,"styles",n],r)},getAppliedStyles(t){const n=typeof t=="string"?t:t.id;return e.getResourceMeta(n,"styles")}}}function Y(e,t){const n=I(),r=c.useMemo(()=>Ce(n),[n]);return A(()=>{if(!e)return null;const o=r.getAppliedStyles(e.id);return o?t?o[t]:o:void 0},[e,t])}var Cn=Object.defineProperty,bn=Object.defineProperties,En=Object.getOwnPropertyDescriptors,je=Object.getOwnPropertySymbols,Pn=Object.prototype.hasOwnProperty,wn=Object.prototype.propertyIsEnumerable,_e=(e,t,n)=>t in e?Cn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Le=(e,t)=>{for(var n in t||(t={}))Pn.call(t,n)&&_e(e,n,t[n]);if(je)for(var n of je(t))wn.call(t,n)&&_e(e,n,t[n]);return e},Fe=(e,t)=>bn(e,En(t));const In=/&?(xywh=)?(pixel:|percent:|pct:)?([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?)/,Rn=/&?(t=)(npt:)?([0-9]+(.[0-9]+)?)?(,([0-9]+(.[0-9]+)?))?/;function Z(e){if(Array.isArray(e))return e.reduce((t,n)=>{const{selector:r,selectors:o}=Z(n);return r&&(t.selector||(t.selector=r),t.selectors.push(...o)),t},{selector:null,selectors:[]});if(!e)return{selector:null,selectors:[]};if(typeof e=="string"){const[t,n]=e.split("#");return n?Z({type:"FragmentSelector",value:n}):{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=In.exec(e.value);if(t){const r={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:r,selectors:[r]}}const n=e.value.match(Rn);if(n){const r={type:"TemporalSelector",temporal:{startTime:n[4]?parseFloat(n[4]):0,endTime:n[7]?parseFloat(n[7]):void 0}};return{selector:r,selectors:[r]}}return{selector:null,selectors:[]}}return{selector:null,selectors:[]}}function k(e,t={}){if(Array.isArray(e))return k(e[0]);if(typeof e=="string"){const[n,r]=e.split("#");return r?k({type:"SpecificResource",source:{id:n,type:"Unknown"},selector:{type:"FragmentSelector",value:r}}):{type:"SpecificResource",source:{id:n,type:t.typeMap&&t.typeMap[n]||"Unknown"},selector:null,selectors:[]}}if(e.type==="Choice"||e.type==="List"||e.type==="Composite"||e.type==="Independents")return k(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:n,selectors:r}=e.selector?Z(e.selector):{selector:null,selectors:[]};return{type:"SpecificResource",source:e.source,selector:n,selectors:r}}if(e.id){e.type==="Canvas"&&e.partOf&&typeof e.partOf=="string"&&(e.partOf=[{id:e.partOf,type:"Manifest"}]);const[n,r]=e.id.split("#");return r?k({type:"SpecificResource",source:Fe(Le({},e),{id:n}),selector:{type:"FragmentSelector",value:r}}):{type:"SpecificResource",source:Fe(Le({},e),{id:n}),selector:null,selectors:[]}}return{type:"SpecificResource",source:e,selector:null,selectors:[]}}function st(e={},t=[]){const{id:n,selector:r}=e,o=L(),s=I(),i=n||o.annotation,a=A(u=>i?u.iiif.entities.Annotation[i]:void 0,[i]),l=A(u=>a&&a.body?a.body.map(p=>p?u.iiif.entities[p.type][p.id]:null).filter(Boolean):[],[a]);return c.useMemo(()=>{if(!a)return;const u=b(S({},a),{body:l,target:k(a.target,{typeMap:s.getState().iiif.mapping})});return r?r(u):u},[a,r,l,...t])}function _(e={},t=[]){const{id:n,selector:r}=e,o=L(),s=n||o.canvas,i=A(a=>s?a.iiif.entities.Canvas[s]:void 0,[s]);return c.useMemo(()=>{if(!!i)return r?r(i):i},[i,r,...t])}const at=({id:e,style:t,className:n,interactive:r})=>{const o=st({id:e}),s=Y(o,"atlas"),i=Y(o,"html"),a=Se(o,["atlas"]),l=_(),u=c.useMemo(()=>z.mergeStyles(t,s),[t,s]);return l&&o&&o.target&&o.target.selector&&o.target.selector.type==="BoxSelector"&&o.target.source&&o.target.source.id===l.id?d.jsx(z.RegionHighlight,S({id:o.id,isEditing:!0,region:o.target.selector.spatial,style:u,className:(i==null?void 0:i.className)||n,interactive:!!((i==null?void 0:i.href)||r),href:(i==null?void 0:i.href)||null,title:(i==null?void 0:i.title)||null,hrefTarget:(i==null?void 0:i.target)||null},a)):null},fe=({className:e,page:t})=>{var o;const n=Y(t,"atlas"),r=Y(t,"html");return A(s=>t.id?s.iiif.entities.AnnotationPage[t.id]:null,[]),d.jsx(c.Fragment,{children:(o=t.items)==null?void 0:o.map(s=>d.jsx(at,{id:s.id,style:n,className:(r==null?void 0:r.className)||e},s.id))})};function ct({id:e,image:t,thumbnail:n,isStatic:r,x:o=0,y:s=0,children:i,onClick:a}){var l,u,p,f;return d.jsx(c.Fragment,{children:t.service?d.jsxs(c.Fragment,{children:[d.jsx(z.TileSet,{tiles:{id:t.service.id||t.service["@id"]||"unknown",height:t.height,width:t.width,imageService:t.service,thumbnail:n&&n.type==="fixed"?n:void 0},x:((l=t.target)==null?void 0:l.spatial.x)+o,y:((u=t.target)==null?void 0:u.spatial.y)+s,width:(p=t.target)==null?void 0:p.spatial.width,height:(f=t.target)==null?void 0:f.spatial.height,onClick:a}),i]},"service"):d.jsxs(c.Fragment,{children:[d.jsx("world-image",{onClick:a,uri:t.id,target:t.target.spatial,display:t.width&&t.height?{width:t.width,height:t.height}:void 0}),i]},"no-service")},e)}function ut(e){return e.type==="SpecificResource"?[e.source,{selector:e.selector}]:[e,{selector:null}]}function lt(e,t,n){const r=[];let o=null;const s=[];for(const i of t){const a=e.get(i.body);for(const l of a){const[u,{selector:p}]=ut(l),f=(u.type||"unknown").toLowerCase();if(f==="choice"){const g=e.get(u.items),v=n.length?n.map(h=>g.find(y=>y.id===h)).filter(Boolean):[g[0]];v.length===0&&v.push(g[0]),o={type:"single-choice",items:g.map(h=>({id:h.id,label:h.label,selected:v.indexOf(h)!==-1})),label:l.label},a.push(...v);continue}r.indexOf(f)===-1&&r.push(f),s.push({annotationId:i.id,type:f,resource:u,target:i.target,selector:p})}}return{types:r,items:s,choice:o}}function be(e,t){const{selector:n,source:r}=Ut.expandTarget(t);if(r.id!==e.id)return[null,r];const o={type:"BoxSelector",spatial:{x:0,y:0,width:e.width,height:e.height}};return[n?n.type==="TemporalSelector"?{type:"TemporalBoxSelector",temporal:n.temporal,spatial:o.spatial}:n:null,r]}const ft={makeChoice:()=>{}},J={type:"unknown"},w=e=>({type:"unknown",reason:e,annotations:{pages:[]}}),dt=(e,t)=>({type:"empty",width:e,height:t,annotations:{pages:[]},image:null,images:[]});function An(e,t){var r;const n=(r=e==null?void 0:e.iiif)==null?void 0:r.meta[t];return n?n.annotationPageManager:null}function Mn(e,t){return A(n=>{const r=[];if(!e)return r;const o=Object.keys(n.iiif.entities.AnnotationPage);for(const s of o)if(!t||t.indexOf(s)!==-1){const i=An(n,s);i&&i.views&&i.views[e]&&r.push(s)}return r},[e,t])}function pt({canvas:e,manifest:t,all:n,canvases:r}){const o=[];if(t)for(const s of t.annotations)o.indexOf(s.id)===-1&&o.push(s.id);if(n){if(r&&r.length)for(const s of r)for(const i of s.annotations)o.indexOf(i.id)===-1&&o.push(i.id)}else if(e)for(const s of e.annotations)o.indexOf(s.id)===-1&&o.push(s.id);return o}function Tn(e,t){var r;const n=(r=e==null?void 0:e.iiif)==null?void 0:r.meta[t];return n?n.annotationPageManager:null}function gt(e,t={}){const n=I(),r=B(),o=_(),s=ze(),i=c.useMemo(()=>pt({all:t.all,manifest:r,canvas:o,canvases:s}),[t.all,o,s,r]),a=Mn(e,t.all?void 0:i),l=c.useCallback(p=>{!e||n.setMetaValue([p,"annotationPageManager","views"],f=>f&&!f[e]?f:b(S({},f||{}),{[e]:!1}))},[e,n]),u=c.useCallback((p,f={})=>{if(!e)return;const g=n.getState(),v=[];if(f!=null&&f.deselectOthers){const h=Object.keys(g.iiif.entities.AnnotationPage);for(const y of h){const x=Tn(g,y);x&&x.views&&x.views[e]&&v.push(y)}}for(const h of v)l(h);n.setMetaValue([p,"annotationPageManager","views"],h=>h&&h[e]?h:b(S({},h||{}),{[e]:!0}))},[e,l,n]);return{availablePageIds:i,enabledPageIds:a,setPageEnabled:u,setPageDisabled:l}}function ht(e,t){return A((n,r)=>r.get(e.map(o=>({id:o,type:t}))),[e,t])}const vt=D.default.createContext(new U.ImageServiceLoader);function ie(){return c.useContext(vt)}function mt(){const e=ie(),[t,n]=c.useState({}),r=c.useRef(!1);return c.useEffect(()=>()=>{r.current=!0},[]),[c.useCallback((s,{height:i,width:a})=>{if(s){const l=s.id||s["@id"],u=e.loadServiceSync({id:l,width:s.width||a,height:s.height||i,source:s});u?s=u:t[l]||(r.current||n(p=>b(S({},p),{[l]:"loading"})),e.loadService({id:l,width:s.width||a,height:s.height||i}).then(()=>{r.current||n(p=>b(S({},p),{[l]:"done"}))}))}return s},[e,t]),t]}function oe(e={}){const t=_(e.canvasId?{id:e.canvasId}:void 0);return A((n,r)=>{if(!t)return[];const o=r.get(t.items),s=[];for(const i of o)s.push(...r.get(i.items));return s},[t])}function yt(e,t=[]){const n=I(),r=oe(),[o,s]=c.useState((e==null?void 0:e.defaultChoices)||[]),i=c.useMemo(()=>lt(n,r,o),[n,r,o,...t]),l={makeChoice:c.useCallback((u,{deselectOthers:p=!0,deselect:f=!1}={})=>{if(i.choice){if(i.choice.type!=="single-choice")throw new Error("Complex choice not supported yet");s(g=>{if(f){const h=g.filter(y=>y!==u);if(h.length===0){const y=i.items[0].resource.id;return y?[y]:[]}return h}if(p)return[u];const v=[...g];if(v.length===0&&i.items.length){const h=i.items[0].resource.id;h&&v.push(h)}return g.indexOf(u)!==-1?g:[...g,u]})}},[i.choice])};return[i,l]}function xt(e,t,n){const r=[];for(const o of t.items){const s=o.resource&&o.resource.type==="SpecificResource"?o.resource.source:o.resource;if(!s.id)return w("No resource Identifier");let i;if(s.service){const h=U.getImageServices(s);h[0]&&(i=n(h[0],e))}const a={type:"BoxSelector",spatial:{x:0,y:0,width:e.width,height:e.height}},[l,u]=be(e,o.target);if(u.id!==e.id)continue;const p={type:"BoxSelector",spatial:{x:0,y:0,width:e.width,height:e.height}},f=o.resource.type==="SpecificResource"?k(o.resource):null,g=f&&f.selector&&(f.selector.type==="BoxSelector"||f.selector.type==="TemporalBoxSelector")?{type:"BoxSelector",spatial:{x:f.selector.spatial.x,y:f.selector.spatial.y,width:f.selector.spatial.width,height:f.selector.spatial.height}}:p;i&&!i.id&&(i.id=i["@id"]);const v={id:s.id,type:"Image",annotationId:o.annotationId,width:l?s.width:e.width,height:l?s.height:e.height,service:i,sizes:i&&i.sizes?i.sizes:s.width&&s.height?[{width:s.width,height:s.height}]:[],target:l&&l.type!=="PointSelector"?l:a,selector:g};r.push(v)}return{type:"images",image:r[0],images:r,choice:t.choice}}const On=["model/gltf-binary"];function jn(e,t){const r=t.items[0].resource;return r.format?On.indexOf(r.format)===-1?w(`3D format: ${r.format} is unsupported`):{type:"3d-model",model:r}:w("Unknown format")}function _n(e,t){var r;if(!e.duration)return w("No duration on canvas");if(t.items.length>1)return w("Only one audio source supported");const n=(r=t.items[0])==null?void 0:r.resource;return n?n.format?{type:"media",media:{annotationId:t.items[0].annotationId,duration:e.duration,url:n.id,type:"Sound",target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:n.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},annotations:{pages:[]}}:w("Audio does not have format"):w("Unknown audio")}function Ln(e,t){var o;const n=t.items.filter(s=>s.type==="video");if(!e.duration)return w("No duration on canvas");if(n.length>1)return w("Only one video source supported");const r=(o=n[0])==null?void 0:o.resource;return r?r.format?{type:"media",media:{annotationId:t.items[0].annotationId,duration:e.duration,url:r.id,type:"Video",items:[],target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:r.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},annotations:{pages:[]}}:w("Video does not have format"):w("Unknown video")}function St(e,t={},n){const r=e.language||n||"none";switch(e.type){case"TextualBody":{typeof e.value!="undefined"&&(t[r]=e.value);break}case"List":case"Composite":case"Choice":e.items&&e.items.forEach(o=>St(o,t,r))}return t}function Fn(e,t){const n=[];return t.items.forEach(r=>{if(r.resource){const[o]=be(e,r.target);n.push({annotationId:r.annotationId,text:St(r.resource),target:o})}}),{type:"textual-content",items:n}}function Ct(e){const t=B(),n=_(),r=I(),[o,s]=mt(),{enabledPageIds:i}=gt((e==null?void 0:e.annotationPageManagerId)||(t==null?void 0:t.id)||(n==null?void 0:n.id),{all:!1}),a=ht(i,"AnnotationPage"),l=(e==null?void 0:e.strategies)||["empty","images","media","textual-content","complex-timeline"],[u,p]=yt(e,[s]),f=c.useMemo(()=>{if(!n)return J;if(u.types.length===0)return l.indexOf("empty")!==-1?dt(n.width,n.height):J;if(u.types.length!==1)if(u.types.length===2&&u.types.indexOf("text")!==-1)u.types=u.types.filter(v=>v!=="text");else return l.indexOf("complex-timeline")===-1?w("Complex timeline not supported"):w("ComplexTimelineStrategy not yet supported");const g=u.types[0];return g==="image"?l.indexOf("images")===-1?w("Image not supported"):xt(n,u,o):g==="Model"||g==="model"?l.indexOf("3d-model")===-1?w("3D not supported"):jn(n,u):g==="textualbody"?l.indexOf("textual-content")===-1?w("Textual content not supported"):Fn(n,u):g==="sound"||g==="audio"?l.indexOf("media")===-1?w("Media not supported"):_n(n,u):g==="video"?l.indexOf("media")===-1?w("Media not supported"):Ln(n,u):J},[n,u,r,p.makeChoice]);return c.useMemo(()=>f.type==="unknown"?[f,ft]:[b(S({},f),{annotations:{pages:a}}),p],[f,a])}const bt=(e,t=[])=>{const n=I();c.useEffect(()=>{e(n)},[n,...t])};function Vn(e,t={}){const n=t.imageServiceLoader||new U.ImageServiceLoader;async function r(o,s,i,a=[],l){if(typeof o=="string")return{best:U.getFixedSizeFromImage(o),fallback:[],log:[]};const u=e.get(o);if(typeof u=="string")return{best:U.getFixedSizeFromImage(u),fallback:[],log:[]};switch(u.type){case"Annotation":{const p=u.body,f=e.get(p[0]);return l&&!f.width&&(f.width=l.width,f.height=l.height),await n.getThumbnailFromResource(f,s,i,a)}case"Canvas":{const p=u;if(p.thumbnail&&p.thumbnail.length){const f=e.get(p.thumbnail[0]),g=await n.getImageCandidates(f,i);g&&g.length&&a.push(...g)}return r(p.items[0],s,i,a,{width:p.width,height:p.height})}case"AnnotationPage":return r(u.items[0],s,i,a,l);case"Choice":return r(u.items[0],s,i,a,l);case"Collection":{const f=u.items[0];return r(f,s,i,a,l)}case"Manifest":{const f=u.items[0];return r(f,s,i,a,l)}case"SpecificResource":case"Image":case"Dataset":case"Sound":case"Text":case"TextualBody":case"Video":return l&&!u.width&&(u.width=l.width,u.height=l.height),n.getThumbnailFromResource(u,s,i,a);case"Service":case"Range":case"AnnotationCollection":case"CanvasReference":case"ContentResource":return{best:void 0,fallback:[],log:[]}}return{best:void 0,fallback:[],log:[]}}return{getBestThumbnailAtSize:r}}function Et(e,t,{canvasId:n,manifestId:r}={}){const o=I(),s=ie(),i=c.useMemo(()=>Vn(o,{imageServiceLoader:s}),[o,s]),[a,l]=c.useState(),u=B(r?{id:r}:void 0),p=_(n?{id:n}:void 0),f=p||u,g=c.useRef(!1);if(c.useEffect(()=>(g.current=!1,()=>{g.current=!0}),[]),!f)throw new Error("Must be called under a manifest or canvas context.");return bt(v=>{i.getBestThumbnailAtSize(f,e,t).then(h=>{h.best&&!g.current&&l(h.best)})},[f]),a}function kn(e){return{isMuted:!1,playRequested:!1,isPlaying:!1,isFinished:!1,volume:100,duration:e}}function Nn(e,t){switch(t.type){case"FINISHED":return b(S({},e),{isFinished:!0,isPlaying:!1,playRequested:!1});case"PLAY_PAUSE":return b(S({},e),{isFinished:!1,isPlaying:!e.isPlaying});case"PLAY_REQUESTED":return b(S({},e),{isFinished:!1,playRequested:!0});case"PAUSE":return b(S({},e),{isPlaying:!1});case"PLAY":return b(S({},e),{isFinished:!1,playRequested:!1,isPlaying:!0});case"MUTE":return b(S({},e),{isMuted:!0});case"SET_VOLUME":return b(S({},e),{volume:t.volume,isMuted:t.volume===0});case"TOGGLE_MUTE":return b(S({},e),{isMuted:!e.isMuted});case"UNMUTE":return b(S({},e),{isMuted:!1})}return e}function Pt(e){const t=Math.round(e);return`${Math.floor(t/60)}:${`${t%60}`.padStart(2,"0")}`}function Ee(e){const[t,n]=c.useReducer(Nn,kn(e.duration)),r=c.useRef(null),o=c.useRef(null),s=c.useRef(null),i=c.useRef(!1),a=c.useCallback(()=>{o.current&&r.current&&(o.current.innerHTML=Pt(r.current.currentTime),s.current&&(s.current.style.width=`${r.current.currentTime/e.duration*100}%`),i.current!==r.current.muted&&(i.current=r.current.muted,n(r.current.muted?{type:"MUTE"}:{type:"UNMUTE"})))},[e.duration]),l=c.useCallback(()=>{r.current&&(n({type:"PLAY_REQUESTED"}),r.current.play().then(()=>{n({type:"PLAY"})}),a())},[a]),u=c.useCallback(()=>{r.current&&(r.current.duration>0&&r.current.paused?l():p())},[a]),p=c.useCallback(()=>{r.current&&(r.current.pause(),n({type:"PAUSE"}),a())},[a]),f=c.useCallback(()=>{r.current&&(r.current.muted=!r.current.muted,n(r.current.muted?{type:"MUTE"}:{type:"UNMUTE"}))},[]),g=c.useCallback(()=>{r.current&&(r.current.muted=!0,n({type:"MUTE"}))},[]),v=c.useCallback(()=>{r.current&&(r.current.muted=!1,n({type:"UNMUTE"}))},[]),h=c.useCallback(C=>{r.current&&(r.current.muted=!1,r.current.volume=C/100,n({type:"SET_VOLUME",volume:C}))},[]),y=c.useCallback(C=>{r.current&&(r.current.currentTime=Math.max(0,Math.min(C*e.duration,e.duration)),a())},[]),x=c.useCallback(C=>{r.current&&(r.current.currentTime=Math.max(0,Math.min(C,e.duration)),a())},[]);return c.useEffect(()=>{const C=setInterval(()=>{a()},350);return()=>clearInterval(C)},[a,e.duration]),c.useEffect(()=>{const C=()=>{n({type:"FINISHED"})},m=r.current;return m==null||m.addEventListener("ended",C),()=>m==null?void 0:m.removeEventListener("ended",C)},[]),[{element:r,currentTime:o,progress:s},t,{play:l,pause:p,playPause:u,mute:g,unmute:v,toggleMute:f,setVolume:h,setDurationPercent:y,setTime:x}]}const wt=c.createContext(null),It=c.createContext(null),Rt=c.createContext(null);function Un(){const e=c.useContext(wt);if(!e)throw new Error("Ctx not found");return e}function Dn(){const e=c.useContext(It);if(!e)throw new Error("Ctx not found");return e}function Bn(){const e=c.useContext(Rt);if(!e)throw new Error("Ctx not found");return e}function Pe({actions:e,state:t,children:n,currentTime:r,progress:o,element:s}){return d.jsx(Rt.Provider,{value:{currentTime:r,progress:o,element:s},children:d.jsx(It.Provider,{value:e,children:d.jsx(wt.Provider,{value:t,children:n})})})}function Hn({media:e,children:t}){const[{element:n,currentTime:r,progress:o},s,i]=Ee({duration:e.duration});return d.jsx(d.Fragment,{children:d.jsx(H,{children:d.jsxs(Pe,{state:s,actions:i,currentTime:r,progress:o,element:n,children:[d.jsx("audio",{ref:n,src:e.url}),t]})})})}function qn({media:e,children:t}){const[{element:n,currentTime:r,progress:o},s,i]=Ee({duration:e.duration}),a="div";return d.jsxs(d.Fragment,{children:[d.jsxs(H,{overlay:!0,children:[d.jsx("style",{children:`
2
2
  .video-container {
3
3
  position: absolute;
4
4
  top: 0;
@@ -11,7 +11,7 @@
11
11
  justify-content: center;
12
12
  pointer-events: visible;
13
13
  }
14
- `}),f.jsx(s,{className:"video-container",part:"video-container",onClick:()=>i.playPause(),children:f.jsx("video",{ref:r,src:e.url,style:{width:"100%",objectFit:"contain"}})})]}),f.jsx(L,{children:f.jsx(ue,{state:o,actions:i,currentTime:n,progress:a,element:r,children:t})})]})}function dn({model:e}){return f.jsxs(L,{overlay:!0,children:[f.jsx("style",{children:`
14
+ `}),d.jsx(a,{className:"video-container",part:"video-container",onClick:()=>i.playPause(),children:d.jsx("video",{ref:n,src:e.url,style:{width:"100%",objectFit:"contain"}})})]}),d.jsx(H,{children:d.jsx(Pe,{state:s,actions:i,currentTime:r,progress:o,element:n,children:t})})]})}function $n({model:e}){return d.jsxs(H,{overlay:!0,children:[d.jsx("style",{children:`
15
15
  .model-container {
16
16
  position: absolute;
17
17
  top: 0;
@@ -24,5 +24,7 @@
24
24
  justify-content: center;
25
25
  pointer-events: visible;
26
26
  }
27
- `}),f.jsx("div",{className:"model-container",children:f.jsx("model-viewer",{"interaction-prompt":"none",style:{width:"100%",height:"100%"},"camera-controls":"","ar-status":"not-presenting",src:e.id})})]})}function tt({x:e,y:t,onChoiceChange:r,registerActions:n,defaultChoices:a,isStatic:o,renderViewerControls:i,renderMediaControls:s,strategies:u,children:l}){const d=j(),p=se(d,["deep-zoom"]),[h]=Ie(),v=w(),g=c.useMemo(()=>ae(v),[v]),[m,x]=Ge({strategies:u||["images"],defaultChoices:a==null?void 0:a.map(({id:T})=>T)}),E=m.type==="images"?m.choice:void 0;c.useEffect(()=>{n&&n(x)},[m.annotations]),c.useEffect(()=>{if(a)for(const T of a)typeof T.opacity!="undefined"&&g.applyStyles({id:T.id},"atlas",{opacity:T.opacity})},[a]),c.useLayoutEffect(()=>{r&&r(E)},[E]);const S=We({maxWidth:256,maxHeight:256});if(!d)return null;const P=d.accompanyingCanvas,M=S&&S.type==="fixed"?f.jsx("world-object",{height:d.height,width:d.width,x:e,y:t,children:f.jsx("world-image",{uri:S.id,target:{x:0,y:0,width:d.width,height:d.height},display:S.width&&S.height?{width:S.width,height:S.height}:void 0})}):null;if(m.type==="unknown"){if(M)return M;throw new Error(m.reason||"Unknown image strategy")}const rt=f.jsxs(c.Fragment,{children:[h?f.jsx(ee,{page:h}):null,m.annotations&&m.annotations.pages?m.annotations.pages.map(T=>f.jsx(ee,{page:T},T.id)):null,l]});return f.jsxs(f.Fragment,{children:[f.jsxs("world-object",C(y({height:d.height,width:d.width,x:e,y:t},p),{children:[m.type==="images"?f.jsxs(f.Fragment,{children:[m.images.map((T,it)=>f.jsx(Fe,{isStatic:o,image:T,id:T.id,thumbnail:it===0?S:void 0,annotations:rt},T.id)),i?f.jsx(L,{overlay:!0,children:i(m)}):null]}):null,m.type==="3d-model"?f.jsx(dn,{model:m.model}):null,m.type==="media"?f.jsx(f.Fragment,{children:m.media.type==="Sound"?f.jsxs(un,{media:m.media,children:[M,s?s(m):null]}):m.media.type==="Video"?f.jsxs(ln,{media:m.media,children:[M,s?s(m):null]}):null}):null]}),m.type),m.type==="media"&&m.media.type==="Sound"&&P?f.jsx(re,{canvas:P.id,children:f.jsx(tt,{renderViewerControls:i})}):null]})}const fn={RenderImage:Fe,RenderCanvas:tt,RenderAnnotationPage:ee,RenderAnnotation:ke,Viewer:Bt};function pn({annotation:e,children:t}){return f.jsx(V,{value:{annotation:e},children:t})}function mn({collection:e,children:t}){return f.jsx(V,{value:{collection:e},children:t})}function gn({range:e,children:t}){return f.jsx(V,{value:{range:e},children:t})}function hn(e,t={}){return W(t)}function vn(e,t=!1){}function yn(e,t=[]){const{id:r,selector:n}=e,a=O(),o=r||a.collection,i=b(s=>o?s.iiif.entities.Collection[o]:void 0,[o]);return c.useMemo(()=>{if(!!i)return n?n(i):i},[i,n,...t])}function xn(e,t,r,n,a=[]){const o=w(),i=c.useMemo(()=>Ve(o),[o]);c.useEffect(()=>{const s=e;return s?(i.addEventListener(s,t,r,n),()=>{i.removeEventListener(s,t,r)}):()=>{}},[i,e,t,...a])}function Sn(){const e=c.useContext(U);return e&&e.vault?e.vault:q.globalVault()}function En(e,t){const{id:r,isLoaded:n,error:a,resource:o,requestId:i,cached:s}=ne(e,t);return{id:r,isLoaded:n,error:a,manifest:o,requestId:i,cached:s}}function nt({cacheKey:e}={}){const t=j(),r=W(),n=w(),a=K(),[o,i]=c.useState(void 0),[s,u]=c.useState(!1),[l,d]=c.useState("idle"),[p,h]=c.useState(void 0),v=t?t.id:"undefined",g=c.useMemo(()=>{try{if(t&&r.length){const x=r[0],E=n.get(x.body[0]),P=_.getImageServices(E)[0];return P&&a.loadServiceSync({id:P.id||P["@id"],width:P.width||t.width,height:P.height||t.height})||void 0}}catch(x){console.error(x)}},[v,e,t]),m=l==="success"&&o?o:g;return c.useEffect(()=>{(async()=>{try{if(t&&r.length){const x=r[0],E=n.get(x.body[0]),P=_.getImageServices(E)[0];if(!P)return;u(!0),d("loading");try{const M=await a.loadService({id:P.id||P["@id"],width:P.width||t.width,height:P.height||t.height})||void 0;i(M),d("success"),u(!1)}catch(M){d("error"),h(M)}}}catch(x){d("error"),h(x)}})()},[v,e]),c.useMemo(()=>({data:m,isFetching:s,status:l,error:p}),[m,s,l,p])}function Cn(){const e=nt();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 Pn(e={},t=[]){const{id:r,selector:n}=e,a=O(),o=r||a.range,i=b(s=>o?s.iiif.entities.Range[o]:void 0,[o]);return c.useMemo(()=>{if(!!i)return n?n(i):i},[i,n,...t])}function Rn(){const e=B();return e?e.service.find(t=>t.profile==="SearchService1"||t.profile==="http://iiif.io/api/search/1/search"):void 0}function wn(){const e=w();return c.useMemo(()=>ae(e),[e])}exports.AnnotationContext=pn;exports.CanvasContext=re;exports.CanvasPanel=fn;exports.CanvasPortal=L;exports.CollectionContext=mn;exports.ContextBridge=Ae;exports.ImageServiceLoaderContext=qe;exports.ManifestContext=Pe;exports.MediaPlayerProvider=ue;exports.OverlayPortalContext=oe;exports.PortalContext=ie;exports.RangeContext=gn;exports.ReactVaultContext=U;exports.ResourceProvider=V;exports.ResourceReactContext=$;exports.SimpleViewerProvider=gt;exports.SimpleViewerReactContext=N;exports.VaultProvider=Ee;exports.ViewerPresetContext=G;exports.VirtualAnnotationProvider=je;exports.VisibleCanvasReactContext=D;exports.emptyActions=Ne;exports.expandTarget=I;exports.flattenAnnotationPageIds=Be;exports.formatTime=Xe;exports.getImageStrategy=$e;exports.getPaintables=De;exports.parseSelector=z;exports.parseSpecificResource=Ue;exports.unknownResponse=te;exports.unsupportedStrategy=R;exports.useAnnotation=Le;exports.useAnnotationPageManager=He;exports.useAnnotationsAtTime=hn;exports.useCanvas=j;exports.useCanvasClock=vn;exports.useCollection=yn;exports.useContextBridge=we;exports.useDispatch=be;exports.useEventListener=xn;exports.useExistingVault=Sn;exports.useExternalCollection=En;exports.useExternalManifest=Ce;exports.useExternalResource=ne;exports.useImageService=nt;exports.useImageServiceLoader=K;exports.useImageTile=Cn;exports.useLoadImageService=Qe;exports.useManifest=B;exports.useMediaActions=an;exports.useMediaElements=cn;exports.useMediaState=sn;exports.usePaintables=ze;exports.usePaintingAnnotations=W;exports.useRange=Pn;exports.useRenderingStrategy=Ge;exports.useResourceContext=O;exports.useResourceEvents=se;exports.useResources=Ye;exports.useSearchService=Rn;exports.useSimpleMediaPlayer=ce;exports.useSimpleViewer=ht;exports.useStyleHelper=wn;exports.useStyles=F;exports.useThumbnail=We;exports.useVault=w;exports.useVaultEffect=Ke;exports.useVaultSelector=b;exports.useViewerPreset=Oe;exports.useVirtualAnnotationPage=Me;exports.useVirtualAnnotationPageContext=Ie;exports.useVisibleCanvases=Re;
27
+ `}),d.jsx("div",{className:"model-container",children:d.jsx("model-viewer",{"interaction-prompt":"none",style:{width:"100%",height:"100%"},"camera-controls":"","ar-status":"not-presenting",src:e.id})})]})}function At({style:e}){const t=_();return!t||!t.height||!t.width?null:d.jsx("box",{interactive:!1,target:{x:0,y:0,width:t.width,height:t.height},style:e})}var zn=Object.defineProperty,Yn=Object.defineProperties,Qn=Object.getOwnPropertyDescriptors,ee=Object.getOwnPropertySymbols,Mt=Object.prototype.hasOwnProperty,Tt=Object.prototype.propertyIsEnumerable,Ve=(e,t,n)=>t in e?zn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,N=(e,t)=>{for(var n in t||(t={}))Mt.call(t,n)&&Ve(e,n,t[n]);if(ee)for(var n of ee(t))Tt.call(t,n)&&Ve(e,n,t[n]);return e},te=(e,t)=>Yn(e,Qn(t)),Ot=(e,t)=>{var n={};for(var r in e)Mt.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&ee)for(var r of ee(e))t.indexOf(r)<0&&Tt.call(e,r)&&(n[r]=e[r]);return n};function Gn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Kn(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ke(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Wn(e,t,n){return t&&ke(e.prototype,t),n&&ke(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}var Xn={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0},Jn,Zn=D.default.createContext();function er(){return Xn}var tr=function(){function e(){Kn(this,e),this.usedNamespaces={}}return Wn(e,[{key:"addUsedNamespaces",value:function(n){var r=this;n.forEach(function(o){r.usedNamespaces[o]||(r.usedNamespaces[o]=!0)})}},{key:"getUsedNamespaces",value:function(){return Object.keys(this.usedNamespaces)}}]),e}();function nr(){return Jn}function rr(){if(console&&console.warn){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];typeof n[0]=="string"&&(n[0]="react-i18next:: ".concat(n[0])),(e=console).warn.apply(e,n)}}var Ne={};function de(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];typeof t[0]=="string"&&Ne[t[0]]||(typeof t[0]=="string"&&(Ne[t[0]]=new Date),rr.apply(void 0,t))}function Ue(e,t,n){e.loadNamespaces(t,function(){if(e.isInitialized)n();else{var r=function o(){setTimeout(function(){e.off("initialized",o)},0),n()};e.on("initialized",r)}})}function ir(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(!t.languages||!t.languages.length)return de("i18n.languages were undefined or empty",t.languages),!0;var r=t.languages[0],o=t.options?t.options.fallbackLng:!1,s=t.languages[t.languages.length-1];if(r.toLowerCase()==="cimode")return!0;var i=function(l,u){var p=t.services.backendConnector.state["".concat(l,"|").concat(u)];return p===-1||p===2};return n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&t.services.backendConnector.backend&&t.isLanguageChangingTo&&!i(t.isLanguageChangingTo,e)?!1:!!(t.hasResourceBundle(r,e)||!t.services.backendConnector.backend||i(r,e)&&(!o||i(s,e)))}function or(e){if(Array.isArray(e))return e}function sr(e,t){var n=e==null?null:typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r=[],o=!0,s=!1,i,a;try{for(n=n.call(e);!(o=(i=n.next()).done)&&(r.push(i.value),!(t&&r.length===t));o=!0);}catch(l){s=!0,a=l}finally{try{!o&&n.return!=null&&n.return()}finally{if(s)throw a}}return r}}function De(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function ar(e,t){if(!!e){if(typeof e=="string")return De(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return De(e,t)}}function cr(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
28
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ur(e,t){return or(e)||sr(e,t)||ar(e,t)||cr()}function Be(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function ue(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Be(Object(n),!0).forEach(function(r){Gn(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Be(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function jt(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=t.i18n,r=c.useContext(Zn)||{},o=r.i18n,s=r.defaultNS,i=n||o||nr();if(i&&!i.reportNamespaces&&(i.reportNamespaces=new tr),!i){de("You will need to pass in an i18next instance by using initReactI18next");var a=function(T){return Array.isArray(T)?T[T.length-1]:T},l=[a,{},!1];return l.t=a,l.i18n={},l.ready=!1,l}i.options.react&&i.options.react.wait!==void 0&&de("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");var u=ue(ue(ue({},er()),i.options.react),t),p=u.useSuspense,f=u.keyPrefix,g=e||s||i.options&&i.options.defaultNS;g=typeof g=="string"?[g]:g||["translation"],i.reportNamespaces.addUsedNamespaces&&i.reportNamespaces.addUsedNamespaces(g);var v=(i.isInitialized||i.initializedStoreOnce)&&g.every(function(O){return ir(O,i,u)});function h(){return i.getFixedT(null,u.nsMode==="fallback"?g:g[0],f)}var y=c.useState(h),x=ur(y,2),C=x[0],m=x[1],P=c.useRef(!0);c.useEffect(function(){var O=u.bindI18n,T=u.bindI18nStore;P.current=!0,!v&&!p&&Ue(i,g,function(){P.current&&m(h)});function V(){P.current&&m(h)}return O&&i&&i.on(O,V),T&&i&&i.store.on(T,V),function(){P.current=!1,O&&i&&O.split(" ").forEach(function(E){return i.off(E,V)}),T&&i&&T.split(" ").forEach(function(E){return i.store.off(E,V)})}},[i,g.join()]);var j=c.useRef(!0);c.useEffect(function(){P.current&&!j.current&&m(h),j.current=!1},[i]);var M=[C,i,v];if(M.t=C,M.i18n=i,M.ready=v,v||!v&&!p)return M;throw new Promise(function(O){Ue(i,g,function(){O()})})}function lr(e){var t=e,{as:n,language:r,children:o}=t,s=Ot(t,["as","language","children"]);const{i18n:i}=jt(),a=c.useMemo(()=>i.dir?i.dir(r):"ltr",[r]);return c.useMemo(()=>i.services?i.services.languageUtils.getLanguagePartFromCode(i.language)===i.services.languageUtils.getLanguagePartFromCode(r):!1,[i.language,r])?n?d.jsx(n,b(S({},N({},s)),{children:o})):d.jsx("span",b(S({},N({},s)),{children:o})):n?d.jsx(n,b(S({},te(N({},s),{lang:r,dir:a})),{children:o})):d.jsx("span",b(S({},te(N({},s),{lang:r,dir:a})),{children:o}))}function _t(e,t,n=[],r=!1){if(!e||!t||t.length===0)return;if(t.length===1)return t[0];if(t.indexOf(e)!==-1)return e;const o=e.indexOf("-")!==-1?e.slice(0,e.indexOf("-")):null;if(o&&t.indexOf(o)!==-1)return o;for(const s of n)if(t.indexOf(s)!==-1)return s;if(!r){const i=t.map(a=>a.indexOf("-")!==-1?a.slice(0,a.indexOf("-")):null).indexOf(e);if(i!==-1)return t[i];for(const a of n){const l=a.indexOf("-")!==-1?a.slice(0,a.indexOf("-")):null,u=l?t.indexOf(l):-1;if(u!==-1)return t[u]}}return t.indexOf("none")!==-1?"none":t.indexOf("@none")!==-1?"@none":t[0]}function fr(e,t,n={}){const{strictFallback:r=!1,defaultText:o="",separator:s=`
29
+ `,fallbackLanguages:i=[],closest:a}=n,l=Object.keys(e||{}),u=a?t:_t(t,l,i,r);if(!e)return o;if(typeof e=="string")return e;const p=u?e[u]:void 0;return p?typeof p=="string"?p:p.join(s):""}function dr(e,t=[]){const{i18n:n}=jt(),r=n&&n.languages?n.languages:[],o=n&&n.language?n.language:"en";return c.useMemo(()=>{const s=e();return _t(o,s,r)},[r,o,...t])}function pr(e,t){const n=dr(()=>Object.keys(e||{}),[e]);return[c.useMemo(()=>fr(e,n,{defaultText:t,closest:!0}),[n,t,e]),n]}const gr=e=>{var t=e,{as:n,defaultText:r,enableDangerouslySetInnerHTML:o,children:s}=t,i=Ot(t,["as","defaultText","enableDangerouslySetInnerHTML","children"]);const[a,l]=pr(s,r);return l?d.jsx(lr,b(S({},te(N({},i),{as:n,language:l,title:o?void 0:a,dangerouslySetInnerHTML:o?{__html:a}:void 0})),{children:o?void 0:a})):n?d.jsx(n,b(S({},N({},i)),{children:a})):d.jsx("span",b(S({},te(N({},i),{title:o?void 0:a,dangerouslySetInnerHTML:o?{__html:a}:void 0})),{children:o?void 0:a}))};function Lt({x:e,y:t,onChoiceChange:n,registerActions:r,defaultChoices:o,isStatic:s,renderViewerControls:i,renderMediaControls:a,strategies:l,backgroundStyle:u,alwaysShowBackground:p,onClickPaintingAnnotation:f,children:g}){const v=_(),h=Se(v,["deep-zoom"]),[y]=nt(),x=I(),C=c.useMemo(()=>Ce(x),[x]),[m,P]=Ct({strategies:l||["images"],defaultChoices:o==null?void 0:o.map(({id:E})=>E)}),j=m.type==="images"?m.choice:void 0;c.useEffect(()=>{r&&r(P)},[m.annotations]),c.useEffect(()=>{if(o)for(const E of o)typeof E.opacity!="undefined"&&C.applyStyles({id:E.id},"atlas",{opacity:E.opacity})},[o]),c.useLayoutEffect(()=>{n&&n(j)},[j]);const M=Et({maxWidth:256,maxHeight:256});if(!v)return null;const O=v.accompanyingCanvas,T=M&&M.type==="fixed"?d.jsx("world-object",{height:v.height,width:v.width,x:e,y:t,children:d.jsx("world-image",{uri:M.id,target:{x:0,y:0,width:v.width,height:v.height},display:M.width&&M.height?{width:M.width,height:M.height}:void 0})}):null;if(m.type==="unknown"){if(T)return T;throw new Error(m.reason||"Unknown image strategy")}const V=d.jsxs(c.Fragment,{children:[y?d.jsx(fe,{page:y}):null,m.annotations&&m.annotations.pages?m.annotations.pages.map(E=>d.jsx(fe,{page:E},E.id)):null,g]});return d.jsxs(d.Fragment,{children:[d.jsxs("world-object",b(S({height:v.height,width:v.width,x:e,y:t},h),{children:[m.type==="empty"||p?d.jsx(At,{style:u}):null,m.type==="textual-content"?m.items.map((E,se)=>d.jsxs(d.Fragment,{children:[d.jsx(z.HTMLPortal,{onClick:f?q=>{q.stopPropagation(),f(E.annotationId,E,q)}:void 0,target:E.target.spatial||void 0,children:d.jsx(gr,{children:E.text})},se),V]})):null,m.type==="images"?d.jsxs(d.Fragment,{children:[m.images.map((E,se)=>d.jsx(ct,{isStatic:s,image:E,id:E.id,thumbnail:se===0?M:void 0,onClick:f?q=>{q.stopPropagation(),f(E.annotationId,E,q)}:void 0},E.id)),V]}):null,(m.type==="images"||m.type==="empty"||m.type==="textual-content")&&i?d.jsx(H,{overlay:!0,children:i(m)}):null,m.type==="3d-model"?d.jsx($n,{model:m.model}):null,m.type==="media"?d.jsx(d.Fragment,{children:m.media.type==="Sound"?d.jsxs(Hn,{media:m.media,children:[T,a?a(m):null]}):m.media.type==="Video"?d.jsxs(qn,{media:m.media,children:[T,a?a(m):null]}):null}):null]}),`${v.id}/${m.type}`),m.type==="media"&&m.media.type==="Sound"&&O?d.jsx(ge,{canvas:O.id,children:d.jsx(Lt,{renderViewerControls:i})}):null]})}const hr={RenderImage:ct,RenderCanvas:Lt,RenderAnnotationPage:fe,RenderAnnotation:at,Viewer:Sn,CanvasBackground:At};function vr({annotation:e,children:t}){return d.jsx(F,{value:{annotation:e},children:t})}function mr({annotationPage:e,children:t}){return d.jsx(F,{value:{annotationPage:e},children:t})}function yr({collection:e,children:t}){return d.jsx(F,{value:{collection:e},children:t})}function xr(e,t={}){return oe(t)}function Sr(e,t=!1){}function Cr(e){const n=L().manifest,r=e?e.map(o=>typeof o=="string"?o:o==null?void 0:o.id):[];return A(o=>{const s=n?o.iiif.entities.Manifest[n]:void 0,i=(s==null?void 0:s.items)||[];if(typeof e=="undefined")return i;const a=[];for(const l of(s==null?void 0:s.items)||[])r.indexOf(l.id)!==-1&&a.push(l);return a},[r.join("/")])}function br(e,t=[]){const{id:n,selector:r}=e,o=L(),s=n||o.collection,i=A(a=>s?a.iiif.entities.Collection[s]:void 0,[s]);return c.useMemo(()=>{if(!!i)return r?r(i):i},[i,r,...t])}function Er(e,t,n,r,o=[]){const s=I(),i=c.useMemo(()=>ot(s),[s]);c.useEffect(()=>{const a=e;return a?(i.addEventListener(a,t,n,r),()=>{i.removeEventListener(a,t,n)}):()=>{}},[i,e,t,...o])}function Pr(){const e=c.useContext(Q);return e&&e.vault?e.vault:X.globalVault()}function wr(e,t){const{id:n,isLoaded:r,error:o,resource:s,requestId:i,cached:a}=pe(e,t);return{id:n,isLoaded:r,error:o,manifest:s,requestId:i,cached:a}}function Ft({cacheKey:e}={}){const t=_(),n=oe(),r=I(),o=ie(),[s,i]=c.useState(void 0),[a,l]=c.useState(!1),[u,p]=c.useState("idle"),[f,g]=c.useState(void 0),v=t?t.id:"undefined",h=c.useMemo(()=>{try{if(t&&n.length){const x=n[0],C=r.get(x.body[0]),P=U.getImageServices(C)[0];return P&&o.loadServiceSync({id:P.id||P["@id"],width:P.width||t.width,height:P.height||t.height})||void 0}}catch(x){console.error(x)}},[v,e,t]),y=u==="success"&&s?s:h;return c.useEffect(()=>{(async()=>{try{if(t&&n.length){const x=n[0],C=r.get(x.body[0]),P=U.getImageServices(C)[0];if(!P)return;l(!0),p("loading");try{const j=await o.loadService({id:P.id||P["@id"],width:P.width||t.width,height:P.height||t.height})||void 0;i(j),p("success"),l(!1)}catch(j){p("error"),g(j)}}}catch(x){p("error"),g(x)}})()},[v,e]),c.useMemo(()=>({data:y,isFetching:a,status:u,error:f}),[y,a,u,f])}function Ir(){const e=Ft();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 Rr(){const e=B();return e?e.service.find(t=>t.profile==="SearchService1"||t.profile==="http://iiif.io/api/search/1/search"):void 0}function Ar(){const e=I();return c.useMemo(()=>Ce(e),[e])}exports.AnnotationContext=vr;exports.AnnotationPageContext=mr;exports.CanvasContext=ge;exports.CanvasPanel=hr;exports.CanvasPortal=H;exports.CollectionContext=yr;exports.ContextBridge=Je;exports.ImageServiceLoaderContext=vt;exports.InnerViewerProvider=We;exports.ManifestContext=$e;exports.MediaPlayerProvider=Pe;exports.OverlayPortalContext=xe;exports.PortalContext=ye;exports.RangeContext=Ye;exports.ReactVaultContext=Q;exports.ResourceProvider=F;exports.ResourceReactContext=ne;exports.SimpleViewerProvider=Gt;exports.SimpleViewerReactContext=K;exports.VaultProvider=He;exports.ViewerPresetContext=re;exports.VirtualAnnotationProvider=rt;exports.VisibleCanvasReactContext=G;exports.emptyActions=ft;exports.emptyStrategy=dt;exports.expandTarget=k;exports.findAllCanvasesInRange=he;exports.findFirstCanvasFromRange=Qe;exports.findManifestSelectedRange=Yt;exports.findSelectedRange=ve;exports.flattenAnnotationPageIds=pt;exports.formatTime=Pt;exports.getImageStrategy=xt;exports.getManifestSequence=me;exports.getPaintables=lt;exports.getParsedTargetSelector=be;exports.getVisibleCanvasesFromCanvasId=Qt;exports.parseSelector=Z;exports.parseSpecificResource=ut;exports.unknownResponse=J;exports.unsupportedStrategy=w;exports.useAnnotation=st;exports.useAnnotationPageManager=gt;exports.useAnnotationsAtTime=xr;exports.useCanvas=_;exports.useCanvasClock=Sr;exports.useCanvasSequence=Ke;exports.useCanvasSubset=Cr;exports.useCollection=br;exports.useContextBridge=Xe;exports.useDispatch=Ze;exports.useEventListener=Er;exports.useExistingVault=Pr;exports.useExternalCollection=wr;exports.useExternalManifest=qe;exports.useExternalResource=pe;exports.useImageService=Ft;exports.useImageServiceLoader=ie;exports.useImageTile=Ir;exports.useLoadImageService=mt;exports.useManifest=B;exports.useMediaActions=Dn;exports.useMediaElements=Bn;exports.useMediaState=Un;exports.usePaintables=yt;exports.usePaintingAnnotations=oe;exports.useRange=Ge;exports.useRenderingStrategy=Ct;exports.useResourceContext=L;exports.useResourceEvents=Se;exports.useResources=ht;exports.useSearchService=Rr;exports.useSimpleMediaPlayer=Ee;exports.useSimpleViewer=Kt;exports.useStyleHelper=Ar;exports.useStyles=Y;exports.useThumbnail=Et;exports.useVault=I;exports.useVaultEffect=bt;exports.useVaultSelector=A;exports.useViewerPreset=it;exports.useVirtualAnnotationPage=et;exports.useVirtualAnnotationPageContext=nt;exports.useVisibleCanvases=ze;
28
30
  //# sourceMappingURL=index.js.map