react-iiif-vault 1.3.0 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{$ as wo,A as to,Aa as on,B as oo,Ba as D,C as no,Ca as nn,D as ro,Da as un,E as io,Ea as dn,F as ao,Fa as le,G as so,Ga as fn,H as lo,Ha as pn,I as co,Ia as gn,J as mo,Ja as hn,K as uo,Ka as yn,L as fo,La as vn,M as po,Ma as xn,N as go,Na as bn,O as ho,Oa as Sn,P as yo,Pa as ce,Q as vo,R as xo,S as bo,T as So,U as ie,V as Co,W as Io,X as ae,Y as ko,Z as Po,_ as To,a as Wt,aa as Ro,b as A,ba as Eo,c as B,ca as Mo,d as Dt,da as No,e as Ft,ea as Bo,f as Ot,fa as T,g as te,ga as Lo,h as $t,ha as Ho,i as Vt,ia as Ao,j as oe,ja as zo,k as P,ka as qo,l as z,la as Wo,m as Xt,ma as Do,n as ne,na as Fo,o as q,oa as Oo,p as Yt,pa as $o,q as _t,qa as Vo,r as Kt,ra as Xo,s as Qt,sa as Yo,t as Ut,ta as _o,u as Gt,ua as N,v as Jt,va as jo,w as re,wa as se,x as Zt,xa as en,y as jt,ya as tn,z as eo,za as W}from"./chunk-5PAZ34A4.js";import{a as Ko,b as Qo,c as Uo,d as Go,e as Jo,f as Zo,g as rn,h as an,i as sn,j as ln,k as cn,l as mn}from"./chunk-FZEYDVWC.js";import{useCanvas as We}from"@atlas-viewer/atlas";import{forwardRef as De,useImperativeHandle as Fe}from"react";import{Fragment as Oe,jsx as me}from"react/jsx-runtime";var wn=De(function({canvasId:t},o){let n=We(),i=se(t||n?.id),a=P();return Fe(o,()=>i,[t,n]),!n||i.enabledPageIds.length===0?null:me(Oe,{children:i.enabledPageIds.map(s=>me(ce.RenderAnnotationPage,{page:a.get(s)},s))})});import{useMemo as Xe}from"react";import{useMemo as $e}from"react";import{Fragment as Ve,jsx as C,jsxs as F}from"react/jsx-runtime";function O({metadata:e=[],config:t,labelWidth:o=16,showEmptyMessage:n=!0,allowHtml:i,emptyFallback:a,classes:s={},emptyMessage:l="No metadata available",emptyValueFallback:u="No value",emptyLabelFallback:m="",separator:c,tableFooter:f,tableHeader:x}){let h=$e(()=>{let g=(t||[]).reduce((p,b)=>[...p,...b.keys],[]),d={};for(let p of e){let b=p&&p.label?Object.values(p.label):[];for(let r of b)if(r&&r.length&&(g.indexOf(`metadata.${r[0]}`)!==-1||g.length===0)&&p){let S=`metadata.${r[0]}`;d[S]=d[S]?d[S]:[],d[S].push(p);break}}return d},[t,e]);return Object.keys(h).length===0&&n?C(Ve,{children:a})||C("div",{className:s.empty,children:l}):t&&t.length?F("table",{className:s.container,children:[x,C("tbody",{children:t.map((g,d)=>{let p=[];for(let b of g.keys)for(let r of h[b]||[])p.push(C(N,{enableDangerouslySetInnerHTML:i,defaultText:u,separator:c,children:r.value},d+"__"+b));return p.length===0?null:F("tr",{className:s.row,children:[C("td",{className:s.label,style:o?{minWidth:o}:{},children:C(N,{enableDangerouslySetInnerHTML:i,separator:c,defaultText:m,children:g.label})}),C("td",{className:s.value,children:p})]},d)})}),f]}):F("table",{className:s.container,children:[x,C("tbody",{children:e&&e.length?e.map((g,d)=>g?F("tr",{className:s.row,children:[C("td",{className:s.label,style:o?{minWidth:o}:{},children:C(N,{enableDangerouslySetInnerHTML:i,defaultText:u,separator:c,children:g.label})}),C("td",{className:s.value,children:C(N,{enableDangerouslySetInnerHTML:i,defaultText:u,separator:c,children:g.value})})]},d):null):null}),f]})}import{jsx as Ye}from"react/jsx-runtime";function Fn(e){let t=q(),o=T(),n=re(),i=Xe(()=>{let a=t?.metadata||[],s=o?.metadata||[],l=n?.metadata||[];return[...a,...s,...l]},[t,o,n]);return Ye(O,{metadata:i,...e})}import{useEffect as Ue,useState as Ge}from"react";import{createImageServiceRequest as _e,imageServiceRequestToString as Ke}from"@atlas-viewer/iiif-image-api";import{useMemo as Qe}from"react";function Q(e,t={},o=[]){return Qe(()=>{if(!e)return null;let n=t.quality;e&&e.extraQualities&&t.quality&&(e.extraQualities.includes(t.quality)||(n="default"));let i=_e(e);return Ke({identifier:i.identifier,server:i.server,scheme:i.scheme,type:"image",size:{max:!t.size?.width&&!t.size?.height,confined:!1,upscaled:!1,...t.size||{}},format:t.format||"jpg",region:t.region||{full:!0},rotation:t?.rotation?Number.isInteger(t.rotation)?{angle:t.rotation}:t.rotation:{angle:0},quality:n||"default",prefix:i.prefix,originalPath:i.originalPath})},[...o])}import{jsx as $}from"react/jsx-runtime";function Je(e){let t=typeof e.src=="string"?e.src:e.src.id,o=W(),[n,i]=Ge(!1),a;if(t){let l=o.loadServiceSync({id:t});l&&(a=l)}!a&&!n&&o.loadService({id:t}).then(()=>{i(!0)});let s=Q(a,{size:e.size,selector:e.region,rotation:e.rotation,format:e.format,region:e.region,quality:e.quality},[n,e.src,e.size,e.region,e.rotation,e.format,e.region,e.quality]);return Ue(()=>()=>{i(!1)},[t]),s?$("img",{src:s,alt:e.alt,className:e.className,style:e.style}):$(Ze,{...e,fetchImageService:!1})}function Ze(e){if(e.fetchImageService)return $(Je,{...e});let t=typeof e.src=="string"?{id:e.src,profile:"level0"}:e.src,o=Q(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?$("img",{src:o,alt:e.alt,className:e.className,style:e.style}):null}import{jsx as je}from"react/jsx-runtime";function or(e){let t=q();return je(O,{metadata:t?.metadata||[],...e})}import{useLayoutEffect as rt,useRef as it}from"react";import*as U from"react-lazy-load-image-component";import{getValue as et}from"@iiif/helpers/i18n";import{Fragment as ue,jsx as w,jsxs as nt}from"react/jsx-runtime";var{LazyLoadComponent:tt}=U||U.default;function de(e){let{size:t,visible:o,classes:n,canvasId:i,figure:a}=e,s=t?.width||128,l=t?.height||t?.width||128,u=w(ot,{...e}),m=w(tt,{threshold:300,style:{height:l,width:s},visibleByDefault:o,children:i?w(oe,{canvas:i,children:u}):u});return a?w("figure",{className:n?.figure,children:m}):m}function ot({fallback:e,size:t,classes:o,showLabel:n,alt:i,dereference:a=!1}){let s=T(),l=t?.width||128,u=t?.height||t?.width||128,m=i||et(s?.label)||"",c=le({width:l,height:u},a);return!c||c.type!=="fixed"?w(ue,{children:e}):nt(ue,{children:[w("div",{className:o?.imageWrapper,children:w("img",{className:o?.img,src:c.id,alt:m})}),n?w(N,{as:"figcaption",className:o?.label,children:s?.label}):null]})}import{jsx as L}from"react/jsx-runtime";function gr({flat:e,size:t,classes:o={},showLabel:n,figure:i,fallback:a}){let s=it(null),{items:l,sequence:u,currentSequenceIndex:m,setSequenceIndex:c}=ie(),f={row:o.selected?.row||o.row,item:o.selected?.item||o.item,figure:o.selected?.figure||o.figure,img:o.selected?.img||o.img,label:o.selected?.label||o.label,imageWrapper:o.selected?.imageWrapper||o.imageWrapper};rt(()=>{if(!s.current)return;let h=s.current.querySelector("[data-selected=true]");h&&h.scrollIntoView({behavior:"smooth",block:"nearest",inline:"center"})},[m]);let x=[];for(let h of u){let I=[],g=u[m]===h;for(let d of h){let p=l[d];I.push(L("div",{className:g?f.item:o.item,children:L(de,{classes:g?f:o,canvasId:p.id,size:t,showLabel:n,figure:i,placeholder:L("div",{style:{height:128,width:128}}),fallback:a})},d))}if(e){x.push(I);continue}x.push(L("div",{onClick:d=>{c(u.indexOf(h))},"data-selected":g,className:g?f.row:o.row,children:I},h.join("-")))}return L("div",{ref:s,className:o.container,children:x})}import{Fragment as fe,jsx as R,jsxs as pe}from"react/jsx-runtime";var at={draw:!0,polygon:!0,line:!0,lineBox:!0,square:!0,triangle:!0,hexagon:!0,circle:!0,delete:!0};function vr({helper:e,showShapes:t,state:o,enabled:n=at,classNames:i={},icons:a={}}){return pe(fe,{children:[t?pe(fe,{children:[n.draw&&R("button",{className:i.button,onClick:()=>{e.stamps.clear(),e.draw.enable()},"data-active":!o.lineMode&&!o.selectedStamp&&t&&o.drawMode,children:a.DrawIcon||"Draw"}),n.polygon&&R("button",{className:i.button,"data-active":!o.lineMode&&!o.selectedStamp&&t&&!o.drawMode,onClick:()=>{e.stamps.clear(),e.draw.disable(),e.modes.disableLineBoxMode(),e.modes.disableLineMode()},children:a.PolygonIcon||"Polygon"}),n.line&&R("button",{className:i.button,"data-active":o.lineMode&&!o.lineBoxMode,onClick:()=>{e.modes.enableLineMode()},children:a.LineIcon||"Line"}),n.lineBox&&R("button",{className:i.button,"data-active":o.lineBoxMode,onClick:()=>{e.modes.enableLineBoxMode()},children:a.LineBoxIcon||"LineBox"}),n.square&&R("button",{className:i.button,"data-active":o.selectedStamp?.id==="square",onClick:()=>{e.stamps.square()},children:a.SquareIcon||"Square"}),n.triangle&&R("button",{className:i.button,"data-active":o.selectedStamp?.id==="triangle",onClick:()=>{e.stamps.triangle()},children:a.TriangleIcon||"Triangle"}),n.hexagon&&R("button",{className:i.button,"data-active":o.selectedStamp?.id==="hexagon",onClick:()=>{e.stamps.hexagon()},children:a.HexagonIcon||"Hexagon"})]}):null,o.showBoundingBox&&n.delete&&R("button",{className:i.button,onClick:()=>e.key.down("Backspace"),children:a.DeleteForeverIcon||"Delete"})]})}import{createContext as st,useCallback as ge,useContext as ye,useEffect as he,useMemo as G,useState as lt}from"react";import ve from"mitt";import{jsx as ct}from"react/jsx-runtime";var V=st(ve());V.displayName="SelectorHelper";function Tr({children:e}){return ct(V.Provider,{value:G(()=>ve(),[]),children:e})}function wr(){return ye(V)}function xe(e){let t=be(),[o,n]=lt(!1);he(()=>t.withSelector(e).on("highlight",()=>{n(!0)}),[t,e]),he(()=>t.withSelector(e).on("clear-highlight",()=>{n(!1)}),[t,e]);let i=ge(s=>{t.emit("click",{selectorId:e,event:s})},[e,t]),a=ge(s=>{t.emit("hover",{selectorId:e,event:s})},[e,t]);return{controller:t,onClick:i,onHover:a,isHighlighted:o}}function be(){let e=ye(V);return G(()=>({withSelector(t){return{on(o,n){let i=a=>{a&&a.selectorId===t&&n(a)};return e.on(o,i),()=>{e.off(o,i)}},emit(o,n){e.emit(o,{...n,selectorId:t})}}},on(t,o){return e.on(t,o),()=>{e.off(t,o)}},emit(t,o){e.emit(t,o)}}),[e])}function Rr(){let e=be();return G(()=>({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,n){return e.emit("event-listener",{selectorId:t,name:o,callback:n}),()=>{e.emit("remove-event-listener",{selectorId:t,name:o,callback:n})}},getImagePreview(){return new Promise((o,n)=>{e.emit("image-preview-request",{selectorId:t,resolve:o,reject:n})})},on(o,n){return e.withSelector(t).on(o,n)}}},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,n){return e.emit("event-listener",{selectorId:t,name:o,callback:n}),()=>{e.emit("remove-event-listener",{selectorId:t,name:o,callback:n})}},getImagePreview(t){return new Promise((o,n)=>{e.emit("image-preview-request",{selectorId:t,resolve:o,reject:n})})},on(t,o){return e.on(t,o)}}),[e])}import{createContext as mt,useContext as ut,useMemo as dt}from"react";import{jsx as ft}from"react/jsx-runtime";function Se(){return{default:{backgroundColor:"rgba(0,0,0,0)",borderWidth:"2px",borderColor:"rgba(252,0,98, .5)"},highlighted:{backgroundColor:"rgba(75, 103, 225, 0.4)",borderWidth:"1px",borderColor:"rgba(75,103,225,0.99)"},hidden:{borderWidth:"0px",borderColor:"rgba(0,0,0,0)",backgroundColor:"rgba(0,0,0,0)",hidden:!0}}}var J=mt(Se());J.displayName="AnnotationStyle";function Ce(){return ut(J)}function Br({theme:e,children:t}){let o=dt(()=>e||Se(),[e]);return ft(J.Provider,{value:o,children:t})}import{HTMLPortal as xt,useAtlas as bt}from"@atlas-viewer/atlas";import{useEffect as ke,useRef as E,useState as Pe}from"react";import{useEffect as pt,useMemo as gt,useState as ht}from"react";import{createHelper as yt}from"polygon-editor";function Ie(e,t,o){let[n,i]=ht({}),a=gt(()=>yt(e,o),[]);return pt(()=>(a.clock.start(t,i),()=>{a.clock.stop()}),[]),{state:n,helper:a}}import{createSvgHelpers as vt}from"polygon-editor";import{Fragment as Te,jsx as v,jsxs as we}from"react/jsx-runtime";var M=vt();function Re(e,t){let{image:o,currentShape:n,onChange:i,hideShapeLines:a}=e,s=E(),l=E(),u=E(),m=E(),c=E(),f=E(),x=E(),h=E(),[I,g]=Pe(null),[d,p]=Pe(!1),{helper:b,state:r}=Ie(n,(y,k)=>{M.updateTransitionBoundingBox(l.current,y,k),M.updateBoundingBoxPolygon(s.current,y,k),M.updateTransitionShape(f.current,y,k),M.updateClosestLinePointTransform(m.current,y,k),M.updateSelectBox(u.current,y,k),M.updatePointLine(x.current,y,k),M.updateDrawPreview(c.current,y,k,3),M.updateLineBox(h.current,y),g(y.transitionDirection),p(y.transitionRotate)},i);ke(()=>{b.setShape(n||null)},t),ke(()=>{let y=()=>{b.modifiers.reset()};return document.addEventListener("mouseleave",y),()=>{document.removeEventListener("mouseleave",y)}},[]);let S=we(Te,{children:[v("marker",{id:"dot",viewBox:"0 0 10 10",refX:"5",refY:"5",markerWidth:"5",markerHeight:"5",children:v("circle",{cx:"5",cy:"5",r:"4",className:"marker"})}),v("marker",{id:"selected",viewBox:"0 0 10 10",refX:"5",refY:"5",markerWidth:"5",markerHeight:"5",children:v("circle",{cx:"5",cy:"5",r:"4",fill:"#FAFF00"})}),v("marker",{id:"resizer",viewBox:"0 0 10 10",refX:"5",refY:"5",markerWidth:"5",markerHeight:"5",children:v("rect",{width:"10",height:"10",stroke:"#FF0DCB",fill:"#fff",strokeWidth:2})})]}),_=n?n.open?"polyline":"polygon":null,ee=!r.showBoundingBox&&r.closestPoint!==null&&r.actionIntentType==="select-point",Ae=r.actionIntentType==="add-open-point",ze=r.transitionIntentType==="split-line",K=r.transitioning&&r.selectedStamp&&r.transitionIntentType==="stamp-shape",qe=n&&_?we(Te,{children:[v(_,{fill:!r.transitioning&&r.showBoundingBox?"rgba(255, 0, 0, .5)":"none",strokeWidth:K?0:2,stroke:a?"transparent":"#000",points:n.points.map(y=>y.join(",")).join(" "),vectorEffect:"non-scaling-stroke",markerStart:r.showBoundingBox?void 0:"url(#dot)",markerMid:r.showBoundingBox?void 0:"url(#dot)",markerEnd:r.showBoundingBox?void 0:"url(#dot)",style:{pointerEvents:"none"}}),r.lineBoxMode&&r.actionIntentType==="close-line-box"?v("polygon",{fill:"rgba(255, 0, 0, .4)",ref:h,stroke:"#000",strokeWidth:2,vectorEffect:"non-scaling-stroke"}):null,r.transitionIntentType==="draw-shape"&&r.transitioning?v("polyline",{ref:c,fill:"none",stroke:"rgba(255, 0, 0, .5)",strokeWidth:2,vectorEffect:"non-scaling-stroke"}):null,!r.showBoundingBox&&r.selectedPoints&&r.selectedPoints.length?v("polyline",{strokeWidth:2,vectorEffect:"non-scaling-stroke",stroke:"transparent",markerStart:"url(#selected)",markerMid:"url(#selected)",markerEnd:"url(#selected)",fill:"transparent",points:n.points.filter((y,k)=>r.selectedPoints?.includes(k)).map(y=>y.join(",")).join(" ")}):null,ee&&r.closestPoint!==null&&n.points[r.closestPoint]?v("polyline",{strokeWidth:2,vectorEffect:"non-scaling-stroke",stroke:"transparent",markerStart:"url(#selected)",markerMid:"url(#selected)",markerEnd:"url(#selected)",fill:"transparent",points:`${n.points[r.closestPoint][0]},${n.points[r.closestPoint][1]}`}):null,!r.transitioning&&(r.actionIntentType==="add-open-point"||r.actionIntentType==="close-shape"||r.actionIntentType==="close-shape-line")?v("polyline",{stroke:"#000",ref:x,strokeWidth:r.actionIntentType==="close-shape"?2:1,vectorEffect:"non-scaling-stroke"}):null,r.hasClosestLine&&(!r.transitionIntentType||r.transitionIntentType==="split-line")?v("g",{ref:m,children:v("polyline",{style:{opacity:.5},markerStart:"url(#dot)",points:"0,0 10,10",vectorEffect:"non-scaling-stroke",fill:"transparent",strokeWidth:2})}):null,r.transitioning?v(_,{ref:f,fill:n.open?"none":"rgba(255, 0, 0, .5)",stroke:"rgba(255, 0, 0, .5)",strokeWidth:n.open?2:0}):null,r.transitioning&&r.transitionIntentType==="select-multiple-points"?v("rect",{ref:u,fill:"rgba(255, 255, 255, .3)",strokeWidth:1,stroke:"rgba(0,0,0,.2)",vectorEffect:"non-scaling-stroke"}):null,r.showBoundingBox?null:v("g",{name:"controls",children:!1}),r.showBoundingBox&&!K?v("polygon",{ref:s,strokeWidth:2,stroke:"#FF0DCB",fill:"none",markerStart:"url(#resizer)",markerMid:"url(#resizer)",markerEnd:"url(#resizer)",vectorEffect:"non-scaling-stroke"}):null]}):null;return{helper:b,state:r,isAddingPoint:Ae,isSplitting:ze,isStamping:K,isHoveringPoint:ee,transitionDirection:I,transitionRotate:d,defs:S,editor:qe}}import{useEffect as Z}from"react";import{createPortal as St}from"react-dom";import{Fragment as Ee,jsx as H,jsxs as X}from"react/jsx-runtime";var Ct=[{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 Me(e){let t=e.theme||Ct[0],o=bt(),{image:n}=e,{helper:i,defs:a,editor:s,state:l,transitionDirection:u,isSplitting:m,transitionRotate:c,isHoveringPoint:f,isAddingPoint:x,isStamping:h}=Re({currentShape:e.shape||null,onChange:e.updateShape,image:e.image,hideShapeLines:!0},[]),I=r=>{i.pointer([[~~r.atlas.x,~~r.atlas.y]])};Z(()=>{let r=S=>{i.key.up(S.key)};return document.addEventListener("keyup",r),()=>{document.removeEventListener("keyup",r)}},[]),Z(()=>{let r=S=>{i.key.down(S.key)};return document.addEventListener("keydown",r),()=>{document.removeEventListener("keydown",r)}},[]),Z(()=>{let r=[];return u&&r.push(`atlas-cursor-${u}`),l.actionIntentType==="cut-line"&&l.modifiers?.Shift&&r.push("atlas-cursor-cut"),(f||l.transitionIntentType==="move-shape"||l.transitionIntentType==="move-point")&&r.push("atlas-cursor-move"),x&&r.push("atlas-cursor-crosshair"),m&&r.push("atlas-cursor-copy"),c&&r.push("atlas-cursor-rotate"),l.transitionIntentType==="draw-shape"&&r.push("atlas-cursor-draw"),o?.canvas&&o.canvas.classList.add(...r),()=>{o?.canvas&&o.canvas.classList.remove(...r)}},[o?.canvas,x,f,m,l.modifiers?.Shift,l.actionIntentType,l.transitionIntentType,u,c]);let g=e.shape&&e.shape?.points.length===0,d=e.renderControls?e.renderControls(i,l,g):null,p=document.getElementById(e.controlsHtmlId||"atlas-controls"),b="shape";return H(Ee,{children:X("world-object",{height:n.height,width:n.width,onMouseMove:I,onMouseDown:i.pointerDown,onMouseUp:i.pointerUp,onMouseLeave:i.blur,children:[e.shape?X(Ee,{children:[H(b,{open:e.shape.open,points:e.shape.points,relativeStyle:!0,style:h?{}:t.outer}),H(b,{open:e.shape.open,points:e.shape.points,relativeStyle:!0,style:h?{}:t.inner})]}):null,X(xt,{relative:!0,interactive:!1,children:[H("div",{style:{position:"absolute",top:0,right:0,left:0,bottom:0},children:X("svg",{width:"100%",height:"100%",viewBox:`0 0 ${n.width} ${n.height}`,tabIndex:-1,children:[H("defs",{children:a}),s]})}),p?St(d,p,"controls"):null]})]})})}import{jsx as Ne}from"react/jsx-runtime";function si(e){let t=T(),o=e.annotationBucket,n=e.readOnly,i=e.id,{onClick:a,isHighlighted:s}=xe(e.id),l=Ce(),u=s?l.highlighted:l[o||"hidden"]||l.hidden;if(!t)return null;if(n){let m="shape",c=e.polygon,f=c.open;return c?Ne(m,{id:`shape-${i}`,points:c.points,open:f,onClick:a,relativeStyle:!0,target:{x:0,y:0,width:t.width,height:t.height},style:u}):null}return Ne(Me,{image:t,shape:e.polygon||{id:e.id,open:!0,points:[]},updateShape:e.updatePolygon,theme:e.theme,controlsHtmlId:e.controlsHtmlId,renderControls:e.renderControls})}import{jsx as It}from"react/jsx-runtime";function ui({annotation:e,children:t}){return It(B,{value:{annotation:e},children:t})}import{jsx as kt}from"react/jsx-runtime";function gi({annotationPage:e,children:t}){return kt(B,{value:{annotationPage:e},children:t})}import{jsx as Pt}from"react/jsx-runtime";function xi({collection:e,children:t}){return Pt(B,{value:{collection:e},children:t})}function Ii(e,t={}){return D(t)}import{useCanvas as Tt}from"@atlas-viewer/atlas";import{useEffect as wt,useMemo as j,useState as Rt}from"react";function Ei({canvasId:e}={}){let t=Tt(),o=ne(),n=j(()=>e?[e]:t?[t.id]:o.map(m=>m.id),[e,t,o]),[i,a]=Rt({}),s=ae();wt(()=>{let m=c=>{let f=c.partOf.canvasId;f&&a(x=>({...x,[f]:c.choice}))};return s.on("choice-change",m),()=>{s.off("choice-change",m)}},[]);let l=j(()=>{let m=[];for(let c of n){let f=i[c];f&&m.push({canvasId:c,choice:f})}return m},[n,i]),u=j(()=>({makeChoice:(m,c)=>{s.emit("make-choice",{choiceId:m,...c})}}),[s]);return{choices:l,actions:u}}function Ni(e,t=!1){}function Ai(e){let o=A().manifest,n=e?e.map(i=>typeof i=="string"?i:i?.id):[];return z(i=>{let a=o?i.iiif.entities.Manifest[o]:void 0,s=a?.items||[];if(typeof e>"u")return s;let l=[];for(let u of a?.items||[])n.indexOf(u.id)!==-1&&l.push(u);return l},[n.join("/")])}import{useMemo as Et}from"react";function Fi(e,t=[]){let{id:o,selector:n}=e,i=A(),a=o||i.collection,s=z(l=>a?l.iiif.entities.Collection[a]:void 0,[a]);return Et(()=>{if(s)return n?n(s):s},[s,n,...t])}import{useEffect as Mt,useMemo as Nt}from"react";import{createEventsHelper as Bt}from"@iiif/helpers/events";function Yi(e,t,o,n,i=[]){let a=P(),s=Nt(()=>Bt(a),[a]);Mt(()=>{let l=e;return l?(s.addEventListener(l,t,o,n),()=>{s.removeEventListener(l,t,o)}):()=>{}},[s,e,t,...i])}function Ui(e,t){let{id:o,isLoaded:n,error:i,resource:a,requestId:s,cached:l}=te(e,t);return{id:o,isLoaded:n,error:i,manifest:a,requestId:s,cached:l}}import{getImageServices as Be}from"@atlas-viewer/iiif-image-api";import{useEffect as Lt,useMemo as Le,useState as Y}from"react";function He({cacheKey:e}={}){let t=T(),o=D(),n=P(),i=W(),[a,s]=Y(void 0),[l,u]=Y(!1),[m,c]=Y("idle"),[f,x]=Y(void 0),h=t?t.id:"undefined",I=Le(()=>{try{if(t&&o.length){let d=o[0],p=n.get(d.body[0]),r=Be(p)[0];return r&&i.loadServiceSync({id:r.id||r["@id"],width:r.width||t.width,height:r.height||t.height})||void 0}}catch(d){console.error(d)}},[h,e,t]),g=m==="success"&&a?a:I;return Lt(()=>{(async()=>{try{if(t&&o.length){let d=o[0],p=n.get(d.body[0]),r=Be(p)[0];if(!r)return;u(!0),c("loading");try{let S=await i.loadService({id:r.id||r["@id"],width:r.width||t.width,height:r.height||t.height})||void 0;s(S),c("success"),u(!1)}catch(S){c("error"),x(S)}}}catch(d){c("error"),x(d)}})()},[h,e]),Le(()=>({data:g,isFetching:l,status:m,error:f}),[g,l,m,f])}function ia(){let e=He();return{isLoading:e.isFetching,tile:e.data?{id:e.data.id||e.data["@id"],width:e.data.width,height:e.data.height,imageService:e.data,thumbnail:void 0}:null}}import{createStylesHelper as Ht}from"@iiif/helpers/styles";import{useMemo as At}from"react";function ma(){let e=P();return At(()=>Ht(e),[e])}export*from"@iiif/helpers/annotation-targets";export{ui as AnnotationContext,gi as AnnotationPageContext,Br as AnnotationStyleProvider,yo as Auth,lo as AuthProvider,io as AuthRContext,ao as AuthReactContext,so as AuthReactContextActions,wn as CanvasAnnotations,oe as CanvasContext,ce as CanvasPanel,xi as CollectionContext,Fn as CombinedMetadata,bn as ComplexTimelineProvider,To as ContextBridge,Me as CreateCustomShape,ko as EventsProvider,Ze as Image,tn as ImageServiceLoaderContext,bo as InnerViewerProvider,Wo as LanguageProvider,Vo as LanguageString,N as LocaleString,Vt as ManifestContext,or as ManifestMetadata,vn as MediaPlayerProvider,O as Metadata,si as PolygonSelector,Yt as RangeContext,Io as ReactEventContext,Dt as ReactVaultContext,vr as RenderSvgEditorControls,B as ResourceProvider,Wt as ResourceReactContext,Tr as SelectorControllerProvider,gr as SequenceThumbnails,So as SimpleViewerProvider,xo as SimpleViewerReactContext,de as SingleCanvasThumbnail,qo as TranslationProvider,Do as TransliterationProvider,Ft as VaultProvider,No as ViewerPresetContext,Mo as VirtualAnnotationProvider,Xt as VisibleCanvasReactContext,oo as authDetailsForResource,eo as createAuthStateStore,to as createProbe,Co as defaultEmitter,Uo as emptyActions,Zo as emptyStrategy,Kt as findAllCanvasesInRange,_t as findFirstCanvasFromRange,Qt as findManifestSelectedRange,Ut as findSelectedRange,jo as flattenAnnotationPageIds,fn as formatTime,rn as get3dStrategy,cn as getComplexTimelineStrategy,Se as getDefaultAnnotationStyles,an as getImageStrategy,Jt as getManifestSequence,Qo as getParsedTargetSelector,mn as getRenderingStrategy,sn as getTextualContentStrategy,ln as getVideoStrategy,Gt as getVisibleCanvasesFromCanvasId,jt as hasAuth,ro as makeAccessServiceRequest,no as makeAccessTokenRequest,Ko as parseSpecificResource,Ct as svgThemes,Go as unknownResponse,Jo as unsupportedStrategy,Ao as useAnnotation,zo as useAnnotationPage,se as useAnnotationPageManager,Ce as useAnnotationStyles,Ii as useAnnotationsAtTime,uo as useAuthActions,po as useAuthService,mo as useAuthStore,ho as useAuthToken,go as useAuthTokens,T as useCanvas,Ei as useCanvasChoices,Ni as useCanvasClock,Zt as useCanvasSequence,xn as useCanvasStartTime,Ai as useCanvasSubset,Xo as useClosestLanguage,Fi as useCollection,Sn as useComplexTimeline,Po as useContextBridge,_o as useCreateLocaleString,fo as useCurrentAuth,wo as useDispatch,ae as useEventEmitter,Yi as useEventListener,Ot as useExistingVault,Ui as useExternalCollection,$t as useExternalManifest,te as useExternalResource,Oo as useIIIFLanguage,Q as useImage,He as useImageService,W as useImageServiceLoader,ia as useImageTile,co as useIsAuthEnabled,on as useLoadImageService,Yo as useLocaleString,q as useManifest,hn as useMediaActions,yn as useMediaElements,gn as useMediaState,nn as usePaintables,D as usePaintingAnnotations,Ie as usePolygonHelper,re as useRange,un as useRenderingStrategy,A as useResourceContext,Lo as useResourceEvents,en as useResources,vo as useSearchService,be as useSelectorController,wr as useSelectorEmitter,xe as useSelectorEvents,Rr as useSelectorHelper,pn as useSimpleMediaPlayer,ie as useSimpleViewer,ma as useStyleHelper,Ho as useStyles,Re as useSvgEditor,le as useThumbnail,$o as useTranslations,Fo as useTransliteration,P as useVault,dn as useVaultEffect,z as useVaultSelector,Bo as useViewerPreset,Ro as useVirtualAnnotationPage,Eo as useVirtualAnnotationPageContext,ne as useVisibleCanvases};
1
+ import{$ as wo,A as to,Aa as on,B as oo,Ba as D,C as no,Ca as nn,D as ro,Da as un,E as io,Ea as dn,F as ao,Fa as le,G as so,Ga as fn,H as lo,Ha as pn,I as co,Ia as gn,J as mo,Ja as hn,K as uo,Ka as yn,L as fo,La as vn,M as po,Ma as xn,N as go,Na as bn,O as ho,Oa as Sn,P as yo,Pa as ce,Q as vo,R as xo,S as bo,T as So,U as ie,V as Co,W as Io,X as ae,Y as ko,Z as Po,_ as To,a as Wt,aa as Ro,b as A,ba as Eo,c as B,ca as Mo,d as Dt,da as No,e as Ft,ea as Bo,f as Ot,fa as T,g as te,ga as Lo,h as $t,ha as Ho,i as Vt,ia as Ao,j as oe,ja as zo,k as P,ka as qo,l as z,la as Wo,m as Xt,ma as Do,n as ne,na as Fo,o as q,oa as Oo,p as Yt,pa as $o,q as _t,qa as Vo,r as Kt,ra as Xo,s as Qt,sa as Yo,t as Ut,ta as _o,u as Gt,ua as N,v as Jt,va as jo,w as re,wa as se,x as Zt,xa as en,y as jt,ya as tn,z as eo,za as W}from"./chunk-37JMKXWA.js";import{a as Ko,b as Qo,c as Uo,d as Go,e as Jo,f as Zo,g as rn,h as an,i as sn,j as ln,k as cn,l as mn}from"./chunk-QCPOOHCR.js";import{useCanvas as We}from"@atlas-viewer/atlas";import{forwardRef as De,useImperativeHandle as Fe}from"react";import{Fragment as Oe,jsx as me}from"react/jsx-runtime";var wn=De(function({canvasId:t},o){let n=We(),i=se(t||n?.id),a=P();return Fe(o,()=>i,[t,n]),!n||i.enabledPageIds.length===0?null:me(Oe,{children:i.enabledPageIds.map(s=>me(ce.RenderAnnotationPage,{page:a.get(s)},s))})});import{useMemo as Xe}from"react";import{useMemo as $e}from"react";import{Fragment as Ve,jsx as C,jsxs as F}from"react/jsx-runtime";function O({metadata:e=[],config:t,labelWidth:o=16,showEmptyMessage:n=!0,allowHtml:i,emptyFallback:a,classes:s={},emptyMessage:l="No metadata available",emptyValueFallback:u="No value",emptyLabelFallback:m="",separator:c,tableFooter:f,tableHeader:x}){let h=$e(()=>{let g=(t||[]).reduce((p,b)=>[...p,...b.keys],[]),d={};for(let p of e){let b=p&&p.label?Object.values(p.label):[];for(let r of b)if(r&&r.length&&(g.indexOf(`metadata.${r[0]}`)!==-1||g.length===0)&&p){let S=`metadata.${r[0]}`;d[S]=d[S]?d[S]:[],d[S].push(p);break}}return d},[t,e]);return Object.keys(h).length===0&&n?C(Ve,{children:a})||C("div",{className:s.empty,children:l}):t&&t.length?F("table",{className:s.container,children:[x,C("tbody",{children:t.map((g,d)=>{let p=[];for(let b of g.keys)for(let r of h[b]||[])p.push(C(N,{enableDangerouslySetInnerHTML:i,defaultText:u,separator:c,children:r.value},d+"__"+b));return p.length===0?null:F("tr",{className:s.row,children:[C("td",{className:s.label,style:o?{minWidth:o}:{},children:C(N,{enableDangerouslySetInnerHTML:i,separator:c,defaultText:m,children:g.label})}),C("td",{className:s.value,children:p})]},d)})}),f]}):F("table",{className:s.container,children:[x,C("tbody",{children:e&&e.length?e.map((g,d)=>g?F("tr",{className:s.row,children:[C("td",{className:s.label,style:o?{minWidth:o}:{},children:C(N,{enableDangerouslySetInnerHTML:i,defaultText:u,separator:c,children:g.label})}),C("td",{className:s.value,children:C(N,{enableDangerouslySetInnerHTML:i,defaultText:u,separator:c,children:g.value})})]},d):null):null}),f]})}import{jsx as Ye}from"react/jsx-runtime";function Fn(e){let t=q(),o=T(),n=re(),i=Xe(()=>{let a=t?.metadata||[],s=o?.metadata||[],l=n?.metadata||[];return[...a,...s,...l]},[t,o,n]);return Ye(O,{metadata:i,...e})}import{useEffect as Ue,useState as Ge}from"react";import{createImageServiceRequest as _e,imageServiceRequestToString as Ke}from"@atlas-viewer/iiif-image-api";import{useMemo as Qe}from"react";function Q(e,t={},o=[]){return Qe(()=>{if(!e)return null;let n=t.quality;e&&e.extraQualities&&t.quality&&(e.extraQualities.includes(t.quality)||(n="default"));let i=_e(e);return Ke({identifier:i.identifier,server:i.server,scheme:i.scheme,type:"image",size:{max:!t.size?.width&&!t.size?.height,confined:!1,upscaled:!1,...t.size||{}},format:t.format||"jpg",region:t.region||{full:!0},rotation:t?.rotation?Number.isInteger(t.rotation)?{angle:t.rotation}:t.rotation:{angle:0},quality:n||"default",prefix:i.prefix,originalPath:i.originalPath})},[...o])}import{jsx as $}from"react/jsx-runtime";function Je(e){let t=typeof e.src=="string"?e.src:e.src.id,o=W(),[n,i]=Ge(!1),a;if(t){let l=o.loadServiceSync({id:t});l&&(a=l)}!a&&!n&&o.loadService({id:t}).then(()=>{i(!0)});let s=Q(a,{size:e.size,selector:e.region,rotation:e.rotation,format:e.format,region:e.region,quality:e.quality},[n,e.src,e.size,e.region,e.rotation,e.format,e.region,e.quality]);return Ue(()=>()=>{i(!1)},[t]),s?$("img",{src:s,alt:e.alt,className:e.className,style:e.style}):$(Ze,{...e,fetchImageService:!1})}function Ze(e){if(e.fetchImageService)return $(Je,{...e});let t=typeof e.src=="string"?{id:e.src,profile:"level0"}:e.src,o=Q(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?$("img",{src:o,alt:e.alt,className:e.className,style:e.style}):null}import{jsx as je}from"react/jsx-runtime";function or(e){let t=q();return je(O,{metadata:t?.metadata||[],...e})}import{useLayoutEffect as rt,useRef as it}from"react";import*as U from"react-lazy-load-image-component";import{getValue as et}from"@iiif/helpers/i18n";import{Fragment as ue,jsx as w,jsxs as nt}from"react/jsx-runtime";var{LazyLoadComponent:tt}=U||U.default;function de(e){let{size:t,visible:o,classes:n,canvasId:i,figure:a}=e,s=t?.width||128,l=t?.height||t?.width||128,u=w(ot,{...e}),m=w(tt,{threshold:300,style:{height:l,width:s},visibleByDefault:o,children:i?w(oe,{canvas:i,children:u}):u});return a?w("figure",{className:n?.figure,children:m}):m}function ot({fallback:e,size:t,classes:o,showLabel:n,alt:i,dereference:a=!1}){let s=T(),l=t?.width||128,u=t?.height||t?.width||128,m=i||et(s?.label)||"",c=le({width:l,height:u},a);return!c||c.type!=="fixed"?w(ue,{children:e}):nt(ue,{children:[w("div",{className:o?.imageWrapper,children:w("img",{className:o?.img,src:c.id,alt:m})}),n?w(N,{as:"figcaption",className:o?.label,children:s?.label}):null]})}import{jsx as L}from"react/jsx-runtime";function gr({flat:e,size:t,classes:o={},showLabel:n,figure:i,fallback:a}){let s=it(null),{items:l,sequence:u,currentSequenceIndex:m,setSequenceIndex:c}=ie(),f={row:o.selected?.row||o.row,item:o.selected?.item||o.item,figure:o.selected?.figure||o.figure,img:o.selected?.img||o.img,label:o.selected?.label||o.label,imageWrapper:o.selected?.imageWrapper||o.imageWrapper};rt(()=>{if(!s.current)return;let h=s.current.querySelector("[data-selected=true]");h&&h.scrollIntoView({behavior:"smooth",block:"nearest",inline:"center"})},[m]);let x=[];for(let h of u){let I=[],g=u[m]===h;for(let d of h){let p=l[d];I.push(L("div",{className:g?f.item:o.item,children:L(de,{classes:g?f:o,canvasId:p.id,size:t,showLabel:n,figure:i,placeholder:L("div",{style:{height:128,width:128}}),fallback:a})},d))}if(e){x.push(I);continue}x.push(L("div",{onClick:d=>{c(u.indexOf(h))},"data-selected":g,className:g?f.row:o.row,children:I},h.join("-")))}return L("div",{ref:s,className:o.container,children:x})}import{Fragment as fe,jsx as R,jsxs as pe}from"react/jsx-runtime";var at={draw:!0,polygon:!0,line:!0,lineBox:!0,square:!0,triangle:!0,hexagon:!0,circle:!0,delete:!0};function vr({helper:e,showShapes:t,state:o,enabled:n=at,classNames:i={},icons:a={}}){return pe(fe,{children:[t?pe(fe,{children:[n.draw&&R("button",{className:i.button,onClick:()=>{e.stamps.clear(),e.draw.enable()},"data-active":!o.lineMode&&!o.selectedStamp&&t&&o.drawMode,children:a.DrawIcon||"Draw"}),n.polygon&&R("button",{className:i.button,"data-active":!o.lineMode&&!o.selectedStamp&&t&&!o.drawMode,onClick:()=>{e.stamps.clear(),e.draw.disable(),e.modes.disableLineBoxMode(),e.modes.disableLineMode()},children:a.PolygonIcon||"Polygon"}),n.line&&R("button",{className:i.button,"data-active":o.lineMode&&!o.lineBoxMode,onClick:()=>{e.modes.enableLineMode()},children:a.LineIcon||"Line"}),n.lineBox&&R("button",{className:i.button,"data-active":o.lineBoxMode,onClick:()=>{e.modes.enableLineBoxMode()},children:a.LineBoxIcon||"LineBox"}),n.square&&R("button",{className:i.button,"data-active":o.selectedStamp?.id==="square",onClick:()=>{e.stamps.square()},children:a.SquareIcon||"Square"}),n.triangle&&R("button",{className:i.button,"data-active":o.selectedStamp?.id==="triangle",onClick:()=>{e.stamps.triangle()},children:a.TriangleIcon||"Triangle"}),n.hexagon&&R("button",{className:i.button,"data-active":o.selectedStamp?.id==="hexagon",onClick:()=>{e.stamps.hexagon()},children:a.HexagonIcon||"Hexagon"})]}):null,o.showBoundingBox&&n.delete&&R("button",{className:i.button,onClick:()=>e.key.down("Backspace"),children:a.DeleteForeverIcon||"Delete"})]})}import{createContext as st,useCallback as ge,useContext as ye,useEffect as he,useMemo as G,useState as lt}from"react";import ve from"mitt";import{jsx as ct}from"react/jsx-runtime";var V=st(ve());V.displayName="SelectorHelper";function Tr({children:e}){return ct(V.Provider,{value:G(()=>ve(),[]),children:e})}function wr(){return ye(V)}function xe(e){let t=be(),[o,n]=lt(!1);he(()=>t.withSelector(e).on("highlight",()=>{n(!0)}),[t,e]),he(()=>t.withSelector(e).on("clear-highlight",()=>{n(!1)}),[t,e]);let i=ge(s=>{t.emit("click",{selectorId:e,event:s})},[e,t]),a=ge(s=>{t.emit("hover",{selectorId:e,event:s})},[e,t]);return{controller:t,onClick:i,onHover:a,isHighlighted:o}}function be(){let e=ye(V);return G(()=>({withSelector(t){return{on(o,n){let i=a=>{a&&a.selectorId===t&&n(a)};return e.on(o,i),()=>{e.off(o,i)}},emit(o,n){e.emit(o,{...n,selectorId:t})}}},on(t,o){return e.on(t,o),()=>{e.off(t,o)}},emit(t,o){e.emit(t,o)}}),[e])}function Rr(){let e=be();return G(()=>({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,n){return e.emit("event-listener",{selectorId:t,name:o,callback:n}),()=>{e.emit("remove-event-listener",{selectorId:t,name:o,callback:n})}},getImagePreview(){return new Promise((o,n)=>{e.emit("image-preview-request",{selectorId:t,resolve:o,reject:n})})},on(o,n){return e.withSelector(t).on(o,n)}}},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,n){return e.emit("event-listener",{selectorId:t,name:o,callback:n}),()=>{e.emit("remove-event-listener",{selectorId:t,name:o,callback:n})}},getImagePreview(t){return new Promise((o,n)=>{e.emit("image-preview-request",{selectorId:t,resolve:o,reject:n})})},on(t,o){return e.on(t,o)}}),[e])}import{createContext as mt,useContext as ut,useMemo as dt}from"react";import{jsx as ft}from"react/jsx-runtime";function Se(){return{default:{backgroundColor:"rgba(0,0,0,0)",borderWidth:"2px",borderColor:"rgba(252,0,98, .5)"},highlighted:{backgroundColor:"rgba(75, 103, 225, 0.4)",borderWidth:"1px",borderColor:"rgba(75,103,225,0.99)"},hidden:{borderWidth:"0px",borderColor:"rgba(0,0,0,0)",backgroundColor:"rgba(0,0,0,0)",hidden:!0}}}var J=mt(Se());J.displayName="AnnotationStyle";function Ce(){return ut(J)}function Br({theme:e,children:t}){let o=dt(()=>e||Se(),[e]);return ft(J.Provider,{value:o,children:t})}import{HTMLPortal as xt,useAtlas as bt}from"@atlas-viewer/atlas";import{useEffect as ke,useRef as E,useState as Pe}from"react";import{useEffect as pt,useMemo as gt,useState as ht}from"react";import{createHelper as yt}from"polygon-editor";function Ie(e,t,o){let[n,i]=ht({}),a=gt(()=>yt(e,o),[]);return pt(()=>(a.clock.start(t,i),()=>{a.clock.stop()}),[]),{state:n,helper:a}}import{createSvgHelpers as vt}from"polygon-editor";import{Fragment as Te,jsx as v,jsxs as we}from"react/jsx-runtime";var M=vt();function Re(e,t){let{image:o,currentShape:n,onChange:i,hideShapeLines:a}=e,s=E(),l=E(),u=E(),m=E(),c=E(),f=E(),x=E(),h=E(),[I,g]=Pe(null),[d,p]=Pe(!1),{helper:b,state:r}=Ie(n,(y,k)=>{M.updateTransitionBoundingBox(l.current,y,k),M.updateBoundingBoxPolygon(s.current,y,k),M.updateTransitionShape(f.current,y,k),M.updateClosestLinePointTransform(m.current,y,k),M.updateSelectBox(u.current,y,k),M.updatePointLine(x.current,y,k),M.updateDrawPreview(c.current,y,k,3),M.updateLineBox(h.current,y),g(y.transitionDirection),p(y.transitionRotate)},i);ke(()=>{b.setShape(n||null)},t),ke(()=>{let y=()=>{b.modifiers.reset()};return document.addEventListener("mouseleave",y),()=>{document.removeEventListener("mouseleave",y)}},[]);let S=we(Te,{children:[v("marker",{id:"dot",viewBox:"0 0 10 10",refX:"5",refY:"5",markerWidth:"5",markerHeight:"5",children:v("circle",{cx:"5",cy:"5",r:"4",className:"marker"})}),v("marker",{id:"selected",viewBox:"0 0 10 10",refX:"5",refY:"5",markerWidth:"5",markerHeight:"5",children:v("circle",{cx:"5",cy:"5",r:"4",fill:"#FAFF00"})}),v("marker",{id:"resizer",viewBox:"0 0 10 10",refX:"5",refY:"5",markerWidth:"5",markerHeight:"5",children:v("rect",{width:"10",height:"10",stroke:"#FF0DCB",fill:"#fff",strokeWidth:2})})]}),_=n?n.open?"polyline":"polygon":null,ee=!r.showBoundingBox&&r.closestPoint!==null&&r.actionIntentType==="select-point",Ae=r.actionIntentType==="add-open-point",ze=r.transitionIntentType==="split-line",K=r.transitioning&&r.selectedStamp&&r.transitionIntentType==="stamp-shape",qe=n&&_?we(Te,{children:[v(_,{fill:!r.transitioning&&r.showBoundingBox?"rgba(255, 0, 0, .5)":"none",strokeWidth:K?0:2,stroke:a?"transparent":"#000",points:n.points.map(y=>y.join(",")).join(" "),vectorEffect:"non-scaling-stroke",markerStart:r.showBoundingBox?void 0:"url(#dot)",markerMid:r.showBoundingBox?void 0:"url(#dot)",markerEnd:r.showBoundingBox?void 0:"url(#dot)",style:{pointerEvents:"none"}}),r.lineBoxMode&&r.actionIntentType==="close-line-box"?v("polygon",{fill:"rgba(255, 0, 0, .4)",ref:h,stroke:"#000",strokeWidth:2,vectorEffect:"non-scaling-stroke"}):null,r.transitionIntentType==="draw-shape"&&r.transitioning?v("polyline",{ref:c,fill:"none",stroke:"rgba(255, 0, 0, .5)",strokeWidth:2,vectorEffect:"non-scaling-stroke"}):null,!r.showBoundingBox&&r.selectedPoints&&r.selectedPoints.length?v("polyline",{strokeWidth:2,vectorEffect:"non-scaling-stroke",stroke:"transparent",markerStart:"url(#selected)",markerMid:"url(#selected)",markerEnd:"url(#selected)",fill:"transparent",points:n.points.filter((y,k)=>r.selectedPoints?.includes(k)).map(y=>y.join(",")).join(" ")}):null,ee&&r.closestPoint!==null&&n.points[r.closestPoint]?v("polyline",{strokeWidth:2,vectorEffect:"non-scaling-stroke",stroke:"transparent",markerStart:"url(#selected)",markerMid:"url(#selected)",markerEnd:"url(#selected)",fill:"transparent",points:`${n.points[r.closestPoint][0]},${n.points[r.closestPoint][1]}`}):null,!r.transitioning&&(r.actionIntentType==="add-open-point"||r.actionIntentType==="close-shape"||r.actionIntentType==="close-shape-line")?v("polyline",{stroke:"#000",ref:x,strokeWidth:r.actionIntentType==="close-shape"?2:1,vectorEffect:"non-scaling-stroke"}):null,r.hasClosestLine&&(!r.transitionIntentType||r.transitionIntentType==="split-line")?v("g",{ref:m,children:v("polyline",{style:{opacity:.5},markerStart:"url(#dot)",points:"0,0 10,10",vectorEffect:"non-scaling-stroke",fill:"transparent",strokeWidth:2})}):null,r.transitioning?v(_,{ref:f,fill:n.open?"none":"rgba(255, 0, 0, .5)",stroke:"rgba(255, 0, 0, .5)",strokeWidth:n.open?2:0}):null,r.transitioning&&r.transitionIntentType==="select-multiple-points"?v("rect",{ref:u,fill:"rgba(255, 255, 255, .3)",strokeWidth:1,stroke:"rgba(0,0,0,.2)",vectorEffect:"non-scaling-stroke"}):null,r.showBoundingBox?null:v("g",{name:"controls",children:!1}),r.showBoundingBox&&!K?v("polygon",{ref:s,strokeWidth:2,stroke:"#FF0DCB",fill:"none",markerStart:"url(#resizer)",markerMid:"url(#resizer)",markerEnd:"url(#resizer)",vectorEffect:"non-scaling-stroke"}):null]}):null;return{helper:b,state:r,isAddingPoint:Ae,isSplitting:ze,isStamping:K,isHoveringPoint:ee,transitionDirection:I,transitionRotate:d,defs:S,editor:qe}}import{useEffect as Z}from"react";import{createPortal as St}from"react-dom";import{Fragment as Ee,jsx as H,jsxs as X}from"react/jsx-runtime";var Ct=[{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 Me(e){let t=e.theme||Ct[0],o=bt(),{image:n}=e,{helper:i,defs:a,editor:s,state:l,transitionDirection:u,isSplitting:m,transitionRotate:c,isHoveringPoint:f,isAddingPoint:x,isStamping:h}=Re({currentShape:e.shape||null,onChange:e.updateShape,image:e.image,hideShapeLines:!0},[]),I=r=>{i.pointer([[~~r.atlas.x,~~r.atlas.y]])};Z(()=>{let r=S=>{i.key.up(S.key)};return document.addEventListener("keyup",r),()=>{document.removeEventListener("keyup",r)}},[]),Z(()=>{let r=S=>{i.key.down(S.key)};return document.addEventListener("keydown",r),()=>{document.removeEventListener("keydown",r)}},[]),Z(()=>{let r=[];return u&&r.push(`atlas-cursor-${u}`),l.actionIntentType==="cut-line"&&l.modifiers?.Shift&&r.push("atlas-cursor-cut"),(f||l.transitionIntentType==="move-shape"||l.transitionIntentType==="move-point")&&r.push("atlas-cursor-move"),x&&r.push("atlas-cursor-crosshair"),m&&r.push("atlas-cursor-copy"),c&&r.push("atlas-cursor-rotate"),l.transitionIntentType==="draw-shape"&&r.push("atlas-cursor-draw"),o?.canvas&&o.canvas.classList.add(...r),()=>{o?.canvas&&o.canvas.classList.remove(...r)}},[o?.canvas,x,f,m,l.modifiers?.Shift,l.actionIntentType,l.transitionIntentType,u,c]);let g=e.shape&&e.shape?.points.length===0,d=e.renderControls?e.renderControls(i,l,g):null,p=document.getElementById(e.controlsHtmlId||"atlas-controls"),b="shape";return H(Ee,{children:X("world-object",{height:n.height,width:n.width,onMouseMove:I,onMouseDown:i.pointerDown,onMouseUp:i.pointerUp,onMouseLeave:i.blur,children:[e.shape?X(Ee,{children:[H(b,{open:e.shape.open,points:e.shape.points,relativeStyle:!0,style:h?{}:t.outer}),H(b,{open:e.shape.open,points:e.shape.points,relativeStyle:!0,style:h?{}:t.inner})]}):null,X(xt,{relative:!0,interactive:!1,children:[H("div",{style:{position:"absolute",top:0,right:0,left:0,bottom:0},children:X("svg",{width:"100%",height:"100%",viewBox:`0 0 ${n.width} ${n.height}`,tabIndex:-1,children:[H("defs",{children:a}),s]})}),p?St(d,p,"controls"):null]})]})})}import{jsx as Ne}from"react/jsx-runtime";function si(e){let t=T(),o=e.annotationBucket,n=e.readOnly,i=e.id,{onClick:a,isHighlighted:s}=xe(e.id),l=Ce(),u=s?l.highlighted:l[o||"hidden"]||l.hidden;if(!t)return null;if(n){let m="shape",c=e.polygon,f=c.open;return c?Ne(m,{id:`shape-${i}`,points:c.points,open:f,onClick:a,relativeStyle:!0,target:{x:0,y:0,width:t.width,height:t.height},style:u}):null}return Ne(Me,{image:t,shape:e.polygon||{id:e.id,open:!0,points:[]},updateShape:e.updatePolygon,theme:e.theme,controlsHtmlId:e.controlsHtmlId,renderControls:e.renderControls})}import{jsx as It}from"react/jsx-runtime";function ui({annotation:e,children:t}){return It(B,{value:{annotation:e},children:t})}import{jsx as kt}from"react/jsx-runtime";function gi({annotationPage:e,children:t}){return kt(B,{value:{annotationPage:e},children:t})}import{jsx as Pt}from"react/jsx-runtime";function xi({collection:e,children:t}){return Pt(B,{value:{collection:e},children:t})}function Ii(e,t={}){return D(t)}import{useCanvas as Tt}from"@atlas-viewer/atlas";import{useEffect as wt,useMemo as j,useState as Rt}from"react";function Ei({canvasId:e}={}){let t=Tt(),o=ne(),n=j(()=>e?[e]:t?[t.id]:o.map(m=>m.id),[e,t,o]),[i,a]=Rt({}),s=ae();wt(()=>{let m=c=>{let f=c.partOf.canvasId;f&&a(x=>({...x,[f]:c.choice}))};return s.on("choice-change",m),()=>{s.off("choice-change",m)}},[]);let l=j(()=>{let m=[];for(let c of n){let f=i[c];f&&m.push({canvasId:c,choice:f})}return m},[n,i]),u=j(()=>({makeChoice:(m,c)=>{s.emit("make-choice",{choiceId:m,...c})}}),[s]);return{choices:l,actions:u}}function Ni(e,t=!1){}function Ai(e){let o=A().manifest,n=e?e.map(i=>typeof i=="string"?i:i?.id):[];return z(i=>{let a=o?i.iiif.entities.Manifest[o]:void 0,s=a?.items||[];if(typeof e>"u")return s;let l=[];for(let u of a?.items||[])n.indexOf(u.id)!==-1&&l.push(u);return l},[n.join("/")])}import{useMemo as Et}from"react";function Fi(e,t=[]){let{id:o,selector:n}=e,i=A(),a=o||i.collection,s=z(l=>a?l.iiif.entities.Collection[a]:void 0,[a]);return Et(()=>{if(s)return n?n(s):s},[s,n,...t])}import{useEffect as Mt,useMemo as Nt}from"react";import{createEventsHelper as Bt}from"@iiif/helpers/events";function Yi(e,t,o,n,i=[]){let a=P(),s=Nt(()=>Bt(a),[a]);Mt(()=>{let l=e;return l?(s.addEventListener(l,t,o,n),()=>{s.removeEventListener(l,t,o)}):()=>{}},[s,e,t,...i])}function Ui(e,t){let{id:o,isLoaded:n,error:i,resource:a,requestId:s,cached:l}=te(e,t);return{id:o,isLoaded:n,error:i,manifest:a,requestId:s,cached:l}}import{getImageServices as Be}from"@atlas-viewer/iiif-image-api";import{useEffect as Lt,useMemo as Le,useState as Y}from"react";function He({cacheKey:e}={}){let t=T(),o=D(),n=P(),i=W(),[a,s]=Y(void 0),[l,u]=Y(!1),[m,c]=Y("idle"),[f,x]=Y(void 0),h=t?t.id:"undefined",I=Le(()=>{try{if(t&&o.length){let d=o[0],p=n.get(d.body[0]),r=Be(p)[0];return r&&i.loadServiceSync({id:r.id||r["@id"],width:r.width||t.width,height:r.height||t.height})||void 0}}catch(d){console.error(d)}},[h,e,t]),g=m==="success"&&a?a:I;return Lt(()=>{(async()=>{try{if(t&&o.length){let d=o[0],p=n.get(d.body[0]),r=Be(p)[0];if(!r)return;u(!0),c("loading");try{let S=await i.loadService({id:r.id||r["@id"],width:r.width||t.width,height:r.height||t.height})||void 0;s(S),c("success"),u(!1)}catch(S){c("error"),x(S)}}}catch(d){c("error"),x(d)}})()},[h,e]),Le(()=>({data:g,isFetching:l,status:m,error:f}),[g,l,m,f])}function ia(){let e=He();return{isLoading:e.isFetching,tile:e.data?{id:e.data.id||e.data["@id"],width:e.data.width,height:e.data.height,imageService:e.data,thumbnail:void 0}:null}}import{createStylesHelper as Ht}from"@iiif/helpers/styles";import{useMemo as At}from"react";function ma(){let e=P();return At(()=>Ht(e),[e])}export*from"@iiif/helpers/annotation-targets";export{ui as AnnotationContext,gi as AnnotationPageContext,Br as AnnotationStyleProvider,yo as Auth,lo as AuthProvider,io as AuthRContext,ao as AuthReactContext,so as AuthReactContextActions,wn as CanvasAnnotations,oe as CanvasContext,ce as CanvasPanel,xi as CollectionContext,Fn as CombinedMetadata,bn as ComplexTimelineProvider,To as ContextBridge,Me as CreateCustomShape,ko as EventsProvider,Ze as Image,tn as ImageServiceLoaderContext,bo as InnerViewerProvider,Wo as LanguageProvider,Vo as LanguageString,N as LocaleString,Vt as ManifestContext,or as ManifestMetadata,vn as MediaPlayerProvider,O as Metadata,si as PolygonSelector,Yt as RangeContext,Io as ReactEventContext,Dt as ReactVaultContext,vr as RenderSvgEditorControls,B as ResourceProvider,Wt as ResourceReactContext,Tr as SelectorControllerProvider,gr as SequenceThumbnails,So as SimpleViewerProvider,xo as SimpleViewerReactContext,de as SingleCanvasThumbnail,qo as TranslationProvider,Do as TransliterationProvider,Ft as VaultProvider,No as ViewerPresetContext,Mo as VirtualAnnotationProvider,Xt as VisibleCanvasReactContext,oo as authDetailsForResource,eo as createAuthStateStore,to as createProbe,Co as defaultEmitter,Uo as emptyActions,Zo as emptyStrategy,Kt as findAllCanvasesInRange,_t as findFirstCanvasFromRange,Qt as findManifestSelectedRange,Ut as findSelectedRange,jo as flattenAnnotationPageIds,fn as formatTime,rn as get3dStrategy,cn as getComplexTimelineStrategy,Se as getDefaultAnnotationStyles,an as getImageStrategy,Jt as getManifestSequence,Qo as getParsedTargetSelector,mn as getRenderingStrategy,sn as getTextualContentStrategy,ln as getVideoStrategy,Gt as getVisibleCanvasesFromCanvasId,jt as hasAuth,ro as makeAccessServiceRequest,no as makeAccessTokenRequest,Ko as parseSpecificResource,Ct as svgThemes,Go as unknownResponse,Jo as unsupportedStrategy,Ao as useAnnotation,zo as useAnnotationPage,se as useAnnotationPageManager,Ce as useAnnotationStyles,Ii as useAnnotationsAtTime,uo as useAuthActions,po as useAuthService,mo as useAuthStore,ho as useAuthToken,go as useAuthTokens,T as useCanvas,Ei as useCanvasChoices,Ni as useCanvasClock,Zt as useCanvasSequence,xn as useCanvasStartTime,Ai as useCanvasSubset,Xo as useClosestLanguage,Fi as useCollection,Sn as useComplexTimeline,Po as useContextBridge,_o as useCreateLocaleString,fo as useCurrentAuth,wo as useDispatch,ae as useEventEmitter,Yi as useEventListener,Ot as useExistingVault,Ui as useExternalCollection,$t as useExternalManifest,te as useExternalResource,Oo as useIIIFLanguage,Q as useImage,He as useImageService,W as useImageServiceLoader,ia as useImageTile,co as useIsAuthEnabled,on as useLoadImageService,Yo as useLocaleString,q as useManifest,hn as useMediaActions,yn as useMediaElements,gn as useMediaState,nn as usePaintables,D as usePaintingAnnotations,Ie as usePolygonHelper,re as useRange,un as useRenderingStrategy,A as useResourceContext,Lo as useResourceEvents,en as useResources,vo as useSearchService,be as useSelectorController,wr as useSelectorEmitter,xe as useSelectorEvents,Rr as useSelectorHelper,pn as useSimpleMediaPlayer,ie as useSimpleViewer,ma as useStyleHelper,Ho as useStyles,Re as useSvgEditor,le as useThumbnail,$o as useTranslations,Fo as useTransliteration,P as useVault,dn as useVaultEffect,z as useVaultSelector,Bo as useViewerPreset,Ro as useVirtualAnnotationPage,Eo as useVirtualAnnotationPageContext,ne as useVisibleCanvases};
@@ -91,14 +91,16 @@ declare function get3dStrategy(canvas: CanvasNormalized, paintables: Paintables)
91
91
 
92
92
  type TextualContentStrategy = {
93
93
  type: 'textual-content';
94
- items: {
95
- annotationId: string;
96
- text: InternationalString;
97
- target: SupportedTarget | null;
98
- }[];
94
+ items: TextContent[];
99
95
  choice?: ChoiceDescription;
100
96
  annotations?: AnnotationPageDescription;
101
97
  };
98
+ type TextContent = {
99
+ type: 'Text';
100
+ annotationId: string;
101
+ text: InternationalString;
102
+ target: SupportedTarget | null;
103
+ };
102
104
  declare function getTextualContentStrategy(canvas: CanvasNormalized, paintables: Paintables): RenderingStrategy;
103
105
 
104
106
  type MediaStrategy = {
@@ -109,7 +111,7 @@ type MediaStrategy = {
109
111
  };
110
112
  type ComplexTimelineStrategy = {
111
113
  type: 'complex-timeline';
112
- items: Array<SingleImageStrategy['image'] | SingleAudio | SingleVideo | SingleYouTubeVideo>;
114
+ items: Array<SingleImageStrategy['image'] | SingleAudio | SingleVideo | SingleYouTubeVideo | TextContent>;
113
115
  keyframes: TimelineKeyframe[];
114
116
  duration: number;
115
117
  choice?: ChoiceDescription;
@@ -118,7 +120,7 @@ type ComplexTimelineStrategy = {
118
120
  interface TimelineKeyframe {
119
121
  id: string;
120
122
  type: 'enter' | 'exit' | 'change';
121
- resourceType: 'image' | 'audio' | 'video';
123
+ resourceType: 'image' | 'audio' | 'video' | 'text';
122
124
  timeDelta?: number;
123
125
  isPrime?: boolean;
124
126
  time: number;
@@ -168,4 +170,4 @@ type UseRenderingStrategyOptions = {
168
170
  };
169
171
  declare function useRenderingStrategy(options?: UseRenderingStrategyOptions): UseRenderingStrategy;
170
172
 
171
- export { type AudioSequence as A, type ComplexTimelineStrategy as C, type EmptyStrategy as E, type ImageWithOptionalService as I, type MediaStrategy as M, type RenderingStrategy as R, type StrategyActions as S, type TimelineKeyframe as T, type UnknownStrategy as U, type VideoSequence as V, type SingleImageStrategy as a, type SingleAudio as b, type SingleVideo as c, type ImageServiceLoaderType as d, type SingleYouTubeVideo as e, type AnnotationPageDescription as f, getImageStrategy as g, type TextualContentStrategy as h, getTextualContentStrategy as i, type Single3DModelStrategy as j, get3dStrategy as k, type UseRenderingStrategy as l, type ChoiceEvents as m, type UseRenderingStrategyOptions as n, useRenderingStrategy as o, useLoadImageService as u };
173
+ export { type AudioSequence as A, type ComplexTimelineStrategy as C, type EmptyStrategy as E, type ImageWithOptionalService as I, type MediaStrategy as M, type RenderingStrategy as R, type StrategyActions as S, type TimelineKeyframe as T, type UnknownStrategy as U, type VideoSequence as V, type SingleImageStrategy as a, type SingleAudio as b, type SingleVideo as c, type ImageServiceLoaderType as d, type SingleYouTubeVideo as e, type AnnotationPageDescription as f, getImageStrategy as g, type TextualContentStrategy as h, type TextContent as i, getTextualContentStrategy as j, type Single3DModelStrategy as k, get3dStrategy as l, type UseRenderingStrategy as m, type ChoiceEvents as n, type UseRenderingStrategyOptions as o, useRenderingStrategy as p, useLoadImageService as u };
@@ -91,14 +91,16 @@ declare function get3dStrategy(canvas: CanvasNormalized, paintables: Paintables)
91
91
 
92
92
  type TextualContentStrategy = {
93
93
  type: 'textual-content';
94
- items: {
95
- annotationId: string;
96
- text: InternationalString;
97
- target: SupportedTarget | null;
98
- }[];
94
+ items: TextContent[];
99
95
  choice?: ChoiceDescription;
100
96
  annotations?: AnnotationPageDescription;
101
97
  };
98
+ type TextContent = {
99
+ type: 'Text';
100
+ annotationId: string;
101
+ text: InternationalString;
102
+ target: SupportedTarget | null;
103
+ };
102
104
  declare function getTextualContentStrategy(canvas: CanvasNormalized, paintables: Paintables): RenderingStrategy;
103
105
 
104
106
  type MediaStrategy = {
@@ -109,7 +111,7 @@ type MediaStrategy = {
109
111
  };
110
112
  type ComplexTimelineStrategy = {
111
113
  type: 'complex-timeline';
112
- items: Array<SingleImageStrategy['image'] | SingleAudio | SingleVideo | SingleYouTubeVideo>;
114
+ items: Array<SingleImageStrategy['image'] | SingleAudio | SingleVideo | SingleYouTubeVideo | TextContent>;
113
115
  keyframes: TimelineKeyframe[];
114
116
  duration: number;
115
117
  choice?: ChoiceDescription;
@@ -118,7 +120,7 @@ type ComplexTimelineStrategy = {
118
120
  interface TimelineKeyframe {
119
121
  id: string;
120
122
  type: 'enter' | 'exit' | 'change';
121
- resourceType: 'image' | 'audio' | 'video';
123
+ resourceType: 'image' | 'audio' | 'video' | 'text';
122
124
  timeDelta?: number;
123
125
  isPrime?: boolean;
124
126
  time: number;
@@ -168,4 +170,4 @@ type UseRenderingStrategyOptions = {
168
170
  };
169
171
  declare function useRenderingStrategy(options?: UseRenderingStrategyOptions): UseRenderingStrategy;
170
172
 
171
- export { type AudioSequence as A, type ComplexTimelineStrategy as C, type EmptyStrategy as E, type ImageWithOptionalService as I, type MediaStrategy as M, type RenderingStrategy as R, type StrategyActions as S, type TimelineKeyframe as T, type UnknownStrategy as U, type VideoSequence as V, type SingleImageStrategy as a, type SingleAudio as b, type SingleVideo as c, type ImageServiceLoaderType as d, type SingleYouTubeVideo as e, type AnnotationPageDescription as f, getImageStrategy as g, type TextualContentStrategy as h, getTextualContentStrategy as i, type Single3DModelStrategy as j, get3dStrategy as k, type UseRenderingStrategy as l, type ChoiceEvents as m, type UseRenderingStrategyOptions as n, useRenderingStrategy as o, useLoadImageService as u };
173
+ export { type AudioSequence as A, type ComplexTimelineStrategy as C, type EmptyStrategy as E, type ImageWithOptionalService as I, type MediaStrategy as M, type RenderingStrategy as R, type StrategyActions as S, type TimelineKeyframe as T, type UnknownStrategy as U, type VideoSequence as V, type SingleImageStrategy as a, type SingleAudio as b, type SingleVideo as c, type ImageServiceLoaderType as d, type SingleYouTubeVideo as e, type AnnotationPageDescription as f, getImageStrategy as g, type TextualContentStrategy as h, type TextContent as i, getTextualContentStrategy as j, type Single3DModelStrategy as k, get3dStrategy as l, type UseRenderingStrategy as m, type ChoiceEvents as n, type UseRenderingStrategyOptions as o, useRenderingStrategy as p, useLoadImageService as u };
package/dist/utils.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var T=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var O=Object.prototype.hasOwnProperty;var A=(e,t)=>{for(var i in t)T(e,i,{get:t[i],enumerable:!0})},V=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of D(t))!O.call(e,o)&&o!==i&&T(e,o,{get:()=>t[o],enumerable:!(r=B(t,o))||r.enumerable});return e};var U=e=>V(T({},"__esModule",{value:!0}),e);var F={};A(F,{emptyActions:()=>M,emptyStrategy:()=>C,getParsedTargetSelector:()=>y,getRenderingStrategy:()=>Y,parseSpecificResource:()=>W,unknownResponse:()=>f,unsupportedStrategy:()=>m});module.exports=U(F);var w=require("@iiif/helpers");function W(e){return e.type==="SpecificResource"?[e.source,{selector:e.selector}]:[e,{selector:null}]}function y(e,t){let{selector:i,source:r}=(0,w.expandTarget)(t);if(r.id!==e.id)return[null,r];let o={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}};return[i?i.type==="TemporalSelector"?{type:"TemporalBoxSelector",temporal:i.temporal,spatial:o.spatial}:i:null,r]}var M={makeChoice:()=>{}},f={type:"unknown"},m=e=>({type:"unknown",reason:e,annotations:{pages:[]}}),C=(e,t)=>({type:"empty",width:e,height:t,annotations:{pages:[]},image:null,images:[]});var L=["model/gltf-binary"];function P(e,t){let r=t.items[0].resource;return r.format?L.indexOf(r.format)===-1?m(`3D format: ${r.format} is unsupported`):{type:"3d-model",model:r}:m("Unknown format")}function b(e,t){if(!e.duration)return m("No duration on canvas");if(t.items.length>1)return m("Only one audio source supported");let i=t.items[0]?.resource;return i?i.format?{type:"media",media:{annotationId:t.items[0].annotationId,duration:e.duration,url:i.id,type:"Sound",target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:i.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},annotations:{pages:[]}}:m("Audio does not have format"):m("Unknown audio")}var v=require("@atlas-viewer/iiif-image-api");var I=require("@iiif/helpers/annotation-targets");function S(e,t,i){let r=[];for(let o of t.items){let s=o.resource&&o.resource.type==="SpecificResource"?o.resource.source:o.resource;if(!s.id)return m("No resource Identifier");let p;if(s.service){let g=(0,v.getImageServices)(s);g[0]&&(p=i(g[0],e))}let d={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}},[n,a]=y(e,o.target);if(!(a.id===e.id||decodeURIComponent(a.id||"")===(e.id||"")))continue;let c=o.resource.width&&o.resource.height?{type:"BoxSelector",spatial:{x:0,y:0,width:o.resource.width,height:o.resource.height}}:void 0,l=o.resource.type==="SpecificResource"?(0,I.expandTarget)(o.resource):null;if(o.selector){let g=(0,I.expandTarget)({type:"SpecificResource",source:o.resource,selector:o.selector});g&&(l=g)}let u=l&&l.selector&&(l.selector.type==="BoxSelector"||l.selector.type==="TemporalBoxSelector")?{type:"BoxSelector",spatial:{x:l.selector.spatial.x,y:l.selector.spatial.y,width:l.selector.spatial.width,height:l.selector.spatial.height}}:void 0;p&&!p.id&&(p.id=p["@id"]);let z={id:s.id,type:"Image",annotationId:o.annotationId,width:Number(n||u?s.width:e.width),height:Number(n||u?s.height:e.height),service:p,sizes:p&&p.sizes?p.sizes:s.width&&s.height?[{width:s.width,height:s.height}]:[],target:n&&n.type!=="PointSelector"?n:d,selector:u||{type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}}};r.push(z)}return{type:"images",image:r[0],images:r,choice:t.choice}}function R(e,t={},i){let r=e.language||i||"none";switch(e.type){case"TextualBody":{typeof e.value<"u"&&(t[r]=e.value);break}case"List":case"Composite":case"Choice":e.items&&e.items.forEach(o=>R(o,t,r))}return t}function k(e,t){let i=[];return t.items.forEach(r=>{if(r.resource){let[o]=y(e,r.target);i.push({annotationId:r.annotationId,text:R(r.resource),target:o})}}),{type:"textual-content",items:i}}var h=require("@iiif/helpers"),E=/^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\/)|(?:(?:watch)?\?vi?=|&vi?=))([^#&?]*).*/;function x(e,t){let i=t.items.filter(c=>c.type==="video"),r=!1;if(e.duration||(r=!0),i.length>1)return m("Only one video source supported");let o=i[0]?.resource,s=!!(o.service||[]).find(c=>(c.profile||"").includes("youtube.com"));if(!s&&r)return m("Video does not have duration");if(!o)return m("Unknown video");if((!o.format||o.format==="text/html")&&!s)return m("Video does not have format");let p=t.items[0],d={annotationId:t.items[0].annotationId,duration:e.duration,url:o.id,type:"Video",target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:o.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},n=(0,h.expandTarget)(p.target);n.selector&&n.selector.type==="TemporalBoxSelector"&&(d.target=n.selector);let{selector:a}=(0,h.parseSelector)(p.selector);if(a===null){let c=d.target.temporal.startTime,u=(d.target.temporal.endTime||e.duration)-c;d.selector={type:"TemporalSelector",temporal:{startTime:0,endTime:u}}}else a.type==="TemporalSelector"&&(d.selector=a);if(s){d.type="VideoYouTube";let c=o.id.match(E);if(!c[1])return m("Video is not known youtube video");d.youTubeId=c[1]}return{type:"media",media:d,annotations:{pages:[]}}}function N(e,t,i){let r={type:"complex-timeline",items:[],keyframes:[],duration:e.duration||0},o={type:"complex-choice",items:[]};function s(n){n.choice&&(n.choice.type==="complex-choice"?o.items.push(...n.choice.items):o.items.push(n.choice))}for(let n of t.items){if(n.type==="image"){let a=S(e,{choice:null,allChoices:null,types:["image"],items:[n]},i);if(a.type==="images"){s(a),r.items.push(a.image);let c={id:a.image.annotationId,type:"enter",resourceType:"image",time:a.image.target?.temporal?.startTime||0};r.keyframes.push(c);let l={id:a.image.annotationId,type:"exit",resourceType:"image",time:a.image.target?.temporal?.endTime||e.duration||0};r.keyframes.push(l)}}if(n.type==="video"){let a=x(e,{choice:null,allChoices:null,types:["video"],items:[n]});if(a.type==="media"){s(a);let c=a.media;r.items.push(c);let l={id:c.annotationId,type:"enter",resourceType:"video",time:c.target?.temporal?.startTime||0};r.keyframes.push(l);let u={id:c.annotationId,type:"exit",resourceType:"video",time:c.target?.temporal?.endTime||e.duration||0};r.keyframes.push(u)}}}r.keyframes.sort((n,a)=>n.time-a.time);let p=[],d=[];for(let n of r.keyframes){if(n.resourceType==="image"){d.push(n);continue}if(n.type==="enter"){p.length===0&&(n.isPrime=!0),p.push(n),d.push(n);continue}if(n.type==="exit"&&(d.push(n),p=p.filter(a=>a.id!==n.id),p.length!==0)){let a=p[0],c={id:a.id,type:"change",isPrime:!0,resourceType:a.resourceType,time:n.time};d.push(c)}}return r.keyframes=d,o.items.length&&(r.choice=o),r}function Y({canvas:e,paintables:t,supports:i,loadImageService:r}){if(!e)return f;if(t.types.length===0)return i.indexOf("empty")!==-1?C(e.width,e.height):f;if(t.types.length!==1)if(t.types.length===2&&t.types.indexOf("text")!==-1)t.types=t.types.filter(s=>s!=="text");else return i.indexOf("complex-timeline")===-1?m("Complex timeline not supported"):N(e,t,r);let o=t.types[0];return o==="image"?i.indexOf("images")===-1?m("Image not supported"):S(e,t,r):o==="Model"||o==="model"?i.indexOf("3d-model")===-1?m("3D not supported"):P(e,t):o==="textualbody"?i.indexOf("textual-content")===-1?m("Textual content not supported"):k(e,t):o==="sound"||o==="audio"?i.indexOf("media")===-1?m("Media not supported"):b(e,t):o==="video"?i.indexOf("media")===-1?m("Media not supported"):x(e,t):f}
1
+ "use strict";var I=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var O=Object.prototype.hasOwnProperty;var A=(e,t)=>{for(var i in t)I(e,i,{get:t[i],enumerable:!0})},V=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of D(t))!O.call(e,o)&&o!==i&&I(e,o,{get:()=>t[o],enumerable:!(r=B(t,o))||r.enumerable});return e};var U=e=>V(I({},"__esModule",{value:!0}),e);var F={};A(F,{emptyActions:()=>M,emptyStrategy:()=>w,getParsedTargetSelector:()=>y,getRenderingStrategy:()=>Y,parseSpecificResource:()=>W,unknownResponse:()=>f,unsupportedStrategy:()=>m});module.exports=U(F);var P=require("@iiif/helpers");function W(e){return e.type==="SpecificResource"?[e.source,{selector:e.selector}]:[e,{selector:null}]}function y(e,t){let{selector:i,source:r}=(0,P.expandTarget)(t);if(r.id!==e.id)return[null,r];let o={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}};return[i?i.type==="TemporalSelector"?{type:"TemporalBoxSelector",temporal:i.temporal,spatial:o.spatial}:i:null,r]}var M={makeChoice:()=>{}},f={type:"unknown"},m=e=>({type:"unknown",reason:e,annotations:{pages:[]}}),w=(e,t)=>({type:"empty",width:e,height:t,annotations:{pages:[]},image:null,images:[]});var L=["model/gltf-binary"];function k(e,t){let r=t.items[0].resource;return r.format?L.indexOf(r.format)===-1?m(`3D format: ${r.format} is unsupported`):{type:"3d-model",model:r}:m("Unknown format")}function R(e,t){if(!e.duration)return m("No duration on canvas");if(t.items.length>1)return m("Only one audio source supported");let i=t.items[0]?.resource;return i?i.format?{type:"media",media:{annotationId:t.items[0].annotationId,duration:e.duration,url:i.id,type:"Sound",target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:i.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},annotations:{pages:[]}}:m("Audio does not have format"):m("Unknown audio")}var v=require("@atlas-viewer/iiif-image-api");var b=require("@iiif/helpers/annotation-targets");function S(e,t,i){let r=[];for(let o of t.items){let p=o.resource&&o.resource.type==="SpecificResource"?o.resource.source:o.resource;if(!p.id)return m("No resource Identifier");let c;if(p.service){let g=(0,v.getImageServices)(p);g[0]&&(c=i(g[0],e))}let u={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}},[n,a]=y(e,o.target);if(!(a.id===e.id||decodeURIComponent(a.id||"")===(e.id||"")))continue;let s=o.resource.width&&o.resource.height?{type:"BoxSelector",spatial:{x:0,y:0,width:o.resource.width,height:o.resource.height}}:void 0,d=o.resource.type==="SpecificResource"?(0,b.expandTarget)(o.resource):null;if(o.selector){let g=(0,b.expandTarget)({type:"SpecificResource",source:o.resource,selector:o.selector});g&&(d=g)}let l=d&&d.selector&&(d.selector.type==="BoxSelector"||d.selector.type==="TemporalBoxSelector")?{type:"BoxSelector",spatial:{x:d.selector.spatial.x,y:d.selector.spatial.y,width:d.selector.spatial.width,height:d.selector.spatial.height}}:void 0;c&&!c.id&&(c.id=c["@id"]);let C={id:p.id,type:"Image",annotationId:o.annotationId,width:Number(n||l?p.width:e.width),height:Number(n||l?p.height:e.height),service:c,sizes:c&&c.sizes?c.sizes:p.width&&p.height?[{width:p.width,height:p.height}]:[],target:n&&n.type!=="PointSelector"?n:u,selector:l||{type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}}};r.push(C)}return{type:"images",image:r[0],images:r,choice:t.choice}}function N(e,t={},i){let r=e.language||i||"none";switch(e.type){case"TextualBody":{typeof e.value<"u"&&(t[r]=[e.value]);break}case"List":case"Composite":case"Choice":e.items&&e.items.forEach(o=>N(o,t,r))}return t}function h(e,t){let i=[];return t.items.forEach(r=>{if(r.resource){let[o]=y(e,r.target);i.push({type:"Text",annotationId:r.annotationId,text:N(r.resource),target:o})}}),{type:"textual-content",items:i}}var x=require("@iiif/helpers"),E=/^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\/)|(?:(?:watch)?\?vi?=|&vi?=))([^#&?]*).*/;function T(e,t){let i=t.items.filter(s=>s.type==="video"),r=!1;if(e.duration||(r=!0),i.length>1)return m("Only one video source supported");let o=i[0]?.resource,p=!!(o.service||[]).find(s=>(s.profile||"").includes("youtube.com"));if(!p&&r)return m("Video does not have duration");if(!o)return m("Unknown video");if((!o.format||o.format==="text/html")&&!p)return m("Video does not have format");let c=t.items[0],u={annotationId:t.items[0].annotationId,duration:e.duration,url:o.id,type:"Video",target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:o.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},n=(0,x.expandTarget)(c.target);n.selector&&n.selector.type==="TemporalBoxSelector"&&(u.target=n.selector);let{selector:a}=(0,x.parseSelector)(c.selector);if(a===null){let s=u.target.temporal.startTime,l=(u.target.temporal.endTime||e.duration)-s;u.selector={type:"TemporalSelector",temporal:{startTime:0,endTime:l}}}else a.type==="TemporalSelector"&&(u.selector=a);if(p){u.type="VideoYouTube";let s=o.id.match(E);if(!s[1])return m("Video is not known youtube video");u.youTubeId=s[1]}return{type:"media",media:u,annotations:{pages:[]}}}function z(e,t,i){let r={type:"complex-timeline",items:[],keyframes:[],duration:e.duration||0},o={type:"complex-choice",items:[]};function p(n){n.choice&&(n.choice.type==="complex-choice"?o.items.push(...n.choice.items):o.items.push(n.choice))}for(let n of t.items){if(n.type==="image"){let a=S(e,{choice:null,allChoices:null,types:["image"],items:[n]},i);if(a.type==="images"){p(a),r.items.push(a.image);let s={id:a.image.annotationId,type:"enter",resourceType:"image",time:a.image.target?.temporal?.startTime||0};r.keyframes.push(s);let d={id:a.image.annotationId,type:"exit",resourceType:"image",time:a.image.target?.temporal?.endTime||e.duration||0};r.keyframes.push(d)}}if(n.type==="textualbody"){let a=h(e,{choice:null,allChoices:null,types:["textualbody"],items:[n]});if(a.type==="textual-content"){p(a);let s=a.items[0];r.items.push(s);let d=s.target,l={id:s.annotationId,type:"enter",resourceType:"text",time:d.temporal?.startTime||0};r.keyframes.push(l);let C={id:s.annotationId,type:"exit",resourceType:"text",time:d.temporal?.endTime||e.duration||0};r.keyframes.push(C)}}if(n.type==="video"){let a=T(e,{choice:null,allChoices:null,types:["video"],items:[n]});if(a.type==="media"){p(a);let s=a.media;r.items.push(s);let d={id:s.annotationId,type:"enter",resourceType:"video",time:s.target?.temporal?.startTime||0};r.keyframes.push(d);let l={id:s.annotationId,type:"exit",resourceType:"video",time:s.target?.temporal?.endTime||e.duration||0};r.keyframes.push(l)}}}r.keyframes.sort((n,a)=>n.time-a.time);let c=[],u=[];for(let n of r.keyframes){if(n.resourceType==="image"||n.resourceType==="text"){u.push(n);continue}if(n.type==="enter"){c.length===0&&(n.isPrime=!0),c.push(n),u.push(n);continue}if(n.type==="exit"&&(u.push(n),c=c.filter(a=>a.id!==n.id),c.length!==0)){let a=c[0],s={id:a.id,type:"change",isPrime:!0,resourceType:a.resourceType,time:n.time};u.push(s)}}return r.keyframes=u,o.items.length&&(r.choice=o),r}function Y({canvas:e,paintables:t,supports:i,loadImageService:r}){if(!e)return f;if(t.types.length===0)return i.indexOf("empty")!==-1?w(e.width,e.height):f;if(t.types.length!==1)if(t.types.length===2&&t.types.indexOf("text")!==-1)t.types=t.types.filter(p=>p!=="text");else return i.indexOf("complex-timeline")===-1?m("Complex timeline not supported"):z(e,t,r);let o=t.types[0];return o==="image"?i.indexOf("images")===-1?m("Image not supported"):S(e,t,r):o==="Model"||o==="model"?i.indexOf("3d-model")===-1?m("3D not supported"):k(e,t):o==="textualbody"?i.indexOf("textual-content")===-1?m("Textual content not supported"):h(e,t):o==="sound"||o==="audio"?i.indexOf("media")===-1?m("Media not supported"):R(e,t):o==="video"?i.indexOf("media")===-1?m("Media not supported"):T(e,t):f}
package/dist/utils.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { l as UseRenderingStrategy, U as UnknownStrategy, R as RenderingStrategy, d as ImageServiceLoaderType } from './useRenderingStrategy-DUTiqfD8.cjs';
1
+ import { m as UseRenderingStrategy, U as UnknownStrategy, R as RenderingStrategy, d as ImageServiceLoaderType } from './useRenderingStrategy-2EaRC2Nc.cjs';
2
2
  import { CanvasNormalized } from '@iiif/presentation-3-normalized';
3
3
  import { Paintables } from '@iiif/helpers/painting-annotations';
4
4
  import { ContentResource, W3CAnnotationTarget, PointSelector } from '@iiif/presentation-3';
package/dist/utils.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { l as UseRenderingStrategy, U as UnknownStrategy, R as RenderingStrategy, d as ImageServiceLoaderType } from './useRenderingStrategy-DUTiqfD8.js';
1
+ import { m as UseRenderingStrategy, U as UnknownStrategy, R as RenderingStrategy, d as ImageServiceLoaderType } from './useRenderingStrategy-2EaRC2Nc.js';
2
2
  import { CanvasNormalized } from '@iiif/presentation-3-normalized';
3
3
  import { Paintables } from '@iiif/helpers/painting-annotations';
4
4
  import { ContentResource, W3CAnnotationTarget, PointSelector } from '@iiif/presentation-3';
package/dist/utils.js CHANGED
@@ -1 +1 @@
1
- import{a as o,b as r,c as e,d as f,e as m,f as p,l as t}from"./chunk-FZEYDVWC.js";export{e as emptyActions,p as emptyStrategy,r as getParsedTargetSelector,t as getRenderingStrategy,o as parseSpecificResource,f as unknownResponse,m as unsupportedStrategy};
1
+ import{a as o,b as r,c as e,d as f,e as m,f as p,l as t}from"./chunk-QCPOOHCR.js";export{e as emptyActions,p as emptyStrategy,r as getParsedTargetSelector,t as getRenderingStrategy,o as parseSpecificResource,f as unknownResponse,m as unsupportedStrategy};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-iiif-vault",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
@@ -1,48 +0,0 @@
1
- import{c as vt,l as ht}from"./chunk-FZEYDVWC.js";import{forwardRef as Zn,useImperativeHandle as Vi}from"react";import sn,{useCallback as et,useMemo as un,useState as Re}from"react";import{AtlasAuto as fo,ModeContext as po}from"@atlas-viewer/atlas";import{ErrorBoundary as go}from"react-error-boundary";import{useContext as Q}from"react";import Xn,{useContext as er,useMemo as tr}from"react";import{jsx as rr}from"react/jsx-runtime";var nr={collection:void 0,manifest:void 0,range:void 0,canvas:void 0,annotation:void 0,annotationPage:void 0},Ce=Xn.createContext(nr),H=()=>er(Ce);function _({value:e,children:n}){let t=H(),r=tr(()=>({...t,...e}),[e,t]);return rr(Ce.Provider,{value:r,children:n})}import or,{useState as ir}from"react";import{Vault as yt,globalVault as ar}from"@iiif/helpers/vault";import{jsx as St}from"react/jsx-runtime";var Y=or.createContext({vault:null,setVaultInstance:e=>{}});function J({vault:e,vaultOptions:n,useGlobal:t,resources:r,children:o}){let[a,s]=ir(()=>e||(t?ar(n):n?new yt(n):new yt));return St(Y.Provider,{value:{vault:a,setVaultInstance:s},children:St(_,{value:r||{},children:o})})}import{useContext as $r}from"react";import{createContext as Dr,useMemo as Ur}from"react";import{globalVault as sr}from"@iiif/helpers/vault";import{useContext as ur}from"react";function X(e){let n=ur(Y);return e||(n&&n.vault?n.vault:sr())}import{useEffect as cr,useMemo as lr,useState as qe}from"react";function xt(e,{noCache:n=!1}={}){let t=typeof e=="string"?e:e.id,r=X(),[o,a]=qe(t),[s,i]=qe(void 0),u=lr(()=>r.get(t,{skipSelfReturn:!0})||void 0,[t,r]),[c,l]=qe(u);return cr(()=>{(async()=>{try{let d=u&&!n?u:await r.load(t),y=d?d.id||d["@id"]:null;d&&o!==y&&a(y),l(d)}catch(d){i(d)}})()},[t,n]),{isLoaded:!!c,id:o,requestId:t,error:s,resource:c,cached:!!(c&&c===u)}}function Ct(e,n){let{id:t,isLoaded:r,error:o,resource:a,requestId:s,cached:i}=xt(e,n);return{id:t,isLoaded:r,error:o,manifest:a,requestId:s,cached:i}}import{jsx as dr}from"react/jsx-runtime";function At({manifest:e,children:n}){return dr(_,{value:{manifest:e},children:n})}import{jsx as mr}from"react/jsx-runtime";function q({canvas:e,children:n}){return mr(_,{value:{canvas:e},children:n})}import{useContext as vr}from"react";import hr from"react";import{useContext as fr}from"react";var R=()=>{let{vault:e}=fr(Y);if(e===null)throw new Error("Vault not found. Ensure you have your provider set up correctly.");return e};import{useEffect as pr,useState as gr}from"react";function T(e,n=[]){let t=R(),[r,o]=gr(()=>e(t.getState(),t));return pr(()=>t.subscribe(a=>e(a,t),a=>{o(a)},!1),n),r}var ee=hr.createContext([]);function Ae(){let e=vr(ee);return T(n=>e.map(t=>n.iiif.entities.Canvas[t]).filter(Boolean),[e])}import{useMemo as yr}from"react";function V(e={},n=[]){let{id:t,selector:r}=e,o=H(),a=R(),s=t||o.manifest,i=T(u=>s?u.iiif.entities.Manifest[s]:void 0,[s]);return yr(()=>{if(i)return r?r(i):i},[i,r,...n])}import{jsx as Sr}from"react/jsx-runtime";function bt({range:e,children:n}){return Sr(_,{value:{range:e},children:n})}function xr(e,n){for(let t of n.items){if(t.type==="Canvas")return t;if(t.type==="SpecificResource")return t.source;if(t.type==="Range"){let r=xr(e,e.get(t));if(r)return r}}return null}function Be(e,n){let t=[];for(let r of n.items)if(r.type==="SpecificResource"&&r.source?.type==="Canvas"&&(r.source.id.indexOf("#")!==-1?t.push({id:r.source.id.split("#")[0],type:"Canvas"}):t.push(r.source)),r.type==="Range"&&t.push(...Be(e,e.get(r))),r.type==="SpecificResource"){let o=typeof r.source=="string"?r.source:r.source.id;t.push({id:o,type:"Canvas"})}return t}function Va(e,n,t){for(let r of n.structures){let o=Pt(e,e.get(r),t);if(o)return o}return null}function Pt(e,n,t){for(let r of n.items){let o=r?.source?.id?.split("#")[0];if(r.type==="SpecificResource"&&r.source===t||r.type==="SpecificResource"&&r.source?.type==="Canvas"&&t===o)return n;if(r.type==="Range"){let a=Pt(e,e.get(r),t);if(a)return a}}return null}function La(e,n,t,r=!1){let o=n.behavior,a=t?e.get(t):null;if(!a)return[];let s=a.behavior,i=r?!1:o.includes("paged"),u=i?!1:o.includes("continuous"),c=i||u?!1:o.includes("individuals"),l=s.includes("facing-pages"),d=s.includes("non-paged");if(l||d||c||r)return[{id:a.id,type:"Canvas"}];let[y,A]=_e(e,n);if(u)return y;let h=y.findIndex(g=>g.id===t);if(h===-1)return[];for(let g of A)if(g.includes(h))return g.map(b=>y[b]);return[{id:a.id,type:"Canvas"}]}function _e(e,n,{disablePaging:t,skipNonPaged:r}={}){let o=n.behavior,a=o.includes("paged"),s=a?!1:o.includes("continuous"),i=a||s?!1:o.includes("individuals"),u=n.type==="Manifest"?n.items:Be(e,n);if(s)return[u,[u.map((h,g)=>g)]];if(i||!a||t)return[u,u.map((h,g)=>[g])];let c=[],l=[],d=()=>{l.length&&(c.push([...l]),l=[])},y=0,A=!1;for(let h=0;h<u.length;h++){let g=e.get(u[h]);if(g.behavior.includes("non-paged")){h===y&&y++,r||(d(),c.push([h]),d());continue}if(h===y||g.behavior.includes("facing-pages")){l.length&&(A=!0),d(),c.push([h]),d();continue}if(l.push(h),A){d(),A=!1;continue}l.length>1&&d()}return l.length&&d(),[u,c]}import{useCallback as be,useMemo as Ar,useRef as br,useState as Pr}from"react";import{useMemo as Cr}from"react";function Rt(e={},n=[]){let{id:t,selector:r}=e,o=H(),a=t||o.range,s=T(i=>a?i.iiif.entities.Range[a]:void 0,[a]);return Cr(()=>{if(s)return r?r(s):s},[s,r,...n])}function Tt({startCanvas:e,disablePaging:n}){let t=R(),r=V(),o=Rt(),[a,s]=Pr(void 0),i=o||r;if(!i)throw new Error("Nothing selected");let[u,c]=Ar(()=>_e(t,i,{disablePaging:n}),[t,i,n]),l=br(c);if(l.current!==c){let b=l.current[a][0],p=c.findIndex(S=>S.includes(b));l.current=c,s(p)}let d=be(g=>{let b=c.findIndex(p=>p.includes(g));s(b===-1?0:b)},[u,c]),y=be(g=>{let b=u.findIndex(p=>p.id===g);b!==-1?d(b):s(0)},[u,c]),A=be(()=>{s(g=>g>=c.length-1?g:g+1)},[c]),h=be(()=>{s(g=>g<=0?0:g-1)},[c]);return typeof a>"u"&&(e?y(e):s(0)),{visibleItems:c[a]?.map(g=>u[g].id)||[],cursor:a,items:u,sequence:c,hasPrevious:a>0,hasNext:a<c.length-1,setSequenceIndex:s,setCanvasIndex:d,setCanvasId:y,next:A,previous:h}}import{createContext as Ye,useContext as Ht,useEffect as Tr,useMemo as Ir}from"react";import{useStore as me}from"zustand";import{createStore as Mt}from"zustand/vanilla";function Ya(e){let n=e.service||e.services||[];for(let t of n)if(t.type==="AuthProbeService2")return!0;return!1}function F(e,n,t){let r=n.findIndex(s=>s.service.id===e);if(r===-1)return n;let o=[...n],a=t(o[r]);return a===o[r]?n:(o[r]=a,o)}var wt=()=>Mt((e,n)=>({currentAuth:-1,authItems:[],login:()=>{let t=n().authItems[n().currentAuth];if(!t||t.isPending||t.isLoggedIn)return;if(t.type!=="active")throw new Error("Cannot login to non-active service");let r=t.service.service.find(o=>o.type==="AuthAccessTokenService2");if(!r)throw new Error("Token service not found");e(()=>({authItems:F(t.id,n().authItems,o=>({...o,isPending:!0}))})),It(t.service).then(()=>{je(r).then(o=>{let a=o.expiresIn,s=Date.now()+a*1e3;e(()=>({authItems:F(t.id,n().authItems,i=>({...i,isLoggedIn:!0,isPending:!1,session:{token:o.accessToken,expires:s}}))}))}).catch(o=>{e(()=>({authItems:F(t.id,n().authItems,a=>({...a,isLoggedIn:!1,isPending:!1,error:o.message}))}))})})},logout:()=>{let t=n().authItems[n().currentAuth];if(!t||t.isPending||!t.isLoggedIn)return;if(t.type!=="active")throw new Error("Cannot logout of non-active service");let r=t.service.service.find(s=>s.type==="AuthLogoutService2");if(!r)return;let o=`${r.id}?origin=${kt()}`,a=window.open(o);e(()=>({authItems:F(t.id,n().authItems,s=>({...s,isLoggedIn:!1,session:null,isPending:!1}))}))},nextAuth:()=>{let t=n().authItems.length,r=n().currentAuth+1;r>=t||e(()=>({currentAuth:r}))},previousAuth:()=>{let t=n().currentAuth-1;t<0||e(()=>({currentAuth:t}))},setAuth:t=>{t!==-1&&(t<0||t>=n().authItems.length)||e(()=>({currentAuth:t}))},addService:(t,r)=>{if(!t.service)return;let o=t.service.find(i=>i.type==="AuthAccessTokenService2"),a=t;if(n().authItems.find(i=>i.service.id===t.id)){e(()=>({authItems:F(t.id,n().authItems,i=>({...i,instances:i.instances+1}))}));return}if(e(()=>({currentAuth:a.profile==="active"?0:n().currentAuth,authItems:[{id:t.id,type:t.profile,service:t,probeId:r,canAuthenticate:!0,instances:1,isPending:!1,isLoggedIn:!1,session:null},...n().authItems]})),t.profile==="external"){if(!o)throw new Error("Token service not found");je(o).then(i=>{e(()=>({authItems:F(t.id,n().authItems,u=>({...u,isLoggedIn:!0,isPending:!1,session:{token:i.accessToken,expires:i.expiresIn}}))}))}).catch(i=>{e(()=>({authItems:F(t.id,n().authItems,u=>({...u,isLoggedIn:!1,isPending:!1,canAuthenticate:!1,error:i.message}))}))})}if(t.profile==="kiosk"){if(!o)throw new Error("Token service not found");e(()=>({authItems:F(t.id,n().authItems,i=>({...i,isPending:!0}))})),It(a).then(()=>{je(o).then(i=>{e(()=>({authItems:F(t.id,n().authItems,u=>({...u,isLoggedIn:!0,isPending:!1,session:{token:i.accessToken,expires:i.expiresIn}}))}))}).catch(i=>{e(()=>({authItems:F(t.id,n().authItems,u=>({...u,isLoggedIn:!1,isPending:!1,error:i.message}))}))})})}t.profile},removeService:(t,r)=>{let o=n().currentAuth===n().authItems.findIndex(s=>s.service.id===t.id),a=n().currentAuth;if(o){let s=n().authItems.find(u=>u.service.id===t.id);s&&s.instances>1||(a=n().authItems.findIndex(c=>c.service.id!==t.id&&c.instances>0))}e(()=>({authItems:F(t.id,n().authItems,s=>({...s,instances:s.instances-1})),currentAuth:a}))}})),Et=(e,n)=>Mt((t,r)=>({service:e,status:e?"unknown":"success",shouldRedirect:!1,redirectResource:null,shouldSubstitute:!1,substituteResource:null,error:null,errorHeading:null,errorNote:null,shouldDisplayResource:!1,token:n||null,async probe(){if(!r().service)return;let o=r().service?.id;if(!o){t({status:"error",error:"Service ID not found",errorHeading:{en:["Service ID not found"]}});return}t({status:"probing"});let a=r().token;try{let s=await fetch(o,{headers:a?{Authorization:`Bearer ${r().token}`,Accept:"application/json"}:{Accept:"application/json"}}).then(i=>i.json());if(s.status===200)t({status:"success",shouldDisplayResource:!0,error:null,errorHeading:null,errorNote:null,shouldSubstitute:!1,shouldRedirect:!1});else if(s.status<400&&s.status>=300){if(!s.location)throw new Error("Redirect location not found");t({status:"error",shouldDisplayResource:!1,shouldRedirect:!0,redirectResource:s.location||null})}else if(s.status===401)t({status:"error",shouldDisplayResource:!1,shouldRedirect:!1,shouldSubstitute:!!s.substitute,substituteResource:s.substitute||null,error:"Unauthorized",errorHeading:s.heading||{en:["Unauthorized"]},errorNote:s.note||null});else throw new Error("Unknown error")}catch(s){t({status:"error",error:s.message,errorHeading:{en:["Unknown error"]}})}},setToken(o){t({token:o})}}));function Vt(e){let n=e.service||e.services||[],t={hasAuth:!1,services:{}};for(let r of n)if(r.type==="AuthProbeService2"){t.services.probe=r,t.hasAuth=!0;let o=r.service.filter(a=>a.type==="AuthAccessService2");o[0]&&(t.services.access=o[0])}return t}async function je(e,{strict:n=!0}={}){return new Promise((t,r)=>{let o=Math.random().toString(36).substring(7),a=`${e.id}?messageId=${o}&origin=${window.location.origin}`,s=c=>{let l=c.data;if(l.messageId===o){if(n&&l.type!=="AuthAccessToken2"){i(),r("Invalid response, expected type=AuthAccessToken2");return}if(!l.accessToken){i(),r("Invalid response, expected accessToken");return}i(),t(l)}},i=()=>window.removeEventListener("message",s),u=document.createElement("iframe");u.src=a,u.style.display="none",document.body.appendChild(u),window.addEventListener("message",s)})}function kt(e){let n=window.location;if(e){let t=document.createElement("a");return t.href=e,t.protocol+"//"+t.hostname+(t.port?":"+t.port:"")}return n.protocol+"//"+n.hostname+(n.port?":"+n.port:"")}async function It(e){let n=`${e.id}?origin=${kt()}`,t=window.open(n);if(!t)throw new Error("Failed to open window");return new Promise((r,o)=>{let a=setInterval(()=>{t.closed&&(clearInterval(a),r())},500)})}import{useEffect as Nt,useMemo as Lt}from"react";import{useStore as Rr}from"zustand";function zt(e){let n=Lt(()=>Vt(e),[e]),t=Ot(n.services.access?.id),r=Lt(()=>Et(n.services.probe,t),[n.services.probe]),o=Rr(r);return Nt(()=>{o.status==="unknown"&&!t&&o.probe()},[n.services.probe,o.status]),Nt(()=>{t&&(o.setToken(t),o.probe())},[t]),[e,o,n.hasAuth]}import{jsx as Pe}from"react/jsx-runtime";var te=Ye(null),Mr=Ye(null);Mr.displayName="CurrentAuth";var wr=Ye(null);wr.displayName="AuthActions";function Ft({children:e}){let n=Ir(()=>wt(),[]);return Pe(te.Provider,{value:n,children:e})}function $t(){return!!Ht(te)}function fe(){let e=Ht(te);if(!e)throw new Error("useAuthActions must be used within a AuthProvider");return e}function Er(){let e=fe();return me(e,t=>({login:t.login,logout:t.logout,nextAuth:t.nextAuth,previousAuth:t.previousAuth,setAuth:t.setAuth,addService:t.addService,removeService:t.removeService}))}function ds(){let e=fe();return me(e,n=>n)}function Vr(e){let n=fe();return me(n,r=>r.authItems.find(o=>o.service.id===e))}function Ot(e){let n=fe();return me(n,r=>r.authItems.find(o=>o.id===e)?.session?.token)}function ms(e){let n=fe();return me(n,r=>{let o=r.authItems.find(a=>a.service.id===e);return!o||!o.isLoggedIn||!o.session?null:o.session?.token||null})}function kr(e){let n=Er(),t=Vr(e.service.id);return Tr(()=>(n?.addService(e.service,e.probeId),()=>{n?.removeService(e.service,e.probeId)}),[e.service]),t?(t.error||!t.isLoggedIn,e.children):null}function Ke(){return null}function Dt(e){let[n,t,r]=zt(e.resource),o=e.fallbackComponent||Ke,a=e.loadingComponent||Ke,s=e.errorComponent||Ke,i=t.service,u=null;if(!r||!i)return e.children(n);let c=i.service.filter(l=>l.type==="AuthAccessService2");t.status==="error"&&(u=Pe(s,{resource:e.resource,error:t.error||"",heading:t.errorHeading,note:t.errorNote,extra:e.extra})),(t.status==="unknown"||t.status==="probing")&&(u=Pe(a,{})),t.status==="success"&&(u=e.children(n));for(let l of c)u=Pe(kr,{service:l,probeId:i.id,children:u},l.id);return u}import{createContext as Or,useContext as Cs,useMemo as Hr}from"react";import{createStore as Nr}from"zustand/vanilla";var Lr=e=>e.id||e["@id"];function zr(e){return(Array.isArray(e.service)?e.service:[e.service]).find(t=>t.profile==="http://iiif.io/api/search/0/autocomplete"||t.profile==="http://iiif.io/api/search/1/autocomplete"||t.profile==="AutoCompleteService1")}var Ut=e=>{let n;typeof e=="string"?n={"@context":"http://iiif.io/api/search/1/context.json",profile:"http://iiif.io/api/search/1/search","@id":e,id:e,service:[]}:n=e;let t=n?Lr(n):void 0,r=null;return Nr((o,a)=>({service:n,resources:[],lastQuery:{},loading:!1,error:!1,highlight:null,hasSearch:!!n,hasAutocomplete:n?!!zr(n):!1,errorMessage:"",search(s,i={}){if(!t)throw new Error("No search service found.");r&&!r.signal.aborted&&r.abort(),r=new AbortController;let u=new URLSearchParams;s.q&&u.set("q",s.q),s.motivation&&u.set("motivation",s.motivation),s.date&&u.set("date",s.date),s.user&&u.set("user",s.user),o({loading:!0}),fetch(`${t}?${u.toString()}`,{signal:r.signal,headers:{"Content-Type":"application/json",Accept:"application/json",...i.headers||{}}}).then(async c=>{if(!r?.signal.aborted)if(c.ok){let l=await c.json();o({resources:l.resources,error:!1,errorMessage:""})}else o({resources:[],error:!0,errorMessage:c.statusText})})},clearSearch(){o({resources:[],error:!1,errorMessage:""})},highlightResult(s){let i=a().resources.find(u=>u["@id"]===s);o({highlight:i})},nextResult(){let s=a().resources,i=a().highlight;if(!i){o({highlight:s[0]||null});return}let u=s.findIndex(c=>c["@id"]===i["@id"]);if(u===-1){o({highlight:s[0]||null});return}o({highlight:s[u+1]||s[0]||null})},previousResult(){let s=a().resources,i=a().highlight;if(!i){o({highlight:s[s.length-1]||null});return}let u=s.findIndex(c=>c["@id"]===i["@id"]);if(u===-1){o({highlight:s[s.length-1]||null});return}if(u===0){o({highlight:s[s.length-1]||null});return}o({highlight:s[u-1]||s[s.length-1]||null})}}))};import{useStore as Ts}from"zustand";function qt(){let e=V();return e?e.service.find(n=>n.profile==="SearchService1"||n.profile==="http://iiif.io/api/search/1/search"):void 0}import{jsx as Qe}from"react/jsx-runtime";var ne=Or(null);ne.displayName="Search";function Bt(e){let n=qt();return e.store?Qe(ne.Provider,{value:e.store,children:e.children}):Qe(Fr,{service:n,children:e.children})}function Fr({service:e,children:n}){let t=Hr(()=>Ut(e),[e]);return Qe(ne.Provider,{value:t,children:n})}import{jsx as z}from"react/jsx-runtime";var pe=()=>{},ge=Dr({setCurrentCanvasId:pe,setCurrentCanvasIndex:pe,nextCanvas:pe,previousCanvas:pe,items:[],sequence:[],setSequenceIndex:pe,currentSequenceIndex:0,hasNext:!1,hasPrevious:!1});function qr(e){let n=V(),{cursor:t,visibleItems:r,next:o,sequence:a,items:s,setCanvasIndex:i,setCanvasId:u,previous:c,setSequenceIndex:l,hasNext:d,hasPrevious:y}=Tt({startCanvas:e.startCanvas,disablePaging:e.pagingEnabled===!1}),A=Ur(()=>({sequence:a,items:s,setCurrentCanvasId:u,nextCanvas:o,previousCanvas:c,totalCanvases:s.length,setCurrentCanvasIndex:i,setSequenceIndex:l,currentSequenceIndex:t,hasNext:d,hasPrevious:y}),[a,s,u,o,c,s,i,l,t]);return n?r.length===0?null:z(ge.Provider,{value:A,children:z(ee.Provider,{value:r,children:z(q,{canvas:r[0],children:e.children})})}):(console.warn("The manifest passed to the provider is not a valid IIIF manifest."),z("div",{children:"Sorry, something went wrong."}))}function _t(e){let n=X(e.vault),t=Ct(e.manifest);if(!t)return console.warn("The manifest passed to the provider is not a valid IIIF manifest."),z("div",{children:"Sorry, something went wrong."});if(t.error)return z("div",{children:t.error.toString()});if(!t.isLoaded)return z("div",{children:"Loading..."});let r=z(qr,{...e,children:e.children});return z(J,{vault:n,children:z(At,{manifest:t.id,children:z(Ft,{children:z(Bt,{children:e.rangeId?z(bt,{range:e.rangeId,children:r}):r})})})})}function jt(){return $r(ge)}import Br from"react";import{createContext as _r,useMemo as jr}from"react";import Kr from"mitt";import{jsx as Qr}from"react/jsx-runtime";var Yr=Kr(),re=_r({emitter:Yr});re.displayName="Events";function Kt(){return Br.useContext(re).emitter}function ru({emitter:e,children:n}){return Qr(re.Provider,{value:jr(()=>({emitter:e}),[e]),children:n})}import{jsx as oe}from"react/jsx-runtime";function Yt(){return{VaultContext:Q(Y),ResourceContext:Q(Ce),SimpleViewerReactContext:Q(ge),VisibleCanvasReactContext:Q(ee),AuthRContext:Q(te),SearchReactContext:Q(ne),ReactEventContext:Q(re)}}function Qt(e){return oe(J,{vault:e.bridge.VaultContext.vault||void 0,resources:e.bridge.ResourceContext,children:oe(ee.Provider,{value:e.bridge.VisibleCanvasReactContext,children:oe(ge.Provider,{value:e.bridge.SimpleViewerReactContext,children:oe(re.Provider,{value:e.bridge.ReactEventContext,children:oe(te.Provider,{value:e.bridge.AuthRContext,children:oe(ne.Provider,{value:e.bridge.SearchReactContext,children:e.children})})})})})})}import{createContext as Xr,useContext as eo,useMemo as to}from"react";import{useCallback as Gt,useLayoutEffect as Gr,useMemo as Zr,useRef as Jr}from"react";import{entityActions as We}from"@iiif/helpers/vault/actions";import{useMemo as Wr}from"react";function Wt(){let n=R().getStore();return Wr(()=>t=>n.dispatch(t),[n])}function Zt(e){return typeof e!="string"&&e&&e.bindToVault}function Jt(){let e=R(),n=Jr([]),t=Wt(),r=Zr(()=>`vault://annotation-page/${new Date().getTime()}/${Math.round(Math.random()*1e9).toString(16)}`,[]);Gr(()=>{let i={id:r,type:"AnnotationPage",behavior:[],label:null,thumbnail:[],summary:null,requiredStatement:null,metadata:[],rights:null,provider:[],items:[],seeAlso:[],homepage:[],rendering:[],service:[]};t(We.importEntities({entities:{AnnotationPage:{[i.id]:i}}}))},[r]);let o=T(i=>r&&i.iiif.entities.AnnotationPage[r]||null,[r]),a=Gt((i,u)=>{if(r){if(Zt(i)){let d=i;d.__vault||d.bindToVault(e),i=typeof d.source=="string"?d.source:d.source.id,n.current[i]=d}else typeof i!="string"&&(i=i.id);let c=e.get({id:r,type:"AnnotationPage"}),l=e.get({id:i,type:"Annotation"});c&&l&&(c.items.find(d=>d.id===l.id)||t(We.addReference({id:r,type:"AnnotationPage",key:"items",reference:{id:i,type:"Annotation"},index:u})))}},[r]),s=Gt(i=>{r&&(Zt(i)?i=typeof i.source=="string"?i.source:i.source.id:typeof i!="string"&&(i=i.id),n.current[i]&&n.current[i].beforeRemove(),e.get({id:r,type:"AnnotationPage"})&&t(We.removeReference({id:r,type:"AnnotationPage",key:"items",reference:{id:i,type:"Annotation"}})))},[r]);return[o,{addAnnotation:a,removeAnnotation:s}]}import{jsx as no}from"react/jsx-runtime";var Xt=Xr(null);function en(){let e=eo(Xt);return[e.fullPage,{addAnnotation:e.addAnnotation,removeAnnotation:e.removeAnnotation}]}function tn({children:e}){let[n,{addAnnotation:t,removeAnnotation:r}]=Jt();return no(Xt.Provider,{value:to(()=>({fullPage:n,addAnnotation:t,removeAnnotation:r}),[n]),children:e})}import{jsx as Ge,jsxs as ro}from"react/jsx-runtime";function nn({width:e,style:n,height:t,error:r,resetErrorBoundary:o}){return ro("div",{style:{width:e,height:t,minHeight:500,...n||{},background:"#f9f9f9"},children:[Ge("h3",{children:"Error occurred"}),Ge("p",{children:r.message}),Ge("button",{onClick:o,children:"Reset"})]})}import{createContext as oo,useContext as io}from"react";var ve=oo(null);function rn(){return io(ve)}import{createContext as on,useContext as ao,useEffect as so}from"react";var Ze=on(()=>{}),Je=on(()=>{});function O(e,n,t,r,o=[]){let a=ao(e==="portal"?Je:Ze);so(()=>(e!=="none"&&a(n,t,r),()=>{a(n,null)}),[n,e,a,...o])}import{createContext as co,useContext as lo,useEffect as mo}from"react";import{useMemo as uo}from"react";function w(e={},n=[]){let{id:t,selector:r}=e,o=H(),a=t||o.canvas,s=T(i=>a?i.iiif.entities.Canvas[a]:void 0,[a]);return uo(()=>{if(s)return r?r(s):s},[s,r,...n])}var Xe=co(()=>{});function an(e){let n=w(),t=lo(Xe);mo(()=>n&&n.id?(t(n.id,e),()=>t(n.id,-1)):()=>{},[n,e])}import{Fragment as vo,jsx as k,jsxs as ho}from"react/jsx-runtime";function cn({children:e,errorFallback:n,outerContainerProps:t={},worldScale:r,...o}){let[a,s]=Re(),i=Yt(),u=n||nn,[c,l]=Re({}),d=Object.entries(c),[y,A]=Re({}),h=Object.entries(y),[g,b]=Re({}),p=un(()=>r||Math.max(...Object.values(g)),[g]),S=un(()=>({maxOverZoom:p||1,...o.runtimeOptions||{}}),[p,o.runtimeOptions]),m=et((x,P)=>{b(C=>{if(P===-1){let{[x]:K,...f}=C;return f}return{...C,[x]:P}})},[]),v=et((x,P,C)=>{l(({[x]:K,...f})=>P?{...f,[x]:{element:P,props:C}}:f)},[]),I=et((x,P,C)=>{A(({[x]:K,...f})=>P?{...f,[x]:{element:P,props:C}}:f)},[]);return ho(go,{resetKeys:[],fallbackRender:x=>k(u,{...o,...x}),children:[k(fo,{...o,containerProps:{style:{position:"relative"},...o.containerProps||{}},htmlChildren:k(vo,{children:d.map(([x,{element:P,props:C}])=>k(sn.Fragment,{children:k(P,{...C||{}})},x))}),onCreated:x=>{s(x),o.onCreated&&o.onCreated(x)},runtimeOptions:S,children:k(ve.Provider,{value:a,children:k(Xe.Provider,{value:m,children:k(Ze.Provider,{value:v,children:k(Je.Provider,{value:I,children:k(Qt,{bridge:i,children:k(po.Provider,{value:o.mode||"explore",children:k(tn,{children:e})})})})})})})}),k("div",{children:h.map(([x,{element:P,props:C}])=>k(sn.Fragment,{children:k(P,{...C||{}})},x))})]})}import{mergeStyles as bo,RegionHighlight as Po}from"@atlas-viewer/atlas";import{useMemo as ln}from"react";import{createEventsHelper as yo}from"@iiif/helpers/events";function Te(e,n){let t=R(),r=ln(()=>yo(t),[t]),o=T(()=>e&&e.id?t.getResourceMeta(e.id,"eventManager"):null,[e]);return ln(()=>e?r.getListenersAsProps(e,n):{},[o,e,t,n])}import{useMemo as So}from"react";import{createStylesHelper as xo}from"@iiif/helpers/styles";function ie(e,n){let t=R(),r=So(()=>xo(t),[t]);return T(()=>{if(!e)return null;let o=r.getAppliedStyles(e.id);return o?n?o[n]:o:void 0},[e,n])}import{useMemo as Ro}from"react";import{useMemo as Co}from"react";import{expandTarget as Ao}from"@iiif/helpers/annotation-targets";function Ie(e={},n=[]){let{id:t,selector:r}=e,o=H(),a=R(),s=t||o.annotation,i=T(c=>s?c.iiif.entities.Annotation[s]:void 0,[s]),u=T(c=>i&&i.body?i.body.map(l=>l?l.type==="SpecificResource"?{...l,source:a.get(l)}:l?c.iiif.entities[l.type][l.id]:null:null).filter(Boolean):[],[i]);return Co(()=>{if(!i)return;let c={...i,body:u,target:Ao(i.target,{typeMap:a.getState().iiif.mapping})};return r?r(c):c},[i,r,u,...n])}import{jsx as To}from"react/jsx-runtime";var Me=({id:e,style:n,className:t,interactive:r})=>{let o=Ie({id:e}),a=ie(o,"atlas"),s=ie(o,"html"),i=Te(o,["atlas"]),u=w(),c=Ro(()=>bo(n,a),[n,a]);return u&&o&&o.target&&o.target.selector&&o.target.selector.type==="BoxSelector"&&o.target.source&&(o.target.source.id===u.id||o.target.source===u.id)?To(Po,{id:o.id,isEditing:!0,region:o.target.selector.spatial,style:c,className:s?.className||t,interactive:!!(s?.href||r),href:s?.href||null,title:s?.title||null,hrefTarget:s?.target||null,onClick:()=>{},...i}):null};import{Fragment as Mo}from"react";import{useMemo as Io}from"react";function dn(e={},n=[]){let{id:t,selector:r}=e,o=H(),a=t||o.annotationPage,s=T(i=>a?i.iiif.entities.AnnotationPage[a]:void 0,[a]);return Io(()=>{if(s)return r?r(s):s},[s,...n])}import{jsx as mn}from"react/jsx-runtime";var he=({className:e,page:n})=>{let t=dn({id:n.id})||n,r=ie(t,"atlas"),o=ie(t,"html");return T(a=>t.id?a.iiif.entities.AnnotationPage[t.id]:null,[]),mn(Mo,{children:t.items?.map(a=>mn(Me,{id:a.id,style:r,className:o?.className||e},a.id))})};import{createStylesHelper as Ii}from"@iiif/helpers/styles";import{Fragment as An,useMemo as zo}from"react";import{HTMLPortal as ko,TileSet as xn}from"@atlas-viewer/atlas";import ae,{useMemo as tt}from"react";import{jsx as $}from"react/jsx-runtime";var pn=ae.createContext("en"),gn=ae.createContext({}),vn=ae.createContext(null);function Gc(e){return $(gn.Provider,{value:e.translations,children:e.children})}function Zc(e){return $(pn.Provider,{value:e.language,children:e.children})}function Jc(e){return $(vn.Provider,{value:e.convert,children:e.children})}function hn(){return ae.useContext(vn)}function nt(){return ae.useContext(pn)}function yn(){return ae.useContext(gn)}function fn(e){return e.indexOf("-")!==-1?e.slice(0,e.indexOf("-")):e}function wo({as:e,language:n,children:t,viewingDirection:r,...o}){let a=nt();return tt(()=>fn(a)===fn(n),[a,n])?e?$(e,{...o,children:t}):$("span",{...o,children:t}):e?$(e,{...o,lang:n,dir:r,children:t}):$("span",{...o,lang:n,dir:r,children:t})}function Sn(e,n,t){if(n.length===0)return;if(n.length===1)return n[0];if(n.indexOf(e)!==-1)return e;let r=e.indexOf("-")!==-1?e.slice(0,e.indexOf("-")):null;if(r&&n.indexOf(r)!==-1)return r;for(let o of t)if(n.indexOf(o)!==-1)return o;return n.indexOf("none")!==-1?"none":n.indexOf("@none")!==-1?"@none":n[0]}var Eo=(e,n=[])=>{let t=nt();return tt(()=>{let r=e();return Sn(t,r,[])},[t,...n])};function W(e,n,t,r){return n?t?t(e[n]||n,r||"none"):e[n]||n:""}function Vo(e,n,t=`
2
- `,r={}){let o=hn(),a=Eo(()=>Object.keys(e||{}),[e]);return[tt(()=>{if(!e)return W(r,n,o)||"";if(typeof e=="string")return W(r,e,o);let s=a?e[a]:void 0;return s?typeof s=="string"?s:s.map(i=>W(r,i,o,a)).join(t):""},[a,n,e]),a]}function Xc(){let e=nt(),n=yn(),t=hn();return function(o,a="",s=`
3
- `,i=n){let u=Object.keys(o||{}),c=Sn(e,u,[]);if(!o)return W(i,a,t)||"";if(typeof o=="string")return W(i,o,t);let l=c?o[c]:void 0;return l?typeof l=="string"?W(i,l,t,c):l.map(d=>W(i,d,t,c)).join(typeof s<"u"?s:`
4
- `):""}}function ye({as:e,defaultText:n,enableDangerouslySetInnerHTML:t,children:r,separator:o,...a}){let s=yn(),[i,u]=Vo(r,n,o,s);return u?$(wo,{...a,as:e,language:u,title:t?void 0:i,dangerouslySetInnerHTML:t?{__html:i}:void 0,children:t?void 0:i}):e?$(e,{...a,children:i}):$("span",{...a,title:t?void 0:i,dangerouslySetInnerHTML:t?{__html:i}:void 0,children:t?void 0:i})}import{jsx as B,jsxs as Lo}from"react/jsx-runtime";function No({resource:e,heading:n,note:t,extra:r}){return r?B(ko,{target:{x:0,y:0,width:r.target?.spatial.width,height:r.target?.spatial.height},backgroundColor:"#333",relative:!0,children:B("div",{style:{display:"flex",alignContent:"center",justifyContent:"center",alignItems:"center",height:"100%",width:"100%",background:"#444",color:"#BBB"},children:Lo("div",{children:[B(ye,{children:n||"Not authorised"}),t&&B("p",{children:B(ye,{children:t})}),B("p",{children:e.id||e["@id"]||"unknown"})]})})}):null}function Cn({image:e,thumbnail:n,crop:t,enableSizes:r}){if(!$t()){let a=e.service,s=a.width||e.width||0,i=a.height||e.height||0;return B(xn,{tiles:{id:a.id||a["@id"]||"unknown",height:i,width:s,imageService:a},enableSizes:r,x:0,y:0,width:e.target?.spatial.width,height:e.target?.spatial.height,crop:t})}return B(Dt,{resource:e.service,errorComponent:No,extra:e,children:a=>{let s=a.width||e.width||0,i=a.height||e.height||0;return B(xn,{tiles:{id:a.id||a["@id"]||"unknown",height:i,width:s,imageService:a},enableSizes:r,x:0,y:0,width:e.target?.spatial.width,height:e.target?.spatial.height,crop:t})}},e.id)}import{jsx as rt,jsxs as bn}from"react/jsx-runtime";function se({id:e,image:n,thumbnail:t,isStatic:r,x:o=0,y:a=0,children:s,selector:i,onClick:u,enableSizes:c}){let l=zo(()=>{if(!(!i||i.spatial.x===0&&i.spatial.y===0))return i.spatial},[i]);return rt("world-object",{x:o+n.target.spatial.x,y:a+n.target.spatial.y,width:n.target.spatial.width,height:n.target.spatial.height,onClick:u,children:n.service?bn(An,{children:[rt(Cn,{image:n,thumbnail:t,crop:l,enableSizes:c}),s]},"service"):bn(An,{children:[rt("world-image",{onClick:u,uri:n.id,target:{x:0,y:0,width:n.target.spatial.width,height:n.target.spatial.height},display:n.width&&n.height?{width:n.width,height:n.height}:void 0,crop:l}),s]},"no-service")},e+(n.service?"server":"no-service"))}import{Fragment as Mi,useEffect as Wn,useLayoutEffect as wi,useMemo as Gn}from"react";import{HTMLPortal as Ei}from"@atlas-viewer/atlas";import{useEffect as Nn,useMemo as Ln}from"react";import{useCallback as Tn,useMemo as Ho}from"react";function Oo(e,n){let t=e?.iiif?.meta[n];return t?t.annotationPageManager:null}function Pn(e,n){return T(t=>{let r=[];if(!e)return r;let o=Object.keys(t.iiif.entities.AnnotationPage);for(let a of o)if(!n||n.indexOf(a)!==-1){let s=Oo(t,a);s&&s.views&&s.views[e]&&r.push(a)}return r},[e,n])}function Rn({canvas:e,manifest:n,all:t,canvases:r}){let o=[];if(n)for(let a of n.annotations)o.indexOf(a.id)===-1&&o.push(a.id);if(t){if(r&&r.length)for(let a of r)for(let s of a.annotations)o.indexOf(s.id)===-1&&o.push(s.id)}else if(e)for(let a of e.annotations)o.indexOf(a.id)===-1&&o.push(a.id);return o}function Fo(e,n){let t=e?.iiif?.meta[n];return t?t.annotationPageManager:null}function In(e,n={}){let t=R(),r=V(),o=w(),a=Ae(),s=Ho(()=>Rn({all:n.all,manifest:r,canvas:o,canvases:a}),[n.all,o,a,r]),i=Pn(e,n.all?void 0:s),u=Tn(l=>{e&&t.setMetaValue([l,"annotationPageManager","views"],d=>d&&!d[e]?d:{...d||{},[e]:!1})},[e,t]),c=Tn((l,d={})=>{if(!e)return;let y=t.getState(),A=[];if(d?.deselectOthers){let h=Object.keys(y.iiif.entities.AnnotationPage);for(let g of h){let b=Fo(y,g);b&&b.views&&b.views[e]&&A.push(g)}}for(let h of A)u(h);t.setMetaValue([l,"annotationPageManager","views"],h=>h&&h[e]?h:{...h||{},[e]:!0})},[e,u,t]);return{availablePageIds:s,enabledPageIds:i,setPageEnabled:c,setPageDisabled:u}}function Mn(e,n){return T((t,r)=>r.get(e.map(o=>({id:o,type:n}))),[e,n])}import{useCallback as Bo,useEffect as _o,useRef as jo,useState as Ko}from"react";import $o,{useContext as Do}from"react";import{ImageServiceLoader as Uo}from"@atlas-viewer/iiif-image-api";var qo=$o.createContext(new Uo);function we(){return Do(qo)}function wn(){let e=we(),[n,t]=Ko({}),r=jo(!1);return _o(()=>()=>{r.current=!0},[]),[Bo((a,{height:s,width:i})=>{if(a){let u=a.id||a["@id"],c=e.loadServiceSync({id:u,width:a.width||i,height:a.height||s,source:a});c?a=c:n[u]||(r.current||t(l=>({...l,[u]:"loading"})),e.loadService({id:u,width:a.width||i,height:a.height||s}).then(()=>{r.current||t(l=>({...l,[u]:"done"}))}))}return a},[e,n]),n]}import{useCallback as Yo,useMemo as Vn,useState as Qo}from"react";function En(e={}){let n=Ie(),t=w(e.canvasId?{id:e.canvasId}:void 0);return T((r,o)=>{if(!t)return[];if(n&&e.enableSingleAnnotation)return[n];let a=o.get(t.items),s=[];for(let i of a)s.push(...o.get(i.items));return s},[t])}import{createPaintingAnnotationsHelper as Wo}from"@iiif/helpers/painting-annotations";function kn(e,n=[]){let t=R(),r=Vn(()=>Wo(t),[]),o=En({enableSingleAnnotation:e?.enableSingleAnnotation}),[a,s]=Qo(e?.defaultChoices||[]),i=Vn(()=>r.getPaintables(o,a),[t,o,a,...n]),c={makeChoice:Yo((l,{deselectOthers:d=!0,deselect:y=!1}={})=>{i.choice&&s(A=>{if(y){let g=A.filter(b=>b!==l);if(g.length===0){let b=i.items[0].resource.id;return b?[b]:[]}return g}if(d)return[l];let h=[...A];if(h.length===0&&i.items.length){let g=i.items[0].resource.id;g&&h.push(g)}return A.indexOf(l)!==-1?A:[...A,l]})},[i.choice])};return[i,c]}function zn(e){let n=V(),t=w(),r=R(),o=Kt(),a=e?.emitter||o,[s,i]=wn(),{enabledPageIds:u}=In(e?.annotationPageManagerId||n?.id||t?.id,{all:!1}),c=Mn(u,"AnnotationPage"),l=e?.strategies||["empty","images","media","textual-content","complex-timeline"],[d,y]=kn(e,[i]);Nn(()=>{let h=g=>{y.makeChoice(g.choiceId,{deselectOthers:g.deselectOthers,deselect:g.deselect})};return a.on("make-choice",h),()=>{a.off("make-choice",h)}},[]);let A=Ln(()=>ht({canvas:t,paintables:d,supports:l,loadImageService:s}),[t,d,r,y.makeChoice]);return Nn(()=>{let h=d.allChoices,g={canvasId:t?.id,manifestId:n?.id};h&&a.emit("choice-change",{choice:h,partOf:g})},[t?.id,d.allChoices]),Ln(()=>A.type==="unknown"?[A,vt]:[{...A,annotations:{pages:c}},y],[A,c])}import{useEffect as Zo,useMemo as Jo,useRef as Xo,useState as ei}from"react";import{useEffect as Go}from"react";var On=(e,n=[])=>{let t=R();Go(()=>{e(t)},[t,...n])};import{createThumbnailHelper as ti}from"@iiif/helpers/thumbnail";function Ee(e,n,{canvasId:t,manifestId:r}={}){let o=R(),a=we(),s=Jo(()=>ti(o,{imageServiceLoader:a}),[o,a]),[i,u]=ei(),c=V(r?{id:r}:void 0),l=w(t?{id:t}:void 0),d=l||c,y=Xo(!1);if(Zo(()=>(y.current=!1,()=>{y.current=!0}),[]),!d)throw new Error("Must be called under a manifest or canvas context.");return On(A=>{s.getBestThumbnailAtSize(d,e,n).then(h=>{h.best&&!y.current&&u(h.best)})},[d]),i}import{useCallback as D,useEffect as Hn,useReducer as ni,useRef as Ve}from"react";function ri(e){return{isMuted:!1,playRequested:!1,isPlaying:!1,isFinished:!1,volume:100,duration:e}}function oi(e,n){switch(n.type){case"FINISHED":return{...e,isFinished:!0,isPlaying:!1,playRequested:!1};case"PLAY_PAUSE":return{...e,isFinished:!1,isPlaying:!e.isPlaying};case"PLAY_REQUESTED":return{...e,isFinished:!1,playRequested:!0};case"PAUSE":return{...e,isPlaying:!1};case"PLAY":return{...e,isFinished:!1,playRequested:!1,isPlaying:!0};case"MUTE":return{...e,isMuted:!0};case"SET_VOLUME":return{...e,volume:n.volume,isMuted:n.volume===0};case"TOGGLE_MUTE":return{...e,isMuted:!e.isMuted};case"UNMUTE":return{...e,isMuted:!1}}return e}function ot(e){let n=Math.round(e);return`${Math.floor(n/60)}:${`${n%60}`.padStart(2,"0")}`}function ue(e){let[n,t]=ni(oi,ri(e.duration)),r=Ve(null),o=Ve(null),a=Ve(null),s=Ve(!1),i=D(()=>{o.current&&r.current&&(o.current.innerHTML=ot(r.current.currentTime),a.current&&(a.current.style.width=`${r.current.currentTime/e.duration*100}%`),s.current!==r.current.muted&&(s.current=r.current.muted,t(r.current.muted?{type:"MUTE"}:{type:"UNMUTE"})))},[e.duration]),u=D(()=>{r.current&&(t({type:"PLAY_REQUESTED"}),r.current.play().then(()=>{t({type:"PLAY"})}),i())},[i]),c=D(()=>{r.current&&(r.current.duration>0&&r.current.paused?u():l())},[i]),l=D(()=>{r.current&&(r.current.pause(),t({type:"PAUSE"}),i())},[i]),d=D(()=>{r.current&&(r.current.muted=!r.current.muted,t(r.current.muted?{type:"MUTE"}:{type:"UNMUTE"}))},[]),y=D(()=>{r.current&&(r.current.muted=!0,t({type:"MUTE"}))},[]),A=D(()=>{r.current&&(r.current.muted=!1,t({type:"UNMUTE"}))},[]),h=D(p=>{r.current&&(r.current.muted=!1,r.current.volume=p/100,t({type:"SET_VOLUME",volume:p}))},[]),g=D(p=>{r.current&&(r.current.currentTime=Math.max(0,Math.min(p*e.duration,e.duration)),i())},[]),b=D(p=>{r.current&&(r.current.currentTime=Math.max(0,Math.min(p,e.duration)),i())},[]);return Hn(()=>{let p=setInterval(()=>{i()},350);return()=>clearInterval(p)},[i,e.duration]),Hn(()=>{let p=()=>{t({type:"FINISHED"})},S=r.current;return S?.addEventListener("ended",p),()=>S?.removeEventListener("ended",p)},[]),[{element:r,currentTime:o,progress:a},n,{play:u,pause:l,playPause:c,mute:y,unmute:A,toggleMute:d,setVolume:h,setDurationPercent:g,setTime:b}]}import{createContext as at,useContext as st}from"react";import{jsx as it}from"react/jsx-runtime";var Fn=at(null),$n=at(null),Dn=at(null);function vd(){let e=st(Fn);if(!e)throw new Error("Ctx not found");return e}function hd(){let e=st($n);if(!e)throw new Error("Ctx not found");return e}function yd(){let e=st(Dn);if(!e)throw new Error("Ctx not found");return e}function ke({actions:e,state:n,children:t,currentTime:r,progress:o,element:a}){return it(Dn.Provider,{value:{currentTime:r,progress:o,element:a},children:it($n.Provider,{value:e,children:it(Fn.Provider,{value:n,children:t})})})}import{useMemo as ii}from"react";import{expandTarget as ai}from"@iiif/helpers";function Ne(){let e=V(),n=w();return ii(()=>{if(!e||!n||!e.start)return null;let t=ai(e.start);return!t||t.source.id!==n.id||!t||!t.selector||t.selector.type!=="TemporalSelector"?null:t.selector.temporal},[e,n])}import{jsx as si,jsxs as ui}from"react/jsx-runtime";function ut({media:e,startTime:n,children:t}){let[{element:r,currentTime:o,progress:a},s,i]=ue({duration:e.duration}),u=n?`${e.url}#t=${n}`:e.url;return ui(ke,{state:s,actions:i,currentTime:o,progress:a,element:r,children:[si("audio",{ref:r,src:u}),t]})}function Le({media:e,mediaControlsDeps:n,children:t}){let r=Ne();return O("portal","audio",ut,{media:e,startTime:r?r.startTime:null,children:t},[e,r,...n||[]]),null}import{jsx as Un,jsxs as ci}from"react/jsx-runtime";function ct({element:e,media:n,startTime:t,playPause:r,poster:o}){let a="div",s=t?`${n.url}#t=${t}`:n.url;return ci(a,{className:"video-container",part:"video-container",onClick:r,children:[Un("style",{children:`
5
- .video-container {
6
- position: absolute;
7
- top: 0;
8
- bottom: 0;
9
- left: 0;
10
- right: 0;
11
- background: #000;
12
- z-index: 13;
13
- display: flex;
14
- justify-content: center;
15
- pointer-events: visible;
16
- }
17
- `}),Un("video",{poster:o,ref:e,src:s,style:{width:"100%",objectFit:"contain"}})]})}function ze({media:e,mediaControlsDeps:n,children:t,videoComponent:r=ct}){let o=w(),a=Ne(),s=o&&o.placeholderCanvas&&o.placeholderCanvas.id||void 0,i=Ee({},!1,{canvasId:s}),[{element:u,currentTime:c,progress:l},d,y]=ue({duration:e.duration});return O("overlay","video-element",r,{element:u,media:e,playPause:y.playPause,poster:i?.id,startTime:a?a.startTime:null},[i]),O("portal","custom-controls",ke,{state:d,actions:y,currentTime:c,progress:l,element:u,children:t},[c,d,e,...n||[]]),null}import{Fragment as li,jsx as lt,jsxs as di}from"react/jsx-runtime";function dt({model:e}){return di(li,{children:[lt("style",{children:`
18
- .model-container {
19
- position: absolute;
20
- top: 0;
21
- bottom: 0;
22
- left: 0;
23
- right: 0;
24
- background: #000;
25
- z-index: 13;
26
- display: flex;
27
- justify-content: center;
28
- pointer-events: visible;
29
- }
30
- `}),lt("div",{className:"model-container",children:lt("model-viewer",{"interaction-prompt":"none",style:{width:"100%",height:"100%"},"camera-controls":"","ar-status":"not-presenting",src:e.id})})]})}function Oe({model:e,name:n}){return O("overlay",`model-${n}`,dt,{model:e},[e]),null}import{jsx as mi}from"react/jsx-runtime";function He({style:e}){let n=w();return!n||!n.height||!n.width?null:mi("box",{interactive:!1,target:{x:0,y:0,width:Number(n.width),height:Number(n.height)},style:e})}import{jsx as qn}from"react/jsx-runtime";function Fe(e){let n=w();return!n||!n.placeholderCanvas?null:qn(q,{canvas:n.placeholderCanvas.id,children:qn(ce,{renderViewerControls:e.renderViewerControls})})}import{useRef as fi}from"react";import{jsx as Bn,jsxs as gi}from"react/jsx-runtime";function pi({element:e,media:n,playPause:t}){let r=fi(null);return n.youTubeId?gi("div",{className:"video-container",part:"video-container",onClick:t,children:[Bn("style",{children:`
31
- .video-container {
32
- position: absolute;
33
- top: 0;
34
- bottom: 0;
35
- left: 0;
36
- right: 0;
37
- background: #000;
38
- z-index: 13;
39
- display: flex;
40
- justify-content: center;
41
- pointer-events: visible;
42
- }
43
- .video-yt {
44
- border: none;
45
- width: 100%;
46
- object-fit: contain;
47
- }
48
- `}),Bn("iframe",{className:"video-yt",ref:r,src:`https://www.youtube.com/embed/${n.youTubeId}?enablejsapi=1&origin=${window.location.host}`,referrerPolicy:"no-referrer",sandbox:"allow-scripts allow-same-origin allow-presentation"})]}):null}function _n({media:e,mediaControlsDeps:n,children:t}){let[{element:r,currentTime:o,progress:a},s,i]=ue({duration:e.duration});return O("overlay","video-element",pi,{element:r,media:e,playPause:i.playPause}),null}import{useLayoutEffect as Ai,useMemo as bi}from"react";import vi from"mitt";import{createStore as hi}from"zustand/vanilla";function jn({currentKeyFrameIndex:e,keyframes:n,targetTime:t,currentTime:r}){if(r<=t){let o=n.findIndex(i=>i.time>t);if(o===-1)return[e,[]];let a={},s=n.slice(e,o);for(let i of s)i.type==="enter"&&(a[i.id]=i),i.type==="exit"&&(a[i.id]?delete a[i.id]:a[i.id]=i);return[o,Object.values(a)]}return[e,[]]}function Kn({complexTimeline:e,startTime:n=0}){let t=vi(),r={},o={progress:null,currentTime:null},a=0,s=null,i=0,u=null;function c(){let S=b.getState().visibleElements,m=r,v=[],I=Object.keys(m);for(let x of I){let P=m[x],C=S[x];P&&C&&v.push(P)}return v}function l(){return Object.keys(r).map(S=>r[S])}function d(p){o.currentTime&&(o.currentTime.innerHTML=ot(p),o.progress&&(o.progress.style.width=`${p/e.duration*100}%`))}let y=()=>{let p=b.getState(),S=p.currentPrime;if(!S)return;let m=r,v=p.visibleElements,I=Object.keys(m);for(let x of I){let P=m[x],C=v[x];if(P&&x!==S.id&&C){let K=i-C.time*1e3;Math.abs(i-C.time*1e3-P.currentTime*1e3)>300&&(P.currentTime=K/1e3)}}},A=(p=0)=>{let S=p-a,m=b.getState();if(m.isPlaying){let v=m.currentPrime;if(v){let C=r[v.id];C.paused?i+=S:i=(v.time+C.currentTime)*1e3}else i+=S;let I=i/1e3;if(I>m.duration){b.getState().setTime(0),b.setState({isPlaying:!1}),h(),d(0);return}d(I);let[x,P]=jn({currentTime:I,currentKeyFrameIndex:m.nextKeyframeIndex,keyframes:m.complexTimeline.keyframes,targetTime:I});P.length&&m.applyKeyframes(x,P)}a=p,s=requestAnimationFrame(A)},h=()=>{s&&cancelAnimationFrame(s)},g=(p,S)=>{},b=hi((p,S)=>({complexTimeline:e,elements:{},visibleElements:{},isBuffering:!1,bufferMap:{},isMuted:!1,playRequested:!1,isPlaying:!1,isFinished:!1,isReady:!1,volume:100,duration:e.duration,clockStartRequests:0,clockStartTime:0,primeTime:0,currentPrime:null,clockRunning:!1,nextKeyframeIndex:0,startClock:()=>{S().clockRunning||(A(),u=setInterval(y,500)),p({clockRunning:!0,clockStartRequests:S().clockStartRequests+1})},applyKeyframes(m,v){let I=S(),x={...I.visibleElements},P=I.currentPrime;for(let C of v)C.type==="enter"&&(x[C.id]=C,t.emit("complex-timeline.enter",{id:C.id})),C.type==="exit"&&(x[C.id]=null,t.emit("complex-timeline.exit",{id:C.id})),C.isPrime&&(P=C);p({nextKeyframeIndex:m,visibleElements:x,currentPrime:P})},stopClock:()=>{let m=S().clockStartRequests;if(m!==0){if(m===1){h(),u&&clearInterval(u),p({clockRunning:!1,clockStartRequests:0});return}p({clockStartRequests:m-1})}},setElement:(m,v)=>{r[m]=v;let I=Object.keys(r),x=S().complexTimeline;g(v,m),x.items.filter(C=>C.type!=="Image").every(C=>I.includes(C.annotationId))&&!S().isReady&&(t.emit("complex-timeline.ready",{complexTimeline:x}),p({isReady:!0}))},removeElement:m=>{delete r[m]},mute(){for(let m of l())m.muted=!0;p({isMuted:!0})},unmute(){for(let m of l())m.muted=!1;p({isMuted:!1})},play(){if(!S().isPlaying){for(let v of c())v.play();p({isPlaying:!0})}},pause(){if(S().isPlaying){for(let v of c())v.pause();p({isPlaying:!1})}},playPause(){let m=S();m.isPlaying?m.pause():m.play()},setDurationPercent(m){let I=S().duration*m;S().setTime(I)},setTime(m){let v=S(),I=i/1e3,x=v.nextKeyframeIndex;if(I>m){p({visibleElements:{},currentPrime:null});let G=Object.keys(v.visibleElements);for(let L of G)t.emit("complex-timeline.exit",{id:L});I=0,x=0}let[P,C]=jn({currentTime:I,currentKeyFrameIndex:x,keyframes:v.complexTimeline.keyframes,targetTime:m});v.applyKeyframes(P,C),i=m*1e3;let f=b.getState().visibleElements,De=r,Se=Object.keys(f);for(let G of Se){let L=f[G];if(L){let Z=De[G];Z&&(Z.currentTime=(i-L.time*1e3)/1e3)}}},setVolume(m){for(let v of l())v.volume=Math.min(1,Math.max(0,m/100));p({volume:m})},toggleMute(){let m=S();m.isMuted?(m.unmute(),p({isMuted:!1})):(m.mute(),p({isMuted:!0}))},clearProgressElement(){o.progress=null},setProgressElement(m){o.progress=m},setCurrentTimeElement(m){o.currentTime=m},clearCurrentTimeElement(){o.currentTime=null}}));return t.on("complex-timeline.enter",p=>{let S=b.getState(),m=p.id,v=r[m];v&&S.isPlaying&&v.play()}),t.on("complex-timeline.exit",p=>{let S=b.getState(),m=p.id,v=r[m];v&&(v.currentTime=0,v.pause())}),b.getState().setTime(n),{store:b,emitter:t}}import{HTMLPortal as Pi}from"@atlas-viewer/atlas";import{useStore as ft}from"zustand";import{createContext as yi,useContext as Si}from"react";import{useStore as xi}from"zustand";import{jsx as Ci}from"react/jsx-runtime";var mt=yi(null);mt.displayName="ComplexTimeline";function Yn({children:e,store:n}){return Ci(mt.Provider,{value:n,children:e})}function mm(e){let n=Si(mt);if(!n)throw new Error("useComplexTimeline must be used within a ComplexTimelineProvider");return xi(n,e)}import{Fragment as Ri,jsx as pt,jsxs as Ti}from"react/jsx-runtime";function Qn({strategy:e,children:n}){let{store:t}=bi(()=>Kn({complexTimeline:e}),[e]),r=ft(t,c=>c.isReady),o=ft(t,c=>c.visibleElements),a=ft(t,c=>c),{playPause:s,isPlaying:i}=a;function u(c){return l=>{l&&t.getState().setElement(c,l)}}return Ai(()=>{if(r){let{startClock:c,stopClock:l}=t.getState();return c(),()=>{l()}}},[r]),O("portal","custom-controls",Yn,{store:t,children:n},[r]),Ti(Ri,{children:[e.items.map(c=>c.type!=="Image"||!o[c.annotationId]?null:pt(se,{image:c,id:c.annotationId},c.id)),e.items.map((c,l)=>c.type!=="Video"||!c.target.spatial?null:pt(Pi,{target:c.target.spatial,children:pt("video",{ref:u(c.annotationId),src:c.url,style:{height:"100%",width:"100%",opacity:o[c.annotationId]?1:0}})},l))]})}import{Fragment as $e,jsx as E,jsxs as j}from"react/jsx-runtime";function ce({x:e,y:n,onChoiceChange:t,registerActions:r,defaultChoices:o,isStatic:a,renderViewerControls:s,renderMediaControls:i,renderComplexTimelineControls:u,viewControlsDeps:c,mediaControlsDeps:l,strategies:d,throwOnUnknown:y,backgroundStyle:A,alwaysShowBackground:h,keepCanvasScale:g=!1,enableSizes:b=!1,enableYouTube:p=!0,onClickPaintingAnnotation:S,children:m}){let v=w(),I=Te(v,["deep-zoom"]),[x]=en(),P=rn(),C=R(),K=Gn(()=>Ii(C),[C]),[f,De]=zn({strategies:d||["images"],defaultChoices:o?.map(({id:M})=>M)}),Se=f.type==="images"?f.choice:void 0,G=Gn(()=>g?1:Math.max(1,...f.type==="images"?f.images.map(M=>(M.width||0)/M.target?.spatial.width):[]),[g,f]);an(G),Wn(()=>{r&&r(De)},[f.annotations]),Wn(()=>{if(o)for(let M of o)typeof M.opacity<"u"&&K.applyStyles({id:M.id},"atlas",{opacity:M.opacity})},[o]),wi(()=>{t&&t(Se)},[Se]),O(P&&(f.type==="images"||f.type==="empty"||f.type==="textual-content"&&s)?"overlay":"none",`canvas-portal-controls-${v?.id}`,ve.Provider,s?{value:P||null,children:s(f)}:{},[v,P,f,...c||[]]);let L=Ee({maxWidth:256,maxHeight:256});if(!v)return null;let Z=v.accompanyingCanvas,Ue=v.placeholderCanvas,le=L&&L.type==="fixed"?E("world-object",{height:v.height,width:v.width,x:e,y:n,children:E("world-image",{uri:L.id,target:{x:0,y:0,width:v.width,height:v.height},display:L.width&&L.height?{width:L.width,height:L.height}:void 0,crop:void 0})}):null;if(f.type==="unknown"){if(le)return le;if(y)throw new Error(f.reason||"Unknown image strategy");return null}let gt=j(Mi,{children:[x?E(he,{page:x}):null,f.annotations&&f.annotations.pages?f.annotations.pages.map(M=>E(he,{page:M},M.id)):null,m]}),Jn=f.type==="images"?f.images.length:0,zi=f.type==="media"&&f.media.type==="Video"&&Ue?E(Fe,{renderViewerControls:s}):null;return j($e,{children:[j("world-object",{height:v.height,width:v.width,x:e,y:n,...I,children:[f.type==="empty"||h?E(He,{style:A}):null,f.type==="complex-timeline"?E(Qn,{strategy:f,children:u?u(f):null}):null,f.type==="textual-content"?f.items.map((M,xe)=>j($e,{children:[E(Ei,{onClick:S?de=>{de.stopPropagation(),S(M.annotationId,M,de)}:void 0,target:M.target?.spatial||void 0,children:E("div",{"data-textual-content":!0,children:E(ye,{enableDangerouslySetInnerHTML:!0,children:M.text})})},xe),gt]})):null,f.type==="images"?j($e,{children:[f.images.map((M,xe)=>E(se,{isStatic:a,image:M,id:M.id,thumbnail:xe===0?L:void 0,selector:M.selector,enableSizes:b,onClick:S?de=>{de.stopPropagation(),S(M.annotationId,M,de)}:void 0},M.id+xe)),gt]}):null,f.type==="3d-model"?E(Oe,{model:f.model}):null,f.type==="media"?E($e,{children:f.media.type==="Sound"?j(Le,{media:f.media,mediaControlsDeps:l,children:[le,i?i(f):null]}):f.media.type==="Video"?j(ze,{media:f.media,mediaControlsDeps:l,children:[le,i?i(f):null]}):f.media.type==="VideoYouTube"&&p?j(_n,{media:f.media,mediaControlsDeps:l,children:[le,i?i(f):null]}):null}):null]},`${v.id}/${f.type}/${Jn}`),f.type==="media"&&f.media.type==="Sound"&&Z?E(q,{canvas:Z.id,children:E(ce,{renderViewerControls:s})}):null,f.type==="media"&&f.media.type==="Sound"&&Ue&&!Z?E(q,{canvas:Ue.id,children:E(ce,{renderViewerControls:s})}):null]})}import{Fragment as Ni,jsx as U,jsxs as Li}from"react/jsx-runtime";var ki=Zn(function(n,t){let r=V(),o=Ae(),a=jt(),{ViewerControls:s,MediaControls:i,ComplexTimelineControls:u}=n.components||{};if(Vi(t,()=>a,[a]),!r)return U("div",{});let c=0;return Li(Ni,{children:[n.header,U(N.Viewer,{height:n.height,mode:n.mode,renderPreset:n.renderPreset,runtimeOptions:n.runtimeOptions,children:o.map((l,d)=>{let y=c;return c+=l.width+(n.spacing||0),U(q,{canvas:l.id,children:U(N.RenderCanvas,{strategies:["3d-model","media","images","empty","textual-content","complex-timeline"],renderViewerControls:d===0&&s?()=>U(s,{}):void 0,renderMediaControls:d===0&&i?()=>U(i,{}):void 0,renderComplexTimelineControls:d===0&&u?()=>U(u,{}):void 0,x:y,...n.canvasProps||{},children:n.annotations},l.id)},l.id)})},n.reuseAtlas?"":a.currentSequenceIndex),n.children]})}),N=Zn(function({children:n,height:t,annotations:r,canvasProps:o,spacing:a,header:s,components:i,mode:u,reuseAtlas:c,renderPreset:l,runtimeOptions:d,...y},A){let h=X();return U(J,{vault:h,children:U(_t,{...y,children:U(ki,{ref:A,height:t,components:i,spacing:a,canvasProps:o,annotations:r,header:s,mode:u,reuseAtlas:c,renderPreset:l,runtimeOptions:d,children:n})})})});N.RenderImage=se;N.RenderCanvas=ce;N.RenderAnnotationPage=he;N.RenderAnnotation=Me;N.Viewer=cn;N.CanvasBackground=He;N.Audio=Le;N.Video=ze;N.Model=Oe;N.AudioHTML=ut;N.VideoHTML=ct;N.ModelHTML=dt;N.PlaceholderCanvas=Fe;export{Ce as a,H as b,_ as c,Y as d,J as e,X as f,xt as g,Ct as h,At as i,q as j,R as k,T as l,ee as m,Ae as n,V as o,bt as p,xr as q,Be as r,Va as s,Pt as t,La as u,_e as v,Rt as w,Tt as x,Ya as y,wt as z,Et as A,Vt as B,je as C,It as D,te as E,Mr as F,wr as G,Ft as H,$t as I,fe as J,Er as K,ds as L,Vr as M,Ot as N,ms as O,Dt as P,qt as Q,ge as R,qr as S,_t as T,jt as U,Yr as V,re as W,Kt as X,ru as Y,Yt as Z,Qt as _,Wt as $,Jt as aa,en as ba,tn as ca,ve as da,rn as ea,w as fa,Te as ga,ie as ha,Ie as ia,dn as ja,Gc as ka,Zc as la,Jc as ma,hn as na,nt as oa,yn as pa,wo as qa,Eo as ra,Vo as sa,Xc as ta,ye as ua,Rn as va,In as wa,Mn as xa,qo as ya,we as za,wn as Aa,En as Ba,kn as Ca,zn as Da,On as Ea,Ee as Fa,ot as Ga,ue as Ha,vd as Ia,hd as Ja,yd as Ka,ke as La,Ne as Ma,Yn as Na,mm as Oa,N as Pa};
@@ -1 +0,0 @@
1
- import{expandTarget as R}from"@iiif/helpers";function W(e){return e.type==="SpecificResource"?[e.source,{selector:e.selector}]:[e,{selector:null}]}function y(e,o){let{selector:n,source:r}=R(o);if(r.id!==e.id)return[null,r];let t={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}};return[n?n.type==="TemporalSelector"?{type:"TemporalBoxSelector",temporal:n.temporal,spatial:t.spatial}:n:null,r]}var M={makeChoice:()=>{}},f={type:"unknown"},m=e=>({type:"unknown",reason:e,annotations:{pages:[]}}),x=(e,o)=>({type:"empty",width:e,height:o,annotations:{pages:[]},image:null,images:[]});var k=["model/gltf-binary"];function T(e,o){let r=o.items[0].resource;return r.format?k.indexOf(r.format)===-1?m(`3D format: ${r.format} is unsupported`):{type:"3d-model",model:r}:m("Unknown format")}import{getImageServices as N}from"@atlas-viewer/iiif-image-api";import{expandTarget as C}from"@iiif/helpers/annotation-targets";function S(e,o,n){let r=[];for(let t of o.items){let s=t.resource&&t.resource.type==="SpecificResource"?t.resource.source:t.resource;if(!s.id)return m("No resource Identifier");let p;if(s.service){let g=N(s);g[0]&&(p=n(g[0],e))}let d={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}},[i,a]=y(e,t.target);if(!(a.id===e.id||decodeURIComponent(a.id||"")===(e.id||"")))continue;let c=t.resource.width&&t.resource.height?{type:"BoxSelector",spatial:{x:0,y:0,width:t.resource.width,height:t.resource.height}}:void 0,l=t.resource.type==="SpecificResource"?C(t.resource):null;if(t.selector){let g=C({type:"SpecificResource",source:t.resource,selector:t.selector});g&&(l=g)}let u=l&&l.selector&&(l.selector.type==="BoxSelector"||l.selector.type==="TemporalBoxSelector")?{type:"BoxSelector",spatial:{x:l.selector.spatial.x,y:l.selector.spatial.y,width:l.selector.spatial.width,height:l.selector.spatial.height}}:void 0;p&&!p.id&&(p.id=p["@id"]);let v={id:s.id,type:"Image",annotationId:t.annotationId,width:Number(i||u?s.width:e.width),height:Number(i||u?s.height:e.height),service:p,sizes:p&&p.sizes?p.sizes:s.width&&s.height?[{width:s.width,height:s.height}]:[],target:i&&i.type!=="PointSelector"?i:d,selector:u||{type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}}};r.push(v)}return{type:"images",image:r[0],images:r,choice:o.choice}}function I(e,o={},n){let r=e.language||n||"none";switch(e.type){case"TextualBody":{typeof e.value<"u"&&(o[r]=e.value);break}case"List":case"Composite":case"Choice":e.items&&e.items.forEach(t=>I(t,o,r))}return o}function w(e,o){let n=[];return o.items.forEach(r=>{if(r.resource){let[t]=y(e,r.target);n.push({annotationId:r.annotationId,text:I(r.resource),target:t})}}),{type:"textual-content",items:n}}import{expandTarget as z,parseSelector as B}from"@iiif/helpers";var D=/^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\/)|(?:(?:watch)?\?vi?=|&vi?=))([^#&?]*).*/;function h(e,o){let n=o.items.filter(c=>c.type==="video"),r=!1;if(e.duration||(r=!0),n.length>1)return m("Only one video source supported");let t=n[0]?.resource,s=!!(t.service||[]).find(c=>(c.profile||"").includes("youtube.com"));if(!s&&r)return m("Video does not have duration");if(!t)return m("Unknown video");if((!t.format||t.format==="text/html")&&!s)return m("Video does not have format");let p=o.items[0],d={annotationId:o.items[0].annotationId,duration:e.duration,url:t.id,type:"Video",target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:t.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},i=z(p.target);i.selector&&i.selector.type==="TemporalBoxSelector"&&(d.target=i.selector);let{selector:a}=B(p.selector);if(a===null){let c=d.target.temporal.startTime,u=(d.target.temporal.endTime||e.duration)-c;d.selector={type:"TemporalSelector",temporal:{startTime:0,endTime:u}}}else a.type==="TemporalSelector"&&(d.selector=a);if(s){d.type="VideoYouTube";let c=t.id.match(D);if(!c[1])return m("Video is not known youtube video");d.youTubeId=c[1]}return{type:"media",media:d,annotations:{pages:[]}}}function P(e,o,n){let r={type:"complex-timeline",items:[],keyframes:[],duration:e.duration||0},t={type:"complex-choice",items:[]};function s(i){i.choice&&(i.choice.type==="complex-choice"?t.items.push(...i.choice.items):t.items.push(i.choice))}for(let i of o.items){if(i.type==="image"){let a=S(e,{choice:null,allChoices:null,types:["image"],items:[i]},n);if(a.type==="images"){s(a),r.items.push(a.image);let c={id:a.image.annotationId,type:"enter",resourceType:"image",time:a.image.target?.temporal?.startTime||0};r.keyframes.push(c);let l={id:a.image.annotationId,type:"exit",resourceType:"image",time:a.image.target?.temporal?.endTime||e.duration||0};r.keyframes.push(l)}}if(i.type==="video"){let a=h(e,{choice:null,allChoices:null,types:["video"],items:[i]});if(a.type==="media"){s(a);let c=a.media;r.items.push(c);let l={id:c.annotationId,type:"enter",resourceType:"video",time:c.target?.temporal?.startTime||0};r.keyframes.push(l);let u={id:c.annotationId,type:"exit",resourceType:"video",time:c.target?.temporal?.endTime||e.duration||0};r.keyframes.push(u)}}}r.keyframes.sort((i,a)=>i.time-a.time);let p=[],d=[];for(let i of r.keyframes){if(i.resourceType==="image"){d.push(i);continue}if(i.type==="enter"){p.length===0&&(i.isPrime=!0),p.push(i),d.push(i);continue}if(i.type==="exit"&&(d.push(i),p=p.filter(a=>a.id!==i.id),p.length!==0)){let a=p[0],c={id:a.id,type:"change",isPrime:!0,resourceType:a.resourceType,time:i.time};d.push(c)}}return r.keyframes=d,t.items.length&&(r.choice=t),r}function b(e,o){if(!e.duration)return m("No duration on canvas");if(o.items.length>1)return m("Only one audio source supported");let n=o.items[0]?.resource;return n?n.format?{type:"media",media:{annotationId:o.items[0].annotationId,duration:e.duration,url:n.id,type:"Sound",target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:n.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},annotations:{pages:[]}}:m("Audio does not have format"):m("Unknown audio")}function ce({canvas:e,paintables:o,supports:n,loadImageService:r}){if(!e)return f;if(o.types.length===0)return n.indexOf("empty")!==-1?x(e.width,e.height):f;if(o.types.length!==1)if(o.types.length===2&&o.types.indexOf("text")!==-1)o.types=o.types.filter(s=>s!=="text");else return n.indexOf("complex-timeline")===-1?m("Complex timeline not supported"):P(e,o,r);let t=o.types[0];return t==="image"?n.indexOf("images")===-1?m("Image not supported"):S(e,o,r):t==="Model"||t==="model"?n.indexOf("3d-model")===-1?m("3D not supported"):T(e,o):t==="textualbody"?n.indexOf("textual-content")===-1?m("Textual content not supported"):w(e,o):t==="sound"||t==="audio"?n.indexOf("media")===-1?m("Media not supported"):b(e,o):t==="video"?n.indexOf("media")===-1?m("Media not supported"):h(e,o):f}export{W as a,y as b,M as c,f as d,m as e,x as f,T as g,S as h,w as i,h as j,P as k,ce as l};