react-iiif-vault 0.9.10 → 0.9.13

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