react-iiif-vault 2.0.10 → 2.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.d.ts +7 -3
- package/dist/bundle.global.js +52 -46
- package/dist/canvas-panel.cjs +6 -6
- package/dist/canvas-panel.d.cts +1 -1
- package/dist/canvas-panel.d.ts +1 -1
- package/dist/canvas-panel.js +1 -1
- package/dist/chunk-5EBWATUV.js +49 -0
- package/dist/{index-BAwkF_tl.d.cts → index-DHghDluJ.d.cts} +5 -2
- package/dist/{index-C3XrwwYg.d.ts → index-DijgVxjb.d.ts} +5 -2
- package/dist/index.cjs +8 -8
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +1 -1
- package/package.json +2 -1
- package/dist/chunk-FA723YSS.js +0 -49
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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-
|
|
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-
|
|
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-DHghDluJ.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-DHghDluJ.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';
|
|
@@ -132,9 +132,10 @@ interface ImageStrategyProps {
|
|
|
132
132
|
enableSizes?: boolean;
|
|
133
133
|
enableAnnotations?: boolean;
|
|
134
134
|
onClickPaintingAnnotation?: (id: string, image: ImageWithOptionalService, e: any) => void;
|
|
135
|
+
rotation?: number;
|
|
135
136
|
children?: ReactNode;
|
|
136
137
|
}
|
|
137
|
-
declare function RenderImageStrategy({ isStatic, enableSizes, enableAnnotations, onClickPaintingAnnotation, children, }: ImageStrategyProps): react_jsx_runtime.JSX.Element | null;
|
|
138
|
+
declare function RenderImageStrategy({ isStatic, enableSizes, enableAnnotations, onClickPaintingAnnotation, rotation, children, }: ImageStrategyProps): react_jsx_runtime.JSX.Element | null;
|
|
138
139
|
|
|
139
140
|
interface TextualContextStrategyProps {
|
|
140
141
|
onClickPaintingAnnotation?: (id: string, e: any) => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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-
|
|
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-
|
|
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-DijgVxjb.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-DijgVxjb.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';
|
|
@@ -132,9 +132,10 @@ interface ImageStrategyProps {
|
|
|
132
132
|
enableSizes?: boolean;
|
|
133
133
|
enableAnnotations?: boolean;
|
|
134
134
|
onClickPaintingAnnotation?: (id: string, image: ImageWithOptionalService, e: any) => void;
|
|
135
|
+
rotation?: number;
|
|
135
136
|
children?: ReactNode;
|
|
136
137
|
}
|
|
137
|
-
declare function RenderImageStrategy({ isStatic, enableSizes, enableAnnotations, onClickPaintingAnnotation, children, }: ImageStrategyProps): react_jsx_runtime.JSX.Element | null;
|
|
138
|
+
declare function RenderImageStrategy({ isStatic, enableSizes, enableAnnotations, onClickPaintingAnnotation, rotation, children, }: ImageStrategyProps): react_jsx_runtime.JSX.Element | null;
|
|
138
139
|
|
|
139
140
|
interface TextualContextStrategyProps {
|
|
140
141
|
onClickPaintingAnnotation?: (id: string, e: any) => void;
|
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-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
|
+
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-5EBWATUV.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};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-iiif-vault",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.12",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -80,6 +80,7 @@
|
|
|
80
80
|
"react-dom": "^18.2.0 || ^19.2.0"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
|
+
"@atlas-viewer/atlas": "3.2.1",
|
|
83
84
|
"react": "^19.2.0",
|
|
84
85
|
"react-dom": "^19.2.0",
|
|
85
86
|
"@testing-library/react": "^15.0.2",
|
package/dist/chunk-FA723YSS.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import{c as ln,l as un}from"./chunk-P7XHGETS.js";import{forwardRef as Vr,useImperativeHandle as Ol,useMemo as Bl}from"react";import Nr,{useContext as Lr,useMemo as zr}from"react";import{jsx as Br}from"react/jsx-runtime";var Or={collection:void 0,manifest:void 0,range:void 0,canvas:void 0,annotation:void 0,annotationPage:void 0},$e=Nr.createContext(Or),_=()=>Lr($e);function ie({value:e,children:t}){let n=_(),o=zr(()=>({...n,...e}),[e,n]);return Br($e.Provider,{value:o,children:t})}import{jsx as Hr}from"react/jsx-runtime";function ee({canvas:e,children:t}){return Hr(ie,{value:{canvas:e},children:t})}import Dr,{useState as qr}from"react";import{Vault as cn,globalVault as $r}from"@iiif/helpers/vault";import{jsx as dn}from"react/jsx-runtime";var le=Dr.createContext({vault:null,setVaultInstance:e=>{}});function ge({vault:e,vaultOptions:t,useGlobal:n,resources:o,children:s}){let[i,r]=qr(()=>e||(n?$r(t):t?new cn(t):new cn));return dn(le.Provider,{value:{vault:i,setVaultInstance:r},children:dn(ie,{value:o||{},children:s})})}import{useContext as _r}from"react";import jr from"react";import{useContext as Fr}from"react";var M=()=>{let{vault:e}=Fr(le);if(e===null)throw new Error("Vault not found. Ensure you have your provider set up correctly.");return e};import{useEffect as Wr,useState as Ur}from"react";function k(e,t=[]){let n=M(),[o,s]=Ur(()=>e(n.getState(),n));return Wr(()=>n.subscribe(i=>e(i,n),i=>{s(i)},!1),t),o}var he=jr.createContext([]);function Fe(){let e=_r(he);return k(t=>e.map(n=>t.iiif.entities.Canvas[n]).filter(Boolean),[e])}import{globalVault as Kr}from"@iiif/helpers/vault";import{useContext as Yr}from"react";function ye(e){let t=Yr(le);return e||(t&&t.vault?t.vault:Kr())}import{useMemo as Gr}from"react";function B(e={},t=[]){let{id:n,selector:o}=e,s=_(),i=M(),r=n||s.manifest,a=k(l=>r?l.iiif.entities.Manifest[r]:void 0,[r]);return Gr(()=>{if(a)return o?o(a):a},[a,o,...t])}import{useContext as Si}from"react";import{createContext as xi,useMemo as bi}from"react";import{useEffect as Qr,useMemo as Xr,useState as yt}from"react";function mn(e,{noCache:t=!1}={}){let n=typeof e=="string"?e:e.id,o=ye(),[s,i]=yt(n),[r,a]=yt(void 0),l=Xr(()=>o.get(n,{skipSelfReturn:!0})||void 0,[n,o]),[u,g]=yt(l);return Qr(()=>{(async()=>{try{let c=l&&!t?l:await o.load(n),d=c?c.id||c["@id"]:null;c&&s!==d&&i(d),g(c)}catch(c){a(c)}})()},[n,t]),{isLoaded:!!u,id:s,requestId:n,error:r,resource:u,cached:!!(u&&u===l)}}function pn(e,t){let{id:n,isLoaded:o,error:s,resource:i,requestId:r,cached:a}=mn(e,t);return{id:n,isLoaded:o,error:s,manifest:i,requestId:r,cached:a}}import{jsx as Zr}from"react/jsx-runtime";function fn({manifest:e,children:t}){return Zr(ie,{value:{manifest:e},children:t})}import{jsx as Jr}from"react/jsx-runtime";function gn({range:e,children:t}){return Jr(ie,{value:{range:e},children:t})}function ei(e,t){for(let n of t.items){if(n.type==="Canvas")return n;if(n.type==="SpecificResource")return n.source;if(n.type==="Range"){let o=ei(e,e.get(n));if(o)return o}}return null}function vt(e,t){let n=[];for(let o of t.items)if(o.type==="SpecificResource"&&o.source?.type==="Canvas"&&(o.source.id.indexOf("#")!==-1?n.push({id:o.source.id.split("#")[0],type:"Canvas"}):n.push(o.source)),o.type==="Range"&&n.push(...vt(e,e.get(o))),o.type==="SpecificResource"){let s=typeof o.source=="string"?o.source:o.source.id;n.push({id:s,type:"Canvas"})}return n}function Ou(e,t,n){for(let o of t.structures){let s=hn(e,e.get(o),n);if(s)return s}return null}function hn(e,t,n){for(let o of t.items){let s=o?.source?.id?.split("#")[0];if(o.type==="SpecificResource"&&o.source===n||o.type==="SpecificResource"&&o.source?.type==="Canvas"&&n===s)return t;if(o.type==="Range"){let i=hn(e,e.get(o),n);if(i)return i}}return null}function Du(e,t,n,o=!1){let s=t.behavior,i=n?e.get(n):null;if(!i)return[];let r=i.behavior,a=o?!1:s.includes("paged"),l=a?!1:s.includes("continuous"),u=a||l?!1:s.includes("individuals"),g=r.includes("facing-pages"),c=r.includes("non-paged");if(g||c||u||o)return[{id:i.id,type:"Canvas"}];let[d,p]=St(e,t);if(l)return d;let y=d.findIndex(f=>f.id===n);if(y===-1)return[];for(let f of p)if(f.includes(y))return f.map(x=>d[x]);return[{id:i.id,type:"Canvas"}]}function St(e,t,{disablePaging:n,skipNonPaged:o}={}){let s=t.behavior,i=s.includes("paged"),r=i?!1:s.includes("continuous"),a=i||r?!1:s.includes("individuals"),l=t.type==="Manifest"?t.items:vt(e,t);if(r)return[l,[l.map((y,f)=>f)]];if(a||!i||n)return[l,l.map((y,f)=>[f])];let u=[],g=[],c=()=>{g.length&&(u.push([...g]),g=[])},d=0,p=!1;for(let y=0;y<l.length;y++){let f=e.get(l[y]);if(f.behavior.includes("non-paged")){y===d&&d++,o||(c(),u.push([y]),c());continue}if(y===d||f.behavior.includes("facing-pages")){g.length&&(p=!0),c(),u.push([y]),c();continue}if(g.push(y),p){c(),p=!1;continue}g.length>1&&c()}return g.length&&c(),[l,u]}import{useCallback as We,useMemo as ni,useRef as oi,useState as ri}from"react";import{useMemo as ti}from"react";function yn(e={},t=[]){let{id:n,selector:o}=e,s=_(),i=n||s.range,r=k(a=>i?a.iiif.entities.Range[i]:void 0,[i]);return ti(()=>{if(r)return o?o(r):r},[r,o,...t])}function vn({startCanvas:e,disablePaging:t}){let n=M(),o=B(),s=yn(),[i,r]=ri(void 0),a=s||o;if(!a)throw new Error("Nothing selected");let[l,u]=ni(()=>St(n,a,{disablePaging:t}),[n,a,t]),g=oi(u);if(g.current!==u){let x=g.current[i][0],v=u.findIndex(m=>m.includes(x));g.current=u,r(v)}let c=We(f=>{let x=u.findIndex(v=>v.includes(f));r(x===-1?0:x)},[l,u]),d=We(f=>{let x=l.findIndex(v=>v.id===f);x!==-1?c(x):r(0)},[l,u]),p=We(()=>{r(f=>f>=u.length-1?f:f+1)},[u]),y=We(()=>{r(f=>f<=0?0:f-1)},[u]);return typeof i>"u"&&(e?d(e):r(0)),{visibleItems:u[i]?.map(f=>l[f].id)||[],cursor:i,items:l,sequence:u,hasPrevious:i>0,hasNext:i<u.length-1,setSequenceIndex:r,setCanvasIndex:c,setCanvasId:d,next:p,previous:y}}import{createContext as Ct,useContext as Mn,useEffect as ai,useMemo as si}from"react";import{useStore as Ve}from"zustand";import{createStore as xn}from"zustand/vanilla";function Zu(e){let t=e.service||e.services||[];for(let n of t)if(n.type==="AuthProbeService2")return!0;return!1}function j(e,t,n){let o=t.findIndex(r=>r.service.id===e);if(o===-1)return t;let s=[...t],i=n(s[o]);return i===s[o]?t:(s[o]=i,s)}var bn=()=>xn((e,t)=>({currentAuth:-1,authItems:[],login:()=>{let n=t().authItems[t().currentAuth];if(!n||n.isPending||n.isLoggedIn)return;if(n.type!=="active")throw new Error("Cannot login to non-active service");let o=n.service.service.find(s=>s.type==="AuthAccessTokenService2");if(!o)throw new Error("Token service not found");e(()=>({authItems:j(n.id,t().authItems,s=>({...s,isPending:!0}))})),Sn(n.service).then(()=>{xt(o).then(s=>{let i=s.expiresIn,r=Date.now()+i*1e3;e(()=>({authItems:j(n.id,t().authItems,a=>({...a,isLoggedIn:!0,isPending:!1,session:{token:s.accessToken,expires:r}}))}))}).catch(s=>{e(()=>({authItems:j(n.id,t().authItems,i=>({...i,isLoggedIn:!1,isPending:!1,error:s.message}))}))})})},logout:()=>{let n=t().authItems[t().currentAuth];if(!n||n.isPending||!n.isLoggedIn)return;if(n.type!=="active")throw new Error("Cannot logout of non-active service");let o=n.service.service.find(r=>r.type==="AuthLogoutService2");if(!o)return;let s=`${o.id}?origin=${An()}`,i=window.open(s);e(()=>({authItems:j(n.id,t().authItems,r=>({...r,isLoggedIn:!1,session:null,isPending:!1}))}))},nextAuth:()=>{let n=t().authItems.length,o=t().currentAuth+1;o>=n||e(()=>({currentAuth:o}))},previousAuth:()=>{let n=t().currentAuth-1;n<0||e(()=>({currentAuth:n}))},setAuth:n=>{n!==-1&&(n<0||n>=t().authItems.length)||e(()=>({currentAuth:n}))},addService:(n,o)=>{if(!n.service)return;let s=n.service.find(a=>a.type==="AuthAccessTokenService2"),i=n;if(t().authItems.find(a=>a.service.id===n.id)){e(()=>({authItems:j(n.id,t().authItems,a=>({...a,instances:a.instances+1}))}));return}if(e(()=>({currentAuth:i.profile==="active"?0:t().currentAuth,authItems:[{id:n.id,type:n.profile,service:n,probeId:o,canAuthenticate:!0,instances:1,isPending:!1,isLoggedIn:!1,session:null},...t().authItems]})),n.profile==="external"){if(!s)throw new Error("Token service not found");xt(s).then(a=>{e(()=>({authItems:j(n.id,t().authItems,l=>({...l,isLoggedIn:!0,isPending:!1,session:{token:a.accessToken,expires:a.expiresIn}}))}))}).catch(a=>{e(()=>({authItems:j(n.id,t().authItems,l=>({...l,isLoggedIn:!1,isPending:!1,canAuthenticate:!1,error:a.message}))}))})}if(n.profile==="kiosk"){if(!s)throw new Error("Token service not found");e(()=>({authItems:j(n.id,t().authItems,a=>({...a,isPending:!0}))})),Sn(i).then(()=>{xt(s).then(a=>{e(()=>({authItems:j(n.id,t().authItems,l=>({...l,isLoggedIn:!0,isPending:!1,session:{token:a.accessToken,expires:a.expiresIn}}))}))}).catch(a=>{e(()=>({authItems:j(n.id,t().authItems,l=>({...l,isLoggedIn:!1,isPending:!1,error:a.message}))}))})})}n.profile},removeService:(n,o)=>{let s=t().currentAuth===t().authItems.findIndex(r=>r.service.id===n.id),i=t().currentAuth;if(s){let r=t().authItems.find(l=>l.service.id===n.id);r&&r.instances>1||(i=t().authItems.findIndex(u=>u.service.id!==n.id&&u.instances>0))}e(()=>({authItems:j(n.id,t().authItems,r=>({...r,instances:r.instances-1})),currentAuth:i}))}})),Cn=(e,t)=>xn((n,o)=>({service:e,status:e?"unknown":"success",shouldRedirect:!1,redirectResource:null,shouldSubstitute:!1,substituteResource:null,error:null,errorHeading:null,errorNote:null,shouldDisplayResource:!1,token:t||null,async probe(){if(!o().service)return;let s=o().service?.id;if(!s){n({status:"error",error:"Service ID not found",errorHeading:{en:["Service ID not found"]}});return}n({status:"probing"});let i=o().token;try{let r=await fetch(s,{headers:i?{Authorization:`Bearer ${o().token}`,Accept:"application/json"}:{Accept:"application/json"}}).then(a=>a.json());if(r.status===200)n({status:"success",shouldDisplayResource:!0,error:null,errorHeading:null,errorNote:null,shouldSubstitute:!1,shouldRedirect:!1});else if(r.status<400&&r.status>=300){if(!r.location)throw new Error("Redirect location not found");n({status:"error",shouldDisplayResource:!1,shouldRedirect:!0,redirectResource:r.location||null})}else if(r.status===401)n({status:"error",shouldDisplayResource:!1,shouldRedirect:!1,shouldSubstitute:!!r.substitute,substituteResource:r.substitute||null,error:"Unauthorized",errorHeading:r.heading||{en:["Unauthorized"]},errorNote:r.note||null});else throw new Error("Unknown error")}catch(r){n({status:"error",error:r.message,errorHeading:{en:["Unknown error"]}})}},setToken(s){n({token:s})}}));function Rn(e){let t=e.service||e.services||[],n={hasAuth:!1,services:{}};for(let o of t)if(o.type==="AuthProbeService2"){n.services.probe=o,n.hasAuth=!0;let s=o.service.filter(i=>i.type==="AuthAccessService2");s[0]&&(n.services.access=s[0])}return n}async function xt(e,{strict:t=!0}={}){return new Promise((n,o)=>{let s=Math.random().toString(36).substring(7),i=`${e.id}?messageId=${s}&origin=${window.location.origin}`,r=u=>{let g=u.data;if(g.messageId===s){if(t&&g.type!=="AuthAccessToken2"){a(),o("Invalid response, expected type=AuthAccessToken2");return}if(!g.accessToken){a(),o("Invalid response, expected accessToken");return}a(),n(g)}},a=()=>window.removeEventListener("message",r),l=document.createElement("iframe");l.src=i,l.style.display="none",document.body.appendChild(l),window.addEventListener("message",r)})}function An(e){let t=window.location;if(e){let n=document.createElement("a");return n.href=e,n.protocol+"//"+n.hostname+(n.port?":"+n.port:"")}return t.protocol+"//"+t.hostname+(t.port?":"+t.port:"")}async function Sn(e){let t=`${e.id}?origin=${An()}`,n=window.open(t);if(!n)throw new Error("Failed to open window");return new Promise((o,s)=>{let i=setInterval(()=>{n.closed&&(clearInterval(i),o())},500)})}import{useEffect as Pn,useMemo as wn}from"react";import{useStore as ii}from"zustand";function Tn(e){let t=wn(()=>Rn(e),[e]),n=In(t.services.access?.id),o=wn(()=>Cn(t.services.probe,n),[t.services.probe]),s=ii(o);return Pn(()=>{s.status==="unknown"&&!n&&s.probe()},[t.services.probe,s.status]),Pn(()=>{n&&(s.setToken(n),s.probe())},[n]),[e,s,t.hasAuth]}import{jsx as Ue}from"react/jsx-runtime";var ve=Ct(null),li=Ct(null);li.displayName="CurrentAuth";var ui=Ct(null);ui.displayName="AuthActions";function kn({children:e}){let t=si(()=>bn(),[]);return Ue(ve.Provider,{value:t,children:e})}function En(){return!!Mn(ve)}function Ne(){let e=Mn(ve);if(!e)throw new Error("useAuthActions must be used within a AuthProvider");return e}function ci(){let e=Ne();return Ve(e,n=>({login:n.login,logout:n.logout,nextAuth:n.nextAuth,previousAuth:n.previousAuth,setAuth:n.setAuth,addService:n.addService,removeService:n.removeService}))}function hc(){let e=Ne();return Ve(e,t=>t)}function di(e){let t=Ne();return Ve(t,o=>o.authItems.find(s=>s.service.id===e))}function In(e){let t=Ne();return Ve(t,o=>o.authItems.find(s=>s.id===e)?.session?.token)}function yc(e){let t=Ne();return Ve(t,o=>{let s=o.authItems.find(i=>i.service.id===e);return!s||!s.isLoggedIn||!s.session?null:s.session?.token||null})}function mi(e){let t=ci(),n=di(e.service.id);return ai(()=>(t?.addService(e.service,e.probeId),()=>{t?.removeService(e.service,e.probeId)}),[e.service]),n?(n.error||!n.isLoggedIn,e.children):null}function bt(){return null}function Vn(e){let[t,n,o]=Tn(e.resource),s=e.fallbackComponent||bt,i=e.loadingComponent||bt,r=e.errorComponent||bt,a=n.service,l=null;if(!o||!a)return e.children(t);let u=a.service.filter(g=>g.type==="AuthAccessService2");n.status==="error"&&(l=Ue(r,{resource:e.resource,error:n.error||"",heading:n.errorHeading,note:n.errorNote,extra:e.extra})),(n.status==="unknown"||n.status==="probing")&&(l=Ue(i,{})),n.status==="success"&&(l=e.children(t));for(let g of u)l=Ue(mi,{service:g,probeId:a.id,children:l},g.id);return l}import{createContext as hi,useContext as wc,useMemo as yi}from"react";import{createStore as pi}from"zustand/vanilla";var fi=e=>e.id||e["@id"];function gi(e){return(Array.isArray(e.service)?e.service:[e.service]).find(n=>n.profile==="http://iiif.io/api/search/0/autocomplete"||n.profile==="http://iiif.io/api/search/1/autocomplete"||n.profile==="AutoCompleteService1")}var Nn=e=>{let t;typeof e=="string"?t={"@context":"http://iiif.io/api/search/1/context.json",profile:"http://iiif.io/api/search/1/search","@id":e,id:e,service:[]}:t=e;let n=t?fi(t):void 0,o=null;return pi((s,i)=>({service:t,resources:[],lastQuery:{},loading:!1,error:!1,highlight:null,hasSearch:!!t,hasAutocomplete:t?!!gi(t):!1,errorMessage:"",search(r,a={}){if(!n)throw new Error("No search service found.");o&&!o.signal.aborted&&o.abort(),o=new AbortController;let l=new URLSearchParams;r.q&&l.set("q",r.q),r.motivation&&l.set("motivation",r.motivation),r.date&&l.set("date",r.date),r.user&&l.set("user",r.user),s({loading:!0}),fetch(`${n}?${l.toString()}`,{signal:o.signal,headers:{"Content-Type":"application/json",Accept:"application/json",...a.headers||{}}}).then(async u=>{if(!o?.signal.aborted)if(u.ok){let g=await u.json();s({resources:g.resources,error:!1,errorMessage:""})}else s({resources:[],error:!0,errorMessage:u.statusText})})},clearSearch(){s({resources:[],error:!1,errorMessage:""})},highlightResult(r){let a=i().resources.find(l=>l["@id"]===r);s({highlight:a})},nextResult(){let r=i().resources,a=i().highlight;if(!a){s({highlight:r[0]||null});return}let l=r.findIndex(u=>u["@id"]===a["@id"]);if(l===-1){s({highlight:r[0]||null});return}s({highlight:r[l+1]||r[0]||null})},previousResult(){let r=i().resources,a=i().highlight;if(!a){s({highlight:r[r.length-1]||null});return}let l=r.findIndex(u=>u["@id"]===a["@id"]);if(l===-1){s({highlight:r[r.length-1]||null});return}if(l===0){s({highlight:r[r.length-1]||null});return}s({highlight:r[l-1]||r[r.length-1]||null})}}))};import{useStore as Ec}from"zustand";function Ln(){let e=B();return e?e.service.find(t=>t.profile==="SearchService1"||t.profile==="http://iiif.io/api/search/1/search"):void 0}import{jsx as Rt}from"react/jsx-runtime";var Se=hi(null);Se.displayName="Search";function zn(e){let t=Ln();return e.store?Rt(Se.Provider,{value:e.store,children:e.children}):Rt(vi,{service:t,children:e.children})}function vi({service:e,children:t}){let n=yi(()=>Nn(e),[e]);return Rt(Se.Provider,{value:n,children:t})}import{jsx as F}from"react/jsx-runtime";var Le=()=>{},ze=xi({setCurrentCanvasId:Le,setCurrentCanvasIndex:Le,nextCanvas:Le,previousCanvas:Le,items:[],sequence:[],setSequenceIndex:Le,currentSequenceIndex:0,hasNext:!1,hasPrevious:!1});function Ci(e){let t=B(),{cursor:n,visibleItems:o,next:s,sequence:i,items:r,setCanvasIndex:a,setCanvasId:l,previous:u,setSequenceIndex:g,hasNext:c,hasPrevious:d}=vn({startCanvas:e.startCanvas,disablePaging:e.pagingEnabled===!1}),p=bi(()=>({sequence:i,items:r,setCurrentCanvasId:l,nextCanvas:s,previousCanvas:u,totalCanvases:r.length,setCurrentCanvasIndex:a,setSequenceIndex:g,currentSequenceIndex:n,hasNext:c,hasPrevious:d}),[i,r,l,s,u,r,a,g,n]);return t?o.length===0?null:F(ze.Provider,{value:p,children:F(he.Provider,{value:o,children:F(ee,{canvas:o[0],children:e.children})})}):(console.warn("The manifest passed to the provider is not a valid IIIF manifest."),F("div",{children:"Sorry, something went wrong."}))}function On(e){let t=ye(e.vault),n=pn(e.manifest);if(!n)return console.warn("The manifest passed to the provider is not a valid IIIF manifest."),F("div",{children:"Sorry, something went wrong."});if(n.error)return F("div",{children:n.error.toString()});if(!n.isLoaded)return F("div",{children:"Loading..."});let o=F(Ci,{...e,children:e.children});return F(ge,{vault:t,children:F(fn,{manifest:n.id,children:F(kn,{children:F(zn,{children:e.rangeId?F(gn,{range:e.rangeId,children:o}):o})})})})}function _e(){return Si(ze)}import{ModeContext as Vi}from"@atlas-viewer/atlas";import{createContext as Ni,useContext as Wn,useEffect as Li,useMemo as zi}from"react";import{useStore as Oi}from"zustand";import Ri from"mitt";import{createContext as Ai,useContext as Bn,useEffect as Pi}from"react";import{jsx as Ti}from"react/jsx-runtime";var wi=Ri(),At=Ai(wi);function id({children:e,emitter:t}){return Ti(At.Provider,{value:t,children:e})}function Hn(){return Bn(At)}function Dn(e,t,n=[]){let o=Bn(At);Pi(()=>{let s=i=>{t(i)};return o.on(e,s),()=>{o.off(e,s)}},[o,e,...n])}import{createHelper as Mi}from"polygon-editor";import{createStore as ki}from"zustand/vanilla";function Pt(e){let t=Math.max(...e.map(i=>i[0])),n=Math.min(...e.map(i=>i[0])),o=Math.max(...e.map(i=>i[1])),s=Math.min(...e.map(i=>i[1]));for(let i of e)if(i[0]!==n&&i[0]!==t&&i[1]!==s&&i[1]!==o||i[0]<n||i[0]>t||i[1]<s||i[1]>o)return!1;return!0}function xe(e){if(!e)return null;if(e.points.length>2){let t=Math.min(...e.points.map(i=>i[0])),n=Math.min(...e.points.map(i=>i[1])),o=Math.max(0,...e.points.map(i=>i[0])),s=Math.max(0,...e.points.map(i=>i[1]));return{x:t,y:n,width:o-t,height:s-n}}return null}function Ii(e){return e.type==="SvgSelector"}function cd(e){return e.type==="BoxSelector"}function wt(e,t){if(Ii(e)){let r=e.svgShape==="polyline";if(!e.points||e.points.length===0)return null;if(t){let{width:a,height:l}=t;return{type:"SvgSelector",value:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${a} ${l}" width="${a}" height="${l}"><${r?"polygon":"polyline"} points="${e.points.map(g=>g.join(",")).join(" ")}" /></svg>`}}return{type:"SvgSelector",value:`<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'><g><path d='M${e.points.map(a=>a.join(",")).join(" ")}${r?" Z":""}' /></g></svg>`}}if(!e.spatial)return null;let{x:n,y:o,width:s,height:i}=e.spatial||{};return!s||!i?null:{type:"FragmentSelector",value:`xywh=${~~n},${~~o},${~~s},${~~i}`}}function Tt(e,t){if(!e||!e.points.length)return null;if(Pt(e.points)){let n=e.points.map(l=>l[0]),o=e.points.map(l=>l[1]),s=Math.min(...n),i=Math.min(...o),r=Math.max(...n)-s,a=Math.max(...o)-i;return wt({type:"BoxSelector",spatial:{x:s,y:i,width:r,height:a}},t)}return wt({type:"SvgSelector",points:e.points,svgShape:e.open?"polygon":"polyline"},t)}function qn(e){if(e.type==="polygon"&&!e.noBox&&e.points&&Pt(e.points)){let n=xe({open:!1,points:e.points||[]});return qn({...e,type:"box",selector:n})}if(e.type==="polygon"||e.type==="draw")return{polygon:{points:e.points||[],open:e.open||!1},requestType:e.type,boundingBox:xe({points:e.points||[],open:!1}),metadata:{},arguments:e.arguments||{},target:Tt({points:e.points||[],open:!1},e.bounds)};let t=e.selector;if(t){let n=[[t.x,t.y],[t.x+t.width,t.y],[t.x+t.width,t.y+t.height],[t.x,t.y+t.height]];return{polygon:{points:n,open:!1},requestType:e.type,boundingBox:t,metadata:{},target:Tt({points:n,open:!1},e.bounds),arguments:e.arguments||{}}}return{polygon:{points:[],open:!1},requestType:e.type,boundingBox:null,target:null,metadata:{},arguments:e.arguments||{}}}var Ei={shapeId:null,noShape:!0,transitioning:!1,actionIntentType:null,transitionIntentType:null,selectedPoints:[],hasClosestLine:!1,lastCreationTool:null,modifiers:{Alt:!1,Shift:!1,Meta:!1,proximity:0},bounds:null,showBoundingBox:!1,currentModifiers:{},validIntentKeys:{},pointerInsideShape:!1,closestPoint:null,transitionModifiers:null,selectedStamp:null,bezierLines:[],boxMode:!1,fixedAspectRatio:!1,cursor:"",enabledTools:["pointer","pen","box","lineBox","stamp","hand","line","pencil"],canDelete:!0,canDeselect:!0,isToolSwitchingLocked:!1,currentTool:"box",snapEnabled:!1,snapToPoints:!1,snapToLines:!1,snapToIntersections:!1,snapToGrid:!1,snapToParallel:!1};function $n({events:e,enabledTools:t,keyboardShortcutMapping:n,keyboardShortcutsEnabled:o=!1,debug:s}){let i=ki((a,l)=>{let u=null,c=Mi({emitter:e,keyboardShortcutsEnabled:o,keyboardShortcutMapping:n,enabledTools:t,customSetState:d=>{s&&console.log("partial state",d),a(p=>({polygonState:{...p.polygonState,...d}}))}},d=>{a(p=>p.tool.requestId?{polygon:{...d,id:p.tool.requestId}}:{polygon:{id:void 0,points:[],open:!0}}),e.emit("atlas.polygon-update",d)});return{mode:"explore",tool:{enabled:!1,requestId:null,canvasId:null},runtime:null,requestType:null,requests:{},history:c.history,polygon:null,validRequestIds:[],metadata:{},stableViewport:null,canvasRelativePositions:{},canvasViewports:{},polygons:c,polygonState:Ei,setMetadata:(d,p)=>{let y=p||l().tool.requestId;y&&a(f=>({metadata:{...f.metadata,[y]:{...f.metadata[y]||{},...d}}}))},setToolCanvasId:d=>{a(p=>({tool:{...p.tool,canvasId:d}}))},switchTool:{pointer(){a({mode:"sketch"}),r.tools.setTool("pointer")},hand(){a({mode:"explore"}),r.tools.setTool("hand")},draw(){a({mode:"sketch"}),r.tools.setTool("pencil")},pen(){a({mode:"sketch"}),r.tools.setTool("pen")},line(){a({mode:"sketch"}),r.tools.setTool("line")},lineBox(){a({mode:"sketch"}),r.tools.setTool("lineBox")},box(){a({mode:"sketch"}),r.tools.setTool("box")},triangle(){a({mode:"sketch"}),r.tools.setTool("stamp"),r.stamps.triangle()},hexagon(){a({mode:"sketch"}),r.tools.setTool("stamp"),r.stamps.hexagon()},circle(){a({mode:"sketch"}),r.tools.setTool("stamp"),r.stamps.circle()},remove(){let d=l();d.tool.requestId&&(c.setShape({points:[],open:!0}),d.cancelRequest(d.tool.requestId))}},reset:()=>{let d=l();d.tool.requestId&&d.cancelRequest(d.tool.requestId)},setPolygonState:d=>a({polygonState:typeof d=="function"?d(l().polygonState):d}),getRequestId:()=>{let d=Math.random().toString(36).slice(2);return a(p=>({validRequestIds:[...p.validRequestIds,d]})),{requestId:d,clear:()=>{l().tool.requestId,a(p=>({tool:p.tool.requestId===d?{enabled:!1,requestId:null,canvasId:null}:p.tool,validRequestIds:p.validRequestIds.filter(y=>y!==d)}))}}},cancelRequest:d=>{let p=d||l().tool.requestId;p&&(a(y=>({mode:"explore",tool:y.tool.requestId===p?{enabled:!1,requestId:null,canvasId:null}:y.tool,validRequestIds:y.validRequestIds.filter(f=>f!==p)})),e.emit("atlas.request-cancelled",{id:p}))},requestAnnotation:async(d,p)=>{let f={...l().requests,[p.requestId]:d},x=qn(d);s&&console.log("requestAnnotation",{response:x,request:d});try{let{points:v=[],open:m=!0}=x.polygon||{},{requestId:h,canvasId:S=null,toolId:b}=p,C=b,R=l(),P=R.validRequestIds.includes(h),L=x.requestType;return s&&console.log("setting points",{requestType:L,points:v,open:m}),!P||R.tool.enabled?null:(c.setShape({id:h,points:v,open:m}),L==="polygon"&&(C=C||"pen",c.tools.setTool("pen")),L==="draw"&&(C=C||"draw",c.tools.setTool("pencil")),L==="box"&&(C=C||"box",c.tools.setTool("box")),L==="target"?(C=C||"box",c.tools.setTool("box"),c.lockAspectRatio(),c.tools.lockToolSwitching(),c.tools.setCanDeselect(!1),c.tools.setCanDelete(!1)):(c.tools.unlockToolSwitching(),c.tools.setCanDeselect(!0),c.tools.setCanDelete(!0)),d.bounds&&c.setBounds(d.bounds),e.emit("atlas.annotation-request",{id:h}),a({polygon:{id:h,points:v,open:m},mode:"sketch",requestType:L,tool:{enabled:!0,requestId:h,canvasId:S},requests:f}),C?R.switchTool[C]?.():v.length===0&&R.switchTool.box(),(typeof d.selectByDefault>"u"&&v.length&&L==="box"||d.selectByDefault)&&R.switchTool.pointer(),new Promise(re=>{let T=w=>{w.id===h&&(a(I=>({mode:"explore",tool:{requestId:null,enabled:!1,canvasId:null},requests:Object.fromEntries(Object.entries(I.requests).filter(([E])=>E!==h))})),e.off("atlas.request-cancelled",T),e.off("atlas.annotation-completed",z),re(null))},z=w=>{w.id===h&&(a(I=>({mode:"explore",tool:{requestId:null,enabled:!1,canvasId:null},requests:Object.fromEntries(Object.entries(I.requests).filter(([E])=>E!==h))})),e.off("atlas.annotation-completed",z),e.off("atlas.request-cancelled",T),re(w))};e.on("atlas.request-cancelled",T),e.on("atlas.annotation-completed",z)}))}catch(v){return console.error(v),null}},completeRequest:d=>{let p=l().tool.requestId;if(typeof d=="string"&&d&&d!==p)return;let y=p?l().requests[p]?.arguments||{}:{},f=p?l().metadata[p]||{}:{},x=l().polygonState.bounds,v=l().polygon;v&&(e.emit("atlas.annotation-completed",{id:v.id,polygon:v,requestType:l().requestType,target:Tt(v,x),canvasId:l().tool.canvasId,boundingBox:xe(v),metadata:f,arguments:{...y}}),c.setShape(null))},setAtlasRuntime:d=>{u=d,e.emit("atlas.ready",{runtime:d}),r.setScale(1/u._lastGoodScale),u.world.addLayoutSubscriber((p,y)=>{(p==="event-activation"||p==="zoom-to"||p==="go-home")&&u?._lastGoodScale&&!Number.isNaN(u._lastGoodScale)&&r.setScale(1/u._lastGoodScale)}),a({runtime:u})},clearAtlasRuntime:()=>{u=null,a({stableViewport:null,runtime:null})},setCanvasRelativePosition:(d,p)=>{a(y=>({canvasRelativePositions:{...y.canvasRelativePositions,[d]:p}}))},clearCanvasRelativePosition:d=>{a(p=>{let y={...p.canvasRelativePositions};return delete y[d],{canvasRelativePositions:y}})},changeMode:d=>{a({mode:d})},nudgeLeft:d=>{if(!u)return;let p=u.getViewport(),y=d??p.width*.1;u.world.gotoRegion({x:p.x-y,y:p.y,width:p.width,height:p.height,nudge:!0})},nudgeRight:d=>{if(!u)return;let p=u.getViewport(),y=d??p.width*.1;u.world.gotoRegion({x:p.x+y,y:p.y,width:p.width,height:p.height,nudge:!0})},nudgeUp:d=>{if(!u)return;let p=u.getViewport(),y=d??p.height*.1;u.world.gotoRegion({x:p.x,y:p.y-y,width:p.width,height:p.height,nudge:!0})},nudgeDown:d=>{if(!u)return;let p=u.getViewport(),y=d??p.height*.1;u.world.gotoRegion({x:p.x,y:p.y+y,width:p.width,height:p.height,nudge:!0})},zoomIn:()=>{u?.world?.zoomIn()},zoomOut:()=>{u?.world?.zoomOut()},goHome:()=>{u?.world?.goHome()},goToRegion:d=>{u?.world?.gotoRegion(d)},getRuntime:()=>u}}),r=i.getState().polygons;return e.on("atlas.annotation-request",()=>{r.clock.start((a,l,u)=>{e.emit("atlas.polygon-render",{state:a,slowState:l,dt:u})},a=>{typeof a=="object"?i.setState({polygonState:a}):i.setState(l=>({polygonState:a(l.polygonState)}))})}),e.on("atlas.annotation-completed",()=>{r.clock.stop()}),e.on("atlas.request-cancelled",()=>{r.clock.stop()}),i}import{jsx as Fn}from"react/jsx-runtime";var be=Ni(null);function q(){return Wn(be)}var It={};function Un(e="atlas"){return It[e]?.getState()}function Oe({children:e,name:t="atlas",existing:n,atlasStoreConfig:o}){let s=Hn(),i=Wn(be),r=zi(()=>n||i||$n({events:s,...o||{}}),[s,n,i]),a=Oi(r,l=>l.mode);return Li(()=>{let l=t;return l&&(It[l]=r),()=>{l&&delete It[l]}},[r,t]),Fn(be.Provider,{value:r,children:Fn(Vi.Provider,{value:a||"explore",children:e})})}import{mergeStyles as Ye}from"@atlas-viewer/atlas";import{useMemo as ta}from"react";import{createContext as Bi,useContext as Hi,useMemo as Di}from"react";import{jsx as qi}from"react/jsx-runtime";function _n(){return{default:{backgroundColor:"rgba(0,0,0,0)",borderWidth:"2px",borderColor:"rgba(252,0,98, .5)"},highlighted:{backgroundColor:"rgba(75, 103, 225, 0.4)",borderWidth:"1px",borderColor:"rgba(75,103,225,0.99)"},hidden:{borderWidth:"0px",borderColor:"rgba(0,0,0,0)",backgroundColor:"rgba(0,0,0,0)",hidden:!0}}}var Mt=Bi(_n());Mt.displayName="AnnotationStyle";function jn(){return Hi(Mt)}function Td({theme:e,children:t}){let n=Di(()=>e||_n(),[e]);return qi(Mt.Provider,{value:n,children:t})}import{expandTarget as ji}from"@iiif/helpers/annotation-targets";import{useMemo as Ki}from"react";import{useEffect as $i,useMemo as Fi,useState as Wi}from"react";import{create as Ui}from"zustand";var _i=Ui()((e,t)=>{let n=new Map,o=()=>Math.random().toString(36).substring(2,15),s=i=>{let r=n.get(i);if(r)return r;let a=o();return n.set(i,a),a};return{stylesheets:{},loading:[],errors:[],async parseStylesheet(i){let{loadStylesheet:r,setStylesheet:a}=t();if(!i)return null;if(typeof i=="string")return i.startsWith("http")?{id:i,type:"CssStylesheet",value:await r(i)}:{id:a(i),type:"CssStylesheet",value:i};if(i.type==="CssStylesheet"){let l=i.id;if("value"in i){let u=Array.isArray(i.value)?i.value.join(`
|
|
2
|
-
`):i.value;if(u)return{id:a(u,l),type:"CssStylesheet",value:u}}if("id"in i&&i.id){let u=await r(i.id);return{id:i.id,type:"CssStylesheet",value:u}}}return null},async loadStylesheet(i){if(t().loading.includes(i))return"";try{let a=await fetch(i);if(!a.ok)throw new Error(`Failed to load stylesheet from ${i}`);let l=await a.text();return e(u=>({stylesheets:{...u.stylesheets,[i]:l}})),l}catch(a){return e(l=>({errors:[...l.errors,{url:i,error:a}]})),""}},setStylesheet(i,r){let a=r||s(i);return e(l=>({stylesheets:{...l.stylesheets,[a]:i}})),a}}});function Kn(e){let[t,n]=Wi(""),{loading:o,errors:s,stylesheets:i,parseStylesheet:r}=_i();return $i(()=>{e&&r(e).then(l=>{l?.id&&n(l.id)})},[e,r]),[Fi(()=>{let l={};return t&&i[t]&&(l[t]=i[t]),l},[t,i]),{id:t,stylesheets:i,loading:o,errors:s}]}function je(e={},t=[]){let{id:n,selector:o}=e,s=_(),i=M(),r=n||s.annotation,a=k(g=>r?g.iiif.entities.Annotation[r]:void 0,[r]),[l]=Kn(a?.stylesheet),u=k(g=>a&&a.body?a.body.map(c=>c?c.type==="SpecificResource"?{...c,source:i.get(c)}:c?g.iiif.entities[c.type][c.id]:null:null).filter(Boolean):[],[a]);return Ki(()=>{if(!a)return;let g={...a,body:u,target:ji(a.target,{typeMap:i.getState().iiif.mapping,loadedStylesheets:l})};return o?o(g):g},[a,o,u,l,...t])}import{useMemo as Yi}from"react";function A(e={},t=[]){let{id:n,selector:o}=e,s=_(),i=n||s.canvas,r=k(a=>i?a.iiif.entities.Canvas[i]:void 0,[i]);return Yi(()=>{if(r)return o?o(r):r},[r,o,...t])}import{useMemo as Yn}from"react";import{createEventsHelper as Gi}from"@iiif/helpers/events";function Ke(e,t){let n=M(),o=Yn(()=>Gi(n),[n]),s=k(()=>e&&e.id?n.getResourceMeta(e.id,"eventManager"):null,[e]);return Yn(()=>e?o.getListenersAsProps(e,t):{},[s,e,n,t])}import{useMemo as Qi}from"react";import{createStylesHelper as Xi}from"@iiif/helpers/styles";function Ce(e,t){let n=M(),o=Qi(()=>Xi(n),[n]);return k(()=>{if(!e)return null;let s=o.getAppliedStyles(e.id);return s?t?s[t]:s:void 0},[e,t])}import{useCallback as ea}from"react";import{HTMLPortal as Zi,useResizeWorldItem as Ji}from"@atlas-viewer/atlas";import{useMemo as te}from"react";import{Fragment as kt,jsx as K,jsxs as Et}from"react/jsx-runtime";function Gn({handleSize:e,resizable:t,onSave:n,children:o,maintainAspectRatio:s,disableCardinalControls:i,aspectRatio:r,...a}){let l=typeof e>"u"?s?12:8:e,{portalRef:u,mode:g,mouseEvent:c,isEditing:d}=Ji({x:a.x||0,y:a.y||0,width:a.width,height:a.height,aspectRatio:r,maintainAspectRatio:s},n),p=te(()=>c("translate"),[c]),y=te(()=>c("east"),[c]),f=te(()=>c("west"),[c]),x=te(()=>c("south"),[c]),v=te(()=>c("north"),[c]),m=te(()=>c("south-east"),[c]),h=te(()=>c("south-west"),[c]),S=te(()=>c("north-east"),[c]),b=te(()=>c("north-west"),[c]),C=g==="sketch",R={zIndex:999,boxShadow:"0px 2px 3px 0 rgba(0,0,0,0.2)",outline:"2px solid rgba(155,155,155,.7)",borderRadius:s||i?"50%":2,position:"absolute",background:"#fff",pointerEvents:d?"none":C?"initial":"none"};return K(kt,{children:Et("world-object",{...a,children:[o,C&&t?K(Zi,{ref:u,target:{x:0,y:0,height:a.height,width:a.width},relative:!0,interactive:!1,children:C&&t?Et(kt,{children:[K("div",{onMouseDown:p,onTouchStart:p,style:{display:"block",width:"100%",height:"100%",cursor:"move",border:"1px solid rgba(255,255,255, .7)",outline:"2px solid rgba(155,155,155, .7)",boxSizing:"border-box",pointerEvents:d?"none":C?"initial":"none"}}),s?null:Et(kt,{children:[K("div",{title:"east",onTouchStart:y,onMouseDown:y,style:{...R,cursor:"e-resize",height:l*2,width:l,right:0,top:"50%",opacity:i?0:1,transform:`translate(${l/2}px, -${l}px)`}}),K("div",{title:"west",onMouseDown:f,style:{...R,cursor:"w-resize",position:"absolute",height:l*2,width:l,left:0,top:"50%",opacity:i?0:1,transform:`translate(-${l/2}px, -${l}px)`}}),K("div",{title:"north",onMouseDown:v,style:{...R,cursor:"n-resize",position:"absolute",height:l,width:l*2,left:"50%",top:0,opacity:i?0:1,transform:`translate(-${l}px, -${l/2}px)`}}),K("div",{title:"south",onMouseDown:x,style:{...R,cursor:"s-resize",position:"absolute",height:l,width:l*2,left:"50%",bottom:0,opacity:i?0:1,transform:`translate(-${l}px, ${l/2}px)`}})]}),K("div",{title:"north-east",onMouseDown:S,style:{...R,cursor:"ne-resize",position:"absolute",height:l,width:l,right:0,top:0,transform:`translate(${l/2}px, -${l/2}px)`}}),K("div",{title:"south-east",onMouseDown:m,style:{...R,cursor:"se-resize",position:"absolute",height:l,width:l,bottom:0,right:0,transform:`translate(${l/2}px, ${l/2}px)`}}),K("div",{title:"south-west",onMouseDown:h,style:{...R,cursor:"sw-resize",position:"absolute",height:l,width:l,bottom:0,left:0,transform:`translate(-${l/2}px, ${l/2}px)`}}),K("div",{title:"north-west",onMouseDown:b,style:{...R,cursor:"nw-resize",position:"absolute",height:l,width:l,top:0,left:0,transform:`translate(-${l/2}px, -${l/2}px)`}})]}):null}):null]})})}import{jsx as Qn}from"react/jsx-runtime";function Xn({id:e,interactive:t,region:n,onClick:o,onHover:s,onSave:i,aspectRatio:r,maintainAspectRatio:a,disableCardinalControls:l,isEditing:u,style:g={backgroundColor:"rgba(0,0,0,.5)"}}){let c=ea(d=>{u&&i?.({id:n.id,x:n.x,y:n.y,height:n.height,width:n.width,...d})},[i,u,n.id,n.x,n.y,n.height,n.width]);return Qn(Gn,{id:e,x:n.x,y:n.y,width:n.width,aspectRatio:r,height:n.height,resizable:u,onSave:c,maintainAspectRatio:a,disableCardinalControls:l,children:Qn("box",{interactive:t,onClick:d=>{d.preventDefault(),d.stopPropagation(),o?.(n)},relativeStyle:!0,onMouseEnter:()=>{s?.(n)},target:{x:0,y:0,width:n.width,height:n.height},style:g})})}import{jsx as na}from"react/jsx-runtime";var Re=({id:e,style:t,className:n,interactive:o,targetId:s,ignoreTargetId:i})=>{let r=je({id:e}),a=Ce(r,"atlas"),l=Ce(r,"html"),u=Ke(r,["atlas"]),g=A(),c=jn(),d=ta(()=>Ye(Ye(Ye(Ye(t,a),r?.motivation?.includes("highlighting")?c.highlighted:c.default),r?.target?.selector?.boxStyle||{})),[t,a,c,r?.motivation,r?.target]),p=s||g?.id;return g&&r&&r.target&&r.target.selector&&(r.target.selector.type==="BoxSelector"||r.target.selector.type==="SvgSelector")&&r.target.source&&(i?!0:r.target.source.id===p||r.target.source===p)?na(Xn,{id:r.id,isEditing:!0,region:r.target.selector.spatial,style:d,className:l?.className||n,interactive:!!(l?.href||o),href:l?.href||null,title:l?.title||null,hrefTarget:l?.target||null,onClick:()=>{},...u}):null};import{Fragment as ra}from"react";import{useMemo as oa}from"react";function Zn(e={},t=[]){let{id:n,selector:o}=e,s=_(),i=n||s.annotationPage,r=k(a=>i?a.iiif.entities.AnnotationPage[i]:void 0,[i]);return oa(()=>{if(r)return o?o(r):r},[r,...t])}import{jsx as Jn}from"react/jsx-runtime";var ue=({className:e,page:t,targetId:n,ignoreTargetId:o})=>{let s=Zn({id:t.id})||t,i=Ce(s,"atlas"),r=Ce(s,"html");return k(a=>s.id?a.iiif.entities.AnnotationPage[s.id]:null,[]),Jn(ra,{children:s.items?.map(a=>Jn(Re,{id:a.id,style:i,className:r?.className||e,targetId:n,ignoreTargetId:o},a.id))})};import{createContext as Nt,useContext as Lt}from"react";import{jsx as Vt}from"react/jsx-runtime";var eo=Nt(null),to=Nt(null),no=Nt(null);function Em(){let e=Lt(eo);if(!e)throw new Error("Ctx not found");return e}function Vm(){let e=Lt(to);if(!e)throw new Error("Ctx not found");return e}function Nm(){let e=Lt(no);if(!e)throw new Error("Ctx not found");return e}function Ge({actions:e,state:t,children:n,currentTime:o,progress:s,element:i}){return Vt(no.Provider,{value:{currentTime:o,progress:s,element:i},children:Vt(to.Provider,{value:e,children:Vt(eo.Provider,{value:t,children:n})})})}import{useMemo as ia}from"react";import{expandTarget as aa}from"@iiif/helpers";function Qe(){let e=B(),t=A();return ia(()=>{if(!e||!t||!e.start)return null;let n=aa(e.start);return!n||n.source.id!==t.id||!n||!n.selector||n.selector.type!=="TemporalSelector"?null:n.selector.temporal},[e,t])}import{useCallback as Q,useEffect as zt,useReducer as sa,useRef as Xe}from"react";function oo(e){return{isMuted:!1,playRequested:!1,isPlaying:!1,isFinished:!1,volume:100,duration:e}}function la(e,t){switch(t.type){case"RESET":return t.state;case"FINISHED":return{...e,isFinished:!0,isPlaying:!1,playRequested:!1};case"PLAY_PAUSE":return{...e,isFinished:!1,isPlaying:!e.isPlaying};case"PLAY_REQUESTED":return{...e,isFinished:!1,playRequested:!0};case"PAUSE":return{...e,isPlaying:!1};case"PLAY":return{...e,isFinished:!1,playRequested:!1,isPlaying:!0};case"MUTE":return{...e,isMuted:!0};case"SET_VOLUME":return{...e,volume:t.volume,isMuted:t.volume===0};case"TOGGLE_MUTE":return{...e,isMuted:!e.isMuted};case"UNMUTE":return{...e,isMuted:!1}}return e}function Ot(e){let t=Math.round(e);return`${Math.floor(t/60)}:${`${t%60}`.padStart(2,"0")}`}function Ae(e){let[t,n]=sa(la,oo(e.duration));zt(()=>{n({type:"RESET",state:oo(e.duration)})},[e.duration]);let o=Xe(null),s=Xe(null),i=Xe(null),r=Xe(!1),a=Q(()=>{s.current&&o.current&&(s.current.innerHTML=Ot(o.current.currentTime),i.current&&(i.current.style.width=`${o.current.currentTime/e.duration*100}%`),r.current!==o.current.muted&&(r.current=o.current.muted,n(o.current.muted?{type:"MUTE"}:{type:"UNMUTE"})))},[e.duration]),l=Q(()=>{o.current&&(n({type:"PLAY_REQUESTED"}),o.current.play().then(()=>{n({type:"PLAY"})}),a())},[a]),u=Q(()=>{o.current&&(o.current.duration>0&&o.current.paused?l():g())},[a]),g=Q(()=>{o.current&&(o.current.pause(),n({type:"PAUSE"}),a())},[a]),c=Q(()=>{o.current&&(o.current.muted=!o.current.muted,n(o.current.muted?{type:"MUTE"}:{type:"UNMUTE"}))},[]),d=Q(()=>{o.current&&(o.current.muted=!0,n({type:"MUTE"}))},[]),p=Q(()=>{o.current&&(o.current.muted=!1,n({type:"UNMUTE"}))},[]),y=Q(v=>{o.current&&(o.current.muted=!1,o.current.volume=v/100,n({type:"SET_VOLUME",volume:v}))},[]),f=Q(v=>{o.current&&(o.current.currentTime=Math.max(0,Math.min(v*e.duration,e.duration)),a())},[]),x=Q(v=>{if(o.current){let m=typeof v=="function"?v(o.current.currentTime):v;o.current.currentTime=Math.max(0,Math.min(m,e.duration)),a()}},[]);return zt(()=>{let v=setInterval(()=>{a()},350);return()=>clearInterval(v)},[a,e.duration]),zt(()=>{let v=()=>{n({type:"FINISHED"})},m=o.current;return m?.addEventListener("ended",v),()=>m?.removeEventListener("ended",v)},[]),[{element:o,currentTime:s,progress:i},t,{play:l,pause:g,playPause:u,mute:d,unmute:p,toggleMute:c,setVolume:y,setDurationPercent:f,setTime:x}]}import{createContext as ro,useContext as ua,useEffect as ca}from"react";var Bt=ro(()=>{}),Ht=ro(()=>{});function D(e,t,n,o,s=[]){let i=ua(e==="portal"?Ht:Bt);ca(()=>(e!=="none"&&i(t,n,o),()=>{i(t,null)}),[t,e,i,...s])}import{jsx as da,jsxs as ma}from"react/jsx-runtime";function Dt({media:e,startTime:t,children:n}){let[{element:o,currentTime:s,progress:i},r,a]=Ae({duration:e.duration}),l=t?`${e.url}#t=${t}`:e.url;return ma(Ge,{state:r,actions:a,currentTime:s,progress:i,element:o,children:[da("audio",{ref:o,src:l}),n]},e.url)}function Ze({media:e,mediaControlsDeps:t,audioCopmonent:n=Dt,children:o}){let s=Qe();return D("portal","audio",n,{media:e,startTime:s?s.startTime:null,children:o},[e,s,...t||[]]),null}import{createContext as pa,useContext as fa}from"react";var ce=pa(null);ce.displayName="Strategy";function V(){let e=fa(ce);if(!e)throw new Error("useStrategy must be used within a StrategyProvider");return e}import{Fragment as ga,jsx as qt,jsxs as ha}from"react/jsx-runtime";function $t({model:e}){return ha(ga,{children:[qt("style",{children:`
|
|
3
|
-
.model-container {
|
|
4
|
-
position: absolute;
|
|
5
|
-
top: 0;
|
|
6
|
-
bottom: 0;
|
|
7
|
-
left: 0;
|
|
8
|
-
right: 0;
|
|
9
|
-
background: #000;
|
|
10
|
-
z-index: 13;
|
|
11
|
-
display: flex;
|
|
12
|
-
justify-content: center;
|
|
13
|
-
pointer-events: visible;
|
|
14
|
-
}
|
|
15
|
-
`}),qt("div",{className:"model-container",children:qt("model-viewer",{"interaction-prompt":"none",style:{width:"100%",height:"100%"},"camera-controls":"","ar-status":"not-presenting",src:e.id})})]})}function Je({model:e,name:t}){return D("overlay",`model-${t}`,$t,{model:e},[e]),null}import{jsx as ya}from"react/jsx-runtime";function io(){let{strategy:e}=V();return e.type!=="3d-model"?null:ya(Je,{model:e.model})}import{createContext as va,useContext as Sa}from"react";var et=va(null);et.displayName="Controls";function $(){let e=Sa(et);if(!e)throw new Error("useStrategy must be used within a StrategyProvider");return e}import{Fragment as xa,jsx as tt,jsxs as ba}from"react/jsx-runtime";function ao(){let{strategy:e}=V(),{renderViewerControls:t,viewControlsDeps:n}=$(),o=A(),s=o?.accompanyingCanvas,i=o?.placeholderCanvas;return ba(xa,{children:[e.type==="media"&&e.media.type==="Sound"&&s?tt(ee,{canvas:s.id,children:tt(de,{renderViewerControls:t,viewControlsDeps:n})}):null,e.type==="media"&&e.media.type==="Sound"&&i&&!s?tt(ee,{canvas:i.id,children:tt(de,{renderViewerControls:t,viewControlsDeps:n})}):null]})}import{createContext as wa,useContext as Ta,useMemo as Ia}from"react";import{useCallback as lo,useLayoutEffect as Ra,useMemo as Aa,useRef as Pa}from"react";import{entityActions as Ft}from"@iiif/helpers/vault/actions";import{useMemo as Ca}from"react";function so(){let t=M().getStore();return Ca(()=>n=>t.dispatch(n),[t])}function uo(e){return typeof e!="string"&&e&&e.bindToVault}function co(){let e=M(),t=Pa([]),n=so(),o=Aa(()=>`vault://annotation-page/${new Date().getTime()}/${Math.round(Math.random()*1e9).toString(16)}`,[]);Ra(()=>{let a={id:o,type:"AnnotationPage",behavior:[],label:null,thumbnail:[],summary:null,requiredStatement:null,metadata:[],rights:null,provider:[],items:[],seeAlso:[],homepage:[],rendering:[],service:[]};n(Ft.importEntities({entities:{AnnotationPage:{[a.id]:a}}}))},[o]);let s=k(a=>o&&a.iiif.entities.AnnotationPage[o]||null,[o]),i=lo((a,l)=>{if(o){if(uo(a)){let c=a;c.__vault||c.bindToVault(e),a=typeof c.source=="string"?c.source:c.source.id,t.current[a]=c}else typeof a!="string"&&(a=a.id);let u=e.get({id:o,type:"AnnotationPage"}),g=e.get({id:a,type:"Annotation"});u&&g&&(u.items.find(c=>c.id===g.id)||n(Ft.addReference({id:o,type:"AnnotationPage",key:"items",reference:{id:a,type:"Annotation"},index:l})))}},[o]),r=lo(a=>{o&&(uo(a)?a=typeof a.source=="string"?a.source:a.source.id:typeof a!="string"&&(a=a.id),t.current[a]&&t.current[a].beforeRemove(),e.get({id:o,type:"AnnotationPage"})&&n(Ft.removeReference({id:o,type:"AnnotationPage",key:"items",reference:{id:a,type:"Annotation"}})))},[o]);return[s,{addAnnotation:i,removeAnnotation:r}]}import{jsx as Ma}from"react/jsx-runtime";var mo=wa(null);function po(){let e=Ta(mo);return[e.fullPage,{addAnnotation:e.addAnnotation,removeAnnotation:e.removeAnnotation}]}function fo({children:e}){let[t,{addAnnotation:n,removeAnnotation:o}]=co();return Ma(mo.Provider,{value:Ia(()=>({fullPage:t,addAnnotation:n,removeAnnotation:o}),[t]),children:e})}import{Fragment as ka,jsx as go,jsxs as Ea}from"react/jsx-runtime";function ho({children:e}){let{strategy:t}=V(),[n]=po();return t.type!=="images"?null:Ea(ka,{children:[n?go(ue,{page:n}):null,t.annotations&&t.annotations.pages?t.annotations.pages.map(o=>go(ue,{page:o},o.id)):null,e]})}import{useEffect as Ba,useMemo as Ha,useRef as Da,useState as qa}from"react";import{useEffect as Va}from"react";var yo=(e,t=[])=>{let n=M();Va(()=>{e(n)},[n,...t])};import Na,{useContext as La}from"react";import{ImageServiceLoader as za}from"@iiif/helpers/image-service";var Oa=Na.createContext(new za);function vo(){return La(Oa)}import{createThumbnailHelper as $a}from"@iiif/helpers/thumbnail";function Pe(e,t,{canvasId:n,manifestId:o}={}){let s=M(),i=vo(),r=Ha(()=>$a(s,{imageServiceLoader:i}),[s,i]),[a,l]=qa(),u=B(o?{id:o}:void 0),g=A(n?{id:n}:void 0),c=g||u,d=Da(!1);if(Ba(()=>(d.current=!1,()=>{d.current=!0}),[]),!c)throw new Error("Must be called under a manifest or canvas context.");return yo(p=>{r.getBestThumbnailAtSize(c,e,t).then(y=>{y.best&&!d.current&&l(y.best)})},[c]),a}import{jsx as So}from"react/jsx-runtime";function we({x:e=0,y:t=0}){let n=A(),o=Pe({maxWidth:256,maxHeight:256});return!n||!o||o.type!=="fixed"?null:So("world-object",{height:n.height,width:n.width,x:e,y:t,children:So("world-image",{uri:o.id,target:{x:0,y:0,width:n.width,height:n.height},display:o.width&&o.height?{width:o.width,height:o.height}:void 0,crop:void 0})})}import{jsx as Fa,jsxs as Wa}from"react/jsx-runtime";function xo({as:e}){let{strategy:t}=V(),{renderMediaControls:n,mediaControlsDeps:o}=$();return t.type!=="media"||t.media.type!=="Sound"?null:Wa(Ze,{media:t.media,mediaControlsDeps:o,audioCopmonent:e,children:[Fa(we,{}),n?n(t):null]},t.media.url)}import{HTMLPortal as Do}from"@atlas-viewer/atlas";import{useLayoutEffect as ls,useMemo as us}from"react";import{useStore as qo}from"zustand";import{createContext as Ua,useContext as _a}from"react";import{useStore as ja}from"zustand";import{jsx as Ka}from"react/jsx-runtime";var Wt=Ua(null);Wt.displayName="ComplexTimeline";function bo({children:e,store:t}){return Ka(Wt.Provider,{value:t,children:e})}function cf(e){let t=_a(Wt);if(!t)throw new Error("useComplexTimeline must be used within a ComplexTimelineProvider");return ja(t,e)}import Ya from"mitt";import{createStore as Ga}from"zustand/vanilla";function Co({currentKeyFrameIndex:e,keyframes:t,targetTime:n,currentTime:o}){if(o<=n){let s=t.findIndex(a=>a.time>n);if(s===-1)return[e,[]];let i={},r=t.slice(e,s);for(let a of r)a.type==="enter"&&(i[a.id]=a),a.type==="exit"&&(i[a.id]?delete i[a.id]:i[a.id]=a);return[s,Object.values(i)]}return[e,[]]}function Ro({complexTimeline:e,startTime:t=0}){let n=Ya(),o={},s={progress:null,currentTime:null},i=0,r=null,a=0,l=null;function u(){let m=x.getState().visibleElements,h=o,S=[],b=Object.keys(h);for(let C of b){let R=h[C],P=m[C];R&&P&&S.push(R)}return S}function g(){return Object.keys(o).map(m=>o[m])}function c(v){s.currentTime&&(s.currentTime.innerHTML=Ot(v),s.progress&&(s.progress.style.width=`${v/e.duration*100}%`))}let d=()=>{let v=x.getState(),m=v.currentPrime;if(!m)return;let h=o,S=v.visibleElements,b=Object.keys(h);for(let C of b){let R=h[C],P=S[C];if(R&&C!==m.id&&P){let L=a-P.time*1e3;Math.abs(a-P.time*1e3-R.currentTime*1e3)>300&&(R.currentTime=L/1e3)}}},p=(v=0)=>{let m=v-i,h=x.getState();if(h.isPlaying){let S=h.currentPrime;if(S){let P=o[S.id];P&&(P.paused?a+=m:a=(S.time+P.currentTime)*1e3)}else a+=m;let b=a/1e3;if(b>h.duration){x.getState().setTime(0),x.setState({isPlaying:!1}),y(),c(0);return}c(b);let[C,R]=Co({currentTime:b,currentKeyFrameIndex:h.nextKeyframeIndex,keyframes:h.complexTimeline.keyframes,targetTime:b});R.length&&h.applyKeyframes(C,R)}i=v,r=requestAnimationFrame(p)},y=()=>{r&&cancelAnimationFrame(r)},f=(v,m)=>{},x=Ga((v,m)=>({complexTimeline:e,elements:{},visibleElements:{},isBuffering:!1,bufferMap:{},isMuted:!1,playRequested:!1,isPlaying:!1,isFinished:!1,isReady:!1,volume:100,duration:e.duration,clockStartRequests:0,clockStartTime:0,primeTime:0,currentPrime:null,clockRunning:!1,nextKeyframeIndex:0,startClock:()=>{m().clockRunning||(p(),l=setInterval(d,500)),v({clockRunning:!0,clockStartRequests:m().clockStartRequests+1})},applyKeyframes(h,S){let b=m(),C={...b.visibleElements},R=b.currentPrime;for(let P of S)P.type==="enter"&&(C[P.id]=P,n.emit("complex-timeline.enter",{id:P.id})),P.type==="exit"&&(C[P.id]=null,n.emit("complex-timeline.exit",{id:P.id})),P.isPrime&&(R=P);v({nextKeyframeIndex:h,visibleElements:C,currentPrime:R})},stopClock:()=>{let h=m().clockStartRequests;if(h!==0){if(h===1){y(),l&&clearInterval(l),v({clockRunning:!1,clockStartRequests:0});return}v({clockStartRequests:h-1})}},setElement:(h,S)=>{o[h]=S;let b=Object.keys(o),C=m().complexTimeline;f(S,h),C.items.filter(P=>P.type!=="Image"&&P.type!=="Text").every(P=>b.includes(P.annotationId))&&!m().isReady&&(n.emit("complex-timeline.ready",{complexTimeline:C}),v({isReady:!0}))},removeElement:h=>{delete o[h]},mute(){for(let h of g())h.muted=!0;v({isMuted:!0})},unmute(){for(let h of g())h.muted=!1;v({isMuted:!1})},play(){if(!m().isPlaying){for(let S of u())S.play();v({isPlaying:!0})}},pause(){if(m().isPlaying){for(let S of u())S.pause();v({isPlaying:!1})}},playPause(){let h=m();h.isPlaying?h.pause():h.play()},setDurationPercent(h){let b=m().duration*h;m().setTime(b)},setTime(h){let S=m(),b=a/1e3,C=typeof h=="function"?h(b):h,R=S.nextKeyframeIndex;if(b>C){v({visibleElements:{},currentPrime:null});let I=Object.keys(S.visibleElements);for(let E of I)n.emit("complex-timeline.exit",{id:E});b=0,R=0}let[P,L]=Co({currentTime:b,currentKeyFrameIndex:R,keyframes:S.complexTimeline.keyframes,targetTime:C});S.applyKeyframes(P,L),a=C*1e3;let T=x.getState().visibleElements,z=o,w=Object.keys(T);for(let I of w){let E=T[I];if(E){let Ee=z[I];Ee&&(Ee.currentTime=(a-E.time*1e3)/1e3)}}c(C)},setVolume(h){for(let S of g())S.volume=Math.min(1,Math.max(0,h/100));v({volume:h})},toggleMute(){let h=m();h.isMuted?(h.unmute(),v({isMuted:!1})):(h.mute(),v({isMuted:!0}))},clearProgressElement(){s.progress=null},setProgressElement(h){s.progress=h},setCurrentTimeElement(h){s.currentTime=h},clearCurrentTimeElement(){s.currentTime=null}}));return n.on("complex-timeline.enter",v=>{let m=x.getState(),h=v.id,S=o[h];S&&m.isPlaying&&S.play()}),n.on("complex-timeline.exit",v=>{let m=x.getState(),h=v.id,S=o[h];S&&(S.currentTime=0,S.pause())}),x.getState().setTime(t),{store:x,emitter:n}}import{Fragment as Oo,useMemo as Bo}from"react";import{HTMLPortal as os}from"@atlas-viewer/atlas";import{getId as rs}from"@iiif/parser/image-3";import Qa,{useContext as Xa}from"react";import{imageServices as Za}from"@iiif/helpers/image-service";import{useStore as nt}from"zustand";var Ao=Qa.createContext(Za.store);Ao.displayName="ImageServicesHelper";function ot(){return Xa(Ao)}function Po(e){let t=ot();return nt(t,({loaded:n})=>n[e])}function rt(){let e=ot();return nt(e,({loadServiceSync:t})=>t)}function wo(){let e=ot();return nt(e,({loaded:t})=>t)}function bf(){let e=ot();return nt(e,({loadService:t})=>t)}import Te,{useMemo as Ut}from"react";import{jsx as X}from"react/jsx-runtime";var Io=Te.createContext("en"),Mo=Te.createContext({}),ko=Te.createContext(null);function Pf(e){return X(Mo.Provider,{value:e.translations,children:e.children})}function wf(e){return X(Io.Provider,{value:e.language,children:e.children})}function Tf(e){return X(ko.Provider,{value:e.convert,children:e.children})}function Eo(){return Te.useContext(ko)}function _t(){return Te.useContext(Io)}function Vo(){return Te.useContext(Mo)}function To(e){return e.indexOf("-")!==-1?e.slice(0,e.indexOf("-")):e}function Ja({as:e,language:t,children:n,viewingDirection:o,...s}){let i=_t();return Ut(()=>To(i)===To(t),[i,t])?e?X(e,{...s,children:n}):X("span",{...s,children:n}):e?X(e,{...s,lang:t,dir:o,children:n}):X("span",{...s,lang:t,dir:o,children:n})}function No(e,t,n){if(t.length===0)return;if(t.length===1)return t[0];if(t.indexOf(e)!==-1)return e;let o=e.indexOf("-")!==-1?e.slice(0,e.indexOf("-")):null;if(o&&t.indexOf(o)!==-1)return o;for(let s of n)if(t.indexOf(s)!==-1)return s;return t.indexOf("none")!==-1?"none":t.indexOf("@none")!==-1?"@none":t[0]}var es=(e,t=[])=>{let n=_t();return Ut(()=>{let o=e();return No(n,o,[])},[n,...t])};function me(e,t,n,o){return t?n?n(e[t]||t,o||"none"):e[t]||t:""}function ts(e,t,n=`
|
|
16
|
-
`,o={}){let s=Eo(),i=es(()=>Object.keys(e||{}),[e]);return[Ut(()=>{if(!e)return me(o,t,s)||"";if(typeof e=="string")return me(o,e,s);let r=i?e[i]:void 0;return r?typeof r=="string"?r:r.map(a=>me(o,a,s,i)).join(n):""},[i,t,e]),i]}function If(){let e=_t(),t=Vo(),n=Eo();return function(s,i="",r=`
|
|
17
|
-
`,a=t){let l=Object.keys(s||{}),u=No(e,l,[]);if(!s)return me(a,i,n)||"";if(typeof s=="string")return me(a,s,n);let g=u?s[u]:void 0;return g?typeof g=="string"?me(a,g,n,u):g.map(c=>me(a,c,n,u)).join(typeof r<"u"?r:`
|
|
18
|
-
`):""}}function Be({as:e,defaultText:t,enableDangerouslySetInnerHTML:n,children:o,separator:s,...i}){let r=Vo(),[a,l]=ts(o,t,s,r);return l?X(Ja,{...i,as:e,language:l,title:n?void 0:a,dangerouslySetInnerHTML:n?{__html:a}:void 0,children:n?void 0:a}):e?X(e,{...i,children:a}):X("span",{...i,title:n?void 0:a,dangerouslySetInnerHTML:n?{__html:a}:void 0,children:n?void 0:a})}import{isImageServiceLevel as Lo}from"@iiif/parser/image-3";import{useMemo as jt}from"react";import{jsx as it,jsxs as ns}from"react/jsx-runtime";var Kt=e=>{let t=e.format||"jpg",n=e.width/(e.crop?.width||e.tiles.width),o=e.tiles.imageService.sizes||[],s=e.enableThumbnail,i=e.enableSizes,r=jt(()=>{let u=e.tiles.imageService.id||e.tiles.imageService["@id"];return u?.endsWith("/info.json")?u.slice(0,-1*10):u},[e.tiles.imageService.id,e.tiles.imageService["@id"]]),a=jt(()=>{let u=e.tiles.imageService.tiles||[];if(!u.length){let g=e.width,c=[1],d=1;for(;2**d<g;)d=d*2,c.push(d);return(e.tiles.imageService.maxArea||e.tiles.imageService.maxWidth||e.tiles.imageService.maxHeight)&&Lo(2,e.tiles.imageService)?[{width:256,height:256,scaleFactors:c}]:Lo(2,e.tiles.imageService)?[{width:256,height:256,scaleFactors:c}]:[]}return u},[e.tiles.imageService,e.width]),l=jt(()=>{let u=e.tiles.imageService;return(u?u["@context"]?Array.isArray(u["@context"])?u["@context"]:[u["@context"]]:[]:[]).indexOf("http://iiif.io/api/image/3/context.json")!==-1},[e.tiles.imageService.id,e.tiles.imageService]);return it("world-object",{rotation:e.rotation,scale:n,height:e.crop?.height||e.tiles.height,width:e.crop?.width||e.tiles.width,x:e.x,y:e.y,onClick:e.onClick,children:ns("composite-image",{id:e.tiles.imageService.id,width:e.crop?.width||e.tiles.width,height:e.crop?.height||e.tiles.height,crop:e.crop,renderOptions:e.renderOptions,children:[s&&e.tiles.thumbnail?it("world-image",{priority:!0,uri:e.tiles.thumbnail.id,target:{width:e.tiles.width,height:e.tiles.height},display:{width:e.tiles.thumbnail.width,height:e.tiles.thumbnail.height},crop:e.crop}):null,i&&o.map((u,g)=>it("world-image",{uri:`${r}/full/${u.width},${l?u.height:""}/0/default.${t}`,target:{width:e.tiles.width,height:e.tiles.height},display:{width:u.width,height:u.height},crop:e.crop},g)),a.map(u=>(u.scaleFactors||[]).map(g=>it("tiled-image",{uri:e.tiles.imageService.id,display:{width:e.tiles.width,height:e.tiles.height},format:t,tile:u,scaleFactor:g,crop:e.crop,version3:l},`${e.tiles.imageService.id}-tile-${g}`)))]},e.tiles.imageService.id)},e.tiles.imageService.id)};import{jsx as ne,jsxs as as}from"react/jsx-runtime";function is({resource:e,heading:t,note:n,extra:o}){return o?ne(os,{target:{x:0,y:0,width:o.target?.spatial.width,height:o.target?.spatial.height},backgroundColor:"#333",relative:!0,children:ne("div",{style:{display:"flex",alignContent:"center",justifyContent:"center",alignItems:"center",height:"100%",width:"100%",background:"#444",color:"#BBB"},children:as("div",{children:[ne(Be,{children:t||"Not authorised"}),n&&ne("p",{children:ne(Be,{children:n})}),ne("p",{children:e.id||e["@id"]||"unknown"})]})})}):null}function zo({image:e,thumbnail:t,crop:n,enableSizes:o,enableThumbnail:s,renderOptions:i,rotation:r}){let a=En(),l=rs(e.service),u=Po(l),g=rt(),c=u?.service;g(e.service,e);let d=c&&u?.status==="done",p=(c?.preferredFormats||[])[0],y=t&&t.type==="fixed"&&t.id&&!t.id.includes("/full/full/")&&!t.id.includes("/max/")?t:void 0;if(d===!1)return null;if(!a){let f=e.service,x=f.width||e.width||0,v=f.height||e.height||0,m=0,h=0,S=e.target?.spatial.width||x,b=e.target?.spatial.height||v,C=S,R=b;return(r===90||r===270)&&([S,b]=[b,S],m=(C-S)/2,h=(R-b)/2),ne(Kt,{enableThumbnail:s,renderOptions:i,rotation:r,tiles:{id:f.id||f["@id"]||"unknown",height:v,width:x,imageService:f,thumbnail:y},enableSizes:o,x:m,y:h,format:p,width:S,height:b,crop:n})}return ne(Vn,{resource:e.service,errorComponent:is,extra:e,children:f=>{let x=f.width||e.width||0,v=f.height||e.height||0,m=0,h=0,S=e.target?.spatial.width||x,b=e.target?.spatial.height||v,C=S,R=b;return(r===90||r===270)&&([S,b]=[b,S],m=(C-S)/2,h=(R-b)/2),ne(Kt,{enableThumbnail:s,renderOptions:i,tiles:{id:f.id||f["@id"]||"unknown",height:v,width:x,imageService:f,thumbnail:y},rotation:r,format:p,enableSizes:o,x:m,y:h,width:S,height:b,crop:n})}},e.id)}import{jsx as Yt,jsxs as Gt}from"react/jsx-runtime";function Ie({id:e,image:t,thumbnail:n,isStatic:o,x:s=0,y:i=0,children:r,selector:a,onClick:l,enableSizes:u,enableAnnotations:g}){let c=Bo(()=>{if(!(!a||a.spatial.x===0&&a.spatial.y===0))return a.spatial},[a]),d=Bo(()=>{if(typeof t.rotation<"u")return t.rotation;if(!t.annotation)return 0;let S=Array.isArray(t.annotation.body)?t.annotation.body?.[0]:t.annotation.body;if(S&&S.selector?.type==="ImageApiSelector")return Number(S.selector.rotation)},[t]),p=!!t.service,y=s+t.target.spatial.x,f=i+t.target.spatial.y,x=t.target.spatial.width,v=t.target.spatial.height,m=t.target.spatial.width,h=t.target.spatial.height;return(d===90||d===270)&&([m,h]=[h,m],p||([x,v]=[v,x],y+=(t.target.spatial.width-x)/2,f+=(t.target.spatial.height-v)/2)),Gt("world-object",{x:y,y:f,width:x,height:v,onClick:l,rotation:p?0:d,children:[t.service?Gt(Oo,{children:[Yt(zo,{image:t,thumbnail:n,crop:c,enableSizes:u,rotation:d}),r]},"service"):Gt(Oo,{children:[Yt("world-image",{onClick:l,uri:t.id,target:{x:0,y:0,width:m,height:h},display:m&&h?{width:m,height:h}:void 0,crop:c}),r]},"no-service"),g&&t.annotationPages?t.annotationPages.map(S=>Yt(ue,{page:S,className:"image-service-annotation",ignoreTargetId:!0},S.id)):null]},e+(p?"server":"no-service"))}import{HTMLPortal as ss}from"@atlas-viewer/atlas";import{Fragment as Ho,jsx as He}from"react/jsx-runtime";function at({strategy:e,onClickPaintingAnnotation:t}){return He(Ho,{children:e.items.map((n,o)=>He(Ho,{children:He(ss,{onClick:t?s=>{s.stopPropagation(),t(n.annotationId,n,s)}:void 0,target:n.target?.spatial||void 0,children:He("div",{"data-textual-content":!0,children:He(Be,{enableDangerouslySetInnerHTML:!0,children:n.text})})},o)}))})}import{Fragment as cs,jsx as pe,jsxs as ds}from"react/jsx-runtime";function $o({strategy:e,children:t}){let{store:n}=us(()=>Ro({complexTimeline:e}),[e]),o=qo(n,r=>r.isReady),s=qo(n,r=>r.visibleElements);function i(r){return a=>{a&&n.getState().setElement(r,a)}}return ls(()=>{if(o){let{startClock:r,stopClock:a}=n.getState();return r(),()=>{a()}}},[e,o]),D("portal","custom-controls",bo,{store:n,children:t},[o]),ds(cs,{children:[e.items.map(r=>r.type!=="Image"||!s[r.annotationId]?null:pe(Ie,{image:r,id:r.annotationId},r.id)),e.items.map((r,a)=>r.type!=="Text"||!s[r.annotationId]?null:pe(at,{strategy:{type:"textual-content",items:[r]}},a)),e.items.map((r,a)=>r.type!=="Video"||!r.target.spatial?null:pe(Do,{target:r.target.spatial,children:pe("video",{ref:i(r.annotationId),src:r.url,style:{height:"100%",width:"100%",opacity:s[r.annotationId]?1:0}})},a)),e.items.map((r,a)=>r.type!=="Sound"?null:pe(Do,{children:pe("audio",{ref:i(r.annotationId),src:r.url})},a)),e.highlights.map(({annotation:r})=>s[r.id]?pe(Re,{id:r.id,ignoreTargetId:!0,style:{outline:"3px solid red"},className:"image-service-annotation"},r.id):null)]})}import{jsx as ms}from"react/jsx-runtime";function Fo(){let{strategy:e}=V(),{renderComplexTimelineControls:t}=$();return e.type!=="complex-timeline"?null:ms($o,{strategy:e,children:t?t(e):null})}import{jsx as ps}from"react/jsx-runtime";function st({style:e}){let t=A();return!t||!t.height||!t.width?null:ps("box",{interactive:!1,target:{x:0,y:0,width:Number(t.width),height:Number(t.height)},style:e})}import{jsx as fs}from"react/jsx-runtime";function Wo({backgroundStyle:e,alwaysShowBackground:t}){let{strategy:n}=V();return n.type!=="empty"&&!t?null:fs(st,{style:e})}import{createContext as gs,useContext as hs}from"react";var fe=gs(null);function lt(){return hs(fe)}import{Fragment as vs,jsx as ys,jsxs as Ss}from"react/jsx-runtime";function Uo({isStatic:e=!1,enableSizes:t=!1,enableAnnotations:n=!0,onClickPaintingAnnotation:o,children:s}){let{strategy:i}=V(),{renderViewerControls:r,viewControlsDeps:a}=$(),l=A(),u=lt(),g=Pe({maxWidth:256,maxHeight:256});return D(u&&i.type==="images"&&r?"overlay":"none",`canvas-portal-controls-${l?.id}`,fe.Provider,r?{value:u||null,children:r(i)}:{},[l,u,i,...a||[]]),i.type!=="images"?null:Ss(vs,{children:[i.images.map((c,d)=>ys(Ie,{isStatic:e,image:c,id:c.id,thumbnail:d===0?g:void 0,selector:c.selector,enableSizes:t,enableAnnotations:n,onClick:o?p=>{o(c.annotationId,c,p)}:void 0},c.id+d)),s]})}import{Fragment as bs,jsx as xs,jsxs as Cs}from"react/jsx-runtime";function _o({onClickPaintingAnnotation:e,children:t}){let{strategy:n}=V(),{renderViewerControls:o,viewControlsDeps:s}=$(),i=lt(),r=A();return D(i&&n.type==="textual-content"&&o?"overlay":"none",`canvas-portal-controls-${r?.id}`,fe.Provider,o?{value:i||null,children:o(n)}:{},[r,i,n,...s||[]]),n.type!=="textual-content"?null:Cs(bs,{children:[xs(at,{strategy:n,onClickPaintingAnnotation:e}),t]})}import{jsx as jo,jsxs as Rs}from"react/jsx-runtime";function Qt({element:e,media:t,startTime:n,playPause:o,poster:s}){let i="div",r=n?`${t.url}#t=${n}`:t.url;return Rs(i,{className:"video-container",part:"video-container",onClick:o,children:[jo("style",{children:`
|
|
19
|
-
.video-container {
|
|
20
|
-
position: absolute;
|
|
21
|
-
top: 0;
|
|
22
|
-
bottom: 0;
|
|
23
|
-
left: 0;
|
|
24
|
-
right: 0;
|
|
25
|
-
background: #000;
|
|
26
|
-
z-index: 13;
|
|
27
|
-
display: flex;
|
|
28
|
-
justify-content: center;
|
|
29
|
-
pointer-events: visible;
|
|
30
|
-
}
|
|
31
|
-
`}),jo("video",{poster:s,ref:e,src:r,style:{width:"100%",objectFit:"contain"}})]})}function ut({media:e,mediaControlsDeps:t,children:n,videoComponent:o=Qt,captions:s}){let i=A(),r=Qe(),a=i&&i.placeholderCanvas&&i.placeholderCanvas.id||void 0,l=Pe({},!1,{canvasId:a}),[{element:u,currentTime:g,progress:c},d,p]=Ae({duration:e.duration});return D("overlay","video-element",o,{element:u,media:e,playPause:p.playPause,poster:l?.id,canvas:i,startTime:r?r.startTime:null,captions:s},[l]),D("portal","custom-controls",Ge,{state:d,actions:p,currentTime:g,progress:c,element:u,children:n},[g,d,e,...t||[]]),null}import{jsx as As,jsxs as Ps}from"react/jsx-runtime";function Ko({as:e}){let{strategy:t}=V(),{renderMediaControls:n,mediaControlsDeps:o}=$();return t.type!=="media"||t.media.type!=="Video"?null:Ps(ut,{captions:t.captions,media:t.media,mediaControlsDeps:o,videoComponent:e,children:[As(we,{}),n?n(t):null]},t.media.url)}import{useRef as ws}from"react";import{jsx as Yo,jsxs as Is}from"react/jsx-runtime";function Ts({element:e,media:t,playPause:n}){let o=ws(null);return t.youTubeId?Is("div",{className:"video-container",part:"video-container",onClick:n,children:[Yo("style",{children:`
|
|
32
|
-
.video-container {
|
|
33
|
-
position: absolute;
|
|
34
|
-
top: 0;
|
|
35
|
-
bottom: 0;
|
|
36
|
-
left: 0;
|
|
37
|
-
right: 0;
|
|
38
|
-
background: #000;
|
|
39
|
-
z-index: 13;
|
|
40
|
-
display: flex;
|
|
41
|
-
justify-content: center;
|
|
42
|
-
pointer-events: visible;
|
|
43
|
-
}
|
|
44
|
-
.video-yt {
|
|
45
|
-
border: none;
|
|
46
|
-
width: 100%;
|
|
47
|
-
object-fit: contain;
|
|
48
|
-
}
|
|
49
|
-
`}),Yo("iframe",{className:"video-yt",ref:o,src:`https://www.youtube.com/embed/${t.youTubeId}?enablejsapi=1&origin=${window.location.host}`,referrerPolicy:"no-referrer",sandbox:"allow-scripts allow-same-origin allow-presentation"})]}):null}function Go({media:e,mediaControlsDeps:t,children:n}){let[{element:o,currentTime:s,progress:i},r,a]=Ae({duration:e.duration});return D("overlay","video-element",Ts,{element:o,media:e,playPause:a.playPause}),null}import{jsx as Ms,jsxs as ks}from"react/jsx-runtime";function Qo(){let{strategy:e}=V(),{renderMediaControls:t,mediaControlsDeps:n}=$();return e.type!=="media"||e.media.type!=="VideoYouTube"?null:ks(Go,{media:e.media,mediaControlsDeps:n,children:[Ms(we,{}),t?t(e):null]})}import{startTransition as sl,useMemo as ll}from"react";import{useStore as J}from"zustand";import{HTMLPortal as Ls,useAtlas as zs}from"@atlas-viewer/atlas";import{useCallback as Jt,useEffect as en}from"react";import{createSvgHelpers as Es}from"polygon-editor";import{useEffect as Vs,useRef as Z,useState as Zo}from"react";import{useStore as Xt}from"zustand";function Xo(e){let t=q(),n=Xt(t,i=>i.polygons),o=Xt(t,i=>i.polygonState),s=Xt(t,i=>i.polygon);return Dn("atlas.polygon-render",({state:i,slowState:r,dt:a})=>{e(i,r,a)}),{currentShape:s,state:o,helper:n}}import{Fragment as Zt,jsx as N,jsxs as Me}from"react/jsx-runtime";var oe=Es(),Ns={shapeFill:"#ffffff33",shapeStroke:"#000",lineStroke:"#000",ghostLineStroke:"#0F0",activeLineStroke:"#4D7EEA",boundingBoxDottedStroke:"#0007",boundingBoxStroke:"#fffA",controlFill:"#fff"};function Jo(e){let{image:t}=e,n={...Ns,...e.theme||{}},o=Z(),s=Z(),i=Z(),r=Z(),a=Z(),l=Z(),u=Z(),g=Z(),c=Z(),d=Z(),[p,y]=Zo(null),[f,x]=Zo(!1),{helper:v,state:m,currentShape:h}=Xo((T,z)=>{if(T.closestLineIndex,oe.updateTransitionBoundingBox(i.current,T,z),oe.updateBoundingBoxPolygon(o.current,T,z),oe.updateBoundingBoxPolygon(s.current,T,z),oe.updateTransitionShape(u.current,T,z),oe.updateClosestLinePointTransform(a.current,T,z),oe.updateSelectBox(r.current,T,z),oe.updatePointLine(g.current,T,z),oe.updateDrawPreview(l.current,T,z,3),oe.updateLineBox(c.current,T),y(T.transitionDirection),x(T.transitionRotate),T.closestLineIndex!==-1&&d.current){let w=T.polygon,I=w.points[T.closestLineIndex],E=w.points[(T.closestLineIndex+1)%w.points.length];I&&E&&d.current.setAttribute("points",`${I[0]},${I[1]} ${E[0]},${E[1]}`)}});Vs(()=>{let T=()=>{v.modifiers.reset()};return document.addEventListener("mouseleave",T),()=>{document.removeEventListener("mouseleave",T)}},[]);let S=Me(Zt,{children:[Me("marker",{id:"dot",viewBox:"0 0 10 10",refX:"5",refY:"5",markerWidth:"5",markerHeight:"5",children:[N("circle",{cx:"5",cy:"5",r:"5",fill:n.lineStroke,className:"marker"}),N("circle",{cx:"5",cy:"5",r:"3",fill:n.controlFill})]}),N("marker",{id:"newdot",viewBox:"0 0 10 10",refX:"5",refY:"5",markerWidth:"5",markerHeight:"5",children:N("circle",{cx:"5",cy:"5",r:"5",fill:n.activeLineStroke,className:"marker"})}),Me("marker",{id:"selected",viewBox:"0 0 10 10",refX:"5",refY:"5",markerWidth:"5",markerHeight:"5",children:[N("circle",{cx:"5",cy:"5",r:"5",fill:n.lineStroke}),N("circle",{cx:"5",cy:"5",r:"3",fill:n.activeLineStroke})]}),Me("marker",{id:"resizer",viewBox:"0 0 10 10",refX:"5",refY:"5",markerWidth:"6",markerHeight:"6",children:[N("rect",{width:"10",height:"10",fill:n.lineStroke}),N("rect",{x:"1",y:"1",width:"8",height:"8",fill:n.controlFill})]})]}),b=h?h.open?"polyline":"polygon":null,C=!m.showBoundingBox&&m.closestPoint!==null&&m.actionIntentType==="select-point",R=m.actionIntentType==="add-open-point",P=m.transitionIntentType==="split-line",L=m.transitioning&&m.selectedStamp&&m.transitionIntentType==="stamp-shape",re=h&&b?Me(Zt,{children:[N(b,{fill:(!m.transitioning||m.transitionIntentType==="select-multiple-points")&&!h.open?n.shapeFill:"none",strokeWidth:L||m.showBoundingBox&&m.boxMode||m.transitioning&&m.transitionIntentType==="split-line"||m.transitioning&&m.transitionIntentType==="move-point"?0:2,stroke:n.shapeStroke,points:h.points.map(T=>T.join(",")).join(" "),vectorEffect:"non-scaling-stroke",markerStart:m.showBoundingBox?void 0:m.boxMode?"url(#resizer)":"url(#dot)",markerMid:m.showBoundingBox?void 0:m.boxMode?"url(#resizer)":"url(#dot)",markerEnd:m.showBoundingBox?void 0:m.boxMode?"url(#resizer)":"url(#dot)",style:{pointerEvents:"none"},opacity:m.transitioning&&m.transitionIntentType==="move-shape"?0:1}),m.currentTool==="lineBox"&&m.actionIntentType==="close-line-box"?N("polygon",{fill:n.shapeFill,ref:c,stroke:n.lineStroke,strokeWidth:2,vectorEffect:"non-scaling-stroke"}):null,m.transitionIntentType==="draw-shape"&&m.transitioning?N("polyline",{ref:l,fill:"none",stroke:n.activeLineStroke,strokeWidth:2,vectorEffect:"non-scaling-stroke"}):null,!(m.transitioning&&m.transitionIntentType==="move-point")&&!(m.transitioning&&m.transitionIntentType==="stamp-shape")&&!m.showBoundingBox&&m.selectedPoints&&m.selectedPoints.length?N("polyline",{strokeWidth:2,vectorEffect:"non-scaling-stroke",stroke:"transparent",markerStart:"url(#selected)",markerMid:"url(#selected)",markerEnd:"url(#selected)",fill:"transparent",points:h.points.filter((T,z)=>m.selectedPoints?.includes(z)).map(T=>T.join(",")).join(" "),opacity:m.transitioning&&m.transitionIntentType==="move-shape"?0:1}):null,C&&!m.transitioning&&m.closestPoint!==null&&h.points[m.closestPoint]?N("polyline",{strokeWidth:2,vectorEffect:"non-scaling-stroke",stroke:"transparent",markerStart:"url(#selected)",markerMid:"url(#selected)",markerEnd:"url(#selected)",fill:n.activeLineStroke,points:`${h.points[m.closestPoint][0]},${h.points[m.closestPoint][1]}`,opacity:m.transitioning&&m.transitionIntentType==="move-shape"?0:1}):null,!m.transitioning&&(m.actionIntentType==="add-open-point"||m.actionIntentType==="close-shape"||m.actionIntentType==="close-shape-line")?N("polyline",{stroke:n.activeLineStroke,ref:g,strokeWidth:m.actionIntentType==="add-open-point"?1:2,vectorEffect:"non-scaling-stroke"}):null,m.hasClosestLine&&!m.showBoundingBox&&!m.transitioning&&m.currentTool!=="box"&&m.transitionIntentType==="split-line"?N("g",{children:N("polyline",{ref:d,vectorEffect:"non-scaling-stroke",fill:"transparent",stroke:n.activeLineStroke,strokeWidth:3})}):null,m.hasClosestLine&&!m.showBoundingBox&&!m.transitioning&&m.currentTool!=="box"&&m.transitionIntentType==="split-line"?N("g",{ref:a,children:N("polyline",{markerStart:"url(#newdot)",points:"0,0 1,1",vectorEffect:"non-scaling-stroke",stroke:"transparent",fill:"transparent",strokeWidth:2})}):null,m.transitioning?N(b,{ref:u,fill:h.open?"none":n.shapeFill,stroke:m.transitionIntentType==="stamp-shape"?n.activeLineStroke:n.shapeStroke,vectorEffect:"non-scaling-stroke",strokeWidth:(h.open,2)}):null,m.transitioning&&m.transitionIntentType==="select-multiple-points"?N("rect",{ref:r,fill:"rgba(255, 255, 255, .3)",strokeWidth:1,stroke:"rgba(0,0,0,.2)",vectorEffect:"non-scaling-stroke"}):null,m.showBoundingBox&&!L?Me(Zt,{children:[N("polygon",{ref:o,strokeWidth:2,stroke:n.boundingBoxStroke,fill:"none",markerStart:"url(#resizer)",markerMid:"url(#resizer)",markerEnd:"url(#resizer)",vectorEffect:"non-scaling-stroke"}),N("polygon",{ref:s,strokeWidth:2,stroke:n.boundingBoxDottedStroke,fill:"none",strokeDasharray:"4 4",markerStart:"url(#resizer)",markerMid:"url(#resizer)",markerEnd:"url(#resizer)",vectorEffect:"non-scaling-stroke"})]}):null]}):null;return{currentTool:v.state.slowState.currentTool,setCurrentTool:v.tools.setTool,helper:v,currentShape:h,state:m,isAddingPoint:R,isSplitting:P,isStamping:L,isHoveringPoint:C,transitionDirection:p,transitionRotate:f,defs:S,editor:re}}import{jsx as De,jsxs as Os}from"react/jsx-runtime";function er(e){let t=zs(),{image:n}=e,{helper:o,defs:s,editor:i,state:r,transitionDirection:a,isSplitting:l,transitionRotate:u,isHoveringPoint:g,isAddingPoint:c}=Jo({image:e.image,theme:e.theme}),d=Jt(f=>{f.button!==2&&o.pointer([[~~f.atlas.x,~~f.atlas.y]])},[o]),p=Jt(f=>{f.button!==2&&o.pointerDown()},[o]),y=Jt(f=>{f.button!==2&&o.pointerUp()},[o]);return en(()=>{let f=x=>{o.key.up(x.key)};return document.addEventListener("keyup",f),()=>{document.removeEventListener("keyup",f)}},[o]),en(()=>{let f=x=>{x.target&&["INPUT","TEXTAREA"].includes(x.target.tagName)||x.target?.isContentEditable||document.activeElement&&(document.activeElement instanceof HTMLInputElement||document.activeElement instanceof HTMLTextAreaElement||document.activeElement.isContentEditable)||o.key.down(x.key)};return document.addEventListener("keydown",f),()=>{document.removeEventListener("keydown",f)}},[o]),en(()=>{let f=[];return a&&f.push(`atlas-cursor-${a}`),r.actionIntentType==="cut-line"&&r.modifiers?.Shift&&f.push("atlas-cursor-cut"),(g||r.transitionIntentType==="move-shape"||r.transitionIntentType==="move-point")&&f.push("atlas-cursor-move"),c&&f.push("atlas-cursor-crosshair"),l&&f.push("atlas-cursor-copy"),u&&f.push("atlas-cursor-rotate"),r.transitionIntentType==="draw-shape"&&f.push("atlas-cursor-draw"),t?.canvas&&t.canvas.classList.add(...f),()=>{t?.canvas&&t.canvas.classList.remove(...f)}},[t?.canvas,c,g,l,r.modifiers?.Shift,r.actionIntentType,r.transitionIntentType,a,u]),De("world-object",{height:n.height,width:n.width,onMouseMove:d,onMouseDown:p,onMouseUp:y,onMouseLeave:o.blur,children:De(Ls,{relative:!0,interactive:!1,children:De("div",{className:"absolute top-0 right-0 left-0 bottom-0",children:Os("svg",{width:"100%",height:"100%",viewBox:`0 0 ${n.width} ${n.height}`,tabIndex:-1,children:[De("title",{children:"Annotation Editor"}),De("defs",{children:s}),i]})})})})}import{useCallback as nl}from"react";import{create as ol}from"zustand";import{HTMLPortal as js}from"@atlas-viewer/atlas";import{autoUpdate as Ks,flip as Ys,offset as Gs,shift as Qs,useDismiss as Xs,useFloating as Zs,useInteractions as Js}from"@floating-ui/react";import{createPortal as el}from"react-dom";import Ws,{useContext as W,useMemo as Us}from"react";import Bs from"react";import{createContext as Hs,useMemo as Ds}from"react";import qs from"mitt";import{jsx as Fs}from"react/jsx-runtime";var $s=qs(),ke=Hs({emitter:$s});ke.displayName="Events";function tr(){return Bs.useContext(ke).emitter}function Lh({emitter:e,children:t}){return Fs(ke.Provider,{value:Ds(()=>({emitter:e}),[e]),children:t})}import{jsx as U}from"react/jsx-runtime";var qe=Ws.createContext({});function ct(){let e=W(qe),t=Object.keys(e),n={};for(let o of t)e[o].Provider&&(n[o]={value:W(e[o]),Provider:e[o].Provider});return n}function _s(e){let t=Object.keys(e),n=e.children;for(let o of t){if(o==="children")continue;let{value:s,Provider:i}=e[o];n=U(i,{value:s,children:n})}return n}function Kh(e){let t=W(qe),n=Us(()=>({...t,...e.providers}),[e.providers]);return U(qe.Provider,{value:n,children:e.children})}function dt(){return{VaultContext:W(le),ResourceContext:W($e),SimpleViewerReactContext:W(ze),VisibleCanvasReactContext:W(he),AuthRContext:W(ve),SearchReactContext:W(Se),ReactEventContext:W(ke),ContextBridgeReactContext:W(qe),StrategyReactContext:W(ce),AtlasStoreReactContext:W(be)}}function mt(e){return U(ge,{vault:e.bridge.VaultContext.vault||void 0,resources:e.bridge.ResourceContext,children:U(he.Provider,{value:e.bridge.VisibleCanvasReactContext,children:U(ze.Provider,{value:e.bridge.SimpleViewerReactContext,children:U(ke.Provider,{value:e.bridge.ReactEventContext,children:U(be.Provider,{value:e.bridge.AtlasStoreReactContext,children:U(ve.Provider,{value:e.bridge.AuthRContext,children:U(Se.Provider,{value:e.bridge.SearchReactContext,children:U(qe.Provider,{value:e.bridge.ContextBridgeReactContext,children:U(ce.Provider,{value:e.bridge.StrategyReactContext,children:e.custom?U(_s,{...e.custom,children:e.children}):e.children})})})})})})})})})}import{jsx as tn,jsxs as tl}from"react/jsx-runtime";function pt({annotation:e,target:t,children:n,dismissable:o,isOpen:s,onOpenChange:i,placement:r}){let a=dt(),l=ct(),{refs:u,floatingStyles:g,context:c}=Zs({open:s,onOpenChange:i,nodeId:e.id,placement:r||"bottom",middleware:[Gs(10),Qs(),Ys({mainAxis:!0})],whileElementsMounted:Ks}),d=Xs(c),{getReferenceProps:p,getFloatingProps:y}=Js([o?d:null].filter(f=>f!==null));return tl(js,{relative:!0,target:t,interactive:!1,children:[tn("div",{ref:u.setReference,...p(),style:{position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none"}}),el(tn(mt,{bridge:a,custom:l,children:tn("div",{ref:u.setFloating,style:g,...y(),children:n})}),document.getElementById("atlas-floating-ui"))]})}import{Fragment as il,jsx as nr}from"react/jsx-runtime";var rl=ol()(e=>({isMenuOpen:!1,menuPosition:{x:0,y:0},setMenuPosition(t){e({menuPosition:t})},toggle(t){e(n=>({isMenuOpen:!n.isMenuOpen,menuPosition:t}))},open(t){e({isMenuOpen:!0,menuPosition:t})},setIsMenuOpen(t){e(typeof t=="function"?n=>({isMenuOpen:t(n.isMenuOpen)}):{isMenuOpen:t})},close(){e({isMenuOpen:!1})}}));function ft(e,t,n){let{isMenuOpen:o,setIsMenuOpen:s,close:i,open:r,menuPosition:a,setMenuPosition:l,toggle:u}=rl(),g=nl(p=>{n&&(p.preventDefault(),p.stopPropagation(),u(p.atlas))},[u,n]);return[nr(il,{children:n&&o&&nr(pt,{dismissable:!0,placement:"bottom-start",isOpen:o,onOpenChange:s,annotation:{id:e},target:{x:a.x,y:a.y,height:1,width:1},children:o&&n({canvasId:t,position:a,close:()=>s(!1)})})}),{onContextMenu:g},{open:r,close:i,toggle:u,isMenuOpen:o,setIsMenuOpen:s,menuPosition:a,setMenuPosition:l}]}import{useStore as al}from"zustand";function or(){let e=q();return al(e,t=>t.tool.requestId&&t.requests[t.tool.requestId]||null)}import{Fragment as rr,jsx as ae,jsxs as nn}from"react/jsx-runtime";function ir({theme:e,renderContextMenu:t,children:n}){let o=q(),s=A(),i=J(o,b=>b.polygon),r=J(o,b=>b.polygonState.currentTool),a=J(o,b=>b.mode),l=J(o,b=>b.changeMode),u=J(o,b=>b.polygonState.transitioning),{enabled:g,requestId:c}=J(o,b=>b.tool),d=ll(()=>xe(i),[i]),p=or(),[y,f]=ft("editing-annotation",s?.id,t),x=p?.annotationPopup||n||ae(ul,{}),v=p?.svgTheme||e,m=()=>{l("sketch")};if(!g||!s||!c||!i)return null;let h=d&&i.id&&!u&&(r==="pointer"||r==="hand"||!i.open)?ae(pt,{annotation:i,target:d,children:x}):null,S="shape";return a==="explore"?nn(rr,{children:[ae(S,{id:`shape-${i.id}`,points:i.points,open:i.open,onClick:m,relativeStyle:!0,target:{x:0,y:0,width:s.width,height:s.height},style:{":hover":{backgroundColor:"rgba(0,0,0,0.2)"},backgroundColor:"rgba(0,0,0,0)",borderWidth:"4px",borderColor:"rgba(255, 255, 255, .4)"},...f}),ae(S,{id:`shape-${i.id}`,points:i.points,open:i.open,onClick:m,relativeStyle:!0,target:{x:0,y:0,width:s.width,height:s.height},style:{backgroundColor:"rgba(0,0,0,0)",borderWidth:"2px",borderColor:"rgba(0, 0, 0, .4)"}}),h]}):nn(rr,{children:[t?ae(S,{id:`shape-${i.id}`,points:i.points,open:i.open,target:{x:0,y:0,width:s.width,height:s.height},...f}):null,ae(er,{image:s,theme:v}),h,y]})}function ul(){let e=q(),t=J(e,r=>r.changeMode),n=J(e,r=>r.mode),o=J(e,r=>r.completeRequest),s=J(e,r=>r.tool),i=()=>{sl(()=>{o()})};return s.enabled?nn("div",{className:"svg-tools-container animate-fadeIn",children:[n!=="sketch"&&ae("button",{className:"svg-tools-button",onClick:()=>{t("sketch")},children:"Edit"}),ae("button",{className:"svg-tools-button",onClick:i,children:"Save"})]}):null}import{useEffect as on,useMemo as rn}from"react";import{useEffect as gr,useMemo as hr}from"react";import{useCallback as lr,useMemo as dl}from"react";function cl(e,t){let n=e?.iiif?.meta[t];return n?n.annotationPageManager:null}function ar(e,t){return k(n=>{let o=[];if(!e)return o;let s=Object.keys(n.iiif.entities.AnnotationPage);for(let i of s)if(!t||t.indexOf(i)!==-1){let r=cl(n,i);r&&r.views&&r.views[e]&&o.push(i)}return o},[e,t])}function sr({canvas:e,manifest:t,all:n,canvases:o}){let s=[];if(t)for(let i of t.annotations)s.indexOf(i.id)===-1&&s.push(i.id);if(n){if(o&&o.length)for(let i of o)for(let r of i.annotations)s.indexOf(r.id)===-1&&s.push(r.id)}else if(e)for(let i of e.annotations)s.indexOf(i.id)===-1&&s.push(i.id);return s}function ml(e,t){let n=e?.iiif?.meta[t];return n?n.annotationPageManager:null}function ur(e,t={}){let n=M(),o=B(),s=A(),i=Fe(),r=dl(()=>sr({all:t.all,manifest:o,canvas:s,canvases:i}),[t.all,s,i,o]),a=ar(e,t.all?void 0:r),l=lr(g=>{e&&n.setMetaValue([g,"annotationPageManager","views"],c=>c&&!c[e]?c:{...c||{},[e]:!1})},[e,n]),u=lr((g,c={})=>{if(!e)return;let d=n.getState(),p=[];if(c?.deselectOthers){let y=Object.keys(d.iiif.entities.AnnotationPage);for(let f of y){let x=ml(d,f);x&&x.views&&x.views[e]&&p.push(f)}}for(let y of p)l(y);n.setMetaValue([g,"annotationPageManager","views"],y=>y&&y[e]?y:{...y||{},[e]:!0})},[e,l,n]);return{availablePageIds:r,enabledPageIds:a,setPageEnabled:u,setPageDisabled:l}}function cr(e,t){return k((n,o)=>o.get(e.map(s=>({id:s,type:t}))),[e,t])}import pl from"mitt";import{useCallback as fl}from"react";import{createStore as gl}from"zustand";var hl=gl((e,t)=>({loaded:{},setLoaded:(n,o="done")=>{e(s=>({loaded:{...s.loaded,[n]:o}}))}})),yl=pl();yl.on("loaded",e=>{hl.getState().setLoaded(e.imageServiceId)});function dr(){let e=rt(),t=wo();return[fl((o,{height:s,width:i})=>o&&e(o,{height:s,width:i},!0),[e]),t]}import{useCallback as vl,useMemo as pr,useState as Sl}from"react";function mr(e={}){let t=je(),n=A(e.canvasId?{id:e.canvasId}:void 0);return k((o,s)=>{if(!n)return[];if(t&&e.enableSingleAnnotation)return[t];let i=s.get(n.items),r=[];for(let a of i)r.push(...s.get(a.items));return r},[n])}import{createPaintingAnnotationsHelper as xl}from"@iiif/helpers/painting-annotations";function fr(e,t=[]){let n=M(),o=pr(()=>xl(n),[]),s=mr({enableSingleAnnotation:e?.enableSingleAnnotation}),[i,r]=Sl(e?.defaultChoices||[]),a=pr(()=>o.getPaintables(s,i),[n,s,i,...t]),u={makeChoice:vl((g,{deselectOthers:c=!0,deselect:d=!1}={})=>{a.choice&&r(p=>{if(d){let f=p.filter(x=>x!==g);if(f.length===0){let x=a.items[0].resource.id;return x?[x]:[]}return f}if(c)return[g];let y=[...p];if(y.length===0&&a.items.length){let f=a.items[0].resource.id;f&&y.push(f)}return p.indexOf(g)!==-1?p:[...p,g]})},[a.choice])};return[a,u]}function yr(e){let t=B(),n=A(),o=M(),s=tr(),i=e?.emitter||s,[r,a]=dr(),{enabledPageIds:l}=ur(e?.annotationPageManagerId||t?.id||n?.id,{all:!1}),u=cr(l,"AnnotationPage"),g=e?.strategies||["empty","images","media","textual-content","complex-timeline"],[c,d]=fr(e,[a]);gr(()=>{let y=f=>{d.makeChoice(f.choiceId,{deselectOthers:f.deselectOthers,deselect:f.deselect})};return i.on("make-choice",y),()=>{i.off("make-choice",y)}},[]);let p=hr(()=>un({canvas:n,paintables:c,supports:g,loadImageService:r,vault:o}),[n,c,o,d.makeChoice]);return gr(()=>{let y=c.allChoices,f={canvasId:n?.id,manifestId:t?.id};y&&i.emit("choice-change",{choice:y,partOf:f})},[n?.id,c.allChoices]),hr(()=>p.type==="unknown"?[p,ln]:[{...p,annotations:{pages:u}},d],[p,u])}import{createStylesHelper as bl}from"@iiif/helpers";import{jsx as vr}from"react/jsx-runtime";function Sr({strategies:e,registerActions:t,defaultChoices:n,onChoiceChange:o,mediaControlsDeps:s,renderMediaControls:i,renderViewerControls:r,viewControlsDeps:a,renderComplexTimelineControls:l,complexTimelineControlsDeps:u,throwOnUnknown:g,children:c}){let d=A(),p=M(),y=rn(()=>bl(p),[p]),[f,x]=yr({strategies:e||["images"],defaultChoices:n?.map(({id:S})=>S)}),v="choice"in f?f.choice:void 0;if(on(()=>{t&&t(x)},[f.annotations]),on(()=>{o&&o(v)},[v]),on(()=>{if(n)for(let S of n)typeof S.opacity<"u"&&y.applyStyles({id:S.id},"atlas",{opacity:S.opacity})},[n]),f.type==="unknown"&&g)throw new Error(f.reason||"Unknown strategy");let m=rn(()=>({renderMediaControls:i,mediaControlsDeps:s||[],renderViewerControls:r,viewControlsDeps:a||[],renderComplexTimelineControls:l,complexTimelineControlsDeps:u||[]}),[s,i,r,a,l,u]),h=rn(()=>({strategy:f,actions:x,choices:"choice"in f?f.choice:[]}),[f,d]);return vr(et.Provider,{value:m,children:vr(ce.Provider,{value:h,children:c})})}import{useEffect as br,useMemo as Pl}from"react";import{useStore as Cr}from"zustand";import{createContext as Cl,useContext as Rl,useEffect as Al}from"react";var an=Cl(()=>{});function xr(e){let t=A(),n=Rl(an);Al(()=>t&&t.id?(n(t.id,e),()=>n(t.id,-1)):()=>{},[t,e])}import{jsxs as wl}from"react/jsx-runtime";function Rr({x:e=0,y:t=0,keepCanvasScale:n=!0,renderContextMenu:o,children:s}){let{strategy:i}=V(),r=A(),a=q(),l=Ke(r,["deep-zoom"]),u=Cr(a,f=>f.setCanvasRelativePosition),g=Cr(a,f=>f.clearCanvasRelativePosition),[c,d]=ft(`context-menu/${r?.id}`,r?.id,o),p=Pl(()=>n?1:Math.max(1,...i.type==="images"?i.images.map(f=>(f.width||0)/f.target?.spatial.width):[]),[n,i]);br(()=>{if(r)return u(r.id,{x:e,y:t,width:r.width,height:r.height}),()=>{g(r.id)}},[e,t,r,g,u]),br(()=>{r&&a.getState().reset()},[a,r]),xr(p);let y=i.type==="images"?i.images.length:0;return r?wl("world-object",{height:r.height,width:r.width,x:e,y:t,...d,...l,children:[c,s]},`${r.id}/${i.type}/${y}`):null}import{jsx as Y,jsxs as Ar}from"react/jsx-runtime";function de({x:e,y:t,onChoiceChange:n,registerActions:o,defaultChoices:s,isStatic:i,renderViewerControls:r,renderMediaControls:a,renderComplexTimelineControls:l,complexTimelineControlsDeps:u,viewControlsDeps:g,mediaControlsDeps:c,strategies:d,throwOnUnknown:p,backgroundStyle:y,alwaysShowBackground:f,keepCanvasScale:x=!1,enableSizes:v=!1,enableYouTube:m=!0,onClickPaintingAnnotation:h,components:S={},children:b,annotationPopup:C,svgTheme:R,renderContextMenu:P,renderAnnotationContextMenu:L}){return Ar(Sr,{throwOnUnknown:p,onChoiceChange:n,registerActions:o,strategies:d,defaultChoices:s,mediaControlsDeps:c,renderMediaControls:a,renderViewerControls:r,renderComplexTimelineControls:l,complexTimelineControlsDeps:u,viewControlsDeps:g,children:[Ar(Rr,{keepCanvasScale:x,x:e,y:t,renderContextMenu:P,children:[Y(Wo,{alwaysShowBackground:f,backgroundStyle:y}),Y(Fo,{}),Y(_o,{}),Y(Uo,{isStatic:i,enableSizes:v,onClickPaintingAnnotation:h}),Y(ho,{}),Y(io,{}),Y(xo,{as:S.Audio}),Y(Ko,{as:S.Video}),m?Y(Qo,{}):null,Y(ir,{theme:R,renderContextMenu:L,children:C}),b]}),Y(ao,{})]})}import{jsx as Pr}from"react/jsx-runtime";function wr(e){let t=A();return!t||!t.placeholderCanvas?null:Pr(ee,{canvas:t.placeholderCanvas.id,children:Pr(de,{renderViewerControls:e.renderViewerControls})})}import{AtlasAuto as kl}from"@atlas-viewer/atlas";import Mr,{useCallback as gt,useMemo as El,useState as ht}from"react";import{ErrorBoundary as Vl}from"react-error-boundary";import{useStore as kr}from"zustand";import{useEffect as Tl,useMemo as Il}from"react";function Tr(e,t=2e3){let{currentSequenceIndex:n,sequence:o,items:s}=_e(),i=A(),r=Il(()=>{let l=o[n]||[];return l.length===0&&i?[{id:i.id,type:"Canvas"}]:l.map(u=>s[u])},[o,n,i,s]),a=q();Tl(()=>{let u=setInterval(()=>{if(e&&t!==-1){let g={x:e.x,y:e.y,width:e.width,height:e.height},c=a.getState().canvasRelativePositions,d={};for(let p of r){let y=c[p.id];if(y){let f=y.x,x=y.y,v=y.width,m=y.height,h={x:Math.max(f,g.x),y:Math.max(x,g.y),width:Math.min(f+v,g.x+g.width)-Math.max(f,g.x),height:Math.min(x+m,g.y+g.height)-Math.max(x,g.y)};h.width<=0||h.height<=0||(d[p.id]={x:h.x-y.x,y:h.y-y.y,width:h.width,height:h.height}),a.setState({canvasViewports:d})}}}},t);return()=>{clearTimeout(u)}},[r,e,a,t])}import{jsx as sn,jsxs as Ml}from"react/jsx-runtime";function Ir({width:e,style:t,height:n,error:o,resetErrorBoundary:s}){return Ml("div",{style:{width:e,height:n,minHeight:500,...t||{},background:"#f9f9f9"},children:[sn("h3",{children:"Error occurred"}),sn("p",{children:o.message}),sn("button",{type:"button",onClick:s,children:"Reset"})]})}import{Fragment as Ll,jsx as O,jsxs as zl}from"react/jsx-runtime";function Er(e){let t=q();return O(Oe,{name:e.name,existing:t,children:O(Nl,{...e})})}function Nl({name:e,children:t,errorFallback:n,outerContainerProps:o={},worldScale:s,updateViewportTimeout:i,...r}){let a=q(),l=kr(a,w=>w.mode),u=kr(a,w=>w.setAtlasRuntime),[g,c]=ht(),d=ct(),p=dt(),y=n||Ir,[f,x]=ht({}),v=Object.entries(f),[m,h]=ht({}),S=Object.entries(m),[b,C]=ht({}),{worldScale:R,runtimeOptions:P}=El(()=>{if(Object.values(b).length===0)return{worldScale:1,runtimeOptions:r.runtimeOptions||{maxOverZoom:1}};let I=Math.max(...Object.values(b));return{worldScale:I,runtimeOptions:{maxOverZoom:I||1,...r.runtimeOptions||{}}}},[b,r.runtimeOptions]);Tr(g?.runtime,i);let L=gt((w,I)=>{C(E=>{if(I===-1){let{[w]:Ee,...se}=E;return se}return{...E,[w]:I}})},[]),re=gt((w,I,E)=>{x(({[w]:Ee,...se})=>I?{...se,[w]:{element:I,props:E}}:se)},[]),T=gt((w,I,E)=>{h(({[w]:Ee,...se})=>I?{...se,[w]:{element:I,props:E}}:se)},[]),z=gt(w=>{c(w),u(w.runtime),r.onCreated&&r.onCreated(w)},[r.onCreated,u]);return zl(Vl,{resetKeys:[],fallbackRender:w=>O(y,{...r,...w}),children:[O(kl,{...r,mode:l,containerProps:{style:{position:"relative"},...r.containerProps||{}},htmlChildren:O(Ll,{children:v.map(([w,{element:I,props:E}])=>O(Mr.Fragment,{children:O(I,{...E||{}})},w))}),onCreated:z,runtimeOptions:P,children:O(Oe,{name:e,existing:a,children:O(fe.Provider,{value:g,children:O(an.Provider,{value:L,children:O(Bt.Provider,{value:re,children:O(Ht.Provider,{value:T,children:O(mt,{bridge:p,custom:d,children:O(fo,{children:t})})})})})})})}),O("div",{children:S.map(([w,{element:I,props:E}])=>O(Mr.Fragment,{children:O(I,{...E||{}})},w))}),O("div",{id:"atlas-floating-ui",style:{position:"relative",zIndex:999999}})]})}import{Fragment as Dl,jsx as G,jsxs as ql}from"react/jsx-runtime";var Hl=Vr(function(t,n){let o=B(),s=Fe(),i=_e(),{ViewerControls:r,MediaControls:a,ComplexTimelineControls:l}=t.components||{};if(Ol(n,()=>i,[i]),!o)return G("div",{});let u=0,g=o.viewingDirection==="top-to-bottom",c=o.viewingDirection==="bottom-to-top",d=o.viewingDirection==="left-to-right",p=o.viewingDirection==="right-to-left",f=o.behavior.includes("continuous")?0:t.spacing||0,x=c||p,v=Bl(()=>x?[...s].reverse():s,[s,x]);return ql(Dl,{children:[t.header,G(H.Viewer,{height:t.height,mode:t.mode,renderPreset:t.renderPreset,runtimeOptions:t.runtimeOptions,updateViewportTimeout:t.updateViewportTimeout,homePaddingPx:t.padding,children:v.map((m,h)=>{let S=0,b=0;return!g&&!c?(S=u,u+=m.width+f):(b=u,u+=m.height+f),G(ee,{canvas:m.id,children:G(H.RenderCanvas,{strategies:["3d-model","media","images","empty","textual-content","complex-timeline"],renderViewerControls:h===0&&r?()=>G(r,{}):void 0,renderMediaControls:h===0&&a?()=>G(a,{}):void 0,annotationPopup:t.annotationPopup,renderContextMenu:t.renderContextMenu,keepCanvasScale:t.keepCanvasScale,renderComplexTimelineControls:h===0&&l?()=>G(l,{}):void 0,renderAnnotationContextMenu:t.renderAnnotationContextMenu,x:S,y:b,svgTheme:t.svgTheme,...t.canvasProps||{},children:t.annotations},m.id)},m.id)})},t.reuseAtlas?"":i.currentSequenceIndex),t.children]})}),H=Vr(function({children:t,height:n,annotations:o,canvasProps:s,spacing:i,header:r,components:a,mode:l,reuseAtlas:u,renderPreset:g,runtimeOptions:c,annotationPopup:d,name:p,svgTheme:y,updateViewportTimeout:f,renderContextMenu:x,keepCanvasScale:v,renderAnnotationContextMenu:m,padding:h,...S},b){let C=ye();return G(Oe,{name:p,children:G(ge,{vault:C,children:G(On,{...S,children:G(Hl,{ref:b,height:n,components:a,spacing:i,canvasProps:s,annotations:o,header:r,mode:l,reuseAtlas:u,renderPreset:g,runtimeOptions:c,annotationPopup:d,svgTheme:y,updateViewportTimeout:f,renderContextMenu:x,keepCanvasScale:v,renderAnnotationContextMenu:m,padding:h,children:t})})})})});H.RenderImage=Ie;H.RenderCanvas=de;H.RenderAnnotationPage=ue;H.RenderAnnotation=Re;H.Viewer=Er;H.CanvasBackground=st;H.Audio=Ze;H.Video=ut;H.Model=Je;H.AudioHTML=Dt;H.VideoHTML=Qt;H.ModelHTML=$t;H.PlaceholderCanvas=wr;H.getAtlasStoreByName=Un;export{$e as a,_ as b,ie as c,ee as d,le as e,ge as f,M as g,k as h,he as i,Fe as j,ye as k,B as l,mn as m,pn as n,fn as o,gn as p,ei as q,vt as r,Ou as s,hn as t,Du as u,St as v,yn as w,vn as x,Zu as y,bn as z,Cn as A,Rn as B,xt as C,Sn as D,ve as E,li as F,ui as G,kn as H,En as I,Ne as J,ci as K,hc as L,di as M,In as N,yc as O,Vn as P,Ln as Q,ze as R,Ci as S,On as T,_e as U,At as V,id as W,Hn as X,Dn as Y,Pt as Z,xe as _,Ii as $,cd as aa,wt as ba,Tt as ca,qn as da,$n as ea,be as fa,q as ga,Un as ha,Oe as ia,_n as ja,jn as ka,Td as la,_i as ma,Kn as na,je as oa,A as pa,Ke as qa,Ce as ra,Gn as sa,Xn as ta,Re as ua,Zn as va,ue as wa,Em as xa,Vm as ya,Nm as za,Ge as Aa,Qe as Ba,Ot as Ca,Ae as Da,D as Ea,ce as Fa,V as Ga,io as Ha,et as Ia,$ as Ja,ao as Ka,so as La,co as Ma,po as Na,fo as Oa,ho as Pa,yo as Qa,Oa as Ra,vo as Sa,Pe as Ta,we as Ua,xo as Va,bo as Wa,cf as Xa,rt as Ya,bf as Za,Pf as _a,wf as $a,Tf as ab,Eo as bb,_t as cb,Vo as db,Ja as eb,es as fb,ts as gb,If as hb,Be as ib,Ie as jb,Fo as kb,Wo as lb,fe as mb,lt as nb,Uo as ob,_o as pb,Ko as qb,Qo as rb,Xo as sb,Ns as tb,Jo as ub,$s as vb,ke as wb,tr as xb,Lh as yb,ct as zb,_s as Ab,Kh as Bb,dt as Cb,mt as Db,rl as Eb,ft as Fb,or as Gb,ir as Hb,ul as Ib,sr as Jb,ur as Kb,cr as Lb,dr as Mb,mr as Nb,fr as Ob,yr as Pb,Sr as Qb,Rr as Rb,Ir as Sb,Er as Tb,H as Ub};
|