react-iiif-vault 0.9.12 → 0.9.13

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