react-iiif-vault 1.2.5 → 1.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.d.ts +6 -1
- package/dist/bundle.global.js +18 -18
- package/dist/canvas-panel.cjs +4 -4
- package/dist/canvas-panel.js +1 -1
- package/dist/{chunk-7Z6G4L4M.js → chunk-QKLET6KX.js} +7 -7
- package/dist/index.cjs +7 -7
- package/dist/index.d.cts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/canvas-panel.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";var Or=Object.create;var qe=Object.defineProperty;var Fr=Object.getOwnPropertyDescriptor;var Hr=Object.getOwnPropertyNames;var Dr=Object.getPrototypeOf,Ur=Object.prototype.hasOwnProperty;var Br=(e,t)=>{for(var n in t)qe(e,n,{get:t[n],enumerable:!0})},Bt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Hr(t))!Ur.call(e,o)&&o!==n&&qe(e,o,{get:()=>t[o],enumerable:!(r=Fr(t,o))||r.enumerable});return e};var G=(e,t,n)=>(n=e!=null?Or(Dr(e)):{},Bt(t||!e||!e.__esModule?qe(n,"default",{value:e,enumerable:!0}):n,e)),qr=e=>Bt(qe({},"__esModule",{value:!0}),e);var Ro={};Br(Ro,{CanvasPanel:()=>M});module.exports=qr(Ro);var De=require("react");var E=G(require("react"),1),Je=require("@atlas-viewer/atlas"),qn=require("react-error-boundary");var J=require("react");var ue=G(require("react"),1),qt=require("react/jsx-runtime"),$r={collection:void 0,manifest:void 0,range:void 0,canvas:void 0,annotation:void 0,annotationPage:void 0},$e=ue.default.createContext($r),F=()=>(0,ue.useContext)($e);function Z({value:e,children:t}){let n=F(),r=(0,ue.useMemo)(()=>({...n,...e}),[e,n]);return(0,qt.jsx)($e.Provider,{value:r,children:t})}var _e=G(require("react"),1),Re=require("@iiif/helpers/vault");var Ct=require("react/jsx-runtime"),re=_e.default.createContext({vault:null,setVaultInstance:e=>{}});function ce({vault:e,vaultOptions:t,useGlobal:n,resources:r,children:o}){let[i,a]=(0,_e.useState)(()=>e||(n?(0,Re.globalVault)(t):t?new Re.Vault(t):new Re.Vault));return(0,Ct.jsx)(re.Provider,{value:{vault:i,setVaultInstance:a},children:(0,Ct.jsx)(Z,{value:r||{},children:o})})}var An=require("react"),Ge=require("react");var $t=require("@iiif/helpers/vault"),_t=require("react");function le(e){let t=(0,_t.useContext)(re);return e||(t&&t.vault?t.vault:(0,$t.globalVault)())}var K=require("react");function Wt(e,{noCache:t=!1}={}){let n=typeof e=="string"?e:e.id,r=le(),[o,i]=(0,K.useState)(n),[a,s]=(0,K.useState)(void 0),u=(0,K.useMemo)(()=>r.get(n,{skipSelfReturn:!0})||void 0,[n,r]),[c,l]=(0,K.useState)(u);return(0,K.useEffect)(()=>{(async()=>{try{let d=u&&!t?u:await r.load(n),g=d?d.id||d["@id"]:null;d&&o!==g&&i(g),l(d)}catch(d){s(d)}})()},[n,t]),{isLoaded:!!c,id:o,requestId:n,error:a,resource:c,cached:!!(c&&c===u)}}function jt(e,t){let{id:n,isLoaded:r,error:o,resource:i,requestId:a,cached:s}=Wt(e,t);return{id:n,isLoaded:r,error:o,manifest:i,requestId:a,cached:s}}var Qt=require("react/jsx-runtime");function Yt({manifest:e,children:t}){return(0,Qt.jsx)(Z,{value:{manifest:e},children:t})}var Gt=require("react/jsx-runtime");function _({canvas:e,children:t}){return(0,Gt.jsx)(Z,{value:{canvas:e},children:t})}var Kt=require("react"),Jt=G(require("react"),1);var Zt=require("react"),y=()=>{let{vault:e}=(0,Zt.useContext)(re);if(e===null)throw new Error("Vault not found. Ensure you have your provider set up correctly.");return e};var We=require("react");function S(e,t=[]){let n=y(),[r,o]=(0,We.useState)(()=>e(n.getState(),n));return(0,We.useEffect)(()=>n.subscribe(i=>e(i,n),i=>{o(i)},!1),t),r}var de=Jt.default.createContext([]);function je(){let e=(0,Kt.useContext)(de);return S(t=>e.map(n=>t.iiif.entities.Canvas[n]).filter(Boolean),[e])}var Xt=require("react");function T(e={},t=[]){let{id:n,selector:r}=e,o=F(),i=y(),a=n||o.manifest,s=S(u=>a?u.iiif.entities.Manifest[a]:void 0,[a]);return(0,Xt.useMemo)(()=>{if(s)return r?r(s):s},[s,r,...t])}var tn=require("react/jsx-runtime");function en({range:e,children:t}){return(0,tn.jsx)(Z,{value:{range:e},children:t})}function At(e,t){let n=[];for(let r of t.items)if(r.type==="SpecificResource"&&r.source?.type==="Canvas"&&(r.source.id.indexOf("#")!==-1?n.push({id:r.source.id.split("#")[0],type:"Canvas"}):n.push(r.source)),r.type==="Range"&&n.push(...At(e,e.get(r))),r.type==="SpecificResource"){let o=typeof r.source=="string"?r.source:r.source.id;n.push({id:o,type:"Canvas"})}return n}function nn(e,t,{disablePaging:n,skipNonPaged:r}={}){let o=t.behavior,i=o.includes("paged"),a=i?!1:o.includes("continuous"),s=i||a?!1:o.includes("individuals"),u=t.type==="Manifest"?t.items:At(e,t);if(a)return[u,[u.map((m,p)=>p)]];if(s||!i||n)return[u,u.map((m,p)=>[p])];let c=[],l=[],d=()=>{l.length&&(c.push([...l]),l=[])},g=0,h=!1;for(let m=0;m<u.length;m++){let p=e.get(u[m]);if(p.behavior.includes("non-paged")){m===g&&g++,r||(d(),c.push([m]),d());continue}if(m===g||p.behavior.includes("facing-pages")){l.length&&(h=!0),d(),c.push([m]),d();continue}if(l.push(m),h){d(),h=!1;continue}l.length>1&&d()}return l.length&&d(),[u,c]}var H=require("react");var rn=require("react");function on(e={},t=[]){let{id:n,selector:r}=e,o=F(),i=n||o.range,a=S(s=>i?s.iiif.entities.Range[i]:void 0,[i]);return(0,rn.useMemo)(()=>{if(a)return r?r(a):a},[a,r,...t])}function an({startCanvas:e,disablePaging:t}){let n=y(),r=T(),o=on(),[i,a]=(0,H.useState)(void 0),s=o||r;if(!s)throw new Error("Nothing selected");let[u,c]=(0,H.useMemo)(()=>nn(n,s,{disablePaging:t}),[n,s,t]),l=(0,H.useRef)(c);if(l.current!==c){let P=l.current[i][0],x=c.findIndex(Y=>Y.includes(P));l.current=c,a(x)}let d=(0,H.useCallback)(p=>{let P=c.findIndex(x=>x.includes(p));a(P===-1?0:P)},[u,c]),g=(0,H.useCallback)(p=>{let P=u.findIndex(x=>x.id===p);P!==-1?d(P):a(0)},[u,c]),h=(0,H.useCallback)(()=>{a(p=>p>=c.length-1?p:p+1)},[c]),m=(0,H.useCallback)(()=>{a(p=>p<=0?0:p-1)},[c]);return typeof i>"u"&&(e?g(e):a(0)),{visibleItems:c[i]?.map(p=>u[p].id)||[],cursor:i,items:u,sequence:c,hasPrevious:i>0,hasNext:i<c.length-1,setSequenceIndex:a,setCanvasIndex:d,setCanvasId:g,next:h,previous:m}}var U=require("react"),Ye=require("zustand");var Rt=require("zustand/vanilla");function D(e,t,n){let r=t.findIndex(a=>a.service.id===e);if(r===-1)return t;let o=[...t],i=n(o[r]);return i===o[r]?t:(o[r]=i,o)}var un=()=>(0,Rt.createStore)((e,t)=>({currentAuth:-1,authItems:[],login:()=>{let n=t().authItems[t().currentAuth];if(!n||n.isPending||n.isLoggedIn)return;if(n.type!=="active")throw new Error("Cannot login to non-active service");let r=n.service.service.find(o=>o.type==="AuthAccessTokenService2");if(!r)throw new Error("Token service not found");e(()=>({authItems:D(n.id,t().authItems,o=>({...o,isPending:!0}))})),sn(n.service).then(()=>{Pt(r).then(o=>{let i=o.expiresIn,a=Date.now()+i*1e3;e(()=>({authItems:D(n.id,t().authItems,s=>({...s,isLoggedIn:!0,isPending:!1,session:{token:o.accessToken,expires:a}}))}))}).catch(o=>{e(()=>({authItems:D(n.id,t().authItems,i=>({...i,isLoggedIn:!1,isPending:!1,error:o.message}))}))})})},logout:()=>{let n=t().authItems[t().currentAuth];if(!n||n.isPending||!n.isLoggedIn)return;if(n.type!=="active")throw new Error("Cannot logout of non-active service");let r=n.service.service.find(a=>a.type==="AuthLogoutService2");if(!r)return;let o=`${r.id}?origin=${dn()}`,i=window.open(o);e(()=>({authItems:D(n.id,t().authItems,a=>({...a,isLoggedIn:!1,session:null,isPending:!1}))}))},nextAuth:()=>{let n=t().authItems.length,r=t().currentAuth+1;r>=n||e(()=>({currentAuth:r}))},previousAuth:()=>{let n=t().currentAuth-1;n<0||e(()=>({currentAuth:n}))},setAuth:n=>{n!==-1&&(n<0||n>=t().authItems.length)||e(()=>({currentAuth:n}))},addService:(n,r)=>{if(!n.service)return;let o=n.service.find(s=>s.type==="AuthAccessTokenService2"),i=n;if(t().authItems.find(s=>s.service.id===n.id)){e(()=>({authItems:D(n.id,t().authItems,s=>({...s,instances:s.instances+1}))}));return}if(e(()=>({currentAuth:i.profile==="active"?0:t().currentAuth,authItems:[{id:n.id,type:n.profile,service:n,probeId:r,canAuthenticate:!0,instances:1,isPending:!1,isLoggedIn:!1,session:null},...t().authItems]})),n.profile==="external"){if(!o)throw new Error("Token service not found");Pt(o).then(s=>{e(()=>({authItems:D(n.id,t().authItems,u=>({...u,isLoggedIn:!0,isPending:!1,session:{token:s.accessToken,expires:s.expiresIn}}))}))}).catch(s=>{e(()=>({authItems:D(n.id,t().authItems,u=>({...u,isLoggedIn:!1,isPending:!1,canAuthenticate:!1,error:s.message}))}))})}if(n.profile==="kiosk"){if(!o)throw new Error("Token service not found");e(()=>({authItems:D(n.id,t().authItems,s=>({...s,isPending:!0}))})),sn(i).then(()=>{Pt(o).then(s=>{e(()=>({authItems:D(n.id,t().authItems,u=>({...u,isLoggedIn:!0,isPending:!1,session:{token:s.accessToken,expires:s.expiresIn}}))}))}).catch(s=>{e(()=>({authItems:D(n.id,t().authItems,u=>({...u,isLoggedIn:!1,isPending:!1,error:s.message}))}))})})}n.profile},removeService:(n,r)=>{let o=t().currentAuth===t().authItems.findIndex(a=>a.service.id===n.id),i=t().currentAuth;if(o){let a=t().authItems.find(u=>u.service.id===n.id);a&&a.instances>1||(i=t().authItems.findIndex(c=>c.service.id!==n.id&&c.instances>0))}e(()=>({authItems:D(n.id,t().authItems,a=>({...a,instances:a.instances-1})),currentAuth:i}))}})),cn=(e,t)=>(0,Rt.createStore)((n,r)=>({service:e,status:e?"unknown":"success",shouldRedirect:!1,redirectResource:null,shouldSubstitute:!1,substituteResource:null,error:null,errorHeading:null,errorNote:null,shouldDisplayResource:!1,token:t||null,async probe(){if(!r().service)return;let o=r().service?.id;if(!o){n({status:"error",error:"Service ID not found",errorHeading:{en:["Service ID not found"]}});return}n({status:"probing"});let i=r().token;try{let a=await fetch(o,{headers:i?{Authorization:`Bearer ${r().token}`,Accept:"application/json"}:{Accept:"application/json"}}).then(s=>s.json());if(a.status===200)n({status:"success",shouldDisplayResource:!0,error:null,errorHeading:null,errorNote:null,shouldSubstitute:!1,shouldRedirect:!1});else if(a.status<400&&a.status>=300){if(!a.location)throw new Error("Redirect location not found");n({status:"error",shouldDisplayResource:!1,shouldRedirect:!0,redirectResource:a.location||null})}else if(a.status===401)n({status:"error",shouldDisplayResource:!1,shouldRedirect:!1,shouldSubstitute:!!a.substitute,substituteResource:a.substitute||null,error:"Unauthorized",errorHeading:a.heading||{en:["Unauthorized"]},errorNote:a.note||null});else throw new Error("Unknown error")}catch(a){n({status:"error",error:a.message,errorHeading:{en:["Unknown error"]}})}},setToken(o){n({token:o})}}));function ln(e){let t=e.service||e.services||[],n={hasAuth:!1,services:{}};for(let r of t)if(r.type==="AuthProbeService2"){n.services.probe=r,n.hasAuth=!0;let o=r.service.filter(i=>i.type==="AuthAccessService2");o[0]&&(n.services.access=o[0])}return n}async function Pt(e,{strict:t=!0}={}){return new Promise((n,r)=>{let o=Math.random().toString(36).substring(7),i=`${e.id}?messageId=${o}&origin=${window.location.origin}`,a=c=>{let l=c.data;if(l.messageId===o){if(t&&l.type!=="AuthAccessToken2"){s(),r("Invalid response, expected type=AuthAccessToken2");return}if(!l.accessToken){s(),r("Invalid response, expected accessToken");return}s(),n(l)}},s=()=>window.removeEventListener("message",a),u=document.createElement("iframe");u.src=i,u.style.display="none",document.body.appendChild(u),window.addEventListener("message",a)})}function dn(e){let t=window.location;if(e){let n=document.createElement("a");return n.href=e,n.protocol+"//"+n.hostname+(n.port?":"+n.port:"")}return t.protocol+"//"+t.hostname+(t.port?":"+t.port:"")}async function sn(e){let t=`${e.id}?origin=${dn()}`,n=window.open(t);if(!n)throw new Error("Failed to open window");return new Promise((r,o)=>{let i=setInterval(()=>{n.closed&&(clearInterval(i),r())},500)})}var me=require("react");var mn=require("zustand");function fn(e){let t=(0,me.useMemo)(()=>ln(e),[e]),n=pn(t.services.access?.id),r=(0,me.useMemo)(()=>cn(t.services.probe,n),[t.services.probe]),o=(0,mn.useStore)(r);return(0,me.useEffect)(()=>{o.status==="unknown"&&!n&&o.probe()},[t.services.probe,o.status]),(0,me.useEffect)(()=>{n&&(o.setToken(n),o.probe())},[n]),[e,o,t.hasAuth]}var be=require("react/jsx-runtime"),fe=(0,U.createContext)(null),_r=(0,U.createContext)(null);_r.displayName="CurrentAuth";var Wr=(0,U.createContext)(null);Wr.displayName="AuthActions";function gn({children:e}){let t=(0,U.useMemo)(()=>un(),[]);return(0,be.jsx)(fe.Provider,{value:t,children:e})}function hn(){return!!(0,U.useContext)(fe)}function It(){let e=(0,U.useContext)(fe);if(!e)throw new Error("useAuthActions must be used within a AuthProvider");return e}function jr(){let e=It();return(0,Ye.useStore)(e,n=>({login:n.login,logout:n.logout,nextAuth:n.nextAuth,previousAuth:n.previousAuth,setAuth:n.setAuth,addService:n.addService,removeService:n.removeService}))}function Yr(e){let t=It();return(0,Ye.useStore)(t,r=>r.authItems.find(o=>o.service.id===e))}function pn(e){let t=It();return(0,Ye.useStore)(t,r=>r.authItems.find(o=>o.id===e)?.session?.token)}function Qr(e){let t=jr(),n=Yr(e.service.id);return(0,U.useEffect)(()=>(t?.addService(e.service,e.probeId),()=>{t?.removeService(e.service,e.probeId)}),[e.service]),n?(n.error||!n.isLoggedIn,e.children):null}function bt(){return null}function vn(e){let[t,n,r]=fn(e.resource),o=e.fallbackComponent||bt,i=e.loadingComponent||bt,a=e.errorComponent||bt,s=n.service,u=null;if(!r||!s)return e.children(t);let c=s.service.filter(l=>l.type==="AuthAccessService2");n.status==="error"&&(u=(0,be.jsx)(a,{resource:e.resource,error:n.error||"",heading:n.errorHeading,note:n.errorNote,extra:e.extra})),(n.status==="unknown"||n.status==="probing")&&(u=(0,be.jsx)(i,{})),n.status==="success"&&(u=e.children(t));for(let l of c)u=(0,be.jsx)(Qr,{service:l,probeId:s.id,children:u},l.id);return u}var Ie=require("react");var yn=require("zustand/vanilla"),Gr=e=>e.id||e["@id"];function Zr(e){return(Array.isArray(e.service)?e.service:[e.service]).find(n=>n.profile==="http://iiif.io/api/search/0/autocomplete"||n.profile==="http://iiif.io/api/search/1/autocomplete"||n.profile==="AutoCompleteService1")}var Sn=e=>{let t;typeof e=="string"?t={"@context":"http://iiif.io/api/search/1/context.json",profile:"http://iiif.io/api/search/1/search","@id":e,id:e,service:[]}:t=e;let n=t?Gr(t):void 0,r=null;return(0,yn.createStore)((o,i)=>({service:t,resources:[],lastQuery:{},loading:!1,error:!1,highlight:null,hasSearch:!!t,hasAutocomplete:t?!!Zr(t):!1,errorMessage:"",search(a,s={}){if(!n)throw new Error("No search service found.");r&&!r.signal.aborted&&r.abort(),r=new AbortController;let u=new URLSearchParams;a.q&&u.set("q",a.q),a.motivation&&u.set("motivation",a.motivation),a.date&&u.set("date",a.date),a.user&&u.set("user",a.user),o({loading:!0}),fetch(`${n}?${u.toString()}`,{signal:r.signal,headers:{"Content-Type":"application/json",Accept:"application/json",...s.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(a){let s=i().resources.find(u=>u["@id"]===a);o({highlight:s})},nextResult(){let a=i().resources,s=i().highlight;if(!s){o({highlight:a[0]||null});return}let u=a.findIndex(c=>c["@id"]===s["@id"]);if(u===-1){o({highlight:a[0]||null});return}o({highlight:a[u+1]||a[0]||null})},previousResult(){let a=i().resources,s=i().highlight;if(!s){o({highlight:a[a.length-1]||null});return}let u=a.findIndex(c=>c["@id"]===s["@id"]);if(u===-1){o({highlight:a[a.length-1]||null});return}if(u===0){o({highlight:a[a.length-1]||null});return}o({highlight:a[u-1]||a[a.length-1]||null})}}))};var Kr=require("zustand");function xn(){let e=T();return e?e.service.find(t=>t.profile==="SearchService1"||t.profile==="http://iiif.io/api/search/1/search"):void 0}var Qe=require("react/jsx-runtime"),pe=(0,Ie.createContext)(null);pe.displayName="Search";function Cn(e){let t=xn();return e.store?(0,Qe.jsx)(pe.Provider,{value:e.store,children:e.children}):(0,Qe.jsx)(Jr,{service:t,children:e.children})}function Jr({service:e,children:t}){let n=(0,Ie.useMemo)(()=>Sn(e),[e]);return(0,Qe.jsx)(pe.Provider,{value:n,children:t})}var k=require("react/jsx-runtime"),we=()=>{},Te=(0,Ge.createContext)({setCurrentCanvasId:we,setCurrentCanvasIndex:we,nextCanvas:we,previousCanvas:we,items:[],sequence:[],setSequenceIndex:we,currentSequenceIndex:0,hasNext:!1,hasPrevious:!1});function Xr(e){let t=T(),{cursor:n,visibleItems:r,next:o,sequence:i,items:a,setCanvasIndex:s,setCanvasId:u,previous:c,setSequenceIndex:l,hasNext:d,hasPrevious:g}=an({startCanvas:e.startCanvas,disablePaging:e.pagingEnabled===!1}),h=(0,Ge.useMemo)(()=>({sequence:i,items:a,setCurrentCanvasId:u,nextCanvas:o,previousCanvas:c,totalCanvases:a.length,setCurrentCanvasIndex:s,setSequenceIndex:l,currentSequenceIndex:n,hasNext:d,hasPrevious:g}),[i,a,u,o,c,a,s,l,n]);return t?r.length===0?null:(0,k.jsx)(Te.Provider,{value:h,children:(0,k.jsx)(de.Provider,{value:r,children:(0,k.jsx)(_,{canvas:r[0],children:e.children})})}):(console.warn("The manifest passed to the provider is not a valid IIIF manifest."),(0,k.jsx)("div",{children:"Sorry, something went wrong."}))}function Pn(e){let t=le(e.vault),n=jt(e.manifest);if(!n)return console.warn("The manifest passed to the provider is not a valid IIIF manifest."),(0,k.jsx)("div",{children:"Sorry, something went wrong."});if(n.error)return(0,k.jsx)("div",{children:n.error.toString()});if(!n.isLoaded)return(0,k.jsx)("div",{children:"Loading..."});let r=(0,k.jsx)(Xr,{...e,children:e.children});return(0,k.jsx)(ce,{vault:t,children:(0,k.jsx)(Yt,{manifest:n.id,children:(0,k.jsx)(gn,{children:(0,k.jsx)(Cn,{children:e.rangeId?(0,k.jsx)(en,{range:e.rangeId,children:r}):r})})})})}function Rn(){return(0,An.useContext)(Te)}var bn=G(require("react"),1),wt=require("react"),In=G(require("mitt"),1),to=require("react/jsx-runtime"),eo=(0,In.default)(),Me=(0,wt.createContext)({emitter:eo});Me.displayName="Events";function wn(){return bn.default.useContext(Me).emitter}var oe=require("react/jsx-runtime");function Tn(){return{VaultContext:(0,J.useContext)(re),ResourceContext:(0,J.useContext)($e),SimpleViewerReactContext:(0,J.useContext)(Te),VisibleCanvasReactContext:(0,J.useContext)(de),AuthRContext:(0,J.useContext)(fe),SearchReactContext:(0,J.useContext)(pe),ReactEventContext:(0,J.useContext)(Me)}}function Mn(e){return(0,oe.jsx)(ce,{vault:e.bridge.VaultContext.vault||void 0,resources:e.bridge.ResourceContext,children:(0,oe.jsx)(de.Provider,{value:e.bridge.VisibleCanvasReactContext,children:(0,oe.jsx)(Te.Provider,{value:e.bridge.SimpleViewerReactContext,children:(0,oe.jsx)(Me.Provider,{value:e.bridge.ReactEventContext,children:(0,oe.jsx)(fe.Provider,{value:e.bridge.AuthRContext,children:(0,oe.jsx)(pe.Provider,{value:e.bridge.SearchReactContext,children:e.children})})})})})})}var ge=require("react");var W=require("react");var Ze=require("@iiif/helpers/vault/actions");var Vn=require("react");function Nn(){let t=y().getStore();return(0,Vn.useMemo)(()=>n=>t.dispatch(n),[t])}function En(e){return typeof e!="string"&&e&&e.bindToVault}function kn(){let e=y(),t=(0,W.useRef)([]),n=Nn(),r=(0,W.useMemo)(()=>`vault://annotation-page/${new Date().getTime()}/${Math.round(Math.random()*1e9).toString(16)}`,[]);(0,W.useLayoutEffect)(()=>{let s={id:r,type:"AnnotationPage",behavior:[],label:null,thumbnail:[],summary:null,requiredStatement:null,metadata:[],rights:null,provider:[],items:[],seeAlso:[],homepage:[],rendering:[],service:[]};n(Ze.entityActions.importEntities({entities:{AnnotationPage:{[s.id]:s}}}))},[r]);let o=S(s=>r&&s.iiif.entities.AnnotationPage[r]||null,[r]),i=(0,W.useCallback)((s,u)=>{if(r){if(En(s)){let d=s;d.__vault||d.bindToVault(e),s=typeof d.source=="string"?d.source:d.source.id,t.current[s]=d}else typeof s!="string"&&(s=s.id);let c=e.get({id:r,type:"AnnotationPage"}),l=e.get({id:s,type:"Annotation"});c&&l&&(c.items.find(d=>d.id===l.id)||n(Ze.entityActions.addReference({id:r,type:"AnnotationPage",key:"items",reference:{id:s,type:"Annotation"},index:u})))}},[r]),a=(0,W.useCallback)(s=>{r&&(En(s)?s=typeof s.source=="string"?s.source:s.source.id:typeof s!="string"&&(s=s.id),t.current[s]&&t.current[s].beforeRemove(),e.get({id:r,type:"AnnotationPage"})&&n(Ze.entityActions.removeReference({id:r,type:"AnnotationPage",key:"items",reference:{id:s,type:"Annotation"}})))},[r]);return[o,{addAnnotation:i,removeAnnotation:a}]}var Fn=require("react/jsx-runtime"),Ln=(0,ge.createContext)(null);function zn(){let e=(0,ge.useContext)(Ln);return[e.fullPage,{addAnnotation:e.addAnnotation,removeAnnotation:e.removeAnnotation}]}function On({children:e}){let[t,{addAnnotation:n,removeAnnotation:r}]=kn();return(0,Fn.jsx)(Ln.Provider,{value:(0,ge.useMemo)(()=>({fullPage:t,addAnnotation:n,removeAnnotation:r}),[t]),children:e})}var he=require("react/jsx-runtime");function Hn({width:e,style:t,height:n,error:r,resetErrorBoundary:o}){return(0,he.jsxs)("div",{style:{width:e,height:n,minHeight:500,...t||{},background:"#f9f9f9"},children:[(0,he.jsx)("h3",{children:"Error occurred"}),(0,he.jsx)("p",{children:r.message}),(0,he.jsx)("button",{onClick:o,children:"Reset"})]})}var Ke=require("react"),Ve=(0,Ke.createContext)(null);function Dn(){return(0,Ke.useContext)(Ve)}var ie=require("react"),Tt=(0,ie.createContext)(()=>{}),Mt=(0,ie.createContext)(()=>{});function B(e,t,n,r,o=[]){let i=(0,ie.useContext)(e==="portal"?Mt:Tt);(0,ie.useEffect)(()=>(e!=="none"&&i(t,n,r),()=>{i(t,null)}),[t,e,i,...o])}var ve=require("react");var Un=require("react");function R(e={},t=[]){let{id:n,selector:r}=e,o=F(),i=n||o.canvas,a=S(s=>i?s.iiif.entities.Canvas[i]:void 0,[i]);return(0,Un.useMemo)(()=>{if(a)return r?r(a):a},[a,r,...t])}var Vt=(0,ve.createContext)(()=>{});function Bn(e){let t=R(),n=(0,ve.useContext)(Vt);(0,ve.useEffect)(()=>t&&t.id?(n(t.id,e),()=>n(t.id,-1)):()=>{},[t,e])}var w=require("react/jsx-runtime");function $n({children:e,errorFallback:t,outerContainerProps:n={},worldScale:r,...o}){let[i,a]=(0,E.useState)(),s=Tn(),u=t||Hn,[c,l]=(0,E.useState)({}),d=Object.entries(c),[g,h]=(0,E.useState)({}),m=Object.entries(g),[p,P]=(0,E.useState)({}),x=(0,E.useMemo)(()=>r||Math.max(...Object.values(p)),[p]),Y=(0,E.useMemo)(()=>({maxOverZoom:x||1,...o.runtimeOptions||{}}),[x,o.runtimeOptions]),V=(0,E.useCallback)((b,N)=>{P(z=>{if(N===-1){let{[b]:f,...$}=z;return $}return{...z,[b]:N}})},[]),yt=(0,E.useCallback)((b,N,z)=>{l(({[b]:f,...$})=>N?{...$,[b]:{element:N,props:z}}:$)},[]),Ue=(0,E.useCallback)((b,N,z)=>{h(({[b]:f,...$})=>N?{...$,[b]:{element:N,props:z}}:$)},[]);return(0,w.jsxs)(qn.ErrorBoundary,{resetKeys:[],fallbackRender:b=>(0,w.jsx)(u,{...o,...b}),children:[(0,w.jsx)(Je.AtlasAuto,{...o,containerProps:{style:{position:"relative"},...o.containerProps||{}},htmlChildren:(0,w.jsx)(w.Fragment,{children:d.map(([b,{element:N,props:z}])=>(0,w.jsx)(E.default.Fragment,{children:(0,w.jsx)(N,{...z||{}})},b))}),onCreated:b=>{a(b),o.onCreated&&o.onCreated(b)},runtimeOptions:Y,children:(0,w.jsx)(Ve.Provider,{value:i,children:(0,w.jsx)(Vt.Provider,{value:V,children:(0,w.jsx)(Tt.Provider,{value:yt,children:(0,w.jsx)(Mt.Provider,{value:Ue,children:(0,w.jsx)(Mn,{bridge:s,children:(0,w.jsx)(Je.ModeContext.Provider,{value:o.mode||"explore",children:(0,w.jsx)(On,{children:e})})})})})})})}),(0,w.jsx)("div",{children:m.map(([b,{element:N,props:z}])=>(0,w.jsx)(E.default.Fragment,{children:(0,w.jsx)(N,{...z||{}})},b))})]})}var tt=require("@atlas-viewer/atlas");var Nt=require("react"),_n=require("@iiif/helpers/events");function Xe(e,t){let n=y(),r=(0,Nt.useMemo)(()=>(0,_n.createEventsHelper)(n),[n]),o=S(()=>e&&e.id?n.getResourceMeta(e.id,"eventManager"):null,[e]);return(0,Nt.useMemo)(()=>e?r.getListenersAsProps(e,t):{},[o,e,n,t])}var Wn=require("react"),jn=require("@iiif/helpers/styles");function ye(e,t){let n=y(),r=(0,Wn.useMemo)(()=>(0,jn.createStylesHelper)(n),[n]);return S(()=>{if(!e)return null;let o=r.getAppliedStyles(e.id);return o?t?o[t]:o:void 0},[e,t])}var Gn=require("react");var Yn=require("react");var Qn=require("@iiif/helpers/annotation-targets");function et(e={},t=[]){let{id:n,selector:r}=e,o=F(),i=y(),a=n||o.annotation,s=S(c=>a?c.iiif.entities.Annotation[a]:void 0,[a]),u=S(c=>s&&s.body?s.body.map(l=>l?l.type==="SpecificResource"?{...l,source:i.get(l)}:l?c.iiif.entities[l.type][l.id]:null:null).filter(Boolean):[],[s]);return(0,Yn.useMemo)(()=>{if(!s)return;let c={...s,body:u,target:(0,Qn.expandTarget)(s.target,{typeMap:i.getState().iiif.mapping})};return r?r(c):c},[s,r,u,...t])}var Zn=require("react/jsx-runtime"),nt=({id:e,style:t,className:n,interactive:r})=>{let o=et({id:e}),i=ye(o,"atlas"),a=ye(o,"html"),s=Xe(o,["atlas"]),u=R(),c=(0,Gn.useMemo)(()=>(0,tt.mergeStyles)(t,i),[t,i]);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)?(0,Zn.jsx)(tt.RegionHighlight,{id:o.id,isEditing:!0,region:o.target.selector.spatial,style:c,className:a?.className||n,interactive:!!(a?.href||r),href:a?.href||null,title:a?.title||null,hrefTarget:a?.target||null,onClick:()=>{},...s}):null};var Xn=require("react");var Kn=require("react");function Jn(e={},t=[]){let{id:n,selector:r}=e,o=F(),i=n||o.annotationPage,a=S(s=>i?s.iiif.entities.AnnotationPage[i]:void 0,[i]);return(0,Kn.useMemo)(()=>{if(a)return r?r(a):a},[a,...t])}var Et=require("react/jsx-runtime"),Ne=({className:e,page:t})=>{let n=Jn({id:t.id})||t,r=ye(n,"atlas"),o=ye(n,"html");return S(i=>n.id?i.iiif.entities.AnnotationPage[n.id]:null,[]),(0,Et.jsx)(Xn.Fragment,{children:n.items?.map(i=>(0,Et.jsx)(nt,{id:i.id,style:r,className:o?.className||e},i.id))})};var Er=require("@iiif/helpers/styles");var Le=require("react");var ke=require("@atlas-viewer/atlas");var j=G(require("react"),1),X=require("react/jsx-runtime"),no=j.default.createContext("en"),ro=j.default.createContext({});function tr(){return j.default.useContext(no)}function oo(){return j.default.useContext(ro)}function er(e){return e.indexOf("-")!==-1?e.slice(0,e.indexOf("-")):e}function io({as:e,language:t,children:n,viewingDirection:r,...o}){let i=tr();return(0,j.useMemo)(()=>er(i)===er(t),[i,t])?e?(0,X.jsx)(e,{...o,children:n}):(0,X.jsx)("span",{...o,children:n}):e?(0,X.jsx)(e,{...o,lang:t,dir:r,children:n}):(0,X.jsx)("span",{...o,lang:t,dir:r,children:n})}function ao(e,t,n){if(t.length===0)return;if(t.length===1)return t[0];if(t.indexOf(e)!==-1)return e;let r=e.indexOf("-")!==-1?e.slice(0,e.indexOf("-")):null;if(r&&t.indexOf(r)!==-1)return r;for(let o of n)if(t.indexOf(o)!==-1)return o;return t.indexOf("none")!==-1?"none":t.indexOf("@none")!==-1?"@none":t[0]}var so=(e,t=[])=>{let n=tr();return(0,j.useMemo)(()=>{let r=e();return ao(n,r,[])},[n,...t])};function kt(e,t){return t?e[t]||t:""}function uo(e,t,n=`
|
|
2
|
-
`,r={}){let o=so(()=>Object.keys(e||{}),[e]);return[(0,j.useMemo)(()=>{if(!e)return kt(r,t)||"";if(typeof e=="string")return kt(r,e);let i=o?e[o]:void 0;return i?typeof i=="string"?i:i.map(a=>kt(r,a)).join(n):""},[o,t,e]),o]}function Ee({as:e,defaultText:t,enableDangerouslySetInnerHTML:n,children:r,separator:o,...i}){let a=oo(),[s,u]=uo(r,t,o,a);return u?(0,X.jsx)(io,{...i,as:e,language:u,title:n?void 0:s,dangerouslySetInnerHTML:n?{__html:s}:void 0,children:n?void 0:s}):e?(0,X.jsx)(e,{...i,children:s}):(0,X.jsx)("span",{...i,title:n?void 0:s,dangerouslySetInnerHTML:n?{__html:s}:void 0,children:n?void 0:s})}var O=require("react/jsx-runtime");function co({resource:e,heading:t,note:n,extra:r}){return r?(0,O.jsx)(ke.HTMLPortal,{target:{x:0,y:0,width:r.target?.spatial.width,height:r.target?.spatial.height},backgroundColor:"#333",relative:!0,children:(0,O.jsx)("div",{style:{display:"flex",alignContent:"center",justifyContent:"center",alignItems:"center",height:"100%",width:"100%",background:"#444",color:"#BBB"},children:(0,O.jsxs)("div",{children:[(0,O.jsx)(Ee,{children:t||"Not authorised"}),n&&(0,O.jsx)("p",{children:(0,O.jsx)(Ee,{children:n})}),(0,O.jsx)("p",{children:e.id||e["@id"]||"unknown"})]})})}):null}function nr({image:e,thumbnail:t,crop:n,enableSizes:r}){if(!hn()){let i=e.service,a=i.width||e.width||0,s=i.height||e.height||0;return(0,O.jsx)(ke.TileSet,{tiles:{id:i.id||i["@id"]||"unknown",height:s,width:a,imageService:i},enableSizes:r,x:0,y:0,width:e.target?.spatial.width,height:e.target?.spatial.height,crop:n})}return(0,O.jsx)(vn,{resource:e.service,errorComponent:co,extra:e,children:i=>{let a=i.width||e.width||0,s=i.height||e.height||0;return(0,O.jsx)(ke.TileSet,{tiles:{id:i.id||i["@id"]||"unknown",height:s,width:a,imageService:i},enableSizes:r,x:0,y:0,width:e.target?.spatial.width,height:e.target?.spatial.height,crop:n})}},e.id)}var ae=require("react/jsx-runtime");function rt({id:e,image:t,thumbnail:n,isStatic:r,x:o=0,y:i=0,children:a,selector:s,onClick:u,enableSizes:c}){let l=(0,Le.useMemo)(()=>{if(!(!s||s.spatial.x===0&&s.spatial.y===0))return s.spatial},[s]);return(0,ae.jsx)("world-object",{x:o+t.target.spatial.x,y:i+t.target.spatial.y,width:t.target.spatial.width,height:t.target.spatial.height,onClick:u,children:t.service?(0,ae.jsxs)(Le.Fragment,{children:[(0,ae.jsx)(nr,{image:t,thumbnail:n,crop:l,enableSizes:c}),a]},"service"):(0,ae.jsxs)(Le.Fragment,{children:[(0,ae.jsx)("world-image",{onClick:u,uri:t.id,target:{x:0,y:0,width:t.target.spatial.width,height:t.target.spatial.height},display:t.width&&t.height?{width:t.width,height:t.height}:void 0,crop:l}),a]},"no-service")},e+(t.service?"server":"no-service"))}var q=require("react"),kr=require("@atlas-viewer/atlas");var Se=require("react");var rr=require("@iiif/helpers");function ot(e,t){let{selector:n,source:r}=(0,rr.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[n?n.type==="TemporalSelector"?{type:"TemporalBoxSelector",temporal:n.temporal,spatial:o.spatial}:n:null,r]}var or={makeChoice:()=>{}},it={type:"unknown"},C=e=>({type:"unknown",reason:e,annotations:{pages:[]}}),ir=(e,t)=>({type:"empty",width:e,height:t,annotations:{pages:[]},image:null,images:[]});var ze=require("react");function lo(e,t){let n=e?.iiif?.meta[t];return n?n.annotationPageManager:null}function ar(e,t){return S(n=>{let r=[];if(!e)return r;let o=Object.keys(n.iiif.entities.AnnotationPage);for(let i of o)if(!t||t.indexOf(i)!==-1){let a=lo(n,i);a&&a.views&&a.views[e]&&r.push(i)}return r},[e,t])}function sr({canvas:e,manifest:t,all:n,canvases:r}){let o=[];if(t)for(let i of t.annotations)o.indexOf(i.id)===-1&&o.push(i.id);if(n){if(r&&r.length)for(let i of r)for(let a of i.annotations)o.indexOf(a.id)===-1&&o.push(a.id)}else if(e)for(let i of e.annotations)o.indexOf(i.id)===-1&&o.push(i.id);return o}function mo(e,t){let n=e?.iiif?.meta[t];return n?n.annotationPageManager:null}function ur(e,t={}){let n=y(),r=T(),o=R(),i=je(),a=(0,ze.useMemo)(()=>sr({all:t.all,manifest:r,canvas:o,canvases:i}),[t.all,o,i,r]),s=ar(e,t.all?void 0:a),u=(0,ze.useCallback)(l=>{e&&n.setMetaValue([l,"annotationPageManager","views"],d=>d&&!d[e]?d:{...d||{},[e]:!1})},[e,n]),c=(0,ze.useCallback)((l,d={})=>{if(!e)return;let g=n.getState(),h=[];if(d?.deselectOthers){let m=Object.keys(g.iiif.entities.AnnotationPage);for(let p of m){let P=mo(g,p);P&&P.views&&P.views[e]&&h.push(p)}}for(let m of h)u(m);n.setMetaValue([l,"annotationPageManager","views"],m=>m&&m[e]?m:{...m||{},[e]:!0})},[e,u,n]);return{availablePageIds:a,enabledPageIds:s,setPageEnabled:c,setPageDisabled:u}}function cr(e,t){return S((n,r)=>r.get(e.map(o=>({id:o,type:t}))),[e,t])}var ee=require("react");var at=G(require("react"),1),lr=require("@atlas-viewer/iiif-image-api"),fo=at.default.createContext(new lr.ImageServiceLoader);function st(){return(0,at.useContext)(fo)}function dr(){let e=st(),[t,n]=(0,ee.useState)({}),r=(0,ee.useRef)(!1);return(0,ee.useEffect)(()=>()=>{r.current=!0},[]),[(0,ee.useCallback)((i,{height:a,width:s})=>{if(i){let u=i.id||i["@id"],c=e.loadServiceSync({id:u,width:i.width||s,height:i.height||a,source:i});c?i=c:t[u]||(r.current||n(l=>({...l,[u]:"loading"})),e.loadService({id:u,width:i.width||s,height:i.height||a}).then(()=>{r.current||n(l=>({...l,[u]:"done"}))}))}return i},[e,t]),t]}var se=require("react");function mr(e={}){let t=et(),n=R(e.canvasId?{id:e.canvasId}:void 0);return S((r,o)=>{if(!n)return[];if(t&&e.enableSingleAnnotation)return[t];let i=o.get(n.items),a=[];for(let s of i)a.push(...o.get(s.items));return a},[n])}var fr=require("@iiif/helpers/painting-annotations");function pr(e,t=[]){let n=y(),r=(0,se.useMemo)(()=>(0,fr.createPaintingAnnotationsHelper)(n),[]),o=mr({enableSingleAnnotation:e?.enableSingleAnnotation}),[i,a]=(0,se.useState)(e?.defaultChoices||[]),s=(0,se.useMemo)(()=>r.getPaintables(o,i),[n,o,i,...t]),c={makeChoice:(0,se.useCallback)((l,{deselectOthers:d=!0,deselect:g=!1}={})=>{s.choice&&a(h=>{if(g){let p=h.filter(P=>P!==l);if(p.length===0){let P=s.items[0].resource.id;return P?[P]:[]}return p}if(d)return[l];let m=[...h];if(m.length===0&&s.items.length){let p=s.items[0].resource.id;p&&m.push(p)}return h.indexOf(l)!==-1?h:[...h,l]})},[s.choice])};return[s,c]}var po=["model/gltf-binary"];function gr(e,t){let r=t.items[0].resource;return r.format?po.indexOf(r.format)===-1?C(`3D format: ${r.format} is unsupported`):{type:"3d-model",model:r}:C("Unknown format")}function hr(e,t){if(!e.duration)return C("No duration on canvas");if(t.items.length>1)return C("Only one audio source supported");let n=t.items[0]?.resource;return n?n.format?{type:"media",media:{annotationId:t.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:[]}}:C("Audio does not have format"):C("Unknown audio")}var vr=require("@atlas-viewer/iiif-image-api");var Lt=require("@iiif/helpers/annotation-targets");function yr(e,t,n){let r=[];for(let o of t.items){let i=o.resource&&o.resource.type==="SpecificResource"?o.resource.source:o.resource;if(!i.id)return C("No resource Identifier");let a;if(i.service){let m=(0,vr.getImageServices)(i);m[0]&&(a=n(m[0],e))}let s={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}},[u,c]=ot(e,o.target);if(!(c.id===e.id||decodeURIComponent(c.id||"")===(e.id||"")))continue;let l=o.resource.width&&o.resource.height?{type:"BoxSelector",spatial:{x:0,y:0,width:o.resource.width,height:o.resource.height}}:void 0,d=o.resource.type==="SpecificResource"?(0,Lt.expandTarget)(o.resource):null;if(o.selector){let m=(0,Lt.expandTarget)({type:"SpecificResource",source:o.resource,selector:o.selector});m&&(d=m)}let g=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;a&&!a.id&&(a.id=a["@id"]);let h={id:i.id,type:"Image",annotationId:o.annotationId,width:Number(u||g?i.width:e.width),height:Number(u||g?i.height:e.height),service:a,sizes:a&&a.sizes?a.sizes:i.width&&i.height?[{width:i.width,height:i.height}]:[],target:u&&u.type!=="PointSelector"?u:s,selector:g};r.push(h)}return{type:"images",image:r[0],images:r,choice:t.choice}}function Sr(e,t={},n){let r=e.language||n||"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=>Sr(o,t,r))}return t}function xr(e,t){let n=[];return t.items.forEach(r=>{if(r.resource){let[o]=ot(e,r.target);n.push({annotationId:r.annotationId,text:Sr(r.resource),target:o})}}),{type:"textual-content",items:n}}var go=/^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\/)|(?:(?:watch)?\?vi?=|&vi?=))([^#&?]*).*/;function Cr(e,t){let n=t.items.filter(s=>s.type==="video"),r=!1;if(e.duration||(r=!0),n.length>1)return C("Only one video source supported");let o=n[0]?.resource,i=!!(o.service||[]).find(s=>(s.profile||"").includes("youtube.com"));if(!i&&r)return C("Video does not have duration");if(!o)return C("Unknown video");if((!o.format||o.format==="text/html")&&!i)return C("Video does not have format");let a={annotationId:t.items[0].annotationId,duration:e.duration,url:o.id,type:"Video",items:[],target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:o.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}};if(i){a.type="VideoYouTube";let s=o.id.match(go);if(!s[1])return C("Video is not known youtube video");a.youTubeId=s[1]}return{type:"media",media:a,annotations:{pages:[]}}}function Ar({canvas:e,paintables:t,supports:n,loadImageService:r}){if(!e)return it;if(t.types.length===0)return n.indexOf("empty")!==-1?ir(e.width,e.height):it;if(t.types.length!==1)if(t.types.length===2&&t.types.indexOf("text")!==-1)t.types=t.types.filter(i=>i!=="text");else return n.indexOf("complex-timeline")===-1?C("Complex timeline not supported"):C("ComplexTimelineStrategy not yet supported");let o=t.types[0];return o==="image"?n.indexOf("images")===-1?C("Image not supported"):yr(e,t,r):o==="Model"||o==="model"?n.indexOf("3d-model")===-1?C("3D not supported"):gr(e,t):o==="textualbody"?n.indexOf("textual-content")===-1?C("Textual content not supported"):xr(e,t):o==="sound"||o==="audio"?n.indexOf("media")===-1?C("Media not supported"):hr(e,t):o==="video"?n.indexOf("media")===-1?C("Media not supported"):Cr(e,t):it}function Pr(e){let t=T(),n=R(),r=y(),o=wn(),i=e?.emitter||o,[a,s]=dr(),{enabledPageIds:u}=ur(e?.annotationPageManagerId||t?.id||n?.id,{all:!1}),c=cr(u,"AnnotationPage"),l=e?.strategies||["empty","images","media","textual-content","complex-timeline"],[d,g]=pr(e,[s]);(0,Se.useEffect)(()=>{let m=p=>{g.makeChoice(p.choiceId,{deselectOthers:p.deselectOthers,deselect:p.deselect})};return i.on("make-choice",m),()=>{i.off("make-choice",m)}},[]);let h=(0,Se.useMemo)(()=>Ar({canvas:n,paintables:d,supports:l,loadImageService:a}),[n,d,r,g.makeChoice]);return(0,Se.useEffect)(()=>{let m=d.allChoices,p={canvasId:n?.id,manifestId:t?.id};m&&i.emit("choice-change",{choice:m,partOf:p})},[n?.id,d.allChoices]),(0,Se.useMemo)(()=>h.type==="unknown"?[h,or]:[{...h,annotations:{pages:c}},g],[h,c])}var te=require("react");var Rr=require("react"),br=(e,t=[])=>{let n=y();(0,Rr.useEffect)(()=>{e(n)},[n,...t])};var Ir=require("@iiif/helpers/thumbnail");function ut(e,t,{canvasId:n,manifestId:r}={}){let o=y(),i=st(),a=(0,te.useMemo)(()=>(0,Ir.createThumbnailHelper)(o,{imageServiceLoader:i}),[o,i]),[s,u]=(0,te.useState)(),c=T(r?{id:r}:void 0),l=R(n?{id:n}:void 0),d=l||c,g=(0,te.useRef)(!1);if((0,te.useEffect)(()=>(g.current=!1,()=>{g.current=!0}),[]),!d)throw new Error("Must be called under a manifest or canvas context.");return br(h=>{a.getBestThumbnailAtSize(d,e,t).then(m=>{m.best&&!g.current&&u(m.best)})},[d]),s}var I=require("react");function ho(e){return{isMuted:!1,playRequested:!1,isPlaying:!1,isFinished:!1,volume:100,duration:e}}function vo(e,t){switch(t.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:t.volume,isMuted:t.volume===0};case"TOGGLE_MUTE":return{...e,isMuted:!e.isMuted};case"UNMUTE":return{...e,isMuted:!1}}return e}function yo(e){let t=Math.round(e);return`${Math.floor(t/60)}:${`${t%60}`.padStart(2,"0")}`}function xe(e){let[t,n]=(0,I.useReducer)(vo,ho(e.duration)),r=(0,I.useRef)(null),o=(0,I.useRef)(null),i=(0,I.useRef)(null),a=(0,I.useRef)(!1),s=(0,I.useCallback)(()=>{o.current&&r.current&&(o.current.innerHTML=yo(r.current.currentTime),i.current&&(i.current.style.width=`${r.current.currentTime/e.duration*100}%`),a.current!==r.current.muted&&(a.current=r.current.muted,n(r.current.muted?{type:"MUTE"}:{type:"UNMUTE"})))},[e.duration]),u=(0,I.useCallback)(()=>{r.current&&(n({type:"PLAY_REQUESTED"}),r.current.play().then(()=>{n({type:"PLAY"})}),s())},[s]),c=(0,I.useCallback)(()=>{r.current&&(r.current.duration>0&&r.current.paused?u():l())},[s]),l=(0,I.useCallback)(()=>{r.current&&(r.current.pause(),n({type:"PAUSE"}),s())},[s]),d=(0,I.useCallback)(()=>{r.current&&(r.current.muted=!r.current.muted,n(r.current.muted?{type:"MUTE"}:{type:"UNMUTE"}))},[]),g=(0,I.useCallback)(()=>{r.current&&(r.current.muted=!0,n({type:"MUTE"}))},[]),h=(0,I.useCallback)(()=>{r.current&&(r.current.muted=!1,n({type:"UNMUTE"}))},[]),m=(0,I.useCallback)(x=>{r.current&&(r.current.muted=!1,r.current.volume=x/100,n({type:"SET_VOLUME",volume:x}))},[]),p=(0,I.useCallback)(x=>{r.current&&(r.current.currentTime=Math.max(0,Math.min(x*e.duration,e.duration)),s())},[]),P=(0,I.useCallback)(x=>{r.current&&(r.current.currentTime=Math.max(0,Math.min(x,e.duration)),s())},[]);return(0,I.useEffect)(()=>{let x=setInterval(()=>{s()},350);return()=>clearInterval(x)},[s,e.duration]),(0,I.useEffect)(()=>{let x=()=>{n({type:"FINISHED"})},Y=r.current;return Y?.addEventListener("ended",x),()=>Y?.removeEventListener("ended",x)},[]),[{element:r,currentTime:o,progress:i},t,{play:u,pause:l,playPause:c,mute:g,unmute:h,toggleMute:d,setVolume:m,setDurationPercent:p,setTime:P}]}var Oe=require("react"),ct=require("react/jsx-runtime"),So=(0,Oe.createContext)(null),xo=(0,Oe.createContext)(null),Co=(0,Oe.createContext)(null);function lt({actions:e,state:t,children:n,currentTime:r,progress:o,element:i}){return(0,ct.jsx)(Co.Provider,{value:{currentTime:r,progress:o,element:i},children:(0,ct.jsx)(xo.Provider,{value:e,children:(0,ct.jsx)(So.Provider,{value:t,children:n})})})}var wr=require("react");var Tr=require("@iiif/helpers");function dt(){let e=T(),t=R();return(0,wr.useMemo)(()=>{if(!e||!t||!e.start)return null;let n=(0,Tr.expandTarget)(e.start);return!n||n.source.id!==t.id||!n||!n.selector||n.selector.type!=="TemporalSelector"?null:n.selector.temporal},[e,t])}var ft=require("react/jsx-runtime");function zt({media:e,startTime:t,children:n}){let[{element:r,currentTime:o,progress:i},a,s]=xe({duration:e.duration}),u=t?`${e.url}#t=${t}`:e.url;return(0,ft.jsxs)(lt,{state:a,actions:s,currentTime:o,progress:i,element:r,children:[(0,ft.jsx)("audio",{ref:r,src:u}),n]})}function mt({media:e,mediaControlsDeps:t,children:n}){let r=dt();return B("portal","audio",zt,{media:e,startTime:r?r.startTime:null,children:n},[e,r,...t||[]]),null}var Fe=require("react/jsx-runtime");function Ot({element:e,media:t,startTime:n,playPause:r,poster:o}){let i="div",a=n?`${t.url}#t=${n}`:t.url;return(0,Fe.jsxs)(i,{className:"video-container",part:"video-container",onClick:r,children:[(0,Fe.jsx)("style",{children:`
|
|
1
|
+
"use strict";var Or=Object.create;var qe=Object.defineProperty;var Fr=Object.getOwnPropertyDescriptor;var Hr=Object.getOwnPropertyNames;var Dr=Object.getPrototypeOf,Ur=Object.prototype.hasOwnProperty;var Br=(e,t)=>{for(var n in t)qe(e,n,{get:t[n],enumerable:!0})},Bt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Hr(t))!Ur.call(e,o)&&o!==n&&qe(e,o,{get:()=>t[o],enumerable:!(r=Fr(t,o))||r.enumerable});return e};var G=(e,t,n)=>(n=e!=null?Or(Dr(e)):{},Bt(t||!e||!e.__esModule?qe(n,"default",{value:e,enumerable:!0}):n,e)),qr=e=>Bt(qe({},"__esModule",{value:!0}),e);var Io={};Br(Io,{CanvasPanel:()=>M});module.exports=qr(Io);var De=require("react");var E=G(require("react"),1),Je=require("@atlas-viewer/atlas"),qn=require("react-error-boundary");var J=require("react");var ue=G(require("react"),1),qt=require("react/jsx-runtime"),$r={collection:void 0,manifest:void 0,range:void 0,canvas:void 0,annotation:void 0,annotationPage:void 0},$e=ue.default.createContext($r),F=()=>(0,ue.useContext)($e);function Z({value:e,children:t}){let n=F(),r=(0,ue.useMemo)(()=>({...n,...e}),[e,n]);return(0,qt.jsx)($e.Provider,{value:r,children:t})}var _e=G(require("react"),1),Re=require("@iiif/helpers/vault");var Ct=require("react/jsx-runtime"),re=_e.default.createContext({vault:null,setVaultInstance:e=>{}});function ce({vault:e,vaultOptions:t,useGlobal:n,resources:r,children:o}){let[i,a]=(0,_e.useState)(()=>e||(n?(0,Re.globalVault)(t):t?new Re.Vault(t):new Re.Vault));return(0,Ct.jsx)(re.Provider,{value:{vault:i,setVaultInstance:a},children:(0,Ct.jsx)(Z,{value:r||{},children:o})})}var An=require("react"),Ge=require("react");var $t=require("@iiif/helpers/vault"),_t=require("react");function le(e){let t=(0,_t.useContext)(re);return e||(t&&t.vault?t.vault:(0,$t.globalVault)())}var K=require("react");function Wt(e,{noCache:t=!1}={}){let n=typeof e=="string"?e:e.id,r=le(),[o,i]=(0,K.useState)(n),[a,s]=(0,K.useState)(void 0),u=(0,K.useMemo)(()=>r.get(n,{skipSelfReturn:!0})||void 0,[n,r]),[c,l]=(0,K.useState)(u);return(0,K.useEffect)(()=>{(async()=>{try{let d=u&&!t?u:await r.load(n),g=d?d.id||d["@id"]:null;d&&o!==g&&i(g),l(d)}catch(d){s(d)}})()},[n,t]),{isLoaded:!!c,id:o,requestId:n,error:a,resource:c,cached:!!(c&&c===u)}}function jt(e,t){let{id:n,isLoaded:r,error:o,resource:i,requestId:a,cached:s}=Wt(e,t);return{id:n,isLoaded:r,error:o,manifest:i,requestId:a,cached:s}}var Qt=require("react/jsx-runtime");function Yt({manifest:e,children:t}){return(0,Qt.jsx)(Z,{value:{manifest:e},children:t})}var Gt=require("react/jsx-runtime");function W({canvas:e,children:t}){return(0,Gt.jsx)(Z,{value:{canvas:e},children:t})}var Kt=require("react"),Jt=G(require("react"),1);var Zt=require("react"),y=()=>{let{vault:e}=(0,Zt.useContext)(re);if(e===null)throw new Error("Vault not found. Ensure you have your provider set up correctly.");return e};var We=require("react");function S(e,t=[]){let n=y(),[r,o]=(0,We.useState)(()=>e(n.getState(),n));return(0,We.useEffect)(()=>n.subscribe(i=>e(i,n),i=>{o(i)},!1),t),r}var de=Jt.default.createContext([]);function je(){let e=(0,Kt.useContext)(de);return S(t=>e.map(n=>t.iiif.entities.Canvas[n]).filter(Boolean),[e])}var Xt=require("react");function w(e={},t=[]){let{id:n,selector:r}=e,o=F(),i=y(),a=n||o.manifest,s=S(u=>a?u.iiif.entities.Manifest[a]:void 0,[a]);return(0,Xt.useMemo)(()=>{if(s)return r?r(s):s},[s,r,...t])}var tn=require("react/jsx-runtime");function en({range:e,children:t}){return(0,tn.jsx)(Z,{value:{range:e},children:t})}function At(e,t){let n=[];for(let r of t.items)if(r.type==="SpecificResource"&&r.source?.type==="Canvas"&&(r.source.id.indexOf("#")!==-1?n.push({id:r.source.id.split("#")[0],type:"Canvas"}):n.push(r.source)),r.type==="Range"&&n.push(...At(e,e.get(r))),r.type==="SpecificResource"){let o=typeof r.source=="string"?r.source:r.source.id;n.push({id:o,type:"Canvas"})}return n}function nn(e,t,{disablePaging:n,skipNonPaged:r}={}){let o=t.behavior,i=o.includes("paged"),a=i?!1:o.includes("continuous"),s=i||a?!1:o.includes("individuals"),u=t.type==="Manifest"?t.items:At(e,t);if(a)return[u,[u.map((m,p)=>p)]];if(s||!i||n)return[u,u.map((m,p)=>[p])];let c=[],l=[],d=()=>{l.length&&(c.push([...l]),l=[])},g=0,h=!1;for(let m=0;m<u.length;m++){let p=e.get(u[m]);if(p.behavior.includes("non-paged")){m===g&&g++,r||(d(),c.push([m]),d());continue}if(m===g||p.behavior.includes("facing-pages")){l.length&&(h=!0),d(),c.push([m]),d();continue}if(l.push(m),h){d(),h=!1;continue}l.length>1&&d()}return l.length&&d(),[u,c]}var H=require("react");var rn=require("react");function on(e={},t=[]){let{id:n,selector:r}=e,o=F(),i=n||o.range,a=S(s=>i?s.iiif.entities.Range[i]:void 0,[i]);return(0,rn.useMemo)(()=>{if(a)return r?r(a):a},[a,r,...t])}function an({startCanvas:e,disablePaging:t}){let n=y(),r=w(),o=on(),[i,a]=(0,H.useState)(void 0),s=o||r;if(!s)throw new Error("Nothing selected");let[u,c]=(0,H.useMemo)(()=>nn(n,s,{disablePaging:t}),[n,s,t]),l=(0,H.useRef)(c);if(l.current!==c){let P=l.current[i][0],x=c.findIndex(Y=>Y.includes(P));l.current=c,a(x)}let d=(0,H.useCallback)(p=>{let P=c.findIndex(x=>x.includes(p));a(P===-1?0:P)},[u,c]),g=(0,H.useCallback)(p=>{let P=u.findIndex(x=>x.id===p);P!==-1?d(P):a(0)},[u,c]),h=(0,H.useCallback)(()=>{a(p=>p>=c.length-1?p:p+1)},[c]),m=(0,H.useCallback)(()=>{a(p=>p<=0?0:p-1)},[c]);return typeof i>"u"&&(e?g(e):a(0)),{visibleItems:c[i]?.map(p=>u[p].id)||[],cursor:i,items:u,sequence:c,hasPrevious:i>0,hasNext:i<c.length-1,setSequenceIndex:a,setCanvasIndex:d,setCanvasId:g,next:h,previous:m}}var U=require("react"),Ye=require("zustand");var Rt=require("zustand/vanilla");function D(e,t,n){let r=t.findIndex(a=>a.service.id===e);if(r===-1)return t;let o=[...t],i=n(o[r]);return i===o[r]?t:(o[r]=i,o)}var un=()=>(0,Rt.createStore)((e,t)=>({currentAuth:-1,authItems:[],login:()=>{let n=t().authItems[t().currentAuth];if(!n||n.isPending||n.isLoggedIn)return;if(n.type!=="active")throw new Error("Cannot login to non-active service");let r=n.service.service.find(o=>o.type==="AuthAccessTokenService2");if(!r)throw new Error("Token service not found");e(()=>({authItems:D(n.id,t().authItems,o=>({...o,isPending:!0}))})),sn(n.service).then(()=>{Pt(r).then(o=>{let i=o.expiresIn,a=Date.now()+i*1e3;e(()=>({authItems:D(n.id,t().authItems,s=>({...s,isLoggedIn:!0,isPending:!1,session:{token:o.accessToken,expires:a}}))}))}).catch(o=>{e(()=>({authItems:D(n.id,t().authItems,i=>({...i,isLoggedIn:!1,isPending:!1,error:o.message}))}))})})},logout:()=>{let n=t().authItems[t().currentAuth];if(!n||n.isPending||!n.isLoggedIn)return;if(n.type!=="active")throw new Error("Cannot logout of non-active service");let r=n.service.service.find(a=>a.type==="AuthLogoutService2");if(!r)return;let o=`${r.id}?origin=${dn()}`,i=window.open(o);e(()=>({authItems:D(n.id,t().authItems,a=>({...a,isLoggedIn:!1,session:null,isPending:!1}))}))},nextAuth:()=>{let n=t().authItems.length,r=t().currentAuth+1;r>=n||e(()=>({currentAuth:r}))},previousAuth:()=>{let n=t().currentAuth-1;n<0||e(()=>({currentAuth:n}))},setAuth:n=>{n!==-1&&(n<0||n>=t().authItems.length)||e(()=>({currentAuth:n}))},addService:(n,r)=>{if(!n.service)return;let o=n.service.find(s=>s.type==="AuthAccessTokenService2"),i=n;if(t().authItems.find(s=>s.service.id===n.id)){e(()=>({authItems:D(n.id,t().authItems,s=>({...s,instances:s.instances+1}))}));return}if(e(()=>({currentAuth:i.profile==="active"?0:t().currentAuth,authItems:[{id:n.id,type:n.profile,service:n,probeId:r,canAuthenticate:!0,instances:1,isPending:!1,isLoggedIn:!1,session:null},...t().authItems]})),n.profile==="external"){if(!o)throw new Error("Token service not found");Pt(o).then(s=>{e(()=>({authItems:D(n.id,t().authItems,u=>({...u,isLoggedIn:!0,isPending:!1,session:{token:s.accessToken,expires:s.expiresIn}}))}))}).catch(s=>{e(()=>({authItems:D(n.id,t().authItems,u=>({...u,isLoggedIn:!1,isPending:!1,canAuthenticate:!1,error:s.message}))}))})}if(n.profile==="kiosk"){if(!o)throw new Error("Token service not found");e(()=>({authItems:D(n.id,t().authItems,s=>({...s,isPending:!0}))})),sn(i).then(()=>{Pt(o).then(s=>{e(()=>({authItems:D(n.id,t().authItems,u=>({...u,isLoggedIn:!0,isPending:!1,session:{token:s.accessToken,expires:s.expiresIn}}))}))}).catch(s=>{e(()=>({authItems:D(n.id,t().authItems,u=>({...u,isLoggedIn:!1,isPending:!1,error:s.message}))}))})})}n.profile},removeService:(n,r)=>{let o=t().currentAuth===t().authItems.findIndex(a=>a.service.id===n.id),i=t().currentAuth;if(o){let a=t().authItems.find(u=>u.service.id===n.id);a&&a.instances>1||(i=t().authItems.findIndex(c=>c.service.id!==n.id&&c.instances>0))}e(()=>({authItems:D(n.id,t().authItems,a=>({...a,instances:a.instances-1})),currentAuth:i}))}})),cn=(e,t)=>(0,Rt.createStore)((n,r)=>({service:e,status:e?"unknown":"success",shouldRedirect:!1,redirectResource:null,shouldSubstitute:!1,substituteResource:null,error:null,errorHeading:null,errorNote:null,shouldDisplayResource:!1,token:t||null,async probe(){if(!r().service)return;let o=r().service?.id;if(!o){n({status:"error",error:"Service ID not found",errorHeading:{en:["Service ID not found"]}});return}n({status:"probing"});let i=r().token;try{let a=await fetch(o,{headers:i?{Authorization:`Bearer ${r().token}`,Accept:"application/json"}:{Accept:"application/json"}}).then(s=>s.json());if(a.status===200)n({status:"success",shouldDisplayResource:!0,error:null,errorHeading:null,errorNote:null,shouldSubstitute:!1,shouldRedirect:!1});else if(a.status<400&&a.status>=300){if(!a.location)throw new Error("Redirect location not found");n({status:"error",shouldDisplayResource:!1,shouldRedirect:!0,redirectResource:a.location||null})}else if(a.status===401)n({status:"error",shouldDisplayResource:!1,shouldRedirect:!1,shouldSubstitute:!!a.substitute,substituteResource:a.substitute||null,error:"Unauthorized",errorHeading:a.heading||{en:["Unauthorized"]},errorNote:a.note||null});else throw new Error("Unknown error")}catch(a){n({status:"error",error:a.message,errorHeading:{en:["Unknown error"]}})}},setToken(o){n({token:o})}}));function ln(e){let t=e.service||e.services||[],n={hasAuth:!1,services:{}};for(let r of t)if(r.type==="AuthProbeService2"){n.services.probe=r,n.hasAuth=!0;let o=r.service.filter(i=>i.type==="AuthAccessService2");o[0]&&(n.services.access=o[0])}return n}async function Pt(e,{strict:t=!0}={}){return new Promise((n,r)=>{let o=Math.random().toString(36).substring(7),i=`${e.id}?messageId=${o}&origin=${window.location.origin}`,a=c=>{let l=c.data;if(l.messageId===o){if(t&&l.type!=="AuthAccessToken2"){s(),r("Invalid response, expected type=AuthAccessToken2");return}if(!l.accessToken){s(),r("Invalid response, expected accessToken");return}s(),n(l)}},s=()=>window.removeEventListener("message",a),u=document.createElement("iframe");u.src=i,u.style.display="none",document.body.appendChild(u),window.addEventListener("message",a)})}function dn(e){let t=window.location;if(e){let n=document.createElement("a");return n.href=e,n.protocol+"//"+n.hostname+(n.port?":"+n.port:"")}return t.protocol+"//"+t.hostname+(t.port?":"+t.port:"")}async function sn(e){let t=`${e.id}?origin=${dn()}`,n=window.open(t);if(!n)throw new Error("Failed to open window");return new Promise((r,o)=>{let i=setInterval(()=>{n.closed&&(clearInterval(i),r())},500)})}var me=require("react");var mn=require("zustand");function fn(e){let t=(0,me.useMemo)(()=>ln(e),[e]),n=pn(t.services.access?.id),r=(0,me.useMemo)(()=>cn(t.services.probe,n),[t.services.probe]),o=(0,mn.useStore)(r);return(0,me.useEffect)(()=>{o.status==="unknown"&&!n&&o.probe()},[t.services.probe,o.status]),(0,me.useEffect)(()=>{n&&(o.setToken(n),o.probe())},[n]),[e,o,t.hasAuth]}var be=require("react/jsx-runtime"),fe=(0,U.createContext)(null),_r=(0,U.createContext)(null);_r.displayName="CurrentAuth";var Wr=(0,U.createContext)(null);Wr.displayName="AuthActions";function gn({children:e}){let t=(0,U.useMemo)(()=>un(),[]);return(0,be.jsx)(fe.Provider,{value:t,children:e})}function hn(){return!!(0,U.useContext)(fe)}function It(){let e=(0,U.useContext)(fe);if(!e)throw new Error("useAuthActions must be used within a AuthProvider");return e}function jr(){let e=It();return(0,Ye.useStore)(e,n=>({login:n.login,logout:n.logout,nextAuth:n.nextAuth,previousAuth:n.previousAuth,setAuth:n.setAuth,addService:n.addService,removeService:n.removeService}))}function Yr(e){let t=It();return(0,Ye.useStore)(t,r=>r.authItems.find(o=>o.service.id===e))}function pn(e){let t=It();return(0,Ye.useStore)(t,r=>r.authItems.find(o=>o.id===e)?.session?.token)}function Qr(e){let t=jr(),n=Yr(e.service.id);return(0,U.useEffect)(()=>(t?.addService(e.service,e.probeId),()=>{t?.removeService(e.service,e.probeId)}),[e.service]),n?(n.error||!n.isLoggedIn,e.children):null}function bt(){return null}function vn(e){let[t,n,r]=fn(e.resource),o=e.fallbackComponent||bt,i=e.loadingComponent||bt,a=e.errorComponent||bt,s=n.service,u=null;if(!r||!s)return e.children(t);let c=s.service.filter(l=>l.type==="AuthAccessService2");n.status==="error"&&(u=(0,be.jsx)(a,{resource:e.resource,error:n.error||"",heading:n.errorHeading,note:n.errorNote,extra:e.extra})),(n.status==="unknown"||n.status==="probing")&&(u=(0,be.jsx)(i,{})),n.status==="success"&&(u=e.children(t));for(let l of c)u=(0,be.jsx)(Qr,{service:l,probeId:s.id,children:u},l.id);return u}var Ie=require("react");var yn=require("zustand/vanilla"),Gr=e=>e.id||e["@id"];function Zr(e){return(Array.isArray(e.service)?e.service:[e.service]).find(n=>n.profile==="http://iiif.io/api/search/0/autocomplete"||n.profile==="http://iiif.io/api/search/1/autocomplete"||n.profile==="AutoCompleteService1")}var Sn=e=>{let t;typeof e=="string"?t={"@context":"http://iiif.io/api/search/1/context.json",profile:"http://iiif.io/api/search/1/search","@id":e,id:e,service:[]}:t=e;let n=t?Gr(t):void 0,r=null;return(0,yn.createStore)((o,i)=>({service:t,resources:[],lastQuery:{},loading:!1,error:!1,highlight:null,hasSearch:!!t,hasAutocomplete:t?!!Zr(t):!1,errorMessage:"",search(a,s={}){if(!n)throw new Error("No search service found.");r&&!r.signal.aborted&&r.abort(),r=new AbortController;let u=new URLSearchParams;a.q&&u.set("q",a.q),a.motivation&&u.set("motivation",a.motivation),a.date&&u.set("date",a.date),a.user&&u.set("user",a.user),o({loading:!0}),fetch(`${n}?${u.toString()}`,{signal:r.signal,headers:{"Content-Type":"application/json",Accept:"application/json",...s.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(a){let s=i().resources.find(u=>u["@id"]===a);o({highlight:s})},nextResult(){let a=i().resources,s=i().highlight;if(!s){o({highlight:a[0]||null});return}let u=a.findIndex(c=>c["@id"]===s["@id"]);if(u===-1){o({highlight:a[0]||null});return}o({highlight:a[u+1]||a[0]||null})},previousResult(){let a=i().resources,s=i().highlight;if(!s){o({highlight:a[a.length-1]||null});return}let u=a.findIndex(c=>c["@id"]===s["@id"]);if(u===-1){o({highlight:a[a.length-1]||null});return}if(u===0){o({highlight:a[a.length-1]||null});return}o({highlight:a[u-1]||a[a.length-1]||null})}}))};var Kr=require("zustand");function xn(){let e=w();return e?e.service.find(t=>t.profile==="SearchService1"||t.profile==="http://iiif.io/api/search/1/search"):void 0}var Qe=require("react/jsx-runtime"),pe=(0,Ie.createContext)(null);pe.displayName="Search";function Cn(e){let t=xn();return e.store?(0,Qe.jsx)(pe.Provider,{value:e.store,children:e.children}):(0,Qe.jsx)(Jr,{service:t,children:e.children})}function Jr({service:e,children:t}){let n=(0,Ie.useMemo)(()=>Sn(e),[e]);return(0,Qe.jsx)(pe.Provider,{value:n,children:t})}var k=require("react/jsx-runtime"),Te=()=>{},we=(0,Ge.createContext)({setCurrentCanvasId:Te,setCurrentCanvasIndex:Te,nextCanvas:Te,previousCanvas:Te,items:[],sequence:[],setSequenceIndex:Te,currentSequenceIndex:0,hasNext:!1,hasPrevious:!1});function Xr(e){let t=w(),{cursor:n,visibleItems:r,next:o,sequence:i,items:a,setCanvasIndex:s,setCanvasId:u,previous:c,setSequenceIndex:l,hasNext:d,hasPrevious:g}=an({startCanvas:e.startCanvas,disablePaging:e.pagingEnabled===!1}),h=(0,Ge.useMemo)(()=>({sequence:i,items:a,setCurrentCanvasId:u,nextCanvas:o,previousCanvas:c,totalCanvases:a.length,setCurrentCanvasIndex:s,setSequenceIndex:l,currentSequenceIndex:n,hasNext:d,hasPrevious:g}),[i,a,u,o,c,a,s,l,n]);return t?r.length===0?null:(0,k.jsx)(we.Provider,{value:h,children:(0,k.jsx)(de.Provider,{value:r,children:(0,k.jsx)(W,{canvas:r[0],children:e.children})})}):(console.warn("The manifest passed to the provider is not a valid IIIF manifest."),(0,k.jsx)("div",{children:"Sorry, something went wrong."}))}function Pn(e){let t=le(e.vault),n=jt(e.manifest);if(!n)return console.warn("The manifest passed to the provider is not a valid IIIF manifest."),(0,k.jsx)("div",{children:"Sorry, something went wrong."});if(n.error)return(0,k.jsx)("div",{children:n.error.toString()});if(!n.isLoaded)return(0,k.jsx)("div",{children:"Loading..."});let r=(0,k.jsx)(Xr,{...e,children:e.children});return(0,k.jsx)(ce,{vault:t,children:(0,k.jsx)(Yt,{manifest:n.id,children:(0,k.jsx)(gn,{children:(0,k.jsx)(Cn,{children:e.rangeId?(0,k.jsx)(en,{range:e.rangeId,children:r}):r})})})})}function Rn(){return(0,An.useContext)(we)}var bn=G(require("react"),1),Tt=require("react"),In=G(require("mitt"),1),to=require("react/jsx-runtime"),eo=(0,In.default)(),Me=(0,Tt.createContext)({emitter:eo});Me.displayName="Events";function Tn(){return bn.default.useContext(Me).emitter}var oe=require("react/jsx-runtime");function wn(){return{VaultContext:(0,J.useContext)(re),ResourceContext:(0,J.useContext)($e),SimpleViewerReactContext:(0,J.useContext)(we),VisibleCanvasReactContext:(0,J.useContext)(de),AuthRContext:(0,J.useContext)(fe),SearchReactContext:(0,J.useContext)(pe),ReactEventContext:(0,J.useContext)(Me)}}function Mn(e){return(0,oe.jsx)(ce,{vault:e.bridge.VaultContext.vault||void 0,resources:e.bridge.ResourceContext,children:(0,oe.jsx)(de.Provider,{value:e.bridge.VisibleCanvasReactContext,children:(0,oe.jsx)(we.Provider,{value:e.bridge.SimpleViewerReactContext,children:(0,oe.jsx)(Me.Provider,{value:e.bridge.ReactEventContext,children:(0,oe.jsx)(fe.Provider,{value:e.bridge.AuthRContext,children:(0,oe.jsx)(pe.Provider,{value:e.bridge.SearchReactContext,children:e.children})})})})})})}var ge=require("react");var j=require("react");var Ze=require("@iiif/helpers/vault/actions");var Vn=require("react");function Nn(){let t=y().getStore();return(0,Vn.useMemo)(()=>n=>t.dispatch(n),[t])}function En(e){return typeof e!="string"&&e&&e.bindToVault}function kn(){let e=y(),t=(0,j.useRef)([]),n=Nn(),r=(0,j.useMemo)(()=>`vault://annotation-page/${new Date().getTime()}/${Math.round(Math.random()*1e9).toString(16)}`,[]);(0,j.useLayoutEffect)(()=>{let s={id:r,type:"AnnotationPage",behavior:[],label:null,thumbnail:[],summary:null,requiredStatement:null,metadata:[],rights:null,provider:[],items:[],seeAlso:[],homepage:[],rendering:[],service:[]};n(Ze.entityActions.importEntities({entities:{AnnotationPage:{[s.id]:s}}}))},[r]);let o=S(s=>r&&s.iiif.entities.AnnotationPage[r]||null,[r]),i=(0,j.useCallback)((s,u)=>{if(r){if(En(s)){let d=s;d.__vault||d.bindToVault(e),s=typeof d.source=="string"?d.source:d.source.id,t.current[s]=d}else typeof s!="string"&&(s=s.id);let c=e.get({id:r,type:"AnnotationPage"}),l=e.get({id:s,type:"Annotation"});c&&l&&(c.items.find(d=>d.id===l.id)||n(Ze.entityActions.addReference({id:r,type:"AnnotationPage",key:"items",reference:{id:s,type:"Annotation"},index:u})))}},[r]),a=(0,j.useCallback)(s=>{r&&(En(s)?s=typeof s.source=="string"?s.source:s.source.id:typeof s!="string"&&(s=s.id),t.current[s]&&t.current[s].beforeRemove(),e.get({id:r,type:"AnnotationPage"})&&n(Ze.entityActions.removeReference({id:r,type:"AnnotationPage",key:"items",reference:{id:s,type:"Annotation"}})))},[r]);return[o,{addAnnotation:i,removeAnnotation:a}]}var Fn=require("react/jsx-runtime"),Ln=(0,ge.createContext)(null);function zn(){let e=(0,ge.useContext)(Ln);return[e.fullPage,{addAnnotation:e.addAnnotation,removeAnnotation:e.removeAnnotation}]}function On({children:e}){let[t,{addAnnotation:n,removeAnnotation:r}]=kn();return(0,Fn.jsx)(Ln.Provider,{value:(0,ge.useMemo)(()=>({fullPage:t,addAnnotation:n,removeAnnotation:r}),[t]),children:e})}var he=require("react/jsx-runtime");function Hn({width:e,style:t,height:n,error:r,resetErrorBoundary:o}){return(0,he.jsxs)("div",{style:{width:e,height:n,minHeight:500,...t||{},background:"#f9f9f9"},children:[(0,he.jsx)("h3",{children:"Error occurred"}),(0,he.jsx)("p",{children:r.message}),(0,he.jsx)("button",{onClick:o,children:"Reset"})]})}var Ke=require("react"),Ve=(0,Ke.createContext)(null);function Dn(){return(0,Ke.useContext)(Ve)}var ie=require("react"),wt=(0,ie.createContext)(()=>{}),Mt=(0,ie.createContext)(()=>{});function B(e,t,n,r,o=[]){let i=(0,ie.useContext)(e==="portal"?Mt:wt);(0,ie.useEffect)(()=>(e!=="none"&&i(t,n,r),()=>{i(t,null)}),[t,e,i,...o])}var ve=require("react");var Un=require("react");function R(e={},t=[]){let{id:n,selector:r}=e,o=F(),i=n||o.canvas,a=S(s=>i?s.iiif.entities.Canvas[i]:void 0,[i]);return(0,Un.useMemo)(()=>{if(a)return r?r(a):a},[a,r,...t])}var Vt=(0,ve.createContext)(()=>{});function Bn(e){let t=R(),n=(0,ve.useContext)(Vt);(0,ve.useEffect)(()=>t&&t.id?(n(t.id,e),()=>n(t.id,-1)):()=>{},[t,e])}var T=require("react/jsx-runtime");function $n({children:e,errorFallback:t,outerContainerProps:n={},worldScale:r,...o}){let[i,a]=(0,E.useState)(),s=wn(),u=t||Hn,[c,l]=(0,E.useState)({}),d=Object.entries(c),[g,h]=(0,E.useState)({}),m=Object.entries(g),[p,P]=(0,E.useState)({}),x=(0,E.useMemo)(()=>r||Math.max(...Object.values(p)),[p]),Y=(0,E.useMemo)(()=>({maxOverZoom:x||1,...o.runtimeOptions||{}}),[x,o.runtimeOptions]),V=(0,E.useCallback)((b,N)=>{P(z=>{if(N===-1){let{[b]:f,..._}=z;return _}return{...z,[b]:N}})},[]),yt=(0,E.useCallback)((b,N,z)=>{l(({[b]:f,..._})=>N?{..._,[b]:{element:N,props:z}}:_)},[]),Ue=(0,E.useCallback)((b,N,z)=>{h(({[b]:f,..._})=>N?{..._,[b]:{element:N,props:z}}:_)},[]);return(0,T.jsxs)(qn.ErrorBoundary,{resetKeys:[],fallbackRender:b=>(0,T.jsx)(u,{...o,...b}),children:[(0,T.jsx)(Je.AtlasAuto,{...o,containerProps:{style:{position:"relative"},...o.containerProps||{}},htmlChildren:(0,T.jsx)(T.Fragment,{children:d.map(([b,{element:N,props:z}])=>(0,T.jsx)(E.default.Fragment,{children:(0,T.jsx)(N,{...z||{}})},b))}),onCreated:b=>{a(b),o.onCreated&&o.onCreated(b)},runtimeOptions:Y,children:(0,T.jsx)(Ve.Provider,{value:i,children:(0,T.jsx)(Vt.Provider,{value:V,children:(0,T.jsx)(wt.Provider,{value:yt,children:(0,T.jsx)(Mt.Provider,{value:Ue,children:(0,T.jsx)(Mn,{bridge:s,children:(0,T.jsx)(Je.ModeContext.Provider,{value:o.mode||"explore",children:(0,T.jsx)(On,{children:e})})})})})})})}),(0,T.jsx)("div",{children:m.map(([b,{element:N,props:z}])=>(0,T.jsx)(E.default.Fragment,{children:(0,T.jsx)(N,{...z||{}})},b))})]})}var tt=require("@atlas-viewer/atlas");var Nt=require("react"),_n=require("@iiif/helpers/events");function Xe(e,t){let n=y(),r=(0,Nt.useMemo)(()=>(0,_n.createEventsHelper)(n),[n]),o=S(()=>e&&e.id?n.getResourceMeta(e.id,"eventManager"):null,[e]);return(0,Nt.useMemo)(()=>e?r.getListenersAsProps(e,t):{},[o,e,n,t])}var Wn=require("react"),jn=require("@iiif/helpers/styles");function ye(e,t){let n=y(),r=(0,Wn.useMemo)(()=>(0,jn.createStylesHelper)(n),[n]);return S(()=>{if(!e)return null;let o=r.getAppliedStyles(e.id);return o?t?o[t]:o:void 0},[e,t])}var Gn=require("react");var Yn=require("react");var Qn=require("@iiif/helpers/annotation-targets");function et(e={},t=[]){let{id:n,selector:r}=e,o=F(),i=y(),a=n||o.annotation,s=S(c=>a?c.iiif.entities.Annotation[a]:void 0,[a]),u=S(c=>s&&s.body?s.body.map(l=>l?l.type==="SpecificResource"?{...l,source:i.get(l)}:l?c.iiif.entities[l.type][l.id]:null:null).filter(Boolean):[],[s]);return(0,Yn.useMemo)(()=>{if(!s)return;let c={...s,body:u,target:(0,Qn.expandTarget)(s.target,{typeMap:i.getState().iiif.mapping})};return r?r(c):c},[s,r,u,...t])}var Zn=require("react/jsx-runtime"),nt=({id:e,style:t,className:n,interactive:r})=>{let o=et({id:e}),i=ye(o,"atlas"),a=ye(o,"html"),s=Xe(o,["atlas"]),u=R(),c=(0,Gn.useMemo)(()=>(0,tt.mergeStyles)(t,i),[t,i]);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)?(0,Zn.jsx)(tt.RegionHighlight,{id:o.id,isEditing:!0,region:o.target.selector.spatial,style:c,className:a?.className||n,interactive:!!(a?.href||r),href:a?.href||null,title:a?.title||null,hrefTarget:a?.target||null,onClick:()=>{},...s}):null};var Xn=require("react");var Kn=require("react");function Jn(e={},t=[]){let{id:n,selector:r}=e,o=F(),i=n||o.annotationPage,a=S(s=>i?s.iiif.entities.AnnotationPage[i]:void 0,[i]);return(0,Kn.useMemo)(()=>{if(a)return r?r(a):a},[a,...t])}var Et=require("react/jsx-runtime"),Ne=({className:e,page:t})=>{let n=Jn({id:t.id})||t,r=ye(n,"atlas"),o=ye(n,"html");return S(i=>n.id?i.iiif.entities.AnnotationPage[n.id]:null,[]),(0,Et.jsx)(Xn.Fragment,{children:n.items?.map(i=>(0,Et.jsx)(nt,{id:i.id,style:r,className:o?.className||e},i.id))})};var Er=require("@iiif/helpers/styles");var Le=require("react");var ke=require("@atlas-viewer/atlas");var q=G(require("react"),1),X=require("react/jsx-runtime"),no=q.default.createContext("en"),ro=q.default.createContext({}),oo=q.default.createContext(null);function io(){return q.default.useContext(oo)}function tr(){return q.default.useContext(no)}function ao(){return q.default.useContext(ro)}function er(e){return e.indexOf("-")!==-1?e.slice(0,e.indexOf("-")):e}function so({as:e,language:t,children:n,viewingDirection:r,...o}){let i=tr();return(0,q.useMemo)(()=>er(i)===er(t),[i,t])?e?(0,X.jsx)(e,{...o,children:n}):(0,X.jsx)("span",{...o,children:n}):e?(0,X.jsx)(e,{...o,lang:t,dir:r,children:n}):(0,X.jsx)("span",{...o,lang:t,dir:r,children:n})}function uo(e,t,n){if(t.length===0)return;if(t.length===1)return t[0];if(t.indexOf(e)!==-1)return e;let r=e.indexOf("-")!==-1?e.slice(0,e.indexOf("-")):null;if(r&&t.indexOf(r)!==-1)return r;for(let o of n)if(t.indexOf(o)!==-1)return o;return t.indexOf("none")!==-1?"none":t.indexOf("@none")!==-1?"@none":t[0]}var co=(e,t=[])=>{let n=tr();return(0,q.useMemo)(()=>{let r=e();return uo(n,r,[])},[n,...t])};function kt(e,t,n,r){return t?n?n(e[t]||t,r||"none"):e[t]||t:""}function lo(e,t,n=`
|
|
2
|
+
`,r={}){let o=io(),i=co(()=>Object.keys(e||{}),[e]);return[(0,q.useMemo)(()=>{if(!e)return kt(r,t,o)||"";if(typeof e=="string")return kt(r,e,o);let a=i?e[i]:void 0;return a?typeof a=="string"?a:a.map(s=>kt(r,s,o,i)).join(n):""},[i,t,e]),i]}function Ee({as:e,defaultText:t,enableDangerouslySetInnerHTML:n,children:r,separator:o,...i}){let a=ao(),[s,u]=lo(r,t,o,a);return u?(0,X.jsx)(so,{...i,as:e,language:u,title:n?void 0:s,dangerouslySetInnerHTML:n?{__html:s}:void 0,children:n?void 0:s}):e?(0,X.jsx)(e,{...i,children:s}):(0,X.jsx)("span",{...i,title:n?void 0:s,dangerouslySetInnerHTML:n?{__html:s}:void 0,children:n?void 0:s})}var O=require("react/jsx-runtime");function mo({resource:e,heading:t,note:n,extra:r}){return r?(0,O.jsx)(ke.HTMLPortal,{target:{x:0,y:0,width:r.target?.spatial.width,height:r.target?.spatial.height},backgroundColor:"#333",relative:!0,children:(0,O.jsx)("div",{style:{display:"flex",alignContent:"center",justifyContent:"center",alignItems:"center",height:"100%",width:"100%",background:"#444",color:"#BBB"},children:(0,O.jsxs)("div",{children:[(0,O.jsx)(Ee,{children:t||"Not authorised"}),n&&(0,O.jsx)("p",{children:(0,O.jsx)(Ee,{children:n})}),(0,O.jsx)("p",{children:e.id||e["@id"]||"unknown"})]})})}):null}function nr({image:e,thumbnail:t,crop:n,enableSizes:r}){if(!hn()){let i=e.service,a=i.width||e.width||0,s=i.height||e.height||0;return(0,O.jsx)(ke.TileSet,{tiles:{id:i.id||i["@id"]||"unknown",height:s,width:a,imageService:i},enableSizes:r,x:0,y:0,width:e.target?.spatial.width,height:e.target?.spatial.height,crop:n})}return(0,O.jsx)(vn,{resource:e.service,errorComponent:mo,extra:e,children:i=>{let a=i.width||e.width||0,s=i.height||e.height||0;return(0,O.jsx)(ke.TileSet,{tiles:{id:i.id||i["@id"]||"unknown",height:s,width:a,imageService:i},enableSizes:r,x:0,y:0,width:e.target?.spatial.width,height:e.target?.spatial.height,crop:n})}},e.id)}var ae=require("react/jsx-runtime");function rt({id:e,image:t,thumbnail:n,isStatic:r,x:o=0,y:i=0,children:a,selector:s,onClick:u,enableSizes:c}){let l=(0,Le.useMemo)(()=>{if(!(!s||s.spatial.x===0&&s.spatial.y===0))return s.spatial},[s]);return(0,ae.jsx)("world-object",{x:o+t.target.spatial.x,y:i+t.target.spatial.y,width:t.target.spatial.width,height:t.target.spatial.height,onClick:u,children:t.service?(0,ae.jsxs)(Le.Fragment,{children:[(0,ae.jsx)(nr,{image:t,thumbnail:n,crop:l,enableSizes:c}),a]},"service"):(0,ae.jsxs)(Le.Fragment,{children:[(0,ae.jsx)("world-image",{onClick:u,uri:t.id,target:{x:0,y:0,width:t.target.spatial.width,height:t.target.spatial.height},display:t.width&&t.height?{width:t.width,height:t.height}:void 0,crop:l}),a]},"no-service")},e+(t.service?"server":"no-service"))}var $=require("react"),kr=require("@atlas-viewer/atlas");var Se=require("react");var rr=require("@iiif/helpers");function ot(e,t){let{selector:n,source:r}=(0,rr.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[n?n.type==="TemporalSelector"?{type:"TemporalBoxSelector",temporal:n.temporal,spatial:o.spatial}:n:null,r]}var or={makeChoice:()=>{}},it={type:"unknown"},C=e=>({type:"unknown",reason:e,annotations:{pages:[]}}),ir=(e,t)=>({type:"empty",width:e,height:t,annotations:{pages:[]},image:null,images:[]});var ze=require("react");function fo(e,t){let n=e?.iiif?.meta[t];return n?n.annotationPageManager:null}function ar(e,t){return S(n=>{let r=[];if(!e)return r;let o=Object.keys(n.iiif.entities.AnnotationPage);for(let i of o)if(!t||t.indexOf(i)!==-1){let a=fo(n,i);a&&a.views&&a.views[e]&&r.push(i)}return r},[e,t])}function sr({canvas:e,manifest:t,all:n,canvases:r}){let o=[];if(t)for(let i of t.annotations)o.indexOf(i.id)===-1&&o.push(i.id);if(n){if(r&&r.length)for(let i of r)for(let a of i.annotations)o.indexOf(a.id)===-1&&o.push(a.id)}else if(e)for(let i of e.annotations)o.indexOf(i.id)===-1&&o.push(i.id);return o}function po(e,t){let n=e?.iiif?.meta[t];return n?n.annotationPageManager:null}function ur(e,t={}){let n=y(),r=w(),o=R(),i=je(),a=(0,ze.useMemo)(()=>sr({all:t.all,manifest:r,canvas:o,canvases:i}),[t.all,o,i,r]),s=ar(e,t.all?void 0:a),u=(0,ze.useCallback)(l=>{e&&n.setMetaValue([l,"annotationPageManager","views"],d=>d&&!d[e]?d:{...d||{},[e]:!1})},[e,n]),c=(0,ze.useCallback)((l,d={})=>{if(!e)return;let g=n.getState(),h=[];if(d?.deselectOthers){let m=Object.keys(g.iiif.entities.AnnotationPage);for(let p of m){let P=po(g,p);P&&P.views&&P.views[e]&&h.push(p)}}for(let m of h)u(m);n.setMetaValue([l,"annotationPageManager","views"],m=>m&&m[e]?m:{...m||{},[e]:!0})},[e,u,n]);return{availablePageIds:a,enabledPageIds:s,setPageEnabled:c,setPageDisabled:u}}function cr(e,t){return S((n,r)=>r.get(e.map(o=>({id:o,type:t}))),[e,t])}var ee=require("react");var at=G(require("react"),1),lr=require("@atlas-viewer/iiif-image-api"),go=at.default.createContext(new lr.ImageServiceLoader);function st(){return(0,at.useContext)(go)}function dr(){let e=st(),[t,n]=(0,ee.useState)({}),r=(0,ee.useRef)(!1);return(0,ee.useEffect)(()=>()=>{r.current=!0},[]),[(0,ee.useCallback)((i,{height:a,width:s})=>{if(i){let u=i.id||i["@id"],c=e.loadServiceSync({id:u,width:i.width||s,height:i.height||a,source:i});c?i=c:t[u]||(r.current||n(l=>({...l,[u]:"loading"})),e.loadService({id:u,width:i.width||s,height:i.height||a}).then(()=>{r.current||n(l=>({...l,[u]:"done"}))}))}return i},[e,t]),t]}var se=require("react");function mr(e={}){let t=et(),n=R(e.canvasId?{id:e.canvasId}:void 0);return S((r,o)=>{if(!n)return[];if(t&&e.enableSingleAnnotation)return[t];let i=o.get(n.items),a=[];for(let s of i)a.push(...o.get(s.items));return a},[n])}var fr=require("@iiif/helpers/painting-annotations");function pr(e,t=[]){let n=y(),r=(0,se.useMemo)(()=>(0,fr.createPaintingAnnotationsHelper)(n),[]),o=mr({enableSingleAnnotation:e?.enableSingleAnnotation}),[i,a]=(0,se.useState)(e?.defaultChoices||[]),s=(0,se.useMemo)(()=>r.getPaintables(o,i),[n,o,i,...t]),c={makeChoice:(0,se.useCallback)((l,{deselectOthers:d=!0,deselect:g=!1}={})=>{s.choice&&a(h=>{if(g){let p=h.filter(P=>P!==l);if(p.length===0){let P=s.items[0].resource.id;return P?[P]:[]}return p}if(d)return[l];let m=[...h];if(m.length===0&&s.items.length){let p=s.items[0].resource.id;p&&m.push(p)}return h.indexOf(l)!==-1?h:[...h,l]})},[s.choice])};return[s,c]}var ho=["model/gltf-binary"];function gr(e,t){let r=t.items[0].resource;return r.format?ho.indexOf(r.format)===-1?C(`3D format: ${r.format} is unsupported`):{type:"3d-model",model:r}:C("Unknown format")}function hr(e,t){if(!e.duration)return C("No duration on canvas");if(t.items.length>1)return C("Only one audio source supported");let n=t.items[0]?.resource;return n?n.format?{type:"media",media:{annotationId:t.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:[]}}:C("Audio does not have format"):C("Unknown audio")}var vr=require("@atlas-viewer/iiif-image-api");var Lt=require("@iiif/helpers/annotation-targets");function yr(e,t,n){let r=[];for(let o of t.items){let i=o.resource&&o.resource.type==="SpecificResource"?o.resource.source:o.resource;if(!i.id)return C("No resource Identifier");let a;if(i.service){let m=(0,vr.getImageServices)(i);m[0]&&(a=n(m[0],e))}let s={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}},[u,c]=ot(e,o.target);if(!(c.id===e.id||decodeURIComponent(c.id||"")===(e.id||"")))continue;let l=o.resource.width&&o.resource.height?{type:"BoxSelector",spatial:{x:0,y:0,width:o.resource.width,height:o.resource.height}}:void 0,d=o.resource.type==="SpecificResource"?(0,Lt.expandTarget)(o.resource):null;if(o.selector){let m=(0,Lt.expandTarget)({type:"SpecificResource",source:o.resource,selector:o.selector});m&&(d=m)}let g=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;a&&!a.id&&(a.id=a["@id"]);let h={id:i.id,type:"Image",annotationId:o.annotationId,width:Number(u||g?i.width:e.width),height:Number(u||g?i.height:e.height),service:a,sizes:a&&a.sizes?a.sizes:i.width&&i.height?[{width:i.width,height:i.height}]:[],target:u&&u.type!=="PointSelector"?u:s,selector:g};r.push(h)}return{type:"images",image:r[0],images:r,choice:t.choice}}function Sr(e,t={},n){let r=e.language||n||"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=>Sr(o,t,r))}return t}function xr(e,t){let n=[];return t.items.forEach(r=>{if(r.resource){let[o]=ot(e,r.target);n.push({annotationId:r.annotationId,text:Sr(r.resource),target:o})}}),{type:"textual-content",items:n}}var vo=/^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\/)|(?:(?:watch)?\?vi?=|&vi?=))([^#&?]*).*/;function Cr(e,t){let n=t.items.filter(s=>s.type==="video"),r=!1;if(e.duration||(r=!0),n.length>1)return C("Only one video source supported");let o=n[0]?.resource,i=!!(o.service||[]).find(s=>(s.profile||"").includes("youtube.com"));if(!i&&r)return C("Video does not have duration");if(!o)return C("Unknown video");if((!o.format||o.format==="text/html")&&!i)return C("Video does not have format");let a={annotationId:t.items[0].annotationId,duration:e.duration,url:o.id,type:"Video",items:[],target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:o.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}};if(i){a.type="VideoYouTube";let s=o.id.match(vo);if(!s[1])return C("Video is not known youtube video");a.youTubeId=s[1]}return{type:"media",media:a,annotations:{pages:[]}}}function Ar({canvas:e,paintables:t,supports:n,loadImageService:r}){if(!e)return it;if(t.types.length===0)return n.indexOf("empty")!==-1?ir(e.width,e.height):it;if(t.types.length!==1)if(t.types.length===2&&t.types.indexOf("text")!==-1)t.types=t.types.filter(i=>i!=="text");else return n.indexOf("complex-timeline")===-1?C("Complex timeline not supported"):C("ComplexTimelineStrategy not yet supported");let o=t.types[0];return o==="image"?n.indexOf("images")===-1?C("Image not supported"):yr(e,t,r):o==="Model"||o==="model"?n.indexOf("3d-model")===-1?C("3D not supported"):gr(e,t):o==="textualbody"?n.indexOf("textual-content")===-1?C("Textual content not supported"):xr(e,t):o==="sound"||o==="audio"?n.indexOf("media")===-1?C("Media not supported"):hr(e,t):o==="video"?n.indexOf("media")===-1?C("Media not supported"):Cr(e,t):it}function Pr(e){let t=w(),n=R(),r=y(),o=Tn(),i=e?.emitter||o,[a,s]=dr(),{enabledPageIds:u}=ur(e?.annotationPageManagerId||t?.id||n?.id,{all:!1}),c=cr(u,"AnnotationPage"),l=e?.strategies||["empty","images","media","textual-content","complex-timeline"],[d,g]=pr(e,[s]);(0,Se.useEffect)(()=>{let m=p=>{g.makeChoice(p.choiceId,{deselectOthers:p.deselectOthers,deselect:p.deselect})};return i.on("make-choice",m),()=>{i.off("make-choice",m)}},[]);let h=(0,Se.useMemo)(()=>Ar({canvas:n,paintables:d,supports:l,loadImageService:a}),[n,d,r,g.makeChoice]);return(0,Se.useEffect)(()=>{let m=d.allChoices,p={canvasId:n?.id,manifestId:t?.id};m&&i.emit("choice-change",{choice:m,partOf:p})},[n?.id,d.allChoices]),(0,Se.useMemo)(()=>h.type==="unknown"?[h,or]:[{...h,annotations:{pages:c}},g],[h,c])}var te=require("react");var Rr=require("react"),br=(e,t=[])=>{let n=y();(0,Rr.useEffect)(()=>{e(n)},[n,...t])};var Ir=require("@iiif/helpers/thumbnail");function ut(e,t,{canvasId:n,manifestId:r}={}){let o=y(),i=st(),a=(0,te.useMemo)(()=>(0,Ir.createThumbnailHelper)(o,{imageServiceLoader:i}),[o,i]),[s,u]=(0,te.useState)(),c=w(r?{id:r}:void 0),l=R(n?{id:n}:void 0),d=l||c,g=(0,te.useRef)(!1);if((0,te.useEffect)(()=>(g.current=!1,()=>{g.current=!0}),[]),!d)throw new Error("Must be called under a manifest or canvas context.");return br(h=>{a.getBestThumbnailAtSize(d,e,t).then(m=>{m.best&&!g.current&&u(m.best)})},[d]),s}var I=require("react");function yo(e){return{isMuted:!1,playRequested:!1,isPlaying:!1,isFinished:!1,volume:100,duration:e}}function So(e,t){switch(t.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:t.volume,isMuted:t.volume===0};case"TOGGLE_MUTE":return{...e,isMuted:!e.isMuted};case"UNMUTE":return{...e,isMuted:!1}}return e}function xo(e){let t=Math.round(e);return`${Math.floor(t/60)}:${`${t%60}`.padStart(2,"0")}`}function xe(e){let[t,n]=(0,I.useReducer)(So,yo(e.duration)),r=(0,I.useRef)(null),o=(0,I.useRef)(null),i=(0,I.useRef)(null),a=(0,I.useRef)(!1),s=(0,I.useCallback)(()=>{o.current&&r.current&&(o.current.innerHTML=xo(r.current.currentTime),i.current&&(i.current.style.width=`${r.current.currentTime/e.duration*100}%`),a.current!==r.current.muted&&(a.current=r.current.muted,n(r.current.muted?{type:"MUTE"}:{type:"UNMUTE"})))},[e.duration]),u=(0,I.useCallback)(()=>{r.current&&(n({type:"PLAY_REQUESTED"}),r.current.play().then(()=>{n({type:"PLAY"})}),s())},[s]),c=(0,I.useCallback)(()=>{r.current&&(r.current.duration>0&&r.current.paused?u():l())},[s]),l=(0,I.useCallback)(()=>{r.current&&(r.current.pause(),n({type:"PAUSE"}),s())},[s]),d=(0,I.useCallback)(()=>{r.current&&(r.current.muted=!r.current.muted,n(r.current.muted?{type:"MUTE"}:{type:"UNMUTE"}))},[]),g=(0,I.useCallback)(()=>{r.current&&(r.current.muted=!0,n({type:"MUTE"}))},[]),h=(0,I.useCallback)(()=>{r.current&&(r.current.muted=!1,n({type:"UNMUTE"}))},[]),m=(0,I.useCallback)(x=>{r.current&&(r.current.muted=!1,r.current.volume=x/100,n({type:"SET_VOLUME",volume:x}))},[]),p=(0,I.useCallback)(x=>{r.current&&(r.current.currentTime=Math.max(0,Math.min(x*e.duration,e.duration)),s())},[]),P=(0,I.useCallback)(x=>{r.current&&(r.current.currentTime=Math.max(0,Math.min(x,e.duration)),s())},[]);return(0,I.useEffect)(()=>{let x=setInterval(()=>{s()},350);return()=>clearInterval(x)},[s,e.duration]),(0,I.useEffect)(()=>{let x=()=>{n({type:"FINISHED"})},Y=r.current;return Y?.addEventListener("ended",x),()=>Y?.removeEventListener("ended",x)},[]),[{element:r,currentTime:o,progress:i},t,{play:u,pause:l,playPause:c,mute:g,unmute:h,toggleMute:d,setVolume:m,setDurationPercent:p,setTime:P}]}var Oe=require("react"),ct=require("react/jsx-runtime"),Co=(0,Oe.createContext)(null),Ao=(0,Oe.createContext)(null),Po=(0,Oe.createContext)(null);function lt({actions:e,state:t,children:n,currentTime:r,progress:o,element:i}){return(0,ct.jsx)(Po.Provider,{value:{currentTime:r,progress:o,element:i},children:(0,ct.jsx)(Ao.Provider,{value:e,children:(0,ct.jsx)(Co.Provider,{value:t,children:n})})})}var Tr=require("react");var wr=require("@iiif/helpers");function dt(){let e=w(),t=R();return(0,Tr.useMemo)(()=>{if(!e||!t||!e.start)return null;let n=(0,wr.expandTarget)(e.start);return!n||n.source.id!==t.id||!n||!n.selector||n.selector.type!=="TemporalSelector"?null:n.selector.temporal},[e,t])}var ft=require("react/jsx-runtime");function zt({media:e,startTime:t,children:n}){let[{element:r,currentTime:o,progress:i},a,s]=xe({duration:e.duration}),u=t?`${e.url}#t=${t}`:e.url;return(0,ft.jsxs)(lt,{state:a,actions:s,currentTime:o,progress:i,element:r,children:[(0,ft.jsx)("audio",{ref:r,src:u}),n]})}function mt({media:e,mediaControlsDeps:t,children:n}){let r=dt();return B("portal","audio",zt,{media:e,startTime:r?r.startTime:null,children:n},[e,r,...t||[]]),null}var Fe=require("react/jsx-runtime");function Ot({element:e,media:t,startTime:n,playPause:r,poster:o}){let i="div",a=n?`${t.url}#t=${n}`:t.url;return(0,Fe.jsxs)(i,{className:"video-container",part:"video-container",onClick:r,children:[(0,Fe.jsx)("style",{children:`
|
|
3
3
|
.video-container {
|
|
4
4
|
position: absolute;
|
|
5
5
|
top: 0;
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
justify-content: center;
|
|
26
26
|
pointer-events: visible;
|
|
27
27
|
}
|
|
28
|
-
`}),(0,ne.jsx)("div",{className:"model-container",children:(0,ne.jsx)("model-viewer",{"interaction-prompt":"none",style:{width:"100%",height:"100%"},"camera-controls":"","ar-status":"not-presenting",src:e.id})})]})}function gt({model:e,name:t}){return B("overlay",`model-${t}`,Ft,{model:e},[e]),null}var Mr=require("react/jsx-runtime");function ht({style:e}){let t=R();return!t||!t.height||!t.width?null:(0,Mr.jsx)("box",{interactive:!1,target:{x:0,y:0,width:Number(t.width),height:Number(t.height)},style:e})}var Ht=require("react/jsx-runtime");function vt(e){let t=R();return!t||!t.placeholderCanvas?null:(0,Ht.jsx)(
|
|
28
|
+
`}),(0,ne.jsx)("div",{className:"model-container",children:(0,ne.jsx)("model-viewer",{"interaction-prompt":"none",style:{width:"100%",height:"100%"},"camera-controls":"","ar-status":"not-presenting",src:e.id})})]})}function gt({model:e,name:t}){return B("overlay",`model-${t}`,Ft,{model:e},[e]),null}var Mr=require("react/jsx-runtime");function ht({style:e}){let t=R();return!t||!t.height||!t.width?null:(0,Mr.jsx)("box",{interactive:!1,target:{x:0,y:0,width:Number(t.width),height:Number(t.height)},style:e})}var Ht=require("react/jsx-runtime");function vt(e){let t=R();return!t||!t.placeholderCanvas?null:(0,Ht.jsx)(W,{canvas:t.placeholderCanvas.id,children:(0,Ht.jsx)(Ce,{renderViewerControls:e.renderViewerControls})})}var Vr=require("react"),He=require("react/jsx-runtime");function Ro({element:e,media:t,playPause:n}){let r=(0,Vr.useRef)(null);return t.youTubeId?(0,He.jsxs)("div",{className:"video-container",part:"video-container",onClick:n,children:[(0,He.jsx)("style",{children:`
|
|
29
29
|
.video-container {
|
|
30
30
|
position: absolute;
|
|
31
31
|
top: 0;
|
|
@@ -43,4 +43,4 @@
|
|
|
43
43
|
width: 100%;
|
|
44
44
|
object-fit: contain;
|
|
45
45
|
}
|
|
46
|
-
`}),(0,He.jsx)("iframe",{className:"video-yt",ref:r,src:`https://www.youtube.com/embed/${t.youTubeId}?enablejsapi=1&origin=${window.location.host}`,referrerPolicy:"no-referrer",sandbox:"allow-scripts allow-same-origin allow-presentation"})]}):null}function Nr({media:e,mediaControlsDeps:t,children:n}){let[{element:r,currentTime:o,progress:i},a,s]=xe({duration:e.duration});return B("overlay","video-element",
|
|
46
|
+
`}),(0,He.jsx)("iframe",{className:"video-yt",ref:r,src:`https://www.youtube.com/embed/${t.youTubeId}?enablejsapi=1&origin=${window.location.host}`,referrerPolicy:"no-referrer",sandbox:"allow-scripts allow-same-origin allow-presentation"})]}):null}function Nr({media:e,mediaControlsDeps:t,children:n}){let[{element:r,currentTime:o,progress:i},a,s]=xe({duration:e.duration});return B("overlay","video-element",Ro,{element:r,media:e,playPause:s.playPause}),null}var v=require("react/jsx-runtime");function Ce({x:e,y:t,onChoiceChange:n,registerActions:r,defaultChoices:o,isStatic:i,renderViewerControls:a,renderMediaControls:s,viewControlsDeps:u,mediaControlsDeps:c,strategies:l,throwOnUnknown:d,backgroundStyle:g,alwaysShowBackground:h,keepCanvasScale:m=!1,enableSizes:p=!1,enableYouTube:P=!0,onClickPaintingAnnotation:x,children:Y}){let V=R(),yt=Xe(V,["deep-zoom"]),[Ue]=zn(),b=Dn(),N=y(),z=(0,$.useMemo)(()=>(0,Er.createStylesHelper)(N),[N]),[f,_]=Pr({strategies:l||["images"],defaultChoices:o?.map(({id:A})=>A)}),Dt=f.type==="images"?f.choice:void 0,Lr=(0,$.useMemo)(()=>m?1:Math.max(1,...f.type==="images"?f.images.map(A=>(A.width||0)/A.target?.spatial.width):[]),[m,f]);Bn(Lr),(0,$.useEffect)(()=>{r&&r(_)},[f.annotations]),(0,$.useEffect)(()=>{if(o)for(let A of o)typeof A.opacity<"u"&&z.applyStyles({id:A.id},"atlas",{opacity:A.opacity})},[o]),(0,$.useLayoutEffect)(()=>{n&&n(Dt)},[Dt]),B(b&&(f.type==="images"||f.type==="empty"||f.type==="textual-content"&&a)?"overlay":"none",`canvas-portal-controls-${V?.id}`,Ve.Provider,a?{value:b||null,children:a(f)}:{},[V,b,f,...u||[]]);let Q=ut({maxWidth:256,maxHeight:256});if(!V)return null;let St=V.accompanyingCanvas,xt=V.placeholderCanvas,Ae=Q&&Q.type==="fixed"?(0,v.jsx)("world-object",{height:V.height,width:V.width,x:e,y:t,children:(0,v.jsx)("world-image",{uri:Q.id,target:{x:0,y:0,width:V.width,height:V.height},display:Q.width&&Q.height?{width:Q.width,height:Q.height}:void 0,crop:void 0})}):null;if(f.type==="unknown"){if(Ae)return Ae;if(d)throw new Error(f.reason||"Unknown image strategy");return null}let Ut=(0,v.jsxs)($.Fragment,{children:[Ue?(0,v.jsx)(Ne,{page:Ue}):null,f.annotations&&f.annotations.pages?f.annotations.pages.map(A=>(0,v.jsx)(Ne,{page:A},A.id)):null,Y]}),zr=f.type==="images"?f.images.length:0,To=f.type==="media"&&f.media.type==="Video"&&xt?(0,v.jsx)(vt,{renderViewerControls:a}):null;return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)("world-object",{height:V.height,width:V.width,x:e,y:t,...yt,children:[f.type==="empty"||h?(0,v.jsx)(ht,{style:g}):null,f.type==="textual-content"?f.items.map((A,Be)=>(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(kr.HTMLPortal,{onClick:x?Pe=>{Pe.stopPropagation(),x(A.annotationId,A,Pe)}:void 0,target:A.target?.spatial||void 0,children:(0,v.jsx)("div",{"data-textual-content":!0,children:(0,v.jsx)(Ee,{enableDangerouslySetInnerHTML:!0,children:A.text})})},Be),Ut]})):null,f.type==="images"?(0,v.jsxs)(v.Fragment,{children:[f.images.map((A,Be)=>(0,v.jsx)(rt,{isStatic:i,image:A,id:A.id,thumbnail:Be===0?Q:void 0,selector:A.selector,enableSizes:p,onClick:x?Pe=>{Pe.stopPropagation(),x(A.annotationId,A,Pe)}:void 0},A.id+Be)),Ut]}):null,f.type==="3d-model"?(0,v.jsx)(gt,{model:f.model}):null,f.type==="media"?(0,v.jsx)(v.Fragment,{children:f.media.type==="Sound"?(0,v.jsxs)(mt,{media:f.media,mediaControlsDeps:c,children:[Ae,s?s(f):null]}):f.media.type==="Video"?(0,v.jsxs)(pt,{media:f.media,mediaControlsDeps:c,children:[Ae,s?s(f):null]}):f.media.type==="VideoYouTube"&&P?(0,v.jsxs)(Nr,{media:f.media,mediaControlsDeps:c,children:[Ae,s?s(f):null]}):null}):null]},`${V.id}/${f.type}/${zr}`),f.type==="media"&&f.media.type==="Sound"&&St?(0,v.jsx)(W,{canvas:St.id,children:(0,v.jsx)(Ce,{renderViewerControls:a})}):null,f.type==="media"&&f.media.type==="Sound"&&xt&&!St?(0,v.jsx)(W,{canvas:xt.id,children:(0,v.jsx)(Ce,{renderViewerControls:a})}):null]})}var L=require("react/jsx-runtime"),bo=(0,De.forwardRef)(function(t,n){let r=w(),o=je(),i=Rn(),{ViewerControls:a,MediaControls:s}=t.components||{};if((0,De.useImperativeHandle)(n,()=>i,[i]),!r)return(0,L.jsx)("div",{});let u=0;return(0,L.jsxs)(L.Fragment,{children:[t.header,(0,L.jsx)(M.Viewer,{height:t.height,mode:t.mode,renderPreset:t.renderPreset,runtimeOptions:t.runtimeOptions,children:o.map((c,l)=>{let d=u;return u+=c.width+(t.spacing||0),(0,L.jsx)(W,{canvas:c.id,children:(0,L.jsx)(M.RenderCanvas,{strategies:["3d-model","media","images","empty","textual-content"],renderViewerControls:l===0&&a?()=>(0,L.jsx)(a,{}):void 0,renderMediaControls:l===0&&s?()=>(0,L.jsx)(s,{}):void 0,x:d,...t.canvasProps||{},children:t.annotations},c.id)},c.id)})},t.reuseAtlas?"":i.currentSequenceIndex),t.children]})}),M=(0,De.forwardRef)(function({children:t,height:n,annotations:r,canvasProps:o,spacing:i,header:a,components:s,mode:u,reuseAtlas:c,renderPreset:l,runtimeOptions:d,...g},h){let m=le();return(0,L.jsx)(ce,{vault:m,children:(0,L.jsx)(Pn,{...g,children:(0,L.jsx)(bo,{ref:h,height:n,components:s,spacing:i,canvasProps:o,annotations:r,header:a,mode:u,reuseAtlas:c,renderPreset:l,runtimeOptions:d,children:t})})})});M.RenderImage=rt;M.RenderCanvas=Ce;M.RenderAnnotationPage=Ne;M.RenderAnnotation=nt;M.Viewer=$n;M.CanvasBackground=ht;M.Audio=mt;M.Video=pt;M.Model=gt;M.AudioHTML=zt;M.VideoHTML=Ot;M.ModelHTML=Ft;M.PlaceholderCanvas=vt;
|
package/dist/canvas-panel.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Na as a}from"./chunk-QKLET6KX.js";import"./chunk-DXFXJCXN.js";export{a as CanvasPanel};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{c as lt,k as dt}from"./chunk-DXFXJCXN.js";import{forwardRef as Un,useImperativeHandle as li}from"react";import en,{useCallback as Ke,useMemo as tn,useState as Se}from"react";import{AtlasAuto as to,ModeContext as no}from"@atlas-viewer/atlas";import{ErrorBoundary as ro}from"react-error-boundary";import{useContext as Y}from"react";import $n,{useContext as Bn,useMemo as _n}from"react";import{jsx as Yn}from"react/jsx-runtime";var jn={collection:void 0,manifest:void 0,range:void 0,canvas:void 0,annotation:void 0,annotationPage:void 0},ge=$n.createContext(jn),E=()=>Bn(ge);function B({value:e,children:n}){let t=E(),r=_n(()=>({...t,...e}),[e,t]);return Yn(ge.Provider,{value:r,children:n})}import Qn,{useState as Wn}from"react";import{Vault as mt,globalVault as Gn}from"@iiif/helpers/vault";import{jsx as ft}from"react/jsx-runtime";var j=Qn.createContext({vault:null,setVaultInstance:e=>{}});function W({vault:e,vaultOptions:n,useGlobal:t,resources:r,children:o}){let[i,a]=Wn(()=>e||(t?Gn(n):n?new mt(n):new mt));return ft(j.Provider,{value:{vault:i,setVaultInstance:a},children:ft(B,{value:r||{},children:o})})}import{useContext as wr}from"react";import{createContext as Vr,useMemo as Tr}from"react";import{globalVault as Zn}from"@iiif/helpers/vault";import{useContext as Kn}from"react";function G(e){let n=Kn(j);return e||(n&&n.vault?n.vault:Zn())}import{useEffect as Jn,useMemo as Xn,useState as Ue}from"react";function pt(e,{noCache:n=!1}={}){let t=typeof e=="string"?e:e.id,r=G(),[o,i]=Ue(t),[a,s]=Ue(void 0),u=Xn(()=>r.get(t,{skipSelfReturn:!0})||void 0,[t,r]),[c,l]=Ue(u);return Jn(()=>{(async()=>{try{let d=u&&!n?u:await r.load(t),g=d?d.id||d["@id"]:null;d&&o!==g&&i(g),l(d)}catch(d){s(d)}})()},[t,n]),{isLoaded:!!c,id:o,requestId:t,error:a,resource:c,cached:!!(c&&c===u)}}function gt(e,n){let{id:t,isLoaded:r,error:o,resource:i,requestId:a,cached:s}=pt(e,n);return{id:t,isLoaded:r,error:o,manifest:i,requestId:a,cached:s}}import{jsx as er}from"react/jsx-runtime";function ht({manifest:e,children:n}){return er(B,{value:{manifest:e},children:n})}import{jsx as tr}from"react/jsx-runtime";function F({canvas:e,children:n}){return tr(B,{value:{canvas:e},children:n})}import{useContext as ir}from"react";import ar from"react";import{useContext as nr}from"react";var v=()=>{let{vault:e}=nr(j);if(e===null)throw new Error("Vault not found. Ensure you have your provider set up correctly.");return e};import{useEffect as rr,useState as or}from"react";function y(e,n=[]){let t=v(),[r,o]=or(()=>e(t.getState(),t));return rr(()=>t.subscribe(i=>e(i,t),i=>{o(i)},!1),n),r}var Z=ar.createContext([]);function he(){let e=ir(Z);return y(n=>e.map(t=>n.iiif.entities.Canvas[t]).filter(Boolean),[e])}import{useMemo as sr}from"react";function R(e={},n=[]){let{id:t,selector:r}=e,o=E(),i=v(),a=t||o.manifest,s=y(u=>a?u.iiif.entities.Manifest[a]:void 0,[a]);return sr(()=>{if(s)return r?r(s):s},[s,r,...n])}import{jsx as ur}from"react/jsx-runtime";function vt({range:e,children:n}){return ur(B,{value:{range:e},children:n})}function cr(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=cr(e,e.get(t));if(r)return r}}return null}function De(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(...De(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 la(e,n,t){for(let r of n.structures){let o=yt(e,e.get(r),t);if(o)return o}return null}function yt(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 i=yt(e,e.get(r),t);if(i)return i}}return null}function fa(e,n,t,r=!1){let o=n.behavior,i=t?e.get(t):null;if(!i)return[];let a=i.behavior,s=r?!1:o.includes("paged"),u=s?!1:o.includes("continuous"),c=s||u?!1:o.includes("individuals"),l=a.includes("facing-pages"),d=a.includes("non-paged");if(l||d||c||r)return[{id:i.id,type:"Canvas"}];let[g,h]=qe(e,n);if(u)return g;let f=g.findIndex(m=>m.id===t);if(f===-1)return[];for(let m of h)if(m.includes(f))return m.map(x=>g[x]);return[{id:i.id,type:"Canvas"}]}function qe(e,n,{disablePaging:t,skipNonPaged:r}={}){let o=n.behavior,i=o.includes("paged"),a=i?!1:o.includes("continuous"),s=i||a?!1:o.includes("individuals"),u=n.type==="Manifest"?n.items:De(e,n);if(a)return[u,[u.map((f,m)=>m)]];if(s||!i||t)return[u,u.map((f,m)=>[m])];let c=[],l=[],d=()=>{l.length&&(c.push([...l]),l=[])},g=0,h=!1;for(let f=0;f<u.length;f++){let m=e.get(u[f]);if(m.behavior.includes("non-paged")){f===g&&g++,r||(d(),c.push([f]),d());continue}if(f===g||m.behavior.includes("facing-pages")){l.length&&(h=!0),d(),c.push([f]),d();continue}if(l.push(f),h){d(),h=!1;continue}l.length>1&&d()}return l.length&&d(),[u,c]}import{useCallback as ve,useMemo as dr,useRef as mr,useState as fr}from"react";import{useMemo as lr}from"react";function St(e={},n=[]){let{id:t,selector:r}=e,o=E(),i=t||o.range,a=y(s=>i?s.iiif.entities.Range[i]:void 0,[i]);return lr(()=>{if(a)return r?r(a):a},[a,r,...n])}function xt({startCanvas:e,disablePaging:n}){let t=v(),r=R(),o=St(),[i,a]=fr(void 0),s=o||r;if(!s)throw new Error("Nothing selected");let[u,c]=dr(()=>qe(t,s,{disablePaging:n}),[t,s,n]),l=mr(c);if(l.current!==c){let x=l.current[i][0],S=c.findIndex(q=>q.includes(x));l.current=c,a(S)}let d=ve(m=>{let x=c.findIndex(S=>S.includes(m));a(x===-1?0:x)},[u,c]),g=ve(m=>{let x=u.findIndex(S=>S.id===m);x!==-1?d(x):a(0)},[u,c]),h=ve(()=>{a(m=>m>=c.length-1?m:m+1)},[c]),f=ve(()=>{a(m=>m<=0?0:m-1)},[c]);return typeof i>"u"&&(e?g(e):a(0)),{visibleItems:c[i]?.map(m=>u[m].id)||[],cursor:i,items:u,sequence:c,hasPrevious:i>0,hasNext:i<c.length-1,setSequenceIndex:a,setCanvasIndex:d,setCanvasId:g,next:h,previous:f}}import{createContext as _e,useContext as Nt,useEffect as gr,useMemo as hr}from"react";import{useStore as ae}from"zustand";import{createStore as Ct}from"zustand/vanilla";function Ia(e){let n=e.service||e.services||[];for(let t of n)if(t.type==="AuthProbeService2")return!0;return!1}function k(e,n,t){let r=n.findIndex(a=>a.service.id===e);if(r===-1)return n;let o=[...n],i=t(o[r]);return i===o[r]?n:(o[r]=i,o)}var Pt=()=>Ct((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:k(t.id,n().authItems,o=>({...o,isPending:!0}))})),At(t.service).then(()=>{$e(r).then(o=>{let i=o.expiresIn,a=Date.now()+i*1e3;e(()=>({authItems:k(t.id,n().authItems,s=>({...s,isLoggedIn:!0,isPending:!1,session:{token:o.accessToken,expires:a}}))}))}).catch(o=>{e(()=>({authItems:k(t.id,n().authItems,i=>({...i,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(a=>a.type==="AuthLogoutService2");if(!r)return;let o=`${r.id}?origin=${It()}`,i=window.open(o);e(()=>({authItems:k(t.id,n().authItems,a=>({...a,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(s=>s.type==="AuthAccessTokenService2"),i=t;if(n().authItems.find(s=>s.service.id===t.id)){e(()=>({authItems:k(t.id,n().authItems,s=>({...s,instances:s.instances+1}))}));return}if(e(()=>({currentAuth:i.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");$e(o).then(s=>{e(()=>({authItems:k(t.id,n().authItems,u=>({...u,isLoggedIn:!0,isPending:!1,session:{token:s.accessToken,expires:s.expiresIn}}))}))}).catch(s=>{e(()=>({authItems:k(t.id,n().authItems,u=>({...u,isLoggedIn:!1,isPending:!1,canAuthenticate:!1,error:s.message}))}))})}if(t.profile==="kiosk"){if(!o)throw new Error("Token service not found");e(()=>({authItems:k(t.id,n().authItems,s=>({...s,isPending:!0}))})),At(i).then(()=>{$e(o).then(s=>{e(()=>({authItems:k(t.id,n().authItems,u=>({...u,isLoggedIn:!0,isPending:!1,session:{token:s.accessToken,expires:s.expiresIn}}))}))}).catch(s=>{e(()=>({authItems:k(t.id,n().authItems,u=>({...u,isLoggedIn:!1,isPending:!1,error:s.message}))}))})})}t.profile},removeService:(t,r)=>{let o=n().currentAuth===n().authItems.findIndex(a=>a.service.id===t.id),i=n().currentAuth;if(o){let a=n().authItems.find(u=>u.service.id===t.id);a&&a.instances>1||(i=n().authItems.findIndex(c=>c.service.id!==t.id&&c.instances>0))}e(()=>({authItems:k(t.id,n().authItems,a=>({...a,instances:a.instances-1})),currentAuth:i}))}})),Rt=(e,n)=>Ct((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 i=r().token;try{let a=await fetch(o,{headers:i?{Authorization:`Bearer ${r().token}`,Accept:"application/json"}:{Accept:"application/json"}}).then(s=>s.json());if(a.status===200)t({status:"success",shouldDisplayResource:!0,error:null,errorHeading:null,errorNote:null,shouldSubstitute:!1,shouldRedirect:!1});else if(a.status<400&&a.status>=300){if(!a.location)throw new Error("Redirect location not found");t({status:"error",shouldDisplayResource:!1,shouldRedirect:!0,redirectResource:a.location||null})}else if(a.status===401)t({status:"error",shouldDisplayResource:!1,shouldRedirect:!1,shouldSubstitute:!!a.substitute,substituteResource:a.substitute||null,error:"Unauthorized",errorHeading:a.heading||{en:["Unauthorized"]},errorNote:a.note||null});else throw new Error("Unknown error")}catch(a){t({status:"error",error:a.message,errorHeading:{en:["Unknown error"]}})}},setToken(o){t({token:o})}}));function bt(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(i=>i.type==="AuthAccessService2");o[0]&&(t.services.access=o[0])}return t}async function $e(e,{strict:n=!0}={}){return new Promise((t,r)=>{let o=Math.random().toString(36).substring(7),i=`${e.id}?messageId=${o}&origin=${window.location.origin}`,a=c=>{let l=c.data;if(l.messageId===o){if(n&&l.type!=="AuthAccessToken2"){s(),r("Invalid response, expected type=AuthAccessToken2");return}if(!l.accessToken){s(),r("Invalid response, expected accessToken");return}s(),t(l)}},s=()=>window.removeEventListener("message",a),u=document.createElement("iframe");u.src=i,u.style.display="none",document.body.appendChild(u),window.addEventListener("message",a)})}function It(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 At(e){let n=`${e.id}?origin=${It()}`,t=window.open(n);if(!t)throw new Error("Failed to open window");return new Promise((r,o)=>{let i=setInterval(()=>{t.closed&&(clearInterval(i),r())},500)})}import{useEffect as Mt,useMemo as wt}from"react";import{useStore as pr}from"zustand";function Vt(e){let n=wt(()=>bt(e),[e]),t=Tt(n.services.access?.id),r=wt(()=>Rt(n.services.probe,t),[n.services.probe]),o=pr(r);return Mt(()=>{o.status==="unknown"&&!t&&o.probe()},[n.services.probe,o.status]),Mt(()=>{t&&(o.setToken(t),o.probe())},[t]),[e,o,n.hasAuth]}import{jsx as ye}from"react/jsx-runtime";var K=_e(null),vr=_e(null);vr.displayName="CurrentAuth";var yr=_e(null);yr.displayName="AuthActions";function Et({children:e}){let n=hr(()=>Pt(),[]);return ye(K.Provider,{value:n,children:e})}function kt(){return!!Nt(K)}function se(){let e=Nt(K);if(!e)throw new Error("useAuthActions must be used within a AuthProvider");return e}function Sr(){let e=se();return ae(e,t=>({login:t.login,logout:t.logout,nextAuth:t.nextAuth,previousAuth:t.previousAuth,setAuth:t.setAuth,addService:t.addService,removeService:t.removeService}))}function _a(){let e=se();return ae(e,n=>n)}function xr(e){let n=se();return ae(n,r=>r.authItems.find(o=>o.service.id===e))}function Tt(e){let n=se();return ae(n,r=>r.authItems.find(o=>o.id===e)?.session?.token)}function ja(e){let n=se();return ae(n,r=>{let o=r.authItems.find(i=>i.service.id===e);return!o||!o.isLoggedIn||!o.session?null:o.session?.token||null})}function Ar(e){let n=Sr(),t=xr(e.service.id);return gr(()=>(n?.addService(e.service,e.probeId),()=>{n?.removeService(e.service,e.probeId)}),[e.service]),t?(t.error||!t.isLoggedIn,e.children):null}function Be(){return null}function Lt(e){let[n,t,r]=Vt(e.resource),o=e.fallbackComponent||Be,i=e.loadingComponent||Be,a=e.errorComponent||Be,s=t.service,u=null;if(!r||!s)return e.children(n);let c=s.service.filter(l=>l.type==="AuthAccessService2");t.status==="error"&&(u=ye(a,{resource:e.resource,error:t.error||"",heading:t.errorHeading,note:t.errorNote,extra:e.extra})),(t.status==="unknown"||t.status==="probing")&&(u=ye(i,{})),t.status==="success"&&(u=e.children(n));for(let l of c)u=ye(Ar,{service:l,probeId:s.id,children:u},l.id);return u}import{createContext as br,useContext as es,useMemo as Ir}from"react";import{createStore as Cr}from"zustand/vanilla";var Pr=e=>e.id||e["@id"];function Rr(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 zt=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?Pr(n):void 0,r=null;return Cr((o,i)=>({service:n,resources:[],lastQuery:{},loading:!1,error:!1,highlight:null,hasSearch:!!n,hasAutocomplete:n?!!Rr(n):!1,errorMessage:"",search(a,s={}){if(!t)throw new Error("No search service found.");r&&!r.signal.aborted&&r.abort(),r=new AbortController;let u=new URLSearchParams;a.q&&u.set("q",a.q),a.motivation&&u.set("motivation",a.motivation),a.date&&u.set("date",a.date),a.user&&u.set("user",a.user),o({loading:!0}),fetch(`${t}?${u.toString()}`,{signal:r.signal,headers:{"Content-Type":"application/json",Accept:"application/json",...s.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(a){let s=i().resources.find(u=>u["@id"]===a);o({highlight:s})},nextResult(){let a=i().resources,s=i().highlight;if(!s){o({highlight:a[0]||null});return}let u=a.findIndex(c=>c["@id"]===s["@id"]);if(u===-1){o({highlight:a[0]||null});return}o({highlight:a[u+1]||a[0]||null})},previousResult(){let a=i().resources,s=i().highlight;if(!s){o({highlight:a[a.length-1]||null});return}let u=a.findIndex(c=>c["@id"]===s["@id"]);if(u===-1){o({highlight:a[a.length-1]||null});return}if(u===0){o({highlight:a[a.length-1]||null});return}o({highlight:a[u-1]||a[a.length-1]||null})}}))};import{useStore as is}from"zustand";function Ot(){let e=R();return e?e.service.find(n=>n.profile==="SearchService1"||n.profile==="http://iiif.io/api/search/1/search"):void 0}import{jsx as je}from"react/jsx-runtime";var J=br(null);J.displayName="Search";function Ft(e){let n=Ot();return e.store?je(J.Provider,{value:e.store,children:e.children}):je(Mr,{service:n,children:e.children})}function Mr({service:e,children:n}){let t=Ir(()=>zt(e),[e]);return je(J.Provider,{value:t,children:n})}import{jsx as T}from"react/jsx-runtime";var ue=()=>{},ce=Vr({setCurrentCanvasId:ue,setCurrentCanvasIndex:ue,nextCanvas:ue,previousCanvas:ue,items:[],sequence:[],setSequenceIndex:ue,currentSequenceIndex:0,hasNext:!1,hasPrevious:!1});function Nr(e){let n=R(),{cursor:t,visibleItems:r,next:o,sequence:i,items:a,setCanvasIndex:s,setCanvasId:u,previous:c,setSequenceIndex:l,hasNext:d,hasPrevious:g}=xt({startCanvas:e.startCanvas,disablePaging:e.pagingEnabled===!1}),h=Tr(()=>({sequence:i,items:a,setCurrentCanvasId:u,nextCanvas:o,previousCanvas:c,totalCanvases:a.length,setCurrentCanvasIndex:s,setSequenceIndex:l,currentSequenceIndex:t,hasNext:d,hasPrevious:g}),[i,a,u,o,c,a,s,l,t]);return n?r.length===0?null:T(ce.Provider,{value:h,children:T(Z.Provider,{value:r,children:T(F,{canvas:r[0],children:e.children})})}):(console.warn("The manifest passed to the provider is not a valid IIIF manifest."),T("div",{children:"Sorry, something went wrong."}))}function Ht(e){let n=G(e.vault),t=gt(e.manifest);if(!t)return console.warn("The manifest passed to the provider is not a valid IIIF manifest."),T("div",{children:"Sorry, something went wrong."});if(t.error)return T("div",{children:t.error.toString()});if(!t.isLoaded)return T("div",{children:"Loading..."});let r=T(Nr,{...e,children:e.children});return T(W,{vault:n,children:T(ht,{manifest:t.id,children:T(Et,{children:T(Ft,{children:e.rangeId?T(vt,{range:e.rangeId,children:r}):r})})})})}function Ut(){return wr(ce)}import Er from"react";import{createContext as kr,useMemo as Lr}from"react";import zr from"mitt";import{jsx as Fr}from"react/jsx-runtime";var Or=zr(),X=kr({emitter:Or});X.displayName="Events";function Dt(){return Er.useContext(X).emitter}function Os({emitter:e,children:n}){return Fr(X.Provider,{value:Lr(()=>({emitter:e}),[e]),children:n})}import{jsx as ee}from"react/jsx-runtime";function qt(){return{VaultContext:Y(j),ResourceContext:Y(ge),SimpleViewerReactContext:Y(ce),VisibleCanvasReactContext:Y(Z),AuthRContext:Y(K),SearchReactContext:Y(J),ReactEventContext:Y(X)}}function $t(e){return ee(W,{vault:e.bridge.VaultContext.vault||void 0,resources:e.bridge.ResourceContext,children:ee(Z.Provider,{value:e.bridge.VisibleCanvasReactContext,children:ee(ce.Provider,{value:e.bridge.SimpleViewerReactContext,children:ee(X.Provider,{value:e.bridge.ReactEventContext,children:ee(K.Provider,{value:e.bridge.AuthRContext,children:ee(J.Provider,{value:e.bridge.SearchReactContext,children:e.children})})})})})})}import{createContext as $r,useContext as Br,useMemo as _r}from"react";import{useCallback as _t,useLayoutEffect as Ur,useMemo as Dr,useRef as qr}from"react";import{entityActions as Ye}from"@iiif/helpers/vault/actions";import{useMemo as Hr}from"react";function Bt(){let n=v().getStore();return Hr(()=>t=>n.dispatch(t),[n])}function jt(e){return typeof e!="string"&&e&&e.bindToVault}function Yt(){let e=v(),n=qr([]),t=Bt(),r=Dr(()=>`vault://annotation-page/${new Date().getTime()}/${Math.round(Math.random()*1e9).toString(16)}`,[]);Ur(()=>{let s={id:r,type:"AnnotationPage",behavior:[],label:null,thumbnail:[],summary:null,requiredStatement:null,metadata:[],rights:null,provider:[],items:[],seeAlso:[],homepage:[],rendering:[],service:[]};t(Ye.importEntities({entities:{AnnotationPage:{[s.id]:s}}}))},[r]);let o=y(s=>r&&s.iiif.entities.AnnotationPage[r]||null,[r]),i=_t((s,u)=>{if(r){if(jt(s)){let d=s;d.__vault||d.bindToVault(e),s=typeof d.source=="string"?d.source:d.source.id,n.current[s]=d}else typeof s!="string"&&(s=s.id);let c=e.get({id:r,type:"AnnotationPage"}),l=e.get({id:s,type:"Annotation"});c&&l&&(c.items.find(d=>d.id===l.id)||t(Ye.addReference({id:r,type:"AnnotationPage",key:"items",reference:{id:s,type:"Annotation"},index:u})))}},[r]),a=_t(s=>{r&&(jt(s)?s=typeof s.source=="string"?s.source:s.source.id:typeof s!="string"&&(s=s.id),n.current[s]&&n.current[s].beforeRemove(),e.get({id:r,type:"AnnotationPage"})&&t(Ye.removeReference({id:r,type:"AnnotationPage",key:"items",reference:{id:s,type:"Annotation"}})))},[r]);return[o,{addAnnotation:i,removeAnnotation:a}]}import{jsx as jr}from"react/jsx-runtime";var Qt=$r(null);function Wt(){let e=Br(Qt);return[e.fullPage,{addAnnotation:e.addAnnotation,removeAnnotation:e.removeAnnotation}]}function Gt({children:e}){let[n,{addAnnotation:t,removeAnnotation:r}]=Yt();return jr(Qt.Provider,{value:_r(()=>({fullPage:n,addAnnotation:t,removeAnnotation:r}),[n]),children:e})}import{jsx as Qe,jsxs as Yr}from"react/jsx-runtime";function Zt({width:e,style:n,height:t,error:r,resetErrorBoundary:o}){return Yr("div",{style:{width:e,height:t,minHeight:500,...n||{},background:"#f9f9f9"},children:[Qe("h3",{children:"Error occurred"}),Qe("p",{children:r.message}),Qe("button",{onClick:o,children:"Reset"})]})}import{createContext as Qr,useContext as Wr}from"react";var le=Qr(null);function Kt(){return Wr(le)}import{createContext as Jt,useContext as Gr,useEffect as Zr}from"react";var We=Jt(()=>{}),Ge=Jt(()=>{});function L(e,n,t,r,o=[]){let i=Gr(e==="portal"?Ge:We);Zr(()=>(e!=="none"&&i(n,t,r),()=>{i(n,null)}),[n,e,i,...o])}import{createContext as Jr,useContext as Xr,useEffect as eo}from"react";import{useMemo as Kr}from"react";function C(e={},n=[]){let{id:t,selector:r}=e,o=E(),i=t||o.canvas,a=y(s=>i?s.iiif.entities.Canvas[i]:void 0,[i]);return Kr(()=>{if(a)return r?r(a):a},[a,r,...n])}var Ze=Jr(()=>{});function Xt(e){let n=C(),t=Xr(Ze);eo(()=>n&&n.id?(t(n.id,e),()=>t(n.id,-1)):()=>{},[n,e])}import{Fragment as oo,jsx as w,jsxs as io}from"react/jsx-runtime";function nn({children:e,errorFallback:n,outerContainerProps:t={},worldScale:r,...o}){let[i,a]=Se(),s=qt(),u=n||Zt,[c,l]=Se({}),d=Object.entries(c),[g,h]=Se({}),f=Object.entries(g),[m,x]=Se({}),S=tn(()=>r||Math.max(...Object.values(m)),[m]),q=tn(()=>({maxOverZoom:S||1,...o.runtimeOptions||{}}),[S,o.runtimeOptions]),I=Ke((P,M)=>{x(N=>{if(M===-1){let{[P]:p,...O}=N;return O}return{...N,[P]:M}})},[]),Oe=Ke((P,M,N)=>{l(({[P]:p,...O})=>M?{...O,[P]:{element:M,props:N}}:O)},[]),fe=Ke((P,M,N)=>{h(({[P]:p,...O})=>M?{...O,[P]:{element:M,props:N}}:O)},[]);return io(ro,{resetKeys:[],fallbackRender:P=>w(u,{...o,...P}),children:[w(to,{...o,containerProps:{style:{position:"relative"},...o.containerProps||{}},htmlChildren:w(oo,{children:d.map(([P,{element:M,props:N}])=>w(en.Fragment,{children:w(M,{...N||{}})},P))}),onCreated:P=>{a(P),o.onCreated&&o.onCreated(P)},runtimeOptions:q,children:w(le.Provider,{value:i,children:w(Ze.Provider,{value:I,children:w(We.Provider,{value:Oe,children:w(Ge.Provider,{value:fe,children:w($t,{bridge:s,children:w(no.Provider,{value:o.mode||"explore",children:w(Gt,{children:e})})})})})})})}),w("div",{children:f.map(([P,{element:M,props:N}])=>w(en.Fragment,{children:w(M,{...N||{}})},P))})]})}import{mergeStyles as mo,RegionHighlight as fo}from"@atlas-viewer/atlas";import{useMemo as rn}from"react";import{createEventsHelper as ao}from"@iiif/helpers/events";function xe(e,n){let t=v(),r=rn(()=>ao(t),[t]),o=y(()=>e&&e.id?t.getResourceMeta(e.id,"eventManager"):null,[e]);return rn(()=>e?r.getListenersAsProps(e,n):{},[o,e,t,n])}import{useMemo as so}from"react";import{createStylesHelper as uo}from"@iiif/helpers/styles";function te(e,n){let t=v(),r=so(()=>uo(t),[t]);return y(()=>{if(!e)return null;let o=r.getAppliedStyles(e.id);return o?n?o[n]:o:void 0},[e,n])}import{useMemo as po}from"react";import{useMemo as co}from"react";import{expandTarget as lo}from"@iiif/helpers/annotation-targets";function Ae(e={},n=[]){let{id:t,selector:r}=e,o=E(),i=v(),a=t||o.annotation,s=y(c=>a?c.iiif.entities.Annotation[a]:void 0,[a]),u=y(c=>s&&s.body?s.body.map(l=>l?l.type==="SpecificResource"?{...l,source:i.get(l)}:l?c.iiif.entities[l.type][l.id]:null:null).filter(Boolean):[],[s]);return co(()=>{if(!s)return;let c={...s,body:u,target:lo(s.target,{typeMap:i.getState().iiif.mapping})};return r?r(c):c},[s,r,u,...n])}import{jsx as go}from"react/jsx-runtime";var Ce=({id:e,style:n,className:t,interactive:r})=>{let o=Ae({id:e}),i=te(o,"atlas"),a=te(o,"html"),s=xe(o,["atlas"]),u=C(),c=po(()=>mo(n,i),[n,i]);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)?go(fo,{id:o.id,isEditing:!0,region:o.target.selector.spatial,style:c,className:a?.className||t,interactive:!!(a?.href||r),href:a?.href||null,title:a?.title||null,hrefTarget:a?.target||null,onClick:()=>{},...s}):null};import{Fragment as vo}from"react";import{useMemo as ho}from"react";function on(e={},n=[]){let{id:t,selector:r}=e,o=E(),i=t||o.annotationPage,a=y(s=>i?s.iiif.entities.AnnotationPage[i]:void 0,[i]);return ho(()=>{if(a)return r?r(a):a},[a,...n])}import{jsx as an}from"react/jsx-runtime";var de=({className:e,page:n})=>{let t=on({id:n.id})||n,r=te(t,"atlas"),o=te(t,"html");return y(i=>t.id?i.iiif.entities.AnnotationPage[t.id]:null,[]),an(vo,{children:t.items?.map(i=>an(Ce,{id:i.id,style:r,className:o?.className||e},i.id))})};import{createStylesHelper as ai}from"@iiif/helpers/styles";import{Fragment as pn,useMemo as Ro}from"react";import{HTMLPortal as Ao,TileSet as mn}from"@atlas-viewer/atlas";import Pe,{useMemo as Je}from"react";import{jsx as H}from"react/jsx-runtime";var un=Pe.createContext("en"),cn=Pe.createContext({});function Vc(e){return H(cn.Provider,{value:e.translations,children:e.children})}function Tc(e){return H(un.Provider,{value:e.language,children:e.children})}function Xe(){return Pe.useContext(un)}function ln(){return Pe.useContext(cn)}function sn(e){return e.indexOf("-")!==-1?e.slice(0,e.indexOf("-")):e}function yo({as:e,language:n,children:t,viewingDirection:r,...o}){let i=Xe();return Je(()=>sn(i)===sn(n),[i,n])?e?H(e,{...o,children:t}):H("span",{...o,children:t}):e?H(e,{...o,lang:n,dir:r,children:t}):H("span",{...o,lang:n,dir:r,children:t})}function dn(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 So=(e,n=[])=>{let t=Xe();return Je(()=>{let r=e();return dn(t,r,[])},[t,...n])};function Q(e,n){return n?e[n]||n:""}function xo(e,n,t=`
|
|
2
|
-
`,r={}){let o=
|
|
3
|
-
`,
|
|
4
|
-
`):""}}function me({as:e,defaultText:n,enableDangerouslySetInnerHTML:t,children:r,separator:o,...i}){let a=ln(),[s,u]=xo(r,n,o,a);return u?H(yo,{...i,as:e,language:u,title:t?void 0:s,dangerouslySetInnerHTML:t?{__html:s}:void 0,children:t?void 0:s}):e?H(e,{...i,children:s}):H("span",{...i,title:t?void 0:s,dangerouslySetInnerHTML:t?{__html:s}:void 0,children:t?void 0:s})}import{jsx as U,jsxs as Po}from"react/jsx-runtime";function Co({resource:e,heading:n,note:t,extra:r}){return r?U(Ao,{target:{x:0,y:0,width:r.target?.spatial.width,height:r.target?.spatial.height},backgroundColor:"#333",relative:!0,children:U("div",{style:{display:"flex",alignContent:"center",justifyContent:"center",alignItems:"center",height:"100%",width:"100%",background:"#444",color:"#BBB"},children:Po("div",{children:[U(me,{children:n||"Not authorised"}),t&&U("p",{children:U(me,{children:t})}),U("p",{children:e.id||e["@id"]||"unknown"})]})})}):null}function fn({image:e,thumbnail:n,crop:t,enableSizes:r}){if(!kt()){let i=e.service,a=i.width||e.width||0,s=i.height||e.height||0;return U(mn,{tiles:{id:i.id||i["@id"]||"unknown",height:s,width:a,imageService:i},enableSizes:r,x:0,y:0,width:e.target?.spatial.width,height:e.target?.spatial.height,crop:t})}return U(Lt,{resource:e.service,errorComponent:Co,extra:e,children:i=>{let a=i.width||e.width||0,s=i.height||e.height||0;return U(mn,{tiles:{id:i.id||i["@id"]||"unknown",height:s,width:a,imageService:i},enableSizes:r,x:0,y:0,width:e.target?.spatial.width,height:e.target?.spatial.height,crop:t})}},e.id)}import{jsx as et,jsxs as gn}from"react/jsx-runtime";function Re({id:e,image:n,thumbnail:t,isStatic:r,x:o=0,y:i=0,children:a,selector:s,onClick:u,enableSizes:c}){let l=Ro(()=>{if(!(!s||s.spatial.x===0&&s.spatial.y===0))return s.spatial},[s]);return et("world-object",{x:o+n.target.spatial.x,y:i+n.target.spatial.y,width:n.target.spatial.width,height:n.target.spatial.height,onClick:u,children:n.service?gn(pn,{children:[et(fn,{image:n,thumbnail:t,crop:l,enableSizes:c}),a]},"service"):gn(pn,{children:[et("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}),a]},"no-service")},e+(n.service?"server":"no-service"))}import{Fragment as si,useEffect as Fn,useLayoutEffect as ui,useMemo as Hn}from"react";import{HTMLPortal as ci}from"@atlas-viewer/atlas";import{useEffect as bn,useMemo as In}from"react";import{useCallback as yn,useMemo as Io}from"react";function bo(e,n){let t=e?.iiif?.meta[n];return t?t.annotationPageManager:null}function hn(e,n){return y(t=>{let r=[];if(!e)return r;let o=Object.keys(t.iiif.entities.AnnotationPage);for(let i of o)if(!n||n.indexOf(i)!==-1){let a=bo(t,i);a&&a.views&&a.views[e]&&r.push(i)}return r},[e,n])}function vn({canvas:e,manifest:n,all:t,canvases:r}){let o=[];if(n)for(let i of n.annotations)o.indexOf(i.id)===-1&&o.push(i.id);if(t){if(r&&r.length)for(let i of r)for(let a of i.annotations)o.indexOf(a.id)===-1&&o.push(a.id)}else if(e)for(let i of e.annotations)o.indexOf(i.id)===-1&&o.push(i.id);return o}function Mo(e,n){let t=e?.iiif?.meta[n];return t?t.annotationPageManager:null}function Sn(e,n={}){let t=v(),r=R(),o=C(),i=he(),a=Io(()=>vn({all:n.all,manifest:r,canvas:o,canvases:i}),[n.all,o,i,r]),s=hn(e,n.all?void 0:a),u=yn(l=>{e&&t.setMetaValue([l,"annotationPageManager","views"],d=>d&&!d[e]?d:{...d||{},[e]:!1})},[e,t]),c=yn((l,d={})=>{if(!e)return;let g=t.getState(),h=[];if(d?.deselectOthers){let f=Object.keys(g.iiif.entities.AnnotationPage);for(let m of f){let x=Mo(g,m);x&&x.views&&x.views[e]&&h.push(m)}}for(let f of h)u(f);t.setMetaValue([l,"annotationPageManager","views"],f=>f&&f[e]?f:{...f||{},[e]:!0})},[e,u,t]);return{availablePageIds:a,enabledPageIds:s,setPageEnabled:c,setPageDisabled:u}}function xn(e,n){return y((t,r)=>r.get(e.map(o=>({id:o,type:n}))),[e,n])}import{useCallback as Eo,useEffect as ko,useRef as Lo,useState as zo}from"react";import wo,{useContext as Vo}from"react";import{ImageServiceLoader as To}from"@atlas-viewer/iiif-image-api";var No=wo.createContext(new To);function be(){return Vo(No)}function An(){let e=be(),[n,t]=zo({}),r=Lo(!1);return ko(()=>()=>{r.current=!0},[]),[Eo((i,{height:a,width:s})=>{if(i){let u=i.id||i["@id"],c=e.loadServiceSync({id:u,width:i.width||s,height:i.height||a,source:i});c?i=c:n[u]||(r.current||t(l=>({...l,[u]:"loading"})),e.loadService({id:u,width:i.width||s,height:i.height||a}).then(()=>{r.current||t(l=>({...l,[u]:"done"}))}))}return i},[e,n]),n]}import{useCallback as Oo,useMemo as Pn,useState as Fo}from"react";function Cn(e={}){let n=Ae(),t=C(e.canvasId?{id:e.canvasId}:void 0);return y((r,o)=>{if(!t)return[];if(n&&e.enableSingleAnnotation)return[n];let i=o.get(t.items),a=[];for(let s of i)a.push(...o.get(s.items));return a},[t])}import{createPaintingAnnotationsHelper as Ho}from"@iiif/helpers/painting-annotations";function Rn(e,n=[]){let t=v(),r=Pn(()=>Ho(t),[]),o=Cn({enableSingleAnnotation:e?.enableSingleAnnotation}),[i,a]=Fo(e?.defaultChoices||[]),s=Pn(()=>r.getPaintables(o,i),[t,o,i,...n]),c={makeChoice:Oo((l,{deselectOthers:d=!0,deselect:g=!1}={})=>{s.choice&&a(h=>{if(g){let m=h.filter(x=>x!==l);if(m.length===0){let x=s.items[0].resource.id;return x?[x]:[]}return m}if(d)return[l];let f=[...h];if(f.length===0&&s.items.length){let m=s.items[0].resource.id;m&&f.push(m)}return h.indexOf(l)!==-1?h:[...h,l]})},[s.choice])};return[s,c]}function Mn(e){let n=R(),t=C(),r=v(),o=Dt(),i=e?.emitter||o,[a,s]=An(),{enabledPageIds:u}=Sn(e?.annotationPageManagerId||n?.id||t?.id,{all:!1}),c=xn(u,"AnnotationPage"),l=e?.strategies||["empty","images","media","textual-content","complex-timeline"],[d,g]=Rn(e,[s]);bn(()=>{let f=m=>{g.makeChoice(m.choiceId,{deselectOthers:m.deselectOthers,deselect:m.deselect})};return i.on("make-choice",f),()=>{i.off("make-choice",f)}},[]);let h=In(()=>dt({canvas:t,paintables:d,supports:l,loadImageService:a}),[t,d,r,g.makeChoice]);return bn(()=>{let f=d.allChoices,m={canvasId:t?.id,manifestId:n?.id};f&&i.emit("choice-change",{choice:f,partOf:m})},[t?.id,d.allChoices]),In(()=>h.type==="unknown"?[h,lt]:[{...h,annotations:{pages:c}},g],[h,c])}import{useEffect as Do,useMemo as qo,useRef as $o,useState as Bo}from"react";import{useEffect as Uo}from"react";var wn=(e,n=[])=>{let t=v();Uo(()=>{e(t)},[t,...n])};import{createThumbnailHelper as _o}from"@iiif/helpers/thumbnail";function Ie(e,n,{canvasId:t,manifestId:r}={}){let o=v(),i=be(),a=qo(()=>_o(o,{imageServiceLoader:i}),[o,i]),[s,u]=Bo(),c=R(r?{id:r}:void 0),l=C(t?{id:t}:void 0),d=l||c,g=$o(!1);if(Do(()=>(g.current=!1,()=>{g.current=!0}),[]),!d)throw new Error("Must be called under a manifest or canvas context.");return wn(h=>{a.getBestThumbnailAtSize(d,e,n).then(f=>{f.best&&!g.current&&u(f.best)})},[d]),s}import{useCallback as z,useEffect as Vn,useReducer as jo,useRef as Me}from"react";function Yo(e){return{isMuted:!1,playRequested:!1,isPlaying:!1,isFinished:!1,volume:100,duration:e}}function Qo(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 Wo(e){let n=Math.round(e);return`${Math.floor(n/60)}:${`${n%60}`.padStart(2,"0")}`}function ne(e){let[n,t]=jo(Qo,Yo(e.duration)),r=Me(null),o=Me(null),i=Me(null),a=Me(!1),s=z(()=>{o.current&&r.current&&(o.current.innerHTML=Wo(r.current.currentTime),i.current&&(i.current.style.width=`${r.current.currentTime/e.duration*100}%`),a.current!==r.current.muted&&(a.current=r.current.muted,t(r.current.muted?{type:"MUTE"}:{type:"UNMUTE"})))},[e.duration]),u=z(()=>{r.current&&(t({type:"PLAY_REQUESTED"}),r.current.play().then(()=>{t({type:"PLAY"})}),s())},[s]),c=z(()=>{r.current&&(r.current.duration>0&&r.current.paused?u():l())},[s]),l=z(()=>{r.current&&(r.current.pause(),t({type:"PAUSE"}),s())},[s]),d=z(()=>{r.current&&(r.current.muted=!r.current.muted,t(r.current.muted?{type:"MUTE"}:{type:"UNMUTE"}))},[]),g=z(()=>{r.current&&(r.current.muted=!0,t({type:"MUTE"}))},[]),h=z(()=>{r.current&&(r.current.muted=!1,t({type:"UNMUTE"}))},[]),f=z(S=>{r.current&&(r.current.muted=!1,r.current.volume=S/100,t({type:"SET_VOLUME",volume:S}))},[]),m=z(S=>{r.current&&(r.current.currentTime=Math.max(0,Math.min(S*e.duration,e.duration)),s())},[]),x=z(S=>{r.current&&(r.current.currentTime=Math.max(0,Math.min(S,e.duration)),s())},[]);return Vn(()=>{let S=setInterval(()=>{s()},350);return()=>clearInterval(S)},[s,e.duration]),Vn(()=>{let S=()=>{t({type:"FINISHED"})},q=r.current;return q?.addEventListener("ended",S),()=>q?.removeEventListener("ended",S)},[]),[{element:r,currentTime:o,progress:i},n,{play:u,pause:l,playPause:c,mute:g,unmute:h,toggleMute:d,setVolume:f,setDurationPercent:m,setTime:x}]}import{createContext as nt,useContext as rt}from"react";import{jsx as tt}from"react/jsx-runtime";var Tn=nt(null),Nn=nt(null),En=nt(null);function Wl(){let e=rt(Tn);if(!e)throw new Error("Ctx not found");return e}function Gl(){let e=rt(Nn);if(!e)throw new Error("Ctx not found");return e}function Zl(){let e=rt(En);if(!e)throw new Error("Ctx not found");return e}function we({actions:e,state:n,children:t,currentTime:r,progress:o,element:i}){return tt(En.Provider,{value:{currentTime:r,progress:o,element:i},children:tt(Nn.Provider,{value:e,children:tt(Tn.Provider,{value:n,children:t})})})}import{useMemo as Go}from"react";import{expandTarget as Zo}from"@iiif/helpers";function Ve(){let e=R(),n=C();return Go(()=>{if(!e||!n||!e.start)return null;let t=Zo(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 Ko,jsxs as Jo}from"react/jsx-runtime";function ot({media:e,startTime:n,children:t}){let[{element:r,currentTime:o,progress:i},a,s]=ne({duration:e.duration}),u=n?`${e.url}#t=${n}`:e.url;return Jo(we,{state:a,actions:s,currentTime:o,progress:i,element:r,children:[Ko("audio",{ref:r,src:u}),t]})}function Te({media:e,mediaControlsDeps:n,children:t}){let r=Ve();return L("portal","audio",ot,{media:e,startTime:r?r.startTime:null,children:t},[e,r,...n||[]]),null}import{jsx as kn,jsxs as Xo}from"react/jsx-runtime";function it({element:e,media:n,startTime:t,playPause:r,poster:o}){let i="div",a=t?`${n.url}#t=${t}`:n.url;return Xo(i,{className:"video-container",part:"video-container",onClick:r,children:[kn("style",{children:`
|
|
1
|
+
import{c as lt,k as dt}from"./chunk-DXFXJCXN.js";import{forwardRef as qn,useImperativeHandle as mi}from"react";import en,{useCallback as Ke,useMemo as tn,useState as xe}from"react";import{AtlasAuto as ro,ModeContext as oo}from"@atlas-viewer/atlas";import{ErrorBoundary as io}from"react-error-boundary";import{useContext as Y}from"react";import _n,{useContext as jn,useMemo as Yn}from"react";import{jsx as Wn}from"react/jsx-runtime";var Qn={collection:void 0,manifest:void 0,range:void 0,canvas:void 0,annotation:void 0,annotationPage:void 0},he=_n.createContext(Qn),E=()=>jn(he);function B({value:e,children:n}){let t=E(),r=Yn(()=>({...t,...e}),[e,t]);return Wn(he.Provider,{value:r,children:n})}import Gn,{useState as Zn}from"react";import{Vault as mt,globalVault as Kn}from"@iiif/helpers/vault";import{jsx as ft}from"react/jsx-runtime";var j=Gn.createContext({vault:null,setVaultInstance:e=>{}});function W({vault:e,vaultOptions:n,useGlobal:t,resources:r,children:o}){let[i,a]=Zn(()=>e||(t?Kn(n):n?new mt(n):new mt));return ft(j.Provider,{value:{vault:i,setVaultInstance:a},children:ft(B,{value:r||{},children:o})})}import{useContext as Vr}from"react";import{createContext as Nr,useMemo as Er}from"react";import{globalVault as Jn}from"@iiif/helpers/vault";import{useContext as Xn}from"react";function G(e){let n=Xn(j);return e||(n&&n.vault?n.vault:Jn())}import{useEffect as er,useMemo as tr,useState as Ue}from"react";function pt(e,{noCache:n=!1}={}){let t=typeof e=="string"?e:e.id,r=G(),[o,i]=Ue(t),[a,s]=Ue(void 0),u=tr(()=>r.get(t,{skipSelfReturn:!0})||void 0,[t,r]),[c,l]=Ue(u);return er(()=>{(async()=>{try{let d=u&&!n?u:await r.load(t),g=d?d.id||d["@id"]:null;d&&o!==g&&i(g),l(d)}catch(d){s(d)}})()},[t,n]),{isLoaded:!!c,id:o,requestId:t,error:a,resource:c,cached:!!(c&&c===u)}}function gt(e,n){let{id:t,isLoaded:r,error:o,resource:i,requestId:a,cached:s}=pt(e,n);return{id:t,isLoaded:r,error:o,manifest:i,requestId:a,cached:s}}import{jsx as nr}from"react/jsx-runtime";function ht({manifest:e,children:n}){return nr(B,{value:{manifest:e},children:n})}import{jsx as rr}from"react/jsx-runtime";function H({canvas:e,children:n}){return rr(B,{value:{canvas:e},children:n})}import{useContext as sr}from"react";import ur from"react";import{useContext as or}from"react";var v=()=>{let{vault:e}=or(j);if(e===null)throw new Error("Vault not found. Ensure you have your provider set up correctly.");return e};import{useEffect as ir,useState as ar}from"react";function y(e,n=[]){let t=v(),[r,o]=ar(()=>e(t.getState(),t));return ir(()=>t.subscribe(i=>e(i,t),i=>{o(i)},!1),n),r}var Z=ur.createContext([]);function ve(){let e=sr(Z);return y(n=>e.map(t=>n.iiif.entities.Canvas[t]).filter(Boolean),[e])}import{useMemo as cr}from"react";function R(e={},n=[]){let{id:t,selector:r}=e,o=E(),i=v(),a=t||o.manifest,s=y(u=>a?u.iiif.entities.Manifest[a]:void 0,[a]);return cr(()=>{if(s)return r?r(s):s},[s,r,...n])}import{jsx as lr}from"react/jsx-runtime";function vt({range:e,children:n}){return lr(B,{value:{range:e},children:n})}function dr(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=dr(e,e.get(t));if(r)return r}}return null}function De(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(...De(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 ma(e,n,t){for(let r of n.structures){let o=yt(e,e.get(r),t);if(o)return o}return null}function yt(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 i=yt(e,e.get(r),t);if(i)return i}}return null}function ga(e,n,t,r=!1){let o=n.behavior,i=t?e.get(t):null;if(!i)return[];let a=i.behavior,s=r?!1:o.includes("paged"),u=s?!1:o.includes("continuous"),c=s||u?!1:o.includes("individuals"),l=a.includes("facing-pages"),d=a.includes("non-paged");if(l||d||c||r)return[{id:i.id,type:"Canvas"}];let[g,h]=qe(e,n);if(u)return g;let f=g.findIndex(m=>m.id===t);if(f===-1)return[];for(let m of h)if(m.includes(f))return m.map(x=>g[x]);return[{id:i.id,type:"Canvas"}]}function qe(e,n,{disablePaging:t,skipNonPaged:r}={}){let o=n.behavior,i=o.includes("paged"),a=i?!1:o.includes("continuous"),s=i||a?!1:o.includes("individuals"),u=n.type==="Manifest"?n.items:De(e,n);if(a)return[u,[u.map((f,m)=>m)]];if(s||!i||t)return[u,u.map((f,m)=>[m])];let c=[],l=[],d=()=>{l.length&&(c.push([...l]),l=[])},g=0,h=!1;for(let f=0;f<u.length;f++){let m=e.get(u[f]);if(m.behavior.includes("non-paged")){f===g&&g++,r||(d(),c.push([f]),d());continue}if(f===g||m.behavior.includes("facing-pages")){l.length&&(h=!0),d(),c.push([f]),d();continue}if(l.push(f),h){d(),h=!1;continue}l.length>1&&d()}return l.length&&d(),[u,c]}import{useCallback as ye,useMemo as fr,useRef as pr,useState as gr}from"react";import{useMemo as mr}from"react";function St(e={},n=[]){let{id:t,selector:r}=e,o=E(),i=t||o.range,a=y(s=>i?s.iiif.entities.Range[i]:void 0,[i]);return mr(()=>{if(a)return r?r(a):a},[a,r,...n])}function xt({startCanvas:e,disablePaging:n}){let t=v(),r=R(),o=St(),[i,a]=gr(void 0),s=o||r;if(!s)throw new Error("Nothing selected");let[u,c]=fr(()=>qe(t,s,{disablePaging:n}),[t,s,n]),l=pr(c);if(l.current!==c){let x=l.current[i][0],S=c.findIndex(q=>q.includes(x));l.current=c,a(S)}let d=ye(m=>{let x=c.findIndex(S=>S.includes(m));a(x===-1?0:x)},[u,c]),g=ye(m=>{let x=u.findIndex(S=>S.id===m);x!==-1?d(x):a(0)},[u,c]),h=ye(()=>{a(m=>m>=c.length-1?m:m+1)},[c]),f=ye(()=>{a(m=>m<=0?0:m-1)},[c]);return typeof i>"u"&&(e?g(e):a(0)),{visibleItems:c[i]?.map(m=>u[m].id)||[],cursor:i,items:u,sequence:c,hasPrevious:i>0,hasNext:i<c.length-1,setSequenceIndex:a,setCanvasIndex:d,setCanvasId:g,next:h,previous:f}}import{createContext as _e,useContext as Nt,useEffect as vr,useMemo as yr}from"react";import{useStore as se}from"zustand";import{createStore as Ct}from"zustand/vanilla";function wa(e){let n=e.service||e.services||[];for(let t of n)if(t.type==="AuthProbeService2")return!0;return!1}function k(e,n,t){let r=n.findIndex(a=>a.service.id===e);if(r===-1)return n;let o=[...n],i=t(o[r]);return i===o[r]?n:(o[r]=i,o)}var Pt=()=>Ct((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:k(t.id,n().authItems,o=>({...o,isPending:!0}))})),At(t.service).then(()=>{$e(r).then(o=>{let i=o.expiresIn,a=Date.now()+i*1e3;e(()=>({authItems:k(t.id,n().authItems,s=>({...s,isLoggedIn:!0,isPending:!1,session:{token:o.accessToken,expires:a}}))}))}).catch(o=>{e(()=>({authItems:k(t.id,n().authItems,i=>({...i,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(a=>a.type==="AuthLogoutService2");if(!r)return;let o=`${r.id}?origin=${It()}`,i=window.open(o);e(()=>({authItems:k(t.id,n().authItems,a=>({...a,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(s=>s.type==="AuthAccessTokenService2"),i=t;if(n().authItems.find(s=>s.service.id===t.id)){e(()=>({authItems:k(t.id,n().authItems,s=>({...s,instances:s.instances+1}))}));return}if(e(()=>({currentAuth:i.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");$e(o).then(s=>{e(()=>({authItems:k(t.id,n().authItems,u=>({...u,isLoggedIn:!0,isPending:!1,session:{token:s.accessToken,expires:s.expiresIn}}))}))}).catch(s=>{e(()=>({authItems:k(t.id,n().authItems,u=>({...u,isLoggedIn:!1,isPending:!1,canAuthenticate:!1,error:s.message}))}))})}if(t.profile==="kiosk"){if(!o)throw new Error("Token service not found");e(()=>({authItems:k(t.id,n().authItems,s=>({...s,isPending:!0}))})),At(i).then(()=>{$e(o).then(s=>{e(()=>({authItems:k(t.id,n().authItems,u=>({...u,isLoggedIn:!0,isPending:!1,session:{token:s.accessToken,expires:s.expiresIn}}))}))}).catch(s=>{e(()=>({authItems:k(t.id,n().authItems,u=>({...u,isLoggedIn:!1,isPending:!1,error:s.message}))}))})})}t.profile},removeService:(t,r)=>{let o=n().currentAuth===n().authItems.findIndex(a=>a.service.id===t.id),i=n().currentAuth;if(o){let a=n().authItems.find(u=>u.service.id===t.id);a&&a.instances>1||(i=n().authItems.findIndex(c=>c.service.id!==t.id&&c.instances>0))}e(()=>({authItems:k(t.id,n().authItems,a=>({...a,instances:a.instances-1})),currentAuth:i}))}})),Rt=(e,n)=>Ct((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 i=r().token;try{let a=await fetch(o,{headers:i?{Authorization:`Bearer ${r().token}`,Accept:"application/json"}:{Accept:"application/json"}}).then(s=>s.json());if(a.status===200)t({status:"success",shouldDisplayResource:!0,error:null,errorHeading:null,errorNote:null,shouldSubstitute:!1,shouldRedirect:!1});else if(a.status<400&&a.status>=300){if(!a.location)throw new Error("Redirect location not found");t({status:"error",shouldDisplayResource:!1,shouldRedirect:!0,redirectResource:a.location||null})}else if(a.status===401)t({status:"error",shouldDisplayResource:!1,shouldRedirect:!1,shouldSubstitute:!!a.substitute,substituteResource:a.substitute||null,error:"Unauthorized",errorHeading:a.heading||{en:["Unauthorized"]},errorNote:a.note||null});else throw new Error("Unknown error")}catch(a){t({status:"error",error:a.message,errorHeading:{en:["Unknown error"]}})}},setToken(o){t({token:o})}}));function bt(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(i=>i.type==="AuthAccessService2");o[0]&&(t.services.access=o[0])}return t}async function $e(e,{strict:n=!0}={}){return new Promise((t,r)=>{let o=Math.random().toString(36).substring(7),i=`${e.id}?messageId=${o}&origin=${window.location.origin}`,a=c=>{let l=c.data;if(l.messageId===o){if(n&&l.type!=="AuthAccessToken2"){s(),r("Invalid response, expected type=AuthAccessToken2");return}if(!l.accessToken){s(),r("Invalid response, expected accessToken");return}s(),t(l)}},s=()=>window.removeEventListener("message",a),u=document.createElement("iframe");u.src=i,u.style.display="none",document.body.appendChild(u),window.addEventListener("message",a)})}function It(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 At(e){let n=`${e.id}?origin=${It()}`,t=window.open(n);if(!t)throw new Error("Failed to open window");return new Promise((r,o)=>{let i=setInterval(()=>{t.closed&&(clearInterval(i),r())},500)})}import{useEffect as Mt,useMemo as wt}from"react";import{useStore as hr}from"zustand";function Tt(e){let n=wt(()=>bt(e),[e]),t=Vt(n.services.access?.id),r=wt(()=>Rt(n.services.probe,t),[n.services.probe]),o=hr(r);return Mt(()=>{o.status==="unknown"&&!t&&o.probe()},[n.services.probe,o.status]),Mt(()=>{t&&(o.setToken(t),o.probe())},[t]),[e,o,n.hasAuth]}import{jsx as Se}from"react/jsx-runtime";var K=_e(null),Sr=_e(null);Sr.displayName="CurrentAuth";var xr=_e(null);xr.displayName="AuthActions";function Et({children:e}){let n=yr(()=>Pt(),[]);return Se(K.Provider,{value:n,children:e})}function kt(){return!!Nt(K)}function ue(){let e=Nt(K);if(!e)throw new Error("useAuthActions must be used within a AuthProvider");return e}function Ar(){let e=ue();return se(e,t=>({login:t.login,logout:t.logout,nextAuth:t.nextAuth,previousAuth:t.previousAuth,setAuth:t.setAuth,addService:t.addService,removeService:t.removeService}))}function Ya(){let e=ue();return se(e,n=>n)}function Cr(e){let n=ue();return se(n,r=>r.authItems.find(o=>o.service.id===e))}function Vt(e){let n=ue();return se(n,r=>r.authItems.find(o=>o.id===e)?.session?.token)}function Qa(e){let n=ue();return se(n,r=>{let o=r.authItems.find(i=>i.service.id===e);return!o||!o.isLoggedIn||!o.session?null:o.session?.token||null})}function Pr(e){let n=Ar(),t=Cr(e.service.id);return vr(()=>(n?.addService(e.service,e.probeId),()=>{n?.removeService(e.service,e.probeId)}),[e.service]),t?(t.error||!t.isLoggedIn,e.children):null}function Be(){return null}function Lt(e){let[n,t,r]=Tt(e.resource),o=e.fallbackComponent||Be,i=e.loadingComponent||Be,a=e.errorComponent||Be,s=t.service,u=null;if(!r||!s)return e.children(n);let c=s.service.filter(l=>l.type==="AuthAccessService2");t.status==="error"&&(u=Se(a,{resource:e.resource,error:t.error||"",heading:t.errorHeading,note:t.errorNote,extra:e.extra})),(t.status==="unknown"||t.status==="probing")&&(u=Se(i,{})),t.status==="success"&&(u=e.children(n));for(let l of c)u=Se(Pr,{service:l,probeId:s.id,children:u},l.id);return u}import{createContext as Mr,useContext as ns,useMemo as wr}from"react";import{createStore as Rr}from"zustand/vanilla";var br=e=>e.id||e["@id"];function Ir(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 zt=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?br(n):void 0,r=null;return Rr((o,i)=>({service:n,resources:[],lastQuery:{},loading:!1,error:!1,highlight:null,hasSearch:!!n,hasAutocomplete:n?!!Ir(n):!1,errorMessage:"",search(a,s={}){if(!t)throw new Error("No search service found.");r&&!r.signal.aborted&&r.abort(),r=new AbortController;let u=new URLSearchParams;a.q&&u.set("q",a.q),a.motivation&&u.set("motivation",a.motivation),a.date&&u.set("date",a.date),a.user&&u.set("user",a.user),o({loading:!0}),fetch(`${t}?${u.toString()}`,{signal:r.signal,headers:{"Content-Type":"application/json",Accept:"application/json",...s.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(a){let s=i().resources.find(u=>u["@id"]===a);o({highlight:s})},nextResult(){let a=i().resources,s=i().highlight;if(!s){o({highlight:a[0]||null});return}let u=a.findIndex(c=>c["@id"]===s["@id"]);if(u===-1){o({highlight:a[0]||null});return}o({highlight:a[u+1]||a[0]||null})},previousResult(){let a=i().resources,s=i().highlight;if(!s){o({highlight:a[a.length-1]||null});return}let u=a.findIndex(c=>c["@id"]===s["@id"]);if(u===-1){o({highlight:a[a.length-1]||null});return}if(u===0){o({highlight:a[a.length-1]||null});return}o({highlight:a[u-1]||a[a.length-1]||null})}}))};import{useStore as ss}from"zustand";function Ot(){let e=R();return e?e.service.find(n=>n.profile==="SearchService1"||n.profile==="http://iiif.io/api/search/1/search"):void 0}import{jsx as je}from"react/jsx-runtime";var J=Mr(null);J.displayName="Search";function Ft(e){let n=Ot();return e.store?je(J.Provider,{value:e.store,children:e.children}):je(Tr,{service:n,children:e.children})}function Tr({service:e,children:n}){let t=wr(()=>zt(e),[e]);return je(J.Provider,{value:t,children:n})}import{jsx as V}from"react/jsx-runtime";var ce=()=>{},le=Nr({setCurrentCanvasId:ce,setCurrentCanvasIndex:ce,nextCanvas:ce,previousCanvas:ce,items:[],sequence:[],setSequenceIndex:ce,currentSequenceIndex:0,hasNext:!1,hasPrevious:!1});function kr(e){let n=R(),{cursor:t,visibleItems:r,next:o,sequence:i,items:a,setCanvasIndex:s,setCanvasId:u,previous:c,setSequenceIndex:l,hasNext:d,hasPrevious:g}=xt({startCanvas:e.startCanvas,disablePaging:e.pagingEnabled===!1}),h=Er(()=>({sequence:i,items:a,setCurrentCanvasId:u,nextCanvas:o,previousCanvas:c,totalCanvases:a.length,setCurrentCanvasIndex:s,setSequenceIndex:l,currentSequenceIndex:t,hasNext:d,hasPrevious:g}),[i,a,u,o,c,a,s,l,t]);return n?r.length===0?null:V(le.Provider,{value:h,children:V(Z.Provider,{value:r,children:V(H,{canvas:r[0],children:e.children})})}):(console.warn("The manifest passed to the provider is not a valid IIIF manifest."),V("div",{children:"Sorry, something went wrong."}))}function Ht(e){let n=G(e.vault),t=gt(e.manifest);if(!t)return console.warn("The manifest passed to the provider is not a valid IIIF manifest."),V("div",{children:"Sorry, something went wrong."});if(t.error)return V("div",{children:t.error.toString()});if(!t.isLoaded)return V("div",{children:"Loading..."});let r=V(kr,{...e,children:e.children});return V(W,{vault:n,children:V(ht,{manifest:t.id,children:V(Et,{children:V(Ft,{children:e.rangeId?V(vt,{range:e.rangeId,children:r}):r})})})})}function Ut(){return Vr(le)}import Lr from"react";import{createContext as zr,useMemo as Or}from"react";import Fr from"mitt";import{jsx as Ur}from"react/jsx-runtime";var Hr=Fr(),X=zr({emitter:Hr});X.displayName="Events";function Dt(){return Lr.useContext(X).emitter}function Hs({emitter:e,children:n}){return Ur(X.Provider,{value:Or(()=>({emitter:e}),[e]),children:n})}import{jsx as ee}from"react/jsx-runtime";function qt(){return{VaultContext:Y(j),ResourceContext:Y(he),SimpleViewerReactContext:Y(le),VisibleCanvasReactContext:Y(Z),AuthRContext:Y(K),SearchReactContext:Y(J),ReactEventContext:Y(X)}}function $t(e){return ee(W,{vault:e.bridge.VaultContext.vault||void 0,resources:e.bridge.ResourceContext,children:ee(Z.Provider,{value:e.bridge.VisibleCanvasReactContext,children:ee(le.Provider,{value:e.bridge.SimpleViewerReactContext,children:ee(X.Provider,{value:e.bridge.ReactEventContext,children:ee(K.Provider,{value:e.bridge.AuthRContext,children:ee(J.Provider,{value:e.bridge.SearchReactContext,children:e.children})})})})})})}import{createContext as _r,useContext as jr,useMemo as Yr}from"react";import{useCallback as _t,useLayoutEffect as qr,useMemo as $r,useRef as Br}from"react";import{entityActions as Ye}from"@iiif/helpers/vault/actions";import{useMemo as Dr}from"react";function Bt(){let n=v().getStore();return Dr(()=>t=>n.dispatch(t),[n])}function jt(e){return typeof e!="string"&&e&&e.bindToVault}function Yt(){let e=v(),n=Br([]),t=Bt(),r=$r(()=>`vault://annotation-page/${new Date().getTime()}/${Math.round(Math.random()*1e9).toString(16)}`,[]);qr(()=>{let s={id:r,type:"AnnotationPage",behavior:[],label:null,thumbnail:[],summary:null,requiredStatement:null,metadata:[],rights:null,provider:[],items:[],seeAlso:[],homepage:[],rendering:[],service:[]};t(Ye.importEntities({entities:{AnnotationPage:{[s.id]:s}}}))},[r]);let o=y(s=>r&&s.iiif.entities.AnnotationPage[r]||null,[r]),i=_t((s,u)=>{if(r){if(jt(s)){let d=s;d.__vault||d.bindToVault(e),s=typeof d.source=="string"?d.source:d.source.id,n.current[s]=d}else typeof s!="string"&&(s=s.id);let c=e.get({id:r,type:"AnnotationPage"}),l=e.get({id:s,type:"Annotation"});c&&l&&(c.items.find(d=>d.id===l.id)||t(Ye.addReference({id:r,type:"AnnotationPage",key:"items",reference:{id:s,type:"Annotation"},index:u})))}},[r]),a=_t(s=>{r&&(jt(s)?s=typeof s.source=="string"?s.source:s.source.id:typeof s!="string"&&(s=s.id),n.current[s]&&n.current[s].beforeRemove(),e.get({id:r,type:"AnnotationPage"})&&t(Ye.removeReference({id:r,type:"AnnotationPage",key:"items",reference:{id:s,type:"Annotation"}})))},[r]);return[o,{addAnnotation:i,removeAnnotation:a}]}import{jsx as Qr}from"react/jsx-runtime";var Qt=_r(null);function Wt(){let e=jr(Qt);return[e.fullPage,{addAnnotation:e.addAnnotation,removeAnnotation:e.removeAnnotation}]}function Gt({children:e}){let[n,{addAnnotation:t,removeAnnotation:r}]=Yt();return Qr(Qt.Provider,{value:Yr(()=>({fullPage:n,addAnnotation:t,removeAnnotation:r}),[n]),children:e})}import{jsx as Qe,jsxs as Wr}from"react/jsx-runtime";function Zt({width:e,style:n,height:t,error:r,resetErrorBoundary:o}){return Wr("div",{style:{width:e,height:t,minHeight:500,...n||{},background:"#f9f9f9"},children:[Qe("h3",{children:"Error occurred"}),Qe("p",{children:r.message}),Qe("button",{onClick:o,children:"Reset"})]})}import{createContext as Gr,useContext as Zr}from"react";var de=Gr(null);function Kt(){return Zr(de)}import{createContext as Jt,useContext as Kr,useEffect as Jr}from"react";var We=Jt(()=>{}),Ge=Jt(()=>{});function L(e,n,t,r,o=[]){let i=Kr(e==="portal"?Ge:We);Jr(()=>(e!=="none"&&i(n,t,r),()=>{i(n,null)}),[n,e,i,...o])}import{createContext as eo,useContext as to,useEffect as no}from"react";import{useMemo as Xr}from"react";function C(e={},n=[]){let{id:t,selector:r}=e,o=E(),i=t||o.canvas,a=y(s=>i?s.iiif.entities.Canvas[i]:void 0,[i]);return Xr(()=>{if(a)return r?r(a):a},[a,r,...n])}var Ze=eo(()=>{});function Xt(e){let n=C(),t=to(Ze);no(()=>n&&n.id?(t(n.id,e),()=>t(n.id,-1)):()=>{},[n,e])}import{Fragment as ao,jsx as w,jsxs as so}from"react/jsx-runtime";function nn({children:e,errorFallback:n,outerContainerProps:t={},worldScale:r,...o}){let[i,a]=xe(),s=qt(),u=n||Zt,[c,l]=xe({}),d=Object.entries(c),[g,h]=xe({}),f=Object.entries(g),[m,x]=xe({}),S=tn(()=>r||Math.max(...Object.values(m)),[m]),q=tn(()=>({maxOverZoom:S||1,...o.runtimeOptions||{}}),[S,o.runtimeOptions]),I=Ke((P,M)=>{x(N=>{if(M===-1){let{[P]:p,...F}=N;return F}return{...N,[P]:M}})},[]),Oe=Ke((P,M,N)=>{l(({[P]:p,...F})=>M?{...F,[P]:{element:M,props:N}}:F)},[]),pe=Ke((P,M,N)=>{h(({[P]:p,...F})=>M?{...F,[P]:{element:M,props:N}}:F)},[]);return so(io,{resetKeys:[],fallbackRender:P=>w(u,{...o,...P}),children:[w(ro,{...o,containerProps:{style:{position:"relative"},...o.containerProps||{}},htmlChildren:w(ao,{children:d.map(([P,{element:M,props:N}])=>w(en.Fragment,{children:w(M,{...N||{}})},P))}),onCreated:P=>{a(P),o.onCreated&&o.onCreated(P)},runtimeOptions:q,children:w(de.Provider,{value:i,children:w(Ze.Provider,{value:I,children:w(We.Provider,{value:Oe,children:w(Ge.Provider,{value:pe,children:w($t,{bridge:s,children:w(oo.Provider,{value:o.mode||"explore",children:w(Gt,{children:e})})})})})})})}),w("div",{children:f.map(([P,{element:M,props:N}])=>w(en.Fragment,{children:w(M,{...N||{}})},P))})]})}import{mergeStyles as po,RegionHighlight as go}from"@atlas-viewer/atlas";import{useMemo as rn}from"react";import{createEventsHelper as uo}from"@iiif/helpers/events";function Ae(e,n){let t=v(),r=rn(()=>uo(t),[t]),o=y(()=>e&&e.id?t.getResourceMeta(e.id,"eventManager"):null,[e]);return rn(()=>e?r.getListenersAsProps(e,n):{},[o,e,t,n])}import{useMemo as co}from"react";import{createStylesHelper as lo}from"@iiif/helpers/styles";function te(e,n){let t=v(),r=co(()=>lo(t),[t]);return y(()=>{if(!e)return null;let o=r.getAppliedStyles(e.id);return o?n?o[n]:o:void 0},[e,n])}import{useMemo as ho}from"react";import{useMemo as mo}from"react";import{expandTarget as fo}from"@iiif/helpers/annotation-targets";function Ce(e={},n=[]){let{id:t,selector:r}=e,o=E(),i=v(),a=t||o.annotation,s=y(c=>a?c.iiif.entities.Annotation[a]:void 0,[a]),u=y(c=>s&&s.body?s.body.map(l=>l?l.type==="SpecificResource"?{...l,source:i.get(l)}:l?c.iiif.entities[l.type][l.id]:null:null).filter(Boolean):[],[s]);return mo(()=>{if(!s)return;let c={...s,body:u,target:fo(s.target,{typeMap:i.getState().iiif.mapping})};return r?r(c):c},[s,r,u,...n])}import{jsx as vo}from"react/jsx-runtime";var Pe=({id:e,style:n,className:t,interactive:r})=>{let o=Ce({id:e}),i=te(o,"atlas"),a=te(o,"html"),s=Ae(o,["atlas"]),u=C(),c=ho(()=>po(n,i),[n,i]);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)?vo(go,{id:o.id,isEditing:!0,region:o.target.selector.spatial,style:c,className:a?.className||t,interactive:!!(a?.href||r),href:a?.href||null,title:a?.title||null,hrefTarget:a?.target||null,onClick:()=>{},...s}):null};import{Fragment as So}from"react";import{useMemo as yo}from"react";function on(e={},n=[]){let{id:t,selector:r}=e,o=E(),i=t||o.annotationPage,a=y(s=>i?s.iiif.entities.AnnotationPage[i]:void 0,[i]);return yo(()=>{if(a)return r?r(a):a},[a,...n])}import{jsx as an}from"react/jsx-runtime";var me=({className:e,page:n})=>{let t=on({id:n.id})||n,r=te(t,"atlas"),o=te(t,"html");return y(i=>t.id?i.iiif.entities.AnnotationPage[t.id]:null,[]),an(So,{children:t.items?.map(i=>an(Pe,{id:i.id,style:r,className:o?.className||e},i.id))})};import{createStylesHelper as ui}from"@iiif/helpers/styles";import{Fragment as hn,useMemo as Io}from"react";import{HTMLPortal as Po,TileSet as pn}from"@atlas-viewer/atlas";import ne,{useMemo as Je}from"react";import{jsx as z}from"react/jsx-runtime";var un=ne.createContext("en"),cn=ne.createContext({}),ln=ne.createContext(null);function Nc(e){return z(cn.Provider,{value:e.translations,children:e.children})}function Ec(e){return z(un.Provider,{value:e.language,children:e.children})}function kc(e){return z(ln.Provider,{value:e.convert,children:e.children})}function dn(){return ne.useContext(ln)}function Xe(){return ne.useContext(un)}function mn(){return ne.useContext(cn)}function sn(e){return e.indexOf("-")!==-1?e.slice(0,e.indexOf("-")):e}function xo({as:e,language:n,children:t,viewingDirection:r,...o}){let i=Xe();return Je(()=>sn(i)===sn(n),[i,n])?e?z(e,{...o,children:t}):z("span",{...o,children:t}):e?z(e,{...o,lang:n,dir:r,children:t}):z("span",{...o,lang:n,dir:r,children:t})}function fn(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 Ao=(e,n=[])=>{let t=Xe();return Je(()=>{let r=e();return fn(t,r,[])},[t,...n])};function Q(e,n,t,r){return n?t?t(e[n]||n,r||"none"):e[n]||n:""}function Co(e,n,t=`
|
|
2
|
+
`,r={}){let o=dn(),i=Ao(()=>Object.keys(e||{}),[e]);return[Je(()=>{if(!e)return Q(r,n,o)||"";if(typeof e=="string")return Q(r,e,o);let a=i?e[i]:void 0;return a?typeof a=="string"?a:a.map(s=>Q(r,s,o,i)).join(t):""},[i,n,e]),i]}function Lc(){let e=Xe(),n=mn(),t=dn();return function(o,i="",a=`
|
|
3
|
+
`,s=n){let u=Object.keys(o||{}),c=fn(e,u,[]);if(!o)return Q(s,i,t)||"";if(typeof o=="string")return Q(s,o,t);let l=c?o[c]:void 0;return l?typeof l=="string"?Q(s,l,t,c):l.map(d=>Q(s,d,t,c)).join(typeof a<"u"?a:`
|
|
4
|
+
`):""}}function fe({as:e,defaultText:n,enableDangerouslySetInnerHTML:t,children:r,separator:o,...i}){let a=mn(),[s,u]=Co(r,n,o,a);return u?z(xo,{...i,as:e,language:u,title:t?void 0:s,dangerouslySetInnerHTML:t?{__html:s}:void 0,children:t?void 0:s}):e?z(e,{...i,children:s}):z("span",{...i,title:t?void 0:s,dangerouslySetInnerHTML:t?{__html:s}:void 0,children:t?void 0:s})}import{jsx as U,jsxs as bo}from"react/jsx-runtime";function Ro({resource:e,heading:n,note:t,extra:r}){return r?U(Po,{target:{x:0,y:0,width:r.target?.spatial.width,height:r.target?.spatial.height},backgroundColor:"#333",relative:!0,children:U("div",{style:{display:"flex",alignContent:"center",justifyContent:"center",alignItems:"center",height:"100%",width:"100%",background:"#444",color:"#BBB"},children:bo("div",{children:[U(fe,{children:n||"Not authorised"}),t&&U("p",{children:U(fe,{children:t})}),U("p",{children:e.id||e["@id"]||"unknown"})]})})}):null}function gn({image:e,thumbnail:n,crop:t,enableSizes:r}){if(!kt()){let i=e.service,a=i.width||e.width||0,s=i.height||e.height||0;return U(pn,{tiles:{id:i.id||i["@id"]||"unknown",height:s,width:a,imageService:i},enableSizes:r,x:0,y:0,width:e.target?.spatial.width,height:e.target?.spatial.height,crop:t})}return U(Lt,{resource:e.service,errorComponent:Ro,extra:e,children:i=>{let a=i.width||e.width||0,s=i.height||e.height||0;return U(pn,{tiles:{id:i.id||i["@id"]||"unknown",height:s,width:a,imageService:i},enableSizes:r,x:0,y:0,width:e.target?.spatial.width,height:e.target?.spatial.height,crop:t})}},e.id)}import{jsx as et,jsxs as vn}from"react/jsx-runtime";function Re({id:e,image:n,thumbnail:t,isStatic:r,x:o=0,y:i=0,children:a,selector:s,onClick:u,enableSizes:c}){let l=Io(()=>{if(!(!s||s.spatial.x===0&&s.spatial.y===0))return s.spatial},[s]);return et("world-object",{x:o+n.target.spatial.x,y:i+n.target.spatial.y,width:n.target.spatial.width,height:n.target.spatial.height,onClick:u,children:n.service?vn(hn,{children:[et(gn,{image:n,thumbnail:t,crop:l,enableSizes:c}),a]},"service"):vn(hn,{children:[et("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}),a]},"no-service")},e+(n.service?"server":"no-service"))}import{Fragment as ci,useEffect as Un,useLayoutEffect as li,useMemo as Dn}from"react";import{HTMLPortal as di}from"@atlas-viewer/atlas";import{useEffect as Mn,useMemo as wn}from"react";import{useCallback as xn,useMemo as wo}from"react";function Mo(e,n){let t=e?.iiif?.meta[n];return t?t.annotationPageManager:null}function yn(e,n){return y(t=>{let r=[];if(!e)return r;let o=Object.keys(t.iiif.entities.AnnotationPage);for(let i of o)if(!n||n.indexOf(i)!==-1){let a=Mo(t,i);a&&a.views&&a.views[e]&&r.push(i)}return r},[e,n])}function Sn({canvas:e,manifest:n,all:t,canvases:r}){let o=[];if(n)for(let i of n.annotations)o.indexOf(i.id)===-1&&o.push(i.id);if(t){if(r&&r.length)for(let i of r)for(let a of i.annotations)o.indexOf(a.id)===-1&&o.push(a.id)}else if(e)for(let i of e.annotations)o.indexOf(i.id)===-1&&o.push(i.id);return o}function To(e,n){let t=e?.iiif?.meta[n];return t?t.annotationPageManager:null}function An(e,n={}){let t=v(),r=R(),o=C(),i=ve(),a=wo(()=>Sn({all:n.all,manifest:r,canvas:o,canvases:i}),[n.all,o,i,r]),s=yn(e,n.all?void 0:a),u=xn(l=>{e&&t.setMetaValue([l,"annotationPageManager","views"],d=>d&&!d[e]?d:{...d||{},[e]:!1})},[e,t]),c=xn((l,d={})=>{if(!e)return;let g=t.getState(),h=[];if(d?.deselectOthers){let f=Object.keys(g.iiif.entities.AnnotationPage);for(let m of f){let x=To(g,m);x&&x.views&&x.views[e]&&h.push(m)}}for(let f of h)u(f);t.setMetaValue([l,"annotationPageManager","views"],f=>f&&f[e]?f:{...f||{},[e]:!0})},[e,u,t]);return{availablePageIds:a,enabledPageIds:s,setPageEnabled:c,setPageDisabled:u}}function Cn(e,n){return y((t,r)=>r.get(e.map(o=>({id:o,type:n}))),[e,n])}import{useCallback as Lo,useEffect as zo,useRef as Oo,useState as Fo}from"react";import Vo,{useContext as No}from"react";import{ImageServiceLoader as Eo}from"@atlas-viewer/iiif-image-api";var ko=Vo.createContext(new Eo);function be(){return No(ko)}function Pn(){let e=be(),[n,t]=Fo({}),r=Oo(!1);return zo(()=>()=>{r.current=!0},[]),[Lo((i,{height:a,width:s})=>{if(i){let u=i.id||i["@id"],c=e.loadServiceSync({id:u,width:i.width||s,height:i.height||a,source:i});c?i=c:n[u]||(r.current||t(l=>({...l,[u]:"loading"})),e.loadService({id:u,width:i.width||s,height:i.height||a}).then(()=>{r.current||t(l=>({...l,[u]:"done"}))}))}return i},[e,n]),n]}import{useCallback as Ho,useMemo as bn,useState as Uo}from"react";function Rn(e={}){let n=Ce(),t=C(e.canvasId?{id:e.canvasId}:void 0);return y((r,o)=>{if(!t)return[];if(n&&e.enableSingleAnnotation)return[n];let i=o.get(t.items),a=[];for(let s of i)a.push(...o.get(s.items));return a},[t])}import{createPaintingAnnotationsHelper as Do}from"@iiif/helpers/painting-annotations";function In(e,n=[]){let t=v(),r=bn(()=>Do(t),[]),o=Rn({enableSingleAnnotation:e?.enableSingleAnnotation}),[i,a]=Uo(e?.defaultChoices||[]),s=bn(()=>r.getPaintables(o,i),[t,o,i,...n]),c={makeChoice:Ho((l,{deselectOthers:d=!0,deselect:g=!1}={})=>{s.choice&&a(h=>{if(g){let m=h.filter(x=>x!==l);if(m.length===0){let x=s.items[0].resource.id;return x?[x]:[]}return m}if(d)return[l];let f=[...h];if(f.length===0&&s.items.length){let m=s.items[0].resource.id;m&&f.push(m)}return h.indexOf(l)!==-1?h:[...h,l]})},[s.choice])};return[s,c]}function Tn(e){let n=R(),t=C(),r=v(),o=Dt(),i=e?.emitter||o,[a,s]=Pn(),{enabledPageIds:u}=An(e?.annotationPageManagerId||n?.id||t?.id,{all:!1}),c=Cn(u,"AnnotationPage"),l=e?.strategies||["empty","images","media","textual-content","complex-timeline"],[d,g]=In(e,[s]);Mn(()=>{let f=m=>{g.makeChoice(m.choiceId,{deselectOthers:m.deselectOthers,deselect:m.deselect})};return i.on("make-choice",f),()=>{i.off("make-choice",f)}},[]);let h=wn(()=>dt({canvas:t,paintables:d,supports:l,loadImageService:a}),[t,d,r,g.makeChoice]);return Mn(()=>{let f=d.allChoices,m={canvasId:t?.id,manifestId:n?.id};f&&i.emit("choice-change",{choice:f,partOf:m})},[t?.id,d.allChoices]),wn(()=>h.type==="unknown"?[h,lt]:[{...h,annotations:{pages:c}},g],[h,c])}import{useEffect as $o,useMemo as Bo,useRef as _o,useState as jo}from"react";import{useEffect as qo}from"react";var Vn=(e,n=[])=>{let t=v();qo(()=>{e(t)},[t,...n])};import{createThumbnailHelper as Yo}from"@iiif/helpers/thumbnail";function Ie(e,n,{canvasId:t,manifestId:r}={}){let o=v(),i=be(),a=Bo(()=>Yo(o,{imageServiceLoader:i}),[o,i]),[s,u]=jo(),c=R(r?{id:r}:void 0),l=C(t?{id:t}:void 0),d=l||c,g=_o(!1);if($o(()=>(g.current=!1,()=>{g.current=!0}),[]),!d)throw new Error("Must be called under a manifest or canvas context.");return Vn(h=>{a.getBestThumbnailAtSize(d,e,n).then(f=>{f.best&&!g.current&&u(f.best)})},[d]),s}import{useCallback as O,useEffect as Nn,useReducer as Qo,useRef as Me}from"react";function Wo(e){return{isMuted:!1,playRequested:!1,isPlaying:!1,isFinished:!1,volume:100,duration:e}}function Go(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 Zo(e){let n=Math.round(e);return`${Math.floor(n/60)}:${`${n%60}`.padStart(2,"0")}`}function re(e){let[n,t]=Qo(Go,Wo(e.duration)),r=Me(null),o=Me(null),i=Me(null),a=Me(!1),s=O(()=>{o.current&&r.current&&(o.current.innerHTML=Zo(r.current.currentTime),i.current&&(i.current.style.width=`${r.current.currentTime/e.duration*100}%`),a.current!==r.current.muted&&(a.current=r.current.muted,t(r.current.muted?{type:"MUTE"}:{type:"UNMUTE"})))},[e.duration]),u=O(()=>{r.current&&(t({type:"PLAY_REQUESTED"}),r.current.play().then(()=>{t({type:"PLAY"})}),s())},[s]),c=O(()=>{r.current&&(r.current.duration>0&&r.current.paused?u():l())},[s]),l=O(()=>{r.current&&(r.current.pause(),t({type:"PAUSE"}),s())},[s]),d=O(()=>{r.current&&(r.current.muted=!r.current.muted,t(r.current.muted?{type:"MUTE"}:{type:"UNMUTE"}))},[]),g=O(()=>{r.current&&(r.current.muted=!0,t({type:"MUTE"}))},[]),h=O(()=>{r.current&&(r.current.muted=!1,t({type:"UNMUTE"}))},[]),f=O(S=>{r.current&&(r.current.muted=!1,r.current.volume=S/100,t({type:"SET_VOLUME",volume:S}))},[]),m=O(S=>{r.current&&(r.current.currentTime=Math.max(0,Math.min(S*e.duration,e.duration)),s())},[]),x=O(S=>{r.current&&(r.current.currentTime=Math.max(0,Math.min(S,e.duration)),s())},[]);return Nn(()=>{let S=setInterval(()=>{s()},350);return()=>clearInterval(S)},[s,e.duration]),Nn(()=>{let S=()=>{t({type:"FINISHED"})},q=r.current;return q?.addEventListener("ended",S),()=>q?.removeEventListener("ended",S)},[]),[{element:r,currentTime:o,progress:i},n,{play:u,pause:l,playPause:c,mute:g,unmute:h,toggleMute:d,setVolume:f,setDurationPercent:m,setTime:x}]}import{createContext as nt,useContext as rt}from"react";import{jsx as tt}from"react/jsx-runtime";var En=nt(null),kn=nt(null),Ln=nt(null);function Kl(){let e=rt(En);if(!e)throw new Error("Ctx not found");return e}function Jl(){let e=rt(kn);if(!e)throw new Error("Ctx not found");return e}function Xl(){let e=rt(Ln);if(!e)throw new Error("Ctx not found");return e}function we({actions:e,state:n,children:t,currentTime:r,progress:o,element:i}){return tt(Ln.Provider,{value:{currentTime:r,progress:o,element:i},children:tt(kn.Provider,{value:e,children:tt(En.Provider,{value:n,children:t})})})}import{useMemo as Ko}from"react";import{expandTarget as Jo}from"@iiif/helpers";function Te(){let e=R(),n=C();return Ko(()=>{if(!e||!n||!e.start)return null;let t=Jo(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 Xo,jsxs as ei}from"react/jsx-runtime";function ot({media:e,startTime:n,children:t}){let[{element:r,currentTime:o,progress:i},a,s]=re({duration:e.duration}),u=n?`${e.url}#t=${n}`:e.url;return ei(we,{state:a,actions:s,currentTime:o,progress:i,element:r,children:[Xo("audio",{ref:r,src:u}),t]})}function Ve({media:e,mediaControlsDeps:n,children:t}){let r=Te();return L("portal","audio",ot,{media:e,startTime:r?r.startTime:null,children:t},[e,r,...n||[]]),null}import{jsx as zn,jsxs as ti}from"react/jsx-runtime";function it({element:e,media:n,startTime:t,playPause:r,poster:o}){let i="div",a=t?`${n.url}#t=${t}`:n.url;return ti(i,{className:"video-container",part:"video-container",onClick:r,children:[zn("style",{children:`
|
|
5
5
|
.video-container {
|
|
6
6
|
position: absolute;
|
|
7
7
|
top: 0;
|
|
@@ -14,7 +14,7 @@ import{c as lt,k as dt}from"./chunk-DXFXJCXN.js";import{forwardRef as Un,useImpe
|
|
|
14
14
|
justify-content: center;
|
|
15
15
|
pointer-events: visible;
|
|
16
16
|
}
|
|
17
|
-
`}),
|
|
17
|
+
`}),zn("video",{poster:o,ref:e,src:a,style:{width:"100%",objectFit:"contain"}})]})}function Ne({media:e,mediaControlsDeps:n,children:t,videoComponent:r=it}){let o=C(),i=Te(),a=o&&o.placeholderCanvas&&o.placeholderCanvas.id||void 0,s=Ie({},!1,{canvasId:a}),[{element:u,currentTime:c,progress:l},d,g]=re({duration:e.duration});return L("overlay","video-element",r,{element:u,media:e,playPause:g.playPause,poster:s?.id,startTime:i?i.startTime:null},[s]),L("portal","custom-controls",we,{state:d,actions:g,currentTime:c,progress:l,element:u,children:t},[c,d,e,...n||[]]),null}import{Fragment as ni,jsx as at,jsxs as ri}from"react/jsx-runtime";function st({model:e}){return ri(ni,{children:[at("style",{children:`
|
|
18
18
|
.model-container {
|
|
19
19
|
position: absolute;
|
|
20
20
|
top: 0;
|
|
@@ -27,7 +27,7 @@ import{c as lt,k as dt}from"./chunk-DXFXJCXN.js";import{forwardRef as Un,useImpe
|
|
|
27
27
|
justify-content: center;
|
|
28
28
|
pointer-events: visible;
|
|
29
29
|
}
|
|
30
|
-
`}),at("div",{className:"model-container",children:at("model-viewer",{"interaction-prompt":"none",style:{width:"100%",height:"100%"},"camera-controls":"","ar-status":"not-presenting",src:e.id})})]})}function Ee({model:e,name:n}){return L("overlay",`model-${n}`,st,{model:e},[e]),null}import{jsx as
|
|
30
|
+
`}),at("div",{className:"model-container",children:at("model-viewer",{"interaction-prompt":"none",style:{width:"100%",height:"100%"},"camera-controls":"","ar-status":"not-presenting",src:e.id})})]})}function Ee({model:e,name:n}){return L("overlay",`model-${n}`,st,{model:e},[e]),null}import{jsx as oi}from"react/jsx-runtime";function ke({style:e}){let n=C();return!n||!n.height||!n.width?null:oi("box",{interactive:!1,target:{x:0,y:0,width:Number(n.width),height:Number(n.height)},style:e})}import{jsx as On}from"react/jsx-runtime";function Le(e){let n=C();return!n||!n.placeholderCanvas?null:On(H,{canvas:n.placeholderCanvas.id,children:On(oe,{renderViewerControls:e.renderViewerControls})})}import{useRef as ii}from"react";import{jsx as Fn,jsxs as si}from"react/jsx-runtime";function ai({element:e,media:n,playPause:t}){let r=ii(null);return n.youTubeId?si("div",{className:"video-container",part:"video-container",onClick:t,children:[Fn("style",{children:`
|
|
31
31
|
.video-container {
|
|
32
32
|
position: absolute;
|
|
33
33
|
top: 0;
|
|
@@ -45,4 +45,4 @@ import{c as lt,k as dt}from"./chunk-DXFXJCXN.js";import{forwardRef as Un,useImpe
|
|
|
45
45
|
width: 100%;
|
|
46
46
|
object-fit: contain;
|
|
47
47
|
}
|
|
48
|
-
`}),
|
|
48
|
+
`}),Fn("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 Hn({media:e,mediaControlsDeps:n,children:t}){let[{element:r,currentTime:o,progress:i},a,s]=re({duration:e.duration});return L("overlay","video-element",ai,{element:r,media:e,playPause:s.playPause}),null}import{Fragment as ze,jsx as b,jsxs as _}from"react/jsx-runtime";function oe({x:e,y:n,onChoiceChange:t,registerActions:r,defaultChoices:o,isStatic:i,renderViewerControls:a,renderMediaControls:s,viewControlsDeps:u,mediaControlsDeps:c,strategies:l,throwOnUnknown:d,backgroundStyle:g,alwaysShowBackground:h,keepCanvasScale:f=!1,enableSizes:m=!1,enableYouTube:x=!0,onClickPaintingAnnotation:S,children:q}){let I=C(),Oe=Ae(I,["deep-zoom"]),[pe]=Wt(),P=Kt(),M=v(),N=Dn(()=>ui(M),[M]),[p,F]=Tn({strategies:l||["images"],defaultChoices:o?.map(({id:A})=>A)}),ut=p.type==="images"?p.choice:void 0,$n=Dn(()=>f?1:Math.max(1,...p.type==="images"?p.images.map(A=>(A.width||0)/A.target?.spatial.width):[]),[f,p]);Xt($n),Un(()=>{r&&r(F)},[p.annotations]),Un(()=>{if(o)for(let A of o)typeof A.opacity<"u"&&N.applyStyles({id:A.id},"atlas",{opacity:A.opacity})},[o]),li(()=>{t&&t(ut)},[ut]),L(P&&(p.type==="images"||p.type==="empty"||p.type==="textual-content"&&a)?"overlay":"none",`canvas-portal-controls-${I?.id}`,de.Provider,a?{value:P||null,children:a(p)}:{},[I,P,p,...u||[]]);let $=Ie({maxWidth:256,maxHeight:256});if(!I)return null;let Fe=I.accompanyingCanvas,He=I.placeholderCanvas,ie=$&&$.type==="fixed"?b("world-object",{height:I.height,width:I.width,x:e,y:n,children:b("world-image",{uri:$.id,target:{x:0,y:0,width:I.width,height:I.height},display:$.width&&$.height?{width:$.width,height:$.height}:void 0,crop:void 0})}):null;if(p.type==="unknown"){if(ie)return ie;if(d)throw new Error(p.reason||"Unknown image strategy");return null}let ct=_(ci,{children:[pe?b(me,{page:pe}):null,p.annotations&&p.annotations.pages?p.annotations.pages.map(A=>b(me,{page:A},A.id)):null,q]}),Bn=p.type==="images"?p.images.length:0,hi=p.type==="media"&&p.media.type==="Video"&&He?b(Le,{renderViewerControls:a}):null;return _(ze,{children:[_("world-object",{height:I.height,width:I.width,x:e,y:n,...Oe,children:[p.type==="empty"||h?b(ke,{style:g}):null,p.type==="textual-content"?p.items.map((A,ge)=>_(ze,{children:[b(di,{onClick:S?ae=>{ae.stopPropagation(),S(A.annotationId,A,ae)}:void 0,target:A.target?.spatial||void 0,children:b("div",{"data-textual-content":!0,children:b(fe,{enableDangerouslySetInnerHTML:!0,children:A.text})})},ge),ct]})):null,p.type==="images"?_(ze,{children:[p.images.map((A,ge)=>b(Re,{isStatic:i,image:A,id:A.id,thumbnail:ge===0?$:void 0,selector:A.selector,enableSizes:m,onClick:S?ae=>{ae.stopPropagation(),S(A.annotationId,A,ae)}:void 0},A.id+ge)),ct]}):null,p.type==="3d-model"?b(Ee,{model:p.model}):null,p.type==="media"?b(ze,{children:p.media.type==="Sound"?_(Ve,{media:p.media,mediaControlsDeps:c,children:[ie,s?s(p):null]}):p.media.type==="Video"?_(Ne,{media:p.media,mediaControlsDeps:c,children:[ie,s?s(p):null]}):p.media.type==="VideoYouTube"&&x?_(Hn,{media:p.media,mediaControlsDeps:c,children:[ie,s?s(p):null]}):null}):null]},`${I.id}/${p.type}/${Bn}`),p.type==="media"&&p.media.type==="Sound"&&Fe?b(H,{canvas:Fe.id,children:b(oe,{renderViewerControls:a})}):null,p.type==="media"&&p.media.type==="Sound"&&He&&!Fe?b(H,{canvas:He.id,children:b(oe,{renderViewerControls:a})}):null]})}import{Fragment as pi,jsx as D,jsxs as gi}from"react/jsx-runtime";var fi=qn(function(n,t){let r=R(),o=ve(),i=Ut(),{ViewerControls:a,MediaControls:s}=n.components||{};if(mi(t,()=>i,[i]),!r)return D("div",{});let u=0;return gi(pi,{children:[n.header,D(T.Viewer,{height:n.height,mode:n.mode,renderPreset:n.renderPreset,runtimeOptions:n.runtimeOptions,children:o.map((c,l)=>{let d=u;return u+=c.width+(n.spacing||0),D(H,{canvas:c.id,children:D(T.RenderCanvas,{strategies:["3d-model","media","images","empty","textual-content"],renderViewerControls:l===0&&a?()=>D(a,{}):void 0,renderMediaControls:l===0&&s?()=>D(s,{}):void 0,x:d,...n.canvasProps||{},children:n.annotations},c.id)},c.id)})},n.reuseAtlas?"":i.currentSequenceIndex),n.children]})}),T=qn(function({children:n,height:t,annotations:r,canvasProps:o,spacing:i,header:a,components:s,mode:u,reuseAtlas:c,renderPreset:l,runtimeOptions:d,...g},h){let f=G();return D(W,{vault:f,children:D(Ht,{...g,children:D(fi,{ref:h,height:t,components:s,spacing:i,canvasProps:o,annotations:r,header:a,mode:u,reuseAtlas:c,renderPreset:l,runtimeOptions:d,children:n})})})});T.RenderImage=Re;T.RenderCanvas=oe;T.RenderAnnotationPage=me;T.RenderAnnotation=Pe;T.Viewer=nn;T.CanvasBackground=ke;T.Audio=Ve;T.Video=Ne;T.Model=Ee;T.AudioHTML=ot;T.VideoHTML=it;T.ModelHTML=st;T.PlaceholderCanvas=Le;export{he as a,E as b,B as c,j as d,W as e,G as f,pt as g,gt as h,ht as i,H as j,v as k,y as l,Z as m,ve as n,R as o,vt as p,dr as q,De as r,ma as s,yt as t,ga as u,qe as v,St as w,xt as x,wa as y,Pt as z,Rt as A,bt as B,$e as C,At as D,K as E,Sr as F,xr as G,Et as H,kt as I,ue as J,Ar as K,Ya as L,Cr as M,Vt as N,Qa as O,Lt as P,Ot as Q,le as R,kr as S,Ht as T,Ut as U,Hr as V,X as W,Dt as X,Hs as Y,qt as Z,$t as _,Bt as $,Yt as aa,Wt as ba,Gt as ca,de as da,Kt as ea,C as fa,Ae as ga,te as ha,Ce as ia,on as ja,Nc as ka,Ec as la,kc as ma,dn as na,Xe as oa,mn as pa,xo as qa,Ao as ra,Co as sa,Lc as ta,fe as ua,Sn as va,An as wa,Cn as xa,ko as ya,be as za,Pn as Aa,Rn as Ba,In as Ca,Tn as Da,Vn as Ea,Ie as Fa,Zo as Ga,re as Ha,Kl as Ia,Jl as Ja,Xl as Ka,we as La,Te as Ma,T as Na};
|