react-iiif-vault 1.3.2 → 1.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.d.ts +1 -1
- package/dist/bundle.global.js +9 -9
- package/dist/canvas-panel.cjs +5 -5
- package/dist/canvas-panel.js +1 -1
- package/dist/{chunk-37JMKXWA.js → chunk-L6FWDFSU.js} +7 -7
- package/dist/chunk-UFC4ZSNV.js +1 -0
- package/dist/index.cjs +6 -6
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-QCPOOHCR.js +0 -1
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as wo,A as to,Aa as on,B as oo,Ba as D,C as no,Ca as nn,D as ro,Da as un,E as io,Ea as dn,F as ao,Fa as le,G as so,Ga as fn,H as lo,Ha as pn,I as co,Ia as gn,J as mo,Ja as hn,K as uo,Ka as yn,L as fo,La as vn,M as po,Ma as xn,N as go,Na as bn,O as ho,Oa as Sn,P as yo,Pa as ce,Q as vo,R as xo,S as bo,T as So,U as ie,V as Co,W as Io,X as ae,Y as ko,Z as Po,_ as To,a as Wt,aa as Ro,b as A,ba as Eo,c as B,ca as Mo,d as Dt,da as No,e as Ft,ea as Bo,f as Ot,fa as T,g as te,ga as Lo,h as $t,ha as Ho,i as Vt,ia as Ao,j as oe,ja as zo,k as P,ka as qo,l as z,la as Wo,m as Xt,ma as Do,n as ne,na as Fo,o as q,oa as Oo,p as Yt,pa as $o,q as _t,qa as Vo,r as Kt,ra as Xo,s as Qt,sa as Yo,t as Ut,ta as _o,u as Gt,ua as N,v as Jt,va as jo,w as re,wa as se,x as Zt,xa as en,y as jt,ya as tn,z as eo,za as W}from"./chunk-37JMKXWA.js";import{a as Ko,b as Qo,c as Uo,d as Go,e as Jo,f as Zo,g as rn,h as an,i as sn,j as ln,k as cn,l as mn}from"./chunk-QCPOOHCR.js";import{useCanvas as We}from"@atlas-viewer/atlas";import{forwardRef as De,useImperativeHandle as Fe}from"react";import{Fragment as Oe,jsx as me}from"react/jsx-runtime";var wn=De(function({canvasId:t},o){let n=We(),i=se(t||n?.id),a=P();return Fe(o,()=>i,[t,n]),!n||i.enabledPageIds.length===0?null:me(Oe,{children:i.enabledPageIds.map(s=>me(ce.RenderAnnotationPage,{page:a.get(s)},s))})});import{useMemo as Xe}from"react";import{useMemo as $e}from"react";import{Fragment as Ve,jsx as C,jsxs as F}from"react/jsx-runtime";function O({metadata:e=[],config:t,labelWidth:o=16,showEmptyMessage:n=!0,allowHtml:i,emptyFallback:a,classes:s={},emptyMessage:l="No metadata available",emptyValueFallback:u="No value",emptyLabelFallback:m="",separator:c,tableFooter:f,tableHeader:x}){let h=$e(()=>{let g=(t||[]).reduce((p,b)=>[...p,...b.keys],[]),d={};for(let p of e){let b=p&&p.label?Object.values(p.label):[];for(let r of b)if(r&&r.length&&(g.indexOf(`metadata.${r[0]}`)!==-1||g.length===0)&&p){let S=`metadata.${r[0]}`;d[S]=d[S]?d[S]:[],d[S].push(p);break}}return d},[t,e]);return Object.keys(h).length===0&&n?C(Ve,{children:a})||C("div",{className:s.empty,children:l}):t&&t.length?F("table",{className:s.container,children:[x,C("tbody",{children:t.map((g,d)=>{let p=[];for(let b of g.keys)for(let r of h[b]||[])p.push(C(N,{enableDangerouslySetInnerHTML:i,defaultText:u,separator:c,children:r.value},d+"__"+b));return p.length===0?null:F("tr",{className:s.row,children:[C("td",{className:s.label,style:o?{minWidth:o}:{},children:C(N,{enableDangerouslySetInnerHTML:i,separator:c,defaultText:m,children:g.label})}),C("td",{className:s.value,children:p})]},d)})}),f]}):F("table",{className:s.container,children:[x,C("tbody",{children:e&&e.length?e.map((g,d)=>g?F("tr",{className:s.row,children:[C("td",{className:s.label,style:o?{minWidth:o}:{},children:C(N,{enableDangerouslySetInnerHTML:i,defaultText:u,separator:c,children:g.label})}),C("td",{className:s.value,children:C(N,{enableDangerouslySetInnerHTML:i,defaultText:u,separator:c,children:g.value})})]},d):null):null}),f]})}import{jsx as Ye}from"react/jsx-runtime";function Fn(e){let t=q(),o=T(),n=re(),i=Xe(()=>{let a=t?.metadata||[],s=o?.metadata||[],l=n?.metadata||[];return[...a,...s,...l]},[t,o,n]);return Ye(O,{metadata:i,...e})}import{useEffect as Ue,useState as Ge}from"react";import{createImageServiceRequest as _e,imageServiceRequestToString as Ke}from"@atlas-viewer/iiif-image-api";import{useMemo as Qe}from"react";function Q(e,t={},o=[]){return Qe(()=>{if(!e)return null;let n=t.quality;e&&e.extraQualities&&t.quality&&(e.extraQualities.includes(t.quality)||(n="default"));let i=_e(e);return Ke({identifier:i.identifier,server:i.server,scheme:i.scheme,type:"image",size:{max:!t.size?.width&&!t.size?.height,confined:!1,upscaled:!1,...t.size||{}},format:t.format||"jpg",region:t.region||{full:!0},rotation:t?.rotation?Number.isInteger(t.rotation)?{angle:t.rotation}:t.rotation:{angle:0},quality:n||"default",prefix:i.prefix,originalPath:i.originalPath})},[...o])}import{jsx as $}from"react/jsx-runtime";function Je(e){let t=typeof e.src=="string"?e.src:e.src.id,o=W(),[n,i]=Ge(!1),a;if(t){let l=o.loadServiceSync({id:t});l&&(a=l)}!a&&!n&&o.loadService({id:t}).then(()=>{i(!0)});let s=Q(a,{size:e.size,selector:e.region,rotation:e.rotation,format:e.format,region:e.region,quality:e.quality},[n,e.src,e.size,e.region,e.rotation,e.format,e.region,e.quality]);return Ue(()=>()=>{i(!1)},[t]),s?$("img",{src:s,alt:e.alt,className:e.className,style:e.style}):$(Ze,{...e,fetchImageService:!1})}function Ze(e){if(e.fetchImageService)return $(Je,{...e});let t=typeof e.src=="string"?{id:e.src,profile:"level0"}:e.src,o=Q(t,{size:e.size,selector:e.region,rotation:e.rotation,format:e.format,region:e.region,quality:e.quality},[e.src,e.size,e.region,e.rotation,e.format,e.region,e.quality]);return o?$("img",{src:o,alt:e.alt,className:e.className,style:e.style}):null}import{jsx as je}from"react/jsx-runtime";function or(e){let t=q();return je(O,{metadata:t?.metadata||[],...e})}import{useLayoutEffect as rt,useRef as it}from"react";import*as U from"react-lazy-load-image-component";import{getValue as et}from"@iiif/helpers/i18n";import{Fragment as ue,jsx as w,jsxs as nt}from"react/jsx-runtime";var{LazyLoadComponent:tt}=U||U.default;function de(e){let{size:t,visible:o,classes:n,canvasId:i,figure:a}=e,s=t?.width||128,l=t?.height||t?.width||128,u=w(ot,{...e}),m=w(tt,{threshold:300,style:{height:l,width:s},visibleByDefault:o,children:i?w(oe,{canvas:i,children:u}):u});return a?w("figure",{className:n?.figure,children:m}):m}function ot({fallback:e,size:t,classes:o,showLabel:n,alt:i,dereference:a=!1}){let s=T(),l=t?.width||128,u=t?.height||t?.width||128,m=i||et(s?.label)||"",c=le({width:l,height:u},a);return!c||c.type!=="fixed"?w(ue,{children:e}):nt(ue,{children:[w("div",{className:o?.imageWrapper,children:w("img",{className:o?.img,src:c.id,alt:m})}),n?w(N,{as:"figcaption",className:o?.label,children:s?.label}):null]})}import{jsx as L}from"react/jsx-runtime";function gr({flat:e,size:t,classes:o={},showLabel:n,figure:i,fallback:a}){let s=it(null),{items:l,sequence:u,currentSequenceIndex:m,setSequenceIndex:c}=ie(),f={row:o.selected?.row||o.row,item:o.selected?.item||o.item,figure:o.selected?.figure||o.figure,img:o.selected?.img||o.img,label:o.selected?.label||o.label,imageWrapper:o.selected?.imageWrapper||o.imageWrapper};rt(()=>{if(!s.current)return;let h=s.current.querySelector("[data-selected=true]");h&&h.scrollIntoView({behavior:"smooth",block:"nearest",inline:"center"})},[m]);let x=[];for(let h of u){let I=[],g=u[m]===h;for(let d of h){let p=l[d];I.push(L("div",{className:g?f.item:o.item,children:L(de,{classes:g?f:o,canvasId:p.id,size:t,showLabel:n,figure:i,placeholder:L("div",{style:{height:128,width:128}}),fallback:a})},d))}if(e){x.push(I);continue}x.push(L("div",{onClick:d=>{c(u.indexOf(h))},"data-selected":g,className:g?f.row:o.row,children:I},h.join("-")))}return L("div",{ref:s,className:o.container,children:x})}import{Fragment as fe,jsx as R,jsxs as pe}from"react/jsx-runtime";var at={draw:!0,polygon:!0,line:!0,lineBox:!0,square:!0,triangle:!0,hexagon:!0,circle:!0,delete:!0};function vr({helper:e,showShapes:t,state:o,enabled:n=at,classNames:i={},icons:a={}}){return pe(fe,{children:[t?pe(fe,{children:[n.draw&&R("button",{className:i.button,onClick:()=>{e.stamps.clear(),e.draw.enable()},"data-active":!o.lineMode&&!o.selectedStamp&&t&&o.drawMode,children:a.DrawIcon||"Draw"}),n.polygon&&R("button",{className:i.button,"data-active":!o.lineMode&&!o.selectedStamp&&t&&!o.drawMode,onClick:()=>{e.stamps.clear(),e.draw.disable(),e.modes.disableLineBoxMode(),e.modes.disableLineMode()},children:a.PolygonIcon||"Polygon"}),n.line&&R("button",{className:i.button,"data-active":o.lineMode&&!o.lineBoxMode,onClick:()=>{e.modes.enableLineMode()},children:a.LineIcon||"Line"}),n.lineBox&&R("button",{className:i.button,"data-active":o.lineBoxMode,onClick:()=>{e.modes.enableLineBoxMode()},children:a.LineBoxIcon||"LineBox"}),n.square&&R("button",{className:i.button,"data-active":o.selectedStamp?.id==="square",onClick:()=>{e.stamps.square()},children:a.SquareIcon||"Square"}),n.triangle&&R("button",{className:i.button,"data-active":o.selectedStamp?.id==="triangle",onClick:()=>{e.stamps.triangle()},children:a.TriangleIcon||"Triangle"}),n.hexagon&&R("button",{className:i.button,"data-active":o.selectedStamp?.id==="hexagon",onClick:()=>{e.stamps.hexagon()},children:a.HexagonIcon||"Hexagon"})]}):null,o.showBoundingBox&&n.delete&&R("button",{className:i.button,onClick:()=>e.key.down("Backspace"),children:a.DeleteForeverIcon||"Delete"})]})}import{createContext as st,useCallback as ge,useContext as ye,useEffect as he,useMemo as G,useState as lt}from"react";import ve from"mitt";import{jsx as ct}from"react/jsx-runtime";var V=st(ve());V.displayName="SelectorHelper";function Tr({children:e}){return ct(V.Provider,{value:G(()=>ve(),[]),children:e})}function wr(){return ye(V)}function xe(e){let t=be(),[o,n]=lt(!1);he(()=>t.withSelector(e).on("highlight",()=>{n(!0)}),[t,e]),he(()=>t.withSelector(e).on("clear-highlight",()=>{n(!1)}),[t,e]);let i=ge(s=>{t.emit("click",{selectorId:e,event:s})},[e,t]),a=ge(s=>{t.emit("hover",{selectorId:e,event:s})},[e,t]);return{controller:t,onClick:i,onHover:a,isHighlighted:o}}function be(){let e=ye(V);return G(()=>({withSelector(t){return{on(o,n){let i=a=>{a&&a.selectorId===t&&n(a)};return e.on(o,i),()=>{e.off(o,i)}},emit(o,n){e.emit(o,{...n,selectorId:t})}}},on(t,o){return e.on(t,o),()=>{e.off(t,o)}},emit(t,o){e.emit(t,o)}}),[e])}function Rr(){let e=be();return G(()=>({withSelector(t){return{highlight(){e.emit("highlight",{selectorId:t})},clearHighlight(){e.emit("clear-highlight",{selectorId:t})},zoomTo(){e.emit("zoom-to",{selectorId:t})},addEventListener(o,n){return e.emit("event-listener",{selectorId:t,name:o,callback:n}),()=>{e.emit("remove-event-listener",{selectorId:t,name:o,callback:n})}},getImagePreview(){return new Promise((o,n)=>{e.emit("image-preview-request",{selectorId:t,resolve:o,reject:n})})},on(o,n){return e.withSelector(t).on(o,n)}}},highlight(t){e.emit("highlight",{selectorId:t})},clearHighlight(t){e.emit("clear-highlight",{selectorId:t})},zoomTo(t){e.emit("zoom-to",{selectorId:t})},addEventListener(t,o,n){return e.emit("event-listener",{selectorId:t,name:o,callback:n}),()=>{e.emit("remove-event-listener",{selectorId:t,name:o,callback:n})}},getImagePreview(t){return new Promise((o,n)=>{e.emit("image-preview-request",{selectorId:t,resolve:o,reject:n})})},on(t,o){return e.on(t,o)}}),[e])}import{createContext as mt,useContext as ut,useMemo as dt}from"react";import{jsx as ft}from"react/jsx-runtime";function Se(){return{default:{backgroundColor:"rgba(0,0,0,0)",borderWidth:"2px",borderColor:"rgba(252,0,98, .5)"},highlighted:{backgroundColor:"rgba(75, 103, 225, 0.4)",borderWidth:"1px",borderColor:"rgba(75,103,225,0.99)"},hidden:{borderWidth:"0px",borderColor:"rgba(0,0,0,0)",backgroundColor:"rgba(0,0,0,0)",hidden:!0}}}var J=mt(Se());J.displayName="AnnotationStyle";function Ce(){return ut(J)}function Br({theme:e,children:t}){let o=dt(()=>e||Se(),[e]);return ft(J.Provider,{value:o,children:t})}import{HTMLPortal as xt,useAtlas as bt}from"@atlas-viewer/atlas";import{useEffect as ke,useRef as E,useState as Pe}from"react";import{useEffect as pt,useMemo as gt,useState as ht}from"react";import{createHelper as yt}from"polygon-editor";function Ie(e,t,o){let[n,i]=ht({}),a=gt(()=>yt(e,o),[]);return pt(()=>(a.clock.start(t,i),()=>{a.clock.stop()}),[]),{state:n,helper:a}}import{createSvgHelpers as vt}from"polygon-editor";import{Fragment as Te,jsx as v,jsxs as we}from"react/jsx-runtime";var M=vt();function Re(e,t){let{image:o,currentShape:n,onChange:i,hideShapeLines:a}=e,s=E(),l=E(),u=E(),m=E(),c=E(),f=E(),x=E(),h=E(),[I,g]=Pe(null),[d,p]=Pe(!1),{helper:b,state:r}=Ie(n,(y,k)=>{M.updateTransitionBoundingBox(l.current,y,k),M.updateBoundingBoxPolygon(s.current,y,k),M.updateTransitionShape(f.current,y,k),M.updateClosestLinePointTransform(m.current,y,k),M.updateSelectBox(u.current,y,k),M.updatePointLine(x.current,y,k),M.updateDrawPreview(c.current,y,k,3),M.updateLineBox(h.current,y),g(y.transitionDirection),p(y.transitionRotate)},i);ke(()=>{b.setShape(n||null)},t),ke(()=>{let y=()=>{b.modifiers.reset()};return document.addEventListener("mouseleave",y),()=>{document.removeEventListener("mouseleave",y)}},[]);let S=we(Te,{children:[v("marker",{id:"dot",viewBox:"0 0 10 10",refX:"5",refY:"5",markerWidth:"5",markerHeight:"5",children:v("circle",{cx:"5",cy:"5",r:"4",className:"marker"})}),v("marker",{id:"selected",viewBox:"0 0 10 10",refX:"5",refY:"5",markerWidth:"5",markerHeight:"5",children:v("circle",{cx:"5",cy:"5",r:"4",fill:"#FAFF00"})}),v("marker",{id:"resizer",viewBox:"0 0 10 10",refX:"5",refY:"5",markerWidth:"5",markerHeight:"5",children:v("rect",{width:"10",height:"10",stroke:"#FF0DCB",fill:"#fff",strokeWidth:2})})]}),_=n?n.open?"polyline":"polygon":null,ee=!r.showBoundingBox&&r.closestPoint!==null&&r.actionIntentType==="select-point",Ae=r.actionIntentType==="add-open-point",ze=r.transitionIntentType==="split-line",K=r.transitioning&&r.selectedStamp&&r.transitionIntentType==="stamp-shape",qe=n&&_?we(Te,{children:[v(_,{fill:!r.transitioning&&r.showBoundingBox?"rgba(255, 0, 0, .5)":"none",strokeWidth:K?0:2,stroke:a?"transparent":"#000",points:n.points.map(y=>y.join(",")).join(" "),vectorEffect:"non-scaling-stroke",markerStart:r.showBoundingBox?void 0:"url(#dot)",markerMid:r.showBoundingBox?void 0:"url(#dot)",markerEnd:r.showBoundingBox?void 0:"url(#dot)",style:{pointerEvents:"none"}}),r.lineBoxMode&&r.actionIntentType==="close-line-box"?v("polygon",{fill:"rgba(255, 0, 0, .4)",ref:h,stroke:"#000",strokeWidth:2,vectorEffect:"non-scaling-stroke"}):null,r.transitionIntentType==="draw-shape"&&r.transitioning?v("polyline",{ref:c,fill:"none",stroke:"rgba(255, 0, 0, .5)",strokeWidth:2,vectorEffect:"non-scaling-stroke"}):null,!r.showBoundingBox&&r.selectedPoints&&r.selectedPoints.length?v("polyline",{strokeWidth:2,vectorEffect:"non-scaling-stroke",stroke:"transparent",markerStart:"url(#selected)",markerMid:"url(#selected)",markerEnd:"url(#selected)",fill:"transparent",points:n.points.filter((y,k)=>r.selectedPoints?.includes(k)).map(y=>y.join(",")).join(" ")}):null,ee&&r.closestPoint!==null&&n.points[r.closestPoint]?v("polyline",{strokeWidth:2,vectorEffect:"non-scaling-stroke",stroke:"transparent",markerStart:"url(#selected)",markerMid:"url(#selected)",markerEnd:"url(#selected)",fill:"transparent",points:`${n.points[r.closestPoint][0]},${n.points[r.closestPoint][1]}`}):null,!r.transitioning&&(r.actionIntentType==="add-open-point"||r.actionIntentType==="close-shape"||r.actionIntentType==="close-shape-line")?v("polyline",{stroke:"#000",ref:x,strokeWidth:r.actionIntentType==="close-shape"?2:1,vectorEffect:"non-scaling-stroke"}):null,r.hasClosestLine&&(!r.transitionIntentType||r.transitionIntentType==="split-line")?v("g",{ref:m,children:v("polyline",{style:{opacity:.5},markerStart:"url(#dot)",points:"0,0 10,10",vectorEffect:"non-scaling-stroke",fill:"transparent",strokeWidth:2})}):null,r.transitioning?v(_,{ref:f,fill:n.open?"none":"rgba(255, 0, 0, .5)",stroke:"rgba(255, 0, 0, .5)",strokeWidth:n.open?2:0}):null,r.transitioning&&r.transitionIntentType==="select-multiple-points"?v("rect",{ref:u,fill:"rgba(255, 255, 255, .3)",strokeWidth:1,stroke:"rgba(0,0,0,.2)",vectorEffect:"non-scaling-stroke"}):null,r.showBoundingBox?null:v("g",{name:"controls",children:!1}),r.showBoundingBox&&!K?v("polygon",{ref:s,strokeWidth:2,stroke:"#FF0DCB",fill:"none",markerStart:"url(#resizer)",markerMid:"url(#resizer)",markerEnd:"url(#resizer)",vectorEffect:"non-scaling-stroke"}):null]}):null;return{helper:b,state:r,isAddingPoint:Ae,isSplitting:ze,isStamping:K,isHoveringPoint:ee,transitionDirection:I,transitionRotate:d,defs:S,editor:qe}}import{useEffect as Z}from"react";import{createPortal as St}from"react-dom";import{Fragment as Ee,jsx as H,jsxs as X}from"react/jsx-runtime";var Ct=[{name:"Default",outer:{borderWidth:4,borderColor:"rgba(255, 255, 255, .4)"},inner:{borderWidth:2,borderColor:"#000"}},{name:"High contrast",outer:{borderWidth:3,borderColor:"#fff"},inner:{borderWidth:1,borderColor:"#000"}},{name:"Lightsaber",outer:{borderWidth:"4",borderColor:"rgba(56,68,255,0.64)"},inner:{borderWidth:"2",borderColor:"#fff"}},{name:"Bright",outer:{borderWidth:"6",borderColor:"#25d527"},inner:{borderWidth:"3",borderColor:"#a916ff"}},{name:"pink",outer:{borderWidth:"4",borderColor:"#ff00ff"},inner:{borderWidth:"2",borderColor:"#ffffff"}},{name:"fine (dark)",outer:{borderWidth:"1",borderColor:"#000000"},inner:{}},{name:"fine (light)",outer:{borderWidth:"1",borderColor:"#FFF"},inner:{}}];function Me(e){let t=e.theme||Ct[0],o=bt(),{image:n}=e,{helper:i,defs:a,editor:s,state:l,transitionDirection:u,isSplitting:m,transitionRotate:c,isHoveringPoint:f,isAddingPoint:x,isStamping:h}=Re({currentShape:e.shape||null,onChange:e.updateShape,image:e.image,hideShapeLines:!0},[]),I=r=>{i.pointer([[~~r.atlas.x,~~r.atlas.y]])};Z(()=>{let r=S=>{i.key.up(S.key)};return document.addEventListener("keyup",r),()=>{document.removeEventListener("keyup",r)}},[]),Z(()=>{let r=S=>{i.key.down(S.key)};return document.addEventListener("keydown",r),()=>{document.removeEventListener("keydown",r)}},[]),Z(()=>{let r=[];return u&&r.push(`atlas-cursor-${u}`),l.actionIntentType==="cut-line"&&l.modifiers?.Shift&&r.push("atlas-cursor-cut"),(f||l.transitionIntentType==="move-shape"||l.transitionIntentType==="move-point")&&r.push("atlas-cursor-move"),x&&r.push("atlas-cursor-crosshair"),m&&r.push("atlas-cursor-copy"),c&&r.push("atlas-cursor-rotate"),l.transitionIntentType==="draw-shape"&&r.push("atlas-cursor-draw"),o?.canvas&&o.canvas.classList.add(...r),()=>{o?.canvas&&o.canvas.classList.remove(...r)}},[o?.canvas,x,f,m,l.modifiers?.Shift,l.actionIntentType,l.transitionIntentType,u,c]);let g=e.shape&&e.shape?.points.length===0,d=e.renderControls?e.renderControls(i,l,g):null,p=document.getElementById(e.controlsHtmlId||"atlas-controls"),b="shape";return H(Ee,{children:X("world-object",{height:n.height,width:n.width,onMouseMove:I,onMouseDown:i.pointerDown,onMouseUp:i.pointerUp,onMouseLeave:i.blur,children:[e.shape?X(Ee,{children:[H(b,{open:e.shape.open,points:e.shape.points,relativeStyle:!0,style:h?{}:t.outer}),H(b,{open:e.shape.open,points:e.shape.points,relativeStyle:!0,style:h?{}:t.inner})]}):null,X(xt,{relative:!0,interactive:!1,children:[H("div",{style:{position:"absolute",top:0,right:0,left:0,bottom:0},children:X("svg",{width:"100%",height:"100%",viewBox:`0 0 ${n.width} ${n.height}`,tabIndex:-1,children:[H("defs",{children:a}),s]})}),p?St(d,p,"controls"):null]})]})})}import{jsx as Ne}from"react/jsx-runtime";function si(e){let t=T(),o=e.annotationBucket,n=e.readOnly,i=e.id,{onClick:a,isHighlighted:s}=xe(e.id),l=Ce(),u=s?l.highlighted:l[o||"hidden"]||l.hidden;if(!t)return null;if(n){let m="shape",c=e.polygon,f=c.open;return c?Ne(m,{id:`shape-${i}`,points:c.points,open:f,onClick:a,relativeStyle:!0,target:{x:0,y:0,width:t.width,height:t.height},style:u}):null}return Ne(Me,{image:t,shape:e.polygon||{id:e.id,open:!0,points:[]},updateShape:e.updatePolygon,theme:e.theme,controlsHtmlId:e.controlsHtmlId,renderControls:e.renderControls})}import{jsx as It}from"react/jsx-runtime";function ui({annotation:e,children:t}){return It(B,{value:{annotation:e},children:t})}import{jsx as kt}from"react/jsx-runtime";function gi({annotationPage:e,children:t}){return kt(B,{value:{annotationPage:e},children:t})}import{jsx as Pt}from"react/jsx-runtime";function xi({collection:e,children:t}){return Pt(B,{value:{collection:e},children:t})}function Ii(e,t={}){return D(t)}import{useCanvas as Tt}from"@atlas-viewer/atlas";import{useEffect as wt,useMemo as j,useState as Rt}from"react";function Ei({canvasId:e}={}){let t=Tt(),o=ne(),n=j(()=>e?[e]:t?[t.id]:o.map(m=>m.id),[e,t,o]),[i,a]=Rt({}),s=ae();wt(()=>{let m=c=>{let f=c.partOf.canvasId;f&&a(x=>({...x,[f]:c.choice}))};return s.on("choice-change",m),()=>{s.off("choice-change",m)}},[]);let l=j(()=>{let m=[];for(let c of n){let f=i[c];f&&m.push({canvasId:c,choice:f})}return m},[n,i]),u=j(()=>({makeChoice:(m,c)=>{s.emit("make-choice",{choiceId:m,...c})}}),[s]);return{choices:l,actions:u}}function Ni(e,t=!1){}function Ai(e){let o=A().manifest,n=e?e.map(i=>typeof i=="string"?i:i?.id):[];return z(i=>{let a=o?i.iiif.entities.Manifest[o]:void 0,s=a?.items||[];if(typeof e>"u")return s;let l=[];for(let u of a?.items||[])n.indexOf(u.id)!==-1&&l.push(u);return l},[n.join("/")])}import{useMemo as Et}from"react";function Fi(e,t=[]){let{id:o,selector:n}=e,i=A(),a=o||i.collection,s=z(l=>a?l.iiif.entities.Collection[a]:void 0,[a]);return Et(()=>{if(s)return n?n(s):s},[s,n,...t])}import{useEffect as Mt,useMemo as Nt}from"react";import{createEventsHelper as Bt}from"@iiif/helpers/events";function Yi(e,t,o,n,i=[]){let a=P(),s=Nt(()=>Bt(a),[a]);Mt(()=>{let l=e;return l?(s.addEventListener(l,t,o,n),()=>{s.removeEventListener(l,t,o)}):()=>{}},[s,e,t,...i])}function Ui(e,t){let{id:o,isLoaded:n,error:i,resource:a,requestId:s,cached:l}=te(e,t);return{id:o,isLoaded:n,error:i,manifest:a,requestId:s,cached:l}}import{getImageServices as Be}from"@atlas-viewer/iiif-image-api";import{useEffect as Lt,useMemo as Le,useState as Y}from"react";function He({cacheKey:e}={}){let t=T(),o=D(),n=P(),i=W(),[a,s]=Y(void 0),[l,u]=Y(!1),[m,c]=Y("idle"),[f,x]=Y(void 0),h=t?t.id:"undefined",I=Le(()=>{try{if(t&&o.length){let d=o[0],p=n.get(d.body[0]),r=Be(p)[0];return r&&i.loadServiceSync({id:r.id||r["@id"],width:r.width||t.width,height:r.height||t.height})||void 0}}catch(d){console.error(d)}},[h,e,t]),g=m==="success"&&a?a:I;return Lt(()=>{(async()=>{try{if(t&&o.length){let d=o[0],p=n.get(d.body[0]),r=Be(p)[0];if(!r)return;u(!0),c("loading");try{let S=await i.loadService({id:r.id||r["@id"],width:r.width||t.width,height:r.height||t.height})||void 0;s(S),c("success"),u(!1)}catch(S){c("error"),x(S)}}}catch(d){c("error"),x(d)}})()},[h,e]),Le(()=>({data:g,isFetching:l,status:m,error:f}),[g,l,m,f])}function ia(){let e=He();return{isLoading:e.isFetching,tile:e.data?{id:e.data.id||e.data["@id"],width:e.data.width,height:e.data.height,imageService:e.data,thumbnail:void 0}:null}}import{createStylesHelper as Ht}from"@iiif/helpers/styles";import{useMemo as At}from"react";function ma(){let e=P();return At(()=>Ht(e),[e])}export*from"@iiif/helpers/annotation-targets";export{ui as AnnotationContext,gi as AnnotationPageContext,Br as AnnotationStyleProvider,yo as Auth,lo as AuthProvider,io as AuthRContext,ao as AuthReactContext,so as AuthReactContextActions,wn as CanvasAnnotations,oe as CanvasContext,ce as CanvasPanel,xi as CollectionContext,Fn as CombinedMetadata,bn as ComplexTimelineProvider,To as ContextBridge,Me as CreateCustomShape,ko as EventsProvider,Ze as Image,tn as ImageServiceLoaderContext,bo as InnerViewerProvider,Wo as LanguageProvider,Vo as LanguageString,N as LocaleString,Vt as ManifestContext,or as ManifestMetadata,vn as MediaPlayerProvider,O as Metadata,si as PolygonSelector,Yt as RangeContext,Io as ReactEventContext,Dt as ReactVaultContext,vr as RenderSvgEditorControls,B as ResourceProvider,Wt as ResourceReactContext,Tr as SelectorControllerProvider,gr as SequenceThumbnails,So as SimpleViewerProvider,xo as SimpleViewerReactContext,de as SingleCanvasThumbnail,qo as TranslationProvider,Do as TransliterationProvider,Ft as VaultProvider,No as ViewerPresetContext,Mo as VirtualAnnotationProvider,Xt as VisibleCanvasReactContext,oo as authDetailsForResource,eo as createAuthStateStore,to as createProbe,Co as defaultEmitter,Uo as emptyActions,Zo as emptyStrategy,Kt as findAllCanvasesInRange,_t as findFirstCanvasFromRange,Qt as findManifestSelectedRange,Ut as findSelectedRange,jo as flattenAnnotationPageIds,fn as formatTime,rn as get3dStrategy,cn as getComplexTimelineStrategy,Se as getDefaultAnnotationStyles,an as getImageStrategy,Jt as getManifestSequence,Qo as getParsedTargetSelector,mn as getRenderingStrategy,sn as getTextualContentStrategy,ln as getVideoStrategy,Gt as getVisibleCanvasesFromCanvasId,jt as hasAuth,ro as makeAccessServiceRequest,no as makeAccessTokenRequest,Ko as parseSpecificResource,Ct as svgThemes,Go as unknownResponse,Jo as unsupportedStrategy,Ao as useAnnotation,zo as useAnnotationPage,se as useAnnotationPageManager,Ce as useAnnotationStyles,Ii as useAnnotationsAtTime,uo as useAuthActions,po as useAuthService,mo as useAuthStore,ho as useAuthToken,go as useAuthTokens,T as useCanvas,Ei as useCanvasChoices,Ni as useCanvasClock,Zt as useCanvasSequence,xn as useCanvasStartTime,Ai as useCanvasSubset,Xo as useClosestLanguage,Fi as useCollection,Sn as useComplexTimeline,Po as useContextBridge,_o as useCreateLocaleString,fo as useCurrentAuth,wo as useDispatch,ae as useEventEmitter,Yi as useEventListener,Ot as useExistingVault,Ui as useExternalCollection,$t as useExternalManifest,te as useExternalResource,Oo as useIIIFLanguage,Q as useImage,He as useImageService,W as useImageServiceLoader,ia as useImageTile,co as useIsAuthEnabled,on as useLoadImageService,Yo as useLocaleString,q as useManifest,hn as useMediaActions,yn as useMediaElements,gn as useMediaState,nn as usePaintables,D as usePaintingAnnotations,Ie as usePolygonHelper,re as useRange,un as useRenderingStrategy,A as useResourceContext,Lo as useResourceEvents,en as useResources,vo as useSearchService,be as useSelectorController,wr as useSelectorEmitter,xe as useSelectorEvents,Rr as useSelectorHelper,pn as useSimpleMediaPlayer,ie as useSimpleViewer,ma as useStyleHelper,Ho as useStyles,Re as useSvgEditor,le as useThumbnail,$o as useTranslations,Fo as useTransliteration,P as useVault,dn as useVaultEffect,z as useVaultSelector,Bo as useViewerPreset,Ro as useVirtualAnnotationPage,Eo as useVirtualAnnotationPageContext,ne as useVisibleCanvases};
|
|
1
|
+
import{$ as wo,A as to,Aa as on,B as oo,Ba as D,C as no,Ca as nn,D as ro,Da as un,E as io,Ea as dn,F as ao,Fa as le,G as so,Ga as fn,H as lo,Ha as pn,I as co,Ia as gn,J as mo,Ja as hn,K as uo,Ka as yn,L as fo,La as vn,M as po,Ma as xn,N as go,Na as bn,O as ho,Oa as Sn,P as yo,Pa as ce,Q as vo,R as xo,S as bo,T as So,U as ie,V as Co,W as Io,X as ae,Y as ko,Z as Po,_ as To,a as Wt,aa as Ro,b as A,ba as Eo,c as B,ca as Mo,d as Dt,da as No,e as Ft,ea as Bo,f as Ot,fa as T,g as te,ga as Lo,h as $t,ha as Ho,i as Vt,ia as Ao,j as oe,ja as zo,k as P,ka as qo,l as z,la as Wo,m as Xt,ma as Do,n as ne,na as Fo,o as q,oa as Oo,p as Yt,pa as $o,q as _t,qa as Vo,r as Kt,ra as Xo,s as Qt,sa as Yo,t as Ut,ta as _o,u as Gt,ua as N,v as Jt,va as jo,w as re,wa as se,x as Zt,xa as en,y as jt,ya as tn,z as eo,za as W}from"./chunk-L6FWDFSU.js";import{a as Ko,b as Qo,c as Uo,d as Go,e as Jo,f as Zo,g as rn,h as an,i as sn,j as ln,k as cn,l as mn}from"./chunk-UFC4ZSNV.js";import{useCanvas as We}from"@atlas-viewer/atlas";import{forwardRef as De,useImperativeHandle as Fe}from"react";import{Fragment as Oe,jsx as me}from"react/jsx-runtime";var wn=De(function({canvasId:t},o){let n=We(),i=se(t||n?.id),a=P();return Fe(o,()=>i,[t,n]),!n||i.enabledPageIds.length===0?null:me(Oe,{children:i.enabledPageIds.map(s=>me(ce.RenderAnnotationPage,{page:a.get(s)},s))})});import{useMemo as Xe}from"react";import{useMemo as $e}from"react";import{Fragment as Ve,jsx as C,jsxs as F}from"react/jsx-runtime";function O({metadata:e=[],config:t,labelWidth:o=16,showEmptyMessage:n=!0,allowHtml:i,emptyFallback:a,classes:s={},emptyMessage:l="No metadata available",emptyValueFallback:u="No value",emptyLabelFallback:m="",separator:c,tableFooter:f,tableHeader:x}){let h=$e(()=>{let g=(t||[]).reduce((p,b)=>[...p,...b.keys],[]),d={};for(let p of e){let b=p&&p.label?Object.values(p.label):[];for(let r of b)if(r&&r.length&&(g.indexOf(`metadata.${r[0]}`)!==-1||g.length===0)&&p){let S=`metadata.${r[0]}`;d[S]=d[S]?d[S]:[],d[S].push(p);break}}return d},[t,e]);return Object.keys(h).length===0&&n?C(Ve,{children:a})||C("div",{className:s.empty,children:l}):t&&t.length?F("table",{className:s.container,children:[x,C("tbody",{children:t.map((g,d)=>{let p=[];for(let b of g.keys)for(let r of h[b]||[])p.push(C(N,{enableDangerouslySetInnerHTML:i,defaultText:u,separator:c,children:r.value},d+"__"+b));return p.length===0?null:F("tr",{className:s.row,children:[C("td",{className:s.label,style:o?{minWidth:o}:{},children:C(N,{enableDangerouslySetInnerHTML:i,separator:c,defaultText:m,children:g.label})}),C("td",{className:s.value,children:p})]},d)})}),f]}):F("table",{className:s.container,children:[x,C("tbody",{children:e&&e.length?e.map((g,d)=>g?F("tr",{className:s.row,children:[C("td",{className:s.label,style:o?{minWidth:o}:{},children:C(N,{enableDangerouslySetInnerHTML:i,defaultText:u,separator:c,children:g.label})}),C("td",{className:s.value,children:C(N,{enableDangerouslySetInnerHTML:i,defaultText:u,separator:c,children:g.value})})]},d):null):null}),f]})}import{jsx as Ye}from"react/jsx-runtime";function Fn(e){let t=q(),o=T(),n=re(),i=Xe(()=>{let a=t?.metadata||[],s=o?.metadata||[],l=n?.metadata||[];return[...a,...s,...l]},[t,o,n]);return Ye(O,{metadata:i,...e})}import{useEffect as Ue,useState as Ge}from"react";import{createImageServiceRequest as _e,imageServiceRequestToString as Ke}from"@atlas-viewer/iiif-image-api";import{useMemo as Qe}from"react";function Q(e,t={},o=[]){return Qe(()=>{if(!e)return null;let n=t.quality;e&&e.extraQualities&&t.quality&&(e.extraQualities.includes(t.quality)||(n="default"));let i=_e(e);return Ke({identifier:i.identifier,server:i.server,scheme:i.scheme,type:"image",size:{max:!t.size?.width&&!t.size?.height,confined:!1,upscaled:!1,...t.size||{}},format:t.format||"jpg",region:t.region||{full:!0},rotation:t?.rotation?Number.isInteger(t.rotation)?{angle:t.rotation}:t.rotation:{angle:0},quality:n||"default",prefix:i.prefix,originalPath:i.originalPath})},[...o])}import{jsx as $}from"react/jsx-runtime";function Je(e){let t=typeof e.src=="string"?e.src:e.src.id,o=W(),[n,i]=Ge(!1),a;if(t){let l=o.loadServiceSync({id:t});l&&(a=l)}!a&&!n&&o.loadService({id:t}).then(()=>{i(!0)});let s=Q(a,{size:e.size,selector:e.region,rotation:e.rotation,format:e.format,region:e.region,quality:e.quality},[n,e.src,e.size,e.region,e.rotation,e.format,e.region,e.quality]);return Ue(()=>()=>{i(!1)},[t]),s?$("img",{src:s,alt:e.alt,className:e.className,style:e.style}):$(Ze,{...e,fetchImageService:!1})}function Ze(e){if(e.fetchImageService)return $(Je,{...e});let t=typeof e.src=="string"?{id:e.src,profile:"level0"}:e.src,o=Q(t,{size:e.size,selector:e.region,rotation:e.rotation,format:e.format,region:e.region,quality:e.quality},[e.src,e.size,e.region,e.rotation,e.format,e.region,e.quality]);return o?$("img",{src:o,alt:e.alt,className:e.className,style:e.style}):null}import{jsx as je}from"react/jsx-runtime";function or(e){let t=q();return je(O,{metadata:t?.metadata||[],...e})}import{useLayoutEffect as rt,useRef as it}from"react";import*as U from"react-lazy-load-image-component";import{getValue as et}from"@iiif/helpers/i18n";import{Fragment as ue,jsx as w,jsxs as nt}from"react/jsx-runtime";var{LazyLoadComponent:tt}=U||U.default;function de(e){let{size:t,visible:o,classes:n,canvasId:i,figure:a}=e,s=t?.width||128,l=t?.height||t?.width||128,u=w(ot,{...e}),m=w(tt,{threshold:300,style:{height:l,width:s},visibleByDefault:o,children:i?w(oe,{canvas:i,children:u}):u});return a?w("figure",{className:n?.figure,children:m}):m}function ot({fallback:e,size:t,classes:o,showLabel:n,alt:i,dereference:a=!1}){let s=T(),l=t?.width||128,u=t?.height||t?.width||128,m=i||et(s?.label)||"",c=le({width:l,height:u},a);return!c||c.type!=="fixed"?w(ue,{children:e}):nt(ue,{children:[w("div",{className:o?.imageWrapper,children:w("img",{className:o?.img,src:c.id,alt:m})}),n?w(N,{as:"figcaption",className:o?.label,children:s?.label}):null]})}import{jsx as L}from"react/jsx-runtime";function gr({flat:e,size:t,classes:o={},showLabel:n,figure:i,fallback:a}){let s=it(null),{items:l,sequence:u,currentSequenceIndex:m,setSequenceIndex:c}=ie(),f={row:o.selected?.row||o.row,item:o.selected?.item||o.item,figure:o.selected?.figure||o.figure,img:o.selected?.img||o.img,label:o.selected?.label||o.label,imageWrapper:o.selected?.imageWrapper||o.imageWrapper};rt(()=>{if(!s.current)return;let h=s.current.querySelector("[data-selected=true]");h&&h.scrollIntoView({behavior:"smooth",block:"nearest",inline:"center"})},[m]);let x=[];for(let h of u){let I=[],g=u[m]===h;for(let d of h){let p=l[d];I.push(L("div",{className:g?f.item:o.item,children:L(de,{classes:g?f:o,canvasId:p.id,size:t,showLabel:n,figure:i,placeholder:L("div",{style:{height:128,width:128}}),fallback:a})},d))}if(e){x.push(I);continue}x.push(L("div",{onClick:d=>{c(u.indexOf(h))},"data-selected":g,className:g?f.row:o.row,children:I},h.join("-")))}return L("div",{ref:s,className:o.container,children:x})}import{Fragment as fe,jsx as R,jsxs as pe}from"react/jsx-runtime";var at={draw:!0,polygon:!0,line:!0,lineBox:!0,square:!0,triangle:!0,hexagon:!0,circle:!0,delete:!0};function vr({helper:e,showShapes:t,state:o,enabled:n=at,classNames:i={},icons:a={}}){return pe(fe,{children:[t?pe(fe,{children:[n.draw&&R("button",{className:i.button,onClick:()=>{e.stamps.clear(),e.draw.enable()},"data-active":!o.lineMode&&!o.selectedStamp&&t&&o.drawMode,children:a.DrawIcon||"Draw"}),n.polygon&&R("button",{className:i.button,"data-active":!o.lineMode&&!o.selectedStamp&&t&&!o.drawMode,onClick:()=>{e.stamps.clear(),e.draw.disable(),e.modes.disableLineBoxMode(),e.modes.disableLineMode()},children:a.PolygonIcon||"Polygon"}),n.line&&R("button",{className:i.button,"data-active":o.lineMode&&!o.lineBoxMode,onClick:()=>{e.modes.enableLineMode()},children:a.LineIcon||"Line"}),n.lineBox&&R("button",{className:i.button,"data-active":o.lineBoxMode,onClick:()=>{e.modes.enableLineBoxMode()},children:a.LineBoxIcon||"LineBox"}),n.square&&R("button",{className:i.button,"data-active":o.selectedStamp?.id==="square",onClick:()=>{e.stamps.square()},children:a.SquareIcon||"Square"}),n.triangle&&R("button",{className:i.button,"data-active":o.selectedStamp?.id==="triangle",onClick:()=>{e.stamps.triangle()},children:a.TriangleIcon||"Triangle"}),n.hexagon&&R("button",{className:i.button,"data-active":o.selectedStamp?.id==="hexagon",onClick:()=>{e.stamps.hexagon()},children:a.HexagonIcon||"Hexagon"})]}):null,o.showBoundingBox&&n.delete&&R("button",{className:i.button,onClick:()=>e.key.down("Backspace"),children:a.DeleteForeverIcon||"Delete"})]})}import{createContext as st,useCallback as ge,useContext as ye,useEffect as he,useMemo as G,useState as lt}from"react";import ve from"mitt";import{jsx as ct}from"react/jsx-runtime";var V=st(ve());V.displayName="SelectorHelper";function Tr({children:e}){return ct(V.Provider,{value:G(()=>ve(),[]),children:e})}function wr(){return ye(V)}function xe(e){let t=be(),[o,n]=lt(!1);he(()=>t.withSelector(e).on("highlight",()=>{n(!0)}),[t,e]),he(()=>t.withSelector(e).on("clear-highlight",()=>{n(!1)}),[t,e]);let i=ge(s=>{t.emit("click",{selectorId:e,event:s})},[e,t]),a=ge(s=>{t.emit("hover",{selectorId:e,event:s})},[e,t]);return{controller:t,onClick:i,onHover:a,isHighlighted:o}}function be(){let e=ye(V);return G(()=>({withSelector(t){return{on(o,n){let i=a=>{a&&a.selectorId===t&&n(a)};return e.on(o,i),()=>{e.off(o,i)}},emit(o,n){e.emit(o,{...n,selectorId:t})}}},on(t,o){return e.on(t,o),()=>{e.off(t,o)}},emit(t,o){e.emit(t,o)}}),[e])}function Rr(){let e=be();return G(()=>({withSelector(t){return{highlight(){e.emit("highlight",{selectorId:t})},clearHighlight(){e.emit("clear-highlight",{selectorId:t})},zoomTo(){e.emit("zoom-to",{selectorId:t})},addEventListener(o,n){return e.emit("event-listener",{selectorId:t,name:o,callback:n}),()=>{e.emit("remove-event-listener",{selectorId:t,name:o,callback:n})}},getImagePreview(){return new Promise((o,n)=>{e.emit("image-preview-request",{selectorId:t,resolve:o,reject:n})})},on(o,n){return e.withSelector(t).on(o,n)}}},highlight(t){e.emit("highlight",{selectorId:t})},clearHighlight(t){e.emit("clear-highlight",{selectorId:t})},zoomTo(t){e.emit("zoom-to",{selectorId:t})},addEventListener(t,o,n){return e.emit("event-listener",{selectorId:t,name:o,callback:n}),()=>{e.emit("remove-event-listener",{selectorId:t,name:o,callback:n})}},getImagePreview(t){return new Promise((o,n)=>{e.emit("image-preview-request",{selectorId:t,resolve:o,reject:n})})},on(t,o){return e.on(t,o)}}),[e])}import{createContext as mt,useContext as ut,useMemo as dt}from"react";import{jsx as ft}from"react/jsx-runtime";function Se(){return{default:{backgroundColor:"rgba(0,0,0,0)",borderWidth:"2px",borderColor:"rgba(252,0,98, .5)"},highlighted:{backgroundColor:"rgba(75, 103, 225, 0.4)",borderWidth:"1px",borderColor:"rgba(75,103,225,0.99)"},hidden:{borderWidth:"0px",borderColor:"rgba(0,0,0,0)",backgroundColor:"rgba(0,0,0,0)",hidden:!0}}}var J=mt(Se());J.displayName="AnnotationStyle";function Ce(){return ut(J)}function Br({theme:e,children:t}){let o=dt(()=>e||Se(),[e]);return ft(J.Provider,{value:o,children:t})}import{HTMLPortal as xt,useAtlas as bt}from"@atlas-viewer/atlas";import{useEffect as ke,useRef as E,useState as Pe}from"react";import{useEffect as pt,useMemo as gt,useState as ht}from"react";import{createHelper as yt}from"polygon-editor";function Ie(e,t,o){let[n,i]=ht({}),a=gt(()=>yt(e,o),[]);return pt(()=>(a.clock.start(t,i),()=>{a.clock.stop()}),[]),{state:n,helper:a}}import{createSvgHelpers as vt}from"polygon-editor";import{Fragment as Te,jsx as v,jsxs as we}from"react/jsx-runtime";var M=vt();function Re(e,t){let{image:o,currentShape:n,onChange:i,hideShapeLines:a}=e,s=E(),l=E(),u=E(),m=E(),c=E(),f=E(),x=E(),h=E(),[I,g]=Pe(null),[d,p]=Pe(!1),{helper:b,state:r}=Ie(n,(y,k)=>{M.updateTransitionBoundingBox(l.current,y,k),M.updateBoundingBoxPolygon(s.current,y,k),M.updateTransitionShape(f.current,y,k),M.updateClosestLinePointTransform(m.current,y,k),M.updateSelectBox(u.current,y,k),M.updatePointLine(x.current,y,k),M.updateDrawPreview(c.current,y,k,3),M.updateLineBox(h.current,y),g(y.transitionDirection),p(y.transitionRotate)},i);ke(()=>{b.setShape(n||null)},t),ke(()=>{let y=()=>{b.modifiers.reset()};return document.addEventListener("mouseleave",y),()=>{document.removeEventListener("mouseleave",y)}},[]);let S=we(Te,{children:[v("marker",{id:"dot",viewBox:"0 0 10 10",refX:"5",refY:"5",markerWidth:"5",markerHeight:"5",children:v("circle",{cx:"5",cy:"5",r:"4",className:"marker"})}),v("marker",{id:"selected",viewBox:"0 0 10 10",refX:"5",refY:"5",markerWidth:"5",markerHeight:"5",children:v("circle",{cx:"5",cy:"5",r:"4",fill:"#FAFF00"})}),v("marker",{id:"resizer",viewBox:"0 0 10 10",refX:"5",refY:"5",markerWidth:"5",markerHeight:"5",children:v("rect",{width:"10",height:"10",stroke:"#FF0DCB",fill:"#fff",strokeWidth:2})})]}),_=n?n.open?"polyline":"polygon":null,ee=!r.showBoundingBox&&r.closestPoint!==null&&r.actionIntentType==="select-point",Ae=r.actionIntentType==="add-open-point",ze=r.transitionIntentType==="split-line",K=r.transitioning&&r.selectedStamp&&r.transitionIntentType==="stamp-shape",qe=n&&_?we(Te,{children:[v(_,{fill:!r.transitioning&&r.showBoundingBox?"rgba(255, 0, 0, .5)":"none",strokeWidth:K?0:2,stroke:a?"transparent":"#000",points:n.points.map(y=>y.join(",")).join(" "),vectorEffect:"non-scaling-stroke",markerStart:r.showBoundingBox?void 0:"url(#dot)",markerMid:r.showBoundingBox?void 0:"url(#dot)",markerEnd:r.showBoundingBox?void 0:"url(#dot)",style:{pointerEvents:"none"}}),r.lineBoxMode&&r.actionIntentType==="close-line-box"?v("polygon",{fill:"rgba(255, 0, 0, .4)",ref:h,stroke:"#000",strokeWidth:2,vectorEffect:"non-scaling-stroke"}):null,r.transitionIntentType==="draw-shape"&&r.transitioning?v("polyline",{ref:c,fill:"none",stroke:"rgba(255, 0, 0, .5)",strokeWidth:2,vectorEffect:"non-scaling-stroke"}):null,!r.showBoundingBox&&r.selectedPoints&&r.selectedPoints.length?v("polyline",{strokeWidth:2,vectorEffect:"non-scaling-stroke",stroke:"transparent",markerStart:"url(#selected)",markerMid:"url(#selected)",markerEnd:"url(#selected)",fill:"transparent",points:n.points.filter((y,k)=>r.selectedPoints?.includes(k)).map(y=>y.join(",")).join(" ")}):null,ee&&r.closestPoint!==null&&n.points[r.closestPoint]?v("polyline",{strokeWidth:2,vectorEffect:"non-scaling-stroke",stroke:"transparent",markerStart:"url(#selected)",markerMid:"url(#selected)",markerEnd:"url(#selected)",fill:"transparent",points:`${n.points[r.closestPoint][0]},${n.points[r.closestPoint][1]}`}):null,!r.transitioning&&(r.actionIntentType==="add-open-point"||r.actionIntentType==="close-shape"||r.actionIntentType==="close-shape-line")?v("polyline",{stroke:"#000",ref:x,strokeWidth:r.actionIntentType==="close-shape"?2:1,vectorEffect:"non-scaling-stroke"}):null,r.hasClosestLine&&(!r.transitionIntentType||r.transitionIntentType==="split-line")?v("g",{ref:m,children:v("polyline",{style:{opacity:.5},markerStart:"url(#dot)",points:"0,0 10,10",vectorEffect:"non-scaling-stroke",fill:"transparent",strokeWidth:2})}):null,r.transitioning?v(_,{ref:f,fill:n.open?"none":"rgba(255, 0, 0, .5)",stroke:"rgba(255, 0, 0, .5)",strokeWidth:n.open?2:0}):null,r.transitioning&&r.transitionIntentType==="select-multiple-points"?v("rect",{ref:u,fill:"rgba(255, 255, 255, .3)",strokeWidth:1,stroke:"rgba(0,0,0,.2)",vectorEffect:"non-scaling-stroke"}):null,r.showBoundingBox?null:v("g",{name:"controls",children:!1}),r.showBoundingBox&&!K?v("polygon",{ref:s,strokeWidth:2,stroke:"#FF0DCB",fill:"none",markerStart:"url(#resizer)",markerMid:"url(#resizer)",markerEnd:"url(#resizer)",vectorEffect:"non-scaling-stroke"}):null]}):null;return{helper:b,state:r,isAddingPoint:Ae,isSplitting:ze,isStamping:K,isHoveringPoint:ee,transitionDirection:I,transitionRotate:d,defs:S,editor:qe}}import{useEffect as Z}from"react";import{createPortal as St}from"react-dom";import{Fragment as Ee,jsx as H,jsxs as X}from"react/jsx-runtime";var Ct=[{name:"Default",outer:{borderWidth:4,borderColor:"rgba(255, 255, 255, .4)"},inner:{borderWidth:2,borderColor:"#000"}},{name:"High contrast",outer:{borderWidth:3,borderColor:"#fff"},inner:{borderWidth:1,borderColor:"#000"}},{name:"Lightsaber",outer:{borderWidth:"4",borderColor:"rgba(56,68,255,0.64)"},inner:{borderWidth:"2",borderColor:"#fff"}},{name:"Bright",outer:{borderWidth:"6",borderColor:"#25d527"},inner:{borderWidth:"3",borderColor:"#a916ff"}},{name:"pink",outer:{borderWidth:"4",borderColor:"#ff00ff"},inner:{borderWidth:"2",borderColor:"#ffffff"}},{name:"fine (dark)",outer:{borderWidth:"1",borderColor:"#000000"},inner:{}},{name:"fine (light)",outer:{borderWidth:"1",borderColor:"#FFF"},inner:{}}];function Me(e){let t=e.theme||Ct[0],o=bt(),{image:n}=e,{helper:i,defs:a,editor:s,state:l,transitionDirection:u,isSplitting:m,transitionRotate:c,isHoveringPoint:f,isAddingPoint:x,isStamping:h}=Re({currentShape:e.shape||null,onChange:e.updateShape,image:e.image,hideShapeLines:!0},[]),I=r=>{i.pointer([[~~r.atlas.x,~~r.atlas.y]])};Z(()=>{let r=S=>{i.key.up(S.key)};return document.addEventListener("keyup",r),()=>{document.removeEventListener("keyup",r)}},[]),Z(()=>{let r=S=>{i.key.down(S.key)};return document.addEventListener("keydown",r),()=>{document.removeEventListener("keydown",r)}},[]),Z(()=>{let r=[];return u&&r.push(`atlas-cursor-${u}`),l.actionIntentType==="cut-line"&&l.modifiers?.Shift&&r.push("atlas-cursor-cut"),(f||l.transitionIntentType==="move-shape"||l.transitionIntentType==="move-point")&&r.push("atlas-cursor-move"),x&&r.push("atlas-cursor-crosshair"),m&&r.push("atlas-cursor-copy"),c&&r.push("atlas-cursor-rotate"),l.transitionIntentType==="draw-shape"&&r.push("atlas-cursor-draw"),o?.canvas&&o.canvas.classList.add(...r),()=>{o?.canvas&&o.canvas.classList.remove(...r)}},[o?.canvas,x,f,m,l.modifiers?.Shift,l.actionIntentType,l.transitionIntentType,u,c]);let g=e.shape&&e.shape?.points.length===0,d=e.renderControls?e.renderControls(i,l,g):null,p=document.getElementById(e.controlsHtmlId||"atlas-controls"),b="shape";return H(Ee,{children:X("world-object",{height:n.height,width:n.width,onMouseMove:I,onMouseDown:i.pointerDown,onMouseUp:i.pointerUp,onMouseLeave:i.blur,children:[e.shape?X(Ee,{children:[H(b,{open:e.shape.open,points:e.shape.points,relativeStyle:!0,style:h?{}:t.outer}),H(b,{open:e.shape.open,points:e.shape.points,relativeStyle:!0,style:h?{}:t.inner})]}):null,X(xt,{relative:!0,interactive:!1,children:[H("div",{style:{position:"absolute",top:0,right:0,left:0,bottom:0},children:X("svg",{width:"100%",height:"100%",viewBox:`0 0 ${n.width} ${n.height}`,tabIndex:-1,children:[H("defs",{children:a}),s]})}),p?St(d,p,"controls"):null]})]})})}import{jsx as Ne}from"react/jsx-runtime";function si(e){let t=T(),o=e.annotationBucket,n=e.readOnly,i=e.id,{onClick:a,isHighlighted:s}=xe(e.id),l=Ce(),u=s?l.highlighted:l[o||"hidden"]||l.hidden;if(!t)return null;if(n){let m="shape",c=e.polygon,f=c.open;return c?Ne(m,{id:`shape-${i}`,points:c.points,open:f,onClick:a,relativeStyle:!0,target:{x:0,y:0,width:t.width,height:t.height},style:u}):null}return Ne(Me,{image:t,shape:e.polygon||{id:e.id,open:!0,points:[]},updateShape:e.updatePolygon,theme:e.theme,controlsHtmlId:e.controlsHtmlId,renderControls:e.renderControls})}import{jsx as It}from"react/jsx-runtime";function ui({annotation:e,children:t}){return It(B,{value:{annotation:e},children:t})}import{jsx as kt}from"react/jsx-runtime";function gi({annotationPage:e,children:t}){return kt(B,{value:{annotationPage:e},children:t})}import{jsx as Pt}from"react/jsx-runtime";function xi({collection:e,children:t}){return Pt(B,{value:{collection:e},children:t})}function Ii(e,t={}){return D(t)}import{useCanvas as Tt}from"@atlas-viewer/atlas";import{useEffect as wt,useMemo as j,useState as Rt}from"react";function Ei({canvasId:e}={}){let t=Tt(),o=ne(),n=j(()=>e?[e]:t?[t.id]:o.map(m=>m.id),[e,t,o]),[i,a]=Rt({}),s=ae();wt(()=>{let m=c=>{let f=c.partOf.canvasId;f&&a(x=>({...x,[f]:c.choice}))};return s.on("choice-change",m),()=>{s.off("choice-change",m)}},[]);let l=j(()=>{let m=[];for(let c of n){let f=i[c];f&&m.push({canvasId:c,choice:f})}return m},[n,i]),u=j(()=>({makeChoice:(m,c)=>{s.emit("make-choice",{choiceId:m,...c})}}),[s]);return{choices:l,actions:u}}function Ni(e,t=!1){}function Ai(e){let o=A().manifest,n=e?e.map(i=>typeof i=="string"?i:i?.id):[];return z(i=>{let a=o?i.iiif.entities.Manifest[o]:void 0,s=a?.items||[];if(typeof e>"u")return s;let l=[];for(let u of a?.items||[])n.indexOf(u.id)!==-1&&l.push(u);return l},[n.join("/")])}import{useMemo as Et}from"react";function Fi(e,t=[]){let{id:o,selector:n}=e,i=A(),a=o||i.collection,s=z(l=>a?l.iiif.entities.Collection[a]:void 0,[a]);return Et(()=>{if(s)return n?n(s):s},[s,n,...t])}import{useEffect as Mt,useMemo as Nt}from"react";import{createEventsHelper as Bt}from"@iiif/helpers/events";function Yi(e,t,o,n,i=[]){let a=P(),s=Nt(()=>Bt(a),[a]);Mt(()=>{let l=e;return l?(s.addEventListener(l,t,o,n),()=>{s.removeEventListener(l,t,o)}):()=>{}},[s,e,t,...i])}function Ui(e,t){let{id:o,isLoaded:n,error:i,resource:a,requestId:s,cached:l}=te(e,t);return{id:o,isLoaded:n,error:i,manifest:a,requestId:s,cached:l}}import{getImageServices as Be}from"@atlas-viewer/iiif-image-api";import{useEffect as Lt,useMemo as Le,useState as Y}from"react";function He({cacheKey:e}={}){let t=T(),o=D(),n=P(),i=W(),[a,s]=Y(void 0),[l,u]=Y(!1),[m,c]=Y("idle"),[f,x]=Y(void 0),h=t?t.id:"undefined",I=Le(()=>{try{if(t&&o.length){let d=o[0],p=n.get(d.body[0]),r=Be(p)[0];return r&&i.loadServiceSync({id:r.id||r["@id"],width:r.width||t.width,height:r.height||t.height})||void 0}}catch(d){console.error(d)}},[h,e,t]),g=m==="success"&&a?a:I;return Lt(()=>{(async()=>{try{if(t&&o.length){let d=o[0],p=n.get(d.body[0]),r=Be(p)[0];if(!r)return;u(!0),c("loading");try{let S=await i.loadService({id:r.id||r["@id"],width:r.width||t.width,height:r.height||t.height})||void 0;s(S),c("success"),u(!1)}catch(S){c("error"),x(S)}}}catch(d){c("error"),x(d)}})()},[h,e]),Le(()=>({data:g,isFetching:l,status:m,error:f}),[g,l,m,f])}function ia(){let e=He();return{isLoading:e.isFetching,tile:e.data?{id:e.data.id||e.data["@id"],width:e.data.width,height:e.data.height,imageService:e.data,thumbnail:void 0}:null}}import{createStylesHelper as Ht}from"@iiif/helpers/styles";import{useMemo as At}from"react";function ma(){let e=P();return At(()=>Ht(e),[e])}export*from"@iiif/helpers/annotation-targets";export{ui as AnnotationContext,gi as AnnotationPageContext,Br as AnnotationStyleProvider,yo as Auth,lo as AuthProvider,io as AuthRContext,ao as AuthReactContext,so as AuthReactContextActions,wn as CanvasAnnotations,oe as CanvasContext,ce as CanvasPanel,xi as CollectionContext,Fn as CombinedMetadata,bn as ComplexTimelineProvider,To as ContextBridge,Me as CreateCustomShape,ko as EventsProvider,Ze as Image,tn as ImageServiceLoaderContext,bo as InnerViewerProvider,Wo as LanguageProvider,Vo as LanguageString,N as LocaleString,Vt as ManifestContext,or as ManifestMetadata,vn as MediaPlayerProvider,O as Metadata,si as PolygonSelector,Yt as RangeContext,Io as ReactEventContext,Dt as ReactVaultContext,vr as RenderSvgEditorControls,B as ResourceProvider,Wt as ResourceReactContext,Tr as SelectorControllerProvider,gr as SequenceThumbnails,So as SimpleViewerProvider,xo as SimpleViewerReactContext,de as SingleCanvasThumbnail,qo as TranslationProvider,Do as TransliterationProvider,Ft as VaultProvider,No as ViewerPresetContext,Mo as VirtualAnnotationProvider,Xt as VisibleCanvasReactContext,oo as authDetailsForResource,eo as createAuthStateStore,to as createProbe,Co as defaultEmitter,Uo as emptyActions,Zo as emptyStrategy,Kt as findAllCanvasesInRange,_t as findFirstCanvasFromRange,Qt as findManifestSelectedRange,Ut as findSelectedRange,jo as flattenAnnotationPageIds,fn as formatTime,rn as get3dStrategy,cn as getComplexTimelineStrategy,Se as getDefaultAnnotationStyles,an as getImageStrategy,Jt as getManifestSequence,Qo as getParsedTargetSelector,mn as getRenderingStrategy,sn as getTextualContentStrategy,ln as getVideoStrategy,Gt as getVisibleCanvasesFromCanvasId,jt as hasAuth,ro as makeAccessServiceRequest,no as makeAccessTokenRequest,Ko as parseSpecificResource,Ct as svgThemes,Go as unknownResponse,Jo as unsupportedStrategy,Ao as useAnnotation,zo as useAnnotationPage,se as useAnnotationPageManager,Ce as useAnnotationStyles,Ii as useAnnotationsAtTime,uo as useAuthActions,po as useAuthService,mo as useAuthStore,ho as useAuthToken,go as useAuthTokens,T as useCanvas,Ei as useCanvasChoices,Ni as useCanvasClock,Zt as useCanvasSequence,xn as useCanvasStartTime,Ai as useCanvasSubset,Xo as useClosestLanguage,Fi as useCollection,Sn as useComplexTimeline,Po as useContextBridge,_o as useCreateLocaleString,fo as useCurrentAuth,wo as useDispatch,ae as useEventEmitter,Yi as useEventListener,Ot as useExistingVault,Ui as useExternalCollection,$t as useExternalManifest,te as useExternalResource,Oo as useIIIFLanguage,Q as useImage,He as useImageService,W as useImageServiceLoader,ia as useImageTile,co as useIsAuthEnabled,on as useLoadImageService,Yo as useLocaleString,q as useManifest,hn as useMediaActions,yn as useMediaElements,gn as useMediaState,nn as usePaintables,D as usePaintingAnnotations,Ie as usePolygonHelper,re as useRange,un as useRenderingStrategy,A as useResourceContext,Lo as useResourceEvents,en as useResources,vo as useSearchService,be as useSelectorController,wr as useSelectorEmitter,xe as useSelectorEvents,Rr as useSelectorHelper,pn as useSimpleMediaPlayer,ie as useSimpleViewer,ma as useStyleHelper,Ho as useStyles,Re as useSvgEditor,le as useThumbnail,$o as useTranslations,Fo as useTransliteration,P as useVault,dn as useVaultEffect,z as useVaultSelector,Bo as useViewerPreset,Ro as useVirtualAnnotationPage,Eo as useVirtualAnnotationPageContext,ne as useVisibleCanvases};
|
package/dist/utils.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var I=Object.defineProperty;var
|
|
1
|
+
"use strict";var I=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var V=(e,t)=>{for(var i in t)I(e,i,{get:t[i],enumerable:!0})},U=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of O(t))!A.call(e,o)&&o!==i&&I(e,o,{get:()=>t[o],enumerable:!(r=D(t,o))||r.enumerable});return e};var W=e=>U(I({},"__esModule",{value:!0}),e);var G={};V(G,{emptyActions:()=>L,emptyStrategy:()=>w,getParsedTargetSelector:()=>f,getRenderingStrategy:()=>F,parseSpecificResource:()=>M,unknownResponse:()=>S,unsupportedStrategy:()=>m});module.exports=W(G);var P=require("@iiif/helpers");function M(e){return e.type==="SpecificResource"?[e.source,{selector:e.selector}]:[e,{selector:null}]}function f(e,t){let{selector:i,source:r}=(0,P.expandTarget)(t);if(r.id!==e.id)return[null,r];let o={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}};return[i?i.type==="TemporalSelector"?{type:"TemporalBoxSelector",temporal:i.temporal,spatial:o.spatial}:i:null,r]}var L={makeChoice:()=>{}},S={type:"unknown"},m=e=>({type:"unknown",reason:e,annotations:{pages:[]}}),w=(e,t)=>({type:"empty",width:e,height:t,annotations:{pages:[]},image:null,images:[]});var E=["model/gltf-binary"];function k(e,t){let r=t.items[0].resource;return r.format?E.indexOf(r.format)===-1?m(`3D format: ${r.format} is unsupported`):{type:"3d-model",model:r}:m("Unknown format")}function R(e,t){if(!e.duration)return m("No duration on canvas");if(t.items.length>1)return m("Only one audio source supported");let i=t.items[0]?.resource;return i?i.format?{type:"media",media:{annotationId:t.items[0].annotationId,duration:e.duration,url:i.id,type:"Sound",target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:i.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},annotations:{pages:[]}}:m("Audio does not have format"):m("Unknown audio")}var v=require("@atlas-viewer/iiif-image-api");var b=require("@iiif/helpers/annotation-targets");function h(e,t,i){let r=[];for(let o of t.items){let p=o.resource&&o.resource.type==="SpecificResource"?o.resource.source:o.resource;if(!p.id)return m("No resource Identifier");let c;if(p.service){let y=(0,v.getImageServices)(p);y[0]&&(c=i(y[0],e))}let d={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}},[n,a]=f(e,o.target),s=e.id?.split("?")[0]||"";if(!(a.id===e.id||decodeURIComponent(a.id||"")===(e.id||"")||a.id===s||decodeURIComponent(a.id||"")===s))continue;let l=o.resource.width&&o.resource.height?{type:"BoxSelector",spatial:{x:0,y:0,width:o.resource.width,height:o.resource.height}}:void 0,u=o.resource.type==="SpecificResource"?(0,b.expandTarget)(o.resource):null;if(o.selector){let y=(0,b.expandTarget)({type:"SpecificResource",source:o.resource,selector:o.selector});y&&(u=y)}let g=u&&u.selector&&(u.selector.type==="BoxSelector"||u.selector.type==="TemporalBoxSelector")?{type:"BoxSelector",spatial:{x:u.selector.spatial.x,y:u.selector.spatial.y,width:u.selector.spatial.width,height:u.selector.spatial.height}}:void 0;c&&!c.id&&(c.id=c["@id"]);let B={id:p.id,type:"Image",annotationId:o.annotationId,width:Number(n||g?p.width:e.width),height:Number(n||g?p.height:e.height),service:c,sizes:c&&c.sizes?c.sizes:p.width&&p.height?[{width:p.width,height:p.height}]:[],target:n&&n.type!=="PointSelector"?n:d,selector:g||{type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}}};r.push(B)}return{type:"images",image:r[0],images:r,choice:t.choice}}function N(e,t={},i){let r=e.language||i||"none";switch(e.type){case"TextualBody":{typeof e.value<"u"&&(t[r]=[e.value]);break}case"List":case"Composite":case"Choice":e.items&&e.items.forEach(o=>N(o,t,r))}return t}function x(e,t){let i=[];return t.items.forEach(r=>{if(r.resource){let[o]=f(e,r.target);i.push({type:"Text",annotationId:r.annotationId,text:N(r.resource),target:o})}}),{type:"textual-content",items:i}}var T=require("@iiif/helpers"),Y=/^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\/)|(?:(?:watch)?\?vi?=|&vi?=))([^#&?]*).*/;function C(e,t){let i=t.items.filter(s=>s.type==="video"),r=!1;if(e.duration||(r=!0),i.length>1)return m("Only one video source supported");let o=i[0]?.resource,p=!!(o.service||[]).find(s=>(s.profile||"").includes("youtube.com"));if(!p&&r)return m("Video does not have duration");if(!o)return m("Unknown video");if((!o.format||o.format==="text/html")&&!p)return m("Video does not have format");let c=t.items[0],d={annotationId:t.items[0].annotationId,duration:e.duration,url:o.id,type:"Video",target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:o.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},n=(0,T.expandTarget)(c.target);n.selector&&n.selector.type==="TemporalBoxSelector"&&(d.target=n.selector);let{selector:a}=(0,T.parseSelector)(c.selector);if(a===null){let s=d.target.temporal.startTime,u=(d.target.temporal.endTime||e.duration)-s;d.selector={type:"TemporalSelector",temporal:{startTime:0,endTime:u}}}else a.type==="TemporalSelector"&&(d.selector=a);if(p){d.type="VideoYouTube";let s=o.id.match(Y);if(!s[1])return m("Video is not known youtube video");d.youTubeId=s[1]}return{type:"media",media:d,annotations:{pages:[]}}}function z(e,t,i){let r={type:"complex-timeline",items:[],keyframes:[],duration:e.duration||0},o={type:"complex-choice",items:[]};function p(n){n.choice&&(n.choice.type==="complex-choice"?o.items.push(...n.choice.items):o.items.push(n.choice))}for(let n of t.items){if(n.type==="image"){let a=h(e,{choice:null,allChoices:null,types:["image"],items:[n]},i);if(a.type==="images"){p(a),r.items.push(a.image);let s={id:a.image.annotationId,type:"enter",resourceType:"image",time:a.image.target?.temporal?.startTime||0};r.keyframes.push(s);let l={id:a.image.annotationId,type:"exit",resourceType:"image",time:a.image.target?.temporal?.endTime||e.duration||0};r.keyframes.push(l)}}if(n.type==="textualbody"){let a=x(e,{choice:null,allChoices:null,types:["textualbody"],items:[n]});if(a.type==="textual-content"){p(a);let s=a.items[0];r.items.push(s);let l=s.target,u={id:s.annotationId,type:"enter",resourceType:"text",time:l.temporal?.startTime||0};r.keyframes.push(u);let g={id:s.annotationId,type:"exit",resourceType:"text",time:l.temporal?.endTime||e.duration||0};r.keyframes.push(g)}}if(n.type==="video"){let a=C(e,{choice:null,allChoices:null,types:["video"],items:[n]});if(a.type==="media"){p(a);let s=a.media;r.items.push(s);let l={id:s.annotationId,type:"enter",resourceType:"video",time:s.target?.temporal?.startTime||0};r.keyframes.push(l);let u={id:s.annotationId,type:"exit",resourceType:"video",time:s.target?.temporal?.endTime||e.duration||0};r.keyframes.push(u)}}}r.keyframes.sort((n,a)=>n.time-a.time);let c=[],d=[];for(let n of r.keyframes){if(n.resourceType==="image"||n.resourceType==="text"){d.push(n);continue}if(n.type==="enter"){c.length===0&&(n.isPrime=!0),c.push(n),d.push(n);continue}if(n.type==="exit"&&(d.push(n),c=c.filter(a=>a.id!==n.id),c.length!==0)){let a=c[0],s={id:a.id,type:"change",isPrime:!0,resourceType:a.resourceType,time:n.time};d.push(s)}}return r.keyframes=d,o.items.length&&(r.choice=o),r}function F({canvas:e,paintables:t,supports:i,loadImageService:r}){if(!e)return S;if(t.types.length===0)return i.indexOf("empty")!==-1?w(e.width,e.height):S;if(t.types.length!==1)if(t.types.length===2&&t.types.indexOf("text")!==-1)t.types=t.types.filter(p=>p!=="text");else return i.indexOf("complex-timeline")===-1?m("Complex timeline not supported"):z(e,t,r);let o=t.types[0];return o==="image"?i.indexOf("images")===-1?m("Image not supported"):h(e,t,r):o==="Model"||o==="model"?i.indexOf("3d-model")===-1?m("3D not supported"):k(e,t):o==="textualbody"?i.indexOf("textual-content")===-1?m("Textual content not supported"):x(e,t):o==="sound"||o==="audio"?i.indexOf("media")===-1?m("Media not supported"):R(e,t):o==="video"?i.indexOf("media")===-1?m("Media not supported"):C(e,t):S}
|
package/dist/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as o,b as r,c as e,d as f,e as m,f as p,l as t}from"./chunk-
|
|
1
|
+
import{a as o,b as r,c as e,d as f,e as m,f as p,l as t}from"./chunk-UFC4ZSNV.js";export{e as emptyActions,p as emptyStrategy,r as getParsedTargetSelector,t as getRenderingStrategy,o as parseSpecificResource,f as unknownResponse,m as unsupportedStrategy};
|
package/package.json
CHANGED
package/dist/chunk-QCPOOHCR.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{expandTarget as R}from"@iiif/helpers";function W(e){return e.type==="SpecificResource"?[e.source,{selector:e.selector}]:[e,{selector:null}]}function y(e,r){let{selector:n,source:o}=R(r);if(o.id!==e.id)return[null,o];let t={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}};return[n?n.type==="TemporalSelector"?{type:"TemporalBoxSelector",temporal:n.temporal,spatial:t.spatial}:n:null,o]}var M={makeChoice:()=>{}},f={type:"unknown"},m=e=>({type:"unknown",reason:e,annotations:{pages:[]}}),C=(e,r)=>({type:"empty",width:e,height:r,annotations:{pages:[]},image:null,images:[]});var v=["model/gltf-binary"];function I(e,r){let o=r.items[0].resource;return o.format?v.indexOf(o.format)===-1?m(`3D format: ${o.format} is unsupported`):{type:"3d-model",model:o}:m("Unknown format")}import{getImageServices as N}from"@atlas-viewer/iiif-image-api";import{expandTarget as w}from"@iiif/helpers/annotation-targets";function S(e,r,n){let o=[];for(let t of r.items){let p=t.resource&&t.resource.type==="SpecificResource"?t.resource.source:t.resource;if(!p.id)return m("No resource Identifier");let c;if(p.service){let g=N(p);g[0]&&(c=n(g[0],e))}let u={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}},[i,a]=y(e,t.target);if(!(a.id===e.id||decodeURIComponent(a.id||"")===(e.id||"")))continue;let s=t.resource.width&&t.resource.height?{type:"BoxSelector",spatial:{x:0,y:0,width:t.resource.width,height:t.resource.height}}:void 0,d=t.resource.type==="SpecificResource"?w(t.resource):null;if(t.selector){let g=w({type:"SpecificResource",source:t.resource,selector:t.selector});g&&(d=g)}let l=d&&d.selector&&(d.selector.type==="BoxSelector"||d.selector.type==="TemporalBoxSelector")?{type:"BoxSelector",spatial:{x:d.selector.spatial.x,y:d.selector.spatial.y,width:d.selector.spatial.width,height:d.selector.spatial.height}}:void 0;c&&!c.id&&(c.id=c["@id"]);let T={id:p.id,type:"Image",annotationId:t.annotationId,width:Number(i||l?p.width:e.width),height:Number(i||l?p.height:e.height),service:c,sizes:c&&c.sizes?c.sizes:p.width&&p.height?[{width:p.width,height:p.height}]:[],target:i&&i.type!=="PointSelector"?i:u,selector:l||{type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}}};o.push(T)}return{type:"images",image:o[0],images:o,choice:r.choice}}function b(e,r={},n){let o=e.language||n||"none";switch(e.type){case"TextualBody":{typeof e.value<"u"&&(r[o]=[e.value]);break}case"List":case"Composite":case"Choice":e.items&&e.items.forEach(t=>b(t,r,o))}return r}function h(e,r){let n=[];return r.items.forEach(o=>{if(o.resource){let[t]=y(e,o.target);n.push({type:"Text",annotationId:o.annotationId,text:b(o.resource),target:t})}}),{type:"textual-content",items:n}}import{expandTarget as z,parseSelector as B}from"@iiif/helpers";var D=/^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\/)|(?:(?:watch)?\?vi?=|&vi?=))([^#&?]*).*/;function x(e,r){let n=r.items.filter(s=>s.type==="video"),o=!1;if(e.duration||(o=!0),n.length>1)return m("Only one video source supported");let t=n[0]?.resource,p=!!(t.service||[]).find(s=>(s.profile||"").includes("youtube.com"));if(!p&&o)return m("Video does not have duration");if(!t)return m("Unknown video");if((!t.format||t.format==="text/html")&&!p)return m("Video does not have format");let c=r.items[0],u={annotationId:r.items[0].annotationId,duration:e.duration,url:t.id,type:"Video",target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:t.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},i=z(c.target);i.selector&&i.selector.type==="TemporalBoxSelector"&&(u.target=i.selector);let{selector:a}=B(c.selector);if(a===null){let s=u.target.temporal.startTime,l=(u.target.temporal.endTime||e.duration)-s;u.selector={type:"TemporalSelector",temporal:{startTime:0,endTime:l}}}else a.type==="TemporalSelector"&&(u.selector=a);if(p){u.type="VideoYouTube";let s=t.id.match(D);if(!s[1])return m("Video is not known youtube video");u.youTubeId=s[1]}return{type:"media",media:u,annotations:{pages:[]}}}function P(e,r,n){let o={type:"complex-timeline",items:[],keyframes:[],duration:e.duration||0},t={type:"complex-choice",items:[]};function p(i){i.choice&&(i.choice.type==="complex-choice"?t.items.push(...i.choice.items):t.items.push(i.choice))}for(let i of r.items){if(i.type==="image"){let a=S(e,{choice:null,allChoices:null,types:["image"],items:[i]},n);if(a.type==="images"){p(a),o.items.push(a.image);let s={id:a.image.annotationId,type:"enter",resourceType:"image",time:a.image.target?.temporal?.startTime||0};o.keyframes.push(s);let d={id:a.image.annotationId,type:"exit",resourceType:"image",time:a.image.target?.temporal?.endTime||e.duration||0};o.keyframes.push(d)}}if(i.type==="textualbody"){let a=h(e,{choice:null,allChoices:null,types:["textualbody"],items:[i]});if(a.type==="textual-content"){p(a);let s=a.items[0];o.items.push(s);let d=s.target,l={id:s.annotationId,type:"enter",resourceType:"text",time:d.temporal?.startTime||0};o.keyframes.push(l);let T={id:s.annotationId,type:"exit",resourceType:"text",time:d.temporal?.endTime||e.duration||0};o.keyframes.push(T)}}if(i.type==="video"){let a=x(e,{choice:null,allChoices:null,types:["video"],items:[i]});if(a.type==="media"){p(a);let s=a.media;o.items.push(s);let d={id:s.annotationId,type:"enter",resourceType:"video",time:s.target?.temporal?.startTime||0};o.keyframes.push(d);let l={id:s.annotationId,type:"exit",resourceType:"video",time:s.target?.temporal?.endTime||e.duration||0};o.keyframes.push(l)}}}o.keyframes.sort((i,a)=>i.time-a.time);let c=[],u=[];for(let i of o.keyframes){if(i.resourceType==="image"||i.resourceType==="text"){u.push(i);continue}if(i.type==="enter"){c.length===0&&(i.isPrime=!0),c.push(i),u.push(i);continue}if(i.type==="exit"&&(u.push(i),c=c.filter(a=>a.id!==i.id),c.length!==0)){let a=c[0],s={id:a.id,type:"change",isPrime:!0,resourceType:a.resourceType,time:i.time};u.push(s)}}return o.keyframes=u,t.items.length&&(o.choice=t),o}function k(e,r){if(!e.duration)return m("No duration on canvas");if(r.items.length>1)return m("Only one audio source supported");let n=r.items[0]?.resource;return n?n.format?{type:"media",media:{annotationId:r.items[0].annotationId,duration:e.duration,url:n.id,type:"Sound",target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:n.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},annotations:{pages:[]}}:m("Audio does not have format"):m("Unknown audio")}function de({canvas:e,paintables:r,supports:n,loadImageService:o}){if(!e)return f;if(r.types.length===0)return n.indexOf("empty")!==-1?C(e.width,e.height):f;if(r.types.length!==1)if(r.types.length===2&&r.types.indexOf("text")!==-1)r.types=r.types.filter(p=>p!=="text");else return n.indexOf("complex-timeline")===-1?m("Complex timeline not supported"):P(e,r,o);let t=r.types[0];return t==="image"?n.indexOf("images")===-1?m("Image not supported"):S(e,r,o):t==="Model"||t==="model"?n.indexOf("3d-model")===-1?m("3D not supported"):I(e,r):t==="textualbody"?n.indexOf("textual-content")===-1?m("Textual content not supported"):h(e,r):t==="sound"||t==="audio"?n.indexOf("media")===-1?m("Media not supported"):k(e,r):t==="video"?n.indexOf("media")===-1?m("Media not supported"):x(e,r):f}export{W as a,y as b,M as c,f as d,m as e,C as f,I as g,S as h,h as i,x as j,P as k,de as l};
|