tapspace
Version:
A zoomable user interface lib for web apps
1 lines • 223 kB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.tapspace=e():t.tapspace=e()}(self,(()=>(()=>{var t={46010:(t,e,n)=>{t.exports=n(51568)},55711:t=>{t.exports=t=>e=>{const n=e.distanceToCamera,r=e.depthOnCamera;if(null===t.previousDistance)return t.previousDistance=n,t.previousDepth=r,t.emit("cameraenter",e),void t.emit("camerain",e);n!==t.previousDistance&&(n<t.previousDistance?t.emit("cameraenter",e):t.emit("cameraleave",e),r<t.previousDepth?t.emit("camerain",e):t.emit("cameraout",e),t.previousDistance=n,t.previousDepth=r)}},65129:(t,e,n)=>{const r=n(537),s=n(55711),o=function(t){if(r.call(this),!t||!t.tran)throw new Error("Invalid component");this.component=t,this.bound=!1,this.previousDistance=null,this.previousDepth=null,this.onmeasure=null};t.exports=o;const i=o.prototype;Object.assign(i,r.prototype),i.bind=function(){this.bound||(this.bound=!0,this.onmeasure=s(this))},i.update=function(){throw new Error("Not implemented.")},i.unbind=function(){this.bound&&(this.bound=!1,this.previousDistance=null,this.previousDepth=null,this.onmeasure=null,this.off())}},537:(t,e,n)=>{const r=n(98767),s=function(){r(this)};t.exports=s;const o=s.prototype;o.bind=function(){throw new Error("Subclass must override this method.")},o.update=function(){throw new Error("Subclass must override this method.")},o.unbind=function(){throw new Error("Subclass must override this method.")}},50149:(t,e,n)=>{const r=n(14318),s=n(64629),o=n(49846),i=n(20571),a=n(74017),c=function(t,e,n){n||(n={}),this.options=Object.assign({preventDefault:!0,stopPropagation:!1},n),this.onpointerdown=null,this.onpointermove=null,this.onpointerup=null,this.onpointercancel=null,this.oncontextmenu=null,this.element=t,this.onstart=e.onstart,this.onmove=e.onmove,this.onend=e.onend,this.oncancel=e.oncancel,this.started=!1,this.currPointers={},this.onpointerdown=o(this),this.onpointermove=i(this),this.onpointerup=a(this),this.onpointercancel=s(this),this.oncontextmenu=r(this),window.addEventListener("contextmenu",this.oncontextmenu);const c={capture:!1,passive:!1};this.element.addEventListener("pointerdown",this.onpointerdown,c),this.element.addEventListener("pointermove",this.onpointermove,c),this.element.addEventListener("pointerup",this.onpointerup,c),this.element.addEventListener("pointercancel",this.onpointercancel,c)};t.exports=c;const h=c.prototype;h.update=n(95444),h.unbind=n(97143)},45162:t=>{t.exports=t=>{if(t.defaultPrevented)return!1;if(t.target.affine)return!0;if(t.currentTarget.classList.contains("affine-proxy-pointer"))return!0;let e=t.target;for(;e&&e!==t.currentTarget;){if(e.classList.contains("affine-proxy-pointer"))return!0;e=e.parentElement}return!1}},14318:t=>{t.exports=t=>e=>{if(!t.started)return;const n=Object.assign({},t.currPointers);t.currPointers={},t.started=!1,t.oncancel(n)}},64629:(t,e,n)=>{const r=n(45162);t.exports=t=>function(e){if(!t.started)return;if(!r(e))return;if(!t.currPointers[e.pointerId])return;t.options.preventDefault&&e.preventDefault();const n=Object.assign({},t.currPointers);delete n[e.pointerId],Object.keys(n).length<1&&(t.started=!1,t.oncancel(t.currPointers)),t.currPointers=n}},49846:(t,e,n)=>{const r=n(45162);t.exports=t=>function(e){if(!r(e))return;t.options.preventDefault&&e.preventDefault(),e.target.setPointerCapture(e.pointerId);const n=Object.assign({},t.currPointers);n[e.pointerId]={x:e.pageX,y:e.pageY,target:e.target},t.started||(t.started=!0,t.onstart(n)),t.currPointers=n}},20571:(t,e,n)=>{const r=n(45162);t.exports=t=>function(e){if(!t.started)return;if(!r(e))return;if(!t.currPointers[e.pointerId])return;t.options.preventDefault&&e.preventDefault();const n=Object.assign({},t.currPointers);n[e.pointerId]&&(n[e.pointerId]={x:e.pageX,y:e.pageY,target:e.target}),t.onmove(t.currPointers,n),t.currPointers=n}},74017:(t,e,n)=>{const r=n(45162);t.exports=t=>function(e){if(!t.started)return;if(!r(e))return;if(!t.currPointers[e.pointerId])return;t.options.preventDefault&&e.preventDefault();const n=Object.assign({},t.currPointers);delete n[e.pointerId],Object.keys(n).length<1&&(t.started=!1,t.onend(t.currPointers)),t.currPointers=n}},97143:t=>{t.exports=function(){this.element.removeEventListener("pointerdown",this.onpointerdown),this.element.removeEventListener("pointermove",this.onpointermove),this.element.removeEventListener("pointerup",this.onpointerup),this.element.removeEventListener("pointercancel",this.onpointercancel),this.onpointerdown=null,this.onpointermove=null,this.onpointerup=null,this.onpointercancel=null,window.removeEventListener("contextmenu",this.oncontextmenu),this.oncontextmenu=null}},95444:t=>{t.exports=function(t){this.options=Object.assign({preventDefault:this.options.preventDefault,stopPropagation:this.options.stopPropagation},t)}},60598:(t,e,n)=>{const r=n(84373).helm3.compose;t.exports=(t,e)=>{const n=e.x,s=e.y;return r({a:1,b:0,x:-n,y:-s,z:0},r(t,{a:1,b:0,x:n,y:s,z:0}))}},97258:(t,e,n)=>{const r=n(80474),s=n(40380),o=n(27101),i=n(29852),a=n(41078),c=n(27390),h=n(9876).transform.IDENTITY;t.exports=(t,e,n)=>{if(null===e.startTime)throw new Error("Unexpected onCancel call");if(Object.keys(n).length<1)throw new Error("Unexpected empty lastPointers");const p=t.component.getViewport();if(!p)throw new Error("Cannot capture gesture without a viewport.");const u=s(t.freedom,p),l=r(n,p),x=o(l),f=i(u,x);t.emit("gesturecancel",{travel:e.totalTravel,duration:Date.now()-e.startTime,component:t.component,target:e.target,mean:new c(p,x),transform:new a(p,e.totalTransform),transformOrigin:new c(p,{x:0,y:0}),delta:new a(p,h),deltaOrigin:new c(p,f)}),e.startTime=null,e.totalTravel=null,e.totalTransform=null,e.pointersOnRoot={},e.target=null}},74182:(t,e,n)=>{const r=n(80474),s=n(40380),o=n(27101),i=n(29852),a=n(41078),c=n(27390),h=n(9876).transform.IDENTITY;t.exports=(t,e,n)=>{if(null===e.startTime)throw new Error("Unexpected onEnd call");const p=t.component.getViewport();if(!p)throw new Error("Cannot capture gesture without a viewport.");const u=s(t.freedom,p),l=r(n,p),x=o(l),f=i(u,x);t.emit("gestureend",{travel:e.totalTravel,duration:Date.now()-e.startTime,component:t.component,target:e.target,mean:new c(p,x),transform:new a(p,e.totalTransform),transformOrigin:new c(p,{x:0,y:0}),delta:new a(p,h),deltaOrigin:new c(p,f)}),e.startTime=null,e.totalTravel=null,e.totalTransform=null,e.pointersOnRoot={},e.target=null}},90732:(t,e,n)=>{const r=n(80474),s=n(40380),o=n(60598),i=n(27101),a=n(29852),c=n(41078),h=n(27390),p=n(9876),u=p.transform.compose;t.exports=(t,e,n,l)=>{if(null===e.startTime)throw new Error("Unexpected onMove call");const x=t.component.getViewport();if(!x)throw new Error("Cannot capture gesture without a viewport.");const f=e.pointersOnRoot,d=r(l,x),y=[],m=[];Object.keys(f).forEach((t=>{d[t]&&(y.push(f[t]),m.push(d[t]))}));const b=s(t.freedom,x),w=i(d),g=a(b,w),v=p.estimate({estimator:b.type,domain:y,range:m,center:b.pivot,angle:b.angle});v.z=0;const z=o(v,g),T=Object.keys(n),M=T.length;let R=0;T.forEach((t=>{if(l[t]){const e=n[t].x-l[t].x,r=n[t].y-l[t].y;R+=(Math.abs(e)+Math.abs(r))/M}})),e.totalTravel+=R;const E=u(v,e.totalTransform);e.totalTransform=E,e.pointersOnRoot=d,t.emit("gesturemove",{travel:e.totalTravel,duration:Date.now()-e.startTime,component:t.component,target:e.target,mean:new h(x,w),transform:new c(x,e.totalTransform),transformOrigin:new h(x,{x:0,y:0}),delta:new c(x,z),deltaOrigin:new h(x,g)})}},57354:(t,e,n)=>{const r=n(34440),s=n(80474),o=n(40380),i=n(29852),a=n(27101),c=n(41078),h=n(27390),p=n(9876).transform.IDENTITY;t.exports=(t,e,n)=>{const u=t.component.getViewport();if(!u)throw new Error("Cannot capture gesture without a viewport.");const l=s(n,u);e.startTime=Date.now(),e.totalTravel=0,e.totalTransform=p,e.target=r(n),e.pointersOnRoot=l;const x=o(t.freedom,u),f=a(l),d=i(x,f);t.emit("gesturestart",{travel:0,duration:0,component:e.component,target:e.target,mean:new h(u,f),transform:new c(u,p),transformOrigin:new h(u,{x:0,y:0}),delta:new c(u,p),deltaOrigin:new h(u,d)})}},34440:(t,e,n)=>{const r=n(37720).findAffineAncestor;t.exports=t=>{const e=Object.keys(t);if(e.length>0){const n=t[e[0]].target;return r(n)}throw new Error("cannot find target from empty set of pointers.")}},29852:t=>{t.exports=(t,e)=>t.pivot?t.pivot:e},27101:(t,e,n)=>{const r=n(84373).point2;t.exports=t=>r.mean(Object.values(t))},60784:(t,e,n)=>{const r=n(537),s=n(50149),o=n(57354),i=n(90732),a=n(74182),c=n(97258),h=function(t,e){if(r.call(this),!t||!t.tran)throw new Error("Invalid component");if(this.component=t,e||(e={}),this.preventDefault=!0,"boolean"==typeof e.preventDefault&&(this.preventDefault=e.preventDefault),"boolean"==typeof e.stopPropagation&&(this.stopPropagation=e.stopPropagation),this.freedom={type:"TSR"},e.freedom&&(this.freedom=e.freedom),!this.freedom.type)throw new Error("A freedom object must have a freedom type.");this.bound=!1,this.sensor=null};t.exports=h;const p=h.prototype;Object.assign(p,r.prototype),p.bind=function(){if(this.bound)return;this.bound=!0;const t={startTime:null,totalTravel:null,totalTransform:null,pointersOnRoot:{},target:null},e=this;this.sensor=new s(this.component.element,{onstart:n=>{o(e,t,n)},onmove:(n,r)=>{i(e,t,n,r)},onend:n=>{a(e,t,n)},oncancel:n=>{c(e,t,n)}},{preventDefault:this.preventDefault,stopPropagation:this.stopPropagation})},p.getFreedom=function(){return this.freedom},p.update=function(t){t.freedom&&(this.freedom=t.freedom),"boolean"==typeof t.preventDefault&&(this.preventDefault=t.preventDefault),"boolean"==typeof t.stopPropagation&&(this.stopPropagation=t.stopPropagation),this.sensor&&this.sensor.update({preventDefault:this.preventDefault,stopPropagation:this.stopPropagation})},p.unbind=function(){this.bound&&(this.bound=!1,this.sensor.unbind(),this.sensor=null,this.off())}},40380:t=>{t.exports=(t,e)=>{const n={type:t.type};return t.pivot&&(n.pivot=e.at(t.pivot).point),t.angle&&(n.angle=t.angle),n}},80474:t=>{t.exports=(t,e)=>{const n=e.atPageFn(),r={};let s,o;const i=Object.keys(t);for(;i.length>0;)s=i.pop(),o=t[s],r[s]=n(o.x,o.y).point;return r}},93355:t=>{t.exports=t=>function(e){e.target===t.component.element&&(e.preventDefault(),t.emit("keydown",e))}},96513:t=>{t.exports=t=>function(e){e.target===t.component.element&&(e.preventDefault(),t.emit("keyup",e))}},44271:(t,e,n)=>{const r=n(537),s=n(93355),o=n(96513),i=function(t,e){if(r.call(this),!t||!t.tran)throw new Error("Invalid component");this.component=t,this.bound=!1,this.onkeydown=null,this.onkeyup=null};t.exports=i;const a=i.prototype;Object.assign(a,r.prototype),a.bind=function(){if(this.bound)return;this.bound=!0,this.onkeydown=s(this),this.onkeyup=o(this);const t=this.component.element;t.addEventListener("keydown",this.onkeydown),t.addEventListener("keyup",this.onkeyup)},a.update=function(t){},a.unbind=function(){if(!this.bound)return;this.bound=!1;const t=this.component.element;t.removeEventListener("keydown",this.onkeydown),t.removeEventListener("keyup",this.onkeyup),this.onkeydown=null,this.onkeyup=null,this.off()}},88351:(t,e,n)=>{const r=n(53744);t.exports=t=>e=>{const n={target:t.component,previousSize:t.previousSize,size:t.previousSize};let s=null;for(const t of e)s=t.borderBoxSize&&t.borderBoxSize.length>0?{w:t.borderBoxSize[0].inlineSize,h:t.borderBoxSize[0].blockSize}:{w:t.contentRect.width,h:t.contentRect.height};if(s){s.d=0;const e=new r(t.component,s);n.size=e,t.previousSize=e}t.emit("resize",n)}},29231:(t,e,n)=>{const r=n(537),s=n(88351),o=function(t){if(r.call(this),!t||!t.tran)throw new Error("Invalid component");this.component=t,this.previousSize=null,this.bound=!1,this.onresize=null};t.exports=o;const i=o.prototype;Object.assign(i,r.prototype),i.bind=function(){this.bound||(this.bound=!0,this.onresize=s(this),this.observer=new window.ResizeObserver(this.onresize),this.observer.observe(this.component.element),this.previousSize=this.component.getSize())},i.unbind=function(){this.bound&&(this.bound=!1,this.observer.disconnect(),this.observer=null,this.onresize=()=>{},this.off())}},64175:(t,e,n)=>{const r=n(37720).findAffineAncestor,s=n(45737);t.exports=t=>function(e){if(!s(e))return;let n;t.options.preventDefault&&e.preventDefault();const o=t.component.getViewport();if(!o||!o.atPage)return;n=o.atPage(e.pageX,e.pageY);const i=e.deltaX,a=e.deltaY;let c=1;switch(e.deltaMode){case 0:default:c=1;break;case 1:c=14;break;case 2:c=400}const h=r(e.target);t.emit("wheel",{center:n,component:t.component,target:h,deltaX:c*i,deltaY:c*a})}},20106:(t,e,n)=>{const r=n(537),s=n(64175),o=function(t,e){if(r.call(this),!t||!t.tran)throw new Error("Invalid component");this.component=t,e||(e={}),this.options=Object.assign({preventDefault:!0,stopPropagation:!1},e),this.bound=!1,this.onwheel=null};t.exports=o;const i=o.prototype;Object.assign(i,r.prototype),i.bind=function(){this.bound||(this.bound=!0,this.onwheel=s(this),this.component.element.addEventListener("wheel",this.onwheel,{passive:!1}))},i.update=function(t){this.options=Object.assign({},this.options,t)},i.unbind=function(){this.bound&&(this.bound=!1,this.component.element.removeEventListener("wheel",this.onwheel),this.onwheel=null,this.off())}},45737:t=>{t.exports=t=>{if(t.defaultPrevented)return!1;if(t.target.affine)return!0;if(t.currentTarget.classList.contains("affine-proxy-wheel"))return!0;let e=t.target;for(;e&&e!==t.currentTarget;){if(e.classList.contains("affine-proxy-wheel"))return!0;e=e.parentElement}return!1}},95683:(t,e,n)=>{e.camera=n(65129),e.gesture=n(60784),e.keyboard=n(44271),e.resize=n(29231),e.wheel=n(20106)},90066:(t,e,n)=>{const r=n(23477);t.exports=function(t){return!1===t?(this.element.style.removeProperty("transition"),this.ontransitionend&&(this.element.removeEventListener("transitionend",this.ontransitionend),this.ontransitionend=null)):r(this.element,t),this}},15044:(t,e,n)=>{const r=n(23477);t.exports=function(t){const e=this.element;return this.ontransitionend&&(e.removeEventListener("transitioncancel",this.ontransitioncancel),e.removeEventListener("transitionend",this.ontransitionend),this.ontransitioncancel=null,this.ontransitionend=null),this.ontransitioncancel=t=>{this.ontransitionend(t)},this.ontransitionend=t=>{this.ontransitionend&&(e.style.removeProperty("transition"),e.removeEventListener("transitioncancel",this.ontransitioncancel),e.removeEventListener("transitionend",this.ontransitionend),this.ontransitioncancel=null,this.ontransitionend=null,this.requestIdle())},e.addEventListener("transitioncancel",this.ontransitioncancel),e.addEventListener("transitionend",this.ontransitionend),r(e,t),this}},75251:t=>{t.exports=function(){return this.ontransitionend&&this.ontransitionend(),this}},23477:t=>{t.exports=function(t,e){let n="200ms",r="ease",s="0ms";if("object"==typeof e){switch(typeof e.duration){case"string":n=e.duration;break;case"number":n=Math.round(e.duration)+"ms";break;case"undefined":break;default:throw new Error("Invalid duration: "+e.duration)}switch(typeof e.easing){case"string":r=e.easing;break;case"undefined":break;default:throw new Error("Invalid easing: "+e.easing)}switch(typeof e.delay){case"string":s=e.delay;break;case"number":s=Math.round(e.delay)+"ms";break;case"undefined":break;default:throw new Error("Invalid delay: "+e.delay)}}t.style.transition="transform "+n+" "+r+" "+s}},32166:(t,e,n)=>{const r=function(){this.ontransitioncancel=null,this.ontransitionend=null};t.exports=r;const s=r.prototype;s.isAnimatable=!0,s.animate=n(90066),s.animateOnce=n(15044),s.cancelAnimation=n(75251)},158:t=>{t.exports=t=>(e,n)=>new t(e,n)},38938:(t,e,n)=>{const r=n(16289);t.exports=function(){const t=this.size.w,e=this.angle,n=t/(2*Math.sin(e/2));return new r(this,n*e)}},57838:(t,e,n)=>{const r=n(16289);t.exports=function(){const t=this.size.w,e=this.angle,n=t/(2*Math.sin(e/2));return new r(this,n)}},4389:(t,e,n)=>{const r=n(29032),s=Math.PI/18,o=Math.PI,i=function(t,e){const n=Math.abs(t),i=Math.min(Math.max(n,s),o);this.angle=Math.sign(t)*i;const a=document.createElement("div");a.classList.add("affine-arc");const c=document.createElement("div");c.style.position="absolute",c.style.boxSizing="border-box",c.style.border=e||"1px solid black",c.style.left="0px",c.style.top="-50px",c.style.borderRadius="50px",c.style.width="100px",c.style.height="100px",c.classList.add("affine-proxy-pointer"),c.classList.add("affine-proxy-wheel"),a.appendChild(c),this.circle=c,r.call(this,a),this.setSize({w:100,h:50})};t.exports=i;const a=i.prototype;a.isArc=!0,Object.assign(a,r.prototype),i.create=n(158)(i),a.atStart=a.atBottomLeft,a.atEnd=a.atBottomRight,a.getLength=n(38938),a.getRadius=n(57838),a.setPoints=n(37089)},37089:t=>{t.exports=function(t,e){const n=t.getDistanceTo(e).transitRaw(this),r=Math.abs(this.angle),s=n/(2*Math.sin(r/2)),o=n/2*Math.tan(r/4);this.setSize(n,o+2);const i=2*s,a=i.toFixed(0)+"px";let c,h,p,u;return this.circle.style.width=a,this.circle.style.height=a,this.circle.style.borderRadius=s.toFixed(0)+"px",this.angle>=0?(c=0,h=n/2-s):(c=o-i,h=n/2-s),this.circle.style.top=c.toFixed(0)+"px",this.circle.style.left=h.toFixed(0)+"px",this.angle>=0?(p=this.atBottomLeft(),u=this.atBottomRight()):(p=this.atTopLeft(),u=this.atTopRight()),this.match({estimator:"TR",sources:[p,u],targets:[t,e]}),this}},74229:t=>{t.exports=function(){return this.atNorm(0,1)}},35869:t=>{t.exports=function(){return this.atNorm(.5,1)}},56967:t=>{t.exports=function(){return this.atNorm(1,1)}},50690:t=>{t.exports=function(){return this.atNorm(0,.5)}},89206:t=>{t.exports=function(){return this.atNorm(.5,.5)}},96030:t=>{t.exports=function(){return this.atNorm(1,.5)}},4654:t=>{t.exports=function(){throw new Error("Subclass must override atNorm method.")}},58301:t=>{t.exports=function(){return this.atNorm(0,0)}},17139:t=>{t.exports=function(){return this.atNorm(.5,0)}},30842:t=>{t.exports=function(){return this.atNorm(1,0)}},28162:t=>{t.exports=function(){return this.getSize().getArea()}},48781:(t,e,n)=>{const r=n(67441),s=n(84373).box3;t.exports=function(t){const e=this.getSize().getRaw();let n={a:1,b:0,x:0,y:0,z:0,w:e.w,h:e.h,d:0};if(t){const e=this.getTransitionTo(t);n=s.transitFrom(n,e),n=s.getBounds(n)}else t=this;return new r(t,n)}},24422:(t,e,n)=>{const r=n(40160);t.exports=function(){const t=this.getSize().getRaw(),e=t.w/2,n=t.h/2,s=Math.sqrt(e*e+n*n);return new r(this,{x:e,y:n,z:0,r:s})}},2878:(t,e,n)=>{const r=n(16289);t.exports=function(){const t=this.getSize().size,e=t.w,n=t.h;return new r(this,Math.sqrt(e*e+n*n))}},26016:t=>{t.exports=function(){throw new Error("Subclass must override getHeight method.")}},8734:t=>{t.exports=function(){throw new Error("Subclass must override getSize method.")}},50226:t=>{t.exports=function(){throw new Error("Subclass must override getWidth method.")}},75955:(t,e,n)=>{const r=n(49163),s=function(t){r.call(this,t)},o=s.prototype;t.exports=s,o.isBlockComponent=!0,Object.assign(o,r.prototype),o.atBottomLeft=n(74229),o.atBottomMid=n(35869),o.atBottomRight=n(56967),o.atCenter=n(89206),o.atMidLeft=n(50690),o.atMid=o.atCenter,o.atMidMid=o.atCenter,o.atMiddle=o.atCenter,o.atMidRight=n(96030),o.atNorm=n(4654),o.atTopLeft=n(58301),o.atTopMid=n(17139),o.atTopRight=n(30842),o.getArea=n(28162),o.getBoundingBox=n(48781),o.getBoundingCircle=n(24422),o.getDiameter=n(2878),o.getNormalizedPoint=o.atNorm,o.getSize=n(8734),o.getWidth=n(50226),o.getHeight=n(26016),o.moveCenterTo=n(74428),o.normAt=n(55820),o.scaleToFill=n(54153),o.scaleToFit=n(32532),o.scaleToHeight=n(16899),o.scaleToWidth=n(44203)},74428:t=>{t.exports=function(t){return this.match({source:this.atMid(),target:t}),this}},55820:t=>{t.exports=function(t,e){throw new Error("Subclass must override normAt method.")}},54153:t=>{t.exports=function(t,e){t.transitRaw&&(t=t.transitRaw(this));const n=this.getSize().size,r=t.w/n.w,s=t.h/n.h,o=Math.max(r,s);return this.scaleBy(o,e),this}},32532:t=>{t.exports=function(t,e){t.transitRaw&&(t=t.transitRaw(this));const n=this.getSize().size,r=t.w/n.w,s=t.h/n.h,o=Math.min(r,s);return this.scaleBy(o,e),this}},16899:t=>{t.exports=function(t,e){t.transitRaw&&(t=t.transitRaw(this));const n=t/this.getSize().size.h;return this.scaleBy(n,e),this}},44203:t=>{t.exports=function(t,e){t.transitRaw&&(t=t.transitRaw(this));const n=t/this.getWidth().getRaw();return this.scaleBy(n,e),this}},53506:t=>{t.exports=function(t,e){return this.element.appendChild(t.element),e&&t.translateTo(e),this}},9671:t=>{t.exports=function(t){const e=this.element.classList;return e.add.apply(e,arguments),this}},26376:t=>{t.exports=function(t,e){if("string"!=typeof t)throw new Error("Invalid key");if(!e.isComponent)throw new Error("Invalid target");return this.links[t]=e,this}},29698:(t,e,n)=>{const r=n(27390);t.exports=function(t,e,n){let s;if("object"==typeof t&&t)s=t.transitRaw?t.transitRaw(this):{x:t.x,y:t.y,z:"number"==typeof t.z?t.z:0};else{if("number"!=typeof t)throw new Error("Invalid coordinates");s={x:t,y:e,z:"number"==typeof n?n:0}}return new r(this,s)}},82487:(t,e,n)=>{const r=n(27390);t.exports=function(){return new r(this,{x:0,y:0,z:0})}},89029:t=>{t.exports=function(t){const e=t.element.nextElementSibling;return this.element.parentNode.insertBefore(this.element,e),this}},33928:t=>{t.exports=function(){return this.element.parentNode.appendChild(this.element),this}},27764:t=>{t.exports=t=>{if(t&&t.element&&t.tran)return t;if(t.affine)return t.affine;let e=t.parentElement;for(;e;){if(e.affine)return e.affine;e=e.parentElement}return null}},39570:t=>{t.exports=t=>t&&t.affine},1657:t=>{t.exports=function(t){if(this===t)return this;const e=[];let n=this.element;for(;n&&n.affine;)e.push(n),n=n.parentElement;const r=[];for(n=t.element;n&&n.affine;)r.push(n),n=n.parentElement;let s=e.pop(),o=r.pop();if(s!==o)return null;let i=s;for(;e.length>0&&r.length>0;){if(s=e.pop(),o=r.pop(),s!==o)return i.affine;i=s}return i.affine}},7704:t=>{t.exports=function(t){return this.links[t]||null}},73162:t=>{t.exports=function(){const t=[];let e=this.element.parentElement;for(;e&&e.affine;)t.push(e.affine),e=e.parentElement;return t}},28674:(t,e,n)=>{const r=n(19268);t.exports=function(){return new r(this,{a:1,b:0,x:0,y:0,z:0})}},26139:(t,e,n)=>{const r=n(19268);t.exports=function(t){return t.transitRaw&&(t=t.transitRaw(this)),new r(this,{a:1,b:0,x:t.x,y:t.y,z:t.z})}},86557:t=>{t.exports=function(){const t=this.element,e=[];for(let n=0;n<t.children.length;n+=1)t.children[n].affine&&e.push(t.children[n].affine);return e}},84688:t=>{t.exports=function(){let t=[];const e=this.getChildren();for(let n=0;n<e.length;n+=1){const r=e[n];t=t.concat(r,r.getDescendants())}return t}},93301:t=>{t.exports=function(){return this.element}},54432:t=>{t.exports=function(){return this.getDescendants().filter((t=>t.isLeaf()))}},40306:(t,e,n)=>{const r=n(52568);t.exports=function(){return new r(this,{a:1,b:0})}},7950:t=>{t.exports=function(){const t=this.element.parentElement;return t&&t.affine?t.affine:null}},26532:t=>{t.exports=function(){let t=this,e=this.element.parentElement;for(;e&&e.affine;)t=e.affine,e=e.parentElement;return t}},34682:(t,e,n)=>{const r=n(84373).plane3;t.exports=function(t,e){const n=this.getTransitionTo(t,e);return r.invert(n)}},72115:(t,e,n)=>{const r=n(84373).plane3;t.exports=function(t,e){if(t===this)return r.IDENTITY;const n=this.findCommonAncestor(t);if(null===n){if(e)return null;throw new Error("Transition between the planes does not exist because they are not connected.")}const s=n.element;let o=this.element,i=r.IDENTITY;for(;o!==s;)i=r.compose(o.affine.tran,i),o=o.parentElement;const a=i;for(o=t.element,i=r.IDENTITY;o!==s;)i=r.compose(o.affine.tran,i),o=o.parentElement;const c=i;return r.transitTo(a,c)}},51308:(t,e,n)=>{const r=n(84373).plane3;t.exports=function(){return r.copy(this.tran)}},65871:(t,e,n)=>{const r=n(84373).plane3;t.exports=function(t){const e=t.getParent();if(e)return this.getTransitionTo(e);const n=this.getTransitionTo(t);return r.compose(t.tran,n)}},38703:(t,e,n)=>{const r=n(76130);t.exports=function(t,e,n){return new r(this,{x:t,y:e,z:n=n||0})}},44200:t=>{t.exports=function(){const t=this.getRoot();return t.isViewport?t:null}},19260:t=>{t.exports=function(t){return this.element.classList.contains(t)}},88546:t=>{t.exports=function(t){return t in this.links}},37720:(t,e,n)=>{const r=n(98767),s=function(t){if(!t)throw new Error("Element does not exist.");if(t.affine)throw new Error("Element is already affine.");t.affine=this,this.element=t,this.links={},this.idleTimeout=null,this.tran={a:1,b:0,x:0,y:0,z:0}};t.exports=s;const o=s.prototype;o.isComponent=!0,r(o),s.findAffineAncestor=n(27764),s.isAffine=n(39570),o.addChild=n(53506),o.addClass=n(9671),o.addLink=n(26376),o.appendChild=o.addChild,o.at=n(29698),o.atAnchor=n(82487),o.bringAbove=n(89029),o.bringToFront=n(33928),o.findCommonAncestor=n(1657),o.followLink=n(7704),o.getAncestors=n(73162),o.getBasis=n(28674),o.getBasisAt=n(26139),o.getChildren=n(86557),o.getDescendants=n(84688),o.getElement=n(93301),o.getLeaves=n(54432),o.getOrientation=n(40306),o.getParent=n(7950),o.getPoint=o.at,o.getRoot=n(26532),o.getTransitionFrom=n(34682),o.getTransitionTo=n(72115),o.getTransitionToParent=n(51308),o.getTransitionToParentOf=n(65871),o.getVector=n(38703),o.getViewport=n(44200),o.hasClass=n(19260),o.hasLink=n(88546),o.isLeaf=n(46009),o.isRoot=n(42278),o.prependChild=n(44636),o.remove=n(42930),o.removeChild=n(28291),o.removeClass=n(23230),o.removeLink=n(26106),o.removeLinks=n(41498),o.replaceChild=n(89521),o.replaceParent=n(36410),o.requestIdle=n(9216),o.sendBelow=n(92778),o.sendToBack=n(4702),o.setId=n(470),o.setParent=n(13915),o.sortByDepth=n(66722)},46009:t=>{t.exports=function(){return 0===this.getChildren().length}},42278:t=>{t.exports=function(){const t=this.element.parentElement;return!t||!t.affine}},44636:t=>{t.exports=function(t,e){return this.element.prepend(t.element),e&&t.translateTo(e),this}},42930:t=>{t.exports=function(){const t=this.element,e=t.parentElement;return e&&e.removeChild(t),this}},28291:t=>{t.exports=function(t){let e;return e=t.nodeType?t:t.element,e.parentElement===this.element&&this.element.removeChild(e),this}},23230:t=>{t.exports=function(t){return this.element.classList.remove(t),this}},26106:t=>{t.exports=function(t,e){if("string"!=typeof t)throw new Error("Invalid key");return e||delete this.links[t],e.isComponent&&this.links[t]===e&&delete this.links[t],this}},41498:t=>{t.exports=function(){return Object.keys(this.links).forEach((t=>{const e=this.links[t];Object.keys(e.links).forEach((t=>{e.removeLink(t,this)})),delete this.links[t]})),this.links={},this}},89521:t=>{t.exports=function(t,e){if(!t.isComponent)throw new Error("Cannot replace non-affine element.");if(!e.isComponent)throw new Error("Cannot replace with a non-affine element.");if(t.element.parentElement!==this.element)throw new Error("Cannot replace non-existing element.");const n=t.tran;return t.element.replaceWith(e.element),e.tran=n,e.renderTransform(),this}},36410:(t,e,n)=>{const r=n(84373).plane3;t.exports=function(t){if(!t.element||!t.element.affine)throw new Error("Cannot append to non-affine element.");const e=this.getParent();if(!e)throw new Error("Cannot replace non-existing parent.");const n=e.getTransitionTo(t),s=r.transitFrom(this.tran,n);return t.element.appendChild(this.element),this.tran=s,this.renderTransform(),this}},9216:t=>{t.exports=function(){return this.idleTimeout&&clearTimeout(this.idleTimeout),this.idleTimeout=setTimeout((()=>{this.ontransitionend||this.emit("idle")}),150),this}},92778:t=>{t.exports=function(t){return this.element.parentNode.insertBefore(this.element,t.element),this}},4702:t=>{t.exports=function(){return this.element.parentNode.prepend(this.element),this}},470:t=>{t.exports=function(t){return this.element.id=t,this}},13915:t=>{t.exports=function(t,e){if(!t.element||!t.element.affine)throw new Error("Cannot append to non-affine element.");return t.addChild(this,e),this}},66722:t=>{t.exports=function(){const t=this.getChildren();return t.sort(((t,e)=>t.tran.z===e.tran.z?0:t.tran.z>e.tran.z?1:-1)),t.forEach((t=>{this.element.appendChild(t.element)})),this}},2340:(t,e,n)=>{const r=n(29032),s=function(t){r.call(this,t),t.classList.add("affine-control")};t.exports=s;const o=s.prototype;o.isControlComponent=!0,Object.assign(o,r.prototype)},93002:t=>{t.exports=t=>e=>new t(e)},41896:t=>{t.exports=function(t){for(;this.element.firstChild;)this.element.removeChild(this.element.lastChild);if("string"==typeof t)this.element.innerHTML=t;else if("object"==typeof t){if(!t.nodeType)throw new Error("Invalid content type.");this.element.appendChild(t)}return this}},79138:(t,e,n)=>{const r=n(2340),s=function(t){const e=document.createElement("div");r.call(this,e),this.html(t)};t.exports=s;const o=s.prototype;o.isCustomControl=!0,Object.assign(o,r.prototype),s.create=n(93002)(s),o.html=n(41896)},15040:t=>{t.exports=function(){return this.at(this.endpoint)}},14332:t=>{t.exports=function(){return this.at(this.startpoint)}},3828:t=>{t.exports=t=>e=>new t(e)},55010:(t,e,n)=>{const r=n(89810),s=n(35805);t.exports=t=>{const e={width:1,style:"solid",color:"black"};if(!t)return e;if("string"==typeof t){const e=s.parse(t);return{width:r(e.width),style:e.style,color:e.color}}switch(typeof(t=Object.assign({},t)).width){case"string":t.width=r(t.width);break;case"number":break;default:t.width=e.width}return"string"==typeof t.style||(t.style=e.style),"string"==typeof t.color||(t.color=e.color),t}},35805:(t,e)=>{const n=/(\d+.?\d*)(\w{2,4})/i,r=["none","hidden","dotted","dashed","solid","double","groove","ridge","inset","outset"];e.parse=t=>{const e=t.trim().split(" "),s={width:"1px",style:"solid",color:"black"};for(;e.length;){const t=e.pop().trim();n.test(t)?s.width=t:r.indexOf(t)>-1?s.style=t:s.color=t}return s},e.stringify=t=>t.width+"px "+t.style+" "+t.color},62781:(t,e,n)=>{const r=n(67441);t.exports=function(){const t={a:1,b:0,x:0,y:0,z:Math.min(this.startpoint.z,this.endpoint.z),w:Math.abs(this.endpoint.x-this.startpoint.x),h:this.border.width,d:Math.abs(this.endpoint.z-this.startpoint.z)};return new r(this,t)}},34110:t=>{t.exports=function(){const t=this.at(this.startpoint),e=this.at(this.endpoint);return t.getDistanceTo(e)}},65282:(t,e,n)=>{const r=n(29032),s=n(35805),o=n(55010),i=function(t){t=o(t);const e=document.createElement("div");e.style.borderTop=s.stringify(t),this.border=t,r.call(this,e),e.classList.add("affine-edge"),this.setSize({w:100,h:t.width}),this.startpoint={x:0,y:0,z:0},this.endpoint={x:100,y:0,z:0}};t.exports=i;const a=i.prototype;a.isEdge=!0,Object.assign(a,r.prototype),i.create=n(3828)(i),a.getBoundingBox=n(62781),a.atStart=n(14332),a.atEnd=n(15040),a.getLength=n(34110),a.renderTransform=n(1721),a.setPoints=n(40496),a.trimPoints=n(37458)},1721:(t,e,n)=>{const r=n(72236);t.exports=function(){r(this.element,this.tran)}},40496:(t,e,n)=>{const r=n(84373),s=r.point2,o=r.point3,i=r.vec2;t.exports=function(t,e){t.transitRaw&&(t=t.transitRaw(this)),e.transitRaw&&(e=e.transitRaw(this));const n=o.distance(t,e),r=this.border.width,a={w:n,h:r};this.setSize(a);const c=i.norm(s.difference(e,t)),h=e.z-t.z;this.startpoint={x:0,y:0,z:0},this.endpoint={x:c,y:0,z:h};const p={x:0,y:r/2,z:0},u={x:c,y:r/2,z:0};return e.z=t.z,this.match({sources:[p,u],targets:[t,e],estimator:"TR"}),this}},37458:t=>{t.exports=function(t,e,n,r){r||(r=n);const s=t.getVectorTo(e),o=t.polarOffset(n,s),i=e.polarOffset(r,s.negate());return this.setPoints(o,i),this}},8782:(t,e,n)=>{const r=n(27390);t.exports=function(t,e,n){const s=this.size,o=t*s.w,i=e*s.h;let a=0;return n&&"number"==typeof n&&(a=n*s.h),new r(this,{x:o,y:i,z:a})}},95371:(t,e,n)=>{const r=n(16289);t.exports=function(){return new r(this,this.size.h)}},72711:(t,e,n)=>{const r=n(53744);t.exports=function(){return new r(this,{w:this.size.w,h:this.size.h,d:0})}},48485:(t,e,n)=>{const r=n(16289);t.exports=function(){return new r(this,this.size.w)}},29032:(t,e,n)=>{const r=n(75955),s=function(t){if(!t)throw new Error("Element does not exist");r.call(this,t),t.classList.add("affine-frame"),this.setSize({width:256,height:256})};t.exports=s;const o=s.prototype;o.isFrameComponent=!0,Object.assign(o,r.prototype),o.atNorm=n(8782),o.getSize=n(72711),o.getWidth=n(48485),o.getHeight=n(95371),o.normAt=n(41256),o.getNormalizedPoint=o.atNorm,o.matchPixelSize=n(77218),o.matchSize=n(24506),o.resizeTo=n(84509),o.setHeight=n(18516),o.setSize=n(83747),o.setWidth=n(72715),o.transformToFill=n(13098),o.transformToFit=n(11574)},77218:t=>{t.exports=function(t){const e=t.getSize().size;return this.setSize(e),this}},24506:t=>{t.exports=function(t){const e=t.getSize();return this.setSize(e),this}},41256:t=>{t.exports=function(t,e){"object"==typeof t&&(t.transitRaw&&(t=t.transitRaw(this)),e=t.y,t=t.x);const n=this.size;return{rx:0===n.w?0:t/n.w,ry:0===n.h?0:e/n.h}}},84509:(t,e,n)=>{const r=n(84373),s=r.point3,o=r.vec3,i=r.plane3;t.exports=function(t,e){e||(e=this.atAnchor());const n=this.at(e).point,r=n.x/this.size.w,a=n.y/this.size.h,c=this.anchor,h=c.x/this.size.w,p=c.y/this.size.h;this.setSize(t);const u={x:h*this.size.w,y:p*this.size.h,z:c.z};this.anchor=u;const l={x:r*this.size.w,y:a*this.size.h,z:n.z},x=s.diff(l,n),f=o.transitFrom(x,this.tran);return this.tran=i.translateBy(this.tran,f),this.renderTransform(),this}},18516:t=>{t.exports=function(t,e){return t.transitRaw&&(t=t.transitRaw(this)),this.resizeTo({w:this.size.w,h:t},e),this}},83747:(t,e,n)=>{const r=n(89810);t.exports=function(t,e){let n=0,s=0;if("number"==typeof t)n=t,s="number"==typeof e?e:t;else if("object"==typeof t){if(t.transitRaw&&(t=t.transitRaw(this)),"w"in t)n=t.w;else{if(!("width"in t))throw new Error("Invalid width: "+t.width);n=t.width}if("h"in t)s=t.h;else{if(!("height"in t))throw new Error("Invalid height: "+t.height);s=t.height}}return"string"==typeof n&&(n=r(n)),"string"==typeof s&&(s=r(s)),this.size={w:n,h:s,d:0},this.element.style.width=this.size.w+"px",this.element.style.height=this.size.h+"px",this}},72715:t=>{t.exports=function(t,e){return t.transitRaw&&(t=t.transitRaw(this)),this.resizeTo({w:t,h:this.size.h},e),this}},13098:t=>{t.exports=function(t,e){const n=this.getSize().getRaw();return n.w>=n.h?this.match({source:[this.atTopMid(),this.atBottomMid()],target:[t.atNorm(.5,0),t.atNorm(.5,1)]}):this.match({source:[this.atMidLeft(),this.atMidRight()],target:[t.atNorm(0,.5),t.atNorm(1,.5)]}),e||(e=1),this.scaleBy(1/e,this.atCenter()),this}},11574:t=>{t.exports=function(t,e){const n=this.getSize().getRaw();return n.w>=n.h?this.match({source:[this.atMidLeft(),this.atMidRight()],target:[t.atNorm(0,.5),t.atNorm(1,.5)]}):this.match({source:[this.atTopMid(),this.atBottomMid()],target:[t.atNorm(.5,0),t.atNorm(.5,1)]}),e||(e=1),this.scaleBy(1/e,this.atCenter()),this}},89046:t=>{t.exports=t=>()=>{const e=document.createElement("div");return new t(e)}},45460:(t,e,n)=>{const r=n(67610),s=n(2815),o=function(t){r.call(this,t),s.call(this),t.classList.add("affine-group")};t.exports=o;const i=o.prototype;i.isGroup=!0,Object.assign(i,r.prototype),Object.assign(i,s.prototype),o.create=n(89046)(o)},54511:t=>{t.exports=function(){return this.viewport.atAnchor()}},4613:(t,e,n)=>{t.exports=n(45213)},30846:(t,e,n)=>{const r=n(84373).plane3;t.exports=function(){const t=this.tran,e=this.getChildren();for(let n=0;n<e.length;n+=1){const s=e[n];s.tran=r.compose(t,s.tran)}this.tran=r.IDENTITY,this.renderTransform();for(let t=0;t<e.length;t+=1)e[t].renderTransform();return this}},153:(t,e,n)=>{t.exports=n(52137)},67223:(t,e,n)=>{t.exports=n(61705)},13025:(t,e,n)=>{const r=n(37720),s=n(32166),o=function(t){this.viewport=t;const e=document.createElement("div");e.className="affine-hyperspace",r.call(this,e),s.call(this)};t.exports=o;const i=o.prototype;i.isHyperspace=!0,Object.assign(i,r.prototype),Object.assign(i,s.prototype),i.requestIdle=n(36472),i.atAnchor=n(54511),i.atNorm=n(4613),i.commit=n(30846),i.getBoundingBox=n(153),i.getBoundingCircle=n(67223),i.renderTransform=n(87072),i.scaleBy=n(77309),i.transformBy=n(92378),i.translateBy=n(8118)},87072:(t,e,n)=>{const r=n(72236),s=n(84373).plane3;t.exports=function(){const t=this.tran;if(!s.validate(t))throw new Error("Invalid hyperspace transform: "+t);return r(this.element,t),this}},36472:t=>{t.exports=function(){return this.viewport.requestIdle(),this}},77309:(t,e,n)=>{const r=n(84373);t.exports=function(t,e){e.transitRaw&&(e=e.transitRaw(this));const n=r.point3.transitFrom(e,this.tran),s=r.plane3.scaleBy(this.tran,n,t);return this.tran=s,this.renderTransform(),this}},92378:(t,e,n)=>{const r=n(84373).plane3;t.exports=function(t,e){t.transitRaw&&(t=t.transitRaw(this)),e||(e={x:0,y:0,z:0}),e.transitRaw&&(e=e.transitRaw(this));const n=((t,e)=>{const n=e.x,s=e.y,o={a:1,b:0,x:n,y:s,z:0},i={a:1,b:0,x:-n,y:-s,z:0};return r.compose(o,r.compose(t,i))})(t,e);return this.tran=r.compose(n,this.tran),this.renderTransform(),this}},8118:(t,e,n)=>{const r=n(84373).plane3;t.exports=function(t){return t.transitRaw&&(t=t.transitRaw(this)),this.tran=r.translateBy(this.tran,t),this.renderTransform(),this}},72841:t=>{t.exports=function(t,e){if(this.interactions[t])throw new Error("The element already has interaction "+t);return this.interactions[t]=e,e.bind(),this}},85420:(t,e,n)=>{const r=n(95683);t.exports=function(t,e){const n=this.capturers[t];if(n)return e&&n.update(e),n;const s=r[t];if(!s)throw new Error("Unknown capturer: "+t);const o=new s(this,e);o.bind(),this.capturers[t]=o;const i=this.requestIdle.bind(this);switch(t){case"gesture":o.on("gestureend",i),o.on("gesturecancel",i);break;case"resize":o.on("resize",i);break;case"wheel":o.on("wheel",i)}return o}},24009:(t,e,n)=>{const r={mouse:n(17758)};t.exports=function(t,e){const n=this.converters[t];if(n)return n;const s=r[t];if(s){const n=new s(this,e);return this.converters[t]=n,n}throw new Error("Unknown converter: "+t)}},17758:(t,e,n)=>{const r=n(91604),s=n(15093),o=function(t){this.component=t,this.running=!1,this.handlers=null};t.exports=o;const i=o.prototype;i.start=function(){if(this.running)return;this.running=!0;const t=this.component.element;this.handlers=r(t)},i.stop=function(){if(this.running){this.running=!1;const t=this.component.element;s(t,this.handlers),this.handlers=null}}},91604:t=>{t.exports=t=>{let e=!1,n=null;const r=!0,s=!0,o=function(t){if(!e&&!t.defaultPrevented){e=!0,n=t.target;const o=document.createEvent("Event");o.initEvent("ratstart",r,s),o.target=n,o.pageX=t.pageX,o.pageY=t.pageY,!n.dispatchEvent(o)&&t.preventDefault()}},i=function(t){if(e&&!t.defaultPrevented){const e=document.createEvent("Event");e.initEvent("ratmove",r,s),e.target=n,e.pageX=t.pageX,e.pageY=t.pageY,!n.dispatchEvent(e)&&t.preventDefault()}},a=function(t){if(e&&!t.defaultPrevented){e=!1;const o=document.createEvent("Event");o.initEvent("ratend",r,s),o.target=n,o.pageX=t.pageX,o.pageY=t.pageY,!n.dispatchEvent(o)&&t.preventDefault(),n=null}},c=function(t){t.stopPropagation()};return t.addEventListener("mousedown",o),t.addEventListener("mousemove",i),t.addEventListener("mouseup",a),t.addEventListener("mouseleave",a),t.addEventListener("ratstart",c),t.addEventListener("ratmove",c),t.addEventListener("ratend",c),{onmousedown:o,onmousemove:i,onmouseup:a,onmouseleave:a,onratstart:c,onratmove:c,onratend:c}}},15093:t=>{t.exports=(t,e)=>{const n=e,r=t;r.removeEventListener("mousedown",n.onmousedown),r.removeEventListener("mousemove",n.onmousemove),r.removeEventListener("mouseup",n.onmouseup),r.removeEventListener("mouseleave",n.onmouseleave),r.removeEventListener("ratstart",n.onratstart),r.removeEventListener("ratmove",n.onratmove),r.removeEventListener("ratend",n.onratend)}},13402:t=>{t.exports=function(){throw new Error("InteractiveComponent subclass should implement component.focus method.")}},94813:t=>{t.exports=function(t){if(!1===t)return this.element.removeAttribute("tabindex"),this;t||(t={});let e=0;return"number"==typeof t.tabindex&&(e=Math.floor(t.tabindex),e<0&&(e=-1)),this.element.setAttribute("tabindex",e),this}},43982:t=>{t.exports=function(t){return this.capturers[t]||null}},90423:t=>{t.exports=function(t){return this.interactions[t]}},86580:t=>{t.exports=function(t){return!!this.capturers[t]}},84407:t=>{t.exports=function(t){return t in this.interactions}},2815:(t,e,n)=>{const r=function(){this.capturers={},this.converters={},this.interactions={}};t.exports=r;const s=r.prototype;s.isInteractiveComponent=!0,s.addInteraction=n(72841),s.capturer=n(85420),s.converter=n(24009),s.getCapturer=n(43982),s.getInteraction=n(90423),s.hasCapturer=n(86580),s.hasInteraction=n(84407),s.focus=n(13402),s.focusable=n(94813),s.removeAllInteractions=n(42385),s.removeInteraction=n(72739),s.setContentInput=n(54446),s.startCapturer=s.capturer,s.stopCapturer=n(15518),s.updateCapturer=s.capturer},42385:t=>{t.exports=function(){const t=Object.keys(this.interactions);for(let e=0;e<t.length;e+=1)this.removeInteraction(t[e]);return this}},72739:t=>{t.exports=function(t){const e=this.interactions[t];return e&&(e.unbind(),delete this.interactions[t]),this}},54446:t=>{const e=["pointer","wheel"];t.exports=function(t){const n=this.element.classList;if("boolean"==typeof t){if(t){const t=e.length;for(let r=0;r<t;r+=1)n.remove("affine-proxy-"+e[r])}else{const t=e.length;for(let r=0;r<t;r+=1)n.add("affine-proxy-"+e[r])}return this}const r=e.length,s=arguments.length;for(let t=0;t<r;t+=1){let r=!1;for(let n=0;n<s;n+=1)if(e[t]===arguments[n]){r=!0;break}r?n.remove("affine-proxy-"+e[t]):n.add("affine-proxy-"+e[t])}return this}},15518:t=>{t.exports=function(t){const e=this.capturers[t];return e&&(e.unbind(),delete this.capturers[t]),this}},55696:(t,e,n)=>{const r=n(79032);t.exports=function(t){if(!1===t)return this.removeInteraction("approach"),this;const e=new r(this,this,t);return this.addInteraction("approach",e),this}},64981:t=>{t.exports=t=>e=>{const n=document.createElement("div"),r=new t(n);return r.html(e),r}},38035:t=>{t.exports=function(){return this.removeAllInteractions(),this.capturer("gesture",{preventDefault:!0}),this}},2904:(t,e,n)=>{const r=n(34797);t.exports=function(t){let e=this.getInteraction("pinch");return!1===t?(e&&(e.disableTranslation(),e.hasAnyFreedom()||this.removeInteraction("pinch")),this):(e?e.enableTranslation():(e=new r(this,this),e.enableTranslation(),this.addInteraction("pinch",e)),this)}},48264:t=>{t.exports=function(t){t||(t={});let e=!1;"boolean"==typeof t.focusVisible&&(e=t.focusVisible);let n=!1;return"boolean"==typeof t.preventScroll&&(n=t.preventScroll),n||this.getViewport().translateTo(this.atAnchor()),this.element.focus({focusVisible:e,preventScroll:n}),this}},62280:(t,e,n)=>{const r=n(98976);t.exports=function(t){if(!1===t)return this.removeInteraction("hold"),this;const e=new r(this,this,t);return this.addInteraction("hold",e),this}},3954:t=>{t.exports=function(t){for(;this.element.firstChild;)this.element.removeChild(this.element.lastChild);if("string"==typeof t)this.element.innerHTML=t;else if("object"==typeof t){if(!t.nodeType)throw new Error("Invalid content type.");this.element.appendChild(t)}return this}},22964:(t,e,n)=>{const r=n(29032),s=n(2815),o=n(32166),i=function(t){r.call(this,t),s.call(this),o.call(this),t.classList.add("affine-item"),this.mass=1/0};t.exports=i;const a=i.prototype;a.isItem=!0,Object.assign(a,r.prototype),Object.assign(a,s.prototype),Object.assign(a,o.prototype),i.create=n(64981)(i),a.focus=n(48264),a.approachable=n(55696),a.dilatable=n(1930),a.disable=n(38035),a.draggable=n(2904),a.holdable=n(62280),a.pannable=a.draggable,a.translatable=a.draggable,a.resizable=n(43295),a.rotatable=n(47176),a.rotateable=a.rotatable,a.scalable=a.dilatable,a.slidable=n(43323),a.slideable=a.slidable,a.tappable=n(11680),a.html=n(3954)},43295:()=>{},47176:(t,e,n)=>{const r=n(34797);t.exports=function(t){let e=this.getInteraction("pinch");return!1===t?(e&&(e.disableRotation(),e.hasAnyFreedom()||this.removeInteraction("pinch")),this):(t||(t={}),e?e.enableRotation(t.pivot):(e=new r(this,this),e.enableRotation(t.pivot),this.addInteraction("pinch",e)),this)}},1930:(t,e,n)=>{const r=n(34797);t.exports=function(t){let e=this.getInteraction("pinch");return!1===t?(e&&(e.disableDilation(),e.hasAnyFreedom()||this.removeInteraction("pinch")),this):(t||(t={}),e?e.enableDilation(t.pivot):(e=new r(this,this),e.enableDilation(t.pivot),this.addInteraction("pinch",e)),this)}},43323:(t,e,n)=>{const r=n(76011);t.exports=function(t){if(!1===t)return this.removeInteraction("slide"),this;this.removeInteraction("pinch");const e=new r(this,this,t);return this.addInteraction("slide",e),this}},11680:(t,e,n)=>{const r=n(26673);t.exports=function(t){if(!1===t)return this.removeInteraction("tap"),this;if(this.hasInteraction("tap"))return this.interactions.tap.update(t),this;const e=new r(this,this,t);return this.addInteraction("tap",e),this}},43278:t=>{t.exports=t=>(e,n)=>new t(e,n)},77238:(t,e,n)=>{const r=n(40160);t.exports=function(){const t=this.size.w/2;return new r(this,{x:t,y:t,z:0,r:t})}},25597:(t,e,n)=>{const r=n(16289);t.exports=function(){return new r(this,this.size.w)}},31736:(t,e,n)=>{const r=n(16289);t.exports=function(){const t=this.size.w/2;return new r(this,t)}},4568:(t,e,n)=>{const r=n(22964),s=function(t,e){const n=document.createElement("div");e&&(n.style.backgroundColor=e),n.style.borderRadius=t+"px",r.call(this,n),n.classList.add("affine-circle"),n.classList.add("affine-node"),this.setAnchor({x:t,y:t,z:0}),this.setSize({w:2*t,h:2*t})};t.exports=s;const o=s.prototype;o.isCircle=!0,Object.assign(o,r.prototype),s.create=n(43278)(s),o.getBoundingCircle=n(77238),o.getDiameter=n(25597),o.getRadius=n(31736)},75939:t=>{t.exports=function(t,e){return this.element.appendChild(t.element),e&&(e.transitRaw&&(e=e.transitRaw(this)),t.translateTo(e)),this}},45213:t=>{t.exports=function(t,e){return this.getBoundingBox().atNorm(t,e)}},79688:t=>{t.exports=t=>function(){const e=document.createElement("div");return e.className="affine-plane",new t(e)}},52137:(t,e,n)=>{const r=n(67441);t.exports=function(t){t||(t=this);const e=this.getDescendants(),n=[];for(let t=0;t<e.length;t+=1)e[t].isBlockComponent&&n.push(e[t].getBoundingBox());return r.fromBoxes(t,n)}},61705:(t,e,n)=>{const r=n(40160);t.exports=function(){const t=this.getDescendants(),e=[];for(let n=0;n<t.length;n+=1)t[n].isBlockComponent&&(e.push(t[n].atNorm(0,0)),e.push(t[n].atNorm(0,1)),e.push(t[n].atNorm(1,0)),e.push(t[n].atNorm(1,1)));return r.fromPoints(this,e)}},67610:(t,e,n)=>{const r=n(49163),s=function(){const t=document.createElement("div");t.className="affine-plane",r.call(this,t)};t.exports=s;const o=s.prototype;o.isPlane=!0,Object.assign(o,r.prototype),s.create=n(79688)(s),o.addChild=n(75939),o.appendChild=o.addChild,o.atNorm=n(45213),o.getBoundingBox=n(52137),o.getBoundingCircle=n(61705)},20308:(t,e,n)=>{const r=n(27390),s=n(84373).point2;t.exports=function(t){let e;if(t)if(t.transitRaw)e=t.transitRaw(this);else{if(!s.validate(t))throw new Error("Invalid alternative anchor point: "+t);e=t}else e=this.anchor;return new r(this,e)}},72236:t=>{t.exports=function(t,e){const n=e.a.toFixed(8),r=e.b.toFixed(8),s=(-e.b).toFixed(8),o=e.x.toFixed(8),i=e.y.toFixed(8);t.style.transform="matrix("+n+","+r+","+s+","+n+","+o+","+i+")"}},67864:t=>{t.exports=function(t,e){t.style.transformOrigin=e.x+"px "+e.y+"px"}},78026:(t,e,n)=>{const r=n(13853);t.exports=function(t,e){if("number"!=typeof t)throw new Error("Invalid theta angle");return"number"!=typeof e&&(e=Math.PI/2),r.fromSpherical(this,t,e)}},9750:t=>{t.exports=function(t){return t.atAnchor?this.atAnchor().getDistanceTo(t.atAnchor()):this.atAnchor().getDistanceTo(t.at(0,0))}},1490:(t,e,n)=>{const r=n(84373).point3,s=n(27390);t.exports=function(){const t=this.getParent();if(t){const e=r.transitFrom(this.anchor,this.tran);return new s(t,e)}return null}},55777:(t,e,n)=>{const r=n(65057);t.exports=function(){return new r(this,1)}},9703:t=>{t.exports=function(t){return t.atAnchor?this.atAnchor().getVectorTo(t.atAnchor()):this.atAnchor().getVectorTo(t.at(0,0))}},49163:(t,e,n)=>{const r=n(37720),s=function(t){if(!t)throw new Error("Element does not exist");r.call(this,t),this.anchor={x:0,y:0,z:0}};t.exports=s;const o=s.prototype;o.isTransformerComponent=!0,Object.assign(o,r.prototype),o.atAnchor=n(20308),o.getDirection=n(78026),o.getDistanceTo=n(9750),o.getPosition=n(1490),o.getRotation=o.getDirection,o.getScale=n(55777),o.getVectorTo=n(9703),o.match=n(24950),o.matchBasis=n(47832),o.matchPoint=n(2973),o.moveTo=n(12682),o.renderTransform=n(77937),o.rotateBy=n(15050),o.rotateByDegrees=n(89059),o.scaleBy=n(32093),o.setAnchor=n(28969),o.setBasis=n(34832),o.setOrientation=n(50154),o.setScale=n(15112),o.snapGrid=n(95155),o.snapPixels=n(73349),o.transformBy=n(95550),o.transformTo=o.setBasis,o.translateBy=n(81914),o.translateTo=o.moveTo},24950:(t,e,n)=>{const r=n(84373).dir2,s=n(9876);t.exports=function(t){if(t.source&&!t.sources&&(t.sources=t.source),t.target&&!t.targets&&(t.targets=t.target),!t.sources)throw new Error("Missing parameter: sources");if(!t.targets)throw new Error("Missing parameter: targets");Array.isArray(t.sources)||(t.sources=[t.sources]),Array.isArray(t.targets)||(t.targets=[t.targets]);const e=[];for(let n=0;n<t.sources.length;n+=1){const r=t.sources[n];r.transitRaw?e.push(r.transitRaw(this)):e.push({x:r.x,y:r.y,z:r.z||0})}const n=[];for(let e=0;e<t.targets.length;e+=1){const r=t.targets[e];r.transitRaw?n.push(r.transitRaw(this)):n.push({x:r.x,y:r.y,z:r.z||0})}let o=null;if(t.pivot){const e=t.pivot;if(e.transitRaw)o=e.transitRaw(this);else{const t=e.z||0;o={x:e.x,y:e.y,z:t}}}let i=null;if(t.angle){const e=t.angle;if(e.basis){const t=e.basis.getTransitionTo(this),n=r.transitFrom(e.dir,t);i=r.toAngle(n)}else i=e}let a="TSR";t.estimator&&(a=t.estimator);const c=s.estimate({estimator:a,domain:e,range:n,center:o,angle:i});let h=0;if(a.indexOf("T")>=0){const t=Math.min(e.length,n.length);let r=0,s=0;for(let o=0;o<t;o+=1)r+=e[o].z,s+=n[o].z;t>0&&(h=s/t-r/t)}return c.z=h,this.transformBy(c,{x:0,y:0}),this}},47832:(t,e,n)=>{const r=n(84373).plane3;t.exports=function(t,e){t.transitRaw&&(t=t.transitRaw(this)),e.transitRaw&&(e=e.transitRa