@excalidraw/element 0.18.0-ab0255f → 0.18.0-abeeaeb

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/dev/index.js +1 -0
  2. package/dist/dev/index.js.map +2 -2
  3. package/dist/prod/index.js +1 -1
  4. package/dist/types/common/src/colors.d.ts +5 -7
  5. package/dist/types/element/src/sortElements.d.ts +10 -0
  6. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +15 -6
  7. package/dist/types/excalidraw/actions/actionBoundText.d.ts +10 -4
  8. package/dist/types/excalidraw/actions/actionCanvas.d.ts +35 -14
  9. package/dist/types/excalidraw/actions/actionClipboard.d.ts +10 -4
  10. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +5 -2
  11. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +15 -6
  12. package/dist/types/excalidraw/actions/actionDeselect.d.ts +5 -2
  13. package/dist/types/excalidraw/actions/actionElementLink.d.ts +5 -2
  14. package/dist/types/excalidraw/actions/actionElementLock.d.ts +10 -4
  15. package/dist/types/excalidraw/actions/actionExport.d.ts +10 -4
  16. package/dist/types/excalidraw/actions/actionFrame.d.ts +15 -6
  17. package/dist/types/excalidraw/actions/actionGroup.d.ts +11 -5
  18. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +5 -2
  19. package/dist/types/excalidraw/actions/actionLink.d.ts +5 -2
  20. package/dist/types/excalidraw/actions/actionMenu.d.ts +5 -2
  21. package/dist/types/excalidraw/actions/actionProperties.d.ts +10 -4
  22. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +5 -2
  23. package/dist/types/excalidraw/actions/actionStyles.d.ts +5 -2
  24. package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +5 -2
  25. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +5 -2
  26. package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +5 -2
  27. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +5 -2
  28. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +5 -2
  29. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +5 -2
  30. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +5 -2
  31. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +5 -2
  32. package/dist/types/excalidraw/appState.d.ts +5 -0
  33. package/dist/types/excalidraw/components/App.bucketFill.d.ts +14 -0
  34. package/dist/types/excalidraw/components/App.cursor.d.ts +2 -3
  35. package/dist/types/excalidraw/components/App.d.ts +12 -5
  36. package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +6 -2
  37. package/dist/types/excalidraw/components/ColorPicker/CustomColorList.d.ts +3 -1
  38. package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +2 -1
  39. package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +4 -2
  40. package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +4 -2
  41. package/dist/types/excalidraw/components/ColorPicker/TopPicks.d.ts +8 -1
  42. package/dist/types/excalidraw/components/ColorPicker/topPicksDnD.d.ts +31 -0
  43. package/dist/types/excalidraw/components/LayerUI.d.ts +2 -1
  44. package/dist/types/excalidraw/components/UserList.d.ts +3 -2
  45. package/dist/types/excalidraw/components/ViewportStatusFrame/ViewportStatusFrame.d.ts +11 -0
  46. package/dist/types/excalidraw/components/icons.d.ts +3 -0
  47. package/dist/types/excalidraw/data/blob.d.ts +10 -4
  48. package/dist/types/excalidraw/data/json.d.ts +5 -2
  49. package/dist/types/excalidraw/lasso/utils.d.ts +2 -0
  50. package/dist/types/excalidraw/types.d.ts +47 -4
  51. package/dist/types/excalidraw/viewport.d.ts +5 -2
  52. package/package.json +4 -4
  53. package/dist/types/excalidraw/components/FollowMode/FollowMode.d.ts +0 -10
@@ -25,4 +25,4 @@ var Ju=Object.create;var Ua=Object.defineProperty;var em=Object.getOwnPropertyDe
25
25
  table, .gist { height: 100%; }
26
26
  .gist .gist-file { height: calc(100vh - 2px); padding: 0px; display: grid; grid-template-rows: 1fr auto; }
27
27
  </style>
