tapspace
Version:
A zoomable user interface lib for web apps
1 lines • 216 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),g=i(d),w=a(b,g),v=p.estimate({estimator:b.type,domain:y,range:m,center:b.pivot,angle:b.angle});v.z=0;const z=o(v,w),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,g),transform:new c(x,e.totalTransform),transformOrigin:new h(x,{x:0,y:0}),delta:new c(x,z),deltaOrigin:new h(x,w)})}},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(45632).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(45632).findAffineAncestor,s=n(45737);t.exports=t=>function(e){if(!s(e))return;let n;t.options.preventDefault&&e.preventDefault();const o=t.component.getRoot();n=o.atPage?o.atPage(e.pageX,e.pageY):o.at(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)},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}},58987:t=>{t.exports=function(t,e){return this.element.appendChild(t.element),e&&t.translateTo(e),this}},33662:t=>{t.exports=function(t){const e=this.element.classList;return e.add.apply(e,arguments),this}},31792:(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)}},26003: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}},65029:t=>{t.exports=t=>t&&t.affine},74845: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}},70514:t=>{t.exports=function(){const t=[];let e=this.element.parentElement;for(;e&&e.affine;)t.push(e.affine),e=e.parentElement;return t}},63341:(t,e,n)=>{const r=n(19268);t.exports=function(){return new r(this,{a:1,b:0,x:0,y:0,z:0})}},85820: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}},27322: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}},46833:t=>{t.exports=function(){return this.element}},38172:t=>{t.exports=function(){return this.getDescendants().filter((t=>t.isLeaf()))}},8247:(t,e,n)=>{const r=n(52568);t.exports=function(){return new r(this,{a:1,b:0})}},39754:t=>{t.exports=function(){const t=this.element.parentElement;return t&&t.affine?t.affine:null}},38047:t=>{t.exports=function(){let t=this,e=this.element.parentElement;for(;e&&e.affine;)t=e.affine,e=e.parentElement;return t}},28574:(t,e,n)=>{const r=n(84373).plane3;t.exports=function(t){const e=this.getTransitionTo(t);return r.invert(e)}},10938:(t,e,n)=>{const r=n(84373).plane3;t.exports=function(t){if(t===this)return r.IDENTITY;const e=this.findCommonAncestor(t);if(null===e)throw new Error("Transition between the planes does not exist because they are not connected.");const n=e.element;let s=this.element,o=r.IDENTITY;for(;s!==n;)o=r.compose(s.affine.tran,o),s=s.parentElement;const i=o;for(s=t.element,o=r.IDENTITY;s!==n;)o=r.compose(s.affine.tran,o),s=s.parentElement;const a=o;return r.transitTo(i,a)}},29448:(t,e,n)=>{const r=n(84373).plane3;t.exports=function(){return r.copy(this.tran)}},39124:(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)}},60186:(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})}},61688:t=>{t.exports=function(){const t=this.getRoot();return t.atCamera?t:null}},45632:(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.tran={a:1,b:0,x:0,y:0,z:0}};t.exports=s;const o=s.prototype;o.isBasisComponent=!0,r(o),s.findAffineAncestor=n(26003),s.isAffine=n(65029),o.addChild=n(58987),o.addClass=n(33662),o.appendChild=o.addChild,o.at=n(31792),o.findCommonAncestor=n(74845),o.getAncestors=n(70514),o.getBasis=n(63341),o.getChildren=n(85820),o.getDescendants=n(27322),o.getElement=n(46833),o.getLeaves=n(38172),o.getOrientation=n(8247),o.getParent=n(39754),o.getPoint=o.at,o.getRoot=n(38047),o.getTransitionFrom=n(28574),o.getTransitionTo=n(10938),o.getTransitionToParent=n(29448),o.getTransitionToParentOf=n(39124),o.getVector=n(60186),o.getViewport=n(61688),o.isLeaf=n(37778),o.isPlanar=n(39023),o.isRoot=n(1827),o.prependChild=n(46087),o.remove=n(42636),o.removeChild=n(23121),o.removeClass=n(344),o.replaceChild=n(91134),o.replaceParent=n(74093),o.setId=n(36891),o.setParent=n(77333)},37778:t=>{t.exports=function(){return 0===this.getChildren().length}},39023:t=>{t.exports=function(){let t=this.element.parentElement;for(;t&&t.affine;){if(t.affine.isPlane)return!0;t=t.parentElement}return!1}},1827:t=>{t.exports=function(){const t=this.element.parentElement;return!t||!t.affine}},46087:t=>{t.exports=function(t,e){return this.element.prepend(t.element),e&&t.translateTo(e),this}},42636:t=>{t.exports=function(){const t=this.element,e=t.parentElement;return e&&e.removeChild(t),this}},23121:t=>{t.exports=function(t){let e;return e=t.nodeType?t:t.element,this.element.removeChild(e),this}},344:t=>{t.exports=function(t){return this.element.classList.remove(t),this}},91134:t=>{t.exports=function(t,e){if(!t.isBasisComponent)throw new Error("Cannot replace non-affine element.");if(!e.isBasisComponent)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}},74093:(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}},36891:t=>{t.exports=function(t){return this.element.id=t,this}},77333: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}},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)}},51223:(t,e,n)=>{const r=n(19204);t.exports=function(){const t=this.getSize().getRaw(),e=t.w/2,n=t.h/2,s=t.d/2,o=Math.sqrt(e*e+n*n);return new r(this,{x:e,y:n,z:s,r:o})}},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.getBoundingSphere=n(51223),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}},35282:t=>{t.exports=t=>(e,n)=>new t(e,n)},41866:(t,e,n)=>{const r=n(16289);t.exports=function(){return new r(this,this.size.w)}},70184:(t,e,n)=>{const r=n(16289);t.exports=function(){const t=this.size.w/2;return new r(this,t)}},51643:(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"),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(35282)(s),o.getDiameter=n(41866),o.getRadius=n(70184)},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},42306:(t,e,n)=>{const r=n(84373),s=r.point3,o=r.vec3;t.exports=function(t,e){const n=t.tran,r=n.a,i=n.b,a=Math.sqrt(r*r+i*i),c=t.startpoint,h=t.endpoint,p=s.delta(c,h),u=s.delta(c,e),l=o.unit(p),x=o.unit(o.cross(p,u)),f=o.unit(o.cross(l,x)),d=n.x,y=n.y,m=-n.z,b=(r*l.x-i*l.y).toFixed(8),g=(i*l.x+r*l.y).toFixed(8),w=(-l.z*a).toFixed(8),v=(r*x.x-i*x.y).toFixed(8),z=(i*x.x+r*x.y).toFixed(8),T=(-x.z*a).toFixed(8),M=(r*f.x-i*f.y).toFixed(8),R=(i*f.x+r*f.y).toFixed(8),E=(-f.z*a).toFixed(8),B=d.toFixed(8),I=y.toFixed(8),C=m.toFixed(8);t.element.style.transform="matrix3d("+b+","+g+","+w+",0,"+v+","+z+","+T+",0,"+M+","+R+","+E+",0,"+B+","+I+","+C+",1)"}},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(42306),s=n(72236),o=n(84373).point3;t.exports=function(){if(this.isPlanar())s(this.element,this.tran);else{const t=o.offset(this.startpoint,0,0,-1);r(this,t)}}},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)}},20653:t=>{t.exports=function(){return this.mass}},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}),this.mass=0};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.getMass=n(20653),o.isSolid=n(49399),o.matchPixelSize=n(77218),o.matchSize=n(24506),o.resizeTo=n(84509),o.setHeight=n(18516),o.setSize=n(83747),o.setSolidity=n(2363),o.setMass=n(5028),o.setWidth=n(72715)},49399:t=>{t.exports=function(){return this.mass>0}},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}},5028:t=>{t.exports=function(t){return isFinite(t)?this.mass=Math.abs(t):this.mass=1/0,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}},2363:t=>{t.exports=function(t){return this.mass=t?1/0:0,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}},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)},4613:(t,e,n)=>{t.exports=n(38091)},153:(t,e,n)=>{t.exports=n(92412)},55193:(t,e,n)=>{t.exports=n(70804)},13025:(t,e,n)=>{const r=n(45632),s=function(){const t=document.createElement("div");t.className="affine-hyperspace",r.call(this,t)};t.exports=s;const o=s.prototype;o.isHyperspace=!0,Object.assign(o,r.prototype),o.atNorm=n(4613),o.getBoundingBox=n(153),o.getBoundingSphere=n(55193),o.renderTransform=n(87072),o.scaleBy=n(77309),o.transformBy=n(92378),o.translateBy=n(8118)},87072:(t,e,n)=>{const r=n(53635),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}},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),s=this.getChildren();for(let t=0;t<s.length;t+=1){const e=s[t];e.tran=r.compose(n,e.tran)}for(let t=0;t<s.length;t+=1)s[t].renderTransform();return this}},8118:(t,e,n)=>{const r=n(84373).plane3;t.exports=function(t){t.transitRaw&&(t=t.transitRaw(this));const e=this.getChildren(),n=e.length;for(let s=0;s<n;s+=1){const n=e[s];n.tran=r.translateBy(n.tran,t)}for(let t=0;t<n;t+=1)e[t].renderTransform();return 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);switch(o.bind(),this.capturers[t]=o,t){case"gesture":o.on("gestureend",this.requestIdle),o.on("gesturecancel",this.requestIdle);break;case"resize":o.on("resize",this.requestIdle);break;case"wheel":o.on("wheel",this.requestIdle)}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=n(42189).P2,s=function(){this.capturers={},this.converters={},this.interactions={};const t=this;this.requestIdle=r(500,(()=>{t.emit("idle")}),{noLeading:!0})};t.exports=s;const o=s.prototype;o.isInteractiveComponent=!0,o.addInteraction=n(72841),o.capturer=n(85420),o.converter=n(24009),o.getCapturer=n(43982),o.getInteraction=n(90423),o.hasCapturer=n(86580),o.hasInteraction=n(84407),o.focus=n(13402),o.focusable=n(94813),o.removeAllInteractions=n(42385),o.removeInteraction=n(72739),o.setContentInput=n(54446),o.startCapturer=o.capturer,o.stopCapturer=n(15518),o.updateCapturer=o.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=function(t){r.call(this,t),s.call(this),t.classList.add("affine-item"),this.mass=1/0};t.exports=o;const i=o.prototype;i.isItem=!0,Object.assign(i,r.prototype),Object.assign(i,s.prototype),o.create=n(64981)(o),i.focus=n(48264),i.approachable=n(55696),i.dilatable=n(1930),i.disable=n(38035),i.draggable=n(2904),i.holdable=n(62280),i.pannable=i.draggable,i.translatable=i.draggable,i.resizable=n(43295),i.rotatable=n(47176),i.rotateable=i.rotatable,i.scalable=i.dilatable,i.slidable=n(43323),i.slideable=i.slidable,i.tappable=n(11680),i.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;const e=new r(this,this,t);return this.addInteraction("tap",e),this}},75939:t=>{t.exports=function(t,e){return this.element.appendChild(t.element),e&&(e.transitRaw&&(e=e.transitRaw(this)),e.z=0,t.translateTo(e)),this}},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)}},66403:(t,e,n)=>{const r=n(19204);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.getBoundingBox=n(52137),o.getBoundingSphere=n(66403)},38091:t=>{t.exports=function(t,e,n){return this.getBoundingBox().atNorm(t,e,n)}},46885:t=>{t.exports=t=>function(){return new t}},92412:(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)}},70804:(t,e,n)=>{const r=n(19204);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)}},1039:t=>{t.exports=function(t,e,n){return this.getBoundingBox().getSize()}},73201:(t,e,n)=>{const r=n(49163),s=function(){const t=document.createElement("div");t.className="affine-space",r.call(this,t)};t.exports=s;const o=s.prototype;o.isSpace=!0,Object.assign(o,r.prototype),s.create=n(46885)(s),o.atNorm=n(38091),o.getBoundingBox=n(92412),o.getBoundingSphere=n(70804),o.getSize=n(1039)},57729:(t,e,n)=>{const r=n(27345);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}},59976:(t,e,n)=>{const r=n(27345);t.exports=function(t){if(this.ontransitionend)return this;const e=this.element,n=this;return this.ontransitionend=t=>{e.style.removeProperty("transition"),n.ontransitionend&&(n.removeEventListener("transitionend",n.ontransitionend),n.ontransitionend=null)},e.addEventListener("transitionend",this.ontransitionend),r(e,t),this}},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+")"}},53635: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),a=(-e.z).toFixed(8),c=Math.sqrt(e.a*e.a+e.b*e.b).toFixed(8);t.style.transform="matrix3d("+n+","+r+",0,0,"+s+","+n+",0,0,0,0,"+c+",0,"+o+","+i+","+a+",1)"}},67864:t=>{t.exports=function(t,e){t.style.transformOrigin=e.x+"px "+e.y+"px"}},27345:t=>{t.exports=function(t,e){e=Object.assign({duration:"200ms",easing:"ease",delay:"0ms"},e),t.style.transition="transform "+e.duration+" "+e.easing+" "+e.delay}},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(45632),s=function(t){if(!t)throw new Error("Element does not exist");r.call(this,t),this.anchor={x:0,y:0,z:0},this.ontransitionend=null};t.exports=s;const o=s.prototype;o.isTransformerComponent=!0,Object.assign(o,r.prototype),o.animate=n(57729),o.animateOnce=n(59976),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.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),this}},2973:t=>{t.exports=function(t,e){const n=t.getVectorTo(e);return this.translateBy(n),this}},48889:(t,e,n)=>{const r=n(84373).plane3;t.exports=(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(i,r.compose(t,o))}},77937:(t,e,n)=>{const r=n(72236),s=n(53635),o=n(48889),i=n(84373).plane3;t.exports=function(t){let e=this.tran;if(!i.validate(e))throw new Error("Invalid plane transform: "+e);t&&(e=t),e=o(e,this.anchor),this.isPlanar()?r(this.element,e):s(this.element,e)}},15050:(t,e,n)=>{const r=n(84373);t.exports=function(t,e){const n=this.atAnchor(e),s=r.point3.transitFrom(n.point,this.tran),o=r.plane3.rotateBy(this.tran,s,t);return this.tran=o,this.renderTransform(),this}},89059:t=>{const e=Math.PI/180;t.exports=function(t,n){const r=t*e;return this.rotateBy(r,n)}},32093:(t,e,n)=>{const r=n(84373);t.exports=function(t,e){e=this.atAnchor(e);const n=r.point3.transitFrom(e.point,this.tran),s=r.plane3.scaleBy(this.tran,n,t);return this.tran=s,this.renderTransform(),this}},28969:(t,e,n)=>{const r=n(67864);t.exports=function(t,e){if("object"==typeof t)t.transitRaw&&(t=t.transitRaw(this));else{if("number"!=typeof t||"number"!=typeof e)throw new Error("Invalid point");t={x:t,y:e}}return this.anchor={x:t.x,y:t.y,z:0},r(this.element,this.anchor),this}},34832:t=>{t.exports=function(t){return t.getBasis&&(t=t.getBasis()),t.transitRawOuter&&(t=t.transitRawOuter(this)),this.tran=t,this.renderTransform(),this}},50154:t=>{t.exports=function(t,e){t.transitRawOuter&&(t=t.transitRawOuter(this));const n=Math.atan2(this.tran.b,this.tran.a),r=Math.atan2(t.b,t.a);return this.rotateBy(r-n,e),this}},15112:(t,e,n)=>{const r=n(84373).plane3;t.exports=function(t,e){const n=typeof t;if("object"===n){if(!t.transitRaw)throw new Error("Invalid scale");t=t.transitRawOuter(this)}else if("number"!==n)throw new Error("Invalid scale");const s=r.getScale(this.tran);if(0===s)this.tran={a:t,b:0,x:this.tran.x,y:this.tran.y,z:this.tran.z},this.renderTransform();else{const n=t/s;this.scaleBy(n,e)}return this}},95155:t=>{t.exports=function(t,e){throw new Error("not implemented")}},73349:(t,e,n)=>{const r=n(84373).plane3,s=Math.abs;t.exports=function(t){t=this.atAnchor(t);let e=this.tran;if(s(e.a)<.02||s(e.b)<.02){const n=t.transitRaw(this.getParent());e=r.rotateToOrtho(e,n),e={a:e.a,b:e.b,x:Math.roun