react-iiif-vault 2.0.8 → 2.0.10

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
1
  export * from '@iiif/helpers/annotation-targets';
2
- import { S as SVGTheme, R as RenderContextProps, A as AudioComponentProps, V as VideoComponentProps, u as useSvgEditor, a as SimpleViewerContext, b as AtlasStore, c as AnnotationRequest, d as AnnotationResponse, e as AnnotationRequestOptions, f as SimpleViewerProps } from './index-VNY_GL30.cjs';
3
- export { h as AtlasStoreEvents, n as AtlasStoreProvider, k as AtlasStoreReactContext, g as CanvasPanel, C as CanvasPanelProps, i as CreateAtlasStoreProps, o as RenderAnnotation, q as RenderAnnotationPage, x as SimpleViewerActions, y as SimpleViewerActionsType, w as SimpleViewerReducerState, j as createAtlasStore, v as defaultSvgTheme, m as getAtlasStoreByName, p as polygonToTarget, r as requestToAnnotationResponse, t as useAtlasContextMenu, l as useAtlasStore, s as useContextMenuStore } from './index-VNY_GL30.cjs';
2
+ import { S as SVGTheme, R as RenderContextProps, A as AudioComponentProps, V as VideoComponentProps, u as useSvgEditor, a as SimpleViewerContext, b as AtlasStore, c as AnnotationRequest, d as AnnotationResponse, e as AnnotationRequestOptions, f as SimpleViewerProps } from './index-BAwkF_tl.cjs';
3
+ export { h as AtlasStoreEvents, n as AtlasStoreProvider, k as AtlasStoreReactContext, g as CanvasPanel, C as CanvasPanelProps, i as CreateAtlasStoreProps, o as RenderAnnotation, q as RenderAnnotationPage, x as SimpleViewerActions, y as SimpleViewerActionsType, w as SimpleViewerReducerState, j as createAtlasStore, v as defaultSvgTheme, m as getAtlasStoreByName, p as polygonToTarget, r as requestToAnnotationResponse, t as useAtlasContextMenu, l as useAtlasStore, s as useContextMenuStore } from './index-BAwkF_tl.cjs';
4
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
5
5
  import { BoxStyle, AtlasProps, Preset } from '@atlas-viewer/atlas';
6
6
  import * as React$1 from 'react';
7
7
  import React__default, { ReactNode, FunctionComponent, RefObject, Context } from 'react';
8
- 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, d as ImageServiceLoaderType, U as UnknownStrategy } from './useRenderingStrategy-Bg8-k9-n.cjs';
9
- export { i as AnnotationPageDescription, A as AudioSequence, n as ChoiceEvents, e as Single3DModelStrategy, S as SingleAudio, a as SingleVideo, h as SingleYouTubeVideo, k as TextContent, j as TextualContentStrategy, m as UseRenderingStrategy, o as UseRenderingStrategyOptions, V as VideoSequence, g as get3dStrategy, f as getImageStrategy, l as getTextualContentStrategy, u as useLoadImageService, p as useRenderingStrategy } from './useRenderingStrategy-Bg8-k9-n.cjs';
8
+ 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, d as ImageServiceLoaderType, U as UnknownStrategy } from './useRenderingStrategy-CoKE915F.cjs';
9
+ export { i as AnnotationPageDescription, A as AudioSequence, n as ChoiceEvents, e as Single3DModelStrategy, S as SingleAudio, a as SingleVideo, h as SingleYouTubeVideo, k as TextContent, j as TextualContentStrategy, m as UseRenderingStrategy, o as UseRenderingStrategyOptions, V as VideoSequence, g as get3dStrategy, f as getImageStrategy, l as getTextualContentStrategy, u as useLoadImageService, p as useRenderingStrategy } from './useRenderingStrategy-CoKE915F.cjs';
10
10
  import * as _iiif_helpers from '@iiif/helpers';
11
11
  import { ChoiceDescription, Paintables, ComplexChoice, SupportedSelector, SvgSelector, BoxSelector } from '@iiif/helpers';
12
12
  import * as polygon_editor from 'polygon-editor';
@@ -22,8 +22,8 @@ import { Emitter, EventType, Handler } from 'mitt';
22
22
  import { ImageServiceLoader, ImageCandidateRequest, ImageCandidate } from '@iiif/helpers/image-service';
23
23
  import { Vault, VaultOptions, NormalizedEntity, IIIFStore } from '@iiif/helpers/vault';
24
24
  import { CanvasNormalized, AnnotationNormalized, AnnotationPageNormalized, CollectionNormalized, ManifestNormalized, RangeNormalized } from '@iiif/presentation-3-normalized';
25
- import { C as CompatVault } from './utils-CMAqRpk_.cjs';
26
- export { e as emptyActions, c as emptyStrategy, a as getParsedTargetSelector, g as getRenderingStrategy, p as parseSpecificResource, u as unknownResponse, b as unsupportedStrategy } from './utils-CMAqRpk_.cjs';
25
+ import { C as CompatVault } from './utils-BKdiug6F.cjs';
26
+ export { e as emptyActions, c as emptyStrategy, a as getParsedTargetSelector, g as getRenderingStrategy, p as parseSpecificResource, u as unknownResponse, b as unsupportedStrategy } from './utils-BKdiug6F.cjs';
27
27
  import { VaultZustandStore } from '@iiif/helpers/vault/store';
28
28
  import * as _iiif_helpers_painting_annotations from '@iiif/helpers/painting-annotations';
29
29
  import * as _iiif_helpers_styles from '@iiif/helpers/styles';
package/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  export * from '@iiif/helpers/annotation-targets';
2
- import { S as SVGTheme, R as RenderContextProps, A as AudioComponentProps, V as VideoComponentProps, u as useSvgEditor, a as SimpleViewerContext, b as AtlasStore, c as AnnotationRequest, d as AnnotationResponse, e as AnnotationRequestOptions, f as SimpleViewerProps } from './index-BzqDQGvO.js';
3
- export { h as AtlasStoreEvents, n as AtlasStoreProvider, k as AtlasStoreReactContext, g as CanvasPanel, C as CanvasPanelProps, i as CreateAtlasStoreProps, o as RenderAnnotation, q as RenderAnnotationPage, x as SimpleViewerActions, y as SimpleViewerActionsType, w as SimpleViewerReducerState, j as createAtlasStore, v as defaultSvgTheme, m as getAtlasStoreByName, p as polygonToTarget, r as requestToAnnotationResponse, t as useAtlasContextMenu, l as useAtlasStore, s as useContextMenuStore } from './index-BzqDQGvO.js';
2
+ import { S as SVGTheme, R as RenderContextProps, A as AudioComponentProps, V as VideoComponentProps, u as useSvgEditor, a as SimpleViewerContext, b as AtlasStore, c as AnnotationRequest, d as AnnotationResponse, e as AnnotationRequestOptions, f as SimpleViewerProps } from './index-C3XrwwYg.js';
3
+ export { h as AtlasStoreEvents, n as AtlasStoreProvider, k as AtlasStoreReactContext, g as CanvasPanel, C as CanvasPanelProps, i as CreateAtlasStoreProps, o as RenderAnnotation, q as RenderAnnotationPage, x as SimpleViewerActions, y as SimpleViewerActionsType, w as SimpleViewerReducerState, j as createAtlasStore, v as defaultSvgTheme, m as getAtlasStoreByName, p as polygonToTarget, r as requestToAnnotationResponse, t as useAtlasContextMenu, l as useAtlasStore, s as useContextMenuStore } from './index-C3XrwwYg.js';
4
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
5
5
  import { BoxStyle, AtlasProps, Preset } from '@atlas-viewer/atlas';
6
6
  import * as React$1 from 'react';
7
7
  import React__default, { ReactNode, FunctionComponent, RefObject, Context } from 'react';
8
- 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, d as ImageServiceLoaderType, U as UnknownStrategy } from './useRenderingStrategy-Bg8-k9-n.js';
9
- export { i as AnnotationPageDescription, A as AudioSequence, n as ChoiceEvents, e as Single3DModelStrategy, S as SingleAudio, a as SingleVideo, h as SingleYouTubeVideo, k as TextContent, j as TextualContentStrategy, m as UseRenderingStrategy, o as UseRenderingStrategyOptions, V as VideoSequence, g as get3dStrategy, f as getImageStrategy, l as getTextualContentStrategy, u as useLoadImageService, p as useRenderingStrategy } from './useRenderingStrategy-Bg8-k9-n.js';
8
+ 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, d as ImageServiceLoaderType, U as UnknownStrategy } from './useRenderingStrategy-CoKE915F.js';
9
+ export { i as AnnotationPageDescription, A as AudioSequence, n as ChoiceEvents, e as Single3DModelStrategy, S as SingleAudio, a as SingleVideo, h as SingleYouTubeVideo, k as TextContent, j as TextualContentStrategy, m as UseRenderingStrategy, o as UseRenderingStrategyOptions, V as VideoSequence, g as get3dStrategy, f as getImageStrategy, l as getTextualContentStrategy, u as useLoadImageService, p as useRenderingStrategy } from './useRenderingStrategy-CoKE915F.js';
10
10
  import * as _iiif_helpers from '@iiif/helpers';
11
11
  import { ChoiceDescription, Paintables, ComplexChoice, SupportedSelector, SvgSelector, BoxSelector } from '@iiif/helpers';
12
12
  import * as polygon_editor from 'polygon-editor';
@@ -22,8 +22,8 @@ import { Emitter, EventType, Handler } from 'mitt';
22
22
  import { ImageServiceLoader, ImageCandidateRequest, ImageCandidate } from '@iiif/helpers/image-service';
23
23
  import { Vault, VaultOptions, NormalizedEntity, IIIFStore } from '@iiif/helpers/vault';
24
24
  import { CanvasNormalized, AnnotationNormalized, AnnotationPageNormalized, CollectionNormalized, ManifestNormalized, RangeNormalized } from '@iiif/presentation-3-normalized';
25
- import { C as CompatVault } from './utils-CHozUicY.js';
26
- export { e as emptyActions, c as emptyStrategy, a as getParsedTargetSelector, g as getRenderingStrategy, p as parseSpecificResource, u as unknownResponse, b as unsupportedStrategy } from './utils-CHozUicY.js';
25
+ import { C as CompatVault } from './utils-CmwQWQLa.js';
26
+ export { e as emptyActions, c as emptyStrategy, a as getParsedTargetSelector, g as getRenderingStrategy, p as parseSpecificResource, u as unknownResponse, b as unsupportedStrategy } from './utils-CmwQWQLa.js';
27
27
  import { VaultZustandStore } from '@iiif/helpers/vault/store';
28
28
  import * as _iiif_helpers_painting_annotations from '@iiif/helpers/painting-annotations';
