@annotorious/openseadragon 3.6.7 → 3.6.8
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.
|
@@ -1144,5 +1144,5 @@ void main(void)\r
|
|
|
1144
1144
|
font-weight: ${e.weight};
|
|
1145
1145
|
font-style: ${e.style};
|
|
1146
1146
|
font-display: ${e.display};
|
|
1147
|
-
}`,this._stylesheet)}get stylesheet(){return this._stylesheet}set stylesheet(t){this._stylesheet!==t&&(this._stylesheet=t,this.styleID++)}normalizeColor(t){return Array.isArray(t)&&(t=Pw(t)),typeof t=="number"?Iw(t):t}dropShadowToCSS(){let t=this.normalizeColor(this.dropShadowColor);const e=this.dropShadowAlpha,i=Math.round(Math.cos(this.dropShadowAngle)*this.dropShadowDistance),n=Math.round(Math.sin(this.dropShadowAngle)*this.dropShadowDistance);t.startsWith("#")&&e<1&&(t+=(e*255|0).toString(16).padStart(2,"0"));const s=`${i}px ${n}px`;return this.dropShadowBlur>0?`text-shadow: ${s} ${this.dropShadowBlur}px ${t}`:`text-shadow: ${s} ${t}`}reset(){Object.assign(this,pn.defaultOptions)}onBeforeDraw(){const{fontsDirty:t}=this;return this.fontsDirty=!1,this.isSafari&&this._fonts.length>0&&t?new Promise(e=>setTimeout(e,100)):Promise.resolve()}get isSafari(){const{userAgent:t}=J.ADAPTER.getNavigator();return/^((?!chrome|android).)*safari/i.test(t)}set fillGradientStops(t){console.warn("[HTMLTextStyle] fillGradientStops is not supported by HTMLText")}get fillGradientStops(){return super.fillGradientStops}set fillGradientType(t){console.warn("[HTMLTextStyle] fillGradientType is not supported by HTMLText")}get fillGradientType(){return super.fillGradientType}set miterLimit(t){console.warn("[HTMLTextStyle] miterLimit is not supported by HTMLText")}get miterLimit(){return super.miterLimit}set trim(t){console.warn("[HTMLTextStyle] trim is not supported by HTMLText")}get trim(){return super.trim}set textBaseline(t){console.warn("[HTMLTextStyle] textBaseline is not supported by HTMLText")}get textBaseline(){return super.textBaseline}set leading(t){console.warn("[HTMLTextStyle] leading is not supported by HTMLText")}get leading(){return super.leading}set lineJoin(t){console.warn("[HTMLTextStyle] lineJoin is not supported by HTMLText")}get lineJoin(){return super.lineJoin}};Ph.availableFonts={},Ph.defaultOptions={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",letterSpacing:0,lineHeight:0,padding:0,stroke:"black",strokeThickness:0,whiteSpace:"normal",wordWrap:!1,wordWrapWidth:100};let Rh=Ph;const Oo=class mn extends en{constructor(t="",e={}){super(ht.EMPTY),this._text=null,this._style=null,this._autoResolution=!0,this.localStyleID=-1,this.dirty=!1,this._updateID=0,this.ownsStyle=!1;const i=new Image,n=ht.from(i,{scaleMode:J.SCALE_MODE,resourceOptions:{autoLoad:!1}});n.orig=new xt,n.trim=new xt,this.texture=n;const s="http://www.w3.org/2000/svg",o="http://www.w3.org/1999/xhtml",a=document.createElementNS(s,"svg"),l=document.createElementNS(s,"foreignObject"),h=document.createElementNS(o,"div"),c=document.createElementNS(o,"style");l.setAttribute("width","10000"),l.setAttribute("height","10000"),l.style.overflow="hidden",a.appendChild(l),this.maxWidth=mn.defaultMaxWidth,this.maxHeight=mn.defaultMaxHeight,this._domElement=h,this._styleElement=c,this._svgRoot=a,this._foreignObject=l,this._foreignObject.appendChild(c),this._foreignObject.appendChild(h),this._image=i,this._loadImage=new Image,this._autoResolution=mn.defaultAutoResolution,this._resolution=mn.defaultResolution??J.RESOLUTION,this.text=t,this.style=e}measureText(t){var c,u;const{text:e,style:i,resolution:n}=Object.assign({text:this._text,style:this._style,resolution:this._resolution},t);Object.assign(this._domElement,{innerHTML:e,style:i.toCSS(n)}),this._styleElement.textContent=i.toGlobalCSS(),document.body.appendChild(this._svgRoot);const s=this._domElement.getBoundingClientRect();this._svgRoot.remove();const{width:o,height:a}=s;(o>this.maxWidth||a>this.maxHeight)&&console.warn("[HTMLText] Large expanse of text, increase HTMLText.maxWidth or HTMLText.maxHeight property.");const l=Math.min(this.maxWidth,Math.ceil(o)),h=Math.min(this.maxHeight,Math.ceil(a));return this._svgRoot.setAttribute("width",l.toString()),this._svgRoot.setAttribute("height",h.toString()),e!==this._text&&(this._domElement.innerHTML=this._text),i!==this._style&&(Object.assign(this._domElement,{style:(c=this._style)==null?void 0:c.toCSS(n)}),this._styleElement.textContent=(u=this._style)==null?void 0:u.toGlobalCSS()),{width:l+i.padding*2,height:h+i.padding*2}}async updateText(t=!0){const{style:e,_image:i,_loadImage:n}=this;if(this.localStyleID!==e.styleID&&(this.dirty=!0,this.localStyleID=e.styleID),!this.dirty&&t)return;const{width:s,height:o}=this.measureText();i.width=n.width=Math.ceil(Math.max(1,s)),i.height=n.height=Math.ceil(Math.max(1,o)),this._updateID++;const a=this._updateID;await new Promise(l=>{n.onload=async()=>{if(a<this._updateID){l();return}await e.onBeforeDraw(),i.src=n.src,n.onload=null,n.src="",this.updateTexture(),l()};const h=new XMLSerializer().serializeToString(this._svgRoot);n.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(h)}`})}get source(){return this._image}updateTexture(){const{style:t,texture:e,_image:i,resolution:n}=this,{padding:s}=t,{baseTexture:o}=e;e.trim.width=e._frame.width=i.width/n,e.trim.height=e._frame.height=i.height/n,e.trim.x=-s,e.trim.y=-s,e.orig.width=e._frame.width-s*2,e.orig.height=e._frame.height-s*2,this._onTextureUpdate(),o.setRealSize(i.width,i.height,n),this.dirty=!1}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._render(t)}_renderCanvas(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._renderCanvas(t)}getLocalBounds(t){return this.updateText(!0),super.getLocalBounds(t)}_calculateBounds(){this.updateText(!0),this.calculateVertices(),this._bounds.addQuad(this.vertexData)}_onStyleChange(){this.dirty=!0}destroy(t){var i,n,s,o,a;typeof t=="boolean"&&(t={children:t}),t=Object.assign({},mn.defaultDestroyOptions,t),super.destroy(t);const e=null;this.ownsStyle&&((i=this._style)==null||i.cleanFonts()),this._style=e,(n=this._svgRoot)==null||n.remove(),this._svgRoot=e,(s=this._domElement)==null||s.remove(),this._domElement=e,(o=this._foreignObject)==null||o.remove(),this._foreignObject=e,(a=this._styleElement)==null||a.remove(),this._styleElement=e,this._loadImage.src="",this._loadImage.onload=null,this._loadImage=e,this._image.src="",this._image=e}get width(){return this.updateText(!0),Math.abs(this.scale.x)*this._image.width/this.resolution}set width(t){this.updateText(!0);const e=kr(this.scale.x)||1;this.scale.x=e*t/this._image.width/this.resolution,this._width=t}get height(){return this.updateText(!0),Math.abs(this.scale.y)*this._image.height/this.resolution}set height(t){this.updateText(!0);const e=kr(this.scale.y)||1;this.scale.y=e*t/this._image.height/this.resolution,this._height=t}get style(){return this._style}set style(t){this._style!==t&&(t=t||{},t instanceof Rh?(this.ownsStyle=!1,this._style=t):t instanceof zr?(console.warn("[HTMLText] Cloning TextStyle, if this is not what you want, use HTMLTextStyle"),this.ownsStyle=!0,this._style=Rh.from(t)):(this.ownsStyle=!0,this._style=new Rh(t)),this.localStyleID=-1,this.dirty=!0)}get text(){return this._text}set text(t){t=String(t===""||t===null||t===void 0?" ":t),t=this.sanitiseText(t),this._text!==t&&(this._text=t,this.dirty=!0)}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}sanitiseText(t){return t.replace(/<br>/gi,"<br/>").replace(/<hr>/gi,"<hr/>").replace(/ /gi," ")}};Oo.defaultDestroyOptions={texture:!0,children:!1,baseTexture:!0},Oo.defaultMaxWidth=2024,Oo.defaultMaxHeight=2024,Oo.defaultAutoResolution=!0;const $S=16777215,HS=.25,XS=16777215,VS=1,zS=1.5;let Yr=!1,cn;const Mh=r=>{const t={tint:r!=null&&r.fill?new Mt(r.fill).toNumber():$S,alpha:(r==null?void 0:r.fillOpacity)!==void 0?Math.min(r.fillOpacity,1):String(r==null?void 0:r.fill).toLowerCase().startsWith("rgba(")?new Mt(r==null?void 0:r.fill).alpha:HS},e={tint:r!=null&&r.stroke?new Mt(r.stroke).toNumber():XS,alpha:(r==null?void 0:r.strokeOpacity)!==void 0?Math.min(r.strokeOpacity,1):String(r==null?void 0:r.stroke).toLowerCase().startsWith("rgba(")?new Mt(r==null?void 0:r.stroke).alpha:VS,lineWidth:(r==null?void 0:r.strokeWidth)===void 0?zS:r.strokeWidth};return{fillStyle:t,strokeStyle:e}},un=r=>(t,e,i,n={})=>{const{fillStyle:s,strokeStyle:o}=Mh(i),a=new Zn;n.strokeOnly||(a.beginFill(16777215),r(e,a),a.endFill(),a.tint=s.tint,a.alpha=s.alpha),t.addChild(a);const l=new Zn,h=o.lineWidth===1?1:o.lineWidth/cn;return l.lineStyle(h,16777215,1,.5,o.lineWidth===1),r(e,l),l.tint=o.tint||16777215,l.alpha=o.alpha,t.addChild(l),{fill:a,stroke:l,strokeWidth:o.lineWidth}},jS=un((r,t)=>{const{x:e,y:i,w:n,h:s}=r.geometry;t.drawRect(e,i,n,s)}),WS=un((r,t)=>{const{cx:e,cy:i,rx:n,ry:s}=r.geometry;t.drawEllipse(e,i,n,s)}),YS=un((r,t)=>{const[[e,i],[n,s]]=r.geometry.points;t.moveTo(e,i),t.lineTo(n,s),t.closePath()}),qS=un((r,t)=>{const e=r.geometry.points.reduce((i,n)=>[...i,...n],[]);t.drawPolygon(e)}),KS=un((r,t)=>{const{points:e,closed:i}=r.geometry;if(e.length===0)return;i||t.beginFill(0,0);const n=(o,a)=>{const[l,h]=o.point,[c,u]=a.point;if(o.type==="CURVE"||a.type==="CURVE"){const d=o.type==="CURVE"&&o.outHandle?o.outHandle[0]:l,p=o.type==="CURVE"&&o.outHandle?o.outHandle[1]:h,f=a.type==="CURVE"&&a.inHandle?a.inHandle[0]:c,m=a.type==="CURVE"&&a.inHandle?a.inHandle[1]:u;t.bezierCurveTo(d,p,f,m,c,u)}else t.lineTo(c,u)},s=e[0];t.moveTo(s.point[0],s.point[1]);for(let o=1;o<e.length;o++){const a=e[o-1],l=e[o];n(a,l)}if(i&&e.length>2){const o=e[e.length-1],a=e[0];n(o,a),t.closePath()}else t.endFill()}),ZS=un((r,t)=>{const e=i=>i.points.reduce((n,s)=>[...n,...s],[]);r.geometry.polygons.forEach(i=>{const[n,...s]=i.rings;t.drawPolygon(e(n)),s.forEach(o=>{t.beginHole(),t.drawPolygon(e(o)),t.endHole()})})}),Tm=r=>{const t=r.viewport.getContainerSize().x;return r.viewport.getZoom(!0)*t/r.world.getContentFactor()},Am=(r,t,e,i)=>()=>{const n=r.viewport.viewportToImageRectangle(r.viewport.getBounds(!0)),s=Tm(r);(s!==cn||!Yr)&&(Yr=!0,e.forEach(({stroke:d,strokeWidth:p})=>{const{lineStyle:f}=d.geometry.graphicsData[0];p>1?(Yr=s===cn,f.width=p/s,f.native=!1,d.geometry.invalidate()):p===1&&!f.native&&(f.width=1,f.native=!0,d.geometry.invalidate())})),cn=s;const o=r.viewport.getFlip();let a=Math.PI*r.viewport.getRotation(!0)/180;a<0&&(a+=2*Math.PI),a>2*Math.PI&&(a-=2*Math.PI);const l=o?r.viewport._containerInnerSize.x+n.x*s:-n.x*s,h=-n.y*s;let c,u;a>0&&a<=Math.PI/2?(c=n.height*s,u=0):a>Math.PI/2&&a<=Math.PI?(c=n.width*s,u=n.height*s):a>Math.PI&&a<=Math.PI*1.5?(c=0,u=n.width*s):(c=0,u=0),t.position.x=c+l*Math.cos(a)-h*Math.sin(a),t.position.y=u+l*Math.sin(a)+h*Math.cos(a),t.scale.set(o?-s:s,s),t.rotation=a,i.render(t)},JS=(r,t)=>{const e=new Zn,i=xp({width:t.width,height:t.height,backgroundAlpha:0,view:t,antialias:!0,resolution:2}),n=new Map;let s=new Set,o,a;cn=Tm(r);const l=(g,b)=>{Yr=!1;const C=n.get(g.id);C&&(C.fill.destroy(),C.stroke.destroy());const{selector:R}=g.target,A=typeof a=="function"?a(g,b):a;let P;if(R.type===mt.RECTANGLE)P=jS(e,R,A);else if(R.type===mt.POLYGON)P=qS(e,R,A);else if(R.type===mt.ELLIPSE)P=WS(e,R,A);else if(R.type===mt.MULTIPOLYGON)P=ZS(e,R,A);else if(R.type===mt.POLYLINE){const M=R;P=KS(e,M,A,{strokeOnly:!M.geometry.closed})}else R.type===mt.LINE?P=YS(e,R,A):console.warn(`Unsupported shape type: ${R.type}`);P&&n.set(g.id,{annotation:g,...P})},h=g=>{const b=n.get(g.id);b&&(n.delete(g.id),b.fill.destroy(),b.stroke.destroy())},c=(g,b,C)=>{Yr=!1;const R=n.get(g.id);if(R&&(n.delete(g.id),R.fill.destroy(),R.stroke.destroy(),l(b,C),s.has(b.id))){const{fill:A,stroke:P}=n.get(b.id);e.removeChild(A),e.removeChild(P)}},u=(g,b)=>{const C=n.get(g);C&&(n.delete(g),C.fill.destroy(),C.stroke.destroy(),l(C.annotation,b))},d=(g,b)=>{i.resize(g,b),i.render(e)},p=g=>{Yr=!1;const{children:b}=e;n.forEach(({fill:C,stroke:R,annotation:A})=>{const P=g?s.has(A.id)||g(A):!0;P&&!b.includes(C)?(e.addChild(C),e.addChild(R)):!P&&b.includes(C)&&(e.removeChild(C),e.removeChild(R))}),i.render(e)},f=g=>{const b=new Set(g.selected.map(A=>A.id)),C=g.selected.filter(({id:A})=>!s.has(A)),R=[...s].filter(A=>!b.has(A));C.forEach(({id:A,editable:P})=>{if(P){const M=n.get(A);M&&da(M.annotation.target.selector)&&(e.removeChild(M.fill),e.removeChild(M.stroke))}else u(A,{selected:!0,hovered:A===o})}),R.forEach(A=>u(A,{hovered:A===o})),s=b,i.render(e)},m=g=>{o!==g&&(o&&!s.has(o)&&u(o,{selected:s.has(o)}),g&&u(g,{selected:s.has(g),hovered:!0}),o=g,i.render(e))},_=g=>{if(typeof g=="function")n.forEach(({annotation:b,fill:C,stroke:R,strokeWidth:A},P)=>{A>1&&(Yr=!1);const M={selected:s.has(b.id),hovered:o===b.id},{fillStyle:k,strokeStyle:U}=Mh(g(b,M));C.tint=k.tint,C.alpha=k.alpha,R.tint=U.tint||16777215,R.alpha=U.alpha,n.set(b.id,{annotation:b,fill:C,stroke:R,strokeWidth:U.lineWidth})});else{const{fillStyle:b,strokeStyle:C}=Mh(g);C.lineWidth>1&&(Yr=!1),n.forEach(({annotation:R,fill:A,stroke:P,strokeWidth:M},k)=>{A.tint=b.tint,A.alpha=b.alpha,P.tint=C.tint||16777215,P.alpha=C.alpha,n.set(R.id,{annotation:R,fill:A,stroke:P,strokeWidth:C.lineWidth})})}a=g,i.render(e),Am(r,e,n,i)()},v=g=>{g?t.classList.remove("hidden"):t.classList.add("hidden")};return{addAnnotation:l,destroy:()=>i.destroy(),getScale:()=>cn,redraw:Am(r,e,n,i),removeAnnotation:h,resize:d,setFilter:p,setHovered:m,setSelected:f,setStyle:_,setVisible:v,updateAnnotation:c}};function QS(r,t,e){let i,n,{filter:s}=t,{state:o}=t,{style:a}=t,{viewer:l}=t,{visible:h=!0}=t;const{store:c,hover:u,selection:d,viewport:p}=o;vs(r,u,A=>e(11,i=A)),vs(r,d,A=>e(8,n=A));const f=Di();let m,_;const v=A=>{const P=new ce.Point(A.x,A.y),{x:M,y:k}=l.viewport.pointFromPixel(P);return l.viewport.viewportToImageCoordinates(M,k)},y=()=>2/m.getScale(),g=A=>{const{x:P,y:M}=A.position;_={x:P,y:M}},b=A=>P=>{const{x:M,y:k}=v(new ce.Point(P.offsetX,P.offsetY)),U=y(),I=c.getAt(M,k,s,U);I?(A.classList.add("hover"),i!==I.id&&(u.set(I.id),m.setHovered(I.id))):(A.classList.remove("hover"),i&&(u.set(void 0),m.setHovered(void 0)))},C=A=>{if(!_)return;const P=A.originalEvent,{x:M,y:k}=A.position,U=M-_.x,I=k-_.y;if(Math.sqrt(U*U+I*I)<5){const{x:E,y:S}=v(A.position),L=y(),D=c.getAt(E,S,s,L);D?f("click",{originalEvent:P,annotation:D}):f("click",{originalEvent:P})}_=void 0};let R;return ei(()=>{var D;const{offsetWidth:A,offsetHeight:P}=l.canvas,M=document.createElement("canvas");M.width=A,M.height=P,M.className="a9s-gl-canvas",(D=l.element.querySelector(".openseadragon-canvas"))==null||D.appendChild(M),e(7,m=JS(l,M));const k=b(M);M.addEventListener("pointermove",k);const U=new ResizeObserver(N=>{try{const{width:H,height:B}=N[0].contentRect;M.width=H,M.height=B,m.resize(H,B)}catch{console.warn("WebGL canvas already disposed")}});U.observe(M);const I=()=>{const N=l.viewport.getBounds();R=l.viewport.viewportToImageRectangle(N);const{x:H,y:B,width:O,height:$}=R,F=c.getIntersecting(H,B,O,$);p.set(F.map(X=>X.id))};l.addHandler("canvas-press",g),l.addHandler("canvas-release",C),l.addHandler("update-viewport",m.redraw),l.addHandler("animation-finish",I);const T=N=>N.filter(H=>Le(H)),E=N=>Le(N.oldValue)&&Le(N.newValue),S=N=>{const{selector:H}=N.target;if(H.type===mt.POLYGON){const B=Q_(H);return{...N,target:{...N.target,selector:{...B}}}}else if(H.type===mt.MULTIPOLYGON){const B=Z_(H);return{...N,target:{...N.target,selector:{...B}}}}else return N},L=N=>{const{created:H,updated:B,deleted:O}=N.changes,$=(H||[]).filter(F=>Le(F)).map(S);if(T(O||[]).forEach(F=>m.removeAnnotation(F)),$.forEach(F=>m.addAnnotation(F)),(B||[]).filter(F=>E(F)).map(({oldValue:F,newValue:X})=>({oldValue:F,newValue:S(X)})).forEach(({oldValue:F,newValue:X})=>m.updateAnnotation(F,X)),R){const{x:F,y:X,width:V,height:dt}=R,yt=c.getIntersecting(F,X,V,dt);p.set(yt.map(z=>z.id))}else p.set(c.all().map(F=>F.id));m.redraw()};return c.observe(L),()=>{var N;M.removeEventListener("pointermove",k),U.disconnect(),l.removeHandler("canvas-press",g),l.removeHandler("canvas-release",C),l.removeHandler("update-viewport",m.redraw),l.removeHandler("animation-finish",I),c.unobserve(L),m.destroy(),(N=M.parentNode)==null||N.removeChild(M)}}),r.$$set=A=>{"filter"in A&&e(2,s=A.filter),"state"in A&&e(3,o=A.state),"style"in A&&e(4,a=A.style),"viewer"in A&&e(5,l=A.viewer),"visible"in A&&e(6,h=A.visible)},r.$$.update=()=>{r.$$.dirty&132&&(m==null||m.setFilter(s)),r.$$.dirty&384&&(m==null||m.setSelected(n)),r.$$.dirty&144&&(m==null||m.setStyle(a)),r.$$.dirty&192&&(m==null||m.setVisible(h))},[u,d,s,o,a,l,h,m,n]}class t2 extends jt{constructor(t){super(),zt(this,t,QS,null,Ut,{filter:2,state:3,style:4,viewer:5,visible:6})}}const Sm=(r,t,e,i)=>{if(!i)return r;if(t.shiftKey||t.ctrlKey||t.metaKey){const s=(e.selected||[]).map(o=>o.id);return s.includes(r)?s.filter(o=>o!==r):[...s,r]}else return r},e2=r=>({transform:r&2,scale:r&1}),Cm=r=>({transform:r[1],scale:r[0]});function r2(r){let t;const e=r[4].default,i=lu(e,r,r[3],Cm);return{c(){i&&i.c()},m(n,s){i&&i.m(n,s),t=!0},p(n,[s]){i&&i.p&&(!t||s&11)&&uu(i,e,n,n[3],t?cu(e,n[3],s,e2):du(n[3]),Cm)},i(n){t||(q(i,n),t=!0)},o(n){ot(i,n),t=!1},d(n){i&&i.d(n)}}}function i2(r,t,e){let{$$slots:i={},$$scope:n}=t,{viewer:s}=t,o=1,a;const l=()=>{const h=s.viewport.getContainerSize().x,c=s.viewport.getZoom(!0),u=s.viewport.getFlip(),d=s.viewport.pixelFromPoint(new ce.Point(0,0),!0);u&&(d.x=h-d.x);const p=c*h/s.world.getContentFactor(),f=u?-p:p,m=s.viewport.getRotation(!0);e(1,a=`translate(${d.x}, ${d.y}) scale(${f}, ${p}) rotate(${m})`),e(0,o=c*h/s.world.getContentFactor())};return ei(()=>(s.addHandler("update-viewport",l),()=>{s.removeHandler("update-viewport",l)})),r.$$set=h=>{"viewer"in h&&e(2,s=h.viewer),"$$scope"in h&&e(3,n=h.$$scope)},[o,a,s,n,i]}class Dh extends jt{constructor(t){super(),zt(this,t,i2,r2,Ut,{viewer:2})}}function n2(r,t,e){const i=Di();let{drawingMode:n}=t,{opts:s}=t,{target:o}=t,{tool:a}=t,{transform:l}=t,{viewer:h}=t,{viewportScale:c}=t,u;return ei(()=>{const d=o.closest("svg"),p=[],f=(m,_,v)=>{if(d==null||d.addEventListener(m,_,v),p.push(()=>d==null?void 0:d.removeEventListener(m,_,v)),m==="pointerup"||m==="dblclick"){const y=b=>{const{originalEvent:C}=b;_(C)},g=m==="pointerup"?"canvas-click":"canvas-double-click";h.addHandler(g,y),p.push(()=>h.removeHandler(g,y))}else if(m==="pointermove"){const y=g=>{const{originalEvent:b}=g;_(b)};h.addHandler("canvas-drag",y),p.push(()=>h.removeHandler("canvas-drag",y))}};return e(7,u=new a({target:o,props:{addEventListener:f,drawingMode:n,opts:s,transform:l,viewportScale:c,svgEl:d}})),u.$on("create",m=>i("create",m.detail)),()=>{p.forEach(m=>m()),u.$destroy()}}),r.$$set=d=>{"drawingMode"in d&&e(0,n=d.drawingMode),"opts"in d&&e(1,s=d.opts),"target"in d&&e(2,o=d.target),"tool"in d&&e(3,a=d.tool),"transform"in d&&e(4,l=d.transform),"viewer"in d&&e(5,h=d.viewer),"viewportScale"in d&&e(6,c=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&144&&u&&u.$set({transform:l}),r.$$.dirty&192&&u&&u.$set({viewportScale:c})},[n,s,o,a,l,h,c,u]}class s2 extends jt{constructor(t){super(),zt(this,t,n2,null,Ut,{drawingMode:0,opts:1,target:2,tool:3,transform:4,viewer:5,viewportScale:6})}}const{Boolean:o2}=va;function Im(r,t,e){const i=r.slice();i[38]=t[e];const n=i[17](i[38].target.selector);return i[39]=n,i}function a2(r){let t=`${r[2]}-${r[7]}`,e,i,n=Pm(r);return{c(){n.c(),e=Pe()},m(s,o){n.m(s,o),st(s,e,o),i=!0},p(s,o){o[0]&132&&Ut(t,t=`${s[2]}-${s[7]}`)?(ne(),ot(n,1,1,Ft),se(),n=Pm(s),n.c(),q(n,1),n.m(e.parentNode,e)):n.p(s,o)},i(s){i||(q(n),i=!0)},o(s){ot(n),i=!1},d(s){s&&nt(e),n.d(s)}}}function l2(r){let t,e,i=xe(r[9].filter(r[27])),n=[];for(let o=0;o<i.length;o+=1)n[o]=Dm(Im(r,i,o));const s=o=>ot(n[o],1,1,()=>{n[o]=null});return{c(){for(let o=0;o<n.length;o+=1)n[o].c();t=Pe()},m(o,a){for(let l=0;l<n.length;l+=1)n[l]&&n[l].m(o,a);st(o,t,a),e=!0},p(o,a){if(a[0]&193282|a[1]&64){i=xe(o[9].filter(o[27]));let l;for(l=0;l<i.length;l+=1){const h=Im(o,i,l);n[l]?(n[l].p(h,a),q(n[l],1)):(n[l]=Dm(h),n[l].c(),q(n[l],1),n[l].m(t.parentNode,t))}for(ne(),l=i.length;l<n.length;l+=1)s(l);se()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)q(n[a]);e=!0}},o(o){n=n.filter(o2);for(let a=0;a<n.length;a+=1)ot(n[a]);e=!1},d(o){o&&nt(t),Dr(n,o)}}}function Pm(r){let t,e;return t=new s2({props:{target:r[8],tool:r[10],drawingMode:r[4],transform:{elementToImage:r[12]},viewer:r[3],viewportScale:r[37],opts:r[5]}}),t.$on("create",r[16]),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n[0]&256&&(s.target=i[8]),n[0]&1024&&(s.tool=i[10]),n[0]&16&&(s.drawingMode=i[4]),n[0]&8&&(s.viewer=i[3]),n[1]&64&&(s.viewportScale=i[37]),n[0]&32&&(s.opts=i[5]),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){ot(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function Rm(r){let t=r[38].id,e,i,n=Mm(r);return{c(){n.c(),e=Pe()},m(s,o){n.m(s,o),st(s,e,o),i=!0},p(s,o){o[0]&512&&Ut(t,t=s[38].id)?(ne(),ot(n,1,1,Ft),se(),n=Mm(s),n.c(),q(n,1),n.m(e.parentNode,e)):n.p(s,o)},i(s){i||(q(n),i=!0)},o(s){ot(n),i=!1},d(s){s&&nt(e),n.d(s)}}}function Mm(r){let t,e;return t=new Uv({props:{target:r[8],editor:r[17](r[38].target.selector),annotation:r[38],style:r[1],transform:{elementToImage:r[12]},viewportScale:r[37]}}),t.$on("grab",r[13]),t.$on("change",function(){Kt(r[15](r[38]))&&r[15](r[38]).apply(this,arguments)}),t.$on("release",r[14]),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){r=i;const s={};n[0]&256&&(s.target=r[8]),n[0]&512&&(s.editor=r[17](r[38].target.selector)),n[0]&512&&(s.annotation=r[38]),n[0]&2&&(s.style=r[1]),n[1]&64&&(s.viewportScale=r[37]),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){ot(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function Dm(r){let t,e,i=r[39]&&Rm(r);return{c(){i&&i.c(),t=Pe()},m(n,s){i&&i.m(n,s),st(n,t,s),e=!0},p(n,s){n[39]?i?(i.p(n,s),s[0]&512&&q(i,1)):(i=Rm(n),i.c(),q(i,1),i.m(t.parentNode,t)):i&&(ne(),ot(i,1,1,()=>{i=null}),se())},i(n){e||(q(i),e=!0)},o(n){ot(i),e=!1},d(n){n&&nt(t),i&&i.d(n)}}}function h2(r){let t,e,i,n,s,o;const a=[l2,a2],l=[];function h(c,u){var d;return c[8]&&((d=c[9])==null?void 0:d.length)===1?0:c[8]&&c[10]&&c[0]?1:-1}return~(i=h(r))&&(n=l[i]=a[i](r)),{c(){t=et("svg"),e=et("g"),n&&n.c(),w(e,"transform",s=r[36]),w(e,"class","svelte-g4ws1v"),w(t,"tabindex",0),w(t,"class","a9s-annotationlayer a9s-osd-drawinglayer svelte-g4ws1v"),Br(t,"drawing",r[0]),Br(t,"editing",r[9]),Br(t,"hover",r[6])},m(c,u){st(c,t,u),At(t,e),~i&&l[i].m(e,null),r[28](e),o=!0},p(c,u){let d=i;i=h(c),i===d?~i&&l[i].p(c,u):(n&&(ne(),ot(l[d],1,1,()=>{l[d]=null}),se()),~i?(n=l[i],n?n.p(c,u):(n=l[i]=a[i](c),n.c()),q(n,1),n.m(e,null)):n=null),(!o||u[1]&32&&s!==(s=c[36]))&&w(e,"transform",s),(!o||u[0]&1)&&Br(t,"drawing",c[0]),(!o||u[0]&512)&&Br(t,"editing",c[9]),(!o||u[0]&64)&&Br(t,"hover",c[6])},i(c){o||(q(n),o=!0)},o(c){ot(n),o=!1},d(c){c&&nt(t),~i&&l[i].d(),r[28](null)}}}function c2(r){let t,e;return t=new Dh({props:{viewer:r[3],$$slots:{default:[h2,({transform:i,scale:n})=>({36:i,37:n}),({transform:i,scale:n})=>[0,(i?32:0)|(n?64:0)]]},$$scope:{ctx:r}}}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n[0]&8&&(s.viewer=i[3]),n[0]&2047|n[1]&2144&&(s.$$scope={dirty:n,ctx:i}),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){ot(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function u2(r,t,e){let i,n,s,o,{drawingEnabled:a}=t,{filter:l}=t,{multiSelect:h}=t,{preferredDrawingMode:c}=t,{state:u}=t,{style:d=void 0}=t,{toolName:p=ms()[0]}=t,{user:f}=t,{viewer:m}=t,_=!1,v=0;const y=()=>e(7,v+=1),g=()=>p,b=()=>a;let C;const{store:R,selection:A,hover:P}=u;vs(r,A,F=>e(26,o=F));let M,k,U;const I=F=>{R.unobserve(M);const X=F.filter(({editable:V})=>V).map(({id:V})=>V);X.length>0?(e(9,k=X.map(V=>R.getAnnotation(V))),M=V=>{const{updated:dt}=V.changes;e(9,k=(dt||[]).map(yt=>yt.newValue))},R.observe(M,{annotations:X}),m.forceRedraw()):e(9,k=void 0)},T=(F,X)=>{const{x:V,y:dt}=m.viewport.viewerElementToImageCoordinates(new ce.Point(F,X));return[V,dt]},E=()=>{const F=m.viewport.getContainerSize().x;return m.viewport.getZoom(!0)*F/m.world.getContentFactor()},S=()=>2/E(),L=F=>{m.setMouseNavEnabled(!1),U=F.timeStamp},D=F=>{if(m.setMouseNavEnabled(!0),performance.now()-(U||0)<300){const{offsetX:V,offsetY:dt}=F.detail,[yt,z]=T(V,dt),wt=S(),it=R.getAt(yt,z,void 0,wt);if(it&&(!l||l(it))&&!k.find(_t=>_t.id===it.id)){P.set(it.id);const _t=Sm(it.id,F.detail,A,h);A.userSelect(_t)}}},N=F=>X=>{var z;const{target:V}=F,dt=10*60*1e3,yt=((z=V.creator)==null?void 0:z.id)!==f.id||!V.created||new Date().getTime()-V.created.getTime()>dt;R.updateTarget({...V,selector:X.detail,created:yt?V.created:new Date,updated:yt?new Date:void 0,updatedBy:yt?f:void 0})},H=F=>{const X=ov(),V={id:X,bodies:[],target:{annotation:X,selector:F.detail,creator:f,created:new Date}};R.addAnnotation(V),A.setSelected(V.id),m.setMouseNavEnabled(!0)},B=F=>da(F);ei(()=>{const F=X=>{if(o.selected.length===0)return;const{offsetX:V,offsetY:dt}=X,yt=m.viewport.pointFromPixel(new ce.Point(V,dt)),{x:z,y:wt}=m.viewport.viewportToImageCoordinates(yt.x,yt.y),it=S();e(6,_=!!R.getAt(z,wt,l,it))};return m.element.addEventListener("pointermove",F),()=>{var X;(X=m.element)==null||X.removeEventListener("pointermove",F)}});const O=F=>Le(F);function $(F){bs[F?"unshift":"push"](()=>{C=F,e(8,C)})}return r.$$set=F=>{"drawingEnabled"in F&&e(0,a=F.drawingEnabled),"filter"in F&&e(18,l=F.filter),"multiSelect"in F&&e(19,h=F.multiSelect),"preferredDrawingMode"in F&&e(20,c=F.preferredDrawingMode),"state"in F&&e(21,u=F.state),"style"in F&&e(1,d=F.style),"toolName"in F&&e(2,p=F.toolName),"user"in F&&e(22,f=F.user),"viewer"in F&&e(3,m=F.viewer)},r.$$.update=()=>{r.$$.dirty[0]&4&&e(10,{tool:i,opts:n}=gs(p)||{tool:void 0,opts:void 0},i,(e(5,n),e(2,p))),r.$$.dirty[0]&1048608&&e(4,s=(n==null?void 0:n.drawingMode)||c),r.$$.dirty[0]&25&&(a&&s==="drag"?m.setMouseNavEnabled(!1):m.setMouseNavEnabled(!0)),r.$$.dirty[0]&1&&a&&A.clear(),r.$$.dirty[0]&67108889&&o.selected.length===0&&s==="drag"&&a&&m.setMouseNavEnabled(!1),r.$$.dirty[0]&67108864&&I(o.selected)},[a,d,p,m,s,n,_,v,C,k,i,A,T,L,D,N,H,B,l,h,c,u,f,y,g,b,o,O,$]}class d2 extends jt{constructor(t){super(),zt(this,t,u2,c2,Ut,{drawingEnabled:0,filter:18,multiSelect:19,preferredDrawingMode:20,state:21,style:1,toolName:2,user:22,viewer:3,cancelDrawing:23,getDrawingTool:24,isDrawingEnabled:25},null,[-1,-1])}get cancelDrawing(){return this.$$.ctx[23]}get getDrawingTool(){return this.$$.ctx[24]}get isDrawingEnabled(){return this.$$.ctx[25]}}function f2(r){let t,e,i,n,s,o,a,l=r[2].appearance.label+"",h,c,u,d;return{c(){t=et("g"),e=et("rect"),a=et("text"),h=ba(l),w(e,"class","a9s-presence-label-bg svelte-1rehw2p"),w(e,"x",r[0]),w(e,"y",i=r[1]-18/r[3]),w(e,"height",n=18/r[3]),w(e,"fill",s=r[2].appearance.color),w(e,"stroke",o=r[2].appearance.color),w(a,"font-size",c=12/r[3]),w(a,"x",u=r[0]+Math.round(5/r[3])),w(a,"y",d=r[1]-5/r[3]),w(a,"class","svelte-1rehw2p"),w(t,"class","a9s-presence-label")},m(p,f){st(p,t,f),At(t,e),At(t,a),At(a,h),r[6](t)},p(p,[f]){f&1&&w(e,"x",p[0]),f&10&&i!==(i=p[1]-18/p[3])&&w(e,"y",i),f&8&&n!==(n=18/p[3])&&w(e,"height",n),f&4&&s!==(s=p[2].appearance.color)&&w(e,"fill",s),f&4&&o!==(o=p[2].appearance.color)&&w(e,"stroke",o),f&4&&l!==(l=p[2].appearance.label+"")&&L_(h,l),f&8&&c!==(c=12/p[3])&&w(a,"font-size",c),f&9&&u!==(u=p[0]+Math.round(5/p[3]))&&w(a,"x",u),f&10&&d!==(d=p[1]-5/p[3])&&w(a,"y",d)},i:Ft,o:Ft,d(p){p&&nt(t),r[6](null)}}}function p2(r,t,e){let{x:i}=t,{y:n}=t,{user:s}=t,{scale:o}=t,{hAlign:a=null}=t,l;const h=u=>{const d=l.querySelector("text"),p=l.querySelector("rect"),f=d.getBBox().width+10/u;a==="CENTER"&&l.setAttribute("style",`transform: translateX(-${f/2}px)`),p.setAttribute("width",`${f}`)};function c(u){bs[u?"unshift":"push"](()=>{l=u,e(4,l)})}return r.$$set=u=>{"x"in u&&e(0,i=u.x),"y"in u&&e(1,n=u.y),"user"in u&&e(2,s=u.user),"scale"in u&&e(3,o=u.scale),"hAlign"in u&&e(5,a=u.hAlign)},r.$$.update=()=>{r.$$.dirty&24&&l&&h(o)},[i,n,s,o,l,a,c]}class Bm extends jt{constructor(t){super(),zt(this,t,p2,f2,Ut,{x:0,y:1,user:2,scale:3,hAlign:5})}}function m2(r){let t,e,i,n,s,o;return e=new Bm({props:{scale:r[1],user:r[0],x:r[3][0],y:r[3][1],hAlign:"CENTER"}}),{c(){t=et("g"),Lt(e.$$.fragment),i=et("polygon"),w(i,"class","a9s-presence-shape a9s-presence-polygon svelte-fgq4n0"),w(i,"stroke",n=r[0].appearance.color),w(i,"fill","transparent"),w(i,"points",s=r[2].points.map(Om).join(" ")),w(t,"class","a9s-presence-overlay")},m(a,l){st(a,t,l),Bt(e,t,null),At(t,i),o=!0},p(a,[l]){const h={};l&2&&(h.scale=a[1]),l&1&&(h.user=a[0]),l&8&&(h.x=a[3][0]),l&8&&(h.y=a[3][1]),e.$set(h),(!o||l&1&&n!==(n=a[0].appearance.color))&&w(i,"stroke",n),(!o||l&4&&s!==(s=a[2].points.map(Om).join(" ")))&&w(i,"points",s)},i(a){o||(q(e.$$.fragment,a),o=!0)},o(a){ot(e.$$.fragment,a),o=!1},d(a){a&&nt(t),Ot(e)}}}const Om=r=>r.join(",");function g2(r,t,e){let i,n,{annotation:s}=t,{user:o}=t,{scale:a}=t;const l=h=>{let[c,...u]=h.points;return u.forEach(([d,p])=>{p<c[1]&&(c=[d,p])}),c};return r.$$set=h=>{"annotation"in h&&e(4,s=h.annotation),"user"in h&&e(0,o=h.user),"scale"in h&&e(1,a=h.scale)},r.$$.update=()=>{r.$$.dirty&16&&e(2,i=s.target.selector.geometry),r.$$.dirty&4&&e(3,n=l(i))},[o,a,i,n,s]}class y2 extends jt{constructor(t){super(),zt(this,t,g2,m2,Ut,{annotation:4,user:0,scale:1})}}function _2(r){let t,e,i,n,s,o,a,l,h;return e=new Bm({props:{scale:r[1],user:r[0],x:r[2].x,y:r[2].y}}),{c(){t=et("g"),Lt(e.$$.fragment),i=et("rect"),w(i,"class","a9s-presence-shape a9s-presence-rectangle svelte-gze948"),w(i,"stroke",n=r[0].appearance.color),w(i,"fill","transparent"),w(i,"x",s=r[2].x),w(i,"y",o=r[2].y),w(i,"width",a=r[2].w),w(i,"height",l=r[2].h),w(t,"class","a9s-presence-overlay")},m(c,u){st(c,t,u),Bt(e,t,null),At(t,i),h=!0},p(c,[u]){const d={};u&2&&(d.scale=c[1]),u&1&&(d.user=c[0]),u&4&&(d.x=c[2].x),u&4&&(d.y=c[2].y),e.$set(d),(!h||u&1&&n!==(n=c[0].appearance.color))&&w(i,"stroke",n),(!h||u&4&&s!==(s=c[2].x))&&w(i,"x",s),(!h||u&4&&o!==(o=c[2].y))&&w(i,"y",o),(!h||u&4&&a!==(a=c[2].w))&&w(i,"width",a),(!h||u&4&&l!==(l=c[2].h))&&w(i,"height",l)},i(c){h||(q(e.$$.fragment,c),h=!0)},o(c){ot(e.$$.fragment,c),h=!1},d(c){c&&nt(t),Ot(e)}}}function v2(r,t,e){let i,{annotation:n}=t,{user:s}=t,{scale:o}=t;return r.$$set=a=>{"annotation"in a&&e(3,n=a.annotation),"user"in a&&e(0,s=a.user),"scale"in a&&e(1,o=a.scale)},r.$$.update=()=>{r.$$.dirty&8&&e(2,i=n.target.selector.geometry)},[s,o,i,n]}class b2 extends jt{constructor(t){super(),zt(this,t,v2,_2,Ut,{annotation:3,user:0,scale:1})}}const{Boolean:x2}=va;function Lm(r,t,e){const i=r.slice();return i[8]=t[e],i}function Nm(r){let t,e;return t=new Dh({props:{viewer:r[0],$$slots:{default:[T2,({transform:i,scale:n})=>({6:i,7:n}),({transform:i,scale:n})=>(i?64:0)|(n?128:0)]},$$scope:{ctx:r}}}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n&1&&(s.viewer=i[0]),n&2244&&(s.$$scope={dirty:n,ctx:i}),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){ot(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function Fm(r){let t,e,i=xe(r[2]),n=[];for(let o=0;o<i.length;o+=1)n[o]=km(Lm(r,i,o));const s=o=>ot(n[o],1,1,()=>{n[o]=null});return{c(){for(let o=0;o<n.length;o+=1)n[o].c();t=Pe()},m(o,a){for(let l=0;l<n.length;l+=1)n[l]&&n[l].m(o,a);st(o,t,a),e=!0},p(o,a){if(a&132){i=xe(o[2]);let l;for(l=0;l<i.length;l+=1){const h=Lm(o,i,l);n[l]?(n[l].p(h,a),q(n[l],1)):(n[l]=km(h),n[l].c(),q(n[l],1),n[l].m(t.parentNode,t))}for(ne(),l=i.length;l<n.length;l+=1)s(l);se()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)q(n[a]);e=!0}},o(o){n=n.filter(x2);for(let a=0;a<n.length;a+=1)ot(n[a]);e=!1},d(o){o&&nt(t),Dr(n,o)}}}function w2(r){let t,e;return t=new y2({props:{annotation:r[8].annotation,user:r[8].selectedBy,scale:r[7]}}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n&4&&(s.annotation=i[8].annotation),n&4&&(s.user=i[8].selectedBy),n&128&&(s.scale=i[7]),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){ot(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function E2(r){let t,e;return t=new b2({props:{annotation:r[8].annotation,user:r[8].selectedBy,scale:r[7]}}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n&4&&(s.annotation=i[8].annotation),n&4&&(s.user=i[8].selectedBy),n&128&&(s.scale=i[7]),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){ot(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function km(r){let t,e,i,n;const s=[E2,w2],o=[];function a(l,h){return l[8].annotation.target.selector.type===mt.RECTANGLE?0:l[8].annotation.target.selector.type===mt.POLYGON?1:-1}return~(t=a(r))&&(e=o[t]=s[t](r)),{c(){e&&e.c(),i=Pe()},m(l,h){~t&&o[t].m(l,h),st(l,i,h),n=!0},p(l,h){let c=t;t=a(l),t===c?~t&&o[t].p(l,h):(e&&(ne(),ot(o[c],1,1,()=>{o[c]=null}),se()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=s[t](l),e.c()),q(e,1),e.m(i.parentNode,i)):e=null)},i(l){n||(q(e),n=!0)},o(l){ot(e),n=!1},d(l){l&&nt(i),~t&&o[t].d(l)}}}function T2(r){let t,e,i,n,s=r[2].length>0&&Fm(r);return{c(){t=et("svg"),e=et("g"),s&&s.c(),w(e,"transform",i=r[6]),w(t,"class","a9s-osd-presencelayer svelte-1krwc4m")},m(o,a){st(o,t,a),At(t,e),s&&s.m(e,null),n=!0},p(o,a){o[2].length>0?s?(s.p(o,a),a&4&&q(s,1)):(s=Fm(o),s.c(),q(s,1),s.m(e,null)):s&&(ne(),ot(s,1,1,()=>{s=null}),se()),(!n||a&64&&i!==(i=o[6]))&&w(e,"transform",i)},i(o){n||(q(s),n=!0)},o(o){ot(s),n=!1},d(o){o&&nt(t),s&&s.d()}}}function A2(r){let t=!!r[1],e,i,n=t&&Nm(r);return{c(){n&&n.c(),e=Pe()},m(s,o){n&&n.m(s,o),st(s,e,o),i=!0},p(s,[o]){o&2&&(t=!!s[1]),t?n?(n.p(s,o),o&2&&q(n,1)):(n=Nm(s),n.c(),q(n,1),n.m(e.parentNode,e)):n&&(ne(),ot(n,1,1,()=>{n=null}),se())},i(s){i||(q(n),i=!0)},o(s){ot(n),i=!1},d(s){s&&nt(e),n&&n.d(s)}}}function S2(r,t,e){let{store:i}=t,{viewer:n}=t,{provider:s}=t,o=[],a;const l=(h,c)=>{e(2,o=[...o.filter(({selectedBy:u})=>u.presenceKey!==h.presenceKey),...(c||[]).map(u=>({annotation:i.getAnnotation(u),selectedBy:h}))].filter(({annotation:u})=>(u||console.warn("Selection event on unknown annotation"),!!u))),a&&i.unobserve(a),a=u=>{const{deleted:d,updated:p}=u.changes,f=new Set((d||[]).map(_=>_.id)),m=o.filter(({annotation:_})=>!f.has(_.id)).map(_=>{const v=(p||[]).find(y=>y.oldValue.id===_.annotation.id);return v?{selectedBy:_.selectedBy,annotation:v.newValue}:_});e(2,o=m)},i.observe(a,{annotations:o.map(u=>u.annotation.id)})};return F_(()=>{a&&i.unobserve(a)}),r.$$set=h=>{"store"in h&&e(3,i=h.store),"viewer"in h&&e(0,n=h.viewer),"provider"in h&&e(1,s=h.provider)},r.$$.update=()=>{r.$$.dirty&2&&s&&s.on("selectionChange",l)},[n,s,o,i]}class C2 extends jt{constructor(t){super(),zt(this,t,S2,A2,Ut,{store:3,viewer:0,provider:1})}}function I2(r){let t,e,i,n,s;return{c(){t=et("ellipse"),w(t,"cx",e=r[0].cx),w(t,"cy",i=r[0].cy),w(t,"rx",n=r[0].rx),w(t,"ry",s=r[0].ry)},m(o,a){st(o,t,a)},p(o,[a]){a&1&&e!==(e=o[0].cx)&&w(t,"cx",e),a&1&&i!==(i=o[0].cy)&&w(t,"cy",i),a&1&&n!==(n=o[0].rx)&&w(t,"rx",n),a&1&&s!==(s=o[0].ry)&&w(t,"ry",s)},i:Ft,o:Ft,d(o){o&&nt(t)}}}function P2(r,t,e){let i,{annotation:n}=t;return r.$$set=s=>{"annotation"in s&&e(1,n=s.annotation)},r.$$.update=()=>{r.$$.dirty&2&&e(0,i=n.target.selector.geometry)},[i,n]}class R2 extends jt{constructor(t){super(),zt(this,t,P2,I2,Ut,{annotation:1})}}function M2(r){let t,e,i,n,s;return{c(){t=et("line"),w(t,"x1",e=r[0].points[0][0]),w(t,"y1",i=r[0].points[0][1]),w(t,"x2",n=r[0].points[1][0]),w(t,"y2",s=r[0].points[1][1])},m(o,a){st(o,t,a)},p(o,[a]){a&1&&e!==(e=o[0].points[0][0])&&w(t,"x1",e),a&1&&i!==(i=o[0].points[0][1])&&w(t,"y1",i),a&1&&n!==(n=o[0].points[1][0])&&w(t,"x2",n),a&1&&s!==(s=o[0].points[1][1])&&w(t,"y2",s)},i:Ft,o:Ft,d(o){o&&nt(t)}}}function D2(r,t,e){let i,{annotation:n}=t;return r.$$set=s=>{"annotation"in s&&e(1,n=s.annotation)},r.$$.update=()=>{r.$$.dirty&2&&e(0,i=n.target.selector.geometry)},[i,n]}class B2 extends jt{constructor(t){super(),zt(this,t,D2,M2,Ut,{annotation:1})}}function Um(r,t,e){const i=r.slice();return i[2]=t[e],i}function Gm(r){let t,e;return{c(){t=et("path"),e=et("path"),w(t,"fill-rule","evenodd"),w(t,"d",$e(r[2])),w(e,"class","a9s-inner"),w(e,"fill-rule","evenodd"),w(e,"d",$e(r[2]))},m(i,n){st(i,t,n),st(i,e,n)},p:Ft,d(i){i&&(nt(t),nt(e))}}}function O2(r){let t,e=xe(r[0]),i=[];for(let n=0;n<e.length;n+=1)i[n]=Gm(Um(r,e,n));return{c(){t=et("g");for(let n=0;n<i.length;n+=1)i[n].c()},m(n,s){st(n,t,s);for(let o=0;o<i.length;o+=1)i[o]&&i[o].m(t,null)},p(n,[s]){if(s&1){e=xe(n[0]);let o;for(o=0;o<e.length;o+=1){const a=Um(n,e,o);i[o]?i[o].p(a,s):(i[o]=Gm(a),i[o].c(),i[o].m(t,null))}for(;o<i.length;o+=1)i[o].d(1);i.length=e.length}},i:Ft,o:Ft,d(n){n&&nt(t),Dr(i,n)}}}function L2(r,t,e){let{annotation:i}=t;const{polygons:n}=i.target.selector.geometry;return r.$$set=s=>{"annotation"in s&&e(1,i=s.annotation)},[n,i]}class N2 extends jt{constructor(t){super(),zt(this,t,L2,O2,Ut,{annotation:1})}}function F2(r){let t,e;return{c(){t=et("polygon"),w(t,"points",e=r[0].points.map($m).join(" "))},m(i,n){st(i,t,n)},p(i,[n]){n&1&&e!==(e=i[0].points.map($m).join(" "))&&w(t,"points",e)},i:Ft,o:Ft,d(i){i&&nt(t)}}}const $m=r=>r.join(",");function k2(r,t,e){let i,{annotation:n}=t;return r.$$set=s=>{"annotation"in s&&e(1,n=s.annotation)},r.$$.update=()=>{r.$$.dirty&2&&e(0,i=n.target.selector.geometry)},[i,n]}class U2 extends jt{constructor(t){super(),zt(this,t,k2,F2,Ut,{annotation:1})}}function G2(r){let t;return{c(){t=et("path"),w(t,"d",r[0])},m(e,i){st(e,t,i)},p(e,[i]){i&1&&w(t,"d",e[0])},i:Ft,o:Ft,d(e){e&&nt(t)}}}function $2(r,t,e){let i,n,{annotation:s}=t;return r.$$set=o=>{"annotation"in o&&e(1,s=o.annotation)},r.$$.update=()=>{r.$$.dirty&2&&e(2,i=s.target.selector.geometry),r.$$.dirty&4&&e(0,n=Jo(i))},[n,s,i]}class H2 extends jt{constructor(t){super(),zt(this,t,$2,G2,Ut,{annotation:1})}}function X2(r){let t,e,i,n,s;return{c(){t=et("rect"),w(t,"x",e=r[0].x),w(t,"y",i=r[0].y),w(t,"width",n=r[0].w),w(t,"height",s=r[0].h)},m(o,a){st(o,t,a)},p(o,[a]){a&1&&e!==(e=o[0].x)&&w(t,"x",e),a&1&&i!==(i=o[0].y)&&w(t,"y",i),a&1&&n!==(n=o[0].w)&&w(t,"width",n),a&1&&s!==(s=o[0].h)&&w(t,"height",s)},i:Ft,o:Ft,d(o){o&&nt(t)}}}function V2(r,t,e){let i,{annotation:n}=t;return r.$$set=s=>{"annotation"in s&&e(1,n=s.annotation)},r.$$.update=()=>{r.$$.dirty&2&&e(0,i=n.target.selector.geometry)},[i,n]}class z2 extends jt{constructor(t){super(),zt(this,t,V2,X2,Ut,{annotation:1})}}const{Boolean:j2}=va;function Hm(r,t,e){const i=r.slice();return i[10]=t[e],i}function Xm(r){let t,e;return t=new Dh({props:{viewer:r[0],$$slots:{default:[Q2,({transform:i})=>({9:i}),({transform:i})=>i?512:0]},$$scope:{ctx:r}}}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n&1&&(s.viewer=i[0]),n&8710&&(s.$$scope={dirty:n,ctx:i}),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){ot(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function W2(r){let t,e;return t=new B2({props:{annotation:r[10]}}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n&2&&(s.annotation=i[10]),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){ot(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function Y2(r){let t,e;return t=new R2({props:{annotation:r[10]}}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n&2&&(s.annotation=i[10]),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){ot(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function q2(r){let t,e;return t=new H2({props:{annotation:r[10]}}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n&2&&(s.annotation=i[10]),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){ot(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function K2(r){let t,e;return t=new N2({props:{annotation:r[10]}}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n&2&&(s.annotation=i[10]),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){ot(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function Z2(r){let t,e;return t=new U2({props:{annotation:r[10]}}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n&2&&(s.annotation=i[10]),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){ot(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function J2(r){let t,e;return t=new z2({props:{annotation:r[10]}}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n&2&&(s.annotation=i[10]),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){ot(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function Vm(r){let t,e,i,n;const s=[J2,Z2,K2,q2,Y2,W2],o=[];function a(l,h){return l[10].target.selector.type===mt.RECTANGLE?0:l[10].target.selector.type===mt.POLYGON?1:l[10].target.selector.type===mt.MULTIPOLYGON?2:l[10].target.selector.type===mt.POLYLINE?3:l[10].target.selector.type===mt.ELLIPSE?4:l[10].target.selector.type===mt.LINE?5:-1}return~(t=a(r))&&(e=o[t]=s[t](r)),{c(){e&&e.c(),i=Pe()},m(l,h){~t&&o[t].m(l,h),st(l,i,h),n=!0},p(l,h){let c=t;t=a(l),t===c?~t&&o[t].p(l,h):(e&&(ne(),ot(o[c],1,1,()=>{o[c]=null}),se()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=s[t](l),e.c()),q(e,1),e.m(i.parentNode,i)):e=null)},i(l){n||(q(e),n=!0)},o(l){ot(e),n=!1},d(l){l&&nt(i),~t&&o[t].d(l)}}}function Q2(r){let t,e,i,n,s,o,a,l,h,c,u,d,p,f,m=xe(r[1].filter(r[6])),_=[];for(let y=0;y<m.length;y+=1)_[y]=Vm(Hm(r,m,y));const v=y=>ot(_[y],1,1,()=>{_[y]=null});return{c(){var y,g,b,C;t=et("svg"),e=et("g"),i=et("rect"),l=et("rect");for(let R=0;R<_.length;R+=1)_[R].c();w(i,"class","a9s-union-bg svelte-jwrce3"),w(i,"x",n=(y=r[2])==null?void 0:y.minX),w(i,"y",s=(g=r[2])==null?void 0:g.minY),w(i,"width",o=r[2]?r[2].maxX-r[2].minX:0),w(i,"height",a=r[2]?r[2].maxY-r[2].minY:0),w(l,"class","a9s-union-fg svelte-jwrce3"),w(l,"x",h=(b=r[2])==null?void 0:b.minX),w(l,"y",c=(C=r[2])==null?void 0:C.minY),w(l,"width",u=r[2]?r[2].maxX-r[2].minX:0),w(l,"height",d=r[2]?r[2].maxY-r[2].minY:0),w(e,"transform",p=r[9]),w(t,"class","a9s-osd-selectionlayer svelte-jwrce3")},m(y,g){st(y,t,g),At(t,e),At(e,i),At(e,l);for(let b=0;b<_.length;b+=1)_[b]&&_[b].m(e,null);f=!0},p(y,g){var b,C,R,A;if((!f||g&4&&n!==(n=(b=y[2])==null?void 0:b.minX))&&w(i,"x",n),(!f||g&4&&s!==(s=(C=y[2])==null?void 0:C.minY))&&w(i,"y",s),(!f||g&4&&o!==(o=y[2]?y[2].maxX-y[2].minX:0))&&w(i,"width",o),(!f||g&4&&a!==(a=y[2]?y[2].maxY-y[2].minY:0))&&w(i,"height",a),(!f||g&4&&h!==(h=(R=y[2])==null?void 0:R.minX))&&w(l,"x",h),(!f||g&4&&c!==(c=(A=y[2])==null?void 0:A.minY))&&w(l,"y",c),(!f||g&4&&u!==(u=y[2]?y[2].maxX-y[2].minX:0))&&w(l,"width",u),(!f||g&4&&d!==(d=y[2]?y[2].maxY-y[2].minY:0))&&w(l,"height",d),g&2){m=xe(y[1].filter(y[6]));let P;for(P=0;P<m.length;P+=1){const M=Hm(y,m,P);_[P]?(_[P].p(M,g),q(_[P],1)):(_[P]=Vm(M),_[P].c(),q(_[P],1),_[P].m(e,null))}for(ne(),P=m.length;P<_.length;P+=1)v(P);se()}(!f||g&512&&p!==(p=y[9]))&&w(e,"transform",p)},i(y){if(!f){for(let g=0;g<m.length;g+=1)q(_[g]);f=!0}},o(y){_=_.filter(j2);for(let g=0;g<_.length;g+=1)ot(_[g]);f=!1},d(y){y&&nt(t),Dr(_,y)}}}function tC(r){let t=!!r[2],e,i,n=t&&Xm(r);return{c(){n&&n.c(),e=Pe()},m(s,o){n&&n.m(s,o),st(s,e,o),i=!0},p(s,[o]){o&4&&(t=!!s[2]),t?n?(n.p(s,o),o&4&&q(n,1)):(n=Xm(s),n.c(),q(n,1),n.m(e.parentNode,e)):n&&(ne(),ot(n,1,1,()=>{n=null}),se())},i(s){i||(q(n),i=!0)},o(s){ot(n),i=!1},d(s){s&&nt(e),n&&n.d(s)}}}function eC(r,t,e){let i,n,s,{state:o}=t,{viewer:a}=t;const{store:l}=o,{selection:h}=o;vs(r,h,d=>e(5,s=d));const c=d=>{let p=-1/0,f=-1/0,m=1/0,_=1/0;for(let v of d.filter(y=>Le(y))){const{bounds:y}=v.target.selector.geometry;y.maxX>p&&(p=y.maxX),y.maxY>f&&(f=y.maxY),y.minX<m&&(m=y.minX),y.minY<_&&(_=y.minY)}return a.forceRedraw(),{maxX:p,maxY:f,minX:m,minY:_}},u=d=>Le(d);return r.$$set=d=>{"state"in d&&e(4,o=d.state),"viewer"in d&&e(0,a=d.viewer)},r.$$.update=()=>{r.$$.dirty&32&&e(1,i=s.selected.map(({id:d})=>l.getAnnotation(d))),r.$$.dirty&2&&e(2,n=i.length>1?c(i):void 0)},[a,i,n,h,o,s,u]}class rC extends jt{constructor(t){super(),zt(this,t,eC,tC,Ut,{state:4,viewer:0})}}const zm=(r,t)=>{t==="auto"?r.addHandler("open",e=>{const i=r.world.getItemCount();r.world.getItemAt(i-1).addOnceHandler("fully-loaded-change",s=>{const{fullyLoaded:o}=s;if(o){const a=r.canvas.querySelector("canvas"),l=eu(a);r.element.setAttribute("data-theme",l)}})}):r.element.setAttribute("data-theme",t)},jm=(r,t,e)=>(i,n={})=>{const s=typeof i=="string"?i:i.id,o=t.getAnnotation(s);if(!o||!Le(o))return;const a=r.container.getBoundingClientRect(),{padding:l}=n;let[h,c,u,d]=l?Array.isArray(l)?l:[l,l,l,l]:[0,0,0,0];h=h/a.height,c=c/a.width,u=u/a.height,d=d/a.width;const{minX:p,minY:f,maxX:m,maxY:_}=o.target.selector.geometry.bounds,v=m-p,y=_-f,g=p-d*v,b=f-h*y,C=v+(c+d)*v,R=y+(h+u)*y,A=r.viewport.imageToViewportRectangle(g,b,C,R);r.viewport[e](A,n.immediately)},iC=(r,t)=>jm(r,t,"fitBounds"),nC=(r,t)=>jm(r,t,"fitBoundsWithConstraints"),sC=(r,t={})=>{const e=iu(t,{drawingEnabled:!1,drawingMode:pr?"drag":"click",userSelectAction:Go.EDIT,theme:"light"}),i=tu(e),{hover:n,selection:s,store:o}=i,a=ug(o,e.initialHistory),l=dg(i,a,e.adapter,e.autoSave);let h=bg(),c=e.drawingEnabled,u=e.drawingMode,d=e.modalSelect;const p=su(a,r.element),f=new t2({target:r.element,props:{state:i,viewer:r,style:e.style,filter:void 0}}),m=new C2({target:r.element.querySelector(".openseadragon-canvas"),props:{provider:void 0,store:o,viewer:r}}),_=new d2({target:r.element.querySelector(".openseadragon-canvas"),props:{drawingEnabled:!!c,filter:void 0,multiSelect:e.multiSelect,preferredDrawingMode:u,state:i,style:e.style,user:h,viewer:r}}),v=new rC({target:r.element.querySelector(".openseadragon-canvas"),props:{state:i,viewer:r}});f.$on("click",O=>{const{originalEvent:$,annotation:F}=O.detail,X=V=>Sm(V.id,$,s,e.multiSelect);d?s.isEmpty()&&F&&s.userSelect(X(F),$):F&&!(u==="click"&&c)?s.userSelect(X(F),$):s.isEmpty()||s.clear()}),r.element.addEventListener("pointerdown",O=>{if(n.current){const $=o.getAnnotation(n.current);l.emit("clickAnnotation",$,O)}}),zm(r,e.theme);const y=pg(i,a,e.adapter),g=()=>_.cancelDrawing(),b=()=>{f.$destroy(),m.$destroy(),_.$destroy(),v.$destroy(),p.destroy(),a.destroy()},C=iC(r,o),R=nC(r,o),A=()=>_.getDrawingTool(),P=()=>h,M=()=>_.isDrawingEnabled(),k=(O,$,F)=>Uc(O,$,F),U=(O,$)=>Lc(O,$),I=O=>{if(!gs(O))throw`No drawing tool named ${O}`;_.$set({toolName:O})},T=O=>{c=O,_.$set({drawingEnabled:O})},E=O=>{f.$set({filter:O}),_.$set({filter:O})},S=O=>d=O,L=O=>{f.$set({style:O}),_.$set({style:O})},D=O=>m.$set({provider:O}),N=O=>zm(r,O),H=O=>{h=O,_.$set({user:O})},B=O=>f.$set({visible:O});return{...y,cancelDrawing:g,destroy:b,fitBounds:C,fitBoundsWithConstraints:R,getDrawingTool:A,getUser:P,isDrawingEnabled:M,listDrawingTools:ms,on:l.on,off:l.off,registerDrawingTool:k,registerShapeEditor:U,setDrawingEnabled:T,setDrawingTool:I,setFilter:E,setModalSelect:S,setPresenceProvider:D,setStyle:L,setTheme:N,setUser:H,setVisible:B,state:i,viewer:r}};Yt.ShapeType=mt,Yt.UserSelectAction=Go,Yt.W3CImageFormat=Wy,Yt.chainStyles=Fy,Yt.computeStyle=Ny,Yt.createBody=rg,Yt.createImageAnnotator=M_,Yt.createOSDAnnotator=sC,Yt.defaultColorProvider=wg,Object.defineProperty(Yt,Symbol.toStringTag,{value:"Module"})});
|
|
1147
|
+
}`,this._stylesheet)}get stylesheet(){return this._stylesheet}set stylesheet(t){this._stylesheet!==t&&(this._stylesheet=t,this.styleID++)}normalizeColor(t){return Array.isArray(t)&&(t=Pw(t)),typeof t=="number"?Iw(t):t}dropShadowToCSS(){let t=this.normalizeColor(this.dropShadowColor);const e=this.dropShadowAlpha,i=Math.round(Math.cos(this.dropShadowAngle)*this.dropShadowDistance),n=Math.round(Math.sin(this.dropShadowAngle)*this.dropShadowDistance);t.startsWith("#")&&e<1&&(t+=(e*255|0).toString(16).padStart(2,"0"));const s=`${i}px ${n}px`;return this.dropShadowBlur>0?`text-shadow: ${s} ${this.dropShadowBlur}px ${t}`:`text-shadow: ${s} ${t}`}reset(){Object.assign(this,pn.defaultOptions)}onBeforeDraw(){const{fontsDirty:t}=this;return this.fontsDirty=!1,this.isSafari&&this._fonts.length>0&&t?new Promise(e=>setTimeout(e,100)):Promise.resolve()}get isSafari(){const{userAgent:t}=J.ADAPTER.getNavigator();return/^((?!chrome|android).)*safari/i.test(t)}set fillGradientStops(t){console.warn("[HTMLTextStyle] fillGradientStops is not supported by HTMLText")}get fillGradientStops(){return super.fillGradientStops}set fillGradientType(t){console.warn("[HTMLTextStyle] fillGradientType is not supported by HTMLText")}get fillGradientType(){return super.fillGradientType}set miterLimit(t){console.warn("[HTMLTextStyle] miterLimit is not supported by HTMLText")}get miterLimit(){return super.miterLimit}set trim(t){console.warn("[HTMLTextStyle] trim is not supported by HTMLText")}get trim(){return super.trim}set textBaseline(t){console.warn("[HTMLTextStyle] textBaseline is not supported by HTMLText")}get textBaseline(){return super.textBaseline}set leading(t){console.warn("[HTMLTextStyle] leading is not supported by HTMLText")}get leading(){return super.leading}set lineJoin(t){console.warn("[HTMLTextStyle] lineJoin is not supported by HTMLText")}get lineJoin(){return super.lineJoin}};Ph.availableFonts={},Ph.defaultOptions={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",letterSpacing:0,lineHeight:0,padding:0,stroke:"black",strokeThickness:0,whiteSpace:"normal",wordWrap:!1,wordWrapWidth:100};let Rh=Ph;const Oo=class mn extends en{constructor(t="",e={}){super(ht.EMPTY),this._text=null,this._style=null,this._autoResolution=!0,this.localStyleID=-1,this.dirty=!1,this._updateID=0,this.ownsStyle=!1;const i=new Image,n=ht.from(i,{scaleMode:J.SCALE_MODE,resourceOptions:{autoLoad:!1}});n.orig=new xt,n.trim=new xt,this.texture=n;const s="http://www.w3.org/2000/svg",o="http://www.w3.org/1999/xhtml",a=document.createElementNS(s,"svg"),l=document.createElementNS(s,"foreignObject"),h=document.createElementNS(o,"div"),c=document.createElementNS(o,"style");l.setAttribute("width","10000"),l.setAttribute("height","10000"),l.style.overflow="hidden",a.appendChild(l),this.maxWidth=mn.defaultMaxWidth,this.maxHeight=mn.defaultMaxHeight,this._domElement=h,this._styleElement=c,this._svgRoot=a,this._foreignObject=l,this._foreignObject.appendChild(c),this._foreignObject.appendChild(h),this._image=i,this._loadImage=new Image,this._autoResolution=mn.defaultAutoResolution,this._resolution=mn.defaultResolution??J.RESOLUTION,this.text=t,this.style=e}measureText(t){var c,u;const{text:e,style:i,resolution:n}=Object.assign({text:this._text,style:this._style,resolution:this._resolution},t);Object.assign(this._domElement,{innerHTML:e,style:i.toCSS(n)}),this._styleElement.textContent=i.toGlobalCSS(),document.body.appendChild(this._svgRoot);const s=this._domElement.getBoundingClientRect();this._svgRoot.remove();const{width:o,height:a}=s;(o>this.maxWidth||a>this.maxHeight)&&console.warn("[HTMLText] Large expanse of text, increase HTMLText.maxWidth or HTMLText.maxHeight property.");const l=Math.min(this.maxWidth,Math.ceil(o)),h=Math.min(this.maxHeight,Math.ceil(a));return this._svgRoot.setAttribute("width",l.toString()),this._svgRoot.setAttribute("height",h.toString()),e!==this._text&&(this._domElement.innerHTML=this._text),i!==this._style&&(Object.assign(this._domElement,{style:(c=this._style)==null?void 0:c.toCSS(n)}),this._styleElement.textContent=(u=this._style)==null?void 0:u.toGlobalCSS()),{width:l+i.padding*2,height:h+i.padding*2}}async updateText(t=!0){const{style:e,_image:i,_loadImage:n}=this;if(this.localStyleID!==e.styleID&&(this.dirty=!0,this.localStyleID=e.styleID),!this.dirty&&t)return;const{width:s,height:o}=this.measureText();i.width=n.width=Math.ceil(Math.max(1,s)),i.height=n.height=Math.ceil(Math.max(1,o)),this._updateID++;const a=this._updateID;await new Promise(l=>{n.onload=async()=>{if(a<this._updateID){l();return}await e.onBeforeDraw(),i.src=n.src,n.onload=null,n.src="",this.updateTexture(),l()};const h=new XMLSerializer().serializeToString(this._svgRoot);n.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(h)}`})}get source(){return this._image}updateTexture(){const{style:t,texture:e,_image:i,resolution:n}=this,{padding:s}=t,{baseTexture:o}=e;e.trim.width=e._frame.width=i.width/n,e.trim.height=e._frame.height=i.height/n,e.trim.x=-s,e.trim.y=-s,e.orig.width=e._frame.width-s*2,e.orig.height=e._frame.height-s*2,this._onTextureUpdate(),o.setRealSize(i.width,i.height,n),this.dirty=!1}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._render(t)}_renderCanvas(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._renderCanvas(t)}getLocalBounds(t){return this.updateText(!0),super.getLocalBounds(t)}_calculateBounds(){this.updateText(!0),this.calculateVertices(),this._bounds.addQuad(this.vertexData)}_onStyleChange(){this.dirty=!0}destroy(t){var i,n,s,o,a;typeof t=="boolean"&&(t={children:t}),t=Object.assign({},mn.defaultDestroyOptions,t),super.destroy(t);const e=null;this.ownsStyle&&((i=this._style)==null||i.cleanFonts()),this._style=e,(n=this._svgRoot)==null||n.remove(),this._svgRoot=e,(s=this._domElement)==null||s.remove(),this._domElement=e,(o=this._foreignObject)==null||o.remove(),this._foreignObject=e,(a=this._styleElement)==null||a.remove(),this._styleElement=e,this._loadImage.src="",this._loadImage.onload=null,this._loadImage=e,this._image.src="",this._image=e}get width(){return this.updateText(!0),Math.abs(this.scale.x)*this._image.width/this.resolution}set width(t){this.updateText(!0);const e=kr(this.scale.x)||1;this.scale.x=e*t/this._image.width/this.resolution,this._width=t}get height(){return this.updateText(!0),Math.abs(this.scale.y)*this._image.height/this.resolution}set height(t){this.updateText(!0);const e=kr(this.scale.y)||1;this.scale.y=e*t/this._image.height/this.resolution,this._height=t}get style(){return this._style}set style(t){this._style!==t&&(t=t||{},t instanceof Rh?(this.ownsStyle=!1,this._style=t):t instanceof zr?(console.warn("[HTMLText] Cloning TextStyle, if this is not what you want, use HTMLTextStyle"),this.ownsStyle=!0,this._style=Rh.from(t)):(this.ownsStyle=!0,this._style=new Rh(t)),this.localStyleID=-1,this.dirty=!0)}get text(){return this._text}set text(t){t=String(t===""||t===null||t===void 0?" ":t),t=this.sanitiseText(t),this._text!==t&&(this._text=t,this.dirty=!0)}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}sanitiseText(t){return t.replace(/<br>/gi,"<br/>").replace(/<hr>/gi,"<hr/>").replace(/ /gi," ")}};Oo.defaultDestroyOptions={texture:!0,children:!1,baseTexture:!0},Oo.defaultMaxWidth=2024,Oo.defaultMaxHeight=2024,Oo.defaultAutoResolution=!0;const $S=16777215,HS=.25,XS=16777215,VS=1,zS=1.5;let Yr=!1,cn;const Mh=r=>{const t={tint:r!=null&&r.fill?new Mt(r.fill).toNumber():$S,alpha:(r==null?void 0:r.fillOpacity)!==void 0?Math.min(r.fillOpacity,1):String(r==null?void 0:r.fill).toLowerCase().startsWith("rgba(")?new Mt(r==null?void 0:r.fill).alpha:HS},e={tint:r!=null&&r.stroke?new Mt(r.stroke).toNumber():XS,alpha:(r==null?void 0:r.strokeOpacity)!==void 0?Math.min(r.strokeOpacity,1):String(r==null?void 0:r.stroke).toLowerCase().startsWith("rgba(")?new Mt(r==null?void 0:r.stroke).alpha:VS,lineWidth:(r==null?void 0:r.strokeWidth)===void 0?zS:r.strokeWidth};return{fillStyle:t,strokeStyle:e}},un=r=>(t,e,i,n={})=>{const{fillStyle:s,strokeStyle:o}=Mh(i),a=new Zn;n.strokeOnly||(a.beginFill(16777215),r(e,a),a.endFill(),a.tint=s.tint,a.alpha=s.alpha),t.addChild(a);const l=new Zn,h=o.lineWidth===1?1:o.lineWidth/cn;return l.lineStyle(h,16777215,1,.5,o.lineWidth===1),r(e,l),l.tint=o.tint||16777215,l.alpha=o.alpha,t.addChild(l),{fill:a,stroke:l,strokeWidth:o.lineWidth}},jS=un((r,t)=>{const{x:e,y:i,w:n,h:s}=r.geometry;t.drawRect(e,i,n,s)}),WS=un((r,t)=>{const{cx:e,cy:i,rx:n,ry:s}=r.geometry;t.drawEllipse(e,i,n,s)}),YS=un((r,t)=>{const[[e,i],[n,s]]=r.geometry.points;t.moveTo(e,i),t.lineTo(n,s),t.closePath()}),qS=un((r,t)=>{const e=r.geometry.points.reduce((i,n)=>[...i,...n],[]);t.drawPolygon(e)}),KS=un((r,t)=>{const{points:e,closed:i}=r.geometry;if(e.length===0)return;i||t.beginFill(0,0);const n=(o,a)=>{const[l,h]=o.point,[c,u]=a.point;if(o.type==="CURVE"||a.type==="CURVE"){const d=o.type==="CURVE"&&o.outHandle?o.outHandle[0]:l,p=o.type==="CURVE"&&o.outHandle?o.outHandle[1]:h,f=a.type==="CURVE"&&a.inHandle?a.inHandle[0]:c,m=a.type==="CURVE"&&a.inHandle?a.inHandle[1]:u;t.bezierCurveTo(d,p,f,m,c,u)}else t.lineTo(c,u)},s=e[0];t.moveTo(s.point[0],s.point[1]);for(let o=1;o<e.length;o++){const a=e[o-1],l=e[o];n(a,l)}if(i&&e.length>2){const o=e[e.length-1],a=e[0];n(o,a),t.closePath()}else t.endFill()}),ZS=un((r,t)=>{const e=i=>i.points.reduce((n,s)=>[...n,...s],[]);r.geometry.polygons.forEach(i=>{const[n,...s]=i.rings;t.drawPolygon(e(n)),s.forEach(o=>{t.beginHole(),t.drawPolygon(e(o)),t.endHole()})})}),Tm=r=>{const t=r.viewport.getContainerSize().x;return r.viewport.getZoom(!0)*t/r.world.getContentFactor()},Am=(r,t,e,i)=>()=>{const n=r.viewport.viewportToImageRectangle(r.viewport.getBounds(!0)),s=Tm(r);(s!==cn||!Yr)&&(Yr=!0,e.forEach(({stroke:d,strokeWidth:p})=>{const{lineStyle:f}=d.geometry.graphicsData[0];p>1?(Yr=s===cn,f.width=p/s,f.native=!1,d.geometry.invalidate()):p===1&&!f.native&&(f.width=1,f.native=!0,d.geometry.invalidate())})),cn=s;const o=r.viewport.getFlip();let a=Math.PI*r.viewport.getRotation(!0)/180;a<0&&(a+=2*Math.PI),a>2*Math.PI&&(a-=2*Math.PI);const l=o?r.viewport._containerInnerSize.x+n.x*s:-n.x*s,h=-n.y*s;let c,u;a>0&&a<=Math.PI/2?(c=n.height*s,u=0):a>Math.PI/2&&a<=Math.PI?(c=n.width*s,u=n.height*s):a>Math.PI&&a<=Math.PI*1.5?(c=0,u=n.width*s):(c=0,u=0),t.position.x=c+l*Math.cos(a)-h*Math.sin(a),t.position.y=u+l*Math.sin(a)+h*Math.cos(a),t.scale.set(o?-s:s,s),t.rotation=a,i.render(t)},JS=(r,t)=>{const e=new Zn,i=xp({width:t.width,height:t.height,backgroundAlpha:0,view:t,antialias:!0,resolution:2}),n=new Map;let s=new Set,o,a;cn=Tm(r);const l=(g,b)=>{Yr=!1;const C=n.get(g.id);C&&(C.fill.destroy(),C.stroke.destroy());const{selector:R}=g.target,A=typeof a=="function"?a(g,b):a;let P;if(R.type===mt.RECTANGLE)P=jS(e,R,A);else if(R.type===mt.POLYGON)P=qS(e,R,A);else if(R.type===mt.ELLIPSE)P=WS(e,R,A);else if(R.type===mt.MULTIPOLYGON)P=ZS(e,R,A);else if(R.type===mt.POLYLINE){const M=R;P=KS(e,M,A,{strokeOnly:!M.geometry.closed})}else R.type===mt.LINE?P=YS(e,R,A):console.warn(`Unsupported shape type: ${R.type}`);P&&n.set(g.id,{annotation:g,...P})},h=g=>{const b=n.get(g.id);b&&(n.delete(g.id),b.fill.destroy(),b.stroke.destroy())},c=(g,b,C)=>{Yr=!1;const R=n.get(g.id);if(R&&(n.delete(g.id),R.fill.destroy(),R.stroke.destroy(),l(b,C),s.has(b.id))){const{fill:A,stroke:P}=n.get(b.id);e.removeChild(A),e.removeChild(P)}},u=(g,b)=>{const C=n.get(g);C&&(n.delete(g),C.fill.destroy(),C.stroke.destroy(),l(C.annotation,b))},d=(g,b)=>{i.resize(g,b),i.render(e)},p=g=>{Yr=!1;const{children:b}=e;n.forEach(({fill:C,stroke:R,annotation:A})=>{const P=g?s.has(A.id)||g(A):!0;P&&!b.includes(C)?(e.addChild(C),e.addChild(R)):!P&&b.includes(C)&&(e.removeChild(C),e.removeChild(R))}),i.render(e)},f=g=>{const b=new Set(g.selected.map(A=>A.id)),C=g.selected.filter(({id:A})=>!s.has(A)),R=[...s].filter(A=>!b.has(A));C.forEach(({id:A,editable:P})=>{if(P){const M=n.get(A);M&&da(M.annotation.target.selector)&&(e.removeChild(M.fill),e.removeChild(M.stroke))}else u(A,{selected:!0,hovered:A===o})}),R.forEach(A=>u(A,{hovered:A===o})),s=b,i.render(e)},m=g=>{o!==g&&(g&&s.has(g)||(o&&!s.has(o)&&u(o,{selected:s.has(o)}),g&&u(g,{selected:s.has(g),hovered:!0}),o=g,i.render(e)))},_=g=>{if(typeof g=="function")n.forEach(({annotation:b,fill:C,stroke:R,strokeWidth:A},P)=>{A>1&&(Yr=!1);const M={selected:s.has(b.id),hovered:o===b.id},{fillStyle:k,strokeStyle:U}=Mh(g(b,M));C.tint=k.tint,C.alpha=k.alpha,R.tint=U.tint||16777215,R.alpha=U.alpha,n.set(b.id,{annotation:b,fill:C,stroke:R,strokeWidth:U.lineWidth})});else{const{fillStyle:b,strokeStyle:C}=Mh(g);C.lineWidth>1&&(Yr=!1),n.forEach(({annotation:R,fill:A,stroke:P,strokeWidth:M},k)=>{A.tint=b.tint,A.alpha=b.alpha,P.tint=C.tint||16777215,P.alpha=C.alpha,n.set(R.id,{annotation:R,fill:A,stroke:P,strokeWidth:C.lineWidth})})}a=g,i.render(e),Am(r,e,n,i)()},v=g=>{g?t.classList.remove("hidden"):t.classList.add("hidden")};return{addAnnotation:l,destroy:()=>i.destroy(),getScale:()=>cn,redraw:Am(r,e,n,i),removeAnnotation:h,resize:d,setFilter:p,setHovered:m,setSelected:f,setStyle:_,setVisible:v,updateAnnotation:c}};function QS(r,t,e){let i,n,{filter:s}=t,{state:o}=t,{style:a}=t,{viewer:l}=t,{visible:h=!0}=t;const{store:c,hover:u,selection:d,viewport:p}=o;vs(r,u,A=>e(11,i=A)),vs(r,d,A=>e(8,n=A));const f=Di();let m,_;const v=A=>{const P=new ce.Point(A.x,A.y),{x:M,y:k}=l.viewport.pointFromPixel(P);return l.viewport.viewportToImageCoordinates(M,k)},y=()=>2/m.getScale(),g=A=>{const{x:P,y:M}=A.position;_={x:P,y:M}},b=A=>P=>{const{x:M,y:k}=v(new ce.Point(P.offsetX,P.offsetY)),U=y(),I=c.getAt(M,k,s,U);I?(A.classList.add("hover"),i!==I.id&&(u.set(I.id),m.setHovered(I.id))):(A.classList.remove("hover"),i&&(u.set(void 0),m.setHovered(void 0)))},C=A=>{if(!_)return;const P=A.originalEvent,{x:M,y:k}=A.position,U=M-_.x,I=k-_.y;if(Math.sqrt(U*U+I*I)<5){const{x:E,y:S}=v(A.position),L=y(),D=c.getAt(E,S,s,L);D?f("click",{originalEvent:P,annotation:D}):f("click",{originalEvent:P})}_=void 0};let R;return ei(()=>{var D;const{offsetWidth:A,offsetHeight:P}=l.canvas,M=document.createElement("canvas");M.width=A,M.height=P,M.className="a9s-gl-canvas",(D=l.element.querySelector(".openseadragon-canvas"))==null||D.appendChild(M),e(7,m=JS(l,M));const k=b(M);M.addEventListener("pointermove",k);const U=new ResizeObserver(N=>{try{const{width:H,height:B}=N[0].contentRect;M.width=H,M.height=B,m.resize(H,B)}catch{console.warn("WebGL canvas already disposed")}});U.observe(M);const I=()=>{const N=l.viewport.getBounds();R=l.viewport.viewportToImageRectangle(N);const{x:H,y:B,width:O,height:$}=R,F=c.getIntersecting(H,B,O,$);p.set(F.map(X=>X.id))};l.addHandler("canvas-press",g),l.addHandler("canvas-release",C),l.addHandler("update-viewport",m.redraw),l.addHandler("animation-finish",I);const T=N=>N.filter(H=>Le(H)),E=N=>Le(N.oldValue)&&Le(N.newValue),S=N=>{const{selector:H}=N.target;if(H.type===mt.POLYGON){const B=Q_(H);return{...N,target:{...N.target,selector:{...B}}}}else if(H.type===mt.MULTIPOLYGON){const B=Z_(H);return{...N,target:{...N.target,selector:{...B}}}}else return N},L=N=>{const{created:H,updated:B,deleted:O}=N.changes,$=(H||[]).filter(F=>Le(F)).map(S);if(T(O||[]).forEach(F=>m.removeAnnotation(F)),$.forEach(F=>m.addAnnotation(F)),(B||[]).filter(F=>E(F)).map(({oldValue:F,newValue:X})=>({oldValue:F,newValue:S(X)})).forEach(({oldValue:F,newValue:X})=>m.updateAnnotation(F,X)),R){const{x:F,y:X,width:V,height:dt}=R,yt=c.getIntersecting(F,X,V,dt);p.set(yt.map(z=>z.id))}else p.set(c.all().map(F=>F.id));m.redraw()};return c.observe(L),()=>{var N;M.removeEventListener("pointermove",k),U.disconnect(),l.removeHandler("canvas-press",g),l.removeHandler("canvas-release",C),l.removeHandler("update-viewport",m.redraw),l.removeHandler("animation-finish",I),c.unobserve(L),m.destroy(),(N=M.parentNode)==null||N.removeChild(M)}}),r.$$set=A=>{"filter"in A&&e(2,s=A.filter),"state"in A&&e(3,o=A.state),"style"in A&&e(4,a=A.style),"viewer"in A&&e(5,l=A.viewer),"visible"in A&&e(6,h=A.visible)},r.$$.update=()=>{r.$$.dirty&132&&(m==null||m.setFilter(s)),r.$$.dirty&384&&(m==null||m.setSelected(n)),r.$$.dirty&144&&(m==null||m.setStyle(a)),r.$$.dirty&192&&(m==null||m.setVisible(h))},[u,d,s,o,a,l,h,m,n]}class t2 extends jt{constructor(t){super(),zt(this,t,QS,null,Ut,{filter:2,state:3,style:4,viewer:5,visible:6})}}const Sm=(r,t,e,i)=>{if(!i)return r;if(t.shiftKey||t.ctrlKey||t.metaKey){const s=(e.selected||[]).map(o=>o.id);return s.includes(r)?s.filter(o=>o!==r):[...s,r]}else return r},e2=r=>({transform:r&2,scale:r&1}),Cm=r=>({transform:r[1],scale:r[0]});function r2(r){let t;const e=r[4].default,i=lu(e,r,r[3],Cm);return{c(){i&&i.c()},m(n,s){i&&i.m(n,s),t=!0},p(n,[s]){i&&i.p&&(!t||s&11)&&uu(i,e,n,n[3],t?cu(e,n[3],s,e2):du(n[3]),Cm)},i(n){t||(q(i,n),t=!0)},o(n){ot(i,n),t=!1},d(n){i&&i.d(n)}}}function i2(r,t,e){let{$$slots:i={},$$scope:n}=t,{viewer:s}=t,o=1,a;const l=()=>{const h=s.viewport.getContainerSize().x,c=s.viewport.getZoom(!0),u=s.viewport.getFlip(),d=s.viewport.pixelFromPoint(new ce.Point(0,0),!0);u&&(d.x=h-d.x);const p=c*h/s.world.getContentFactor(),f=u?-p:p,m=s.viewport.getRotation(!0);e(1,a=`translate(${d.x}, ${d.y}) scale(${f}, ${p}) rotate(${m})`),e(0,o=c*h/s.world.getContentFactor())};return ei(()=>(s.addHandler("update-viewport",l),()=>{s.removeHandler("update-viewport",l)})),r.$$set=h=>{"viewer"in h&&e(2,s=h.viewer),"$$scope"in h&&e(3,n=h.$$scope)},[o,a,s,n,i]}class Dh extends jt{constructor(t){super(),zt(this,t,i2,r2,Ut,{viewer:2})}}function n2(r,t,e){const i=Di();let{drawingMode:n}=t,{opts:s}=t,{target:o}=t,{tool:a}=t,{transform:l}=t,{viewer:h}=t,{viewportScale:c}=t,u;return ei(()=>{const d=o.closest("svg"),p=[],f=(m,_,v)=>{if(d==null||d.addEventListener(m,_,v),p.push(()=>d==null?void 0:d.removeEventListener(m,_,v)),m==="pointerup"||m==="dblclick"){const y=b=>{const{originalEvent:C}=b;_(C)},g=m==="pointerup"?"canvas-click":"canvas-double-click";h.addHandler(g,y),p.push(()=>h.removeHandler(g,y))}else if(m==="pointermove"){const y=g=>{const{originalEvent:b}=g;_(b)};h.addHandler("canvas-drag",y),p.push(()=>h.removeHandler("canvas-drag",y))}};return e(7,u=new a({target:o,props:{addEventListener:f,drawingMode:n,opts:s,transform:l,viewportScale:c,svgEl:d}})),u.$on("create",m=>i("create",m.detail)),()=>{p.forEach(m=>m()),u.$destroy()}}),r.$$set=d=>{"drawingMode"in d&&e(0,n=d.drawingMode),"opts"in d&&e(1,s=d.opts),"target"in d&&e(2,o=d.target),"tool"in d&&e(3,a=d.tool),"transform"in d&&e(4,l=d.transform),"viewer"in d&&e(5,h=d.viewer),"viewportScale"in d&&e(6,c=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&144&&u&&u.$set({transform:l}),r.$$.dirty&192&&u&&u.$set({viewportScale:c})},[n,s,o,a,l,h,c,u]}class s2 extends jt{constructor(t){super(),zt(this,t,n2,null,Ut,{drawingMode:0,opts:1,target:2,tool:3,transform:4,viewer:5,viewportScale:6})}}const{Boolean:o2}=va;function Im(r,t,e){const i=r.slice();i[38]=t[e];const n=i[17](i[38].target.selector);return i[39]=n,i}function a2(r){let t=`${r[2]}-${r[7]}`,e,i,n=Pm(r);return{c(){n.c(),e=Pe()},m(s,o){n.m(s,o),st(s,e,o),i=!0},p(s,o){o[0]&132&&Ut(t,t=`${s[2]}-${s[7]}`)?(ne(),ot(n,1,1,Ft),se(),n=Pm(s),n.c(),q(n,1),n.m(e.parentNode,e)):n.p(s,o)},i(s){i||(q(n),i=!0)},o(s){ot(n),i=!1},d(s){s&&nt(e),n.d(s)}}}function l2(r){let t,e,i=xe(r[9].filter(r[27])),n=[];for(let o=0;o<i.length;o+=1)n[o]=Dm(Im(r,i,o));const s=o=>ot(n[o],1,1,()=>{n[o]=null});return{c(){for(let o=0;o<n.length;o+=1)n[o].c();t=Pe()},m(o,a){for(let l=0;l<n.length;l+=1)n[l]&&n[l].m(o,a);st(o,t,a),e=!0},p(o,a){if(a[0]&193282|a[1]&64){i=xe(o[9].filter(o[27]));let l;for(l=0;l<i.length;l+=1){const h=Im(o,i,l);n[l]?(n[l].p(h,a),q(n[l],1)):(n[l]=Dm(h),n[l].c(),q(n[l],1),n[l].m(t.parentNode,t))}for(ne(),l=i.length;l<n.length;l+=1)s(l);se()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)q(n[a]);e=!0}},o(o){n=n.filter(o2);for(let a=0;a<n.length;a+=1)ot(n[a]);e=!1},d(o){o&&nt(t),Dr(n,o)}}}function Pm(r){let t,e;return t=new s2({props:{target:r[8],tool:r[10],drawingMode:r[4],transform:{elementToImage:r[12]},viewer:r[3],viewportScale:r[37],opts:r[5]}}),t.$on("create",r[16]),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n[0]&256&&(s.target=i[8]),n[0]&1024&&(s.tool=i[10]),n[0]&16&&(s.drawingMode=i[4]),n[0]&8&&(s.viewer=i[3]),n[1]&64&&(s.viewportScale=i[37]),n[0]&32&&(s.opts=i[5]),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){ot(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function Rm(r){let t=r[38].id,e,i,n=Mm(r);return{c(){n.c(),e=Pe()},m(s,o){n.m(s,o),st(s,e,o),i=!0},p(s,o){o[0]&512&&Ut(t,t=s[38].id)?(ne(),ot(n,1,1,Ft),se(),n=Mm(s),n.c(),q(n,1),n.m(e.parentNode,e)):n.p(s,o)},i(s){i||(q(n),i=!0)},o(s){ot(n),i=!1},d(s){s&&nt(e),n.d(s)}}}function Mm(r){let t,e;return t=new Uv({props:{target:r[8],editor:r[17](r[38].target.selector),annotation:r[38],style:r[1],transform:{elementToImage:r[12]},viewportScale:r[37]}}),t.$on("grab",r[13]),t.$on("change",function(){Kt(r[15](r[38]))&&r[15](r[38]).apply(this,arguments)}),t.$on("release",r[14]),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){r=i;const s={};n[0]&256&&(s.target=r[8]),n[0]&512&&(s.editor=r[17](r[38].target.selector)),n[0]&512&&(s.annotation=r[38]),n[0]&2&&(s.style=r[1]),n[1]&64&&(s.viewportScale=r[37]),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){ot(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function Dm(r){let t,e,i=r[39]&&Rm(r);return{c(){i&&i.c(),t=Pe()},m(n,s){i&&i.m(n,s),st(n,t,s),e=!0},p(n,s){n[39]?i?(i.p(n,s),s[0]&512&&q(i,1)):(i=Rm(n),i.c(),q(i,1),i.m(t.parentNode,t)):i&&(ne(),ot(i,1,1,()=>{i=null}),se())},i(n){e||(q(i),e=!0)},o(n){ot(i),e=!1},d(n){n&&nt(t),i&&i.d(n)}}}function h2(r){let t,e,i,n,s,o;const a=[l2,a2],l=[];function h(c,u){var d;return c[8]&&((d=c[9])==null?void 0:d.length)===1?0:c[8]&&c[10]&&c[0]?1:-1}return~(i=h(r))&&(n=l[i]=a[i](r)),{c(){t=et("svg"),e=et("g"),n&&n.c(),w(e,"transform",s=r[36]),w(e,"class","svelte-g4ws1v"),w(t,"tabindex",0),w(t,"class","a9s-annotationlayer a9s-osd-drawinglayer svelte-g4ws1v"),Br(t,"drawing",r[0]),Br(t,"editing",r[9]),Br(t,"hover",r[6])},m(c,u){st(c,t,u),At(t,e),~i&&l[i].m(e,null),r[28](e),o=!0},p(c,u){let d=i;i=h(c),i===d?~i&&l[i].p(c,u):(n&&(ne(),ot(l[d],1,1,()=>{l[d]=null}),se()),~i?(n=l[i],n?n.p(c,u):(n=l[i]=a[i](c),n.c()),q(n,1),n.m(e,null)):n=null),(!o||u[1]&32&&s!==(s=c[36]))&&w(e,"transform",s),(!o||u[0]&1)&&Br(t,"drawing",c[0]),(!o||u[0]&512)&&Br(t,"editing",c[9]),(!o||u[0]&64)&&Br(t,"hover",c[6])},i(c){o||(q(n),o=!0)},o(c){ot(n),o=!1},d(c){c&&nt(t),~i&&l[i].d(),r[28](null)}}}function c2(r){let t,e;return t=new Dh({props:{viewer:r[3],$$slots:{default:[h2,({transform:i,scale:n})=>({36:i,37:n}),({transform:i,scale:n})=>[0,(i?32:0)|(n?64:0)]]},$$scope:{ctx:r}}}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n[0]&8&&(s.viewer=i[3]),n[0]&2047|n[1]&2144&&(s.$$scope={dirty:n,ctx:i}),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){ot(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function u2(r,t,e){let i,n,s,o,{drawingEnabled:a}=t,{filter:l}=t,{multiSelect:h}=t,{preferredDrawingMode:c}=t,{state:u}=t,{style:d=void 0}=t,{toolName:p=ms()[0]}=t,{user:f}=t,{viewer:m}=t,_=!1,v=0;const y=()=>e(7,v+=1),g=()=>p,b=()=>a;let C;const{store:R,selection:A,hover:P}=u;vs(r,A,F=>e(26,o=F));let M,k,U;const I=F=>{R.unobserve(M);const X=F.filter(({editable:V})=>V).map(({id:V})=>V);X.length>0?(e(9,k=X.map(V=>R.getAnnotation(V))),M=V=>{const{updated:dt}=V.changes;e(9,k=(dt||[]).map(yt=>yt.newValue))},R.observe(M,{annotations:X}),m.forceRedraw()):e(9,k=void 0)},T=(F,X)=>{const{x:V,y:dt}=m.viewport.viewerElementToImageCoordinates(new ce.Point(F,X));return[V,dt]},E=()=>{const F=m.viewport.getContainerSize().x;return m.viewport.getZoom(!0)*F/m.world.getContentFactor()},S=()=>2/E(),L=F=>{m.setMouseNavEnabled(!1),U=F.timeStamp},D=F=>{if(m.setMouseNavEnabled(!0),performance.now()-(U||0)<300){const{offsetX:V,offsetY:dt}=F.detail,[yt,z]=T(V,dt),wt=S(),it=R.getAt(yt,z,void 0,wt);if(it&&(!l||l(it))&&!k.find(_t=>_t.id===it.id)){P.set(it.id);const _t=Sm(it.id,F.detail,A,h);A.userSelect(_t)}}},N=F=>X=>{var z;const{target:V}=F,dt=10*60*1e3,yt=((z=V.creator)==null?void 0:z.id)!==f.id||!V.created||new Date().getTime()-V.created.getTime()>dt;R.updateTarget({...V,selector:X.detail,created:yt?V.created:new Date,updated:yt?new Date:void 0,updatedBy:yt?f:void 0})},H=F=>{const X=ov(),V={id:X,bodies:[],target:{annotation:X,selector:F.detail,creator:f,created:new Date}};R.addAnnotation(V),A.setSelected(V.id),m.setMouseNavEnabled(!0)},B=F=>da(F);ei(()=>{const F=X=>{if(o.selected.length===0)return;const{offsetX:V,offsetY:dt}=X,yt=m.viewport.pointFromPixel(new ce.Point(V,dt)),{x:z,y:wt}=m.viewport.viewportToImageCoordinates(yt.x,yt.y),it=S();e(6,_=!!R.getAt(z,wt,l,it))};return m.element.addEventListener("pointermove",F),()=>{var X;(X=m.element)==null||X.removeEventListener("pointermove",F)}});const O=F=>Le(F);function $(F){bs[F?"unshift":"push"](()=>{C=F,e(8,C)})}return r.$$set=F=>{"drawingEnabled"in F&&e(0,a=F.drawingEnabled),"filter"in F&&e(18,l=F.filter),"multiSelect"in F&&e(19,h=F.multiSelect),"preferredDrawingMode"in F&&e(20,c=F.preferredDrawingMode),"state"in F&&e(21,u=F.state),"style"in F&&e(1,d=F.style),"toolName"in F&&e(2,p=F.toolName),"user"in F&&e(22,f=F.user),"viewer"in F&&e(3,m=F.viewer)},r.$$.update=()=>{r.$$.dirty[0]&4&&e(10,{tool:i,opts:n}=gs(p)||{tool:void 0,opts:void 0},i,(e(5,n),e(2,p))),r.$$.dirty[0]&1048608&&e(4,s=(n==null?void 0:n.drawingMode)||c),r.$$.dirty[0]&25&&(a&&s==="drag"?m.setMouseNavEnabled(!1):m.setMouseNavEnabled(!0)),r.$$.dirty[0]&1&&a&&A.clear(),r.$$.dirty[0]&67108889&&o.selected.length===0&&s==="drag"&&a&&m.setMouseNavEnabled(!1),r.$$.dirty[0]&67108864&&I(o.selected)},[a,d,p,m,s,n,_,v,C,k,i,A,T,L,D,N,H,B,l,h,c,u,f,y,g,b,o,O,$]}class d2 extends jt{constructor(t){super(),zt(this,t,u2,c2,Ut,{drawingEnabled:0,filter:18,multiSelect:19,preferredDrawingMode:20,state:21,style:1,toolName:2,user:22,viewer:3,cancelDrawing:23,getDrawingTool:24,isDrawingEnabled:25},null,[-1,-1])}get cancelDrawing(){return this.$$.ctx[23]}get getDrawingTool(){return this.$$.ctx[24]}get isDrawingEnabled(){return this.$$.ctx[25]}}function f2(r){let t,e,i,n,s,o,a,l=r[2].appearance.label+"",h,c,u,d;return{c(){t=et("g"),e=et("rect"),a=et("text"),h=ba(l),w(e,"class","a9s-presence-label-bg svelte-1rehw2p"),w(e,"x",r[0]),w(e,"y",i=r[1]-18/r[3]),w(e,"height",n=18/r[3]),w(e,"fill",s=r[2].appearance.color),w(e,"stroke",o=r[2].appearance.color),w(a,"font-size",c=12/r[3]),w(a,"x",u=r[0]+Math.round(5/r[3])),w(a,"y",d=r[1]-5/r[3]),w(a,"class","svelte-1rehw2p"),w(t,"class","a9s-presence-label")},m(p,f){st(p,t,f),At(t,e),At(t,a),At(a,h),r[6](t)},p(p,[f]){f&1&&w(e,"x",p[0]),f&10&&i!==(i=p[1]-18/p[3])&&w(e,"y",i),f&8&&n!==(n=18/p[3])&&w(e,"height",n),f&4&&s!==(s=p[2].appearance.color)&&w(e,"fill",s),f&4&&o!==(o=p[2].appearance.color)&&w(e,"stroke",o),f&4&&l!==(l=p[2].appearance.label+"")&&L_(h,l),f&8&&c!==(c=12/p[3])&&w(a,"font-size",c),f&9&&u!==(u=p[0]+Math.round(5/p[3]))&&w(a,"x",u),f&10&&d!==(d=p[1]-5/p[3])&&w(a,"y",d)},i:Ft,o:Ft,d(p){p&&nt(t),r[6](null)}}}function p2(r,t,e){let{x:i}=t,{y:n}=t,{user:s}=t,{scale:o}=t,{hAlign:a=null}=t,l;const h=u=>{const d=l.querySelector("text"),p=l.querySelector("rect"),f=d.getBBox().width+10/u;a==="CENTER"&&l.setAttribute("style",`transform: translateX(-${f/2}px)`),p.setAttribute("width",`${f}`)};function c(u){bs[u?"unshift":"push"](()=>{l=u,e(4,l)})}return r.$$set=u=>{"x"in u&&e(0,i=u.x),"y"in u&&e(1,n=u.y),"user"in u&&e(2,s=u.user),"scale"in u&&e(3,o=u.scale),"hAlign"in u&&e(5,a=u.hAlign)},r.$$.update=()=>{r.$$.dirty&24&&l&&h(o)},[i,n,s,o,l,a,c]}class Bm extends jt{constructor(t){super(),zt(this,t,p2,f2,Ut,{x:0,y:1,user:2,scale:3,hAlign:5})}}function m2(r){let t,e,i,n,s,o;return e=new Bm({props:{scale:r[1],user:r[0],x:r[3][0],y:r[3][1],hAlign:"CENTER"}}),{c(){t=et("g"),Lt(e.$$.fragment),i=et("polygon"),w(i,"class","a9s-presence-shape a9s-presence-polygon svelte-fgq4n0"),w(i,"stroke",n=r[0].appearance.color),w(i,"fill","transparent"),w(i,"points",s=r[2].points.map(Om).join(" ")),w(t,"class","a9s-presence-overlay")},m(a,l){st(a,t,l),Bt(e,t,null),At(t,i),o=!0},p(a,[l]){const h={};l&2&&(h.scale=a[1]),l&1&&(h.user=a[0]),l&8&&(h.x=a[3][0]),l&8&&(h.y=a[3][1]),e.$set(h),(!o||l&1&&n!==(n=a[0].appearance.color))&&w(i,"stroke",n),(!o||l&4&&s!==(s=a[2].points.map(Om).join(" ")))&&w(i,"points",s)},i(a){o||(q(e.$$.fragment,a),o=!0)},o(a){ot(e.$$.fragment,a),o=!1},d(a){a&&nt(t),Ot(e)}}}const Om=r=>r.join(",");function g2(r,t,e){let i,n,{annotation:s}=t,{user:o}=t,{scale:a}=t;const l=h=>{let[c,...u]=h.points;return u.forEach(([d,p])=>{p<c[1]&&(c=[d,p])}),c};return r.$$set=h=>{"annotation"in h&&e(4,s=h.annotation),"user"in h&&e(0,o=h.user),"scale"in h&&e(1,a=h.scale)},r.$$.update=()=>{r.$$.dirty&16&&e(2,i=s.target.selector.geometry),r.$$.dirty&4&&e(3,n=l(i))},[o,a,i,n,s]}class y2 extends jt{constructor(t){super(),zt(this,t,g2,m2,Ut,{annotation:4,user:0,scale:1})}}function _2(r){let t,e,i,n,s,o,a,l,h;return e=new Bm({props:{scale:r[1],user:r[0],x:r[2].x,y:r[2].y}}),{c(){t=et("g"),Lt(e.$$.fragment),i=et("rect"),w(i,"class","a9s-presence-shape a9s-presence-rectangle svelte-gze948"),w(i,"stroke",n=r[0].appearance.color),w(i,"fill","transparent"),w(i,"x",s=r[2].x),w(i,"y",o=r[2].y),w(i,"width",a=r[2].w),w(i,"height",l=r[2].h),w(t,"class","a9s-presence-overlay")},m(c,u){st(c,t,u),Bt(e,t,null),At(t,i),h=!0},p(c,[u]){const d={};u&2&&(d.scale=c[1]),u&1&&(d.user=c[0]),u&4&&(d.x=c[2].x),u&4&&(d.y=c[2].y),e.$set(d),(!h||u&1&&n!==(n=c[0].appearance.color))&&w(i,"stroke",n),(!h||u&4&&s!==(s=c[2].x))&&w(i,"x",s),(!h||u&4&&o!==(o=c[2].y))&&w(i,"y",o),(!h||u&4&&a!==(a=c[2].w))&&w(i,"width",a),(!h||u&4&&l!==(l=c[2].h))&&w(i,"height",l)},i(c){h||(q(e.$$.fragment,c),h=!0)},o(c){ot(e.$$.fragment,c),h=!1},d(c){c&&nt(t),Ot(e)}}}function v2(r,t,e){let i,{annotation:n}=t,{user:s}=t,{scale:o}=t;return r.$$set=a=>{"annotation"in a&&e(3,n=a.annotation),"user"in a&&e(0,s=a.user),"scale"in a&&e(1,o=a.scale)},r.$$.update=()=>{r.$$.dirty&8&&e(2,i=n.target.selector.geometry)},[s,o,i,n]}class b2 extends jt{constructor(t){super(),zt(this,t,v2,_2,Ut,{annotation:3,user:0,scale:1})}}const{Boolean:x2}=va;function Lm(r,t,e){const i=r.slice();return i[8]=t[e],i}function Nm(r){let t,e;return t=new Dh({props:{viewer:r[0],$$slots:{default:[T2,({transform:i,scale:n})=>({6:i,7:n}),({transform:i,scale:n})=>(i?64:0)|(n?128:0)]},$$scope:{ctx:r}}}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n&1&&(s.viewer=i[0]),n&2244&&(s.$$scope={dirty:n,ctx:i}),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){ot(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function Fm(r){let t,e,i=xe(r[2]),n=[];for(let o=0;o<i.length;o+=1)n[o]=km(Lm(r,i,o));const s=o=>ot(n[o],1,1,()=>{n[o]=null});return{c(){for(let o=0;o<n.length;o+=1)n[o].c();t=Pe()},m(o,a){for(let l=0;l<n.length;l+=1)n[l]&&n[l].m(o,a);st(o,t,a),e=!0},p(o,a){if(a&132){i=xe(o[2]);let l;for(l=0;l<i.length;l+=1){const h=Lm(o,i,l);n[l]?(n[l].p(h,a),q(n[l],1)):(n[l]=km(h),n[l].c(),q(n[l],1),n[l].m(t.parentNode,t))}for(ne(),l=i.length;l<n.length;l+=1)s(l);se()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)q(n[a]);e=!0}},o(o){n=n.filter(x2);for(let a=0;a<n.length;a+=1)ot(n[a]);e=!1},d(o){o&&nt(t),Dr(n,o)}}}function w2(r){let t,e;return t=new y2({props:{annotation:r[8].annotation,user:r[8].selectedBy,scale:r[7]}}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n&4&&(s.annotation=i[8].annotation),n&4&&(s.user=i[8].selectedBy),n&128&&(s.scale=i[7]),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){ot(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function E2(r){let t,e;return t=new b2({props:{annotation:r[8].annotation,user:r[8].selectedBy,scale:r[7]}}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n&4&&(s.annotation=i[8].annotation),n&4&&(s.user=i[8].selectedBy),n&128&&(s.scale=i[7]),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){ot(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function km(r){let t,e,i,n;const s=[E2,w2],o=[];function a(l,h){return l[8].annotation.target.selector.type===mt.RECTANGLE?0:l[8].annotation.target.selector.type===mt.POLYGON?1:-1}return~(t=a(r))&&(e=o[t]=s[t](r)),{c(){e&&e.c(),i=Pe()},m(l,h){~t&&o[t].m(l,h),st(l,i,h),n=!0},p(l,h){let c=t;t=a(l),t===c?~t&&o[t].p(l,h):(e&&(ne(),ot(o[c],1,1,()=>{o[c]=null}),se()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=s[t](l),e.c()),q(e,1),e.m(i.parentNode,i)):e=null)},i(l){n||(q(e),n=!0)},o(l){ot(e),n=!1},d(l){l&&nt(i),~t&&o[t].d(l)}}}function T2(r){let t,e,i,n,s=r[2].length>0&&Fm(r);return{c(){t=et("svg"),e=et("g"),s&&s.c(),w(e,"transform",i=r[6]),w(t,"class","a9s-osd-presencelayer svelte-1krwc4m")},m(o,a){st(o,t,a),At(t,e),s&&s.m(e,null),n=!0},p(o,a){o[2].length>0?s?(s.p(o,a),a&4&&q(s,1)):(s=Fm(o),s.c(),q(s,1),s.m(e,null)):s&&(ne(),ot(s,1,1,()=>{s=null}),se()),(!n||a&64&&i!==(i=o[6]))&&w(e,"transform",i)},i(o){n||(q(s),n=!0)},o(o){ot(s),n=!1},d(o){o&&nt(t),s&&s.d()}}}function A2(r){let t=!!r[1],e,i,n=t&&Nm(r);return{c(){n&&n.c(),e=Pe()},m(s,o){n&&n.m(s,o),st(s,e,o),i=!0},p(s,[o]){o&2&&(t=!!s[1]),t?n?(n.p(s,o),o&2&&q(n,1)):(n=Nm(s),n.c(),q(n,1),n.m(e.parentNode,e)):n&&(ne(),ot(n,1,1,()=>{n=null}),se())},i(s){i||(q(n),i=!0)},o(s){ot(n),i=!1},d(s){s&&nt(e),n&&n.d(s)}}}function S2(r,t,e){let{store:i}=t,{viewer:n}=t,{provider:s}=t,o=[],a;const l=(h,c)=>{e(2,o=[...o.filter(({selectedBy:u})=>u.presenceKey!==h.presenceKey),...(c||[]).map(u=>({annotation:i.getAnnotation(u),selectedBy:h}))].filter(({annotation:u})=>(u||console.warn("Selection event on unknown annotation"),!!u))),a&&i.unobserve(a),a=u=>{const{deleted:d,updated:p}=u.changes,f=new Set((d||[]).map(_=>_.id)),m=o.filter(({annotation:_})=>!f.has(_.id)).map(_=>{const v=(p||[]).find(y=>y.oldValue.id===_.annotation.id);return v?{selectedBy:_.selectedBy,annotation:v.newValue}:_});e(2,o=m)},i.observe(a,{annotations:o.map(u=>u.annotation.id)})};return F_(()=>{a&&i.unobserve(a)}),r.$$set=h=>{"store"in h&&e(3,i=h.store),"viewer"in h&&e(0,n=h.viewer),"provider"in h&&e(1,s=h.provider)},r.$$.update=()=>{r.$$.dirty&2&&s&&s.on("selectionChange",l)},[n,s,o,i]}class C2 extends jt{constructor(t){super(),zt(this,t,S2,A2,Ut,{store:3,viewer:0,provider:1})}}function I2(r){let t,e,i,n,s;return{c(){t=et("ellipse"),w(t,"cx",e=r[0].cx),w(t,"cy",i=r[0].cy),w(t,"rx",n=r[0].rx),w(t,"ry",s=r[0].ry)},m(o,a){st(o,t,a)},p(o,[a]){a&1&&e!==(e=o[0].cx)&&w(t,"cx",e),a&1&&i!==(i=o[0].cy)&&w(t,"cy",i),a&1&&n!==(n=o[0].rx)&&w(t,"rx",n),a&1&&s!==(s=o[0].ry)&&w(t,"ry",s)},i:Ft,o:Ft,d(o){o&&nt(t)}}}function P2(r,t,e){let i,{annotation:n}=t;return r.$$set=s=>{"annotation"in s&&e(1,n=s.annotation)},r.$$.update=()=>{r.$$.dirty&2&&e(0,i=n.target.selector.geometry)},[i,n]}class R2 extends jt{constructor(t){super(),zt(this,t,P2,I2,Ut,{annotation:1})}}function M2(r){let t,e,i,n,s;return{c(){t=et("line"),w(t,"x1",e=r[0].points[0][0]),w(t,"y1",i=r[0].points[0][1]),w(t,"x2",n=r[0].points[1][0]),w(t,"y2",s=r[0].points[1][1])},m(o,a){st(o,t,a)},p(o,[a]){a&1&&e!==(e=o[0].points[0][0])&&w(t,"x1",e),a&1&&i!==(i=o[0].points[0][1])&&w(t,"y1",i),a&1&&n!==(n=o[0].points[1][0])&&w(t,"x2",n),a&1&&s!==(s=o[0].points[1][1])&&w(t,"y2",s)},i:Ft,o:Ft,d(o){o&&nt(t)}}}function D2(r,t,e){let i,{annotation:n}=t;return r.$$set=s=>{"annotation"in s&&e(1,n=s.annotation)},r.$$.update=()=>{r.$$.dirty&2&&e(0,i=n.target.selector.geometry)},[i,n]}class B2 extends jt{constructor(t){super(),zt(this,t,D2,M2,Ut,{annotation:1})}}function Um(r,t,e){const i=r.slice();return i[2]=t[e],i}function Gm(r){let t,e;return{c(){t=et("path"),e=et("path"),w(t,"fill-rule","evenodd"),w(t,"d",$e(r[2])),w(e,"class","a9s-inner"),w(e,"fill-rule","evenodd"),w(e,"d",$e(r[2]))},m(i,n){st(i,t,n),st(i,e,n)},p:Ft,d(i){i&&(nt(t),nt(e))}}}function O2(r){let t,e=xe(r[0]),i=[];for(let n=0;n<e.length;n+=1)i[n]=Gm(Um(r,e,n));return{c(){t=et("g");for(let n=0;n<i.length;n+=1)i[n].c()},m(n,s){st(n,t,s);for(let o=0;o<i.length;o+=1)i[o]&&i[o].m(t,null)},p(n,[s]){if(s&1){e=xe(n[0]);let o;for(o=0;o<e.length;o+=1){const a=Um(n,e,o);i[o]?i[o].p(a,s):(i[o]=Gm(a),i[o].c(),i[o].m(t,null))}for(;o<i.length;o+=1)i[o].d(1);i.length=e.length}},i:Ft,o:Ft,d(n){n&&nt(t),Dr(i,n)}}}function L2(r,t,e){let{annotation:i}=t;const{polygons:n}=i.target.selector.geometry;return r.$$set=s=>{"annotation"in s&&e(1,i=s.annotation)},[n,i]}class N2 extends jt{constructor(t){super(),zt(this,t,L2,O2,Ut,{annotation:1})}}function F2(r){let t,e;return{c(){t=et("polygon"),w(t,"points",e=r[0].points.map($m).join(" "))},m(i,n){st(i,t,n)},p(i,[n]){n&1&&e!==(e=i[0].points.map($m).join(" "))&&w(t,"points",e)},i:Ft,o:Ft,d(i){i&&nt(t)}}}const $m=r=>r.join(",");function k2(r,t,e){let i,{annotation:n}=t;return r.$$set=s=>{"annotation"in s&&e(1,n=s.annotation)},r.$$.update=()=>{r.$$.dirty&2&&e(0,i=n.target.selector.geometry)},[i,n]}class U2 extends jt{constructor(t){super(),zt(this,t,k2,F2,Ut,{annotation:1})}}function G2(r){let t;return{c(){t=et("path"),w(t,"d",r[0])},m(e,i){st(e,t,i)},p(e,[i]){i&1&&w(t,"d",e[0])},i:Ft,o:Ft,d(e){e&&nt(t)}}}function $2(r,t,e){let i,n,{annotation:s}=t;return r.$$set=o=>{"annotation"in o&&e(1,s=o.annotation)},r.$$.update=()=>{r.$$.dirty&2&&e(2,i=s.target.selector.geometry),r.$$.dirty&4&&e(0,n=Jo(i))},[n,s,i]}class H2 extends jt{constructor(t){super(),zt(this,t,$2,G2,Ut,{annotation:1})}}function X2(r){let t,e,i,n,s;return{c(){t=et("rect"),w(t,"x",e=r[0].x),w(t,"y",i=r[0].y),w(t,"width",n=r[0].w),w(t,"height",s=r[0].h)},m(o,a){st(o,t,a)},p(o,[a]){a&1&&e!==(e=o[0].x)&&w(t,"x",e),a&1&&i!==(i=o[0].y)&&w(t,"y",i),a&1&&n!==(n=o[0].w)&&w(t,"width",n),a&1&&s!==(s=o[0].h)&&w(t,"height",s)},i:Ft,o:Ft,d(o){o&&nt(t)}}}function V2(r,t,e){let i,{annotation:n}=t;return r.$$set=s=>{"annotation"in s&&e(1,n=s.annotation)},r.$$.update=()=>{r.$$.dirty&2&&e(0,i=n.target.selector.geometry)},[i,n]}class z2 extends jt{constructor(t){super(),zt(this,t,V2,X2,Ut,{annotation:1})}}const{Boolean:j2}=va;function Hm(r,t,e){const i=r.slice();return i[10]=t[e],i}function Xm(r){let t,e;return t=new Dh({props:{viewer:r[0],$$slots:{default:[Q2,({transform:i})=>({9:i}),({transform:i})=>i?512:0]},$$scope:{ctx:r}}}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n&1&&(s.viewer=i[0]),n&8710&&(s.$$scope={dirty:n,ctx:i}),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){ot(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function W2(r){let t,e;return t=new B2({props:{annotation:r[10]}}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n&2&&(s.annotation=i[10]),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){ot(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function Y2(r){let t,e;return t=new R2({props:{annotation:r[10]}}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n&2&&(s.annotation=i[10]),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){ot(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function q2(r){let t,e;return t=new H2({props:{annotation:r[10]}}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n&2&&(s.annotation=i[10]),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){ot(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function K2(r){let t,e;return t=new N2({props:{annotation:r[10]}}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n&2&&(s.annotation=i[10]),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){ot(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function Z2(r){let t,e;return t=new U2({props:{annotation:r[10]}}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n&2&&(s.annotation=i[10]),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){ot(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function J2(r){let t,e;return t=new z2({props:{annotation:r[10]}}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n&2&&(s.annotation=i[10]),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){ot(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function Vm(r){let t,e,i,n;const s=[J2,Z2,K2,q2,Y2,W2],o=[];function a(l,h){return l[10].target.selector.type===mt.RECTANGLE?0:l[10].target.selector.type===mt.POLYGON?1:l[10].target.selector.type===mt.MULTIPOLYGON?2:l[10].target.selector.type===mt.POLYLINE?3:l[10].target.selector.type===mt.ELLIPSE?4:l[10].target.selector.type===mt.LINE?5:-1}return~(t=a(r))&&(e=o[t]=s[t](r)),{c(){e&&e.c(),i=Pe()},m(l,h){~t&&o[t].m(l,h),st(l,i,h),n=!0},p(l,h){let c=t;t=a(l),t===c?~t&&o[t].p(l,h):(e&&(ne(),ot(o[c],1,1,()=>{o[c]=null}),se()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=s[t](l),e.c()),q(e,1),e.m(i.parentNode,i)):e=null)},i(l){n||(q(e),n=!0)},o(l){ot(e),n=!1},d(l){l&&nt(i),~t&&o[t].d(l)}}}function Q2(r){let t,e,i,n,s,o,a,l,h,c,u,d,p,f,m=xe(r[1].filter(r[6])),_=[];for(let y=0;y<m.length;y+=1)_[y]=Vm(Hm(r,m,y));const v=y=>ot(_[y],1,1,()=>{_[y]=null});return{c(){var y,g,b,C;t=et("svg"),e=et("g"),i=et("rect"),l=et("rect");for(let R=0;R<_.length;R+=1)_[R].c();w(i,"class","a9s-union-bg svelte-jwrce3"),w(i,"x",n=(y=r[2])==null?void 0:y.minX),w(i,"y",s=(g=r[2])==null?void 0:g.minY),w(i,"width",o=r[2]?r[2].maxX-r[2].minX:0),w(i,"height",a=r[2]?r[2].maxY-r[2].minY:0),w(l,"class","a9s-union-fg svelte-jwrce3"),w(l,"x",h=(b=r[2])==null?void 0:b.minX),w(l,"y",c=(C=r[2])==null?void 0:C.minY),w(l,"width",u=r[2]?r[2].maxX-r[2].minX:0),w(l,"height",d=r[2]?r[2].maxY-r[2].minY:0),w(e,"transform",p=r[9]),w(t,"class","a9s-osd-selectionlayer svelte-jwrce3")},m(y,g){st(y,t,g),At(t,e),At(e,i),At(e,l);for(let b=0;b<_.length;b+=1)_[b]&&_[b].m(e,null);f=!0},p(y,g){var b,C,R,A;if((!f||g&4&&n!==(n=(b=y[2])==null?void 0:b.minX))&&w(i,"x",n),(!f||g&4&&s!==(s=(C=y[2])==null?void 0:C.minY))&&w(i,"y",s),(!f||g&4&&o!==(o=y[2]?y[2].maxX-y[2].minX:0))&&w(i,"width",o),(!f||g&4&&a!==(a=y[2]?y[2].maxY-y[2].minY:0))&&w(i,"height",a),(!f||g&4&&h!==(h=(R=y[2])==null?void 0:R.minX))&&w(l,"x",h),(!f||g&4&&c!==(c=(A=y[2])==null?void 0:A.minY))&&w(l,"y",c),(!f||g&4&&u!==(u=y[2]?y[2].maxX-y[2].minX:0))&&w(l,"width",u),(!f||g&4&&d!==(d=y[2]?y[2].maxY-y[2].minY:0))&&w(l,"height",d),g&2){m=xe(y[1].filter(y[6]));let P;for(P=0;P<m.length;P+=1){const M=Hm(y,m,P);_[P]?(_[P].p(M,g),q(_[P],1)):(_[P]=Vm(M),_[P].c(),q(_[P],1),_[P].m(e,null))}for(ne(),P=m.length;P<_.length;P+=1)v(P);se()}(!f||g&512&&p!==(p=y[9]))&&w(e,"transform",p)},i(y){if(!f){for(let g=0;g<m.length;g+=1)q(_[g]);f=!0}},o(y){_=_.filter(j2);for(let g=0;g<_.length;g+=1)ot(_[g]);f=!1},d(y){y&&nt(t),Dr(_,y)}}}function tC(r){let t=!!r[2],e,i,n=t&&Xm(r);return{c(){n&&n.c(),e=Pe()},m(s,o){n&&n.m(s,o),st(s,e,o),i=!0},p(s,[o]){o&4&&(t=!!s[2]),t?n?(n.p(s,o),o&4&&q(n,1)):(n=Xm(s),n.c(),q(n,1),n.m(e.parentNode,e)):n&&(ne(),ot(n,1,1,()=>{n=null}),se())},i(s){i||(q(n),i=!0)},o(s){ot(n),i=!1},d(s){s&&nt(e),n&&n.d(s)}}}function eC(r,t,e){let i,n,s,{state:o}=t,{viewer:a}=t;const{store:l}=o,{selection:h}=o;vs(r,h,d=>e(5,s=d));const c=d=>{let p=-1/0,f=-1/0,m=1/0,_=1/0;for(let v of d.filter(y=>Le(y))){const{bounds:y}=v.target.selector.geometry;y.maxX>p&&(p=y.maxX),y.maxY>f&&(f=y.maxY),y.minX<m&&(m=y.minX),y.minY<_&&(_=y.minY)}return a.forceRedraw(),{maxX:p,maxY:f,minX:m,minY:_}},u=d=>Le(d);return r.$$set=d=>{"state"in d&&e(4,o=d.state),"viewer"in d&&e(0,a=d.viewer)},r.$$.update=()=>{r.$$.dirty&32&&e(1,i=s.selected.map(({id:d})=>l.getAnnotation(d))),r.$$.dirty&2&&e(2,n=i.length>1?c(i):void 0)},[a,i,n,h,o,s,u]}class rC extends jt{constructor(t){super(),zt(this,t,eC,tC,Ut,{state:4,viewer:0})}}const zm=(r,t)=>{t==="auto"?r.addHandler("open",e=>{const i=r.world.getItemCount();r.world.getItemAt(i-1).addOnceHandler("fully-loaded-change",s=>{const{fullyLoaded:o}=s;if(o){const a=r.canvas.querySelector("canvas"),l=eu(a);r.element.setAttribute("data-theme",l)}})}):r.element.setAttribute("data-theme",t)},jm=(r,t,e)=>(i,n={})=>{const s=typeof i=="string"?i:i.id,o=t.getAnnotation(s);if(!o||!Le(o))return;const a=r.container.getBoundingClientRect(),{padding:l}=n;let[h,c,u,d]=l?Array.isArray(l)?l:[l,l,l,l]:[0,0,0,0];h=h/a.height,c=c/a.width,u=u/a.height,d=d/a.width;const{minX:p,minY:f,maxX:m,maxY:_}=o.target.selector.geometry.bounds,v=m-p,y=_-f,g=p-d*v,b=f-h*y,C=v+(c+d)*v,R=y+(h+u)*y,A=r.viewport.imageToViewportRectangle(g,b,C,R);r.viewport[e](A,n.immediately)},iC=(r,t)=>jm(r,t,"fitBounds"),nC=(r,t)=>jm(r,t,"fitBoundsWithConstraints"),sC=(r,t={})=>{const e=iu(t,{drawingEnabled:!1,drawingMode:pr?"drag":"click",userSelectAction:Go.EDIT,theme:"light"}),i=tu(e),{hover:n,selection:s,store:o}=i,a=ug(o,e.initialHistory),l=dg(i,a,e.adapter,e.autoSave);let h=bg(),c=e.drawingEnabled,u=e.drawingMode,d=e.modalSelect;const p=su(a,r.element),f=new t2({target:r.element,props:{state:i,viewer:r,style:e.style,filter:void 0}}),m=new C2({target:r.element.querySelector(".openseadragon-canvas"),props:{provider:void 0,store:o,viewer:r}}),_=new d2({target:r.element.querySelector(".openseadragon-canvas"),props:{drawingEnabled:!!c,filter:void 0,multiSelect:e.multiSelect,preferredDrawingMode:u,state:i,style:e.style,user:h,viewer:r}}),v=new rC({target:r.element.querySelector(".openseadragon-canvas"),props:{state:i,viewer:r}});f.$on("click",O=>{const{originalEvent:$,annotation:F}=O.detail,X=V=>Sm(V.id,$,s,e.multiSelect);d?s.isEmpty()&&F&&s.userSelect(X(F),$):F&&!(u==="click"&&c)?s.userSelect(X(F),$):s.isEmpty()||s.clear()}),r.element.addEventListener("pointerdown",O=>{if(n.current){const $=o.getAnnotation(n.current);l.emit("clickAnnotation",$,O)}}),zm(r,e.theme);const y=pg(i,a,e.adapter),g=()=>_.cancelDrawing(),b=()=>{f.$destroy(),m.$destroy(),_.$destroy(),v.$destroy(),p.destroy(),a.destroy()},C=iC(r,o),R=nC(r,o),A=()=>_.getDrawingTool(),P=()=>h,M=()=>_.isDrawingEnabled(),k=(O,$,F)=>Uc(O,$,F),U=(O,$)=>Lc(O,$),I=O=>{if(!gs(O))throw`No drawing tool named ${O}`;_.$set({toolName:O})},T=O=>{c=O,_.$set({drawingEnabled:O})},E=O=>{f.$set({filter:O}),_.$set({filter:O})},S=O=>d=O,L=O=>{f.$set({style:O}),_.$set({style:O})},D=O=>m.$set({provider:O}),N=O=>zm(r,O),H=O=>{h=O,_.$set({user:O})},B=O=>f.$set({visible:O});return{...y,cancelDrawing:g,destroy:b,fitBounds:C,fitBoundsWithConstraints:R,getDrawingTool:A,getUser:P,isDrawingEnabled:M,listDrawingTools:ms,on:l.on,off:l.off,registerDrawingTool:k,registerShapeEditor:U,setDrawingEnabled:T,setDrawingTool:I,setFilter:E,setModalSelect:S,setPresenceProvider:D,setStyle:L,setTheme:N,setUser:H,setVisible:B,state:i,viewer:r}};Yt.ShapeType=mt,Yt.UserSelectAction=Go,Yt.W3CImageFormat=Wy,Yt.chainStyles=Fy,Yt.computeStyle=Ny,Yt.createBody=rg,Yt.createImageAnnotator=M_,Yt.createOSDAnnotator=sC,Yt.defaultColorProvider=wg,Object.defineProperty(Yt,Symbol.toStringTag,{value:"Module"})});
|
|
1148
1148
|
//# sourceMappingURL=annotorious-openseadragon.js.map
|