react-iiif-vault 0.9.13 → 0.9.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle/cjs/index.js +3 -11
- package/dist/bundle/cjs/index.js.map +1 -1
- package/dist/bundle/esm/index.mjs +16 -48
- package/dist/bundle/esm/index.mjs.map +1 -1
- package/dist/canvas-panel/cjs/canvas-panel.js +3 -11
- package/dist/canvas-panel/cjs/canvas-panel.js.map +1 -1
- package/dist/canvas-panel/esm/canvas-panel.mjs +16 -48
- package/dist/canvas-panel/esm/canvas-panel.mjs.map +1 -1
- package/dist/index.umd.js +27 -35
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
"use strict";var _e=Object.defineProperty,Oe=Object.defineProperties;var Ie=Object.getOwnPropertyDescriptors;var U=Object.getOwnPropertySymbols;var ne=Object.prototype.hasOwnProperty,re=Object.prototype.propertyIsEnumerable;var te=(e,t,r)=>t in e?_e(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,y=(e,t)=>{for(var r in t||(t={}))ne.call(t,r)&&te(e,r,t[r]);if(U)for(var r of U(t))re.call(t,r)&&te(e,r,t[r]);return e},E=(e,t)=>Oe(e,Ie(t));var oe=(e,t)=>{var r={};for(var n in e)ne.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&U)for(var n of U(e))t.indexOf(n)<0&&re.call(e,n)&&(r[n]=e[n]);return r};Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var c=require("react"),D=require("@atlas-viewer/atlas"),Y=require("@iiif/vault"),P=require("typesafe-actions"),ke=require("react-dom"),I=require("@atlas-viewer/iiif-image-api");function de(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}function Le(e){if(e&&e.__esModule)return e;var t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});return e&&Object.keys(e).forEach(function(r){if(r!=="default"){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,Object.freeze(t)}var $=Le(c),_=de(c),Fe=de(ke);function z(e,t){return z=Object.setPrototypeOf||function(n,o){return n.__proto__=o,n},z(e,t)}function Ue(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,z(e,t)}var Ve=function(t,r){return t===void 0&&(t=[]),r===void 0&&(r=[]),t.length!==r.length||t.some(function(n,o){return!Object.is(n,r[o])})},ie={error:null},De=function(e){Ue(t,e);function t(){for(var n,o=arguments.length,i=new Array(o),a=0;a<o;a++)i[a]=arguments[a];return n=e.call.apply(e,[this].concat(i))||this,n.state=ie,n.resetErrorBoundary=function(){for(var s,f=arguments.length,u=new Array(f),l=0;l<f;l++)u[l]=arguments[l];n.props.onReset==null||(s=n.props).onReset.apply(s,u),n.reset()},n}t.getDerivedStateFromError=function(o){return{error:o}};var r=t.prototype;return r.reset=function(){this.setState(ie)},r.componentDidCatch=function(o,i){var a,s;(a=(s=this.props).onError)==null||a.call(s,o,i)},r.componentDidUpdate=function(o,i){var a=this.state.error,s=this.props.resetKeys;if(a!==null&&i.error!==null&&Ve(o.resetKeys,s)){var f,u;(f=(u=this.props).onResetKeysChange)==null||f.call(u,o.resetKeys,s),this.reset()}},r.render=function(){var o=this.state.error,i=this.props,a=i.fallbackRender,s=i.FallbackComponent,f=i.fallback;if(o!==null){var u={error:o,resetErrorBoundary:this.resetErrorBoundary};if($.isValidElement(f))return f;if(typeof a=="function")return a(u);if(s)return $.createElement(s,u);throw new Error("react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop")}return this.props.children},t}($.Component),j={exports:{}},B={};/**
|
|
2
|
-
* @license React
|
|
3
|
-
* react-jsx-runtime.production.min.js
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
-
*
|
|
7
|
-
* This source code is licensed under the MIT license found in the
|
|
8
|
-
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var Ne=_.default,je=Symbol.for("react.element"),Be=Symbol.for("react.fragment"),He=Object.prototype.hasOwnProperty,Ye=Ne.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,$e={key:!0,ref:!0,__self:!0,__source:!0};function pe(e,t,r){var n,o={},i=null,a=null;r!==void 0&&(i=""+r),t.key!==void 0&&(i=""+t.key),t.ref!==void 0&&(a=t.ref);for(n in t)He.call(t,n)&&!$e.hasOwnProperty(n)&&(o[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps,t)o[n]===void 0&&(o[n]=t[n]);return{$$typeof:je,type:e,key:i,ref:a,props:o,_owner:Ye.current}}B.Fragment=Be;B.jsx=pe;B.jsxs=pe;j.exports=B;const p=j.exports.jsx,b=j.exports.jsxs,k=j.exports.Fragment,Qe={collection:void 0,manifest:void 0,range:void 0,canvas:void 0,annotation:void 0},K=_.default.createContext(Qe),H=()=>c.useContext(K);function me({value:e,children:t}){const r=H(),n=c.useMemo(()=>y(y({},r),e),[e,r]);return p(K.Provider,{value:n,children:t})}const W=_.default.createContext({vault:null,setVaultInstance:e=>{}});function ze({vault:e,vaultOptions:t,useGlobal:r,resources:n,children:o}){const[i,a]=c.useState(()=>e||(r?Y.globalVault(t):t?new Y.Vault(t):new Y.Vault));return p(W.Provider,{value:{vault:i,setVaultInstance:a},children:p(me,{value:n||{},children:o})})}const A=()=>{const{vault:e}=c.useContext(W);if(e===null)throw new Error("Vault not found. Ensure you have your provider set up correctly.");return e};function qe({canvas:e,children:t}){return p(me,{value:{canvas:e},children:t})}function T(e,t=[]){const r=A(),[n,o]=c.useState(()=>e(r.getState(),r));return c.useEffect(()=>r.subscribe(i=>e(i,r),i=>{o(i)},!1),t),n}const J=_.default.createContext([]);function Ge(){const e=c.useContext(J);return T(t=>e.map(r=>t.iiif.entities.Canvas[r]).filter(Boolean),[e])}const V=()=>{},he=c.createContext({setCurrentCanvasId:V,setCurrentCanvasIndex:V,nextCanvas:V,previousCanvas:V,currentCanvasIndex:-1,totalCanvases:0,pagingView:!0});function Ke(){return{VaultContext:c.useContext(W),ResourceContext:c.useContext(K),SimpleViewerReactContext:c.useContext(he),VisibleCanvasReactContext:c.useContext(J)}}function We(e){return p(ze,{vault:e.bridge.VaultContext.vault||void 0,resources:e.bridge.ResourceContext,children:p(J.Provider,{value:e.bridge.VisibleCanvasReactContext,children:p(he.Provider,{value:e.bridge.SimpleViewerReactContext,children:e.children})})})}const Je="@iiif/IMPORT_ENTITIES",Xe="@iiif/MODIFY_ENTITY_FIELD",Ze="@iiif/REORDER_ENTITY_FIELD",et="@iiif/ADD_REFERENCE",tt="@iiif/REMOVE_REFERENCE",nt=P.createAction(Je)(),rt=P.createAction(Xe)(),ot=P.createAction(Ze)(),it=P.createAction(et)(),at=P.createAction(tt)(),Q={importEntities:nt,modifyEntityField:rt,reorderEntityField:ot,addReference:it,removeReference:at},st="@iiif/ADD_MAPPING",ct="@iiif/ADD_MAPPINGS";P.createAction(st)();P.createAction(ct)();const ut="@iiif/SET_META_VALUE",lt="@iiif/SET_META_VALUE_DYNAMIC",ft="@iiif/UNSET_META_VALUE";P.createAction(ut)();P.createAction(lt)();P.createAction(ft)();const dt="@iiif/REQUEST_RESOURCE",pt="@iiif/REQUEST_ERROR",mt="@iiif/REQUEST_MISMATCH",ht="@iiif/REQUEST_COMPLETE",gt="@iiif/REQUEST_OFFLINE_RESOURCE";P.createAction(dt)();P.createAction(pt)();P.createAction(mt)();P.createAction(ht)();P.createAction(gt)();const yt="@iiif/BATCH",vt="@iiif/BATCH_IMPORT";P.createAction(yt)();P.createAction(vt)();function Et(){const t=A().getStore();return c.useMemo(()=>r=>t.dispatch(r),[t])}function ae(e){return typeof e!="string"&&e&&e.bindToVault}function St(){const e=A(),t=c.useRef([]),r=Et(),n=c.useMemo(()=>`vault://annotation-page/${new Date().getTime()}/${Math.round(Math.random()*1e9).toString(16)}`,[]);c.useLayoutEffect(()=>{const s={id:n,type:"AnnotationPage",behavior:[],motivation:null,label:null,thumbnail:[],summary:null,requiredStatement:null,metadata:[],rights:null,provider:[],items:[],seeAlso:[],homepage:[],logo:[],rendering:[],service:[]};r(Q.importEntities({entities:{AnnotationPage:{[s.id]:s}}}))},[n]);const o=T(s=>n?s.iiif.entities.AnnotationPage[n]:null,[n]),i=c.useCallback((s,f)=>{if(n){if(ae(s)){const d=s;d.__vault||d.bindToVault(e),s=typeof d.source=="string"?d.source:d.source.id,t.current[s]=d}else typeof s!="string"&&(s=s.id);const u=e.get({id:n,type:"AnnotationPage"}),l=e.get({id:s,type:"Annotation"});u&&l&&(u.items.find(d=>d.id===l.id)||r(Q.addReference({id:n,type:"AnnotationPage",key:"items",reference:{id:s,type:"Annotation"},index:f})))}},[n]),a=c.useCallback(s=>{n&&(ae(s)?s=typeof s.source=="string"?s.source:s.source.id:typeof s!="string"&&(s=s.id),t.current[s]&&t.current[s].beforeRemove(),e.get({id:n,type:"AnnotationPage"})&&r(Q.removeReference({id:n,type:"AnnotationPage",key:"items",reference:{id:s,type:"Annotation"}})))},[n]);return[o,{addAnnotation:i,removeAnnotation:a}]}const ge=c.createContext(null);function Pt(){const e=c.useContext(ge);return[e.fullPage,{addAnnotation:e.addAnnotation,removeAnnotation:e.removeAnnotation}]}function Rt({children:e}){const[t,{addAnnotation:r,removeAnnotation:n}]=St();return p(ge.Provider,{value:c.useMemo(()=>({fullPage:t,addAnnotation:r,removeAnnotation:n}),[t]),children:e})}function Ct({width:e,style:t,height:r}){return p("div",{style:E(y({width:e,height:r,minHeight:500},t||{}),{background:"#f9f9f9"}),children:"Unknown error"})}var ye,bt=Fe.default;ye=bt.createRoot;const X=c.createContext(null);function At(){return c.useContext(X)}const ve=_.default.createContext(null),Ee=_.default.createContext(null);function L({children:e,overlay:t}){const r=c.useContext(t?Ee:ve),n=c.useRef(null),o=At();return c.useLayoutEffect(()=>{n.current||(n.current=r?ye(r):null)},[]),c.useLayoutEffect(()=>()=>{var i;(i=n.current)==null||i.unmount(),n.current=null},[]),c.useLayoutEffect(()=>{n.current&&n.current.render(p(X.Provider,{value:o,children:e}))},[e,o]),null}function xt(o){var i=o,{children:e,errorFallback:t,outerContainerProps:r={}}=i,n=oe(i,["children","errorFallback","outerContainerProps"]);const a=c.useRef(null),[s,f]=c.useState(),[u,l]=c.useState(),d=c.useRef(null),[m,v]=c.useState(),g=Ke(),h=t||Ct;return c.useLayoutEffect(()=>{f(a.current),v(d.current)},[]),b(De,{fallbackRender:()=>p(h,y({},n)),children:[p(D.AtlasAuto,E(y({},n),{containerProps:y({style:{position:"relative"}},n.containerProps||{}),htmlChildren:p("div",{ref:d}),onCreated:w=>{l(w),n.onCreated&&n.onCreated(w)},children:p(X.Provider,{value:u,children:p(ve.Provider,{value:s,children:p(Ee.Provider,{value:m,children:p(We,{bridge:g,children:p(Rt,{children:e})})})})})})),p("div",{ref:a})]})}function Tt(e){return{addEventListener(t,r,n,o){if(!!t)return e.setMetaValue([t.id,"eventManager",r],i=>{const a=i||[];for(const s of a)if(s.callback===n)return a;return[...a,{callback:n,scope:o}]}),n},removeEventListener(t,r,n){!t||e.setMetaValue([t.id,"eventManager",r],o=>(o||[]).filter(i=>i.callback!==n))},getListenersAsProps(t,r){const n=typeof t=="string"?{id:t}:t;if(!n||!n.id)return{};const o=e.getResourceMeta(n.id,"eventManager"),i={};if(o&&n)for(const a of Object.keys(o))i[a]=s=>{const f=e.get(n);for(const{callback:u,scope:l}of o[a]||[])(!l||r&&l.indexOf(r)!==-1)&&u(s,f)};return i}}}function Se(e,t){const r=A(),n=c.useMemo(()=>Tt(r),[r]),o=T(()=>e&&e.id?r.getResourceMeta(e.id,"eventManager"):null,[e]);return c.useMemo(()=>e?n.getListenersAsProps(e,t):{},[o,e,r,t])}function Pe(e){return{applyStyles(t,r,n){const o=typeof t=="string"?t:t.id;return e.setMetaValue([o,"styles",r],n)},getAppliedStyles(t){const r=typeof t=="string"?t:t.id;return e.getResourceMeta(r,"styles")}}}function N(e,t){const r=A(),n=c.useMemo(()=>Pe(r),[r]);return T(()=>{if(!e)return null;const o=n.getAppliedStyles(e.id);return o?t?o[t]:o:void 0},[e,t])}var wt=Object.defineProperty,Mt=Object.defineProperties,_t=Object.getOwnPropertyDescriptors,se=Object.getOwnPropertySymbols,Ot=Object.prototype.hasOwnProperty,It=Object.prototype.propertyIsEnumerable,ce=(e,t,r)=>t in e?wt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ue=(e,t)=>{for(var r in t||(t={}))Ot.call(t,r)&&ce(e,r,t[r]);if(se)for(var r of se(t))It.call(t,r)&&ce(e,r,t[r]);return e},le=(e,t)=>Mt(e,_t(t));const kt=/&?(xywh=)?(pixel:|percent:|pct:)?([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?)/,Lt=/&?(t=)(npt:)?([0-9]+(.[0-9]+)?)?(,([0-9]+(.[0-9]+)?))?/;function q(e){if(Array.isArray(e))return e.reduce((t,r)=>{const{selector:n,selectors:o}=q(r);return n&&(t.selector||(t.selector=n),t.selectors.push(...o)),t},{selector:null,selectors:[]});if(!e)return{selector:null,selectors:[]};if(typeof e=="string"){const[t,r]=e.split("#");return r?q({type:"FragmentSelector",value:r}):{selector:null,selectors:[]}}if(e.type==="PointSelector"&&(e.t||e.t===0)){const t={type:"TemporalSelector",temporal:{startTime:e.t}};return{selector:t,selectors:[t]}}if(e.type==="FragmentSelector"){const t=kt.exec(e.value);if(t){const n={type:"BoxSelector",spatial:{unit:t[2]==="percent:"||t[2]==="pct:"?"percent":"pixel",x:parseFloat(t[3]),y:parseFloat(t[4]),width:parseFloat(t[5]),height:parseFloat(t[6])}};return{selector:n,selectors:[n]}}const r=e.value.match(Lt);if(r){const n={type:"TemporalSelector",temporal:{startTime:r[4]?parseFloat(r[4]):0,endTime:r[7]?parseFloat(r[7]):void 0}};return{selector:n,selectors:[n]}}return{selector:null,selectors:[]}}return{selector:null,selectors:[]}}function M(e,t={}){if(Array.isArray(e))return M(e[0]);if(typeof e=="string"){const[r,n]=e.split("#");return n?M({type:"SpecificResource",source:{id:r,type:"Unknown"},selector:{type:"FragmentSelector",value:n}}):{type:"SpecificResource",source:{id:r,type:t.typeMap&&t.typeMap[r]||"Unknown"},selector:null,selectors:[]}}if(e.type==="Choice"||e.type==="List"||e.type==="Composite"||e.type==="Independents")return M(e.items[0]);if(e.type==="SpecificResource"){e.source.type==="Canvas"&&e.source.partOf&&typeof e.source.partOf=="string"&&(e.source.partOf=[{id:e.source.partOf,type:"Manifest"}]);const{selector:r,selectors:n}=e.selector?q(e.selector):{selector:null,selectors:[]};return{type:"SpecificResource",source:e.source,selector:r,selectors:n}}if(e.id){e.type==="Canvas"&&e.partOf&&typeof e.partOf=="string"&&(e.partOf=[{id:e.partOf,type:"Manifest"}]);const[r,n]=e.id.split("#");return n?M({type:"SpecificResource",source:le(ue({},e),{id:r}),selector:{type:"FragmentSelector",value:n}}):{type:"SpecificResource",source:le(ue({},e),{id:r}),selector:null,selectors:[]}}return{type:"SpecificResource",source:e,selector:null,selectors:[]}}function Ft(e={},t=[]){const{id:r,selector:n}=e,o=H(),i=A(),a=r||o.annotation,s=T(u=>a?u.iiif.entities.Annotation[a]:void 0,[a]),f=T(u=>s&&s.body?s.body.map(l=>l?u.iiif.entities[l.type][l.id]:null).filter(Boolean):[],[s]);return c.useMemo(()=>{if(!s)return;const u=E(y({},s),{body:f,target:M(s.target,{typeMap:i.getState().iiif.mapping})});return n?n(u):u},[s,n,f,...t])}function O(e={},t=[]){const{id:r,selector:n}=e,o=H(),i=r||o.canvas,a=T(s=>i?s.iiif.entities.Canvas[i]:void 0,[i]);return c.useMemo(()=>{if(!!a)return n?n(a):a},[a,n,...t])}const Re=({id:e,style:t,className:r,interactive:n})=>{const o=Ft({id:e}),i=N(o,"atlas"),a=N(o,"html"),s=Se(o,["atlas"]),f=O(),u=c.useMemo(()=>D.mergeStyles(t,i),[t,i]);return f&&o&&o.target&&o.target.selector&&o.target.selector.type==="BoxSelector"&&o.target.source&&o.target.source.id===f.id?p(D.RegionHighlight,y({id:o.id,isEditing:!0,region:o.target.selector.spatial,style:u,className:(a==null?void 0:a.className)||r,interactive:!!((a==null?void 0:a.href)||n),href:(a==null?void 0:a.href)||null,title:(a==null?void 0:a.title)||null,hrefTarget:(a==null?void 0:a.target)||null},s)):null},G=({className:e,page:t})=>{var o;const r=N(t,"atlas"),n=N(t,"html");return T(i=>t.id?i.iiif.entities.AnnotationPage[t.id]:null,[]),p(c.Fragment,{children:(o=t.items)==null?void 0:o.map(i=>p(Re,{id:i.id,style:r,className:(n==null?void 0:n.className)||e},i.id))})};function Ce({id:e,image:t,thumbnail:r,isStatic:n,x:o=0,y:i=0,annotations:a,children:s}){var f,u,l,d;return p(c.Fragment,{children:t.service?b(c.Fragment,{children:[p(D.TileSet,{tiles:{id:t.service.id||t.service["@id"]||"unknown",height:t.height,width:t.width,imageService:t.service,thumbnail:r&&r.type==="fixed"?r:void 0},x:((f=t.target)==null?void 0:f.spatial.x)+o,y:((u=t.target)==null?void 0:u.spatial.y)+i,width:(l=t.target)==null?void 0:l.spatial.width,height:(d=t.target)==null?void 0:d.spatial.height}),a,s]},"service"):b(c.Fragment,{children:[p("world-image",{uri:t.id,target:t.target.spatial,display:t.width&&t.height?{width:t.width,height:t.height}:void 0}),a,s]},"no-service")},e)}function Ut(e){return e.type==="SpecificResource"?[e.source,{selector:e.selector}]:[e,{selector:null}]}function Vt(e,t,r){const n=[];let o=null;const i=[];for(const a of t){const s=e.get(a.body);for(const f of s){const[u,{selector:l}]=Ut(f),d=(u.type||"unknown").toLowerCase();if(d==="choice"){const m=e.get(u.items),v=r.length?r.map(g=>m.find(h=>h.id===g)).filter(Boolean):[m[0]];v.length===0&&v.push(m[0]),o={type:"single-choice",items:m.map(g=>({id:g.id,label:g.label,selected:v.indexOf(g)!==-1})),label:f.label},s.push(...v);continue}n.indexOf(d)===-1&&n.push(d),i.push({type:d,resource:u,target:a.target,selector:l})}}return{types:n,items:i,choice:o}}const Dt={makeChoice:()=>{}},fe={type:"unknown"},S=e=>({type:"unknown",reason:e,annotations:{pages:[]}});function Z(e={},t=[]){const{id:r,selector:n}=e,o=H();A();const i=r||o.manifest,a=T(s=>i?s.iiif.entities.Manifest[i]:void 0,[i]);return c.useMemo(()=>{if(!!a)return n?n(a):a},[a,n,...t])}function Nt(e,t){var n;const r=(n=e==null?void 0:e.iiif)==null?void 0:n.meta[t];return r?r.annotationPageManager:null}function jt(e,t){return T(r=>{const n=[];if(!e)return n;const o=Object.keys(r.iiif.entities.AnnotationPage);for(const i of o)if(!t||t.indexOf(i)!==-1){const a=Nt(r,i);a&&a.views&&a.views[e]&&n.push(i)}return n},[e,t])}function Bt({canvas:e,manifest:t,all:r,canvases:n}){const o=[];if(t)for(const i of t.annotations)o.indexOf(i.id)===-1&&o.push(i.id);if(r){if(n&&n.length)for(const i of n)for(const a of i.annotations)o.indexOf(a.id)===-1&&o.push(a.id)}else if(e)for(const i of e.annotations)o.indexOf(i.id)===-1&&o.push(i.id);return o}function Ht(e,t){var n;const r=(n=e==null?void 0:e.iiif)==null?void 0:n.meta[t];return r?r.annotationPageManager:null}function Yt(e,t={}){const r=A(),n=Z(),o=O(),i=Ge(),a=c.useMemo(()=>Bt({all:t.all,manifest:n,canvas:o,canvases:i}),[t.all,o,i,n]),s=jt(e,t.all?void 0:a),f=c.useCallback(l=>{!e||r.setMetaValue([l,"annotationPageManager","views"],d=>d&&!d[e]?d:E(y({},d||{}),{[e]:!1}))},[e,r]),u=c.useCallback((l,d={})=>{if(!e)return;const m=r.getState(),v=[];if(d!=null&&d.deselectOthers){const g=Object.keys(m.iiif.entities.AnnotationPage);for(const h of g){const w=Ht(m,h);w&&w.views&&w.views[e]&&v.push(h)}}for(const g of v)f(g);r.setMetaValue([l,"annotationPageManager","views"],g=>g&&g[e]?g:E(y({},g||{}),{[e]:!0}))},[e,f,r]);return{availablePageIds:a,enabledPageIds:s,setPageEnabled:u,setPageDisabled:f}}function $t(e,t){return T((r,n)=>n.get(e.map(o=>({id:o,type:t}))),[e,t])}const Qt=_.default.createContext(new I.ImageServiceLoader);function be(){return c.useContext(Qt)}function zt(){const e=be(),[t,r]=c.useState({}),n=c.useRef(!1);return c.useEffect(()=>()=>{n.current=!0},[]),[c.useCallback((i,{height:a,width:s})=>{if(i){const f=i.id||i["@id"],u=e.loadServiceSync({id:f,width:i.width||s,height:i.height||a,source:i});u?i=u:t[f]||(n.current||r(l=>E(y({},l),{[f]:"loading"})),e.loadService({id:f,width:i.width||s,height:i.height||a}).then(()=>{n.current||r(l=>E(y({},l),{[f]:"done"}))}))}return i},[e,t]),t]}function qt(e={}){const t=O(e.canvasId?{id:e.canvasId}:void 0);return T((r,n)=>{if(!t)return[];const o=n.get(t.items),i=[];for(const a of o)i.push(...n.get(a.items));return i},[t])}function Gt(e,t=[]){const r=A(),n=qt(),[o,i]=c.useState((e==null?void 0:e.defaultChoices)||[]),a=c.useMemo(()=>Vt(r,n,o),[r,n,o,...t]),f={makeChoice:c.useCallback((u,{deselectOthers:l=!0,deselect:d=!1}={})=>{if(a.choice){if(a.choice.type!=="single-choice")throw new Error("Complex choice not supported yet");i(m=>{if(d){const g=m.filter(h=>h!==u);if(g.length===0){const h=a.items[0].resource.id;return h?[h]:[]}return g}if(l)return[u];const v=[...m];if(v.length===0&&a.items.length){const g=a.items[0].resource.id;g&&v.push(g)}return m.indexOf(u)!==-1?m:[...m,u]})}},[a.choice])};return[a,f]}function Kt(e,t,r){const n=[];for(const o of t.items){const i=o.resource&&o.resource.type==="SpecificResource"?o.resource.source:o.resource;if(!i.id)return S("No resource Identifier");let a;if(i.service){const h=I.getImageServices(i);h[0]&&(a=r(h[0],e))}const{selector:s,source:f}=M(o.target);if(f.id!==e.id)continue;const u={type:"BoxSelector",spatial:{x:0,y:0,width:e.width,height:e.height}},l=s?s.type==="TemporalSelector"?{type:"TemporalBoxSelector",temporal:s.temporal,spatial:u.spatial}:s:null,d={type:"BoxSelector",spatial:{x:0,y:0,width:e.width,height:e.height}},m=o.resource.type==="SpecificResource"?M(o.resource):null,v=m&&m.selector&&(m.selector.type==="BoxSelector"||m.selector.type==="TemporalBoxSelector")?{type:"BoxSelector",spatial:{x:m.selector.spatial.x,y:m.selector.spatial.y,width:m.selector.spatial.width,height:m.selector.spatial.height}}:d;a&&!a.id&&(a.id=a["@id"]);const g={id:i.id,type:"Image",width:l?i.width:e.width,height:l?i.height:e.height,service:a,sizes:a&&a.sizes?a.sizes:i.width&&i.height?[{width:i.width,height:i.height}]:[],target:l&&l.type!=="PointSelector"?l:u,selector:v};n.push(g)}return{type:"images",image:n[0],images:n,choice:t.choice}}const Wt=["model/gltf-binary"];function Jt(e,t){const n=t.items[0].resource;return n.format?Wt.indexOf(n.format)===-1?S(`3D format: ${n.format} is unsupported`):{type:"3d-model",model:n}:S("Unknown format")}function Xt(e,t){var n;if(!e.duration)return S("No duration on canvas");if(t.items.length>1)return S("Only one audio source supported");const r=(n=t.items[0])==null?void 0:n.resource;return r?r.format?{type:"media",media:{duration:e.duration,url:r.id,type:"Sound",target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:r.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},annotations:{pages:[]}}:S("Audio does not have format"):S("Unknown audio")}function Zt(e,t){var o;const r=t.items.filter(i=>i.type==="video");if(!e.duration)return S("No duration on canvas");if(r.length>1)return S("Only one video source supported");const n=(o=r[0])==null?void 0:o.resource;return n?n.format?{type:"media",media:{duration:e.duration,url:n.id,type:"Video",items:[],target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:n.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},annotations:{pages:[]}}:S("Video does not have format"):S("Unknown video")}function en(e){const t=Z(),r=O(),n=A(),[o,i]=zt(),{enabledPageIds:a}=Yt((e==null?void 0:e.annotationPageManagerId)||(t==null?void 0:t.id)||(r==null?void 0:r.id),{all:!1}),s=$t(a,"AnnotationPage"),f=(e==null?void 0:e.strategies)||["images","media","complex-timeline"],[u,l]=Gt(e,[i]),d=c.useMemo(()=>{if(!r||u.types.length===0)return fe;if(u.types.length!==1)if(u.types.length===2&&u.types.indexOf("text")!==-1)u.types=u.types.filter(v=>v!=="text");else return f.indexOf("complex-timeline")===-1?S("Complex timeline not supported"):S("ComplexTimelineStrategy not yet supported");const m=u.types[0];return m==="image"?f.indexOf("images")===-1?S("Image not supported"):Kt(r,u,o):m==="Model"||m==="model"?f.indexOf("3d-model")===-1?S("3D not supported"):Jt(r,u):m==="sound"||m==="audio"?f.indexOf("media")===-1?S("Media not supported"):Xt(r,u):m==="video"?f.indexOf("media")===-1?S("Media not supported"):Zt(r,u):fe},[r,u,n,l.makeChoice]);return c.useMemo(()=>d.type==="unknown"?[d,Dt]:[E(y({},d),{annotations:{pages:s}}),l],[d,s])}const tn=(e,t=[])=>{const r=A();c.useEffect(()=>{e(r)},[r,...t])};function nn(e,t={}){const r=t.imageServiceLoader||new I.ImageServiceLoader;async function n(o,i,a,s=[],f){if(typeof o=="string")return{best:I.getFixedSizeFromImage(o),fallback:[],log:[]};const u=e.get(o);if(typeof u=="string")return{best:I.getFixedSizeFromImage(u),fallback:[],log:[]};switch(u.type){case"Annotation":{const l=u.body,d=e.get(l[0]);return f&&!d.width&&(d.width=f.width,d.height=f.height),await r.getThumbnailFromResource(d,i,a,s)}case"Canvas":{const l=u;if(l.thumbnail&&l.thumbnail.length){const d=e.get(l.thumbnail[0]),m=await r.getImageCandidates(d,a);m&&m.length&&s.push(...m)}return n(l.items[0],i,a,s,{width:l.width,height:l.height})}case"AnnotationPage":return n(u.items[0],i,a,s,f);case"Choice":return n(u.items[0],i,a,s,f);case"Collection":{const d=u.items[0];return n(d,i,a,s,f)}case"Manifest":{const d=u.items[0];return n(d,i,a,s,f)}case"SpecificResource":case"Image":case"Dataset":case"Sound":case"Text":case"TextualBody":case"Video":return f&&!u.width&&(u.width=f.width,u.height=f.height),r.getThumbnailFromResource(u,i,a,s);case"Service":case"Range":case"AnnotationCollection":case"CanvasReference":case"ContentResource":return{best:void 0,fallback:[],log:[]}}return{best:void 0,fallback:[],log:[]}}return{getBestThumbnailAtSize:n}}function rn(e,t,{canvasId:r,manifestId:n}={}){const o=A(),i=be(),a=c.useMemo(()=>nn(o,{imageServiceLoader:i}),[o,i]),[s,f]=c.useState(),u=Z(n?{id:n}:void 0),l=O(r?{id:r}:void 0),d=l||u,m=c.useRef(!1);if(c.useEffect(()=>()=>{m.current=!0},[]),!d)throw new Error("Must be called under a manifest or canvas context.");return tn(v=>{a.getBestThumbnailAtSize(d,e,t).then(g=>{g.best&&!m.current&&f(g.best)})},[d]),s}function on(e){return{isMuted:!1,playRequested:!1,isPlaying:!1,isFinished:!1,volume:100,duration:e}}function an(e,t){switch(t.type){case"FINISHED":return E(y({},e),{isFinished:!0,isPlaying:!1,playRequested:!1});case"PLAY_PAUSE":return E(y({},e),{isFinished:!1,isPlaying:!e.isPlaying});case"PLAY_REQUESTED":return E(y({},e),{isFinished:!1,playRequested:!0});case"PAUSE":return E(y({},e),{isPlaying:!1});case"PLAY":return E(y({},e),{isFinished:!1,playRequested:!1,isPlaying:!0});case"MUTE":return E(y({},e),{isMuted:!0});case"SET_VOLUME":return E(y({},e),{volume:t.volume,isMuted:t.volume===0});case"TOGGLE_MUTE":return E(y({},e),{isMuted:!e.isMuted});case"UNMUTE":return E(y({},e),{isMuted:!1})}return e}function sn(e){const t=Math.round(e);return`${Math.floor(t/60)}:${`${t%60}`.padStart(2,"0")}`}function Ae(e){const[t,r]=c.useReducer(an,on(e.duration)),n=c.useRef(null),o=c.useRef(null),i=c.useRef(null),a=c.useRef(!1),s=c.useCallback(()=>{o.current&&n.current&&(o.current.innerHTML=sn(n.current.currentTime),i.current&&(i.current.style.width=`${n.current.currentTime/e.duration*100}%`),a.current!==n.current.muted&&(a.current=n.current.muted,r(n.current.muted?{type:"MUTE"}:{type:"UNMUTE"})))},[e.duration]),f=c.useCallback(()=>{n.current&&(r({type:"PLAY_REQUESTED"}),n.current.play().then(()=>{r({type:"PLAY"})}),s())},[s]),u=c.useCallback(()=>{n.current&&(n.current.duration>0&&n.current.paused?f():l())},[s]),l=c.useCallback(()=>{n.current&&(n.current.pause(),r({type:"PAUSE"}),s())},[s]),d=c.useCallback(()=>{n.current&&(n.current.muted=!n.current.muted,r(n.current.muted?{type:"MUTE"}:{type:"UNMUTE"}))},[]),m=c.useCallback(()=>{n.current&&(n.current.muted=!0,r({type:"MUTE"}))},[]),v=c.useCallback(()=>{n.current&&(n.current.muted=!1,r({type:"UNMUTE"}))},[]),g=c.useCallback(C=>{n.current&&(n.current.muted=!1,n.current.volume=C/100,r({type:"SET_VOLUME",volume:C}))},[]),h=c.useCallback(C=>{n.current&&(n.current.currentTime=Math.max(0,Math.min(C*e.duration,e.duration)),s())},[]),w=c.useCallback(C=>{n.current&&(n.current.currentTime=Math.max(0,Math.min(C,e.duration)),s())},[]);return c.useEffect(()=>{const C=setInterval(()=>{s()},350);return()=>clearInterval(C)},[s,e.duration]),c.useEffect(()=>{const C=()=>{r({type:"FINISHED"})},R=n.current;return R==null||R.addEventListener("ended",C),()=>R==null?void 0:R.removeEventListener("ended",C)},[]),[{element:n,currentTime:o,progress:i},t,{play:f,pause:l,playPause:u,mute:m,unmute:v,toggleMute:d,setVolume:g,setDurationPercent:h,setTime:w}]}const cn=c.createContext(null),un=c.createContext(null),ln=c.createContext(null);function xe({actions:e,state:t,children:r,currentTime:n,progress:o,element:i}){return p(ln.Provider,{value:{currentTime:n,progress:o,element:i},children:p(un.Provider,{value:e,children:p(cn.Provider,{value:t,children:r})})})}function fn({media:e,children:t}){const[{element:r,currentTime:n,progress:o},i,a]=Ae({duration:e.duration});return p(k,{children:p(L,{children:b(xe,{state:i,actions:a,currentTime:n,progress:o,element:r,children:[p("audio",{ref:r,src:e.url}),t]})})})}function dn({media:e,children:t}){const[{element:r,currentTime:n,progress:o},i,a]=Ae({duration:e.duration});return b(k,{children:[b(L,{overlay:!0,children:[p("style",{children:`
|
|
1
|
+
"use strict";var Ae=Object.defineProperty,be=Object.defineProperties;var Te=Object.getOwnPropertyDescriptors;var k=Object.getOwnPropertySymbols;var J=Object.prototype.hasOwnProperty,Z=Object.prototype.propertyIsEnumerable;var X=(e,t,r)=>t in e?Ae(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,y=(e,t)=>{for(var r in t||(t={}))J.call(t,r)&&X(e,r,t[r]);if(k)for(var r of k(t))Z.call(t,r)&&X(e,r,t[r]);return e},E=(e,t)=>be(e,Te(t));var ee=(e,t)=>{var r={};for(var n in e)J.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&k)for(var n of k(e))t.indexOf(n)<0&&Z.call(e,n)&&(r[n]=e[n]);return r};Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var c=require("react"),L=require("@atlas-viewer/atlas"),f=require("react/jsx-runtime"),D=require("@iiif/vault"),S=require("typesafe-actions"),Me=require("react-dom"),j=require("@atlas-viewer/iiif-image-api");function ce(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}function we(e){if(e&&e.__esModule)return e;var t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});return e&&Object.keys(e).forEach(function(r){if(r!=="default"){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,Object.freeze(t)}var N=we(c),w=ce(c),_e=ce(Me);function H(e,t){return H=Object.setPrototypeOf||function(n,o){return n.__proto__=o,n},H(e,t)}function je(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,H(e,t)}var Oe=function(t,r){return t===void 0&&(t=[]),r===void 0&&(r=[]),t.length!==r.length||t.some(function(n,o){return!Object.is(n,r[o])})},te={error:null},Ie=function(e){je(t,e);function t(){for(var n,o=arguments.length,i=new Array(o),s=0;s<o;s++)i[s]=arguments[s];return n=e.call.apply(e,[this].concat(i))||this,n.state=te,n.resetErrorBoundary=function(){for(var a,d=arguments.length,u=new Array(d),l=0;l<d;l++)u[l]=arguments[l];n.props.onReset==null||(a=n.props).onReset.apply(a,u),n.reset()},n}t.getDerivedStateFromError=function(o){return{error:o}};var r=t.prototype;return r.reset=function(){this.setState(te)},r.componentDidCatch=function(o,i){var s,a;(s=(a=this.props).onError)==null||s.call(a,o,i)},r.componentDidUpdate=function(o,i){var s=this.state.error,a=this.props.resetKeys;if(s!==null&&i.error!==null&&Oe(o.resetKeys,a)){var d,u;(d=(u=this.props).onResetKeysChange)==null||d.call(u,o.resetKeys,a),this.reset()}},r.render=function(){var o=this.state.error,i=this.props,s=i.fallbackRender,a=i.FallbackComponent,d=i.fallback;if(o!==null){var u={error:o,resetErrorBoundary:this.resetErrorBoundary};if(N.isValidElement(d))return d;if(typeof s=="function")return s(u);if(a)return N.createElement(a,u);throw new Error("react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop")}return this.props.children},t}(N.Component);const ke={collection:void 0,manifest:void 0,range:void 0,canvas:void 0,annotation:void 0},z=w.default.createContext(ke),U=()=>c.useContext(z);function ue({value:e,children:t}){const r=U(),n=c.useMemo(()=>y(y({},r),e),[e,r]);return f.jsx(z.Provider,{value:n,children:t})}const $=w.default.createContext({vault:null,setVaultInstance:e=>{}});function Fe({vault:e,vaultOptions:t,useGlobal:r,resources:n,children:o}){const[i,s]=c.useState(()=>e||(r?D.globalVault(t):t?new D.Vault(t):new D.Vault));return f.jsx($.Provider,{value:{vault:i,setVaultInstance:s},children:f.jsx(ue,{value:n||{},children:o})})}const R=()=>{const{vault:e}=c.useContext($);if(e===null)throw new Error("Vault not found. Ensure you have your provider set up correctly.");return e};function Le({canvas:e,children:t}){return f.jsx(ue,{value:{canvas:e},children:t})}function b(e,t=[]){const r=R(),[n,o]=c.useState(()=>e(r.getState(),r));return c.useEffect(()=>r.subscribe(i=>e(i,r),i=>{o(i)},!1),t),n}const q=w.default.createContext([]);function Ve(){const e=c.useContext(q);return b(t=>e.map(r=>t.iiif.entities.Canvas[r]).filter(Boolean),[e])}const F=()=>{},le=c.createContext({setCurrentCanvasId:F,setCurrentCanvasIndex:F,nextCanvas:F,previousCanvas:F,currentCanvasIndex:-1,totalCanvases:0,pagingView:!0});function Ue(){return{VaultContext:c.useContext($),ResourceContext:c.useContext(z),SimpleViewerReactContext:c.useContext(le),VisibleCanvasReactContext:c.useContext(q)}}function De(e){return f.jsx(Fe,{vault:e.bridge.VaultContext.vault||void 0,resources:e.bridge.ResourceContext,children:f.jsx(q.Provider,{value:e.bridge.VisibleCanvasReactContext,children:f.jsx(le.Provider,{value:e.bridge.SimpleViewerReactContext,children:e.children})})})}const Ne="@iiif/IMPORT_ENTITIES",Be="@iiif/MODIFY_ENTITY_FIELD",He="@iiif/REORDER_ENTITY_FIELD",Ye="@iiif/ADD_REFERENCE",Qe="@iiif/REMOVE_REFERENCE",ze=S.createAction(Ne)(),$e=S.createAction(Be)(),qe=S.createAction(He)(),Ge=S.createAction(Ye)(),Ke=S.createAction(Qe)(),B={importEntities:ze,modifyEntityField:$e,reorderEntityField:qe,addReference:Ge,removeReference:Ke},We="@iiif/ADD_MAPPING",Xe="@iiif/ADD_MAPPINGS";S.createAction(We)();S.createAction(Xe)();const Je="@iiif/SET_META_VALUE",Ze="@iiif/SET_META_VALUE_DYNAMIC",et="@iiif/UNSET_META_VALUE";S.createAction(Je)();S.createAction(Ze)();S.createAction(et)();const tt="@iiif/REQUEST_RESOURCE",nt="@iiif/REQUEST_ERROR",rt="@iiif/REQUEST_MISMATCH",ot="@iiif/REQUEST_COMPLETE",it="@iiif/REQUEST_OFFLINE_RESOURCE";S.createAction(tt)();S.createAction(nt)();S.createAction(rt)();S.createAction(ot)();S.createAction(it)();const st="@iiif/BATCH",at="@iiif/BATCH_IMPORT";S.createAction(st)();S.createAction(at)();function ct(){const t=R().getStore();return c.useMemo(()=>r=>t.dispatch(r),[t])}function ne(e){return typeof e!="string"&&e&&e.bindToVault}function ut(){const e=R(),t=c.useRef([]),r=ct(),n=c.useMemo(()=>`vault://annotation-page/${new Date().getTime()}/${Math.round(Math.random()*1e9).toString(16)}`,[]);c.useLayoutEffect(()=>{const a={id:n,type:"AnnotationPage",behavior:[],motivation:null,label:null,thumbnail:[],summary:null,requiredStatement:null,metadata:[],rights:null,provider:[],items:[],seeAlso:[],homepage:[],logo:[],rendering:[],service:[]};r(B.importEntities({entities:{AnnotationPage:{[a.id]:a}}}))},[n]);const o=b(a=>n?a.iiif.entities.AnnotationPage[n]:null,[n]),i=c.useCallback((a,d)=>{if(n){if(ne(a)){const p=a;p.__vault||p.bindToVault(e),a=typeof p.source=="string"?p.source:p.source.id,t.current[a]=p}else typeof a!="string"&&(a=a.id);const u=e.get({id:n,type:"AnnotationPage"}),l=e.get({id:a,type:"Annotation"});u&&l&&(u.items.find(p=>p.id===l.id)||r(B.addReference({id:n,type:"AnnotationPage",key:"items",reference:{id:a,type:"Annotation"},index:d})))}},[n]),s=c.useCallback(a=>{n&&(ne(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:n,type:"AnnotationPage"})&&r(B.removeReference({id:n,type:"AnnotationPage",key:"items",reference:{id:a,type:"Annotation"}})))},[n]);return[o,{addAnnotation:i,removeAnnotation:s}]}const fe=c.createContext(null);function lt(){const e=c.useContext(fe);return[e.fullPage,{addAnnotation:e.addAnnotation,removeAnnotation:e.removeAnnotation}]}function ft({children:e}){const[t,{addAnnotation:r,removeAnnotation:n}]=ut();return f.jsx(fe.Provider,{value:c.useMemo(()=>({fullPage:t,addAnnotation:r,removeAnnotation:n}),[t]),children:e})}function dt({width:e,style:t,height:r}){return f.jsx("div",{style:E(y({width:e,height:r,minHeight:500},t||{}),{background:"#f9f9f9"}),children:"Unknown error"})}var de,pt=_e.default;de=pt.createRoot;const G=c.createContext(null);function mt(){return c.useContext(G)}const pe=w.default.createContext(null),me=w.default.createContext(null);function O({children:e,overlay:t}){const r=c.useContext(t?me:pe),n=c.useRef(null),o=mt();return c.useLayoutEffect(()=>{n.current||(n.current=r?de(r):null)},[]),c.useLayoutEffect(()=>()=>{var i;(i=n.current)==null||i.unmount(),n.current=null},[]),c.useLayoutEffect(()=>{n.current&&n.current.render(f.jsx(G.Provider,{value:o,children:e}))},[e,o]),null}function ht(o){var i=o,{children:e,errorFallback:t,outerContainerProps:r={}}=i,n=ee(i,["children","errorFallback","outerContainerProps"]);const s=c.useRef(null),[a,d]=c.useState(),[u,l]=c.useState(),p=c.useRef(null),[m,v]=c.useState(),g=Ue(),h=t||dt;return c.useLayoutEffect(()=>{d(s.current),v(p.current)},[]),f.jsxs(Ie,{fallbackRender:()=>f.jsx(h,y({},n)),children:[f.jsx(L.AtlasAuto,E(y({},n),{containerProps:y({style:{position:"relative"}},n.containerProps||{}),htmlChildren:f.jsx("div",{ref:p}),onCreated:T=>{l(T),n.onCreated&&n.onCreated(T)},children:f.jsx(G.Provider,{value:u,children:f.jsx(pe.Provider,{value:a,children:f.jsx(me.Provider,{value:m,children:f.jsx(De,{bridge:g,children:f.jsx(ft,{children:e})})})})})})),f.jsx("div",{ref:s})]})}function gt(e){return{addEventListener(t,r,n,o){if(!!t)return e.setMetaValue([t.id,"eventManager",r],i=>{const s=i||[];for(const a of s)if(a.callback===n)return s;return[...s,{callback:n,scope:o}]}),n},removeEventListener(t,r,n){!t||e.setMetaValue([t.id,"eventManager",r],o=>(o||[]).filter(i=>i.callback!==n))},getListenersAsProps(t,r){const n=typeof t=="string"?{id:t}:t;if(!n||!n.id)return{};const o=e.getResourceMeta(n.id,"eventManager"),i={};if(o&&n)for(const s of Object.keys(o))i[s]=a=>{const d=e.get(n);for(const{callback:u,scope:l}of o[s]||[])(!l||r&&l.indexOf(r)!==-1)&&u(a,d)};return i}}}function he(e,t){const r=R(),n=c.useMemo(()=>gt(r),[r]),o=b(()=>e&&e.id?r.getResourceMeta(e.id,"eventManager"):null,[e]);return c.useMemo(()=>e?n.getListenersAsProps(e,t):{},[o,e,r,t])}function ge(e){return{applyStyles(t,r,n){const o=typeof t=="string"?t:t.id;return e.setMetaValue([o,"styles",r],n)},getAppliedStyles(t){const r=typeof t=="string"?t:t.id;return e.getResourceMeta(r,"styles")}}}function V(e,t){const r=R(),n=c.useMemo(()=>ge(r),[r]);return b(()=>{if(!e)return null;const o=n.getAppliedStyles(e.id);return o?t?o[t]:o:void 0},[e,t])}var yt=Object.defineProperty,vt=Object.defineProperties,Et=Object.getOwnPropertyDescriptors,re=Object.getOwnPropertySymbols,xt=Object.prototype.hasOwnProperty,St=Object.prototype.propertyIsEnumerable,oe=(e,t,r)=>t in e?yt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ie=(e,t)=>{for(var r in t||(t={}))xt.call(t,r)&&oe(e,r,t[r]);if(re)for(var r of re(t))St.call(t,r)&&oe(e,r,t[r]);return e},se=(e,t)=>vt(e,Et(t));const Pt=/&?(xywh=)?(pixel:|percent:|pct:)?([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?)/,Ct=/&?(t=)(npt:)?([0-9]+(.[0-9]+)?)?(,([0-9]+(.[0-9]+)?))?/;function Y(e){if(Array.isArray(e))return e.reduce((t,r)=>{const{selector:n,selectors:o}=Y(r);return n&&(t.selector||(t.selector=n),t.selectors.push(...o)),t},{selector:null,selectors:[]});if(!e)return{selector:null,selectors:[]};if(typeof e=="string"){const[t,r]=e.split("#");return r?Y({type:"FragmentSelector",value:r}):{selector:null,selectors:[]}}if(e.type==="PointSelector"&&(e.t||e.t===0)){const t={type:"TemporalSelector",temporal:{startTime:e.t}};return{selector:t,selectors:[t]}}if(e.type==="FragmentSelector"){const t=Pt.exec(e.value);if(t){const n={type:"BoxSelector",spatial:{unit:t[2]==="percent:"||t[2]==="pct:"?"percent":"pixel",x:parseFloat(t[3]),y:parseFloat(t[4]),width:parseFloat(t[5]),height:parseFloat(t[6])}};return{selector:n,selectors:[n]}}const r=e.value.match(Ct);if(r){const n={type:"TemporalSelector",temporal:{startTime:r[4]?parseFloat(r[4]):0,endTime:r[7]?parseFloat(r[7]):void 0}};return{selector:n,selectors:[n]}}return{selector:null,selectors:[]}}return{selector:null,selectors:[]}}function M(e,t={}){if(Array.isArray(e))return M(e[0]);if(typeof e=="string"){const[r,n]=e.split("#");return n?M({type:"SpecificResource",source:{id:r,type:"Unknown"},selector:{type:"FragmentSelector",value:n}}):{type:"SpecificResource",source:{id:r,type:t.typeMap&&t.typeMap[r]||"Unknown"},selector:null,selectors:[]}}if(e.type==="Choice"||e.type==="List"||e.type==="Composite"||e.type==="Independents")return M(e.items[0]);if(e.type==="SpecificResource"){e.source.type==="Canvas"&&e.source.partOf&&typeof e.source.partOf=="string"&&(e.source.partOf=[{id:e.source.partOf,type:"Manifest"}]);const{selector:r,selectors:n}=e.selector?Y(e.selector):{selector:null,selectors:[]};return{type:"SpecificResource",source:e.source,selector:r,selectors:n}}if(e.id){e.type==="Canvas"&&e.partOf&&typeof e.partOf=="string"&&(e.partOf=[{id:e.partOf,type:"Manifest"}]);const[r,n]=e.id.split("#");return n?M({type:"SpecificResource",source:se(ie({},e),{id:r}),selector:{type:"FragmentSelector",value:n}}):{type:"SpecificResource",source:se(ie({},e),{id:r}),selector:null,selectors:[]}}return{type:"SpecificResource",source:e,selector:null,selectors:[]}}function Rt(e={},t=[]){const{id:r,selector:n}=e,o=U(),i=R(),s=r||o.annotation,a=b(u=>s?u.iiif.entities.Annotation[s]:void 0,[s]),d=b(u=>a&&a.body?a.body.map(l=>l?u.iiif.entities[l.type][l.id]:null).filter(Boolean):[],[a]);return c.useMemo(()=>{if(!a)return;const u=E(y({},a),{body:d,target:M(a.target,{typeMap:i.getState().iiif.mapping})});return n?n(u):u},[a,n,d,...t])}function _(e={},t=[]){const{id:r,selector:n}=e,o=U(),i=r||o.canvas,s=b(a=>i?a.iiif.entities.Canvas[i]:void 0,[i]);return c.useMemo(()=>{if(!!s)return n?n(s):s},[s,n,...t])}const ye=({id:e,style:t,className:r,interactive:n})=>{const o=Rt({id:e}),i=V(o,"atlas"),s=V(o,"html"),a=he(o,["atlas"]),d=_(),u=c.useMemo(()=>L.mergeStyles(t,i),[t,i]);return d&&o&&o.target&&o.target.selector&&o.target.selector.type==="BoxSelector"&&o.target.source&&o.target.source.id===d.id?f.jsx(L.RegionHighlight,y({id:o.id,isEditing:!0,region:o.target.selector.spatial,style:u,className:(s==null?void 0:s.className)||r,interactive:!!((s==null?void 0:s.href)||n),href:(s==null?void 0:s.href)||null,title:(s==null?void 0:s.title)||null,hrefTarget:(s==null?void 0:s.target)||null},a)):null},Q=({className:e,page:t})=>{var o;const r=V(t,"atlas"),n=V(t,"html");return b(i=>t.id?i.iiif.entities.AnnotationPage[t.id]:null,[]),f.jsx(c.Fragment,{children:(o=t.items)==null?void 0:o.map(i=>f.jsx(ye,{id:i.id,style:r,className:(n==null?void 0:n.className)||e},i.id))})};function ve({id:e,image:t,thumbnail:r,isStatic:n,x:o=0,y:i=0,annotations:s,children:a}){var d,u,l,p;return f.jsx(c.Fragment,{children:t.service?f.jsxs(c.Fragment,{children:[f.jsx(L.TileSet,{tiles:{id:t.service.id||t.service["@id"]||"unknown",height:t.height,width:t.width,imageService:t.service,thumbnail:r&&r.type==="fixed"?r:void 0},x:((d=t.target)==null?void 0:d.spatial.x)+o,y:((u=t.target)==null?void 0:u.spatial.y)+i,width:(l=t.target)==null?void 0:l.spatial.width,height:(p=t.target)==null?void 0:p.spatial.height}),s,a]},"service"):f.jsxs(c.Fragment,{children:[f.jsx("world-image",{uri:t.id,target:t.target.spatial,display:t.width&&t.height?{width:t.width,height:t.height}:void 0}),s,a]},"no-service")},e)}function At(e){return e.type==="SpecificResource"?[e.source,{selector:e.selector}]:[e,{selector:null}]}function bt(e,t,r){const n=[];let o=null;const i=[];for(const s of t){const a=e.get(s.body);for(const d of a){const[u,{selector:l}]=At(d),p=(u.type||"unknown").toLowerCase();if(p==="choice"){const m=e.get(u.items),v=r.length?r.map(g=>m.find(h=>h.id===g)).filter(Boolean):[m[0]];v.length===0&&v.push(m[0]),o={type:"single-choice",items:m.map(g=>({id:g.id,label:g.label,selected:v.indexOf(g)!==-1})),label:d.label},a.push(...v);continue}n.indexOf(p)===-1&&n.push(p),i.push({type:p,resource:u,target:s.target,selector:l})}}return{types:n,items:i,choice:o}}const Tt={makeChoice:()=>{}},ae={type:"unknown"},x=e=>({type:"unknown",reason:e,annotations:{pages:[]}});function K(e={},t=[]){const{id:r,selector:n}=e,o=U();R();const i=r||o.manifest,s=b(a=>i?a.iiif.entities.Manifest[i]:void 0,[i]);return c.useMemo(()=>{if(!!s)return n?n(s):s},[s,n,...t])}function Mt(e,t){var n;const r=(n=e==null?void 0:e.iiif)==null?void 0:n.meta[t];return r?r.annotationPageManager:null}function wt(e,t){return b(r=>{const n=[];if(!e)return n;const o=Object.keys(r.iiif.entities.AnnotationPage);for(const i of o)if(!t||t.indexOf(i)!==-1){const s=Mt(r,i);s&&s.views&&s.views[e]&&n.push(i)}return n},[e,t])}function _t({canvas:e,manifest:t,all:r,canvases:n}){const o=[];if(t)for(const i of t.annotations)o.indexOf(i.id)===-1&&o.push(i.id);if(r){if(n&&n.length)for(const i of n)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 jt(e,t){var n;const r=(n=e==null?void 0:e.iiif)==null?void 0:n.meta[t];return r?r.annotationPageManager:null}function Ot(e,t={}){const r=R(),n=K(),o=_(),i=Ve(),s=c.useMemo(()=>_t({all:t.all,manifest:n,canvas:o,canvases:i}),[t.all,o,i,n]),a=wt(e,t.all?void 0:s),d=c.useCallback(l=>{!e||r.setMetaValue([l,"annotationPageManager","views"],p=>p&&!p[e]?p:E(y({},p||{}),{[e]:!1}))},[e,r]),u=c.useCallback((l,p={})=>{if(!e)return;const m=r.getState(),v=[];if(p!=null&&p.deselectOthers){const g=Object.keys(m.iiif.entities.AnnotationPage);for(const h of g){const T=jt(m,h);T&&T.views&&T.views[e]&&v.push(h)}}for(const g of v)d(g);r.setMetaValue([l,"annotationPageManager","views"],g=>g&&g[e]?g:E(y({},g||{}),{[e]:!0}))},[e,d,r]);return{availablePageIds:s,enabledPageIds:a,setPageEnabled:u,setPageDisabled:d}}function It(e,t){return b((r,n)=>n.get(e.map(o=>({id:o,type:t}))),[e,t])}const kt=w.default.createContext(new j.ImageServiceLoader);function Ee(){return c.useContext(kt)}function Ft(){const e=Ee(),[t,r]=c.useState({}),n=c.useRef(!1);return c.useEffect(()=>()=>{n.current=!0},[]),[c.useCallback((i,{height:s,width:a})=>{if(i){const d=i.id||i["@id"],u=e.loadServiceSync({id:d,width:i.width||a,height:i.height||s,source:i});u?i=u:t[d]||(n.current||r(l=>E(y({},l),{[d]:"loading"})),e.loadService({id:d,width:i.width||a,height:i.height||s}).then(()=>{n.current||r(l=>E(y({},l),{[d]:"done"}))}))}return i},[e,t]),t]}function Lt(e={}){const t=_(e.canvasId?{id:e.canvasId}:void 0);return b((r,n)=>{if(!t)return[];const o=n.get(t.items),i=[];for(const s of o)i.push(...n.get(s.items));return i},[t])}function Vt(e,t=[]){const r=R(),n=Lt(),[o,i]=c.useState((e==null?void 0:e.defaultChoices)||[]),s=c.useMemo(()=>bt(r,n,o),[r,n,o,...t]),d={makeChoice:c.useCallback((u,{deselectOthers:l=!0,deselect:p=!1}={})=>{if(s.choice){if(s.choice.type!=="single-choice")throw new Error("Complex choice not supported yet");i(m=>{if(p){const g=m.filter(h=>h!==u);if(g.length===0){const h=s.items[0].resource.id;return h?[h]:[]}return g}if(l)return[u];const v=[...m];if(v.length===0&&s.items.length){const g=s.items[0].resource.id;g&&v.push(g)}return m.indexOf(u)!==-1?m:[...m,u]})}},[s.choice])};return[s,d]}function Ut(e,t,r){const n=[];for(const o of t.items){const i=o.resource&&o.resource.type==="SpecificResource"?o.resource.source:o.resource;if(!i.id)return x("No resource Identifier");let s;if(i.service){const h=j.getImageServices(i);h[0]&&(s=r(h[0],e))}const{selector:a,source:d}=M(o.target);if(d.id!==e.id)continue;const u={type:"BoxSelector",spatial:{x:0,y:0,width:e.width,height:e.height}},l=a?a.type==="TemporalSelector"?{type:"TemporalBoxSelector",temporal:a.temporal,spatial:u.spatial}:a:null,p={type:"BoxSelector",spatial:{x:0,y:0,width:e.width,height:e.height}},m=o.resource.type==="SpecificResource"?M(o.resource):null,v=m&&m.selector&&(m.selector.type==="BoxSelector"||m.selector.type==="TemporalBoxSelector")?{type:"BoxSelector",spatial:{x:m.selector.spatial.x,y:m.selector.spatial.y,width:m.selector.spatial.width,height:m.selector.spatial.height}}:p;s&&!s.id&&(s.id=s["@id"]);const g={id:i.id,type:"Image",width:l?i.width:e.width,height:l?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:u,selector:v};n.push(g)}return{type:"images",image:n[0],images:n,choice:t.choice}}const Dt=["model/gltf-binary"];function Nt(e,t){const n=t.items[0].resource;return n.format?Dt.indexOf(n.format)===-1?x(`3D format: ${n.format} is unsupported`):{type:"3d-model",model:n}:x("Unknown format")}function Bt(e,t){var n;if(!e.duration)return x("No duration on canvas");if(t.items.length>1)return x("Only one audio source supported");const r=(n=t.items[0])==null?void 0:n.resource;return r?r.format?{type:"media",media:{duration:e.duration,url:r.id,type:"Sound",target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:r.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},annotations:{pages:[]}}:x("Audio does not have format"):x("Unknown audio")}function Ht(e,t){var o;const r=t.items.filter(i=>i.type==="video");if(!e.duration)return x("No duration on canvas");if(r.length>1)return x("Only one video source supported");const n=(o=r[0])==null?void 0:o.resource;return n?n.format?{type:"media",media:{duration:e.duration,url:n.id,type:"Video",items:[],target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:n.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},annotations:{pages:[]}}:x("Video does not have format"):x("Unknown video")}function Yt(e){const t=K(),r=_(),n=R(),[o,i]=Ft(),{enabledPageIds:s}=Ot((e==null?void 0:e.annotationPageManagerId)||(t==null?void 0:t.id)||(r==null?void 0:r.id),{all:!1}),a=It(s,"AnnotationPage"),d=(e==null?void 0:e.strategies)||["images","media","complex-timeline"],[u,l]=Vt(e,[i]),p=c.useMemo(()=>{if(!r||u.types.length===0)return ae;if(u.types.length!==1)if(u.types.length===2&&u.types.indexOf("text")!==-1)u.types=u.types.filter(v=>v!=="text");else return d.indexOf("complex-timeline")===-1?x("Complex timeline not supported"):x("ComplexTimelineStrategy not yet supported");const m=u.types[0];return m==="image"?d.indexOf("images")===-1?x("Image not supported"):Ut(r,u,o):m==="Model"||m==="model"?d.indexOf("3d-model")===-1?x("3D not supported"):Nt(r,u):m==="sound"||m==="audio"?d.indexOf("media")===-1?x("Media not supported"):Bt(r,u):m==="video"?d.indexOf("media")===-1?x("Media not supported"):Ht(r,u):ae},[r,u,n,l.makeChoice]);return c.useMemo(()=>p.type==="unknown"?[p,Tt]:[E(y({},p),{annotations:{pages:a}}),l],[p,a])}const Qt=(e,t=[])=>{const r=R();c.useEffect(()=>{e(r)},[r,...t])};function zt(e,t={}){const r=t.imageServiceLoader||new j.ImageServiceLoader;async function n(o,i,s,a=[],d){if(typeof o=="string")return{best:j.getFixedSizeFromImage(o),fallback:[],log:[]};const u=e.get(o);if(typeof u=="string")return{best:j.getFixedSizeFromImage(u),fallback:[],log:[]};switch(u.type){case"Annotation":{const l=u.body,p=e.get(l[0]);return d&&!p.width&&(p.width=d.width,p.height=d.height),await r.getThumbnailFromResource(p,i,s,a)}case"Canvas":{const l=u;if(l.thumbnail&&l.thumbnail.length){const p=e.get(l.thumbnail[0]),m=await r.getImageCandidates(p,s);m&&m.length&&a.push(...m)}return n(l.items[0],i,s,a,{width:l.width,height:l.height})}case"AnnotationPage":return n(u.items[0],i,s,a,d);case"Choice":return n(u.items[0],i,s,a,d);case"Collection":{const p=u.items[0];return n(p,i,s,a,d)}case"Manifest":{const p=u.items[0];return n(p,i,s,a,d)}case"SpecificResource":case"Image":case"Dataset":case"Sound":case"Text":case"TextualBody":case"Video":return d&&!u.width&&(u.width=d.width,u.height=d.height),r.getThumbnailFromResource(u,i,s,a);case"Service":case"Range":case"AnnotationCollection":case"CanvasReference":case"ContentResource":return{best:void 0,fallback:[],log:[]}}return{best:void 0,fallback:[],log:[]}}return{getBestThumbnailAtSize:n}}function $t(e,t,{canvasId:r,manifestId:n}={}){const o=R(),i=Ee(),s=c.useMemo(()=>zt(o,{imageServiceLoader:i}),[o,i]),[a,d]=c.useState(),u=K(n?{id:n}:void 0),l=_(r?{id:r}:void 0),p=l||u,m=c.useRef(!1);if(c.useEffect(()=>()=>{m.current=!0},[]),!p)throw new Error("Must be called under a manifest or canvas context.");return Qt(v=>{s.getBestThumbnailAtSize(p,e,t).then(g=>{g.best&&!m.current&&d(g.best)})},[p]),a}function qt(e){return{isMuted:!1,playRequested:!1,isPlaying:!1,isFinished:!1,volume:100,duration:e}}function Gt(e,t){switch(t.type){case"FINISHED":return E(y({},e),{isFinished:!0,isPlaying:!1,playRequested:!1});case"PLAY_PAUSE":return E(y({},e),{isFinished:!1,isPlaying:!e.isPlaying});case"PLAY_REQUESTED":return E(y({},e),{isFinished:!1,playRequested:!0});case"PAUSE":return E(y({},e),{isPlaying:!1});case"PLAY":return E(y({},e),{isFinished:!1,playRequested:!1,isPlaying:!0});case"MUTE":return E(y({},e),{isMuted:!0});case"SET_VOLUME":return E(y({},e),{volume:t.volume,isMuted:t.volume===0});case"TOGGLE_MUTE":return E(y({},e),{isMuted:!e.isMuted});case"UNMUTE":return E(y({},e),{isMuted:!1})}return e}function Kt(e){const t=Math.round(e);return`${Math.floor(t/60)}:${`${t%60}`.padStart(2,"0")}`}function xe(e){const[t,r]=c.useReducer(Gt,qt(e.duration)),n=c.useRef(null),o=c.useRef(null),i=c.useRef(null),s=c.useRef(!1),a=c.useCallback(()=>{o.current&&n.current&&(o.current.innerHTML=Kt(n.current.currentTime),i.current&&(i.current.style.width=`${n.current.currentTime/e.duration*100}%`),s.current!==n.current.muted&&(s.current=n.current.muted,r(n.current.muted?{type:"MUTE"}:{type:"UNMUTE"})))},[e.duration]),d=c.useCallback(()=>{n.current&&(r({type:"PLAY_REQUESTED"}),n.current.play().then(()=>{r({type:"PLAY"})}),a())},[a]),u=c.useCallback(()=>{n.current&&(n.current.duration>0&&n.current.paused?d():l())},[a]),l=c.useCallback(()=>{n.current&&(n.current.pause(),r({type:"PAUSE"}),a())},[a]),p=c.useCallback(()=>{n.current&&(n.current.muted=!n.current.muted,r(n.current.muted?{type:"MUTE"}:{type:"UNMUTE"}))},[]),m=c.useCallback(()=>{n.current&&(n.current.muted=!0,r({type:"MUTE"}))},[]),v=c.useCallback(()=>{n.current&&(n.current.muted=!1,r({type:"UNMUTE"}))},[]),g=c.useCallback(C=>{n.current&&(n.current.muted=!1,n.current.volume=C/100,r({type:"SET_VOLUME",volume:C}))},[]),h=c.useCallback(C=>{n.current&&(n.current.currentTime=Math.max(0,Math.min(C*e.duration,e.duration)),a())},[]),T=c.useCallback(C=>{n.current&&(n.current.currentTime=Math.max(0,Math.min(C,e.duration)),a())},[]);return c.useEffect(()=>{const C=setInterval(()=>{a()},350);return()=>clearInterval(C)},[a,e.duration]),c.useEffect(()=>{const C=()=>{r({type:"FINISHED"})},P=n.current;return P==null||P.addEventListener("ended",C),()=>P==null?void 0:P.removeEventListener("ended",C)},[]),[{element:n,currentTime:o,progress:i},t,{play:d,pause:l,playPause:u,mute:m,unmute:v,toggleMute:p,setVolume:g,setDurationPercent:h,setTime:T}]}const Wt=c.createContext(null),Xt=c.createContext(null),Jt=c.createContext(null);function Se({actions:e,state:t,children:r,currentTime:n,progress:o,element:i}){return f.jsx(Jt.Provider,{value:{currentTime:n,progress:o,element:i},children:f.jsx(Xt.Provider,{value:e,children:f.jsx(Wt.Provider,{value:t,children:r})})})}function Zt({media:e,children:t}){const[{element:r,currentTime:n,progress:o},i,s]=xe({duration:e.duration});return f.jsx(f.Fragment,{children:f.jsx(O,{children:f.jsxs(Se,{state:i,actions:s,currentTime:n,progress:o,element:r,children:[f.jsx("audio",{ref:r,src:e.url}),t]})})})}function en({media:e,children:t}){const[{element:r,currentTime:n,progress:o},i,s]=xe({duration:e.duration}),a="div";return f.jsxs(f.Fragment,{children:[f.jsxs(O,{overlay:!0,children:[f.jsx("style",{children:`
|
|
10
2
|
.video-container {
|
|
11
3
|
position: absolute;
|
|
12
4
|
top: 0;
|
|
@@ -19,7 +11,7 @@
|
|
|
19
11
|
justify-content: center;
|
|
20
12
|
pointer-events: visible;
|
|
21
13
|
}
|
|
22
|
-
`}),
|
|
14
|
+
`}),f.jsx(a,{className:"video-container",part:"video-container",onClick:()=>s.playPause(),children:f.jsx("video",{ref:r,src:e.url,style:{width:"100%",objectFit:"contain"}})})]}),f.jsx(O,{children:f.jsx(Se,{state:i,actions:s,currentTime:n,progress:o,element:r,children:t})})]})}function tn({model:e}){return f.jsxs(O,{overlay:!0,children:[f.jsx("style",{children:`
|
|
23
15
|
.model-container {
|
|
24
16
|
position: absolute;
|
|
25
17
|
top: 0;
|
|
@@ -32,5 +24,5 @@
|
|
|
32
24
|
justify-content: center;
|
|
33
25
|
pointer-events: visible;
|
|
34
26
|
}
|
|
35
|
-
`}),
|
|
27
|
+
`}),f.jsx("div",{className:"model-container",children:f.jsx("model-viewer",{"interaction-prompt":"none",style:{width:"100%",height:"100%"},"camera-controls":"","ar-status":"not-presenting",src:e.id})})]})}function Pe({x:e,y:t,onChoiceChange:r,registerActions:n,defaultChoices:o,isStatic:i,renderViewerControls:s,renderMediaControls:a,strategies:d,children:u}){const l=_(),p=he(l,["deep-zoom"]),[m]=lt(),v=R(),g=c.useMemo(()=>ge(v),[v]),[h,T]=Yt({strategies:d||["images"],defaultChoices:o==null?void 0:o.map(({id:A})=>A)}),C=h.type==="images"?h.choice:void 0;c.useEffect(()=>{n&&n(T)},[h.annotations]),c.useEffect(()=>{if(o)for(const A of o)typeof A.opacity!="undefined"&&g.applyStyles({id:A.id},"atlas",{opacity:A.opacity})},[o]),c.useLayoutEffect(()=>{r&&r(C)},[C]);const P=$t({maxWidth:256,maxHeight:256});if(!l)return null;const W=l.accompanyingCanvas,I=P&&P.type==="fixed"?f.jsx("world-object",{height:l.height,width:l.width,x:e,y:t,children:f.jsx("world-image",{uri:P.id,target:{x:0,y:0,width:l.width,height:l.height},display:P.width&&P.height?{width:P.width,height:P.height}:void 0})}):null;if(h.type==="unknown"){if(I)return I;throw new Error(h.reason||"Unknown image strategy")}const Ce=f.jsxs(c.Fragment,{children:[m?f.jsx(Q,{page:m}):null,h.annotations&&h.annotations.pages?h.annotations.pages.map(A=>f.jsx(Q,{page:A},A.id)):null,u]});return f.jsxs(f.Fragment,{children:[f.jsxs("world-object",E(y({height:l.height,width:l.width,x:e,y:t},p),{children:[h.type==="images"?f.jsxs(f.Fragment,{children:[h.images.map((A,Re)=>f.jsx(ve,{isStatic:i,image:A,id:A.id,thumbnail:Re===0?P:void 0,annotations:Ce},A.id)),s?f.jsx(O,{overlay:!0,children:s(h)}):null]}):null,h.type==="3d-model"?f.jsx(tn,{model:h.model}):null,h.type==="media"?f.jsx(f.Fragment,{children:h.media.type==="Sound"?f.jsxs(Zt,{media:h.media,children:[I,a?a(h):null]}):h.media.type==="Video"?f.jsxs(en,{media:h.media,children:[I,a?a(h):null]}):null}):null]}),h.type),h.type==="media"&&h.media.type==="Sound"&&W?f.jsx(Le,{canvas:W.id,children:f.jsx(Pe,{renderViewerControls:s})}):null]})}const nn={RenderImage:ve,RenderCanvas:Pe,RenderAnnotationPage:Q,RenderAnnotation:ye,Viewer:ht};exports.CanvasPanel=nn;
|
|
36
28
|
//# sourceMappingURL=canvas-panel.js.map
|