29
29
  import * as _iiif_helpers_styles from '@iiif/helpers/styles';
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{$ as Jr,$a as Uo,A as Nr,Aa as Io,Ab as dn,B as Ar,Ba as Ro,Bb as gn,C as kr,Ca as Co,Cb as hn,D as Mr,Da as Po,Db as yn,E as Lr,Ea as Pe,Eb as vn,F as Hr,Fa as To,Fb as bn,G as zr,Ga as wo,Gb as xn,H as Br,Ha as Eo,Hb as Sn,I as Fr,Ia as qo,Ib as In,J as Or,Ja as No,Jb as qn,K as Vr,Ka as Ao,Kb as ke,L as Wr,La as ko,Lb as Nn,M as Dr,Ma as Mo,Mb as Me,N as _r,Na as Lo,Nb as B,O as Ur,Oa as Ho,Ob as An,P as $r,Pa as zo,Pb as Bn,Q as Xr,Qa as Bo,Qb as Fn,R as Kr,Ra as Fo,Rb as On,S as Gr,Sa as Te,Sb as He,T as Qr,Ta as we,Tb as ze,U as be,Ua as Oo,Ub as Be,V as Yr,Va as Vo,W as Zr,Wa as Wo,X as jr,Xa as Do,Y as G,Ya as Ee,Z as xe,Za as qe,_ as Se,_a as _o,a as gr,aa as eo,ab as $o,b as $,ba as to,bb as Xo,c as z,ca as Ie,cb as Ko,d as pe,da as Re,db as Go,e as hr,ea as ro,eb as Qo,f as de,fa as oo,fb as Yo,g as T,ga as w,gb as Zo,h as X,ha as no,hb as jo,i as yr,ia as io,ib as L,j as ge,ja as ao,jb as Ne,k as he,ka as Ce,kb as Jo,l as K,la as so,lb as en,m as ye,ma as co,mb as ae,n as vr,na as lo,nb as tn,o as br,oa as uo,ob as rn,p as xr,pa as E,pb as on,q as Sr,qa as mo,qb as nn,r as Ir,ra as fo,rb as an,s as Rr,sa as po,sb as sn,t as Cr,ta as go,tb as cn,u as Pr,ua as ho,ub as ln,v as Tr,va as yo,vb as un,w as ve,wa as vo,wb as mn,x as wr,xa as bo,xb as Ae,y as Er,ya as xo,yb as fn,z as qr,za as So,zb as pn}from"./chunk-ICQYS35G.js";import"./chunk-UNH7HXGJ.js";import{a as Rn,b as Cn,c as Pn,d as Tn,e as wn,f as En,g as kn,h as Mn,i as Ln,j as Hn,k as zn,l as Le}from"./chunk-FBET7GLW.js";export*from"@iiif/helpers/annotation-targets";import{useEffect as gt}from"react";import{useCallback as Fe,useEffect as pt,useRef as dt,useState as Q}from"react";import{useStore as F}from"zustand";function Oe(e){let[t,r]=Q(0),o=w(),n=F(o,h=>h.tool.enabled),i=F(o,h=>h.tool.requestId),a=F(o,h=>h.getRequestId),c=F(o,h=>h.requestAnnotation),g=F(o,h=>h.completeRequest),m=F(o,h=>h.cancelRequest),s=dt(e?.onSuccess);s.current=e?.onSuccess;let[b,x]=Q(!1),[S,l]=Q(null),[f,v]=Q(null),u=n&&i!==f,y=n&&i===f,p=Fe(async(h,C)=>{if(f){let M=s.current;x(!0);let q=await c(h,{...C,requestId:f});if(q)return M?.(q),r(A=>A+1),x(!1),l(q),q;let H={id:f,cancelled:!0,...Re(h)};return M?.(H),l(H),r(A=>A+1),x(!1),H}return null},[c,f]),d=Fe(()=>{l(null),x(!1)},[]);return pt(()=>{let h=a();return v(h.requestId),()=>{h.clear()}},[t]),{id:t,busy:u,isPending:b,isActive:y,requestId:f,requestAnnotation:p,cancelRequest:()=>f?m(f):void 0,completeRequest:()=>f?g(f):void 0,reset:d,data:S}}var Kn=[{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 Ve(e){let{id:t,data:r,requestAnnotation:o,cancelRequest:n,isPending:i}=Oe({onSuccess:a=>{e.updateShape(a.polygon)}});return gt(()=>(o({type:"polygon",open:e.shape?.open,points:e.shape?.points}),()=>{n()}),[]),null}import{createContext as ht,useCallback as We,useContext as _e,useEffect as De,useMemo as se,useState as yt}from"react";import Ue from"mitt";import{jsx as vt}from"react/jsx-runtime";var Y=ht(Ue());Y.displayName="SelectorHelper";function ei({children:e}){return vt(Y.Provider,{value:se(()=>Ue(),[]),children:e})}function ti(){return _e(Y)}function $e(e){let t=Xe(),[r,o]=yt(!1);De(()=>t.withSelector(e).on("highlight",()=>{o(!0)}),[t,e]),De(()=>t.withSelector(e).on("clear-highlight",()=>{o(!1)}),[t,e]);let n=We(a=>{t.emit("click",{selectorId:e,event:a})},[e,t]),i=We(a=>{t.emit("hover",{selectorId:e,event:a})},[e,t]);return{controller:t,onClick:n,onHover:i,isHighlighted:r}}function Xe(){let e=_e(Y);return se(()=>({withSelector(t){return{on(r,o){let n=i=>{i&&i.selectorId===t&&o(i)};return e.on(r,n),()=>{e.off(r,n)}},emit(r,o){e.emit(r,{...o,selectorId:t})}}},on(t,r){return e.on(t,r),()=>{e.off(t,r)}},emit(t,r){e.emit(t,r)}}),[e])}function ri(){let e=Xe();return se(()=>({withSelector(t){return{highlight(){e.emit("highlight",{selectorId:t})},clearHighlight(){e.emit("clear-highlight",{selectorId:t})},zoomTo(){e.emit("zoom-to",{selectorId:t})},addEventListener(r,o){return e.emit("event-listener",{selectorId:t,name:r,callback:o}),()=>{e.emit("remove-event-listener",{selectorId:t,name:r,callback:o})}},getImagePreview(){return new Promise((r,o)=>{e.emit("image-preview-request",{selectorId:t,resolve:r,reject:o})})},on(r,o){return e.withSelector(t).on(r,o)}}},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,r,o){return e.emit("event-listener",{selectorId:t,name:r,callback:o}),()=>{e.emit("remove-event-listener",{selectorId:t,name:r,callback:o})}},getImagePreview(t){return new Promise((r,o)=>{e.emit("image-preview-request",{selectorId:t,resolve:r,reject:o})})},on(t,r){return e.on(t,r)}}),[e])}import{jsx as Ke}from"react/jsx-runtime";function mi(e){let t=E(),r=e.annotationBucket,o=e.readOnly,n=e.id,{onClick:i,isHighlighted:a}=$e(e.id),c=Ce(),g=a?c.highlighted:c[r||"hidden"]||c.hidden;if(!t)return null;if(o){let m="shape",s=e.polygon,b=s.open;return s?Ke(m,{id:`shape-${n}`,points:s.points,open:b,onClick:i,relativeStyle:!0,target:{x:0,y:0,width:t.width,height:t.height},style:g}):null}return Ke(Ve,{image:t,shape:e.polygon||{id:e.id,open:!0,points:[]},updateShape:e.updatePolygon,theme:e.theme,controlsHtmlId:e.controlsHtmlId,renderControls:e.renderControls})}import{useCanvas as bt}from"@atlas-viewer/atlas";import{forwardRef as xt,useImperativeHandle as St}from"react";import{Fragment as It,jsx as Ge}from"react/jsx-runtime";var bi=xt(function({canvasId:t},r){let o=bt(),n=ke(t||o?.id),i=T();return St(r,()=>n,[t,o]),!o||n.enabledPageIds.length===0?null:Ge(It,{children:n.enabledPageIds.map(a=>Ge(Be.RenderAnnotationPage,{page:i.get(a)},a))})});import{useMemo as Pt}from"react";import{useMemo as Rt}from"react";import{Fragment as Ct,jsx as R,jsxs as Z}from"react/jsx-runtime";function j({metadata:e=[],config:t,labelWidth:r=16,showEmptyMessage:o=!0,allowHtml:n,emptyFallback:i,classes:a={},emptyMessage:c="No metadata available",emptyValueFallback:g="No value",emptyLabelFallback:m="",separator:s,tableFooter:b,tableHeader:x,customLabelRender:S,customValueRender:l}){let f=Rt(()=>{let u=(t||[]).reduce((p,d)=>[...p,...d.keys],[]),y={};for(let p of e){let d=p?.label?Object.values(p.label):[];for(let h of d)if(h?.length&&(u.indexOf(`metadata.${h[0]}`)!==-1||u.length===0)&&p){let C=`metadata.${h[0]}`;y[C]=y[C]?y[C]:[],y[C].push(p);break}}return y},[t,e]);return Object.keys(f).length===0&&o?R(Ct,{children:i})||R("div",{className:a.empty,children:c}):t?.length?Z("table",{className:a.container,children:[x,R("tbody",{children:t.map((u,y)=>{let p=[];for(let h of u.keys)for(let C of f[h]||[]){let M=R(L,{enableDangerouslySetInnerHTML:n,defaultText:g,separator:s,children:C.value},y+"__"+h);l?p.push(l(C,M)):p.push(M)}if(p.length===0)return null;let d=R(L,{enableDangerouslySetInnerHTML:n,separator:s,defaultText:m,children:u.label});return Z("tr",{className:a.row,children:[R("td",{className:a.label,style:r?{minWidth:r}:{},children:S?S(u.label,d):d}),R("td",{className:a.value,children:p})]},y)})}),b]}):Z("table",{className:a.container,children:[x,R("tbody",{children:e?.length?e.map((u,y)=>{if(!u)return null;let p=R(L,{enableDangerouslySetInnerHTML:n,defaultText:g,separator:s,children:u.label}),d=R(L,{enableDangerouslySetInnerHTML:n,defaultText:g,separator:s,children:u.value});return Z("tr",{className:a.row,children:[R("td",{className:a.label,style:r?{minWidth:r}:{},children:S?S(u.label,p):p}),R("td",{className:a.value,children:l?l(u,d):d})]},y)}):null}),b]})}import{jsx as Tt}from"react/jsx-runtime";function ki(e){let t=K(),r=E(),o=ve(),n=Pt(()=>{let i=t?.metadata||[],a=r?.metadata||[],c=o?.metadata||[];return[...i,...a,...c]},[t,r,o]);return Tt(j,{metadata:n,...e})}import{useEffect as Nt,useState as At}from"react";import{createImageServiceRequest as wt,imageServiceRequestToString as Et}from"@iiif/parser/image-3";import{useMemo as qt}from"react";function ce(e,t={},r=[]){return qt(()=>{if(!e)return null;let o=t.quality;e&&e.extraQualities&&t.quality&&(e.extraQualities.includes(t.quality)||(o="default"));let n=wt(e);return Et({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:o||"default",prefix:n.prefix,originalPath:n.originalPath})},[...r])}import{jsx as J}from"react/jsx-runtime";function kt(e){let t=typeof e.src=="string"?e.src:e.src.id,r=Te(),[o,n]=At(!1),i;if(t){let c=r.loadServiceSync({id:t});c&&(i=c)}!i&&!o&&r.loadService({id:t}).then(()=>{n(!0)});let a=ce(i,{size:e.size,selector:e.region,rotation:e.rotation,format:e.format,region:e.region,quality:e.quality},[o,e.src,e.size,e.region,e.rotation,e.format,e.region,e.quality]);return Nt(()=>()=>{n(!1)},[t]),a?J("img",{src:a,alt:e.alt,className:e.className,style:e.style}):J(Mt,{...e,fetchImageService:!1})}function Mt(e){if(e.fetchImageService)return J(kt,{...e});let t=typeof e.src=="string"?{id:e.src,profile:"level0"}:e.src,r=ce(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 r?J("img",{src:r,alt:e.alt,className:e.className,style:e.style}):null}import{useMemo as Lt,useState as Ht}from"react";import{ErrorBoundary as zt}from"react-error-boundary";import{jsx as O,jsxs as Ft}from"react/jsx-runtime";function ta({src:e,errorFallback:t,interactive:r,skipSizes:o,children:n,renderViewerControls:i,viewControlsDeps:a,fluid:c,x:g,y:m,...s}){let b=he(),[x,S]=Ht(),l=t||He,[f,v]=Me(),u=Lt(()=>{let p=v[e]?.status,d=f({id:e},{});return d?.height&&d.width&&p!=="loading"?{id:e,width:d.width,height:d.height,service:d,type:"Image",selector:{type:"BoxSelector",spatial:{x:0,y:0,width:d.width,height:d.height}},target:{type:"BoxSelector",spatial:{x:0,y:0,width:d.width,height:d.height}}}:null},[f,e,v]);if(!u||!u.height||!u.width)return null;let y=c?void 0:s.homePosition?s.homePosition.width/s.homePosition.height:u.width/u.height;return O(zt,{resetKeys:[],fallbackRender:p=>O(l,{...s,...p}),children:O(de,{vault:b,children:O(ze,{...s,aspectRatio:y,containerProps:{style:{position:"relative"},...s.containerProps||{}},onCreated:p=>{S(p),s.onCreated&&s.onCreated(p)},children:Ft(ae.Provider,{value:x,children:[O(Ne,{image:u,id:u.id,isStatic:!r,x:g,y:m},u.id),O(Bt,{viewerPreset:x,renderViewerControls:i,image:u,src:e,viewControlsDeps:a}),n]})})})})}function Bt({viewerPreset:e,renderViewerControls:t,image:r,src:o,viewControlsDeps:n}){return Pe(e&&t?"overlay":"none",`canvas-portal-controls-${o}`,ae.Provider,t&&r?{value:e||null,children:t({image:r,images:[r],type:"images"})}:{},[o,e,...n||[]]),null}import{jsx as Ot}from"react/jsx-runtime";function sa(e){let t=K();return Ot(j,{metadata:t?.metadata||[],...e})}import{useLayoutEffect as Ut,useRef as $t}from"react";import*as le from"react-lazy-load-image-component";import{getValue as Vt}from"@iiif/helpers/i18n";import{Fragment as Qe,jsx as k,jsxs as _t}from"react/jsx-runtime";var{LazyLoadComponent:Wt}=le||le.default;function Ye(e){let{size:t,visible:r,classes:o,canvasId:n,figure:i}=e,a=t?.width||128,c=t?.height||t?.width||128,g=k(Dt,{...e}),m=k(Wt,{threshold:300,style:{height:c,width:a},visibleByDefault:r,children:n?k(pe,{canvas:n,children:g}):g});return i?k("figure",{className:o?.figure,children:m}):m}function Dt({fallback:e,size:t,classes:r,showLabel:o,alt:n,dereference:i=!1}){let a=E(),c=t?.width||128,g=t?.height||t?.width||128,m=n||Vt(a?.label)||"",s=we({width:c,height:g,allowUnsafe:!0},i);return!s||s.type!=="fixed"?k(Qe,{children:e}):_t(Qe,{children:[k("div",{className:r?.imageWrapper,children:k("img",{className:r?.img,src:s.id,alt:m})}),o?k(L,{as:"figcaption",className:r?.label,children:a?.label}):null]})}import{jsx as W}from"react/jsx-runtime";function xa({scrollBehaviour:e,dereference:t,flat:r,size:o,classes:n={},showLabel:i,figure:a,fallback:c}){let g=$t(null),{items:m,sequence:s,currentSequenceIndex:b,setSequenceIndex:x}=be(),S={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};Ut(()=>{if(!g.current)return;let f=g.current.querySelector("[data-selected=true]");f&&f.scrollIntoView({behavior:e||"instant",block:"nearest",inline:"center"})},[b]);let l=[];for(let f of s){let v=[],u=s[b]===f;for(let y of f){let p=m[y];v.push(W("div",{className:u?S.item:n.item,children:W(Ye,{classes:u?S:n,canvasId:p.id,size:o,dereference:t,showLabel:i,figure:a,placeholder:W("div",{style:{height:128,width:128}}),fallback:c})},y))}if(r){l.push(v);continue}l.push(W("div",{onClick:y=>{x(s.indexOf(f))},"data-selected":u,className:u?S.row:n.row,children:v},f.join("-")))}return W("div",{ref:g,className:n.container,children:l})}import{useStore as ee}from"zustand";function Ze(){let e=w(),t=ee(e,i=>i.completeRequest),r=ee(e,i=>i.polygonState.currentTool),o=ee(e,i=>i.polygonState.selectedStamp),n=ee(e,i=>i.switchTool);return{completeRequest:t,currentTool:r,selectedStamp:o,switchTool:n}}import{Fragment as je,jsx as P,jsxs as Je}from"react/jsx-runtime";var Xt={draw:!0,polygon:!0,line:!0,lineBox:!0,box:!0,triangle:!0,hexagon:!0,circle:!0,delete:!0,pen:!0};function wa({showShapes:e=!0,enabled:t=Xt,classNames:r={},icons:o={}}){let{currentTool:n,switchTool:i,selectedStamp:a}=Ze();return Je(je,{children:[n,P("button",{className:r.button,onClick:i.pointer,"data-active":n==="pointer",children:o.PointerIcon||"Pointer"}),P("button",{className:r.button,onClick:i.hand,"data-active":n==="hand",children:o.HandIcon||"Hand"}),e?Je(je,{children:[t.box&&P("button",{className:r.button,onClick:i.box,"data-active":n==="box",children:o.BoxIcon||"Box"}),t.pen&&P("button",{className:r.button,onClick:i.pen,"data-active":n==="pen",children:o.PenIcon||"Pen"}),t.draw&&P("button",{className:r.button,onClick:i.draw,"data-active":n==="pencil",children:o.DrawIcon||"Draw"}),t.line&&P("button",{className:r.button,onClick:i.line,"data-active":n==="line",children:o.LineIcon||"Line"}),t.lineBox&&P("button",{className:r.button,onClick:i.lineBox,"data-active":n==="lineBox",children:o.LineBoxIcon||"LineBox"}),t.triangle&&P("button",{className:r.button,onClick:i.triangle,"data-active":n==="stamp"&&a?.id==="triangle",children:o.TriangleIcon||"Triangle"}),t.hexagon&&P("button",{className:r.button,onClick:i.hexagon,"data-active":n==="stamp"&&a?.id==="hexagon",children:o.HexagonIcon||"Hexagon"}),t.circle&&P("button",{className:r.button,"data-active":n==="stamp"&&a?.id==="circle",onClick:i.circle,children:o.CircleIcon||"Circle"})]}):null,t.delete&&P("button",{className:r.button,onClick:i.remove,children:o.DeleteForeverIcon||"Delete"})]})}import{jsx as Kt}from"react/jsx-runtime";function Aa({annotation:e,children:t}){return Kt(z,{value:{annotation:e},children:t})}import{jsx as Gt}from"react/jsx-runtime";function Ha({annotationPage:e,children:t}){return Gt(z,{value:{annotationPage:e},children:t})}import{jsx as Qt}from"react/jsx-runtime";function Oa({collection:e,children:t}){return Qt(z,{value:{collection:e},children:t})}function _a(e,t={}){return B(t)}import{useCanvas as Yt}from"@atlas-viewer/atlas";import{useEffect as Zt,useMemo as ue,useState as jt}from"react";function Qa({canvasId:e}={}){let t=Yt(),r=ge(),o=ue(()=>e?[e]:t?[t.id]:r.map(m=>m.id),[e,t,r]),[n,i]=jt({}),a=Ae();Zt(()=>{let m=s=>{let b=s.partOf.canvasId;b&&i(x=>({...x,[b]:s.choice}))};return a.on("choice-change",m),()=>{a.off("choice-change",m)}},[]);let c=ue(()=>{let m=[];for(let s of o){let b=n[s];b&&m.push({canvasId:s,choice:b})}return m},[o,n]),g=ue(()=>({makeChoice:(m,s)=>{a.emit("make-choice",{choiceId:m,...s})}}),[a]);return{choices:c,actions:g}}function Za(e,t=!1){}function ts(e){let r=$().manifest,o=e?e.map(n=>typeof n=="string"?n:n?.id):[];return X(n=>{let i=r?n.iiif.entities.Manifest[r]:void 0,a=i?.items||[];if(typeof e>"u")return a;let c=[];for(let g of i?.items||[])o.indexOf(g.id)!==-1&&c.push(g);return c},[o.join("/")])}import{useMemo as Jt}from"react";function as(e,t=[]){let{id:r,selector:o}=e,n=$(),i=r||n.collection,a=X(c=>i?c.iiif.entities.Collection[i]:void 0,[i]);return Jt(()=>{if(a)return o?o(a):a},[a,o,...t])}import{startTransition as er,useMemo as tr}from"react";import{useStore as et}from"zustand";function ms(){let e=w(),t=et(e,o=>o.completeRequest),r=et(e,o=>o.cancelRequest);return tr(()=>({saveAnnotation:()=>{er(()=>{t()})},cancelRequest:r}),[t,r])}import{useCallback as rr}from"react";import{useStore as me}from"zustand";function hs({requestId:e}={}){let t=w(),r=me(t,c=>c.metadata),o=me(t,c=>c.tool.requestId),n=e||o,i=me(t,c=>c.setMetadata),a=rr(c=>i(c,n||void 0),[i,n]);return[n?r[n]||{}:{},a]}import{useStore as or}from"zustand";function Ss(e){let t=w(),r=or(t,o=>o.tool.requestId);G("polygons.start-transition",o=>{e.requestId&&r!==e.requestId||e?.onStart?.(o.transitionIntent)},[r,e.requestId]),G("polygons.end-transition",o=>{e.requestId&&r!==e.requestId||e?.onEnd?.(o.transitionIntent,o.response)},[r,e.requestId]),G("polygons.transition",o=>{e.requestId&&r!==e.requestId||e?.onTransition?.(o.transitionIntent)},[r,e.requestId])}import{useEffect as nr,useMemo as ir}from"react";import{createEventsHelper as ar}from"@iiif/helpers/events";function Ts(e,t,r,o,n=[]){let i=T(),a=ir(()=>ar(i),[i]);nr(()=>{let c=e;return c?(a.addEventListener(c,t,r,o),()=>{a.removeEventListener(c,t,r)}):()=>{}},[a,e,t,...n])}function Ns(e,t){let{id:r,isLoaded:o,error:n,resource:i,requestId:a,cached:c}=ye(e,t);return{id:r,isLoaded:o,error:n,manifest:i,requestId:a,cached:c}}import{getImageServices as tt}from"@iiif/parser/image-3";import{useEffect as sr,useMemo as rt,useState as te}from"react";function ot({cacheKey:e}={}){let t=E(),r=B(),o=T(),n=Ee(),i=qe(),[a,c]=te(void 0),[g,m]=te(!1),[s,b]=te("idle"),[x,S]=te(void 0),l=t?t.id:"undefined",f=rt(()=>{try{if(t&&r.length){let u=r[0],y=o.get(u.body[0]),d=tt(y)[0];return d&&n(d,{width:d.width||t.width,height:d.height||t.height},!0)||void 0}}catch(u){console.error(u)}},[l,e,t]),v=s==="success"&&a?a:f;return sr(()=>{(async()=>{try{if(t&&r.length){let u=r[0],y=o.get(u.body[0]),d=tt(y)[0];if(!d)return;m(!0),b("loading");try{let h=await i(d,{width:d.width||t.width,height:d.height||t.height})||void 0;c(h),b("success"),m(!1)}catch(h){b("error"),S(h)}}}catch(u){b("error"),S(u)}})()},[l,e]),rt(()=>({data:v,isFetching:g,status:s,error:x}),[v,g,s,x])}function Vs(){let e=ot();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{useMemo as fe}from"react";import{createPaintingAnnotationsHelper as cr}from"@iiif/helpers";function Gs({supports:e=["empty","images","media","3d-model","textual-content","complex-timeline"]}={}){let t=T(),r=E(),o=B(),n=fe(()=>cr(t),[t]),i=fe(()=>n.getPaintables(o),[n,o]);return fe(()=>Le({canvas:r,loadImageService:a=>a,paintables:i,supports:e}),[r,i,e])}import{createStylesHelper as lr}from"@iiif/helpers/styles";import{useMemo as ur}from"react";function Js(){let e=T();return ur(()=>lr(e),[e])}import{useCallback as mr,useEffect as oe,useMemo as lt,useRef as ne,useState as ut}from"react";var re=[.6,.02,0,.75],nt=16,it={linear:[0,0,1,1],"ease-in":[.42,0,1,1],"ease-out":[0,0,.58,1],"ease-in-out":[.42,0,.58,1],"ease-in-cubic":re,"ease-out-cubic":[.215,.61,.355,1]};function at(e,t,r){let o=Math.max(0,Math.min(1,r));return{x:e.x+(t.x-e.x)*o,y:e.y+(t.y-e.y)*o,width:e.width+(t.width-e.width)*o,height:e.height+(t.height-e.height)*o}}function st(e,t){let r=[],o=e;for(let n of t)r.push({from:o,to:n}),o=n;return r}function D([e,t,r,o]){let n=3*e,i=3*(r-e)-n,a=1-n-i,c=3*t,g=3*(o-t)-c,m=1-c-g;function s(l){return((a*l+i)*l+n)*l}function b(l){return((m*l+g)*l+c)*l}function x(l){return(3*a*l+2*i)*l+n}function S(l,f=1e-6){let v=l;for(let p=0;p<8;p++){let d=s(v)-l;if(Math.abs(d)<f)return v;let h=x(v);if(Math.abs(h)<1e-6)break;v=v-d/h}let u=0,y=1;for(v=l;u<y;){let p=s(v);if(Math.abs(p-l)<f)return v;l>p?u=v:y=v,v=(y-u)*.5+u}return v}return l=>{if(l<=0)return 0;if(l>=1)return 1;let f=S(l);return b(f)}}function ct(e,t){if(!t||t.length===0)return{index:-1,t:0};if(Number.isNaN(e)||!isFinite(e))return{index:-1,t:0};if(e<0)return{index:-1,t:0};if(e>=t.length)return{index:t.length,t:0};let r=Math.floor(e),o=e-r;return{index:r,t:o}}function nc(e){let{initial:t,regions:r,progress:o,getProgress:n,enabled:i=!0,easing:a,reportEveryFrame:c=!1,pollInterval:g=nt,loop:m=!1,onEnter:s,onExit:b,onProgress:x,jumpTo:S}=e,l=lt(()=>st(t,r),[t,r]),[f,v]=ut(()=>-1),[u,y]=ut(0),p=ne(-1),d=ne(0),h=ne(!0),C=ne(()=>{});oe(()=>(h.current=!0,()=>{h.current=!1}),[]);let M=lt(()=>{if(!a)return D(re);if(typeof a=="function")return a;if(Array.isArray(a)&&a.length===4)return D(a);let I=it[a];return I?D(I):D(re)},[a]),q=mr(I=>{if(!(I<0||I>=l.length)&&(v(I),p.current=I,d.current=0,y(0),s))try{s(I)}catch{}},[l,s]);oe(()=>{C.current=q,S&&S(q)},[q,S]);function H(I){let{index:V,t:_}=ct(I,l),N=V;if(m&&l.length>0){let ie=l.length;N=(V%ie+ie)%ie}let U=M(_);if(N!==p.current){if(p.current>=0&&b)try{b(p.current)}catch{}if(N>=0&&s)try{s(N)}catch{}p.current=N,h.current&&v(N)}if(d.current=U,h.current&&(c||N!==f)&&y(U),x&&N>=0)try{x(N,U)}catch{}}oe(()=>{i&&typeof o=="number"&&H(o)},[o,i]),oe(()=>{if(!i||typeof n!="function")return;let I=null,V=()=>{try{let _=n();H(_)}catch{}};return V(),I=setInterval(V,g),()=>clearInterval(I)},[n,i,g]);let A=f>=0&&f<l.length?l[f]:void 0,ft=A?at(A.from,A.to,d.current):void 0;return{transitions:l,currentIndex:f,currentTransition:A,t:d.current,rect:ft,jumpTo:q}}import{useEffect as fr,useRef as mt,useState as pr}from"react";function sc(e,t={}){let{axis:r="y",offset:o=0,steps:n=1,enabled:i=!0}=t,[a,c]=pr(0),g=mt(-1),m=mt(null);return fr(()=>{if(!i||!e||!e.current)return;let s=e.current,b=()=>{let S=r==="y"?s.scrollTop:s.scrollLeft,l=r==="y"?s.clientHeight:s.clientWidth,v=(r==="y"?s.scrollHeight:s.scrollWidth)-l,y=(v<=0?0:Math.max(0,Math.min(1,(S+o)/v)))*n;y!==g.current&&(g.current=y,c(y)),m.current=null},x=()=>{m.current===null&&(m.current=requestAnimationFrame(b))};return s.addEventListener("scroll",x,{passive:!0}),b(),()=>{s.removeEventListener("scroll",x),m.current!==null&&cancelAnimationFrame(m.current)}},[e,r,o,n,i]),a}function lc(e,t){let{x:r,y:o,width:n,height:i}=e,{x:a,y:c}=t,{width:g,height:m}=t;return r+n>a&&r<a+g&&o+i>c&&o<c+m}import dr from"tiny-invariant";function gc(e,t){let r=e.boundingBox||Se(e.polygon);if(e.polygon&&!xe(e.polygon.points)){let o=e.target||Ie(e.polygon,t);return dr(o?.type==="SvgSelector"),{type:"SvgSelector",points:e.polygon.points,spatial:{unit:"pixel",...r||{}},svgShape:e.polygon.open?"polyline":"polygon",svg:o.value}}return{type:"BoxSelector",spatial:r}}export{Aa as AnnotationContext,Ha as AnnotationPageContext,so as AnnotationStyleProvider,io as AtlasStoreProvider,oo as AtlasStoreReactContext,$r as Auth,Br as AuthProvider,Lr as AuthRContext,Hr as AuthReactContext,zr as AuthReactContextActions,bi as CanvasAnnotations,pe as CanvasContext,Be as CanvasPanel,Fn as CanvasStrategyProvider,On as CanvasWorldObject,Oa as CollectionContext,ki as CombinedMetadata,Wo as ComplexTimelineProvider,yn as ContextBridge,qo as ControlsReactContext,Ve as CreateCustomShape,dn as CustomContextBridge,gn as CustomContextBridgeProvider,re as DEFAULT_BEZIER,nt as DEFAULT_POLL_INTERVAL,In as DefaultEditingTools,it as EASING_PRESETS,Zr as EventEmitterProvider,fn as EventsProvider,Mt as Image,ta as ImageService,Fo as ImageServiceLoaderContext,Gr as InnerViewerProvider,Uo as LanguageProvider,Qo as LanguageString,L as LocaleString,br as ManifestContext,sa as ManifestMetadata,Io as MediaPlayerProvider,j as Metadata,mi as PolygonSelector,xr as RangeContext,Yr as ReactEmitterContext,mn as ReactEventContext,hr as ReactVaultContext,go as RegionHighlight,Eo as Render3DModelStrategy,Ao as RenderAccompanyingCanvas,ho as RenderAnnotation,Sn as RenderAnnotationEditing,vo as RenderAnnotationPage,zo as RenderAnnotationStrategy,Vo as RenderAudioStrategy,Jo as RenderComplexTimelineStrategy,en as RenderEmptyStrategy,rn as RenderImageStrategy,wa as RenderSvgEditorControls,on as RenderTextualContentStrategy,nn as RenderVideoStrategy,an as RenderYouTubeStrategy,po as ResizeWorldItem,z as ResourceProvider,gr as ResourceReactContext,ei as SelectorControllerProvider,xa as SequenceThumbnails,Qr as SimpleViewerProvider,Kr as SimpleViewerReactContext,Ye as SingleCanvasThumbnail,To as StrategyReactContext,Oo as ThumbnailFallbackImage,_o as TranslationProvider,$o as TransliterationProvider,de as VaultProvider,ae as ViewerPresetContext,Ho as VirtualAnnotationProvider,yr as VisibleCanvasReactContext,gc as annotationResponseToSelector,Ar as authDetailsForResource,st as buildTransitions,ro as createAtlasStore,qr as createAuthStateStore,Nr as createProbe,D as cubicBezierEasing,un as defaultEmitter,cn as defaultSvgTheme,Pn as emptyActions,En as emptyStrategy,Ir as findAllCanvasesInRange,Sr as findFirstCanvasFromRange,Rr as findManifestSelectedRange,Cr as findSelectedRange,qn as flattenAnnotationPageIds,Co as formatTime,kn as get3dStrategy,no as getAtlasStoreByName,zn as getComplexTimelineStrategy,ao as getDefaultAnnotationStyles,Mn as getImageStrategy,Tr as getManifestSequence,Cn as getParsedTargetSelector,Le as getRenderingStrategy,ct as getStepFromProgress,Ln as getTextualContentStrategy,Hn as getVideoStrategy,Pr as getVisibleCanvasesFromCanvasId,Er as hasAuth,at as interpolateRect,eo as isBoxSelector,xe as isRectangle,Jr as isSvgSelector,Mr as makeAccessServiceRequest,kr as makeAccessTokenRequest,Rn as parseSpecificResource,Ie as polygonToTarget,Re as requestToAnnotationResponse,to as seraliseSupportedSelector,Kn as svgThemes,lc as targetIntersects,Tn as unknownResponse,wn as unsupportedStrategy,uo as useAnnotation,yo as useAnnotationPage,ke as useAnnotationPageManager,Ce as useAnnotationStyles,_a as useAnnotationsAtTime,bn as useAtlasContextMenu,w as useAtlasStore,Vr as useAuthActions,Dr as useAuthService,Or as useAuthStore,Ur as useAuthToken,_r as useAuthTokens,E as useCanvas,Qa as useCanvasChoices,Za as useCanvasClock,wr as useCanvasSequence,Ro as useCanvasStartTime,ts as useCanvasSubset,Yo as useClosestLanguage,as as useCollection,Do as useComplexTimeline,hn as useContextBridge,vn as useContextMenuStore,jo as useCreateLocaleString,ms as useCurrentAnnotationActions,hs as useCurrentAnnotationMetadata,xn as useCurrentAnnotationRequest,Ss as useCurrentAnnotationTransition,Wr as useCurrentAuth,pn as useCustomContextBridge,ko as useDispatch,jr as useEmitter,G as useEvent,Ae as useEventEmitter,Ts as useEventListener,he as useExistingVault,Ns as useExternalCollection,vr as useExternalManifest,ye as useExternalResource,Ko as useIIIFLanguage,ce as useImage,ot as useImageService,Te as useImageServiceLoader,Vs as useImageTile,Fr as useIsAuthEnabled,Me as useLoadImageService,Zo as useLocaleString,K as useManifest,xo as useMediaActions,So as useMediaElements,bo as useMediaState,An as usePaintables,B as usePaintingAnnotations,sn as usePolygonHelper,ve as useRange,lo as useRemoteStylesheet,No as useRenderControls,Bn as useRenderingStrategy,Oe as useRequestAnnotation,$ as useResourceContext,mo as useResourceEvents,Nn as useResources,Xr as useSearchService,Xe as useSelectorController,ti as useSelectorEmitter,$e as useSelectorEvents,ri as useSelectorHelper,Po as useSimpleMediaPlayer,be as useSimpleViewer,Gs as useStaticRenderingStrategy,wo as useStrategy,Js as useStyleHelper,fo as useStyles,co as useStylesheetStore,ln as useSvgEditor,Ze as useSvgEditorControls,we as useThumbnail,Go as useTranslations,Xo as useTransliteration,T as useVault,Bo as useVaultEffect,X as useVaultSelector,tn as useViewerPreset,sc as useViewportScroll,nc as useViewportTour,Mo as useVirtualAnnotationPage,Lo as useVirtualAnnotationPageContext,ge as useVisibleCanvases};
1
+ import{$ as Jr,$a as Uo,A as Nr,Aa as Io,Ab as dn,B as Ar,Ba as Ro,Bb as gn,C as kr,Ca as Co,Cb as hn,D as Mr,Da as Po,Db as yn,E as Lr,Ea as Pe,Eb as vn,F as Hr,Fa as To,Fb as bn,G as zr,Ga as wo,Gb as xn,H as Br,Ha as Eo,Hb as Sn,I as Fr,Ia as qo,Ib as In,J as Or,Ja as No,Jb as qn,K as Vr,Ka as Ao,Kb as ke,L as Wr,La as ko,Lb as Nn,M as Dr,Ma as Mo,Mb as Me,N as _r,Na as Lo,Nb as B,O as Ur,Oa as Ho,Ob as An,P as $r,Pa as zo,Pb as Bn,Q as Xr,Qa as Bo,Qb as Fn,R as Kr,Ra as Fo,Rb as On,S as Gr,Sa as Te,Sb as He,T as Qr,Ta as we,Tb as ze,U as be,Ua as Oo,Ub as Be,V as Yr,Va as Vo,W as Zr,Wa as Wo,X as jr,Xa as Do,Y as G,Ya as Ee,Z as xe,Za as qe,_ as Se,_a as _o,a as gr,aa as eo,ab as $o,b as $,ba as to,bb as Xo,c as z,ca as Ie,cb as Ko,d as pe,da as Re,db as Go,e as hr,ea as ro,eb as Qo,f as de,fa as oo,fb as Yo,g as T,ga as w,gb as Zo,h as X,ha as no,hb as jo,i as yr,ia as io,ib as L,j as ge,ja as ao,jb as Ne,k as he,ka as Ce,kb as Jo,l as K,la as so,lb as en,m as ye,ma as co,mb as ae,n as vr,na as lo,nb as tn,o as br,oa as uo,ob as rn,p as xr,pa as E,pb as on,q as Sr,qa as mo,qb as nn,r as Ir,ra as fo,rb as an,s as Rr,sa as po,sb as sn,t as Cr,ta as go,tb as cn,u as Pr,ua as ho,ub as ln,v as Tr,va as yo,vb as un,w as ve,wa as vo,wb as mn,x as wr,xa as bo,xb as Ae,y as Er,ya as xo,yb as fn,z as qr,za as So,zb as pn}from"./chunk-FA723YSS.js";import"./chunk-UNH7HXGJ.js";import{a as Rn,b as Cn,c as Pn,d as Tn,e as wn,f as En,g as kn,h as Mn,i as Ln,j as Hn,k as zn,l as Le}from"./chunk-P7XHGETS.js";export*from"@iiif/helpers/annotation-targets";import{useEffect as gt}from"react";import{useCallback as Fe,useEffect as pt,useRef as dt,useState as Q}from"react";import{useStore as F}from"zustand";function Oe(e){let[t,r]=Q(0),o=w(),n=F(o,h=>h.tool.enabled),i=F(o,h=>h.tool.requestId),a=F(o,h=>h.getRequestId),c=F(o,h=>h.requestAnnotation),g=F(o,h=>h.completeRequest),m=F(o,h=>h.cancelRequest),s=dt(e?.onSuccess);s.current=e?.onSuccess;let[b,x]=Q(!1),[S,l]=Q(null),[f,v]=Q(null),u=n&&i!==f,y=n&&i===f,p=Fe(async(h,C)=>{if(f){let M=s.current;x(!0);let q=await c(h,{...C,requestId:f});if(q)return M?.(q),r(A=>A+1),x(!1),l(q),q;let H={id:f,cancelled:!0,...Re(h)};return M?.(H),l(H),r(A=>A+1),x(!1),H}return null},[c,f]),d=Fe(()=>{l(null),x(!1)},[]);return pt(()=>{let h=a();return v(h.requestId),()=>{h.clear()}},[t]),{id:t,busy:u,isPending:b,isActive:y,requestId:f,requestAnnotation:p,cancelRequest:()=>f?m(f):void 0,completeRequest:()=>f?g(f):void 0,reset:d,data:S}}var Kn=[{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 Ve(e){let{id:t,data:r,requestAnnotation:o,cancelRequest:n,isPending:i}=Oe({onSuccess:a=>{e.updateShape(a.polygon)}});return gt(()=>(o({type:"polygon",open:e.shape?.open,points:e.shape?.points}),()=>{n()}),[]),null}import{createContext as ht,useCallback as We,useContext as _e,useEffect as De,useMemo as se,useState as yt}from"react";import Ue from"mitt";import{jsx as vt}from"react/jsx-runtime";var Y=ht(Ue());Y.displayName="SelectorHelper";function ei({children:e}){return vt(Y.Provider,{value:se(()=>Ue(),[]),children:e})}function ti(){return _e(Y)}function $e(e){let t=Xe(),[r,o]=yt(!1);De(()=>t.withSelector(e).on("highlight",()=>{o(!0)}),[t,e]),De(()=>t.withSelector(e).on("clear-highlight",()=>{o(!1)}),[t,e]);let n=We(a=>{t.emit("click",{selectorId:e,event:a})},[e,t]),i=We(a=>{t.emit("hover",{selectorId:e,event:a})},[e,t]);return{controller:t,onClick:n,onHover:i,isHighlighted:r}}function Xe(){let e=_e(Y);return se(()=>({withSelector(t){return{on(r,o){let n=i=>{i&&i.selectorId===t&&o(i)};return e.on(r,n),()=>{e.off(r,n)}},emit(r,o){e.emit(r,{...o,selectorId:t})}}},on(t,r){return e.on(t,r),()=>{e.off(t,r)}},emit(t,r){e.emit(t,r)}}),[e])}function ri(){let e=Xe();return se(()=>({withSelector(t){return{highlight(){e.emit("highlight",{selectorId:t})},clearHighlight(){e.emit("clear-highlight",{selectorId:t})},zoomTo(){e.emit("zoom-to",{selectorId:t})},addEventListener(r,o){return e.emit("event-listener",{selectorId:t,name:r,callback:o}),()=>{e.emit("remove-event-listener",{selectorId:t,name:r,callback:o})}},getImagePreview(){return new Promise((r,o)=>{e.emit("image-preview-request",{selectorId:t,resolve:r,reject:o})})},on(r,o){return e.withSelector(t).on(r,o)}}},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,r,o){return e.emit("event-listener",{selectorId:t,name:r,callback:o}),()=>{e.emit("remove-event-listener",{selectorId:t,name:r,callback:o})}},getImagePreview(t){return new Promise((r,o)=>{e.emit("image-preview-request",{selectorId:t,resolve:r,reject:o})})},on(t,r){return e.on(t,r)}}),[e])}import{jsx as Ke}from"react/jsx-runtime";function mi(e){let t=E(),r=e.annotationBucket,o=e.readOnly,n=e.id,{onClick:i,isHighlighted:a}=$e(e.id),c=Ce(),g=a?c.highlighted:c[r||"hidden"]||c.hidden;if(!t)return null;if(o){let m="shape",s=e.polygon,b=s.open;return s?Ke(m,{id:`shape-${n}`,points:s.points,open:b,onClick:i,relativeStyle:!0,target:{x:0,y:0,width:t.width,height:t.height},style:g}):null}return Ke(Ve,{image:t,shape:e.polygon||{id:e.id,open:!0,points:[]},updateShape:e.updatePolygon,theme:e.theme,controlsHtmlId:e.controlsHtmlId,renderControls:e.renderControls})}import{useCanvas as bt}from"@atlas-viewer/atlas";import{forwardRef as xt,useImperativeHandle as St}from"react";import{Fragment as It,jsx as Ge}from"react/jsx-runtime";var bi=xt(function({canvasId:t},r){let o=bt(),n=ke(t||o?.id),i=T();return St(r,()=>n,[t,o]),!o||n.enabledPageIds.length===0?null:Ge(It,{children:n.enabledPageIds.map(a=>Ge(Be.RenderAnnotationPage,{page:i.get(a)},a))})});import{useMemo as Pt}from"react";import{useMemo as Rt}from"react";import{Fragment as Ct,jsx as R,jsxs as Z}from"react/jsx-runtime";function j({metadata:e=[],config:t,labelWidth:r=16,showEmptyMessage:o=!0,allowHtml:n,emptyFallback:i,classes:a={},emptyMessage:c="No metadata available",emptyValueFallback:g="No value",emptyLabelFallback:m="",separator:s,tableFooter:b,tableHeader:x,customLabelRender:S,customValueRender:l}){let f=Rt(()=>{let u=(t||[]).reduce((p,d)=>[...p,...d.keys],[]),y={};for(let p of e){let d=p?.label?Object.values(p.label):[];for(let h of d)if(h?.length&&(u.indexOf(`metadata.${h[0]}`)!==-1||u.length===0)&&p){let C=`metadata.${h[0]}`;y[C]=y[C]?y[C]:[],y[C].push(p);break}}return y},[t,e]);return Object.keys(f).length===0&&o?R(Ct,{children:i})||R("div",{className:a.empty,children:c}):t?.length?Z("table",{className:a.container,children:[x,R("tbody",{children:t.map((u,y)=>{let p=[];for(let h of u.keys)for(let C of f[h]||[]){let M=R(L,{enableDangerouslySetInnerHTML:n,defaultText:g,separator:s,children:C.value},y+"__"+h);l?p.push(l(C,M)):p.push(M)}if(p.length===0)return null;let d=R(L,{enableDangerouslySetInnerHTML:n,separator:s,defaultText:m,children:u.label});return Z("tr",{className:a.row,children:[R("td",{className:a.label,style:r?{minWidth:r}:{},children:S?S(u.label,d):d}),R("td",{className:a.value,children:p})]},y)})}),b]}):Z("table",{className:a.container,children:[x,R("tbody",{children:e?.length?e.map((u,y)=>{if(!u)return null;let p=R(L,{enableDangerouslySetInnerHTML:n,defaultText:g,separator:s,children:u.label}),d=R(L,{enableDangerouslySetInnerHTML:n,defaultText:g,separator:s,children:u.value});return Z("tr",{className:a.row,children:[R("td",{className:a.label,style:r?{minWidth:r}:{},children:S?S(u.label,p):p}),R("td",{className:a.value,children:l?l(u,d):d})]},y)}):null}),b]})}import{jsx as Tt}from"react/jsx-runtime";function ki(e){let t=K(),r=E(),o=ve(),n=Pt(()=>{let i=t?.metadata||[],a=r?.metadata||[],c=o?.metadata||[];return[...i,...a,...c]},[t,r,o]);return Tt(j,{metadata:n,...e})}import{useEffect as Nt,useState as At}from"react";import{createImageServiceRequest as wt,imageServiceRequestToString as Et}from"@iiif/parser/image-3";import{useMemo as qt}from"react";function ce(e,t={},r=[]){return qt(()=>{if(!e)return null;let o=t.quality;e&&e.extraQualities&&t.quality&&(e.extraQualities.includes(t.quality)||(o="default"));let n=wt(e);return Et({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:o||"default",prefix:n.prefix,originalPath:n.originalPath})},[...r])}import{jsx as J}from"react/jsx-runtime";function kt(e){let t=typeof e.src=="string"?e.src:e.src.id,r=Te(),[o,n]=At(!1),i;if(t){let c=r.loadServiceSync({id:t});c&&(i=c)}!i&&!o&&r.loadService({id:t}).then(()=>{n(!0)});let a=ce(i,{size:e.size,selector:e.region,rotation:e.rotation,format:e.format,region:e.region,quality:e.quality},[o,e.src,e.size,e.region,e.rotation,e.format,e.region,e.quality]);return Nt(()=>()=>{n(!1)},[t]),a?J("img",{src:a,alt:e.alt,className:e.className,style:e.style}):J(Mt,{...e,fetchImageService:!1})}function Mt(e){if(e.fetchImageService)return J(kt,{...e});let t=typeof e.src=="string"?{id:e.src,profile:"level0"}:e.src,r=ce(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 r?J("img",{src:r,alt:e.alt,className:e.className,style:e.style}):null}import{useMemo as Lt,useState as Ht}from"react";import{ErrorBoundary as zt}from"react-error-boundary";import{jsx as O,jsxs as Ft}from"react/jsx-runtime";function ta({src:e,errorFallback:t,interactive:r,skipSizes:o,children:n,renderViewerControls:i,viewControlsDeps:a,fluid:c,x:g,y:m,...s}){let b=he(),[x,S]=Ht(),l=t||He,[f,v]=Me(),u=Lt(()=>{let p=v[e]?.status,d=f({id:e},{});return d?.height&&d.width&&p!=="loading"?{id:e,width:d.width,height:d.height,service:d,type:"Image",selector:{type:"BoxSelector",spatial:{x:0,y:0,width:d.width,height:d.height}},target:{type:"BoxSelector",spatial:{x:0,y:0,width:d.width,height:d.height}}}:null},[f,e,v]);if(!u||!u.height||!u.width)return null;let y=c?void 0:s.homePosition?s.homePosition.width/s.homePosition.height:u.width/u.height;return O(zt,{resetKeys:[],fallbackRender:p=>O(l,{...s,...p}),children:O(de,{vault:b,children:O(ze,{...s,aspectRatio:y,containerProps:{style:{position:"relative"},...s.containerProps||{}},onCreated:p=>{S(p),s.onCreated&&s.onCreated(p)},children:Ft(ae.Provider,{value:x,children:[O(Ne,{image:u,id:u.id,isStatic:!r,x:g,y:m},u.id),O(Bt,{viewerPreset:x,renderViewerControls:i,image:u,src:e,viewControlsDeps:a}),n]})})})})}function Bt({viewerPreset:e,renderViewerControls:t,image:r,src:o,viewControlsDeps:n}){return Pe(e&&t?"overlay":"none",`canvas-portal-controls-${o}`,ae.Provider,t&&r?{value:e||null,children:t({image:r,images:[r],type:"images"})}:{},[o,e,...n||[]]),null}import{jsx as Ot}from"react/jsx-runtime";function sa(e){let t=K();return Ot(j,{metadata:t?.metadata||[],...e})}import{useLayoutEffect as Ut,useRef as $t}from"react";import*as le from"react-lazy-load-image-component";import{getValue as Vt}from"@iiif/helpers/i18n";import{Fragment as Qe,jsx as k,jsxs as _t}from"react/jsx-runtime";var{LazyLoadComponent:Wt}=le||le.default;function Ye(e){let{size:t,visible:r,classes:o,canvasId:n,figure:i}=e,a=t?.width||128,c=t?.height||t?.width||128,g=k(Dt,{...e}),m=k(Wt,{threshold:300,style:{height:c,width:a},visibleByDefault:r,children:n?k(pe,{canvas:n,children:g}):g});return i?k("figure",{className:o?.figure,children:m}):m}function Dt({fallback:e,size:t,classes:r,showLabel:o,alt:n,dereference:i=!1}){let a=E(),c=t?.width||128,g=t?.height||t?.width||128,m=n||Vt(a?.label)||"",s=we({width:c,height:g,allowUnsafe:!0},i);return!s||s.type!=="fixed"?k(Qe,{children:e}):_t(Qe,{children:[k("div",{className:r?.imageWrapper,children:k("img",{className:r?.img,src:s.id,alt:m})}),o?k(L,{as:"figcaption",className:r?.label,children:a?.label}):null]})}import{jsx as W}from"react/jsx-runtime";function xa({scrollBehaviour:e,dereference:t,flat:r,size:o,classes:n={},showLabel:i,figure:a,fallback:c}){let g=$t(null),{items:m,sequence:s,currentSequenceIndex:b,setSequenceIndex:x}=be(),S={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};Ut(()=>{if(!g.current)return;let f=g.current.querySelector("[data-selected=true]");f&&f.scrollIntoView({behavior:e||"instant",block:"nearest",inline:"center"})},[b]);let l=[];for(let f of s){let v=[],u=s[b]===f;for(let y of f){let p=m[y];v.push(W("div",{className:u?S.item:n.item,children:W(Ye,{classes:u?S:n,canvasId:p.id,size:o,dereference:t,showLabel:i,figure:a,placeholder:W("div",{style:{height:128,width:128}}),fallback:c})},y))}if(r){l.push(v);continue}l.push(W("div",{onClick:y=>{x(s.indexOf(f))},"data-selected":u,className:u?S.row:n.row,children:v},f.join("-")))}return W("div",{ref:g,className:n.container,children:l})}import{useStore as ee}from"zustand";function Ze(){let e=w(),t=ee(e,i=>i.completeRequest),r=ee(e,i=>i.polygonState.currentTool),o=ee(e,i=>i.polygonState.selectedStamp),n=ee(e,i=>i.switchTool);return{completeRequest:t,currentTool:r,selectedStamp:o,switchTool:n}}import{Fragment as je,jsx as P,jsxs as Je}from"react/jsx-runtime";var Xt={draw:!0,polygon:!0,line:!0,lineBox:!0,box:!0,triangle:!0,hexagon:!0,circle:!0,delete:!0,pen:!0};function wa({showShapes:e=!0,enabled:t=Xt,classNames:r={},icons:o={}}){let{currentTool:n,switchTool:i,selectedStamp:a}=Ze();return Je(je,{children:[n,P("button",{className:r.button,onClick:i.pointer,"data-active":n==="pointer",children:o.PointerIcon||"Pointer"}),P("button",{className:r.button,onClick:i.hand,"data-active":n==="hand",children:o.HandIcon||"Hand"}),e?Je(je,{children:[t.box&&P("button",{className:r.button,onClick:i.box,"data-active":n==="box",children:o.BoxIcon||"Box"}),t.pen&&P("button",{className:r.button,onClick:i.pen,"data-active":n==="pen",children:o.PenIcon||"Pen"}),t.draw&&P("button",{className:r.button,onClick:i.draw,"data-active":n==="pencil",children:o.DrawIcon||"Draw"}),t.line&&P("button",{className:r.button,onClick:i.line,"data-active":n==="line",children:o.LineIcon||"Line"}),t.lineBox&&P("button",{className:r.button,onClick:i.lineBox,"data-active":n==="lineBox",children:o.LineBoxIcon||"LineBox"}),t.triangle&&P("button",{className:r.button,onClick:i.triangle,"data-active":n==="stamp"&&a?.id==="triangle",children:o.TriangleIcon||"Triangle"}),t.hexagon&&P("button",{className:r.button,onClick:i.hexagon,"data-active":n==="stamp"&&a?.id==="hexagon",children:o.HexagonIcon||"Hexagon"}),t.circle&&P("button",{className:r.button,"data-active":n==="stamp"&&a?.id==="circle",onClick:i.circle,children:o.CircleIcon||"Circle"})]}):null,t.delete&&P("button",{className:r.button,onClick:i.remove,children:o.DeleteForeverIcon||"Delete"})]})}import{jsx as Kt}from"react/jsx-runtime";function Aa({annotation:e,children:t}){return Kt(z,{value:{annotation:e},children:t})}import{jsx as Gt}from"react/jsx-runtime";function Ha({annotationPage:e,children:t}){return Gt(z,{value:{annotationPage:e},children:t})}import{jsx as Qt}from"react/jsx-runtime";function Oa({collection:e,children:t}){return Qt(z,{value:{collection:e},children:t})}function _a(e,t={}){return B(t)}import{useCanvas as Yt}from"@atlas-viewer/atlas";import{useEffect as Zt,useMemo as ue,useState as jt}from"react";function Qa({canvasId:e}={}){let t=Yt(),r=ge(),o=ue(()=>e?[e]:t?[t.id]:r.map(m=>m.id),[e,t,r]),[n,i]=jt({}),a=Ae();Zt(()=>{let m=s=>{let b=s.partOf.canvasId;b&&i(x=>({...x,[b]:s.choice}))};return a.on("choice-change",m),()=>{a.off("choice-change",m)}},[]);let c=ue(()=>{let m=[];for(let s of o){let b=n[s];b&&m.push({canvasId:s,choice:b})}return m},[o,n]),g=ue(()=>({makeChoice:(m,s)=>{a.emit("make-choice",{choiceId:m,...s})}}),[a]);return{choices:c,actions:g}}function Za(e,t=!1){}function ts(e){let r=$().manifest,o=e?e.map(n=>typeof n=="string"?n:n?.id):[];return X(n=>{let i=r?n.iiif.entities.Manifest[r]:void 0,a=i?.items||[];if(typeof e>"u")return a;let c=[];for(let g of i?.items||[])o.indexOf(g.id)!==-1&&c.push(g);return c},[o.join("/")])}import{useMemo as Jt}from"react";function as(e,t=[]){let{id:r,selector:o}=e,n=$(),i=r||n.collection,a=X(c=>i?c.iiif.entities.Collection[i]:void 0,[i]);return Jt(()=>{if(a)return o?o(a):a},[a,o,...t])}import{startTransition as er,useMemo as tr}from"react";import{useStore as et}from"zustand";function ms(){let e=w(),t=et(e,o=>o.completeRequest),r=et(e,o=>o.cancelRequest);return tr(()=>({saveAnnotation:()=>{er(()=>{t()})},cancelRequest:r}),[t,r])}import{useCallback as rr}from"react";import{useStore as me}from"zustand";function hs({requestId:e}={}){let t=w(),r=me(t,c=>c.metadata),o=me(t,c=>c.tool.requestId),n=e||o,i=me(t,c=>c.setMetadata),a=rr(c=>i(c,n||void 0),[i,n]);return[n?r[n]||{}:{},a]}import{useStore as or}from"zustand";function Ss(e){let t=w(),r=or(t,o=>o.tool.requestId);G("polygons.start-transition",o=>{e.requestId&&r!==e.requestId||e?.onStart?.(o.transitionIntent)},[r,e.requestId]),G("polygons.end-transition",o=>{e.requestId&&r!==e.requestId||e?.onEnd?.(o.transitionIntent,o.response)},[r,e.requestId]),G("polygons.transition",o=>{e.requestId&&r!==e.requestId||e?.onTransition?.(o.transitionIntent)},[r,e.requestId])}import{useEffect as nr,useMemo as ir}from"react";import{createEventsHelper as ar}from"@iiif/helpers/events";function Ts(e,t,r,o,n=[]){let i=T(),a=ir(()=>ar(i),[i]);nr(()=>{let c=e;return c?(a.addEventListener(c,t,r,o),()=>{a.removeEventListener(c,t,r)}):()=>{}},[a,e,t,...n])}function Ns(e,t){let{id:r,isLoaded:o,error:n,resource:i,requestId:a,cached:c}=ye(e,t);return{id:r,isLoaded:o,error:n,manifest:i,requestId:a,cached:c}}import{getImageServices as tt}from"@iiif/parser/image-3";import{useEffect as sr,useMemo as rt,useState as te}from"react";function ot({cacheKey:e}={}){let t=E(),r=B(),o=T(),n=Ee(),i=qe(),[a,c]=te(void 0),[g,m]=te(!1),[s,b]=te("idle"),[x,S]=te(void 0),l=t?t.id:"undefined",f=rt(()=>{try{if(t&&r.length){let u=r[0],y=o.get(u.body[0]),d=tt(y)[0];return d&&n(d,{width:d.width||t.width,height:d.height||t.height},!0)||void 0}}catch(u){console.error(u)}},[l,e,t]),v=s==="success"&&a?a:f;return sr(()=>{(async()=>{try{if(t&&r.length){let u=r[0],y=o.get(u.body[0]),d=tt(y)[0];if(!d)return;m(!0),b("loading");try{let h=await i(d,{width:d.width||t.width,height:d.height||t.height})||void 0;c(h),b("success"),m(!1)}catch(h){b("error"),S(h)}}}catch(u){b("error"),S(u)}})()},[l,e]),rt(()=>({data:v,isFetching:g,status:s,error:x}),[v,g,s,x])}function Vs(){let e=ot();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{useMemo as fe}from"react";import{createPaintingAnnotationsHelper as cr}from"@iiif/helpers";function Gs({supports:e=["empty","images","media","3d-model","textual-content","complex-timeline"]}={}){let t=T(),r=E(),o=B(),n=fe(()=>cr(t),[t]),i=fe(()=>n.getPaintables(o),[n,o]);return fe(()=>Le({canvas:r,loadImageService:a=>a,paintables:i,supports:e}),[r,i,e])}import{createStylesHelper as lr}from"@iiif/helpers/styles";import{useMemo as ur}from"react";function Js(){let e=T();return ur(()=>lr(e),[e])}import{useCallback as mr,useEffect as oe,useMemo as lt,useRef as ne,useState as ut}from"react";var re=[.6,.02,0,.75],nt=16,it={linear:[0,0,1,1],"ease-in":[.42,0,1,1],"ease-out":[0,0,.58,1],"ease-in-out":[.42,0,.58,1],"ease-in-cubic":re,"ease-out-cubic":[.215,.61,.355,1]};function at(e,t,r){let o=Math.max(0,Math.min(1,r));return{x:e.x+(t.x-e.x)*o,y:e.y+(t.y-e.y)*o,width:e.width+(t.width-e.width)*o,height:e.height+(t.height-e.height)*o}}function st(e,t){let r=[],o=e;for(let n of t)r.push({from:o,to:n}),o=n;return r}function D([e,t,r,o]){let n=3*e,i=3*(r-e)-n,a=1-n-i,c=3*t,g=3*(o-t)-c,m=1-c-g;function s(l){return((a*l+i)*l+n)*l}function b(l){return((m*l+g)*l+c)*l}function x(l){return(3*a*l+2*i)*l+n}function S(l,f=1e-6){let v=l;for(let p=0;p<8;p++){let d=s(v)-l;if(Math.abs(d)<f)return v;let h=x(v);if(Math.abs(h)<1e-6)break;v=v-d/h}let u=0,y=1;for(v=l;u<y;){let p=s(v);if(Math.abs(p-l)<f)return v;l>p?u=v:y=v,v=(y-u)*.5+u}return v}return l=>{if(l<=0)return 0;if(l>=1)return 1;let f=S(l);return b(f)}}function ct(e,t){if(!t||t.length===0)return{index:-1,t:0};if(Number.isNaN(e)||!isFinite(e))return{index:-1,t:0};if(e<0)return{index:-1,t:0};if(e>=t.length)return{index:t.length,t:0};let r=Math.floor(e),o=e-r;return{index:r,t:o}}function nc(e){let{initial:t,regions:r,progress:o,getProgress:n,enabled:i=!0,easing:a,reportEveryFrame:c=!1,pollInterval:g=nt,loop:m=!1,onEnter:s,onExit:b,onProgress:x,jumpTo:S}=e,l=lt(()=>st(t,r),[t,r]),[f,v]=ut(()=>-1),[u,y]=ut(0),p=ne(-1),d=ne(0),h=ne(!0),C=ne(()=>{});oe(()=>(h.current=!0,()=>{h.current=!1}),[]);let M=lt(()=>{if(!a)return D(re);if(typeof a=="function")return a;if(Array.isArray(a)&&a.length===4)return D(a);let I=it[a];return I?D(I):D(re)},[a]),q=mr(I=>{if(!(I<0||I>=l.length)&&(v(I),p.current=I,d.current=0,y(0),s))try{s(I)}catch{}},[l,s]);oe(()=>{C.current=q,S&&S(q)},[q,S]);function H(I){let{index:V,t:_}=ct(I,l),N=V;if(m&&l.length>0){let ie=l.length;N=(V%ie+ie)%ie}let U=M(_);if(N!==p.current){if(p.current>=0&&b)try{b(p.current)}catch{}if(N>=0&&s)try{s(N)}catch{}p.current=N,h.current&&v(N)}if(d.current=U,h.current&&(c||N!==f)&&y(U),x&&N>=0)try{x(N,U)}catch{}}oe(()=>{i&&typeof o=="number"&&H(o)},[o,i]),oe(()=>{if(!i||typeof n!="function")return;let I=null,V=()=>{try{let _=n();H(_)}catch{}};return V(),I=setInterval(V,g),()=>clearInterval(I)},[n,i,g]);let A=f>=0&&f<l.length?l[f]:void 0,ft=A?at(A.from,A.to,d.current):void 0;return{transitions:l,currentIndex:f,currentTransition:A,t:d.current,rect:ft,jumpTo:q}}import{useEffect as fr,useRef as mt,useState as pr}from"react";function sc(e,t={}){let{axis:r="y",offset:o=0,steps:n=1,enabled:i=!0}=t,[a,c]=pr(0),g=mt(-1),m=mt(null);return fr(()=>{if(!i||!e||!e.current)return;let s=e.current,b=()=>{let S=r==="y"?s.scrollTop:s.scrollLeft,l=r==="y"?s.clientHeight:s.clientWidth,v=(r==="y"?s.scrollHeight:s.scrollWidth)-l,y=(v<=0?0:Math.max(0,Math.min(1,(S+o)/v)))*n;y!==g.current&&(g.current=y,c(y)),m.current=null},x=()=>{m.current===null&&(m.current=requestAnimationFrame(b))};return s.addEventListener("scroll",x,{passive:!0}),b(),()=>{s.removeEventListener("scroll",x),m.current!==null&&cancelAnimationFrame(m.current)}},[e,r,o,n,i]),a}function lc(e,t){let{x:r,y:o,width:n,height:i}=e,{x:a,y:c}=t,{width:g,height:m}=t;return r+n>a&&r<a+g&&o+i>c&&o<c+m}import dr from"tiny-invariant";function gc(e,t){let r=e.boundingBox||Se(e.polygon);if(e.polygon&&!xe(e.polygon.points)){let o=e.target||Ie(e.polygon,t);return dr(o?.type==="SvgSelector"),{type:"SvgSelector",points:e.polygon.points,spatial:{unit:"pixel",...r||{}},svgShape:e.polygon.open?"polyline":"polygon",svg:o.value}}return{type:"BoxSelector",spatial:r}}export{Aa as AnnotationContext,Ha as AnnotationPageContext,so as AnnotationStyleProvider,io as AtlasStoreProvider,oo as AtlasStoreReactContext,$r as Auth,Br as AuthProvider,Lr as AuthRContext,Hr as AuthReactContext,zr as AuthReactContextActions,bi as CanvasAnnotations,pe as CanvasContext,Be as CanvasPanel,Fn as CanvasStrategyProvider,On as CanvasWorldObject,Oa as CollectionContext,ki as CombinedMetadata,Wo as ComplexTimelineProvider,yn as ContextBridge,qo as ControlsReactContext,Ve as CreateCustomShape,dn as CustomContextBridge,gn as CustomContextBridgeProvider,re as DEFAULT_BEZIER,nt as DEFAULT_POLL_INTERVAL,In as DefaultEditingTools,it as EASING_PRESETS,Zr as EventEmitterProvider,fn as EventsProvider,Mt as Image,ta as ImageService,Fo as ImageServiceLoaderContext,Gr as InnerViewerProvider,Uo as LanguageProvider,Qo as LanguageString,L as LocaleString,br as ManifestContext,sa as ManifestMetadata,Io as MediaPlayerProvider,j as Metadata,mi as PolygonSelector,xr as RangeContext,Yr as ReactEmitterContext,mn as ReactEventContext,hr as ReactVaultContext,go as RegionHighlight,Eo as Render3DModelStrategy,Ao as RenderAccompanyingCanvas,ho as RenderAnnotation,Sn as RenderAnnotationEditing,vo as RenderAnnotationPage,zo as RenderAnnotationStrategy,Vo as RenderAudioStrategy,Jo as RenderComplexTimelineStrategy,en as RenderEmptyStrategy,rn as RenderImageStrategy,wa as RenderSvgEditorControls,on as RenderTextualContentStrategy,nn as RenderVideoStrategy,an as RenderYouTubeStrategy,po as ResizeWorldItem,z as ResourceProvider,gr as ResourceReactContext,ei as SelectorControllerProvider,xa as SequenceThumbnails,Qr as SimpleViewerProvider,Kr as SimpleViewerReactContext,Ye as SingleCanvasThumbnail,To as StrategyReactContext,Oo as ThumbnailFallbackImage,_o as TranslationProvider,$o as TransliterationProvider,de as VaultProvider,ae as ViewerPresetContext,Ho as VirtualAnnotationProvider,yr as VisibleCanvasReactContext,gc as annotationResponseToSelector,Ar as authDetailsForResource,st as buildTransitions,ro as createAtlasStore,qr as createAuthStateStore,Nr as createProbe,D as cubicBezierEasing,un as defaultEmitter,cn as defaultSvgTheme,Pn as emptyActions,En as emptyStrategy,Ir as findAllCanvasesInRange,Sr as findFirstCanvasFromRange,Rr as findManifestSelectedRange,Cr as findSelectedRange,qn as flattenAnnotationPageIds,Co as formatTime,kn as get3dStrategy,no as getAtlasStoreByName,zn as getComplexTimelineStrategy,ao as getDefaultAnnotationStyles,Mn as getImageStrategy,Tr as getManifestSequence,Cn as getParsedTargetSelector,Le as getRenderingStrategy,ct as getStepFromProgress,Ln as getTextualContentStrategy,Hn as getVideoStrategy,Pr as getVisibleCanvasesFromCanvasId,Er as hasAuth,at as interpolateRect,eo as isBoxSelector,xe as isRectangle,Jr as isSvgSelector,Mr as makeAccessServiceRequest,kr as makeAccessTokenRequest,Rn as parseSpecificResource,Ie as polygonToTarget,Re as requestToAnnotationResponse,to as seraliseSupportedSelector,Kn as svgThemes,lc as targetIntersects,Tn as unknownResponse,wn as unsupportedStrategy,uo as useAnnotation,yo as useAnnotationPage,ke as useAnnotationPageManager,Ce as useAnnotationStyles,_a as useAnnotationsAtTime,bn as useAtlasContextMenu,w as useAtlasStore,Vr as useAuthActions,Dr as useAuthService,Or as useAuthStore,Ur as useAuthToken,_r as useAuthTokens,E as useCanvas,Qa as useCanvasChoices,Za as useCanvasClock,wr as useCanvasSequence,Ro as useCanvasStartTime,ts as useCanvasSubset,Yo as useClosestLanguage,as as useCollection,Do as useComplexTimeline,hn as useContextBridge,vn as useContextMenuStore,jo as useCreateLocaleString,ms as useCurrentAnnotationActions,hs as useCurrentAnnotationMetadata,xn as useCurrentAnnotationRequest,Ss as useCurrentAnnotationTransition,Wr as useCurrentAuth,pn as useCustomContextBridge,ko as useDispatch,jr as useEmitter,G as useEvent,Ae as useEventEmitter,Ts as useEventListener,he as useExistingVault,Ns as useExternalCollection,vr as useExternalManifest,ye as useExternalResource,Ko as useIIIFLanguage,ce as useImage,ot as useImageService,Te as useImageServiceLoader,Vs as useImageTile,Fr as useIsAuthEnabled,Me as useLoadImageService,Zo as useLocaleString,K as useManifest,xo as useMediaActions,So as useMediaElements,bo as useMediaState,An as usePaintables,B as usePaintingAnnotations,sn as usePolygonHelper,ve as useRange,lo as useRemoteStylesheet,No as useRenderControls,Bn as useRenderingStrategy,Oe as useRequestAnnotation,$ as useResourceContext,mo as useResourceEvents,Nn as useResources,Xr as useSearchService,Xe as useSelectorController,ti as useSelectorEmitter,$e as useSelectorEvents,ri as useSelectorHelper,Po as useSimpleMediaPlayer,be as useSimpleViewer,Gs as useStaticRenderingStrategy,wo as useStrategy,Js as useStyleHelper,fo as useStyles,co as useStylesheetStore,ln as useSvgEditor,Ze as useSvgEditorControls,we as useThumbnail,Go as useTranslations,Xo as useTransliteration,T as useVault,Bo as useVaultEffect,X as useVaultSelector,tn as useViewerPreset,sc as useViewportScroll,nc as useViewportTour,Mo as useVirtualAnnotationPage,Lo as useVirtualAnnotationPageContext,ge as useVisibleCanvases};
@@ -1,7 +1,7 @@
1
1
  import { ChoiceDescription, Paintables, SupportedTarget, ComplexChoice } from '@iiif/helpers';
2
2
  import { ImageService, ExternalWebResource, InternationalString } from '@iiif/presentation-3';
3
3
  import { AnnotationNormalized, AnnotationPageNormalized, CanvasNormalized } from '@iiif/presentation-3-normalized';
4
- import { BoxSelector, TemporalBoxSelector, TemporalSelector } from '@iiif/helpers/annotation-targets';
4
+ import { TransformPoint, SelectorTransform, BoxStyle, BoxSelector, TemporalBoxSelector, TemporalSelector } from '@iiif/helpers/annotation-targets';
5
5
  import { Emitter } from 'mitt';
6
6
 
7
7
  type ImageWithOptionalService = {
@@ -12,6 +12,12 @@ type ImageWithOptionalService = {
12
12
  service?: ImageService;
13
13
  width?: number;
14
14
  height?: number;
15
+ rotation?: number;
16
+ rotationOrigin?: TransformPoint;
17
+ translate?: TransformPoint;
18
+ transform?: SelectorTransform;
19
+ style?: BoxStyle;
20
+ styleClass?: string;
15
21
  sizes?: Array<{
16
22
  width: number;
17
23
  height: number;
@@ -1,7 +1,7 @@
1
1
  import { ChoiceDescription, Paintables, SupportedTarget, ComplexChoice } from '@iiif/helpers';
2
2
  import { ImageService, ExternalWebResource, InternationalString } from '@iiif/presentation-3';
3
3
  import { AnnotationNormalized, AnnotationPageNormalized, CanvasNormalized } from '@iiif/presentation-3-normalized';
4
- import { BoxSelector, TemporalBoxSelector, TemporalSelector } from '@iiif/helpers/annotation-targets';
4
+ import { TransformPoint, SelectorTransform, BoxStyle, BoxSelector, TemporalBoxSelector, TemporalSelector } from '@iiif/helpers/annotation-targets';
5
5
  import { Emitter } from 'mitt';
6
6
 
7
7
  type ImageWithOptionalService = {
@@ -12,6 +12,12 @@ type ImageWithOptionalService = {
12
12
  service?: ImageService;
13
13
  width?: number;
14
14
  height?: number;
15
+ rotation?: number;
16
+ rotationOrigin?: TransformPoint;
17
+ translate?: TransformPoint;
18
+ transform?: SelectorTransform;
19
+ style?: BoxStyle;
20
+ styleClass?: string;
15
21
  sizes?: Array<{
16
22
  width: number;
17
23
  height: number;
@@ -1,4 +1,4 @@
1
- import { R as RenderingStrategy, d as ImageServiceLoaderType, m as UseRenderingStrategy, U as UnknownStrategy } from './useRenderingStrategy-Bg8-k9-n.cjs';
1
+ import { R as RenderingStrategy, d as ImageServiceLoaderType, m as UseRenderingStrategy, U as UnknownStrategy } from './useRenderingStrategy-CoKE915F.cjs';
2
2
  import { CanvasNormalized } from '@iiif/presentation-3-normalized';
3
3
  import { Paintables } from '@iiif/helpers/painting-annotations';
4
4
  import * as _iiif_helpers_vault from '@iiif/helpers/vault';
@@ -1,4 +1,4 @@
1
- import { R as RenderingStrategy, d as ImageServiceLoaderType, m as UseRenderingStrategy, U as UnknownStrategy } from './useRenderingStrategy-Bg8-k9-n.js';
1
+ import { R as RenderingStrategy, d as ImageServiceLoaderType, m as UseRenderingStrategy, U as UnknownStrategy } from './useRenderingStrategy-CoKE915F.js';
2
2
  import { CanvasNormalized } from '@iiif/presentation-3-normalized';
3
3
  import { Paintables } from '@iiif/helpers/painting-annotations';
4
4
  import * as _iiif_helpers_vault from '@iiif/helpers/vault';
package/dist/utils.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var z=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var H=Object.prototype.hasOwnProperty;var _=(e,t)=>{for(var i in t)z(e,i,{get:t[i],enumerable:!0})},j=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of G(t))!H.call(e,o)&&o!==i&&z(e,o,{get:()=>t[o],enumerable:!(r=q(t,o))||r.enumerable});return e};var Q=e=>j(z({},"__esModule",{value:!0}),e);var ee={};_(ee,{emptyActions:()=>J,emptyStrategy:()=>v,getParsedTargetSelector:()=>C,getRenderingStrategy:()=>Z,parseSpecificResource:()=>$,unknownResponse:()=>I,unsupportedStrategy:()=>c});module.exports=Q(ee);var D=require("@iiif/helpers");function $(e){return e.type==="SpecificResource"?[e.source,{selector:e.selector}]:[e,{selector:null}]}function C(e,t){let{selector:i,source:r}=(0,D.expandTarget)(t);if(r.id!==e.id)return[null,r];let o={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}};return[i?i.type==="TemporalSelector"?{type:"TemporalBoxSelector",temporal:i.temporal,spatial:o.spatial}:i:null,r]}var J={makeChoice:()=>{}},I={type:"unknown"},c=e=>({type:"unknown",reason:e,annotations:{pages:[]}}),v=(e,t)=>({type:"empty",width:e,height:t,annotations:{pages:[]},image:null,images:[]});var K=["model/gltf-binary"];function M(e,t){let i=t.items[0],r=i.resource;return r.format?K.indexOf(r.format)===-1?c(`3D format: ${r.format} is unsupported`):{type:"3d-model",model:r,annotationId:i.annotationId,annotation:i.annotation}:c("Unknown format")}function w(e,t){let i=t.items,r=i[0];if(i.length===0||!r)return c("No audio");if(!e.duration)return c("No duration on canvas");if(i.length>1)return c("Only one audio source supported");let o=r.resource;return o?("format"in o||(o.format="audio/mpeg"),{type:"media",media:{annotationId:r.annotationId,annotation:r.annotation,duration:e.duration,url:o.id,type:"Sound",target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:o.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},annotations:{pages:[]}}):c("Unknown audio")}var A=require("@iiif/helpers/annotation-targets"),O=require("@iiif/parser/image-3");function h(e){return e.replace(/^http:/,"https:")}function V(e,t,i){let r=[],o=[];for(let a of t.items){let l=a.resource&&a.resource.type==="SpecificResource"?a.resource.source:a.resource;if(!l.id)return c("No resource Identifier");let u;if(l.service){let S=(0,O.getImageServices)(l);S[0]&&(u=i(S[0],e))}let d={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}},[y,n]=C(e,a.target),m=e.id?.split("?")[0]||"";if(!(h(n.id||"")===h(e.id)||h(decodeURIComponent(n.id||""))===h(e.id||"")||h(n.id||"")===h(m)||h(decodeURIComponent(n.id||""))===h(m)))continue;let s=a.resource.width&&a.resource.height?{type:"BoxSelector",spatial:{x:0,y:0,width:a.resource.width,height:a.resource.height}}:void 0,p=a.resource.type==="SpecificResource"?(0,A.expandTarget)(a.resource):null;if(a.selector){let S=(0,A.expandTarget)({type:"SpecificResource",source:a.resource,selector:a.selector});S&&(p=S)}let f=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;u&&!u.id&&(u.id=u["@id"]);let g={id:l.id,type:"Image",annotationId:a.annotationId,annotation:a.annotation,width:Number(y||f?l.width:e.width),height:Number(y||f?l.height:e.height),service:u,sizes:u&&u.sizes?u.sizes:l.width&&l.height?[{width:l.width,height:l.height}]:[],target:y&&y.type!=="PointSelector"?y:d,selector:f||{type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}},annotationPages:a.resource.annotations||[]};r.push(g)}return{type:"images",image:r[0],images:r,choice:t.choice}}function U(e,t={},i){let r=e.language||i||"none";switch(e.type){case"TextualBody":{typeof e.value<"u"&&(t[r]=[e.value]);break}case"List":case"Composite":case"Choice":e.items&&e.items.forEach(o=>U(o,t,r))}return t}function k(e,t){let i=[];return t.items.forEach(r=>{if(r.resource){let[o]=C(e,r.target);i.push({type:"Text",annotationId:r.annotationId,annotation:r.annotation,text:U(r.resource),target:o})}}),{type:"textual-content",items:i}}var P=require("@iiif/helpers");var X=/^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\/)|(?:(?:watch)?\?vi?=|&vi?=))([^#&?]*).*/;function N(e,t,i,r=!1){let o=t.items.filter(g=>g.type==="video"),a=o[0],l=!1,u=!1;if(e.duration||(u=!0),o.length>1||!a)return c("Only one video source supported");let d=o[0]?.resource,y=!!(d.service||[]).find(g=>(g.profile||"").includes("youtube.com"));if(!y&&u)return c("Video does not have duration");if(!d)return c("Unknown video");if((!d.format||d.format==="text/html")&&!y)return c("Video does not have format");let n=[],m=i.get(e.annotations||[]);for(let g of m){let S=i.get(g.items||[]);for(let x of S)if((x.motivation?Array.isArray(x.motivation||"")?x.motivation:[x.motivation]:[]).includes("supplementing")){let E=i.get(x.body||[]);for(let Y of E){let T=Y;if(T.type==="Choice")for(let F of T.items){let b=i.get(F);b.format==="text/vtt"&&n.push({id:b.id,type:"Text",format:"text/vtt",label:b.label,language:b.language})}else T.format==="text/vtt"&&n.push({id:T.id,type:"Text",format:"text/vtt",label:T.label,language:T.language})}}}let s={annotationId:a.annotationId,annotation:a.annotation,duration:e.duration,url:d.id,type:"Video",target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:d.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},p=(0,P.expandTarget)(a.target);p.selector&&p.selector.type==="TemporalBoxSelector"&&(s.target=p.selector);let{selector:f}=(0,P.parseSelector)(a.selector);if(f===null){let g=s.target.temporal.startTime,x=(s.target.temporal.endTime||e.duration)-g;s.selector={type:"TemporalSelector",temporal:{startTime:0,endTime:x}}}else f.type==="TemporalSelector"&&(s.selector=f);if(r&&!s.target.spatial&&(l=!0,s.target={type:"TemporalBoxSelector",temporal:s.target.temporal,spatial:{x:e.width/2,y:e.height/2,width:e.width/2,height:e.height/2}}),y){s.type="VideoYouTube";let g=d.id.match(X);if(!g[1])return c("Video is not known youtube video");s.youTubeId=g[1]}return{type:"media",media:s,annotations:{pages:[]},noSpatial:l,captions:n}}var L=require("@iiif/helpers");function W(e,t,i,r){let o={type:"complex-timeline",items:[],keyframes:[],highlights:[],duration:e.duration||0},a={type:"complex-choice",items:[]},l=r.get(e.annotations);function u(n){n.choice&&(n.choice.type==="complex-choice"?a.items.push(...n.choice.items):a.items.push(n.choice))}for(let n of t.items){if(n.type==="image"){let m=V(e,{choice:null,allChoices:null,types:["image"],items:[n]},i);if(m.type==="images"){if(!m.image)continue;u(m),o.items.push(m.image);let s={id:m.image.annotationId,type:"enter",resourceType:"image",time:m.image.target?.temporal?.startTime||0};o.keyframes.push(s);let p={id:m.image.annotationId,type:"exit",resourceType:"image",time:m.image.target?.temporal?.endTime||e.duration||0};o.keyframes.push(p)}}if(n.type==="textualbody"){let m=k(e,{choice:null,allChoices:null,types:["textualbody"],items:[n]});if(m.type==="textual-content"){u(m);let s=m.items[0];o.items.push(s);let p=s.target,f={id:s.annotationId,type:"enter",resourceType:"text",time:p.temporal?.startTime||0};o.keyframes.push(f);let g={id:s.annotationId,type:"exit",resourceType:"text",time:p.temporal?.endTime||e.duration||0};o.keyframes.push(g)}}if(n.type==="video"){let m=N(e,{choice:null,allChoices:null,types:["video"],items:[n]},r,!0);if(m.type==="media"){u(m);let s=m.media;o.items.push(s);let p={id:s.annotationId,type:"enter",resourceType:"video",time:s.target?.temporal?.startTime||0};o.keyframes.push(p);let f={id:s.annotationId,type:"exit",resourceType:"video",time:s.target?.temporal?.endTime||e.duration||0};o.keyframes.push(f)}}if(n.type==="audio"||n.type==="sound"){let m=w(e,{choice:null,allChoices:null,types:["audio"],items:[n]});if(m.type==="media"){u(m);let s=m.media;o.items.push(s);let p={id:s.annotationId,type:"enter",resourceType:"audio",time:s.target?.temporal?.startTime||0};o.keyframes.push(p);let f={id:s.annotationId,type:"exit",resourceType:"audio",time:s.target?.temporal?.endTime||e.duration||0};o.keyframes.push(f)}}}for(let n of l)for(let m of n.items){let s=r.get(m),p=(0,L.expandTarget)(s.target,{typeMap:r.getState?.().iiif.mapping});if(p.selector?.temporal){let f={id:s.id,type:"enter",resourceType:"highlight",time:p.selector.temporal.startTime||0};o.keyframes.push(f);let g={id:s.id,type:"exit",resourceType:"highlight",time:p.selector.temporal.endTime||e.duration||0};o.keyframes.push(g)}o.highlights.push({annotation:s,target:p})}o.keyframes.sort((n,m)=>n.time-m.time);let d=[],y=[];for(let n of o.keyframes){if(n.resourceType==="image"||n.resourceType==="text"||n.resourceType==="highlight"){y.push(n);continue}if(n.type==="enter"){d.length===0&&(n.isPrime=!0),d.push(n),y.push(n);continue}if(n.type==="exit"&&(y.push(n),d=d.filter(m=>m.id!==n.id),d.length!==0)){let m=d[0],s={id:m.id,type:"change",isPrime:!0,resourceType:m.resourceType,time:n.time};y.push(s)}}return o.keyframes=y,a.items.length&&(o.choice=a),o}var R={},B={get(e){return e},setMetaValue([e,t,i],r){let o=B.getResourceMeta(e,t),a=o?o[i]:void 0,l=typeof r=="function"?r(a):r;R[e]={...R[e]||{},[t]:{...(R[e]||{})[t]||{},[i]:l}}},getResourceMeta:(e,t)=>{let i=R[e];if(i)return t?i[t]:i},async load(e){let t=typeof e=="string"?e:e.id;return fetch(t).then(i=>i.json())},requestStatus(e){}};function Z({canvas:e,paintables:t,supports:i,loadImageService:r,vault:o=B}){if(!e)return I;if(t.types.length===0)return i.indexOf("empty")!==-1?v(e.width,e.height):I;if(t.types.length!==1)if(t.types.length===2&&t.types.indexOf("text")!==-1)t.types=t.types.filter(l=>l!=="text");else return i.indexOf("complex-timeline")===-1?c("Complex timeline not supported"):W(e,t,r,o);let a=t.types[0];return a==="image"?i.indexOf("images")===-1?c("Image not supported"):V(e,t,r):a==="Model"||a==="model"?i.indexOf("3d-model")===-1?c("3D not supported"):M(e,t):a==="textualbody"?i.indexOf("textual-content")===-1?c("Textual content not supported"):k(e,t):a==="sound"||a==="audio"?i.indexOf("media")===-1?c("Media not supported"):w(e,t):a==="video"?i.indexOf("media")===-1?c("Media not supported"):N(e,t,o):I}
1
+ "use strict";var z=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var Q=Object.prototype.hasOwnProperty;var $=(e,t)=>{for(var i in t)z(e,i,{get:t[i],enumerable:!0})},J=(e,t,i,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of j(t))!Q.call(e,o)&&o!==i&&z(e,o,{get:()=>t[o],enumerable:!(a=_(t,o))||a.enumerable});return e};var K=e=>J(z({},"__esModule",{value:!0}),e);var re={};$(re,{emptyActions:()=>Z,emptyStrategy:()=>O,getParsedTargetSelector:()=>b,getRenderingStrategy:()=>ie,parseSpecificResource:()=>X,unknownResponse:()=>I,unsupportedStrategy:()=>m});module.exports=K(re);var U=require("@iiif/helpers");function X(e){return e.type==="SpecificResource"?[e.source,{selector:e.selector}]:[e,{selector:null}]}function b(e,t){let{selector:i,source:a}=(0,U.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[i?i.type==="TemporalSelector"?{type:"TemporalBoxSelector",temporal:i.temporal,spatial:o.spatial}:i:null,a]}var Z={makeChoice:()=>{}},I={type:"unknown"},m=e=>({type:"unknown",reason:e,annotations:{pages:[]}}),O=(e,t)=>({type:"empty",width:e,height:t,annotations:{pages:[]},image:null,images:[]});var ee=["model/gltf-binary"];function L(e,t){let i=t.items[0],a=i.resource;return a.format?ee.indexOf(a.format)===-1?m(`3D format: ${a.format} is unsupported`):{type:"3d-model",model:a,annotationId:i.annotationId,annotation:i.annotation}:m("Unknown format")}function R(e,t){let i=t.items,a=i[0];if(i.length===0||!a)return m("No audio");if(!e.duration)return m("No duration on canvas");if(i.length>1)return m("Only one audio source supported");let o=a.resource;return o?("format"in o||(o.format="audio/mpeg"),{type:"media",media:{annotationId:a.annotationId,annotation:a.annotation,duration:e.duration,url:o.id,type:"Sound",target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:o.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},annotations:{pages:[]}}):m("Unknown audio")}var v=require("@iiif/helpers/annotation-targets"),E=require("@iiif/parser/image-3");function S(e){return e.replace(/^http:/,"https:")}function W(e){if(!(e?.type!=="ImageApiSelector"||typeof e.rotation>"u"))return B(e.rotation)}function B(e){if(e===null||typeof e>"u"||e==="")return;let t=Number(e);return Number.isFinite(t)?t:void 0}function te(e){let t=e.selector||{};return{...e.rotationOrigin||t.rotationOrigin?{rotationOrigin:e.rotationOrigin||t.rotationOrigin}:{},...e.translate||t.translate?{translate:e.translate||t.translate}:{},...e.transform||t.transform?{transform:e.transform||t.transform}:{},...e.style||t.boxStyle?{style:e.style||t.boxStyle}:{},...e.styleClass?{styleClass:e.styleClass}:{}}}function N(e,t,i){let a=[],o=[];for(let n of t.items){let u=n.resource&&n.resource.type==="SpecificResource"?n.resource.source:n.resource;if(!u.id)return m("No resource Identifier");let d=(n.resource.type==="SpecificResource"?W(n.resource.selector):void 0)??W(n.selector)??B(n.rotation)??B(n.selector?.rotation),f=typeof d<"u",r;if(u.service){let T=(0,E.getImageServices)(u);T[0]&&(r=i(T[0],f?{width:Number(u.width||e.width),height:Number(u.height||e.height)}:e))}let p={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}},[s,c]=b(e,n.target),g=e.id?.split("?")[0]||"";if(!(S(c.id||"")===S(e.id)||S(decodeURIComponent(c.id||""))===S(e.id||"")||S(c.id||"")===S(g)||S(decodeURIComponent(c.id||""))===S(g)))continue;let y=n.resource.width&&n.resource.height?{type:"BoxSelector",spatial:{x:0,y:0,width:n.resource.width,height:n.resource.height}}:void 0,l=n.resource.type==="SpecificResource"?(0,v.expandTarget)(n.resource):null;if(n.selector){let T=(0,v.expandTarget)({type:"SpecificResource",source:n.resource,selector:n.selector});T&&(l=T)}let h=l&&l.selector&&(l.selector.type==="BoxSelector"||l.selector.type==="TemporalBoxSelector")?{type:"BoxSelector",spatial:{x:l.selector.spatial.x,y:l.selector.spatial.y,width:l.selector.spatial.width,height:l.selector.spatial.height},...typeof l.selector.rotation<"u"?{rotation:l.selector.rotation}:{},...l.selector.rotationOrigin?{rotationOrigin:l.selector.rotationOrigin}:{},...l.selector.translate?{translate:l.selector.translate}:{},...l.selector.transform?{transform:l.selector.transform}:{},...l.selector.boxStyle?{boxStyle:l.selector.boxStyle}:{}}:void 0;r&&!r.id&&(r.id=r["@id"]);let D={id:u.id,type:"Image",annotationId:n.annotationId,annotation:n.annotation,width:Number(f||s||h?u.width:e.width),height:Number(f||s||h?u.height:e.height),...typeof d<"u"?{rotation:d}:{},...te(n),service:r,sizes:r&&r.sizes?r.sizes:u.width&&u.height?[{width:u.width,height:u.height}]:[],target:s&&s.type!=="PointSelector"?s:p,selector:h||{type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}},annotationPages:n.resource.annotations||[]};a.push(D)}return{type:"images",image:a[0],images:a,choice:t.choice}}function Y(e,t={},i){let a=e.language||i||"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=>Y(o,t,a))}return t}function V(e,t){let i=[];return t.items.forEach(a=>{if(a.resource){let[o]=b(e,a.target);i.push({type:"Text",annotationId:a.annotationId,annotation:a.annotation,text:Y(a.resource),target:o})}}),{type:"textual-content",items:i}}var k=require("@iiif/helpers");var oe=/^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\/)|(?:(?:watch)?\?vi?=|&vi?=))([^#&?]*).*/;function P(e,t,i,a=!1){let o=t.items.filter(y=>y.type==="video"),n=o[0],u=!1,x=!1;if(e.duration||(x=!0),o.length>1||!n)return m("Only one video source supported");let d=o[0]?.resource,f=!!(d.service||[]).find(y=>(y.profile||"").includes("youtube.com"));if(!f&&x)return m("Video does not have duration");if(!d)return m("Unknown video");if((!d.format||d.format==="text/html")&&!f)return m("Video does not have format");let r=[],p=i.get(e.annotations||[]);for(let y of p){let l=i.get(y.items||[]);for(let h of l)if((h.motivation?Array.isArray(h.motivation||"")?h.motivation:[h.motivation]:[]).includes("supplementing")){let T=i.get(h.body||[]);for(let G of T){let C=G;if(C.type==="Choice")for(let H of C.items){let w=i.get(H);w.format==="text/vtt"&&r.push({id:w.id,type:"Text",format:"text/vtt",label:w.label,language:w.language})}else C.format==="text/vtt"&&r.push({id:C.id,type:"Text",format:"text/vtt",label:C.label,language:C.language})}}}let s={annotationId:n.annotationId,annotation:n.annotation,duration:e.duration,url:d.id,type:"Video",target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:d.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},c=(0,k.expandTarget)(n.target);c.selector&&c.selector.type==="TemporalBoxSelector"&&(s.target=c.selector);let{selector:g}=(0,k.parseSelector)(n.selector);if(g===null){let y=s.target.temporal.startTime,h=(s.target.temporal.endTime||e.duration)-y;s.selector={type:"TemporalSelector",temporal:{startTime:0,endTime:h}}}else g.type==="TemporalSelector"&&(s.selector=g);if(a&&!s.target.spatial&&(u=!0,s.target={type:"TemporalBoxSelector",temporal:s.target.temporal,spatial:{x:e.width/2,y:e.height/2,width:e.width/2,height:e.height/2}}),f){s.type="VideoYouTube";let y=d.id.match(oe);if(!y[1])return m("Video is not known youtube video");s.youTubeId=y[1]}return{type:"media",media:s,annotations:{pages:[]},noSpatial:u,captions:r}}var F=require("@iiif/helpers");function q(e,t,i,a){let o={type:"complex-timeline",items:[],keyframes:[],highlights:[],duration:e.duration||0},n={type:"complex-choice",items:[]},u=a.get(e.annotations);function x(r){r.choice&&(r.choice.type==="complex-choice"?n.items.push(...r.choice.items):n.items.push(r.choice))}for(let r of t.items){if(r.type==="image"){let p=N(e,{choice:null,allChoices:null,types:["image"],items:[r]},i);if(p.type==="images"){if(!p.image)continue;x(p),o.items.push(p.image);let s={id:p.image.annotationId,type:"enter",resourceType:"image",time:p.image.target?.temporal?.startTime||0};o.keyframes.push(s);let c={id:p.image.annotationId,type:"exit",resourceType:"image",time:p.image.target?.temporal?.endTime||e.duration||0};o.keyframes.push(c)}}if(r.type==="textualbody"){let p=V(e,{choice:null,allChoices:null,types:["textualbody"],items:[r]});if(p.type==="textual-content"){x(p);let s=p.items[0];o.items.push(s);let c=s.target,g={id:s.annotationId,type:"enter",resourceType:"text",time:c.temporal?.startTime||0};o.keyframes.push(g);let y={id:s.annotationId,type:"exit",resourceType:"text",time:c.temporal?.endTime||e.duration||0};o.keyframes.push(y)}}if(r.type==="video"){let p=P(e,{choice:null,allChoices:null,types:["video"],items:[r]},a,!0);if(p.type==="media"){x(p);let s=p.media;o.items.push(s);let c={id:s.annotationId,type:"enter",resourceType:"video",time:s.target?.temporal?.startTime||0};o.keyframes.push(c);let g={id:s.annotationId,type:"exit",resourceType:"video",time:s.target?.temporal?.endTime||e.duration||0};o.keyframes.push(g)}}if(r.type==="audio"||r.type==="sound"){let p=R(e,{choice:null,allChoices:null,types:["audio"],items:[r]});if(p.type==="media"){x(p);let s=p.media;o.items.push(s);let c={id:s.annotationId,type:"enter",resourceType:"audio",time:s.target?.temporal?.startTime||0};o.keyframes.push(c);let g={id:s.annotationId,type:"exit",resourceType:"audio",time:s.target?.temporal?.endTime||e.duration||0};o.keyframes.push(g)}}}for(let r of u)for(let p of r.items){let s=a.get(p),c=(0,F.expandTarget)(s.target,{typeMap:a.getState?.().iiif.mapping});if(c.selector?.temporal){let g={id:s.id,type:"enter",resourceType:"highlight",time:c.selector.temporal.startTime||0};o.keyframes.push(g);let y={id:s.id,type:"exit",resourceType:"highlight",time:c.selector.temporal.endTime||e.duration||0};o.keyframes.push(y)}o.highlights.push({annotation:s,target:c})}o.keyframes.sort((r,p)=>r.time-p.time);let d=[],f=[];for(let r of o.keyframes){if(r.resourceType==="image"||r.resourceType==="text"||r.resourceType==="highlight"){f.push(r);continue}if(r.type==="enter"){d.length===0&&(r.isPrime=!0),d.push(r),f.push(r);continue}if(r.type==="exit"&&(f.push(r),d=d.filter(p=>p.id!==r.id),d.length!==0)){let p=d[0],s={id:p.id,type:"change",isPrime:!0,resourceType:p.resourceType,time:r.time};f.push(s)}}return o.keyframes=f,n.items.length&&(o.choice=n),o}var A={},M={get(e){return e},setMetaValue([e,t,i],a){let o=M.getResourceMeta(e,t),n=o?o[i]:void 0,u=typeof a=="function"?a(n):a;A[e]={...A[e]||{},[t]:{...(A[e]||{})[t]||{},[i]:u}}},getResourceMeta:(e,t)=>{let i=A[e];if(i)return t?i[t]:i},async load(e){let t=typeof e=="string"?e:e.id;return fetch(t).then(i=>i.json())},requestStatus(e){}};function ie({canvas:e,paintables:t,supports:i,loadImageService:a,vault:o=M}){if(!e)return I;if(t.types.length===0)return i.indexOf("empty")!==-1?O(e.width,e.height):I;if(t.types.length!==1)if(t.types.length===2&&t.types.indexOf("text")!==-1)t.types=t.types.filter(u=>u!=="text");else return i.indexOf("complex-timeline")===-1?m("Complex timeline not supported"):q(e,t,a,o);let n=t.types[0];return n==="image"?i.indexOf("images")===-1?m("Image not supported"):N(e,t,a):n==="Model"||n==="model"?i.indexOf("3d-model")===-1?m("3D not supported"):L(e,t):n==="textualbody"?i.indexOf("textual-content")===-1?m("Textual content not supported"):V(e,t):n==="sound"||n==="audio"?i.indexOf("media")===-1?m("Media not supported"):R(e,t):n==="video"?i.indexOf("media")===-1?m("Media not supported"):P(e,t,o):I}
package/dist/utils.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- export { e as emptyActions, c as emptyStrategy, a as getParsedTargetSelector, g as getRenderingStrategy, p as parseSpecificResource, u as unknownResponse, b as unsupportedStrategy } from './utils-CMAqRpk_.cjs';
2
- import './useRenderingStrategy-Bg8-k9-n.cjs';
1
+ export { e as emptyActions, c as emptyStrategy, a as getParsedTargetSelector, g as getRenderingStrategy, p as parseSpecificResource, u as unknownResponse, b as unsupportedStrategy } from './utils-BKdiug6F.cjs';
2
+ import './useRenderingStrategy-CoKE915F.cjs';
3
3
  import '@iiif/helpers';
4
4
  import '@iiif/presentation-3';
5
5
  import '@iiif/presentation-3-normalized';
package/dist/utils.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { e as emptyActions, c as emptyStrategy, a as getParsedTargetSelector, g as getRenderingStrategy, p as parseSpecificResource, u as unknownResponse, b as unsupportedStrategy } from './utils-CHozUicY.js';
2
- import './useRenderingStrategy-Bg8-k9-n.js';
1
+ export { e as emptyActions, c as emptyStrategy, a as getParsedTargetSelector, g as getRenderingStrategy, p as parseSpecificResource, u as unknownResponse, b as unsupportedStrategy } from './utils-CmwQWQLa.js';
2
+ import './useRenderingStrategy-CoKE915F.js';
3
3
  import '@iiif/helpers';
4
4
  import '@iiif/presentation-3';
5
5
  import '@iiif/presentation-3-normalized';
package/dist/utils.js CHANGED
@@ -1 +1 @@
1
- import"./chunk-UNH7HXGJ.js";import{a,b,c,d,e,f,l as g}from"./chunk-FBET7GLW.js";export{c as emptyActions,f as emptyStrategy,b as getParsedTargetSelector,g as getRenderingStrategy,a as parseSpecificResource,d as unknownResponse,e as unsupportedStrategy};
1
+ import"./chunk-UNH7HXGJ.js";import{a,b,c,d,e,f,l as g}from"./chunk-P7XHGETS.js";export{c as emptyActions,f as emptyStrategy,b as getParsedTargetSelector,g as getRenderingStrategy,a as parseSpecificResource,d as unknownResponse,e as unsupportedStrategy};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-iiif-vault",
3
- "version": "2.0.8",
3
+ "version": "2.0.10",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
@@ -61,8 +61,8 @@
61
61
  },
62
62
  "dependencies": {
63
63
  "@floating-ui/react": "^0.27.13",
64
- "@iiif/helpers": "^1.5.4",
65
- "@iiif/parser": "^2.2.5",
64
+ "@iiif/helpers": "^1.5.9",
65
+ "@iiif/parser": "^2.2.10",
66
66
  "@iiif/presentation-2": "^1.0.4",
67
67
  "@iiif/presentation-3": "^2.2.3",
68
68
  "@iiif/presentation-3-normalized": "^0.9.7",
@@ -1 +0,0 @@
1
- import{expandTarget as L}from"@iiif/helpers";function J(e){return e.type==="SpecificResource"?[e.source,{selector:e.selector}]:[e,{selector:null}]}function I(e,t){let{selector:o,source:r}=L(t);if(r.id!==e.id)return[null,r];let i={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}};return[o?o.type==="TemporalSelector"?{type:"TemporalBoxSelector",temporal:o.temporal,spatial:i.spatial}:o:null,r]}var K={makeChoice:()=>{}},b={type:"unknown"},c=e=>({type:"unknown",reason:e,annotations:{pages:[]}}),z=(e,t)=>({type:"empty",width:e,height:t,annotations:{pages:[]},image:null,images:[]});var W=["model/gltf-binary"];function v(e,t){let o=t.items[0],r=o.resource;return r.format?W.indexOf(r.format)===-1?c(`3D format: ${r.format} is unsupported`):{type:"3d-model",model:r,annotationId:o.annotationId,annotation:o.annotation}:c("Unknown format")}import{expandTarget as A}from"@iiif/helpers/annotation-targets";import{getImageServices as E}from"@iiif/parser/image-3";function h(e){return e.replace(/^http:/,"https:")}function w(e,t,o){let r=[],i=[];for(let a of t.items){let l=a.resource&&a.resource.type==="SpecificResource"?a.resource.source:a.resource;if(!l.id)return c("No resource Identifier");let u;if(l.service){let S=E(l);S[0]&&(u=o(S[0],e))}let d={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}},[y,n]=I(e,a.target),m=e.id?.split("?")[0]||"";if(!(h(n.id||"")===h(e.id)||h(decodeURIComponent(n.id||""))===h(e.id||"")||h(n.id||"")===h(m)||h(decodeURIComponent(n.id||""))===h(m)))continue;let s=a.resource.width&&a.resource.height?{type:"BoxSelector",spatial:{x:0,y:0,width:a.resource.width,height:a.resource.height}}:void 0,p=a.resource.type==="SpecificResource"?A(a.resource):null;if(a.selector){let S=A({type:"SpecificResource",source:a.resource,selector:a.selector});S&&(p=S)}let f=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;u&&!u.id&&(u.id=u["@id"]);let g={id:l.id,type:"Image",annotationId:a.annotationId,annotation:a.annotation,width:Number(y||f?l.width:e.width),height:Number(y||f?l.height:e.height),service:u,sizes:u&&u.sizes?u.sizes:l.width&&l.height?[{width:l.width,height:l.height}]:[],target:y&&y.type!=="PointSelector"?y:d,selector:f||{type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}},annotationPages:a.resource.annotations||[]};r.push(g)}return{type:"images",image:r[0],images:r,choice:t.choice}}function B(e,t={},o){let r=e.language||o||"none";switch(e.type){case"TextualBody":{typeof e.value<"u"&&(t[r]=[e.value]);break}case"List":case"Composite":case"Choice":e.items&&e.items.forEach(i=>B(i,t,r))}return t}function V(e,t){let o=[];return t.items.forEach(r=>{if(r.resource){let[i]=I(e,r.target);o.push({type:"Text",annotationId:r.annotationId,annotation:r.annotation,text:B(r.resource),target:i})}}),{type:"textual-content",items:o}}import{expandTarget as Y,parseSelector as F}from"@iiif/helpers";var q=/^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\/)|(?:(?:watch)?\?vi?=|&vi?=))([^#&?]*).*/;function k(e,t,o,r=!1){let i=t.items.filter(g=>g.type==="video"),a=i[0],l=!1,u=!1;if(e.duration||(u=!0),i.length>1||!a)return c("Only one video source supported");let d=i[0]?.resource,y=!!(d.service||[]).find(g=>(g.profile||"").includes("youtube.com"));if(!y&&u)return c("Video does not have duration");if(!d)return c("Unknown video");if((!d.format||d.format==="text/html")&&!y)return c("Video does not have format");let n=[],m=o.get(e.annotations||[]);for(let g of m){let S=o.get(g.items||[]);for(let x of S)if((x.motivation?Array.isArray(x.motivation||"")?x.motivation:[x.motivation]:[]).includes("supplementing")){let M=o.get(x.body||[]);for(let O of M){let T=O;if(T.type==="Choice")for(let U of T.items){let C=o.get(U);C.format==="text/vtt"&&n.push({id:C.id,type:"Text",format:"text/vtt",label:C.label,language:C.language})}else T.format==="text/vtt"&&n.push({id:T.id,type:"Text",format:"text/vtt",label:T.label,language:T.language})}}}let s={annotationId:a.annotationId,annotation:a.annotation,duration:e.duration,url:d.id,type:"Video",target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:d.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},p=Y(a.target);p.selector&&p.selector.type==="TemporalBoxSelector"&&(s.target=p.selector);let{selector:f}=F(a.selector);if(f===null){let g=s.target.temporal.startTime,x=(s.target.temporal.endTime||e.duration)-g;s.selector={type:"TemporalSelector",temporal:{startTime:0,endTime:x}}}else f.type==="TemporalSelector"&&(s.selector=f);if(r&&!s.target.spatial&&(l=!0,s.target={type:"TemporalBoxSelector",temporal:s.target.temporal,spatial:{x:e.width/2,y:e.height/2,width:e.width/2,height:e.height/2}}),y){s.type="VideoYouTube";let g=d.id.match(q);if(!g[1])return c("Video is not known youtube video");s.youTubeId=g[1]}return{type:"media",media:s,annotations:{pages:[]},noSpatial:l,captions:n}}import{expandTarget as G}from"@iiif/helpers";function P(e,t){let o=t.items,r=o[0];if(o.length===0||!r)return c("No audio");if(!e.duration)return c("No duration on canvas");if(o.length>1)return c("Only one audio source supported");let i=r.resource;return i?("format"in i||(i.format="audio/mpeg"),{type:"media",media:{annotationId:r.annotationId,annotation:r.annotation,duration:e.duration,url:i.id,type:"Sound",target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:i.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},annotations:{pages:[]}}):c("Unknown audio")}function D(e,t,o,r){let i={type:"complex-timeline",items:[],keyframes:[],highlights:[],duration:e.duration||0},a={type:"complex-choice",items:[]},l=r.get(e.annotations);function u(n){n.choice&&(n.choice.type==="complex-choice"?a.items.push(...n.choice.items):a.items.push(n.choice))}for(let n of t.items){if(n.type==="image"){let m=w(e,{choice:null,allChoices:null,types:["image"],items:[n]},o);if(m.type==="images"){if(!m.image)continue;u(m),i.items.push(m.image);let s={id:m.image.annotationId,type:"enter",resourceType:"image",time:m.image.target?.temporal?.startTime||0};i.keyframes.push(s);let p={id:m.image.annotationId,type:"exit",resourceType:"image",time:m.image.target?.temporal?.endTime||e.duration||0};i.keyframes.push(p)}}if(n.type==="textualbody"){let m=V(e,{choice:null,allChoices:null,types:["textualbody"],items:[n]});if(m.type==="textual-content"){u(m);let s=m.items[0];i.items.push(s);let p=s.target,f={id:s.annotationId,type:"enter",resourceType:"text",time:p.temporal?.startTime||0};i.keyframes.push(f);let g={id:s.annotationId,type:"exit",resourceType:"text",time:p.temporal?.endTime||e.duration||0};i.keyframes.push(g)}}if(n.type==="video"){let m=k(e,{choice:null,allChoices:null,types:["video"],items:[n]},r,!0);if(m.type==="media"){u(m);let s=m.media;i.items.push(s);let p={id:s.annotationId,type:"enter",resourceType:"video",time:s.target?.temporal?.startTime||0};i.keyframes.push(p);let f={id:s.annotationId,type:"exit",resourceType:"video",time:s.target?.temporal?.endTime||e.duration||0};i.keyframes.push(f)}}if(n.type==="audio"||n.type==="sound"){let m=P(e,{choice:null,allChoices:null,types:["audio"],items:[n]});if(m.type==="media"){u(m);let s=m.media;i.items.push(s);let p={id:s.annotationId,type:"enter",resourceType:"audio",time:s.target?.temporal?.startTime||0};i.keyframes.push(p);let f={id:s.annotationId,type:"exit",resourceType:"audio",time:s.target?.temporal?.endTime||e.duration||0};i.keyframes.push(f)}}}for(let n of l)for(let m of n.items){let s=r.get(m),p=G(s.target,{typeMap:r.getState?.().iiif.mapping});if(p.selector?.temporal){let f={id:s.id,type:"enter",resourceType:"highlight",time:p.selector.temporal.startTime||0};i.keyframes.push(f);let g={id:s.id,type:"exit",resourceType:"highlight",time:p.selector.temporal.endTime||e.duration||0};i.keyframes.push(g)}i.highlights.push({annotation:s,target:p})}i.keyframes.sort((n,m)=>n.time-m.time);let d=[],y=[];for(let n of i.keyframes){if(n.resourceType==="image"||n.resourceType==="text"||n.resourceType==="highlight"){y.push(n);continue}if(n.type==="enter"){d.length===0&&(n.isPrime=!0),d.push(n),y.push(n);continue}if(n.type==="exit"&&(y.push(n),d=d.filter(m=>m.id!==n.id),d.length!==0)){let m=d[0],s={id:m.id,type:"change",isPrime:!0,resourceType:m.resourceType,time:n.time};y.push(s)}}return i.keyframes=y,a.items.length&&(i.choice=a),i}var N={},R={get(e){return e},setMetaValue([e,t,o],r){let i=R.getResourceMeta(e,t),a=i?i[o]:void 0,l=typeof r=="function"?r(a):r;N[e]={...N[e]||{},[t]:{...(N[e]||{})[t]||{},[o]:l}}},getResourceMeta:(e,t)=>{let o=N[e];if(o)return t?o[t]:o},async load(e){let t=typeof e=="string"?e:e.id;return fetch(t).then(o=>o.json())},requestStatus(e){}};function ve({canvas:e,paintables:t,supports:o,loadImageService:r,vault:i=R}){if(!e)return b;if(t.types.length===0)return o.indexOf("empty")!==-1?z(e.width,e.height):b;if(t.types.length!==1)if(t.types.length===2&&t.types.indexOf("text")!==-1)t.types=t.types.filter(l=>l!=="text");else return o.indexOf("complex-timeline")===-1?c("Complex timeline not supported"):D(e,t,r,i);let a=t.types[0];return a==="image"?o.indexOf("images")===-1?c("Image not supported"):w(e,t,r):a==="Model"||a==="model"?o.indexOf("3d-model")===-1?c("3D not supported"):v(e,t):a==="textualbody"?o.indexOf("textual-content")===-1?c("Textual content not supported"):V(e,t):a==="sound"||a==="audio"?o.indexOf("media")===-1?c("Media not supported"):P(e,t):a==="video"?o.indexOf("media")===-1?c("Media not supported"):k(e,t,i):b}export{J as a,I as b,K as c,b as d,c as e,z as f,v as g,w as h,V as i,k as j,D as k,ve as l};