react-iiif-vault 1.0.8 → 1.0.9

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.
Files changed (65) hide show
  1. package/.build/types/canvas-panel/Viewer.d.ts +1 -1
  2. package/.build/types/canvas-panel/index.d.ts +2 -1
  3. package/.build/types/canvas-panel/render/Audio.d.ts +1 -1
  4. package/.build/types/canvas-panel/render/Canvas.d.ts +2 -2
  5. package/.build/types/canvas-panel/render/CanvasBackground.d.ts +1 -1
  6. package/.build/types/canvas-panel/render/DefaultCanvasFallback.d.ts +1 -1
  7. package/.build/types/canvas-panel/render/Image.d.ts +1 -1
  8. package/.build/types/canvas-panel/render/Model.d.ts +1 -1
  9. package/.build/types/canvas-panel/render/Video.d.ts +1 -1
  10. package/.build/types/canvas-panel/render/VideoYouTube.d.ts +1 -1
  11. package/.build/types/components/CanvasAnnotations.d.ts +10 -0
  12. package/.build/types/components/CombinedMetadata.d.ts +4 -0
  13. package/.build/types/components/Image.d.ts +15 -0
  14. package/.build/types/components/ManifestMetadata.d.ts +4 -0
  15. package/.build/types/components/Metadata.d.ts +39 -0
  16. package/.build/types/components/SequenceThumbnails.d.ts +29 -0
  17. package/.build/types/components/SingleCanvasThumbnail.d.ts +20 -0
  18. package/.build/types/context/AnnotationContext.d.ts +1 -1
  19. package/.build/types/context/AnnotationPageContext.d.ts +1 -1
  20. package/.build/types/context/CanvasContext.d.ts +1 -1
  21. package/.build/types/context/CollectionContext.d.ts +1 -1
  22. package/.build/types/context/ContextBridge.d.ts +1 -1
  23. package/.build/types/context/ManifestContext.d.ts +1 -1
  24. package/.build/types/context/MediaContext.d.ts +1 -1
  25. package/.build/types/context/RangeContext.d.ts +1 -1
  26. package/.build/types/context/ResourceContext.d.ts +2 -2
  27. package/.build/types/context/VaultContext.d.ts +1 -1
  28. package/.build/types/demo/media-controls.d.ts +1 -1
  29. package/.build/types/demo/viewer-controls.d.ts +1 -1
  30. package/.build/types/features/rendering-strategy/3d-strategy.d.ts +1 -1
  31. package/.build/types/features/rendering-strategy/image-strategy.d.ts +1 -1
  32. package/.build/types/features/rendering-strategy/resource-types.d.ts +7 -7
  33. package/.build/types/features/rendering-strategy/strategies.d.ts +5 -5
  34. package/.build/types/features/rendering-strategy/textual-content-strategy.d.ts +1 -1
  35. package/.build/types/hooks/useEventListener.d.ts +1 -1
  36. package/.build/types/hooks/useExternalResource.d.ts +1 -1
  37. package/.build/types/hooks/useImage.d.ts +10 -0
  38. package/.build/types/hooks/useLoadImageService.d.ts +1 -1
  39. package/.build/types/hooks/useRenderingStrategy.d.ts +3 -3
  40. package/.build/types/hooks/useSimpleMediaPlayer.d.ts +2 -2
  41. package/.build/types/hooks/useVirtualAnnotationPageContext.d.ts +81 -81
  42. package/.build/types/index.d.ts +8 -0
  43. package/.build/types/utility/i18n-utils.d.ts +8 -6
  44. package/.build/types/viewers/SimpleViewerContext.d.ts +2 -2
  45. package/.build/types/viewers/SimpleViewerContext.hooks.d.ts +2 -0
  46. package/.build/types/viewers/SimpleViewerContext.types.d.ts +6 -4
  47. package/dist/bundle/cjs/index.js +7 -6
  48. package/dist/bundle/cjs/index.js.map +1 -1
  49. package/dist/bundle/esm/index.mjs +2390 -1174
  50. package/dist/bundle/esm/index.mjs.map +1 -1
  51. package/dist/canvas-panel/cjs/canvas-panel.js +5 -5
  52. package/dist/canvas-panel/cjs/canvas-panel.js.map +1 -1
  53. package/dist/canvas-panel/esm/canvas-panel.mjs +540 -480
  54. package/dist/canvas-panel/esm/canvas-panel.mjs.map +1 -1
  55. package/dist/index.umd.js +78 -76
  56. package/dist/index.umd.js.map +1 -1
  57. package/dist/react17/cjs/index.js +7 -6
  58. package/dist/react17/cjs/index.js.map +1 -1
  59. package/dist/react17/esm/index.mjs +2390 -1174
  60. package/dist/react17/esm/index.mjs.map +1 -1
  61. package/dist/utils/cjs/utils.js +1 -1
  62. package/dist/utils/cjs/utils.js.map +1 -1
  63. package/dist/utils/esm/utils.mjs +21 -21
  64. package/dist/utils/esm/utils.mjs.map +1 -1
  65. package/package.json +24 -22
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),u=require("react"),_=require("@atlas-viewer/atlas"),X=require("@iiif/helpers/vault"),ge=require("@iiif/helpers/styles"),Y=require("@iiif/helpers/annotation-targets"),Bt=require("@iiif/helpers"),te=require("@atlas-viewer/iiif-image-api"),Ht=require("@iiif/helpers/thumbnail");function $t(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const ce=$t(u);function de(e,t){return de=Object.setPrototypeOf||function(r,o){return r.__proto__=o,r},de(e,t)}function Yt(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,de(e,t)}var zt=function(t,n){return t===void 0&&(t=[]),n===void 0&&(n=[]),t.length!==n.length||t.some(function(r,o){return!Object.is(r,n[o])})},Ie={error:null},Kt=function(e){Yt(t,e);function t(){for(var r,o=arguments.length,i=new Array(o),s=0;s<o;s++)i[s]=arguments[s];return r=e.call.apply(e,[this].concat(i))||this,r.state=Ie,r.resetErrorBoundary=function(){for(var a,l=arguments.length,f=new Array(l),d=0;d<l;d++)f[d]=arguments[d];r.props.onReset==null||(a=r.props).onReset.apply(a,f),r.reset()},r}t.getDerivedStateFromError=function(o){return{error:o}};var n=t.prototype;return n.reset=function(){this.setState(Ie)},n.componentDidCatch=function(o,i){var s,a;(s=(a=this.props).onError)==null||s.call(a,o,i)},n.componentDidUpdate=function(o,i){var s=this.state.error,a=this.props.resetKeys;if(s!==null&&i.error!==null&&zt(o.resetKeys,a)){var l,f;(l=(f=this.props).onResetKeysChange)==null||l.call(f,o.resetKeys,a),this.reset()}},n.render=function(){var o=this.state.error,i=this.props,s=i.fallbackRender,a=i.FallbackComponent,l=i.fallback;if(o!==null){var f={error:o,resetErrorBoundary:this.resetErrorBoundary};if(ce.isValidElement(l))return l;if(typeof s=="function")return s(f);if(a)return ce.createElement(a,f);throw new Error("react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop")}return this.props.children},t}(ce.Component);const Wt={collection:void 0,manifest:void 0,range:void 0,canvas:void 0,annotation:void 0,annotationPage:void 0},ne=u.createContext(Wt),O=()=>u.useContext(ne);function N({value:e,children:t}){const n=O(),r=u.useMemo(()=>({...n,...e}),[e,n]);return c.jsx(ne.Provider,{value:r,children:t})}const K=u.createContext({vault:null,setVaultInstance:e=>{}});function he({vault:e,vaultOptions:t,useGlobal:n,resources:r,children:o}){const[i,s]=u.useState(()=>e||(n?X.globalVault(t):t?new X.Vault(t):new X.Vault));return c.jsx(K.Provider,{value:{vault:i,setVaultInstance:s},children:c.jsx(N,{value:r||{},children:o})})}const M=()=>{const{vault:e}=u.useContext(K);if(e===null)throw new Error("Vault not found. Ensure you have your provider set up correctly.");return e};function me(e,{noCache:t=!1}={}){const n=typeof e=="string"?e:e.id,r=M(),[o,i]=u.useState(n),[s,a]=u.useState(void 0),l=u.useMemo(()=>r.get(n,{skipSelfReturn:!0})||void 0,[n,r]),[f,d]=u.useState(l);return u.useEffect(()=>{(async()=>{try{const g=l&&!t?l:await r.load(n),p=g?g.id||g["@id"]:null;g&&o!==p&&i(p),d(g)}catch(g){a(g)}})()},[n,t]),{isLoaded:!!f,id:o,requestId:n,error:s,resource:f,cached:!!(f&&f===l)}}function Te(e,t){const{id:n,isLoaded:r,error:o,resource:i,requestId:s,cached:a}=me(e,t);return{id:n,isLoaded:r,error:o,manifest:i,requestId:s,cached:a}}function Ve({manifest:e,children:t}){return c.jsx(N,{value:{manifest:e},children:t})}function re({canvas:e,children:t}){return c.jsx(N,{value:{canvas:e},children:t})}function E(e,t=[]){const n=M(),[r,o]=u.useState(()=>e(n.getState(),n));return u.useEffect(()=>n.subscribe(i=>e(i,n),i=>{o(i)},!1),t),r}const W=u.createContext([]);function ve(){const e=u.useContext(W);return E(t=>e.map(n=>t.iiif.entities.Canvas[n]).filter(Boolean),[e])}function D(e={},t=[]){const{id:n,selector:r}=e,o=O();M();const i=n||o.manifest,s=E(a=>i?a.iiif.entities.Manifest[i]:void 0,[i]);return u.useMemo(()=>{if(s)return r?r(s):s},[s,r,...t])}function Le({range:e,children:t}){return c.jsx(N,{value:{range:e},children:t})}function ke(e,t){for(const n of t.items){if(n.type==="Canvas")return n;if(n.type==="SpecificResource")return n.source;if(n.type==="Range"){const r=ke(e,e.get(n));if(r)return r}}return null}function pe(e,t){var r;const n=[];for(const o of t.items)if(o.type==="SpecificResource"&&((r=o.source)==null?void 0:r.type)==="Canvas"&&(o.source.id.indexOf("#")!==-1?n.push({id:o.source.id.split("#")[0],type:"Canvas"}):n.push(o.source)),o.type==="Range"&&n.push(...pe(e,e.get(o))),o.type==="SpecificResource"){const i=typeof o.source=="string"?o.source:o.source.id;n.push({id:i,type:"Canvas"})}return n}function Gt(e,t,n){for(const r of t.structures){const o=ye(e,e.get(r),n);if(o)return o}return null}function ye(e,t,n){var r,o,i;for(const s of t.items){const a=(o=(r=s==null?void 0:s.source)==null?void 0:r.id)==null?void 0:o.split("#")[0];if(s.type==="SpecificResource"&&s.source===n||s.type==="SpecificResource"&&((i=s.source)==null?void 0:i.type)==="Canvas"&&n===a)return t;if(s.type==="Range"){const l=ye(e,e.get(s),n);if(l)return l}}return null}function Qt(e,t,n,r=!1){const o=t.behavior,i=n?e.get(n):null;if(!i)return[];const s=i.behavior,a=r?!1:o.includes("paged"),l=a?!1:o.includes("continuous"),f=a||l?!1:o.includes("individuals"),d=s.includes("facing-pages"),g=s.includes("non-paged");if(d||g||f||r)return[{id:i.id,type:"Canvas"}];const[p,y]=xe(e,t);if(l)return p;const m=p.findIndex(h=>h.id===n);if(m===-1)return[];for(const h of y)if(h.includes(m))return h.map(x=>p[x]);return[{id:i.id,type:"Canvas"}]}function xe(e,t,{disablePaging:n,skipNonPaged:r}={}){const o=t.behavior,i=o.includes("paged"),s=i?!1:o.includes("continuous"),a=i||s?!1:o.includes("individuals"),l=t.type==="Manifest"?t.items:pe(e,t);if(s)return[l,[l.map((m,h)=>h)]];if(a||!i||n)return[l,l.map((m,h)=>[h])];const f=[];let d=[];const g=()=>{d.length&&(f.push([...d]),d=[])};let p=0,y=!1;for(let m=0;m<l.length;m++){const h=e.get(l[m]);if(h.behavior.includes("non-paged")){m===p&&p++,r||(g(),f.push([m]),g());continue}if(m===p||h.behavior.includes("facing-pages")){d.length&&(y=!0),g(),f.push([m]),g();continue}if(d.push(m),y){g(),y=!1;continue}d.length>1&&g()}return d.length&&g(),[l,f]}function Oe(e={},t=[]){const{id:n,selector:r}=e,o=O(),i=n||o.range,s=E(a=>i?a.iiif.entities.Range[i]:void 0,[i]);return u.useMemo(()=>{if(s)return r?r(s):s},[s,r,...t])}function Fe({startCanvas:e,disablePaging:t}){var m;const n=M(),r=D(),o=Oe(),[i,s]=u.useState(void 0),a=o||r;if(!a)throw new Error("Nothing selected");const[l,f]=u.useMemo(()=>xe(n,a,{disablePaging:t}),[n,a]),d=u.useCallback(h=>{const x=f.findIndex(C=>C.includes(h));s(x===-1?0:x)},[l,f]),g=u.useCallback(h=>{const x=l.findIndex(C=>C.id===h);x!==-1?d(x):s(0)},[l,f]),p=u.useCallback(()=>{s(h=>h>=f.length?h:h+1)},[f]),y=u.useCallback(()=>{s(h=>h<=0?0:h-1)},[f]);return typeof i>"u"&&(e?g(e):s(0)),{visibleItems:((m=f[i])==null?void 0:m.map(h=>l[h].id))||[],cursor:i,items:l,sequence:f,setSequenceIndex:s,setCanvasIndex:d,setCanvasId:g,next:p,previous:y}}const $=()=>{},G=u.createContext({setCurrentCanvasId:$,setCurrentCanvasIndex:$,nextCanvas:$,previousCanvas:$,items:[],sequence:[],setSequenceIndex:$,currentSequenceIndex:0});function Ne(e){const t=D(),{cursor:n,visibleItems:r,next:o,sequence:i,items:s,setCanvasIndex:a,setCanvasId:l,previous:f,setSequenceIndex:d}=Fe({startCanvas:e.startCanvas,disablePaging:e.pagingEnabled===!1}),g=u.useMemo(()=>({sequence:i,items:s,setCurrentCanvasId:l,nextCanvas:o,previousCanvas:f,totalCanvases:s.length,setCurrentCanvasIndex:a,setSequenceIndex:d,currentSequenceIndex:n}),[i,s,l,o,f,s,a,d,n]);return t?r.length===0?null:c.jsx(G.Provider,{value:g,children:c.jsx(W.Provider,{value:r,children:c.jsx(re,{canvas:r[0],children:e.children})})}):(console.warn("The manifest passed to the provider is not a valid IIIF manifest."),c.jsx("div",{children:"Sorry, something went wrong."}))}function De(e){const t=Te(e.manifest);if(!t)return console.warn("The manifest passed to the provider is not a valid IIIF manifest."),c.jsx("div",{children:"Sorry, something went wrong."});if(t.error)return c.jsx("div",{children:t.error.toString()});if(!t.isLoaded)return c.jsx("div",{children:"Loading..."});const n=c.jsx(Ne,{...e,children:e.children});return c.jsx(Ve,{manifest:t.id,children:e.rangeId?c.jsx(Le,{range:e.rangeId,children:n}):n})}function qe(){return u.useContext(G)}function _e(){return{VaultContext:u.useContext(K),ResourceContext:u.useContext(ne),SimpleViewerReactContext:u.useContext(G),VisibleCanvasReactContext:u.useContext(W)}}function Ue(e){return c.jsx(he,{vault:e.bridge.VaultContext.vault||void 0,resources:e.bridge.ResourceContext,children:c.jsx(W.Provider,{value:e.bridge.VisibleCanvasReactContext,children:c.jsx(G.Provider,{value:e.bridge.SimpleViewerReactContext,children:e.children})})})}const T=function(e){return function(){const t={type:e,getType:()=>e,toString:()=>e};return(n,r)=>({...t,...n!==void 0&&{payload:n},...r!==void 0&&{meta:r}})}},Jt="@iiif/IMPORT_ENTITIES",Zt="@iiif/MODIFY_ENTITY_FIELD",Xt="@iiif/REORDER_ENTITY_FIELD",en="@iiif/ADD_REFERENCE",tn="@iiif/UPDATE_REFERENCE",nn="@iiif/REMOVE_REFERENCE",rn="@iiif/ADD_METADATA",on="@iiif/REMOVE_METADATA",sn="@iiif/UPDATE_METADATA",an="@iiif/REORDER_METADATA",un=T(Jt)(),cn=T(Zt)(),ln=T(Xt)(),dn=T(en)(),fn=T(nn)(),gn=T(tn)(),hn=T(rn)(),mn=T(sn)(),vn=T(on)(),pn=T(an)(),le={importEntities:un,modifyEntityField:cn,reorderEntityField:ln,addReference:dn,removeReference:fn,updateReference:gn,addMetadata:hn,removeMetadata:vn,updateMetadata:mn,reorderMetadata:pn};function Be(){const t=M().getStore();return u.useMemo(()=>n=>t.dispatch(n),[t])}function Re(e){return typeof e!="string"&&e&&e.bindToVault}function He(){const e=M(),t=u.useRef([]),n=Be(),r=u.useMemo(()=>`vault://annotation-page/${new Date().getTime()}/${Math.round(Math.random()*1e9).toString(16)}`,[]);u.useLayoutEffect(()=>{const a={id:r,type:"AnnotationPage",behavior:[],label:null,thumbnail:[],summary:null,requiredStatement:null,metadata:[],rights:null,provider:[],items:[],seeAlso:[],homepage:[],rendering:[],service:[]};n(le.importEntities({entities:{AnnotationPage:{[a.id]:a}}}))},[r]);const o=E(a=>r?a.iiif.entities.AnnotationPage[r]:null,[r]),i=u.useCallback((a,l)=>{if(r){if(Re(a)){const g=a;g.__vault||g.bindToVault(e),a=typeof g.source=="string"?g.source:g.source.id,t.current[a]=g}else typeof a!="string"&&(a=a.id);const f=e.get({id:r,type:"AnnotationPage"}),d=e.get({id:a,type:"Annotation"});f&&d&&(f.items.find(g=>g.id===d.id)||n(le.addReference({id:r,type:"AnnotationPage",key:"items",reference:{id:a,type:"Annotation"},index:l})))}},[r]),s=u.useCallback(a=>{r&&(Re(a)?a=typeof a.source=="string"?a.source:a.source.id:typeof a!="string"&&(a=a.id),t.current[a]&&t.current[a].beforeRemove(),e.get({id:r,type:"AnnotationPage"})&&n(le.removeReference({id:r,type:"AnnotationPage",key:"items",reference:{id:a,type:"Annotation"}})))},[r]);return[o,{addAnnotation:i,removeAnnotation:s}]}const $e=u.createContext(null);function Ye(){const e=u.useContext($e);return[e.fullPage,{addAnnotation:e.addAnnotation,removeAnnotation:e.removeAnnotation}]}function ze({children:e}){const[t,{addAnnotation:n,removeAnnotation:r}]=He();return c.jsx($e.Provider,{value:u.useMemo(()=>({fullPage:t,addAnnotation:n,removeAnnotation:r}),[t]),children:e})}function yn({width:e,style:t,height:n,error:r,resetErrorBoundary:o}){return c.jsxs("div",{style:{width:e,height:n,minHeight:500,...t||{},background:"#f9f9f9"},children:[c.jsx("h3",{children:"Error occurred"}),c.jsx("p",{children:r.message}),c.jsx("button",{onClick:o,children:"Reset"})]})}const oe=u.createContext(null);function Ke(){return u.useContext(oe)}const We=u.createContext(()=>{}),Ge=u.createContext(()=>{});function U(e,t,n,r,o=[]){const i=u.useContext(e==="portal"?Ge:We);u.useEffect(()=>(e!=="none"&&i(t,n,r),()=>{i(t,null)}),[t,e,i,...o])}function V(e={},t=[]){const{id:n,selector:r}=e,o=O(),i=n||o.canvas,s=E(a=>i?a.iiif.entities.Canvas[i]:void 0,[i]);return u.useMemo(()=>{if(s)return r?r(s):s},[s,r,...t])}const Qe=u.createContext(()=>{});function xn(e){const t=V(),n=u.useContext(Qe);u.useEffect(()=>t&&t.id?(n(t.id,e),()=>n(t.id,-1)):()=>{},[t,e])}function Sn({children:e,errorFallback:t,outerContainerProps:n={},worldScale:r,...o}){const[i,s]=u.useState(),a=_e(),l=t||yn,[f,d]=u.useState({}),g=Object.entries(f),[p,y]=u.useState({}),m=Object.entries(p),[h,x]=u.useState({}),C=u.useMemo(()=>r||Math.max(...Object.values(h)),[h]),j=u.useMemo(()=>({maxOverZoom:C||1,...o.runtimeOptions||{}}),[C,o.runtimeOptions]),S=u.useCallback((w,I)=>{x(A=>{if(I===-1){const{[w]:v,...k}=A;return k}return{...A,[w]:I}})},[]),L=u.useCallback((w,I,A)=>{d(({[w]:v,...k})=>I?{...k,[w]:{element:I,props:A}}:k)},[]),Q=u.useCallback((w,I,A)=>{y(({[w]:v,...k})=>I?{...k,[w]:{element:I,props:A}}:k)},[]);return c.jsxs(Kt,{resetKeys:[],fallbackRender:w=>c.jsx(l,{...o,...w}),children:[c.jsx(_.AtlasAuto,{...o,containerProps:{style:{position:"relative"},...o.containerProps||{}},htmlChildren:c.jsx(c.Fragment,{children:g.map(([w,{element:I,props:A}])=>c.jsx(u.Fragment,{children:c.jsx(I,{...A||{}})},w))}),onCreated:w=>{s(w),o.onCreated&&o.onCreated(w)},runtimeOptions:j,children:c.jsx(oe.Provider,{value:i,children:c.jsx(Qe.Provider,{value:S,children:c.jsx(We.Provider,{value:L,children:c.jsx(Ge.Provider,{value:Q,children:c.jsx(Ue,{bridge:a,children:c.jsx(_.ModeContext.Provider,{value:o.mode||"explore",children:c.jsx(ze,{children:e})})})})})})})}),c.jsx("div",{children:m.map(([w,{element:I,props:A}])=>c.jsx(u.Fragment,{children:c.jsx(I,{...A||{}})},w))})]})}const J={},Je={get(e){return e},setMetaValue([e,t,n],r){const o=Je.getResourceMeta(e,t),i=o?o[n]:void 0,s=typeof r=="function"?r(i):r;J[e]={...J[e]||{},[t]:{...(J[e]||{})[t]||{},[n]:s}}},getResourceMeta:(e,t)=>{const n=J[e];if(n)return t?n[t]:n}};function Ze(e=Je){return{addEventListener(t,n,r,o){if(t)return e.setMetaValue([t.id,"eventManager",n],i=>{const s=i||[];for(const a of s)if(a.callback===r)return s;return[...s,{callback:r,scope:o}]}),r},removeEventListener(t,n,r){t&&e.setMetaValue([t.id,"eventManager",n],o=>(o||[]).filter(i=>i.callback!==r))},getListenersAsProps(t,n){const r=typeof t=="string"?{id:t}:t;if(!r||!r.id)return{};const o=e.getResourceMeta(r.id,"eventManager"),i={};if(o&&r)for(const s of Object.keys(o))i[s]=a=>{const l=e.get(r);for(const{callback:f,scope:d}of o[s]||[])(!d||n&&d.indexOf(n)!==-1)&&f(a,l)};return i}}}function Se(e,t){const n=M(),r=u.useMemo(()=>Ze(n),[n]),o=E(()=>e&&e.id?n.getResourceMeta(e.id,"eventManager"):null,[e]);return u.useMemo(()=>e?r.getListenersAsProps(e,t):{},[o,e,n,t])}function z(e,t){const n=M(),r=u.useMemo(()=>ge.createStylesHelper(n),[n]);return E(()=>{if(!e)return null;const o=r.getAppliedStyles(e.id);return o?t?o[t]:o:void 0},[e,t])}function Ce(e={},t=[]){const{id:n,selector:r}=e,o=O(),i=M(),s=n||o.annotation,a=E(f=>s?f.iiif.entities.Annotation[s]:void 0,[s]),l=E(f=>a&&a.body?a.body.map(d=>d?d.type==="SpecificResource"?{...d,source:i.get(d)}:d?f.iiif.entities[d.type][d.id]:null:null).filter(Boolean):[],[a]);return u.useMemo(()=>{if(!a)return;const f={...a,body:l,target:Y.expandTarget(a.target,{typeMap:i.getState().iiif.mapping})};return r?r(f):f},[a,r,l,...t])}const Xe=({id:e,style:t,className:n,interactive:r})=>{const o=Ce({id:e}),i=z(o,"atlas"),s=z(o,"html"),a=Se(o,["atlas"]),l=V(),f=u.useMemo(()=>_.mergeStyles(t,i),[t,i]);return l&&o&&o.target&&o.target.selector&&o.target.selector.type==="BoxSelector"&&o.target.source&&(o.target.source.id===l.id||o.target.source===l.id)?c.jsx(_.RegionHighlight,{id:o.id,isEditing:!0,region:o.target.selector.spatial,style:f,className:(s==null?void 0:s.className)||n,interactive:!!(s!=null&&s.href||r),href:(s==null?void 0:s.href)||null,title:(s==null?void 0:s.title)||null,hrefTarget:(s==null?void 0:s.target)||null,onClick:()=>{},...a}):null};function et(e={},t=[]){const{id:n,selector:r}=e,o=O(),i=n||o.annotationPage,s=E(a=>i?a.iiif.entities.AnnotationPage[i]:void 0,[i]);return u.useMemo(()=>{if(s)return r?r(s):s},[s,...t])}const fe=({className:e,page:t})=>{var i;const n=et({id:t.id})||t,r=z(n,"atlas"),o=z(n,"html");return E(s=>n.id?s.iiif.entities.AnnotationPage[n.id]:null,[]),c.jsx(u.Fragment,{children:(i=n.items)==null?void 0:i.map(s=>c.jsx(Xe,{id:s.id,style:r,className:(o==null?void 0:o.className)||e},s.id))})};function tt({id:e,image:t,thumbnail:n,isStatic:r,x:o=0,y:i=0,children:s,selector:a,onClick:l,enableSizes:f}){var g,p;const d=u.useMemo(()=>{if(!(!a||a.spatial.x===0&&a.spatial.y===0))return a.spatial},[a]);return c.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:l,children:t.service?c.jsxs(u.Fragment,{children:[c.jsx(_.TileSet,{tiles:{id:t.service.id||t.service["@id"]||"unknown",height:t.height,width:t.width,imageService:t.service,thumbnail:n&&n.type==="fixed"?n:void 0},enableSizes:f,x:0,y:0,width:(g=t.target)==null?void 0:g.spatial.width,height:(p=t.target)==null?void 0:p.spatial.height,crop:d}),s]},"service"):c.jsxs(u.Fragment,{children:[c.jsx("world-image",{onClick:l,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:d}),s]},"no-service")},e+(t.service?"server":"no-service"))}function Cn(e){return e.type==="SpecificResource"?[e.source,{selector:e.selector}]:[e,{selector:null}]}function be(e,t){const{selector:n,source:r}=Bt.expandTarget(t);if(r.id!==e.id)return[null,r];const 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]}const nt={makeChoice:()=>{}},ee={type:"unknown"},P=e=>({type:"unknown",reason:e,annotations:{pages:[]}}),rt=(e,t)=>({type:"empty",width:e,height:t,annotations:{pages:[]},image:null,images:[]});function bn(e,t){var r;const n=(r=e==null?void 0:e.iiif)==null?void 0:r.meta[t];return n?n.annotationPageManager:null}function wn(e,t){return E(n=>{const r=[];if(!e)return r;const o=Object.keys(n.iiif.entities.AnnotationPage);for(const i of o)if(!t||t.indexOf(i)!==-1){const s=bn(n,i);s&&s.views&&s.views[e]&&r.push(i)}return r},[e,t])}function ot({canvas:e,manifest:t,all:n,canvases:r}){const o=[];if(t)for(const i of t.annotations)o.indexOf(i.id)===-1&&o.push(i.id);if(n){if(r&&r.length)for(const i of r)for(const s of i.annotations)o.indexOf(s.id)===-1&&o.push(s.id)}else if(e)for(const i of e.annotations)o.indexOf(i.id)===-1&&o.push(i.id);return o}function Pn(e,t){var r;const n=(r=e==null?void 0:e.iiif)==null?void 0:r.meta[t];return n?n.annotationPageManager:null}function it(e,t={}){const n=M(),r=D(),o=V(),i=ve(),s=u.useMemo(()=>ot({all:t.all,manifest:r,canvas:o,canvases:i}),[t.all,o,i,r]),a=wn(e,t.all?void 0:s),l=u.useCallback(d=>{e&&n.setMetaValue([d,"annotationPageManager","views"],g=>g&&!g[e]?g:{...g||{},[e]:!1})},[e,n]),f=u.useCallback((d,g={})=>{if(!e)return;const p=n.getState(),y=[];if(g!=null&&g.deselectOthers){const m=Object.keys(p.iiif.entities.AnnotationPage);for(const h of m){const x=Pn(p,h);x&&x.views&&x.views[e]&&y.push(h)}}for(const m of y)l(m);n.setMetaValue([d,"annotationPageManager","views"],m=>m&&m[e]?m:{...m||{},[e]:!0})},[e,l,n]);return{availablePageIds:s,enabledPageIds:a,setPageEnabled:f,setPageDisabled:l}}function st(e,t){return E((n,r)=>r.get(e.map(o=>({id:o,type:t}))),[e,t])}const at=u.createContext(new te.ImageServiceLoader);function ie(){return u.useContext(at)}function ut(){const e=ie(),[t,n]=u.useState({}),r=u.useRef(!1);return u.useEffect(()=>()=>{r.current=!0},[]),[u.useCallback((i,{height:s,width:a})=>{if(i){const l=i.id||i["@id"],f=e.loadServiceSync({id:l,width:i.width||a,height:i.height||s,source:i});f?i=f:t[l]||(r.current||n(d=>({...d,[l]:"loading"})),e.loadService({id:l,width:i.width||a,height:i.height||s}).then(()=>{r.current||n(d=>({...d,[l]:"done"}))}))}return i},[e,t]),t]}function se(e={}){const t=Ce(),n=V(e.canvasId?{id:e.canvasId}:void 0);return E((r,o)=>{if(!n)return[];if(t&&e.enableSingleAnnotation)return[t];const i=o.get(n.items),s=[];for(const a of i)s.push(...o.get(a.items));return s},[n])}function Mn(e){return e.type==="SpecificResource"?[e.source,{selector:e.selector}]:[e,{selector:null}]}const Z={},ct={get(e){return e},setMetaValue([e,t,n],r){const o=ct.getResourceMeta(e,t),i=o?o[n]:void 0,s=typeof r=="function"?r(i):r;Z[e]={...Z[e]||{},[t]:{...(Z[e]||{})[t]||{},[n]:s}}},getResourceMeta:(e,t)=>{const n=Z[e];if(n)return t?n[t]:n}};function jn(e=ct){function t(o){const i=o?typeof o=="string"?e.get(o):o:null;if(!i)return[];const s=e.get(i.items,{parent:i}),a=[];for(const l of s)a.push(...e.get(l.items,{parent:l}));return a}function n(o,i=[]){const s=Array.isArray(o)?o:t(o),a=[];let l=null;const f=[];for(const d of s){if(d.type!=="Annotation")throw new Error("getPaintables() accept either a canvas or list of annotations");const g=Array.from(Array.isArray(d.body)?d.body:[d.body]);for(const p of g){const[y,{selector:m}]=Mn(p),h=e.get(y),x=(h.type||"unknown").toLowerCase();if(x==="choice"){const C=e.get(h.items,{parent:h.id}),j=i.length?i.map(S=>C.find(L=>L.id===S)).filter(Boolean):[C[0]];j.length===0&&j.push(C[0]),l={type:"single-choice",items:C.map(S=>({id:S.id,label:S.label,selected:j.indexOf(S)!==-1})),label:y.label},g.push(...j);continue}a.indexOf(x)===-1&&a.push(x),f.push({type:x,annotationId:d.id,resource:h,target:d.target,selector:m})}}return{types:a,items:f,choice:l}}function r(o){const{choice:i}=n(o);return i}return{getAllPaintingAnnotations:t,getPaintables:n,extractChoices:r}}function lt(e,t=[]){const n=M(),r=u.useMemo(()=>jn(n),[]),o=se({enableSingleAnnotation:e==null?void 0:e.enableSingleAnnotation}),[i,s]=u.useState((e==null?void 0:e.defaultChoices)||[]),a=u.useMemo(()=>r.getPaintables(o,i),[n,o,i,...t]),f={makeChoice:u.useCallback((d,{deselectOthers:g=!0,deselect:p=!1}={})=>{if(a.choice){if(a.choice.type!=="single-choice")throw new Error("Complex choice not supported yet");s(y=>{if(p){const h=y.filter(x=>x!==d);if(h.length===0){const x=a.items[0].resource.id;return x?[x]:[]}return h}if(g)return[d];const m=[...y];if(m.length===0&&a.items.length){const h=a.items[0].resource.id;h&&m.push(h)}return y.indexOf(d)!==-1?y:[...y,d]})}},[a.choice])};return[a,f]}const En=["model/gltf-binary"];function dt(e,t){const r=t.items[0].resource;return r.format?En.indexOf(r.format)===-1?P(`3D format: ${r.format} is unsupported`):{type:"3d-model",model:r}:P("Unknown format")}function In(e,t){var r;if(!e.duration)return P("No duration on canvas");if(t.items.length>1)return P("Only one audio source supported");const n=(r=t.items[0])==null?void 0:r.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:[]}}:P("Audio does not have format"):P("Unknown audio")}function ft(e,t,n){const r=[];for(const o of t.items){const i=o.resource&&o.resource.type==="SpecificResource"?o.resource.source:o.resource;if(!i.id)return P("No resource Identifier");let s;if(i.service){const y=te.getImageServices(i);y[0]&&(s=n(y[0],e))}const a={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}},[l,f]=be(e,o.target);if(f.id!==e.id)continue;o.resource.width&&o.resource.height&&(o.resource.width,o.resource.height);let d=o.resource.type==="SpecificResource"?Y.expandTarget(o.resource):null;if(o.selector){const y=Y.expandTarget({type:"SpecificResource",source:o.resource,selector:o.selector});y&&(d=y)}const 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;s&&!s.id&&(s.id=s["@id"]);const p={id:i.id,type:"Image",annotationId:o.annotationId,width:Number(l||g?i.width:e.width),height:Number(l||g?i.height:e.height),service:s,sizes:s&&s.sizes?s.sizes:i.width&&i.height?[{width:i.width,height:i.height}]:[],target:l&&l.type!=="PointSelector"?l:a,selector:g};r.push(p)}return{type:"images",image:r[0],images:r,choice:t.choice}}function gt(e,t={},n){const 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=>gt(o,t,r))}return t}function ht(e,t){const n=[];return t.items.forEach(r=>{if(r.resource){const[o]=be(e,r.target);n.push({annotationId:r.annotationId,text:gt(r.resource),target:o})}}),{type:"textual-content",items:n}}const Rn=/^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\/)|(?:(?:watch)?\?vi?=|&vi?=))([^#&?]*).*/;function mt(e,t){var a;const n=t.items.filter(l=>l.type==="video");let r=!1;if(e.duration||(r=!0),n.length>1)return P("Only one video source supported");const o=(a=n[0])==null?void 0:a.resource,i=!!(o.service||[]).find(l=>(l.profile||"").includes("youtube.com"));if(!i&&r)return P("Video does not have duration");if(!o)return P("Unknown video");if((!o.format||o.format==="text/html")&&!i)return P("Video does not have format");const s={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){s.type="VideoYouTube";const l=o.id.match(Rn);if(!l[1])return P("Video is not known youtube video");s.youTubeId=l[1]}return{type:"media",media:s,annotations:{pages:[]}}}function vt({canvas:e,paintables:t,supports:n,loadImageService:r}){if(!e)return console.log("No canvas"),ee;if(t.types.length===0)return n.indexOf("empty")!==-1?rt(e.width,e.height):(console.log("No paintables"),ee);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?P("Complex timeline not supported"):P("ComplexTimelineStrategy not yet supported");const o=t.types[0];return o==="image"?n.indexOf("images")===-1?P("Image not supported"):ft(e,t,r):o==="Model"||o==="model"?n.indexOf("3d-model")===-1?P("3D not supported"):dt(e,t):o==="textualbody"?n.indexOf("textual-content")===-1?P("Textual content not supported"):ht(e,t):o==="sound"||o==="audio"?n.indexOf("media")===-1?P("Media not supported"):In(e,t):o==="video"?n.indexOf("media")===-1?P("Media not supported"):mt(e,t):ee}function pt(e){const t=D(),n=V(),r=M(),[o,i]=ut(),{enabledPageIds:s}=it((e==null?void 0:e.annotationPageManagerId)||(t==null?void 0:t.id)||(n==null?void 0:n.id),{all:!1}),a=st(s,"AnnotationPage"),l=(e==null?void 0:e.strategies)||["empty","images","media","textual-content","complex-timeline"],[f,d]=lt(e,[i]),g=u.useMemo(()=>vt({canvas:n,paintables:f,supports:l,loadImageService:o}),[n,f,r,d.makeChoice]);return u.useMemo(()=>g.type==="unknown"?[g,nt]:[{...g,annotations:{pages:a}},d],[g,a])}const yt=(e,t=[])=>{const n=M();u.useEffect(()=>{e(n)},[n,...t])};function xt(e,t,{canvasId:n,manifestId:r}={}){const o=M(),i=ie(),s=u.useMemo(()=>Ht.createThumbnailHelper(o,{imageServiceLoader:i}),[o,i]),[a,l]=u.useState(),f=D(r?{id:r}:void 0),d=V(n?{id:n}:void 0),g=d||f,p=u.useRef(!1);if(u.useEffect(()=>(p.current=!1,()=>{p.current=!0}),[]),!g)throw new Error("Must be called under a manifest or canvas context.");return yt(y=>{s.getBestThumbnailAtSize(g,e,t).then(m=>{m.best&&!p.current&&l(m.best)})},[g]),a}function An(e){return{isMuted:!1,playRequested:!1,isPlaying:!1,isFinished:!1,volume:100,duration:e}}function Tn(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 St(e){const t=Math.round(e);return`${Math.floor(t/60)}:${`${t%60}`.padStart(2,"0")}`}function ae(e){const[t,n]=u.useReducer(Tn,An(e.duration)),r=u.useRef(null),o=u.useRef(null),i=u.useRef(null),s=u.useRef(!1),a=u.useCallback(()=>{o.current&&r.current&&(o.current.innerHTML=St(r.current.currentTime),i.current&&(i.current.style.width=`${r.current.currentTime/e.duration*100}%`),s.current!==r.current.muted&&(s.current=r.current.muted,n(r.current.muted?{type:"MUTE"}:{type:"UNMUTE"})))},[e.duration]),l=u.useCallback(()=>{r.current&&(n({type:"PLAY_REQUESTED"}),r.current.play().then(()=>{n({type:"PLAY"})}),a())},[a]),f=u.useCallback(()=>{r.current&&(r.current.duration>0&&r.current.paused?l():d())},[a]),d=u.useCallback(()=>{r.current&&(r.current.pause(),n({type:"PAUSE"}),a())},[a]),g=u.useCallback(()=>{r.current&&(r.current.muted=!r.current.muted,n(r.current.muted?{type:"MUTE"}:{type:"UNMUTE"}))},[]),p=u.useCallback(()=>{r.current&&(r.current.muted=!0,n({type:"MUTE"}))},[]),y=u.useCallback(()=>{r.current&&(r.current.muted=!1,n({type:"UNMUTE"}))},[]),m=u.useCallback(C=>{r.current&&(r.current.muted=!1,r.current.volume=C/100,n({type:"SET_VOLUME",volume:C}))},[]),h=u.useCallback(C=>{r.current&&(r.current.currentTime=Math.max(0,Math.min(C*e.duration,e.duration)),a())},[]),x=u.useCallback(C=>{r.current&&(r.current.currentTime=Math.max(0,Math.min(C,e.duration)),a())},[]);return u.useEffect(()=>{const C=setInterval(()=>{a()},350);return()=>clearInterval(C)},[a,e.duration]),u.useEffect(()=>{const C=()=>{n({type:"FINISHED"})},j=r.current;return j==null||j.addEventListener("ended",C),()=>j==null?void 0:j.removeEventListener("ended",C)},[]),[{element:r,currentTime:o,progress:i},t,{play:l,pause:d,playPause:f,mute:p,unmute:y,toggleMute:g,setVolume:m,setDurationPercent:h,setTime:x}]}const Ct=u.createContext(null),bt=u.createContext(null),wt=u.createContext(null);function Vn(){const e=u.useContext(Ct);if(!e)throw new Error("Ctx not found");return e}function Ln(){const e=u.useContext(bt);if(!e)throw new Error("Ctx not found");return e}function kn(){const e=u.useContext(wt);if(!e)throw new Error("Ctx not found");return e}function we({actions:e,state:t,children:n,currentTime:r,progress:o,element:i}){return c.jsx(wt.Provider,{value:{currentTime:r,progress:o,element:i},children:c.jsx(bt.Provider,{value:e,children:c.jsx(Ct.Provider,{value:t,children:n})})})}function Pt({media:e,children:t}){const[{element:n,currentTime:r,progress:o},i,s]=ae({duration:e.duration});return c.jsxs(we,{state:i,actions:s,currentTime:r,progress:o,element:n,children:[c.jsx("audio",{ref:n,src:e.url}),t]})}function Mt({media:e,mediaControlsDeps:t,children:n}){return U("portal","audio",Pt,{media:e,children:n},[e,...t||[]]),null}function jt({element:e,media:t,playPause:n}){return c.jsxs("div",{className:"video-container",part:"video-container",onClick:n,children:[c.jsx("style",{children:`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),c=require("react"),Oe=require("@atlas-viewer/atlas"),Ye=require("@iiif/helpers/vault"),ot=require("@iiif/helpers/styles"),Le=require("@iiif/helpers/annotation-targets"),Un=require("@iiif/helpers"),Ee=require("@atlas-viewer/iiif-image-api"),$n=require("@iiif/helpers/thumbnail"),Hn=require("react-dom"),Wn=c.createContext(null),tt={didCatch:!1,error:null};class Yn extends c.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=tt}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(){const{error:t}=this.state;if(t!==null){for(var n,o,r=arguments.length,s=new Array(r),i=0;i<r;i++)s[i]=arguments[i];(n=(o=this.props).onReset)===null||n===void 0||n.call(o,{args:s,reason:"imperative-api"}),this.setState(tt)}}componentDidCatch(t,n){var o,r;(o=(r=this.props).onError)===null||o===void 0||o.call(r,t,n)}componentDidUpdate(t,n){const{didCatch:o}=this.state,{resetKeys:r}=this.props;if(o&&n.error!==null&&zn(t.resetKeys,r)){var s,i;(s=(i=this.props).onReset)===null||s===void 0||s.call(i,{next:r,prev:t.resetKeys,reason:"keys"}),this.setState(tt)}}render(){const{children:t,fallbackRender:n,FallbackComponent:o,fallback:r}=this.props,{didCatch:s,error:i}=this.state;let a=t;if(s){const p={error:i,resetErrorBoundary:this.resetErrorBoundary};if(typeof n=="function")a=n(p);else if(o)a=c.createElement(o,p);else if(r===null||c.isValidElement(r))a=r;else throw i}return c.createElement(Wn.Provider,{value:{didCatch:s,error:i,resetErrorBoundary:this.resetErrorBoundary}},a)}}function zn(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return e.length!==t.length||e.some((n,o)=>!Object.is(n,t[o]))}const Kn={collection:void 0,manifest:void 0,range:void 0,canvas:void 0,annotation:void 0,annotationPage:void 0},Ke=c.createContext(Kn),xe=()=>c.useContext(Ke);function we({value:e,children:t}){const n=xe(),o=c.useMemo(()=>({...n,...e}),[e,n]);return u.jsx(Ke.Provider,{value:o,children:t})}const ke=c.createContext({vault:null,setVaultInstance:e=>{}});function it({vault:e,vaultOptions:t,useGlobal:n,resources:o,children:r}){const[s,i]=c.useState(()=>e||(n?Ye.globalVault(t):t?new Ye.Vault(t):new Ye.Vault));return u.jsx(ke.Provider,{value:{vault:s,setVaultInstance:i},children:u.jsx(we,{value:o||{},children:r})})}const J=()=>{const{vault:e}=c.useContext(ke);if(e===null)throw new Error("Vault not found. Ensure you have your provider set up correctly.");return e};function st(e,{noCache:t=!1}={}){const n=typeof e=="string"?e:e.id,o=J(),[r,s]=c.useState(n),[i,a]=c.useState(void 0),p=c.useMemo(()=>o.get(n,{skipSelfReturn:!0})||void 0,[n,o]),[y,f]=c.useState(p);return c.useEffect(()=>{(async()=>{try{const g=p&&!t?p:await o.load(n),O=g?g.id||g["@id"]:null;g&&r!==O&&s(O),f(g)}catch(g){a(g)}})()},[n,t]),{isLoaded:!!y,id:r,requestId:n,error:i,resource:y,cached:!!(y&&y===p)}}function It(e,t){const{id:n,isLoaded:o,error:r,resource:s,requestId:i,cached:a}=st(e,t);return{id:n,isLoaded:o,error:r,manifest:s,requestId:i,cached:a}}function Mt({manifest:e,children:t}){return u.jsx(we,{value:{manifest:e},children:t})}function Ve({canvas:e,children:t}){return u.jsx(we,{value:{canvas:e},children:t})}function se(e,t=[]){const n=J(),[o,r]=c.useState(()=>e(n.getState(),n));return c.useEffect(()=>n.subscribe(s=>e(s,n),s=>{r(s)},!1),t),o}const Ne=c.createContext([]);function at(){const e=c.useContext(Ne);return se(t=>e.map(n=>t.iiif.entities.Canvas[n]).filter(Boolean),[e])}function ve(e={},t=[]){const{id:n,selector:o}=e,r=xe();J();const s=n||r.manifest,i=se(a=>s?a.iiif.entities.Manifest[s]:void 0,[s]);return c.useMemo(()=>{if(i)return o?o(i):i},[i,o,...t])}function Rt({range:e,children:t}){return u.jsx(we,{value:{range:e},children:t})}function Lt(e,t){for(const n of t.items){if(n.type==="Canvas")return n;if(n.type==="SpecificResource")return n.source;if(n.type==="Range"){const o=Lt(e,e.get(n));if(o)return o}}return null}function ut(e,t){var o;const n=[];for(const r of t.items)if(r.type==="SpecificResource"&&((o=r.source)==null?void 0:o.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(...ut(e,e.get(r))),r.type==="SpecificResource"){const s=typeof r.source=="string"?r.source:r.source.id;n.push({id:s,type:"Canvas"})}return n}function Qn(e,t,n){for(const o of t.structures){const r=ct(e,e.get(o),n);if(r)return r}return null}function ct(e,t,n){var o,r,s;for(const i of t.items){const a=(r=(o=i==null?void 0:i.source)==null?void 0:o.id)==null?void 0:r.split("#")[0];if(i.type==="SpecificResource"&&i.source===n||i.type==="SpecificResource"&&((s=i.source)==null?void 0:s.type)==="Canvas"&&n===a)return t;if(i.type==="Range"){const p=ct(e,e.get(i),n);if(p)return p}}return null}function Gn(e,t,n,o=!1){const r=t.behavior,s=n?e.get(n):null;if(!s)return[];const i=s.behavior,a=o?!1:r.includes("paged"),p=a?!1:r.includes("continuous"),y=a||p?!1:r.includes("individuals"),f=i.includes("facing-pages"),g=i.includes("non-paged");if(f||g||y||o)return[{id:s.id,type:"Canvas"}];const[O,R]=lt(e,t);if(p)return O;const E=O.findIndex(x=>x.id===n);if(E===-1)return[];for(const x of R)if(x.includes(E))return x.map(T=>O[T]);return[{id:s.id,type:"Canvas"}]}function lt(e,t,{disablePaging:n,skipNonPaged:o}={}){const r=t.behavior,s=r.includes("paged"),i=s?!1:r.includes("continuous"),a=s||i?!1:r.includes("individuals"),p=t.type==="Manifest"?t.items:ut(e,t);if(i)return[p,[p.map((E,x)=>x)]];if(a||!s||n)return[p,p.map((E,x)=>[x])];const y=[];let f=[];const g=()=>{f.length&&(y.push([...f]),f=[])};let O=0,R=!1;for(let E=0;E<p.length;E++){const x=e.get(p[E]);if(x.behavior.includes("non-paged")){E===O&&O++,o||(g(),y.push([E]),g());continue}if(E===O||x.behavior.includes("facing-pages")){f.length&&(R=!0),g(),y.push([E]),g();continue}if(f.push(E),R){g(),R=!1;continue}f.length>1&&g()}return f.length&&g(),[p,y]}function ft(e={},t=[]){const{id:n,selector:o}=e,r=xe(),s=n||r.range,i=se(a=>s?a.iiif.entities.Range[s]:void 0,[s]);return c.useMemo(()=>{if(i)return o?o(i):i},[i,o,...t])}function At({startCanvas:e,disablePaging:t}){var E;const n=J(),o=ve(),r=ft(),[s,i]=c.useState(void 0),a=r||o;if(!a)throw new Error("Nothing selected");const[p,y]=c.useMemo(()=>lt(n,a,{disablePaging:t}),[n,a]),f=c.useCallback(x=>{const T=y.findIndex(I=>I.includes(x));i(T===-1?0:T)},[p,y]),g=c.useCallback(x=>{const T=p.findIndex(I=>I.id===x);T!==-1?f(T):i(0)},[p,y]),O=c.useCallback(()=>{i(x=>x>=y.length-1?x:x+1)},[y]),R=c.useCallback(()=>{i(x=>x<=0?0:x-1)},[y]);return typeof s>"u"&&(e?g(e):i(0)),{visibleItems:((E=y[s])==null?void 0:E.map(x=>p[x].id))||[],cursor:s,items:p,sequence:y,hasPrevious:s>0,hasNext:s<y.length-1,setSequenceIndex:i,setCanvasIndex:f,setCanvasId:g,next:O,previous:R}}const Re=()=>{},_e=c.createContext({setCurrentCanvasId:Re,setCurrentCanvasIndex:Re,nextCanvas:Re,previousCanvas:Re,items:[],sequence:[],setSequenceIndex:Re,currentSequenceIndex:0,hasNext:!1,hasPrevious:!1});function kt(e){const t=ve(),{cursor:n,visibleItems:o,next:r,sequence:s,items:i,setCanvasIndex:a,setCanvasId:p,previous:y,setSequenceIndex:f,hasNext:g,hasPrevious:O}=At({startCanvas:e.startCanvas,disablePaging:e.pagingEnabled===!1}),R=c.useMemo(()=>({sequence:s,items:i,setCurrentCanvasId:p,nextCanvas:r,previousCanvas:y,totalCanvases:i.length,setCurrentCanvasIndex:a,setSequenceIndex:f,currentSequenceIndex:n,hasNext:g,hasPrevious:O}),[s,i,p,r,y,i,a,f,n]);return t?o.length===0?null:u.jsx(_e.Provider,{value:R,children:u.jsx(Ne.Provider,{value:o,children:u.jsx(Ve,{canvas:o[0],children:e.children})})}):(console.warn("The manifest passed to the provider is not a valid IIIF manifest."),u.jsx("div",{children:"Sorry, something went wrong."}))}function Vt(e){const t=It(e.manifest);if(!t)return console.warn("The manifest passed to the provider is not a valid IIIF manifest."),u.jsx("div",{children:"Sorry, something went wrong."});if(t.error)return u.jsx("div",{children:t.error.toString()});if(!t.isLoaded)return u.jsx("div",{children:"Loading..."});const n=u.jsx(kt,{...e,children:e.children});return u.jsx(Mt,{manifest:t.id,children:e.rangeId?u.jsx(Rt,{range:e.rangeId,children:n}):n})}function dt(){return c.useContext(_e)}function Nt(){return{VaultContext:c.useContext(ke),ResourceContext:c.useContext(Ke),SimpleViewerReactContext:c.useContext(_e),VisibleCanvasReactContext:c.useContext(Ne)}}function _t(e){return u.jsx(it,{vault:e.bridge.VaultContext.vault||void 0,resources:e.bridge.ResourceContext,children:u.jsx(Ne.Provider,{value:e.bridge.VisibleCanvasReactContext,children:u.jsx(_e.Provider,{value:e.bridge.SimpleViewerReactContext,children:e.children})})})}const be=function(e){return function(){const t={type:e,getType:()=>e,toString:()=>e};return(n,o)=>({...t,...n!==void 0&&{payload:n},...o!==void 0&&{meta:o}})}},Xn="@iiif/IMPORT_ENTITIES",Jn="@iiif/MODIFY_ENTITY_FIELD",Zn="@iiif/REORDER_ENTITY_FIELD",er="@iiif/ADD_REFERENCE",tr="@iiif/UPDATE_REFERENCE",nr="@iiif/REMOVE_REFERENCE",rr="@iiif/ADD_METADATA",or="@iiif/REMOVE_METADATA",ir="@iiif/UPDATE_METADATA",sr="@iiif/REORDER_METADATA",ar=be(Xn)(),ur=be(Jn)(),cr=be(Zn)(),lr=be(er)(),fr=be(nr)(),dr=be(tr)(),pr=be(rr)(),hr=be(ir)(),yr=be(or)(),gr=be(sr)(),nt={importEntities:ar,modifyEntityField:ur,reorderEntityField:cr,addReference:lr,removeReference:fr,updateReference:dr,addMetadata:pr,removeMetadata:yr,updateMetadata:hr,reorderMetadata:gr};function Dt(){const t=J().getStore();return c.useMemo(()=>n=>t.dispatch(n),[t])}function Tt(e){return typeof e!="string"&&e&&e.bindToVault}function qt(){const e=J(),t=c.useRef([]),n=Dt(),o=c.useMemo(()=>`vault://annotation-page/${new Date().getTime()}/${Math.round(Math.random()*1e9).toString(16)}`,[]);c.useLayoutEffect(()=>{const a={id:o,type:"AnnotationPage",behavior:[],label:null,thumbnail:[],summary:null,requiredStatement:null,metadata:[],rights:null,provider:[],items:[],seeAlso:[],homepage:[],rendering:[],service:[]};n(nt.importEntities({entities:{AnnotationPage:{[a.id]:a}}}))},[o]);const r=se(a=>o?a.iiif.entities.AnnotationPage[o]:null,[o]),s=c.useCallback((a,p)=>{if(o){if(Tt(a)){const g=a;g.__vault||g.bindToVault(e),a=typeof g.source=="string"?g.source:g.source.id,t.current[a]=g}else typeof a!="string"&&(a=a.id);const y=e.get({id:o,type:"AnnotationPage"}),f=e.get({id:a,type:"Annotation"});y&&f&&(y.items.find(g=>g.id===f.id)||n(nt.addReference({id:o,type:"AnnotationPage",key:"items",reference:{id:a,type:"Annotation"},index:p})))}},[o]),i=c.useCallback(a=>{o&&(Tt(a)?a=typeof a.source=="string"?a.source:a.source.id:typeof a!="string"&&(a=a.id),t.current[a]&&t.current[a].beforeRemove(),e.get({id:o,type:"AnnotationPage"})&&n(nt.removeReference({id:o,type:"AnnotationPage",key:"items",reference:{id:a,type:"Annotation"}})))},[o]);return[r,{addAnnotation:s,removeAnnotation:i}]}const Ft=c.createContext(null);function Bt(){const e=c.useContext(Ft);return[e.fullPage,{addAnnotation:e.addAnnotation,removeAnnotation:e.removeAnnotation}]}function Ut({children:e}){const[t,{addAnnotation:n,removeAnnotation:o}]=qt();return u.jsx(Ft.Provider,{value:c.useMemo(()=>({fullPage:t,addAnnotation:n,removeAnnotation:o}),[t]),children:e})}function mr({width:e,style:t,height:n,error:o,resetErrorBoundary:r}){return u.jsxs("div",{style:{width:e,height:n,minHeight:500,...t||{},background:"#f9f9f9"},children:[u.jsx("h3",{children:"Error occurred"}),u.jsx("p",{children:o.message}),u.jsx("button",{onClick:r,children:"Reset"})]})}const Qe=c.createContext(null);function $t(){return c.useContext(Qe)}const Ht=c.createContext(()=>{}),Wt=c.createContext(()=>{});function Ie(e,t,n,o,r=[]){const s=c.useContext(e==="portal"?Wt:Ht);c.useEffect(()=>(e!=="none"&&s(t,n,o),()=>{s(t,null)}),[t,e,s,...r])}function ye(e={},t=[]){const{id:n,selector:o}=e,r=xe(),s=n||r.canvas,i=se(a=>s?a.iiif.entities.Canvas[s]:void 0,[s]);return c.useMemo(()=>{if(i)return o?o(i):i},[i,o,...t])}const Yt=c.createContext(()=>{});function vr(e){const t=ye(),n=c.useContext(Yt);c.useEffect(()=>t&&t.id?(n(t.id,e),()=>n(t.id,-1)):()=>{},[t,e])}function br({children:e,errorFallback:t,outerContainerProps:n={},worldScale:o,...r}){const[s,i]=c.useState(),a=Nt(),p=t||mr,[y,f]=c.useState({}),g=Object.entries(y),[O,R]=c.useState({}),E=Object.entries(O),[x,T]=c.useState({}),I=c.useMemo(()=>o||Math.max(...Object.values(x)),[x]),k=c.useMemo(()=>({maxOverZoom:I||1,...r.runtimeOptions||{}}),[I,r.runtimeOptions]),j=c.useCallback((L,q)=>{T(M=>{if(q===-1){const{[L]:P,...U}=M;return U}return{...M,[L]:q}})},[]),B=c.useCallback((L,q,M)=>{f(({[L]:P,...U})=>q?{...U,[L]:{element:q,props:M}}:U)},[]),A=c.useCallback((L,q,M)=>{R(({[L]:P,...U})=>q?{...U,[L]:{element:q,props:M}}:U)},[]);return u.jsxs(Yn,{resetKeys:[],fallbackRender:L=>u.jsx(p,{...r,...L}),children:[u.jsx(Oe.AtlasAuto,{...r,containerProps:{style:{position:"relative"},...r.containerProps||{}},htmlChildren:u.jsx(u.Fragment,{children:g.map(([L,{element:q,props:M}])=>u.jsx(c.Fragment,{children:u.jsx(q,{...M||{}})},L))}),onCreated:L=>{i(L),r.onCreated&&r.onCreated(L)},runtimeOptions:k,children:u.jsx(Qe.Provider,{value:s,children:u.jsx(Yt.Provider,{value:j,children:u.jsx(Ht.Provider,{value:B,children:u.jsx(Wt.Provider,{value:A,children:u.jsx(_t,{bridge:a,children:u.jsx(Oe.ModeContext.Provider,{value:r.mode||"explore",children:u.jsx(Ut,{children:e})})})})})})})}),u.jsx("div",{children:E.map(([L,{element:q,props:M}])=>u.jsx(c.Fragment,{children:u.jsx(q,{...M||{}})},L))})]})}const He={},zt={get(e){return e},setMetaValue([e,t,n],o){const r=zt.getResourceMeta(e,t),s=r?r[n]:void 0,i=typeof o=="function"?o(s):o;He[e]={...He[e]||{},[t]:{...(He[e]||{})[t]||{},[n]:i}}},getResourceMeta:(e,t)=>{const n=He[e];if(n)return t?n[t]:n}};function Kt(e=zt){return{addEventListener(t,n,o,r){if(t)return e.setMetaValue([t.id,"eventManager",n],s=>{const i=s||[];for(const a of i)if(a.callback===o)return i;return[...i,{callback:o,scope:r}]}),o},removeEventListener(t,n,o){t&&e.setMetaValue([t.id,"eventManager",n],r=>(r||[]).filter(s=>s.callback!==o))},getListenersAsProps(t,n){const o=typeof t=="string"?{id:t}:t;if(!o||!o.id)return{};const r=e.getResourceMeta(o.id,"eventManager"),s={};if(r&&o)for(const i of Object.keys(r))s[i]=a=>{const p=e.get(o);for(const{callback:y,scope:f}of r[i]||[])(!f||n&&f.indexOf(n)!==-1)&&y(a,p)};return s}}}function pt(e,t){const n=J(),o=c.useMemo(()=>Kt(n),[n]),r=se(()=>e&&e.id?n.getResourceMeta(e.id,"eventManager"):null,[e]);return c.useMemo(()=>e?o.getListenersAsProps(e,t):{},[r,e,n,t])}function Ae(e,t){const n=J(),o=c.useMemo(()=>ot.createStylesHelper(n),[n]);return se(()=>{if(!e)return null;const r=o.getAppliedStyles(e.id);return r?t?r[t]:r:void 0},[e,t])}function ht(e={},t=[]){const{id:n,selector:o}=e,r=xe(),s=J(),i=n||r.annotation,a=se(y=>i?y.iiif.entities.Annotation[i]:void 0,[i]),p=se(y=>a&&a.body?a.body.map(f=>f?f.type==="SpecificResource"?{...f,source:s.get(f)}:f?y.iiif.entities[f.type][f.id]:null:null).filter(Boolean):[],[a]);return c.useMemo(()=>{if(!a)return;const y={...a,body:p,target:Le.expandTarget(a.target,{typeMap:s.getState().iiif.mapping})};return o?o(y):y},[a,o,p,...t])}const Qt=({id:e,style:t,className:n,interactive:o})=>{const r=ht({id:e}),s=Ae(r,"atlas"),i=Ae(r,"html"),a=pt(r,["atlas"]),p=ye(),y=c.useMemo(()=>Oe.mergeStyles(t,s),[t,s]);return p&&r&&r.target&&r.target.selector&&r.target.selector.type==="BoxSelector"&&r.target.source&&(r.target.source.id===p.id||r.target.source===p.id)?u.jsx(Oe.RegionHighlight,{id:r.id,isEditing:!0,region:r.target.selector.spatial,style:y,className:(i==null?void 0:i.className)||n,interactive:!!(i!=null&&i.href||o),href:(i==null?void 0:i.href)||null,title:(i==null?void 0:i.title)||null,hrefTarget:(i==null?void 0:i.target)||null,onClick:()=>{},...a}):null};function Gt(e={},t=[]){const{id:n,selector:o}=e,r=xe(),s=n||r.annotationPage,i=se(a=>s?a.iiif.entities.AnnotationPage[s]:void 0,[s]);return c.useMemo(()=>{if(i)return o?o(i):i},[i,...t])}const rt=({className:e,page:t})=>{var s;const n=Gt({id:t.id})||t,o=Ae(n,"atlas"),r=Ae(n,"html");return se(i=>n.id?i.iiif.entities.AnnotationPage[n.id]:null,[]),u.jsx(c.Fragment,{children:(s=n.items)==null?void 0:s.map(i=>u.jsx(Qt,{id:i.id,style:o,className:(r==null?void 0:r.className)||e},i.id))})};function Xt({id:e,image:t,thumbnail:n,isStatic:o,x:r=0,y:s=0,children:i,selector:a,onClick:p,enableSizes:y}){var g,O;const f=c.useMemo(()=>{if(!(!a||a.spatial.x===0&&a.spatial.y===0))return a.spatial},[a]);return u.jsx("world-object",{x:r+t.target.spatial.x,y:s+t.target.spatial.y,width:t.target.spatial.width,height:t.target.spatial.height,onClick:p,children:t.service?u.jsxs(c.Fragment,{children:[u.jsx(Oe.TileSet,{tiles:{id:t.service.id||t.service["@id"]||"unknown",height:t.height,width:t.width,imageService:t.service,thumbnail:n&&n.type==="fixed"?n:void 0},enableSizes:y,x:0,y:0,width:(g=t.target)==null?void 0:g.spatial.width,height:(O=t.target)==null?void 0:O.spatial.height,crop:f}),i]},"service"):u.jsxs(c.Fragment,{children:[u.jsx("world-image",{onClick:p,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:f}),i]},"no-service")},e+(t.service?"server":"no-service"))}function xr(e){return e.type==="SpecificResource"?[e.source,{selector:e.selector}]:[e,{selector:null}]}function yt(e,t){const{selector:n,source:o}=Un.expandTarget(t);if(o.id!==e.id)return[null,o];const r={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:r.spatial}:n:null,o]}const Jt={makeChoice:()=>{}},ze={type:"unknown"},X=e=>({type:"unknown",reason:e,annotations:{pages:[]}}),Zt=(e,t)=>({type:"empty",width:e,height:t,annotations:{pages:[]},image:null,images:[]});function wr(e,t){var o;const n=(o=e==null?void 0:e.iiif)==null?void 0:o.meta[t];return n?n.annotationPageManager:null}function Sr(e,t){return se(n=>{const o=[];if(!e)return o;const r=Object.keys(n.iiif.entities.AnnotationPage);for(const s of r)if(!t||t.indexOf(s)!==-1){const i=wr(n,s);i&&i.views&&i.views[e]&&o.push(s)}return o},[e,t])}function en({canvas:e,manifest:t,all:n,canvases:o}){const r=[];if(t)for(const s of t.annotations)r.indexOf(s.id)===-1&&r.push(s.id);if(n){if(o&&o.length)for(const s of o)for(const i of s.annotations)r.indexOf(i.id)===-1&&r.push(i.id)}else if(e)for(const s of e.annotations)r.indexOf(s.id)===-1&&r.push(s.id);return r}function Pr(e,t){var o;const n=(o=e==null?void 0:e.iiif)==null?void 0:o.meta[t];return n?n.annotationPageManager:null}function gt(e,t={}){const n=J(),o=ve(),r=ye(),s=at(),i=c.useMemo(()=>en({all:t.all,manifest:o,canvas:r,canvases:s}),[t.all,r,s,o]),a=Sr(e,t.all?void 0:i),p=c.useCallback(f=>{e&&n.setMetaValue([f,"annotationPageManager","views"],g=>g&&!g[e]?g:{...g||{},[e]:!1})},[e,n]),y=c.useCallback((f,g={})=>{if(!e)return;const O=n.getState(),R=[];if(g!=null&&g.deselectOthers){const E=Object.keys(O.iiif.entities.AnnotationPage);for(const x of E){const T=Pr(O,x);T&&T.views&&T.views[e]&&R.push(x)}}for(const E of R)p(E);n.setMetaValue([f,"annotationPageManager","views"],E=>E&&E[e]?E:{...E||{},[e]:!0})},[e,p,n]);return{availablePageIds:i,enabledPageIds:a,setPageEnabled:y,setPageDisabled:p}}function tn(e,t){return se((n,o)=>o.get(e.map(r=>({id:r,type:t}))),[e,t])}const nn=c.createContext(new Ee.ImageServiceLoader);function De(){return c.useContext(nn)}function rn(){const e=De(),[t,n]=c.useState({}),o=c.useRef(!1);return c.useEffect(()=>()=>{o.current=!0},[]),[c.useCallback((s,{height:i,width:a})=>{if(s){const p=s.id||s["@id"],y=e.loadServiceSync({id:p,width:s.width||a,height:s.height||i,source:s});y?s=y:t[p]||(o.current||n(f=>({...f,[p]:"loading"})),e.loadService({id:p,width:s.width||a,height:s.height||i}).then(()=>{o.current||n(f=>({...f,[p]:"done"}))}))}return s},[e,t]),t]}function Ge(e={}){const t=ht(),n=ye(e.canvasId?{id:e.canvasId}:void 0);return se((o,r)=>{if(!n)return[];if(t&&e.enableSingleAnnotation)return[t];const s=r.get(n.items),i=[];for(const a of s)i.push(...r.get(a.items));return i},[n])}function jr(e){return e.type==="SpecificResource"?[e.source,{selector:e.selector}]:[e,{selector:null}]}const We={},on={get(e){return e},setMetaValue([e,t,n],o){const r=on.getResourceMeta(e,t),s=r?r[n]:void 0,i=typeof o=="function"?o(s):o;We[e]={...We[e]||{},[t]:{...(We[e]||{})[t]||{},[n]:i}}},getResourceMeta:(e,t)=>{const n=We[e];if(n)return t?n[t]:n}};function Or(e=on){function t(r){const s=r?typeof r=="string"?e.get(r):r:null;if(!s)return[];const i=e.get(s.items,{parent:s}),a=[];for(const p of i)a.push(...e.get(p.items,{parent:p}));return a}function n(r,s=[]){const i=Array.isArray(r)?r:t(r),a=[];let p=null;const y=[];for(const f of i){if(f.type!=="Annotation")throw new Error("getPaintables() accept either a canvas or list of annotations");const g=Array.from(Array.isArray(f.body)?f.body:[f.body]);for(const O of g){const[R,{selector:E}]=jr(O),x=e.get(R),T=(x.type||"unknown").toLowerCase();if(T==="choice"){const I=e.get(x.items,{parent:x.id}),k=s.length?s.map(j=>I.find(B=>B.id===j)).filter(Boolean):[I[0]];k.length===0&&k.push(I[0]),p={type:"single-choice",items:I.map(j=>({id:j.id,label:j.label,selected:k.indexOf(j)!==-1})),label:R.label},g.push(...k);continue}a.indexOf(T)===-1&&a.push(T),y.push({type:T,annotationId:f.id,resource:x,target:f.target,selector:E})}}return{types:a,items:y,choice:p}}function o(r){const{choice:s}=n(r);return s}return{getAllPaintingAnnotations:t,getPaintables:n,extractChoices:o}}function sn(e,t=[]){const n=J(),o=c.useMemo(()=>Or(n),[]),r=Ge({enableSingleAnnotation:e==null?void 0:e.enableSingleAnnotation}),[s,i]=c.useState((e==null?void 0:e.defaultChoices)||[]),a=c.useMemo(()=>o.getPaintables(r,s),[n,r,s,...t]),y={makeChoice:c.useCallback((f,{deselectOthers:g=!0,deselect:O=!1}={})=>{if(a.choice){if(a.choice.type!=="single-choice")throw new Error("Complex choice not supported yet");i(R=>{if(O){const x=R.filter(T=>T!==f);if(x.length===0){const T=a.items[0].resource.id;return T?[T]:[]}return x}if(g)return[f];const E=[...R];if(E.length===0&&a.items.length){const x=a.items[0].resource.id;x&&E.push(x)}return R.indexOf(f)!==-1?R:[...R,f]})}},[a.choice])};return[a,y]}const Cr=["model/gltf-binary"];function an(e,t){const o=t.items[0].resource;return o.format?Cr.indexOf(o.format)===-1?X(`3D format: ${o.format} is unsupported`):{type:"3d-model",model:o}:X("Unknown format")}function Tr(e,t){var o;if(!e.duration)return X("No duration on canvas");if(t.items.length>1)return X("Only one audio source supported");const n=(o=t.items[0])==null?void 0:o.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:[]}}:X("Audio does not have format"):X("Unknown audio")}function un(e,t,n){const o=[];for(const r of t.items){const s=r.resource&&r.resource.type==="SpecificResource"?r.resource.source:r.resource;if(!s.id)return X("No resource Identifier");let i;if(s.service){const R=Ee.getImageServices(s);R[0]&&(i=n(R[0],e))}const a={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}},[p,y]=yt(e,r.target);if(!(y.id===e.id||decodeURIComponent(y.id||"")===(e.id||"")))continue;r.resource.width&&r.resource.height&&(r.resource.width,r.resource.height);let f=r.resource.type==="SpecificResource"?Le.expandTarget(r.resource):null;if(r.selector){const R=Le.expandTarget({type:"SpecificResource",source:r.resource,selector:r.selector});R&&(f=R)}const g=f&&f.selector&&(f.selector.type==="BoxSelector"||f.selector.type==="TemporalBoxSelector")?{type:"BoxSelector",spatial:{x:f.selector.spatial.x,y:f.selector.spatial.y,width:f.selector.spatial.width,height:f.selector.spatial.height}}:void 0;i&&!i.id&&(i.id=i["@id"]);const O={id:s.id,type:"Image",annotationId:r.annotationId,width:Number(p||g?s.width:e.width),height:Number(p||g?s.height:e.height),service:i,sizes:i&&i.sizes?i.sizes:s.width&&s.height?[{width:s.width,height:s.height}]:[],target:p&&p.type!=="PointSelector"?p:a,selector:g};o.push(O)}return{type:"images",image:o[0],images:o,choice:t.choice}}function cn(e,t={},n){const o=e.language||n||"none";switch(e.type){case"TextualBody":{typeof e.value<"u"&&(t[o]=e.value);break}case"List":case"Composite":case"Choice":e.items&&e.items.forEach(r=>cn(r,t,o))}return t}function ln(e,t){const n=[];return t.items.forEach(o=>{if(o.resource){const[r]=yt(e,o.target);n.push({annotationId:o.annotationId,text:cn(o.resource),target:r})}}),{type:"textual-content",items:n}}const Er=/^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\/)|(?:(?:watch)?\?vi?=|&vi?=))([^#&?]*).*/;function fn(e,t){var a;const n=t.items.filter(p=>p.type==="video");let o=!1;if(e.duration||(o=!0),n.length>1)return X("Only one video source supported");const r=(a=n[0])==null?void 0:a.resource,s=!!(r.service||[]).find(p=>(p.profile||"").includes("youtube.com"));if(!s&&o)return X("Video does not have duration");if(!r)return X("Unknown video");if((!r.format||r.format==="text/html")&&!s)return X("Video does not have format");const i={annotationId:t.items[0].annotationId,duration:e.duration,url:r.id,type:"Video",items:[],target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:r.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}};if(s){i.type="VideoYouTube";const p=r.id.match(Er);if(!p[1])return X("Video is not known youtube video");i.youTubeId=p[1]}return{type:"media",media:i,annotations:{pages:[]}}}function dn({canvas:e,paintables:t,supports:n,loadImageService:o}){if(!e)return console.log("No canvas"),ze;if(t.types.length===0)return n.indexOf("empty")!==-1?Zt(e.width,e.height):(console.log("No paintables"),ze);if(t.types.length!==1)if(t.types.length===2&&t.types.indexOf("text")!==-1)t.types=t.types.filter(s=>s!=="text");else return n.indexOf("complex-timeline")===-1?X("Complex timeline not supported"):X("ComplexTimelineStrategy not yet supported");const r=t.types[0];return r==="image"?n.indexOf("images")===-1?X("Image not supported"):un(e,t,o):r==="Model"||r==="model"?n.indexOf("3d-model")===-1?X("3D not supported"):an(e,t):r==="textualbody"?n.indexOf("textual-content")===-1?X("Textual content not supported"):ln(e,t):r==="sound"||r==="audio"?n.indexOf("media")===-1?X("Media not supported"):Tr(e,t):r==="video"?n.indexOf("media")===-1?X("Media not supported"):fn(e,t):ze}function pn(e){const t=ve(),n=ye(),o=J(),[r,s]=rn(),{enabledPageIds:i}=gt((e==null?void 0:e.annotationPageManagerId)||(t==null?void 0:t.id)||(n==null?void 0:n.id),{all:!1}),a=tn(i,"AnnotationPage"),p=(e==null?void 0:e.strategies)||["empty","images","media","textual-content","complex-timeline"],[y,f]=sn(e,[s]),g=c.useMemo(()=>dn({canvas:n,paintables:y,supports:p,loadImageService:r}),[n,y,o,f.makeChoice]);return c.useMemo(()=>g.type==="unknown"?[g,Jt]:[{...g,annotations:{pages:a}},f],[g,a])}const hn=(e,t=[])=>{const n=J();c.useEffect(()=>{e(n)},[n,...t])};function mt(e,t,{canvasId:n,manifestId:o}={}){const r=J(),s=De(),i=c.useMemo(()=>$n.createThumbnailHelper(r,{imageServiceLoader:s}),[r,s]),[a,p]=c.useState(),y=ve(o?{id:o}:void 0),f=ye(n?{id:n}:void 0),g=f||y,O=c.useRef(!1);if(c.useEffect(()=>(O.current=!1,()=>{O.current=!0}),[]),!g)throw new Error("Must be called under a manifest or canvas context.");return hn(R=>{i.getBestThumbnailAtSize(g,e,t).then(E=>{E.best&&!O.current&&p(E.best)})},[g]),a}function Ir(e){return{isMuted:!1,playRequested:!1,isPlaying:!1,isFinished:!1,volume:100,duration:e}}function Mr(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 yn(e){const t=Math.round(e);return`${Math.floor(t/60)}:${`${t%60}`.padStart(2,"0")}`}function Xe(e){const[t,n]=c.useReducer(Mr,Ir(e.duration)),o=c.useRef(null),r=c.useRef(null),s=c.useRef(null),i=c.useRef(!1),a=c.useCallback(()=>{r.current&&o.current&&(r.current.innerHTML=yn(o.current.currentTime),s.current&&(s.current.style.width=`${o.current.currentTime/e.duration*100}%`),i.current!==o.current.muted&&(i.current=o.current.muted,n(o.current.muted?{type:"MUTE"}:{type:"UNMUTE"})))},[e.duration]),p=c.useCallback(()=>{o.current&&(n({type:"PLAY_REQUESTED"}),o.current.play().then(()=>{n({type:"PLAY"})}),a())},[a]),y=c.useCallback(()=>{o.current&&(o.current.duration>0&&o.current.paused?p():f())},[a]),f=c.useCallback(()=>{o.current&&(o.current.pause(),n({type:"PAUSE"}),a())},[a]),g=c.useCallback(()=>{o.current&&(o.current.muted=!o.current.muted,n(o.current.muted?{type:"MUTE"}:{type:"UNMUTE"}))},[]),O=c.useCallback(()=>{o.current&&(o.current.muted=!0,n({type:"MUTE"}))},[]),R=c.useCallback(()=>{o.current&&(o.current.muted=!1,n({type:"UNMUTE"}))},[]),E=c.useCallback(I=>{o.current&&(o.current.muted=!1,o.current.volume=I/100,n({type:"SET_VOLUME",volume:I}))},[]),x=c.useCallback(I=>{o.current&&(o.current.currentTime=Math.max(0,Math.min(I*e.duration,e.duration)),a())},[]),T=c.useCallback(I=>{o.current&&(o.current.currentTime=Math.max(0,Math.min(I,e.duration)),a())},[]);return c.useEffect(()=>{const I=setInterval(()=>{a()},350);return()=>clearInterval(I)},[a,e.duration]),c.useEffect(()=>{const I=()=>{n({type:"FINISHED"})},k=o.current;return k==null||k.addEventListener("ended",I),()=>k==null?void 0:k.removeEventListener("ended",I)},[]),[{element:o,currentTime:r,progress:s},t,{play:p,pause:f,playPause:y,mute:O,unmute:R,toggleMute:g,setVolume:E,setDurationPercent:x,setTime:T}]}const gn=c.createContext(null),mn=c.createContext(null),vn=c.createContext(null);function Rr(){const e=c.useContext(gn);if(!e)throw new Error("Ctx not found");return e}function Lr(){const e=c.useContext(mn);if(!e)throw new Error("Ctx not found");return e}function Ar(){const e=c.useContext(vn);if(!e)throw new Error("Ctx not found");return e}function vt({actions:e,state:t,children:n,currentTime:o,progress:r,element:s}){return u.jsx(vn.Provider,{value:{currentTime:o,progress:r,element:s},children:u.jsx(mn.Provider,{value:e,children:u.jsx(gn.Provider,{value:t,children:n})})})}function bn({media:e,children:t}){const[{element:n,currentTime:o,progress:r},s,i]=Xe({duration:e.duration});return u.jsxs(vt,{state:s,actions:i,currentTime:o,progress:r,element:n,children:[u.jsx("audio",{ref:n,src:e.url}),t]})}function xn({media:e,mediaControlsDeps:t,children:n}){return Ie("portal","audio",bn,{media:e,children:n},[e,...t||[]]),null}function wn({element:e,media:t,playPause:n}){return u.jsxs("div",{className:"video-container",part:"video-container",onClick:n,children:[u.jsx("style",{children:`
2
2
  .video-container {
3
3
  position: absolute;
4
4
  top: 0;
@@ -11,7 +11,7 @@
11
11
  justify-content: center;
12
12
  pointer-events: visible;
13
13
  }
14
- `}),c.jsx("video",{ref:e,src:t.url,style:{width:"100%",objectFit:"contain"}})]})}function Et({media:e,mediaControlsDeps:t,children:n}){const[{element:r,currentTime:o,progress:i},s,a]=ae({duration:e.duration});return U("overlay","video-element",jt,{element:r,media:e,playPause:a.playPause}),U("portal","custom-controls",we,{state:s,actions:a,currentTime:o,progress:i,element:r,children:n},[o,s,e,...t||[]]),null}function It({model:e}){return c.jsxs(c.Fragment,{children:[c.jsx("style",{children:`
14
+ `}),u.jsx("video",{ref:e,src:t.url,style:{width:"100%",objectFit:"contain"}})]})}function Sn({media:e,mediaControlsDeps:t,children:n}){const[{element:o,currentTime:r,progress:s},i,a]=Xe({duration:e.duration});return Ie("overlay","video-element",wn,{element:o,media:e,playPause:a.playPause}),Ie("portal","custom-controls",vt,{state:i,actions:a,currentTime:r,progress:s,element:o,children:n},[r,i,e,...t||[]]),null}function Pn({model:e}){return u.jsxs(u.Fragment,{children:[u.jsx("style",{children:`
15
15
  .model-container {
16
16
  position: absolute;
17
17
  top: 0;
@@ -24,9 +24,9 @@
24
24
  justify-content: center;
25
25
  pointer-events: visible;
26
26
  }
27
- `}),c.jsx("div",{className:"model-container",children:c.jsx("model-viewer",{"interaction-prompt":"none",style:{width:"100%",height:"100%"},"camera-controls":"","ar-status":"not-presenting",src:e.id})})]})}function Rt({model:e,name:t}){return U("overlay",`model-${t}`,It,{model:e},[e]),null}function At({style:e}){const t=V();return!t||!t.height||!t.width?null:c.jsx("box",{interactive:!1,target:{x:0,y:0,width:Number(t.width),height:Number(t.height)},style:e})}const Tt=u.createContext("en");function On(e){return c.jsx(Tt.Provider,{value:e.language,children:e.children})}function ue(){return u.useContext(Tt)}function Ae(e){return e.indexOf("-")!==-1?e.slice(0,e.indexOf("-")):e}function Vt({as:e,language:t,children:n,viewingDirection:r,...o}){const i=ue();return u.useMemo(()=>Ae(i)===Ae(t),[i,t])?e?c.jsx(e,{...o,children:n}):c.jsx("span",{...o,children:n}):e?c.jsx(e,{...o,lang:t,dir:r,children:n}):c.jsx("span",{...o,lang:t,dir:r,children:n})}function Lt(e,t,n){if(t.length===0)return;if(t.length===1)return t[0];if(t.indexOf(e)!==-1)return e;const r=e.indexOf("-")!==-1?e.slice(0,e.indexOf("-")):null;if(r&&t.indexOf(r)!==-1)return r;for(const o of n)if(t.indexOf(o)!==-1)return o;return t.indexOf("none")!==-1?"none":t.indexOf("@none")!==-1?"@none":t[0]}const kt=(e,t=[])=>{const n=ue();return u.useMemo(()=>{const r=e();return Lt(n,r,[])},[n,...t])};function Ot(e,t){const n=kt(()=>Object.keys(e||{}),[e]);return[u.useMemo(()=>{if(!e)return t||"";if(typeof e=="string")return e;const r=n?e[n]:void 0;return r?typeof r=="string"?r:r.join(`
28
- `):""},[n,t,e]),n]}function Fn(){const e=ue();return function(n,r,o){const i=Object.keys(n||{}),s=Lt(e,i,[]);if(!n)return r||"";if(typeof n=="string")return n;const a=s?n[s]:void 0;return a?typeof a=="string"?a:a.join(typeof o<"u"?o:`
29
- `):""}}const Ft=({as:e,defaultText:t,enableDangerouslySetInnerHTML:n,children:r,...o})=>{const[i,s]=Ot(r,t);return s?c.jsx(Vt,{...o,as:e,language:s,title:n?void 0:i,dangerouslySetInnerHTML:n?{__html:i}:void 0,children:n?void 0:i}):e?c.jsx(e,{...o,children:i}):c.jsx("span",{...o,title:n?void 0:i,dangerouslySetInnerHTML:n?{__html:i}:void 0,children:n?void 0:i})};function Nn({element:e,media:t,playPause:n}){const r=u.useRef(null);return t.youTubeId?c.jsxs("div",{className:"video-container",part:"video-container",onClick:n,children:[c.jsx("style",{children:`
27
+ `}),u.jsx("div",{className:"model-container",children:u.jsx("model-viewer",{"interaction-prompt":"none",style:{width:"100%",height:"100%"},"camera-controls":"","ar-status":"not-presenting",src:e.id})})]})}function jn({model:e,name:t}){return Ie("overlay",`model-${t}`,Pn,{model:e},[e]),null}function On({style:e}){const t=ye();return!t||!t.height||!t.width?null:u.jsx("box",{interactive:!1,target:{x:0,y:0,width:Number(t.width),height:Number(t.height)},style:e})}const Cn=c.createContext("en");function kr(e){return u.jsx(Cn.Provider,{value:e.language,children:e.children})}function Je(){return c.useContext(Cn)}function Et(e){return e.indexOf("-")!==-1?e.slice(0,e.indexOf("-")):e}function Tn({as:e,language:t,children:n,viewingDirection:o,...r}){const s=Je();return c.useMemo(()=>Et(s)===Et(t),[s,t])?e?u.jsx(e,{...r,children:n}):u.jsx("span",{...r,children:n}):e?u.jsx(e,{...r,lang:t,dir:o,children:n}):u.jsx("span",{...r,lang:t,dir:o,children:n})}function En(e,t,n){if(t.length===0)return;if(t.length===1)return t[0];if(t.indexOf(e)!==-1)return e;const o=e.indexOf("-")!==-1?e.slice(0,e.indexOf("-")):null;if(o&&t.indexOf(o)!==-1)return o;for(const r of n)if(t.indexOf(r)!==-1)return r;return t.indexOf("none")!==-1?"none":t.indexOf("@none")!==-1?"@none":t[0]}const In=(e,t=[])=>{const n=Je();return c.useMemo(()=>{const o=e();return En(n,o,[])},[n,...t])};function Mn(e,t,n=`
28
+ `){const o=In(()=>Object.keys(e||{}),[e]);return[c.useMemo(()=>{if(!e)return t||"";if(typeof e=="string")return e;const r=o?e[o]:void 0;return r?typeof r=="string"?r:r.join(n):""},[o,t,e]),o]}function Vr(){const e=Je();return function(n,o,r){const s=Object.keys(n||{}),i=En(e,s,[]);if(!n)return o||"";if(typeof n=="string")return n;const a=i?n[i]:void 0;return a?typeof a=="string"?a:a.join(typeof r<"u"?r:`
29
+ `):""}}function je({as:e,defaultText:t,enableDangerouslySetInnerHTML:n,children:o,separator:r,...s}){const[i,a]=Mn(o,t,r);return a?u.jsx(Tn,{...s,as:e,language:a,title:n?void 0:i,dangerouslySetInnerHTML:n?{__html:i}:void 0,children:n?void 0:i}):e?u.jsx(e,{...s,children:i}):u.jsx("span",{...s,title:n?void 0:i,dangerouslySetInnerHTML:n?{__html:i}:void 0,children:n?void 0:i})}function Nr({element:e,media:t,playPause:n}){const o=c.useRef(null);return t.youTubeId?u.jsxs("div",{className:"video-container",part:"video-container",onClick:n,children:[u.jsx("style",{children:`
30
30
  .video-container {
31
31
  position: absolute;
32
32
  top: 0;
@@ -44,5 +44,6 @@
44
44
  width: 100%;
45
45
  object-fit: contain;
46
46
  }
47
- `}),c.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 Dn({media:e,mediaControlsDeps:t,children:n}){const[{element:r,currentTime:o,progress:i},s,a]=ae({duration:e.duration});return U("overlay","video-element",Nn,{element:r,media:e,playPause:a.playPause}),null}function Nt({x:e,y:t,onChoiceChange:n,registerActions:r,defaultChoices:o,isStatic:i,renderViewerControls:s,renderMediaControls:a,viewControlsDeps:l,mediaControlsDeps:f,strategies:d,throwOnUnknown:g,backgroundStyle:p,alwaysShowBackground:y,keepCanvasScale:m=!1,enableSizes:h=!1,enableYouTube:x=!0,onClickPaintingAnnotation:C,children:j}){const S=V(),L=Se(S,["deep-zoom"]),[Q]=Ye(),w=Ke(),I=M(),A=u.useMemo(()=>ge.createStylesHelper(I),[I]),[v,k]=pt({strategies:d||["images"],defaultChoices:o==null?void 0:o.map(({id:b})=>b)}),Pe=v.type==="images"?v.choice:void 0,_t=u.useMemo(()=>m?1:Math.max(1,...v.type==="images"?v.images.map(b=>{var q;return(b.width||0)/((q=b.target)==null?void 0:q.spatial.width)}):[]),[m,v]);xn(_t),u.useEffect(()=>{r&&r(k)},[v.annotations]),u.useEffect(()=>{if(o)for(const b of o)typeof b.opacity<"u"&&A.applyStyles({id:b.id},"atlas",{opacity:b.opacity})},[o]),u.useLayoutEffect(()=>{n&&n(Pe)},[Pe]),U(w&&(v.type==="images"||v.type==="empty"||v.type==="textual-content"&&s)?"overlay":"none",`canvas-portal-controls-${S==null?void 0:S.id}`,oe.Provider,s?{value:w||null,children:s(v)}:{},[S,w,v,...l||[]]);const F=xt({maxWidth:256,maxHeight:256});if(!S)return null;const Me=S.accompanyingCanvas,B=F&&F.type==="fixed"?c.jsx("world-object",{height:S.height,width:S.width,x:e,y:t,children:c.jsx("world-image",{uri:F.id,target:{x:0,y:0,width:S.width,height:S.height},display:F.width&&F.height?{width:F.width,height:F.height}:void 0,crop:void 0})}):null;if(v.type==="unknown"){if(B)return B;if(g)throw new Error(v.reason||"Unknown image strategy");return null}const je=c.jsxs(u.Fragment,{children:[Q?c.jsx(fe,{page:Q}):null,v.annotations&&v.annotations.pages?v.annotations.pages.map(b=>c.jsx(fe,{page:b},b.id)):null,j]}),Ut=v.type==="images"?v.images.length:0;return c.jsxs(c.Fragment,{children:[c.jsxs("world-object",{height:S.height,width:S.width,x:e,y:t,...L,children:[v.type==="empty"||y?c.jsx(At,{style:p}):null,v.type==="textual-content"?v.items.map((b,q)=>{var H;return c.jsxs(c.Fragment,{children:[c.jsx(_.HTMLPortal,{onClick:C?Ee=>{Ee.stopPropagation(),C(b.annotationId,b,Ee)}:void 0,target:((H=b.target)==null?void 0:H.spatial)||void 0,children:c.jsx("div",{"data-textual-content":!0,children:c.jsx(Ft,{enableDangerouslySetInnerHTML:!0,children:b.text})})},q),je]})}):null,v.type==="images"?c.jsxs(c.Fragment,{children:[v.images.map((b,q)=>c.jsx(tt,{isStatic:i,image:b,id:b.id,thumbnail:q===0?F:void 0,selector:b.selector,enableSizes:h,onClick:C?H=>{H.stopPropagation(),C(b.annotationId,b,H)}:void 0},b.id+q)),je]}):null,v.type==="3d-model"?c.jsx(Rt,{model:v.model}):null,v.type==="media"?c.jsx(c.Fragment,{children:v.media.type==="Sound"?c.jsxs(Mt,{media:v.media,mediaControlsDeps:f,children:[B,a?a(v):null]}):v.media.type==="Video"?c.jsxs(Et,{media:v.media,mediaControlsDeps:f,children:[B,a?a(v):null]}):v.media.type==="VideoYouTube"&&x?c.jsxs(Dn,{media:v.media,mediaControlsDeps:f,children:[B,a?a(v):null]}):null}):null]},`${S.id}/${v.type}/${Ut}`),v.type==="media"&&v.media.type==="Sound"&&Me?c.jsx(re,{canvas:Me.id,children:c.jsx(Nt,{renderViewerControls:s})}):null]})}function Dt(){const e=u.useContext(K);return e&&e.vault?e.vault:X.globalVault()}const qn=u.forwardRef(function(t,n){const r=D(),o=ve(),i=qe(),{ViewerControls:s,MediaControls:a}=t.components||{};if(u.useImperativeHandle(n,()=>i,[i]),!r)return c.jsx("div",{});let l=0;return c.jsxs(c.Fragment,{children:[t.header,c.jsx(R.Viewer,{height:t.height,mode:t.mode,children:o.map((f,d)=>{const g=l;return l+=f.width+(t.spacing||0),c.jsx(re,{canvas:f.id,children:c.jsx(R.RenderCanvas,{strategies:["3d-model","media","images","empty","textual-content"],renderViewerControls:d===0&&s?()=>c.jsx(s,{}):void 0,renderMediaControls:d===0&&a?()=>c.jsx(a,{}):void 0,x:g,...t.canvasProps||{},children:t.annotations},f.id)},f.id)})},t.reuseAtlas?"":i.currentSequenceIndex),t.children]})}),R=u.forwardRef(function({children:t,height:n,annotations:r,canvasProps:o,spacing:i,header:s,components:a,mode:l,...f},d){const g=Dt();return c.jsx(he,{vault:g,children:c.jsx(De,{...f,children:c.jsx(qn,{ref:d,height:n,components:a,spacing:i,canvasProps:o,annotations:r,header:s,mode:l,children:t})})})});R.RenderImage=tt;R.RenderCanvas=Nt;R.RenderAnnotationPage=fe;R.RenderAnnotation=Xe;R.Viewer=Sn;R.CanvasBackground=At;R.Audio=Mt;R.Video=Et;R.Model=Rt;R.AudioHTML=Pt;R.VideoHTML=jt;R.ModelHTML=It;function _n({annotation:e,children:t}){return c.jsx(N,{value:{annotation:e},children:t})}function Un({annotationPage:e,children:t}){return c.jsx(N,{value:{annotationPage:e},children:t})}function Bn({collection:e,children:t}){return c.jsx(N,{value:{collection:e},children:t})}function Hn(e,t={}){return se(t)}function $n(e,t=!1){}function Yn(e){const n=O().manifest,r=e?e.map(o=>typeof o=="string"?o:o==null?void 0:o.id):[];return E(o=>{const i=n?o.iiif.entities.Manifest[n]:void 0,s=(i==null?void 0:i.items)||[];if(typeof e>"u")return s;const a=[];for(const l of(i==null?void 0:i.items)||[])r.indexOf(l.id)!==-1&&a.push(l);return a},[r.join("/")])}function zn(e,t=[]){const{id:n,selector:r}=e,o=O(),i=n||o.collection,s=E(a=>i?a.iiif.entities.Collection[i]:void 0,[i]);return u.useMemo(()=>{if(s)return r?r(s):s},[s,r,...t])}function Kn(e,t,n,r,o=[]){const i=M(),s=u.useMemo(()=>Ze(i),[i]);u.useEffect(()=>{const a=e;return a?(s.addEventListener(a,t,n,r),()=>{s.removeEventListener(a,t,n)}):()=>{}},[s,e,t,...o])}function Wn(e,t){const{id:n,isLoaded:r,error:o,resource:i,requestId:s,cached:a}=me(e,t);return{id:n,isLoaded:r,error:o,manifest:i,requestId:s,cached:a}}function qt({cacheKey:e}={}){const t=V(),n=se(),r=M(),o=ie(),[i,s]=u.useState(void 0),[a,l]=u.useState(!1),[f,d]=u.useState("idle"),[g,p]=u.useState(void 0),y=t?t.id:"undefined",m=u.useMemo(()=>{try{if(t&&n.length){const x=n[0],C=r.get(x.body[0]),S=te.getImageServices(C)[0];return S&&o.loadServiceSync({id:S.id||S["@id"],width:S.width||t.width,height:S.height||t.height})||void 0}}catch(x){console.error(x)}},[y,e,t]),h=f==="success"&&i?i:m;return u.useEffect(()=>{(async()=>{try{if(t&&n.length){const x=n[0],C=r.get(x.body[0]),S=te.getImageServices(C)[0];if(!S)return;l(!0),d("loading");try{const L=await o.loadService({id:S.id||S["@id"],width:S.width||t.width,height:S.height||t.height})||void 0;s(L),d("success"),l(!1)}catch(L){d("error"),p(L)}}}catch(x){d("error"),p(x)}})()},[y,e]),u.useMemo(()=>({data:h,isFetching:a,status:f,error:g}),[h,a,f,g])}function Gn(){const e=qt();return{isLoading:e.isFetching,tile:e.data?{id:e.data.id||e.data["@id"],width:e.data.width,height:e.data.height,imageService:e.data,thumbnail:void 0}:null}}function Qn(){const e=D();return e?e.service.find(t=>t.profile==="SearchService1"||t.profile==="http://iiif.io/api/search/1/search"):void 0}function Jn(){const e=M();return u.useMemo(()=>ge.createStylesHelper(e),[e])}exports.AnnotationContext=_n;exports.AnnotationPageContext=Un;exports.CanvasContext=re;exports.CanvasPanel=R;exports.CollectionContext=Bn;exports.ContextBridge=Ue;exports.ImageServiceLoaderContext=at;exports.InnerViewerProvider=Ne;exports.LanguageProvider=On;exports.LanguageString=Vt;exports.LocaleString=Ft;exports.ManifestContext=Ve;exports.MediaPlayerProvider=we;exports.RangeContext=Le;exports.ReactVaultContext=K;exports.ResourceProvider=N;exports.ResourceReactContext=ne;exports.SimpleViewerProvider=De;exports.SimpleViewerReactContext=G;exports.VaultProvider=he;exports.ViewerPresetContext=oe;exports.VirtualAnnotationProvider=ze;exports.VisibleCanvasReactContext=W;exports.emptyActions=nt;exports.emptyStrategy=rt;exports.findAllCanvasesInRange=pe;exports.findFirstCanvasFromRange=ke;exports.findManifestSelectedRange=Gt;exports.findSelectedRange=ye;exports.flattenAnnotationPageIds=ot;exports.formatTime=St;exports.get3dStrategy=dt;exports.getImageStrategy=ft;exports.getManifestSequence=xe;exports.getParsedTargetSelector=be;exports.getRenderingStrategy=vt;exports.getTextualContentStrategy=ht;exports.getVideoStrategy=mt;exports.getVisibleCanvasesFromCanvasId=Qt;exports.parseSpecificResource=Cn;exports.unknownResponse=ee;exports.unsupportedStrategy=P;exports.useAnnotation=Ce;exports.useAnnotationPage=et;exports.useAnnotationPageManager=it;exports.useAnnotationsAtTime=Hn;exports.useCanvas=V;exports.useCanvasClock=$n;exports.useCanvasSequence=Fe;exports.useCanvasSubset=Yn;exports.useClosestLanguage=kt;exports.useCollection=zn;exports.useContextBridge=_e;exports.useCreateLocaleString=Fn;exports.useDispatch=Be;exports.useEventListener=Kn;exports.useExistingVault=Dt;exports.useExternalCollection=Wn;exports.useExternalManifest=Te;exports.useExternalResource=me;exports.useIIIFLanguage=ue;exports.useImageService=qt;exports.useImageServiceLoader=ie;exports.useImageTile=Gn;exports.useLoadImageService=ut;exports.useLocaleString=Ot;exports.useManifest=D;exports.useMediaActions=Ln;exports.useMediaElements=kn;exports.useMediaState=Vn;exports.usePaintables=lt;exports.usePaintingAnnotations=se;exports.useRange=Oe;exports.useRenderingStrategy=pt;exports.useResourceContext=O;exports.useResourceEvents=Se;exports.useResources=st;exports.useSearchService=Qn;exports.useSimpleMediaPlayer=ae;exports.useSimpleViewer=qe;exports.useStyleHelper=Jn;exports.useStyles=z;exports.useThumbnail=xt;exports.useVault=M;exports.useVaultEffect=yt;exports.useVaultSelector=E;exports.useViewerPreset=Ke;exports.useVirtualAnnotationPage=He;exports.useVirtualAnnotationPageContext=Ye;exports.useVisibleCanvases=ve;Object.keys(Y).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>Y[e]})});
47
+ `}),u.jsx("iframe",{className:"video-yt",ref:o,src:`https://www.youtube.com/embed/${t.youTubeId}?enablejsapi=1&origin=${window.location.host}`,referrerPolicy:"no-referrer",sandbox:"allow-scripts allow-same-origin allow-presentation"})]}):null}function _r({media:e,mediaControlsDeps:t,children:n}){const[{element:o,currentTime:r,progress:s},i,a]=Xe({duration:e.duration});return Ie("overlay","video-element",Nr,{element:o,media:e,playPause:a.playPause}),null}function Rn({x:e,y:t,onChoiceChange:n,registerActions:o,defaultChoices:r,isStatic:s,renderViewerControls:i,renderMediaControls:a,viewControlsDeps:p,mediaControlsDeps:y,strategies:f,throwOnUnknown:g,backgroundStyle:O,alwaysShowBackground:R,keepCanvasScale:E=!1,enableSizes:x=!1,enableYouTube:T=!0,onClickPaintingAnnotation:I,children:k}){const j=ye(),B=pt(j,["deep-zoom"]),[A]=Bt(),L=$t(),q=J(),M=c.useMemo(()=>ot.createStylesHelper(q),[q]),[P,U]=pn({strategies:f||["images"],defaultChoices:r==null?void 0:r.map(({id:N})=>N)}),W=P.type==="images"?P.choice:void 0,Q=c.useMemo(()=>E?1:Math.max(1,...P.type==="images"?P.images.map(N=>{var te;return(N.width||0)/((te=N.target)==null?void 0:te.spatial.width)}):[]),[E,P]);vr(Q),c.useEffect(()=>{o&&o(U)},[P.annotations]),c.useEffect(()=>{if(r)for(const N of r)typeof N.opacity<"u"&&M.applyStyles({id:N.id},"atlas",{opacity:N.opacity})},[r]),c.useLayoutEffect(()=>{n&&n(W)},[W]),Ie(L&&(P.type==="images"||P.type==="empty"||P.type==="textual-content"&&i)?"overlay":"none",`canvas-portal-controls-${j==null?void 0:j.id}`,Qe.Provider,i?{value:L||null,children:i(P)}:{},[j,L,P,...p||[]]);const Y=mt({maxWidth:256,maxHeight:256});if(!j)return null;const Z=j.accompanyingCanvas,ee=Y&&Y.type==="fixed"?u.jsx("world-object",{height:j.height,width:j.width,x:e,y:t,children:u.jsx("world-image",{uri:Y.id,target:{x:0,y:0,width:j.width,height:j.height},display:Y.width&&Y.height?{width:Y.width,height:Y.height}:void 0,crop:void 0})}):null;if(P.type==="unknown"){if(ee)return ee;if(g)throw new Error(P.reason||"Unknown image strategy");return null}const oe=u.jsxs(c.Fragment,{children:[A?u.jsx(rt,{page:A}):null,P.annotations&&P.annotations.pages?P.annotations.pages.map(N=>u.jsx(rt,{page:N},N.id)):null,k]}),pe=P.type==="images"?P.images.length:0;return u.jsxs(u.Fragment,{children:[u.jsxs("world-object",{height:j.height,width:j.width,x:e,y:t,...B,children:[P.type==="empty"||R?u.jsx(On,{style:O}):null,P.type==="textual-content"?P.items.map((N,te)=>{var $;return u.jsxs(u.Fragment,{children:[u.jsx(Oe.HTMLPortal,{onClick:I?ae=>{ae.stopPropagation(),I(N.annotationId,N,ae)}:void 0,target:(($=N.target)==null?void 0:$.spatial)||void 0,children:u.jsx("div",{"data-textual-content":!0,children:u.jsx(je,{enableDangerouslySetInnerHTML:!0,children:N.text})})},te),oe]})}):null,P.type==="images"?u.jsxs(u.Fragment,{children:[P.images.map((N,te)=>u.jsx(Xt,{isStatic:s,image:N,id:N.id,thumbnail:te===0?Y:void 0,selector:N.selector,enableSizes:x,onClick:I?$=>{$.stopPropagation(),I(N.annotationId,N,$)}:void 0},N.id+te)),oe]}):null,P.type==="3d-model"?u.jsx(jn,{model:P.model}):null,P.type==="media"?u.jsx(u.Fragment,{children:P.media.type==="Sound"?u.jsxs(xn,{media:P.media,mediaControlsDeps:y,children:[ee,a?a(P):null]}):P.media.type==="Video"?u.jsxs(Sn,{media:P.media,mediaControlsDeps:y,children:[ee,a?a(P):null]}):P.media.type==="VideoYouTube"&&T?u.jsxs(_r,{media:P.media,mediaControlsDeps:y,children:[ee,a?a(P):null]}):null}):null]},`${j.id}/${P.type}/${pe}`),P.type==="media"&&P.media.type==="Sound"&&Z?u.jsx(Ve,{canvas:Z.id,children:u.jsx(Rn,{renderViewerControls:i})}):null]})}function Ln(){const e=c.useContext(ke);return e&&e.vault?e.vault:Ye.globalVault()}const Dr=c.forwardRef(function(t,n){const o=ve(),r=at(),s=dt(),{ViewerControls:i,MediaControls:a}=t.components||{};if(c.useImperativeHandle(n,()=>s,[s]),!o)return u.jsx("div",{});let p=0;return u.jsxs(u.Fragment,{children:[t.header,u.jsx(de.Viewer,{height:t.height,mode:t.mode,children:r.map((y,f)=>{const g=p;return p+=y.width+(t.spacing||0),u.jsx(Ve,{canvas:y.id,children:u.jsx(de.RenderCanvas,{strategies:["3d-model","media","images","empty","textual-content"],renderViewerControls:f===0&&i?()=>u.jsx(i,{}):void 0,renderMediaControls:f===0&&a?()=>u.jsx(a,{}):void 0,x:g,...t.canvasProps||{},children:t.annotations},y.id)},y.id)})},t.reuseAtlas?"":s.currentSequenceIndex),t.children]})}),de=c.forwardRef(function({children:t,height:n,annotations:o,canvasProps:r,spacing:s,header:i,components:a,mode:p,reuseAtlas:y,...f},g){const O=Ln();return u.jsx(it,{vault:O,children:u.jsx(Vt,{...f,children:u.jsx(Dr,{ref:g,height:n,components:a,spacing:s,canvasProps:r,annotations:o,header:i,mode:p,reuseAtlas:y,children:t})})})});de.RenderImage=Xt;de.RenderCanvas=Rn;de.RenderAnnotationPage=rt;de.RenderAnnotation=Qt;de.Viewer=br;de.CanvasBackground=On;de.Audio=xn;de.Video=Sn;de.Model=jn;de.AudioHTML=bn;de.VideoHTML=wn;de.ModelHTML=Pn;const qr=c.forwardRef(function({canvasId:t},n){const o=Oe.useCanvas(),r=gt(t||(o==null?void 0:o.id)),s=J();return c.useImperativeHandle(n,()=>r,[t,o]),!o||r.enabledPageIds.length===0?null:u.jsx(u.Fragment,{children:r.enabledPageIds.map(i=>u.jsx(de.RenderAnnotationPage,{page:s.get(i)},i))})});function bt({metadata:e=[],config:t,labelWidth:n=16,showEmptyMessage:o=!0,allowHtml:r,emptyFallback:s,classes:i={},emptyMessage:a="No metadata available",emptyValueFallback:p="No value",emptyLabelFallback:y="",separator:f,tableFooter:g,tableHeader:O}){const R=c.useMemo(()=>{const x=(t||[]).reduce((I,k)=>[...I,...k.keys],[]),T={};for(const I of e){const k=I&&I.label?Object.values(I.label):[];for(const j of k)if(j&&j.length&&(x.indexOf(`metadata.${j[0]}`)!==-1||x.length===0)&&I){const B=`metadata.${j[0]}`;T[B]=T[B]?T[B]:[],T[B].push(I);break}}return T},[t,e]);return Object.keys(R).length===0&&o?u.jsx(u.Fragment,{children:s})||u.jsx("div",{className:i.empty,children:a}):t&&t.length?u.jsxs("table",{className:i.container,children:[O,u.jsx("tbody",{children:t.map((x,T)=>{const I=[];for(const k of x.keys)for(const j of R[k]||[])I.push(u.jsx(je,{enableDangerouslySetInnerHTML:r,defaultText:p,separator:f,children:j.value},T+"__"+k));return I.length===0?null:u.jsxs("tr",{className:i.row,children:[u.jsx("td",{className:i.label,style:n?{minWidth:n}:{},children:u.jsx(je,{enableDangerouslySetInnerHTML:r,separator:f,defaultText:y,children:x.label})}),u.jsx("td",{className:i.value,children:I})]},T)})}),g]}):u.jsxs("table",{className:i.container,children:[O,u.jsx("tbody",{children:e&&e.length?e.map((x,T)=>x?u.jsxs("tr",{className:i.row,children:[u.jsx("td",{className:i.label,style:n?{minWidth:n}:{},children:u.jsx(je,{enableDangerouslySetInnerHTML:r,defaultText:p,separator:f,children:x.label})}),u.jsx("td",{className:i.value,children:u.jsx(je,{enableDangerouslySetInnerHTML:r,defaultText:p,separator:f,children:x.value})})]},T):null):null}),g]})}function Fr(e){const t=ve(),n=ye(),o=ft(),r=c.useMemo(()=>{const s=(t==null?void 0:t.metadata)||[],i=(n==null?void 0:n.metadata)||[],a=(o==null?void 0:o.metadata)||[];return[...s,...i,...a]},[t,n,o]);return u.jsx(bt,{metadata:r,...e})}function xt(e,t={},n=[]){return c.useMemo(()=>{var i,a;if(!e)return null;let o=t.quality;e&&e.extraQualities&&t.quality&&(e.extraQualities.includes(t.quality)||(console.log("Invalid quality",t.quality,e.extraQualities),o="default"));const r=Ee.createImageServiceRequest(e);return Ee.imageServiceRequestToString({identifier:r.identifier,server:r.server,scheme:r.scheme,type:"image",size:{max:!((i=t.size)!=null&&i.width)&&!((a=t.size)!=null&&a.height),confined:!1,upscaled:!1,...t.size||{}},format:t.format||"jpg",region:t.region||{full:!0},rotation:t!=null&&t.rotation?Number.isInteger(t.rotation)?{angle:t.rotation}:t.rotation:{angle:0},quality:o||"default",prefix:r.prefix,originalPath:r.originalPath})},[...n])}function Br(e){const t=typeof e.src=="string"?e.src:e.src.id,n=De(),[o,r]=c.useState(!1);let s;if(t){const a=n.loadServiceSync({id:t});a&&(s=a)}!s&&!o&&n.loadService({id:t}).then(()=>{r(!0)});const i=xt(s,{size:e.size,selector:e.region,rotation:e.rotation,format:e.format,region:e.region,quality:e.quality},[o,e.src,e.size,e.region,e.rotation,e.format,e.region,e.quality]);return c.useEffect(()=>()=>{r(!1)},[t]),i?u.jsx("img",{src:i,alt:e.alt,className:e.className,style:e.style}):u.jsx(An,{...e,fetchImageService:!1})}function An(e){if(e.fetchImageService)return u.jsx(Br,{...e});const t=typeof e.src=="string"?{id:e.src,profile:"level0"}:e.src,n=xt(t,{size:e.size,selector:e.region,rotation:e.rotation,format:e.format,region:e.region,quality:e.quality},[e.src,e.size,e.region,e.rotation,e.format,e.region,e.quality]);return n?u.jsx("img",{src:n,alt:e.alt,className:e.className,style:e.style}):null}function Ur(e){const t=ve();return u.jsx(bt,{metadata:(t==null?void 0:t.metadata)||[],...e})}var kn={exports:{}};(()=>{var e={296:(r,s,i)=>{var a=/^\s+|\s+$/g,p=/^[-+]0x[0-9a-f]+$/i,y=/^0b[01]+$/i,f=/^0o[0-7]+$/i,g=parseInt,O=typeof i.g=="object"&&i.g&&i.g.Object===Object&&i.g,R=typeof self=="object"&&self&&self.Object===Object&&self,E=O||R||Function("return this")(),x=Object.prototype.toString,T=Math.max,I=Math.min,k=function(){return E.Date.now()};function j(A){var L=typeof A;return!!A&&(L=="object"||L=="function")}function B(A){if(typeof A=="number")return A;if(function(M){return typeof M=="symbol"||function(P){return!!P&&typeof P=="object"}(M)&&x.call(M)=="[object Symbol]"}(A))return NaN;if(j(A)){var L=typeof A.valueOf=="function"?A.valueOf():A;A=j(L)?L+"":L}if(typeof A!="string")return A===0?A:+A;A=A.replace(a,"");var q=y.test(A);return q||f.test(A)?g(A.slice(2),q?2:8):p.test(A)?NaN:+A}r.exports=function(A,L,q){var M,P,U,W,Q,Y,Z=0,ee=!1,oe=!1,pe=!0;if(typeof A!="function")throw new TypeError("Expected a function");function N(ne){var re=M,ce=P;return M=P=void 0,Z=ne,W=A.apply(ce,re)}function te(ne){var re=ne-Y;return Y===void 0||re>=L||re<0||oe&&ne-Z>=U}function $(){var ne=k();if(te(ne))return ae(ne);Q=setTimeout($,function(re){var ce=L-(re-Y);return oe?I(ce,U-(re-Z)):ce}(ne))}function ae(ne){return Q=void 0,pe&&M?N(ne):(M=P=void 0,W)}function ue(){var ne=k(),re=te(ne);if(M=arguments,P=this,Y=ne,re){if(Q===void 0)return function(ce){return Z=ce,Q=setTimeout($,L),ee?N(ce):W}(Y);if(oe)return Q=setTimeout($,L),N(Y)}return Q===void 0&&(Q=setTimeout($,L)),W}return L=B(L)||0,j(q)&&(ee=!!q.leading,U=(oe="maxWait"in q)?T(B(q.maxWait)||0,L):U,pe="trailing"in q?!!q.trailing:pe),ue.cancel=function(){Q!==void 0&&clearTimeout(Q),Z=0,M=Y=P=Q=void 0},ue.flush=function(){return Q===void 0?W:ae(k())},ue}},96:(r,s,i)=>{var a="Expected a function",p=NaN,y="[object Symbol]",f=/^\s+|\s+$/g,g=/^[-+]0x[0-9a-f]+$/i,O=/^0b[01]+$/i,R=/^0o[0-7]+$/i,E=parseInt,x=typeof i.g=="object"&&i.g&&i.g.Object===Object&&i.g,T=typeof self=="object"&&self&&self.Object===Object&&self,I=x||T||Function("return this")(),k=Object.prototype.toString,j=Math.max,B=Math.min,A=function(){return I.Date.now()};function L(M){var P=typeof M;return!!M&&(P=="object"||P=="function")}function q(M){if(typeof M=="number")return M;if(function(W){return typeof W=="symbol"||function(Q){return!!Q&&typeof Q=="object"}(W)&&k.call(W)==y}(M))return p;if(L(M)){var P=typeof M.valueOf=="function"?M.valueOf():M;M=L(P)?P+"":P}if(typeof M!="string")return M===0?M:+M;M=M.replace(f,"");var U=O.test(M);return U||R.test(M)?E(M.slice(2),U?2:8):g.test(M)?p:+M}r.exports=function(M,P,U){var W=!0,Q=!0;if(typeof M!="function")throw new TypeError(a);return L(U)&&(W="leading"in U?!!U.leading:W,Q="trailing"in U?!!U.trailing:Q),function(Y,Z,ee){var oe,pe,N,te,$,ae,ue=0,ne=!1,re=!1,ce=!0;if(typeof Y!="function")throw new TypeError(a);function Me(le){var he=oe,me=pe;return oe=pe=void 0,ue=le,te=Y.apply(me,he)}function qe(le){var he=le-ae;return ae===void 0||he>=Z||he<0||re&&le-ue>=N}function ge(){var le=A();if(qe(le))return Fe(le);$=setTimeout(ge,function(he){var me=Z-(he-ae);return re?B(me,N-(he-ue)):me}(le))}function Fe(le){return $=void 0,ce&&oe?Me(le):(oe=pe=void 0,te)}function Se(){var le=A(),he=qe(le);if(oe=arguments,pe=this,ae=le,he){if($===void 0)return function(me){return ue=me,$=setTimeout(ge,Z),ne?Me(me):te}(ae);if(re)return $=setTimeout(ge,Z),Me(ae)}return $===void 0&&($=setTimeout(ge,Z)),te}return Z=q(Z)||0,L(ee)&&(ne=!!ee.leading,N=(re="maxWait"in ee)?j(q(ee.maxWait)||0,Z):N,ce="trailing"in ee?!!ee.trailing:ce),Se.cancel=function(){$!==void 0&&clearTimeout($),ue=0,oe=ae=pe=$=void 0},Se.flush=function(){return $===void 0?te:Fe(A())},Se}(M,P,{leading:W,maxWait:P,trailing:Q})}},703:(r,s,i)=>{var a=i(414);function p(){}function y(){}y.resetWarningCache=p,r.exports=function(){function f(R,E,x,T,I,k){if(k!==a){var j=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw j.name="Invariant Violation",j}}function g(){return f}f.isRequired=f;var O={array:f,bigint:f,bool:f,func:f,number:f,object:f,string:f,symbol:f,any:f,arrayOf:g,element:f,elementType:f,instanceOf:g,node:f,objectOf:g,oneOf:g,oneOfType:g,shape:g,exact:g,checkPropTypes:y,resetWarningCache:p};return O.PropTypes=O,O}},697:(r,s,i)=>{r.exports=i(703)()},414:r=>{r.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"}},t={};function n(r){var s=t[r];if(s!==void 0)return s.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.n=r=>{var s=r&&r.__esModule?()=>r.default:()=>r;return n.d(s,{a:s}),s},n.d=(r,s)=>{for(var i in s)n.o(s,i)&&!n.o(r,i)&&Object.defineProperty(r,i,{enumerable:!0,get:s[i]})},n.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),n.o=(r,s)=>Object.prototype.hasOwnProperty.call(r,s),n.r=r=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})};var o={};(()=>{n.r(o),n.d(o,{LazyLoadComponent:()=>wt,LazyLoadImage:()=>Bn,trackWindowScroll:()=>ae});const r=c;var s=n.n(r),i=n(697);const a=Hn;var p=n.n(a);function y(){return typeof window<"u"&&"IntersectionObserver"in window&&"isIntersecting"in window.IntersectionObserverEntry.prototype}function f(m){return f=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(l){return typeof l}:function(l){return l&&typeof Symbol=="function"&&l.constructor===Symbol&&l!==Symbol.prototype?"symbol":typeof l},f(m)}function g(m,l){var v=Object.keys(m);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(m);l&&(b=b.filter(function(V){return Object.getOwnPropertyDescriptor(m,V).enumerable})),v.push.apply(v,b)}return v}function O(m,l,v){return(l=E(l))in m?Object.defineProperty(m,l,{value:v,enumerable:!0,configurable:!0,writable:!0}):m[l]=v,m}function R(m,l){for(var v=0;v<l.length;v++){var b=l[v];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(m,E(b.key),b)}}function E(m){var l=function(v,b){if(f(v)!=="object"||v===null)return v;var V=v[Symbol.toPrimitive];if(V!==void 0){var _=V.call(v,"string");if(f(_)!=="object")return _;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(v)}(m);return f(l)==="symbol"?l:String(l)}function x(m,l){return x=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(v,b){return v.__proto__=b,v},x(m,l)}function T(m){return T=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(l){return l.__proto__||Object.getPrototypeOf(l)},T(m)}var I=function(m){m.forEach(function(l){l.isIntersecting&&l.target.onVisible()})},k={},j=function(m){(function(d,h){if(typeof h!="function"&&h!==null)throw new TypeError("Super expression must either be null or a function");d.prototype=Object.create(h&&h.prototype,{constructor:{value:d,writable:!0,configurable:!0}}),Object.defineProperty(d,"prototype",{writable:!1}),h&&x(d,h)})(F,m);var l,v,b,V,_=(b=F,V=function(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}(),function(){var d,h=T(b);if(V){var C=T(this).constructor;d=Reflect.construct(h,arguments,C)}else d=h.apply(this,arguments);return function(S,w){if(w&&(f(w)==="object"||typeof w=="function"))return w;if(w!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return function(D){if(D===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return D}(S)}(this,d)});function F(d){var h;if(function(S,w){if(!(S instanceof w))throw new TypeError("Cannot call a class as a function")}(this,F),(h=_.call(this,d)).supportsObserver=!d.scrollPosition&&d.useIntersectionObserver&&y(),h.supportsObserver){var C=d.threshold;h.observer=function(S){return k[S]=k[S]||new IntersectionObserver(I,{rootMargin:S+"px"}),k[S]}(C)}return h}return l=F,v=[{key:"componentDidMount",value:function(){this.placeholder&&this.observer&&(this.placeholder.onVisible=this.props.onVisible,this.observer.observe(this.placeholder)),this.supportsObserver||this.updateVisibility()}},{key:"componentWillUnmount",value:function(){this.observer&&this.placeholder&&this.observer.unobserve(this.placeholder)}},{key:"componentDidUpdate",value:function(){this.supportsObserver||this.updateVisibility()}},{key:"getPlaceholderBoundingBox",value:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.props.scrollPosition,h=this.placeholder.getBoundingClientRect(),C=p().findDOMNode(this.placeholder).style,S=parseInt(C.getPropertyValue("margin-left"),10)||0,w=parseInt(C.getPropertyValue("margin-top"),10)||0;return{bottom:d.y+h.bottom+w,left:d.x+h.left+S,right:d.x+h.right+S,top:d.y+h.top+w}}},{key:"isPlaceholderInViewport",value:function(){if(typeof window>"u"||!this.placeholder)return!1;var d=this.props,h=d.scrollPosition,C=d.threshold,S=this.getPlaceholderBoundingBox(h),w=h.y+window.innerHeight,D=h.x,z=h.x+window.innerWidth,K=h.y;return K-C<=S.bottom&&w+C>=S.top&&D-C<=S.right&&z+C>=S.left}},{key:"updateVisibility",value:function(){this.isPlaceholderInViewport()&&this.props.onVisible()}},{key:"render",value:function(){var d=this,h=this.props,C=h.className,S=h.height,w=h.placeholder,D=h.style,z=h.width;if(w&&typeof w.type!="function")return s().cloneElement(w,{ref:function(H){return d.placeholder=H}});var K=function(H){for(var ie=1;ie<arguments.length;ie++){var G=arguments[ie]!=null?arguments[ie]:{};ie%2?g(Object(G),!0).forEach(function(fe){O(H,fe,G[fe])}):Object.getOwnPropertyDescriptors?Object.defineProperties(H,Object.getOwnPropertyDescriptors(G)):g(Object(G)).forEach(function(fe){Object.defineProperty(H,fe,Object.getOwnPropertyDescriptor(G,fe))})}return H}({display:"inline-block"},D);return z!==void 0&&(K.width=z),S!==void 0&&(K.height=S),s().createElement("span",{className:C,ref:function(H){return d.placeholder=H},style:K},w)}}],v&&R(l.prototype,v),Object.defineProperty(l,"prototype",{writable:!1}),F}(s().Component);j.propTypes={onVisible:i.PropTypes.func.isRequired,className:i.PropTypes.string,height:i.PropTypes.oneOfType([i.PropTypes.number,i.PropTypes.string]),placeholder:i.PropTypes.element,threshold:i.PropTypes.number,useIntersectionObserver:i.PropTypes.bool,scrollPosition:i.PropTypes.shape({x:i.PropTypes.number.isRequired,y:i.PropTypes.number.isRequired}),width:i.PropTypes.oneOfType([i.PropTypes.number,i.PropTypes.string])},j.defaultProps={className:"",placeholder:null,threshold:100,useIntersectionObserver:!0};const B=j;var A=n(296),L=n.n(A),q=n(96),M=n.n(q),P=function(m){var l=getComputedStyle(m,null);return l.getPropertyValue("overflow")+l.getPropertyValue("overflow-y")+l.getPropertyValue("overflow-x")};const U=function(m){if(!(m instanceof HTMLElement))return window;for(var l=m;l&&l instanceof HTMLElement;){if(/(scroll|auto)/.test(P(l)))return l;l=l.parentNode}return window};function W(m){return W=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(l){return typeof l}:function(l){return l&&typeof Symbol=="function"&&l.constructor===Symbol&&l!==Symbol.prototype?"symbol":typeof l},W(m)}var Q=["delayMethod","delayTime"];function Y(){return Y=Object.assign?Object.assign.bind():function(m){for(var l=1;l<arguments.length;l++){var v=arguments[l];for(var b in v)Object.prototype.hasOwnProperty.call(v,b)&&(m[b]=v[b])}return m},Y.apply(this,arguments)}function Z(m,l){for(var v=0;v<l.length;v++){var b=l[v];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(m,(V=function(_,F){if(W(_)!=="object"||_===null)return _;var d=_[Symbol.toPrimitive];if(d!==void 0){var h=d.call(_,"string");if(W(h)!=="object")return h;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(_)}(b.key),W(V)==="symbol"?V:String(V)),b)}var V}function ee(m,l){return ee=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(v,b){return v.__proto__=b,v},ee(m,l)}function oe(m,l){if(l&&(W(l)==="object"||typeof l=="function"))return l;if(l!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return pe(m)}function pe(m){if(m===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return m}function N(m){return N=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(l){return l.__proto__||Object.getPrototypeOf(l)},N(m)}var te=function(){return typeof window>"u"?0:window.scrollX||window.pageXOffset},$=function(){return typeof window>"u"?0:window.scrollY||window.pageYOffset};const ae=function(m){var l=function(v){(function(C,S){if(typeof S!="function"&&S!==null)throw new TypeError("Super expression must either be null or a function");C.prototype=Object.create(S&&S.prototype,{constructor:{value:C,writable:!0,configurable:!0}}),Object.defineProperty(C,"prototype",{writable:!1}),S&&ee(C,S)})(h,v);var b,V,_,F,d=(_=h,F=function(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}(),function(){var C,S=N(_);if(F){var w=N(this).constructor;C=Reflect.construct(S,arguments,w)}else C=S.apply(this,arguments);return oe(this,C)});function h(C){var S;if(function(D,z){if(!(D instanceof z))throw new TypeError("Cannot call a class as a function")}(this,h),(S=d.call(this,C)).useIntersectionObserver=C.useIntersectionObserver&&y(),S.useIntersectionObserver)return oe(S);var w=S.onChangeScroll.bind(pe(S));return C.delayMethod==="debounce"?S.delayedScroll=L()(w,C.delayTime):C.delayMethod==="throttle"&&(S.delayedScroll=M()(w,C.delayTime)),S.state={scrollPosition:{x:te(),y:$()}},S.baseComponentRef=s().createRef(),S}return b=h,(V=[{key:"componentDidMount",value:function(){this.addListeners()}},{key:"componentWillUnmount",value:function(){this.removeListeners()}},{key:"componentDidUpdate",value:function(){typeof window>"u"||this.useIntersectionObserver||U(p().findDOMNode(this.baseComponentRef.current))!==this.scrollElement&&(this.removeListeners(),this.addListeners())}},{key:"addListeners",value:function(){typeof window>"u"||this.useIntersectionObserver||(this.scrollElement=U(p().findDOMNode(this.baseComponentRef.current)),this.scrollElement.addEventListener("scroll",this.delayedScroll,{passive:!0}),window.addEventListener("resize",this.delayedScroll,{passive:!0}),this.scrollElement!==window&&window.addEventListener("scroll",this.delayedScroll,{passive:!0}))}},{key:"removeListeners",value:function(){typeof window>"u"||this.useIntersectionObserver||(this.scrollElement.removeEventListener("scroll",this.delayedScroll),window.removeEventListener("resize",this.delayedScroll),this.scrollElement!==window&&window.removeEventListener("scroll",this.delayedScroll))}},{key:"onChangeScroll",value:function(){this.useIntersectionObserver||this.setState({scrollPosition:{x:te(),y:$()}})}},{key:"render",value:function(){var C=this.props,S=(C.delayMethod,C.delayTime,function(D,z){if(D==null)return{};var K,H,ie=function(fe,Te){if(fe==null)return{};var Pe,$e,Ot={},Ct=Object.keys(fe);for($e=0;$e<Ct.length;$e++)Pe=Ct[$e],Te.indexOf(Pe)>=0||(Ot[Pe]=fe[Pe]);return Ot}(D,z);if(Object.getOwnPropertySymbols){var G=Object.getOwnPropertySymbols(D);for(H=0;H<G.length;H++)K=G[H],z.indexOf(K)>=0||Object.prototype.propertyIsEnumerable.call(D,K)&&(ie[K]=D[K])}return ie}(C,Q)),w=this.useIntersectionObserver?null:this.state.scrollPosition;return s().createElement(m,Y({forwardRef:this.baseComponentRef,scrollPosition:w},S))}}])&&Z(b.prototype,V),Object.defineProperty(b,"prototype",{writable:!1}),h}(s().Component);return l.propTypes={delayMethod:i.PropTypes.oneOf(["debounce","throttle"]),delayTime:i.PropTypes.number,useIntersectionObserver:i.PropTypes.bool},l.defaultProps={delayMethod:"throttle",delayTime:300,useIntersectionObserver:!0},l};function ue(m){return ue=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(l){return typeof l}:function(l){return l&&typeof Symbol=="function"&&l.constructor===Symbol&&l!==Symbol.prototype?"symbol":typeof l},ue(m)}function ne(m,l){for(var v=0;v<l.length;v++){var b=l[v];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(m,(V=function(_,F){if(ue(_)!=="object"||_===null)return _;var d=_[Symbol.toPrimitive];if(d!==void 0){var h=d.call(_,"string");if(ue(h)!=="object")return h;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(_)}(b.key),ue(V)==="symbol"?V:String(V)),b)}var V}function re(m,l){return re=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(v,b){return v.__proto__=b,v},re(m,l)}function ce(m){return ce=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(l){return l.__proto__||Object.getPrototypeOf(l)},ce(m)}var Me=function(m){(function(d,h){if(typeof h!="function"&&h!==null)throw new TypeError("Super expression must either be null or a function");d.prototype=Object.create(h&&h.prototype,{constructor:{value:d,writable:!0,configurable:!0}}),Object.defineProperty(d,"prototype",{writable:!1}),h&&re(d,h)})(F,m);var l,v,b,V,_=(b=F,V=function(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}(),function(){var d,h=ce(b);if(V){var C=ce(this).constructor;d=Reflect.construct(h,arguments,C)}else d=h.apply(this,arguments);return function(S,w){if(w&&(ue(w)==="object"||typeof w=="function"))return w;if(w!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return function(D){if(D===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return D}(S)}(this,d)});function F(d){return function(h,C){if(!(h instanceof C))throw new TypeError("Cannot call a class as a function")}(this,F),_.call(this,d)}return l=F,(v=[{key:"render",value:function(){return s().createElement(B,this.props)}}])&&ne(l.prototype,v),Object.defineProperty(l,"prototype",{writable:!1}),F}(s().Component);const qe=ae(Me);function ge(m){return ge=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(l){return typeof l}:function(l){return l&&typeof Symbol=="function"&&l.constructor===Symbol&&l!==Symbol.prototype?"symbol":typeof l},ge(m)}function Fe(m,l){for(var v=0;v<l.length;v++){var b=l[v];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(m,(V=function(_,F){if(ge(_)!=="object"||_===null)return _;var d=_[Symbol.toPrimitive];if(d!==void 0){var h=d.call(_,"string");if(ge(h)!=="object")return h;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(_)}(b.key),ge(V)==="symbol"?V:String(V)),b)}var V}function Se(m,l){return Se=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(v,b){return v.__proto__=b,v},Se(m,l)}function le(m){if(m===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return m}function he(m){return he=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(l){return l.__proto__||Object.getPrototypeOf(l)},he(m)}var me=function(m){(function(d,h){if(typeof h!="function"&&h!==null)throw new TypeError("Super expression must either be null or a function");d.prototype=Object.create(h&&h.prototype,{constructor:{value:d,writable:!0,configurable:!0}}),Object.defineProperty(d,"prototype",{writable:!1}),h&&Se(d,h)})(F,m);var l,v,b,V,_=(b=F,V=function(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}(),function(){var d,h=he(b);if(V){var C=he(this).constructor;d=Reflect.construct(h,arguments,C)}else d=h.apply(this,arguments);return function(S,w){if(w&&(ge(w)==="object"||typeof w=="function"))return w;if(w!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return le(S)}(this,d)});function F(d){var h;(function(z,K){if(!(z instanceof K))throw new TypeError("Cannot call a class as a function")})(this,F),h=_.call(this,d);var C=d.afterLoad,S=d.beforeLoad,w=d.scrollPosition,D=d.visibleByDefault;return h.state={visible:D},D&&(S(),C()),h.onVisible=h.onVisible.bind(le(h)),h.isScrollTracked=!!(w&&Number.isFinite(w.x)&&w.x>=0&&Number.isFinite(w.y)&&w.y>=0),h}return l=F,(v=[{key:"componentDidUpdate",value:function(d,h){h.visible!==this.state.visible&&this.props.afterLoad()}},{key:"onVisible",value:function(){this.props.beforeLoad(),this.setState({visible:!0})}},{key:"render",value:function(){if(this.state.visible)return this.props.children;var d=this.props,h=d.className,C=d.delayMethod,S=d.delayTime,w=d.height,D=d.placeholder,z=d.scrollPosition,K=d.style,H=d.threshold,ie=d.useIntersectionObserver,G=d.width;return this.isScrollTracked||ie&&y()?s().createElement(B,{className:h,height:w,onVisible:this.onVisible,placeholder:D,scrollPosition:z,style:K,threshold:H,useIntersectionObserver:ie,width:G}):s().createElement(qe,{className:h,delayMethod:C,delayTime:S,height:w,onVisible:this.onVisible,placeholder:D,style:K,threshold:H,width:G})}}])&&Fe(l.prototype,v),Object.defineProperty(l,"prototype",{writable:!1}),F}(s().Component);me.propTypes={afterLoad:i.PropTypes.func,beforeLoad:i.PropTypes.func,useIntersectionObserver:i.PropTypes.bool,visibleByDefault:i.PropTypes.bool},me.defaultProps={afterLoad:function(){return{}},beforeLoad:function(){return{}},useIntersectionObserver:!0,visibleByDefault:!1};const wt=me;function Ce(m){return Ce=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(l){return typeof l}:function(l){return l&&typeof Symbol=="function"&&l.constructor===Symbol&&l!==Symbol.prototype?"symbol":typeof l},Ce(m)}var Dn=["afterLoad","beforeLoad","delayMethod","delayTime","effect","placeholder","placeholderSrc","scrollPosition","threshold","useIntersectionObserver","visibleByDefault","wrapperClassName","wrapperProps"];function St(m,l){var v=Object.keys(m);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(m);l&&(b=b.filter(function(V){return Object.getOwnPropertyDescriptor(m,V).enumerable})),v.push.apply(v,b)}return v}function Pt(m){for(var l=1;l<arguments.length;l++){var v=arguments[l]!=null?arguments[l]:{};l%2?St(Object(v),!0).forEach(function(b){qn(m,b,v[b])}):Object.getOwnPropertyDescriptors?Object.defineProperties(m,Object.getOwnPropertyDescriptors(v)):St(Object(v)).forEach(function(b){Object.defineProperty(m,b,Object.getOwnPropertyDescriptor(v,b))})}return m}function qn(m,l,v){return(l=jt(l))in m?Object.defineProperty(m,l,{value:v,enumerable:!0,configurable:!0,writable:!0}):m[l]=v,m}function Be(){return Be=Object.assign?Object.assign.bind():function(m){for(var l=1;l<arguments.length;l++){var v=arguments[l];for(var b in v)Object.prototype.hasOwnProperty.call(v,b)&&(m[b]=v[b])}return m},Be.apply(this,arguments)}function Fn(m,l){for(var v=0;v<l.length;v++){var b=l[v];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(m,jt(b.key),b)}}function jt(m){var l=function(v,b){if(Ce(v)!=="object"||v===null)return v;var V=v[Symbol.toPrimitive];if(V!==void 0){var _=V.call(v,"string");if(Ce(_)!=="object")return _;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(v)}(m);return Ce(l)==="symbol"?l:String(l)}function Ze(m,l){return Ze=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(v,b){return v.__proto__=b,v},Ze(m,l)}function Ue(m){return Ue=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(l){return l.__proto__||Object.getPrototypeOf(l)},Ue(m)}var et=function(m){(function(d,h){if(typeof h!="function"&&h!==null)throw new TypeError("Super expression must either be null or a function");d.prototype=Object.create(h&&h.prototype,{constructor:{value:d,writable:!0,configurable:!0}}),Object.defineProperty(d,"prototype",{writable:!1}),h&&Ze(d,h)})(F,m);var l,v,b,V,_=(b=F,V=function(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}(),function(){var d,h=Ue(b);if(V){var C=Ue(this).constructor;d=Reflect.construct(h,arguments,C)}else d=h.apply(this,arguments);return function(S,w){if(w&&(Ce(w)==="object"||typeof w=="function"))return w;if(w!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return function(D){if(D===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return D}(S)}(this,d)});function F(d){var h;return function(C,S){if(!(C instanceof S))throw new TypeError("Cannot call a class as a function")}(this,F),(h=_.call(this,d)).state={loaded:!1},h}return l=F,(v=[{key:"onImageLoad",value:function(){var d=this;return this.state.loaded?null:function(h){d.props.onLoad(h),d.props.afterLoad(),d.setState({loaded:!0})}}},{key:"getImg",value:function(){var d=this.props,h=(d.afterLoad,d.beforeLoad,d.delayMethod,d.delayTime,d.effect,d.placeholder,d.placeholderSrc,d.scrollPosition,d.threshold,d.useIntersectionObserver,d.visibleByDefault,d.wrapperClassName,d.wrapperProps,function(C,S){if(C==null)return{};var w,D,z=function(H,ie){if(H==null)return{};var G,fe,Te={},Pe=Object.keys(H);for(fe=0;fe<Pe.length;fe++)G=Pe[fe],ie.indexOf(G)>=0||(Te[G]=H[G]);return Te}(C,S);if(Object.getOwnPropertySymbols){var K=Object.getOwnPropertySymbols(C);for(D=0;D<K.length;D++)w=K[D],S.indexOf(w)>=0||Object.prototype.propertyIsEnumerable.call(C,w)&&(z[w]=C[w])}return z}(d,Dn));return s().createElement("img",Be({},h,{onLoad:this.onImageLoad()}))}},{key:"getLazyLoadImage",value:function(){var d=this.props,h=d.beforeLoad,C=d.className,S=d.delayMethod,w=d.delayTime,D=d.height,z=d.placeholder,K=d.scrollPosition,H=d.style,ie=d.threshold,G=d.useIntersectionObserver,fe=d.visibleByDefault,Te=d.width;return s().createElement(wt,{beforeLoad:h,className:C,delayMethod:S,delayTime:w,height:D,placeholder:z,scrollPosition:K,style:H,threshold:ie,useIntersectionObserver:G,visibleByDefault:fe,width:Te},this.getImg())}},{key:"getWrappedLazyLoadImage",value:function(d){var h=this.props,C=h.effect,S=h.height,w=h.placeholderSrc,D=h.width,z=h.wrapperClassName,K=h.wrapperProps,H=this.state.loaded,ie=H?" lazy-load-image-loaded":"",G=H||!w?{}:{backgroundImage:"url(".concat(w,")"),backgroundSize:"100% 100%"};return s().createElement("span",Be({className:z+" lazy-load-image-background "+C+ie,style:Pt(Pt({},G),{},{color:"transparent",display:"inline-block",height:S,width:D})},K),d)}},{key:"render",value:function(){var d=this.props,h=d.effect,C=d.placeholderSrc,S=d.visibleByDefault,w=d.wrapperClassName,D=d.wrapperProps,z=this.getLazyLoadImage();return(h||C)&&!S||w||D?this.getWrappedLazyLoadImage(z):z}}])&&Fn(l.prototype,v),Object.defineProperty(l,"prototype",{writable:!1}),F}(s().Component);et.propTypes={onLoad:i.PropTypes.func,afterLoad:i.PropTypes.func,beforeLoad:i.PropTypes.func,delayMethod:i.PropTypes.string,delayTime:i.PropTypes.number,effect:i.PropTypes.string,placeholderSrc:i.PropTypes.string,threshold:i.PropTypes.number,useIntersectionObserver:i.PropTypes.bool,visibleByDefault:i.PropTypes.bool,wrapperClassName:i.PropTypes.string,wrapperProps:i.PropTypes.object},et.defaultProps={onLoad:function(){},afterLoad:function(){return{}},beforeLoad:function(){return{}},delayMethod:"throttle",delayTime:300,effect:"",placeholderSrc:null,threshold:100,useIntersectionObserver:!0,visibleByDefault:!1,wrapperClassName:""};const Bn=et})(),kn.exports=o})();var $r=kn.exports;function Hr(e,t,n=[],o=!1,r=[]){if(r.length&&(t=t.filter(i=>r.indexOf(i)===-1)),!t||t.length===0)return;if(t.length===1)return t[0];if(!e)return t.indexOf("none")!==-1?"none":t[0];if(t.indexOf(e)!==-1)return e;const s=e.indexOf("-")!==-1?e.slice(0,e.indexOf("-")):null;if(s&&t.indexOf(s)!==-1)return s;for(const i of n)if(t.indexOf(i)!==-1)return i;if(!o&&e){const i=t.map(a=>a.indexOf("-")!==-1?a.slice(0,a.indexOf("-")):null).indexOf(e);if(i!==-1)return t[i];for(const a of n){const p=a.indexOf("-")!==-1?a.slice(0,a.indexOf("-")):null,y=p?t.indexOf(p):-1;if(y!==-1)return t[y]}}return t.indexOf("none")!==-1?"none":t.indexOf("@none")!==-1?"@none":t[0]}function Vn(e,t,n={}){const{strictFallback:o=!1,defaultText:r="",separator:s=`
48
+ `,fallbackLanguages:i=[],closest:a,skipLanguages:p}=n,y=Object.keys(e||{}),f=a?t:Hr(t,y,i,o,p);if(!e)return r;if(typeof e=="string")return e;const g=f?e[f]:void 0;if(g&&f){if(typeof g=="string")return g;if(g.length===1&&g[0]===""){const O=n.skipLanguages||[];return Vn(e,t,{...n,skipLanguages:[...O,f]})}return g.join(s)}return""}function Wr(e,t={}){return Vn(e,t.language||(typeof navigator<"u"?navigator.language:"en"),t)}const Yr=$r.LazyLoadComponent;function Nn(e){const{size:t,visible:n,classes:o,canvasId:r,figure:s}=e,i=(t==null?void 0:t.width)||128,a=(t==null?void 0:t.height)||(t==null?void 0:t.width)||128,p=u.jsx(zr,{...e}),y=u.jsx(Yr,{threshold:300,style:{height:a,width:i},visibleByDefault:n,children:r?u.jsx(Ve,{canvas:r,children:p}):p});return s?u.jsx("figure",{className:o==null?void 0:o.figure,children:y}):y}function zr({fallback:e,size:t,classes:n,showLabel:o,alt:r,dereference:s=!1}){const i=ye(),a=(t==null?void 0:t.width)||128,p=(t==null?void 0:t.height)||(t==null?void 0:t.width)||128,y=r||Wr(i==null?void 0:i.label)||"",f=mt({width:a,height:p},s);return!f||f.type!=="fixed"?u.jsx(u.Fragment,{children:e}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:n==null?void 0:n.imageWrapper,children:u.jsx("img",{className:n==null?void 0:n.img,src:f.id,alt:y})}),o?u.jsx(je,{as:"figcaption",className:n==null?void 0:n.label,children:i==null?void 0:i.label}):null]})}function Kr({flat:e,size:t,classes:n={},showLabel:o,figure:r,fallback:s}){var R,E,x,T,I,k;const i=c.useRef(null),{items:a,sequence:p,currentSequenceIndex:y,setSequenceIndex:f}=dt(),g={row:((R=n.selected)==null?void 0:R.row)||n.row,item:((E=n.selected)==null?void 0:E.item)||n.item,figure:((x=n.selected)==null?void 0:x.figure)||n.figure,img:((T=n.selected)==null?void 0:T.img)||n.img,label:((I=n.selected)==null?void 0:I.label)||n.label,imageWrapper:((k=n.selected)==null?void 0:k.imageWrapper)||n.imageWrapper};c.useLayoutEffect(()=>{if(!i.current)return;const j=i.current.querySelector("[data-selected=true]");j&&j.scrollIntoView({behavior:"smooth",block:"nearest",inline:"center"})},[y]);const O=[];for(const j of p){const B=[],A=p[y]===j;for(const L of j){const q=a[L];B.push(u.jsx("div",{className:A?g.item:n.item,children:u.jsx(Nn,{classes:A?g:n,canvasId:q.id,size:t,showLabel:o,figure:r,placeholder:u.jsx("div",{style:{height:128,width:128}}),fallback:s})},L))}if(e){O.push(B);continue}O.push(u.jsx("div",{onClick:L=>{f(p.indexOf(j))},"data-selected":A,className:A?g.row:n.row,children:B}))}return u.jsx("div",{ref:i,className:n.container,children:O})}function Qr({annotation:e,children:t}){return u.jsx(we,{value:{annotation:e},children:t})}function Gr({annotationPage:e,children:t}){return u.jsx(we,{value:{annotationPage:e},children:t})}function Xr({collection:e,children:t}){return u.jsx(we,{value:{collection:e},children:t})}function Jr(e,t={}){return Ge(t)}function Zr(e,t=!1){}function eo(e){const n=xe().manifest,o=e?e.map(r=>typeof r=="string"?r:r==null?void 0:r.id):[];return se(r=>{const s=n?r.iiif.entities.Manifest[n]:void 0,i=(s==null?void 0:s.items)||[];if(typeof e>"u")return i;const a=[];for(const p of(s==null?void 0:s.items)||[])o.indexOf(p.id)!==-1&&a.push(p);return a},[o.join("/")])}function to(e,t=[]){const{id:n,selector:o}=e,r=xe(),s=n||r.collection,i=se(a=>s?a.iiif.entities.Collection[s]:void 0,[s]);return c.useMemo(()=>{if(i)return o?o(i):i},[i,o,...t])}function no(e,t,n,o,r=[]){const s=J(),i=c.useMemo(()=>Kt(s),[s]);c.useEffect(()=>{const a=e;return a?(i.addEventListener(a,t,n,o),()=>{i.removeEventListener(a,t,n)}):()=>{}},[i,e,t,...r])}function ro(e,t){const{id:n,isLoaded:o,error:r,resource:s,requestId:i,cached:a}=st(e,t);return{id:n,isLoaded:o,error:r,manifest:s,requestId:i,cached:a}}function _n({cacheKey:e}={}){const t=ye(),n=Ge(),o=J(),r=De(),[s,i]=c.useState(void 0),[a,p]=c.useState(!1),[y,f]=c.useState("idle"),[g,O]=c.useState(void 0),R=t?t.id:"undefined",E=c.useMemo(()=>{try{if(t&&n.length){const T=n[0],I=o.get(T.body[0]),j=Ee.getImageServices(I)[0];return j&&r.loadServiceSync({id:j.id||j["@id"],width:j.width||t.width,height:j.height||t.height})||void 0}}catch(T){console.error(T)}},[R,e,t]),x=y==="success"&&s?s:E;return c.useEffect(()=>{(async()=>{try{if(t&&n.length){const T=n[0],I=o.get(T.body[0]),j=Ee.getImageServices(I)[0];if(!j)return;p(!0),f("loading");try{const B=await r.loadService({id:j.id||j["@id"],width:j.width||t.width,height:j.height||t.height})||void 0;i(B),f("success"),p(!1)}catch(B){f("error"),O(B)}}}catch(T){f("error"),O(T)}})()},[R,e]),c.useMemo(()=>({data:x,isFetching:a,status:y,error:g}),[x,a,y,g])}function oo(){const e=_n();return{isLoading:e.isFetching,tile:e.data?{id:e.data.id||e.data["@id"],width:e.data.width,height:e.data.height,imageService:e.data,thumbnail:void 0}:null}}function io(){const e=ve();return e?e.service.find(t=>t.profile==="SearchService1"||t.profile==="http://iiif.io/api/search/1/search"):void 0}function so(){const e=J();return c.useMemo(()=>ot.createStylesHelper(e),[e])}exports.AnnotationContext=Qr;exports.AnnotationPageContext=Gr;exports.CanvasAnnotations=qr;exports.CanvasContext=Ve;exports.CanvasPanel=de;exports.CollectionContext=Xr;exports.CombinedMetadata=Fr;exports.ContextBridge=_t;exports.Image=An;exports.ImageServiceLoaderContext=nn;exports.InnerViewerProvider=kt;exports.LanguageProvider=kr;exports.LanguageString=Tn;exports.LocaleString=je;exports.ManifestContext=Mt;exports.ManifestMetadata=Ur;exports.MediaPlayerProvider=vt;exports.Metadata=bt;exports.RangeContext=Rt;exports.ReactVaultContext=ke;exports.ResourceProvider=we;exports.ResourceReactContext=Ke;exports.SequenceThumbnails=Kr;exports.SimpleViewerProvider=Vt;exports.SimpleViewerReactContext=_e;exports.SingleCanvasThumbnail=Nn;exports.VaultProvider=it;exports.ViewerPresetContext=Qe;exports.VirtualAnnotationProvider=Ut;exports.VisibleCanvasReactContext=Ne;exports.emptyActions=Jt;exports.emptyStrategy=Zt;exports.findAllCanvasesInRange=ut;exports.findFirstCanvasFromRange=Lt;exports.findManifestSelectedRange=Qn;exports.findSelectedRange=ct;exports.flattenAnnotationPageIds=en;exports.formatTime=yn;exports.get3dStrategy=an;exports.getImageStrategy=un;exports.getManifestSequence=lt;exports.getParsedTargetSelector=yt;exports.getRenderingStrategy=dn;exports.getTextualContentStrategy=ln;exports.getVideoStrategy=fn;exports.getVisibleCanvasesFromCanvasId=Gn;exports.parseSpecificResource=xr;exports.unknownResponse=ze;exports.unsupportedStrategy=X;exports.useAnnotation=ht;exports.useAnnotationPage=Gt;exports.useAnnotationPageManager=gt;exports.useAnnotationsAtTime=Jr;exports.useCanvas=ye;exports.useCanvasClock=Zr;exports.useCanvasSequence=At;exports.useCanvasSubset=eo;exports.useClosestLanguage=In;exports.useCollection=to;exports.useContextBridge=Nt;exports.useCreateLocaleString=Vr;exports.useDispatch=Dt;exports.useEventListener=no;exports.useExistingVault=Ln;exports.useExternalCollection=ro;exports.useExternalManifest=It;exports.useExternalResource=st;exports.useIIIFLanguage=Je;exports.useImage=xt;exports.useImageService=_n;exports.useImageServiceLoader=De;exports.useImageTile=oo;exports.useLoadImageService=rn;exports.useLocaleString=Mn;exports.useManifest=ve;exports.useMediaActions=Lr;exports.useMediaElements=Ar;exports.useMediaState=Rr;exports.usePaintables=sn;exports.usePaintingAnnotations=Ge;exports.useRange=ft;exports.useRenderingStrategy=pn;exports.useResourceContext=xe;exports.useResourceEvents=pt;exports.useResources=tn;exports.useSearchService=io;exports.useSimpleMediaPlayer=Xe;exports.useSimpleViewer=dt;exports.useStyleHelper=so;exports.useStyles=Ae;exports.useThumbnail=mt;exports.useVault=J;exports.useVaultEffect=hn;exports.useVaultSelector=se;exports.useViewerPreset=$t;exports.useVirtualAnnotationPage=qt;exports.useVirtualAnnotationPageContext=Bt;exports.useVisibleCanvases=at;Object.keys(Le).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>Le[e]})});
48
49
  //# sourceMappingURL=index.js.map