react-iiif-vault 1.5.0 → 1.5.2

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/index.d.cts CHANGED
@@ -1,12 +1,12 @@
1
- import { A as AudioComponentProps, V as VideoComponentProps, S as SimpleViewerContext, a as SimpleViewerProps } from './index-Cs7EchlV.cjs';
2
- export { C as CanvasPanel, c as SimpleViewerActions, d as SimpleViewerActionsType, b as SimpleViewerReducerState } from './index-Cs7EchlV.cjs';
1
+ import { A as AudioComponentProps, V as VideoComponentProps, S as SimpleViewerContext, a as SimpleViewerProps } from './index-CMSk5Jbz.cjs';
2
+ export { C as CanvasPanel, c as SimpleViewerActions, d as SimpleViewerActionsType, b as SimpleViewerReducerState } from './index-CMSk5Jbz.cjs';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import * as React$1 from 'react';
5
5
  import React__default, { ReactNode, FunctionComponent, RefObject, Context } from 'react';
6
- import { R as RenderingStrategy, b as StrategyActions, M as MediaStrategy, c as SingleImageStrategy, E as EmptyStrategy, C as ComplexTimelineStrategy, I as ImageWithOptionalService, T as TimelineKeyframe, U as UnknownStrategy, d as ImageServiceLoaderType } from './useRenderingStrategy-B03X9rQS.cjs';
7
- export { f as AnnotationPageDescription, A as AudioSequence, n as ChoiceEvents, k as Single3DModelStrategy, S as SingleAudio, a as SingleVideo, e as SingleYouTubeVideo, i as TextContent, h as TextualContentStrategy, m as UseRenderingStrategy, o as UseRenderingStrategyOptions, V as VideoSequence, l as get3dStrategy, g as getImageStrategy, j as getTextualContentStrategy, u as useLoadImageService, p as useRenderingStrategy } from './useRenderingStrategy-B03X9rQS.cjs';
6
+ import { R as RenderingStrategy, b as StrategyActions, M as MediaStrategy, c as SingleImageStrategy, E as EmptyStrategy, C as ComplexTimelineStrategy, I as ImageWithOptionalService, T as TimelineKeyframe, U as UnknownStrategy, d as ImageServiceLoaderType } from './useRenderingStrategy-BiuSDiXu.cjs';
7
+ export { f as AnnotationPageDescription, A as AudioSequence, n as ChoiceEvents, k as Single3DModelStrategy, S as SingleAudio, a as SingleVideo, e as SingleYouTubeVideo, i as TextContent, h as TextualContentStrategy, m as UseRenderingStrategy, o as UseRenderingStrategyOptions, V as VideoSequence, l as get3dStrategy, g as getImageStrategy, j as getTextualContentStrategy, u as useLoadImageService, p as useRenderingStrategy } from './useRenderingStrategy-BiuSDiXu.cjs';
8
8
  import * as _iiif_helpers from '@iiif/helpers';
9
- import { ChoiceDescription, Paintables, Vault as Vault$1, ComplexChoice } from '@iiif/helpers';
9
+ import { ChoiceDescription, Paintables, ComplexChoice } from '@iiif/helpers';
10
10
  import { BoxStyle, AtlasProps, Preset } from '@atlas-viewer/atlas';
11
11
  import { InternationalString, ImageService as ImageService$1, ImageSize, AuthProbeService2, Auth2LocationResource, Auth2SubstituteResource, AuthAccessService2, AuthAccessTokenService2, AuthAccessToken2, SearchServiceQueryParams, SearchServiceSearchResponse, SearchService as SearchService$1, SearchServiceAutocomplete, Reference, Annotation } from '@iiif/presentation-3';
12
12
  import { RegionParameter, RotationParameter, SizeParameter } from '@iiif/parser/image-3';
@@ -21,7 +21,8 @@ import { Emitter, EventType, Handler } from 'mitt';
21
21
  import { Vault, VaultOptions, NormalizedEntity, IIIFStore } from '@iiif/helpers/vault';
22
22
  import { CanvasNormalized, AnnotationNormalized, AnnotationPageNormalized, CollectionNormalized, ManifestNormalized, RangeNormalized } from '@iiif/presentation-3-normalized';
23
23
  import { ImageServiceLoader, ImageCandidateRequest, ImageCandidate } from '@iiif/helpers/image-service';
24
- export { emptyActions, emptyStrategy, getParsedTargetSelector, getRenderingStrategy, parseSpecificResource, unknownResponse, unsupportedStrategy } from './utils.cjs';
24
+ import { C as CompatVault } from './utils-CvRzsfRK.cjs';
25
+ 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';
25
26
  import { VaultZustandStore } from '@iiif/helpers/vault/store';
26
27
  import * as _iiif_helpers_painting_annotations from '@iiif/helpers/painting-annotations';
27
28
  import * as _iiif_helpers_styles from '@iiif/helpers/styles';
@@ -177,6 +178,7 @@ interface SequenceThumbnailsProps {
177
178
  width: number;
178
179
  height?: number;
179
180
  };