28
- `),intrinsicSize:{w:550,h:720},sandbox:{allowSameOrigin:n}};return Ot.set(e,p),p}return Ot.set(e,{link:e,intrinsicSize:o,type:i,sandbox:{allowSameOrigin:n}}),{link:e,intrinsicSize:o,type:i,sandbox:{allowSameOrigin:n}}},sT=e=>{let t;Co(e)?t="IFrame element":t=!e.link||e?.link===""?"Empty Web-Embed":e.link;let n=Math.max(Math.min(e.width/2,e.width/t.length),e.width/30),i=ix.Helvetica,o=rx({fontSize:n,fontFamily:i});return si({x:e.x+e.width/2,y:e.y+e.height/2,strokeColor:e.strokeColor!=="transparent"?e.strokeColor:"black",backgroundColor:"transparent",fontFamily:i,fontSize:n,text:rn(t,o,e.width-20),textAlign:"center",verticalAlign:ox.MIDDLE,angle:e.angle??0})},Ma=(e,t)=>{try{let{hostname:n}=new URL(e),i=n.replace(/^www\./,"");if(t instanceof Set){if(Sa.has(i))return i;let r=i.replace(/^([^.]+)/,"*");return Sa.has(r)?r:null}let o=t.replace(/^www\./,"");if(i===o)return o}catch{}return null},aT=e=>{let t=e.match(ux);if(t&&t.length===2)return t[1];let n=e.match(fx);if(n&&n.length===2)return n[1];let i=e.match(dx);if(i&&i.length===2)return i[1];if(fu.test(e))return`https://giphy.com/embed/${fu.exec(e)[1]}`;let o=e.match(px);return o&&o.length===2?o[1]:e},lT=(e,t)=>{if(!e)return!1;if(t!=null)if(typeof t=="function"){let n=t(e);if(typeof n=="boolean")return n}else{if(typeof t=="boolean")return t;if(t instanceof RegExp)return t.test(e);if(Array.isArray(t)){for(let n of t)if(n instanceof RegExp){if(e.match(n))return!0}else if(Ma(e,n))return!0;return!1}}return!!Ma(e,Sa)};I();import{invariant as Aa,toBrandedType as gx}from"@excalidraw/common";import{clamp as Ex,pointFrom as xu}from"@excalidraw/math";var bu=100,wu=100,xx=e=>{let t=[...e].sort((i,o)=>i.start-o.start),n=[];for(let i of t){let o=n[n.length-1];o&&i.start<=o.end?o.end=Math.max(o.end,i.end):n.push({...i})}return n},Iu=(e,t,n)=>n.every(i=>e+t<=i.start||e>=i.end),bx=(e,t,n)=>{if(Iu(e,t,n))return e;let i=[-1/0,...n.map(a=>a.end)],o=[...n.map(a=>a.start),1/0],r=e,s=1/0;for(let a=0;a<i.length;a++){if(o[a]-i[a]<t)continue;let l=Ex(e,i[a],o[a]-t),d=Math.abs(l-e);d<=s&&(r=l,s=d)}return r},wx=(e,t)=>{let n=[...t.values()].filter(j),i=new Set([e.id]),o=[e.id],r=[];for(;o.length>0;){let s=o.shift();for(let a of n){let l=a.startBinding?.elementId,d=a.endBinding?.elementId,c;if(l===s?c=d:d===s&&(c=l),!c||i.has(c))continue;i.add(c);let u=t.get(c);u&&we(u)&&(r.push(u),o.push(c))}}return r},yx=(e,t,n,i,o)=>{let r=t==="left"||t==="right",s=r?e.width:e.height,a=r?e.height:e.width,l=r?wu:bu,d=r?bu:wu,c=r?e.x:e.y,u=r?e.y+e.height/2:e.x+e.width/2,m=t==="right"||t==="down"?c+s+l:c-l-s,p=xx(i.filter(b=>{let y=r?b[0]:b[1],w=r?b[2]:b[3];return y<m+s&&w>m}).map(b=>({start:(r?b[1]:b[0])-d,end:(r?b[3]:b[2])+d}))),h=a+d,f=n*a+(n-1)*d,E=(o===null?null:[o,o-h].filter(b=>Iu(b,f,p)).sort((b,y)=>Math.abs(b+f/2-u)-Math.abs(y+f/2-u))[0]??null)??bx(u-f/2,f,p);return{positions:Array.from({length:n},(b,y)=>{let w=E+y*h;return r?{x:m,y:w}:{x:w,y:m}}),crossStart:E}},Px=(e,t,n)=>{let i=Ai({type:e.type,x:t,y:n,width:e.width,height:e.height,roundness:e.roundness,roughness:e.roughness,backgroundColor:e.backgroundColor,strokeColor:e.strokeColor,strokeWidth:e.strokeWidth,opacity:e.opacity,fillStyle:e.fillStyle,strokeStyle:e.strokeStyle});return Aa(Dl(i),"not an ExcalidrawFlowchartNodeElement"),i},Ix=(e,t,n,i,o,r=null)=>{let s=i.getNonDeletedElementsMap(),a=wx(e,s).map(u=>lt(u,s)),{positions:l,crossStart:d}=yx(e,n,o,a,r),c=[];for(let u of l){let m=Px(e,u.x,u.y),p=Sx(e,m,n,t,i);c.push(m,p)}return{nodes:c,crossStart:d}},Sx=(e,t,n,i,o)=>{let r,s;switch(n){case"up":{r=e.x+e.width/2,s=e.y-6;break}case"down":{r=e.x+e.width/2,s=e.y+e.height+6;break}case"right":{r=e.x+e.width+6,s=e.y+e.height/2;break}case"left":{r=e.x-6,s=e.y+e.height/2;break}}let l,d;switch(n){case"up":{l=t.x+t.width/2-r,d=t.y+t.height-s+6;break}case"down":{l=t.x+t.width/2-r,d=t.y-s-6;break}case"right":{l=t.x-r-6,d=t.y-s+t.height/2;break}case"left":{l=t.x+t.width-r+6,d=t.y-s+t.height/2;break}}let c=br({type:"arrow",x:r,y:s,startArrowhead:null,endArrowhead:i.currentItemEndArrowhead,strokeColor:e.strokeColor,strokeStyle:e.strokeStyle,strokeWidth:e.strokeWidth,opacity:e.opacity,roughness:e.roughness,points:[xu(0,0),xu(l,d)],elbowed:!0}),u=o.getNonDeletedElementsMap();Vt(c,e,"orbit","start",o),Vt(c,t,"orbit","end",o);let m=new Map;m.set(e.id,e),m.set(t.id,t),m.set(c.id,c),R.movePoints(c,o,new Map([[1,{point:c.points[1]}]]));let p=xi(c,gx(new Map([...u.entries(),[e.id,e],[t.id,t],[c.id,c]])),{points:c.points});return{...c,...p,isDeleted:c.isDeleted}},yu=class e{isExploring=!1;sameLevelNodes=[];sameLevelIndex=0;direction=null;visitedNodes=new Set;clear(){this.isExploring=!1,this.sameLevelNodes=[],this.sameLevelIndex=0,this.direction=null,this.visitedNodes.clear()}exploreByDirection(t,n,i){if(!we(t))return null;if(i!==this.direction&&this.clear(),this.visitedNodes.has(t.id)||this.visitedNodes.add(t.id),this.isExploring&&i===this.direction&&this.sameLevelNodes.length>1)return this.sameLevelIndex=(this.sameLevelIndex+1)%this.sameLevelNodes.length,this.sameLevelNodes[this.sameLevelIndex].id;let o=[...e.getSuccessors(t,n,i),...e.getPredecessors(t,n,i)];if(o.length>0)return this.sameLevelIndex=0,this.isExploring=!0,this.sameLevelNodes=o,this.direction=i,this.visitedNodes.add(o[0].id),o[0].id;if(i===this.direction||!this.isExploring){this.isExploring||this.visitedNodes.add(t.id);let s=["up","right","down","left"].filter(a=>a!==i).map(a=>[...e.getSuccessors(t,n,a),...e.getPredecessors(t,n,a)]).flat().filter(a=>!this.visitedNodes.has(a.id));for(let a of s)if(!this.visitedNodes.has(a.id))return this.visitedNodes.add(a.id),this.isExploring=!0,this.direction=i,a.id}return null}static getNodeRelatives(t,n,i,o){let r=[...i.values()].reduce((s,a)=>{let l;if(j(a)&&(l=a[t==="predecessors"?"startBinding":"endBinding"])&&a[t==="predecessors"?"endBinding":"startBinding"]?.elementId===n.id){let d=i.get(l.elementId);if(!d)return s;Aa(we(d),"not an ExcalidrawBindableElement");let c=t==="predecessors"?a.points[a.points.length-1]:[0,0],u=gi(n,lt(n,i),[c[0]+a.x,c[1]+a.y]);s.push({relative:d,heading:u})}return s},[]);switch(o){case"up":return r.filter(s=>fe(s.heading,Ze)).map(s=>s.relative);case"down":return r.filter(s=>fe(s.heading,Be)).map(s=>s.relative);case"right":return r.filter(s=>fe(s.heading,he)).map(s=>s.relative);case"left":return r.filter(s=>fe(s.heading,Ne)).map(s=>s.relative)}}static getSuccessors(t,n,i){return e.getNodeRelatives("successors",t,n,i)}static getPredecessors(t,n,i){return e.getNodeRelatives("predecessors",t,n,i)}},Pu=class{isCreatingChart=!1;numberOfNodes=0;direction=null;clusterCrossStart=null;pendingNodes=null;createNodes(t,n,i,o){let r=o.getNonDeletedElementsMap();i!==this.direction?(this.numberOfNodes=1,this.clusterCrossStart=null):this.numberOfNodes+=1;let{nodes:s,crossStart:a}=Ix(t,n,i,o,this.numberOfNodes,this.clusterCrossStart);if(this.isCreatingChart=!0,this.direction=i,this.clusterCrossStart=a,this.pendingNodes=s,t.frameId){let l=r.get(t.frameId);Aa(l&&ko(l),"not an ExcalidrawFrameElement"),l&&this.pendingNodes.every(d=>Gn([d],l,r)||Ln(d,l,r))&&(this.pendingNodes=this.pendingNodes.map(d=>Fe(d,r,{frameId:t.frameId})))}}clear(){this.isCreatingChart=!1,this.pendingNodes=null,this.direction=null,this.numberOfNodes=0,this.clusterCrossStart=null}},PT=(e,t)=>{for(let[,n]of t)if(n.type==="arrow"&&(n.startBinding?.elementId===e.id||n.endBinding?.elementId===e.id))return!0;return!1};I();import{pointDistance as Gi,pointFrom as Da}from"@excalidraw/math";import{invariant as Ou}from"@excalidraw/common";I();import{arrayToMap as Mu,findIndex as Au,findLastIndex as Tu}from"@excalidraw/common";import{isFiniteNumber as Mx}from"@excalidraw/math";var Ta=(e,t)=>e.frameId===t||e.id===t,Du=(e,t,n)=>{let i=[],o=[],r=null,s=-1,a=Mu(n||Zt(e,t,{includeBoundTextElement:!0,includeElementsInFrames:!0}));for(;++s<e.length;){let l=e[s];a.get(l.id)?(o.length&&(i=i.concat(o),o=[]),i.push(s),r=s+1):l.isDeleted&&r===s?(r=s+1,o.push(s)):o=[]}return i},Ax=e=>{let t=0;return e.reduce((n,i,o)=>(o>0&&e[o-1]!==i-1&&(t=++t),(n[t]||(n[t]=[])).push(i),n),[])},Su=(e,t,n,i)=>{if("containerId"in e&&e.containerId){let o=i.getElement(e.containerId);if(o)return n==="left"?Math.min(t.indexOf(o),t.indexOf(e)):Math.max(t.indexOf(o),t.indexOf(e))}else{let o=e.boundElements?.find(r=>r.type!=="arrow")?.id;if(o){let r=i.getElement(o);if(r)return n==="left"?Math.min(t.indexOf(r),t.indexOf(e)):Math.max(t.indexOf(r),t.indexOf(e))}}},Tx=(e,t)=>{let n=-1,i=-1;return e.forEach((o,r)=>{Ta(o,t)&&(n===-1&&(n=r),i=r)}),n===-1?[]:e.slice(n,i+1)},vu=(e,t,n,i,o,r)=>{let s=r||sn(e,kn(n),i);if(!s)return n;let a=de(s,i),l=oe(s)?Ue(s,i):null,d=[s.id,a?.id,l?.id].filter(m=>!!m),c=n.findIndex(m=>d.includes(m.id)),u=n.findIndex(m=>m.id===t.id);if(u!==-1&&c!==-1&&u<c){let m=Array.from(n),p=m.splice(u,1)[0];m.splice(c,0,p),o.replaceAllElements(m)}return n},Dx=(e,t,n,i,o,r)=>{let s=t[n],a=m=>m.isDeleted?!1:o?m.frameId===o:e.editingGroupId?m.groupIds.includes(e.editingGroupId):!0,l=i==="left"?Tu(t,m=>a(m),Math.max(0,n-1)):Au(t,m=>a(m),n+1),d=t[l];if(!d)return-1;if(e.editingGroupId){if(s?.groupIds.join("")===d?.groupIds.join(""))return Su(d,t,i,r)??l;if(!d?.groupIds.includes(e.editingGroupId))return-1}if(!o&&(d.frameId||J(d))){let m=Tx(t,d.frameId||d.id);return i==="left"?t.indexOf(m[0]):t.indexOf(m[m.length-1])}if(!d.groupIds.length)return Su(d,t,i,r)??l;let c=e.editingGroupId?d.groupIds[d.groupIds.indexOf(e.editingGroupId)-1]:d.groupIds[d.groupIds.length-1],u=Qe(t,c);return u.length?i==="left"?t.indexOf(u[0]):t.indexOf(u[u.length-1]):l},Bu=(e,t)=>t.reduce((n,i)=>{let o=e[i];return n.set(o.id,o),n},new Map),Lu=(e,t)=>{if(e.length!==t.length)return console.error("z-index reordering failed: resulting array have different lengths"),!1;let n=new Map;for(let i of e)n.set(i.id,(n.get(i.id)||0)+1);for(let i of t){let o=n.get(i.id);if(!o)return console.error("z-index reordering failed: element id mismatch / duplicate ids"),!1;n.set(i.id,o-1)}return!0},Cu=(e,t,n,i)=>{let o=e,r=Du(e,t),s=Bu(e,r),a=Ax(r);n==="right"&&(a=a.reverse());let l=new Set(r.filter(d=>J(e[d])).map(d=>e[d].id));return a.forEach((d,c)=>{let u=d[0],m=d[d.length-1],p=n==="left"?u:m,h=d.some(y=>{let w=e[y];return w.frameId&&l.has(w.frameId)})?null:e[p]?.frameId,f=Dx(t,e,p,n,h,i);if(f===-1||p===f)return;let g=n==="left"?e.slice(0,f):e.slice(0,u),E=e.slice(u,m+1),x=n==="left"?e.slice(f,u):e.slice(m+1,f+1),b=n==="left"?e.slice(m+1):e.slice(f+1);e=n==="left"?[...g,...E,...x,...b]:[...g,...x,...E,...b]}),Lu(o,e)?(ni(e,s),e):o},Gu=(e,t,n,i,o)=>{let r=Du(e,t,o);if(r.length===0)return e;let s=Bu(e,r),a=[],l,d;if(n==="left"){if(i)l=Au(e,f=>Ta(f,i));else if(t.editingGroupId){let f=Qe(e,t.editingGroupId);if(!f.length)return e;l=e.indexOf(f[0])}else l=0;d=r[r.length-1]}else{if(i)d=Tu(e,f=>Ta(f,i));else if(t.editingGroupId){let f=Qe(e,t.editingGroupId);if(!f.length)return e;d=e.indexOf(f[f.length-1])}else d=e.length-1;l=r[0]}l===-1&&(l=0);let c=f=>Mx(f)&&f>=0;if(!c(l)||!c(d)||l>d||r.some(f=>f<l||f>d))return e;for(let f=l;f<d+1;f++)r.includes(f)||a.push(e[f]);let u=Array.from(s.values()),m=e.slice(0,l),p=e.slice(d+1),h=n==="left"?[...m,...u,...a,...p]:[...m,...a,...u,...p];return Lu(e,h)?(ni(h,s),h):e};function ku(e,t,n,i){let o=Mu(Zt(e,t,{includeBoundTextElement:!0,includeElementsInFrames:!0})),r={regularElements:[],frameChildren:new Map},s=new Set;for(let d of e)o.has(d.id)&&J(d)&&s.add(d.id);for(let d of e)if(o.has(d.id))if(J(d)||d.frameId&&s.has(d.frameId))r.regularElements.push(d);else if(!d.frameId)r.regularElements.push(d);else{let c=r.frameChildren.get(d.frameId)||[];c.push(d),r.frameChildren.set(d.frameId,c)}let a=e,l=Array.from(r.frameChildren.entries());for(let[d,c]of l)a=i(a,t,n,d,c);return i(a,t,n,null,r.regularElements)}var kT=(e,t,n)=>Cu(e,t,"left",n),OT=(e,t,n)=>Cu(e,t,"right",n),NT=(e,t)=>ku(e,t,"left",Gu),FT=(e,t)=>ku(e,t,"right",Gu);var Tr=(e,t,n,i,o,r,s=!1)=>{if(j(t)||!$t(o)||t.points.length!==2)return!1;if(!s){let l=t.startBinding?.elementId===n.id?0:t.points.length-1,d=R.getPointAtIndexGlobalCoordinates(t,l,i);if(Gi(e,d)<no*1.5/o.zoom.value)return!1}let a=R.getPointAtIndexGlobalCoordinates(t,r==="end"?t.points.length-1:0,i);return Gi(e,a)>=no*1.5/o.zoom.value&&Ht({element:n,elementsMap:i,point:e,threshold:ve(n,t),overrideShouldTestInside:!0})},vx=(e,t,n,i,o,r,s)=>{let a=new Map,l=r.selectedLinearElement?.initialState.arrowOtherEndpointInitialBinding,d=n?"startBinding":"endBinding",c=n?"endBinding":"startBinding",u=e[d],m=l?.mode==="orbit"&&e[c]?.mode==="inside"?l:e[c];if(u&&t){let p=t&&m&&u.elementId===m.elementId;s||p?u={...u,mode:"inside"}:u={...u,mode:"orbit"};let h=n?0:e.points.length-1,f=Ct(e,d,u,t,i,!0);f&&a.set(h,{point:f})}if(m&&m.mode==="orbit"){let p=i.get(m.elementId);if(p&&we(p)&&$t(r)){t&&m.elementId===t.id?m={...m,mode:"inside"}:m={...m,mode:"orbit"};let f=n?e.points.length-1:0,g=Ct(e,c,m,p,i);g&&a.set(f,{point:g})}}a.size>0&&R.movePoints(e,o,a,{[d]:u,[c]:m})},Nu=(e,t,n,i,o,r,s)=>{let a=R.getElement(e.elementId,t);if(!a||!_e(a)||j(a)||!e.hoveredFocusPointBinding||!e.draggedFocusPointBinding)return;let l=e.draggedFocusPointBinding==="start",d=l?a.startBinding:a.endBinding,{x:c,y:u}=e.pointerOffset,m=Da(n.x-c,n.y-u),p=l?"startBinding":"endBinding",h=rd(m,a,i.getNonDeletedElements(),t,Dt(o.zoom));if(h&&$t(o)){a[p]&&h.id!==d?.elementId&&Xe(a,e.draggedFocusPointBinding,i);let f=s&&a[p]?.mode==="orbit"?"inside":!s&&a[p]?.mode==="inside"?"orbit":null;(!a[p]||f)&&Vt(a,h,f||"orbit",e.draggedFocusPointBinding,i,m),i.mutateElement(a,{[p]:{...a[p],elementId:h.id,mode:f||a[p]?.mode||"orbit",...yi(a,h,e.draggedFocusPointBinding,t,m)}})}else{let f=new Map,g=l?0:a.points.length-1;f.set(g,{point:R.createPointAt(a,t,m[0],m[1],r)}),R.movePoints(a,i,f),a[p]&&Xe(a,l?"start":"end",i)}vx(a,h,l,t,i,o,s),h&&$t(o)&&vu(m,a,i.getElementsIncludingDeleted(),t,i,h)},$T=(e,t,n,i)=>{let o=Da(t.origin.x,t.origin.y),r=no*1.5/i.zoom.value;if(e.startBinding?.elementId){let s=n.get(e.startBinding.elementId);if(s&&we(s)&&!s.isDeleted){let a=He(e.startBinding.fixedPoint,s,n);if(Tr(a,e,s,n,i,"start")&&Gi(o,a)<=r)return{hitFocusPoint:"start",pointerOffset:{x:o[0]-a[0],y:o[1]-a[1]},arrowOtherEndpointInitialBinding:e.endBinding}}}if(e.endBinding?.elementId){let s=n.get(e.endBinding.elementId);if(s&&we(s)&&!s.isDeleted){let a=He(e.endBinding.fixedPoint,s,n);if(Tr(a,e,s,n,i,"end")&&Gi(o,a)<=r)return{hitFocusPoint:"end",pointerOffset:{x:o[0]-a[0],y:o[1]-a[1]},arrowOtherEndpointInitialBinding:e.startBinding}}}return{hitFocusPoint:null,pointerOffset:{x:0,y:0},arrowOtherEndpointInitialBinding:null}},VT=(e,t)=>{Ou(e.draggedFocusPointBinding,"Must have a dragged focus point at pointer release");let n=R.getElement(e.elementId,t.getNonDeletedElementsMap());Ou(n,"Arrow must be in the scene");let i=e.draggedFocusPointBinding==="start"?"startBinding":"endBinding",o=e.draggedFocusPointBinding==="start"?"endBinding":"startBinding",r=n[i]?.elementId,s=n[o]?.elementId,a=r&&t.getNonDeletedElements().find(d=>d.id!==r&&d.id!==s&&we(d)&&d.boundElements?.find(({id:c})=>c===n.id));a&&t.mutateElement(a,{boundElements:a.boundElements?.filter(({id:d})=>d!==n.id)});let l=r&&t.getNonDeletedElementsMap().get(r);return l&&t.mutateElement(l,{boundElements:[...(l.boundElements||[])?.filter(({id:d})=>d!==n.id),{id:n.id,type:"arrow"}]}),{arrowOtherEndpointInitialBinding:null}},ZT=(e,t,n,i,o)=>{let r=i.getNonDeletedElementsMap(),s=Da(t,n),a=no*1.5/o.zoom.value;if(e.startBinding?.elementId){let l=r.get(e.startBinding.elementId);if(l&&we(l)&&!l.isDeleted){let d=He(e.startBinding.fixedPoint,l,r);if(Tr(d,e,l,r,o,"start")&&Gi(s,d)<=a)return"start"}}if(e.endBinding?.elementId){let l=r.get(e.endBinding.elementId);if(l&&we(l)&&!l.isDeleted){let d=He(e.endBinding.fixedPoint,l,r);if(Tr(d,e,l,r,o,"end")&&Gi(s,d)<=a)return"end"}}return null};I();import{MIME_TYPES as Fu,SVG_NS as Bx}from"@excalidraw/common";var Lx=e=>new Promise((t,n)=>{let i=new Image;i.onload=()=>{t(i)},i.onerror=o=>{n(o)},i.src=e}),eD=async({fileIds:e,files:t,imageCache:n})=>{let i=new Map,o=new Map;return await Promise.all(e.reduce((r,s)=>{let a=t[s];return a&&!i.has(s)?(i.set(s,!0),r.concat((async()=>{try{if(a.mimeType===Fu.binary)throw new Error("Only images can be added to ImageCache");let l=Lx(a.dataURL),d={image:l,mimeType:a.mimeType};n.set(s,d);let c=await l;n.set(s,{...d,image:c})}catch{o.set(s,!0)}})())):r},[])),{imageCache:n,updatedFiles:i,erroredFiles:o}},tD=e=>e.filter(t=>Vn(t)),Cx=e=>e?.nodeName.toLowerCase()==="svg",nD=e=>{let t=new DOMParser().parseFromString(e,Fu.svg),n=t.querySelector("svg");if(t.querySelector("parsererror")||!Cx(n))throw new Error("Invalid SVG");{n.hasAttribute("xmlns")||n.setAttribute("xmlns",Bx);let o=n.getAttribute("width"),r=n.getAttribute("height");(o?.includes("%")||o==="auto")&&(o=null),(r?.includes("%")||r==="auto")&&(r=null);let s=n.getAttribute("viewBox");if(!o||!r){if(o=o||"50",r=r||"50",s){let a=s.match(/\d+ +\d+ +(\d+(?:\.\d+)?) +(\d+(?:\.\d+)?)/);a&&([,o,r]=a)}n.setAttribute("width",o),n.setAttribute("height",r)}return s||n.setAttribute("viewBox",`0 0 ${o} ${r}`),n.outerHTML}};I();var aD=(e,t,n,i=50)=>{if(!e||e.length===0)return[];let o=[],r=Array.isArray(e[0])?e:e.map(p=>[p]),s=r.length,a=Math.max(1,Math.ceil(Math.sqrt(s))),l=[];for(let p=0;p<s;p+=a)l.push(r.slice(p,p+a));let d=0,c=l.map(p=>{let h=0,f=0,g=p.map(E=>{let[x,b,y,w]=Je(E);return{elements:E,bounds:[x,b,y,w],width:y-x,height:w-b}});return g.forEach((E,x)=>{h+=E.width,x<g.length-1&&(h+=i),E.height>f&&(f=E.height)}),d+=f,{unitBounds:g,width:h,maxHeight:f}}),u=d+Math.max(0,l.length-1)*i,m=n-u/2;return c.forEach(p=>{let{unitBounds:h,width:f,maxHeight:g}=p,E=t-f/2;h.forEach(x=>{let[b,y]=x.bounds,w=E-b,M=m-y;x.elements.forEach(S=>{o.push(Ke(S,{x:S.x+w,y:S.y+M}))}),E+=x.width+i}),m+=g+i}),o};I();import{pointCenter as Gx,normalizeRadians as vr,pointFrom as me,pointRotateRads as Nt}from"@excalidraw/math";import{MIN_FONT_SIZE as Ba,SHIFT_LOCKING_ANGLE as Br,rescalePoints as Ru,getFontString as Dr}from"@excalidraw/common";var wD=(e,t,n,i,o,r,s,a,l,d,c)=>{let u=i.getNonDeletedElementsMap();if(n.length===1){let[m]=n;if(t==="rotation")j(m)||(kx(m,i,a,l,o),je(m,i));else if(t){let p=n[0].id,h=u.get(p),f=e.get(p);if(h&&f){let{nextWidth:g,nextHeight:E}=zx(h,f,t,a,l,{shouldMaintainAspectRatio:s,shouldResizeFromCenter:r});Rx(g,E,h,f,e,i,t,{shouldMaintainAspectRatio:s,shouldResizeFromCenter:r})}}return oe(m)&&je(m,i),!0}else if(n.length>1){if(t==="rotation")return Nx(e,n,i,a,l,o,d,c),!0;if(t){let{nextWidth:m,nextHeight:p,flipByX:h,flipByY:f,originalBoundingBox:g}=_x(n,e,u,t,a,l,{shouldMaintainAspectRatio:s,shouldResizeFromCenter:r});return Hx(n,u,t,i,e,{shouldResizeFromCenter:r,shouldMaintainAspectRatio:s,flipByX:h,flipByY:f,nextWidth:m,nextHeight:p,originalBoundingBox:g}),!0}}return!1},kx=(e,t,n,i,o)=>{let[r,s,a,l]=Z(e,t.getNonDeletedElementsMap()),d=(r+a)/2,c=(s+l)/2,u;J(e)?u=0:(u=5*Math.PI/2+Math.atan2(i-c,n-d),o&&(u=u+Br/2,u=u-u%Br),u=vr(u));let m=Bt(e),p={angle:u};if(_e(e)&&(p={...p},e.startBinding&&Xe(e,"start",t),e.endBinding&&Xe(e,"end",t)),t.mutateElement(e,p),m){let h=t.getElement(m);if(h&&!X(e)){let{x:f,y:g}=Ki(e,h,t.getNonDeletedElementsMap());t.mutateElement(h,{angle:u,x:f,y:g})}}},zu=(e,t,n,i)=>K(e)||be(e)?{points:Ru(0,t,Ru(1,n,e.points,i),i)}:{},La=(e,t,n)=>{let i=e.width;if(Ie(e)){let s=Ue(e,t);s&&(i=vt(s,e))}let r=e.fontSize*(n/i);return r<Ba?null:{size:r}},Ox=(e,t,n,i,o,r,s)=>{let a=n.getNonDeletedElementsMap(),l=t.width*(s/t.height),d=La(t,a,l);if(d!==null){if(i.includes("n")||i.includes("s")){let c=me(e.x,e.y),u=va(c,e.width,e.height,l,s,e.angle,i,!1,o);n.mutateElement(t,{fontSize:d.size,width:l,height:s,x:u.x,y:u.y});return}if(i==="e"||i==="w"){let c=zo(Dr({fontSize:t.fontSize,fontFamily:t.fontFamily}),t.lineHeight),u=Math.max(c,r),m=rn(t.originalText,Dr(t),Math.abs(u)),p=ft(m,Dr(t),t.lineHeight),h=p.height,f=me(e.x,e.y),g=va(f,e.width,e.height,u,h,t.angle,i,!1,o),E={width:Math.abs(u),height:Math.abs(p.height),x:g.x,y:g.y,text:m,autoResize:!1};n.mutateElement(t,E)}}},Nx=(e,t,n,i,o,r,s,a)=>{let l=n.getNonDeletedElementsMap(),d=5*Math.PI/2+Math.atan2(o-a,i-s);r&&(d+=Br/2,d-=d%Br);let c=new Map(t.map(u=>[u.id,u]));for(let u of t)if(!J(u)){let[m,p,h,f]=Z(u,l),g=(m+h)/2,E=(p+f)/2,x=e.get(u.id)?.angle??u.angle,[b,y]=Nt(me(g,E),me(s,a),d+x-u.angle),w=j(u)?{points:Ld(u,l)}:{x:u.x+(b-g),y:u.y+(y-E),angle:vr(d+x)};n.mutateElement(u,w),je(u,n,{simultaneouslyUpdated:t}),_e(u)&&(u.startBinding&&(c.has(u.startBinding.elementId)||Xe(u,"start",n)),u.endBinding&&(c.has(u.endBinding.elementId)||Xe(u,"end",n)));let M=de(u,l);if(M&&!X(u)){let{x:S,y:T}=Ki(u,M,l);n.mutateElement(M,{x:S,y:T,angle:vr(d+x)})}}n.triggerUpdate()},yD=(e,t,n,i,o)=>{let[r,s,a,l]=t.length===1?Z(t[0],n):Je(t),d=(r+a)/2,c=(s+l)/2,u=t.length===1?t[0].angle:0;switch([i,o]=Nt(me(i,o),me(d,c),-u),e){case"n":return Nt(me(i-(r+a)/2,o-s),me(0,0),u);case"s":return Nt(me(i-(r+a)/2,o-l),me(0,0),u);case"w":return Nt(me(i-r,o-(s+l)/2),me(0,0),u);case"e":return Nt(me(i-a,o-(s+l)/2),me(0,0),u);case"nw":return Nt(me(i-r,o-s),me(0,0),u);case"ne":return Nt(me(i-a,o-s),me(0,0),u);case"sw":return Nt(me(i-r,o-l),me(0,0),u);case"se":return Nt(me(i-a,o-l),me(0,0),u);default:return[0,0]}},PD=(e,t)=>{let[,[n,i]]=t.points;return e==="nw"&&(n<0||i<0)||e==="ne"&&n>=0||e==="sw"&&n<=0||e==="se"&&(n>0||i>0)?"end":"origin"},Fx=(e,t,n)=>{if(n)return"center";if(t)switch(e){case"n":return"south-side";case"e":return"west-side";case"s":return"north-side";case"w":return"east-side";case"ne":return"bottom-left";case"nw":return"bottom-right";case"se":return"top-left";case"sw":return"top-right"}return["e","se","s"].includes(e)?"top-left":["n","nw","w"].includes(e)?"bottom-right":e==="ne"?"bottom-left":"top-right"},va=(e,t,n,i,o,r,s,a,l)=>{let d=Fx(s,a,l),[c,u]=e;switch(d){case"top-left":return{x:c+(t-i)/2+(i-t)/2*Math.cos(r)+(n-o)/2*Math.sin(r),y:u+(n-o)/2+(i-t)/2*Math.sin(r)+(o-n)/2*Math.cos(r)};case"top-right":return{x:c+(t-i)/2*(Math.cos(r)+1)+(n-o)/2*Math.sin(r),y:u+(n-o)/2+(t-i)/2*Math.sin(r)+(o-n)/2*Math.cos(r)};case"bottom-left":return{x:c+(t-i)/2*(1-Math.cos(r))+(o-n)/2*Math.sin(r),y:u+(n-o)/2*(Math.cos(r)+1)+(i-t)/2*Math.sin(r)};case"bottom-right":return{x:c+(t-i)/2*(Math.cos(r)+1)+(o-n)/2*Math.sin(r),y:u+(n-o)/2*(Math.cos(r)+1)+(t-i)/2*Math.sin(r)};case"center":return{x:c-(i-t)/2,y:u-(o-n)/2};case"east-side":return{x:c+(t-i)/2*(Math.cos(r)+1),y:u+(t-i)/2*Math.sin(r)+(n-o)/2};case"west-side":return{x:c+(t-i)/2*(1-Math.cos(r)),y:u+(i-t)/2*Math.sin(r)+(n-o)/2};case"north-side":return{x:c+(t-i)/2+(n-o)/2*Math.sin(r),y:u+(o-n)/2*(Math.cos(r)-1)};case"south-side":return{x:c+(t-i)/2+(o-n)/2*Math.sin(r),y:u+(n-o)/2*(Math.cos(r)+1)}}},Rx=(e,t,n,i,o,r,s,{shouldInformMutation:a=!0,shouldMaintainAspectRatio:l=!1,shouldResizeFromCenter:d=!1}={})=>{if(oe(n)&&oe(i))return Ox(i,n,r,s,d,e,t);let c={},u=r.getNonDeletedElementsMap(),m=de(n,u);if(m){let g=o.get(m.id);if(g&&(c={fontSize:g.fontSize}),l){let E={...n,width:e,height:t},x=La(m,u,vt(E,m));if(x===null)return;c={fontSize:x.size}}else{let E=Hl(Dr(m),m.lineHeight),x=Wl(m.fontSize,m.lineHeight);e=Math.max(e,E),t=Math.max(t,x)}}let p=zu(i,e,t,!0),h=me(i.x,i.y);if(K(i)){let[g,E]=ue(i,o);h=me(g,E)}let f=va(h,i.width,i.height,e,t,i.angle,s,l,d);if(K(i)&&p.points){let g=i.x-h[0],E=i.y-h[1];f.x+=g,f.y+=E;let x=p.points[0][0],b=p.points[0][1];f.x+=x,f.y+=b,p.points=p.points.map(y=>me(y[0]-x,y[1]-b))}if(e<0&&(f.x=f.x+e),t<0&&(f.y=f.y+t),"scale"in n&&"scale"in i&&r.mutateElement(n,{scale:[(Math.sign(e)||i.scale[0])*i.scale[0],(Math.sign(t)||i.scale[1])*i.scale[1]]}),X(n)&&m&&l){let g=e/n.width*m.fontSize;if(g<Ba)return;c.fontSize=g}if(e!==0&&t!==0&&Number.isFinite(f.x)&&Number.isFinite(f.y)){let g={...f,width:Math.abs(e),height:Math.abs(t),...p};_e(n)&&(n.startBinding&&(g={...g},n.startBinding&&Xe(n,"start",r)),n.endBinding&&(g={...g,endBinding:null})),r.mutateElement(n,g,{informMutation:a,isDragging:!1}),m&&c!=null&&r.mutateElement(m,{fontSize:c.fontSize}),qn(n,r,s,l,d),je(n,r)}},zx=(e,t,n,i,o,{shouldMaintainAspectRatio:r=!1,shouldResizeFromCenter:s=!1}={})=>{let[a,l,d,c]=wn(t,t.width,t.height,!0),u=me(a,l),m=me(d,c),p=Gx(u,m),h=Nt(me(i,o),p,-t.angle),[f,g,E,x]=wn(e,e.width,e.height,!0),b=E-f,y=x-g,w=m[0]-u[0],M=m[1]-u[1],S=w/b,T=M/y;n.includes("e")&&(S=(h[0]-u[0])/b),n.includes("s")&&(T=(h[1]-u[1])/y),n.includes("w")&&(S=(m[0]-h[0])/b),n.includes("n")&&(T=(m[1]-h[1])/y);let A=e.width*S,F=e.height*T;if(s&&(A=2*A-t.width,F=2*F-t.height),r){let B=Math.abs(A)/t.width,k=Math.abs(F)/t.height;if(n.length===1&&(F*=B,A*=k),n.length===2){let G=Math.max(B,k);A=t.width*G*Math.sign(A),F=t.height*G*Math.sign(F)}}return{nextWidth:A,nextHeight:F}},_x=(e,t,n,i,o,r,{shouldMaintainAspectRatio:s=!1,shouldResizeFromCenter:a=!1}={})=>{let l=e.map(G=>t.get(G.id)),d=l.reduce((G,_)=>{if(!K(_))return G;let W=Bt(_);if(!W)return G;let D=t.get(W)??null;return Ie(D)?[...G,{...D,...R.getBoundTextElementPosition(_,D,n)}]:G},[]),c=un(l.map(G=>G).concat(d)),{minX:u,minY:m,maxX:p,maxY:h,midX:f,midY:g}=c,E=p-u,x=h-m,b={ne:[u,h],se:[u,m],sw:[p,m],nw:[p,h],e:[u,m+x/2],w:[p,m+x/2],n:[u+E/2,h],s:[u+E/2,m]},[y,w]=a?[f,g]:b[i],M=a?2:1,S=Math.max(Math.abs(o-y)/E||0,Math.abs(r-w)/x||0)*M,T=i.includes("e")||i.includes("w")?Math.abs(o-y)*M:E,A=i.includes("n")||i.includes("s")?Math.abs(r-w)*M:x;s&&(T=E*S*Math.sign(o-y),A=x*S*Math.sign(r-w));let F={ne:[o<y,r>w],se:[o<y,r<w],sw:[o>y,r<w],nw:[o>y,r>w],e:[o<y,!1],w:[o>y,!1],n:[!1,r>w],s:[!1,r<w]},[B,k]=F[i].map(G=>G);return{originalBoundingBox:c,nextWidth:T,nextHeight:A,flipByX:B,flipByY:k}},Hx=(e,t,n,i,o,{shouldMaintainAspectRatio:r=!1,shouldResizeFromCenter:s=!1,flipByX:a=!1,flipByY:l=!1,nextHeight:d,nextWidth:c,originalBoundingBox:u}={})=>{if(c===void 0&&d===void 0&&a===void 0&&l===void 0||d===0||c===0)return;o||(o=t);let m=e.reduce((M,S)=>{let T=o.get(S.id);return T&&M.push({orig:T,latest:S}),M},[]),p;if(u)p=u;else{let M=m.reduce((S,{orig:T})=>{if(!K(T))return S;let A=Bt(T);if(!A)return S;let F=o.get(A)??null;return Ie(F)?[...S,{...F,...R.getBoundTextElementPosition(T,F,t)}]:S},[]);p=un([...m.map(({orig:S})=>S),...M])}let{minX:h,minY:f,maxX:g,maxY:E,midX:x,midY:b}=p,y=g-h,w=E-f;if(c===void 0&&d===void 0&&(c=y,d=w),r&&(c===void 0?c=d*(y/w):d===void 0?d=c*(w/y):Math.abs(c/d-y/w)>.001&&(c=d*(y/w))),c&&d){let M=n.includes("e")||n.includes("w")?Math.abs(c)/y:1,S=n.includes("n")||n.includes("s")?Math.abs(d)/w:1,T;n.length===1?T=n.includes("e")||n.includes("w")?M:S:T=Math.max(Math.abs(c)/y||0,Math.abs(d)/w||0);let A={ne:[h,E],se:[h,f],sw:[g,f],nw:[g,E],e:[h,f+w/2],w:[g,f+w/2],n:[h+y/2,E],s:[h+y/2,f]},[F,B]=s?[x,b]:A[n],k=r||m.some(P=>P.latest.angle!==0||oe(P.latest)||$d(P.latest));k&&(M=T,S=T);let[G,_]=[a?-1:1,l?-1:1],W=[];for(let{orig:P,latest:v}of m){if(oe(P)&&Ie(P))continue;let C=P.width*M,z=P.height*S,Q=vr(P.angle*G*_),ee=K(P)||be(P),te=P.x-F,ne=P.y-B,Ae=a&&!ee?C:0,Ft=l&&!ee?z:0,Rt=F+G*(te*M+Ae),hn=B+_*(ne*S+Ft),pe=zu(P,C*G,z*_,!1),ie={x:Rt,y:hn,width:C,height:z,angle:Q,...pe};if(j(P)&&(P.startBinding&&(ie.startBinding={...P.startBinding,fixedPoint:[a?-P.startBinding.fixedPoint[0]+1:P.startBinding.fixedPoint[0],l?-P.startBinding.fixedPoint[1]+1:P.startBinding.fixedPoint[1]]}),P.endBinding&&(ie.endBinding={...P.endBinding,fixedPoint:[a?-P.endBinding.fixedPoint[0]+1:P.endBinding.fixedPoint[0],l?-P.endBinding.fixedPoint[1]+1:P.endBinding.fixedPoint[1]]}),P.fixedSegments&&pe.points&&(ie.fixedSegments=P.fixedSegments.map(Te=>({...Te,start:pe.points[Te.index-1],end:pe.points[Te.index]})))),ke(P)&&(ie.scale=[P.scale[0]*G,P.scale[1]*_]),oe(P)){let Te=La(P,t,C);if(!Te)return;ie.fontSize=Te.size}let Le=o.get(Bt(P)??"");if(Le)if(k){let Te=Le.fontSize*T;if(Te<Ba)return;ie.boundTextFontSize=Te}else ie.boundTextFontSize=Le.fontSize;W.push({element:v,update:ie})}let D=W.map(({element:P})=>P),L=new Map(W.map(({element:P})=>[P.id,P]));for(let{element:P,update:{boundTextFontSize:v,...C}}of W){let{angle:z}=C;i.mutateElement(P,C),je(P,i,{simultaneouslyUpdated:D}),_e(P)&&(P.startBinding&&(L.has(P.startBinding.elementId)||Xe(P,"start",i)),P.endBinding&&(L.has(P.endBinding.elementId)||Xe(P,"end",i)));let Q=de(P,t);Q&&v&&(i.mutateElement(Q,{fontSize:v,angle:K(P)?void 0:z}),qn(P,i,n,!0,s))}i.triggerUpdate()}};I();import{pointFrom as Pt,pointOnLineSegment as Xu,pointRotateRads as Cr}from"@excalidraw/math";import{SIDE_RESIZING_THRESHOLD as Fa}from"@excalidraw/common";I();import{DEFAULT_TRANSFORM_HANDLE_SPACING as Ga}from"@excalidraw/common";import{pointFrom as _u,pointRotateRads as Wx}from"@excalidraw/math";var Hu={mouse:8,pen:16,touch:28},Ux=16,Uu={e:!0,s:!0,n:!0,w:!0},vD={e:!0,s:!0,n:!0,w:!0},BD={e:!0,s:!0,n:!0,w:!0,rotation:!0},Wu={e:!0,s:!0,n:!0,w:!0,nw:!0,se:!0},Ca={e:!0,s:!0,n:!0,w:!0},fn=(e,t,n,i,o,r,s)=>{let[a,l]=Wx(_u(e+n/2,t+i/2),_u(o,r),s);return[a-n/2,l-i/2,n,i]},Lr=e=>!(e.formFactor==="phone"&&e.userAgent.isMobileDevice),ka=e=>Lr(e)?Uu:{},Oa=([e,t,n,i,o,r],s,a,l,d={},c=4,u=Ga)=>{let m=Hu[l],p=m/a.value,h=m/a.value,f=m/a.value,g=m/a.value,E=n-e,x=i-t,b=c/a.value,y=(m-u*2)/(2*a.value),w={nw:d.nw?void 0:fn(e-b-f+y,t-b-g+y,p,h,o,r,s),ne:d.ne?void 0:fn(n+b-y,t-b-g+y,p,h,o,r,s),sw:d.sw?void 0:fn(e-b-f+y,i+b-y,p,h,o,r,s),se:d.se?void 0:fn(n+b-y,i+b-y,p,h,o,r,s),rotation:d.rotation?void 0:fn(e+E/2-p/2,t-b-g+y-Ux/a.value,p,h,o,r,s)},M=5*Hu.mouse/a.value;return Math.abs(E)>M&&(d.n||(w.n=fn(e+E/2-p/2,t-b-g+y,p,h,o,r,s)),d.s||(w.s=fn(e+E/2-p/2,i+b-y,p,h,o,r,s))),Math.abs(x)>M&&(d.w||(w.w=fn(e-b-f+y,t+x/2-h/2,p,h,o,r,s)),d.e||(w.e=fn(n+b-y,t+x/2-h/2,p,h,o,r,s))),w},Yu=(e,t,n,i="mouse",o=Uu)=>{if(e.locked||j(e))return{};if(e.type==="freedraw"||K(e)){if(e.points.length===2){let[,s]=e.points;s[0]===0||s[1]===0?o=Ca:s[0]>0&&s[1]<0?o=Wu:s[0]>0&&s[1]>0?o=Ca:s[0]<0&&s[1]>0?o=Wu:s[0]<0&&s[1]<0&&(o=Ca)}}else J(e)&&(o={...o,rotation:!0});let r=K(e)?Ga+8:ke(e)?0:Ga;return Oa(Z(e,n,!0),e.angle,t,i,o,r,ke(e)?0:void 0)},LD=(e,t,n)=>{if(t.selectedLinearElement?.isEditing||t.selectedLinearElement?.isDragging)return!1;if(e.length>1)return!0;let i=e[0];return j(i)?!1:K(i)?i.points.length>2&&!n.userAgent.isMobileDevice:!0};var Ra=(e,t,n)=>t>=e[0]&&t<=e[0]+e[2]&&n>=e[1]&&n<=e[1]+e[3],Yx=(e,t,n,i,o,r,s,a)=>{if(!n.selectedElementIds[e.id])return!1;let{rotation:l,...d}=Yu(e,r,t,s,ka(a));if(l&&Ra(l,i,o))return"rotation";let c=Object.keys(d).filter(u=>{let m=d[u];return m?Ra(m,i,o):!1});if(c.length>0)return c[0];if(Lr(a)){let[u,m,p,h,f,g]=Z(e,t);if(!(K(e)&&e.points.length<=2)){let E=ke(e)?0:Fa/r.value,x=Fa/r.value,b=ju(Pt(u-E,m-E),Pt(p+E,h+E),Pt(f,g),e.angle);for(let[y,w]of Object.entries(b))if(Xu(Pt(i,o),w,x))return y}}return!1},zD=(e,t,n,i,o,r,s,a)=>e.reduce((l,d)=>{if(l)return l;let c=Yx(d,s,t,n,i,o,r,a);return c?{element:d,transformHandleType:c}:null},null),_D=([e,t,n,i],o,r,s,a,l)=>{let d=Oa([e,t,n,i,(e+n)/2,(t+i)/2],0,s,a,ka(l)),c=Object.keys(d).find(u=>{let m=d[u];return m&&Ra(m,o,r)});if(c)return c;if(Lr(l)){let u=(e+n)/2,m=(t+i)/2,p=Fa/s.value,h=ju(Pt(e-p,t-p),Pt(n+p,i+p),Pt(u,m),0);for(let[f,g]of Object.entries(h))if(Xu(Pt(o,r),g,p))return f}return!1},Na=["ns","nesw","ew","nwse"],Xx=(e,t)=>{let n=Na.indexOf(e);if(n>=0){let i=Math.round(t/(Math.PI/4));e=Na[(n+i)%Na.length]}return e},HD=e=>{let{element:t,transformHandleType:n}=e,i=t&&Math.sign(t.height)*Math.sign(t.width)===-1,o=null;switch(n){case"n":case"s":o="ns";break;case"w":case"e":o="ew";break;case"nw":case"se":i?o="nesw":o="nwse";break;case"ne":case"sw":i?o="nwse":o="nesw";break;case"rotation":return"grab"}return o&&t&&(o=Xx(o,t.angle)),o?`${o}-resize`:""},ju=([e,t],[n,i],o,r)=>{let s=Cr(Pt(e,t),o,r),a=Cr(Pt(n,t),o,r),l=Cr(Pt(e,i),o,r),d=Cr(Pt(n,i),o,r);return{n:[s,a],e:[a,d],s:[d,l],w:[l,s]}};I();var XD=(e,t)=>!!(!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&(e.activeTool.type!=="custom"&&(e.editingTextElement||e.activeTool.type!=="selection"&&e.activeTool.type!=="lasso"&&e.activeTool.type!=="eraser"&&e.activeTool.type!=="hand"&&e.activeTool.type!=="laser")||Zt(t,e).length));I();import{pointFrom as Gr}from"@excalidraw/math";import{DEFAULT_FONT_FAMILY as jx,DEFAULT_FONT_SIZE as $x,TEXT_ALIGN as Vx,VERTICAL_ALIGN as Zx,getSizeFromPoints as Kx,randomId as qx,arrayToMap as Qx,assertNever as za,cloneJSON as Vu,getFontString as Jx,isDevEnv as eb,toBrandedType as tb,getLineHeight as nb}from"@excalidraw/common";var kr={width:100,height:0},Un=100,ib=(e,t,n)=>{let i=si({x:0,y:0,textAlign:Vx.CENTER,verticalAlign:Zx.MIDDLE,...t,containerId:e.id,strokeColor:t.strokeColor||e.strokeColor});return Object.assign(e,{boundElements:(e.boundElements||[]).concat({type:"text",id:i.id})}),Uo(i,e,n),[e,i]},$u=(e,t,n,i,o)=>{let r,s;if(Object.assign(e,{startBinding:e?.startBinding||null,endBinding:e.endBinding||null}),t){let c=t?.width??Un,u=t?.height??Un,m;t.id&&(m=i.getElement(t.id),m||console.error(`No element for start binding with id ${t.id} found`));let p=t.x||e.x-c,h=t.y||e.y-u/2,f=m?m.type:t.type;if(f){if(f==="text"){let g="";m&&m.type==="text"?g=m.text:t.type==="text"&&(g=t.text),g||console.error(`No text found for start binding text element for ${e.id}`),r=si({x:p,y:h,type:"text",...m,...t,text:g}),Object.assign(r,{x:t.x||e.x-r.width,y:t.y||e.y-r.height/2})}else switch(f){case"rectangle":case"ellipse":case"diamond":{r=Ai({x:p,y:h,width:c,height:u,...m,...t,type:f});break}default:za(e,`Unhandled element start type "${t.type}"`,!0)}Vt(e,r,"orbit","start",o)}}if(n){let c=n?.height??Un,u=n?.width??Un,m;n.id&&(m=i.getElement(n.id),m||console.error(`No element for end binding with id ${n.id} found`));let p=n.x||e.x+e.width,h=n.y||e.y-c/2,f=m?m.type:n.type;if(f){if(f==="text"){let g="";m&&m.type==="text"?g=m.text:n.type==="text"&&(g=n.text),g||console.error(`No text found for end binding text element for ${e.id}`),s=si({x:p,y:h,type:"text",...m,...n,text:g}),Object.assign(s,{y:n.y||e.y-s.height/2})}else switch(f){case"rectangle":case"ellipse":case"diamond":{s=Ai({x:p,y:h,width:u,height:c,...m,...n,type:f});break}default:za(e,`Unhandled element end type "${f}"`,!0)}Vt(e,s,"orbit","end",o)}}if(e.points.length<2)return{linearElement:e,startBoundElement:r,endBoundElement:s};let a=e.points.length-1,l=.5,d=Vu(e.points);return e.points[a][0]>e.points[a-1][0]&&(d[0][0]=l,d[a][0]-=l),e.points[a][0]<e.points[a-1][0]&&(d[0][0]=-l,d[a][0]+=l),e.points[a][1]>e.points[a-1][1]&&(d[0][1]=l,d[a][1]-=l),e.points[a][1]<e.points[a-1][1]&&(d[0][1]=-l,d[a][1]+=l),Object.assign(e,R.getNormalizeElementPointsAndCoords({...e,points:d})),{linearElement:e,startBoundElement:r,endBoundElement:s}},_a=class{excalidrawElements=new Map;add=t=>{t&&this.excalidrawElements.set(t.id,t)};getElements=()=>$s(Array.from(this.excalidrawElements.values()));getElementsMap=()=>tb(Qx(this.getElements()));getElement=t=>this.excalidrawElements.get(t)},rv=(e,t)=>{if(!e)return[];let n=Vu(e),i=new _a,o=new Map,r=new Map;for(let l of n){let d,c=l.id;switch(t?.regenerateIds!==!1&&Object.assign(l,{id:qx()}),l.type){case"rectangle":case"ellipse":case"diamond":{let m=l?.label?.text&&l.width===void 0?0:l?.width||Un,p=l?.label?.text&&l.height===void 0?0:l?.height||Un;d=Ai({...l,width:m,height:p});break}case"line":{let m=l.width||kr.width,p=l.height||kr.height;d=Lc({width:m,height:p,points:[Gr(0,0),Gr(m,p)],...l});break}case"arrow":{let m=l.width||kr.width,p=l.height||kr.height;d=br({width:m,height:p,endArrowhead:"arrow",points:[Gr(0,0),Gr(m,p)],...l,type:"arrow"}),Object.assign(d,Kx(d.points));break}case"text":{let m=l?.fontFamily||jx,p=l?.fontSize||$x,h=l?.lineHeight||nb(m),f=l.text??"",g=Zi(f),E=ft(g,Jx({fontFamily:m,fontSize:p}),h);d=si({width:E.width,height:E.height,fontFamily:m,fontSize:p,...l});break}case"image":{d=Cc({width:l?.width||Un,height:l?.height||Un,...l});break}case"frame":{d=Dc({x:0,y:0,...l});break}case"magicframe":{d=vc({x:0,y:0,...l});break}case"freedraw":case"iframe":case"embeddable":{d=l;break}default:d=l,za(l,`Unhandled element type "${l.type}"`,!0)}i.getElement(d.id)?console.error(`Duplicate id found for ${d.id}`):(i.add(d),o.set(d.id,l),c&&r.set(c,d.id))}let s=i.getElementsMap(),a=new Ci(s);for(let[l,d]of o){let c=i.getElement(l);switch(d.type){case"rectangle":case"ellipse":case"diamond":case"arrow":{if(d.label?.text){let[u,m]=ib(c,d?.label,a);if(i.add(u),i.add(m),X(u)){let p=d.type==="arrow"?d?.start:void 0,h=d.type==="arrow"?d?.end:void 0;if(p&&p.id){let x=r.get(p.id);x&&Object.assign(p,{id:x})}if(h&&h.id){let x=r.get(h.id);x&&Object.assign(h,{id:x})}let{linearElement:f,startBoundElement:g,endBoundElement:E}=$u(u,p,h,i,a);u=f,i.add(f),i.add(g),i.add(E)}}else switch(d.type){case"arrow":{let{start:u,end:m}=d;if(u&&u.id){let g=r.get(u.id);Object.assign(u,{id:g})}if(m&&m.id){let g=r.get(m.id);Object.assign(m,{id:g})}let{linearElement:p,startBoundElement:h,endBoundElement:f}=$u(c,u,m,i,a);i.add(p),i.add(h),i.add(f);break}}break}}}for(let[l,d]of o){if(d.type!=="frame"&&d.type!=="magicframe")continue;let c=i.getElement(l);if(!c)throw new Error(`Excalidraw element with id ${l} doesn't exist`);let u=[];d.children.forEach(w=>{let M=r.get(w);if(!M)throw new Error(`Element with ${w} wasn't mapped correctly`);let S=i.getElement(M);if(!S)throw new Error(`Frame element with id ${M} doesn't exist`);Object.assign(S,{frameId:c.id}),S?.boundElements?.forEach(T=>{let A=i.getElement(T.id);if(!A)throw new Error(`Bound element with id ${T.id} doesn't exist`);Object.assign(A,{frameId:c.id}),u.push(A)}),u.push(S)});let[m,p,h,f]=Je(u),g=10;m=m-g,p=p-g,h=h+g,f=f+g;let E=c?.x||m,x=c?.y||p,b=c?.width||h-m,y=c?.height||f-p;Object.assign(c,{x:E,y:x,width:b,height:y}),eb()&&d.children.length&&(c?.x||c?.y||c?.width||c?.height)&&console.info("User provided frame attributes are being considered, if you find this inaccurate, please remove any of the attributes - x, y, width and height so frame coordinates and dimensions are calculated automatically")}return i.getElements()};I();var cv=({app:e,event:t})=>{let n=e.state;if(n.selectedLinearElement&&e.lastPointerMoveCoords){if(n.selectedLinearElement.draggedFocusPointBinding)return Nu(n.selectedLinearElement,e.scene.getNonDeletedElementsMap(),e.lastPointerMoveCoords,e.scene,n,e.getEffectiveGridSize(),t.altKey),!0;if(n.selectedLinearElement.hoverPointIndex!==null&&e.lastPointerMoveEvent&&n.selectedLinearElement.initialState.lastClickedPoint>=0&&n.selectedLinearElement.isDragging)return R.handlePointDragging(e.lastPointerMoveEvent,e,e.lastPointerMoveCoords.x,e.lastPointerMoveCoords.y,n.selectedLinearElement),!0}return!1};I();var ob=e=>{switch(e){case void 0:case null:return null;case"dot":return"circle";case"crowfoot_one":return"cardinality_one";case"crowfoot_many":return"cardinality_many";case"crowfoot_one_or_many":return"cardinality_one_or_many";default:return e}},pv=e=>{let t=ob(e);return t===null?null:t};I();import{getBoundsFromPoints as Qu,getElementAbsoluteCoords as rb}from"@excalidraw/element/bounds";import{newArrowElement as Zu,newElement as sb,newLinearElement as Or}from"@excalidraw/element/newElement";import{ELEMENT_PENDING_DRAW_SHAPE_OPACITY as ab,getStrokeWidthByKey as Nr,ROUNDNESS as Ku}from"@excalidraw/common";import{convexHull as lb,distanceToLineSegment as db,elongation as cb,kurtosis as qu,lineSegment as ub,orientPrincipalAxes as mb,pointFrom as tt,polygonArea as pb,principalAxes as fb,principalCoords as hb,skewness as gb}from"@excalidraw/math";var Eb=64,xb=25,bb=.15,wb=.25,yb=.5,Pb=.15,Ib=.3,Sb=1.5,ki=3;function Mb(e,t){let n=0;for(let a=1;a<e.length;a++)n+=Math.hypot(e[a][0]-e[a-1][0],e[a][1]-e[a-1][1]);let i=n/(t-1),o=0,r=[e[0]],s=e[0];for(let a=1;a<e.length;a++){let l=e[a],d=Math.hypot(l[0]-s[0],l[1]-s[1]);if(o+d>=i){let c=i-o;for(;c<=d+1e-10;){let u=c/d,m=[s[0]+u*(l[0]-s[0]),s[1]+u*(l[1]-s[1])];if(r.push(m),r.length===t)return r;s=m,o=0,c+=i}o=d-(c-i)}else o+=d;s=l}for(;r.length<t;)r.push(e[e.length-1]);return r}function Ab(e){let t=e[0],n=t,i=0;for(let s of e){let a=Math.hypot(s[0]-t[0],s[1]-t[1]);a>i&&(i=a,n=s)}if(i===0)return 0;let o=ub(t,n),r=0;for(let s of e)Math.hypot(s[0]-n[0],s[1]-n[1])<=yb*i||(r=Math.max(r,db(s,o)));return r/i}function Tb(e){let t=[];for(let n=ki;n<e.length-ki;n++){let[i,o]=e[n-ki],[r,s]=e[n],[a,l]=e[n+ki],d=r-i,c=s-o,u=a-r,m=l-s;t.push(Math.abs(Math.atan2(d*m-c*u,d*u+c*m)))}return t}function Db(e){let t=Tb(e),n=t.reduce((r,s)=>r+s,0);if(n===0)return 0;let i=new Array(t.length).fill(!1),o=0;for(let r=0;r<4;r++){let s=-1,a=0;for(let l=0;l<t.length;l++)!i[l]&&t[l]>a&&(a=t[l],s=l);if(s<0)break;for(let l=s-ki;l<=s+ki;l++)l>=0&&l<t.length&&!i[l]&&(o+=t[l],i[l]=!0)}return o/n}function vb(e){let t=Mb(e,Eb),n=0;for(let m=1;m<t.length;m++)n+=Math.hypot(t[m][0]-t[m-1][0],t[m][1]-t[m-1][1]);let i=Math.hypot(t[t.length-1][0]-t[0][0],t[t.length-1][1]-t[0][1]),o=mb(t,fb(t)),r=hb(t,o).map(([m])=>m),s=lb(t),[a,l,d,c]=Qu(t),u=(d-a)*(c-l);return{gapRatio:n>0?i/n:0,elongation:cb(o),majorSkew:gb(r),hullFillRatio:u>0?pb(s)/u:0,cornerTurnShare:Db(t),kurtosisProduct:qu(t.map(([m])=>m))*qu(t.map(([,m])=>m)),shaftDeviationRatio:Ab(t)}}var Bb=[{type:"rectangle",hullFillRatio:1,cornerTurnShare:.95,kurtosisProduct:1.83},{type:"diamond",hullFillRatio:.5,cornerTurnShare:.95,kurtosisProduct:3.24},{type:"ellipse",hullFillRatio:Math.PI/4,cornerTurnShare:.55,kurtosisProduct:2.25}],Lb=.2,Cb=.2,Gb=.7;function kb(e){let t="freedraw",n=Sb;for(let i of Bb){let o=Math.hypot((e.hullFillRatio-i.hullFillRatio)/Lb,(e.cornerTurnShare-i.cornerTurnShare)/Cb,(e.kurtosisProduct-i.kurtosisProduct)/Gb);o<n&&(n=o,t=i.type)}return t}function Ob(e){return e.elongation>wb||e.shaftDeviationRatio>Pb?"freedraw":Math.abs(e.majorSkew)>=Ib?"arrow":"line"}function Nb(e){return e.gapRatio>bb?Ob(e):kb(e)}function Fb(e,t,n){let[i,o,r,s]=t,a=r-i,l=s-o;if(a===0&&l===0)return e[e.length-1];let d=[tt(i,o),tt((i+r)/2,o),tt(r,o),tt(r,(o+s)/2),tt(r,s),tt((i+r)/2,s),tt(i,s),tt(i,(o+s)/2)],c=-1,u=tt(r,s);for(let h of d){let f=Math.hypot(h[0]-n[0],h[1]-n[1]);f>c&&(c=f,u=h)}let m=1/0,p=e[e.length-1];for(let h of e){let f=Math.hypot(h[0]-u[0],h[1]-u[1]);f<m&&(m=f,p=h)}return p}var Rb=(e,t,n=1)=>{typeof window<"u"&&(window.LAST_POINTS=e.map(([u,m])=>tt(u,m)));let i=Qu(e),[o,r,s,a]=i,l=Math.max(s-o,a-r);if(e.length<3||l*n<xb)return{type:"freedraw",points:e,boundingBox:i};let d=Nb(vb(e));return{type:t?.type==="arrow"&&d!=="arrow"?"freedraw":d,points:e,boundingBox:i}},zb=(e,t,n,i,o)=>{let r=Rb(e,i,t.zoom.value),s=r.boundingBox,[a,l,d,c]=s,m=(o??qs([...n.values()])).find(h=>{let[f,g,E,x]=rb(h,n);return f<=a&&g<=l&&E>=d&&x>=c})?.id??null,p=t.currentItemRoundness==="round"?{type:Oo(r.type)?Ku.ADAPTIVE_RADIUS:Ku.PROPORTIONAL_RADIUS}:null;switch(r.type){case"rectangle":case"diamond":case"ellipse":return sb({type:r.type,x:r.boundingBox[0],y:r.boundingBox[1],width:r.boundingBox[2]-r.boundingBox[0],height:r.boundingBox[3]-r.boundingBox[1],groupIds:[],angle:0,frameId:m,roundness:p,roughness:t.currentItemRoughness,backgroundColor:t.currentItemBackgroundColor,strokeColor:t.currentItemStrokeColor,fillStyle:t.currentItemFillStyle,opacity:t.currentItemOpacity,strokeStyle:t.currentItemStrokeStyle,strokeWidth:Nr(r.type,t.currentItemStrokeWidthKey)});case"arrow":{let[h,f]=r.points[0],[g,E]=Fb(r.points,r.boundingBox,r.points[0]),x=tt(g-h,E-f);if(Math.hypot(g-r.points[0][0],E-r.points[0][1])<60){let M=Or({type:"line",x:h,y:f,points:[tt(r.points[0][0]-h,r.points[0][1]-f),x],groupIds:[],frameId:m,locked:!1,angle:0,roundness:p,roughness:t.currentItemRoughness,backgroundColor:t.currentItemBackgroundColor,strokeColor:t.currentItemStrokeColor,fillStyle:t.currentItemFillStyle,opacity:t.currentItemOpacity,strokeStyle:t.currentItemStrokeStyle,strokeWidth:Nr(r.type,t.currentItemStrokeWidthKey)}),S=R.getNormalizeElementPointsAndCoords(M);return Or({...M,...S})}let y=Zu({type:"arrow",x:h,y:f,startArrowhead:t.currentItemStartArrowhead,endArrowhead:t.currentItemEndArrowhead,points:[tt(r.points[0][0]-h,r.points[0][1]-f),x],groupIds:[],frameId:m,locked:!1,angle:0,roundness:p,roughness:t.currentItemRoughness,backgroundColor:t.currentItemBackgroundColor,strokeColor:t.currentItemStrokeColor,fillStyle:t.currentItemFillStyle,opacity:t.currentItemOpacity,strokeStyle:t.currentItemStrokeStyle,strokeWidth:Nr(r.type,t.currentItemStrokeWidthKey)}),w=R.getNormalizeElementPointsAndCoords(y);return Zu({...y,...w})}case"line":{let[h,f]=r.points[0],g=r.points[r.points.length-1],E=Or({type:r.type,x:h,y:f,points:[tt(r.points[0][0]-h,r.points[0][1]-f),tt(g[0]-h,g[1]-f)],groupIds:[],frameId:m,locked:!1,angle:0,roundness:p,roughness:t.currentItemRoughness,backgroundColor:t.currentItemBackgroundColor,strokeColor:t.currentItemStrokeColor,fillStyle:t.currentItemFillStyle,opacity:t.currentItemOpacity,strokeStyle:t.currentItemStrokeStyle,strokeWidth:Nr(r.type,t.currentItemStrokeWidthKey)}),x=R.getNormalizeElementPointsAndCoords(E);return Or({...E,...x})}}},_b=(e,t)=>{if(!e||e.type!==t.type||e.x!==t.x||e.y!==t.y||e.width!==t.width||e.height!==t.height||e.angle!==t.angle)return!1;if(K(e)&&K(t)){if(e.points.length!==t.points.length)return!1;for(let n=0;n<e.points.length;n++)if(e.points[n][0]!==t.points[n][0]||e.points[n][1]!==t.points[n][1])return!1}return!0},Iv=(e,t)=>{if(e.state.activeTool.type==="autoshape"){e.drawShape.trail.addPointToPath(t.x,t.y);let n=e.drawShape.trail.getCurrentPoints();if(n.length>=3){let i=zb(n,e.state,e.scene.getNonDeletedElementsMap(),e.state.newElement,e.scene.getNonDeletedFramesLikes());if(i&&!Oe(i)){let o=e.state.newElement,r={...i,id:o?.type===i.type?o.id:i.id,seed:1,opacity:ab,isDeleted:!1};_b(o,r)||e.setState({newElement:r})}else e.state.newElement!==null&&e.setState({newElement:null})}return!0}return!1};var Dv=e=>e.reduce((t,n)=>t+n.version,0),Kc=e=>{let t=5381;for(let n of Hb(e))t=(t<<5)+t+n.versionNonce;return t>>>0},qc=e=>{let t=5381;for(let n=0;n<e.length;n++){let i=e.charCodeAt(n);t=(t<<5)+t+i}return t>>>0},Ve=e=>!e.isDeleted,vv=e=>e.filter(t=>Ve(t)&&!Tc(t)),kn=e=>e.filter(Ve);export{Rn as AppStateDelta,Cf as BASE_ARROW_MIN_LENGTH,Md as BASE_BINDING_GAP,Qn as BASE_BINDING_GAP_ELBOW,ce as BASE_PADDING,vn as BindableElement,Dn as BoundElement,ut as CaptureUpdateAction,Wg as DEFAULT_BUCKET_FILL_OPTIONS,jI as DEFAULT_LINK_SIZE,Uu as DEFAULT_OMIT_SIDES,$ as Delta,Ea as DurableIncrement,aa as ElementBounds,zn as ElementsDelta,xa as EphemeralIncrement,no as FOCUS_POINT_SIZE,Pu as FlowChartCreator,yu as FlowChartNavigator,Be as HEADING_DOWN,Ne as HEADING_LEFT,he as HEADING_RIGHT,Ze as HEADING_UP,Eg as INVISIBLY_SMALL_ELEMENT_SIZE,Xs as InvalidFractionalIndexError,R as LinearElementEditor,ze as MINIMAL_CROP_SIZE,BD as OMIT_SIDES_FOR_FRAME,vD as OMIT_SIDES_FOR_MULTIPLE_ELEMENTS,Ci as Scene,Et as ShapeCache,$c as Store,mo as StoreChange,ba as StoreDelta,Sr as StoreIncrement,_n as StoreSnapshot,lt as aabbForElement,Ph as addElementsToFrame,G1 as addToGroup,jS as alignElements,zf as avoidRectangularCorner,Vt as bindBindingElement,u1 as bindBindingElementToFixedPoint,nc as bindElementsToFramesAfterDuplication,Gf as bindOrUnbindBindingElement,a1 as bindOrUnbindBindingElements,ks as bindPointToSnapToElementOutline,Bd as bindingProperties,Qs as boundsContainBounds,xd as bumpVersion,Wf as calculateFixedPointForElbowArrowBinding,yi as calculateFixedPointForNonElbowArrowBinding,t0 as canApplyRoundnessTypeToElement,Bl as canBecomePolygon,$l as canChangeRoundness,nx as canCreateLinkFromElements,aP as canHaveArrowheads,Lr as canResizeFromSides,fi as charWidth,fe as compareHeading,Ki as computeBoundTextPosition,CM as computeBucketFillPolygon,ps as computeContainerDimensionForBoundText,B0 as containsCJK,rv as convertToExcalidrawElements,zb as convertToShape,Iv as convertToShapeHandlePointerMoveFromPointerDown,sT as createPlaceholderEmbeddableLabel,Ia as createSrcDoc,$y as cropElement,Pn as deconstructDiamondElement,No as deconstructLinearOrFreeDrawElement,yn as deconstructRectanguloidElement,ga as deepCopyElement,ZA as defaultGetElementLinkFromSelection,I0 as detectLineHeight,Ut as distanceToElement,CA as distributeElements,gt as doBoundsIntersect,YA as dragNewElement,tx as dragNewTextElement,WA as dragSelectedElements,uE as duplicateElement,VM as duplicateElements,C1 as editGroupForSelectedElement,re as elementCenterPoint,Ln as elementOverlapsWithFrame,oo as elementWithCanvasCache,Gn as elementsAreInFrameBounds,jd as elementsAreInSameGroup,Kd as elementsOverlappingBBox,lT as embeddableURLValidator,uh as excludeElementsInFramesFromSelection,MI as filterElementsEligibleAsFrameChildren,d1 as fixBindingsAfterDeletion,vd as fixDuplicatedBindingsAfterDuplication,Ss as flipHeading,LI as frameAndChildrenSelectedTogether,Fl as generateLinearCollisionShape,ct as generateRoughOptions,K1 as getActiveTextElement,Xo as getAllHoveredElementAtPoint,Wl as getApproxMinLineHeight,Hl as getApproxMinLineWidth,Ld as getArrowLocalFixedPoints,cg as getArrowheadAngle,pv as getArrowheadForPicker,et as getArrowheadPoints,dg as getArrowheadSize,ve as getBindingGap,c1 as getBindingSideMidPoint,zs as getBindingStrategyForDraggingBindingElementEndpoints,de as getBoundTextElement,Bt as getBoundTextElementId,U0 as getBoundTextElementPosition,qi as getBoundTextMaxHeight,vt as getBoundTextMaxWidth,oi as getBoundsFromPoints,an as getCenterForBounds,un as getCommonBoundingBox,Je as getCommonBounds,wh as getCommonFrameId,H0 as getContainerCenter,fs as getContainerCoords,Ue as getContainerElement,Cn as getContainingFrame,nn as getCornerRadius,jo as getCubicBezierCurveBound,HD as getCursorForResizingElement,Th as getDefaultFrameName,n0 as getDefaultRoundnessTypeForElement,Nl as getDiamondBaseCorners,pi as getDiamondPoints,UA as getDragOffsetXY,vS as getDraggedElementsBounds,Z as getElementAbsoluteCoords,ue as getElementBounds,Ii as getElementLineSegments,Ws as getElementPointsCoords,Ec as getElementShape,zD as getElementWithTransformHandleType,ic as getElementsCompletelyInFrame,Qe as getElementsInGroup,SI as getElementsInNewFrame,II as getElementsInResizingFrame,EI as getElementsIntersectingFrame,BI as getElementsOverlappingFrame,Zd as getElementsWithinSelection,rT as getEmbedLink,xM as getEndpointBoundTextDragAnchor,Vy as getFlipAdjustedCropPosition,Bn as getFrameChildren,yh as getFrameChildrenInsertionIndex,qs as getFrameLikeElements,vI as getFrameLikeTitle,ZI as getFreedrawOutlineAsSegments,eg as getFreedrawOutlinePoints,xc as getFreedrawStrokeCenterPoints,He as getGlobalFixedPointForBindableElement,Uf as getGlobalFixedPoints,Ed as getHeadingForElbowArrowSnap,sn as getHoveredElementForBinding,rd as getHoveredElementForFocusPoint,tD as getInitializedImageElements,_o as getLineHeightInPx,In as getLineWidth,i0 as getLinearElementSubType,KA as getLinkIdAndTypeFromSelection,Wd as getLockedLinearCursorAlignSize,gp as getMaxCharWidth,O1 as getMaximumGroups,M0 as getMinCharWidth,io as getMinMaxXYFromCurvePathOps,zo as getMinTextElementWidth,Vd as getNewGroupIdsForDuplication,kn as getNonDeletedElements,Xd as getNonDeletedGroupIds,zS as getNormalizedDimensions,Li as getObservedAppState,ka as getOmitSidesForEditorInterface,x0 as getOriginalContainerHeightFromCache,la as getPerfectElementSize,DS as getRectangleBoxAbsoluteCoords,Rh as getRenderOpacity,PD as getResizeArrowDirection,yD as getResizeOffsetXY,wn as getResizedElementAbsoluteCoords,PI as getRootElements,Dv as getSceneVersion,Zt as getSelectedElements,ar as getSelectedElementsByGroup,Ys as getSelectedGroupForElement,sh as getSelectedGroupIdForElement,oh as getSelectedGroupIds,Z1 as getSelectionStateForElements,dp as getSnapOutlineMidPoint,V1 as getTargetElements,Sh as getTargetFrame,da as getTextAnchorRatios,gM as getTextBindingForArrowEndpoint,W0 as getTextElementAngle,$0 as getTextFromElements,hp as getTextHeight,Ul as getTextWidth,_D as getTransformHandleTypeFromCoords,Yu as getTransformHandles,Oa as getTransformHandlesFromCoords,hM as getUnboundArrowEndpointAtPoint,Pl as getUncroppedImageElement,es as getUncroppedWidthAndHeight,j1 as getVisibleAndNonSelectedElements,vv as getVisibleElements,BS as getVisibleSceneBounds,Mp as getWrappedTextLines,yI as groupByFrameLikes,bI as groupsAreAtLeastIntersectingTheFrame,wI as groupsAreCompletelyOutOfFrame,qn as handleBindTextResize,Nu as handleFocusPointDrag,ZT as handleFocusPointHover,$T as handleFocusPointPointerDown,VT as handleFocusPointPointerUp,hi as hasBackground,_t as hasBoundTextElement,LD as hasBoundingBox,rP as hasFreedrawMode,nP as hasStrokeColor,oP as hasStrokeStyle,iP as hasStrokeWidth,Kc as hashElementsVersion,qc as hashString,st as headingForPoint,gi as headingForPointFromElement,Lt as headingForPointIsHorizontal,at as headingIsHorizontal,DP as headingIsVertical,Jp as hitElementBoundText,Qp as hitElementBoundingBox,PP as hitElementBoundingBoxOnly,Ht as hitElementItself,ot as intersectElementWithLineSegment,e0 as isArrowBoundToElement,X as isArrowElement,we as isBindableElement,Ps as isBindableElementInsideOtherBindable,_e as isBindingElement,Qm as isBindingElementType,$t as isBindingEnabled,Ie as isBoundToContainer,Uc as isBucketFillCompatible,xI as isCursorInFrame,Km as isCurvedArrow,j as isElbowArrow,RS as isElementCompletelyInViewport,Ks as isElementContainingFrame,rc as isElementInFrame,rh as isElementInGroup,qd as isElementInViewport,Si as isElementIntersectingFrame,qA as isElementLink,o0 as isEligibleFrameChildType,Sl as isEmbeddableElement,EM as isEndpointBoundText,Tl as isExcalidrawElement,Yf as isFixedPoint,Dl as isFlowchartNodeElement,Tr as isFocusPointVisible,ko as isFrameElement,J as isFrameLikeElement,be as isFreeDrawElement,Vm as isFreeDrawElementType,Cx as isHTMLSVGElement,Co as isIframeElement,Go as isIframeLikeElement,ke as isImageElement,$d as isInGroup,Vn as isInitializedImageElement,Tc as isInvisiblySmallElement,Oe as isLineElement,K as isLinearElement,qm as isLinearElementType,Ml as isMagicFrameElement,P0 as isMeasureTextSupported,PT as isNodeInFlowchart,Ve as isNonDeletedElement,Tt as isPathALoop,it as isPointInElement,ji as isRectangularElement,Al as isRectanguloidElement,GM as isRestylableFill,ih as isSelectedViaGroup,Zm as isSharpArrow,Jy as isSimpleArrow,$1 as isSomeElementSelected,Jm as isTextBindableContainer,oe as isTextElement,Oo as isUsingAdaptiveRadius,vl as isUsingProportionalRadius,ts as isValidPolygon,j0 as isValidTextContainer,Lx as loadHTMLImageElement,Us as makeNextSelectedElementIds,Dt as maxBindingDistance_simple,cv as maybeHandleArrowPointlikeDrag,aT as maybeParseEmbedSrc,La as measureFontSizeFromWidth,ft as measureText,NT as moveAllLeft,FT as moveAllRight,vu as moveArrowAboveBindable,kT as moveOneLeft,OT as moveOneRight,Fe as mutateElement,br as newArrowElement,Ai as newElement,Ke as newElementWith,nM as newEmbeddableElement,Dc as newFrameElement,rM as newFreeDrawElement,iM as newIframeElement,Cc as newImageElement,Lc as newLinearElement,vc as newMagicFrameElement,si as newTextElement,ob as normalizeArrowhead,Yc as normalizeElementOrder,We as normalizeFixedPoint,nD as normalizeSVG,Zi as normalizeText,dr as omitGroupsContainingFrameLikes,bh as omitPartialGroups,Jd as orderByFractionalIndex,Vi as originalContainerCache,QA as parseElementLinkFromURL,Ip as parseTokens,Yt as pointInsideBounds,pg as pointInsideBoundsInclusive,aD as positionElementsOnGrid,as as projectFixedPointOntoDiagonal,Rb as recognizeShape,Uo as redrawTextBoundingBox,oM as refreshTextDimensions,Ih as removeAllElementsFromFrame,oc as removeElementsFromFrame,k1 as removeFromSelectedGroups,VI as renderElement,$I as renderSelectionElement,Rc as rendersOpaqueFill,AI as replaceAllElementsInFrame,zu as rescalePointsInElement,zl as resetOriginalContainerCache,Hx as resizeMultipleElements,Rx as resizeSingleElement,Ox as resizeSingleTextElement,Yx as resizeTest,nh as selectGroup,Ud as selectGroupsForSelectedElements,Yd as selectGroupsFromGivenElements,S0 as setCustomTextMetricsProvider,Y0 as shouldAllowVerticalAlign,DI as shouldApplyFrameClip,Yo as shouldTestInside,XD as showSelectedShapeActions,_s as snapToMid,X0 as suppportsHorizontalAlign,$s as syncInvalidIndices,ec as syncInvalidIndicesImmutable,ni as syncMovedIndices,Hd as toggleLinePolygonState,sP as toolIsArrow,wD as transformElements,Xe as unbindBindingElement,l1 as updateBindings,je as updateBoundElements,Ct as updateBoundPoint,xi as updateElbowArrowPoints,TI as updateFrameMembershipOfSelectedElements,eD as updateImageCache,Rl as updateOriginalContainerCache,gd as validateElbowPoints,hh as validateFractionalIndices,Xt as vectorToHeading,rn as wrapText};
28
+ `),intrinsicSize:{w:550,h:720},sandbox:{allowSameOrigin:n}};return Ot.set(e,p),p}return Ot.set(e,{link:e,intrinsicSize:o,type:i,sandbox:{allowSameOrigin:n}}),{link:e,intrinsicSize:o,type:i,sandbox:{allowSameOrigin:n}}},sT=e=>{let t;Co(e)?t="IFrame element":t=!e.link||e?.link===""?"Empty Web-Embed":e.link;let n=Math.max(Math.min(e.width/2,e.width/t.length),e.width/30),i=ix.Helvetica,o=rx({fontSize:n,fontFamily:i});return si({x:e.x+e.width/2,y:e.y+e.height/2,strokeColor:e.strokeColor!=="transparent"?e.strokeColor:"black",backgroundColor:"transparent",fontFamily:i,fontSize:n,text:rn(t,o,e.width-20),textAlign:"center",verticalAlign:ox.MIDDLE,angle:e.angle??0})},Ma=(e,t)=>{try{let{hostname:n}=new URL(e),i=n.replace(/^www\./,"");if(t instanceof Set){if(Sa.has(i))return i;let r=i.replace(/^([^.]+)/,"*");return Sa.has(r)?r:null}let o=t.replace(/^www\./,"");if(i===o)return o}catch{}return null},aT=e=>{let t=e.match(ux);if(t&&t.length===2)return t[1];let n=e.match(fx);if(n&&n.length===2)return n[1];let i=e.match(dx);if(i&&i.length===2)return i[1];if(fu.test(e))return`https://giphy.com/embed/${fu.exec(e)[1]}`;let o=e.match(px);return o&&o.length===2?o[1]:e},lT=(e,t)=>{if(!e)return!1;if(t!=null)if(typeof t=="function"){let n=t(e);if(typeof n=="boolean")return n}else{if(typeof t=="boolean")return t;if(t instanceof RegExp)return t.test(e);if(Array.isArray(t)){for(let n of t)if(n instanceof RegExp){if(e.match(n))return!0}else if(Ma(e,n))return!0;return!1}}return!!Ma(e,Sa)};I();import{invariant as Aa,toBrandedType as gx}from"@excalidraw/common";import{clamp as Ex,pointFrom as xu}from"@excalidraw/math";var bu=100,wu=100,xx=e=>{let t=[...e].sort((i,o)=>i.start-o.start),n=[];for(let i of t){let o=n[n.length-1];o&&i.start<=o.end?o.end=Math.max(o.end,i.end):n.push({...i})}return n},Iu=(e,t,n)=>n.every(i=>e+t<=i.start||e>=i.end),bx=(e,t,n)=>{if(Iu(e,t,n))return e;let i=[-1/0,...n.map(a=>a.end)],o=[...n.map(a=>a.start),1/0],r=e,s=1/0;for(let a=0;a<i.length;a++){if(o[a]-i[a]<t)continue;let l=Ex(e,i[a],o[a]-t),d=Math.abs(l-e);d<=s&&(r=l,s=d)}return r},wx=(e,t)=>{let n=[...t.values()].filter(j),i=new Set([e.id]),o=[e.id],r=[];for(;o.length>0;){let s=o.shift();for(let a of n){let l=a.startBinding?.elementId,d=a.endBinding?.elementId,c;if(l===s?c=d:d===s&&(c=l),!c||i.has(c))continue;i.add(c);let u=t.get(c);u&&we(u)&&(r.push(u),o.push(c))}}return r},yx=(e,t,n,i,o)=>{let r=t==="left"||t==="right",s=r?e.width:e.height,a=r?e.height:e.width,l=r?wu:bu,d=r?bu:wu,c=r?e.x:e.y,u=r?e.y+e.height/2:e.x+e.width/2,m=t==="right"||t==="down"?c+s+l:c-l-s,p=xx(i.filter(b=>{let y=r?b[0]:b[1],w=r?b[2]:b[3];return y<m+s&&w>m}).map(b=>({start:(r?b[1]:b[0])-d,end:(r?b[3]:b[2])+d}))),h=a+d,f=n*a+(n-1)*d,E=(o===null?null:[o,o-h].filter(b=>Iu(b,f,p)).sort((b,y)=>Math.abs(b+f/2-u)-Math.abs(y+f/2-u))[0]??null)??bx(u-f/2,f,p);return{positions:Array.from({length:n},(b,y)=>{let w=E+y*h;return r?{x:m,y:w}:{x:w,y:m}}),crossStart:E}},Px=(e,t,n)=>{let i=Ai({type:e.type,x:t,y:n,width:e.width,height:e.height,roundness:e.roundness,roughness:e.roughness,backgroundColor:e.backgroundColor,strokeColor:e.strokeColor,strokeWidth:e.strokeWidth,opacity:e.opacity,fillStyle:e.fillStyle,strokeStyle:e.strokeStyle});return Aa(Dl(i),"not an ExcalidrawFlowchartNodeElement"),i},Ix=(e,t,n,i,o,r=null)=>{let s=i.getNonDeletedElementsMap(),a=wx(e,s).map(u=>lt(u,s)),{positions:l,crossStart:d}=yx(e,n,o,a,r),c=[];for(let u of l){let m=Px(e,u.x,u.y),p=Sx(e,m,n,t,i);c.push(m,p)}return{nodes:c,crossStart:d}},Sx=(e,t,n,i,o)=>{let r,s;switch(n){case"up":{r=e.x+e.width/2,s=e.y-6;break}case"down":{r=e.x+e.width/2,s=e.y+e.height+6;break}case"right":{r=e.x+e.width+6,s=e.y+e.height/2;break}case"left":{r=e.x-6,s=e.y+e.height/2;break}}let l,d;switch(n){case"up":{l=t.x+t.width/2-r,d=t.y+t.height-s+6;break}case"down":{l=t.x+t.width/2-r,d=t.y-s-6;break}case"right":{l=t.x-r-6,d=t.y-s+t.height/2;break}case"left":{l=t.x+t.width-r+6,d=t.y-s+t.height/2;break}}let c=br({type:"arrow",x:r,y:s,startArrowhead:null,endArrowhead:i.currentItemEndArrowhead,strokeColor:e.strokeColor,strokeStyle:e.strokeStyle,strokeWidth:e.strokeWidth,opacity:e.opacity,roughness:e.roughness,points:[xu(0,0),xu(l,d)],elbowed:!0}),u=o.getNonDeletedElementsMap();Vt(c,e,"orbit","start",o),Vt(c,t,"orbit","end",o);let m=new Map;m.set(e.id,e),m.set(t.id,t),m.set(c.id,c),R.movePoints(c,o,new Map([[1,{point:c.points[1]}]]));let p=xi(c,gx(new Map([...u.entries(),[e.id,e],[t.id,t],[c.id,c]])),{points:c.points});return{...c,...p,isDeleted:c.isDeleted}},yu=class e{isExploring=!1;sameLevelNodes=[];sameLevelIndex=0;direction=null;visitedNodes=new Set;clear(){this.isExploring=!1,this.sameLevelNodes=[],this.sameLevelIndex=0,this.direction=null,this.visitedNodes.clear()}exploreByDirection(t,n,i){if(!we(t))return null;if(i!==this.direction&&this.clear(),this.visitedNodes.has(t.id)||this.visitedNodes.add(t.id),this.isExploring&&i===this.direction&&this.sameLevelNodes.length>1)return this.sameLevelIndex=(this.sameLevelIndex+1)%this.sameLevelNodes.length,this.sameLevelNodes[this.sameLevelIndex].id;let o=[...e.getSuccessors(t,n,i),...e.getPredecessors(t,n,i)];if(o.length>0)return this.sameLevelIndex=0,this.isExploring=!0,this.sameLevelNodes=o,this.direction=i,this.visitedNodes.add(o[0].id),o[0].id;if(i===this.direction||!this.isExploring){this.isExploring||this.visitedNodes.add(t.id);let s=["up","right","down","left"].filter(a=>a!==i).map(a=>[...e.getSuccessors(t,n,a),...e.getPredecessors(t,n,a)]).flat().filter(a=>!this.visitedNodes.has(a.id));for(let a of s)if(!this.visitedNodes.has(a.id))return this.visitedNodes.add(a.id),this.isExploring=!0,this.direction=i,a.id}return null}static getNodeRelatives(t,n,i,o){let r=[...i.values()].reduce((s,a)=>{let l;if(j(a)&&(l=a[t==="predecessors"?"startBinding":"endBinding"])&&a[t==="predecessors"?"endBinding":"startBinding"]?.elementId===n.id){let d=i.get(l.elementId);if(!d)return s;Aa(we(d),"not an ExcalidrawBindableElement");let c=t==="predecessors"?a.points[a.points.length-1]:[0,0],u=gi(n,lt(n,i),[c[0]+a.x,c[1]+a.y]);s.push({relative:d,heading:u})}return s},[]);switch(o){case"up":return r.filter(s=>fe(s.heading,Ze)).map(s=>s.relative);case"down":return r.filter(s=>fe(s.heading,Be)).map(s=>s.relative);case"right":return r.filter(s=>fe(s.heading,he)).map(s=>s.relative);case"left":return r.filter(s=>fe(s.heading,Ne)).map(s=>s.relative)}}static getSuccessors(t,n,i){return e.getNodeRelatives("successors",t,n,i)}static getPredecessors(t,n,i){return e.getNodeRelatives("predecessors",t,n,i)}},Pu=class{isCreatingChart=!1;numberOfNodes=0;direction=null;clusterCrossStart=null;pendingNodes=null;createNodes(t,n,i,o){let r=o.getNonDeletedElementsMap();i!==this.direction?(this.numberOfNodes=1,this.clusterCrossStart=null):this.numberOfNodes+=1;let{nodes:s,crossStart:a}=Ix(t,n,i,o,this.numberOfNodes,this.clusterCrossStart);if(this.isCreatingChart=!0,this.direction=i,this.clusterCrossStart=a,this.pendingNodes=s,t.frameId){let l=r.get(t.frameId);Aa(l&&ko(l),"not an ExcalidrawFrameElement"),l&&this.pendingNodes.every(d=>Gn([d],l,r)||Ln(d,l,r))&&(this.pendingNodes=this.pendingNodes.map(d=>Fe(d,r,{frameId:t.frameId})))}}clear(){this.isCreatingChart=!1,this.pendingNodes=null,this.direction=null,this.numberOfNodes=0,this.clusterCrossStart=null}},PT=(e,t)=>{for(let[,n]of t)if(n.type==="arrow"&&(n.startBinding?.elementId===e.id||n.endBinding?.elementId===e.id))return!0;return!1};I();import{pointDistance as Gi,pointFrom as Da}from"@excalidraw/math";import{invariant as Ou}from"@excalidraw/common";I();import{arrayToMap as Mu,findIndex as Au,findLastIndex as Tu}from"@excalidraw/common";import{isFiniteNumber as Mx}from"@excalidraw/math";var Ta=(e,t)=>e.frameId===t||e.id===t,Du=(e,t,n)=>{let i=[],o=[],r=null,s=-1,a=Mu(n||Zt(e,t,{includeBoundTextElement:!0,includeElementsInFrames:!0}));for(;++s<e.length;){let l=e[s];a.get(l.id)?(o.length&&(i=i.concat(o),o=[]),i.push(s),r=s+1):l.isDeleted&&r===s?(r=s+1,o.push(s)):o=[]}return i},Ax=e=>{let t=0;return e.reduce((n,i,o)=>(o>0&&e[o-1]!==i-1&&(t=++t),(n[t]||(n[t]=[])).push(i),n),[])},Su=(e,t,n,i)=>{if("containerId"in e&&e.containerId){let o=i.getElement(e.containerId);if(o)return n==="left"?Math.min(t.indexOf(o),t.indexOf(e)):Math.max(t.indexOf(o),t.indexOf(e))}else{let o=e.boundElements?.find(r=>r.type!=="arrow")?.id;if(o){let r=i.getElement(o);if(r)return n==="left"?Math.min(t.indexOf(r),t.indexOf(e)):Math.max(t.indexOf(r),t.indexOf(e))}}},Tx=(e,t)=>{let n=-1,i=-1;return e.forEach((o,r)=>{Ta(o,t)&&(n===-1&&(n=r),i=r)}),n===-1?[]:e.slice(n,i+1)},vu=(e,t,n,i,o,r)=>{let s=r||sn(e,kn(n),i);if(!s)return n;let a=de(s,i),l=oe(s)?Ue(s,i):null,d=[s.id,a?.id,l?.id].filter(m=>!!m),c=n.findIndex(m=>d.includes(m.id)),u=n.findIndex(m=>m.id===t.id);if(u!==-1&&c!==-1&&u<c){let m=Array.from(n),p=m.splice(u,1)[0];m.splice(c,0,p),o.replaceAllElements(m)}return n},Dx=(e,t,n,i,o,r)=>{let s=t[n],a=m=>m.isDeleted?!1:o?m.frameId===o:e.editingGroupId?m.groupIds.includes(e.editingGroupId):!0,l=i==="left"?Tu(t,m=>a(m),Math.max(0,n-1)):Au(t,m=>a(m),n+1),d=t[l];if(!d)return-1;if(e.editingGroupId){if(s?.groupIds.join("")===d?.groupIds.join(""))return Su(d,t,i,r)??l;if(!d?.groupIds.includes(e.editingGroupId))return-1}if(!o&&(d.frameId||J(d))){let m=Tx(t,d.frameId||d.id);return i==="left"?t.indexOf(m[0]):t.indexOf(m[m.length-1])}if(!d.groupIds.length)return Su(d,t,i,r)??l;let c=e.editingGroupId?d.groupIds[d.groupIds.indexOf(e.editingGroupId)-1]:d.groupIds[d.groupIds.length-1],u=Qe(t,c);return u.length?i==="left"?t.indexOf(u[0]):t.indexOf(u[u.length-1]):l},Bu=(e,t)=>t.reduce((n,i)=>{let o=e[i];return n.set(o.id,o),n},new Map),Lu=(e,t)=>{if(e.length!==t.length)return console.error("z-index reordering failed: resulting array have different lengths"),!1;let n=new Map;for(let i of e)n.set(i.id,(n.get(i.id)||0)+1);for(let i of t){let o=n.get(i.id);if(!o)return console.error("z-index reordering failed: element id mismatch / duplicate ids"),!1;n.set(i.id,o-1)}return!0},Cu=(e,t,n,i)=>{let o=e,r=Du(e,t),s=Bu(e,r),a=Ax(r);n==="right"&&(a=a.reverse());let l=new Set(r.filter(d=>J(e[d])).map(d=>e[d].id));return a.forEach((d,c)=>{let u=d[0],m=d[d.length-1],p=n==="left"?u:m,h=d.some(y=>{let w=e[y];return w.frameId&&l.has(w.frameId)})?null:e[p]?.frameId,f=Dx(t,e,p,n,h,i);if(f===-1||p===f)return;let g=n==="left"?e.slice(0,f):e.slice(0,u),E=e.slice(u,m+1),x=n==="left"?e.slice(f,u):e.slice(m+1,f+1),b=n==="left"?e.slice(m+1):e.slice(f+1);e=n==="left"?[...g,...E,...x,...b]:[...g,...x,...E,...b]}),Lu(o,e)?(ni(e,s),e):o},Gu=(e,t,n,i,o)=>{let r=Du(e,t,o);if(r.length===0)return e;let s=Bu(e,r),a=[],l,d;if(n==="left"){if(i)l=Au(e,f=>Ta(f,i));else if(t.editingGroupId){let f=Qe(e,t.editingGroupId);if(!f.length)return e;l=e.indexOf(f[0])}else l=0;d=r[r.length-1]}else{if(i)d=Tu(e,f=>Ta(f,i));else if(t.editingGroupId){let f=Qe(e,t.editingGroupId);if(!f.length)return e;d=e.indexOf(f[f.length-1])}else d=e.length-1;l=r[0]}l===-1&&(l=0);let c=f=>Mx(f)&&f>=0;if(!c(l)||!c(d)||l>d||r.some(f=>f<l||f>d))return e;for(let f=l;f<d+1;f++)r.includes(f)||a.push(e[f]);let u=Array.from(s.values()),m=e.slice(0,l),p=e.slice(d+1),h=n==="left"?[...m,...u,...a,...p]:[...m,...a,...u,...p];return Lu(e,h)?(ni(h,s),h):e};function ku(e,t,n,i){let o=Mu(Zt(e,t,{includeBoundTextElement:!0,includeElementsInFrames:!0})),r={regularElements:[],frameChildren:new Map},s=new Set;for(let d of e)o.has(d.id)&&J(d)&&s.add(d.id);for(let d of e)if(o.has(d.id))if(J(d)||d.frameId&&s.has(d.frameId))r.regularElements.push(d);else if(!d.frameId)r.regularElements.push(d);else{let c=r.frameChildren.get(d.frameId)||[];c.push(d),r.frameChildren.set(d.frameId,c)}let a=e,l=Array.from(r.frameChildren.entries());for(let[d,c]of l)a=i(a,t,n,d,c);return i(a,t,n,null,r.regularElements)}var kT=(e,t,n)=>Cu(e,t,"left",n),OT=(e,t,n)=>Cu(e,t,"right",n),NT=(e,t)=>ku(e,t,"left",Gu),FT=(e,t)=>ku(e,t,"right",Gu);var Tr=(e,t,n,i,o,r,s=!1)=>{if(j(t)||!$t(o)||t.points.length!==2)return!1;if(!s){let l=t.startBinding?.elementId===n.id?0:t.points.length-1,d=R.getPointAtIndexGlobalCoordinates(t,l,i);if(Gi(e,d)<no*1.5/o.zoom.value)return!1}let a=R.getPointAtIndexGlobalCoordinates(t,r==="end"?t.points.length-1:0,i);return Gi(e,a)>=no*1.5/o.zoom.value&&Ht({element:n,elementsMap:i,point:e,threshold:ve(n,t),overrideShouldTestInside:!0})},vx=(e,t,n,i,o,r,s)=>{let a=new Map,l=r.selectedLinearElement?.initialState.arrowOtherEndpointInitialBinding,d=n?"startBinding":"endBinding",c=n?"endBinding":"startBinding",u=e[d],m=l?.mode==="orbit"&&e[c]?.mode==="inside"?l:e[c];if(u&&t){let p=t&&m&&u.elementId===m.elementId;s||p?u={...u,mode:"inside"}:u={...u,mode:"orbit"};let h=n?0:e.points.length-1,f=Ct(e,d,u,t,i,!0);f&&a.set(h,{point:f})}if(m&&m.mode==="orbit"){let p=i.get(m.elementId);if(p&&we(p)&&$t(r)){t&&m.elementId===t.id?m={...m,mode:"inside"}:m={...m,mode:"orbit"};let f=n?e.points.length-1:0,g=Ct(e,c,m,p,i);g&&a.set(f,{point:g})}}a.size>0&&R.movePoints(e,o,a,{[d]:u,[c]:m})},Nu=(e,t,n,i,o,r,s)=>{let a=R.getElement(e.elementId,t);if(!a||!_e(a)||j(a)||!e.hoveredFocusPointBinding||!e.draggedFocusPointBinding)return;let l=e.draggedFocusPointBinding==="start",d=l?a.startBinding:a.endBinding,{x:c,y:u}=e.pointerOffset,m=Da(n.x-c,n.y-u),p=l?"startBinding":"endBinding",h=rd(m,a,i.getNonDeletedElements(),t,Dt(o.zoom));if(h&&$t(o)){a[p]&&h.id!==d?.elementId&&Xe(a,e.draggedFocusPointBinding,i);let f=s&&a[p]?.mode==="orbit"?"inside":!s&&a[p]?.mode==="inside"?"orbit":null;(!a[p]||f)&&Vt(a,h,f||"orbit",e.draggedFocusPointBinding,i,m),i.mutateElement(a,{[p]:{...a[p],elementId:h.id,mode:f||a[p]?.mode||"orbit",...yi(a,h,e.draggedFocusPointBinding,t,m)}})}else{let f=new Map,g=l?0:a.points.length-1;f.set(g,{point:R.createPointAt(a,t,m[0],m[1],r)}),R.movePoints(a,i,f),a[p]&&Xe(a,l?"start":"end",i)}vx(a,h,l,t,i,o,s),h&&$t(o)&&vu(m,a,i.getElementsIncludingDeleted(),t,i,h)},$T=(e,t,n,i)=>{let o=Da(t.origin.x,t.origin.y),r=no*1.5/i.zoom.value;if(e.startBinding?.elementId){let s=n.get(e.startBinding.elementId);if(s&&we(s)&&!s.isDeleted){let a=He(e.startBinding.fixedPoint,s,n);if(Tr(a,e,s,n,i,"start")&&Gi(o,a)<=r)return{hitFocusPoint:"start",pointerOffset:{x:o[0]-a[0],y:o[1]-a[1]},arrowOtherEndpointInitialBinding:e.endBinding}}}if(e.endBinding?.elementId){let s=n.get(e.endBinding.elementId);if(s&&we(s)&&!s.isDeleted){let a=He(e.endBinding.fixedPoint,s,n);if(Tr(a,e,s,n,i,"end")&&Gi(o,a)<=r)return{hitFocusPoint:"end",pointerOffset:{x:o[0]-a[0],y:o[1]-a[1]},arrowOtherEndpointInitialBinding:e.startBinding}}}return{hitFocusPoint:null,pointerOffset:{x:0,y:0},arrowOtherEndpointInitialBinding:null}},VT=(e,t)=>{Ou(e.draggedFocusPointBinding,"Must have a dragged focus point at pointer release");let n=R.getElement(e.elementId,t.getNonDeletedElementsMap());Ou(n,"Arrow must be in the scene");let i=e.draggedFocusPointBinding==="start"?"startBinding":"endBinding",o=e.draggedFocusPointBinding==="start"?"endBinding":"startBinding",r=n[i]?.elementId,s=n[o]?.elementId,a=r&&t.getNonDeletedElements().find(d=>d.id!==r&&d.id!==s&&we(d)&&d.boundElements?.find(({id:c})=>c===n.id));a&&t.mutateElement(a,{boundElements:a.boundElements?.filter(({id:d})=>d!==n.id)});let l=r&&t.getNonDeletedElementsMap().get(r);return l&&t.mutateElement(l,{boundElements:[...(l.boundElements||[])?.filter(({id:d})=>d!==n.id),{id:n.id,type:"arrow"}]}),{arrowOtherEndpointInitialBinding:null}},ZT=(e,t,n,i,o)=>{let r=i.getNonDeletedElementsMap(),s=Da(t,n),a=no*1.5/o.zoom.value;if(e.startBinding?.elementId){let l=r.get(e.startBinding.elementId);if(l&&we(l)&&!l.isDeleted){let d=He(e.startBinding.fixedPoint,l,r);if(Tr(d,e,l,r,o,"start")&&Gi(s,d)<=a)return"start"}}if(e.endBinding?.elementId){let l=r.get(e.endBinding.elementId);if(l&&we(l)&&!l.isDeleted){let d=He(e.endBinding.fixedPoint,l,r);if(Tr(d,e,l,r,o,"end")&&Gi(s,d)<=a)return"end"}}return null};I();import{MIME_TYPES as Fu,SVG_NS as Bx}from"@excalidraw/common";var Lx=e=>new Promise((t,n)=>{let i=new Image;i.onload=()=>{t(i)},i.onerror=o=>{n(o)},i.src=e}),eD=async({fileIds:e,files:t,imageCache:n})=>{let i=new Map,o=new Map;return await Promise.all(e.reduce((r,s)=>{let a=t[s];return a&&!i.has(s)?(i.set(s,!0),r.concat((async()=>{try{if(a.mimeType===Fu.binary)throw new Error("Only images can be added to ImageCache");let l=Lx(a.dataURL),d={image:l,mimeType:a.mimeType};n.set(s,d);let c=await l;n.set(s,{...d,image:c})}catch{o.set(s,!0)}})())):r},[])),{imageCache:n,updatedFiles:i,erroredFiles:o}},tD=e=>e.filter(t=>Vn(t)),Cx=e=>e?.nodeName.toLowerCase()==="svg",nD=e=>{let t=new DOMParser().parseFromString(e,Fu.svg),n=t.querySelector("svg");if(t.querySelector("parsererror")||!Cx(n))throw new Error("Invalid SVG");{n.hasAttribute("xmlns")||n.setAttribute("xmlns",Bx);let o=n.getAttribute("width"),r=n.getAttribute("height");(o?.includes("%")||o==="auto")&&(o=null),(r?.includes("%")||r==="auto")&&(r=null);let s=n.getAttribute("viewBox");if(!o||!r){if(o=o||"50",r=r||"50",s){let a=s.match(/\d+ +\d+ +(\d+(?:\.\d+)?) +(\d+(?:\.\d+)?)/);a&&([,o,r]=a)}n.setAttribute("width",o),n.setAttribute("height",r)}return s||n.setAttribute("viewBox",`0 0 ${o} ${r}`),n.outerHTML}};I();var aD=(e,t,n,i=50)=>{if(!e||e.length===0)return[];let o=[],r=Array.isArray(e[0])?e:e.map(p=>[p]),s=r.length,a=Math.max(1,Math.ceil(Math.sqrt(s))),l=[];for(let p=0;p<s;p+=a)l.push(r.slice(p,p+a));let d=0,c=l.map(p=>{let h=0,f=0,g=p.map(E=>{let[x,b,y,w]=Je(E);return{elements:E,bounds:[x,b,y,w],width:y-x,height:w-b}});return g.forEach((E,x)=>{h+=E.width,x<g.length-1&&(h+=i),E.height>f&&(f=E.height)}),d+=f,{unitBounds:g,width:h,maxHeight:f}}),u=d+Math.max(0,l.length-1)*i,m=n-u/2;return c.forEach(p=>{let{unitBounds:h,width:f,maxHeight:g}=p,E=t-f/2;h.forEach(x=>{let[b,y]=x.bounds,w=E-b,M=m-y;x.elements.forEach(S=>{o.push(Ke(S,{x:S.x+w,y:S.y+M}))}),E+=x.width+i}),m+=g+i}),o};I();import{pointCenter as Gx,normalizeRadians as vr,pointFrom as me,pointRotateRads as Nt}from"@excalidraw/math";import{MIN_FONT_SIZE as Ba,SHIFT_LOCKING_ANGLE as Br,rescalePoints as Ru,getFontString as Dr}from"@excalidraw/common";var wD=(e,t,n,i,o,r,s,a,l,d,c)=>{let u=i.getNonDeletedElementsMap();if(n.length===1){let[m]=n;if(t==="rotation")j(m)||(kx(m,i,a,l,o),je(m,i));else if(t){let p=n[0].id,h=u.get(p),f=e.get(p);if(h&&f){let{nextWidth:g,nextHeight:E}=zx(h,f,t,a,l,{shouldMaintainAspectRatio:s,shouldResizeFromCenter:r});Rx(g,E,h,f,e,i,t,{shouldMaintainAspectRatio:s,shouldResizeFromCenter:r})}}return oe(m)&&je(m,i),!0}else if(n.length>1){if(t==="rotation")return Nx(e,n,i,a,l,o,d,c),!0;if(t){let{nextWidth:m,nextHeight:p,flipByX:h,flipByY:f,originalBoundingBox:g}=_x(n,e,u,t,a,l,{shouldMaintainAspectRatio:s,shouldResizeFromCenter:r});return Hx(n,u,t,i,e,{shouldResizeFromCenter:r,shouldMaintainAspectRatio:s,flipByX:h,flipByY:f,nextWidth:m,nextHeight:p,originalBoundingBox:g}),!0}}return!1},kx=(e,t,n,i,o)=>{let[r,s,a,l]=Z(e,t.getNonDeletedElementsMap()),d=(r+a)/2,c=(s+l)/2,u;J(e)?u=0:(u=5*Math.PI/2+Math.atan2(i-c,n-d),o&&(u=u+Br/2,u=u-u%Br),u=vr(u));let m=Bt(e),p={angle:u};if(_e(e)&&(p={...p},e.startBinding&&Xe(e,"start",t),e.endBinding&&Xe(e,"end",t)),t.mutateElement(e,p),m){let h=t.getElement(m);if(h&&!X(e)){let{x:f,y:g}=Ki(e,h,t.getNonDeletedElementsMap());t.mutateElement(h,{angle:u,x:f,y:g})}}},zu=(e,t,n,i)=>K(e)||be(e)?{points:Ru(0,t,Ru(1,n,e.points,i),i)}:{},La=(e,t,n)=>{let i=e.width;if(Ie(e)){let s=Ue(e,t);s&&(i=vt(s,e))}let r=e.fontSize*(n/i);return r<Ba?null:{size:r}},Ox=(e,t,n,i,o,r,s)=>{let a=n.getNonDeletedElementsMap(),l=t.width*(s/t.height),d=La(t,a,l);if(d!==null){if(i.includes("n")||i.includes("s")){let c=me(e.x,e.y),u=va(c,e.width,e.height,l,s,e.angle,i,!1,o);n.mutateElement(t,{fontSize:d.size,width:l,height:s,x:u.x,y:u.y});return}if(i==="e"||i==="w"){let c=zo(Dr({fontSize:t.fontSize,fontFamily:t.fontFamily}),t.lineHeight),u=Math.max(c,r),m=rn(t.originalText,Dr(t),Math.abs(u)),p=ft(m,Dr(t),t.lineHeight),h=p.height,f=me(e.x,e.y),g=va(f,e.width,e.height,u,h,t.angle,i,!1,o),E={width:Math.abs(u),height:Math.abs(p.height),x:g.x,y:g.y,text:m,autoResize:!1};n.mutateElement(t,E)}}},Nx=(e,t,n,i,o,r,s,a)=>{let l=n.getNonDeletedElementsMap(),d=5*Math.PI/2+Math.atan2(o-a,i-s);r&&(d+=Br/2,d-=d%Br);let c=new Map(t.map(u=>[u.id,u]));for(let u of t)if(!J(u)){let[m,p,h,f]=Z(u,l),g=(m+h)/2,E=(p+f)/2,x=e.get(u.id)?.angle??u.angle,[b,y]=Nt(me(g,E),me(s,a),d+x-u.angle),w=j(u)?{points:Ld(u,l)}:{x:u.x+(b-g),y:u.y+(y-E),angle:vr(d+x)};n.mutateElement(u,w),je(u,n,{simultaneouslyUpdated:t}),_e(u)&&(u.startBinding&&(c.has(u.startBinding.elementId)||Xe(u,"start",n)),u.endBinding&&(c.has(u.endBinding.elementId)||Xe(u,"end",n)));let M=de(u,l);if(M&&!X(u)){let{x:S,y:T}=Ki(u,M,l);n.mutateElement(M,{x:S,y:T,angle:vr(d+x)})}}n.triggerUpdate()},yD=(e,t,n,i,o)=>{let[r,s,a,l]=t.length===1?Z(t[0],n):Je(t),d=(r+a)/2,c=(s+l)/2,u=t.length===1?t[0].angle:0;switch([i,o]=Nt(me(i,o),me(d,c),-u),e){case"n":return Nt(me(i-(r+a)/2,o-s),me(0,0),u);case"s":return Nt(me(i-(r+a)/2,o-l),me(0,0),u);case"w":return Nt(me(i-r,o-(s+l)/2),me(0,0),u);case"e":return Nt(me(i-a,o-(s+l)/2),me(0,0),u);case"nw":return Nt(me(i-r,o-s),me(0,0),u);case"ne":return Nt(me(i-a,o-s),me(0,0),u);case"sw":return Nt(me(i-r,o-l),me(0,0),u);case"se":return Nt(me(i-a,o-l),me(0,0),u);default:return[0,0]}},PD=(e,t)=>{let[,[n,i]]=t.points;return e==="nw"&&(n<0||i<0)||e==="ne"&&n>=0||e==="sw"&&n<=0||e==="se"&&(n>0||i>0)?"end":"origin"},Fx=(e,t,n)=>{if(n)return"center";if(t)switch(e){case"n":return"south-side";case"e":return"west-side";case"s":return"north-side";case"w":return"east-side";case"ne":return"bottom-left";case"nw":return"bottom-right";case"se":return"top-left";case"sw":return"top-right"}return["e","se","s"].includes(e)?"top-left":["n","nw","w"].includes(e)?"bottom-right":e==="ne"?"bottom-left":"top-right"},va=(e,t,n,i,o,r,s,a,l)=>{let d=Fx(s,a,l),[c,u]=e;switch(d){case"top-left":return{x:c+(t-i)/2+(i-t)/2*Math.cos(r)+(n-o)/2*Math.sin(r),y:u+(n-o)/2+(i-t)/2*Math.sin(r)+(o-n)/2*Math.cos(r)};case"top-right":return{x:c+(t-i)/2*(Math.cos(r)+1)+(n-o)/2*Math.sin(r),y:u+(n-o)/2+(t-i)/2*Math.sin(r)+(o-n)/2*Math.cos(r)};case"bottom-left":return{x:c+(t-i)/2*(1-Math.cos(r))+(o-n)/2*Math.sin(r),y:u+(n-o)/2*(Math.cos(r)+1)+(i-t)/2*Math.sin(r)};case"bottom-right":return{x:c+(t-i)/2*(Math.cos(r)+1)+(o-n)/2*Math.sin(r),y:u+(n-o)/2*(Math.cos(r)+1)+(t-i)/2*Math.sin(r)};case"center":return{x:c-(i-t)/2,y:u-(o-n)/2};case"east-side":return{x:c+(t-i)/2*(Math.cos(r)+1),y:u+(t-i)/2*Math.sin(r)+(n-o)/2};case"west-side":return{x:c+(t-i)/2*(1-Math.cos(r)),y:u+(i-t)/2*Math.sin(r)+(n-o)/2};case"north-side":return{x:c+(t-i)/2+(n-o)/2*Math.sin(r),y:u+(o-n)/2*(Math.cos(r)-1)};case"south-side":return{x:c+(t-i)/2+(o-n)/2*Math.sin(r),y:u+(n-o)/2*(Math.cos(r)+1)}}},Rx=(e,t,n,i,o,r,s,{shouldInformMutation:a=!0,shouldMaintainAspectRatio:l=!1,shouldResizeFromCenter:d=!1}={})=>{if(oe(n)&&oe(i))return Ox(i,n,r,s,d,e,t);let c={},u=r.getNonDeletedElementsMap(),m=de(n,u);if(m){let g=o.get(m.id);if(g&&(c={fontSize:g.fontSize}),l){let E={...n,width:e,height:t},x=La(m,u,vt(E,m));if(x===null)return;c={fontSize:x.size}}else{let E=Hl(Dr(m),m.lineHeight),x=Wl(m.fontSize,m.lineHeight);e=Math.max(e,E),t=Math.max(t,x)}}let p=zu(i,e,t,!0),h=me(i.x,i.y);if(K(i)){let[g,E]=ue(i,o);h=me(g,E)}let f=va(h,i.width,i.height,e,t,i.angle,s,l,d);if(K(i)&&p.points){let g=i.x-h[0],E=i.y-h[1];f.x+=g,f.y+=E;let x=p.points[0][0],b=p.points[0][1];f.x+=x,f.y+=b,p.points=p.points.map(y=>me(y[0]-x,y[1]-b))}if(e<0&&(f.x=f.x+e),t<0&&(f.y=f.y+t),"scale"in n&&"scale"in i&&r.mutateElement(n,{scale:[(Math.sign(e)||i.scale[0])*i.scale[0],(Math.sign(t)||i.scale[1])*i.scale[1]]}),X(n)&&m&&l){let g=e/n.width*m.fontSize;if(g<Ba)return;c.fontSize=g}if(e!==0&&t!==0&&Number.isFinite(f.x)&&Number.isFinite(f.y)){let g={...f,width:Math.abs(e),height:Math.abs(t),...p};_e(n)&&(n.startBinding&&(g={...g},n.startBinding&&Xe(n,"start",r)),n.endBinding&&(g={...g,endBinding:null})),r.mutateElement(n,g,{informMutation:a,isDragging:!1}),m&&c!=null&&r.mutateElement(m,{fontSize:c.fontSize}),qn(n,r,s,l,d),je(n,r)}},zx=(e,t,n,i,o,{shouldMaintainAspectRatio:r=!1,shouldResizeFromCenter:s=!1}={})=>{let[a,l,d,c]=wn(t,t.width,t.height,!0),u=me(a,l),m=me(d,c),p=Gx(u,m),h=Nt(me(i,o),p,-t.angle),[f,g,E,x]=wn(e,e.width,e.height,!0),b=E-f,y=x-g,w=m[0]-u[0],M=m[1]-u[1],S=w/b,T=M/y;n.includes("e")&&(S=(h[0]-u[0])/b),n.includes("s")&&(T=(h[1]-u[1])/y),n.includes("w")&&(S=(m[0]-h[0])/b),n.includes("n")&&(T=(m[1]-h[1])/y);let A=e.width*S,F=e.height*T;if(s&&(A=2*A-t.width,F=2*F-t.height),r){let B=Math.abs(A)/t.width,k=Math.abs(F)/t.height;if(n.length===1&&(F*=B,A*=k),n.length===2){let G=Math.max(B,k);A=t.width*G*Math.sign(A),F=t.height*G*Math.sign(F)}}return{nextWidth:A,nextHeight:F}},_x=(e,t,n,i,o,r,{shouldMaintainAspectRatio:s=!1,shouldResizeFromCenter:a=!1}={})=>{let l=e.map(G=>t.get(G.id)),d=l.reduce((G,_)=>{if(!K(_))return G;let W=Bt(_);if(!W)return G;let D=t.get(W)??null;return Ie(D)?[...G,{...D,...R.getBoundTextElementPosition(_,D,n)}]:G},[]),c=un(l.map(G=>G).concat(d)),{minX:u,minY:m,maxX:p,maxY:h,midX:f,midY:g}=c,E=p-u,x=h-m,b={ne:[u,h],se:[u,m],sw:[p,m],nw:[p,h],e:[u,m+x/2],w:[p,m+x/2],n:[u+E/2,h],s:[u+E/2,m]},[y,w]=a?[f,g]:b[i],M=a?2:1,S=Math.max(Math.abs(o-y)/E||0,Math.abs(r-w)/x||0)*M,T=i.includes("e")||i.includes("w")?Math.abs(o-y)*M:E,A=i.includes("n")||i.includes("s")?Math.abs(r-w)*M:x;s&&(T=E*S*Math.sign(o-y),A=x*S*Math.sign(r-w));let F={ne:[o<y,r>w],se:[o<y,r<w],sw:[o>y,r<w],nw:[o>y,r>w],e:[o<y,!1],w:[o>y,!1],n:[!1,r>w],s:[!1,r<w]},[B,k]=F[i].map(G=>G);return{originalBoundingBox:c,nextWidth:T,nextHeight:A,flipByX:B,flipByY:k}},Hx=(e,t,n,i,o,{shouldMaintainAspectRatio:r=!1,shouldResizeFromCenter:s=!1,flipByX:a=!1,flipByY:l=!1,nextHeight:d,nextWidth:c,originalBoundingBox:u}={})=>{if(c===void 0&&d===void 0&&a===void 0&&l===void 0||d===0||c===0)return;o||(o=t);let m=e.reduce((M,S)=>{let T=o.get(S.id);return T&&M.push({orig:T,latest:S}),M},[]),p;if(u)p=u;else{let M=m.reduce((S,{orig:T})=>{if(!K(T))return S;let A=Bt(T);if(!A)return S;let F=o.get(A)??null;return Ie(F)?[...S,{...F,...R.getBoundTextElementPosition(T,F,t)}]:S},[]);p=un([...m.map(({orig:S})=>S),...M])}let{minX:h,minY:f,maxX:g,maxY:E,midX:x,midY:b}=p,y=g-h,w=E-f;if(c===void 0&&d===void 0&&(c=y,d=w),r&&(c===void 0?c=d*(y/w):d===void 0?d=c*(w/y):Math.abs(c/d-y/w)>.001&&(c=d*(y/w))),c&&d){let M=n.includes("e")||n.includes("w")?Math.abs(c)/y:1,S=n.includes("n")||n.includes("s")?Math.abs(d)/w:1,T;n.length===1?T=n.includes("e")||n.includes("w")?M:S:T=Math.max(Math.abs(c)/y||0,Math.abs(d)/w||0);let A={ne:[h,E],se:[h,f],sw:[g,f],nw:[g,E],e:[h,f+w/2],w:[g,f+w/2],n:[h+y/2,E],s:[h+y/2,f]},[F,B]=s?[x,b]:A[n],k=r||m.some(P=>P.latest.angle!==0||oe(P.latest)||$d(P.latest));k&&(M=T,S=T);let[G,_]=[a?-1:1,l?-1:1],W=[];for(let{orig:P,latest:v}of m){if(oe(P)&&Ie(P))continue;let C=P.width*M,z=P.height*S,Q=vr(P.angle*G*_),ee=K(P)||be(P),te=P.x-F,ne=P.y-B,Ae=a&&!ee?C:0,Ft=l&&!ee?z:0,Rt=F+G*(te*M+Ae),hn=B+_*(ne*S+Ft),pe=zu(P,C*G,z*_,!1),ie={x:Rt,y:hn,width:C,height:z,angle:Q,...pe};if(j(P)&&(P.startBinding&&(ie.startBinding={...P.startBinding,fixedPoint:[a?-P.startBinding.fixedPoint[0]+1:P.startBinding.fixedPoint[0],l?-P.startBinding.fixedPoint[1]+1:P.startBinding.fixedPoint[1]]}),P.endBinding&&(ie.endBinding={...P.endBinding,fixedPoint:[a?-P.endBinding.fixedPoint[0]+1:P.endBinding.fixedPoint[0],l?-P.endBinding.fixedPoint[1]+1:P.endBinding.fixedPoint[1]]}),P.fixedSegments&&pe.points&&(ie.fixedSegments=P.fixedSegments.map(Te=>({...Te,start:pe.points[Te.index-1],end:pe.points[Te.index]})))),ke(P)&&(ie.scale=[P.scale[0]*G,P.scale[1]*_]),oe(P)){let Te=La(P,t,C);if(!Te)return;ie.fontSize=Te.size}let Le=o.get(Bt(P)??"");if(Le)if(k){let Te=Le.fontSize*T;if(Te<Ba)return;ie.boundTextFontSize=Te}else ie.boundTextFontSize=Le.fontSize;W.push({element:v,update:ie})}let D=W.map(({element:P})=>P),L=new Map(W.map(({element:P})=>[P.id,P]));for(let{element:P,update:{boundTextFontSize:v,...C}}of W){let{angle:z}=C;i.mutateElement(P,C),je(P,i,{simultaneouslyUpdated:D}),_e(P)&&(P.startBinding&&(L.has(P.startBinding.elementId)||Xe(P,"start",i)),P.endBinding&&(L.has(P.endBinding.elementId)||Xe(P,"end",i)));let Q=de(P,t);Q&&v&&(i.mutateElement(Q,{fontSize:v,angle:K(P)?void 0:z}),qn(P,i,n,!0,s))}i.triggerUpdate()}};I();import{pointFrom as Pt,pointOnLineSegment as Xu,pointRotateRads as Cr}from"@excalidraw/math";import{SIDE_RESIZING_THRESHOLD as Fa}from"@excalidraw/common";I();import{DEFAULT_TRANSFORM_HANDLE_SPACING as Ga}from"@excalidraw/common";import{pointFrom as _u,pointRotateRads as Wx}from"@excalidraw/math";var Hu={mouse:8,pen:16,touch:28},Ux=16,Uu={e:!0,s:!0,n:!0,w:!0},vD={e:!0,s:!0,n:!0,w:!0},BD={e:!0,s:!0,n:!0,w:!0,rotation:!0},Wu={e:!0,s:!0,n:!0,w:!0,nw:!0,se:!0},Ca={e:!0,s:!0,n:!0,w:!0},fn=(e,t,n,i,o,r,s)=>{let[a,l]=Wx(_u(e+n/2,t+i/2),_u(o,r),s);return[a-n/2,l-i/2,n,i]},Lr=e=>!(e.formFactor==="phone"&&e.userAgent.isMobileDevice),ka=e=>Lr(e)?Uu:{},Oa=([e,t,n,i,o,r],s,a,l,d={},c=4,u=Ga)=>{let m=Hu[l],p=m/a.value,h=m/a.value,f=m/a.value,g=m/a.value,E=n-e,x=i-t,b=c/a.value,y=(m-u*2)/(2*a.value),w={nw:d.nw?void 0:fn(e-b-f+y,t-b-g+y,p,h,o,r,s),ne:d.ne?void 0:fn(n+b-y,t-b-g+y,p,h,o,r,s),sw:d.sw?void 0:fn(e-b-f+y,i+b-y,p,h,o,r,s),se:d.se?void 0:fn(n+b-y,i+b-y,p,h,o,r,s),rotation:d.rotation?void 0:fn(e+E/2-p/2,t-b-g+y-Ux/a.value,p,h,o,r,s)},M=5*Hu.mouse/a.value;return Math.abs(E)>M&&(d.n||(w.n=fn(e+E/2-p/2,t-b-g+y,p,h,o,r,s)),d.s||(w.s=fn(e+E/2-p/2,i+b-y,p,h,o,r,s))),Math.abs(x)>M&&(d.w||(w.w=fn(e-b-f+y,t+x/2-h/2,p,h,o,r,s)),d.e||(w.e=fn(n+b-y,t+x/2-h/2,p,h,o,r,s))),w},Yu=(e,t,n,i="mouse",o=Uu)=>{if(e.locked||j(e))return{};if(e.type==="freedraw"||K(e)){if(e.points.length===2){let[,s]=e.points;s[0]===0||s[1]===0?o=Ca:s[0]>0&&s[1]<0?o=Wu:s[0]>0&&s[1]>0?o=Ca:s[0]<0&&s[1]>0?o=Wu:s[0]<0&&s[1]<0&&(o=Ca)}}else J(e)&&(o={...o,rotation:!0});let r=K(e)?Ga+8:ke(e)?0:Ga;return Oa(Z(e,n,!0),e.angle,t,i,o,r,ke(e)?0:void 0)},LD=(e,t,n)=>{if(t.selectedLinearElement?.isEditing||t.selectedLinearElement?.isDragging)return!1;if(e.length>1)return!0;let i=e[0];return j(i)?!1:K(i)?i.points.length>2&&!n.userAgent.isMobileDevice:!0};var Ra=(e,t,n)=>t>=e[0]&&t<=e[0]+e[2]&&n>=e[1]&&n<=e[1]+e[3],Yx=(e,t,n,i,o,r,s,a)=>{if(!n.selectedElementIds[e.id])return!1;let{rotation:l,...d}=Yu(e,r,t,s,ka(a));if(l&&Ra(l,i,o))return"rotation";let c=Object.keys(d).filter(u=>{let m=d[u];return m?Ra(m,i,o):!1});if(c.length>0)return c[0];if(Lr(a)){let[u,m,p,h,f,g]=Z(e,t);if(!(K(e)&&e.points.length<=2)){let E=ke(e)?0:Fa/r.value,x=Fa/r.value,b=ju(Pt(u-E,m-E),Pt(p+E,h+E),Pt(f,g),e.angle);for(let[y,w]of Object.entries(b))if(Xu(Pt(i,o),w,x))return y}}return!1},zD=(e,t,n,i,o,r,s,a)=>e.reduce((l,d)=>{if(l)return l;let c=Yx(d,s,t,n,i,o,r,a);return c?{element:d,transformHandleType:c}:null},null),_D=([e,t,n,i],o,r,s,a,l)=>{let d=Oa([e,t,n,i,(e+n)/2,(t+i)/2],0,s,a,ka(l)),c=Object.keys(d).find(u=>{let m=d[u];return m&&Ra(m,o,r)});if(c)return c;if(Lr(l)){let u=(e+n)/2,m=(t+i)/2,p=Fa/s.value,h=ju(Pt(e-p,t-p),Pt(n+p,i+p),Pt(u,m),0);for(let[f,g]of Object.entries(h))if(Xu(Pt(o,r),g,p))return f}return!1},Na=["ns","nesw","ew","nwse"],Xx=(e,t)=>{let n=Na.indexOf(e);if(n>=0){let i=Math.round(t/(Math.PI/4));e=Na[(n+i)%Na.length]}return e},HD=e=>{let{element:t,transformHandleType:n}=e,i=t&&Math.sign(t.height)*Math.sign(t.width)===-1,o=null;switch(n){case"n":case"s":o="ns";break;case"w":case"e":o="ew";break;case"nw":case"se":i?o="nesw":o="nwse";break;case"ne":case"sw":i?o="nwse":o="nesw";break;case"rotation":return"grab"}return o&&t&&(o=Xx(o,t.angle)),o?`${o}-resize`:""},ju=([e,t],[n,i],o,r)=>{let s=Cr(Pt(e,t),o,r),a=Cr(Pt(n,t),o,r),l=Cr(Pt(e,i),o,r),d=Cr(Pt(n,i),o,r);return{n:[s,a],e:[a,d],s:[d,l],w:[l,s]}};I();var XD=(e,t)=>!!(!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&(e.activeTool.type!=="custom"&&(e.editingTextElement||e.activeTool.type!=="selection"&&e.activeTool.type!=="lasso"&&e.activeTool.type!=="eraser"&&e.activeTool.type!=="hand"&&e.activeTool.type!=="laser")||Zt(t,e).length));I();import{pointFrom as Gr}from"@excalidraw/math";import{DEFAULT_FONT_FAMILY as jx,DEFAULT_FONT_SIZE as $x,TEXT_ALIGN as Vx,VERTICAL_ALIGN as Zx,getSizeFromPoints as Kx,randomId as qx,arrayToMap as Qx,assertNever as za,cloneJSON as Vu,getFontString as Jx,isDevEnv as eb,toBrandedType as tb,getLineHeight as nb}from"@excalidraw/common";var kr={width:100,height:0},Un=100,ib=(e,t,n)=>{let i=si({x:0,y:0,textAlign:Vx.CENTER,verticalAlign:Zx.MIDDLE,...t,containerId:e.id,strokeColor:t.strokeColor||e.strokeColor});return Object.assign(e,{boundElements:(e.boundElements||[]).concat({type:"text",id:i.id})}),Uo(i,e,n),[e,i]},$u=(e,t,n,i,o)=>{let r,s;if(Object.assign(e,{startBinding:e?.startBinding||null,endBinding:e.endBinding||null}),t){let c=t?.width??Un,u=t?.height??Un,m;t.id&&(m=i.getElement(t.id),m||console.error(`No element for start binding with id ${t.id} found`));let p=t.x||e.x-c,h=t.y||e.y-u/2,f=m?m.type:t.type;if(f){if(f==="text"){let g="";m&&m.type==="text"?g=m.text:t.type==="text"&&(g=t.text),g||console.error(`No text found for start binding text element for ${e.id}`),r=si({x:p,y:h,type:"text",...m,...t,text:g}),Object.assign(r,{x:t.x||e.x-r.width,y:t.y||e.y-r.height/2})}else switch(f){case"rectangle":case"ellipse":case"diamond":{r=Ai({x:p,y:h,width:c,height:u,...m,...t,type:f});break}default:za(e,`Unhandled element start type "${t.type}"`,!0)}Vt(e,r,"orbit","start",o)}}if(n){let c=n?.height??Un,u=n?.width??Un,m;n.id&&(m=i.getElement(n.id),m||console.error(`No element for end binding with id ${n.id} found`));let p=n.x||e.x+e.width,h=n.y||e.y-c/2,f=m?m.type:n.type;if(f){if(f==="text"){let g="";m&&m.type==="text"?g=m.text:n.type==="text"&&(g=n.text),g||console.error(`No text found for end binding text element for ${e.id}`),s=si({x:p,y:h,type:"text",...m,...n,text:g}),Object.assign(s,{y:n.y||e.y-s.height/2})}else switch(f){case"rectangle":case"ellipse":case"diamond":{s=Ai({x:p,y:h,width:u,height:c,...m,...n,type:f});break}default:za(e,`Unhandled element end type "${f}"`,!0)}Vt(e,s,"orbit","end",o)}}if(e.points.length<2)return{linearElement:e,startBoundElement:r,endBoundElement:s};let a=e.points.length-1,l=.5,d=Vu(e.points);return e.points[a][0]>e.points[a-1][0]&&(d[0][0]=l,d[a][0]-=l),e.points[a][0]<e.points[a-1][0]&&(d[0][0]=-l,d[a][0]+=l),e.points[a][1]>e.points[a-1][1]&&(d[0][1]=l,d[a][1]-=l),e.points[a][1]<e.points[a-1][1]&&(d[0][1]=-l,d[a][1]+=l),Object.assign(e,R.getNormalizeElementPointsAndCoords({...e,points:d})),{linearElement:e,startBoundElement:r,endBoundElement:s}},_a=class{excalidrawElements=new Map;add=t=>{t&&this.excalidrawElements.set(t.id,t)};getElements=()=>$s(Array.from(this.excalidrawElements.values()));getElementsMap=()=>tb(Qx(this.getElements()));getElement=t=>this.excalidrawElements.get(t)},rv=(e,t)=>{if(!e)return[];let n=Vu(e),i=new _a,o=new Map,r=new Map;for(let l of n){let d,c=l.id;switch(t?.regenerateIds!==!1&&Object.assign(l,{id:qx()}),l.type){case"rectangle":case"ellipse":case"diamond":{let m=l?.label?.text&&l.width===void 0?0:l?.width||Un,p=l?.label?.text&&l.height===void 0?0:l?.height||Un;d=Ai({...l,width:m,height:p});break}case"line":{let m=l.width||kr.width,p=l.height||kr.height;d=Lc({width:m,height:p,points:[Gr(0,0),Gr(m,p)],...l});break}case"arrow":{let m=l.width||kr.width,p=l.height||kr.height;d=br({width:m,height:p,endArrowhead:"arrow",points:[Gr(0,0),Gr(m,p)],...l,type:"arrow"}),Object.assign(d,Kx(d.points));break}case"text":{let m=l?.fontFamily||jx,p=l?.fontSize||$x,h=l?.lineHeight||nb(m),f=l.text??"",g=Zi(f),E=ft(g,Jx({fontFamily:m,fontSize:p}),h);d=si({width:E.width,height:E.height,fontFamily:m,fontSize:p,...l});break}case"image":{d=Cc({width:l?.width||Un,height:l?.height||Un,...l});break}case"frame":{d=Dc({x:0,y:0,...l});break}case"magicframe":{d=vc({x:0,y:0,...l});break}case"freedraw":case"iframe":case"embeddable":{d=l;break}default:d=l,za(l,`Unhandled element type "${l.type}"`,!0)}i.getElement(d.id)?console.error(`Duplicate id found for ${d.id}`):(i.add(d),o.set(d.id,l),c&&r.set(c,d.id))}let s=i.getElementsMap(),a=new Ci(s);for(let[l,d]of o){let c=i.getElement(l);switch(d.type){case"rectangle":case"ellipse":case"diamond":case"arrow":{if(d.label?.text){let[u,m]=ib(c,d?.label,a);if(i.add(u),i.add(m),X(u)){let p=d.type==="arrow"?d?.start:void 0,h=d.type==="arrow"?d?.end:void 0;if(p&&p.id){let x=r.get(p.id);x&&Object.assign(p,{id:x})}if(h&&h.id){let x=r.get(h.id);x&&Object.assign(h,{id:x})}let{linearElement:f,startBoundElement:g,endBoundElement:E}=$u(u,p,h,i,a);u=f,i.add(f),i.add(g),i.add(E)}}else switch(d.type){case"arrow":{let{start:u,end:m}=d;if(u&&u.id){let g=r.get(u.id);Object.assign(u,{id:g})}if(m&&m.id){let g=r.get(m.id);Object.assign(m,{id:g})}let{linearElement:p,startBoundElement:h,endBoundElement:f}=$u(c,u,m,i,a);i.add(p),i.add(h),i.add(f);break}}break}}}for(let[l,d]of o){if(d.type!=="frame"&&d.type!=="magicframe")continue;let c=i.getElement(l);if(!c)throw new Error(`Excalidraw element with id ${l} doesn't exist`);let u=[];d.children.forEach(w=>{let M=r.get(w);if(!M)throw new Error(`Element with ${w} wasn't mapped correctly`);let S=i.getElement(M);if(!S)throw new Error(`Frame element with id ${M} doesn't exist`);Object.assign(S,{frameId:c.id}),S?.boundElements?.forEach(T=>{let A=i.getElement(T.id);if(!A)throw new Error(`Bound element with id ${T.id} doesn't exist`);Object.assign(A,{frameId:c.id}),u.push(A)}),u.push(S)});let[m,p,h,f]=Je(u),g=10;m=m-g,p=p-g,h=h+g,f=f+g;let E=c?.x||m,x=c?.y||p,b=c?.width||h-m,y=c?.height||f-p;Object.assign(c,{x:E,y:x,width:b,height:y}),eb()&&d.children.length&&(c?.x||c?.y||c?.width||c?.height)&&console.info("User provided frame attributes are being considered, if you find this inaccurate, please remove any of the attributes - x, y, width and height so frame coordinates and dimensions are calculated automatically")}return i.getElements()};I();var cv=({app:e,event:t})=>{let n=e.state;if(n.selectedLinearElement&&e.lastPointerMoveCoords){if(n.selectedLinearElement.draggedFocusPointBinding)return Nu(n.selectedLinearElement,e.scene.getNonDeletedElementsMap(),e.lastPointerMoveCoords,e.scene,n,e.getEffectiveGridSize(),t.altKey),!0;if(n.selectedLinearElement.hoverPointIndex!==null&&e.lastPointerMoveEvent&&n.selectedLinearElement.initialState.lastClickedPoint>=0&&n.selectedLinearElement.isDragging)return R.handlePointDragging(e.lastPointerMoveEvent,e,e.lastPointerMoveCoords.x,e.lastPointerMoveCoords.y,n.selectedLinearElement),!0}return!1};I();var ob=e=>{switch(e){case void 0:case null:return null;case"dot":return"circle";case"crowfoot_one":return"cardinality_one";case"crowfoot_many":return"cardinality_many";case"crowfoot_one_or_many":return"cardinality_one_or_many";default:return e}},pv=e=>{let t=ob(e);return t===null?null:t};I();import{getBoundsFromPoints as Qu,getElementAbsoluteCoords as rb}from"@excalidraw/element/bounds";import{newArrowElement as Zu,newElement as sb,newLinearElement as Or}from"@excalidraw/element/newElement";import{ELEMENT_PENDING_DRAW_SHAPE_OPACITY as ab,getStrokeWidthByKey as Nr,ROUNDNESS as Ku}from"@excalidraw/common";import{convexHull as lb,distanceToLineSegment as db,elongation as cb,kurtosis as qu,lineSegment as ub,orientPrincipalAxes as mb,pointFrom as tt,polygonArea as pb,principalAxes as fb,principalCoords as hb,skewness as gb}from"@excalidraw/math";var Eb=64,xb=25,bb=.15,wb=.25,yb=.5,Pb=.15,Ib=.3,Sb=1.5,ki=3;function Mb(e,t){let n=0;for(let a=1;a<e.length;a++)n+=Math.hypot(e[a][0]-e[a-1][0],e[a][1]-e[a-1][1]);let i=n/(t-1),o=0,r=[e[0]],s=e[0];for(let a=1;a<e.length;a++){let l=e[a],d=Math.hypot(l[0]-s[0],l[1]-s[1]);if(o+d>=i){let c=i-o;for(;c<=d+1e-10;){let u=c/d,m=[s[0]+u*(l[0]-s[0]),s[1]+u*(l[1]-s[1])];if(r.push(m),r.length===t)return r;s=m,o=0,c+=i}o=d-(c-i)}else o+=d;s=l}for(;r.length<t;)r.push(e[e.length-1]);return r}function Ab(e){let t=e[0],n=t,i=0;for(let s of e){let a=Math.hypot(s[0]-t[0],s[1]-t[1]);a>i&&(i=a,n=s)}if(i===0)return 0;let o=ub(t,n),r=0;for(let s of e)Math.hypot(s[0]-n[0],s[1]-n[1])<=yb*i||(r=Math.max(r,db(s,o)));return r/i}function Tb(e){let t=[];for(let n=ki;n<e.length-ki;n++){let[i,o]=e[n-ki],[r,s]=e[n],[a,l]=e[n+ki],d=r-i,c=s-o,u=a-r,m=l-s;t.push(Math.abs(Math.atan2(d*m-c*u,d*u+c*m)))}return t}function Db(e){let t=Tb(e),n=t.reduce((r,s)=>r+s,0);if(n===0)return 0;let i=new Array(t.length).fill(!1),o=0;for(let r=0;r<4;r++){let s=-1,a=0;for(let l=0;l<t.length;l++)!i[l]&&t[l]>a&&(a=t[l],s=l);if(s<0)break;for(let l=s-ki;l<=s+ki;l++)l>=0&&l<t.length&&!i[l]&&(o+=t[l],i[l]=!0)}return o/n}function vb(e){let t=Mb(e,Eb),n=0;for(let m=1;m<t.length;m++)n+=Math.hypot(t[m][0]-t[m-1][0],t[m][1]-t[m-1][1]);let i=Math.hypot(t[t.length-1][0]-t[0][0],t[t.length-1][1]-t[0][1]),o=mb(t,fb(t)),r=hb(t,o).map(([m])=>m),s=lb(t),[a,l,d,c]=Qu(t),u=(d-a)*(c-l);return{gapRatio:n>0?i/n:0,elongation:cb(o),majorSkew:gb(r),hullFillRatio:u>0?pb(s)/u:0,cornerTurnShare:Db(t),kurtosisProduct:qu(t.map(([m])=>m))*qu(t.map(([,m])=>m)),shaftDeviationRatio:Ab(t)}}var Bb=[{type:"rectangle",hullFillRatio:1,cornerTurnShare:.95,kurtosisProduct:1.83},{type:"diamond",hullFillRatio:.5,cornerTurnShare:.95,kurtosisProduct:3.24},{type:"ellipse",hullFillRatio:Math.PI/4,cornerTurnShare:.55,kurtosisProduct:2.25}],Lb=.2,Cb=.2,Gb=.7;function kb(e){let t="freedraw",n=Sb;for(let i of Bb){let o=Math.hypot((e.hullFillRatio-i.hullFillRatio)/Lb,(e.cornerTurnShare-i.cornerTurnShare)/Cb,(e.kurtosisProduct-i.kurtosisProduct)/Gb);o<n&&(n=o,t=i.type)}return t}function Ob(e){return e.elongation>wb||e.shaftDeviationRatio>Pb?"freedraw":Math.abs(e.majorSkew)>=Ib?"arrow":"line"}function Nb(e){return e.gapRatio>bb?Ob(e):kb(e)}function Fb(e,t,n){let[i,o,r,s]=t,a=r-i,l=s-o;if(a===0&&l===0)return e[e.length-1];let d=[tt(i,o),tt((i+r)/2,o),tt(r,o),tt(r,(o+s)/2),tt(r,s),tt((i+r)/2,s),tt(i,s),tt(i,(o+s)/2)],c=-1,u=tt(r,s);for(let h of d){let f=Math.hypot(h[0]-n[0],h[1]-n[1]);f>c&&(c=f,u=h)}let m=1/0,p=e[e.length-1];for(let h of e){let f=Math.hypot(h[0]-u[0],h[1]-u[1]);f<m&&(m=f,p=h)}return p}var Rb=(e,t,n=1)=>{typeof window<"u"&&(window.LAST_POINTS=e.map(([u,m])=>tt(u,m)));let i=Qu(e),[o,r,s,a]=i,l=Math.max(s-o,a-r);if(e.length<3||l*n<xb)return{type:"freedraw",points:e,boundingBox:i};let d=Nb(vb(e));return{type:t?.type==="arrow"&&d!=="arrow"?"freedraw":d,points:e,boundingBox:i}},zb=(e,t,n,i,o)=>{let r=Rb(e,i,t.zoom.value),s=r.boundingBox,[a,l,d,c]=s,m=(o??qs([...n.values()])).find(h=>{let[f,g,E,x]=rb(h,n);return f<=a&&g<=l&&E>=d&&x>=c})?.id??null,p=t.currentItemRoundness==="round"?{type:Oo(r.type)?Ku.ADAPTIVE_RADIUS:Ku.PROPORTIONAL_RADIUS}:null;switch(r.type){case"rectangle":case"diamond":case"ellipse":return sb({type:r.type,x:r.boundingBox[0],y:r.boundingBox[1],width:r.boundingBox[2]-r.boundingBox[0],height:r.boundingBox[3]-r.boundingBox[1],groupIds:[],angle:0,frameId:m,roundness:p,roughness:t.currentItemRoughness,backgroundColor:t.currentItemBackgroundColor,strokeColor:t.currentItemStrokeColor,fillStyle:t.currentItemFillStyle,opacity:t.currentItemOpacity,strokeStyle:t.currentItemStrokeStyle,strokeWidth:Nr(r.type,t.currentItemStrokeWidthKey)});case"arrow":{let[h,f]=r.points[0],[g,E]=Fb(r.points,r.boundingBox,r.points[0]),x=tt(g-h,E-f);if(Math.hypot(g-r.points[0][0],E-r.points[0][1])<60){let M=Or({type:"line",x:h,y:f,points:[tt(r.points[0][0]-h,r.points[0][1]-f),x],groupIds:[],frameId:m,locked:!1,angle:0,roundness:p,roughness:t.currentItemRoughness,backgroundColor:t.currentItemBackgroundColor,strokeColor:t.currentItemStrokeColor,fillStyle:t.currentItemFillStyle,opacity:t.currentItemOpacity,strokeStyle:t.currentItemStrokeStyle,strokeWidth:Nr(r.type,t.currentItemStrokeWidthKey)}),S=R.getNormalizeElementPointsAndCoords(M);return Or({...M,...S})}let y=Zu({type:"arrow",x:h,y:f,startArrowhead:t.currentItemStartArrowhead,endArrowhead:t.currentItemEndArrowhead,points:[tt(r.points[0][0]-h,r.points[0][1]-f),x],groupIds:[],frameId:m,locked:!1,angle:0,roundness:p,roughness:t.currentItemRoughness,backgroundColor:t.currentItemBackgroundColor,strokeColor:t.currentItemStrokeColor,fillStyle:t.currentItemFillStyle,opacity:t.currentItemOpacity,strokeStyle:t.currentItemStrokeStyle,strokeWidth:Nr(r.type,t.currentItemStrokeWidthKey)}),w=R.getNormalizeElementPointsAndCoords(y);return Zu({...y,...w})}case"line":{let[h,f]=r.points[0],g=r.points[r.points.length-1],E=Or({type:r.type,x:h,y:f,points:[tt(r.points[0][0]-h,r.points[0][1]-f),tt(g[0]-h,g[1]-f)],groupIds:[],frameId:m,locked:!1,angle:0,roundness:p,roughness:t.currentItemRoughness,backgroundColor:t.currentItemBackgroundColor,strokeColor:t.currentItemStrokeColor,fillStyle:t.currentItemFillStyle,opacity:t.currentItemOpacity,strokeStyle:t.currentItemStrokeStyle,strokeWidth:Nr(r.type,t.currentItemStrokeWidthKey)}),x=R.getNormalizeElementPointsAndCoords(E);return Or({...E,...x})}}},_b=(e,t)=>{if(!e||e.type!==t.type||e.x!==t.x||e.y!==t.y||e.width!==t.width||e.height!==t.height||e.angle!==t.angle)return!1;if(K(e)&&K(t)){if(e.points.length!==t.points.length)return!1;for(let n=0;n<e.points.length;n++)if(e.points[n][0]!==t.points[n][0]||e.points[n][1]!==t.points[n][1])return!1}return!0},Iv=(e,t)=>{if(e.state.activeTool.type==="autoshape"){e.drawShape.trail.addPointToPath(t.x,t.y);let n=e.drawShape.trail.getCurrentPoints();if(n.length>=3){let i=zb(n,e.state,e.scene.getNonDeletedElementsMap(),e.state.newElement,e.scene.getNonDeletedFramesLikes());if(i&&!Oe(i)){let o=e.state.newElement,r={...i,id:o?.type===i.type?o.id:i.id,seed:1,opacity:ab,isDeleted:!1};_b(o,r)||e.setState({newElement:r})}else e.state.newElement!==null&&e.setState({newElement:null})}return!0}return!1};var Dv=e=>e.reduce((t,n)=>t+n.version,0),Kc=e=>{let t=5381;for(let n of Hb(e))t=(t<<5)+t+n.versionNonce;return t>>>0},qc=e=>{let t=5381;for(let n=0;n<e.length;n++){let i=e.charCodeAt(n);t=(t<<5)+t+i}return t>>>0},Ve=e=>!e.isDeleted,vv=e=>e.filter(t=>Ve(t)&&!Tc(t)),kn=e=>e.filter(Ve);export{Rn as AppStateDelta,Cf as BASE_ARROW_MIN_LENGTH,Md as BASE_BINDING_GAP,Qn as BASE_BINDING_GAP_ELBOW,ce as BASE_PADDING,vn as BindableElement,Dn as BoundElement,ut as CaptureUpdateAction,Wg as DEFAULT_BUCKET_FILL_OPTIONS,jI as DEFAULT_LINK_SIZE,Uu as DEFAULT_OMIT_SIDES,$ as Delta,Ea as DurableIncrement,aa as ElementBounds,zn as ElementsDelta,xa as EphemeralIncrement,no as FOCUS_POINT_SIZE,Pu as FlowChartCreator,yu as FlowChartNavigator,Be as HEADING_DOWN,Ne as HEADING_LEFT,he as HEADING_RIGHT,Ze as HEADING_UP,Eg as INVISIBLY_SMALL_ELEMENT_SIZE,Xs as InvalidFractionalIndexError,R as LinearElementEditor,ze as MINIMAL_CROP_SIZE,BD as OMIT_SIDES_FOR_FRAME,vD as OMIT_SIDES_FOR_MULTIPLE_ELEMENTS,Ci as Scene,Et as ShapeCache,$c as Store,mo as StoreChange,ba as StoreDelta,Sr as StoreIncrement,_n as StoreSnapshot,lt as aabbForElement,Ph as addElementsToFrame,G1 as addToGroup,jS as alignElements,zf as avoidRectangularCorner,Vt as bindBindingElement,u1 as bindBindingElementToFixedPoint,nc as bindElementsToFramesAfterDuplication,Gf as bindOrUnbindBindingElement,a1 as bindOrUnbindBindingElements,ks as bindPointToSnapToElementOutline,Bd as bindingProperties,Qs as boundsContainBounds,xd as bumpVersion,Wf as calculateFixedPointForElbowArrowBinding,yi as calculateFixedPointForNonElbowArrowBinding,t0 as canApplyRoundnessTypeToElement,Bl as canBecomePolygon,$l as canChangeRoundness,nx as canCreateLinkFromElements,aP as canHaveArrowheads,Lr as canResizeFromSides,fi as charWidth,fe as compareHeading,Ki as computeBoundTextPosition,CM as computeBucketFillPolygon,ps as computeContainerDimensionForBoundText,B0 as containsCJK,rv as convertToExcalidrawElements,zb as convertToShape,Iv as convertToShapeHandlePointerMoveFromPointerDown,sT as createPlaceholderEmbeddableLabel,Ia as createSrcDoc,$y as cropElement,Pn as deconstructDiamondElement,No as deconstructLinearOrFreeDrawElement,yn as deconstructRectanguloidElement,ga as deepCopyElement,ZA as defaultGetElementLinkFromSelection,I0 as detectLineHeight,Ut as distanceToElement,CA as distributeElements,gt as doBoundsIntersect,YA as dragNewElement,tx as dragNewTextElement,WA as dragSelectedElements,uE as duplicateElement,VM as duplicateElements,C1 as editGroupForSelectedElement,re as elementCenterPoint,Ln as elementOverlapsWithFrame,oo as elementWithCanvasCache,Gn as elementsAreInFrameBounds,jd as elementsAreInSameGroup,Kd as elementsOverlappingBBox,lT as embeddableURLValidator,uh as excludeElementsInFramesFromSelection,MI as filterElementsEligibleAsFrameChildren,d1 as fixBindingsAfterDeletion,vd as fixDuplicatedBindingsAfterDuplication,Ss as flipHeading,LI as frameAndChildrenSelectedTogether,Fl as generateLinearCollisionShape,ct as generateRoughOptions,K1 as getActiveTextElement,Xo as getAllHoveredElementAtPoint,Wl as getApproxMinLineHeight,Hl as getApproxMinLineWidth,Ld as getArrowLocalFixedPoints,cg as getArrowheadAngle,pv as getArrowheadForPicker,et as getArrowheadPoints,dg as getArrowheadSize,ve as getBindingGap,c1 as getBindingSideMidPoint,zs as getBindingStrategyForDraggingBindingElementEndpoints,de as getBoundTextElement,Bt as getBoundTextElementId,U0 as getBoundTextElementPosition,qi as getBoundTextMaxHeight,vt as getBoundTextMaxWidth,oi as getBoundsFromPoints,an as getCenterForBounds,un as getCommonBoundingBox,Je as getCommonBounds,wh as getCommonFrameId,H0 as getContainerCenter,fs as getContainerCoords,Ue as getContainerElement,Cn as getContainingFrame,nn as getCornerRadius,jo as getCubicBezierCurveBound,HD as getCursorForResizingElement,Th as getDefaultFrameName,n0 as getDefaultRoundnessTypeForElement,Nl as getDiamondBaseCorners,pi as getDiamondPoints,UA as getDragOffsetXY,vS as getDraggedElementsBounds,Z as getElementAbsoluteCoords,ue as getElementBounds,Ii as getElementLineSegments,Ws as getElementPointsCoords,Ec as getElementShape,zD as getElementWithTransformHandleType,ic as getElementsCompletelyInFrame,Qe as getElementsInGroup,SI as getElementsInNewFrame,II as getElementsInResizingFrame,EI as getElementsIntersectingFrame,BI as getElementsOverlappingFrame,Zd as getElementsWithinSelection,rT as getEmbedLink,xM as getEndpointBoundTextDragAnchor,Vy as getFlipAdjustedCropPosition,Bn as getFrameChildren,yh as getFrameChildrenInsertionIndex,qs as getFrameLikeElements,vI as getFrameLikeTitle,ZI as getFreedrawOutlineAsSegments,eg as getFreedrawOutlinePoints,xc as getFreedrawStrokeCenterPoints,He as getGlobalFixedPointForBindableElement,Uf as getGlobalFixedPoints,Ed as getHeadingForElbowArrowSnap,sn as getHoveredElementForBinding,rd as getHoveredElementForFocusPoint,tD as getInitializedImageElements,_o as getLineHeightInPx,In as getLineWidth,i0 as getLinearElementSubType,KA as getLinkIdAndTypeFromSelection,Wd as getLockedLinearCursorAlignSize,gp as getMaxCharWidth,O1 as getMaximumGroups,M0 as getMinCharWidth,io as getMinMaxXYFromCurvePathOps,zo as getMinTextElementWidth,Vd as getNewGroupIdsForDuplication,kn as getNonDeletedElements,Xd as getNonDeletedGroupIds,zS as getNormalizedDimensions,Li as getObservedAppState,ka as getOmitSidesForEditorInterface,x0 as getOriginalContainerHeightFromCache,la as getPerfectElementSize,DS as getRectangleBoxAbsoluteCoords,Rh as getRenderOpacity,PD as getResizeArrowDirection,yD as getResizeOffsetXY,wn as getResizedElementAbsoluteCoords,PI as getRootElements,Dv as getSceneVersion,Zt as getSelectedElements,ar as getSelectedElementsByGroup,Ys as getSelectedGroupForElement,sh as getSelectedGroupIdForElement,oh as getSelectedGroupIds,Z1 as getSelectionStateForElements,dp as getSnapOutlineMidPoint,V1 as getTargetElements,Sh as getTargetFrame,da as getTextAnchorRatios,gM as getTextBindingForArrowEndpoint,W0 as getTextElementAngle,$0 as getTextFromElements,hp as getTextHeight,Ul as getTextWidth,_D as getTransformHandleTypeFromCoords,Yu as getTransformHandles,Oa as getTransformHandlesFromCoords,hM as getUnboundArrowEndpointAtPoint,Pl as getUncroppedImageElement,es as getUncroppedWidthAndHeight,j1 as getVisibleAndNonSelectedElements,vv as getVisibleElements,BS as getVisibleSceneBounds,Mp as getWrappedTextLines,yI as groupByFrameLikes,bI as groupsAreAtLeastIntersectingTheFrame,wI as groupsAreCompletelyOutOfFrame,qn as handleBindTextResize,Nu as handleFocusPointDrag,ZT as handleFocusPointHover,$T as handleFocusPointPointerDown,VT as handleFocusPointPointerUp,hi as hasBackground,_t as hasBoundTextElement,LD as hasBoundingBox,rP as hasFreedrawMode,nP as hasStrokeColor,oP as hasStrokeStyle,iP as hasStrokeWidth,Kc as hashElementsVersion,qc as hashString,st as headingForPoint,gi as headingForPointFromElement,Lt as headingForPointIsHorizontal,at as headingIsHorizontal,DP as headingIsVertical,Jp as hitElementBoundText,Qp as hitElementBoundingBox,PP as hitElementBoundingBoxOnly,Ht as hitElementItself,ot as intersectElementWithLineSegment,e0 as isArrowBoundToElement,X as isArrowElement,we as isBindableElement,Ps as isBindableElementInsideOtherBindable,_e as isBindingElement,Qm as isBindingElementType,$t as isBindingEnabled,Ie as isBoundToContainer,Uc as isBucketFillCompatible,xI as isCursorInFrame,Km as isCurvedArrow,j as isElbowArrow,RS as isElementCompletelyInViewport,Ks as isElementContainingFrame,rc as isElementInFrame,rh as isElementInGroup,qd as isElementInViewport,Si as isElementIntersectingFrame,qA as isElementLink,o0 as isEligibleFrameChildType,Sl as isEmbeddableElement,EM as isEndpointBoundText,Tl as isExcalidrawElement,Yf as isFixedPoint,Dl as isFlowchartNodeElement,Tr as isFocusPointVisible,ko as isFrameElement,J as isFrameLikeElement,be as isFreeDrawElement,Vm as isFreeDrawElementType,Cx as isHTMLSVGElement,Co as isIframeElement,Go as isIframeLikeElement,ke as isImageElement,$d as isInGroup,Vn as isInitializedImageElement,Tc as isInvisiblySmallElement,Oe as isLineElement,K as isLinearElement,qm as isLinearElementType,Ml as isMagicFrameElement,P0 as isMeasureTextSupported,PT as isNodeInFlowchart,Ve as isNonDeletedElement,Tt as isPathALoop,it as isPointInElement,ji as isRectangularElement,Al as isRectanguloidElement,GM as isRestylableFill,ih as isSelectedViaGroup,Zm as isSharpArrow,Jy as isSimpleArrow,$1 as isSomeElementSelected,Jm as isTextBindableContainer,oe as isTextElement,Oo as isUsingAdaptiveRadius,vl as isUsingProportionalRadius,ts as isValidPolygon,j0 as isValidTextContainer,Lx as loadHTMLImageElement,Us as makeNextSelectedElementIds,Dt as maxBindingDistance_simple,cv as maybeHandleArrowPointlikeDrag,aT as maybeParseEmbedSrc,La as measureFontSizeFromWidth,ft as measureText,NT as moveAllLeft,FT as moveAllRight,vu as moveArrowAboveBindable,kT as moveOneLeft,OT as moveOneRight,Fe as mutateElement,br as newArrowElement,Ai as newElement,Ke as newElementWith,nM as newEmbeddableElement,Dc as newFrameElement,rM as newFreeDrawElement,iM as newIframeElement,Cc as newImageElement,Lc as newLinearElement,vc as newMagicFrameElement,si as newTextElement,ob as normalizeArrowhead,rE as normalizeBoundElementsOrder,Yc as normalizeElementOrder,We as normalizeFixedPoint,nD as normalizeSVG,Zi as normalizeText,dr as omitGroupsContainingFrameLikes,bh as omitPartialGroups,Jd as orderByFractionalIndex,Vi as originalContainerCache,QA as parseElementLinkFromURL,Ip as parseTokens,Yt as pointInsideBounds,pg as pointInsideBoundsInclusive,aD as positionElementsOnGrid,as as projectFixedPointOntoDiagonal,Rb as recognizeShape,Uo as redrawTextBoundingBox,oM as refreshTextDimensions,Ih as removeAllElementsFromFrame,oc as removeElementsFromFrame,k1 as removeFromSelectedGroups,VI as renderElement,$I as renderSelectionElement,Rc as rendersOpaqueFill,AI as replaceAllElementsInFrame,zu as rescalePointsInElement,zl as resetOriginalContainerCache,Hx as resizeMultipleElements,Rx as resizeSingleElement,Ox as resizeSingleTextElement,Yx as resizeTest,nh as selectGroup,Ud as selectGroupsForSelectedElements,Yd as selectGroupsFromGivenElements,S0 as setCustomTextMetricsProvider,Y0 as shouldAllowVerticalAlign,DI as shouldApplyFrameClip,Yo as shouldTestInside,XD as showSelectedShapeActions,_s as snapToMid,X0 as suppportsHorizontalAlign,$s as syncInvalidIndices,ec as syncInvalidIndicesImmutable,ni as syncMovedIndices,Hd as toggleLinePolygonState,sP as toolIsArrow,wD as transformElements,Xe as unbindBindingElement,l1 as updateBindings,je as updateBoundElements,Ct as updateBoundPoint,xi as updateElbowArrowPoints,TI as updateFrameMembershipOfSelectedElements,eD as updateImageCache,Rl as updateOriginalContainerCache,gd as validateElbowPoints,hh as validateFractionalIndices,Xt as vectorToHeading,rn as wrapText};
@@ -1,4 +1,5 @@
1
1
  export declare const applyDarkModeFilter: (color: string, enable?: boolean) => string;
