moi-computer 0.12.0 → 0.12.1-next.0

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 (140) hide show
  1. package/README.md +1 -1
  2. package/client/AGENTS.md +2 -2
  3. package/client/api/app-ui-keys.ts +1 -1
  4. package/client/api/workspace-keys.ts +1 -3
  5. package/client/app/routes/WorkspaceRoute.tsx +2 -8
  6. package/client/features/applets/applet-runtime.ts +11 -13
  7. package/client/features/chat/ChatPanel.tsx +70 -49
  8. package/client/features/chat/ChatPopup.tsx +81 -8
  9. package/client/features/chat/applet-chat-intents.ts +31 -12
  10. package/client/features/chat/chat-send.ts +33 -1
  11. package/client/features/chat/chat-store.ts +10 -0
  12. package/client/features/chat/composer/ChatComposer.tsx +24 -27
  13. package/client/features/chat/composer/ModelPicker.tsx +3 -3
  14. package/client/features/chat/composer/useWorkspaceComposerState.tsx +3 -3
  15. package/client/features/chat/connection/chat-frames.ts +14 -7
  16. package/client/features/chat/messages/ChatEmptyState.tsx +33 -19
  17. package/client/features/chat/messages/MarkdownContent.tsx +3 -3
  18. package/client/features/chat/messages/fork-history.ts +14 -0
  19. package/client/features/chat/sessions/ChatSelector.tsx +138 -79
  20. package/client/features/chat/sessions/api.ts +109 -19
  21. package/client/features/chat/sessions/browser-tab-state.ts +30 -7
  22. package/client/features/chat/sessions/useSelectedSession.ts +217 -51
  23. package/client/features/chat/useChat.ts +43 -45
  24. package/client/features/collab/client.ts +10 -11
  25. package/client/features/collab/hooks.tsx +6 -11
  26. package/client/features/collab/host-state.ts +57 -128
  27. package/client/features/collab/provider.tsx +3 -3
  28. package/client/features/collab/testing/fake-engine.ts +6 -27
  29. package/client/features/collab/workspace-users-menu.tsx +3 -7
  30. package/client/features/drawings/{useViewBuilderSketch.ts → useViewSketch.ts} +7 -7
  31. package/client/features/home/HomePage.tsx +2 -2
  32. package/client/features/overview/Overview.tsx +3 -6
  33. package/client/features/overview/default/ViewsWidget.tsx +5 -12
  34. package/client/features/overview/default/registry.tsx +2 -4
  35. package/client/features/views/PendingViewScreen.tsx +279 -0
  36. package/client/features/views/ViewManager.tsx +10 -10
  37. package/client/features/views/api.ts +63 -130
  38. package/client/features/views/useViewActions.ts +151 -0
  39. package/client/features/views/useViewDrafts.ts +79 -0
  40. package/client/features/views/view-presentation.ts +4 -5
  41. package/client/features/views/view-submission.ts +88 -0
  42. package/client/features/workspace/WorkspaceMenu.tsx +63 -0
  43. package/client/features/workspace/WorkspaceScreen.tsx +180 -375
  44. package/client/features/workspace/browser-tab-state.ts +16 -9
  45. package/client/features/workspace/moi-context.ts +13 -15
  46. package/client/features/workspace/tab-resolution.ts +16 -29
  47. package/client/features/workspace/useWorkspaceNavigation.ts +146 -104
  48. package/client/index.tsx +5 -1
  49. package/client/runtime/useWorkspaceEvents.ts +7 -6
  50. package/client/store/ui.ts +25 -29
  51. package/dist/chunk-1zhnhy00.js +1 -0
  52. package/dist/chunk-27501vke.js +1 -0
  53. package/dist/{chunk-jf6czgrz.js → chunk-9xtv6djt.js} +2 -2
  54. package/dist/chunk-am1x230f.js +2 -0
  55. package/dist/{chunk-nez8sdta.js → chunk-darpsw65.js} +1 -1
  56. package/dist/{chunk-97eg9mjn.js → chunk-gps4qc38.js} +1 -1
  57. package/dist/{chunk-3a48fyf7.js → chunk-hzwr8dp8.js} +4 -4
  58. package/dist/{chunk-efdyz6xp.js → chunk-j905va8r.js} +1 -1
  59. package/dist/chunk-n33w9y38.js +10 -0
  60. package/dist/chunk-r63ks44z.js +68 -0
  61. package/dist/{chunk-vfpsc75k.js → chunk-vqpkqtdr.js} +1 -1
  62. package/dist/chunk-wd46nk26.css +1 -0
  63. package/dist/chunk-xgt7vxt9.js +1 -0
  64. package/dist/{chunk-z3byfve5.js → chunk-yvzhwtfa.js} +2 -2
  65. package/dist/index.html +1 -1
  66. package/lib/ids.ts +2 -5
  67. package/lib/moi-context.ts +100 -73
  68. package/lib/navigation.ts +48 -87
  69. package/lib/session-drafts.ts +10 -0
  70. package/lib/types.ts +64 -31
  71. package/lib/view-build-directives.ts +12 -0
  72. package/lib/workspace-layout.ts +1 -1
  73. package/lib/workspace-tabs.ts +12 -7
  74. package/package.json +3 -1
  75. package/server/agent-launcher.ts +27 -0
  76. package/server/api.ts +119 -209
  77. package/server/app-config.ts +21 -2
  78. package/server/applets/build-worker.ts +2 -1
  79. package/server/applets/view-source.ts +7 -1
  80. package/server/cli-env.ts +72 -50
  81. package/server/cli.ts +101 -64
  82. package/server/control.ts +82 -63
  83. package/server/data-dir.ts +13 -0
  84. package/server/functions.ts +2 -1
  85. package/server/harness/README.md +8 -0
  86. package/server/harness/acp/adapter.ts +2 -2
  87. package/server/harness/acp/client.ts +2 -1
  88. package/server/harness/acp/discovery.ts +3 -3
  89. package/server/harness/acp/session.ts +6 -9
  90. package/server/harness/claude-code/adapter.ts +13 -8
  91. package/server/harness/claude-code/auth.ts +3 -2
  92. package/server/harness/claude-code/cli.ts +3 -1
  93. package/server/harness/claude-code/git-worktree.ts +5 -2
  94. package/server/harness/claude-code/index.ts +5 -0
  95. package/server/harness/claude-code/mcp.ts +2 -0
  96. package/server/harness/claude-code/models.ts +2 -0
  97. package/server/harness/claude-code/session.ts +5 -34
  98. package/server/harness/claude-code/sessions.ts +8 -12
  99. package/server/harness/codex/NOTES.md +23 -4
  100. package/server/harness/codex/adapter.ts +5 -3
  101. package/server/harness/codex/client.ts +13 -21
  102. package/server/harness/codex/index.ts +18 -0
  103. package/server/harness/codex/session.ts +6 -14
  104. package/server/harness/codex/thread-list.ts +74 -0
  105. package/server/harness/fork.ts +12 -0
  106. package/server/harness/openclaw/adapter.ts +3 -3
  107. package/server/harness/openclaw/session.ts +2 -30
  108. package/server/harness/session-title.ts +12 -3
  109. package/server/harness/types.ts +8 -3
  110. package/server/moi-scaffold.ts +2 -1
  111. package/server/pending-views.ts +164 -0
  112. package/server/registry.ts +14 -4
  113. package/server/selected-session.ts +91 -44
  114. package/server/service.ts +16 -2
  115. package/server/session-archive.ts +32 -0
  116. package/server/session-config.ts +16 -111
  117. package/server/session-lifecycle.ts +17 -0
  118. package/server/session-store.ts +127 -0
  119. package/server/status.ts +3 -1
  120. package/server/tabs.ts +7 -10
  121. package/server/view-sessions.ts +267 -0
  122. package/server/views.ts +30 -41
  123. package/server/web.ts +47 -45
  124. package/server/workspace-env.ts +27 -0
  125. package/server/workspace-init.ts +6 -2
  126. package/workspace/.claude/skills/moi-workspace/SKILL.md +49 -20
  127. package/workspace/.claude/skills/moi-workspace/references/COLLAB.md +2 -5
  128. package/client/features/views/ViewBuilder.tsx +0 -239
  129. package/client/features/views/useViewBuilderActions.ts +0 -103
  130. package/client/features/views/useViewBuilderDrafts.ts +0 -68
  131. package/dist/chunk-2jncyq65.js +0 -1
  132. package/dist/chunk-e2q5ken7.js +0 -68
  133. package/dist/chunk-h2kj1ysj.js +0 -1
  134. package/dist/chunk-nzwgm8vc.css +0 -1
  135. package/dist/chunk-ph0h6h86.js +0 -1
  136. package/dist/chunk-ryg9z3kn.js +0 -10
  137. package/dist/chunk-tpn177bt.js +0 -2
  138. package/lib/view-builder-directives.ts +0 -16
  139. package/server/chat-selection.ts +0 -22
  140. package/server/view-builders.ts +0 -453
@@ -1,4 +1,4 @@
1
- import"/chunk-pcnahct1.js";import{Cc as r10,Jb as U40,La as G40,Q as nQ,Rb as V40,U as W40,Vb as N40,Xa as H40,Xb as B40,_a as $40,b as c,c as rJ0,cc as Dy,da as z40,gc as J40,hb as _40,m as SJ,sc as s10,tc as My,yb as F40,yc as L40,zc as k40}from"/chunk-ryg9z3kn.js";import{Qc as m,Uc as E40}from"/chunk-z3byfve5.js";import{Wc as E,Xc as oQ,Yc as f7,Zc as wd}from"/chunk-97eg9mjn.js";var Xx=oQ((u_,KK)=>{var I40=200,hD="__lodash_hash_undefined__",s_=1,vy=2,Sy=9007199254740991,m_="[object Arguments]",TD="[object Array]",w40="[object AsyncFunction]",fy="[object Boolean]",gy="[object Date]",hy="[object Error]",uy="[object Function]",b40="[object GeneratorFunction]",c_="[object Map]",my="[object Number]",T40="[object Null]",XK="[object Object]",ky="[object Promise]",y40="[object Proxy]",cy="[object RegExp]",l_="[object Set]",ly="[object String]",x40="[object Symbol]",v40="[object Undefined]",yD="[object WeakMap]",py="[object ArrayBuffer]",p_="[object DataView]",S40="[object Float32Array]",f40="[object Float64Array]",g40="[object Int8Array]",h40="[object Int16Array]",u40="[object Int32Array]",m40="[object Uint8Array]",c40="[object Uint8ClampedArray]",l40="[object Uint16Array]",p40="[object Uint32Array]",d40=/[\\^$.*+?()[\]{}|]/g,i40=/^\[object .+?Constructor\]$/,n40=/^(?:0|[1-9]\d*)$/,m4={};m4[S40]=m4[f40]=m4[g40]=m4[h40]=m4[u40]=m4[m40]=m4[c40]=m4[l40]=m4[p40]=!0;m4[m_]=m4[TD]=m4[py]=m4[fy]=m4[p_]=m4[gy]=m4[hy]=m4[uy]=m4[c_]=m4[my]=m4[XK]=m4[cy]=m4[l_]=m4[ly]=m4[yD]=!1;var dy=typeof global=="object"&&global&&global.Object===Object&&global,s40=typeof self=="object"&&self&&self.Object===Object&&self,LJ=dy||s40||Function("return this")(),iy=typeof u_=="object"&&u_&&!u_.nodeType&&u_,Ey=iy&&typeof KK=="object"&&KK&&!KK.nodeType&&KK,ny=Ey&&Ey.exports===iy,ID=ny&&dy.process,Ay=function(){try{return ID&&ID.binding&&ID.binding("util")}catch(J){}}(),Cy=Ay&&Ay.isTypedArray;function r40(J,Q){var Z=-1,q=J==null?0:J.length,X=0,K=[];while(++Z<q){var Y=J[Z];if(Q(Y,Z,J))K[X++]=Y}return K}function a40(J,Q){var Z=-1,q=Q.length,X=J.length;while(++Z<q)J[X+Z]=Q[Z];return J}function o40(J,Q){var Z=-1,q=J==null?0:J.length;while(++Z<q)if(Q(J[Z],Z,J))return!0;return!1}function t40(J,Q){var Z=-1,q=Array(J);while(++Z<J)q[Z]=Q(Z);return q}function e40(J){return function(Q){return J(Q)}}function J60(J,Q){return J.has(Q)}function Q60(J,Q){return J==null?void 0:J[Q]}function Z60(J){var Q=-1,Z=Array(J.size);return J.forEach(function(q,X){Z[++Q]=[X,q]}),Z}function q60(J,Q){return function(Z){return J(Q(Z))}}function X60(J){var Q=-1,Z=Array(J.size);return J.forEach(function(q){Z[++Q]=q}),Z}var K60=Array.prototype,Y60=Function.prototype,r_=Object.prototype,wD=LJ["__core-js_shared__"],sy=Y60.toString,D2=r_.hasOwnProperty,Py=function(){var J=/[^.]+$/.exec(wD&&wD.keys&&wD.keys.IE_PROTO||"");return J?"Symbol(src)_1."+J:""}(),ry=r_.toString,W60=RegExp("^"+sy.call(D2).replace(d40,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Iy=ny?LJ.Buffer:void 0,d_=LJ.Symbol,wy=LJ.Uint8Array,ay=r_.propertyIsEnumerable,z60=K60.splice,gq=d_?d_.toStringTag:void 0,by=Object.getOwnPropertySymbols,G60=Iy?Iy.isBuffer:void 0,H60=q60(Object.keys,Object),xD=YK(LJ,"DataView"),tW=YK(LJ,"Map"),vD=YK(LJ,"Promise"),SD=YK(LJ,"Set"),fD=YK(LJ,"WeakMap"),eW=YK(Object,"create"),$60=mq(xD),_60=mq(tW),F60=mq(vD),U60=mq(SD),V60=mq(fD),Ty=d_?d_.prototype:void 0,bD=Ty?Ty.valueOf:void 0;function hq(J){var Q=-1,Z=J==null?0:J.length;this.clear();while(++Q<Z){var q=J[Q];this.set(q[0],q[1])}}function N60(){this.__data__=eW?eW(null):{},this.size=0}function B60(J){var Q=this.has(J)&&delete this.__data__[J];return this.size-=Q?1:0,Q}function L60(J){var Q=this.__data__;if(eW){var Z=Q[J];return Z===hD?void 0:Z}return D2.call(Q,J)?Q[J]:void 0}function O60(J){var Q=this.__data__;return eW?Q[J]!==void 0:D2.call(Q,J)}function D60(J,Q){var Z=this.__data__;return this.size+=this.has(J)?0:1,Z[J]=eW&&Q===void 0?hD:Q,this}hq.prototype.clear=N60;hq.prototype.delete=B60;hq.prototype.get=L60;hq.prototype.has=O60;hq.prototype.set=D60;function OJ(J){var Q=-1,Z=J==null?0:J.length;this.clear();while(++Q<Z){var q=J[Q];this.set(q[0],q[1])}}function M60(){this.__data__=[],this.size=0}function j60(J){var Q=this.__data__,Z=a_(Q,J);if(Z<0)return!1;var q=Q.length-1;if(Z==q)Q.pop();else z60.call(Q,Z,1);return--this.size,!0}function R60(J){var Q=this.__data__,Z=a_(Q,J);return Z<0?void 0:Q[Z][1]}function k60(J){return a_(this.__data__,J)>-1}function E60(J,Q){var Z=this.__data__,q=a_(Z,J);if(q<0)++this.size,Z.push([J,Q]);else Z[q][1]=Q;return this}OJ.prototype.clear=M60;OJ.prototype.delete=j60;OJ.prototype.get=R60;OJ.prototype.has=k60;OJ.prototype.set=E60;function uq(J){var Q=-1,Z=J==null?0:J.length;this.clear();while(++Q<Z){var q=J[Q];this.set(q[0],q[1])}}function A60(){this.size=0,this.__data__={hash:new hq,map:new(tW||OJ),string:new hq}}function C60(J){var Q=o_(this,J).delete(J);return this.size-=Q?1:0,Q}function P60(J){return o_(this,J).get(J)}function I60(J){return o_(this,J).has(J)}function w60(J,Q){var Z=o_(this,J),q=Z.size;return Z.set(J,Q),this.size+=Z.size==q?0:1,this}uq.prototype.clear=A60;uq.prototype.delete=C60;uq.prototype.get=P60;uq.prototype.has=I60;uq.prototype.set=w60;function i_(J){var Q=-1,Z=J==null?0:J.length;this.__data__=new uq;while(++Q<Z)this.add(J[Q])}function b60(J){return this.__data__.set(J,hD),this}function T60(J){return this.__data__.has(J)}i_.prototype.add=i_.prototype.push=b60;i_.prototype.has=T60;function aQ(J){var Q=this.__data__=new OJ(J);this.size=Q.size}function y60(){this.__data__=new OJ,this.size=0}function x60(J){var Q=this.__data__,Z=Q.delete(J);return this.size=Q.size,Z}function v60(J){return this.__data__.get(J)}function S60(J){return this.__data__.has(J)}function f60(J,Q){var Z=this.__data__;if(Z instanceof OJ){var q=Z.__data__;if(!tW||q.length<I40-1)return q.push([J,Q]),this.size=++Z.size,this;Z=this.__data__=new uq(q)}return Z.set(J,Q),this.size=Z.size,this}aQ.prototype.clear=y60;aQ.prototype.delete=x60;aQ.prototype.get=v60;aQ.prototype.has=S60;aQ.prototype.set=f60;function g60(J,Q){var Z=n_(J),q=!Z&&e60(J),X=!Z&&!q&&gD(J),K=!Z&&!q&&!X&&qx(J),Y=Z||q||X||K,W=Y?t40(J.length,String):[],z=W.length;for(var G in J)if((Q||D2.call(J,G))&&!(Y&&(G=="length"||X&&(G=="offset"||G=="parent")||K&&(G=="buffer"||G=="byteLength"||G=="byteOffset")||s60(G,z))))W.push(G);return W}function a_(J,Q){var Z=J.length;while(Z--)if(ey(J[Z][0],Q))return Z;return-1}function h60(J,Q,Z){var q=Q(J);return n_(J)?q:a40(q,Z(J))}function Qz(J){if(J==null)return J===void 0?v40:T40;return gq&&gq in Object(J)?i60(J):t60(J)}function yy(J){return Jz(J)&&Qz(J)==m_}function oy(J,Q,Z,q,X){if(J===Q)return!0;if(J==null||Q==null||!Jz(J)&&!Jz(Q))return J!==J&&Q!==Q;return u60(J,Q,Z,q,oy,X)}function u60(J,Q,Z,q,X,K){var Y=n_(J),W=n_(Q),z=Y?TD:rQ(J),G=W?TD:rQ(Q);z=z==m_?XK:z,G=G==m_?XK:G;var $=z==XK,H=G==XK,_=z==G;if(_&&gD(J)){if(!gD(Q))return!1;Y=!0,$=!1}if(_&&!$)return K||(K=new aQ),Y||qx(J)?ty(J,Q,Z,q,X,K):p60(J,Q,z,Z,q,X,K);if(!(Z&s_)){var F=$&&D2.call(J,"__wrapped__"),U=H&&D2.call(Q,"__wrapped__");if(F||U){var V=F?J.value():J,B=U?Q.value():Q;return K||(K=new aQ),X(V,B,Z,q,K)}}if(!_)return!1;return K||(K=new aQ),d60(J,Q,Z,q,X,K)}function m60(J){if(!Zx(J)||a60(J))return!1;var Q=Jx(J)?W60:i40;return Q.test(mq(J))}function c60(J){return Jz(J)&&Qx(J.length)&&!!m4[Qz(J)]}function l60(J){if(!o60(J))return H60(J);var Q=[];for(var Z in Object(J))if(D2.call(J,Z)&&Z!="constructor")Q.push(Z);return Q}function ty(J,Q,Z,q,X,K){var Y=Z&s_,W=J.length,z=Q.length;if(W!=z&&!(Y&&z>W))return!1;var G=K.get(J);if(G&&K.get(Q))return G==Q;var $=-1,H=!0,_=Z&vy?new i_:void 0;K.set(J,Q),K.set(Q,J);while(++$<W){var F=J[$],U=Q[$];if(q)var V=Y?q(U,F,$,Q,J,K):q(F,U,$,J,Q,K);if(V!==void 0){if(V)continue;H=!1;break}if(_){if(!o40(Q,function(B,N){if(!J60(_,N)&&(F===B||X(F,B,Z,q,K)))return _.push(N)})){H=!1;break}}else if(!(F===U||X(F,U,Z,q,K))){H=!1;break}}return K.delete(J),K.delete(Q),H}function p60(J,Q,Z,q,X,K,Y){switch(Z){case p_:if(J.byteLength!=Q.byteLength||J.byteOffset!=Q.byteOffset)return!1;J=J.buffer,Q=Q.buffer;case py:if(J.byteLength!=Q.byteLength||!K(new wy(J),new wy(Q)))return!1;return!0;case fy:case gy:case my:return ey(+J,+Q);case hy:return J.name==Q.name&&J.message==Q.message;case cy:case ly:return J==Q+"";case c_:var W=Z60;case l_:var z=q&s_;if(W||(W=X60),J.size!=Q.size&&!z)return!1;var G=Y.get(J);if(G)return G==Q;q|=vy,Y.set(J,Q);var $=ty(W(J),W(Q),q,X,K,Y);return Y.delete(J),$;case x40:if(bD)return bD.call(J)==bD.call(Q)}return!1}function d60(J,Q,Z,q,X,K){var Y=Z&s_,W=xy(J),z=W.length,G=xy(Q),$=G.length;if(z!=$&&!Y)return!1;var H=z;while(H--){var _=W[H];if(!(Y?_ in Q:D2.call(Q,_)))return!1}var F=K.get(J);if(F&&K.get(Q))return F==Q;var U=!0;K.set(J,Q),K.set(Q,J);var V=Y;while(++H<z){_=W[H];var B=J[_],N=Q[_];if(q)var L=Y?q(N,B,_,Q,J,K):q(B,N,_,J,Q,K);if(!(L===void 0?B===N||X(B,N,Z,q,K):L)){U=!1;break}V||(V=_=="constructor")}if(U&&!V){var D=J.constructor,O=Q.constructor;if(D!=O&&(("constructor"in J)&&("constructor"in Q))&&!(typeof D=="function"&&D instanceof D&&typeof O=="function"&&O instanceof O))U=!1}return K.delete(J),K.delete(Q),U}function xy(J){return h60(J,Z50,n60)}function o_(J,Q){var Z=J.__data__;return r60(Q)?Z[typeof Q=="string"?"string":"hash"]:Z.map}function YK(J,Q){var Z=Q60(J,Q);return m60(Z)?Z:void 0}function i60(J){var Q=D2.call(J,gq),Z=J[gq];try{J[gq]=void 0;var q=!0}catch(K){}var X=ry.call(J);if(q)if(Q)J[gq]=Z;else delete J[gq];return X}var n60=!by?q50:function(J){if(J==null)return[];return J=Object(J),r40(by(J),function(Q){return ay.call(J,Q)})},rQ=Qz;if(xD&&rQ(new xD(new ArrayBuffer(1)))!=p_||tW&&rQ(new tW)!=c_||vD&&rQ(vD.resolve())!=ky||SD&&rQ(new SD)!=l_||fD&&rQ(new fD)!=yD)rQ=function(J){var Q=Qz(J),Z=Q==XK?J.constructor:void 0,q=Z?mq(Z):"";if(q)switch(q){case $60:return p_;case _60:return c_;case F60:return ky;case U60:return l_;case V60:return yD}return Q};function s60(J,Q){return Q=Q==null?Sy:Q,!!Q&&(typeof J=="number"||n40.test(J))&&(J>-1&&J%1==0&&J<Q)}function r60(J){var Q=typeof J;return Q=="string"||Q=="number"||Q=="symbol"||Q=="boolean"?J!=="__proto__":J===null}function a60(J){return!!Py&&Py in J}function o60(J){var Q=J&&J.constructor,Z=typeof Q=="function"&&Q.prototype||r_;return J===Z}function t60(J){return ry.call(J)}function mq(J){if(J!=null){try{return sy.call(J)}catch(Q){}try{return J+""}catch(Q){}}return""}function ey(J,Q){return J===Q||J!==J&&Q!==Q}var e60=yy(function(){return arguments}())?yy:function(J){return Jz(J)&&D2.call(J,"callee")&&!ay.call(J,"callee")},n_=Array.isArray;function J50(J){return J!=null&&Qx(J.length)&&!Jx(J)}var gD=G60||X50;function Q50(J,Q){return oy(J,Q)}function Jx(J){if(!Zx(J))return!1;var Q=Qz(J);return Q==uy||Q==b40||Q==w40||Q==y40}function Qx(J){return typeof J=="number"&&J>-1&&J%1==0&&J<=Sy}function Zx(J){var Q=typeof J;return J!=null&&(Q=="object"||Q=="function")}function Jz(J){return J!=null&&typeof J=="object"}var qx=Cy?e40(Cy):c60;function Z50(J){return J50(J)?g60(J):l60(J)}function q50(){return[]}function X50(){return!1}KK.exports=Q50});var eD=oQ((t_,zK)=>{var K50=200,aD="__lodash_hash_undefined__",Vx=1,XF=2,Nx=9007199254740991,e_="[object Arguments]",cD="[object Array]",Bx="[object Boolean]",Lx="[object Date]",Ox="[object Error]",Dx="[object Function]",Y50="[object GeneratorFunction]",JF="[object Map]",Mx="[object Number]",WK="[object Object]",Kx="[object Promise]",jx="[object RegExp]",QF="[object Set]",Rx="[object String]",W50="[object Symbol]",lD="[object WeakMap]",kx="[object ArrayBuffer]",ZF="[object DataView]",z50="[object Float32Array]",G50="[object Float64Array]",H50="[object Int8Array]",$50="[object Int16Array]",_50="[object Int32Array]",F50="[object Uint8Array]",U50="[object Uint8ClampedArray]",V50="[object Uint16Array]",N50="[object Uint32Array]",B50=/[\\^$.*+?()[\]{}|]/g,L50=/^\[object .+?Constructor\]$/,O50=/^(?:0|[1-9]\d*)$/,c4={};c4[z50]=c4[G50]=c4[H50]=c4[$50]=c4[_50]=c4[F50]=c4[U50]=c4[V50]=c4[N50]=!0;c4[e_]=c4[cD]=c4[kx]=c4[Bx]=c4[ZF]=c4[Lx]=c4[Ox]=c4[Dx]=c4[JF]=c4[Mx]=c4[WK]=c4[jx]=c4[QF]=c4[Rx]=c4[lD]=!1;var Ex=typeof global=="object"&&global&&global.Object===Object&&global,D50=typeof self=="object"&&self&&self.Object===Object&&self,JZ=Ex||D50||Function("return this")(),Ax=typeof t_=="object"&&t_&&!t_.nodeType&&t_,Yx=Ax&&typeof zK=="object"&&zK&&!zK.nodeType&&zK,M50=Yx&&Yx.exports===Ax,Wx=M50&&Ex.process,zx=function(){try{return Wx&&Wx.binding("util")}catch(J){}}(),Gx=zx&&zx.isTypedArray;function j50(J,Q){var Z=-1,q=J?J.length:0;while(++Z<q)if(Q(J[Z],Z,J))return!0;return!1}function R50(J,Q){var Z=-1,q=Array(J);while(++Z<J)q[Z]=Q(Z);return q}function k50(J){return function(Q){return J(Q)}}function E50(J,Q){return J==null?void 0:J[Q]}function pD(J){var Q=!1;if(J!=null&&typeof J.toString!="function")try{Q=!!(J+"")}catch(Z){}return Q}function A50(J){var Q=-1,Z=Array(J.size);return J.forEach(function(q,X){Z[++Q]=[X,q]}),Z}function C50(J,Q){return function(Z){return J(Q(Z))}}function P50(J){var Q=-1,Z=Array(J.size);return J.forEach(function(q){Z[++Q]=q}),Z}var I50=Array.prototype,w50=Function.prototype,KF=Object.prototype,uD=JZ["__core-js_shared__"],Hx=function(){var J=/[^.]+$/.exec(uD&&uD.keys&&uD.keys.IE_PROTO||"");return J?"Symbol(src)_1."+J:""}(),Cx=w50.toString,DJ=KF.hasOwnProperty,Xz=KF.toString,b50=RegExp("^"+Cx.call(DJ).replace(B50,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),$x=JZ.Symbol,_x=JZ.Uint8Array,T50=KF.propertyIsEnumerable,y50=I50.splice,x50=C50(Object.keys,Object),dD=GK(JZ,"DataView"),Zz=GK(JZ,"Map"),iD=GK(JZ,"Promise"),nD=GK(JZ,"Set"),sD=GK(JZ,"WeakMap"),qz=GK(Object,"create"),v50=pq(dD),S50=pq(Zz),f50=pq(iD),g50=pq(nD),h50=pq(sD),Fx=$x?$x.prototype:void 0,mD=Fx?Fx.valueOf:void 0;function cq(J){var Q=-1,Z=J?J.length:0;this.clear();while(++Q<Z){var q=J[Q];this.set(q[0],q[1])}}function u50(){this.__data__=qz?qz(null):{}}function m50(J){return this.has(J)&&delete this.__data__[J]}function c50(J){var Q=this.__data__;if(qz){var Z=Q[J];return Z===aD?void 0:Z}return DJ.call(Q,J)?Q[J]:void 0}function l50(J){var Q=this.__data__;return qz?Q[J]!==void 0:DJ.call(Q,J)}function p50(J,Q){var Z=this.__data__;return Z[J]=qz&&Q===void 0?aD:Q,this}cq.prototype.clear=u50;cq.prototype.delete=m50;cq.prototype.get=c50;cq.prototype.has=l50;cq.prototype.set=p50;function MJ(J){var Q=-1,Z=J?J.length:0;this.clear();while(++Q<Z){var q=J[Q];this.set(q[0],q[1])}}function d50(){this.__data__=[]}function i50(J){var Q=this.__data__,Z=YF(Q,J);if(Z<0)return!1;var q=Q.length-1;if(Z==q)Q.pop();else y50.call(Q,Z,1);return!0}function n50(J){var Q=this.__data__,Z=YF(Q,J);return Z<0?void 0:Q[Z][1]}function s50(J){return YF(this.__data__,J)>-1}function r50(J,Q){var Z=this.__data__,q=YF(Z,J);if(q<0)Z.push([J,Q]);else Z[q][1]=Q;return this}MJ.prototype.clear=d50;MJ.prototype.delete=i50;MJ.prototype.get=n50;MJ.prototype.has=s50;MJ.prototype.set=r50;function lq(J){var Q=-1,Z=J?J.length:0;this.clear();while(++Q<Z){var q=J[Q];this.set(q[0],q[1])}}function a50(){this.__data__={hash:new cq,map:new(Zz||MJ),string:new cq}}function o50(J){return WF(this,J).delete(J)}function t50(J){return WF(this,J).get(J)}function e50(J){return WF(this,J).has(J)}function J80(J,Q){return WF(this,J).set(J,Q),this}lq.prototype.clear=a50;lq.prototype.delete=o50;lq.prototype.get=t50;lq.prototype.has=e50;lq.prototype.set=J80;function qF(J){var Q=-1,Z=J?J.length:0;this.__data__=new lq;while(++Q<Z)this.add(J[Q])}function Q80(J){return this.__data__.set(J,aD),this}function Z80(J){return this.__data__.has(J)}qF.prototype.add=qF.prototype.push=Q80;qF.prototype.has=Z80;function eQ(J){this.__data__=new MJ(J)}function q80(){this.__data__=new MJ}function X80(J){return this.__data__.delete(J)}function K80(J){return this.__data__.get(J)}function Y80(J){return this.__data__.has(J)}function W80(J,Q){var Z=this.__data__;if(Z instanceof MJ){var q=Z.__data__;if(!Zz||q.length<K50-1)return q.push([J,Q]),this;Z=this.__data__=new lq(q)}return Z.set(J,Q),this}eQ.prototype.clear=q80;eQ.prototype.delete=X80;eQ.prototype.get=K80;eQ.prototype.has=Y80;eQ.prototype.set=W80;function z80(J,Q){var Z=rD(J)||D80(J)?R50(J.length,String):[],q=Z.length,X=!!q;for(var K in J)if((Q||DJ.call(J,K))&&!(X&&(K=="length"||N80(K,q))))Z.push(K);return Z}function YF(J,Q){var Z=J.length;while(Z--)if(wx(J[Z][0],Q))return Z;return-1}function G80(J){return Xz.call(J)}function Px(J,Q,Z,q,X){if(J===Q)return!0;if(J==null||Q==null||!oD(J)&&!tD(Q))return J!==J&&Q!==Q;return H80(J,Q,Px,Z,q,X)}function H80(J,Q,Z,q,X,K){var Y=rD(J),W=rD(Q),z=cD,G=cD;if(!Y)z=tQ(J),z=z==e_?WK:z;if(!W)G=tQ(Q),G=G==e_?WK:G;var $=z==WK&&!pD(J),H=G==WK&&!pD(Q),_=z==G;if(_&&!$)return K||(K=new eQ),Y||R80(J)?Ix(J,Q,Z,q,X,K):U80(J,Q,z,Z,q,X,K);if(!(X&XF)){var F=$&&DJ.call(J,"__wrapped__"),U=H&&DJ.call(Q,"__wrapped__");if(F||U){var V=F?J.value():J,B=U?Q.value():Q;return K||(K=new eQ),Z(V,B,q,X,K)}}if(!_)return!1;return K||(K=new eQ),V80(J,Q,Z,q,X,K)}function $80(J){if(!oD(J)||L80(J))return!1;var Q=Tx(J)||pD(J)?b50:L50;return Q.test(pq(J))}function _80(J){return tD(J)&&yx(J.length)&&!!c4[Xz.call(J)]}function F80(J){if(!O80(J))return x50(J);var Q=[];for(var Z in Object(J))if(DJ.call(J,Z)&&Z!="constructor")Q.push(Z);return Q}function Ix(J,Q,Z,q,X,K){var Y=X&XF,W=J.length,z=Q.length;if(W!=z&&!(Y&&z>W))return!1;var G=K.get(J);if(G&&K.get(Q))return G==Q;var $=-1,H=!0,_=X&Vx?new qF:void 0;K.set(J,Q),K.set(Q,J);while(++$<W){var F=J[$],U=Q[$];if(q)var V=Y?q(U,F,$,Q,J,K):q(F,U,$,J,Q,K);if(V!==void 0){if(V)continue;H=!1;break}if(_){if(!j50(Q,function(B,N){if(!_.has(N)&&(F===B||Z(F,B,q,X,K)))return _.add(N)})){H=!1;break}}else if(!(F===U||Z(F,U,q,X,K))){H=!1;break}}return K.delete(J),K.delete(Q),H}function U80(J,Q,Z,q,X,K,Y){switch(Z){case ZF:if(J.byteLength!=Q.byteLength||J.byteOffset!=Q.byteOffset)return!1;J=J.buffer,Q=Q.buffer;case kx:if(J.byteLength!=Q.byteLength||!q(new _x(J),new _x(Q)))return!1;return!0;case Bx:case Lx:case Mx:return wx(+J,+Q);case Ox:return J.name==Q.name&&J.message==Q.message;case jx:case Rx:return J==Q+"";case JF:var W=A50;case QF:var z=K&XF;if(W||(W=P50),J.size!=Q.size&&!z)return!1;var G=Y.get(J);if(G)return G==Q;K|=Vx,Y.set(J,Q);var $=Ix(W(J),W(Q),q,X,K,Y);return Y.delete(J),$;case W50:if(mD)return mD.call(J)==mD.call(Q)}return!1}function V80(J,Q,Z,q,X,K){var Y=X&XF,W=Ux(J),z=W.length,G=Ux(Q),$=G.length;if(z!=$&&!Y)return!1;var H=z;while(H--){var _=W[H];if(!(Y?_ in Q:DJ.call(Q,_)))return!1}var F=K.get(J);if(F&&K.get(Q))return F==Q;var U=!0;K.set(J,Q),K.set(Q,J);var V=Y;while(++H<z){_=W[H];var B=J[_],N=Q[_];if(q)var L=Y?q(N,B,_,Q,J,K):q(B,N,_,J,Q,K);if(!(L===void 0?B===N||Z(B,N,q,X,K):L)){U=!1;break}V||(V=_=="constructor")}if(U&&!V){var D=J.constructor,O=Q.constructor;if(D!=O&&(("constructor"in J)&&("constructor"in Q))&&!(typeof D=="function"&&D instanceof D&&typeof O=="function"&&O instanceof O))U=!1}return K.delete(J),K.delete(Q),U}function WF(J,Q){var Z=J.__data__;return B80(Q)?Z[typeof Q=="string"?"string":"hash"]:Z.map}function GK(J,Q){var Z=E50(J,Q);return $80(Z)?Z:void 0}var tQ=G80;if(dD&&tQ(new dD(new ArrayBuffer(1)))!=ZF||Zz&&tQ(new Zz)!=JF||iD&&tQ(iD.resolve())!=Kx||nD&&tQ(new nD)!=QF||sD&&tQ(new sD)!=lD)tQ=function(J){var Q=Xz.call(J),Z=Q==WK?J.constructor:void 0,q=Z?pq(Z):void 0;if(q)switch(q){case v50:return ZF;case S50:return JF;case f50:return Kx;case g50:return QF;case h50:return lD}return Q};function N80(J,Q){return Q=Q==null?Nx:Q,!!Q&&(typeof J=="number"||O50.test(J))&&(J>-1&&J%1==0&&J<Q)}function B80(J){var Q=typeof J;return Q=="string"||Q=="number"||Q=="symbol"||Q=="boolean"?J!=="__proto__":J===null}function L80(J){return!!Hx&&Hx in J}function O80(J){var Q=J&&J.constructor,Z=typeof Q=="function"&&Q.prototype||KF;return J===Z}function pq(J){if(J!=null){try{return Cx.call(J)}catch(Q){}try{return J+""}catch(Q){}}return""}function wx(J,Q){return J===Q||J!==J&&Q!==Q}function D80(J){return M80(J)&&DJ.call(J,"callee")&&(!T50.call(J,"callee")||Xz.call(J)==e_)}var rD=Array.isArray;function bx(J){return J!=null&&yx(J.length)&&!Tx(J)}function M80(J){return tD(J)&&bx(J)}function j80(J,Q,Z){Z=typeof Z=="function"?Z:void 0;var q=Z?Z(J,Q):void 0;return q===void 0?Px(J,Q,Z):!!q}function Tx(J){var Q=oD(J)?Xz.call(J):"";return Q==Dx||Q==Y50}function yx(J){return typeof J=="number"&&J>-1&&J%1==0&&J<=Nx}function oD(J){var Q=typeof J;return!!J&&(Q=="object"||Q=="function")}function tD(J){return!!J&&typeof J=="object"}var R80=Gx?k50(Gx):_80;function Ux(J){return bx(J)?z80(J):F80(J)}zK.exports=j80});var gx=oQ((uO0,fx)=>{var Sx="Expected a function",xx=NaN,k80="[object Symbol]",E80=/^\s+|\s+$/g,A80=/^[-+]0x[0-9a-f]+$/i,C80=/^0b[01]+$/i,P80=/^0o[0-7]+$/i,I80=parseInt,w80=typeof global=="object"&&global&&global.Object===Object&&global,b80=typeof self=="object"&&self&&self.Object===Object&&self,T80=w80||b80||Function("return this")(),y80=Object.prototype,x80=y80.toString,v80=Math.max,S80=Math.min,JM=function(){return T80.Date.now()};function f80(J,Q,Z){var q,X,K,Y,W,z,G=0,$=!1,H=!1,_=!0;if(typeof J!="function")throw TypeError(Sx);if(Q=vx(Q)||0,zF(Z))$=!!Z.leading,H="maxWait"in Z,K=H?v80(vx(Z.maxWait)||0,Q):K,_="trailing"in Z?!!Z.trailing:_;function F(k){var R=q,P=X;return q=X=void 0,G=k,Y=J.apply(P,R),Y}function U(k){return G=k,W=setTimeout(N,Q),$?F(k):Y}function V(k){var R=k-z,P=k-G,A=Q-R;return H?S80(A,K-P):A}function B(k){var R=k-z,P=k-G;return z===void 0||R>=Q||R<0||H&&P>=K}function N(){var k=JM();if(B(k))return L(k);W=setTimeout(N,V(k))}function L(k){if(W=void 0,_&&q)return F(k);return q=X=void 0,Y}function D(){if(W!==void 0)clearTimeout(W);G=0,q=z=X=W=void 0}function O(){return W===void 0?Y:L(JM())}function j(){var k=JM(),R=B(k);if(q=arguments,X=this,z=k,R){if(W===void 0)return U(z);if(H)return W=setTimeout(N,Q),F(z)}if(W===void 0)W=setTimeout(N,Q);return Y}return j.cancel=D,j.flush=O,j}function g80(J,Q,Z){var q=!0,X=!0;if(typeof J!="function")throw TypeError(Sx);if(zF(Z))q="leading"in Z?!!Z.leading:q,X="trailing"in Z?!!Z.trailing:X;return f80(J,Q,{leading:q,maxWait:Q,trailing:X})}function zF(J){var Q=typeof J;return!!J&&(Q=="object"||Q=="function")}function h80(J){return!!J&&typeof J=="object"}function u80(J){return typeof J=="symbol"||h80(J)&&x80.call(J)==k80}function vx(J){if(typeof J=="number")return J;if(u80(J))return xx;if(zF(J)){var Q=typeof J.valueOf=="function"?J.valueOf():J;J=zF(Q)?Q+"":Q}if(typeof J!="string")return J===0?J:+J;J=J.replace(E80,"");var Z=C80.test(J);return Z||P80.test(J)?I80(J.slice(2),Z?2:8):A80.test(J)?xx:+J}fx.exports=g80});var dx=oQ((mO0,px)=>{var m80=200,qM="__lodash_hash_undefined__",c80=1/0,l80="[object Function]",p80="[object GeneratorFunction]",d80=/[\\^$.*+?()[\]{}|]/g,i80=/^\[object .+?Constructor\]$/,n80=typeof global=="object"&&global&&global.Object===Object&&global,s80=typeof self=="object"&&self&&self.Object===Object&&self,XM=n80||s80||Function("return this")();function r80(J,Q){var Z=J?J.length:0;return!!Z&&t80(J,Q,0)>-1}function a80(J,Q,Z){var q=-1,X=J?J.length:0;while(++q<X)if(Z(Q,J[q]))return!0;return!1}function o80(J,Q,Z,q){var X=J.length,K=Z+(q?1:-1);while(q?K--:++K<X)if(Q(J[K],K,J))return K;return-1}function t80(J,Q,Z){if(Q!==Q)return o80(J,e80,Z);var q=Z-1,X=J.length;while(++q<X)if(J[q]===Q)return q;return-1}function e80(J){return J!==J}function J90(J,Q){return J.has(Q)}function Q90(J,Q){return J==null?void 0:J[Q]}function Z90(J){var Q=!1;if(J!=null&&typeof J.toString!="function")try{Q=!!(J+"")}catch(Z){}return Q}function ux(J){var Q=-1,Z=Array(J.size);return J.forEach(function(q){Z[++Q]=q}),Z}var q90=Array.prototype,X90=Function.prototype,mx=Object.prototype,QM=XM["__core-js_shared__"],hx=function(){var J=/[^.]+$/.exec(QM&&QM.keys&&QM.keys.IE_PROTO||"");return J?"Symbol(src)_1."+J:""}(),cx=X90.toString,KM=mx.hasOwnProperty,K90=mx.toString,Y90=RegExp("^"+cx.call(KM).replace(d80,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),W90=q90.splice,z90=YM(XM,"Map"),ZM=YM(XM,"Set"),Kz=YM(Object,"create");function dq(J){var Q=-1,Z=J?J.length:0;this.clear();while(++Q<Z){var q=J[Q];this.set(q[0],q[1])}}function G90(){this.__data__=Kz?Kz(null):{}}function H90(J){return this.has(J)&&delete this.__data__[J]}function $90(J){var Q=this.__data__;if(Kz){var Z=Q[J];return Z===qM?void 0:Z}return KM.call(Q,J)?Q[J]:void 0}function _90(J){var Q=this.__data__;return Kz?Q[J]!==void 0:KM.call(Q,J)}function F90(J,Q){var Z=this.__data__;return Z[J]=Kz&&Q===void 0?qM:Q,this}dq.prototype.clear=G90;dq.prototype.delete=H90;dq.prototype.get=$90;dq.prototype.has=_90;dq.prototype.set=F90;function HK(J){var Q=-1,Z=J?J.length:0;this.clear();while(++Q<Z){var q=J[Q];this.set(q[0],q[1])}}function U90(){this.__data__=[]}function V90(J){var Q=this.__data__,Z=HF(Q,J);if(Z<0)return!1;var q=Q.length-1;if(Z==q)Q.pop();else W90.call(Q,Z,1);return!0}function N90(J){var Q=this.__data__,Z=HF(Q,J);return Z<0?void 0:Q[Z][1]}function B90(J){return HF(this.__data__,J)>-1}function L90(J,Q){var Z=this.__data__,q=HF(Z,J);if(q<0)Z.push([J,Q]);else Z[q][1]=Q;return this}HK.prototype.clear=U90;HK.prototype.delete=V90;HK.prototype.get=N90;HK.prototype.has=B90;HK.prototype.set=L90;function $K(J){var Q=-1,Z=J?J.length:0;this.clear();while(++Q<Z){var q=J[Q];this.set(q[0],q[1])}}function O90(){this.__data__={hash:new dq,map:new(z90||HK),string:new dq}}function D90(J){return $F(this,J).delete(J)}function M90(J){return $F(this,J).get(J)}function j90(J){return $F(this,J).has(J)}function R90(J,Q){return $F(this,J).set(J,Q),this}$K.prototype.clear=O90;$K.prototype.delete=D90;$K.prototype.get=M90;$K.prototype.has=j90;$K.prototype.set=R90;function GF(J){var Q=-1,Z=J?J.length:0;this.__data__=new $K;while(++Q<Z)this.add(J[Q])}function k90(J){return this.__data__.set(J,qM),this}function E90(J){return this.__data__.has(J)}GF.prototype.add=GF.prototype.push=k90;GF.prototype.has=E90;function HF(J,Q){var Z=J.length;while(Z--)if(y90(J[Z][0],Q))return Z;return-1}function A90(J){if(!lx(J)||w90(J))return!1;var Q=x90(J)||Z90(J)?Y90:i80;return Q.test(b90(J))}function C90(J,Q,Z){var q=-1,X=r80,K=J.length,Y=!0,W=[],z=W;if(Z)Y=!1,X=a80;else if(K>=m80){var G=Q?null:P90(J);if(G)return ux(G);Y=!1,X=J90,z=new GF}else z=Q?[]:W;J:while(++q<K){var $=J[q],H=Q?Q($):$;if($=Z||$!==0?$:0,Y&&H===H){var _=z.length;while(_--)if(z[_]===H)continue J;if(Q)z.push(H);W.push($)}else if(!X(z,H,Z)){if(z!==W)z.push(H);W.push($)}}return W}var P90=!(ZM&&1/ux(new ZM([,-0]))[1]==c80)?v90:function(J){return new ZM(J)};function $F(J,Q){var Z=J.__data__;return I90(Q)?Z[typeof Q=="string"?"string":"hash"]:Z.map}function YM(J,Q){var Z=Q90(J,Q);return A90(Z)?Z:void 0}function I90(J){var Q=typeof J;return Q=="string"||Q=="number"||Q=="symbol"||Q=="boolean"?J!=="__proto__":J===null}function w90(J){return!!hx&&hx in J}function b90(J){if(J!=null){try{return cx.call(J)}catch(Q){}try{return J+""}catch(Q){}}return""}function T90(J){return J&&J.length?C90(J):[]}function y90(J,Q){return J===Q||J!==J&&Q!==Q}function x90(J){var Q=lx(J)?K90.call(J):"";return Q==l80||Q==p80}function lx(J){var Q=typeof J;return!!J&&(Q=="object"||Q=="function")}function v90(){}px.exports=T90});var c1=oQ((Jb0,mF)=>{/*!
1
+ import"/chunk-pcnahct1.js";import{Ac as L40,Cc as r10,Dc as k40,Kb as U40,La as G40,Q as nQ,Sb as V40,U as W40,Wb as N40,Xa as H40,Yb as B40,_a as $40,b as c,c as rJ0,da as z40,dc as Dy,hc as J40,ib as _40,m as SJ,uc as s10,vc as My,yb as F40}from"/chunk-n33w9y38.js";import{Sc as m,Wc as E40}from"/chunk-yvzhwtfa.js";import{$c as wd,Yc as E,Zc as oQ,_c as f7}from"/chunk-gps4qc38.js";var Xx=oQ((u_,KK)=>{var I40=200,hD="__lodash_hash_undefined__",s_=1,vy=2,Sy=9007199254740991,m_="[object Arguments]",TD="[object Array]",w40="[object AsyncFunction]",fy="[object Boolean]",gy="[object Date]",hy="[object Error]",uy="[object Function]",b40="[object GeneratorFunction]",c_="[object Map]",my="[object Number]",T40="[object Null]",XK="[object Object]",ky="[object Promise]",y40="[object Proxy]",cy="[object RegExp]",l_="[object Set]",ly="[object String]",x40="[object Symbol]",v40="[object Undefined]",yD="[object WeakMap]",py="[object ArrayBuffer]",p_="[object DataView]",S40="[object Float32Array]",f40="[object Float64Array]",g40="[object Int8Array]",h40="[object Int16Array]",u40="[object Int32Array]",m40="[object Uint8Array]",c40="[object Uint8ClampedArray]",l40="[object Uint16Array]",p40="[object Uint32Array]",d40=/[\\^$.*+?()[\]{}|]/g,i40=/^\[object .+?Constructor\]$/,n40=/^(?:0|[1-9]\d*)$/,m4={};m4[S40]=m4[f40]=m4[g40]=m4[h40]=m4[u40]=m4[m40]=m4[c40]=m4[l40]=m4[p40]=!0;m4[m_]=m4[TD]=m4[py]=m4[fy]=m4[p_]=m4[gy]=m4[hy]=m4[uy]=m4[c_]=m4[my]=m4[XK]=m4[cy]=m4[l_]=m4[ly]=m4[yD]=!1;var dy=typeof global=="object"&&global&&global.Object===Object&&global,s40=typeof self=="object"&&self&&self.Object===Object&&self,LJ=dy||s40||Function("return this")(),iy=typeof u_=="object"&&u_&&!u_.nodeType&&u_,Ey=iy&&typeof KK=="object"&&KK&&!KK.nodeType&&KK,ny=Ey&&Ey.exports===iy,ID=ny&&dy.process,Ay=function(){try{return ID&&ID.binding&&ID.binding("util")}catch(J){}}(),Cy=Ay&&Ay.isTypedArray;function r40(J,Q){var Z=-1,q=J==null?0:J.length,X=0,K=[];while(++Z<q){var Y=J[Z];if(Q(Y,Z,J))K[X++]=Y}return K}function a40(J,Q){var Z=-1,q=Q.length,X=J.length;while(++Z<q)J[X+Z]=Q[Z];return J}function o40(J,Q){var Z=-1,q=J==null?0:J.length;while(++Z<q)if(Q(J[Z],Z,J))return!0;return!1}function t40(J,Q){var Z=-1,q=Array(J);while(++Z<J)q[Z]=Q(Z);return q}function e40(J){return function(Q){return J(Q)}}function J60(J,Q){return J.has(Q)}function Q60(J,Q){return J==null?void 0:J[Q]}function Z60(J){var Q=-1,Z=Array(J.size);return J.forEach(function(q,X){Z[++Q]=[X,q]}),Z}function q60(J,Q){return function(Z){return J(Q(Z))}}function X60(J){var Q=-1,Z=Array(J.size);return J.forEach(function(q){Z[++Q]=q}),Z}var K60=Array.prototype,Y60=Function.prototype,r_=Object.prototype,wD=LJ["__core-js_shared__"],sy=Y60.toString,D2=r_.hasOwnProperty,Py=function(){var J=/[^.]+$/.exec(wD&&wD.keys&&wD.keys.IE_PROTO||"");return J?"Symbol(src)_1."+J:""}(),ry=r_.toString,W60=RegExp("^"+sy.call(D2).replace(d40,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Iy=ny?LJ.Buffer:void 0,d_=LJ.Symbol,wy=LJ.Uint8Array,ay=r_.propertyIsEnumerable,z60=K60.splice,gq=d_?d_.toStringTag:void 0,by=Object.getOwnPropertySymbols,G60=Iy?Iy.isBuffer:void 0,H60=q60(Object.keys,Object),xD=YK(LJ,"DataView"),tW=YK(LJ,"Map"),vD=YK(LJ,"Promise"),SD=YK(LJ,"Set"),fD=YK(LJ,"WeakMap"),eW=YK(Object,"create"),$60=mq(xD),_60=mq(tW),F60=mq(vD),U60=mq(SD),V60=mq(fD),Ty=d_?d_.prototype:void 0,bD=Ty?Ty.valueOf:void 0;function hq(J){var Q=-1,Z=J==null?0:J.length;this.clear();while(++Q<Z){var q=J[Q];this.set(q[0],q[1])}}function N60(){this.__data__=eW?eW(null):{},this.size=0}function B60(J){var Q=this.has(J)&&delete this.__data__[J];return this.size-=Q?1:0,Q}function L60(J){var Q=this.__data__;if(eW){var Z=Q[J];return Z===hD?void 0:Z}return D2.call(Q,J)?Q[J]:void 0}function O60(J){var Q=this.__data__;return eW?Q[J]!==void 0:D2.call(Q,J)}function D60(J,Q){var Z=this.__data__;return this.size+=this.has(J)?0:1,Z[J]=eW&&Q===void 0?hD:Q,this}hq.prototype.clear=N60;hq.prototype.delete=B60;hq.prototype.get=L60;hq.prototype.has=O60;hq.prototype.set=D60;function OJ(J){var Q=-1,Z=J==null?0:J.length;this.clear();while(++Q<Z){var q=J[Q];this.set(q[0],q[1])}}function M60(){this.__data__=[],this.size=0}function j60(J){var Q=this.__data__,Z=a_(Q,J);if(Z<0)return!1;var q=Q.length-1;if(Z==q)Q.pop();else z60.call(Q,Z,1);return--this.size,!0}function R60(J){var Q=this.__data__,Z=a_(Q,J);return Z<0?void 0:Q[Z][1]}function k60(J){return a_(this.__data__,J)>-1}function E60(J,Q){var Z=this.__data__,q=a_(Z,J);if(q<0)++this.size,Z.push([J,Q]);else Z[q][1]=Q;return this}OJ.prototype.clear=M60;OJ.prototype.delete=j60;OJ.prototype.get=R60;OJ.prototype.has=k60;OJ.prototype.set=E60;function uq(J){var Q=-1,Z=J==null?0:J.length;this.clear();while(++Q<Z){var q=J[Q];this.set(q[0],q[1])}}function A60(){this.size=0,this.__data__={hash:new hq,map:new(tW||OJ),string:new hq}}function C60(J){var Q=o_(this,J).delete(J);return this.size-=Q?1:0,Q}function P60(J){return o_(this,J).get(J)}function I60(J){return o_(this,J).has(J)}function w60(J,Q){var Z=o_(this,J),q=Z.size;return Z.set(J,Q),this.size+=Z.size==q?0:1,this}uq.prototype.clear=A60;uq.prototype.delete=C60;uq.prototype.get=P60;uq.prototype.has=I60;uq.prototype.set=w60;function i_(J){var Q=-1,Z=J==null?0:J.length;this.__data__=new uq;while(++Q<Z)this.add(J[Q])}function b60(J){return this.__data__.set(J,hD),this}function T60(J){return this.__data__.has(J)}i_.prototype.add=i_.prototype.push=b60;i_.prototype.has=T60;function aQ(J){var Q=this.__data__=new OJ(J);this.size=Q.size}function y60(){this.__data__=new OJ,this.size=0}function x60(J){var Q=this.__data__,Z=Q.delete(J);return this.size=Q.size,Z}function v60(J){return this.__data__.get(J)}function S60(J){return this.__data__.has(J)}function f60(J,Q){var Z=this.__data__;if(Z instanceof OJ){var q=Z.__data__;if(!tW||q.length<I40-1)return q.push([J,Q]),this.size=++Z.size,this;Z=this.__data__=new uq(q)}return Z.set(J,Q),this.size=Z.size,this}aQ.prototype.clear=y60;aQ.prototype.delete=x60;aQ.prototype.get=v60;aQ.prototype.has=S60;aQ.prototype.set=f60;function g60(J,Q){var Z=n_(J),q=!Z&&e60(J),X=!Z&&!q&&gD(J),K=!Z&&!q&&!X&&qx(J),Y=Z||q||X||K,W=Y?t40(J.length,String):[],z=W.length;for(var G in J)if((Q||D2.call(J,G))&&!(Y&&(G=="length"||X&&(G=="offset"||G=="parent")||K&&(G=="buffer"||G=="byteLength"||G=="byteOffset")||s60(G,z))))W.push(G);return W}function a_(J,Q){var Z=J.length;while(Z--)if(ey(J[Z][0],Q))return Z;return-1}function h60(J,Q,Z){var q=Q(J);return n_(J)?q:a40(q,Z(J))}function Qz(J){if(J==null)return J===void 0?v40:T40;return gq&&gq in Object(J)?i60(J):t60(J)}function yy(J){return Jz(J)&&Qz(J)==m_}function oy(J,Q,Z,q,X){if(J===Q)return!0;if(J==null||Q==null||!Jz(J)&&!Jz(Q))return J!==J&&Q!==Q;return u60(J,Q,Z,q,oy,X)}function u60(J,Q,Z,q,X,K){var Y=n_(J),W=n_(Q),z=Y?TD:rQ(J),G=W?TD:rQ(Q);z=z==m_?XK:z,G=G==m_?XK:G;var $=z==XK,H=G==XK,_=z==G;if(_&&gD(J)){if(!gD(Q))return!1;Y=!0,$=!1}if(_&&!$)return K||(K=new aQ),Y||qx(J)?ty(J,Q,Z,q,X,K):p60(J,Q,z,Z,q,X,K);if(!(Z&s_)){var F=$&&D2.call(J,"__wrapped__"),U=H&&D2.call(Q,"__wrapped__");if(F||U){var V=F?J.value():J,B=U?Q.value():Q;return K||(K=new aQ),X(V,B,Z,q,K)}}if(!_)return!1;return K||(K=new aQ),d60(J,Q,Z,q,X,K)}function m60(J){if(!Zx(J)||a60(J))return!1;var Q=Jx(J)?W60:i40;return Q.test(mq(J))}function c60(J){return Jz(J)&&Qx(J.length)&&!!m4[Qz(J)]}function l60(J){if(!o60(J))return H60(J);var Q=[];for(var Z in Object(J))if(D2.call(J,Z)&&Z!="constructor")Q.push(Z);return Q}function ty(J,Q,Z,q,X,K){var Y=Z&s_,W=J.length,z=Q.length;if(W!=z&&!(Y&&z>W))return!1;var G=K.get(J);if(G&&K.get(Q))return G==Q;var $=-1,H=!0,_=Z&vy?new i_:void 0;K.set(J,Q),K.set(Q,J);while(++$<W){var F=J[$],U=Q[$];if(q)var V=Y?q(U,F,$,Q,J,K):q(F,U,$,J,Q,K);if(V!==void 0){if(V)continue;H=!1;break}if(_){if(!o40(Q,function(B,N){if(!J60(_,N)&&(F===B||X(F,B,Z,q,K)))return _.push(N)})){H=!1;break}}else if(!(F===U||X(F,U,Z,q,K))){H=!1;break}}return K.delete(J),K.delete(Q),H}function p60(J,Q,Z,q,X,K,Y){switch(Z){case p_:if(J.byteLength!=Q.byteLength||J.byteOffset!=Q.byteOffset)return!1;J=J.buffer,Q=Q.buffer;case py:if(J.byteLength!=Q.byteLength||!K(new wy(J),new wy(Q)))return!1;return!0;case fy:case gy:case my:return ey(+J,+Q);case hy:return J.name==Q.name&&J.message==Q.message;case cy:case ly:return J==Q+"";case c_:var W=Z60;case l_:var z=q&s_;if(W||(W=X60),J.size!=Q.size&&!z)return!1;var G=Y.get(J);if(G)return G==Q;q|=vy,Y.set(J,Q);var $=ty(W(J),W(Q),q,X,K,Y);return Y.delete(J),$;case x40:if(bD)return bD.call(J)==bD.call(Q)}return!1}function d60(J,Q,Z,q,X,K){var Y=Z&s_,W=xy(J),z=W.length,G=xy(Q),$=G.length;if(z!=$&&!Y)return!1;var H=z;while(H--){var _=W[H];if(!(Y?_ in Q:D2.call(Q,_)))return!1}var F=K.get(J);if(F&&K.get(Q))return F==Q;var U=!0;K.set(J,Q),K.set(Q,J);var V=Y;while(++H<z){_=W[H];var B=J[_],N=Q[_];if(q)var L=Y?q(N,B,_,Q,J,K):q(B,N,_,J,Q,K);if(!(L===void 0?B===N||X(B,N,Z,q,K):L)){U=!1;break}V||(V=_=="constructor")}if(U&&!V){var D=J.constructor,O=Q.constructor;if(D!=O&&(("constructor"in J)&&("constructor"in Q))&&!(typeof D=="function"&&D instanceof D&&typeof O=="function"&&O instanceof O))U=!1}return K.delete(J),K.delete(Q),U}function xy(J){return h60(J,Z50,n60)}function o_(J,Q){var Z=J.__data__;return r60(Q)?Z[typeof Q=="string"?"string":"hash"]:Z.map}function YK(J,Q){var Z=Q60(J,Q);return m60(Z)?Z:void 0}function i60(J){var Q=D2.call(J,gq),Z=J[gq];try{J[gq]=void 0;var q=!0}catch(K){}var X=ry.call(J);if(q)if(Q)J[gq]=Z;else delete J[gq];return X}var n60=!by?q50:function(J){if(J==null)return[];return J=Object(J),r40(by(J),function(Q){return ay.call(J,Q)})},rQ=Qz;if(xD&&rQ(new xD(new ArrayBuffer(1)))!=p_||tW&&rQ(new tW)!=c_||vD&&rQ(vD.resolve())!=ky||SD&&rQ(new SD)!=l_||fD&&rQ(new fD)!=yD)rQ=function(J){var Q=Qz(J),Z=Q==XK?J.constructor:void 0,q=Z?mq(Z):"";if(q)switch(q){case $60:return p_;case _60:return c_;case F60:return ky;case U60:return l_;case V60:return yD}return Q};function s60(J,Q){return Q=Q==null?Sy:Q,!!Q&&(typeof J=="number"||n40.test(J))&&(J>-1&&J%1==0&&J<Q)}function r60(J){var Q=typeof J;return Q=="string"||Q=="number"||Q=="symbol"||Q=="boolean"?J!=="__proto__":J===null}function a60(J){return!!Py&&Py in J}function o60(J){var Q=J&&J.constructor,Z=typeof Q=="function"&&Q.prototype||r_;return J===Z}function t60(J){return ry.call(J)}function mq(J){if(J!=null){try{return sy.call(J)}catch(Q){}try{return J+""}catch(Q){}}return""}function ey(J,Q){return J===Q||J!==J&&Q!==Q}var e60=yy(function(){return arguments}())?yy:function(J){return Jz(J)&&D2.call(J,"callee")&&!ay.call(J,"callee")},n_=Array.isArray;function J50(J){return J!=null&&Qx(J.length)&&!Jx(J)}var gD=G60||X50;function Q50(J,Q){return oy(J,Q)}function Jx(J){if(!Zx(J))return!1;var Q=Qz(J);return Q==uy||Q==b40||Q==w40||Q==y40}function Qx(J){return typeof J=="number"&&J>-1&&J%1==0&&J<=Sy}function Zx(J){var Q=typeof J;return J!=null&&(Q=="object"||Q=="function")}function Jz(J){return J!=null&&typeof J=="object"}var qx=Cy?e40(Cy):c60;function Z50(J){return J50(J)?g60(J):l60(J)}function q50(){return[]}function X50(){return!1}KK.exports=Q50});var eD=oQ((t_,zK)=>{var K50=200,aD="__lodash_hash_undefined__",Vx=1,XF=2,Nx=9007199254740991,e_="[object Arguments]",cD="[object Array]",Bx="[object Boolean]",Lx="[object Date]",Ox="[object Error]",Dx="[object Function]",Y50="[object GeneratorFunction]",JF="[object Map]",Mx="[object Number]",WK="[object Object]",Kx="[object Promise]",jx="[object RegExp]",QF="[object Set]",Rx="[object String]",W50="[object Symbol]",lD="[object WeakMap]",kx="[object ArrayBuffer]",ZF="[object DataView]",z50="[object Float32Array]",G50="[object Float64Array]",H50="[object Int8Array]",$50="[object Int16Array]",_50="[object Int32Array]",F50="[object Uint8Array]",U50="[object Uint8ClampedArray]",V50="[object Uint16Array]",N50="[object Uint32Array]",B50=/[\\^$.*+?()[\]{}|]/g,L50=/^\[object .+?Constructor\]$/,O50=/^(?:0|[1-9]\d*)$/,c4={};c4[z50]=c4[G50]=c4[H50]=c4[$50]=c4[_50]=c4[F50]=c4[U50]=c4[V50]=c4[N50]=!0;c4[e_]=c4[cD]=c4[kx]=c4[Bx]=c4[ZF]=c4[Lx]=c4[Ox]=c4[Dx]=c4[JF]=c4[Mx]=c4[WK]=c4[jx]=c4[QF]=c4[Rx]=c4[lD]=!1;var Ex=typeof global=="object"&&global&&global.Object===Object&&global,D50=typeof self=="object"&&self&&self.Object===Object&&self,JZ=Ex||D50||Function("return this")(),Ax=typeof t_=="object"&&t_&&!t_.nodeType&&t_,Yx=Ax&&typeof zK=="object"&&zK&&!zK.nodeType&&zK,M50=Yx&&Yx.exports===Ax,Wx=M50&&Ex.process,zx=function(){try{return Wx&&Wx.binding("util")}catch(J){}}(),Gx=zx&&zx.isTypedArray;function j50(J,Q){var Z=-1,q=J?J.length:0;while(++Z<q)if(Q(J[Z],Z,J))return!0;return!1}function R50(J,Q){var Z=-1,q=Array(J);while(++Z<J)q[Z]=Q(Z);return q}function k50(J){return function(Q){return J(Q)}}function E50(J,Q){return J==null?void 0:J[Q]}function pD(J){var Q=!1;if(J!=null&&typeof J.toString!="function")try{Q=!!(J+"")}catch(Z){}return Q}function A50(J){var Q=-1,Z=Array(J.size);return J.forEach(function(q,X){Z[++Q]=[X,q]}),Z}function C50(J,Q){return function(Z){return J(Q(Z))}}function P50(J){var Q=-1,Z=Array(J.size);return J.forEach(function(q){Z[++Q]=q}),Z}var I50=Array.prototype,w50=Function.prototype,KF=Object.prototype,uD=JZ["__core-js_shared__"],Hx=function(){var J=/[^.]+$/.exec(uD&&uD.keys&&uD.keys.IE_PROTO||"");return J?"Symbol(src)_1."+J:""}(),Cx=w50.toString,DJ=KF.hasOwnProperty,Xz=KF.toString,b50=RegExp("^"+Cx.call(DJ).replace(B50,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),$x=JZ.Symbol,_x=JZ.Uint8Array,T50=KF.propertyIsEnumerable,y50=I50.splice,x50=C50(Object.keys,Object),dD=GK(JZ,"DataView"),Zz=GK(JZ,"Map"),iD=GK(JZ,"Promise"),nD=GK(JZ,"Set"),sD=GK(JZ,"WeakMap"),qz=GK(Object,"create"),v50=pq(dD),S50=pq(Zz),f50=pq(iD),g50=pq(nD),h50=pq(sD),Fx=$x?$x.prototype:void 0,mD=Fx?Fx.valueOf:void 0;function cq(J){var Q=-1,Z=J?J.length:0;this.clear();while(++Q<Z){var q=J[Q];this.set(q[0],q[1])}}function u50(){this.__data__=qz?qz(null):{}}function m50(J){return this.has(J)&&delete this.__data__[J]}function c50(J){var Q=this.__data__;if(qz){var Z=Q[J];return Z===aD?void 0:Z}return DJ.call(Q,J)?Q[J]:void 0}function l50(J){var Q=this.__data__;return qz?Q[J]!==void 0:DJ.call(Q,J)}function p50(J,Q){var Z=this.__data__;return Z[J]=qz&&Q===void 0?aD:Q,this}cq.prototype.clear=u50;cq.prototype.delete=m50;cq.prototype.get=c50;cq.prototype.has=l50;cq.prototype.set=p50;function MJ(J){var Q=-1,Z=J?J.length:0;this.clear();while(++Q<Z){var q=J[Q];this.set(q[0],q[1])}}function d50(){this.__data__=[]}function i50(J){var Q=this.__data__,Z=YF(Q,J);if(Z<0)return!1;var q=Q.length-1;if(Z==q)Q.pop();else y50.call(Q,Z,1);return!0}function n50(J){var Q=this.__data__,Z=YF(Q,J);return Z<0?void 0:Q[Z][1]}function s50(J){return YF(this.__data__,J)>-1}function r50(J,Q){var Z=this.__data__,q=YF(Z,J);if(q<0)Z.push([J,Q]);else Z[q][1]=Q;return this}MJ.prototype.clear=d50;MJ.prototype.delete=i50;MJ.prototype.get=n50;MJ.prototype.has=s50;MJ.prototype.set=r50;function lq(J){var Q=-1,Z=J?J.length:0;this.clear();while(++Q<Z){var q=J[Q];this.set(q[0],q[1])}}function a50(){this.__data__={hash:new cq,map:new(Zz||MJ),string:new cq}}function o50(J){return WF(this,J).delete(J)}function t50(J){return WF(this,J).get(J)}function e50(J){return WF(this,J).has(J)}function J80(J,Q){return WF(this,J).set(J,Q),this}lq.prototype.clear=a50;lq.prototype.delete=o50;lq.prototype.get=t50;lq.prototype.has=e50;lq.prototype.set=J80;function qF(J){var Q=-1,Z=J?J.length:0;this.__data__=new lq;while(++Q<Z)this.add(J[Q])}function Q80(J){return this.__data__.set(J,aD),this}function Z80(J){return this.__data__.has(J)}qF.prototype.add=qF.prototype.push=Q80;qF.prototype.has=Z80;function eQ(J){this.__data__=new MJ(J)}function q80(){this.__data__=new MJ}function X80(J){return this.__data__.delete(J)}function K80(J){return this.__data__.get(J)}function Y80(J){return this.__data__.has(J)}function W80(J,Q){var Z=this.__data__;if(Z instanceof MJ){var q=Z.__data__;if(!Zz||q.length<K50-1)return q.push([J,Q]),this;Z=this.__data__=new lq(q)}return Z.set(J,Q),this}eQ.prototype.clear=q80;eQ.prototype.delete=X80;eQ.prototype.get=K80;eQ.prototype.has=Y80;eQ.prototype.set=W80;function z80(J,Q){var Z=rD(J)||D80(J)?R50(J.length,String):[],q=Z.length,X=!!q;for(var K in J)if((Q||DJ.call(J,K))&&!(X&&(K=="length"||N80(K,q))))Z.push(K);return Z}function YF(J,Q){var Z=J.length;while(Z--)if(wx(J[Z][0],Q))return Z;return-1}function G80(J){return Xz.call(J)}function Px(J,Q,Z,q,X){if(J===Q)return!0;if(J==null||Q==null||!oD(J)&&!tD(Q))return J!==J&&Q!==Q;return H80(J,Q,Px,Z,q,X)}function H80(J,Q,Z,q,X,K){var Y=rD(J),W=rD(Q),z=cD,G=cD;if(!Y)z=tQ(J),z=z==e_?WK:z;if(!W)G=tQ(Q),G=G==e_?WK:G;var $=z==WK&&!pD(J),H=G==WK&&!pD(Q),_=z==G;if(_&&!$)return K||(K=new eQ),Y||R80(J)?Ix(J,Q,Z,q,X,K):U80(J,Q,z,Z,q,X,K);if(!(X&XF)){var F=$&&DJ.call(J,"__wrapped__"),U=H&&DJ.call(Q,"__wrapped__");if(F||U){var V=F?J.value():J,B=U?Q.value():Q;return K||(K=new eQ),Z(V,B,q,X,K)}}if(!_)return!1;return K||(K=new eQ),V80(J,Q,Z,q,X,K)}function $80(J){if(!oD(J)||L80(J))return!1;var Q=Tx(J)||pD(J)?b50:L50;return Q.test(pq(J))}function _80(J){return tD(J)&&yx(J.length)&&!!c4[Xz.call(J)]}function F80(J){if(!O80(J))return x50(J);var Q=[];for(var Z in Object(J))if(DJ.call(J,Z)&&Z!="constructor")Q.push(Z);return Q}function Ix(J,Q,Z,q,X,K){var Y=X&XF,W=J.length,z=Q.length;if(W!=z&&!(Y&&z>W))return!1;var G=K.get(J);if(G&&K.get(Q))return G==Q;var $=-1,H=!0,_=X&Vx?new qF:void 0;K.set(J,Q),K.set(Q,J);while(++$<W){var F=J[$],U=Q[$];if(q)var V=Y?q(U,F,$,Q,J,K):q(F,U,$,J,Q,K);if(V!==void 0){if(V)continue;H=!1;break}if(_){if(!j50(Q,function(B,N){if(!_.has(N)&&(F===B||Z(F,B,q,X,K)))return _.add(N)})){H=!1;break}}else if(!(F===U||Z(F,U,q,X,K))){H=!1;break}}return K.delete(J),K.delete(Q),H}function U80(J,Q,Z,q,X,K,Y){switch(Z){case ZF:if(J.byteLength!=Q.byteLength||J.byteOffset!=Q.byteOffset)return!1;J=J.buffer,Q=Q.buffer;case kx:if(J.byteLength!=Q.byteLength||!q(new _x(J),new _x(Q)))return!1;return!0;case Bx:case Lx:case Mx:return wx(+J,+Q);case Ox:return J.name==Q.name&&J.message==Q.message;case jx:case Rx:return J==Q+"";case JF:var W=A50;case QF:var z=K&XF;if(W||(W=P50),J.size!=Q.size&&!z)return!1;var G=Y.get(J);if(G)return G==Q;K|=Vx,Y.set(J,Q);var $=Ix(W(J),W(Q),q,X,K,Y);return Y.delete(J),$;case W50:if(mD)return mD.call(J)==mD.call(Q)}return!1}function V80(J,Q,Z,q,X,K){var Y=X&XF,W=Ux(J),z=W.length,G=Ux(Q),$=G.length;if(z!=$&&!Y)return!1;var H=z;while(H--){var _=W[H];if(!(Y?_ in Q:DJ.call(Q,_)))return!1}var F=K.get(J);if(F&&K.get(Q))return F==Q;var U=!0;K.set(J,Q),K.set(Q,J);var V=Y;while(++H<z){_=W[H];var B=J[_],N=Q[_];if(q)var L=Y?q(N,B,_,Q,J,K):q(B,N,_,J,Q,K);if(!(L===void 0?B===N||Z(B,N,q,X,K):L)){U=!1;break}V||(V=_=="constructor")}if(U&&!V){var D=J.constructor,O=Q.constructor;if(D!=O&&(("constructor"in J)&&("constructor"in Q))&&!(typeof D=="function"&&D instanceof D&&typeof O=="function"&&O instanceof O))U=!1}return K.delete(J),K.delete(Q),U}function WF(J,Q){var Z=J.__data__;return B80(Q)?Z[typeof Q=="string"?"string":"hash"]:Z.map}function GK(J,Q){var Z=E50(J,Q);return $80(Z)?Z:void 0}var tQ=G80;if(dD&&tQ(new dD(new ArrayBuffer(1)))!=ZF||Zz&&tQ(new Zz)!=JF||iD&&tQ(iD.resolve())!=Kx||nD&&tQ(new nD)!=QF||sD&&tQ(new sD)!=lD)tQ=function(J){var Q=Xz.call(J),Z=Q==WK?J.constructor:void 0,q=Z?pq(Z):void 0;if(q)switch(q){case v50:return ZF;case S50:return JF;case f50:return Kx;case g50:return QF;case h50:return lD}return Q};function N80(J,Q){return Q=Q==null?Nx:Q,!!Q&&(typeof J=="number"||O50.test(J))&&(J>-1&&J%1==0&&J<Q)}function B80(J){var Q=typeof J;return Q=="string"||Q=="number"||Q=="symbol"||Q=="boolean"?J!=="__proto__":J===null}function L80(J){return!!Hx&&Hx in J}function O80(J){var Q=J&&J.constructor,Z=typeof Q=="function"&&Q.prototype||KF;return J===Z}function pq(J){if(J!=null){try{return Cx.call(J)}catch(Q){}try{return J+""}catch(Q){}}return""}function wx(J,Q){return J===Q||J!==J&&Q!==Q}function D80(J){return M80(J)&&DJ.call(J,"callee")&&(!T50.call(J,"callee")||Xz.call(J)==e_)}var rD=Array.isArray;function bx(J){return J!=null&&yx(J.length)&&!Tx(J)}function M80(J){return tD(J)&&bx(J)}function j80(J,Q,Z){Z=typeof Z=="function"?Z:void 0;var q=Z?Z(J,Q):void 0;return q===void 0?Px(J,Q,Z):!!q}function Tx(J){var Q=oD(J)?Xz.call(J):"";return Q==Dx||Q==Y50}function yx(J){return typeof J=="number"&&J>-1&&J%1==0&&J<=Nx}function oD(J){var Q=typeof J;return!!J&&(Q=="object"||Q=="function")}function tD(J){return!!J&&typeof J=="object"}var R80=Gx?k50(Gx):_80;function Ux(J){return bx(J)?z80(J):F80(J)}zK.exports=j80});var gx=oQ((uO0,fx)=>{var Sx="Expected a function",xx=NaN,k80="[object Symbol]",E80=/^\s+|\s+$/g,A80=/^[-+]0x[0-9a-f]+$/i,C80=/^0b[01]+$/i,P80=/^0o[0-7]+$/i,I80=parseInt,w80=typeof global=="object"&&global&&global.Object===Object&&global,b80=typeof self=="object"&&self&&self.Object===Object&&self,T80=w80||b80||Function("return this")(),y80=Object.prototype,x80=y80.toString,v80=Math.max,S80=Math.min,JM=function(){return T80.Date.now()};function f80(J,Q,Z){var q,X,K,Y,W,z,G=0,$=!1,H=!1,_=!0;if(typeof J!="function")throw TypeError(Sx);if(Q=vx(Q)||0,zF(Z))$=!!Z.leading,H="maxWait"in Z,K=H?v80(vx(Z.maxWait)||0,Q):K,_="trailing"in Z?!!Z.trailing:_;function F(k){var R=q,P=X;return q=X=void 0,G=k,Y=J.apply(P,R),Y}function U(k){return G=k,W=setTimeout(N,Q),$?F(k):Y}function V(k){var R=k-z,P=k-G,A=Q-R;return H?S80(A,K-P):A}function B(k){var R=k-z,P=k-G;return z===void 0||R>=Q||R<0||H&&P>=K}function N(){var k=JM();if(B(k))return L(k);W=setTimeout(N,V(k))}function L(k){if(W=void 0,_&&q)return F(k);return q=X=void 0,Y}function D(){if(W!==void 0)clearTimeout(W);G=0,q=z=X=W=void 0}function O(){return W===void 0?Y:L(JM())}function j(){var k=JM(),R=B(k);if(q=arguments,X=this,z=k,R){if(W===void 0)return U(z);if(H)return W=setTimeout(N,Q),F(z)}if(W===void 0)W=setTimeout(N,Q);return Y}return j.cancel=D,j.flush=O,j}function g80(J,Q,Z){var q=!0,X=!0;if(typeof J!="function")throw TypeError(Sx);if(zF(Z))q="leading"in Z?!!Z.leading:q,X="trailing"in Z?!!Z.trailing:X;return f80(J,Q,{leading:q,maxWait:Q,trailing:X})}function zF(J){var Q=typeof J;return!!J&&(Q=="object"||Q=="function")}function h80(J){return!!J&&typeof J=="object"}function u80(J){return typeof J=="symbol"||h80(J)&&x80.call(J)==k80}function vx(J){if(typeof J=="number")return J;if(u80(J))return xx;if(zF(J)){var Q=typeof J.valueOf=="function"?J.valueOf():J;J=zF(Q)?Q+"":Q}if(typeof J!="string")return J===0?J:+J;J=J.replace(E80,"");var Z=C80.test(J);return Z||P80.test(J)?I80(J.slice(2),Z?2:8):A80.test(J)?xx:+J}fx.exports=g80});var dx=oQ((mO0,px)=>{var m80=200,qM="__lodash_hash_undefined__",c80=1/0,l80="[object Function]",p80="[object GeneratorFunction]",d80=/[\\^$.*+?()[\]{}|]/g,i80=/^\[object .+?Constructor\]$/,n80=typeof global=="object"&&global&&global.Object===Object&&global,s80=typeof self=="object"&&self&&self.Object===Object&&self,XM=n80||s80||Function("return this")();function r80(J,Q){var Z=J?J.length:0;return!!Z&&t80(J,Q,0)>-1}function a80(J,Q,Z){var q=-1,X=J?J.length:0;while(++q<X)if(Z(Q,J[q]))return!0;return!1}function o80(J,Q,Z,q){var X=J.length,K=Z+(q?1:-1);while(q?K--:++K<X)if(Q(J[K],K,J))return K;return-1}function t80(J,Q,Z){if(Q!==Q)return o80(J,e80,Z);var q=Z-1,X=J.length;while(++q<X)if(J[q]===Q)return q;return-1}function e80(J){return J!==J}function J90(J,Q){return J.has(Q)}function Q90(J,Q){return J==null?void 0:J[Q]}function Z90(J){var Q=!1;if(J!=null&&typeof J.toString!="function")try{Q=!!(J+"")}catch(Z){}return Q}function ux(J){var Q=-1,Z=Array(J.size);return J.forEach(function(q){Z[++Q]=q}),Z}var q90=Array.prototype,X90=Function.prototype,mx=Object.prototype,QM=XM["__core-js_shared__"],hx=function(){var J=/[^.]+$/.exec(QM&&QM.keys&&QM.keys.IE_PROTO||"");return J?"Symbol(src)_1."+J:""}(),cx=X90.toString,KM=mx.hasOwnProperty,K90=mx.toString,Y90=RegExp("^"+cx.call(KM).replace(d80,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),W90=q90.splice,z90=YM(XM,"Map"),ZM=YM(XM,"Set"),Kz=YM(Object,"create");function dq(J){var Q=-1,Z=J?J.length:0;this.clear();while(++Q<Z){var q=J[Q];this.set(q[0],q[1])}}function G90(){this.__data__=Kz?Kz(null):{}}function H90(J){return this.has(J)&&delete this.__data__[J]}function $90(J){var Q=this.__data__;if(Kz){var Z=Q[J];return Z===qM?void 0:Z}return KM.call(Q,J)?Q[J]:void 0}function _90(J){var Q=this.__data__;return Kz?Q[J]!==void 0:KM.call(Q,J)}function F90(J,Q){var Z=this.__data__;return Z[J]=Kz&&Q===void 0?qM:Q,this}dq.prototype.clear=G90;dq.prototype.delete=H90;dq.prototype.get=$90;dq.prototype.has=_90;dq.prototype.set=F90;function HK(J){var Q=-1,Z=J?J.length:0;this.clear();while(++Q<Z){var q=J[Q];this.set(q[0],q[1])}}function U90(){this.__data__=[]}function V90(J){var Q=this.__data__,Z=HF(Q,J);if(Z<0)return!1;var q=Q.length-1;if(Z==q)Q.pop();else W90.call(Q,Z,1);return!0}function N90(J){var Q=this.__data__,Z=HF(Q,J);return Z<0?void 0:Q[Z][1]}function B90(J){return HF(this.__data__,J)>-1}function L90(J,Q){var Z=this.__data__,q=HF(Z,J);if(q<0)Z.push([J,Q]);else Z[q][1]=Q;return this}HK.prototype.clear=U90;HK.prototype.delete=V90;HK.prototype.get=N90;HK.prototype.has=B90;HK.prototype.set=L90;function $K(J){var Q=-1,Z=J?J.length:0;this.clear();while(++Q<Z){var q=J[Q];this.set(q[0],q[1])}}function O90(){this.__data__={hash:new dq,map:new(z90||HK),string:new dq}}function D90(J){return $F(this,J).delete(J)}function M90(J){return $F(this,J).get(J)}function j90(J){return $F(this,J).has(J)}function R90(J,Q){return $F(this,J).set(J,Q),this}$K.prototype.clear=O90;$K.prototype.delete=D90;$K.prototype.get=M90;$K.prototype.has=j90;$K.prototype.set=R90;function GF(J){var Q=-1,Z=J?J.length:0;this.__data__=new $K;while(++Q<Z)this.add(J[Q])}function k90(J){return this.__data__.set(J,qM),this}function E90(J){return this.__data__.has(J)}GF.prototype.add=GF.prototype.push=k90;GF.prototype.has=E90;function HF(J,Q){var Z=J.length;while(Z--)if(y90(J[Z][0],Q))return Z;return-1}function A90(J){if(!lx(J)||w90(J))return!1;var Q=x90(J)||Z90(J)?Y90:i80;return Q.test(b90(J))}function C90(J,Q,Z){var q=-1,X=r80,K=J.length,Y=!0,W=[],z=W;if(Z)Y=!1,X=a80;else if(K>=m80){var G=Q?null:P90(J);if(G)return ux(G);Y=!1,X=J90,z=new GF}else z=Q?[]:W;J:while(++q<K){var $=J[q],H=Q?Q($):$;if($=Z||$!==0?$:0,Y&&H===H){var _=z.length;while(_--)if(z[_]===H)continue J;if(Q)z.push(H);W.push($)}else if(!X(z,H,Z)){if(z!==W)z.push(H);W.push($)}}return W}var P90=!(ZM&&1/ux(new ZM([,-0]))[1]==c80)?v90:function(J){return new ZM(J)};function $F(J,Q){var Z=J.__data__;return I90(Q)?Z[typeof Q=="string"?"string":"hash"]:Z.map}function YM(J,Q){var Z=Q90(J,Q);return A90(Z)?Z:void 0}function I90(J){var Q=typeof J;return Q=="string"||Q=="number"||Q=="symbol"||Q=="boolean"?J!=="__proto__":J===null}function w90(J){return!!hx&&hx in J}function b90(J){if(J!=null){try{return cx.call(J)}catch(Q){}try{return J+""}catch(Q){}}return""}function T90(J){return J&&J.length?C90(J):[]}function y90(J,Q){return J===Q||J!==J&&Q!==Q}function x90(J){var Q=lx(J)?K90.call(J):"";return Q==l80||Q==p80}function lx(J){var Q=typeof J;return!!J&&(Q=="object"||Q=="function")}function v90(){}px.exports=T90});var c1=oQ((Jb0,mF)=>{/*!
2
2
  Copyright (c) 2018 Jed Watson.
3
3
  Licensed under the MIT License (MIT), see
4
4
  http://jedwatson.github.io/classnames
@@ -92,7 +92,7 @@ Keep seeing this message?
92
92
  *
93
93
  * N.B. On iOS, you have to take into account the offsetTop as well so that you get an accurate position
94
94
  * while using the virtual keyboard.
95
- */function gU(J){let Q=new ArrayBuffer(J.length),Z=new Uint8Array(Q);for(let q=0,X=J.length;q<X;q++)Z[q]=J.charCodeAt(q);return Q}function wh(J){let Q=atob(J),Z=gU(Q);return crypto.subtle.importKey("spki",new Uint8Array(Z),{name:"ECDSA",namedCurve:"P-256"},!0,["verify"])}var WZ0=30,b2={ANNUAL_LICENSE:1,PERPETUAL_LICENSE:2,INTERNAL_LICENSE:4,WITH_WATERMARK:8,EVALUATION_LICENSE:16,NATIVE_LICENSE:32},zZ0=Math.max(...Object.values(b2)),QH={ID:0,HOSTS:1,FLAGS:2,EXPIRY_DATE:3},GZ0=Object.keys(QH).length,HY="sales@tldraw.com",HZ0=`${Q6()}/watermarks/watermark-track.svg`;class IZ{publicKey="MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEHJh0uUfxHtCGyerXmmatE368Hd9rI6LH9oPDQihnaCryRFWEVeOvf9U/SPbyxX74LFyJs5tYeAHq5Nc0Ax25LQ";isDevelopment;isTest;isCryptoAvailable;state=V0("license state","pending");verbose=!0;constructor(J,Q){this.isTest=!1,this.isDevelopment=this.getIsDevelopment(),this.publicKey=Q||this.publicKey,this.isCryptoAvailable=!!crypto.subtle,this.getLicenseFromKey(J).then((Z)=>{let q=$Z0(Z,(X)=>this.outputMessages(X),this.isDevelopment);this.maybeTrack(Z,q),this.state.set(q)}).catch((Z)=>{console.error("License validation failed:",Z),this.state.set("unlicensed")})}getIsDevelopment(){return!["https:","vscode-webview:"].includes(window.location.protocol)||this.isLoopbackHost(window.location.hostname)||!1}isLoopbackHost(J){let Q=J.toLowerCase().replace(/^\[|\]$/g,"");return Q==="localhost"||Q==="::1"||/^127(?:\.\d{1,3}){3}$/.test(Q)}getTrackType(J,Q){if(Q==="unlicensed-production")return"unlicensed";if(this.isDevelopment)return null;if(!J.isLicenseParseable)return null;if(J.isEvaluationLicense)return"evaluation";if(Q==="licensed-with-watermark")return"with_watermark";return null}maybeTrack(J,Q){let Z=this.getTrackType(J,Q);if(!Z)return;let q=new URL(HZ0);if(q.searchParams.set("version",qY),q.searchParams.set("license_type",Z),"license"in J){q.searchParams.set("license_id",J.license.id);let X=this.isFlagEnabled(J.license.flags,b2.EVALUATION_LICENSE)?"evaluation":this.isFlagEnabled(J.license.flags,b2.ANNUAL_LICENSE)?"annual":this.isFlagEnabled(J.license.flags,b2.PERPETUAL_LICENSE)?"perpetual":"unknown";q.searchParams.set("sku",X)}q.searchParams.set("url",window.location.href),q.searchParams.set("environment","production"),fetch(q.toString())}async extractLicenseKey(J){let[Q,Z]=J.split("."),[q,X]=Q.split("/");if(!q.startsWith("tldraw-"))throw Error(`Unsupported prefix '${q}'`);let K=await wh(this.publicKey),Y;try{Y=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},K,new Uint8Array(gU(atob(Z))),new Uint8Array(gU(atob(X))))}catch(z){throw console.error(z),Error("Could not perform signature validation")}if(!Y)throw Error("Invalid signature");let W;try{W=JSON.parse(atob(X))}catch{throw Error("Could not parse object")}if(W.length>GZ0)this.outputMessages(["License key contains some unknown properties.","You may want to update tldraw packages to a newer version to get access to new functionality."]);return{id:W[QH.ID],hosts:W[QH.HOSTS],flags:W[QH.FLAGS],expiryDate:W[QH.EXPIRY_DATE]}}async getLicenseFromKey(J){if(!J){if(!this.isDevelopment)this.outputNoLicenseKeyProvided();return{isLicenseParseable:!1,reason:"no-key-provided"}}if(this.isDevelopment&&!this.isCryptoAvailable){if(this.verbose)console.log("tldraw: you seem to be in a development environment that does not support crypto. License not verified."),console.log("You should check that this works in production separately.");return{isLicenseParseable:!1,reason:"has-key-development-mode"}}let Q=J.replace(/[\u200B-\u200D\uFEFF]/g,"");Q=Q.replace(/\r?\n|\r/g,"");try{let Z=await this.extractLicenseKey(Q),q=new Date(Z.expiryDate),X=this.isFlagEnabled(Z.flags,b2.ANNUAL_LICENSE),K=this.isFlagEnabled(Z.flags,b2.PERPETUAL_LICENSE),Y=this.isFlagEnabled(Z.flags,b2.EVALUATION_LICENSE),W=X&&this.isAnnualLicenseExpired(q),z=K&&this.isPerpetualLicenseExpired(q),G=K&&!z?0:this.getDaysSinceExpiry(q),$={license:Z,isLicenseParseable:!0,isDevelopment:this.isDevelopment,isDomainValid:this.isDomainValid(Z),expiryDate:q,isAnnualLicense:X,isAnnualLicenseExpired:W,isPerpetualLicense:K,isPerpetualLicenseExpired:z,isInternalLicense:this.isFlagEnabled(Z.flags,b2.INTERNAL_LICENSE),isNativeLicense:this.isNativeLicense(Z),isLicensedWithWatermark:this.isFlagEnabled(Z.flags,b2.WITH_WATERMARK),isEvaluationLicense:Y,isEvaluationLicenseExpired:Y&&this.isEvaluationLicenseExpired(q),daysSinceExpiry:G};return this.outputLicenseInfoIfNeeded($),$}catch(Z){return this.outputInvalidLicenseKey(Z.message),{isLicenseParseable:!1,reason:"invalid-license-key"}}}isDomainValid(J){let Q=window.location.hostname.toLowerCase();return J.hosts.some((Z)=>{let q=Z.toLowerCase().trim();if(q===Q||`www.${q}`===Q||q===`www.${Q}`)return!0;if(Z==="*")return!0;if(this.isNativeLicense(J))return new RegExp(q).test(window.location.href);if(Z.includes("*")){let X=new RegExp(Z.replace(/\*/g,".*?"));return X.test(Q)||X.test(`www.${Q}`)}if(window.location.protocol==="vscode-webview:"){let K=new URL(window.location.href).searchParams.get("extensionId");if(q===K)return!0}return!1})}isNativeLicense(J){return this.isFlagEnabled(J.flags,b2.NATIVE_LICENSE)}getExpirationDateWithoutGracePeriod(J){return new Date(J.getFullYear(),J.getMonth(),J.getDate())}getExpirationDateWithGracePeriod(J){return new Date(J.getFullYear(),J.getMonth(),J.getDate()+WZ0+1)}isAnnualLicenseExpired(J){let Q=this.getExpirationDateWithGracePeriod(J);return new Date>=Q}isPerpetualLicenseExpired(J){let Q=this.getExpirationDateWithGracePeriod(J),Z={major:new Date(DR.major),minor:new Date(DR.minor)};return Z.major>=Q||Z.minor>=Q}getDaysSinceExpiry(J){let Q=new Date,Z=this.getExpirationDateWithoutGracePeriod(J),q=Q.getTime()-Z.getTime(),X=Math.floor(q/86400000);return Math.max(0,X)}isEvaluationLicenseExpired(J){let Q=new Date,Z=this.getExpirationDateWithoutGracePeriod(J);return Q>=Z}isFlagEnabled(J,Q){return(J&Q)===Q}outputNoLicenseKeyProvided(){}outputInvalidLicenseKey(J){this.outputMessages(["Invalid tldraw license key",`Reason: ${J}`])}outputLicenseInfoIfNeeded(J){if(J.license.flags>=zZ0*2)this.outputMessages(["Warning: This tldraw license contains some unknown flags.","This will still work, however, you may want to update tldraw packages to a newer version to get access to new functionality."],"warning")}outputMessages(J,Q="error"){if(this.isTest)return;if(this.verbose){this.outputDelimiter(Q);for(let Z of J){let q=Q==="warning"?"orange":"crimson";console.log(`%c${Z}`,`color: white; background: ${q}; padding: 2px; border-radius: 3px;`)}this.outputDelimiter(Q)}}outputDelimiter(J="error"){console.log("%c-------------------------------------------------------------------",`color: white; background: ${J==="warning"?"orange":"crimson"}; padding: 2px; border-radius: 3px;`)}static className="tl-watermark_SEE-LICENSE"}function $Z0(J,Q,Z){if(!J.isLicenseParseable){if(Z)return"unlicensed";if(J.reason==="no-key-provided")Q(["No tldraw license key provided!","A license is required for production deployments.",`Please reach out to ${HY} to purchase a license.`]);else Q(["Invalid license key. tldraw requires a valid license for production use.",`Please reach out to ${HY} to purchase a license.`]);return"unlicensed-production"}if(!J.isDomainValid&&!J.isDevelopment)return Q(["License key is not valid for this domain.","A license is required for production deployments.",`Please reach out to ${HY} to purchase a license.`]),"unlicensed-production";if(J.isEvaluationLicense)if(J.isEvaluationLicenseExpired)return Q(["Your tldraw evaluation license has expired!",`Please reach out to ${HY} to purchase a full license.`]),"expired";else return"licensed";if(J.isPerpetualLicenseExpired||J.isAnnualLicenseExpired)return Q(["Your tldraw license has been expired for more than 30 days!",`Please reach out to ${HY} to renew your license.`]),"expired";let q=J.daysSinceExpiry;if(q>0&&!J.isEvaluationLicense)return Q(["Your tldraw license has expired.",`License expired ${q} days ago.`,`Please reach out to ${HY} to renew your license.`]),"licensed";if(J.isLicensedWithWatermark)return"licensed-with-watermark";return"licensed"}var uU=E(c(),1);var lJ=E(m(),1);var Th=lJ.createContext({});function yh(){return lJ.useContext(Th)}function bh(J){return J==="expired"||J==="unlicensed-production"}var xh=5000;function vh({licenseKey:J=FZ0()??void 0,children:Q}){let[Z]=lJ.useState(()=>new IZ(J)),q=g(Z.state),[X,K]=lJ.useState(!0);if(lJ.useEffect(()=>{if(bh(q)&&X){let Y=setTimeout(()=>{K(!1)},xh);return()=>clearTimeout(Y)}},[q,X]),bh(q)&&!X)return uU.jsx(_Z0,{});return uU.jsx(Th.Provider,{value:Z,children:Q})}function _Z0(){return uU.jsx("div",{"data-testid":"tl-license-expired",style:{display:"none"}})}var hU=void 0;function FZ0(){if(hU!==void 0)return hU;return hU=Q7(()=>process.env.TLDRAW_LICENSE_KEY)||Q7(()=>process.env.NEXT_PUBLIC_TLDRAW_LICENSE_KEY)||Q7(()=>process.env.REACT_APP_TLDRAW_LICENSE_KEY)||Q7(()=>process.env.GATSBY_TLDRAW_LICENSE_KEY)||Q7(()=>process.env.VITE_TLDRAW_LICENSE_KEY)||Q7(()=>"tldraw-2026-09-27/WyJlaDdIczMxRSIsWyIqIl0sMTYsIjIwMjYtMDktMjciXQ.6OucDghQHnAFl2Ceg8qf48M2oIis6qHdZfqFsKdBZwd610QixrvG1jUnwCbI1Xs2BoXzptPs+pQYF25NyShFbw")||Q7(()=>import.meta.env.TLDRAW_LICENSE_KEY)||Q7(()=>import.meta.env.NEXT_PUBLIC_TLDRAW_LICENSE_KEY)||Q7(()=>import.meta.env.REACT_APP_TLDRAW_LICENSE_KEY)||Q7(()=>import.meta.env.GATSBY_TLDRAW_LICENSE_KEY)||Q7(()=>import.meta.env.VITE_TLDRAW_LICENSE_KEY)||Q7(()=>import.meta.env.PUBLIC_TLDRAW_LICENSE_KEY)||null,hU}function Q7(J){try{return J()}catch{return}}function pJ(J,Q=20){return Math.max(8,Math.ceil(J/Q))}class y3 extends n6{_center;_radius;_start;_end;_largeArcFlag;_sweepFlag;_measure;_angleStart;_angleEnd;constructor(J){super({...J,isFilled:!1,isClosed:!1});let{center:Q,sweepFlag:Z,largeArcFlag:q,start:X,end:K}=J;if(X.equals(K))throw Error("Arc must have different start and end points.");this._angleStart=M.Angle(Q,X),this._angleEnd=M.Angle(Q,K),this._radius=M.Dist(Q,X),this._measure=Dj(this._angleStart,this._angleEnd,Z,q),this._start=X,this._end=K,this._sweepFlag=Z,this._largeArcFlag=q,this._center=Q}nearestPoint(J){let{_center:Q,_measure:Z,_radius:q,_angleEnd:X,_angleStart:K,_start:Y,_end:W}=this,z=eF(Z,K,X,Q.angle(J));if(z<=0)return Y;if(z>=1)return W;let G=J.x-Q.x,$=J.y-Q.y,H=Math.sqrt(G*G+$*$);if(H===0)return Y;let _=q/H;return new M(Q.x+G*_,Q.y+$*_)}hitTestLineSegment(J,Q){let{_center:Z,_radius:q,_measure:X,_angleStart:K,_angleEnd:Y}=this,W=fJ(J,Q,Z,q);if(W===null)return!1;return W.some((z)=>{let G=eF(X,K,Y,Z.angle(z));return G>=0&&G<=1})}getVertices(){let{_center:J,_measure:Q,length:Z,_radius:q,_angleStart:X}=this,K=[];for(let Y=0,W=pJ(Math.abs(Z));Y<W+1;Y++){let z=Y/W*Q,G=X+z;K.push(V3(J,q,G))}return K}getSvgPathData(J=!0){let{_start:Q,_end:Z,_radius:q,_largeArcFlag:X,_sweepFlag:K}=this;return`${J?`M${Q.toFixed()}`:""} A${q} ${q} 0 ${X} ${K} ${Z.toFixed()}`}getLength(){return Math.abs(this._measure*this._radius)}}class r7 extends n6{constructor(J){super({isClosed:!0,...J});this.config=J;let{x:Q=0,y:Z=0,radius:q}=J;this._x=Q,this._y=Z,this._center=new M(q+Q,q+Z),this._radius=q}config;_center;_radius;_x;_y;getBounds(){return new d(this._x,this._y,this._radius*2,this._radius*2)}getVertices(){let{_center:J,_radius:Q}=this,Z=N1*Q,q=[];for(let X=0,K=pJ(Z);X<K;X++){let Y=X/K*N1;q.push(V3(J,Q,Y))}return q}nearestPoint(J){let{_center:Q,_radius:Z}=this,q=J.x-Q.x,X=J.y-Q.y,K=Math.sqrt(q*q+X*X);if(K===0)return new M(Q.x+Z,Q.y);let Y=Z/K;return new M(Q.x+q*Y,Q.y+X*Y)}distanceToPoint(J,Q=!1){let{_center:Z,_radius:q}=this,X=J.x-Z.x,K=J.y-Z.y,W=Math.sqrt(X*X+K*K)-q;if(W<0&&(this.isFilled||Q))return W;return Math.abs(W)}hitTestPoint(J,Q=0,Z=!1){let{_center:q,_radius:X}=this,K=J.x-q.x,Y=J.y-q.y,W=K*K+Y*Y;if((this.isFilled||Z)&&W<=X*X)return!0;let z=X+Q;if(W>z*z)return!1;let G=X-Q;if(G<=0)return!0;return W>=G*G}hitTestLineSegment(J,Q,Z=0){let{_center:q,_radius:X}=this;return fJ(J,Q,q,X+Z)!==null}getSvgPathData(){let{_center:J,_radius:Q}=this;return`M${J.x+Q},${J.y} a${Q},${Q} 0 1,0 ${Q*2},0a${Q},${Q} 0 1,0 -${Q*2},0`}}class $Y extends J7{_a;_b;_c;_d;_resolution;constructor(J){let{start:Q,cp1:Z,cp2:q,end:X}=J;super({...J,points:[Q,X]});this._a=Q,this._b=Z,this._c=q,this._d=X,this._resolution=J.resolution??10}getVertices(){let J=[],{_a:Q,_b:Z,_c:q,_d:X}=this;for(let K=0,Y=this._resolution;K<=Y;K++){let W=K/Y;J.push(new M((1-W)*(1-W)*(1-W)*Q.x+3*((1-W)*(1-W))*W*Z.x+3*(1-W)*(W*W)*q.x+W*W*W*X.x,(1-W)*(1-W)*(1-W)*Q.y+3*((1-W)*(1-W))*W*Z.y+3*(1-W)*(W*W)*q.y+W*W*W*X.y))}return J}nearestPoint(J){let Q,Z=1/0,q,X;for(let K of this.segments)if(X=K.nearestPoint(J),q=M.Dist2(X,J),q<Z)Q=X,Z=q;if(!Q)throw Error("nearest point not found");return Q}distanceToPoint(J,Q=!1){let{segments:Z}=this,q=1/0;for(let X=0;X<Z.length;X++){let K=Z[X].distanceToPoint(J);if(K<q)q=K}return q}getSvgPathData(J=!0){let{_a:Q,_b:Z,_c:q,_d:X}=this;return`${J?`M ${Q.toFixed()} `:""} C${Z.toFixed()} ${q.toFixed()} ${X.toFixed()}`}static GetAtT(J,Q){let{_a:Z,_b:q,_c:X,_d:K}=J;return new M((1-Q)*(1-Q)*(1-Q)*Z.x+3*((1-Q)*(1-Q))*Q*q.x+3*(1-Q)*(Q*Q)*X.x+Q*Q*Q*K.x,(1-Q)*(1-Q)*(1-Q)*Z.y+3*((1-Q)*(1-Q))*Q*q.y+3*(1-Q)*(Q*Q)*X.y+Q*Q*Q*K.y)}getLength(J,Q=32){let Z,q=this._a,X=0;for(let K=1;K<=Q;K++)Z=$Y.GetAtT(this,K/Q),X+=M.Dist(q,Z),q=Z;return X}}class _Y extends n6{constructor(J){super({...J,isClosed:!0});this.config=J;let{width:Q,height:Z}=J;this._w=Q,this._h=Z}config;_w;_h;_edges;get edges(){if(!this._edges){let{vertices:J}=this;this._edges=[];for(let Q=0,Z=J.length;Q<Z;Q++){let q=J[Q],X=J[(Q+1)%Z];this._edges.push(new d8({start:q,end:X}))}}return this._edges}getVertices(){let J=Math.max(1,this._w),Q=Math.max(1,this._h),Z=J/2,q=Q/2,X=Math.pow(Z-q,2)/Math.pow(Z+q,2),K=B1*(Z+q)*(1+3*X/(10+Math.sqrt(4-3*X))),Y=pJ(K),W=N1/Y,z=Math.cos(W),G=Math.sin(W),$=0,H=1,_=0,F=1,U=Array(Y);for(let V=0;V<Y;V++)U[V]=new M(M0(Z+Z*H,0,J),M0(q+q*$,0,Q)),_=G*H+z*$,F=z*H-G*$,$=_,H=F;return U}nearestPoint(J){let Q,Z=1/0,q,X;for(let K of this.edges)if(X=K.nearestPoint(J),q=M.Dist2(X,J),q<Z)Q=X,Z=q;if(!Q)throw Error("nearest point not found");return Q}distanceToPoint(J,Q=!1){let{edges:Z}=this,q=1/0;for(let X=0;X<Z.length;X++){let K=Z[X].distanceToPoint(J);if(K<q)q=K}if(this.isClosed&&(this.isFilled||Q)&&n1(J,this.vertices))return-q;return q}hitTestLineSegment(J,Q){return this.edges.some((Z)=>Z.hitTestLineSegment(J,Q))}getBounds(){return new d(0,0,this._w,this._h)}getLength(){let{_w:J,_h:Q}=this,Z=J/2,q=Q/2,X=Math.max(0,Z),K=Math.max(0,q);return Nj(X,K)}getSvgPathData(J=!1){let{_w:Q,_h:Z}=this,q=Q/2,X=Z/2,K=Math.max(0,q),Y=Math.max(0,X);return`${J?`M${q-K},${X}`:""} a${K},${Y},0,1,1,${K*2},0a${K},${Y},0,1,1,-${K*2},0`}}var i4=E(c(),1);var nh=E(c1(),1),Y4=E(m(),1);var Sh=E(m(),1);function fh(){let J=v(),Q=Q1(),Z=z6(),q=g(V1.forceSrgb);Sh.default.useEffect(()=>{if(Z==="dark")Q.setAttribute("data-color-mode","dark"),Q.classList.remove("tl-theme__light"),Q.classList.add("tl-theme__dark");else Q.setAttribute("data-color-mode","light"),Q.classList.remove("tl-theme__dark"),Q.classList.add("tl-theme__light");if(q)Q.classList.add("tl-theme__force-sRGB");else Q.classList.remove("tl-theme__force-sRGB")},[J,Q,q,Z])}var mU=E(m(),1);function gh(){let[J,Q]=mU.useState(0);mU.useEffect(()=>Q((Z)=>Z+1),[])}var hh=E(m(),1);function uh(){let J=v();hh.useLayoutEffect(()=>{return P1("stateAttribute",()=>{let Q=J.getContainer(),Z=J.getInstanceState();Q.setAttribute("data-state",J.getPath()),Q.setAttribute("data-coarse",String(Z.isCoarsePointer))})},[J])}var mh=E(m(),1);function ch(){let J=v(),Q=Q1();mh.useEffect(()=>{let Z=(K)=>Q.style.setProperty("--tl-zoom",K.toString()),q=jJ(Z,100),X=new B9("useZoomCss",()=>Z(J.getEfficientZoomLevel()));return X.attach(),X.execute(),()=>{X.detach(),q.cancel()}},[J,Q])}var x9=E(c(),1);var wZ=E(m(),1);var lh='<svg xmlns="http://www.w3.org/2000/svg" width="3001" height="1000" fill="none"><path fill="#000" d="M590.656 300.449c0 49.706-40.294 90-90 90-49.705 0-90-40.294-90-90 0-49.705 40.295-90 90-90 49.706 0 90 40.295 90 90M569.431 719.011c-15.247 32.821-56.006 91.589-98.338 91.438-32.004-.115-38.642-30.904-17.414-50.856 17.381-16.337 28.246-48.075 31.995-72.719.415-2.728-1.556-5.197-4.272-5.679-39.666-7.04-70.746-40.877-70.746-83.417 0-48.23 38.983-87.329 87.07-87.329 39.936 0 70.172 22.237 83.369 52.397 18.839 43.055 7.117 115.733-11.664 156.165M2613.29 385.681V239.319c0-11.363 9.22-20.569 20.59-20.569h8.26c11.37 0 20.59 9.206 20.59 20.569v36.911c0 8.629 7 15.625 15.63 15.625h35.25c8.63 0 15.63-6.996 15.63-15.625v-36.911c0-11.363 9.22-20.569 20.59-20.569h8.17c11.37 0 20.59 9.206 20.59 20.569v146.362c0 11.363-9.22 20.569-20.59 20.569h-8.17c-11.37 0-20.59-9.206-20.59-20.569v-36.999c0-8.63-7-15.625-15.63-15.625h-35.25c-8.63 0-15.63 6.995-15.63 15.625v36.999c0 11.363-9.22 20.569-20.59 20.569h-8.26c-11.37 0-20.59-9.206-20.59-20.569M2391.97 239.319v146.362c0 11.348-9.16 20.569-20.49 20.569h-8.2c-11.33 0-20.49-9.221-20.49-20.569V239.319c0-11.348 9.16-20.569 20.49-20.569h8.2c11.33 0 20.49 9.221 20.49 20.569M2098.23 391.43l-42.69-146.361c-3.85-13.171 6.06-26.319 19.79-26.319h10.6c9.59 0 17.93 6.611 20.08 15.952l17.01 73.045c1.48 6.348 10.47 6.478 12.14.176l19.47-73.838c2.38-9.04 10.57-15.335 19.93-15.335h12.1c9.37 0 17.56 6.3 19.94 15.346l19.49 74.067c1.66 6.305 10.65 6.178 12.13-.171l17.09-73.294c2.15-9.339 10.49-15.948 20.08-15.948h10.53c13.72 0 23.63 13.141 19.79 26.31l-42.63 146.361c-2.56 8.789-10.63 14.829-19.79 14.829h-15.68c-9.12 0-17.16-5.98-19.76-14.709l-21.17-71.059c-1.77-5.948-10.19-5.957-11.97-.012l-21.33 71.071c-2.6 8.729-10.64 14.709-19.76 14.709h-15.59c-9.17 0-17.23-6.035-19.8-14.82M2443.23 218.75h118.59c11.38 0 20.62 9.195 20.62 20.557s-9.24 20.556-20.62 20.556h-24.79c-5.53 0-10 4.477-10 10v115.818c0 11.368-9.25 20.569-20.63 20.569h-7.65c-11.39 0-20.63-9.201-20.63-20.569V269.863c0-5.523-4.48-10-10-10h-24.89c-11.37 0-20.61-9.195-20.61-20.556s9.24-20.557 20.61-20.557M1174.15 218.75h24.64c8.35 0 15.88 5.042 19.04 12.764l34.61 83.942c2.13 5.161 9.44 5.155 11.56-.01l34.43-83.932a20.58 20.58 0 0 1 19.04-12.764h24.64c11.37 0 20.58 9.208 20.58 20.569v146.362c0 11.361-9.21 20.569-20.58 20.569h-7.09c-11.36 0-20.58-9.208-20.58-20.569l-.12-50.645c-.01-6.888-9.53-8.688-12.06-2.283l-23.46 59.332a20.57 20.57 0 0 1-19.14 13.009h-3.03a20.57 20.57 0 0 1-19.15-13.046l-23.47-59.68c-2.52-6.416-12.05-4.623-12.06 2.271l-.13 51.042c0 11.361-9.21 20.569-20.57 20.569h-7.1c-11.36 0-20.57-9.208-20.57-20.569V239.319c0-11.361 9.21-20.569 20.57-20.569"/><path fill="#000" fill-rule="evenodd" d="m1449.94 391.836 6.12-19.392a6.255 6.255 0 0 1 5.96-4.369l50.22-.061a6.24 6.24 0 0 1 5.96 4.348l6.23 19.486c2.71 8.581 10.71 14.402 19.74 14.402h9.34c14.13 0 24.15-13.791 19.61-27.151l-49.74-146.361c-2.85-8.37-10.74-13.988-19.61-13.988h-33.16c-8.87 0-16.77 5.618-19.61 13.988l-49.74 146.361c-4.54 13.36 5.48 27.151 19.61 27.151h9.32c9.04 0 17.04-5.827 19.75-14.414m31.1-98.858c1.85-5.807 10.08-5.796 11.91.016l8.83 27.916c1.28 4.028-1.73 8.134-5.96 8.134h-17.74c-4.23 0-7.24-4.119-5.95-8.151zM1681.81 406.25c18.91 0 35.39-3.686 49.36-11.168 13.97-7.544 24.73-18.394 32.24-32.489 7.56-14.105 11.29-30.866 11.29-50.182 0-19.256-3.73-35.957-11.29-50.004-7.57-14.094-18.35-24.912-32.32-32.397-13.91-7.545-30.4-11.26-49.37-11.26h-49.5c-11.38 0-20.63 9.201-20.63 20.569v146.362c0 11.368 9.25 20.569 20.63 20.569zm23.13-47.701c-6.62 3.215-14.85 4.886-24.79 4.886-10.49 0-19-8.507-19-19v-64.34c0-10.149 8.23-18.376 18.38-18.376 10.18 0 18.56 1.703 25.23 4.974 6.59 3.149 11.63 8.315 15.08 15.633 3.45 7.269 5.28 17.268 5.28 30.162 0 12.891-1.82 22.951-5.28 30.347-3.39 7.319-8.36 12.509-14.9 15.714" clip-rule="evenodd"/><path fill="#000" d="M1804.21 385.681V239.319c0-11.361 9.21-20.569 20.58-20.569h91.28c11.36 0 20.57 9.202 20.57 20.557s-9.21 20.556-20.57 20.556h-54.64a7.807 7.807 0 0 0-7.81 7.813v16.366a7.806 7.806 0 0 0 7.81 7.812h48.13c11.37 0 20.58 9.246 20.58 20.602s-9.21 20.601-20.58 20.601h-48.13a7.806 7.806 0 0 0-7.81 7.812v16.455a7.807 7.807 0 0 0 7.81 7.813h54.64c11.36 0 20.57 9.202 20.57 20.556s-9.21 20.557-20.57 20.557h-91.28c-11.37 0-20.58-9.208-20.58-20.569"/><path fill="#000" fill-rule="evenodd" d="M2875.5 68.75h-2750c-31.066 0-56.25 25.184-56.25 56.25v750c0 31.066 25.184 56.25 56.25 56.25h2750c31.07 0 56.25-25.184 56.25-56.25V125c0-31.066-25.18-56.25-56.25-56.25M125.5 0C56.464 0 .5 55.964.5 125v750c0 69.036 55.965 125 125 125h2750c69.04 0 125-55.964 125-125V125c0-69.036-55.96-125-125-125z" clip-rule="evenodd"/><path fill="#000" d="M2476.06 804.813c-10.54 0-19.82-6.947-22.81-17.068L2390.79 575.7c-4.49-15.248 6.92-30.534 22.8-30.534h27.75c11.1 0 20.72 7.686 23.18 18.52L2489 671.402c2.07 9.093 14.93 9.321 17.32.308l28.83-108.844c2.76-10.435 12.19-17.7 22.98-17.7h25.17c10.8 0 20.25 7.293 22.99 17.755l28.27 107.739c2.36 9.001 15.18 8.829 17.3-.232l25.01-106.888c2.51-10.763 12.1-18.374 23.14-18.374h27.87c15.88 0 27.29 15.286 22.8 30.534l-62.46 212.045a23.78 23.78 0 0 1-22.81 17.068h-32.12c-10.39 0-19.58-6.763-22.69-16.696l-32.08-102.694c-2.62-8.397-14.51-8.331-17.04.095l-30.74 102.346c-3.02 10.061-12.27 16.949-22.76 16.949zM1742.44 804.813h-75.81c-13.09 0-23.71-10.656-23.71-23.801V568.967c0-13.145 10.62-23.801 23.71-23.801h74.8c26.6 0 49.59 5.198 68.95 15.594 19.45 10.312 34.44 25.187 44.96 44.627 10.61 19.355 15.91 42.556 15.91 69.602q0 40.57-15.78 69.73c-10.53 19.355-25.43 34.231-44.71 44.627-19.28 10.311-42.05 15.467-68.32 15.467m-29.3-83.642c0 13.145 10.61 23.801 23.71 23.801h3.06c12.8 0 23.7-2.07 32.71-6.212 9.09-4.141 16-11.283 20.71-21.426q7.2-15.213 7.2-42.345 0-27.13-7.32-42.344c-4.8-10.143-11.87-17.285-21.22-21.426-9.26-4.142-20.63-6.212-34.1-6.212h-1.04c-13.1 0-23.71 10.656-23.71 23.801zM1460.86 804.813c-13.12 0-23.76-10.656-23.76-23.801V568.967c0-13.145 10.64-23.801 23.76-23.801h22.84c13.13 0 23.76 10.656 23.76 23.801v155.247c0 13.145 10.64 23.801 23.76 23.801h57.27c13.12 0 23.76 10.656 23.76 23.801v9.196c0 13.145-10.64 23.801-23.76 23.801zM1204.45 601.964c-13.13 0-23.77-10.656-23.77-23.801v-9.196c0-13.145 10.64-23.801 23.77-23.801h177.89c13.13 0 23.78 10.656 23.78 23.801v9.196c0 13.145-10.65 23.801-23.78 23.801h-39.38c-8.21 0-14.86 6.66-14.86 14.875v164.173c0 13.145-10.64 23.801-23.78 23.801h-21.85c-13.13 0-23.78-10.656-23.78-23.801V616.839c0-8.215-6.65-14.875-14.86-14.875z"/><path fill="#000" fill-rule="evenodd" d="M2223.05 787.891c-3.02 10.047-12.27 16.922-22.74 16.922h-25.43c-16.19 0-27.64-15.862-22.57-31.261l69.88-212.045c3.21-9.753 12.31-16.341 22.56-16.341h61.84c10.25 0 19.35 6.588 22.56 16.341l69.87 212.045c5.08 15.399-6.37 31.261-22.56 31.261h-25.43c-10.48 0-19.72-6.875-22.74-16.922l-6.7-22.2a14.84 14.84 0 0 0-14.21-10.576h-63.42c-6.55 0-12.32 4.296-14.22 10.576zm76.13-96.945-14.13-48.436c-2.46-8.451-14.36-8.602-17.04-.217l-15.46 48.436c-1.84 5.759 2.45 11.645 8.48 11.645h29.6c5.94 0 10.22-5.715 8.55-11.428" clip-rule="evenodd"/><path fill="#000" d="M1939.6 804.813c-13.13 0-23.77-10.656-23.77-23.801V568.967c0-13.145 10.64-23.801 23.77-23.801h88.13c19.24 0 36.08 3.508 50.51 10.523s25.65 17.115 33.67 30.3q12.03 19.779 12.03 47.416c0 18.595-4.14 34.273-12.41 47.036-7.64 11.913-18.18 21.101-31.63 27.564-16.98 8.159-36 11.104-54.7 11.104h-43.07c-76.56 0 4.08-135.84 4.08-84.706v7.996c0 12.117 9.81 21.941 21.91 21.941 8.12 0 16.3-.345 24.04-3.043 5.91-2.113 10.43-5.451 13.55-10.015 3.2-4.565 4.81-10.523 4.81-17.877 0-7.437-1.61-13.481-4.81-18.129-3.12-4.733-7.64-8.199-13.55-10.396-7.05-2.766-14.67-3.423-22.18-3.423-13.13 0-23.77 10.656-23.77 23.801v47.71c0 11.825 11.14 16.003 19.91 20.752 12.31 6.671 7.58 25.389-6.42 25.389-7.45 0-13.49 6.048-13.49 13.508v48.395c0 13.145-10.63 23.801-23.76 23.801zm134.89-106.758 5.41 9.95 33.51 61.622c8.62 15.86-2.84 35.186-20.87 35.186h-22.27c-8.74 0-16.77-4.798-20.92-12.496l-35.05-65.04a15.52 15.52 0 0 0-13.66-8.168c-42.24 0 40.62-82.154 73.85-21.054M931.652 0h68.748v1000h-68.748z"/></svg>',ph='<svg xmlns="http://www.w3.org/2000/svg" width="400" height="1601" fill="none"><path fill="#000" d="M72 1319.8c0-10.73 7.071-20.18 17.372-23.22l215.823-63.62c15.519-4.57 31.078 7.05 31.078 23.22v28.26c0 11.31-7.824 21.1-18.85 23.61l-109.636 24.94c-9.254 2.1-9.487 15.2-.313 17.63l110.784 29.37a24.21 24.21 0 0 1 18.015 23.4v25.64c0 11-7.423 20.62-18.071 23.41l-109.659 28.79c-9.162 2.41-8.986 15.47.236 17.63l108.792 25.46c10.955 2.56 18.702 12.33 18.702 23.57v28.39c0 16.17-15.559 27.79-31.078 23.22l-215.823-63.62c-10.3-3.04-17.372-12.49-17.372-23.22v-32.72c0-10.59 6.883-19.95 16.994-23.11l104.523-32.67c8.547-2.67 8.479-14.79-.096-17.36l-104.17-31.3C79.01 1372.42 72 1363 72 1352.31zM72 572.638V495.43c0-13.336 10.846-24.147 24.225-24.147h215.823c13.379 0 24.225 10.811 24.225 24.147v76.179q0 40.645-15.872 70.228-15.743 29.712-45.422 45.79-29.55 16.206-70.843 16.206-41.292 0-70.971-16.078-29.55-16.077-45.422-45.532Q72 612.767 72 572.638m85.132-29.84c-13.379 0-24.225 10.81-24.225 24.146v3.122q0 19.55 6.323 33.313 6.323 13.89 21.807 21.094 15.485 7.332 43.099 7.331t43.1-7.46q15.484-7.33 21.807-21.608 6.323-14.15 6.323-34.728v-1.064c0-13.336-10.846-24.146-24.225-24.146zM72 285.858c0-13.363 10.846-24.197 24.225-24.197h215.823c13.379 0 24.225 10.834 24.225 24.197v23.27c0 13.364-10.846 24.197-24.225 24.197H154.035c-13.379 0-24.225 10.834-24.225 24.197v58.328c0 13.364-10.846 24.197-24.225 24.197h-9.36C82.845 440.047 72 429.214 72 415.85zM278.463 24.72c0-13.374 10.846-24.216 24.225-24.216h9.36c13.379 0 24.225 10.842 24.225 24.216v181.174c0 13.374-10.846 24.216-24.225 24.216h-9.36c-13.379 0-24.225-10.842-24.225-24.216v-40.108c0-8.359-6.779-15.135-15.141-15.135H96.225c-13.38 0-24.225-10.842-24.225-24.216v-22.256c0-13.374 10.846-24.216 24.225-24.216h167.097c8.362 0 15.141-6.776 15.141-15.135z"/><path fill="#000" fill-rule="evenodd" d="M89.224 1062.13C78.997 1059.04 72 1049.63 72 1038.96v-25.9c0-16.486 16.145-28.147 31.818-22.979l215.823 71.169a24.19 24.19 0 0 1 16.632 22.98v62.97c0 10.45-6.706 19.71-16.632 22.98l-215.823 71.17C88.145 1246.51 72 1234.86 72 1218.37v-25.9c0-10.67 6.997-20.08 17.224-23.17l22.595-6.81a15.13 15.13 0 0 0 10.765-14.48v-64.59a15.13 15.13 0 0 0-10.765-14.48zm98.672 77.53 49.299-14.39c8.601-2.51 8.755-14.62.22-17.35l-49.299-15.75c-5.861-1.88-11.852 2.49-11.852 8.64v30.14c0 6.05 5.817 10.41 11.632 8.71" clip-rule="evenodd"/><path fill="#000" d="M72 773.439c0-13.367 10.846-24.203 24.225-24.203h215.823c13.379 0 24.225 10.836 24.225 24.203v89.762q0 29.395-10.711 51.439-10.71 22.046-30.84 34.293t-48.261 12.248q-28.388 0-47.873-12.635-18.187-11.672-28.056-32.218c-8.303-17.289-11.301-36.661-11.301-55.705v-43.867c0-77.976 138.26 4.16 86.215 4.16h-8.138c-12.334 0-22.332 9.989-22.332 22.311 0 8.269.351 16.6 3.097 24.487q3.225 9.024 10.194 13.794 6.968 4.899 18.194 4.899 11.356 0 18.453-4.899 7.226-4.77 10.581-13.794c2.815-7.188 3.484-14.944 3.484-22.596 0-13.366-10.846-24.202-24.225-24.202h-48.56c-12.036 0-16.288 11.345-21.122 20.272-6.79 12.539-25.841 7.72-25.841-6.536 0-7.586-6.156-13.736-13.749-13.736H96.225C82.845 820.916 72 810.08 72 796.714zm108.66 137.378-10.128 5.511-62.72 34.131C91.67 959.243 72 947.569 72 929.205V906.52a24.2 24.2 0 0 1 12.719-21.299l66.199-35.696a15.82 15.82 0 0 0 8.313-13.921c0-43.012 83.618 41.371 21.429 75.213"/></svg>';function dh(J){return g("watermarkState",()=>J.state.get(),[J])}var UZ0=`data:image/svg+xml;utf8,${encodeURIComponent(lh)}`,VZ0=`data:image/svg+xml;utf8,${encodeURIComponent(ph)}`,ih=wZ.memo(function(){let Q=yh(),Z=v(),q=g("is mobile",()=>Z.getViewportScreenBounds().width<700,[Z]),X=dh(Q);if(!["licensed-with-watermark","unlicensed"].includes(X))return null;return x9.jsxs(x9.Fragment,{children:[x9.jsx(LZ0,{}),x9.jsx(BZ0,{src:q?VZ0:UZ0,isUnlicensed:X==="unlicensed"})]})}),NZ0=wZ.memo(function({isDebugMode:Q,isMobile:Z}){let q=v(),X=_3(),K=wZ.useRef(null);r6(K);let Y="https://tldraw.dev/pricing?utm_source=sdk&utm_medium=organic&utm_campaign=watermark";return x9.jsx("div",{ref:K,className:IZ.className,"data-debug":Q,"data-mobile":Z,"data-unlicensed":!0,"data-testid":"tl-watermark-unlicensed",draggable:!1,...X,children:x9.jsx("button",{draggable:!1,role:"button",onPointerDown:(W)=>{q.markEventAsHandled(W),W0(W)},title:"The tldraw SDK requires a license key to work in production. You can get a free 100-day trial license at tldraw.dev/pricing.",onClick:()=>{M3.openWindow(Y,"_blank",!0)},children:"Get a license for production"})})}),BZ0=wZ.memo(function({src:Q,isUnlicensed:Z}){let q=v(),X=g("debug mode",()=>q.getInstanceState().isDebugMode,[q]),K=g("is mobile",()=>q.getViewportScreenBounds().width<700,[q]),Y=_3(),W=wZ.useRef(null);r6(W);let z=`url('${Q}') center 100% / 100% no-repeat`,G="https://tldraw.dev/?utm_source=sdk&utm_medium=organic&utm_campaign=watermark";if(Z)return x9.jsx(NZ0,{isDebugMode:X,isMobile:K});return x9.jsx("div",{ref:W,className:IZ.className,"data-debug":X,"data-mobile":K,"data-testid":"tl-watermark-licensed",draggable:!1,...Y,children:x9.jsx("button",{draggable:!1,role:"button",onPointerDown:($)=>{q.markEventAsHandled($),W0($)},title:"Build infinite canvas applications with the tldraw SDK. Learn more at https://tldraw.dev.",onClick:()=>{M3.openWindow(G,"_blank")},style:{mask:z,WebkitMask:z}})})}),LZ0=wZ.memo(function(){let Q=v(),Z=IZ.className,q=`
95
+ */function gU(J){let Q=new ArrayBuffer(J.length),Z=new Uint8Array(Q);for(let q=0,X=J.length;q<X;q++)Z[q]=J.charCodeAt(q);return Q}function wh(J){let Q=atob(J),Z=gU(Q);return crypto.subtle.importKey("spki",new Uint8Array(Z),{name:"ECDSA",namedCurve:"P-256"},!0,["verify"])}var WZ0=30,b2={ANNUAL_LICENSE:1,PERPETUAL_LICENSE:2,INTERNAL_LICENSE:4,WITH_WATERMARK:8,EVALUATION_LICENSE:16,NATIVE_LICENSE:32},zZ0=Math.max(...Object.values(b2)),QH={ID:0,HOSTS:1,FLAGS:2,EXPIRY_DATE:3},GZ0=Object.keys(QH).length,HY="sales@tldraw.com",HZ0=`${Q6()}/watermarks/watermark-track.svg`;class IZ{publicKey="MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEHJh0uUfxHtCGyerXmmatE368Hd9rI6LH9oPDQihnaCryRFWEVeOvf9U/SPbyxX74LFyJs5tYeAHq5Nc0Ax25LQ";isDevelopment;isTest;isCryptoAvailable;state=V0("license state","pending");verbose=!0;constructor(J,Q){this.isTest=!1,this.isDevelopment=this.getIsDevelopment(),this.publicKey=Q||this.publicKey,this.isCryptoAvailable=!!crypto.subtle,this.getLicenseFromKey(J).then((Z)=>{let q=$Z0(Z,(X)=>this.outputMessages(X),this.isDevelopment);this.maybeTrack(Z,q),this.state.set(q)}).catch((Z)=>{console.error("License validation failed:",Z),this.state.set("unlicensed")})}getIsDevelopment(){return!["https:","vscode-webview:"].includes(window.location.protocol)||this.isLoopbackHost(window.location.hostname)||!1}isLoopbackHost(J){let Q=J.toLowerCase().replace(/^\[|\]$/g,"");return Q==="localhost"||Q==="::1"||/^127(?:\.\d{1,3}){3}$/.test(Q)}getTrackType(J,Q){if(Q==="unlicensed-production")return"unlicensed";if(this.isDevelopment)return null;if(!J.isLicenseParseable)return null;if(J.isEvaluationLicense)return"evaluation";if(Q==="licensed-with-watermark")return"with_watermark";return null}maybeTrack(J,Q){let Z=this.getTrackType(J,Q);if(!Z)return;let q=new URL(HZ0);if(q.searchParams.set("version",qY),q.searchParams.set("license_type",Z),"license"in J){q.searchParams.set("license_id",J.license.id);let X=this.isFlagEnabled(J.license.flags,b2.EVALUATION_LICENSE)?"evaluation":this.isFlagEnabled(J.license.flags,b2.ANNUAL_LICENSE)?"annual":this.isFlagEnabled(J.license.flags,b2.PERPETUAL_LICENSE)?"perpetual":"unknown";q.searchParams.set("sku",X)}q.searchParams.set("url",window.location.href),q.searchParams.set("environment","production"),fetch(q.toString())}async extractLicenseKey(J){let[Q,Z]=J.split("."),[q,X]=Q.split("/");if(!q.startsWith("tldraw-"))throw Error(`Unsupported prefix '${q}'`);let K=await wh(this.publicKey),Y;try{Y=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},K,new Uint8Array(gU(atob(Z))),new Uint8Array(gU(atob(X))))}catch(z){throw console.error(z),Error("Could not perform signature validation")}if(!Y)throw Error("Invalid signature");let W;try{W=JSON.parse(atob(X))}catch{throw Error("Could not parse object")}if(W.length>GZ0)this.outputMessages(["License key contains some unknown properties.","You may want to update tldraw packages to a newer version to get access to new functionality."]);return{id:W[QH.ID],hosts:W[QH.HOSTS],flags:W[QH.FLAGS],expiryDate:W[QH.EXPIRY_DATE]}}async getLicenseFromKey(J){if(!J){if(!this.isDevelopment)this.outputNoLicenseKeyProvided();return{isLicenseParseable:!1,reason:"no-key-provided"}}if(this.isDevelopment&&!this.isCryptoAvailable){if(this.verbose)console.log("tldraw: you seem to be in a development environment that does not support crypto. License not verified."),console.log("You should check that this works in production separately.");return{isLicenseParseable:!1,reason:"has-key-development-mode"}}let Q=J.replace(/[\u200B-\u200D\uFEFF]/g,"");Q=Q.replace(/\r?\n|\r/g,"");try{let Z=await this.extractLicenseKey(Q),q=new Date(Z.expiryDate),X=this.isFlagEnabled(Z.flags,b2.ANNUAL_LICENSE),K=this.isFlagEnabled(Z.flags,b2.PERPETUAL_LICENSE),Y=this.isFlagEnabled(Z.flags,b2.EVALUATION_LICENSE),W=X&&this.isAnnualLicenseExpired(q),z=K&&this.isPerpetualLicenseExpired(q),G=K&&!z?0:this.getDaysSinceExpiry(q),$={license:Z,isLicenseParseable:!0,isDevelopment:this.isDevelopment,isDomainValid:this.isDomainValid(Z),expiryDate:q,isAnnualLicense:X,isAnnualLicenseExpired:W,isPerpetualLicense:K,isPerpetualLicenseExpired:z,isInternalLicense:this.isFlagEnabled(Z.flags,b2.INTERNAL_LICENSE),isNativeLicense:this.isNativeLicense(Z),isLicensedWithWatermark:this.isFlagEnabled(Z.flags,b2.WITH_WATERMARK),isEvaluationLicense:Y,isEvaluationLicenseExpired:Y&&this.isEvaluationLicenseExpired(q),daysSinceExpiry:G};return this.outputLicenseInfoIfNeeded($),$}catch(Z){return this.outputInvalidLicenseKey(Z.message),{isLicenseParseable:!1,reason:"invalid-license-key"}}}isDomainValid(J){let Q=window.location.hostname.toLowerCase();return J.hosts.some((Z)=>{let q=Z.toLowerCase().trim();if(q===Q||`www.${q}`===Q||q===`www.${Q}`)return!0;if(Z==="*")return!0;if(this.isNativeLicense(J))return new RegExp(q).test(window.location.href);if(Z.includes("*")){let X=new RegExp(Z.replace(/\*/g,".*?"));return X.test(Q)||X.test(`www.${Q}`)}if(window.location.protocol==="vscode-webview:"){let K=new URL(window.location.href).searchParams.get("extensionId");if(q===K)return!0}return!1})}isNativeLicense(J){return this.isFlagEnabled(J.flags,b2.NATIVE_LICENSE)}getExpirationDateWithoutGracePeriod(J){return new Date(J.getFullYear(),J.getMonth(),J.getDate())}getExpirationDateWithGracePeriod(J){return new Date(J.getFullYear(),J.getMonth(),J.getDate()+WZ0+1)}isAnnualLicenseExpired(J){let Q=this.getExpirationDateWithGracePeriod(J);return new Date>=Q}isPerpetualLicenseExpired(J){let Q=this.getExpirationDateWithGracePeriod(J),Z={major:new Date(DR.major),minor:new Date(DR.minor)};return Z.major>=Q||Z.minor>=Q}getDaysSinceExpiry(J){let Q=new Date,Z=this.getExpirationDateWithoutGracePeriod(J),q=Q.getTime()-Z.getTime(),X=Math.floor(q/86400000);return Math.max(0,X)}isEvaluationLicenseExpired(J){let Q=new Date,Z=this.getExpirationDateWithoutGracePeriod(J);return Q>=Z}isFlagEnabled(J,Q){return(J&Q)===Q}outputNoLicenseKeyProvided(){}outputInvalidLicenseKey(J){this.outputMessages(["Invalid tldraw license key",`Reason: ${J}`])}outputLicenseInfoIfNeeded(J){if(J.license.flags>=zZ0*2)this.outputMessages(["Warning: This tldraw license contains some unknown flags.","This will still work, however, you may want to update tldraw packages to a newer version to get access to new functionality."],"warning")}outputMessages(J,Q="error"){if(this.isTest)return;if(this.verbose){this.outputDelimiter(Q);for(let Z of J){let q=Q==="warning"?"orange":"crimson";console.log(`%c${Z}`,`color: white; background: ${q}; padding: 2px; border-radius: 3px;`)}this.outputDelimiter(Q)}}outputDelimiter(J="error"){console.log("%c-------------------------------------------------------------------",`color: white; background: ${J==="warning"?"orange":"crimson"}; padding: 2px; border-radius: 3px;`)}static className="tl-watermark_SEE-LICENSE"}function $Z0(J,Q,Z){if(!J.isLicenseParseable){if(Z)return"unlicensed";if(J.reason==="no-key-provided")Q(["No tldraw license key provided!","A license is required for production deployments.",`Please reach out to ${HY} to purchase a license.`]);else Q(["Invalid license key. tldraw requires a valid license for production use.",`Please reach out to ${HY} to purchase a license.`]);return"unlicensed-production"}if(!J.isDomainValid&&!J.isDevelopment)return Q(["License key is not valid for this domain.","A license is required for production deployments.",`Please reach out to ${HY} to purchase a license.`]),"unlicensed-production";if(J.isEvaluationLicense)if(J.isEvaluationLicenseExpired)return Q(["Your tldraw evaluation license has expired!",`Please reach out to ${HY} to purchase a full license.`]),"expired";else return"licensed";if(J.isPerpetualLicenseExpired||J.isAnnualLicenseExpired)return Q(["Your tldraw license has been expired for more than 30 days!",`Please reach out to ${HY} to renew your license.`]),"expired";let q=J.daysSinceExpiry;if(q>0&&!J.isEvaluationLicense)return Q(["Your tldraw license has expired.",`License expired ${q} days ago.`,`Please reach out to ${HY} to renew your license.`]),"licensed";if(J.isLicensedWithWatermark)return"licensed-with-watermark";return"licensed"}var uU=E(c(),1);var lJ=E(m(),1);var Th=lJ.createContext({});function yh(){return lJ.useContext(Th)}function bh(J){return J==="expired"||J==="unlicensed-production"}var xh=5000;function vh({licenseKey:J=FZ0()??void 0,children:Q}){let[Z]=lJ.useState(()=>new IZ(J)),q=g(Z.state),[X,K]=lJ.useState(!0);if(lJ.useEffect(()=>{if(bh(q)&&X){let Y=setTimeout(()=>{K(!1)},xh);return()=>clearTimeout(Y)}},[q,X]),bh(q)&&!X)return uU.jsx(_Z0,{});return uU.jsx(Th.Provider,{value:Z,children:Q})}function _Z0(){return uU.jsx("div",{"data-testid":"tl-license-expired",style:{display:"none"}})}var hU=void 0;function FZ0(){if(hU!==void 0)return hU;return hU=Q7(()=>process.env.TLDRAW_LICENSE_KEY)||Q7(()=>process.env.NEXT_PUBLIC_TLDRAW_LICENSE_KEY)||Q7(()=>process.env.REACT_APP_TLDRAW_LICENSE_KEY)||Q7(()=>process.env.GATSBY_TLDRAW_LICENSE_KEY)||Q7(()=>process.env.VITE_TLDRAW_LICENSE_KEY)||Q7(()=>"")||Q7(()=>import.meta.env.TLDRAW_LICENSE_KEY)||Q7(()=>import.meta.env.NEXT_PUBLIC_TLDRAW_LICENSE_KEY)||Q7(()=>import.meta.env.REACT_APP_TLDRAW_LICENSE_KEY)||Q7(()=>import.meta.env.GATSBY_TLDRAW_LICENSE_KEY)||Q7(()=>import.meta.env.VITE_TLDRAW_LICENSE_KEY)||Q7(()=>import.meta.env.PUBLIC_TLDRAW_LICENSE_KEY)||null,hU}function Q7(J){try{return J()}catch{return}}function pJ(J,Q=20){return Math.max(8,Math.ceil(J/Q))}class y3 extends n6{_center;_radius;_start;_end;_largeArcFlag;_sweepFlag;_measure;_angleStart;_angleEnd;constructor(J){super({...J,isFilled:!1,isClosed:!1});let{center:Q,sweepFlag:Z,largeArcFlag:q,start:X,end:K}=J;if(X.equals(K))throw Error("Arc must have different start and end points.");this._angleStart=M.Angle(Q,X),this._angleEnd=M.Angle(Q,K),this._radius=M.Dist(Q,X),this._measure=Dj(this._angleStart,this._angleEnd,Z,q),this._start=X,this._end=K,this._sweepFlag=Z,this._largeArcFlag=q,this._center=Q}nearestPoint(J){let{_center:Q,_measure:Z,_radius:q,_angleEnd:X,_angleStart:K,_start:Y,_end:W}=this,z=eF(Z,K,X,Q.angle(J));if(z<=0)return Y;if(z>=1)return W;let G=J.x-Q.x,$=J.y-Q.y,H=Math.sqrt(G*G+$*$);if(H===0)return Y;let _=q/H;return new M(Q.x+G*_,Q.y+$*_)}hitTestLineSegment(J,Q){let{_center:Z,_radius:q,_measure:X,_angleStart:K,_angleEnd:Y}=this,W=fJ(J,Q,Z,q);if(W===null)return!1;return W.some((z)=>{let G=eF(X,K,Y,Z.angle(z));return G>=0&&G<=1})}getVertices(){let{_center:J,_measure:Q,length:Z,_radius:q,_angleStart:X}=this,K=[];for(let Y=0,W=pJ(Math.abs(Z));Y<W+1;Y++){let z=Y/W*Q,G=X+z;K.push(V3(J,q,G))}return K}getSvgPathData(J=!0){let{_start:Q,_end:Z,_radius:q,_largeArcFlag:X,_sweepFlag:K}=this;return`${J?`M${Q.toFixed()}`:""} A${q} ${q} 0 ${X} ${K} ${Z.toFixed()}`}getLength(){return Math.abs(this._measure*this._radius)}}class r7 extends n6{constructor(J){super({isClosed:!0,...J});this.config=J;let{x:Q=0,y:Z=0,radius:q}=J;this._x=Q,this._y=Z,this._center=new M(q+Q,q+Z),this._radius=q}config;_center;_radius;_x;_y;getBounds(){return new d(this._x,this._y,this._radius*2,this._radius*2)}getVertices(){let{_center:J,_radius:Q}=this,Z=N1*Q,q=[];for(let X=0,K=pJ(Z);X<K;X++){let Y=X/K*N1;q.push(V3(J,Q,Y))}return q}nearestPoint(J){let{_center:Q,_radius:Z}=this,q=J.x-Q.x,X=J.y-Q.y,K=Math.sqrt(q*q+X*X);if(K===0)return new M(Q.x+Z,Q.y);let Y=Z/K;return new M(Q.x+q*Y,Q.y+X*Y)}distanceToPoint(J,Q=!1){let{_center:Z,_radius:q}=this,X=J.x-Z.x,K=J.y-Z.y,W=Math.sqrt(X*X+K*K)-q;if(W<0&&(this.isFilled||Q))return W;return Math.abs(W)}hitTestPoint(J,Q=0,Z=!1){let{_center:q,_radius:X}=this,K=J.x-q.x,Y=J.y-q.y,W=K*K+Y*Y;if((this.isFilled||Z)&&W<=X*X)return!0;let z=X+Q;if(W>z*z)return!1;let G=X-Q;if(G<=0)return!0;return W>=G*G}hitTestLineSegment(J,Q,Z=0){let{_center:q,_radius:X}=this;return fJ(J,Q,q,X+Z)!==null}getSvgPathData(){let{_center:J,_radius:Q}=this;return`M${J.x+Q},${J.y} a${Q},${Q} 0 1,0 ${Q*2},0a${Q},${Q} 0 1,0 -${Q*2},0`}}class $Y extends J7{_a;_b;_c;_d;_resolution;constructor(J){let{start:Q,cp1:Z,cp2:q,end:X}=J;super({...J,points:[Q,X]});this._a=Q,this._b=Z,this._c=q,this._d=X,this._resolution=J.resolution??10}getVertices(){let J=[],{_a:Q,_b:Z,_c:q,_d:X}=this;for(let K=0,Y=this._resolution;K<=Y;K++){let W=K/Y;J.push(new M((1-W)*(1-W)*(1-W)*Q.x+3*((1-W)*(1-W))*W*Z.x+3*(1-W)*(W*W)*q.x+W*W*W*X.x,(1-W)*(1-W)*(1-W)*Q.y+3*((1-W)*(1-W))*W*Z.y+3*(1-W)*(W*W)*q.y+W*W*W*X.y))}return J}nearestPoint(J){let Q,Z=1/0,q,X;for(let K of this.segments)if(X=K.nearestPoint(J),q=M.Dist2(X,J),q<Z)Q=X,Z=q;if(!Q)throw Error("nearest point not found");return Q}distanceToPoint(J,Q=!1){let{segments:Z}=this,q=1/0;for(let X=0;X<Z.length;X++){let K=Z[X].distanceToPoint(J);if(K<q)q=K}return q}getSvgPathData(J=!0){let{_a:Q,_b:Z,_c:q,_d:X}=this;return`${J?`M ${Q.toFixed()} `:""} C${Z.toFixed()} ${q.toFixed()} ${X.toFixed()}`}static GetAtT(J,Q){let{_a:Z,_b:q,_c:X,_d:K}=J;return new M((1-Q)*(1-Q)*(1-Q)*Z.x+3*((1-Q)*(1-Q))*Q*q.x+3*(1-Q)*(Q*Q)*X.x+Q*Q*Q*K.x,(1-Q)*(1-Q)*(1-Q)*Z.y+3*((1-Q)*(1-Q))*Q*q.y+3*(1-Q)*(Q*Q)*X.y+Q*Q*Q*K.y)}getLength(J,Q=32){let Z,q=this._a,X=0;for(let K=1;K<=Q;K++)Z=$Y.GetAtT(this,K/Q),X+=M.Dist(q,Z),q=Z;return X}}class _Y extends n6{constructor(J){super({...J,isClosed:!0});this.config=J;let{width:Q,height:Z}=J;this._w=Q,this._h=Z}config;_w;_h;_edges;get edges(){if(!this._edges){let{vertices:J}=this;this._edges=[];for(let Q=0,Z=J.length;Q<Z;Q++){let q=J[Q],X=J[(Q+1)%Z];this._edges.push(new d8({start:q,end:X}))}}return this._edges}getVertices(){let J=Math.max(1,this._w),Q=Math.max(1,this._h),Z=J/2,q=Q/2,X=Math.pow(Z-q,2)/Math.pow(Z+q,2),K=B1*(Z+q)*(1+3*X/(10+Math.sqrt(4-3*X))),Y=pJ(K),W=N1/Y,z=Math.cos(W),G=Math.sin(W),$=0,H=1,_=0,F=1,U=Array(Y);for(let V=0;V<Y;V++)U[V]=new M(M0(Z+Z*H,0,J),M0(q+q*$,0,Q)),_=G*H+z*$,F=z*H-G*$,$=_,H=F;return U}nearestPoint(J){let Q,Z=1/0,q,X;for(let K of this.edges)if(X=K.nearestPoint(J),q=M.Dist2(X,J),q<Z)Q=X,Z=q;if(!Q)throw Error("nearest point not found");return Q}distanceToPoint(J,Q=!1){let{edges:Z}=this,q=1/0;for(let X=0;X<Z.length;X++){let K=Z[X].distanceToPoint(J);if(K<q)q=K}if(this.isClosed&&(this.isFilled||Q)&&n1(J,this.vertices))return-q;return q}hitTestLineSegment(J,Q){return this.edges.some((Z)=>Z.hitTestLineSegment(J,Q))}getBounds(){return new d(0,0,this._w,this._h)}getLength(){let{_w:J,_h:Q}=this,Z=J/2,q=Q/2,X=Math.max(0,Z),K=Math.max(0,q);return Nj(X,K)}getSvgPathData(J=!1){let{_w:Q,_h:Z}=this,q=Q/2,X=Z/2,K=Math.max(0,q),Y=Math.max(0,X);return`${J?`M${q-K},${X}`:""} a${K},${Y},0,1,1,${K*2},0a${K},${Y},0,1,1,-${K*2},0`}}var i4=E(c(),1);var nh=E(c1(),1),Y4=E(m(),1);var Sh=E(m(),1);function fh(){let J=v(),Q=Q1(),Z=z6(),q=g(V1.forceSrgb);Sh.default.useEffect(()=>{if(Z==="dark")Q.setAttribute("data-color-mode","dark"),Q.classList.remove("tl-theme__light"),Q.classList.add("tl-theme__dark");else Q.setAttribute("data-color-mode","light"),Q.classList.remove("tl-theme__dark"),Q.classList.add("tl-theme__light");if(q)Q.classList.add("tl-theme__force-sRGB");else Q.classList.remove("tl-theme__force-sRGB")},[J,Q,q,Z])}var mU=E(m(),1);function gh(){let[J,Q]=mU.useState(0);mU.useEffect(()=>Q((Z)=>Z+1),[])}var hh=E(m(),1);function uh(){let J=v();hh.useLayoutEffect(()=>{return P1("stateAttribute",()=>{let Q=J.getContainer(),Z=J.getInstanceState();Q.setAttribute("data-state",J.getPath()),Q.setAttribute("data-coarse",String(Z.isCoarsePointer))})},[J])}var mh=E(m(),1);function ch(){let J=v(),Q=Q1();mh.useEffect(()=>{let Z=(K)=>Q.style.setProperty("--tl-zoom",K.toString()),q=jJ(Z,100),X=new B9("useZoomCss",()=>Z(J.getEfficientZoomLevel()));return X.attach(),X.execute(),()=>{X.detach(),q.cancel()}},[J,Q])}var x9=E(c(),1);var wZ=E(m(),1);var lh='<svg xmlns="http://www.w3.org/2000/svg" width="3001" height="1000" fill="none"><path fill="#000" d="M590.656 300.449c0 49.706-40.294 90-90 90-49.705 0-90-40.294-90-90 0-49.705 40.295-90 90-90 49.706 0 90 40.295 90 90M569.431 719.011c-15.247 32.821-56.006 91.589-98.338 91.438-32.004-.115-38.642-30.904-17.414-50.856 17.381-16.337 28.246-48.075 31.995-72.719.415-2.728-1.556-5.197-4.272-5.679-39.666-7.04-70.746-40.877-70.746-83.417 0-48.23 38.983-87.329 87.07-87.329 39.936 0 70.172 22.237 83.369 52.397 18.839 43.055 7.117 115.733-11.664 156.165M2613.29 385.681V239.319c0-11.363 9.22-20.569 20.59-20.569h8.26c11.37 0 20.59 9.206 20.59 20.569v36.911c0 8.629 7 15.625 15.63 15.625h35.25c8.63 0 15.63-6.996 15.63-15.625v-36.911c0-11.363 9.22-20.569 20.59-20.569h8.17c11.37 0 20.59 9.206 20.59 20.569v146.362c0 11.363-9.22 20.569-20.59 20.569h-8.17c-11.37 0-20.59-9.206-20.59-20.569v-36.999c0-8.63-7-15.625-15.63-15.625h-35.25c-8.63 0-15.63 6.995-15.63 15.625v36.999c0 11.363-9.22 20.569-20.59 20.569h-8.26c-11.37 0-20.59-9.206-20.59-20.569M2391.97 239.319v146.362c0 11.348-9.16 20.569-20.49 20.569h-8.2c-11.33 0-20.49-9.221-20.49-20.569V239.319c0-11.348 9.16-20.569 20.49-20.569h8.2c11.33 0 20.49 9.221 20.49 20.569M2098.23 391.43l-42.69-146.361c-3.85-13.171 6.06-26.319 19.79-26.319h10.6c9.59 0 17.93 6.611 20.08 15.952l17.01 73.045c1.48 6.348 10.47 6.478 12.14.176l19.47-73.838c2.38-9.04 10.57-15.335 19.93-15.335h12.1c9.37 0 17.56 6.3 19.94 15.346l19.49 74.067c1.66 6.305 10.65 6.178 12.13-.171l17.09-73.294c2.15-9.339 10.49-15.948 20.08-15.948h10.53c13.72 0 23.63 13.141 19.79 26.31l-42.63 146.361c-2.56 8.789-10.63 14.829-19.79 14.829h-15.68c-9.12 0-17.16-5.98-19.76-14.709l-21.17-71.059c-1.77-5.948-10.19-5.957-11.97-.012l-21.33 71.071c-2.6 8.729-10.64 14.709-19.76 14.709h-15.59c-9.17 0-17.23-6.035-19.8-14.82M2443.23 218.75h118.59c11.38 0 20.62 9.195 20.62 20.557s-9.24 20.556-20.62 20.556h-24.79c-5.53 0-10 4.477-10 10v115.818c0 11.368-9.25 20.569-20.63 20.569h-7.65c-11.39 0-20.63-9.201-20.63-20.569V269.863c0-5.523-4.48-10-10-10h-24.89c-11.37 0-20.61-9.195-20.61-20.556s9.24-20.557 20.61-20.557M1174.15 218.75h24.64c8.35 0 15.88 5.042 19.04 12.764l34.61 83.942c2.13 5.161 9.44 5.155 11.56-.01l34.43-83.932a20.58 20.58 0 0 1 19.04-12.764h24.64c11.37 0 20.58 9.208 20.58 20.569v146.362c0 11.361-9.21 20.569-20.58 20.569h-7.09c-11.36 0-20.58-9.208-20.58-20.569l-.12-50.645c-.01-6.888-9.53-8.688-12.06-2.283l-23.46 59.332a20.57 20.57 0 0 1-19.14 13.009h-3.03a20.57 20.57 0 0 1-19.15-13.046l-23.47-59.68c-2.52-6.416-12.05-4.623-12.06 2.271l-.13 51.042c0 11.361-9.21 20.569-20.57 20.569h-7.1c-11.36 0-20.57-9.208-20.57-20.569V239.319c0-11.361 9.21-20.569 20.57-20.569"/><path fill="#000" fill-rule="evenodd" d="m1449.94 391.836 6.12-19.392a6.255 6.255 0 0 1 5.96-4.369l50.22-.061a6.24 6.24 0 0 1 5.96 4.348l6.23 19.486c2.71 8.581 10.71 14.402 19.74 14.402h9.34c14.13 0 24.15-13.791 19.61-27.151l-49.74-146.361c-2.85-8.37-10.74-13.988-19.61-13.988h-33.16c-8.87 0-16.77 5.618-19.61 13.988l-49.74 146.361c-4.54 13.36 5.48 27.151 19.61 27.151h9.32c9.04 0 17.04-5.827 19.75-14.414m31.1-98.858c1.85-5.807 10.08-5.796 11.91.016l8.83 27.916c1.28 4.028-1.73 8.134-5.96 8.134h-17.74c-4.23 0-7.24-4.119-5.95-8.151zM1681.81 406.25c18.91 0 35.39-3.686 49.36-11.168 13.97-7.544 24.73-18.394 32.24-32.489 7.56-14.105 11.29-30.866 11.29-50.182 0-19.256-3.73-35.957-11.29-50.004-7.57-14.094-18.35-24.912-32.32-32.397-13.91-7.545-30.4-11.26-49.37-11.26h-49.5c-11.38 0-20.63 9.201-20.63 20.569v146.362c0 11.368 9.25 20.569 20.63 20.569zm23.13-47.701c-6.62 3.215-14.85 4.886-24.79 4.886-10.49 0-19-8.507-19-19v-64.34c0-10.149 8.23-18.376 18.38-18.376 10.18 0 18.56 1.703 25.23 4.974 6.59 3.149 11.63 8.315 15.08 15.633 3.45 7.269 5.28 17.268 5.28 30.162 0 12.891-1.82 22.951-5.28 30.347-3.39 7.319-8.36 12.509-14.9 15.714" clip-rule="evenodd"/><path fill="#000" d="M1804.21 385.681V239.319c0-11.361 9.21-20.569 20.58-20.569h91.28c11.36 0 20.57 9.202 20.57 20.557s-9.21 20.556-20.57 20.556h-54.64a7.807 7.807 0 0 0-7.81 7.813v16.366a7.806 7.806 0 0 0 7.81 7.812h48.13c11.37 0 20.58 9.246 20.58 20.602s-9.21 20.601-20.58 20.601h-48.13a7.806 7.806 0 0 0-7.81 7.812v16.455a7.807 7.807 0 0 0 7.81 7.813h54.64c11.36 0 20.57 9.202 20.57 20.556s-9.21 20.557-20.57 20.557h-91.28c-11.37 0-20.58-9.208-20.58-20.569"/><path fill="#000" fill-rule="evenodd" d="M2875.5 68.75h-2750c-31.066 0-56.25 25.184-56.25 56.25v750c0 31.066 25.184 56.25 56.25 56.25h2750c31.07 0 56.25-25.184 56.25-56.25V125c0-31.066-25.18-56.25-56.25-56.25M125.5 0C56.464 0 .5 55.964.5 125v750c0 69.036 55.965 125 125 125h2750c69.04 0 125-55.964 125-125V125c0-69.036-55.96-125-125-125z" clip-rule="evenodd"/><path fill="#000" d="M2476.06 804.813c-10.54 0-19.82-6.947-22.81-17.068L2390.79 575.7c-4.49-15.248 6.92-30.534 22.8-30.534h27.75c11.1 0 20.72 7.686 23.18 18.52L2489 671.402c2.07 9.093 14.93 9.321 17.32.308l28.83-108.844c2.76-10.435 12.19-17.7 22.98-17.7h25.17c10.8 0 20.25 7.293 22.99 17.755l28.27 107.739c2.36 9.001 15.18 8.829 17.3-.232l25.01-106.888c2.51-10.763 12.1-18.374 23.14-18.374h27.87c15.88 0 27.29 15.286 22.8 30.534l-62.46 212.045a23.78 23.78 0 0 1-22.81 17.068h-32.12c-10.39 0-19.58-6.763-22.69-16.696l-32.08-102.694c-2.62-8.397-14.51-8.331-17.04.095l-30.74 102.346c-3.02 10.061-12.27 16.949-22.76 16.949zM1742.44 804.813h-75.81c-13.09 0-23.71-10.656-23.71-23.801V568.967c0-13.145 10.62-23.801 23.71-23.801h74.8c26.6 0 49.59 5.198 68.95 15.594 19.45 10.312 34.44 25.187 44.96 44.627 10.61 19.355 15.91 42.556 15.91 69.602q0 40.57-15.78 69.73c-10.53 19.355-25.43 34.231-44.71 44.627-19.28 10.311-42.05 15.467-68.32 15.467m-29.3-83.642c0 13.145 10.61 23.801 23.71 23.801h3.06c12.8 0 23.7-2.07 32.71-6.212 9.09-4.141 16-11.283 20.71-21.426q7.2-15.213 7.2-42.345 0-27.13-7.32-42.344c-4.8-10.143-11.87-17.285-21.22-21.426-9.26-4.142-20.63-6.212-34.1-6.212h-1.04c-13.1 0-23.71 10.656-23.71 23.801zM1460.86 804.813c-13.12 0-23.76-10.656-23.76-23.801V568.967c0-13.145 10.64-23.801 23.76-23.801h22.84c13.13 0 23.76 10.656 23.76 23.801v155.247c0 13.145 10.64 23.801 23.76 23.801h57.27c13.12 0 23.76 10.656 23.76 23.801v9.196c0 13.145-10.64 23.801-23.76 23.801zM1204.45 601.964c-13.13 0-23.77-10.656-23.77-23.801v-9.196c0-13.145 10.64-23.801 23.77-23.801h177.89c13.13 0 23.78 10.656 23.78 23.801v9.196c0 13.145-10.65 23.801-23.78 23.801h-39.38c-8.21 0-14.86 6.66-14.86 14.875v164.173c0 13.145-10.64 23.801-23.78 23.801h-21.85c-13.13 0-23.78-10.656-23.78-23.801V616.839c0-8.215-6.65-14.875-14.86-14.875z"/><path fill="#000" fill-rule="evenodd" d="M2223.05 787.891c-3.02 10.047-12.27 16.922-22.74 16.922h-25.43c-16.19 0-27.64-15.862-22.57-31.261l69.88-212.045c3.21-9.753 12.31-16.341 22.56-16.341h61.84c10.25 0 19.35 6.588 22.56 16.341l69.87 212.045c5.08 15.399-6.37 31.261-22.56 31.261h-25.43c-10.48 0-19.72-6.875-22.74-16.922l-6.7-22.2a14.84 14.84 0 0 0-14.21-10.576h-63.42c-6.55 0-12.32 4.296-14.22 10.576zm76.13-96.945-14.13-48.436c-2.46-8.451-14.36-8.602-17.04-.217l-15.46 48.436c-1.84 5.759 2.45 11.645 8.48 11.645h29.6c5.94 0 10.22-5.715 8.55-11.428" clip-rule="evenodd"/><path fill="#000" d="M1939.6 804.813c-13.13 0-23.77-10.656-23.77-23.801V568.967c0-13.145 10.64-23.801 23.77-23.801h88.13c19.24 0 36.08 3.508 50.51 10.523s25.65 17.115 33.67 30.3q12.03 19.779 12.03 47.416c0 18.595-4.14 34.273-12.41 47.036-7.64 11.913-18.18 21.101-31.63 27.564-16.98 8.159-36 11.104-54.7 11.104h-43.07c-76.56 0 4.08-135.84 4.08-84.706v7.996c0 12.117 9.81 21.941 21.91 21.941 8.12 0 16.3-.345 24.04-3.043 5.91-2.113 10.43-5.451 13.55-10.015 3.2-4.565 4.81-10.523 4.81-17.877 0-7.437-1.61-13.481-4.81-18.129-3.12-4.733-7.64-8.199-13.55-10.396-7.05-2.766-14.67-3.423-22.18-3.423-13.13 0-23.77 10.656-23.77 23.801v47.71c0 11.825 11.14 16.003 19.91 20.752 12.31 6.671 7.58 25.389-6.42 25.389-7.45 0-13.49 6.048-13.49 13.508v48.395c0 13.145-10.63 23.801-23.76 23.801zm134.89-106.758 5.41 9.95 33.51 61.622c8.62 15.86-2.84 35.186-20.87 35.186h-22.27c-8.74 0-16.77-4.798-20.92-12.496l-35.05-65.04a15.52 15.52 0 0 0-13.66-8.168c-42.24 0 40.62-82.154 73.85-21.054M931.652 0h68.748v1000h-68.748z"/></svg>',ph='<svg xmlns="http://www.w3.org/2000/svg" width="400" height="1601" fill="none"><path fill="#000" d="M72 1319.8c0-10.73 7.071-20.18 17.372-23.22l215.823-63.62c15.519-4.57 31.078 7.05 31.078 23.22v28.26c0 11.31-7.824 21.1-18.85 23.61l-109.636 24.94c-9.254 2.1-9.487 15.2-.313 17.63l110.784 29.37a24.21 24.21 0 0 1 18.015 23.4v25.64c0 11-7.423 20.62-18.071 23.41l-109.659 28.79c-9.162 2.41-8.986 15.47.236 17.63l108.792 25.46c10.955 2.56 18.702 12.33 18.702 23.57v28.39c0 16.17-15.559 27.79-31.078 23.22l-215.823-63.62c-10.3-3.04-17.372-12.49-17.372-23.22v-32.72c0-10.59 6.883-19.95 16.994-23.11l104.523-32.67c8.547-2.67 8.479-14.79-.096-17.36l-104.17-31.3C79.01 1372.42 72 1363 72 1352.31zM72 572.638V495.43c0-13.336 10.846-24.147 24.225-24.147h215.823c13.379 0 24.225 10.811 24.225 24.147v76.179q0 40.645-15.872 70.228-15.743 29.712-45.422 45.79-29.55 16.206-70.843 16.206-41.292 0-70.971-16.078-29.55-16.077-45.422-45.532Q72 612.767 72 572.638m85.132-29.84c-13.379 0-24.225 10.81-24.225 24.146v3.122q0 19.55 6.323 33.313 6.323 13.89 21.807 21.094 15.485 7.332 43.099 7.331t43.1-7.46q15.484-7.33 21.807-21.608 6.323-14.15 6.323-34.728v-1.064c0-13.336-10.846-24.146-24.225-24.146zM72 285.858c0-13.363 10.846-24.197 24.225-24.197h215.823c13.379 0 24.225 10.834 24.225 24.197v23.27c0 13.364-10.846 24.197-24.225 24.197H154.035c-13.379 0-24.225 10.834-24.225 24.197v58.328c0 13.364-10.846 24.197-24.225 24.197h-9.36C82.845 440.047 72 429.214 72 415.85zM278.463 24.72c0-13.374 10.846-24.216 24.225-24.216h9.36c13.379 0 24.225 10.842 24.225 24.216v181.174c0 13.374-10.846 24.216-24.225 24.216h-9.36c-13.379 0-24.225-10.842-24.225-24.216v-40.108c0-8.359-6.779-15.135-15.141-15.135H96.225c-13.38 0-24.225-10.842-24.225-24.216v-22.256c0-13.374 10.846-24.216 24.225-24.216h167.097c8.362 0 15.141-6.776 15.141-15.135z"/><path fill="#000" fill-rule="evenodd" d="M89.224 1062.13C78.997 1059.04 72 1049.63 72 1038.96v-25.9c0-16.486 16.145-28.147 31.818-22.979l215.823 71.169a24.19 24.19 0 0 1 16.632 22.98v62.97c0 10.45-6.706 19.71-16.632 22.98l-215.823 71.17C88.145 1246.51 72 1234.86 72 1218.37v-25.9c0-10.67 6.997-20.08 17.224-23.17l22.595-6.81a15.13 15.13 0 0 0 10.765-14.48v-64.59a15.13 15.13 0 0 0-10.765-14.48zm98.672 77.53 49.299-14.39c8.601-2.51 8.755-14.62.22-17.35l-49.299-15.75c-5.861-1.88-11.852 2.49-11.852 8.64v30.14c0 6.05 5.817 10.41 11.632 8.71" clip-rule="evenodd"/><path fill="#000" d="M72 773.439c0-13.367 10.846-24.203 24.225-24.203h215.823c13.379 0 24.225 10.836 24.225 24.203v89.762q0 29.395-10.711 51.439-10.71 22.046-30.84 34.293t-48.261 12.248q-28.388 0-47.873-12.635-18.187-11.672-28.056-32.218c-8.303-17.289-11.301-36.661-11.301-55.705v-43.867c0-77.976 138.26 4.16 86.215 4.16h-8.138c-12.334 0-22.332 9.989-22.332 22.311 0 8.269.351 16.6 3.097 24.487q3.225 9.024 10.194 13.794 6.968 4.899 18.194 4.899 11.356 0 18.453-4.899 7.226-4.77 10.581-13.794c2.815-7.188 3.484-14.944 3.484-22.596 0-13.366-10.846-24.202-24.225-24.202h-48.56c-12.036 0-16.288 11.345-21.122 20.272-6.79 12.539-25.841 7.72-25.841-6.536 0-7.586-6.156-13.736-13.749-13.736H96.225C82.845 820.916 72 810.08 72 796.714zm108.66 137.378-10.128 5.511-62.72 34.131C91.67 959.243 72 947.569 72 929.205V906.52a24.2 24.2 0 0 1 12.719-21.299l66.199-35.696a15.82 15.82 0 0 0 8.313-13.921c0-43.012 83.618 41.371 21.429 75.213"/></svg>';function dh(J){return g("watermarkState",()=>J.state.get(),[J])}var UZ0=`data:image/svg+xml;utf8,${encodeURIComponent(lh)}`,VZ0=`data:image/svg+xml;utf8,${encodeURIComponent(ph)}`,ih=wZ.memo(function(){let Q=yh(),Z=v(),q=g("is mobile",()=>Z.getViewportScreenBounds().width<700,[Z]),X=dh(Q);if(!["licensed-with-watermark","unlicensed"].includes(X))return null;return x9.jsxs(x9.Fragment,{children:[x9.jsx(LZ0,{}),x9.jsx(BZ0,{src:q?VZ0:UZ0,isUnlicensed:X==="unlicensed"})]})}),NZ0=wZ.memo(function({isDebugMode:Q,isMobile:Z}){let q=v(),X=_3(),K=wZ.useRef(null);r6(K);let Y="https://tldraw.dev/pricing?utm_source=sdk&utm_medium=organic&utm_campaign=watermark";return x9.jsx("div",{ref:K,className:IZ.className,"data-debug":Q,"data-mobile":Z,"data-unlicensed":!0,"data-testid":"tl-watermark-unlicensed",draggable:!1,...X,children:x9.jsx("button",{draggable:!1,role:"button",onPointerDown:(W)=>{q.markEventAsHandled(W),W0(W)},title:"The tldraw SDK requires a license key to work in production. You can get a free 100-day trial license at tldraw.dev/pricing.",onClick:()=>{M3.openWindow(Y,"_blank",!0)},children:"Get a license for production"})})}),BZ0=wZ.memo(function({src:Q,isUnlicensed:Z}){let q=v(),X=g("debug mode",()=>q.getInstanceState().isDebugMode,[q]),K=g("is mobile",()=>q.getViewportScreenBounds().width<700,[q]),Y=_3(),W=wZ.useRef(null);r6(W);let z=`url('${Q}') center 100% / 100% no-repeat`,G="https://tldraw.dev/?utm_source=sdk&utm_medium=organic&utm_campaign=watermark";if(Z)return x9.jsx(NZ0,{isDebugMode:X,isMobile:K});return x9.jsx("div",{ref:W,className:IZ.className,"data-debug":X,"data-mobile":K,"data-testid":"tl-watermark-licensed",draggable:!1,...Y,children:x9.jsx("button",{draggable:!1,role:"button",onPointerDown:($)=>{q.markEventAsHandled($),W0($)},title:"Build infinite canvas applications with the tldraw SDK. Learn more at https://tldraw.dev.",onClick:()=>{M3.openWindow(G,"_blank")},style:{mask:z,WebkitMask:z}})})}),LZ0=wZ.memo(function(){let Q=v(),Z=IZ.className,q=`
96
96
  /* ------------------- SEE LICENSE -------------------
97
97
  The tldraw watermark is part of tldraw's license. It is shown for unlicensed
98
98
  or "licensed-with-watermark" users. By using this library, you agree to
@@ -373,7 +373,7 @@ ${Z}
373
373
  `).map((Q)=>Q||" ").join(`
374
374
  `)}}var Sz0=/[\u0590-\u05FF\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]/;function vN(J){return Sz0.test(J)}function fz0(J){return J.replace(/\t/g,Cd)}function gz0(J){let Q=J.split(`
375
375
  `);while(Q[0]&&Q[0].trim().length===0)Q.shift();let Z=1/0;for(let q of Q)if(q.trim().length>0){let X=q.length-q.trimStart().length;Z=Math.min(Z,X)}return Q.map((q)=>q.slice(Z)).join(`
376
- `)}var Pd={"&amp;":"&","&quot;":'"',"&apos;":"'","&#27;":"'","&#34;":'"',"&#38;":"&","&#39;":"'","&#8211;":"–","&#8212;":"—","&#8216;":"‘","&#8217;":"’","&#8220;":"“","&#8221;":"”","&#8230;":"…"},hz0=new RegExp(Object.keys(Pd).join("|"),"g");function IA(J){return J.replace(hz0,(Q)=>Pd[Q])}function uz0(J){return J.replace(/[ \t]+$/gm,"").replace(/\n+$/,"")}function Id(J){return uz0(gz0(fz0(J)))}var wA=5000,bd=10485760;function bA(J,Q){J.registerExternalAssetHandler("file",async(Z)=>{return Td(J,Z,Q)}),J.registerExternalAssetHandler("url",async(Z)=>{return xd(J,Z,Q)}),J.registerExternalContentHandler("svg-text",async(Z)=>{return vd(J,Z)}),J.registerExternalContentHandler("embed",(Z)=>{return Sd(J,Z)}),J.registerExternalContentHandler("files",async(Z)=>{return fd(J,Z,Q)}),J.registerExternalContentHandler("file-replace",async(Z)=>{return yd(J,Z,Q)}),J.registerExternalContentHandler("text",async(Z)=>{return hY(J,Z)}),J.registerExternalContentHandler("url",async(Z)=>{return gd(J,Z,Q)}),J.registerExternalContentHandler("tldraw",async(Z)=>{return hd(J,Z)}),J.registerExternalContentHandler("excalidraw",async(Z)=>{return ud(J,Z)})}async function Td(J,{file:Q,assetId:Z},q){if(!SN(J,Q,q))Q0(!1,"File checks failed");let K=await yA(Q);if(!K)Q0(!1,"SVG file contained no safe content");let Y=await fN(J,K,Z);if(!Y)Q0(!1,`No asset util found for MIME type "${Q.type}"`);let W=await J.uploadAsset(Y,K);if(Y.props.src=W.src,W.meta)Y.meta={...Y.meta,...W.meta};return k9.create(Y)}async function yd(J,{file:Q,shapeId:Z},q){if(!SN(J,Q,q))Q0(!1,"File checks failed");let K=await yA(Q);if(!K)return;let Y=J.getShape(Z);if(!Y)Q0(!1,"Shape not found");let W=FF(await K.arrayBuffer()),z=k9.createId(W);J.createTemporaryAssetPreview(z,K);let G=await fN(J,K,z);if(!G)return;if(J.createAssets([G]),Y.type==="image"){let H=Y,_=H.props.crop,F=G.props.w,U=G.props.h,V=H.x,B=H.y,N=_;if(_){let L=cl(H,G.props.w,G.props.h);N=L.crop,F=L.w,U=L.h,V=L.x,B=L.y}J.updateShapes([{id:H.id,type:H.type,props:{assetId:z,crop:N,w:F,h:U},x:V,y:B}])}else if(Y.type==="video")J.updateShapes([{id:Y.id,type:Y.type,props:{assetId:z,w:G.props.w,h:G.props.h}}]);let $=await J.getAssetForExternalContent({type:"file",file:K,assetId:z});return J.updateAssets([{...$,id:z}]),$}async function xd(J,{url:Q},{toasts:Z,msg:q}){let X;try{let Y=await(await b6(Q,{method:"GET",mode:"no-cors"})).text(),W=new DOMParser().parseFromString(Y,"text/html");if(X={image:W.head.querySelector('meta[property="og:image"]')?.getAttribute("content")??"",favicon:W.head.querySelector('link[rel="apple-touch-icon"]')?.getAttribute("href")??W.head.querySelector('link[rel="icon"]')?.getAttribute("href")??"",title:W.head.querySelector('meta[property="og:title"]')?.getAttribute("content")??Q,description:W.head.querySelector('meta[property="og:description"]')?.getAttribute("content")??""},!X.image.startsWith("http"))X.image=new URL(X.image,Q).href;if(!X.favicon.startsWith("http"))X.favicon=new URL(X.favicon,Q).href}catch(K){console.error(K),Z.addToast({title:q("assets.url.failed"),severity:"error"}),X={image:"",favicon:"",title:"",description:""}}return{id:k9.createId(sq(Q)),typeName:"asset",type:"bookmark",props:{src:Q,description:X.description,image:X.image,favicon:X.favicon,title:X.title},meta:{}}}async function vd(J,{point:Q,text:Z}){let{sanitizeSvg:q}=await import("/chunk-h2kj1ysj.js");if(Z=q(Z),!Z)return;let X=Q??(J.inputs.getShiftKey()?J.inputs.getCurrentPagePoint():J.getViewportPageBounds().center),K=new DOMParser().parseFromString(Z,"image/svg+xml").querySelector("svg");if(!K)throw Error("No <svg/> element present");let Y=parseFloat(K.getAttribute("width")||"0"),W=parseFloat(K.getAttribute("height")||"0");if(!(Y&&W)){let G=J.getContainerDocument();G.body.appendChild(K);let $=K.getBoundingClientRect();G.body.removeChild(K),Y=$.width,W=$.height}let z=await J.getAssetForExternalContent({type:"file",file:new File([Z],"asset.svg",{type:"image/svg+xml"})});if(!z)throw Error("Could not create an asset");TA(J,[z],X)}function Sd(J,{point:Q,url:Z,embed:q}){let X=Q??(J.inputs.getShiftKey()?J.inputs.getCurrentPagePoint():J.getViewportPageBounds().center),{width:K,height:Y}=q,W=l0(),z=j6(new M(X.x-(K||450)/2,X.y-(Y||450)/2),J),G={id:W,type:"embed",x:z.x,y:z.y,props:{w:K,h:Y,url:Z}};if(J.canCreateShape(G))J.createShape(G).select(W)}async function fd(J,{point:Q,files:Z},q){let{toasts:X,msg:K}=q;if(Z.length>J.options.maxFilesAtOnce){X.addToast({title:K("assets.files.amount-too-many"),severity:"error"});return}let Y=Q??(J.inputs.getShiftKey()?J.inputs.getCurrentPagePoint():J.getViewportPageBounds().center),W=new M(Y.x,Y.y),z=[],G=[];for(let $ of Z){if(!SN(J,$,q))continue;let _=await yA($);if(!_){X.addToast({title:K("assets.files.upload-failed"),severity:"error"});continue}let F=await fN(J,_);if(!F)continue;if(F.type==="image")J.createTemporaryAssetPreview(F.id,_);z.push(F),G.push({asset:F,file:_})}Promise.allSettled(G.map(async($)=>{try{let H=await J.getAssetForExternalContent({type:"file",file:$.file});if(!H)throw Error("Could not create an asset");J.updateAssets([{...H,id:$.asset.id}])}catch(H){X.addToast({title:K("assets.files.upload-failed"),severity:"error"}),console.error(H),J.deleteAssets([$.asset.id]);return}})),TA(J,z,W)}async function hY(J,{point:Q,text:Z,html:q}){let X=Q??(J.inputs.getShiftKey()?J.inputs.getCurrentPagePoint():J.getViewportPageBounds().center),K=J.getShapeUtil("text").getDefaultProps(),Y=Id(Z),W=q?PA(J,q):x1(Y),z,G,$,H="middle",_=h9(J,W),F=W.content.length>1,U=vN(Y);if(F)H=F?U?"end":"start":"middle";let V=J.getCurrentTheme(),B=J.textMeasure.measureHtml(_,{...G5,lineHeight:V.lineHeight,fontFamily:g9(V,K.font),fontSize:V.fontSize*o3[K.size],maxWidth:null}),N=Math.min(F?J.getViewportPageBounds().width*0.9:920,Math.max(200,J.getViewportPageBounds().width*0.9));if(B.w>N){let O=J.textMeasure.measureHtml(_,{...G5,lineHeight:V.lineHeight,fontFamily:g9(V,K.font),fontSize:V.fontSize*o3[K.size],maxWidth:N});z=O.w,G=O.h,$=!1,H=U?"end":"start"}else z=Math.max(B.w,10),G=Math.max(B.h,10),$=!0;if(X.y-G/2<J.getViewportPageBounds().minY+40)X.y=J.getViewportPageBounds().minY+40+G/2;let L=j6(new M(X.x-z/2,X.y-G/2),J),D=l0();J.createShapes([{id:D,type:"text",x:L.x,y:L.y,props:{richText:W,textAlign:H,autoSize:$,w:z}}])}async function gd(J,{point:Q,url:Z},{toasts:q,msg:X}){let Y=J.getShapeUtil("embed")?.getEmbedDefinition(Z);if(Y&&Y.definition.embedOnPaste!==!1)return J.putExternalContent({type:"embed",url:Y.url,point:Q,embed:Y.definition});let W=Q??(J.inputs.getShiftKey()?J.inputs.getCurrentPagePoint():J.getViewportPageBounds().center);if(!(await cH(J,{url:Z,center:W})).ok){q.addToast({title:X("assets.url.failed"),severity:"error"});return}}async function hd(J,{point:Q,content:Z}){J.run(()=>{let q=J.getSelectionPageBounds();J.markHistoryStoppingPoint("paste");for(let Y of Z.shapes)if(Z.rootShapeIds.includes(Y.id))Y.isLocked=!1;let X=J.isInAny("select.dragging_handle","select.translating","select.resizing","select.rotating");J.putContentOntoCurrentPage(Z,{point:Q,select:!X});let K=J.getSelectionPageBounds();if(!X&&q&&K&&q?.collides(K))J.updateInstanceState({isChangingStyle:!0}),J.timers.setTimeout(()=>{J.updateInstanceState({isChangingStyle:!1})},150)})}async function ud(J,{point:Q,content:Z}){J.run(()=>{xE(J,Z,Q)})}async function TA(J,Q,Z){if(!Q.length)return[];let q=M.From(Z),X=[];for(let K=0;K<Q.length;K++){let Y=Q[K],z=J.getShapeUtilForAssetType(Y.type)?.createShapeForAsset?.(Y,q)??null;if(z){if(X.push(z),"w"in Y.props&&typeof Y.props.w==="number")q.x+=Y.props.w}}return J.run(()=>{let K=Q.filter((Y)=>!J.getAsset(Y.id));J.store.atomic(()=>{if(J.canCreateShapes(X)){if(K.length)J.createAssets(K);J.createShapes(X).select(...X.map((Y)=>Y.id)),md(J,Z)}})}),X.map((K)=>K.id)}function md(J,Q){let Z=J.getViewportPageBounds(),q=J.getSelectionPageBounds();if(q){let X=q.center.sub(Q);J.updateShapes(J.getSelectedShapes().map((K)=>{let Y=J.getShapeParentTransform(K).decompose().rotation,W=M.Rot(X,-Y);return{id:K.id,type:K.type,x:K.x-W.x,y:K.y-W.y}}))}if(q=J.getSelectionPageBounds(),q&&J.getInstanceState().isGridMode){let X=J.getDocumentSettings().gridSize,K=new M(q.minX,q.minY),Y=K.clone().snapToGrid(X),W=M.Sub(K,Y);J.updateShapes(J.getSelectedShapes().map((z)=>{let G={x:z.x-W.x,y:z.y-W.y};return{id:z.id,type:z.type,x:G.x,y:G.y}}))}if(q=J.getSelectionPageBounds(),q&&!Z.contains(q))J.zoomToSelection({animation:{duration:J.options.animationMediumMs}})}async function yA(J){if(J.type!=="image/svg+xml")return J;try{let Q=await J.text(),{sanitizeSvg:Z}=await import("/chunk-h2kj1ysj.js"),q=Z(Q);if(!q)return null;return new File([q],J.name,{type:J.type,lastModified:J.lastModified})}catch{return null}}function SN(J,Q,Z){let{maxAssetSize:q=bd,acceptedImageMimeTypes:X,acceptedVideoMimeTypes:K,toasts:Y,msg:W}=Z;if(!(!!J.getAssetUtilForMimeType(Q.type)||(X?.includes(Q.type)??!1)||(K?.includes(Q.type)??!1)))return Y.addToast({title:W("assets.files.type-not-allowed"),severity:"error"}),!1;if(Q.size>q){let G=($)=>{if($===0)return"0 bytes";let H=["bytes","KB","MB","GB","TB","PB"],_=1024,F=Math.floor(Math.log($)/Math.log(_)),U=$/Math.pow(_,F);return`${U%1===0?U.toString():U.toFixed(1)} ${H[F]}`};return Y.addToast({title:W("assets.files.size-too-big"),description:W("assets.files.maximum-size").replace("{size}",G(q)),severity:"error"}),!1}if(!Q.type)return Y.addToast({title:W("assets.files.upload-failed"),severity:"error"}),console.error("No mime type"),!1;return!0}async function fN(J,Q,Z){if(!Z){let X=FF(await Q.arrayBuffer());Z=k9.createId(X)}let q=J.getAssetUtilForMimeType(Q.type);if(!q)return null;return await q.getAssetFromFile(Q,Z)}async function xA(J,Q,Z){let q=Z.name;if(!q){if(q=`shapes at ${cd()}`,Q.length===1){let Y=J.getShape(Q[0]);if(J.isShapeOfType(Y,"frame"))q=Y.props.name||"frame";else q=`${dK(Y.id)} at ${cd()}`}}q+=`.${Z.format}`;let{blob:X}=await J.toImage(Q,Z),K=new File([X],q,{type:X.type});gN(K,J.getContainerDocument())}function cd(){let J=new Date,Q=String(J.getFullYear()).slice(2),Z=String(J.getMonth()+1).padStart(2,"0"),q=String(J.getDate()).padStart(2,"0"),X=String(J.getHours()).padStart(2,"0"),K=String(J.getMinutes()).padStart(2,"0"),Y=String(J.getSeconds()).padStart(2,"0");return`${Q}-${Z}-${q} ${X}.${K}.${Y}`}function gN(J,Q){let Z=(Q??_4()).createElement("a"),q=URL.createObjectURL(J);Z.href=q,Z.download=J.name,Z.click(),URL.revokeObjectURL(q)}function hN(J,Q){let Z=D0(Q.map((X)=>J.getShape(X)).filter((X)=>X&&J.isShapeFrameLike(X)));if(!Z.length)return;let q=[];J.run(()=>{Z.map((X)=>{let K=J.getSortedChildIdsForParent(X.id);if(K.length)z1(J,K,{filter:(Y)=>!Z.find((W)=>W.id===Y.id)}),q.push(...K)}),J.setSelectedShapes(q),J.deleteShapes(Q)})}var ld=50;function vA(J,Q,Z={padding:ld}){let q=d.FromPoints(J.flatMap((G)=>{if(!G)return[];let $=Q.getShapeGeometry(G.id);return Q.getShapeLocalTransform(G)?.applyToPoints($.vertices)??[]})),X=Z.padding??ld,K=q.w+2*X,Y=q.h+2*X,W=X-q.minX,z=X-q.minY;return{w:K,h:Y,dx:W,dy:z}}function uY(J,Q,Z={}){let q=J.getShape(Q);if(!q||!J.isShapeFrameLike(q))return;let X=J.getSortedChildIdsForParent(q.id),K=D0(X.map((H)=>J.getShape(H)));if(!K.length)return;let{w:Y,h:W,dx:z,dy:G}=vA(K,J,Z);if(z===0&&G===0&&q.props.w===Y&&q.props.h===W)return;let $=new M(z,G).rot(q.rotation);J.run(()=>{let H=X.map((_)=>{let F=J.getShape(_);return{id:F.id,type:F.type,x:F.x+z,y:F.y+G}});H.push({id:q.id,type:q.type,x:q.x-$.x,y:q.y-$.y,props:{w:Y,h:W}}),J.updateShapes(H)})}var q5=E(c(),1);var R7=E(m(),1);var GI=E(c(),1),va=E(c1(),1),Sa=E(m(),1);var n5=E(c(),1);var $8={};f7($8,{createContextMenuScope:()=>V$0,Trigger:()=>w$0,SubTrigger:()=>l$0,SubContent:()=>p$0,Sub:()=>c$0,Separator:()=>u$0,Root:()=>I$0,RadioItem:()=>g$0,RadioGroup:()=>f$0,Portal:()=>b$0,Label:()=>x$0,ItemIndicator:()=>h$0,Item:()=>v$0,Group:()=>y$0,ContextMenuTrigger:()=>PC,ContextMenuSubTrigger:()=>mC,ContextMenuSubContent:()=>cC,ContextMenuSub:()=>uC,ContextMenuSeparator:()=>gC,ContextMenuRadioItem:()=>SC,ContextMenuRadioGroup:()=>vC,ContextMenuPortal:()=>IC,ContextMenuLabel:()=>TC,ContextMenuItemIndicator:()=>fC,ContextMenuItem:()=>yC,ContextMenuGroup:()=>bC,ContextMenuContent:()=>wC,ContextMenuCheckboxItem:()=>xC,ContextMenuArrow:()=>hC,ContextMenu:()=>CC,Content:()=>T$0,CheckboxItem:()=>S$0,Arrow:()=>m$0});var M4=E(m(),1);var $t0=!!(typeof window<"u"&&window.document&&window.document.createElement);function Z0(J,Q,{checkForDefaultPrevented:Z=!0}={}){return function(X){if(J?.(X),Z===!1||!X.defaultPrevented)return Q?.(X)}}var KQ=E(m(),1),pd=E(c(),1);function U4(J,Q=[]){let Z=[];function q(K,Y){let W=KQ.createContext(Y);W.displayName=K+"Context";let z=Z.length;Z=[...Z,Y];let G=(H)=>{let{scope:_,children:F,...U}=H,V=_?.[J]?.[z]||W,B=KQ.useMemo(()=>U,Object.values(U));return pd.jsx(V.Provider,{value:B,children:F})};G.displayName=K+"Provider";function $(H,_){let F=_?.[J]?.[z]||W,U=KQ.useContext(F);if(U)return U;if(Y!==void 0)return Y;throw Error(`\`${H}\` must be used within \`${K}\``)}return[G,$]}let X=()=>{let K=Z.map((Y)=>{return KQ.createContext(Y)});return function(W){let z=W?.[J]||K;return KQ.useMemo(()=>({[`__scope${J}`]:{...W,[J]:z}}),[W,z])}};return X.scopeName=J,[q,mz0(X,...Q)]}function mz0(...J){let Q=J[0];if(J.length===1)return Q;let Z=()=>{let q=J.map((X)=>({useScope:X(),scopeName:X.scopeName}));return function(K){let Y=q.reduce((W,{useScope:z,scopeName:G})=>{let H=z(K)[`__scope${G}`];return{...W,...H}},{});return KQ.useMemo(()=>({[`__scope${Q.scopeName}`]:Y}),[Y])}};return Z.scopeName=Q.scopeName,Z}var rd=E(m(),1),ad=E(SJ(),1);var mY={};f7(mY,{createSlottable:()=>mN,createSlot:()=>P8,Slottable:()=>lz0,Slot:()=>cz0,Root:()=>cz0});var p5=E(m(),1);var id=E(m(),1);function dd(J,Q){if(typeof J==="function")return J(Q);else if(J!==null&&J!==void 0)J.current=Q}function Y$(...J){return(Q)=>{let Z=!1,q=J.map((X)=>{let K=dd(X,Q);if(!Z&&typeof K=="function")Z=!0;return K});if(Z)return()=>{for(let X=0;X<q.length;X++){let K=q[X];if(typeof K=="function")K();else dd(J[X],null)}}}}function p0(...J){return id.useCallback(Y$(...J),J)}function P8(J){let Q=p5.forwardRef((Z,q)=>{let{children:X,...K}=Z,Y=null,W=!1,z=[];if(nd(X)&&typeof uN==="function")X=uN(X._payload);if(p5.Children.forEach(X,(_)=>{if(nz0(_)){W=!0;let F=_,U="child"in F.props?F.props.child:F.props.children;if(nd(U)&&typeof uN==="function")U=uN(U._payload);Y=pz0(F,U),z.push(Y?.props?.children)}else z.push(_)}),Y)Y=p5.cloneElement(Y,void 0,z);else if(!W&&p5.Children.count(X)===1&&p5.isValidElement(X))Y=X;let G=Y?iz0(Y):void 0,$=p0(q,G);if(!Y){if(X||X===0)throw Error(W?oz0(J):az0(J));return X}let H=dz0(K,Y.props??{});if(Y.type!==p5.Fragment)H.ref=q?$:G;return p5.cloneElement(Y,H)});return Q.displayName=`${J}.Slot`,Q}var cz0=P8("Slot"),sd=Symbol.for("radix.slottable");function mN(J){let Q=(Z)=>("child"in Z)?Z.children(Z.child):Z.children;return Q.displayName=`${J}.Slottable`,Q.__radixId=sd,Q}var lz0=mN("Slottable"),pz0=(J,Q)=>{if("child"in J.props){let Z=J.props.child;if(!p5.isValidElement(Z))return null;return p5.cloneElement(Z,void 0,J.props.children(Z.props.children))}return p5.isValidElement(Q)?Q:null};function dz0(J,Q){let Z={...Q};for(let q in Q){let X=J[q],K=Q[q];if(/^on[A-Z]/.test(q)){if(X&&K)Z[q]=(...W)=>{let z=K(...W);return X(...W),z};else if(X)Z[q]=X}else if(q==="style")Z[q]={...X,...K};else if(q==="className")Z[q]=[X,K].filter(Boolean).join(" ")}return{...J,...Z}}function iz0(J){let Q=Object.getOwnPropertyDescriptor(J.props,"ref")?.get,Z=Q&&"isReactWarning"in Q&&Q.isReactWarning;if(Z)return J.ref;if(Q=Object.getOwnPropertyDescriptor(J,"ref")?.get,Z=Q&&"isReactWarning"in Q&&Q.isReactWarning,Z)return J.props.ref;return J.props.ref||J.ref}function nz0(J){return p5.isValidElement(J)&&typeof J.type==="function"&&"__radixId"in J.type&&J.type.__radixId===sd}var sz0=Symbol.for("react.lazy");function nd(J){return J!=null&&typeof J==="object"&&"$$typeof"in J&&J.$$typeof===sz0&&"_payload"in J&&rz0(J._payload)}function rz0(J){return typeof J==="object"&&J!==null&&"then"in J}var az0=(J)=>{return`${J} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`},oz0=(J)=>{return`${J} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`},uN=p5[" use ".trim().toString()];var od=E(c(),1),tz0=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],_0=tz0.reduce((J,Q)=>{let Z=P8(`Primitive.${Q}`),q=rd.forwardRef((X,K)=>{let{asChild:Y,...W}=X,z=Y?Z:Q;if(typeof window<"u")window[Symbol.for("radix-ui")]=!0;return od.jsx(z,{...W,ref:K})});return q.displayName=`Primitive.${Q}`,{...J,[Q]:q}},{});function cY(J,Q){if(J)ad.flushSync(()=>J.dispatchEvent(Q))}var T0=E(m(),1);var o7=E(m(),1);var cN=E(c(),1),lN=E(m(),1);var JG0=E(c(),1);function c2(J){let Q=J+"CollectionProvider",[Z,q]=U4(Q),[X,K]=Z(Q,{collectionRef:{current:null},itemMap:new Map}),Y=(V)=>{let{scope:B,children:N}=V,L=o7.useRef(null),D=o7.useRef(new Map).current;return cN.jsx(X,{scope:B,itemMap:D,collectionRef:L,children:N})};Y.displayName=Q;let W=J+"CollectionSlot",z=P8(W),G=o7.forwardRef((V,B)=>{let{scope:N,children:L}=V,D=K(W,N),O=p0(B,D.collectionRef);return cN.jsx(z,{ref:O,children:L})});G.displayName=W;let $=J+"CollectionItemSlot",H="data-radix-collection-item",_=P8($),F=o7.forwardRef((V,B)=>{let{scope:N,children:L,...D}=V,O=o7.useRef(null),j=p0(B,O),k=K($,N);return o7.useEffect(()=>{return k.itemMap.set(O,{ref:O,...D}),()=>void k.itemMap.delete(O)}),cN.jsx(_,{...{[H]:""},ref:j,children:L})});F.displayName=$;function U(V){let B=K(J+"CollectionConsumer",V);return o7.useCallback(()=>{let L=B.collectionRef.current;if(!L)return[];let D=Array.from(L.querySelectorAll(`[${H}]`));return Array.from(B.itemMap.values()).sort((k,R)=>D.indexOf(k.ref.current)-D.indexOf(R.ref.current))},[B.collectionRef,B.itemMap])}return[{Provider:Y,Slot:G,ItemSlot:F},U,q]}var td=new WeakMap,Mt0=class J extends Map{#J;constructor(Q){super(Q);this.#J=[...super.keys()],td.set(this,!0)}set(Q,Z){if(td.get(this))if(this.has(Q))this.#J[this.#J.indexOf(Q)]=Q;else this.#J.push(Q);return super.set(Q,Z),this}insert(Q,Z,q){let X=this.has(Z),K=this.#J.length,Y=ed(Q),W=Y>=0?Y:K+Y,z=W<0||W>=K?-1:W;if(z===this.size||X&&z===this.size-1||z===-1)return this.set(Z,q),this;let G=this.size+(X?0:1);if(Y<0)W++;let $=[...this.#J],H,_=!1;for(let F=W;F<G;F++)if(W===F){let U=$[F];if($[F]===Z)U=$[F+1];if(X)this.delete(Z);H=this.get(U),this.set(Z,q)}else{if(!_&&$[F-1]===Z)_=!0;let U=$[_?F:F-1],V=H;H=this.get(U),this.delete(U),this.set(U,V)}return this}with(Q,Z,q){let X=new J(this);return X.insert(Q,Z,q),X}before(Q){let Z=this.#J.indexOf(Q)-1;if(Z<0)return;return this.entryAt(Z)}setBefore(Q,Z,q){let X=this.#J.indexOf(Q);if(X===-1)return this;return this.insert(X,Z,q)}after(Q){let Z=this.#J.indexOf(Q);if(Z=Z===-1||Z===this.size-1?-1:Z+1,Z===-1)return;return this.entryAt(Z)}setAfter(Q,Z,q){let X=this.#J.indexOf(Q);if(X===-1)return this;return this.insert(X+1,Z,q)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return this.#J=[],super.clear()}delete(Q){let Z=super.delete(Q);if(Z)this.#J.splice(this.#J.indexOf(Q),1);return Z}deleteAt(Q){let Z=this.keyAt(Q);if(Z!==void 0)return this.delete(Z);return!1}at(Q){let Z=SA(this.#J,Q);if(Z!==void 0)return this.get(Z)}entryAt(Q){let Z=SA(this.#J,Q);if(Z!==void 0)return[Z,this.get(Z)]}indexOf(Q){return this.#J.indexOf(Q)}keyAt(Q){return SA(this.#J,Q)}from(Q,Z){let q=this.indexOf(Q);if(q===-1)return;let X=q+Z;if(X<0)X=0;if(X>=this.size)X=this.size-1;return this.at(X)}keyFrom(Q,Z){let q=this.indexOf(Q);if(q===-1)return;let X=q+Z;if(X<0)X=0;if(X>=this.size)X=this.size-1;return this.keyAt(X)}find(Q,Z){let q=0;for(let X of this){if(Reflect.apply(Q,Z,[X,q,this]))return X;q++}return}findIndex(Q,Z){let q=0;for(let X of this){if(Reflect.apply(Q,Z,[X,q,this]))return q;q++}return-1}filter(Q,Z){let q=[],X=0;for(let K of this){if(Reflect.apply(Q,Z,[K,X,this]))q.push(K);X++}return new J(q)}map(Q,Z){let q=[],X=0;for(let K of this)q.push([K[0],Reflect.apply(Q,Z,[K,X,this])]),X++;return new J(q)}reduce(...Q){let[Z,q]=Q,X=0,K=q??this.at(0);for(let Y of this){if(X===0&&Q.length===1)K=Y;else K=Reflect.apply(Z,this,[K,Y,X,this]);X++}return K}reduceRight(...Q){let[Z,q]=Q,X=q??this.at(-1);for(let K=this.size-1;K>=0;K--){let Y=this.at(K);if(K===this.size-1&&Q.length===1)X=Y;else X=Reflect.apply(Z,this,[X,Y,K,this])}return X}toSorted(Q){let Z=[...this.entries()].sort(Q);return new J(Z)}toReversed(){let Q=new J;for(let Z=this.size-1;Z>=0;Z--){let q=this.keyAt(Z),X=this.get(q);Q.set(q,X)}return Q}toSpliced(...Q){let Z=[...this.entries()];return Z.splice(...Q),new J(Z)}slice(Q,Z){let q=new J,X=this.size-1;if(Q===void 0)return q;if(Q<0)Q=Q+this.size;if(Z!==void 0&&Z>0)X=Z-1;for(let K=Q;K<=X;K++){let Y=this.keyAt(K),W=this.get(Y);q.set(Y,W)}return q}every(Q,Z){let q=0;for(let X of this){if(!Reflect.apply(Q,Z,[X,q,this]))return!1;q++}return!0}some(Q,Z){let q=0;for(let X of this){if(Reflect.apply(Q,Z,[X,q,this]))return!0;q++}return!1}};function SA(J,Q){if("at"in Array.prototype)return Array.prototype.at.call(J,Q);let Z=ez0(J,Q);return Z===-1?void 0:J[Z]}function ez0(J,Q){let Z=J.length,q=ed(Q),X=q>=0?q:Z+q;return X<0||X>=Z?-1:X}function ed(J){return J!==J||J===0?0:Math.trunc(J)}var pN=E(m(),1),QG0=E(c(),1),ZG0=pN.createContext(void 0);function _7(J){let Q=pN.useContext(ZG0);return J||Q||"ltr"}var W4=E(m(),1);var lY=E(m(),1);function $6(J){let Q=lY.useRef(J);return lY.useEffect(()=>{Q.current=J}),lY.useMemo(()=>(...Z)=>Q.current?.(...Z),[])}var Ji=E(m(),1);function Qi(J,Q=globalThis?.document){let Z=$6(J);Ji.useEffect(()=>{let q=(X)=>{if(X.key==="Escape")Z(X)};return Q.addEventListener("keydown",q,{capture:!0}),()=>Q.removeEventListener("keydown",q,{capture:!0})},[Z,Q])}var gA=E(c(),1),qG0="DismissableLayer",fA="dismissableLayer.update",XG0="dismissableLayer.pointerDownOutside",KG0="dismissableLayer.focusOutside",Zi,hA=W4.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),F7=W4.forwardRef((J,Q)=>{let{disableOutsidePointerEvents:Z=!1,deferPointerDownOutside:q=!1,onEscapeKeyDown:X,onPointerDownOutside:K,onFocusOutside:Y,onInteractOutside:W,onDismiss:z,...G}=J,$=W4.useContext(hA),[H,_]=W4.useState(null),F=H?.ownerDocument??globalThis?.document,[,U]=W4.useState({}),V=p0(Q,(A)=>_(A)),B=Array.from($.layers),[N]=[...$.layersWithOutsidePointerEventsDisabled].slice(-1),L=B.indexOf(N),D=H?B.indexOf(H):-1,O=$.layersWithOutsidePointerEventsDisabled.size>0,j=D>=L,k=W4.useRef(!1),R=WG0((A)=>{let I=A.target;if(!(I instanceof Node))return;let C=[...$.branches].some((y)=>y.contains(I));if(!j||C)return;if(K?.(A),W?.(A),!A.defaultPrevented)z?.()},{ownerDocument:F,deferPointerDownOutside:q,isDeferredPointerDownOutsideRef:k,dismissableSurfaces:$.dismissableSurfaces}),P=zG0((A)=>{if(q&&k.current)return;let I=A.target;if([...$.branches].some((y)=>y.contains(I)))return;if(Y?.(A),W?.(A),!A.defaultPrevented)z?.()},F);return Qi((A)=>{if(D!==$.layers.size-1)return;if(X?.(A),!A.defaultPrevented&&z)A.preventDefault(),z()},F),W4.useEffect(()=>{if(!H)return;if(Z){if($.layersWithOutsidePointerEventsDisabled.size===0)Zi=F.body.style.pointerEvents,F.body.style.pointerEvents="none";$.layersWithOutsidePointerEventsDisabled.add(H)}return $.layers.add(H),qi(),()=>{if(Z){if($.layersWithOutsidePointerEventsDisabled.delete(H),$.layersWithOutsidePointerEventsDisabled.size===0)F.body.style.pointerEvents=Zi}}},[H,F,Z,$]),W4.useEffect(()=>{return()=>{if(!H)return;$.layers.delete(H),$.layersWithOutsidePointerEventsDisabled.delete(H),qi()}},[H,$]),W4.useEffect(()=>{let A=()=>U({});return document.addEventListener(fA,A),()=>document.removeEventListener(fA,A)},[]),gA.jsx(_0.div,{...G,ref:V,style:{pointerEvents:O?j?"auto":"none":void 0,...J.style},onFocusCapture:Z0(J.onFocusCapture,P.onFocusCapture),onBlurCapture:Z0(J.onBlurCapture,P.onBlurCapture),onPointerDownCapture:Z0(J.onPointerDownCapture,R.onPointerDownCapture)})});F7.displayName=qG0;var YG0="DismissableLayerBranch",Xi=W4.forwardRef((J,Q)=>{let Z=W4.useContext(hA),q=W4.useRef(null),X=p0(Q,q);return W4.useEffect(()=>{let K=q.current;if(K)return Z.branches.add(K),()=>{Z.branches.delete(K)}},[Z.branches]),gA.jsx(_0.div,{...J,ref:X})});Xi.displayName=YG0;function Ki(){let J=W4.useContext(hA),[Q,Z]=W4.useState(null);return W4.useEffect(()=>{if(!Q)return;return J.dismissableSurfaces.add(Q),()=>{J.dismissableSurfaces.delete(Q)}},[Q,J.dismissableSurfaces]),Z}function WG0(J,Q){let{ownerDocument:Z=globalThis?.document,deferPointerDownOutside:q=!1,isDeferredPointerDownOutsideRef:X,dismissableSurfaces:K}=Q,Y=$6(J),W=W4.useRef(!1),z=W4.useRef(!1),G=W4.useRef(new Map),$=W4.useRef(()=>{});return W4.useEffect(()=>{function H(){z.current=!1,X.current=!1,G.current.clear()}function _(){return Array.from(G.current.values()).some(Boolean)}function F(L){if(!z.current)return;let D=L.target;if(!(D instanceof Node&&[...K].some((j)=>j.contains(D))))G.current.set(L.type,!0);if(L.type==="click")window.setTimeout(()=>{if(z.current)$.current()},0)}function U(L){if(z.current)G.current.set(L.type,!1)}let V=(L)=>{if(L.target&&!W.current){let O=function(){Z.removeEventListener("click",$.current);let k=_();if(H(),!k)Yi(XG0,Y,j,{discrete:!0})};var D=O;let j={originalEvent:L};if(z.current=!0,X.current=q&&L.button===0,G.current.clear(),!q||L.button!==0)O();else Z.removeEventListener("click",$.current),$.current=O,Z.addEventListener("click",$.current,{once:!0})}else Z.removeEventListener("click",$.current),H();W.current=!1},B=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(let L of B)Z.addEventListener(L,F,!0),Z.addEventListener(L,U);let N=window.setTimeout(()=>{Z.addEventListener("pointerdown",V)},0);return()=>{window.clearTimeout(N),Z.removeEventListener("pointerdown",V),Z.removeEventListener("click",$.current);for(let L of B)Z.removeEventListener(L,F,!0),Z.removeEventListener(L,U)}},[Z,Y,q,X,K]),{onPointerDownCapture:()=>W.current=!0}}function zG0(J,Q=globalThis?.document){let Z=$6(J),q=W4.useRef(!1);return W4.useEffect(()=>{let X=(K)=>{if(K.target&&!q.current)Yi(KG0,Z,{originalEvent:K},{discrete:!1})};return Q.addEventListener("focusin",X),()=>Q.removeEventListener("focusin",X)},[Q,Z]),{onFocusCapture:()=>q.current=!0,onBlurCapture:()=>q.current=!1}}function qi(){let J=new CustomEvent(fA);document.dispatchEvent(J)}function Yi(J,Q,Z,{discrete:q}){let X=Z.originalEvent.target,K=new CustomEvent(J,{bubbles:!1,cancelable:!0,detail:Z});if(Q)X.addEventListener(J,Q,{once:!0});if(q)cY(X,K);else X.dispatchEvent(K)}var Wi=F7,zi=Xi;var Hi=E(m(),1),dN=0,pY=null;function iZ(){Hi.useEffect(()=>{if(!pY)pY={start:Gi(),end:Gi()};let{start:J,end:Q}=pY;if(document.body.firstElementChild!==J)document.body.insertAdjacentElement("afterbegin",J);if(document.body.lastElementChild!==Q)document.body.insertAdjacentElement("beforeend",Q);return dN++,()=>{if(dN===1)pY?.start.remove(),pY?.end.remove(),pY=null;dN=Math.max(0,dN-1)}},[])}function Gi(){let J=document.createElement("span");return J.setAttribute("data-radix-focus-guard",""),J.tabIndex=0,J.style.outline="none",J.style.opacity="0",J.style.position="fixed",J.style.pointerEvents="none",J}var U7=E(m(),1);var Vi=E(c(),1),uA="focusScope.autoFocusOnMount",mA="focusScope.autoFocusOnUnmount",$i={bubbles:!1,cancelable:!0},HG0="FocusScope",YQ=U7.forwardRef((J,Q)=>{let{loop:Z=!1,trapped:q=!1,onMountAutoFocus:X,onUnmountAutoFocus:K,...Y}=J,[W,z]=U7.useState(null),G=$6(X),$=$6(K),H=U7.useRef(null),_=p0(Q,(V)=>z(V)),F=U7.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;U7.useEffect(()=>{if(q){let L=function(k){if(F.paused||!W)return;let R=k.target;if(W.contains(R))H.current=R;else nZ(H.current,{select:!0})},D=function(k){if(F.paused||!W)return;let R=k.relatedTarget;if(R===null)return;if(!W.contains(R))nZ(H.current,{select:!0})},O=function(k){if(document.activeElement!==document.body)return;for(let P of k)if(P.removedNodes.length>0)nZ(W)};var V=L,B=D,N=O;document.addEventListener("focusin",L),document.addEventListener("focusout",D);let j=new MutationObserver(O);if(W)j.observe(W,{childList:!0,subtree:!0});return()=>{document.removeEventListener("focusin",L),document.removeEventListener("focusout",D),j.disconnect()}}},[q,W,F.paused]),U7.useEffect(()=>{if(W){Fi.add(F);let V=document.activeElement;if(!W.contains(V)){let N=new CustomEvent(uA,$i);if(W.addEventListener(uA,G),W.dispatchEvent(N),!N.defaultPrevented){if($G0(NG0(Ni(W)),{select:!0}),document.activeElement===V)nZ(W)}}return()=>{W.removeEventListener(uA,G),setTimeout(()=>{let N=new CustomEvent(mA,$i);if(W.addEventListener(mA,$),W.dispatchEvent(N),!N.defaultPrevented)nZ(V??document.body,{select:!0});W.removeEventListener(mA,$),Fi.remove(F)},0)}}},[W,G,$,F]);let U=U7.useCallback((V)=>{if(!Z&&!q)return;if(F.paused)return;let B=V.key==="Tab"&&!V.altKey&&!V.ctrlKey&&!V.metaKey,N=document.activeElement;if(B&&N){let L=V.currentTarget,[D,O]=_G0(L);if(!(D&&O)){if(N===L)V.preventDefault()}else if(!V.shiftKey&&N===O){if(V.preventDefault(),Z)nZ(D,{select:!0})}else if(V.shiftKey&&N===D){if(V.preventDefault(),Z)nZ(O,{select:!0})}}},[Z,q,F.paused]);return Vi.jsx(_0.div,{tabIndex:-1,...Y,ref:_,onKeyDown:U})});YQ.displayName=HG0;function $G0(J,{select:Q=!1}={}){let Z=document.activeElement;for(let q of J)if(nZ(q,{select:Q}),document.activeElement!==Z)return}function _G0(J){let Q=Ni(J),Z=_i(Q,J),q=_i(Q.reverse(),J);return[Z,q]}function Ni(J){let Q=[],Z=document.createTreeWalker(J,NodeFilter.SHOW_ELEMENT,{acceptNode:(q)=>{let X=q.tagName==="INPUT"&&q.type==="hidden";if(q.disabled||q.hidden||X)return NodeFilter.FILTER_SKIP;return q.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});while(Z.nextNode())Q.push(Z.currentNode);return Q}function _i(J,Q){for(let Z of J)if(!FG0(Z,{upTo:Q}))return Z}function FG0(J,{upTo:Q}){if(getComputedStyle(J).visibility==="hidden")return!0;while(J){if(Q!==void 0&&J===Q)return!1;if(getComputedStyle(J).display==="none")return!0;J=J.parentElement}return!1}function UG0(J){return J instanceof HTMLInputElement&&"select"in J}function nZ(J,{select:Q=!1}={}){if(J&&J.focus){let Z=document.activeElement;if(J.focus({preventScroll:!0}),J!==Z&&UG0(J)&&Q)J.select()}}var Fi=VG0();function VG0(){let J=[];return{add(Q){let Z=J[0];if(Q!==Z)Z?.pause();J=Ui(J,Q),J.unshift(Q)},remove(Q){J=Ui(J,Q),J[0]?.resume()}}}function Ui(J,Q){let Z=[...J],q=Z.indexOf(Q);if(q!==-1)Z.splice(q,1);return Z}function NG0(J){return J.filter((Q)=>Q.tagName!=="A")}var cA=E(m(),1);var Bi=E(m(),1),f4=globalThis?.document?Bi.useLayoutEffect:()=>{};var BG0=cA[" useId ".trim().toString()]||(()=>{return}),LG0=0;function o6(J){let[Q,Z]=cA.useState(BG0());return f4(()=>{if(!J)Z((q)=>q??String(LG0++))},[J]),J||(Q?`radix-${Q}`:"")}var d5=E(m(),1);var Di=["top","right","bottom","left"];var{min:l2,max:I8,round:z$,floor:G$}=Math,t7=(J)=>({x:J,y:J}),OG0={left:"right",right:"left",bottom:"top",top:"bottom"};function nN(J,Q,Z){return I8(J,l2(Q,Z))}function p2(J,Q){return typeof J==="function"?J(Q):J}function d2(J){return J.split("-")[0]}function zX(J){return J.split("-")[1]}function sN(J){return J==="x"?"y":"x"}function rN(J){return J==="y"?"height":"width"}function e7(J){let Q=J[0];return Q==="t"||Q==="b"?"y":"x"}function aN(J){return sN(e7(J))}function Mi(J,Q,Z){if(Z===void 0)Z=!1;let q=zX(J),X=aN(J),K=rN(X),Y=X==="x"?q===(Z?"end":"start")?"right":"left":q==="start"?"bottom":"top";if(Q.reference[K]>Q.floating[K])Y=W$(Y);return[Y,W$(Y)]}function ji(J){let Q=W$(J);return[iN(J),Q,iN(Q)]}function iN(J){return J.includes("start")?J.replace("start","end"):J.replace("end","start")}var Li=["left","right"],Oi=["right","left"],DG0=["top","bottom"],MG0=["bottom","top"];function jG0(J,Q,Z){switch(J){case"top":case"bottom":if(Z)return Q?Oi:Li;return Q?Li:Oi;case"left":case"right":return Q?DG0:MG0;default:return[]}}function Ri(J,Q,Z,q){let X=zX(J),K=jG0(d2(J),Z==="start",q);if(X){if(K=K.map((Y)=>Y+"-"+X),Q)K=K.concat(K.map(iN))}return K}function W$(J){let Q=d2(J);return OG0[Q]+J.slice(Q.length)}function RG0(J){return{top:0,right:0,bottom:0,left:0,...J}}function lA(J){return typeof J!=="number"?RG0(J):{top:J,right:J,bottom:J,left:J}}function GX(J){let{x:Q,y:Z,width:q,height:X}=J;return{width:q,height:X,top:Z,left:Q,right:Q+q,bottom:Z+X,x:Q,y:Z}}function ki(J,Q,Z){let{reference:q,floating:X}=J,K=e7(Q),Y=aN(Q),W=rN(Y),z=d2(Q),G=K==="y",$=q.x+q.width/2-X.width/2,H=q.y+q.height/2-X.height/2,_=q[W]/2-X[W]/2,F;switch(z){case"top":F={x:$,y:q.y-X.height};break;case"bottom":F={x:$,y:q.y+q.height};break;case"right":F={x:q.x+q.width,y:H};break;case"left":F={x:q.x-X.width,y:H};break;default:F={x:q.x,y:q.y}}switch(zX(Q)){case"start":F[Y]-=_*(Z&&G?-1:1);break;case"end":F[Y]+=_*(Z&&G?-1:1);break}return F}async function Ci(J,Q){var Z;if(Q===void 0)Q={};let{x:q,y:X,platform:K,rects:Y,elements:W,strategy:z}=J,{boundary:G="clippingAncestors",rootBoundary:$="viewport",elementContext:H="floating",altBoundary:_=!1,padding:F=0}=p2(Q,J),U=lA(F),B=W[_?H==="floating"?"reference":"floating":H],N=GX(await K.getClippingRect({element:((Z=await(K.isElement==null?void 0:K.isElement(B)))!=null?Z:!0)?B:B.contextElement||await(K.getDocumentElement==null?void 0:K.getDocumentElement(W.floating)),boundary:G,rootBoundary:$,strategy:z})),L=H==="floating"?{x:q,y:X,width:Y.floating.width,height:Y.floating.height}:Y.reference,D=await(K.getOffsetParent==null?void 0:K.getOffsetParent(W.floating)),O=await(K.isElement==null?void 0:K.isElement(D))?await(K.getScale==null?void 0:K.getScale(D))||{x:1,y:1}:{x:1,y:1},j=GX(K.convertOffsetParentRelativeRectToViewportRelativeRect?await K.convertOffsetParentRelativeRectToViewportRelativeRect({elements:W,rect:L,offsetParent:D,strategy:z}):L);return{top:(N.top-j.top+U.top)/O.y,bottom:(j.bottom-N.bottom+U.bottom)/O.y,left:(N.left-j.left+U.left)/O.x,right:(j.right-N.right+U.right)/O.x}}var kG0=50,Pi=async(J,Q,Z)=>{let{placement:q="bottom",strategy:X="absolute",middleware:K=[],platform:Y}=Z,W=Y.detectOverflow?Y:{...Y,detectOverflow:Ci},z=await(Y.isRTL==null?void 0:Y.isRTL(Q)),G=await Y.getElementRects({reference:J,floating:Q,strategy:X}),{x:$,y:H}=ki(G,q,z),_=q,F=0,U={};for(let V=0;V<K.length;V++){let B=K[V];if(!B)continue;let{name:N,fn:L}=B,{x:D,y:O,data:j,reset:k}=await L({x:$,y:H,initialPlacement:q,placement:_,strategy:X,middlewareData:U,rects:G,platform:W,elements:{reference:J,floating:Q}});if($=D!=null?D:$,H=O!=null?O:H,U[N]={...U[N],...j},k&&F<kG0){if(F++,typeof k==="object"){if(k.placement)_=k.placement;if(k.rects)G=k.rects===!0?await Y.getElementRects({reference:J,floating:Q,strategy:X}):k.rects;({x:$,y:H}=ki(G,_,z))}V=-1}}return{x:$,y:H,placement:_,strategy:X,middlewareData:U}},Ii=(J)=>({name:"arrow",options:J,async fn(Q){let{x:Z,y:q,placement:X,rects:K,platform:Y,elements:W,middlewareData:z}=Q,{element:G,padding:$=0}=p2(J,Q)||{};if(G==null)return{};let H=lA($),_={x:Z,y:q},F=aN(X),U=rN(F),V=await Y.getDimensions(G),B=F==="y",N=B?"top":"left",L=B?"bottom":"right",D=B?"clientHeight":"clientWidth",O=K.reference[U]+K.reference[F]-_[F]-K.floating[U],j=_[F]-K.reference[F],k=await(Y.getOffsetParent==null?void 0:Y.getOffsetParent(G)),R=k?k[D]:0;if(!R||!await(Y.isElement==null?void 0:Y.isElement(k)))R=W.floating[D]||K.floating[U];let P=O/2-j/2,A=R/2-V[U]/2-1,I=l2(H[N],A),C=l2(H[L],A),y=I,S=R-V[U]-C,T=R/2-V[U]/2+P,h=nN(y,T,S),b=!z.arrow&&zX(X)!=null&&T!==h&&K.reference[U]/2-(T<y?I:C)-V[U]/2<0,x=b?T<y?T-y:T-S:0;return{[F]:_[F]+x,data:{[F]:h,centerOffset:T-h-x,...b&&{alignmentOffset:x}},reset:b}}});var wi=function(J){if(J===void 0)J={};return{name:"flip",options:J,async fn(Q){var Z,q;let{placement:X,middlewareData:K,rects:Y,initialPlacement:W,platform:z,elements:G}=Q,{mainAxis:$=!0,crossAxis:H=!0,fallbackPlacements:_,fallbackStrategy:F="bestFit",fallbackAxisSideDirection:U="none",flipAlignment:V=!0,...B}=p2(J,Q);if((Z=K.arrow)!=null&&Z.alignmentOffset)return{};let N=d2(X),L=e7(W),D=d2(W)===W,O=await(z.isRTL==null?void 0:z.isRTL(G.floating)),j=_||(D||!V?[W$(W)]:ji(W)),k=U!=="none";if(!_&&k)j.push(...Ri(W,V,U,O));let R=[W,...j],P=await z.detectOverflow(Q,B),A=[],I=((q=K.flip)==null?void 0:q.overflows)||[];if($)A.push(P[N]);if(H){let T=Mi(X,Y,O);A.push(P[T[0]],P[T[1]])}if(I=[...I,{placement:X,overflows:A}],!A.every((T)=>T<=0)){var C,y;let T=(((C=K.flip)==null?void 0:C.index)||0)+1,h=R[T];if(h){if(!(H==="alignment"?L!==e7(h):!1)||I.every((f)=>e7(f.placement)===L?f.overflows[0]>0:!0))return{data:{index:T,overflows:I},reset:{placement:h}}}let b=(y=I.filter((x)=>x.overflows[0]<=0).sort((x,f)=>x.overflows[1]-f.overflows[1])[0])==null?void 0:y.placement;if(!b)switch(F){case"bestFit":{var S;let x=(S=I.filter((f)=>{if(k){let u=e7(f.placement);return u===L||u==="y"}return!0}).map((f)=>[f.placement,f.overflows.filter((u)=>u>0).reduce((u,p)=>u+p,0)]).sort((f,u)=>f[1]-u[1])[0])==null?void 0:S[0];if(x)b=x;break}case"initialPlacement":b=W;break}if(X!==b)return{reset:{placement:b}}}return{}}}};function Ei(J,Q){return{top:J.top-Q.height,right:J.right-Q.width,bottom:J.bottom-Q.height,left:J.left-Q.width}}function Ai(J){return Di.some((Q)=>J[Q]>=0)}var bi=function(J){if(J===void 0)J={};return{name:"hide",options:J,async fn(Q){let{rects:Z,platform:q}=Q,{strategy:X="referenceHidden",...K}=p2(J,Q);switch(X){case"referenceHidden":{let Y=await q.detectOverflow(Q,{...K,elementContext:"reference"}),W=Ei(Y,Z.reference);return{data:{referenceHiddenOffsets:W,referenceHidden:Ai(W)}}}case"escaped":{let Y=await q.detectOverflow(Q,{...K,altBoundary:!0}),W=Ei(Y,Z.floating);return{data:{escapedOffsets:W,escaped:Ai(W)}}}default:return{}}}}};var Ti=new Set(["left","top"]);async function EG0(J,Q){let{placement:Z,platform:q,elements:X}=J,K=await(q.isRTL==null?void 0:q.isRTL(X.floating)),Y=d2(Z),W=zX(Z),z=e7(Z)==="y",G=Ti.has(Y)?-1:1,$=K&&z?-1:1,H=p2(Q,J),{mainAxis:_,crossAxis:F,alignmentAxis:U}=typeof H==="number"?{mainAxis:H,crossAxis:0,alignmentAxis:null}:{mainAxis:H.mainAxis||0,crossAxis:H.crossAxis||0,alignmentAxis:H.alignmentAxis};if(W&&typeof U==="number")F=W==="end"?U*-1:U;return z?{x:F*$,y:_*G}:{x:_*G,y:F*$}}var yi=function(J){if(J===void 0)J=0;return{name:"offset",options:J,async fn(Q){var Z,q;let{x:X,y:K,placement:Y,middlewareData:W}=Q,z=await EG0(Q,J);if(Y===((Z=W.offset)==null?void 0:Z.placement)&&(q=W.arrow)!=null&&q.alignmentOffset)return{};return{x:X+z.x,y:K+z.y,data:{...z,placement:Y}}}}},xi=function(J){if(J===void 0)J={};return{name:"shift",options:J,async fn(Q){let{x:Z,y:q,placement:X,platform:K}=Q,{mainAxis:Y=!0,crossAxis:W=!1,limiter:z={fn:(N)=>{let{x:L,y:D}=N;return{x:L,y:D}}},...G}=p2(J,Q),$={x:Z,y:q},H=await K.detectOverflow(Q,G),_=e7(d2(X)),F=sN(_),U=$[F],V=$[_];if(Y){let N=F==="y"?"top":"left",L=F==="y"?"bottom":"right",D=U+H[N],O=U-H[L];U=nN(D,U,O)}if(W){let N=_==="y"?"top":"left",L=_==="y"?"bottom":"right",D=V+H[N],O=V-H[L];V=nN(D,V,O)}let B=z.fn({...Q,[F]:U,[_]:V});return{...B,data:{x:B.x-Z,y:B.y-q,enabled:{[F]:Y,[_]:W}}}}}},vi=function(J){if(J===void 0)J={};return{options:J,fn(Q){let{x:Z,y:q,placement:X,rects:K,middlewareData:Y}=Q,{offset:W=0,mainAxis:z=!0,crossAxis:G=!0}=p2(J,Q),$={x:Z,y:q},H=e7(X),_=sN(H),F=$[_],U=$[H],V=p2(W,Q),B=typeof V==="number"?{mainAxis:V,crossAxis:0}:{mainAxis:0,crossAxis:0,...V};if(z){let D=_==="y"?"height":"width",O=K.reference[_]-K.floating[D]+B.mainAxis,j=K.reference[_]+K.reference[D]-B.mainAxis;if(F<O)F=O;else if(F>j)F=j}if(G){var N,L;let D=_==="y"?"width":"height",O=Ti.has(d2(X)),j=K.reference[H]-K.floating[D]+(O?((N=Y.offset)==null?void 0:N[H])||0:0)+(O?0:B.crossAxis),k=K.reference[H]+K.reference[D]+(O?0:((L=Y.offset)==null?void 0:L[H])||0)-(O?B.crossAxis:0);if(U<j)U=j;else if(U>k)U=k}return{[_]:F,[H]:U}}}},Si=function(J){if(J===void 0)J={};return{name:"size",options:J,async fn(Q){var Z,q;let{placement:X,rects:K,platform:Y,elements:W}=Q,{apply:z=()=>{},...G}=p2(J,Q),$=await Y.detectOverflow(Q,G),H=d2(X),_=zX(X),F=e7(X)==="y",{width:U,height:V}=K.floating,B,N;if(H==="top"||H==="bottom")B=H,N=_===(await(Y.isRTL==null?void 0:Y.isRTL(W.floating))?"start":"end")?"left":"right";else N=H,B=_==="end"?"top":"bottom";let L=V-$.top-$.bottom,D=U-$.left-$.right,O=l2(V-$[B],L),j=l2(U-$[N],D),k=!Q.middlewareData.shift,R=O,P=j;if((Z=Q.middlewareData.shift)!=null&&Z.enabled.x)P=D;if((q=Q.middlewareData.shift)!=null&&q.enabled.y)R=L;if(k&&!_){let I=I8($.left,0),C=I8($.right,0),y=I8($.top,0),S=I8($.bottom,0);if(F)P=U-2*(I!==0||C!==0?I+C:I8($.left,$.right));else R=V-2*(y!==0||S!==0?y+S:I8($.top,$.bottom))}await z({...Q,availableWidth:P,availableHeight:R});let A=await Y.getDimensions(W.floating);if(U!==A.width||V!==A.height)return{reset:{rects:!0}};return{}}}};function oN(){return typeof window<"u"}function _X(J){if(gi(J))return(J.nodeName||"").toLowerCase();return"#document"}function t8(J){var Q;return(J==null||(Q=J.ownerDocument)==null?void 0:Q.defaultView)||window}function J2(J){var Q;return(Q=(gi(J)?J.ownerDocument:J.document)||window.document)==null?void 0:Q.documentElement}function gi(J){if(!oN())return!1;return J instanceof Node||J instanceof t8(J).Node}function V7(J){if(!oN())return!1;return J instanceof Element||J instanceof t8(J).Element}function i2(J){if(!oN())return!1;return J instanceof HTMLElement||J instanceof t8(J).HTMLElement}function fi(J){if(!oN()||typeof ShadowRoot>"u")return!1;return J instanceof ShadowRoot||J instanceof t8(J).ShadowRoot}function dY(J){let{overflow:Q,overflowX:Z,overflowY:q,display:X}=N7(J);return/auto|scroll|overlay|hidden|clip/.test(Q+q+Z)&&X!=="inline"&&X!=="contents"}function hi(J){return/^(table|td|th)$/.test(_X(J))}function H$(J){try{if(J.matches(":popover-open"))return!0}catch(Q){}try{return J.matches(":modal")}catch(Q){return!1}}var AG0=/transform|translate|scale|rotate|perspective|filter/,CG0=/paint|layout|strict|content/,HX=(J)=>!!J&&J!=="none",pA;function tN(J){let Q=V7(J)?N7(J):J;return HX(Q.transform)||HX(Q.translate)||HX(Q.scale)||HX(Q.rotate)||HX(Q.perspective)||!eN()&&(HX(Q.backdropFilter)||HX(Q.filter))||AG0.test(Q.willChange||"")||CG0.test(Q.contain||"")}function ui(J){let Q=WQ(J);while(i2(Q)&&!FX(Q)){if(tN(Q))return Q;else if(H$(Q))return null;Q=WQ(Q)}return null}function eN(){if(pA==null)pA=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none");return pA}function FX(J){return/^(html|body|#document)$/.test(_X(J))}function N7(J){return t8(J).getComputedStyle(J)}function $$(J){if(V7(J))return{scrollLeft:J.scrollLeft,scrollTop:J.scrollTop};return{scrollLeft:J.scrollX,scrollTop:J.scrollY}}function WQ(J){if(_X(J)==="html")return J;let Q=J.assignedSlot||J.parentNode||fi(J)&&J.host||J2(J);return fi(Q)?Q.host:Q}function mi(J){let Q=WQ(J);if(FX(Q))return J.ownerDocument?J.ownerDocument.body:J.body;if(i2(Q)&&dY(Q))return Q;return mi(Q)}function $X(J,Q,Z){var q;if(Q===void 0)Q=[];if(Z===void 0)Z=!0;let X=mi(J),K=X===((q=J.ownerDocument)==null?void 0:q.body),Y=t8(X);if(K){let W=JB(Y);return Q.concat(Y,Y.visualViewport||[],dY(X)?X:[],W&&Z?$X(W):[])}else return Q.concat(X,$X(X,[],Z))}function JB(J){return J.parent&&Object.getPrototypeOf(J.parent)?J.frameElement:null}function di(J){let Q=N7(J),Z=parseFloat(Q.width)||0,q=parseFloat(Q.height)||0,X=i2(J),K=X?J.offsetWidth:Z,Y=X?J.offsetHeight:q,W=z$(Z)!==K||z$(q)!==Y;if(W)Z=K,q=Y;return{width:Z,height:q,$:W}}function iA(J){return!V7(J)?J.contextElement:J}function iY(J){let Q=iA(J);if(!i2(Q))return t7(1);let Z=Q.getBoundingClientRect(),{width:q,height:X,$:K}=di(Q),Y=(K?z$(Z.width):Z.width)/q,W=(K?z$(Z.height):Z.height)/X;if(!Y||!Number.isFinite(Y))Y=1;if(!W||!Number.isFinite(W))W=1;return{x:Y,y:W}}var PG0=t7(0);function ii(J){let Q=t8(J);if(!eN()||!Q.visualViewport)return PG0;return{x:Q.visualViewport.offsetLeft,y:Q.visualViewport.offsetTop}}function IG0(J,Q,Z){if(Q===void 0)Q=!1;if(!Z||Q&&Z!==t8(J))return!1;return Q}function UX(J,Q,Z,q){if(Q===void 0)Q=!1;if(Z===void 0)Z=!1;let X=J.getBoundingClientRect(),K=iA(J),Y=t7(1);if(Q)if(q){if(V7(q))Y=iY(q)}else Y=iY(J);let W=IG0(K,Z,q)?ii(K):t7(0),z=(X.left+W.x)/Y.x,G=(X.top+W.y)/Y.y,$=X.width/Y.x,H=X.height/Y.y;if(K){let _=t8(K),F=q&&V7(q)?t8(q):q,U=_,V=JB(U);while(V&&q&&F!==U){let B=iY(V),N=V.getBoundingClientRect(),L=N7(V),D=N.left+(V.clientLeft+parseFloat(L.paddingLeft))*B.x,O=N.top+(V.clientTop+parseFloat(L.paddingTop))*B.y;z*=B.x,G*=B.y,$*=B.x,H*=B.y,z+=D,G+=O,U=t8(V),V=JB(U)}}return GX({width:$,height:H,x:z,y:G})}function QB(J,Q){let Z=$$(J).scrollLeft;if(!Q)return UX(J2(J)).left+Z;return Q.left+Z}function ni(J,Q){let Z=J.getBoundingClientRect(),q=Z.left+Q.scrollLeft-QB(J,Z),X=Z.top+Q.scrollTop;return{x:q,y:X}}function wG0(J){let{elements:Q,rect:Z,offsetParent:q,strategy:X}=J,K=X==="fixed",Y=J2(q),W=Q?H$(Q.floating):!1;if(q===Y||W&&K)return Z;let z={scrollLeft:0,scrollTop:0},G=t7(1),$=t7(0),H=i2(q);if(H||!H&&!K){if(_X(q)!=="body"||dY(Y))z=$$(q);if(H){let F=UX(q);G=iY(q),$.x=F.x+q.clientLeft,$.y=F.y+q.clientTop}}let _=Y&&!H&&!K?ni(Y,z):t7(0);return{width:Z.width*G.x,height:Z.height*G.y,x:Z.x*G.x-z.scrollLeft*G.x+$.x+_.x,y:Z.y*G.y-z.scrollTop*G.y+$.y+_.y}}function bG0(J){return Array.from(J.getClientRects())}function TG0(J){let Q=J2(J),Z=$$(J),q=J.ownerDocument.body,X=I8(Q.scrollWidth,Q.clientWidth,q.scrollWidth,q.clientWidth),K=I8(Q.scrollHeight,Q.clientHeight,q.scrollHeight,q.clientHeight),Y=-Z.scrollLeft+QB(J),W=-Z.scrollTop;if(N7(q).direction==="rtl")Y+=I8(Q.clientWidth,q.clientWidth)-X;return{width:X,height:K,x:Y,y:W}}var ci=25;function yG0(J,Q){let Z=t8(J),q=J2(J),X=Z.visualViewport,K=q.clientWidth,Y=q.clientHeight,W=0,z=0;if(X){K=X.width,Y=X.height;let $=eN();if(!$||$&&Q==="fixed")W=X.offsetLeft,z=X.offsetTop}let G=QB(q);if(G<=0){let $=q.ownerDocument,H=$.body,_=getComputedStyle(H),F=$.compatMode==="CSS1Compat"?parseFloat(_.marginLeft)+parseFloat(_.marginRight)||0:0,U=Math.abs(q.clientWidth-H.clientWidth-F);if(U<=ci)K-=U}else if(G<=ci)K+=G;return{width:K,height:Y,x:W,y:z}}function xG0(J,Q){let Z=UX(J,!0,Q==="fixed"),q=Z.top+J.clientTop,X=Z.left+J.clientLeft,K=i2(J)?iY(J):t7(1),Y=J.clientWidth*K.x,W=J.clientHeight*K.y,z=X*K.x,G=q*K.y;return{width:Y,height:W,x:z,y:G}}function li(J,Q,Z){let q;if(Q==="viewport")q=yG0(J,Z);else if(Q==="document")q=TG0(J2(J));else if(V7(Q))q=xG0(Q,Z);else{let X=ii(J);q={x:Q.x-X.x,y:Q.y-X.y,width:Q.width,height:Q.height}}return GX(q)}function si(J,Q){let Z=WQ(J);if(Z===Q||!V7(Z)||FX(Z))return!1;return N7(Z).position==="fixed"||si(Z,Q)}function vG0(J,Q){let Z=Q.get(J);if(Z)return Z;let q=$X(J,[],!1).filter((W)=>V7(W)&&_X(W)!=="body"),X=null,K=N7(J).position==="fixed",Y=K?WQ(J):J;while(V7(Y)&&!FX(Y)){let W=N7(Y),z=tN(Y);if(!z&&W.position==="fixed")X=null;if(K?!z&&!X:!z&&W.position==="static"&&!!X&&(X.position==="absolute"||X.position==="fixed")||dY(Y)&&!z&&si(J,Y))q=q.filter(($)=>$!==Y);else X=W;Y=WQ(Y)}return Q.set(J,q),q}function SG0(J){let{element:Q,boundary:Z,rootBoundary:q,strategy:X}=J,Y=[...Z==="clippingAncestors"?H$(Q)?[]:vG0(Q,this._c):[].concat(Z),q],W=li(Q,Y[0],X),z=W.top,G=W.right,$=W.bottom,H=W.left;for(let _=1;_<Y.length;_++){let F=li(Q,Y[_],X);z=I8(F.top,z),G=l2(F.right,G),$=l2(F.bottom,$),H=I8(F.left,H)}return{width:G-H,height:$-z,x:H,y:z}}function fG0(J){let{width:Q,height:Z}=di(J);return{width:Q,height:Z}}function gG0(J,Q,Z){let q=i2(Q),X=J2(Q),K=Z==="fixed",Y=UX(J,!0,K,Q),W={scrollLeft:0,scrollTop:0},z=t7(0);function G(){z.x=QB(X)}if(q||!q&&!K){if(_X(Q)!=="body"||dY(X))W=$$(Q);if(q){let F=UX(Q,!0,K,Q);z.x=F.x+Q.clientLeft,z.y=F.y+Q.clientTop}else if(X)G()}if(K&&!q&&X)G();let $=X&&!q&&!K?ni(X,W):t7(0),H=Y.left+W.scrollLeft-z.x-$.x,_=Y.top+W.scrollTop-z.y-$.y;return{x:H,y:_,width:Y.width,height:Y.height}}function dA(J){return N7(J).position==="static"}function pi(J,Q){if(!i2(J)||N7(J).position==="fixed")return null;if(Q)return Q(J);let Z=J.offsetParent;if(J2(J)===Z)Z=Z.ownerDocument.body;return Z}function ri(J,Q){let Z=t8(J);if(H$(J))return Z;if(!i2(J)){let X=WQ(J);while(X&&!FX(X)){if(V7(X)&&!dA(X))return X;X=WQ(X)}return Z}let q=pi(J,Q);while(q&&hi(q)&&dA(q))q=pi(q,Q);if(q&&FX(q)&&dA(q)&&!tN(q))return Z;return q||ui(J)||Z}var hG0=async function(J){let Q=this.getOffsetParent||ri,Z=this.getDimensions,q=await Z(J.floating);return{reference:gG0(J.reference,await Q(J.floating),J.strategy),floating:{x:0,y:0,width:q.width,height:q.height}}};function uG0(J){return N7(J).direction==="rtl"}var ai={convertOffsetParentRelativeRectToViewportRelativeRect:wG0,getDocumentElement:J2,getClippingRect:SG0,getOffsetParent:ri,getElementRects:hG0,getClientRects:bG0,getDimensions:fG0,getScale:iY,isElement:V7,isRTL:uG0};function oi(J,Q){return J.x===Q.x&&J.y===Q.y&&J.width===Q.width&&J.height===Q.height}function mG0(J,Q){let Z=null,q,X=J2(J);function K(){var W;clearTimeout(q),(W=Z)==null||W.disconnect(),Z=null}function Y(W,z){if(W===void 0)W=!1;if(z===void 0)z=1;K();let G=J.getBoundingClientRect(),{left:$,top:H,width:_,height:F}=G;if(!W)Q();if(!_||!F)return;let U=G$(H),V=G$(X.clientWidth-($+_)),B=G$(X.clientHeight-(H+F)),N=G$($),D={rootMargin:-U+"px "+-V+"px "+-B+"px "+-N+"px",threshold:I8(0,l2(1,z))||1},O=!0;function j(k){let R=k[0].intersectionRatio;if(R!==z){if(!O)return Y();if(!R)q=setTimeout(()=>{Y(!1,0.0000001)},1000);else Y(!1,R)}if(R===1&&!oi(G,J.getBoundingClientRect()))Y();O=!1}try{Z=new IntersectionObserver(j,{...D,root:X.ownerDocument})}catch(k){Z=new IntersectionObserver(j,D)}Z.observe(J)}return Y(!0),K}function nA(J,Q,Z,q){if(q===void 0)q={};let{ancestorScroll:X=!0,ancestorResize:K=!0,elementResize:Y=typeof ResizeObserver==="function",layoutShift:W=typeof IntersectionObserver==="function",animationFrame:z=!1}=q,G=iA(J),$=X||K?[...G?$X(G):[],...Q?$X(Q):[]]:[];$.forEach((N)=>{X&&N.addEventListener("scroll",Z,{passive:!0}),K&&N.addEventListener("resize",Z)});let H=G&&W?mG0(G,Z):null,_=-1,F=null;if(Y){if(F=new ResizeObserver((N)=>{let[L]=N;if(L&&L.target===G&&F&&Q)F.unobserve(Q),cancelAnimationFrame(_),_=requestAnimationFrame(()=>{var D;(D=F)==null||D.observe(Q)});Z()}),G&&!z)F.observe(G);if(Q)F.observe(Q)}let U,V=z?UX(J):null;if(z)B();function B(){let N=UX(J);if(V&&!oi(V,N))Z();V=N,U=requestAnimationFrame(B)}return Z(),()=>{var N;if($.forEach((L)=>{X&&L.removeEventListener("scroll",Z),K&&L.removeEventListener("resize",Z)}),H==null||H(),(N=F)==null||N.disconnect(),F=null,z)cancelAnimationFrame(U)}}var ti=yi;var ei=xi,Jn=wi,Qn=Si,Zn=bi,sA=Ii;var qn=vi,rA=(J,Q,Z)=>{let q=new Map,X={platform:ai,...Z},K={...X.platform,_c:q};return Pi(J,Q,{...X,platform:K})};var t6=E(m(),1),Kn=E(m(),1),Yn=E(SJ(),1),cG0=typeof document<"u",lG0=function(){},ZB=cG0?Kn.useLayoutEffect:lG0;function qB(J,Q){if(J===Q)return!0;if(typeof J!==typeof Q)return!1;if(typeof J==="function"&&J.toString()===Q.toString())return!0;let Z,q,X;if(J&&Q&&typeof J==="object"){if(Array.isArray(J)){if(Z=J.length,Z!==Q.length)return!1;for(q=Z;q--!==0;)if(!qB(J[q],Q[q]))return!1;return!0}if(X=Object.keys(J),Z=X.length,Z!==Object.keys(Q).length)return!1;for(q=Z;q--!==0;)if(!{}.hasOwnProperty.call(Q,X[q]))return!1;for(q=Z;q--!==0;){let K=X[q];if(K==="_owner"&&J.$$typeof)continue;if(!qB(J[K],Q[K]))return!1}return!0}return J!==J&&Q!==Q}function Wn(J){if(typeof window>"u")return 1;return(J.ownerDocument.defaultView||window).devicePixelRatio||1}function Xn(J,Q){let Z=Wn(J);return Math.round(Q*Z)/Z}function aA(J){let Q=t6.useRef(J);return ZB(()=>{Q.current=J}),Q}function zn(J){if(J===void 0)J={};let{placement:Q="bottom",strategy:Z="absolute",middleware:q=[],platform:X,elements:{reference:K,floating:Y}={},transform:W=!0,whileElementsMounted:z,open:G}=J,[$,H]=t6.useState({x:0,y:0,strategy:Z,placement:Q,middlewareData:{},isPositioned:!1}),[_,F]=t6.useState(q);if(!qB(_,q))F(q);let[U,V]=t6.useState(null),[B,N]=t6.useState(null),L=t6.useCallback((f)=>{if(f!==k.current)k.current=f,V(f)},[]),D=t6.useCallback((f)=>{if(f!==R.current)R.current=f,N(f)},[]),O=K||U,j=Y||B,k=t6.useRef(null),R=t6.useRef(null),P=t6.useRef($),A=z!=null,I=aA(z),C=aA(X),y=aA(G),S=t6.useCallback(()=>{if(!k.current||!R.current)return;let f={placement:Q,strategy:Z,middleware:_};if(C.current)f.platform=C.current;rA(k.current,R.current,f).then((u)=>{let p={...u,isPositioned:y.current!==!1};if(T.current&&!qB(P.current,p))P.current=p,Yn.flushSync(()=>{H(p)})})},[_,Q,Z,C,y]);ZB(()=>{if(G===!1&&P.current.isPositioned)P.current.isPositioned=!1,H((f)=>({...f,isPositioned:!1}))},[G]);let T=t6.useRef(!1);ZB(()=>{return T.current=!0,()=>{T.current=!1}},[]),ZB(()=>{if(O)k.current=O;if(j)R.current=j;if(O&&j){if(I.current)return I.current(O,j,S);S()}},[O,j,S,I,A]);let h=t6.useMemo(()=>({reference:k,floating:R,setReference:L,setFloating:D}),[L,D]),b=t6.useMemo(()=>({reference:O,floating:j}),[O,j]),x=t6.useMemo(()=>{let f={position:Z,left:0,top:0};if(!b.floating)return f;let u=Xn(b.floating,$.x),p=Xn(b.floating,$.y);if(W)return{...f,transform:"translate("+u+"px, "+p+"px)",...Wn(b.floating)>=1.5&&{willChange:"transform"}};return{position:Z,left:u,top:p}},[Z,W,b.floating,$.x,$.y]);return t6.useMemo(()=>({...$,update:S,refs:h,elements:b,floatingStyles:x}),[$,S,h,b,x])}var pG0=(J)=>{function Q(Z){return{}.hasOwnProperty.call(Z,"current")}return{name:"arrow",options:J,fn(Z){let{element:q,padding:X}=typeof J==="function"?J(Z):J;if(q&&Q(q)){if(q.current!=null)return sA({element:q.current,padding:X}).fn(Z);return{}}if(q)return sA({element:q,padding:X}).fn(Z);return{}}}},Gn=(J,Q)=>{let Z=ti(J);return{name:Z.name,fn:Z.fn,options:[J,Q]}},Hn=(J,Q)=>{let Z=ei(J);return{name:Z.name,fn:Z.fn,options:[J,Q]}},$n=(J,Q)=>{return{fn:qn(J).fn,options:[J,Q]}},_n=(J,Q)=>{let Z=Jn(J);return{name:Z.name,fn:Z.fn,options:[J,Q]}},Fn=(J,Q)=>{let Z=Qn(J);return{name:Z.name,fn:Z.fn,options:[J,Q]}};var Un=(J,Q)=>{let Z=Zn(J);return{name:Z.name,fn:Z.fn,options:[J,Q]}};var Vn=(J,Q)=>{let Z=pG0(J);return{name:Z.name,fn:Z.fn,options:[J,Q]}};var Nn=E(m(),1);var oA=E(c(),1),dG0="Arrow",Bn=Nn.forwardRef((J,Q)=>{let{children:Z,width:q=10,height:X=5,...K}=J;return oA.jsx(_0.svg,{...K,ref:Q,width:q,height:X,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:J.asChild?Z:oA.jsx("polygon",{points:"0,0 30,0 15,10"})})});Bn.displayName=dG0;var Ln=Bn;var On=E(m(),1);function XB(J){let[Q,Z]=On.useState(void 0);return f4(()=>{if(J){Z({width:J.offsetWidth,height:J.offsetHeight});let q=new ResizeObserver((X)=>{if(!Array.isArray(X))return;if(!X.length)return;let K=X[0],Y,W;if("borderBoxSize"in K){let z=K.borderBoxSize,G=Array.isArray(z)?z[0]:z;Y=G.inlineSize,W=G.blockSize}else Y=J.offsetWidth,W=J.offsetHeight;Z({width:Y,height:W})});return q.observe(J,{box:"border-box"}),()=>q.unobserve(J)}else Z(void 0)},[J]),Q}var sZ=E(c(),1);var tA="Popper",[Dn,B7]=U4(tA),[nG0,Mn]=Dn(tA),jn=(J)=>{let{__scopePopper:Q,children:Z}=J,[q,X]=d5.useState(null),[K,Y]=d5.useState(void 0);return sZ.jsx(nG0,{scope:Q,anchor:q,onAnchorChange:X,placementState:K,setPlacementState:Y,children:Z})};jn.displayName=tA;var Rn="PopperAnchor",kn=d5.forwardRef((J,Q)=>{let{__scopePopper:Z,virtualRef:q,...X}=J,K=Mn(Rn,Z),Y=d5.useRef(null),W=K.onAnchorChange,z=d5.useCallback((U)=>{if(Y.current=U,U)W(U)},[W]),G=p0(Q,z),$=d5.useRef(null);d5.useEffect(()=>{if(!q)return;let U=$.current;if($.current=q.current,U!==$.current)W($.current)});let H=K.placementState&&JC(K.placementState),_=H?.[0],F=H?.[1];return q?null:sZ.jsx(_0.div,{"data-radix-popper-side":_,"data-radix-popper-align":F,...X,ref:G})});kn.displayName=Rn;var eA="PopperContent",[sG0,rG0]=Dn(eA),En=d5.forwardRef((J,Q)=>{let{__scopePopper:Z,side:q="bottom",sideOffset:X=0,align:K="center",alignOffset:Y=0,arrowPadding:W=0,avoidCollisions:z=!0,collisionBoundary:G=[],collisionPadding:$=0,sticky:H="partial",hideWhenDetached:_=!1,updatePositionStrategy:F="optimized",onPlaced:U,...V}=J,B=Mn(eA,Z),[N,L]=d5.useState(null),D=p0(Q,(O0)=>L(O0)),[O,j]=d5.useState(null),k=XB(O),R=k?.width??0,P=k?.height??0,A=q+(K!=="center"?"-"+K:""),I=typeof $==="number"?$:{top:0,right:0,bottom:0,left:0,...$},C=Array.isArray(G)?G:[G],y=C.length>0,S={padding:I,boundary:C.filter(oG0),altBoundary:y},{refs:T,floatingStyles:h,placement:b,isPositioned:x,middlewareData:f}=zn({strategy:"fixed",placement:A,whileElementsMounted:(...O0)=>{return nA(...O0,{animationFrame:F==="always"})},elements:{reference:B.anchor},middleware:[Gn({mainAxis:X+P,alignmentAxis:Y}),z&&Hn({mainAxis:!0,crossAxis:!1,limiter:H==="partial"?$n():void 0,...S}),z&&_n({...S}),Fn({...S,apply:({elements:O0,rects:Z1,availableWidth:q1,availableHeight:r})=>{let{width:s,height:F0}=Z1.reference,s0=O0.floating.style;s0.setProperty("--radix-popper-available-width",`${q1}px`),s0.setProperty("--radix-popper-available-height",`${r}px`),s0.setProperty("--radix-popper-anchor-width",`${s}px`),s0.setProperty("--radix-popper-anchor-height",`${F0}px`)}}),O&&Vn({element:O,padding:W}),tG0({arrowWidth:R,arrowHeight:P}),_&&Un({strategy:"referenceHidden",...S,boundary:y?S.boundary:void 0})]}),u=B.setPlacementState;f4(()=>{return u(b),()=>{u(void 0)}},[b,u]);let[p,o]=JC(b),K0=$6(U);f4(()=>{if(x)K0?.()},[x,K0]);let U0=f.arrow?.x,y0=f.arrow?.y,D1=f.arrow?.centerOffset!==0,[j0,Y0]=d5.useState();return f4(()=>{if(N)Y0(window.getComputedStyle(N).zIndex)},[N]),sZ.jsx("div",{ref:T.setFloating,"data-radix-popper-content-wrapper":"",style:{...h,transform:x?h.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:j0,"--radix-popper-transform-origin":[f.transformOrigin?.x,f.transformOrigin?.y].join(" "),...f.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:J.dir,children:sZ.jsx(sG0,{scope:Z,placedSide:p,placedAlign:o,onArrowChange:j,arrowX:U0,arrowY:y0,shouldHideArrow:D1,children:sZ.jsx(_0.div,{"data-side":p,"data-align":o,...V,ref:D,style:{...V.style,animation:!x?"none":void 0}})})})});En.displayName=eA;var An="PopperArrow",aG0={top:"bottom",right:"left",bottom:"top",left:"right"},Cn=d5.forwardRef(function(Q,Z){let{__scopePopper:q,...X}=Q,K=rG0(An,q),Y=aG0[K.placedSide];return sZ.jsx("span",{ref:K.onArrowChange,style:{position:"absolute",left:K.arrowX,top:K.arrowY,[Y]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[K.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[K.placedSide],visibility:K.shouldHideArrow?"hidden":void 0},children:sZ.jsx(Ln,{...X,ref:Z,style:{...X.style,display:"block"}})})});Cn.displayName=An;function oG0(J){return J!==null}var tG0=(J)=>({name:"transformOrigin",options:J,fn(Q){let{placement:Z,rects:q,middlewareData:X}=Q,Y=X.arrow?.centerOffset!==0,W=Y?0:J.arrowWidth,z=Y?0:J.arrowHeight,[G,$]=JC(Z),H={start:"0%",center:"50%",end:"100%"}[$],_=(X.arrow?.x??0)+W/2,F=(X.arrow?.y??0)+z/2,U="",V="";if(G==="bottom")U=Y?H:`${_}px`,V=`${-z}px`;else if(G==="top")U=Y?H:`${_}px`,V=`${q.floating.height+z}px`;else if(G==="right")U=`${-z}px`,V=Y?H:`${F}px`;else if(G==="left")U=`${q.floating.width+z}px`,V=Y?H:`${F}px`;return{data:{x:U,y:V}}}});function JC(J){let[Q,Z="center"]=J.split("-");return[Q,Z]}var zQ=jn,GQ=kn,rZ=En,aZ=Cn;var YB=E(m(),1),Pn=E(SJ(),1);var In=E(c(),1),eG0="Portal",m9=YB.forwardRef((J,Q)=>{let{container:Z,...q}=J,[X,K]=YB.useState(!1);f4(()=>K(!0),[]);let Y=Z||X&&globalThis?.document?.body;return Y?Pn.createPortal(In.jsx(_0.div,{...q,ref:Q}),Y):null});m9.displayName=eG0;var z8=E(m(),1);var bn=E(m(),1);function JH0(J,Q){return bn.useReducer((Z,q)=>{return Q[Z][q]??Z},J)}var e6=(J)=>{let{present:Q,children:Z}=J,q=QH0(Q),X=typeof Z==="function"?Z({present:q.isPresent}):z8.Children.only(Z),K=ZH0(q.ref,qH0(X));return typeof Z==="function"||q.isPresent?z8.cloneElement(X,{ref:K}):null};e6.displayName="Presence";function QH0(J){let[Q,Z]=z8.useState(),q=z8.useRef(null),X=z8.useRef(J),K=z8.useRef("none"),Y=J?"mounted":"unmounted",[W,z]=JH0(Y,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return z8.useEffect(()=>{let G=WB(q.current);K.current=W==="mounted"?G:"none"},[W]),f4(()=>{let G=q.current,$=X.current;if($!==J){let _=K.current,F=WB(G);if(J)z("MOUNT");else if(F==="none"||G?.display==="none")z("UNMOUNT");else if($&&_!==F)z("ANIMATION_OUT");else z("UNMOUNT");X.current=J}},[J,z]),f4(()=>{if(Q){let G,$=Q.ownerDocument.defaultView??window,H=(F)=>{let V=WB(q.current).includes(CSS.escape(F.animationName));if(F.target===Q&&V){if(z("ANIMATION_END"),!X.current){let B=Q.style.animationFillMode;Q.style.animationFillMode="forwards",G=$.setTimeout(()=>{if(Q.style.animationFillMode==="forwards")Q.style.animationFillMode=B})}}},_=(F)=>{if(F.target===Q)K.current=WB(q.current)};return Q.addEventListener("animationstart",_),Q.addEventListener("animationcancel",H),Q.addEventListener("animationend",H),()=>{$.clearTimeout(G),Q.removeEventListener("animationstart",_),Q.removeEventListener("animationcancel",H),Q.removeEventListener("animationend",H)}}else z("ANIMATION_END")},[Q,z]),{isPresent:["mounted","unmountSuspended"].includes(W),ref:z8.useCallback((G)=>{q.current=G?getComputedStyle(G):null,Z(G)},[])}}function wn(J,Q){if(typeof J==="function")return J(Q);else if(J!==null&&J!==void 0)J.current=Q}function ZH0(...J){let Q=z8.useRef(J);return Q.current=J,z8.useCallback((Z)=>{let q=Q.current,X=!1,K=q.map((Y)=>{let W=wn(Y,Z);if(!X&&typeof W==="function")X=!0;return W});if(X)return()=>{for(let Y=0;Y<K.length;Y++){let W=K[Y];if(typeof W==="function")W();else wn(q[Y],null)}}},[])}function WB(J){return J?.animationName||"none"}function qH0(J){let Q=Object.getOwnPropertyDescriptor(J.props,"ref")?.get,Z=Q&&"isReactWarning"in Q&&Q.isReactWarning;if(Z)return J.ref;if(Q=Object.getOwnPropertyDescriptor(J,"ref")?.get,Z=Q&&"isReactWarning"in Q&&Q.isReactWarning,Z)return J.props.ref;return J.props.ref||J.ref}var C5=E(m(),1);var L7=E(m(),1);var zB=E(m(),1);var XH0=L7[" useInsertionEffect ".trim().toString()]||f4;function g4({prop:J,defaultProp:Q,onChange:Z=()=>{},caller:q}){let[X,K,Y]=KH0({defaultProp:Q,onChange:Z}),W=J!==void 0,z=W?J:X;{let $=L7.useRef(J!==void 0);L7.useEffect(()=>{let H=$.current;if(H!==W)console.warn(`${q} is changing from ${H?"controlled":"uncontrolled"} to ${W?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`);$.current=W},[W,q])}let G=L7.useCallback(($)=>{if(W){let H=YH0($)?$(J):$;if(H!==J)Y.current?.(H)}else K($)},[W,J,K,Y]);return[z,G]}function KH0({defaultProp:J,onChange:Q}){let[Z,q]=L7.useState(J),X=L7.useRef(Z),K=L7.useRef(Q);return XH0(()=>{K.current=Q},[Q]),L7.useEffect(()=>{if(X.current!==Z)K.current?.(Z),X.current=Z},[Z,X]),[Z,q,K]}function YH0(J){return typeof J==="function"}var De0=Symbol("RADIX:SYNC_STATE");var oZ=E(c(),1),QC="rovingFocusGroup.onEntryFocus",WH0={bubbles:!1,cancelable:!0},_$="RovingFocusGroup",[ZC,Tn,zH0]=c2(_$),[GH0,HQ]=U4(_$,[zH0]),[HH0,$H0]=GH0(_$),yn=C5.forwardRef((J,Q)=>{return oZ.jsx(ZC.Provider,{scope:J.__scopeRovingFocusGroup,children:oZ.jsx(ZC.Slot,{scope:J.__scopeRovingFocusGroup,children:oZ.jsx(_H0,{...J,ref:Q})})})});yn.displayName=_$;var _H0=C5.forwardRef((J,Q)=>{let{__scopeRovingFocusGroup:Z,orientation:q,loop:X=!1,dir:K,currentTabStopId:Y,defaultCurrentTabStopId:W,onCurrentTabStopIdChange:z,onEntryFocus:G,preventScrollOnEntryFocus:$=!1,...H}=J,_=C5.useRef(null),F=p0(Q,_),U=_7(K),[V,B]=g4({prop:Y,defaultProp:W??null,onChange:z,caller:_$}),[N,L]=C5.useState(!1),D=$6(G),O=Tn(Z),j=C5.useRef(!1),[k,R]=C5.useState(0);return C5.useEffect(()=>{let P=_.current;if(P)return P.addEventListener(QC,D),()=>P.removeEventListener(QC,D)},[D]),oZ.jsx(HH0,{scope:Z,orientation:q,dir:U,loop:X,currentTabStopId:V,onItemFocus:C5.useCallback((P)=>B(P),[B]),onItemShiftTab:C5.useCallback(()=>L(!0),[]),onFocusableItemAdd:C5.useCallback(()=>R((P)=>P+1),[]),onFocusableItemRemove:C5.useCallback(()=>R((P)=>P-1),[]),children:oZ.jsx(_0.div,{tabIndex:N||k===0?-1:0,"data-orientation":q,...H,ref:F,style:{outline:"none",...J.style},onMouseDown:Z0(J.onMouseDown,()=>{j.current=!0}),onFocus:Z0(J.onFocus,(P)=>{let A=!j.current;if(P.target===P.currentTarget&&A&&!N){let I=new CustomEvent(QC,WH0);if(P.currentTarget.dispatchEvent(I),!I.defaultPrevented){let C=O().filter((b)=>b.focusable),y=C.find((b)=>b.active),S=C.find((b)=>b.id===V),h=[y,S,...C].filter(Boolean).map((b)=>b.ref.current);Sn(h,$)}}j.current=!1}),onBlur:Z0(J.onBlur,()=>L(!1))})})}),xn="RovingFocusGroupItem",vn=C5.forwardRef((J,Q)=>{let{__scopeRovingFocusGroup:Z,focusable:q=!0,active:X=!1,tabStopId:K,children:Y,...W}=J,z=o6(),G=K||z,$=$H0(xn,Z),H=$.currentTabStopId===G,_=Tn(Z),{onFocusableItemAdd:F,onFocusableItemRemove:U,currentTabStopId:V}=$;return C5.useEffect(()=>{if(q)return F(),()=>U()},[q,F,U]),oZ.jsx(ZC.ItemSlot,{scope:Z,id:G,focusable:q,active:X,children:oZ.jsx(_0.span,{tabIndex:H?0:-1,"data-orientation":$.orientation,...W,ref:Q,onMouseDown:Z0(J.onMouseDown,(B)=>{if(!q)B.preventDefault();else $.onItemFocus(G)}),onFocus:Z0(J.onFocus,()=>$.onItemFocus(G)),onKeyDown:Z0(J.onKeyDown,(B)=>{if(B.key==="Tab"&&B.shiftKey){$.onItemShiftTab();return}if(B.target!==B.currentTarget)return;let N=VH0(B,$.orientation,$.dir);if(N!==void 0){if(B.metaKey||B.ctrlKey||B.altKey||B.shiftKey)return;B.preventDefault();let D=_().filter((O)=>O.focusable).map((O)=>O.ref.current);if(N==="last")D.reverse();else if(N==="prev"||N==="next"){if(N==="prev")D.reverse();let O=D.indexOf(B.currentTarget);D=$.loop?NH0(D,O+1):D.slice(O+1)}setTimeout(()=>Sn(D))}}),children:typeof Y==="function"?Y({isCurrentTabStop:H,hasTabStop:V!=null}):Y})})});vn.displayName=xn;var FH0={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function UH0(J,Q){if(Q!=="rtl")return J;return J==="ArrowLeft"?"ArrowRight":J==="ArrowRight"?"ArrowLeft":J}function VH0(J,Q,Z){let q=UH0(J.key,Z);if(Q==="vertical"&&["ArrowLeft","ArrowRight"].includes(q))return;if(Q==="horizontal"&&["ArrowUp","ArrowDown"].includes(q))return;return FH0[q]}function Sn(J,Q=!1){let Z=document.activeElement;for(let q of J){if(q===Z)return;if(q.focus({preventScroll:Q}),document.activeElement!==Z)return}}function NH0(J,Q){return J.map((Z,q)=>J[(Q+q)%J.length])}var nY=yn,VX=vn;var BH0=function(J){if(typeof document>"u")return null;var Q=Array.isArray(J)?J[0]:J;return Q.ownerDocument.body},sY=new WeakMap,GB=new WeakMap,HB={},XC=0,fn=function(J){return J&&(J.host||fn(J.parentNode))},LH0=function(J,Q){return Q.map(function(Z){if(J.contains(Z))return Z;var q=fn(Z);if(q&&J.contains(q))return q;return console.error("aria-hidden",Z,"in not contained inside",J,". Doing nothing"),null}).filter(function(Z){return Boolean(Z)})},OH0=function(J,Q,Z,q){var X=LH0(Q,Array.isArray(J)?J:[J]);if(!HB[Z])HB[Z]=new WeakMap;var K=HB[Z],Y=[],W=new Set,z=new Set(X),G=function(H){if(!H||W.has(H))return;W.add(H),G(H.parentNode)};X.forEach(G);var $=function(H){if(!H||z.has(H))return;Array.prototype.forEach.call(H.children,function(_){if(W.has(_))$(_);else try{var F=_.getAttribute(q),U=F!==null&&F!=="false",V=(sY.get(_)||0)+1,B=(K.get(_)||0)+1;if(sY.set(_,V),K.set(_,B),Y.push(_),V===1&&U)GB.set(_,!0);if(B===1)_.setAttribute(Z,"true");if(!U)_.setAttribute(q,"true")}catch(N){console.error("aria-hidden: cannot operate on ",_,N)}})};return $(Q),W.clear(),XC++,function(){if(Y.forEach(function(H){var _=sY.get(H)-1,F=K.get(H)-1;if(sY.set(H,_),K.set(H,F),!_){if(!GB.has(H))H.removeAttribute(q);GB.delete(H)}if(!F)H.removeAttribute(Z)}),XC--,!XC)sY=new WeakMap,sY=new WeakMap,GB=new WeakMap,HB={}}},tZ=function(J,Q,Z){if(Z===void 0)Z="data-aria-hidden";var q=Array.from(Array.isArray(J)?J:[J]),X=Q||BH0(J);if(!X)return function(){return null};return q.push.apply(q,Array.from(X.querySelectorAll("[aria-live], script"))),OH0(q,X,Z,"aria-hidden")};var e8=function(){return e8=Object.assign||function(Q){for(var Z,q=1,X=arguments.length;q<X;q++){Z=arguments[q];for(var K in Z)if(Object.prototype.hasOwnProperty.call(Z,K))Q[K]=Z[K]}return Q},e8.apply(this,arguments)};function $B(J,Q){var Z={};for(var q in J)if(Object.prototype.hasOwnProperty.call(J,q)&&Q.indexOf(q)<0)Z[q]=J[q];if(J!=null&&typeof Object.getOwnPropertySymbols==="function"){for(var X=0,q=Object.getOwnPropertySymbols(J);X<q.length;X++)if(Q.indexOf(q[X])<0&&Object.prototype.propertyIsEnumerable.call(J,q[X]))Z[q[X]]=J[q[X]]}return Z}function gn(J,Q,Z){if(Z||arguments.length===2){for(var q=0,X=Q.length,K;q<X;q++)if(K||!(q in Q)){if(!K)K=Array.prototype.slice.call(Q,0,q);K[q]=Q[q]}}return J.concat(K||Array.prototype.slice.call(Q))}var NB=E(m(),1);var G8=E(m(),1);var NX="right-scroll-bar-position",BX="width-before-scroll-bar",KC="with-scroll-bars-hidden",YC="--removed-body-scroll-bar-size";var FB=E(m(),1);function _B(J,Q){if(typeof J==="function")J(Q);else if(J)J.current=Q;return J}var hn=E(m(),1);function un(J,Q){var Z=hn.useState(function(){return{value:J,callback:Q,facade:{get current(){return Z.value},set current(q){var X=Z.value;if(X!==q)Z.value=q,Z.callback(q,X)}}}})[0];return Z.callback=Q,Z.facade}var DH0=typeof window<"u"?FB.useLayoutEffect:FB.useEffect,mn=new WeakMap;function WC(J,Q){var Z=un(Q||null,function(q){return J.forEach(function(X){return _B(X,q)})});return DH0(function(){var q=mn.get(Z);if(q){var X=new Set(q),K=new Set(J),Y=Z.current;X.forEach(function(W){if(!K.has(W))_B(W,null)}),K.forEach(function(W){if(!X.has(W))_B(W,Y)})}mn.set(Z,J)},[J]),Z}function MH0(J){return J}function jH0(J,Q){if(Q===void 0)Q=MH0;var Z=[],q=!1,X={read:function(){if(q)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");if(Z.length)return Z[Z.length-1];return J},useMedium:function(K){var Y=Q(K,q);return Z.push(Y),function(){Z=Z.filter(function(W){return W!==Y})}},assignSyncMedium:function(K){q=!0;while(Z.length){var Y=Z;Z=[],Y.forEach(K)}Z={push:function(W){return K(W)},filter:function(){return Z}}},assignMedium:function(K){q=!0;var Y=[];if(Z.length){var W=Z;Z=[],W.forEach(K),Y=Z}var z=function(){var $=Y;Y=[],$.forEach(K)},G=function(){return Promise.resolve().then(z)};G(),Z={push:function($){Y.push($),G()},filter:function($){return Y=Y.filter($),Z}}}};return X}function zC(J){if(J===void 0)J={};var Q=jH0(null);return Q.options=e8({async:!0,ssr:!1},J),Q}var cn=E(m(),1),ln=function(J){var Q=J.sideCar,Z=$B(J,["sideCar"]);if(!Q)throw Error("Sidecar: please provide `sideCar` property to import the right car");var q=Q.read();if(!q)throw Error("Sidecar medium not found");return cn.createElement(q,e8({},Z))};ln.isSideCarExport=!0;function GC(J,Q){return J.useMedium(Q),ln}var UB=zC();var HC=function(){return},F$=G8.forwardRef(function(J,Q){var Z=G8.useRef(null),q=G8.useState({onScrollCapture:HC,onWheelCapture:HC,onTouchMoveCapture:HC}),X=q[0],K=q[1],Y=J.forwardProps,W=J.children,z=J.className,G=J.removeScrollBar,$=J.enabled,H=J.shards,_=J.sideCar,F=J.noRelative,U=J.noIsolation,V=J.inert,B=J.allowPinchZoom,N=J.as,L=N===void 0?"div":N,D=J.gapMode,O=$B(J,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),j=_,k=WC([Z,Q]),R=e8(e8({},O),X);return G8.createElement(G8.Fragment,null,$&&G8.createElement(j,{sideCar:UB,removeScrollBar:G,shards:H,noRelative:F,noIsolation:U,inert:V,setCallbacks:K,allowPinchZoom:!!B,lockRef:Z,gapMode:D}),Y?G8.cloneElement(G8.Children.only(W),e8(e8({},R),{ref:k})):G8.createElement(L,e8({},R,{className:z,ref:k}),W))});F$.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};F$.classNames={fullWidth:BX,zeroRight:NX};var s4=E(m(),1);var aY=E(m(),1);var nn=E(m(),1);var pn;var dn=function(){if(pn)return pn;if(typeof __webpack_nonce__<"u")return __webpack_nonce__;return};function RH0(){if(!document)return null;var J=document.createElement("style");J.type="text/css";var Q=dn();if(Q)J.setAttribute("nonce",Q);return J}function kH0(J,Q){if(J.styleSheet)J.styleSheet.cssText=Q;else J.appendChild(document.createTextNode(Q))}function EH0(J){var Q=document.head||document.getElementsByTagName("head")[0];Q.appendChild(J)}var $C=function(){var J=0,Q=null;return{add:function(Z){if(J==0){if(Q=RH0())kH0(Q,Z),EH0(Q)}J++},remove:function(){if(J--,!J&&Q)Q.parentNode&&Q.parentNode.removeChild(Q),Q=null}}};var _C=function(){var J=$C();return function(Q,Z){nn.useEffect(function(){return J.add(Q),function(){J.remove()}},[Q&&Z])}};var U$=function(){var J=_C(),Q=function(Z){var{styles:q,dynamic:X}=Z;return J(q,X),null};return Q};var AH0={left:0,top:0,right:0,gap:0},FC=function(J){return parseInt(J||"",10)||0},CH0=function(J){var Q=window.getComputedStyle(document.body),Z=Q[J==="padding"?"paddingLeft":"marginLeft"],q=Q[J==="padding"?"paddingTop":"marginTop"],X=Q[J==="padding"?"paddingRight":"marginRight"];return[FC(Z),FC(q),FC(X)]},UC=function(J){if(J===void 0)J="margin";if(typeof window>"u")return AH0;var Q=CH0(J),Z=document.documentElement.clientWidth,q=window.innerWidth;return{left:Q[0],top:Q[1],right:Q[2],gap:Math.max(0,q-Z+Q[2]-Q[0])}};var PH0=U$(),rY="data-scroll-locked",IH0=function(J,Q,Z,q){var{left:X,top:K,right:Y,gap:W}=J;if(Z===void 0)Z="margin";return`
376
+ `)}var Pd={"&amp;":"&","&quot;":'"',"&apos;":"'","&#27;":"'","&#34;":'"',"&#38;":"&","&#39;":"'","&#8211;":"–","&#8212;":"—","&#8216;":"‘","&#8217;":"’","&#8220;":"“","&#8221;":"”","&#8230;":"…"},hz0=new RegExp(Object.keys(Pd).join("|"),"g");function IA(J){return J.replace(hz0,(Q)=>Pd[Q])}function uz0(J){return J.replace(/[ \t]+$/gm,"").replace(/\n+$/,"")}function Id(J){return uz0(gz0(fz0(J)))}var wA=5000,bd=10485760;function bA(J,Q){J.registerExternalAssetHandler("file",async(Z)=>{return Td(J,Z,Q)}),J.registerExternalAssetHandler("url",async(Z)=>{return xd(J,Z,Q)}),J.registerExternalContentHandler("svg-text",async(Z)=>{return vd(J,Z)}),J.registerExternalContentHandler("embed",(Z)=>{return Sd(J,Z)}),J.registerExternalContentHandler("files",async(Z)=>{return fd(J,Z,Q)}),J.registerExternalContentHandler("file-replace",async(Z)=>{return yd(J,Z,Q)}),J.registerExternalContentHandler("text",async(Z)=>{return hY(J,Z)}),J.registerExternalContentHandler("url",async(Z)=>{return gd(J,Z,Q)}),J.registerExternalContentHandler("tldraw",async(Z)=>{return hd(J,Z)}),J.registerExternalContentHandler("excalidraw",async(Z)=>{return ud(J,Z)})}async function Td(J,{file:Q,assetId:Z},q){if(!SN(J,Q,q))Q0(!1,"File checks failed");let K=await yA(Q);if(!K)Q0(!1,"SVG file contained no safe content");let Y=await fN(J,K,Z);if(!Y)Q0(!1,`No asset util found for MIME type "${Q.type}"`);let W=await J.uploadAsset(Y,K);if(Y.props.src=W.src,W.meta)Y.meta={...Y.meta,...W.meta};return k9.create(Y)}async function yd(J,{file:Q,shapeId:Z},q){if(!SN(J,Q,q))Q0(!1,"File checks failed");let K=await yA(Q);if(!K)return;let Y=J.getShape(Z);if(!Y)Q0(!1,"Shape not found");let W=FF(await K.arrayBuffer()),z=k9.createId(W);J.createTemporaryAssetPreview(z,K);let G=await fN(J,K,z);if(!G)return;if(J.createAssets([G]),Y.type==="image"){let H=Y,_=H.props.crop,F=G.props.w,U=G.props.h,V=H.x,B=H.y,N=_;if(_){let L=cl(H,G.props.w,G.props.h);N=L.crop,F=L.w,U=L.h,V=L.x,B=L.y}J.updateShapes([{id:H.id,type:H.type,props:{assetId:z,crop:N,w:F,h:U},x:V,y:B}])}else if(Y.type==="video")J.updateShapes([{id:Y.id,type:Y.type,props:{assetId:z,w:G.props.w,h:G.props.h}}]);let $=await J.getAssetForExternalContent({type:"file",file:K,assetId:z});return J.updateAssets([{...$,id:z}]),$}async function xd(J,{url:Q},{toasts:Z,msg:q}){let X;try{let Y=await(await b6(Q,{method:"GET",mode:"no-cors"})).text(),W=new DOMParser().parseFromString(Y,"text/html");if(X={image:W.head.querySelector('meta[property="og:image"]')?.getAttribute("content")??"",favicon:W.head.querySelector('link[rel="apple-touch-icon"]')?.getAttribute("href")??W.head.querySelector('link[rel="icon"]')?.getAttribute("href")??"",title:W.head.querySelector('meta[property="og:title"]')?.getAttribute("content")??Q,description:W.head.querySelector('meta[property="og:description"]')?.getAttribute("content")??""},!X.image.startsWith("http"))X.image=new URL(X.image,Q).href;if(!X.favicon.startsWith("http"))X.favicon=new URL(X.favicon,Q).href}catch(K){console.error(K),Z.addToast({title:q("assets.url.failed"),severity:"error"}),X={image:"",favicon:"",title:"",description:""}}return{id:k9.createId(sq(Q)),typeName:"asset",type:"bookmark",props:{src:Q,description:X.description,image:X.image,favicon:X.favicon,title:X.title},meta:{}}}async function vd(J,{point:Q,text:Z}){let{sanitizeSvg:q}=await import("/chunk-xgt7vxt9.js");if(Z=q(Z),!Z)return;let X=Q??(J.inputs.getShiftKey()?J.inputs.getCurrentPagePoint():J.getViewportPageBounds().center),K=new DOMParser().parseFromString(Z,"image/svg+xml").querySelector("svg");if(!K)throw Error("No <svg/> element present");let Y=parseFloat(K.getAttribute("width")||"0"),W=parseFloat(K.getAttribute("height")||"0");if(!(Y&&W)){let G=J.getContainerDocument();G.body.appendChild(K);let $=K.getBoundingClientRect();G.body.removeChild(K),Y=$.width,W=$.height}let z=await J.getAssetForExternalContent({type:"file",file:new File([Z],"asset.svg",{type:"image/svg+xml"})});if(!z)throw Error("Could not create an asset");TA(J,[z],X)}function Sd(J,{point:Q,url:Z,embed:q}){let X=Q??(J.inputs.getShiftKey()?J.inputs.getCurrentPagePoint():J.getViewportPageBounds().center),{width:K,height:Y}=q,W=l0(),z=j6(new M(X.x-(K||450)/2,X.y-(Y||450)/2),J),G={id:W,type:"embed",x:z.x,y:z.y,props:{w:K,h:Y,url:Z}};if(J.canCreateShape(G))J.createShape(G).select(W)}async function fd(J,{point:Q,files:Z},q){let{toasts:X,msg:K}=q;if(Z.length>J.options.maxFilesAtOnce){X.addToast({title:K("assets.files.amount-too-many"),severity:"error"});return}let Y=Q??(J.inputs.getShiftKey()?J.inputs.getCurrentPagePoint():J.getViewportPageBounds().center),W=new M(Y.x,Y.y),z=[],G=[];for(let $ of Z){if(!SN(J,$,q))continue;let _=await yA($);if(!_){X.addToast({title:K("assets.files.upload-failed"),severity:"error"});continue}let F=await fN(J,_);if(!F)continue;if(F.type==="image")J.createTemporaryAssetPreview(F.id,_);z.push(F),G.push({asset:F,file:_})}Promise.allSettled(G.map(async($)=>{try{let H=await J.getAssetForExternalContent({type:"file",file:$.file});if(!H)throw Error("Could not create an asset");J.updateAssets([{...H,id:$.asset.id}])}catch(H){X.addToast({title:K("assets.files.upload-failed"),severity:"error"}),console.error(H),J.deleteAssets([$.asset.id]);return}})),TA(J,z,W)}async function hY(J,{point:Q,text:Z,html:q}){let X=Q??(J.inputs.getShiftKey()?J.inputs.getCurrentPagePoint():J.getViewportPageBounds().center),K=J.getShapeUtil("text").getDefaultProps(),Y=Id(Z),W=q?PA(J,q):x1(Y),z,G,$,H="middle",_=h9(J,W),F=W.content.length>1,U=vN(Y);if(F)H=F?U?"end":"start":"middle";let V=J.getCurrentTheme(),B=J.textMeasure.measureHtml(_,{...G5,lineHeight:V.lineHeight,fontFamily:g9(V,K.font),fontSize:V.fontSize*o3[K.size],maxWidth:null}),N=Math.min(F?J.getViewportPageBounds().width*0.9:920,Math.max(200,J.getViewportPageBounds().width*0.9));if(B.w>N){let O=J.textMeasure.measureHtml(_,{...G5,lineHeight:V.lineHeight,fontFamily:g9(V,K.font),fontSize:V.fontSize*o3[K.size],maxWidth:N});z=O.w,G=O.h,$=!1,H=U?"end":"start"}else z=Math.max(B.w,10),G=Math.max(B.h,10),$=!0;if(X.y-G/2<J.getViewportPageBounds().minY+40)X.y=J.getViewportPageBounds().minY+40+G/2;let L=j6(new M(X.x-z/2,X.y-G/2),J),D=l0();J.createShapes([{id:D,type:"text",x:L.x,y:L.y,props:{richText:W,textAlign:H,autoSize:$,w:z}}])}async function gd(J,{point:Q,url:Z},{toasts:q,msg:X}){let Y=J.getShapeUtil("embed")?.getEmbedDefinition(Z);if(Y&&Y.definition.embedOnPaste!==!1)return J.putExternalContent({type:"embed",url:Y.url,point:Q,embed:Y.definition});let W=Q??(J.inputs.getShiftKey()?J.inputs.getCurrentPagePoint():J.getViewportPageBounds().center);if(!(await cH(J,{url:Z,center:W})).ok){q.addToast({title:X("assets.url.failed"),severity:"error"});return}}async function hd(J,{point:Q,content:Z}){J.run(()=>{let q=J.getSelectionPageBounds();J.markHistoryStoppingPoint("paste");for(let Y of Z.shapes)if(Z.rootShapeIds.includes(Y.id))Y.isLocked=!1;let X=J.isInAny("select.dragging_handle","select.translating","select.resizing","select.rotating");J.putContentOntoCurrentPage(Z,{point:Q,select:!X});let K=J.getSelectionPageBounds();if(!X&&q&&K&&q?.collides(K))J.updateInstanceState({isChangingStyle:!0}),J.timers.setTimeout(()=>{J.updateInstanceState({isChangingStyle:!1})},150)})}async function ud(J,{point:Q,content:Z}){J.run(()=>{xE(J,Z,Q)})}async function TA(J,Q,Z){if(!Q.length)return[];let q=M.From(Z),X=[];for(let K=0;K<Q.length;K++){let Y=Q[K],z=J.getShapeUtilForAssetType(Y.type)?.createShapeForAsset?.(Y,q)??null;if(z){if(X.push(z),"w"in Y.props&&typeof Y.props.w==="number")q.x+=Y.props.w}}return J.run(()=>{let K=Q.filter((Y)=>!J.getAsset(Y.id));J.store.atomic(()=>{if(J.canCreateShapes(X)){if(K.length)J.createAssets(K);J.createShapes(X).select(...X.map((Y)=>Y.id)),md(J,Z)}})}),X.map((K)=>K.id)}function md(J,Q){let Z=J.getViewportPageBounds(),q=J.getSelectionPageBounds();if(q){let X=q.center.sub(Q);J.updateShapes(J.getSelectedShapes().map((K)=>{let Y=J.getShapeParentTransform(K).decompose().rotation,W=M.Rot(X,-Y);return{id:K.id,type:K.type,x:K.x-W.x,y:K.y-W.y}}))}if(q=J.getSelectionPageBounds(),q&&J.getInstanceState().isGridMode){let X=J.getDocumentSettings().gridSize,K=new M(q.minX,q.minY),Y=K.clone().snapToGrid(X),W=M.Sub(K,Y);J.updateShapes(J.getSelectedShapes().map((z)=>{let G={x:z.x-W.x,y:z.y-W.y};return{id:z.id,type:z.type,x:G.x,y:G.y}}))}if(q=J.getSelectionPageBounds(),q&&!Z.contains(q))J.zoomToSelection({animation:{duration:J.options.animationMediumMs}})}async function yA(J){if(J.type!=="image/svg+xml")return J;try{let Q=await J.text(),{sanitizeSvg:Z}=await import("/chunk-xgt7vxt9.js"),q=Z(Q);if(!q)return null;return new File([q],J.name,{type:J.type,lastModified:J.lastModified})}catch{return null}}function SN(J,Q,Z){let{maxAssetSize:q=bd,acceptedImageMimeTypes:X,acceptedVideoMimeTypes:K,toasts:Y,msg:W}=Z;if(!(!!J.getAssetUtilForMimeType(Q.type)||(X?.includes(Q.type)??!1)||(K?.includes(Q.type)??!1)))return Y.addToast({title:W("assets.files.type-not-allowed"),severity:"error"}),!1;if(Q.size>q){let G=($)=>{if($===0)return"0 bytes";let H=["bytes","KB","MB","GB","TB","PB"],_=1024,F=Math.floor(Math.log($)/Math.log(_)),U=$/Math.pow(_,F);return`${U%1===0?U.toString():U.toFixed(1)} ${H[F]}`};return Y.addToast({title:W("assets.files.size-too-big"),description:W("assets.files.maximum-size").replace("{size}",G(q)),severity:"error"}),!1}if(!Q.type)return Y.addToast({title:W("assets.files.upload-failed"),severity:"error"}),console.error("No mime type"),!1;return!0}async function fN(J,Q,Z){if(!Z){let X=FF(await Q.arrayBuffer());Z=k9.createId(X)}let q=J.getAssetUtilForMimeType(Q.type);if(!q)return null;return await q.getAssetFromFile(Q,Z)}async function xA(J,Q,Z){let q=Z.name;if(!q){if(q=`shapes at ${cd()}`,Q.length===1){let Y=J.getShape(Q[0]);if(J.isShapeOfType(Y,"frame"))q=Y.props.name||"frame";else q=`${dK(Y.id)} at ${cd()}`}}q+=`.${Z.format}`;let{blob:X}=await J.toImage(Q,Z),K=new File([X],q,{type:X.type});gN(K,J.getContainerDocument())}function cd(){let J=new Date,Q=String(J.getFullYear()).slice(2),Z=String(J.getMonth()+1).padStart(2,"0"),q=String(J.getDate()).padStart(2,"0"),X=String(J.getHours()).padStart(2,"0"),K=String(J.getMinutes()).padStart(2,"0"),Y=String(J.getSeconds()).padStart(2,"0");return`${Q}-${Z}-${q} ${X}.${K}.${Y}`}function gN(J,Q){let Z=(Q??_4()).createElement("a"),q=URL.createObjectURL(J);Z.href=q,Z.download=J.name,Z.click(),URL.revokeObjectURL(q)}function hN(J,Q){let Z=D0(Q.map((X)=>J.getShape(X)).filter((X)=>X&&J.isShapeFrameLike(X)));if(!Z.length)return;let q=[];J.run(()=>{Z.map((X)=>{let K=J.getSortedChildIdsForParent(X.id);if(K.length)z1(J,K,{filter:(Y)=>!Z.find((W)=>W.id===Y.id)}),q.push(...K)}),J.setSelectedShapes(q),J.deleteShapes(Q)})}var ld=50;function vA(J,Q,Z={padding:ld}){let q=d.FromPoints(J.flatMap((G)=>{if(!G)return[];let $=Q.getShapeGeometry(G.id);return Q.getShapeLocalTransform(G)?.applyToPoints($.vertices)??[]})),X=Z.padding??ld,K=q.w+2*X,Y=q.h+2*X,W=X-q.minX,z=X-q.minY;return{w:K,h:Y,dx:W,dy:z}}function uY(J,Q,Z={}){let q=J.getShape(Q);if(!q||!J.isShapeFrameLike(q))return;let X=J.getSortedChildIdsForParent(q.id),K=D0(X.map((H)=>J.getShape(H)));if(!K.length)return;let{w:Y,h:W,dx:z,dy:G}=vA(K,J,Z);if(z===0&&G===0&&q.props.w===Y&&q.props.h===W)return;let $=new M(z,G).rot(q.rotation);J.run(()=>{let H=X.map((_)=>{let F=J.getShape(_);return{id:F.id,type:F.type,x:F.x+z,y:F.y+G}});H.push({id:q.id,type:q.type,x:q.x-$.x,y:q.y-$.y,props:{w:Y,h:W}}),J.updateShapes(H)})}var q5=E(c(),1);var R7=E(m(),1);var GI=E(c(),1),va=E(c1(),1),Sa=E(m(),1);var n5=E(c(),1);var $8={};f7($8,{createContextMenuScope:()=>V$0,Trigger:()=>w$0,SubTrigger:()=>l$0,SubContent:()=>p$0,Sub:()=>c$0,Separator:()=>u$0,Root:()=>I$0,RadioItem:()=>g$0,RadioGroup:()=>f$0,Portal:()=>b$0,Label:()=>x$0,ItemIndicator:()=>h$0,Item:()=>v$0,Group:()=>y$0,ContextMenuTrigger:()=>PC,ContextMenuSubTrigger:()=>mC,ContextMenuSubContent:()=>cC,ContextMenuSub:()=>uC,ContextMenuSeparator:()=>gC,ContextMenuRadioItem:()=>SC,ContextMenuRadioGroup:()=>vC,ContextMenuPortal:()=>IC,ContextMenuLabel:()=>TC,ContextMenuItemIndicator:()=>fC,ContextMenuItem:()=>yC,ContextMenuGroup:()=>bC,ContextMenuContent:()=>wC,ContextMenuCheckboxItem:()=>xC,ContextMenuArrow:()=>hC,ContextMenu:()=>CC,Content:()=>T$0,CheckboxItem:()=>S$0,Arrow:()=>m$0});var M4=E(m(),1);var $t0=!!(typeof window<"u"&&window.document&&window.document.createElement);function Z0(J,Q,{checkForDefaultPrevented:Z=!0}={}){return function(X){if(J?.(X),Z===!1||!X.defaultPrevented)return Q?.(X)}}var KQ=E(m(),1),pd=E(c(),1);function U4(J,Q=[]){let Z=[];function q(K,Y){let W=KQ.createContext(Y);W.displayName=K+"Context";let z=Z.length;Z=[...Z,Y];let G=(H)=>{let{scope:_,children:F,...U}=H,V=_?.[J]?.[z]||W,B=KQ.useMemo(()=>U,Object.values(U));return pd.jsx(V.Provider,{value:B,children:F})};G.displayName=K+"Provider";function $(H,_){let F=_?.[J]?.[z]||W,U=KQ.useContext(F);if(U)return U;if(Y!==void 0)return Y;throw Error(`\`${H}\` must be used within \`${K}\``)}return[G,$]}let X=()=>{let K=Z.map((Y)=>{return KQ.createContext(Y)});return function(W){let z=W?.[J]||K;return KQ.useMemo(()=>({[`__scope${J}`]:{...W,[J]:z}}),[W,z])}};return X.scopeName=J,[q,mz0(X,...Q)]}function mz0(...J){let Q=J[0];if(J.length===1)return Q;let Z=()=>{let q=J.map((X)=>({useScope:X(),scopeName:X.scopeName}));return function(K){let Y=q.reduce((W,{useScope:z,scopeName:G})=>{let H=z(K)[`__scope${G}`];return{...W,...H}},{});return KQ.useMemo(()=>({[`__scope${Q.scopeName}`]:Y}),[Y])}};return Z.scopeName=Q.scopeName,Z}var rd=E(m(),1),ad=E(SJ(),1);var mY={};f7(mY,{createSlottable:()=>mN,createSlot:()=>P8,Slottable:()=>lz0,Slot:()=>cz0,Root:()=>cz0});var p5=E(m(),1);var id=E(m(),1);function dd(J,Q){if(typeof J==="function")return J(Q);else if(J!==null&&J!==void 0)J.current=Q}function Y$(...J){return(Q)=>{let Z=!1,q=J.map((X)=>{let K=dd(X,Q);if(!Z&&typeof K=="function")Z=!0;return K});if(Z)return()=>{for(let X=0;X<q.length;X++){let K=q[X];if(typeof K=="function")K();else dd(J[X],null)}}}}function p0(...J){return id.useCallback(Y$(...J),J)}function P8(J){let Q=p5.forwardRef((Z,q)=>{let{children:X,...K}=Z,Y=null,W=!1,z=[];if(nd(X)&&typeof uN==="function")X=uN(X._payload);if(p5.Children.forEach(X,(_)=>{if(nz0(_)){W=!0;let F=_,U="child"in F.props?F.props.child:F.props.children;if(nd(U)&&typeof uN==="function")U=uN(U._payload);Y=pz0(F,U),z.push(Y?.props?.children)}else z.push(_)}),Y)Y=p5.cloneElement(Y,void 0,z);else if(!W&&p5.Children.count(X)===1&&p5.isValidElement(X))Y=X;let G=Y?iz0(Y):void 0,$=p0(q,G);if(!Y){if(X||X===0)throw Error(W?oz0(J):az0(J));return X}let H=dz0(K,Y.props??{});if(Y.type!==p5.Fragment)H.ref=q?$:G;return p5.cloneElement(Y,H)});return Q.displayName=`${J}.Slot`,Q}var cz0=P8("Slot"),sd=Symbol.for("radix.slottable");function mN(J){let Q=(Z)=>("child"in Z)?Z.children(Z.child):Z.children;return Q.displayName=`${J}.Slottable`,Q.__radixId=sd,Q}var lz0=mN("Slottable"),pz0=(J,Q)=>{if("child"in J.props){let Z=J.props.child;if(!p5.isValidElement(Z))return null;return p5.cloneElement(Z,void 0,J.props.children(Z.props.children))}return p5.isValidElement(Q)?Q:null};function dz0(J,Q){let Z={...Q};for(let q in Q){let X=J[q],K=Q[q];if(/^on[A-Z]/.test(q)){if(X&&K)Z[q]=(...W)=>{let z=K(...W);return X(...W),z};else if(X)Z[q]=X}else if(q==="style")Z[q]={...X,...K};else if(q==="className")Z[q]=[X,K].filter(Boolean).join(" ")}return{...J,...Z}}function iz0(J){let Q=Object.getOwnPropertyDescriptor(J.props,"ref")?.get,Z=Q&&"isReactWarning"in Q&&Q.isReactWarning;if(Z)return J.ref;if(Q=Object.getOwnPropertyDescriptor(J,"ref")?.get,Z=Q&&"isReactWarning"in Q&&Q.isReactWarning,Z)return J.props.ref;return J.props.ref||J.ref}function nz0(J){return p5.isValidElement(J)&&typeof J.type==="function"&&"__radixId"in J.type&&J.type.__radixId===sd}var sz0=Symbol.for("react.lazy");function nd(J){return J!=null&&typeof J==="object"&&"$$typeof"in J&&J.$$typeof===sz0&&"_payload"in J&&rz0(J._payload)}function rz0(J){return typeof J==="object"&&J!==null&&"then"in J}var az0=(J)=>{return`${J} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`},oz0=(J)=>{return`${J} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`},uN=p5[" use ".trim().toString()];var od=E(c(),1),tz0=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],_0=tz0.reduce((J,Q)=>{let Z=P8(`Primitive.${Q}`),q=rd.forwardRef((X,K)=>{let{asChild:Y,...W}=X,z=Y?Z:Q;if(typeof window<"u")window[Symbol.for("radix-ui")]=!0;return od.jsx(z,{...W,ref:K})});return q.displayName=`Primitive.${Q}`,{...J,[Q]:q}},{});function cY(J,Q){if(J)ad.flushSync(()=>J.dispatchEvent(Q))}var T0=E(m(),1);var o7=E(m(),1);var cN=E(c(),1),lN=E(m(),1);var JG0=E(c(),1);function c2(J){let Q=J+"CollectionProvider",[Z,q]=U4(Q),[X,K]=Z(Q,{collectionRef:{current:null},itemMap:new Map}),Y=(V)=>{let{scope:B,children:N}=V,L=o7.useRef(null),D=o7.useRef(new Map).current;return cN.jsx(X,{scope:B,itemMap:D,collectionRef:L,children:N})};Y.displayName=Q;let W=J+"CollectionSlot",z=P8(W),G=o7.forwardRef((V,B)=>{let{scope:N,children:L}=V,D=K(W,N),O=p0(B,D.collectionRef);return cN.jsx(z,{ref:O,children:L})});G.displayName=W;let $=J+"CollectionItemSlot",H="data-radix-collection-item",_=P8($),F=o7.forwardRef((V,B)=>{let{scope:N,children:L,...D}=V,O=o7.useRef(null),j=p0(B,O),k=K($,N);return o7.useEffect(()=>{return k.itemMap.set(O,{ref:O,...D}),()=>void k.itemMap.delete(O)}),cN.jsx(_,{...{[H]:""},ref:j,children:L})});F.displayName=$;function U(V){let B=K(J+"CollectionConsumer",V);return o7.useCallback(()=>{let L=B.collectionRef.current;if(!L)return[];let D=Array.from(L.querySelectorAll(`[${H}]`));return Array.from(B.itemMap.values()).sort((k,R)=>D.indexOf(k.ref.current)-D.indexOf(R.ref.current))},[B.collectionRef,B.itemMap])}return[{Provider:Y,Slot:G,ItemSlot:F},U,q]}var td=new WeakMap,Mt0=class J extends Map{#J;constructor(Q){super(Q);this.#J=[...super.keys()],td.set(this,!0)}set(Q,Z){if(td.get(this))if(this.has(Q))this.#J[this.#J.indexOf(Q)]=Q;else this.#J.push(Q);return super.set(Q,Z),this}insert(Q,Z,q){let X=this.has(Z),K=this.#J.length,Y=ed(Q),W=Y>=0?Y:K+Y,z=W<0||W>=K?-1:W;if(z===this.size||X&&z===this.size-1||z===-1)return this.set(Z,q),this;let G=this.size+(X?0:1);if(Y<0)W++;let $=[...this.#J],H,_=!1;for(let F=W;F<G;F++)if(W===F){let U=$[F];if($[F]===Z)U=$[F+1];if(X)this.delete(Z);H=this.get(U),this.set(Z,q)}else{if(!_&&$[F-1]===Z)_=!0;let U=$[_?F:F-1],V=H;H=this.get(U),this.delete(U),this.set(U,V)}return this}with(Q,Z,q){let X=new J(this);return X.insert(Q,Z,q),X}before(Q){let Z=this.#J.indexOf(Q)-1;if(Z<0)return;return this.entryAt(Z)}setBefore(Q,Z,q){let X=this.#J.indexOf(Q);if(X===-1)return this;return this.insert(X,Z,q)}after(Q){let Z=this.#J.indexOf(Q);if(Z=Z===-1||Z===this.size-1?-1:Z+1,Z===-1)return;return this.entryAt(Z)}setAfter(Q,Z,q){let X=this.#J.indexOf(Q);if(X===-1)return this;return this.insert(X+1,Z,q)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return this.#J=[],super.clear()}delete(Q){let Z=super.delete(Q);if(Z)this.#J.splice(this.#J.indexOf(Q),1);return Z}deleteAt(Q){let Z=this.keyAt(Q);if(Z!==void 0)return this.delete(Z);return!1}at(Q){let Z=SA(this.#J,Q);if(Z!==void 0)return this.get(Z)}entryAt(Q){let Z=SA(this.#J,Q);if(Z!==void 0)return[Z,this.get(Z)]}indexOf(Q){return this.#J.indexOf(Q)}keyAt(Q){return SA(this.#J,Q)}from(Q,Z){let q=this.indexOf(Q);if(q===-1)return;let X=q+Z;if(X<0)X=0;if(X>=this.size)X=this.size-1;return this.at(X)}keyFrom(Q,Z){let q=this.indexOf(Q);if(q===-1)return;let X=q+Z;if(X<0)X=0;if(X>=this.size)X=this.size-1;return this.keyAt(X)}find(Q,Z){let q=0;for(let X of this){if(Reflect.apply(Q,Z,[X,q,this]))return X;q++}return}findIndex(Q,Z){let q=0;for(let X of this){if(Reflect.apply(Q,Z,[X,q,this]))return q;q++}return-1}filter(Q,Z){let q=[],X=0;for(let K of this){if(Reflect.apply(Q,Z,[K,X,this]))q.push(K);X++}return new J(q)}map(Q,Z){let q=[],X=0;for(let K of this)q.push([K[0],Reflect.apply(Q,Z,[K,X,this])]),X++;return new J(q)}reduce(...Q){let[Z,q]=Q,X=0,K=q??this.at(0);for(let Y of this){if(X===0&&Q.length===1)K=Y;else K=Reflect.apply(Z,this,[K,Y,X,this]);X++}return K}reduceRight(...Q){let[Z,q]=Q,X=q??this.at(-1);for(let K=this.size-1;K>=0;K--){let Y=this.at(K);if(K===this.size-1&&Q.length===1)X=Y;else X=Reflect.apply(Z,this,[X,Y,K,this])}return X}toSorted(Q){let Z=[...this.entries()].sort(Q);return new J(Z)}toReversed(){let Q=new J;for(let Z=this.size-1;Z>=0;Z--){let q=this.keyAt(Z),X=this.get(q);Q.set(q,X)}return Q}toSpliced(...Q){let Z=[...this.entries()];return Z.splice(...Q),new J(Z)}slice(Q,Z){let q=new J,X=this.size-1;if(Q===void 0)return q;if(Q<0)Q=Q+this.size;if(Z!==void 0&&Z>0)X=Z-1;for(let K=Q;K<=X;K++){let Y=this.keyAt(K),W=this.get(Y);q.set(Y,W)}return q}every(Q,Z){let q=0;for(let X of this){if(!Reflect.apply(Q,Z,[X,q,this]))return!1;q++}return!0}some(Q,Z){let q=0;for(let X of this){if(Reflect.apply(Q,Z,[X,q,this]))return!0;q++}return!1}};function SA(J,Q){if("at"in Array.prototype)return Array.prototype.at.call(J,Q);let Z=ez0(J,Q);return Z===-1?void 0:J[Z]}function ez0(J,Q){let Z=J.length,q=ed(Q),X=q>=0?q:Z+q;return X<0||X>=Z?-1:X}function ed(J){return J!==J||J===0?0:Math.trunc(J)}var pN=E(m(),1),QG0=E(c(),1),ZG0=pN.createContext(void 0);function _7(J){let Q=pN.useContext(ZG0);return J||Q||"ltr"}var W4=E(m(),1);var lY=E(m(),1);function $6(J){let Q=lY.useRef(J);return lY.useEffect(()=>{Q.current=J}),lY.useMemo(()=>(...Z)=>Q.current?.(...Z),[])}var Ji=E(m(),1);function Qi(J,Q=globalThis?.document){let Z=$6(J);Ji.useEffect(()=>{let q=(X)=>{if(X.key==="Escape")Z(X)};return Q.addEventListener("keydown",q,{capture:!0}),()=>Q.removeEventListener("keydown",q,{capture:!0})},[Z,Q])}var gA=E(c(),1),qG0="DismissableLayer",fA="dismissableLayer.update",XG0="dismissableLayer.pointerDownOutside",KG0="dismissableLayer.focusOutside",Zi,hA=W4.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),F7=W4.forwardRef((J,Q)=>{let{disableOutsidePointerEvents:Z=!1,deferPointerDownOutside:q=!1,onEscapeKeyDown:X,onPointerDownOutside:K,onFocusOutside:Y,onInteractOutside:W,onDismiss:z,...G}=J,$=W4.useContext(hA),[H,_]=W4.useState(null),F=H?.ownerDocument??globalThis?.document,[,U]=W4.useState({}),V=p0(Q,(A)=>_(A)),B=Array.from($.layers),[N]=[...$.layersWithOutsidePointerEventsDisabled].slice(-1),L=B.indexOf(N),D=H?B.indexOf(H):-1,O=$.layersWithOutsidePointerEventsDisabled.size>0,j=D>=L,k=W4.useRef(!1),R=WG0((A)=>{let I=A.target;if(!(I instanceof Node))return;let C=[...$.branches].some((y)=>y.contains(I));if(!j||C)return;if(K?.(A),W?.(A),!A.defaultPrevented)z?.()},{ownerDocument:F,deferPointerDownOutside:q,isDeferredPointerDownOutsideRef:k,dismissableSurfaces:$.dismissableSurfaces}),P=zG0((A)=>{if(q&&k.current)return;let I=A.target;if([...$.branches].some((y)=>y.contains(I)))return;if(Y?.(A),W?.(A),!A.defaultPrevented)z?.()},F);return Qi((A)=>{if(D!==$.layers.size-1)return;if(X?.(A),!A.defaultPrevented&&z)A.preventDefault(),z()},F),W4.useEffect(()=>{if(!H)return;if(Z){if($.layersWithOutsidePointerEventsDisabled.size===0)Zi=F.body.style.pointerEvents,F.body.style.pointerEvents="none";$.layersWithOutsidePointerEventsDisabled.add(H)}return $.layers.add(H),qi(),()=>{if(Z){if($.layersWithOutsidePointerEventsDisabled.delete(H),$.layersWithOutsidePointerEventsDisabled.size===0)F.body.style.pointerEvents=Zi}}},[H,F,Z,$]),W4.useEffect(()=>{return()=>{if(!H)return;$.layers.delete(H),$.layersWithOutsidePointerEventsDisabled.delete(H),qi()}},[H,$]),W4.useEffect(()=>{let A=()=>U({});return document.addEventListener(fA,A),()=>document.removeEventListener(fA,A)},[]),gA.jsx(_0.div,{...G,ref:V,style:{pointerEvents:O?j?"auto":"none":void 0,...J.style},onFocusCapture:Z0(J.onFocusCapture,P.onFocusCapture),onBlurCapture:Z0(J.onBlurCapture,P.onBlurCapture),onPointerDownCapture:Z0(J.onPointerDownCapture,R.onPointerDownCapture)})});F7.displayName=qG0;var YG0="DismissableLayerBranch",Xi=W4.forwardRef((J,Q)=>{let Z=W4.useContext(hA),q=W4.useRef(null),X=p0(Q,q);return W4.useEffect(()=>{let K=q.current;if(K)return Z.branches.add(K),()=>{Z.branches.delete(K)}},[Z.branches]),gA.jsx(_0.div,{...J,ref:X})});Xi.displayName=YG0;function Ki(){let J=W4.useContext(hA),[Q,Z]=W4.useState(null);return W4.useEffect(()=>{if(!Q)return;return J.dismissableSurfaces.add(Q),()=>{J.dismissableSurfaces.delete(Q)}},[Q,J.dismissableSurfaces]),Z}function WG0(J,Q){let{ownerDocument:Z=globalThis?.document,deferPointerDownOutside:q=!1,isDeferredPointerDownOutsideRef:X,dismissableSurfaces:K}=Q,Y=$6(J),W=W4.useRef(!1),z=W4.useRef(!1),G=W4.useRef(new Map),$=W4.useRef(()=>{});return W4.useEffect(()=>{function H(){z.current=!1,X.current=!1,G.current.clear()}function _(){return Array.from(G.current.values()).some(Boolean)}function F(L){if(!z.current)return;let D=L.target;if(!(D instanceof Node&&[...K].some((j)=>j.contains(D))))G.current.set(L.type,!0);if(L.type==="click")window.setTimeout(()=>{if(z.current)$.current()},0)}function U(L){if(z.current)G.current.set(L.type,!1)}let V=(L)=>{if(L.target&&!W.current){let O=function(){Z.removeEventListener("click",$.current);let k=_();if(H(),!k)Yi(XG0,Y,j,{discrete:!0})};var D=O;let j={originalEvent:L};if(z.current=!0,X.current=q&&L.button===0,G.current.clear(),!q||L.button!==0)O();else Z.removeEventListener("click",$.current),$.current=O,Z.addEventListener("click",$.current,{once:!0})}else Z.removeEventListener("click",$.current),H();W.current=!1},B=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(let L of B)Z.addEventListener(L,F,!0),Z.addEventListener(L,U);let N=window.setTimeout(()=>{Z.addEventListener("pointerdown",V)},0);return()=>{window.clearTimeout(N),Z.removeEventListener("pointerdown",V),Z.removeEventListener("click",$.current);for(let L of B)Z.removeEventListener(L,F,!0),Z.removeEventListener(L,U)}},[Z,Y,q,X,K]),{onPointerDownCapture:()=>W.current=!0}}function zG0(J,Q=globalThis?.document){let Z=$6(J),q=W4.useRef(!1);return W4.useEffect(()=>{let X=(K)=>{if(K.target&&!q.current)Yi(KG0,Z,{originalEvent:K},{discrete:!1})};return Q.addEventListener("focusin",X),()=>Q.removeEventListener("focusin",X)},[Q,Z]),{onFocusCapture:()=>q.current=!0,onBlurCapture:()=>q.current=!1}}function qi(){let J=new CustomEvent(fA);document.dispatchEvent(J)}function Yi(J,Q,Z,{discrete:q}){let X=Z.originalEvent.target,K=new CustomEvent(J,{bubbles:!1,cancelable:!0,detail:Z});if(Q)X.addEventListener(J,Q,{once:!0});if(q)cY(X,K);else X.dispatchEvent(K)}var Wi=F7,zi=Xi;var Hi=E(m(),1),dN=0,pY=null;function iZ(){Hi.useEffect(()=>{if(!pY)pY={start:Gi(),end:Gi()};let{start:J,end:Q}=pY;if(document.body.firstElementChild!==J)document.body.insertAdjacentElement("afterbegin",J);if(document.body.lastElementChild!==Q)document.body.insertAdjacentElement("beforeend",Q);return dN++,()=>{if(dN===1)pY?.start.remove(),pY?.end.remove(),pY=null;dN=Math.max(0,dN-1)}},[])}function Gi(){let J=document.createElement("span");return J.setAttribute("data-radix-focus-guard",""),J.tabIndex=0,J.style.outline="none",J.style.opacity="0",J.style.position="fixed",J.style.pointerEvents="none",J}var U7=E(m(),1);var Vi=E(c(),1),uA="focusScope.autoFocusOnMount",mA="focusScope.autoFocusOnUnmount",$i={bubbles:!1,cancelable:!0},HG0="FocusScope",YQ=U7.forwardRef((J,Q)=>{let{loop:Z=!1,trapped:q=!1,onMountAutoFocus:X,onUnmountAutoFocus:K,...Y}=J,[W,z]=U7.useState(null),G=$6(X),$=$6(K),H=U7.useRef(null),_=p0(Q,(V)=>z(V)),F=U7.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;U7.useEffect(()=>{if(q){let L=function(k){if(F.paused||!W)return;let R=k.target;if(W.contains(R))H.current=R;else nZ(H.current,{select:!0})},D=function(k){if(F.paused||!W)return;let R=k.relatedTarget;if(R===null)return;if(!W.contains(R))nZ(H.current,{select:!0})},O=function(k){if(document.activeElement!==document.body)return;for(let P of k)if(P.removedNodes.length>0)nZ(W)};var V=L,B=D,N=O;document.addEventListener("focusin",L),document.addEventListener("focusout",D);let j=new MutationObserver(O);if(W)j.observe(W,{childList:!0,subtree:!0});return()=>{document.removeEventListener("focusin",L),document.removeEventListener("focusout",D),j.disconnect()}}},[q,W,F.paused]),U7.useEffect(()=>{if(W){Fi.add(F);let V=document.activeElement;if(!W.contains(V)){let N=new CustomEvent(uA,$i);if(W.addEventListener(uA,G),W.dispatchEvent(N),!N.defaultPrevented){if($G0(NG0(Ni(W)),{select:!0}),document.activeElement===V)nZ(W)}}return()=>{W.removeEventListener(uA,G),setTimeout(()=>{let N=new CustomEvent(mA,$i);if(W.addEventListener(mA,$),W.dispatchEvent(N),!N.defaultPrevented)nZ(V??document.body,{select:!0});W.removeEventListener(mA,$),Fi.remove(F)},0)}}},[W,G,$,F]);let U=U7.useCallback((V)=>{if(!Z&&!q)return;if(F.paused)return;let B=V.key==="Tab"&&!V.altKey&&!V.ctrlKey&&!V.metaKey,N=document.activeElement;if(B&&N){let L=V.currentTarget,[D,O]=_G0(L);if(!(D&&O)){if(N===L)V.preventDefault()}else if(!V.shiftKey&&N===O){if(V.preventDefault(),Z)nZ(D,{select:!0})}else if(V.shiftKey&&N===D){if(V.preventDefault(),Z)nZ(O,{select:!0})}}},[Z,q,F.paused]);return Vi.jsx(_0.div,{tabIndex:-1,...Y,ref:_,onKeyDown:U})});YQ.displayName=HG0;function $G0(J,{select:Q=!1}={}){let Z=document.activeElement;for(let q of J)if(nZ(q,{select:Q}),document.activeElement!==Z)return}function _G0(J){let Q=Ni(J),Z=_i(Q,J),q=_i(Q.reverse(),J);return[Z,q]}function Ni(J){let Q=[],Z=document.createTreeWalker(J,NodeFilter.SHOW_ELEMENT,{acceptNode:(q)=>{let X=q.tagName==="INPUT"&&q.type==="hidden";if(q.disabled||q.hidden||X)return NodeFilter.FILTER_SKIP;return q.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});while(Z.nextNode())Q.push(Z.currentNode);return Q}function _i(J,Q){for(let Z of J)if(!FG0(Z,{upTo:Q}))return Z}function FG0(J,{upTo:Q}){if(getComputedStyle(J).visibility==="hidden")return!0;while(J){if(Q!==void 0&&J===Q)return!1;if(getComputedStyle(J).display==="none")return!0;J=J.parentElement}return!1}function UG0(J){return J instanceof HTMLInputElement&&"select"in J}function nZ(J,{select:Q=!1}={}){if(J&&J.focus){let Z=document.activeElement;if(J.focus({preventScroll:!0}),J!==Z&&UG0(J)&&Q)J.select()}}var Fi=VG0();function VG0(){let J=[];return{add(Q){let Z=J[0];if(Q!==Z)Z?.pause();J=Ui(J,Q),J.unshift(Q)},remove(Q){J=Ui(J,Q),J[0]?.resume()}}}function Ui(J,Q){let Z=[...J],q=Z.indexOf(Q);if(q!==-1)Z.splice(q,1);return Z}function NG0(J){return J.filter((Q)=>Q.tagName!=="A")}var cA=E(m(),1);var Bi=E(m(),1),f4=globalThis?.document?Bi.useLayoutEffect:()=>{};var BG0=cA[" useId ".trim().toString()]||(()=>{return}),LG0=0;function o6(J){let[Q,Z]=cA.useState(BG0());return f4(()=>{if(!J)Z((q)=>q??String(LG0++))},[J]),J||(Q?`radix-${Q}`:"")}var d5=E(m(),1);var Di=["top","right","bottom","left"];var{min:l2,max:I8,round:z$,floor:G$}=Math,t7=(J)=>({x:J,y:J}),OG0={left:"right",right:"left",bottom:"top",top:"bottom"};function nN(J,Q,Z){return I8(J,l2(Q,Z))}function p2(J,Q){return typeof J==="function"?J(Q):J}function d2(J){return J.split("-")[0]}function zX(J){return J.split("-")[1]}function sN(J){return J==="x"?"y":"x"}function rN(J){return J==="y"?"height":"width"}function e7(J){let Q=J[0];return Q==="t"||Q==="b"?"y":"x"}function aN(J){return sN(e7(J))}function Mi(J,Q,Z){if(Z===void 0)Z=!1;let q=zX(J),X=aN(J),K=rN(X),Y=X==="x"?q===(Z?"end":"start")?"right":"left":q==="start"?"bottom":"top";if(Q.reference[K]>Q.floating[K])Y=W$(Y);return[Y,W$(Y)]}function ji(J){let Q=W$(J);return[iN(J),Q,iN(Q)]}function iN(J){return J.includes("start")?J.replace("start","end"):J.replace("end","start")}var Li=["left","right"],Oi=["right","left"],DG0=["top","bottom"],MG0=["bottom","top"];function jG0(J,Q,Z){switch(J){case"top":case"bottom":if(Z)return Q?Oi:Li;return Q?Li:Oi;case"left":case"right":return Q?DG0:MG0;default:return[]}}function Ri(J,Q,Z,q){let X=zX(J),K=jG0(d2(J),Z==="start",q);if(X){if(K=K.map((Y)=>Y+"-"+X),Q)K=K.concat(K.map(iN))}return K}function W$(J){let Q=d2(J);return OG0[Q]+J.slice(Q.length)}function RG0(J){return{top:0,right:0,bottom:0,left:0,...J}}function lA(J){return typeof J!=="number"?RG0(J):{top:J,right:J,bottom:J,left:J}}function GX(J){let{x:Q,y:Z,width:q,height:X}=J;return{width:q,height:X,top:Z,left:Q,right:Q+q,bottom:Z+X,x:Q,y:Z}}function ki(J,Q,Z){let{reference:q,floating:X}=J,K=e7(Q),Y=aN(Q),W=rN(Y),z=d2(Q),G=K==="y",$=q.x+q.width/2-X.width/2,H=q.y+q.height/2-X.height/2,_=q[W]/2-X[W]/2,F;switch(z){case"top":F={x:$,y:q.y-X.height};break;case"bottom":F={x:$,y:q.y+q.height};break;case"right":F={x:q.x+q.width,y:H};break;case"left":F={x:q.x-X.width,y:H};break;default:F={x:q.x,y:q.y}}switch(zX(Q)){case"start":F[Y]-=_*(Z&&G?-1:1);break;case"end":F[Y]+=_*(Z&&G?-1:1);break}return F}async function Ci(J,Q){var Z;if(Q===void 0)Q={};let{x:q,y:X,platform:K,rects:Y,elements:W,strategy:z}=J,{boundary:G="clippingAncestors",rootBoundary:$="viewport",elementContext:H="floating",altBoundary:_=!1,padding:F=0}=p2(Q,J),U=lA(F),B=W[_?H==="floating"?"reference":"floating":H],N=GX(await K.getClippingRect({element:((Z=await(K.isElement==null?void 0:K.isElement(B)))!=null?Z:!0)?B:B.contextElement||await(K.getDocumentElement==null?void 0:K.getDocumentElement(W.floating)),boundary:G,rootBoundary:$,strategy:z})),L=H==="floating"?{x:q,y:X,width:Y.floating.width,height:Y.floating.height}:Y.reference,D=await(K.getOffsetParent==null?void 0:K.getOffsetParent(W.floating)),O=await(K.isElement==null?void 0:K.isElement(D))?await(K.getScale==null?void 0:K.getScale(D))||{x:1,y:1}:{x:1,y:1},j=GX(K.convertOffsetParentRelativeRectToViewportRelativeRect?await K.convertOffsetParentRelativeRectToViewportRelativeRect({elements:W,rect:L,offsetParent:D,strategy:z}):L);return{top:(N.top-j.top+U.top)/O.y,bottom:(j.bottom-N.bottom+U.bottom)/O.y,left:(N.left-j.left+U.left)/O.x,right:(j.right-N.right+U.right)/O.x}}var kG0=50,Pi=async(J,Q,Z)=>{let{placement:q="bottom",strategy:X="absolute",middleware:K=[],platform:Y}=Z,W=Y.detectOverflow?Y:{...Y,detectOverflow:Ci},z=await(Y.isRTL==null?void 0:Y.isRTL(Q)),G=await Y.getElementRects({reference:J,floating:Q,strategy:X}),{x:$,y:H}=ki(G,q,z),_=q,F=0,U={};for(let V=0;V<K.length;V++){let B=K[V];if(!B)continue;let{name:N,fn:L}=B,{x:D,y:O,data:j,reset:k}=await L({x:$,y:H,initialPlacement:q,placement:_,strategy:X,middlewareData:U,rects:G,platform:W,elements:{reference:J,floating:Q}});if($=D!=null?D:$,H=O!=null?O:H,U[N]={...U[N],...j},k&&F<kG0){if(F++,typeof k==="object"){if(k.placement)_=k.placement;if(k.rects)G=k.rects===!0?await Y.getElementRects({reference:J,floating:Q,strategy:X}):k.rects;({x:$,y:H}=ki(G,_,z))}V=-1}}return{x:$,y:H,placement:_,strategy:X,middlewareData:U}},Ii=(J)=>({name:"arrow",options:J,async fn(Q){let{x:Z,y:q,placement:X,rects:K,platform:Y,elements:W,middlewareData:z}=Q,{element:G,padding:$=0}=p2(J,Q)||{};if(G==null)return{};let H=lA($),_={x:Z,y:q},F=aN(X),U=rN(F),V=await Y.getDimensions(G),B=F==="y",N=B?"top":"left",L=B?"bottom":"right",D=B?"clientHeight":"clientWidth",O=K.reference[U]+K.reference[F]-_[F]-K.floating[U],j=_[F]-K.reference[F],k=await(Y.getOffsetParent==null?void 0:Y.getOffsetParent(G)),R=k?k[D]:0;if(!R||!await(Y.isElement==null?void 0:Y.isElement(k)))R=W.floating[D]||K.floating[U];let P=O/2-j/2,A=R/2-V[U]/2-1,I=l2(H[N],A),C=l2(H[L],A),y=I,S=R-V[U]-C,T=R/2-V[U]/2+P,h=nN(y,T,S),b=!z.arrow&&zX(X)!=null&&T!==h&&K.reference[U]/2-(T<y?I:C)-V[U]/2<0,x=b?T<y?T-y:T-S:0;return{[F]:_[F]+x,data:{[F]:h,centerOffset:T-h-x,...b&&{alignmentOffset:x}},reset:b}}});var wi=function(J){if(J===void 0)J={};return{name:"flip",options:J,async fn(Q){var Z,q;let{placement:X,middlewareData:K,rects:Y,initialPlacement:W,platform:z,elements:G}=Q,{mainAxis:$=!0,crossAxis:H=!0,fallbackPlacements:_,fallbackStrategy:F="bestFit",fallbackAxisSideDirection:U="none",flipAlignment:V=!0,...B}=p2(J,Q);if((Z=K.arrow)!=null&&Z.alignmentOffset)return{};let N=d2(X),L=e7(W),D=d2(W)===W,O=await(z.isRTL==null?void 0:z.isRTL(G.floating)),j=_||(D||!V?[W$(W)]:ji(W)),k=U!=="none";if(!_&&k)j.push(...Ri(W,V,U,O));let R=[W,...j],P=await z.detectOverflow(Q,B),A=[],I=((q=K.flip)==null?void 0:q.overflows)||[];if($)A.push(P[N]);if(H){let T=Mi(X,Y,O);A.push(P[T[0]],P[T[1]])}if(I=[...I,{placement:X,overflows:A}],!A.every((T)=>T<=0)){var C,y;let T=(((C=K.flip)==null?void 0:C.index)||0)+1,h=R[T];if(h){if(!(H==="alignment"?L!==e7(h):!1)||I.every((f)=>e7(f.placement)===L?f.overflows[0]>0:!0))return{data:{index:T,overflows:I},reset:{placement:h}}}let b=(y=I.filter((x)=>x.overflows[0]<=0).sort((x,f)=>x.overflows[1]-f.overflows[1])[0])==null?void 0:y.placement;if(!b)switch(F){case"bestFit":{var S;let x=(S=I.filter((f)=>{if(k){let u=e7(f.placement);return u===L||u==="y"}return!0}).map((f)=>[f.placement,f.overflows.filter((u)=>u>0).reduce((u,p)=>u+p,0)]).sort((f,u)=>f[1]-u[1])[0])==null?void 0:S[0];if(x)b=x;break}case"initialPlacement":b=W;break}if(X!==b)return{reset:{placement:b}}}return{}}}};function Ei(J,Q){return{top:J.top-Q.height,right:J.right-Q.width,bottom:J.bottom-Q.height,left:J.left-Q.width}}function Ai(J){return Di.some((Q)=>J[Q]>=0)}var bi=function(J){if(J===void 0)J={};return{name:"hide",options:J,async fn(Q){let{rects:Z,platform:q}=Q,{strategy:X="referenceHidden",...K}=p2(J,Q);switch(X){case"referenceHidden":{let Y=await q.detectOverflow(Q,{...K,elementContext:"reference"}),W=Ei(Y,Z.reference);return{data:{referenceHiddenOffsets:W,referenceHidden:Ai(W)}}}case"escaped":{let Y=await q.detectOverflow(Q,{...K,altBoundary:!0}),W=Ei(Y,Z.floating);return{data:{escapedOffsets:W,escaped:Ai(W)}}}default:return{}}}}};var Ti=new Set(["left","top"]);async function EG0(J,Q){let{placement:Z,platform:q,elements:X}=J,K=await(q.isRTL==null?void 0:q.isRTL(X.floating)),Y=d2(Z),W=zX(Z),z=e7(Z)==="y",G=Ti.has(Y)?-1:1,$=K&&z?-1:1,H=p2(Q,J),{mainAxis:_,crossAxis:F,alignmentAxis:U}=typeof H==="number"?{mainAxis:H,crossAxis:0,alignmentAxis:null}:{mainAxis:H.mainAxis||0,crossAxis:H.crossAxis||0,alignmentAxis:H.alignmentAxis};if(W&&typeof U==="number")F=W==="end"?U*-1:U;return z?{x:F*$,y:_*G}:{x:_*G,y:F*$}}var yi=function(J){if(J===void 0)J=0;return{name:"offset",options:J,async fn(Q){var Z,q;let{x:X,y:K,placement:Y,middlewareData:W}=Q,z=await EG0(Q,J);if(Y===((Z=W.offset)==null?void 0:Z.placement)&&(q=W.arrow)!=null&&q.alignmentOffset)return{};return{x:X+z.x,y:K+z.y,data:{...z,placement:Y}}}}},xi=function(J){if(J===void 0)J={};return{name:"shift",options:J,async fn(Q){let{x:Z,y:q,placement:X,platform:K}=Q,{mainAxis:Y=!0,crossAxis:W=!1,limiter:z={fn:(N)=>{let{x:L,y:D}=N;return{x:L,y:D}}},...G}=p2(J,Q),$={x:Z,y:q},H=await K.detectOverflow(Q,G),_=e7(d2(X)),F=sN(_),U=$[F],V=$[_];if(Y){let N=F==="y"?"top":"left",L=F==="y"?"bottom":"right",D=U+H[N],O=U-H[L];U=nN(D,U,O)}if(W){let N=_==="y"?"top":"left",L=_==="y"?"bottom":"right",D=V+H[N],O=V-H[L];V=nN(D,V,O)}let B=z.fn({...Q,[F]:U,[_]:V});return{...B,data:{x:B.x-Z,y:B.y-q,enabled:{[F]:Y,[_]:W}}}}}},vi=function(J){if(J===void 0)J={};return{options:J,fn(Q){let{x:Z,y:q,placement:X,rects:K,middlewareData:Y}=Q,{offset:W=0,mainAxis:z=!0,crossAxis:G=!0}=p2(J,Q),$={x:Z,y:q},H=e7(X),_=sN(H),F=$[_],U=$[H],V=p2(W,Q),B=typeof V==="number"?{mainAxis:V,crossAxis:0}:{mainAxis:0,crossAxis:0,...V};if(z){let D=_==="y"?"height":"width",O=K.reference[_]-K.floating[D]+B.mainAxis,j=K.reference[_]+K.reference[D]-B.mainAxis;if(F<O)F=O;else if(F>j)F=j}if(G){var N,L;let D=_==="y"?"width":"height",O=Ti.has(d2(X)),j=K.reference[H]-K.floating[D]+(O?((N=Y.offset)==null?void 0:N[H])||0:0)+(O?0:B.crossAxis),k=K.reference[H]+K.reference[D]+(O?0:((L=Y.offset)==null?void 0:L[H])||0)-(O?B.crossAxis:0);if(U<j)U=j;else if(U>k)U=k}return{[_]:F,[H]:U}}}},Si=function(J){if(J===void 0)J={};return{name:"size",options:J,async fn(Q){var Z,q;let{placement:X,rects:K,platform:Y,elements:W}=Q,{apply:z=()=>{},...G}=p2(J,Q),$=await Y.detectOverflow(Q,G),H=d2(X),_=zX(X),F=e7(X)==="y",{width:U,height:V}=K.floating,B,N;if(H==="top"||H==="bottom")B=H,N=_===(await(Y.isRTL==null?void 0:Y.isRTL(W.floating))?"start":"end")?"left":"right";else N=H,B=_==="end"?"top":"bottom";let L=V-$.top-$.bottom,D=U-$.left-$.right,O=l2(V-$[B],L),j=l2(U-$[N],D),k=!Q.middlewareData.shift,R=O,P=j;if((Z=Q.middlewareData.shift)!=null&&Z.enabled.x)P=D;if((q=Q.middlewareData.shift)!=null&&q.enabled.y)R=L;if(k&&!_){let I=I8($.left,0),C=I8($.right,0),y=I8($.top,0),S=I8($.bottom,0);if(F)P=U-2*(I!==0||C!==0?I+C:I8($.left,$.right));else R=V-2*(y!==0||S!==0?y+S:I8($.top,$.bottom))}await z({...Q,availableWidth:P,availableHeight:R});let A=await Y.getDimensions(W.floating);if(U!==A.width||V!==A.height)return{reset:{rects:!0}};return{}}}};function oN(){return typeof window<"u"}function _X(J){if(gi(J))return(J.nodeName||"").toLowerCase();return"#document"}function t8(J){var Q;return(J==null||(Q=J.ownerDocument)==null?void 0:Q.defaultView)||window}function J2(J){var Q;return(Q=(gi(J)?J.ownerDocument:J.document)||window.document)==null?void 0:Q.documentElement}function gi(J){if(!oN())return!1;return J instanceof Node||J instanceof t8(J).Node}function V7(J){if(!oN())return!1;return J instanceof Element||J instanceof t8(J).Element}function i2(J){if(!oN())return!1;return J instanceof HTMLElement||J instanceof t8(J).HTMLElement}function fi(J){if(!oN()||typeof ShadowRoot>"u")return!1;return J instanceof ShadowRoot||J instanceof t8(J).ShadowRoot}function dY(J){let{overflow:Q,overflowX:Z,overflowY:q,display:X}=N7(J);return/auto|scroll|overlay|hidden|clip/.test(Q+q+Z)&&X!=="inline"&&X!=="contents"}function hi(J){return/^(table|td|th)$/.test(_X(J))}function H$(J){try{if(J.matches(":popover-open"))return!0}catch(Q){}try{return J.matches(":modal")}catch(Q){return!1}}var AG0=/transform|translate|scale|rotate|perspective|filter/,CG0=/paint|layout|strict|content/,HX=(J)=>!!J&&J!=="none",pA;function tN(J){let Q=V7(J)?N7(J):J;return HX(Q.transform)||HX(Q.translate)||HX(Q.scale)||HX(Q.rotate)||HX(Q.perspective)||!eN()&&(HX(Q.backdropFilter)||HX(Q.filter))||AG0.test(Q.willChange||"")||CG0.test(Q.contain||"")}function ui(J){let Q=WQ(J);while(i2(Q)&&!FX(Q)){if(tN(Q))return Q;else if(H$(Q))return null;Q=WQ(Q)}return null}function eN(){if(pA==null)pA=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none");return pA}function FX(J){return/^(html|body|#document)$/.test(_X(J))}function N7(J){return t8(J).getComputedStyle(J)}function $$(J){if(V7(J))return{scrollLeft:J.scrollLeft,scrollTop:J.scrollTop};return{scrollLeft:J.scrollX,scrollTop:J.scrollY}}function WQ(J){if(_X(J)==="html")return J;let Q=J.assignedSlot||J.parentNode||fi(J)&&J.host||J2(J);return fi(Q)?Q.host:Q}function mi(J){let Q=WQ(J);if(FX(Q))return J.ownerDocument?J.ownerDocument.body:J.body;if(i2(Q)&&dY(Q))return Q;return mi(Q)}function $X(J,Q,Z){var q;if(Q===void 0)Q=[];if(Z===void 0)Z=!0;let X=mi(J),K=X===((q=J.ownerDocument)==null?void 0:q.body),Y=t8(X);if(K){let W=JB(Y);return Q.concat(Y,Y.visualViewport||[],dY(X)?X:[],W&&Z?$X(W):[])}else return Q.concat(X,$X(X,[],Z))}function JB(J){return J.parent&&Object.getPrototypeOf(J.parent)?J.frameElement:null}function di(J){let Q=N7(J),Z=parseFloat(Q.width)||0,q=parseFloat(Q.height)||0,X=i2(J),K=X?J.offsetWidth:Z,Y=X?J.offsetHeight:q,W=z$(Z)!==K||z$(q)!==Y;if(W)Z=K,q=Y;return{width:Z,height:q,$:W}}function iA(J){return!V7(J)?J.contextElement:J}function iY(J){let Q=iA(J);if(!i2(Q))return t7(1);let Z=Q.getBoundingClientRect(),{width:q,height:X,$:K}=di(Q),Y=(K?z$(Z.width):Z.width)/q,W=(K?z$(Z.height):Z.height)/X;if(!Y||!Number.isFinite(Y))Y=1;if(!W||!Number.isFinite(W))W=1;return{x:Y,y:W}}var PG0=t7(0);function ii(J){let Q=t8(J);if(!eN()||!Q.visualViewport)return PG0;return{x:Q.visualViewport.offsetLeft,y:Q.visualViewport.offsetTop}}function IG0(J,Q,Z){if(Q===void 0)Q=!1;if(!Z||Q&&Z!==t8(J))return!1;return Q}function UX(J,Q,Z,q){if(Q===void 0)Q=!1;if(Z===void 0)Z=!1;let X=J.getBoundingClientRect(),K=iA(J),Y=t7(1);if(Q)if(q){if(V7(q))Y=iY(q)}else Y=iY(J);let W=IG0(K,Z,q)?ii(K):t7(0),z=(X.left+W.x)/Y.x,G=(X.top+W.y)/Y.y,$=X.width/Y.x,H=X.height/Y.y;if(K){let _=t8(K),F=q&&V7(q)?t8(q):q,U=_,V=JB(U);while(V&&q&&F!==U){let B=iY(V),N=V.getBoundingClientRect(),L=N7(V),D=N.left+(V.clientLeft+parseFloat(L.paddingLeft))*B.x,O=N.top+(V.clientTop+parseFloat(L.paddingTop))*B.y;z*=B.x,G*=B.y,$*=B.x,H*=B.y,z+=D,G+=O,U=t8(V),V=JB(U)}}return GX({width:$,height:H,x:z,y:G})}function QB(J,Q){let Z=$$(J).scrollLeft;if(!Q)return UX(J2(J)).left+Z;return Q.left+Z}function ni(J,Q){let Z=J.getBoundingClientRect(),q=Z.left+Q.scrollLeft-QB(J,Z),X=Z.top+Q.scrollTop;return{x:q,y:X}}function wG0(J){let{elements:Q,rect:Z,offsetParent:q,strategy:X}=J,K=X==="fixed",Y=J2(q),W=Q?H$(Q.floating):!1;if(q===Y||W&&K)return Z;let z={scrollLeft:0,scrollTop:0},G=t7(1),$=t7(0),H=i2(q);if(H||!H&&!K){if(_X(q)!=="body"||dY(Y))z=$$(q);if(H){let F=UX(q);G=iY(q),$.x=F.x+q.clientLeft,$.y=F.y+q.clientTop}}let _=Y&&!H&&!K?ni(Y,z):t7(0);return{width:Z.width*G.x,height:Z.height*G.y,x:Z.x*G.x-z.scrollLeft*G.x+$.x+_.x,y:Z.y*G.y-z.scrollTop*G.y+$.y+_.y}}function bG0(J){return Array.from(J.getClientRects())}function TG0(J){let Q=J2(J),Z=$$(J),q=J.ownerDocument.body,X=I8(Q.scrollWidth,Q.clientWidth,q.scrollWidth,q.clientWidth),K=I8(Q.scrollHeight,Q.clientHeight,q.scrollHeight,q.clientHeight),Y=-Z.scrollLeft+QB(J),W=-Z.scrollTop;if(N7(q).direction==="rtl")Y+=I8(Q.clientWidth,q.clientWidth)-X;return{width:X,height:K,x:Y,y:W}}var ci=25;function yG0(J,Q){let Z=t8(J),q=J2(J),X=Z.visualViewport,K=q.clientWidth,Y=q.clientHeight,W=0,z=0;if(X){K=X.width,Y=X.height;let $=eN();if(!$||$&&Q==="fixed")W=X.offsetLeft,z=X.offsetTop}let G=QB(q);if(G<=0){let $=q.ownerDocument,H=$.body,_=getComputedStyle(H),F=$.compatMode==="CSS1Compat"?parseFloat(_.marginLeft)+parseFloat(_.marginRight)||0:0,U=Math.abs(q.clientWidth-H.clientWidth-F);if(U<=ci)K-=U}else if(G<=ci)K+=G;return{width:K,height:Y,x:W,y:z}}function xG0(J,Q){let Z=UX(J,!0,Q==="fixed"),q=Z.top+J.clientTop,X=Z.left+J.clientLeft,K=i2(J)?iY(J):t7(1),Y=J.clientWidth*K.x,W=J.clientHeight*K.y,z=X*K.x,G=q*K.y;return{width:Y,height:W,x:z,y:G}}function li(J,Q,Z){let q;if(Q==="viewport")q=yG0(J,Z);else if(Q==="document")q=TG0(J2(J));else if(V7(Q))q=xG0(Q,Z);else{let X=ii(J);q={x:Q.x-X.x,y:Q.y-X.y,width:Q.width,height:Q.height}}return GX(q)}function si(J,Q){let Z=WQ(J);if(Z===Q||!V7(Z)||FX(Z))return!1;return N7(Z).position==="fixed"||si(Z,Q)}function vG0(J,Q){let Z=Q.get(J);if(Z)return Z;let q=$X(J,[],!1).filter((W)=>V7(W)&&_X(W)!=="body"),X=null,K=N7(J).position==="fixed",Y=K?WQ(J):J;while(V7(Y)&&!FX(Y)){let W=N7(Y),z=tN(Y);if(!z&&W.position==="fixed")X=null;if(K?!z&&!X:!z&&W.position==="static"&&!!X&&(X.position==="absolute"||X.position==="fixed")||dY(Y)&&!z&&si(J,Y))q=q.filter(($)=>$!==Y);else X=W;Y=WQ(Y)}return Q.set(J,q),q}function SG0(J){let{element:Q,boundary:Z,rootBoundary:q,strategy:X}=J,Y=[...Z==="clippingAncestors"?H$(Q)?[]:vG0(Q,this._c):[].concat(Z),q],W=li(Q,Y[0],X),z=W.top,G=W.right,$=W.bottom,H=W.left;for(let _=1;_<Y.length;_++){let F=li(Q,Y[_],X);z=I8(F.top,z),G=l2(F.right,G),$=l2(F.bottom,$),H=I8(F.left,H)}return{width:G-H,height:$-z,x:H,y:z}}function fG0(J){let{width:Q,height:Z}=di(J);return{width:Q,height:Z}}function gG0(J,Q,Z){let q=i2(Q),X=J2(Q),K=Z==="fixed",Y=UX(J,!0,K,Q),W={scrollLeft:0,scrollTop:0},z=t7(0);function G(){z.x=QB(X)}if(q||!q&&!K){if(_X(Q)!=="body"||dY(X))W=$$(Q);if(q){let F=UX(Q,!0,K,Q);z.x=F.x+Q.clientLeft,z.y=F.y+Q.clientTop}else if(X)G()}if(K&&!q&&X)G();let $=X&&!q&&!K?ni(X,W):t7(0),H=Y.left+W.scrollLeft-z.x-$.x,_=Y.top+W.scrollTop-z.y-$.y;return{x:H,y:_,width:Y.width,height:Y.height}}function dA(J){return N7(J).position==="static"}function pi(J,Q){if(!i2(J)||N7(J).position==="fixed")return null;if(Q)return Q(J);let Z=J.offsetParent;if(J2(J)===Z)Z=Z.ownerDocument.body;return Z}function ri(J,Q){let Z=t8(J);if(H$(J))return Z;if(!i2(J)){let X=WQ(J);while(X&&!FX(X)){if(V7(X)&&!dA(X))return X;X=WQ(X)}return Z}let q=pi(J,Q);while(q&&hi(q)&&dA(q))q=pi(q,Q);if(q&&FX(q)&&dA(q)&&!tN(q))return Z;return q||ui(J)||Z}var hG0=async function(J){let Q=this.getOffsetParent||ri,Z=this.getDimensions,q=await Z(J.floating);return{reference:gG0(J.reference,await Q(J.floating),J.strategy),floating:{x:0,y:0,width:q.width,height:q.height}}};function uG0(J){return N7(J).direction==="rtl"}var ai={convertOffsetParentRelativeRectToViewportRelativeRect:wG0,getDocumentElement:J2,getClippingRect:SG0,getOffsetParent:ri,getElementRects:hG0,getClientRects:bG0,getDimensions:fG0,getScale:iY,isElement:V7,isRTL:uG0};function oi(J,Q){return J.x===Q.x&&J.y===Q.y&&J.width===Q.width&&J.height===Q.height}function mG0(J,Q){let Z=null,q,X=J2(J);function K(){var W;clearTimeout(q),(W=Z)==null||W.disconnect(),Z=null}function Y(W,z){if(W===void 0)W=!1;if(z===void 0)z=1;K();let G=J.getBoundingClientRect(),{left:$,top:H,width:_,height:F}=G;if(!W)Q();if(!_||!F)return;let U=G$(H),V=G$(X.clientWidth-($+_)),B=G$(X.clientHeight-(H+F)),N=G$($),D={rootMargin:-U+"px "+-V+"px "+-B+"px "+-N+"px",threshold:I8(0,l2(1,z))||1},O=!0;function j(k){let R=k[0].intersectionRatio;if(R!==z){if(!O)return Y();if(!R)q=setTimeout(()=>{Y(!1,0.0000001)},1000);else Y(!1,R)}if(R===1&&!oi(G,J.getBoundingClientRect()))Y();O=!1}try{Z=new IntersectionObserver(j,{...D,root:X.ownerDocument})}catch(k){Z=new IntersectionObserver(j,D)}Z.observe(J)}return Y(!0),K}function nA(J,Q,Z,q){if(q===void 0)q={};let{ancestorScroll:X=!0,ancestorResize:K=!0,elementResize:Y=typeof ResizeObserver==="function",layoutShift:W=typeof IntersectionObserver==="function",animationFrame:z=!1}=q,G=iA(J),$=X||K?[...G?$X(G):[],...Q?$X(Q):[]]:[];$.forEach((N)=>{X&&N.addEventListener("scroll",Z,{passive:!0}),K&&N.addEventListener("resize",Z)});let H=G&&W?mG0(G,Z):null,_=-1,F=null;if(Y){if(F=new ResizeObserver((N)=>{let[L]=N;if(L&&L.target===G&&F&&Q)F.unobserve(Q),cancelAnimationFrame(_),_=requestAnimationFrame(()=>{var D;(D=F)==null||D.observe(Q)});Z()}),G&&!z)F.observe(G);if(Q)F.observe(Q)}let U,V=z?UX(J):null;if(z)B();function B(){let N=UX(J);if(V&&!oi(V,N))Z();V=N,U=requestAnimationFrame(B)}return Z(),()=>{var N;if($.forEach((L)=>{X&&L.removeEventListener("scroll",Z),K&&L.removeEventListener("resize",Z)}),H==null||H(),(N=F)==null||N.disconnect(),F=null,z)cancelAnimationFrame(U)}}var ti=yi;var ei=xi,Jn=wi,Qn=Si,Zn=bi,sA=Ii;var qn=vi,rA=(J,Q,Z)=>{let q=new Map,X={platform:ai,...Z},K={...X.platform,_c:q};return Pi(J,Q,{...X,platform:K})};var t6=E(m(),1),Kn=E(m(),1),Yn=E(SJ(),1),cG0=typeof document<"u",lG0=function(){},ZB=cG0?Kn.useLayoutEffect:lG0;function qB(J,Q){if(J===Q)return!0;if(typeof J!==typeof Q)return!1;if(typeof J==="function"&&J.toString()===Q.toString())return!0;let Z,q,X;if(J&&Q&&typeof J==="object"){if(Array.isArray(J)){if(Z=J.length,Z!==Q.length)return!1;for(q=Z;q--!==0;)if(!qB(J[q],Q[q]))return!1;return!0}if(X=Object.keys(J),Z=X.length,Z!==Object.keys(Q).length)return!1;for(q=Z;q--!==0;)if(!{}.hasOwnProperty.call(Q,X[q]))return!1;for(q=Z;q--!==0;){let K=X[q];if(K==="_owner"&&J.$$typeof)continue;if(!qB(J[K],Q[K]))return!1}return!0}return J!==J&&Q!==Q}function Wn(J){if(typeof window>"u")return 1;return(J.ownerDocument.defaultView||window).devicePixelRatio||1}function Xn(J,Q){let Z=Wn(J);return Math.round(Q*Z)/Z}function aA(J){let Q=t6.useRef(J);return ZB(()=>{Q.current=J}),Q}function zn(J){if(J===void 0)J={};let{placement:Q="bottom",strategy:Z="absolute",middleware:q=[],platform:X,elements:{reference:K,floating:Y}={},transform:W=!0,whileElementsMounted:z,open:G}=J,[$,H]=t6.useState({x:0,y:0,strategy:Z,placement:Q,middlewareData:{},isPositioned:!1}),[_,F]=t6.useState(q);if(!qB(_,q))F(q);let[U,V]=t6.useState(null),[B,N]=t6.useState(null),L=t6.useCallback((f)=>{if(f!==k.current)k.current=f,V(f)},[]),D=t6.useCallback((f)=>{if(f!==R.current)R.current=f,N(f)},[]),O=K||U,j=Y||B,k=t6.useRef(null),R=t6.useRef(null),P=t6.useRef($),A=z!=null,I=aA(z),C=aA(X),y=aA(G),S=t6.useCallback(()=>{if(!k.current||!R.current)return;let f={placement:Q,strategy:Z,middleware:_};if(C.current)f.platform=C.current;rA(k.current,R.current,f).then((u)=>{let p={...u,isPositioned:y.current!==!1};if(T.current&&!qB(P.current,p))P.current=p,Yn.flushSync(()=>{H(p)})})},[_,Q,Z,C,y]);ZB(()=>{if(G===!1&&P.current.isPositioned)P.current.isPositioned=!1,H((f)=>({...f,isPositioned:!1}))},[G]);let T=t6.useRef(!1);ZB(()=>{return T.current=!0,()=>{T.current=!1}},[]),ZB(()=>{if(O)k.current=O;if(j)R.current=j;if(O&&j){if(I.current)return I.current(O,j,S);S()}},[O,j,S,I,A]);let h=t6.useMemo(()=>({reference:k,floating:R,setReference:L,setFloating:D}),[L,D]),b=t6.useMemo(()=>({reference:O,floating:j}),[O,j]),x=t6.useMemo(()=>{let f={position:Z,left:0,top:0};if(!b.floating)return f;let u=Xn(b.floating,$.x),p=Xn(b.floating,$.y);if(W)return{...f,transform:"translate("+u+"px, "+p+"px)",...Wn(b.floating)>=1.5&&{willChange:"transform"}};return{position:Z,left:u,top:p}},[Z,W,b.floating,$.x,$.y]);return t6.useMemo(()=>({...$,update:S,refs:h,elements:b,floatingStyles:x}),[$,S,h,b,x])}var pG0=(J)=>{function Q(Z){return{}.hasOwnProperty.call(Z,"current")}return{name:"arrow",options:J,fn(Z){let{element:q,padding:X}=typeof J==="function"?J(Z):J;if(q&&Q(q)){if(q.current!=null)return sA({element:q.current,padding:X}).fn(Z);return{}}if(q)return sA({element:q,padding:X}).fn(Z);return{}}}},Gn=(J,Q)=>{let Z=ti(J);return{name:Z.name,fn:Z.fn,options:[J,Q]}},Hn=(J,Q)=>{let Z=ei(J);return{name:Z.name,fn:Z.fn,options:[J,Q]}},$n=(J,Q)=>{return{fn:qn(J).fn,options:[J,Q]}},_n=(J,Q)=>{let Z=Jn(J);return{name:Z.name,fn:Z.fn,options:[J,Q]}},Fn=(J,Q)=>{let Z=Qn(J);return{name:Z.name,fn:Z.fn,options:[J,Q]}};var Un=(J,Q)=>{let Z=Zn(J);return{name:Z.name,fn:Z.fn,options:[J,Q]}};var Vn=(J,Q)=>{let Z=pG0(J);return{name:Z.name,fn:Z.fn,options:[J,Q]}};var Nn=E(m(),1);var oA=E(c(),1),dG0="Arrow",Bn=Nn.forwardRef((J,Q)=>{let{children:Z,width:q=10,height:X=5,...K}=J;return oA.jsx(_0.svg,{...K,ref:Q,width:q,height:X,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:J.asChild?Z:oA.jsx("polygon",{points:"0,0 30,0 15,10"})})});Bn.displayName=dG0;var Ln=Bn;var On=E(m(),1);function XB(J){let[Q,Z]=On.useState(void 0);return f4(()=>{if(J){Z({width:J.offsetWidth,height:J.offsetHeight});let q=new ResizeObserver((X)=>{if(!Array.isArray(X))return;if(!X.length)return;let K=X[0],Y,W;if("borderBoxSize"in K){let z=K.borderBoxSize,G=Array.isArray(z)?z[0]:z;Y=G.inlineSize,W=G.blockSize}else Y=J.offsetWidth,W=J.offsetHeight;Z({width:Y,height:W})});return q.observe(J,{box:"border-box"}),()=>q.unobserve(J)}else Z(void 0)},[J]),Q}var sZ=E(c(),1);var tA="Popper",[Dn,B7]=U4(tA),[nG0,Mn]=Dn(tA),jn=(J)=>{let{__scopePopper:Q,children:Z}=J,[q,X]=d5.useState(null),[K,Y]=d5.useState(void 0);return sZ.jsx(nG0,{scope:Q,anchor:q,onAnchorChange:X,placementState:K,setPlacementState:Y,children:Z})};jn.displayName=tA;var Rn="PopperAnchor",kn=d5.forwardRef((J,Q)=>{let{__scopePopper:Z,virtualRef:q,...X}=J,K=Mn(Rn,Z),Y=d5.useRef(null),W=K.onAnchorChange,z=d5.useCallback((U)=>{if(Y.current=U,U)W(U)},[W]),G=p0(Q,z),$=d5.useRef(null);d5.useEffect(()=>{if(!q)return;let U=$.current;if($.current=q.current,U!==$.current)W($.current)});let H=K.placementState&&JC(K.placementState),_=H?.[0],F=H?.[1];return q?null:sZ.jsx(_0.div,{"data-radix-popper-side":_,"data-radix-popper-align":F,...X,ref:G})});kn.displayName=Rn;var eA="PopperContent",[sG0,rG0]=Dn(eA),En=d5.forwardRef((J,Q)=>{let{__scopePopper:Z,side:q="bottom",sideOffset:X=0,align:K="center",alignOffset:Y=0,arrowPadding:W=0,avoidCollisions:z=!0,collisionBoundary:G=[],collisionPadding:$=0,sticky:H="partial",hideWhenDetached:_=!1,updatePositionStrategy:F="optimized",onPlaced:U,...V}=J,B=Mn(eA,Z),[N,L]=d5.useState(null),D=p0(Q,(O0)=>L(O0)),[O,j]=d5.useState(null),k=XB(O),R=k?.width??0,P=k?.height??0,A=q+(K!=="center"?"-"+K:""),I=typeof $==="number"?$:{top:0,right:0,bottom:0,left:0,...$},C=Array.isArray(G)?G:[G],y=C.length>0,S={padding:I,boundary:C.filter(oG0),altBoundary:y},{refs:T,floatingStyles:h,placement:b,isPositioned:x,middlewareData:f}=zn({strategy:"fixed",placement:A,whileElementsMounted:(...O0)=>{return nA(...O0,{animationFrame:F==="always"})},elements:{reference:B.anchor},middleware:[Gn({mainAxis:X+P,alignmentAxis:Y}),z&&Hn({mainAxis:!0,crossAxis:!1,limiter:H==="partial"?$n():void 0,...S}),z&&_n({...S}),Fn({...S,apply:({elements:O0,rects:Z1,availableWidth:q1,availableHeight:r})=>{let{width:s,height:F0}=Z1.reference,s0=O0.floating.style;s0.setProperty("--radix-popper-available-width",`${q1}px`),s0.setProperty("--radix-popper-available-height",`${r}px`),s0.setProperty("--radix-popper-anchor-width",`${s}px`),s0.setProperty("--radix-popper-anchor-height",`${F0}px`)}}),O&&Vn({element:O,padding:W}),tG0({arrowWidth:R,arrowHeight:P}),_&&Un({strategy:"referenceHidden",...S,boundary:y?S.boundary:void 0})]}),u=B.setPlacementState;f4(()=>{return u(b),()=>{u(void 0)}},[b,u]);let[p,o]=JC(b),K0=$6(U);f4(()=>{if(x)K0?.()},[x,K0]);let U0=f.arrow?.x,y0=f.arrow?.y,D1=f.arrow?.centerOffset!==0,[j0,Y0]=d5.useState();return f4(()=>{if(N)Y0(window.getComputedStyle(N).zIndex)},[N]),sZ.jsx("div",{ref:T.setFloating,"data-radix-popper-content-wrapper":"",style:{...h,transform:x?h.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:j0,"--radix-popper-transform-origin":[f.transformOrigin?.x,f.transformOrigin?.y].join(" "),...f.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:J.dir,children:sZ.jsx(sG0,{scope:Z,placedSide:p,placedAlign:o,onArrowChange:j,arrowX:U0,arrowY:y0,shouldHideArrow:D1,children:sZ.jsx(_0.div,{"data-side":p,"data-align":o,...V,ref:D,style:{...V.style,animation:!x?"none":void 0}})})})});En.displayName=eA;var An="PopperArrow",aG0={top:"bottom",right:"left",bottom:"top",left:"right"},Cn=d5.forwardRef(function(Q,Z){let{__scopePopper:q,...X}=Q,K=rG0(An,q),Y=aG0[K.placedSide];return sZ.jsx("span",{ref:K.onArrowChange,style:{position:"absolute",left:K.arrowX,top:K.arrowY,[Y]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[K.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[K.placedSide],visibility:K.shouldHideArrow?"hidden":void 0},children:sZ.jsx(Ln,{...X,ref:Z,style:{...X.style,display:"block"}})})});Cn.displayName=An;function oG0(J){return J!==null}var tG0=(J)=>({name:"transformOrigin",options:J,fn(Q){let{placement:Z,rects:q,middlewareData:X}=Q,Y=X.arrow?.centerOffset!==0,W=Y?0:J.arrowWidth,z=Y?0:J.arrowHeight,[G,$]=JC(Z),H={start:"0%",center:"50%",end:"100%"}[$],_=(X.arrow?.x??0)+W/2,F=(X.arrow?.y??0)+z/2,U="",V="";if(G==="bottom")U=Y?H:`${_}px`,V=`${-z}px`;else if(G==="top")U=Y?H:`${_}px`,V=`${q.floating.height+z}px`;else if(G==="right")U=`${-z}px`,V=Y?H:`${F}px`;else if(G==="left")U=`${q.floating.width+z}px`,V=Y?H:`${F}px`;return{data:{x:U,y:V}}}});function JC(J){let[Q,Z="center"]=J.split("-");return[Q,Z]}var zQ=jn,GQ=kn,rZ=En,aZ=Cn;var YB=E(m(),1),Pn=E(SJ(),1);var In=E(c(),1),eG0="Portal",m9=YB.forwardRef((J,Q)=>{let{container:Z,...q}=J,[X,K]=YB.useState(!1);f4(()=>K(!0),[]);let Y=Z||X&&globalThis?.document?.body;return Y?Pn.createPortal(In.jsx(_0.div,{...q,ref:Q}),Y):null});m9.displayName=eG0;var z8=E(m(),1);var bn=E(m(),1);function JH0(J,Q){return bn.useReducer((Z,q)=>{return Q[Z][q]??Z},J)}var e6=(J)=>{let{present:Q,children:Z}=J,q=QH0(Q),X=typeof Z==="function"?Z({present:q.isPresent}):z8.Children.only(Z),K=ZH0(q.ref,qH0(X));return typeof Z==="function"||q.isPresent?z8.cloneElement(X,{ref:K}):null};e6.displayName="Presence";function QH0(J){let[Q,Z]=z8.useState(),q=z8.useRef(null),X=z8.useRef(J),K=z8.useRef("none"),Y=J?"mounted":"unmounted",[W,z]=JH0(Y,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return z8.useEffect(()=>{let G=WB(q.current);K.current=W==="mounted"?G:"none"},[W]),f4(()=>{let G=q.current,$=X.current;if($!==J){let _=K.current,F=WB(G);if(J)z("MOUNT");else if(F==="none"||G?.display==="none")z("UNMOUNT");else if($&&_!==F)z("ANIMATION_OUT");else z("UNMOUNT");X.current=J}},[J,z]),f4(()=>{if(Q){let G,$=Q.ownerDocument.defaultView??window,H=(F)=>{let V=WB(q.current).includes(CSS.escape(F.animationName));if(F.target===Q&&V){if(z("ANIMATION_END"),!X.current){let B=Q.style.animationFillMode;Q.style.animationFillMode="forwards",G=$.setTimeout(()=>{if(Q.style.animationFillMode==="forwards")Q.style.animationFillMode=B})}}},_=(F)=>{if(F.target===Q)K.current=WB(q.current)};return Q.addEventListener("animationstart",_),Q.addEventListener("animationcancel",H),Q.addEventListener("animationend",H),()=>{$.clearTimeout(G),Q.removeEventListener("animationstart",_),Q.removeEventListener("animationcancel",H),Q.removeEventListener("animationend",H)}}else z("ANIMATION_END")},[Q,z]),{isPresent:["mounted","unmountSuspended"].includes(W),ref:z8.useCallback((G)=>{q.current=G?getComputedStyle(G):null,Z(G)},[])}}function wn(J,Q){if(typeof J==="function")return J(Q);else if(J!==null&&J!==void 0)J.current=Q}function ZH0(...J){let Q=z8.useRef(J);return Q.current=J,z8.useCallback((Z)=>{let q=Q.current,X=!1,K=q.map((Y)=>{let W=wn(Y,Z);if(!X&&typeof W==="function")X=!0;return W});if(X)return()=>{for(let Y=0;Y<K.length;Y++){let W=K[Y];if(typeof W==="function")W();else wn(q[Y],null)}}},[])}function WB(J){return J?.animationName||"none"}function qH0(J){let Q=Object.getOwnPropertyDescriptor(J.props,"ref")?.get,Z=Q&&"isReactWarning"in Q&&Q.isReactWarning;if(Z)return J.ref;if(Q=Object.getOwnPropertyDescriptor(J,"ref")?.get,Z=Q&&"isReactWarning"in Q&&Q.isReactWarning,Z)return J.props.ref;return J.props.ref||J.ref}var C5=E(m(),1);var L7=E(m(),1);var zB=E(m(),1);var XH0=L7[" useInsertionEffect ".trim().toString()]||f4;function g4({prop:J,defaultProp:Q,onChange:Z=()=>{},caller:q}){let[X,K,Y]=KH0({defaultProp:Q,onChange:Z}),W=J!==void 0,z=W?J:X;{let $=L7.useRef(J!==void 0);L7.useEffect(()=>{let H=$.current;if(H!==W)console.warn(`${q} is changing from ${H?"controlled":"uncontrolled"} to ${W?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`);$.current=W},[W,q])}let G=L7.useCallback(($)=>{if(W){let H=YH0($)?$(J):$;if(H!==J)Y.current?.(H)}else K($)},[W,J,K,Y]);return[z,G]}function KH0({defaultProp:J,onChange:Q}){let[Z,q]=L7.useState(J),X=L7.useRef(Z),K=L7.useRef(Q);return XH0(()=>{K.current=Q},[Q]),L7.useEffect(()=>{if(X.current!==Z)K.current?.(Z),X.current=Z},[Z,X]),[Z,q,K]}function YH0(J){return typeof J==="function"}var De0=Symbol("RADIX:SYNC_STATE");var oZ=E(c(),1),QC="rovingFocusGroup.onEntryFocus",WH0={bubbles:!1,cancelable:!0},_$="RovingFocusGroup",[ZC,Tn,zH0]=c2(_$),[GH0,HQ]=U4(_$,[zH0]),[HH0,$H0]=GH0(_$),yn=C5.forwardRef((J,Q)=>{return oZ.jsx(ZC.Provider,{scope:J.__scopeRovingFocusGroup,children:oZ.jsx(ZC.Slot,{scope:J.__scopeRovingFocusGroup,children:oZ.jsx(_H0,{...J,ref:Q})})})});yn.displayName=_$;var _H0=C5.forwardRef((J,Q)=>{let{__scopeRovingFocusGroup:Z,orientation:q,loop:X=!1,dir:K,currentTabStopId:Y,defaultCurrentTabStopId:W,onCurrentTabStopIdChange:z,onEntryFocus:G,preventScrollOnEntryFocus:$=!1,...H}=J,_=C5.useRef(null),F=p0(Q,_),U=_7(K),[V,B]=g4({prop:Y,defaultProp:W??null,onChange:z,caller:_$}),[N,L]=C5.useState(!1),D=$6(G),O=Tn(Z),j=C5.useRef(!1),[k,R]=C5.useState(0);return C5.useEffect(()=>{let P=_.current;if(P)return P.addEventListener(QC,D),()=>P.removeEventListener(QC,D)},[D]),oZ.jsx(HH0,{scope:Z,orientation:q,dir:U,loop:X,currentTabStopId:V,onItemFocus:C5.useCallback((P)=>B(P),[B]),onItemShiftTab:C5.useCallback(()=>L(!0),[]),onFocusableItemAdd:C5.useCallback(()=>R((P)=>P+1),[]),onFocusableItemRemove:C5.useCallback(()=>R((P)=>P-1),[]),children:oZ.jsx(_0.div,{tabIndex:N||k===0?-1:0,"data-orientation":q,...H,ref:F,style:{outline:"none",...J.style},onMouseDown:Z0(J.onMouseDown,()=>{j.current=!0}),onFocus:Z0(J.onFocus,(P)=>{let A=!j.current;if(P.target===P.currentTarget&&A&&!N){let I=new CustomEvent(QC,WH0);if(P.currentTarget.dispatchEvent(I),!I.defaultPrevented){let C=O().filter((b)=>b.focusable),y=C.find((b)=>b.active),S=C.find((b)=>b.id===V),h=[y,S,...C].filter(Boolean).map((b)=>b.ref.current);Sn(h,$)}}j.current=!1}),onBlur:Z0(J.onBlur,()=>L(!1))})})}),xn="RovingFocusGroupItem",vn=C5.forwardRef((J,Q)=>{let{__scopeRovingFocusGroup:Z,focusable:q=!0,active:X=!1,tabStopId:K,children:Y,...W}=J,z=o6(),G=K||z,$=$H0(xn,Z),H=$.currentTabStopId===G,_=Tn(Z),{onFocusableItemAdd:F,onFocusableItemRemove:U,currentTabStopId:V}=$;return C5.useEffect(()=>{if(q)return F(),()=>U()},[q,F,U]),oZ.jsx(ZC.ItemSlot,{scope:Z,id:G,focusable:q,active:X,children:oZ.jsx(_0.span,{tabIndex:H?0:-1,"data-orientation":$.orientation,...W,ref:Q,onMouseDown:Z0(J.onMouseDown,(B)=>{if(!q)B.preventDefault();else $.onItemFocus(G)}),onFocus:Z0(J.onFocus,()=>$.onItemFocus(G)),onKeyDown:Z0(J.onKeyDown,(B)=>{if(B.key==="Tab"&&B.shiftKey){$.onItemShiftTab();return}if(B.target!==B.currentTarget)return;let N=VH0(B,$.orientation,$.dir);if(N!==void 0){if(B.metaKey||B.ctrlKey||B.altKey||B.shiftKey)return;B.preventDefault();let D=_().filter((O)=>O.focusable).map((O)=>O.ref.current);if(N==="last")D.reverse();else if(N==="prev"||N==="next"){if(N==="prev")D.reverse();let O=D.indexOf(B.currentTarget);D=$.loop?NH0(D,O+1):D.slice(O+1)}setTimeout(()=>Sn(D))}}),children:typeof Y==="function"?Y({isCurrentTabStop:H,hasTabStop:V!=null}):Y})})});vn.displayName=xn;var FH0={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function UH0(J,Q){if(Q!=="rtl")return J;return J==="ArrowLeft"?"ArrowRight":J==="ArrowRight"?"ArrowLeft":J}function VH0(J,Q,Z){let q=UH0(J.key,Z);if(Q==="vertical"&&["ArrowLeft","ArrowRight"].includes(q))return;if(Q==="horizontal"&&["ArrowUp","ArrowDown"].includes(q))return;return FH0[q]}function Sn(J,Q=!1){let Z=document.activeElement;for(let q of J){if(q===Z)return;if(q.focus({preventScroll:Q}),document.activeElement!==Z)return}}function NH0(J,Q){return J.map((Z,q)=>J[(Q+q)%J.length])}var nY=yn,VX=vn;var BH0=function(J){if(typeof document>"u")return null;var Q=Array.isArray(J)?J[0]:J;return Q.ownerDocument.body},sY=new WeakMap,GB=new WeakMap,HB={},XC=0,fn=function(J){return J&&(J.host||fn(J.parentNode))},LH0=function(J,Q){return Q.map(function(Z){if(J.contains(Z))return Z;var q=fn(Z);if(q&&J.contains(q))return q;return console.error("aria-hidden",Z,"in not contained inside",J,". Doing nothing"),null}).filter(function(Z){return Boolean(Z)})},OH0=function(J,Q,Z,q){var X=LH0(Q,Array.isArray(J)?J:[J]);if(!HB[Z])HB[Z]=new WeakMap;var K=HB[Z],Y=[],W=new Set,z=new Set(X),G=function(H){if(!H||W.has(H))return;W.add(H),G(H.parentNode)};X.forEach(G);var $=function(H){if(!H||z.has(H))return;Array.prototype.forEach.call(H.children,function(_){if(W.has(_))$(_);else try{var F=_.getAttribute(q),U=F!==null&&F!=="false",V=(sY.get(_)||0)+1,B=(K.get(_)||0)+1;if(sY.set(_,V),K.set(_,B),Y.push(_),V===1&&U)GB.set(_,!0);if(B===1)_.setAttribute(Z,"true");if(!U)_.setAttribute(q,"true")}catch(N){console.error("aria-hidden: cannot operate on ",_,N)}})};return $(Q),W.clear(),XC++,function(){if(Y.forEach(function(H){var _=sY.get(H)-1,F=K.get(H)-1;if(sY.set(H,_),K.set(H,F),!_){if(!GB.has(H))H.removeAttribute(q);GB.delete(H)}if(!F)H.removeAttribute(Z)}),XC--,!XC)sY=new WeakMap,sY=new WeakMap,GB=new WeakMap,HB={}}},tZ=function(J,Q,Z){if(Z===void 0)Z="data-aria-hidden";var q=Array.from(Array.isArray(J)?J:[J]),X=Q||BH0(J);if(!X)return function(){return null};return q.push.apply(q,Array.from(X.querySelectorAll("[aria-live], script"))),OH0(q,X,Z,"aria-hidden")};var e8=function(){return e8=Object.assign||function(Q){for(var Z,q=1,X=arguments.length;q<X;q++){Z=arguments[q];for(var K in Z)if(Object.prototype.hasOwnProperty.call(Z,K))Q[K]=Z[K]}return Q},e8.apply(this,arguments)};function $B(J,Q){var Z={};for(var q in J)if(Object.prototype.hasOwnProperty.call(J,q)&&Q.indexOf(q)<0)Z[q]=J[q];if(J!=null&&typeof Object.getOwnPropertySymbols==="function"){for(var X=0,q=Object.getOwnPropertySymbols(J);X<q.length;X++)if(Q.indexOf(q[X])<0&&Object.prototype.propertyIsEnumerable.call(J,q[X]))Z[q[X]]=J[q[X]]}return Z}function gn(J,Q,Z){if(Z||arguments.length===2){for(var q=0,X=Q.length,K;q<X;q++)if(K||!(q in Q)){if(!K)K=Array.prototype.slice.call(Q,0,q);K[q]=Q[q]}}return J.concat(K||Array.prototype.slice.call(Q))}var NB=E(m(),1);var G8=E(m(),1);var NX="right-scroll-bar-position",BX="width-before-scroll-bar",KC="with-scroll-bars-hidden",YC="--removed-body-scroll-bar-size";var FB=E(m(),1);function _B(J,Q){if(typeof J==="function")J(Q);else if(J)J.current=Q;return J}var hn=E(m(),1);function un(J,Q){var Z=hn.useState(function(){return{value:J,callback:Q,facade:{get current(){return Z.value},set current(q){var X=Z.value;if(X!==q)Z.value=q,Z.callback(q,X)}}}})[0];return Z.callback=Q,Z.facade}var DH0=typeof window<"u"?FB.useLayoutEffect:FB.useEffect,mn=new WeakMap;function WC(J,Q){var Z=un(Q||null,function(q){return J.forEach(function(X){return _B(X,q)})});return DH0(function(){var q=mn.get(Z);if(q){var X=new Set(q),K=new Set(J),Y=Z.current;X.forEach(function(W){if(!K.has(W))_B(W,null)}),K.forEach(function(W){if(!X.has(W))_B(W,Y)})}mn.set(Z,J)},[J]),Z}function MH0(J){return J}function jH0(J,Q){if(Q===void 0)Q=MH0;var Z=[],q=!1,X={read:function(){if(q)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");if(Z.length)return Z[Z.length-1];return J},useMedium:function(K){var Y=Q(K,q);return Z.push(Y),function(){Z=Z.filter(function(W){return W!==Y})}},assignSyncMedium:function(K){q=!0;while(Z.length){var Y=Z;Z=[],Y.forEach(K)}Z={push:function(W){return K(W)},filter:function(){return Z}}},assignMedium:function(K){q=!0;var Y=[];if(Z.length){var W=Z;Z=[],W.forEach(K),Y=Z}var z=function(){var $=Y;Y=[],$.forEach(K)},G=function(){return Promise.resolve().then(z)};G(),Z={push:function($){Y.push($),G()},filter:function($){return Y=Y.filter($),Z}}}};return X}function zC(J){if(J===void 0)J={};var Q=jH0(null);return Q.options=e8({async:!0,ssr:!1},J),Q}var cn=E(m(),1),ln=function(J){var Q=J.sideCar,Z=$B(J,["sideCar"]);if(!Q)throw Error("Sidecar: please provide `sideCar` property to import the right car");var q=Q.read();if(!q)throw Error("Sidecar medium not found");return cn.createElement(q,e8({},Z))};ln.isSideCarExport=!0;function GC(J,Q){return J.useMedium(Q),ln}var UB=zC();var HC=function(){return},F$=G8.forwardRef(function(J,Q){var Z=G8.useRef(null),q=G8.useState({onScrollCapture:HC,onWheelCapture:HC,onTouchMoveCapture:HC}),X=q[0],K=q[1],Y=J.forwardProps,W=J.children,z=J.className,G=J.removeScrollBar,$=J.enabled,H=J.shards,_=J.sideCar,F=J.noRelative,U=J.noIsolation,V=J.inert,B=J.allowPinchZoom,N=J.as,L=N===void 0?"div":N,D=J.gapMode,O=$B(J,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),j=_,k=WC([Z,Q]),R=e8(e8({},O),X);return G8.createElement(G8.Fragment,null,$&&G8.createElement(j,{sideCar:UB,removeScrollBar:G,shards:H,noRelative:F,noIsolation:U,inert:V,setCallbacks:K,allowPinchZoom:!!B,lockRef:Z,gapMode:D}),Y?G8.cloneElement(G8.Children.only(W),e8(e8({},R),{ref:k})):G8.createElement(L,e8({},R,{className:z,ref:k}),W))});F$.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};F$.classNames={fullWidth:BX,zeroRight:NX};var s4=E(m(),1);var aY=E(m(),1);var nn=E(m(),1);var pn;var dn=function(){if(pn)return pn;if(typeof __webpack_nonce__<"u")return __webpack_nonce__;return};function RH0(){if(!document)return null;var J=document.createElement("style");J.type="text/css";var Q=dn();if(Q)J.setAttribute("nonce",Q);return J}function kH0(J,Q){if(J.styleSheet)J.styleSheet.cssText=Q;else J.appendChild(document.createTextNode(Q))}function EH0(J){var Q=document.head||document.getElementsByTagName("head")[0];Q.appendChild(J)}var $C=function(){var J=0,Q=null;return{add:function(Z){if(J==0){if(Q=RH0())kH0(Q,Z),EH0(Q)}J++},remove:function(){if(J--,!J&&Q)Q.parentNode&&Q.parentNode.removeChild(Q),Q=null}}};var _C=function(){var J=$C();return function(Q,Z){nn.useEffect(function(){return J.add(Q),function(){J.remove()}},[Q&&Z])}};var U$=function(){var J=_C(),Q=function(Z){var{styles:q,dynamic:X}=Z;return J(q,X),null};return Q};var AH0={left:0,top:0,right:0,gap:0},FC=function(J){return parseInt(J||"",10)||0},CH0=function(J){var Q=window.getComputedStyle(document.body),Z=Q[J==="padding"?"paddingLeft":"marginLeft"],q=Q[J==="padding"?"paddingTop":"marginTop"],X=Q[J==="padding"?"paddingRight":"marginRight"];return[FC(Z),FC(q),FC(X)]},UC=function(J){if(J===void 0)J="margin";if(typeof window>"u")return AH0;var Q=CH0(J),Z=document.documentElement.clientWidth,q=window.innerWidth;return{left:Q[0],top:Q[1],right:Q[2],gap:Math.max(0,q-Z+Q[2]-Q[0])}};var PH0=U$(),rY="data-scroll-locked",IH0=function(J,Q,Z,q){var{left:X,top:K,right:Y,gap:W}=J;if(Z===void 0)Z="margin";return`
377
377
  .`.concat(KC,` {
378
378
  overflow: hidden `).concat(q,`;
379
379
  padding-right: `).concat(W,"px ").concat(q,`;
@@ -543,4 +543,4 @@ ${Z}
543
543
  ${(q?Q.height:0)-(Y?Y:0)}px)`:""} ${W}`,transformOrigin:Q?"0 0":"center center"}}function AL0({shape:J,src:Q}){let Z=M5(),q=R10(J),X=J.props.crop;if(q.transform&&X){let{transform:K,width:Y,height:W}=q,z=(X.bottomRight.x-X.topLeft.x)*Y,G=(X.bottomRight.y-X.topLeft.y)*W,$=[new M(0,0),new M(z,0),new M(z,G),new M(0,G)],H=b_(J,{width:Y,height:W});return C4.jsxs(C4.Fragment,{children:[C4.jsx("defs",{children:C4.jsx("clipPath",{id:Z,children:X.isCircle?C4.jsx("ellipse",{cx:z/2,cy:G/2,rx:z/2,ry:G/2}):C4.jsx("polygon",{points:$.map((_)=>`${_.x},${_.y}`).join(" ")})})}),C4.jsx("g",{clipPath:`url(#${Z})`,children:C4.jsx("image",{href:Q,width:Y,height:W,"aria-label":J.props.altText,style:H?{...H}:{transform:K}})})]})}else return C4.jsx("image",{href:Q,width:J.props.w,height:J.props.h,"aria-label":J.props.altText,style:b_(J,{width:J.props.w,height:J.props.h})})}function k10(J){let Q=!1;return{promise:new Promise((q)=>{let X=y7();X.onload=()=>{if(Q)return;let K=_4().createElement("canvas");K.width=X.width,K.height=X.height;let Y=K.getContext("2d");if(!Y)return;Y.drawImage(X,0,0),q(K.toDataURL())},X.crossOrigin="anonymous",X.src=J}),cancel:()=>Q=!0}}var YD=E(c(),1);var CL0=new C1;class WD extends s6{static type="line";static props=HG;static migrations=$G;options={getDefaultDisplayValues(J,Q,Z,q){let{color:X,size:K}=Q.props;return{strokeColor:W1(Z.colors[q],X,"solid"),strokeWidth:Z.strokeWidth*Q4[K]}},getCustomDisplayValues(){return{}}};hideResizeHandles(J){return!0}hideRotateHandle(J){return!0}hideSelectionBoundsFg(J){return!0}hideSelectionBoundsBg(J){return!0}hideInMinimap(){return!0}getDefaultProps(){let[J,Q]=R2(2);return{dash:"draw",size:"m",color:"black",spline:"line",points:{[J]:{id:J,index:J,x:0,y:0},[Q]:{id:Q,index:Q,x:0.1,y:0.1}},scale:1}}getGeometry(J){let Q=PT(J).toGeometry();return Q0(Q instanceof wY),Q}getHandles(J){return CL0.get(J.props,()=>{let Q=this.getGeometry(J),Z=T_(J),q=Z.map((X)=>({...X,id:X.index,type:"vertex",canSnap:!0}));for(let X=0;X<Z.length-1;X++){let K=r9(Z[X].index,Z[X+1].index),W=Q.getSegments()[X].interpolateAlongEdge(0.5);q.push({id:K,type:"create",index:K,x:W.x,y:W.y,canSnap:!0})}return q.sort(O4)})}onResize(J,Q){let{scaleX:Z,scaleY:q}=Q;return{props:{points:L5(J.props.points,(X,{id:K,index:Y,x:W,y:z})=>({id:K,index:Y,x:W*Z,y:z*q}))}}}onBeforeCreate(J){let{props:{points:Q}}=J,Z=Object.keys(Q);if(Z.length<2)return;let q=Q[Z[0]];if(Z.every((K)=>{let Y=Q[K];return Y.x===q.x&&Y.y===q.y})){let K=Z[Z.length-1];return Q[K]={...Q[K],x:Q[K].x+0.1,y:Q[K].y+0.1},J}return}onHandleDrag(J,{handle:Q}){let Z=j6(new M(Q.x,Q.y),this.editor);return{...J,props:{...J.props,points:{...J.props.points,[Q.id]:{id:Q.id,index:Q.index,x:Z.x,y:Z.y}}}}}onHandleDragStart(J,{handle:Q}){if(Q.type==="create")return{...J,props:{...J.props,points:{...J.props.points,[Q.index]:{id:Q.index,index:Q.index,x:Q.x,y:Q.y}}}};return}component(J){let Q=z6(),Z=k0(this,J,Q);return YD.jsx(J8,{style:{minWidth:50,minHeight:50},children:YD.jsx(E10,{shape:J,strokeColor:Z.strokeColor,strokeWidth:Z.strokeWidth})})}getIndicatorPath(J){let Q=k0(this,J).strokeWidth*J.props.scale,Z=PT(J),{dash:q}=J.props;return Z.toPath2D({style:q==="draw"?"draw":"solid",strokeWidth:1,passes:1,randomSeed:J.id,offset:0,roundness:Q*2})}toSvg(J,Q){let Z=k0(this,J,Q.colorMode);return YD.jsx(E10,{shouldScale:!0,shape:J,strokeColor:Z.strokeColor,strokeWidth:Z.strokeWidth})}getHandleSnapGeometry(J){let Q=T_(J);return{points:Q,getSelfSnapPoints:(Z)=>{let q=this.getHandles(J).filter((X)=>X.type==="vertex").findIndex((X)=>X.id===Z.id);return Q.filter((X,K)=>Math.abs(K-q)>1).map(M.From)},getSelfSnapOutline:(Z)=>{let q=this.getHandles(J).filter((K)=>K.type==="vertex").findIndex((K)=>K.id===Z.id),X=this.getGeometry(J).getSegments().filter((K,Y)=>Y!==q-1&&Y!==q);if(!X.length)return null;return new y4({children:X})}}}getInterpolatedProps(J,Q,Z){let q=T_(J),X=T_(Q),K=[],Y=[],W=tq;if(q.length>X.length)for(let z=0;z<q.length;z++){if(K[z]={...q[z]},X[z]===void 0)Y[z]={...X[X.length-1],id:W};else Y[z]={...X[z],id:W};W=p6(W)}else if(X.length>q.length)for(let z=0;z<X.length;z++){if(Y[z]={...X[z]},q[z]===void 0)K[z]={...q[q.length-1],id:W};else K[z]={...q[z],id:W};W=p6(W)}else for(let z=0;z<X.length;z++)K[z]=q[z],Y[z]=X[z];return{...Z>0.5?Q.props:J.props,points:Object.fromEntries(K.map((z,G)=>{let $=Y[G];return[z.id,{...z,x:I0(z.x,$.x,Z),y:I0(z.y,$.y,Z)}]})),scale:I0(J.props.scale,Q.props.scale,Z)}}}function T_(J){return Object.values(J.props.points).sort(O4)}var PL0=new C1;function PT(J){return PL0.get(J,()=>{let Q=T_(J).map(M.From);switch(J.props.spline){case"cubic":return I1.cubicSplineThroughPoints(Q,{endOffsets:0});case"line":return I1.lineThroughPoints(Q,{endOffsets:0})}})}function E10({shape:J,shouldScale:Q=!1,forceSolid:Z=!1,strokeColor:q,strokeWidth:X}){let K=PT(J),{dash:Y}=J.props,W=1/J.props.scale,z=Q?W:1,G=X*J.props.scale;return K.toSvg({style:Y,strokeWidth:G,forceSolid:Z,randomSeed:J.id,props:{transform:`scale(${z})`,stroke:q,fill:"none"}})}var m1=E(c(),1);var GD=E(m(),1);var IL0=Object.freeze({start:"start",middle:"center",end:"end","start-legacy":"start","end-legacy":"end","middle-legacy":"center"}),wL0=Object.freeze({start:"start",middle:"middle",end:"end"});class HD extends s6{static type="note";static props=_G;static migrations=FG;options={resizeMode:"none",getDefaultDisplayValues(J,Q,Z,q){let{color:X,labelColor:K,font:Y,size:W,align:z,verticalAlign:G}=Q.props,$=Z.colors[q];return{noteWidth:200,noteHeight:200,noteBackgroundColor:W1($,X,"noteFill"),borderColor:$.noteBorder,borderWidth:2,labelColor:K==="black"?W1($,X,"noteText"):W1($,K,"fill"),labelFontFamily:g9(Z,Y),labelFontSize:Z.fontSize*pH[W],labelLineHeight:Z.lineHeight,labelFontWeight:G5.fontWeight,labelFontVariant:G5.fontVariant,labelFontStyle:G5.fontStyle,labelPadding:JQ,labelHorizontalAlign:IL0[z],labelVerticalAlign:wL0[G]}},getCustomDisplayValues(){return{}}};canEdit(J){return!0}hideResizeHandles(J){let{resizeMode:Q}=this.options;switch(Q){case"none":return!0;case"scale":return!1;default:throw h0(Q)}}isAspectRatioLocked(J){return this.options.resizeMode==="scale"}hideSelectionBoundsFg(J){return!1}getDefaultProps(){return{color:"black",richText:x1(""),size:"m",font:"draw",align:"middle",verticalAlign:"middle",labelColor:"black",growY:0,fontSizeAdjustment:1,url:"",scale:1,textLastEditedBy:null}}getGeometry(J){let{labelHeight:Q,labelWidth:Z}=this.getLabelSize(J),{scale:q}=J.props,X=k0(this,J),K=Q*q,Y=Z*q,W=X.noteWidth*q,z=zD(J,X.noteHeight);return new y4({children:[new x4({width:W,height:z,isFilled:!0}),new x4({x:X.labelHorizontalAlign==="start"?0:X.labelHorizontalAlign==="end"?W-Y:(W-Y)/2,y:X.labelVerticalAlign==="start"?0:X.labelVerticalAlign==="end"?z-K:(z-K)/2,width:Y,height:K,isFilled:!0,isLabel:!0,excludeFromShapeBounds:!0})]})}getHandles(J){let{scale:Q}=J.props;if(this.editor.getInstanceState().isCoarsePointer)return[];let q=this.editor.getEfficientZoomLevel();if(q*Q<0.25)return[];let X=k0(this,J),K=zD(J,X.noteHeight),Y=X.noteWidth*Q,W=S00/q*Q;if(q*Q<0.5)return[{id:"bottom",index:"a3",type:"clone",x:Y/2,y:K+W}];return[{id:"top",index:"a1",type:"clone",x:Y/2,y:-W},{id:"right",index:"a2",type:"clone",x:Y+W,y:K/2},{id:"bottom",index:"a3",type:"clone",x:Y/2,y:K+W},{id:"left",index:"a4",type:"clone",x:-W,y:K/2}]}onResize(J,Q){let{resizeMode:Z}=this.options;switch(Z){case"none":return;case"scale":return tG(J,Q);default:throw h0(Z)}}getText(J){return u9(this.editor,J.props.richText)}getReferencedUserIds(J){return J.props.textLastEditedBy?[J.props.textLastEditedBy]:[]}getFontFaces(J){let Q=r1(J.props.richText)?[]:eJ(this.editor,J.props.richText,{family:`tldraw_${J.props.font}`,weight:"normal",style:"normal"});if(J.props.textLastEditedBy&&!r1(J.props.richText))return[...Q,YX.tldraw_sans.normal.normal];let Z=pZ(this.editor.getCurrentTheme(),J.props.font);if(Z)return[...Z,...Q];return Q.length?Q:Y1}component(J){let{id:Q,type:Z,props:q}=J,{scale:X,richText:K,fontSizeAdjustment:Y,textLastEditedBy:W}=q,z=bL0(Q),G=g("shape rotation",()=>this.editor.getShapePageTransform(Q)?.rotation()??0,[this.editor]),$=z6(),H=k0(this,J,$),_=H.noteWidth*X,F=zD(J,H.noteHeight),U=yq(0.25/X),V=J.id===this.editor.getOnlySelectedShapeId(),B=M_(this.editor,J.id),N=r1(K),L=g("attribution",()=>{if(!W||N)return null;let D=this.editor.getAttributionDisplayName(W);if(!D)return null;return{short:D.split(" ")[0],full:D}},[W,N,this.editor]);return m1.jsxs(m1.Fragment,{children:[m1.jsxs("div",{id:Q,className:"tl-note__container",style:{width:_,height:F,backgroundColor:H.noteBackgroundColor,borderBottom:U?`${H.borderWidth*X}px solid ${H.borderColor}`:"none",boxShadow:U?"none":TL0(J.id,G,X)},children:[L&&m1.jsx(J9,{content:L.full,side:"bottom",children:m1.jsx("div",{className:"tl-note__attribution",style:{["--note-attribution-scale"]:X,fontSize:11*X,color:H.labelColor,opacity:0.6},children:L.short})}),(V||B||!N)&&m1.jsx(mQ,{shapeId:Q,type:Z,fontFamily:H.labelFontFamily,fontSize:(Y??1)*H.labelFontSize,lineHeight:H.labelLineHeight,textAlign:H.labelHorizontalAlign,verticalAlign:H.labelVerticalAlign,richText:K,isSelected:V,labelColor:H.labelColor,wrap:!0,padding:H.labelPadding,hasCustomTabBehavior:!0,showTextOutline:!1,onKeyDown:z,style:X!==1?{transform:`scale(${X})`,transformOrigin:"top left",width:H.noteWidth,height:H.noteHeight+J.props.growY}:void 0})]}),"url"in J.props&&J.props.url&&m1.jsx(B2,{url:J.props.url})]})}getIndicatorPath(J){let{scale:Q}=J.props,Z=k0(this,J),q=new Path2D;return q.rect(0,0,Z.noteWidth*Q,zD(J,Z.noteHeight)),q}toSvg(J,Q){let Z=k0(this,J,Q.colorMode),q=new d(0,0,Z.noteWidth,Z.noteHeight+J.props.growY),X=`note-shadow-${J.id.replace(/:/g,"_")}`;Q.addExportDef({key:X,getElement:()=>m1.jsxs("filter",{id:X,x:"-10%",y:"-10%",width:"130%",height:"150%",children:[m1.jsx("feMorphology",{in:"SourceAlpha",operator:"erode",radius:"3",result:"erode1"}),m1.jsx("feGaussianBlur",{in:"erode1",stdDeviation:"3",result:"blur1"}),m1.jsx("feOffset",{in:"blur1",dy:"3",result:"offsetBlur1"}),m1.jsx("feComponentTransfer",{in:"offsetBlur1",result:"shadow1",children:m1.jsx("feFuncA",{type:"linear",slope:"0.5"})}),m1.jsx("feMorphology",{in:"SourceAlpha",operator:"erode",radius:"10",result:"erode2"}),m1.jsx("feGaussianBlur",{in:"erode2",stdDeviation:"6",result:"blur2"}),m1.jsx("feOffset",{in:"blur2",dy:"6",result:"offsetBlur2"}),m1.jsx("feComponentTransfer",{in:"offsetBlur2",result:"shadow2",children:m1.jsx("feFuncA",{type:"linear",slope:"0.5"})}),m1.jsxs("feMerge",{children:[m1.jsx("feMergeNode",{in:"shadow1"}),m1.jsx("feMergeNode",{in:"shadow2"}),m1.jsx("feMergeNode",{in:"SourceGraphic"})]})]})});let{textLastEditedBy:K}=J.props,Y=K&&!r1(J.props.richText)?this.editor.getAttributionDisplayName(K)?.split(" ")[0]??null:null;return m1.jsxs(m1.Fragment,{children:[Q.isDarkMode?null:m1.jsx("rect",{rx:1,width:Z.noteWidth,height:q.h,fill:Z.noteBackgroundColor,filter:`url(#${X})`}),m1.jsx("rect",{rx:1,width:Z.noteWidth,height:q.h,fill:Z.noteBackgroundColor}),m1.jsx(cQ,{fontSize:(J.props.fontSizeAdjustment??1)*Z.labelFontSize,fontFamily:Z.labelFontFamily,lineHeight:Z.labelLineHeight,textAlign:Z.labelHorizontalAlign,verticalAlign:Z.labelVerticalAlign,richText:J.props.richText,labelColor:Z.labelColor,bounds:q,padding:Z.labelPadding,showTextOutline:!1}),Y&&m1.jsx("foreignObject",{x:0,y:0,width:Z.noteWidth,height:q.h,className:"tl-export-embed-styles",children:m1.jsx("div",{style:{position:"relative",width:"100%",height:"100%"},children:m1.jsx("div",{className:"tl-note__attribution",style:{fontSize:11,color:Z.labelColor,opacity:0.6},children:Y})})})]})}onBeforeCreate(J){return this.getNoteSizeAdjustments(J)}onBeforeUpdate(J,Q){let Z=!V6.default(J.props.richText,Q.props.richText);if(!Z&&J.props.font===Q.props.font&&J.props.size===Q.props.size)return;let q=Q;if(Z)if(r1(Q.props.richText))q={...q,props:{...q.props,textLastEditedBy:null}};else q={...q,props:{...q.props,textLastEditedBy:this.editor.getAttributionUserId()}};return this.getNoteSizeAdjustments(q)??(Z?q:void 0)}getInterpolatedProps(J,Q,Z){return{...Z>0.5?Q.props:J.props,scale:I0(J.props.scale,Q.props.scale,Z)}}getNoteSizeAdjustments(J){let Q=k0(this,J),{labelHeight:Z,fontSizeAdjustment:q}=this.getLabelSize(J),X=Math.max(0,Z-Q.noteHeight);if(X!==J.props.growY||q!==J.props.fontSizeAdjustment)return{...J,props:{...J.props,growY:X,fontSizeAdjustment:q}};return}_labelSizesForNoteCache=new C1;getLabelSize(J){return this._labelSizesForNoteCache.get(J,()=>this.measureNoteLabelSize(J))}measureNoteLabelSize(J){let Q=k0(this,J),{richText:Z}=J.props;if(r1(Z))return{labelHeight:i8(Q.labelFontSize,Q.labelLineHeight)+Q.labelPadding*2,labelWidth:100,fontSizeAdjustment:1};let q=Q.labelFontSize,X=q,K=0,Y=Q.noteHeight,W=Q.noteWidth,z=1;do{X=Math.min(q,q-K);let G=h9(this.editor,Z),$=this.editor.textMeasure.measureHtml(G,{...G5,lineHeight:Q.labelLineHeight,fontFamily:Q.labelFontFamily,fontSize:X,maxWidth:Q.noteWidth-Q.labelPadding*2-z,disableOverflowWrapBreaking:!0,measureScrollWidth:!0});if(Y=$.h+Q.labelPadding*2,W=$.w+Q.labelPadding*2,X<=14){let H=h9(this.editor,Z),_=this.editor.textMeasure.measureHtml(H,{...G5,lineHeight:Q.labelLineHeight,fontFamily:Q.labelFontFamily,fontSize:X,maxWidth:Q.noteWidth-Q.labelPadding*2-z});Y=_.h+Q.labelPadding*2,W=_.w+Q.labelPadding*2;break}if($.scrollWidth.toFixed(0)===$.w.toFixed(0))break}while(K++<50);return{labelHeight:Y,labelWidth:W,fontSizeAdjustment:X===q?1:X/q}}}function bL0(J){let Q=v(),Z=GD.useContext(uH);return GD.useCallback((q)=>{let X=Q.getShape(J);if(!X)return;let K=q.key==="Tab",Y=(q.metaKey||q.ctrlKey)&&q.key==="Enter";if(K&&xN(Q)){q.preventDefault();return}if(K||Y){q.preventDefault();let W=Q.getShapePageTransform(J),z=W.rotation(),G=!!(Z?.dir==="rtl"||vN(u9(Q,X.props.richText))),$=Q.getShapeUtil(X),H=k0($,X),F=(K?H.noteWidth+Q.options.adjacentShapeMargin:H.noteHeight+Q.options.adjacentShapeMargin+(Y&&!q.shiftKey?X.props.growY:0))*X.props.scale,U=new M(K?q.shiftKey!=G?-1:1:0,Y?q.shiftKey?-1:1:0).mul(F).add(new M(H.noteWidth/2,H.noteHeight/2).mul(X.props.scale)).rot(z).add(W.point()),V=vO(Q,{shape:X,center:U,pageRotation:z,noteWidth:H.noteWidth,noteHeight:H.noteHeight});if(V)S4(Q,V,{selectAll:!0})}},[J,Q,Z?.dir])}function zD(J,Q){return(Q+J.props.growY)*J.props.scale}function TL0(J,Q,Z){let q=N9(J),X=Math.abs(q())+0.5,K=Math.cos(Q),Y=5*Z,W=4*Z,z=6*Z,G=7*Z;return`0px ${Math.max(0,Y-X)}px ${Y}px -${Y}px rgba(15, 23, 31, .6),
544
544
  0px ${(W+X*G)*Math.max(0,K)}px ${z+X*G}px -${W+X*z}px rgba(15, 23, 31, ${(0.3+X*0.1).toFixed(2)}),
545
545
  0px ${48*Z}px ${10*Z}px -${10*Z}px inset rgba(15, 23, 44, ${((0.022+q()*0.005)*((1+K)/2)).toFixed(2)})`}var IT=E(c(),1);var A10=E(m(),1);var yL0=0.3,xL0=M9("text size",(J,Q)=>{J.fonts.trackFontsForShape(Q);let Z=J.getShapeUtil(Q),q=k0(Z,Q);return C10(J,Q.props,q)},{areRecordsEqual:(J,Q)=>J.props===Q.props});class $D extends s6{static type="text";static props=UG;static migrations=VG;options={extraArrowHorizontalPadding:10,showTextOutline:!0,getDefaultDisplayValues(J,Q,Z,q){let{color:X,font:K,size:Y}=Q.props;return{color:W1(Z.colors[q],X,"solid"),fontFamily:g9(Z,K),fontSize:Z.fontSize*o3[Y],lineHeight:Z.lineHeight,fontWeight:G5.fontWeight,fontStyle:G5.fontStyle,fontVariant:G5.fontVariant}},getCustomDisplayValues(){return{}}};getDefaultProps(){return{color:"black",size:"m",w:8,font:"draw",textAlign:"start",autoSize:!0,scale:1,richText:x1("")}}getMinDimensions(J){return xL0.get(this.editor,J.id)}getGeometry(J,Q){let{scale:Z}=J.props,{width:q,height:X}=this.getMinDimensions(J),K=Q?.context??"none";return new x4({x:(K==="@tldraw/arrow-without-arrowhead"?-this.options.extraArrowHorizontalPadding:0)*Z,width:(q+(K==="@tldraw/arrow-without-arrowhead"?this.options.extraArrowHorizontalPadding*2:0))*Z,height:X*Z,isFilled:!0,isLabel:!0})}getFontFaces(J){let Q=pZ(this.editor.getCurrentTheme(),J.props.font);if(Q)return Q;return eJ(this.editor,J.props.richText,{family:`tldraw_${J.props.font}`,weight:"normal",style:"normal"})}getText(J){return u9(this.editor,J.props.richText)}canEdit(J){return!0}isAspectRatioLocked(J){return!0}component(J){let{id:Q,props:{richText:Z,scale:q,textAlign:X}}=J,{width:K,height:Y}=this.getMinDimensions(J),W=J.id===this.editor.getOnlySelectedShapeId(),z=z6(),G=k0(this,J,z),$=vL0(Q);return IT.jsx(mQ,{shapeId:Q,classNamePrefix:"tl-text-shape",type:"text",fontFamily:G.fontFamily,fontSize:G.fontSize,lineHeight:G.lineHeight,textAlign:X==="middle"?"center":X,verticalAlign:"middle",richText:Z,labelColor:G.color,isSelected:W,textWidth:K,textHeight:Y,showTextOutline:this.options.showTextOutline,style:{transform:`scale(${q})`,transformOrigin:"top left"},wrap:!0,onKeyDown:$})}getIndicatorPath(J){if(J.props.autoSize&&this.editor.getEditingShapeId()===J.id)return;let Q=this.editor.getShapeGeometry(J).bounds,Z=new Path2D;return Z.rect(0,0,Q.width,Q.height),Z}toSvg(J,Q){let Z=this.editor.getShapeGeometry(J).bounds,q=Z.width/(J.props.scale??1),X=Z.height/(J.props.scale??1),K=k0(this,J,Q.colorMode),Y=Math.ceil(K.fontSize*yL0),W=new d(-Y,-Y,q+Y*2,X+Y*2);return IT.jsx(cQ,{fontSize:K.fontSize,fontFamily:K.fontFamily,lineHeight:K.lineHeight,textAlign:J.props.textAlign==="middle"?"center":J.props.textAlign,verticalAlign:"middle",richText:J.props.richText,labelColor:K.color,bounds:W,padding:Y,showTextOutline:this.options.showTextOutline})}onResize(J,Q){let{newPoint:Z,initialBounds:q,initialShape:X,scaleX:K,handle:Y}=Q;if(Q.mode==="scale_shape"||Y!=="right"&&Y!=="left")return{id:J.id,type:J.type,...tG(J,Q)};else{let W=Math.max(1,Math.abs(q.width*K)),{x:z,y:G}=K<0?M.Sub(Z,M.FromAngle(J.rotation).mul(W)):Z;return{id:J.id,type:J.type,x:z,y:G,props:{w:W/X.props.scale,autoSize:!1}}}}onEditEnd(J){if(u9(this.editor,J.props.richText).trimEnd().length===0)this.editor.deleteShapes([J.id])}onBeforeUpdate(J,Q){if(!Q.props.autoSize)return;let Z=J.props.size!==Q.props.size||J.props.textAlign!==Q.props.textAlign||J.props.font!==Q.props.font||J.props.scale!==1&&Q.props.scale===1,q=!V6.default(J.props.richText,Q.props.richText);if(!Z&&!q)return;let X=this.getMinDimensions(J),K=k0(this,Q),Y=C10(this.editor,Q.props,K),W=X.width*J.props.scale,z=X.height*J.props.scale,G=Y.width*Q.props.scale,$=Y.height*Q.props.scale,H;switch(Q.props.textAlign){case"middle":{H=new M((G-W)/2,q?0:($-z)/2);break}case"end":{H=new M(G-W,q?0:($-z)/2);break}default:{if(q)break;H=new M(0,($-z)/2);break}}if(H){H.rot(Q.rotation);let{x:_,y:F}=Q;return{...Q,x:_-H.x,y:F-H.y,props:{...Q.props,w:G}}}else return{...Q,props:{...Q.props,w:G}}}}function C10(J,Q,Z){let{richText:q,w:X}=Q,K=16,Y=Q.autoSize?null:Math.max(16,Math.floor(X)),W=h9(J,q),z=J.textMeasure.measureHtml(W,{lineHeight:Z.lineHeight,fontWeight:Z.fontWeight,fontStyle:Z.fontStyle,padding:"0px",fontFamily:Z.fontFamily,fontSize:Z.fontSize,maxWidth:Y});return{width:Y??Math.max(16,z.w+1),height:Math.max(Z.fontSize,z.h)}}function vL0(J){let Q=v();return A10.useCallback((Z)=>{if(Q.getEditingShapeId()!==J)return;switch(Z.key){case"Enter":{if(Z.ctrlKey||Z.metaKey)Q.complete();break}}},[Q,J])}var y5=E(c(),1);var P10=E(c1(),1),b7=E(m(),1);var SL0=new C1;class _D extends n8{static type="video";static props=NG;static migrations=BG;static handledAssetTypes=["video"];options={autoplay:!0,getDefaultDisplayValues(){return{}},getCustomDisplayValues(){return{}}};canEdit(J){return!0}isAspectRatioLocked(J){return!0}getDefaultProps(){return{w:100,h:100,assetId:null,autoplay:this.options.autoplay,url:"",altText:"",time:0,playing:!0}}createShapeForAsset(J,Q){let Z=J;return{id:l0(),type:"video",x:Q.x,y:Q.y,opacity:1,props:{assetId:Z.id,w:Z.props.w,h:Z.props.h}}}getAriaDescriptor(J){return J.props.altText}component(J){return y5.jsx(fL0,{shape:J})}getIndicatorPath(J){let Q=new Path2D;return Q.rect(0,0,J.props.w,J.props.h),Q}async toSvg(J,Q){let Z=J.props;if(!Z.assetId)return null;let q=this.editor.getAsset(Z.assetId);if(!q)return null;let X=await SL0.get(q,async()=>{let K=await Q.resolveAssetUrl(q.id,Z.w);if(!K)return null;let Y=await l6.loadVideo(K,this.editor.getContainerDocument());return await l6.getVideoFrameAsDataUrl(Y,0)});if(!X)return null;return y5.jsx("image",{href:X,width:Z.w,height:Z.h,"aria-label":J.props.altText})}}var fL0=b7.memo(function({shape:Q}){let Z=v(),q=Z.getShapeGeometry(Q).bounds.w*Z.getEfficientZoomLevel()>=110,X=cJ(Q.id),K=fH(),{Spinner:Y}=T4(),{asset:W,url:z}=P_({shapeId:Q.id,assetId:Q.props.assetId,width:Q.props.w}),G=b7.useRef(null),[$,H]=b7.useState(!1),_=b7.useCallback((V)=>{if(!V.currentTarget)return;H(!0)},[]),[F,U]=b7.useState(!1);return b7.useEffect(()=>{let V=G.current?.ownerDocument??Z.getContainerDocument(),B=()=>U(V.fullscreenElement===G.current);return V.addEventListener("fullscreenchange",B),()=>V.removeEventListener("fullscreenchange",B)}),b7.useEffect(()=>{let V=G.current;if(!V)return;if(X){if(V.ownerDocument.activeElement!==V)V.focus()}},[X,$]),y5.jsxs(y5.Fragment,{children:[y5.jsx(c8,{id:Q.id,style:{color:"var(--tl-color-text-3)",backgroundColor:W?"transparent":"var(--tl-color-low)",border:W?"none":"1px solid var(--tl-color-low-border)"},children:y5.jsx("div",{className:"tl-counter-scaled",children:y5.jsx("div",{className:"tl-video-container",children:!W?y5.jsx(qD,{}):Y&&!W.props.src?y5.jsx(Y,{}):z?y5.jsxs(y5.Fragment,{children:[y5.jsx("video",{ref:G,style:X?{pointerEvents:"all"}:!$?{display:"none"}:void 0,className:P10.default("tl-video",`tl-video-shape-${Q.id.split(":")[1]}`,{"tl-video-is-fullscreen":F}),width:"100%",height:"100%",draggable:!1,playsInline:!0,autoPlay:Q.props.autoplay&&!K,muted:!0,loop:!0,disableRemotePlayback:!0,disablePictureInPicture:!0,controls:X&&q,onLoadedData:_,hidden:!$,"aria-label":Q.props.altText,children:y5.jsx("source",{src:z})},z),!$&&Y&&y5.jsx(Y,{})]}):null})})}),"url"in Q.props&&Q.props.url&&y5.jsx(B2,{url:Q.props.url})]})});var eX=[$D,pO,nO,eO,HD,WD,tO,cO,ZD,vq,KD,_D];function wT(J){let Q=J.sideEffects.register({instance:{afterChange:(Z,q)=>{if(Z.cameraState!==q.cameraState&&q.cameraState==="idle")V2(J)}},instance_page_state:{afterChange:(Z,q)=>{if(Z.croppingShapeId!==q.croppingShapeId){let X=J.isIn("select.crop");if(!Z.croppingShapeId&&q.croppingShapeId){if(!X)J.setCurrentTool("select.crop.idle")}else if(Z.croppingShapeId&&!q.croppingShapeId){if(X)J.setCurrentTool("select.idle")}}if(Z.editingShapeId!==q.editingShapeId){if(!Z.editingShapeId&&q.editingShapeId){if(!J.isIn("select.editing_shape")){let X=J.getEditingShape();if(X&&X.type==="text"&&J.isInAny("text.pointing","select.resizing")&&J.getInstanceState().isToolLocked)J.setCurrentTool("select.editing_shape",{target:"shape",shape:X,isCreatingTextWhileToolLocked:!0});else J.setCurrentTool("select.editing_shape",{target:"shape",shape:X})}}else if(Z.editingShapeId&&!q.editingShapeId){if(J.isIn("select.editing_shape"))J.setCurrentTool("select.idle")}}}}});return()=>{Q(),wq(J)}}class bT extends a{static id="erasing";static trackPerformance=!0;info={};scribbleId="id";markId="";excludedShapeIds=new Set;_erasingShapeIds=[];onEnter(J){this.markId=this.editor.markHistoryStoppingPoint("erase scribble begin"),this.info=J;let Q=this.editor.inputs.getOriginPagePoint();this.excludedShapeIds=new Set(this.editor.getCurrentPageShapes().filter((q)=>{if(this.editor.isShapeOrAncestorLocked(q))return!0;if(this.editor.isShapeOfType(q,"group")||this.editor.isShapeFrameLike(q)){let X=this.editor.getPointInShapeSpace(q,Q);return this.editor.getShapeGeometry(q).bounds.containsPoint(X)}return!1}).map((q)=>q.id)),this._erasingShapeIds=this.editor.getShapesAtPoint(Q).filter((q)=>!this.excludedShapeIds.has(q.id)).map((q)=>q.id),this.editor.setErasingShapes([...new Set([...this.editor.getErasingShapeIds(),...this._erasingShapeIds])]);let Z=this.editor.scribbles.addScribble({color:"muted-1",size:12});this.scribbleId=Z.id,this.update()}pushPointToScribble(){let{x:J,y:Q}=this.editor.inputs.getCurrentPagePoint();this.editor.scribbles.addPoint(this.scribbleId,J,Q)}onExit(){this.editor.setErasingShapes([]),this.editor.scribbles.stop(this.scribbleId)}onPointerMove(){this.update()}onPointerUp(J){this.complete(J)}onCancel(){this.cancel()}onComplete(){this.complete()}update(){let{editor:J,excludedShapeIds:Q}=this,Z=J.getErasingShapeIds(),q=J.getZoomLevel(),X=J.inputs.getCurrentPagePoint(),K=J.inputs.getPreviousPagePoint();this.pushPointToScribble();let Y=new Set(Z),W=this.editor.options.hitTestMargin/q,z=d.FromPoints([K,X]).expandBy(W),G=J.getShapeIdsInsideBounds(z);if(G.size===0){J.setErasingShapes(Array.from(Y));return}let H=J.getCurrentPageRenderingShapesSorted().filter((_)=>G.has(_.id));for(let _ of H){if(J.isShapeOfType(_,"group"))continue;let F=J.getShapeMask(_.id);if(F&&!n1(X,F))continue;let U=J.getShapeGeometry(_),V=J.getShapePageTransform(_);if(!U||!V)continue;let B=V.clone().invert(),N=B.applyToPoint(K),L=B.applyToPoint(X),{bounds:D}=U;if(D.minX-W>Math.max(N.x,L.x)||D.minY-W>Math.max(N.y,L.y)||D.maxX+W<Math.min(N.x,L.x)||D.maxY+W<Math.min(N.y,L.y))continue;if(U.hitTestLineSegment(N,L,W)){let O=J.getOutermostSelectableShape(_);if(Q.has(O.id))Y.add(J.getOutermostSelectableShape(_,(j)=>!Q.has(j.id)).id);else Y.add(O.id)}this._erasingShapeIds=[...Y]}this.editor.setErasingShapes(this._erasingShapeIds.filter((_)=>!Q.has(_)))}complete(J){let{editor:Q}=this;Q.deleteShapes(Q.getCurrentPageState().erasingShapeIds),this.parent.transition("idle",J),this._erasingShapeIds=[]}cancel(){let{editor:J}=this;J.bailToMark(this.markId),this.parent.transition("idle",this.info)}}class TT extends a{static id="idle";onEnter(J){if(!(J?.accelKey??this.editor.inputs.getAccelKey()))this.parent.maybeReturnToOriginatingTool()}onKeyUp(J){if(!J6(J))this.parent.maybeReturnToOriginatingTool()}onPointerDown(J){this.parent.transition("pointing",J)}onCancel(){let J=this.parent.info.onInteractionEnd;this.editor.setCurrentTool(J??"select")}}class yT extends a{static id="pointing";onEnter(J){let Q=J.accelKey,Z=this.editor.getZoomLevel(),q=this.editor.getCurrentPageRenderingShapesSorted(),X=this.editor.inputs.getCurrentPagePoint(),K=new Set,Y=K.size;for(let W=q.length,z=W-1;z>=0;z--){let G=q[z];if(this.editor.isShapeOrAncestorLocked(G)||this.editor.isShapeOfType(G,"group"))continue;if(this.editor.isPointInShape(G,X,{hitInside:!1,margin:this.editor.options.hitTestMargin/Z})){let $=this.editor.getOutermostSelectableShape(G);if(this.editor.isShapeFrameLike($)&&K.size>Y)break;if(K.add($.id),Q)break}}this.editor.setErasingShapes([...K])}onLongPress(J){if(J.accelKey)return;this.startErasing(J)}onExit(J,Q){if(Q!=="erasing")this.editor.setErasingShapes([])}onPointerMove(J){if(this.editor.inputs.getIsDragging())this.startErasing(J)}onPointerUp(J){this.complete(J)}onCancel(){this.cancel()}onComplete(){this.complete()}onInterrupt(){this.cancel()}startErasing(J){this.parent.transition("erasing",J)}complete(J){let Q=this.editor.getErasingShapeIds();if(Q.length)this.editor.markHistoryStoppingPoint("erase end"),this.editor.deleteShapes(Q);this.parent.transition("idle",J)}cancel(){this.parent.transition("idle")}}class FD extends a{static id="eraser";static initial="idle";static isLockable=!1;static children(){return[TT,yT,bT]}info={};onEnter(J={}){if(this.info=J,J.onInteractionEnd)this.setCurrentToolIdMask(J.onInteractionEnd);this.editor.setCursor({type:"cross",rotation:0})}onExit(){this.setCurrentToolIdMask(void 0),this.info={}}maybeReturnToOriginatingTool(){let{onInteractionEnd:J}=this.info;if(!J)return;this.editor.setCurrentTool(J)}}class xT extends a{static id="dragging";static trackPerformance=!0;initialCamera=new M;onEnter(){this.initialCamera=M.From(this.editor.getCamera()),this.update()}onPointerMove(){this.update()}onPointerDown(){this.parent.transition("idle")}onPointerUp(){this.complete()}onInterrupt(){this.parent.transition("idle")}onCancel(){this.parent.transition("idle")}onComplete(){this.complete()}update(){let{initialCamera:J,editor:Q}=this,Z=Q.inputs.getCurrentScreenPoint(),q=Q.inputs.getOriginScreenPoint(),X=M.Sub(Z,q).div(Q.getZoomLevel());if(X.len2()===0)return;Q.setCamera(J.clone().add(X))}complete(){let{editor:J}=this,Q=J.inputs.getPointerVelocity(),Z=Math.min(Q.len(),2);if(Z>0.1)this.editor.slideCamera({speed:Z,direction:{x:Q.x,y:Q.y,z:0}});this.parent.transition("idle")}}class vT extends a{static id="idle";onEnter(){this.editor.setCursor({type:"grab",rotation:0})}onPointerDown(J){this.parent.transition("pointing",J)}onCancel(){this.editor.setCurrentTool("select")}}class ST extends a{static id="one_finger_zooming";anchorScreenPoint=new M;initialCamera=new M;initialZoom=1;originScreenY=0;onEnter(J){let Q=this.editor.getCamera();this.initialCamera=M.From(Q),this.initialZoom=Q.z,this.anchorScreenPoint=this.editor.inputs.getOriginScreenPoint().clone(),this.originScreenY=this.editor.inputs.getCurrentScreenPoint().y,this.editor.setCursor({type:"grab",rotation:0})}onPointerMove(J){this.editor.menus.clearOpenMenus();let Q=this.editor.inputs.getCurrentScreenPoint().y,Z=(this.originScreenY-Q)*-1,q=Math.pow(2,Z/200),X=this.clampZoom(this.initialZoom*q),{x:K,y:Y}=this.initialCamera,{x:W,y:z}=this.anchorScreenPoint;this.editor.setCamera(new M(K+W/X-W/this.initialZoom,Y+z/X-z/this.initialZoom,X),{immediate:!0})}onPointerUp(J){this.complete()}onCancel(){this.parent.transition("idle")}onInterrupt(){this.parent.transition("idle")}complete(){let J=this.editor.inputs.getPointerVelocity(),Q=Math.min(J.len(),2);if(Q>0.1)this.editor.slideCamera({speed:Q,direction:{x:0,y:0,z:Math.sign(J.y)*0.01}});this.parent.transition("idle")}clampZoom(J){let{zoomSteps:Q}=this.editor.getCameraOptions(),Z=this.editor.getBaseZoom(),q=Q[0]*Z,X=Y6(Q)*Z;return M0(J,q,X)}}class fT extends a{static id="pointing";onEnter(){this.editor.stopCameraAnimation(),this.editor.setCursor({type:"grabbing",rotation:0})}onLongPress(){this.startDragging()}onPointerMove(){if(this.editor.inputs.getIsDragging())this.startDragging()}startDragging(){this.parent.transition("dragging")}onPointerUp(){this.complete()}onCancel(){this.complete()}onComplete(){this.complete()}onInterrupt(){this.complete()}complete(){this.parent.transition("idle")}}class UD extends a{static id="hand";static initial="idle";static isLockable=!1;static children(){return[vT,fT,xT,ST]}onDoubleClick(J){switch(J.phase){case"settle-down":{if(this.editor.getInstanceState().isCoarsePointer)this.transition("one_finger_zooming",J);break}case"settle-up":{let Q=this.editor.inputs.getCurrentScreenPoint();this.editor.zoomIn(Q,{animation:{duration:220,easing:O6.easeOutQuint}});break}}}}class gT extends a{static id="idle";onPointerDown(){let J=this.parent.getSessionId(),Q=this.editor.scribbles.addScribbleToSession(J,{color:"laser",opacity:0.7,size:4,taper:!1});this.parent.transition("lasering",{sessionId:J,scribbleId:Q.id})}}class hT extends a{static id="lasering";static trackPerformance=!0;scribbleId="";sessionId="";onEnter(J){this.sessionId=J.sessionId,this.scribbleId=J.scribbleId,this.pushPointToScribble()}onPointerMove(){this.pushPointToScribble()}pushPointToScribble(){let{x:J,y:Q}=this.editor.inputs.getCurrentPagePoint();this.editor.scribbles.addPointToSession(this.sessionId,this.scribbleId,J,Q)}onTick(){this.editor.scribbles.extendSession(this.sessionId)}onPointerUp(){this.complete()}onCancel(){this.onComplete()}onComplete(){this.complete()}complete(){this.editor.scribbles.complete(this.scribbleId),this.parent.transition("idle")}}class VD extends a{static id="laser";static initial="idle";static children(){return[gT,hT]}static isLockable=!1;sessionId=null;onEnter(){this.editor.setCursor({type:"cross",rotation:0})}onExit(){this.sessionId=null}onCancel(){if(this.sessionId&&this.editor.scribbles.isSessionActive(this.sessionId))this.editor.scribbles.clearSession(this.sessionId),this.sessionId=null,this.transition("idle");else this.editor.setCurrentTool("select")}getSessionId(){if(this.sessionId&&this.editor.scribbles.isSessionActive(this.sessionId))return this.sessionId;return this.sessionId=this.editor.scribbles.startSession({selfConsume:!1,idleTimeoutMs:this.editor.options.laserDelayMs,fadeMode:"grouped",fadeEasing:"ease-in"}),this.sessionId}}class uT extends a{static id="brushing";static trackPerformance=!0;info={};initialSelectedShapeIds=[];excludedShapeIds=new Set;isWrapMode=!1;viewportDidChange=!1;cleanupViewportChangeReactor(){}onEnter(J){let{editor:Q}=this,Z=Q.inputs.getAltKey();this.isWrapMode=Q.user.getIsWrapMode(),this.viewportDidChange=!1;let q=!0;if(this.cleanupViewportChangeReactor=P1("viewport change while brushing",()=>{if(Q.getViewportPageBounds(),!q&&!this.viewportDidChange)this.viewportDidChange=!0}),Z){this.parent.transition("scribble_brushing",J);return}let X=Q.options.selectLockedShapes;this.excludedShapeIds=new Set(Q.getCurrentPageShapes().filter((K)=>Q.isShapeOfType(K,"group")||!X&&Q.isShapeOrAncestorLocked(K)).map((K)=>K.id)),this.info=J,this.initialSelectedShapeIds=Q.getSelectedShapeIds().slice(),this.hitTestShapes(),q=!1}onExit(){this.initialSelectedShapeIds=[],this.editor.updateInstanceState({brush:null}),this.cleanupViewportChangeReactor()}onTick({elapsed:J}){let{editor:Q}=this;if(!Q.inputs.getIsDragging()||Q.inputs.getIsPanning())return;Q.edgeScrollManager.updateEdgeScrolling(J)}onPointerMove(){this.hitTestShapes()}onPointerUp(){this.complete()}onComplete(){this.complete()}onCancel(J){this.editor.setSelectedShapes(this.initialSelectedShapeIds),this.parent.transition("idle",J)}onKeyDown(J){if(this.editor.inputs.getAltKey())this.parent.transition("scribble_brushing",J);else this.hitTestShapes()}onKeyUp(){this.hitTestShapes()}complete(){this.hitTestShapes(),this.parent.transition("idle")}hitTestShapes(){let{editor:J,excludedShapeIds:Q,isWrapMode:Z}=this,q=J.inputs.getOriginPagePoint(),X=J.inputs.getCurrentPagePoint(),K=J.inputs.getShiftKey(),Y=J.inputs.getCtrlKey(),W=new Set(K?this.initialSelectedShapeIds:[]),z=Z?!Y:Y,G=d.FromPoints([q,X]),{corners:$}=G,H,_,F,U,V,B,N=J.getViewportPageBounds().contains(G),L=J.getCurrentPageId(),D=J.getShapeIdsInsideBounds(G);if(D.size===0){let P=J.getInstanceState().brush;if(!P||!G.equals(P))J.updateInstanceState({brush:{...G.toJson()}});let A=J.getSelectedShapeIds();if(A.length!==W.size||A.some((I)=>!W.has(I)))J.setSelectedShapes(Array.from(W));return}let j=(N&&!this.viewportDidChange?J.getCurrentPageRenderingShapesSorted():J.getCurrentPageShapesSorted()).filter((P)=>D.has(P.id));J:for(let P=0,A=j.length;P<A;P++){if(F=j[P],Q.has(F.id)||W.has(F.id))continue J;if(U=J.getShapePageBounds(F),!U)continue J;if(G.contains(U)){this.handleHit(F,X,L,W,$);continue J}if(z||J.isShapeFrameLike(F))continue J;if(G.collides(U)){if(V=J.getShapePageTransform(F),!V)continue J;B=V.clone().invert().applyToPoints($);let I=J.getShapeGeometry(F);Q:for(let C=0;C<4;C++)if(H=B[C],_=B[(C+1)%4],I.hitTestLineSegment(H,_,0)){this.handleHit(F,X,L,W,$);break Q}}}let k=J.getInstanceState().brush;if(!k||!G.equals(k))J.updateInstanceState({brush:{...G.toJson()}});let R=J.getSelectedShapeIds();if(R.length!==W.size||R.some((P)=>!W.has(P)))J.setSelectedShapes(Array.from(W))}onInterrupt(){this.editor.updateInstanceState({brush:null})}handleHit(J,Q,Z,q,X){if(J.parentId===Z){q.add(J.id);return}let K=this.editor.getOutermostSelectableShape(J),Y=this.editor.getShapeMask(K.id);if(Y&&!yG(Y,X)&&!n1(Q,Y))return;q.add(K.id)}}var VJ={bottom:"ns-resize",top:"ns-resize",left:"ew-resize",right:"ew-resize",bottom_left:"nesw-resize",bottom_right:"nwse-resize",top_left:"nwse-resize",top_right:"nesw-resize",bottom_left_rotate:"swne-rotate",bottom_right_rotate:"senw-rotate",top_left_rotate:"nwse-rotate",top_right_rotate:"nesw-rotate",mobile_rotate:"grabbing"};class mT extends a{static id="pointing_resize_handle";info={};updateCursor(){let J=VJ[this.info.handle];this.editor.setCursor({type:J,rotation:this.editor.getSelectionRotation()})}onEnter(J){if(this.info=J,typeof J.onInteractionEnd==="string")this.parent.setCurrentToolIdMask(J.onInteractionEnd);this.updateCursor()}onExit(){this.parent.setCurrentToolIdMask(void 0)}onPointerMove(){if(this.editor.inputs.getIsDragging())this.startResizing()}onLongPress(){this.startResizing()}startResizing(){if(this.editor.getIsReadonly())return;this.parent.transition("resizing",this.info)}onPointerUp(){this.complete()}onDoubleClick(J){if(this.editor.inputs.getShiftKey()||J.phase!=="down"||J.ctrlKey||J.shiftKey)return;this.parent.transition("idle"),this.parent.getCurrent()?.handleEvent(J)}onCancel(){this.cancel()}onComplete(){this.cancel()}onInterrupt(){this.cancel()}complete(){let{onInteractionEnd:J}=this.info;if(J){if(typeof J==="string")this.editor.setCurrentTool(J,{});else J();return}this.parent.transition("idle")}cancel(){let{onInteractionEnd:J}=this.info;if(J){if(typeof J==="string")this.editor.setCurrentTool(J,{});else J();return}this.parent.transition("idle")}}class y_ extends a{static id="cropping";static trackPerformance=!0;info={};markId="";snapshot={};onEnter(J){if(this.info=J,typeof J.onInteractionEnd==="string")this.parent.setCurrentToolIdMask(J.onInteractionEnd);this.markId=this.editor.markHistoryStoppingPoint("cropping"),this.snapshot=this.createSnapshot(),this.updateShapes()}onPointerMove(){this.updateShapes()}onKeyDown(){this.updateShapes()}onKeyUp(){this.updateShapes()}onPointerUp(){this.complete()}onComplete(){this.complete()}onCancel(){this.cancel()}onExit(){this.parent.setCurrentToolIdMask(void 0)}updateCursor(){if(!this.editor.getSelectedShapes()[0])return;let Q=VJ[this.info.handle];this.editor.setCursor({type:Q,rotation:this.editor.getSelectionRotation()})}updateShapes(){let{shape:J,cursorHandleOffset:Q}=this.snapshot;if(!J)return;let Z=this.editor.getShapeUtil(J.type);if(!Z)return;let q=this.editor.inputs.getShiftKey(),X=this.editor.inputs.getCurrentPagePoint().clone().sub(Q),K=this.editor.inputs.getOriginPagePoint().clone().sub(Q),Y=X.clone().sub(K).rot(-J.rotation),W=J.props.crop??a8(),z=A8(J.props,W),$=(Z.onCrop?.bind(Z)??yE)(J,{handle:this.info.handle,change:Y,crop:W,uncroppedSize:z,initialShape:this.snapshot.shape,aspectRatioLocked:q});if(!$)return;this.editor.updateShapes([{id:J.id,type:J.type,...$}]),this.updateCursor()}complete(){this.updateShapes(),z1(this.editor,[this.snapshot.shape.id]);let{onInteractionEnd:J}=this.info;if(J)if(typeof J==="string")this.editor.setCurrentTool(J,this.info);else J();else this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle")}cancel(){this.editor.bailToMark(this.markId);let{onInteractionEnd:J}=this.info;if(J)if(typeof J==="string")this.editor.setCurrentTool(J,this.info);else J();else this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle")}createSnapshot(){let J=this.editor.getSelectionRotation(),Q=this.editor.inputs.getOriginPagePoint(),Z=this.editor.getOnlySelectedShape(),q=this.editor.getSelectionRotatedPageBounds(),X=M.RotWith(q.getHandlePoint(this.info.handle),q.point,J),K=M.Sub(Q,X);return{shape:Z,cursorHandleOffset:K}}}class x_ extends a{static id="pointing_crop_handle";info={};onEnter(J){if(this.info=J,typeof J.onInteractionEnd==="string")this.parent.setCurrentToolIdMask(J.onInteractionEnd);let Q=this.editor.getSelectedShapes()[0];if(!Q)return;let Z=VJ[this.info.handle];this.editor.setCursor({type:Z,rotation:this.editor.getSelectionRotation()}),this.editor.setCroppingShape(Q.id)}onExit(){this.editor.setCursor({type:"default",rotation:0}),this.parent.setCurrentToolIdMask(void 0)}onPointerMove(){if(this.editor.inputs.getIsDragging())this.startCropping()}onLongPress(){this.startCropping()}startCropping(){if(this.editor.getIsReadonly())return;this.parent.transition("cropping",{...this.info,onInteractionEnd:this.info.onInteractionEnd})}onPointerUp(){let{onInteractionEnd:J}=this.info;if(J){if(typeof J==="string")this.editor.setCurrentTool(J,this.info);else J();return}this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle")}onDoubleClick(J){if(this.editor.inputs.getShiftKey()||J.phase!=="down"||J.ctrlKey||J.shiftKey)return;this.parent.transition("idle"),this.parent.getCurrent()?.handleEvent(J)}onCancel(){this.cancel()}onComplete(){this.cancel()}onInterrupt(){this.cancel()}cancel(){let{onInteractionEnd:J}=this.info;if(J){if(typeof J==="string")this.editor.setCurrentTool(J,this.info);else J();return}this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle")}}function JK(J,Q=!1){let Z=J.getZoomLevel(),q=J.inputs.getCurrentPagePoint();return J.getShapeAtPoint(q,{hitInside:!1,hitLabels:Q,hitLocked:J.options.selectLockedShapes,margin:J.options.hitTestMargin/Z,renderingOnly:!0})??J.getSelectedShapeAtPoint(q)}function nW(J){if(J.isDisposed)return!1;let Q=J.inputs.getCurrentPagePoint(),Z=J.options.hitTestMargin/J.getZoomLevel(),q=J.overlays.getOverlayAtPoint(Q,Z),X=J.overlays.getHoveredOverlayId();if(q){J.overlays.setHoveredOverlay(q.id),J.setHoveredShape(null);let Y=J.overlays.getOverlayUtil(q).getCursor(q);if(Y)J.setCursor({type:Y,rotation:J.getSelectionRotation()});return!0}if(X)J.setCursor({type:"default",rotation:0});return J.overlays.setHoveredOverlay(null),!1}function ND(J,Q,Z){if(!Q)throw Error("Needs to translate a cropped shape!");let{crop:q}=Q.props;if(!q)return;let X=J.inputs.getShiftKey()?Math.abs(Z.x)<Math.abs(Z.y)?"x":"y":null;if(X==="x")Z.x=0;else if(X==="y")Z.y=0;Z.rot(-Q.rotation);let{w:K,h:Y}=A8(Q.props,q),W=q.bottomRight.x-q.topLeft.x,z=q.bottomRight.y-q.topLeft.y,G=$1(q),$=1-W,H=1-z;return G.topLeft.x=M0(G.topLeft.x-Z.x/K,0,$),G.topLeft.y=M0(G.topLeft.y-Z.y/Y,0,H),G.bottomRight.x=G.topLeft.x+W,G.bottomRight.y=G.topLeft.y+z,{id:Q.id,type:Q.type,props:{crop:G}}}class cT extends a{static id="idle";onEnter(){this.editor.setCursor({type:"default",rotation:0});let J=this.editor.getOnlySelectedShape();if(J)this.editor.setCroppingShape(J.id);nW(this.editor)}onExit(){this.editor.setCursor({type:"default",rotation:0})}onPointerMove(){nW(this.editor)}onCancel(){this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle",{})}onPointerDown(J){if(J.accelKey){this.cancel(),this.editor.root.handleEvent(J);return}switch(J.target){case"canvas":{let Q=this.editor.inputs.getCurrentPagePoint(),Z=this.editor.overlays.getOverlayAtPoint(Q,this.editor.options.hitTestMargin/this.editor.getZoomLevel());if(Z){let X=Z.props.overlayType;if(X==="resize_handle"||X==="rotate_handle"||X==="mobile_rotate"){this.onPointerDown({...J,target:"selection",handle:Z.props.handle});return}}let q=JK(this.editor);if(q&&!this.editor.isShapeOfType(q,"group")){this.onPointerDown({...J,shape:q,target:"shape"});return}this.cancel(),this.editor.root.handleEvent(J);break}case"shape":{if(J.shape.id===this.editor.getCroppingShapeId()){this.editor.setCurrentTool("select.crop.pointing_crop",J);return}else if(this.editor.getShapeUtil(J.shape)?.canCrop(J.shape))this.editor.setCroppingShape(J.shape.id),this.editor.setSelectedShapes([J.shape.id]),this.editor.setCurrentTool("select.crop.pointing_crop",J);else this.cancel(),this.editor.root.handleEvent(J);break}case"selection":{switch(J.handle){case"mobile_rotate":case"top_left_rotate":case"top_right_rotate":case"bottom_left_rotate":case"bottom_right_rotate":{this.editor.setCurrentTool("select.pointing_rotate_handle",{...J,onInteractionEnd:"select.crop.idle"});break}case"top":case"right":case"bottom":case"left":case"top_left":case"top_right":case"bottom_left":case"bottom_right":{this.editor.setCurrentTool("select.crop.pointing_crop_handle",{...J,onInteractionEnd:"select.crop.idle"});break}default:this.cancel()}break}}}onDoubleClick(J){if(this.editor.inputs.getShiftKey()||J.phase!=="down")return;let Q=this.editor.getCroppingShapeId();if(!Q)return;let Z=this.editor.getShape(Q);if(!Z)return;let q=this.editor.getShapeUtil(Z);if(!q)return;if(J.target==="canvas"){let X=this.editor.inputs.getCurrentPagePoint(),K=this.editor.overlays.getOverlayAtPoint(X,this.editor.options.hitTestMargin/this.editor.getZoomLevel());if(K){let Y=K.props.overlayType;if(Y==="resize_handle"||Y==="rotate_handle"||Y==="mobile_rotate"){this.onDoubleClick({...J,target:"selection",handle:K.props.handle});return}}}if(J.target==="selection"){q.onDoubleClickEdge?.(Z,J);return}this.cancel(),this.editor.root.handleEvent(J)}onKeyDown(){this.nudgeCroppingImage(!1)}onKeyRepeat(){this.nudgeCroppingImage(!0)}onKeyUp(J){switch(J.key){case"Enter":{this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle",{});break}}}cancel(){this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle",{})}nudgeCroppingImage(J=!1){let{editor:{inputs:{keys:Q}}}=this,Z=Q.has("ShiftLeft"),q=new M(0,0);if(Q.has("ArrowLeft"))q.x+=1;if(Q.has("ArrowRight"))q.x-=1;if(Q.has("ArrowUp"))q.y+=1;if(Q.has("ArrowDown"))q.y-=1;if(q.equals(new M(0,0)))return;if(Z)q.mul(10);let X=this.editor.getShape(this.editor.getCroppingShapeId());if(!X)return;let K=ND(this.editor,X,q);if(K){if(!J)this.editor.markHistoryStoppingPoint("translate crop");this.editor.updateShapes([K])}}}class lT extends a{static id="pointing_crop";onCancel(){this.editor.setCurrentTool("select.crop.idle",{})}onPointerMove(J){if(this.editor.inputs.getIsDragging())this.startDragging(J)}onLongPress(J){this.startDragging(J)}onPointerUp(J){this.editor.setCurrentTool("select.crop.idle",J)}onDoubleClick(J){if(this.editor.inputs.getShiftKey()||J.phase!=="down"||J.ctrlKey||J.shiftKey)return;this.parent.transition("idle"),this.parent.getCurrent()?.handleEvent(J)}startDragging(J){this.editor.setCurrentTool("select.crop.translating_crop",J)}}class pT extends a{static id="translating_crop";info={};markId="";snapshot={};onEnter(J){this.info=J,this.snapshot=this.createSnapshot(),this.markId=this.editor.markHistoryStoppingPoint("translating_crop"),this.editor.setCursor({type:"move",rotation:0}),this.updateShapes()}onExit(){this.editor.setCursor({type:"default",rotation:0})}onPointerMove(){this.updateShapes()}onPointerUp(){this.complete()}onComplete(){this.complete()}onCancel(){this.cancel()}onKeyDown(J){switch(J.key){case"Alt":case"Shift":{this.updateShapes();return}}}onKeyUp(J){switch(J.key){case"Enter":{this.complete();return}case"Alt":case"Shift":this.updateShapes()}}complete(){this.updateShapes(),this.editor.setCurrentTool("select.crop.idle",this.info)}cancel(){this.editor.bailToMark(this.markId),this.editor.setCurrentTool("select.crop.idle",this.info)}createSnapshot(){return{shape:this.editor.getOnlySelectedShape()}}updateShapes(){let J=this.snapshot.shape;if(!J)return;let Q=this.editor.inputs.getOriginPagePoint(),q=this.editor.inputs.getCurrentPagePoint().clone().sub(Q),X=ND(this.editor,J,q);if(X)this.editor.updateShapes([X])}}class dT extends a{static id="crop";static initial="idle";static children(){return[cT,pT,lT,x_,y_]}markId="";onEnter(){this.didExit=!1,this.markId=this.editor.markHistoryStoppingPoint("crop")}didExit=!1;onExit(){if(!this.didExit){if(this.didExit=!0,this.editor.getMarkIdMatching(this.markId)===this.markId)this.editor.squashToMark(this.markId)}}onCancel(){if(!this.didExit)this.didExit=!0,this.editor.bailToMark(this.markId)}}class iT extends a{static id="dragging_handle";static trackPerformance=!0;shapeId;initialHandle;initialAdjacentHandle;initialPagePoint;markId;initialPageTransform;initialPageRotation;info;isPrecise=!1;isPreciseId=null;pointingId=null;onEnter(J){let{shape:Q,isCreating:Z,creatingMarkId:q,handle:X}=J;if(this.info=J,typeof J.onInteractionEnd==="string")this.parent.setCurrentToolIdMask(J.onInteractionEnd);if(this.shapeId=Q.id,this.markId="",Z)if(q)this.markId=q;else{let $=this.editor.getMarkIdMatching(`creating:${this.editor.getOnlySelectedShapeId()}`);if($)this.markId=$}else this.markId=this.editor.markHistoryStoppingPoint("dragging handle");this.initialHandle=$1(X),this.initialPageTransform=this.editor.getShapePageTransform(Q),this.initialPageRotation=this.initialPageTransform.rotation(),this.initialPagePoint=this.editor.inputs.getOriginPagePoint().clone(),this.editor.setCursor({type:Z?"cross":"grabbing",rotation:0});let K=this.editor.getShapeHandles(Q).sort(O4),Y=K.findIndex(($)=>$.id===J.handle.id);if(this.initialAdjacentHandle=null,J.handle.snapReferenceHandleId){let $=K.find((H)=>H.id===J.handle.snapReferenceHandleId);if($)this.initialAdjacentHandle=$}if(!this.initialAdjacentHandle){for(let $=Y+1;$<K.length;$++){let H=K[$];if(H.type==="vertex"&&H.id!=="middle"&&H.id!==J.handle.id){this.initialAdjacentHandle=H;break}}if(!this.initialAdjacentHandle)for(let $=K.length-1;$>=0;$--){let H=K[$];if(H.type==="vertex"&&H.id!=="middle"&&H.id!==J.handle.id){this.initialAdjacentHandle=H;break}}}if(this.editor.isShapeOfType(Q,"arrow")){let $=Z4(this.editor,Q)[J.handle.id];if(this.isPrecise=!1,$)if(this.isPrecise=$.props.isPrecise,this.isPrecise)this.isPreciseId=$.toId;else this.resetExactTimeout()}let W={handle:this.initialHandle,isPrecise:this.isPrecise,isCreatingShape:!!this.info.isCreating,initial:Q},G=this.editor.getShapeUtil(Q).onHandleDragStart?.(Q,W);if(G)this.editor.updateShapes([{...G,id:Q.id,type:Q.type}]);this.update(),this.editor.select(this.shapeId)}exactTimeout=-1;resetExactTimeout(){let Q=this.editor.getShapeUtil("arrow").options.pointingPreciseTimeout;if(this.exactTimeout!==-1)this.clearExactTimeout();this.exactTimeout=this.editor.timers.setTimeout(()=>{if(this.getIsActive()&&!this.isPrecise)this.isPrecise=!0,this.isPreciseId=this.pointingId,this.update();this.exactTimeout=-1},Q)}clearExactTimeout(){if(this.exactTimeout!==-1)clearTimeout(this.exactTimeout),this.exactTimeout=-1}onPointerMove(){this.update()}onKeyDown(){this.update()}onKeyUp(){this.update()}onPointerUp(){this.complete()}onComplete(){this.update(),this.complete()}onCancel(){this.cancel()}onExit(){this.parent.setCurrentToolIdMask(void 0),pX(this.editor),this.editor.snaps.clearIndicators(),this.editor.setCursor({type:"default",rotation:0})}complete(){this.editor.snaps.clearIndicators(),z1(this.editor,[this.shapeId]);let J=this.editor.getShape(this.shapeId);if(J){let Z=this.editor.getShapeUtil(J),q={handle:this.initialHandle,isPrecise:this.isPrecise,isCreatingShape:!!this.info.isCreating,initial:this.info.shape},X=Z.onHandleDragEnd?.(J,q);if(X)this.editor.updateShapes([{...X,id:J.id}])}let{onInteractionEnd:Q}=this.info;if(Q)if(typeof Q==="string"){if(this.editor.getInstanceState().isToolLocked&&Q){this.editor.setCurrentTool(Q,{shapeId:this.shapeId});return}}else{Q?.();return}this.parent.transition("idle")}cancel(){let J=this.editor.getShape(this.shapeId);if(J){let Z=this.editor.getShapeUtil(J),q={handle:this.initialHandle,isPrecise:this.isPrecise,isCreatingShape:!!this.info.isCreating,initial:this.info.shape};Z.onHandleDragCancel?.(J,q)}this.editor.bailToMark(this.markId),this.editor.snaps.clearIndicators();let{onInteractionEnd:Q}=this.info;if(Q){if(typeof Q==="string")this.editor.setCurrentTool(Q,{shapeId:this.shapeId});else Q?.();return}this.parent.transition("idle")}update(){let{editor:J,shapeId:Q,initialPagePoint:Z}=this,{initialHandle:q,initialPageRotation:X,initialAdjacentHandle:K}=this,Y=this.editor.user.getIsSnapMode(),{snaps:W}=J,z=J.inputs.getCurrentPagePoint(),G=J.inputs.getShiftKey(),$=J.inputs.getCtrlKey(),H=J.inputs.getAltKey(),_=J.inputs.getPointerVelocity(),F=this.info.shape,U=J.getShape(Q);if(!U)return;let V=J.getShapeUtil(U),B=J.isShapeOfType(U,"arrow")?Z4(J,U)[q.id]:void 0,N=z.clone().sub(Z).rot(-X).add(q);if(G&&K&&q.id!=="middle"){let k=M.Angle(K,N),P=LZ(k,24)-k;N=M.RotWith(N,K,P)}J.snaps.clearIndicators();let L={...q,x:N.x,y:N.y},D=!1;if(q.canSnap&&q.snapType)DK("canSnap is deprecated. Cannot use both canSnap and snapType together - snapping disabled. Please use only snapType.");else D=q.canSnap||q.snapType!==void 0;if(D&&(Y?!$:$)){if(!J.getShapePageTransform(U.id))throw Error("Expected a page transform");let R=W.handles.snapHandle({currentShapeId:Q,handle:L});if(R)R.nudge.rot(-J.getShapeParentTransform(U).rotation()),N.add(R.nudge),L={...q,x:N.x,y:N.y}}let O=V.onHandleDrag?.(U,{handle:L,isPrecise:this.isPrecise||H,isCreatingShape:!!this.info.isCreating,initial:F}),j={id:U.id,type:U.type,...O};if(q.type==="vertex"&&this.editor.isShapeOfType(U,"arrow")){let k=Z4(J,U)[q.id];if(k){if(B?.toId!==k.toId)this.pointingId=k.toId,this.isPrecise=_.len()<0.5||H,this.isPreciseId=this.isPrecise?k.toId:null,this.resetExactTimeout()}else if(B)this.pointingId=null,this.isPrecise=!1,this.isPreciseId=null,this.resetExactTimeout()}if(O)J.updateShapes([j])}}function BD(J){if(J.isLabel)return[J];if(J instanceof y4)return J.children.filter((Q)=>Q.isLabel);return[]}class nT extends a{static id="editing_shape";hitLabelOnShapeForPointerUp=null;info={};didPointerDownOnEditingShape=!1;isTextInputFocused(){let J=this.editor.getContainer(),Q=this.editor.getContainerDocument();return J.contains(Q.activeElement)&&vJ(!1,Q)}onEnter(J){let Q=this.editor.getEditingShape();if(!Q)throw Error("Entered editing state without an editing shape");if(this.hitLabelOnShapeForPointerUp=null,this.didPointerDownOnEditingShape=!1,this.info=J,J.isCreatingTextWhileToolLocked)this.parent.setCurrentToolIdMask("text");this.editor.setCursor({type:"default",rotation:0}),V2(this.editor),this.editor.select(Q)}onExit(){let J=!!this.editor.getEditingShapeId();if(this.editor.setEditingShape(null),wq(this.editor),this.info.isCreatingTextWhileToolLocked&&J)this.parent.setCurrentToolIdMask(void 0),this.editor.setCurrentTool("text",{})}onPointerMove(J){if(this.hitLabelOnShapeForPointerUp&&this.editor.inputs.getIsDragging()){if(this.editor.getIsReadonly())return;if(this.hitLabelOnShapeForPointerUp.isLocked)return;this.editor.select(this.hitLabelOnShapeForPointerUp),this.parent.transition("translating",J),this.hitLabelOnShapeForPointerUp=null;return}if(this.didPointerDownOnEditingShape&&this.editor.inputs.isDragging){if(this.editor.getIsReadonly())return;let Q=this.editor.getEditingShape();if(!Q||Q.isLocked)return;if(!this.isTextInputFocused()){this.editor.select(Q),this.parent.transition("translating",J),this.didPointerDownOnEditingShape=!1;return}this.didPointerDownOnEditingShape=!1}switch(J.target){case"shape":case"canvas":{V2(this.editor);return}}}onPointerDown(J){switch(this.hitLabelOnShapeForPointerUp=null,this.didPointerDownOnEditingShape=!1,J.target){case"canvas":{let Q=JK(this.editor,!0);if(Q){this.onPointerDown({...J,shape:Q,target:"shape"});return}break}case"shape":{let{shape:Q}=J,Z=this.editor.getEditingShape();if(!Z)throw Error("Expected an editing shape!");let q=this.editor.getShapeUtil(Q).getGeometry(Q),X=BD(q),K=X.length===1?X[0]:void 0,Y=this.editor.isShapeOfType(Z,"text")&&u9(this.editor,Z.props.richText).trim()==="";if(K&&!Y){let W=this.editor.getPointInShapeSpace(Q,this.editor.inputs.getCurrentPagePoint());if(K.bounds.containsPoint(W,0)&&K.hitTestPoint(W))if(Q.id===Z.id){this.didPointerDownOnEditingShape=!0;return}else{this.hitLabelOnShapeForPointerUp=Q,this.editor.markHistoryStoppingPoint("editing on pointer up"),this.editor.select(Q.id);return}}else{if(Q.id===Z.id){if(this.editor.isShapeFrameLike(Q))this.editor.setEditingShape(null),this.parent.transition("idle",J)}else{this.parent.transition("pointing_shape",J);return}return}break}}this.parent.transition("idle",J),this.editor.root.handleEvent(J)}onPointerUp(J){if(this.didPointerDownOnEditingShape){if(this.didPointerDownOnEditingShape=!1,!this.isTextInputFocused()){this.editor.getRichTextEditor()?.commands.focus("all");return}}let Q=this.hitLabelOnShapeForPointerUp;if(!Q)return;this.hitLabelOnShapeForPointerUp=null;let Z=this.editor.getShapeUtil(Q);if(Q.isLocked)return;if(this.editor.getIsReadonly()){if(!Z.canEditInReadonly(Q)){this.parent.transition("pointing_shape",J);return}}this.editor.select(Q.id);let q=this.editor.getEditingShape(),X=q&&q.id!==Q.id;this.editor.setEditingShape(Q.id);let K=S0.isIos||S0.isAndroid;if(!K||!X)this.editor.emit("place-caret",{shapeId:Q.id,point:J.point});else if(K&&X)this.editor.emit("select-all-text",{shapeId:Q.id});V2(this.editor)}onComplete(J){this.editor.getContainer().focus(),this.parent.transition("idle",J)}onCancel(J){this.editor.getContainer().focus(),this.parent.transition("idle",J)}}function QK(J,Q){let Z=J.getSelectedShapeIds(),q=J.inputs.getCurrentPagePoint(),{shiftKey:X,altKey:K,accelKey:Y}=Q,W=X||Y,z=J.options.selectLockedShapes,G=J.getShapeAtPoint(q,{hitInside:!1,margin:J.options.hitTestMargin/J.getZoomLevel(),hitLabels:!0,hitLocked:z,renderingOnly:!0,filter:($)=>z||!$.isLocked});if(G){let $=J.getOutermostSelectableShape(G);if(W&&!K)if(J.cancelDoubleClick(),Z.includes($.id))J.markHistoryStoppingPoint("deselecting shape"),J.deselect($);else J.markHistoryStoppingPoint("shift selecting shape"),J.setSelectedShapes([...Z,$.id]);else{let H=void 0;if($===G)H=G;else if($.id===J.getFocusedGroupId()||Z.includes($.id))H=G;else H=$;if(H&&!Z.includes(H.id))J.markHistoryStoppingPoint("selecting shape"),J.select(H.id)}}else if(W)return;else{if(Z.length>0)J.markHistoryStoppingPoint("selecting none"),J.selectNone();let $=J.getFocusedGroupId();if($4($)){let H=J.getShape($);if(!J.isPointInShape(H,q,{margin:0,hitInside:!0}))J.setFocusedGroup(null)}}}var gL0=["Delete","Backspace","[","]","Enter"," ","Shift","Tab"];class sT extends a{static id="idle";selectedShapesOnKeyDown=[];onEnter(){if(this.parent.setCurrentToolIdMask(void 0),this.editor.setCursor({type:"default",rotation:0}),!nW(this.editor))V2(this.editor);this.selectedShapesOnKeyDown=[]}onExit(){this.editor.updateInstanceState({isChangingStyle:!1}),wq(this.editor)}onPointerMove(){if(!nW(this.editor))V2(this.editor);if(v5(()=>this.editor.getInstanceState()).isChangingStyle)this.editor.updateInstanceState({isChangingStyle:!1})}onPointerDown(J){switch(J.target){case"canvas":{let Q=this.editor.inputs.getCurrentPagePoint(),Z=this.editor.overlays.getOverlayAtPoint(Q,this.editor.options.hitTestMargin/this.editor.getZoomLevel());if(Z){this.onPointerDown({...J,target:"overlay",overlay:Z});return}let q=JK(this.editor);if(q&&(this.editor.options.selectLockedShapes||!q.isLocked)){this.onPointerDown({...J,shape:q,target:"shape"});return}let X=this.editor.getSelectedShapeIds(),K=this.editor.getOnlySelectedShape();if(X.length>1||K&&!this.editor.getShapeUtil(K).hideSelectionBoundsBg(K)){if(I10(this.editor,Q)){this.onPointerDown({...J,target:"selection"});return}}this.parent.transition("pointing_canvas",J);break}case"overlay":{let{overlay:Q}=J,Z=this.editor.overlays.getOverlayUtil(Q);if(Z.onPointerDown){if(Z.onPointerDown(Q,J)!==!1)return}let q=Q.props.overlayType;if(Q.type==="shape_handle"){let X=this.editor.getShape(Q.props.shapeId);if(X)this.onPointerDown({...J,target:"handle",shape:X,handle:Q.props.handle})}else switch(q){case"rotate_handle":{this.onPointerDown({...J,target:"selection",handle:Q.props.handle});break}case"mobile_rotate":{this.onPointerDown({...J,target:"selection",handle:Q.props.handle});break}case"resize_handle":{this.onPointerDown({...J,target:"selection",handle:Q.props.handle});break}default:this.onPointerDown({...J,target:"selection"})}break}case"shape":{let{shape:Q}=J;if(!this.editor.options.selectLockedShapes&&this.editor.isShapeOrAncestorLocked(Q)){this.parent.transition("pointing_canvas",J);break}this.parent.transition("pointing_shape",J);break}case"handle":{if(this.editor.getIsReadonly())break;if(this.editor.inputs.getAltKey())this.parent.transition("pointing_shape",J);else this.parent.transition("pointing_handle",J);break}case"selection":{switch(J.handle){case"mobile_rotate":case"top_left_rotate":case"top_right_rotate":case"bottom_left_rotate":case"bottom_right_rotate":{if(J.accelKey){this.parent.transition("brushing",J);break}this.parent.transition("pointing_rotate_handle",J);break}case"top":case"right":case"bottom":case"left":case"top_left":case"top_right":case"bottom_left":case"bottom_right":{let Q=this.editor.getOnlySelectedShape();if(J.ctrlKey&&this.editor.canCropShape(Q))this.parent.transition("crop.pointing_crop_handle",J);else{if(J.accelKey){this.parent.transition("brushing",J);break}this.parent.transition("pointing_resize_handle",J)}break}default:{let Q=this.editor.getHoveredShape();if(Q&&!this.editor.getSelectedShapeIds().includes(Q.id)&&(this.editor.options.selectLockedShapes||!Q.isLocked)){this.onPointerDown({...J,shape:Q,target:"shape"});return}this.parent.transition("pointing_selection",J)}}break}}}onDoubleClick(J){if(this.editor.inputs.getShiftKey()||J.phase!=="down")return;if(J.ctrlKey||J.shiftKey)return;switch(J.target){case"canvas":{let Q=this.editor.inputs.getCurrentPagePoint(),Z=this.editor.overlays.getOverlayAtPoint(Q,this.editor.options.hitTestMargin/this.editor.getZoomLevel());if(Z){if(Z.type==="shape_handle"){let Y=this.editor.getShape(Z.props.shapeId);if(Y){this.onDoubleClick({...J,target:"handle",shape:Y,handle:Z.props.handle});return}}let K=Z.props.overlayType;if(K==="resize_handle"||K==="rotate_handle"||K==="mobile_rotate"){this.onDoubleClick({...J,target:"selection",handle:Z.props.handle});return}}let q=this.editor.getHoveredShape(),X=q&&!this.editor.isShapeOfType(q,"group")?q:this.editor.getSelectedShapeAtPoint(Q)??this.editor.getShapeAtPoint(Q,{margin:this.editor.options.hitTestMargin/this.editor.getZoomLevel(),hitInside:!1});if(X){if(this.editor.isShapeOfType(X,"group")){QK(this.editor,J);return}else{let K=this.editor.getShape(X.parentId);if(K&&this.editor.isShapeOfType(K,"group")){let Y=this.editor.getFocusedGroupId();if(Y&&K.id===Y);else{QK(this.editor,J);return}}}this.onDoubleClick({...J,shape:X,target:"shape"});return}if(!this.editor.inputs.getShiftKey())this.handleDoubleClickOnCanvas(J);break}case"selection":{let Q=this.editor.getOnlySelectedShape();if(Q){let Z=this.editor.getShapeUtil(Q),q=J.handle==="right"||J.handle==="left"||J.handle==="top"||J.handle==="bottom",X=J.handle==="top_left"||J.handle==="top_right"||J.handle==="bottom_right"||J.handle==="bottom_left";if(this.editor.getIsReadonly()){if(this.editor.canEditShape(Q,{type:X?"double-click-corner":q?"double-click-edge":"double-click"}))this.startEditingShape(Q,J,!0);break}if(q){let K=Z.onDoubleClickEdge?.(Q,J);if(K){this.editor.markHistoryStoppingPoint("double click edge"),this.editor.updateShapes([K]),z1(this.editor,[Q.id]);return}}if(X){let K=Z.onDoubleClickCorner?.(Q,J);if(K){this.editor.markHistoryStoppingPoint("double click corner"),this.editor.updateShapes([K]),z1(this.editor,[Q.id]);return}}if(this.editor.canCropShape(Q)){this.parent.transition("crop",J);return}if(this.editor.canEditShape(Q))this.startEditingShape(Q,J,!0)}break}case"shape":{let{shape:Q}=J,Z=this.editor.getShapeUtil(Q);if(Q.type!=="video"&&Q.type!=="embed"&&this.editor.getIsReadonly())break;if(Z.onDoubleClick){let q=Z.onDoubleClick?.(Q);if(q){this.editor.updateShapes([q]);return}}if(Z.canCrop(Q)&&!this.editor.isShapeOrAncestorLocked(Q)){this.editor.markHistoryStoppingPoint("select and crop"),this.editor.select(J.shape?.id),this.parent.transition("crop",J);return}if(this.editor.canEditShape(Q))this.startEditingShape(Q,J,!0);else this.handleDoubleClickOnCanvas(J);break}case"handle":{if(this.editor.getIsReadonly())break;let{shape:Q,handle:Z}=J,X=this.editor.getShapeUtil(Q).onDoubleClickHandle?.(Q,Z);if(X)this.editor.updateShapes([X]);else if(this.editor.canEditShape(Q))this.startEditingShape(Q,J,!0)}}}onRightClick(J){switch(J.target){case"canvas":{let Q=this.editor.getSelectedShapeIds(),Z=this.editor.getOnlySelectedShape(),q=this.editor.inputs.getCurrentPagePoint();if(Q.length>1||Z&&!this.editor.getShapeUtil(Z).hideSelectionBoundsBg(Z)){if(I10(this.editor,q)){this.onRightClick({...J,target:"selection"});return}}let X=this.editor.getHoveredShape(),K=X&&!this.editor.isShapeOfType(X,"group")?X:this.editor.getShapeAtPoint(q,{margin:this.editor.options.hitTestMargin/this.editor.getZoomLevel(),hitInside:!1,hitLabels:!0,hitLocked:!0,hitFrameInside:!0,renderingOnly:!0});if(K){this.onRightClick({...J,shape:K,target:"shape"});return}this.editor.selectNone();break}case"shape":{let{selectedShapeIds:Q}=this.editor.getCurrentPageState(),{shape:Z}=J,q=this.editor.getOutermostSelectableShape(Z,(X)=>!Q.includes(X.id));if(!Q.includes(q.id)&&!this.editor.findShapeAncestor(q,(X)=>Q.includes(X.id)))this.editor.markHistoryStoppingPoint("selecting shape"),this.editor.setSelectedShapes([q.id]);break}}}onCancel(){if(this.editor.getFocusedGroupId()!==this.editor.getCurrentPageId()&&this.editor.getSelectedShapeIds().length>0)this.editor.popFocusedGroupId();else this.editor.markHistoryStoppingPoint("clearing selection"),this.editor.selectNone()}onKeyDown(J){switch(this.selectedShapesOnKeyDown=this.editor.getSelectedShapes(),J.code){case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":{if(J.accelKey){if(J.shiftKey){if(J.code==="ArrowDown")this.editor.selectFirstChildShape();else if(J.code==="ArrowUp")this.editor.selectParentShape()}else this.editor.selectAdjacentShape(J.code.replace("Arrow","").toLowerCase());return}this.nudgeSelectedShapes(!1);return}}if(V1.editOnType.get()){if(!gL0.includes(J.key)&&!J.altKey&&!J.ctrlKey){let Q=this.editor.getOnlySelectedShape();if(Q&&this.editor.isShapeOfType(Q,"note")&&this.editor.canEditShape(Q)){this.startEditingShape(Q,{...J,target:"shape",shape:Q},!0);return}}}}onKeyRepeat(J){switch(J.code){case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":{if(J.accelKey){this.editor.selectAdjacentShape(J.code.replace("Arrow","").toLowerCase());return}this.nudgeSelectedShapes(!0);break}case"Tab":{if(this.editor.getSelectedShapes().length&&!J.altKey)this.editor.selectAdjacentShape(J.shiftKey?"prev":"next");break}}}onKeyUp(J){switch(J.key){case"Enter":{if(!this.selectedShapesOnKeyDown.length)return;let Q=this.editor.getSelectedShapes();if(Q.every((q)=>this.editor.isShapeOfType(q,"group"))){this.editor.setSelectedShapes(Q.flatMap((q)=>this.editor.getSortedChildIdsForParent(q.id)));return}let Z=this.editor.getOnlySelectedShape();if(Z&&this.editor.canEditShape(Z,{type:"press_enter"})){this.startEditingShape(Z,{...J,target:"shape",shape:Z},!0);return}if(this.editor.canCropShape(Z))this.parent.transition("crop",J);break}case"Tab":{if(this.editor.getSelectedShapes().length&&!J.altKey)this.editor.selectAdjacentShape(J.shiftKey?"prev":"next");break}}}startEditingShape(J,Q,Z){let{editor:q}=this;if(this.editor.markHistoryStoppingPoint("editing shape"),kE(J))S4(q,J,{selectAll:Z});else q.setEditingShape(J);this.parent.transition("editing_shape",Q)}isOverArrowLabelTest(J){if(!J)return!1;return mO(this.editor,J)}handleDoubleClickOnCanvas(J){if(this.editor.getIsReadonly())return;if(!this.editor.options.createTextOnCanvasDoubleClick)return;this.editor.markHistoryStoppingPoint("creating text shape");let Q=l0(),{x:Z,y:q}=this.editor.inputs.getCurrentPagePoint();this.editor.createShapes([{id:Q,type:"text",x:Z,y:q,props:{richText:x1(""),autoSize:!0}}]);let X=this.editor.getShape(Q);if(!X)return;if(!this.editor.canEditShape(X))return;S4(this.editor,Q,{info:J})}nudgeSelectedShapes(J=!1){let{editor:{inputs:{keys:Q}}}=this,Z=Q.has("ShiftLeft"),q=new M(0,0);if(Q.has("ArrowLeft"))q.x-=1;if(Q.has("ArrowRight"))q.x+=1;if(Q.has("ArrowUp"))q.y-=1;if(Q.has("ArrowDown"))q.y+=1;if(q.equals(new M(0,0)))return;if(!J)this.editor.markHistoryStoppingPoint("nudge shapes");this.editor.updateInstanceState({isChangingStyle:!0});let{gridSize:X}=this.editor.getDocumentSettings(),K=this.editor.getInstanceState().isGridMode?Z?X*mL0:X:Z?hL0:uL0,Y=this.editor.getSelectedShapeIds();this.editor.nudgeShapes(Y,q.mul(K)),z1(this.editor,Y)}}var hL0=10,uL0=1,mL0=5;function I10(J,Q){let Z=J.getSelectionRotatedPageBounds();if(!Z)return!1;let q=J.getSelectionRotation();if(!q)return Z.containsPoint(Q);return n1(Q,Z.corners.map((X)=>M.RotWith(X,Z.point,q)))}class rT extends a{static id="pointing_arrow_label";shapeId="";markId="";wasAlreadySelected=!1;didDrag=!1;didCtrlOnEnter=!1;info={};updateCursor(){this.editor.setCursor({type:"grabbing",rotation:0})}onEnter(J){let{shape:Q}=J;if(typeof J.onInteractionEnd==="string")this.parent.setCurrentToolIdMask(J.onInteractionEnd);this.info=J,this.shapeId=Q.id,this.didDrag=!1,this.didCtrlOnEnter=J.accelKey,this.wasAlreadySelected=this.editor.getOnlySelectedShapeId()===Q.id,this.updateCursor();let q=this.editor.getShapeGeometry(Q).children[1];if(!q)throw Error(`Expected to find an arrow label geometry for shape: ${Q.id}`);let X=this.editor.inputs.getCurrentPagePoint(),K=this.editor.getPointInShapeSpace(Q,X);if(this._labelDragOffset=M.Sub(q.center,K),this.markId=this.editor.markHistoryStoppingPoint("label-drag start"),J.shiftKey||J.accelKey){let W=this.editor.getSelectedShapeIds();this.editor.setSelectedShapes([...W,this.shapeId]);return}this.editor.setSelectedShapes([this.shapeId])}onExit(){this.parent.setCurrentToolIdMask(void 0),this.editor.setCursor({type:"default",rotation:0})}_labelDragOffset=new M(0,0);onPointerMove(){if(!this.editor.inputs.getIsDragging())return;if(this.didCtrlOnEnter){this.parent.transition("brushing",this.info);return}let Q=this.editor.getShape(this.shapeId);if(!Q)return;let Z=this.editor.getShapeUtil("arrow").options,q=aX(this.editor,Q),X=this.editor.getShapePageTransform(Q.id),K=this.editor.getPointInShapeSpace(Q,this.editor.inputs.getCurrentPagePoint()).add(this._labelDragOffset),Y=uO(this.editor,Q),W=q.uninterpolateAlongEdge(K);if(isNaN(W))W=Y;let z=X.applyToPoint(q.interpolateAlongEdge(W)),G=X.applyToPoint(q.interpolateAlongEdge(Y));if(M.DistMin(z,G,Z.labelCenterSnapDistance/this.editor.getZoomLevel()))W=Y;this.didDrag=!0,this.editor.updateShape({id:Q.id,type:Q.type,props:{labelPosition:W}})}onPointerUp(){let J=this.editor.getShape(this.shapeId);if(!J)return;if(this.didDrag||!this.wasAlreadySelected)this.complete();else if(this.editor.canEditShape(J))S4(this.editor,J.id)}onCancel(){this.cancel()}onComplete(){this.cancel()}onInterrupt(){this.cancel()}complete(){let{onInteractionEnd:J}=this.info;if(J){if(typeof J==="string")this.editor.setCurrentTool(J,{});else J();return}this.parent.transition("idle")}cancel(){this.editor.bailToMark(this.markId);let{onInteractionEnd:J}=this.info;if(J){if(typeof J==="string")this.editor.setCurrentTool(J,{});else J();return}this.parent.transition("idle")}}class aT extends a{static id="pointing_canvas";onEnter(J){if(!(J.shiftKey||J.accelKey)){if(this.editor.getSelectedShapeIds().length>0)this.editor.markHistoryStoppingPoint("selecting none"),this.editor.selectNone()}}onPointerMove(J){if(this.editor.inputs.getIsDragging())this.parent.transition("brushing",J)}onPointerUp(J){QK(this.editor,J),this.complete()}onDoubleClick(J){if(this.editor.inputs.getShiftKey()||J.phase!=="down"||J.ctrlKey||J.shiftKey)return;this.parent.transition("idle"),this.parent.getCurrent()?.handleEvent(J)}onComplete(){this.complete()}onInterrupt(){this.parent.transition("idle")}complete(){this.parent.transition("idle")}}class oT extends a{static id="pointing_handle";didCtrlOnEnter=!1;info={};isDoubleClick=!1;onEnter(J){this.info=J,this.isDoubleClick=!1,this.didCtrlOnEnter=J.accelKey;let{shape:Q}=J;if(this.editor.isShapeOfType(Q,"arrow")){let Z=Z4(this.editor,Q),q=Z[J.handle.id],X=Z[J.handle.id==="start"?"end":"start"],K=this.editor.getShapePageTransform(Q.id);if(q)TQ({editor:this.editor,pointInPageSpace:K.applyToPoint(J.handle),arrow:Q,isPrecise:q.props.isPrecise,currentBinding:q,oppositeBinding:X})}this.editor.setCursor({type:"grabbing",rotation:0})}onExit(){this.editor.setHintingShapes([]),this.editor.setCursor({type:"default",rotation:0})}onPointerUp(){let{shape:J,handle:Q}=this.info;if(this.isDoubleClick){this.parent.transition("idle"),this.parent.getCurrent()?.handleEvent({...this.info,type:"click",name:"double_click",phase:"down"});return}if(this.editor.isShapeOfType(J,"note")){let{editor:Z}=this,q=w10(Z,J,Q,!1);if(q){S4(Z,q,{selectAll:!0});return}}this.parent.transition("idle",this.info)}onDoubleClick(J){if(this.editor.inputs.getShiftKey()||J.phase!=="down"||J.ctrlKey||J.shiftKey)return;this.isDoubleClick=!0}onPointerMove(J){let{editor:Q}=this;if(Q.inputs.getIsDragging())if(this.didCtrlOnEnter)this.parent.transition("brushing",J);else this.startDraggingHandle()}onLongPress(){this.startDraggingHandle()}startDraggingHandle(){let{editor:J}=this;if(J.getIsReadonly())return;let{shape:Q,handle:Z}=this.info;if(J.isShapeOfType(Q,"note")){let q=J.getShapeUtil(Q),X=k0(q,Q),K=w10(J,Q,Z,!0);if(K){let Y=J.getPointInParentSpace(K,J.inputs.getOriginPagePoint()).sub(M.Rot(new M(X.noteWidth/2,X.noteHeight/2).mul(Q.props.scale),K.rotation));J.updateShape({...K,x:Y.x,y:Y.y}),J.setHoveredShape(K.id).select(K.id).setCurrentTool("select.translating",{...this.info,target:"shape",shape:J.getShape(K),onInteractionEnd:"note",isCreating:!0,onCreate:()=>{S4(J,K,{selectAll:!0})}});return}}this.parent.transition("dragging_handle",this.info)}onCancel(){this.cancel()}onComplete(){this.cancel()}onInterrupt(){this.cancel()}cancel(){this.parent.transition("idle")}}function w10(J,Q,Z,q){let X=J.getShapeUtil(Q),K=k0(X,Q),Y=J.getShapePageTransform(Q.id),W=Y.point(),z=Y.rotation(),$=rb(J,{pagePoint:W,pageRotation:z,growY:Q.props.growY*Q.props.scale,extraHeight:0,scale:Q.props.scale,noteWidth:K.noteWidth,noteHeight:K.noteHeight})[Z.index];if($)return vO(J,{shape:Q,center:$,pageRotation:z,noteWidth:K.noteWidth,noteHeight:K.noteHeight,forceNew:q});return}class tT extends a{static id="pointing_rotate_handle";info={};updateCursor(){this.editor.setCursor({type:VJ[this.info.handle],rotation:this.editor.getSelectionRotation()})}onEnter(J){if(this.info=J,typeof J.onInteractionEnd==="string")this.parent.setCurrentToolIdMask(J.onInteractionEnd);this.updateCursor()}onExit(){this.parent.setCurrentToolIdMask(void 0),this.editor.setCursor({type:"default",rotation:0})}onPointerMove(){if(this.editor.inputs.getIsDragging())this.startRotating()}onLongPress(){this.startRotating()}startRotating(){if(this.editor.getIsReadonly())return;this.parent.transition("rotating",this.info)}onPointerUp(){this.complete()}onDoubleClick(J){if(this.editor.inputs.getShiftKey()||J.phase!=="down"||J.ctrlKey||J.shiftKey)return;this.parent.transition("idle"),this.parent.getCurrent()?.handleEvent(J)}onCancel(){this.cancel()}onComplete(){this.cancel()}onInterrupt(){this.cancel()}complete(){let{onInteractionEnd:J}=this.info;if(J){if(typeof J==="string")this.editor.setCurrentTool(J,{});else J?.();return}this.parent.transition("idle")}cancel(){let{onInteractionEnd:J}=this.info;if(J){if(typeof J==="string")this.editor.setCurrentTool(J,{});else J();return}this.parent.transition("idle")}}class eT extends a{static id="pointing_selection";info={};onEnter(J){this.info=J}onPointerUp(J){QK(this.editor,J),this.parent.transition("idle",J)}onPointerMove(J){if(this.editor.inputs.getIsDragging())this.startTranslating(J)}onLongPress(J){this.startTranslating(J)}startTranslating(J){if(this.editor.getIsReadonly())return;this.parent.transition("translating",J)}onDoubleClick(J){if(this.editor.inputs.getShiftKey()||J.phase!=="down"||J.ctrlKey||J.shiftKey)return;let Q=this.editor.getHoveredShape(),Z=Q&&!this.editor.isShapeOfType(Q,"group")?Q:this.editor.getShapeAtPoint(this.editor.inputs.getCurrentPagePoint(),{hitInside:!0,margin:0,renderingOnly:!0});if(Z){this.parent.transition("idle"),this.parent.getCurrent()?.handleEvent({...J,target:"shape",shape:this.editor.getShape(Z)});return}}onCancel(){this.cancel()}onComplete(){this.cancel()}onInterrupt(){this.cancel()}cancel(){this.parent.transition("idle")}}class Jy extends a{static id="pointing_shape";hitShape={};hitShapeForPointerUp={};isDoubleClick=!1;didCtrlOnEnter=!1;didSelectOnEnter=!1;onEnter(J){let Q=this.editor.getSelectedShapeIds(),Z=this.editor.getSelectionRotatedPageBounds(),q=this.editor.getFocusedGroupId(),X=this.editor.inputs.getCurrentPagePoint(),{shiftKey:K,altKey:Y,accelKey:W}=J;this.hitShape=J.shape,this.isDoubleClick=!1,this.didCtrlOnEnter=W;let z=this.editor.getOutermostSelectableShape(J.shape),G=this.editor.findShapeAncestor(z,($)=>Q.includes($.id));if(this.didCtrlOnEnter||this.editor.getShapeUtil(J.shape).onClick||z.id===q||Q.includes(z.id)||G||Q.length>1&&Z?.containsPoint(X)){this.didSelectOnEnter=!1,this.hitShapeForPointerUp=z;return}if(this.didSelectOnEnter=!0,K&&!Y){if(this.editor.cancelDoubleClick(),!Q.includes(z.id))this.editor.markHistoryStoppingPoint("shift selecting shape"),this.editor.setSelectedShapes([...Q,z.id])}else this.editor.markHistoryStoppingPoint("selecting shape"),this.editor.setSelectedShapes([z.id])}onPointerUp(J){let Q=this.editor.getSelectedShapeIds(),Z=this.editor.getFocusedGroupId(),q=this.editor.getZoomLevel(),X=this.editor.inputs.getCurrentPagePoint(),K=J.shiftKey||J.accelKey,Y=this.editor.getShapeAtPoint(X,{margin:this.editor.options.hitTestMargin/q,hitInside:!0,renderingOnly:!0})??this.hitShape;if(!this.editor.getShape(Y.id)){this.parent.transition("idle",J);return}let W=Y?this.editor.getOutermostSelectableShape(Y):this.hitShapeForPointerUp;if(W){let z=this.editor.getShapeUtil(W);if(z.onClick){let G=z.onClick?.(W);if(G){this.editor.markHistoryStoppingPoint("shape on click"),this.editor.updateShapes([G]),this.parent.transition("idle",J);return}}if(W.id===Z){if(Q.length>0)this.editor.markHistoryStoppingPoint("clearing shape ids"),this.editor.setSelectedShapes([]);else this.editor.popFocusedGroupId();this.parent.transition("idle",J);return}}if(!this.didSelectOnEnter){let z=this.editor.getOutermostSelectableShape(Y,(G)=>!Q.includes(G.id));if(Q.includes(z.id))if(K)this.editor.markHistoryStoppingPoint("deselecting on pointer up"),this.editor.deselect(W);else if(Q.includes(W.id)){if(Q.length===1){let G=this.editor.getShapeUtil(W).getGeometry(W),$=BD(G),H=$.length===1?$[0]:void 0;if(H){let _=this.editor.getPointInShapeSpace(W,X);if(H.bounds.containsPoint(_,0)&&H.hitTestPoint(_)){this.editor.run(()=>{if(this.editor.markHistoryStoppingPoint("editing on pointer up"),this.editor.select(W.id),!this.editor.canEditShape(W))return;if(this.editor.setEditingShape(W.id),this.editor.setCurrentTool("select.editing_shape"),this.isDoubleClick)this.editor.emit("select-all-text",{shapeId:W.id});else this.editor.emit("place-caret",{shapeId:W.id,point:J.point})});return}}}this.editor.markHistoryStoppingPoint("selecting on pointer up"),this.editor.select(W.id)}else this.editor.markHistoryStoppingPoint("selecting on pointer up"),this.editor.select(W);else if(K){let G=this.editor.getShapeAncestors(z);this.editor.markHistoryStoppingPoint("shift deselecting on pointer up"),this.editor.setSelectedShapes([...this.editor.getSelectedShapeIds().filter(($)=>!G.find((H)=>H.id===$)),z.id])}else this.editor.markHistoryStoppingPoint("selecting on pointer up"),this.editor.setSelectedShapes([z.id])}this.parent.transition("idle",J)}onDoubleClick(J){if(this.isDoubleClick=!0,this.editor.inputs.getShiftKey()||J.phase!=="down"||J.ctrlKey||J.shiftKey)return;let{shape:Q,...Z}=J;this.parent.transition("idle"),this.parent.getCurrent()?.handleEvent({...Z,target:"canvas"})}onPointerMove(J){if(this.editor.inputs.getIsDragging()){if(mO(this.editor,this.hitShape)){this.parent.transition("pointing_arrow_label",{...J,shape:this.hitShape});return}if(this.didCtrlOnEnter)this.parent.transition("brushing",J);else this.startTranslating(J)}}onLongPress(J){this.startTranslating(J)}startTranslating(J){if(this.editor.getIsReadonly())return;if(!this.didSelectOnEnter&&!this.editor.getSelectedShapeIds().length)this.editor.markHistoryStoppingPoint("selecting shape"),this.editor.setSelectedShapes([this.hitShapeForPointerUp.id]);this.editor.focus(),this.parent.transition("translating",J)}onCancel(){this.cancel()}onComplete(){this.cancel()}onInterrupt(){this.cancel()}cancel(){this.parent.transition("idle")}}class Zy extends a{static id="resizing";static trackPerformance=!0;info={};markId="";didHoldCommand=!1;creationCursorOffset={x:0,y:0};snapshot={};onEnter(J){let{isCreating:Q=!1,creatingMarkId:Z,creationCursorOffset:q={x:0,y:0}}=J;if(this.info=J,this.didHoldCommand=!1,typeof J.onInteractionEnd==="string")this.parent.setCurrentToolIdMask(J.onInteractionEnd);this.creationCursorOffset=q;try{this.snapshot=this._createSnapshot()}catch(X){console.error(X),this.cancel();return}if(this.markId="",Q)if(Z)this.markId=Z;else{let X=this.editor.getMarkIdMatching(`creating:${this.editor.getOnlySelectedShapeId()}`);if(X)this.markId=X}else this.markId=this.editor.markHistoryStoppingPoint("starting resizing");if(Q)this.editor.setCursor({type:"cross",rotation:0});this.handleResizeStart(),this.updateShapes()}onTick({elapsed:J}){let{editor:Q}=this;if(!Q.inputs.getIsDragging()||Q.inputs.getIsPanning())return;Q.edgeScrollManager.updateEdgeScrolling(J)}onPointerMove(){this.updateShapes()}onKeyDown(){this.updateShapes()}onKeyUp(){this.updateShapes()}onPointerUp(){this.complete()}onComplete(){this.complete()}onCancel(){this.cancel()}cancel(){let{shapeSnapshots:J}=this.snapshot;J.forEach(({shape:Z})=>{let q=this.editor.getShape(Z.id);if(q)this.editor.getShapeUtil(Z).onResizeCancel?.(Z,q)}),this.editor.bailToMark(this.markId);let{onInteractionEnd:Q}=this.info;if(Q){if(typeof Q==="string")this.editor.setCurrentTool(Q,{});else Q();return}this.parent.transition("idle")}complete(){if(z1(this.editor,this.snapshot.selectedShapeIds),this.handleResizeEnd(),this.info.isCreating&&this.info.onCreate){this.info.onCreate?.(this.editor.getOnlySelectedShape());return}let{onInteractionEnd:J}=this.info;if(J)if(typeof J==="string"){if(this.editor.getInstanceState().isToolLocked){this.editor.setCurrentTool(J,{});return}}else{J();return}this.parent.transition("idle")}handleResizeStart(){let{shapeSnapshots:J}=this.snapshot,Q=[];if(J.forEach(({shape:Z})=>{let X=this.editor.getShapeUtil(Z).onResizeStart?.(Z);if(X)Q.push(X)}),Q.length>0)this.editor.updateShapes(Q)}handleResizeEnd(){let{shapeSnapshots:J}=this.snapshot,Q=[];if(J.forEach(({shape:Z})=>{let q=this.editor.getShape(Z.id),K=this.editor.getShapeUtil(Z).onResizeEnd?.(Z,q);if(K)Q.push(K)}),Q.length>0)this.editor.updateShapes(Q)}updateShapes(){let{editor:J,info:Q,snapshot:{frames:Z,shapeSnapshots:q,selectionBounds:X,cursorHandleOffset:K,selectedShapeIds:Y,selectionRotation:W,canShapesDeform:z,initialSelectionPageBounds:G,resizeLevels:$}}=this,H=J.inputs.getAltKey(),F=J.inputs.getShiftKey()||!z;if(q.size===1){let I=[...q.values()][0];if(J.isShapeOfType(I.shape,"text"))F=!(Q.handle==="left"||Q.handle==="right")}let U=J6(J.inputs),V=J.inputs.getCurrentPagePoint().clone().sub(K).sub(this.creationCursorOffset),B=J.inputs.getOriginPagePoint().clone().sub(K);if(J.getInstanceState().isGridMode&&!U){let{gridSize:I}=J.getDocumentSettings();V.snapToGrid(I)}let N=Q.handle,L=b10(N,Math.PI);if(J.snaps.clearIndicators(),(J.user.getIsSnapMode()?!U:U)&&W%F4===0){let{nudge:I}=J.snaps.shapeBounds.snapResizeShapes({dragDelta:M.Sub(V,B),initialSelectionPageBounds:G,handle:b10(N,W),isAspectRatioLocked:F,isResizingFromCenter:H});V.add(I)}let O=M.RotWith(H?X.center:X.getHandlePoint(L),X.point,W),j=M.Sub(V,O).rot(-W),k=M.Sub(B,O).rot(-W),R=M.DivV(j,k);if(!Number.isFinite(R.x))R.x=1;if(!Number.isFinite(R.y))R.y=1;let P=N==="top"||N==="bottom",A=N==="left"||N==="right";if(F)if(A)R.y=Math.abs(R.x);else if(P)R.x=Math.abs(R.y);else if(Math.abs(R.x)>Math.abs(R.y))R.y=Math.abs(R.x)*(R.y<0?-1:1);else R.x=Math.abs(R.y)*(R.x<0?-1:1);else{if(P)R.x=1;if(A)R.y=1}if(!this.info.isCreating)this.updateCursor({dragHandle:N,isFlippedX:R.x<0,isFlippedY:R.y<0,rotation:W});if(q.size>1)B10(this.editor,q,R,W,F);for(let I of $){let C=[];for(let y of I){let S=q.get(y),T=J.getResizeShapePartial(y,R,{initialShape:S.shape,initialBounds:S.bounds,initialPageTransform:S.pageTransform,dragHandle:N,mode:Y.length===1&&y===Y[0]?"resize_bounds":"scale_shape",scaleOrigin:O,isAspectRatioLocked:F,scaleAxisRotation:W,skipStartAndEndCallbacks:!0});if(T)C.push(T)}if(C.length>0)J.updateShapes(C)}if(U){this.didHoldCommand=!0;let I=[];for(let{id:C,children:y}of Z){if(!y.length)continue;let S=q.get(C).shape,T=this.editor.getShape(C);if(!(S&&T))continue;let h=T.x-S.x,b=T.y-S.y,x=new M(h,b).rot(-S.rotation);if(x.x!==0||x.y!==0)for(let f of y)I.push({id:f.id,type:f.type,x:f.x-x.x,y:f.y-x.y})}if(I.length>0)this.editor.updateShapes(I)}else if(this.didHoldCommand){this.didHoldCommand=!1;let I=[];for(let{children:C}of Z)for(let y of C)I.push({id:y.id,type:y.type,x:y.x,y:y.y});if(I.length>0)this.editor.updateShapes(I)}this.updateEnclosureHints()}updateEnclosureHints(){if(!this.info.isCreating)return;let J=this.editor.getOnlySelectedShape();if(!J||!this.editor.isShapeOfType(J,"frame"))return;let Q=lb(this.editor,J),Z=this.editor.getHintingShapeIds();if(Q.length===Z.length&&Q.every((q,X)=>q===Z[X]))return;this.editor.setHintingShapes(Q)}updateCursor({dragHandle:J,isFlippedX:Q,isFlippedY:Z,rotation:q}){let X=this.editor.getInstanceState().cursor,K=X.type;switch(J){case"top_left":case"bottom_right":{if(K="nwse-resize",Q!==Z)K="nesw-resize";break}case"top_right":case"bottom_left":{if(K="nesw-resize",Q!==Z)K="nwse-resize";break}}if(K===X.type&&q===X.rotation)return;this.editor.setCursor({type:K,rotation:q})}onExit(){if(this.parent.setCurrentToolIdMask(void 0),this.editor.setCursor({type:"default",rotation:0}),this.editor.snaps.clearIndicators(),MT(this.editor,null),this.info.isCreating&&this.editor.getHintingShapeIds().length>0)this.editor.setHintingShapes([])}_createSnapshot(){let{editor:J}=this,Q=J.getSelectedShapeIds(),Z=J.getSelectionRotation(),q=J.inputs.getOriginPagePoint(),X=J.getSelectionRotatedPageBounds();if(!X)throw Error("Resizing but nothing is selected");let K=M.RotWith(X.getHandlePoint(this.info.handle),X.point,Z),Y=M.Sub(q,K),W=new Map,z=[],G=(U)=>{let V=J.getShape(U);if(!V)return!1;let B=J.getShapeUtil(V);if(B.canResize(V)){let N=J.getShapePageTransform(V);W.set(V.id,{shape:V,bounds:J.getShapeGeometry(V).bounds,pageTransform:N,pageRotation:i.Decompose(N).rotation,isAspectRatioLocked:B.isAspectRatioLocked(V)})}if(J.isShapeFrameLike(V))z.push({id:V.id,children:D0(J.getSortedChildIdsForParent(V).map((N)=>J.getShape(N)))});if(!B.canResizeChildren(V))return!1;return};Q.forEach((U)=>{if(G(U)===!1)return;J.visitDescendants(U,G)});let $=![...W.values()].some((U)=>!U3(U.pageRotation,Z)||U.isAspectRatioLocked),H=[],_=new Map,F=(U)=>{let V=_.get(U);if(V!==void 0)return V;let B=0,N=J.getShape(U)?.parentId;while(N&&$4(N)){if(W.has(N)){B=F(N)+1;break}N=J.getShape(N)?.parentId}return _.set(U,B),B};for(let U of W.keys()){let V=F(U);while(H.length<=V)H.push([]);H[V].push(U)}return{shapeSnapshots:W,selectionBounds:X,cursorHandleOffset:Y,selectionRotation:Z,selectedShapeIds:Q,canShapesDeform:$,initialSelectionPageBounds:this.editor.getSelectionPageBounds(),frames:z,resizeLevels:H}}}var Qy=["top","top_right","right","bottom_right","bottom","bottom_left","left","top_left"];function b10(J,Q){Q=Q%N1;let Z=Math.round(Q/(B1/4)),q=Qy.indexOf(J);return Qy[(q+Z)%Qy.length]}var T10=Math.PI/180;class qy extends a{static id="rotating";static trackPerformance=!0;snapshot={};info={};markId="";onEnter(J){if(this.info=J,typeof J.onInteractionEnd==="string")this.parent.setCurrentToolIdMask(J.onInteractionEnd);this.markId=this.editor.markHistoryStoppingPoint("rotate start");let Q=iG({editor:this.editor,ids:this.editor.getSelectedShapeIds()});if(!Q){this.parent.transition("idle",this.info);return}this.snapshot=Q;let Z=this._getRotationFromPointerPosition({snapToNearestDegree:!1});A3({editor:this.editor,delta:this._getRotationFromPointerPosition({snapToNearestDegree:!1}),snapshot:this.snapshot,stage:"start"}),this.editor.setCursor({type:VJ[this.info.handle],rotation:Z+this.snapshot.initialShapesRotation})}onExit(){this.editor.setCursor({type:"default",rotation:0}),this.parent.setCurrentToolIdMask(void 0),this.snapshot={}}onPointerMove(){this.update()}onKeyDown(){this.update()}onKeyUp(){this.update()}onPointerUp(){this.complete()}onComplete(){this.complete()}onCancel(){this.cancel()}update(){let J=this._getRotationFromPointerPosition({snapToNearestDegree:!1});A3({editor:this.editor,delta:J,snapshot:this.snapshot,stage:"update"}),this.editor.setCursor({type:VJ[this.info.handle],rotation:J+this.snapshot.initialShapesRotation})}cancel(){let{shapeSnapshots:J}=this.snapshot;J.forEach(({shape:Z})=>{let q=this.editor.getShape(Z.id);if(q)this.editor.getShapeUtil(Z).onRotateCancel?.(Z,q)}),this.editor.bailToMark(this.markId);let{onInteractionEnd:Q}=this.info;if(Q){if(typeof Q==="string")this.editor.setCurrentTool(Q,this.info);else Q();return}this.parent.transition("idle",this.info)}complete(){A3({editor:this.editor,delta:this._getRotationFromPointerPosition({snapToNearestDegree:!0}),snapshot:this.snapshot,stage:"end"}),z1(this.editor,this.snapshot.shapeSnapshots.map((Q)=>Q.shape.id));let{onInteractionEnd:J}=this.info;if(J){if(typeof J==="string")this.editor.setCurrentTool(J,this.info);else J();return}this.parent.transition("idle",this.info)}_getRotationFromPointerPosition({snapToNearestDegree:J}){let Q=this.editor.inputs.getShiftKey(),Z=this.editor.inputs.getCurrentPagePoint(),{initialCursorAngle:q,initialShapesRotation:X,initialPageCenter:K}=this.snapshot,Y=K.angle(Z)-q,W=X+Y;if(Q)W=LZ(W,24);else if(J){if(W=Math.round(W/T10)*T10,this.editor.getInstanceState().isCoarsePointer){let z=LZ(W,4),G=iK(W,z);if(Math.abs(G)<Lj(5))W=z}}return W-X}}class Xy extends a{static id="scribble_brushing";static trackPerformance=!0;hits=new Set;size=0;scribbleId="id";initialSelectedShapeIds=new Set;newlySelectedShapeIds=new Set;onEnter(){this.initialSelectedShapeIds=new Set(this.editor.inputs.getShiftKey()?this.editor.getSelectedShapeIds():[]),this.newlySelectedShapeIds=new Set,this.size=0,this.hits.clear();let J=this.editor.scribbles.addScribble({color:"selection-stroke",opacity:0.32,size:12});this.scribbleId=J.id,this.updateScribbleSelection(!0),this.editor.updateInstanceState({brush:null})}onExit(){this.editor.scribbles.stop(this.scribbleId)}onPointerMove(){this.updateScribbleSelection(!0)}onPointerUp(){this.complete()}onKeyDown(){this.updateScribbleSelection(!1)}onKeyUp(){if(!this.editor.inputs.getAltKey())this.parent.transition("brushing");else this.updateScribbleSelection(!1)}onCancel(){this.cancel()}onComplete(){this.complete()}pushPointToScribble(){let{x:J,y:Q}=this.editor.inputs.getCurrentPagePoint();this.editor.scribbles.addPoint(this.scribbleId,J,Q)}updateScribbleSelection(J){let{editor:Q}=this,Z=this.editor.inputs.getShiftKey(),q=this.editor.inputs.getOriginPagePoint(),X=this.editor.inputs.getPreviousPagePoint(),K=this.editor.inputs.getCurrentPagePoint(),{newlySelectedShapeIds:Y,initialSelectedShapeIds:W}=this;if(J)this.pushPointToScribble();let z=0,G=d.FromPoints([X,K]).expandBy(z),$=Q.getShapeIdsInsideBounds(G);if($.size===0){let O=Q.getSelectedShapeIds(),j=new Set(Z?[...Y,...W]:[...Y]);if(O.length!==j.size||O.some((k)=>!j.has(k)))this.editor.setSelectedShapes(Array.from(j));return}let F=this.editor.getCurrentPageRenderingShapesSorted().filter((O)=>$.has(O.id)),U,V,B,N;for(let O=0,j=F.length;O<j;O++){if(U=F[O],Q.isShapeOfType(U,"group")||Y.has(U.id)||!Q.options.selectLockedShapes&&Q.isShapeOrAncestorLocked(U))continue;if(V=Q.getShapeGeometry(U),Q.isShapeFrameLike(U)&&V.bounds.containsPoint(Q.getPointInShapeSpace(U,q)))continue;let k=Q.getShapePageTransform(U);if(!V||!k)continue;let R=k.clone().invert();B=R.applyToPoint(X),N=R.applyToPoint(K);let{bounds:P}=V;if(P.minX-z>Math.max(B.x,N.x)||P.minY-z>Math.max(B.y,N.y)||P.maxX+z<Math.min(B.x,N.x)||P.maxY+z<Math.min(B.y,N.y))continue;if(V.hitTestLineSegment(B,N,z)){let A=this.editor.getOutermostSelectableShape(U),I=this.editor.getShapeMask(A.id);if(I){if(O3(X,K,I)!==null){if(!n1(K,I))continue}}Y.add(A.id)}}let L=Q.getSelectedShapeIds(),D=new Set(Z?[...Y,...W]:[...Y]);if(L.length!==D.size||L.some((O)=>!D.has(O)))this.editor.setSelectedShapes(Array.from(D))}complete(){this.updateScribbleSelection(!0),this.parent.transition("idle")}cancel(){this.editor.setSelectedShapes([...this.initialSelectedShapeIds]),this.parent.transition("idle")}}var{defineProperty:cL0,getOwnPropertyDescriptor:lL0}=Object,pL0=(J,Q,Z,q)=>{var X=q>1?void 0:q?lL0(Q,Z):Q;for(var K=J.length-1,Y;K>=0;K--)if(Y=J[K])X=(q?Y(Q,Z,X):Y(X))||X;if(q&&X)cL0(Q,Z,X);return X},dL0=320,iL0=60;class LD{constructor(J){this.editor=J,J.disposables.add(this.dispose)}editor;shapesToActuallyMove=[];draggedOverShapeIds=new Set;initialGroupIds=new Map;initialParentIds=new Map;initialIndices=new Map;initialDraggingOverShape;prevDraggingOverShape;prevPagePoint=new M;intervalTimerId=-1;startDraggingShapes(J,Q,Z){let{editor:q}=this;if(this.intervalTimerId!==-1)return;let X=new Set(J),K=new Set;for(let z of X){let G=q.getShapeParent(z);if(G&&q.isShapeOfType(G,"group")){if(!K.has(G))K.add(G)}}for(let z of K){let G=D0(q.getSortedChildIdsForParent(z).map(($)=>q.getShape($)));X.add(z);for(let $ of G)X.delete($)}this.initialParentIds.clear();for(let z of X){let G=q.getShapeParent(z);if(G)this.initialParentIds.set(z.id,G.id);this.initialIndices.set(z.id,z.index);let $=q.findShapeAncestor(z,(H)=>q.isShapeOfType(H,"group"));if($)this.initialGroupIds.set(z.id,$.id)}let Y=q.getCurrentPageShapesSorted();this.shapesToActuallyMove=Array.from(X).filter((z)=>!z.isLocked).sort((z,G)=>Y.indexOf(z)-Y.indexOf(G)),this.initialDraggingOverShape=q.getDraggingOverShape(Q,this.shapesToActuallyMove),this.prevDraggingOverShape=this.initialDraggingOverShape,this.updateDraggingShapes(Q,Z);let W=0;this.intervalTimerId=this.editor.timers.setInterval(()=>{if(W++,W%3&&this.editor.inputs.getPointerVelocity().len()>0.5)return;this.updateDraggingShapes(q.inputs.getCurrentPagePoint(),Z)},J.length>10?dL0:iL0)}dropShapes(J){let{editor:Q}=this,Z=Q.inputs.getCurrentPagePoint();this.updateDraggingShapes(Z);let q=Q.getDraggingOverShape(Z,J);if(q){let X=Q.getShapeUtil(q),K=y10(Q,q,J);if(K.length>0)X.onDropShapesOver?.(q,K,{initialDraggingOverShapeId:this.initialDraggingOverShape?.id??null,initialParentIds:this.initialParentIds,initialIndices:this.initialIndices})}this.dispose()}clear(){clearInterval(this.intervalTimerId),this.intervalTimerId=-1,this.initialParentIds.clear(),this.initialIndices.clear(),this.shapesToActuallyMove=[],this.initialDraggingOverShape=void 0,this.prevDraggingOverShape=void 0,this.editor.setHintingShapes([])}dispose(){this.clear()}updateDraggingShapes(J,Q){let{editor:Z}=this,q=D0(this.shapesToActuallyMove.map((W)=>Z.getShape(W)));if(!q.length)return;let X=Z.getDraggingOverShape(J,this.shapesToActuallyMove),K=Z.inputs.getCurrentPagePoint(),Y=!this.prevPagePoint.equals(K);this.prevPagePoint.setTo(K),Z.run(()=>{if(this.prevDraggingOverShape?.id===X?.id){if(Y&&X&&$4(X.id)&&!Z.inputs.getPreviousPagePoint().equals(K))Z.getShapeUtil(X).onDragShapesOver?.(X,q,{initialDraggingOverShapeId:this.initialDraggingOverShape?.id??null,initialParentIds:this.initialParentIds,initialIndices:this.initialIndices});return}if(this.prevDraggingOverShape){let W=Z.getShapeUtil(this.prevDraggingOverShape),z=this.editor.getShape(this.prevDraggingOverShape),G=nL0(Z,z,q);if(G.length>0)W.onDragShapesOut?.(z,G,{nextDraggingOverShapeId:X?.id??null,initialDraggingOverShapeId:this.initialDraggingOverShape?.id??null,initialParentIds:this.initialParentIds,initialIndices:this.initialIndices})}if(X){let W=Z.getShapeUtil(X),z=y10(Z,X,q);if(z.length>0)W.onDragShapesIn?.(X,z,{initialDraggingOverShapeId:this.initialDraggingOverShape?.id??null,prevDraggingOverShapeId:this.prevDraggingOverShape?.id??null,initialParentIds:this.initialParentIds,initialIndices:this.initialIndices}),Z.setHintingShapes([X.id]);else if(this.prevDraggingOverShape)Z.setHintingShapes([])}else if(this.prevDraggingOverShape)Z.setHintingShapes([]);Q?.()}),this.prevDraggingOverShape=X}}pL0([f1],LD.prototype,"dispose",1);function y10(J,Q,Z){let q=J.getShapeUtil(Q);return Z.filter((X)=>q.canReceiveNewChildrenOfType(Q,X.type))}function nL0(J,Q,Z){let q=J.getShapeUtil(Q);return Z.filter((X)=>q.canRemoveChildrenOfType(Q,X.type))}var{defineProperty:sL0,getOwnPropertyDescriptor:rL0}=Object,aL0=(J,Q,Z,q)=>{var X=q>1?void 0:q?rL0(Q,Z):Q;for(var K=J.length-1,Y;K>=0;K--)if(Y=J[K])X=(q?Y(Q,Z,X):Y(X))||X;if(q&&X)sL0(Q,Z,X);return X};class OD extends a{static id="translating";static trackPerformance=!0;info={};selectionSnapshot={};snapshot={};markId="";isCloning=!1;isCreating=!1;onCreate(J){return}dragAndDropManager=new LD(this.editor);onEnter(J){let{isCreating:Q=!1,creatingMarkId:Z,onCreate:q=()=>{return}}=J;if(!this.editor.getSelectedShapeIds()?.length){this.parent.transition("idle");return}if(this.info=J,typeof J.onInteractionEnd==="string")this.parent.setCurrentToolIdMask(J.onInteractionEnd);if(this.isCreating=Q,this.markId="",Q)if(Z)this.markId=Z;else{let X=this.editor.getMarkIdMatching(`creating:${this.editor.getOnlySelectedShapeId()}`);if(X)this.markId=X}else this.markId=this.editor.markHistoryStoppingPoint("translating");if(this.onCreate=q,this.isCloning=!1,this.info=J,this.editor.setCursor({type:"move",rotation:0}),this.selectionSnapshot=x10(this.editor),!this.isCreating){if(this.editor.inputs.getAltKey()){if(this.startCloning(),this.isCloning)return}}this.snapshot=this.selectionSnapshot,this.handleStart(),this.updateShapes()}onExit(){this.parent.setCurrentToolIdMask(void 0),this.selectionSnapshot={},this.snapshot={},this.editor.snaps.clearIndicators(),this.editor.setCursor({type:"default",rotation:0}),this.dragAndDropManager.clear()}onTick({elapsed:J}){let{editor:Q}=this;if(!Q.inputs.getIsDragging()||Q.inputs.getIsPanning())return;Q.edgeScrollManager.updateEdgeScrolling(J)}onPointerMove(){this.updateShapes()}onKeyDown(){if(this.editor.inputs.getAltKey()&&!this.isCloning){if(this.startCloning(),this.isCloning)return}this.updateShapes()}onKeyUp(){if(!this.editor.inputs.getAltKey()&&this.isCloning){this.stopCloning();return}this.updateShapes()}onPointerUp(){this.complete()}onComplete(){this.complete()}onCancel(){this.cancel()}startCloning(){if(this.isCreating)return;let J=Array.from(this.editor.getSelectedShapeIds());if(!this.editor.canCreateShapes(J))return;this.isCloning=!0,this.reset(),this.markId=this.editor.markHistoryStoppingPoint("translate cloning"),this.editor.duplicateShapes(Array.from(this.editor.getSelectedShapeIds())),this.snapshot=x10(this.editor),this.handleStart(),this.updateShapes()}stopCloning(){this.isCloning=!1,this.snapshot=this.selectionSnapshot,this.reset(),this.markId=this.editor.markHistoryStoppingPoint("translate"),this.updateShapes()}reset(){this.editor.bailToMark(this.markId)}complete(){this.updateShapes(),this.dragAndDropManager.dropShapes(this.snapshot.movingShapes),this.handleEnd(),z1(this.editor,this.snapshot.movingShapes.map((Q)=>Q.id));let{onInteractionEnd:J}=this.info;if(J)if(typeof J==="string"){if(this.editor.getInstanceState().isToolLocked){this.editor.setCurrentTool(J);return}}else{J();return}if(this.isCreating)this.onCreate?.(this.editor.getOnlySelectedShape());else this.parent.transition("idle")}cancel(){let{movingShapes:J}=this.snapshot;J.forEach((Z)=>{let q=this.editor.getShape(Z.id);if(q)this.editor.getShapeUtil(Z).onTranslateCancel?.(Z,q)}),this.reset();let{onInteractionEnd:Q}=this.info;if(Q){if(typeof Q==="string")this.editor.setCurrentTool(Q);else Q();return}this.parent.transition("idle",this.info)}handleStart(){let{movingShapes:J}=this.snapshot,Q=[];if(J.forEach((Z)=>{let X=this.editor.getShapeUtil(Z).onTranslateStart?.(Z);if(X)Q.push(X)}),Q.length>0)this.editor.updateShapes(Q);this.dragAndDropManager.startDraggingShapes(D0(this.snapshot.movingShapes.map((Z)=>this.editor.getShape(Z.id))),this.editor.inputs.getOriginPagePoint(),this.updateParentTransforms),this.editor.setHoveredShape(null)}handleEnd(){let{movingShapes:J}=this.snapshot;if(this.isCloning&&J.length>0){let Z=M.Average(J.map((X)=>this.editor.getShapePageTransform(X.id).point())),q=M.Sub(Z,this.selectionSnapshot.averagePagePoint);if(!M.IsNaN(q))this.editor.updateInstanceState({duplicateProps:{shapeIds:J.map((X)=>X.id),offset:{x:q.x,y:q.y}}})}let Q=[];if(J.forEach((Z)=>{let q=this.editor.getShape(Z.id),K=this.editor.getShapeUtil(Z).onTranslateEnd?.(Z,q);if(K)Q.push(K)}),Q.length>0)this.editor.updateShapes(Q)}updateShapes(){let{snapshot:J}=this;this.dragAndDropManager.startDraggingShapes(J.movingShapes,this.editor.inputs.getOriginPagePoint(),this.updateParentTransforms),oL0({editor:this.editor,snapshot:J});let{movingShapes:Q}=J,Z=[];if(Q.forEach((q)=>{let X=this.editor.getShape(q.id),Y=this.editor.getShapeUtil(q).onTranslate?.(q,X);if(Y)Z.push(Y)}),Z.length>0)this.editor.updateShapes(Z)}updateParentTransforms(){let{editor:J,snapshot:{shapeSnapshots:Q}}=this,Z=[];Q.forEach((q)=>{let X=J.getShape(q.shape.id);if(!X)return;Z.push(X);let K=B6(X.parentId)?null:i.Inverse(J.getShapePageTransform(X.parentId));q.parentTransform=K})}}aL0([f1],OD.prototype,"updateParentTransforms",1);function x10(J){let Q=[],Z=[],q=J.getSelectedShapeIds(),X=D0(q.map((_)=>{let F=J.getShape(_);if(!F)return null;Q.push(F);let U=J.getShapePageTransform(_),V=U.point(),B=U.rotation();Z.push(V);let N=w4.isId(F.parentId)?null:i.Inverse(J.getShapePageTransform(F.parentId));return{shape:F,pagePoint:V,pageRotation:B,parentTransform:N}})),K=J.getOnlySelectedShape(),Y=[];if(K)Y=J.snaps.shapeBounds.getSnapPoints(K.id);else{let _=J.getSelectionPageBounds();if(_)Y=_.cornersAndCenter.map((F,U)=>({id:"selection:"+U,x:F.x,y:F.y}))}let W,z,G,$=J.inputs.getOriginPagePoint(),H=X.filter((_)=>J.isShapeOfType(_.shape,"note")&&J.isPointInShape(_.shape,$));if(H.length===0);else if(H.length===1)z=H[0];else{let _=J.getCurrentPageShapesSorted();z=H.map((F)=>({snapshot:F,index:_.findIndex((U)=>U.id===F.shape.id)})).sort((F,U)=>U.index-F.index)[0]?.snapshot}if(z){let _=J.getShapeUtil(z.shape),F=k0(_,z.shape);W=xO(J,{rotation:z.pageRotation,scale:z.shape.props.scale,extraHeight:z.shape.props.growY??0,noteWidth:F.noteWidth,noteHeight:F.noteHeight}),G=new M(F.noteWidth/2,F.noteHeight/2)}return{averagePagePoint:M.Average(Z),movingShapes:Q,shapeSnapshots:X,initialPageBounds:J.getSelectionPageBounds(),initialSnapPoints:Y,noteAdjacentPositions:W,noteSnapshot:z,noteCenterOffset:G}}function oL0({editor:J,snapshot:Q}){let{inputs:Z}=J,{noteSnapshot:q,noteAdjacentPositions:X,noteCenterOffset:K,initialPageBounds:Y,initialSnapPoints:W,shapeSnapshots:z,averagePagePoint:G}=Q,$=J.inputs.getShiftKey(),H=J.inputs.getAccelKey(),_=J.getInstanceState().isGridMode,F=J.getDocumentSettings().gridSize,U=M.Sub(Z.getCurrentPagePoint(),Z.getOriginPagePoint()),V=$?Math.abs(U.x)<Math.abs(U.y)?"x":"y":null;if(V==="x")U.x=0;else if(V==="y")U.y=0;J.snaps.clearIndicators();let B=J.user.getIsSnapMode()?!H:H,N=!1;if(B&&J.inputs.getPointerVelocity().len()<0.5){let{nudge:j}=J.snaps.shapeBounds.snapTranslateShapes({dragDelta:U,initialSelectionPageBounds:Y,lockedAxis:V,initialSelectionSnapPoints:W});U.add(j)}else if(q&&X&&K){let{scale:j}=q.shape.props,k=q.pagePoint.clone().add(U).add(K.clone().mul(j).rot(q.pageRotation)),R=yO/J.getZoomLevel(),P=new M(0,0);for(let A of X){let I=M.Sub(k,A),C=I.len();if(C<R)N=!0,R=C,P=I}U.sub(P)}let L=M.Add(G,U),D=J.snaps.getIndicators();if(_&&!H&&!N&&D.length===0)L.snapToGrid(F);let O=M.Sub(L,G);J.updateShapes(D0(z.map(({shape:j,pagePoint:k,parentTransform:R})=>{let P=M.Add(k,O),A=R?i.applyToPoint(R,P):P;return{id:j.id,type:j.type,x:A.x,y:A.y}})))}class DD extends a{static id="select";static initial="idle";static isLockable=!1;reactor=void 0;static children(){return[dT,y_,sT,aT,Jy,OD,uT,Xy,x_,eT,mT,nT,Zy,qy,tT,rT,oT,iT]}cleanUpDuplicateProps(){let J=this.editor.getSelectedShapeIds(),Q=this.editor.getInstanceState();if(!Q.duplicateProps)return;let Z=new Set(Q.duplicateProps.shapeIds);if(J.length===Z.size&&J.every((q)=>Z.has(q)))return;this.editor.updateInstanceState({duplicateProps:null})}onEnter(){this.reactor=P1("clean duplicate props",()=>{try{this.cleanUpDuplicateProps()}catch(J){console.error(J)}})}onExit(){if(this.reactor?.(),this.editor.getCurrentPageState().editingShapeId)this.editor.setEditingShape(null)}}class Ky extends a{static id="idle";info={};onEnter(J){this.info=J}onPointerDown(){this.parent.transition("pointing",this.info)}onKeyDown(J){if(J.key==="Shift")this.parent.transition("zoom_quick",this.info)}}class Yy extends a{static id="pointing";info={};onEnter(J){this.info=J}onPointerUp(){this.complete()}onPointerMove(){if(this.editor.inputs.getIsDragging())this.parent.transition("zoom_brushing",this.info)}onCancel(){this.cancel()}complete(){let J=this.editor.inputs.getCurrentScreenPoint();if(this.editor.inputs.getAltKey())this.editor.zoomOut(J,{animation:{duration:220}});else this.editor.zoomIn(J,{animation:{duration:220}});this.parent.transition("idle",this.info)}cancel(){this.parent.transition("idle",this.info)}}class Wy extends a{static id="zoom_brushing";info={};zoomBrush=new d;onEnter(J){this.info=J,this.update()}onExit(){this.editor.updateInstanceState({zoomBrush:null})}onPointerMove(){this.update()}onPointerUp(){this.complete()}onCancel(){this.cancel()}update(){let J=this.editor.inputs.getOriginPagePoint(),Q=this.editor.inputs.getCurrentPagePoint();this.zoomBrush.setTo(d.FromPoints([J,Q])),this.editor.updateInstanceState({zoomBrush:this.zoomBrush.toJson()})}cancel(){this.parent.transition("idle",this.info)}complete(){let{zoomBrush:J}=this,Q=8/this.editor.getZoomLevel();if(J.width<Q&&J.height<Q){let Z=this.editor.inputs.getCurrentScreenPoint();if(this.editor.inputs.getAltKey())this.editor.zoomOut(Z,{animation:{duration:220}});else this.editor.zoomIn(Z,{animation:{duration:220}})}else{let Z=this.editor.inputs.getAltKey()?this.editor.getZoomLevel()/2:void 0;this.editor.zoomToBounds(J,{targetZoom:Z,animation:{duration:220}})}this.parent.transition("idle",this.info)}}class zy extends a{static id="zoom_quick";info={};qzState="idle";initialVpb=new d;initialPp=new M;overviewZoom=1;cleanupZoomReactor(){}nextVpb=new d;onEnter(J){let{editor:Q}=this;this.info=J,this.qzState="idle",this.initialVpb=Q.getViewportPageBounds(),this.initialPp=M.From(Q.inputs.getCurrentPagePoint()),Q.setCursor({type:"zoom-in",rotation:0});let Z=this.initialVpb,q=Q.getCurrentPageBounds(),X=q?d.Expand(Z,q):Z.clone(),K=Q.getViewportScreenBounds(),Y=Q.inputs.getCurrentScreenPoint(),W=Y.x,z=Y.y,{x:G,y:$}=this.initialPp,H=G-X.minX,_=X.maxX-G,F=$-X.minY,U=X.maxY-$,V=Q.getCamera().z;if(H>0)V=Math.min(V,W/H);if(_>0)V=Math.min(V,(K.w-W)/_);if(F>0)V=Math.min(V,z/F);if(U>0)V=Math.min(V,(K.h-z)/U);if(V*=0.85,V=Math.max(Q.getCameraOptions().zoomSteps[0],V),this.overviewZoom=V,Q.options.quickZoomPreservesScreenBounds)this.cleanupZoomReactor=P1("zoom change in quick zoom",()=>{Q.getZoomLevel(),this.updateBrush()});let{x:B,y:N,z:L}=Q.getCamera(),D=L/V;if(Q.setCamera(new M((B+G)*D-G,(N+$)*D-$,V)),!Q.options.quickZoomPreservesScreenBounds)this.updateBrush()}onExit(){this.cleanupZoomReactor(),this.zoomToNewViewport(),this.editor.updateInstanceState({zoomBrush:null})}onPointerUp(){let J=this.info.onInteractionEnd?.split(".")[0]??"select";this.editor.setCurrentTool(J)}onCancel(){this.qzState="idle";let J=this.info.onInteractionEnd?.split(".")[0]??"select";this.editor.setCurrentTool(J)}onKeyUp(J){if(J.key==="Shift")this.parent.transition("idle",this.info)}updateBrush(){let{editor:J}=this,Q=this.getNextVpb();this.nextVpb.setTo(Q),J.updateInstanceState({zoomBrush:Q.toJson()})}zoomToNewViewport(){let{editor:J}=this;switch(this.qzState){case"idle":J.zoomToBounds(this.initialVpb,{inset:0});break;case"moving":J.zoomToBounds(this.nextVpb,{inset:0});break}}onPointerMove(){if(this.qzState!=="moving")return;this.updateBrush()}onTick(){let{editor:J}=this;switch(this.qzState){case"idle":{let Q=J.getZoomLevel();if(M.Dist2(J.inputs.getCurrentPagePoint(),this.initialPp)*Q>J.options.dragDistanceSquared/Q)this.qzState="moving",this.updateBrush();break}case"moving":break}}getNextVpb(){let{editor:J}=this,Q,Z;if(J.options.quickZoomPreservesScreenBounds){let G=this.overviewZoom/J.getCamera().z;Q=this.initialVpb.w*G,Z=this.initialVpb.h*G}else Q=this.initialVpb.w,Z=this.initialVpb.h;let{x:q,y:X}=J.inputs.getCurrentPagePoint(),K=J.getViewportScreenBounds(),Y=J.inputs.getCurrentScreenPoint(),{x:W,y:z}=new M(Y.x/K.w,Y.y/K.h);return new d(q-W*Q,X-z*Z,Q,Z)}}class MD extends a{static id="zoom";static initial="idle";static children(){return[Ky,Yy,Wy,zy]}static isLockable=!1;info={};onEnter(J){this.info=J;let Q=J.onInteractionEnd?.split(".")[0];this.parent.setCurrentToolIdMask(Q),this.updateCursor()}onExit(){this.parent.setCurrentToolIdMask(void 0),this.editor.updateInstanceState({zoomBrush:null,cursor:{type:"default",rotation:0}})}onKeyDown(){this.updateCursor()}onKeyUp(J){if(this.updateCursor(),J.key.toLowerCase()==="z")this.complete()}onInterrupt(){this.complete()}complete(){let J=this.info.onInteractionEnd?.split(".")[0]??"select";this.editor.setCurrentTool(J)}updateCursor(){if(this.editor.inputs.getAltKey()&&!this.editor.isIn("zoom.zoom_quick"))this.editor.setCursor({type:"zoom-out",rotation:0});else this.editor.setCursor({type:"zoom-in",rotation:0})}}var Gy=[FD,UD,VD,MD,DD];var ZK=E(c(),1);var f10=E(c1(),1),g10=E(m(),1);var v10=E(c(),1);var S10=E(m(),1),Hy=S10.default.forwardRef(function({isEditing:Q,text:Z,handleFocus:q,handleChange:X,handleKeyDown:K,handlePaste:Y,handleBlur:W,handleInputPointerDown:z,handleDoubleClick:G},$){let H=v();return v10.jsx("textarea",{ref:$,className:"tl-text tl-text-input",name:"text",tabIndex:-1,disabled:!Q,readOnly:!Q,autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",autoSave:"off",placeholder:"",spellCheck:"true",wrap:"off",dir:"auto",defaultValue:Z,onFocus:q,onChange:(F)=>{X({plaintext:F.target.value})},onKeyDown:(F)=>K(F.nativeEvent),onBlur:W,onTouchEnd:H.markEventAsHandled,onContextMenu:Q?(F)=>F.stopPropagation():void 0,onPointerDown:z,onPaste:Y,onDoubleClick:G,onDragStart:W0})});var tL0=g10.default.memo(function({shapeId:Q,type:Z,text:q,labelColor:X,fontFamily:K,fontSize:Y,lineHeight:W,textAlign:z,verticalAlign:G,wrap:$,isSelected:H,padding:_=0,onKeyDown:F,classNamePrefix:U,style:V,textWidth:B,textHeight:N,showTextOutline:L=!0}){let{rInput:D,isEmpty:O,isEditing:j,isReadyForEditing:k,...R}=KT(Q,Z,q),P=WX.normalizeTextForDom(q||""),A=P.length>0,I=D_(z);if(!j&&!A)return null;let C=U||"tl-text";return ZK.jsx("div",{className:`${C}-label tl-text-wrapper tl-plain-text-wrapper`,"aria-hidden":!j,"data-hastext":!O,"data-isediting":j,"data-is-ready-for-editing":k,"data-textwrap":!!$,"data-isselected":H,style:{fontFamily:K,textAlign:z,justifyContent:z==="center"||I?"center":z==="end"?"flex-end":"flex-start",alignItems:G==="middle"?"center":G==="end"?"flex-end":"flex-start",padding:_,...V},children:ZK.jsxs("div",{className:`${C}-label__inner tl-text-content__wrapper`,style:{fontSize:Y,lineHeight:`${i8(Y,W)}px`,minHeight:`${i8(Y,W)}px`,minWidth:Math.ceil(B||0),color:X,width:B?Math.ceil(B):void 0,height:N?Math.ceil(N):void 0},children:[ZK.jsx("div",{className:f10.default(`${C} tl-text tl-text-content`,L?"tl-text__outline":"tl-text__no-outline"),dir:"auto",children:P.split(`
546
- `).map((y,S)=>ZK.jsx("div",{dir:"auto",children:y},S))}),(k||H)&&ZK.jsx(Hy,{ref:D,text:q,isEditing:j,shapeId:Q,...R,handleKeyDown:F??R.handleKeyDown})]})})});var F9=E(c(),1);var L2=E(m(),1);var u10=E(m(),1);var h10=E(m(),1),v_={fonts:{tldraw_mono:`${Q6()}/fonts/IBMPlexMono-Medium.woff2`,tldraw_mono_italic:`${Q6()}/fonts/IBMPlexMono-MediumItalic.woff2`,tldraw_mono_bold:`${Q6()}/fonts/IBMPlexMono-Bold.woff2`,tldraw_mono_italic_bold:`${Q6()}/fonts/IBMPlexMono-BoldItalic.woff2`,tldraw_serif:`${Q6()}/fonts/IBMPlexSerif-Medium.woff2`,tldraw_serif_italic:`${Q6()}/fonts/IBMPlexSerif-MediumItalic.woff2`,tldraw_serif_bold:`${Q6()}/fonts/IBMPlexSerif-Bold.woff2`,tldraw_serif_italic_bold:`${Q6()}/fonts/IBMPlexSerif-BoldItalic.woff2`,tldraw_sans:`${Q6()}/fonts/IBMPlexSans-Medium.woff2`,tldraw_sans_italic:`${Q6()}/fonts/IBMPlexSans-MediumItalic.woff2`,tldraw_sans_bold:`${Q6()}/fonts/IBMPlexSans-Bold.woff2`,tldraw_sans_italic_bold:`${Q6()}/fonts/IBMPlexSans-BoldItalic.woff2`,tldraw_draw:`${Q6()}/fonts/Shantell_Sans-Informal_Regular.woff2`,tldraw_draw_italic:`${Q6()}/fonts/Shantell_Sans-Informal_Regular_Italic.woff2`,tldraw_draw_bold:`${Q6()}/fonts/Shantell_Sans-Informal_Bold.woff2`,tldraw_draw_italic_bold:`${Q6()}/fonts/Shantell_Sans-Informal_Bold_Italic.woff2`}};function jD(J){return h10.useMemo(()=>{if(!J)return v_;return{fonts:{...v_.fonts,...J?.fonts}}},[J])}var $y=["align-bottom","align-center-horizontal","align-center-vertical","align-left","align-right","align-top","alt","arrow-arc","arrow-cycle","arrow-elbow","arrow-left","arrowhead-arrow","arrowhead-bar","arrowhead-diamond","arrowhead-dot","arrowhead-none","arrowhead-square","arrowhead-triangle-inverted","arrowhead-triangle","blob","bold","bookmark","bring-forward","bring-to-front","broken","bulletList","check-circle","check","chevron-down","chevron-left","chevron-right","chevron-up","chevrons-ne","chevrons-sw","clipboard-copied","clipboard-copy","code","color","comment","corners","crop","cross-2","cross-circle","dash-dashed","dash-dotted","dash-draw","dash-solid","disconnected","discord","distribute-horizontal","distribute-vertical","dot","dots-horizontal","dots-vertical","download","drag-handle-dots","duplicate","edit","external-link","fill-fill","fill-lined-fill","fill-none","fill-pattern","fill-semi","fill-solid","follow","following","font-draw","font-mono","font-sans","font-serif","geo-arrow-down","geo-arrow-left","geo-arrow-right","geo-arrow-up","geo-check-box","geo-cloud","geo-diamond","geo-ellipse","geo-heart","geo-hexagon","geo-octagon","geo-oval","geo-pentagon","geo-rectangle","geo-rhombus-2","geo-rhombus","geo-star","geo-trapezoid","geo-triangle","geo-x-box","github","group","heading","help-circle","highlight","horizontal-align-end","horizontal-align-middle","horizontal-align-start","info-circle","italic","leading","link","list","lock","manual","menu","minus","mixed","pack","plus","question-mark-circle","question-mark","redo","reset-zoom","rotate-ccw","rotate-cw","send-backward","send-to-back","share-1","size-extra-large","size-large","size-medium","size-small","spline-cubic","spline-line","stack-horizontal","stack-vertical","status-offline","stretch-horizontal","stretch-vertical","strike","text-align-center","text-align-left","text-align-right","toggle-off","toggle-on","tool-arrow","tool-eraser","tool-frame","tool-hand","tool-highlight","tool-laser","tool-line","tool-media","tool-note","tool-pencil","tool-pointer","tool-screenshot","tool-text","trash","twitter","underline","undo","ungroup","unlock","vertical-align-end","vertical-align-middle","vertical-align-start","warning-triangle","zoom-in","zoom-out"];var S_={...v_,icons:Object.fromEntries($y.map((J)=>[J,`${Q6()}/icons/icon/0_merged.svg#${J}`])),translations:Object.fromEntries(C2.map((J)=>[J.locale,`${Q6()}/translations/${J.locale}.json`])),embedIcons:Object.fromEntries(zW.map((J)=>[J.type,`${Q6()}/embed-icons/${J.type}.png`]))};function RD(J){return u10.useMemo(()=>{if(!J)return S_;return{fonts:Object.assign({...S_.fonts},{...J?.fonts}),icons:Object.assign({...S_.icons},{...J?.icons}),embedIcons:Object.assign({...S_.embedIcons},{...J?.embedIcons}),translations:Object.assign({...S_.translations},{...J?.translations})}},[J])}var _y=E(c(),1);function m10(){let{Spinner:J}=T4();return _y.jsx(tR,{children:J?_y.jsx(J,{}):null})}var U1=E(c(),1);var p10=E(c1(),1),d9=E(m(),1);var _9=E(c(),1);var Fy=p1(function({overrides:Q,components:Z,assetUrls:q,onUiEvent:X,forceMobile:K,mediaMimeTypes:Y,children:W}){let z=J1();return _9.jsx(cI.Provider,{value:Y,children:_9.jsx(hH,{assetUrls:RD(q),children:_9.jsx(mH,{overrides:BL(Q),locale:z?.user.getLocale()??v6.locale,children:_9.jsx(zI,{children:_9.jsx(VI,{onEvent:X,children:_9.jsx(bI,{children:_9.jsx(II,{context:"tla",children:_9.jsx(AE,{children:_9.jsx(_I,{forceMobile:K,children:_9.jsx(jb,{overrides:Z,children:_9.jsx(eL0,{overrides:Q,children:W})})})})})})})})})})})});function eL0({overrides:J,children:Q}){let Z=Ro(J);return _9.jsx(ee,{overrides:Z.actions,children:_9.jsx(Ao,{overrides:Z.tools,children:Q})})}var c10=E(m(),1);function l10(){let J=v(),{addToast:Q}=P5();c10.useEffect(()=>{function Z({name:q,count:X}){Q({title:"Maximum shapes reached",description:`You've reached the maximum number of shapes allowed on ${q} (${X}). Please delete some shapes or move to a different page to continue.`,severity:"warning"})}return J.addListener("max-shapes",Z),()=>{J.removeListener("max-shapes",Z)}},[J,Q])}var Uy=d9.default.memo(function({renderDebugMenuItems:Q,children:Z,hideUi:q,components:X,...K}){return U1.jsx(Fy,{...K,components:X,children:U1.jsx(JO0,{hideUi:q,renderDebugMenuItems:Q,children:Z})})}),JO0=d9.default.memo(function({children:Q,hideUi:Z,...q}){return Fb(),gI(),U1.jsxs(U1.Fragment,{children:[Q,Z?null:U1.jsx(QO0,{...q})]})}),QO0=d9.default.memo(function(){let Q=v(),Z=t(),q=A1(),X=I6(),K=g("focus",()=>Q.getInstanceState().isFocusMode,[Q]),Y=g("debug",()=>Q.getInstanceState().isDebugMode,[Q]),W=Q1(),z=t0(),G=g("locale",()=>Q.user.getLocale(),[Q]);d9.useEffect(()=>{W.dir=z,W.lang=G},[W,z,G]);let{SharePanel:$,TopPanel:H,MenuPanel:_,StylePanel:F,Toolbar:U,HelpMenu:V,NavigationPanel:B,HelperButtons:N,DebugPanel:L,Toasts:D,Dialogs:O,A11y:j,FollowingIndicator:k}=N4();l10();let R=d9.useRef(!1),P=d9.useRef(-1),[A,I]=d9.useState(!1);EJ("update hide toolbar while delayed",()=>{if(!(S0.isIos||S0.isAndroid))return;if(Q.getEditingShapeId()===null){if(R.current)if(R.current=!1,clearTimeout(P.current),S0.isAndroid)P.current=Q.timers.setTimeout(()=>{I(!1)},150);else I(!1);return}if(!R.current)R.current=!0,clearTimeout(P.current),I(!0)},[]);let{"toggle-focus-mode":C}=f6(),{breakpointsAbove:y,breakpointsBelow:S}=d9.useMemo(()=>{let T=[],h=[];for(let b=0;b<HW.length;b++)if(b<=q)T.push(b);else h.push(b);return{breakpointsAbove:T,breakpointsBelow:h}},[q]);return U1.jsxs("div",{className:p10.default("tlui-layout",{"tlui-layout__mobile":q<e0.TABLET_SM}),role:"document","data-iseditinganything":A,"data-breakpoint":q,"data-breakpoints-above":y.join(" "),"data-breakpoints-below":S.join(" "),children:[U1.jsx(Z00,{}),K?U1.jsx("div",{className:"tlui-layout__top",children:U1.jsx(w0,{type:"icon",className:"tlui-focus-button",title:Z("focus-mode.toggle-focus-mode"),onClick:()=>C.onSelect("menu"),children:U1.jsx(z0,{icon:"dot"})})}):U1.jsxs(U1.Fragment,{children:[U1.jsxs("div",{className:"tlui-layout__top",children:[U1.jsxs("div",{className:"tlui-layout__top__left",children:[_&&U1.jsx(_,{}),N&&U1.jsx(N,{})]}),U1.jsx("div",{className:"tlui-layout__top__center",children:H&&U1.jsx(H,{})}),U1.jsxs("div",{className:"tlui-layout__top__right",children:[$&&U1.jsx($,{}),F&&q>=e0.TABLET_SM&&!X&&U1.jsx(F,{})]})]}),U1.jsxs("div",{className:"tlui-layout__bottom",children:[U1.jsxs("div",{className:"tlui-layout__bottom__main",children:[B&&U1.jsx(B,{}),U&&U1.jsx(U,{}),V&&U1.jsx(V,{})]}),Y&&L&&U1.jsx(L,{}),j&&U1.jsx(j,{})]})]}),k&&U1.jsx(k,{}),D&&U1.jsx(D,{}),O&&U1.jsx(O,{})]})});function kD(){let{RichTextToolbar:J,ImageToolbar:Q,VideoToolbar:Z,CursorChatBubble:q}=N4();return U1.jsxs(U1.Fragment,{children:[J&&U1.jsx(J,{}),Q&&U1.jsx(Q,{}),Z&&U1.jsx(Z,{}),q&&U1.jsx(q,{})]})}var ZO0=[...Gy,...JT];function qO0(J,Q){let{maxImageDimension:Z,acceptedImageMimeTypes:q,acceptedVideoMimeTypes:X}=Q,K=Z!==void 0||q!==void 0,Y=X!==void 0;if(!K&&!Y)return J;return J.map((W)=>{if(K&&W.type==="image")return W.configure({...Z!==void 0&&{maxDimension:Z},...q!==void 0&&{supportedMimeTypes:q}});if(Y&&W.type==="video")return W.configure({...X!==void 0&&{supportedMimeTypes:X}});return W})}function Vy(J){let{children:Q,maxImageDimension:Z,maxAssetSize:q,acceptedImageMimeTypes:X,acceptedVideoMimeTypes:K,onMount:Y,components:W={},shapeUtils:z=[],bindingUtils:G=[],assetUtils:$=[],overlayUtils:H=[],tools:_=[],embeds:F,options:U,locale:V,textOptions:B,...N}=J,L=b9(W),D=W?.InFrontOfTheCanvas,O=L2.useMemo(()=>{if(N.hideUi)return D??null;if(!D)return kD;return()=>F9.jsxs(F9.Fragment,{children:[F9.jsx(kD,{}),F9.jsx(D,{})]})},[N.hideUi,D]),j=L2.useMemo(()=>({Spinner:w$,LoadingScreen:m10,...L,InFrontOfTheCanvas:O}),[L,O]),k=l8(z),R=L2.useMemo(()=>M2("type",k,eX),[k]),P=l8(G),A=L2.useMemo(()=>M2("type",P,sX),[P]),I=l8($),C=L2.useMemo(()=>qO0(M2("type",I,hb),{maxImageDimension:Z,acceptedImageMimeTypes:X,acceptedVideoMimeTypes:K}),[I,Z,X,K]),y=l8(H),S=L2.useMemo(()=>M2("type",y,ub),[y]),T=l8(_),h=L2.useMemo(()=>M2("id",T,ZO0),[T]),b=l8(X??aq),x=l8(K??UK),f=U?.text??B,u=L2.useMemo(()=>{return{addFontsFromNode:K$,...f,tipTapConfig:{extensions:dZ,...f?.tipTapConfig}}},[f]),p=L2.useMemo(()=>({...U,text:u}),[U,u]),o=L2.useMemo(()=>[...b,...x],[b,x]),K0=jD(N.assetUrls);if(R.find((y0)=>y0.type==="embed")&&F)vq.setEmbedDefinitions(F);return F9.jsx(hH,{assetUrls:RD(N.assetUrls),children:F9.jsx(mH,{overrides:BL(N.overrides),locale:V??N.user?.userPreferences.get().locale??v6.locale,children:F9.jsx(oR,{initialState:"select",...N,components:j,shapeUtils:R,bindingUtils:A,assetUtils:C,overlayUtils:S,tools:h,options:p,assetUrls:K0,children:F9.jsxs(Uy,{...N,components:j,mediaMimeTypes:o,children:[F9.jsx(XO0,{maxImageDimension:Z,maxAssetSize:q,acceptedImageMimeTypes:b,acceptedVideoMimeTypes:x,onMount:Y}),Q]})})})})}function XO0({maxImageDimension:J,maxAssetSize:Q,acceptedImageMimeTypes:Z,acceptedVideoMimeTypes:q,onMount:X}){let K=v(),Y=P5(),W=t(),z=o0();cU(()=>{let H=[];H.push(wT(K)),K.fonts.requestFonts(CA);let _=K.getThemes();for(let F of Object.values(_))for(let U of Object.keys(F.fonts)){let V=F.fonts[U];if(V.faces?.length)K.fonts.requestFonts(V.faces)}return K.once("edit",()=>z("edit",{source:"unknown"})),bA(K,{maxImageDimension:J,maxAssetSize:Q,acceptedImageMimeTypes:Z,acceptedVideoMimeTypes:q,toasts:Y,msg:W}),H.push(K.store.props.onMount(K)),H.push(X?.(K)),()=>{H.forEach((F)=>F?.())}});let{Canvas:G}=T4(),{ContextMenu:$}=N4();if($)return F9.jsx($,{});if(G)return F9.jsx(G,{});return null}var Ny=E(c(),1);var i9=E(m(),1);var d10={text:{tipTapConfig:{extensions:dZ},addFontsFromNode:K$}},KO0=i9.memo(function(Q){let[Z,q]=i9.useState(null),[X,K]=i9.useState(null),Y=l8(Q.shapeUtils??[]),W=i9.useMemo(()=>M2("type",Y,eX),[Y]),z=l8(Q.bindingUtils??[]),G=i9.useMemo(()=>M2("type",z,sX),[z]),$=rR({snapshot:Q.snapshot,shapeUtils:W}),{pageId:H,bounds:_,scale:F,pixelRatio:U,background:V,padding:B,darkMode:N,preserveAspectRatio:L,format:D="svg",licenseKey:O,assetUrls:j,options:k,textOptions:R}=Q,P=i9.useMemo(()=>({...d10,...k,text:{...d10.text,...k?.text??R}}),[k,R]),A=jD(j);return i9.useLayoutEffect(()=>{if(!X)return;if(!$)return;let I=!1,C=X.ownerDocument.createElement("div");X.appendChild(C),X.classList.add("tl-container","tl-theme__light");let y=new G0({store:$,shapeUtils:W,bindingUtils:G,tools:[],getContainer:()=>C,licenseKey:O,fontAssetUrls:A.fonts,options:P});if(H)y.setCurrentPage(H);let S=y.getCurrentPageShapeIds();async function T(){let h=await y.toImage([...S],{bounds:_,scale:F,background:V,padding:B,darkMode:N,preserveAspectRatio:L,format:D});if(!h||I)return;let b=URL.createObjectURL(h.blob);q(b),y.dispose()}return T(),()=>{I=!0}},[D,X,$,W,G,H,_,F,V,B,N,L,O,U,A,P]),i9.useEffect(()=>{return()=>{if(Z)URL.revokeObjectURL(Z)}},[Z]),Ny.jsx("div",{ref:K,style:{position:"relative",width:"100%",height:"100%"},children:Z&&Ny.jsx("img",{src:Z,referrerPolicy:"strict-origin-when-cross-origin",style:{width:"100%",height:"100%"}})})});var NJ=E(c(),1);var ED=E(m(),1);var YO0=ED.memo(function({children:Q}){let Z=t(),q=A1(),X=ED.useRef(null);r6(X);let K=Q??NJ.jsx(Pw,{});if(q<e0.MOBILE)return null;return NJ.jsx("div",{ref:X,className:"tlui-help-menu",children:NJ.jsxs(LQ,{id:"help menu",children:[NJ.jsx(OQ,{children:NJ.jsx(w0,{type:"help",title:Z("help-menu.title"),"data-testid":"help-menu.button",children:NJ.jsx(z0,{icon:"question-mark",small:!0})})}),NJ.jsx(DQ,{side:"top",align:"end",alignOffset:0,sideOffset:8,children:NJ.jsx(z4,{type:"menu",sourceId:"help-menu",children:K})})]})})});var f_=E(c(),1);var i10=E(c1(),1);var n10=E(m(),1);var WO0=n10.forwardRef(function({children:Q,className:Z},q){return f_.jsxs(k$.Trigger,{ref:q,className:i10.default("tlui-button tlui-select__trigger",Z),children:[Q,f_.jsx(k$.Icon,{className:"tlui-select__chevron",children:f_.jsx(S6,{icon:"chevron-down",label:"",small:!0})})]})});var zO0=E(c(),1),By=E(m(),1);var n9={White:"white",LightGray:"lightGray",Gray:"gray",Black:"black",Green:"green",Cyan:"cyan",Blue:"blue",Indigo:"indigo",Violet:"violet",Red:"red",Orange:"orange",Yellow:"yellow"},qK={Small:"small",Medium:"medium",Large:"large"},g_={Draw:"draw",Solid:"solid",Dashed:"dashed",Dotted:"dotted"},iQ={Start:"start",Middle:"middle",End:"end",Justify:"justify"},h_={Script:"script",Sans:"sans",Serif:"serif",Mono:"mono"};var yD1={[n9.White]:"black",[n9.Black]:"black",[n9.LightGray]:"grey",[n9.Gray]:"grey",[n9.Green]:"light-green",[n9.Cyan]:"green",[n9.Blue]:"light-blue",[n9.Indigo]:"blue",[n9.Orange]:"orange",[n9.Yellow]:"yellow",[n9.Red]:"red",[n9.Violet]:"light-violet"},xD1={[h_.Mono]:"mono",[h_.Sans]:"sans",[h_.Script]:"draw",[h_.Serif]:"serif"},vD1={[iQ.Start]:"start",[iQ.Middle]:"middle",[iQ.End]:"end",[iQ.Justify]:"start"},SD1={[iQ.Start]:"start",[iQ.Middle]:"middle",[iQ.End]:"end",[iQ.Justify]:"start"},fD1={[qK.Small]:"s",[qK.Medium]:"l",[qK.Large]:"xl"},gD1={[qK.Small]:"m",[qK.Medium]:"l",[qK.Large]:"xl"},hD1={[g_.Solid]:"solid",[g_.Dashed]:"dashed",[g_.Dotted]:"dotted",[g_.Draw]:"draw"};var HO0=w.object({schemaVersion:w.literal(1),storeVersion:w.positiveInteger,recordVersions:w.dict(w.string,w.object({version:w.positiveInteger,subTypeVersions:w.dict(w.string,w.positiveInteger).optional(),subTypeKey:w.string.optional()}))}),$O0=w.object({schemaVersion:w.literal(2),sequences:w.dict(w.string,w.positiveInteger)}),lD1=w.object({tldrawFileFormatVersion:w.nonZeroInteger,schema:w.numberUnion("schemaVersion",{1:HO0,2:$O0}),records:w.arrayOf(w.object({id:w.string,typeName:w.string}).allowUnknownProperties())});x5("tldraw","5.2.3","esm");var _O0=s10()(r10((J)=>({sessions:{},setSession:(Q,Z)=>J((q)=>({sessions:{...q.sessions,[Q]:Z}})),removeSession:(Q)=>J((Z)=>{let q={...Z.sessions};return delete q[Q],{sessions:q}})}),{name:"moi:scratch-sessions"})),FO0=500;function a10(J,Q){let{sessions:Z,setSession:q,removeSession:X}=_O0.getState(),K=Z[Q];if(K)try{jZ(J.store,K)}catch{X(Q)}let Y=MZ(J.store),W=null,z=P1("save scratch session",()=>{let G=Y.get();if(!G)return;if(W)clearTimeout(W);W=setTimeout(()=>q(Q,G),FO0)});return()=>{if(z(),W)clearTimeout(W)}}var sW=E(m(),1);function UO0(J){if(!J||typeof J!=="object")return null;let Q=J.sequences;if(!Q||typeof Q!=="object")return null;let Z={};for(let[q,X]of Object.entries(Q))if(typeof X==="number")Z[q]=X;return Object.keys(Z).length>0?Z:null}function o10(J,Q){let Z=UO0(J);if(!Z)return[];let q=[];for(let[X,K]of Object.entries(Z)){let Y=Q[X];if(Y===void 0)q.push({id:X,fileVersion:K});else if(K>Y)q.push({id:X,fileVersion:K,runtimeVersion:Y})}return q}function t10(J,Q){if(J)return`moi ${J.moi}, tldraw ${J.tldraw}`;return Q.map((Z)=>Z.runtimeVersion===void 0?`${Z.id} v${Z.fileVersion} (unknown here)`:`${Z.id} v${Z.fileVersion} > v${Z.runtimeVersion}`).join(", ")}var U9=E(c(),1),e10=null;function VO0(){return e10??=w2({shapeUtils:eX,bindingUtils:sX}).schema,e10}function Ly(J,Q){let Z=VO0();try{if(Z.migrateStoreSnapshot(J).type==="success")return null}catch{}let q=o10(J.schema,Z.serialize().sequences);if(q.length>0)return{newer:!0,writer:Q,detail:t10(Q,q)};return{newer:!1,writer:Q,detail:"The saved snapshot failed to load."}}function Q40(J){let[Q,Z]=sW.useState(null);sW.useEffect(()=>{let X=!1;return fetch(`/api/workspaces/${J}/scratchpad`).then((K)=>K.json()).then((K)=>{if(X)return;let Y,W=null;if(K?.document){if(W=Ly(K.document,K.writer),!W)Y=K.document}Z({snapshot:Y,skew:W})}).catch(()=>{if(!X)Z({skew:null})}),()=>{X=!0}},[J]);let q=sW.useCallback((X)=>{Z((K)=>({snapshot:K?.snapshot,skew:X}))},[]);return{loaded:Q!==null,snapshot:Q?.snapshot,skew:Q?.skew??null,flagSkew:q}}function Z40({skew:J}){return U9.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center bg-muted/40 bg-[radial-gradient(var(--color-border)_1px,transparent_1px)] [background-size:16px_16px] p-6",children:U9.jsxs("div",{className:"flex max-w-md animate-in flex-col gap-3 rounded-lg bg-background p-6 shadow-xs duration-200 fade-in-0 zoom-in-95",children:[U9.jsxs("div",{className:"flex items-center gap-2",children:[U9.jsx(J40,{size:20,stroke:1.5,className:"shrink-0 text-amber-600"}),U9.jsx("h2",{className:"font-medium text-foreground",children:J.newer?"This canvas needs a newer moi":"This canvas couldn’t be loaded"})]}),J.newer?U9.jsxs(U9.Fragment,{children:[U9.jsxs("p",{className:"text-sm text-pretty text-muted-foreground",children:["This scratchpad was saved by a newer version of moi",J.writer?` (v${J.writer.moi})`:"",".",U9.jsx("br",{})," Please update moi and restart the server:"]}),U9.jsx("code",{className:"self-start rounded bg-muted px-2 py-1 font-mono text-xs text-foreground",children:"bun install -g moi-computer@latest"})]}):U9.jsx("p",{className:"text-sm text-muted-foreground",children:J.detail})]})})}var fq=E(m(),1);var u4=E(c(),1),NO0=[{kind:"tool",id:"select",label:"Select",Icon:U40},{kind:"tool",id:"hand",label:"Hand",Icon:H40},{kind:"sep"},{kind:"tool",id:"draw",label:"Pencil",Icon:F40},{kind:"geo",label:"Rectangle",Icon:N40},{kind:"tool",id:"note",label:"Sticker",Icon:B40},{kind:"tool",id:"text",label:"Text",Icon:Dy},{kind:"tool",id:"line",label:"Line",Icon:_40},{kind:"tool",id:"arrow",label:"Arrow",Icon:z40},{kind:"sep"},{kind:"tool",id:"highlight",label:"Highlighter",Icon:$40},{kind:"tool",id:"eraser",label:"Eraser",Icon:G40}];function Oy({label:J,active:Q,Icon:Z,onClick:q}){return u4.jsx(W40,{type:"button",size:"icon",variant:Q?"default":"ghost","aria-label":J,title:J,onClick:q,className:nQ(!Q&&"text-muted-foreground hover:text-foreground"),children:u4.jsx(Z,{stroke:1.5})})}function q40(J,Q){if(Q==="geo")J.setStyleForNextShapes(T6,"draw"),J.setStyleForNextShapes(e4,"m");else if(Q==="note")J.setStyleForNextShapes(I4,"draw"),J.setStyleForNextShapes(A9,"middle"),J.setStyleForNextShapes(C9,"middle"),K40(J,"sticker","yellow");else if(Q==="text")J.setStyleForNextShapes(I4,"draw"),J.setStyleForNextShapes(A9,"middle"),J.setStyleForNextShapes(C9,"middle");else if(Q==="highlight")K40(J,"highlight","yellow");else if(Q==="arrow")J.setStyleForNextShapes(T6,"draw");else if(Q==="draw"||Q==="line"){let Z=J.getStyleForNextShape(T6);if(Z!=="draw"&&Z!=="dashed")J.setStyleForNextShapes(T6,"draw")}}var X40="[&_.tl-canvas]:cursor-pencil";function O40({editor:J}){let[Q,Z]=fq.useState(()=>J.getCurrentToolId());fq.useEffect(()=>{let K=J.getContainer(),Y=()=>{let z=J.getCurrentToolId();Z(z),K.classList.toggle(X40,z==="draw")};Y();let W=P1("scratch current tool",Y);return()=>{W(),K.classList.remove(X40)}},[J]);let q=(K)=>{J.run(()=>{q40(J,K),J.setCurrentTool(K)})},X=()=>{J.run(()=>{J.setStyleForNextShapes(x6,"rectangle"),q40(J,"geo"),J.setCurrentTool("geo")})};return u4.jsx("div",{className:"absolute top-1/2 left-2 -translate-y-1/2",children:u4.jsx(L40.div,{initial:{x:-72,opacity:0},animate:{x:0,opacity:1},transition:{type:"spring",bounce:0.2,duration:0.55},className:"flex flex-col gap-1 rounded-xl bg-background/95 p-1 shadow-md backdrop-blur",children:NO0.map((K,Y)=>{if(K.kind==="sep")return u4.jsx("div",{className:"mx-1 my-0.5 h-px bg-border"},`sep-${Y}`);if(K.kind==="geo")return u4.jsx(Oy,{label:K.label,Icon:K.Icon,active:Q==="geo",onClick:X},"geo");if(K.kind==="menu")return u4.jsx(Oy,{label:K.label,Icon:K.Icon,active:!1,onClick:()=>{}},"menu");return u4.jsx(Oy,{label:K.label,Icon:K.Icon,active:Q===K.id,onClick:()=>q(K.id)},K.id)})})})}var BO0=["color","size","dash","fill"],D40={draw:["color","size","dash"],geo:["color","fill"],note:["color","size"],text:["color","size"],line:["color","dash","size"],highlight:["color","size"],arrow:["color","size"]},LO0={draw:["color","size","dash"],geo:["color","fill"],note:["color","size"],text:["color","size"],line:["color","dash","size"],highlight:["color","size"],arrow:["color","size"]},M40={regular:{swatches:[{value:"black",klass:"bg-[#1d1d1d]"},{value:"red",klass:"bg-[#e03131]"},{value:"yellow",klass:"bg-[#f1ac4b]"},{value:"green",klass:"bg-[#099268]"},{value:"blue",klass:"bg-[#4465e9]"},{value:"grey",klass:"bg-[#9fa8b2]"}]},highlight:{swatches:[{value:"yellow",klass:"bg-[#fddd00]"},{value:"green",klass:"bg-[#00ffc8]"},{value:"blue",klass:"bg-[#10acff]"}]},sticker:{swatches:[{value:"yellow",klass:"bg-[#fed49a]"},{value:"blue",klass:"bg-[#8aa3ff]"},{value:"green",klass:"bg-[#6fc896]"}]}};function OO0(J){let Q=J.getCurrentToolId();if(Q==="highlight")return"highlight";if(Q==="note")return"sticker";if(D40[Q])return"regular";let Z=new Set(J.getSelectedShapeIds().map((q)=>J.getShape(q)?.type));if(Z.size===1){if(Z.has("highlight"))return"highlight";if(Z.has("note"))return"sticker"}return"regular"}function K40(J,Q,Z){if(!M40[Q].swatches.map((X)=>X.value).includes(J.getStyleForNextShape(_1)))J.setStyleForNextShapes(_1,Z)}var DO0=[{value:"m",label:"Small",dot:"size-1.5",glyph:16},{value:"xl",label:"Large",dot:"size-3",glyph:24}],MO0=[{value:"draw",label:"Rough",preview:"border-b-2 border-current"},{value:"dashed",label:"Dash",preview:"border-b-2 border-dashed border-current"}],jO0=[{value:"none",label:"None",preview:"border border-foreground/50"},{value:"solid",label:"Semi",preview:"border border-foreground/40 bg-foreground/25"},{value:"fill",label:"Solid",preview:"border border-foreground bg-foreground"},{value:"pattern",label:"Pattern",preview:"border border-foreground/40 bg-[repeating-linear-gradient(45deg,currentColor_0,currentColor_1px,transparent_1px,transparent_3px)]"}];function AD(J,Q){if(J.getSelectedShapeIds().length>0)return J.getSharedStyles().getAsKnownValue(Q);return J.getStyleForNextShape(Q)}function CD(J,Q,Z){J.run(()=>{if(J.setStyleForNextShapes(Q,Z),J.getSelectedShapeIds().length>0)J.setStyleForSelectedShapes(Q,Z)})}function RO0(J){let Q=D40[J.getCurrentToolId()];if(Q)return Q;let Z=J.getSelectedShapeIds();if(Z.length===0)return[];let q=new Set;for(let X of Z){let K=J.getShape(X);if(!K)continue;for(let Y of LO0[K.type]??[])q.add(Y)}return BO0.filter((X)=>q.has(X))}function kO0(J){let Q=J.getCurrentToolId();if(Q==="draw")return"pen";if(Q==="text")return"letter";let Z=J.getSelectedShapeIds(),q=new Set(Z.map((X)=>J.getShape(X)?.type));if(q.size===1){if(q.has("draw"))return"pen";if(q.has("text"))return"letter"}return"dot"}function Y40(J){return{controls:RO0(J),palette:M40[OO0(J)],color:AD(J,_1),size:AD(J,e4),sizeGlyph:kO0(J),dash:AD(J,T6),fill:AD(J,y6)}}function j40({editor:J}){let[Q,Z]=fq.useState(()=>Y40(J));if(fq.useEffect(()=>{return P1("scratch styles",()=>Z(Y40(J)))},[J]),Q.controls.length===0)return null;let q={color:u4.jsx("div",{className:"flex flex-col items-center gap-2 pt-1",children:Q.palette.swatches.map((X)=>u4.jsx("button",{type:"button",title:X.value,onClick:()=>CD(J,_1,X.value),className:nQ("size-5.5 rounded-full ring-offset-1 ring-offset-background",X.klass,Q.color===X.value?"ring-2 ring-primary":"ring-1 ring-black/15")},X.value))}),size:u4.jsx("div",{className:"flex flex-col items-center gap-1 text-foreground",children:DO0.map((X)=>u4.jsx("button",{type:"button",title:X.label,onClick:()=>CD(J,e4,X.value),className:nQ("flex size-7.5 items-center justify-center rounded-full hover:bg-accent hover:text-accent-foreground",Q.size===X.value&&"bg-accent text-accent-foreground"),children:Q.sizeGlyph==="pen"?u4.jsx(V40,{size:20,stroke:X.value==="m"?1.25:2}):Q.sizeGlyph==="letter"?u4.jsx(Dy,{size:X.glyph,stroke:X.glyph===16?1.75:1.5}):u4.jsx("span",{className:nQ("rounded-full bg-current",X.dot)})},X.value))}),dash:u4.jsx("div",{className:"flex flex-col items-center gap-1 text-foreground",children:MO0.map((X)=>u4.jsx("button",{type:"button",title:X.label,onClick:()=>CD(J,T6,X.value),className:nQ("flex size-7.5 items-center justify-center rounded-full hover:bg-accent hover:text-accent-foreground",Q.dash===X.value&&"bg-accent text-accent-foreground"),children:u4.jsx("span",{className:nQ("w-3.5",X.preview)})},X.value))}),fill:u4.jsx("div",{className:"flex flex-col items-center gap-1 text-foreground",children:jO0.map((X)=>u4.jsx("button",{type:"button",title:X.label,onClick:()=>CD(J,y6,X.value),className:nQ("flex size-7.5 items-center justify-center rounded-full hover:bg-accent hover:text-accent-foreground",Q.fill===X.value&&"bg-accent text-accent-foreground"),children:u4.jsx("span",{className:nQ("size-4.5 rounded-lg",X.preview)})},X.value))})};return u4.jsx("div",{className:"absolute top-1/2 left-14 flex -translate-y-1/2 flex-col items-center gap-1.5 rounded-full bg-background/95 px-1 py-1 shadow-[0_2px_8px_rgba(0,0,0,0.08),0_4px_16px_rgba(0,0,0,0.06),0_0_0_1px_rgba(0,0,0,0.04)] backdrop-blur",children:Q.controls.map((X,K)=>u4.jsxs(fq.Fragment,{children:[K>0&&u4.jsx("div",{className:"h-px w-5 bg-border"}),q[X]]},X))})}var O8=E(c(),1),R40=Math.random().toString(36).slice(2),EO0=500,AO0="tldraw-2026-09-27/WyJlaDdIczMxRSIsWyIqIl0sMTYsIjIwMjYtMDktMjciXQ.6OucDghQHnAFl2Ceg8qf48M2oIis6qHdZfqFsKdBZwd610QixrvG1jUnwCbI1Xs2BoXzptPs+pQYF25NyShFbw";function CO0(J){return async(Q)=>{if(Q.kind!=="view")throw Error(`Scratchpad op "${Q.kind}" runs on the server, not the browser.`);let Z=[...J.getCurrentPageShapeIds()];if(Z.length===0)throw Error("Canvas is empty — nothing to view.");let{url:q}=await J.toImageDataUrl(Z,{format:"png",background:!0,padding:32});return{image:q}}}function PO0(J){let Q=`/api/workspaces/${J}/scratchpad/assets`;return{async upload(Z,q){let X=await fetch(Q,{method:"POST",headers:{"Content-Type":q.type||"application/octet-stream"},body:q});if(!X.ok)throw Error(`Upload failed: ${await X.text()}`);let{src:K}=await X.json();return{src:K}},resolve(Z){let q=Z.props.src;if(q?.startsWith("asset:"))return`${Q}/${q.slice(6)}`;return q}}}function IO0(){return O8.jsx("div",{className:"absolute inset-0 bg-background"})}function wO0({x:J,y:Q,z:Z,size:q}){let X=M5("scratch-grid"),K=v(),Y=K.options.gridSteps[0]?.step??1;for(let _ of K.options.gridSteps)if(Z>=_.min)Y=_.step;let W=Y*q*Z,z=0.5+J*Z,G=0.5+Q*Z,$=z>0?z%W:W+z%W,H=G>0?G%W:W+G%W;return O8.jsxs("svg",{className:"tl-grid",version:"1.1",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[O8.jsx("defs",{children:O8.jsx("pattern",{id:X,width:W,height:W,patternUnits:"userSpaceOnUse",children:O8.jsx("circle",{className:"fill-accent",cx:$,cy:H,r:1})})}),O8.jsx("rect",{width:"100%",height:"100%",fill:`url(#${X})`})]})}var bO0={Background:IO0,Grid:wO0,Toolbar:null,StylePanel:null,Minimap:null,MainMenu:null,PageMenu:null,ActionsMenu:null,QuickActions:null,HelpMenu:null,DebugMenu:null,ZoomMenu:null},TO0={tools(J,Q){return delete Q.frame,delete Q.laser,Q},actions(J,Q){for(let Z of["export-as-svg","export-as-png","copy-as-svg","copy-as-png","print"])delete Q[Z];return Q}},yO0={maxPages:1},xO0=33554432,vO0=2048;function yE1(){let J=k40();return O8.jsx(SO0,{workspaceId:J},J)}function SO0({workspaceId:J}){let Q=O2.useRef(null),Z=O2.useRef(null),q=O2.useRef(null),X=O2.useRef(!1),[K,Y]=O2.useState(null),{loaded:W,snapshot:z,skew:G,flagSkew:$}=Q40(J),[H]=O2.useState(()=>PO0(J)),_=O2.useCallback(()=>{let U=Q.current;if(!U)return;let V;try{V=uG(U.store).document}catch{return}fetch(`/api/workspaces/${J}/scratchpad`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({document:V,origin:R40})}).catch(()=>{})},[J]);E40((U)=>{if(U.type!=="scratchpad:updated"||U.workspaceId!==J)return;if(U.origin&&U.origin===R40)return;if(!Q.current)return;fetch(`/api/workspaces/${J}/scratchpad`).then((V)=>V.json()).then((V)=>{let B=Q.current;if(!B||!V?.document)return;let N=Ly(V.document,V.writer);if(N){if(q.current)clearTimeout(q.current);$(N);return}X.current=!0,R3(B.store,{document:V.document})}).catch(()=>{})});let F=O2.useCallback((U)=>{Q.current=U,Y(U),U.updateInstanceState({isGridMode:!0}),U.run(()=>{U.setStyleForNextShapes(I4,"draw"),U.setStyleForNextShapes(A9,"middle"),U.setStyleForNextShapes(C9,"middle"),U.setStyleForNextShapes(y6,"fill")});let V=a10(U,J),B=U.store.listen(()=>{if(X.current){X.current=!1;return}if(q.current)clearTimeout(q.current);q.current=setTimeout(_,EO0)},{source:"user",scope:"document"});My(J,CO0(U));let N=(D)=>{let O=D.target;if(!!O&&!!Z.current?.contains(O)){if(!U.getIsFocused())U.focus()}else if(U.getIsFocused())U.blur()},L=U.getContainer().ownerDocument;return L.addEventListener("pointerdown",N,!0),U.focus(),()=>{if(B(),V(),L.removeEventListener("pointerdown",N,!0),q.current)clearTimeout(q.current);My(J,null),Y(null),Q.current=null}},[J,_]);if(!W)return O8.jsx("div",{className:"min-h-0 flex-1 bg-muted/40"});if(G)return O8.jsx(Z40,{skew:G});return O8.jsxs("div",{ref:Z,className:"relative min-h-0 flex-1 overflow-hidden",children:[O8.jsx("div",{className:"absolute inset-0",children:O8.jsx(Vy,{snapshot:z,assets:H,licenseKey:AO0,onMount:F,components:bO0,overrides:TO0,options:yO0,maxAssetSize:xO0,maxImageDimension:vO0,autoFocus:!1})}),K&&O8.jsx(O40,{editor:K}),K&&O8.jsx(j40,{editor:K})]})}export{yE1 as Scratchpad};
546
+ `).map((y,S)=>ZK.jsx("div",{dir:"auto",children:y},S))}),(k||H)&&ZK.jsx(Hy,{ref:D,text:q,isEditing:j,shapeId:Q,...R,handleKeyDown:F??R.handleKeyDown})]})})});var F9=E(c(),1);var L2=E(m(),1);var u10=E(m(),1);var h10=E(m(),1),v_={fonts:{tldraw_mono:`${Q6()}/fonts/IBMPlexMono-Medium.woff2`,tldraw_mono_italic:`${Q6()}/fonts/IBMPlexMono-MediumItalic.woff2`,tldraw_mono_bold:`${Q6()}/fonts/IBMPlexMono-Bold.woff2`,tldraw_mono_italic_bold:`${Q6()}/fonts/IBMPlexMono-BoldItalic.woff2`,tldraw_serif:`${Q6()}/fonts/IBMPlexSerif-Medium.woff2`,tldraw_serif_italic:`${Q6()}/fonts/IBMPlexSerif-MediumItalic.woff2`,tldraw_serif_bold:`${Q6()}/fonts/IBMPlexSerif-Bold.woff2`,tldraw_serif_italic_bold:`${Q6()}/fonts/IBMPlexSerif-BoldItalic.woff2`,tldraw_sans:`${Q6()}/fonts/IBMPlexSans-Medium.woff2`,tldraw_sans_italic:`${Q6()}/fonts/IBMPlexSans-MediumItalic.woff2`,tldraw_sans_bold:`${Q6()}/fonts/IBMPlexSans-Bold.woff2`,tldraw_sans_italic_bold:`${Q6()}/fonts/IBMPlexSans-BoldItalic.woff2`,tldraw_draw:`${Q6()}/fonts/Shantell_Sans-Informal_Regular.woff2`,tldraw_draw_italic:`${Q6()}/fonts/Shantell_Sans-Informal_Regular_Italic.woff2`,tldraw_draw_bold:`${Q6()}/fonts/Shantell_Sans-Informal_Bold.woff2`,tldraw_draw_italic_bold:`${Q6()}/fonts/Shantell_Sans-Informal_Bold_Italic.woff2`}};function jD(J){return h10.useMemo(()=>{if(!J)return v_;return{fonts:{...v_.fonts,...J?.fonts}}},[J])}var $y=["align-bottom","align-center-horizontal","align-center-vertical","align-left","align-right","align-top","alt","arrow-arc","arrow-cycle","arrow-elbow","arrow-left","arrowhead-arrow","arrowhead-bar","arrowhead-diamond","arrowhead-dot","arrowhead-none","arrowhead-square","arrowhead-triangle-inverted","arrowhead-triangle","blob","bold","bookmark","bring-forward","bring-to-front","broken","bulletList","check-circle","check","chevron-down","chevron-left","chevron-right","chevron-up","chevrons-ne","chevrons-sw","clipboard-copied","clipboard-copy","code","color","comment","corners","crop","cross-2","cross-circle","dash-dashed","dash-dotted","dash-draw","dash-solid","disconnected","discord","distribute-horizontal","distribute-vertical","dot","dots-horizontal","dots-vertical","download","drag-handle-dots","duplicate","edit","external-link","fill-fill","fill-lined-fill","fill-none","fill-pattern","fill-semi","fill-solid","follow","following","font-draw","font-mono","font-sans","font-serif","geo-arrow-down","geo-arrow-left","geo-arrow-right","geo-arrow-up","geo-check-box","geo-cloud","geo-diamond","geo-ellipse","geo-heart","geo-hexagon","geo-octagon","geo-oval","geo-pentagon","geo-rectangle","geo-rhombus-2","geo-rhombus","geo-star","geo-trapezoid","geo-triangle","geo-x-box","github","group","heading","help-circle","highlight","horizontal-align-end","horizontal-align-middle","horizontal-align-start","info-circle","italic","leading","link","list","lock","manual","menu","minus","mixed","pack","plus","question-mark-circle","question-mark","redo","reset-zoom","rotate-ccw","rotate-cw","send-backward","send-to-back","share-1","size-extra-large","size-large","size-medium","size-small","spline-cubic","spline-line","stack-horizontal","stack-vertical","status-offline","stretch-horizontal","stretch-vertical","strike","text-align-center","text-align-left","text-align-right","toggle-off","toggle-on","tool-arrow","tool-eraser","tool-frame","tool-hand","tool-highlight","tool-laser","tool-line","tool-media","tool-note","tool-pencil","tool-pointer","tool-screenshot","tool-text","trash","twitter","underline","undo","ungroup","unlock","vertical-align-end","vertical-align-middle","vertical-align-start","warning-triangle","zoom-in","zoom-out"];var S_={...v_,icons:Object.fromEntries($y.map((J)=>[J,`${Q6()}/icons/icon/0_merged.svg#${J}`])),translations:Object.fromEntries(C2.map((J)=>[J.locale,`${Q6()}/translations/${J.locale}.json`])),embedIcons:Object.fromEntries(zW.map((J)=>[J.type,`${Q6()}/embed-icons/${J.type}.png`]))};function RD(J){return u10.useMemo(()=>{if(!J)return S_;return{fonts:Object.assign({...S_.fonts},{...J?.fonts}),icons:Object.assign({...S_.icons},{...J?.icons}),embedIcons:Object.assign({...S_.embedIcons},{...J?.embedIcons}),translations:Object.assign({...S_.translations},{...J?.translations})}},[J])}var _y=E(c(),1);function m10(){let{Spinner:J}=T4();return _y.jsx(tR,{children:J?_y.jsx(J,{}):null})}var U1=E(c(),1);var p10=E(c1(),1),d9=E(m(),1);var _9=E(c(),1);var Fy=p1(function({overrides:Q,components:Z,assetUrls:q,onUiEvent:X,forceMobile:K,mediaMimeTypes:Y,children:W}){let z=J1();return _9.jsx(cI.Provider,{value:Y,children:_9.jsx(hH,{assetUrls:RD(q),children:_9.jsx(mH,{overrides:BL(Q),locale:z?.user.getLocale()??v6.locale,children:_9.jsx(zI,{children:_9.jsx(VI,{onEvent:X,children:_9.jsx(bI,{children:_9.jsx(II,{context:"tla",children:_9.jsx(AE,{children:_9.jsx(_I,{forceMobile:K,children:_9.jsx(jb,{overrides:Z,children:_9.jsx(eL0,{overrides:Q,children:W})})})})})})})})})})})});function eL0({overrides:J,children:Q}){let Z=Ro(J);return _9.jsx(ee,{overrides:Z.actions,children:_9.jsx(Ao,{overrides:Z.tools,children:Q})})}var c10=E(m(),1);function l10(){let J=v(),{addToast:Q}=P5();c10.useEffect(()=>{function Z({name:q,count:X}){Q({title:"Maximum shapes reached",description:`You've reached the maximum number of shapes allowed on ${q} (${X}). Please delete some shapes or move to a different page to continue.`,severity:"warning"})}return J.addListener("max-shapes",Z),()=>{J.removeListener("max-shapes",Z)}},[J,Q])}var Uy=d9.default.memo(function({renderDebugMenuItems:Q,children:Z,hideUi:q,components:X,...K}){return U1.jsx(Fy,{...K,components:X,children:U1.jsx(JO0,{hideUi:q,renderDebugMenuItems:Q,children:Z})})}),JO0=d9.default.memo(function({children:Q,hideUi:Z,...q}){return Fb(),gI(),U1.jsxs(U1.Fragment,{children:[Q,Z?null:U1.jsx(QO0,{...q})]})}),QO0=d9.default.memo(function(){let Q=v(),Z=t(),q=A1(),X=I6(),K=g("focus",()=>Q.getInstanceState().isFocusMode,[Q]),Y=g("debug",()=>Q.getInstanceState().isDebugMode,[Q]),W=Q1(),z=t0(),G=g("locale",()=>Q.user.getLocale(),[Q]);d9.useEffect(()=>{W.dir=z,W.lang=G},[W,z,G]);let{SharePanel:$,TopPanel:H,MenuPanel:_,StylePanel:F,Toolbar:U,HelpMenu:V,NavigationPanel:B,HelperButtons:N,DebugPanel:L,Toasts:D,Dialogs:O,A11y:j,FollowingIndicator:k}=N4();l10();let R=d9.useRef(!1),P=d9.useRef(-1),[A,I]=d9.useState(!1);EJ("update hide toolbar while delayed",()=>{if(!(S0.isIos||S0.isAndroid))return;if(Q.getEditingShapeId()===null){if(R.current)if(R.current=!1,clearTimeout(P.current),S0.isAndroid)P.current=Q.timers.setTimeout(()=>{I(!1)},150);else I(!1);return}if(!R.current)R.current=!0,clearTimeout(P.current),I(!0)},[]);let{"toggle-focus-mode":C}=f6(),{breakpointsAbove:y,breakpointsBelow:S}=d9.useMemo(()=>{let T=[],h=[];for(let b=0;b<HW.length;b++)if(b<=q)T.push(b);else h.push(b);return{breakpointsAbove:T,breakpointsBelow:h}},[q]);return U1.jsxs("div",{className:p10.default("tlui-layout",{"tlui-layout__mobile":q<e0.TABLET_SM}),role:"document","data-iseditinganything":A,"data-breakpoint":q,"data-breakpoints-above":y.join(" "),"data-breakpoints-below":S.join(" "),children:[U1.jsx(Z00,{}),K?U1.jsx("div",{className:"tlui-layout__top",children:U1.jsx(w0,{type:"icon",className:"tlui-focus-button",title:Z("focus-mode.toggle-focus-mode"),onClick:()=>C.onSelect("menu"),children:U1.jsx(z0,{icon:"dot"})})}):U1.jsxs(U1.Fragment,{children:[U1.jsxs("div",{className:"tlui-layout__top",children:[U1.jsxs("div",{className:"tlui-layout__top__left",children:[_&&U1.jsx(_,{}),N&&U1.jsx(N,{})]}),U1.jsx("div",{className:"tlui-layout__top__center",children:H&&U1.jsx(H,{})}),U1.jsxs("div",{className:"tlui-layout__top__right",children:[$&&U1.jsx($,{}),F&&q>=e0.TABLET_SM&&!X&&U1.jsx(F,{})]})]}),U1.jsxs("div",{className:"tlui-layout__bottom",children:[U1.jsxs("div",{className:"tlui-layout__bottom__main",children:[B&&U1.jsx(B,{}),U&&U1.jsx(U,{}),V&&U1.jsx(V,{})]}),Y&&L&&U1.jsx(L,{}),j&&U1.jsx(j,{})]})]}),k&&U1.jsx(k,{}),D&&U1.jsx(D,{}),O&&U1.jsx(O,{})]})});function kD(){let{RichTextToolbar:J,ImageToolbar:Q,VideoToolbar:Z,CursorChatBubble:q}=N4();return U1.jsxs(U1.Fragment,{children:[J&&U1.jsx(J,{}),Q&&U1.jsx(Q,{}),Z&&U1.jsx(Z,{}),q&&U1.jsx(q,{})]})}var ZO0=[...Gy,...JT];function qO0(J,Q){let{maxImageDimension:Z,acceptedImageMimeTypes:q,acceptedVideoMimeTypes:X}=Q,K=Z!==void 0||q!==void 0,Y=X!==void 0;if(!K&&!Y)return J;return J.map((W)=>{if(K&&W.type==="image")return W.configure({...Z!==void 0&&{maxDimension:Z},...q!==void 0&&{supportedMimeTypes:q}});if(Y&&W.type==="video")return W.configure({...X!==void 0&&{supportedMimeTypes:X}});return W})}function Vy(J){let{children:Q,maxImageDimension:Z,maxAssetSize:q,acceptedImageMimeTypes:X,acceptedVideoMimeTypes:K,onMount:Y,components:W={},shapeUtils:z=[],bindingUtils:G=[],assetUtils:$=[],overlayUtils:H=[],tools:_=[],embeds:F,options:U,locale:V,textOptions:B,...N}=J,L=b9(W),D=W?.InFrontOfTheCanvas,O=L2.useMemo(()=>{if(N.hideUi)return D??null;if(!D)return kD;return()=>F9.jsxs(F9.Fragment,{children:[F9.jsx(kD,{}),F9.jsx(D,{})]})},[N.hideUi,D]),j=L2.useMemo(()=>({Spinner:w$,LoadingScreen:m10,...L,InFrontOfTheCanvas:O}),[L,O]),k=l8(z),R=L2.useMemo(()=>M2("type",k,eX),[k]),P=l8(G),A=L2.useMemo(()=>M2("type",P,sX),[P]),I=l8($),C=L2.useMemo(()=>qO0(M2("type",I,hb),{maxImageDimension:Z,acceptedImageMimeTypes:X,acceptedVideoMimeTypes:K}),[I,Z,X,K]),y=l8(H),S=L2.useMemo(()=>M2("type",y,ub),[y]),T=l8(_),h=L2.useMemo(()=>M2("id",T,ZO0),[T]),b=l8(X??aq),x=l8(K??UK),f=U?.text??B,u=L2.useMemo(()=>{return{addFontsFromNode:K$,...f,tipTapConfig:{extensions:dZ,...f?.tipTapConfig}}},[f]),p=L2.useMemo(()=>({...U,text:u}),[U,u]),o=L2.useMemo(()=>[...b,...x],[b,x]),K0=jD(N.assetUrls);if(R.find((y0)=>y0.type==="embed")&&F)vq.setEmbedDefinitions(F);return F9.jsx(hH,{assetUrls:RD(N.assetUrls),children:F9.jsx(mH,{overrides:BL(N.overrides),locale:V??N.user?.userPreferences.get().locale??v6.locale,children:F9.jsx(oR,{initialState:"select",...N,components:j,shapeUtils:R,bindingUtils:A,assetUtils:C,overlayUtils:S,tools:h,options:p,assetUrls:K0,children:F9.jsxs(Uy,{...N,components:j,mediaMimeTypes:o,children:[F9.jsx(XO0,{maxImageDimension:Z,maxAssetSize:q,acceptedImageMimeTypes:b,acceptedVideoMimeTypes:x,onMount:Y}),Q]})})})})}function XO0({maxImageDimension:J,maxAssetSize:Q,acceptedImageMimeTypes:Z,acceptedVideoMimeTypes:q,onMount:X}){let K=v(),Y=P5(),W=t(),z=o0();cU(()=>{let H=[];H.push(wT(K)),K.fonts.requestFonts(CA);let _=K.getThemes();for(let F of Object.values(_))for(let U of Object.keys(F.fonts)){let V=F.fonts[U];if(V.faces?.length)K.fonts.requestFonts(V.faces)}return K.once("edit",()=>z("edit",{source:"unknown"})),bA(K,{maxImageDimension:J,maxAssetSize:Q,acceptedImageMimeTypes:Z,acceptedVideoMimeTypes:q,toasts:Y,msg:W}),H.push(K.store.props.onMount(K)),H.push(X?.(K)),()=>{H.forEach((F)=>F?.())}});let{Canvas:G}=T4(),{ContextMenu:$}=N4();if($)return F9.jsx($,{});if(G)return F9.jsx(G,{});return null}var Ny=E(c(),1);var i9=E(m(),1);var d10={text:{tipTapConfig:{extensions:dZ},addFontsFromNode:K$}},KO0=i9.memo(function(Q){let[Z,q]=i9.useState(null),[X,K]=i9.useState(null),Y=l8(Q.shapeUtils??[]),W=i9.useMemo(()=>M2("type",Y,eX),[Y]),z=l8(Q.bindingUtils??[]),G=i9.useMemo(()=>M2("type",z,sX),[z]),$=rR({snapshot:Q.snapshot,shapeUtils:W}),{pageId:H,bounds:_,scale:F,pixelRatio:U,background:V,padding:B,darkMode:N,preserveAspectRatio:L,format:D="svg",licenseKey:O,assetUrls:j,options:k,textOptions:R}=Q,P=i9.useMemo(()=>({...d10,...k,text:{...d10.text,...k?.text??R}}),[k,R]),A=jD(j);return i9.useLayoutEffect(()=>{if(!X)return;if(!$)return;let I=!1,C=X.ownerDocument.createElement("div");X.appendChild(C),X.classList.add("tl-container","tl-theme__light");let y=new G0({store:$,shapeUtils:W,bindingUtils:G,tools:[],getContainer:()=>C,licenseKey:O,fontAssetUrls:A.fonts,options:P});if(H)y.setCurrentPage(H);let S=y.getCurrentPageShapeIds();async function T(){let h=await y.toImage([...S],{bounds:_,scale:F,background:V,padding:B,darkMode:N,preserveAspectRatio:L,format:D});if(!h||I)return;let b=URL.createObjectURL(h.blob);q(b),y.dispose()}return T(),()=>{I=!0}},[D,X,$,W,G,H,_,F,V,B,N,L,O,U,A,P]),i9.useEffect(()=>{return()=>{if(Z)URL.revokeObjectURL(Z)}},[Z]),Ny.jsx("div",{ref:K,style:{position:"relative",width:"100%",height:"100%"},children:Z&&Ny.jsx("img",{src:Z,referrerPolicy:"strict-origin-when-cross-origin",style:{width:"100%",height:"100%"}})})});var NJ=E(c(),1);var ED=E(m(),1);var YO0=ED.memo(function({children:Q}){let Z=t(),q=A1(),X=ED.useRef(null);r6(X);let K=Q??NJ.jsx(Pw,{});if(q<e0.MOBILE)return null;return NJ.jsx("div",{ref:X,className:"tlui-help-menu",children:NJ.jsxs(LQ,{id:"help menu",children:[NJ.jsx(OQ,{children:NJ.jsx(w0,{type:"help",title:Z("help-menu.title"),"data-testid":"help-menu.button",children:NJ.jsx(z0,{icon:"question-mark",small:!0})})}),NJ.jsx(DQ,{side:"top",align:"end",alignOffset:0,sideOffset:8,children:NJ.jsx(z4,{type:"menu",sourceId:"help-menu",children:K})})]})})});var f_=E(c(),1);var i10=E(c1(),1);var n10=E(m(),1);var WO0=n10.forwardRef(function({children:Q,className:Z},q){return f_.jsxs(k$.Trigger,{ref:q,className:i10.default("tlui-button tlui-select__trigger",Z),children:[Q,f_.jsx(k$.Icon,{className:"tlui-select__chevron",children:f_.jsx(S6,{icon:"chevron-down",label:"",small:!0})})]})});var zO0=E(c(),1),By=E(m(),1);var n9={White:"white",LightGray:"lightGray",Gray:"gray",Black:"black",Green:"green",Cyan:"cyan",Blue:"blue",Indigo:"indigo",Violet:"violet",Red:"red",Orange:"orange",Yellow:"yellow"},qK={Small:"small",Medium:"medium",Large:"large"},g_={Draw:"draw",Solid:"solid",Dashed:"dashed",Dotted:"dotted"},iQ={Start:"start",Middle:"middle",End:"end",Justify:"justify"},h_={Script:"script",Sans:"sans",Serif:"serif",Mono:"mono"};var yD1={[n9.White]:"black",[n9.Black]:"black",[n9.LightGray]:"grey",[n9.Gray]:"grey",[n9.Green]:"light-green",[n9.Cyan]:"green",[n9.Blue]:"light-blue",[n9.Indigo]:"blue",[n9.Orange]:"orange",[n9.Yellow]:"yellow",[n9.Red]:"red",[n9.Violet]:"light-violet"},xD1={[h_.Mono]:"mono",[h_.Sans]:"sans",[h_.Script]:"draw",[h_.Serif]:"serif"},vD1={[iQ.Start]:"start",[iQ.Middle]:"middle",[iQ.End]:"end",[iQ.Justify]:"start"},SD1={[iQ.Start]:"start",[iQ.Middle]:"middle",[iQ.End]:"end",[iQ.Justify]:"start"},fD1={[qK.Small]:"s",[qK.Medium]:"l",[qK.Large]:"xl"},gD1={[qK.Small]:"m",[qK.Medium]:"l",[qK.Large]:"xl"},hD1={[g_.Solid]:"solid",[g_.Dashed]:"dashed",[g_.Dotted]:"dotted",[g_.Draw]:"draw"};var HO0=w.object({schemaVersion:w.literal(1),storeVersion:w.positiveInteger,recordVersions:w.dict(w.string,w.object({version:w.positiveInteger,subTypeVersions:w.dict(w.string,w.positiveInteger).optional(),subTypeKey:w.string.optional()}))}),$O0=w.object({schemaVersion:w.literal(2),sequences:w.dict(w.string,w.positiveInteger)}),lD1=w.object({tldrawFileFormatVersion:w.nonZeroInteger,schema:w.numberUnion("schemaVersion",{1:HO0,2:$O0}),records:w.arrayOf(w.object({id:w.string,typeName:w.string}).allowUnknownProperties())});x5("tldraw","5.2.3","esm");var _O0=s10()(r10((J)=>({sessions:{},setSession:(Q,Z)=>J((q)=>({sessions:{...q.sessions,[Q]:Z}})),removeSession:(Q)=>J((Z)=>{let q={...Z.sessions};return delete q[Q],{sessions:q}})}),{name:"moi:scratch-sessions"})),FO0=500;function a10(J,Q){let{sessions:Z,setSession:q,removeSession:X}=_O0.getState(),K=Z[Q];if(K)try{jZ(J.store,K)}catch{X(Q)}let Y=MZ(J.store),W=null,z=P1("save scratch session",()=>{let G=Y.get();if(!G)return;if(W)clearTimeout(W);W=setTimeout(()=>q(Q,G),FO0)});return()=>{if(z(),W)clearTimeout(W)}}var sW=E(m(),1);function UO0(J){if(!J||typeof J!=="object")return null;let Q=J.sequences;if(!Q||typeof Q!=="object")return null;let Z={};for(let[q,X]of Object.entries(Q))if(typeof X==="number")Z[q]=X;return Object.keys(Z).length>0?Z:null}function o10(J,Q){let Z=UO0(J);if(!Z)return[];let q=[];for(let[X,K]of Object.entries(Z)){let Y=Q[X];if(Y===void 0)q.push({id:X,fileVersion:K});else if(K>Y)q.push({id:X,fileVersion:K,runtimeVersion:Y})}return q}function t10(J,Q){if(J)return`moi ${J.moi}, tldraw ${J.tldraw}`;return Q.map((Z)=>Z.runtimeVersion===void 0?`${Z.id} v${Z.fileVersion} (unknown here)`:`${Z.id} v${Z.fileVersion} > v${Z.runtimeVersion}`).join(", ")}var U9=E(c(),1),e10=null;function VO0(){return e10??=w2({shapeUtils:eX,bindingUtils:sX}).schema,e10}function Ly(J,Q){let Z=VO0();try{if(Z.migrateStoreSnapshot(J).type==="success")return null}catch{}let q=o10(J.schema,Z.serialize().sequences);if(q.length>0)return{newer:!0,writer:Q,detail:t10(Q,q)};return{newer:!1,writer:Q,detail:"The saved snapshot failed to load."}}function Q40(J){let[Q,Z]=sW.useState(null);sW.useEffect(()=>{let X=!1;return fetch(`/api/workspaces/${J}/scratchpad`).then((K)=>K.json()).then((K)=>{if(X)return;let Y,W=null;if(K?.document){if(W=Ly(K.document,K.writer),!W)Y=K.document}Z({snapshot:Y,skew:W})}).catch(()=>{if(!X)Z({skew:null})}),()=>{X=!0}},[J]);let q=sW.useCallback((X)=>{Z((K)=>({snapshot:K?.snapshot,skew:X}))},[]);return{loaded:Q!==null,snapshot:Q?.snapshot,skew:Q?.skew??null,flagSkew:q}}function Z40({skew:J}){return U9.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center bg-muted/40 bg-[radial-gradient(var(--color-border)_1px,transparent_1px)] [background-size:16px_16px] p-6",children:U9.jsxs("div",{className:"flex max-w-md animate-in flex-col gap-3 rounded-lg bg-background p-6 shadow-xs duration-200 fade-in-0 zoom-in-95",children:[U9.jsxs("div",{className:"flex items-center gap-2",children:[U9.jsx(J40,{size:20,stroke:1.5,className:"shrink-0 text-amber-600"}),U9.jsx("h2",{className:"font-medium text-foreground",children:J.newer?"This canvas needs a newer moi":"This canvas couldn’t be loaded"})]}),J.newer?U9.jsxs(U9.Fragment,{children:[U9.jsxs("p",{className:"text-sm text-pretty text-muted-foreground",children:["This scratchpad was saved by a newer version of moi",J.writer?` (v${J.writer.moi})`:"",".",U9.jsx("br",{})," Please update moi and restart the server:"]}),U9.jsx("code",{className:"self-start rounded bg-muted px-2 py-1 font-mono text-xs text-foreground",children:"bun install -g moi-computer@latest"})]}):U9.jsx("p",{className:"text-sm text-muted-foreground",children:J.detail})]})})}var fq=E(m(),1);var u4=E(c(),1),NO0=[{kind:"tool",id:"select",label:"Select",Icon:U40},{kind:"tool",id:"hand",label:"Hand",Icon:H40},{kind:"sep"},{kind:"tool",id:"draw",label:"Pencil",Icon:F40},{kind:"geo",label:"Rectangle",Icon:N40},{kind:"tool",id:"note",label:"Sticker",Icon:B40},{kind:"tool",id:"text",label:"Text",Icon:Dy},{kind:"tool",id:"line",label:"Line",Icon:_40},{kind:"tool",id:"arrow",label:"Arrow",Icon:z40},{kind:"sep"},{kind:"tool",id:"highlight",label:"Highlighter",Icon:$40},{kind:"tool",id:"eraser",label:"Eraser",Icon:G40}];function Oy({label:J,active:Q,Icon:Z,onClick:q}){return u4.jsx(W40,{type:"button",size:"icon",variant:Q?"default":"ghost","aria-label":J,title:J,onClick:q,className:nQ(!Q&&"text-muted-foreground hover:text-foreground"),children:u4.jsx(Z,{stroke:1.5})})}function q40(J,Q){if(Q==="geo")J.setStyleForNextShapes(T6,"draw"),J.setStyleForNextShapes(e4,"m");else if(Q==="note")J.setStyleForNextShapes(I4,"draw"),J.setStyleForNextShapes(A9,"middle"),J.setStyleForNextShapes(C9,"middle"),K40(J,"sticker","yellow");else if(Q==="text")J.setStyleForNextShapes(I4,"draw"),J.setStyleForNextShapes(A9,"middle"),J.setStyleForNextShapes(C9,"middle");else if(Q==="highlight")K40(J,"highlight","yellow");else if(Q==="arrow")J.setStyleForNextShapes(T6,"draw");else if(Q==="draw"||Q==="line"){let Z=J.getStyleForNextShape(T6);if(Z!=="draw"&&Z!=="dashed")J.setStyleForNextShapes(T6,"draw")}}var X40="[&_.tl-canvas]:cursor-pencil";function O40({editor:J}){let[Q,Z]=fq.useState(()=>J.getCurrentToolId());fq.useEffect(()=>{let K=J.getContainer(),Y=()=>{let z=J.getCurrentToolId();Z(z),K.classList.toggle(X40,z==="draw")};Y();let W=P1("scratch current tool",Y);return()=>{W(),K.classList.remove(X40)}},[J]);let q=(K)=>{J.run(()=>{q40(J,K),J.setCurrentTool(K)})},X=()=>{J.run(()=>{J.setStyleForNextShapes(x6,"rectangle"),q40(J,"geo"),J.setCurrentTool("geo")})};return u4.jsx("div",{className:"absolute top-1/2 left-2 -translate-y-1/2",children:u4.jsx(L40.div,{initial:{x:-72,opacity:0},animate:{x:0,opacity:1},transition:{type:"spring",bounce:0.2,duration:0.55},className:"flex flex-col gap-1 rounded-xl bg-background/95 p-1 shadow-md backdrop-blur",children:NO0.map((K,Y)=>{if(K.kind==="sep")return u4.jsx("div",{className:"mx-1 my-0.5 h-px bg-border"},`sep-${Y}`);if(K.kind==="geo")return u4.jsx(Oy,{label:K.label,Icon:K.Icon,active:Q==="geo",onClick:X},"geo");if(K.kind==="menu")return u4.jsx(Oy,{label:K.label,Icon:K.Icon,active:!1,onClick:()=>{}},"menu");return u4.jsx(Oy,{label:K.label,Icon:K.Icon,active:Q===K.id,onClick:()=>q(K.id)},K.id)})})})}var BO0=["color","size","dash","fill"],D40={draw:["color","size","dash"],geo:["color","fill"],note:["color","size"],text:["color","size"],line:["color","dash","size"],highlight:["color","size"],arrow:["color","size"]},LO0={draw:["color","size","dash"],geo:["color","fill"],note:["color","size"],text:["color","size"],line:["color","dash","size"],highlight:["color","size"],arrow:["color","size"]},M40={regular:{swatches:[{value:"black",klass:"bg-[#1d1d1d]"},{value:"red",klass:"bg-[#e03131]"},{value:"yellow",klass:"bg-[#f1ac4b]"},{value:"green",klass:"bg-[#099268]"},{value:"blue",klass:"bg-[#4465e9]"},{value:"grey",klass:"bg-[#9fa8b2]"}]},highlight:{swatches:[{value:"yellow",klass:"bg-[#fddd00]"},{value:"green",klass:"bg-[#00ffc8]"},{value:"blue",klass:"bg-[#10acff]"}]},sticker:{swatches:[{value:"yellow",klass:"bg-[#fed49a]"},{value:"blue",klass:"bg-[#8aa3ff]"},{value:"green",klass:"bg-[#6fc896]"}]}};function OO0(J){let Q=J.getCurrentToolId();if(Q==="highlight")return"highlight";if(Q==="note")return"sticker";if(D40[Q])return"regular";let Z=new Set(J.getSelectedShapeIds().map((q)=>J.getShape(q)?.type));if(Z.size===1){if(Z.has("highlight"))return"highlight";if(Z.has("note"))return"sticker"}return"regular"}function K40(J,Q,Z){if(!M40[Q].swatches.map((X)=>X.value).includes(J.getStyleForNextShape(_1)))J.setStyleForNextShapes(_1,Z)}var DO0=[{value:"m",label:"Small",dot:"size-1.5",glyph:16},{value:"xl",label:"Large",dot:"size-3",glyph:24}],MO0=[{value:"draw",label:"Rough",preview:"border-b-2 border-current"},{value:"dashed",label:"Dash",preview:"border-b-2 border-dashed border-current"}],jO0=[{value:"none",label:"None",preview:"border border-foreground/50"},{value:"solid",label:"Semi",preview:"border border-foreground/40 bg-foreground/25"},{value:"fill",label:"Solid",preview:"border border-foreground bg-foreground"},{value:"pattern",label:"Pattern",preview:"border border-foreground/40 bg-[repeating-linear-gradient(45deg,currentColor_0,currentColor_1px,transparent_1px,transparent_3px)]"}];function AD(J,Q){if(J.getSelectedShapeIds().length>0)return J.getSharedStyles().getAsKnownValue(Q);return J.getStyleForNextShape(Q)}function CD(J,Q,Z){J.run(()=>{if(J.setStyleForNextShapes(Q,Z),J.getSelectedShapeIds().length>0)J.setStyleForSelectedShapes(Q,Z)})}function RO0(J){let Q=D40[J.getCurrentToolId()];if(Q)return Q;let Z=J.getSelectedShapeIds();if(Z.length===0)return[];let q=new Set;for(let X of Z){let K=J.getShape(X);if(!K)continue;for(let Y of LO0[K.type]??[])q.add(Y)}return BO0.filter((X)=>q.has(X))}function kO0(J){let Q=J.getCurrentToolId();if(Q==="draw")return"pen";if(Q==="text")return"letter";let Z=J.getSelectedShapeIds(),q=new Set(Z.map((X)=>J.getShape(X)?.type));if(q.size===1){if(q.has("draw"))return"pen";if(q.has("text"))return"letter"}return"dot"}function Y40(J){return{controls:RO0(J),palette:M40[OO0(J)],color:AD(J,_1),size:AD(J,e4),sizeGlyph:kO0(J),dash:AD(J,T6),fill:AD(J,y6)}}function j40({editor:J}){let[Q,Z]=fq.useState(()=>Y40(J));if(fq.useEffect(()=>{return P1("scratch styles",()=>Z(Y40(J)))},[J]),Q.controls.length===0)return null;let q={color:u4.jsx("div",{className:"flex flex-col items-center gap-2 pt-1",children:Q.palette.swatches.map((X)=>u4.jsx("button",{type:"button",title:X.value,onClick:()=>CD(J,_1,X.value),className:nQ("size-5.5 rounded-full ring-offset-1 ring-offset-background",X.klass,Q.color===X.value?"ring-2 ring-primary":"ring-1 ring-black/15")},X.value))}),size:u4.jsx("div",{className:"flex flex-col items-center gap-1 text-foreground",children:DO0.map((X)=>u4.jsx("button",{type:"button",title:X.label,onClick:()=>CD(J,e4,X.value),className:nQ("flex size-7.5 items-center justify-center rounded-full hover:bg-accent hover:text-accent-foreground",Q.size===X.value&&"bg-accent text-accent-foreground"),children:Q.sizeGlyph==="pen"?u4.jsx(V40,{size:20,stroke:X.value==="m"?1.25:2}):Q.sizeGlyph==="letter"?u4.jsx(Dy,{size:X.glyph,stroke:X.glyph===16?1.75:1.5}):u4.jsx("span",{className:nQ("rounded-full bg-current",X.dot)})},X.value))}),dash:u4.jsx("div",{className:"flex flex-col items-center gap-1 text-foreground",children:MO0.map((X)=>u4.jsx("button",{type:"button",title:X.label,onClick:()=>CD(J,T6,X.value),className:nQ("flex size-7.5 items-center justify-center rounded-full hover:bg-accent hover:text-accent-foreground",Q.dash===X.value&&"bg-accent text-accent-foreground"),children:u4.jsx("span",{className:nQ("w-3.5",X.preview)})},X.value))}),fill:u4.jsx("div",{className:"flex flex-col items-center gap-1 text-foreground",children:jO0.map((X)=>u4.jsx("button",{type:"button",title:X.label,onClick:()=>CD(J,y6,X.value),className:nQ("flex size-7.5 items-center justify-center rounded-full hover:bg-accent hover:text-accent-foreground",Q.fill===X.value&&"bg-accent text-accent-foreground"),children:u4.jsx("span",{className:nQ("size-4.5 rounded-lg",X.preview)})},X.value))})};return u4.jsx("div",{className:"absolute top-1/2 left-14 flex -translate-y-1/2 flex-col items-center gap-1.5 rounded-full bg-background/95 px-1 py-1 shadow-[0_2px_8px_rgba(0,0,0,0.08),0_4px_16px_rgba(0,0,0,0.06),0_0_0_1px_rgba(0,0,0,0.04)] backdrop-blur",children:Q.controls.map((X,K)=>u4.jsxs(fq.Fragment,{children:[K>0&&u4.jsx("div",{className:"h-px w-5 bg-border"}),q[X]]},X))})}var O8=E(c(),1),R40=Math.random().toString(36).slice(2),EO0=500,AO0=void 0;function CO0(J){return async(Q)=>{if(Q.kind!=="view")throw Error(`Scratchpad op "${Q.kind}" runs on the server, not the browser.`);let Z=[...J.getCurrentPageShapeIds()];if(Z.length===0)throw Error("Canvas is empty — nothing to view.");let{url:q}=await J.toImageDataUrl(Z,{format:"png",background:!0,padding:32});return{image:q}}}function PO0(J){let Q=`/api/workspaces/${J}/scratchpad/assets`;return{async upload(Z,q){let X=await fetch(Q,{method:"POST",headers:{"Content-Type":q.type||"application/octet-stream"},body:q});if(!X.ok)throw Error(`Upload failed: ${await X.text()}`);let{src:K}=await X.json();return{src:K}},resolve(Z){let q=Z.props.src;if(q?.startsWith("asset:"))return`${Q}/${q.slice(6)}`;return q}}}function IO0(){return O8.jsx("div",{className:"absolute inset-0 bg-background"})}function wO0({x:J,y:Q,z:Z,size:q}){let X=M5("scratch-grid"),K=v(),Y=K.options.gridSteps[0]?.step??1;for(let _ of K.options.gridSteps)if(Z>=_.min)Y=_.step;let W=Y*q*Z,z=0.5+J*Z,G=0.5+Q*Z,$=z>0?z%W:W+z%W,H=G>0?G%W:W+G%W;return O8.jsxs("svg",{className:"tl-grid",version:"1.1",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[O8.jsx("defs",{children:O8.jsx("pattern",{id:X,width:W,height:W,patternUnits:"userSpaceOnUse",children:O8.jsx("circle",{className:"fill-accent",cx:$,cy:H,r:1})})}),O8.jsx("rect",{width:"100%",height:"100%",fill:`url(#${X})`})]})}var bO0={Background:IO0,Grid:wO0,Toolbar:null,StylePanel:null,Minimap:null,MainMenu:null,PageMenu:null,ActionsMenu:null,QuickActions:null,HelpMenu:null,DebugMenu:null,ZoomMenu:null},TO0={tools(J,Q){return delete Q.frame,delete Q.laser,Q},actions(J,Q){for(let Z of["export-as-svg","export-as-png","copy-as-svg","copy-as-png","print"])delete Q[Z];return Q}},yO0={maxPages:1},xO0=33554432,vO0=2048;function yE1(){let J=k40();return O8.jsx(SO0,{workspaceId:J},J)}function SO0({workspaceId:J}){let Q=O2.useRef(null),Z=O2.useRef(null),q=O2.useRef(null),X=O2.useRef(!1),[K,Y]=O2.useState(null),{loaded:W,snapshot:z,skew:G,flagSkew:$}=Q40(J),[H]=O2.useState(()=>PO0(J)),_=O2.useCallback(()=>{let U=Q.current;if(!U)return;let V;try{V=uG(U.store).document}catch{return}fetch(`/api/workspaces/${J}/scratchpad`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({document:V,origin:R40})}).catch(()=>{})},[J]);E40((U)=>{if(U.type!=="scratchpad:updated"||U.workspaceId!==J)return;if(U.origin&&U.origin===R40)return;if(!Q.current)return;fetch(`/api/workspaces/${J}/scratchpad`).then((V)=>V.json()).then((V)=>{let B=Q.current;if(!B||!V?.document)return;let N=Ly(V.document,V.writer);if(N){if(q.current)clearTimeout(q.current);$(N);return}X.current=!0,R3(B.store,{document:V.document})}).catch(()=>{})});let F=O2.useCallback((U)=>{Q.current=U,Y(U),U.updateInstanceState({isGridMode:!0}),U.run(()=>{U.setStyleForNextShapes(I4,"draw"),U.setStyleForNextShapes(A9,"middle"),U.setStyleForNextShapes(C9,"middle"),U.setStyleForNextShapes(y6,"fill")});let V=a10(U,J),B=U.store.listen(()=>{if(X.current){X.current=!1;return}if(q.current)clearTimeout(q.current);q.current=setTimeout(_,EO0)},{source:"user",scope:"document"});My(J,CO0(U));let N=(D)=>{let O=D.target;if(!!O&&!!Z.current?.contains(O)){if(!U.getIsFocused())U.focus()}else if(U.getIsFocused())U.blur()},L=U.getContainer().ownerDocument;return L.addEventListener("pointerdown",N,!0),U.focus(),()=>{if(B(),V(),L.removeEventListener("pointerdown",N,!0),q.current)clearTimeout(q.current);My(J,null),Y(null),Q.current=null}},[J,_]);if(!W)return O8.jsx("div",{className:"min-h-0 flex-1 bg-muted/40"});if(G)return O8.jsx(Z40,{skew:G});return O8.jsxs("div",{ref:Z,className:"relative min-h-0 flex-1 overflow-hidden",children:[O8.jsx("div",{className:"absolute inset-0",children:O8.jsx(Vy,{snapshot:z,assets:H,licenseKey:AO0,onMount:F,components:bO0,overrides:TO0,options:yO0,maxAssetSize:xO0,maxImageDimension:vO0,autoFocus:!1})}),K&&O8.jsx(O40,{editor:K}),K&&O8.jsx(j40,{editor:K})]})}export{yE1 as Scratchpad};