react-iiif-vault 1.4.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.d.ts +150 -18
- package/dist/bundle.global.js +30 -28
- package/dist/canvas-panel.cjs +7 -7
- package/dist/canvas-panel.d.cts +2 -3
- package/dist/canvas-panel.d.ts +2 -3
- package/dist/canvas-panel.js +1 -1
- package/dist/chunk-IWRMLB3G.js +48 -0
- package/dist/chunk-XNDN34SQ.js +1 -0
- package/dist/{index-BAYQ0qVx.d.cts → index-CMSk5Jbz.d.cts} +5 -5
- package/dist/{index-CnXzAuQK.d.ts → index-CWeYvmxZ.d.ts} +5 -5
- package/dist/index.cjs +9 -9
- package/dist/index.d.cts +128 -18
- package/dist/index.d.ts +128 -18
- package/dist/index.js +1 -1
- package/dist/{useRenderingStrategy-DkjxMKJV.d.cts → useRenderingStrategy-BiuSDiXu.d.cts} +16 -3
- package/dist/{useRenderingStrategy-DkjxMKJV.d.ts → useRenderingStrategy-BiuSDiXu.d.ts} +16 -3
- package/dist/utils-C-h4SU3S.d.ts +41 -0
- package/dist/utils-CvRzsfRK.d.cts +41 -0
- package/dist/utils.cjs +1 -1
- package/dist/utils.d.cts +7 -32
- package/dist/utils.d.ts +7 -32
- package/dist/utils.js +1 -1
- package/package.json +4 -5
- package/dist/chunk-7KUFVAUD.js +0 -48
- package/dist/chunk-CCTBCLBV.js +0 -1
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { ChoiceDescription, Paintables, SupportedTarget, ComplexChoice } from '@iiif/helpers';
|
|
2
2
|
import { ImageService, ExternalWebResource, InternationalString } from '@iiif/presentation-3';
|
|
3
|
-
import { AnnotationPageNormalized, CanvasNormalized } from '@iiif/presentation-3-normalized';
|
|
3
|
+
import { AnnotationNormalized, AnnotationPageNormalized, CanvasNormalized } from '@iiif/presentation-3-normalized';
|
|
4
4
|
import { BoxSelector, TemporalBoxSelector, TemporalSelector } from '@iiif/helpers/annotation-targets';
|
|
5
5
|
import { Emitter } from 'mitt';
|
|
6
6
|
|
|
7
7
|
type ImageWithOptionalService = {
|
|
8
8
|
id: string;
|
|
9
9
|
annotationId: string;
|
|
10
|
+
annotation: AnnotationNormalized;
|
|
10
11
|
type: 'Image';
|
|
11
12
|
service?: ImageService;
|
|
12
13
|
width?: number;
|
|
@@ -21,6 +22,7 @@ type ImageWithOptionalService = {
|
|
|
21
22
|
type SingleAudio = {
|
|
22
23
|
type: 'Sound';
|
|
23
24
|
annotationId: string;
|
|
25
|
+
annotation: AnnotationNormalized;
|
|
24
26
|
url: string;
|
|
25
27
|
format: string;
|
|
26
28
|
duration: number;
|
|
@@ -33,6 +35,7 @@ type SingleAudio = {
|
|
|
33
35
|
type SingleYouTubeVideo = {
|
|
34
36
|
type: 'VideoYouTube';
|
|
35
37
|
annotationId: string;
|
|
38
|
+
annotation: AnnotationNormalized;
|
|
36
39
|
url: string;
|
|
37
40
|
youTubeId: string;
|
|
38
41
|
duration: number;
|
|
@@ -42,6 +45,7 @@ type SingleYouTubeVideo = {
|
|
|
42
45
|
type SingleVideo = {
|
|
43
46
|
type: 'Video';
|
|
44
47
|
annotationId: string;
|
|
48
|
+
annotation: AnnotationNormalized;
|
|
45
49
|
url: string;
|
|
46
50
|
format: string;
|
|
47
51
|
duration: number;
|
|
@@ -70,7 +74,13 @@ type ImageServiceLoaderType = (imageService: any | undefined, { height, width }:
|
|
|
70
74
|
height: number;
|
|
71
75
|
width: number;
|
|
72
76
|
}) => ImageService | undefined;
|
|
73
|
-
declare function useLoadImageService(): readonly [ImageServiceLoaderType, Record<string,
|
|
77
|
+
declare function useLoadImageService(): readonly [ImageServiceLoaderType, Record<string, {
|
|
78
|
+
status: "error" | "loading" | "done";
|
|
79
|
+
service: ImageService | null;
|
|
80
|
+
error?: boolean | undefined;
|
|
81
|
+
errorMesage?: string | undefined;
|
|
82
|
+
real?: boolean | undefined;
|
|
83
|
+
}>];
|
|
74
84
|
|
|
75
85
|
type SingleImageStrategy = {
|
|
76
86
|
type: 'images';
|
|
@@ -86,6 +96,8 @@ type Single3DModelStrategy = {
|
|
|
86
96
|
model: ExternalWebResource;
|
|
87
97
|
choice?: ChoiceDescription;
|
|
88
98
|
annotations?: AnnotationPageDescription;
|
|
99
|
+
annotation: AnnotationNormalized;
|
|
100
|
+
annotationId: string;
|
|
89
101
|
};
|
|
90
102
|
declare function get3dStrategy(canvas: CanvasNormalized, paintables: Paintables): RenderingStrategy;
|
|
91
103
|
|
|
@@ -97,9 +109,10 @@ type TextualContentStrategy = {
|
|
|
97
109
|
};
|
|
98
110
|
type TextContent = {
|
|
99
111
|
type: 'Text';
|
|
100
|
-
annotationId: string;
|
|
101
112
|
text: InternationalString;
|
|
102
113
|
target: SupportedTarget | null;
|
|
114
|
+
annotationId: string;
|
|
115
|
+
annotation: AnnotationNormalized;
|
|
103
116
|
};
|
|
104
117
|
declare function getTextualContentStrategy(canvas: CanvasNormalized, paintables: Paintables): RenderingStrategy;
|
|
105
118
|
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { ChoiceDescription, Paintables, SupportedTarget, ComplexChoice } from '@iiif/helpers';
|
|
2
2
|
import { ImageService, ExternalWebResource, InternationalString } from '@iiif/presentation-3';
|
|
3
|
-
import { AnnotationPageNormalized, CanvasNormalized } from '@iiif/presentation-3-normalized';
|
|
3
|
+
import { AnnotationNormalized, AnnotationPageNormalized, CanvasNormalized } from '@iiif/presentation-3-normalized';
|
|
4
4
|
import { BoxSelector, TemporalBoxSelector, TemporalSelector } from '@iiif/helpers/annotation-targets';
|
|
5
5
|
import { Emitter } from 'mitt';
|
|
6
6
|
|
|
7
7
|
type ImageWithOptionalService = {
|
|
8
8
|
id: string;
|
|
9
9
|
annotationId: string;
|
|
10
|
+
annotation: AnnotationNormalized;
|
|
10
11
|
type: 'Image';
|
|
11
12
|
service?: ImageService;
|
|
12
13
|
width?: number;
|
|
@@ -21,6 +22,7 @@ type ImageWithOptionalService = {
|
|
|
21
22
|
type SingleAudio = {
|
|
22
23
|
type: 'Sound';
|
|
23
24
|
annotationId: string;
|
|
25
|
+
annotation: AnnotationNormalized;
|
|
24
26
|
url: string;
|
|
25
27
|
format: string;
|
|
26
28
|
duration: number;
|
|
@@ -33,6 +35,7 @@ type SingleAudio = {
|
|
|
33
35
|
type SingleYouTubeVideo = {
|
|
34
36
|
type: 'VideoYouTube';
|
|
35
37
|
annotationId: string;
|
|
38
|
+
annotation: AnnotationNormalized;
|
|
36
39
|
url: string;
|
|
37
40
|
youTubeId: string;
|
|
38
41
|
duration: number;
|
|
@@ -42,6 +45,7 @@ type SingleYouTubeVideo = {
|
|
|
42
45
|
type SingleVideo = {
|
|
43
46
|
type: 'Video';
|
|
44
47
|
annotationId: string;
|
|
48
|
+
annotation: AnnotationNormalized;
|
|
45
49
|
url: string;
|
|
46
50
|
format: string;
|
|
47
51
|
duration: number;
|
|
@@ -70,7 +74,13 @@ type ImageServiceLoaderType = (imageService: any | undefined, { height, width }:
|
|
|
70
74
|
height: number;
|
|
71
75
|
width: number;
|
|
72
76
|
}) => ImageService | undefined;
|
|
73
|
-
declare function useLoadImageService(): readonly [ImageServiceLoaderType, Record<string,
|
|
77
|
+
declare function useLoadImageService(): readonly [ImageServiceLoaderType, Record<string, {
|
|
78
|
+
status: "error" | "loading" | "done";
|
|
79
|
+
service: ImageService | null;
|
|
80
|
+
error?: boolean | undefined;
|
|
81
|
+
errorMesage?: string | undefined;
|
|
82
|
+
real?: boolean | undefined;
|
|
83
|
+
}>];
|
|
74
84
|
|
|
75
85
|
type SingleImageStrategy = {
|
|
76
86
|
type: 'images';
|
|
@@ -86,6 +96,8 @@ type Single3DModelStrategy = {
|
|
|
86
96
|
model: ExternalWebResource;
|
|
87
97
|
choice?: ChoiceDescription;
|
|
88
98
|
annotations?: AnnotationPageDescription;
|
|
99
|
+
annotation: AnnotationNormalized;
|
|
100
|
+
annotationId: string;
|
|
89
101
|
};
|
|
90
102
|
declare function get3dStrategy(canvas: CanvasNormalized, paintables: Paintables): RenderingStrategy;
|
|
91
103
|
|
|
@@ -97,9 +109,10 @@ type TextualContentStrategy = {
|
|
|
97
109
|
};
|
|
98
110
|
type TextContent = {
|
|
99
111
|
type: 'Text';
|
|
100
|
-
annotationId: string;
|
|
101
112
|
text: InternationalString;
|
|
102
113
|
target: SupportedTarget | null;
|
|
114
|
+
annotationId: string;
|
|
115
|
+
annotation: AnnotationNormalized;
|
|
103
116
|
};
|
|
104
117
|
declare function getTextualContentStrategy(canvas: CanvasNormalized, paintables: Paintables): RenderingStrategy;
|
|
105
118
|
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { m as UseRenderingStrategy, U as UnknownStrategy, R as RenderingStrategy, d as ImageServiceLoaderType } from './useRenderingStrategy-BiuSDiXu.js';
|
|
2
|
+
import { CanvasNormalized } from '@iiif/presentation-3-normalized';
|
|
3
|
+
import { Paintables } from '@iiif/helpers/painting-annotations';
|
|
4
|
+
import * as _iiif_helpers_vault from '@iiif/helpers/vault';
|
|
5
|
+
import { ContentResource, W3CAnnotationTarget, PointSelector } from '@iiif/presentation-3';
|
|
6
|
+
import { TemporalBoxSelector, BoxSelector, SupportedTarget } from '@iiif/helpers';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Parse specific resource.
|
|
10
|
+
*
|
|
11
|
+
* This could be expanded to support pulling out more from the specific resource.
|
|
12
|
+
*
|
|
13
|
+
* @param resource
|
|
14
|
+
*/
|
|
15
|
+
declare function parseSpecificResource(resource: ContentResource): any[];
|
|
16
|
+
declare function getParsedTargetSelector(canvas: CanvasNormalized, target: W3CAnnotationTarget | W3CAnnotationTarget[]): [TemporalBoxSelector | BoxSelector | PointSelector | null, SupportedTarget['source']];
|
|
17
|
+
declare const emptyActions: {
|
|
18
|
+
makeChoice: () => void;
|
|
19
|
+
};
|
|
20
|
+
declare const unknownResponse: UseRenderingStrategy[0];
|
|
21
|
+
declare const unsupportedStrategy: (reason: string) => UnknownStrategy;
|
|
22
|
+
declare const emptyStrategy: (width: number, height: number) => UseRenderingStrategy[0];
|
|
23
|
+
|
|
24
|
+
type CompatVault = {
|
|
25
|
+
get: _iiif_helpers_vault.Vault['get'];
|
|
26
|
+
setMetaValue: _iiif_helpers_vault.Vault['setMetaValue'];
|
|
27
|
+
getResourceMeta: _iiif_helpers_vault.Vault['getResourceMeta'];
|
|
28
|
+
load: _iiif_helpers_vault.Vault['load'];
|
|
29
|
+
requestStatus: _iiif_helpers_vault.Vault['requestStatus'];
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
interface GetRenderStrategyOptions {
|
|
33
|
+
canvas: CanvasNormalized | null | undefined;
|
|
34
|
+
paintables: Paintables;
|
|
35
|
+
supports: string[];
|
|
36
|
+
loadImageService: ImageServiceLoaderType;
|
|
37
|
+
vault?: CompatVault;
|
|
38
|
+
}
|
|
39
|
+
declare function getRenderingStrategy({ canvas, paintables, supports, loadImageService, vault, }: GetRenderStrategyOptions): RenderingStrategy;
|
|
40
|
+
|
|
41
|
+
export { type CompatVault as C, unsupportedStrategy as a, emptyStrategy as b, getRenderingStrategy as c, emptyActions as e, getParsedTargetSelector as g, parseSpecificResource as p, unknownResponse as u };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { m as UseRenderingStrategy, U as UnknownStrategy, R as RenderingStrategy, d as ImageServiceLoaderType } from './useRenderingStrategy-BiuSDiXu.cjs';
|
|
2
|
+
import { CanvasNormalized } from '@iiif/presentation-3-normalized';
|
|
3
|
+
import { Paintables } from '@iiif/helpers/painting-annotations';
|
|
4
|
+
import * as _iiif_helpers_vault from '@iiif/helpers/vault';
|
|
5
|
+
import { ContentResource, W3CAnnotationTarget, PointSelector } from '@iiif/presentation-3';
|
|
6
|
+
import { TemporalBoxSelector, BoxSelector, SupportedTarget } from '@iiif/helpers';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Parse specific resource.
|
|
10
|
+
*
|
|
11
|
+
* This could be expanded to support pulling out more from the specific resource.
|
|
12
|
+
*
|
|
13
|
+
* @param resource
|
|
14
|
+
*/
|
|
15
|
+
declare function parseSpecificResource(resource: ContentResource): any[];
|
|
16
|
+
declare function getParsedTargetSelector(canvas: CanvasNormalized, target: W3CAnnotationTarget | W3CAnnotationTarget[]): [TemporalBoxSelector | BoxSelector | PointSelector | null, SupportedTarget['source']];
|
|
17
|
+
declare const emptyActions: {
|
|
18
|
+
makeChoice: () => void;
|
|
19
|
+
};
|
|
20
|
+
declare const unknownResponse: UseRenderingStrategy[0];
|
|
21
|
+
declare const unsupportedStrategy: (reason: string) => UnknownStrategy;
|
|
22
|
+
declare const emptyStrategy: (width: number, height: number) => UseRenderingStrategy[0];
|
|
23
|
+
|
|
24
|
+
type CompatVault = {
|
|
25
|
+
get: _iiif_helpers_vault.Vault['get'];
|
|
26
|
+
setMetaValue: _iiif_helpers_vault.Vault['setMetaValue'];
|
|
27
|
+
getResourceMeta: _iiif_helpers_vault.Vault['getResourceMeta'];
|
|
28
|
+
load: _iiif_helpers_vault.Vault['load'];
|
|
29
|
+
requestStatus: _iiif_helpers_vault.Vault['requestStatus'];
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
interface GetRenderStrategyOptions {
|
|
33
|
+
canvas: CanvasNormalized | null | undefined;
|
|
34
|
+
paintables: Paintables;
|
|
35
|
+
supports: string[];
|
|
36
|
+
loadImageService: ImageServiceLoaderType;
|
|
37
|
+
vault?: CompatVault;
|
|
38
|
+
}
|
|
39
|
+
declare function getRenderingStrategy({ canvas, paintables, supports, loadImageService, vault, }: GetRenderStrategyOptions): RenderingStrategy;
|
|
40
|
+
|
|
41
|
+
export { type CompatVault as C, unsupportedStrategy as a, emptyStrategy as b, getRenderingStrategy as c, emptyActions as e, getParsedTargetSelector as g, parseSpecificResource as p, unknownResponse as u };
|
package/dist/utils.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var v=Object.defineProperty;var
|
|
1
|
+
"use strict";var v=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var Y=Object.prototype.hasOwnProperty;var F=(e,o)=>{for(var r in o)v(e,r,{get:o[r],enumerable:!0})},q=(e,o,r,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of E(o))!Y.call(e,t)&&t!==r&&v(e,t,{get:()=>o[t],enumerable:!(i=L(o,t))||i.enumerable});return e};var G=e=>q(v({},"__esModule",{value:!0}),e);var J={};F(J,{emptyActions:()=>j,emptyStrategy:()=>R,getParsedTargetSelector:()=>S,getRenderingStrategy:()=>H,parseSpecificResource:()=>_,unknownResponse:()=>x,unsupportedStrategy:()=>p});module.exports=G(J);var k=require("@iiif/helpers");function _(e){return e.type==="SpecificResource"?[e.source,{selector:e.selector}]:[e,{selector:null}]}function S(e,o){let{selector:r,source:i}=(0,k.expandTarget)(o);if(i.id!==e.id)return[null,i];let t={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}};return[r?r.type==="TemporalSelector"?{type:"TemporalBoxSelector",temporal:r.temporal,spatial:t.spatial}:r:null,i]}var j={makeChoice:()=>{}},x={type:"unknown"},p=e=>({type:"unknown",reason:e,annotations:{pages:[]}}),R=(e,o)=>({type:"empty",width:e,height:o,annotations:{pages:[]},image:null,images:[]});var Q=["model/gltf-binary"];function z(e,o){let r=o.items[0],i=r.resource;return i.format?Q.indexOf(i.format)===-1?p(`3D format: ${i.format} is unsupported`):{type:"3d-model",model:i,annotationId:r.annotationId,annotation:r.annotation}:p("Unknown format")}function A(e,o){let r=o.items,i=r[0];if(r.length===0||!i)return p("No audio");if(!e.duration)return p("No duration on canvas");if(r.length>1)return p("Only one audio source supported");let t=i.resource;return t?"format"in t?{type:"media",media:{annotationId:i.annotationId,annotation:i.annotation,duration:e.duration,url:t.id,type:"Sound",target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:t.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},annotations:{pages:[]}}:p("Audio does not have format"):p("Unknown audio")}var B=require("@iiif/parser/image-3");var N=require("@iiif/helpers/annotation-targets");function C(e,o,r){let i=[];for(let t of o.items){let s=t.resource&&t.resource.type==="SpecificResource"?t.resource.source:t.resource;if(!s.id)return p("No resource Identifier");let m;if(s.service){let g=(0,B.getImageServices)(s);g[0]&&(m=r(g[0],e))}let y={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}},[d,a]=S(e,t.target),n=e.id?.split("?")[0]||"";if(!(a.id===e.id||decodeURIComponent(a.id||"")===(e.id||"")||a.id===n||decodeURIComponent(a.id||"")===n))continue;let l=t.resource.width&&t.resource.height?{type:"BoxSelector",spatial:{x:0,y:0,width:t.resource.width,height:t.resource.height}}:void 0,c=t.resource.type==="SpecificResource"?(0,N.expandTarget)(t.resource):null;if(t.selector){let g=(0,N.expandTarget)({type:"SpecificResource",source:t.resource,selector:t.selector});g&&(c=g)}let u=c&&c.selector&&(c.selector.type==="BoxSelector"||c.selector.type==="TemporalBoxSelector")?{type:"BoxSelector",spatial:{x:c.selector.spatial.x,y:c.selector.spatial.y,width:c.selector.spatial.width,height:c.selector.spatial.height}}:void 0;m&&!m.id&&(m.id=m["@id"]);let f={id:s.id,type:"Image",annotationId:t.annotationId,annotation:t.annotation,width:Number(d||u?s.width:e.width),height:Number(d||u?s.height:e.height),service:m,sizes:m&&m.sizes?m.sizes:s.width&&s.height?[{width:s.width,height:s.height}]:[],target:d&&d.type!=="PointSelector"?d:y,selector:u||{type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}}};i.push(f)}return{type:"images",image:i[0],images:i,choice:o.choice}}function D(e,o={},r){let i=e.language||r||"none";switch(e.type){case"TextualBody":{typeof e.value<"u"&&(o[i]=[e.value]);break}case"List":case"Composite":case"Choice":e.items&&e.items.forEach(t=>D(t,o,i))}return o}function I(e,o){let r=[];return o.items.forEach(i=>{if(i.resource){let[t]=S(e,i.target);r.push({type:"Text",annotationId:i.annotationId,annotation:i.annotation,text:D(i.resource),target:t})}}),{type:"textual-content",items:r}}var b=require("@iiif/helpers"),$=/^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\/)|(?:(?:watch)?\?vi?=|&vi?=))([^#&?]*).*/;function V(e,o,r){let i=o.items.filter(u=>u.type==="video"),t=i[0],s=!1;if(e.duration||(s=!0),i.length>1||!t)return p("Only one video source supported");let m=i[0]?.resource,y=!!(m.service||[]).find(u=>(u.profile||"").includes("youtube.com"));if(!y&&s)return p("Video does not have duration");if(!m)return p("Unknown video");if((!m.format||m.format==="text/html")&&!y)return p("Video does not have format");let d=[],a=r.get(e.annotations||[]);for(let u of a){let f=r.get(u.items||[]);for(let g of f)if((g.motivation?Array.isArray(g.motivation||"")?g.motivation:[g.motivation]:[]).includes("supplementing")){let O=r.get(g.body||[]);for(let U of O){let h=U;if(h.type==="Choice")for(let W of h.items){let T=r.get(W);T.format==="text/vtt"&&d.push({id:T.id,type:"Text",format:"text/vtt",label:T.label,language:T.language})}else h.format==="text/vtt"&&d.push({id:h.id,type:"Text",format:"text/vtt",label:h.label,language:h.language})}}}let n={annotationId:t.annotationId,annotation:t.annotation,duration:e.duration,url:m.id,type:"Video",target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:m.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},l=(0,b.expandTarget)(t.target);l.selector&&l.selector.type==="TemporalBoxSelector"&&(n.target=l.selector);let{selector:c}=(0,b.parseSelector)(t.selector);if(c===null){let u=n.target.temporal.startTime,g=(n.target.temporal.endTime||e.duration)-u;n.selector={type:"TemporalSelector",temporal:{startTime:0,endTime:g}}}else c.type==="TemporalSelector"&&(n.selector=c);if(y){n.type="VideoYouTube";let u=m.id.match($);if(!u[1])return p("Video is not known youtube video");n.youTubeId=u[1]}return{type:"media",media:n,annotations:{pages:[]},captions:d}}function M(e,o,r,i){let t={type:"complex-timeline",items:[],keyframes:[],duration:e.duration||0},s={type:"complex-choice",items:[]};function m(a){a.choice&&(a.choice.type==="complex-choice"?s.items.push(...a.choice.items):s.items.push(a.choice))}for(let a of o.items){if(a.type==="image"){let n=C(e,{choice:null,allChoices:null,types:["image"],items:[a]},r);if(n.type==="images"){m(n),t.items.push(n.image);let l={id:n.image.annotationId,type:"enter",resourceType:"image",time:n.image.target?.temporal?.startTime||0};t.keyframes.push(l);let c={id:n.image.annotationId,type:"exit",resourceType:"image",time:n.image.target?.temporal?.endTime||e.duration||0};t.keyframes.push(c)}}if(a.type==="textualbody"){let n=I(e,{choice:null,allChoices:null,types:["textualbody"],items:[a]});if(n.type==="textual-content"){m(n);let l=n.items[0];t.items.push(l);let c=l.target,u={id:l.annotationId,type:"enter",resourceType:"text",time:c.temporal?.startTime||0};t.keyframes.push(u);let f={id:l.annotationId,type:"exit",resourceType:"text",time:c.temporal?.endTime||e.duration||0};t.keyframes.push(f)}}if(a.type==="video"){let n=V(e,{choice:null,allChoices:null,types:["video"],items:[a]},i);if(n.type==="media"){m(n);let l=n.media;t.items.push(l);let c={id:l.annotationId,type:"enter",resourceType:"video",time:l.target?.temporal?.startTime||0};t.keyframes.push(c);let u={id:l.annotationId,type:"exit",resourceType:"video",time:l.target?.temporal?.endTime||e.duration||0};t.keyframes.push(u)}}}t.keyframes.sort((a,n)=>a.time-n.time);let y=[],d=[];for(let a of t.keyframes){if(a.resourceType==="image"||a.resourceType==="text"){d.push(a);continue}if(a.type==="enter"){y.length===0&&(a.isPrime=!0),y.push(a),d.push(a);continue}if(a.type==="exit"&&(d.push(a),y=y.filter(n=>n.id!==a.id),y.length!==0)){let n=y[0],l={id:n.id,type:"change",isPrime:!0,resourceType:n.resourceType,time:a.time};d.push(l)}}return t.keyframes=d,s.items.length&&(t.choice=s),t}var w={},P={get(e){return e},setMetaValue([e,o,r],i){let t=P.getResourceMeta(e,o),s=t?t[r]:void 0,m=typeof i=="function"?i(s):i;w[e]={...w[e]||{},[o]:{...(w[e]||{})[o]||{},[r]:m}}},getResourceMeta:(e,o)=>{let r=w[e];if(r)return o?r[o]:r},async load(e){let o=typeof e=="string"?e:e.id;return fetch(o).then(r=>r.json())},requestStatus(e){}};function H({canvas:e,paintables:o,supports:r,loadImageService:i,vault:t=P}){if(!e)return x;if(o.types.length===0)return r.indexOf("empty")!==-1?R(e.width,e.height):x;if(o.types.length!==1)if(o.types.length===2&&o.types.indexOf("text")!==-1)o.types=o.types.filter(m=>m!=="text");else return r.indexOf("complex-timeline")===-1?p("Complex timeline not supported"):M(e,o,i,t);let s=o.types[0];return s==="image"?r.indexOf("images")===-1?p("Image not supported"):C(e,o,i):s==="Model"||s==="model"?r.indexOf("3d-model")===-1?p("3D not supported"):z(e,o):s==="textualbody"?r.indexOf("textual-content")===-1?p("Textual content not supported"):I(e,o):s==="sound"||s==="audio"?r.indexOf("media")===-1?p("Media not supported"):A(e,o):s==="video"?r.indexOf("media")===-1?p("Media not supported"):V(e,o,t):x}
|
package/dist/utils.d.cts
CHANGED
|
@@ -1,34 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
1
|
+
export { e as emptyActions, b as emptyStrategy, g as getParsedTargetSelector, c as getRenderingStrategy, p as parseSpecificResource, u as unknownResponse, a as unsupportedStrategy } from './utils-CvRzsfRK.cjs';
|
|
2
|
+
import './useRenderingStrategy-BiuSDiXu.cjs';
|
|
3
|
+
import '@iiif/helpers';
|
|
4
|
+
import '@iiif/presentation-3';
|
|
5
|
+
import '@iiif/presentation-3-normalized';
|
|
6
6
|
import '@iiif/helpers/annotation-targets';
|
|
7
7
|
import 'mitt';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* Parse specific resource.
|
|
11
|
-
*
|
|
12
|
-
* This could be expanded to support pulling out more from the specific resource.
|
|
13
|
-
*
|
|
14
|
-
* @param resource
|
|
15
|
-
*/
|
|
16
|
-
declare function parseSpecificResource(resource: ContentResource): any[];
|
|
17
|
-
declare function getParsedTargetSelector(canvas: CanvasNormalized, target: W3CAnnotationTarget | W3CAnnotationTarget[]): [TemporalBoxSelector | BoxSelector | PointSelector | null, SupportedTarget['source']];
|
|
18
|
-
declare const emptyActions: {
|
|
19
|
-
makeChoice: () => void;
|
|
20
|
-
};
|
|
21
|
-
declare const unknownResponse: UseRenderingStrategy[0];
|
|
22
|
-
declare const unsupportedStrategy: (reason: string) => UnknownStrategy;
|
|
23
|
-
declare const emptyStrategy: (width: number, height: number) => UseRenderingStrategy[0];
|
|
24
|
-
|
|
25
|
-
interface GetRenderStrategyOptions {
|
|
26
|
-
canvas: CanvasNormalized | null | undefined;
|
|
27
|
-
paintables: Paintables;
|
|
28
|
-
supports: string[];
|
|
29
|
-
loadImageService: ImageServiceLoaderType;
|
|
30
|
-
vault: Vault;
|
|
31
|
-
}
|
|
32
|
-
declare function getRenderingStrategy({ canvas, paintables, supports, loadImageService, vault, }: GetRenderStrategyOptions): RenderingStrategy;
|
|
33
|
-
|
|
34
|
-
export { emptyActions, emptyStrategy, getParsedTargetSelector, getRenderingStrategy, parseSpecificResource, unknownResponse, unsupportedStrategy };
|
|
8
|
+
import '@iiif/helpers/painting-annotations';
|
|
9
|
+
import '@iiif/helpers/vault';
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,34 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
1
|
+
export { e as emptyActions, b as emptyStrategy, g as getParsedTargetSelector, c as getRenderingStrategy, p as parseSpecificResource, u as unknownResponse, a as unsupportedStrategy } from './utils-C-h4SU3S.js';
|
|
2
|
+
import './useRenderingStrategy-BiuSDiXu.js';
|
|
3
|
+
import '@iiif/helpers';
|
|
4
|
+
import '@iiif/presentation-3';
|
|
5
|
+
import '@iiif/presentation-3-normalized';
|
|
6
6
|
import '@iiif/helpers/annotation-targets';
|
|
7
7
|
import 'mitt';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* Parse specific resource.
|
|
11
|
-
*
|
|
12
|
-
* This could be expanded to support pulling out more from the specific resource.
|
|
13
|
-
*
|
|
14
|
-
* @param resource
|
|
15
|
-
*/
|
|
16
|
-
declare function parseSpecificResource(resource: ContentResource): any[];
|
|
17
|
-
declare function getParsedTargetSelector(canvas: CanvasNormalized, target: W3CAnnotationTarget | W3CAnnotationTarget[]): [TemporalBoxSelector | BoxSelector | PointSelector | null, SupportedTarget['source']];
|
|
18
|
-
declare const emptyActions: {
|
|
19
|
-
makeChoice: () => void;
|
|
20
|
-
};
|
|
21
|
-
declare const unknownResponse: UseRenderingStrategy[0];
|
|
22
|
-
declare const unsupportedStrategy: (reason: string) => UnknownStrategy;
|
|
23
|
-
declare const emptyStrategy: (width: number, height: number) => UseRenderingStrategy[0];
|
|
24
|
-
|
|
25
|
-
interface GetRenderStrategyOptions {
|
|
26
|
-
canvas: CanvasNormalized | null | undefined;
|
|
27
|
-
paintables: Paintables;
|
|
28
|
-
supports: string[];
|
|
29
|
-
loadImageService: ImageServiceLoaderType;
|
|
30
|
-
vault: Vault;
|
|
31
|
-
}
|
|
32
|
-
declare function getRenderingStrategy({ canvas, paintables, supports, loadImageService, vault, }: GetRenderStrategyOptions): RenderingStrategy;
|
|
33
|
-
|
|
34
|
-
export { emptyActions, emptyStrategy, getParsedTargetSelector, getRenderingStrategy, parseSpecificResource, unknownResponse, unsupportedStrategy };
|
|
8
|
+
import '@iiif/helpers/painting-annotations';
|
|
9
|
+
import '@iiif/helpers/vault';
|
package/dist/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as o,b as r,c as e,d as f,e as m,f as p,l as t}from"./chunk-
|
|
1
|
+
import{a as o,b as r,c as e,d as f,e as m,f as p,l as t}from"./chunk-XNDN34SQ.js";export{e as emptyActions,p as emptyStrategy,r as getParsedTargetSelector,t as getRenderingStrategy,o as parseSpecificResource,f as unknownResponse,m as unsupportedStrategy};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-iiif-vault",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -58,10 +58,9 @@
|
|
|
58
58
|
"react-reconciler": "0.29"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@atlas-viewer/atlas": "^2.2.
|
|
62
|
-
"@
|
|
63
|
-
"@iiif/
|
|
64
|
-
"@iiif/parser": "^2.1.2",
|
|
61
|
+
"@atlas-viewer/atlas": "^2.2.9",
|
|
62
|
+
"@iiif/helpers": "^1.3.1",
|
|
63
|
+
"@iiif/parser": "^2.1.7",
|
|
65
64
|
"@iiif/presentation-2": "^1.0.4",
|
|
66
65
|
"@iiif/presentation-3": "^2.2.3",
|
|
67
66
|
"@iiif/presentation-3-normalized": "^0.9.7",
|
package/dist/chunk-7KUFVAUD.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import{c as yt,l as xt}from"./chunk-CCTBCLBV.js";import{forwardRef as nr,useImperativeHandle as Ui}from"react";import ln,{useCallback as rt,useMemo as dn,useState as Te}from"react";import{AtlasAuto as Ao,ModeContext as Po}from"@atlas-viewer/atlas";import{ErrorBoundary as bo}from"react-error-boundary";import{useContext as D,useMemo as to}from"react";import ir,{useContext as ar,useMemo as sr}from"react";import{jsx as cr}from"react/jsx-runtime";var ur={collection:void 0,manifest:void 0,range:void 0,canvas:void 0,annotation:void 0,annotationPage:void 0},Ae=ir.createContext(ur),F=()=>ar(Ae);function Y({value:e,children:n}){let t=F(),r=sr(()=>({...t,...e}),[e,t]);return cr(Ae.Provider,{value:r,children:n})}import lr,{useState as dr}from"react";import{Vault as St,globalVault as mr}from"@iiif/helpers/vault";import{jsx as Ct}from"react/jsx-runtime";var W=lr.createContext({vault:null,setVaultInstance:e=>{}});function ee({vault:e,vaultOptions:n,useGlobal:t,resources:r,children:o}){let[s,i]=dr(()=>e||(t?mr(n):n?new St(n):new St));return Ct(W.Provider,{value:{vault:s,setVaultInstance:i},children:Ct(Y,{value:r||{},children:o})})}import{useContext as jr}from"react";import{createContext as Kr,useMemo as Yr}from"react";import{globalVault as fr}from"@iiif/helpers/vault";import{useContext as pr}from"react";function te(e){let n=pr(W);return e||(n&&n.vault?n.vault:fr())}import{useEffect as gr,useMemo as vr,useState as _e}from"react";function At(e,{noCache:n=!1}={}){let t=typeof e=="string"?e:e.id,r=te(),[o,s]=_e(t),[i,a]=_e(void 0),u=vr(()=>r.get(t,{skipSelfReturn:!0})||void 0,[t,r]),[l,c]=_e(u);return gr(()=>{(async()=>{try{let d=u&&!n?u:await r.load(t),v=d?d.id||d["@id"]:null;d&&o!==v&&s(v),c(d)}catch(d){a(d)}})()},[t,n]),{isLoaded:!!l,id:o,requestId:t,error:i,resource:l,cached:!!(l&&l===u)}}function Pt(e,n){let{id:t,isLoaded:r,error:o,resource:s,requestId:i,cached:a}=At(e,n);return{id:t,isLoaded:r,error:o,manifest:s,requestId:i,cached:a}}import{jsx as hr}from"react/jsx-runtime";function bt({manifest:e,children:n}){return hr(Y,{value:{manifest:e},children:n})}import{jsx as yr}from"react/jsx-runtime";function _({canvas:e,children:n}){return yr(Y,{value:{canvas:e},children:n})}import{useContext as Ar}from"react";import Pr from"react";import{useContext as xr}from"react";var R=()=>{let{vault:e}=xr(W);if(e===null)throw new Error("Vault not found. Ensure you have your provider set up correctly.");return e};import{useEffect as Sr,useState as Cr}from"react";function T(e,n=[]){let t=R(),[r,o]=Cr(()=>e(t.getState(),t));return Sr(()=>t.subscribe(s=>e(s,t),s=>{o(s)},!1),n),r}var ne=Pr.createContext([]);function Pe(){let e=Ar(ne);return T(n=>e.map(t=>n.iiif.entities.Canvas[t]).filter(Boolean),[e])}import{useMemo as br}from"react";function V(e={},n=[]){let{id:t,selector:r}=e,o=F(),s=R(),i=t||o.manifest,a=T(u=>i?u.iiif.entities.Manifest[i]:void 0,[i]);return br(()=>{if(a)return r?r(a):a},[a,r,...n])}import{jsx as Rr}from"react/jsx-runtime";function Rt({range:e,children:n}){return Rr(Y,{value:{range:e},children:n})}function Tr(e,n){for(let t of n.items){if(t.type==="Canvas")return t;if(t.type==="SpecificResource")return t.source;if(t.type==="Range"){let r=Tr(e,e.get(t));if(r)return r}}return null}function je(e,n){let t=[];for(let r of n.items)if(r.type==="SpecificResource"&&r.source?.type==="Canvas"&&(r.source.id.indexOf("#")!==-1?t.push({id:r.source.id.split("#")[0],type:"Canvas"}):t.push(r.source)),r.type==="Range"&&t.push(...je(e,e.get(r))),r.type==="SpecificResource"){let o=typeof r.source=="string"?r.source:r.source.id;t.push({id:o,type:"Canvas"})}return t}function Ua(e,n,t){for(let r of n.structures){let o=Tt(e,e.get(r),t);if(o)return o}return null}function Tt(e,n,t){for(let r of n.items){let o=r?.source?.id?.split("#")[0];if(r.type==="SpecificResource"&&r.source===t||r.type==="SpecificResource"&&r.source?.type==="Canvas"&&t===o)return n;if(r.type==="Range"){let s=Tt(e,e.get(r),t);if(s)return s}}return null}function _a(e,n,t,r=!1){let o=n.behavior,s=t?e.get(t):null;if(!s)return[];let i=s.behavior,a=r?!1:o.includes("paged"),u=a?!1:o.includes("continuous"),l=a||u?!1:o.includes("individuals"),c=i.includes("facing-pages"),d=i.includes("non-paged");if(c||d||l||r)return[{id:s.id,type:"Canvas"}];let[v,x]=Ke(e,n);if(u)return v;let h=v.findIndex(g=>g.id===t);if(h===-1)return[];for(let g of x)if(g.includes(h))return g.map(A=>v[A]);return[{id:s.id,type:"Canvas"}]}function Ke(e,n,{disablePaging:t,skipNonPaged:r}={}){let o=n.behavior,s=o.includes("paged"),i=s?!1:o.includes("continuous"),a=s||i?!1:o.includes("individuals"),u=n.type==="Manifest"?n.items:je(e,n);if(i)return[u,[u.map((h,g)=>g)]];if(a||!s||t)return[u,u.map((h,g)=>[g])];let l=[],c=[],d=()=>{c.length&&(l.push([...c]),c=[])},v=0,x=!1;for(let h=0;h<u.length;h++){let g=e.get(u[h]);if(g.behavior.includes("non-paged")){h===v&&v++,r||(d(),l.push([h]),d());continue}if(h===v||g.behavior.includes("facing-pages")){c.length&&(x=!0),d(),l.push([h]),d();continue}if(c.push(h),x){d(),x=!1;continue}c.length>1&&d()}return c.length&&d(),[u,l]}import{useCallback as be,useMemo as Mr,useRef as wr,useState as Er}from"react";import{useMemo as Ir}from"react";function It(e={},n=[]){let{id:t,selector:r}=e,o=F(),s=t||o.range,i=T(a=>s?a.iiif.entities.Range[s]:void 0,[s]);return Ir(()=>{if(i)return r?r(i):i},[i,r,...n])}function Mt({startCanvas:e,disablePaging:n}){let t=R(),r=V(),o=It(),[s,i]=Er(void 0),a=o||r;if(!a)throw new Error("Nothing selected");let[u,l]=Mr(()=>Ke(t,a,{disablePaging:n}),[t,a,n]),c=wr(l);if(c.current!==l){let A=c.current[s][0],p=l.findIndex(S=>S.includes(A));c.current=l,i(p)}let d=be(g=>{let A=l.findIndex(p=>p.includes(g));i(A===-1?0:A)},[u,l]),v=be(g=>{let A=u.findIndex(p=>p.id===g);A!==-1?d(A):i(0)},[u,l]),x=be(()=>{i(g=>g>=l.length-1?g:g+1)},[l]),h=be(()=>{i(g=>g<=0?0:g-1)},[l]);return typeof s>"u"&&(e?v(e):i(0)),{visibleItems:l[s]?.map(g=>u[g].id)||[],cursor:s,items:u,sequence:l,hasPrevious:s>0,hasNext:s<l.length-1,setSequenceIndex:i,setCanvasIndex:d,setCanvasId:v,next:x,previous:h}}import{createContext as We,useContext as $t,useEffect as kr,useMemo as Nr}from"react";import{useStore as fe}from"zustand";import{createStore as Et}from"zustand/vanilla";function rs(e){let n=e.service||e.services||[];for(let t of n)if(t.type==="AuthProbeService2")return!0;return!1}function $(e,n,t){let r=n.findIndex(i=>i.service.id===e);if(r===-1)return n;let o=[...n],s=t(o[r]);return s===o[r]?n:(o[r]=s,o)}var Vt=()=>Et((e,n)=>({currentAuth:-1,authItems:[],login:()=>{let t=n().authItems[n().currentAuth];if(!t||t.isPending||t.isLoggedIn)return;if(t.type!=="active")throw new Error("Cannot login to non-active service");let r=t.service.service.find(o=>o.type==="AuthAccessTokenService2");if(!r)throw new Error("Token service not found");e(()=>({authItems:$(t.id,n().authItems,o=>({...o,isPending:!0}))})),wt(t.service).then(()=>{Ye(r).then(o=>{let s=o.expiresIn,i=Date.now()+s*1e3;e(()=>({authItems:$(t.id,n().authItems,a=>({...a,isLoggedIn:!0,isPending:!1,session:{token:o.accessToken,expires:i}}))}))}).catch(o=>{e(()=>({authItems:$(t.id,n().authItems,s=>({...s,isLoggedIn:!1,isPending:!1,error:o.message}))}))})})},logout:()=>{let t=n().authItems[n().currentAuth];if(!t||t.isPending||!t.isLoggedIn)return;if(t.type!=="active")throw new Error("Cannot logout of non-active service");let r=t.service.service.find(i=>i.type==="AuthLogoutService2");if(!r)return;let o=`${r.id}?origin=${Lt()}`,s=window.open(o);e(()=>({authItems:$(t.id,n().authItems,i=>({...i,isLoggedIn:!1,session:null,isPending:!1}))}))},nextAuth:()=>{let t=n().authItems.length,r=n().currentAuth+1;r>=t||e(()=>({currentAuth:r}))},previousAuth:()=>{let t=n().currentAuth-1;t<0||e(()=>({currentAuth:t}))},setAuth:t=>{t!==-1&&(t<0||t>=n().authItems.length)||e(()=>({currentAuth:t}))},addService:(t,r)=>{if(!t.service)return;let o=t.service.find(a=>a.type==="AuthAccessTokenService2"),s=t;if(n().authItems.find(a=>a.service.id===t.id)){e(()=>({authItems:$(t.id,n().authItems,a=>({...a,instances:a.instances+1}))}));return}if(e(()=>({currentAuth:s.profile==="active"?0:n().currentAuth,authItems:[{id:t.id,type:t.profile,service:t,probeId:r,canAuthenticate:!0,instances:1,isPending:!1,isLoggedIn:!1,session:null},...n().authItems]})),t.profile==="external"){if(!o)throw new Error("Token service not found");Ye(o).then(a=>{e(()=>({authItems:$(t.id,n().authItems,u=>({...u,isLoggedIn:!0,isPending:!1,session:{token:a.accessToken,expires:a.expiresIn}}))}))}).catch(a=>{e(()=>({authItems:$(t.id,n().authItems,u=>({...u,isLoggedIn:!1,isPending:!1,canAuthenticate:!1,error:a.message}))}))})}if(t.profile==="kiosk"){if(!o)throw new Error("Token service not found");e(()=>({authItems:$(t.id,n().authItems,a=>({...a,isPending:!0}))})),wt(s).then(()=>{Ye(o).then(a=>{e(()=>({authItems:$(t.id,n().authItems,u=>({...u,isLoggedIn:!0,isPending:!1,session:{token:a.accessToken,expires:a.expiresIn}}))}))}).catch(a=>{e(()=>({authItems:$(t.id,n().authItems,u=>({...u,isLoggedIn:!1,isPending:!1,error:a.message}))}))})})}t.profile},removeService:(t,r)=>{let o=n().currentAuth===n().authItems.findIndex(i=>i.service.id===t.id),s=n().currentAuth;if(o){let i=n().authItems.find(u=>u.service.id===t.id);i&&i.instances>1||(s=n().authItems.findIndex(l=>l.service.id!==t.id&&l.instances>0))}e(()=>({authItems:$(t.id,n().authItems,i=>({...i,instances:i.instances-1})),currentAuth:s}))}})),kt=(e,n)=>Et((t,r)=>({service:e,status:e?"unknown":"success",shouldRedirect:!1,redirectResource:null,shouldSubstitute:!1,substituteResource:null,error:null,errorHeading:null,errorNote:null,shouldDisplayResource:!1,token:n||null,async probe(){if(!r().service)return;let o=r().service?.id;if(!o){t({status:"error",error:"Service ID not found",errorHeading:{en:["Service ID not found"]}});return}t({status:"probing"});let s=r().token;try{let i=await fetch(o,{headers:s?{Authorization:`Bearer ${r().token}`,Accept:"application/json"}:{Accept:"application/json"}}).then(a=>a.json());if(i.status===200)t({status:"success",shouldDisplayResource:!0,error:null,errorHeading:null,errorNote:null,shouldSubstitute:!1,shouldRedirect:!1});else if(i.status<400&&i.status>=300){if(!i.location)throw new Error("Redirect location not found");t({status:"error",shouldDisplayResource:!1,shouldRedirect:!0,redirectResource:i.location||null})}else if(i.status===401)t({status:"error",shouldDisplayResource:!1,shouldRedirect:!1,shouldSubstitute:!!i.substitute,substituteResource:i.substitute||null,error:"Unauthorized",errorHeading:i.heading||{en:["Unauthorized"]},errorNote:i.note||null});else throw new Error("Unknown error")}catch(i){t({status:"error",error:i.message,errorHeading:{en:["Unknown error"]}})}},setToken(o){t({token:o})}}));function Nt(e){let n=e.service||e.services||[],t={hasAuth:!1,services:{}};for(let r of n)if(r.type==="AuthProbeService2"){t.services.probe=r,t.hasAuth=!0;let o=r.service.filter(s=>s.type==="AuthAccessService2");o[0]&&(t.services.access=o[0])}return t}async function Ye(e,{strict:n=!0}={}){return new Promise((t,r)=>{let o=Math.random().toString(36).substring(7),s=`${e.id}?messageId=${o}&origin=${window.location.origin}`,i=l=>{let c=l.data;if(c.messageId===o){if(n&&c.type!=="AuthAccessToken2"){a(),r("Invalid response, expected type=AuthAccessToken2");return}if(!c.accessToken){a(),r("Invalid response, expected accessToken");return}a(),t(c)}},a=()=>window.removeEventListener("message",i),u=document.createElement("iframe");u.src=s,u.style.display="none",document.body.appendChild(u),window.addEventListener("message",i)})}function Lt(e){let n=window.location;if(e){let t=document.createElement("a");return t.href=e,t.protocol+"//"+t.hostname+(t.port?":"+t.port:"")}return n.protocol+"//"+n.hostname+(n.port?":"+n.port:"")}async function wt(e){let n=`${e.id}?origin=${Lt()}`,t=window.open(n);if(!t)throw new Error("Failed to open window");return new Promise((r,o)=>{let s=setInterval(()=>{t.closed&&(clearInterval(s),r())},500)})}import{useEffect as zt,useMemo as Ot}from"react";import{useStore as Vr}from"zustand";function Ht(e){let n=Ot(()=>Nt(e),[e]),t=Ft(n.services.access?.id),r=Ot(()=>kt(n.services.probe,t),[n.services.probe]),o=Vr(r);return zt(()=>{o.status==="unknown"&&!t&&o.probe()},[n.services.probe,o.status]),zt(()=>{t&&(o.setToken(t),o.probe())},[t]),[e,o,n.hasAuth]}import{jsx as Re}from"react/jsx-runtime";var re=We(null),Lr=We(null);Lr.displayName="CurrentAuth";var zr=We(null);zr.displayName="AuthActions";function Dt({children:e}){let n=Nr(()=>Vt(),[]);return Re(re.Provider,{value:n,children:e})}function Ut(){return!!$t(re)}function pe(){let e=$t(re);if(!e)throw new Error("useAuthActions must be used within a AuthProvider");return e}function Or(){let e=pe();return fe(e,t=>({login:t.login,logout:t.logout,nextAuth:t.nextAuth,previousAuth:t.previousAuth,setAuth:t.setAuth,addService:t.addService,removeService:t.removeService}))}function Cs(){let e=pe();return fe(e,n=>n)}function Hr(e){let n=pe();return fe(n,r=>r.authItems.find(o=>o.service.id===e))}function Ft(e){let n=pe();return fe(n,r=>r.authItems.find(o=>o.id===e)?.session?.token)}function As(e){let n=pe();return fe(n,r=>{let o=r.authItems.find(s=>s.service.id===e);return!o||!o.isLoggedIn||!o.session?null:o.session?.token||null})}function Fr(e){let n=Or(),t=Hr(e.service.id);return kr(()=>(n?.addService(e.service,e.probeId),()=>{n?.removeService(e.service,e.probeId)}),[e.service]),t?(t.error||!t.isLoggedIn,e.children):null}function Qe(){return null}function qt(e){let[n,t,r]=Ht(e.resource),o=e.fallbackComponent||Qe,s=e.loadingComponent||Qe,i=e.errorComponent||Qe,a=t.service,u=null;if(!r||!a)return e.children(n);let l=a.service.filter(c=>c.type==="AuthAccessService2");t.status==="error"&&(u=Re(i,{resource:e.resource,error:t.error||"",heading:t.errorHeading,note:t.errorNote,extra:e.extra})),(t.status==="unknown"||t.status==="probing")&&(u=Re(s,{})),t.status==="success"&&(u=e.children(n));for(let c of l)u=Re(Fr,{service:c,probeId:a.id,children:u},c.id);return u}import{createContext as qr,useContext as Vs,useMemo as Br}from"react";import{createStore as $r}from"zustand/vanilla";var Dr=e=>e.id||e["@id"];function Ur(e){return(Array.isArray(e.service)?e.service:[e.service]).find(t=>t.profile==="http://iiif.io/api/search/0/autocomplete"||t.profile==="http://iiif.io/api/search/1/autocomplete"||t.profile==="AutoCompleteService1")}var Bt=e=>{let n;typeof e=="string"?n={"@context":"http://iiif.io/api/search/1/context.json",profile:"http://iiif.io/api/search/1/search","@id":e,id:e,service:[]}:n=e;let t=n?Dr(n):void 0,r=null;return $r((o,s)=>({service:n,resources:[],lastQuery:{},loading:!1,error:!1,highlight:null,hasSearch:!!n,hasAutocomplete:n?!!Ur(n):!1,errorMessage:"",search(i,a={}){if(!t)throw new Error("No search service found.");r&&!r.signal.aborted&&r.abort(),r=new AbortController;let u=new URLSearchParams;i.q&&u.set("q",i.q),i.motivation&&u.set("motivation",i.motivation),i.date&&u.set("date",i.date),i.user&&u.set("user",i.user),o({loading:!0}),fetch(`${t}?${u.toString()}`,{signal:r.signal,headers:{"Content-Type":"application/json",Accept:"application/json",...a.headers||{}}}).then(async l=>{if(!r?.signal.aborted)if(l.ok){let c=await l.json();o({resources:c.resources,error:!1,errorMessage:""})}else o({resources:[],error:!0,errorMessage:l.statusText})})},clearSearch(){o({resources:[],error:!1,errorMessage:""})},highlightResult(i){let a=s().resources.find(u=>u["@id"]===i);o({highlight:a})},nextResult(){let i=s().resources,a=s().highlight;if(!a){o({highlight:i[0]||null});return}let u=i.findIndex(l=>l["@id"]===a["@id"]);if(u===-1){o({highlight:i[0]||null});return}o({highlight:i[u+1]||i[0]||null})},previousResult(){let i=s().resources,a=s().highlight;if(!a){o({highlight:i[i.length-1]||null});return}let u=i.findIndex(l=>l["@id"]===a["@id"]);if(u===-1){o({highlight:i[i.length-1]||null});return}if(u===0){o({highlight:i[i.length-1]||null});return}o({highlight:i[u-1]||i[i.length-1]||null})}}))};import{useStore as Os}from"zustand";function _t(){let e=V();return e?e.service.find(n=>n.profile==="SearchService1"||n.profile==="http://iiif.io/api/search/1/search"):void 0}import{jsx as Ge}from"react/jsx-runtime";var oe=qr(null);oe.displayName="Search";function jt(e){let n=_t();return e.store?Ge(oe.Provider,{value:e.store,children:e.children}):Ge(_r,{service:n,children:e.children})}function _r({service:e,children:n}){let t=Br(()=>Bt(e),[e]);return Ge(oe.Provider,{value:t,children:n})}import{jsx as O}from"react/jsx-runtime";var ge=()=>{},ve=Kr({setCurrentCanvasId:ge,setCurrentCanvasIndex:ge,nextCanvas:ge,previousCanvas:ge,items:[],sequence:[],setSequenceIndex:ge,currentSequenceIndex:0,hasNext:!1,hasPrevious:!1});function Qr(e){let n=V(),{cursor:t,visibleItems:r,next:o,sequence:s,items:i,setCanvasIndex:a,setCanvasId:u,previous:l,setSequenceIndex:c,hasNext:d,hasPrevious:v}=Mt({startCanvas:e.startCanvas,disablePaging:e.pagingEnabled===!1}),x=Yr(()=>({sequence:s,items:i,setCurrentCanvasId:u,nextCanvas:o,previousCanvas:l,totalCanvases:i.length,setCurrentCanvasIndex:a,setSequenceIndex:c,currentSequenceIndex:t,hasNext:d,hasPrevious:v}),[s,i,u,o,l,i,a,c,t]);return n?r.length===0?null:O(ve.Provider,{value:x,children:O(ne.Provider,{value:r,children:O(_,{canvas:r[0],children:e.children})})}):(console.warn("The manifest passed to the provider is not a valid IIIF manifest."),O("div",{children:"Sorry, something went wrong."}))}function Kt(e){let n=te(e.vault),t=Pt(e.manifest);if(!t)return console.warn("The manifest passed to the provider is not a valid IIIF manifest."),O("div",{children:"Sorry, something went wrong."});if(t.error)return O("div",{children:t.error.toString()});if(!t.isLoaded)return O("div",{children:"Loading..."});let r=O(Qr,{...e,children:e.children});return O(ee,{vault:n,children:O(bt,{manifest:t.id,children:O(Dt,{children:O(jt,{children:e.rangeId?O(Rt,{range:e.rangeId,children:r}):r})})})})}function Yt(){return jr(ve)}import Wr from"react";import{createContext as Gr,useMemo as Zr}from"react";import Jr from"mitt";import{jsx as eo}from"react/jsx-runtime";var Xr=Jr(),ie=Gr({emitter:Xr});ie.displayName="Events";function Qt(){return Wr.useContext(ie).emitter}function fu({emitter:e,children:n}){return eo(ie.Provider,{value:Zr(()=>({emitter:e}),[e]),children:n})}import no from"react";import{jsx as j}from"react/jsx-runtime";var Ze=no.createContext({});function Wt(){let e=D(Ze),n=Object.keys(e),t={};for(let r of n)e[r].Provider&&(t[r]={value:D(e[r]),Provider:e[r].Provider});return t}function ro(e){let n=Object.keys(e),t=e.children;for(let r of n){if(r==="children")continue;let{value:o,Provider:s}=e[r];t=j(s,{value:o,children:t})}return t}function Iu(e){let n=D(Ze),t=to(()=>({...n,...e.providers}),[e.providers]);return j(Ze.Provider,{value:t,children:e.children})}function Gt(){return{VaultContext:D(W),ResourceContext:D(Ae),SimpleViewerReactContext:D(ve),VisibleCanvasReactContext:D(ne),AuthRContext:D(re),SearchReactContext:D(oe),ReactEventContext:D(ie)}}function Zt(e){return j(ee,{vault:e.bridge.VaultContext.vault||void 0,resources:e.bridge.ResourceContext,children:j(ne.Provider,{value:e.bridge.VisibleCanvasReactContext,children:j(ve.Provider,{value:e.bridge.SimpleViewerReactContext,children:j(ie.Provider,{value:e.bridge.ReactEventContext,children:j(re.Provider,{value:e.bridge.AuthRContext,children:j(oe.Provider,{value:e.bridge.SearchReactContext,children:e.custom?j(ro,{...e.custom,children:e.children}):e.children})})})})})})}import{createContext as uo,useContext as co,useMemo as lo}from"react";import{useCallback as Xt,useLayoutEffect as io,useMemo as ao,useRef as so}from"react";import{entityActions as Je}from"@iiif/helpers/vault/actions";import{useMemo as oo}from"react";function Jt(){let n=R().getStore();return oo(()=>t=>n.dispatch(t),[n])}function en(e){return typeof e!="string"&&e&&e.bindToVault}function tn(){let e=R(),n=so([]),t=Jt(),r=ao(()=>`vault://annotation-page/${new Date().getTime()}/${Math.round(Math.random()*1e9).toString(16)}`,[]);io(()=>{let a={id:r,type:"AnnotationPage",behavior:[],label:null,thumbnail:[],summary:null,requiredStatement:null,metadata:[],rights:null,provider:[],items:[],seeAlso:[],homepage:[],rendering:[],service:[]};t(Je.importEntities({entities:{AnnotationPage:{[a.id]:a}}}))},[r]);let o=T(a=>r&&a.iiif.entities.AnnotationPage[r]||null,[r]),s=Xt((a,u)=>{if(r){if(en(a)){let d=a;d.__vault||d.bindToVault(e),a=typeof d.source=="string"?d.source:d.source.id,n.current[a]=d}else typeof a!="string"&&(a=a.id);let l=e.get({id:r,type:"AnnotationPage"}),c=e.get({id:a,type:"Annotation"});l&&c&&(l.items.find(d=>d.id===c.id)||t(Je.addReference({id:r,type:"AnnotationPage",key:"items",reference:{id:a,type:"Annotation"},index:u})))}},[r]),i=Xt(a=>{r&&(en(a)?a=typeof a.source=="string"?a.source:a.source.id:typeof a!="string"&&(a=a.id),n.current[a]&&n.current[a].beforeRemove(),e.get({id:r,type:"AnnotationPage"})&&t(Je.removeReference({id:r,type:"AnnotationPage",key:"items",reference:{id:a,type:"Annotation"}})))},[r]);return[o,{addAnnotation:s,removeAnnotation:i}]}import{jsx as mo}from"react/jsx-runtime";var nn=uo(null);function rn(){let e=co(nn);return[e.fullPage,{addAnnotation:e.addAnnotation,removeAnnotation:e.removeAnnotation}]}function on({children:e}){let[n,{addAnnotation:t,removeAnnotation:r}]=tn();return mo(nn.Provider,{value:lo(()=>({fullPage:n,addAnnotation:t,removeAnnotation:r}),[n]),children:e})}import{jsx as Xe,jsxs as fo}from"react/jsx-runtime";function an({width:e,style:n,height:t,error:r,resetErrorBoundary:o}){return fo("div",{style:{width:e,height:t,minHeight:500,...n||{},background:"#f9f9f9"},children:[Xe("h3",{children:"Error occurred"}),Xe("p",{children:r.message}),Xe("button",{onClick:o,children:"Reset"})]})}import{createContext as po,useContext as go}from"react";var he=po(null);function sn(){return go(he)}import{createContext as un,useContext as vo,useEffect as ho}from"react";var et=un(()=>{}),tt=un(()=>{});function H(e,n,t,r,o=[]){let s=vo(e==="portal"?tt:et);ho(()=>(e!=="none"&&s(n,t,r),()=>{s(n,null)}),[n,e,s,...o])}import{createContext as xo,useContext as So,useEffect as Co}from"react";import{useMemo as yo}from"react";function M(e={},n=[]){let{id:t,selector:r}=e,o=F(),s=t||o.canvas,i=T(a=>s?a.iiif.entities.Canvas[s]:void 0,[s]);return yo(()=>{if(i)return r?r(i):i},[i,r,...n])}var nt=xo(()=>{});function cn(e){let n=M(),t=So(nt);Co(()=>n&&n.id?(t(n.id,e),()=>t(n.id,-1)):()=>{},[n,e])}import{Fragment as Ro,jsx as k,jsxs as To}from"react/jsx-runtime";function mn({children:e,errorFallback:n,outerContainerProps:t={},worldScale:r,...o}){let[s,i]=Te(),a=Wt(),u=Gt(),l=n||an,[c,d]=Te({}),v=Object.entries(c),[x,h]=Te({}),g=Object.entries(x),[A,p]=Te({}),S=dn(()=>r||Math.max(...Object.values(A)),[A]),m=dn(()=>({maxOverZoom:S||1,...o.runtimeOptions||{}}),[S,o.runtimeOptions]),P=rt((C,y)=>{p(E=>{if(y===-1){let{[C]:Z,...f}=E;return f}return{...E,[C]:y}})},[]),b=rt((C,y,E)=>{d(({[C]:Z,...f})=>y?{...f,[C]:{element:y,props:E}}:f)},[]),I=rt((C,y,E)=>{h(({[C]:Z,...f})=>y?{...f,[C]:{element:y,props:E}}:f)},[]);return To(bo,{resetKeys:[],fallbackRender:C=>k(l,{...o,...C}),children:[k(Ao,{...o,containerProps:{style:{position:"relative"},...o.containerProps||{}},htmlChildren:k(Ro,{children:v.map(([C,{element:y,props:E}])=>k(ln.Fragment,{children:k(y,{...E||{}})},C))}),onCreated:C=>{i(C),o.onCreated&&o.onCreated(C)},runtimeOptions:m,children:k(he.Provider,{value:s,children:k(nt.Provider,{value:P,children:k(et.Provider,{value:b,children:k(tt.Provider,{value:I,children:k(Zt,{bridge:u,custom:a,children:k(Po.Provider,{value:o.mode||"explore",children:k(on,{children:e})})})})})})})}),k("div",{children:g.map(([C,{element:y,props:E}])=>k(ln.Fragment,{children:k(y,{...E||{}})},C))})]})}import{mergeStyles as ko,RegionHighlight as No}from"@atlas-viewer/atlas";import{useMemo as fn}from"react";import{createEventsHelper as Io}from"@iiif/helpers/events";function Ie(e,n){let t=R(),r=fn(()=>Io(t),[t]),o=T(()=>e&&e.id?t.getResourceMeta(e.id,"eventManager"):null,[e]);return fn(()=>e?r.getListenersAsProps(e,n):{},[o,e,t,n])}import{useMemo as Mo}from"react";import{createStylesHelper as wo}from"@iiif/helpers/styles";function ae(e,n){let t=R(),r=Mo(()=>wo(t),[t]);return T(()=>{if(!e)return null;let o=r.getAppliedStyles(e.id);return o?n?o[n]:o:void 0},[e,n])}import{useMemo as Lo}from"react";import{useMemo as Eo}from"react";import{expandTarget as Vo}from"@iiif/helpers/annotation-targets";function Me(e={},n=[]){let{id:t,selector:r}=e,o=F(),s=R(),i=t||o.annotation,a=T(l=>i?l.iiif.entities.Annotation[i]:void 0,[i]),u=T(l=>a&&a.body?a.body.map(c=>c?c.type==="SpecificResource"?{...c,source:s.get(c)}:c?l.iiif.entities[c.type][c.id]:null:null).filter(Boolean):[],[a]);return Eo(()=>{if(!a)return;let l={...a,body:u,target:Vo(a.target,{typeMap:s.getState().iiif.mapping})};return r?r(l):l},[a,r,u,...n])}import{jsx as zo}from"react/jsx-runtime";var we=({id:e,style:n,className:t,interactive:r})=>{let o=Me({id:e}),s=ae(o,"atlas"),i=ae(o,"html"),a=Ie(o,["atlas"]),u=M(),l=Lo(()=>ko(n,s),[n,s]);return u&&o&&o.target&&o.target.selector&&o.target.selector.type==="BoxSelector"&&o.target.source&&(o.target.source.id===u.id||o.target.source===u.id)?zo(No,{id:o.id,isEditing:!0,region:o.target.selector.spatial,style:l,className:i?.className||t,interactive:!!(i?.href||r),href:i?.href||null,title:i?.title||null,hrefTarget:i?.target||null,onClick:()=>{},...a}):null};import{Fragment as Ho}from"react";import{useMemo as Oo}from"react";function pn(e={},n=[]){let{id:t,selector:r}=e,o=F(),s=t||o.annotationPage,i=T(a=>s?a.iiif.entities.AnnotationPage[s]:void 0,[s]);return Oo(()=>{if(i)return r?r(i):i},[i,...n])}import{jsx as gn}from"react/jsx-runtime";var ye=({className:e,page:n})=>{let t=pn({id:n.id})||n,r=ae(t,"atlas"),o=ae(t,"html");return T(s=>t.id?s.iiif.entities.AnnotationPage[t.id]:null,[]),gn(Ho,{children:t.items?.map(s=>gn(we,{id:s.id,style:r,className:o?.className||e},s.id))})};import{createStylesHelper as Fi}from"@iiif/helpers/styles";import{Fragment as Rn,useMemo as Wo}from"react";import{HTMLPortal as jo,TileSet as Pn}from"@atlas-viewer/atlas";import se,{useMemo as ot}from"react";import{jsx as U}from"react/jsx-runtime";var hn=se.createContext("en"),yn=se.createContext({}),xn=se.createContext(null);function cl(e){return U(yn.Provider,{value:e.translations,children:e.children})}function ll(e){return U(hn.Provider,{value:e.language,children:e.children})}function dl(e){return U(xn.Provider,{value:e.convert,children:e.children})}function Sn(){return se.useContext(xn)}function it(){return se.useContext(hn)}function Cn(){return se.useContext(yn)}function vn(e){return e.indexOf("-")!==-1?e.slice(0,e.indexOf("-")):e}function Fo({as:e,language:n,children:t,viewingDirection:r,...o}){let s=it();return ot(()=>vn(s)===vn(n),[s,n])?e?U(e,{...o,children:t}):U("span",{...o,children:t}):e?U(e,{...o,lang:n,dir:r,children:t}):U("span",{...o,lang:n,dir:r,children:t})}function An(e,n,t){if(n.length===0)return;if(n.length===1)return n[0];if(n.indexOf(e)!==-1)return e;let r=e.indexOf("-")!==-1?e.slice(0,e.indexOf("-")):null;if(r&&n.indexOf(r)!==-1)return r;for(let o of t)if(n.indexOf(o)!==-1)return o;return n.indexOf("none")!==-1?"none":n.indexOf("@none")!==-1?"@none":n[0]}var $o=(e,n=[])=>{let t=it();return ot(()=>{let r=e();return An(t,r,[])},[t,...n])};function G(e,n,t,r){return n?t?t(e[n]||n,r||"none"):e[n]||n:""}function Do(e,n,t=`
|
|
2
|
-
`,r={}){let o=Sn(),s=$o(()=>Object.keys(e||{}),[e]);return[ot(()=>{if(!e)return G(r,n,o)||"";if(typeof e=="string")return G(r,e,o);let i=s?e[s]:void 0;return i?typeof i=="string"?i:i.map(a=>G(r,a,o,s)).join(t):""},[s,n,e]),s]}function ml(){let e=it(),n=Cn(),t=Sn();return function(o,s="",i=`
|
|
3
|
-
`,a=n){let u=Object.keys(o||{}),l=An(e,u,[]);if(!o)return G(a,s,t)||"";if(typeof o=="string")return G(a,o,t);let c=l?o[l]:void 0;return c?typeof c=="string"?G(a,c,t,l):c.map(d=>G(a,d,t,l)).join(typeof i<"u"?i:`
|
|
4
|
-
`):""}}function xe({as:e,defaultText:n,enableDangerouslySetInnerHTML:t,children:r,separator:o,...s}){let i=Cn(),[a,u]=Do(r,n,o,i);return u?U(Fo,{...s,as:e,language:u,title:t?void 0:a,dangerouslySetInnerHTML:t?{__html:a}:void 0,children:t?void 0:a}):e?U(e,{...s,children:a}):U("span",{...s,title:t?void 0:a,dangerouslySetInnerHTML:t?{__html:a}:void 0,children:t?void 0:a})}import{canonicalServiceUrl as Ko}from"@iiif/parser/image-3";import Uo,{useContext as qo}from"react";import{ImageServiceLoader as Bo}from"@atlas-viewer/iiif-image-api";var _o=Uo.createContext(new Bo);function ue(){return qo(_o)}import{jsx as K,jsxs as Qo}from"react/jsx-runtime";function Yo({resource:e,heading:n,note:t,extra:r}){return r?K(jo,{target:{x:0,y:0,width:r.target?.spatial.width,height:r.target?.spatial.height},backgroundColor:"#333",relative:!0,children:K("div",{style:{display:"flex",alignContent:"center",justifyContent:"center",alignItems:"center",height:"100%",width:"100%",background:"#444",color:"#BBB"},children:Qo("div",{children:[K(xe,{children:n||"Not authorised"}),t&&K("p",{children:K(xe,{children:t})}),K("p",{children:e.id||e["@id"]||"unknown"})]})})}):null}function bn({image:e,thumbnail:n,crop:t,enableSizes:r,enableThumbnail:o,renderOptions:s}){let i=Ut(),a=ue(),u=e.service?Ko(e.service.id||e.service["@id"]||""):void 0,l=u?!!a.imageServices[u]:void 0,c=n&&n.type==="fixed"&&n.id&&!n.id.includes("/full/full/")&&!n.id.includes("/max/")?n:void 0;if(l===!1)return null;if(!i){let d=e.service,v=d.width||e.width||0,x=d.height||e.height||0;return K(Pn,{enableThumbnail:o,renderOptions:s,tiles:{id:d.id||d["@id"]||"unknown",height:x,width:v,imageService:d,thumbnail:c},enableSizes:r,x:0,y:0,width:e.target?.spatial.width,height:e.target?.spatial.height,crop:t})}return K(qt,{resource:e.service,errorComponent:Yo,extra:e,children:d=>{let v=d.width||e.width||0,x=d.height||e.height||0;return K(Pn,{enableThumbnail:o,renderOptions:s,tiles:{id:d.id||d["@id"]||"unknown",height:x,width:v,imageService:d,thumbnail:c},enableSizes:r,x:0,y:0,width:e.target?.spatial.width,height:e.target?.spatial.height,crop:t})}},e.id)}import{jsx as at,jsxs as Tn}from"react/jsx-runtime";function ce({id:e,image:n,thumbnail:t,isStatic:r,x:o=0,y:s=0,children:i,selector:a,onClick:u,enableSizes:l}){let c=Wo(()=>{if(!(!a||a.spatial.x===0&&a.spatial.y===0))return a.spatial},[a]);return at("world-object",{x:o+n.target.spatial.x,y:s+n.target.spatial.y,width:n.target.spatial.width,height:n.target.spatial.height,onClick:u,children:n.service?Tn(Rn,{children:[at(bn,{image:n,thumbnail:t,crop:c,enableSizes:l}),i]},"service"):Tn(Rn,{children:[at("world-image",{onClick:u,uri:n.id,target:{x:0,y:0,width:n.target.spatial.width,height:n.target.spatial.height},display:n.width&&n.height?{width:n.width,height:n.height}:void 0,crop:c}),i]},"no-service")},e+(n.service?"server":"no-service"))}import{Fragment as $i,useEffect as er,useLayoutEffect as Di,useMemo as tr}from"react";import{useEffect as On,useMemo as Hn}from"react";import{useCallback as wn,useMemo as Zo}from"react";function Go(e,n){let t=e?.iiif?.meta[n];return t?t.annotationPageManager:null}function In(e,n){return T(t=>{let r=[];if(!e)return r;let o=Object.keys(t.iiif.entities.AnnotationPage);for(let s of o)if(!n||n.indexOf(s)!==-1){let i=Go(t,s);i&&i.views&&i.views[e]&&r.push(s)}return r},[e,n])}function Mn({canvas:e,manifest:n,all:t,canvases:r}){let o=[];if(n)for(let s of n.annotations)o.indexOf(s.id)===-1&&o.push(s.id);if(t){if(r&&r.length)for(let s of r)for(let i of s.annotations)o.indexOf(i.id)===-1&&o.push(i.id)}else if(e)for(let s of e.annotations)o.indexOf(s.id)===-1&&o.push(s.id);return o}function Jo(e,n){let t=e?.iiif?.meta[n];return t?t.annotationPageManager:null}function En(e,n={}){let t=R(),r=V(),o=M(),s=Pe(),i=Zo(()=>Mn({all:n.all,manifest:r,canvas:o,canvases:s}),[n.all,o,s,r]),a=In(e,n.all?void 0:i),u=wn(c=>{e&&t.setMetaValue([c,"annotationPageManager","views"],d=>d&&!d[e]?d:{...d||{},[e]:!1})},[e,t]),l=wn((c,d={})=>{if(!e)return;let v=t.getState(),x=[];if(d?.deselectOthers){let h=Object.keys(v.iiif.entities.AnnotationPage);for(let g of h){let A=Jo(v,g);A&&A.views&&A.views[e]&&x.push(g)}}for(let h of x)u(h);t.setMetaValue([c,"annotationPageManager","views"],h=>h&&h[e]?h:{...h||{},[e]:!0})},[e,u,t]);return{availablePageIds:i,enabledPageIds:a,setPageEnabled:l,setPageDisabled:u}}function Vn(e,n){return T((t,r)=>r.get(e.map(o=>({id:o,type:n}))),[e,n])}import{useCallback as Xo,useEffect as ei,useRef as ti,useState as ni}from"react";function kn(){let e=ue(),[n,t]=ni({}),r=ti(!1);return ei(()=>()=>{r.current=!0},[]),[Xo((s,{height:i,width:a})=>{if(s){let u=s.id||s["@id"],l=e.loadServiceSync({id:u,width:s.width||a,height:s.height||i,source:s});l?s=l:n[u]||(r.current||t(c=>({...c,[u]:"loading"})),e.loadService({id:u,width:s.width||a,height:s.height||i}).then(()=>{r.current||t(c=>({...c,[u]:"done"}))}))}return s},[e,n]),n]}import{useCallback as ri,useMemo as Ln,useState as oi}from"react";function Nn(e={}){let n=Me(),t=M(e.canvasId?{id:e.canvasId}:void 0);return T((r,o)=>{if(!t)return[];if(n&&e.enableSingleAnnotation)return[n];let s=o.get(t.items),i=[];for(let a of s)i.push(...o.get(a.items));return i},[t])}import{createPaintingAnnotationsHelper as ii}from"@iiif/helpers/painting-annotations";function zn(e,n=[]){let t=R(),r=Ln(()=>ii(t),[]),o=Nn({enableSingleAnnotation:e?.enableSingleAnnotation}),[s,i]=oi(e?.defaultChoices||[]),a=Ln(()=>r.getPaintables(o,s),[t,o,s,...n]),l={makeChoice:ri((c,{deselectOthers:d=!0,deselect:v=!1}={})=>{a.choice&&i(x=>{if(v){let g=x.filter(A=>A!==c);if(g.length===0){let A=a.items[0].resource.id;return A?[A]:[]}return g}if(d)return[c];let h=[...x];if(h.length===0&&a.items.length){let g=a.items[0].resource.id;g&&h.push(g)}return x.indexOf(c)!==-1?x:[...x,c]})},[a.choice])};return[a,l]}function Fn(e){let n=V(),t=M(),r=R(),o=Qt(),s=e?.emitter||o,[i,a]=kn(),{enabledPageIds:u}=En(e?.annotationPageManagerId||n?.id||t?.id,{all:!1}),l=Vn(u,"AnnotationPage"),c=e?.strategies||["empty","images","media","textual-content","complex-timeline"],[d,v]=zn(e,[a]);On(()=>{let h=g=>{v.makeChoice(g.choiceId,{deselectOthers:g.deselectOthers,deselect:g.deselect})};return s.on("make-choice",h),()=>{s.off("make-choice",h)}},[]);let x=Hn(()=>xt({canvas:t,paintables:d,supports:c,loadImageService:i,vault:r}),[t,d,r,v.makeChoice]);return On(()=>{let h=d.allChoices,g={canvasId:t?.id,manifestId:n?.id};h&&s.emit("choice-change",{choice:h,partOf:g})},[t?.id,d.allChoices]),Hn(()=>x.type==="unknown"?[x,yt]:[{...x,annotations:{pages:l}},v],[x,l])}import{useEffect as si,useMemo as ui,useRef as ci,useState as li}from"react";import{useEffect as ai}from"react";var $n=(e,n=[])=>{let t=R();ai(()=>{e(t)},[t,...n])};import{createThumbnailHelper as di}from"@iiif/helpers/thumbnail";function Ee(e,n,{canvasId:t,manifestId:r}={}){let o=R(),s=ue(),i=ui(()=>di(o,{imageServiceLoader:s}),[o,s]),[a,u]=li(),l=V(r?{id:r}:void 0),c=M(t?{id:t}:void 0),d=c||l,v=ci(!1);if(si(()=>(v.current=!1,()=>{v.current=!0}),[]),!d)throw new Error("Must be called under a manifest or canvas context.");return $n(x=>{i.getBestThumbnailAtSize(d,e,n).then(h=>{h.best&&!v.current&&u(h.best)})},[d]),a}import{useCallback as q,useEffect as Dn,useReducer as mi,useRef as Ve}from"react";function fi(e){return{isMuted:!1,playRequested:!1,isPlaying:!1,isFinished:!1,volume:100,duration:e}}function pi(e,n){switch(n.type){case"FINISHED":return{...e,isFinished:!0,isPlaying:!1,playRequested:!1};case"PLAY_PAUSE":return{...e,isFinished:!1,isPlaying:!e.isPlaying};case"PLAY_REQUESTED":return{...e,isFinished:!1,playRequested:!0};case"PAUSE":return{...e,isPlaying:!1};case"PLAY":return{...e,isFinished:!1,playRequested:!1,isPlaying:!0};case"MUTE":return{...e,isMuted:!0};case"SET_VOLUME":return{...e,volume:n.volume,isMuted:n.volume===0};case"TOGGLE_MUTE":return{...e,isMuted:!e.isMuted};case"UNMUTE":return{...e,isMuted:!1}}return e}function st(e){let n=Math.round(e);return`${Math.floor(n/60)}:${`${n%60}`.padStart(2,"0")}`}function le(e){let[n,t]=mi(pi,fi(e.duration)),r=Ve(null),o=Ve(null),s=Ve(null),i=Ve(!1),a=q(()=>{o.current&&r.current&&(o.current.innerHTML=st(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,t(r.current.muted?{type:"MUTE"}:{type:"UNMUTE"})))},[e.duration]),u=q(()=>{r.current&&(t({type:"PLAY_REQUESTED"}),r.current.play().then(()=>{t({type:"PLAY"})}),a())},[a]),l=q(()=>{r.current&&(r.current.duration>0&&r.current.paused?u():c())},[a]),c=q(()=>{r.current&&(r.current.pause(),t({type:"PAUSE"}),a())},[a]),d=q(()=>{r.current&&(r.current.muted=!r.current.muted,t(r.current.muted?{type:"MUTE"}:{type:"UNMUTE"}))},[]),v=q(()=>{r.current&&(r.current.muted=!0,t({type:"MUTE"}))},[]),x=q(()=>{r.current&&(r.current.muted=!1,t({type:"UNMUTE"}))},[]),h=q(p=>{r.current&&(r.current.muted=!1,r.current.volume=p/100,t({type:"SET_VOLUME",volume:p}))},[]),g=q(p=>{r.current&&(r.current.currentTime=Math.max(0,Math.min(p*e.duration,e.duration)),a())},[]),A=q(p=>{if(r.current){let S=typeof p=="function"?p(r.current.currentTime):p;r.current.currentTime=Math.max(0,Math.min(S,e.duration)),a()}},[]);return Dn(()=>{let p=setInterval(()=>{a()},350);return()=>clearInterval(p)},[a,e.duration]),Dn(()=>{let p=()=>{t({type:"FINISHED"})},S=r.current;return S?.addEventListener("ended",p),()=>S?.removeEventListener("ended",p)},[]),[{element:r,currentTime:o,progress:s},n,{play:u,pause:c,playPause:l,mute:v,unmute:x,toggleMute:d,setVolume:h,setDurationPercent:g,setTime:A}]}import{createContext as ct,useContext as lt}from"react";import{jsx as ut}from"react/jsx-runtime";var Un=ct(null),qn=ct(null),Bn=ct(null);function kd(){let e=lt(Un);if(!e)throw new Error("Ctx not found");return e}function Nd(){let e=lt(qn);if(!e)throw new Error("Ctx not found");return e}function Ld(){let e=lt(Bn);if(!e)throw new Error("Ctx not found");return e}function ke({actions:e,state:n,children:t,currentTime:r,progress:o,element:s}){return ut(Bn.Provider,{value:{currentTime:r,progress:o,element:s},children:ut(qn.Provider,{value:e,children:ut(Un.Provider,{value:n,children:t})})})}import{useMemo as gi}from"react";import{expandTarget as vi}from"@iiif/helpers";function Ne(){let e=V(),n=M();return gi(()=>{if(!e||!n||!e.start)return null;let t=vi(e.start);return!t||t.source.id!==n.id||!t||!t.selector||t.selector.type!=="TemporalSelector"?null:t.selector.temporal},[e,n])}import{jsx as hi,jsxs as yi}from"react/jsx-runtime";function dt({media:e,startTime:n,children:t}){let[{element:r,currentTime:o,progress:s},i,a]=le({duration:e.duration}),u=n?`${e.url}#t=${n}`:e.url;return yi(ke,{state:i,actions:a,currentTime:o,progress:s,element:r,children:[hi("audio",{ref:r,src:u}),t]})}function Le({media:e,mediaControlsDeps:n,audioCopmonent:t=dt,children:r}){let o=Ne();return H("portal","audio",t,{media:e,startTime:o?o.startTime:null,children:r},[e,o,...n||[]]),null}import{jsx as _n,jsxs as xi}from"react/jsx-runtime";function mt({element:e,media:n,startTime:t,playPause:r,poster:o}){let s="div",i=t?`${n.url}#t=${t}`:n.url;return xi(s,{className:"video-container",part:"video-container",onClick:r,children:[_n("style",{children:`
|
|
5
|
-
.video-container {
|
|
6
|
-
position: absolute;
|
|
7
|
-
top: 0;
|
|
8
|
-
bottom: 0;
|
|
9
|
-
left: 0;
|
|
10
|
-
right: 0;
|
|
11
|
-
background: #000;
|
|
12
|
-
z-index: 13;
|
|
13
|
-
display: flex;
|
|
14
|
-
justify-content: center;
|
|
15
|
-
pointer-events: visible;
|
|
16
|
-
}
|
|
17
|
-
`}),_n("video",{poster:o,ref:e,src:i,style:{width:"100%",objectFit:"contain"}})]})}function ze({media:e,mediaControlsDeps:n,children:t,videoComponent:r=mt,captions:o}){let s=M(),i=Ne(),a=s&&s.placeholderCanvas&&s.placeholderCanvas.id||void 0,u=Ee({},!1,{canvasId:a}),[{element:l,currentTime:c,progress:d},v,x]=le({duration:e.duration});return H("overlay","video-element",r,{element:l,media:e,playPause:x.playPause,poster:u?.id,canvas:s,startTime:i?i.startTime:null,captions:o},[u]),H("portal","custom-controls",ke,{state:v,actions:x,currentTime:c,progress:d,element:l,children:t},[c,v,e,...n||[]]),null}import{Fragment as Si,jsx as ft,jsxs as Ci}from"react/jsx-runtime";function pt({model:e}){return Ci(Si,{children:[ft("style",{children:`
|
|
18
|
-
.model-container {
|
|
19
|
-
position: absolute;
|
|
20
|
-
top: 0;
|
|
21
|
-
bottom: 0;
|
|
22
|
-
left: 0;
|
|
23
|
-
right: 0;
|
|
24
|
-
background: #000;
|
|
25
|
-
z-index: 13;
|
|
26
|
-
display: flex;
|
|
27
|
-
justify-content: center;
|
|
28
|
-
pointer-events: visible;
|
|
29
|
-
}
|
|
30
|
-
`}),ft("div",{className:"model-container",children:ft("model-viewer",{"interaction-prompt":"none",style:{width:"100%",height:"100%"},"camera-controls":"","ar-status":"not-presenting",src:e.id})})]})}function Oe({model:e,name:n}){return H("overlay",`model-${n}`,pt,{model:e},[e]),null}import{jsx as Ai}from"react/jsx-runtime";function He({style:e}){let n=M();return!n||!n.height||!n.width?null:Ai("box",{interactive:!1,target:{x:0,y:0,width:Number(n.width),height:Number(n.height)},style:e})}import{jsx as jn}from"react/jsx-runtime";function Fe(e){let n=M();return!n||!n.placeholderCanvas?null:jn(_,{canvas:n.placeholderCanvas.id,children:jn(de,{renderViewerControls:e.renderViewerControls})})}import{useRef as Pi}from"react";import{jsx as Kn,jsxs as Ri}from"react/jsx-runtime";function bi({element:e,media:n,playPause:t}){let r=Pi(null);return n.youTubeId?Ri("div",{className:"video-container",part:"video-container",onClick:t,children:[Kn("style",{children:`
|
|
31
|
-
.video-container {
|
|
32
|
-
position: absolute;
|
|
33
|
-
top: 0;
|
|
34
|
-
bottom: 0;
|
|
35
|
-
left: 0;
|
|
36
|
-
right: 0;
|
|
37
|
-
background: #000;
|
|
38
|
-
z-index: 13;
|
|
39
|
-
display: flex;
|
|
40
|
-
justify-content: center;
|
|
41
|
-
pointer-events: visible;
|
|
42
|
-
}
|
|
43
|
-
.video-yt {
|
|
44
|
-
border: none;
|
|
45
|
-
width: 100%;
|
|
46
|
-
object-fit: contain;
|
|
47
|
-
}
|
|
48
|
-
`}),Kn("iframe",{className:"video-yt",ref:r,src:`https://www.youtube.com/embed/${n.youTubeId}?enablejsapi=1&origin=${window.location.host}`,referrerPolicy:"no-referrer",sandbox:"allow-scripts allow-same-origin allow-presentation"})]}):null}function Yn({media:e,mediaControlsDeps:n,children:t}){let[{element:r,currentTime:o,progress:s},i,a]=le({duration:e.duration});return H("overlay","video-element",bi,{element:r,media:e,playPause:a.playPause}),null}import{useLayoutEffect as Ni,useMemo as Li}from"react";import Ti from"mitt";import{createStore as Ii}from"zustand/vanilla";function Qn({currentKeyFrameIndex:e,keyframes:n,targetTime:t,currentTime:r}){if(r<=t){let o=n.findIndex(a=>a.time>t);if(o===-1)return[e,[]];let s={},i=n.slice(e,o);for(let a of i)a.type==="enter"&&(s[a.id]=a),a.type==="exit"&&(s[a.id]?delete s[a.id]:s[a.id]=a);return[o,Object.values(s)]}return[e,[]]}function Wn({complexTimeline:e,startTime:n=0}){let t=Ti(),r={},o={progress:null,currentTime:null},s=0,i=null,a=0,u=null;function l(){let S=A.getState().visibleElements,m=r,P=[],b=Object.keys(m);for(let I of b){let C=m[I],y=S[I];C&&y&&P.push(C)}return P}function c(){return Object.keys(r).map(S=>r[S])}function d(p){o.currentTime&&(o.currentTime.innerHTML=st(p),o.progress&&(o.progress.style.width=`${p/e.duration*100}%`))}let v=()=>{let p=A.getState(),S=p.currentPrime;if(!S)return;let m=r,P=p.visibleElements,b=Object.keys(m);for(let I of b){let C=m[I],y=P[I];if(C&&I!==S.id&&y){let E=a-y.time*1e3;Math.abs(a-y.time*1e3-C.currentTime*1e3)>300&&(C.currentTime=E/1e3)}}},x=(p=0)=>{let S=p-s,m=A.getState();if(m.isPlaying){let P=m.currentPrime;if(P){let y=r[P.id];y&&(y.paused?a+=S:a=(P.time+y.currentTime)*1e3)}else a+=S;let b=a/1e3;if(b>m.duration){A.getState().setTime(0),A.setState({isPlaying:!1}),h(),d(0);return}d(b);let[I,C]=Qn({currentTime:b,currentKeyFrameIndex:m.nextKeyframeIndex,keyframes:m.complexTimeline.keyframes,targetTime:b});C.length&&m.applyKeyframes(I,C)}s=p,i=requestAnimationFrame(x)},h=()=>{i&&cancelAnimationFrame(i)},g=(p,S)=>{},A=Ii((p,S)=>({complexTimeline:e,elements:{},visibleElements:{},isBuffering:!1,bufferMap:{},isMuted:!1,playRequested:!1,isPlaying:!1,isFinished:!1,isReady:!1,volume:100,duration:e.duration,clockStartRequests:0,clockStartTime:0,primeTime:0,currentPrime:null,clockRunning:!1,nextKeyframeIndex:0,startClock:()=>{S().clockRunning||(x(),u=setInterval(v,500)),p({clockRunning:!0,clockStartRequests:S().clockStartRequests+1})},applyKeyframes(m,P){let b=S(),I={...b.visibleElements},C=b.currentPrime;for(let y of P)y.type==="enter"&&(I[y.id]=y,t.emit("complex-timeline.enter",{id:y.id})),y.type==="exit"&&(I[y.id]=null,t.emit("complex-timeline.exit",{id:y.id})),y.isPrime&&(C=y);p({nextKeyframeIndex:m,visibleElements:I,currentPrime:C})},stopClock:()=>{let m=S().clockStartRequests;if(m!==0){if(m===1){h(),u&&clearInterval(u),p({clockRunning:!1,clockStartRequests:0});return}p({clockStartRequests:m-1})}},setElement:(m,P)=>{r[m]=P;let b=Object.keys(r),I=S().complexTimeline;g(P,m),I.items.filter(y=>y.type!=="Image"&&y.type!=="Text").every(y=>b.includes(y.annotationId))&&!S().isReady&&(t.emit("complex-timeline.ready",{complexTimeline:I}),p({isReady:!0}))},removeElement:m=>{delete r[m]},mute(){for(let m of c())m.muted=!0;p({isMuted:!0})},unmute(){for(let m of c())m.muted=!1;p({isMuted:!1})},play(){if(!S().isPlaying){for(let P of l())P.play();p({isPlaying:!0})}},pause(){if(S().isPlaying){for(let P of l())P.pause();p({isPlaying:!1})}},playPause(){let m=S();m.isPlaying?m.pause():m.play()},setDurationPercent(m){let b=S().duration*m;S().setTime(b)},setTime(m){let P=S(),b=a/1e3,I=typeof m=="function"?m(b):m,C=P.nextKeyframeIndex;if(b>I){p({visibleElements:{},currentPrime:null});let J=Object.keys(P.visibleElements);for(let z of J)t.emit("complex-timeline.exit",{id:z});b=0,C=0}let[y,E]=Qn({currentTime:b,currentKeyFrameIndex:C,keyframes:P.complexTimeline.keyframes,targetTime:I});P.applyKeyframes(y,E),a=I*1e3;let f=A.getState().visibleElements,qe=r,Ce=Object.keys(f);for(let J of Ce){let z=f[J];if(z){let X=qe[J];X&&(X.currentTime=(a-z.time*1e3)/1e3)}}d(I)},setVolume(m){for(let P of c())P.volume=Math.min(1,Math.max(0,m/100));p({volume:m})},toggleMute(){let m=S();m.isMuted?(m.unmute(),p({isMuted:!1})):(m.mute(),p({isMuted:!0}))},clearProgressElement(){o.progress=null},setProgressElement(m){o.progress=m},setCurrentTimeElement(m){o.currentTime=m},clearCurrentTimeElement(){o.currentTime=null}}));return t.on("complex-timeline.enter",p=>{let S=A.getState(),m=p.id,P=r[m];P&&S.isPlaying&&P.play()}),t.on("complex-timeline.exit",p=>{let S=A.getState(),m=p.id,P=r[m];P&&(P.currentTime=0,P.pause())}),A.getState().setTime(n),{store:A,emitter:t}}import{HTMLPortal as zi}from"@atlas-viewer/atlas";import{useStore as Jn}from"zustand";import{createContext as Mi,useContext as wi}from"react";import{useStore as Ei}from"zustand";import{jsx as Vi}from"react/jsx-runtime";var gt=Mi(null);gt.displayName="ComplexTimeline";function Gn({children:e,store:n}){return Vi(gt.Provider,{value:n,children:e})}function Mm(e){let n=wi(gt);if(!n)throw new Error("useComplexTimeline must be used within a ComplexTimelineProvider");return Ei(n,e)}import{HTMLPortal as ki}from"@atlas-viewer/atlas";import{Fragment as Zn,jsx as Se}from"react/jsx-runtime";function $e({strategy:e,onClickPaintingAnnotation:n}){return Se(Zn,{children:e.items.map((t,r)=>Se(Zn,{children:Se(ki,{onClick:n?o=>{o.stopPropagation(),n(t.annotationId,t,o)}:void 0,target:t.target?.spatial||void 0,children:Se("div",{"data-textual-content":!0,children:Se(xe,{enableDangerouslySetInnerHTML:!0,children:t.text})})},r)}))})}import{Fragment as Oi,jsx as De,jsxs as Hi}from"react/jsx-runtime";function Xn({strategy:e,children:n}){let{store:t}=Li(()=>Wn({complexTimeline:e}),[e]),r=Jn(t,i=>i.isReady),o=Jn(t,i=>i.visibleElements);function s(i){return a=>{a&&t.getState().setElement(i,a)}}return Ni(()=>{if(r){let{startClock:i,stopClock:a}=t.getState();return i(),()=>{a()}}},[e,r]),H("portal","custom-controls",Gn,{store:t,children:n},[r]),Hi(Oi,{children:[e.items.map(i=>i.type!=="Image"||!o[i.annotationId]?null:De(ce,{image:i,id:i.annotationId},i.id)),e.items.map((i,a)=>i.type!=="Text"||!o[i.annotationId]?null:De($e,{strategy:{type:"textual-content",items:[i]}},a)),e.items.map((i,a)=>i.type!=="Video"||!i.target.spatial?null:De(zi,{target:i.target.spatial,children:De("video",{ref:s(i.annotationId),src:i.url,style:{height:"100%",width:"100%",opacity:o[i.annotationId]?1:0}})},a))]})}import{Fragment as Ue,jsx as N,jsxs as Q}from"react/jsx-runtime";function de({x:e,y:n,onChoiceChange:t,registerActions:r,defaultChoices:o,isStatic:s,renderViewerControls:i,renderMediaControls:a,renderComplexTimelineControls:u,viewControlsDeps:l,mediaControlsDeps:c,strategies:d,throwOnUnknown:v,backgroundStyle:x,alwaysShowBackground:h,keepCanvasScale:g=!1,enableSizes:A=!1,enableYouTube:p=!0,onClickPaintingAnnotation:S,components:m={},children:P}){let b=M(),I=Ie(b,["deep-zoom"]),[C]=rn(),y=sn(),E=R(),Z=tr(()=>Fi(E),[E]),[f,qe]=Fn({strategies:d||["images"],defaultChoices:o?.map(({id:w})=>w)}),Ce=f.type==="images"?f.choice:void 0,J=tr(()=>g?1:Math.max(1,...f.type==="images"?f.images.map(w=>(w.width||0)/w.target?.spatial.width):[]),[g,f]);cn(J),er(()=>{r&&r(qe)},[f.annotations]),er(()=>{if(o)for(let w of o)typeof w.opacity<"u"&&Z.applyStyles({id:w.id},"atlas",{opacity:w.opacity})},[o]),Di(()=>{t&&t(Ce)},[Ce]),H(y&&(f.type==="images"||f.type==="empty"||f.type==="textual-content"&&i)?"overlay":"none",`canvas-portal-controls-${b?.id}`,he.Provider,i?{value:y||null,children:i(f)}:{},[b,y,f,...l||[]]);let z=Ee({maxWidth:256,maxHeight:256});if(!b)return null;let X=b.accompanyingCanvas,Be=b.placeholderCanvas,me=z&&z.type==="fixed"?N("world-object",{height:b.height,width:b.width,x:e,y:n,children:N("world-image",{uri:z.id,target:{x:0,y:0,width:b.width,height:b.height},display:z.width&&z.height?{width:z.width,height:z.height}:void 0,crop:void 0})}):null;if(f.type==="unknown"){if(me)return me;if(v)throw new Error(f.reason||"Unknown image strategy");return null}let vt=Q($i,{children:[C?N(ye,{page:C}):null,f.annotations&&f.annotations.pages?f.annotations.pages.map(w=>N(ye,{page:w},w.id)):null,P]}),rr=f.type==="images"?f.images.length:0,ji=f.type==="media"&&f.media.type==="Video"&&Be?N(Fe,{renderViewerControls:i}):null;return Q(Ue,{children:[Q("world-object",{height:b.height,width:b.width,x:e,y:n,...I,children:[f.type==="empty"||h?N(He,{style:x}):null,f.type==="complex-timeline"?N(Xn,{strategy:f,children:u?u(f):null}):null,f.type==="textual-content"?Q(Ue,{children:[N($e,{strategy:f,onClickPaintingAnnotation:S}),vt]}):null,f.type==="images"?Q(Ue,{children:[f.images.map((w,ht)=>N(ce,{isStatic:s,image:w,id:w.id,thumbnail:ht===0?z:void 0,selector:w.selector,enableSizes:A,onClick:S?or=>{S(w.annotationId,w,or)}:void 0},w.id+ht)),vt]}):null,f.type==="3d-model"?N(Oe,{model:f.model}):null,f.type==="media"?N(Ue,{children:f.media.type==="Sound"?Q(Le,{media:f.media,mediaControlsDeps:c,audioCopmonent:m.Audio,children:[me,a?a(f):null]}):f.media.type==="Video"?Q(ze,{captions:f.captions,media:f.media,mediaControlsDeps:c,videoComponent:m.Video,children:[me,a?a(f):null]}):f.media.type==="VideoYouTube"&&p?Q(Yn,{media:f.media,mediaControlsDeps:c,children:[me,a?a(f):null]}):null}):null]},`${b.id}/${f.type}/${rr}`),f.type==="media"&&f.media.type==="Sound"&&X?N(_,{canvas:X.id,children:N(de,{renderViewerControls:i})}):null,f.type==="media"&&f.media.type==="Sound"&&Be&&!X?N(_,{canvas:Be.id,children:N(de,{renderViewerControls:i})}):null]})}import{Fragment as Bi,jsx as B,jsxs as _i}from"react/jsx-runtime";var qi=nr(function(n,t){let r=V(),o=Pe(),s=Yt(),{ViewerControls:i,MediaControls:a,ComplexTimelineControls:u}=n.components||{};if(Ui(t,()=>s,[s]),!r)return B("div",{});let l=0;return _i(Bi,{children:[n.header,B(L.Viewer,{height:n.height,mode:n.mode,renderPreset:n.renderPreset,runtimeOptions:n.runtimeOptions,children:o.map((c,d)=>{let v=l;return l+=c.width+(n.spacing||0),B(_,{canvas:c.id,children:B(L.RenderCanvas,{strategies:["3d-model","media","images","empty","textual-content","complex-timeline"],renderViewerControls:d===0&&i?()=>B(i,{}):void 0,renderMediaControls:d===0&&a?()=>B(a,{}):void 0,renderComplexTimelineControls:d===0&&u?()=>B(u,{}):void 0,x:v,...n.canvasProps||{},children:n.annotations},c.id)},c.id)})},n.reuseAtlas?"":s.currentSequenceIndex),n.children]})}),L=nr(function({children:n,height:t,annotations:r,canvasProps:o,spacing:s,header:i,components:a,mode:u,reuseAtlas:l,renderPreset:c,runtimeOptions:d,...v},x){let h=te();return B(ee,{vault:h,children:B(Kt,{...v,children:B(qi,{ref:x,height:t,components:a,spacing:s,canvasProps:o,annotations:r,header:i,mode:u,reuseAtlas:l,renderPreset:c,runtimeOptions:d,children:n})})})});L.RenderImage=ce;L.RenderCanvas=de;L.RenderAnnotationPage=ye;L.RenderAnnotation=we;L.Viewer=mn;L.CanvasBackground=He;L.Audio=Le;L.Video=ze;L.Model=Oe;L.AudioHTML=dt;L.VideoHTML=mt;L.ModelHTML=pt;L.PlaceholderCanvas=Fe;export{Ae as a,F as b,Y as c,W as d,ee as e,te as f,At as g,Pt as h,bt as i,_ as j,R as k,T as l,ne as m,Pe as n,V as o,Rt as p,Tr as q,je as r,Ua as s,Tt as t,_a as u,Ke as v,It as w,Mt as x,rs as y,Vt as z,kt as A,Nt as B,Ye as C,wt as D,re as E,Lr as F,zr as G,Dt as H,Ut as I,pe as J,Or as K,Cs as L,Hr as M,Ft as N,As as O,qt as P,_t as Q,ve as R,Qr as S,Kt as T,Yt as U,Xr as V,ie as W,Qt as X,fu as Y,Wt as Z,ro as _,Iu as $,Gt as aa,Zt as ba,Jt as ca,tn as da,rn as ea,on as fa,he as ga,sn as ha,M as ia,Ie as ja,ae as ka,Me as la,pn as ma,cl as na,ll as oa,dl as pa,Sn as qa,it as ra,Cn as sa,Fo as ta,$o as ua,Do as va,ml as wa,xe as xa,_o as ya,ue as za,Mn as Aa,En as Ba,Vn as Ca,kn as Da,Nn as Ea,zn as Fa,Fn as Ga,$n as Ha,Ee as Ia,st as Ja,le as Ka,kd as La,Nd as Ma,Ld as Na,ke as Oa,Ne as Pa,Gn as Qa,Mm as Ra,L as Sa};
|
package/dist/chunk-CCTBCLBV.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{expandTarget as D}from"@iiif/helpers";function _(e){return e.type==="SpecificResource"?[e.source,{selector:e.selector}]:[e,{selector:null}]}function x(e,o){let{selector:n,source:s}=D(o);if(s.id!==e.id)return[null,s];let t={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}};return[n?n.type==="TemporalSelector"?{type:"TemporalBoxSelector",temporal:n.temporal,spatial:t.spatial}:n:null,s]}var K={makeChoice:()=>{}},T={type:"unknown"},m=e=>({type:"unknown",reason:e,annotations:{pages:[]}}),w=(e,o)=>({type:"empty",width:e,height:o,annotations:{pages:[]},image:null,images:[]});var A=["model/gltf-binary"];function v(e,o){let s=o.items[0].resource;return s.format?A.indexOf(s.format)===-1?m(`3D format: ${s.format} is unsupported`):{type:"3d-model",model:s}:m("Unknown format")}import{getImageServices as O}from"@atlas-viewer/iiif-image-api";import{expandTarget as P}from"@iiif/helpers/annotation-targets";function C(e,o,n){let s=[];for(let t of o.items){let a=t.resource&&t.resource.type==="SpecificResource"?t.resource.source:t.resource;if(!a.id)return m("No resource Identifier");let c;if(a.service){let g=O(a);g[0]&&(c=n(g[0],e))}let y={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}},[u,i]=x(e,t.target),r=e.id?.split("?")[0]||"";if(!(i.id===e.id||decodeURIComponent(i.id||"")===(e.id||"")||i.id===r||decodeURIComponent(i.id||"")===r))continue;let l=t.resource.width&&t.resource.height?{type:"BoxSelector",spatial:{x:0,y:0,width:t.resource.width,height:t.resource.height}}:void 0,p=t.resource.type==="SpecificResource"?P(t.resource):null;if(t.selector){let g=P({type:"SpecificResource",source:t.resource,selector:t.selector});g&&(p=g)}let d=p&&p.selector&&(p.selector.type==="BoxSelector"||p.selector.type==="TemporalBoxSelector")?{type:"BoxSelector",spatial:{x:p.selector.spatial.x,y:p.selector.spatial.y,width:p.selector.spatial.width,height:p.selector.spatial.height}}:void 0;c&&!c.id&&(c.id=c["@id"]);let f={id:a.id,type:"Image",annotationId:t.annotationId,width:Number(u||d?a.width:e.width),height:Number(u||d?a.height:e.height),service:c,sizes:c&&c.sizes?c.sizes:a.width&&a.height?[{width:a.width,height:a.height}]:[],target:u&&u.type!=="PointSelector"?u:y,selector:d||{type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}}};s.push(f)}return{type:"images",image:s[0],images:s,choice:o.choice}}function k(e,o={},n){let s=e.language||n||"none";switch(e.type){case"TextualBody":{typeof e.value<"u"&&(o[s]=[e.value]);break}case"List":case"Composite":case"Choice":e.items&&e.items.forEach(t=>k(t,o,s))}return o}function I(e,o){let n=[];return o.items.forEach(s=>{if(s.resource){let[t]=x(e,s.target);n.push({type:"Text",annotationId:s.annotationId,text:k(s.resource),target:t})}}),{type:"textual-content",items:n}}import{expandTarget as U,parseSelector as W}from"@iiif/helpers";var L=/^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\/)|(?:(?:watch)?\?vi?=|&vi?=))([^#&?]*).*/;function b(e,o,n){let s=o.items.filter(d=>d.type==="video"),t=!1;if(e.duration||(t=!0),s.length>1)return m("Only one video source supported");let a=s[0]?.resource,c=!!(a.service||[]).find(d=>(d.profile||"").includes("youtube.com"));if(!c&&t)return m("Video does not have duration");if(!a)return m("Unknown video");if((!a.format||a.format==="text/html")&&!c)return m("Video does not have format");let y=[],u=n.get(e.annotations);for(let d of u){let f=n.get(d.items);for(let g of f)if((g.motivation?Array.isArray(g.motivation||"")?g.motivation:[g.motivation]:[]).includes("supplementing")){let V=n.get(g.body);for(let z of V){let h=z;if(h.type==="Choice")for(let B of h.items){let S=n.get(B);S.format==="text/vtt"&&y.push({id:S.id,type:"Text",format:"text/vtt",label:S.label,language:S.language})}else h.format==="text/vtt"&&y.push({id:h.id,type:"Text",format:"text/vtt",label:h.label,language:h.language})}}}let i=o.items[0],r={annotationId:o.items[0].annotationId,duration:e.duration,url:a.id,type:"Video",target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:a.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},l=U(i.target);l.selector&&l.selector.type==="TemporalBoxSelector"&&(r.target=l.selector);let{selector:p}=W(i.selector);if(p===null){let d=r.target.temporal.startTime,g=(r.target.temporal.endTime||e.duration)-d;r.selector={type:"TemporalSelector",temporal:{startTime:0,endTime:g}}}else p.type==="TemporalSelector"&&(r.selector=p);if(c){r.type="VideoYouTube";let d=a.id.match(L);if(!d[1])return m("Video is not known youtube video");r.youTubeId=d[1]}return{type:"media",media:r,annotations:{pages:[]},captions:y}}function R(e,o,n,s){let t={type:"complex-timeline",items:[],keyframes:[],duration:e.duration||0},a={type:"complex-choice",items:[]};function c(i){i.choice&&(i.choice.type==="complex-choice"?a.items.push(...i.choice.items):a.items.push(i.choice))}for(let i of o.items){if(i.type==="image"){let r=C(e,{choice:null,allChoices:null,types:["image"],items:[i]},n);if(r.type==="images"){c(r),t.items.push(r.image);let l={id:r.image.annotationId,type:"enter",resourceType:"image",time:r.image.target?.temporal?.startTime||0};t.keyframes.push(l);let p={id:r.image.annotationId,type:"exit",resourceType:"image",time:r.image.target?.temporal?.endTime||e.duration||0};t.keyframes.push(p)}}if(i.type==="textualbody"){let r=I(e,{choice:null,allChoices:null,types:["textualbody"],items:[i]});if(r.type==="textual-content"){c(r);let l=r.items[0];t.items.push(l);let p=l.target,d={id:l.annotationId,type:"enter",resourceType:"text",time:p.temporal?.startTime||0};t.keyframes.push(d);let f={id:l.annotationId,type:"exit",resourceType:"text",time:p.temporal?.endTime||e.duration||0};t.keyframes.push(f)}}if(i.type==="video"){let r=b(e,{choice:null,allChoices:null,types:["video"],items:[i]},s);if(r.type==="media"){c(r);let l=r.media;t.items.push(l);let p={id:l.annotationId,type:"enter",resourceType:"video",time:l.target?.temporal?.startTime||0};t.keyframes.push(p);let d={id:l.annotationId,type:"exit",resourceType:"video",time:l.target?.temporal?.endTime||e.duration||0};t.keyframes.push(d)}}}t.keyframes.sort((i,r)=>i.time-r.time);let y=[],u=[];for(let i of t.keyframes){if(i.resourceType==="image"||i.resourceType==="text"){u.push(i);continue}if(i.type==="enter"){y.length===0&&(i.isPrime=!0),y.push(i),u.push(i);continue}if(i.type==="exit"&&(u.push(i),y=y.filter(r=>r.id!==i.id),y.length!==0)){let r=y[0],l={id:r.id,type:"change",isPrime:!0,resourceType:r.resourceType,time:i.time};u.push(l)}}return t.keyframes=u,a.items.length&&(t.choice=a),t}function N(e,o){if(!e.duration)return m("No duration on canvas");if(o.items.length>1)return m("Only one audio source supported");let n=o.items[0]?.resource;return n?n.format?{type:"media",media:{annotationId:o.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:[]}}:m("Audio does not have format"):m("Unknown audio")}function xe({canvas:e,paintables:o,supports:n,loadImageService:s,vault:t}){if(!e)return T;if(o.types.length===0)return n.indexOf("empty")!==-1?w(e.width,e.height):T;if(o.types.length!==1)if(o.types.length===2&&o.types.indexOf("text")!==-1)o.types=o.types.filter(c=>c!=="text");else return n.indexOf("complex-timeline")===-1?m("Complex timeline not supported"):R(e,o,s,t);let a=o.types[0];return a==="image"?n.indexOf("images")===-1?m("Image not supported"):C(e,o,s):a==="Model"||a==="model"?n.indexOf("3d-model")===-1?m("3D not supported"):v(e,o):a==="textualbody"?n.indexOf("textual-content")===-1?m("Textual content not supported"):I(e,o):a==="sound"||a==="audio"?n.indexOf("media")===-1?m("Media not supported"):N(e,o):a==="video"?n.indexOf("media")===-1?m("Media not supported"):b(e,o,t):T}export{_ as a,x as b,K as c,T as d,m as e,w as f,v as g,C as h,I as i,b as j,R as k,xe as l};
|