2
+ export declare const removeDarkModeFilter: (color: string) => string;
2
3
  export type ColorTuple = readonly [string, string, string, string, string];
3
4
  export type ColorPaletteCustom = {
4
5
  [key: string]: ColorTuple | string;
@@ -28,6 +29,10 @@ export declare const COLOR_PALETTE: {
28
29
  };
29
30
  export type ColorPalette = typeof COLOR_PALETTE;
30
31
  export type ColorPickerColor = keyof typeof COLOR_PALETTE;
32
+ /** number of slots in the color-picker top-picks strip — the strip layout is
33
+ * sized for exactly this many swatches, and pick customization (replace /
34
+ * reorder) preserves it */
35
+ export declare const COLOR_TOP_PICKS_SLOTS = 5;
31
36
  export declare const DEFAULT_ELEMENT_STROKE_PICKS: ColorTuple;
32
37
  export declare const DEFAULT_ELEMENT_BACKGROUND_PICKS: ColorTuple;
33
38
  export declare const BUCKET_FILL_BACKGROUND_PICKS: ColorTuple;
@@ -66,13 +71,6 @@ export declare const DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE: {
66
71
  readonly black: "#1e1e1e";
67
72
  readonly bronze: readonly ["#f8f1ee", "#eaddd7", "#d2bab0", "#a18072", "#846358"];
68
73
  };
69
- /**
70
- * The color the bucket fill tool actually fills with: the shared
71
- * `currentItemBackgroundColor`, falling back to green when that is
72
- * transparent (the tool's picker doesn't offer transparent, but the shared
73
- * state can hold it from the generic shape picker).
74
- */
75
- export declare const getBucketFillBackgroundColor: (backgroundColor: string) => string;
76
74
  export declare const getAllColorsSpecificShade: (index: 0 | 1 | 2 | 3 | 4) => ("#fff5f5" | "#ffc9c9" | "#ff8787" | "#fa5252" | "#e03131" | "#fff0f6" | "#fcc2d7" | "#f783ac" | "#e64980" | "#c2255c" | "#f8f0fc" | "#eebefa" | "#da77f2" | "#be4bdb" | "#9c36b5" | "#f3f0ff" | "#d0bfff" | "#9775fa" | "#7950f2" | "#6741d9" | "#e7f5ff" | "#a5d8ff" | "#4dabf7" | "#228be6" | "#1971c2" | "#e3fafc" | "#99e9f2" | "#3bc9db" | "#15aabf" | "#0c8599" | "#e6fcf5" | "#96f2d7" | "#38d9a9" | "#12b886" | "#099268" | "#ebfbee" | "#b2f2bb" | "#69db7c" | "#40c057" | "#2f9e44" | "#fff9db" | "#ffec99" | "#ffd43b" | "#fab005" | "#f08c00" | "#fff4e6" | "#ffd8a8" | "#ffa94d" | "#fd7e14" | "#e8590c")[];
77
75
  export declare const rgbToHex: (r: number, g: number, b: number, a?: number) => string;
78
76
  /**
@@ -1,2 +1,12 @@
1
1
  import type { ExcalidrawElement } from "./types";
2
+ /**
3
+ * In theory, when we have text elements bound to a container, they
4
+ * should be right after the container element in the elements array.
5
+ * However, this is not guaranteed due to old and potential future bugs.
6
+ *
7
+ * This function sorts containers and their bound texts together. It prefers
8
+ * original z-index of container (i.e. it moves bound text elements after
9
+ * containers).
10
+ */
11
+ export declare const normalizeBoundElementsOrder: <T extends ExcalidrawElement>(elements: readonly T[]) => readonly T[];
2
12
  export declare const normalizeElementOrder: (elements: readonly ExcalidrawElement[]) => readonly ExcalidrawElement[];
@@ -152,8 +152,6 @@ export declare const actionAddToLibrary: {
152
152
  y: number;
153
153
  } | null;
154
154
  objectsSnapModeEnabled: boolean;
155
- userToFollow: import("../types").UserToFollow | null;
156
- followedBy: Set<import("../types").SocketId>;
157
155
  isCropping: boolean;
158
156
  croppingElementId: import("@excalidraw/element/types").ExcalidrawElement["id"] | null;
159
157
  searchMatches: Readonly<{
@@ -165,6 +163,11 @@ export declare const actionAddToLibrary: {
165
163
  [groupId: string]: true;
166
164
  };
167
165
  bindMode: import("@excalidraw/element/types").BindMode;
166
+ colorTopPicks: {
167
+ elementStroke: readonly string[] | null;
168
+ elementBackground: readonly string[] | null;
169
+ bucketFill: readonly string[] | null;
170
+ };
168
171
  };
169
172
  } | {
170
173
  captureUpdate: "EVENTUALLY";
@@ -317,8 +320,6 @@ export declare const actionAddToLibrary: {
317
320
  y: number;
318
321
  } | null;
319
322
  objectsSnapModeEnabled: boolean;
320
- userToFollow: import("../types").UserToFollow | null;
321
- followedBy: Set<import("../types").SocketId>;
322
323
  isCropping: boolean;
323
324
  croppingElementId: import("@excalidraw/element/types").ExcalidrawElement["id"] | null;
324
325
  searchMatches: Readonly<{
@@ -330,6 +331,11 @@ export declare const actionAddToLibrary: {
330
331
  [groupId: string]: true;
331
332
  };
332
333
  bindMode: import("@excalidraw/element/types").BindMode;
334
+ colorTopPicks: {
335
+ elementStroke: readonly string[] | null;
336
+ elementBackground: readonly string[] | null;
337
+ bucketFill: readonly string[] | null;
338
+ };
333
339
  };
334
340
  }> | {
335
341
  captureUpdate: "EVENTUALLY";
@@ -482,8 +488,6 @@ export declare const actionAddToLibrary: {
482
488
  y: number;
483
489
  } | null;
484
490
  objectsSnapModeEnabled: boolean;
485
- userToFollow: import("../types").UserToFollow | null;
486
- followedBy: Set<import("../types").SocketId>;
487
491
  isCropping: boolean;
488
492
  croppingElementId: import("@excalidraw/element/types").ExcalidrawElement["id"] | null;
489
493
  searchMatches: Readonly<{
@@ -495,6 +499,11 @@ export declare const actionAddToLibrary: {
495
499
  [groupId: string]: true;
496
500
  };
497
501
  bindMode: import("@excalidraw/element/types").BindMode;
502
+ colorTopPicks: {
503
+ elementStroke: readonly string[] | null;
504
+ elementBackground: readonly string[] | null;
505
+ bucketFill: readonly string[] | null;
506
+ };
498
507
  };
499
508
  };
