@annotorious/openseadragon 3.0.7 → 3.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(Mt,Nt){typeof exports=="object"&&typeof module<"u"?Nt(exports,require("openseadragon")):typeof define=="function"&&define.amd?define(["exports","openseadragon"],Nt):(Mt=typeof globalThis<"u"?globalThis:Mt||self,Nt(Mt.AnnotoriousOSD={},Mt.OpenSeadragon))})(this,function(Mt,Nt){"use strict";var HE=Object.defineProperty;var XE=(Mt,Nt,Pr)=>Nt in Mt?HE(Mt,Nt,{enumerable:!0,configurable:!0,writable:!0,value:Pr}):Mt[Nt]=Pr;var Fl=(Mt,Nt,Pr)=>XE(Mt,typeof Nt!="symbol"?Nt+"":Nt,Pr);var Pr=Object.prototype.hasOwnProperty;function Mr(r,t){var e,i;if(r===t)return!0;if(r&&t&&(e=r.constructor)===t.constructor){if(e===Date)return r.getTime()===t.getTime();if(e===RegExp)return r.toString()===t.toString();if(e===Array){if((i=r.length)===t.length)for(;i--&&Mr(r[i],t[i]););return i===-1}if(!e||typeof r=="object"){i=0;for(e in r)if(Pr.call(r,e)&&++i&&!Pr.call(t,e)||!(e in t)||!Mr(r[e],t[e]))return!1;return Object.keys(t).length===i}}return r!==r&&t!==t}for(var ao=(r=>(r.EDIT="EDIT",r.SELECT="SELECT",r.NONE="NONE",r))(ao||{}),Ht=[],lo=0;lo<256;++lo)Ht.push((lo+256).toString(16).slice(1));function Jf(r,t=0){return(Ht[r[t+0]]+Ht[r[t+1]]+Ht[r[t+2]]+Ht[r[t+3]]+"-"+Ht[r[t+4]]+Ht[r[t+5]]+"-"+Ht[r[t+6]]+Ht[r[t+7]]+"-"+Ht[r[t+8]]+Ht[r[t+9]]+"-"+Ht[r[t+10]]+Ht[r[t+11]]+Ht[r[t+12]]+Ht[r[t+13]]+Ht[r[t+14]]+Ht[r[t+15]]).toLowerCase()}var Cs,Qf=new Uint8Array(16);function tp(){if(!Cs&&(Cs=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Cs))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Cs(Qf)}var ep=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const Xl={randomUUID:ep};function rp(r,t,e){if(Xl.randomUUID&&!t&&!r)return Xl.randomUUID();r=r||{};var i=r.random||(r.rng||tp)();return i[6]=i[6]&15|64,i[8]=i[8]&63|128,Jf(i)}const ho=r=>{const t=e=>{const i={...e};return e.created&&typeof e.created=="string"&&(i.created=new Date(e.created)),e.updated&&typeof e.updated=="string"&&(i.updated=new Date(e.updated)),i};return{...r,bodies:(r.bodies||[]).map(t),target:t(r.target)}},ip=(r,t,e,i)=>({id:rp(),annotation:typeof r=="string"?r:r.id,created:e||new Date,creator:i,...t}),sp=(r,t)=>{const e=new Set(r.bodies.map(i=>i.id));return t.bodies.filter(i=>!e.has(i.id))},np=(r,t)=>{const e=new Set(t.bodies.map(i=>i.id));return r.bodies.filter(i=>!e.has(i.id))},op=(r,t)=>t.bodies.map(e=>{const i=r.bodies.find(s=>s.id===e.id);return{newBody:e,oldBody:i&&!Mr(i,e)?i:void 0}}).filter(({oldBody:e})=>e).map(({oldBody:e,newBody:i})=>({oldBody:e,newBody:i})),ap=(r,t)=>!Mr(r.target,t.target),lp=(r,t)=>{const e=sp(r,t),i=np(r,t),s=op(r,t);return{oldValue:r,newValue:t,bodiesCreated:e.length>0?e:void 0,bodiesDeleted:i.length>0?i:void 0,bodiesUpdated:s.length>0?s:void 0,targetUpdated:ap(r,t)?{oldTarget:r.target,newTarget:t.target}:void 0}};var dr=(r=>(r.LOCAL="LOCAL",r.REMOTE="REMOTE",r.SILENT="SILENT",r))(dr||{});const hp=(r,t)=>{const e=new Set((r.created||[]).map(u=>u.id)),i=new Set((r.updated||[]).map(({newValue:u})=>u.id)),s=new Set((t.created||[]).map(u=>u.id)),n=new Set((t.deleted||[]).map(u=>u.id)),o=new Set((t.updated||[]).map(({oldValue:u})=>u.id)),a=new Set((t.updated||[]).filter(({oldValue:u})=>e.has(u.id)||i.has(u.id)).map(({oldValue:u})=>u.id)),l=[...(r.created||[]).filter(u=>!n.has(u.id)).map(u=>o.has(u.id)?t.updated.find(({oldValue:d})=>d.id===u.id).newValue:u),...t.created||[]],h=[...(r.deleted||[]).filter(u=>!s.has(u.id)),...(t.deleted||[]).filter(u=>!e.has(u.id))],c=[...(r.updated||[]).filter(({newValue:u})=>!n.has(u.id)).map(u=>{const{oldValue:d,newValue:f}=u;if(o.has(f.id)){const p=t.updated.find(m=>m.oldValue.id===f.id).newValue;return lp(d,p)}else return u}),...(t.updated||[]).filter(({oldValue:u})=>!a.has(u.id))];return{created:l,deleted:h,updated:c}};let cp=()=>({emit(r,...t){for(let e=0,i=this.events[r]||[],s=i.length;e<s;e++)i[e](...t)},events:{},on(r,t){var e;return((e=this.events)[r]||(e[r]=[])).push(t),()=>{var i;this.events[r]=(i=this.events[r])==null?void 0:i.filter(s=>t!==s)}}});const up=250,dp=r=>{const t=cp(),e=[];let i=-1,s=!1,n=0;const o=f=>{if(!s){const{changes:p}=f,m=performance.now();if(m-n>up)e.splice(i+1),e.push(p),i=e.length-1;else{const _=e.length-1;e[_]=hp(e[_],p)}n=m}s=!1};r.observe(o,{origin:dr.LOCAL});const a=f=>f&&f.length>0&&r.bulkDeleteAnnotation(f),l=f=>f&&f.length>0&&r.bulkAddAnnotation(f,!1),h=f=>f&&f.length>0&&r.bulkUpdateAnnotation(f.map(({oldValue:p})=>p)),c=f=>f&&f.length>0&&r.bulkUpdateAnnotation(f.map(({newValue:p})=>p)),u=f=>f&&f.length>0&&r.bulkAddAnnotation(f,!1),d=f=>f&&f.length>0&&r.bulkDeleteAnnotation(f);return{canRedo:()=>e.length-1>i,canUndo:()=>i>-1,destroy:()=>r.unobserve(o),on:(f,p)=>t.on(f,p),redo:()=>{if(e.length-1>i){s=!0;const{created:f,updated:p,deleted:m}=e[i+1];l(f),c(p),d(m),t.emit("redo",e[i+1]),i+=1}},undo:()=>{if(i>-1){s=!0;const{created:f,updated:p,deleted:m}=e[i];a(f),h(p),u(m),t.emit("undo",e[i]),i-=1}}}},fp=(r,t,e,i)=>{const{hover:s,selection:n,store:o,viewport:a}=r,l=new Map;let h=[],c,u;const d=(y,x)=>{l.has(y)?l.get(y).push(x):l.set(y,[x])},f=(y,x)=>{const g=l.get(y);if(g){const v=g.indexOf(x);v!==-1&&g.splice(v,1)}},p=(y,x,g)=>{l.has(y)&&setTimeout(()=>{l.get(y).forEach(v=>{if(e){const w=Array.isArray(x)?x.map(A=>e.serialize(A)):e.serialize(x),I=g?g instanceof PointerEvent?g:e.serialize(g):void 0;v(w,I)}else v(x,g)})},1)},m=()=>{const{selected:y}=n,x=(y||[]).map(({id:g})=>o.getAnnotation(g));x.forEach(g=>{const v=h.find(w=>w.id===g.id);(!v||!Mr(v,g))&&p("updateAnnotation",g,v)}),h=h.map(g=>x.find(({id:w})=>w===g.id)||g)};n.subscribe(({selected:y})=>{if(!(h.length===0&&y.length===0)){if(h.length===0&&y.length>0)h=y.map(({id:x})=>o.getAnnotation(x));else if(h.length>0&&y.length===0)h.forEach(x=>{const g=o.getAnnotation(x.id);g&&!Mr(g,x)&&p("updateAnnotation",g,x)}),h=[];else{const x=new Set(h.map(v=>v.id)),g=new Set(y.map(({id:v})=>v));h.filter(v=>!g.has(v.id)).forEach(v=>{const w=o.getAnnotation(v.id);w&&!Mr(w,v)&&p("updateAnnotation",w,v)}),h=[...h.filter(v=>g.has(v.id)),...y.filter(({id:v})=>!x.has(v)).map(({id:v})=>o.getAnnotation(v))]}p("selectionChanged",h)}}),s.subscribe(y=>{!c&&y?p("mouseEnterAnnotation",o.getAnnotation(y)):c&&!y?p("mouseLeaveAnnotation",o.getAnnotation(c)):c&&y&&(p("mouseLeaveAnnotation",o.getAnnotation(c)),p("mouseEnterAnnotation",o.getAnnotation(y))),c=y}),a==null||a.subscribe(y=>p("viewportIntersect",y.map(x=>o.getAnnotation(x)))),o.observe(y=>{i&&(u&&clearTimeout(u),u=setTimeout(m,1e3));const{created:x,deleted:g}=y.changes;(x||[]).forEach(v=>p("createAnnotation",v)),(g||[]).forEach(v=>p("deleteAnnotation",v)),(y.changes.updated||[]).filter(v=>[...v.bodiesCreated||[],...v.bodiesDeleted||[],...v.bodiesUpdated||[]].length>0).forEach(({oldValue:v,newValue:w})=>{const I=h.find(A=>A.id===v.id)||v;h=h.map(A=>A.id===v.id?w:A),p("updateAnnotation",w,I)})},{origin:dr.LOCAL}),o.observe(y=>{if(h){const x=new Set(h.map(v=>v.id)),g=(y.changes.updated||[]).filter(({newValue:v})=>x.has(v.id)).map(({newValue:v})=>v);g.length>0&&(h=h.map(v=>g.find(I=>I.id===v.id)||v))}},{origin:dr.REMOTE});const _=y=>x=>{const{updated:g}=x;y?(g||[]).forEach(v=>p("updateAnnotation",v.oldValue,v.newValue)):(g||[]).forEach(v=>p("updateAnnotation",v.newValue,v.oldValue))};return t.on("undo",_(!0)),t.on("redo",_(!1)),{on:d,off:f,emit:p}},pp=r=>t=>t.reduce((e,i)=>{const{parsed:s,error:n}=r.parse(i);return n?{parsed:e.parsed,failed:[...e.failed,i]}:s?{parsed:[...e.parsed,s],failed:e.failed}:{...e}},{parsed:[],failed:[]}),mp=(r,t,e)=>{const{store:i,selection:s}=r,n=y=>{if(e){const{parsed:x,error:g}=e.parse(y);x?i.addAnnotation(x,dr.REMOTE):console.error(g)}else i.addAnnotation(ho(y),dr.REMOTE)},o=()=>s.clear(),a=()=>i.clear(),l=y=>{const x=i.getAnnotation(y);return e&&x?e.serialize(x):x},h=()=>e?i.all().map(e.serialize):i.all(),c=()=>{var y;const x=(((y=s.selected)==null?void 0:y.map(g=>g.id))||[]).map(g=>i.getAnnotation(g)).filter(Boolean);return e?x.map(e.serialize):x},u=(y,x=!0)=>fetch(y).then(g=>g.json()).then(g=>(f(g,x),g)),d=y=>{if(typeof y=="string"){const x=i.getAnnotation(y);if(i.deleteAnnotation(y),x)return e?e.serialize(x):x}else{const x=e?e.parse(y).parsed:y;if(x)return i.deleteAnnotation(x),y}},f=(y,x=!0)=>{if(e){const g=e.parseAll||pp(e),{parsed:v,failed:w}=g(y);w.length>0&&console.warn(`Discarded ${w.length} invalid annotations`,w),i.bulkAddAnnotation(v,x,dr.REMOTE)}else i.bulkAddAnnotation(y.map(ho),x,dr.REMOTE)},p=(y,x)=>{y?s.setSelected(y,x):s.clear()},m=y=>{s.clear(),s.setUserSelectAction(y)},_=y=>{if(e){const x=e.parse(y).parsed,g=e.serialize(i.getAnnotation(x.id));return i.updateAnnotation(x),g}else{const x=i.getAnnotation(y.id);return i.updateAnnotation(ho(y)),x}};return{addAnnotation:n,cancelSelected:o,canRedo:t.canRedo,canUndo:t.canUndo,clearAnnotations:a,getAnnotationById:l,getAnnotations:h,getSelected:c,loadAnnotations:u,redo:t.redo,removeAnnotation:d,setAnnotations:f,setSelected:p,setUserSelectAction:m,undo:t.undo,updateAnnotation:_}},gp="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let yp=r=>crypto.getRandomValues(new Uint8Array(r)),_p=(r,t,e)=>{let i=(2<<Math.log(r.length-1)/Math.LN2)-1,s=-~(1.6*i*t/r.length);return(n=t)=>{let o="";for(;;){let a=e(s),l=s;for(;l--;)if(o+=r[a[l]&i]||"",o.length===n)return o}}},vp=(r,t=21)=>_p(r,t,yp),xp=(r=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(r));for(;r--;)t+=gp[e[r]&63];return t};const bp=()=>({isGuest:!0,id:vp("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),wp=["#ff7c00","#1ac938","#e8000b","#8b2be2","#9f4800","#f14cc1","#ffc400","#00d7ff","#023eff"],Ep=()=>{const r=[...wp];return{assignRandomColor:()=>{const t=Math.floor(Math.random()*r.length),e=r[t];return r.splice(t,1),e},releaseColor:t=>r.push(t)}};xp();var Tp=Object.defineProperty,Ap=(r,t,e)=>t in r?Tp(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Vl=(r,t,e)=>Ap(r,typeof t!="symbol"?t+"":t,e);function At(){}function co(r,t){for(const e in t)r[e]=t[e];return r}function zl(r){return r()}function Wl(){return Object.create(null)}function Pe(r){r.forEach(zl)}function Ut(r){return typeof r=="function"}function qt(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}function Sp(r){return Object.keys(r).length===0}function jl(r,...t){if(r==null){for(const i of t)i(void 0);return At}const e=r.subscribe(...t);return e.unsubscribe?()=>e.unsubscribe():e}function uo(r,t,e){r.$$.on_destroy.push(jl(t,e))}function Ip(r,t,e,i){if(r){const s=Yl(r,t,e,i);return r[0](s)}}function Yl(r,t,e,i){return r[1]&&i?co(e.ctx.slice(),r[1](i(t))):e.ctx}function Cp(r,t,e,i){if(r[2]&&i){const s=r[2](i(e));if(t.dirty===void 0)return s;if(typeof s=="object"){const n=[],o=Math.max(t.dirty.length,s.length);for(let a=0;a<o;a+=1)n[a]=t.dirty[a]|s[a];return n}return t.dirty|s}return t.dirty}function Rp(r,t,e,i,s,n){if(s){const o=Yl(t,e,i,n);r.p(o,s)}}function Pp(r){if(r.ctx.length>32){const t=[],e=r.ctx.length/32;for(let i=0;i<e;i++)t[i]=-1;return t}return-1}function ql(r){const t={};for(const e in r)e[0]!=="$"&&(t[e]=r[e]);return t}function Rs(r){return r??""}function Me(r,t){r.appendChild(t)}function it(r,t,e){r.insertBefore(t,e||null)}function et(r){r.parentNode&&r.parentNode.removeChild(r)}function fo(r,t){for(let e=0;e<r.length;e+=1)r[e]&&r[e].d(t)}function yt(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function Kl(r){return document.createTextNode(r)}function ge(){return Kl(" ")}function ye(){return Kl("")}function Dt(r,t,e,i){return r.addEventListener(t,e,i),()=>r.removeEventListener(t,e,i)}function T(r,t,e){e==null?r.removeAttribute(t):r.getAttribute(t)!==e&&r.setAttribute(t,e)}function Mp(r){return Array.from(r.childNodes)}function fr(r,t,e){r.classList.toggle(t,!!e)}function Bp(r,t,{bubbles:e=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:t,bubbles:e,cancelable:i})}let Xi;function Vi(r){Xi=r}function Zl(){if(!Xi)throw new Error("Function called outside component initialization");return Xi}function zi(r){Zl().$$.on_mount.push(r)}function Qr(){const r=Zl();return(t,e,{cancelable:i=!1}={})=>{const s=r.$$.callbacks[t];if(s){const n=Bp(t,e,{cancelable:i});return s.slice().forEach(o=>{o.call(r,n)}),!n.defaultPrevented}return!0}}function Ze(r,t){const e=r.$$.callbacks[t.type];e&&e.slice().forEach(i=>i.call(this,t))}const ti=[],Ps=[];let ei=[];const Jl=[],Dp=Promise.resolve();let po=!1;function Op(){po||(po=!0,Dp.then(Ql))}function mo(r){ei.push(r)}const go=new Set;let ri=0;function Ql(){if(ri!==0)return;const r=Xi;do{try{for(;ri<ti.length;){const t=ti[ri];ri++,Vi(t),Fp(t.$$)}}catch(t){throw ti.length=0,ri=0,t}for(Vi(null),ti.length=0,ri=0;Ps.length;)Ps.pop()();for(let t=0;t<ei.length;t+=1){const e=ei[t];go.has(e)||(go.add(e),e())}ei.length=0}while(ti.length);for(;Jl.length;)Jl.pop()();po=!1,go.clear(),Vi(r)}function Fp(r){if(r.fragment!==null){r.update(),Pe(r.before_update);const t=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,t),r.after_update.forEach(mo)}}function Lp(r){const t=[],e=[];ei.forEach(i=>r.indexOf(i)===-1?t.push(i):e.push(i)),e.forEach(i=>i()),ei=t}const Ms=new Set;let Br;function _e(){Br={r:0,c:[],p:Br}}function ve(){Br.r||Pe(Br.c),Br=Br.p}function ot(r,t){r&&r.i&&(Ms.delete(r),r.i(t))}function mt(r,t,e,i){if(r&&r.o){if(Ms.has(r))return;Ms.add(r),Br.c.push(()=>{Ms.delete(r),i&&(e&&r.d(1),i())}),r.o(t)}else i&&i()}function ii(r){return(r==null?void 0:r.length)!==void 0?r:Array.from(r)}function ce(r){r&&r.c()}function se(r,t,e){const{fragment:i,after_update:s}=r.$$;i&&i.m(t,e),mo(()=>{const n=r.$$.on_mount.map(zl).filter(Ut);r.$$.on_destroy?r.$$.on_destroy.push(...n):Pe(n),r.$$.on_mount=[]}),s.forEach(mo)}function ne(r,t){const e=r.$$;e.fragment!==null&&(Lp(e.after_update),Pe(e.on_destroy),e.fragment&&e.fragment.d(t),e.on_destroy=e.fragment=null,e.ctx=[])}function Np(r,t){r.$$.dirty[0]===-1&&(ti.push(r),Op(),r.$$.dirty.fill(0)),r.$$.dirty[t/31|0]|=1<<t%31}function ue(r,t,e,i,s,n,o=null,a=[-1]){const l=Xi;Vi(r);const h=r.$$={fragment:null,ctx:[],props:n,update:At,not_equal:s,bound:Wl(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:Wl(),dirty:a,skip_bound:!1,root:t.target||l.$$.root};o&&o(h.root);let c=!1;if(h.ctx=e?e(r,t.props||{},(u,d,...f)=>{const p=f.length?f[0]:d;return h.ctx&&s(h.ctx[u],h.ctx[u]=p)&&(!h.skip_bound&&h.bound[u]&&h.bound[u](p),c&&Np(r,u)),d}):[],h.update(),c=!0,Pe(h.before_update),h.fragment=i?i(h.ctx):!1,t.target){if(t.hydrate){const u=Mp(t.target);h.fragment&&h.fragment.l(u),u.forEach(et)}else h.fragment&&h.fragment.c();t.intro&&ot(r.$$.fragment),se(r,t.target,t.anchor),Ql()}Vi(l)}class de{constructor(){Vl(this,"$$"),Vl(this,"$$set")}$destroy(){ne(this,1),this.$destroy=At}$on(t,e){if(!Ut(e))return At;const i=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return i.push(e),()=>{const s=i.indexOf(e);s!==-1&&i.splice(s,1)}}$set(t){this.$$set&&!Sp(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const Up="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Up);var wt=(r=>(r.ELLIPSE="ELLIPSE",r.POLYGON="POLYGON",r.RECTANGLE="RECTANGLE",r))(wt||{});const yo={},_o=(r,t)=>yo[r]=t,vo=r=>yo[r.type].area(r),kp=(r,t,e)=>yo[r.type].intersects(r,t,e),Bs=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}},Gp={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),c=t-i,u=e-s,d=l*c+h*u,f=h*c-l*u;return d*d/(n*n)+f*f/(o*o)<=1}};_o(wt.ELLIPSE,Gp);const $p={area:r=>{const{points:t}=r.geometry;let e=0,i=t.length-1;for(let s=0;s<t.length;s++)e+=(t[i][0]+t[s][0])*(t[i][1]-t[s][1]),i=s;return Math.abs(.5*e)},intersects:(r,t,e)=>{const{points:i}=r.geometry;let s=!1;for(let n=0,o=i.length-1;n<i.length;o=n++){const a=i[n][0],l=i[n][1],h=i[o][0],c=i[o][1];l>e!=c>e&&t<(h-a)*(e-l)/(c-l)+a&&(s=!s)}return s}};_o(wt.POLYGON,$p);const Hp={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};_o(wt.RECTANGLE,Hp);const Je=r=>Ds(r.target),Ds=r=>{var t,e;return(r==null?void 0:r.annotation)!==void 0&&((e=(t=r==null?void 0:r.selector)==null?void 0:t.geometry)==null?void 0:e.bounds)!==void 0},Xp=(r,t=!1)=>{const e=typeof r=="string"?r:r.value,i=/^(xywh)=(pixel|percent)?:?(.+?),(.+?),(.+?),(.+)*/g,s=[...e.matchAll(i)][0],[n,o,a,l,h,c,u]=s;if(o!=="xywh")throw new Error("Unsupported MediaFragment: "+e);if(a&&a!=="pixel")throw new Error(`Unsupported MediaFragment unit: ${a}`);const[d,f,p,m]=[l,h,c,u].map(parseFloat);return{type:wt.RECTANGLE,geometry:{x:d,y:f,w:p,h:m,bounds:{minX:d,minY:t?f-m:f,maxX:d+p,maxY:t?f:f+m}}}},Vp=r=>{const{x:t,y:e,w:i,h:s}=r;return{type:"FragmentSelector",conformsTo:"http://www.w3.org/TR/media-frags/",value:`xywh=pixel:${t},${e},${i},${s}`}},th="http://www.w3.org/2000/svg",eh=r=>{const t=i=>{Array.from(i.attributes).forEach(s=>{s.name.startsWith("on")&&i.removeAttribute(s.name)})},e=r.getElementsByTagName("script");return Array.from(e).reverse().forEach(i=>i.parentNode.removeChild(i)),Array.from(r.querySelectorAll("*")).forEach(t),r},zp=r=>{const t=new XMLSerializer().serializeToString(r.documentElement).replace("<svg>",`<svg xmlns="${th}">`);return new DOMParser().parseFromString(t,"image/svg+xml").documentElement},Wp=r=>{const t=new DOMParser().parseFromString(r,"image/svg+xml"),e=t.lookupPrefix(th),i=t.lookupNamespaceURI(null);return e||i?eh(t).firstChild:eh(zp(t)).firstChild},jp=r=>{const[t,e,i]=r.match(/(<polygon points=["|'])([^("|')]*)/)||[],s=i.split(" ").map(n=>n.split(",").map(parseFloat));return{type:wt.POLYGON,geometry:{points:s,bounds:Bs(s)}}},Yp=r=>{const t=Wp(r),e=parseFloat(t.getAttribute("cx")),i=parseFloat(t.getAttribute("cy")),s=parseFloat(t.getAttribute("rx")),n=parseFloat(t.getAttribute("ry")),o={minX:e-s,minY:i-n,maxX:e+s,maxY:i+n};return{type:wt.ELLIPSE,geometry:{cx:e,cy:i,rx:s,ry:n,bounds:o}}},qp=r=>{const t=typeof r=="string"?r:r.value;if(t.includes("<polygon points="))return jp(t);if(t.includes("<ellipse "))return Yp(t);throw"Unsupported SVG shape: "+t},Kp=r=>{let t;if(r.type===wt.POLYGON){const e=r.geometry,{points:i}=e;t=`<svg><polygon points="${i.map(s=>s.join(",")).join(" ")}" /></svg>`}else if(r.type===wt.ELLIPSE){const e=r.geometry;t=`<svg><ellipse cx="${e.cx}" cy="${e.cy}" rx="${e.rx}" ry="${e.ry}" /></svg>`}if(t)return{type:"SvgSelector",value:t};throw`Unsupported shape type: ${r.type}`};for(var Xt=[],xo=0;xo<256;++xo)Xt.push((xo+256).toString(16).slice(1));function Zp(r,t=0){return(Xt[r[t+0]]+Xt[r[t+1]]+Xt[r[t+2]]+Xt[r[t+3]]+"-"+Xt[r[t+4]]+Xt[r[t+5]]+"-"+Xt[r[t+6]]+Xt[r[t+7]]+"-"+Xt[r[t+8]]+Xt[r[t+9]]+"-"+Xt[r[t+10]]+Xt[r[t+11]]+Xt[r[t+12]]+Xt[r[t+13]]+Xt[r[t+14]]+Xt[r[t+15]]).toLowerCase()}var Os,Jp=new Uint8Array(16);function Qp(){if(!Os&&(Os=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Os))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Os(Jp)}var tm=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const rh={randomUUID:tm};function ih(r,t,e){if(rh.randomUUID&&!t&&!r)return rh.randomUUID();r=r||{};var i=r.random||(r.rng||Qp)();return i[6]=i[6]&15|64,i[8]=i[8]&63|128,Zp(i)}var sh=Object.prototype.hasOwnProperty;function pr(r,t){var e,i;if(r===t)return!0;if(r&&t&&(e=r.constructor)===t.constructor){if(e===Date)return r.getTime()===t.getTime();if(e===RegExp)return r.toString()===t.toString();if(e===Array){if((i=r.length)===t.length)for(;i--&&pr(r[i],t[i]););return i===-1}if(!e||typeof r=="object"){i=0;for(e in r)if(sh.call(r,e)&&++i&&!sh.call(t,e)||!(e in t)||!pr(r[e],t[e]))return!1;return Object.keys(t).length===i}}return r!==r&&t!==t}function bo(){}function em(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}const si=[];function wo(r,t=bo){let e;const i=new Set;function s(a){if(em(r,a)&&(r=a,e)){const l=!si.length;for(const h of i)h[1](),si.push(h,r);if(l){for(let h=0;h<si.length;h+=2)si[h][0](si[h+1]);si.length=0}}}function n(a){s(a(r))}function o(a,l=bo){const h=[a,l];return i.add(h),i.size===1&&(e=t(s,n)||bo),a(r),()=>{i.delete(h),i.size===0&&e&&(e(),e=null)}}return{set:s,update:n,subscribe:o}}const rm=r=>{const{subscribe:t,set:e}=wo();let i;return t(s=>i=s),r.observe(({changes:s})=>{if(i){(s.deleted||[]).some(o=>o.id===i)&&e(void 0);const n=(s.updated||[]).find(({oldValue:o})=>o.id===i);n&&e(n.newValue.id)}}),{get current(){return i},subscribe:t,set:e}};var nh=(r=>(r.EDIT="EDIT",r.SELECT="SELECT",r.NONE="NONE",r))(nh||{});const Fs={selected:[]},im=(r,t,e)=>{const{subscribe:i,set:s}=wo(Fs);let n=t,o=Fs;i(p=>o=p);const a=()=>{pr(o,Fs)||s(Fs)},l=()=>{var p;return((p=o.selected)==null?void 0:p.length)===0},h=p=>{if(l())return!1;const m=typeof p=="string"?p:p.id;return o.selected.some(_=>_.id===m)},c=(p,m)=>{const _=r.getAnnotation(p);if(!_){console.warn("Invalid selection: "+p);return}switch(oh(_,n,e)){case"EDIT":s({selected:[{id:p,editable:!0}],event:m});break;case"SELECT":s({selected:[{id:p}],event:m});break;default:s({selected:[],event:m})}},u=(p,m)=>{const _=Array.isArray(p)?p:[p],y=_.map(x=>r.getAnnotation(x)).filter(x=>!!x);s({selected:y.map(x=>{const g=m===void 0?oh(x,n,e)==="EDIT":m;return{id:x.id,editable:g}})}),y.length!==_.length&&console.warn("Invalid selection",p)},d=p=>{if(l())return!1;const{selected:m}=o;m.some(({id:_})=>p.includes(_))&&s({selected:m.filter(({id:_})=>!p.includes(_))})},f=p=>n=p;return r.observe(({changes:p})=>d((p.deleted||[]).map(m=>m.id))),{get event(){return o?o.event:null},get selected(){return o?[...o.selected]:null},get userSelectAction(){return n},clear:a,isEmpty:l,isSelected:h,setSelected:u,setUserSelectAction:f,subscribe:i,userSelect:c}},oh=(r,t,e)=>{const i=e?e.serialize(r):r;return typeof t=="function"?t(i):t||"EDIT"};for(var Vt=[],Eo=0;Eo<256;++Eo)Vt.push((Eo+256).toString(16).slice(1));function sm(r,t=0){return(Vt[r[t+0]]+Vt[r[t+1]]+Vt[r[t+2]]+Vt[r[t+3]]+"-"+Vt[r[t+4]]+Vt[r[t+5]]+"-"+Vt[r[t+6]]+Vt[r[t+7]]+"-"+Vt[r[t+8]]+Vt[r[t+9]]+"-"+Vt[r[t+10]]+Vt[r[t+11]]+Vt[r[t+12]]+Vt[r[t+13]]+Vt[r[t+14]]+Vt[r[t+15]]).toLowerCase()}var Ls,nm=new Uint8Array(16);function om(){if(!Ls&&(Ls=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Ls))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ls(nm)}var am=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const ah={randomUUID:am};function lm(r,t,e){if(ah.randomUUID&&!t&&!r)return ah.randomUUID();r=r||{};var i=r.random||(r.rng||om)();return i[6]=i[6]&15|64,i[8]=i[8]&63|128,sm(i)}const To=r=>{const t=e=>{const i={...e};return e.created&&typeof e.created=="string"&&(i.created=new Date(e.created)),e.updated&&typeof e.updated=="string"&&(i.updated=new Date(e.updated)),i};return{...r,bodies:(r.bodies||[]).map(t),target:t(r.target)}},hm=(r,t)=>{const e=new Set(r.bodies.map(i=>i.id));return t.bodies.filter(i=>!e.has(i.id))},cm=(r,t)=>{const e=new Set(t.bodies.map(i=>i.id));return r.bodies.filter(i=>!e.has(i.id))},um=(r,t)=>t.bodies.map(e=>{const i=r.bodies.find(s=>s.id===e.id);return{newBody:e,oldBody:i&&!pr(i,e)?i:void 0}}).filter(({oldBody:e})=>e).map(({oldBody:e,newBody:i})=>({oldBody:e,newBody:i})),dm=(r,t)=>!pr(r.target,t.target),lh=(r,t)=>{const e=hm(r,t),i=cm(r,t),s=um(r,t);return{oldValue:r,newValue:t,bodiesCreated:e.length>0?e:void 0,bodiesDeleted:i.length>0?i:void 0,bodiesUpdated:s.length>0?s:void 0,targetUpdated:dm(r,t)?{oldTarget:r.target,newTarget:t.target}:void 0}};var St=(r=>(r.LOCAL="LOCAL",r.REMOTE="REMOTE",r.SILENT="SILENT",r))(St||{});const fm=(r,t)=>{var e,i;const{changes:s,origin:n}=t;if(!(r.options.origin?r.options.origin===n:n!=="SILENT"))return!1;if(r.options.ignore){const{ignore:o}=r.options,a=l=>l&&l.length>0;if(!(a(s.created)||a(s.deleted))){const l=(e=s.updated)==null?void 0:e.some(c=>a(c.bodiesCreated)||a(c.bodiesDeleted)||a(c.bodiesUpdated)),h=(i=s.updated)==null?void 0:i.some(c=>c.targetUpdated);if(o==="BODY_ONLY"&&l&&!h||o==="TARGET_ONLY"&&h&&!l)return!1}}if(r.options.annotations){const o=new Set([...(s.created||[]).map(a=>a.id),...(s.deleted||[]).map(a=>a.id),...(s.updated||[]).map(({oldValue:a})=>a.id)]);return!!(Array.isArray(r.options.annotations)?r.options.annotations:[r.options.annotations]).find(a=>o.has(a))}else return!0},pm=(r,t)=>{const e=new Set((r.created||[]).map(u=>u.id)),i=new Set((r.updated||[]).map(({newValue:u})=>u.id)),s=new Set((t.created||[]).map(u=>u.id)),n=new Set((t.deleted||[]).map(u=>u.id)),o=new Set((t.updated||[]).map(({oldValue:u})=>u.id)),a=new Set((t.updated||[]).filter(({oldValue:u})=>e.has(u.id)||i.has(u.id)).map(({oldValue:u})=>u.id)),l=[...(r.created||[]).filter(u=>!n.has(u.id)).map(u=>o.has(u.id)?t.updated.find(({oldValue:d})=>d.id===u.id).newValue:u),...t.created||[]],h=[...(r.deleted||[]).filter(u=>!s.has(u.id)),...(t.deleted||[]).filter(u=>!e.has(u.id))],c=[...(r.updated||[]).filter(({newValue:u})=>!n.has(u.id)).map(u=>{const{oldValue:d,newValue:f}=u;if(o.has(f.id)){const p=t.updated.find(m=>m.oldValue.id===f.id).newValue;return lh(d,p)}else return u}),...(t.updated||[]).filter(({oldValue:u})=>!a.has(u.id))];return{created:l,deleted:h,updated:c}},Ao=r=>{const t=r.id===void 0?lm():r.id;return{...r,id:t,bodies:r.bodies===void 0?[]:r.bodies.map(e=>({...e,annotation:t})),target:{...r.target,annotation:t}}},mm=r=>r.id!==void 0,gm=()=>{const r=new Map,t=new Map,e=[],i=(S,R={})=>{e.push({onChange:S,options:R})},s=S=>{const R=e.findIndex(E=>E.onChange==S);R>-1&&e.splice(R,1)},n=(S,R)=>{const E={origin:S,changes:{created:R.created||[],updated:R.updated||[],deleted:R.deleted||[]},state:[...r.values()]};e.forEach(b=>{fm(b,E)&&b.onChange(E)})},o=(S,R=St.LOCAL)=>{if(S.id&&r.get(S.id))throw Error(`Cannot add annotation ${S.id} - exists already`);{const E=Ao(S);r.set(E.id,E),E.bodies.forEach(b=>t.set(b.id,E.id)),n(R,{created:[E]})}},a=(S,R)=>{const E=Ao(typeof S=="string"?R:S),b=typeof S=="string"?S:S.id,D=b&&r.get(b);if(D){const F=lh(D,E);return b===E.id?r.set(b,E):(r.delete(b),r.set(E.id,E)),D.bodies.forEach(G=>t.delete(G.id)),E.bodies.forEach(G=>t.set(G.id,E.id)),F}else console.warn(`Cannot update annotation ${b} - does not exist`)},l=(S,R=St.LOCAL,E=St.LOCAL)=>{const b=mm(R)?E:R,D=a(S,R);D&&n(b,{updated:[D]})},h=(S,R=St.LOCAL)=>{const E=S.reduce((b,D)=>{const F=a(D);return F?[...b,F]:b},[]);E.length>0&&n(R,{updated:E})},c=(S,R=St.LOCAL)=>{const E=r.get(S.annotation);if(E){const b={...E,bodies:[...E.bodies,S]};r.set(E.id,b),t.set(S.id,b.id),n(R,{updated:[{oldValue:E,newValue:b,bodiesCreated:[S]}]})}else console.warn(`Attempt to add body to missing annotation: ${S.annotation}`)},u=()=>[...r.values()],d=(S=St.LOCAL)=>{const R=[...r.values()];r.clear(),t.clear(),n(S,{deleted:R})},f=(S,R=!0,E=St.LOCAL)=>{const b=S.map(Ao);if(R){const D=[...r.values()];r.clear(),t.clear(),b.forEach(F=>{r.set(F.id,F),F.bodies.forEach(G=>t.set(G.id,F.id))}),n(E,{created:b,deleted:D})}else{const D=S.reduce((F,G)=>{const $=G.id&&r.get(G.id);return $?[...F,$]:F},[]);if(D.length>0)throw Error(`Bulk insert would overwrite the following annotations: ${D.map(F=>F.id).join(", ")}`);b.forEach(F=>{r.set(F.id,F),F.bodies.forEach(G=>t.set(G.id,F.id))}),n(E,{created:b})}},p=S=>{const R=typeof S=="string"?S:S.id,E=r.get(R);if(E)return r.delete(R),E.bodies.forEach(b=>t.delete(b.id)),E;console.warn(`Attempt to delete missing annotation: ${R}`)},m=(S,R=St.LOCAL)=>{const E=p(S);E&&n(R,{deleted:[E]})},_=(S,R=St.LOCAL)=>{const E=S.reduce((b,D)=>{const F=p(D);return F?[...b,F]:b},[]);E.length>0&&n(R,{deleted:E})},y=S=>{const R=r.get(S.annotation);if(R){const E=R.bodies.find(b=>b.id===S.id);if(E){t.delete(E.id);const b={...R,bodies:R.bodies.filter(D=>D.id!==S.id)};return r.set(R.id,b),{oldValue:R,newValue:b,bodiesDeleted:[E]}}else console.warn(`Attempt to delete missing body ${S.id} from annotation ${S.annotation}`)}else console.warn(`Attempt to delete body from missing annotation ${S.annotation}`)},x=(S,R=St.LOCAL)=>{const E=y(S);E&&n(R,{updated:[E]})},g=(S,R=St.LOCAL)=>{const E=S.map(b=>y(b)).filter(Boolean);E.length>0&&n(R,{updated:E})},v=S=>{const R=r.get(S);return R?{...R}:void 0},w=S=>{const R=t.get(S);if(R){const E=v(R).bodies.find(b=>b.id===S);if(E)return E;console.error(`Store integrity error: body ${S} in index, but not in annotation`)}else console.warn(`Attempt to retrieve missing body: ${S}`)},I=(S,R)=>{if(S.annotation!==R.annotation)throw"Annotation integrity violation: annotation ID must be the same when updating bodies";const E=r.get(S.annotation);if(E){const b=E.bodies.find(F=>F.id===S.id),D={...E,bodies:E.bodies.map(F=>F.id===b.id?R:F)};return r.set(E.id,D),b.id!==R.id&&(t.delete(b.id),t.set(R.id,D.id)),{oldValue:E,newValue:D,bodiesUpdated:[{oldBody:b,newBody:R}]}}else console.warn(`Attempt to add body to missing annotation ${S.annotation}`)},A=(S,R,E=St.LOCAL)=>{const b=I(S,R);b&&n(E,{updated:[b]})},C=(S,R=St.LOCAL)=>{const E=S.map(b=>I({id:b.id,annotation:b.annotation},b)).filter(Boolean);n(R,{updated:E})},N=S=>{const R=r.get(S.annotation);if(R){const E={...R,target:{...R.target,...S}};return r.set(R.id,E),{oldValue:R,newValue:E,targetUpdated:{oldTarget:R.target,newTarget:S}}}else console.warn(`Attempt to update target on missing annotation: ${S.annotation}`)};return{addAnnotation:o,addBody:c,all:u,bulkAddAnnotation:f,bulkDeleteAnnotation:_,bulkDeleteBodies:g,bulkUpdateAnnotation:h,bulkUpdateBodies:C,bulkUpdateTargets:(S,R=St.LOCAL)=>{const E=S.map(b=>N(b)).filter(Boolean);E.length>0&&n(R,{updated:E})},clear:d,deleteAnnotation:m,deleteBody:x,getAnnotation:v,getBody:w,observe:i,unobserve:s,updateAnnotation:l,updateBody:A,updateTarget:(S,R=St.LOCAL)=>{const E=N(S);E&&n(R,{updated:[E]})}}},ym=r=>({...r,subscribe:t=>{const e=i=>t(i.state);return r.observe(e),t(r.all()),()=>r.unobserve(e)}});let _m=()=>({emit(r,...t){for(let e=0,i=this.events[r]||[],s=i.length;e<s;e++)i[e](...t)},events:{},on(r,t){var e;return((e=this.events)[r]||(e[r]=[])).push(t),()=>{var i;this.events[r]=(i=this.events[r])==null?void 0:i.filter(s=>t!==s)}}});const vm=250,xm=r=>{const t=_m(),e=[];let i=-1,s=!1,n=0;const o=f=>{if(!s){const{changes:p}=f,m=performance.now();if(m-n>vm)e.splice(i+1),e.push(p),i=e.length-1;else{const _=e.length-1;e[_]=pm(e[_],p)}n=m}s=!1};r.observe(o,{origin:St.LOCAL});const a=f=>f&&f.length>0&&r.bulkDeleteAnnotation(f),l=f=>f&&f.length>0&&r.bulkAddAnnotation(f,!1),h=f=>f&&f.length>0&&r.bulkUpdateAnnotation(f.map(({oldValue:p})=>p)),c=f=>f&&f.length>0&&r.bulkUpdateAnnotation(f.map(({newValue:p})=>p)),u=f=>f&&f.length>0&&r.bulkAddAnnotation(f,!1),d=f=>f&&f.length>0&&r.bulkDeleteAnnotation(f);return{canRedo:()=>e.length-1>i,canUndo:()=>i>-1,destroy:()=>r.unobserve(o),on:(f,p)=>t.on(f,p),redo:()=>{if(e.length-1>i){s=!0;const{created:f,updated:p,deleted:m}=e[i+1];l(f),c(p),d(m),t.emit("redo",e[i+1]),i+=1}},undo:()=>{if(i>-1){s=!0;const{created:f,updated:p,deleted:m}=e[i];a(f),h(p),u(m),t.emit("undo",e[i]),i-=1}}}},bm=()=>{const{subscribe:r,set:t}=wo([]);return{subscribe:r,set:t}},wm=(r,t,e,i)=>{const{hover:s,selection:n,store:o,viewport:a}=r,l=new Map;let h=[],c,u;const d=(y,x)=>{l.has(y)?l.get(y).push(x):l.set(y,[x])},f=(y,x)=>{const g=l.get(y);if(g){const v=g.indexOf(x);v!==-1&&g.splice(v,1)}},p=(y,x,g)=>{l.has(y)&&setTimeout(()=>{l.get(y).forEach(v=>{if(e){const w=Array.isArray(x)?x.map(A=>e.serialize(A)):e.serialize(x),I=g?g instanceof PointerEvent?g:e.serialize(g):void 0;v(w,I)}else v(x,g)})},1)},m=()=>{const{selected:y}=n,x=(y||[]).map(({id:g})=>o.getAnnotation(g));x.forEach(g=>{const v=h.find(w=>w.id===g.id);(!v||!pr(v,g))&&p("updateAnnotation",g,v)}),h=h.map(g=>x.find(({id:v})=>v===g.id)||g)};n.subscribe(({selected:y})=>{if(!(h.length===0&&y.length===0)){if(h.length===0&&y.length>0)h=y.map(({id:x})=>o.getAnnotation(x));else if(h.length>0&&y.length===0)h.forEach(x=>{const g=o.getAnnotation(x.id);g&&!pr(g,x)&&p("updateAnnotation",g,x)}),h=[];else{const x=new Set(h.map(v=>v.id)),g=new Set(y.map(({id:v})=>v));h.filter(v=>!g.has(v.id)).forEach(v=>{const w=o.getAnnotation(v.id);w&&!pr(w,v)&&p("updateAnnotation",w,v)}),h=[...h.filter(v=>g.has(v.id)),...y.filter(({id:v})=>!x.has(v)).map(({id:v})=>o.getAnnotation(v))]}p("selectionChanged",h)}}),s.subscribe(y=>{!c&&y?p("mouseEnterAnnotation",o.getAnnotation(y)):c&&!y?p("mouseLeaveAnnotation",o.getAnnotation(c)):c&&y&&(p("mouseLeaveAnnotation",o.getAnnotation(c)),p("mouseEnterAnnotation",o.getAnnotation(y))),c=y}),a==null||a.subscribe(y=>p("viewportIntersect",y.map(x=>o.getAnnotation(x)))),o.observe(y=>{i&&(u&&clearTimeout(u),u=setTimeout(m,1e3));const{created:x,deleted:g}=y.changes;(x||[]).forEach(v=>p("createAnnotation",v)),(g||[]).forEach(v=>p("deleteAnnotation",v)),(y.changes.updated||[]).filter(v=>[...v.bodiesCreated||[],...v.bodiesDeleted||[],...v.bodiesUpdated||[]].length>0).forEach(({oldValue:v,newValue:w})=>{const I=h.find(A=>A.id===v.id)||v;h=h.map(A=>A.id===v.id?w:A),p("updateAnnotation",w,I)})},{origin:St.LOCAL}),o.observe(y=>{if(h){const x=new Set(h.map(v=>v.id)),g=(y.changes.updated||[]).filter(({newValue:v})=>x.has(v.id)).map(({newValue:v})=>v);g.length>0&&(h=h.map(v=>g.find(w=>w.id===v.id)||v))}},{origin:St.REMOTE});const _=y=>x=>{const{updated:g}=x;y?(g||[]).forEach(v=>p("updateAnnotation",v.oldValue,v.newValue)):(g||[]).forEach(v=>p("updateAnnotation",v.newValue,v.oldValue))};return t.on("undo",_(!0)),t.on("redo",_(!1)),{on:d,off:f,emit:p}},Em=r=>t=>t.reduce((e,i)=>{const{parsed:s,error:n}=r.parse(i);return n?{parsed:e.parsed,failed:[...e.failed,i]}:s?{parsed:[...e.parsed,s],failed:e.failed}:{...e}},{parsed:[],failed:[]}),Tm=(r,t,e)=>{const{store:i,selection:s}=r,n=y=>{if(e){const{parsed:x,error:g}=e.parse(y);x?i.addAnnotation(x,St.REMOTE):console.error(g)}else i.addAnnotation(To(y),St.REMOTE)},o=()=>s.clear(),a=()=>i.clear(),l=y=>{const x=i.getAnnotation(y);return e&&x?e.serialize(x):x},h=()=>e?i.all().map(e.serialize):i.all(),c=()=>{var y;const x=(((y=s.selected)==null?void 0:y.map(g=>g.id))||[]).map(g=>i.getAnnotation(g)).filter(Boolean);return e?x.map(e.serialize):x},u=(y,x=!0)=>fetch(y).then(g=>g.json()).then(g=>(f(g,x),g)),d=y=>{if(typeof y=="string"){const x=i.getAnnotation(y);if(i.deleteAnnotation(y),x)return e?e.serialize(x):x}else{const x=e?e.parse(y).parsed:y;if(x)return i.deleteAnnotation(x),y}},f=(y,x=!0)=>{if(e){const g=e.parseAll||Em(e),{parsed:v,failed:w}=g(y);w.length>0&&console.warn(`Discarded ${w.length} invalid annotations`,w),i.bulkAddAnnotation(v,x,St.REMOTE)}else i.bulkAddAnnotation(y.map(To),x,St.REMOTE)},p=(y,x)=>{y?s.setSelected(y,x):s.clear()},m=y=>{s.clear(),s.setUserSelectAction(y)},_=y=>{if(e){const x=e.parse(y).parsed,g=e.serialize(i.getAnnotation(x.id));return i.updateAnnotation(x),g}else{const x=i.getAnnotation(y.id);return i.updateAnnotation(To(y)),x}};return{addAnnotation:n,cancelSelected:o,canRedo:t.canRedo,canUndo:t.canUndo,clearAnnotations:a,getAnnotationById:l,getAnnotations:h,getSelected:c,loadAnnotations:u,redo:t.redo,removeAnnotation:d,setAnnotations:f,setSelected:p,setUserSelectAction:m,undo:t.undo,updateAnnotation:_}},Am=(r,t,e)=>typeof t=="function"?t(r,e):t,Sm=(r,t)=>typeof r!="function"&&typeof t!="function"?{...r||{},...t||{}}:(e,i)=>{const s=typeof r=="function"?r(e,i):r,n=typeof t=="function"?t(e,i):t;return{...s||{},...n||{}}},Im="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Cm=r=>crypto.getRandomValues(new Uint8Array(r)),Rm=(r,t,e)=>{let i=(2<<Math.log(r.length-1)/Math.LN2)-1,s=-~(1.6*i*t/r.length);return(n=t)=>{let o="";for(;;){let a=e(s),l=s;for(;l--;)if(o+=r[a[l]&i]||"",o.length===n)return o}}},Pm=(r,t=21)=>Rm(r,t,Cm),Mm=(r=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(r));for(;r--;)t+=Im[e[r]&63];return t};const Bm=()=>({isGuest:!0,id:Pm("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),Dm=r=>{const t=JSON.stringify(r);let e=0;for(let i=0,s=t.length;i<s;i++){let n=t.charCodeAt(i);e=(e<<5)-e+n,e|=0}return`${e}`},hh=r=>r?typeof r=="object"?{...r}:r:void 0,Om=(r,t)=>(Array.isArray(r)?r:[r]).map(e=>{const{id:i,type:s,purpose:n,value:o,created:a,modified:l,creator:h,...c}=e;return{id:i||`temp-${Dm(e)}`,annotation:t,type:s,purpose:n,value:o,creator:hh(h),created:a?new Date(a):void 0,updated:l?new Date(l):void 0,...c}}),Fm=r=>r.map(t=>{var e;const{annotation:i,created:s,updated:n,...o}=t,a={...o,created:s==null?void 0:s.toISOString(),modified:n==null?void 0:n.toISOString()};return(e=a.id)!=null&&e.startsWith("temp-")&&delete a.id,a});Mm();const Lm=(r,t={strict:!0,invertY:!1})=>({parse:e=>Nm(e,t),serialize:e=>Um(e,r,t)}),Nm=(r,t={strict:!0,invertY:!1})=>{const e=r.id||ih(),{creator:i,created:s,modified:n,body:o,...a}=r,l=Om(o||[],e),h=Array.isArray(r.target)?r.target[0]:r.target,c=Array.isArray(h.selector)?h.selector[0]:h.selector,u=(c==null?void 0:c.type)==="FragmentSelector"?Xp(c,t.invertY):(c==null?void 0:c.type)==="SvgSelector"?qp(c):void 0;return u||!t.strict?{parsed:{...a,id:e,bodies:l,target:{created:s?new Date(s):void 0,creator:hh(i),updated:n?new Date(n):void 0,...Array.isArray(a.target)?a.target[0]:a.target,annotation:e,selector:u||c}}}:{error:Error(`Invalid selector: ${JSON.stringify(c)}`)}},Um=(r,t,e={strict:!0,invertY:!1})=>{const{selector:i,creator:s,created:n,updated:o,updatedBy:a,...l}=r.target;let h;try{h=i.type==wt.RECTANGLE?Vp(i.geometry):Kp(i)}catch(u){if(e.strict)throw u;h=i}const c={...r,"@context":"http://www.w3.org/ns/anno.jsonld",id:r.id,type:"Annotation",body:Fm(r.bodies),created:n==null?void 0:n.toISOString(),creator:s,modified:o==null?void 0:o.toISOString(),target:{...l,source:t,selector:h}};return delete c.bodies,"annotation"in c.target&&delete c.target.annotation,c};function ch(r,t,e){const i=r.slice();return i[10]=t[e],i[12]=e,i}function uh(r){let t,e;return t=new Wi({props:{x:r[10][0],y:r[10][1],scale:r[3]}}),t.$on("pointerdown",function(){Ut(r[9](`HANDLE-${r[12]}`))&&r[9](`HANDLE-${r[12]}`).apply(this,arguments)}),{c(){ce(t.$$.fragment)},m(i,s){se(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||(ot(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){ne(t,i)}}}function km(r){let t,e,i,s,n,o,a,l,h,c,u,d=ii(r[4].points),f=[];for(let m=0;m<d.length;m+=1)f[m]=uh(ch(r,d,m));const p=m=>mt(f[m],1,1,()=>{f[m]=null});return{c(){t=yt("polygon"),s=ge(),n=yt("polygon"),a=ge();for(let m=0;m<f.length;m+=1)f[m].c();l=ye(),T(t,"class","a9s-outer"),T(t,"style",e=r[1]?"display:none;":void 0),T(t,"points",i=r[4].points.map(dh).join(" ")),T(n,"class","a9s-inner a9s-shape-handle"),T(n,"style",r[1]),T(n,"points",o=r[4].points.map(fh).join(" "))},m(m,_){it(m,t,_),it(m,s,_),it(m,n,_),it(m,a,_);for(let y=0;y<f.length;y+=1)f[y]&&f[y].m(m,_);it(m,l,_),h=!0,c||(u=[Dt(t,"pointerdown",function(){Ut(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Dt(n,"pointerdown",function(){Ut(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)})],c=!0)},p(m,_){if(r=m,(!h||_&2&&e!==(e=r[1]?"display:none;":void 0))&&T(t,"style",e),(!h||_&16&&i!==(i=r[4].points.map(dh).join(" ")))&&T(t,"points",i),(!h||_&2)&&T(n,"style",r[1]),(!h||_&16&&o!==(o=r[4].points.map(fh).join(" ")))&&T(n,"points",o),_&536){d=ii(r[4].points);let y;for(y=0;y<d.length;y+=1){const x=ch(r,d,y);f[y]?(f[y].p(x,_),ot(f[y],1)):(f[y]=uh(x),f[y].c(),ot(f[y],1),f[y].m(l.parentNode,l))}for(_e(),y=d.length;y<f.length;y+=1)p(y);ve()}},i(m){if(!h){for(let _=0;_<d.length;_+=1)ot(f[_]);h=!0}},o(m){f=f.filter(Boolean);for(let _=0;_<f.length;_+=1)mt(f[_]);h=!1},d(m){m&&(et(t),et(s),et(n),et(a),et(l)),fo(f,m),c=!1,Pe(u)}}}function Gm(r){let t,e;return t=new vh({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[km,({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(){ce(t.$$.fragment)},m(i,s){se(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||(ot(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){ne(t,i)}}}const dh=r=>r.join(","),fh=r=>r.join(",");function $m(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 _=d.geometry;f==="SHAPE"?m=_.points.map(([x,g])=>[x+p[0],g+p[1]]):m=_.points.map(([x,g],v)=>f===`HANDLE-${v}`?[x+p[0],g+p[1]]:[x,g]);const y=Bs(m);return{...d,geometry:{points:m,bounds:y}}};function h(d){Ze.call(this,r,d)}function c(d){Ze.call(this,r,d)}function u(d){Ze.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,c,u]}class Hm extends de{constructor(t){super(),ue(this,t,$m,Gm,qt,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}const So=(r,t)=>{const e=Math.abs(t[0]-r[0]),i=Math.abs(t[1]-r[1]);return Math.sqrt(Math.pow(e,2)+Math.pow(i,2))},ni=[];function Xm(r,t=At){let e;const i=new Set;function s(a){if(qt(r,a)&&(r=a,e)){const l=!ni.length;for(const h of i)h[1](),ni.push(h,r);if(l){for(let h=0;h<ni.length;h+=2)ni[h][0](ni[h+1]);ni.length=0}}}function n(a){s(a(r))}function o(a,l=At){const h=[a,l];return i.add(h),i.size===1&&(e=t(s,n)||At),a(r),()=>{i.delete(h),i.size===0&&e&&(e(),e=null)}}return{set:s,update:n,subscribe:o}}const Vm=(r,t)=>{const{naturalWidth:e,naturalHeight:i}=r;if(!e&&!i){const{width:s,height:n}=r;t.setAttribute("viewBox",`0 0 ${s} ${n}`),r.addEventListener("load",o=>{const a=o.target;t.setAttribute("viewBox",`0 0 ${a.naturalWidth} ${a.naturalHeight}`)})}else t.setAttribute("viewBox",`0 0 ${e} ${i}`)},zm=(r,t)=>{Vm(r,t);const{subscribe:e,set:i}=Xm(1);let s;return window.ResizeObserver&&(s=new ResizeObserver(()=>{const n=t.getBoundingClientRect(),{width:o,height:a}=t.viewBox.baseVal,l=Math.max(n.width/o,n.height/a);i(l)}),s.observe(t.parentElement)),{destroy:()=>{s&&s.disconnect()},subscribe:e}},ph=typeof window>"u"||typeof navigator>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0;function Wm(r){let t,e,i,s,n,o;return{c(){t=yt("rect"),T(t,"class",e=Rs(`a9s-handle ${r[8].class||""}`.trim())+" svelte-1sgkh33"),T(t,"x",i=r[0]-r[5]/2),T(t,"y",s=r[1]-r[5]/2),T(t,"width",r[5]),T(t,"height",r[5])},m(a,l){it(a,t,l),n||(o=Dt(t,"pointerdown",r[11]),n=!0)},p(a,l){l&256&&e!==(e=Rs(`a9s-handle ${a[8].class||""}`.trim())+" svelte-1sgkh33")&&T(t,"class",e),l&33&&i!==(i=a[0]-a[5]/2)&&T(t,"x",i),l&34&&s!==(s=a[1]-a[5]/2)&&T(t,"y",s),l&32&&T(t,"width",a[5]),l&32&&T(t,"height",a[5])},d(a){a&&et(t),n=!1,o()}}}function jm(r){let t,e,i,s,n,o,a,l,h;return{c(){t=yt("g"),e=yt("circle"),s=yt("rect"),T(e,"cx",r[0]),T(e,"cy",r[1]),T(e,"r",i=r[3]/r[2]),T(e,"class","a9s-touch-halo svelte-1sgkh33"),fr(e,"touched",r[4]),T(s,"class",n=Rs(`a9s-handle ${r[8].class||""}`.trim())+" svelte-1sgkh33"),T(s,"x",o=r[0]-r[5]/2),T(s,"y",a=r[1]-r[5]/2),T(s,"width",r[5]),T(s,"height",r[5]),T(t,"class","a9s-touch-handle")},m(c,u){it(c,t,u),Me(t,e),Me(t,s),l||(h=[Dt(e,"pointerdown",r[10]),Dt(e,"pointerdown",r[6]),Dt(e,"pointerup",r[7]),Dt(s,"pointerdown",r[9]),Dt(s,"pointerdown",r[6]),Dt(s,"pointerup",r[7])],l=!0)},p(c,u){u&1&&T(e,"cx",c[0]),u&2&&T(e,"cy",c[1]),u&12&&i!==(i=c[3]/c[2])&&T(e,"r",i),u&16&&fr(e,"touched",c[4]),u&256&&n!==(n=Rs(`a9s-handle ${c[8].class||""}`.trim())+" svelte-1sgkh33")&&T(s,"class",n),u&33&&o!==(o=c[0]-c[5]/2)&&T(s,"x",o),u&34&&a!==(a=c[1]-c[5]/2)&&T(s,"y",a),u&32&&T(s,"width",c[5]),u&32&&T(s,"height",c[5])},d(c){c&&et(t),l=!1,Pe(h)}}}function Ym(r){let t;function e(s,n){return ph?jm:Wm}let i=e()(r);return{c(){i.c(),t=ye()},m(s,n){i.m(s,n),it(s,t,n)},p(s,[n]){i.p(s,n)},i:At,o:At,d(s){s&&et(t),i.d(s)}}}function qm(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)},c=()=>e(4,l=!1);function u(p){Ze.call(this,r,p)}function d(p){Ze.call(this,r,p)}function f(p){Ze.call(this,r,p)}return r.$$set=p=>{e(8,t=co(co({},t),ql(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=ql(t),[s,n,o,a,l,i,h,c,t,u,d,f]}class Wi extends de{constructor(t){super(),ue(this,t,qm,Ym,qt,{x:0,y:1,scale:2,radius:3})}}function Km(r){let t,e,i,s,n,o,a,l,h,c,u,d,f,p,m,_,y,x,g,v,w,I,A,C,N,S,R,E,b,D,F,G,$,B,Z,P,U,j,rt,Q,H,V,lt;return B=new Wi({props:{class:"a9s-corner-handle-topleft",x:r[4].x,y:r[4].y,scale:r[3]}}),B.$on("pointerdown",function(){Ut(r[9]("TOP_LEFT"))&&r[9]("TOP_LEFT").apply(this,arguments)}),P=new Wi({props:{class:"a9s-corner-handle-topright",x:r[4].x+r[4].w,y:r[4].y,scale:r[3]}}),P.$on("pointerdown",function(){Ut(r[9]("TOP_RIGHT"))&&r[9]("TOP_RIGHT").apply(this,arguments)}),j=new Wi({props:{class:"a9s-corner-handle-bottomright",x:r[4].x+r[4].w,y:r[4].y+r[4].h,scale:r[3]}}),j.$on("pointerdown",function(){Ut(r[9]("BOTTOM_RIGHT"))&&r[9]("BOTTOM_RIGHT").apply(this,arguments)}),Q=new Wi({props:{class:"a9s-corner-handle-bottomleft",x:r[4].x,y:r[4].y+r[4].h,scale:r[3]}}),Q.$on("pointerdown",function(){Ut(r[9]("BOTTOM_LEFT"))&&r[9]("BOTTOM_LEFT").apply(this,arguments)}),{c(){t=yt("rect"),a=ge(),l=yt("rect"),f=ge(),p=yt("rect"),x=ge(),g=yt("rect"),A=ge(),C=yt("rect"),E=ge(),b=yt("rect"),$=ge(),ce(B.$$.fragment),Z=ge(),ce(P.$$.fragment),U=ge(),ce(j.$$.fragment),rt=ge(),ce(Q.$$.fragment),T(t,"class","a9s-outer"),T(t,"style",e=r[1]?"display:none;":void 0),T(t,"x",i=r[4].x),T(t,"y",s=r[4].y),T(t,"width",n=r[4].w),T(t,"height",o=r[4].h),T(l,"class","a9s-inner a9s-shape-handle"),T(l,"style",r[1]),T(l,"x",h=r[4].x),T(l,"y",c=r[4].y),T(l,"width",u=r[4].w),T(l,"height",d=r[4].h),T(p,"class","a9s-edge-handle a9s-edge-handle-top"),T(p,"x",m=r[4].x),T(p,"y",_=r[4].y),T(p,"height",1),T(p,"width",y=r[4].w),T(g,"class","a9s-edge-handle a9s-edge-handle-right"),T(g,"x",v=r[4].x+r[4].w),T(g,"y",w=r[4].y),T(g,"height",I=r[4].h),T(g,"width",1),T(C,"class","a9s-edge-handle a9s-edge-handle-bottom"),T(C,"x",N=r[4].x),T(C,"y",S=r[4].y+r[4].h),T(C,"height",1),T(C,"width",R=r[4].w),T(b,"class","a9s-edge-handle a9s-edge-handle-left"),T(b,"x",D=r[4].x),T(b,"y",F=r[4].y),T(b,"height",G=r[4].h),T(b,"width",1)},m(L,O){it(L,t,O),it(L,a,O),it(L,l,O),it(L,f,O),it(L,p,O),it(L,x,O),it(L,g,O),it(L,A,O),it(L,C,O),it(L,E,O),it(L,b,O),it(L,$,O),se(B,L,O),it(L,Z,O),se(P,L,O),it(L,U,O),se(j,L,O),it(L,rt,O),se(Q,L,O),H=!0,V||(lt=[Dt(t,"pointerdown",function(){Ut(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Dt(l,"pointerdown",function(){Ut(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Dt(p,"pointerdown",function(){Ut(r[9]("TOP"))&&r[9]("TOP").apply(this,arguments)}),Dt(g,"pointerdown",function(){Ut(r[9]("RIGHT"))&&r[9]("RIGHT").apply(this,arguments)}),Dt(C,"pointerdown",function(){Ut(r[9]("BOTTOM"))&&r[9]("BOTTOM").apply(this,arguments)}),Dt(b,"pointerdown",function(){Ut(r[9]("LEFT"))&&r[9]("LEFT").apply(this,arguments)})],V=!0)},p(L,O){r=L,(!H||O&2&&e!==(e=r[1]?"display:none;":void 0))&&T(t,"style",e),(!H||O&16&&i!==(i=r[4].x))&&T(t,"x",i),(!H||O&16&&s!==(s=r[4].y))&&T(t,"y",s),(!H||O&16&&n!==(n=r[4].w))&&T(t,"width",n),(!H||O&16&&o!==(o=r[4].h))&&T(t,"height",o),(!H||O&2)&&T(l,"style",r[1]),(!H||O&16&&h!==(h=r[4].x))&&T(l,"x",h),(!H||O&16&&c!==(c=r[4].y))&&T(l,"y",c),(!H||O&16&&u!==(u=r[4].w))&&T(l,"width",u),(!H||O&16&&d!==(d=r[4].h))&&T(l,"height",d),(!H||O&16&&m!==(m=r[4].x))&&T(p,"x",m),(!H||O&16&&_!==(_=r[4].y))&&T(p,"y",_),(!H||O&16&&y!==(y=r[4].w))&&T(p,"width",y),(!H||O&16&&v!==(v=r[4].x+r[4].w))&&T(g,"x",v),(!H||O&16&&w!==(w=r[4].y))&&T(g,"y",w),(!H||O&16&&I!==(I=r[4].h))&&T(g,"height",I),(!H||O&16&&N!==(N=r[4].x))&&T(C,"x",N),(!H||O&16&&S!==(S=r[4].y+r[4].h))&&T(C,"y",S),(!H||O&16&&R!==(R=r[4].w))&&T(C,"width",R),(!H||O&16&&D!==(D=r[4].x))&&T(b,"x",D),(!H||O&16&&F!==(F=r[4].y))&&T(b,"y",F),(!H||O&16&&G!==(G=r[4].h))&&T(b,"height",G);const _t={};O&16&&(_t.x=r[4].x),O&16&&(_t.y=r[4].y),O&8&&(_t.scale=r[3]),B.$set(_t);const ht={};O&16&&(ht.x=r[4].x+r[4].w),O&16&&(ht.y=r[4].y),O&8&&(ht.scale=r[3]),P.$set(ht);const vt={};O&16&&(vt.x=r[4].x+r[4].w),O&16&&(vt.y=r[4].y+r[4].h),O&8&&(vt.scale=r[3]),j.$set(vt);const xt={};O&16&&(xt.x=r[4].x),O&16&&(xt.y=r[4].y+r[4].h),O&8&&(xt.scale=r[3]),Q.$set(xt)},i(L){H||(ot(B.$$.fragment,L),ot(P.$$.fragment,L),ot(j.$$.fragment,L),ot(Q.$$.fragment,L),H=!0)},o(L){mt(B.$$.fragment,L),mt(P.$$.fragment,L),mt(j.$$.fragment,L),mt(Q.$$.fragment,L),H=!1},d(L){L&&(et(t),et(a),et(l),et(f),et(p),et(x),et(g),et(A),et(C),et(E),et(b),et($),et(Z),et(U),et(rt)),ne(B,L),ne(P,L),ne(j,L),ne(Q,L),V=!1,Pe(lt)}}}function Zm(r){let t,e;return t=new vh({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[Km,({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(){ce(t.$$.fragment)},m(i,s){se(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||(ot(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){ne(t,i)}}}function Jm(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],[x,g]=[m.maxX,m.maxY];const[v,w]=p;if(f==="SHAPE")_+=v,x+=v,y+=w,g+=w;else{switch(f){case"TOP":case"TOP_LEFT":case"TOP_RIGHT":{y+=w;break}case"BOTTOM":case"BOTTOM_LEFT":case"BOTTOM_RIGHT":{g+=w;break}}switch(f){case"LEFT":case"TOP_LEFT":case"BOTTOM_LEFT":{_+=v;break}case"RIGHT":case"TOP_RIGHT":case"BOTTOM_RIGHT":{x+=v;break}}}const I=Math.min(_,x),A=Math.min(y,g),C=Math.abs(x-_),N=Math.abs(g-y);return{...d,geometry:{x:I,y:A,w:C,h:N,bounds:{minX:I,minY:A,maxX:I+C,maxY:A+N}}}};function h(d){Ze.call(this,r,d)}function c(d){Ze.call(this,r,d)}function u(d){Ze.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,c,u]}class Qm extends de{constructor(t){super(),ue(this,t,Jm,Zm,qt,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}const mh=new Map([[wt.RECTANGLE,Qm],[wt.POLYGON,Hm]]),gh=r=>mh.get(r.type),yh=(r,t)=>mh.set(r,t),tg=r=>({}),_h=r=>({grab:r[0]});function eg(r){let t,e,i,s;const n=r[7].default,o=Ip(n,r,r[6],_h);return{c(){t=yt("g"),o&&o.c(),T(t,"class","a9s-annotation selected")},m(a,l){it(a,t,l),o&&o.m(t,null),e=!0,i||(s=[Dt(t,"pointerup",r[2]),Dt(t,"pointermove",r[1])],i=!0)},p(a,[l]){o&&o.p&&(!e||l&64)&&Rp(o,n,a,a[6],e?Cp(n,a[6],l,tg):Pp(a[6]),_h)},i(a){e||(ot(o,a),e=!0)},o(a){mt(o,a),e=!1},d(a){a&&et(t),o&&o.d(a),i=!1,Pe(s)}}}function rg(r,t,e){let{$$slots:i={},$$scope:s}=t;const n=Qr();let{shape:o}=t,{editor:a}=t,{transform:l}=t,h,c,u;const d=m=>_=>{h=m,c=l.elementToImage(_.offsetX,_.offsetY),u=o,_.target.setPointerCapture(_.pointerId),n("grab",_)},f=m=>{if(h){const[_,y]=l.elementToImage(m.offsetX,m.offsetY),x=[_-c[0],y-c[1]];e(3,o=a(u,h,x)),n("change",o)}},p=m=>{m.target.releasePointerCapture(m.pointerId),h=void 0,u=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 vh extends de{constructor(t){super(),ue(this,t,rg,eg,qt,{shape:3,editor:4,transform:5})}}const Ns=(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 ig(r,t,e){let i;const s=Qr();let{annotation:n}=t,{editor:o}=t,{style:a}=t,{target:l}=t,{transform:h}=t,{viewportScale:c}=t,u;return zi(()=>(e(6,u=new o({target:l,props:{shape:n.target.selector,computedStyle:i,transform:h,viewportScale:c}})),u.$on("change",d=>{u.$$set({shape:d.detail}),s("change",d.detail)}),u.$on("grab",d=>s("grab",d.detail)),u.$on("release",d=>s("release",d.detail)),()=>{u.$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,c=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&5&&(i=Ns(n,a)),r.$$.dirty&65&&n&&(u==null||u.$set({shape:n.target.selector})),r.$$.dirty&80&&u&&u.$set({transform:h}),r.$$.dirty&96&&u&&u.$set({viewportScale:c})},[n,o,a,l,h,c,u]}class sg extends de{constructor(t){super(),ue(this,t,ig,null,qt,{annotation:0,editor:1,style:2,target:3,transform:4,viewportScale:5})}}function ng(r,t,e){const i=Qr();let{drawingMode:s}=t,{target:n}=t,{tool:o}=t,{transform:a}=t,{viewportScale:l}=t,h;return zi(()=>{const c=n.closest("svg"),u=[],d=(f,p,m)=>{c==null||c.addEventListener(f,p,m),u.push(()=>c==null?void 0:c.removeEventListener(f,p,m))};return e(5,h=new o({target:n,props:{addEventListener:d,drawingMode:s,transform:a,viewportScale:l}})),h.$on("create",f=>i("create",f.detail)),()=>{u.forEach(f=>f()),h.$destroy()}}),r.$$set=c=>{"drawingMode"in c&&e(0,s=c.drawingMode),"target"in c&&e(1,n=c.target),"tool"in c&&e(2,o=c.tool),"transform"in c&&e(3,a=c.transform),"viewportScale"in c&&e(4,l=c.viewportScale)},r.$$.update=()=>{r.$$.dirty&40&&h&&h.$set({transform:a}),r.$$.dirty&48&&h&&h.$set({viewportScale:l})},[s,n,o,a,l,h]}class og extends de{constructor(t){super(),ue(this,t,ng,null,qt,{drawingMode:0,target:1,tool:2,transform:3,viewportScale:4})}}function xh(r){let t,e;return{c(){t=yt("rect"),e=yt("rect"),T(t,"class","a9s-outer"),T(t,"x",r[1]),T(t,"y",r[2]),T(t,"width",r[3]),T(t,"height",r[4]),T(e,"class","a9s-inner"),T(e,"x",r[1]),T(e,"y",r[2]),T(e,"width",r[3]),T(e,"height",r[4])},m(i,s){it(i,t,s),it(i,e,s)},p(i,s){s&2&&T(t,"x",i[1]),s&4&&T(t,"y",i[2]),s&8&&T(t,"width",i[3]),s&16&&T(t,"height",i[4]),s&2&&T(e,"x",i[1]),s&4&&T(e,"y",i[2]),s&8&&T(e,"width",i[3]),s&16&&T(e,"height",i[4])},d(i){i&&(et(t),et(e))}}}function ag(r){let t,e=r[0]&&xh(r);return{c(){t=yt("g"),e&&e.c(),T(t,"class","a9s-annotation a9s-rubberband")},m(i,s){it(i,t,s),e&&e.m(t,null)},p(i,[s]){i[0]?e?e.p(i,s):(e=xh(i),e.c(),e.m(t,null)):e&&(e.d(1),e=null)},i:At,o:At,d(i){i&&et(t),e&&e.d()}}}function lg(r,t,e){const i=Qr();let{addEventListener:s}=t,{drawingMode:n}=t,{transform:o}=t,a,l,h,c,u,d,f;const p=x=>{const g=x;a=performance.now(),n==="drag"&&(e(0,l=o.elementToImage(g.offsetX,g.offsetY)),h=l,e(1,c=l[0]),e(2,u=l[1]),e(3,d=1),e(4,f=1))},m=x=>{const g=x;l&&(h=o.elementToImage(g.offsetX,g.offsetY),e(1,c=Math.min(h[0],l[0])),e(2,u=Math.min(h[1],l[1])),e(3,d=Math.abs(h[0]-l[0])),e(4,f=Math.abs(h[1]-l[1])))},_=x=>{const g=x,v=performance.now()-a;if(n==="click"){if(v>300)return;l?y():(e(0,l=o.elementToImage(g.offsetX,g.offsetY)),h=l,e(1,c=l[0]),e(2,u=l[1]),e(3,d=1),e(4,f=1))}else l&&(v>300||d*f>100?(g.stopPropagation(),y()):(e(0,l=void 0),h=void 0))},y=()=>{if(d*f>15){const x={type:wt.RECTANGLE,geometry:{bounds:{minX:c,minY:u,maxX:c+d,maxY:u+f},x:c,y:u,w:d,h:f}};i("create",x)}e(0,l=void 0),h=void 0};return zi(()=>{s("pointerdown",p),s("pointermove",m),s("pointerup",_,!0)}),r.$$set=x=>{"addEventListener"in x&&e(5,s=x.addEventListener),"drawingMode"in x&&e(6,n=x.drawingMode),"transform"in x&&e(7,o=x.transform)},[l,c,u,d,f,s,n,o]}class hg extends de{constructor(t){super(),ue(this,t,lg,ag,qt,{addEventListener:5,drawingMode:6,transform:7})}}function Io(r){const t=r.slice(),e=(t[2]?t[0]:[...t[0],t[1]]).map(i=>i.join(",")).join(" ");return t[16]=e,t}function bh(r){let t,e,i,s,n,o=r[2]&&wh(r);return{c(){t=yt("polygon"),i=yt("polygon"),o&&o.c(),n=ye(),T(t,"class","a9s-outer"),T(t,"points",e=r[16]),T(i,"class","a9s-inner"),T(i,"points",s=r[16])},m(a,l){it(a,t,l),it(a,i,l),o&&o.m(a,l),it(a,n,l)},p(a,l){l&7&&e!==(e=a[16])&&T(t,"points",e),l&7&&s!==(s=a[16])&&T(i,"points",s),a[2]?o?o.p(a,l):(o=wh(a),o.c(),o.m(n.parentNode,n)):o&&(o.d(1),o=null)},d(a){a&&(et(t),et(i),et(n)),o&&o.d(a)}}}function wh(r){let t,e,i;return{c(){t=yt("rect"),T(t,"class","a9s-corner-handle"),T(t,"x",e=r[0][0][0]-r[3]/2),T(t,"y",i=r[0][0][1]-r[3]/2),T(t,"height",r[3]),T(t,"width",r[3])},m(s,n){it(s,t,n)},p(s,n){n&9&&e!==(e=s[0][0][0]-s[3]/2)&&T(t,"x",e),n&9&&i!==(i=s[0][0][1]-s[3]/2)&&T(t,"y",i),n&8&&T(t,"height",s[3]),n&8&&T(t,"width",s[3])},d(s){s&&et(t)}}}function cg(r){let t,e=r[1]&&bh(Io(r));return{c(){t=yt("g"),e&&e.c(),T(t,"class","a9s-annotation a9s-rubberband")},m(i,s){it(i,t,s),e&&e.m(t,null)},p(i,[s]){i[1]?e?e.p(Io(i),s):(e=bh(Io(i)),e.c(),e.m(t,null)):e&&(e.d(1),e=null)},i:At,o:At,d(i){i&&et(t),e&&e.d()}}}const ug=20,dg=1500;function fg(r,t,e){let i;const s=Qr();let{addEventListener:n}=t,{drawingMode:o}=t,{transform:a}=t,{viewportScale:l=1}=t,h,c=[],u,d,f=!1;const p=g=>{const v=g,{timeStamp:w,offsetX:I,offsetY:A}=v;if(h={timeStamp:w,offsetX:I,offsetY:A},o==="drag"&&c.length===0){const C=a.elementToImage(v.offsetX,v.offsetY);c.push(C),e(1,u=C)}},m=g=>{const v=g;if(d&&clearTimeout(d),c.length>0){if(e(1,u=a.elementToImage(v.offsetX,v.offsetY)),c.length>2){const w=So(u,c[0])*l;e(2,f=w<ug)}v.pointerType==="touch"&&(d=setTimeout(()=>{y()},dg))}},_=g=>{const v=g;if(d&&clearTimeout(d),o==="click"){const w=v.timeStamp-h.timeStamp,I=So([h.offsetX,h.offsetY],[v.offsetX,v.offsetY]);if(w>300||I>15)return;if(f)x();else if(c.length===0){const A=a.elementToImage(v.offsetX,v.offsetY);c.push(A),e(1,u=A)}else c.push(u)}else{if(c.length===1&&So(c[0],u)<=4){e(0,c=[]),e(1,u=void 0);return}v.stopImmediatePropagation(),f?x():c.push(u)}},y=()=>{if(!u)return;const g=[...c,u],v={type:wt.POLYGON,geometry:{bounds:Bs(g),points:g}};vo(v)>4&&(e(0,c=[]),e(1,u=void 0),s("create",v))},x=()=>{const g={type:wt.POLYGON,geometry:{bounds:Bs(c),points:[...c]}};e(0,c=[]),e(1,u=void 0),s("create",g)};return zi(()=>{n("pointerdown",p,!0),n("pointermove",m),n("pointerup",_,!0),n("dblclick",y,!0)}),r.$$set=g=>{"addEventListener"in g&&e(4,n=g.addEventListener),"drawingMode"in g&&e(5,o=g.drawingMode),"transform"in g&&e(6,a=g.transform),"viewportScale"in g&&e(7,l=g.viewportScale)},r.$$.update=()=>{r.$$.dirty&128&&e(3,i=10/l)},[c,u,f,i,n,o,a,l]}class pg extends de{constructor(t){super(),ue(this,t,fg,cg,qt,{addEventListener:4,drawingMode:5,transform:6,viewportScale:7})}}const Co=new Map([["rectangle",{tool:hg}],["polygon",{tool:pg}]]),Us=()=>[...Co.keys()],ks=r=>Co.get(r),Eh=(r,t,e)=>Co.set(r,{tool:t,opts:e});function mg(r){let t,e,i,s,n;return{c(){t=yt("g"),e=yt("ellipse"),s=yt("ellipse"),T(e,"class","a9s-outer"),T(e,"style",i=r[1]?"display:none;":void 0),T(e,"cx",r[2]),T(e,"cy",r[3]),T(e,"rx",r[4]),T(e,"ry",r[5]),T(s,"class","a9s-inner"),T(s,"style",r[1]),T(s,"cx",r[2]),T(s,"cy",r[3]),T(s,"rx",r[4]),T(s,"ry",r[5]),T(t,"class","a9s-annotation"),T(t,"data-id",n=r[0].id)},m(o,a){it(o,t,a),Me(t,e),Me(t,s)},p(o,[a]){a&2&&i!==(i=o[1]?"display:none;":void 0)&&T(e,"style",i),a&2&&T(s,"style",o[1]),a&1&&n!==(n=o[0].id)&&T(t,"data-id",n)},i:At,o:At,d(o){o&&et(t)}}}function gg(r,t,e){let i,{annotation:s}=t,{geom:n}=t,{style:o}=t;const{cx:a,cy:l,rx:h,ry:c}=n;return r.$$set=u=>{"annotation"in u&&e(0,s=u.annotation),"geom"in u&&e(6,n=u.geom),"style"in u&&e(7,o=u.style)},r.$$.update=()=>{r.$$.dirty&129&&e(1,i=Ns(s,o))},[s,i,a,l,h,c,n,o]}class yg extends de{constructor(t){super(),ue(this,t,gg,mg,qt,{annotation:0,geom:6,style:7})}}function _g(r){let t,e,i,s,n;return{c(){t=yt("g"),e=yt("polygon"),s=yt("polygon"),T(e,"class","a9s-outer"),T(e,"style",i=r[1]?"display:none;":void 0),T(e,"points",r[2].map(vg).join(" ")),T(s,"class","a9s-inner"),T(s,"style",r[1]),T(s,"points",r[2].map(xg).join(" ")),T(t,"class","a9s-annotation"),T(t,"data-id",n=r[0].id)},m(o,a){it(o,t,a),Me(t,e),Me(t,s)},p(o,[a]){a&2&&i!==(i=o[1]?"display:none;":void 0)&&T(e,"style",i),a&2&&T(s,"style",o[1]),a&1&&n!==(n=o[0].id)&&T(t,"data-id",n)},i:At,o:At,d(o){o&&et(t)}}}const vg=r=>r.join(","),xg=r=>r.join(",");function bg(r,t,e){let i,{annotation:s}=t,{geom:n}=t,{style:o}=t;const{points:a}=n;return r.$$set=l=>{"annotation"in l&&e(0,s=l.annotation),"geom"in l&&e(3,n=l.geom),"style"in l&&e(4,o=l.style)},r.$$.update=()=>{r.$$.dirty&17&&e(1,i=Ns(s,o))},[s,i,a,n,o]}class wg extends de{constructor(t){super(),ue(this,t,bg,_g,qt,{annotation:0,geom:3,style:4})}}function Eg(r){let t,e,i,s,n;return{c(){t=yt("g"),e=yt("rect"),s=yt("rect"),T(e,"class","a9s-outer"),T(e,"style",i=r[5]?"display:none;":void 0),T(e,"x",r[4]),T(e,"y",r[3]),T(e,"width",r[2]),T(e,"height",r[1]),T(s,"class","a9s-inner"),T(s,"style",r[5]),T(s,"x",r[4]),T(s,"y",r[3]),T(s,"width",r[2]),T(s,"height",r[1]),T(t,"class","a9s-annotation"),T(t,"data-id",n=r[0].id)},m(o,a){it(o,t,a),Me(t,e),Me(t,s)},p(o,[a]){a&32&&i!==(i=o[5]?"display:none;":void 0)&&T(e,"style",i),a&16&&T(e,"x",o[4]),a&8&&T(e,"y",o[3]),a&4&&T(e,"width",o[2]),a&2&&T(e,"height",o[1]),a&32&&T(s,"style",o[5]),a&16&&T(s,"x",o[4]),a&8&&T(s,"y",o[3]),a&4&&T(s,"width",o[2]),a&2&&T(s,"height",o[1]),a&1&&n!==(n=o[0].id)&&T(t,"data-id",n)},i:At,o:At,d(o){o&&et(t)}}}function Tg(r,t,e){let i,s,n,o,a,{annotation:l}=t,{geom:h}=t,{style:c}=t;return r.$$set=u=>{"annotation"in u&&e(0,l=u.annotation),"geom"in u&&e(6,h=u.geom),"style"in u&&e(7,c=u.style)},r.$$.update=()=>{r.$$.dirty&129&&e(5,i=Ns(l,c)),r.$$.dirty&64&&e(4,{x:s,y:n,w:o,h:a}=h,s,(e(3,n),e(6,h)),(e(2,o),e(6,h)),(e(1,a),e(6,h)))},[l,a,o,n,s,i,h,c]}class Ag extends de{constructor(t){super(),ue(this,t,Tg,Eg,qt,{annotation:0,geom:6,style:7})}}const Sg=r=>({elementToImage:(t,e)=>{const i=r.getBoundingClientRect(),s=r.createSVGPoint();s.x=t+i.x,s.y=e+i.y;const{x:n,y:o}=s.matrixTransform(r.getScreenCTM().inverse());return[n,o]}}),Ig=250,Cg=(r,t)=>{const e=Qr();let i;return{onPointerDown:()=>i=performance.now(),onPointerUp:s=>{if(performance.now()-i<Ig){const{x:n,y:o}=Th(s,r),a=t.getAt(n,o);a?e("click",{originalEvent:s,annotation:a}):e("click",{originalEvent:s})}}}},Th=(r,t)=>{const e=t.createSVGPoint(),i=t.getBoundingClientRect(),s=r.clientX-i.x,n=r.clientY-i.y,{left:o,top:a}=t.getBoundingClientRect();return e.x=s+o,e.y=n+a,e.matrixTransform(t.getScreenCTM().inverse())};function Ah(r,t,e){const i=r.slice();i[37]=t[e];const s=i[23](i[37].target.selector);return i[38]=s,i}function Sh(r,t,e){const i=r.slice();return i[41]=t[e],i}function Ro(r){const t=r.slice(),e=t[41].target.selector;return t[44]=e,t}function Ih(r){let t=r[41].id,e,i,s=Ch(r);return{c(){s.c(),e=ye()},m(n,o){s.m(n,o),it(n,e,o),i=!0},p(n,o){o[0]&32768&&qt(t,t=n[41].id)?(_e(),mt(s,1,1,At),ve(),s=Ch(n),s.c(),ot(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(ot(s),i=!0)},o(n){mt(s),i=!1},d(n){n&&et(e),s.d(n)}}}function Rg(r){let t,e;return t=new wg({props:{annotation:r[41],geom:r[44].geometry,style:r[1]}}),{c(){ce(t.$$.fragment)},m(i,s){se(t,i,s),e=!0},p(i,s){const n={};s[0]&32768&&(n.annotation=i[41]),s[0]&32768&&(n.geom=i[44].geometry),s[0]&2&&(n.style=i[1]),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){ne(t,i)}}}function Pg(r){let t,e;return t=new Ag({props:{annotation:r[41],geom:r[44].geometry,style:r[1]}}),{c(){ce(t.$$.fragment)},m(i,s){se(t,i,s),e=!0},p(i,s){const n={};s[0]&32768&&(n.annotation=i[41]),s[0]&32768&&(n.geom=i[44].geometry),s[0]&2&&(n.style=i[1]),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){ne(t,i)}}}function Mg(r){var t;let e,i;return e=new yg({props:{annotation:r[41],geom:(t=r[44])==null?void 0:t.geometry,style:r[1]}}),{c(){ce(e.$$.fragment)},m(s,n){se(e,s,n),i=!0},p(s,n){var o;const a={};n[0]&32768&&(a.annotation=s[41]),n[0]&32768&&(a.geom=(o=s[44])==null?void 0:o.geometry),n[0]&2&&(a.style=s[1]),e.$set(a)},i(s){i||(ot(e.$$.fragment,s),i=!0)},o(s){mt(e.$$.fragment,s),i=!1},d(s){ne(e,s)}}}function Ch(r){let t,e,i,s;const n=[Mg,Pg,Rg],o=[];function a(l,h){var c,u,d;return((c=l[44])==null?void 0:c.type)===wt.ELLIPSE?0:((u=l[44])==null?void 0:u.type)===wt.RECTANGLE?1:((d=l[44])==null?void 0:d.type)===wt.POLYGON?2:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=ye()},m(l,h){~t&&o[t].m(l,h),it(l,i,h),s=!0},p(l,h){let c=t;t=a(l),t===c?~t&&o[t].p(l,h):(e&&(_e(),mt(o[c],1,1,()=>{o[c]=null}),ve()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=n[t](l),e.c()),ot(e,1),e.m(i.parentNode,i)):e=null)},i(l){s||(ot(e),s=!0)},o(l){mt(e),s=!1},d(l){l&&et(i),~t&&o[t].d(l)}}}function Rh(r){let t=Je(r[41])&&!r[8](r[41]),e,i,s=t&&Ih(Ro(r));return{c(){s&&s.c(),e=ye()},m(n,o){s&&s.m(n,o),it(n,e,o),i=!0},p(n,o){o[0]&33024&&(t=Je(n[41])&&!n[8](n[41])),t?s?(s.p(Ro(n),o),o[0]&33024&&ot(s,1)):(s=Ih(Ro(n)),s.c(),ot(s,1),s.m(e.parentNode,e)):s&&(_e(),mt(s,1,1,()=>{s=null}),ve())},i(n){i||(ot(s),i=!0)},o(n){mt(s),i=!1},d(n){n&&et(e),s&&s.d(n)}}}function Ph(r){let t,e,i,s;const n=[Dg,Bg],o=[];function a(l,h){return l[7]?0:l[13]&&l[0]?1:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=ye()},m(l,h){~t&&o[t].m(l,h),it(l,i,h),s=!0},p(l,h){let c=t;t=a(l),t===c?~t&&o[t].p(l,h):(e&&(_e(),mt(o[c],1,1,()=>{o[c]=null}),ve()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=n[t](l),e.c()),ot(e,1),e.m(i.parentNode,i)):e=null)},i(l){s||(ot(e),s=!0)},o(l){mt(e),s=!1},d(l){l&&et(i),~t&&o[t].d(l)}}}function Bg(r){let t=r[2],e,i,s=Mh(r);return{c(){s.c(),e=ye()},m(n,o){s.m(n,o),it(n,e,o),i=!0},p(n,o){o[0]&4&&qt(t,t=n[2])?(_e(),mt(s,1,1,At),ve(),s=Mh(n),s.c(),ot(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(ot(s),i=!0)},o(n){mt(s),i=!1},d(n){n&&et(e),s.d(n)}}}function Dg(r){let t,e,i=ii(r[7]),s=[];for(let o=0;o<i.length;o+=1)s[o]=Oh(Ah(r,i,o));const n=o=>mt(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=ye()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);it(o,t,a),e=!0},p(o,a){if(a[0]&10553506){i=ii(o[7]);let l;for(l=0;l<i.length;l+=1){const h=Ah(o,i,l);s[l]?(s[l].p(h,a),ot(s[l],1)):(s[l]=Oh(h),s[l].c(),ot(s[l],1),s[l].m(t.parentNode,t))}for(_e(),l=i.length;l<s.length;l+=1)n(l);ve()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)ot(s[a]);e=!0}},o(o){s=s.filter(Boolean);for(let a=0;a<s.length;a+=1)mt(s[a]);e=!1},d(o){o&&et(t),fo(s,o)}}}function Mh(r){let t,e;return t=new og({props:{target:r[5],tool:r[13],drawingMode:r[12],transform:r[11],viewportScale:r[16]}}),t.$on("create",r[20]),{c(){ce(t.$$.fragment)},m(i,s){se(t,i,s),e=!0},p(i,s){const n={};s[0]&32&&(n.target=i[5]),s[0]&8192&&(n.tool=i[13]),s[0]&4096&&(n.drawingMode=i[12]),s[0]&2048&&(n.transform=i[11]),s[0]&65536&&(n.viewportScale=i[16]),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){ne(t,i)}}}function Bh(r){let t=r[37].id,e,i,s=Dh(r);return{c(){s.c(),e=ye()},m(n,o){s.m(n,o),it(n,e,o),i=!0},p(n,o){o[0]&128&&qt(t,t=n[37].id)?(_e(),mt(s,1,1,At),ve(),s=Dh(n),s.c(),ot(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(ot(s),i=!0)},o(n){mt(s),i=!1},d(n){n&&et(e),s.d(n)}}}function Dh(r){let t,e;return t=new sg({props:{target:r[5],editor:r[23](r[37].target.selector),annotation:r[37],style:r[1],transform:r[11],viewportScale:r[16]}}),t.$on("change",function(){Ut(r[21](r[37]))&&r[21](r[37]).apply(this,arguments)}),{c(){ce(t.$$.fragment)},m(i,s){se(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&32&&(n.target=r[5]),s[0]&128&&(n.editor=r[23](r[37].target.selector)),s[0]&128&&(n.annotation=r[37]),s[0]&2&&(n.style=r[1]),s[0]&2048&&(n.transform=r[11]),s[0]&65536&&(n.viewportScale=r[16]),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){ne(t,i)}}}function Oh(r){let t,e,i=r[38]&&Bh(r);return{c(){i&&i.c(),t=ye()},m(s,n){i&&i.m(s,n),it(s,t,n),e=!0},p(s,n){s[38]?i?(i.p(s,n),n[0]&128&&ot(i,1)):(i=Bh(s),i.c(),ot(i,1),i.m(t.parentNode,t)):i&&(_e(),mt(i,1,1,()=>{i=null}),ve())},i(s){e||(ot(i),e=!0)},o(s){mt(i),e=!1},d(s){s&&et(t),i&&i.d(s)}}}function Og(r){let t,e,i,s,n,o,a=ii(r[15].filter(r[32])),l=[];for(let u=0;u<a.length;u+=1)l[u]=Rh(Sh(r,a,u));const h=u=>mt(l[u],1,1,()=>{l[u]=null});let c=r[5]&&Ph(r);return{c(){t=yt("svg"),e=yt("g");for(let u=0;u<l.length;u+=1)l[u].c();i=yt("g"),c&&c.c(),T(i,"class","drawing"),T(t,"class","a9s-annotationlayer"),fr(t,"drawing",r[13]),fr(t,"hidden",!r[3]),fr(t,"hover",r[14])},m(u,d){it(u,t,d),Me(t,e);for(let f=0;f<l.length;f+=1)l[f]&&l[f].m(e,null);Me(t,i),c&&c.m(i,null),r[33](i),r[34](t),s=!0,n||(o=[Dt(t,"pointerup",function(){Ut(r[9])&&r[9].apply(this,arguments)}),Dt(t,"pointerdown",function(){Ut(r[10])&&r[10].apply(this,arguments)}),Dt(t,"pointermove",r[22])],n=!0)},p(u,d){if(r=u,d[0]&33026){a=ii(r[15].filter(r[32]));let f;for(f=0;f<a.length;f+=1){const p=Sh(r,a,f);l[f]?(l[f].p(p,d),ot(l[f],1)):(l[f]=Rh(p),l[f].c(),ot(l[f],1),l[f].m(e,null))}for(_e(),f=a.length;f<l.length;f+=1)h(f);ve()}r[5]?c?(c.p(r,d),d[0]&32&&ot(c,1)):(c=Ph(r),c.c(),ot(c,1),c.m(i,null)):c&&(_e(),mt(c,1,1,()=>{c=null}),ve()),(!s||d[0]&8192)&&fr(t,"drawing",r[13]),(!s||d[0]&8)&&fr(t,"hidden",!r[3]),(!s||d[0]&16384)&&fr(t,"hover",r[14])},i(u){if(!s){for(let d=0;d<a.length;d+=1)ot(l[d]);ot(c),s=!0}},o(u){l=l.filter(Boolean);for(let d=0;d<l.length;d+=1)mt(l[d]);mt(c),s=!1},d(u){u&&et(t),fo(l,u),c&&c.d(),r[33](null),r[34](null),n=!1,Pe(o)}}}function Fg(r,t,e){let i,s,n,o,a,l,h,c,u,d,f,p=At,m=()=>(p(),p=jl(E,V=>e(16,f=V)),E);r.$$.on_destroy.push(()=>p());let{drawingEnabled:_}=t,{image:y}=t,{preferredDrawingMode:x}=t,{state:g}=t,{style:v=void 0}=t,{toolName:w=Us()[0]}=t,{user:I}=t,{visible:A=!0}=t;const C=()=>w,N=()=>_;let S,R,E;zi(()=>m(e(6,E=zm(y,R))));const{hover:b,selection:D,store:F}=g;uo(r,b,V=>e(14,c=V)),uo(r,D,V=>e(31,u=V)),uo(r,F,V=>e(15,d=V));let G,$;const B=V=>{G&&F.unobserve(G);const lt=V.filter(({editable:L})=>L).map(({id:L})=>L);lt.length>0?(e(7,$=lt.map(L=>F.getAnnotation(L)).filter(L=>L&&Je(L))),G=L=>{const{updated:O}=L.changes;e(7,$=O==null?void 0:O.map(_t=>_t.newValue))},F.observe(G,{annotations:lt})):e(7,$=void 0)},Z=V=>{const lt=ih(),L={id:lt,bodies:[],target:{annotation:lt,selector:V.detail,creator:I,created:new Date}};F.addAnnotation(L),D.setSelected(L.id)},P=V=>lt=>{var L;const{target:O}=V,_t=10*60*1e3,ht=((L=O.creator)==null?void 0:L.id)!==I.id||!O.created||new Date().getTime()-O.created.getTime()>_t;F.updateTarget({...O,selector:lt.detail,created:ht?O.created:new Date,updated:ht?new Date:void 0,updatedBy:ht?I:void 0})},U=V=>{const{x:lt,y:L}=Th(V,R),O=F.getAt(lt,L);O?c!==O.id&&b.set(O.id):b.set(void 0)},j=V=>gh(V),rt=V=>Je(V);function Q(V){Ps[V?"unshift":"push"](()=>{S=V,e(5,S)})}function H(V){Ps[V?"unshift":"push"](()=>{R=V,e(4,R)})}return r.$$set=V=>{"drawingEnabled"in V&&e(0,_=V.drawingEnabled),"image"in V&&e(24,y=V.image),"preferredDrawingMode"in V&&e(25,x=V.preferredDrawingMode),"state"in V&&e(26,g=V.state),"style"in V&&e(1,v=V.style),"toolName"in V&&e(2,w=V.toolName),"user"in V&&e(27,I=V.user),"visible"in V&&e(3,A=V.visible)},r.$$.update=()=>{r.$$.dirty[0]&4&&e(13,{tool:i,opts:s}=ks(w)||{tool:void 0,opts:void 0},i,(e(30,s),e(2,w))),r.$$.dirty[0]&1107296256&&e(12,n=(s==null?void 0:s.drawingMode)||x),r.$$.dirty[0]&16&&e(11,o=Sg(R)),r.$$.dirty[0]&16&&e(10,{onPointerDown:a,onPointerUp:l}=Cg(R,F),a,(e(9,l),e(4,R))),r.$$.dirty[1]&1&&e(8,h=V=>u.selected.find(lt=>lt.id===V.id&<.editable)),r.$$.dirty[1]&1&&B(u.selected)},[_,v,w,A,R,S,E,$,h,l,a,o,n,i,c,d,f,b,D,F,Z,P,U,j,y,x,g,I,C,N,s,u,rt,Q,H]}class Lg extends de{constructor(t){super(),ue(this,t,Fg,Og,qt,{drawingEnabled:0,image:24,preferredDrawingMode:25,state:26,style:1,toolName:2,user:27,visible:3,getDrawingTool:28,isDrawingEnabled:29},null,[-1,-1])}get getDrawingTool(){return this.$$.ctx[28]}get isDrawingEnabled(){return this.$$.ctx[29]}}function Fh(r,t,e=0,i=r.length-1,s=Ng){for(;i>e;){if(i-e>600){const l=i-e+1,h=t-e+1,c=Math.log(l),u=.5*Math.exp(2*c/3),d=.5*Math.sqrt(c*u*(l-u)/l)*(h-l/2<0?-1:1),f=Math.max(e,Math.floor(t-h*u/l+d)),p=Math.min(i,Math.floor(t+(l-h)*u/l+d));Fh(r,t,f,p,s)}const n=r[t];let o=e,a=i;for(ji(r,e,t),s(r[i],n)>0&&ji(r,e,i);o<a;){for(ji(r,o,a),o++,a--;s(r[o],n)<0;)o++;for(;s(r[a],n)>0;)a--}s(r[e],n)===0?ji(r,e,a):(a++,ji(r,a,i)),a<=t&&(e=a+1),t<=a&&(i=a-1)}}function ji(r,t,e){const i=r[t];r[t]=r[e],r[e]=i}function Ng(r,t){return r<t?-1:r>t?1:0}class Ug{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(t){let e=this.data;const i=[];if(!$s(t,e))return i;const s=this.toBBox,n=[];for(;e;){for(let o=0;o<e.children.length;o++){const a=e.children[o],l=e.leaf?s(a):a;$s(t,l)&&(e.leaf?i.push(a):Mo(t,l)?this._all(a,i):n.push(a))}e=n.pop()}return i}collides(t){let e=this.data;if(!$s(t,e))return!1;const i=[];for(;e;){for(let s=0;s<e.children.length;s++){const n=e.children[s],o=e.leaf?this.toBBox(n):n;if($s(t,o)){if(e.leaf||Mo(t,o))return!0;i.push(n)}}e=i.pop()}return!1}load(t){if(!(t&&t.length))return this;if(t.length<this._minEntries){for(let i=0;i<t.length;i++)this.insert(t[i]);return this}let e=this._build(t.slice(),0,t.length-1,0);if(!this.data.children.length)this.data=e;else if(this.data.height===e.height)this._splitRoot(this.data,e);else{if(this.data.height<e.height){const i=this.data;this.data=e,e=i}this._insert(e,this.data.height-e.height-1,!0)}return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=ai([]),this}remove(t,e){if(!t)return this;let i=this.data;const s=this.toBBox(t),n=[],o=[];let a,l,h;for(;i||n.length;){if(i||(i=n.pop(),l=n[n.length-1],a=o.pop(),h=!0),i.leaf){const c=kg(t,i.children,e);if(c!==-1)return i.children.splice(c,1),n.push(i),this._condense(n),this}!h&&!i.leaf&&Mo(i,s)?(n.push(i),o.push(a),a=0,l=i,i=i.children[0]):l?(a++,i=l.children[a],h=!1):i=null}return this}toBBox(t){return t}compareMinX(t,e){return t.minX-e.minX}compareMinY(t,e){return t.minY-e.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,e){const i=[];for(;t;)t.leaf?e.push(...t.children):i.push(...t.children),t=i.pop();return e}_build(t,e,i,s){const n=i-e+1;let o=this._maxEntries,a;if(n<=o)return a=ai(t.slice(e,i+1)),oi(a,this.toBBox),a;s||(s=Math.ceil(Math.log(n)/Math.log(o)),o=Math.ceil(n/Math.pow(o,s-1))),a=ai([]),a.leaf=!1,a.height=s;const l=Math.ceil(n/o),h=l*Math.ceil(Math.sqrt(o));Lh(t,e,i,h,this.compareMinX);for(let c=e;c<=i;c+=h){const u=Math.min(c+h-1,i);Lh(t,c,u,l,this.compareMinY);for(let d=c;d<=u;d+=l){const f=Math.min(d+l-1,u);a.children.push(this._build(t,d,f,s-1))}}return oi(a,this.toBBox),a}_chooseSubtree(t,e,i,s){for(;s.push(e),!(e.leaf||s.length-1===i);){let n=1/0,o=1/0,a;for(let l=0;l<e.children.length;l++){const h=e.children[l],c=Po(h),u=Hg(t,h)-c;u<o?(o=u,n=c<n?c:n,a=h):u===o&&c<n&&(n=c,a=h)}e=a||e.children[0]}return e}_insert(t,e,i){const s=i?t:this.toBBox(t),n=[],o=this._chooseSubtree(s,this.data,e,n);for(o.children.push(t),qi(o,s);e>=0&&n[e].children.length>this._maxEntries;)this._split(n,e),e--;this._adjustParentBBoxes(s,n,e)}_split(t,e){const i=t[e],s=i.children.length,n=this._minEntries;this._chooseSplitAxis(i,n,s);const o=this._chooseSplitIndex(i,n,s),a=ai(i.children.splice(o,i.children.length-o));a.height=i.height,a.leaf=i.leaf,oi(i,this.toBBox),oi(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)}_splitRoot(t,e){this.data=ai([t,e]),this.data.height=t.height+1,this.data.leaf=!1,oi(this.data,this.toBBox)}_chooseSplitIndex(t,e,i){let s,n=1/0,o=1/0;for(let a=e;a<=i-e;a++){const l=Yi(t,0,a,this.toBBox),h=Yi(t,a,i,this.toBBox),c=Xg(l,h),u=Po(l)+Po(h);c<n?(n=c,s=a,o=u<o?u:o):c===n&&u<o&&(o=u,s=a)}return s||i-e}_chooseSplitAxis(t,e,i){const s=t.leaf?this.compareMinX:Gg,n=t.leaf?this.compareMinY:$g,o=this._allDistMargin(t,e,i,s),a=this._allDistMargin(t,e,i,n);o<a&&t.children.sort(s)}_allDistMargin(t,e,i,s){t.children.sort(s);const n=this.toBBox,o=Yi(t,0,e,n),a=Yi(t,i-e,i,n);let l=Gs(o)+Gs(a);for(let h=e;h<i-e;h++){const c=t.children[h];qi(o,t.leaf?n(c):c),l+=Gs(o)}for(let h=i-e-1;h>=e;h--){const c=t.children[h];qi(a,t.leaf?n(c):c),l+=Gs(a)}return l}_adjustParentBBoxes(t,e,i){for(let s=i;s>=0;s--)qi(e[s],t)}_condense(t){for(let e=t.length-1,i;e>=0;e--)t[e].children.length===0?e>0?(i=t[e-1].children,i.splice(i.indexOf(t[e]),1)):this.clear():oi(t[e],this.toBBox)}}function kg(r,t,e){if(!e)return t.indexOf(r);for(let i=0;i<t.length;i++)if(e(r,t[i]))return i;return-1}function oi(r,t){Yi(r,0,r.children.length,t,r)}function Yi(r,t,e,i,s){s||(s=ai(null)),s.minX=1/0,s.minY=1/0,s.maxX=-1/0,s.maxY=-1/0;for(let n=t;n<e;n++){const o=r.children[n];qi(s,r.leaf?i(o):o)}return s}function qi(r,t){return r.minX=Math.min(r.minX,t.minX),r.minY=Math.min(r.minY,t.minY),r.maxX=Math.max(r.maxX,t.maxX),r.maxY=Math.max(r.maxY,t.maxY),r}function Gg(r,t){return r.minX-t.minX}function $g(r,t){return r.minY-t.minY}function Po(r){return(r.maxX-r.minX)*(r.maxY-r.minY)}function Gs(r){return r.maxX-r.minX+(r.maxY-r.minY)}function Hg(r,t){return(Math.max(t.maxX,r.maxX)-Math.min(t.minX,r.minX))*(Math.max(t.maxY,r.maxY)-Math.min(t.minY,r.minY))}function Xg(r,t){const e=Math.max(r.minX,t.minX),i=Math.max(r.minY,t.minY),s=Math.min(r.maxX,t.maxX),n=Math.min(r.maxY,t.maxY);return Math.max(0,s-e)*Math.max(0,n-i)}function Mo(r,t){return r.minX<=t.minX&&r.minY<=t.minY&&t.maxX<=r.maxX&&t.maxY<=r.maxY}function $s(r,t){return t.minX<=r.maxX&&t.minY<=r.maxY&&t.maxX>=r.minX&&t.maxY>=r.minY}function ai(r){return{children:r,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Lh(r,t,e,i,s){const n=[t,e];for(;n.length;){if(e=n.pop(),t=n.pop(),e-t<=i)continue;const o=t+Math.ceil((e-t)/i/2)*i;Fh(r,o,t,e,s),n.push(t,o,o,e)}}const Vg=()=>{const r=new Ug,t=new Map,e=()=>[...t.values()],i=()=>{r.clear(),t.clear()},s=o=>{if(!Ds(o))return;const{minX:a,minY:l,maxX:h,maxY:c}=o.selector.geometry.bounds,u={minX:a,minY:l,maxX:h,maxY:c,target:o};r.insert(u),t.set(o.annotation,u)},n=o=>{if(!Ds(o))return;const a=t.get(o.annotation);a&&r.remove(a),t.delete(o.annotation)};return{all:e,clear:i,getAt:(o,a)=>{const l=r.search({minX:o,minY:a,maxX:o,maxY:a}).map(h=>h.target).filter(h=>h.selector.type===wt.RECTANGLE||kp(h.selector,o,a));if(l.length>0)return l.sort((h,c)=>vo(h.selector)-vo(c.selector)),l[0]},getIntersecting:(o,a,l,h)=>r.search({minX:o,minY:a,maxX:o+l,maxY:a+h}).map(c=>c.target),insert:s,remove:n,set:(o,a=!0)=>{a&&i();const l=o.reduce((h,c)=>{if(Ds(c)){const{minX:u,minY:d,maxX:f,maxY:p}=c.selector.geometry.bounds;return[...h,{minX:u,minY:d,maxX:f,maxY:p,target:c}]}else return h},[]);l.forEach(h=>t.set(h.target.annotation,h)),r.load(l)},size:()=>r.all().length,update:(o,a)=>{n(o),s(a)}}},Nh=r=>{const t=gm(),e=Vg(),i=im(t,r.userSelectAction,r.adapter),s=rm(t),n=bm();return t.observe(({changes:o})=>{e.set((o.created||[]).map(a=>a.target),!1),(o.deleted||[]).forEach(a=>e.remove(a.target)),(o.updated||[]).forEach(({oldValue:a,newValue:l})=>e.update(a.target,l.target))}),{store:{...t,getAt:(o,a)=>{const l=e.getAt(o,a);return l?t.getAnnotation(l.annotation):void 0},getIntersecting:(o,a,l,h)=>e.getIntersecting(o,a,l,h).map(c=>t.getAnnotation(c.annotation))},selection:i,hover:s,viewport:n}},zg=r=>{const t=Nh(r);return{...t,store:ym(t.store)}},Wg=r=>{let t,e;if(r.nodeName==="CANVAS")t=r,e=t.getContext("2d",{willReadFrequently:!0});else{const s=r;t=document.createElement("canvas"),t.width=s.width,t.height=s.height,e=t.getContext("2d",{willReadFrequently:!0}),e.drawImage(s,0,0,s.width,s.height)}let i=0;for(let s=1;s<10;s++)for(let n=1;n<10;n++){const o=Math.round(n*t.width/10),a=Math.round(s*t.height/10),l=e.getImageData(o,a,1,1).data,h=(.299*l[0]+.587*l[1]+.114*l[2])/255;i+=h}return i/81},Uh=r=>{const t=Wg(r),e=t>.6?"dark":"light";return console.log(`[Annotorious] Image brightness: ${t.toFixed(1)}. Setting ${e} theme.`),e},kh=(r,t,e)=>t.setAttribute("data-theme",e==="auto"?Uh(r):e),Gh=(r,t)=>({...r,drawingEnabled:r.drawingEnabled===void 0?t.drawingEnabled:r.drawingEnabled,drawingMode:r.drawingMode||t.drawingMode,userSelectAction:r.userSelectAction||t.userSelectAction,theme:r.theme||t.theme}),$h=typeof navigator>"u"?!1:navigator.userAgent.indexOf("Mac OS X")!==-1,Hh=(r,t)=>{const e=t||document,i=o=>{const a=o;a.key==="z"&&a.ctrlKey?r.undo():a.key==="y"&&a.ctrlKey&&r.redo()},s=o=>{const a=o;a.key==="z"&&a.metaKey&&(a.shiftKey?r.redo():r.undo())},n=()=>{$h?e.removeEventListener("keydown",s):e.removeEventListener("keydown",i)};return $h?e.addEventListener("keydown",s):e.addEventListener("keydown",i),{destroy:n}},jg=(r,t={})=>{if(!r)throw"Missing argument: image";const e=typeof r=="string"?document.getElementById(r):r,i=Gh(t,{drawingEnabled:!0,drawingMode:"drag",userSelectAction:nh.EDIT,theme:"light"}),s=zg(i),{selection:n,store:o}=s,a=xm(o),l=wm(s,a,i.adapter,i.autoSave),h=document.createElement("DIV");h.style.position="relative",h.style.display="inline-block",e.style.display="block",e.parentNode.insertBefore(h,e),h.appendChild(e);const c=Hh(a);let u=Bm();kh(e,h,i.theme);const d=new Lg({target:h,props:{drawingEnabled:!!i.drawingEnabled,image:e,preferredDrawingMode:i.drawingMode,state:s,style:i.style,user:u}});d.$on("click",E=>{const{originalEvent:b,annotation:D}=E.detail;D?n.userSelect(D.id,b):n.isEmpty()||n.clear()});const f=Tm(s,a,i.adapter),p=()=>{d.$set({drawingEnabled:!1}),setTimeout(()=>d.$set({drawingEnabled:!0}),1)},m=()=>{d.$destroy(),h.parentNode.insertBefore(e,h),h.parentNode.removeChild(h),c.destroy(),a.destroy()},_=()=>d.getDrawingTool(),y=()=>u,x=()=>d.isDrawingEnabled(),g=(E,b,D)=>Eh(E,b,D),v=(E,b)=>yh(E,b),w=E=>{if(!ks(E))throw`No drawing tool named ${E}`;d.$set({toolName:E})},I=E=>d.$set({drawingEnabled:E}),A=E=>{console.warn("Filter not implemented yet")},C=E=>d.$set({style:E}),N=E=>kh(e,h,E),S=E=>{u=E,d.$set({user:E})},R=E=>d.$set({visible:E});return{...f,cancelDrawing:p,destroy:m,getDrawingTool:_,getUser:y,isDrawingEnabled:x,listDrawingTools:Us,on:l.on,off:l.off,registerDrawingTool:g,registerShapeEditor:v,setDrawingEnabled:I,setDrawingTool:w,setFilter:A,setStyle:C,setTheme:N,setUser:S,setVisible:R,element:h,state:s}};function Be(){}function Bo(r,t){for(const e in t)r[e]=t[e];return r}function Xh(r){return r()}function Vh(){return Object.create(null)}function Qe(r){r.forEach(Xh)}function Kt(r){return typeof r=="function"}function te(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}function Yg(r){return Object.keys(r).length===0}function qg(r,...t){if(r==null){for(const i of t)i(void 0);return Be}const e=r.subscribe(...t);return e.unsubscribe?()=>e.unsubscribe():e}function Do(r,t,e){r.$$.on_destroy.push(qg(t,e))}function zh(r,t,e,i){if(r){const s=Wh(r,t,e,i);return r[0](s)}}function Wh(r,t,e,i){return r[1]&&i?Bo(e.ctx.slice(),r[1](i(t))):e.ctx}function jh(r,t,e,i){if(r[2]&&i){const s=r[2](i(e));if(t.dirty===void 0)return s;if(typeof s=="object"){const n=[],o=Math.max(t.dirty.length,s.length);for(let a=0;a<o;a+=1)n[a]=t.dirty[a]|s[a];return n}return t.dirty|s}return t.dirty}function Yh(r,t,e,i,s,n){if(s){const o=Wh(t,e,i,n);r.p(o,s)}}function qh(r){if(r.ctx.length>32){const t=[],e=r.ctx.length/32;for(let i=0;i<e;i++)t[i]=-1;return t}return-1}function Kh(r){const t={};for(const e in r)e[0]!=="$"&&(t[e]=r[e]);return t}function Hs(r){return r??""}const Kg=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global;function tr(r,t){r.appendChild(t)}function ft(r,t,e){r.insertBefore(t,e||null)}function ct(r){r.parentNode&&r.parentNode.removeChild(r)}function Oo(r,t){for(let e=0;e<r.length;e+=1)r[e]&&r[e].d(t)}function Tt(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function Fo(r){return document.createTextNode(r)}function xe(){return Fo(" ")}function er(){return Fo("")}function zt(r,t,e,i){return r.addEventListener(t,e,i),()=>r.removeEventListener(t,e,i)}function M(r,t,e){e==null?r.removeAttribute(t):r.getAttribute(t)!==e&&r.setAttribute(t,e)}function Zg(r){return Array.from(r.childNodes)}function Jg(r,t){t=""+t,r.data!==t&&(r.data=t)}function Xs(r,t,e){r.classList.toggle(t,!!e)}function Qg(r,t,{bubbles:e=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:t,bubbles:e,cancelable:i})}let Ki;function Zi(r){Ki=r}function Lo(){if(!Ki)throw new Error("Function called outside component initialization");return Ki}function Vs(r){Lo().$$.on_mount.push(r)}function ty(r){Lo().$$.on_destroy.push(r)}function zs(){const r=Lo();return(t,e,{cancelable:i=!1}={})=>{const s=r.$$.callbacks[t];if(s){const n=Qg(t,e,{cancelable:i});return s.slice().forEach(o=>{o.call(r,n)}),!n.defaultPrevented}return!0}}function rr(r,t){const e=r.$$.callbacks[t.type];e&&e.slice().forEach(i=>i.call(this,t))}const li=[],Ws=[];let hi=[];const Zh=[],ey=Promise.resolve();let No=!1;function ry(){No||(No=!0,ey.then(Jh))}function Uo(r){hi.push(r)}const ko=new Set;let ci=0;function Jh(){if(ci!==0)return;const r=Ki;do{try{for(;ci<li.length;){const t=li[ci];ci++,Zi(t),iy(t.$$)}}catch(t){throw li.length=0,ci=0,t}for(Zi(null),li.length=0,ci=0;Ws.length;)Ws.pop()();for(let t=0;t<hi.length;t+=1){const e=hi[t];ko.has(e)||(ko.add(e),e())}hi.length=0}while(li.length);for(;Zh.length;)Zh.pop()();No=!1,ko.clear(),Zi(r)}function iy(r){if(r.fragment!==null){r.update(),Qe(r.before_update);const t=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,t),r.after_update.forEach(Uo)}}function sy(r){const t=[],e=[];hi.forEach(i=>r.indexOf(i)===-1?t.push(i):e.push(i)),e.forEach(i=>i()),hi=t}const js=new Set;let Dr;function De(){Dr={r:0,c:[],p:Dr}}function Oe(){Dr.r||Qe(Dr.c),Dr=Dr.p}function st(r,t){r&&r.i&&(js.delete(r),r.i(t))}function ut(r,t,e,i){if(r&&r.o){if(js.has(r))return;js.add(r),Dr.c.push(()=>{js.delete(r),i&&(e&&r.d(1),i())}),r.o(t)}else i&&i()}function ui(r){return(r==null?void 0:r.length)!==void 0?r:Array.from(r)}function ee(r){r&&r.c()}function Zt(r,t,e){const{fragment:i,after_update:s}=r.$$;i&&i.m(t,e),Uo(()=>{const n=r.$$.on_mount.map(Xh).filter(Kt);r.$$.on_destroy?r.$$.on_destroy.push(...n):Qe(n),r.$$.on_mount=[]}),s.forEach(Uo)}function Jt(r,t){const e=r.$$;e.fragment!==null&&(sy(e.after_update),Qe(e.on_destroy),e.fragment&&e.fragment.d(t),e.on_destroy=e.fragment=null,e.ctx=[])}function ny(r,t){r.$$.dirty[0]===-1&&(li.push(r),ry(),r.$$.dirty.fill(0)),r.$$.dirty[t/31|0]|=1<<t%31}function oe(r,t,e,i,s,n,o=null,a=[-1]){const l=Ki;Zi(r);const h=r.$$={fragment:null,ctx:[],props:n,update:Be,not_equal:s,bound:Vh(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:Vh(),dirty:a,skip_bound:!1,root:t.target||l.$$.root};o&&o(h.root);let c=!1;if(h.ctx=e?e(r,t.props||{},(u,d,...f)=>{const p=f.length?f[0]:d;return h.ctx&&s(h.ctx[u],h.ctx[u]=p)&&(!h.skip_bound&&h.bound[u]&&h.bound[u](p),c&&ny(r,u)),d}):[],h.update(),c=!0,Qe(h.before_update),h.fragment=i?i(h.ctx):!1,t.target){if(t.hydrate){const u=Zg(t.target);h.fragment&&h.fragment.l(u),u.forEach(ct)}else h.fragment&&h.fragment.c();t.intro&&st(r.$$.fragment),Zt(r,t.target,t.anchor),Jh()}Zi(l)}class ae{constructor(){Fl(this,"$$");Fl(this,"$$set")}$destroy(){Jt(this,1),this.$destroy=Be}$on(t,e){if(!Kt(e))return Be;const i=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return i.push(e),()=>{const s=i.indexOf(e);s!==-1&&i.splice(s,1)}}$set(t){this.$$set&&!Yg(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const oy="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(oy);var Or=(r=>(r[r.WEBGL_LEGACY=0]="WEBGL_LEGACY",r[r.WEBGL=1]="WEBGL",r[r.WEBGL2=2]="WEBGL2",r))(Or||{}),Qh=(r=>(r[r.UNKNOWN=0]="UNKNOWN",r[r.WEBGL=1]="WEBGL",r[r.CANVAS=2]="CANVAS",r))(Qh||{}),Go=(r=>(r[r.COLOR=16384]="COLOR",r[r.DEPTH=256]="DEPTH",r[r.STENCIL=1024]="STENCIL",r))(Go||{}),tt=(r=>(r[r.NORMAL=0]="NORMAL",r[r.ADD=1]="ADD",r[r.MULTIPLY=2]="MULTIPLY",r[r.SCREEN=3]="SCREEN",r[r.OVERLAY=4]="OVERLAY",r[r.DARKEN=5]="DARKEN",r[r.LIGHTEN=6]="LIGHTEN",r[r.COLOR_DODGE=7]="COLOR_DODGE",r[r.COLOR_BURN=8]="COLOR_BURN",r[r.HARD_LIGHT=9]="HARD_LIGHT",r[r.SOFT_LIGHT=10]="SOFT_LIGHT",r[r.DIFFERENCE=11]="DIFFERENCE",r[r.EXCLUSION=12]="EXCLUSION",r[r.HUE=13]="HUE",r[r.SATURATION=14]="SATURATION",r[r.COLOR=15]="COLOR",r[r.LUMINOSITY=16]="LUMINOSITY",r[r.NORMAL_NPM=17]="NORMAL_NPM",r[r.ADD_NPM=18]="ADD_NPM",r[r.SCREEN_NPM=19]="SCREEN_NPM",r[r.NONE=20]="NONE",r[r.SRC_OVER=0]="SRC_OVER",r[r.SRC_IN=21]="SRC_IN",r[r.SRC_OUT=22]="SRC_OUT",r[r.SRC_ATOP=23]="SRC_ATOP",r[r.DST_OVER=24]="DST_OVER",r[r.DST_IN=25]="DST_IN",r[r.DST_OUT=26]="DST_OUT",r[r.DST_ATOP=27]="DST_ATOP",r[r.ERASE=26]="ERASE",r[r.SUBTRACT=28]="SUBTRACT",r[r.XOR=29]="XOR",r))(tt||{}),Fe=(r=>(r[r.POINTS=0]="POINTS",r[r.LINES=1]="LINES",r[r.LINE_LOOP=2]="LINE_LOOP",r[r.LINE_STRIP=3]="LINE_STRIP",r[r.TRIANGLES=4]="TRIANGLES",r[r.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",r[r.TRIANGLE_FAN=6]="TRIANGLE_FAN",r))(Fe||{}),k=(r=>(r[r.RGBA=6408]="RGBA",r[r.RGB=6407]="RGB",r[r.RG=33319]="RG",r[r.RED=6403]="RED",r[r.RGBA_INTEGER=36249]="RGBA_INTEGER",r[r.RGB_INTEGER=36248]="RGB_INTEGER",r[r.RG_INTEGER=33320]="RG_INTEGER",r[r.RED_INTEGER=36244]="RED_INTEGER",r[r.ALPHA=6406]="ALPHA",r[r.LUMINANCE=6409]="LUMINANCE",r[r.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",r[r.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",r[r.DEPTH_STENCIL=34041]="DEPTH_STENCIL",r))(k||{}),di=(r=>(r[r.TEXTURE_2D=3553]="TEXTURE_2D",r[r.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",r[r.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",r[r.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",r[r.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",r[r.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",r[r.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",r))(di||{}),J=(r=>(r[r.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",r[r.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",r[r.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",r[r.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",r[r.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",r[r.UNSIGNED_INT=5125]="UNSIGNED_INT",r[r.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",r[r.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",r[r.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",r[r.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",r[r.BYTE=5120]="BYTE",r[r.SHORT=5122]="SHORT",r[r.INT=5124]="INT",r[r.FLOAT=5126]="FLOAT",r[r.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",r[r.HALF_FLOAT=36193]="HALF_FLOAT",r))(J||{}),z=(r=>(r[r.FLOAT=0]="FLOAT",r[r.INT=1]="INT",r[r.UINT=2]="UINT",r))(z||{}),ir=(r=>(r[r.NEAREST=0]="NEAREST",r[r.LINEAR=1]="LINEAR",r))(ir||{}),mr=(r=>(r[r.CLAMP=33071]="CLAMP",r[r.REPEAT=10497]="REPEAT",r[r.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",r))(mr||{}),Le=(r=>(r[r.OFF=0]="OFF",r[r.POW2=1]="POW2",r[r.ON=2]="ON",r[r.ON_MANUAL=3]="ON_MANUAL",r))(Le||{}),ie=(r=>(r[r.NPM=0]="NPM",r[r.UNPACK=1]="UNPACK",r[r.PMA=2]="PMA",r[r.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",r[r.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",r[r.PREMULTIPLIED_ALPHA=2]="PREMULTIPLIED_ALPHA",r))(ie||{}),Ne=(r=>(r[r.NO=0]="NO",r[r.YES=1]="YES",r[r.AUTO=2]="AUTO",r[r.BLEND=0]="BLEND",r[r.CLEAR=1]="CLEAR",r[r.BLIT=2]="BLIT",r))(Ne||{}),$o=(r=>(r[r.AUTO=0]="AUTO",r[r.MANUAL=1]="MANUAL",r))($o||{}),fe=(r=>(r.LOW="lowp",r.MEDIUM="mediump",r.HIGH="highp",r))(fe||{}),Ft=(r=>(r[r.NONE=0]="NONE",r[r.SCISSOR=1]="SCISSOR",r[r.STENCIL=2]="STENCIL",r[r.SPRITE=3]="SPRITE",r[r.COLOR=4]="COLOR",r))(Ft||{}),Ot=(r=>(r[r.NONE=0]="NONE",r[r.LOW=2]="LOW",r[r.MEDIUM=4]="MEDIUM",r[r.HIGH=8]="HIGH",r))(Ot||{}),Ue=(r=>(r[r.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",r[r.ARRAY_BUFFER=34962]="ARRAY_BUFFER",r[r.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",r))(Ue||{});const W={ADAPTER:{createCanvas:(r,t)=>{const e=document.createElement("canvas");return e.width=r,e.height=t,e},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(r,t)=>fetch(r,t),parseXML:r=>new DOMParser().parseFromString(r,"text/xml")},RESOLUTION:1,CREATE_IMAGE_BITMAP:!1,ROUND_PIXELS:!1};var Ho=/iPhone/i,tc=/iPod/i,ec=/iPad/i,rc=/\biOS-universal(?:.+)Mac\b/i,Xo=/\bAndroid(?:.+)Mobile\b/i,ic=/Android/i,fi=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,Ys=/Silk/i,sr=/Windows Phone/i,sc=/\bWindows(?:.+)ARM\b/i,nc=/BlackBerry/i,oc=/BB10/i,ac=/Opera Mini/i,lc=/\b(CriOS|Chrome)(?:.+)Mobile/i,hc=/Mobile(?:.+)Firefox\b/i,cc=function(r){return typeof r<"u"&&r.platform==="MacIntel"&&typeof r.maxTouchPoints=="number"&&r.maxTouchPoints>1&&typeof MSStream>"u"};function ay(r){return function(t){return t.test(r)}}function uc(r){var t={userAgent:"",platform:"",maxTouchPoints:0};!r&&typeof navigator<"u"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof r=="string"?t.userAgent=r:r&&r.userAgent&&(t={userAgent:r.userAgent,platform:r.platform,maxTouchPoints:r.maxTouchPoints||0});var e=t.userAgent,i=e.split("[FBAN");typeof i[1]<"u"&&(e=i[0]),i=e.split("Twitter"),typeof i[1]<"u"&&(e=i[0]);var s=ay(e),n={apple:{phone:s(Ho)&&!s(sr),ipod:s(tc),tablet:!s(Ho)&&(s(ec)||cc(t))&&!s(sr),universal:s(rc),device:(s(Ho)||s(tc)||s(ec)||s(rc)||cc(t))&&!s(sr)},amazon:{phone:s(fi),tablet:!s(fi)&&s(Ys),device:s(fi)||s(Ys)},android:{phone:!s(sr)&&s(fi)||!s(sr)&&s(Xo),tablet:!s(sr)&&!s(fi)&&!s(Xo)&&(s(Ys)||s(ic)),device:!s(sr)&&(s(fi)||s(Ys)||s(Xo)||s(ic))||s(/\bokhttp\b/i)},windows:{phone:s(sr),tablet:s(sc),device:s(sr)||s(sc)},other:{blackberry:s(nc),blackberry10:s(oc),opera:s(ac),firefox:s(hc),chrome:s(lc),device:s(nc)||s(oc)||s(ac)||s(hc)||s(lc)},any:!1,phone:!1,tablet:!1};return n.any=n.apple.device||n.android.device||n.windows.device||n.other.device,n.phone=n.apple.phone||n.android.phone||n.windows.phone,n.tablet=n.apple.tablet||n.android.tablet||n.windows.tablet,n}const ly=uc.default??uc,nr=ly(globalThis.navigator);W.RETINA_PREFIX=/@([0-9\.]+)x/,W.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;var Ji=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function dc(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function hy(r){if(r.__esModule)return r;var t=r.default;if(typeof t=="function"){var e=function i(){return this instanceof i?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(r).forEach(function(i){var s=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:function(){return r[i]}})}),e}var fc={exports:{}};(function(r){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function s(l,h,c){this.fn=l,this.context=h,this.once=c||!1}function n(l,h,c,u,d){if(typeof c!="function")throw new TypeError("The listener must be a function");var f=new s(c,u||l,d),p=e?e+h:h;return l._events[p]?l._events[p].fn?l._events[p]=[l._events[p],f]:l._events[p].push(f):(l._events[p]=f,l._eventsCount++),l}function o(l,h){--l._eventsCount===0?l._events=new i:delete l._events[h]}function a(){this._events=new i,this._eventsCount=0}a.prototype.eventNames=function(){var h=[],c,u;if(this._eventsCount===0)return h;for(u in c=this._events)t.call(c,u)&&h.push(e?u.slice(1):u);return Object.getOwnPropertySymbols?h.concat(Object.getOwnPropertySymbols(c)):h},a.prototype.listeners=function(h){var c=e?e+h:h,u=this._events[c];if(!u)return[];if(u.fn)return[u.fn];for(var d=0,f=u.length,p=new Array(f);d<f;d++)p[d]=u[d].fn;return p},a.prototype.listenerCount=function(h){var c=e?e+h:h,u=this._events[c];return u?u.fn?1:u.length:0},a.prototype.emit=function(h,c,u,d,f,p){var m=e?e+h:h;if(!this._events[m])return!1;var _=this._events[m],y=arguments.length,x,g;if(_.fn){switch(_.once&&this.removeListener(h,_.fn,void 0,!0),y){case 1:return _.fn.call(_.context),!0;case 2:return _.fn.call(_.context,c),!0;case 3:return _.fn.call(_.context,c,u),!0;case 4:return _.fn.call(_.context,c,u,d),!0;case 5:return _.fn.call(_.context,c,u,d,f),!0;case 6:return _.fn.call(_.context,c,u,d,f,p),!0}for(g=1,x=new Array(y-1);g<y;g++)x[g-1]=arguments[g];_.fn.apply(_.context,x)}else{var v=_.length,w;for(g=0;g<v;g++)switch(_[g].once&&this.removeListener(h,_[g].fn,void 0,!0),y){case 1:_[g].fn.call(_[g].context);break;case 2:_[g].fn.call(_[g].context,c);break;case 3:_[g].fn.call(_[g].context,c,u);break;case 4:_[g].fn.call(_[g].context,c,u,d);break;default:if(!x)for(w=1,x=new Array(y-1);w<y;w++)x[w-1]=arguments[w];_[g].fn.apply(_[g].context,x)}}return!0},a.prototype.on=function(h,c,u){return n(this,h,c,u,!1)},a.prototype.once=function(h,c,u){return n(this,h,c,u,!0)},a.prototype.removeListener=function(h,c,u,d){var f=e?e+h:h;if(!this._events[f])return this;if(!c)return o(this,f),this;var p=this._events[f];if(p.fn)p.fn===c&&(!d||p.once)&&(!u||p.context===u)&&o(this,f);else{for(var m=0,_=[],y=p.length;m<y;m++)(p[m].fn!==c||d&&!p[m].once||u&&p[m].context!==u)&&_.push(p[m]);_.length?this._events[f]=_.length===1?_[0]:_:o(this,f)}return this},a.prototype.removeAllListeners=function(h){var c;return h?(c=e?e+h:h,this._events[c]&&o(this,c)):(this._events=new i,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=e,a.EventEmitter=a,r.exports=a})(fc);var cy=fc.exports;const Qi=dc(cy);var Vo={exports:{}};Vo.exports=qs,Vo.exports.default=qs;function qs(r,t,e){e=e||2;var i=t&&t.length,s=i?t[0]*e:r.length,n=pc(r,0,s,e,!0),o=[];if(!n||n.next===n.prev)return o;var a,l,h,c,u,d,f;if(i&&(n=my(r,t,n,e)),r.length>80*e){a=h=r[0],l=c=r[1];for(var p=e;p<s;p+=e)u=r[p],d=r[p+1],u<a&&(a=u),d<l&&(l=d),u>h&&(h=u),d>c&&(c=d);f=Math.max(h-a,c-l),f=f!==0?32767/f:0}return ts(n,o,e,a,l,f,0),o}function pc(r,t,e,i,s){var n,o;if(s===jo(r,t,e,i)>0)for(n=t;n<e;n+=i)o=yc(n,r[n],r[n+1],o);else for(n=e-i;n>=t;n-=i)o=yc(n,r[n],r[n+1],o);return o&&Ks(o,o.next)&&(rs(o),o=o.next),o}function Fr(r,t){if(!r)return r;t||(t=r);var e=r,i;do if(i=!1,!e.steiner&&(Ks(e,e.next)||It(e.prev,e,e.next)===0)){if(rs(e),e=t=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==t);return t}function ts(r,t,e,i,s,n,o){if(r){!o&&n&&xy(r,i,s,n);for(var a=r,l,h;r.prev!==r.next;){if(l=r.prev,h=r.next,n?dy(r,i,s,n):uy(r)){t.push(l.i/e|0),t.push(r.i/e|0),t.push(h.i/e|0),rs(r),r=h.next,a=h.next;continue}if(r=h,r===a){o?o===1?(r=fy(Fr(r),t,e),ts(r,t,e,i,s,n,2)):o===2&&py(r,t,e,i,s,n):ts(Fr(r),t,e,i,s,n,1);break}}}}function uy(r){var t=r.prev,e=r,i=r.next;if(It(t,e,i)>=0)return!1;for(var s=t.x,n=e.x,o=i.x,a=t.y,l=e.y,h=i.y,c=s<n?s<o?s:o:n<o?n:o,u=a<l?a<h?a:h:l<h?l:h,d=s>n?s>o?s:o:n>o?n:o,f=a>l?a>h?a:h:l>h?l:h,p=i.next;p!==t;){if(p.x>=c&&p.x<=d&&p.y>=u&&p.y<=f&&pi(s,a,n,l,o,h,p.x,p.y)&&It(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function dy(r,t,e,i){var s=r.prev,n=r,o=r.next;if(It(s,n,o)>=0)return!1;for(var a=s.x,l=n.x,h=o.x,c=s.y,u=n.y,d=o.y,f=a<l?a<h?a:h:l<h?l:h,p=c<u?c<d?c:d:u<d?u:d,m=a>l?a>h?a:h:l>h?l:h,_=c>u?c>d?c:d:u>d?u:d,y=zo(f,p,t,e,i),x=zo(m,_,t,e,i),g=r.prevZ,v=r.nextZ;g&&g.z>=y&&v&&v.z<=x;){if(g.x>=f&&g.x<=m&&g.y>=p&&g.y<=_&&g!==s&&g!==o&&pi(a,c,l,u,h,d,g.x,g.y)&&It(g.prev,g,g.next)>=0||(g=g.prevZ,v.x>=f&&v.x<=m&&v.y>=p&&v.y<=_&&v!==s&&v!==o&&pi(a,c,l,u,h,d,v.x,v.y)&&It(v.prev,v,v.next)>=0))return!1;v=v.nextZ}for(;g&&g.z>=y;){if(g.x>=f&&g.x<=m&&g.y>=p&&g.y<=_&&g!==s&&g!==o&&pi(a,c,l,u,h,d,g.x,g.y)&&It(g.prev,g,g.next)>=0)return!1;g=g.prevZ}for(;v&&v.z<=x;){if(v.x>=f&&v.x<=m&&v.y>=p&&v.y<=_&&v!==s&&v!==o&&pi(a,c,l,u,h,d,v.x,v.y)&&It(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function fy(r,t,e){var i=r;do{var s=i.prev,n=i.next.next;!Ks(s,n)&&mc(s,i,i.next,n)&&es(s,n)&&es(n,s)&&(t.push(s.i/e|0),t.push(i.i/e|0),t.push(n.i/e|0),rs(i),rs(i.next),i=r=n),i=i.next}while(i!==r);return Fr(i)}function py(r,t,e,i,s,n){var o=r;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&Ey(o,a)){var l=gc(o,a);o=Fr(o,o.next),l=Fr(l,l.next),ts(o,t,e,i,s,n,0),ts(l,t,e,i,s,n,0);return}a=a.next}o=o.next}while(o!==r)}function my(r,t,e,i){var s=[],n,o,a,l,h;for(n=0,o=t.length;n<o;n++)a=t[n]*i,l=n<o-1?t[n+1]*i:r.length,h=pc(r,a,l,i,!1),h===h.next&&(h.steiner=!0),s.push(wy(h));for(s.sort(gy),n=0;n<s.length;n++)e=yy(s[n],e);return e}function gy(r,t){return r.x-t.x}function yy(r,t){var e=_y(r,t);if(!e)return t;var i=gc(e,r);return Fr(i,i.next),Fr(e,e.next)}function _y(r,t){var e=t,i=r.x,s=r.y,n=-1/0,o;do{if(s<=e.y&&s>=e.next.y&&e.next.y!==e.y){var a=e.x+(s-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(a<=i&&a>n&&(n=a,o=e.x<e.next.x?e:e.next,a===i))return o}e=e.next}while(e!==t);if(!o)return null;var l=o,h=o.x,c=o.y,u=1/0,d;e=o;do i>=e.x&&e.x>=h&&i!==e.x&&pi(s<c?i:n,s,h,c,s<c?n:i,s,e.x,e.y)&&(d=Math.abs(s-e.y)/(i-e.x),es(e,r)&&(d<u||d===u&&(e.x>o.x||e.x===o.x&&vy(o,e)))&&(o=e,u=d)),e=e.next;while(e!==l);return o}function vy(r,t){return It(r.prev,r,t.prev)<0&&It(t.next,r,r.next)<0}function xy(r,t,e,i){var s=r;do s.z===0&&(s.z=zo(s.x,s.y,t,e,i)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==r);s.prevZ.nextZ=null,s.prevZ=null,by(s)}function by(r){var t,e,i,s,n,o,a,l,h=1;do{for(e=r,r=null,n=null,o=0;e;){for(o++,i=e,a=0,t=0;t<h&&(a++,i=i.nextZ,!!i);t++);for(l=h;a>0||l>0&&i;)a!==0&&(l===0||!i||e.z<=i.z)?(s=e,e=e.nextZ,a--):(s=i,i=i.nextZ,l--),n?n.nextZ=s:r=s,s.prevZ=n,n=s;e=i}n.nextZ=null,h*=2}while(o>1);return r}function zo(r,t,e,i,s){return r=(r-e)*s|0,t=(t-i)*s|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,r|t<<1}function wy(r){var t=r,e=r;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==r);return e}function pi(r,t,e,i,s,n,o,a){return(s-o)*(t-a)>=(r-o)*(n-a)&&(r-o)*(i-a)>=(e-o)*(t-a)&&(e-o)*(n-a)>=(s-o)*(i-a)}function Ey(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!Ty(r,t)&&(es(r,t)&&es(t,r)&&Ay(r,t)&&(It(r.prev,r,t.prev)||It(r,t.prev,t))||Ks(r,t)&&It(r.prev,r,r.next)>0&&It(t.prev,t,t.next)>0)}function It(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function Ks(r,t){return r.x===t.x&&r.y===t.y}function mc(r,t,e,i){var s=Js(It(r,t,e)),n=Js(It(r,t,i)),o=Js(It(e,i,r)),a=Js(It(e,i,t));return!!(s!==n&&o!==a||s===0&&Zs(r,e,t)||n===0&&Zs(r,i,t)||o===0&&Zs(e,r,i)||a===0&&Zs(e,t,i))}function Zs(r,t,e){return t.x<=Math.max(r.x,e.x)&&t.x>=Math.min(r.x,e.x)&&t.y<=Math.max(r.y,e.y)&&t.y>=Math.min(r.y,e.y)}function Js(r){return r>0?1:r<0?-1:0}function Ty(r,t){var e=r;do{if(e.i!==r.i&&e.next.i!==r.i&&e.i!==t.i&&e.next.i!==t.i&&mc(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function es(r,t){return It(r.prev,r,r.next)<0?It(r,t,r.next)>=0&&It(r,r.prev,t)>=0:It(r,t,r.prev)<0||It(r,r.next,t)<0}function Ay(r,t){var e=r,i=!1,s=(r.x+t.x)/2,n=(r.y+t.y)/2;do e.y>n!=e.next.y>n&&e.next.y!==e.y&&s<(e.next.x-e.x)*(n-e.y)/(e.next.y-e.y)+e.x&&(i=!i),e=e.next;while(e!==r);return i}function gc(r,t){var e=new Wo(r.i,r.x,r.y),i=new Wo(t.i,t.x,t.y),s=r.next,n=t.prev;return r.next=t,t.prev=r,e.next=s,s.prev=e,i.next=e,e.prev=i,n.next=i,i.prev=n,i}function yc(r,t,e,i){var s=new Wo(r,t,e);return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function rs(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function Wo(r,t,e){this.i=r,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}qs.deviation=function(r,t,e,i){var s=t&&t.length,n=s?t[0]*e:r.length,o=Math.abs(jo(r,0,n,e));if(s)for(var a=0,l=t.length;a<l;a++){var h=t[a]*e,c=a<l-1?t[a+1]*e:r.length;o-=Math.abs(jo(r,h,c,e))}var u=0;for(a=0;a<i.length;a+=3){var d=i[a]*e,f=i[a+1]*e,p=i[a+2]*e;u+=Math.abs((r[d]-r[p])*(r[f+1]-r[d+1])-(r[d]-r[f])*(r[p+1]-r[d+1]))}return o===0&&u===0?0:Math.abs((u-o)/o)};function jo(r,t,e,i){for(var s=0,n=t,o=e-i;n<e;n+=i)s+=(r[o]-r[n])*(r[n+1]+r[o+1]),o=n;return s}qs.flatten=function(r){for(var t=r[0][0].length,e={vertices:[],holes:[],dimensions:t},i=0,s=0;s<r.length;s++){for(var n=0;n<r[s].length;n++)for(var o=0;o<t;o++)e.vertices.push(r[s][n][o]);s>0&&(i+=r[s-1].length,e.holes.push(i))}return e};var Sy=Vo.exports;const Iy=dc(Sy);var Qs={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */Qs.exports,function(r,t){(function(e){var i=t&&!t.nodeType&&t,s=r&&!r.nodeType&&r,n=typeof Ji=="object"&&Ji;(n.global===n||n.window===n||n.self===n)&&(e=n);var o,a=2147483647,l=36,h=1,c=26,u=38,d=700,f=72,p=128,m="-",_=/^xn--/,y=/[^\x20-\x7E]/,x=/[\x2E\u3002\uFF0E\uFF61]/g,g={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},v=l-h,w=Math.floor,I=String.fromCharCode,A;function C(P){throw new RangeError(g[P])}function N(P,U){for(var j=P.length,rt=[];j--;)rt[j]=U(P[j]);return rt}function S(P,U){var j=P.split("@"),rt="";j.length>1&&(rt=j[0]+"@",P=j[1]),P=P.replace(x,".");var Q=P.split("."),H=N(Q,U).join(".");return rt+H}function R(P){for(var U=[],j=0,rt=P.length,Q,H;j<rt;)Q=P.charCodeAt(j++),Q>=55296&&Q<=56319&&j<rt?(H=P.charCodeAt(j++),(H&64512)==56320?U.push(((Q&1023)<<10)+(H&1023)+65536):(U.push(Q),j--)):U.push(Q);return U}function E(P){return N(P,function(U){var j="";return U>65535&&(U-=65536,j+=I(U>>>10&1023|55296),U=56320|U&1023),j+=I(U),j}).join("")}function b(P){return P-48<10?P-22:P-65<26?P-65:P-97<26?P-97:l}function D(P,U){return P+22+75*(P<26)-((U!=0)<<5)}function F(P,U,j){var rt=0;for(P=j?w(P/d):P>>1,P+=w(P/U);P>v*c>>1;rt+=l)P=w(P/v);return w(rt+(v+1)*P/(P+u))}function G(P){var U=[],j=P.length,rt,Q=0,H=p,V=f,lt,L,O,_t,ht,vt,xt,Ye,qe;for(lt=P.lastIndexOf(m),lt<0&&(lt=0),L=0;L<lt;++L)P.charCodeAt(L)>=128&&C("not-basic"),U.push(P.charCodeAt(L));for(O=lt>0?lt+1:0;O<j;){for(_t=Q,ht=1,vt=l;O>=j&&C("invalid-input"),xt=b(P.charCodeAt(O++)),(xt>=l||xt>w((a-Q)/ht))&&C("overflow"),Q+=xt*ht,Ye=vt<=V?h:vt>=V+c?c:vt-V,!(xt<Ye);vt+=l)qe=l-Ye,ht>w(a/qe)&&C("overflow"),ht*=qe;rt=U.length+1,V=F(Q-_t,rt,_t==0),w(Q/rt)>a-H&&C("overflow"),H+=w(Q/rt),Q%=rt,U.splice(Q++,0,H)}return E(U)}function $(P){var U,j,rt,Q,H,V,lt,L,O,_t,ht,vt=[],xt,Ye,qe,ws;for(P=R(P),xt=P.length,U=p,j=0,H=f,V=0;V<xt;++V)ht=P[V],ht<128&&vt.push(I(ht));for(rt=Q=vt.length,Q&&vt.push(m);rt<xt;){for(lt=a,V=0;V<xt;++V)ht=P[V],ht>=U&&ht<lt&&(lt=ht);for(Ye=rt+1,lt-U>w((a-j)/Ye)&&C("overflow"),j+=(lt-U)*Ye,U=lt,V=0;V<xt;++V)if(ht=P[V],ht<U&&++j>a&&C("overflow"),ht==U){for(L=j,O=l;_t=O<=H?h:O>=H+c?c:O-H,!(L<_t);O+=l)ws=L-_t,qe=l-_t,vt.push(I(D(_t+ws%qe,0))),L=w(ws/qe);vt.push(I(D(L,0))),H=F(j,Ye,rt==Q),j=0,++rt}++j,++U}return vt.join("")}function B(P){return S(P,function(U){return _.test(U)?G(U.slice(4).toLowerCase()):U})}function Z(P){return S(P,function(U){return y.test(U)?"xn--"+$(U):U})}if(o={version:"1.4.1",ucs2:{decode:R,encode:E},decode:G,encode:$,toASCII:Z,toUnicode:B},i&&s)if(r.exports==i)s.exports=o;else for(A in o)o.hasOwnProperty(A)&&(i[A]=o[A]);else e.punycode=o})(Ji)}(Qs,Qs.exports);var Cy=Qs.exports,Ry=Error,Py=EvalError,My=RangeError,By=ReferenceError,_c=SyntaxError,is=TypeError,Dy=URIError,Oy=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var t={},e=Symbol("test"),i=Object(e);if(typeof e=="string"||Object.prototype.toString.call(e)!=="[object Symbol]"||Object.prototype.toString.call(i)!=="[object Symbol]")return!1;var s=42;t[e]=s;for(e in t)return!1;if(typeof Object.keys=="function"&&Object.keys(t).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(t).length!==0)return!1;var n=Object.getOwnPropertySymbols(t);if(n.length!==1||n[0]!==e||!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var o=Object.getOwnPropertyDescriptor(t,e);if(o.value!==s||o.enumerable!==!0)return!1}return!0},vc=typeof Symbol<"u"&&Symbol,Fy=Oy,Ly=function(){return typeof vc!="function"||typeof Symbol!="function"||typeof vc("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:Fy()},Yo={__proto__:null,foo:{}},Ny=Object,Uy=function(){return{__proto__:Yo}.foo===Yo.foo&&!(Yo instanceof Ny)},ky="Function.prototype.bind called on incompatible ",Gy=Object.prototype.toString,$y=Math.max,Hy="[object Function]",xc=function(t,e){for(var i=[],s=0;s<t.length;s+=1)i[s]=t[s];for(var n=0;n<e.length;n+=1)i[n+t.length]=e[n];return i},Xy=function(t,e){for(var i=[],s=e,n=0;s<t.length;s+=1,n+=1)i[n]=t[s];return i},Vy=function(r,t){for(var e="",i=0;i<r.length;i+=1)e+=r[i],i+1<r.length&&(e+=t);return e},zy=function(t){var e=this;if(typeof e!="function"||Gy.apply(e)!==Hy)throw new TypeError(ky+e);for(var i=Xy(arguments,1),s,n=function(){if(this instanceof s){var c=e.apply(this,xc(i,arguments));return Object(c)===c?c:this}return e.apply(t,xc(i,arguments))},o=$y(0,e.length-i.length),a=[],l=0;l<o;l++)a[l]="$"+l;if(s=Function("binder","return function ("+Vy(a,",")+"){ return binder.apply(this,arguments); }")(n),e.prototype){var h=function(){};h.prototype=e.prototype,s.prototype=new h,h.prototype=null}return s},Wy=zy,qo=Function.prototype.bind||Wy,jy=Function.prototype.call,Yy=Object.prototype.hasOwnProperty,qy=qo,Ky=qy.call(jy,Yy),pt,Zy=Ry,Jy=Py,Qy=My,t0=By,mi=_c,gi=is,e0=Dy,bc=Function,Ko=function(r){try{return bc('"use strict"; return ('+r+").constructor;")()}catch{}},Lr=Object.getOwnPropertyDescriptor;if(Lr)try{Lr({},"")}catch{Lr=null}var Zo=function(){throw new gi},r0=Lr?function(){try{return arguments.callee,Zo}catch{try{return Lr(arguments,"callee").get}catch{return Zo}}}():Zo,yi=Ly(),i0=Uy(),kt=Object.getPrototypeOf||(i0?function(r){return r.__proto__}:null),_i={},s0=typeof Uint8Array>"u"||!kt?pt:kt(Uint8Array),Nr={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?pt:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?pt:ArrayBuffer,"%ArrayIteratorPrototype%":yi&&kt?kt([][Symbol.iterator]()):pt,"%AsyncFromSyncIteratorPrototype%":pt,"%AsyncFunction%":_i,"%AsyncGenerator%":_i,"%AsyncGeneratorFunction%":_i,"%AsyncIteratorPrototype%":_i,"%Atomics%":typeof Atomics>"u"?pt:Atomics,"%BigInt%":typeof BigInt>"u"?pt:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?pt:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?pt:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?pt:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Zy,"%eval%":eval,"%EvalError%":Jy,"%Float32Array%":typeof Float32Array>"u"?pt:Float32Array,"%Float64Array%":typeof Float64Array>"u"?pt:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?pt:FinalizationRegistry,"%Function%":bc,"%GeneratorFunction%":_i,"%Int8Array%":typeof Int8Array>"u"?pt:Int8Array,"%Int16Array%":typeof Int16Array>"u"?pt:Int16Array,"%Int32Array%":typeof Int32Array>"u"?pt:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":yi&&kt?kt(kt([][Symbol.iterator]())):pt,"%JSON%":typeof JSON=="object"?JSON:pt,"%Map%":typeof Map>"u"?pt:Map,"%MapIteratorPrototype%":typeof Map>"u"||!yi||!kt?pt:kt(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?pt:Promise,"%Proxy%":typeof Proxy>"u"?pt:Proxy,"%RangeError%":Qy,"%ReferenceError%":t0,"%Reflect%":typeof Reflect>"u"?pt:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?pt:Set,"%SetIteratorPrototype%":typeof Set>"u"||!yi||!kt?pt:kt(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?pt:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":yi&&kt?kt(""[Symbol.iterator]()):pt,"%Symbol%":yi?Symbol:pt,"%SyntaxError%":mi,"%ThrowTypeError%":r0,"%TypedArray%":s0,"%TypeError%":gi,"%Uint8Array%":typeof Uint8Array>"u"?pt:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?pt:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?pt:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?pt:Uint32Array,"%URIError%":e0,"%WeakMap%":typeof WeakMap>"u"?pt:WeakMap,"%WeakRef%":typeof WeakRef>"u"?pt:WeakRef,"%WeakSet%":typeof WeakSet>"u"?pt:WeakSet};if(kt)try{null.error}catch(r){var n0=kt(kt(r));Nr["%Error.prototype%"]=n0}var o0=function r(t){var e;if(t==="%AsyncFunction%")e=Ko("async function () {}");else if(t==="%GeneratorFunction%")e=Ko("function* () {}");else if(t==="%AsyncGeneratorFunction%")e=Ko("async function* () {}");else if(t==="%AsyncGenerator%"){var i=r("%AsyncGeneratorFunction%");i&&(e=i.prototype)}else if(t==="%AsyncIteratorPrototype%"){var s=r("%AsyncGenerator%");s&&kt&&(e=kt(s.prototype))}return Nr[t]=e,e},wc={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},ss=qo,tn=Ky,a0=ss.call(Function.call,Array.prototype.concat),l0=ss.call(Function.apply,Array.prototype.splice),Ec=ss.call(Function.call,String.prototype.replace),en=ss.call(Function.call,String.prototype.slice),h0=ss.call(Function.call,RegExp.prototype.exec),c0=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,u0=/\\(\\)?/g,d0=function(t){var e=en(t,0,1),i=en(t,-1);if(e==="%"&&i!=="%")throw new mi("invalid intrinsic syntax, expected closing `%`");if(i==="%"&&e!=="%")throw new mi("invalid intrinsic syntax, expected opening `%`");var s=[];return Ec(t,c0,function(n,o,a,l){s[s.length]=a?Ec(l,u0,"$1"):o||n}),s},f0=function(t,e){var i=t,s;if(tn(wc,i)&&(s=wc[i],i="%"+s[0]+"%"),tn(Nr,i)){var n=Nr[i];if(n===_i&&(n=o0(i)),typeof n>"u"&&!e)throw new gi("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:s,name:i,value:n}}throw new mi("intrinsic "+t+" does not exist!")},vi=function(t,e){if(typeof t!="string"||t.length===0)throw new gi("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof e!="boolean")throw new gi('"allowMissing" argument must be a boolean');if(h0(/^%?[^%]*%?$/,t)===null)throw new mi("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var i=d0(t),s=i.length>0?i[0]:"",n=f0("%"+s+"%",e),o=n.name,a=n.value,l=!1,h=n.alias;h&&(s=h[0],l0(i,a0([0,1],h)));for(var c=1,u=!0;c<i.length;c+=1){var d=i[c],f=en(d,0,1),p=en(d,-1);if((f==='"'||f==="'"||f==="`"||p==='"'||p==="'"||p==="`")&&f!==p)throw new mi("property names with quotes must have matching quotes");if((d==="constructor"||!u)&&(l=!0),s+="."+d,o="%"+s+"%",tn(Nr,o))a=Nr[o];else if(a!=null){if(!(d in a)){if(!e)throw new gi("base intrinsic for "+t+" exists, but the property is not available.");return}if(Lr&&c+1>=i.length){var m=Lr(a,d);u=!!m,u&&"get"in m&&!("originalValue"in m.get)?a=m.get:a=a[d]}else u=tn(a,d),a=a[d];u&&!l&&(Nr[o]=a)}}return a},Tc={exports:{}},Jo,Ac;function Qo(){if(Ac)return Jo;Ac=1;var r=vi,t=r("%Object.defineProperty%",!0)||!1;if(t)try{t({},"a",{value:1})}catch{t=!1}return Jo=t,Jo}var p0=vi,rn=p0("%Object.getOwnPropertyDescriptor%",!0);if(rn)try{rn([],"length")}catch{rn=null}var Sc=rn,Ic=Qo(),m0=_c,xi=is,Cc=Sc,g0=function(t,e,i){if(!t||typeof t!="object"&&typeof t!="function")throw new xi("`obj` must be an object or a function`");if(typeof e!="string"&&typeof e!="symbol")throw new xi("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new xi("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new xi("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new xi("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new xi("`loose`, if provided, must be a boolean");var s=arguments.length>3?arguments[3]:null,n=arguments.length>4?arguments[4]:null,o=arguments.length>5?arguments[5]:null,a=arguments.length>6?arguments[6]:!1,l=!!Cc&&Cc(t,e);if(Ic)Ic(t,e,{configurable:o===null&&l?l.configurable:!o,enumerable:s===null&&l?l.enumerable:!s,value:i,writable:n===null&&l?l.writable:!n});else if(a||!s&&!n&&!o)t[e]=i;else throw new m0("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},ta=Qo(),Rc=function(){return!!ta};Rc.hasArrayLengthDefineBug=function(){if(!ta)return null;try{return ta([],"length",{value:1}).length!==1}catch{return!0}};var y0=Rc,_0=vi,Pc=g0,v0=y0(),Mc=Sc,Bc=is,x0=_0("%Math.floor%"),b0=function(t,e){if(typeof t!="function")throw new Bc("`fn` is not a function");if(typeof e!="number"||e<0||e>4294967295||x0(e)!==e)throw new Bc("`length` must be a positive 32-bit integer");var i=arguments.length>2&&!!arguments[2],s=!0,n=!0;if("length"in t&&Mc){var o=Mc(t,"length");o&&!o.configurable&&(s=!1),o&&!o.writable&&(n=!1)}return(s||n||!i)&&(v0?Pc(t,"length",e,!0,!0):Pc(t,"length",e)),t};(function(r){var t=qo,e=vi,i=b0,s=is,n=e("%Function.prototype.apply%"),o=e("%Function.prototype.call%"),a=e("%Reflect.apply%",!0)||t.call(o,n),l=Qo(),h=e("%Math.max%");r.exports=function(d){if(typeof d!="function")throw new s("a function is required");var f=a(t,o,arguments);return i(f,1+h(0,d.length-(arguments.length-1)),!0)};var c=function(){return a(t,n,arguments)};l?l(r.exports,"apply",{value:c}):r.exports.apply=c})(Tc);var w0=Tc.exports,Dc=vi,Oc=w0,E0=Oc(Dc("String.prototype.indexOf")),T0=function(t,e){var i=Dc(t,!!e);return typeof i=="function"&&E0(t,".prototype.")>-1?Oc(i):i};const A0=hy(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var ea=typeof Map=="function"&&Map.prototype,ra=Object.getOwnPropertyDescriptor&&ea?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,sn=ea&&ra&&typeof ra.get=="function"?ra.get:null,Fc=ea&&Map.prototype.forEach,ia=typeof Set=="function"&&Set.prototype,sa=Object.getOwnPropertyDescriptor&&ia?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,nn=ia&&sa&&typeof sa.get=="function"?sa.get:null,Lc=ia&&Set.prototype.forEach,S0=typeof WeakMap=="function"&&WeakMap.prototype,ns=S0?WeakMap.prototype.has:null,I0=typeof WeakSet=="function"&&WeakSet.prototype,os=I0?WeakSet.prototype.has:null,C0=typeof WeakRef=="function"&&WeakRef.prototype,Nc=C0?WeakRef.prototype.deref:null,R0=Boolean.prototype.valueOf,P0=Object.prototype.toString,M0=Function.prototype.toString,B0=String.prototype.match,na=String.prototype.slice,gr=String.prototype.replace,D0=String.prototype.toUpperCase,Uc=String.prototype.toLowerCase,kc=RegExp.prototype.test,Gc=Array.prototype.concat,ke=Array.prototype.join,O0=Array.prototype.slice,$c=Math.floor,oa=typeof BigInt=="function"?BigInt.prototype.valueOf:null,aa=Object.getOwnPropertySymbols,la=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,bi=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Qt=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===bi||!0)?Symbol.toStringTag:null,Hc=Object.prototype.propertyIsEnumerable,Xc=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(r){return r.__proto__}:null);function Vc(r,t){if(r===1/0||r===-1/0||r!==r||r&&r>-1e3&&r<1e3||kc.call(/e/,t))return t;var e=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof r=="number"){var i=r<0?-$c(-r):$c(r);if(i!==r){var s=String(i),n=na.call(t,s.length+1);return gr.call(s,e,"$&_")+"."+gr.call(gr.call(n,/([0-9]{3})/g,"$&_"),/_$/,"")}}return gr.call(t,e,"$&_")}var ha=A0,zc=ha.custom,Wc=qc(zc)?zc:null,F0=function r(t,e,i,s){var n=e||{};if(yr(n,"quoteStyle")&&n.quoteStyle!=="single"&&n.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(yr(n,"maxStringLength")&&(typeof n.maxStringLength=="number"?n.maxStringLength<0&&n.maxStringLength!==1/0:n.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var o=yr(n,"customInspect")?n.customInspect:!0;if(typeof o!="boolean"&&o!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(yr(n,"indent")&&n.indent!==null&&n.indent!==" "&&!(parseInt(n.indent,10)===n.indent&&n.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(yr(n,"numericSeparator")&&typeof n.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var a=n.numericSeparator;if(typeof t>"u")return"undefined";if(t===null)return"null";if(typeof t=="boolean")return t?"true":"false";if(typeof t=="string")return Zc(t,n);if(typeof t=="number"){if(t===0)return 1/0/t>0?"0":"-0";var l=String(t);return a?Vc(t,l):l}if(typeof t=="bigint"){var h=String(t)+"n";return a?Vc(t,h):h}var c=typeof n.depth>"u"?5:n.depth;if(typeof i>"u"&&(i=0),i>=c&&c>0&&typeof t=="object")return ca(t)?"[Array]":"[Object]";var u=Q0(n,i);if(typeof s>"u")s=[];else if(Kc(s,t)>=0)return"[Circular]";function d(b,D,F){if(D&&(s=O0.call(s),s.push(D)),F){var G={depth:n.depth};return yr(n,"quoteStyle")&&(G.quoteStyle=n.quoteStyle),r(b,G,i+1,s)}return r(b,n,i+1,s)}if(typeof t=="function"&&!Yc(t)){var f=V0(t),p=on(t,d);return"[Function"+(f?": "+f:" (anonymous)")+"]"+(p.length>0?" { "+ke.call(p,", ")+" }":"")}if(qc(t)){var m=bi?gr.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):la.call(t);return typeof t=="object"&&!bi?as(m):m}if(K0(t)){for(var _="<"+Uc.call(String(t.nodeName)),y=t.attributes||[],x=0;x<y.length;x++)_+=" "+y[x].name+"="+jc(L0(y[x].value),"double",n);return _+=">",t.childNodes&&t.childNodes.length&&(_+="..."),_+="</"+Uc.call(String(t.nodeName))+">",_}if(ca(t)){if(t.length===0)return"[]";var g=on(t,d);return u&&!J0(g)?"["+da(g,u)+"]":"[ "+ke.call(g,", ")+" ]"}if(U0(t)){var v=on(t,d);return!("cause"in Error.prototype)&&"cause"in t&&!Hc.call(t,"cause")?"{ ["+String(t)+"] "+ke.call(Gc.call("[cause]: "+d(t.cause),v),", ")+" }":v.length===0?"["+String(t)+"]":"{ ["+String(t)+"] "+ke.call(v,", ")+" }"}if(typeof t=="object"&&o){if(Wc&&typeof t[Wc]=="function"&&ha)return ha(t,{depth:c-i});if(o!=="symbol"&&typeof t.inspect=="function")return t.inspect()}if(z0(t)){var w=[];return Fc&&Fc.call(t,function(b,D){w.push(d(D,t,!0)+" => "+d(b,t))}),Jc("Map",sn.call(t),w,u)}if(Y0(t)){var I=[];return Lc&&Lc.call(t,function(b){I.push(d(b,t))}),Jc("Set",nn.call(t),I,u)}if(W0(t))return ua("WeakMap");if(q0(t))return ua("WeakSet");if(j0(t))return ua("WeakRef");if(G0(t))return as(d(Number(t)));if(H0(t))return as(d(oa.call(t)));if($0(t))return as(R0.call(t));if(k0(t))return as(d(String(t)));if(typeof window<"u"&&t===window)return"{ [object Window] }";if(typeof globalThis<"u"&&t===globalThis||typeof Ji<"u"&&t===Ji)return"{ [object globalThis] }";if(!N0(t)&&!Yc(t)){var A=on(t,d),C=Xc?Xc(t)===Object.prototype:t instanceof Object||t.constructor===Object,N=t instanceof Object?"":"null prototype",S=!C&&Qt&&Object(t)===t&&Qt in t?na.call(_r(t),8,-1):N?"Object":"",R=C||typeof t.constructor!="function"?"":t.constructor.name?t.constructor.name+" ":"",E=R+(S||N?"["+ke.call(Gc.call([],S||[],N||[]),": ")+"] ":"");return A.length===0?E+"{}":u?E+"{"+da(A,u)+"}":E+"{ "+ke.call(A,", ")+" }"}return String(t)};function jc(r,t,e){var i=(e.quoteStyle||t)==="double"?'"':"'";return i+r+i}function L0(r){return gr.call(String(r),/"/g,""")}function ca(r){return _r(r)==="[object Array]"&&(!Qt||!(typeof r=="object"&&Qt in r))}function N0(r){return _r(r)==="[object Date]"&&(!Qt||!(typeof r=="object"&&Qt in r))}function Yc(r){return _r(r)==="[object RegExp]"&&(!Qt||!(typeof r=="object"&&Qt in r))}function U0(r){return _r(r)==="[object Error]"&&(!Qt||!(typeof r=="object"&&Qt in r))}function k0(r){return _r(r)==="[object String]"&&(!Qt||!(typeof r=="object"&&Qt in r))}function G0(r){return _r(r)==="[object Number]"&&(!Qt||!(typeof r=="object"&&Qt in r))}function $0(r){return _r(r)==="[object Boolean]"&&(!Qt||!(typeof r=="object"&&Qt in r))}function qc(r){if(bi)return r&&typeof r=="object"&&r instanceof Symbol;if(typeof r=="symbol")return!0;if(!r||typeof r!="object"||!la)return!1;try{return la.call(r),!0}catch{}return!1}function H0(r){if(!r||typeof r!="object"||!oa)return!1;try{return oa.call(r),!0}catch{}return!1}var X0=Object.prototype.hasOwnProperty||function(r){return r in this};function yr(r,t){return X0.call(r,t)}function _r(r){return P0.call(r)}function V0(r){if(r.name)return r.name;var t=B0.call(M0.call(r),/^function\s*([\w$]+)/);return t?t[1]:null}function Kc(r,t){if(r.indexOf)return r.indexOf(t);for(var e=0,i=r.length;e<i;e++)if(r[e]===t)return e;return-1}function z0(r){if(!sn||!r||typeof r!="object")return!1;try{sn.call(r);try{nn.call(r)}catch{return!0}return r instanceof Map}catch{}return!1}function W0(r){if(!ns||!r||typeof r!="object")return!1;try{ns.call(r,ns);try{os.call(r,os)}catch{return!0}return r instanceof WeakMap}catch{}return!1}function j0(r){if(!Nc||!r||typeof r!="object")return!1;try{return Nc.call(r),!0}catch{}return!1}function Y0(r){if(!nn||!r||typeof r!="object")return!1;try{nn.call(r);try{sn.call(r)}catch{return!0}return r instanceof Set}catch{}return!1}function q0(r){if(!os||!r||typeof r!="object")return!1;try{os.call(r,os);try{ns.call(r,ns)}catch{return!0}return r instanceof WeakSet}catch{}return!1}function K0(r){return!r||typeof r!="object"?!1:typeof HTMLElement<"u"&&r instanceof HTMLElement?!0:typeof r.nodeName=="string"&&typeof r.getAttribute=="function"}function Zc(r,t){if(r.length>t.maxStringLength){var e=r.length-t.maxStringLength,i="... "+e+" more character"+(e>1?"s":"");return Zc(na.call(r,0,t.maxStringLength),t)+i}var s=gr.call(gr.call(r,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,Z0);return jc(s,"single",t)}function Z0(r){var t=r.charCodeAt(0),e={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return e?"\\"+e:"\\x"+(t<16?"0":"")+D0.call(t.toString(16))}function as(r){return"Object("+r+")"}function ua(r){return r+" { ? }"}function Jc(r,t,e,i){var s=i?da(e,i):ke.call(e,", ");return r+" ("+t+") {"+s+"}"}function J0(r){for(var t=0;t<r.length;t++)if(Kc(r[t],`
|
|
1
|
+
(function(Mt,Nt){typeof exports=="object"&&typeof module<"u"?Nt(exports,require("openseadragon")):typeof define=="function"&&define.amd?define(["exports","openseadragon"],Nt):(Mt=typeof globalThis<"u"?globalThis:Mt||self,Nt(Mt.AnnotoriousOSD={},Mt.OpenSeadragon))})(this,function(Mt,Nt){"use strict";var HE=Object.defineProperty;var XE=(Mt,Nt,Pr)=>Nt in Mt?HE(Mt,Nt,{enumerable:!0,configurable:!0,writable:!0,value:Pr}):Mt[Nt]=Pr;var Fl=(Mt,Nt,Pr)=>XE(Mt,typeof Nt!="symbol"?Nt+"":Nt,Pr);var Pr=Object.prototype.hasOwnProperty;function Mr(r,t){var e,i;if(r===t)return!0;if(r&&t&&(e=r.constructor)===t.constructor){if(e===Date)return r.getTime()===t.getTime();if(e===RegExp)return r.toString()===t.toString();if(e===Array){if((i=r.length)===t.length)for(;i--&&Mr(r[i],t[i]););return i===-1}if(!e||typeof r=="object"){i=0;for(e in r)if(Pr.call(r,e)&&++i&&!Pr.call(t,e)||!(e in t)||!Mr(r[e],t[e]))return!1;return Object.keys(t).length===i}}return r!==r&&t!==t}for(var ao=(r=>(r.EDIT="EDIT",r.SELECT="SELECT",r.NONE="NONE",r))(ao||{}),Ht=[],lo=0;lo<256;++lo)Ht.push((lo+256).toString(16).slice(1));function Jf(r,t=0){return(Ht[r[t+0]]+Ht[r[t+1]]+Ht[r[t+2]]+Ht[r[t+3]]+"-"+Ht[r[t+4]]+Ht[r[t+5]]+"-"+Ht[r[t+6]]+Ht[r[t+7]]+"-"+Ht[r[t+8]]+Ht[r[t+9]]+"-"+Ht[r[t+10]]+Ht[r[t+11]]+Ht[r[t+12]]+Ht[r[t+13]]+Ht[r[t+14]]+Ht[r[t+15]]).toLowerCase()}var Cs,Qf=new Uint8Array(16);function tp(){if(!Cs&&(Cs=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Cs))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Cs(Qf)}var ep=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const Xl={randomUUID:ep};function rp(r,t,e){if(Xl.randomUUID&&!t&&!r)return Xl.randomUUID();r=r||{};var i=r.random||(r.rng||tp)();return i[6]=i[6]&15|64,i[8]=i[8]&63|128,Jf(i)}const ho=r=>{const t=e=>{const i={...e};return e.created&&typeof e.created=="string"&&(i.created=new Date(e.created)),e.updated&&typeof e.updated=="string"&&(i.updated=new Date(e.updated)),i};return{...r,bodies:(r.bodies||[]).map(t),target:t(r.target)}},ip=(r,t,e,i)=>({id:rp(),annotation:typeof r=="string"?r:r.id,created:e||new Date,creator:i,...t}),sp=(r,t)=>{const e=new Set(r.bodies.map(i=>i.id));return t.bodies.filter(i=>!e.has(i.id))},np=(r,t)=>{const e=new Set(t.bodies.map(i=>i.id));return r.bodies.filter(i=>!e.has(i.id))},op=(r,t)=>t.bodies.map(e=>{const i=r.bodies.find(s=>s.id===e.id);return{newBody:e,oldBody:i&&!Mr(i,e)?i:void 0}}).filter(({oldBody:e})=>e).map(({oldBody:e,newBody:i})=>({oldBody:e,newBody:i})),ap=(r,t)=>!Mr(r.target,t.target),lp=(r,t)=>{const e=sp(r,t),i=np(r,t),s=op(r,t);return{oldValue:r,newValue:t,bodiesCreated:e.length>0?e:void 0,bodiesDeleted:i.length>0?i:void 0,bodiesUpdated:s.length>0?s:void 0,targetUpdated:ap(r,t)?{oldTarget:r.target,newTarget:t.target}:void 0}};var dr=(r=>(r.LOCAL="LOCAL",r.REMOTE="REMOTE",r.SILENT="SILENT",r))(dr||{});const hp=(r,t)=>{const e=new Set((r.created||[]).map(u=>u.id)),i=new Set((r.updated||[]).map(({newValue:u})=>u.id)),s=new Set((t.created||[]).map(u=>u.id)),n=new Set((t.deleted||[]).map(u=>u.id)),o=new Set((t.updated||[]).map(({oldValue:u})=>u.id)),a=new Set((t.updated||[]).filter(({oldValue:u})=>e.has(u.id)||i.has(u.id)).map(({oldValue:u})=>u.id)),l=[...(r.created||[]).filter(u=>!n.has(u.id)).map(u=>o.has(u.id)?t.updated.find(({oldValue:d})=>d.id===u.id).newValue:u),...t.created||[]],h=[...(r.deleted||[]).filter(u=>!s.has(u.id)),...(t.deleted||[]).filter(u=>!e.has(u.id))],c=[...(r.updated||[]).filter(({newValue:u})=>!n.has(u.id)).map(u=>{const{oldValue:d,newValue:f}=u;if(o.has(f.id)){const p=t.updated.find(m=>m.oldValue.id===f.id).newValue;return lp(d,p)}else return u}),...(t.updated||[]).filter(({oldValue:u})=>!a.has(u.id))];return{created:l,deleted:h,updated:c}};let cp=()=>({emit(r,...t){for(let e=0,i=this.events[r]||[],s=i.length;e<s;e++)i[e](...t)},events:{},on(r,t){var e;return((e=this.events)[r]||(e[r]=[])).push(t),()=>{var i;this.events[r]=(i=this.events[r])==null?void 0:i.filter(s=>t!==s)}}});const up=250,dp=r=>{const t=cp(),e=[];let i=-1,s=!1,n=0;const o=f=>{if(!s){const{changes:p}=f,m=performance.now();if(m-n>up)e.splice(i+1),e.push(p),i=e.length-1;else{const _=e.length-1;e[_]=hp(e[_],p)}n=m}s=!1};r.observe(o,{origin:dr.LOCAL});const a=f=>f&&f.length>0&&r.bulkDeleteAnnotation(f),l=f=>f&&f.length>0&&r.bulkAddAnnotation(f,!1),h=f=>f&&f.length>0&&r.bulkUpdateAnnotation(f.map(({oldValue:p})=>p)),c=f=>f&&f.length>0&&r.bulkUpdateAnnotation(f.map(({newValue:p})=>p)),u=f=>f&&f.length>0&&r.bulkAddAnnotation(f,!1),d=f=>f&&f.length>0&&r.bulkDeleteAnnotation(f);return{canRedo:()=>e.length-1>i,canUndo:()=>i>-1,destroy:()=>r.unobserve(o),on:(f,p)=>t.on(f,p),redo:()=>{if(e.length-1>i){s=!0;const{created:f,updated:p,deleted:m}=e[i+1];l(f),c(p),d(m),t.emit("redo",e[i+1]),i+=1}},undo:()=>{if(i>-1){s=!0;const{created:f,updated:p,deleted:m}=e[i];a(f),h(p),u(m),t.emit("undo",e[i]),i-=1}}}},fp=(r,t,e,i)=>{const{hover:s,selection:n,store:o,viewport:a}=r,l=new Map;let h=[],c,u;const d=(y,x)=>{l.has(y)?l.get(y).push(x):l.set(y,[x])},f=(y,x)=>{const g=l.get(y);if(g){const v=g.indexOf(x);v!==-1&&g.splice(v,1)}},p=(y,x,g)=>{l.has(y)&&setTimeout(()=>{l.get(y).forEach(v=>{if(e){const w=Array.isArray(x)?x.map(A=>e.serialize(A)):e.serialize(x),I=g?g instanceof PointerEvent?g:e.serialize(g):void 0;v(w,I)}else v(x,g)})},1)},m=()=>{const{selected:y}=n,x=(y||[]).map(({id:g})=>o.getAnnotation(g));x.forEach(g=>{const v=h.find(w=>w.id===g.id);(!v||!Mr(v,g))&&p("updateAnnotation",g,v)}),h=h.map(g=>x.find(({id:w})=>w===g.id)||g)};n.subscribe(({selected:y})=>{if(!(h.length===0&&y.length===0)){if(h.length===0&&y.length>0)h=y.map(({id:x})=>o.getAnnotation(x));else if(h.length>0&&y.length===0)h.forEach(x=>{const g=o.getAnnotation(x.id);g&&!Mr(g,x)&&p("updateAnnotation",g,x)}),h=[];else{const x=new Set(h.map(v=>v.id)),g=new Set(y.map(({id:v})=>v));h.filter(v=>!g.has(v.id)).forEach(v=>{const w=o.getAnnotation(v.id);w&&!Mr(w,v)&&p("updateAnnotation",w,v)}),h=[...h.filter(v=>g.has(v.id)),...y.filter(({id:v})=>!x.has(v)).map(({id:v})=>o.getAnnotation(v))]}p("selectionChanged",h)}}),s.subscribe(y=>{!c&&y?p("mouseEnterAnnotation",o.getAnnotation(y)):c&&!y?p("mouseLeaveAnnotation",o.getAnnotation(c)):c&&y&&(p("mouseLeaveAnnotation",o.getAnnotation(c)),p("mouseEnterAnnotation",o.getAnnotation(y))),c=y}),a==null||a.subscribe(y=>p("viewportIntersect",y.map(x=>o.getAnnotation(x)))),o.observe(y=>{i&&(u&&clearTimeout(u),u=setTimeout(m,1e3));const{created:x,deleted:g}=y.changes;(x||[]).forEach(v=>p("createAnnotation",v)),(g||[]).forEach(v=>p("deleteAnnotation",v)),(y.changes.updated||[]).filter(v=>[...v.bodiesCreated||[],...v.bodiesDeleted||[],...v.bodiesUpdated||[]].length>0).forEach(({oldValue:v,newValue:w})=>{const I=h.find(A=>A.id===v.id)||v;h=h.map(A=>A.id===v.id?w:A),p("updateAnnotation",w,I)})},{origin:dr.LOCAL}),o.observe(y=>{if(h){const x=new Set(h.map(v=>v.id)),g=(y.changes.updated||[]).filter(({newValue:v})=>x.has(v.id)).map(({newValue:v})=>v);g.length>0&&(h=h.map(v=>g.find(I=>I.id===v.id)||v))}},{origin:dr.REMOTE});const _=y=>x=>{const{updated:g}=x;y?(g||[]).forEach(v=>p("updateAnnotation",v.oldValue,v.newValue)):(g||[]).forEach(v=>p("updateAnnotation",v.newValue,v.oldValue))};return t.on("undo",_(!0)),t.on("redo",_(!1)),{on:d,off:f,emit:p}},pp=r=>t=>t.reduce((e,i)=>{const{parsed:s,error:n}=r.parse(i);return n?{parsed:e.parsed,failed:[...e.failed,i]}:s?{parsed:[...e.parsed,s],failed:e.failed}:{...e}},{parsed:[],failed:[]}),mp=(r,t,e)=>{const{store:i,selection:s}=r,n=y=>{if(e){const{parsed:x,error:g}=e.parse(y);x?i.addAnnotation(x,dr.REMOTE):console.error(g)}else i.addAnnotation(ho(y),dr.REMOTE)},o=()=>s.clear(),a=()=>i.clear(),l=y=>{const x=i.getAnnotation(y);return e&&x?e.serialize(x):x},h=()=>e?i.all().map(e.serialize):i.all(),c=()=>{var y;const x=(((y=s.selected)==null?void 0:y.map(g=>g.id))||[]).map(g=>i.getAnnotation(g)).filter(Boolean);return e?x.map(e.serialize):x},u=(y,x=!0)=>fetch(y).then(g=>g.json()).then(g=>(f(g,x),g)),d=y=>{if(typeof y=="string"){const x=i.getAnnotation(y);if(i.deleteAnnotation(y),x)return e?e.serialize(x):x}else{const x=e?e.parse(y).parsed:y;if(x)return i.deleteAnnotation(x),y}},f=(y,x=!0)=>{if(e){const g=e.parseAll||pp(e),{parsed:v,failed:w}=g(y);w.length>0&&console.warn(`Discarded ${w.length} invalid annotations`,w),i.bulkAddAnnotation(v,x,dr.REMOTE)}else i.bulkAddAnnotation(y.map(ho),x,dr.REMOTE)},p=(y,x)=>{y?s.setSelected(y,x):s.clear()},m=y=>{s.clear(),s.setUserSelectAction(y)},_=y=>{if(e){const x=e.parse(y).parsed,g=e.serialize(i.getAnnotation(x.id));return i.updateAnnotation(x),g}else{const x=i.getAnnotation(y.id);return i.updateAnnotation(ho(y)),x}};return{addAnnotation:n,cancelSelected:o,canRedo:t.canRedo,canUndo:t.canUndo,clearAnnotations:a,getAnnotationById:l,getAnnotations:h,getSelected:c,loadAnnotations:u,redo:t.redo,removeAnnotation:d,setAnnotations:f,setSelected:p,setUserSelectAction:m,undo:t.undo,updateAnnotation:_}},gp="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let yp=r=>crypto.getRandomValues(new Uint8Array(r)),_p=(r,t,e)=>{let i=(2<<Math.log(r.length-1)/Math.LN2)-1,s=-~(1.6*i*t/r.length);return(n=t)=>{let o="";for(;;){let a=e(s),l=s;for(;l--;)if(o+=r[a[l]&i]||"",o.length===n)return o}}},vp=(r,t=21)=>_p(r,t,yp),xp=(r=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(r));for(;r--;)t+=gp[e[r]&63];return t};const bp=()=>({isGuest:!0,id:vp("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),wp=["#ff7c00","#1ac938","#e8000b","#8b2be2","#9f4800","#f14cc1","#ffc400","#00d7ff","#023eff"],Ep=()=>{const r=[...wp];return{assignRandomColor:()=>{const t=Math.floor(Math.random()*r.length),e=r[t];return r.splice(t,1),e},releaseColor:t=>r.push(t)}};xp();var Tp=Object.defineProperty,Ap=(r,t,e)=>t in r?Tp(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Vl=(r,t,e)=>Ap(r,typeof t!="symbol"?t+"":t,e);function At(){}function co(r,t){for(const e in t)r[e]=t[e];return r}function zl(r){return r()}function Wl(){return Object.create(null)}function Pe(r){r.forEach(zl)}function Ut(r){return typeof r=="function"}function qt(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}function Sp(r){return Object.keys(r).length===0}function jl(r,...t){if(r==null){for(const i of t)i(void 0);return At}const e=r.subscribe(...t);return e.unsubscribe?()=>e.unsubscribe():e}function uo(r,t,e){r.$$.on_destroy.push(jl(t,e))}function Ip(r,t,e,i){if(r){const s=Yl(r,t,e,i);return r[0](s)}}function Yl(r,t,e,i){return r[1]&&i?co(e.ctx.slice(),r[1](i(t))):e.ctx}function Cp(r,t,e,i){if(r[2]&&i){const s=r[2](i(e));if(t.dirty===void 0)return s;if(typeof s=="object"){const n=[],o=Math.max(t.dirty.length,s.length);for(let a=0;a<o;a+=1)n[a]=t.dirty[a]|s[a];return n}return t.dirty|s}return t.dirty}function Rp(r,t,e,i,s,n){if(s){const o=Yl(t,e,i,n);r.p(o,s)}}function Pp(r){if(r.ctx.length>32){const t=[],e=r.ctx.length/32;for(let i=0;i<e;i++)t[i]=-1;return t}return-1}function ql(r){const t={};for(const e in r)e[0]!=="$"&&(t[e]=r[e]);return t}function Rs(r){return r??""}function Me(r,t){r.appendChild(t)}function it(r,t,e){r.insertBefore(t,e||null)}function et(r){r.parentNode&&r.parentNode.removeChild(r)}function fo(r,t){for(let e=0;e<r.length;e+=1)r[e]&&r[e].d(t)}function yt(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function Kl(r){return document.createTextNode(r)}function ge(){return Kl(" ")}function ye(){return Kl("")}function Dt(r,t,e,i){return r.addEventListener(t,e,i),()=>r.removeEventListener(t,e,i)}function T(r,t,e){e==null?r.removeAttribute(t):r.getAttribute(t)!==e&&r.setAttribute(t,e)}function Mp(r){return Array.from(r.childNodes)}function fr(r,t,e){r.classList.toggle(t,!!e)}function Bp(r,t,{bubbles:e=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:t,bubbles:e,cancelable:i})}let Xi;function Vi(r){Xi=r}function Zl(){if(!Xi)throw new Error("Function called outside component initialization");return Xi}function zi(r){Zl().$$.on_mount.push(r)}function Qr(){const r=Zl();return(t,e,{cancelable:i=!1}={})=>{const s=r.$$.callbacks[t];if(s){const n=Bp(t,e,{cancelable:i});return s.slice().forEach(o=>{o.call(r,n)}),!n.defaultPrevented}return!0}}function Ze(r,t){const e=r.$$.callbacks[t.type];e&&e.slice().forEach(i=>i.call(this,t))}const ti=[],Ps=[];let ei=[];const Jl=[],Dp=Promise.resolve();let po=!1;function Op(){po||(po=!0,Dp.then(Ql))}function mo(r){ei.push(r)}const go=new Set;let ri=0;function Ql(){if(ri!==0)return;const r=Xi;do{try{for(;ri<ti.length;){const t=ti[ri];ri++,Vi(t),Fp(t.$$)}}catch(t){throw ti.length=0,ri=0,t}for(Vi(null),ti.length=0,ri=0;Ps.length;)Ps.pop()();for(let t=0;t<ei.length;t+=1){const e=ei[t];go.has(e)||(go.add(e),e())}ei.length=0}while(ti.length);for(;Jl.length;)Jl.pop()();po=!1,go.clear(),Vi(r)}function Fp(r){if(r.fragment!==null){r.update(),Pe(r.before_update);const t=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,t),r.after_update.forEach(mo)}}function Lp(r){const t=[],e=[];ei.forEach(i=>r.indexOf(i)===-1?t.push(i):e.push(i)),e.forEach(i=>i()),ei=t}const Ms=new Set;let Br;function _e(){Br={r:0,c:[],p:Br}}function ve(){Br.r||Pe(Br.c),Br=Br.p}function ot(r,t){r&&r.i&&(Ms.delete(r),r.i(t))}function mt(r,t,e,i){if(r&&r.o){if(Ms.has(r))return;Ms.add(r),Br.c.push(()=>{Ms.delete(r),i&&(e&&r.d(1),i())}),r.o(t)}else i&&i()}function ii(r){return(r==null?void 0:r.length)!==void 0?r:Array.from(r)}function ce(r){r&&r.c()}function se(r,t,e){const{fragment:i,after_update:s}=r.$$;i&&i.m(t,e),mo(()=>{const n=r.$$.on_mount.map(zl).filter(Ut);r.$$.on_destroy?r.$$.on_destroy.push(...n):Pe(n),r.$$.on_mount=[]}),s.forEach(mo)}function ne(r,t){const e=r.$$;e.fragment!==null&&(Lp(e.after_update),Pe(e.on_destroy),e.fragment&&e.fragment.d(t),e.on_destroy=e.fragment=null,e.ctx=[])}function Np(r,t){r.$$.dirty[0]===-1&&(ti.push(r),Op(),r.$$.dirty.fill(0)),r.$$.dirty[t/31|0]|=1<<t%31}function ue(r,t,e,i,s,n,o=null,a=[-1]){const l=Xi;Vi(r);const h=r.$$={fragment:null,ctx:[],props:n,update:At,not_equal:s,bound:Wl(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:Wl(),dirty:a,skip_bound:!1,root:t.target||l.$$.root};o&&o(h.root);let c=!1;if(h.ctx=e?e(r,t.props||{},(u,d,...f)=>{const p=f.length?f[0]:d;return h.ctx&&s(h.ctx[u],h.ctx[u]=p)&&(!h.skip_bound&&h.bound[u]&&h.bound[u](p),c&&Np(r,u)),d}):[],h.update(),c=!0,Pe(h.before_update),h.fragment=i?i(h.ctx):!1,t.target){if(t.hydrate){const u=Mp(t.target);h.fragment&&h.fragment.l(u),u.forEach(et)}else h.fragment&&h.fragment.c();t.intro&&ot(r.$$.fragment),se(r,t.target,t.anchor),Ql()}Vi(l)}class de{constructor(){Vl(this,"$$"),Vl(this,"$$set")}$destroy(){ne(this,1),this.$destroy=At}$on(t,e){if(!Ut(e))return At;const i=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return i.push(e),()=>{const s=i.indexOf(e);s!==-1&&i.splice(s,1)}}$set(t){this.$$set&&!Sp(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const Up="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Up);var wt=(r=>(r.ELLIPSE="ELLIPSE",r.POLYGON="POLYGON",r.RECTANGLE="RECTANGLE",r))(wt||{});const yo={},_o=(r,t)=>yo[r]=t,vo=r=>yo[r.type].area(r),kp=(r,t,e)=>yo[r.type].intersects(r,t,e),Bs=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}},Gp={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),c=t-i,u=e-s,d=l*c+h*u,f=h*c-l*u;return d*d/(n*n)+f*f/(o*o)<=1}};_o(wt.ELLIPSE,Gp);const $p={area:r=>{const{points:t}=r.geometry;let e=0,i=t.length-1;for(let s=0;s<t.length;s++)e+=(t[i][0]+t[s][0])*(t[i][1]-t[s][1]),i=s;return Math.abs(.5*e)},intersects:(r,t,e)=>{const{points:i}=r.geometry;let s=!1;for(let n=0,o=i.length-1;n<i.length;o=n++){const a=i[n][0],l=i[n][1],h=i[o][0],c=i[o][1];l>e!=c>e&&t<(h-a)*(e-l)/(c-l)+a&&(s=!s)}return s}};_o(wt.POLYGON,$p);const Hp={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};_o(wt.RECTANGLE,Hp);const Je=r=>Ds(r.target),Ds=r=>{var t,e;return(r==null?void 0:r.annotation)!==void 0&&((e=(t=r==null?void 0:r.selector)==null?void 0:t.geometry)==null?void 0:e.bounds)!==void 0},Xp=(r,t=!1)=>{const e=typeof r=="string"?r:r.value,i=/^(xywh)=(pixel|percent)?:?(.+?),(.+?),(.+?),(.+)*/g,s=[...e.matchAll(i)][0],[n,o,a,l,h,c,u]=s;if(o!=="xywh")throw new Error("Unsupported MediaFragment: "+e);if(a&&a!=="pixel")throw new Error(`Unsupported MediaFragment unit: ${a}`);const[d,f,p,m]=[l,h,c,u].map(parseFloat);return{type:wt.RECTANGLE,geometry:{x:d,y:f,w:p,h:m,bounds:{minX:d,minY:t?f-m:f,maxX:d+p,maxY:t?f:f+m}}}},Vp=r=>{const{x:t,y:e,w:i,h:s}=r;return{type:"FragmentSelector",conformsTo:"http://www.w3.org/TR/media-frags/",value:`xywh=pixel:${t},${e},${i},${s}`}},th="http://www.w3.org/2000/svg",eh=r=>{const t=i=>{Array.from(i.attributes).forEach(s=>{s.name.startsWith("on")&&i.removeAttribute(s.name)})},e=r.getElementsByTagName("script");return Array.from(e).reverse().forEach(i=>i.parentNode.removeChild(i)),Array.from(r.querySelectorAll("*")).forEach(t),r},zp=r=>{const t=new XMLSerializer().serializeToString(r.documentElement).replace("<svg>",`<svg xmlns="${th}">`);return new DOMParser().parseFromString(t,"image/svg+xml").documentElement},Wp=r=>{const t=new DOMParser().parseFromString(r,"image/svg+xml"),e=t.lookupPrefix(th),i=t.lookupNamespaceURI(null);return e||i?eh(t).firstChild:eh(zp(t)).firstChild},jp=r=>{const[t,e,i]=r.match(/(<polygon points=["|'])([^("|')]*)/)||[],s=i.split(" ").map(n=>n.split(",").map(parseFloat));return{type:wt.POLYGON,geometry:{points:s,bounds:Bs(s)}}},Yp=r=>{const t=Wp(r),e=parseFloat(t.getAttribute("cx")),i=parseFloat(t.getAttribute("cy")),s=parseFloat(t.getAttribute("rx")),n=parseFloat(t.getAttribute("ry")),o={minX:e-s,minY:i-n,maxX:e+s,maxY:i+n};return{type:wt.ELLIPSE,geometry:{cx:e,cy:i,rx:s,ry:n,bounds:o}}},qp=r=>{const t=typeof r=="string"?r:r.value;if(t.includes("<polygon points="))return jp(t);if(t.includes("<ellipse "))return Yp(t);throw"Unsupported SVG shape: "+t},Kp=r=>{let t;if(r.type===wt.POLYGON){const e=r.geometry,{points:i}=e;t=`<svg><polygon points="${i.map(s=>s.join(",")).join(" ")}" /></svg>`}else if(r.type===wt.ELLIPSE){const e=r.geometry;t=`<svg><ellipse cx="${e.cx}" cy="${e.cy}" rx="${e.rx}" ry="${e.ry}" /></svg>`}if(t)return{type:"SvgSelector",value:t};throw`Unsupported shape type: ${r.type}`};for(var Xt=[],xo=0;xo<256;++xo)Xt.push((xo+256).toString(16).slice(1));function Zp(r,t=0){return(Xt[r[t+0]]+Xt[r[t+1]]+Xt[r[t+2]]+Xt[r[t+3]]+"-"+Xt[r[t+4]]+Xt[r[t+5]]+"-"+Xt[r[t+6]]+Xt[r[t+7]]+"-"+Xt[r[t+8]]+Xt[r[t+9]]+"-"+Xt[r[t+10]]+Xt[r[t+11]]+Xt[r[t+12]]+Xt[r[t+13]]+Xt[r[t+14]]+Xt[r[t+15]]).toLowerCase()}var Os,Jp=new Uint8Array(16);function Qp(){if(!Os&&(Os=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Os))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Os(Jp)}var tm=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const rh={randomUUID:tm};function ih(r,t,e){if(rh.randomUUID&&!t&&!r)return rh.randomUUID();r=r||{};var i=r.random||(r.rng||Qp)();return i[6]=i[6]&15|64,i[8]=i[8]&63|128,Zp(i)}var sh=Object.prototype.hasOwnProperty;function pr(r,t){var e,i;if(r===t)return!0;if(r&&t&&(e=r.constructor)===t.constructor){if(e===Date)return r.getTime()===t.getTime();if(e===RegExp)return r.toString()===t.toString();if(e===Array){if((i=r.length)===t.length)for(;i--&&pr(r[i],t[i]););return i===-1}if(!e||typeof r=="object"){i=0;for(e in r)if(sh.call(r,e)&&++i&&!sh.call(t,e)||!(e in t)||!pr(r[e],t[e]))return!1;return Object.keys(t).length===i}}return r!==r&&t!==t}function bo(){}function em(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}const si=[];function wo(r,t=bo){let e;const i=new Set;function s(a){if(em(r,a)&&(r=a,e)){const l=!si.length;for(const h of i)h[1](),si.push(h,r);if(l){for(let h=0;h<si.length;h+=2)si[h][0](si[h+1]);si.length=0}}}function n(a){s(a(r))}function o(a,l=bo){const h=[a,l];return i.add(h),i.size===1&&(e=t(s,n)||bo),a(r),()=>{i.delete(h),i.size===0&&e&&(e(),e=null)}}return{set:s,update:n,subscribe:o}}const rm=r=>{const{subscribe:t,set:e}=wo();let i;return t(s=>i=s),r.observe(({changes:s})=>{if(i){(s.deleted||[]).some(o=>o.id===i)&&e(void 0);const n=(s.updated||[]).find(({oldValue:o})=>o.id===i);n&&e(n.newValue.id)}}),{get current(){return i},subscribe:t,set:e}};var nh=(r=>(r.EDIT="EDIT",r.SELECT="SELECT",r.NONE="NONE",r))(nh||{});const Fs={selected:[]},im=(r,t,e)=>{const{subscribe:i,set:s}=wo(Fs);let n=t,o=Fs;i(p=>o=p);const a=()=>{pr(o,Fs)||s(Fs)},l=()=>{var p;return((p=o.selected)==null?void 0:p.length)===0},h=p=>{if(l())return!1;const m=typeof p=="string"?p:p.id;return o.selected.some(_=>_.id===m)},c=(p,m)=>{const _=r.getAnnotation(p);if(!_){console.warn("Invalid selection: "+p);return}switch(oh(_,n,e)){case"EDIT":s({selected:[{id:p,editable:!0}],event:m});break;case"SELECT":s({selected:[{id:p}],event:m});break;default:s({selected:[],event:m})}},u=(p,m)=>{const _=Array.isArray(p)?p:[p],y=_.map(x=>r.getAnnotation(x)).filter(x=>!!x);s({selected:y.map(x=>{const g=m===void 0?oh(x,n,e)==="EDIT":m;return{id:x.id,editable:g}})}),y.length!==_.length&&console.warn("Invalid selection",p)},d=p=>{if(l())return!1;const{selected:m}=o;m.some(({id:_})=>p.includes(_))&&s({selected:m.filter(({id:_})=>!p.includes(_))})},f=p=>n=p;return r.observe(({changes:p})=>d((p.deleted||[]).map(m=>m.id))),{get event(){return o?o.event:null},get selected(){return o?[...o.selected]:null},get userSelectAction(){return n},clear:a,isEmpty:l,isSelected:h,setSelected:u,setUserSelectAction:f,subscribe:i,userSelect:c}},oh=(r,t,e)=>{const i=e?e.serialize(r):r;return typeof t=="function"?t(i):t||"EDIT"};for(var Vt=[],Eo=0;Eo<256;++Eo)Vt.push((Eo+256).toString(16).slice(1));function sm(r,t=0){return(Vt[r[t+0]]+Vt[r[t+1]]+Vt[r[t+2]]+Vt[r[t+3]]+"-"+Vt[r[t+4]]+Vt[r[t+5]]+"-"+Vt[r[t+6]]+Vt[r[t+7]]+"-"+Vt[r[t+8]]+Vt[r[t+9]]+"-"+Vt[r[t+10]]+Vt[r[t+11]]+Vt[r[t+12]]+Vt[r[t+13]]+Vt[r[t+14]]+Vt[r[t+15]]).toLowerCase()}var Ls,nm=new Uint8Array(16);function om(){if(!Ls&&(Ls=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Ls))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ls(nm)}var am=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const ah={randomUUID:am};function lm(r,t,e){if(ah.randomUUID&&!t&&!r)return ah.randomUUID();r=r||{};var i=r.random||(r.rng||om)();return i[6]=i[6]&15|64,i[8]=i[8]&63|128,sm(i)}const To=r=>{const t=e=>{const i={...e};return e.created&&typeof e.created=="string"&&(i.created=new Date(e.created)),e.updated&&typeof e.updated=="string"&&(i.updated=new Date(e.updated)),i};return{...r,bodies:(r.bodies||[]).map(t),target:t(r.target)}},hm=(r,t)=>{const e=new Set(r.bodies.map(i=>i.id));return t.bodies.filter(i=>!e.has(i.id))},cm=(r,t)=>{const e=new Set(t.bodies.map(i=>i.id));return r.bodies.filter(i=>!e.has(i.id))},um=(r,t)=>t.bodies.map(e=>{const i=r.bodies.find(s=>s.id===e.id);return{newBody:e,oldBody:i&&!pr(i,e)?i:void 0}}).filter(({oldBody:e})=>e).map(({oldBody:e,newBody:i})=>({oldBody:e,newBody:i})),dm=(r,t)=>!pr(r.target,t.target),lh=(r,t)=>{const e=hm(r,t),i=cm(r,t),s=um(r,t);return{oldValue:r,newValue:t,bodiesCreated:e.length>0?e:void 0,bodiesDeleted:i.length>0?i:void 0,bodiesUpdated:s.length>0?s:void 0,targetUpdated:dm(r,t)?{oldTarget:r.target,newTarget:t.target}:void 0}};var St=(r=>(r.LOCAL="LOCAL",r.REMOTE="REMOTE",r.SILENT="SILENT",r))(St||{});const fm=(r,t)=>{var e,i;const{changes:s,origin:n}=t;if(!(r.options.origin?r.options.origin===n:n!=="SILENT"))return!1;if(r.options.ignore){const{ignore:o}=r.options,a=l=>l&&l.length>0;if(!(a(s.created)||a(s.deleted))){const l=(e=s.updated)==null?void 0:e.some(c=>a(c.bodiesCreated)||a(c.bodiesDeleted)||a(c.bodiesUpdated)),h=(i=s.updated)==null?void 0:i.some(c=>c.targetUpdated);if(o==="BODY_ONLY"&&l&&!h||o==="TARGET_ONLY"&&h&&!l)return!1}}if(r.options.annotations){const o=new Set([...(s.created||[]).map(a=>a.id),...(s.deleted||[]).map(a=>a.id),...(s.updated||[]).map(({oldValue:a})=>a.id)]);return!!(Array.isArray(r.options.annotations)?r.options.annotations:[r.options.annotations]).find(a=>o.has(a))}else return!0},pm=(r,t)=>{const e=new Set((r.created||[]).map(u=>u.id)),i=new Set((r.updated||[]).map(({newValue:u})=>u.id)),s=new Set((t.created||[]).map(u=>u.id)),n=new Set((t.deleted||[]).map(u=>u.id)),o=new Set((t.updated||[]).map(({oldValue:u})=>u.id)),a=new Set((t.updated||[]).filter(({oldValue:u})=>e.has(u.id)||i.has(u.id)).map(({oldValue:u})=>u.id)),l=[...(r.created||[]).filter(u=>!n.has(u.id)).map(u=>o.has(u.id)?t.updated.find(({oldValue:d})=>d.id===u.id).newValue:u),...t.created||[]],h=[...(r.deleted||[]).filter(u=>!s.has(u.id)),...(t.deleted||[]).filter(u=>!e.has(u.id))],c=[...(r.updated||[]).filter(({newValue:u})=>!n.has(u.id)).map(u=>{const{oldValue:d,newValue:f}=u;if(o.has(f.id)){const p=t.updated.find(m=>m.oldValue.id===f.id).newValue;return lh(d,p)}else return u}),...(t.updated||[]).filter(({oldValue:u})=>!a.has(u.id))];return{created:l,deleted:h,updated:c}},Ao=r=>{const t=r.id===void 0?lm():r.id;return{...r,id:t,bodies:r.bodies===void 0?[]:r.bodies.map(e=>({...e,annotation:t})),target:{...r.target,annotation:t}}},mm=r=>r.id!==void 0,gm=()=>{const r=new Map,t=new Map,e=[],i=(S,R={})=>{e.push({onChange:S,options:R})},s=S=>{const R=e.findIndex(E=>E.onChange==S);R>-1&&e.splice(R,1)},n=(S,R)=>{const E={origin:S,changes:{created:R.created||[],updated:R.updated||[],deleted:R.deleted||[]},state:[...r.values()]};e.forEach(b=>{fm(b,E)&&b.onChange(E)})},o=(S,R=St.LOCAL)=>{if(S.id&&r.get(S.id))throw Error(`Cannot add annotation ${S.id} - exists already`);{const E=Ao(S);r.set(E.id,E),E.bodies.forEach(b=>t.set(b.id,E.id)),n(R,{created:[E]})}},a=(S,R)=>{const E=Ao(typeof S=="string"?R:S),b=typeof S=="string"?S:S.id,D=b&&r.get(b);if(D){const F=lh(D,E);return b===E.id?r.set(b,E):(r.delete(b),r.set(E.id,E)),D.bodies.forEach(G=>t.delete(G.id)),E.bodies.forEach(G=>t.set(G.id,E.id)),F}else console.warn(`Cannot update annotation ${b} - does not exist`)},l=(S,R=St.LOCAL,E=St.LOCAL)=>{const b=mm(R)?E:R,D=a(S,R);D&&n(b,{updated:[D]})},h=(S,R=St.LOCAL)=>{const E=S.reduce((b,D)=>{const F=a(D);return F?[...b,F]:b},[]);E.length>0&&n(R,{updated:E})},c=(S,R=St.LOCAL)=>{const E=r.get(S.annotation);if(E){const b={...E,bodies:[...E.bodies,S]};r.set(E.id,b),t.set(S.id,b.id),n(R,{updated:[{oldValue:E,newValue:b,bodiesCreated:[S]}]})}else console.warn(`Attempt to add body to missing annotation: ${S.annotation}`)},u=()=>[...r.values()],d=(S=St.LOCAL)=>{const R=[...r.values()];r.clear(),t.clear(),n(S,{deleted:R})},f=(S,R=!0,E=St.LOCAL)=>{const b=S.map(Ao);if(R){const D=[...r.values()];r.clear(),t.clear(),b.forEach(F=>{r.set(F.id,F),F.bodies.forEach(G=>t.set(G.id,F.id))}),n(E,{created:b,deleted:D})}else{const D=S.reduce((F,G)=>{const $=G.id&&r.get(G.id);return $?[...F,$]:F},[]);if(D.length>0)throw Error(`Bulk insert would overwrite the following annotations: ${D.map(F=>F.id).join(", ")}`);b.forEach(F=>{r.set(F.id,F),F.bodies.forEach(G=>t.set(G.id,F.id))}),n(E,{created:b})}},p=S=>{const R=typeof S=="string"?S:S.id,E=r.get(R);if(E)return r.delete(R),E.bodies.forEach(b=>t.delete(b.id)),E;console.warn(`Attempt to delete missing annotation: ${R}`)},m=(S,R=St.LOCAL)=>{const E=p(S);E&&n(R,{deleted:[E]})},_=(S,R=St.LOCAL)=>{const E=S.reduce((b,D)=>{const F=p(D);return F?[...b,F]:b},[]);E.length>0&&n(R,{deleted:E})},y=S=>{const R=r.get(S.annotation);if(R){const E=R.bodies.find(b=>b.id===S.id);if(E){t.delete(E.id);const b={...R,bodies:R.bodies.filter(D=>D.id!==S.id)};return r.set(R.id,b),{oldValue:R,newValue:b,bodiesDeleted:[E]}}else console.warn(`Attempt to delete missing body ${S.id} from annotation ${S.annotation}`)}else console.warn(`Attempt to delete body from missing annotation ${S.annotation}`)},x=(S,R=St.LOCAL)=>{const E=y(S);E&&n(R,{updated:[E]})},g=(S,R=St.LOCAL)=>{const E=S.map(b=>y(b)).filter(Boolean);E.length>0&&n(R,{updated:E})},v=S=>{const R=r.get(S);return R?{...R}:void 0},w=S=>{const R=t.get(S);if(R){const E=v(R).bodies.find(b=>b.id===S);if(E)return E;console.error(`Store integrity error: body ${S} in index, but not in annotation`)}else console.warn(`Attempt to retrieve missing body: ${S}`)},I=(S,R)=>{if(S.annotation!==R.annotation)throw"Annotation integrity violation: annotation ID must be the same when updating bodies";const E=r.get(S.annotation);if(E){const b=E.bodies.find(F=>F.id===S.id),D={...E,bodies:E.bodies.map(F=>F.id===b.id?R:F)};return r.set(E.id,D),b.id!==R.id&&(t.delete(b.id),t.set(R.id,D.id)),{oldValue:E,newValue:D,bodiesUpdated:[{oldBody:b,newBody:R}]}}else console.warn(`Attempt to add body to missing annotation ${S.annotation}`)},A=(S,R,E=St.LOCAL)=>{const b=I(S,R);b&&n(E,{updated:[b]})},C=(S,R=St.LOCAL)=>{const E=S.map(b=>I({id:b.id,annotation:b.annotation},b)).filter(Boolean);n(R,{updated:E})},N=S=>{const R=r.get(S.annotation);if(R){const E={...R,target:{...R.target,...S}};return r.set(R.id,E),{oldValue:R,newValue:E,targetUpdated:{oldTarget:R.target,newTarget:S}}}else console.warn(`Attempt to update target on missing annotation: ${S.annotation}`)};return{addAnnotation:o,addBody:c,all:u,bulkAddAnnotation:f,bulkDeleteAnnotation:_,bulkDeleteBodies:g,bulkUpdateAnnotation:h,bulkUpdateBodies:C,bulkUpdateTargets:(S,R=St.LOCAL)=>{const E=S.map(b=>N(b)).filter(Boolean);E.length>0&&n(R,{updated:E})},clear:d,deleteAnnotation:m,deleteBody:x,getAnnotation:v,getBody:w,observe:i,unobserve:s,updateAnnotation:l,updateBody:A,updateTarget:(S,R=St.LOCAL)=>{const E=N(S);E&&n(R,{updated:[E]})}}},ym=r=>({...r,subscribe:t=>{const e=i=>t(i.state);return r.observe(e),t(r.all()),()=>r.unobserve(e)}});let _m=()=>({emit(r,...t){for(let e=0,i=this.events[r]||[],s=i.length;e<s;e++)i[e](...t)},events:{},on(r,t){var e;return((e=this.events)[r]||(e[r]=[])).push(t),()=>{var i;this.events[r]=(i=this.events[r])==null?void 0:i.filter(s=>t!==s)}}});const vm=250,xm=r=>{const t=_m(),e=[];let i=-1,s=!1,n=0;const o=f=>{if(!s){const{changes:p}=f,m=performance.now();if(m-n>vm)e.splice(i+1),e.push(p),i=e.length-1;else{const _=e.length-1;e[_]=pm(e[_],p)}n=m}s=!1};r.observe(o,{origin:St.LOCAL});const a=f=>f&&f.length>0&&r.bulkDeleteAnnotation(f),l=f=>f&&f.length>0&&r.bulkAddAnnotation(f,!1),h=f=>f&&f.length>0&&r.bulkUpdateAnnotation(f.map(({oldValue:p})=>p)),c=f=>f&&f.length>0&&r.bulkUpdateAnnotation(f.map(({newValue:p})=>p)),u=f=>f&&f.length>0&&r.bulkAddAnnotation(f,!1),d=f=>f&&f.length>0&&r.bulkDeleteAnnotation(f);return{canRedo:()=>e.length-1>i,canUndo:()=>i>-1,destroy:()=>r.unobserve(o),on:(f,p)=>t.on(f,p),redo:()=>{if(e.length-1>i){s=!0;const{created:f,updated:p,deleted:m}=e[i+1];l(f),c(p),d(m),t.emit("redo",e[i+1]),i+=1}},undo:()=>{if(i>-1){s=!0;const{created:f,updated:p,deleted:m}=e[i];a(f),h(p),u(m),t.emit("undo",e[i]),i-=1}}}},bm=()=>{const{subscribe:r,set:t}=wo([]);return{subscribe:r,set:t}},wm=(r,t,e,i)=>{const{hover:s,selection:n,store:o,viewport:a}=r,l=new Map;let h=[],c,u;const d=(y,x)=>{l.has(y)?l.get(y).push(x):l.set(y,[x])},f=(y,x)=>{const g=l.get(y);if(g){const v=g.indexOf(x);v!==-1&&g.splice(v,1)}},p=(y,x,g)=>{l.has(y)&&setTimeout(()=>{l.get(y).forEach(v=>{if(e){const w=Array.isArray(x)?x.map(A=>e.serialize(A)):e.serialize(x),I=g?g instanceof PointerEvent?g:e.serialize(g):void 0;v(w,I)}else v(x,g)})},1)},m=()=>{const{selected:y}=n,x=(y||[]).map(({id:g})=>o.getAnnotation(g));x.forEach(g=>{const v=h.find(w=>w.id===g.id);(!v||!pr(v,g))&&p("updateAnnotation",g,v)}),h=h.map(g=>x.find(({id:v})=>v===g.id)||g)};n.subscribe(({selected:y})=>{if(!(h.length===0&&y.length===0)){if(h.length===0&&y.length>0)h=y.map(({id:x})=>o.getAnnotation(x));else if(h.length>0&&y.length===0)h.forEach(x=>{const g=o.getAnnotation(x.id);g&&!pr(g,x)&&p("updateAnnotation",g,x)}),h=[];else{const x=new Set(h.map(v=>v.id)),g=new Set(y.map(({id:v})=>v));h.filter(v=>!g.has(v.id)).forEach(v=>{const w=o.getAnnotation(v.id);w&&!pr(w,v)&&p("updateAnnotation",w,v)}),h=[...h.filter(v=>g.has(v.id)),...y.filter(({id:v})=>!x.has(v)).map(({id:v})=>o.getAnnotation(v))]}p("selectionChanged",h)}}),s.subscribe(y=>{!c&&y?p("mouseEnterAnnotation",o.getAnnotation(y)):c&&!y?p("mouseLeaveAnnotation",o.getAnnotation(c)):c&&y&&(p("mouseLeaveAnnotation",o.getAnnotation(c)),p("mouseEnterAnnotation",o.getAnnotation(y))),c=y}),a==null||a.subscribe(y=>p("viewportIntersect",y.map(x=>o.getAnnotation(x)))),o.observe(y=>{i&&(u&&clearTimeout(u),u=setTimeout(m,1e3));const{created:x,deleted:g}=y.changes;(x||[]).forEach(v=>p("createAnnotation",v)),(g||[]).forEach(v=>p("deleteAnnotation",v)),(y.changes.updated||[]).filter(v=>[...v.bodiesCreated||[],...v.bodiesDeleted||[],...v.bodiesUpdated||[]].length>0).forEach(({oldValue:v,newValue:w})=>{const I=h.find(A=>A.id===v.id)||v;h=h.map(A=>A.id===v.id?w:A),p("updateAnnotation",w,I)})},{origin:St.LOCAL}),o.observe(y=>{if(h){const x=new Set(h.map(v=>v.id)),g=(y.changes.updated||[]).filter(({newValue:v})=>x.has(v.id)).map(({newValue:v})=>v);g.length>0&&(h=h.map(v=>g.find(w=>w.id===v.id)||v))}},{origin:St.REMOTE});const _=y=>x=>{const{updated:g}=x;y?(g||[]).forEach(v=>p("updateAnnotation",v.oldValue,v.newValue)):(g||[]).forEach(v=>p("updateAnnotation",v.newValue,v.oldValue))};return t.on("undo",_(!0)),t.on("redo",_(!1)),{on:d,off:f,emit:p}},Em=r=>t=>t.reduce((e,i)=>{const{parsed:s,error:n}=r.parse(i);return n?{parsed:e.parsed,failed:[...e.failed,i]}:s?{parsed:[...e.parsed,s],failed:e.failed}:{...e}},{parsed:[],failed:[]}),Tm=(r,t,e)=>{const{store:i,selection:s}=r,n=y=>{if(e){const{parsed:x,error:g}=e.parse(y);x?i.addAnnotation(x,St.REMOTE):console.error(g)}else i.addAnnotation(To(y),St.REMOTE)},o=()=>s.clear(),a=()=>i.clear(),l=y=>{const x=i.getAnnotation(y);return e&&x?e.serialize(x):x},h=()=>e?i.all().map(e.serialize):i.all(),c=()=>{var y;const x=(((y=s.selected)==null?void 0:y.map(g=>g.id))||[]).map(g=>i.getAnnotation(g)).filter(Boolean);return e?x.map(e.serialize):x},u=(y,x=!0)=>fetch(y).then(g=>g.json()).then(g=>(f(g,x),g)),d=y=>{if(typeof y=="string"){const x=i.getAnnotation(y);if(i.deleteAnnotation(y),x)return e?e.serialize(x):x}else{const x=e?e.parse(y).parsed:y;if(x)return i.deleteAnnotation(x),y}},f=(y,x=!0)=>{if(e){const g=e.parseAll||Em(e),{parsed:v,failed:w}=g(y);w.length>0&&console.warn(`Discarded ${w.length} invalid annotations`,w),i.bulkAddAnnotation(v,x,St.REMOTE)}else i.bulkAddAnnotation(y.map(To),x,St.REMOTE)},p=(y,x)=>{y?s.setSelected(y,x):s.clear()},m=y=>{s.clear(),s.setUserSelectAction(y)},_=y=>{if(e){const x=e.parse(y).parsed,g=e.serialize(i.getAnnotation(x.id));return i.updateAnnotation(x),g}else{const x=i.getAnnotation(y.id);return i.updateAnnotation(To(y)),x}};return{addAnnotation:n,cancelSelected:o,canRedo:t.canRedo,canUndo:t.canUndo,clearAnnotations:a,getAnnotationById:l,getAnnotations:h,getSelected:c,loadAnnotations:u,redo:t.redo,removeAnnotation:d,setAnnotations:f,setSelected:p,setUserSelectAction:m,undo:t.undo,updateAnnotation:_}},Am=(r,t,e)=>typeof t=="function"?t(r,e):t,Sm=(r,t)=>typeof r!="function"&&typeof t!="function"?{...r||{},...t||{}}:(e,i)=>{const s=typeof r=="function"?r(e,i):r,n=typeof t=="function"?t(e,i):t;return{...s||{},...n||{}}},Im="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Cm=r=>crypto.getRandomValues(new Uint8Array(r)),Rm=(r,t,e)=>{let i=(2<<Math.log(r.length-1)/Math.LN2)-1,s=-~(1.6*i*t/r.length);return(n=t)=>{let o="";for(;;){let a=e(s),l=s;for(;l--;)if(o+=r[a[l]&i]||"",o.length===n)return o}}},Pm=(r,t=21)=>Rm(r,t,Cm),Mm=(r=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(r));for(;r--;)t+=Im[e[r]&63];return t};const Bm=()=>({isGuest:!0,id:Pm("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),Dm=r=>{const t=JSON.stringify(r);let e=0;for(let i=0,s=t.length;i<s;i++){let n=t.charCodeAt(i);e=(e<<5)-e+n,e|=0}return`${e}`},hh=r=>r?typeof r=="object"?{...r}:r:void 0,Om=(r,t)=>(Array.isArray(r)?r:[r]).map(e=>{const{id:i,type:s,purpose:n,value:o,created:a,modified:l,creator:h,...c}=e;return{id:i||`temp-${Dm(e)}`,annotation:t,type:s,purpose:n,value:o,creator:hh(h),created:a?new Date(a):void 0,updated:l?new Date(l):void 0,...c}}),Fm=r=>r.map(t=>{var e;const{annotation:i,created:s,updated:n,...o}=t,a={...o,created:s==null?void 0:s.toISOString(),modified:n==null?void 0:n.toISOString()};return(e=a.id)!=null&&e.startsWith("temp-")&&delete a.id,a});Mm();const Lm=(r,t={strict:!0,invertY:!1})=>({parse:e=>Nm(e,t),serialize:e=>Um(e,r,t)}),Nm=(r,t={strict:!0,invertY:!1})=>{const e=r.id||ih(),{creator:i,created:s,modified:n,body:o,...a}=r,l=Om(o||[],e),h=Array.isArray(r.target)?r.target[0]:r.target,c=Array.isArray(h.selector)?h.selector[0]:h.selector,u=(c==null?void 0:c.type)==="FragmentSelector"?Xp(c,t.invertY):(c==null?void 0:c.type)==="SvgSelector"?qp(c):void 0;return u||!t.strict?{parsed:{...a,id:e,bodies:l,target:{created:s?new Date(s):void 0,creator:hh(i),updated:n?new Date(n):void 0,...Array.isArray(a.target)?a.target[0]:a.target,annotation:e,selector:u||c}}}:{error:Error(`Invalid selector: ${JSON.stringify(c)}`)}},Um=(r,t,e={strict:!0,invertY:!1})=>{const{selector:i,creator:s,created:n,updated:o,updatedBy:a,...l}=r.target;let h;try{h=i.type==wt.RECTANGLE?Vp(i.geometry):Kp(i)}catch(u){if(e.strict)throw u;h=i}const c={...r,"@context":"http://www.w3.org/ns/anno.jsonld",id:r.id,type:"Annotation",body:Fm(r.bodies),created:n==null?void 0:n.toISOString(),creator:s,modified:o==null?void 0:o.toISOString(),target:{...l,source:t,selector:h}};return delete c.bodies,"annotation"in c.target&&delete c.target.annotation,c};function ch(r,t,e){const i=r.slice();return i[10]=t[e],i[12]=e,i}function uh(r){let t,e;return t=new Wi({props:{x:r[10][0],y:r[10][1],scale:r[3]}}),t.$on("pointerdown",function(){Ut(r[9](`HANDLE-${r[12]}`))&&r[9](`HANDLE-${r[12]}`).apply(this,arguments)}),{c(){ce(t.$$.fragment)},m(i,s){se(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||(ot(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){ne(t,i)}}}function km(r){let t,e,i,s,n,o,a,l,h,c,u,d=ii(r[4].points),f=[];for(let m=0;m<d.length;m+=1)f[m]=uh(ch(r,d,m));const p=m=>mt(f[m],1,1,()=>{f[m]=null});return{c(){t=yt("polygon"),s=ge(),n=yt("polygon"),a=ge();for(let m=0;m<f.length;m+=1)f[m].c();l=ye(),T(t,"class","a9s-outer"),T(t,"style",e=r[1]?"display:none;":void 0),T(t,"points",i=r[4].points.map(dh).join(" ")),T(n,"class","a9s-inner a9s-shape-handle"),T(n,"style",r[1]),T(n,"points",o=r[4].points.map(fh).join(" "))},m(m,_){it(m,t,_),it(m,s,_),it(m,n,_),it(m,a,_);for(let y=0;y<f.length;y+=1)f[y]&&f[y].m(m,_);it(m,l,_),h=!0,c||(u=[Dt(t,"pointerdown",function(){Ut(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Dt(n,"pointerdown",function(){Ut(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)})],c=!0)},p(m,_){if(r=m,(!h||_&2&&e!==(e=r[1]?"display:none;":void 0))&&T(t,"style",e),(!h||_&16&&i!==(i=r[4].points.map(dh).join(" ")))&&T(t,"points",i),(!h||_&2)&&T(n,"style",r[1]),(!h||_&16&&o!==(o=r[4].points.map(fh).join(" ")))&&T(n,"points",o),_&536){d=ii(r[4].points);let y;for(y=0;y<d.length;y+=1){const x=ch(r,d,y);f[y]?(f[y].p(x,_),ot(f[y],1)):(f[y]=uh(x),f[y].c(),ot(f[y],1),f[y].m(l.parentNode,l))}for(_e(),y=d.length;y<f.length;y+=1)p(y);ve()}},i(m){if(!h){for(let _=0;_<d.length;_+=1)ot(f[_]);h=!0}},o(m){f=f.filter(Boolean);for(let _=0;_<f.length;_+=1)mt(f[_]);h=!1},d(m){m&&(et(t),et(s),et(n),et(a),et(l)),fo(f,m),c=!1,Pe(u)}}}function Gm(r){let t,e;return t=new vh({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[km,({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(){ce(t.$$.fragment)},m(i,s){se(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||(ot(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){ne(t,i)}}}const dh=r=>r.join(","),fh=r=>r.join(",");function $m(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 _=d.geometry;f==="SHAPE"?m=_.points.map(([x,g])=>[x+p[0],g+p[1]]):m=_.points.map(([x,g],v)=>f===`HANDLE-${v}`?[x+p[0],g+p[1]]:[x,g]);const y=Bs(m);return{...d,geometry:{points:m,bounds:y}}};function h(d){Ze.call(this,r,d)}function c(d){Ze.call(this,r,d)}function u(d){Ze.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,c,u]}class Hm extends de{constructor(t){super(),ue(this,t,$m,Gm,qt,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}const So=(r,t)=>{const e=Math.abs(t[0]-r[0]),i=Math.abs(t[1]-r[1]);return Math.sqrt(Math.pow(e,2)+Math.pow(i,2))},ni=[];function Xm(r,t=At){let e;const i=new Set;function s(a){if(qt(r,a)&&(r=a,e)){const l=!ni.length;for(const h of i)h[1](),ni.push(h,r);if(l){for(let h=0;h<ni.length;h+=2)ni[h][0](ni[h+1]);ni.length=0}}}function n(a){s(a(r))}function o(a,l=At){const h=[a,l];return i.add(h),i.size===1&&(e=t(s,n)||At),a(r),()=>{i.delete(h),i.size===0&&e&&(e(),e=null)}}return{set:s,update:n,subscribe:o}}const Vm=(r,t)=>{const{naturalWidth:e,naturalHeight:i}=r;if(!e&&!i){const{width:s,height:n}=r;t.setAttribute("viewBox",`0 0 ${s} ${n}`),r.addEventListener("load",o=>{const a=o.target;t.setAttribute("viewBox",`0 0 ${a.naturalWidth} ${a.naturalHeight}`)})}else t.setAttribute("viewBox",`0 0 ${e} ${i}`)},zm=(r,t)=>{Vm(r,t);const{subscribe:e,set:i}=Xm(1);let s;return window.ResizeObserver&&(s=new ResizeObserver(()=>{const n=t.getBoundingClientRect(),{width:o,height:a}=t.viewBox.baseVal,l=Math.max(n.width/o,n.height/a);i(l)}),s.observe(t.parentElement)),{destroy:()=>{s&&s.disconnect()},subscribe:e}},ph=typeof window>"u"||typeof navigator>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0;function Wm(r){let t,e,i,s,n,o;return{c(){t=yt("rect"),T(t,"class",e=Rs(`a9s-handle ${r[8].class||""}`.trim())+" svelte-1sgkh33"),T(t,"x",i=r[0]-r[5]/2),T(t,"y",s=r[1]-r[5]/2),T(t,"width",r[5]),T(t,"height",r[5])},m(a,l){it(a,t,l),n||(o=Dt(t,"pointerdown",r[11]),n=!0)},p(a,l){l&256&&e!==(e=Rs(`a9s-handle ${a[8].class||""}`.trim())+" svelte-1sgkh33")&&T(t,"class",e),l&33&&i!==(i=a[0]-a[5]/2)&&T(t,"x",i),l&34&&s!==(s=a[1]-a[5]/2)&&T(t,"y",s),l&32&&T(t,"width",a[5]),l&32&&T(t,"height",a[5])},d(a){a&&et(t),n=!1,o()}}}function jm(r){let t,e,i,s,n,o,a,l,h;return{c(){t=yt("g"),e=yt("circle"),s=yt("rect"),T(e,"cx",r[0]),T(e,"cy",r[1]),T(e,"r",i=r[3]/r[2]),T(e,"class","a9s-touch-halo svelte-1sgkh33"),fr(e,"touched",r[4]),T(s,"class",n=Rs(`a9s-handle ${r[8].class||""}`.trim())+" svelte-1sgkh33"),T(s,"x",o=r[0]-r[5]/2),T(s,"y",a=r[1]-r[5]/2),T(s,"width",r[5]),T(s,"height",r[5]),T(t,"class","a9s-touch-handle")},m(c,u){it(c,t,u),Me(t,e),Me(t,s),l||(h=[Dt(e,"pointerdown",r[10]),Dt(e,"pointerdown",r[6]),Dt(e,"pointerup",r[7]),Dt(s,"pointerdown",r[9]),Dt(s,"pointerdown",r[6]),Dt(s,"pointerup",r[7])],l=!0)},p(c,u){u&1&&T(e,"cx",c[0]),u&2&&T(e,"cy",c[1]),u&12&&i!==(i=c[3]/c[2])&&T(e,"r",i),u&16&&fr(e,"touched",c[4]),u&256&&n!==(n=Rs(`a9s-handle ${c[8].class||""}`.trim())+" svelte-1sgkh33")&&T(s,"class",n),u&33&&o!==(o=c[0]-c[5]/2)&&T(s,"x",o),u&34&&a!==(a=c[1]-c[5]/2)&&T(s,"y",a),u&32&&T(s,"width",c[5]),u&32&&T(s,"height",c[5])},d(c){c&&et(t),l=!1,Pe(h)}}}function Ym(r){let t;function e(s,n){return ph?jm:Wm}let i=e()(r);return{c(){i.c(),t=ye()},m(s,n){i.m(s,n),it(s,t,n)},p(s,[n]){i.p(s,n)},i:At,o:At,d(s){s&&et(t),i.d(s)}}}function qm(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)},c=()=>e(4,l=!1);function u(p){Ze.call(this,r,p)}function d(p){Ze.call(this,r,p)}function f(p){Ze.call(this,r,p)}return r.$$set=p=>{e(8,t=co(co({},t),ql(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=ql(t),[s,n,o,a,l,i,h,c,t,u,d,f]}class Wi extends de{constructor(t){super(),ue(this,t,qm,Ym,qt,{x:0,y:1,scale:2,radius:3})}}function Km(r){let t,e,i,s,n,o,a,l,h,c,u,d,f,p,m,_,y,x,g,v,w,I,A,C,N,S,R,E,b,D,F,G,$,B,Z,P,U,j,rt,Q,H,V,lt;return B=new Wi({props:{class:"a9s-corner-handle-topleft",x:r[4].x,y:r[4].y,scale:r[3]}}),B.$on("pointerdown",function(){Ut(r[9]("TOP_LEFT"))&&r[9]("TOP_LEFT").apply(this,arguments)}),P=new Wi({props:{class:"a9s-corner-handle-topright",x:r[4].x+r[4].w,y:r[4].y,scale:r[3]}}),P.$on("pointerdown",function(){Ut(r[9]("TOP_RIGHT"))&&r[9]("TOP_RIGHT").apply(this,arguments)}),j=new Wi({props:{class:"a9s-corner-handle-bottomright",x:r[4].x+r[4].w,y:r[4].y+r[4].h,scale:r[3]}}),j.$on("pointerdown",function(){Ut(r[9]("BOTTOM_RIGHT"))&&r[9]("BOTTOM_RIGHT").apply(this,arguments)}),Q=new Wi({props:{class:"a9s-corner-handle-bottomleft",x:r[4].x,y:r[4].y+r[4].h,scale:r[3]}}),Q.$on("pointerdown",function(){Ut(r[9]("BOTTOM_LEFT"))&&r[9]("BOTTOM_LEFT").apply(this,arguments)}),{c(){t=yt("rect"),a=ge(),l=yt("rect"),f=ge(),p=yt("rect"),x=ge(),g=yt("rect"),A=ge(),C=yt("rect"),E=ge(),b=yt("rect"),$=ge(),ce(B.$$.fragment),Z=ge(),ce(P.$$.fragment),U=ge(),ce(j.$$.fragment),rt=ge(),ce(Q.$$.fragment),T(t,"class","a9s-outer"),T(t,"style",e=r[1]?"display:none;":void 0),T(t,"x",i=r[4].x),T(t,"y",s=r[4].y),T(t,"width",n=r[4].w),T(t,"height",o=r[4].h),T(l,"class","a9s-inner a9s-shape-handle"),T(l,"style",r[1]),T(l,"x",h=r[4].x),T(l,"y",c=r[4].y),T(l,"width",u=r[4].w),T(l,"height",d=r[4].h),T(p,"class","a9s-edge-handle a9s-edge-handle-top"),T(p,"x",m=r[4].x),T(p,"y",_=r[4].y),T(p,"height",1),T(p,"width",y=r[4].w),T(g,"class","a9s-edge-handle a9s-edge-handle-right"),T(g,"x",v=r[4].x+r[4].w),T(g,"y",w=r[4].y),T(g,"height",I=r[4].h),T(g,"width",1),T(C,"class","a9s-edge-handle a9s-edge-handle-bottom"),T(C,"x",N=r[4].x),T(C,"y",S=r[4].y+r[4].h),T(C,"height",1),T(C,"width",R=r[4].w),T(b,"class","a9s-edge-handle a9s-edge-handle-left"),T(b,"x",D=r[4].x),T(b,"y",F=r[4].y),T(b,"height",G=r[4].h),T(b,"width",1)},m(L,O){it(L,t,O),it(L,a,O),it(L,l,O),it(L,f,O),it(L,p,O),it(L,x,O),it(L,g,O),it(L,A,O),it(L,C,O),it(L,E,O),it(L,b,O),it(L,$,O),se(B,L,O),it(L,Z,O),se(P,L,O),it(L,U,O),se(j,L,O),it(L,rt,O),se(Q,L,O),H=!0,V||(lt=[Dt(t,"pointerdown",function(){Ut(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Dt(l,"pointerdown",function(){Ut(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Dt(p,"pointerdown",function(){Ut(r[9]("TOP"))&&r[9]("TOP").apply(this,arguments)}),Dt(g,"pointerdown",function(){Ut(r[9]("RIGHT"))&&r[9]("RIGHT").apply(this,arguments)}),Dt(C,"pointerdown",function(){Ut(r[9]("BOTTOM"))&&r[9]("BOTTOM").apply(this,arguments)}),Dt(b,"pointerdown",function(){Ut(r[9]("LEFT"))&&r[9]("LEFT").apply(this,arguments)})],V=!0)},p(L,O){r=L,(!H||O&2&&e!==(e=r[1]?"display:none;":void 0))&&T(t,"style",e),(!H||O&16&&i!==(i=r[4].x))&&T(t,"x",i),(!H||O&16&&s!==(s=r[4].y))&&T(t,"y",s),(!H||O&16&&n!==(n=r[4].w))&&T(t,"width",n),(!H||O&16&&o!==(o=r[4].h))&&T(t,"height",o),(!H||O&2)&&T(l,"style",r[1]),(!H||O&16&&h!==(h=r[4].x))&&T(l,"x",h),(!H||O&16&&c!==(c=r[4].y))&&T(l,"y",c),(!H||O&16&&u!==(u=r[4].w))&&T(l,"width",u),(!H||O&16&&d!==(d=r[4].h))&&T(l,"height",d),(!H||O&16&&m!==(m=r[4].x))&&T(p,"x",m),(!H||O&16&&_!==(_=r[4].y))&&T(p,"y",_),(!H||O&16&&y!==(y=r[4].w))&&T(p,"width",y),(!H||O&16&&v!==(v=r[4].x+r[4].w))&&T(g,"x",v),(!H||O&16&&w!==(w=r[4].y))&&T(g,"y",w),(!H||O&16&&I!==(I=r[4].h))&&T(g,"height",I),(!H||O&16&&N!==(N=r[4].x))&&T(C,"x",N),(!H||O&16&&S!==(S=r[4].y+r[4].h))&&T(C,"y",S),(!H||O&16&&R!==(R=r[4].w))&&T(C,"width",R),(!H||O&16&&D!==(D=r[4].x))&&T(b,"x",D),(!H||O&16&&F!==(F=r[4].y))&&T(b,"y",F),(!H||O&16&&G!==(G=r[4].h))&&T(b,"height",G);const _t={};O&16&&(_t.x=r[4].x),O&16&&(_t.y=r[4].y),O&8&&(_t.scale=r[3]),B.$set(_t);const ht={};O&16&&(ht.x=r[4].x+r[4].w),O&16&&(ht.y=r[4].y),O&8&&(ht.scale=r[3]),P.$set(ht);const vt={};O&16&&(vt.x=r[4].x+r[4].w),O&16&&(vt.y=r[4].y+r[4].h),O&8&&(vt.scale=r[3]),j.$set(vt);const xt={};O&16&&(xt.x=r[4].x),O&16&&(xt.y=r[4].y+r[4].h),O&8&&(xt.scale=r[3]),Q.$set(xt)},i(L){H||(ot(B.$$.fragment,L),ot(P.$$.fragment,L),ot(j.$$.fragment,L),ot(Q.$$.fragment,L),H=!0)},o(L){mt(B.$$.fragment,L),mt(P.$$.fragment,L),mt(j.$$.fragment,L),mt(Q.$$.fragment,L),H=!1},d(L){L&&(et(t),et(a),et(l),et(f),et(p),et(x),et(g),et(A),et(C),et(E),et(b),et($),et(Z),et(U),et(rt)),ne(B,L),ne(P,L),ne(j,L),ne(Q,L),V=!1,Pe(lt)}}}function Zm(r){let t,e;return t=new vh({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[Km,({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(){ce(t.$$.fragment)},m(i,s){se(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||(ot(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){ne(t,i)}}}function Jm(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],[x,g]=[m.maxX,m.maxY];const[v,w]=p;if(f==="SHAPE")_+=v,x+=v,y+=w,g+=w;else{switch(f){case"TOP":case"TOP_LEFT":case"TOP_RIGHT":{y+=w;break}case"BOTTOM":case"BOTTOM_LEFT":case"BOTTOM_RIGHT":{g+=w;break}}switch(f){case"LEFT":case"TOP_LEFT":case"BOTTOM_LEFT":{_+=v;break}case"RIGHT":case"TOP_RIGHT":case"BOTTOM_RIGHT":{x+=v;break}}}const I=Math.min(_,x),A=Math.min(y,g),C=Math.abs(x-_),N=Math.abs(g-y);return{...d,geometry:{x:I,y:A,w:C,h:N,bounds:{minX:I,minY:A,maxX:I+C,maxY:A+N}}}};function h(d){Ze.call(this,r,d)}function c(d){Ze.call(this,r,d)}function u(d){Ze.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,c,u]}class Qm extends de{constructor(t){super(),ue(this,t,Jm,Zm,qt,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}const mh=new Map([[wt.RECTANGLE,Qm],[wt.POLYGON,Hm]]),gh=r=>mh.get(r.type),yh=(r,t)=>mh.set(r,t),tg=r=>({}),_h=r=>({grab:r[0]});function eg(r){let t,e,i,s;const n=r[7].default,o=Ip(n,r,r[6],_h);return{c(){t=yt("g"),o&&o.c(),T(t,"class","a9s-annotation selected")},m(a,l){it(a,t,l),o&&o.m(t,null),e=!0,i||(s=[Dt(t,"pointerup",r[2]),Dt(t,"pointermove",r[1])],i=!0)},p(a,[l]){o&&o.p&&(!e||l&64)&&Rp(o,n,a,a[6],e?Cp(n,a[6],l,tg):Pp(a[6]),_h)},i(a){e||(ot(o,a),e=!0)},o(a){mt(o,a),e=!1},d(a){a&&et(t),o&&o.d(a),i=!1,Pe(s)}}}function rg(r,t,e){let{$$slots:i={},$$scope:s}=t;const n=Qr();let{shape:o}=t,{editor:a}=t,{transform:l}=t,h,c,u;const d=m=>_=>{h=m,c=l.elementToImage(_.offsetX,_.offsetY),u=o,_.target.setPointerCapture(_.pointerId),n("grab",_)},f=m=>{if(h){const[_,y]=l.elementToImage(m.offsetX,m.offsetY),x=[_-c[0],y-c[1]];e(3,o=a(u,h,x)),n("change",o)}},p=m=>{m.target.releasePointerCapture(m.pointerId),h=void 0,u=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 vh extends de{constructor(t){super(),ue(this,t,rg,eg,qt,{shape:3,editor:4,transform:5})}}const Ns=(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 ig(r,t,e){let i;const s=Qr();let{annotation:n}=t,{editor:o}=t,{style:a}=t,{target:l}=t,{transform:h}=t,{viewportScale:c}=t,u;return zi(()=>(e(6,u=new o({target:l,props:{shape:n.target.selector,computedStyle:i,transform:h,viewportScale:c}})),u.$on("change",d=>{u.$$set({shape:d.detail}),s("change",d.detail)}),u.$on("grab",d=>s("grab",d.detail)),u.$on("release",d=>s("release",d.detail)),()=>{u.$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,c=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&5&&e(7,i=Ns(n,a)),r.$$.dirty&65&&n&&(u==null||u.$set({shape:n.target.selector})),r.$$.dirty&80&&u&&u.$set({transform:h}),r.$$.dirty&96&&u&&u.$set({viewportScale:c}),r.$$.dirty&192&&u&&i&&u.$set({computedStyle:i})},[n,o,a,l,h,c,u,i]}class sg extends de{constructor(t){super(),ue(this,t,ig,null,qt,{annotation:0,editor:1,style:2,target:3,transform:4,viewportScale:5})}}function ng(r,t,e){const i=Qr();let{drawingMode:s}=t,{target:n}=t,{tool:o}=t,{transform:a}=t,{viewportScale:l}=t,h;return zi(()=>{const c=n.closest("svg"),u=[],d=(f,p,m)=>{c==null||c.addEventListener(f,p,m),u.push(()=>c==null?void 0:c.removeEventListener(f,p,m))};return e(5,h=new o({target:n,props:{addEventListener:d,drawingMode:s,transform:a,viewportScale:l}})),h.$on("create",f=>i("create",f.detail)),()=>{u.forEach(f=>f()),h.$destroy()}}),r.$$set=c=>{"drawingMode"in c&&e(0,s=c.drawingMode),"target"in c&&e(1,n=c.target),"tool"in c&&e(2,o=c.tool),"transform"in c&&e(3,a=c.transform),"viewportScale"in c&&e(4,l=c.viewportScale)},r.$$.update=()=>{r.$$.dirty&40&&h&&h.$set({transform:a}),r.$$.dirty&48&&h&&h.$set({viewportScale:l})},[s,n,o,a,l,h]}class og extends de{constructor(t){super(),ue(this,t,ng,null,qt,{drawingMode:0,target:1,tool:2,transform:3,viewportScale:4})}}function xh(r){let t,e;return{c(){t=yt("rect"),e=yt("rect"),T(t,"class","a9s-outer"),T(t,"x",r[1]),T(t,"y",r[2]),T(t,"width",r[3]),T(t,"height",r[4]),T(e,"class","a9s-inner"),T(e,"x",r[1]),T(e,"y",r[2]),T(e,"width",r[3]),T(e,"height",r[4])},m(i,s){it(i,t,s),it(i,e,s)},p(i,s){s&2&&T(t,"x",i[1]),s&4&&T(t,"y",i[2]),s&8&&T(t,"width",i[3]),s&16&&T(t,"height",i[4]),s&2&&T(e,"x",i[1]),s&4&&T(e,"y",i[2]),s&8&&T(e,"width",i[3]),s&16&&T(e,"height",i[4])},d(i){i&&(et(t),et(e))}}}function ag(r){let t,e=r[0]&&xh(r);return{c(){t=yt("g"),e&&e.c(),T(t,"class","a9s-annotation a9s-rubberband")},m(i,s){it(i,t,s),e&&e.m(t,null)},p(i,[s]){i[0]?e?e.p(i,s):(e=xh(i),e.c(),e.m(t,null)):e&&(e.d(1),e=null)},i:At,o:At,d(i){i&&et(t),e&&e.d()}}}function lg(r,t,e){const i=Qr();let{addEventListener:s}=t,{drawingMode:n}=t,{transform:o}=t,a,l,h,c,u,d,f;const p=x=>{const g=x;a=performance.now(),n==="drag"&&(e(0,l=o.elementToImage(g.offsetX,g.offsetY)),h=l,e(1,c=l[0]),e(2,u=l[1]),e(3,d=1),e(4,f=1))},m=x=>{const g=x;l&&(h=o.elementToImage(g.offsetX,g.offsetY),e(1,c=Math.min(h[0],l[0])),e(2,u=Math.min(h[1],l[1])),e(3,d=Math.abs(h[0]-l[0])),e(4,f=Math.abs(h[1]-l[1])))},_=x=>{const g=x,v=performance.now()-a;if(n==="click"){if(v>300)return;l?y():(e(0,l=o.elementToImage(g.offsetX,g.offsetY)),h=l,e(1,c=l[0]),e(2,u=l[1]),e(3,d=1),e(4,f=1))}else l&&(v>300||d*f>100?(g.stopPropagation(),y()):(e(0,l=void 0),h=void 0))},y=()=>{if(d*f>15){const x={type:wt.RECTANGLE,geometry:{bounds:{minX:c,minY:u,maxX:c+d,maxY:u+f},x:c,y:u,w:d,h:f}};i("create",x)}e(0,l=void 0),h=void 0};return zi(()=>{s("pointerdown",p),s("pointermove",m),s("pointerup",_,!0)}),r.$$set=x=>{"addEventListener"in x&&e(5,s=x.addEventListener),"drawingMode"in x&&e(6,n=x.drawingMode),"transform"in x&&e(7,o=x.transform)},[l,c,u,d,f,s,n,o]}class hg extends de{constructor(t){super(),ue(this,t,lg,ag,qt,{addEventListener:5,drawingMode:6,transform:7})}}function Io(r){const t=r.slice(),e=(t[2]?t[0]:[...t[0],t[1]]).map(i=>i.join(",")).join(" ");return t[16]=e,t}function bh(r){let t,e,i,s,n,o=r[2]&&wh(r);return{c(){t=yt("polygon"),i=yt("polygon"),o&&o.c(),n=ye(),T(t,"class","a9s-outer"),T(t,"points",e=r[16]),T(i,"class","a9s-inner"),T(i,"points",s=r[16])},m(a,l){it(a,t,l),it(a,i,l),o&&o.m(a,l),it(a,n,l)},p(a,l){l&7&&e!==(e=a[16])&&T(t,"points",e),l&7&&s!==(s=a[16])&&T(i,"points",s),a[2]?o?o.p(a,l):(o=wh(a),o.c(),o.m(n.parentNode,n)):o&&(o.d(1),o=null)},d(a){a&&(et(t),et(i),et(n)),o&&o.d(a)}}}function wh(r){let t,e,i;return{c(){t=yt("rect"),T(t,"class","a9s-corner-handle"),T(t,"x",e=r[0][0][0]-r[3]/2),T(t,"y",i=r[0][0][1]-r[3]/2),T(t,"height",r[3]),T(t,"width",r[3])},m(s,n){it(s,t,n)},p(s,n){n&9&&e!==(e=s[0][0][0]-s[3]/2)&&T(t,"x",e),n&9&&i!==(i=s[0][0][1]-s[3]/2)&&T(t,"y",i),n&8&&T(t,"height",s[3]),n&8&&T(t,"width",s[3])},d(s){s&&et(t)}}}function cg(r){let t,e=r[1]&&bh(Io(r));return{c(){t=yt("g"),e&&e.c(),T(t,"class","a9s-annotation a9s-rubberband")},m(i,s){it(i,t,s),e&&e.m(t,null)},p(i,[s]){i[1]?e?e.p(Io(i),s):(e=bh(Io(i)),e.c(),e.m(t,null)):e&&(e.d(1),e=null)},i:At,o:At,d(i){i&&et(t),e&&e.d()}}}const ug=20,dg=1500;function fg(r,t,e){let i;const s=Qr();let{addEventListener:n}=t,{drawingMode:o}=t,{transform:a}=t,{viewportScale:l=1}=t,h,c=[],u,d,f=!1;const p=g=>{const v=g,{timeStamp:w,offsetX:I,offsetY:A}=v;if(h={timeStamp:w,offsetX:I,offsetY:A},o==="drag"&&c.length===0){const C=a.elementToImage(v.offsetX,v.offsetY);c.push(C),e(1,u=C)}},m=g=>{const v=g;if(d&&clearTimeout(d),c.length>0){if(e(1,u=a.elementToImage(v.offsetX,v.offsetY)),c.length>2){const w=So(u,c[0])*l;e(2,f=w<ug)}v.pointerType==="touch"&&(d=setTimeout(()=>{y()},dg))}},_=g=>{const v=g;if(d&&clearTimeout(d),o==="click"){const w=v.timeStamp-h.timeStamp,I=So([h.offsetX,h.offsetY],[v.offsetX,v.offsetY]);if(w>300||I>15)return;if(f)x();else if(c.length===0){const A=a.elementToImage(v.offsetX,v.offsetY);c.push(A),e(1,u=A)}else c.push(u)}else{if(c.length===1&&So(c[0],u)<=4){e(0,c=[]),e(1,u=void 0);return}v.stopImmediatePropagation(),f?x():c.push(u)}},y=()=>{if(!u)return;const g=[...c,u],v={type:wt.POLYGON,geometry:{bounds:Bs(g),points:g}};vo(v)>4&&(e(0,c=[]),e(1,u=void 0),s("create",v))},x=()=>{const g={type:wt.POLYGON,geometry:{bounds:Bs(c),points:[...c]}};e(0,c=[]),e(1,u=void 0),s("create",g)};return zi(()=>{n("pointerdown",p,!0),n("pointermove",m),n("pointerup",_,!0),n("dblclick",y,!0)}),r.$$set=g=>{"addEventListener"in g&&e(4,n=g.addEventListener),"drawingMode"in g&&e(5,o=g.drawingMode),"transform"in g&&e(6,a=g.transform),"viewportScale"in g&&e(7,l=g.viewportScale)},r.$$.update=()=>{r.$$.dirty&128&&e(3,i=10/l)},[c,u,f,i,n,o,a,l]}class pg extends de{constructor(t){super(),ue(this,t,fg,cg,qt,{addEventListener:4,drawingMode:5,transform:6,viewportScale:7})}}const Co=new Map([["rectangle",{tool:hg}],["polygon",{tool:pg}]]),Us=()=>[...Co.keys()],ks=r=>Co.get(r),Eh=(r,t,e)=>Co.set(r,{tool:t,opts:e});function mg(r){let t,e,i,s,n;return{c(){t=yt("g"),e=yt("ellipse"),s=yt("ellipse"),T(e,"class","a9s-outer"),T(e,"style",i=r[1]?"display:none;":void 0),T(e,"cx",r[2]),T(e,"cy",r[3]),T(e,"rx",r[4]),T(e,"ry",r[5]),T(s,"class","a9s-inner"),T(s,"style",r[1]),T(s,"cx",r[2]),T(s,"cy",r[3]),T(s,"rx",r[4]),T(s,"ry",r[5]),T(t,"class","a9s-annotation"),T(t,"data-id",n=r[0].id)},m(o,a){it(o,t,a),Me(t,e),Me(t,s)},p(o,[a]){a&2&&i!==(i=o[1]?"display:none;":void 0)&&T(e,"style",i),a&2&&T(s,"style",o[1]),a&1&&n!==(n=o[0].id)&&T(t,"data-id",n)},i:At,o:At,d(o){o&&et(t)}}}function gg(r,t,e){let i,{annotation:s}=t,{geom:n}=t,{style:o}=t;const{cx:a,cy:l,rx:h,ry:c}=n;return r.$$set=u=>{"annotation"in u&&e(0,s=u.annotation),"geom"in u&&e(6,n=u.geom),"style"in u&&e(7,o=u.style)},r.$$.update=()=>{r.$$.dirty&129&&e(1,i=Ns(s,o))},[s,i,a,l,h,c,n,o]}class yg extends de{constructor(t){super(),ue(this,t,gg,mg,qt,{annotation:0,geom:6,style:7})}}function _g(r){let t,e,i,s,n;return{c(){t=yt("g"),e=yt("polygon"),s=yt("polygon"),T(e,"class","a9s-outer"),T(e,"style",i=r[1]?"display:none;":void 0),T(e,"points",r[2].map(vg).join(" ")),T(s,"class","a9s-inner"),T(s,"style",r[1]),T(s,"points",r[2].map(xg).join(" ")),T(t,"class","a9s-annotation"),T(t,"data-id",n=r[0].id)},m(o,a){it(o,t,a),Me(t,e),Me(t,s)},p(o,[a]){a&2&&i!==(i=o[1]?"display:none;":void 0)&&T(e,"style",i),a&2&&T(s,"style",o[1]),a&1&&n!==(n=o[0].id)&&T(t,"data-id",n)},i:At,o:At,d(o){o&&et(t)}}}const vg=r=>r.join(","),xg=r=>r.join(",");function bg(r,t,e){let i,{annotation:s}=t,{geom:n}=t,{style:o}=t;const{points:a}=n;return r.$$set=l=>{"annotation"in l&&e(0,s=l.annotation),"geom"in l&&e(3,n=l.geom),"style"in l&&e(4,o=l.style)},r.$$.update=()=>{r.$$.dirty&17&&e(1,i=Ns(s,o))},[s,i,a,n,o]}class wg extends de{constructor(t){super(),ue(this,t,bg,_g,qt,{annotation:0,geom:3,style:4})}}function Eg(r){let t,e,i,s,n;return{c(){t=yt("g"),e=yt("rect"),s=yt("rect"),T(e,"class","a9s-outer"),T(e,"style",i=r[5]?"display:none;":void 0),T(e,"x",r[4]),T(e,"y",r[3]),T(e,"width",r[2]),T(e,"height",r[1]),T(s,"class","a9s-inner"),T(s,"style",r[5]),T(s,"x",r[4]),T(s,"y",r[3]),T(s,"width",r[2]),T(s,"height",r[1]),T(t,"class","a9s-annotation"),T(t,"data-id",n=r[0].id)},m(o,a){it(o,t,a),Me(t,e),Me(t,s)},p(o,[a]){a&32&&i!==(i=o[5]?"display:none;":void 0)&&T(e,"style",i),a&16&&T(e,"x",o[4]),a&8&&T(e,"y",o[3]),a&4&&T(e,"width",o[2]),a&2&&T(e,"height",o[1]),a&32&&T(s,"style",o[5]),a&16&&T(s,"x",o[4]),a&8&&T(s,"y",o[3]),a&4&&T(s,"width",o[2]),a&2&&T(s,"height",o[1]),a&1&&n!==(n=o[0].id)&&T(t,"data-id",n)},i:At,o:At,d(o){o&&et(t)}}}function Tg(r,t,e){let i,s,n,o,a,{annotation:l}=t,{geom:h}=t,{style:c}=t;return r.$$set=u=>{"annotation"in u&&e(0,l=u.annotation),"geom"in u&&e(6,h=u.geom),"style"in u&&e(7,c=u.style)},r.$$.update=()=>{r.$$.dirty&129&&e(5,i=Ns(l,c)),r.$$.dirty&64&&e(4,{x:s,y:n,w:o,h:a}=h,s,(e(3,n),e(6,h)),(e(2,o),e(6,h)),(e(1,a),e(6,h)))},[l,a,o,n,s,i,h,c]}class Ag extends de{constructor(t){super(),ue(this,t,Tg,Eg,qt,{annotation:0,geom:6,style:7})}}const Sg=r=>({elementToImage:(t,e)=>{const i=r.getBoundingClientRect(),s=r.createSVGPoint();s.x=t+i.x,s.y=e+i.y;const{x:n,y:o}=s.matrixTransform(r.getScreenCTM().inverse());return[n,o]}}),Ig=250,Cg=(r,t)=>{const e=Qr();let i;return{onPointerDown:()=>i=performance.now(),onPointerUp:s=>{if(performance.now()-i<Ig){const{x:n,y:o}=Th(s,r),a=t.getAt(n,o);a?e("click",{originalEvent:s,annotation:a}):e("click",{originalEvent:s})}}}},Th=(r,t)=>{const e=t.createSVGPoint(),i=t.getBoundingClientRect(),s=r.clientX-i.x,n=r.clientY-i.y,{left:o,top:a}=t.getBoundingClientRect();return e.x=s+o,e.y=n+a,e.matrixTransform(t.getScreenCTM().inverse())};function Ah(r,t,e){const i=r.slice();i[37]=t[e];const s=i[23](i[37].target.selector);return i[38]=s,i}function Sh(r,t,e){const i=r.slice();return i[41]=t[e],i}function Ro(r){const t=r.slice(),e=t[41].target.selector;return t[44]=e,t}function Ih(r){let t=r[41].id,e,i,s=Ch(r);return{c(){s.c(),e=ye()},m(n,o){s.m(n,o),it(n,e,o),i=!0},p(n,o){o[0]&32768&&qt(t,t=n[41].id)?(_e(),mt(s,1,1,At),ve(),s=Ch(n),s.c(),ot(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(ot(s),i=!0)},o(n){mt(s),i=!1},d(n){n&&et(e),s.d(n)}}}function Rg(r){let t,e;return t=new wg({props:{annotation:r[41],geom:r[44].geometry,style:r[1]}}),{c(){ce(t.$$.fragment)},m(i,s){se(t,i,s),e=!0},p(i,s){const n={};s[0]&32768&&(n.annotation=i[41]),s[0]&32768&&(n.geom=i[44].geometry),s[0]&2&&(n.style=i[1]),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){ne(t,i)}}}function Pg(r){let t,e;return t=new Ag({props:{annotation:r[41],geom:r[44].geometry,style:r[1]}}),{c(){ce(t.$$.fragment)},m(i,s){se(t,i,s),e=!0},p(i,s){const n={};s[0]&32768&&(n.annotation=i[41]),s[0]&32768&&(n.geom=i[44].geometry),s[0]&2&&(n.style=i[1]),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){ne(t,i)}}}function Mg(r){var t;let e,i;return e=new yg({props:{annotation:r[41],geom:(t=r[44])==null?void 0:t.geometry,style:r[1]}}),{c(){ce(e.$$.fragment)},m(s,n){se(e,s,n),i=!0},p(s,n){var o;const a={};n[0]&32768&&(a.annotation=s[41]),n[0]&32768&&(a.geom=(o=s[44])==null?void 0:o.geometry),n[0]&2&&(a.style=s[1]),e.$set(a)},i(s){i||(ot(e.$$.fragment,s),i=!0)},o(s){mt(e.$$.fragment,s),i=!1},d(s){ne(e,s)}}}function Ch(r){let t,e,i,s;const n=[Mg,Pg,Rg],o=[];function a(l,h){var c,u,d;return((c=l[44])==null?void 0:c.type)===wt.ELLIPSE?0:((u=l[44])==null?void 0:u.type)===wt.RECTANGLE?1:((d=l[44])==null?void 0:d.type)===wt.POLYGON?2:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=ye()},m(l,h){~t&&o[t].m(l,h),it(l,i,h),s=!0},p(l,h){let c=t;t=a(l),t===c?~t&&o[t].p(l,h):(e&&(_e(),mt(o[c],1,1,()=>{o[c]=null}),ve()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=n[t](l),e.c()),ot(e,1),e.m(i.parentNode,i)):e=null)},i(l){s||(ot(e),s=!0)},o(l){mt(e),s=!1},d(l){l&&et(i),~t&&o[t].d(l)}}}function Rh(r){let t=Je(r[41])&&!r[8](r[41]),e,i,s=t&&Ih(Ro(r));return{c(){s&&s.c(),e=ye()},m(n,o){s&&s.m(n,o),it(n,e,o),i=!0},p(n,o){o[0]&33024&&(t=Je(n[41])&&!n[8](n[41])),t?s?(s.p(Ro(n),o),o[0]&33024&&ot(s,1)):(s=Ih(Ro(n)),s.c(),ot(s,1),s.m(e.parentNode,e)):s&&(_e(),mt(s,1,1,()=>{s=null}),ve())},i(n){i||(ot(s),i=!0)},o(n){mt(s),i=!1},d(n){n&&et(e),s&&s.d(n)}}}function Ph(r){let t,e,i,s;const n=[Dg,Bg],o=[];function a(l,h){return l[7]?0:l[13]&&l[0]?1:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=ye()},m(l,h){~t&&o[t].m(l,h),it(l,i,h),s=!0},p(l,h){let c=t;t=a(l),t===c?~t&&o[t].p(l,h):(e&&(_e(),mt(o[c],1,1,()=>{o[c]=null}),ve()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=n[t](l),e.c()),ot(e,1),e.m(i.parentNode,i)):e=null)},i(l){s||(ot(e),s=!0)},o(l){mt(e),s=!1},d(l){l&&et(i),~t&&o[t].d(l)}}}function Bg(r){let t=r[2],e,i,s=Mh(r);return{c(){s.c(),e=ye()},m(n,o){s.m(n,o),it(n,e,o),i=!0},p(n,o){o[0]&4&&qt(t,t=n[2])?(_e(),mt(s,1,1,At),ve(),s=Mh(n),s.c(),ot(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(ot(s),i=!0)},o(n){mt(s),i=!1},d(n){n&&et(e),s.d(n)}}}function Dg(r){let t,e,i=ii(r[7]),s=[];for(let o=0;o<i.length;o+=1)s[o]=Oh(Ah(r,i,o));const n=o=>mt(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=ye()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);it(o,t,a),e=!0},p(o,a){if(a[0]&10553506){i=ii(o[7]);let l;for(l=0;l<i.length;l+=1){const h=Ah(o,i,l);s[l]?(s[l].p(h,a),ot(s[l],1)):(s[l]=Oh(h),s[l].c(),ot(s[l],1),s[l].m(t.parentNode,t))}for(_e(),l=i.length;l<s.length;l+=1)n(l);ve()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)ot(s[a]);e=!0}},o(o){s=s.filter(Boolean);for(let a=0;a<s.length;a+=1)mt(s[a]);e=!1},d(o){o&&et(t),fo(s,o)}}}function Mh(r){let t,e;return t=new og({props:{target:r[5],tool:r[13],drawingMode:r[12],transform:r[11],viewportScale:r[16]}}),t.$on("create",r[20]),{c(){ce(t.$$.fragment)},m(i,s){se(t,i,s),e=!0},p(i,s){const n={};s[0]&32&&(n.target=i[5]),s[0]&8192&&(n.tool=i[13]),s[0]&4096&&(n.drawingMode=i[12]),s[0]&2048&&(n.transform=i[11]),s[0]&65536&&(n.viewportScale=i[16]),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){ne(t,i)}}}function Bh(r){let t=r[37].id,e,i,s=Dh(r);return{c(){s.c(),e=ye()},m(n,o){s.m(n,o),it(n,e,o),i=!0},p(n,o){o[0]&128&&qt(t,t=n[37].id)?(_e(),mt(s,1,1,At),ve(),s=Dh(n),s.c(),ot(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(ot(s),i=!0)},o(n){mt(s),i=!1},d(n){n&&et(e),s.d(n)}}}function Dh(r){let t,e;return t=new sg({props:{target:r[5],editor:r[23](r[37].target.selector),annotation:r[37],style:r[1],transform:r[11],viewportScale:r[16]}}),t.$on("change",function(){Ut(r[21](r[37]))&&r[21](r[37]).apply(this,arguments)}),{c(){ce(t.$$.fragment)},m(i,s){se(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&32&&(n.target=r[5]),s[0]&128&&(n.editor=r[23](r[37].target.selector)),s[0]&128&&(n.annotation=r[37]),s[0]&2&&(n.style=r[1]),s[0]&2048&&(n.transform=r[11]),s[0]&65536&&(n.viewportScale=r[16]),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){ne(t,i)}}}function Oh(r){let t,e,i=r[38]&&Bh(r);return{c(){i&&i.c(),t=ye()},m(s,n){i&&i.m(s,n),it(s,t,n),e=!0},p(s,n){s[38]?i?(i.p(s,n),n[0]&128&&ot(i,1)):(i=Bh(s),i.c(),ot(i,1),i.m(t.parentNode,t)):i&&(_e(),mt(i,1,1,()=>{i=null}),ve())},i(s){e||(ot(i),e=!0)},o(s){mt(i),e=!1},d(s){s&&et(t),i&&i.d(s)}}}function Og(r){let t,e,i,s,n,o,a=ii(r[15].filter(r[32])),l=[];for(let u=0;u<a.length;u+=1)l[u]=Rh(Sh(r,a,u));const h=u=>mt(l[u],1,1,()=>{l[u]=null});let c=r[5]&&Ph(r);return{c(){t=yt("svg"),e=yt("g");for(let u=0;u<l.length;u+=1)l[u].c();i=yt("g"),c&&c.c(),T(i,"class","drawing"),T(t,"class","a9s-annotationlayer"),fr(t,"drawing",r[13]),fr(t,"hidden",!r[3]),fr(t,"hover",r[14])},m(u,d){it(u,t,d),Me(t,e);for(let f=0;f<l.length;f+=1)l[f]&&l[f].m(e,null);Me(t,i),c&&c.m(i,null),r[33](i),r[34](t),s=!0,n||(o=[Dt(t,"pointerup",function(){Ut(r[9])&&r[9].apply(this,arguments)}),Dt(t,"pointerdown",function(){Ut(r[10])&&r[10].apply(this,arguments)}),Dt(t,"pointermove",r[22])],n=!0)},p(u,d){if(r=u,d[0]&33026){a=ii(r[15].filter(r[32]));let f;for(f=0;f<a.length;f+=1){const p=Sh(r,a,f);l[f]?(l[f].p(p,d),ot(l[f],1)):(l[f]=Rh(p),l[f].c(),ot(l[f],1),l[f].m(e,null))}for(_e(),f=a.length;f<l.length;f+=1)h(f);ve()}r[5]?c?(c.p(r,d),d[0]&32&&ot(c,1)):(c=Ph(r),c.c(),ot(c,1),c.m(i,null)):c&&(_e(),mt(c,1,1,()=>{c=null}),ve()),(!s||d[0]&8192)&&fr(t,"drawing",r[13]),(!s||d[0]&8)&&fr(t,"hidden",!r[3]),(!s||d[0]&16384)&&fr(t,"hover",r[14])},i(u){if(!s){for(let d=0;d<a.length;d+=1)ot(l[d]);ot(c),s=!0}},o(u){l=l.filter(Boolean);for(let d=0;d<l.length;d+=1)mt(l[d]);mt(c),s=!1},d(u){u&&et(t),fo(l,u),c&&c.d(),r[33](null),r[34](null),n=!1,Pe(o)}}}function Fg(r,t,e){let i,s,n,o,a,l,h,c,u,d,f,p=At,m=()=>(p(),p=jl(E,V=>e(16,f=V)),E);r.$$.on_destroy.push(()=>p());let{drawingEnabled:_}=t,{image:y}=t,{preferredDrawingMode:x}=t,{state:g}=t,{style:v=void 0}=t,{toolName:w=Us()[0]}=t,{user:I}=t,{visible:A=!0}=t;const C=()=>w,N=()=>_;let S,R,E;zi(()=>m(e(6,E=zm(y,R))));const{hover:b,selection:D,store:F}=g;uo(r,b,V=>e(14,c=V)),uo(r,D,V=>e(31,u=V)),uo(r,F,V=>e(15,d=V));let G,$;const B=V=>{G&&F.unobserve(G);const lt=V.filter(({editable:L})=>L).map(({id:L})=>L);lt.length>0?(e(7,$=lt.map(L=>F.getAnnotation(L)).filter(L=>L&&Je(L))),G=L=>{const{updated:O}=L.changes;e(7,$=O==null?void 0:O.map(_t=>_t.newValue))},F.observe(G,{annotations:lt})):e(7,$=void 0)},Z=V=>{const lt=ih(),L={id:lt,bodies:[],target:{annotation:lt,selector:V.detail,creator:I,created:new Date}};F.addAnnotation(L),D.setSelected(L.id)},P=V=>lt=>{var L;const{target:O}=V,_t=10*60*1e3,ht=((L=O.creator)==null?void 0:L.id)!==I.id||!O.created||new Date().getTime()-O.created.getTime()>_t;F.updateTarget({...O,selector:lt.detail,created:ht?O.created:new Date,updated:ht?new Date:void 0,updatedBy:ht?I:void 0})},U=V=>{const{x:lt,y:L}=Th(V,R),O=F.getAt(lt,L);O?c!==O.id&&b.set(O.id):b.set(void 0)},j=V=>gh(V),rt=V=>Je(V);function Q(V){Ps[V?"unshift":"push"](()=>{S=V,e(5,S)})}function H(V){Ps[V?"unshift":"push"](()=>{R=V,e(4,R)})}return r.$$set=V=>{"drawingEnabled"in V&&e(0,_=V.drawingEnabled),"image"in V&&e(24,y=V.image),"preferredDrawingMode"in V&&e(25,x=V.preferredDrawingMode),"state"in V&&e(26,g=V.state),"style"in V&&e(1,v=V.style),"toolName"in V&&e(2,w=V.toolName),"user"in V&&e(27,I=V.user),"visible"in V&&e(3,A=V.visible)},r.$$.update=()=>{r.$$.dirty[0]&4&&e(13,{tool:i,opts:s}=ks(w)||{tool:void 0,opts:void 0},i,(e(30,s),e(2,w))),r.$$.dirty[0]&1107296256&&e(12,n=(s==null?void 0:s.drawingMode)||x),r.$$.dirty[0]&16&&e(11,o=Sg(R)),r.$$.dirty[0]&16&&e(10,{onPointerDown:a,onPointerUp:l}=Cg(R,F),a,(e(9,l),e(4,R))),r.$$.dirty[1]&1&&e(8,h=V=>u.selected.find(lt=>lt.id===V.id&<.editable)),r.$$.dirty[1]&1&&B(u.selected)},[_,v,w,A,R,S,E,$,h,l,a,o,n,i,c,d,f,b,D,F,Z,P,U,j,y,x,g,I,C,N,s,u,rt,Q,H]}class Lg extends de{constructor(t){super(),ue(this,t,Fg,Og,qt,{drawingEnabled:0,image:24,preferredDrawingMode:25,state:26,style:1,toolName:2,user:27,visible:3,getDrawingTool:28,isDrawingEnabled:29},null,[-1,-1])}get getDrawingTool(){return this.$$.ctx[28]}get isDrawingEnabled(){return this.$$.ctx[29]}}function Fh(r,t,e=0,i=r.length-1,s=Ng){for(;i>e;){if(i-e>600){const l=i-e+1,h=t-e+1,c=Math.log(l),u=.5*Math.exp(2*c/3),d=.5*Math.sqrt(c*u*(l-u)/l)*(h-l/2<0?-1:1),f=Math.max(e,Math.floor(t-h*u/l+d)),p=Math.min(i,Math.floor(t+(l-h)*u/l+d));Fh(r,t,f,p,s)}const n=r[t];let o=e,a=i;for(ji(r,e,t),s(r[i],n)>0&&ji(r,e,i);o<a;){for(ji(r,o,a),o++,a--;s(r[o],n)<0;)o++;for(;s(r[a],n)>0;)a--}s(r[e],n)===0?ji(r,e,a):(a++,ji(r,a,i)),a<=t&&(e=a+1),t<=a&&(i=a-1)}}function ji(r,t,e){const i=r[t];r[t]=r[e],r[e]=i}function Ng(r,t){return r<t?-1:r>t?1:0}class Ug{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(t){let e=this.data;const i=[];if(!$s(t,e))return i;const s=this.toBBox,n=[];for(;e;){for(let o=0;o<e.children.length;o++){const a=e.children[o],l=e.leaf?s(a):a;$s(t,l)&&(e.leaf?i.push(a):Mo(t,l)?this._all(a,i):n.push(a))}e=n.pop()}return i}collides(t){let e=this.data;if(!$s(t,e))return!1;const i=[];for(;e;){for(let s=0;s<e.children.length;s++){const n=e.children[s],o=e.leaf?this.toBBox(n):n;if($s(t,o)){if(e.leaf||Mo(t,o))return!0;i.push(n)}}e=i.pop()}return!1}load(t){if(!(t&&t.length))return this;if(t.length<this._minEntries){for(let i=0;i<t.length;i++)this.insert(t[i]);return this}let e=this._build(t.slice(),0,t.length-1,0);if(!this.data.children.length)this.data=e;else if(this.data.height===e.height)this._splitRoot(this.data,e);else{if(this.data.height<e.height){const i=this.data;this.data=e,e=i}this._insert(e,this.data.height-e.height-1,!0)}return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=ai([]),this}remove(t,e){if(!t)return this;let i=this.data;const s=this.toBBox(t),n=[],o=[];let a,l,h;for(;i||n.length;){if(i||(i=n.pop(),l=n[n.length-1],a=o.pop(),h=!0),i.leaf){const c=kg(t,i.children,e);if(c!==-1)return i.children.splice(c,1),n.push(i),this._condense(n),this}!h&&!i.leaf&&Mo(i,s)?(n.push(i),o.push(a),a=0,l=i,i=i.children[0]):l?(a++,i=l.children[a],h=!1):i=null}return this}toBBox(t){return t}compareMinX(t,e){return t.minX-e.minX}compareMinY(t,e){return t.minY-e.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,e){const i=[];for(;t;)t.leaf?e.push(...t.children):i.push(...t.children),t=i.pop();return e}_build(t,e,i,s){const n=i-e+1;let o=this._maxEntries,a;if(n<=o)return a=ai(t.slice(e,i+1)),oi(a,this.toBBox),a;s||(s=Math.ceil(Math.log(n)/Math.log(o)),o=Math.ceil(n/Math.pow(o,s-1))),a=ai([]),a.leaf=!1,a.height=s;const l=Math.ceil(n/o),h=l*Math.ceil(Math.sqrt(o));Lh(t,e,i,h,this.compareMinX);for(let c=e;c<=i;c+=h){const u=Math.min(c+h-1,i);Lh(t,c,u,l,this.compareMinY);for(let d=c;d<=u;d+=l){const f=Math.min(d+l-1,u);a.children.push(this._build(t,d,f,s-1))}}return oi(a,this.toBBox),a}_chooseSubtree(t,e,i,s){for(;s.push(e),!(e.leaf||s.length-1===i);){let n=1/0,o=1/0,a;for(let l=0;l<e.children.length;l++){const h=e.children[l],c=Po(h),u=Hg(t,h)-c;u<o?(o=u,n=c<n?c:n,a=h):u===o&&c<n&&(n=c,a=h)}e=a||e.children[0]}return e}_insert(t,e,i){const s=i?t:this.toBBox(t),n=[],o=this._chooseSubtree(s,this.data,e,n);for(o.children.push(t),qi(o,s);e>=0&&n[e].children.length>this._maxEntries;)this._split(n,e),e--;this._adjustParentBBoxes(s,n,e)}_split(t,e){const i=t[e],s=i.children.length,n=this._minEntries;this._chooseSplitAxis(i,n,s);const o=this._chooseSplitIndex(i,n,s),a=ai(i.children.splice(o,i.children.length-o));a.height=i.height,a.leaf=i.leaf,oi(i,this.toBBox),oi(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)}_splitRoot(t,e){this.data=ai([t,e]),this.data.height=t.height+1,this.data.leaf=!1,oi(this.data,this.toBBox)}_chooseSplitIndex(t,e,i){let s,n=1/0,o=1/0;for(let a=e;a<=i-e;a++){const l=Yi(t,0,a,this.toBBox),h=Yi(t,a,i,this.toBBox),c=Xg(l,h),u=Po(l)+Po(h);c<n?(n=c,s=a,o=u<o?u:o):c===n&&u<o&&(o=u,s=a)}return s||i-e}_chooseSplitAxis(t,e,i){const s=t.leaf?this.compareMinX:Gg,n=t.leaf?this.compareMinY:$g,o=this._allDistMargin(t,e,i,s),a=this._allDistMargin(t,e,i,n);o<a&&t.children.sort(s)}_allDistMargin(t,e,i,s){t.children.sort(s);const n=this.toBBox,o=Yi(t,0,e,n),a=Yi(t,i-e,i,n);let l=Gs(o)+Gs(a);for(let h=e;h<i-e;h++){const c=t.children[h];qi(o,t.leaf?n(c):c),l+=Gs(o)}for(let h=i-e-1;h>=e;h--){const c=t.children[h];qi(a,t.leaf?n(c):c),l+=Gs(a)}return l}_adjustParentBBoxes(t,e,i){for(let s=i;s>=0;s--)qi(e[s],t)}_condense(t){for(let e=t.length-1,i;e>=0;e--)t[e].children.length===0?e>0?(i=t[e-1].children,i.splice(i.indexOf(t[e]),1)):this.clear():oi(t[e],this.toBBox)}}function kg(r,t,e){if(!e)return t.indexOf(r);for(let i=0;i<t.length;i++)if(e(r,t[i]))return i;return-1}function oi(r,t){Yi(r,0,r.children.length,t,r)}function Yi(r,t,e,i,s){s||(s=ai(null)),s.minX=1/0,s.minY=1/0,s.maxX=-1/0,s.maxY=-1/0;for(let n=t;n<e;n++){const o=r.children[n];qi(s,r.leaf?i(o):o)}return s}function qi(r,t){return r.minX=Math.min(r.minX,t.minX),r.minY=Math.min(r.minY,t.minY),r.maxX=Math.max(r.maxX,t.maxX),r.maxY=Math.max(r.maxY,t.maxY),r}function Gg(r,t){return r.minX-t.minX}function $g(r,t){return r.minY-t.minY}function Po(r){return(r.maxX-r.minX)*(r.maxY-r.minY)}function Gs(r){return r.maxX-r.minX+(r.maxY-r.minY)}function Hg(r,t){return(Math.max(t.maxX,r.maxX)-Math.min(t.minX,r.minX))*(Math.max(t.maxY,r.maxY)-Math.min(t.minY,r.minY))}function Xg(r,t){const e=Math.max(r.minX,t.minX),i=Math.max(r.minY,t.minY),s=Math.min(r.maxX,t.maxX),n=Math.min(r.maxY,t.maxY);return Math.max(0,s-e)*Math.max(0,n-i)}function Mo(r,t){return r.minX<=t.minX&&r.minY<=t.minY&&t.maxX<=r.maxX&&t.maxY<=r.maxY}function $s(r,t){return t.minX<=r.maxX&&t.minY<=r.maxY&&t.maxX>=r.minX&&t.maxY>=r.minY}function ai(r){return{children:r,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Lh(r,t,e,i,s){const n=[t,e];for(;n.length;){if(e=n.pop(),t=n.pop(),e-t<=i)continue;const o=t+Math.ceil((e-t)/i/2)*i;Fh(r,o,t,e,s),n.push(t,o,o,e)}}const Vg=()=>{const r=new Ug,t=new Map,e=()=>[...t.values()],i=()=>{r.clear(),t.clear()},s=o=>{if(!Ds(o))return;const{minX:a,minY:l,maxX:h,maxY:c}=o.selector.geometry.bounds,u={minX:a,minY:l,maxX:h,maxY:c,target:o};r.insert(u),t.set(o.annotation,u)},n=o=>{if(!Ds(o))return;const a=t.get(o.annotation);a&&r.remove(a),t.delete(o.annotation)};return{all:e,clear:i,getAt:(o,a)=>{const l=r.search({minX:o,minY:a,maxX:o,maxY:a}).map(h=>h.target).filter(h=>h.selector.type===wt.RECTANGLE||kp(h.selector,o,a));if(l.length>0)return l.sort((h,c)=>vo(h.selector)-vo(c.selector)),l[0]},getIntersecting:(o,a,l,h)=>r.search({minX:o,minY:a,maxX:o+l,maxY:a+h}).map(c=>c.target),insert:s,remove:n,set:(o,a=!0)=>{a&&i();const l=o.reduce((h,c)=>{if(Ds(c)){const{minX:u,minY:d,maxX:f,maxY:p}=c.selector.geometry.bounds;return[...h,{minX:u,minY:d,maxX:f,maxY:p,target:c}]}else return h},[]);l.forEach(h=>t.set(h.target.annotation,h)),r.load(l)},size:()=>r.all().length,update:(o,a)=>{n(o),s(a)}}},Nh=r=>{const t=gm(),e=Vg(),i=im(t,r.userSelectAction,r.adapter),s=rm(t),n=bm();return t.observe(({changes:o})=>{e.set((o.created||[]).map(a=>a.target),!1),(o.deleted||[]).forEach(a=>e.remove(a.target)),(o.updated||[]).forEach(({oldValue:a,newValue:l})=>e.update(a.target,l.target))}),{store:{...t,getAt:(o,a)=>{const l=e.getAt(o,a);return l?t.getAnnotation(l.annotation):void 0},getIntersecting:(o,a,l,h)=>e.getIntersecting(o,a,l,h).map(c=>t.getAnnotation(c.annotation))},selection:i,hover:s,viewport:n}},zg=r=>{const t=Nh(r);return{...t,store:ym(t.store)}},Wg=r=>{let t,e;if(r.nodeName==="CANVAS")t=r,e=t.getContext("2d",{willReadFrequently:!0});else{const s=r;t=document.createElement("canvas"),t.width=s.width,t.height=s.height,e=t.getContext("2d",{willReadFrequently:!0}),e.drawImage(s,0,0,s.width,s.height)}let i=0;for(let s=1;s<10;s++)for(let n=1;n<10;n++){const o=Math.round(n*t.width/10),a=Math.round(s*t.height/10),l=e.getImageData(o,a,1,1).data,h=(.299*l[0]+.587*l[1]+.114*l[2])/255;i+=h}return i/81},Uh=r=>{const t=Wg(r),e=t>.6?"dark":"light";return console.log(`[Annotorious] Image brightness: ${t.toFixed(1)}. Setting ${e} theme.`),e},kh=(r,t,e)=>t.setAttribute("data-theme",e==="auto"?Uh(r):e),Gh=(r,t)=>({...r,drawingEnabled:r.drawingEnabled===void 0?t.drawingEnabled:r.drawingEnabled,drawingMode:r.drawingMode||t.drawingMode,userSelectAction:r.userSelectAction||t.userSelectAction,theme:r.theme||t.theme}),$h=typeof navigator>"u"?!1:navigator.userAgent.indexOf("Mac OS X")!==-1,Hh=(r,t)=>{const e=t||document,i=o=>{const a=o;a.key==="z"&&a.ctrlKey?r.undo():a.key==="y"&&a.ctrlKey&&r.redo()},s=o=>{const a=o;a.key==="z"&&a.metaKey&&(a.shiftKey?r.redo():r.undo())},n=()=>{$h?e.removeEventListener("keydown",s):e.removeEventListener("keydown",i)};return $h?e.addEventListener("keydown",s):e.addEventListener("keydown",i),{destroy:n}},jg=(r,t={})=>{if(!r)throw"Missing argument: image";const e=typeof r=="string"?document.getElementById(r):r,i=Gh(t,{drawingEnabled:!0,drawingMode:"drag",userSelectAction:nh.EDIT,theme:"light"}),s=zg(i),{selection:n,store:o}=s,a=xm(o),l=wm(s,a,i.adapter,i.autoSave),h=document.createElement("DIV");h.style.position="relative",h.style.display="inline-block",e.style.display="block",e.parentNode.insertBefore(h,e),h.appendChild(e);const c=Hh(a);let u=Bm();kh(e,h,i.theme);const d=new Lg({target:h,props:{drawingEnabled:!!i.drawingEnabled,image:e,preferredDrawingMode:i.drawingMode,state:s,style:i.style,user:u}});d.$on("click",E=>{const{originalEvent:b,annotation:D}=E.detail;D?n.userSelect(D.id,b):n.isEmpty()||n.clear()});const f=Tm(s,a,i.adapter),p=()=>{d.$set({drawingEnabled:!1}),setTimeout(()=>d.$set({drawingEnabled:!0}),1)},m=()=>{d.$destroy(),h.parentNode.insertBefore(e,h),h.parentNode.removeChild(h),c.destroy(),a.destroy()},_=()=>d.getDrawingTool(),y=()=>u,x=()=>d.isDrawingEnabled(),g=(E,b,D)=>Eh(E,b,D),v=(E,b)=>yh(E,b),w=E=>{if(!ks(E))throw`No drawing tool named ${E}`;d.$set({toolName:E})},I=E=>d.$set({drawingEnabled:E}),A=E=>{console.warn("Filter not implemented yet")},C=E=>d.$set({style:E}),N=E=>kh(e,h,E),S=E=>{u=E,d.$set({user:E})},R=E=>d.$set({visible:E});return{...f,cancelDrawing:p,destroy:m,getDrawingTool:_,getUser:y,isDrawingEnabled:x,listDrawingTools:Us,on:l.on,off:l.off,registerDrawingTool:g,registerShapeEditor:v,setDrawingEnabled:I,setDrawingTool:w,setFilter:A,setStyle:C,setTheme:N,setUser:S,setVisible:R,element:h,state:s}};function Be(){}function Bo(r,t){for(const e in t)r[e]=t[e];return r}function Xh(r){return r()}function Vh(){return Object.create(null)}function Qe(r){r.forEach(Xh)}function Kt(r){return typeof r=="function"}function te(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}function Yg(r){return Object.keys(r).length===0}function qg(r,...t){if(r==null){for(const i of t)i(void 0);return Be}const e=r.subscribe(...t);return e.unsubscribe?()=>e.unsubscribe():e}function Do(r,t,e){r.$$.on_destroy.push(qg(t,e))}function zh(r,t,e,i){if(r){const s=Wh(r,t,e,i);return r[0](s)}}function Wh(r,t,e,i){return r[1]&&i?Bo(e.ctx.slice(),r[1](i(t))):e.ctx}function jh(r,t,e,i){if(r[2]&&i){const s=r[2](i(e));if(t.dirty===void 0)return s;if(typeof s=="object"){const n=[],o=Math.max(t.dirty.length,s.length);for(let a=0;a<o;a+=1)n[a]=t.dirty[a]|s[a];return n}return t.dirty|s}return t.dirty}function Yh(r,t,e,i,s,n){if(s){const o=Wh(t,e,i,n);r.p(o,s)}}function qh(r){if(r.ctx.length>32){const t=[],e=r.ctx.length/32;for(let i=0;i<e;i++)t[i]=-1;return t}return-1}function Kh(r){const t={};for(const e in r)e[0]!=="$"&&(t[e]=r[e]);return t}function Hs(r){return r??""}const Kg=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global;function tr(r,t){r.appendChild(t)}function ft(r,t,e){r.insertBefore(t,e||null)}function ct(r){r.parentNode&&r.parentNode.removeChild(r)}function Oo(r,t){for(let e=0;e<r.length;e+=1)r[e]&&r[e].d(t)}function Tt(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function Fo(r){return document.createTextNode(r)}function xe(){return Fo(" ")}function er(){return Fo("")}function zt(r,t,e,i){return r.addEventListener(t,e,i),()=>r.removeEventListener(t,e,i)}function M(r,t,e){e==null?r.removeAttribute(t):r.getAttribute(t)!==e&&r.setAttribute(t,e)}function Zg(r){return Array.from(r.childNodes)}function Jg(r,t){t=""+t,r.data!==t&&(r.data=t)}function Xs(r,t,e){r.classList.toggle(t,!!e)}function Qg(r,t,{bubbles:e=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:t,bubbles:e,cancelable:i})}let Ki;function Zi(r){Ki=r}function Lo(){if(!Ki)throw new Error("Function called outside component initialization");return Ki}function Vs(r){Lo().$$.on_mount.push(r)}function ty(r){Lo().$$.on_destroy.push(r)}function zs(){const r=Lo();return(t,e,{cancelable:i=!1}={})=>{const s=r.$$.callbacks[t];if(s){const n=Qg(t,e,{cancelable:i});return s.slice().forEach(o=>{o.call(r,n)}),!n.defaultPrevented}return!0}}function rr(r,t){const e=r.$$.callbacks[t.type];e&&e.slice().forEach(i=>i.call(this,t))}const li=[],Ws=[];let hi=[];const Zh=[],ey=Promise.resolve();let No=!1;function ry(){No||(No=!0,ey.then(Jh))}function Uo(r){hi.push(r)}const ko=new Set;let ci=0;function Jh(){if(ci!==0)return;const r=Ki;do{try{for(;ci<li.length;){const t=li[ci];ci++,Zi(t),iy(t.$$)}}catch(t){throw li.length=0,ci=0,t}for(Zi(null),li.length=0,ci=0;Ws.length;)Ws.pop()();for(let t=0;t<hi.length;t+=1){const e=hi[t];ko.has(e)||(ko.add(e),e())}hi.length=0}while(li.length);for(;Zh.length;)Zh.pop()();No=!1,ko.clear(),Zi(r)}function iy(r){if(r.fragment!==null){r.update(),Qe(r.before_update);const t=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,t),r.after_update.forEach(Uo)}}function sy(r){const t=[],e=[];hi.forEach(i=>r.indexOf(i)===-1?t.push(i):e.push(i)),e.forEach(i=>i()),hi=t}const js=new Set;let Dr;function De(){Dr={r:0,c:[],p:Dr}}function Oe(){Dr.r||Qe(Dr.c),Dr=Dr.p}function st(r,t){r&&r.i&&(js.delete(r),r.i(t))}function ut(r,t,e,i){if(r&&r.o){if(js.has(r))return;js.add(r),Dr.c.push(()=>{js.delete(r),i&&(e&&r.d(1),i())}),r.o(t)}else i&&i()}function ui(r){return(r==null?void 0:r.length)!==void 0?r:Array.from(r)}function ee(r){r&&r.c()}function Zt(r,t,e){const{fragment:i,after_update:s}=r.$$;i&&i.m(t,e),Uo(()=>{const n=r.$$.on_mount.map(Xh).filter(Kt);r.$$.on_destroy?r.$$.on_destroy.push(...n):Qe(n),r.$$.on_mount=[]}),s.forEach(Uo)}function Jt(r,t){const e=r.$$;e.fragment!==null&&(sy(e.after_update),Qe(e.on_destroy),e.fragment&&e.fragment.d(t),e.on_destroy=e.fragment=null,e.ctx=[])}function ny(r,t){r.$$.dirty[0]===-1&&(li.push(r),ry(),r.$$.dirty.fill(0)),r.$$.dirty[t/31|0]|=1<<t%31}function oe(r,t,e,i,s,n,o=null,a=[-1]){const l=Ki;Zi(r);const h=r.$$={fragment:null,ctx:[],props:n,update:Be,not_equal:s,bound:Vh(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:Vh(),dirty:a,skip_bound:!1,root:t.target||l.$$.root};o&&o(h.root);let c=!1;if(h.ctx=e?e(r,t.props||{},(u,d,...f)=>{const p=f.length?f[0]:d;return h.ctx&&s(h.ctx[u],h.ctx[u]=p)&&(!h.skip_bound&&h.bound[u]&&h.bound[u](p),c&&ny(r,u)),d}):[],h.update(),c=!0,Qe(h.before_update),h.fragment=i?i(h.ctx):!1,t.target){if(t.hydrate){const u=Zg(t.target);h.fragment&&h.fragment.l(u),u.forEach(ct)}else h.fragment&&h.fragment.c();t.intro&&st(r.$$.fragment),Zt(r,t.target,t.anchor),Jh()}Zi(l)}class ae{constructor(){Fl(this,"$$");Fl(this,"$$set")}$destroy(){Jt(this,1),this.$destroy=Be}$on(t,e){if(!Kt(e))return Be;const i=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return i.push(e),()=>{const s=i.indexOf(e);s!==-1&&i.splice(s,1)}}$set(t){this.$$set&&!Yg(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const oy="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(oy);var Or=(r=>(r[r.WEBGL_LEGACY=0]="WEBGL_LEGACY",r[r.WEBGL=1]="WEBGL",r[r.WEBGL2=2]="WEBGL2",r))(Or||{}),Qh=(r=>(r[r.UNKNOWN=0]="UNKNOWN",r[r.WEBGL=1]="WEBGL",r[r.CANVAS=2]="CANVAS",r))(Qh||{}),Go=(r=>(r[r.COLOR=16384]="COLOR",r[r.DEPTH=256]="DEPTH",r[r.STENCIL=1024]="STENCIL",r))(Go||{}),tt=(r=>(r[r.NORMAL=0]="NORMAL",r[r.ADD=1]="ADD",r[r.MULTIPLY=2]="MULTIPLY",r[r.SCREEN=3]="SCREEN",r[r.OVERLAY=4]="OVERLAY",r[r.DARKEN=5]="DARKEN",r[r.LIGHTEN=6]="LIGHTEN",r[r.COLOR_DODGE=7]="COLOR_DODGE",r[r.COLOR_BURN=8]="COLOR_BURN",r[r.HARD_LIGHT=9]="HARD_LIGHT",r[r.SOFT_LIGHT=10]="SOFT_LIGHT",r[r.DIFFERENCE=11]="DIFFERENCE",r[r.EXCLUSION=12]="EXCLUSION",r[r.HUE=13]="HUE",r[r.SATURATION=14]="SATURATION",r[r.COLOR=15]="COLOR",r[r.LUMINOSITY=16]="LUMINOSITY",r[r.NORMAL_NPM=17]="NORMAL_NPM",r[r.ADD_NPM=18]="ADD_NPM",r[r.SCREEN_NPM=19]="SCREEN_NPM",r[r.NONE=20]="NONE",r[r.SRC_OVER=0]="SRC_OVER",r[r.SRC_IN=21]="SRC_IN",r[r.SRC_OUT=22]="SRC_OUT",r[r.SRC_ATOP=23]="SRC_ATOP",r[r.DST_OVER=24]="DST_OVER",r[r.DST_IN=25]="DST_IN",r[r.DST_OUT=26]="DST_OUT",r[r.DST_ATOP=27]="DST_ATOP",r[r.ERASE=26]="ERASE",r[r.SUBTRACT=28]="SUBTRACT",r[r.XOR=29]="XOR",r))(tt||{}),Fe=(r=>(r[r.POINTS=0]="POINTS",r[r.LINES=1]="LINES",r[r.LINE_LOOP=2]="LINE_LOOP",r[r.LINE_STRIP=3]="LINE_STRIP",r[r.TRIANGLES=4]="TRIANGLES",r[r.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",r[r.TRIANGLE_FAN=6]="TRIANGLE_FAN",r))(Fe||{}),k=(r=>(r[r.RGBA=6408]="RGBA",r[r.RGB=6407]="RGB",r[r.RG=33319]="RG",r[r.RED=6403]="RED",r[r.RGBA_INTEGER=36249]="RGBA_INTEGER",r[r.RGB_INTEGER=36248]="RGB_INTEGER",r[r.RG_INTEGER=33320]="RG_INTEGER",r[r.RED_INTEGER=36244]="RED_INTEGER",r[r.ALPHA=6406]="ALPHA",r[r.LUMINANCE=6409]="LUMINANCE",r[r.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",r[r.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",r[r.DEPTH_STENCIL=34041]="DEPTH_STENCIL",r))(k||{}),di=(r=>(r[r.TEXTURE_2D=3553]="TEXTURE_2D",r[r.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",r[r.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",r[r.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",r[r.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",r[r.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",r[r.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",r))(di||{}),J=(r=>(r[r.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",r[r.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",r[r.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",r[r.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",r[r.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",r[r.UNSIGNED_INT=5125]="UNSIGNED_INT",r[r.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",r[r.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",r[r.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",r[r.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",r[r.BYTE=5120]="BYTE",r[r.SHORT=5122]="SHORT",r[r.INT=5124]="INT",r[r.FLOAT=5126]="FLOAT",r[r.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",r[r.HALF_FLOAT=36193]="HALF_FLOAT",r))(J||{}),z=(r=>(r[r.FLOAT=0]="FLOAT",r[r.INT=1]="INT",r[r.UINT=2]="UINT",r))(z||{}),ir=(r=>(r[r.NEAREST=0]="NEAREST",r[r.LINEAR=1]="LINEAR",r))(ir||{}),mr=(r=>(r[r.CLAMP=33071]="CLAMP",r[r.REPEAT=10497]="REPEAT",r[r.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",r))(mr||{}),Le=(r=>(r[r.OFF=0]="OFF",r[r.POW2=1]="POW2",r[r.ON=2]="ON",r[r.ON_MANUAL=3]="ON_MANUAL",r))(Le||{}),ie=(r=>(r[r.NPM=0]="NPM",r[r.UNPACK=1]="UNPACK",r[r.PMA=2]="PMA",r[r.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",r[r.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",r[r.PREMULTIPLIED_ALPHA=2]="PREMULTIPLIED_ALPHA",r))(ie||{}),Ne=(r=>(r[r.NO=0]="NO",r[r.YES=1]="YES",r[r.AUTO=2]="AUTO",r[r.BLEND=0]="BLEND",r[r.CLEAR=1]="CLEAR",r[r.BLIT=2]="BLIT",r))(Ne||{}),$o=(r=>(r[r.AUTO=0]="AUTO",r[r.MANUAL=1]="MANUAL",r))($o||{}),fe=(r=>(r.LOW="lowp",r.MEDIUM="mediump",r.HIGH="highp",r))(fe||{}),Ft=(r=>(r[r.NONE=0]="NONE",r[r.SCISSOR=1]="SCISSOR",r[r.STENCIL=2]="STENCIL",r[r.SPRITE=3]="SPRITE",r[r.COLOR=4]="COLOR",r))(Ft||{}),Ot=(r=>(r[r.NONE=0]="NONE",r[r.LOW=2]="LOW",r[r.MEDIUM=4]="MEDIUM",r[r.HIGH=8]="HIGH",r))(Ot||{}),Ue=(r=>(r[r.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",r[r.ARRAY_BUFFER=34962]="ARRAY_BUFFER",r[r.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",r))(Ue||{});const W={ADAPTER:{createCanvas:(r,t)=>{const e=document.createElement("canvas");return e.width=r,e.height=t,e},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(r,t)=>fetch(r,t),parseXML:r=>new DOMParser().parseFromString(r,"text/xml")},RESOLUTION:1,CREATE_IMAGE_BITMAP:!1,ROUND_PIXELS:!1};var Ho=/iPhone/i,tc=/iPod/i,ec=/iPad/i,rc=/\biOS-universal(?:.+)Mac\b/i,Xo=/\bAndroid(?:.+)Mobile\b/i,ic=/Android/i,fi=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,Ys=/Silk/i,sr=/Windows Phone/i,sc=/\bWindows(?:.+)ARM\b/i,nc=/BlackBerry/i,oc=/BB10/i,ac=/Opera Mini/i,lc=/\b(CriOS|Chrome)(?:.+)Mobile/i,hc=/Mobile(?:.+)Firefox\b/i,cc=function(r){return typeof r<"u"&&r.platform==="MacIntel"&&typeof r.maxTouchPoints=="number"&&r.maxTouchPoints>1&&typeof MSStream>"u"};function ay(r){return function(t){return t.test(r)}}function uc(r){var t={userAgent:"",platform:"",maxTouchPoints:0};!r&&typeof navigator<"u"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof r=="string"?t.userAgent=r:r&&r.userAgent&&(t={userAgent:r.userAgent,platform:r.platform,maxTouchPoints:r.maxTouchPoints||0});var e=t.userAgent,i=e.split("[FBAN");typeof i[1]<"u"&&(e=i[0]),i=e.split("Twitter"),typeof i[1]<"u"&&(e=i[0]);var s=ay(e),n={apple:{phone:s(Ho)&&!s(sr),ipod:s(tc),tablet:!s(Ho)&&(s(ec)||cc(t))&&!s(sr),universal:s(rc),device:(s(Ho)||s(tc)||s(ec)||s(rc)||cc(t))&&!s(sr)},amazon:{phone:s(fi),tablet:!s(fi)&&s(Ys),device:s(fi)||s(Ys)},android:{phone:!s(sr)&&s(fi)||!s(sr)&&s(Xo),tablet:!s(sr)&&!s(fi)&&!s(Xo)&&(s(Ys)||s(ic)),device:!s(sr)&&(s(fi)||s(Ys)||s(Xo)||s(ic))||s(/\bokhttp\b/i)},windows:{phone:s(sr),tablet:s(sc),device:s(sr)||s(sc)},other:{blackberry:s(nc),blackberry10:s(oc),opera:s(ac),firefox:s(hc),chrome:s(lc),device:s(nc)||s(oc)||s(ac)||s(hc)||s(lc)},any:!1,phone:!1,tablet:!1};return n.any=n.apple.device||n.android.device||n.windows.device||n.other.device,n.phone=n.apple.phone||n.android.phone||n.windows.phone,n.tablet=n.apple.tablet||n.android.tablet||n.windows.tablet,n}const ly=uc.default??uc,nr=ly(globalThis.navigator);W.RETINA_PREFIX=/@([0-9\.]+)x/,W.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;var Ji=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function dc(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function hy(r){if(r.__esModule)return r;var t=r.default;if(typeof t=="function"){var e=function i(){return this instanceof i?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(r).forEach(function(i){var s=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:function(){return r[i]}})}),e}var fc={exports:{}};(function(r){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function s(l,h,c){this.fn=l,this.context=h,this.once=c||!1}function n(l,h,c,u,d){if(typeof c!="function")throw new TypeError("The listener must be a function");var f=new s(c,u||l,d),p=e?e+h:h;return l._events[p]?l._events[p].fn?l._events[p]=[l._events[p],f]:l._events[p].push(f):(l._events[p]=f,l._eventsCount++),l}function o(l,h){--l._eventsCount===0?l._events=new i:delete l._events[h]}function a(){this._events=new i,this._eventsCount=0}a.prototype.eventNames=function(){var h=[],c,u;if(this._eventsCount===0)return h;for(u in c=this._events)t.call(c,u)&&h.push(e?u.slice(1):u);return Object.getOwnPropertySymbols?h.concat(Object.getOwnPropertySymbols(c)):h},a.prototype.listeners=function(h){var c=e?e+h:h,u=this._events[c];if(!u)return[];if(u.fn)return[u.fn];for(var d=0,f=u.length,p=new Array(f);d<f;d++)p[d]=u[d].fn;return p},a.prototype.listenerCount=function(h){var c=e?e+h:h,u=this._events[c];return u?u.fn?1:u.length:0},a.prototype.emit=function(h,c,u,d,f,p){var m=e?e+h:h;if(!this._events[m])return!1;var _=this._events[m],y=arguments.length,x,g;if(_.fn){switch(_.once&&this.removeListener(h,_.fn,void 0,!0),y){case 1:return _.fn.call(_.context),!0;case 2:return _.fn.call(_.context,c),!0;case 3:return _.fn.call(_.context,c,u),!0;case 4:return _.fn.call(_.context,c,u,d),!0;case 5:return _.fn.call(_.context,c,u,d,f),!0;case 6:return _.fn.call(_.context,c,u,d,f,p),!0}for(g=1,x=new Array(y-1);g<y;g++)x[g-1]=arguments[g];_.fn.apply(_.context,x)}else{var v=_.length,w;for(g=0;g<v;g++)switch(_[g].once&&this.removeListener(h,_[g].fn,void 0,!0),y){case 1:_[g].fn.call(_[g].context);break;case 2:_[g].fn.call(_[g].context,c);break;case 3:_[g].fn.call(_[g].context,c,u);break;case 4:_[g].fn.call(_[g].context,c,u,d);break;default:if(!x)for(w=1,x=new Array(y-1);w<y;w++)x[w-1]=arguments[w];_[g].fn.apply(_[g].context,x)}}return!0},a.prototype.on=function(h,c,u){return n(this,h,c,u,!1)},a.prototype.once=function(h,c,u){return n(this,h,c,u,!0)},a.prototype.removeListener=function(h,c,u,d){var f=e?e+h:h;if(!this._events[f])return this;if(!c)return o(this,f),this;var p=this._events[f];if(p.fn)p.fn===c&&(!d||p.once)&&(!u||p.context===u)&&o(this,f);else{for(var m=0,_=[],y=p.length;m<y;m++)(p[m].fn!==c||d&&!p[m].once||u&&p[m].context!==u)&&_.push(p[m]);_.length?this._events[f]=_.length===1?_[0]:_:o(this,f)}return this},a.prototype.removeAllListeners=function(h){var c;return h?(c=e?e+h:h,this._events[c]&&o(this,c)):(this._events=new i,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=e,a.EventEmitter=a,r.exports=a})(fc);var cy=fc.exports;const Qi=dc(cy);var Vo={exports:{}};Vo.exports=qs,Vo.exports.default=qs;function qs(r,t,e){e=e||2;var i=t&&t.length,s=i?t[0]*e:r.length,n=pc(r,0,s,e,!0),o=[];if(!n||n.next===n.prev)return o;var a,l,h,c,u,d,f;if(i&&(n=my(r,t,n,e)),r.length>80*e){a=h=r[0],l=c=r[1];for(var p=e;p<s;p+=e)u=r[p],d=r[p+1],u<a&&(a=u),d<l&&(l=d),u>h&&(h=u),d>c&&(c=d);f=Math.max(h-a,c-l),f=f!==0?32767/f:0}return ts(n,o,e,a,l,f,0),o}function pc(r,t,e,i,s){var n,o;if(s===jo(r,t,e,i)>0)for(n=t;n<e;n+=i)o=yc(n,r[n],r[n+1],o);else for(n=e-i;n>=t;n-=i)o=yc(n,r[n],r[n+1],o);return o&&Ks(o,o.next)&&(rs(o),o=o.next),o}function Fr(r,t){if(!r)return r;t||(t=r);var e=r,i;do if(i=!1,!e.steiner&&(Ks(e,e.next)||It(e.prev,e,e.next)===0)){if(rs(e),e=t=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==t);return t}function ts(r,t,e,i,s,n,o){if(r){!o&&n&&xy(r,i,s,n);for(var a=r,l,h;r.prev!==r.next;){if(l=r.prev,h=r.next,n?dy(r,i,s,n):uy(r)){t.push(l.i/e|0),t.push(r.i/e|0),t.push(h.i/e|0),rs(r),r=h.next,a=h.next;continue}if(r=h,r===a){o?o===1?(r=fy(Fr(r),t,e),ts(r,t,e,i,s,n,2)):o===2&&py(r,t,e,i,s,n):ts(Fr(r),t,e,i,s,n,1);break}}}}function uy(r){var t=r.prev,e=r,i=r.next;if(It(t,e,i)>=0)return!1;for(var s=t.x,n=e.x,o=i.x,a=t.y,l=e.y,h=i.y,c=s<n?s<o?s:o:n<o?n:o,u=a<l?a<h?a:h:l<h?l:h,d=s>n?s>o?s:o:n>o?n:o,f=a>l?a>h?a:h:l>h?l:h,p=i.next;p!==t;){if(p.x>=c&&p.x<=d&&p.y>=u&&p.y<=f&&pi(s,a,n,l,o,h,p.x,p.y)&&It(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function dy(r,t,e,i){var s=r.prev,n=r,o=r.next;if(It(s,n,o)>=0)return!1;for(var a=s.x,l=n.x,h=o.x,c=s.y,u=n.y,d=o.y,f=a<l?a<h?a:h:l<h?l:h,p=c<u?c<d?c:d:u<d?u:d,m=a>l?a>h?a:h:l>h?l:h,_=c>u?c>d?c:d:u>d?u:d,y=zo(f,p,t,e,i),x=zo(m,_,t,e,i),g=r.prevZ,v=r.nextZ;g&&g.z>=y&&v&&v.z<=x;){if(g.x>=f&&g.x<=m&&g.y>=p&&g.y<=_&&g!==s&&g!==o&&pi(a,c,l,u,h,d,g.x,g.y)&&It(g.prev,g,g.next)>=0||(g=g.prevZ,v.x>=f&&v.x<=m&&v.y>=p&&v.y<=_&&v!==s&&v!==o&&pi(a,c,l,u,h,d,v.x,v.y)&&It(v.prev,v,v.next)>=0))return!1;v=v.nextZ}for(;g&&g.z>=y;){if(g.x>=f&&g.x<=m&&g.y>=p&&g.y<=_&&g!==s&&g!==o&&pi(a,c,l,u,h,d,g.x,g.y)&&It(g.prev,g,g.next)>=0)return!1;g=g.prevZ}for(;v&&v.z<=x;){if(v.x>=f&&v.x<=m&&v.y>=p&&v.y<=_&&v!==s&&v!==o&&pi(a,c,l,u,h,d,v.x,v.y)&&It(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function fy(r,t,e){var i=r;do{var s=i.prev,n=i.next.next;!Ks(s,n)&&mc(s,i,i.next,n)&&es(s,n)&&es(n,s)&&(t.push(s.i/e|0),t.push(i.i/e|0),t.push(n.i/e|0),rs(i),rs(i.next),i=r=n),i=i.next}while(i!==r);return Fr(i)}function py(r,t,e,i,s,n){var o=r;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&Ey(o,a)){var l=gc(o,a);o=Fr(o,o.next),l=Fr(l,l.next),ts(o,t,e,i,s,n,0),ts(l,t,e,i,s,n,0);return}a=a.next}o=o.next}while(o!==r)}function my(r,t,e,i){var s=[],n,o,a,l,h;for(n=0,o=t.length;n<o;n++)a=t[n]*i,l=n<o-1?t[n+1]*i:r.length,h=pc(r,a,l,i,!1),h===h.next&&(h.steiner=!0),s.push(wy(h));for(s.sort(gy),n=0;n<s.length;n++)e=yy(s[n],e);return e}function gy(r,t){return r.x-t.x}function yy(r,t){var e=_y(r,t);if(!e)return t;var i=gc(e,r);return Fr(i,i.next),Fr(e,e.next)}function _y(r,t){var e=t,i=r.x,s=r.y,n=-1/0,o;do{if(s<=e.y&&s>=e.next.y&&e.next.y!==e.y){var a=e.x+(s-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(a<=i&&a>n&&(n=a,o=e.x<e.next.x?e:e.next,a===i))return o}e=e.next}while(e!==t);if(!o)return null;var l=o,h=o.x,c=o.y,u=1/0,d;e=o;do i>=e.x&&e.x>=h&&i!==e.x&&pi(s<c?i:n,s,h,c,s<c?n:i,s,e.x,e.y)&&(d=Math.abs(s-e.y)/(i-e.x),es(e,r)&&(d<u||d===u&&(e.x>o.x||e.x===o.x&&vy(o,e)))&&(o=e,u=d)),e=e.next;while(e!==l);return o}function vy(r,t){return It(r.prev,r,t.prev)<0&&It(t.next,r,r.next)<0}function xy(r,t,e,i){var s=r;do s.z===0&&(s.z=zo(s.x,s.y,t,e,i)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==r);s.prevZ.nextZ=null,s.prevZ=null,by(s)}function by(r){var t,e,i,s,n,o,a,l,h=1;do{for(e=r,r=null,n=null,o=0;e;){for(o++,i=e,a=0,t=0;t<h&&(a++,i=i.nextZ,!!i);t++);for(l=h;a>0||l>0&&i;)a!==0&&(l===0||!i||e.z<=i.z)?(s=e,e=e.nextZ,a--):(s=i,i=i.nextZ,l--),n?n.nextZ=s:r=s,s.prevZ=n,n=s;e=i}n.nextZ=null,h*=2}while(o>1);return r}function zo(r,t,e,i,s){return r=(r-e)*s|0,t=(t-i)*s|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,r|t<<1}function wy(r){var t=r,e=r;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==r);return e}function pi(r,t,e,i,s,n,o,a){return(s-o)*(t-a)>=(r-o)*(n-a)&&(r-o)*(i-a)>=(e-o)*(t-a)&&(e-o)*(n-a)>=(s-o)*(i-a)}function Ey(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!Ty(r,t)&&(es(r,t)&&es(t,r)&&Ay(r,t)&&(It(r.prev,r,t.prev)||It(r,t.prev,t))||Ks(r,t)&&It(r.prev,r,r.next)>0&&It(t.prev,t,t.next)>0)}function It(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function Ks(r,t){return r.x===t.x&&r.y===t.y}function mc(r,t,e,i){var s=Js(It(r,t,e)),n=Js(It(r,t,i)),o=Js(It(e,i,r)),a=Js(It(e,i,t));return!!(s!==n&&o!==a||s===0&&Zs(r,e,t)||n===0&&Zs(r,i,t)||o===0&&Zs(e,r,i)||a===0&&Zs(e,t,i))}function Zs(r,t,e){return t.x<=Math.max(r.x,e.x)&&t.x>=Math.min(r.x,e.x)&&t.y<=Math.max(r.y,e.y)&&t.y>=Math.min(r.y,e.y)}function Js(r){return r>0?1:r<0?-1:0}function Ty(r,t){var e=r;do{if(e.i!==r.i&&e.next.i!==r.i&&e.i!==t.i&&e.next.i!==t.i&&mc(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function es(r,t){return It(r.prev,r,r.next)<0?It(r,t,r.next)>=0&&It(r,r.prev,t)>=0:It(r,t,r.prev)<0||It(r,r.next,t)<0}function Ay(r,t){var e=r,i=!1,s=(r.x+t.x)/2,n=(r.y+t.y)/2;do e.y>n!=e.next.y>n&&e.next.y!==e.y&&s<(e.next.x-e.x)*(n-e.y)/(e.next.y-e.y)+e.x&&(i=!i),e=e.next;while(e!==r);return i}function gc(r,t){var e=new Wo(r.i,r.x,r.y),i=new Wo(t.i,t.x,t.y),s=r.next,n=t.prev;return r.next=t,t.prev=r,e.next=s,s.prev=e,i.next=e,e.prev=i,n.next=i,i.prev=n,i}function yc(r,t,e,i){var s=new Wo(r,t,e);return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function rs(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function Wo(r,t,e){this.i=r,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}qs.deviation=function(r,t,e,i){var s=t&&t.length,n=s?t[0]*e:r.length,o=Math.abs(jo(r,0,n,e));if(s)for(var a=0,l=t.length;a<l;a++){var h=t[a]*e,c=a<l-1?t[a+1]*e:r.length;o-=Math.abs(jo(r,h,c,e))}var u=0;for(a=0;a<i.length;a+=3){var d=i[a]*e,f=i[a+1]*e,p=i[a+2]*e;u+=Math.abs((r[d]-r[p])*(r[f+1]-r[d+1])-(r[d]-r[f])*(r[p+1]-r[d+1]))}return o===0&&u===0?0:Math.abs((u-o)/o)};function jo(r,t,e,i){for(var s=0,n=t,o=e-i;n<e;n+=i)s+=(r[o]-r[n])*(r[n+1]+r[o+1]),o=n;return s}qs.flatten=function(r){for(var t=r[0][0].length,e={vertices:[],holes:[],dimensions:t},i=0,s=0;s<r.length;s++){for(var n=0;n<r[s].length;n++)for(var o=0;o<t;o++)e.vertices.push(r[s][n][o]);s>0&&(i+=r[s-1].length,e.holes.push(i))}return e};var Sy=Vo.exports;const Iy=dc(Sy);var Qs={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */Qs.exports,function(r,t){(function(e){var i=t&&!t.nodeType&&t,s=r&&!r.nodeType&&r,n=typeof Ji=="object"&&Ji;(n.global===n||n.window===n||n.self===n)&&(e=n);var o,a=2147483647,l=36,h=1,c=26,u=38,d=700,f=72,p=128,m="-",_=/^xn--/,y=/[^\x20-\x7E]/,x=/[\x2E\u3002\uFF0E\uFF61]/g,g={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},v=l-h,w=Math.floor,I=String.fromCharCode,A;function C(P){throw new RangeError(g[P])}function N(P,U){for(var j=P.length,rt=[];j--;)rt[j]=U(P[j]);return rt}function S(P,U){var j=P.split("@"),rt="";j.length>1&&(rt=j[0]+"@",P=j[1]),P=P.replace(x,".");var Q=P.split("."),H=N(Q,U).join(".");return rt+H}function R(P){for(var U=[],j=0,rt=P.length,Q,H;j<rt;)Q=P.charCodeAt(j++),Q>=55296&&Q<=56319&&j<rt?(H=P.charCodeAt(j++),(H&64512)==56320?U.push(((Q&1023)<<10)+(H&1023)+65536):(U.push(Q),j--)):U.push(Q);return U}function E(P){return N(P,function(U){var j="";return U>65535&&(U-=65536,j+=I(U>>>10&1023|55296),U=56320|U&1023),j+=I(U),j}).join("")}function b(P){return P-48<10?P-22:P-65<26?P-65:P-97<26?P-97:l}function D(P,U){return P+22+75*(P<26)-((U!=0)<<5)}function F(P,U,j){var rt=0;for(P=j?w(P/d):P>>1,P+=w(P/U);P>v*c>>1;rt+=l)P=w(P/v);return w(rt+(v+1)*P/(P+u))}function G(P){var U=[],j=P.length,rt,Q=0,H=p,V=f,lt,L,O,_t,ht,vt,xt,Ye,qe;for(lt=P.lastIndexOf(m),lt<0&&(lt=0),L=0;L<lt;++L)P.charCodeAt(L)>=128&&C("not-basic"),U.push(P.charCodeAt(L));for(O=lt>0?lt+1:0;O<j;){for(_t=Q,ht=1,vt=l;O>=j&&C("invalid-input"),xt=b(P.charCodeAt(O++)),(xt>=l||xt>w((a-Q)/ht))&&C("overflow"),Q+=xt*ht,Ye=vt<=V?h:vt>=V+c?c:vt-V,!(xt<Ye);vt+=l)qe=l-Ye,ht>w(a/qe)&&C("overflow"),ht*=qe;rt=U.length+1,V=F(Q-_t,rt,_t==0),w(Q/rt)>a-H&&C("overflow"),H+=w(Q/rt),Q%=rt,U.splice(Q++,0,H)}return E(U)}function $(P){var U,j,rt,Q,H,V,lt,L,O,_t,ht,vt=[],xt,Ye,qe,ws;for(P=R(P),xt=P.length,U=p,j=0,H=f,V=0;V<xt;++V)ht=P[V],ht<128&&vt.push(I(ht));for(rt=Q=vt.length,Q&&vt.push(m);rt<xt;){for(lt=a,V=0;V<xt;++V)ht=P[V],ht>=U&&ht<lt&&(lt=ht);for(Ye=rt+1,lt-U>w((a-j)/Ye)&&C("overflow"),j+=(lt-U)*Ye,U=lt,V=0;V<xt;++V)if(ht=P[V],ht<U&&++j>a&&C("overflow"),ht==U){for(L=j,O=l;_t=O<=H?h:O>=H+c?c:O-H,!(L<_t);O+=l)ws=L-_t,qe=l-_t,vt.push(I(D(_t+ws%qe,0))),L=w(ws/qe);vt.push(I(D(L,0))),H=F(j,Ye,rt==Q),j=0,++rt}++j,++U}return vt.join("")}function B(P){return S(P,function(U){return _.test(U)?G(U.slice(4).toLowerCase()):U})}function Z(P){return S(P,function(U){return y.test(U)?"xn--"+$(U):U})}if(o={version:"1.4.1",ucs2:{decode:R,encode:E},decode:G,encode:$,toASCII:Z,toUnicode:B},i&&s)if(r.exports==i)s.exports=o;else for(A in o)o.hasOwnProperty(A)&&(i[A]=o[A]);else e.punycode=o})(Ji)}(Qs,Qs.exports);var Cy=Qs.exports,Ry=Error,Py=EvalError,My=RangeError,By=ReferenceError,_c=SyntaxError,is=TypeError,Dy=URIError,Oy=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var t={},e=Symbol("test"),i=Object(e);if(typeof e=="string"||Object.prototype.toString.call(e)!=="[object Symbol]"||Object.prototype.toString.call(i)!=="[object Symbol]")return!1;var s=42;t[e]=s;for(e in t)return!1;if(typeof Object.keys=="function"&&Object.keys(t).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(t).length!==0)return!1;var n=Object.getOwnPropertySymbols(t);if(n.length!==1||n[0]!==e||!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var o=Object.getOwnPropertyDescriptor(t,e);if(o.value!==s||o.enumerable!==!0)return!1}return!0},vc=typeof Symbol<"u"&&Symbol,Fy=Oy,Ly=function(){return typeof vc!="function"||typeof Symbol!="function"||typeof vc("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:Fy()},Yo={__proto__:null,foo:{}},Ny=Object,Uy=function(){return{__proto__:Yo}.foo===Yo.foo&&!(Yo instanceof Ny)},ky="Function.prototype.bind called on incompatible ",Gy=Object.prototype.toString,$y=Math.max,Hy="[object Function]",xc=function(t,e){for(var i=[],s=0;s<t.length;s+=1)i[s]=t[s];for(var n=0;n<e.length;n+=1)i[n+t.length]=e[n];return i},Xy=function(t,e){for(var i=[],s=e,n=0;s<t.length;s+=1,n+=1)i[n]=t[s];return i},Vy=function(r,t){for(var e="",i=0;i<r.length;i+=1)e+=r[i],i+1<r.length&&(e+=t);return e},zy=function(t){var e=this;if(typeof e!="function"||Gy.apply(e)!==Hy)throw new TypeError(ky+e);for(var i=Xy(arguments,1),s,n=function(){if(this instanceof s){var c=e.apply(this,xc(i,arguments));return Object(c)===c?c:this}return e.apply(t,xc(i,arguments))},o=$y(0,e.length-i.length),a=[],l=0;l<o;l++)a[l]="$"+l;if(s=Function("binder","return function ("+Vy(a,",")+"){ return binder.apply(this,arguments); }")(n),e.prototype){var h=function(){};h.prototype=e.prototype,s.prototype=new h,h.prototype=null}return s},Wy=zy,qo=Function.prototype.bind||Wy,jy=Function.prototype.call,Yy=Object.prototype.hasOwnProperty,qy=qo,Ky=qy.call(jy,Yy),pt,Zy=Ry,Jy=Py,Qy=My,t0=By,mi=_c,gi=is,e0=Dy,bc=Function,Ko=function(r){try{return bc('"use strict"; return ('+r+").constructor;")()}catch{}},Lr=Object.getOwnPropertyDescriptor;if(Lr)try{Lr({},"")}catch{Lr=null}var Zo=function(){throw new gi},r0=Lr?function(){try{return arguments.callee,Zo}catch{try{return Lr(arguments,"callee").get}catch{return Zo}}}():Zo,yi=Ly(),i0=Uy(),kt=Object.getPrototypeOf||(i0?function(r){return r.__proto__}:null),_i={},s0=typeof Uint8Array>"u"||!kt?pt:kt(Uint8Array),Nr={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?pt:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?pt:ArrayBuffer,"%ArrayIteratorPrototype%":yi&&kt?kt([][Symbol.iterator]()):pt,"%AsyncFromSyncIteratorPrototype%":pt,"%AsyncFunction%":_i,"%AsyncGenerator%":_i,"%AsyncGeneratorFunction%":_i,"%AsyncIteratorPrototype%":_i,"%Atomics%":typeof Atomics>"u"?pt:Atomics,"%BigInt%":typeof BigInt>"u"?pt:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?pt:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?pt:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?pt:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Zy,"%eval%":eval,"%EvalError%":Jy,"%Float32Array%":typeof Float32Array>"u"?pt:Float32Array,"%Float64Array%":typeof Float64Array>"u"?pt:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?pt:FinalizationRegistry,"%Function%":bc,"%GeneratorFunction%":_i,"%Int8Array%":typeof Int8Array>"u"?pt:Int8Array,"%Int16Array%":typeof Int16Array>"u"?pt:Int16Array,"%Int32Array%":typeof Int32Array>"u"?pt:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":yi&&kt?kt(kt([][Symbol.iterator]())):pt,"%JSON%":typeof JSON=="object"?JSON:pt,"%Map%":typeof Map>"u"?pt:Map,"%MapIteratorPrototype%":typeof Map>"u"||!yi||!kt?pt:kt(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?pt:Promise,"%Proxy%":typeof Proxy>"u"?pt:Proxy,"%RangeError%":Qy,"%ReferenceError%":t0,"%Reflect%":typeof Reflect>"u"?pt:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?pt:Set,"%SetIteratorPrototype%":typeof Set>"u"||!yi||!kt?pt:kt(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?pt:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":yi&&kt?kt(""[Symbol.iterator]()):pt,"%Symbol%":yi?Symbol:pt,"%SyntaxError%":mi,"%ThrowTypeError%":r0,"%TypedArray%":s0,"%TypeError%":gi,"%Uint8Array%":typeof Uint8Array>"u"?pt:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?pt:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?pt:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?pt:Uint32Array,"%URIError%":e0,"%WeakMap%":typeof WeakMap>"u"?pt:WeakMap,"%WeakRef%":typeof WeakRef>"u"?pt:WeakRef,"%WeakSet%":typeof WeakSet>"u"?pt:WeakSet};if(kt)try{null.error}catch(r){var n0=kt(kt(r));Nr["%Error.prototype%"]=n0}var o0=function r(t){var e;if(t==="%AsyncFunction%")e=Ko("async function () {}");else if(t==="%GeneratorFunction%")e=Ko("function* () {}");else if(t==="%AsyncGeneratorFunction%")e=Ko("async function* () {}");else if(t==="%AsyncGenerator%"){var i=r("%AsyncGeneratorFunction%");i&&(e=i.prototype)}else if(t==="%AsyncIteratorPrototype%"){var s=r("%AsyncGenerator%");s&&kt&&(e=kt(s.prototype))}return Nr[t]=e,e},wc={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},ss=qo,tn=Ky,a0=ss.call(Function.call,Array.prototype.concat),l0=ss.call(Function.apply,Array.prototype.splice),Ec=ss.call(Function.call,String.prototype.replace),en=ss.call(Function.call,String.prototype.slice),h0=ss.call(Function.call,RegExp.prototype.exec),c0=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,u0=/\\(\\)?/g,d0=function(t){var e=en(t,0,1),i=en(t,-1);if(e==="%"&&i!=="%")throw new mi("invalid intrinsic syntax, expected closing `%`");if(i==="%"&&e!=="%")throw new mi("invalid intrinsic syntax, expected opening `%`");var s=[];return Ec(t,c0,function(n,o,a,l){s[s.length]=a?Ec(l,u0,"$1"):o||n}),s},f0=function(t,e){var i=t,s;if(tn(wc,i)&&(s=wc[i],i="%"+s[0]+"%"),tn(Nr,i)){var n=Nr[i];if(n===_i&&(n=o0(i)),typeof n>"u"&&!e)throw new gi("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:s,name:i,value:n}}throw new mi("intrinsic "+t+" does not exist!")},vi=function(t,e){if(typeof t!="string"||t.length===0)throw new gi("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof e!="boolean")throw new gi('"allowMissing" argument must be a boolean');if(h0(/^%?[^%]*%?$/,t)===null)throw new mi("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var i=d0(t),s=i.length>0?i[0]:"",n=f0("%"+s+"%",e),o=n.name,a=n.value,l=!1,h=n.alias;h&&(s=h[0],l0(i,a0([0,1],h)));for(var c=1,u=!0;c<i.length;c+=1){var d=i[c],f=en(d,0,1),p=en(d,-1);if((f==='"'||f==="'"||f==="`"||p==='"'||p==="'"||p==="`")&&f!==p)throw new mi("property names with quotes must have matching quotes");if((d==="constructor"||!u)&&(l=!0),s+="."+d,o="%"+s+"%",tn(Nr,o))a=Nr[o];else if(a!=null){if(!(d in a)){if(!e)throw new gi("base intrinsic for "+t+" exists, but the property is not available.");return}if(Lr&&c+1>=i.length){var m=Lr(a,d);u=!!m,u&&"get"in m&&!("originalValue"in m.get)?a=m.get:a=a[d]}else u=tn(a,d),a=a[d];u&&!l&&(Nr[o]=a)}}return a},Tc={exports:{}},Jo,Ac;function Qo(){if(Ac)return Jo;Ac=1;var r=vi,t=r("%Object.defineProperty%",!0)||!1;if(t)try{t({},"a",{value:1})}catch{t=!1}return Jo=t,Jo}var p0=vi,rn=p0("%Object.getOwnPropertyDescriptor%",!0);if(rn)try{rn([],"length")}catch{rn=null}var Sc=rn,Ic=Qo(),m0=_c,xi=is,Cc=Sc,g0=function(t,e,i){if(!t||typeof t!="object"&&typeof t!="function")throw new xi("`obj` must be an object or a function`");if(typeof e!="string"&&typeof e!="symbol")throw new xi("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new xi("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new xi("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new xi("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new xi("`loose`, if provided, must be a boolean");var s=arguments.length>3?arguments[3]:null,n=arguments.length>4?arguments[4]:null,o=arguments.length>5?arguments[5]:null,a=arguments.length>6?arguments[6]:!1,l=!!Cc&&Cc(t,e);if(Ic)Ic(t,e,{configurable:o===null&&l?l.configurable:!o,enumerable:s===null&&l?l.enumerable:!s,value:i,writable:n===null&&l?l.writable:!n});else if(a||!s&&!n&&!o)t[e]=i;else throw new m0("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},ta=Qo(),Rc=function(){return!!ta};Rc.hasArrayLengthDefineBug=function(){if(!ta)return null;try{return ta([],"length",{value:1}).length!==1}catch{return!0}};var y0=Rc,_0=vi,Pc=g0,v0=y0(),Mc=Sc,Bc=is,x0=_0("%Math.floor%"),b0=function(t,e){if(typeof t!="function")throw new Bc("`fn` is not a function");if(typeof e!="number"||e<0||e>4294967295||x0(e)!==e)throw new Bc("`length` must be a positive 32-bit integer");var i=arguments.length>2&&!!arguments[2],s=!0,n=!0;if("length"in t&&Mc){var o=Mc(t,"length");o&&!o.configurable&&(s=!1),o&&!o.writable&&(n=!1)}return(s||n||!i)&&(v0?Pc(t,"length",e,!0,!0):Pc(t,"length",e)),t};(function(r){var t=qo,e=vi,i=b0,s=is,n=e("%Function.prototype.apply%"),o=e("%Function.prototype.call%"),a=e("%Reflect.apply%",!0)||t.call(o,n),l=Qo(),h=e("%Math.max%");r.exports=function(d){if(typeof d!="function")throw new s("a function is required");var f=a(t,o,arguments);return i(f,1+h(0,d.length-(arguments.length-1)),!0)};var c=function(){return a(t,n,arguments)};l?l(r.exports,"apply",{value:c}):r.exports.apply=c})(Tc);var w0=Tc.exports,Dc=vi,Oc=w0,E0=Oc(Dc("String.prototype.indexOf")),T0=function(t,e){var i=Dc(t,!!e);return typeof i=="function"&&E0(t,".prototype.")>-1?Oc(i):i};const A0=hy(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var ea=typeof Map=="function"&&Map.prototype,ra=Object.getOwnPropertyDescriptor&&ea?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,sn=ea&&ra&&typeof ra.get=="function"?ra.get:null,Fc=ea&&Map.prototype.forEach,ia=typeof Set=="function"&&Set.prototype,sa=Object.getOwnPropertyDescriptor&&ia?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,nn=ia&&sa&&typeof sa.get=="function"?sa.get:null,Lc=ia&&Set.prototype.forEach,S0=typeof WeakMap=="function"&&WeakMap.prototype,ns=S0?WeakMap.prototype.has:null,I0=typeof WeakSet=="function"&&WeakSet.prototype,os=I0?WeakSet.prototype.has:null,C0=typeof WeakRef=="function"&&WeakRef.prototype,Nc=C0?WeakRef.prototype.deref:null,R0=Boolean.prototype.valueOf,P0=Object.prototype.toString,M0=Function.prototype.toString,B0=String.prototype.match,na=String.prototype.slice,gr=String.prototype.replace,D0=String.prototype.toUpperCase,Uc=String.prototype.toLowerCase,kc=RegExp.prototype.test,Gc=Array.prototype.concat,ke=Array.prototype.join,O0=Array.prototype.slice,$c=Math.floor,oa=typeof BigInt=="function"?BigInt.prototype.valueOf:null,aa=Object.getOwnPropertySymbols,la=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,bi=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Qt=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===bi||!0)?Symbol.toStringTag:null,Hc=Object.prototype.propertyIsEnumerable,Xc=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(r){return r.__proto__}:null);function Vc(r,t){if(r===1/0||r===-1/0||r!==r||r&&r>-1e3&&r<1e3||kc.call(/e/,t))return t;var e=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof r=="number"){var i=r<0?-$c(-r):$c(r);if(i!==r){var s=String(i),n=na.call(t,s.length+1);return gr.call(s,e,"$&_")+"."+gr.call(gr.call(n,/([0-9]{3})/g,"$&_"),/_$/,"")}}return gr.call(t,e,"$&_")}var ha=A0,zc=ha.custom,Wc=qc(zc)?zc:null,F0=function r(t,e,i,s){var n=e||{};if(yr(n,"quoteStyle")&&n.quoteStyle!=="single"&&n.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(yr(n,"maxStringLength")&&(typeof n.maxStringLength=="number"?n.maxStringLength<0&&n.maxStringLength!==1/0:n.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var o=yr(n,"customInspect")?n.customInspect:!0;if(typeof o!="boolean"&&o!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(yr(n,"indent")&&n.indent!==null&&n.indent!==" "&&!(parseInt(n.indent,10)===n.indent&&n.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(yr(n,"numericSeparator")&&typeof n.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var a=n.numericSeparator;if(typeof t>"u")return"undefined";if(t===null)return"null";if(typeof t=="boolean")return t?"true":"false";if(typeof t=="string")return Zc(t,n);if(typeof t=="number"){if(t===0)return 1/0/t>0?"0":"-0";var l=String(t);return a?Vc(t,l):l}if(typeof t=="bigint"){var h=String(t)+"n";return a?Vc(t,h):h}var c=typeof n.depth>"u"?5:n.depth;if(typeof i>"u"&&(i=0),i>=c&&c>0&&typeof t=="object")return ca(t)?"[Array]":"[Object]";var u=Q0(n,i);if(typeof s>"u")s=[];else if(Kc(s,t)>=0)return"[Circular]";function d(b,D,F){if(D&&(s=O0.call(s),s.push(D)),F){var G={depth:n.depth};return yr(n,"quoteStyle")&&(G.quoteStyle=n.quoteStyle),r(b,G,i+1,s)}return r(b,n,i+1,s)}if(typeof t=="function"&&!Yc(t)){var f=V0(t),p=on(t,d);return"[Function"+(f?": "+f:" (anonymous)")+"]"+(p.length>0?" { "+ke.call(p,", ")+" }":"")}if(qc(t)){var m=bi?gr.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):la.call(t);return typeof t=="object"&&!bi?as(m):m}if(K0(t)){for(var _="<"+Uc.call(String(t.nodeName)),y=t.attributes||[],x=0;x<y.length;x++)_+=" "+y[x].name+"="+jc(L0(y[x].value),"double",n);return _+=">",t.childNodes&&t.childNodes.length&&(_+="..."),_+="</"+Uc.call(String(t.nodeName))+">",_}if(ca(t)){if(t.length===0)return"[]";var g=on(t,d);return u&&!J0(g)?"["+da(g,u)+"]":"[ "+ke.call(g,", ")+" ]"}if(U0(t)){var v=on(t,d);return!("cause"in Error.prototype)&&"cause"in t&&!Hc.call(t,"cause")?"{ ["+String(t)+"] "+ke.call(Gc.call("[cause]: "+d(t.cause),v),", ")+" }":v.length===0?"["+String(t)+"]":"{ ["+String(t)+"] "+ke.call(v,", ")+" }"}if(typeof t=="object"&&o){if(Wc&&typeof t[Wc]=="function"&&ha)return ha(t,{depth:c-i});if(o!=="symbol"&&typeof t.inspect=="function")return t.inspect()}if(z0(t)){var w=[];return Fc&&Fc.call(t,function(b,D){w.push(d(D,t,!0)+" => "+d(b,t))}),Jc("Map",sn.call(t),w,u)}if(Y0(t)){var I=[];return Lc&&Lc.call(t,function(b){I.push(d(b,t))}),Jc("Set",nn.call(t),I,u)}if(W0(t))return ua("WeakMap");if(q0(t))return ua("WeakSet");if(j0(t))return ua("WeakRef");if(G0(t))return as(d(Number(t)));if(H0(t))return as(d(oa.call(t)));if($0(t))return as(R0.call(t));if(k0(t))return as(d(String(t)));if(typeof window<"u"&&t===window)return"{ [object Window] }";if(typeof globalThis<"u"&&t===globalThis||typeof Ji<"u"&&t===Ji)return"{ [object globalThis] }";if(!N0(t)&&!Yc(t)){var A=on(t,d),C=Xc?Xc(t)===Object.prototype:t instanceof Object||t.constructor===Object,N=t instanceof Object?"":"null prototype",S=!C&&Qt&&Object(t)===t&&Qt in t?na.call(_r(t),8,-1):N?"Object":"",R=C||typeof t.constructor!="function"?"":t.constructor.name?t.constructor.name+" ":"",E=R+(S||N?"["+ke.call(Gc.call([],S||[],N||[]),": ")+"] ":"");return A.length===0?E+"{}":u?E+"{"+da(A,u)+"}":E+"{ "+ke.call(A,", ")+" }"}return String(t)};function jc(r,t,e){var i=(e.quoteStyle||t)==="double"?'"':"'";return i+r+i}function L0(r){return gr.call(String(r),/"/g,""")}function ca(r){return _r(r)==="[object Array]"&&(!Qt||!(typeof r=="object"&&Qt in r))}function N0(r){return _r(r)==="[object Date]"&&(!Qt||!(typeof r=="object"&&Qt in r))}function Yc(r){return _r(r)==="[object RegExp]"&&(!Qt||!(typeof r=="object"&&Qt in r))}function U0(r){return _r(r)==="[object Error]"&&(!Qt||!(typeof r=="object"&&Qt in r))}function k0(r){return _r(r)==="[object String]"&&(!Qt||!(typeof r=="object"&&Qt in r))}function G0(r){return _r(r)==="[object Number]"&&(!Qt||!(typeof r=="object"&&Qt in r))}function $0(r){return _r(r)==="[object Boolean]"&&(!Qt||!(typeof r=="object"&&Qt in r))}function qc(r){if(bi)return r&&typeof r=="object"&&r instanceof Symbol;if(typeof r=="symbol")return!0;if(!r||typeof r!="object"||!la)return!1;try{return la.call(r),!0}catch{}return!1}function H0(r){if(!r||typeof r!="object"||!oa)return!1;try{return oa.call(r),!0}catch{}return!1}var X0=Object.prototype.hasOwnProperty||function(r){return r in this};function yr(r,t){return X0.call(r,t)}function _r(r){return P0.call(r)}function V0(r){if(r.name)return r.name;var t=B0.call(M0.call(r),/^function\s*([\w$]+)/);return t?t[1]:null}function Kc(r,t){if(r.indexOf)return r.indexOf(t);for(var e=0,i=r.length;e<i;e++)if(r[e]===t)return e;return-1}function z0(r){if(!sn||!r||typeof r!="object")return!1;try{sn.call(r);try{nn.call(r)}catch{return!0}return r instanceof Map}catch{}return!1}function W0(r){if(!ns||!r||typeof r!="object")return!1;try{ns.call(r,ns);try{os.call(r,os)}catch{return!0}return r instanceof WeakMap}catch{}return!1}function j0(r){if(!Nc||!r||typeof r!="object")return!1;try{return Nc.call(r),!0}catch{}return!1}function Y0(r){if(!nn||!r||typeof r!="object")return!1;try{nn.call(r);try{sn.call(r)}catch{return!0}return r instanceof Set}catch{}return!1}function q0(r){if(!os||!r||typeof r!="object")return!1;try{os.call(r,os);try{ns.call(r,ns)}catch{return!0}return r instanceof WeakSet}catch{}return!1}function K0(r){return!r||typeof r!="object"?!1:typeof HTMLElement<"u"&&r instanceof HTMLElement?!0:typeof r.nodeName=="string"&&typeof r.getAttribute=="function"}function Zc(r,t){if(r.length>t.maxStringLength){var e=r.length-t.maxStringLength,i="... "+e+" more character"+(e>1?"s":"");return Zc(na.call(r,0,t.maxStringLength),t)+i}var s=gr.call(gr.call(r,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,Z0);return jc(s,"single",t)}function Z0(r){var t=r.charCodeAt(0),e={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return e?"\\"+e:"\\x"+(t<16?"0":"")+D0.call(t.toString(16))}function as(r){return"Object("+r+")"}function ua(r){return r+" { ? }"}function Jc(r,t,e,i){var s=i?da(e,i):ke.call(e,", ");return r+" ("+t+") {"+s+"}"}function J0(r){for(var t=0;t<r.length;t++)if(Kc(r[t],`
|
|
2
2
|
`)>=0)return!1;return!0}function Q0(r,t){var e;if(r.indent===" ")e=" ";else if(typeof r.indent=="number"&&r.indent>0)e=ke.call(Array(r.indent+1)," ");else return null;return{base:e,prev:ke.call(Array(t+1),e)}}function da(r,t){if(r.length===0)return"";var e=`
|
|
3
3
|
`+t.prev+t.base;return e+ke.call(r,","+e)+`
|
|
4
4
|
`+t.prev}function on(r,t){var e=ca(r),i=[];if(e){i.length=r.length;for(var s=0;s<r.length;s++)i[s]=yr(r,s)?t(r[s],r):""}var n=typeof aa=="function"?aa(r):[],o;if(bi){o={};for(var a=0;a<n.length;a++)o["$"+n[a]]=n[a]}for(var l in r)yr(r,l)&&(e&&String(Number(l))===l&&l<r.length||bi&&o["$"+l]instanceof Symbol||(kc.call(/[^\w$]/,l)?i.push(t(l,r)+": "+t(r[l],r)):i.push(l+": "+t(r[l],r))));if(typeof aa=="function")for(var h=0;h<n.length;h++)Hc.call(r,n[h])&&i.push("["+t(n[h])+"]: "+t(r[n[h]],r));return i}var Qc=vi,wi=T0,t_=F0,e_=is,an=Qc("%WeakMap%",!0),ln=Qc("%Map%",!0),r_=wi("WeakMap.prototype.get",!0),i_=wi("WeakMap.prototype.set",!0),s_=wi("WeakMap.prototype.has",!0),n_=wi("Map.prototype.get",!0),o_=wi("Map.prototype.set",!0),a_=wi("Map.prototype.has",!0),fa=function(r,t){for(var e=r,i;(i=e.next)!==null;e=i)if(i.key===t)return e.next=i.next,i.next=r.next,r.next=i,i},l_=function(r,t){var e=fa(r,t);return e&&e.value},h_=function(r,t,e){var i=fa(r,t);i?i.value=e:r.next={key:t,next:r.next,value:e}},c_=function(r,t){return!!fa(r,t)},u_=function(){var t,e,i,s={assert:function(n){if(!s.has(n))throw new e_("Side channel does not contain "+t_(n))},get:function(n){if(an&&n&&(typeof n=="object"||typeof n=="function")){if(t)return r_(t,n)}else if(ln){if(e)return n_(e,n)}else if(i)return l_(i,n)},has:function(n){if(an&&n&&(typeof n=="object"||typeof n=="function")){if(t)return s_(t,n)}else if(ln){if(e)return a_(e,n)}else if(i)return c_(i,n);return!1},set:function(n,o){an&&n&&(typeof n=="object"||typeof n=="function")?(t||(t=new an),i_(t,n,o)):ln?(e||(e=new ln),o_(e,n,o)):(i||(i={key:{},next:null}),h_(i,n,o))}};return s},d_=String.prototype.replace,f_=/%20/g,pa={RFC1738:"RFC1738",RFC3986:"RFC3986"},ma={default:pa.RFC3986,formatters:{RFC1738:function(r){return d_.call(r,f_,"+")},RFC3986:function(r){return String(r)}},RFC1738:pa.RFC1738,RFC3986:pa.RFC3986},p_=ma,ga=Object.prototype.hasOwnProperty,Ur=Array.isArray,Ge=function(){for(var r=[],t=0;t<256;++t)r.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return r}(),m_=function(t){for(;t.length>1;){var e=t.pop(),i=e.obj[e.prop];if(Ur(i)){for(var s=[],n=0;n<i.length;++n)typeof i[n]<"u"&&s.push(i[n]);e.obj[e.prop]=s}}},tu=function(t,e){for(var i=e&&e.plainObjects?Object.create(null):{},s=0;s<t.length;++s)typeof t[s]<"u"&&(i[s]=t[s]);return i},g_=function r(t,e,i){if(!e)return t;if(typeof e!="object"){if(Ur(t))t.push(e);else if(t&&typeof t=="object")(i&&(i.plainObjects||i.allowPrototypes)||!ga.call(Object.prototype,e))&&(t[e]=!0);else return[t,e];return t}if(!t||typeof t!="object")return[t].concat(e);var s=t;return Ur(t)&&!Ur(e)&&(s=tu(t,i)),Ur(t)&&Ur(e)?(e.forEach(function(n,o){if(ga.call(t,o)){var a=t[o];a&&typeof a=="object"&&n&&typeof n=="object"?t[o]=r(a,n,i):t.push(n)}else t[o]=n}),t):Object.keys(e).reduce(function(n,o){var a=e[o];return ga.call(n,o)?n[o]=r(n[o],a,i):n[o]=a,n},s)},y_=function(t,e){return Object.keys(e).reduce(function(i,s){return i[s]=e[s],i},t)},__=function(r,t,e){var i=r.replace(/\+/g," ");if(e==="iso-8859-1")return i.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(i)}catch{return i}},ya=1024,v_=function(t,e,i,s,n){if(t.length===0)return t;var o=t;if(typeof t=="symbol"?o=Symbol.prototype.toString.call(t):typeof t!="string"&&(o=String(t)),i==="iso-8859-1")return escape(o).replace(/%u[0-9a-f]{4}/gi,function(f){return"%26%23"+parseInt(f.slice(2),16)+"%3B"});for(var a="",l=0;l<o.length;l+=ya){for(var h=o.length>=ya?o.slice(l,l+ya):o,c=[],u=0;u<h.length;++u){var d=h.charCodeAt(u);if(d===45||d===46||d===95||d===126||d>=48&&d<=57||d>=65&&d<=90||d>=97&&d<=122||n===p_.RFC1738&&(d===40||d===41)){c[c.length]=h.charAt(u);continue}if(d<128){c[c.length]=Ge[d];continue}if(d<2048){c[c.length]=Ge[192|d>>6]+Ge[128|d&63];continue}if(d<55296||d>=57344){c[c.length]=Ge[224|d>>12]+Ge[128|d>>6&63]+Ge[128|d&63];continue}u+=1,d=65536+((d&1023)<<10|h.charCodeAt(u)&1023),c[c.length]=Ge[240|d>>18]+Ge[128|d>>12&63]+Ge[128|d>>6&63]+Ge[128|d&63]}a+=c.join("")}return a},x_=function(t){for(var e=[{obj:{o:t},prop:"o"}],i=[],s=0;s<e.length;++s)for(var n=e[s],o=n.obj[n.prop],a=Object.keys(o),l=0;l<a.length;++l){var h=a[l],c=o[h];typeof c=="object"&&c!==null&&i.indexOf(c)===-1&&(e.push({obj:o,prop:h}),i.push(c))}return m_(e),t},b_=function(t){return Object.prototype.toString.call(t)==="[object RegExp]"},w_=function(t){return!t||typeof t!="object"?!1:!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))},E_=function(t,e){return[].concat(t,e)},T_=function(t,e){if(Ur(t)){for(var i=[],s=0;s<t.length;s+=1)i.push(e(t[s]));return i}return e(t)},eu={arrayToObject:tu,assign:y_,combine:E_,compact:x_,decode:__,encode:v_,isBuffer:w_,isRegExp:b_,maybeMap:T_,merge:g_},ru=u_,hn=eu,ls=ma,A_=Object.prototype.hasOwnProperty,iu={brackets:function(t){return t+"[]"},comma:"comma",indices:function(t,e){return t+"["+e+"]"},repeat:function(t){return t}},$e=Array.isArray,S_=Array.prototype.push,su=function(r,t){S_.apply(r,$e(t)?t:[t])},I_=Date.prototype.toISOString,nu=ls.default,Lt={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:hn.encode,encodeValuesOnly:!1,format:nu,formatter:ls.formatters[nu],indices:!1,serializeDate:function(t){return I_.call(t)},skipNulls:!1,strictNullHandling:!1},C_=function(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||typeof t=="symbol"||typeof t=="bigint"},_a={},R_=function r(t,e,i,s,n,o,a,l,h,c,u,d,f,p,m,_,y,x){for(var g=t,v=x,w=0,I=!1;(v=v.get(_a))!==void 0&&!I;){var A=v.get(t);if(w+=1,typeof A<"u"){if(A===w)throw new RangeError("Cyclic object value");I=!0}typeof v.get(_a)>"u"&&(w=0)}if(typeof c=="function"?g=c(e,g):g instanceof Date?g=f(g):i==="comma"&&$e(g)&&(g=hn.maybeMap(g,function(P){return P instanceof Date?f(P):P})),g===null){if(o)return h&&!_?h(e,Lt.encoder,y,"key",p):e;g=""}if(C_(g)||hn.isBuffer(g)){if(h){var C=_?e:h(e,Lt.encoder,y,"key",p);return[m(C)+"="+m(h(g,Lt.encoder,y,"value",p))]}return[m(e)+"="+m(String(g))]}var N=[];if(typeof g>"u")return N;var S;if(i==="comma"&&$e(g))_&&h&&(g=hn.maybeMap(g,h)),S=[{value:g.length>0?g.join(",")||null:void 0}];else if($e(c))S=c;else{var R=Object.keys(g);S=u?R.sort(u):R}var E=l?e.replace(/\./g,"%2E"):e,b=s&&$e(g)&&g.length===1?E+"[]":E;if(n&&$e(g)&&g.length===0)return b+"[]";for(var D=0;D<S.length;++D){var F=S[D],G=typeof F=="object"&&typeof F.value<"u"?F.value:g[F];if(!(a&&G===null)){var $=d&&l?F.replace(/\./g,"%2E"):F,B=$e(g)?typeof i=="function"?i(b,$):b:b+(d?"."+$:"["+$+"]");x.set(t,w);var Z=ru();Z.set(_a,x),su(N,r(G,B,i,s,n,o,a,l,i==="comma"&&_&&$e(g)?null:h,c,u,d,f,p,m,_,y,Z))}}return N},P_=function(t){if(!t)return Lt;if(typeof t.allowEmptyArrays<"u"&&typeof t.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof t.encodeDotInKeys<"u"&&typeof t.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(t.encoder!==null&&typeof t.encoder<"u"&&typeof t.encoder!="function")throw new TypeError("Encoder has to be a function.");var e=t.charset||Lt.charset;if(typeof t.charset<"u"&&t.charset!=="utf-8"&&t.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var i=ls.default;if(typeof t.format<"u"){if(!A_.call(ls.formatters,t.format))throw new TypeError("Unknown format option provided.");i=t.format}var s=ls.formatters[i],n=Lt.filter;(typeof t.filter=="function"||$e(t.filter))&&(n=t.filter);var o;if(t.arrayFormat in iu?o=t.arrayFormat:"indices"in t?o=t.indices?"indices":"repeat":o=Lt.arrayFormat,"commaRoundTrip"in t&&typeof t.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var a=typeof t.allowDots>"u"?t.encodeDotInKeys===!0?!0:Lt.allowDots:!!t.allowDots;return{addQueryPrefix:typeof t.addQueryPrefix=="boolean"?t.addQueryPrefix:Lt.addQueryPrefix,allowDots:a,allowEmptyArrays:typeof t.allowEmptyArrays=="boolean"?!!t.allowEmptyArrays:Lt.allowEmptyArrays,arrayFormat:o,charset:e,charsetSentinel:typeof t.charsetSentinel=="boolean"?t.charsetSentinel:Lt.charsetSentinel,commaRoundTrip:t.commaRoundTrip,delimiter:typeof t.delimiter>"u"?Lt.delimiter:t.delimiter,encode:typeof t.encode=="boolean"?t.encode:Lt.encode,encodeDotInKeys:typeof t.encodeDotInKeys=="boolean"?t.encodeDotInKeys:Lt.encodeDotInKeys,encoder:typeof t.encoder=="function"?t.encoder:Lt.encoder,encodeValuesOnly:typeof t.encodeValuesOnly=="boolean"?t.encodeValuesOnly:Lt.encodeValuesOnly,filter:n,format:i,formatter:s,serializeDate:typeof t.serializeDate=="function"?t.serializeDate:Lt.serializeDate,skipNulls:typeof t.skipNulls=="boolean"?t.skipNulls:Lt.skipNulls,sort:typeof t.sort=="function"?t.sort:null,strictNullHandling:typeof t.strictNullHandling=="boolean"?t.strictNullHandling:Lt.strictNullHandling}},M_=function(r,t){var e=r,i=P_(t),s,n;typeof i.filter=="function"?(n=i.filter,e=n("",e)):$e(i.filter)&&(n=i.filter,s=n);var o=[];if(typeof e!="object"||e===null)return"";var a=iu[i.arrayFormat],l=a==="comma"&&i.commaRoundTrip;s||(s=Object.keys(e)),i.sort&&s.sort(i.sort);for(var h=ru(),c=0;c<s.length;++c){var u=s[c];i.skipNulls&&e[u]===null||su(o,R_(e[u],u,a,l,i.allowEmptyArrays,i.strictNullHandling,i.skipNulls,i.encodeDotInKeys,i.encode?i.encoder:null,i.filter,i.sort,i.allowDots,i.serializeDate,i.format,i.formatter,i.encodeValuesOnly,i.charset,h))}var d=o.join(i.delimiter),f=i.addQueryPrefix===!0?"?":"";return i.charsetSentinel&&(i.charset==="iso-8859-1"?f+="utf8=%26%2310003%3B&":f+="utf8=%E2%9C%93&"),d.length>0?f+d:""},Ei=eu,va=Object.prototype.hasOwnProperty,B_=Array.isArray,Pt={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:Ei.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictNullHandling:!1},D_=function(r){return r.replace(/&#(\d+);/g,function(t,e){return String.fromCharCode(parseInt(e,10))})},ou=function(r,t){return r&&typeof r=="string"&&t.comma&&r.indexOf(",")>-1?r.split(","):r},O_="utf8=%26%2310003%3B",F_="utf8=%E2%9C%93",L_=function(t,e){var i={__proto__:null},s=e.ignoreQueryPrefix?t.replace(/^\?/,""):t;s=s.replace(/%5B/gi,"[").replace(/%5D/gi,"]");var n=e.parameterLimit===1/0?void 0:e.parameterLimit,o=s.split(e.delimiter,n),a=-1,l,h=e.charset;if(e.charsetSentinel)for(l=0;l<o.length;++l)o[l].indexOf("utf8=")===0&&(o[l]===F_?h="utf-8":o[l]===O_&&(h="iso-8859-1"),a=l,l=o.length);for(l=0;l<o.length;++l)if(l!==a){var c=o[l],u=c.indexOf("]="),d=u===-1?c.indexOf("="):u+1,f,p;d===-1?(f=e.decoder(c,Pt.decoder,h,"key"),p=e.strictNullHandling?null:""):(f=e.decoder(c.slice(0,d),Pt.decoder,h,"key"),p=Ei.maybeMap(ou(c.slice(d+1),e),function(_){return e.decoder(_,Pt.decoder,h,"value")})),p&&e.interpretNumericEntities&&h==="iso-8859-1"&&(p=D_(p)),c.indexOf("[]=")>-1&&(p=B_(p)?[p]:p);var m=va.call(i,f);m&&e.duplicates==="combine"?i[f]=Ei.combine(i[f],p):(!m||e.duplicates==="last")&&(i[f]=p)}return i},N_=function(r,t,e,i){for(var s=i?t:ou(t,e),n=r.length-1;n>=0;--n){var o,a=r[n];if(a==="[]"&&e.parseArrays)o=e.allowEmptyArrays&&(s===""||e.strictNullHandling&&s===null)?[]:[].concat(s);else{o=e.plainObjects?Object.create(null):{};var l=a.charAt(0)==="["&&a.charAt(a.length-1)==="]"?a.slice(1,-1):a,h=e.decodeDotInKeys?l.replace(/%2E/g,"."):l,c=parseInt(h,10);!e.parseArrays&&h===""?o={0:s}:!isNaN(c)&&a!==h&&String(c)===h&&c>=0&&e.parseArrays&&c<=e.arrayLimit?(o=[],o[c]=s):h!=="__proto__"&&(o[h]=s)}s=o}return s},U_=function(t,e,i,s){if(t){var n=i.allowDots?t.replace(/\.([^.[]+)/g,"[$1]"):t,o=/(\[[^[\]]*])/,a=/(\[[^[\]]*])/g,l=i.depth>0&&o.exec(n),h=l?n.slice(0,l.index):n,c=[];if(h){if(!i.plainObjects&&va.call(Object.prototype,h)&&!i.allowPrototypes)return;c.push(h)}for(var u=0;i.depth>0&&(l=a.exec(n))!==null&&u<i.depth;){if(u+=1,!i.plainObjects&&va.call(Object.prototype,l[1].slice(1,-1))&&!i.allowPrototypes)return;c.push(l[1])}if(l){if(i.strictDepth===!0)throw new RangeError("Input depth exceeded depth option of "+i.depth+" and strictDepth is true");c.push("["+n.slice(l.index)+"]")}return N_(c,e,i,s)}},k_=function(t){if(!t)return Pt;if(typeof t.allowEmptyArrays<"u"&&typeof t.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof t.decodeDotInKeys<"u"&&typeof t.decodeDotInKeys!="boolean")throw new TypeError("`decodeDotInKeys` option can only be `true` or `false`, when provided");if(t.decoder!==null&&typeof t.decoder<"u"&&typeof t.decoder!="function")throw new TypeError("Decoder has to be a function.");if(typeof t.charset<"u"&&t.charset!=="utf-8"&&t.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var e=typeof t.charset>"u"?Pt.charset:t.charset,i=typeof t.duplicates>"u"?Pt.duplicates:t.duplicates;if(i!=="combine"&&i!=="first"&&i!=="last")throw new TypeError("The duplicates option must be either combine, first, or last");var s=typeof t.allowDots>"u"?t.decodeDotInKeys===!0?!0:Pt.allowDots:!!t.allowDots;return{allowDots:s,allowEmptyArrays:typeof t.allowEmptyArrays=="boolean"?!!t.allowEmptyArrays:Pt.allowEmptyArrays,allowPrototypes:typeof t.allowPrototypes=="boolean"?t.allowPrototypes:Pt.allowPrototypes,allowSparse:typeof t.allowSparse=="boolean"?t.allowSparse:Pt.allowSparse,arrayLimit:typeof t.arrayLimit=="number"?t.arrayLimit:Pt.arrayLimit,charset:e,charsetSentinel:typeof t.charsetSentinel=="boolean"?t.charsetSentinel:Pt.charsetSentinel,comma:typeof t.comma=="boolean"?t.comma:Pt.comma,decodeDotInKeys:typeof t.decodeDotInKeys=="boolean"?t.decodeDotInKeys:Pt.decodeDotInKeys,decoder:typeof t.decoder=="function"?t.decoder:Pt.decoder,delimiter:typeof t.delimiter=="string"||Ei.isRegExp(t.delimiter)?t.delimiter:Pt.delimiter,depth:typeof t.depth=="number"||t.depth===!1?+t.depth:Pt.depth,duplicates:i,ignoreQueryPrefix:t.ignoreQueryPrefix===!0,interpretNumericEntities:typeof t.interpretNumericEntities=="boolean"?t.interpretNumericEntities:Pt.interpretNumericEntities,parameterLimit:typeof t.parameterLimit=="number"?t.parameterLimit:Pt.parameterLimit,parseArrays:t.parseArrays!==!1,plainObjects:typeof t.plainObjects=="boolean"?t.plainObjects:Pt.plainObjects,strictDepth:typeof t.strictDepth=="boolean"?!!t.strictDepth:Pt.strictDepth,strictNullHandling:typeof t.strictNullHandling=="boolean"?t.strictNullHandling:Pt.strictNullHandling}},G_=function(r,t){var e=k_(t);if(r===""||r===null||typeof r>"u")return e.plainObjects?Object.create(null):{};for(var i=typeof r=="string"?L_(r,e):r,s=e.plainObjects?Object.create(null):{},n=Object.keys(i),o=0;o<n.length;++o){var a=n[o],l=U_(a,i[a],e,typeof r=="string");s=Ei.merge(s,l,e)}return e.allowSparse===!0?s:Ei.compact(s)},$_=M_,H_=G_,X_=ma,V_={formats:X_,parse:H_,stringify:$_},z_=Cy;function or(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var W_=/^([a-z0-9.+-]+:)/i,j_=/:[0-9]*$/,Y_=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,q_=["<",">",'"',"`"," ","\r",`
|
|
@@ -1144,5 +1144,5 @@ void main(void)\r
|
|
|
1144
1144
|
font-weight: ${e.weight};
|
|
1145
1145
|
font-style: ${e.style};
|
|
1146
1146
|
font-display: ${e.display};
|
|
1147
|
-
}`,this._stylesheet)}get stylesheet(){return this._stylesheet}set stylesheet(t){this._stylesheet!==t&&(this._stylesheet=t,this.styleID++)}normalizeColor(t){return Array.isArray(t)&&(t=gv(t)),typeof t=="number"?mv(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,$i.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}=W.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}};Rl.availableFonts={},Rl.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 Pl=Rl;const Qn=class Hi extends Pi{constructor(t="",e={}){super(q.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=q.from(i,{scaleMode:W.SCALE_MODE,resourceOptions:{autoLoad:!1}});s.orig=new at,s.trim=new at,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"),c=document.createElementNS(o,"style");l.setAttribute("width","10000"),l.setAttribute("height","10000"),l.style.overflow="hidden",a.appendChild(l),this.maxWidth=Hi.defaultMaxWidth,this.maxHeight=Hi.defaultMaxHeight,this._domElement=h,this._styleElement=c,this._svgRoot=a,this._foreignObject=l,this._foreignObject.appendChild(c),this._foreignObject.appendChild(h),this._image=i,this._loadImage=new Image,this._autoResolution=Hi.defaultAutoResolution,this._resolution=Hi.defaultResolution??W.RESOLUTION,this.text=t,this.style=e}measureText(t){var c,u;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:(c=this._style)==null?void 0:c.toCSS(s)}),this._styleElement.textContent=(u=this._style)==null?void 0:u.toGlobalCSS()),{width:l+i.padding*2,height:h+i.padding*2}}async updateText(t=!0){const{style:e,_image:i,_loadImage: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({},Hi.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=vr(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=vr(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 Pl?(this.ownsStyle=!1,this._style=t):t instanceof Sr?(console.warn("[HTMLText] Cloning TextStyle, if this is not what you want, use HTMLTextStyle"),this.ownsStyle=!0,this._style=Pl.from(t)):(this.ownsStyle=!0,this._style=new Pl(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," ")}};Qn.defaultDestroyOptions={texture:!0,children:!1,baseTexture:!0},Qn.defaultMaxWidth=2024,Qn.defaultMaxHeight=2024,Qn.defaultAutoResolution=!0;const Cw=16777215,Rw=.25,Pw=16777215,Mw=1.5;let Rr=!1,xs;const Ml=r=>{const t={tint:r!=null&&r.fill?new bt(r.fill).toNumber():Cw,alpha:(r==null?void 0:r.fillOpacity)===void 0?Rw:Math.min(r.fillOpacity,1)},e={tint:r!=null&&r.stroke?new bt(r.stroke).toNumber():Pw,alpha:(r==null?void 0:r.strokeOpacity)===void 0?1:Math.min(r.strokeOpacity,1),lineWidth:(r==null?void 0:r.strokeWidth)===void 0?Mw:r.strokeWidth};return{fillStyle:t,strokeStyle:e}},Bl=r=>(t,e,i)=>{const{fillStyle:s,strokeStyle:n}=Ml(i),o=new vs;o.beginFill(16777215),r(e,o),o.endFill(),o.tint=s.tint,o.alpha=s.alpha,t.addChild(o);const a=new vs,l=n.lineWidth===1?1:n.lineWidth/xs;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}},Bw=Bl((r,t)=>{const{cx:e,cy:i,rx:s,ry:n}=r.geometry;t.drawEllipse(e,i,s,n)}),Dw=Bl((r,t)=>{const e=r.geometry.points.reduce((i,s)=>[...i,...s],[]);t.drawPolygon(e)}),Ow=Bl((r,t)=>{const{x:e,y:i,w:s,h:n}=r.geometry;t.drawRect(e,i,s,n)}),Tf=r=>{const t=r.viewport.getContainerSize().x;return r.viewport.getZoom(!0)*t/r.world.getContentFactor()},Af=(r,t,e,i)=>()=>{const s=r.viewport.viewportToImageRectangle(r.viewport.getBounds(!0)),n=Tf(r);(n!==xs||!Rr)&&(Rr=!0,e.forEach(({stroke:d,strokeWidth:f})=>{const{lineStyle:p}=d.geometry.graphicsData[0];f>1?(Rr=n===xs,p.width=f/n,d.geometry.invalidate()):f===1&&!p.native&&(p.width=1,p.native=!0,d.geometry.invalidate())})),xs=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 c,u;a>0&&a<=Math.PI/2?(c=s.height*n,u=0):a>Math.PI/2&&a<=Math.PI?(c=s.width*n,u=s.height*n):a>Math.PI&&a<=Math.PI*1.5?(c=0,u=s.width*n):(c=0,u=0),t.position.x=c+l*Math.cos(a)-h*Math.sin(a),t.position.y=u+l*Math.sin(a)+h*Math.cos(a),t.scale.set(o?-n:n,n),t.rotation=a,i.render(t)},Fw=(r,t)=>{const e=new vs,i=xd({width:t.width,height:t.height,backgroundAlpha:0,view:t,antialias:!0,resolution:2}),s=new Map;let n=new Set,o,a;xs=Tf(r);const l=(g,v)=>{Rr=!1;const{selector:w}=g.target,I=typeof a=="function"?a(g,v):a;let A;w.type===wt.RECTANGLE?A=Ow(e,w,I):w.type===wt.POLYGON?A=Dw(e,w,I):w.type===wt.ELLIPSE?A=Bw(e,w,I):console.warn(`Unsupported shape type: ${w.type}`),A&&s.set(g.id,{annotation:g,...A})},h=g=>{const v=s.get(g.id);v&&(s.delete(g.id),v.fill.destroy(),v.stroke.destroy())},c=(g,v,w)=>{Rr=!1;const I=s.get(g.id);I&&(s.delete(g.id),I.fill.destroy(),I.stroke.destroy(),l(v,w))},u=(g,v)=>{const w=s.get(g);w&&(s.delete(g),w.fill.destroy(),w.stroke.destroy(),l(w.annotation,v))},d=(g,v)=>{i.resize(g,v),i.render(e)},f=g=>{Rr=!1;const{children:v}=e;s.forEach(({fill:w,stroke:I,annotation:A})=>{const C=g?n.has(A.id)||g(A):!0;C&&!v.includes(w)?(e.addChild(w),e.addChild(I)):!C&&v.includes(w)&&(e.removeChild(w),e.removeChild(I))}),i.render(e)},p=g=>{o!==g&&(o&&u(o,{selected:n.has(o)}),g&&u(g,{selected:n.has(g),hovered:!0}),o=g,i.render(e))},m=g=>{const v=g.selected.map(A=>A.id),w=v.filter(A=>!n.has(A)),I=[...n].filter(A=>!v.includes(A));[...w,...I].forEach(A=>u(A,{selected:v.includes(A),hovered:A===o})),n=new Set(v),i.render(e)},_=g=>{if(typeof g=="function")s.forEach(({annotation:v,fill:w,stroke:I,strokeWidth:A},C)=>{A>1&&(Rr=!1);const N={selected:n.has(v.id),hovered:o===v.id},{fillStyle:S,strokeStyle:R}=Ml(g(v,N));w.tint=S.tint,w.alpha=S.alpha,I.tint=R.tint||16777215,I.alpha=R.alpha,s.set(v.id,{annotation:v,fill:w,stroke:I,strokeWidth:R.lineWidth})});else{const{fillStyle:v,strokeStyle:w}=Ml(g);w.lineWidth>1&&(Rr=!1),s.forEach(({annotation:I,fill:A,stroke:C,strokeWidth:N},S)=>{A.tint=v.tint,A.alpha=v.alpha,C.tint=w.tint||16777215,C.alpha=w.alpha,s.set(I.id,{annotation:I,fill:A,stroke:C,strokeWidth:w.lineWidth})})}a=g,i.render(e),Af(r,e,s,i)()},y=g=>{g?t.classList.remove("hidden"):t.classList.add("hidden")};return{addAnnotation:l,destroy:()=>i.destroy(),redraw:Af(r,e,s,i),removeAnnotation:h,resize:d,setFilter:f,setHovered:p,setSelected:m,setStyle:_,setVisible:y,updateAnnotation:c}};function Lw(r,t,e){let i,s,{filter:n}=t,{state:o}=t,{style:a}=t,{viewer:l}=t,{visible:h=!0}=t;const{store:c,hover:u,selection:d,viewport:f}=o;Do(r,u,I=>e(11,i=I)),Do(r,d,I=>e(8,s=I));const p=zs();let m,_;const y=I=>{const A=new Nt.Point(I.x,I.y),{x:C,y:N}=l.viewport.pointFromPixel(A);return l.viewport.viewportToImageCoordinates(C,N)},x=I=>{const{x:A,y:C}=I.position;_={x:A,y:C}},g=I=>A=>{const{x:C,y:N}=y(new Nt.Point(A.offsetX,A.offsetY)),S=c.getAt(C,N);S&&(!n||n(S))?(I.classList.add("hover"),i!==S.id&&(u.set(S.id),m.setHovered(S.id))):(I.classList.remove("hover"),i&&(u.set(void 0),m.setHovered(void 0)))},v=I=>{if(!_)return;const A=I.originalEvent,{x:C,y:N}=I.position,S=C-_.x,R=N-_.y;if(Math.sqrt(S*S+R*R)<5){const{x:b,y:D}=y(I.position),F=c.getAt(b,D);F?p("click",{originalEvent:A,annotation:F}):p("click",{originalEvent:A})}_=void 0};let w;return Vs(()=>{var F;const{offsetWidth:I,offsetHeight:A}=l.canvas,C=document.createElement("canvas");C.width=I,C.height=A,C.className="a9s-gl-canvas",(F=l.element.querySelector(".openseadragon-canvas"))==null||F.appendChild(C),e(7,m=Fw(l,C));const N=g(C);C.addEventListener("pointermove",N);const S=new ResizeObserver(G=>{try{const{width:$,height:B}=G[0].contentRect;C.width=$,C.height=B,m.resize($,B)}catch{console.warn("WebGL canvas already disposed")}});S.observe(C);const R=()=>{const G=l.viewport.getBounds();w=l.viewport.viewportToImageRectangle(G);const{x:$,y:B,width:Z,height:P}=w,U=c.getIntersecting($,B,Z,P);f.set(U.map(j=>j.id))};l.addHandler("canvas-press",x),l.addHandler("canvas-release",v),l.addHandler("update-viewport",m.redraw),l.addHandler("animation-finish",R);const E=G=>G.filter($=>Je($)),b=G=>Je(G.oldValue)&&Je(G.newValue),D=G=>{const{created:$,updated:B,deleted:Z}=G.changes;if(E($||[]).forEach(P=>m.addAnnotation(P)),E(Z||[]).forEach(P=>m.removeAnnotation(P)),(B||[]).filter(P=>b(P)).forEach(({oldValue:P,newValue:U})=>m.updateAnnotation(P,U)),w){const{x:P,y:U,width:j,height:rt}=w,Q=c.getIntersecting(P,U,j,rt);f.set(Q.map(H=>H.id))}else f.set(c.all().map(P=>P.id));m.redraw()};return c.observe(D),()=>{var G;C.removeEventListener("pointermove",N),S.disconnect(),l.removeHandler("canvas-press",x),l.removeHandler("canvas-release",v),l.removeHandler("update-viewport",m.redraw),l.removeHandler("animation-finish",R),c.unobserve(D),m.destroy(),(G=C.parentNode)==null||G.removeChild(C)}}),r.$$set=I=>{"filter"in I&&e(2,n=I.filter),"state"in I&&e(3,o=I.state),"style"in I&&e(4,a=I.style),"viewer"in I&&e(5,l=I.viewer),"visible"in I&&e(6,h=I.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))},[u,d,n,o,a,l,h,m,s]}class Nw extends ae{constructor(t){super(),oe(this,t,Lw,null,te,{filter:2,state:3,style:4,viewer:5,visible:6})}}for(var Yt=[],Dl=0;Dl<256;++Dl)Yt.push((Dl+256).toString(16).slice(1));function Uw(r,t=0){return(Yt[r[t+0]]+Yt[r[t+1]]+Yt[r[t+2]]+Yt[r[t+3]]+"-"+Yt[r[t+4]]+Yt[r[t+5]]+"-"+Yt[r[t+6]]+Yt[r[t+7]]+"-"+Yt[r[t+8]]+Yt[r[t+9]]+"-"+Yt[r[t+10]]+Yt[r[t+11]]+Yt[r[t+12]]+Yt[r[t+13]]+Yt[r[t+14]]+Yt[r[t+15]]).toLowerCase()}var to,kw=new Uint8Array(16);function Gw(){if(!to&&(to=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!to))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return to(kw)}var $w=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const Sf={randomUUID:$w};function Hw(r,t,e){if(Sf.randomUUID&&!t&&!r)return Sf.randomUUID();r=r||{};var i=r.random||(r.rng||Gw)();return i[6]=i[6]&15|64,i[8]=i[8]&63|128,Uw(i)}var Ui=(r=>(r.ELLIPSE="ELLIPSE",r.POLYGON="POLYGON",r.RECTANGLE="RECTANGLE",r))(Ui||{});const Ol=(r,t)=>t,Xw=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}},Vw={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),c=t-i,u=e-s,d=l*c+h*u,f=h*c-l*u;return d*d/(n*n)+f*f/(o*o)<=1}};Ol(Ui.ELLIPSE,Vw);const zw={area:r=>{const{points:t}=r.geometry;let e=0,i=t.length-1;for(let s=0;s<t.length;s++)e+=(t[i][0]+t[s][0])*(t[i][1]-t[s][1]),i=s;return Math.abs(.5*e)},intersects:(r,t,e)=>{const{points:i}=r.geometry;let s=!1;for(let n=0,o=i.length-1;n<i.length;o=n++){const a=i[n][0],l=i[n][1],h=i[o][0],c=i[o][1];l>e!=c>e&&t<(h-a)*(e-l)/(c-l)+a&&(s=!s)}return s}};Ol(Ui.POLYGON,zw);const Ww={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};Ol(Ui.RECTANGLE,Ww);function If(r,t,e){const i=r.slice();return i[10]=t[e],i[12]=e,i}function Cf(r){let t,e;return t=new bs({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(){ee(t.$$.fragment)},m(i,s){Zt(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||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Jt(t,i)}}}function jw(r){let t,e,i,s,n,o,a,l,h,c,u,d=ui(r[4].points),f=[];for(let m=0;m<d.length;m+=1)f[m]=Cf(If(r,d,m));const p=m=>ut(f[m],1,1,()=>{f[m]=null});return{c(){t=Tt("polygon"),s=xe(),n=Tt("polygon"),a=xe();for(let m=0;m<f.length;m+=1)f[m].c();l=er(),M(t,"class","a9s-outer"),M(t,"style",e=r[1]?"display:none;":void 0),M(t,"points",i=r[4].points.map(Rf).join(" ")),M(n,"class","a9s-inner a9s-shape-handle"),M(n,"style",r[1]),M(n,"points",o=r[4].points.map(Pf).join(" "))},m(m,_){ft(m,t,_),ft(m,s,_),ft(m,n,_),ft(m,a,_);for(let y=0;y<f.length;y+=1)f[y]&&f[y].m(m,_);ft(m,l,_),h=!0,c||(u=[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)})],c=!0)},p(m,_){if(r=m,(!h||_&2&&e!==(e=r[1]?"display:none;":void 0))&&M(t,"style",e),(!h||_&16&&i!==(i=r[4].points.map(Rf).join(" ")))&&M(t,"points",i),(!h||_&2)&&M(n,"style",r[1]),(!h||_&16&&o!==(o=r[4].points.map(Pf).join(" ")))&&M(n,"points",o),_&536){d=ui(r[4].points);let y;for(y=0;y<d.length;y+=1){const x=If(r,d,y);f[y]?(f[y].p(x,_),st(f[y],1)):(f[y]=Cf(x),f[y].c(),st(f[y],1),f[y].m(l.parentNode,l))}for(De(),y=d.length;y<f.length;y+=1)p(y);Oe()}},i(m){if(!h){for(let _=0;_<d.length;_+=1)st(f[_]);h=!0}},o(m){f=f.filter(Boolean);for(let _=0;_<f.length;_+=1)ut(f[_]);h=!1},d(m){m&&(ct(t),ct(s),ct(n),ct(a),ct(l)),Oo(f,m),c=!1,Qe(u)}}}function Yw(r){let t,e;return t=new Bf({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[jw,({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(){ee(t.$$.fragment)},m(i,s){Zt(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||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Jt(t,i)}}}const Rf=r=>r.join(","),Pf=r=>r.join(",");function qw(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 _=d.geometry;f==="SHAPE"?m=_.points.map(([x,g])=>[x+p[0],g+p[1]]):m=_.points.map(([x,g],v)=>f===`HANDLE-${v}`?[x+p[0],g+p[1]]:[x,g]);const y=Xw(m);return{...d,geometry:{points:m,bounds:y}}};function h(d){rr.call(this,r,d)}function c(d){rr.call(this,r,d)}function u(d){rr.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,c,u]}class Kw extends ae{constructor(t){super(),oe(this,t,qw,Yw,te,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}const Zw=typeof window>"u"||typeof navigator>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0;function Jw(r){let t,e,i,s,n,o;return{c(){t=Tt("rect"),M(t,"class",e=Hs(`a9s-handle ${r[8].class||""}`.trim())+" svelte-1sgkh33"),M(t,"x",i=r[0]-r[5]/2),M(t,"y",s=r[1]-r[5]/2),M(t,"width",r[5]),M(t,"height",r[5])},m(a,l){ft(a,t,l),n||(o=zt(t,"pointerdown",r[11]),n=!0)},p(a,l){l&256&&e!==(e=Hs(`a9s-handle ${a[8].class||""}`.trim())+" svelte-1sgkh33")&&M(t,"class",e),l&33&&i!==(i=a[0]-a[5]/2)&&M(t,"x",i),l&34&&s!==(s=a[1]-a[5]/2)&&M(t,"y",s),l&32&&M(t,"width",a[5]),l&32&&M(t,"height",a[5])},d(a){a&&ct(t),n=!1,o()}}}function Qw(r){let t,e,i,s,n,o,a,l,h;return{c(){t=Tt("g"),e=Tt("circle"),s=Tt("rect"),M(e,"cx",r[0]),M(e,"cy",r[1]),M(e,"r",i=r[3]/r[2]),M(e,"class","a9s-touch-halo svelte-1sgkh33"),Xs(e,"touched",r[4]),M(s,"class",n=Hs(`a9s-handle ${r[8].class||""}`.trim())+" svelte-1sgkh33"),M(s,"x",o=r[0]-r[5]/2),M(s,"y",a=r[1]-r[5]/2),M(s,"width",r[5]),M(s,"height",r[5]),M(t,"class","a9s-touch-handle")},m(c,u){ft(c,t,u),tr(t,e),tr(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(c,u){u&1&&M(e,"cx",c[0]),u&2&&M(e,"cy",c[1]),u&12&&i!==(i=c[3]/c[2])&&M(e,"r",i),u&16&&Xs(e,"touched",c[4]),u&256&&n!==(n=Hs(`a9s-handle ${c[8].class||""}`.trim())+" svelte-1sgkh33")&&M(s,"class",n),u&33&&o!==(o=c[0]-c[5]/2)&&M(s,"x",o),u&34&&a!==(a=c[1]-c[5]/2)&&M(s,"y",a),u&32&&M(s,"width",c[5]),u&32&&M(s,"height",c[5])},d(c){c&&ct(t),l=!1,Qe(h)}}}function tE(r){let t;function e(n,o){return Zw?Qw:Jw}let s=e()(r);return{c(){s.c(),t=er()},m(n,o){s.m(n,o),ft(n,t,o)},p(n,[o]){s.p(n,o)},i:Be,o:Be,d(n){n&&ct(t),s.d(n)}}}function eE(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)},c=()=>e(4,l=!1);function u(p){rr.call(this,r,p)}function d(p){rr.call(this,r,p)}function f(p){rr.call(this,r,p)}return r.$$set=p=>{e(8,t=Bo(Bo({},t),Kh(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=Kh(t),[s,n,o,a,l,i,h,c,t,u,d,f]}class bs extends ae{constructor(t){super(),oe(this,t,eE,tE,te,{x:0,y:1,scale:2,radius:3})}}function rE(r){let t,e,i,s,n,o,a,l,h,c,u,d,f,p,m,_,y,x,g,v,w,I,A,C,N,S,R,E,b,D,F,G,$,B,Z,P,U,j,rt,Q,H,V,lt;return B=new bs({props:{class:"a9s-corner-handle-topleft",x:r[4].x,y:r[4].y,scale:r[3]}}),B.$on("pointerdown",function(){Kt(r[9]("TOP_LEFT"))&&r[9]("TOP_LEFT").apply(this,arguments)}),P=new bs({props:{class:"a9s-corner-handle-topright",x:r[4].x+r[4].w,y:r[4].y,scale:r[3]}}),P.$on("pointerdown",function(){Kt(r[9]("TOP_RIGHT"))&&r[9]("TOP_RIGHT").apply(this,arguments)}),j=new bs({props:{class:"a9s-corner-handle-bottomright",x:r[4].x+r[4].w,y:r[4].y+r[4].h,scale:r[3]}}),j.$on("pointerdown",function(){Kt(r[9]("BOTTOM_RIGHT"))&&r[9]("BOTTOM_RIGHT").apply(this,arguments)}),Q=new bs({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=Tt("rect"),a=xe(),l=Tt("rect"),f=xe(),p=Tt("rect"),x=xe(),g=Tt("rect"),A=xe(),C=Tt("rect"),E=xe(),b=Tt("rect"),$=xe(),ee(B.$$.fragment),Z=xe(),ee(P.$$.fragment),U=xe(),ee(j.$$.fragment),rt=xe(),ee(Q.$$.fragment),M(t,"class","a9s-outer"),M(t,"style",e=r[1]?"display:none;":void 0),M(t,"x",i=r[4].x),M(t,"y",s=r[4].y),M(t,"width",n=r[4].w),M(t,"height",o=r[4].h),M(l,"class","a9s-inner a9s-shape-handle"),M(l,"style",r[1]),M(l,"x",h=r[4].x),M(l,"y",c=r[4].y),M(l,"width",u=r[4].w),M(l,"height",d=r[4].h),M(p,"class","a9s-edge-handle a9s-edge-handle-top"),M(p,"x",m=r[4].x),M(p,"y",_=r[4].y),M(p,"height",1),M(p,"width",y=r[4].w),M(g,"class","a9s-edge-handle a9s-edge-handle-right"),M(g,"x",v=r[4].x+r[4].w),M(g,"y",w=r[4].y),M(g,"height",I=r[4].h),M(g,"width",1),M(C,"class","a9s-edge-handle a9s-edge-handle-bottom"),M(C,"x",N=r[4].x),M(C,"y",S=r[4].y+r[4].h),M(C,"height",1),M(C,"width",R=r[4].w),M(b,"class","a9s-edge-handle a9s-edge-handle-left"),M(b,"x",D=r[4].x),M(b,"y",F=r[4].y),M(b,"height",G=r[4].h),M(b,"width",1)},m(L,O){ft(L,t,O),ft(L,a,O),ft(L,l,O),ft(L,f,O),ft(L,p,O),ft(L,x,O),ft(L,g,O),ft(L,A,O),ft(L,C,O),ft(L,E,O),ft(L,b,O),ft(L,$,O),Zt(B,L,O),ft(L,Z,O),Zt(P,L,O),ft(L,U,O),Zt(j,L,O),ft(L,rt,O),Zt(Q,L,O),H=!0,V||(lt=[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(C,"pointerdown",function(){Kt(r[9]("BOTTOM"))&&r[9]("BOTTOM").apply(this,arguments)}),zt(b,"pointerdown",function(){Kt(r[9]("LEFT"))&&r[9]("LEFT").apply(this,arguments)})],V=!0)},p(L,O){r=L,(!H||O&2&&e!==(e=r[1]?"display:none;":void 0))&&M(t,"style",e),(!H||O&16&&i!==(i=r[4].x))&&M(t,"x",i),(!H||O&16&&s!==(s=r[4].y))&&M(t,"y",s),(!H||O&16&&n!==(n=r[4].w))&&M(t,"width",n),(!H||O&16&&o!==(o=r[4].h))&&M(t,"height",o),(!H||O&2)&&M(l,"style",r[1]),(!H||O&16&&h!==(h=r[4].x))&&M(l,"x",h),(!H||O&16&&c!==(c=r[4].y))&&M(l,"y",c),(!H||O&16&&u!==(u=r[4].w))&&M(l,"width",u),(!H||O&16&&d!==(d=r[4].h))&&M(l,"height",d),(!H||O&16&&m!==(m=r[4].x))&&M(p,"x",m),(!H||O&16&&_!==(_=r[4].y))&&M(p,"y",_),(!H||O&16&&y!==(y=r[4].w))&&M(p,"width",y),(!H||O&16&&v!==(v=r[4].x+r[4].w))&&M(g,"x",v),(!H||O&16&&w!==(w=r[4].y))&&M(g,"y",w),(!H||O&16&&I!==(I=r[4].h))&&M(g,"height",I),(!H||O&16&&N!==(N=r[4].x))&&M(C,"x",N),(!H||O&16&&S!==(S=r[4].y+r[4].h))&&M(C,"y",S),(!H||O&16&&R!==(R=r[4].w))&&M(C,"width",R),(!H||O&16&&D!==(D=r[4].x))&&M(b,"x",D),(!H||O&16&&F!==(F=r[4].y))&&M(b,"y",F),(!H||O&16&&G!==(G=r[4].h))&&M(b,"height",G);const _t={};O&16&&(_t.x=r[4].x),O&16&&(_t.y=r[4].y),O&8&&(_t.scale=r[3]),B.$set(_t);const ht={};O&16&&(ht.x=r[4].x+r[4].w),O&16&&(ht.y=r[4].y),O&8&&(ht.scale=r[3]),P.$set(ht);const vt={};O&16&&(vt.x=r[4].x+r[4].w),O&16&&(vt.y=r[4].y+r[4].h),O&8&&(vt.scale=r[3]),j.$set(vt);const xt={};O&16&&(xt.x=r[4].x),O&16&&(xt.y=r[4].y+r[4].h),O&8&&(xt.scale=r[3]),Q.$set(xt)},i(L){H||(st(B.$$.fragment,L),st(P.$$.fragment,L),st(j.$$.fragment,L),st(Q.$$.fragment,L),H=!0)},o(L){ut(B.$$.fragment,L),ut(P.$$.fragment,L),ut(j.$$.fragment,L),ut(Q.$$.fragment,L),H=!1},d(L){L&&(ct(t),ct(a),ct(l),ct(f),ct(p),ct(x),ct(g),ct(A),ct(C),ct(E),ct(b),ct($),ct(Z),ct(U),ct(rt)),Jt(B,L),Jt(P,L),Jt(j,L),Jt(Q,L),V=!1,Qe(lt)}}}function iE(r){let t,e;return t=new Bf({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[rE,({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(){ee(t.$$.fragment)},m(i,s){Zt(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||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Jt(t,i)}}}function sE(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],[x,g]=[m.maxX,m.maxY];const[v,w]=p;if(f==="SHAPE")_+=v,x+=v,y+=w,g+=w;else{switch(f){case"TOP":case"TOP_LEFT":case"TOP_RIGHT":{y+=w;break}case"BOTTOM":case"BOTTOM_LEFT":case"BOTTOM_RIGHT":{g+=w;break}}switch(f){case"LEFT":case"TOP_LEFT":case"BOTTOM_LEFT":{_+=v;break}case"RIGHT":case"TOP_RIGHT":case"BOTTOM_RIGHT":{x+=v;break}}}const I=Math.min(_,x),A=Math.min(y,g),C=Math.abs(x-_),N=Math.abs(g-y);return{...d,geometry:{x:I,y:A,w:C,h:N,bounds:{minX:I,minY:A,maxX:I+C,maxY:A+N}}}};function h(d){rr.call(this,r,d)}function c(d){rr.call(this,r,d)}function u(d){rr.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,c,u]}class nE extends ae{constructor(t){super(),oe(this,t,sE,iE,te,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}Ui.RECTANGLE,Ui.POLYGON;const oE=r=>({}),Mf=r=>({grab:r[0]});function aE(r){let t,e,i,s;const n=r[7].default,o=zh(n,r,r[6],Mf);return{c(){t=Tt("g"),o&&o.c(),M(t,"class","a9s-annotation selected")},m(a,l){ft(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)&&Yh(o,n,a,a[6],e?jh(n,a[6],l,oE):qh(a[6]),Mf)},i(a){e||(st(o,a),e=!0)},o(a){ut(o,a),e=!1},d(a){a&&ct(t),o&&o.d(a),i=!1,Qe(s)}}}function lE(r,t,e){let{$$slots:i={},$$scope:s}=t;const n=zs();let{shape:o}=t,{editor:a}=t,{transform:l}=t,h,c,u;const d=m=>_=>{h=m,c=l.elementToImage(_.offsetX,_.offsetY),u=o,_.target.setPointerCapture(_.pointerId),n("grab",_)},f=m=>{if(h){const[_,y]=l.elementToImage(m.offsetX,m.offsetY),x=[_-c[0],y-c[1]];e(3,o=a(u,h,x)),n("change",o)}},p=m=>{m.target.releasePointerCapture(m.pointerId),h=void 0,u=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 Bf extends ae{constructor(t){super(),oe(this,t,lE,aE,te,{shape:3,editor:4,transform:5})}}const hE=(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 cE(r,t,e){let i;const s=zs();let{annotation:n}=t,{editor:o}=t,{style:a}=t,{target:l}=t,{transform:h}=t,{viewportScale:c}=t,u;return Vs(()=>(e(6,u=new o({target:l,props:{shape:n.target.selector,computedStyle:i,transform:h,viewportScale:c}})),u.$on("change",d=>{u.$$set({shape:d.detail}),s("change",d.detail)}),u.$on("grab",d=>s("grab",d.detail)),u.$on("release",d=>s("release",d.detail)),()=>{u.$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,c=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&5&&(i=hE(n,a)),r.$$.dirty&65&&n&&(u==null||u.$set({shape:n.target.selector})),r.$$.dirty&80&&u&&u.$set({transform:h}),r.$$.dirty&96&&u&&u.$set({viewportScale:c})},[n,o,a,l,h,c,u]}class uE extends ae{constructor(t){super(),oe(this,t,cE,null,te,{annotation:0,editor:1,style:2,target:3,transform:4,viewportScale:5})}}typeof navigator>"u"?!1:navigator.userAgent.indexOf("Mac OS X")!==-1;const dE=r=>({transform:r&2,scale:r&1}),Df=r=>({transform:r[1],scale:r[0]});function fE(r){let t;const e=r[4].default,i=zh(e,r,r[3],Df);return{c(){i&&i.c()},m(s,n){i&&i.m(s,n),t=!0},p(s,[n]){i&&i.p&&(!t||n&11)&&Yh(i,e,s,s[3],t?jh(e,s[3],n,dE):qh(s[3]),Df)},i(s){t||(st(i,s),t=!0)},o(s){ut(i,s),t=!1},d(s){i&&i.d(s)}}}function pE(r,t,e){let{$$slots:i={},$$scope:s}=t,{viewer:n}=t,o=1,a;const l=()=>{const h=n.viewport.getContainerSize().x,c=n.viewport.getZoom(!0),u=n.viewport.getFlip(),d=n.viewport.pixelFromPoint(new Nt.Point(0,0),!0);u&&(d.x=h-d.x);const f=c*h/n.world.getContentFactor(),p=u?-f:f,m=n.viewport.getRotation(!0);e(1,a=`translate(${d.x}, ${d.y}) scale(${p}, ${f}) rotate(${m})`),e(0,o=c*h/n.world.getContentFactor())};return Vs(()=>(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 Of extends ae{constructor(t){super(),oe(this,t,pE,fE,te,{viewer:2})}}function mE(r,t,e){const i=zs();let{drawingMode:s}=t,{target:n}=t,{tool:o}=t,{transform:a}=t,{viewer:l}=t,{viewportScale:h}=t,c;return Vs(()=>{const u=n.closest("svg"),d=[],f=(p,m,_)=>{if(u==null||u.addEventListener(p,m,_),d.push(()=>u==null?void 0:u.removeEventListener(p,m,_)),p==="pointerup"||p==="dblclick"){const y=g=>{const{originalEvent:v}=g;m(v)},x=p==="pointerup"?"canvas-click":"canvas-double-click";l.addHandler(x,y),d.push(()=>l.removeHandler(x,y))}else if(p==="pointermove"){const y=x=>{const{originalEvent:g}=x;m(g)};l.addHandler("canvas-drag",y),d.push(()=>l.removeHandler("canvas-drag",y))}};return e(6,c=new o({target:n,props:{addEventListener:f,drawingMode:s,transform:a,viewportScale:h}})),c.$on("create",p=>i("create",p.detail)),()=>{d.forEach(p=>p()),c.$destroy()}}),r.$$set=u=>{"drawingMode"in u&&e(0,s=u.drawingMode),"target"in u&&e(1,n=u.target),"tool"in u&&e(2,o=u.tool),"transform"in u&&e(3,a=u.transform),"viewer"in u&&e(4,l=u.viewer),"viewportScale"in u&&e(5,h=u.viewportScale)},r.$$.update=()=>{r.$$.dirty&72&&c&&c.$set({transform:a}),r.$$.dirty&96&&c&&c.$set({viewportScale:h})},[s,n,o,a,l,h,c]}class gE extends ae{constructor(t){super(),oe(this,t,mE,null,te,{drawingMode:0,target:1,tool:2,transform:3,viewer:4,viewportScale:5})}}function Ff(r,t,e){const i=r.slice();i[33]=t[e];const s=i[14](i[33].target.selector);return i[34]=s,i}function yE(r){let t=r[2],e,i,s=Lf(r);return{c(){s.c(),e=er()},m(n,o){s.m(n,o),ft(n,e,o),i=!0},p(n,o){o[0]&4&&te(t,t=n[2])?(De(),ut(s,1,1,Be),Oe(),s=Lf(n),s.c(),st(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(st(s),i=!0)},o(n){ut(s),i=!1},d(n){n&&ct(e),s.d(n)}}}function _E(r){let t,e,i=ui(r[6].filter(r[23])),s=[];for(let o=0;o<i.length;o+=1)s[o]=kf(Ff(r,i,o));const n=o=>ut(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=er()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);ft(o,t,a),e=!0},p(o,a){if(a[0]&24162|a[1]&2){i=ui(o[6].filter(o[23]));let l;for(l=0;l<i.length;l+=1){const h=Ff(o,i,l);s[l]?(s[l].p(h,a),st(s[l],1)):(s[l]=kf(h),s[l].c(),st(s[l],1),s[l].m(t.parentNode,t))}for(De(),l=i.length;l<s.length;l+=1)n(l);Oe()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)st(s[a]);e=!0}},o(o){s=s.filter(Boolean);for(let a=0;a<s.length;a+=1)ut(s[a]);e=!1},d(o){o&&ct(t),Oo(s,o)}}}function Lf(r){let t,e;return t=new gE({props:{target:r[5],tool:r[7],drawingMode:r[4],transform:{elementToImage:r[9]},viewer:r[3],viewportScale:r[32]}}),t.$on("create",r[13]),{c(){ee(t.$$.fragment)},m(i,s){Zt(t,i,s),e=!0},p(i,s){const n={};s[0]&32&&(n.target=i[5]),s[0]&128&&(n.tool=i[7]),s[0]&16&&(n.drawingMode=i[4]),s[0]&8&&(n.viewer=i[3]),s[1]&2&&(n.viewportScale=i[32]),t.$set(n)},i(i){e||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Jt(t,i)}}}function Nf(r){let t=r[33].id,e,i,s=Uf(r);return{c(){s.c(),e=er()},m(n,o){s.m(n,o),ft(n,e,o),i=!0},p(n,o){o[0]&64&&te(t,t=n[33].id)?(De(),ut(s,1,1,Be),Oe(),s=Uf(n),s.c(),st(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(st(s),i=!0)},o(n){ut(s),i=!1},d(n){n&&ct(e),s.d(n)}}}function Uf(r){let t,e;return t=new uE({props:{target:r[5],editor:r[14](r[33].target.selector),annotation:r[33],style:r[1],transform:{elementToImage:r[9]},viewportScale:r[32]}}),t.$on("grab",r[10]),t.$on("change",function(){Kt(r[12](r[33]))&&r[12](r[33]).apply(this,arguments)}),t.$on("release",r[11]),{c(){ee(t.$$.fragment)},m(i,s){Zt(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&32&&(n.target=r[5]),s[0]&64&&(n.editor=r[14](r[33].target.selector)),s[0]&64&&(n.annotation=r[33]),s[0]&2&&(n.style=r[1]),s[1]&2&&(n.viewportScale=r[32]),t.$set(n)},i(i){e||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Jt(t,i)}}}function kf(r){let t,e,i=r[34]&&Nf(r);return{c(){i&&i.c(),t=er()},m(s,n){i&&i.m(s,n),ft(s,t,n),e=!0},p(s,n){s[34]?i?(i.p(s,n),n[0]&64&&st(i,1)):(i=Nf(s),i.c(),st(i,1),i.m(t.parentNode,t)):i&&(De(),ut(i,1,1,()=>{i=null}),Oe())},i(s){e||(st(i),e=!0)},o(s){ut(i),e=!1},d(s){s&&ct(t),i&&i.d(s)}}}function vE(r){let t,e,i,s,n,o;const a=[_E,yE],l=[];function h(c,u){return c[5]&&c[6]?0:c[5]&&c[7]&&c[0]?1:-1}return~(i=h(r))&&(s=l[i]=a[i](r)),{c(){t=Tt("svg"),e=Tt("g"),s&&s.c(),M(e,"transform",n=r[31]),M(e,"class","svelte-190cqdf"),M(t,"class","a9s-annotationlayer a9s-osd-drawinglayer svelte-190cqdf"),Xs(t,"drawing",r[0])},m(c,u){ft(c,t,u),tr(t,e),~i&&l[i].m(e,null),r[24](e),o=!0},p(c,u){let d=i;i=h(c),i===d?~i&&l[i].p(c,u):(s&&(De(),ut(l[d],1,1,()=>{l[d]=null}),Oe()),~i?(s=l[i],s?s.p(c,u):(s=l[i]=a[i](c),s.c()),st(s,1),s.m(e,null)):s=null),(!o||u[1]&1&&n!==(n=c[31]))&&M(e,"transform",n),(!o||u[0]&1)&&Xs(t,"drawing",c[0])},i(c){o||(st(s),o=!0)},o(c){ut(s),o=!1},d(c){c&&ct(t),~i&&l[i].d(),r[24](null)}}}function xE(r){let t,e;return t=new Of({props:{viewer:r[3],$$slots:{default:[vE,({transform:i,scale:s})=>({31:i,32:s}),({transform:i,scale:s})=>[0,(i?1:0)|(s?2:0)]]},$$scope:{ctx:r}}}),{c(){ee(t.$$.fragment)},m(i,s){Zt(t,i,s),e=!0},p(i,s){const n={};s[0]&8&&(n.viewer=i[3]),s[0]&255|s[1]&67&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Jt(t,i)}}}function bE(r,t,e){let i,s,n,o,{drawingEnabled:a}=t,{filter:l}=t,{preferredDrawingMode:h}=t,{state:c}=t,{style:u=void 0}=t,{toolName:d=Us()[0]}=t,{user:f}=t,{viewer:p}=t;const m=()=>d,_=()=>a,y=navigator.userAgent.match(/firefox|fxios/i);let x;const{store:g,selection:v,hover:w}=c;Do(r,v,B=>e(22,o=B));let I,A,C;const N=B=>{g.unobserve(I);const Z=B.filter(({editable:P})=>P).map(({id:P})=>P);if(Z.length>0){if(e(6,A=Z.map(P=>g.getAnnotation(P))),I=P=>{const{updated:U}=P.changes;e(6,A=(U||[]).map(j=>j.newValue))},g.observe(I,{annotations:Z}),y){const{width:P}=p.viewport.viewerElementToViewportRectangle(new Nt.Rect(0,0,1,1));p.viewport.panBy(new Nt.Point(Math.abs(P/10),0))}}else e(6,A=void 0)},S=(B,Z)=>{const{x:P,y:U}=p.viewport.viewerElementToImageCoordinates(new Nt.Point(B,Z));return[P,U]},R=B=>{p.setMouseNavEnabled(!1),C=B.timeStamp},E=B=>{if(p.setMouseNavEnabled(!0),performance.now()-(C||0)<300){const{offsetX:P,offsetY:U}=B.detail,[j,rt]=S(P,U),Q=g.getAt(j,rt);Q&&(!l||l(Q))&&!A.find(V=>V.id===Q.id)&&(w.set(Q.id),v.setSelected(Q.id))}},b=B=>Z=>{var rt;const{target:P}=B,U=10*60*1e3,j=((rt=P.creator)==null?void 0:rt.id)!==f.id||!P.created||new Date().getTime()-P.created.getTime()>U;g.updateTarget({...P,selector:Z.detail,created:j?P.created:new Date,updated:j?new Date:void 0,updatedBy:j?f:void 0})},D=B=>{const Z=Hw(),P={id:Z,bodies:[],target:{annotation:Z,selector:B.detail,creator:f,created:new Date}};g.addAnnotation(P),v.setSelected(P.id),p.setMouseNavEnabled(!0)},F=B=>gh(B),G=B=>Je(B);function $(B){Ws[B?"unshift":"push"](()=>{x=B,e(5,x)})}return r.$$set=B=>{"drawingEnabled"in B&&e(0,a=B.drawingEnabled),"filter"in B&&e(15,l=B.filter),"preferredDrawingMode"in B&&e(16,h=B.preferredDrawingMode),"state"in B&&e(17,c=B.state),"style"in B&&e(1,u=B.style),"toolName"in B&&e(2,d=B.toolName),"user"in B&&e(18,f=B.user),"viewer"in B&&e(3,p=B.viewer)},r.$$.update=()=>{r.$$.dirty[0]&4&&e(7,{tool:i,opts:s}=ks(d)||{tool:void 0,opts:void 0},i,(e(21,s),e(2,d))),r.$$.dirty[0]&2162688&&e(4,n=(s==null?void 0:s.drawingMode)||h),r.$$.dirty[0]&25&&(a&&n==="drag"?p.setMouseNavEnabled(!1):p.setMouseNavEnabled(!0)),r.$$.dirty[0]&1&&a&&v.clear(),r.$$.dirty[0]&4194329&&o.selected.length===0&&n==="drag"&&a&&p.setMouseNavEnabled(!1),r.$$.dirty[0]&4194304&&N(o.selected)},[a,u,d,p,n,x,A,i,v,S,R,E,b,D,F,l,h,c,f,m,_,s,o,G,$]}class wE extends ae{constructor(t){super(),oe(this,t,bE,xE,te,{drawingEnabled:0,filter:15,preferredDrawingMode:16,state:17,style:1,toolName:2,user:18,viewer:3,getDrawingTool:19,isDrawingEnabled:20},null,[-1,-1])}get getDrawingTool(){return this.$$.ctx[19]}get isDrawingEnabled(){return this.$$.ctx[20]}}function EE(r){let t,e,i,s,n,o,a,l=r[2].appearance.label+"",h,c,u,d;return{c(){t=Tt("g"),e=Tt("rect"),a=Tt("text"),h=Fo(l),M(e,"class","a9s-presence-label-bg svelte-1rehw2p"),M(e,"x",r[0]),M(e,"y",i=r[1]-18/r[3]),M(e,"height",s=18/r[3]),M(e,"fill",n=r[2].appearance.color),M(e,"stroke",o=r[2].appearance.color),M(a,"font-size",c=12/r[3]),M(a,"x",u=r[0]+Math.round(5/r[3])),M(a,"y",d=r[1]-5/r[3]),M(a,"class","svelte-1rehw2p"),M(t,"class","a9s-presence-label")},m(f,p){ft(f,t,p),tr(t,e),tr(t,a),tr(a,h),r[6](t)},p(f,[p]){p&1&&M(e,"x",f[0]),p&10&&i!==(i=f[1]-18/f[3])&&M(e,"y",i),p&8&&s!==(s=18/f[3])&&M(e,"height",s),p&4&&n!==(n=f[2].appearance.color)&&M(e,"fill",n),p&4&&o!==(o=f[2].appearance.color)&&M(e,"stroke",o),p&4&&l!==(l=f[2].appearance.label+"")&&Jg(h,l),p&8&&c!==(c=12/f[3])&&M(a,"font-size",c),p&9&&u!==(u=f[0]+Math.round(5/f[3]))&&M(a,"x",u),p&10&&d!==(d=f[1]-5/f[3])&&M(a,"y",d)},i:Be,o:Be,d(f){f&&ct(t),r[6](null)}}}function TE(r,t,e){let{x:i}=t,{y:s}=t,{user:n}=t,{scale:o}=t,{hAlign:a=null}=t,l;const h=u=>{const d=l.querySelector("text"),f=l.querySelector("rect"),p=d.getBBox().width+10/u;a==="CENTER"&&l.setAttribute("style",`transform: translateX(-${p/2}px)`),f.setAttribute("width",`${p}`)};function c(u){Ws[u?"unshift":"push"](()=>{l=u,e(4,l)})}return r.$$set=u=>{"x"in u&&e(0,i=u.x),"y"in u&&e(1,s=u.y),"user"in u&&e(2,n=u.user),"scale"in u&&e(3,o=u.scale),"hAlign"in u&&e(5,a=u.hAlign)},r.$$.update=()=>{r.$$.dirty&24&&l&&h(o)},[i,s,n,o,l,a,c]}class Gf extends ae{constructor(t){super(),oe(this,t,TE,EE,te,{x:0,y:1,user:2,scale:3,hAlign:5})}}function AE(r){let t,e,i,s,n,o;return e=new Gf({props:{scale:r[1],user:r[0],x:r[3][0],y:r[3][1],hAlign:"CENTER"}}),{c(){t=Tt("g"),ee(e.$$.fragment),i=Tt("polygon"),M(i,"class","a9s-presence-shape a9s-presence-polygon svelte-fgq4n0"),M(i,"stroke",s=r[0].appearance.color),M(i,"fill","transparent"),M(i,"points",n=r[2].points.map($f).join(" ")),M(t,"class","a9s-presence-overlay")},m(a,l){ft(a,t,l),Zt(e,t,null),tr(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))&&M(i,"stroke",s),(!o||l&4&&n!==(n=a[2].points.map($f).join(" ")))&&M(i,"points",n)},i(a){o||(st(e.$$.fragment,a),o=!0)},o(a){ut(e.$$.fragment,a),o=!1},d(a){a&&ct(t),Jt(e)}}}const $f=r=>r.join(",");function SE(r,t,e){let i,s,{annotation:n}=t,{user:o}=t,{scale:a}=t;const l=h=>{let[c,...u]=h.points;return u.forEach(([d,f])=>{f<c[1]&&(c=[d,f])}),c};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 IE extends ae{constructor(t){super(),oe(this,t,SE,AE,te,{annotation:4,user:0,scale:1})}}function CE(r){let t,e,i,s,n,o,a,l,h;return e=new Gf({props:{scale:r[1],user:r[0],x:r[2].x,y:r[2].y}}),{c(){t=Tt("g"),ee(e.$$.fragment),i=Tt("rect"),M(i,"class","a9s-presence-shape a9s-presence-rectangle svelte-gze948"),M(i,"stroke",s=r[0].appearance.color),M(i,"fill","transparent"),M(i,"x",n=r[2].x),M(i,"y",o=r[2].y),M(i,"width",a=r[2].w),M(i,"height",l=r[2].h),M(t,"class","a9s-presence-overlay")},m(c,u){ft(c,t,u),Zt(e,t,null),tr(t,i),h=!0},p(c,[u]){const d={};u&2&&(d.scale=c[1]),u&1&&(d.user=c[0]),u&4&&(d.x=c[2].x),u&4&&(d.y=c[2].y),e.$set(d),(!h||u&1&&s!==(s=c[0].appearance.color))&&M(i,"stroke",s),(!h||u&4&&n!==(n=c[2].x))&&M(i,"x",n),(!h||u&4&&o!==(o=c[2].y))&&M(i,"y",o),(!h||u&4&&a!==(a=c[2].w))&&M(i,"width",a),(!h||u&4&&l!==(l=c[2].h))&&M(i,"height",l)},i(c){h||(st(e.$$.fragment,c),h=!0)},o(c){ut(e.$$.fragment,c),h=!1},d(c){c&&ct(t),Jt(e)}}}function RE(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 PE extends ae{constructor(t){super(),oe(this,t,RE,CE,te,{annotation:3,user:0,scale:1})}}const{Boolean:ME}=Kg;function Hf(r,t,e){const i=r.slice();return i[8]=t[e],i}function Xf(r){let t,e;return t=new Of({props:{viewer:r[0],$$slots:{default:[OE,({transform:i,scale:s})=>({6:i,7:s}),({transform:i,scale:s})=>(i?64:0)|(s?128:0)]},$$scope:{ctx:r}}}),{c(){ee(t.$$.fragment)},m(i,s){Zt(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||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Jt(t,i)}}}function Vf(r){let t,e,i=ui(r[2]),s=[];for(let o=0;o<i.length;o+=1)s[o]=zf(Hf(r,i,o));const n=o=>ut(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=er()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);ft(o,t,a),e=!0},p(o,a){if(a&132){i=ui(o[2]);let l;for(l=0;l<i.length;l+=1){const h=Hf(o,i,l);s[l]?(s[l].p(h,a),st(s[l],1)):(s[l]=zf(h),s[l].c(),st(s[l],1),s[l].m(t.parentNode,t))}for(De(),l=i.length;l<s.length;l+=1)n(l);Oe()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)st(s[a]);e=!0}},o(o){s=s.filter(ME);for(let a=0;a<s.length;a+=1)ut(s[a]);e=!1},d(o){o&&ct(t),Oo(s,o)}}}function BE(r){let t,e;return t=new IE({props:{annotation:r[8].annotation,user:r[8].selectedBy,scale:r[7]}}),{c(){ee(t.$$.fragment)},m(i,s){Zt(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||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Jt(t,i)}}}function DE(r){let t,e;return t=new PE({props:{annotation:r[8].annotation,user:r[8].selectedBy,scale:r[7]}}),{c(){ee(t.$$.fragment)},m(i,s){Zt(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||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Jt(t,i)}}}function zf(r){let t,e,i,s;const n=[DE,BE],o=[];function a(l,h){return l[8].annotation.target.selector.type===wt.RECTANGLE?0:l[8].annotation.target.selector.type===wt.POLYGON?1:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=er()},m(l,h){~t&&o[t].m(l,h),ft(l,i,h),s=!0},p(l,h){let c=t;t=a(l),t===c?~t&&o[t].p(l,h):(e&&(De(),ut(o[c],1,1,()=>{o[c]=null}),Oe()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=n[t](l),e.c()),st(e,1),e.m(i.parentNode,i)):e=null)},i(l){s||(st(e),s=!0)},o(l){ut(e),s=!1},d(l){l&&ct(i),~t&&o[t].d(l)}}}function OE(r){let t,e,i,s,n=r[2].length>0&&Vf(r);return{c(){t=Tt("svg"),e=Tt("g"),n&&n.c(),M(e,"transform",i=r[6]),M(t,"class","a9s-osd-presencelayer svelte-1krwc4m")},m(o,a){ft(o,t,a),tr(t,e),n&&n.m(e,null),s=!0},p(o,a){o[2].length>0?n?(n.p(o,a),a&4&&st(n,1)):(n=Vf(o),n.c(),st(n,1),n.m(e,null)):n&&(De(),ut(n,1,1,()=>{n=null}),Oe()),(!s||a&64&&i!==(i=o[6]))&&M(e,"transform",i)},i(o){s||(st(n),s=!0)},o(o){ut(n),s=!1},d(o){o&&ct(t),n&&n.d()}}}function FE(r){let t=!!r[1],e,i,s=t&&Xf(r);return{c(){s&&s.c(),e=er()},m(n,o){s&&s.m(n,o),ft(n,e,o),i=!0},p(n,[o]){o&2&&(t=!!n[1]),t?s?(s.p(n,o),o&2&&st(s,1)):(s=Xf(n),s.c(),st(s,1),s.m(e.parentNode,e)):s&&(De(),ut(s,1,1,()=>{s=null}),Oe())},i(n){i||(st(s),i=!0)},o(n){ut(s),i=!1},d(n){n&&ct(e),s&&s.d(n)}}}function LE(r,t,e){let{store:i}=t,{viewer:s}=t,{provider:n}=t,o=[],a;const l=(h,c)=>{e(2,o=[...o.filter(({selectedBy:u})=>u.presenceKey!==h.presenceKey),...(c||[]).map(u=>({annotation:i.getAnnotation(u),selectedBy:h}))].filter(({annotation:u})=>(u||console.warn("Selection event on unknown annotation"),!!u))),a&&i.unobserve(a),a=u=>{const{deleted:d,updated:f}=u.changes,p=new Set((d||[]).map(_=>_.id)),m=o.filter(({annotation:_})=>!p.has(_.id)).map(_=>{const y=(f||[]).find(x=>x.oldValue.id===_.annotation.id);return y?{selectedBy:_.selectedBy,annotation:y.newValue}:_});e(2,o=m)},i.observe(a,{annotations:o.map(u=>u.annotation.id)})};return ty(()=>{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 NE extends ae{constructor(t){super(),oe(this,t,LE,FE,te,{store:3,viewer:0,provider:1})}}const Wf=(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=Uh(a);r.element.setAttribute("data-theme",l)}})}):r.element.setAttribute("data-theme",t)},jf=(r,t,e)=>(i,s={})=>{const n=typeof i=="string"?i:i.id,o=t.getAnnotation(n);if(!o||!Je(o))return;const a=r.container.getBoundingClientRect(),{padding:l}=s;let[h,c,u,d]=l?Array.isArray(l)?l:[l,l,l,l]:[0,0,0,0];h=h/a.height,c=c/a.width,u=u/a.height,d=d/a.width;const{minX:f,minY:p,maxX:m,maxY:_}=o.target.selector.geometry.bounds,y=m-f,x=_-p,g=f-d*y,v=p-h*x,w=y+(c+d)*y,I=x+(h+u)*x,A=r.viewport.imageToViewportRectangle(g,v,w,I);r.viewport[e](A,s.immediately)},UE=(r,t)=>jf(r,t,"fitBounds"),kE=(r,t)=>jf(r,t,"fitBoundsWithConstraints"),GE=(r,t={})=>{const e=Gh(t,{drawingEnabled:!1,drawingMode:ph?"drag":"click",userSelectAction:ao.EDIT,theme:"light"}),i=Nh(e),{hover:s,selection:n,store:o}=i,a=dp(o),l=fp(i,a,e.adapter,e.autoSave);let h=bp(),c=e.drawingEnabled,u=e.drawingMode;const d=Hh(a,r.element),f=new Nw({target:r.element,props:{state:i,viewer:r,style:e.style,filter:void 0}}),p=new NE({target:r.element.querySelector(".openseadragon-canvas"),props:{provider:void 0,store:o,viewer:r}}),m=new wE({target:r.element.querySelector(".openseadragon-canvas"),props:{drawingEnabled:!!c,filter:void 0,preferredDrawingMode:u,state:i,style:e.style,user:h,viewer:r}});f.$on("click",B=>{const{originalEvent:Z,annotation:P}=B.detail;P&&!(u==="click"&&c)?n.userSelect(P.id,Z):n.isEmpty()||n.clear()}),r.element.addEventListener("pointerdown",B=>{if(s.current){const Z=o.getAnnotation(s.current);l.emit("clickAnnotation",Z,B)}}),Wf(r,e.theme);const _=mp(i,a,e.adapter),y=()=>{m.$set({drawingEnabled:!1}),setTimeout(()=>m.$set({drawingEnabled:!0}),1)},x=()=>{f.$destroy(),p.$destroy(),m.$destroy(),d.destroy(),a.destroy()},g=UE(r,o),v=kE(r,o),w=()=>m.getDrawingTool(),I=()=>h,A=()=>m.isDrawingEnabled(),C=(B,Z,P)=>Eh(B,Z,P),N=(B,Z)=>yh(B,Z),S=B=>{if(!ks(B))throw`No drawing tool named ${B}`;m.$set({toolName:B})},R=B=>{c=B,m.$set({drawingEnabled:c})},E=B=>{f.$set({filter:B}),m.$set({filter:B})},b=B=>{f.$set({style:B}),m.$set({style:B})},D=B=>p.$set({provider:B}),F=B=>Wf(r,B),G=B=>{h=B,m.$set({user:B})},$=B=>f.$set({visible:B});return{..._,cancelDrawing:y,destroy:x,fitBounds:g,fitBoundsWithConstraints:v,getDrawingTool:w,getUser:I,isDrawingEnabled:A,listDrawingTools:Us,on:l.on,off:l.off,registerDrawingTool:C,registerShapeEditor:N,setDrawingEnabled:R,setDrawingTool:S,setFilter:E,setPresenceProvider:D,setStyle:b,setTheme:F,setUser:G,setVisible:$,state:i,viewer:r}};Mt.ShapeType=wt,Mt.UserSelectAction=ao,Mt.W3CImageFormat=Lm,Mt.chainStyles=Sm,Mt.computeStyle=Am,Mt.createBody=ip,Mt.createImageAnnotator=jg,Mt.createOSDAnnotator=GE,Mt.defaultColorProvider=Ep,Object.defineProperty(Mt,Symbol.toStringTag,{value:"Module"})});
|
|
1147
|
+
}`,this._stylesheet)}get stylesheet(){return this._stylesheet}set stylesheet(t){this._stylesheet!==t&&(this._stylesheet=t,this.styleID++)}normalizeColor(t){return Array.isArray(t)&&(t=gv(t)),typeof t=="number"?mv(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,$i.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}=W.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}};Rl.availableFonts={},Rl.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 Pl=Rl;const Qn=class Hi extends Pi{constructor(t="",e={}){super(q.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=q.from(i,{scaleMode:W.SCALE_MODE,resourceOptions:{autoLoad:!1}});s.orig=new at,s.trim=new at,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"),c=document.createElementNS(o,"style");l.setAttribute("width","10000"),l.setAttribute("height","10000"),l.style.overflow="hidden",a.appendChild(l),this.maxWidth=Hi.defaultMaxWidth,this.maxHeight=Hi.defaultMaxHeight,this._domElement=h,this._styleElement=c,this._svgRoot=a,this._foreignObject=l,this._foreignObject.appendChild(c),this._foreignObject.appendChild(h),this._image=i,this._loadImage=new Image,this._autoResolution=Hi.defaultAutoResolution,this._resolution=Hi.defaultResolution??W.RESOLUTION,this.text=t,this.style=e}measureText(t){var c,u;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:(c=this._style)==null?void 0:c.toCSS(s)}),this._styleElement.textContent=(u=this._style)==null?void 0:u.toGlobalCSS()),{width:l+i.padding*2,height:h+i.padding*2}}async updateText(t=!0){const{style:e,_image:i,_loadImage: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({},Hi.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=vr(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=vr(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 Pl?(this.ownsStyle=!1,this._style=t):t instanceof Sr?(console.warn("[HTMLText] Cloning TextStyle, if this is not what you want, use HTMLTextStyle"),this.ownsStyle=!0,this._style=Pl.from(t)):(this.ownsStyle=!0,this._style=new Pl(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," ")}};Qn.defaultDestroyOptions={texture:!0,children:!1,baseTexture:!0},Qn.defaultMaxWidth=2024,Qn.defaultMaxHeight=2024,Qn.defaultAutoResolution=!0;const Cw=16777215,Rw=.25,Pw=16777215,Mw=1.5;let Rr=!1,xs;const Ml=r=>{const t={tint:r!=null&&r.fill?new bt(r.fill).toNumber():Cw,alpha:(r==null?void 0:r.fillOpacity)===void 0?Rw:Math.min(r.fillOpacity,1)},e={tint:r!=null&&r.stroke?new bt(r.stroke).toNumber():Pw,alpha:(r==null?void 0:r.strokeOpacity)===void 0?1:Math.min(r.strokeOpacity,1),lineWidth:(r==null?void 0:r.strokeWidth)===void 0?Mw:r.strokeWidth};return{fillStyle:t,strokeStyle:e}},Bl=r=>(t,e,i)=>{const{fillStyle:s,strokeStyle:n}=Ml(i),o=new vs;o.beginFill(16777215),r(e,o),o.endFill(),o.tint=s.tint,o.alpha=s.alpha,t.addChild(o);const a=new vs,l=n.lineWidth===1?1:n.lineWidth/xs;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}},Bw=Bl((r,t)=>{const{cx:e,cy:i,rx:s,ry:n}=r.geometry;t.drawEllipse(e,i,s,n)}),Dw=Bl((r,t)=>{const e=r.geometry.points.reduce((i,s)=>[...i,...s],[]);t.drawPolygon(e)}),Ow=Bl((r,t)=>{const{x:e,y:i,w:s,h:n}=r.geometry;t.drawRect(e,i,s,n)}),Tf=r=>{const t=r.viewport.getContainerSize().x;return r.viewport.getZoom(!0)*t/r.world.getContentFactor()},Af=(r,t,e,i)=>()=>{const s=r.viewport.viewportToImageRectangle(r.viewport.getBounds(!0)),n=Tf(r);(n!==xs||!Rr)&&(Rr=!0,e.forEach(({stroke:d,strokeWidth:f})=>{const{lineStyle:p}=d.geometry.graphicsData[0];f>1?(Rr=n===xs,p.width=f/n,p.native=!1,d.geometry.invalidate()):f===1&&!p.native&&(p.width=1,p.native=!0,d.geometry.invalidate())})),xs=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 c,u;a>0&&a<=Math.PI/2?(c=s.height*n,u=0):a>Math.PI/2&&a<=Math.PI?(c=s.width*n,u=s.height*n):a>Math.PI&&a<=Math.PI*1.5?(c=0,u=s.width*n):(c=0,u=0),t.position.x=c+l*Math.cos(a)-h*Math.sin(a),t.position.y=u+l*Math.sin(a)+h*Math.cos(a),t.scale.set(o?-n:n,n),t.rotation=a,i.render(t)},Fw=(r,t)=>{const e=new vs,i=xd({width:t.width,height:t.height,backgroundAlpha:0,view:t,antialias:!0,resolution:2}),s=new Map;let n=new Set,o,a;xs=Tf(r);const l=(g,v)=>{Rr=!1;const{selector:w}=g.target,I=typeof a=="function"?a(g,v):a;let A;w.type===wt.RECTANGLE?A=Ow(e,w,I):w.type===wt.POLYGON?A=Dw(e,w,I):w.type===wt.ELLIPSE?A=Bw(e,w,I):console.warn(`Unsupported shape type: ${w.type}`),A&&s.set(g.id,{annotation:g,...A})},h=g=>{const v=s.get(g.id);v&&(s.delete(g.id),v.fill.destroy(),v.stroke.destroy())},c=(g,v,w)=>{Rr=!1;const I=s.get(g.id);I&&(s.delete(g.id),I.fill.destroy(),I.stroke.destroy(),l(v,w))},u=(g,v)=>{const w=s.get(g);w&&(s.delete(g),w.fill.destroy(),w.stroke.destroy(),l(w.annotation,v))},d=(g,v)=>{i.resize(g,v),i.render(e)},f=g=>{Rr=!1;const{children:v}=e;s.forEach(({fill:w,stroke:I,annotation:A})=>{const C=g?n.has(A.id)||g(A):!0;C&&!v.includes(w)?(e.addChild(w),e.addChild(I)):!C&&v.includes(w)&&(e.removeChild(w),e.removeChild(I))}),i.render(e)},p=g=>{o!==g&&(o&&u(o,{selected:n.has(o)}),g&&u(g,{selected:n.has(g),hovered:!0}),o=g,i.render(e))},m=g=>{const v=g.selected.map(A=>A.id),w=v.filter(A=>!n.has(A)),I=[...n].filter(A=>!v.includes(A));[...w,...I].forEach(A=>u(A,{selected:v.includes(A),hovered:A===o})),n=new Set(v),i.render(e)},_=g=>{if(typeof g=="function")s.forEach(({annotation:v,fill:w,stroke:I,strokeWidth:A},C)=>{A>1&&(Rr=!1);const N={selected:n.has(v.id),hovered:o===v.id},{fillStyle:S,strokeStyle:R}=Ml(g(v,N));w.tint=S.tint,w.alpha=S.alpha,I.tint=R.tint||16777215,I.alpha=R.alpha,s.set(v.id,{annotation:v,fill:w,stroke:I,strokeWidth:R.lineWidth})});else{const{fillStyle:v,strokeStyle:w}=Ml(g);w.lineWidth>1&&(Rr=!1),s.forEach(({annotation:I,fill:A,stroke:C,strokeWidth:N},S)=>{A.tint=v.tint,A.alpha=v.alpha,C.tint=w.tint||16777215,C.alpha=w.alpha,s.set(I.id,{annotation:I,fill:A,stroke:C,strokeWidth:w.lineWidth})})}a=g,i.render(e),Af(r,e,s,i)()},y=g=>{g?t.classList.remove("hidden"):t.classList.add("hidden")};return{addAnnotation:l,destroy:()=>i.destroy(),redraw:Af(r,e,s,i),removeAnnotation:h,resize:d,setFilter:f,setHovered:p,setSelected:m,setStyle:_,setVisible:y,updateAnnotation:c}};function Lw(r,t,e){let i,s,{filter:n}=t,{state:o}=t,{style:a}=t,{viewer:l}=t,{visible:h=!0}=t;const{store:c,hover:u,selection:d,viewport:f}=o;Do(r,u,I=>e(11,i=I)),Do(r,d,I=>e(8,s=I));const p=zs();let m,_;const y=I=>{const A=new Nt.Point(I.x,I.y),{x:C,y:N}=l.viewport.pointFromPixel(A);return l.viewport.viewportToImageCoordinates(C,N)},x=I=>{const{x:A,y:C}=I.position;_={x:A,y:C}},g=I=>A=>{const{x:C,y:N}=y(new Nt.Point(A.offsetX,A.offsetY)),S=c.getAt(C,N);S&&(!n||n(S))?(I.classList.add("hover"),i!==S.id&&(u.set(S.id),m.setHovered(S.id))):(I.classList.remove("hover"),i&&(u.set(void 0),m.setHovered(void 0)))},v=I=>{if(!_)return;const A=I.originalEvent,{x:C,y:N}=I.position,S=C-_.x,R=N-_.y;if(Math.sqrt(S*S+R*R)<5){const{x:b,y:D}=y(I.position),F=c.getAt(b,D);F?p("click",{originalEvent:A,annotation:F}):p("click",{originalEvent:A})}_=void 0};let w;return Vs(()=>{var F;const{offsetWidth:I,offsetHeight:A}=l.canvas,C=document.createElement("canvas");C.width=I,C.height=A,C.className="a9s-gl-canvas",(F=l.element.querySelector(".openseadragon-canvas"))==null||F.appendChild(C),e(7,m=Fw(l,C));const N=g(C);C.addEventListener("pointermove",N);const S=new ResizeObserver(G=>{try{const{width:$,height:B}=G[0].contentRect;C.width=$,C.height=B,m.resize($,B)}catch{console.warn("WebGL canvas already disposed")}});S.observe(C);const R=()=>{const G=l.viewport.getBounds();w=l.viewport.viewportToImageRectangle(G);const{x:$,y:B,width:Z,height:P}=w,U=c.getIntersecting($,B,Z,P);f.set(U.map(j=>j.id))};l.addHandler("canvas-press",x),l.addHandler("canvas-release",v),l.addHandler("update-viewport",m.redraw),l.addHandler("animation-finish",R);const E=G=>G.filter($=>Je($)),b=G=>Je(G.oldValue)&&Je(G.newValue),D=G=>{const{created:$,updated:B,deleted:Z}=G.changes;if(E($||[]).forEach(P=>m.addAnnotation(P)),E(Z||[]).forEach(P=>m.removeAnnotation(P)),(B||[]).filter(P=>b(P)).forEach(({oldValue:P,newValue:U})=>m.updateAnnotation(P,U)),w){const{x:P,y:U,width:j,height:rt}=w,Q=c.getIntersecting(P,U,j,rt);f.set(Q.map(H=>H.id))}else f.set(c.all().map(P=>P.id));m.redraw()};return c.observe(D),()=>{var G;C.removeEventListener("pointermove",N),S.disconnect(),l.removeHandler("canvas-press",x),l.removeHandler("canvas-release",v),l.removeHandler("update-viewport",m.redraw),l.removeHandler("animation-finish",R),c.unobserve(D),m.destroy(),(G=C.parentNode)==null||G.removeChild(C)}}),r.$$set=I=>{"filter"in I&&e(2,n=I.filter),"state"in I&&e(3,o=I.state),"style"in I&&e(4,a=I.style),"viewer"in I&&e(5,l=I.viewer),"visible"in I&&e(6,h=I.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))},[u,d,n,o,a,l,h,m,s]}class Nw extends ae{constructor(t){super(),oe(this,t,Lw,null,te,{filter:2,state:3,style:4,viewer:5,visible:6})}}for(var Yt=[],Dl=0;Dl<256;++Dl)Yt.push((Dl+256).toString(16).slice(1));function Uw(r,t=0){return(Yt[r[t+0]]+Yt[r[t+1]]+Yt[r[t+2]]+Yt[r[t+3]]+"-"+Yt[r[t+4]]+Yt[r[t+5]]+"-"+Yt[r[t+6]]+Yt[r[t+7]]+"-"+Yt[r[t+8]]+Yt[r[t+9]]+"-"+Yt[r[t+10]]+Yt[r[t+11]]+Yt[r[t+12]]+Yt[r[t+13]]+Yt[r[t+14]]+Yt[r[t+15]]).toLowerCase()}var to,kw=new Uint8Array(16);function Gw(){if(!to&&(to=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!to))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return to(kw)}var $w=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const Sf={randomUUID:$w};function Hw(r,t,e){if(Sf.randomUUID&&!t&&!r)return Sf.randomUUID();r=r||{};var i=r.random||(r.rng||Gw)();return i[6]=i[6]&15|64,i[8]=i[8]&63|128,Uw(i)}var Ui=(r=>(r.ELLIPSE="ELLIPSE",r.POLYGON="POLYGON",r.RECTANGLE="RECTANGLE",r))(Ui||{});const Ol=(r,t)=>t,Xw=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}},Vw={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),c=t-i,u=e-s,d=l*c+h*u,f=h*c-l*u;return d*d/(n*n)+f*f/(o*o)<=1}};Ol(Ui.ELLIPSE,Vw);const zw={area:r=>{const{points:t}=r.geometry;let e=0,i=t.length-1;for(let s=0;s<t.length;s++)e+=(t[i][0]+t[s][0])*(t[i][1]-t[s][1]),i=s;return Math.abs(.5*e)},intersects:(r,t,e)=>{const{points:i}=r.geometry;let s=!1;for(let n=0,o=i.length-1;n<i.length;o=n++){const a=i[n][0],l=i[n][1],h=i[o][0],c=i[o][1];l>e!=c>e&&t<(h-a)*(e-l)/(c-l)+a&&(s=!s)}return s}};Ol(Ui.POLYGON,zw);const Ww={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};Ol(Ui.RECTANGLE,Ww);function If(r,t,e){const i=r.slice();return i[10]=t[e],i[12]=e,i}function Cf(r){let t,e;return t=new bs({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(){ee(t.$$.fragment)},m(i,s){Zt(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||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Jt(t,i)}}}function jw(r){let t,e,i,s,n,o,a,l,h,c,u,d=ui(r[4].points),f=[];for(let m=0;m<d.length;m+=1)f[m]=Cf(If(r,d,m));const p=m=>ut(f[m],1,1,()=>{f[m]=null});return{c(){t=Tt("polygon"),s=xe(),n=Tt("polygon"),a=xe();for(let m=0;m<f.length;m+=1)f[m].c();l=er(),M(t,"class","a9s-outer"),M(t,"style",e=r[1]?"display:none;":void 0),M(t,"points",i=r[4].points.map(Rf).join(" ")),M(n,"class","a9s-inner a9s-shape-handle"),M(n,"style",r[1]),M(n,"points",o=r[4].points.map(Pf).join(" "))},m(m,_){ft(m,t,_),ft(m,s,_),ft(m,n,_),ft(m,a,_);for(let y=0;y<f.length;y+=1)f[y]&&f[y].m(m,_);ft(m,l,_),h=!0,c||(u=[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)})],c=!0)},p(m,_){if(r=m,(!h||_&2&&e!==(e=r[1]?"display:none;":void 0))&&M(t,"style",e),(!h||_&16&&i!==(i=r[4].points.map(Rf).join(" ")))&&M(t,"points",i),(!h||_&2)&&M(n,"style",r[1]),(!h||_&16&&o!==(o=r[4].points.map(Pf).join(" ")))&&M(n,"points",o),_&536){d=ui(r[4].points);let y;for(y=0;y<d.length;y+=1){const x=If(r,d,y);f[y]?(f[y].p(x,_),st(f[y],1)):(f[y]=Cf(x),f[y].c(),st(f[y],1),f[y].m(l.parentNode,l))}for(De(),y=d.length;y<f.length;y+=1)p(y);Oe()}},i(m){if(!h){for(let _=0;_<d.length;_+=1)st(f[_]);h=!0}},o(m){f=f.filter(Boolean);for(let _=0;_<f.length;_+=1)ut(f[_]);h=!1},d(m){m&&(ct(t),ct(s),ct(n),ct(a),ct(l)),Oo(f,m),c=!1,Qe(u)}}}function Yw(r){let t,e;return t=new Bf({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[jw,({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(){ee(t.$$.fragment)},m(i,s){Zt(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||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Jt(t,i)}}}const Rf=r=>r.join(","),Pf=r=>r.join(",");function qw(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 _=d.geometry;f==="SHAPE"?m=_.points.map(([x,g])=>[x+p[0],g+p[1]]):m=_.points.map(([x,g],v)=>f===`HANDLE-${v}`?[x+p[0],g+p[1]]:[x,g]);const y=Xw(m);return{...d,geometry:{points:m,bounds:y}}};function h(d){rr.call(this,r,d)}function c(d){rr.call(this,r,d)}function u(d){rr.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,c,u]}class Kw extends ae{constructor(t){super(),oe(this,t,qw,Yw,te,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}const Zw=typeof window>"u"||typeof navigator>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0;function Jw(r){let t,e,i,s,n,o;return{c(){t=Tt("rect"),M(t,"class",e=Hs(`a9s-handle ${r[8].class||""}`.trim())+" svelte-1sgkh33"),M(t,"x",i=r[0]-r[5]/2),M(t,"y",s=r[1]-r[5]/2),M(t,"width",r[5]),M(t,"height",r[5])},m(a,l){ft(a,t,l),n||(o=zt(t,"pointerdown",r[11]),n=!0)},p(a,l){l&256&&e!==(e=Hs(`a9s-handle ${a[8].class||""}`.trim())+" svelte-1sgkh33")&&M(t,"class",e),l&33&&i!==(i=a[0]-a[5]/2)&&M(t,"x",i),l&34&&s!==(s=a[1]-a[5]/2)&&M(t,"y",s),l&32&&M(t,"width",a[5]),l&32&&M(t,"height",a[5])},d(a){a&&ct(t),n=!1,o()}}}function Qw(r){let t,e,i,s,n,o,a,l,h;return{c(){t=Tt("g"),e=Tt("circle"),s=Tt("rect"),M(e,"cx",r[0]),M(e,"cy",r[1]),M(e,"r",i=r[3]/r[2]),M(e,"class","a9s-touch-halo svelte-1sgkh33"),Xs(e,"touched",r[4]),M(s,"class",n=Hs(`a9s-handle ${r[8].class||""}`.trim())+" svelte-1sgkh33"),M(s,"x",o=r[0]-r[5]/2),M(s,"y",a=r[1]-r[5]/2),M(s,"width",r[5]),M(s,"height",r[5]),M(t,"class","a9s-touch-handle")},m(c,u){ft(c,t,u),tr(t,e),tr(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(c,u){u&1&&M(e,"cx",c[0]),u&2&&M(e,"cy",c[1]),u&12&&i!==(i=c[3]/c[2])&&M(e,"r",i),u&16&&Xs(e,"touched",c[4]),u&256&&n!==(n=Hs(`a9s-handle ${c[8].class||""}`.trim())+" svelte-1sgkh33")&&M(s,"class",n),u&33&&o!==(o=c[0]-c[5]/2)&&M(s,"x",o),u&34&&a!==(a=c[1]-c[5]/2)&&M(s,"y",a),u&32&&M(s,"width",c[5]),u&32&&M(s,"height",c[5])},d(c){c&&ct(t),l=!1,Qe(h)}}}function tE(r){let t;function e(n,o){return Zw?Qw:Jw}let s=e()(r);return{c(){s.c(),t=er()},m(n,o){s.m(n,o),ft(n,t,o)},p(n,[o]){s.p(n,o)},i:Be,o:Be,d(n){n&&ct(t),s.d(n)}}}function eE(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)},c=()=>e(4,l=!1);function u(p){rr.call(this,r,p)}function d(p){rr.call(this,r,p)}function f(p){rr.call(this,r,p)}return r.$$set=p=>{e(8,t=Bo(Bo({},t),Kh(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=Kh(t),[s,n,o,a,l,i,h,c,t,u,d,f]}class bs extends ae{constructor(t){super(),oe(this,t,eE,tE,te,{x:0,y:1,scale:2,radius:3})}}function rE(r){let t,e,i,s,n,o,a,l,h,c,u,d,f,p,m,_,y,x,g,v,w,I,A,C,N,S,R,E,b,D,F,G,$,B,Z,P,U,j,rt,Q,H,V,lt;return B=new bs({props:{class:"a9s-corner-handle-topleft",x:r[4].x,y:r[4].y,scale:r[3]}}),B.$on("pointerdown",function(){Kt(r[9]("TOP_LEFT"))&&r[9]("TOP_LEFT").apply(this,arguments)}),P=new bs({props:{class:"a9s-corner-handle-topright",x:r[4].x+r[4].w,y:r[4].y,scale:r[3]}}),P.$on("pointerdown",function(){Kt(r[9]("TOP_RIGHT"))&&r[9]("TOP_RIGHT").apply(this,arguments)}),j=new bs({props:{class:"a9s-corner-handle-bottomright",x:r[4].x+r[4].w,y:r[4].y+r[4].h,scale:r[3]}}),j.$on("pointerdown",function(){Kt(r[9]("BOTTOM_RIGHT"))&&r[9]("BOTTOM_RIGHT").apply(this,arguments)}),Q=new bs({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=Tt("rect"),a=xe(),l=Tt("rect"),f=xe(),p=Tt("rect"),x=xe(),g=Tt("rect"),A=xe(),C=Tt("rect"),E=xe(),b=Tt("rect"),$=xe(),ee(B.$$.fragment),Z=xe(),ee(P.$$.fragment),U=xe(),ee(j.$$.fragment),rt=xe(),ee(Q.$$.fragment),M(t,"class","a9s-outer"),M(t,"style",e=r[1]?"display:none;":void 0),M(t,"x",i=r[4].x),M(t,"y",s=r[4].y),M(t,"width",n=r[4].w),M(t,"height",o=r[4].h),M(l,"class","a9s-inner a9s-shape-handle"),M(l,"style",r[1]),M(l,"x",h=r[4].x),M(l,"y",c=r[4].y),M(l,"width",u=r[4].w),M(l,"height",d=r[4].h),M(p,"class","a9s-edge-handle a9s-edge-handle-top"),M(p,"x",m=r[4].x),M(p,"y",_=r[4].y),M(p,"height",1),M(p,"width",y=r[4].w),M(g,"class","a9s-edge-handle a9s-edge-handle-right"),M(g,"x",v=r[4].x+r[4].w),M(g,"y",w=r[4].y),M(g,"height",I=r[4].h),M(g,"width",1),M(C,"class","a9s-edge-handle a9s-edge-handle-bottom"),M(C,"x",N=r[4].x),M(C,"y",S=r[4].y+r[4].h),M(C,"height",1),M(C,"width",R=r[4].w),M(b,"class","a9s-edge-handle a9s-edge-handle-left"),M(b,"x",D=r[4].x),M(b,"y",F=r[4].y),M(b,"height",G=r[4].h),M(b,"width",1)},m(L,O){ft(L,t,O),ft(L,a,O),ft(L,l,O),ft(L,f,O),ft(L,p,O),ft(L,x,O),ft(L,g,O),ft(L,A,O),ft(L,C,O),ft(L,E,O),ft(L,b,O),ft(L,$,O),Zt(B,L,O),ft(L,Z,O),Zt(P,L,O),ft(L,U,O),Zt(j,L,O),ft(L,rt,O),Zt(Q,L,O),H=!0,V||(lt=[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(C,"pointerdown",function(){Kt(r[9]("BOTTOM"))&&r[9]("BOTTOM").apply(this,arguments)}),zt(b,"pointerdown",function(){Kt(r[9]("LEFT"))&&r[9]("LEFT").apply(this,arguments)})],V=!0)},p(L,O){r=L,(!H||O&2&&e!==(e=r[1]?"display:none;":void 0))&&M(t,"style",e),(!H||O&16&&i!==(i=r[4].x))&&M(t,"x",i),(!H||O&16&&s!==(s=r[4].y))&&M(t,"y",s),(!H||O&16&&n!==(n=r[4].w))&&M(t,"width",n),(!H||O&16&&o!==(o=r[4].h))&&M(t,"height",o),(!H||O&2)&&M(l,"style",r[1]),(!H||O&16&&h!==(h=r[4].x))&&M(l,"x",h),(!H||O&16&&c!==(c=r[4].y))&&M(l,"y",c),(!H||O&16&&u!==(u=r[4].w))&&M(l,"width",u),(!H||O&16&&d!==(d=r[4].h))&&M(l,"height",d),(!H||O&16&&m!==(m=r[4].x))&&M(p,"x",m),(!H||O&16&&_!==(_=r[4].y))&&M(p,"y",_),(!H||O&16&&y!==(y=r[4].w))&&M(p,"width",y),(!H||O&16&&v!==(v=r[4].x+r[4].w))&&M(g,"x",v),(!H||O&16&&w!==(w=r[4].y))&&M(g,"y",w),(!H||O&16&&I!==(I=r[4].h))&&M(g,"height",I),(!H||O&16&&N!==(N=r[4].x))&&M(C,"x",N),(!H||O&16&&S!==(S=r[4].y+r[4].h))&&M(C,"y",S),(!H||O&16&&R!==(R=r[4].w))&&M(C,"width",R),(!H||O&16&&D!==(D=r[4].x))&&M(b,"x",D),(!H||O&16&&F!==(F=r[4].y))&&M(b,"y",F),(!H||O&16&&G!==(G=r[4].h))&&M(b,"height",G);const _t={};O&16&&(_t.x=r[4].x),O&16&&(_t.y=r[4].y),O&8&&(_t.scale=r[3]),B.$set(_t);const ht={};O&16&&(ht.x=r[4].x+r[4].w),O&16&&(ht.y=r[4].y),O&8&&(ht.scale=r[3]),P.$set(ht);const vt={};O&16&&(vt.x=r[4].x+r[4].w),O&16&&(vt.y=r[4].y+r[4].h),O&8&&(vt.scale=r[3]),j.$set(vt);const xt={};O&16&&(xt.x=r[4].x),O&16&&(xt.y=r[4].y+r[4].h),O&8&&(xt.scale=r[3]),Q.$set(xt)},i(L){H||(st(B.$$.fragment,L),st(P.$$.fragment,L),st(j.$$.fragment,L),st(Q.$$.fragment,L),H=!0)},o(L){ut(B.$$.fragment,L),ut(P.$$.fragment,L),ut(j.$$.fragment,L),ut(Q.$$.fragment,L),H=!1},d(L){L&&(ct(t),ct(a),ct(l),ct(f),ct(p),ct(x),ct(g),ct(A),ct(C),ct(E),ct(b),ct($),ct(Z),ct(U),ct(rt)),Jt(B,L),Jt(P,L),Jt(j,L),Jt(Q,L),V=!1,Qe(lt)}}}function iE(r){let t,e;return t=new Bf({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[rE,({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(){ee(t.$$.fragment)},m(i,s){Zt(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||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Jt(t,i)}}}function sE(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],[x,g]=[m.maxX,m.maxY];const[v,w]=p;if(f==="SHAPE")_+=v,x+=v,y+=w,g+=w;else{switch(f){case"TOP":case"TOP_LEFT":case"TOP_RIGHT":{y+=w;break}case"BOTTOM":case"BOTTOM_LEFT":case"BOTTOM_RIGHT":{g+=w;break}}switch(f){case"LEFT":case"TOP_LEFT":case"BOTTOM_LEFT":{_+=v;break}case"RIGHT":case"TOP_RIGHT":case"BOTTOM_RIGHT":{x+=v;break}}}const I=Math.min(_,x),A=Math.min(y,g),C=Math.abs(x-_),N=Math.abs(g-y);return{...d,geometry:{x:I,y:A,w:C,h:N,bounds:{minX:I,minY:A,maxX:I+C,maxY:A+N}}}};function h(d){rr.call(this,r,d)}function c(d){rr.call(this,r,d)}function u(d){rr.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,c,u]}class nE extends ae{constructor(t){super(),oe(this,t,sE,iE,te,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}Ui.RECTANGLE,Ui.POLYGON;const oE=r=>({}),Mf=r=>({grab:r[0]});function aE(r){let t,e,i,s;const n=r[7].default,o=zh(n,r,r[6],Mf);return{c(){t=Tt("g"),o&&o.c(),M(t,"class","a9s-annotation selected")},m(a,l){ft(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)&&Yh(o,n,a,a[6],e?jh(n,a[6],l,oE):qh(a[6]),Mf)},i(a){e||(st(o,a),e=!0)},o(a){ut(o,a),e=!1},d(a){a&&ct(t),o&&o.d(a),i=!1,Qe(s)}}}function lE(r,t,e){let{$$slots:i={},$$scope:s}=t;const n=zs();let{shape:o}=t,{editor:a}=t,{transform:l}=t,h,c,u;const d=m=>_=>{h=m,c=l.elementToImage(_.offsetX,_.offsetY),u=o,_.target.setPointerCapture(_.pointerId),n("grab",_)},f=m=>{if(h){const[_,y]=l.elementToImage(m.offsetX,m.offsetY),x=[_-c[0],y-c[1]];e(3,o=a(u,h,x)),n("change",o)}},p=m=>{m.target.releasePointerCapture(m.pointerId),h=void 0,u=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 Bf extends ae{constructor(t){super(),oe(this,t,lE,aE,te,{shape:3,editor:4,transform:5})}}const hE=(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 cE(r,t,e){let i;const s=zs();let{annotation:n}=t,{editor:o}=t,{style:a}=t,{target:l}=t,{transform:h}=t,{viewportScale:c}=t,u;return Vs(()=>(e(6,u=new o({target:l,props:{shape:n.target.selector,computedStyle:i,transform:h,viewportScale:c}})),u.$on("change",d=>{u.$$set({shape:d.detail}),s("change",d.detail)}),u.$on("grab",d=>s("grab",d.detail)),u.$on("release",d=>s("release",d.detail)),()=>{u.$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,c=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&5&&e(7,i=hE(n,a)),r.$$.dirty&65&&n&&(u==null||u.$set({shape:n.target.selector})),r.$$.dirty&80&&u&&u.$set({transform:h}),r.$$.dirty&96&&u&&u.$set({viewportScale:c}),r.$$.dirty&192&&u&&i&&u.$set({computedStyle:i})},[n,o,a,l,h,c,u,i]}class uE extends ae{constructor(t){super(),oe(this,t,cE,null,te,{annotation:0,editor:1,style:2,target:3,transform:4,viewportScale:5})}}typeof navigator>"u"?!1:navigator.userAgent.indexOf("Mac OS X")!==-1;const dE=r=>({transform:r&2,scale:r&1}),Df=r=>({transform:r[1],scale:r[0]});function fE(r){let t;const e=r[4].default,i=zh(e,r,r[3],Df);return{c(){i&&i.c()},m(s,n){i&&i.m(s,n),t=!0},p(s,[n]){i&&i.p&&(!t||n&11)&&Yh(i,e,s,s[3],t?jh(e,s[3],n,dE):qh(s[3]),Df)},i(s){t||(st(i,s),t=!0)},o(s){ut(i,s),t=!1},d(s){i&&i.d(s)}}}function pE(r,t,e){let{$$slots:i={},$$scope:s}=t,{viewer:n}=t,o=1,a;const l=()=>{const h=n.viewport.getContainerSize().x,c=n.viewport.getZoom(!0),u=n.viewport.getFlip(),d=n.viewport.pixelFromPoint(new Nt.Point(0,0),!0);u&&(d.x=h-d.x);const f=c*h/n.world.getContentFactor(),p=u?-f:f,m=n.viewport.getRotation(!0);e(1,a=`translate(${d.x}, ${d.y}) scale(${p}, ${f}) rotate(${m})`),e(0,o=c*h/n.world.getContentFactor())};return Vs(()=>(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 Of extends ae{constructor(t){super(),oe(this,t,pE,fE,te,{viewer:2})}}function mE(r,t,e){const i=zs();let{drawingMode:s}=t,{target:n}=t,{tool:o}=t,{transform:a}=t,{viewer:l}=t,{viewportScale:h}=t,c;return Vs(()=>{const u=n.closest("svg"),d=[],f=(p,m,_)=>{if(u==null||u.addEventListener(p,m,_),d.push(()=>u==null?void 0:u.removeEventListener(p,m,_)),p==="pointerup"||p==="dblclick"){const y=g=>{const{originalEvent:v}=g;m(v)},x=p==="pointerup"?"canvas-click":"canvas-double-click";l.addHandler(x,y),d.push(()=>l.removeHandler(x,y))}else if(p==="pointermove"){const y=x=>{const{originalEvent:g}=x;m(g)};l.addHandler("canvas-drag",y),d.push(()=>l.removeHandler("canvas-drag",y))}};return e(6,c=new o({target:n,props:{addEventListener:f,drawingMode:s,transform:a,viewportScale:h}})),c.$on("create",p=>i("create",p.detail)),()=>{d.forEach(p=>p()),c.$destroy()}}),r.$$set=u=>{"drawingMode"in u&&e(0,s=u.drawingMode),"target"in u&&e(1,n=u.target),"tool"in u&&e(2,o=u.tool),"transform"in u&&e(3,a=u.transform),"viewer"in u&&e(4,l=u.viewer),"viewportScale"in u&&e(5,h=u.viewportScale)},r.$$.update=()=>{r.$$.dirty&72&&c&&c.$set({transform:a}),r.$$.dirty&96&&c&&c.$set({viewportScale:h})},[s,n,o,a,l,h,c]}class gE extends ae{constructor(t){super(),oe(this,t,mE,null,te,{drawingMode:0,target:1,tool:2,transform:3,viewer:4,viewportScale:5})}}function Ff(r,t,e){const i=r.slice();i[33]=t[e];const s=i[14](i[33].target.selector);return i[34]=s,i}function yE(r){let t=r[2],e,i,s=Lf(r);return{c(){s.c(),e=er()},m(n,o){s.m(n,o),ft(n,e,o),i=!0},p(n,o){o[0]&4&&te(t,t=n[2])?(De(),ut(s,1,1,Be),Oe(),s=Lf(n),s.c(),st(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(st(s),i=!0)},o(n){ut(s),i=!1},d(n){n&&ct(e),s.d(n)}}}function _E(r){let t,e,i=ui(r[6].filter(r[23])),s=[];for(let o=0;o<i.length;o+=1)s[o]=kf(Ff(r,i,o));const n=o=>ut(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=er()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);ft(o,t,a),e=!0},p(o,a){if(a[0]&24162|a[1]&2){i=ui(o[6].filter(o[23]));let l;for(l=0;l<i.length;l+=1){const h=Ff(o,i,l);s[l]?(s[l].p(h,a),st(s[l],1)):(s[l]=kf(h),s[l].c(),st(s[l],1),s[l].m(t.parentNode,t))}for(De(),l=i.length;l<s.length;l+=1)n(l);Oe()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)st(s[a]);e=!0}},o(o){s=s.filter(Boolean);for(let a=0;a<s.length;a+=1)ut(s[a]);e=!1},d(o){o&&ct(t),Oo(s,o)}}}function Lf(r){let t,e;return t=new gE({props:{target:r[5],tool:r[7],drawingMode:r[4],transform:{elementToImage:r[9]},viewer:r[3],viewportScale:r[32]}}),t.$on("create",r[13]),{c(){ee(t.$$.fragment)},m(i,s){Zt(t,i,s),e=!0},p(i,s){const n={};s[0]&32&&(n.target=i[5]),s[0]&128&&(n.tool=i[7]),s[0]&16&&(n.drawingMode=i[4]),s[0]&8&&(n.viewer=i[3]),s[1]&2&&(n.viewportScale=i[32]),t.$set(n)},i(i){e||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Jt(t,i)}}}function Nf(r){let t=r[33].id,e,i,s=Uf(r);return{c(){s.c(),e=er()},m(n,o){s.m(n,o),ft(n,e,o),i=!0},p(n,o){o[0]&64&&te(t,t=n[33].id)?(De(),ut(s,1,1,Be),Oe(),s=Uf(n),s.c(),st(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(st(s),i=!0)},o(n){ut(s),i=!1},d(n){n&&ct(e),s.d(n)}}}function Uf(r){let t,e;return t=new uE({props:{target:r[5],editor:r[14](r[33].target.selector),annotation:r[33],style:r[1],transform:{elementToImage:r[9]},viewportScale:r[32]}}),t.$on("grab",r[10]),t.$on("change",function(){Kt(r[12](r[33]))&&r[12](r[33]).apply(this,arguments)}),t.$on("release",r[11]),{c(){ee(t.$$.fragment)},m(i,s){Zt(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&32&&(n.target=r[5]),s[0]&64&&(n.editor=r[14](r[33].target.selector)),s[0]&64&&(n.annotation=r[33]),s[0]&2&&(n.style=r[1]),s[1]&2&&(n.viewportScale=r[32]),t.$set(n)},i(i){e||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Jt(t,i)}}}function kf(r){let t,e,i=r[34]&&Nf(r);return{c(){i&&i.c(),t=er()},m(s,n){i&&i.m(s,n),ft(s,t,n),e=!0},p(s,n){s[34]?i?(i.p(s,n),n[0]&64&&st(i,1)):(i=Nf(s),i.c(),st(i,1),i.m(t.parentNode,t)):i&&(De(),ut(i,1,1,()=>{i=null}),Oe())},i(s){e||(st(i),e=!0)},o(s){ut(i),e=!1},d(s){s&&ct(t),i&&i.d(s)}}}function vE(r){let t,e,i,s,n,o;const a=[_E,yE],l=[];function h(c,u){return c[5]&&c[6]?0:c[5]&&c[7]&&c[0]?1:-1}return~(i=h(r))&&(s=l[i]=a[i](r)),{c(){t=Tt("svg"),e=Tt("g"),s&&s.c(),M(e,"transform",n=r[31]),M(e,"class","svelte-190cqdf"),M(t,"class","a9s-annotationlayer a9s-osd-drawinglayer svelte-190cqdf"),Xs(t,"drawing",r[0])},m(c,u){ft(c,t,u),tr(t,e),~i&&l[i].m(e,null),r[24](e),o=!0},p(c,u){let d=i;i=h(c),i===d?~i&&l[i].p(c,u):(s&&(De(),ut(l[d],1,1,()=>{l[d]=null}),Oe()),~i?(s=l[i],s?s.p(c,u):(s=l[i]=a[i](c),s.c()),st(s,1),s.m(e,null)):s=null),(!o||u[1]&1&&n!==(n=c[31]))&&M(e,"transform",n),(!o||u[0]&1)&&Xs(t,"drawing",c[0])},i(c){o||(st(s),o=!0)},o(c){ut(s),o=!1},d(c){c&&ct(t),~i&&l[i].d(),r[24](null)}}}function xE(r){let t,e;return t=new Of({props:{viewer:r[3],$$slots:{default:[vE,({transform:i,scale:s})=>({31:i,32:s}),({transform:i,scale:s})=>[0,(i?1:0)|(s?2:0)]]},$$scope:{ctx:r}}}),{c(){ee(t.$$.fragment)},m(i,s){Zt(t,i,s),e=!0},p(i,s){const n={};s[0]&8&&(n.viewer=i[3]),s[0]&255|s[1]&67&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Jt(t,i)}}}function bE(r,t,e){let i,s,n,o,{drawingEnabled:a}=t,{filter:l}=t,{preferredDrawingMode:h}=t,{state:c}=t,{style:u=void 0}=t,{toolName:d=Us()[0]}=t,{user:f}=t,{viewer:p}=t;const m=()=>d,_=()=>a,y=navigator.userAgent.match(/firefox|fxios/i);let x;const{store:g,selection:v,hover:w}=c;Do(r,v,B=>e(22,o=B));let I,A,C;const N=B=>{g.unobserve(I);const Z=B.filter(({editable:P})=>P).map(({id:P})=>P);if(Z.length>0){if(e(6,A=Z.map(P=>g.getAnnotation(P))),I=P=>{const{updated:U}=P.changes;e(6,A=(U||[]).map(j=>j.newValue))},g.observe(I,{annotations:Z}),y){const{width:P}=p.viewport.viewerElementToViewportRectangle(new Nt.Rect(0,0,1,1));p.viewport.panBy(new Nt.Point(Math.abs(P/10),0))}}else e(6,A=void 0)},S=(B,Z)=>{const{x:P,y:U}=p.viewport.viewerElementToImageCoordinates(new Nt.Point(B,Z));return[P,U]},R=B=>{p.setMouseNavEnabled(!1),C=B.timeStamp},E=B=>{if(p.setMouseNavEnabled(!0),performance.now()-(C||0)<300){const{offsetX:P,offsetY:U}=B.detail,[j,rt]=S(P,U),Q=g.getAt(j,rt);Q&&(!l||l(Q))&&!A.find(V=>V.id===Q.id)&&(w.set(Q.id),v.setSelected(Q.id))}},b=B=>Z=>{var rt;const{target:P}=B,U=10*60*1e3,j=((rt=P.creator)==null?void 0:rt.id)!==f.id||!P.created||new Date().getTime()-P.created.getTime()>U;g.updateTarget({...P,selector:Z.detail,created:j?P.created:new Date,updated:j?new Date:void 0,updatedBy:j?f:void 0})},D=B=>{const Z=Hw(),P={id:Z,bodies:[],target:{annotation:Z,selector:B.detail,creator:f,created:new Date}};g.addAnnotation(P),v.setSelected(P.id),p.setMouseNavEnabled(!0)},F=B=>gh(B),G=B=>Je(B);function $(B){Ws[B?"unshift":"push"](()=>{x=B,e(5,x)})}return r.$$set=B=>{"drawingEnabled"in B&&e(0,a=B.drawingEnabled),"filter"in B&&e(15,l=B.filter),"preferredDrawingMode"in B&&e(16,h=B.preferredDrawingMode),"state"in B&&e(17,c=B.state),"style"in B&&e(1,u=B.style),"toolName"in B&&e(2,d=B.toolName),"user"in B&&e(18,f=B.user),"viewer"in B&&e(3,p=B.viewer)},r.$$.update=()=>{r.$$.dirty[0]&4&&e(7,{tool:i,opts:s}=ks(d)||{tool:void 0,opts:void 0},i,(e(21,s),e(2,d))),r.$$.dirty[0]&2162688&&e(4,n=(s==null?void 0:s.drawingMode)||h),r.$$.dirty[0]&25&&(a&&n==="drag"?p.setMouseNavEnabled(!1):p.setMouseNavEnabled(!0)),r.$$.dirty[0]&1&&a&&v.clear(),r.$$.dirty[0]&4194329&&o.selected.length===0&&n==="drag"&&a&&p.setMouseNavEnabled(!1),r.$$.dirty[0]&4194304&&N(o.selected)},[a,u,d,p,n,x,A,i,v,S,R,E,b,D,F,l,h,c,f,m,_,s,o,G,$]}class wE extends ae{constructor(t){super(),oe(this,t,bE,xE,te,{drawingEnabled:0,filter:15,preferredDrawingMode:16,state:17,style:1,toolName:2,user:18,viewer:3,getDrawingTool:19,isDrawingEnabled:20},null,[-1,-1])}get getDrawingTool(){return this.$$.ctx[19]}get isDrawingEnabled(){return this.$$.ctx[20]}}function EE(r){let t,e,i,s,n,o,a,l=r[2].appearance.label+"",h,c,u,d;return{c(){t=Tt("g"),e=Tt("rect"),a=Tt("text"),h=Fo(l),M(e,"class","a9s-presence-label-bg svelte-1rehw2p"),M(e,"x",r[0]),M(e,"y",i=r[1]-18/r[3]),M(e,"height",s=18/r[3]),M(e,"fill",n=r[2].appearance.color),M(e,"stroke",o=r[2].appearance.color),M(a,"font-size",c=12/r[3]),M(a,"x",u=r[0]+Math.round(5/r[3])),M(a,"y",d=r[1]-5/r[3]),M(a,"class","svelte-1rehw2p"),M(t,"class","a9s-presence-label")},m(f,p){ft(f,t,p),tr(t,e),tr(t,a),tr(a,h),r[6](t)},p(f,[p]){p&1&&M(e,"x",f[0]),p&10&&i!==(i=f[1]-18/f[3])&&M(e,"y",i),p&8&&s!==(s=18/f[3])&&M(e,"height",s),p&4&&n!==(n=f[2].appearance.color)&&M(e,"fill",n),p&4&&o!==(o=f[2].appearance.color)&&M(e,"stroke",o),p&4&&l!==(l=f[2].appearance.label+"")&&Jg(h,l),p&8&&c!==(c=12/f[3])&&M(a,"font-size",c),p&9&&u!==(u=f[0]+Math.round(5/f[3]))&&M(a,"x",u),p&10&&d!==(d=f[1]-5/f[3])&&M(a,"y",d)},i:Be,o:Be,d(f){f&&ct(t),r[6](null)}}}function TE(r,t,e){let{x:i}=t,{y:s}=t,{user:n}=t,{scale:o}=t,{hAlign:a=null}=t,l;const h=u=>{const d=l.querySelector("text"),f=l.querySelector("rect"),p=d.getBBox().width+10/u;a==="CENTER"&&l.setAttribute("style",`transform: translateX(-${p/2}px)`),f.setAttribute("width",`${p}`)};function c(u){Ws[u?"unshift":"push"](()=>{l=u,e(4,l)})}return r.$$set=u=>{"x"in u&&e(0,i=u.x),"y"in u&&e(1,s=u.y),"user"in u&&e(2,n=u.user),"scale"in u&&e(3,o=u.scale),"hAlign"in u&&e(5,a=u.hAlign)},r.$$.update=()=>{r.$$.dirty&24&&l&&h(o)},[i,s,n,o,l,a,c]}class Gf extends ae{constructor(t){super(),oe(this,t,TE,EE,te,{x:0,y:1,user:2,scale:3,hAlign:5})}}function AE(r){let t,e,i,s,n,o;return e=new Gf({props:{scale:r[1],user:r[0],x:r[3][0],y:r[3][1],hAlign:"CENTER"}}),{c(){t=Tt("g"),ee(e.$$.fragment),i=Tt("polygon"),M(i,"class","a9s-presence-shape a9s-presence-polygon svelte-fgq4n0"),M(i,"stroke",s=r[0].appearance.color),M(i,"fill","transparent"),M(i,"points",n=r[2].points.map($f).join(" ")),M(t,"class","a9s-presence-overlay")},m(a,l){ft(a,t,l),Zt(e,t,null),tr(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))&&M(i,"stroke",s),(!o||l&4&&n!==(n=a[2].points.map($f).join(" ")))&&M(i,"points",n)},i(a){o||(st(e.$$.fragment,a),o=!0)},o(a){ut(e.$$.fragment,a),o=!1},d(a){a&&ct(t),Jt(e)}}}const $f=r=>r.join(",");function SE(r,t,e){let i,s,{annotation:n}=t,{user:o}=t,{scale:a}=t;const l=h=>{let[c,...u]=h.points;return u.forEach(([d,f])=>{f<c[1]&&(c=[d,f])}),c};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 IE extends ae{constructor(t){super(),oe(this,t,SE,AE,te,{annotation:4,user:0,scale:1})}}function CE(r){let t,e,i,s,n,o,a,l,h;return e=new Gf({props:{scale:r[1],user:r[0],x:r[2].x,y:r[2].y}}),{c(){t=Tt("g"),ee(e.$$.fragment),i=Tt("rect"),M(i,"class","a9s-presence-shape a9s-presence-rectangle svelte-gze948"),M(i,"stroke",s=r[0].appearance.color),M(i,"fill","transparent"),M(i,"x",n=r[2].x),M(i,"y",o=r[2].y),M(i,"width",a=r[2].w),M(i,"height",l=r[2].h),M(t,"class","a9s-presence-overlay")},m(c,u){ft(c,t,u),Zt(e,t,null),tr(t,i),h=!0},p(c,[u]){const d={};u&2&&(d.scale=c[1]),u&1&&(d.user=c[0]),u&4&&(d.x=c[2].x),u&4&&(d.y=c[2].y),e.$set(d),(!h||u&1&&s!==(s=c[0].appearance.color))&&M(i,"stroke",s),(!h||u&4&&n!==(n=c[2].x))&&M(i,"x",n),(!h||u&4&&o!==(o=c[2].y))&&M(i,"y",o),(!h||u&4&&a!==(a=c[2].w))&&M(i,"width",a),(!h||u&4&&l!==(l=c[2].h))&&M(i,"height",l)},i(c){h||(st(e.$$.fragment,c),h=!0)},o(c){ut(e.$$.fragment,c),h=!1},d(c){c&&ct(t),Jt(e)}}}function RE(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 PE extends ae{constructor(t){super(),oe(this,t,RE,CE,te,{annotation:3,user:0,scale:1})}}const{Boolean:ME}=Kg;function Hf(r,t,e){const i=r.slice();return i[8]=t[e],i}function Xf(r){let t,e;return t=new Of({props:{viewer:r[0],$$slots:{default:[OE,({transform:i,scale:s})=>({6:i,7:s}),({transform:i,scale:s})=>(i?64:0)|(s?128:0)]},$$scope:{ctx:r}}}),{c(){ee(t.$$.fragment)},m(i,s){Zt(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||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Jt(t,i)}}}function Vf(r){let t,e,i=ui(r[2]),s=[];for(let o=0;o<i.length;o+=1)s[o]=zf(Hf(r,i,o));const n=o=>ut(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=er()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);ft(o,t,a),e=!0},p(o,a){if(a&132){i=ui(o[2]);let l;for(l=0;l<i.length;l+=1){const h=Hf(o,i,l);s[l]?(s[l].p(h,a),st(s[l],1)):(s[l]=zf(h),s[l].c(),st(s[l],1),s[l].m(t.parentNode,t))}for(De(),l=i.length;l<s.length;l+=1)n(l);Oe()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)st(s[a]);e=!0}},o(o){s=s.filter(ME);for(let a=0;a<s.length;a+=1)ut(s[a]);e=!1},d(o){o&&ct(t),Oo(s,o)}}}function BE(r){let t,e;return t=new IE({props:{annotation:r[8].annotation,user:r[8].selectedBy,scale:r[7]}}),{c(){ee(t.$$.fragment)},m(i,s){Zt(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||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Jt(t,i)}}}function DE(r){let t,e;return t=new PE({props:{annotation:r[8].annotation,user:r[8].selectedBy,scale:r[7]}}),{c(){ee(t.$$.fragment)},m(i,s){Zt(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||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Jt(t,i)}}}function zf(r){let t,e,i,s;const n=[DE,BE],o=[];function a(l,h){return l[8].annotation.target.selector.type===wt.RECTANGLE?0:l[8].annotation.target.selector.type===wt.POLYGON?1:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=er()},m(l,h){~t&&o[t].m(l,h),ft(l,i,h),s=!0},p(l,h){let c=t;t=a(l),t===c?~t&&o[t].p(l,h):(e&&(De(),ut(o[c],1,1,()=>{o[c]=null}),Oe()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=n[t](l),e.c()),st(e,1),e.m(i.parentNode,i)):e=null)},i(l){s||(st(e),s=!0)},o(l){ut(e),s=!1},d(l){l&&ct(i),~t&&o[t].d(l)}}}function OE(r){let t,e,i,s,n=r[2].length>0&&Vf(r);return{c(){t=Tt("svg"),e=Tt("g"),n&&n.c(),M(e,"transform",i=r[6]),M(t,"class","a9s-osd-presencelayer svelte-1krwc4m")},m(o,a){ft(o,t,a),tr(t,e),n&&n.m(e,null),s=!0},p(o,a){o[2].length>0?n?(n.p(o,a),a&4&&st(n,1)):(n=Vf(o),n.c(),st(n,1),n.m(e,null)):n&&(De(),ut(n,1,1,()=>{n=null}),Oe()),(!s||a&64&&i!==(i=o[6]))&&M(e,"transform",i)},i(o){s||(st(n),s=!0)},o(o){ut(n),s=!1},d(o){o&&ct(t),n&&n.d()}}}function FE(r){let t=!!r[1],e,i,s=t&&Xf(r);return{c(){s&&s.c(),e=er()},m(n,o){s&&s.m(n,o),ft(n,e,o),i=!0},p(n,[o]){o&2&&(t=!!n[1]),t?s?(s.p(n,o),o&2&&st(s,1)):(s=Xf(n),s.c(),st(s,1),s.m(e.parentNode,e)):s&&(De(),ut(s,1,1,()=>{s=null}),Oe())},i(n){i||(st(s),i=!0)},o(n){ut(s),i=!1},d(n){n&&ct(e),s&&s.d(n)}}}function LE(r,t,e){let{store:i}=t,{viewer:s}=t,{provider:n}=t,o=[],a;const l=(h,c)=>{e(2,o=[...o.filter(({selectedBy:u})=>u.presenceKey!==h.presenceKey),...(c||[]).map(u=>({annotation:i.getAnnotation(u),selectedBy:h}))].filter(({annotation:u})=>(u||console.warn("Selection event on unknown annotation"),!!u))),a&&i.unobserve(a),a=u=>{const{deleted:d,updated:f}=u.changes,p=new Set((d||[]).map(_=>_.id)),m=o.filter(({annotation:_})=>!p.has(_.id)).map(_=>{const y=(f||[]).find(x=>x.oldValue.id===_.annotation.id);return y?{selectedBy:_.selectedBy,annotation:y.newValue}:_});e(2,o=m)},i.observe(a,{annotations:o.map(u=>u.annotation.id)})};return ty(()=>{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 NE extends ae{constructor(t){super(),oe(this,t,LE,FE,te,{store:3,viewer:0,provider:1})}}const Wf=(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=Uh(a);r.element.setAttribute("data-theme",l)}})}):r.element.setAttribute("data-theme",t)},jf=(r,t,e)=>(i,s={})=>{const n=typeof i=="string"?i:i.id,o=t.getAnnotation(n);if(!o||!Je(o))return;const a=r.container.getBoundingClientRect(),{padding:l}=s;let[h,c,u,d]=l?Array.isArray(l)?l:[l,l,l,l]:[0,0,0,0];h=h/a.height,c=c/a.width,u=u/a.height,d=d/a.width;const{minX:f,minY:p,maxX:m,maxY:_}=o.target.selector.geometry.bounds,y=m-f,x=_-p,g=f-d*y,v=p-h*x,w=y+(c+d)*y,I=x+(h+u)*x,A=r.viewport.imageToViewportRectangle(g,v,w,I);r.viewport[e](A,s.immediately)},UE=(r,t)=>jf(r,t,"fitBounds"),kE=(r,t)=>jf(r,t,"fitBoundsWithConstraints"),GE=(r,t={})=>{const e=Gh(t,{drawingEnabled:!1,drawingMode:ph?"drag":"click",userSelectAction:ao.EDIT,theme:"light"}),i=Nh(e),{hover:s,selection:n,store:o}=i,a=dp(o),l=fp(i,a,e.adapter,e.autoSave);let h=bp(),c=e.drawingEnabled,u=e.drawingMode;const d=Hh(a,r.element),f=new Nw({target:r.element,props:{state:i,viewer:r,style:e.style,filter:void 0}}),p=new NE({target:r.element.querySelector(".openseadragon-canvas"),props:{provider:void 0,store:o,viewer:r}}),m=new wE({target:r.element.querySelector(".openseadragon-canvas"),props:{drawingEnabled:!!c,filter:void 0,preferredDrawingMode:u,state:i,style:e.style,user:h,viewer:r}});f.$on("click",B=>{const{originalEvent:Z,annotation:P}=B.detail;P&&!(u==="click"&&c)?n.userSelect(P.id,Z):n.isEmpty()||n.clear()}),r.element.addEventListener("pointerdown",B=>{if(s.current){const Z=o.getAnnotation(s.current);l.emit("clickAnnotation",Z,B)}}),Wf(r,e.theme);const _=mp(i,a,e.adapter),y=()=>{m.$set({drawingEnabled:!1}),setTimeout(()=>m.$set({drawingEnabled:!0}),1)},x=()=>{f.$destroy(),p.$destroy(),m.$destroy(),d.destroy(),a.destroy()},g=UE(r,o),v=kE(r,o),w=()=>m.getDrawingTool(),I=()=>h,A=()=>m.isDrawingEnabled(),C=(B,Z,P)=>Eh(B,Z,P),N=(B,Z)=>yh(B,Z),S=B=>{if(!ks(B))throw`No drawing tool named ${B}`;m.$set({toolName:B})},R=B=>{c=B,m.$set({drawingEnabled:c})},E=B=>{f.$set({filter:B}),m.$set({filter:B})},b=B=>{f.$set({style:B}),m.$set({style:B})},D=B=>p.$set({provider:B}),F=B=>Wf(r,B),G=B=>{h=B,m.$set({user:B})},$=B=>f.$set({visible:B});return{..._,cancelDrawing:y,destroy:x,fitBounds:g,fitBoundsWithConstraints:v,getDrawingTool:w,getUser:I,isDrawingEnabled:A,listDrawingTools:Us,on:l.on,off:l.off,registerDrawingTool:C,registerShapeEditor:N,setDrawingEnabled:R,setDrawingTool:S,setFilter:E,setPresenceProvider:D,setStyle:b,setTheme:F,setUser:G,setVisible:$,state:i,viewer:r}};Mt.ShapeType=wt,Mt.UserSelectAction=ao,Mt.W3CImageFormat=Lm,Mt.chainStyles=Sm,Mt.computeStyle=Am,Mt.createBody=ip,Mt.createImageAnnotator=jg,Mt.createOSDAnnotator=GE,Mt.defaultColorProvider=Ep,Object.defineProperty(Mt,Symbol.toStringTag,{value:"Module"})});
|
|
1148
1148
|
//# sourceMappingURL=annotorious-openseadragon.js.map
|