181
+ dereference?: boolean;
180
182
  classes?: {
181
183
  container?: string;
182
184
  row?: string;
@@ -197,8 +199,9 @@ interface SequenceThumbnailsProps {
197
199
  figure?: boolean;
198
200
  showLabel?: boolean;
199
201
  fallback?: React.ReactNode;
202
+ scrollBehaviour?: ScrollBehavior;
200
203
  }
201
- declare function SequenceThumbnails({ flat, size, classes, showLabel, figure, fallback }: SequenceThumbnailsProps): react_jsx_runtime.JSX.Element;
204
+ declare function SequenceThumbnails({ scrollBehaviour, dereference, flat, size, classes, showLabel, figure, fallback }: SequenceThumbnailsProps): react_jsx_runtime.JSX.Element;
202
205
 
203
206
  interface SingleCanvasThumbnailProps {
204
207
  canvasId?: string;
@@ -851,9 +854,9 @@ interface ControlsContext {
851
854
  declare const ControlsReactContext: React$1.Context<ControlsContext | null>;
852
855
  declare function useRenderControls(): ControlsContext;
853
856
 
854
- declare function getVideoStrategy(canvas: CanvasNormalized, paintables: Paintables, vault: Vault$1): UnknownStrategy | MediaStrategy;
857
+ declare function getVideoStrategy(canvas: CanvasNormalized, paintables: Paintables, vault: CompatVault): UnknownStrategy | MediaStrategy;
855
858
 
856
- declare function getComplexTimelineStrategy(canvas: CanvasNormalized, paintables: Paintables, loadImageService: ImageServiceLoaderType, vault: Vault$1): ComplexTimelineStrategy;
859
+ declare function getComplexTimelineStrategy(canvas: CanvasNormalized, paintables: Paintables, loadImageService: ImageServiceLoaderType, vault: CompatVault): ComplexTimelineStrategy;
857
860
 
858
861
  declare function useAnnotation(options?: {
859
862
  id: string;
package/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- import { A as AudioComponentProps, V as VideoComponentProps, S as SimpleViewerContext, a as SimpleViewerProps } from './index-DZK6q9iO.js';
2
- export { C as CanvasPanel, c as SimpleViewerActions, d as SimpleViewerActionsType, b as SimpleViewerReducerState } from './index-DZK6q9iO.js';
1
+ import { A as AudioComponentProps, V as VideoComponentProps, S as SimpleViewerContext, a as SimpleViewerProps } from './index-CWeYvmxZ.js';
2
+ export { C as CanvasPanel, c as SimpleViewerActions, d as SimpleViewerActionsType, b as SimpleViewerReducerState } from './index-CWeYvmxZ.js';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import * as React$1 from 'react';
5
5
  import React__default, { ReactNode, FunctionComponent, RefObject, Context } from 'react';
6
- import { R as RenderingStrategy, b as StrategyActions, M as MediaStrategy, c as SingleImageStrategy, E as EmptyStrategy, C as ComplexTimelineStrategy, I as ImageWithOptionalService, T as TimelineKeyframe, U as UnknownStrategy, d as ImageServiceLoaderType } from './useRenderingStrategy-B03X9rQS.js';
7
- export { f as AnnotationPageDescription, A as AudioSequence, n as ChoiceEvents, k as Single3DModelStrategy, S as SingleAudio, a as SingleVideo, e as SingleYouTubeVideo, i as TextContent, h as TextualContentStrategy, m as UseRenderingStrategy, o as UseRenderingStrategyOptions, V as VideoSequence, l as get3dStrategy, g as getImageStrategy, j as getTextualContentStrategy, u as useLoadImageService, p as useRenderingStrategy } from './useRenderingStrategy-B03X9rQS.js';
6
+ import { R as RenderingStrategy, b as StrategyActions, M as MediaStrategy, c as SingleImageStrategy, E as EmptyStrategy, C as ComplexTimelineStrategy, I as ImageWithOptionalService, T as TimelineKeyframe, U as UnknownStrategy, d as ImageServiceLoaderType } from './useRenderingStrategy-BiuSDiXu.js';
7
+ export { f as AnnotationPageDescription, A as AudioSequence, n as ChoiceEvents, k as Single3DModelStrategy, S as SingleAudio, a as SingleVideo, e as SingleYouTubeVideo, i as TextContent, h as TextualContentStrategy, m as UseRenderingStrategy, o as UseRenderingStrategyOptions, V as VideoSequence, l as get3dStrategy, g as getImageStrategy, j as getTextualContentStrategy, u as useLoadImageService, p as useRenderingStrategy } from './useRenderingStrategy-BiuSDiXu.js';
8
8
  import * as _iiif_helpers from '@iiif/helpers';
9
- import { ChoiceDescription, Paintables, Vault as Vault$1, ComplexChoice } from '@iiif/helpers';
9
+ import { ChoiceDescription, Paintables, ComplexChoice } from '@iiif/helpers';
10
10
  import { BoxStyle, AtlasProps, Preset } from '@atlas-viewer/atlas';
11
11
  import { InternationalString, ImageService as ImageService$1, ImageSize, AuthProbeService2, Auth2LocationResource, Auth2SubstituteResource, AuthAccessService2, AuthAccessTokenService2, AuthAccessToken2, SearchServiceQueryParams, SearchServiceSearchResponse, SearchService as SearchService$1, SearchServiceAutocomplete, Reference, Annotation } from '@iiif/presentation-3';
12
12
  import { RegionParameter, RotationParameter, SizeParameter } from '@iiif/parser/image-3';
@@ -21,7 +21,8 @@ import { Emitter, EventType, Handler } from 'mitt';
21
21
  import { Vault, VaultOptions, NormalizedEntity, IIIFStore } from '@iiif/helpers/vault';
22
22
  import { CanvasNormalized, AnnotationNormalized, AnnotationPageNormalized, CollectionNormalized, ManifestNormalized, RangeNormalized } from '@iiif/presentation-3-normalized';
23
23
  import { ImageServiceLoader, ImageCandidateRequest, ImageCandidate } from '@iiif/helpers/image-service';
24
- export { emptyActions, emptyStrategy, getParsedTargetSelector, getRenderingStrategy, parseSpecificResource, unknownResponse, unsupportedStrategy } from './utils.js';
24
+ import { C as CompatVault } from './utils-C-h4SU3S.js';
25
+ 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';
25
26
  import { VaultZustandStore } from '@iiif/helpers/vault/store';
26
27
  import * as _iiif_helpers_painting_annotations from '@iiif/helpers/painting-annotations';
27
28
  import * as _iiif_helpers_styles from '@iiif/helpers/styles';
@@ -177,6 +178,7 @@ interface SequenceThumbnailsProps {
177
178
  width: number;
178
179
  height?: number;
179
180
  };
181
+ dereference?: boolean;
180
182
  classes?: {
181
183
  container?: string;
182
184
  row?: string;
@@ -197,8 +199,9 @@ interface SequenceThumbnailsProps {
197
199
  figure?: boolean;
198
200
  showLabel?: boolean;
199
201
  fallback?: React.ReactNode;
202
+ scrollBehaviour?: ScrollBehavior;
200
203
  }
201
- declare function SequenceThumbnails({ flat, size, classes, showLabel, figure, fallback }: SequenceThumbnailsProps): react_jsx_runtime.JSX.Element;
204
+ declare function SequenceThumbnails({ scrollBehaviour, dereference, flat, size, classes, showLabel, figure, fallback }: SequenceThumbnailsProps): react_jsx_runtime.JSX.Element;
202
205
 
203
206
  interface SingleCanvasThumbnailProps {
204
207
  canvasId?: string;
@@ -851,9 +854,9 @@ interface ControlsContext {
851
854
  declare const ControlsReactContext: React$1.Context<ControlsContext | null>;
852
855
  declare function useRenderControls(): ControlsContext;
853
856
 
854
- declare function getVideoStrategy(canvas: CanvasNormalized, paintables: Paintables, vault: Vault$1): UnknownStrategy | MediaStrategy;
857
+ declare function getVideoStrategy(canvas: CanvasNormalized, paintables: Paintables, vault: CompatVault): UnknownStrategy | MediaStrategy;
855
858
 
856
- declare function getComplexTimelineStrategy(canvas: CanvasNormalized, paintables: Paintables, loadImageService: ImageServiceLoaderType, vault: Vault$1): ComplexTimelineStrategy;
859
+ declare function getComplexTimelineStrategy(canvas: CanvasNormalized, paintables: Paintables, loadImageService: ImageServiceLoaderType, vault: CompatVault): ComplexTimelineStrategy;
857
860
 
858
861
  declare function useAnnotation(options?: {
859
862
  id: string;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{$ as Oo,$a as ye,A as ho,Aa as hr,B as yo,Ba as yr,C as vo,Ca as vr,D as xo,Da as xr,E as So,Ea as Sr,F as bo,Fa as br,G as Co,Ga as Cr,H as Io,Ha as Ir,I as ko,Ia as kr,J as Po,Ja as Pr,K as wo,Ka as wr,L as Ro,La as Rr,M as To,Ma as Tr,N as Eo,Na as Er,O as No,Oa as Nr,P as Mo,Pa as Mr,Q as Bo,Qa as Br,R as Lo,Ra as Lr,S as Ho,Sa as B,T as Ao,Ta as ge,U as se,Ua as Hr,V as zo,Va as Ar,W as qo,Wa as zr,X as le,Xa as qr,Y as Wo,Ya as Wr,Z as Do,Za as Dr,_ as Fo,_a as he,a as Zt,aa as $o,ab as Fr,b as q,ba as Vo,bb as Or,c as L,ca as Ko,cb as $r,d as jt,da as Xo,db as Vr,e as eo,ea as Yo,eb as Kr,f as to,fa as _o,fb as Xr,g as re,ga as ce,gb as Yr,h as oo,ha as F,hb as _r,i as ro,ia as Qo,ib as Qr,j as ne,ja as U,jb as Ur,k as P,ka as w,kb as Gr,l as W,la as me,lb as Jr,m as no,ma as Uo,mb as Zr,n as ie,na as Go,nb as ve,o as D,oa as Jo,p as io,pa as Zo,q as ao,qa as ir,r as so,ra as ue,s as lo,sa as ar,t as co,ta as de,u as mo,ua as fe,v as uo,va as pe,w as ae,wa as O,x as fo,xa as sr,y as po,ya as pr,z as go,za as gr}from"./chunk-LXMMN7PH.js";import{a as jo,b as er,c as tr,d as or,e as rr,f as nr,g as lr,h as cr,i as mr,j as ur,k as dr,l as fr}from"./chunk-PCXRCBVF.js";import{useCanvas as _e}from"@atlas-viewer/atlas";import{forwardRef as Qe,useImperativeHandle as Ue}from"react";import{Fragment as Ge,jsx as xe}from"react/jsx-runtime";var nn=Qe(function({canvasId:t},o){let r=_e(),i=ue(t||r?.id),a=P();return Ue(o,()=>i,[t,r]),!r||i.enabledPageIds.length===0?null:xe(Ge,{children:i.enabledPageIds.map(s=>xe(ve.RenderAnnotationPage,{page:a.get(s)},s))})});import{useMemo as je}from"react";import{useMemo as Je}from"react";import{Fragment as Ze,jsx as I,jsxs as $}from"react/jsx-runtime";function V({metadata:e=[],config:t,labelWidth:o=16,showEmptyMessage:r=!0,allowHtml:i,emptyFallback:a,classes:s={},emptyMessage:l="No metadata available",emptyValueFallback:d="No value",emptyLabelFallback:u="",separator:c,tableFooter:f,tableHeader:x}){let y=Je(()=>{let h=(t||[]).reduce((p,g)=>[...p,...g.keys],[]),m={};for(let p of e){let g=p&&p.label?Object.values(p.label):[];for(let n of g)if(n&&n.length&&(h.indexOf(`metadata.${n[0]}`)!==-1||h.length===0)&&p){let v=`metadata.${n[0]}`;m[v]=m[v]?m[v]:[],m[v].push(p);break}}return m},[t,e]);return Object.keys(y).length===0&&r?I(Ze,{children:a})||I("div",{className:s.empty,children:l}):t&&t.length?$("table",{className:s.container,children:[x,I("tbody",{children:t.map((h,m)=>{let p=[];for(let g of h.keys)for(let n of y[g]||[])p.push(I(B,{enableDangerouslySetInnerHTML:i,defaultText:d,separator:c,children:n.value},m+"__"+g));return p.length===0?null:$("tr",{className:s.row,children:[I("td",{className:s.label,style:o?{minWidth:o}:{},children:I(B,{enableDangerouslySetInnerHTML:i,separator:c,defaultText:u,children:h.label})}),I("td",{className:s.value,children:p})]},m)})}),f]}):$("table",{className:s.container,children:[x,I("tbody",{children:e&&e.length?e.map((h,m)=>h?$("tr",{className:s.row,children:[I("td",{className:s.label,style:o?{minWidth:o}:{},children:I(B,{enableDangerouslySetInnerHTML:i,defaultText:d,separator:c,children:h.label})}),I("td",{className:s.value,children:I(B,{enableDangerouslySetInnerHTML:i,defaultText:d,separator:c,children:h.value})})]},m):null):null}),f]})}import{jsx as et}from"react/jsx-runtime";function vn(e){let t=D(),o=w(),r=ae(),i=je(()=>{let a=t?.metadata||[],s=o?.metadata||[],l=r?.metadata||[];return[...a,...s,...l]},[t,o,r]);return et(V,{metadata:i,...e})}import{useEffect as nt,useState as it}from"react";import{createImageServiceRequest as tt,imageServiceRequestToString as ot}from"@iiif/parser/image-3";import{useMemo as rt}from"react";function G(e,t={},o=[]){return rt(()=>{if(!e)return null;let r=t.quality;e&&e.extraQualities&&t.quality&&(e.extraQualities.includes(t.quality)||(r="default"));let i=tt(e);return ot({identifier:i.identifier,server:i.server,scheme:i.scheme,type:"image",size:{max:!t.size?.width&&!t.size?.height,confined:!1,upscaled:!1,...t.size||{}},format:t.format||"jpg",region:t.region||{full:!0},rotation:t?.rotation?Number.isInteger(t.rotation)?{angle:t.rotation}:t.rotation:{angle:0},quality:r||"default",prefix:i.prefix,originalPath:i.originalPath})},[...o])}import{jsx as K}from"react/jsx-runtime";function at(e){let t=typeof e.src=="string"?e.src:e.src.id,o=he(),[r,i]=it(!1),a;if(t){let l=o.loadServiceSync({id:t});l&&(a=l)}!a&&!r&&o.loadService({id:t}).then(()=>{i(!0)});let s=G(a,{size:e.size,selector:e.region,rotation:e.rotation,format:e.format,region:e.region,quality:e.quality},[r,e.src,e.size,e.region,e.rotation,e.format,e.region,e.quality]);return nt(()=>()=>{i(!1)},[t]),s?K("img",{src:s,alt:e.alt,className:e.className,style:e.style}):K(st,{...e,fetchImageService:!1})}function st(e){if(e.fetchImageService)return K(at,{...e});let t=typeof e.src=="string"?{id:e.src,profile:"level0"}:e.src,o=G(t,{size:e.size,selector:e.region,rotation:e.rotation,format:e.format,region:e.region,quality:e.quality},[e.src,e.size,e.region,e.rotation,e.format,e.region,e.quality]);return o?K("img",{src:o,alt:e.alt,className:e.className,style:e.style}):null}import{jsx as lt}from"react/jsx-runtime";function Hn(e){let t=D();return lt(V,{metadata:t?.metadata||[],...e})}import{useLayoutEffect as ft,useRef as pt}from"react";import*as J from"react-lazy-load-image-component";import{getValue as ct}from"@iiif/helpers/i18n";import{Fragment as Se,jsx as R,jsxs as dt}from"react/jsx-runtime";var{LazyLoadComponent:mt}=J||J.default;function be(e){let{size:t,visible:o,classes:r,canvasId:i,figure:a}=e,s=t?.width||128,l=t?.height||t?.width||128,d=R(ut,{...e}),u=R(mt,{threshold:300,style:{height:l,width:s},visibleByDefault:o,children:i?R(ne,{canvas:i,children:d}):d});return a?R("figure",{className:r?.figure,children:u}):u}function ut({fallback:e,size:t,classes:o,showLabel:r,alt:i,dereference:a=!1}){let s=w(),l=t?.width||128,d=t?.height||t?.width||128,u=i||ct(s?.label)||"",c=ye({width:l,height:d},a);return!c||c.type!=="fixed"?R(Se,{children:e}):dt(Se,{children:[R("div",{className:o?.imageWrapper,children:R("img",{className:o?.img,src:c.id,alt:u})}),r?R(B,{as:"figcaption",className:o?.label,children:s?.label}):null]})}import{jsx as H}from"react/jsx-runtime";function _n({flat:e,size:t,classes:o={},showLabel:r,figure:i,fallback:a}){let s=pt(null),{items:l,sequence:d,currentSequenceIndex:u,setSequenceIndex:c}=se(),f={row:o.selected?.row||o.row,item:o.selected?.item||o.item,figure:o.selected?.figure||o.figure,img:o.selected?.img||o.img,label:o.selected?.label||o.label,imageWrapper:o.selected?.imageWrapper||o.imageWrapper};ft(()=>{if(!s.current)return;let y=s.current.querySelector("[data-selected=true]");y&&y.scrollIntoView({behavior:"smooth",block:"nearest",inline:"center"})},[u]);let x=[];for(let y of d){let C=[],h=d[u]===y;for(let m of y){let p=l[m];C.push(H("div",{className:h?f.item:o.item,children:H(be,{classes:h?f:o,canvasId:p.id,size:t,showLabel:r,figure:i,placeholder:H("div",{style:{height:128,width:128}}),fallback:a})},m))}if(e){x.push(C);continue}x.push(H("div",{onClick:m=>{c(d.indexOf(y))},"data-selected":h,className:h?f.row:o.row,children:C},y.join("-")))}return H("div",{ref:s,className:o.container,children:x})}import{Fragment as Ce,jsx as T,jsxs as Ie}from"react/jsx-runtime";var gt={draw:!0,polygon:!0,line:!0,lineBox:!0,square:!0,triangle:!0,hexagon:!0,circle:!0,delete:!0};function Gn({helper:e,showShapes:t,state:o,enabled:r=gt,classNames:i={},icons:a={}}){return Ie(Ce,{children:[t?Ie(Ce,{children:[r.draw&&T("button",{className:i.button,onClick:()=>{e.stamps.clear(),e.draw.enable()},"data-active":!o.lineMode&&!o.selectedStamp&&t&&o.drawMode,children:a.DrawIcon||"Draw"}),r.polygon&&T("button",{className:i.button,"data-active":!o.lineMode&&!o.selectedStamp&&t&&!o.drawMode,onClick:()=>{e.stamps.clear(),e.draw.disable(),e.modes.disableLineBoxMode(),e.modes.disableLineMode()},children:a.PolygonIcon||"Polygon"}),r.line&&T("button",{className:i.button,"data-active":o.lineMode&&!o.lineBoxMode,onClick:()=>{e.modes.enableLineMode()},children:a.LineIcon||"Line"}),r.lineBox&&T("button",{className:i.button,"data-active":o.lineBoxMode,onClick:()=>{e.modes.enableLineBoxMode()},children:a.LineBoxIcon||"LineBox"}),r.square&&T("button",{className:i.button,"data-active":o.selectedStamp?.id==="square",onClick:()=>{e.stamps.square()},children:a.SquareIcon||"Square"}),r.triangle&&T("button",{className:i.button,"data-active":o.selectedStamp?.id==="triangle",onClick:()=>{e.stamps.triangle()},children:a.TriangleIcon||"Triangle"}),r.hexagon&&T("button",{className:i.button,"data-active":o.selectedStamp?.id==="hexagon",onClick:()=>{e.stamps.hexagon()},children:a.HexagonIcon||"Hexagon"})]}):null,o.showBoundingBox&&r.delete&&T("button",{className:i.button,onClick:()=>e.key.down("Backspace"),children:a.DeleteForeverIcon||"Delete"})]})}import{createContext as ht,useCallback as ke,useContext as we,useEffect as Pe,useMemo as Z,useState as yt}from"react";import Re from"mitt";import{jsx as vt}from"react/jsx-runtime";var X=ht(Re());X.displayName="SelectorHelper";function ni({children:e}){return vt(X.Provider,{value:Z(()=>Re(),[]),children:e})}function ii(){return we(X)}function Te(e){let t=Ee(),[o,r]=yt(!1);Pe(()=>t.withSelector(e).on("highlight",()=>{r(!0)}),[t,e]),Pe(()=>t.withSelector(e).on("clear-highlight",()=>{r(!1)}),[t,e]);let i=ke(s=>{t.emit("click",{selectorId:e,event:s})},[e,t]),a=ke(s=>{t.emit("hover",{selectorId:e,event:s})},[e,t]);return{controller:t,onClick:i,onHover:a,isHighlighted:o}}function Ee(){let e=we(X);return Z(()=>({withSelector(t){return{on(o,r){let i=a=>{a&&a.selectorId===t&&r(a)};return e.on(o,i),()=>{e.off(o,i)}},emit(o,r){e.emit(o,{...r,selectorId:t})}}},on(t,o){return e.on(t,o),()=>{e.off(t,o)}},emit(t,o){e.emit(t,o)}}),[e])}function ai(){let e=Ee();return Z(()=>({withSelector(t){return{highlight(){e.emit("highlight",{selectorId:t})},clearHighlight(){e.emit("clear-highlight",{selectorId:t})},zoomTo(){e.emit("zoom-to",{selectorId:t})},addEventListener(o,r){return e.emit("event-listener",{selectorId:t,name:o,callback:r}),()=>{e.emit("remove-event-listener",{selectorId:t,name:o,callback:r})}},getImagePreview(){return new Promise((o,r)=>{e.emit("image-preview-request",{selectorId:t,resolve:o,reject:r})})},on(o,r){return e.withSelector(t).on(o,r)}}},highlight(t){e.emit("highlight",{selectorId:t})},clearHighlight(t){e.emit("clear-highlight",{selectorId:t})},zoomTo(t){e.emit("zoom-to",{selectorId:t})},addEventListener(t,o,r){return e.emit("event-listener",{selectorId:t,name:o,callback:r}),()=>{e.emit("remove-event-listener",{selectorId:t,name:o,callback:r})}},getImagePreview(t){return new Promise((o,r)=>{e.emit("image-preview-request",{selectorId:t,resolve:o,reject:r})})},on(t,o){return e.on(t,o)}}),[e])}import{createContext as xt,useContext as St,useMemo as bt}from"react";import{jsx as Ct}from"react/jsx-runtime";function Ne(){return{default:{backgroundColor:"rgba(0,0,0,0)",borderWidth:"2px",borderColor:"rgba(252,0,98, .5)"},highlighted:{backgroundColor:"rgba(75, 103, 225, 0.4)",borderWidth:"1px",borderColor:"rgba(75,103,225,0.99)"},hidden:{borderWidth:"0px",borderColor:"rgba(0,0,0,0)",backgroundColor:"rgba(0,0,0,0)",hidden:!0}}}var j=xt(Ne());j.displayName="AnnotationStyle";function Me(){return St(j)}function mi({theme:e,children:t}){let o=bt(()=>e||Ne(),[e]);return Ct(j.Provider,{value:o,children:t})}import{HTMLPortal as Tt,useAtlas as Et}from"@atlas-viewer/atlas";import{useEffect as Le,useRef as E,useState as He}from"react";import{useEffect as It,useMemo as kt,useState as Pt}from"react";import{createHelper as wt}from"polygon-editor";function Be(e,t,o){let[r,i]=Pt({}),a=kt(()=>wt(e,o),[]);return It(()=>(a.clock.start(t,i),()=>{a.clock.stop()}),[]),{state:r,helper:a}}import{createSvgHelpers as Rt}from"polygon-editor";import{Fragment as Ae,jsx as b,jsxs as ze}from"react/jsx-runtime";var N=Rt();function qe(e,t){let{image:o,currentShape:r,onChange:i,hideShapeLines:a}=e,s=E(),l=E(),d=E(),u=E(),c=E(),f=E(),x=E(),y=E(),[C,h]=He(null),[m,p]=He(!1),{helper:g,state:n}=Be(r,(S,k)=>{N.updateTransitionBoundingBox(l.current,S,k),N.updateBoundingBoxPolygon(s.current,S,k),N.updateTransitionShape(f.current,S,k),N.updateClosestLinePointTransform(u.current,S,k),N.updateSelectBox(d.current,S,k),N.updatePointLine(x.current,S,k),N.updateDrawPreview(c.current,S,k,3),N.updateLineBox(y.current,S),h(S.transitionDirection),p(S.transitionRotate)},i);Le(()=>{g.setShape(r||null)},t),Le(()=>{let S=()=>{g.modifiers.reset()};return document.addEventListener("mouseleave",S),()=>{document.removeEventListener("mouseleave",S)}},[]);let v=ze(Ae,{children:[b("marker",{id:"dot",viewBox:"0 0 10 10",refX:"5",refY:"5",markerWidth:"5",markerHeight:"5",children:b("circle",{cx:"5",cy:"5",r:"4",className:"marker"})}),b("marker",{id:"selected",viewBox:"0 0 10 10",refX:"5",refY:"5",markerWidth:"5",markerHeight:"5",children:b("circle",{cx:"5",cy:"5",r:"4",fill:"#FAFF00"})}),b("marker",{id:"resizer",viewBox:"0 0 10 10",refX:"5",refY:"5",markerWidth:"5",markerHeight:"5",children:b("rect",{width:"10",height:"10",stroke:"#FF0DCB",fill:"#fff",strokeWidth:2})})]}),M=r?r.open?"polyline":"polygon":null,oe=!n.showBoundingBox&&n.closestPoint!==null&&n.actionIntentType==="select-point",Ke=n.actionIntentType==="add-open-point",Xe=n.transitionIntentType==="split-line",Q=n.transitioning&&n.selectedStamp&&n.transitionIntentType==="stamp-shape",Ye=r&&M?ze(Ae,{children:[b(M,{fill:!n.transitioning&&n.showBoundingBox?"rgba(255, 0, 0, .5)":"none",strokeWidth:Q?0:2,stroke:a?"transparent":"#000",points:r.points.map(S=>S.join(",")).join(" "),vectorEffect:"non-scaling-stroke",markerStart:n.showBoundingBox?void 0:"url(#dot)",markerMid:n.showBoundingBox?void 0:"url(#dot)",markerEnd:n.showBoundingBox?void 0:"url(#dot)",style:{pointerEvents:"none"}}),n.lineBoxMode&&n.actionIntentType==="close-line-box"?b("polygon",{fill:"rgba(255, 0, 0, .4)",ref:y,stroke:"#000",strokeWidth:2,vectorEffect:"non-scaling-stroke"}):null,n.transitionIntentType==="draw-shape"&&n.transitioning?b("polyline",{ref:c,fill:"none",stroke:"rgba(255, 0, 0, .5)",strokeWidth:2,vectorEffect:"non-scaling-stroke"}):null,!n.showBoundingBox&&n.selectedPoints&&n.selectedPoints.length?b("polyline",{strokeWidth:2,vectorEffect:"non-scaling-stroke",stroke:"transparent",markerStart:"url(#selected)",markerMid:"url(#selected)",markerEnd:"url(#selected)",fill:"transparent",points:r.points.filter((S,k)=>n.selectedPoints?.includes(k)).map(S=>S.join(",")).join(" ")}):null,oe&&n.closestPoint!==null&&r.points[n.closestPoint]?b("polyline",{strokeWidth:2,vectorEffect:"non-scaling-stroke",stroke:"transparent",markerStart:"url(#selected)",markerMid:"url(#selected)",markerEnd:"url(#selected)",fill:"transparent",points:`${r.points[n.closestPoint][0]},${r.points[n.closestPoint][1]}`}):null,!n.transitioning&&(n.actionIntentType==="add-open-point"||n.actionIntentType==="close-shape"||n.actionIntentType==="close-shape-line")?b("polyline",{stroke:"#000",ref:x,strokeWidth:n.actionIntentType==="close-shape"?2:1,vectorEffect:"non-scaling-stroke"}):null,n.hasClosestLine&&(!n.transitionIntentType||n.transitionIntentType==="split-line")?b("g",{ref:u,children:b("polyline",{style:{opacity:.5},markerStart:"url(#dot)",points:"0,0 10,10",vectorEffect:"non-scaling-stroke",fill:"transparent",strokeWidth:2})}):null,n.transitioning?b(M,{ref:f,fill:r.open?"none":"rgba(255, 0, 0, .5)",stroke:"rgba(255, 0, 0, .5)",strokeWidth:r.open?2:0}):null,n.transitioning&&n.transitionIntentType==="select-multiple-points"?b("rect",{ref:d,fill:"rgba(255, 255, 255, .3)",strokeWidth:1,stroke:"rgba(0,0,0,.2)",vectorEffect:"non-scaling-stroke"}):null,n.showBoundingBox?null:b("g",{name:"controls",children:!1}),n.showBoundingBox&&!Q?b("polygon",{ref:s,strokeWidth:2,stroke:"#FF0DCB",fill:"none",markerStart:"url(#resizer)",markerMid:"url(#resizer)",markerEnd:"url(#resizer)",vectorEffect:"non-scaling-stroke"}):null]}):null;return{helper:g,state:n,isAddingPoint:Ke,isSplitting:Xe,isStamping:Q,isHoveringPoint:oe,transitionDirection:C,transitionRotate:m,defs:v,editor:Ye}}import{useEffect as ee}from"react";import{createPortal as Nt}from"react-dom";import{Fragment as We,jsx as A,jsxs as Y}from"react/jsx-runtime";var Mt=[{name:"Default",outer:{borderWidth:4,borderColor:"rgba(255, 255, 255, .4)"},inner:{borderWidth:2,borderColor:"#000"}},{name:"High contrast",outer:{borderWidth:3,borderColor:"#fff"},inner:{borderWidth:1,borderColor:"#000"}},{name:"Lightsaber",outer:{borderWidth:"4",borderColor:"rgba(56,68,255,0.64)"},inner:{borderWidth:"2",borderColor:"#fff"}},{name:"Bright",outer:{borderWidth:"6",borderColor:"#25d527"},inner:{borderWidth:"3",borderColor:"#a916ff"}},{name:"pink",outer:{borderWidth:"4",borderColor:"#ff00ff"},inner:{borderWidth:"2",borderColor:"#ffffff"}},{name:"fine (dark)",outer:{borderWidth:"1",borderColor:"#000000"},inner:{}},{name:"fine (light)",outer:{borderWidth:"1",borderColor:"#FFF"},inner:{}}];function De(e){let t=e.theme||Mt[0],o=Et(),{image:r}=e,{helper:i,defs:a,editor:s,state:l,transitionDirection:d,isSplitting:u,transitionRotate:c,isHoveringPoint:f,isAddingPoint:x,isStamping:y}=qe({currentShape:e.shape||null,onChange:e.updateShape,image:e.image,hideShapeLines:!0},[]),C=n=>{i.pointer([[~~n.atlas.x,~~n.atlas.y]])};ee(()=>{let n=v=>{i.key.up(v.key)};return document.addEventListener("keyup",n),()=>{document.removeEventListener("keyup",n)}},[]),ee(()=>{let n=v=>{i.key.down(v.key)};return document.addEventListener("keydown",n),()=>{document.removeEventListener("keydown",n)}},[]),ee(()=>{let n=[];return d&&n.push(`atlas-cursor-${d}`),l.actionIntentType==="cut-line"&&l.modifiers?.Shift&&n.push("atlas-cursor-cut"),(f||l.transitionIntentType==="move-shape"||l.transitionIntentType==="move-point")&&n.push("atlas-cursor-move"),x&&n.push("atlas-cursor-crosshair"),u&&n.push("atlas-cursor-copy"),c&&n.push("atlas-cursor-rotate"),l.transitionIntentType==="draw-shape"&&n.push("atlas-cursor-draw"),o?.canvas&&o.canvas.classList.add(...n),()=>{o?.canvas&&o.canvas.classList.remove(...n)}},[o?.canvas,x,f,u,l.modifiers?.Shift,l.actionIntentType,l.transitionIntentType,d,c]);let h=e.shape&&e.shape?.points.length===0,m=e.renderControls?e.renderControls(i,l,h):null,p=document.getElementById(e.controlsHtmlId||"atlas-controls"),g="shape";return A(We,{children:Y("world-object",{height:r.height,width:r.width,onMouseMove:C,onMouseDown:i.pointerDown,onMouseUp:i.pointerUp,onMouseLeave:i.blur,children:[e.shape?Y(We,{children:[A(g,{open:e.shape.open,points:e.shape.points,relativeStyle:!0,style:y?{}:t.outer}),A(g,{open:e.shape.open,points:e.shape.points,relativeStyle:!0,style:y?{}:t.inner})]}):null,Y(Tt,{relative:!0,interactive:!1,children:[A("div",{style:{position:"absolute",top:0,right:0,left:0,bottom:0},children:Y("svg",{width:"100%",height:"100%",viewBox:`0 0 ${r.width} ${r.height}`,tabIndex:-1,children:[A("defs",{children:a}),s]})}),p?Nt(m,p,"controls"):null]})]})})}import{jsx as Fe}from"react/jsx-runtime";function Di(e){let t=w(),o=e.annotationBucket,r=e.readOnly,i=e.id,{onClick:a,isHighlighted:s}=Te(e.id),l=Me(),d=s?l.highlighted:l[o||"hidden"]||l.hidden;if(!t)return null;if(r){let u="shape",c=e.polygon,f=c.open;return c?Fe(u,{id:`shape-${i}`,points:c.points,open:f,onClick:a,relativeStyle:!0,target:{x:0,y:0,width:t.width,height:t.height},style:d}):null}return Fe(De,{image:t,shape:e.polygon||{id:e.id,open:!0,points:[]},updateShape:e.updatePolygon,theme:e.theme,controlsHtmlId:e.controlsHtmlId,renderControls:e.renderControls})}import{useMemo as Bt,useState as Lt}from"react";import{ErrorBoundary as Ht}from"react-error-boundary";import{jsx as z,jsxs as zt}from"react/jsx-runtime";function Gi({src:e,errorFallback:t,interactive:o,skipSizes:r,children:i,renderViewerControls:a,viewControlsDeps:s,fluid:l,x:d,y:u,...c}){let[f,x]=Lt(),y=t||ce,[C,h]=pe(),m=Bt(()=>{let g=h[e]?.status,n=C({id:e},{});return n?.height&&n.width&&g!=="loading"?{id:e,width:n.width,height:n.height,service:n,type:"Image",selector:{type:"BoxSelector",spatial:{x:0,y:0,width:n.width,height:n.height}},target:{type:"BoxSelector",spatial:{x:0,y:0,width:n.width,height:n.height}}}:null},[C,e,h]);if(U(f&&a?"overlay":"none",`canvas-portal-controls-${e}`,F.Provider,a&&m?{value:f||null,children:a({image:m,images:[m],type:"images"})}:{},[e,m,f,...s||[]]),!m||!m.height||!m.width)return null;let p=l?void 0:c.homePosition?c.homePosition.width/c.homePosition.height:m.width/m.height;return console.log("here",p),z(Ht,{resetKeys:[],fallbackRender:g=>z(y,{...c,...g}),children:z(me,{...c,aspectRatio:p,containerProps:{style:{position:"relative"},...c.containerProps||{}},onCreated:g=>{x(g),c.onCreated&&c.onCreated(g)},children:zt(F.Provider,{value:f,children:[z(ge,{image:m,id:m.id,isStatic:!o,x:d,y:u},m.id),z(At,{viewerPreset:f,renderViewerControls:a,image:m,src:e,viewControlsDeps:s}),i]})})})}function At({viewerPreset:e,renderViewerControls:t,image:o,src:r,viewControlsDeps:i}){return U(e&&t?"overlay":"none",`canvas-portal-controls-${r}`,F.Provider,t&&o?{value:e||null,children:t({image:o,images:[o],type:"images"})}:{},[r,e,...i||[]]),null}import{jsx as qt}from"react/jsx-runtime";function ea({annotation:e,children:t}){return qt(L,{value:{annotation:e},children:t})}import{jsx as Wt}from"react/jsx-runtime";function na({annotationPage:e,children:t}){return Wt(L,{value:{annotationPage:e},children:t})}import{jsx as Dt}from"react/jsx-runtime";function la({collection:e,children:t}){return Dt(L,{value:{collection:e},children:t})}function da(e,t={}){return O(t)}import{useCanvas as Ft}from"@atlas-viewer/atlas";import{useEffect as Ot,useMemo as te,useState as $t}from"react";function va({canvasId:e}={}){let t=Ft(),o=ie(),r=te(()=>e?[e]:t?[t.id]:o.map(u=>u.id),[e,t,o]),[i,a]=$t({}),s=le();Ot(()=>{let u=c=>{let f=c.partOf.canvasId;f&&a(x=>({...x,[f]:c.choice}))};return s.on("choice-change",u),()=>{s.off("choice-change",u)}},[]);let l=te(()=>{let u=[];for(let c of r){let f=i[c];f&&u.push({canvasId:c,choice:f})}return u},[r,i]),d=te(()=>({makeChoice:(u,c)=>{s.emit("make-choice",{choiceId:u,...c})}}),[s]);return{choices:l,actions:d}}function Sa(e,t=!1){}function ka(e){let o=q().manifest,r=e?e.map(i=>typeof i=="string"?i:i?.id):[];return W(i=>{let a=o?i.iiif.entities.Manifest[o]:void 0,s=a?.items||[];if(typeof e>"u")return s;let l=[];for(let d of a?.items||[])r.indexOf(d.id)!==-1&&l.push(d);return l},[r.join("/")])}import{useMemo as Vt}from"react";function Ea(e,t=[]){let{id:o,selector:r}=e,i=q(),a=o||i.collection,s=W(l=>a?l.iiif.entities.Collection[a]:void 0,[a]);return Vt(()=>{if(s)return r?r(s):s},[s,r,...t])}import{useEffect as Kt,useMemo as Xt}from"react";import{createEventsHelper as Yt}from"@iiif/helpers/events";function Ha(e,t,o,r,i=[]){let a=P(),s=Xt(()=>Yt(a),[a]);Kt(()=>{let l=e;return l?(s.addEventListener(l,t,o,r),()=>{s.removeEventListener(l,t,o)}):()=>{}},[s,e,t,...i])}function Wa(e,t){let{id:o,isLoaded:r,error:i,resource:a,requestId:s,cached:l}=re(e,t);return{id:o,isLoaded:r,error:i,manifest:a,requestId:s,cached:l}}import{getImageServices as Oe}from"@iiif/parser/image-3";import{useEffect as _t,useMemo as $e,useState as _}from"react";function Ve({cacheKey:e}={}){let t=w(),o=O(),r=P(),i=de(),a=fe(),[s,l]=_(void 0),[d,u]=_(!1),[c,f]=_("idle"),[x,y]=_(void 0),C=t?t.id:"undefined",h=$e(()=>{try{if(t&&o.length){let p=o[0],g=r.get(p.body[0]),v=Oe(g)[0];return v&&i(v,{width:v.width||t.width,height:v.height||t.height},!0)||void 0}}catch(p){console.error(p)}},[C,e,t]),m=c==="success"&&s?s:h;return _t(()=>{(async()=>{try{if(t&&o.length){let p=o[0],g=r.get(p.body[0]),v=Oe(g)[0];if(!v)return;u(!0),f("loading");try{let M=await a(v,{width:v.width||t.width,height:v.height||t.height})||void 0;l(M),f("success"),u(!1)}catch(M){f("error"),y(M)}}}catch(p){f("error"),y(p)}})()},[C,e]),$e(()=>({data:m,isFetching:d,status:c,error:x}),[m,d,c,x])}function Qa(){let e=Ve();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}}import{createStylesHelper as Qt}from"@iiif/helpers/styles";import{useMemo as Ut}from"react";function ja(){let e=P();return Ut(()=>Qt(e),[e])}export*from"@iiif/helpers/annotation-targets";export{ea as AnnotationContext,na as AnnotationPageContext,mi as AnnotationStyleProvider,Mo as Auth,Io as AuthProvider,So as AuthRContext,bo as AuthReactContext,Co as AuthReactContextActions,nn as CanvasAnnotations,ne as CanvasContext,ve as CanvasPanel,xr as CanvasStrategyProvider,Sr as CanvasWorldObject,la as CollectionContext,vn as CombinedMetadata,Hr as ComplexTimelineProvider,Vo as ContextBridge,yr as ControlsReactContext,De as CreateCustomShape,Fo as CustomContextBridge,Oo as CustomContextBridgeProvider,Wo as EventsProvider,st as Image,Gi as ImageService,Dr as ImageServiceLoaderContext,Ho as InnerViewerProvider,Pr as LanguageProvider,Nr as LanguageString,B as LocaleString,ro as ManifestContext,Hn as ManifestMetadata,Yr as MediaPlayerProvider,V as Metadata,Di as PolygonSelector,io as RangeContext,qo as ReactEventContext,jt as ReactVaultContext,Or as Render3DModelStrategy,Gr as RenderAccompanyingCanvas,$r as RenderAnnotationStrategy,Ur as RenderAudioStrategy,zr as RenderComplexTimelineStrategy,br as RenderEmptyStrategy,Fr as RenderImageStrategy,Gn as RenderSvgEditorControls,qr as RenderTextualContentStrategy,Jr as RenderVideoStrategy,Zr as RenderYouTubeStrategy,L as ResourceProvider,Zt as ResourceReactContext,ni as SelectorControllerProvider,_n as SequenceThumbnails,Ao as SimpleViewerProvider,Lo as SimpleViewerReactContext,be as SingleCanvasThumbnail,gr as StrategyReactContext,Qr as ThumbnailFallbackImage,kr as TranslationProvider,wr as TransliterationProvider,eo as VaultProvider,F as ViewerPresetContext,_o as VirtualAnnotationProvider,no as VisibleCanvasReactContext,yo as authDetailsForResource,go as createAuthStateStore,ho as createProbe,zo as defaultEmitter,tr as emptyActions,nr as emptyStrategy,so as findAllCanvasesInRange,ao as findFirstCanvasFromRange,lo as findManifestSelectedRange,co as findSelectedRange,ir as flattenAnnotationPageIds,Cr as formatTime,lr as get3dStrategy,dr as getComplexTimelineStrategy,Ne as getDefaultAnnotationStyles,cr as getImageStrategy,uo as getManifestSequence,er as getParsedTargetSelector,fr as getRenderingStrategy,mr as getTextualContentStrategy,ur as getVideoStrategy,mo as getVisibleCanvasesFromCanvasId,po as hasAuth,xo as makeAccessServiceRequest,vo as makeAccessTokenRequest,jo as parseSpecificResource,Mt as svgThemes,or as unknownResponse,rr as unsupportedStrategy,Jo as useAnnotation,Zo as useAnnotationPage,ue as useAnnotationPageManager,Me as useAnnotationStyles,da as useAnnotationsAtTime,wo as useAuthActions,To as useAuthService,Po as useAuthStore,No as useAuthToken,Eo as useAuthTokens,w as useCanvas,va as useCanvasChoices,Sa as useCanvasClock,fo as useCanvasSequence,_r as useCanvasStartTime,ka as useCanvasSubset,Mr as useClosestLanguage,Ea as useCollection,Ar as useComplexTimeline,$o as useContextBridge,Lr as useCreateLocaleString,Ro as useCurrentAuth,Do as useCustomContextBridge,Ko as useDispatch,le as useEventEmitter,Ha as useEventListener,to as useExistingVault,Wa as useExternalCollection,oo as useExternalManifest,re as useExternalResource,Tr as useIIIFLanguage,G as useImage,Ve as useImageService,he as useImageServiceLoader,Qa as useImageTile,ko as useIsAuthEnabled,pe as useLoadImageService,Br as useLocaleString,D as useManifest,Kr as useMediaActions,Xr as useMediaElements,Vr as useMediaState,sr as usePaintables,O as usePaintingAnnotations,Be as usePolygonHelper,ae as useRange,vr as useRenderControls,pr as useRenderingStrategy,q as useResourceContext,Uo as useResourceEvents,ar as useResources,Bo as useSearchService,Ee as useSelectorController,ii as useSelectorEmitter,Te as useSelectorEvents,ai as useSelectorHelper,Ir as useSimpleMediaPlayer,se as useSimpleViewer,hr as useStrategy,ja as useStyleHelper,Go as useStyles,qe as useSvgEditor,ye as useThumbnail,Er as useTranslations,Rr as useTransliteration,P as useVault,Wr as useVaultEffect,W as useVaultSelector,Qo as useViewerPreset,Xo as useVirtualAnnotationPage,Yo as useVirtualAnnotationPageContext,ie as useVisibleCanvases};
1
+ import{$ as Oo,$a as ye,A as ho,Aa as hr,B as yo,Ba as yr,C as vo,Ca as vr,D as xo,Da as xr,E as So,Ea as Sr,F as bo,Fa as br,G as Co,Ga as Cr,H as Io,Ha as Ir,I as ko,Ia as kr,J as Po,Ja as Pr,K as wo,Ka as wr,L as Ro,La as Rr,M as To,Ma as Tr,N as Eo,Na as Er,O as No,Oa as Nr,P as Bo,Pa as Br,Q as Mo,Qa as Mr,R as Lo,Ra as Lr,S as Ho,Sa as M,T as Ao,Ta as ge,U as se,Ua as Hr,V as zo,Va as Ar,W as qo,Wa as zr,X as le,Xa as qr,Y as Wo,Ya as Wr,Z as Do,Za as Dr,_ as Fo,_a as he,a as Zt,aa as $o,ab as Fr,b as q,ba as Vo,bb as Or,c as L,ca as Ko,cb as $r,d as jt,da as Uo,db as Vr,e as eo,ea as Xo,eb as Kr,f as to,fa as Yo,fb as Ur,g as re,ga as ce,gb as Xr,h as oo,ha as F,hb as Yr,i as ro,ia as _o,ib as _r,j as ne,ja as Q,jb as Qr,k as P,ka as w,kb as Gr,l as W,la as me,lb as Jr,m as no,ma as Qo,mb as Zr,n as ie,na as Go,nb as ve,o as D,oa as Jo,p as io,pa as Zo,q as ao,qa as ir,r as so,ra as ue,s as lo,sa as ar,t as co,ta as de,u as mo,ua as fe,v as uo,va as pe,w as ae,wa as O,x as fo,xa as sr,y as po,ya as pr,z as go,za as gr}from"./chunk-IWRMLB3G.js";import{a as jo,b as er,c as tr,d as or,e as rr,f as nr,g as lr,h as cr,i as mr,j as ur,k as dr,l as fr}from"./chunk-XNDN34SQ.js";import{useCanvas as Ye}from"@atlas-viewer/atlas";import{forwardRef as _e,useImperativeHandle as Qe}from"react";import{Fragment as Ge,jsx as xe}from"react/jsx-runtime";var nn=_e(function({canvasId:t},o){let r=Ye(),n=ue(t||r?.id),a=P();return Qe(o,()=>n,[t,r]),!r||n.enabledPageIds.length===0?null:xe(Ge,{children:n.enabledPageIds.map(s=>xe(ve.RenderAnnotationPage,{page:a.get(s)},s))})});import{useMemo as je}from"react";import{useMemo as Je}from"react";import{Fragment as Ze,jsx as I,jsxs as $}from"react/jsx-runtime";function V({metadata:e=[],config:t,labelWidth:o=16,showEmptyMessage:r=!0,allowHtml:n,emptyFallback:a,classes:s={},emptyMessage:l="No metadata available",emptyValueFallback:d="No value",emptyLabelFallback:f="",separator:c,tableFooter:p,tableHeader:S}){let b=Je(()=>{let h=(t||[]).reduce((u,g)=>[...u,...g.keys],[]),m={};for(let u of e){let g=u&&u.label?Object.values(u.label):[];for(let i of g)if(i&&i.length&&(h.indexOf(`metadata.${i[0]}`)!==-1||h.length===0)&&u){let y=`metadata.${i[0]}`;m[y]=m[y]?m[y]:[],m[y].push(u);break}}return m},[t,e]);return Object.keys(b).length===0&&r?I(Ze,{children:a})||I("div",{className:s.empty,children:l}):t&&t.length?$("table",{className:s.container,children:[S,I("tbody",{children:t.map((h,m)=>{let u=[];for(let g of h.keys)for(let i of b[g]||[])u.push(I(M,{enableDangerouslySetInnerHTML:n,defaultText:d,separator:c,children:i.value},m+"__"+g));return u.length===0?null:$("tr",{className:s.row,children:[I("td",{className:s.label,style:o?{minWidth:o}:{},children:I(M,{enableDangerouslySetInnerHTML:n,separator:c,defaultText:f,children:h.label})}),I("td",{className:s.value,children:u})]},m)})}),p]}):$("table",{className:s.container,children:[S,I("tbody",{children:e&&e.length?e.map((h,m)=>h?$("tr",{className:s.row,children:[I("td",{className:s.label,style:o?{minWidth:o}:{},children:I(M,{enableDangerouslySetInnerHTML:n,defaultText:d,separator:c,children:h.label})}),I("td",{className:s.value,children:I(M,{enableDangerouslySetInnerHTML:n,defaultText:d,separator:c,children:h.value})})]},m):null):null}),p]})}import{jsx as et}from"react/jsx-runtime";function vn(e){let t=D(),o=w(),r=ae(),n=je(()=>{let a=t?.metadata||[],s=o?.metadata||[],l=r?.metadata||[];return[...a,...s,...l]},[t,o,r]);return et(V,{metadata:n,...e})}import{useEffect as nt,useState as it}from"react";import{createImageServiceRequest as tt,imageServiceRequestToString as ot}from"@iiif/parser/image-3";import{useMemo as rt}from"react";function G(e,t={},o=[]){return rt(()=>{if(!e)return null;let r=t.quality;e&&e.extraQualities&&t.quality&&(e.extraQualities.includes(t.quality)||(r="default"));let n=tt(e);return ot({identifier:n.identifier,server:n.server,scheme:n.scheme,type:"image",size:{max:!t.size?.width&&!t.size?.height,confined:!1,upscaled:!1,...t.size||{}},format:t.format||"jpg",region:t.region||{full:!0},rotation:t?.rotation?Number.isInteger(t.rotation)?{angle:t.rotation}:t.rotation:{angle:0},quality:r||"default",prefix:n.prefix,originalPath:n.originalPath})},[...o])}import{jsx as K}from"react/jsx-runtime";function at(e){let t=typeof e.src=="string"?e.src:e.src.id,o=he(),[r,n]=it(!1),a;if(t){let l=o.loadServiceSync({id:t});l&&(a=l)}!a&&!r&&o.loadService({id:t}).then(()=>{n(!0)});let s=G(a,{size:e.size,selector:e.region,rotation:e.rotation,format:e.format,region:e.region,quality:e.quality},[r,e.src,e.size,e.region,e.rotation,e.format,e.region,e.quality]);return nt(()=>()=>{n(!1)},[t]),s?K("img",{src:s,alt:e.alt,className:e.className,style:e.style}):K(st,{...e,fetchImageService:!1})}function st(e){if(e.fetchImageService)return K(at,{...e});let t=typeof e.src=="string"?{id:e.src,profile:"level0"}:e.src,o=G(t,{size:e.size,selector:e.region,rotation:e.rotation,format:e.format,region:e.region,quality:e.quality},[e.src,e.size,e.region,e.rotation,e.format,e.region,e.quality]);return o?K("img",{src:o,alt:e.alt,className:e.className,style:e.style}):null}import{jsx as lt}from"react/jsx-runtime";function Hn(e){let t=D();return lt(V,{metadata:t?.metadata||[],...e})}import{useLayoutEffect as ft,useRef as pt}from"react";import*as J from"react-lazy-load-image-component";import{getValue as ct}from"@iiif/helpers/i18n";import{Fragment as Se,jsx as R,jsxs as dt}from"react/jsx-runtime";var{LazyLoadComponent:mt}=J||J.default;function be(e){let{size:t,visible:o,classes:r,canvasId:n,figure:a}=e,s=t?.width||128,l=t?.height||t?.width||128,d=R(ut,{...e}),f=R(mt,{threshold:300,style:{height:l,width:s},visibleByDefault:o,children:n?R(ne,{canvas:n,children:d}):d});return a?R("figure",{className:r?.figure,children:f}):f}function ut({fallback:e,size:t,classes:o,showLabel:r,alt:n,dereference:a=!1}){let s=w(),l=t?.width||128,d=t?.height||t?.width||128,f=n||ct(s?.label)||"",c=ye({width:l,height:d,allowUnsafe:!0},a);return!c||c.type!=="fixed"?R(Se,{children:e}):dt(Se,{children:[R("div",{className:o?.imageWrapper,children:R("img",{className:o?.img,src:c.id,alt:f})}),r?R(M,{as:"figcaption",className:o?.label,children:s?.label}):null]})}import{jsx as H}from"react/jsx-runtime";function Yn({scrollBehaviour:e,dereference:t,flat:o,size:r,classes:n={},showLabel:a,figure:s,fallback:l}){let d=pt(null),{items:f,sequence:c,currentSequenceIndex:p,setSequenceIndex:S}=se(),b={row:n.selected?.row||n.row,item:n.selected?.item||n.item,figure:n.selected?.figure||n.figure,img:n.selected?.img||n.img,label:n.selected?.label||n.label,imageWrapper:n.selected?.imageWrapper||n.imageWrapper};ft(()=>{if(!d.current)return;let h=d.current.querySelector("[data-selected=true]");h&&h.scrollIntoView({behavior:e||"instant",block:"nearest",inline:"center"})},[p]);let C=[];for(let h of c){let m=[],u=c[p]===h;for(let g of h){let i=f[g];m.push(H("div",{className:u?b.item:n.item,children:H(be,{classes:u?b:n,canvasId:i.id,size:r,dereference:t,showLabel:a,figure:s,placeholder:H("div",{style:{height:128,width:128}}),fallback:l})},g))}if(o){C.push(m);continue}C.push(H("div",{onClick:g=>{S(c.indexOf(h))},"data-selected":u,className:u?b.row:n.row,children:m},h.join("-")))}return H("div",{ref:d,className:n.container,children:C})}import{Fragment as Ce,jsx as T,jsxs as Ie}from"react/jsx-runtime";var gt={draw:!0,polygon:!0,line:!0,lineBox:!0,square:!0,triangle:!0,hexagon:!0,circle:!0,delete:!0};function Gn({helper:e,showShapes:t,state:o,enabled:r=gt,classNames:n={},icons:a={}}){return Ie(Ce,{children:[t?Ie(Ce,{children:[r.draw&&T("button",{className:n.button,onClick:()=>{e.stamps.clear(),e.draw.enable()},"data-active":!o.lineMode&&!o.selectedStamp&&t&&o.drawMode,children:a.DrawIcon||"Draw"}),r.polygon&&T("button",{className:n.button,"data-active":!o.lineMode&&!o.selectedStamp&&t&&!o.drawMode,onClick:()=>{e.stamps.clear(),e.draw.disable(),e.modes.disableLineBoxMode(),e.modes.disableLineMode()},children:a.PolygonIcon||"Polygon"}),r.line&&T("button",{className:n.button,"data-active":o.lineMode&&!o.lineBoxMode,onClick:()=>{e.modes.enableLineMode()},children:a.LineIcon||"Line"}),r.lineBox&&T("button",{className:n.button,"data-active":o.lineBoxMode,onClick:()=>{e.modes.enableLineBoxMode()},children:a.LineBoxIcon||"LineBox"}),r.square&&T("button",{className:n.button,"data-active":o.selectedStamp?.id==="square",onClick:()=>{e.stamps.square()},children:a.SquareIcon||"Square"}),r.triangle&&T("button",{className:n.button,"data-active":o.selectedStamp?.id==="triangle",onClick:()=>{e.stamps.triangle()},children:a.TriangleIcon||"Triangle"}),r.hexagon&&T("button",{className:n.button,"data-active":o.selectedStamp?.id==="hexagon",onClick:()=>{e.stamps.hexagon()},children:a.HexagonIcon||"Hexagon"})]}):null,o.showBoundingBox&&r.delete&&T("button",{className:n.button,onClick:()=>e.key.down("Backspace"),children:a.DeleteForeverIcon||"Delete"})]})}import{createContext as ht,useCallback as ke,useContext as we,useEffect as Pe,useMemo as Z,useState as yt}from"react";import Re from"mitt";import{jsx as vt}from"react/jsx-runtime";var U=ht(Re());U.displayName="SelectorHelper";function ni({children:e}){return vt(U.Provider,{value:Z(()=>Re(),[]),children:e})}function ii(){return we(U)}function Te(e){let t=Ee(),[o,r]=yt(!1);Pe(()=>t.withSelector(e).on("highlight",()=>{r(!0)}),[t,e]),Pe(()=>t.withSelector(e).on("clear-highlight",()=>{r(!1)}),[t,e]);let n=ke(s=>{t.emit("click",{selectorId:e,event:s})},[e,t]),a=ke(s=>{t.emit("hover",{selectorId:e,event:s})},[e,t]);return{controller:t,onClick:n,onHover:a,isHighlighted:o}}function Ee(){let e=we(U);return Z(()=>({withSelector(t){return{on(o,r){let n=a=>{a&&a.selectorId===t&&r(a)};return e.on(o,n),()=>{e.off(o,n)}},emit(o,r){e.emit(o,{...r,selectorId:t})}}},on(t,o){return e.on(t,o),()=>{e.off(t,o)}},emit(t,o){e.emit(t,o)}}),[e])}function ai(){let e=Ee();return Z(()=>({withSelector(t){return{highlight(){e.emit("highlight",{selectorId:t})},clearHighlight(){e.emit("clear-highlight",{selectorId:t})},zoomTo(){e.emit("zoom-to",{selectorId:t})},addEventListener(o,r){return e.emit("event-listener",{selectorId:t,name:o,callback:r}),()=>{e.emit("remove-event-listener",{selectorId:t,name:o,callback:r})}},getImagePreview(){return new Promise((o,r)=>{e.emit("image-preview-request",{selectorId:t,resolve:o,reject:r})})},on(o,r){return e.withSelector(t).on(o,r)}}},highlight(t){e.emit("highlight",{selectorId:t})},clearHighlight(t){e.emit("clear-highlight",{selectorId:t})},zoomTo(t){e.emit("zoom-to",{selectorId:t})},addEventListener(t,o,r){return e.emit("event-listener",{selectorId:t,name:o,callback:r}),()=>{e.emit("remove-event-listener",{selectorId:t,name:o,callback:r})}},getImagePreview(t){return new Promise((o,r)=>{e.emit("image-preview-request",{selectorId:t,resolve:o,reject:r})})},on(t,o){return e.on(t,o)}}),[e])}import{createContext as xt,useContext as St,useMemo as bt}from"react";import{jsx as Ct}from"react/jsx-runtime";function Ne(){return{default:{backgroundColor:"rgba(0,0,0,0)",borderWidth:"2px",borderColor:"rgba(252,0,98, .5)"},highlighted:{backgroundColor:"rgba(75, 103, 225, 0.4)",borderWidth:"1px",borderColor:"rgba(75,103,225,0.99)"},hidden:{borderWidth:"0px",borderColor:"rgba(0,0,0,0)",backgroundColor:"rgba(0,0,0,0)",hidden:!0}}}var j=xt(Ne());j.displayName="AnnotationStyle";function Be(){return St(j)}function mi({theme:e,children:t}){let o=bt(()=>e||Ne(),[e]);return Ct(j.Provider,{value:o,children:t})}import{HTMLPortal as Tt,useAtlas as Et}from"@atlas-viewer/atlas";import{useEffect as Le,useRef as E,useState as He}from"react";import{useEffect as It,useMemo as kt,useState as Pt}from"react";import{createHelper as wt}from"polygon-editor";function Me(e,t,o){let[r,n]=Pt({}),a=kt(()=>wt(e,o),[]);return It(()=>(a.clock.start(t,n),()=>{a.clock.stop()}),[]),{state:r,helper:a}}import{createSvgHelpers as Rt}from"polygon-editor";import{Fragment as Ae,jsx as x,jsxs as ze}from"react/jsx-runtime";var N=Rt();function qe(e,t){let{image:o,currentShape:r,onChange:n,hideShapeLines:a}=e,s=E(),l=E(),d=E(),f=E(),c=E(),p=E(),S=E(),b=E(),[C,h]=He(null),[m,u]=He(!1),{helper:g,state:i}=Me(r,(v,k)=>{N.updateTransitionBoundingBox(l.current,v,k),N.updateBoundingBoxPolygon(s.current,v,k),N.updateTransitionShape(p.current,v,k),N.updateClosestLinePointTransform(f.current,v,k),N.updateSelectBox(d.current,v,k),N.updatePointLine(S.current,v,k),N.updateDrawPreview(c.current,v,k,3),N.updateLineBox(b.current,v),h(v.transitionDirection),u(v.transitionRotate)},n);Le(()=>{g.setShape(r||null)},t),Le(()=>{let v=()=>{g.modifiers.reset()};return document.addEventListener("mouseleave",v),()=>{document.removeEventListener("mouseleave",v)}},[]);let y=ze(Ae,{children:[x("marker",{id:"dot",viewBox:"0 0 10 10",refX:"5",refY:"5",markerWidth:"5",markerHeight:"5",children:x("circle",{cx:"5",cy:"5",r:"4",className:"marker"})}),x("marker",{id:"selected",viewBox:"0 0 10 10",refX:"5",refY:"5",markerWidth:"5",markerHeight:"5",children:x("circle",{cx:"5",cy:"5",r:"4",fill:"#FAFF00"})}),x("marker",{id:"resizer",viewBox:"0 0 10 10",refX:"5",refY:"5",markerWidth:"5",markerHeight:"5",children:x("rect",{width:"10",height:"10",stroke:"#FF0DCB",fill:"#fff",strokeWidth:2})})]}),B=r?r.open?"polyline":"polygon":null,oe=!i.showBoundingBox&&i.closestPoint!==null&&i.actionIntentType==="select-point",Ke=i.actionIntentType==="add-open-point",Ue=i.transitionIntentType==="split-line",_=i.transitioning&&i.selectedStamp&&i.transitionIntentType==="stamp-shape",Xe=r&&B?ze(Ae,{children:[x(B,{fill:!i.transitioning&&i.showBoundingBox?"rgba(255, 0, 0, .5)":"none",strokeWidth:_?0:2,stroke:a?"transparent":"#000",points:r.points.map(v=>v.join(",")).join(" "),vectorEffect:"non-scaling-stroke",markerStart:i.showBoundingBox?void 0:"url(#dot)",markerMid:i.showBoundingBox?void 0:"url(#dot)",markerEnd:i.showBoundingBox?void 0:"url(#dot)",style:{pointerEvents:"none"}}),i.lineBoxMode&&i.actionIntentType==="close-line-box"?x("polygon",{fill:"rgba(255, 0, 0, .4)",ref:b,stroke:"#000",strokeWidth:2,vectorEffect:"non-scaling-stroke"}):null,i.transitionIntentType==="draw-shape"&&i.transitioning?x("polyline",{ref:c,fill:"none",stroke:"rgba(255, 0, 0, .5)",strokeWidth:2,vectorEffect:"non-scaling-stroke"}):null,!i.showBoundingBox&&i.selectedPoints&&i.selectedPoints.length?x("polyline",{strokeWidth:2,vectorEffect:"non-scaling-stroke",stroke:"transparent",markerStart:"url(#selected)",markerMid:"url(#selected)",markerEnd:"url(#selected)",fill:"transparent",points:r.points.filter((v,k)=>i.selectedPoints?.includes(k)).map(v=>v.join(",")).join(" ")}):null,oe&&i.closestPoint!==null&&r.points[i.closestPoint]?x("polyline",{strokeWidth:2,vectorEffect:"non-scaling-stroke",stroke:"transparent",markerStart:"url(#selected)",markerMid:"url(#selected)",markerEnd:"url(#selected)",fill:"transparent",points:`${r.points[i.closestPoint][0]},${r.points[i.closestPoint][1]}`}):null,!i.transitioning&&(i.actionIntentType==="add-open-point"||i.actionIntentType==="close-shape"||i.actionIntentType==="close-shape-line")?x("polyline",{stroke:"#000",ref:S,strokeWidth:i.actionIntentType==="close-shape"?2:1,vectorEffect:"non-scaling-stroke"}):null,i.hasClosestLine&&(!i.transitionIntentType||i.transitionIntentType==="split-line")?x("g",{ref:f,children:x("polyline",{style:{opacity:.5},markerStart:"url(#dot)",points:"0,0 10,10",vectorEffect:"non-scaling-stroke",fill:"transparent",strokeWidth:2})}):null,i.transitioning?x(B,{ref:p,fill:r.open?"none":"rgba(255, 0, 0, .5)",stroke:"rgba(255, 0, 0, .5)",strokeWidth:r.open?2:0}):null,i.transitioning&&i.transitionIntentType==="select-multiple-points"?x("rect",{ref:d,fill:"rgba(255, 255, 255, .3)",strokeWidth:1,stroke:"rgba(0,0,0,.2)",vectorEffect:"non-scaling-stroke"}):null,i.showBoundingBox?null:x("g",{name:"controls",children:!1}),i.showBoundingBox&&!_?x("polygon",{ref:s,strokeWidth:2,stroke:"#FF0DCB",fill:"none",markerStart:"url(#resizer)",markerMid:"url(#resizer)",markerEnd:"url(#resizer)",vectorEffect:"non-scaling-stroke"}):null]}):null;return{helper:g,state:i,isAddingPoint:Ke,isSplitting:Ue,isStamping:_,isHoveringPoint:oe,transitionDirection:C,transitionRotate:m,defs:y,editor:Xe}}import{useEffect as ee}from"react";import{createPortal as Nt}from"react-dom";import{Fragment as We,jsx as A,jsxs as X}from"react/jsx-runtime";var Bt=[{name:"Default",outer:{borderWidth:4,borderColor:"rgba(255, 255, 255, .4)"},inner:{borderWidth:2,borderColor:"#000"}},{name:"High contrast",outer:{borderWidth:3,borderColor:"#fff"},inner:{borderWidth:1,borderColor:"#000"}},{name:"Lightsaber",outer:{borderWidth:"4",borderColor:"rgba(56,68,255,0.64)"},inner:{borderWidth:"2",borderColor:"#fff"}},{name:"Bright",outer:{borderWidth:"6",borderColor:"#25d527"},inner:{borderWidth:"3",borderColor:"#a916ff"}},{name:"pink",outer:{borderWidth:"4",borderColor:"#ff00ff"},inner:{borderWidth:"2",borderColor:"#ffffff"}},{name:"fine (dark)",outer:{borderWidth:"1",borderColor:"#000000"},inner:{}},{name:"fine (light)",outer:{borderWidth:"1",borderColor:"#FFF"},inner:{}}];function De(e){let t=e.theme||Bt[0],o=Et(),{image:r}=e,{helper:n,defs:a,editor:s,state:l,transitionDirection:d,isSplitting:f,transitionRotate:c,isHoveringPoint:p,isAddingPoint:S,isStamping:b}=qe({currentShape:e.shape||null,onChange:e.updateShape,image:e.image,hideShapeLines:!0},[]),C=i=>{n.pointer([[~~i.atlas.x,~~i.atlas.y]])};ee(()=>{let i=y=>{n.key.up(y.key)};return document.addEventListener("keyup",i),()=>{document.removeEventListener("keyup",i)}},[]),ee(()=>{let i=y=>{n.key.down(y.key)};return document.addEventListener("keydown",i),()=>{document.removeEventListener("keydown",i)}},[]),ee(()=>{let i=[];return d&&i.push(`atlas-cursor-${d}`),l.actionIntentType==="cut-line"&&l.modifiers?.Shift&&i.push("atlas-cursor-cut"),(p||l.transitionIntentType==="move-shape"||l.transitionIntentType==="move-point")&&i.push("atlas-cursor-move"),S&&i.push("atlas-cursor-crosshair"),f&&i.push("atlas-cursor-copy"),c&&i.push("atlas-cursor-rotate"),l.transitionIntentType==="draw-shape"&&i.push("atlas-cursor-draw"),o?.canvas&&o.canvas.classList.add(...i),()=>{o?.canvas&&o.canvas.classList.remove(...i)}},[o?.canvas,S,p,f,l.modifiers?.Shift,l.actionIntentType,l.transitionIntentType,d,c]);let h=e.shape&&e.shape?.points.length===0,m=e.renderControls?e.renderControls(n,l,h):null,u=document.getElementById(e.controlsHtmlId||"atlas-controls"),g="shape";return A(We,{children:X("world-object",{height:r.height,width:r.width,onMouseMove:C,onMouseDown:n.pointerDown,onMouseUp:n.pointerUp,onMouseLeave:n.blur,children:[e.shape?X(We,{children:[A(g,{open:e.shape.open,points:e.shape.points,relativeStyle:!0,style:b?{}:t.outer}),A(g,{open:e.shape.open,points:e.shape.points,relativeStyle:!0,style:b?{}:t.inner})]}):null,X(Tt,{relative:!0,interactive:!1,children:[A("div",{style:{position:"absolute",top:0,right:0,left:0,bottom:0},children:X("svg",{width:"100%",height:"100%",viewBox:`0 0 ${r.width} ${r.height}`,tabIndex:-1,children:[A("defs",{children:a}),s]})}),u?Nt(m,u,"controls"):null]})]})})}import{jsx as Fe}from"react/jsx-runtime";function Di(e){let t=w(),o=e.annotationBucket,r=e.readOnly,n=e.id,{onClick:a,isHighlighted:s}=Te(e.id),l=Be(),d=s?l.highlighted:l[o||"hidden"]||l.hidden;if(!t)return null;if(r){let f="shape",c=e.polygon,p=c.open;return c?Fe(f,{id:`shape-${n}`,points:c.points,open:p,onClick:a,relativeStyle:!0,target:{x:0,y:0,width:t.width,height:t.height},style:d}):null}return Fe(De,{image:t,shape:e.polygon||{id:e.id,open:!0,points:[]},updateShape:e.updatePolygon,theme:e.theme,controlsHtmlId:e.controlsHtmlId,renderControls:e.renderControls})}import{useMemo as Mt,useState as Lt}from"react";import{ErrorBoundary as Ht}from"react-error-boundary";import{jsx as z,jsxs as zt}from"react/jsx-runtime";function Gi({src:e,errorFallback:t,interactive:o,skipSizes:r,children:n,renderViewerControls:a,viewControlsDeps:s,fluid:l,x:d,y:f,...c}){let[p,S]=Lt(),b=t||ce,[C,h]=pe(),m=Mt(()=>{let g=h[e]?.status,i=C({id:e},{});return i?.height&&i.width&&g!=="loading"?{id:e,width:i.width,height:i.height,service:i,type:"Image",selector:{type:"BoxSelector",spatial:{x:0,y:0,width:i.width,height:i.height}},target:{type:"BoxSelector",spatial:{x:0,y:0,width:i.width,height:i.height}}}:null},[C,e,h]);if(Q(p&&a?"overlay":"none",`canvas-portal-controls-${e}`,F.Provider,a&&m?{value:p||null,children:a({image:m,images:[m],type:"images"})}:{},[e,m,p,...s||[]]),!m||!m.height||!m.width)return null;let u=l?void 0:c.homePosition?c.homePosition.width/c.homePosition.height:m.width/m.height;return console.log("here",u),z(Ht,{resetKeys:[],fallbackRender:g=>z(b,{...c,...g}),children:z(me,{...c,aspectRatio:u,containerProps:{style:{position:"relative"},...c.containerProps||{}},onCreated:g=>{S(g),c.onCreated&&c.onCreated(g)},children:zt(F.Provider,{value:p,children:[z(ge,{image:m,id:m.id,isStatic:!o,x:d,y:f},m.id),z(At,{viewerPreset:p,renderViewerControls:a,image:m,src:e,viewControlsDeps:s}),n]})})})}function At({viewerPreset:e,renderViewerControls:t,image:o,src:r,viewControlsDeps:n}){return Q(e&&t?"overlay":"none",`canvas-portal-controls-${r}`,F.Provider,t&&o?{value:e||null,children:t({image:o,images:[o],type:"images"})}:{},[r,e,...n||[]]),null}import{jsx as qt}from"react/jsx-runtime";function ea({annotation:e,children:t}){return qt(L,{value:{annotation:e},children:t})}import{jsx as Wt}from"react/jsx-runtime";function na({annotationPage:e,children:t}){return Wt(L,{value:{annotationPage:e},children:t})}import{jsx as Dt}from"react/jsx-runtime";function la({collection:e,children:t}){return Dt(L,{value:{collection:e},children:t})}function da(e,t={}){return O(t)}import{useCanvas as Ft}from"@atlas-viewer/atlas";import{useEffect as Ot,useMemo as te,useState as $t}from"react";function va({canvasId:e}={}){let t=Ft(),o=ie(),r=te(()=>e?[e]:t?[t.id]:o.map(f=>f.id),[e,t,o]),[n,a]=$t({}),s=le();Ot(()=>{let f=c=>{let p=c.partOf.canvasId;p&&a(S=>({...S,[p]:c.choice}))};return s.on("choice-change",f),()=>{s.off("choice-change",f)}},[]);let l=te(()=>{let f=[];for(let c of r){let p=n[c];p&&f.push({canvasId:c,choice:p})}return f},[r,n]),d=te(()=>({makeChoice:(f,c)=>{s.emit("make-choice",{choiceId:f,...c})}}),[s]);return{choices:l,actions:d}}function Sa(e,t=!1){}function ka(e){let o=q().manifest,r=e?e.map(n=>typeof n=="string"?n:n?.id):[];return W(n=>{let a=o?n.iiif.entities.Manifest[o]:void 0,s=a?.items||[];if(typeof e>"u")return s;let l=[];for(let d of a?.items||[])r.indexOf(d.id)!==-1&&l.push(d);return l},[r.join("/")])}import{useMemo as Vt}from"react";function Ea(e,t=[]){let{id:o,selector:r}=e,n=q(),a=o||n.collection,s=W(l=>a?l.iiif.entities.Collection[a]:void 0,[a]);return Vt(()=>{if(s)return r?r(s):s},[s,r,...t])}import{useEffect as Kt,useMemo as Ut}from"react";import{createEventsHelper as Xt}from"@iiif/helpers/events";function Ha(e,t,o,r,n=[]){let a=P(),s=Ut(()=>Xt(a),[a]);Kt(()=>{let l=e;return l?(s.addEventListener(l,t,o,r),()=>{s.removeEventListener(l,t,o)}):()=>{}},[s,e,t,...n])}function Wa(e,t){let{id:o,isLoaded:r,error:n,resource:a,requestId:s,cached:l}=re(e,t);return{id:o,isLoaded:r,error:n,manifest:a,requestId:s,cached:l}}import{getImageServices as Oe}from"@iiif/parser/image-3";import{useEffect as Yt,useMemo as $e,useState as Y}from"react";function Ve({cacheKey:e}={}){let t=w(),o=O(),r=P(),n=de(),a=fe(),[s,l]=Y(void 0),[d,f]=Y(!1),[c,p]=Y("idle"),[S,b]=Y(void 0),C=t?t.id:"undefined",h=$e(()=>{try{if(t&&o.length){let u=o[0],g=r.get(u.body[0]),y=Oe(g)[0];return y&&n(y,{width:y.width||t.width,height:y.height||t.height},!0)||void 0}}catch(u){console.error(u)}},[C,e,t]),m=c==="success"&&s?s:h;return Yt(()=>{(async()=>{try{if(t&&o.length){let u=o[0],g=r.get(u.body[0]),y=Oe(g)[0];if(!y)return;f(!0),p("loading");try{let B=await a(y,{width:y.width||t.width,height:y.height||t.height})||void 0;l(B),p("success"),f(!1)}catch(B){p("error"),b(B)}}}catch(u){p("error"),b(u)}})()},[C,e]),$e(()=>({data:m,isFetching:d,status:c,error:S}),[m,d,c,S])}function _a(){let e=Ve();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}}import{createStylesHelper as _t}from"@iiif/helpers/styles";import{useMemo as Qt}from"react";function ja(){let e=P();return Qt(()=>_t(e),[e])}export*from"@iiif/helpers/annotation-targets";export{ea as AnnotationContext,na as AnnotationPageContext,mi as AnnotationStyleProvider,Bo as Auth,Io as AuthProvider,So as AuthRContext,bo as AuthReactContext,Co as AuthReactContextActions,nn as CanvasAnnotations,ne as CanvasContext,ve as CanvasPanel,xr as CanvasStrategyProvider,Sr as CanvasWorldObject,la as CollectionContext,vn as CombinedMetadata,Hr as ComplexTimelineProvider,Vo as ContextBridge,yr as ControlsReactContext,De as CreateCustomShape,Fo as CustomContextBridge,Oo as CustomContextBridgeProvider,Wo as EventsProvider,st as Image,Gi as ImageService,Dr as ImageServiceLoaderContext,Ho as InnerViewerProvider,Pr as LanguageProvider,Nr as LanguageString,M as LocaleString,ro as ManifestContext,Hn as ManifestMetadata,Xr as MediaPlayerProvider,V as Metadata,Di as PolygonSelector,io as RangeContext,qo as ReactEventContext,jt as ReactVaultContext,Or as Render3DModelStrategy,Gr as RenderAccompanyingCanvas,$r as RenderAnnotationStrategy,Qr as RenderAudioStrategy,zr as RenderComplexTimelineStrategy,br as RenderEmptyStrategy,Fr as RenderImageStrategy,Gn as RenderSvgEditorControls,qr as RenderTextualContentStrategy,Jr as RenderVideoStrategy,Zr as RenderYouTubeStrategy,L as ResourceProvider,Zt as ResourceReactContext,ni as SelectorControllerProvider,Yn as SequenceThumbnails,Ao as SimpleViewerProvider,Lo as SimpleViewerReactContext,be as SingleCanvasThumbnail,gr as StrategyReactContext,_r as ThumbnailFallbackImage,kr as TranslationProvider,wr as TransliterationProvider,eo as VaultProvider,F as ViewerPresetContext,Yo as VirtualAnnotationProvider,no as VisibleCanvasReactContext,yo as authDetailsForResource,go as createAuthStateStore,ho as createProbe,zo as defaultEmitter,tr as emptyActions,nr as emptyStrategy,so as findAllCanvasesInRange,ao as findFirstCanvasFromRange,lo as findManifestSelectedRange,co as findSelectedRange,ir as flattenAnnotationPageIds,Cr as formatTime,lr as get3dStrategy,dr as getComplexTimelineStrategy,Ne as getDefaultAnnotationStyles,cr as getImageStrategy,uo as getManifestSequence,er as getParsedTargetSelector,fr as getRenderingStrategy,mr as getTextualContentStrategy,ur as getVideoStrategy,mo as getVisibleCanvasesFromCanvasId,po as hasAuth,xo as makeAccessServiceRequest,vo as makeAccessTokenRequest,jo as parseSpecificResource,Bt as svgThemes,or as unknownResponse,rr as unsupportedStrategy,Jo as useAnnotation,Zo as useAnnotationPage,ue as useAnnotationPageManager,Be as useAnnotationStyles,da as useAnnotationsAtTime,wo as useAuthActions,To as useAuthService,Po as useAuthStore,No as useAuthToken,Eo as useAuthTokens,w as useCanvas,va as useCanvasChoices,Sa as useCanvasClock,fo as useCanvasSequence,Yr as useCanvasStartTime,ka as useCanvasSubset,Br as useClosestLanguage,Ea as useCollection,Ar as useComplexTimeline,$o as useContextBridge,Lr as useCreateLocaleString,Ro as useCurrentAuth,Do as useCustomContextBridge,Ko as useDispatch,le as useEventEmitter,Ha as useEventListener,to as useExistingVault,Wa as useExternalCollection,oo as useExternalManifest,re as useExternalResource,Tr as useIIIFLanguage,G as useImage,Ve as useImageService,he as useImageServiceLoader,_a as useImageTile,ko as useIsAuthEnabled,pe as useLoadImageService,Mr as useLocaleString,D as useManifest,Kr as useMediaActions,Ur as useMediaElements,Vr as useMediaState,sr as usePaintables,O as usePaintingAnnotations,Me as usePolygonHelper,ae as useRange,vr as useRenderControls,pr as useRenderingStrategy,q as useResourceContext,Qo as useResourceEvents,ar as useResources,Mo as useSearchService,Ee as useSelectorController,ii as useSelectorEmitter,Te as useSelectorEvents,ai as useSelectorHelper,Ir as useSimpleMediaPlayer,se as useSimpleViewer,hr as useStrategy,ja as useStyleHelper,Go as useStyles,qe as useSvgEditor,ye as useThumbnail,Er as useTranslations,Rr as useTransliteration,P as useVault,Wr as useVaultEffect,W as useVaultSelector,_o as useViewerPreset,Uo as useVirtualAnnotationPage,Xo as useVirtualAnnotationPageContext,ie as useVisibleCanvases};
@@ -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;
@@ -92,6 +96,8 @@ type Single3DModelStrategy = {
92
96
  model: ExternalWebResource;
93
97
  choice?: ChoiceDescription;
94
98
  annotations?: AnnotationPageDescription;
99
+ annotation: AnnotationNormalized;
100
+ annotationId: string;
95
101
  };
96
102
  declare function get3dStrategy(canvas: CanvasNormalized, paintables: Paintables): RenderingStrategy;
97
103
 
@@ -103,9 +109,10 @@ type TextualContentStrategy = {
103
109
  };
104
110
  type TextContent = {
105
111
  type: 'Text';
106
- annotationId: string;
107
112
  text: InternationalString;
108
113
  target: SupportedTarget | null;
114
+ annotationId: string;
115
+ annotation: AnnotationNormalized;
109
116
  };
110
117
  declare function getTextualContentStrategy(canvas: CanvasNormalized, paintables: Paintables): RenderingStrategy;
111
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;
@@ -92,6 +96,8 @@ type Single3DModelStrategy = {
92
96
  model: ExternalWebResource;
93
97
  choice?: ChoiceDescription;
94
98
  annotations?: AnnotationPageDescription;
99
+ annotation: AnnotationNormalized;
100
+ annotationId: string;
95
101
  };
96
102
  declare function get3dStrategy(canvas: CanvasNormalized, paintables: Paintables): RenderingStrategy;
97
103
 
@@ -103,9 +109,10 @@ type TextualContentStrategy = {
103
109
  };
104
110
  type TextContent = {
105
111
  type: 'Text';
106
- annotationId: string;
107
112
  text: InternationalString;
108
113
  target: SupportedTarget | null;
114
+ annotationId: string;
115
+ annotation: AnnotationNormalized;
109
116
  };
110
117
  declare function getTextualContentStrategy(canvas: CanvasNormalized, paintables: Paintables): RenderingStrategy;
111
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 W=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var E=(e,t)=>{for(var r in t)v(e,r,{get:t[r],enumerable:!0})},Y=(e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of L(t))!M.call(e,o)&&o!==r&&v(e,o,{get:()=>t[o],enumerable:!(a=W(t,o))||a.enumerable});return e};var F=e=>Y(v({},"__esModule",{value:!0}),e);var j={};E(j,{emptyActions:()=>_,emptyStrategy:()=>P,getParsedTargetSelector:()=>S,getRenderingStrategy:()=>$,parseSpecificResource:()=>G,unknownResponse:()=>x,unsupportedStrategy:()=>m});module.exports=F(j);var R=require("@iiif/helpers");function G(e){return e.type==="SpecificResource"?[e.source,{selector:e.selector}]:[e,{selector:null}]}function S(e,t){let{selector:r,source:a}=(0,R.expandTarget)(t);if(a.id!==e.id)return[null,a];let o={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:o.spatial}:r:null,a]}var _={makeChoice:()=>{}},x={type:"unknown"},m=e=>({type:"unknown",reason:e,annotations:{pages:[]}}),P=(e,t)=>({type:"empty",width:e,height:t,annotations:{pages:[]},image:null,images:[]});var K=["model/gltf-binary"];function N(e,t){let a=t.items[0].resource;return a.format?K.indexOf(a.format)===-1?m(`3D format: ${a.format} is unsupported`):{type:"3d-model",model:a}:m("Unknown format")}function V(e,t){if(!e.duration)return m("No duration on canvas");if(t.items.length>1)return m("Only one audio source supported");let r=t.items[0]?.resource;return r?r.format?{type:"media",media:{annotationId:t.items[0].annotationId,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:[]}}:m("Audio does not have format"):m("Unknown audio")}var z=require("@iiif/parser/image-3");var k=require("@iiif/helpers/annotation-targets");function C(e,t,r){let a=[];for(let o of t.items){let s=o.resource&&o.resource.type==="SpecificResource"?o.resource.source:o.resource;if(!s.id)return m("No resource Identifier");let c;if(s.service){let g=(0,z.getImageServices)(s);g[0]&&(c=r(g[0],e))}let y={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}},[u,n]=S(e,o.target),i=e.id?.split("?")[0]||"";if(!(n.id===e.id||decodeURIComponent(n.id||"")===(e.id||"")||n.id===i||decodeURIComponent(n.id||"")===i))continue;let l=o.resource.width&&o.resource.height?{type:"BoxSelector",spatial:{x:0,y:0,width:o.resource.width,height:o.resource.height}}:void 0,p=o.resource.type==="SpecificResource"?(0,k.expandTarget)(o.resource):null;if(o.selector){let g=(0,k.expandTarget)({type:"SpecificResource",source:o.resource,selector:o.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:s.id,type:"Image",annotationId:o.annotationId,width:Number(u||d?s.width:e.width),height:Number(u||d?s.height:e.height),service:c,sizes:c&&c.sizes?c.sizes:s.width&&s.height?[{width:s.width,height:s.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)}}};a.push(f)}return{type:"images",image:a[0],images:a,choice:t.choice}}function B(e,t={},r){let a=e.language||r||"none";switch(e.type){case"TextualBody":{typeof e.value<"u"&&(t[a]=[e.value]);break}case"List":case"Composite":case"Choice":e.items&&e.items.forEach(o=>B(o,t,a))}return t}function I(e,t){let r=[];return t.items.forEach(a=>{if(a.resource){let[o]=S(e,a.target);r.push({type:"Text",annotationId:a.annotationId,text:B(a.resource),target:o})}}),{type:"textual-content",items:r}}var b=require("@iiif/helpers"),Q=/^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\/)|(?:(?:watch)?\?vi?=|&vi?=))([^#&?]*).*/;function w(e,t,r){let a=t.items.filter(d=>d.type==="video"),o=!1;if(e.duration||(o=!0),a.length>1)return m("Only one video source supported");let s=a[0]?.resource,c=!!(s.service||[]).find(d=>(d.profile||"").includes("youtube.com"));if(!c&&o)return m("Video does not have duration");if(!s)return m("Unknown video");if((!s.format||s.format==="text/html")&&!c)return m("Video does not have format");let y=[],u=r.get(e.annotations);for(let d of u){let f=r.get(d.items);for(let g of f)if((g.motivation?Array.isArray(g.motivation||"")?g.motivation:[g.motivation]:[]).includes("supplementing")){let A=r.get(g.body);for(let O of A){let h=O;if(h.type==="Choice")for(let U of h.items){let T=r.get(U);T.format==="text/vtt"&&y.push({id:T.id,type:"Text",format:"text/vtt",label:T.label,language:T.language})}else h.format==="text/vtt"&&y.push({id:h.id,type:"Text",format:"text/vtt",label:h.label,language:h.language})}}}let n=t.items[0],i={annotationId:t.items[0].annotationId,duration:e.duration,url:s.id,type:"Video",target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:s.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},l=(0,b.expandTarget)(n.target);l.selector&&l.selector.type==="TemporalBoxSelector"&&(i.target=l.selector);let{selector:p}=(0,b.parseSelector)(n.selector);if(p===null){let d=i.target.temporal.startTime,g=(i.target.temporal.endTime||e.duration)-d;i.selector={type:"TemporalSelector",temporal:{startTime:0,endTime:g}}}else p.type==="TemporalSelector"&&(i.selector=p);if(c){i.type="VideoYouTube";let d=s.id.match(Q);if(!d[1])return m("Video is not known youtube video");i.youTubeId=d[1]}return{type:"media",media:i,annotations:{pages:[]},captions:y}}function D(e,t,r,a){let o={type:"complex-timeline",items:[],keyframes:[],duration:e.duration||0},s={type:"complex-choice",items:[]};function c(n){n.choice&&(n.choice.type==="complex-choice"?s.items.push(...n.choice.items):s.items.push(n.choice))}for(let n of t.items){if(n.type==="image"){let i=C(e,{choice:null,allChoices:null,types:["image"],items:[n]},r);if(i.type==="images"){c(i),o.items.push(i.image);let l={id:i.image.annotationId,type:"enter",resourceType:"image",time:i.image.target?.temporal?.startTime||0};o.keyframes.push(l);let p={id:i.image.annotationId,type:"exit",resourceType:"image",time:i.image.target?.temporal?.endTime||e.duration||0};o.keyframes.push(p)}}if(n.type==="textualbody"){let i=I(e,{choice:null,allChoices:null,types:["textualbody"],items:[n]});if(i.type==="textual-content"){c(i);let l=i.items[0];o.items.push(l);let p=l.target,d={id:l.annotationId,type:"enter",resourceType:"text",time:p.temporal?.startTime||0};o.keyframes.push(d);let f={id:l.annotationId,type:"exit",resourceType:"text",time:p.temporal?.endTime||e.duration||0};o.keyframes.push(f)}}if(n.type==="video"){let i=w(e,{choice:null,allChoices:null,types:["video"],items:[n]},a);if(i.type==="media"){c(i);let l=i.media;o.items.push(l);let p={id:l.annotationId,type:"enter",resourceType:"video",time:l.target?.temporal?.startTime||0};o.keyframes.push(p);let d={id:l.annotationId,type:"exit",resourceType:"video",time:l.target?.temporal?.endTime||e.duration||0};o.keyframes.push(d)}}}o.keyframes.sort((n,i)=>n.time-i.time);let y=[],u=[];for(let n of o.keyframes){if(n.resourceType==="image"||n.resourceType==="text"){u.push(n);continue}if(n.type==="enter"){y.length===0&&(n.isPrime=!0),y.push(n),u.push(n);continue}if(n.type==="exit"&&(u.push(n),y=y.filter(i=>i.id!==n.id),y.length!==0)){let i=y[0],l={id:i.id,type:"change",isPrime:!0,resourceType:i.resourceType,time:n.time};u.push(l)}}return o.keyframes=u,s.items.length&&(o.choice=s),o}function $({canvas:e,paintables:t,supports:r,loadImageService:a,vault:o}){if(!e)return x;if(t.types.length===0)return r.indexOf("empty")!==-1?P(e.width,e.height):x;if(t.types.length!==1)if(t.types.length===2&&t.types.indexOf("text")!==-1)t.types=t.types.filter(c=>c!=="text");else return r.indexOf("complex-timeline")===-1?m("Complex timeline not supported"):D(e,t,a,o);let s=t.types[0];return s==="image"?r.indexOf("images")===-1?m("Image not supported"):C(e,t,a):s==="Model"||s==="model"?r.indexOf("3d-model")===-1?m("3D not supported"):N(e,t):s==="textualbody"?r.indexOf("textual-content")===-1?m("Textual content not supported"):I(e,t):s==="sound"||s==="audio"?r.indexOf("media")===-1?m("Media not supported"):V(e,t):s==="video"?r.indexOf("media")===-1?m("Media not supported"):w(e,t,o):x}
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
- import { m as UseRenderingStrategy, U as UnknownStrategy, R as RenderingStrategy, d as ImageServiceLoaderType } from './useRenderingStrategy-B03X9rQS.cjs';
2
- import { CanvasNormalized } from '@iiif/presentation-3-normalized';
3
- import { Paintables } from '@iiif/helpers/painting-annotations';
4
- import { TemporalBoxSelector, BoxSelector, SupportedTarget, Vault } from '@iiif/helpers';
5
- import { ContentResource, W3CAnnotationTarget, PointSelector } from '@iiif/presentation-3';
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';