500
509
  label: string;
@@ -174,8 +174,6 @@ export declare const actionBindText: {
174
174
  y: number;
175
175
  } | null;
176
176
  objectsSnapModeEnabled: boolean;
177
- userToFollow: import("../types").UserToFollow | null;
178
- followedBy: Set<import("../types").SocketId>;
179
177
  isCropping: boolean;
180
178
  croppingElementId: ExcalidrawElement["id"] | null;
181
179
  searchMatches: Readonly<{
@@ -187,6 +185,11 @@ export declare const actionBindText: {
187
185
  [groupId: string]: true;
188
186
  };
189
187
  bindMode: import("@excalidraw/element/types").BindMode;
188
+ colorTopPicks: {
189
+ elementStroke: readonly string[] | null;
190
+ elementBackground: readonly string[] | null;
191
+ bucketFill: readonly string[] | null;
192
+ };
190
193
  };
191
194
  captureUpdate: "IMMEDIATELY";
192
195
  };
@@ -351,8 +354,6 @@ export declare const actionWrapTextInContainer: {
351
354
  y: number;
352
355
  } | null;
353
356
  objectsSnapModeEnabled: boolean;
354
- userToFollow: import("../types").UserToFollow | null;
355
- followedBy: Set<import("../types").SocketId>;
356
357
  isCropping: boolean;
