react-iiif-vault 2.0.17 → 2.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -687,6 +687,7 @@ declare function useContextBridge(): {
687
687
  ReactEventContext: {
688
688
  emitter: mitt.Emitter<Record<mitt.EventType, unknown>>;
689
689
  };
690
+ ReactEmitterContext: mitt.Emitter<any>;
690
691
  ContextBridgeReactContext: Record<string, React__default.Context<any>>;
691
692
  StrategyReactContext: StrategyContext | null;
692
693
  AtlasStoreReactContext: zustand.StoreApi<AtlasStore> | null;
package/dist/index.d.ts CHANGED
@@ -687,6 +687,7 @@ declare function useContextBridge(): {
687
687
  ReactEventContext: {
688
688
  emitter: mitt.Emitter<Record<mitt.EventType, unknown>>;
689
689
  };
690
+ ReactEmitterContext: mitt.Emitter<any>;
690
691
  ContextBridgeReactContext: Record<string, React__default.Context<any>>;
691
692
  StrategyReactContext: StrategyContext | null;
692
693
  AtlasStoreReactContext: zustand.StoreApi<AtlasStore> | null;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{$ as er,$a as qe,$b as We,A as Ao,Aa as Ir,Ab as ln,B as ko,Ba as Cr,Bb as cn,C as Mo,Ca as Rr,Cb as mn,D as Ho,Da as Pr,Db as un,E as Lo,Ea as Pe,Eb as fn,F as zo,Fa as wr,Fb as ze,G as Bo,Ga as Tr,Gb as pn,H as Fo,Ha as Er,Hb as dn,I as Oo,Ia as qr,Ib as gn,J as Vo,Ja as Nr,Jb as hn,K as Wo,Ka as Ar,Kb as yn,L as Do,La as kr,Lb as vn,M as Uo,Ma as Mr,Mb as xn,N as _o,Na as Hr,Nb as bn,O as $o,Oa as Lr,Ob as Sn,P as Ko,Pa as zr,Pb as In,Q as Qo,Qa as Br,Qb as Cn,R as Go,Ra as Fr,Rb as Nn,S as Xo,Sa as we,Sb as Be,T as Yo,Ta as Or,Tb as An,U as xe,Ua as Te,Ub as Fe,V as Zo,Va as Vr,Vb as B,W as jo,Wa as Wr,Wb as kn,X as Jo,Xa as Dr,Xb as Fn,Y as G,Ya as Ur,Yb as On,Z as be,Za as ie,Zb as Vn,_ as Se,_a as Ee,_b as Ve,a as ho,aa as tr,ab as Ne,ac as De,b as $,ba as or,bb as Ae,c as z,ca as Ie,cb as W,d as pe,da as Ce,db as ke,e as yo,ea as rr,eb as Me,f as de,fa as nr,fb as He,g as w,ga as T,gb as _r,h as K,ha as ir,hb as $r,i as vo,ia as ar,ib as Kr,j as ge,ja as sr,jb as Qr,k as he,ka as Re,kb as Gr,l as Q,la as lr,lb as Xr,m as ye,ma as cr,mb as Yr,n as xo,na as mr,nb as Zr,o as bo,oa as ur,ob as jr,p as So,pa as E,pb as Jr,q as Io,qa as fr,qb as H,r as Co,ra as pr,rb as Le,s as Ro,sa as dr,sb as en,t as Po,ta as gr,tb as tn,u as wo,ua as hr,ub as ae,v as To,va as yr,vb as on,w as ve,wa as vr,wb as rn,x as Eo,xa as xr,xb as nn,y as qo,ya as br,yb as an,z as No,za as Sr,zb as sn}from"./chunk-IGWOGVER.js";import"./chunk-UNH7HXGJ.js";import{a as Rn,b as Pn,c as wn,d as Tn,e as En,f as qn,g as Mn,h as Hn,i as Ln,j as zn,k as Bn,l as Oe}from"./chunk-P7XHGETS.js";export*from"@iiif/helpers/annotation-targets";import{useEffect as gt}from"react";import{useCallback as Ue,useEffect as pt,useRef as dt,useState as X}from"react";import{useStore as F}from"zustand";function _e(e){let[t,o]=X(0),r=T(),n=F(r,g=>g.tool.enabled),i=F(r,g=>g.tool.requestId),a=F(r,g=>g.getRequestId),l=F(r,g=>g.requestAnnotation),f=F(r,g=>g.completeRequest),m=F(r,g=>g.cancelRequest),s=dt(e?.onSuccess);s.current=e?.onSuccess;let[y,x]=X(!1),[b,v]=X(null),[p,S]=X(null),c=n&&i!==p,h=n&&i===p,d=Ue(async(g,R)=>{if(p){let M=s.current;x(!0);let q=await l(g,{...R,requestId:p});if(q)return M?.(q),o(A=>A+1),x(!1),v(q),q;let L={id:p,cancelled:!0,...Ce(g)};return M?.(L),v(L),o(A=>A+1),x(!1),L}return null},[l,p]),u=Ue(()=>{v(null),x(!1)},[]);return pt(()=>{let g=a();return S(g.requestId),()=>{g.clear()}},[t]),{id:t,busy:c,isPending:y,isActive:h,requestId:p,requestAnnotation:d,cancelRequest:()=>p?m(p):void 0,completeRequest:()=>p?f(p):void 0,reset:u,data:b}}var Gn=[{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 $e(e){let{id:t,data:o,requestAnnotation:r,cancelRequest:n,isPending:i}=_e({onSuccess:a=>{e.updateShape(a.polygon)}});return gt(()=>(r({type:"polygon",open:e.shape?.open,points:e.shape?.points}),()=>{n()}),[]),null}import{createContext as ht,useCallback as Ke,useContext as Ge,useEffect as Qe,useMemo as se,useState as yt}from"react";import Xe from"mitt";import{jsx as vt}from"react/jsx-runtime";var Y=ht(Xe());Y.displayName="SelectorHelper";function ti({children:e}){return vt(Y.Provider,{value:se(()=>Xe(),[]),children:e})}function oi(){return Ge(Y)}function Ye(e){let t=Ze(),[o,r]=yt(!1);Qe(()=>t.withSelector(e).on("highlight",()=>{r(!0)}),[t,e]),Qe(()=>t.withSelector(e).on("clear-highlight",()=>{r(!1)}),[t,e]);let n=Ke(a=>{t.emit("click",{selectorId:e,event:a})},[e,t]),i=Ke(a=>{t.emit("hover",{selectorId:e,event:a})},[e,t]);return{controller:t,onClick:n,onHover:i,isHighlighted:o}}function Ze(){let e=Ge(Y);return se(()=>({withSelector(t){return{on(o,r){let n=i=>{i&&i.selectorId===t&&r(i)};return e.on(o,n),()=>{e.off(o,n)}},emit(o,r){e.emit(o,{...r,selectorId:t})}}},on(t,o){return e.on(t,o),()=>{e.off(t,o)}},emit(t,o){e.emit(t,o)}}),[e])}function ri(){let e=Ze();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(o,r){return e.emit("event-listener",{selectorId:t,name:o,callback:r}),()=>{e.emit("remove-event-listener",{selectorId:t,name:o,callback:r})}},getImagePreview(){return new Promise((o,r)=>{e.emit("image-preview-request",{selectorId:t,resolve:o,reject:r})})},on(o,r){return e.withSelector(t).on(o,r)}}},highlight(t){e.emit("highlight",{selectorId:t})},clearHighlight(t){e.emit("clear-highlight",{selectorId:t})},zoomTo(t){e.emit("zoom-to",{selectorId:t})},addEventListener(t,o,r){return e.emit("event-listener",{selectorId:t,name:o,callback:r}),()=>{e.emit("remove-event-listener",{selectorId:t,name:o,callback:r})}},getImagePreview(t){return new Promise((o,r)=>{e.emit("image-preview-request",{selectorId:t,resolve:o,reject:r})})},on(t,o){return e.on(t,o)}}),[e])}import{jsx as je}from"react/jsx-runtime";function fi(e){let t=E(),o=e.annotationBucket,r=e.readOnly,n=e.id,{onClick:i,isHighlighted:a}=Ye(e.id),l=Re(),f=a?l.highlighted:l[o||"hidden"]||l.hidden;if(!t)return null;if(r){let m="shape",s=e.polygon,y=s.open;return s?je(m,{id:`shape-${n}`,points:s.points,open:y,onClick:i,relativeStyle:!0,target:{x:0,y:0,width:t.width,height:t.height},style:f}):null}return je($e,{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 xt}from"@atlas-viewer/atlas";import{forwardRef as bt,useImperativeHandle as St}from"react";import{Fragment as It,jsx as Je}from"react/jsx-runtime";var bi=bt(function({canvasId:t},o){let r=xt(),n=Be(t||r?.id),i=w();return St(o,()=>n,[t,r]),!r||n.enabledPageIds.length===0?null:Je(It,{children:n.enabledPageIds.map(a=>Je(De.RenderAnnotationPage,{page:i.get(a)},a))})});import{useMemo as Pt}from"react";import{useMemo as Ct}from"react";import{Fragment as Rt,jsx as C,jsxs as Z}from"react/jsx-runtime";function j({metadata:e=[],config:t,labelWidth:o=16,showEmptyMessage:r=!0,allowHtml:n,emptyFallback:i,classes:a={},emptyMessage:l="No metadata available",emptyValueFallback:f="No value",emptyLabelFallback:m="",separator:s,tableFooter:y,tableHeader:x,customLabelRender:b,customValueRender:v}){let p=Ct(()=>{let c=(t||[]).reduce((d,u)=>[...d,...u.keys],[]),h={};for(let d of e){let u=d?.label?Object.values(d.label):[];for(let g of u)if(g?.length&&(c.indexOf(`metadata.${g[0]}`)!==-1||c.length===0)&&d){let R=`metadata.${g[0]}`;h[R]=h[R]?h[R]:[],h[R].push(d);break}}return h},[t,e]);return Object.keys(p).length===0&&r?C(Rt,{children:i})||C("div",{className:a.empty,children:l}):t?.length?Z("table",{className:a.container,children:[x,C("tbody",{children:t.map((c,h)=>{let d=[];for(let g of c.keys)for(let R of p[g]||[]){let M=C(H,{enableDangerouslySetInnerHTML:n,defaultText:f,separator:s,children:R.value},h+"__"+g);v?d.push(v(R,M)):d.push(M)}if(d.length===0)return null;let u=C(H,{enableDangerouslySetInnerHTML:n,separator:s,defaultText:m,children:c.label});return Z("tr",{className:a.row,children:[C("td",{className:a.label,style:o?{minWidth:o}:{},children:b?b(c.label,u):u}),C("td",{className:a.value,children:d})]},h)})}),y]}):Z("table",{className:a.container,children:[x,C("tbody",{children:e?.length?e.map((c,h)=>{if(!c)return null;let d=C(H,{enableDangerouslySetInnerHTML:n,defaultText:f,separator:s,children:c.label}),u=C(H,{enableDangerouslySetInnerHTML:n,defaultText:f,separator:s,children:c.value});return Z("tr",{className:a.row,children:[C("td",{className:a.label,style:o?{minWidth:o}:{},children:b?b(c.label,d):d}),C("td",{className:a.value,children:v?v(c,u):u})]},h)}):null}),y]})}import{jsx as wt}from"react/jsx-runtime";function Mi(e){let t=Q(),o=E(),r=ve(),n=Pt(()=>{let i=t?.metadata||[],a=o?.metadata||[],l=r?.metadata||[];return[...i,...a,...l]},[t,o,r]);return wt(j,{metadata:n,...e})}import{useEffect as Nt,useState as At}from"react";import{createImageServiceRequest as Tt,imageServiceRequestToString as Et}from"@iiif/parser/image-3";import{useMemo as qt}from"react";function le(e,t={},o=[]){return qt(()=>{if(!e)return null;let r=t.quality;e&&e.extraQualities&&t.quality&&(e.extraQualities.includes(t.quality)||(r="default"));let n=Tt(e);return 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:r||"default",prefix:n.prefix,originalPath:n.originalPath})},[...o])}import{jsx as J}from"react/jsx-runtime";function kt(e){let t=typeof e.src=="string"?e.src:e.src.id,o=we(),[r,n]=At(!1),i;if(t){let l=o.loadServiceSync({id:t});l&&(i=l)}!i&&!r&&o.loadService({id:t}).then(()=>{n(!0)});let a=le(i,{size:e.size,selector:e.region,rotation:e.rotation,format:e.format,region:e.region,quality:e.quality},[r,e.src,e.size,e.region,e.rotation,e.format,e.region,e.quality]);return Nt(()=>()=>{n(!1)},[t]),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,o=le(t,{size:e.size,selector:e.region,rotation:e.rotation,format:e.format,region:e.region,quality:e.quality},[e.src,e.size,e.region,e.rotation,e.format,e.region,e.quality]);return o?J("img",{src:o,alt:e.alt,className:e.className,style:e.style}):null}import{useMemo as Ht,useState as Lt}from"react";import{ErrorBoundary as zt}from"react-error-boundary";import{jsx as O,jsxs as Ft}from"react/jsx-runtime";function oa({src:e,errorFallback:t,interactive:o,skipSizes:r,children:n,renderViewerControls:i,viewControlsDeps:a,fluid:l,x:f,y:m,...s}){let y=he(),[x,b]=Lt(),v=t||Ve,[p,S]=Fe(),c=Ht(()=>{let d=S[e]?.status,u=p({id:e},{});return u?.height&&u.width&&d!=="loading"?{id:e,width:u.width,height:u.height,service:u,type:"Image",selector:{type:"BoxSelector",spatial:{x:0,y:0,width:u.width,height:u.height}},target:{type:"BoxSelector",spatial:{x:0,y:0,width:u.width,height:u.height}}}:null},[p,e,S]);if(!c||!c.height||!c.width)return null;let h=l?void 0:s.homePosition?s.homePosition.width/s.homePosition.height:c.width/c.height;return O(zt,{resetKeys:[],fallbackRender:d=>O(v,{...s,...d}),children:O(de,{vault:y,children:O(We,{...s,aspectRatio:h,containerProps:{style:{position:"relative"},...s.containerProps||{}},onCreated:d=>{b(d),s.onCreated&&s.onCreated(d)},children:Ft(ae.Provider,{value:x,children:[O(Le,{image:c,id:c.id,isStatic:!o,x:f,y:m},c.id),O(Bt,{viewerPreset:x,renderViewerControls:i,image:c,src:e,viewControlsDeps:a}),n]})})})})}function Bt({viewerPreset:e,renderViewerControls:t,image:o,src:r,viewControlsDeps:n}){return Pe(e&&t?"overlay":"none",`canvas-portal-controls-${r}`,ae.Provider,t&&o?{value:e||null,children:t({image:o,images:[o],type:"images"})}:{},[r,e,...n||[]]),null}import{jsx as Ot}from"react/jsx-runtime";function la(e){let t=Q();return Ot(j,{metadata:t?.metadata||[],...e})}import{useLayoutEffect as _t,useRef as $t}from"react";import*as ce from"react-lazy-load-image-component";import{getValue as Vt}from"@iiif/helpers/i18n";import{Fragment as et,jsx as k,jsxs as Ut}from"react/jsx-runtime";var{LazyLoadComponent:Wt}=ce||ce.default;function tt(e){let{size:t,visible:o,classes:r,canvasId:n,figure:i}=e,a=t?.width||128,l=t?.height||t?.width||128,f=k(Dt,{...e}),m=k(Wt,{threshold:300,style:{height:l,width:a},visibleByDefault:o,children:n?k(pe,{canvas:n,children:f}):f});return i?k("figure",{className:r?.figure,children:m}):m}function Dt({fallback:e,size:t,classes:o,showLabel:r,alt:n,dereference:i=!1}){let a=E(),l=t?.width||128,f=t?.height||t?.width||128,m=n||Vt(a?.label)||"",s=Te({width:l,height:f,allowUnsafe:!0},i);return!s||s.type!=="fixed"?k(et,{children:e}):Ut(et,{children:[k("div",{className:o?.imageWrapper,children:k("img",{className:o?.img,src:s.id,alt:m})}),r?k(H,{as:"figcaption",className:o?.label,children:a?.label}):null]})}import{jsx as D}from"react/jsx-runtime";function Sa({scrollBehaviour:e,dereference:t,flat:o,size:r,classes:n={},showLabel:i,figure:a,fallback:l}){let f=$t(null),{items:m,sequence:s,currentSequenceIndex:y,setSequenceIndex:x}=xe(),b={row:n.selected?.row||n.row,item:n.selected?.item||n.item,figure:n.selected?.figure||n.figure,img:n.selected?.img||n.img,label:n.selected?.label||n.label,imageWrapper:n.selected?.imageWrapper||n.imageWrapper};_t(()=>{if(!f.current)return;let p=f.current.querySelector("[data-selected=true]");p&&p.scrollIntoView({behavior:e||"instant",block:"nearest",inline:"center"})},[y]);let v=[];for(let p of s){let S=[],c=s[y]===p;for(let h of p){let d=m[h];S.push(D("div",{className:c?b.item:n.item,children:D(tt,{classes:c?b:n,canvasId:d.id,size:r,dereference:t,showLabel:i,figure:a,placeholder:D("div",{style:{height:128,width:128}}),fallback:l})},h))}if(o){v.push(S);continue}v.push(D("div",{onClick:h=>{x(s.indexOf(p))},"data-selected":c,className:c?b.row:n.row,children:S},p.join("-")))}return D("div",{ref:f,className:n.container,children:v})}import{useStore as ee}from"zustand";function ot(){let e=T(),t=ee(e,i=>i.completeRequest),o=ee(e,i=>i.polygonState.currentTool),r=ee(e,i=>i.polygonState.selectedStamp),n=ee(e,i=>i.switchTool);return{completeRequest:t,currentTool:o,selectedStamp:r,switchTool:n}}import{Fragment as rt,jsx as P,jsxs as nt}from"react/jsx-runtime";var Kt={draw:!0,polygon:!0,line:!0,lineBox:!0,box:!0,triangle:!0,hexagon:!0,circle:!0,delete:!0,pen:!0};function Ea({showShapes:e=!0,enabled:t=Kt,classNames:o={},icons:r={}}){let{currentTool:n,switchTool:i,selectedStamp:a}=ot();return nt(rt,{children:[n,P("button",{className:o.button,onClick:i.pointer,"data-active":n==="pointer",children:r.PointerIcon||"Pointer"}),P("button",{className:o.button,onClick:i.hand,"data-active":n==="hand",children:r.HandIcon||"Hand"}),e?nt(rt,{children:[t.box&&P("button",{className:o.button,onClick:i.box,"data-active":n==="box",children:r.BoxIcon||"Box"}),t.pen&&P("button",{className:o.button,onClick:i.pen,"data-active":n==="pen",children:r.PenIcon||"Pen"}),t.draw&&P("button",{className:o.button,onClick:i.draw,"data-active":n==="pencil",children:r.DrawIcon||"Draw"}),t.line&&P("button",{className:o.button,onClick:i.line,"data-active":n==="line",children:r.LineIcon||"Line"}),t.lineBox&&P("button",{className:o.button,onClick:i.lineBox,"data-active":n==="lineBox",children:r.LineBoxIcon||"LineBox"}),t.triangle&&P("button",{className:o.button,onClick:i.triangle,"data-active":n==="stamp"&&a?.id==="triangle",children:r.TriangleIcon||"Triangle"}),t.hexagon&&P("button",{className:o.button,onClick:i.hexagon,"data-active":n==="stamp"&&a?.id==="hexagon",children:r.HexagonIcon||"Hexagon"}),t.circle&&P("button",{className:o.button,"data-active":n==="stamp"&&a?.id==="circle",onClick:i.circle,children:r.CircleIcon||"Circle"})]}):null,t.delete&&P("button",{className:o.button,onClick:i.remove,children:r.DeleteForeverIcon||"Delete"})]})}import{jsx as Qt}from"react/jsx-runtime";function ka({annotation:e,children:t}){return Qt(z,{value:{annotation:e},children:t})}import{jsx as Gt}from"react/jsx-runtime";function za({annotationPage:e,children:t}){return Gt(z,{value:{annotationPage:e},children:t})}import{jsx as Xt}from"react/jsx-runtime";function Va({collection:e,children:t}){return Xt(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 me,useState as jt}from"react";function Ya({canvasId:e}={}){let t=Yt(),o=ge(),r=me(()=>e?[e]:t?[t.id]:o.map(m=>m.id),[e,t,o]),[n,i]=jt({}),a=ze();Zt(()=>{let m=s=>{let y=s.partOf.canvasId;y&&i(x=>({...x,[y]:s.choice}))};return a.on("choice-change",m),()=>{a.off("choice-change",m)}},[]);let l=me(()=>{let m=[];for(let s of r){let y=n[s];y&&m.push({canvasId:s,choice:y})}return m},[r,n]),f=me(()=>({makeChoice:(m,s)=>{a.emit("make-choice",{choiceId:m,...s})}}),[a]);return{choices:l,actions:f}}function ja(e,t=!1){}function os(e){let o=$().manifest,r=e?e.map(n=>typeof n=="string"?n:n?.id):[];return K(n=>{let i=o?n.iiif.entities.Manifest[o]:void 0,a=i?.items||[];if(typeof e>"u")return a;let l=[];for(let f of i?.items||[])r.indexOf(f.id)!==-1&&l.push(f);return l},[r.join("/")])}import{useMemo as Jt}from"react";function ss(e,t=[]){let{id:o,selector:r}=e,n=$(),i=o||n.collection,a=K(l=>i?l.iiif.entities.Collection[i]:void 0,[i]);return Jt(()=>{if(a)return r?r(a):a},[a,r,...t])}import{startTransition as eo,useMemo as to}from"react";import{useStore as it}from"zustand";function fs(){let e=T(),t=it(e,r=>r.completeRequest),o=it(e,r=>r.cancelRequest);return to(()=>({saveAnnotation:()=>{eo(()=>{t()})},cancelRequest:o}),[t,o])}import{useCallback as oo}from"react";import{useStore as ue}from"zustand";function ys({requestId:e}={}){let t=T(),o=ue(t,l=>l.metadata),r=ue(t,l=>l.tool.requestId),n=e||r,i=ue(t,l=>l.setMetadata),a=oo(l=>i(l,n||void 0),[i,n]);return[n?o[n]||{}:{},a]}import{useStore as ro}from"zustand";function Is(e){let t=T(),o=ro(t,r=>r.tool.requestId);G("polygons.start-transition",r=>{e.requestId&&o!==e.requestId||e?.onStart?.(r.transitionIntent)},[o,e.requestId]),G("polygons.end-transition",r=>{e.requestId&&o!==e.requestId||e?.onEnd?.(r.transitionIntent,r.response)},[o,e.requestId]),G("polygons.transition",r=>{e.requestId&&o!==e.requestId||e?.onTransition?.(r.transitionIntent)},[o,e.requestId])}import{useEffect as no,useMemo as io}from"react";import{createEventsHelper as ao}from"@iiif/helpers/events";function Ts(e,t,o,r,n=[]){let i=w(),a=io(()=>ao(i),[i]);no(()=>{let l=e;return l?(a.addEventListener(l,t,o,r),()=>{a.removeEventListener(l,t,o)}):()=>{}},[a,e,t,...n])}function As(e,t){let{id:o,isLoaded:r,error:n,resource:i,requestId:a,cached:l}=ye(e,t);return{id:o,isLoaded:r,error:n,manifest:i,requestId:a,cached:l}}import{getImageServices as at}from"@iiif/parser/image-3";import{useEffect as so,useMemo as st,useState as te}from"react";function lt({cacheKey:e}={}){let t=E(),o=B(),r=w(),n=Me(),i=He(),[a,l]=te(void 0),[f,m]=te(!1),[s,y]=te("idle"),[x,b]=te(void 0),v=t?t.id:"undefined",p=st(()=>{try{if(t&&o.length){let c=o[0],h=r.get(c.body[0]),u=at(h)[0];return u&&n(u,{width:u.width||t.width,height:u.height||t.height},!0)||void 0}}catch(c){console.error(c)}},[v,e,t]),S=s==="success"&&a?a:p;return so(()=>{(async()=>{try{if(t&&o.length){let c=o[0],h=r.get(c.body[0]),u=at(h)[0];if(!u)return;m(!0),y("loading");try{let g=await i(u,{width:u.width||t.width,height:u.height||t.height})||void 0;l(g),y("success"),m(!1)}catch(g){y("error"),b(g)}}}catch(c){y("error"),b(c)}})()},[v,e]),st(()=>({data:S,isFetching:f,status:s,error:x}),[S,f,s,x])}function Ws(){let e=lt();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 lo}from"@iiif/helpers";function Xs({supports:e=["empty","images","media","3d-model","textual-content","complex-timeline"]}={}){let t=w(),o=E(),r=B(),n=fe(()=>lo(t),[t]),i=fe(()=>n.getPaintables(r),[n,r]);return fe(()=>Oe({canvas:o,loadImageService:a=>a,paintables:i,supports:e}),[o,i,e])}import{createStylesHelper as co}from"@iiif/helpers/styles";import{useMemo as mo}from"react";function el(){let e=w();return mo(()=>co(e),[e])}import{useCallback as uo,useEffect as oe,useMemo as ct,useRef as re,useState as mt}from"react";function nl(e){let{initial:t,regions:o,progress:r,getProgress:n,enabled:i=!0,easing:a,reportEveryFrame:l=!1,pollInterval:f=Ee,loop:m=!1,onEnter:s,onExit:y,onProgress:x,jumpTo:b}=e,v=ct(()=>Ae(t,o),[t,o]),[p,S]=mt(()=>-1),[c,h]=mt(0),d=re(-1),u=re(0),g=re(!0),R=re(()=>{});oe(()=>(g.current=!0,()=>{g.current=!1}),[]);let M=ct(()=>{if(!a)return W(ie);if(typeof a=="function")return a;if(Array.isArray(a)&&a.length===4)return W(a);let I=qe[a];return I?W(I):W(ie)},[a]),q=uo(I=>{if(!(I<0||I>=v.length)&&(S(I),d.current=I,u.current=0,h(0),s))try{s(I)}catch{}},[v,s]);oe(()=>{R.current=q,b&&b(q)},[q,b]);function L(I){let{index:V,t:U}=ke(I,v),N=V;if(m&&v.length>0){let ne=v.length;N=(V%ne+ne)%ne}let _=M(U);if(N!==d.current){if(d.current>=0&&y)try{y(d.current)}catch{}if(N>=0&&s)try{s(N)}catch{}d.current=N,g.current&&S(N)}if(u.current=_,g.current&&(l||N!==p)&&h(_),x&&N>=0)try{x(N,_)}catch{}}oe(()=>{i&&typeof r=="number"&&L(r)},[r,i]),oe(()=>{if(!i||typeof n!="function")return;let I=null,V=()=>{try{let U=n();L(U)}catch{}};return V(),I=setInterval(V,f),()=>clearInterval(I)},[n,i,f]);let A=p>=0&&p<v.length?v[p]:void 0,ft=A?Ne(A.from,A.to,u.current):void 0;return{transitions:v,currentIndex:p,currentTransition:A,t:u.current,rect:ft,jumpTo:q}}import{useEffect as fo,useRef as ut,useState as po}from"react";function sl(e,t={}){let{axis:o="y",offset:r=0,steps:n=1,enabled:i=!0}=t,[a,l]=po(0),f=ut(-1),m=ut(null);return fo(()=>{if(!i||!e||!e.current)return;let s=e.current,y=()=>{let b=o==="y"?s.scrollTop:s.scrollLeft,v=o==="y"?s.clientHeight:s.clientWidth,S=(o==="y"?s.scrollHeight:s.scrollWidth)-v,h=(S<=0?0:Math.max(0,Math.min(1,(b+r)/S)))*n;h!==f.current&&(f.current=h,l(h)),m.current=null},x=()=>{m.current===null&&(m.current=requestAnimationFrame(y))};return s.addEventListener("scroll",x,{passive:!0}),y(),()=>{s.removeEventListener("scroll",x),m.current!==null&&cancelAnimationFrame(m.current)}},[e,o,r,n,i]),a}function cl(e,t){let{x:o,y:r,width:n,height:i}=e,{x:a,y:l}=t,{width:f,height:m}=t;return o+n>a&&o<a+f&&r+i>l&&r<l+m}import go from"tiny-invariant";function gl(e,t){let o=e.boundingBox||Se(e.polygon);if(e.polygon&&!be(e.polygon.points)){let r=e.target||Ie(e.polygon,t);return go(r?.type==="SvgSelector"),{type:"SvgSelector",points:e.polygon.points,spatial:{unit:"pixel",...o||{}},svgShape:e.polygon.open?"polyline":"polygon",svg:r.value}}return{type:"BoxSelector",spatial:o}}export{ka as AnnotationContext,za as AnnotationPageContext,lr as AnnotationStyleProvider,ar as AtlasStoreProvider,nr as AtlasStoreReactContext,Ko as Auth,Fo as AuthProvider,Lo as AuthRContext,zo as AuthReactContext,Bo as AuthReactContextActions,bi as CanvasAnnotations,pe as CanvasContext,De as CanvasPanel,On as CanvasStrategyProvider,Vn as CanvasWorldObject,Va as CollectionContext,Mi as CombinedMetadata,Dr as ComplexTimelineProvider,vn as ContextBridge,qr as ControlsReactContext,$e as CreateCustomShape,gn as CustomContextBridge,hn as CustomContextBridgeProvider,ie as DEFAULT_BEZIER,Ee as DEFAULT_POLL_INTERVAL,Cn as DefaultEditingTools,qe as EASING_PRESETS,jo as EventEmitterProvider,pn as EventsProvider,Mt as Image,oa as ImageService,Fr as ImageServiceLoaderContext,Xo as InnerViewerProvider,$r as LanguageProvider,Yr as LanguageString,H as LocaleString,bo as ManifestContext,la as ManifestMetadata,Ir as MediaPlayerProvider,j as Metadata,fi as PolygonSelector,So as RangeContext,Zo as ReactEmitterContext,fn as ReactEventContext,yo as ReactVaultContext,gr as RegionHighlight,Er as Render3DModelStrategy,Ar as RenderAccompanyingCanvas,hr as RenderAnnotation,In as RenderAnnotationEditing,vr as RenderAnnotationPage,zr as RenderAnnotationStrategy,Wr as RenderAudioStrategy,en as RenderComplexTimelineStrategy,tn as RenderEmptyStrategy,rn as RenderImageStrategy,Ea as RenderSvgEditorControls,nn as RenderTextualContentStrategy,an as RenderVideoStrategy,sn as RenderYouTubeStrategy,dr as ResizeWorldItem,z as ResourceProvider,ho as ResourceReactContext,ti as SelectorControllerProvider,Sa as SequenceThumbnails,Yo as SimpleViewerProvider,Go as SimpleViewerReactContext,tt as SingleCanvasThumbnail,wr as StrategyReactContext,Vr as ThumbnailFallbackImage,_r as TranslationProvider,Kr as TransliterationProvider,de as VaultProvider,ae as ViewerPresetContext,Lr as VirtualAnnotationProvider,vo as VisibleCanvasReactContext,gl as annotationResponseToSelector,ko as authDetailsForResource,Ae as buildTransitions,rr as createAtlasStore,No as createAuthStateStore,Ao as createProbe,W as cubicBezierEasing,un as defaultEmitter,cn as defaultSvgTheme,wn as emptyActions,qn as emptyStrategy,Co as findAllCanvasesInRange,Io as findFirstCanvasFromRange,Ro as findManifestSelectedRange,Po as findSelectedRange,Nn as flattenAnnotationPageIds,Rr as formatTime,Mn as get3dStrategy,ir as getAtlasStoreByName,Bn as getComplexTimelineStrategy,Or as getCroppedThumbnail,sr as getDefaultAnnotationStyles,Hn as getImageStrategy,To as getManifestSequence,Pn as getParsedTargetSelector,Oe as getRenderingStrategy,ke as getStepFromProgress,Ln as getTextualContentStrategy,zn as getVideoStrategy,wo as getVisibleCanvasesFromCanvasId,qo as hasAuth,Ne as interpolateRect,tr as isBoxSelector,be as isRectangle,er as isSvgSelector,Ho as makeAccessServiceRequest,Mo as makeAccessTokenRequest,Rn as parseSpecificResource,Ie as polygonToTarget,Ce as requestToAnnotationResponse,or as seraliseSupportedSelector,Gn as svgThemes,cl as targetIntersects,Tn as unknownResponse,En as unsupportedStrategy,ur as useAnnotation,yr as useAnnotationPage,Be as useAnnotationPageManager,Re as useAnnotationStyles,_a as useAnnotationsAtTime,bn as useAtlasContextMenu,T as useAtlasStore,Wo as useAuthActions,Uo as useAuthService,Vo as useAuthStore,$o as useAuthToken,_o as useAuthTokens,E as useCanvas,Ya as useCanvasChoices,ja as useCanvasClock,Eo as useCanvasSequence,Cr as useCanvasStartTime,os as useCanvasSubset,Zr as useClosestLanguage,ss as useCollection,Ur as useComplexTimeline,yn as useContextBridge,xn as useContextMenuStore,Jr as useCreateLocaleString,fs as useCurrentAnnotationActions,ys as useCurrentAnnotationMetadata,Sn as useCurrentAnnotationRequest,Is as useCurrentAnnotationTransition,Do as useCurrentAuth,dn as useCustomContextBridge,kr as useDispatch,Jo as useEmitter,G as useEvent,ze as useEventEmitter,Ts as useEventListener,he as useExistingVault,As as useExternalCollection,xo as useExternalManifest,ye as useExternalResource,Gr as useIIIFLanguage,le as useImage,lt as useImageService,we as useImageServiceLoader,Ws as useImageTile,Oo as useIsAuthEnabled,Fe as useLoadImageService,jr as useLocaleString,Q as useManifest,br as useMediaActions,Sr as useMediaElements,xr as useMediaState,kn as usePaintables,B as usePaintingAnnotations,ln as usePolygonHelper,ve as useRange,mr as useRemoteStylesheet,Nr as useRenderControls,Fn as useRenderingStrategy,_e as useRequestAnnotation,$ as useResourceContext,fr as useResourceEvents,An as useResources,Qo as useSearchService,Ze as useSelectorController,oi as useSelectorEmitter,Ye as useSelectorEvents,ri as useSelectorHelper,Pr as useSimpleMediaPlayer,xe as useSimpleViewer,Xs as useStaticRenderingStrategy,Tr as useStrategy,el as useStyleHelper,pr as useStyles,cr as useStylesheetStore,mn as useSvgEditor,ot as useSvgEditorControls,Te as useThumbnail,Xr as useTranslations,Qr as useTransliteration,w as useVault,Br as useVaultEffect,K as useVaultSelector,on as useViewerPreset,sl as useViewportScroll,nl as useViewportTour,Mr as useVirtualAnnotationPage,Hr as useVirtualAnnotationPageContext,ge as useVisibleCanvases};
1
+ import{$ as er,$a as qe,$b as We,A as Ao,Aa as Ir,Ab as ln,B as ko,Ba as Cr,Bb as cn,C as Mo,Ca as Rr,Cb as mn,D as Ho,Da as Pr,Db as un,E as Lo,Ea as Pe,Eb as fn,F as zo,Fa as wr,Fb as ze,G as Bo,Ga as Tr,Gb as pn,H as Fo,Ha as Er,Hb as dn,I as Oo,Ia as qr,Ib as gn,J as Vo,Ja as Nr,Jb as hn,K as Wo,Ka as Ar,Kb as yn,L as Do,La as kr,Lb as vn,M as Uo,Ma as Mr,Mb as xn,N as _o,Na as Hr,Nb as bn,O as $o,Oa as Lr,Ob as Sn,P as Ko,Pa as zr,Pb as In,Q as Qo,Qa as Br,Qb as Cn,R as Go,Ra as Fr,Rb as Nn,S as Xo,Sa as we,Sb as Be,T as Yo,Ta as Or,Tb as An,U as xe,Ua as Te,Ub as Fe,V as Zo,Va as Vr,Vb as B,W as jo,Wa as Wr,Wb as kn,X as Jo,Xa as Dr,Xb as Fn,Y as G,Ya as Ur,Yb as On,Z as be,Za as ie,Zb as Vn,_ as Se,_a as Ee,_b as Ve,a as ho,aa as tr,ab as Ne,ac as De,b as $,ba as or,bb as Ae,c as z,ca as Ie,cb as W,d as pe,da as Ce,db as ke,e as yo,ea as rr,eb as Me,f as de,fa as nr,fb as He,g as w,ga as T,gb as _r,h as K,ha as ir,hb as $r,i as vo,ia as ar,ib as Kr,j as ge,ja as sr,jb as Qr,k as he,ka as Re,kb as Gr,l as Q,la as lr,lb as Xr,m as ye,ma as cr,mb as Yr,n as xo,na as mr,nb as Zr,o as bo,oa as ur,ob as jr,p as So,pa as E,pb as Jr,q as Io,qa as fr,qb as H,r as Co,ra as pr,rb as Le,s as Ro,sa as dr,sb as en,t as Po,ta as gr,tb as tn,u as wo,ua as hr,ub as ae,v as To,va as yr,vb as on,w as ve,wa as vr,wb as rn,x as Eo,xa as xr,xb as nn,y as qo,ya as br,yb as an,z as No,za as Sr,zb as sn}from"./chunk-KUNXFW7A.js";import"./chunk-UNH7HXGJ.js";import{a as Rn,b as Pn,c as wn,d as Tn,e as En,f as qn,g as Mn,h as Hn,i as Ln,j as zn,k as Bn,l as Oe}from"./chunk-P7XHGETS.js";export*from"@iiif/helpers/annotation-targets";import{useEffect as gt}from"react";import{useCallback as Ue,useEffect as pt,useRef as dt,useState as X}from"react";import{useStore as F}from"zustand";function _e(e){let[t,o]=X(0),r=T(),n=F(r,g=>g.tool.enabled),i=F(r,g=>g.tool.requestId),a=F(r,g=>g.getRequestId),l=F(r,g=>g.requestAnnotation),f=F(r,g=>g.completeRequest),m=F(r,g=>g.cancelRequest),s=dt(e?.onSuccess);s.current=e?.onSuccess;let[y,x]=X(!1),[b,v]=X(null),[p,S]=X(null),c=n&&i!==p,h=n&&i===p,d=Ue(async(g,R)=>{if(p){let M=s.current;x(!0);let q=await l(g,{...R,requestId:p});if(q)return M?.(q),o(A=>A+1),x(!1),v(q),q;let L={id:p,cancelled:!0,...Ce(g)};return M?.(L),v(L),o(A=>A+1),x(!1),L}return null},[l,p]),u=Ue(()=>{v(null),x(!1)},[]);return pt(()=>{let g=a();return S(g.requestId),()=>{g.clear()}},[t]),{id:t,busy:c,isPending:y,isActive:h,requestId:p,requestAnnotation:d,cancelRequest:()=>p?m(p):void 0,completeRequest:()=>p?f(p):void 0,reset:u,data:b}}var Gn=[{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 $e(e){let{id:t,data:o,requestAnnotation:r,cancelRequest:n,isPending:i}=_e({onSuccess:a=>{e.updateShape(a.polygon)}});return gt(()=>(r({type:"polygon",open:e.shape?.open,points:e.shape?.points}),()=>{n()}),[]),null}import{createContext as ht,useCallback as Ke,useContext as Ge,useEffect as Qe,useMemo as se,useState as yt}from"react";import Xe from"mitt";import{jsx as vt}from"react/jsx-runtime";var Y=ht(Xe());Y.displayName="SelectorHelper";function ti({children:e}){return vt(Y.Provider,{value:se(()=>Xe(),[]),children:e})}function oi(){return Ge(Y)}function Ye(e){let t=Ze(),[o,r]=yt(!1);Qe(()=>t.withSelector(e).on("highlight",()=>{r(!0)}),[t,e]),Qe(()=>t.withSelector(e).on("clear-highlight",()=>{r(!1)}),[t,e]);let n=Ke(a=>{t.emit("click",{selectorId:e,event:a})},[e,t]),i=Ke(a=>{t.emit("hover",{selectorId:e,event:a})},[e,t]);return{controller:t,onClick:n,onHover:i,isHighlighted:o}}function Ze(){let e=Ge(Y);return se(()=>({withSelector(t){return{on(o,r){let n=i=>{i&&i.selectorId===t&&r(i)};return e.on(o,n),()=>{e.off(o,n)}},emit(o,r){e.emit(o,{...r,selectorId:t})}}},on(t,o){return e.on(t,o),()=>{e.off(t,o)}},emit(t,o){e.emit(t,o)}}),[e])}function ri(){let e=Ze();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(o,r){return e.emit("event-listener",{selectorId:t,name:o,callback:r}),()=>{e.emit("remove-event-listener",{selectorId:t,name:o,callback:r})}},getImagePreview(){return new Promise((o,r)=>{e.emit("image-preview-request",{selectorId:t,resolve:o,reject:r})})},on(o,r){return e.withSelector(t).on(o,r)}}},highlight(t){e.emit("highlight",{selectorId:t})},clearHighlight(t){e.emit("clear-highlight",{selectorId:t})},zoomTo(t){e.emit("zoom-to",{selectorId:t})},addEventListener(t,o,r){return e.emit("event-listener",{selectorId:t,name:o,callback:r}),()=>{e.emit("remove-event-listener",{selectorId:t,name:o,callback:r})}},getImagePreview(t){return new Promise((o,r)=>{e.emit("image-preview-request",{selectorId:t,resolve:o,reject:r})})},on(t,o){return e.on(t,o)}}),[e])}import{jsx as je}from"react/jsx-runtime";function fi(e){let t=E(),o=e.annotationBucket,r=e.readOnly,n=e.id,{onClick:i,isHighlighted:a}=Ye(e.id),l=Re(),f=a?l.highlighted:l[o||"hidden"]||l.hidden;if(!t)return null;if(r){let m="shape",s=e.polygon,y=s.open;return s?je(m,{id:`shape-${n}`,points:s.points,open:y,onClick:i,relativeStyle:!0,target:{x:0,y:0,width:t.width,height:t.height},style:f}):null}return je($e,{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 xt}from"@atlas-viewer/atlas";import{forwardRef as bt,useImperativeHandle as St}from"react";import{Fragment as It,jsx as Je}from"react/jsx-runtime";var bi=bt(function({canvasId:t},o){let r=xt(),n=Be(t||r?.id),i=w();return St(o,()=>n,[t,r]),!r||n.enabledPageIds.length===0?null:Je(It,{children:n.enabledPageIds.map(a=>Je(De.RenderAnnotationPage,{page:i.get(a)},a))})});import{useMemo as Pt}from"react";import{useMemo as Ct}from"react";import{Fragment as Rt,jsx as C,jsxs as Z}from"react/jsx-runtime";function j({metadata:e=[],config:t,labelWidth:o=16,showEmptyMessage:r=!0,allowHtml:n,emptyFallback:i,classes:a={},emptyMessage:l="No metadata available",emptyValueFallback:f="No value",emptyLabelFallback:m="",separator:s,tableFooter:y,tableHeader:x,customLabelRender:b,customValueRender:v}){let p=Ct(()=>{let c=(t||[]).reduce((d,u)=>[...d,...u.keys],[]),h={};for(let d of e){let u=d?.label?Object.values(d.label):[];for(let g of u)if(g?.length&&(c.indexOf(`metadata.${g[0]}`)!==-1||c.length===0)&&d){let R=`metadata.${g[0]}`;h[R]=h[R]?h[R]:[],h[R].push(d);break}}return h},[t,e]);return Object.keys(p).length===0&&r?C(Rt,{children:i})||C("div",{className:a.empty,children:l}):t?.length?Z("table",{className:a.container,children:[x,C("tbody",{children:t.map((c,h)=>{let d=[];for(let g of c.keys)for(let R of p[g]||[]){let M=C(H,{enableDangerouslySetInnerHTML:n,defaultText:f,separator:s,children:R.value},h+"__"+g);v?d.push(v(R,M)):d.push(M)}if(d.length===0)return null;let u=C(H,{enableDangerouslySetInnerHTML:n,separator:s,defaultText:m,children:c.label});return Z("tr",{className:a.row,children:[C("td",{className:a.label,style:o?{minWidth:o}:{},children:b?b(c.label,u):u}),C("td",{className:a.value,children:d})]},h)})}),y]}):Z("table",{className:a.container,children:[x,C("tbody",{children:e?.length?e.map((c,h)=>{if(!c)return null;let d=C(H,{enableDangerouslySetInnerHTML:n,defaultText:f,separator:s,children:c.label}),u=C(H,{enableDangerouslySetInnerHTML:n,defaultText:f,separator:s,children:c.value});return Z("tr",{className:a.row,children:[C("td",{className:a.label,style:o?{minWidth:o}:{},children:b?b(c.label,d):d}),C("td",{className:a.value,children:v?v(c,u):u})]},h)}):null}),y]})}import{jsx as wt}from"react/jsx-runtime";function Mi(e){let t=Q(),o=E(),r=ve(),n=Pt(()=>{let i=t?.metadata||[],a=o?.metadata||[],l=r?.metadata||[];return[...i,...a,...l]},[t,o,r]);return wt(j,{metadata:n,...e})}import{useEffect as Nt,useState as At}from"react";import{createImageServiceRequest as Tt,imageServiceRequestToString as Et}from"@iiif/parser/image-3";import{useMemo as qt}from"react";function le(e,t={},o=[]){return qt(()=>{if(!e)return null;let r=t.quality;e&&e.extraQualities&&t.quality&&(e.extraQualities.includes(t.quality)||(r="default"));let n=Tt(e);return 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:r||"default",prefix:n.prefix,originalPath:n.originalPath})},[...o])}import{jsx as J}from"react/jsx-runtime";function kt(e){let t=typeof e.src=="string"?e.src:e.src.id,o=we(),[r,n]=At(!1),i;if(t){let l=o.loadServiceSync({id:t});l&&(i=l)}!i&&!r&&o.loadService({id:t}).then(()=>{n(!0)});let a=le(i,{size:e.size,selector:e.region,rotation:e.rotation,format:e.format,region:e.region,quality:e.quality},[r,e.src,e.size,e.region,e.rotation,e.format,e.region,e.quality]);return Nt(()=>()=>{n(!1)},[t]),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,o=le(t,{size:e.size,selector:e.region,rotation:e.rotation,format:e.format,region:e.region,quality:e.quality},[e.src,e.size,e.region,e.rotation,e.format,e.region,e.quality]);return o?J("img",{src:o,alt:e.alt,className:e.className,style:e.style}):null}import{useMemo as Ht,useState as Lt}from"react";import{ErrorBoundary as zt}from"react-error-boundary";import{jsx as O,jsxs as Ft}from"react/jsx-runtime";function oa({src:e,errorFallback:t,interactive:o,skipSizes:r,children:n,renderViewerControls:i,viewControlsDeps:a,fluid:l,x:f,y:m,...s}){let y=he(),[x,b]=Lt(),v=t||Ve,[p,S]=Fe(),c=Ht(()=>{let d=S[e]?.status,u=p({id:e},{});return u?.height&&u.width&&d!=="loading"?{id:e,width:u.width,height:u.height,service:u,type:"Image",selector:{type:"BoxSelector",spatial:{x:0,y:0,width:u.width,height:u.height}},target:{type:"BoxSelector",spatial:{x:0,y:0,width:u.width,height:u.height}}}:null},[p,e,S]);if(!c||!c.height||!c.width)return null;let h=l?void 0:s.homePosition?s.homePosition.width/s.homePosition.height:c.width/c.height;return O(zt,{resetKeys:[],fallbackRender:d=>O(v,{...s,...d}),children:O(de,{vault:y,children:O(We,{...s,aspectRatio:h,containerProps:{style:{position:"relative"},...s.containerProps||{}},onCreated:d=>{b(d),s.onCreated&&s.onCreated(d)},children:Ft(ae.Provider,{value:x,children:[O(Le,{image:c,id:c.id,isStatic:!o,x:f,y:m},c.id),O(Bt,{viewerPreset:x,renderViewerControls:i,image:c,src:e,viewControlsDeps:a}),n]})})})})}function Bt({viewerPreset:e,renderViewerControls:t,image:o,src:r,viewControlsDeps:n}){return Pe(e&&t?"overlay":"none",`canvas-portal-controls-${r}`,ae.Provider,t&&o?{value:e||null,children:t({image:o,images:[o],type:"images"})}:{},[r,e,...n||[]]),null}import{jsx as Ot}from"react/jsx-runtime";function la(e){let t=Q();return Ot(j,{metadata:t?.metadata||[],...e})}import{useLayoutEffect as _t,useRef as $t}from"react";import*as ce from"react-lazy-load-image-component";import{getValue as Vt}from"@iiif/helpers/i18n";import{Fragment as et,jsx as k,jsxs as Ut}from"react/jsx-runtime";var{LazyLoadComponent:Wt}=ce||ce.default;function tt(e){let{size:t,visible:o,classes:r,canvasId:n,figure:i}=e,a=t?.width||128,l=t?.height||t?.width||128,f=k(Dt,{...e}),m=k(Wt,{threshold:300,style:{height:l,width:a},visibleByDefault:o,children:n?k(pe,{canvas:n,children:f}):f});return i?k("figure",{className:r?.figure,children:m}):m}function Dt({fallback:e,size:t,classes:o,showLabel:r,alt:n,dereference:i=!1}){let a=E(),l=t?.width||128,f=t?.height||t?.width||128,m=n||Vt(a?.label)||"",s=Te({width:l,height:f,allowUnsafe:!0},i);return!s||s.type!=="fixed"?k(et,{children:e}):Ut(et,{children:[k("div",{className:o?.imageWrapper,children:k("img",{className:o?.img,src:s.id,alt:m})}),r?k(H,{as:"figcaption",className:o?.label,children:a?.label}):null]})}import{jsx as D}from"react/jsx-runtime";function Sa({scrollBehaviour:e,dereference:t,flat:o,size:r,classes:n={},showLabel:i,figure:a,fallback:l}){let f=$t(null),{items:m,sequence:s,currentSequenceIndex:y,setSequenceIndex:x}=xe(),b={row:n.selected?.row||n.row,item:n.selected?.item||n.item,figure:n.selected?.figure||n.figure,img:n.selected?.img||n.img,label:n.selected?.label||n.label,imageWrapper:n.selected?.imageWrapper||n.imageWrapper};_t(()=>{if(!f.current)return;let p=f.current.querySelector("[data-selected=true]");p&&p.scrollIntoView({behavior:e||"instant",block:"nearest",inline:"center"})},[y]);let v=[];for(let p of s){let S=[],c=s[y]===p;for(let h of p){let d=m[h];S.push(D("div",{className:c?b.item:n.item,children:D(tt,{classes:c?b:n,canvasId:d.id,size:r,dereference:t,showLabel:i,figure:a,placeholder:D("div",{style:{height:128,width:128}}),fallback:l})},h))}if(o){v.push(S);continue}v.push(D("div",{onClick:h=>{x(s.indexOf(p))},"data-selected":c,className:c?b.row:n.row,children:S},p.join("-")))}return D("div",{ref:f,className:n.container,children:v})}import{useStore as ee}from"zustand";function ot(){let e=T(),t=ee(e,i=>i.completeRequest),o=ee(e,i=>i.polygonState.currentTool),r=ee(e,i=>i.polygonState.selectedStamp),n=ee(e,i=>i.switchTool);return{completeRequest:t,currentTool:o,selectedStamp:r,switchTool:n}}import{Fragment as rt,jsx as P,jsxs as nt}from"react/jsx-runtime";var Kt={draw:!0,polygon:!0,line:!0,lineBox:!0,box:!0,triangle:!0,hexagon:!0,circle:!0,delete:!0,pen:!0};function Ea({showShapes:e=!0,enabled:t=Kt,classNames:o={},icons:r={}}){let{currentTool:n,switchTool:i,selectedStamp:a}=ot();return nt(rt,{children:[n,P("button",{className:o.button,onClick:i.pointer,"data-active":n==="pointer",children:r.PointerIcon||"Pointer"}),P("button",{className:o.button,onClick:i.hand,"data-active":n==="hand",children:r.HandIcon||"Hand"}),e?nt(rt,{children:[t.box&&P("button",{className:o.button,onClick:i.box,"data-active":n==="box",children:r.BoxIcon||"Box"}),t.pen&&P("button",{className:o.button,onClick:i.pen,"data-active":n==="pen",children:r.PenIcon||"Pen"}),t.draw&&P("button",{className:o.button,onClick:i.draw,"data-active":n==="pencil",children:r.DrawIcon||"Draw"}),t.line&&P("button",{className:o.button,onClick:i.line,"data-active":n==="line",children:r.LineIcon||"Line"}),t.lineBox&&P("button",{className:o.button,onClick:i.lineBox,"data-active":n==="lineBox",children:r.LineBoxIcon||"LineBox"}),t.triangle&&P("button",{className:o.button,onClick:i.triangle,"data-active":n==="stamp"&&a?.id==="triangle",children:r.TriangleIcon||"Triangle"}),t.hexagon&&P("button",{className:o.button,onClick:i.hexagon,"data-active":n==="stamp"&&a?.id==="hexagon",children:r.HexagonIcon||"Hexagon"}),t.circle&&P("button",{className:o.button,"data-active":n==="stamp"&&a?.id==="circle",onClick:i.circle,children:r.CircleIcon||"Circle"})]}):null,t.delete&&P("button",{className:o.button,onClick:i.remove,children:r.DeleteForeverIcon||"Delete"})]})}import{jsx as Qt}from"react/jsx-runtime";function ka({annotation:e,children:t}){return Qt(z,{value:{annotation:e},children:t})}import{jsx as Gt}from"react/jsx-runtime";function za({annotationPage:e,children:t}){return Gt(z,{value:{annotationPage:e},children:t})}import{jsx as Xt}from"react/jsx-runtime";function Va({collection:e,children:t}){return Xt(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 me,useState as jt}from"react";function Ya({canvasId:e}={}){let t=Yt(),o=ge(),r=me(()=>e?[e]:t?[t.id]:o.map(m=>m.id),[e,t,o]),[n,i]=jt({}),a=ze();Zt(()=>{let m=s=>{let y=s.partOf.canvasId;y&&i(x=>({...x,[y]:s.choice}))};return a.on("choice-change",m),()=>{a.off("choice-change",m)}},[]);let l=me(()=>{let m=[];for(let s of r){let y=n[s];y&&m.push({canvasId:s,choice:y})}return m},[r,n]),f=me(()=>({makeChoice:(m,s)=>{a.emit("make-choice",{choiceId:m,...s})}}),[a]);return{choices:l,actions:f}}function ja(e,t=!1){}function os(e){let o=$().manifest,r=e?e.map(n=>typeof n=="string"?n:n?.id):[];return K(n=>{let i=o?n.iiif.entities.Manifest[o]:void 0,a=i?.items||[];if(typeof e>"u")return a;let l=[];for(let f of i?.items||[])r.indexOf(f.id)!==-1&&l.push(f);return l},[r.join("/")])}import{useMemo as Jt}from"react";function ss(e,t=[]){let{id:o,selector:r}=e,n=$(),i=o||n.collection,a=K(l=>i?l.iiif.entities.Collection[i]:void 0,[i]);return Jt(()=>{if(a)return r?r(a):a},[a,r,...t])}import{startTransition as eo,useMemo as to}from"react";import{useStore as it}from"zustand";function fs(){let e=T(),t=it(e,r=>r.completeRequest),o=it(e,r=>r.cancelRequest);return to(()=>({saveAnnotation:()=>{eo(()=>{t()})},cancelRequest:o}),[t,o])}import{useCallback as oo}from"react";import{useStore as ue}from"zustand";function ys({requestId:e}={}){let t=T(),o=ue(t,l=>l.metadata),r=ue(t,l=>l.tool.requestId),n=e||r,i=ue(t,l=>l.setMetadata),a=oo(l=>i(l,n||void 0),[i,n]);return[n?o[n]||{}:{},a]}import{useStore as ro}from"zustand";function Is(e){let t=T(),o=ro(t,r=>r.tool.requestId);G("polygons.start-transition",r=>{e.requestId&&o!==e.requestId||e?.onStart?.(r.transitionIntent)},[o,e.requestId]),G("polygons.end-transition",r=>{e.requestId&&o!==e.requestId||e?.onEnd?.(r.transitionIntent,r.response)},[o,e.requestId]),G("polygons.transition",r=>{e.requestId&&o!==e.requestId||e?.onTransition?.(r.transitionIntent)},[o,e.requestId])}import{useEffect as no,useMemo as io}from"react";import{createEventsHelper as ao}from"@iiif/helpers/events";function Ts(e,t,o,r,n=[]){let i=w(),a=io(()=>ao(i),[i]);no(()=>{let l=e;return l?(a.addEventListener(l,t,o,r),()=>{a.removeEventListener(l,t,o)}):()=>{}},[a,e,t,...n])}function As(e,t){let{id:o,isLoaded:r,error:n,resource:i,requestId:a,cached:l}=ye(e,t);return{id:o,isLoaded:r,error:n,manifest:i,requestId:a,cached:l}}import{getImageServices as at}from"@iiif/parser/image-3";import{useEffect as so,useMemo as st,useState as te}from"react";function lt({cacheKey:e}={}){let t=E(),o=B(),r=w(),n=Me(),i=He(),[a,l]=te(void 0),[f,m]=te(!1),[s,y]=te("idle"),[x,b]=te(void 0),v=t?t.id:"undefined",p=st(()=>{try{if(t&&o.length){let c=o[0],h=r.get(c.body[0]),u=at(h)[0];return u&&n(u,{width:u.width||t.width,height:u.height||t.height},!0)||void 0}}catch(c){console.error(c)}},[v,e,t]),S=s==="success"&&a?a:p;return so(()=>{(async()=>{try{if(t&&o.length){let c=o[0],h=r.get(c.body[0]),u=at(h)[0];if(!u)return;m(!0),y("loading");try{let g=await i(u,{width:u.width||t.width,height:u.height||t.height})||void 0;l(g),y("success"),m(!1)}catch(g){y("error"),b(g)}}}catch(c){y("error"),b(c)}})()},[v,e]),st(()=>({data:S,isFetching:f,status:s,error:x}),[S,f,s,x])}function Ws(){let e=lt();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 lo}from"@iiif/helpers";function Xs({supports:e=["empty","images","media","3d-model","textual-content","complex-timeline"]}={}){let t=w(),o=E(),r=B(),n=fe(()=>lo(t),[t]),i=fe(()=>n.getPaintables(r),[n,r]);return fe(()=>Oe({canvas:o,loadImageService:a=>a,paintables:i,supports:e}),[o,i,e])}import{createStylesHelper as co}from"@iiif/helpers/styles";import{useMemo as mo}from"react";function el(){let e=w();return mo(()=>co(e),[e])}import{useCallback as uo,useEffect as oe,useMemo as ct,useRef as re,useState as mt}from"react";function nl(e){let{initial:t,regions:o,progress:r,getProgress:n,enabled:i=!0,easing:a,reportEveryFrame:l=!1,pollInterval:f=Ee,loop:m=!1,onEnter:s,onExit:y,onProgress:x,jumpTo:b}=e,v=ct(()=>Ae(t,o),[t,o]),[p,S]=mt(()=>-1),[c,h]=mt(0),d=re(-1),u=re(0),g=re(!0),R=re(()=>{});oe(()=>(g.current=!0,()=>{g.current=!1}),[]);let M=ct(()=>{if(!a)return W(ie);if(typeof a=="function")return a;if(Array.isArray(a)&&a.length===4)return W(a);let I=qe[a];return I?W(I):W(ie)},[a]),q=uo(I=>{if(!(I<0||I>=v.length)&&(S(I),d.current=I,u.current=0,h(0),s))try{s(I)}catch{}},[v,s]);oe(()=>{R.current=q,b&&b(q)},[q,b]);function L(I){let{index:V,t:U}=ke(I,v),N=V;if(m&&v.length>0){let ne=v.length;N=(V%ne+ne)%ne}let _=M(U);if(N!==d.current){if(d.current>=0&&y)try{y(d.current)}catch{}if(N>=0&&s)try{s(N)}catch{}d.current=N,g.current&&S(N)}if(u.current=_,g.current&&(l||N!==p)&&h(_),x&&N>=0)try{x(N,_)}catch{}}oe(()=>{i&&typeof r=="number"&&L(r)},[r,i]),oe(()=>{if(!i||typeof n!="function")return;let I=null,V=()=>{try{let U=n();L(U)}catch{}};return V(),I=setInterval(V,f),()=>clearInterval(I)},[n,i,f]);let A=p>=0&&p<v.length?v[p]:void 0,ft=A?Ne(A.from,A.to,u.current):void 0;return{transitions:v,currentIndex:p,currentTransition:A,t:u.current,rect:ft,jumpTo:q}}import{useEffect as fo,useRef as ut,useState as po}from"react";function sl(e,t={}){let{axis:o="y",offset:r=0,steps:n=1,enabled:i=!0}=t,[a,l]=po(0),f=ut(-1),m=ut(null);return fo(()=>{if(!i||!e||!e.current)return;let s=e.current,y=()=>{let b=o==="y"?s.scrollTop:s.scrollLeft,v=o==="y"?s.clientHeight:s.clientWidth,S=(o==="y"?s.scrollHeight:s.scrollWidth)-v,h=(S<=0?0:Math.max(0,Math.min(1,(b+r)/S)))*n;h!==f.current&&(f.current=h,l(h)),m.current=null},x=()=>{m.current===null&&(m.current=requestAnimationFrame(y))};return s.addEventListener("scroll",x,{passive:!0}),y(),()=>{s.removeEventListener("scroll",x),m.current!==null&&cancelAnimationFrame(m.current)}},[e,o,r,n,i]),a}function cl(e,t){let{x:o,y:r,width:n,height:i}=e,{x:a,y:l}=t,{width:f,height:m}=t;return o+n>a&&o<a+f&&r+i>l&&r<l+m}import go from"tiny-invariant";function gl(e,t){let o=e.boundingBox||Se(e.polygon);if(e.polygon&&!be(e.polygon.points)){let r=e.target||Ie(e.polygon,t);return go(r?.type==="SvgSelector"),{type:"SvgSelector",points:e.polygon.points,spatial:{unit:"pixel",...o||{}},svgShape:e.polygon.open?"polyline":"polygon",svg:r.value}}return{type:"BoxSelector",spatial:o}}export{ka as AnnotationContext,za as AnnotationPageContext,lr as AnnotationStyleProvider,ar as AtlasStoreProvider,nr as AtlasStoreReactContext,Ko as Auth,Fo as AuthProvider,Lo as AuthRContext,zo as AuthReactContext,Bo as AuthReactContextActions,bi as CanvasAnnotations,pe as CanvasContext,De as CanvasPanel,On as CanvasStrategyProvider,Vn as CanvasWorldObject,Va as CollectionContext,Mi as CombinedMetadata,Dr as ComplexTimelineProvider,vn as ContextBridge,qr as ControlsReactContext,$e as CreateCustomShape,gn as CustomContextBridge,hn as CustomContextBridgeProvider,ie as DEFAULT_BEZIER,Ee as DEFAULT_POLL_INTERVAL,Cn as DefaultEditingTools,qe as EASING_PRESETS,jo as EventEmitterProvider,pn as EventsProvider,Mt as Image,oa as ImageService,Fr as ImageServiceLoaderContext,Xo as InnerViewerProvider,$r as LanguageProvider,Yr as LanguageString,H as LocaleString,bo as ManifestContext,la as ManifestMetadata,Ir as MediaPlayerProvider,j as Metadata,fi as PolygonSelector,So as RangeContext,Zo as ReactEmitterContext,fn as ReactEventContext,yo as ReactVaultContext,gr as RegionHighlight,Er as Render3DModelStrategy,Ar as RenderAccompanyingCanvas,hr as RenderAnnotation,In as RenderAnnotationEditing,vr as RenderAnnotationPage,zr as RenderAnnotationStrategy,Wr as RenderAudioStrategy,en as RenderComplexTimelineStrategy,tn as RenderEmptyStrategy,rn as RenderImageStrategy,Ea as RenderSvgEditorControls,nn as RenderTextualContentStrategy,an as RenderVideoStrategy,sn as RenderYouTubeStrategy,dr as ResizeWorldItem,z as ResourceProvider,ho as ResourceReactContext,ti as SelectorControllerProvider,Sa as SequenceThumbnails,Yo as SimpleViewerProvider,Go as SimpleViewerReactContext,tt as SingleCanvasThumbnail,wr as StrategyReactContext,Vr as ThumbnailFallbackImage,_r as TranslationProvider,Kr as TransliterationProvider,de as VaultProvider,ae as ViewerPresetContext,Lr as VirtualAnnotationProvider,vo as VisibleCanvasReactContext,gl as annotationResponseToSelector,ko as authDetailsForResource,Ae as buildTransitions,rr as createAtlasStore,No as createAuthStateStore,Ao as createProbe,W as cubicBezierEasing,un as defaultEmitter,cn as defaultSvgTheme,wn as emptyActions,qn as emptyStrategy,Co as findAllCanvasesInRange,Io as findFirstCanvasFromRange,Ro as findManifestSelectedRange,Po as findSelectedRange,Nn as flattenAnnotationPageIds,Rr as formatTime,Mn as get3dStrategy,ir as getAtlasStoreByName,Bn as getComplexTimelineStrategy,Or as getCroppedThumbnail,sr as getDefaultAnnotationStyles,Hn as getImageStrategy,To as getManifestSequence,Pn as getParsedTargetSelector,Oe as getRenderingStrategy,ke as getStepFromProgress,Ln as getTextualContentStrategy,zn as getVideoStrategy,wo as getVisibleCanvasesFromCanvasId,qo as hasAuth,Ne as interpolateRect,tr as isBoxSelector,be as isRectangle,er as isSvgSelector,Ho as makeAccessServiceRequest,Mo as makeAccessTokenRequest,Rn as parseSpecificResource,Ie as polygonToTarget,Ce as requestToAnnotationResponse,or as seraliseSupportedSelector,Gn as svgThemes,cl as targetIntersects,Tn as unknownResponse,En as unsupportedStrategy,ur as useAnnotation,yr as useAnnotationPage,Be as useAnnotationPageManager,Re as useAnnotationStyles,_a as useAnnotationsAtTime,bn as useAtlasContextMenu,T as useAtlasStore,Wo as useAuthActions,Uo as useAuthService,Vo as useAuthStore,$o as useAuthToken,_o as useAuthTokens,E as useCanvas,Ya as useCanvasChoices,ja as useCanvasClock,Eo as useCanvasSequence,Cr as useCanvasStartTime,os as useCanvasSubset,Zr as useClosestLanguage,ss as useCollection,Ur as useComplexTimeline,yn as useContextBridge,xn as useContextMenuStore,Jr as useCreateLocaleString,fs as useCurrentAnnotationActions,ys as useCurrentAnnotationMetadata,Sn as useCurrentAnnotationRequest,Is as useCurrentAnnotationTransition,Do as useCurrentAuth,dn as useCustomContextBridge,kr as useDispatch,Jo as useEmitter,G as useEvent,ze as useEventEmitter,Ts as useEventListener,he as useExistingVault,As as useExternalCollection,xo as useExternalManifest,ye as useExternalResource,Gr as useIIIFLanguage,le as useImage,lt as useImageService,we as useImageServiceLoader,Ws as useImageTile,Oo as useIsAuthEnabled,Fe as useLoadImageService,jr as useLocaleString,Q as useManifest,br as useMediaActions,Sr as useMediaElements,xr as useMediaState,kn as usePaintables,B as usePaintingAnnotations,ln as usePolygonHelper,ve as useRange,mr as useRemoteStylesheet,Nr as useRenderControls,Fn as useRenderingStrategy,_e as useRequestAnnotation,$ as useResourceContext,fr as useResourceEvents,An as useResources,Qo as useSearchService,Ze as useSelectorController,oi as useSelectorEmitter,Ye as useSelectorEvents,ri as useSelectorHelper,Pr as useSimpleMediaPlayer,xe as useSimpleViewer,Xs as useStaticRenderingStrategy,Tr as useStrategy,el as useStyleHelper,pr as useStyles,cr as useStylesheetStore,mn as useSvgEditor,ot as useSvgEditorControls,Te as useThumbnail,Xr as useTranslations,Qr as useTransliteration,w as useVault,Br as useVaultEffect,K as useVaultSelector,on as useViewerPreset,sl as useViewportScroll,nl as useViewportTour,Mr as useVirtualAnnotationPage,Hr 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.17",
3
+ "version": "2.0.18",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
@@ -16,6 +16,7 @@
16
16
  "contributors": [
17
17
  "Stephen Fraser <stephen.fraser@digirati.com>"
18
18
  ],
19
+ "packageManager": "pnpm@11.15.1+sha512.81350b07e53c9538a02f1f2303b4290fa2d7be04e56e2a970c4cc4b417dc761de196edabd49d55c7dc9580db81007c44143e4e3d7e462b3000d23c255122d065",
19
20
  "exports": {
20
21
  ".": {
21
22
  "require": {
@@ -58,11 +59,6 @@
58
59
  "start": "vite"
59
60
  },
60
61
  "license": "MIT",
61
- "resolutions": {
62
- "react": "^19.2.0",
63
- "react-dom": "^19.2.0",
64
- "react-reconciler": "^0.33.0"
65
- },
66
62
  "dependencies": {
67
63
  "@floating-ui/react": "^0.27.13",
68
64
  "@iiif/helpers": "^1.5.9",
@@ -1,49 +0,0 @@
1
- import{c as fn,l as gn}from"./chunk-P7XHGETS.js";import{forwardRef as _r,useImperativeHandle as uu,useMemo as cu}from"react";import jr,{useContext as Kr,useMemo as Yr}from"react";import{jsx as Qr}from"react/jsx-runtime";var Gr={collection:void 0,manifest:void 0,range:void 0,canvas:void 0,annotation:void 0,annotationPage:void 0},_e=jr.createContext(Gr),j=()=>Kr(_e);function ae({value:e,children:t}){let n=j(),o=Yr(()=>({...n,...e}),[e,n]);return Qr(_e.Provider,{value:o,children:t})}import{jsx as Xr}from"react/jsx-runtime";function ne({canvas:e,children:t}){return Xr(ae,{value:{canvas:e},children:t})}import Zr,{useState as Jr}from"react";import{Vault as hn,globalVault as ei}from"@iiif/helpers/vault";import{jsx as yn}from"react/jsx-runtime";var ue=Zr.createContext({vault:null,setVaultInstance:e=>{}});function he({vault:e,vaultOptions:t,useGlobal:n,resources:o,children:s}){let[a,r]=Jr(()=>e||(n?ei(t):t?new hn(t):new hn));return yn(ue.Provider,{value:{vault:a,setVaultInstance:r},children:yn(ae,{value:o||{},children:s})})}import{useContext as ri}from"react";import ii from"react";import{useContext as ti}from"react";var M=()=>{let{vault:e}=ti(ue);if(e===null)throw new Error("Vault not found. Ensure you have your provider set up correctly.");return e};import{useEffect as ni,useState as oi}from"react";function k(e,t=[]){let n=M(),[o,s]=oi(()=>e(n.getState(),n));return ni(()=>n.subscribe(a=>e(a,n),a=>{s(a)},!1),t),o}var ye=ii.createContext([]);function je(){let e=ri(ye);return k(t=>e.map(n=>t.iiif.entities.Canvas[n]).filter(Boolean),[e])}import{globalVault as ai}from"@iiif/helpers/vault";import{useContext as si}from"react";function ve(e){let t=si(ue);return e||(t&&t.vault?t.vault:ai())}import{useMemo as li}from"react";function O(e={},t=[]){let{id:n,selector:o}=e,s=j(),a=M(),r=n||s.manifest,i=k(l=>r?l.iiif.entities.Manifest[r]:void 0,[r]);return li(()=>{if(i)return o?o(i):i},[i,o,...t])}import{useContext as Vi}from"react";import{createContext as Ni,useMemo as Li}from"react";import{useEffect as ui,useMemo as ci,useState as Ct}from"react";function vn(e,{noCache:t=!1}={}){let n=typeof e=="string"?e:e.id,o=ve(),[s,a]=Ct(n),[r,i]=Ct(void 0),l=ci(()=>o.get(n,{skipSelfReturn:!0})||void 0,[n,o]),[u,d]=Ct(l);return ui(()=>{(async()=>{try{let c=l&&!t?l:await o.load(n),m=c?c.id||c["@id"]:null;c&&s!==m&&a(m),d(c)}catch(c){i(c)}})()},[n,t]),{isLoaded:!!u,id:s,requestId:n,error:r,resource:u,cached:!!(u&&u===l)}}function Sn(e,t){let{id:n,isLoaded:o,error:s,resource:a,requestId:r,cached:i}=vn(e,t);return{id:n,isLoaded:o,error:s,manifest:a,requestId:r,cached:i}}import{jsx as di}from"react/jsx-runtime";function xn({manifest:e,children:t}){return di(ae,{value:{manifest:e},children:t})}import{jsx as mi}from"react/jsx-runtime";function bn({range:e,children:t}){return mi(ae,{value:{range:e},children:t})}function pi(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=pi(e,e.get(n));if(o)return o}}return null}function Rt(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(...Rt(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 uc(e,t,n){for(let o of t.structures){let s=Cn(e,e.get(o),n);if(s)return s}return null}function Cn(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 a=Cn(e,e.get(o),n);if(a)return a}}return null}function mc(e,t,n,o=!1){let s=t.behavior,a=n?e.get(n):null;if(!a)return[];let r=a.behavior,i=o?!1:s.includes("paged"),l=i?!1:s.includes("continuous"),u=i||l?!1:s.includes("individuals"),d=r.includes("facing-pages"),c=r.includes("non-paged");if(d||c||u||o)return[{id:a.id,type:"Canvas"}];let[m,p]=At(e,t);if(l)return m;let g=m.findIndex(h=>h.id===n);if(g===-1)return[];for(let h of p)if(h.includes(g))return h.map(S=>m[S]);return[{id:a.id,type:"Canvas"}]}function At(e,t,{disablePaging:n,skipNonPaged:o}={}){let s=t.behavior,a=s.includes("paged"),r=a?!1:s.includes("continuous"),i=a||r?!1:s.includes("individuals"),l=t.type==="Manifest"?t.items:Rt(e,t);if(r)return[l,[l.map((g,h)=>h)]];if(i||!a||n)return[l,l.map((g,h)=>[h])];let u=[],d=[],c=()=>{d.length&&(u.push([...d]),d=[])},m=0,p=!1;for(let g=0;g<l.length;g++){let h=e.get(l[g]);if(h.behavior.includes("non-paged")){g===m&&m++,o||(c(),u.push([g]),c());continue}if(g===m||h.behavior.includes("facing-pages")){d.length&&(p=!0),c(),u.push([g]),c();continue}if(d.push(g),p){c(),p=!1;continue}d.length>1&&c()}return d.length&&c(),[l,u]}import{useCallback as Ke,useMemo as gi,useRef as hi,useState as yi}from"react";import{useMemo as fi}from"react";function Rn(e={},t=[]){let{id:n,selector:o}=e,s=j(),a=n||s.range,r=k(i=>a?i.iiif.entities.Range[a]:void 0,[a]);return fi(()=>{if(r)return o?o(r):r},[r,o,...t])}function An({startCanvas:e,disablePaging:t}){let n=M(),o=O(),s=Rn(),[a,r]=yi(void 0),i=s||o;if(!i)throw new Error("Nothing selected");let[l,u]=gi(()=>At(n,i,{disablePaging:t}),[n,i,t]),d=hi(u);if(d.current!==u){let S=d.current[a][0],v=u.findIndex(f=>f.includes(S));d.current=u,r(v)}let c=Ke(h=>{let S=u.findIndex(v=>v.includes(h));r(S===-1?0:S)},[l,u]),m=Ke(h=>{let S=l.findIndex(v=>v.id===h);S!==-1?c(S):r(0)},[l,u]),p=Ke(()=>{r(h=>h>=u.length-1?h:h+1)},[u]),g=Ke(()=>{r(h=>h<=0?0:h-1)},[u]);return typeof a>"u"&&(e?m(e):r(0)),{visibleItems:u[a]?.map(h=>l[h].id)||[],cursor:a,items:l,sequence:u,hasPrevious:a>0,hasNext:a<u.length-1,setSequenceIndex:r,setCanvasIndex:c,setCanvasId:m,next:p,previous:g}}import{createContext as Tt,useContext as zn,useEffect as Si,useMemo as xi}from"react";import{useStore as Ve}from"zustand";import{createStore as wn}from"zustand/vanilla";function Pc(e){let t=e.service||e.services||[];for(let n of t)if(n.type==="AuthProbeService2")return!0;return!1}function K(e,t,n){let o=t.findIndex(r=>r.service.id===e);if(o===-1)return t;let s=[...t],a=n(s[o]);return a===s[o]?t:(s[o]=a,s)}var Tn=()=>wn((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:K(n.id,t().authItems,s=>({...s,isPending:!0}))})),Pn(n.service).then(()=>{Pt(o).then(s=>{let a=s.expiresIn,r=Date.now()+a*1e3;e(()=>({authItems:K(n.id,t().authItems,i=>({...i,isLoggedIn:!0,isPending:!1,session:{token:s.accessToken,expires:r}}))}))}).catch(s=>{e(()=>({authItems:K(n.id,t().authItems,a=>({...a,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=${kn()}`,a=window.open(s);e(()=>({authItems:K(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(i=>i.type==="AuthAccessTokenService2"),a=n;if(t().authItems.find(i=>i.service.id===n.id)){e(()=>({authItems:K(n.id,t().authItems,i=>({...i,instances:i.instances+1}))}));return}if(e(()=>({currentAuth:a.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");Pt(s).then(i=>{e(()=>({authItems:K(n.id,t().authItems,l=>({...l,isLoggedIn:!0,isPending:!1,session:{token:i.accessToken,expires:i.expiresIn}}))}))}).catch(i=>{e(()=>({authItems:K(n.id,t().authItems,l=>({...l,isLoggedIn:!1,isPending:!1,canAuthenticate:!1,error:i.message}))}))})}if(n.profile==="kiosk"){if(!s)throw new Error("Token service not found");e(()=>({authItems:K(n.id,t().authItems,i=>({...i,isPending:!0}))})),Pn(a).then(()=>{Pt(s).then(i=>{e(()=>({authItems:K(n.id,t().authItems,l=>({...l,isLoggedIn:!0,isPending:!1,session:{token:i.accessToken,expires:i.expiresIn}}))}))}).catch(i=>{e(()=>({authItems:K(n.id,t().authItems,l=>({...l,isLoggedIn:!1,isPending:!1,error:i.message}))}))})})}n.profile},removeService:(n,o)=>{let s=t().currentAuth===t().authItems.findIndex(r=>r.service.id===n.id),a=t().currentAuth;if(s){let r=t().authItems.find(l=>l.service.id===n.id);r&&r.instances>1||(a=t().authItems.findIndex(u=>u.service.id!==n.id&&u.instances>0))}e(()=>({authItems:K(n.id,t().authItems,r=>({...r,instances:r.instances-1})),currentAuth:a}))}})),In=(e,t)=>wn((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 a=o().token;try{let r=await fetch(s,{headers:a?{Authorization:`Bearer ${o().token}`,Accept:"application/json"}:{Accept:"application/json"}}).then(i=>i.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 Mn(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(a=>a.type==="AuthAccessService2");s[0]&&(n.services.access=s[0])}return n}async function Pt(e,{strict:t=!0}={}){return new Promise((n,o)=>{let s=Math.random().toString(36).substring(7),a=`${e.id}?messageId=${s}&origin=${window.location.origin}`,r=u=>{let d=u.data;if(d.messageId===s){if(t&&d.type!=="AuthAccessToken2"){i(),o("Invalid response, expected type=AuthAccessToken2");return}if(!d.accessToken){i(),o("Invalid response, expected accessToken");return}i(),n(d)}},i=()=>window.removeEventListener("message",r),l=document.createElement("iframe");l.src=a,l.style.display="none",document.body.appendChild(l),window.addEventListener("message",r)})}function kn(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 Pn(e){let t=`${e.id}?origin=${kn()}`,n=window.open(t);if(!n)throw new Error("Failed to open window");return new Promise((o,s)=>{let a=setInterval(()=>{n.closed&&(clearInterval(a),o())},500)})}import{useEffect as En,useMemo as Vn}from"react";import{useStore as vi}from"zustand";function Nn(e){let t=Vn(()=>Mn(e),[e]),n=Ln(t.services.access?.id),o=Vn(()=>In(t.services.probe,n),[t.services.probe]),s=vi(o);return En(()=>{s.status==="unknown"&&!n&&s.probe()},[t.services.probe,s.status]),En(()=>{n&&(s.setToken(n),s.probe())},[n]),[e,s,t.hasAuth]}import{jsx as Ye}from"react/jsx-runtime";var Se=Tt(null),bi=Tt(null);bi.displayName="CurrentAuth";var Ci=Tt(null);Ci.displayName="AuthActions";function On({children:e}){let t=xi(()=>Tn(),[]);return Ye(Se.Provider,{value:t,children:e})}function Bn(){return!!zn(Se)}function Ne(){let e=zn(Se);if(!e)throw new Error("useAuthActions must be used within a AuthProvider");return e}function Ri(){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 Wc(){let e=Ne();return Ve(e,t=>t)}function Ai(e){let t=Ne();return Ve(t,o=>o.authItems.find(s=>s.service.id===e))}function Ln(e){let t=Ne();return Ve(t,o=>o.authItems.find(s=>s.id===e)?.session?.token)}function Uc(e){let t=Ne();return Ve(t,o=>{let s=o.authItems.find(a=>a.service.id===e);return!s||!s.isLoggedIn||!s.session?null:s.session?.token||null})}function Pi(e){let t=Ri(),n=Ai(e.service.id);return Si(()=>(t?.addService(e.service,e.probeId),()=>{t?.removeService(e.service,e.probeId)}),[e.service]),n?(n.error||!n.isLoggedIn,e.children):null}function wt(){return null}function Hn(e){let[t,n,o]=Nn(e.resource),s=e.fallbackComponent||wt,a=e.loadingComponent||wt,r=e.errorComponent||wt,i=n.service,l=null;if(!o||!i)return e.children(t);let u=i.service.filter(d=>d.type==="AuthAccessService2");n.status==="error"&&(l=Ye(r,{resource:e.resource,error:n.error||"",heading:n.errorHeading,note:n.errorNote,extra:e.extra})),(n.status==="unknown"||n.status==="probing")&&(l=Ye(a,{})),n.status==="success"&&(l=e.children(t));for(let d of u)l=Ye(Pi,{service:d,probeId:i.id,children:l},d.id);return l}import{createContext as Mi,useContext as Jc,useMemo as ki}from"react";import{createStore as wi}from"zustand/vanilla";var Ti=e=>e.id||e["@id"];function Ii(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 Dn=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?Ti(t):void 0,o=null;return wi((s,a)=>({service:t,resources:[],lastQuery:{},loading:!1,error:!1,highlight:null,hasSearch:!!t,hasAutocomplete:t?!!Ii(t):!1,errorMessage:"",search(r,i={}){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",...i.headers||{}}}).then(async u=>{if(!o?.signal.aborted)if(u.ok){let d=await u.json();s({resources:d.resources,error:!1,errorMessage:""})}else s({resources:[],error:!0,errorMessage:u.statusText})})},clearSearch(){s({resources:[],error:!1,errorMessage:""})},highlightResult(r){let i=a().resources.find(l=>l["@id"]===r);s({highlight:i})},nextResult(){let r=a().resources,i=a().highlight;if(!i){s({highlight:r[0]||null});return}let l=r.findIndex(u=>u["@id"]===i["@id"]);if(l===-1){s({highlight:r[0]||null});return}s({highlight:r[l+1]||r[0]||null})},previousResult(){let r=a().resources,i=a().highlight;if(!i){s({highlight:r[r.length-1]||null});return}let l=r.findIndex(u=>u["@id"]===i["@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 rd}from"zustand";function Fn(){let e=O();return e?e.service.find(t=>t.profile==="SearchService1"||t.profile==="http://iiif.io/api/search/1/search"):void 0}import{jsx as It}from"react/jsx-runtime";var xe=Mi(null);xe.displayName="Search";function qn(e){let t=Fn();return e.store?It(xe.Provider,{value:e.store,children:e.children}):It(Ei,{service:t,children:e.children})}function Ei({service:e,children:t}){let n=ki(()=>Dn(e),[e]);return It(xe.Provider,{value:n,children:t})}import{jsx as W}from"react/jsx-runtime";var Le=()=>{},ze=Ni({setCurrentCanvasId:Le,setCurrentCanvasIndex:Le,nextCanvas:Le,previousCanvas:Le,items:[],sequence:[],setSequenceIndex:Le,currentSequenceIndex:0,hasNext:!1,hasPrevious:!1});function zi(e){let t=O(),{cursor:n,visibleItems:o,next:s,sequence:a,items:r,setCanvasIndex:i,setCanvasId:l,previous:u,setSequenceIndex:d,hasNext:c,hasPrevious:m}=An({startCanvas:e.startCanvas,disablePaging:e.pagingEnabled===!1}),p=Li(()=>({sequence:a,items:r,setCurrentCanvasId:l,nextCanvas:s,previousCanvas:u,totalCanvases:r.length,setCurrentCanvasIndex:i,setSequenceIndex:d,currentSequenceIndex:n,hasNext:c,hasPrevious:m}),[a,r,l,s,u,r,i,d,n]);return t?o.length===0?null:W(ze.Provider,{value:p,children:W(ye.Provider,{value:o,children:W(ne,{canvas:o[0],children:e.children})})}):(console.warn("The manifest passed to the provider is not a valid IIIF manifest."),W("div",{children:"Sorry, something went wrong."}))}function $n(e){let t=ve(e.vault),n=Sn(e.manifest);if(!n)return console.warn("The manifest passed to the provider is not a valid IIIF manifest."),W("div",{children:"Sorry, something went wrong."});if(n.error)return W("div",{children:n.error.toString()});if(!n.isLoaded)return W("div",{children:"Loading..."});let o=W(zi,{...e,children:e.children});return W(he,{vault:t,children:W(xn,{manifest:n.id,children:W(On,{children:W(qn,{children:e.rangeId?W(bn,{range:e.rangeId,children:o}):o})})})})}function Ge(){return Vi(ze)}import{ModeContext as _i}from"@atlas-viewer/atlas";import{createContext as ji,useContext as Gn,useEffect as Ki,useMemo as Yi}from"react";import{useStore as Gi}from"zustand";import Oi from"mitt";import{createContext as Bi,useContext as Wn,useEffect as Hi}from"react";import{jsx as Fi}from"react/jsx-runtime";var Di=Oi(),Mt=Bi(Di);function Vd({children:e,emitter:t}){return Fi(Mt.Provider,{value:t,children:e})}function Un(){return Wn(Mt)}function _n(e,t,n=[]){let o=Wn(Mt);Hi(()=>{let s=a=>{t(a)};return o.on(e,s),()=>{o.off(e,s)}},[o,e,...n])}import{createHelper as $i}from"polygon-editor";import{createStore as Wi}from"zustand/vanilla";function kt(e){let t=Math.max(...e.map(a=>a[0])),n=Math.min(...e.map(a=>a[0])),o=Math.max(...e.map(a=>a[1])),s=Math.min(...e.map(a=>a[1]));for(let a of e)if(a[0]!==n&&a[0]!==t&&a[1]!==s&&a[1]!==o||a[0]<n||a[0]>t||a[1]<s||a[1]>o)return!1;return!0}function be(e){if(!e)return null;if(e.points.length>2){let t=Math.min(...e.points.map(a=>a[0])),n=Math.min(...e.points.map(a=>a[1])),o=Math.max(0,...e.points.map(a=>a[0])),s=Math.max(0,...e.points.map(a=>a[1]));return{x:t,y:n,width:o-t,height:s-n}}return null}function qi(e){return e.type==="SvgSelector"}function Bd(e){return e.type==="BoxSelector"}function Et(e,t){if(qi(e)){let r=e.svgShape==="polyline";if(!e.points||e.points.length===0)return null;if(t){let{width:i,height:l}=t;return{type:"SvgSelector",value:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${i} ${l}" width="${i}" height="${l}"><${r?"polygon":"polyline"} points="${e.points.map(d=>d.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(i=>i.join(",")).join(" ")}${r?" Z":""}' /></g></svg>`}}if(!e.spatial)return null;let{x:n,y:o,width:s,height:a}=e.spatial||{};return!s||!a?null:{type:"FragmentSelector",value:`xywh=${~~n},${~~o},${~~s},${~~a}`}}function Vt(e,t){if(!e||!e.points.length)return null;if(kt(e.points)){let n=e.points.map(l=>l[0]),o=e.points.map(l=>l[1]),s=Math.min(...n),a=Math.min(...o),r=Math.max(...n)-s,i=Math.max(...o)-a;return Et({type:"BoxSelector",spatial:{x:s,y:a,width:r,height:i}},t)}return Et({type:"SvgSelector",points:e.points,svgShape:e.open?"polygon":"polyline"},t)}function jn(e){if(e.type==="polygon"&&!e.noBox&&e.points&&kt(e.points)){let n=be({open:!1,points:e.points||[]});return jn({...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:be({points:e.points||[],open:!1}),metadata:{},arguments:e.arguments||{},target:Vt({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:Vt({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 Ui={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 Kn({events:e,enabledTools:t,keyboardShortcutMapping:n,keyboardShortcutsEnabled:o=!1,debug:s}){let a=Wi((i,l)=>{let u=null,c=$i({emitter:e,keyboardShortcutsEnabled:o,keyboardShortcutMapping:n,enabledTools:t,customSetState:m=>{s&&console.log("partial state",m),i(p=>({polygonState:{...p.polygonState,...m}}))}},m=>{i(p=>p.tool.requestId?{polygon:{...m,id:p.tool.requestId}}:{polygon:{id:void 0,points:[],open:!0}}),e.emit("atlas.polygon-update",m)});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:Ui,setMetadata:(m,p)=>{let g=p||l().tool.requestId;g&&i(h=>({metadata:{...h.metadata,[g]:{...h.metadata[g]||{},...m}}}))},setToolCanvasId:m=>{i(p=>({tool:{...p.tool,canvasId:m}}))},switchTool:{pointer(){i({mode:"sketch"}),r.tools.setTool("pointer")},hand(){i({mode:"explore"}),r.tools.setTool("hand")},draw(){i({mode:"sketch"}),r.tools.setTool("pencil")},pen(){i({mode:"sketch"}),r.tools.setTool("pen")},line(){i({mode:"sketch"}),r.tools.setTool("line")},lineBox(){i({mode:"sketch"}),r.tools.setTool("lineBox")},box(){i({mode:"sketch"}),r.tools.setTool("box")},triangle(){i({mode:"sketch"}),r.tools.setTool("stamp"),r.stamps.triangle()},hexagon(){i({mode:"sketch"}),r.tools.setTool("stamp"),r.stamps.hexagon()},circle(){i({mode:"sketch"}),r.tools.setTool("stamp"),r.stamps.circle()},remove(){let m=l();m.tool.requestId&&(c.setShape({points:[],open:!0}),m.cancelRequest(m.tool.requestId))}},reset:()=>{let m=l();m.tool.requestId&&m.cancelRequest(m.tool.requestId)},setPolygonState:m=>i({polygonState:typeof m=="function"?m(l().polygonState):m}),getRequestId:()=>{let m=Math.random().toString(36).slice(2);return i(p=>({validRequestIds:[...p.validRequestIds,m]})),{requestId:m,clear:()=>{l().tool.requestId,i(p=>({tool:p.tool.requestId===m?{enabled:!1,requestId:null,canvasId:null}:p.tool,validRequestIds:p.validRequestIds.filter(g=>g!==m)}))}}},cancelRequest:m=>{let p=m||l().tool.requestId;p&&(i(g=>({mode:"explore",tool:g.tool.requestId===p?{enabled:!1,requestId:null,canvasId:null}:g.tool,validRequestIds:g.validRequestIds.filter(h=>h!==p)})),e.emit("atlas.request-cancelled",{id:p}))},requestAnnotation:async(m,p)=>{let h={...l().requests,[p.requestId]:m},S=jn(m);s&&console.log("requestAnnotation",{response:S,request:m});try{let{points:v=[],open:f=!0}=S.polygon||{},{requestId:y,canvasId:x=null,toolId:b}=p,C=b,R=l(),A=R.validRequestIds.includes(y),N=S.requestType;return s&&console.log("setting points",{requestType:N,points:v,open:f}),!A||R.tool.enabled?null:(c.setShape({id:y,points:v,open:f}),N==="polygon"&&(C=C||"pen",c.tools.setTool("pen")),N==="draw"&&(C=C||"draw",c.tools.setTool("pencil")),N==="box"&&(C=C||"box",c.tools.setTool("box")),N==="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)),m.bounds&&c.setBounds(m.bounds),e.emit("atlas.annotation-request",{id:y}),i({polygon:{id:y,points:v,open:f},mode:"sketch",requestType:N,tool:{enabled:!0,requestId:y,canvasId:x},requests:h}),C?R.switchTool[C]?.():v.length===0&&R.switchTool.box(),(typeof m.selectByDefault>"u"&&v.length&&N==="box"||m.selectByDefault)&&R.switchTool.pointer(),new Promise(X=>{let T=_=>{_.id===y&&(i(P=>({mode:"explore",tool:{requestId:null,enabled:!1,canvasId:null},requests:Object.fromEntries(Object.entries(P.requests).filter(([I])=>I!==y))})),e.off("atlas.request-cancelled",T),e.off("atlas.annotation-completed",z),X(null))},z=_=>{_.id===y&&(i(P=>({mode:"explore",tool:{requestId:null,enabled:!1,canvasId:null},requests:Object.fromEntries(Object.entries(P.requests).filter(([I])=>I!==y))})),e.off("atlas.annotation-completed",z),e.off("atlas.request-cancelled",T),X(_))};e.on("atlas.request-cancelled",T),e.on("atlas.annotation-completed",z)}))}catch(v){return console.error(v),null}},completeRequest:m=>{let p=l().tool.requestId;if(typeof m=="string"&&m&&m!==p)return;let g=p?l().requests[p]?.arguments||{}:{},h=p?l().metadata[p]||{}:{},S=l().polygonState.bounds,v=l().polygon;v&&(e.emit("atlas.annotation-completed",{id:v.id,polygon:v,requestType:l().requestType,target:Vt(v,S),canvasId:l().tool.canvasId,boundingBox:be(v),metadata:h,arguments:{...g}}),c.setShape(null))},setAtlasRuntime:m=>{u=m,e.emit("atlas.ready",{runtime:m}),r.setScale(1/u._lastGoodScale),u.world.addLayoutSubscriber((p,g)=>{(p==="event-activation"||p==="zoom-to"||p==="go-home")&&u?._lastGoodScale&&!Number.isNaN(u._lastGoodScale)&&r.setScale(1/u._lastGoodScale)}),i({runtime:u})},clearAtlasRuntime:()=>{u=null,i({stableViewport:null,runtime:null})},setCanvasRelativePosition:(m,p)=>{i(g=>({canvasRelativePositions:{...g.canvasRelativePositions,[m]:p}}))},clearCanvasRelativePosition:m=>{i(p=>{let g={...p.canvasRelativePositions};return delete g[m],{canvasRelativePositions:g}})},changeMode:m=>{i({mode:m})},nudgeLeft:m=>{if(!u)return;let p=u.getViewport(),g=m??p.width*.1;u.world.gotoRegion({x:p.x-g,y:p.y,width:p.width,height:p.height,nudge:!0})},nudgeRight:m=>{if(!u)return;let p=u.getViewport(),g=m??p.width*.1;u.world.gotoRegion({x:p.x+g,y:p.y,width:p.width,height:p.height,nudge:!0})},nudgeUp:m=>{if(!u)return;let p=u.getViewport(),g=m??p.height*.1;u.world.gotoRegion({x:p.x,y:p.y-g,width:p.width,height:p.height,nudge:!0})},nudgeDown:m=>{if(!u)return;let p=u.getViewport(),g=m??p.height*.1;u.world.gotoRegion({x:p.x,y:p.y+g,width:p.width,height:p.height,nudge:!0})},zoomIn:()=>{u?.world?.zoomIn()},zoomOut:()=>{u?.world?.zoomOut()},goHome:()=>{u?.world?.goHome()},goToRegion:m=>{u?.world?.gotoRegion(m)},getRuntime:()=>u}}),r=a.getState().polygons;return e.on("atlas.annotation-request",()=>{r.clock.start((i,l,u)=>{e.emit("atlas.polygon-render",{state:i,slowState:l,dt:u})},i=>{typeof i=="object"?a.setState({polygonState:i}):a.setState(l=>({polygonState:i(l.polygonState)}))})}),e.on("atlas.annotation-completed",()=>{r.clock.stop()}),e.on("atlas.request-cancelled",()=>{r.clock.stop()}),a}import{jsx as Yn}from"react/jsx-runtime";var Ce=ji(null);function D(){return Gn(Ce)}var Nt={};function Qn(e="atlas"){return Nt[e]?.getState()}function Oe({children:e,name:t="atlas",existing:n,atlasStoreConfig:o}){let s=Un(),a=Gn(Ce),r=Yi(()=>n||a||Kn({events:s,...o||{}}),[s,n,a]),i=Gi(r,l=>l.mode);return Ki(()=>{let l=t;return l&&(Nt[l]=r),()=>{l&&delete Nt[l]}},[r,t]),Yn(Ce.Provider,{value:r,children:Yn(_i.Provider,{value:i||"explore",children:e})})}import{mergeStyles as Ze}from"@atlas-viewer/atlas";import{useMemo as fa}from"react";import{createContext as Qi,useContext as Xi,useMemo as Zi}from"react";import{jsx as Ji}from"react/jsx-runtime";function Xn(){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 Lt=Qi(Xn());Lt.displayName="AnnotationStyle";function Zn(){return Xi(Lt)}function em({theme:e,children:t}){let n=Zi(()=>e||Xn(),[e]);return Ji(Lt.Provider,{value:n,children:t})}import{expandTarget as ia}from"@iiif/helpers/annotation-targets";import{useMemo as aa}from"react";import{useEffect as ea,useMemo as ta,useState as na}from"react";import{create as oa}from"zustand";var ra=oa()((e,t)=>{let n=new Map,o=()=>Math.random().toString(36).substring(2,15),s=a=>{let r=n.get(a);if(r)return r;let i=o();return n.set(a,i),i};return{stylesheets:{},loading:[],errors:[],async parseStylesheet(a){let{loadStylesheet:r,setStylesheet:i}=t();if(!a)return null;if(typeof a=="string")return a.startsWith("http")?{id:a,type:"CssStylesheet",value:await r(a)}:{id:i(a),type:"CssStylesheet",value:a};if(a.type==="CssStylesheet"){let l=a.id;if("value"in a){let u=Array.isArray(a.value)?a.value.join(`
2
- `):a.value;if(u)return{id:i(u,l),type:"CssStylesheet",value:u}}if("id"in a&&a.id){let u=await r(a.id);return{id:a.id,type:"CssStylesheet",value:u}}}return null},async loadStylesheet(a){if(t().loading.includes(a))return"";try{let i=await fetch(a);if(!i.ok)throw new Error(`Failed to load stylesheet from ${a}`);let l=await i.text();return e(u=>({stylesheets:{...u.stylesheets,[a]:l}})),l}catch(i){return e(l=>({errors:[...l.errors,{url:a,error:i}]})),""}},setStylesheet(a,r){let i=r||s(a);return e(l=>({stylesheets:{...l.stylesheets,[i]:a}})),i}}});function Jn(e){let[t,n]=na(""),{loading:o,errors:s,stylesheets:a,parseStylesheet:r}=ra();return ea(()=>{e&&r(e).then(l=>{l?.id&&n(l.id)})},[e,r]),[ta(()=>{let l={};return t&&a[t]&&(l[t]=a[t]),l},[t,a]),{id:t,stylesheets:a,loading:o,errors:s}]}function Qe(e={},t=[]){let{id:n,selector:o}=e,s=j(),a=M(),r=n||s.annotation,i=k(d=>r?d.iiif.entities.Annotation[r]:void 0,[r]),[l]=Jn(i?.stylesheet),u=k(d=>i&&i.body?i.body.map(c=>c?c.type==="SpecificResource"?{...c,source:a.get(c)}:c?d.iiif.entities[c.type][c.id]:null:null).filter(Boolean):[],[i]);return aa(()=>{if(!i)return;let d={...i,body:u,target:ia(i.target,{typeMap:a.getState().iiif.mapping,loadedStylesheets:l})};return o?o(d):d},[i,o,u,l,...t])}import{useMemo as sa}from"react";function w(e={},t=[]){let{id:n,selector:o}=e,s=j(),a=n||s.canvas,r=k(i=>a?i.iiif.entities.Canvas[a]:void 0,[a]);return sa(()=>{if(r)return o?o(r):r},[r,o,...t])}import{useMemo as eo}from"react";import{createEventsHelper as la}from"@iiif/helpers/events";function Xe(e,t){let n=M(),o=eo(()=>la(n),[n]),s=k(()=>e&&e.id?n.getResourceMeta(e.id,"eventManager"):null,[e]);return eo(()=>e?o.getListenersAsProps(e,t):{},[s,e,n,t])}import{useMemo as ua}from"react";import{createStylesHelper as ca}from"@iiif/helpers/styles";function Re(e,t){let n=M(),o=ua(()=>ca(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 pa}from"react";import{HTMLPortal as da,useResizeWorldItem as ma}from"@atlas-viewer/atlas";import{useMemo as oe}from"react";import{Fragment as zt,jsx as Y,jsxs as Ot}from"react/jsx-runtime";function to({handleSize:e,resizable:t,onSave:n,children:o,maintainAspectRatio:s,disableCardinalControls:a,aspectRatio:r,...i}){let l=typeof e>"u"?s?12:8:e,{portalRef:u,mode:d,mouseEvent:c,isEditing:m}=ma({x:i.x||0,y:i.y||0,width:i.width,height:i.height,aspectRatio:r,maintainAspectRatio:s},n),p=oe(()=>c("translate"),[c]),g=oe(()=>c("east"),[c]),h=oe(()=>c("west"),[c]),S=oe(()=>c("south"),[c]),v=oe(()=>c("north"),[c]),f=oe(()=>c("south-east"),[c]),y=oe(()=>c("south-west"),[c]),x=oe(()=>c("north-east"),[c]),b=oe(()=>c("north-west"),[c]),C=d==="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||a?"50%":2,position:"absolute",background:"#fff",pointerEvents:m?"none":C?"initial":"none"};return Y(zt,{children:Ot("world-object",{...i,children:[o,C&&t?Y(da,{ref:u,target:{x:0,y:0,height:i.height,width:i.width},relative:!0,interactive:!1,children:C&&t?Ot(zt,{children:[Y("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:m?"none":C?"initial":"none"}}),s?null:Ot(zt,{children:[Y("div",{title:"east",onTouchStart:g,onMouseDown:g,style:{...R,cursor:"e-resize",height:l*2,width:l,right:0,top:"50%",opacity:a?0:1,transform:`translate(${l/2}px, -${l}px)`}}),Y("div",{title:"west",onMouseDown:h,style:{...R,cursor:"w-resize",position:"absolute",height:l*2,width:l,left:0,top:"50%",opacity:a?0:1,transform:`translate(-${l/2}px, -${l}px)`}}),Y("div",{title:"north",onMouseDown:v,style:{...R,cursor:"n-resize",position:"absolute",height:l,width:l*2,left:"50%",top:0,opacity:a?0:1,transform:`translate(-${l}px, -${l/2}px)`}}),Y("div",{title:"south",onMouseDown:S,style:{...R,cursor:"s-resize",position:"absolute",height:l,width:l*2,left:"50%",bottom:0,opacity:a?0:1,transform:`translate(-${l}px, ${l/2}px)`}})]}),Y("div",{title:"north-east",onMouseDown:x,style:{...R,cursor:"ne-resize",position:"absolute",height:l,width:l,right:0,top:0,transform:`translate(${l/2}px, -${l/2}px)`}}),Y("div",{title:"south-east",onMouseDown:f,style:{...R,cursor:"se-resize",position:"absolute",height:l,width:l,bottom:0,right:0,transform:`translate(${l/2}px, ${l/2}px)`}}),Y("div",{title:"south-west",onMouseDown:y,style:{...R,cursor:"sw-resize",position:"absolute",height:l,width:l,bottom:0,left:0,transform:`translate(-${l/2}px, ${l/2}px)`}}),Y("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 no}from"react/jsx-runtime";function oo({id:e,interactive:t,region:n,onClick:o,onHover:s,onSave:a,aspectRatio:r,maintainAspectRatio:i,disableCardinalControls:l,isEditing:u,style:d={backgroundColor:"rgba(0,0,0,.5)"}}){let c=pa(m=>{u&&a?.({id:n.id,x:n.x,y:n.y,height:n.height,width:n.width,...m})},[a,u,n.id,n.x,n.y,n.height,n.width]);return no(to,{id:e,x:n.x,y:n.y,width:n.width,aspectRatio:r,height:n.height,resizable:u,onSave:c,maintainAspectRatio:i,disableCardinalControls:l,children:no("box",{interactive:t,onClick:m=>{m.preventDefault(),m.stopPropagation(),o?.(n)},relativeStyle:!0,onMouseEnter:()=>{s?.(n)},target:{x:0,y:0,width:n.width,height:n.height},style:d})})}import{jsx as ga}from"react/jsx-runtime";var Ae=({id:e,style:t,className:n,interactive:o,targetId:s,ignoreTargetId:a})=>{let r=Qe({id:e}),i=Re(r,"atlas"),l=Re(r,"html"),u=Xe(r,["atlas"]),d=w(),c=Zn(),m=fa(()=>Ze(Ze(Ze(Ze(t,i),r?.motivation?.includes("highlighting")?c.highlighted:c.default),r?.target?.selector?.boxStyle||{})),[t,i,c,r?.motivation,r?.target]),p=s||d?.id;return d&&r&&r.target&&r.target.selector&&(r.target.selector.type==="BoxSelector"||r.target.selector.type==="SvgSelector")&&r.target.source&&(a?!0:r.target.source.id===p||r.target.source===p)?ga(oo,{id:r.id,isEditing:!0,region:r.target.selector.spatial,style:m,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 ya}from"react";import{useMemo as ha}from"react";function ro(e={},t=[]){let{id:n,selector:o}=e,s=j(),a=n||s.annotationPage,r=k(i=>a?i.iiif.entities.AnnotationPage[a]:void 0,[a]);return ha(()=>{if(r)return o?o(r):r},[r,...t])}import{jsx as io}from"react/jsx-runtime";var ce=({className:e,page:t,targetId:n,ignoreTargetId:o})=>{let s=ro({id:t.id})||t,a=Re(s,"atlas"),r=Re(s,"html");return k(i=>s.id?i.iiif.entities.AnnotationPage[s.id]:null,[]),io(ya,{children:s.items?.map(i=>io(Ae,{id:i.id,style:a,className:r?.className||e,targetId:n,ignoreTargetId:o},i.id))})};import{createContext as Ht,useContext as Dt}from"react";import{jsx as Bt}from"react/jsx-runtime";var ao=Ht(null),so=Ht(null),lo=Ht(null);function rp(){let e=Dt(ao);if(!e)throw new Error("Ctx not found");return e}function ip(){let e=Dt(so);if(!e)throw new Error("Ctx not found");return e}function ap(){let e=Dt(lo);if(!e)throw new Error("Ctx not found");return e}function Je({actions:e,state:t,children:n,currentTime:o,progress:s,element:a}){return Bt(lo.Provider,{value:{currentTime:o,progress:s,element:a},children:Bt(so.Provider,{value:e,children:Bt(ao.Provider,{value:t,children:n})})})}import{useMemo as va}from"react";import{expandTarget as Sa}from"@iiif/helpers";function et(){let e=O(),t=w();return va(()=>{if(!e||!t||!e.start)return null;let n=Sa(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 Z,useEffect as Ft,useReducer as xa,useRef as tt}from"react";function uo(e){return{isMuted:!1,playRequested:!1,isPlaying:!1,isFinished:!1,volume:100,duration:e}}function ba(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 qt(e){let t=Math.round(e);return`${Math.floor(t/60)}:${`${t%60}`.padStart(2,"0")}`}function Pe(e){let[t,n]=xa(ba,uo(e.duration));Ft(()=>{n({type:"RESET",state:uo(e.duration)})},[e.duration]);let o=tt(null),s=tt(null),a=tt(null),r=tt(!1),i=Z(()=>{s.current&&o.current&&(s.current.innerHTML=qt(o.current.currentTime),a.current&&(a.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=Z(()=>{o.current&&(n({type:"PLAY_REQUESTED"}),o.current.play().then(()=>{n({type:"PLAY"})}),i())},[i]),u=Z(()=>{o.current&&(o.current.duration>0&&o.current.paused?l():d())},[i]),d=Z(()=>{o.current&&(o.current.pause(),n({type:"PAUSE"}),i())},[i]),c=Z(()=>{o.current&&(o.current.muted=!o.current.muted,n(o.current.muted?{type:"MUTE"}:{type:"UNMUTE"}))},[]),m=Z(()=>{o.current&&(o.current.muted=!0,n({type:"MUTE"}))},[]),p=Z(()=>{o.current&&(o.current.muted=!1,n({type:"UNMUTE"}))},[]),g=Z(v=>{o.current&&(o.current.muted=!1,o.current.volume=v/100,n({type:"SET_VOLUME",volume:v}))},[]),h=Z(v=>{o.current&&(o.current.currentTime=Math.max(0,Math.min(v*e.duration,e.duration)),i())},[]),S=Z(v=>{if(o.current){let f=typeof v=="function"?v(o.current.currentTime):v;o.current.currentTime=Math.max(0,Math.min(f,e.duration)),i()}},[]);return Ft(()=>{let v=setInterval(()=>{i()},350);return()=>clearInterval(v)},[i,e.duration]),Ft(()=>{let v=()=>{n({type:"FINISHED"})},f=o.current;return f?.addEventListener("ended",v),()=>f?.removeEventListener("ended",v)},[]),[{element:o,currentTime:s,progress:a},t,{play:l,pause:d,playPause:u,mute:m,unmute:p,toggleMute:c,setVolume:g,setDurationPercent:h,setTime:S}]}import{createContext as co,useContext as Ca,useEffect as Ra}from"react";var $t=co(()=>{}),Wt=co(()=>{});function H(e,t,n,o,s=[]){let a=Ca(e==="portal"?Wt:$t);Ra(()=>(e!=="none"&&a(t,n,o),()=>{a(t,null)}),[t,e,a,...s])}import{jsx as Aa,jsxs as Pa}from"react/jsx-runtime";function Ut({media:e,startTime:t,children:n}){let[{element:o,currentTime:s,progress:a},r,i]=Pe({duration:e.duration}),l=t?`${e.url}#t=${t}`:e.url;return Pa(Je,{state:r,actions:i,currentTime:s,progress:a,element:o,children:[Aa("audio",{ref:o,src:l}),n]},e.url)}function nt({media:e,mediaControlsDeps:t,audioCopmonent:n=Ut,children:o}){let s=et();return H("portal","audio",n,{media:e,startTime:s?s.startTime:null,children:o},[e,s,...t||[]]),null}import{createContext as wa,useContext as Ta}from"react";var de=wa(null);de.displayName="Strategy";function E(){let e=Ta(de);if(!e)throw new Error("useStrategy must be used within a StrategyProvider");return e}import{Fragment as Ia,jsx as _t,jsxs as Ma}from"react/jsx-runtime";function jt({model:e}){return Ma(Ia,{children:[_t("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
- `}),_t("div",{className:"model-container",children:_t("model-viewer",{"interaction-prompt":"none",style:{width:"100%",height:"100%"},"camera-controls":"","ar-status":"not-presenting",src:e.id})})]})}function ot({model:e,name:t}){return H("overlay",`model-${t}`,jt,{model:e},[e]),null}import{jsx as ka}from"react/jsx-runtime";function mo(){let{strategy:e}=E();return e.type!=="3d-model"?null:ka(ot,{model:e.model})}import{createContext as Ea,useContext as Va}from"react";var rt=Ea(null);rt.displayName="Controls";function F(){let e=Va(rt);if(!e)throw new Error("useStrategy must be used within a StrategyProvider");return e}import{Fragment as Na,jsx as it,jsxs as La}from"react/jsx-runtime";function po(){let{strategy:e}=E(),{renderViewerControls:t,viewControlsDeps:n}=F(),o=w(),s=o?.accompanyingCanvas,a=o?.placeholderCanvas;return La(Na,{children:[e.type==="media"&&e.media.type==="Sound"&&s?it(ne,{canvas:s.id,children:it(me,{renderViewerControls:t,viewControlsDeps:n})}):null,e.type==="media"&&e.media.type==="Sound"&&a&&!s?it(ne,{canvas:a.id,children:it(me,{renderViewerControls:t,viewControlsDeps:n})}):null]})}import{createContext as Da,useContext as Fa,useMemo as qa}from"react";import{useCallback as go,useLayoutEffect as Oa,useMemo as Ba,useRef as Ha}from"react";import{entityActions as Kt}from"@iiif/helpers/vault/actions";import{useMemo as za}from"react";function fo(){let t=M().getStore();return za(()=>n=>t.dispatch(n),[t])}function ho(e){return typeof e!="string"&&e&&e.bindToVault}function yo(){let e=M(),t=Ha([]),n=fo(),o=Ba(()=>`vault://annotation-page/${new Date().getTime()}/${Math.round(Math.random()*1e9).toString(16)}`,[]);Oa(()=>{let i={id:o,type:"AnnotationPage",behavior:[],label:null,thumbnail:[],summary:null,requiredStatement:null,metadata:[],rights:null,provider:[],items:[],seeAlso:[],homepage:[],rendering:[],service:[]};n(Kt.importEntities({entities:{AnnotationPage:{[i.id]:i}}}))},[o]);let s=k(i=>o&&i.iiif.entities.AnnotationPage[o]||null,[o]),a=go((i,l)=>{if(o){if(ho(i)){let c=i;c.__vault||c.bindToVault(e),i=typeof c.source=="string"?c.source:c.source.id,t.current[i]=c}else typeof i!="string"&&(i=i.id);let u=e.get({id:o,type:"AnnotationPage"}),d=e.get({id:i,type:"Annotation"});u&&d&&(u.items.find(c=>c.id===d.id)||n(Kt.addReference({id:o,type:"AnnotationPage",key:"items",reference:{id:i,type:"Annotation"},index:l})))}},[o]),r=go(i=>{o&&(ho(i)?i=typeof i.source=="string"?i.source:i.source.id:typeof i!="string"&&(i=i.id),t.current[i]&&t.current[i].beforeRemove(),e.get({id:o,type:"AnnotationPage"})&&n(Kt.removeReference({id:o,type:"AnnotationPage",key:"items",reference:{id:i,type:"Annotation"}})))},[o]);return[s,{addAnnotation:a,removeAnnotation:r}]}import{jsx as $a}from"react/jsx-runtime";var vo=Da(null);function So(){let e=Fa(vo);return[e.fullPage,{addAnnotation:e.addAnnotation,removeAnnotation:e.removeAnnotation}]}function xo({children:e}){let[t,{addAnnotation:n,removeAnnotation:o}]=yo();return $a(vo.Provider,{value:qa(()=>({fullPage:t,addAnnotation:n,removeAnnotation:o}),[t]),children:e})}import{Fragment as Wa,jsx as bo,jsxs as Ua}from"react/jsx-runtime";function Co({children:e}){let{strategy:t}=E(),[n]=So();return t.type!=="images"?null:Ua(Wa,{children:[n?bo(ce,{page:n}):null,t.annotations&&t.annotations.pages?t.annotations.pages.map(o=>bo(ce,{page:o},o.id)):null,e]})}import{useEffect as Qa,useMemo as Xa,useRef as Za,useState as Ja}from"react";import{useEffect as _a}from"react";var Ro=(e,t=[])=>{let n=M();_a(()=>{e(n)},[n,...t])};import ja,{useContext as Ka}from"react";import{ImageServiceLoader as Ya}from"@iiif/helpers/image-service";var Ga=ja.createContext(new Ya);function Ao(){return Ka(Ga)}import{createThumbnailHelper as es}from"@iiif/helpers/thumbnail";import{getId as ts,imageServiceRequestToString as ns,parseImageServiceRequest as os}from"@iiif/parser/image-3";function rs(e,t){try{let n=ts(e);if(!n)return;let o=os(n),s=o.type==="image"?o.region.w:void 0,a=o.type==="image"?o.region.h:void 0,r=s||e.width,i=a||e.height,l=t.width||t.maxWidth,u=t.height||t.maxHeight;if(o.type!=="image"||o.region.full||o.region.square)return;(l||u)&&(o.size={max:!1,upscaled:!1,confined:!!(l&&u),width:l,height:u,version:3});let d=r&&i&&(l||u)?Math.min(l?l/r:1/0,u?u/i:1/0):void 0;return{id:ns(o),type:"fixed",width:r&&d?Math.round(r*d):l||r||e.width||0,height:i&&d?Math.round(i*d):u||i||e.height||0}}catch{return}}function we(e,t,{canvasId:n,manifestId:o}={}){let s=M(),a=Ao(),r=Xa(()=>es(s,{imageServiceLoader:a}),[s,a]),[i,l]=Ja(),u=O(o?{id:o}:void 0),d=w(n?{id:n}:void 0),c=d||u,m=Za(!1);if(Qa(()=>(m.current=!1,()=>{m.current=!0}),[]),!c)throw new Error("Must be called under a manifest or canvas context.");return Ro(p=>{if(c.type==="Canvas"&&c.thumbnail?.length){let g=rs(p.get(c.thumbnail[0]),e);if(g&&!m.current){l(g);return}}r.getBestThumbnailAtSize(c,e,t).then(g=>{g.best&&!m.current&&l(g.best)})},[c,e.width,e.height,e.maxWidth,e.maxHeight,e.minWidth,e.minHeight,e.allowUnsafe,e.unsafeImageService,e.preferFixedSize,t]),i}import{jsx as Po}from"react/jsx-runtime";function Te({x:e=0,y:t=0}){let n=w(),o=we({maxWidth:256,maxHeight:256});return!n||!o||o.type!=="fixed"?null:Po("world-object",{height:n.height,width:n.width,x:e,y:t,children:Po("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 is,jsxs as as}from"react/jsx-runtime";function wo({as:e}){let{strategy:t}=E(),{renderMediaControls:n,mediaControlsDeps:o}=F();return t.type!=="media"||t.media.type!=="Sound"?null:as(nt,{media:t.media,mediaControlsDeps:o,audioCopmonent:e,children:[is(Te,{}),n?n(t):null]},t.media.url)}import{HTMLPortal as Ko}from"@atlas-viewer/atlas";import{useLayoutEffect as Ts,useMemo as Is}from"react";import{useStore as Yo}from"zustand";import{createContext as ss,useContext as ls}from"react";import{useStore as us}from"zustand";import{jsx as cs}from"react/jsx-runtime";var Yt=ss(null);Yt.displayName="ComplexTimeline";function To({children:e,store:t}){return cs(Yt.Provider,{value:t,children:e})}function Hf(e){let t=ls(Yt);if(!t)throw new Error("useComplexTimeline must be used within a ComplexTimelineProvider");return us(t,e)}import ds from"mitt";import{createStore as ms}from"zustand/vanilla";function Io({currentKeyFrameIndex:e,keyframes:t,targetTime:n,currentTime:o}){if(o<=n){let s=t.findIndex(i=>i.time>n);if(s===-1)return[e,[]];let a={},r=t.slice(e,s);for(let i of r)i.type==="enter"&&(a[i.id]=i),i.type==="exit"&&(a[i.id]?delete a[i.id]:a[i.id]=i);return[s,Object.values(a)]}return[e,[]]}function Mo({complexTimeline:e,startTime:t=0}){let n=ds(),o={},s={progress:null,currentTime:null},a=0,r=null,i=0,l=null;function u(){let f=S.getState().visibleElements,y=o,x=[],b=Object.keys(y);for(let C of b){let R=y[C],A=f[C];R&&A&&x.push(R)}return x}function d(){return Object.keys(o).map(f=>o[f])}function c(v){s.currentTime&&(s.currentTime.innerHTML=qt(v),s.progress&&(s.progress.style.width=`${v/e.duration*100}%`))}let m=()=>{let v=S.getState(),f=v.currentPrime;if(!f)return;let y=o,x=v.visibleElements,b=Object.keys(y);for(let C of b){let R=y[C],A=x[C];if(R&&C!==f.id&&A){let N=i-A.time*1e3;Math.abs(i-A.time*1e3-R.currentTime*1e3)>300&&(R.currentTime=N/1e3)}}},p=(v=0)=>{let f=v-a,y=S.getState();if(y.isPlaying){let x=y.currentPrime;if(x){let A=o[x.id];A&&(A.paused?i+=f:i=(x.time+A.currentTime)*1e3)}else i+=f;let b=i/1e3;if(b>y.duration){S.getState().setTime(0),S.setState({isPlaying:!1}),g(),c(0);return}c(b);let[C,R]=Io({currentTime:b,currentKeyFrameIndex:y.nextKeyframeIndex,keyframes:y.complexTimeline.keyframes,targetTime:b});R.length&&y.applyKeyframes(C,R)}a=v,r=requestAnimationFrame(p)},g=()=>{r&&cancelAnimationFrame(r)},h=(v,f)=>{},S=ms((v,f)=>({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:()=>{f().clockRunning||(p(),l=setInterval(m,500)),v({clockRunning:!0,clockStartRequests:f().clockStartRequests+1})},applyKeyframes(y,x){let b=f(),C={...b.visibleElements},R=b.currentPrime;for(let A of x)A.type==="enter"&&(C[A.id]=A,n.emit("complex-timeline.enter",{id:A.id})),A.type==="exit"&&(C[A.id]=null,n.emit("complex-timeline.exit",{id:A.id})),A.isPrime&&(R=A);v({nextKeyframeIndex:y,visibleElements:C,currentPrime:R})},stopClock:()=>{let y=f().clockStartRequests;if(y!==0){if(y===1){g(),l&&clearInterval(l),v({clockRunning:!1,clockStartRequests:0});return}v({clockStartRequests:y-1})}},setElement:(y,x)=>{o[y]=x;let b=Object.keys(o),C=f().complexTimeline;h(x,y),C.items.filter(A=>A.type!=="Image"&&A.type!=="Text").every(A=>b.includes(A.annotationId))&&!f().isReady&&(n.emit("complex-timeline.ready",{complexTimeline:C}),v({isReady:!0}))},removeElement:y=>{delete o[y]},mute(){for(let y of d())y.muted=!0;v({isMuted:!0})},unmute(){for(let y of d())y.muted=!1;v({isMuted:!1})},play(){if(!f().isPlaying){for(let x of u())x.play();v({isPlaying:!0})}},pause(){if(f().isPlaying){for(let x of u())x.pause();v({isPlaying:!1})}},playPause(){let y=f();y.isPlaying?y.pause():y.play()},setDurationPercent(y){let b=f().duration*y;f().setTime(b)},setTime(y){let x=f(),b=i/1e3,C=typeof y=="function"?y(b):y,R=x.nextKeyframeIndex;if(b>C){v({visibleElements:{},currentPrime:null});let P=Object.keys(x.visibleElements);for(let I of P)n.emit("complex-timeline.exit",{id:I});b=0,R=0}let[A,N]=Io({currentTime:b,currentKeyFrameIndex:R,keyframes:x.complexTimeline.keyframes,targetTime:C});x.applyKeyframes(A,N),i=C*1e3;let T=S.getState().visibleElements,z=o,_=Object.keys(T);for(let P of _){let I=T[P];if(I){let $=z[P];$&&($.currentTime=(i-I.time*1e3)/1e3)}}c(C)},setVolume(y){for(let x of d())x.volume=Math.min(1,Math.max(0,y/100));v({volume:y})},toggleMute(){let y=f();y.isMuted?(y.unmute(),v({isMuted:!1})):(y.mute(),v({isMuted:!0}))},clearProgressElement(){s.progress=null},setProgressElement(y){s.progress=y},setCurrentTimeElement(y){s.currentTime=y},clearCurrentTimeElement(){s.currentTime=null}}));return n.on("complex-timeline.enter",v=>{let f=S.getState(),y=v.id,x=o[y];x&&f.isPlaying&&x.play()}),n.on("complex-timeline.exit",v=>{let f=S.getState(),y=v.id,x=o[y];x&&(x.currentTime=0,x.pause())}),S.getState().setTime(t),{store:S,emitter:n}}import{Fragment as Uo,useMemo as _o}from"react";import{useEffect as ko,useRef as De,useState as fs}from"react";var ps=[.6,.02,0,.75],_f=16,Be={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":ps,"ease-out-cubic":[.215,.61,.355,1]};function jf(e,t,n){let o=Math.max(0,Math.min(1,n));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 Kf(e,t){let n=[],o=e;for(let s of t)n.push({from:o,to:s}),o=s;return n}function He([e,t,n,o]){let s=3*e,a=3*(n-e)-s,r=1-s-a,i=3*t,l=3*(o-t)-i,u=1-i-l;function d(g){return((r*g+a)*g+s)*g}function c(g){return((u*g+l)*g+i)*g}function m(g){return(3*r*g+2*a)*g+s}function p(g,h=1e-6){let S=g;for(let y=0;y<8;y++){let x=d(S)-g;if(Math.abs(x)<h)return S;let b=m(S);if(Math.abs(b)<1e-6)break;S=S-x/b}let v=0,f=1;for(S=g;v<f;){let y=d(S);if(Math.abs(y-g)<h)return S;g>y?v=S:f=S,S=(f-v)*.5+v}return S}return g=>{if(g<=0)return 0;if(g>=1)return 1;let h=p(g);return c(h)}}function Yf(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 n=Math.floor(e),o=e-n;return{index:n,t:o}}function Eo(e,{duration:t=300,easing:n}={}){let o=De(He(Be["ease-in-out"]));ko(()=>{if(!n)o.current=He(Be["ease-in-out"]);else if(typeof n=="function")o.current=n;else if(Array.isArray(n))o.current=He(n);else{let d=Be[n];o.current=He(d??Be["ease-in-out"])}},[n]);let[s,a]=fs(e),r=De(e??0),i=De(null),l=De(null),u=De(e);return ko(()=>{if(e===void 0){a(void 0);return}let d=u.current;if(u.current=e,d===void 0){r.current=e,a(e);return}if(d===e&&s===e)return;l.current!==null&&(cancelAnimationFrame(l.current),l.current=null),i.current=null;let c=r.current,m=(((e||0)-c)%360+540)%360-180,p=c+m;function g(h){i.current===null&&(i.current=h);let S=h-i.current,v=Math.min(S/t,1),f=o.current(v),y=c+(p-c)*f;r.current=y,a(y),v<1?l.current=requestAnimationFrame(g):(r.current=((e||0)%360+360)%360,a(r.current),l.current=null)}return l.current=requestAnimationFrame(g),()=>{l.current!==null&&(cancelAnimationFrame(l.current),l.current=null)}},[e,t]),s}import{HTMLPortal as Cs}from"@atlas-viewer/atlas";import{getId as Rs}from"@iiif/parser/image-3";import gs,{useContext as hs}from"react";import{imageServices as ys}from"@iiif/helpers/image-service";import{useStore as at}from"zustand";var Vo=gs.createContext(ys.store);Vo.displayName="ImageServicesHelper";function st(){return hs(Vo)}function No(e){let t=st();return at(t,({loaded:n})=>n[e])}function lt(){let e=st();return at(e,({loadServiceSync:t})=>t)}function Lo(){let e=st();return at(e,({loaded:t})=>t)}function og(){let e=st();return at(e,({loadService:t})=>t)}import Ie,{useMemo as Gt}from"react";import{jsx as J}from"react/jsx-runtime";var Oo=Ie.createContext("en"),Bo=Ie.createContext({}),Ho=Ie.createContext(null);function sg(e){return J(Bo.Provider,{value:e.translations,children:e.children})}function lg(e){return J(Oo.Provider,{value:e.language,children:e.children})}function ug(e){return J(Ho.Provider,{value:e.convert,children:e.children})}function Do(){return Ie.useContext(Ho)}function Qt(){return Ie.useContext(Oo)}function Fo(){return Ie.useContext(Bo)}function zo(e){return e.indexOf("-")!==-1?e.slice(0,e.indexOf("-")):e}function vs({as:e,language:t,children:n,viewingDirection:o,...s}){let a=Qt();return Gt(()=>zo(a)===zo(t),[a,t])?e?J(e,{...s,children:n}):J("span",{...s,children:n}):e?J(e,{...s,lang:t,dir:o,children:n}):J("span",{...s,lang:t,dir:o,children:n})}function qo(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 Ss=(e,t=[])=>{let n=Qt();return Gt(()=>{let o=e();return qo(n,o,[])},[n,...t])};function pe(e,t,n,o){return t?n?n(e[t]||t,o||"none"):e[t]||t:""}function xs(e,t,n=`
16
- `,o={}){let s=Do(),a=Ss(()=>Object.keys(e||{}),[e]);return[Gt(()=>{if(!e)return pe(o,t,s)||"";if(typeof e=="string")return pe(o,e,s);let r=a?e[a]:void 0;return r?typeof r=="string"?r:r.map(i=>pe(o,i,s,a)).join(n):""},[a,t,e]),a]}function cg(){let e=Qt(),t=Fo(),n=Do();return function(s,a="",r=`
17
- `,i=t){let l=Object.keys(s||{}),u=qo(e,l,[]);if(!s)return pe(i,a,n)||"";if(typeof s=="string")return pe(i,s,n);let d=u?s[u]:void 0;return d?typeof d=="string"?pe(i,d,n,u):d.map(c=>pe(i,c,n,u)).join(typeof r<"u"?r:`
18
- `):""}}function Fe({as:e,defaultText:t,enableDangerouslySetInnerHTML:n,children:o,separator:s,...a}){let r=Fo(),[i,l]=xs(o,t,s,r);return l?J(vs,{...a,as:e,language:l,title:n?void 0:i,dangerouslySetInnerHTML:n?{__html:i}:void 0,children:n?void 0:i}):e?J(e,{...a,children:i}):J("span",{...a,title:n?void 0:i,dangerouslySetInnerHTML:n?{__html:i}:void 0,children:n?void 0:i})}import{isImageServiceLevel as $o}from"@iiif/parser/image-3";import{useMemo as Xt}from"react";import{jsx as ut,jsxs as bs}from"react/jsx-runtime";var Zt=e=>{let t=e.format||"jpg",n=e.width/(e.crop?.width||e.tiles.width),o=e.tiles.imageService.sizes||[],s=e.enableThumbnail,a=e.enableSizes,r=Xt(()=>{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"]]),i=Xt(()=>{let u=e.tiles.imageService.tiles||[];if(!u.length){let d=e.width,c=[1],m=1;for(;2**m<d;)m=m*2,c.push(m);return(e.tiles.imageService.maxArea||e.tiles.imageService.maxWidth||e.tiles.imageService.maxHeight)&&$o(2,e.tiles.imageService)?[{width:256,height:256,scaleFactors:c}]:$o(2,e.tiles.imageService)?[{width:256,height:256,scaleFactors:c}]:[]}return u},[e.tiles.imageService,e.width]),l=Xt(()=>{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 ut("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:bs("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?ut("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,a&&o.map((u,d)=>ut("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},d)),i.map(u=>(u.scaleFactors||[]).map(d=>ut("tiled-image",{uri:e.tiles.imageService.id,display:{width:e.tiles.width,height:e.tiles.height},format:t,tile:u,scaleFactor:d,crop:e.crop,version3:l},`${e.tiles.imageService.id}-tile-${d}`)))]},e.tiles.imageService.id)},e.tiles.imageService.id)};import{jsx as re,jsxs as Ps}from"react/jsx-runtime";function As({resource:e,heading:t,note:n,extra:o}){return o?re(Cs,{target:{x:0,y:0,width:o.target?.spatial.width,height:o.target?.spatial.height},backgroundColor:"#333",relative:!0,children:re("div",{style:{display:"flex",alignContent:"center",justifyContent:"center",alignItems:"center",height:"100%",width:"100%",background:"#444",color:"#BBB"},children:Ps("div",{children:[re(Fe,{children:t||"Not authorised"}),n&&re("p",{children:re(Fe,{children:n})}),re("p",{children:e.id||e["@id"]||"unknown"})]})})}):null}function Wo({image:e,thumbnail:t,crop:n,enableSizes:o,enableThumbnail:s,renderOptions:a,rotation:r,manualRotation:i}){let l=Bn(),u=Rs(e.service),d=No(u),c=lt(),m=d?.service;c(e.service,e);let p=m&&d?.status==="done",g=(m?.preferredFormats||[])[0],h=t&&t.type==="fixed"&&t.id&&!t.id.includes("/full/full/")&&!t.id.includes("/max/")?t:void 0;if(p===!1)return null;if(!l){let S=e.service,v=S.width||e.width||0,f=S.height||e.height||0,y=0,x=0,b=e.target?.spatial.width||v,C=e.target?.spatial.height||f,R=b,A=C;return(r===90||r===270)&&!i&&([b,C]=[C,b],y=(R-b)/2,x=(A-C)/2),i&&([b,C]=[C,b]),re(Zt,{enableThumbnail:s,renderOptions:a,rotation:r,tiles:{id:S.id||S["@id"]||"unknown",height:f,width:v,imageService:S,thumbnail:h},enableSizes:o,x:y,y:x,format:g,width:b,height:C,crop:n})}return re(Hn,{resource:e.service,errorComponent:As,extra:e,children:S=>{let v=S.width||e.width||0,f=S.height||e.height||0,y=0,x=0,b=e.target?.spatial.width||v,C=e.target?.spatial.height||f,R=b,A=C;return(r===90||r===270)&&!i&&([b,C]=[C,b],y=(R-b)/2,x=(A-C)/2),re(Zt,{enableThumbnail:s,renderOptions:a,tiles:{id:S.id||S["@id"]||"unknown",height:f,width:v,imageService:S,thumbnail:h},rotation:r,format:g,enableSizes:o,x:y,y:x,width:b,height:C,crop:n})}},e.id)}import{jsx as Jt,jsxs as en}from"react/jsx-runtime";function Me({id:e,image:t,thumbnail:n,isStatic:o,x:s=0,y:a=0,children:r,selector:i,onClick:l,rotation:u,enableSizes:d,enableAnnotations:c}){let m=_o(()=>{if(!(!i||i.spatial.x===0&&i.spatial.y===0))return i.spatial},[i]),p=_o(()=>{if(typeof t.rotation<"u")return t.rotation;if(!t.annotation)return 0;let C=Array.isArray(t.annotation.body)?t.annotation.body?.[0]:t.annotation.body;if(C&&C.selector?.type==="ImageApiSelector")return Number(C.selector.rotation)},[t]),g=Eo(u),h=!!t.service,S=s+t.target.spatial.x,v=a+t.target.spatial.y,f=t.target.spatial.width,y=t.target.spatial.height,x=t.target.spatial.width,b=t.target.spatial.height;return(p===90||p===270)&&([x,b]=[b,x],h||([f,y]=[y,f],S+=(t.target.spatial.width-f)/2,v+=(t.target.spatial.height-y)/2)),en("world-object",{x:S,y:v,width:f,height:y,onClick:l,rotation:t.service?void 0:typeof g<"u"?g:p,children:[t.service?en(Uo,{children:[Jt(Wo,{image:t,thumbnail:n,crop:m,enableSizes:d,rotation:typeof g<"u"?g:p,manualRotation:typeof u<"u"}),r]},"service"):en(Uo,{children:[Jt("world-image",{onClick:l,uri:t.id,target:{x:0,y:0,width:x,height:b},display:x&&b?{width:x,height:b}:void 0,crop:m}),r]},"no-service"),c&&t.annotationPages?t.annotationPages.map(C=>Jt(ce,{page:C,className:"image-service-annotation",ignoreTargetId:!0},C.id)):null]},e+(h?"server":"no-service"))}import{HTMLPortal as ws}from"@atlas-viewer/atlas";import{Fragment as jo,jsx as qe}from"react/jsx-runtime";function ct({strategy:e,onClickPaintingAnnotation:t}){return qe(jo,{children:e.items.map((n,o)=>qe(jo,{children:qe(ws,{onClick:t?s=>{s.stopPropagation(),t(n.annotationId,n,s)}:void 0,target:n.target?.spatial||void 0,children:qe("div",{"data-textual-content":!0,children:qe(Fe,{enableDangerouslySetInnerHTML:!0,children:n.text})})},o)}))})}import{Fragment as Ms,jsx as fe,jsxs as ks}from"react/jsx-runtime";function Go({strategy:e,children:t}){let{store:n}=Is(()=>Mo({complexTimeline:e}),[e]),o=Yo(n,r=>r.isReady),s=Yo(n,r=>r.visibleElements);function a(r){return i=>{i&&n.getState().setElement(r,i)}}return Ts(()=>{if(o){let{startClock:r,stopClock:i}=n.getState();return r(),()=>{i()}}},[e,o]),H("portal","custom-controls",To,{store:n,children:t},[o]),ks(Ms,{children:[e.items.map(r=>r.type!=="Image"||!s[r.annotationId]?null:fe(Me,{image:r,id:r.annotationId},r.id)),e.items.map((r,i)=>r.type!=="Text"||!s[r.annotationId]?null:fe(ct,{strategy:{type:"textual-content",items:[r]}},i)),e.items.map((r,i)=>r.type!=="Video"||!r.target.spatial?null:fe(Ko,{target:r.target.spatial,children:fe("video",{ref:a(r.annotationId),src:r.url,style:{height:"100%",width:"100%",opacity:s[r.annotationId]?1:0}})},i)),e.items.map((r,i)=>r.type!=="Sound"?null:fe(Ko,{children:fe("audio",{ref:a(r.annotationId),src:r.url})},i)),e.highlights.map(({annotation:r})=>s[r.id]?fe(Ae,{id:r.id,ignoreTargetId:!0,style:{outline:"3px solid red"},className:"image-service-annotation"},r.id):null)]})}import{jsx as Es}from"react/jsx-runtime";function Qo(){let{strategy:e}=E(),{renderComplexTimelineControls:t}=F();return e.type!=="complex-timeline"?null:Es(Go,{strategy:e,children:t?t(e):null})}import{jsx as Vs}from"react/jsx-runtime";function dt({style:e}){let t=w();return!t||!t.height||!t.width?null:Vs("box",{interactive:!1,target:{x:0,y:0,width:Number(t.width),height:Number(t.height)},style:e})}import{jsx as Ns}from"react/jsx-runtime";function Xo({backgroundStyle:e,alwaysShowBackground:t}){let{strategy:n}=E();return n.type!=="empty"&&!t?null:Ns(dt,{style:e})}import{createContext as Ls,useContext as zs}from"react";var ge=Ls(null);function mt(){return zs(ge)}import{Fragment as Bs,jsx as Os,jsxs as Hs}from"react/jsx-runtime";function Zo({isStatic:e=!1,enableSizes:t=!1,enableAnnotations:n=!0,onClickPaintingAnnotation:o,rotation:s,children:a}){let{strategy:r}=E(),{renderViewerControls:i,viewControlsDeps:l}=F(),u=w(),d=mt(),c=we({maxWidth:256,maxHeight:256});if(H(d&&r.type==="images"&&i?"overlay":"none",`canvas-portal-controls-${u?.id}`,ge.Provider,i?{value:d||null,children:i(r)}:{},[u,d,r,...l||[]]),r.type!=="images")return null;let m=r.images.length===1?s:0;return Hs(Bs,{children:[r.images.map((p,g)=>Os(Me,{isStatic:e,image:p,id:p.id,thumbnail:g===0?c:void 0,selector:p.selector,enableSizes:t,enableAnnotations:n,rotation:m,onClick:o?h=>{o(p.annotationId,p,h)}:void 0},p.id+g)),a]})}import{Fragment as Fs,jsx as Ds,jsxs as qs}from"react/jsx-runtime";function Jo({onClickPaintingAnnotation:e,children:t}){let{strategy:n}=E(),{renderViewerControls:o,viewControlsDeps:s}=F(),a=mt(),r=w();return H(a&&n.type==="textual-content"&&o?"overlay":"none",`canvas-portal-controls-${r?.id}`,ge.Provider,o?{value:a||null,children:o(n)}:{},[r,a,n,...s||[]]),n.type!=="textual-content"?null:qs(Fs,{children:[Ds(ct,{strategy:n,onClickPaintingAnnotation:e}),t]})}import{jsx as er,jsxs as $s}from"react/jsx-runtime";function tn({element:e,media:t,startTime:n,playPause:o,poster:s}){let a="div",r=n?`${t.url}#t=${n}`:t.url;return $s(a,{className:"video-container",part:"video-container",onClick:o,children:[er("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
- `}),er("video",{poster:s,ref:e,src:r,style:{width:"100%",objectFit:"contain"}})]})}function pt({media:e,mediaControlsDeps:t,children:n,videoComponent:o=tn,captions:s}){let a=w(),r=et(),i=a&&a.placeholderCanvas&&a.placeholderCanvas.id||void 0,l=we({},!1,{canvasId:i}),[{element:u,currentTime:d,progress:c},m,p]=Pe({duration:e.duration});return H("overlay","video-element",o,{element:u,media:e,playPause:p.playPause,poster:l?.id,canvas:a,startTime:r?r.startTime:null,captions:s},[l]),H("portal","custom-controls",Je,{state:m,actions:p,currentTime:d,progress:c,element:u,children:n},[d,m,e,...t||[]]),null}import{jsx as Ws,jsxs as Us}from"react/jsx-runtime";function tr({as:e}){let{strategy:t}=E(),{renderMediaControls:n,mediaControlsDeps:o}=F();return t.type!=="media"||t.media.type!=="Video"?null:Us(pt,{captions:t.captions,media:t.media,mediaControlsDeps:o,videoComponent:e,children:[Ws(Te,{}),n?n(t):null]},t.media.url)}import{useRef as _s}from"react";import{jsx as nr,jsxs as Ys}from"react/jsx-runtime";function js({element:e,media:t,playPause:n}){let o=_s(null);return t.youTubeId?Ys("div",{className:"video-container",part:"video-container",onClick:n,children:[nr("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
- `}),nr("iframe",{title:`YouTube video: ${t.youTubeId}`,className:"video-yt",ref:o,src:`https://www.youtube.com/embed/${t.youTubeId}?enablejsapi=1&origin=${Ks()}&modestbranding=1&rel=0`,referrerPolicy:"no-referrer compute-pressure",sandbox:"allow-scripts allow-same-origin allow-presentation"})]}):null}function Ks(){return typeof window<"u"?window.location.host:""}function or({media:e,mediaControlsDeps:t,children:n}){let[{element:o,currentTime:s,progress:a},r,i]=Pe({duration:e.duration});return H("overlay","video-element",js,{element:o,media:e,playPause:i.playPause}),null}import{jsx as Gs,jsxs as Qs}from"react/jsx-runtime";function rr(){let{strategy:e}=E(),{renderMediaControls:t,mediaControlsDeps:n}=F();return e.type!=="media"||e.media.type!=="VideoYouTube"?null:Qs(or,{media:e.media,mediaControlsDeps:n,children:[Gs(Te,{}),t?t(e):null]})}import{startTransition as zl,useMemo as Ol}from"react";import{useStore as te}from"zustand";import{HTMLPortal as el,useAtlas as tl}from"@atlas-viewer/atlas";import{useCallback as rn,useEffect as an}from"react";import{createSvgHelpers as Xs}from"polygon-editor";import{useEffect as Zs,useRef as ee,useState as ar}from"react";import{useStore as nn}from"zustand";function ir(e){let t=D(),n=nn(t,a=>a.polygons),o=nn(t,a=>a.polygonState),s=nn(t,a=>a.polygon);return _n("atlas.polygon-render",({state:a,slowState:r,dt:i})=>{e(a,r,i)}),{currentShape:s,state:o,helper:n}}import{Fragment as on,jsx as V,jsxs as ke}from"react/jsx-runtime";var ie=Xs(),Js={shapeFill:"#ffffff33",shapeStroke:"#000",lineStroke:"#000",ghostLineStroke:"#0F0",activeLineStroke:"#4D7EEA",boundingBoxDottedStroke:"#0007",boundingBoxStroke:"#fffA",controlFill:"#fff"};function sr(e){let{image:t}=e,n={...Js,...e.theme||{}},o=ee(),s=ee(),a=ee(),r=ee(),i=ee(),l=ee(),u=ee(),d=ee(),c=ee(),m=ee(),[p,g]=ar(null),[h,S]=ar(!1),{helper:v,state:f,currentShape:y}=ir((T,z)=>{if(T.closestLineIndex,ie.updateTransitionBoundingBox(a.current,T,z),ie.updateBoundingBoxPolygon(o.current,T,z),ie.updateBoundingBoxPolygon(s.current,T,z),ie.updateTransitionShape(u.current,T,z),ie.updateClosestLinePointTransform(i.current,T,z),ie.updateSelectBox(r.current,T,z),ie.updatePointLine(d.current,T,z),ie.updateDrawPreview(l.current,T,z,3),ie.updateLineBox(c.current,T),g(T.transitionDirection),S(T.transitionRotate),T.closestLineIndex!==-1&&m.current){let _=T.polygon,P=_.points[T.closestLineIndex],I=_.points[(T.closestLineIndex+1)%_.points.length];P&&I&&m.current.setAttribute("points",`${P[0]},${P[1]} ${I[0]},${I[1]}`)}});Zs(()=>{let T=()=>{v.modifiers.reset()};return document.addEventListener("mouseleave",T),()=>{document.removeEventListener("mouseleave",T)}},[]);let x=ke(on,{children:[ke("marker",{id:"dot",viewBox:"0 0 10 10",refX:"5",refY:"5",markerWidth:"5",markerHeight:"5",children:[V("circle",{cx:"5",cy:"5",r:"5",fill:n.lineStroke,className:"marker"}),V("circle",{cx:"5",cy:"5",r:"3",fill:n.controlFill})]}),V("marker",{id:"newdot",viewBox:"0 0 10 10",refX:"5",refY:"5",markerWidth:"5",markerHeight:"5",children:V("circle",{cx:"5",cy:"5",r:"5",fill:n.activeLineStroke,className:"marker"})}),ke("marker",{id:"selected",viewBox:"0 0 10 10",refX:"5",refY:"5",markerWidth:"5",markerHeight:"5",children:[V("circle",{cx:"5",cy:"5",r:"5",fill:n.lineStroke}),V("circle",{cx:"5",cy:"5",r:"3",fill:n.activeLineStroke})]}),ke("marker",{id:"resizer",viewBox:"0 0 10 10",refX:"5",refY:"5",markerWidth:"6",markerHeight:"6",children:[V("rect",{width:"10",height:"10",fill:n.lineStroke}),V("rect",{x:"1",y:"1",width:"8",height:"8",fill:n.controlFill})]})]}),b=y?y.open?"polyline":"polygon":null,C=!f.showBoundingBox&&f.closestPoint!==null&&f.actionIntentType==="select-point",R=f.actionIntentType==="add-open-point",A=f.transitionIntentType==="split-line",N=f.transitioning&&f.selectedStamp&&f.transitionIntentType==="stamp-shape",X=y&&b?ke(on,{children:[V(b,{fill:(!f.transitioning||f.transitionIntentType==="select-multiple-points")&&!y.open?n.shapeFill:"none",strokeWidth:N||f.showBoundingBox&&f.boxMode||f.transitioning&&f.transitionIntentType==="split-line"||f.transitioning&&f.transitionIntentType==="move-point"?0:2,stroke:n.shapeStroke,points:y.points.map(T=>T.join(",")).join(" "),vectorEffect:"non-scaling-stroke",markerStart:f.showBoundingBox?void 0:f.boxMode?"url(#resizer)":"url(#dot)",markerMid:f.showBoundingBox?void 0:f.boxMode?"url(#resizer)":"url(#dot)",markerEnd:f.showBoundingBox?void 0:f.boxMode?"url(#resizer)":"url(#dot)",style:{pointerEvents:"none"},opacity:f.transitioning&&f.transitionIntentType==="move-shape"?0:1}),f.currentTool==="lineBox"&&f.actionIntentType==="close-line-box"?V("polygon",{fill:n.shapeFill,ref:c,stroke:n.lineStroke,strokeWidth:2,vectorEffect:"non-scaling-stroke"}):null,f.transitionIntentType==="draw-shape"&&f.transitioning?V("polyline",{ref:l,fill:"none",stroke:n.activeLineStroke,strokeWidth:2,vectorEffect:"non-scaling-stroke"}):null,!(f.transitioning&&f.transitionIntentType==="move-point")&&!(f.transitioning&&f.transitionIntentType==="stamp-shape")&&!f.showBoundingBox&&f.selectedPoints&&f.selectedPoints.length?V("polyline",{strokeWidth:2,vectorEffect:"non-scaling-stroke",stroke:"transparent",markerStart:"url(#selected)",markerMid:"url(#selected)",markerEnd:"url(#selected)",fill:"transparent",points:y.points.filter((T,z)=>f.selectedPoints?.includes(z)).map(T=>T.join(",")).join(" "),opacity:f.transitioning&&f.transitionIntentType==="move-shape"?0:1}):null,C&&!f.transitioning&&f.closestPoint!==null&&y.points[f.closestPoint]?V("polyline",{strokeWidth:2,vectorEffect:"non-scaling-stroke",stroke:"transparent",markerStart:"url(#selected)",markerMid:"url(#selected)",markerEnd:"url(#selected)",fill:n.activeLineStroke,points:`${y.points[f.closestPoint][0]},${y.points[f.closestPoint][1]}`,opacity:f.transitioning&&f.transitionIntentType==="move-shape"?0:1}):null,!f.transitioning&&(f.actionIntentType==="add-open-point"||f.actionIntentType==="close-shape"||f.actionIntentType==="close-shape-line")?V("polyline",{stroke:n.activeLineStroke,ref:d,strokeWidth:f.actionIntentType==="add-open-point"?1:2,vectorEffect:"non-scaling-stroke"}):null,f.hasClosestLine&&!f.showBoundingBox&&!f.transitioning&&f.currentTool!=="box"&&f.transitionIntentType==="split-line"?V("g",{children:V("polyline",{ref:m,vectorEffect:"non-scaling-stroke",fill:"transparent",stroke:n.activeLineStroke,strokeWidth:3})}):null,f.hasClosestLine&&!f.showBoundingBox&&!f.transitioning&&f.currentTool!=="box"&&f.transitionIntentType==="split-line"?V("g",{ref:i,children:V("polyline",{markerStart:"url(#newdot)",points:"0,0 1,1",vectorEffect:"non-scaling-stroke",stroke:"transparent",fill:"transparent",strokeWidth:2})}):null,f.transitioning?V(b,{ref:u,fill:y.open?"none":n.shapeFill,stroke:f.transitionIntentType==="stamp-shape"?n.activeLineStroke:n.shapeStroke,vectorEffect:"non-scaling-stroke",strokeWidth:(y.open,2)}):null,f.transitioning&&f.transitionIntentType==="select-multiple-points"?V("rect",{ref:r,fill:"rgba(255, 255, 255, .3)",strokeWidth:1,stroke:"rgba(0,0,0,.2)",vectorEffect:"non-scaling-stroke"}):null,f.showBoundingBox&&!N?ke(on,{children:[V("polygon",{ref:o,strokeWidth:2,stroke:n.boundingBoxStroke,fill:"none",markerStart:"url(#resizer)",markerMid:"url(#resizer)",markerEnd:"url(#resizer)",vectorEffect:"non-scaling-stroke"}),V("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:y,state:f,isAddingPoint:R,isSplitting:A,isStamping:N,isHoveringPoint:C,transitionDirection:p,transitionRotate:h,defs:x,editor:X}}import{jsx as $e,jsxs as nl}from"react/jsx-runtime";function lr(e){let t=tl(),{image:n}=e,{helper:o,defs:s,editor:a,state:r,transitionDirection:i,isSplitting:l,transitionRotate:u,isHoveringPoint:d,isAddingPoint:c}=sr({image:e.image,theme:e.theme}),m=rn(h=>{h.button!==2&&o.pointer([[~~h.atlas.x,~~h.atlas.y]])},[o]),p=rn(h=>{h.button!==2&&o.pointerDown()},[o]),g=rn(h=>{h.button!==2&&o.pointerUp()},[o]);return an(()=>{let h=S=>{o.key.up(S.key)};return document.addEventListener("keyup",h),()=>{document.removeEventListener("keyup",h)}},[o]),an(()=>{let h=S=>{S.target&&["INPUT","TEXTAREA"].includes(S.target.tagName)||S.target?.isContentEditable||document.activeElement&&(document.activeElement instanceof HTMLInputElement||document.activeElement instanceof HTMLTextAreaElement||document.activeElement.isContentEditable)||o.key.down(S.key)};return document.addEventListener("keydown",h),()=>{document.removeEventListener("keydown",h)}},[o]),an(()=>{let h=[];return i&&h.push(`atlas-cursor-${i}`),r.actionIntentType==="cut-line"&&r.modifiers?.Shift&&h.push("atlas-cursor-cut"),(d||r.transitionIntentType==="move-shape"||r.transitionIntentType==="move-point")&&h.push("atlas-cursor-move"),c&&h.push("atlas-cursor-crosshair"),l&&h.push("atlas-cursor-copy"),u&&h.push("atlas-cursor-rotate"),r.transitionIntentType==="draw-shape"&&h.push("atlas-cursor-draw"),t?.canvas&&t.canvas.classList.add(...h),()=>{t?.canvas&&t.canvas.classList.remove(...h)}},[t?.canvas,c,d,l,r.modifiers?.Shift,r.actionIntentType,r.transitionIntentType,i,u]),$e("world-object",{height:n.height,width:n.width,onMouseMove:m,onMouseDown:p,onMouseUp:g,onMouseLeave:o.blur,children:$e(el,{relative:!0,interactive:!1,children:$e("div",{className:"absolute top-0 right-0 left-0 bottom-0",children:nl("svg",{width:"100%",height:"100%",viewBox:`0 0 ${n.width} ${n.height}`,tabIndex:-1,children:[$e("title",{children:"Annotation Editor"}),$e("defs",{children:s}),a]})})})})}import{useCallback as kl}from"react";import{create as El}from"zustand";import{HTMLPortal as hl}from"@atlas-viewer/atlas";import{autoUpdate as yl,detectOverflow as vl,flip as Sl,offset as xl,shift as bl,useDismiss as Cl,useFloating as Rl,useInteractions as Al}from"@floating-ui/react";import{createPortal as Pl}from"react-dom";import pl,{useContext as q,useMemo as fl}from"react";import ol from"react";import{createContext as rl,useMemo as il}from"react";import al from"mitt";import{jsx as ll}from"react/jsx-runtime";var sl=al(),Ee=rl({emitter:sl});Ee.displayName="Events";function ur(){return ol.useContext(Ee).emitter}function gy({emitter:e,children:t}){return ll(Ee.Provider,{value:il(()=>({emitter:e}),[e]),children:t})}import{createContext as ul,useContext as cl,useMemo as dl}from"react";import{jsx as ml}from"react/jsx-runtime";var We=ul("");function cr({children:e,identifier:t}){let n=dl(()=>t??Math.random().toString(36).substring(2,9),[t]);return ml(We.Provider,{value:n,children:e})}function ft(){return cl(We)}import{jsx as U}from"react/jsx-runtime";var Ue=pl.createContext({});function gt(){let e=q(Ue),t=Object.keys(e),n={};for(let o of t)e[o].Provider&&(n[o]={value:q(e[o]),Provider:e[o].Provider});return n}function gl(e){let t=Object.keys(e),n=e.children;for(let o of t){if(o==="children")continue;let{value:s,Provider:a}=e[o];n=U(a,{value:s,children:n})}return n}function Vy(e){let t=q(Ue),n=fl(()=>({...t,...e.providers}),[e.providers]);return U(Ue.Provider,{value:n,children:e.children})}function ht(){return{VaultContext:q(ue),ResourceContext:q(_e),SimpleViewerReactContext:q(ze),VisibleCanvasReactContext:q(ye),AuthRContext:q(Se),SearchReactContext:q(xe),ReactEventContext:q(Ee),ContextBridgeReactContext:q(Ue),StrategyReactContext:q(de),AtlasStoreReactContext:q(Ce),ViewerIdentifierContext:q(We)}}function yt(e){return U(he,{vault:e.bridge.VaultContext.vault||void 0,resources:e.bridge.ResourceContext,children:U(ye.Provider,{value:e.bridge.VisibleCanvasReactContext,children:U(ze.Provider,{value:e.bridge.SimpleViewerReactContext,children:U(Ee.Provider,{value:e.bridge.ReactEventContext,children:U(Ce.Provider,{value:e.bridge.AtlasStoreReactContext,children:U(Se.Provider,{value:e.bridge.AuthRContext,children:U(xe.Provider,{value:e.bridge.SearchReactContext,children:U(We.Provider,{value:e.bridge.ViewerIdentifierContext,children:U(Ue.Provider,{value:e.bridge.ContextBridgeReactContext,children:U(de.Provider,{value:e.bridge.StrategyReactContext,children:e.custom?U(gl,{...e.custom,children:e.children}):e.children})})})})})})})})})})}import{jsx as sn,jsxs as Ml}from"react/jsx-runtime";var pr=10,dr=1;function wl(e){let[t,n]=e.split("-");return[t,n]}function mr(e,t,n){return t>n?e:Math.min(Math.max(e,t),n)}function Tl(e){return e.top>0||e.right>0||e.bottom>0||e.left>0}function Il(e){return{name:"insideHighlightFallback",options:e,async fn(t){if(e.width<=dr||e.height<=dr)return{};let n=await vl(t,{altBoundary:!0});if(!Tl(n))return{};let{reference:o,floating:s}=t.rects,[a,r]=wl(t.initialPlacement),i=Math.min(pr,o.width/2,o.height/2),l=o.x+(o.width-s.width)/2,u=o.y+(o.height-s.height)/2,d=t.x,c=t.y;return a==="top"||a==="bottom"?(c=a==="top"?o.y+i:o.y+o.height-s.height-i,r==="start"?d=o.x+i:r==="end"?d=o.x+o.width-s.width-i:d=l,d=mr(d,o.x+i,o.x+o.width-s.width-i)):(d=a==="left"?o.x+i:o.x+o.width-s.width-i,r==="start"?c=o.y+i:r==="end"?c=o.y+o.height-s.height-i:c=u,c=mr(c,o.y+i,o.y+o.height-s.height-i)),{x:d,y:c}}}}function vt({annotation:e,target:t,children:n,dismissable:o,isOpen:s,onOpenChange:a,placement:r}){let i=ft(),l=ht(),u=gt(),{refs:d,floatingStyles:c,context:m}=Rl({open:s,onOpenChange:a,nodeId:e.id,placement:r||"bottom",middleware:[xl(pr),Sl({mainAxis:!0,fallbackStrategy:"bestFit",altBoundary:!0}),bl({altBoundary:!0}),Il(t)],whileElementsMounted:yl}),p=Cl(m),{getReferenceProps:g,getFloatingProps:h}=Al([o?p:null].filter(S=>S!==null));return Ml(hl,{relative:!0,target:t,interactive:!1,children:[sn("div",{ref:d.setReference,...g(),style:{position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none"}}),Pl(sn(yt,{bridge:l,custom:u,children:sn("div",{ref:d.setFloating,style:c,...h(),children:n})}),document.getElementById(`atlas-floating-ui-${i}`))]})}import{Fragment as Nl,jsx as fr}from"react/jsx-runtime";var Vl=El()(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 St(e,t,n){let{isMenuOpen:o,setIsMenuOpen:s,close:a,open:r,menuPosition:i,setMenuPosition:l,toggle:u}=Vl(),d=kl(p=>{n&&(p.preventDefault(),p.stopPropagation(),u(p.atlas))},[u,n]);return[fr(Nl,{children:n&&o&&fr(vt,{dismissable:!0,placement:"bottom-start",isOpen:o,onOpenChange:s,annotation:{id:e},target:{x:i.x,y:i.y,height:1,width:1},children:o&&n({canvasId:t,position:i,close:()=>s(!1)})})}),{onContextMenu:d},{open:r,close:a,toggle:u,isMenuOpen:o,setIsMenuOpen:s,menuPosition:i,setMenuPosition:l}]}import{useStore as Ll}from"zustand";function gr(){let e=D();return Ll(e,t=>t.tool.requestId&&t.requests[t.tool.requestId]||null)}import{Fragment as hr,jsx as se,jsxs as ln}from"react/jsx-runtime";function yr({theme:e,renderContextMenu:t,children:n}){let o=D(),s=w(),a=te(o,b=>b.polygon),r=te(o,b=>b.polygonState.currentTool),i=te(o,b=>b.mode),l=te(o,b=>b.changeMode),u=te(o,b=>b.polygonState.transitioning),{enabled:d,requestId:c}=te(o,b=>b.tool),m=Ol(()=>be(a),[a]),p=gr(),[g,h]=St("editing-annotation",s?.id,t),S=p?.annotationPopup||n||se(Bl,{}),v=p?.svgTheme||e,f=()=>{l("sketch")};if(!d||!s||!c||!a)return null;let y=m&&a.id&&!u&&(r==="pointer"||r==="hand"||!a.open)?se(vt,{annotation:a,target:m,children:S}):null,x="shape";return i==="explore"?ln(hr,{children:[se(x,{id:`shape-${a.id}`,points:a.points,open:a.open,onClick:f,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)"},...h}),se(x,{id:`shape-${a.id}`,points:a.points,open:a.open,onClick:f,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)"}}),y]}):ln(hr,{children:[t?se(x,{id:`shape-${a.id}`,points:a.points,open:a.open,target:{x:0,y:0,width:s.width,height:s.height},...h}):null,se(lr,{image:s,theme:v}),y,g]})}function Bl(){let e=D(),t=te(e,r=>r.changeMode),n=te(e,r=>r.mode),o=te(e,r=>r.completeRequest),s=te(e,r=>r.tool),a=()=>{zl(()=>{o()})};return s.enabled?ln("div",{className:"svg-tools-container animate-fadeIn",children:[n!=="sketch"&&se("button",{className:"svg-tools-button",onClick:()=>{t("sketch")},children:"Edit"}),se("button",{className:"svg-tools-button",onClick:a,children:"Save"})]}):null}import{useEffect as un,useMemo as cn}from"react";import{useEffect as Tr,useMemo as Ir}from"react";import{useCallback as xr,useMemo as Dl}from"react";function Hl(e,t){let n=e?.iiif?.meta[t];return n?n.annotationPageManager:null}function vr(e,t){return k(n=>{let o=[];if(!e)return o;let s=Object.keys(n.iiif.entities.AnnotationPage);for(let a of s)if(!t||t.indexOf(a)!==-1){let r=Hl(n,a);r&&r.views&&r.views[e]&&o.push(a)}return o},[e,t])}function Sr({canvas:e,manifest:t,all:n,canvases:o}){let s=[];if(t)for(let a of t.annotations)s.indexOf(a.id)===-1&&s.push(a.id);if(n){if(o&&o.length)for(let a of o)for(let r of a.annotations)s.indexOf(r.id)===-1&&s.push(r.id)}else if(e)for(let a of e.annotations)s.indexOf(a.id)===-1&&s.push(a.id);return s}function Fl(e,t){let n=e?.iiif?.meta[t];return n?n.annotationPageManager:null}function br(e,t={}){let n=M(),o=O(),s=w(),a=je(),r=Dl(()=>Sr({all:t.all,manifest:o,canvas:s,canvases:a}),[t.all,s,a,o]),i=vr(e,t.all?void 0:r),l=xr(d=>{e&&n.setMetaValue([d,"annotationPageManager","views"],c=>c&&!c[e]?c:{...c||{},[e]:!1})},[e,n]),u=xr((d,c={})=>{if(!e)return;let m=n.getState(),p=[];if(c?.deselectOthers){let g=Object.keys(m.iiif.entities.AnnotationPage);for(let h of g){let S=Fl(m,h);S&&S.views&&S.views[e]&&p.push(h)}}for(let g of p)l(g);n.setMetaValue([d,"annotationPageManager","views"],g=>g&&g[e]?g:{...g||{},[e]:!0})},[e,l,n]);return{availablePageIds:r,enabledPageIds:i,setPageEnabled:u,setPageDisabled:l}}function Cr(e,t){return k((n,o)=>o.get(e.map(s=>({id:s,type:t}))),[e,t])}import ql from"mitt";import{useCallback as $l}from"react";import{createStore as Wl}from"zustand";var Ul=Wl((e,t)=>({loaded:{},setLoaded:(n,o="done")=>{e(s=>({loaded:{...s.loaded,[n]:o}}))}})),_l=ql();_l.on("loaded",e=>{Ul.getState().setLoaded(e.imageServiceId)});function Rr(){let e=lt(),t=Lo();return[$l((o,{height:s,width:a})=>o&&e(o,{height:s,width:a},!0),[e]),t]}import{useCallback as jl,useMemo as Pr,useState as Kl}from"react";function Ar(e={}){let t=Qe(),n=w(e.canvasId?{id:e.canvasId}:void 0);return k((o,s)=>{if(!n)return[];if(t&&e.enableSingleAnnotation)return[t];let a=s.get(n.items),r=[];for(let i of a)r.push(...s.get(i.items));return r},[n])}import{createPaintingAnnotationsHelper as Yl}from"@iiif/helpers/painting-annotations";function wr(e,t=[]){let n=M(),o=Pr(()=>Yl(n),[]),s=Ar({enableSingleAnnotation:e?.enableSingleAnnotation}),[a,r]=Kl(e?.defaultChoices||[]),i=Pr(()=>o.getPaintables(s,a),[n,s,a,...t]),u={makeChoice:jl((d,{deselectOthers:c=!0,deselect:m=!1}={})=>{i.choice&&r(p=>{if(m){let h=p.filter(S=>S!==d);if(h.length===0){let S=i.items[0].resource.id;return S?[S]:[]}return h}if(c)return[d];let g=[...p];if(g.length===0&&i.items.length){let h=i.items[0].resource.id;h&&g.push(h)}return p.indexOf(d)!==-1?p:[...p,d]})},[i.choice])};return[i,u]}function Mr(e){let t=O(),n=w(),o=M(),s=ur(),a=e?.emitter||s,[r,i]=Rr(),{enabledPageIds:l}=br(e?.annotationPageManagerId||t?.id||n?.id,{all:!1}),u=Cr(l,"AnnotationPage"),d=e?.strategies||["empty","images","media","textual-content","complex-timeline"],[c,m]=wr(e,[i]);Tr(()=>{let g=h=>{m.makeChoice(h.choiceId,{deselectOthers:h.deselectOthers,deselect:h.deselect})};return a.on("make-choice",g),()=>{a.off("make-choice",g)}},[]);let p=Ir(()=>gn({canvas:n,paintables:c,supports:d,loadImageService:r,vault:o}),[n,c,o,m.makeChoice]);return Tr(()=>{let g=c.allChoices,h={canvasId:n?.id,manifestId:t?.id};g&&a.emit("choice-change",{choice:g,partOf:h})},[n?.id,c.allChoices]),Ir(()=>p.type==="unknown"?[p,fn]:[{...p,annotations:{pages:u}},m],[p,u])}import{createStylesHelper as Gl}from"@iiif/helpers";import{jsx as kr}from"react/jsx-runtime";function Er({strategies:e,registerActions:t,defaultChoices:n,onChoiceChange:o,mediaControlsDeps:s,renderMediaControls:a,renderViewerControls:r,viewControlsDeps:i,renderComplexTimelineControls:l,complexTimelineControlsDeps:u,throwOnUnknown:d,children:c}){let m=w(),p=M(),g=cn(()=>Gl(p),[p]),[h,S]=Mr({strategies:e||["images"],defaultChoices:n?.map(({id:x})=>x)}),v="choice"in h?h.choice:void 0;if(un(()=>{t&&t(S)},[h.annotations]),un(()=>{o&&o(v)},[v]),un(()=>{if(n)for(let x of n)typeof x.opacity<"u"&&g.applyStyles({id:x.id},"atlas",{opacity:x.opacity})},[n]),h.type==="unknown"&&d)throw new Error(h.reason||"Unknown strategy");let f=cn(()=>({renderMediaControls:a,mediaControlsDeps:s||[],renderViewerControls:r,viewControlsDeps:i||[],renderComplexTimelineControls:l,complexTimelineControlsDeps:u||[]}),[s,a,r,i,l,u]),y=cn(()=>({strategy:h,actions:S,choices:"choice"in h?h.choice:[]}),[h,m]);return kr(rt.Provider,{value:f,children:kr(de.Provider,{value:y,children:c})})}import{useEffect as Nr,useMemo as Jl}from"react";import{useStore as Lr}from"zustand";import{createContext as Ql,useContext as Xl,useEffect as Zl}from"react";var dn=Ql(()=>{});function Vr(e){let t=w(),n=Xl(dn);Zl(()=>t&&t.id?(n(t.id,e),()=>n(t.id,-1)):()=>{},[t,e])}import{jsxs as eu}from"react/jsx-runtime";function zr({x:e=0,y:t=0,keepCanvasScale:n=!0,renderContextMenu:o,children:s}){let{strategy:a}=E(),r=w(),i=D(),l=Xe(r,["deep-zoom"]),u=Lr(i,h=>h.setCanvasRelativePosition),d=Lr(i,h=>h.clearCanvasRelativePosition),[c,m]=St(`context-menu/${r?.id}`,r?.id,o),p=Jl(()=>n?1:Math.max(1,...a.type==="images"?a.images.map(h=>(h.width||0)/h.target?.spatial.width):[]),[n,a]);Nr(()=>{if(r)return u(r.id,{x:e,y:t,width:r.width,height:r.height}),()=>{d(r.id)}},[e,t,r,d,u]),Nr(()=>{r&&i.getState().reset()},[i,r]),Vr(p);let g=a.type==="images"?a.images.length:0;return r?eu("world-object",{height:r.height,width:r.width,x:e,y:t,...m,...l,children:[c,s]},`${r.id}/${a.type}/${g}`):null}import{jsx as G,jsxs as Or}from"react/jsx-runtime";function me({x:e,y:t,onChoiceChange:n,registerActions:o,defaultChoices:s,isStatic:a,renderViewerControls:r,renderMediaControls:i,renderComplexTimelineControls:l,complexTimelineControlsDeps:u,viewControlsDeps:d,mediaControlsDeps:c,strategies:m,throwOnUnknown:p,rotation:g,backgroundStyle:h,alwaysShowBackground:S,keepCanvasScale:v=!1,enableSizes:f=!1,enableYouTube:y=!0,onClickPaintingAnnotation:x,components:b={},children:C,annotationPopup:R,svgTheme:A,renderContextMenu:N,renderAnnotationContextMenu:X}){return Or(Er,{throwOnUnknown:p,onChoiceChange:n,registerActions:o,strategies:m,defaultChoices:s,mediaControlsDeps:c,renderMediaControls:i,renderViewerControls:r,renderComplexTimelineControls:l,complexTimelineControlsDeps:u,viewControlsDeps:d,children:[Or(zr,{keepCanvasScale:v,x:e,y:t,renderContextMenu:N,children:[G(Xo,{alwaysShowBackground:S,backgroundStyle:h}),G(Qo,{}),G(Jo,{}),G(Zo,{isStatic:a,enableSizes:f,onClickPaintingAnnotation:x,rotation:g}),G(Co,{}),G(mo,{}),G(wo,{as:b.Audio}),G(tr,{as:b.Video}),y?G(rr,{}):null,G(yr,{theme:A,renderContextMenu:X,children:R}),C]}),G(po,{})]})}import{jsx as Br}from"react/jsx-runtime";function Hr(e){let t=w();return!t||!t.placeholderCanvas?null:Br(ne,{canvas:t.placeholderCanvas.id,children:Br(me,{renderViewerControls:e.renderViewerControls})})}import{AtlasAuto as ru}from"@atlas-viewer/atlas";import qr,{useCallback as xt,useMemo as Wr,useState as bt}from"react";import{ErrorBoundary as iu}from"react-error-boundary";import{useStore as $r}from"zustand";import{useEffect as tu,useMemo as nu}from"react";function Dr(e,t=2e3){let{currentSequenceIndex:n,sequence:o,items:s}=Ge(),a=w(),r=nu(()=>{let l=o[n]||[];return l.length===0&&a?[{id:a.id,type:"Canvas"}]:l.map(u=>s[u])},[o,n,a,s]),i=D();tu(()=>{let u=setInterval(()=>{if(e&&t!==-1){let d={x:e.x,y:e.y,width:e.width,height:e.height},c=i.getState().canvasRelativePositions,m={};for(let p of r){let g=c[p.id];if(g){let h=g.x,S=g.y,v=g.width,f=g.height,y={x:Math.max(h,d.x),y:Math.max(S,d.y),width:Math.min(h+v,d.x+d.width)-Math.max(h,d.x),height:Math.min(S+f,d.y+d.height)-Math.max(S,d.y)};y.width<=0||y.height<=0||(m[p.id]={x:y.x-g.x,y:y.y-g.y,width:y.width,height:y.height}),i.setState({canvasViewports:m})}}}},t);return()=>{clearTimeout(u)}},[r,e,i,t])}import{jsx as mn,jsxs as ou}from"react/jsx-runtime";function Fr({width:e,style:t,height:n,error:o,resetErrorBoundary:s}){return ou("div",{style:{width:e,height:n,minHeight:500,...t||{},background:"#f9f9f9"},children:[mn("h3",{children:"Error occurred"}),mn("p",{children:o.message}),mn("button",{type:"button",onClick:s,children:"Reset"})]})}import{Fragment as su,jsx as L,jsxs as lu}from"react/jsx-runtime";function Ur(e){let t=D(),n=Wr(()=>e.name||Math.random().toString(36).substring(2,9),[e.name]);return L(cr,{identifier:n,children:L(Oe,{name:e.name,existing:t,children:L(au,{...e})})})}function au({name:e,children:t,errorFallback:n,outerContainerProps:o={},worldScale:s,updateViewportTimeout:a,...r}){let i=D(),l=ft(),u=$r(i,P=>P.mode),d=$r(i,P=>P.setAtlasRuntime),[c,m]=bt(),p=gt(),g=ht(),h=n||Fr,[S,v]=bt({}),f=Object.entries(S),[y,x]=bt({}),b=Object.entries(y),[C,R]=bt({}),{worldScale:A,runtimeOptions:N}=Wr(()=>{if(Object.values(C).length===0)return{worldScale:1,runtimeOptions:r.runtimeOptions||{maxOverZoom:1}};let I=Math.max(...Object.values(C));return{worldScale:I,runtimeOptions:{maxOverZoom:I||1,...r.runtimeOptions||{}}}},[C,r.runtimeOptions]);Dr(c?.runtime,a);let X=xt((P,I)=>{R($=>{if(I===-1){let{[P]:pn,...le}=$;return le}return{...$,[P]:I}})},[]),T=xt((P,I,$)=>{v(({[P]:pn,...le})=>I?{...le,[P]:{element:I,props:$}}:le)},[]),z=xt((P,I,$)=>{x(({[P]:pn,...le})=>I?{...le,[P]:{element:I,props:$}}:le)},[]),_=xt(P=>{m(P),d(P.runtime),r.onCreated&&r.onCreated(P)},[r.onCreated,d]);return lu(iu,{resetKeys:[],fallbackRender:P=>L(h,{...r,...P}),children:[L(ru,{...r,mode:u,containerProps:{style:{position:"relative"},...r.containerProps||{}},htmlChildren:L(su,{children:f.map(([P,{element:I,props:$}])=>L(qr.Fragment,{children:L(I,{...$||{}})},P))}),onCreated:_,runtimeOptions:N,children:L(Oe,{name:e,existing:i,children:L(ge.Provider,{value:c,children:L(dn.Provider,{value:X,children:L($t.Provider,{value:T,children:L(Wt.Provider,{value:z,children:L(yt,{bridge:g,custom:p,children:L(xo,{children:t})})})})})})})}),L("div",{children:b.map(([P,{element:I,props:$}])=>L(qr.Fragment,{children:L(I,{...$||{}})},P))}),L("div",{id:`atlas-floating-ui-${l}`,className:"atlas-floating-ui",style:{position:"relative",zIndex:999999}})]})}import{Fragment as mu,jsx as Q,jsxs as pu}from"react/jsx-runtime";var du=_r(function(t,n){let o=O(),s=je(),a=Ge(),{ViewerControls:r,MediaControls:i,ComplexTimelineControls:l}=t.components||{};if(uu(n,()=>a,[a]),!o)return Q("div",{});let u=0,d=o.viewingDirection==="top-to-bottom",c=o.viewingDirection==="bottom-to-top",m=o.viewingDirection==="left-to-right",p=o.viewingDirection==="right-to-left",h=o.behavior.includes("continuous")?0:t.spacing||0,S=c||p,v=cu(()=>S?[...s].reverse():s,[s,S]);return pu(mu,{children:[t.header,Q(B.Viewer,{height:t.height,mode:t.mode,renderPreset:t.renderPreset,runtimeOptions:t.runtimeOptions,updateViewportTimeout:t.updateViewportTimeout,homePaddingPx:t.padding,children:v.map((f,y)=>{let x=0,b=0;return!d&&!c?(x=u,u+=f.width+h):(b=u,u+=f.height+h),Q(ne,{canvas:f.id,children:Q(B.RenderCanvas,{strategies:["3d-model","media","images","empty","textual-content","complex-timeline"],renderViewerControls:y===0&&r?()=>Q(r,{}):void 0,renderMediaControls:y===0&&i?()=>Q(i,{}):void 0,annotationPopup:t.annotationPopup,renderContextMenu:t.renderContextMenu,keepCanvasScale:t.keepCanvasScale,renderComplexTimelineControls:y===0&&l?()=>Q(l,{}):void 0,renderAnnotationContextMenu:t.renderAnnotationContextMenu,x,y:b,svgTheme:t.svgTheme,rotation:t.rotation,...t.canvasProps||{},children:t.annotations},f.id)},f.id)})},t.reuseAtlas?"":a.currentSequenceIndex),t.children]})}),B=_r(function({children:t,height:n,annotations:o,canvasProps:s,spacing:a,header:r,components:i,mode:l,reuseAtlas:u,renderPreset:d,runtimeOptions:c,annotationPopup:m,name:p,svgTheme:g,updateViewportTimeout:h,renderContextMenu:S,keepCanvasScale:v,renderAnnotationContextMenu:f,padding:y,rotation:x,...b},C){let R=ve();return Q(Oe,{name:p,children:Q(he,{vault:R,children:Q($n,{...b,children:Q(du,{ref:C,height:n,components:i,spacing:a,canvasProps:s,annotations:o,header:r,mode:l,reuseAtlas:u,renderPreset:d,runtimeOptions:c,annotationPopup:m,svgTheme:g,updateViewportTimeout:h,renderContextMenu:S,keepCanvasScale:v,renderAnnotationContextMenu:f,padding:y,rotation:x,children:t})})})})});B.RenderImage=Me;B.RenderCanvas=me;B.RenderAnnotationPage=ce;B.RenderAnnotation=Ae;B.Viewer=Ur;B.CanvasBackground=dt;B.Audio=nt;B.Video=pt;B.Model=ot;B.AudioHTML=Ut;B.VideoHTML=tn;B.ModelHTML=jt;B.PlaceholderCanvas=Hr;B.getAtlasStoreByName=Qn;export{_e as a,j as b,ae as c,ne as d,ue as e,he as f,M as g,k as h,ye as i,je as j,ve as k,O as l,vn as m,Sn as n,xn as o,bn as p,pi as q,Rt as r,uc as s,Cn as t,mc as u,At as v,Rn as w,An as x,Pc as y,Tn as z,In as A,Mn as B,Pt as C,Pn as D,Se as E,bi as F,Ci as G,On as H,Bn as I,Ne as J,Ri as K,Wc as L,Ai as M,Ln as N,Uc as O,Hn as P,Fn as Q,ze as R,zi as S,$n as T,Ge as U,Mt as V,Vd as W,Un as X,_n as Y,kt as Z,be as _,qi as $,Bd as aa,Et as ba,Vt as ca,jn as da,Kn as ea,Ce as fa,D as ga,Qn as ha,Oe as ia,Xn as ja,Zn as ka,em as la,ra as ma,Jn as na,Qe as oa,w as pa,Xe as qa,Re as ra,to as sa,oo as ta,Ae as ua,ro as va,ce as wa,rp as xa,ip as ya,ap as za,Je as Aa,et as Ba,qt as Ca,Pe as Da,H as Ea,de as Fa,E as Ga,mo as Ha,rt as Ia,F as Ja,po as Ka,fo as La,yo as Ma,So as Na,xo as Oa,Co as Pa,Ro as Qa,Ga as Ra,Ao as Sa,rs as Ta,we as Ua,Te as Va,wo as Wa,To as Xa,Hf as Ya,ps as Za,_f as _a,Be as $a,jf as ab,Kf as bb,He as cb,Yf as db,lt as eb,og as fb,sg as gb,lg as hb,ug as ib,Do as jb,Qt as kb,Fo as lb,vs as mb,Ss as nb,xs as ob,cg as pb,Fe as qb,Me as rb,Qo as sb,Xo as tb,ge as ub,mt as vb,Zo as wb,Jo as xb,tr as yb,rr as zb,ir as Ab,Js as Bb,sr as Cb,sl as Db,Ee as Eb,ur as Fb,gy as Gb,gt as Hb,gl as Ib,Vy as Jb,ht as Kb,yt as Lb,Vl as Mb,St as Nb,gr as Ob,yr as Pb,Bl as Qb,Sr as Rb,br as Sb,Cr as Tb,Rr as Ub,Ar as Vb,wr as Wb,Mr as Xb,Er as Yb,zr as Zb,Fr as _b,Ur as $b,B as ac};