@annotorious/openseadragon 3.3.4 → 3.3.5
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.
|
@@ -1145,6 +1145,6 @@ void main(void)\r
|
|
|
1145
1145
|
font-weight: ${e.weight};
|
|
1146
1146
|
font-style: ${e.style};
|
|
1147
1147
|
font-display: ${e.display};
|
|
1148
|
-
}`,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=ub(t)),typeof t=="number"?hb(t):t}dropShadowToCSS(){let t=this.normalizeColor(this.dropShadowColor);const e=this.dropShadowAlpha,i=Math.round(Math.cos(this.dropShadowAngle)*this.dropShadowDistance),s=Math.round(Math.sin(this.dropShadowAngle)*this.dropShadowDistance);t.startsWith("#")&&e<1&&(t+=(e*255|0).toString(16).padStart(2,"0"));const n=`${i}px ${s}px`;return this.dropShadowBlur>0?`text-shadow: ${n} ${this.dropShadowBlur}px ${t}`:`text-shadow: ${n} ${t}`}reset(){Object.assign(this,cs.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}};dh.availableFonts={},dh.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 fh=dh;const Ro=class ds extends ts{constructor(t="",e={}){super(Z.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,s=Z.from(i,{scaleMode:j.SCALE_MODE,resourceOptions:{autoLoad:!1}});s.orig=new pt,s.trim=new pt,this.texture=s;const n="http://www.w3.org/2000/svg",o="http://www.w3.org/1999/xhtml",a=document.createElementNS(n,"svg"),l=document.createElementNS(n,"foreignObject"),h=document.createElementNS(o,"div"),u=document.createElementNS(o,"style");l.setAttribute("width","10000"),l.setAttribute("height","10000"),l.style.overflow="hidden",a.appendChild(l),this.maxWidth=ds.defaultMaxWidth,this.maxHeight=ds.defaultMaxHeight,this._domElement=h,this._styleElement=u,this._svgRoot=a,this._foreignObject=l,this._foreignObject.appendChild(u),this._foreignObject.appendChild(h),this._image=i,this._loadImage=new Image,this._autoResolution=ds.defaultAutoResolution,this._resolution=ds.defaultResolution??j.RESOLUTION,this.text=t,this.style=e}measureText(t){var u,c;const{text:e,style:i,resolution:s}=Object.assign({text:this._text,style:this._style,resolution:this._resolution},t);Object.assign(this._domElement,{innerHTML:e,style:i.toCSS(s)}),this._styleElement.textContent=i.toGlobalCSS(),document.body.appendChild(this._svgRoot);const n=this._domElement.getBoundingClientRect();this._svgRoot.remove();const{width:o,height:a}=n;(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:(u=this._style)==null?void 0:u.toCSS(s)}),this._styleElement.textContent=(c=this._style)==null?void 0:c.toGlobalCSS()),{width:l+i.padding*2,height:h+i.padding*2}}async updateText(t=!0){const{style:e,_image:i,_loadImage:s}=this;if(this.localStyleID!==e.styleID&&(this.dirty=!0,this.localStyleID=e.styleID),!this.dirty&&t)return;const{width:n,height:o}=this.measureText();i.width=s.width=Math.ceil(Math.max(1,n)),i.height=s.height=Math.ceil(Math.max(1,o)),this._updateID++;const a=this._updateID;await new Promise(l=>{s.onload=async()=>{if(a<this._updateID){l();return}await e.onBeforeDraw(),i.src=s.src,s.onload=null,s.src="",this.updateTexture(),l()};const h=new XMLSerializer().serializeToString(this._svgRoot);s.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(h)}`})}get source(){return this._image}updateTexture(){const{style:t,texture:e,_image:i,resolution:s}=this,{padding:n}=t,{baseTexture:o}=e;e.trim.width=e._frame.width=i.width/s,e.trim.height=e._frame.height=i.height/s,e.trim.x=-n,e.trim.y=-n,e.orig.width=e._frame.width-n*2,e.orig.height=e._frame.height-n*2,this._onTextureUpdate(),o.setRealSize(i.width,i.height,s),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,s,n,o,a;typeof t=="boolean"&&(t={children:t}),t=Object.assign({},ds.defaultDestroyOptions,t),super.destroy(t);const e=null;this.ownsStyle&&((i=this._style)==null||i.cleanFonts()),this._style=e,(s=this._svgRoot)==null||s.remove(),this._svgRoot=e,(n=this._domElement)==null||n.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=Fr(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=Fr(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 fh?(this.ownsStyle=!1,this._style=t):t instanceof Xr?(console.warn("[HTMLText] Cloning TextStyle, if this is not what you want, use HTMLTextStyle"),this.ownsStyle=!0,this._style=fh.from(t)):(this.ownsStyle=!0,this._style=new fh(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," ")}};Ro.defaultDestroyOptions={texture:!0,children:!1,baseTexture:!0},Ro.defaultMaxWidth=2024,Ro.defaultMaxHeight=2024,Ro.defaultAutoResolution=!0;const EA=16777215,TA=.25,wA=16777215,AA=1,SA=1.5;let Yr=!1,Ys;const ph=r=>{const t={tint:r!=null&&r.fill?new wt(r.fill).toNumber():EA,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 wt(r==null?void 0:r.fill).alpha:TA},e={tint:r!=null&&r.stroke?new wt(r.stroke).toNumber():wA,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 wt(r==null?void 0:r.stroke).alpha:AA,lineWidth:(r==null?void 0:r.strokeWidth)===void 0?SA:r.strokeWidth};return{fillStyle:t,strokeStyle:e}},Mo=r=>(t,e,i)=>{const{fillStyle:s,strokeStyle:n}=ph(i),o=new Ws;o.beginFill(16777215),r(e,o),o.endFill(),o.tint=s.tint,o.alpha=s.alpha,t.addChild(o);const a=new Ws,l=n.lineWidth===1?1:n.lineWidth/Ys;return a.lineStyle(l,16777215,1,.5,n.lineWidth===1),r(e,a),a.tint=n.tint||16777215,a.alpha=n.alpha,t.addChild(a),{fill:o,stroke:a,strokeWidth:n.lineWidth}},CA=Mo((r,t)=>{const{x:e,y:i,w:s,h:n}=r.geometry;t.drawRect(e,i,s,n)}),IA=Mo((r,t)=>{const{cx:e,cy:i,rx:s,ry:n}=r.geometry;t.drawEllipse(e,i,s,n)}),RA=Mo((r,t)=>{const e=r.geometry.points.reduce((i,s)=>[...i,...s],[]);t.drawPolygon(e)}),MA=Mo((r,t)=>{const e=i=>i.points.reduce((s,n)=>[...s,...n],[]);r.geometry.polygons.forEach(i=>{const[s,...n]=i.rings;t.drawPolygon(e(s)),n.forEach(o=>{t.beginHole(),t.drawPolygon(e(o)),t.endHole()})})}),Up=r=>{const t=r.viewport.getContainerSize().x;return r.viewport.getZoom(!0)*t/r.world.getContentFactor()},kp=(r,t,e,i)=>()=>{const s=r.viewport.viewportToImageRectangle(r.viewport.getBounds(!0)),n=Up(r);(n!==Ys||!Yr)&&(Yr=!0,e.forEach(({stroke:d,strokeWidth:f})=>{const{lineStyle:p}=d.geometry.graphicsData[0];f>1?(Yr=n===Ys,p.width=f/n,p.native=!1,d.geometry.invalidate()):f===1&&!p.native&&(p.width=1,p.native=!0,d.geometry.invalidate())})),Ys=n;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+s.x*n:-s.x*n,h=-s.y*n;let u,c;a>0&&a<=Math.PI/2?(u=s.height*n,c=0):a>Math.PI/2&&a<=Math.PI?(u=s.width*n,c=s.height*n):a>Math.PI&&a<=Math.PI*1.5?(u=0,c=s.width*n):(u=0,c=0),t.position.x=u+l*Math.cos(a)-h*Math.sin(a),t.position.y=c+l*Math.sin(a)+h*Math.cos(a),t.scale.set(o?-n:n,n),t.rotation=a,i.render(t)},PA=(r,t)=>{const e=new Ws,i=Lf({width:t.width,height:t.height,backgroundAlpha:0,view:t,antialias:!0,resolution:2}),s=new Map;let n=new Set,o,a;Ys=Up(r);const l=(g,x)=>{Yr=!1;const{selector:b}=g.target,S=typeof a=="function"?a(g,x):a;let w;b.type===vt.RECTANGLE?w=CA(e,b,S):b.type===vt.POLYGON?w=RA(e,b,S):b.type===vt.ELLIPSE?w=IA(e,b,S):b.type===vt.MULTIPOLYGLON?w=MA(e,b,S):console.warn(`Unsupported shape type: ${b.type}`),w&&s.set(g.id,{annotation:g,...w})},h=g=>{const x=s.get(g.id);x&&(s.delete(g.id),x.fill.destroy(),x.stroke.destroy())},u=(g,x,b)=>{Yr=!1;const S=s.get(g.id);S&&(s.delete(g.id),S.fill.destroy(),S.stroke.destroy(),l(x,b))},c=(g,x)=>{const b=s.get(g);b&&(s.delete(g),b.fill.destroy(),b.stroke.destroy(),l(b.annotation,x))},d=(g,x)=>{i.resize(g,x),i.render(e)},f=g=>{Yr=!1;const{children:x}=e;s.forEach(({fill:b,stroke:S,annotation:w})=>{const T=g?n.has(w.id)||g(w):!0;T&&!x.includes(b)?(e.addChild(b),e.addChild(S)):!T&&x.includes(b)&&(e.removeChild(b),e.removeChild(S))}),i.render(e)},p=g=>{o!==g&&(o&&c(o,{selected:n.has(o)}),g&&c(g,{selected:n.has(g),hovered:!0}),o=g,i.render(e))},m=g=>{const x=g.selected.map(w=>w.id),b=x.filter(w=>!n.has(w)),S=[...n].filter(w=>!x.includes(w));[...b,...S].forEach(w=>c(w,{selected:x.includes(w),hovered:w===o})),n=new Set(x),i.render(e)},y=g=>{if(typeof g=="function")s.forEach(({annotation:x,fill:b,stroke:S,strokeWidth:w},T)=>{w>1&&(Yr=!1);const N={selected:n.has(x.id),hovered:o===x.id},{fillStyle:F,strokeStyle:z}=ph(g(x,N));b.tint=F.tint,b.alpha=F.alpha,S.tint=z.tint||16777215,S.alpha=z.alpha,s.set(x.id,{annotation:x,fill:b,stroke:S,strokeWidth:z.lineWidth})});else{const{fillStyle:x,strokeStyle:b}=ph(g);b.lineWidth>1&&(Yr=!1),s.forEach(({annotation:S,fill:w,stroke:T,strokeWidth:N},F)=>{w.tint=x.tint,w.alpha=x.alpha,T.tint=b.tint||16777215,T.alpha=b.alpha,s.set(S.id,{annotation:S,fill:w,stroke:T,strokeWidth:b.lineWidth})})}a=g,i.render(e),kp(r,e,s,i)()},_=g=>{g?t.classList.remove("hidden"):t.classList.add("hidden")};return{addAnnotation:l,destroy:()=>i.destroy(),redraw:kp(r,e,s,i),removeAnnotation:h,resize:d,setFilter:f,setHovered:p,setSelected:m,setStyle:y,setVisible:_,updateAnnotation:u}};function OA(r,t,e){let i,s,{filter:n}=t,{state:o}=t,{style:a}=t,{viewer:l}=t,{visible:h=!0}=t;const{store:u,hover:c,selection:d,viewport:f}=o;fn(r,c,S=>e(11,i=S)),fn(r,d,S=>e(8,s=S));const p=yn();let m,y;const _=S=>{const w=new de.Point(S.x,S.y),{x:T,y:N}=l.viewport.pointFromPixel(w);return l.viewport.viewportToImageCoordinates(T,N)},v=S=>{const{x:w,y:T}=S.position;y={x:w,y:T}},g=S=>w=>{const{x:T,y:N}=_(new de.Point(w.offsetX,w.offsetY)),F=u.getAt(T,N);F&&(!n||n(F))?(S.classList.add("hover"),i!==F.id&&(c.set(F.id),m.setHovered(F.id))):(S.classList.remove("hover"),i&&(c.set(void 0),m.setHovered(void 0)))},x=S=>{if(!y)return;const w=S.originalEvent,{x:T,y:N}=S.position,F=T-y.x,z=N-y.y;if(Math.sqrt(F*F+z*z)<5){const{x:E,y:I}=_(S.position),P=u.getAt(E,I);P?p("click",{originalEvent:w,annotation:P}):p("click",{originalEvent:w})}y=void 0};let b;return gn(()=>{var P;const{offsetWidth:S,offsetHeight:w}=l.canvas,T=document.createElement("canvas");T.width=S,T.height=w,T.className="a9s-gl-canvas",(P=l.element.querySelector(".openseadragon-canvas"))==null||P.appendChild(T),e(7,m=PA(l,T));const N=g(T);T.addEventListener("pointermove",N);const F=new ResizeObserver(H=>{try{const{width:k,height:G}=H[0].contentRect;T.width=k,T.height=G,m.resize(k,G)}catch{console.warn("WebGL canvas already disposed")}});F.observe(T);const z=()=>{const H=l.viewport.getBounds();b=l.viewport.viewportToImageRectangle(H);const{x:k,y:G,width:st,height:M}=b,L=u.getIntersecting(k,G,st,M);f.set(L.map(V=>V.id))};l.addHandler("canvas-press",v),l.addHandler("canvas-release",x),l.addHandler("update-viewport",m.redraw),l.addHandler("animation-finish",z);const C=H=>H.filter(k=>Ge(k)),E=H=>Ge(H.oldValue)&&Ge(H.newValue),I=H=>{const{created:k,updated:G,deleted:st}=H.changes;if(C(k||[]).forEach(M=>m.addAnnotation(M)),C(st||[]).forEach(M=>m.removeAnnotation(M)),(G||[]).filter(M=>E(M)).forEach(({oldValue:M,newValue:L})=>m.updateAnnotation(M,L)),b){const{x:M,y:L,width:V,height:rt}=b,Q=u.getIntersecting(M,L,V,rt);f.set(Q.map(X=>X.id))}else f.set(u.all().map(M=>M.id));m.redraw()};return u.observe(I),()=>{var H;T.removeEventListener("pointermove",N),F.disconnect(),l.removeHandler("canvas-press",v),l.removeHandler("canvas-release",x),l.removeHandler("update-viewport",m.redraw),l.removeHandler("animation-finish",z),u.unobserve(I),m.destroy(),(H=T.parentNode)==null||H.removeChild(T)}}),r.$$set=S=>{"filter"in S&&e(2,n=S.filter),"state"in S&&e(3,o=S.state),"style"in S&&e(4,a=S.style),"viewer"in S&&e(5,l=S.viewer),"visible"in S&&e(6,h=S.visible)},r.$$.update=()=>{r.$$.dirty&132&&(m==null||m.setFilter(n)),r.$$.dirty&384&&(m==null||m.setSelected(s)),r.$$.dirty&144&&(m==null||m.setStyle(a)),r.$$.dirty&192&&(m==null||m.setVisible(h))},[c,d,n,o,a,l,h,m,s]}class NA extends re{constructor(t){super(),ee(this,t,OA,null,Wt,{filter:2,state:3,style:4,viewer:5,visible:6})}}const ce=[];for(let r=0;r<256;++r)ce.push((r+256).toString(16).slice(1));function DA(r,t=0){return(ce[r[t+0]]+ce[r[t+1]]+ce[r[t+2]]+ce[r[t+3]]+"-"+ce[r[t+4]]+ce[r[t+5]]+"-"+ce[r[t+6]]+ce[r[t+7]]+"-"+ce[r[t+8]]+ce[r[t+9]]+"-"+ce[r[t+10]]+ce[r[t+11]]+ce[r[t+12]]+ce[r[t+13]]+ce[r[t+14]]+ce[r[t+15]]).toLowerCase()}let mh;const LA=new Uint8Array(16);function BA(){if(!mh){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");mh=crypto.getRandomValues.bind(crypto)}return mh(LA)}const Gp={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function FA(r,t,e){var s;if(Gp.randomUUID&&!r)return Gp.randomUUID();r=r||{};const i=r.random??((s=r.rng)==null?void 0:s.call(r))??BA();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=i[6]&15|64,i[8]=i[8]&63|128,DA(i)}var jr=(r=>(r.ELLIPSE="ELLIPSE",r.MULTIPOLYGLON="MULTIPOLYGON",r.POLYGON="POLYGON",r.RECTANGLE="RECTANGLE",r))(jr||{});const Po=(r,t)=>t,Oo=r=>{let t=1/0,e=1/0,i=-1/0,s=-1/0;return r.forEach(([n,o])=>{t=Math.min(t,n),e=Math.min(e,o),i=Math.max(i,n),s=Math.max(s,o)}),{minX:t,minY:e,maxX:i,maxY:s}},gh=r=>{let t=0,e=r.length-1;for(let i=0;i<r.length;i++)t+=(r[e][0]+r[i][0])*(r[e][1]-r[i][1]),e=i;return Math.abs(.5*t)},yh=(r,t,e)=>{let i=!1;for(let s=0,n=r.length-1;s<r.length;n=s++){const o=r[s][0],a=r[s][1],l=r[n][0],h=r[n][1];a>e!=h>e&&t<(l-o)*(e-a)/(h-a)+o&&(i=!i)}return i},UA=(r,t=!0)=>{let e="M ";return r.forEach(([i,s],n)=>{n===0?e+=`${i},${s}`:e+=` L ${i},${s}`}),t&&(e+=" Z"),e},kA={area:r=>Math.PI*r.geometry.rx*r.geometry.ry,intersects:(r,t,e)=>{const{cx:i,cy:s,rx:n,ry:o}=r.geometry,a=0,l=Math.cos(a),h=Math.sin(a),u=t-i,c=e-s,d=l*u+h*c,f=h*u-l*c;return d*d/(n*n)+f*f/(o*o)<=1}};Po(jr.ELLIPSE,kA);const GA={area:r=>{const{polygons:t}=r.geometry;return t.reduce((e,i)=>{const[s,...n]=i.rings,o=gh(s.points),a=n.reduce((l,h)=>l+gh(h.points),0);return e+o-a},0)},intersects:(r,t,e)=>{const{polygons:i}=r.geometry;for(const s of i){const[n,...o]=s.rings;if(yh(n.points,t,e)){let a=!1;for(const l of o)if(yh(l.points,t,e)){a=!0;break}if(!a)return!0}}return!1}},HA=r=>{const t=r.reduce((e,i)=>[...e,...i.rings[0].points],[]);return Oo(t)},No=r=>r.rings.map(e=>UA(e.points)).join(" ");Po(jr.MULTIPOLYGLON,GA);const $A={area:r=>{const t=r.geometry.points;return gh(t)},intersects:(r,t,e)=>{const i=r.geometry.points;return yh(i,t,e)}};Po(jr.POLYGON,$A);const VA={area:r=>r.geometry.w*r.geometry.h,intersects:(r,t,e)=>t>=r.geometry.x&&t<=r.geometry.x+r.geometry.w&&e>=r.geometry.y&&e<=r.geometry.y+r.geometry.h};Po(jr.RECTANGLE,VA);const jt=" ";function XA(r){let t="";Array.isArray(r)||(r=[r]);for(let e=0;e<r.length;e++){const i=r[e];if(i.type===U.CLOSE_PATH)t+="z";else if(i.type===U.HORIZ_LINE_TO)t+=(i.relative?"h":"H")+i.x;else if(i.type===U.VERT_LINE_TO)t+=(i.relative?"v":"V")+i.y;else if(i.type===U.MOVE_TO)t+=(i.relative?"m":"M")+i.x+jt+i.y;else if(i.type===U.LINE_TO)t+=(i.relative?"l":"L")+i.x+jt+i.y;else if(i.type===U.CURVE_TO)t+=(i.relative?"c":"C")+i.x1+jt+i.y1+jt+i.x2+jt+i.y2+jt+i.x+jt+i.y;else if(i.type===U.SMOOTH_CURVE_TO)t+=(i.relative?"s":"S")+i.x2+jt+i.y2+jt+i.x+jt+i.y;else if(i.type===U.QUAD_TO)t+=(i.relative?"q":"Q")+i.x1+jt+i.y1+jt+i.x+jt+i.y;else if(i.type===U.SMOOTH_QUAD_TO)t+=(i.relative?"t":"T")+i.x+jt+i.y;else if(i.type===U.ARC)t+=(i.relative?"a":"A")+i.rX+jt+i.rY+jt+i.xRot+jt+ +i.lArcFlag+jt+ +i.sweepFlag+jt+i.x+jt+i.y;else throw new Error(`Unexpected command type "${i==null?void 0:i.type}" at index ${e}.`)}return t}function _h([r,t],e){return[r*Math.cos(e)-t*Math.sin(e),r*Math.sin(e)+t*Math.cos(e)]}function Qe(...r){for(let t=0;t<r.length;t++)if(typeof r[t]!="number")throw new Error(`assertNumbers arguments[${t}] is not a number. ${typeof r[t]} == typeof ${r[t]}`);return!0}const qr=Math.PI;function vh(r,t,e){r.lArcFlag=r.lArcFlag===0?0:1,r.sweepFlag=r.sweepFlag===0?0:1;let{rX:i,rY:s}=r;const{x:n,y:o}=r;if(Math.abs(i)<1e-10||Math.abs(s)<1e-10){r.rX=0,r.rY=0,r.cX=(t+n)/2,r.cY=(e+o)/2,r.phi1=0,r.phi2=0;return}i=Math.abs(r.rX),s=Math.abs(r.rY);const a=r.xRot/180*qr,[l,h]=_h([(t-n)/2,(e-o)/2],-a),u=Math.pow(l,2)/Math.pow(i,2)+Math.pow(h,2)/Math.pow(s,2);1<u&&(i*=Math.sqrt(u),s*=Math.sqrt(u)),r.rX=i,r.rY=s;const c=Math.pow(i,2)*Math.pow(h,2)+Math.pow(s,2)*Math.pow(l,2),d=(r.lArcFlag!==r.sweepFlag?1:-1)*Math.sqrt(Math.max(0,(Math.pow(i,2)*Math.pow(s,2)-c)/c)),f=i*h/s*d,p=-s*l/i*d,m=_h([f,p],a);r.cX=m[0]+(t+n)/2,r.cY=m[1]+(e+o)/2,r.phi1=Math.atan2((h-p)/s,(l-f)/i),r.phi2=Math.atan2((-h-p)/s,(-l-f)/i),r.sweepFlag===0&&r.phi2>r.phi1&&(r.phi2-=2*qr),r.sweepFlag===1&&r.phi2<r.phi1&&(r.phi2+=2*qr),r.phi1*=180/qr,r.phi2*=180/qr}function Hp(r,t,e){Qe(r,t,e);const i=r*r+t*t-e*e;if(0>i)return[];if(i===0)return[[r*e/(r*r+t*t),t*e/(r*r+t*t)]];const s=Math.sqrt(i);return[[(r*e+t*s)/(r*r+t*t),(t*e-r*s)/(r*r+t*t)],[(r*e-t*s)/(r*r+t*t),(t*e+r*s)/(r*r+t*t)]]}const Ai=Math.PI/180;function $p(r,t,e){return(1-e)*r+e*t}function Vp(r,t,e,i){return r+Math.cos(i/180*qr)*t+Math.sin(i/180*qr)*e}function Xp(r,t,e,i){const n=t-r,o=e-t,a=i-e,l=3*n+3*a-6*o,h=(o-n)*6,u=3*n;return Math.abs(l)<1e-6?Math.abs(h)<1e-6?[]:[-u/h]:zA(h/l,u/l,1e-6)}function zp(r,t,e,i,s){const n=1-s,o=n*n*n,a=3*n*n*s,l=3*n*s*s,h=s*s*s;return r*o+t*a+e*l+i*h}function zA(r,t,e=1e-6){const i=r*r/4-t;if(i<-e)return[];if(i<=e)return[-r/2];const s=Math.sqrt(i);return[-(r/2)-s,-(r/2)+s]}function WA(r,t,e){r.cX||vh(r,t,e);const i=r.xRot/180*qr;if(Math.abs(r.rX)<1e-10||Math.abs(r.rY)<1e-10)return[{relative:r.relative,type:U.CURVE_TO,x1:t+(r.x-t)/3,y1:e+(r.y-e)/3,x2:t+2*(r.x-t)/3,y2:e+2*(r.y-e)/3,x:r.x,y:r.y}];const s=Math.min(r.phi1,r.phi2),n=Math.max(r.phi1,r.phi2),o=n-s,a=Math.ceil(o/90),l=new Array(a);let h=t,u=e;const c=(d,f)=>{const[p,m]=_h([d*r.rX,f*r.rY],i);return[r.cX+p,r.cY+m]};for(let d=0;d<a;d++){const f=$p(r.phi1,r.phi2,d/a),p=$p(r.phi1,r.phi2,(d+1)/a),m=p-f,y=4/3*Math.tan(m*Ai/4),_=Math.cos(f*Ai)-y*Math.sin(f*Ai),v=Math.sin(f*Ai)+y*Math.cos(f*Ai),g=Math.cos(p*Ai),x=Math.sin(p*Ai),b=g+y*x,S=x-y*g,w=c(_,v),T=c(b,S),N=c(g,x),F={relative:r.relative,type:U.CURVE_TO,x:N[0],y:N[1],x1:w[0],y1:w[1],x2:T[0],y2:T[1]};r.relative&&(F.x1-=h,F.y1-=u,F.x2-=h,F.y2-=u,F.x-=h,F.y-=u),h=N[0],u=N[1],l[d]=F}return l}function xh(r,t,e){const i=t[0]-r[0],s=t[1]-r[1],n=e[0]-r[0],o=e[1]-r[1],a=i*o-s*n;if(!(Math.abs(a)<1e-10))return!1;const h=i*n+s*o,u=i*i+s*s,c=n*n+o*o;return 0<=h&&h<=c&&u<=c}function YA(r,t=!0){if(r.length<2)return r;const e=qt.INFO((n,o,a)=>({...n,x:n.x??o,y:n.y??a,relative:n.relative??!1})),i=[];let s=[];for(const n of r){const o=e(n);o.type===U.MOVE_TO&&s.length>0&&(t?i.push(...Do(s)):i.unshift(...Do(s)),s=[]),s.push(o)}return s.length>0&&(t?i.push(...Do(s)):i.unshift(...Do(s))),i}function Do(r){var s;const t=((s=r[r.length-1])==null?void 0:s.type)===U.CLOSE_PATH,e=t?r.length-2:r.length-1,i=[{type:U.MOVE_TO,relative:!1,x:r[e].x,y:r[e].y}];for(let n=e;n>0;n--){const o=r[n],a=r[n-1];if(o.relative)throw new Error("Relative command are not supported convert first with `toAbs()`");switch(o.type){case U.HORIZ_LINE_TO:i.push({type:U.HORIZ_LINE_TO,relative:!1,x:a.x});break;case U.VERT_LINE_TO:i.push({type:U.VERT_LINE_TO,relative:!1,y:a.y});break;case U.LINE_TO:case U.MOVE_TO:i.push({type:U.LINE_TO,relative:!1,x:a.x,y:a.y});break;case U.CURVE_TO:i.push({type:U.CURVE_TO,relative:!1,x:a.x,y:a.y,x1:o.x2,y1:o.y2,x2:o.x1,y2:o.y1});break;case U.SMOOTH_CURVE_TO:throw new Error("Unsupported command: S (smooth cubic bezier)");case U.SMOOTH_QUAD_TO:throw new Error("Unsupported command: T (smooth quadratic bezier)");case U.ARC:throw new Error("Unsupported command: A (arc)");case U.QUAD_TO:throw new Error("Unsupported command: Q (quadratic bezier)")}}return t&&i.push({type:U.CLOSE_PATH}),i}function jA(r=1e13){Qe(r);function t(e){return Math.round(e*r)/r}return function(i){return"x1"in i&&typeof i.x1<"u"&&(i.x1=t(i.x1)),"y1"in i&&typeof i.y1<"u"&&(i.y1=t(i.y1)),"x2"in i&&typeof i.x2<"u"&&(i.x2=t(i.x2)),"y2"in i&&typeof i.y2<"u"&&(i.y2=t(i.y2)),"x"in i&&typeof i.x<"u"&&(i.x=t(i.x)),"y"in i&&typeof i.y<"u"&&(i.y=t(i.y)),"rX"in i&&typeof i.rX<"u"&&(i.rX=t(i.rX)),"rY"in i&&typeof i.rY<"u"&&(i.rY=t(i.rY)),i}}function Wp(){return Je((r,t,e)=>(r.relative&&(typeof r.x1<"u"&&(r.x1+=t),typeof r.y1<"u"&&(r.y1+=e),typeof r.x2<"u"&&(r.x2+=t),typeof r.y2<"u"&&(r.y2+=e),typeof r.x<"u"&&(r.x+=t),typeof r.y<"u"&&(r.y+=e),r.relative=!1),r))}function qA(){return Je((r,t,e)=>(r.relative||(typeof r.x1<"u"&&(r.x1-=t),typeof r.y1<"u"&&(r.y1-=e),typeof r.x2<"u"&&(r.x2-=t),typeof r.y2<"u"&&(r.y2-=e),typeof r.x<"u"&&(r.x-=t),typeof r.y<"u"&&(r.y-=e),r.relative=!0),r))}function KA(r=!0,t=!0,e=!0,i=!0){return Je((s,n,o,a,l)=>{if(isNaN(a)&&!(s.type&U.MOVE_TO))throw new Error("path must start with moveto");if(t&&s.type&U.HORIZ_LINE_TO&&(s.type=U.LINE_TO,s.y=s.relative?0:o),e&&s.type&U.VERT_LINE_TO&&(s.type=U.LINE_TO,s.x=s.relative?0:n),r&&s.type&U.CLOSE_PATH&&(s.type=U.LINE_TO,s.x=s.relative?a-n:a,s.y=s.relative?l-o:l),s.type&U.ARC&&(s.rX===0||s.rY===0)&&(s.type=U.LINE_TO,delete s.rX,delete s.rY,delete s.xRot,delete s.lArcFlag,delete s.sweepFlag),i&&s.type&U.QUAD_TO){const h=[n,o],u=s.relative?[n+s.x1,o+s.y1]:[s.x1,s.y1],c=s.relative?[n+s.x,o+s.y]:[s.x,s.y];xh(h,u,c)&&(s.type=U.LINE_TO,delete s.x1,delete s.y1)}if(i&&s.type&U.CURVE_TO){const h=[n,o],u=s.relative?[n+s.x1,o+s.y1]:[s.x1,s.y1],c=s.relative?[n+s.x2,o+s.y2]:[s.x2,s.y2],d=s.relative?[n+s.x,o+s.y]:[s.x,s.y];xh(h,u,d)&&xh(h,c,d)&&(s.type=U.LINE_TO,delete s.x1,delete s.y1,delete s.x2,delete s.y2)}return s})}function Yp(){let r=NaN,t=NaN,e=NaN,i=NaN;return Je((s,n,o)=>(s.type&U.SMOOTH_CURVE_TO&&(s.type=U.CURVE_TO,r=isNaN(r)?n:r,t=isNaN(t)?o:t,s.x1=s.relative?n-r:2*n-r,s.y1=s.relative?o-t:2*o-t),s.type&U.CURVE_TO?(r=s.relative?n+s.x2:s.x2,t=s.relative?o+s.y2:s.y2):(r=NaN,t=NaN),s.type&U.SMOOTH_QUAD_TO&&(s.type=U.QUAD_TO,e=isNaN(e)?n:e,i=isNaN(i)?o:i,s.x1=s.relative?n-e:2*n-e,s.y1=s.relative?o-i:2*o-i),s.type&U.QUAD_TO?(e=s.relative?n+s.x1:s.x1,i=s.relative?o+s.y1:s.y1):(e=NaN,i=NaN),s))}function jp(){let r=NaN,t=NaN;return Je((e,i,s)=>{if(e.type&U.SMOOTH_QUAD_TO&&(e.type=U.QUAD_TO,r=isNaN(r)?i:r,t=isNaN(t)?s:t,e.x1=e.relative?i-r:2*i-r,e.y1=e.relative?s-t:2*s-t),e.type&U.QUAD_TO){r=e.relative?i+e.x1:e.x1,t=e.relative?s+e.y1:e.y1;const n=e.x1,o=e.y1;e.type=U.CURVE_TO,e.x1=((e.relative?0:i)+n*2)/3,e.y1=((e.relative?0:s)+o*2)/3,e.x2=(e.x+n*2)/3,e.y2=(e.y+o*2)/3}else r=NaN,t=NaN;return e})}function Je(r){let t=0,e=0,i=NaN,s=NaN;return function(o){if(isNaN(i)&&!(o.type&U.MOVE_TO))throw new Error("path must start with moveto");const a=r(o,t,e,i,s);return o.type&U.CLOSE_PATH&&(t=i,e=s),"x"in o&&typeof o.x<"u"&&(t=o.relative?t+o.x:o.x),"y"in o&&typeof o.y<"u"&&(e=o.relative?e+o.y:o.y),o.type&U.MOVE_TO&&(i=t,s=e),a}}function ZA(r=0){Qe(r);let t=NaN,e=NaN,i=NaN,s=NaN;return Je((n,o,a,l,h)=>{const u=Math.abs;let c=!1,d=0,f=0;if(n.type&U.SMOOTH_CURVE_TO&&(d=isNaN(t)?0:o-t,f=isNaN(e)?0:a-e),n.type&(U.CURVE_TO|U.SMOOTH_CURVE_TO)?(t=n.relative?o+n.x2:n.x2,e=n.relative?a+n.y2:n.y2):(t=NaN,e=NaN),n.type&U.SMOOTH_QUAD_TO?(i=isNaN(i)?o:2*o-i,s=isNaN(s)?a:2*a-s):n.type&U.QUAD_TO?(i=n.relative?o+n.x1:n.x1,s=n.relative?a+n.y1:n.y2):(i=NaN,s=NaN),n.type&U.LINE_COMMANDS||n.type&U.ARC&&(n.rX===0||n.rY===0||!n.lArcFlag)||n.type&U.CURVE_TO||n.type&U.SMOOTH_CURVE_TO||n.type&U.QUAD_TO||n.type&U.SMOOTH_QUAD_TO){const p=typeof n.x>"u"?0:n.relative?n.x:n.x-o,m=typeof n.y>"u"?0:n.relative?n.y:n.y-a;d=isNaN(i)?typeof n.x1>"u"?d:n.relative?n.x:n.x1-o:i-o,f=isNaN(s)?typeof n.y1>"u"?f:n.relative?n.y:n.y1-a:s-a;const y=typeof n.x2>"u"?0:n.relative?n.x:n.x2-o,_=typeof n.y2>"u"?0:n.relative?n.y:n.y2-a;u(p)<=r&&u(m)<=r&&u(d)<=r&&u(f)<=r&&u(y)<=r&&u(_)<=r&&(c=!0)}return n.type&U.CLOSE_PATH&&u(o-l)<=r&&u(a-h)<=r&&(c=!0),c?[]:n})}function Kr(r,t,e,i,s,n){return Qe(r,t,e,i,s,n),Je((o,a,l,h)=>{const u=o.x1,c=o.x2,d=o.relative&&!isNaN(h),f=typeof o.x<"u"?o.x:d?0:a,p=typeof o.y<"u"?o.y:d?0:l;o.type&U.HORIZ_LINE_TO&&t!==0&&(o.type=U.LINE_TO,o.y=o.relative?0:l),o.type&U.VERT_LINE_TO&&e!==0&&(o.type=U.LINE_TO,o.x=o.relative?0:a),typeof o.x<"u"&&(o.x=o.x*r+p*e+(d?0:s)),typeof o.y<"u"&&(o.y=f*t+o.y*i+(d?0:n)),typeof o.x1<"u"&&(o.x1=o.x1*r+o.y1*e+(d?0:s)),typeof o.y1<"u"&&(o.y1=u*t+o.y1*i+(d?0:n)),typeof o.x2<"u"&&(o.x2=o.x2*r+o.y2*e+(d?0:s)),typeof o.y2<"u"&&(o.y2=c*t+o.y2*i+(d?0:n));function m(_){return _*_}const y=r*i-t*e;if(typeof o.xRot<"u"&&(r!==1||t!==0||e!==0||i!==1))if(y===0)delete o.rX,delete o.rY,delete o.xRot,delete o.lArcFlag,delete o.sweepFlag,o.type=U.LINE_TO;else{const _=o.xRot*Math.PI/180,v=Math.sin(_),g=Math.cos(_),x=1/m(o.rX),b=1/m(o.rY),S=m(g)*x+m(v)*b,w=2*v*g*(x-b),T=m(v)*x+m(g)*b,N=S*i*i-w*t*i+T*t*t,F=w*(r*i+t*e)-2*(S*e*i+T*r*t),z=S*e*e-w*r*e+T*r*r,C=(Math.atan2(F,N-z)+Math.PI)%Math.PI/2,E=Math.sin(C),I=Math.cos(C);o.rX=Math.abs(y)/Math.sqrt(N*m(I)+F*E*I+z*m(E)),o.rY=Math.abs(y)/Math.sqrt(N*m(E)-F*E*I+z*m(I)),o.xRot=C*180/Math.PI}return typeof o.sweepFlag<"u"&&0>y&&(o.sweepFlag=+!o.sweepFlag),o})}function QA(r,t=0,e=0){Qe(r,t,e);const i=Math.sin(r),s=Math.cos(r);return Kr(s,i,-i,s,t-t*s+e*i,e-t*i-e*s)}function JA(r,t=0){return Qe(r,t),Kr(1,0,0,1,r,t)}function tS(r,t=r){return Qe(r,t),Kr(r,0,0,t,0,0)}function eS(r){return Qe(r),Kr(1,0,Math.tan(r),1,0,0)}function rS(r){return Qe(r),Kr(1,Math.tan(r),0,1,0,0)}function iS(r=0){return Qe(r),Kr(-1,0,0,1,r,0)}function sS(r=0){return Qe(r),Kr(1,0,0,-1,0,r)}function nS(){return Je((r,t,e)=>U.ARC===r.type?WA(r,r.relative?0:t,r.relative?0:e):r)}function oS(){return Je((r,t,e)=>(r.relative&&(t=0,e=0),U.ARC===r.type&&vh(r,t,e),r))}function qp(){return r=>({...r})}function aS(){const r=qp(),t=Wp(),e=jp(),i=Yp(),s=Je((n,o,a)=>{const l=i(e(t(r(n))));function h(c){c>s.maxX&&(s.maxX=c),c<s.minX&&(s.minX=c)}function u(c){c>s.maxY&&(s.maxY=c),c<s.minY&&(s.minY=c)}if(l.type&U.DRAWING_COMMANDS&&(h(o),u(a)),l.type&U.HORIZ_LINE_TO&&h(l.x),l.type&U.VERT_LINE_TO&&u(l.y),l.type&U.LINE_TO&&(h(l.x),u(l.y)),l.type&U.CURVE_TO){h(l.x),u(l.y);const c=Xp(o,l.x1,l.x2,l.x);for(const f of c)0<f&&1>f&&h(zp(o,l.x1,l.x2,l.x,f));const d=Xp(a,l.y1,l.y2,l.y);for(const f of d)0<f&&1>f&&u(zp(a,l.y1,l.y2,l.y,f))}if(l.type&U.ARC){h(l.x),u(l.y),vh(l,o,a);const c=l.xRot/180*Math.PI,d=Math.cos(c)*l.rX,f=Math.sin(c)*l.rX,p=-Math.sin(c)*l.rY,m=Math.cos(c)*l.rY,[y,_]=l.phi1<l.phi2?[l.phi1,l.phi2]:-180>l.phi2?[l.phi2+360,l.phi1+360]:[l.phi2,l.phi1],v=([b,S])=>{const T=Math.atan2(S,b)*180/Math.PI;return T<y?T+360:T},g=Hp(p,-d,0).map(v);for(const b of g)b>y&&b<_&&h(Vp(l.cX,d,p,b));const x=Hp(m,-f,0).map(v);for(const b of x)b>y&&b<_&&u(Vp(l.cY,f,m,b))}return n});return s.minX=1/0,s.maxX=-1/0,s.minY=1/0,s.maxY=-1/0,s}const qt={ROUND:jA,TO_ABS:Wp,TO_REL:qA,NORMALIZE_HVZ:KA,NORMALIZE_ST:Yp,QT_TO_C:jp,INFO:Je,SANITIZE:ZA,MATRIX:Kr,ROTATE:QA,TRANSLATE:JA,SCALE:tS,SKEW_X:eS,SKEW_Y:rS,X_AXIS_SYMMETRY:iS,Y_AXIS_SYMMETRY:sS,A_TO_C:nS,ANNOTATE_ARCS:oS,CLONE:qp,CALCULATE_BOUNDS:aS,REVERSE_PATH:YA};class Kp{round(t){return this.transform(qt.ROUND(t))}toAbs(){return this.transform(qt.TO_ABS())}toRel(){return this.transform(qt.TO_REL())}normalizeHVZ(t,e,i){return this.transform(qt.NORMALIZE_HVZ(t,e,i))}normalizeST(){return this.transform(qt.NORMALIZE_ST())}qtToC(){return this.transform(qt.QT_TO_C())}aToC(){return this.transform(qt.A_TO_C())}sanitize(t){return this.transform(qt.SANITIZE(t))}translate(t,e){return this.transform(qt.TRANSLATE(t,e))}scale(t,e){return this.transform(qt.SCALE(t,e))}rotate(t,e,i){return this.transform(qt.ROTATE(t,e,i))}matrix(t,e,i,s,n,o){return this.transform(qt.MATRIX(t,e,i,s,n,o))}skewX(t){return this.transform(qt.SKEW_X(t))}skewY(t){return this.transform(qt.SKEW_Y(t))}xSymmetry(t){return this.transform(qt.X_AXIS_SYMMETRY(t))}ySymmetry(t){return this.transform(qt.Y_AXIS_SYMMETRY(t))}annotateArcs(){return this.transform(qt.ANNOTATE_ARCS())}}const lS=r=>r===" "||r===" "||r==="\r"||r===`
|
|
1148
|
+
}`,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=ub(t)),typeof t=="number"?hb(t):t}dropShadowToCSS(){let t=this.normalizeColor(this.dropShadowColor);const e=this.dropShadowAlpha,i=Math.round(Math.cos(this.dropShadowAngle)*this.dropShadowDistance),s=Math.round(Math.sin(this.dropShadowAngle)*this.dropShadowDistance);t.startsWith("#")&&e<1&&(t+=(e*255|0).toString(16).padStart(2,"0"));const n=`${i}px ${s}px`;return this.dropShadowBlur>0?`text-shadow: ${n} ${this.dropShadowBlur}px ${t}`:`text-shadow: ${n} ${t}`}reset(){Object.assign(this,cs.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}};dh.availableFonts={},dh.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 fh=dh;const Ro=class ds extends ts{constructor(t="",e={}){super(Z.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,s=Z.from(i,{scaleMode:j.SCALE_MODE,resourceOptions:{autoLoad:!1}});s.orig=new pt,s.trim=new pt,this.texture=s;const n="http://www.w3.org/2000/svg",o="http://www.w3.org/1999/xhtml",a=document.createElementNS(n,"svg"),l=document.createElementNS(n,"foreignObject"),h=document.createElementNS(o,"div"),u=document.createElementNS(o,"style");l.setAttribute("width","10000"),l.setAttribute("height","10000"),l.style.overflow="hidden",a.appendChild(l),this.maxWidth=ds.defaultMaxWidth,this.maxHeight=ds.defaultMaxHeight,this._domElement=h,this._styleElement=u,this._svgRoot=a,this._foreignObject=l,this._foreignObject.appendChild(u),this._foreignObject.appendChild(h),this._image=i,this._loadImage=new Image,this._autoResolution=ds.defaultAutoResolution,this._resolution=ds.defaultResolution??j.RESOLUTION,this.text=t,this.style=e}measureText(t){var u,c;const{text:e,style:i,resolution:s}=Object.assign({text:this._text,style:this._style,resolution:this._resolution},t);Object.assign(this._domElement,{innerHTML:e,style:i.toCSS(s)}),this._styleElement.textContent=i.toGlobalCSS(),document.body.appendChild(this._svgRoot);const n=this._domElement.getBoundingClientRect();this._svgRoot.remove();const{width:o,height:a}=n;(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:(u=this._style)==null?void 0:u.toCSS(s)}),this._styleElement.textContent=(c=this._style)==null?void 0:c.toGlobalCSS()),{width:l+i.padding*2,height:h+i.padding*2}}async updateText(t=!0){const{style:e,_image:i,_loadImage:s}=this;if(this.localStyleID!==e.styleID&&(this.dirty=!0,this.localStyleID=e.styleID),!this.dirty&&t)return;const{width:n,height:o}=this.measureText();i.width=s.width=Math.ceil(Math.max(1,n)),i.height=s.height=Math.ceil(Math.max(1,o)),this._updateID++;const a=this._updateID;await new Promise(l=>{s.onload=async()=>{if(a<this._updateID){l();return}await e.onBeforeDraw(),i.src=s.src,s.onload=null,s.src="",this.updateTexture(),l()};const h=new XMLSerializer().serializeToString(this._svgRoot);s.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(h)}`})}get source(){return this._image}updateTexture(){const{style:t,texture:e,_image:i,resolution:s}=this,{padding:n}=t,{baseTexture:o}=e;e.trim.width=e._frame.width=i.width/s,e.trim.height=e._frame.height=i.height/s,e.trim.x=-n,e.trim.y=-n,e.orig.width=e._frame.width-n*2,e.orig.height=e._frame.height-n*2,this._onTextureUpdate(),o.setRealSize(i.width,i.height,s),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,s,n,o,a;typeof t=="boolean"&&(t={children:t}),t=Object.assign({},ds.defaultDestroyOptions,t),super.destroy(t);const e=null;this.ownsStyle&&((i=this._style)==null||i.cleanFonts()),this._style=e,(s=this._svgRoot)==null||s.remove(),this._svgRoot=e,(n=this._domElement)==null||n.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=Fr(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=Fr(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 fh?(this.ownsStyle=!1,this._style=t):t instanceof Xr?(console.warn("[HTMLText] Cloning TextStyle, if this is not what you want, use HTMLTextStyle"),this.ownsStyle=!0,this._style=fh.from(t)):(this.ownsStyle=!0,this._style=new fh(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," ")}};Ro.defaultDestroyOptions={texture:!0,children:!1,baseTexture:!0},Ro.defaultMaxWidth=2024,Ro.defaultMaxHeight=2024,Ro.defaultAutoResolution=!0;const EA=16777215,TA=.25,wA=16777215,AA=1,SA=1.5;let Yr=!1,Ys;const ph=r=>{const t={tint:r!=null&&r.fill?new wt(r.fill).toNumber():EA,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 wt(r==null?void 0:r.fill).alpha:TA},e={tint:r!=null&&r.stroke?new wt(r.stroke).toNumber():wA,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 wt(r==null?void 0:r.stroke).alpha:AA,lineWidth:(r==null?void 0:r.strokeWidth)===void 0?SA:r.strokeWidth};return{fillStyle:t,strokeStyle:e}},Mo=r=>(t,e,i)=>{const{fillStyle:s,strokeStyle:n}=ph(i),o=new Ws;o.beginFill(16777215),r(e,o),o.endFill(),o.tint=s.tint,o.alpha=s.alpha,t.addChild(o);const a=new Ws,l=n.lineWidth===1?1:n.lineWidth/Ys;return a.lineStyle(l,16777215,1,.5,n.lineWidth===1),r(e,a),a.tint=n.tint||16777215,a.alpha=n.alpha,t.addChild(a),{fill:o,stroke:a,strokeWidth:n.lineWidth}},CA=Mo((r,t)=>{const{x:e,y:i,w:s,h:n}=r.geometry;t.drawRect(e,i,s,n)}),IA=Mo((r,t)=>{const{cx:e,cy:i,rx:s,ry:n}=r.geometry;t.drawEllipse(e,i,s,n)}),RA=Mo((r,t)=>{const e=r.geometry.points.reduce((i,s)=>[...i,...s],[]);t.drawPolygon(e)}),MA=Mo((r,t)=>{const e=i=>i.points.reduce((s,n)=>[...s,...n],[]);r.geometry.polygons.forEach(i=>{const[s,...n]=i.rings;t.drawPolygon(e(s)),n.forEach(o=>{t.beginHole(),t.drawPolygon(e(o)),t.endHole()})})}),Up=r=>{const t=r.viewport.getContainerSize().x;return r.viewport.getZoom(!0)*t/r.world.getContentFactor()},kp=(r,t,e,i)=>()=>{const s=r.viewport.viewportToImageRectangle(r.viewport.getBounds(!0)),n=Up(r);(n!==Ys||!Yr)&&(Yr=!0,e.forEach(({stroke:d,strokeWidth:f})=>{const{lineStyle:p}=d.geometry.graphicsData[0];f>1?(Yr=n===Ys,p.width=f/n,p.native=!1,d.geometry.invalidate()):f===1&&!p.native&&(p.width=1,p.native=!0,d.geometry.invalidate())})),Ys=n;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+s.x*n:-s.x*n,h=-s.y*n;let u,c;a>0&&a<=Math.PI/2?(u=s.height*n,c=0):a>Math.PI/2&&a<=Math.PI?(u=s.width*n,c=s.height*n):a>Math.PI&&a<=Math.PI*1.5?(u=0,c=s.width*n):(u=0,c=0),t.position.x=u+l*Math.cos(a)-h*Math.sin(a),t.position.y=c+l*Math.sin(a)+h*Math.cos(a),t.scale.set(o?-n:n,n),t.rotation=a,i.render(t)},PA=(r,t)=>{const e=new Ws,i=Lf({width:t.width,height:t.height,backgroundAlpha:0,view:t,antialias:!0,resolution:2}),s=new Map;let n=new Set,o,a;Ys=Up(r);const l=(g,x)=>{Yr=!1;const{selector:b}=g.target,S=typeof a=="function"?a(g,x):a;let w;b.type===vt.RECTANGLE?w=CA(e,b,S):b.type===vt.POLYGON?w=RA(e,b,S):b.type===vt.ELLIPSE?w=IA(e,b,S):b.type===vt.MULTIPOLYGLON?w=MA(e,b,S):console.warn(`Unsupported shape type: ${b.type}`),w&&s.set(g.id,{annotation:g,...w})},h=g=>{const x=s.get(g.id);x&&(s.delete(g.id),x.fill.destroy(),x.stroke.destroy())},u=(g,x,b)=>{Yr=!1;const S=s.get(g.id);S&&(s.delete(g.id),S.fill.destroy(),S.stroke.destroy(),l(x,b))},c=(g,x)=>{const b=s.get(g);b&&(s.delete(g),b.fill.destroy(),b.stroke.destroy(),l(b.annotation,x))},d=(g,x)=>{i.resize(g,x),i.render(e)},f=g=>{Yr=!1;const{children:x}=e;s.forEach(({fill:b,stroke:S,annotation:w})=>{const T=g?n.has(w.id)||g(w):!0;T&&!x.includes(b)?(e.addChild(b),e.addChild(S)):!T&&x.includes(b)&&(e.removeChild(b),e.removeChild(S))}),i.render(e)},p=g=>{o!==g&&(o&&c(o,{selected:n.has(o)}),g&&c(g,{selected:n.has(g),hovered:!0}),o=g,i.render(e))},m=g=>{const x=g.selected.map(w=>w.id),b=x.filter(w=>!n.has(w)),S=[...n].filter(w=>!x.includes(w));[...b,...S].forEach(w=>c(w,{selected:x.includes(w),hovered:w===o})),n=new Set(x),i.render(e)},y=g=>{if(typeof g=="function")s.forEach(({annotation:x,fill:b,stroke:S,strokeWidth:w},T)=>{w>1&&(Yr=!1);const N={selected:n.has(x.id),hovered:o===x.id},{fillStyle:F,strokeStyle:z}=ph(g(x,N));b.tint=F.tint,b.alpha=F.alpha,S.tint=z.tint||16777215,S.alpha=z.alpha,s.set(x.id,{annotation:x,fill:b,stroke:S,strokeWidth:z.lineWidth})});else{const{fillStyle:x,strokeStyle:b}=ph(g);b.lineWidth>1&&(Yr=!1),s.forEach(({annotation:S,fill:w,stroke:T,strokeWidth:N},F)=>{w.tint=x.tint,w.alpha=x.alpha,T.tint=b.tint||16777215,T.alpha=b.alpha,s.set(S.id,{annotation:S,fill:w,stroke:T,strokeWidth:b.lineWidth})})}a=g,i.render(e),kp(r,e,s,i)()},_=g=>{g?t.classList.remove("hidden"):t.classList.add("hidden")};return{addAnnotation:l,destroy:()=>i.destroy(),redraw:kp(r,e,s,i),removeAnnotation:h,resize:d,setFilter:f,setHovered:p,setSelected:m,setStyle:y,setVisible:_,updateAnnotation:u}};function OA(r,t,e){let i,s,{filter:n}=t,{state:o}=t,{style:a}=t,{viewer:l}=t,{visible:h=!0}=t;const{store:u,hover:c,selection:d,viewport:f}=o;fn(r,c,S=>e(11,i=S)),fn(r,d,S=>e(8,s=S));const p=yn();let m,y;const _=S=>{const w=new de.Point(S.x,S.y),{x:T,y:N}=l.viewport.pointFromPixel(w);return l.viewport.viewportToImageCoordinates(T,N)},v=S=>{const{x:w,y:T}=S.position;y={x:w,y:T}},g=S=>w=>{const{x:T,y:N}=_(new de.Point(w.offsetX,w.offsetY)),F=u.getAt(T,N);F&&(!n||n(F))?(S.classList.add("hover"),i!==F.id&&(c.set(F.id),m.setHovered(F.id))):(S.classList.remove("hover"),i&&(c.set(void 0),m.setHovered(void 0)))},x=S=>{if(!y)return;const w=S.originalEvent,{x:T,y:N}=S.position,F=T-y.x,z=N-y.y;if(Math.sqrt(F*F+z*z)<5){const{x:E,y:I}=_(S.position),P=u.getAt(E,I);P?(!n||n(P))&&p("click",{originalEvent:w,annotation:P}):p("click",{originalEvent:w})}y=void 0};let b;return gn(()=>{var P;const{offsetWidth:S,offsetHeight:w}=l.canvas,T=document.createElement("canvas");T.width=S,T.height=w,T.className="a9s-gl-canvas",(P=l.element.querySelector(".openseadragon-canvas"))==null||P.appendChild(T),e(7,m=PA(l,T));const N=g(T);T.addEventListener("pointermove",N);const F=new ResizeObserver(H=>{try{const{width:k,height:G}=H[0].contentRect;T.width=k,T.height=G,m.resize(k,G)}catch{console.warn("WebGL canvas already disposed")}});F.observe(T);const z=()=>{const H=l.viewport.getBounds();b=l.viewport.viewportToImageRectangle(H);const{x:k,y:G,width:st,height:M}=b,L=u.getIntersecting(k,G,st,M);f.set(L.map(V=>V.id))};l.addHandler("canvas-press",v),l.addHandler("canvas-release",x),l.addHandler("update-viewport",m.redraw),l.addHandler("animation-finish",z);const C=H=>H.filter(k=>Ge(k)),E=H=>Ge(H.oldValue)&&Ge(H.newValue),I=H=>{const{created:k,updated:G,deleted:st}=H.changes;if(C(k||[]).forEach(M=>m.addAnnotation(M)),C(st||[]).forEach(M=>m.removeAnnotation(M)),(G||[]).filter(M=>E(M)).forEach(({oldValue:M,newValue:L})=>m.updateAnnotation(M,L)),b){const{x:M,y:L,width:V,height:rt}=b,Q=u.getIntersecting(M,L,V,rt);f.set(Q.map(X=>X.id))}else f.set(u.all().map(M=>M.id));m.redraw()};return u.observe(I),()=>{var H;T.removeEventListener("pointermove",N),F.disconnect(),l.removeHandler("canvas-press",v),l.removeHandler("canvas-release",x),l.removeHandler("update-viewport",m.redraw),l.removeHandler("animation-finish",z),u.unobserve(I),m.destroy(),(H=T.parentNode)==null||H.removeChild(T)}}),r.$$set=S=>{"filter"in S&&e(2,n=S.filter),"state"in S&&e(3,o=S.state),"style"in S&&e(4,a=S.style),"viewer"in S&&e(5,l=S.viewer),"visible"in S&&e(6,h=S.visible)},r.$$.update=()=>{r.$$.dirty&132&&(m==null||m.setFilter(n)),r.$$.dirty&384&&(m==null||m.setSelected(s)),r.$$.dirty&144&&(m==null||m.setStyle(a)),r.$$.dirty&192&&(m==null||m.setVisible(h))},[c,d,n,o,a,l,h,m,s]}class NA extends re{constructor(t){super(),ee(this,t,OA,null,Wt,{filter:2,state:3,style:4,viewer:5,visible:6})}}const ce=[];for(let r=0;r<256;++r)ce.push((r+256).toString(16).slice(1));function DA(r,t=0){return(ce[r[t+0]]+ce[r[t+1]]+ce[r[t+2]]+ce[r[t+3]]+"-"+ce[r[t+4]]+ce[r[t+5]]+"-"+ce[r[t+6]]+ce[r[t+7]]+"-"+ce[r[t+8]]+ce[r[t+9]]+"-"+ce[r[t+10]]+ce[r[t+11]]+ce[r[t+12]]+ce[r[t+13]]+ce[r[t+14]]+ce[r[t+15]]).toLowerCase()}let mh;const LA=new Uint8Array(16);function BA(){if(!mh){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");mh=crypto.getRandomValues.bind(crypto)}return mh(LA)}const Gp={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function FA(r,t,e){var s;if(Gp.randomUUID&&!r)return Gp.randomUUID();r=r||{};const i=r.random??((s=r.rng)==null?void 0:s.call(r))??BA();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=i[6]&15|64,i[8]=i[8]&63|128,DA(i)}var jr=(r=>(r.ELLIPSE="ELLIPSE",r.MULTIPOLYGLON="MULTIPOLYGON",r.POLYGON="POLYGON",r.RECTANGLE="RECTANGLE",r))(jr||{});const Po=(r,t)=>t,Oo=r=>{let t=1/0,e=1/0,i=-1/0,s=-1/0;return r.forEach(([n,o])=>{t=Math.min(t,n),e=Math.min(e,o),i=Math.max(i,n),s=Math.max(s,o)}),{minX:t,minY:e,maxX:i,maxY:s}},gh=r=>{let t=0,e=r.length-1;for(let i=0;i<r.length;i++)t+=(r[e][0]+r[i][0])*(r[e][1]-r[i][1]),e=i;return Math.abs(.5*t)},yh=(r,t,e)=>{let i=!1;for(let s=0,n=r.length-1;s<r.length;n=s++){const o=r[s][0],a=r[s][1],l=r[n][0],h=r[n][1];a>e!=h>e&&t<(l-o)*(e-a)/(h-a)+o&&(i=!i)}return i},UA=(r,t=!0)=>{let e="M ";return r.forEach(([i,s],n)=>{n===0?e+=`${i},${s}`:e+=` L ${i},${s}`}),t&&(e+=" Z"),e},kA={area:r=>Math.PI*r.geometry.rx*r.geometry.ry,intersects:(r,t,e)=>{const{cx:i,cy:s,rx:n,ry:o}=r.geometry,a=0,l=Math.cos(a),h=Math.sin(a),u=t-i,c=e-s,d=l*u+h*c,f=h*u-l*c;return d*d/(n*n)+f*f/(o*o)<=1}};Po(jr.ELLIPSE,kA);const GA={area:r=>{const{polygons:t}=r.geometry;return t.reduce((e,i)=>{const[s,...n]=i.rings,o=gh(s.points),a=n.reduce((l,h)=>l+gh(h.points),0);return e+o-a},0)},intersects:(r,t,e)=>{const{polygons:i}=r.geometry;for(const s of i){const[n,...o]=s.rings;if(yh(n.points,t,e)){let a=!1;for(const l of o)if(yh(l.points,t,e)){a=!0;break}if(!a)return!0}}return!1}},HA=r=>{const t=r.reduce((e,i)=>[...e,...i.rings[0].points],[]);return Oo(t)},No=r=>r.rings.map(e=>UA(e.points)).join(" ");Po(jr.MULTIPOLYGLON,GA);const $A={area:r=>{const t=r.geometry.points;return gh(t)},intersects:(r,t,e)=>{const i=r.geometry.points;return yh(i,t,e)}};Po(jr.POLYGON,$A);const VA={area:r=>r.geometry.w*r.geometry.h,intersects:(r,t,e)=>t>=r.geometry.x&&t<=r.geometry.x+r.geometry.w&&e>=r.geometry.y&&e<=r.geometry.y+r.geometry.h};Po(jr.RECTANGLE,VA);const jt=" ";function XA(r){let t="";Array.isArray(r)||(r=[r]);for(let e=0;e<r.length;e++){const i=r[e];if(i.type===U.CLOSE_PATH)t+="z";else if(i.type===U.HORIZ_LINE_TO)t+=(i.relative?"h":"H")+i.x;else if(i.type===U.VERT_LINE_TO)t+=(i.relative?"v":"V")+i.y;else if(i.type===U.MOVE_TO)t+=(i.relative?"m":"M")+i.x+jt+i.y;else if(i.type===U.LINE_TO)t+=(i.relative?"l":"L")+i.x+jt+i.y;else if(i.type===U.CURVE_TO)t+=(i.relative?"c":"C")+i.x1+jt+i.y1+jt+i.x2+jt+i.y2+jt+i.x+jt+i.y;else if(i.type===U.SMOOTH_CURVE_TO)t+=(i.relative?"s":"S")+i.x2+jt+i.y2+jt+i.x+jt+i.y;else if(i.type===U.QUAD_TO)t+=(i.relative?"q":"Q")+i.x1+jt+i.y1+jt+i.x+jt+i.y;else if(i.type===U.SMOOTH_QUAD_TO)t+=(i.relative?"t":"T")+i.x+jt+i.y;else if(i.type===U.ARC)t+=(i.relative?"a":"A")+i.rX+jt+i.rY+jt+i.xRot+jt+ +i.lArcFlag+jt+ +i.sweepFlag+jt+i.x+jt+i.y;else throw new Error(`Unexpected command type "${i==null?void 0:i.type}" at index ${e}.`)}return t}function _h([r,t],e){return[r*Math.cos(e)-t*Math.sin(e),r*Math.sin(e)+t*Math.cos(e)]}function Qe(...r){for(let t=0;t<r.length;t++)if(typeof r[t]!="number")throw new Error(`assertNumbers arguments[${t}] is not a number. ${typeof r[t]} == typeof ${r[t]}`);return!0}const qr=Math.PI;function vh(r,t,e){r.lArcFlag=r.lArcFlag===0?0:1,r.sweepFlag=r.sweepFlag===0?0:1;let{rX:i,rY:s}=r;const{x:n,y:o}=r;if(Math.abs(i)<1e-10||Math.abs(s)<1e-10){r.rX=0,r.rY=0,r.cX=(t+n)/2,r.cY=(e+o)/2,r.phi1=0,r.phi2=0;return}i=Math.abs(r.rX),s=Math.abs(r.rY);const a=r.xRot/180*qr,[l,h]=_h([(t-n)/2,(e-o)/2],-a),u=Math.pow(l,2)/Math.pow(i,2)+Math.pow(h,2)/Math.pow(s,2);1<u&&(i*=Math.sqrt(u),s*=Math.sqrt(u)),r.rX=i,r.rY=s;const c=Math.pow(i,2)*Math.pow(h,2)+Math.pow(s,2)*Math.pow(l,2),d=(r.lArcFlag!==r.sweepFlag?1:-1)*Math.sqrt(Math.max(0,(Math.pow(i,2)*Math.pow(s,2)-c)/c)),f=i*h/s*d,p=-s*l/i*d,m=_h([f,p],a);r.cX=m[0]+(t+n)/2,r.cY=m[1]+(e+o)/2,r.phi1=Math.atan2((h-p)/s,(l-f)/i),r.phi2=Math.atan2((-h-p)/s,(-l-f)/i),r.sweepFlag===0&&r.phi2>r.phi1&&(r.phi2-=2*qr),r.sweepFlag===1&&r.phi2<r.phi1&&(r.phi2+=2*qr),r.phi1*=180/qr,r.phi2*=180/qr}function Hp(r,t,e){Qe(r,t,e);const i=r*r+t*t-e*e;if(0>i)return[];if(i===0)return[[r*e/(r*r+t*t),t*e/(r*r+t*t)]];const s=Math.sqrt(i);return[[(r*e+t*s)/(r*r+t*t),(t*e-r*s)/(r*r+t*t)],[(r*e-t*s)/(r*r+t*t),(t*e+r*s)/(r*r+t*t)]]}const Ai=Math.PI/180;function $p(r,t,e){return(1-e)*r+e*t}function Vp(r,t,e,i){return r+Math.cos(i/180*qr)*t+Math.sin(i/180*qr)*e}function Xp(r,t,e,i){const n=t-r,o=e-t,a=i-e,l=3*n+3*a-6*o,h=(o-n)*6,u=3*n;return Math.abs(l)<1e-6?Math.abs(h)<1e-6?[]:[-u/h]:zA(h/l,u/l,1e-6)}function zp(r,t,e,i,s){const n=1-s,o=n*n*n,a=3*n*n*s,l=3*n*s*s,h=s*s*s;return r*o+t*a+e*l+i*h}function zA(r,t,e=1e-6){const i=r*r/4-t;if(i<-e)return[];if(i<=e)return[-r/2];const s=Math.sqrt(i);return[-(r/2)-s,-(r/2)+s]}function WA(r,t,e){r.cX||vh(r,t,e);const i=r.xRot/180*qr;if(Math.abs(r.rX)<1e-10||Math.abs(r.rY)<1e-10)return[{relative:r.relative,type:U.CURVE_TO,x1:t+(r.x-t)/3,y1:e+(r.y-e)/3,x2:t+2*(r.x-t)/3,y2:e+2*(r.y-e)/3,x:r.x,y:r.y}];const s=Math.min(r.phi1,r.phi2),n=Math.max(r.phi1,r.phi2),o=n-s,a=Math.ceil(o/90),l=new Array(a);let h=t,u=e;const c=(d,f)=>{const[p,m]=_h([d*r.rX,f*r.rY],i);return[r.cX+p,r.cY+m]};for(let d=0;d<a;d++){const f=$p(r.phi1,r.phi2,d/a),p=$p(r.phi1,r.phi2,(d+1)/a),m=p-f,y=4/3*Math.tan(m*Ai/4),_=Math.cos(f*Ai)-y*Math.sin(f*Ai),v=Math.sin(f*Ai)+y*Math.cos(f*Ai),g=Math.cos(p*Ai),x=Math.sin(p*Ai),b=g+y*x,S=x-y*g,w=c(_,v),T=c(b,S),N=c(g,x),F={relative:r.relative,type:U.CURVE_TO,x:N[0],y:N[1],x1:w[0],y1:w[1],x2:T[0],y2:T[1]};r.relative&&(F.x1-=h,F.y1-=u,F.x2-=h,F.y2-=u,F.x-=h,F.y-=u),h=N[0],u=N[1],l[d]=F}return l}function xh(r,t,e){const i=t[0]-r[0],s=t[1]-r[1],n=e[0]-r[0],o=e[1]-r[1],a=i*o-s*n;if(!(Math.abs(a)<1e-10))return!1;const h=i*n+s*o,u=i*i+s*s,c=n*n+o*o;return 0<=h&&h<=c&&u<=c}function YA(r,t=!0){if(r.length<2)return r;const e=qt.INFO((n,o,a)=>({...n,x:n.x??o,y:n.y??a,relative:n.relative??!1})),i=[];let s=[];for(const n of r){const o=e(n);o.type===U.MOVE_TO&&s.length>0&&(t?i.push(...Do(s)):i.unshift(...Do(s)),s=[]),s.push(o)}return s.length>0&&(t?i.push(...Do(s)):i.unshift(...Do(s))),i}function Do(r){var s;const t=((s=r[r.length-1])==null?void 0:s.type)===U.CLOSE_PATH,e=t?r.length-2:r.length-1,i=[{type:U.MOVE_TO,relative:!1,x:r[e].x,y:r[e].y}];for(let n=e;n>0;n--){const o=r[n],a=r[n-1];if(o.relative)throw new Error("Relative command are not supported convert first with `toAbs()`");switch(o.type){case U.HORIZ_LINE_TO:i.push({type:U.HORIZ_LINE_TO,relative:!1,x:a.x});break;case U.VERT_LINE_TO:i.push({type:U.VERT_LINE_TO,relative:!1,y:a.y});break;case U.LINE_TO:case U.MOVE_TO:i.push({type:U.LINE_TO,relative:!1,x:a.x,y:a.y});break;case U.CURVE_TO:i.push({type:U.CURVE_TO,relative:!1,x:a.x,y:a.y,x1:o.x2,y1:o.y2,x2:o.x1,y2:o.y1});break;case U.SMOOTH_CURVE_TO:throw new Error("Unsupported command: S (smooth cubic bezier)");case U.SMOOTH_QUAD_TO:throw new Error("Unsupported command: T (smooth quadratic bezier)");case U.ARC:throw new Error("Unsupported command: A (arc)");case U.QUAD_TO:throw new Error("Unsupported command: Q (quadratic bezier)")}}return t&&i.push({type:U.CLOSE_PATH}),i}function jA(r=1e13){Qe(r);function t(e){return Math.round(e*r)/r}return function(i){return"x1"in i&&typeof i.x1<"u"&&(i.x1=t(i.x1)),"y1"in i&&typeof i.y1<"u"&&(i.y1=t(i.y1)),"x2"in i&&typeof i.x2<"u"&&(i.x2=t(i.x2)),"y2"in i&&typeof i.y2<"u"&&(i.y2=t(i.y2)),"x"in i&&typeof i.x<"u"&&(i.x=t(i.x)),"y"in i&&typeof i.y<"u"&&(i.y=t(i.y)),"rX"in i&&typeof i.rX<"u"&&(i.rX=t(i.rX)),"rY"in i&&typeof i.rY<"u"&&(i.rY=t(i.rY)),i}}function Wp(){return Je((r,t,e)=>(r.relative&&(typeof r.x1<"u"&&(r.x1+=t),typeof r.y1<"u"&&(r.y1+=e),typeof r.x2<"u"&&(r.x2+=t),typeof r.y2<"u"&&(r.y2+=e),typeof r.x<"u"&&(r.x+=t),typeof r.y<"u"&&(r.y+=e),r.relative=!1),r))}function qA(){return Je((r,t,e)=>(r.relative||(typeof r.x1<"u"&&(r.x1-=t),typeof r.y1<"u"&&(r.y1-=e),typeof r.x2<"u"&&(r.x2-=t),typeof r.y2<"u"&&(r.y2-=e),typeof r.x<"u"&&(r.x-=t),typeof r.y<"u"&&(r.y-=e),r.relative=!0),r))}function KA(r=!0,t=!0,e=!0,i=!0){return Je((s,n,o,a,l)=>{if(isNaN(a)&&!(s.type&U.MOVE_TO))throw new Error("path must start with moveto");if(t&&s.type&U.HORIZ_LINE_TO&&(s.type=U.LINE_TO,s.y=s.relative?0:o),e&&s.type&U.VERT_LINE_TO&&(s.type=U.LINE_TO,s.x=s.relative?0:n),r&&s.type&U.CLOSE_PATH&&(s.type=U.LINE_TO,s.x=s.relative?a-n:a,s.y=s.relative?l-o:l),s.type&U.ARC&&(s.rX===0||s.rY===0)&&(s.type=U.LINE_TO,delete s.rX,delete s.rY,delete s.xRot,delete s.lArcFlag,delete s.sweepFlag),i&&s.type&U.QUAD_TO){const h=[n,o],u=s.relative?[n+s.x1,o+s.y1]:[s.x1,s.y1],c=s.relative?[n+s.x,o+s.y]:[s.x,s.y];xh(h,u,c)&&(s.type=U.LINE_TO,delete s.x1,delete s.y1)}if(i&&s.type&U.CURVE_TO){const h=[n,o],u=s.relative?[n+s.x1,o+s.y1]:[s.x1,s.y1],c=s.relative?[n+s.x2,o+s.y2]:[s.x2,s.y2],d=s.relative?[n+s.x,o+s.y]:[s.x,s.y];xh(h,u,d)&&xh(h,c,d)&&(s.type=U.LINE_TO,delete s.x1,delete s.y1,delete s.x2,delete s.y2)}return s})}function Yp(){let r=NaN,t=NaN,e=NaN,i=NaN;return Je((s,n,o)=>(s.type&U.SMOOTH_CURVE_TO&&(s.type=U.CURVE_TO,r=isNaN(r)?n:r,t=isNaN(t)?o:t,s.x1=s.relative?n-r:2*n-r,s.y1=s.relative?o-t:2*o-t),s.type&U.CURVE_TO?(r=s.relative?n+s.x2:s.x2,t=s.relative?o+s.y2:s.y2):(r=NaN,t=NaN),s.type&U.SMOOTH_QUAD_TO&&(s.type=U.QUAD_TO,e=isNaN(e)?n:e,i=isNaN(i)?o:i,s.x1=s.relative?n-e:2*n-e,s.y1=s.relative?o-i:2*o-i),s.type&U.QUAD_TO?(e=s.relative?n+s.x1:s.x1,i=s.relative?o+s.y1:s.y1):(e=NaN,i=NaN),s))}function jp(){let r=NaN,t=NaN;return Je((e,i,s)=>{if(e.type&U.SMOOTH_QUAD_TO&&(e.type=U.QUAD_TO,r=isNaN(r)?i:r,t=isNaN(t)?s:t,e.x1=e.relative?i-r:2*i-r,e.y1=e.relative?s-t:2*s-t),e.type&U.QUAD_TO){r=e.relative?i+e.x1:e.x1,t=e.relative?s+e.y1:e.y1;const n=e.x1,o=e.y1;e.type=U.CURVE_TO,e.x1=((e.relative?0:i)+n*2)/3,e.y1=((e.relative?0:s)+o*2)/3,e.x2=(e.x+n*2)/3,e.y2=(e.y+o*2)/3}else r=NaN,t=NaN;return e})}function Je(r){let t=0,e=0,i=NaN,s=NaN;return function(o){if(isNaN(i)&&!(o.type&U.MOVE_TO))throw new Error("path must start with moveto");const a=r(o,t,e,i,s);return o.type&U.CLOSE_PATH&&(t=i,e=s),"x"in o&&typeof o.x<"u"&&(t=o.relative?t+o.x:o.x),"y"in o&&typeof o.y<"u"&&(e=o.relative?e+o.y:o.y),o.type&U.MOVE_TO&&(i=t,s=e),a}}function ZA(r=0){Qe(r);let t=NaN,e=NaN,i=NaN,s=NaN;return Je((n,o,a,l,h)=>{const u=Math.abs;let c=!1,d=0,f=0;if(n.type&U.SMOOTH_CURVE_TO&&(d=isNaN(t)?0:o-t,f=isNaN(e)?0:a-e),n.type&(U.CURVE_TO|U.SMOOTH_CURVE_TO)?(t=n.relative?o+n.x2:n.x2,e=n.relative?a+n.y2:n.y2):(t=NaN,e=NaN),n.type&U.SMOOTH_QUAD_TO?(i=isNaN(i)?o:2*o-i,s=isNaN(s)?a:2*a-s):n.type&U.QUAD_TO?(i=n.relative?o+n.x1:n.x1,s=n.relative?a+n.y1:n.y2):(i=NaN,s=NaN),n.type&U.LINE_COMMANDS||n.type&U.ARC&&(n.rX===0||n.rY===0||!n.lArcFlag)||n.type&U.CURVE_TO||n.type&U.SMOOTH_CURVE_TO||n.type&U.QUAD_TO||n.type&U.SMOOTH_QUAD_TO){const p=typeof n.x>"u"?0:n.relative?n.x:n.x-o,m=typeof n.y>"u"?0:n.relative?n.y:n.y-a;d=isNaN(i)?typeof n.x1>"u"?d:n.relative?n.x:n.x1-o:i-o,f=isNaN(s)?typeof n.y1>"u"?f:n.relative?n.y:n.y1-a:s-a;const y=typeof n.x2>"u"?0:n.relative?n.x:n.x2-o,_=typeof n.y2>"u"?0:n.relative?n.y:n.y2-a;u(p)<=r&&u(m)<=r&&u(d)<=r&&u(f)<=r&&u(y)<=r&&u(_)<=r&&(c=!0)}return n.type&U.CLOSE_PATH&&u(o-l)<=r&&u(a-h)<=r&&(c=!0),c?[]:n})}function Kr(r,t,e,i,s,n){return Qe(r,t,e,i,s,n),Je((o,a,l,h)=>{const u=o.x1,c=o.x2,d=o.relative&&!isNaN(h),f=typeof o.x<"u"?o.x:d?0:a,p=typeof o.y<"u"?o.y:d?0:l;o.type&U.HORIZ_LINE_TO&&t!==0&&(o.type=U.LINE_TO,o.y=o.relative?0:l),o.type&U.VERT_LINE_TO&&e!==0&&(o.type=U.LINE_TO,o.x=o.relative?0:a),typeof o.x<"u"&&(o.x=o.x*r+p*e+(d?0:s)),typeof o.y<"u"&&(o.y=f*t+o.y*i+(d?0:n)),typeof o.x1<"u"&&(o.x1=o.x1*r+o.y1*e+(d?0:s)),typeof o.y1<"u"&&(o.y1=u*t+o.y1*i+(d?0:n)),typeof o.x2<"u"&&(o.x2=o.x2*r+o.y2*e+(d?0:s)),typeof o.y2<"u"&&(o.y2=c*t+o.y2*i+(d?0:n));function m(_){return _*_}const y=r*i-t*e;if(typeof o.xRot<"u"&&(r!==1||t!==0||e!==0||i!==1))if(y===0)delete o.rX,delete o.rY,delete o.xRot,delete o.lArcFlag,delete o.sweepFlag,o.type=U.LINE_TO;else{const _=o.xRot*Math.PI/180,v=Math.sin(_),g=Math.cos(_),x=1/m(o.rX),b=1/m(o.rY),S=m(g)*x+m(v)*b,w=2*v*g*(x-b),T=m(v)*x+m(g)*b,N=S*i*i-w*t*i+T*t*t,F=w*(r*i+t*e)-2*(S*e*i+T*r*t),z=S*e*e-w*r*e+T*r*r,C=(Math.atan2(F,N-z)+Math.PI)%Math.PI/2,E=Math.sin(C),I=Math.cos(C);o.rX=Math.abs(y)/Math.sqrt(N*m(I)+F*E*I+z*m(E)),o.rY=Math.abs(y)/Math.sqrt(N*m(E)-F*E*I+z*m(I)),o.xRot=C*180/Math.PI}return typeof o.sweepFlag<"u"&&0>y&&(o.sweepFlag=+!o.sweepFlag),o})}function QA(r,t=0,e=0){Qe(r,t,e);const i=Math.sin(r),s=Math.cos(r);return Kr(s,i,-i,s,t-t*s+e*i,e-t*i-e*s)}function JA(r,t=0){return Qe(r,t),Kr(1,0,0,1,r,t)}function tS(r,t=r){return Qe(r,t),Kr(r,0,0,t,0,0)}function eS(r){return Qe(r),Kr(1,0,Math.tan(r),1,0,0)}function rS(r){return Qe(r),Kr(1,Math.tan(r),0,1,0,0)}function iS(r=0){return Qe(r),Kr(-1,0,0,1,r,0)}function sS(r=0){return Qe(r),Kr(1,0,0,-1,0,r)}function nS(){return Je((r,t,e)=>U.ARC===r.type?WA(r,r.relative?0:t,r.relative?0:e):r)}function oS(){return Je((r,t,e)=>(r.relative&&(t=0,e=0),U.ARC===r.type&&vh(r,t,e),r))}function qp(){return r=>({...r})}function aS(){const r=qp(),t=Wp(),e=jp(),i=Yp(),s=Je((n,o,a)=>{const l=i(e(t(r(n))));function h(c){c>s.maxX&&(s.maxX=c),c<s.minX&&(s.minX=c)}function u(c){c>s.maxY&&(s.maxY=c),c<s.minY&&(s.minY=c)}if(l.type&U.DRAWING_COMMANDS&&(h(o),u(a)),l.type&U.HORIZ_LINE_TO&&h(l.x),l.type&U.VERT_LINE_TO&&u(l.y),l.type&U.LINE_TO&&(h(l.x),u(l.y)),l.type&U.CURVE_TO){h(l.x),u(l.y);const c=Xp(o,l.x1,l.x2,l.x);for(const f of c)0<f&&1>f&&h(zp(o,l.x1,l.x2,l.x,f));const d=Xp(a,l.y1,l.y2,l.y);for(const f of d)0<f&&1>f&&u(zp(a,l.y1,l.y2,l.y,f))}if(l.type&U.ARC){h(l.x),u(l.y),vh(l,o,a);const c=l.xRot/180*Math.PI,d=Math.cos(c)*l.rX,f=Math.sin(c)*l.rX,p=-Math.sin(c)*l.rY,m=Math.cos(c)*l.rY,[y,_]=l.phi1<l.phi2?[l.phi1,l.phi2]:-180>l.phi2?[l.phi2+360,l.phi1+360]:[l.phi2,l.phi1],v=([b,S])=>{const T=Math.atan2(S,b)*180/Math.PI;return T<y?T+360:T},g=Hp(p,-d,0).map(v);for(const b of g)b>y&&b<_&&h(Vp(l.cX,d,p,b));const x=Hp(m,-f,0).map(v);for(const b of x)b>y&&b<_&&u(Vp(l.cY,f,m,b))}return n});return s.minX=1/0,s.maxX=-1/0,s.minY=1/0,s.maxY=-1/0,s}const qt={ROUND:jA,TO_ABS:Wp,TO_REL:qA,NORMALIZE_HVZ:KA,NORMALIZE_ST:Yp,QT_TO_C:jp,INFO:Je,SANITIZE:ZA,MATRIX:Kr,ROTATE:QA,TRANSLATE:JA,SCALE:tS,SKEW_X:eS,SKEW_Y:rS,X_AXIS_SYMMETRY:iS,Y_AXIS_SYMMETRY:sS,A_TO_C:nS,ANNOTATE_ARCS:oS,CLONE:qp,CALCULATE_BOUNDS:aS,REVERSE_PATH:YA};class Kp{round(t){return this.transform(qt.ROUND(t))}toAbs(){return this.transform(qt.TO_ABS())}toRel(){return this.transform(qt.TO_REL())}normalizeHVZ(t,e,i){return this.transform(qt.NORMALIZE_HVZ(t,e,i))}normalizeST(){return this.transform(qt.NORMALIZE_ST())}qtToC(){return this.transform(qt.QT_TO_C())}aToC(){return this.transform(qt.A_TO_C())}sanitize(t){return this.transform(qt.SANITIZE(t))}translate(t,e){return this.transform(qt.TRANSLATE(t,e))}scale(t,e){return this.transform(qt.SCALE(t,e))}rotate(t,e,i){return this.transform(qt.ROTATE(t,e,i))}matrix(t,e,i,s,n,o){return this.transform(qt.MATRIX(t,e,i,s,n,o))}skewX(t){return this.transform(qt.SKEW_X(t))}skewY(t){return this.transform(qt.SKEW_Y(t))}xSymmetry(t){return this.transform(qt.X_AXIS_SYMMETRY(t))}ySymmetry(t){return this.transform(qt.Y_AXIS_SYMMETRY(t))}annotateArcs(){return this.transform(qt.ANNOTATE_ARCS())}}const lS=r=>r===" "||r===" "||r==="\r"||r===`
|
|
1149
1149
|
`,Zp=r=>48<=r.charCodeAt(0)&&r.charCodeAt(0)<=57;class hS extends Kp{constructor(){super();Pt(this,"curNumber","");Pt(this,"curCommandType",-1);Pt(this,"curCommandRelative",!1);Pt(this,"canParseCommandOrComma",!0);Pt(this,"curNumberHasExp",!1);Pt(this,"curNumberHasExpDigits",!1);Pt(this,"curNumberHasDecimal",!1);Pt(this,"curArgs",[])}finish(e=[]){if(this.parse(" ",e),this.curArgs.length!==0||!this.canParseCommandOrComma)throw new SyntaxError("Unterminated command at the path end.");return e}parse(e,i=[]){const s=n=>{i.push(n),this.curArgs.length=0,this.canParseCommandOrComma=!0};for(let n=0;n<e.length;n++){const o=e[n],a=this.curCommandType===U.ARC&&(this.curArgs.length===3||this.curArgs.length===4)&&this.curNumber.length===1&&(this.curNumber==="0"||this.curNumber==="1"),l=Zp(o)&&(this.curNumber==="0"&&o==="0"||a);if(Zp(o)&&!l){this.curNumber+=o,this.curNumberHasExpDigits=this.curNumberHasExp;continue}if(o==="e"||o==="E"){this.curNumber+=o,this.curNumberHasExp=!0;continue}if((o==="-"||o==="+")&&this.curNumberHasExp&&!this.curNumberHasExpDigits){this.curNumber+=o;continue}if(o==="."&&!this.curNumberHasExp&&!this.curNumberHasDecimal&&!a){this.curNumber+=o,this.curNumberHasDecimal=!0;continue}if(this.curNumber&&this.curCommandType!==-1){const h=Number(this.curNumber);if(isNaN(h))throw new SyntaxError(`Invalid number ending at ${n}`);if(this.curCommandType===U.ARC){if(this.curArgs.length===0||this.curArgs.length===1){if(0>h)throw new SyntaxError(`Expected positive number, got "${h}" at index "${n}"`)}else if((this.curArgs.length===3||this.curArgs.length===4)&&this.curNumber!=="0"&&this.curNumber!=="1")throw new SyntaxError(`Expected a flag, got "${this.curNumber}" at index "${n}"`)}this.curArgs.push(h),this.curArgs.length===uS[this.curCommandType]&&(U.HORIZ_LINE_TO===this.curCommandType?s({type:U.HORIZ_LINE_TO,relative:this.curCommandRelative,x:h}):U.VERT_LINE_TO===this.curCommandType?s({type:U.VERT_LINE_TO,relative:this.curCommandRelative,y:h}):this.curCommandType===U.MOVE_TO||this.curCommandType===U.LINE_TO||this.curCommandType===U.SMOOTH_QUAD_TO?(s({type:this.curCommandType,relative:this.curCommandRelative,x:this.curArgs[0],y:this.curArgs[1]}),U.MOVE_TO===this.curCommandType&&(this.curCommandType=U.LINE_TO)):this.curCommandType===U.CURVE_TO?s({type:U.CURVE_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x2:this.curArgs[2],y2:this.curArgs[3],x:this.curArgs[4],y:this.curArgs[5]}):this.curCommandType===U.SMOOTH_CURVE_TO?s({type:U.SMOOTH_CURVE_TO,relative:this.curCommandRelative,x2:this.curArgs[0],y2:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===U.QUAD_TO?s({type:U.QUAD_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===U.ARC&&s({type:U.ARC,relative:this.curCommandRelative,rX:this.curArgs[0],rY:this.curArgs[1],xRot:this.curArgs[2],lArcFlag:this.curArgs[3],sweepFlag:this.curArgs[4],x:this.curArgs[5],y:this.curArgs[6]})),this.curNumber="",this.curNumberHasExpDigits=!1,this.curNumberHasExp=!1,this.curNumberHasDecimal=!1,this.canParseCommandOrComma=!0}if(!lS(o)){if(o===","&&this.canParseCommandOrComma){this.canParseCommandOrComma=!1;continue}if(o==="+"||o==="-"||o==="."){this.curNumber=o,this.curNumberHasDecimal=o===".";continue}if(l){this.curNumber=o,this.curNumberHasDecimal=!1;continue}if(this.curArgs.length!==0)throw new SyntaxError(`Unterminated command at index ${n}.`);if(!this.canParseCommandOrComma)throw new SyntaxError(`Unexpected character "${o}" at index ${n}. Command cannot follow comma`);if(this.canParseCommandOrComma=!1,o==="z"||o==="Z"){i.push({type:U.CLOSE_PATH}),this.canParseCommandOrComma=!0,this.curCommandType=-1;continue}else if(o==="h"||o==="H")this.curCommandType=U.HORIZ_LINE_TO,this.curCommandRelative=o==="h";else if(o==="v"||o==="V")this.curCommandType=U.VERT_LINE_TO,this.curCommandRelative=o==="v";else if(o==="m"||o==="M")this.curCommandType=U.MOVE_TO,this.curCommandRelative=o==="m";else if(o==="l"||o==="L")this.curCommandType=U.LINE_TO,this.curCommandRelative=o==="l";else if(o==="c"||o==="C")this.curCommandType=U.CURVE_TO,this.curCommandRelative=o==="c";else if(o==="s"||o==="S")this.curCommandType=U.SMOOTH_CURVE_TO,this.curCommandRelative=o==="s";else if(o==="q"||o==="Q")this.curCommandType=U.QUAD_TO,this.curCommandRelative=o==="q";else if(o==="t"||o==="T")this.curCommandType=U.SMOOTH_QUAD_TO,this.curCommandRelative=o==="t";else if(o==="a"||o==="A")this.curCommandType=U.ARC,this.curCommandRelative=o==="a";else throw new SyntaxError(`Unexpected character "${o}" at index ${n}.`)}}return i}transform(e){return Object.create(this,{parse:{value(s,n=[]){const o=Object.getPrototypeOf(this).parse.call(this,s);for(const a of o){const l=e(a);Array.isArray(l)?n.push(...l):n.push(l)}return n}}})}}const At=class At extends Kp{constructor(e){super();Pt(this,"commands");typeof e=="string"?this.commands=At.parse(e):this.commands=e}encode(){return At.encode(this.commands)}getBounds(){const e=qt.CALCULATE_BOUNDS();return this.transform(e),e}transform(e){const i=[];for(const s of this.commands){const n=e(s);Array.isArray(n)?i.push(...n):i.push(n)}return this.commands=i,this}reverse(e=!0){return this.commands=qt.REVERSE_PATH(this.commands,e),this}static encode(e){return XA(e)}static parse(e){const i=new hS,s=[];return i.parse(e,s),i.finish(s),s}};Pt(At,"CLOSE_PATH",1),Pt(At,"MOVE_TO",2),Pt(At,"HORIZ_LINE_TO",4),Pt(At,"VERT_LINE_TO",8),Pt(At,"LINE_TO",16),Pt(At,"CURVE_TO",32),Pt(At,"SMOOTH_CURVE_TO",64),Pt(At,"QUAD_TO",128),Pt(At,"SMOOTH_QUAD_TO",256),Pt(At,"ARC",512),Pt(At,"LINE_COMMANDS",At.LINE_TO|At.HORIZ_LINE_TO|At.VERT_LINE_TO),Pt(At,"DRAWING_COMMANDS",At.HORIZ_LINE_TO|At.VERT_LINE_TO|At.LINE_TO|At.CURVE_TO|At.SMOOTH_CURVE_TO|At.QUAD_TO|At.SMOOTH_QUAD_TO|At.ARC);let U=At;const uS={[U.MOVE_TO]:2,[U.LINE_TO]:2,[U.HORIZ_LINE_TO]:1,[U.VERT_LINE_TO]:1,[U.CLOSE_PATH]:0,[U.QUAD_TO]:4,[U.SMOOTH_QUAD_TO]:2,[U.CURVE_TO]:6,[U.SMOOTH_CURVE_TO]:4,[U.ARC]:7};function Qp(r,t,e){const i=r.slice();return i[10]=t[e],i[12]=e,i}function Jp(r){let t,e;return t=new ls({props:{x:r[10][0],y:r[10][1],scale:r[3]}}),t.$on("pointerdown",function(){Kt(r[9](`HANDLE-${r[12]}`))&&r[9](`HANDLE-${r[12]}`).apply(this,arguments)}),{c(){$t(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){r=i;const n={};s&16&&(n.x=r[10][0]),s&16&&(n.y=r[10][1]),s&8&&(n.scale=r[3]),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function cS(r){let t,e,i,s,n,o,a,l,h,u,c,d=Se(r[4].points),f=[];for(let m=0;m<d.length;m+=1)f[m]=Jp(Qp(r,d,m));const p=m=>et(f[m],1,1,()=>{f[m]=null});return{c(){t=xt("polygon"),s=Ve(),n=xt("polygon"),a=Ve();for(let m=0;m<f.length;m+=1)f[m].c();l=Re(),R(t,"class","a9s-outer"),R(t,"style",e=r[1]?"display:none;":void 0),R(t,"points",i=r[4].points.map(tm).join(" ")),R(n,"class","a9s-inner a9s-shape-handle"),R(n,"style",r[1]),R(n,"points",o=r[4].points.map(em).join(" "))},m(m,y){ct(m,t,y),ct(m,s,y),ct(m,n,y),ct(m,a,y);for(let _=0;_<f.length;_+=1)f[_]&&f[_].m(m,y);ct(m,l,y),h=!0,u||(c=[Zt(t,"pointerdown",function(){Kt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Zt(n,"pointerdown",function(){Kt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)})],u=!0)},p(m,y){if(r=m,(!h||y&2&&e!==(e=r[1]?"display:none;":void 0))&&R(t,"style",e),(!h||y&16&&i!==(i=r[4].points.map(tm).join(" ")))&&R(t,"points",i),(!h||y&2)&&R(n,"style",r[1]),(!h||y&16&&o!==(o=r[4].points.map(em).join(" ")))&&R(n,"points",o),y&536){d=Se(r[4].points);let _;for(_=0;_<d.length;_+=1){const v=Qp(r,d,_);f[_]?(f[_].p(v,y),q(f[_],1)):(f[_]=Jp(v),f[_].c(),q(f[_],1),f[_].m(l.parentNode,l))}for(ge(),_=d.length;_<f.length;_+=1)p(_);ye()}},i(m){if(!h){for(let y=0;y<d.length;y+=1)q(f[y]);h=!0}},o(m){f=f.filter(Boolean);for(let y=0;y<f.length;y+=1)et(f[y]);h=!1},d(m){m&&(ht(t),ht(s),ht(n),ht(a),ht(l)),ii(f,m),u=!1,er(c)}}}function dS(r){let t,e;return t=new bh({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[cS,({grab:i})=>({9:i}),({grab:i})=>i?512:0]},$$scope:{ctx:r}}}),t.$on("change",r[6]),t.$on("grab",r[7]),t.$on("release",r[8]),{c(){$t(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,[s]){const n={};s&1&&(n.shape=i[0]),s&4&&(n.transform=i[2]),s&8730&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}const tm=r=>r.join(","),em=r=>r.join(",");function fS(r,t,e){let i,{shape:s}=t,{computedStyle:n}=t,{transform:o}=t,{viewportScale:a=1}=t;const l=(d,f,p)=>{let m;const y=d.geometry;f==="SHAPE"?m=y.points.map(([v,g])=>[v+p[0],g+p[1]]):m=y.points.map(([v,g],x)=>f===`HANDLE-${x}`?[v+p[0],g+p[1]]:[v,g]);const _=Oo(m);return{...d,geometry:{points:m,bounds:_}}};function h(d){De.call(this,r,d)}function u(d){De.call(this,r,d)}function c(d){De.call(this,r,d)}return r.$$set=d=>{"shape"in d&&e(0,s=d.shape),"computedStyle"in d&&e(1,n=d.computedStyle),"transform"in d&&e(2,o=d.transform),"viewportScale"in d&&e(3,a=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&1&&e(4,i=s.geometry)},[s,n,o,a,i,l,h,u,c]}class pS extends re{constructor(t){super(),ee(this,t,fS,dS,Wt,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}const mS=typeof window>"u"||typeof navigator>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0;function gS(r){let t,e,i,s,n,o;return{c(){t=xt("rect"),R(t,"class",e=pn(`a9s-handle ${r[8].class||""}`.trim())+" svelte-1sgkh33"),R(t,"x",i=r[0]-r[5]/2),R(t,"y",s=r[1]-r[5]/2),R(t,"width",r[5]),R(t,"height",r[5])},m(a,l){ct(a,t,l),n||(o=Zt(t,"pointerdown",r[11]),n=!0)},p(a,l){l&256&&e!==(e=pn(`a9s-handle ${a[8].class||""}`.trim())+" svelte-1sgkh33")&&R(t,"class",e),l&33&&i!==(i=a[0]-a[5]/2)&&R(t,"x",i),l&34&&s!==(s=a[1]-a[5]/2)&&R(t,"y",s),l&32&&R(t,"width",a[5]),l&32&&R(t,"height",a[5])},d(a){a&&ht(t),n=!1,o()}}}function yS(r){let t,e,i,s,n,o,a,l,h;return{c(){t=xt("g"),e=xt("circle"),s=xt("rect"),R(e,"cx",r[0]),R(e,"cy",r[1]),R(e,"r",i=r[3]/r[2]),R(e,"class","a9s-touch-halo svelte-1sgkh33"),mn(e,"touched",r[4]),R(s,"class",n=pn(`a9s-handle ${r[8].class||""}`.trim())+" svelte-1sgkh33"),R(s,"x",o=r[0]-r[5]/2),R(s,"y",a=r[1]-r[5]/2),R(s,"width",r[5]),R(s,"height",r[5]),R(t,"class","a9s-touch-handle")},m(u,c){ct(u,t,c),Ae(t,e),Ae(t,s),l||(h=[Zt(e,"pointerdown",r[10]),Zt(e,"pointerdown",r[6]),Zt(e,"pointerup",r[7]),Zt(s,"pointerdown",r[9]),Zt(s,"pointerdown",r[6]),Zt(s,"pointerup",r[7])],l=!0)},p(u,c){c&1&&R(e,"cx",u[0]),c&2&&R(e,"cy",u[1]),c&12&&i!==(i=u[3]/u[2])&&R(e,"r",i),c&16&&mn(e,"touched",u[4]),c&256&&n!==(n=pn(`a9s-handle ${u[8].class||""}`.trim())+" svelte-1sgkh33")&&R(s,"class",n),c&33&&o!==(o=u[0]-u[5]/2)&&R(s,"x",o),c&34&&a!==(a=u[1]-u[5]/2)&&R(s,"y",a),c&32&&R(s,"width",u[5]),c&32&&R(s,"height",u[5])},d(u){u&&ht(t),l=!1,er(h)}}}function _S(r){let t;function e(n,o){return mS?yS:gS}let s=e()(r);return{c(){s.c(),t=Re()},m(n,o){s.m(n,o),ct(n,t,o)},p(n,[o]){s.p(n,o)},i:me,o:me,d(n){n&&ht(t),s.d(n)}}}function vS(r,t,e){let i,{x:s}=t,{y:n}=t,{scale:o}=t,{radius:a=30}=t,l=!1;const h=p=>{p.pointerType==="touch"&&e(4,l=!0)},u=()=>e(4,l=!1);function c(p){De.call(this,r,p)}function d(p){De.call(this,r,p)}function f(p){De.call(this,r,p)}return r.$$set=p=>{e(8,t=pa(pa({},t),rc(p))),"x"in p&&e(0,s=p.x),"y"in p&&e(1,n=p.y),"scale"in p&&e(2,o=p.scale),"radius"in p&&e(3,a=p.radius)},r.$$.update=()=>{r.$$.dirty&4&&e(5,i=10/o)},t=rc(t),[s,n,o,a,l,i,h,u,t,c,d,f]}class ls extends re{constructor(t){super(),ee(this,t,vS,_S,Wt,{x:0,y:1,scale:2,radius:3})}}function xS(r){let t,e,i,s,n,o,a,l,h,u,c,d,f,p,m,y,_,v,g,x,b,S,w,T,N,F,z,C,E,I,P,H,k,G,st,M,L,V,rt,Q,X,_t,St;return G=new ls({props:{class:"a9s-corner-handle-topleft",x:r[4].x,y:r[4].y,scale:r[3]}}),G.$on("pointerdown",function(){Kt(r[9]("TOP_LEFT"))&&r[9]("TOP_LEFT").apply(this,arguments)}),M=new ls({props:{class:"a9s-corner-handle-topright",x:r[4].x+r[4].w,y:r[4].y,scale:r[3]}}),M.$on("pointerdown",function(){Kt(r[9]("TOP_RIGHT"))&&r[9]("TOP_RIGHT").apply(this,arguments)}),V=new ls({props:{class:"a9s-corner-handle-bottomright",x:r[4].x+r[4].w,y:r[4].y+r[4].h,scale:r[3]}}),V.$on("pointerdown",function(){Kt(r[9]("BOTTOM_RIGHT"))&&r[9]("BOTTOM_RIGHT").apply(this,arguments)}),Q=new ls({props:{class:"a9s-corner-handle-bottomleft",x:r[4].x,y:r[4].y+r[4].h,scale:r[3]}}),Q.$on("pointerdown",function(){Kt(r[9]("BOTTOM_LEFT"))&&r[9]("BOTTOM_LEFT").apply(this,arguments)}),{c(){t=xt("rect"),a=Ve(),l=xt("rect"),f=Ve(),p=xt("rect"),v=Ve(),g=xt("rect"),w=Ve(),T=xt("rect"),C=Ve(),E=xt("rect"),k=Ve(),$t(G.$$.fragment),st=Ve(),$t(M.$$.fragment),L=Ve(),$t(V.$$.fragment),rt=Ve(),$t(Q.$$.fragment),R(t,"class","a9s-outer"),R(t,"style",e=r[1]?"display:none;":void 0),R(t,"x",i=r[4].x),R(t,"y",s=r[4].y),R(t,"width",n=r[4].w),R(t,"height",o=r[4].h),R(l,"class","a9s-inner a9s-shape-handle"),R(l,"style",r[1]),R(l,"x",h=r[4].x),R(l,"y",u=r[4].y),R(l,"width",c=r[4].w),R(l,"height",d=r[4].h),R(p,"class","a9s-edge-handle a9s-edge-handle-top"),R(p,"x",m=r[4].x),R(p,"y",y=r[4].y),R(p,"height",1),R(p,"width",_=r[4].w),R(g,"class","a9s-edge-handle a9s-edge-handle-right"),R(g,"x",x=r[4].x+r[4].w),R(g,"y",b=r[4].y),R(g,"height",S=r[4].h),R(g,"width",1),R(T,"class","a9s-edge-handle a9s-edge-handle-bottom"),R(T,"x",N=r[4].x),R(T,"y",F=r[4].y+r[4].h),R(T,"height",1),R(T,"width",z=r[4].w),R(E,"class","a9s-edge-handle a9s-edge-handle-left"),R(E,"x",I=r[4].x),R(E,"y",P=r[4].y),R(E,"height",H=r[4].h),R(E,"width",1)},m(O,D){ct(O,t,D),ct(O,a,D),ct(O,l,D),ct(O,f,D),ct(O,p,D),ct(O,v,D),ct(O,g,D),ct(O,w,D),ct(O,T,D),ct(O,C,D),ct(O,E,D),ct(O,k,D),Ft(G,O,D),ct(O,st,D),Ft(M,O,D),ct(O,L,D),Ft(V,O,D),ct(O,rt,D),Ft(Q,O,D),X=!0,_t||(St=[Zt(t,"pointerdown",function(){Kt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Zt(l,"pointerdown",function(){Kt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Zt(p,"pointerdown",function(){Kt(r[9]("TOP"))&&r[9]("TOP").apply(this,arguments)}),Zt(g,"pointerdown",function(){Kt(r[9]("RIGHT"))&&r[9]("RIGHT").apply(this,arguments)}),Zt(T,"pointerdown",function(){Kt(r[9]("BOTTOM"))&&r[9]("BOTTOM").apply(this,arguments)}),Zt(E,"pointerdown",function(){Kt(r[9]("LEFT"))&&r[9]("LEFT").apply(this,arguments)})],_t=!0)},p(O,D){r=O,(!X||D&2&&e!==(e=r[1]?"display:none;":void 0))&&R(t,"style",e),(!X||D&16&&i!==(i=r[4].x))&&R(t,"x",i),(!X||D&16&&s!==(s=r[4].y))&&R(t,"y",s),(!X||D&16&&n!==(n=r[4].w))&&R(t,"width",n),(!X||D&16&&o!==(o=r[4].h))&&R(t,"height",o),(!X||D&2)&&R(l,"style",r[1]),(!X||D&16&&h!==(h=r[4].x))&&R(l,"x",h),(!X||D&16&&u!==(u=r[4].y))&&R(l,"y",u),(!X||D&16&&c!==(c=r[4].w))&&R(l,"width",c),(!X||D&16&&d!==(d=r[4].h))&&R(l,"height",d),(!X||D&16&&m!==(m=r[4].x))&&R(p,"x",m),(!X||D&16&&y!==(y=r[4].y))&&R(p,"y",y),(!X||D&16&&_!==(_=r[4].w))&&R(p,"width",_),(!X||D&16&&x!==(x=r[4].x+r[4].w))&&R(g,"x",x),(!X||D&16&&b!==(b=r[4].y))&&R(g,"y",b),(!X||D&16&&S!==(S=r[4].h))&&R(g,"height",S),(!X||D&16&&N!==(N=r[4].x))&&R(T,"x",N),(!X||D&16&&F!==(F=r[4].y+r[4].h))&&R(T,"y",F),(!X||D&16&&z!==(z=r[4].w))&&R(T,"width",z),(!X||D&16&&I!==(I=r[4].x))&&R(E,"x",I),(!X||D&16&&P!==(P=r[4].y))&&R(E,"y",P),(!X||D&16&&H!==(H=r[4].h))&&R(E,"height",H);const ut={};D&16&&(ut.x=r[4].x),D&16&&(ut.y=r[4].y),D&8&&(ut.scale=r[3]),G.$set(ut);const lt={};D&16&&(lt.x=r[4].x+r[4].w),D&16&&(lt.y=r[4].y),D&8&&(lt.scale=r[3]),M.$set(lt);const Et={};D&16&&(Et.x=r[4].x+r[4].w),D&16&&(Et.y=r[4].y+r[4].h),D&8&&(Et.scale=r[3]),V.$set(Et);const Tt={};D&16&&(Tt.x=r[4].x),D&16&&(Tt.y=r[4].y+r[4].h),D&8&&(Tt.scale=r[3]),Q.$set(Tt)},i(O){X||(q(G.$$.fragment,O),q(M.$$.fragment,O),q(V.$$.fragment,O),q(Q.$$.fragment,O),X=!0)},o(O){et(G.$$.fragment,O),et(M.$$.fragment,O),et(V.$$.fragment,O),et(Q.$$.fragment,O),X=!1},d(O){O&&(ht(t),ht(a),ht(l),ht(f),ht(p),ht(v),ht(g),ht(w),ht(T),ht(C),ht(E),ht(k),ht(st),ht(L),ht(rt)),Ut(G,O),Ut(M,O),Ut(V,O),Ut(Q,O),_t=!1,er(St)}}}function bS(r){let t,e;return t=new bh({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[xS,({grab:i})=>({9:i}),({grab:i})=>i?512:0]},$$scope:{ctx:r}}}),t.$on("grab",r[6]),t.$on("change",r[7]),t.$on("release",r[8]),{c(){$t(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,[s]){const n={};s&1&&(n.shape=i[0]),s&4&&(n.transform=i[2]),s&1562&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function ES(r,t,e){let i,{shape:s}=t,{computedStyle:n}=t,{transform:o}=t,{viewportScale:a=1}=t;const l=(d,f,p)=>{const m=d.geometry.bounds;let[y,_]=[m.minX,m.minY],[v,g]=[m.maxX,m.maxY];const[x,b]=p;if(f==="SHAPE")y+=x,v+=x,_+=b,g+=b;else{switch(f){case"TOP":case"TOP_LEFT":case"TOP_RIGHT":{_+=b;break}case"BOTTOM":case"BOTTOM_LEFT":case"BOTTOM_RIGHT":{g+=b;break}}switch(f){case"LEFT":case"TOP_LEFT":case"BOTTOM_LEFT":{y+=x;break}case"RIGHT":case"TOP_RIGHT":case"BOTTOM_RIGHT":{v+=x;break}}}const S=Math.min(y,v),w=Math.min(_,g),T=Math.abs(v-y),N=Math.abs(g-_);return{...d,geometry:{x:S,y:w,w:T,h:N,bounds:{minX:S,minY:w,maxX:S+T,maxY:w+N}}}};function h(d){De.call(this,r,d)}function u(d){De.call(this,r,d)}function c(d){De.call(this,r,d)}return r.$$set=d=>{"shape"in d&&e(0,s=d.shape),"computedStyle"in d&&e(1,n=d.computedStyle),"transform"in d&&e(2,o=d.transform),"viewportScale"in d&&e(3,a=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&1&&e(4,i=s.geometry)},[s,n,o,a,i,l,h,u,c]}class TS extends re{constructor(t){super(),ee(this,t,ES,bS,Wt,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}function rm(r,t,e){const i=r.slice();return i[10]=t[e],i[12]=e,i}function im(r,t,e){const i=r.slice();return i[13]=t[e],i[15]=e,i}function sm(r,t,e){const i=r.slice();return i[16]=t[e],i[18]=e,i}function nm(r){let t,e;return t=new ls({props:{x:r[16][0],y:r[16][1],scale:r[3]}}),t.$on("pointerdown",function(){Kt(r[9](`HANDLE-${r[12]}-${r[15]}-${r[18]}`))&&r[9](`HANDLE-${r[12]}-${r[15]}-${r[18]}`).apply(this,arguments)}),{c(){$t(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){r=i;const n={};s&16&&(n.x=r[16][0]),s&16&&(n.y=r[16][1]),s&8&&(n.scale=r[3]),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function om(r){let t,e,i=Se(r[13].points),s=[];for(let o=0;o<i.length;o+=1)s[o]=nm(sm(r,i,o));const n=o=>et(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=Re()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);ct(o,t,a),e=!0},p(o,a){if(a&536){i=Se(o[13].points);let l;for(l=0;l<i.length;l+=1){const h=sm(o,i,l);s[l]?(s[l].p(h,a),q(s[l],1)):(s[l]=nm(h),s[l].c(),q(s[l],1),s[l].m(t.parentNode,t))}for(ge(),l=i.length;l<s.length;l+=1)n(l);ye()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)q(s[a]);e=!0}},o(o){s=s.filter(Boolean);for(let a=0;a<s.length;a+=1)et(s[a]);e=!1},d(o){o&&ht(t),ii(s,o)}}}function am(r){let t,e,i,s,n,o,a,l,h,u=Se(r[10].rings),c=[];for(let f=0;f<u.length;f+=1)c[f]=om(im(r,u,f));const d=f=>et(c[f],1,1,()=>{c[f]=null});return{c(){t=xt("g"),e=xt("path"),n=xt("path");for(let f=0;f<c.length;f+=1)c[f].c();R(e,"class","a9s-outer"),R(e,"style",i=r[1]?"display:none;":void 0),R(e,"fill-rule","evenodd"),R(e,"d",s=No(r[10])),R(n,"class","a9s-inner"),R(n,"style",r[1]),R(n,"fill-rule","evenodd"),R(n,"d",o=No(r[10]))},m(f,p){ct(f,t,p),Ae(t,e),Ae(t,n);for(let m=0;m<c.length;m+=1)c[m]&&c[m].m(t,null);a=!0,l||(h=[Zt(e,"pointerdown",function(){Kt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Zt(n,"pointerdown",function(){Kt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)})],l=!0)},p(f,p){if(r=f,(!a||p&2&&i!==(i=r[1]?"display:none;":void 0))&&R(e,"style",i),(!a||p&16&&s!==(s=No(r[10])))&&R(e,"d",s),(!a||p&2)&&R(n,"style",r[1]),(!a||p&16&&o!==(o=No(r[10])))&&R(n,"d",o),p&536){u=Se(r[10].rings);let m;for(m=0;m<u.length;m+=1){const y=im(r,u,m);c[m]?(c[m].p(y,p),q(c[m],1)):(c[m]=om(y),c[m].c(),q(c[m],1),c[m].m(t,null))}for(ge(),m=u.length;m<c.length;m+=1)d(m);ye()}},i(f){if(!a){for(let p=0;p<u.length;p+=1)q(c[p]);a=!0}},o(f){c=c.filter(Boolean);for(let p=0;p<c.length;p+=1)et(c[p]);a=!1},d(f){f&&ht(t),ii(c,f),l=!1,er(h)}}}function wS(r){let t,e,i=Se(r[4].polygons),s=[];for(let o=0;o<i.length;o+=1)s[o]=am(rm(r,i,o));const n=o=>et(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=Re()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);ct(o,t,a),e=!0},p(o,a){if(a&538){i=Se(o[4].polygons);let l;for(l=0;l<i.length;l+=1){const h=rm(o,i,l);s[l]?(s[l].p(h,a),q(s[l],1)):(s[l]=am(h),s[l].c(),q(s[l],1),s[l].m(t.parentNode,t))}for(ge(),l=i.length;l<s.length;l+=1)n(l);ye()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)q(s[a]);e=!0}},o(o){s=s.filter(Boolean);for(let a=0;a<s.length;a+=1)et(s[a]);e=!1},d(o){o&&ht(t),ii(s,o)}}}function AS(r){let t,e;return t=new bh({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[wS,({grab:i})=>({9:i}),({grab:i})=>i?512:0]},$$scope:{ctx:r}}}),t.$on("change",r[6]),t.$on("grab",r[7]),t.$on("release",r[8]),{c(){$t(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,[s]){const n={};s&1&&(n.shape=i[0]),s&4&&(n.transform=i[2]),s&524826&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function SS(r,t,e){let i,{shape:s}=t,{computedStyle:n}=t,{transform:o}=t,{viewportScale:a=1}=t;const l=(d,f,p)=>{const m=d.geometry.polygons;let y;if(f==="SHAPE")y=m.map(_=>{const v=_.rings.map((x,b)=>({points:x.points.map((w,T)=>[w[0]+p[0],w[1]+p[1]])})),g=Oo(v[0].points);return{rings:v,bounds:g}});else{const[_,v,g,x]=f.split("-").map(b=>parseInt(b));y=m.map((b,S)=>{if(S===v){const w=b.rings.map((N,F)=>F===g?{points:N.points.map((C,E)=>E===x?[C[0]+p[0],C[1]+p[1]]:C)}:N),T=Oo(w[0].points);return{rings:w,bounds:T}}else return b})}return{...d,geometry:{polygons:y,bounds:HA(y)}}};function h(d){De.call(this,r,d)}function u(d){De.call(this,r,d)}function c(d){De.call(this,r,d)}return r.$$set=d=>{"shape"in d&&e(0,s=d.shape),"computedStyle"in d&&e(1,n=d.computedStyle),"transform"in d&&e(2,o=d.transform),"viewportScale"in d&&e(3,a=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&1&&e(4,i=s.geometry)},[s,n,o,a,i,l,h,u,c]}class CS extends re{constructor(t){super(),ee(this,t,SS,AS,Wt,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}jr.RECTANGLE,jr.POLYGON,jr.MULTIPOLYGLON;const IS=r=>({}),lm=r=>({grab:r[0]});function RS(r){let t,e,i,s;const n=r[7].default,o=Zu(n,r,r[6],lm);return{c(){t=xt("g"),o&&o.c(),R(t,"class","a9s-annotation selected")},m(a,l){ct(a,t,l),o&&o.m(t,null),e=!0,i||(s=[Zt(t,"pointerup",r[2]),Zt(t,"pointermove",r[1])],i=!0)},p(a,[l]){o&&o.p&&(!e||l&64)&&tc(o,n,a,a[6],e?Ju(n,a[6],l,IS):ec(a[6]),lm)},i(a){e||(q(o,a),e=!0)},o(a){et(o,a),e=!1},d(a){a&&ht(t),o&&o.d(a),i=!1,er(s)}}}function MS(r,t,e){let{$$slots:i={},$$scope:s}=t;const n=yn();let{shape:o}=t,{editor:a}=t,{transform:l}=t,h,u,c;const d=m=>y=>{h=m,u=l.elementToImage(y.offsetX,y.offsetY),c=o,y.target.setPointerCapture(y.pointerId),n("grab",y)},f=m=>{if(h){const[y,_]=l.elementToImage(m.offsetX,m.offsetY),v=[y-u[0],_-u[1]];e(3,o=a(c,h,v)),n("change",o)}},p=m=>{m.target.releasePointerCapture(m.pointerId),h=void 0,c=o,n("release",m)};return r.$$set=m=>{"shape"in m&&e(3,o=m.shape),"editor"in m&&e(4,a=m.editor),"transform"in m&&e(5,l=m.transform),"$$scope"in m&&e(6,s=m.$$scope)},[d,f,p,o,a,l,s,i]}class bh extends re{constructor(t){super(),ee(this,t,MS,RS,Wt,{shape:3,editor:4,transform:5})}}const PS=(r,t)=>{const e=typeof t=="function"?t(r):t;if(e){const{fill:i,fillOpacity:s,stroke:n,strokeWidth:o,strokeOpacity:a}=e;let l="";return i&&(l+=`fill:${i};`,l+=`fill-opacity:${s||"0.25"};`),n&&(l+=`stroke:${n};`,l+=`stroke-width:${o||"1"};`,l+=`stroke-opacity:${a||"1"};`),l}};function OS(r,t,e){let i;const s=yn();let{annotation:n}=t,{editor:o}=t,{style:a}=t,{target:l}=t,{transform:h}=t,{viewportScale:u}=t,c;return gn(()=>(e(6,c=new o({target:l,props:{shape:n.target.selector,computedStyle:i,transform:h,viewportScale:u}})),c.$on("change",d=>{c.$$set({shape:d.detail}),s("change",d.detail)}),c.$on("grab",d=>s("grab",d.detail)),c.$on("release",d=>s("release",d.detail)),()=>{c.$destroy()})),r.$$set=d=>{"annotation"in d&&e(0,n=d.annotation),"editor"in d&&e(1,o=d.editor),"style"in d&&e(2,a=d.style),"target"in d&&e(3,l=d.target),"transform"in d&&e(4,h=d.transform),"viewportScale"in d&&e(5,u=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&5&&e(7,i=PS(n,a)),r.$$.dirty&65&&n&&(c==null||c.$set({shape:n.target.selector})),r.$$.dirty&80&&c&&c.$set({transform:h}),r.$$.dirty&96&&c&&c.$set({viewportScale:u}),r.$$.dirty&192&&c&&i&&c.$set({computedStyle:i})},[n,o,a,l,h,u,c,i]}class NS extends re{constructor(t){super(),ee(this,t,OS,null,Wt,{annotation:0,editor:1,style:2,target:3,transform:4,viewportScale:5})}}typeof navigator>"u"?!1:navigator.userAgent.indexOf("Mac OS X")!==-1;const hm=(r,t,e,i)=>{if(!i)return r;if(t.shiftKey||t.ctrlKey||t.metaKey){const n=(e.selected||[]).map(o=>o.id);return n.includes(r)?n.filter(o=>o!==r):[...n,r]}else return r},DS=r=>({transform:r&2,scale:r&1}),um=r=>({transform:r[1],scale:r[0]});function LS(r){let t;const e=r[4].default,i=Zu(e,r,r[3],um);return{c(){i&&i.c()},m(s,n){i&&i.m(s,n),t=!0},p(s,[n]){i&&i.p&&(!t||n&11)&&tc(i,e,s,s[3],t?Ju(e,s[3],n,DS):ec(s[3]),um)},i(s){t||(q(i,s),t=!0)},o(s){et(i,s),t=!1},d(s){i&&i.d(s)}}}function BS(r,t,e){let{$$slots:i={},$$scope:s}=t,{viewer:n}=t,o=1,a;const l=()=>{const h=n.viewport.getContainerSize().x,u=n.viewport.getZoom(!0),c=n.viewport.getFlip(),d=n.viewport.pixelFromPoint(new de.Point(0,0),!0);c&&(d.x=h-d.x);const f=u*h/n.world.getContentFactor(),p=c?-f:f,m=n.viewport.getRotation(!0);e(1,a=`translate(${d.x}, ${d.y}) scale(${p}, ${f}) rotate(${m})`),e(0,o=u*h/n.world.getContentFactor())};return gn(()=>(n.addHandler("update-viewport",l),()=>{n.removeHandler("update-viewport",l)})),r.$$set=h=>{"viewer"in h&&e(2,n=h.viewer),"$$scope"in h&&e(3,s=h.$$scope)},[o,a,n,s,i]}class Eh extends re{constructor(t){super(),ee(this,t,BS,LS,Wt,{viewer:2})}}function FS(r,t,e){const i=yn();let{drawingMode:s}=t,{opts:n}=t,{target:o}=t,{tool:a}=t,{transform:l}=t,{viewer:h}=t,{viewportScale:u}=t,c;return gn(()=>{const d=o.closest("svg"),f=[],p=(m,y,_)=>{if(d==null||d.addEventListener(m,y,_),f.push(()=>d==null?void 0:d.removeEventListener(m,y,_)),m==="pointerup"||m==="dblclick"){const v=x=>{const{originalEvent:b}=x;y(b)},g=m==="pointerup"?"canvas-click":"canvas-double-click";h.addHandler(g,v),f.push(()=>h.removeHandler(g,v))}else if(m==="pointermove"){const v=g=>{const{originalEvent:x}=g;y(x)};h.addHandler("canvas-drag",v),f.push(()=>h.removeHandler("canvas-drag",v))}};return e(7,c=new a({target:o,props:{addEventListener:p,drawingMode:s,opts:n,transform:l,viewportScale:u}})),c.$on("create",m=>i("create",m.detail)),()=>{f.forEach(m=>m()),c.$destroy()}}),r.$$set=d=>{"drawingMode"in d&&e(0,s=d.drawingMode),"opts"in d&&e(1,n=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,u=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&144&&c&&c.$set({transform:l}),r.$$.dirty&192&&c&&c.$set({viewportScale:u})},[s,n,o,a,l,h,u,c]}class US extends re{constructor(t){super(),ee(this,t,FS,null,Wt,{drawingMode:0,opts:1,target:2,tool:3,transform:4,viewer:5,viewportScale:6})}}function cm(r,t,e){const i=r.slice();i[35]=t[e];const s=i[16](i[35].target.selector);return i[36]=s,i}function kS(r){let t=`${r[2]}-${r[6]}`,e,i,s=dm(r);return{c(){s.c(),e=Re()},m(n,o){s.m(n,o),ct(n,e,o),i=!0},p(n,o){o[0]&68&&Wt(t,t=`${n[2]}-${n[6]}`)?(ge(),et(s,1,1,me),ye(),s=dm(n),s.c(),q(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(q(s),i=!0)},o(n){et(s),i=!1},d(n){n&&ht(e),s.d(n)}}}function GS(r){let t,e,i=Se(r[8].filter(r[26])),s=[];for(let o=0;o<i.length;o+=1)s[o]=mm(cm(r,i,o));const n=o=>et(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=Re()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);ct(o,t,a),e=!0},p(o,a){if(a[0]&96642|a[1]&8){i=Se(o[8].filter(o[26]));let l;for(l=0;l<i.length;l+=1){const h=cm(o,i,l);s[l]?(s[l].p(h,a),q(s[l],1)):(s[l]=mm(h),s[l].c(),q(s[l],1),s[l].m(t.parentNode,t))}for(ge(),l=i.length;l<s.length;l+=1)n(l);ye()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)q(s[a]);e=!0}},o(o){s=s.filter(Boolean);for(let a=0;a<s.length;a+=1)et(s[a]);e=!1},d(o){o&&ht(t),ii(s,o)}}}function dm(r){let t,e;return t=new US({props:{target:r[7],tool:r[9],drawingMode:r[4],transform:{elementToImage:r[11]},viewer:r[3],viewportScale:r[34],opts:r[5]}}),t.$on("create",r[15]),{c(){$t(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){const n={};s[0]&128&&(n.target=i[7]),s[0]&512&&(n.tool=i[9]),s[0]&16&&(n.drawingMode=i[4]),s[0]&8&&(n.viewer=i[3]),s[1]&8&&(n.viewportScale=i[34]),s[0]&32&&(n.opts=i[5]),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function fm(r){let t=r[35].id,e,i,s=pm(r);return{c(){s.c(),e=Re()},m(n,o){s.m(n,o),ct(n,e,o),i=!0},p(n,o){o[0]&256&&Wt(t,t=n[35].id)?(ge(),et(s,1,1,me),ye(),s=pm(n),s.c(),q(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(q(s),i=!0)},o(n){et(s),i=!1},d(n){n&&ht(e),s.d(n)}}}function pm(r){let t,e;return t=new NS({props:{target:r[7],editor:r[16](r[35].target.selector),annotation:r[35],style:r[1],transform:{elementToImage:r[11]},viewportScale:r[34]}}),t.$on("grab",r[12]),t.$on("change",function(){Kt(r[14](r[35]))&&r[14](r[35]).apply(this,arguments)}),t.$on("release",r[13]),{c(){$t(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&128&&(n.target=r[7]),s[0]&256&&(n.editor=r[16](r[35].target.selector)),s[0]&256&&(n.annotation=r[35]),s[0]&2&&(n.style=r[1]),s[1]&8&&(n.viewportScale=r[34]),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function mm(r){let t,e,i=r[36]&&fm(r);return{c(){i&&i.c(),t=Re()},m(s,n){i&&i.m(s,n),ct(s,t,n),e=!0},p(s,n){s[36]?i?(i.p(s,n),n[0]&256&&q(i,1)):(i=fm(s),i.c(),q(i,1),i.m(t.parentNode,t)):i&&(ge(),et(i,1,1,()=>{i=null}),ye())},i(s){e||(q(i),e=!0)},o(s){et(i),e=!1},d(s){s&&ht(t),i&&i.d(s)}}}function HS(r){let t,e,i,s,n,o;const a=[GS,kS],l=[];function h(u,c){var d;return u[7]&&((d=u[8])==null?void 0:d.length)===1?0:u[7]&&u[9]&&u[0]?1:-1}return~(i=h(r))&&(s=l[i]=a[i](r)),{c(){t=xt("svg"),e=xt("g"),s&&s.c(),R(e,"transform",n=r[33]),R(e,"class","svelte-190cqdf"),R(t,"class","a9s-annotationlayer a9s-osd-drawinglayer svelte-190cqdf"),mn(t,"drawing",r[0])},m(u,c){ct(u,t,c),Ae(t,e),~i&&l[i].m(e,null),r[27](e),o=!0},p(u,c){let d=i;i=h(u),i===d?~i&&l[i].p(u,c):(s&&(ge(),et(l[d],1,1,()=>{l[d]=null}),ye()),~i?(s=l[i],s?s.p(u,c):(s=l[i]=a[i](u),s.c()),q(s,1),s.m(e,null)):s=null),(!o||c[1]&4&&n!==(n=u[33]))&&R(e,"transform",n),(!o||c[0]&1)&&mn(t,"drawing",u[0])},i(u){o||(q(s),o=!0)},o(u){et(s),o=!1},d(u){u&&ht(t),~i&&l[i].d(),r[27](null)}}}function $S(r){let t,e;return t=new Eh({props:{viewer:r[3],$$slots:{default:[HS,({transform:i,scale:s})=>({33:i,34:s}),({transform:i,scale:s})=>[0,(i?4:0)|(s?8:0)]]},$$scope:{ctx:r}}}),{c(){$t(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){const n={};s[0]&8&&(n.viewer=i[3]),s[0]&1023|s[1]&268&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function VS(r,t,e){let i,s,n,o,{drawingEnabled:a}=t,{filter:l}=t,{multiSelect:h}=t,{preferredDrawingMode:u}=t,{state:c}=t,{style:d=void 0}=t,{toolName:f=hn()[0]}=t,{user:p}=t,{viewer:m}=t,y=0;const _=()=>e(6,y+=1),v=()=>f,g=()=>a;let x;const{store:b,selection:S,hover:w}=c;fn(r,S,M=>e(25,o=M));let T,N,F;const z=M=>{b.unobserve(T);const L=M.filter(({editable:V})=>V).map(({id:V})=>V);L.length>0?(e(8,N=L.map(V=>b.getAnnotation(V))),T=V=>{const{updated:rt}=V.changes;e(8,N=(rt||[]).map(Q=>Q.newValue))},b.observe(T,{annotations:L}),m.forceRedraw()):e(8,N=void 0)},C=(M,L)=>{const{x:V,y:rt}=m.viewport.viewerElementToImageCoordinates(new de.Point(M,L));return[V,rt]},E=M=>{m.setMouseNavEnabled(!1),F=M.timeStamp},I=M=>{if(m.setMouseNavEnabled(!0),performance.now()-(F||0)<300){const{offsetX:V,offsetY:rt}=M.detail,[Q,X]=C(V,rt),_t=b.getAt(Q,X);if(_t&&(!l||l(_t))&&!N.find(O=>O.id===_t.id)){w.set(_t.id);const O=hm(_t.id,M.detail,S,h);S.userSelect(O)}}},P=M=>L=>{var X;const{target:V}=M,rt=10*60*1e3,Q=((X=V.creator)==null?void 0:X.id)!==p.id||!V.created||new Date().getTime()-V.created.getTime()>rt;b.updateTarget({...V,selector:L.detail,created:Q?V.created:new Date,updated:Q?new Date:void 0,updatedBy:Q?p:void 0})},H=M=>{const L=FA(),V={id:L,bodies:[],target:{annotation:L,selector:M.detail,creator:p,created:new Date}};b.addAnnotation(V),S.setSelected(V.id),m.setMouseNavEnabled(!0)},k=M=>bu(M),G=M=>Ge(M);function st(M){_n[M?"unshift":"push"](()=>{x=M,e(7,x)})}return r.$$set=M=>{"drawingEnabled"in M&&e(0,a=M.drawingEnabled),"filter"in M&&e(17,l=M.filter),"multiSelect"in M&&e(18,h=M.multiSelect),"preferredDrawingMode"in M&&e(19,u=M.preferredDrawingMode),"state"in M&&e(20,c=M.state),"style"in M&&e(1,d=M.style),"toolName"in M&&e(2,f=M.toolName),"user"in M&&e(21,p=M.user),"viewer"in M&&e(3,m=M.viewer)},r.$$.update=()=>{r.$$.dirty[0]&4&&e(9,{tool:i,opts:s}=un(f)||{tool:void 0,opts:void 0},i,(e(5,s),e(2,f))),r.$$.dirty[0]&524320&&e(4,n=(s==null?void 0:s.drawingMode)||u),r.$$.dirty[0]&25&&(a&&n==="drag"?m.setMouseNavEnabled(!1):m.setMouseNavEnabled(!0)),r.$$.dirty[0]&1&&a&&S.clear(),r.$$.dirty[0]&33554457&&o.selected.length===0&&n==="drag"&&a&&m.setMouseNavEnabled(!1),r.$$.dirty[0]&33554432&&z(o.selected)},[a,d,f,m,n,s,y,x,N,i,S,C,E,I,P,H,k,l,h,u,c,p,_,v,g,o,G,st]}class XS extends re{constructor(t){super(),ee(this,t,VS,$S,Wt,{drawingEnabled:0,filter:17,multiSelect:18,preferredDrawingMode:19,state:20,style:1,toolName:2,user:21,viewer:3,cancelDrawing:22,getDrawingTool:23,isDrawingEnabled:24},null,[-1,-1])}get cancelDrawing(){return this.$$.ctx[22]}get getDrawingTool(){return this.$$.ctx[23]}get isDrawingEnabled(){return this.$$.ctx[24]}}function zS(r){let t,e,i,s,n,o,a,l=r[2].appearance.label+"",h,u,c,d;return{c(){t=xt("g"),e=xt("rect"),a=xt("text"),h=ma(l),R(e,"class","a9s-presence-label-bg svelte-1rehw2p"),R(e,"x",r[0]),R(e,"y",i=r[1]-18/r[3]),R(e,"height",s=18/r[3]),R(e,"fill",n=r[2].appearance.color),R(e,"stroke",o=r[2].appearance.color),R(a,"font-size",u=12/r[3]),R(a,"x",c=r[0]+Math.round(5/r[3])),R(a,"y",d=r[1]-5/r[3]),R(a,"class","svelte-1rehw2p"),R(t,"class","a9s-presence-label")},m(f,p){ct(f,t,p),Ae(t,e),Ae(t,a),Ae(a,h),r[6](t)},p(f,[p]){p&1&&R(e,"x",f[0]),p&10&&i!==(i=f[1]-18/f[3])&&R(e,"y",i),p&8&&s!==(s=18/f[3])&&R(e,"height",s),p&4&&n!==(n=f[2].appearance.color)&&R(e,"fill",n),p&4&&o!==(o=f[2].appearance.color)&&R(e,"stroke",o),p&4&&l!==(l=f[2].appearance.label+"")&&c0(h,l),p&8&&u!==(u=12/f[3])&&R(a,"font-size",u),p&9&&c!==(c=f[0]+Math.round(5/f[3]))&&R(a,"x",c),p&10&&d!==(d=f[1]-5/f[3])&&R(a,"y",d)},i:me,o:me,d(f){f&&ht(t),r[6](null)}}}function WS(r,t,e){let{x:i}=t,{y:s}=t,{user:n}=t,{scale:o}=t,{hAlign:a=null}=t,l;const h=c=>{const d=l.querySelector("text"),f=l.querySelector("rect"),p=d.getBBox().width+10/c;a==="CENTER"&&l.setAttribute("style",`transform: translateX(-${p/2}px)`),f.setAttribute("width",`${p}`)};function u(c){_n[c?"unshift":"push"](()=>{l=c,e(4,l)})}return r.$$set=c=>{"x"in c&&e(0,i=c.x),"y"in c&&e(1,s=c.y),"user"in c&&e(2,n=c.user),"scale"in c&&e(3,o=c.scale),"hAlign"in c&&e(5,a=c.hAlign)},r.$$.update=()=>{r.$$.dirty&24&&l&&h(o)},[i,s,n,o,l,a,u]}class gm extends re{constructor(t){super(),ee(this,t,WS,zS,Wt,{x:0,y:1,user:2,scale:3,hAlign:5})}}function YS(r){let t,e,i,s,n,o;return e=new gm({props:{scale:r[1],user:r[0],x:r[3][0],y:r[3][1],hAlign:"CENTER"}}),{c(){t=xt("g"),$t(e.$$.fragment),i=xt("polygon"),R(i,"class","a9s-presence-shape a9s-presence-polygon svelte-fgq4n0"),R(i,"stroke",s=r[0].appearance.color),R(i,"fill","transparent"),R(i,"points",n=r[2].points.map(ym).join(" ")),R(t,"class","a9s-presence-overlay")},m(a,l){ct(a,t,l),Ft(e,t,null),Ae(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&&s!==(s=a[0].appearance.color))&&R(i,"stroke",s),(!o||l&4&&n!==(n=a[2].points.map(ym).join(" ")))&&R(i,"points",n)},i(a){o||(q(e.$$.fragment,a),o=!0)},o(a){et(e.$$.fragment,a),o=!1},d(a){a&&ht(t),Ut(e)}}}const ym=r=>r.join(",");function jS(r,t,e){let i,s,{annotation:n}=t,{user:o}=t,{scale:a}=t;const l=h=>{let[u,...c]=h.points;return c.forEach(([d,f])=>{f<u[1]&&(u=[d,f])}),u};return r.$$set=h=>{"annotation"in h&&e(4,n=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=n.target.selector.geometry),r.$$.dirty&4&&e(3,s=l(i))},[o,a,i,s,n]}class qS extends re{constructor(t){super(),ee(this,t,jS,YS,Wt,{annotation:4,user:0,scale:1})}}function KS(r){let t,e,i,s,n,o,a,l,h;return e=new gm({props:{scale:r[1],user:r[0],x:r[2].x,y:r[2].y}}),{c(){t=xt("g"),$t(e.$$.fragment),i=xt("rect"),R(i,"class","a9s-presence-shape a9s-presence-rectangle svelte-gze948"),R(i,"stroke",s=r[0].appearance.color),R(i,"fill","transparent"),R(i,"x",n=r[2].x),R(i,"y",o=r[2].y),R(i,"width",a=r[2].w),R(i,"height",l=r[2].h),R(t,"class","a9s-presence-overlay")},m(u,c){ct(u,t,c),Ft(e,t,null),Ae(t,i),h=!0},p(u,[c]){const d={};c&2&&(d.scale=u[1]),c&1&&(d.user=u[0]),c&4&&(d.x=u[2].x),c&4&&(d.y=u[2].y),e.$set(d),(!h||c&1&&s!==(s=u[0].appearance.color))&&R(i,"stroke",s),(!h||c&4&&n!==(n=u[2].x))&&R(i,"x",n),(!h||c&4&&o!==(o=u[2].y))&&R(i,"y",o),(!h||c&4&&a!==(a=u[2].w))&&R(i,"width",a),(!h||c&4&&l!==(l=u[2].h))&&R(i,"height",l)},i(u){h||(q(e.$$.fragment,u),h=!0)},o(u){et(e.$$.fragment,u),h=!1},d(u){u&&ht(t),Ut(e)}}}function ZS(r,t,e){let i,{annotation:s}=t,{user:n}=t,{scale:o}=t;return r.$$set=a=>{"annotation"in a&&e(3,s=a.annotation),"user"in a&&e(0,n=a.user),"scale"in a&&e(1,o=a.scale)},r.$$.update=()=>{r.$$.dirty&8&&e(2,i=s.target.selector.geometry)},[n,o,i,s]}class QS extends re{constructor(t){super(),ee(this,t,ZS,KS,Wt,{annotation:3,user:0,scale:1})}}const{Boolean:JS}=ic;function _m(r,t,e){const i=r.slice();return i[8]=t[e],i}function vm(r){let t,e;return t=new Eh({props:{viewer:r[0],$$slots:{default:[rC,({transform:i,scale:s})=>({6:i,7:s}),({transform:i,scale:s})=>(i?64:0)|(s?128:0)]},$$scope:{ctx:r}}}),{c(){$t(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){const n={};s&1&&(n.viewer=i[0]),s&2244&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function xm(r){let t,e,i=Se(r[2]),s=[];for(let o=0;o<i.length;o+=1)s[o]=bm(_m(r,i,o));const n=o=>et(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=Re()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);ct(o,t,a),e=!0},p(o,a){if(a&132){i=Se(o[2]);let l;for(l=0;l<i.length;l+=1){const h=_m(o,i,l);s[l]?(s[l].p(h,a),q(s[l],1)):(s[l]=bm(h),s[l].c(),q(s[l],1),s[l].m(t.parentNode,t))}for(ge(),l=i.length;l<s.length;l+=1)n(l);ye()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)q(s[a]);e=!0}},o(o){s=s.filter(JS);for(let a=0;a<s.length;a+=1)et(s[a]);e=!1},d(o){o&&ht(t),ii(s,o)}}}function tC(r){let t,e;return t=new qS({props:{annotation:r[8].annotation,user:r[8].selectedBy,scale:r[7]}}),{c(){$t(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){const n={};s&4&&(n.annotation=i[8].annotation),s&4&&(n.user=i[8].selectedBy),s&128&&(n.scale=i[7]),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function eC(r){let t,e;return t=new QS({props:{annotation:r[8].annotation,user:r[8].selectedBy,scale:r[7]}}),{c(){$t(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){const n={};s&4&&(n.annotation=i[8].annotation),s&4&&(n.user=i[8].selectedBy),s&128&&(n.scale=i[7]),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function bm(r){let t,e,i,s;const n=[eC,tC],o=[];function a(l,h){return l[8].annotation.target.selector.type===vt.RECTANGLE?0:l[8].annotation.target.selector.type===vt.POLYGON?1:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=Re()},m(l,h){~t&&o[t].m(l,h),ct(l,i,h),s=!0},p(l,h){let u=t;t=a(l),t===u?~t&&o[t].p(l,h):(e&&(ge(),et(o[u],1,1,()=>{o[u]=null}),ye()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=n[t](l),e.c()),q(e,1),e.m(i.parentNode,i)):e=null)},i(l){s||(q(e),s=!0)},o(l){et(e),s=!1},d(l){l&&ht(i),~t&&o[t].d(l)}}}function rC(r){let t,e,i,s,n=r[2].length>0&&xm(r);return{c(){t=xt("svg"),e=xt("g"),n&&n.c(),R(e,"transform",i=r[6]),R(t,"class","a9s-osd-presencelayer svelte-1krwc4m")},m(o,a){ct(o,t,a),Ae(t,e),n&&n.m(e,null),s=!0},p(o,a){o[2].length>0?n?(n.p(o,a),a&4&&q(n,1)):(n=xm(o),n.c(),q(n,1),n.m(e,null)):n&&(ge(),et(n,1,1,()=>{n=null}),ye()),(!s||a&64&&i!==(i=o[6]))&&R(e,"transform",i)},i(o){s||(q(n),s=!0)},o(o){et(n),s=!1},d(o){o&&ht(t),n&&n.d()}}}function iC(r){let t=!!r[1],e,i,s=t&&vm(r);return{c(){s&&s.c(),e=Re()},m(n,o){s&&s.m(n,o),ct(n,e,o),i=!0},p(n,[o]){o&2&&(t=!!n[1]),t?s?(s.p(n,o),o&2&&q(s,1)):(s=vm(n),s.c(),q(s,1),s.m(e.parentNode,e)):s&&(ge(),et(s,1,1,()=>{s=null}),ye())},i(n){i||(q(s),i=!0)},o(n){et(s),i=!1},d(n){n&&ht(e),s&&s.d(n)}}}function sC(r,t,e){let{store:i}=t,{viewer:s}=t,{provider:n}=t,o=[],a;const l=(h,u)=>{e(2,o=[...o.filter(({selectedBy:c})=>c.presenceKey!==h.presenceKey),...(u||[]).map(c=>({annotation:i.getAnnotation(c),selectedBy:h}))].filter(({annotation:c})=>(c||console.warn("Selection event on unknown annotation"),!!c))),a&&i.unobserve(a),a=c=>{const{deleted:d,updated:f}=c.changes,p=new Set((d||[]).map(y=>y.id)),m=o.filter(({annotation:y})=>!p.has(y.id)).map(y=>{const _=(f||[]).find(v=>v.oldValue.id===y.annotation.id);return _?{selectedBy:y.selectedBy,annotation:_.newValue}:y});e(2,o=m)},i.observe(a,{annotations:o.map(c=>c.annotation.id)})};return f0(()=>{a&&i.unobserve(a)}),r.$$set=h=>{"store"in h&&e(3,i=h.store),"viewer"in h&&e(0,s=h.viewer),"provider"in h&&e(1,n=h.provider)},r.$$.update=()=>{r.$$.dirty&2&&n&&n.on("selectionChange",l)},[s,n,o,i]}class nC extends re{constructor(t){super(),ee(this,t,sC,iC,Wt,{store:3,viewer:0,provider:1})}}function oC(r){let t,e,i,s,n;return{c(){t=xt("rect"),R(t,"x",e=r[0].x),R(t,"y",i=r[0].y),R(t,"width",s=r[0].w),R(t,"height",n=r[0].h)},m(o,a){ct(o,t,a)},p(o,[a]){a&1&&e!==(e=o[0].x)&&R(t,"x",e),a&1&&i!==(i=o[0].y)&&R(t,"y",i),a&1&&s!==(s=o[0].w)&&R(t,"width",s),a&1&&n!==(n=o[0].h)&&R(t,"height",n)},i:me,o:me,d(o){o&&ht(t)}}}function aC(r,t,e){let i,{annotation:s}=t;return r.$$set=n=>{"annotation"in n&&e(1,s=n.annotation)},r.$$.update=()=>{r.$$.dirty&2&&e(0,i=s.target.selector.geometry)},[i,s]}class lC extends re{constructor(t){super(),ee(this,t,aC,oC,Wt,{annotation:1})}}function hC(r){let t,e;return{c(){t=xt("polygon"),R(t,"points",e=r[0].points.map(Em).join(" "))},m(i,s){ct(i,t,s)},p(i,[s]){s&1&&e!==(e=i[0].points.map(Em).join(" "))&&R(t,"points",e)},i:me,o:me,d(i){i&&ht(t)}}}const Em=r=>r.join(",");function uC(r,t,e){let i,{annotation:s}=t;return r.$$set=n=>{"annotation"in n&&e(1,s=n.annotation)},r.$$.update=()=>{r.$$.dirty&2&&e(0,i=s.target.selector.geometry)},[i,s]}class cC extends re{constructor(t){super(),ee(this,t,uC,hC,Wt,{annotation:1})}}function dC(r){let t,e,i,s,n;return{c(){t=xt("ellipse"),R(t,"cx",e=r[0].cx),R(t,"cy",i=r[0].cy),R(t,"rx",s=r[0].rx),R(t,"ry",n=r[0].ry)},m(o,a){ct(o,t,a)},p(o,[a]){a&1&&e!==(e=o[0].cx)&&R(t,"cx",e),a&1&&i!==(i=o[0].cy)&&R(t,"cy",i),a&1&&s!==(s=o[0].rx)&&R(t,"rx",s),a&1&&n!==(n=o[0].ry)&&R(t,"ry",n)},i:me,o:me,d(o){o&&ht(t)}}}function fC(r,t,e){let i,{annotation:s}=t;return r.$$set=n=>{"annotation"in n&&e(1,s=n.annotation)},r.$$.update=()=>{r.$$.dirty&2&&e(0,i=s.target.selector.geometry)},[i,s]}class pC extends re{constructor(t){super(),ee(this,t,fC,dC,Wt,{annotation:1})}}const{Boolean:mC}=ic;function Tm(r,t,e){const i=r.slice();return i[10]=t[e],i}function wm(r){let t,e;return t=new Eh({props:{viewer:r[0],$$slots:{default:[vC,({transform:i})=>({9:i}),({transform:i})=>i?512:0]},$$scope:{ctx:r}}}),{c(){$t(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){const n={};s&1&&(n.viewer=i[0]),s&8710&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function gC(r){let t,e;return t=new pC({props:{annotation:r[10]}}),{c(){$t(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){const n={};s&2&&(n.annotation=i[10]),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function yC(r){let t,e;return t=new cC({props:{annotation:r[10]}}),{c(){$t(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){const n={};s&2&&(n.annotation=i[10]),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function _C(r){let t,e;return t=new lC({props:{annotation:r[10]}}),{c(){$t(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){const n={};s&2&&(n.annotation=i[10]),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function Am(r){let t,e,i,s;const n=[_C,yC,gC],o=[];function a(l,h){return l[10].target.selector.type===vt.RECTANGLE?0:l[10].target.selector.type===vt.POLYGON?1:l[10].target.selector.type===vt.ELLIPSE?2:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=Re()},m(l,h){~t&&o[t].m(l,h),ct(l,i,h),s=!0},p(l,h){let u=t;t=a(l),t===u?~t&&o[t].p(l,h):(e&&(ge(),et(o[u],1,1,()=>{o[u]=null}),ye()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=n[t](l),e.c()),q(e,1),e.m(i.parentNode,i)):e=null)},i(l){s||(q(e),s=!0)},o(l){et(e),s=!1},d(l){l&&ht(i),~t&&o[t].d(l)}}}function vC(r){let t,e,i,s,n,o,a,l,h,u,c,d,f,p,m=Se(r[1].filter(r[6])),y=[];for(let v=0;v<m.length;v+=1)y[v]=Am(Tm(r,m,v));const _=v=>et(y[v],1,1,()=>{y[v]=null});return{c(){var v,g,x,b;t=xt("svg"),e=xt("g"),i=xt("rect"),l=xt("rect");for(let S=0;S<y.length;S+=1)y[S].c();R(i,"class","a9s-union-bg svelte-n2zwns"),R(i,"x",s=(v=r[2])==null?void 0:v.minX),R(i,"y",n=(g=r[2])==null?void 0:g.minY),R(i,"width",o=r[2]?r[2].maxX-r[2].minX:0),R(i,"height",a=r[2]?r[2].maxY-r[2].minY:0),R(l,"class","a9s-union-fg svelte-n2zwns"),R(l,"x",h=(x=r[2])==null?void 0:x.minX),R(l,"y",u=(b=r[2])==null?void 0:b.minY),R(l,"width",c=r[2]?r[2].maxX-r[2].minX:0),R(l,"height",d=r[2]?r[2].maxY-r[2].minY:0),R(e,"transform",f=r[9]),R(t,"class","a9s-osd-selectionlayer svelte-n2zwns")},m(v,g){ct(v,t,g),Ae(t,e),Ae(e,i),Ae(e,l);for(let x=0;x<y.length;x+=1)y[x]&&y[x].m(e,null);p=!0},p(v,g){var x,b,S,w;if((!p||g&4&&s!==(s=(x=v[2])==null?void 0:x.minX))&&R(i,"x",s),(!p||g&4&&n!==(n=(b=v[2])==null?void 0:b.minY))&&R(i,"y",n),(!p||g&4&&o!==(o=v[2]?v[2].maxX-v[2].minX:0))&&R(i,"width",o),(!p||g&4&&a!==(a=v[2]?v[2].maxY-v[2].minY:0))&&R(i,"height",a),(!p||g&4&&h!==(h=(S=v[2])==null?void 0:S.minX))&&R(l,"x",h),(!p||g&4&&u!==(u=(w=v[2])==null?void 0:w.minY))&&R(l,"y",u),(!p||g&4&&c!==(c=v[2]?v[2].maxX-v[2].minX:0))&&R(l,"width",c),(!p||g&4&&d!==(d=v[2]?v[2].maxY-v[2].minY:0))&&R(l,"height",d),g&2){m=Se(v[1].filter(v[6]));let T;for(T=0;T<m.length;T+=1){const N=Tm(v,m,T);y[T]?(y[T].p(N,g),q(y[T],1)):(y[T]=Am(N),y[T].c(),q(y[T],1),y[T].m(e,null))}for(ge(),T=m.length;T<y.length;T+=1)_(T);ye()}(!p||g&512&&f!==(f=v[9]))&&R(e,"transform",f)},i(v){if(!p){for(let g=0;g<m.length;g+=1)q(y[g]);p=!0}},o(v){y=y.filter(mC);for(let g=0;g<y.length;g+=1)et(y[g]);p=!1},d(v){v&&ht(t),ii(y,v)}}}function xC(r){let t=!!r[2],e,i,s=t&&wm(r);return{c(){s&&s.c(),e=Re()},m(n,o){s&&s.m(n,o),ct(n,e,o),i=!0},p(n,[o]){o&4&&(t=!!n[2]),t?s?(s.p(n,o),o&4&&q(s,1)):(s=wm(n),s.c(),q(s,1),s.m(e.parentNode,e)):s&&(ge(),et(s,1,1,()=>{s=null}),ye())},i(n){i||(q(s),i=!0)},o(n){et(s),i=!1},d(n){n&&ht(e),s&&s.d(n)}}}function bC(r,t,e){let i,s,n,{state:o}=t,{viewer:a}=t;const{store:l}=o,{selection:h}=o;fn(r,h,d=>e(5,n=d));const u=d=>{let f=-1/0,p=-1/0,m=1/0,y=1/0;for(let _ of d.filter(v=>Ge(v))){const{bounds:v}=_.target.selector.geometry;v.maxX>f&&(f=v.maxX),v.maxY>p&&(p=v.maxY),v.minX<m&&(m=v.minX),v.minY<y&&(y=v.minY)}return a.forceRedraw(),{maxX:f,maxY:p,minX:m,minY:y}},c=d=>Ge(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=n.selected.map(({id:d})=>l.getAnnotation(d))),r.$$.dirty&2&&e(2,s=i.length>1?u(i):void 0)},[a,i,s,h,o,n,c]}class EC extends re{constructor(t){super(),ee(this,t,bC,xC,Wt,{state:4,viewer:0})}}const Sm=(r,t)=>{t==="auto"?r.addHandler("open",e=>{const i=r.world.getItemCount();r.world.getItemAt(i-1).addOnceHandler("fully-loaded-change",n=>{const{fullyLoaded:o}=n;if(o){const a=r.canvas.querySelector("canvas"),l=Xu(a);r.element.setAttribute("data-theme",l)}})}):r.element.setAttribute("data-theme",t)},Cm=(r,t,e)=>(i,s={})=>{const n=typeof i=="string"?i:i.id,o=t.getAnnotation(n);if(!o||!Ge(o))return;const a=r.container.getBoundingClientRect(),{padding:l}=s;let[h,u,c,d]=l?Array.isArray(l)?l:[l,l,l,l]:[0,0,0,0];h=h/a.height,u=u/a.width,c=c/a.height,d=d/a.width;const{minX:f,minY:p,maxX:m,maxY:y}=o.target.selector.geometry.bounds,_=m-f,v=y-p,g=f-d*_,x=p-h*v,b=_+(u+d)*_,S=v+(h+c)*v,w=r.viewport.imageToViewportRectangle(g,x,b,S);r.viewport[e](w,s.immediately)},TC=(r,t)=>Cm(r,t,"fitBounds"),wC=(r,t)=>Cm(r,t,"fitBoundsWithConstraints"),AC=(r,t={})=>{const e=Wu(t,{drawingEnabled:!1,drawingMode:fu?"drag":"click",userSelectAction:Ho.EDIT,theme:"light"}),i=Vu(e),{hover:s,selection:n,store:o}=i,a=Wm(o,e.initialHistory),l=Ym(i,a,e.adapter,e.autoSave);let h=eg(),u=e.drawingEnabled,c=e.drawingMode,d=e.modalSelect;const f=ju(a,r.element),p=new NA({target:r.element,props:{state:i,viewer:r,style:e.style,filter:void 0}}),m=new nC({target:r.element.querySelector(".openseadragon-canvas"),props:{provider:void 0,store:o,viewer:r}}),y=new XS({target:r.element.querySelector(".openseadragon-canvas"),props:{drawingEnabled:!!u,filter:void 0,multiSelect:e.multiSelect,preferredDrawingMode:c,state:i,style:e.style,user:h,viewer:r}}),_=new EC({target:r.element.querySelector(".openseadragon-canvas"),props:{state:i,viewer:r}});p.$on("click",L=>{const{originalEvent:V,annotation:rt}=L.detail,Q=X=>hm(X.id,V,n,e.multiSelect);d?n.isEmpty()&&rt&&n.userSelect(Q(rt),V):rt&&!(c==="click"&&u)?n.userSelect(Q(rt),V):n.isEmpty()||n.clear()}),r.element.addEventListener("pointerdown",L=>{if(s.current){const V=o.getAnnotation(s.current);l.emit("clickAnnotation",V,L)}}),Sm(r,e.theme);const v=qm(i,a,e.adapter),g=()=>y.cancelDrawing(),x=()=>{p.$destroy(),m.$destroy(),y.$destroy(),_.$destroy(),f.destroy(),a.destroy()},b=TC(r,o),S=wC(r,o),w=()=>y.getDrawingTool(),T=()=>h,N=()=>y.isDrawingEnabled(),F=(L,V,rt)=>Cu(L,V,rt),z=(L,V)=>Eu(L,V),C=L=>{if(!un(L))throw`No drawing tool named ${L}`;y.$set({toolName:L})},E=L=>{u=L,y.$set({drawingEnabled:L})},I=L=>{p.$set({filter:L}),y.$set({filter:L})},P=L=>d=L,H=L=>{p.$set({style:L}),y.$set({style:L})},k=L=>m.$set({provider:L}),G=L=>Sm(r,L),st=L=>{h=L,y.$set({user:L})},M=L=>p.$set({visible:L});return{...v,cancelDrawing:g,destroy:x,fitBounds:b,fitBoundsWithConstraints:S,getDrawingTool:w,getUser:T,isDrawingEnabled:N,listDrawingTools:hn,on:l.on,off:l.off,registerDrawingTool:F,registerShapeEditor:z,setDrawingEnabled:E,setDrawingTool:C,setFilter:I,setModalSelect:P,setPresenceProvider:k,setStyle:H,setTheme:G,setUser:st,setVisible:M,state:i,viewer:r}};Gt.ShapeType=vt,Gt.UserSelectAction=Ho,Gt.W3CImageFormat=$y,Gt.chainStyles=Oy,Gt.computeStyle=Py,Gt.createBody=Fm,Gt.createImageAnnotator=a0,Gt.createOSDAnnotator=AC,Gt.defaultColorProvider=ig,Object.defineProperty(Gt,Symbol.toStringTag,{value:"Module"})});
|
|
1150
1150
|
//# sourceMappingURL=annotorious-openseadragon.js.map
|