357
358
  croppingElementId: ExcalidrawElement["id"] | null;
358
359
  searchMatches: Readonly<{
@@ -364,6 +365,11 @@ export declare const actionWrapTextInContainer: {
364
365
  [groupId: string]: true;
365
366
  };
366
367
  bindMode: import("@excalidraw/element/types").BindMode;
368
+ colorTopPicks: {
369
+ elementStroke: readonly string[] | null;
370
+ elementBackground: readonly string[] | null;
371
+ bucketFill: readonly string[] | null;
372
+ };
367
373
  };
368
374
  captureUpdate: "IMMEDIATELY";
369
375
  };
@@ -26,6 +26,11 @@ export declare const actionClearCanvas: {
26
26
  open: boolean;
27
27
  panels: number;
28
28
  };
29
+ colorTopPicks: {
30
+ elementStroke: readonly string[] | null;
31
+ elementBackground: readonly string[] | null;
32
+ bucketFill: readonly string[] | null;
33
+ };
29
34
  activeTool: {
30
35
  lastActiveTool: import("../types").ActiveTool | null;
31
36
  locked: boolean;
@@ -166,8 +171,6 @@ export declare const actionClearCanvas: {
166
171
  y: number;
167
172
  } | null;
168
173
  objectsSnapModeEnabled: boolean;
169
- userToFollow: import("../types").UserToFollow | null;
170
- followedBy: Set<import("../types").SocketId>;
171
174
  lockedMultiSelections: {
172
175
  [groupId: string]: true;
173
176
  };
@@ -189,7 +192,6 @@ export declare const actionZoomIn: {
189
192
  predicate: (elements: readonly import("@excalidraw/element/types").ExcalidrawElement[], appState: AppState, appProps: import("../types").ExcalidrawProps, app: import("../types").AppClassProperties) => boolean;
190
193
  perform: (_elements: readonly import("@excalidraw/element/types").OrderedExcalidrawElement[], appState: Readonly<AppState>, _: unknown, app: import("../types").AppClassProperties) => {
191
194
  appState: {
192
- userToFollow: null;
193
195
  zoom: import("../types").Zoom;
194
196
  scrollX: number;
195
197
  scrollY: number;
@@ -338,7 +340,6 @@ export declare const actionZoomIn: {
338
340
  y: number;
339
341
  } | null;
340
342
  objectsSnapModeEnabled: boolean;
341
- followedBy: Set<import("../types").SocketId>;
342
343
  isCropping: boolean;
343
344
  croppingElementId: import("@excalidraw/element/types").ExcalidrawElement["id"] | null;
344
345
  searchMatches: Readonly<{
@@ -350,6 +351,11 @@ export declare const actionZoomIn: {
350
351
  [groupId: string]: true;
351
352
  };
352
353
  bindMode: import("@excalidraw/element/types").BindMode;
354
+ colorTopPicks: {
355
+ elementStroke: readonly string[] | null;
356
+ elementBackground: readonly string[] | null;
357
+ bucketFill: readonly string[] | null;
358
+ };
353
359
  };
354
360
  captureUpdate: "EVENTUALLY";
355
361
  };
@@ -370,7 +376,6 @@ export declare const actionZoomOut: {
370
376
  predicate: (elements: readonly import("@excalidraw/element/types").ExcalidrawElement[], appState: AppState, appProps: import("../types").ExcalidrawProps, app: import("../types").AppClassProperties) => boolean;
371
377
  perform: (_elements: readonly import("@excalidraw/element/types").OrderedExcalidrawElement[], appState: Readonly<AppState>, _: unknown, app: import("../types").AppClassProperties) => {
372
378
  appState: {
373
- userToFollow: null;
374
379
  zoom: import("../types").Zoom;
375
380
  scrollX: number;
376
381
  scrollY: number;
@@ -519,7 +524,6 @@ export declare const actionZoomOut: {
519
524
  y: number;
520
525
  } | null;
521
526
  objectsSnapModeEnabled: boolean;
522
- followedBy: Set<import("../types").SocketId>;
523
527
  isCropping: boolean;
524
528
  croppingElementId: import("@excalidraw/element/types").ExcalidrawElement["id"] | null;
525
529
  searchMatches: Readonly<{
@@ -531,6 +535,11 @@ export declare const actionZoomOut: {
531
535
  [groupId: string]: true;
532
536
  };
533
537
  bindMode: import("@excalidraw/element/types").BindMode;
538
+ colorTopPicks: {
539
+ elementStroke: readonly string[] | null;
540
+ elementBackground: readonly string[] | null;
541
+ bucketFill: readonly string[] | null;
542
+ };
534
543
  };
535
544
  captureUpdate: "EVENTUALLY";
536
545
  };
@@ -551,7 +560,6 @@ export declare const actionResetZoom: {
551
560
  predicate: (elements: readonly import("@excalidraw/element/types").ExcalidrawElement[], appState: AppState, appProps: import("../types").ExcalidrawProps, app: import("../types").AppClassProperties) => boolean;
552
561
  perform: (_elements: readonly import("@excalidraw/element/types").OrderedExcalidrawElement[], appState: Readonly<AppState>, _: unknown, app: import("../types").AppClassProperties) => {
553
562
  appState: {
554
- userToFollow: null;
555
563
  zoom: import("../types").Zoom;
556
564
  scrollX: number;
557
565
  scrollY: number;
@@ -700,7 +708,6 @@ export declare const actionResetZoom: {
700
708
  y: number;
701
709
  } | null;
702
710
  objectsSnapModeEnabled: boolean;
703
- followedBy: Set<import("../types").SocketId>;
704
711
  isCropping: boolean;
705
712
  croppingElementId: import("@excalidraw/element/types").ExcalidrawElement["id"] | null;
706
713
  searchMatches: Readonly<{
@@ -712,6 +719,11 @@ export declare const actionResetZoom: {
712
719
  [groupId: string]: true;
713
720
  };
714
721
  bindMode: import("@excalidraw/element/types").BindMode;
722
+ colorTopPicks: {
723
+ elementStroke: readonly string[] | null;
724
+ elementBackground: readonly string[] | null;
725
+ bucketFill: readonly string[] | null;
726
+ };
715
727
  };
716
728
  captureUpdate: "EVENTUALLY";
717
729
  };
@@ -880,8 +892,6 @@ export declare const actionZoomToFitSelectionInViewport: {
880
892
  y: number;
881
893
  } | null;
882
894
  objectsSnapModeEnabled: boolean;
883
- userToFollow: import("../types").UserToFollow | null;
884
- followedBy: Set<import("../types").SocketId>;
885
895
  isCropping: boolean;
886
896
  croppingElementId: import("@excalidraw/element/types").ExcalidrawElement["id"] | null;
887
897
  searchMatches: Readonly<{
@@ -893,6 +903,11 @@ export declare const actionZoomToFitSelectionInViewport: {
893
903
  [groupId: string]: true;
894
904
  };
895
905
  bindMode: import("@excalidraw/element/types").BindMode;
906
+ colorTopPicks: {
907
+ elementStroke: readonly string[] | null;
908
+ elementBackground: readonly string[] | null;
909
+ bucketFill: readonly string[] | null;
910
+ };
896
911
  };
897
912
  captureUpdate: "EVENTUALLY";
898
913
  };
@@ -1060,8 +1075,6 @@ export declare const actionZoomToFitSelection: {
1060
1075
  y: number;
1061
1076
  } | null;
1062
1077
  objectsSnapModeEnabled: boolean;
1063
- userToFollow: import("../types").UserToFollow | null;
1064
- followedBy: Set<import("../types").SocketId>;
1065
1078
  isCropping: boolean;
1066
1079
  croppingElementId: import("@excalidraw/element/types").ExcalidrawElement["id"] | null;
1067
1080
  searchMatches: Readonly<{
@@ -1073,6 +1086,11 @@ export declare const actionZoomToFitSelection: {
1073
1086
  [groupId: string]: true;
1074
1087
  };
1075
1088
  bindMode: import("@excalidraw/element/types").BindMode;
1089
+ colorTopPicks: {
1090
+ elementStroke: readonly string[] | null;
1091
+ elementBackground: readonly string[] | null;
1092
+ bucketFill: readonly string[] | null;
1093
+ };
1076
1094
  };
1077
1095
  captureUpdate: "EVENTUALLY";
1078
1096
  };
@@ -1240,8 +1258,6 @@ export declare const actionZoomToFit: {
1240
1258
  y: number;
1241
1259
  } | null;
1242
1260
  objectsSnapModeEnabled: boolean;
1243
- userToFollow: import("../types").UserToFollow | null;
1244
- followedBy: Set<import("../types").SocketId>;
1245
1261
  isCropping: boolean;
1246
1262
  croppingElementId: import("@excalidraw/element/types").ExcalidrawElement["id"] | null;
1247
1263
  searchMatches: Readonly<{
@@ -1253,6 +1269,11 @@ export declare const actionZoomToFit: {
1253
1269
  [groupId: string]: true;
1254
1270
  };
1255
1271
  bindMode: import("@excalidraw/element/types").BindMode;
1272
+ colorTopPicks: {
1273
+ elementStroke: readonly string[] | null;
1274
+ elementBackground: readonly string[] | null;
1275
+ bucketFill: readonly string[] | null;
1276
+ };
1256
1277
  };
1257
1278
  captureUpdate: "EVENTUALLY";
1258
1279
  };