moi-computer 0.5.2-next.1 → 0.6.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 (83) hide show
  1. package/README.md +39 -0
  2. package/client/AGENTS.md +9 -0
  3. package/client/api/app-ui-keys.ts +4 -0
  4. package/client/api/workspace-keys.ts +2 -2
  5. package/client/app/routes/WorkspaceRoute.tsx +8 -28
  6. package/client/components/shared/Composer.tsx +3 -6
  7. package/client/components/shared/IconGhost.tsx +130 -0
  8. package/client/components/ui/dropdown-menu.tsx +1 -1
  9. package/client/components/ui/spinner.tsx +18 -0
  10. package/client/components/ui/toast.tsx +220 -0
  11. package/client/features/chat/ChatComposer.tsx +3 -2
  12. package/client/features/chat/ChatPanel.tsx +7 -6
  13. package/client/features/chat/ChatPopup.tsx +10 -4
  14. package/client/features/chat/ChatSelector.tsx +263 -48
  15. package/client/features/chat/ModelPicker.tsx +13 -18
  16. package/client/features/chat/api.ts +36 -9
  17. package/client/features/chat/chat-frames.ts +35 -6
  18. package/client/features/chat/chat-send.ts +25 -1
  19. package/client/features/chat/chat-store.ts +43 -18
  20. package/client/features/chat/useChat.ts +54 -52
  21. package/client/features/chat/useSelectedSession.ts +151 -0
  22. package/client/features/chat/useStickToBottom.ts +3 -3
  23. package/client/features/home/api.ts +0 -2
  24. package/client/features/scratchpad/ScratchpadControls.tsx +2 -2
  25. package/client/features/settings/WorkspaceSettings.tsx +6 -6
  26. package/client/features/views/ViewBuilderTab.tsx +3 -4
  27. package/client/features/views/useViewBuilderActions.ts +3 -1
  28. package/client/features/workspace/WorkspaceScreen.tsx +38 -17
  29. package/client/features/workspace/WorkspaceTabs.tsx +10 -1
  30. package/client/main.tsx +2 -0
  31. package/client/runtime/useWorkspaceEvents.ts +1 -0
  32. package/client/store/ui.ts +2 -2
  33. package/dist/{chunk-zs4mte79.js → chunk-0pcdwjkp.js} +1 -1
  34. package/dist/chunk-175bm057.js +27 -0
  35. package/dist/chunk-55sh4dty.js +2 -0
  36. package/dist/{chunk-tzz101ea.js → chunk-9y2zbzqz.js} +1 -1
  37. package/dist/{chunk-jvhvme3z.js → chunk-afgbg75t.js} +1 -1
  38. package/dist/chunk-agtetn7n.css +1 -0
  39. package/dist/chunk-dfs36zgc.js +1 -0
  40. package/dist/chunk-exj6hr30.js +9 -0
  41. package/dist/{chunk-bcrkdhwe.js → chunk-m11ckkxd.js} +1 -1
  42. package/dist/{chunk-kfw1qwqe.js → chunk-rxvx4ta9.js} +3 -3
  43. package/dist/{chunk-xwhya7kb.js → chunk-w3tnv51j.js} +1 -1
  44. package/dist/index.html +1 -1
  45. package/lib/attachment-note.ts +18 -0
  46. package/lib/chat-title.ts +6 -0
  47. package/lib/types.ts +24 -10
  48. package/package.json +1 -1
  49. package/server/agent-caller.ts +16 -0
  50. package/server/api.ts +90 -9
  51. package/server/app-settings.ts +1 -1
  52. package/server/cli.ts +628 -45
  53. package/server/control.ts +18 -1
  54. package/server/data-dir.ts +1 -1
  55. package/server/harness/README.md +6 -0
  56. package/server/harness/claude-code/adapter.ts +2 -2
  57. package/server/harness/claude-code/index.ts +7 -1
  58. package/server/harness/claude-code/session-title.ts +106 -0
  59. package/server/harness/claude-code/session.ts +107 -17
  60. package/server/harness/claude-code/sessions.ts +63 -4
  61. package/server/harness/codex/client.ts +33 -13
  62. package/server/harness/codex/index.ts +2 -0
  63. package/server/harness/codex/session-title.ts +149 -0
  64. package/server/harness/codex/session.ts +84 -11
  65. package/server/harness/openclaw/adapter.ts +4 -2
  66. package/server/harness/openclaw/discovery.ts +2 -0
  67. package/server/harness/openclaw/session.ts +15 -7
  68. package/server/harness/session-title.ts +96 -0
  69. package/server/harness/types.ts +2 -0
  70. package/server/selected-session.ts +132 -0
  71. package/server/service.ts +786 -0
  72. package/server/{thread-config.ts → session-config.ts} +57 -39
  73. package/server/status.ts +2 -0
  74. package/server/update.ts +141 -0
  75. package/server/version.ts +41 -0
  76. package/server/web.ts +17 -1
  77. package/workspace/.claude/skills/moi-workspace/DESIGN.md +16 -26
  78. package/workspace/.claude/skills/moi-workspace/SKILL.md +8 -2
  79. package/dist/chunk-94m3q9ce.js +0 -1
  80. package/dist/chunk-k9dcnd73.js +0 -27
  81. package/dist/chunk-pk11vfzs.js +0 -9
  82. package/dist/chunk-r2bqaege.js +0 -2
  83. package/dist/chunk-y4g8j7mv.css +0 -1
@@ -1,4 +1,4 @@
1
- import"/chunk-pcnahct1.js";import{b as KZ,c as z20,n as bd,o as Td,p as yd,q as xd,r as vd,s as Sd,t as fd,u as gd,v as hd,w as wT,y as f00}from"/chunk-r2bqaege.js";import{$b as C00,Ba as yQ,Fb as A00,Ha as j00,Hc as w00,Kc as b00,Lc as g00,O as m,P as c,fc as PT,jc as P00,kb as R00,lc as I00,sc as IT,vb as k00,wc as B00,yb as E00}from"/chunk-pk11vfzs.js";import{Nc as E,Oc as fQ,Pc as T7,Qc as hp}from"/chunk-tzz101ea.js";var Fy=fQ((F_,gX)=>{var c00=200,JD="__lodash_hash_undefined__",M_=1,pT=2,dT=9007199254740991,U_="[object Arguments]",nL="[object Array]",l00="[object AsyncFunction]",iT="[object Boolean]",nT="[object Date]",sT="[object Error]",rT="[object Function]",p00="[object GeneratorFunction]",V_="[object Map]",aT="[object Number]",d00="[object Null]",fX="[object Object]",yT="[object Promise]",i00="[object Proxy]",oT="[object RegExp]",N_="[object Set]",tT="[object String]",n00="[object Symbol]",s00="[object Undefined]",sL="[object WeakMap]",eT="[object ArrayBuffer]",B_="[object DataView]",r00="[object Float32Array]",a00="[object Float64Array]",o00="[object Int8Array]",t00="[object Int16Array]",e00="[object Int32Array]",J10="[object Uint8Array]",Q10="[object Uint8ClampedArray]",Z10="[object Uint16Array]",q10="[object Uint32Array]",X10=/[\\^$.*+?()[\]{}|]/g,K10=/^\[object .+?Constructor\]$/,Y10=/^(?:0|[1-9]\d*)$/,m4={};m4[r00]=m4[a00]=m4[o00]=m4[t00]=m4[e00]=m4[J10]=m4[Q10]=m4[Z10]=m4[q10]=!0;m4[U_]=m4[nL]=m4[eT]=m4[iT]=m4[B_]=m4[nT]=m4[sT]=m4[rT]=m4[V_]=m4[aT]=m4[fX]=m4[oT]=m4[N_]=m4[tT]=m4[sL]=!1;var Jy=typeof global=="object"&&global&&global.Object===Object&&global,W10=typeof self=="object"&&self&&self.Object===Object&&self,YJ=Jy||W10||Function("return this")(),Qy=typeof F_=="object"&&F_&&!F_.nodeType&&F_,xT=Qy&&typeof gX=="object"&&gX&&!gX.nodeType&&gX,Zy=xT&&xT.exports===Qy,pL=Zy&&Jy.process,vT=function(){try{return pL&&pL.binding&&pL.binding("util")}catch(J){}}(),ST=vT&&vT.isTypedArray;function z10(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 G10(J,Q){var Z=-1,q=Q.length,X=J.length;while(++Z<q)J[X+Z]=Q[Z];return J}function $10(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 H10(J,Q){var Z=-1,q=Array(J);while(++Z<J)q[Z]=Q(Z);return q}function _10(J){return function(Q){return J(Q)}}function F10(J,Q){return J.has(Q)}function U10(J,Q){return J==null?void 0:J[Q]}function V10(J){var Q=-1,Z=Array(J.size);return J.forEach(function(q,X){Z[++Q]=[X,q]}),Z}function N10(J,Q){return function(Z){return J(Q(Z))}}function B10(J){var Q=-1,Z=Array(J.size);return J.forEach(function(q){Z[++Q]=q}),Z}var O10=Array.prototype,L10=Function.prototype,j_=Object.prototype,dL=YJ["__core-js_shared__"],qy=L10.toString,_2=j_.hasOwnProperty,fT=function(){var J=/[^.]+$/.exec(dL&&dL.keys&&dL.keys.IE_PROTO||"");return J?"Symbol(src)_1."+J:""}(),Xy=j_.toString,D10=RegExp("^"+qy.call(_2).replace(X10,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),gT=Zy?YJ.Buffer:void 0,O_=YJ.Symbol,hT=YJ.Uint8Array,Ky=j_.propertyIsEnumerable,M10=O10.splice,Rq=O_?O_.toStringTag:void 0,uT=Object.getOwnPropertySymbols,j10=gT?gT.isBuffer:void 0,R10=N10(Object.keys,Object),rL=hX(YJ,"DataView"),wW=hX(YJ,"Map"),aL=hX(YJ,"Promise"),oL=hX(YJ,"Set"),tL=hX(YJ,"WeakMap"),bW=hX(Object,"create"),k10=Aq(rL),E10=Aq(wW),A10=Aq(aL),C10=Aq(oL),P10=Aq(tL),mT=O_?O_.prototype:void 0,iL=mT?mT.valueOf:void 0;function kq(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 I10(){this.__data__=bW?bW(null):{},this.size=0}function w10(J){var Q=this.has(J)&&delete this.__data__[J];return this.size-=Q?1:0,Q}function b10(J){var Q=this.__data__;if(bW){var Z=Q[J];return Z===JD?void 0:Z}return _2.call(Q,J)?Q[J]:void 0}function T10(J){var Q=this.__data__;return bW?Q[J]!==void 0:_2.call(Q,J)}function y10(J,Q){var Z=this.__data__;return this.size+=this.has(J)?0:1,Z[J]=bW&&Q===void 0?JD:Q,this}kq.prototype.clear=I10;kq.prototype.delete=w10;kq.prototype.get=b10;kq.prototype.has=T10;kq.prototype.set=y10;function WJ(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 x10(){this.__data__=[],this.size=0}function v10(J){var Q=this.__data__,Z=R_(Q,J);if(Z<0)return!1;var q=Q.length-1;if(Z==q)Q.pop();else M10.call(Q,Z,1);return--this.size,!0}function S10(J){var Q=this.__data__,Z=R_(Q,J);return Z<0?void 0:Q[Z][1]}function f10(J){return R_(this.__data__,J)>-1}function g10(J,Q){var Z=this.__data__,q=R_(Z,J);if(q<0)++this.size,Z.push([J,Q]);else Z[q][1]=Q;return this}WJ.prototype.clear=x10;WJ.prototype.delete=v10;WJ.prototype.get=S10;WJ.prototype.has=f10;WJ.prototype.set=g10;function Eq(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 h10(){this.size=0,this.__data__={hash:new kq,map:new(wW||WJ),string:new kq}}function u10(J){var Q=k_(this,J).delete(J);return this.size-=Q?1:0,Q}function m10(J){return k_(this,J).get(J)}function c10(J){return k_(this,J).has(J)}function l10(J,Q){var Z=k_(this,J),q=Z.size;return Z.set(J,Q),this.size+=Z.size==q?0:1,this}Eq.prototype.clear=h10;Eq.prototype.delete=u10;Eq.prototype.get=m10;Eq.prototype.has=c10;Eq.prototype.set=l10;function L_(J){var Q=-1,Z=J==null?0:J.length;this.__data__=new Eq;while(++Q<Z)this.add(J[Q])}function p10(J){return this.__data__.set(J,JD),this}function d10(J){return this.__data__.has(J)}L_.prototype.add=L_.prototype.push=p10;L_.prototype.has=d10;function SQ(J){var Q=this.__data__=new WJ(J);this.size=Q.size}function i10(){this.__data__=new WJ,this.size=0}function n10(J){var Q=this.__data__,Z=Q.delete(J);return this.size=Q.size,Z}function s10(J){return this.__data__.get(J)}function r10(J){return this.__data__.has(J)}function a10(J,Q){var Z=this.__data__;if(Z instanceof WJ){var q=Z.__data__;if(!wW||q.length<c00-1)return q.push([J,Q]),this.size=++Z.size,this;Z=this.__data__=new Eq(q)}return Z.set(J,Q),this.size=Z.size,this}SQ.prototype.clear=i10;SQ.prototype.delete=n10;SQ.prototype.get=s10;SQ.prototype.has=r10;SQ.prototype.set=a10;function o10(J,Q){var Z=D_(J),q=!Z&&_40(J),X=!Z&&!q&&eL(J),K=!Z&&!q&&!X&&_y(J),Y=Z||q||X||K,W=Y?H10(J.length,String):[],z=W.length;for(var G in J)if((Q||_2.call(J,G))&&!(Y&&(G=="length"||X&&(G=="offset"||G=="parent")||K&&(G=="buffer"||G=="byteLength"||G=="byteOffset")||W40(G,z))))W.push(G);return W}function R_(J,Q){var Z=J.length;while(Z--)if(zy(J[Z][0],Q))return Z;return-1}function t10(J,Q,Z){var q=Q(J);return D_(J)?q:G10(q,Z(J))}function yW(J){if(J==null)return J===void 0?s00:d00;return Rq&&Rq in Object(J)?K40(J):H40(J)}function cT(J){return TW(J)&&yW(J)==U_}function Yy(J,Q,Z,q,X){if(J===Q)return!0;if(J==null||Q==null||!TW(J)&&!TW(Q))return J!==J&&Q!==Q;return e10(J,Q,Z,q,Yy,X)}function e10(J,Q,Z,q,X,K){var Y=D_(J),W=D_(Q),z=Y?nL:vQ(J),G=W?nL:vQ(Q);z=z==U_?fX:z,G=G==U_?fX:G;var H=z==fX,$=G==fX,_=z==G;if(_&&eL(J)){if(!eL(Q))return!1;Y=!0,H=!1}if(_&&!H)return K||(K=new SQ),Y||_y(J)?Wy(J,Q,Z,q,X,K):q40(J,Q,z,Z,q,X,K);if(!(Z&M_)){var F=H&&_2.call(J,"__wrapped__"),U=$&&_2.call(Q,"__wrapped__");if(F||U){var V=F?J.value():J,N=U?Q.value():Q;return K||(K=new SQ),X(V,N,Z,q,K)}}if(!_)return!1;return K||(K=new SQ),X40(J,Q,Z,q,X,K)}function J40(J){if(!Hy(J)||G40(J))return!1;var Q=Gy(J)?D10:K10;return Q.test(Aq(J))}function Q40(J){return TW(J)&&$y(J.length)&&!!m4[yW(J)]}function Z40(J){if(!$40(J))return R10(J);var Q=[];for(var Z in Object(J))if(_2.call(J,Z)&&Z!="constructor")Q.push(Z);return Q}function Wy(J,Q,Z,q,X,K){var Y=Z&M_,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 H=-1,$=!0,_=Z&pT?new L_:void 0;K.set(J,Q),K.set(Q,J);while(++H<W){var F=J[H],U=Q[H];if(q)var V=Y?q(U,F,H,Q,J,K):q(F,U,H,J,Q,K);if(V!==void 0){if(V)continue;$=!1;break}if(_){if(!$10(Q,function(N,B){if(!F10(_,B)&&(F===N||X(F,N,Z,q,K)))return _.push(B)})){$=!1;break}}else if(!(F===U||X(F,U,Z,q,K))){$=!1;break}}return K.delete(J),K.delete(Q),$}function q40(J,Q,Z,q,X,K,Y){switch(Z){case B_:if(J.byteLength!=Q.byteLength||J.byteOffset!=Q.byteOffset)return!1;J=J.buffer,Q=Q.buffer;case eT:if(J.byteLength!=Q.byteLength||!K(new hT(J),new hT(Q)))return!1;return!0;case iT:case nT:case aT:return zy(+J,+Q);case sT:return J.name==Q.name&&J.message==Q.message;case oT:case tT:return J==Q+"";case V_:var W=V10;case N_:var z=q&M_;if(W||(W=B10),J.size!=Q.size&&!z)return!1;var G=Y.get(J);if(G)return G==Q;q|=pT,Y.set(J,Q);var H=Wy(W(J),W(Q),q,X,K,Y);return Y.delete(J),H;case n00:if(iL)return iL.call(J)==iL.call(Q)}return!1}function X40(J,Q,Z,q,X,K){var Y=Z&M_,W=lT(J),z=W.length,G=lT(Q),H=G.length;if(z!=H&&!Y)return!1;var $=z;while($--){var _=W[$];if(!(Y?_ in Q:_2.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(++$<z){_=W[$];var N=J[_],B=Q[_];if(q)var O=Y?q(B,N,_,Q,J,K):q(N,B,_,J,Q,K);if(!(O===void 0?N===B||X(N,B,Z,q,K):O)){U=!1;break}V||(V=_=="constructor")}if(U&&!V){var M=J.constructor,L=Q.constructor;if(M!=L&&(("constructor"in J)&&("constructor"in Q))&&!(typeof M=="function"&&M instanceof M&&typeof L=="function"&&L instanceof L))U=!1}return K.delete(J),K.delete(Q),U}function lT(J){return t10(J,V40,Y40)}function k_(J,Q){var Z=J.__data__;return z40(Q)?Z[typeof Q=="string"?"string":"hash"]:Z.map}function hX(J,Q){var Z=U10(J,Q);return J40(Z)?Z:void 0}function K40(J){var Q=_2.call(J,Rq),Z=J[Rq];try{J[Rq]=void 0;var q=!0}catch(K){}var X=Xy.call(J);if(q)if(Q)J[Rq]=Z;else delete J[Rq];return X}var Y40=!uT?N40:function(J){if(J==null)return[];return J=Object(J),z10(uT(J),function(Q){return Ky.call(J,Q)})},vQ=yW;if(rL&&vQ(new rL(new ArrayBuffer(1)))!=B_||wW&&vQ(new wW)!=V_||aL&&vQ(aL.resolve())!=yT||oL&&vQ(new oL)!=N_||tL&&vQ(new tL)!=sL)vQ=function(J){var Q=yW(J),Z=Q==fX?J.constructor:void 0,q=Z?Aq(Z):"";if(q)switch(q){case k10:return B_;case E10:return V_;case A10:return yT;case C10:return N_;case P10:return sL}return Q};function W40(J,Q){return Q=Q==null?dT:Q,!!Q&&(typeof J=="number"||Y10.test(J))&&(J>-1&&J%1==0&&J<Q)}function z40(J){var Q=typeof J;return Q=="string"||Q=="number"||Q=="symbol"||Q=="boolean"?J!=="__proto__":J===null}function G40(J){return!!fT&&fT in J}function $40(J){var Q=J&&J.constructor,Z=typeof Q=="function"&&Q.prototype||j_;return J===Z}function H40(J){return Xy.call(J)}function Aq(J){if(J!=null){try{return qy.call(J)}catch(Q){}try{return J+""}catch(Q){}}return""}function zy(J,Q){return J===Q||J!==J&&Q!==Q}var _40=cT(function(){return arguments}())?cT:function(J){return TW(J)&&_2.call(J,"callee")&&!Ky.call(J,"callee")},D_=Array.isArray;function F40(J){return J!=null&&$y(J.length)&&!Gy(J)}var eL=j10||B40;function U40(J,Q){return Yy(J,Q)}function Gy(J){if(!Hy(J))return!1;var Q=yW(J);return Q==rT||Q==p00||Q==l00||Q==i00}function $y(J){return typeof J=="number"&&J>-1&&J%1==0&&J<=dT}function Hy(J){var Q=typeof J;return J!=null&&(Q=="object"||Q=="function")}function TW(J){return J!=null&&typeof J=="object"}var _y=ST?_10(ST):Q40;function V40(J){return F40(J)?o10(J):Z40(J)}function N40(){return[]}function B40(){return!1}gX.exports=U40});var UD=fQ((E_,mX)=>{var O40=200,HD="__lodash_hash_undefined__",ky=1,b_=2,Ey=9007199254740991,A_="[object Arguments]",qD="[object Array]",Ay="[object Boolean]",Cy="[object Date]",Py="[object Error]",Iy="[object Function]",L40="[object GeneratorFunction]",C_="[object Map]",wy="[object Number]",uX="[object Object]",Uy="[object Promise]",by="[object RegExp]",P_="[object Set]",Ty="[object String]",D40="[object Symbol]",XD="[object WeakMap]",yy="[object ArrayBuffer]",I_="[object DataView]",M40="[object Float32Array]",j40="[object Float64Array]",R40="[object Int8Array]",k40="[object Int16Array]",E40="[object Int32Array]",A40="[object Uint8Array]",C40="[object Uint8ClampedArray]",P40="[object Uint16Array]",I40="[object Uint32Array]",w40=/[\\^$.*+?()[\]{}|]/g,b40=/^\[object .+?Constructor\]$/,T40=/^(?:0|[1-9]\d*)$/,c4={};c4[M40]=c4[j40]=c4[R40]=c4[k40]=c4[E40]=c4[A40]=c4[C40]=c4[P40]=c4[I40]=!0;c4[A_]=c4[qD]=c4[yy]=c4[Ay]=c4[I_]=c4[Cy]=c4[Py]=c4[Iy]=c4[C_]=c4[wy]=c4[uX]=c4[by]=c4[P_]=c4[Ty]=c4[XD]=!1;var xy=typeof global=="object"&&global&&global.Object===Object&&global,y40=typeof self=="object"&&self&&self.Object===Object&&self,uQ=xy||y40||Function("return this")(),vy=typeof E_=="object"&&E_&&!E_.nodeType&&E_,Vy=vy&&typeof mX=="object"&&mX&&!mX.nodeType&&mX,x40=Vy&&Vy.exports===vy,Ny=x40&&xy.process,By=function(){try{return Ny&&Ny.binding("util")}catch(J){}}(),Oy=By&&By.isTypedArray;function v40(J,Q){var Z=-1,q=J?J.length:0;while(++Z<q)if(Q(J[Z],Z,J))return!0;return!1}function S40(J,Q){var Z=-1,q=Array(J);while(++Z<J)q[Z]=Q(Z);return q}function f40(J){return function(Q){return J(Q)}}function g40(J,Q){return J==null?void 0:J[Q]}function KD(J){var Q=!1;if(J!=null&&typeof J.toString!="function")try{Q=!!(J+"")}catch(Z){}return Q}function h40(J){var Q=-1,Z=Array(J.size);return J.forEach(function(q,X){Z[++Q]=[X,q]}),Z}function u40(J,Q){return function(Z){return J(Q(Z))}}function m40(J){var Q=-1,Z=Array(J.size);return J.forEach(function(q){Z[++Q]=q}),Z}var c40=Array.prototype,l40=Function.prototype,T_=Object.prototype,QD=uQ["__core-js_shared__"],Ly=function(){var J=/[^.]+$/.exec(QD&&QD.keys&&QD.keys.IE_PROTO||"");return J?"Symbol(src)_1."+J:""}(),Sy=l40.toString,zJ=T_.hasOwnProperty,SW=T_.toString,p40=RegExp("^"+Sy.call(zJ).replace(w40,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Dy=uQ.Symbol,My=uQ.Uint8Array,d40=T_.propertyIsEnumerable,i40=c40.splice,n40=u40(Object.keys,Object),YD=cX(uQ,"DataView"),xW=cX(uQ,"Map"),WD=cX(uQ,"Promise"),zD=cX(uQ,"Set"),GD=cX(uQ,"WeakMap"),vW=cX(Object,"create"),s40=Iq(YD),r40=Iq(xW),a40=Iq(WD),o40=Iq(zD),t40=Iq(GD),jy=Dy?Dy.prototype:void 0,ZD=jy?jy.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 e40(){this.__data__=vW?vW(null):{}}function J60(J){return this.has(J)&&delete this.__data__[J]}function Q60(J){var Q=this.__data__;if(vW){var Z=Q[J];return Z===HD?void 0:Z}return zJ.call(Q,J)?Q[J]:void 0}function Z60(J){var Q=this.__data__;return vW?Q[J]!==void 0:zJ.call(Q,J)}function q60(J,Q){var Z=this.__data__;return Z[J]=vW&&Q===void 0?HD:Q,this}Cq.prototype.clear=e40;Cq.prototype.delete=J60;Cq.prototype.get=Q60;Cq.prototype.has=Z60;Cq.prototype.set=q60;function GJ(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 X60(){this.__data__=[]}function K60(J){var Q=this.__data__,Z=y_(Q,J);if(Z<0)return!1;var q=Q.length-1;if(Z==q)Q.pop();else i40.call(Q,Z,1);return!0}function Y60(J){var Q=this.__data__,Z=y_(Q,J);return Z<0?void 0:Q[Z][1]}function W60(J){return y_(this.__data__,J)>-1}function z60(J,Q){var Z=this.__data__,q=y_(Z,J);if(q<0)Z.push([J,Q]);else Z[q][1]=Q;return this}GJ.prototype.clear=X60;GJ.prototype.delete=K60;GJ.prototype.get=Y60;GJ.prototype.has=W60;GJ.prototype.set=z60;function Pq(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 G60(){this.__data__={hash:new Cq,map:new(xW||GJ),string:new Cq}}function $60(J){return x_(this,J).delete(J)}function H60(J){return x_(this,J).get(J)}function _60(J){return x_(this,J).has(J)}function F60(J,Q){return x_(this,J).set(J,Q),this}Pq.prototype.clear=G60;Pq.prototype.delete=$60;Pq.prototype.get=H60;Pq.prototype.has=_60;Pq.prototype.set=F60;function w_(J){var Q=-1,Z=J?J.length:0;this.__data__=new Pq;while(++Q<Z)this.add(J[Q])}function U60(J){return this.__data__.set(J,HD),this}function V60(J){return this.__data__.has(J)}w_.prototype.add=w_.prototype.push=U60;w_.prototype.has=V60;function hQ(J){this.__data__=new GJ(J)}function N60(){this.__data__=new GJ}function B60(J){return this.__data__.delete(J)}function O60(J){return this.__data__.get(J)}function L60(J){return this.__data__.has(J)}function D60(J,Q){var Z=this.__data__;if(Z instanceof GJ){var q=Z.__data__;if(!xW||q.length<O40-1)return q.push([J,Q]),this;Z=this.__data__=new Pq(q)}return Z.set(J,Q),this}hQ.prototype.clear=N60;hQ.prototype.delete=B60;hQ.prototype.get=O60;hQ.prototype.has=L60;hQ.prototype.set=D60;function M60(J,Q){var Z=$D(J)||y60(J)?S40(J.length,String):[],q=Z.length,X=!!q;for(var K in J)if((Q||zJ.call(J,K))&&!(X&&(K=="length"||I60(K,q))))Z.push(K);return Z}function y_(J,Q){var Z=J.length;while(Z--)if(hy(J[Z][0],Q))return Z;return-1}function j60(J){return SW.call(J)}function fy(J,Q,Z,q,X){if(J===Q)return!0;if(J==null||Q==null||!_D(J)&&!FD(Q))return J!==J&&Q!==Q;return R60(J,Q,fy,Z,q,X)}function R60(J,Q,Z,q,X,K){var Y=$D(J),W=$D(Q),z=qD,G=qD;if(!Y)z=gQ(J),z=z==A_?uX:z;if(!W)G=gQ(Q),G=G==A_?uX:G;var H=z==uX&&!KD(J),$=G==uX&&!KD(Q),_=z==G;if(_&&!H)return K||(K=new hQ),Y||S60(J)?gy(J,Q,Z,q,X,K):C60(J,Q,z,Z,q,X,K);if(!(X&b_)){var F=H&&zJ.call(J,"__wrapped__"),U=$&&zJ.call(Q,"__wrapped__");if(F||U){var V=F?J.value():J,N=U?Q.value():Q;return K||(K=new hQ),Z(V,N,q,X,K)}}if(!_)return!1;return K||(K=new hQ),P60(J,Q,Z,q,X,K)}function k60(J){if(!_D(J)||b60(J))return!1;var Q=my(J)||KD(J)?p40:b40;return Q.test(Iq(J))}function E60(J){return FD(J)&&cy(J.length)&&!!c4[SW.call(J)]}function A60(J){if(!T60(J))return n40(J);var Q=[];for(var Z in Object(J))if(zJ.call(J,Z)&&Z!="constructor")Q.push(Z);return Q}function gy(J,Q,Z,q,X,K){var Y=X&b_,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 H=-1,$=!0,_=X&ky?new w_:void 0;K.set(J,Q),K.set(Q,J);while(++H<W){var F=J[H],U=Q[H];if(q)var V=Y?q(U,F,H,Q,J,K):q(F,U,H,J,Q,K);if(V!==void 0){if(V)continue;$=!1;break}if(_){if(!v40(Q,function(N,B){if(!_.has(B)&&(F===N||Z(F,N,q,X,K)))return _.add(B)})){$=!1;break}}else if(!(F===U||Z(F,U,q,X,K))){$=!1;break}}return K.delete(J),K.delete(Q),$}function C60(J,Q,Z,q,X,K,Y){switch(Z){case I_:if(J.byteLength!=Q.byteLength||J.byteOffset!=Q.byteOffset)return!1;J=J.buffer,Q=Q.buffer;case yy:if(J.byteLength!=Q.byteLength||!q(new My(J),new My(Q)))return!1;return!0;case Ay:case Cy:case wy:return hy(+J,+Q);case Py:return J.name==Q.name&&J.message==Q.message;case by:case Ty:return J==Q+"";case C_:var W=h40;case P_:var z=K&b_;if(W||(W=m40),J.size!=Q.size&&!z)return!1;var G=Y.get(J);if(G)return G==Q;K|=ky,Y.set(J,Q);var H=gy(W(J),W(Q),q,X,K,Y);return Y.delete(J),H;case D40:if(ZD)return ZD.call(J)==ZD.call(Q)}return!1}function P60(J,Q,Z,q,X,K){var Y=X&b_,W=Ry(J),z=W.length,G=Ry(Q),H=G.length;if(z!=H&&!Y)return!1;var $=z;while($--){var _=W[$];if(!(Y?_ in Q:zJ.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(++$<z){_=W[$];var N=J[_],B=Q[_];if(q)var O=Y?q(B,N,_,Q,J,K):q(N,B,_,J,Q,K);if(!(O===void 0?N===B||Z(N,B,q,X,K):O)){U=!1;break}V||(V=_=="constructor")}if(U&&!V){var M=J.constructor,L=Q.constructor;if(M!=L&&(("constructor"in J)&&("constructor"in Q))&&!(typeof M=="function"&&M instanceof M&&typeof L=="function"&&L instanceof L))U=!1}return K.delete(J),K.delete(Q),U}function x_(J,Q){var Z=J.__data__;return w60(Q)?Z[typeof Q=="string"?"string":"hash"]:Z.map}function cX(J,Q){var Z=g40(J,Q);return k60(Z)?Z:void 0}var gQ=j60;if(YD&&gQ(new YD(new ArrayBuffer(1)))!=I_||xW&&gQ(new xW)!=C_||WD&&gQ(WD.resolve())!=Uy||zD&&gQ(new zD)!=P_||GD&&gQ(new GD)!=XD)gQ=function(J){var Q=SW.call(J),Z=Q==uX?J.constructor:void 0,q=Z?Iq(Z):void 0;if(q)switch(q){case s40:return I_;case r40:return C_;case a40:return Uy;case o40:return P_;case t40:return XD}return Q};function I60(J,Q){return Q=Q==null?Ey:Q,!!Q&&(typeof J=="number"||T40.test(J))&&(J>-1&&J%1==0&&J<Q)}function w60(J){var Q=typeof J;return Q=="string"||Q=="number"||Q=="symbol"||Q=="boolean"?J!=="__proto__":J===null}function b60(J){return!!Ly&&Ly in J}function T60(J){var Q=J&&J.constructor,Z=typeof Q=="function"&&Q.prototype||T_;return J===Z}function Iq(J){if(J!=null){try{return Sy.call(J)}catch(Q){}try{return J+""}catch(Q){}}return""}function hy(J,Q){return J===Q||J!==J&&Q!==Q}function y60(J){return x60(J)&&zJ.call(J,"callee")&&(!d40.call(J,"callee")||SW.call(J)==A_)}var $D=Array.isArray;function uy(J){return J!=null&&cy(J.length)&&!my(J)}function x60(J){return FD(J)&&uy(J)}function v60(J,Q,Z){Z=typeof Z=="function"?Z:void 0;var q=Z?Z(J,Q):void 0;return q===void 0?fy(J,Q,Z):!!q}function my(J){var Q=_D(J)?SW.call(J):"";return Q==Iy||Q==L40}function cy(J){return typeof J=="number"&&J>-1&&J%1==0&&J<=Ey}function _D(J){var Q=typeof J;return!!J&&(Q=="object"||Q=="function")}function FD(J){return!!J&&typeof J=="object"}var S60=Oy?f40(Oy):E60;function Ry(J){return uy(J)?M60(J):A60(J)}mX.exports=v60});var ny=fQ((kB0,iy)=>{var dy="Expected a function",ly=NaN,f60="[object Symbol]",g60=/^\s+|\s+$/g,h60=/^[-+]0x[0-9a-f]+$/i,u60=/^0b[01]+$/i,m60=/^0o[0-7]+$/i,c60=parseInt,l60=typeof global=="object"&&global&&global.Object===Object&&global,p60=typeof self=="object"&&self&&self.Object===Object&&self,d60=l60||p60||Function("return this")(),i60=Object.prototype,n60=i60.toString,s60=Math.max,r60=Math.min,VD=function(){return d60.Date.now()};function a60(J,Q,Z){var q,X,K,Y,W,z,G=0,H=!1,$=!1,_=!0;if(typeof J!="function")throw TypeError(dy);if(Q=py(Q)||0,v_(Z))H=!!Z.leading,$="maxWait"in Z,K=$?s60(py(Z.maxWait)||0,Q):K,_="trailing"in Z?!!Z.trailing:_;function F(k){var R=q,I=X;return q=X=void 0,G=k,Y=J.apply(I,R),Y}function U(k){return G=k,W=setTimeout(B,Q),H?F(k):Y}function V(k){var R=k-z,I=k-G,A=Q-R;return $?r60(A,K-I):A}function N(k){var R=k-z,I=k-G;return z===void 0||R>=Q||R<0||$&&I>=K}function B(){var k=VD();if(N(k))return O(k);W=setTimeout(B,V(k))}function O(k){if(W=void 0,_&&q)return F(k);return q=X=void 0,Y}function M(){if(W!==void 0)clearTimeout(W);G=0,q=z=X=W=void 0}function L(){return W===void 0?Y:O(VD())}function j(){var k=VD(),R=N(k);if(q=arguments,X=this,z=k,R){if(W===void 0)return U(z);if($)return W=setTimeout(B,Q),F(z)}if(W===void 0)W=setTimeout(B,Q);return Y}return j.cancel=M,j.flush=L,j}function o60(J,Q,Z){var q=!0,X=!0;if(typeof J!="function")throw TypeError(dy);if(v_(Z))q="leading"in Z?!!Z.leading:q,X="trailing"in Z?!!Z.trailing:X;return a60(J,Q,{leading:q,maxWait:Q,trailing:X})}function v_(J){var Q=typeof J;return!!J&&(Q=="object"||Q=="function")}function t60(J){return!!J&&typeof J=="object"}function e60(J){return typeof J=="symbol"||t60(J)&&n60.call(J)==f60}function py(J){if(typeof J=="number")return J;if(e60(J))return ly;if(v_(J)){var Q=typeof J.valueOf=="function"?J.valueOf():J;J=v_(Q)?Q+"":Q}if(typeof J!="string")return J===0?J:+J;J=J.replace(g60,"");var Z=u60.test(J);return Z||m60.test(J)?c60(J.slice(2),Z?2:8):h60.test(J)?ly:+J}iy.exports=o60});var Jx=fQ((EB0,ey)=>{var J50=200,OD="__lodash_hash_undefined__",Q50=1/0,Z50="[object Function]",q50="[object GeneratorFunction]",X50=/[\\^$.*+?()[\]{}|]/g,K50=/^\[object .+?Constructor\]$/,Y50=typeof global=="object"&&global&&global.Object===Object&&global,W50=typeof self=="object"&&self&&self.Object===Object&&self,LD=Y50||W50||Function("return this")();function z50(J,Q){var Z=J?J.length:0;return!!Z&&H50(J,Q,0)>-1}function G50(J,Q,Z){var q=-1,X=J?J.length:0;while(++q<X)if(Z(Q,J[q]))return!0;return!1}function $50(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 H50(J,Q,Z){if(Q!==Q)return $50(J,_50,Z);var q=Z-1,X=J.length;while(++q<X)if(J[q]===Q)return q;return-1}function _50(J){return J!==J}function F50(J,Q){return J.has(Q)}function U50(J,Q){return J==null?void 0:J[Q]}function V50(J){var Q=!1;if(J!=null&&typeof J.toString!="function")try{Q=!!(J+"")}catch(Z){}return Q}function ry(J){var Q=-1,Z=Array(J.size);return J.forEach(function(q){Z[++Q]=q}),Z}var N50=Array.prototype,B50=Function.prototype,ay=Object.prototype,ND=LD["__core-js_shared__"],sy=function(){var J=/[^.]+$/.exec(ND&&ND.keys&&ND.keys.IE_PROTO||"");return J?"Symbol(src)_1."+J:""}(),oy=B50.toString,DD=ay.hasOwnProperty,O50=ay.toString,L50=RegExp("^"+oy.call(DD).replace(X50,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),D50=N50.splice,M50=MD(LD,"Map"),BD=MD(LD,"Set"),fW=MD(Object,"create");function wq(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 j50(){this.__data__=fW?fW(null):{}}function R50(J){return this.has(J)&&delete this.__data__[J]}function k50(J){var Q=this.__data__;if(fW){var Z=Q[J];return Z===OD?void 0:Z}return DD.call(Q,J)?Q[J]:void 0}function E50(J){var Q=this.__data__;return fW?Q[J]!==void 0:DD.call(Q,J)}function A50(J,Q){var Z=this.__data__;return Z[J]=fW&&Q===void 0?OD:Q,this}wq.prototype.clear=j50;wq.prototype.delete=R50;wq.prototype.get=k50;wq.prototype.has=E50;wq.prototype.set=A50;function lX(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 C50(){this.__data__=[]}function P50(J){var Q=this.__data__,Z=f_(Q,J);if(Z<0)return!1;var q=Q.length-1;if(Z==q)Q.pop();else D50.call(Q,Z,1);return!0}function I50(J){var Q=this.__data__,Z=f_(Q,J);return Z<0?void 0:Q[Z][1]}function w50(J){return f_(this.__data__,J)>-1}function b50(J,Q){var Z=this.__data__,q=f_(Z,J);if(q<0)Z.push([J,Q]);else Z[q][1]=Q;return this}lX.prototype.clear=C50;lX.prototype.delete=P50;lX.prototype.get=I50;lX.prototype.has=w50;lX.prototype.set=b50;function pX(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 T50(){this.__data__={hash:new wq,map:new(M50||lX),string:new wq}}function y50(J){return g_(this,J).delete(J)}function x50(J){return g_(this,J).get(J)}function v50(J){return g_(this,J).has(J)}function S50(J,Q){return g_(this,J).set(J,Q),this}pX.prototype.clear=T50;pX.prototype.delete=y50;pX.prototype.get=x50;pX.prototype.has=v50;pX.prototype.set=S50;function S_(J){var Q=-1,Z=J?J.length:0;this.__data__=new pX;while(++Q<Z)this.add(J[Q])}function f50(J){return this.__data__.set(J,OD),this}function g50(J){return this.__data__.has(J)}S_.prototype.add=S_.prototype.push=f50;S_.prototype.has=g50;function f_(J,Q){var Z=J.length;while(Z--)if(i50(J[Z][0],Q))return Z;return-1}function h50(J){if(!ty(J)||l50(J))return!1;var Q=n50(J)||V50(J)?L50:K50;return Q.test(p50(J))}function u50(J,Q,Z){var q=-1,X=z50,K=J.length,Y=!0,W=[],z=W;if(Z)Y=!1,X=G50;else if(K>=J50){var G=Q?null:m50(J);if(G)return ry(G);Y=!1,X=F50,z=new S_}else z=Q?[]:W;J:while(++q<K){var H=J[q],$=Q?Q(H):H;if(H=Z||H!==0?H:0,Y&&$===$){var _=z.length;while(_--)if(z[_]===$)continue J;if(Q)z.push($);W.push(H)}else if(!X(z,$,Z)){if(z!==W)z.push($);W.push(H)}}return W}var m50=!(BD&&1/ry(new BD([,-0]))[1]==Q50)?s50:function(J){return new BD(J)};function g_(J,Q){var Z=J.__data__;return c50(Q)?Z[typeof Q=="string"?"string":"hash"]:Z.map}function MD(J,Q){var Z=U50(J,Q);return h50(Z)?Z:void 0}function c50(J){var Q=typeof J;return Q=="string"||Q=="number"||Q=="symbol"||Q=="boolean"?J!=="__proto__":J===null}function l50(J){return!!sy&&sy in J}function p50(J){if(J!=null){try{return oy.call(J)}catch(Q){}try{return J+""}catch(Q){}}return""}function d50(J){return J&&J.length?u50(J):[]}function i50(J,Q){return J===Q||J!==J&&Q!==Q}function n50(J){var Q=ty(J)?O50.call(J):"";return Q==Z50||Q==q50}function ty(J){var Q=typeof J;return!!J&&(Q=="object"||Q=="function")}function s50(){}ey.exports=d50});var c1=fQ((gP0,UF)=>{/*!
1
+ import"/chunk-pcnahct1.js";import{b as KZ,c as z20,n as bd,o as Td,p as yd,q as xd,r as vd,s as Sd,t as fd,u as gd,v as hd,w as wT,y as g00}from"/chunk-55sh4dty.js";import{Cc as IT,Da as yQ,Db as E00,Ga as j00,Gb as A00,Gc as B00,Na as R00,O as m,Ob as C00,Oc as f00,P as c,Sc as b00,jc as P00,pc as PT,sb as k00,tc as I00,vc as w00}from"/chunk-exj6hr30.js";import{Uc as E,Vc as fQ,Wc as T7,Xc as hp}from"/chunk-9y2zbzqz.js";var Fy=fQ((F_,gX)=>{var c00=200,JD="__lodash_hash_undefined__",M_=1,pT=2,dT=9007199254740991,U_="[object Arguments]",nL="[object Array]",l00="[object AsyncFunction]",iT="[object Boolean]",nT="[object Date]",sT="[object Error]",rT="[object Function]",p00="[object GeneratorFunction]",V_="[object Map]",aT="[object Number]",d00="[object Null]",fX="[object Object]",yT="[object Promise]",i00="[object Proxy]",oT="[object RegExp]",N_="[object Set]",tT="[object String]",n00="[object Symbol]",s00="[object Undefined]",sL="[object WeakMap]",eT="[object ArrayBuffer]",B_="[object DataView]",r00="[object Float32Array]",a00="[object Float64Array]",o00="[object Int8Array]",t00="[object Int16Array]",e00="[object Int32Array]",J10="[object Uint8Array]",Q10="[object Uint8ClampedArray]",Z10="[object Uint16Array]",q10="[object Uint32Array]",X10=/[\\^$.*+?()[\]{}|]/g,K10=/^\[object .+?Constructor\]$/,Y10=/^(?:0|[1-9]\d*)$/,m4={};m4[r00]=m4[a00]=m4[o00]=m4[t00]=m4[e00]=m4[J10]=m4[Q10]=m4[Z10]=m4[q10]=!0;m4[U_]=m4[nL]=m4[eT]=m4[iT]=m4[B_]=m4[nT]=m4[sT]=m4[rT]=m4[V_]=m4[aT]=m4[fX]=m4[oT]=m4[N_]=m4[tT]=m4[sL]=!1;var Jy=typeof global=="object"&&global&&global.Object===Object&&global,W10=typeof self=="object"&&self&&self.Object===Object&&self,YJ=Jy||W10||Function("return this")(),Qy=typeof F_=="object"&&F_&&!F_.nodeType&&F_,xT=Qy&&typeof gX=="object"&&gX&&!gX.nodeType&&gX,Zy=xT&&xT.exports===Qy,pL=Zy&&Jy.process,vT=function(){try{return pL&&pL.binding&&pL.binding("util")}catch(J){}}(),ST=vT&&vT.isTypedArray;function z10(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 G10(J,Q){var Z=-1,q=Q.length,X=J.length;while(++Z<q)J[X+Z]=Q[Z];return J}function $10(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 H10(J,Q){var Z=-1,q=Array(J);while(++Z<J)q[Z]=Q(Z);return q}function _10(J){return function(Q){return J(Q)}}function F10(J,Q){return J.has(Q)}function U10(J,Q){return J==null?void 0:J[Q]}function V10(J){var Q=-1,Z=Array(J.size);return J.forEach(function(q,X){Z[++Q]=[X,q]}),Z}function N10(J,Q){return function(Z){return J(Q(Z))}}function B10(J){var Q=-1,Z=Array(J.size);return J.forEach(function(q){Z[++Q]=q}),Z}var O10=Array.prototype,L10=Function.prototype,j_=Object.prototype,dL=YJ["__core-js_shared__"],qy=L10.toString,_2=j_.hasOwnProperty,fT=function(){var J=/[^.]+$/.exec(dL&&dL.keys&&dL.keys.IE_PROTO||"");return J?"Symbol(src)_1."+J:""}(),Xy=j_.toString,D10=RegExp("^"+qy.call(_2).replace(X10,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),gT=Zy?YJ.Buffer:void 0,O_=YJ.Symbol,hT=YJ.Uint8Array,Ky=j_.propertyIsEnumerable,M10=O10.splice,Rq=O_?O_.toStringTag:void 0,uT=Object.getOwnPropertySymbols,j10=gT?gT.isBuffer:void 0,R10=N10(Object.keys,Object),rL=hX(YJ,"DataView"),wW=hX(YJ,"Map"),aL=hX(YJ,"Promise"),oL=hX(YJ,"Set"),tL=hX(YJ,"WeakMap"),bW=hX(Object,"create"),k10=Aq(rL),E10=Aq(wW),A10=Aq(aL),C10=Aq(oL),P10=Aq(tL),mT=O_?O_.prototype:void 0,iL=mT?mT.valueOf:void 0;function kq(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 I10(){this.__data__=bW?bW(null):{},this.size=0}function w10(J){var Q=this.has(J)&&delete this.__data__[J];return this.size-=Q?1:0,Q}function b10(J){var Q=this.__data__;if(bW){var Z=Q[J];return Z===JD?void 0:Z}return _2.call(Q,J)?Q[J]:void 0}function T10(J){var Q=this.__data__;return bW?Q[J]!==void 0:_2.call(Q,J)}function y10(J,Q){var Z=this.__data__;return this.size+=this.has(J)?0:1,Z[J]=bW&&Q===void 0?JD:Q,this}kq.prototype.clear=I10;kq.prototype.delete=w10;kq.prototype.get=b10;kq.prototype.has=T10;kq.prototype.set=y10;function WJ(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 x10(){this.__data__=[],this.size=0}function v10(J){var Q=this.__data__,Z=R_(Q,J);if(Z<0)return!1;var q=Q.length-1;if(Z==q)Q.pop();else M10.call(Q,Z,1);return--this.size,!0}function S10(J){var Q=this.__data__,Z=R_(Q,J);return Z<0?void 0:Q[Z][1]}function f10(J){return R_(this.__data__,J)>-1}function g10(J,Q){var Z=this.__data__,q=R_(Z,J);if(q<0)++this.size,Z.push([J,Q]);else Z[q][1]=Q;return this}WJ.prototype.clear=x10;WJ.prototype.delete=v10;WJ.prototype.get=S10;WJ.prototype.has=f10;WJ.prototype.set=g10;function Eq(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 h10(){this.size=0,this.__data__={hash:new kq,map:new(wW||WJ),string:new kq}}function u10(J){var Q=k_(this,J).delete(J);return this.size-=Q?1:0,Q}function m10(J){return k_(this,J).get(J)}function c10(J){return k_(this,J).has(J)}function l10(J,Q){var Z=k_(this,J),q=Z.size;return Z.set(J,Q),this.size+=Z.size==q?0:1,this}Eq.prototype.clear=h10;Eq.prototype.delete=u10;Eq.prototype.get=m10;Eq.prototype.has=c10;Eq.prototype.set=l10;function L_(J){var Q=-1,Z=J==null?0:J.length;this.__data__=new Eq;while(++Q<Z)this.add(J[Q])}function p10(J){return this.__data__.set(J,JD),this}function d10(J){return this.__data__.has(J)}L_.prototype.add=L_.prototype.push=p10;L_.prototype.has=d10;function SQ(J){var Q=this.__data__=new WJ(J);this.size=Q.size}function i10(){this.__data__=new WJ,this.size=0}function n10(J){var Q=this.__data__,Z=Q.delete(J);return this.size=Q.size,Z}function s10(J){return this.__data__.get(J)}function r10(J){return this.__data__.has(J)}function a10(J,Q){var Z=this.__data__;if(Z instanceof WJ){var q=Z.__data__;if(!wW||q.length<c00-1)return q.push([J,Q]),this.size=++Z.size,this;Z=this.__data__=new Eq(q)}return Z.set(J,Q),this.size=Z.size,this}SQ.prototype.clear=i10;SQ.prototype.delete=n10;SQ.prototype.get=s10;SQ.prototype.has=r10;SQ.prototype.set=a10;function o10(J,Q){var Z=D_(J),q=!Z&&_40(J),X=!Z&&!q&&eL(J),K=!Z&&!q&&!X&&_y(J),Y=Z||q||X||K,W=Y?H10(J.length,String):[],z=W.length;for(var G in J)if((Q||_2.call(J,G))&&!(Y&&(G=="length"||X&&(G=="offset"||G=="parent")||K&&(G=="buffer"||G=="byteLength"||G=="byteOffset")||W40(G,z))))W.push(G);return W}function R_(J,Q){var Z=J.length;while(Z--)if(zy(J[Z][0],Q))return Z;return-1}function t10(J,Q,Z){var q=Q(J);return D_(J)?q:G10(q,Z(J))}function yW(J){if(J==null)return J===void 0?s00:d00;return Rq&&Rq in Object(J)?K40(J):H40(J)}function cT(J){return TW(J)&&yW(J)==U_}function Yy(J,Q,Z,q,X){if(J===Q)return!0;if(J==null||Q==null||!TW(J)&&!TW(Q))return J!==J&&Q!==Q;return e10(J,Q,Z,q,Yy,X)}function e10(J,Q,Z,q,X,K){var Y=D_(J),W=D_(Q),z=Y?nL:vQ(J),G=W?nL:vQ(Q);z=z==U_?fX:z,G=G==U_?fX:G;var H=z==fX,$=G==fX,_=z==G;if(_&&eL(J)){if(!eL(Q))return!1;Y=!0,H=!1}if(_&&!H)return K||(K=new SQ),Y||_y(J)?Wy(J,Q,Z,q,X,K):q40(J,Q,z,Z,q,X,K);if(!(Z&M_)){var F=H&&_2.call(J,"__wrapped__"),U=$&&_2.call(Q,"__wrapped__");if(F||U){var V=F?J.value():J,N=U?Q.value():Q;return K||(K=new SQ),X(V,N,Z,q,K)}}if(!_)return!1;return K||(K=new SQ),X40(J,Q,Z,q,X,K)}function J40(J){if(!Hy(J)||G40(J))return!1;var Q=Gy(J)?D10:K10;return Q.test(Aq(J))}function Q40(J){return TW(J)&&$y(J.length)&&!!m4[yW(J)]}function Z40(J){if(!$40(J))return R10(J);var Q=[];for(var Z in Object(J))if(_2.call(J,Z)&&Z!="constructor")Q.push(Z);return Q}function Wy(J,Q,Z,q,X,K){var Y=Z&M_,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 H=-1,$=!0,_=Z&pT?new L_:void 0;K.set(J,Q),K.set(Q,J);while(++H<W){var F=J[H],U=Q[H];if(q)var V=Y?q(U,F,H,Q,J,K):q(F,U,H,J,Q,K);if(V!==void 0){if(V)continue;$=!1;break}if(_){if(!$10(Q,function(N,B){if(!F10(_,B)&&(F===N||X(F,N,Z,q,K)))return _.push(B)})){$=!1;break}}else if(!(F===U||X(F,U,Z,q,K))){$=!1;break}}return K.delete(J),K.delete(Q),$}function q40(J,Q,Z,q,X,K,Y){switch(Z){case B_:if(J.byteLength!=Q.byteLength||J.byteOffset!=Q.byteOffset)return!1;J=J.buffer,Q=Q.buffer;case eT:if(J.byteLength!=Q.byteLength||!K(new hT(J),new hT(Q)))return!1;return!0;case iT:case nT:case aT:return zy(+J,+Q);case sT:return J.name==Q.name&&J.message==Q.message;case oT:case tT:return J==Q+"";case V_:var W=V10;case N_:var z=q&M_;if(W||(W=B10),J.size!=Q.size&&!z)return!1;var G=Y.get(J);if(G)return G==Q;q|=pT,Y.set(J,Q);var H=Wy(W(J),W(Q),q,X,K,Y);return Y.delete(J),H;case n00:if(iL)return iL.call(J)==iL.call(Q)}return!1}function X40(J,Q,Z,q,X,K){var Y=Z&M_,W=lT(J),z=W.length,G=lT(Q),H=G.length;if(z!=H&&!Y)return!1;var $=z;while($--){var _=W[$];if(!(Y?_ in Q:_2.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(++$<z){_=W[$];var N=J[_],B=Q[_];if(q)var O=Y?q(B,N,_,Q,J,K):q(N,B,_,J,Q,K);if(!(O===void 0?N===B||X(N,B,Z,q,K):O)){U=!1;break}V||(V=_=="constructor")}if(U&&!V){var M=J.constructor,L=Q.constructor;if(M!=L&&(("constructor"in J)&&("constructor"in Q))&&!(typeof M=="function"&&M instanceof M&&typeof L=="function"&&L instanceof L))U=!1}return K.delete(J),K.delete(Q),U}function lT(J){return t10(J,V40,Y40)}function k_(J,Q){var Z=J.__data__;return z40(Q)?Z[typeof Q=="string"?"string":"hash"]:Z.map}function hX(J,Q){var Z=U10(J,Q);return J40(Z)?Z:void 0}function K40(J){var Q=_2.call(J,Rq),Z=J[Rq];try{J[Rq]=void 0;var q=!0}catch(K){}var X=Xy.call(J);if(q)if(Q)J[Rq]=Z;else delete J[Rq];return X}var Y40=!uT?N40:function(J){if(J==null)return[];return J=Object(J),z10(uT(J),function(Q){return Ky.call(J,Q)})},vQ=yW;if(rL&&vQ(new rL(new ArrayBuffer(1)))!=B_||wW&&vQ(new wW)!=V_||aL&&vQ(aL.resolve())!=yT||oL&&vQ(new oL)!=N_||tL&&vQ(new tL)!=sL)vQ=function(J){var Q=yW(J),Z=Q==fX?J.constructor:void 0,q=Z?Aq(Z):"";if(q)switch(q){case k10:return B_;case E10:return V_;case A10:return yT;case C10:return N_;case P10:return sL}return Q};function W40(J,Q){return Q=Q==null?dT:Q,!!Q&&(typeof J=="number"||Y10.test(J))&&(J>-1&&J%1==0&&J<Q)}function z40(J){var Q=typeof J;return Q=="string"||Q=="number"||Q=="symbol"||Q=="boolean"?J!=="__proto__":J===null}function G40(J){return!!fT&&fT in J}function $40(J){var Q=J&&J.constructor,Z=typeof Q=="function"&&Q.prototype||j_;return J===Z}function H40(J){return Xy.call(J)}function Aq(J){if(J!=null){try{return qy.call(J)}catch(Q){}try{return J+""}catch(Q){}}return""}function zy(J,Q){return J===Q||J!==J&&Q!==Q}var _40=cT(function(){return arguments}())?cT:function(J){return TW(J)&&_2.call(J,"callee")&&!Ky.call(J,"callee")},D_=Array.isArray;function F40(J){return J!=null&&$y(J.length)&&!Gy(J)}var eL=j10||B40;function U40(J,Q){return Yy(J,Q)}function Gy(J){if(!Hy(J))return!1;var Q=yW(J);return Q==rT||Q==p00||Q==l00||Q==i00}function $y(J){return typeof J=="number"&&J>-1&&J%1==0&&J<=dT}function Hy(J){var Q=typeof J;return J!=null&&(Q=="object"||Q=="function")}function TW(J){return J!=null&&typeof J=="object"}var _y=ST?_10(ST):Q40;function V40(J){return F40(J)?o10(J):Z40(J)}function N40(){return[]}function B40(){return!1}gX.exports=U40});var UD=fQ((E_,mX)=>{var O40=200,HD="__lodash_hash_undefined__",ky=1,b_=2,Ey=9007199254740991,A_="[object Arguments]",qD="[object Array]",Ay="[object Boolean]",Cy="[object Date]",Py="[object Error]",Iy="[object Function]",L40="[object GeneratorFunction]",C_="[object Map]",wy="[object Number]",uX="[object Object]",Uy="[object Promise]",by="[object RegExp]",P_="[object Set]",Ty="[object String]",D40="[object Symbol]",XD="[object WeakMap]",yy="[object ArrayBuffer]",I_="[object DataView]",M40="[object Float32Array]",j40="[object Float64Array]",R40="[object Int8Array]",k40="[object Int16Array]",E40="[object Int32Array]",A40="[object Uint8Array]",C40="[object Uint8ClampedArray]",P40="[object Uint16Array]",I40="[object Uint32Array]",w40=/[\\^$.*+?()[\]{}|]/g,b40=/^\[object .+?Constructor\]$/,T40=/^(?:0|[1-9]\d*)$/,c4={};c4[M40]=c4[j40]=c4[R40]=c4[k40]=c4[E40]=c4[A40]=c4[C40]=c4[P40]=c4[I40]=!0;c4[A_]=c4[qD]=c4[yy]=c4[Ay]=c4[I_]=c4[Cy]=c4[Py]=c4[Iy]=c4[C_]=c4[wy]=c4[uX]=c4[by]=c4[P_]=c4[Ty]=c4[XD]=!1;var xy=typeof global=="object"&&global&&global.Object===Object&&global,y40=typeof self=="object"&&self&&self.Object===Object&&self,uQ=xy||y40||Function("return this")(),vy=typeof E_=="object"&&E_&&!E_.nodeType&&E_,Vy=vy&&typeof mX=="object"&&mX&&!mX.nodeType&&mX,x40=Vy&&Vy.exports===vy,Ny=x40&&xy.process,By=function(){try{return Ny&&Ny.binding("util")}catch(J){}}(),Oy=By&&By.isTypedArray;function v40(J,Q){var Z=-1,q=J?J.length:0;while(++Z<q)if(Q(J[Z],Z,J))return!0;return!1}function S40(J,Q){var Z=-1,q=Array(J);while(++Z<J)q[Z]=Q(Z);return q}function f40(J){return function(Q){return J(Q)}}function g40(J,Q){return J==null?void 0:J[Q]}function KD(J){var Q=!1;if(J!=null&&typeof J.toString!="function")try{Q=!!(J+"")}catch(Z){}return Q}function h40(J){var Q=-1,Z=Array(J.size);return J.forEach(function(q,X){Z[++Q]=[X,q]}),Z}function u40(J,Q){return function(Z){return J(Q(Z))}}function m40(J){var Q=-1,Z=Array(J.size);return J.forEach(function(q){Z[++Q]=q}),Z}var c40=Array.prototype,l40=Function.prototype,T_=Object.prototype,QD=uQ["__core-js_shared__"],Ly=function(){var J=/[^.]+$/.exec(QD&&QD.keys&&QD.keys.IE_PROTO||"");return J?"Symbol(src)_1."+J:""}(),Sy=l40.toString,zJ=T_.hasOwnProperty,SW=T_.toString,p40=RegExp("^"+Sy.call(zJ).replace(w40,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Dy=uQ.Symbol,My=uQ.Uint8Array,d40=T_.propertyIsEnumerable,i40=c40.splice,n40=u40(Object.keys,Object),YD=cX(uQ,"DataView"),xW=cX(uQ,"Map"),WD=cX(uQ,"Promise"),zD=cX(uQ,"Set"),GD=cX(uQ,"WeakMap"),vW=cX(Object,"create"),s40=Iq(YD),r40=Iq(xW),a40=Iq(WD),o40=Iq(zD),t40=Iq(GD),jy=Dy?Dy.prototype:void 0,ZD=jy?jy.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 e40(){this.__data__=vW?vW(null):{}}function J60(J){return this.has(J)&&delete this.__data__[J]}function Q60(J){var Q=this.__data__;if(vW){var Z=Q[J];return Z===HD?void 0:Z}return zJ.call(Q,J)?Q[J]:void 0}function Z60(J){var Q=this.__data__;return vW?Q[J]!==void 0:zJ.call(Q,J)}function q60(J,Q){var Z=this.__data__;return Z[J]=vW&&Q===void 0?HD:Q,this}Cq.prototype.clear=e40;Cq.prototype.delete=J60;Cq.prototype.get=Q60;Cq.prototype.has=Z60;Cq.prototype.set=q60;function GJ(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 X60(){this.__data__=[]}function K60(J){var Q=this.__data__,Z=y_(Q,J);if(Z<0)return!1;var q=Q.length-1;if(Z==q)Q.pop();else i40.call(Q,Z,1);return!0}function Y60(J){var Q=this.__data__,Z=y_(Q,J);return Z<0?void 0:Q[Z][1]}function W60(J){return y_(this.__data__,J)>-1}function z60(J,Q){var Z=this.__data__,q=y_(Z,J);if(q<0)Z.push([J,Q]);else Z[q][1]=Q;return this}GJ.prototype.clear=X60;GJ.prototype.delete=K60;GJ.prototype.get=Y60;GJ.prototype.has=W60;GJ.prototype.set=z60;function Pq(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 G60(){this.__data__={hash:new Cq,map:new(xW||GJ),string:new Cq}}function $60(J){return x_(this,J).delete(J)}function H60(J){return x_(this,J).get(J)}function _60(J){return x_(this,J).has(J)}function F60(J,Q){return x_(this,J).set(J,Q),this}Pq.prototype.clear=G60;Pq.prototype.delete=$60;Pq.prototype.get=H60;Pq.prototype.has=_60;Pq.prototype.set=F60;function w_(J){var Q=-1,Z=J?J.length:0;this.__data__=new Pq;while(++Q<Z)this.add(J[Q])}function U60(J){return this.__data__.set(J,HD),this}function V60(J){return this.__data__.has(J)}w_.prototype.add=w_.prototype.push=U60;w_.prototype.has=V60;function hQ(J){this.__data__=new GJ(J)}function N60(){this.__data__=new GJ}function B60(J){return this.__data__.delete(J)}function O60(J){return this.__data__.get(J)}function L60(J){return this.__data__.has(J)}function D60(J,Q){var Z=this.__data__;if(Z instanceof GJ){var q=Z.__data__;if(!xW||q.length<O40-1)return q.push([J,Q]),this;Z=this.__data__=new Pq(q)}return Z.set(J,Q),this}hQ.prototype.clear=N60;hQ.prototype.delete=B60;hQ.prototype.get=O60;hQ.prototype.has=L60;hQ.prototype.set=D60;function M60(J,Q){var Z=$D(J)||y60(J)?S40(J.length,String):[],q=Z.length,X=!!q;for(var K in J)if((Q||zJ.call(J,K))&&!(X&&(K=="length"||I60(K,q))))Z.push(K);return Z}function y_(J,Q){var Z=J.length;while(Z--)if(hy(J[Z][0],Q))return Z;return-1}function j60(J){return SW.call(J)}function fy(J,Q,Z,q,X){if(J===Q)return!0;if(J==null||Q==null||!_D(J)&&!FD(Q))return J!==J&&Q!==Q;return R60(J,Q,fy,Z,q,X)}function R60(J,Q,Z,q,X,K){var Y=$D(J),W=$D(Q),z=qD,G=qD;if(!Y)z=gQ(J),z=z==A_?uX:z;if(!W)G=gQ(Q),G=G==A_?uX:G;var H=z==uX&&!KD(J),$=G==uX&&!KD(Q),_=z==G;if(_&&!H)return K||(K=new hQ),Y||S60(J)?gy(J,Q,Z,q,X,K):C60(J,Q,z,Z,q,X,K);if(!(X&b_)){var F=H&&zJ.call(J,"__wrapped__"),U=$&&zJ.call(Q,"__wrapped__");if(F||U){var V=F?J.value():J,N=U?Q.value():Q;return K||(K=new hQ),Z(V,N,q,X,K)}}if(!_)return!1;return K||(K=new hQ),P60(J,Q,Z,q,X,K)}function k60(J){if(!_D(J)||b60(J))return!1;var Q=my(J)||KD(J)?p40:b40;return Q.test(Iq(J))}function E60(J){return FD(J)&&cy(J.length)&&!!c4[SW.call(J)]}function A60(J){if(!T60(J))return n40(J);var Q=[];for(var Z in Object(J))if(zJ.call(J,Z)&&Z!="constructor")Q.push(Z);return Q}function gy(J,Q,Z,q,X,K){var Y=X&b_,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 H=-1,$=!0,_=X&ky?new w_:void 0;K.set(J,Q),K.set(Q,J);while(++H<W){var F=J[H],U=Q[H];if(q)var V=Y?q(U,F,H,Q,J,K):q(F,U,H,J,Q,K);if(V!==void 0){if(V)continue;$=!1;break}if(_){if(!v40(Q,function(N,B){if(!_.has(B)&&(F===N||Z(F,N,q,X,K)))return _.add(B)})){$=!1;break}}else if(!(F===U||Z(F,U,q,X,K))){$=!1;break}}return K.delete(J),K.delete(Q),$}function C60(J,Q,Z,q,X,K,Y){switch(Z){case I_:if(J.byteLength!=Q.byteLength||J.byteOffset!=Q.byteOffset)return!1;J=J.buffer,Q=Q.buffer;case yy:if(J.byteLength!=Q.byteLength||!q(new My(J),new My(Q)))return!1;return!0;case Ay:case Cy:case wy:return hy(+J,+Q);case Py:return J.name==Q.name&&J.message==Q.message;case by:case Ty:return J==Q+"";case C_:var W=h40;case P_:var z=K&b_;if(W||(W=m40),J.size!=Q.size&&!z)return!1;var G=Y.get(J);if(G)return G==Q;K|=ky,Y.set(J,Q);var H=gy(W(J),W(Q),q,X,K,Y);return Y.delete(J),H;case D40:if(ZD)return ZD.call(J)==ZD.call(Q)}return!1}function P60(J,Q,Z,q,X,K){var Y=X&b_,W=Ry(J),z=W.length,G=Ry(Q),H=G.length;if(z!=H&&!Y)return!1;var $=z;while($--){var _=W[$];if(!(Y?_ in Q:zJ.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(++$<z){_=W[$];var N=J[_],B=Q[_];if(q)var O=Y?q(B,N,_,Q,J,K):q(N,B,_,J,Q,K);if(!(O===void 0?N===B||Z(N,B,q,X,K):O)){U=!1;break}V||(V=_=="constructor")}if(U&&!V){var M=J.constructor,L=Q.constructor;if(M!=L&&(("constructor"in J)&&("constructor"in Q))&&!(typeof M=="function"&&M instanceof M&&typeof L=="function"&&L instanceof L))U=!1}return K.delete(J),K.delete(Q),U}function x_(J,Q){var Z=J.__data__;return w60(Q)?Z[typeof Q=="string"?"string":"hash"]:Z.map}function cX(J,Q){var Z=g40(J,Q);return k60(Z)?Z:void 0}var gQ=j60;if(YD&&gQ(new YD(new ArrayBuffer(1)))!=I_||xW&&gQ(new xW)!=C_||WD&&gQ(WD.resolve())!=Uy||zD&&gQ(new zD)!=P_||GD&&gQ(new GD)!=XD)gQ=function(J){var Q=SW.call(J),Z=Q==uX?J.constructor:void 0,q=Z?Iq(Z):void 0;if(q)switch(q){case s40:return I_;case r40:return C_;case a40:return Uy;case o40:return P_;case t40:return XD}return Q};function I60(J,Q){return Q=Q==null?Ey:Q,!!Q&&(typeof J=="number"||T40.test(J))&&(J>-1&&J%1==0&&J<Q)}function w60(J){var Q=typeof J;return Q=="string"||Q=="number"||Q=="symbol"||Q=="boolean"?J!=="__proto__":J===null}function b60(J){return!!Ly&&Ly in J}function T60(J){var Q=J&&J.constructor,Z=typeof Q=="function"&&Q.prototype||T_;return J===Z}function Iq(J){if(J!=null){try{return Sy.call(J)}catch(Q){}try{return J+""}catch(Q){}}return""}function hy(J,Q){return J===Q||J!==J&&Q!==Q}function y60(J){return x60(J)&&zJ.call(J,"callee")&&(!d40.call(J,"callee")||SW.call(J)==A_)}var $D=Array.isArray;function uy(J){return J!=null&&cy(J.length)&&!my(J)}function x60(J){return FD(J)&&uy(J)}function v60(J,Q,Z){Z=typeof Z=="function"?Z:void 0;var q=Z?Z(J,Q):void 0;return q===void 0?fy(J,Q,Z):!!q}function my(J){var Q=_D(J)?SW.call(J):"";return Q==Iy||Q==L40}function cy(J){return typeof J=="number"&&J>-1&&J%1==0&&J<=Ey}function _D(J){var Q=typeof J;return!!J&&(Q=="object"||Q=="function")}function FD(J){return!!J&&typeof J=="object"}var S60=Oy?f40(Oy):E60;function Ry(J){return uy(J)?M60(J):A60(J)}mX.exports=v60});var ny=fQ((kB0,iy)=>{var dy="Expected a function",ly=NaN,f60="[object Symbol]",g60=/^\s+|\s+$/g,h60=/^[-+]0x[0-9a-f]+$/i,u60=/^0b[01]+$/i,m60=/^0o[0-7]+$/i,c60=parseInt,l60=typeof global=="object"&&global&&global.Object===Object&&global,p60=typeof self=="object"&&self&&self.Object===Object&&self,d60=l60||p60||Function("return this")(),i60=Object.prototype,n60=i60.toString,s60=Math.max,r60=Math.min,VD=function(){return d60.Date.now()};function a60(J,Q,Z){var q,X,K,Y,W,z,G=0,H=!1,$=!1,_=!0;if(typeof J!="function")throw TypeError(dy);if(Q=py(Q)||0,v_(Z))H=!!Z.leading,$="maxWait"in Z,K=$?s60(py(Z.maxWait)||0,Q):K,_="trailing"in Z?!!Z.trailing:_;function F(k){var R=q,I=X;return q=X=void 0,G=k,Y=J.apply(I,R),Y}function U(k){return G=k,W=setTimeout(B,Q),H?F(k):Y}function V(k){var R=k-z,I=k-G,A=Q-R;return $?r60(A,K-I):A}function N(k){var R=k-z,I=k-G;return z===void 0||R>=Q||R<0||$&&I>=K}function B(){var k=VD();if(N(k))return O(k);W=setTimeout(B,V(k))}function O(k){if(W=void 0,_&&q)return F(k);return q=X=void 0,Y}function M(){if(W!==void 0)clearTimeout(W);G=0,q=z=X=W=void 0}function L(){return W===void 0?Y:O(VD())}function j(){var k=VD(),R=N(k);if(q=arguments,X=this,z=k,R){if(W===void 0)return U(z);if($)return W=setTimeout(B,Q),F(z)}if(W===void 0)W=setTimeout(B,Q);return Y}return j.cancel=M,j.flush=L,j}function o60(J,Q,Z){var q=!0,X=!0;if(typeof J!="function")throw TypeError(dy);if(v_(Z))q="leading"in Z?!!Z.leading:q,X="trailing"in Z?!!Z.trailing:X;return a60(J,Q,{leading:q,maxWait:Q,trailing:X})}function v_(J){var Q=typeof J;return!!J&&(Q=="object"||Q=="function")}function t60(J){return!!J&&typeof J=="object"}function e60(J){return typeof J=="symbol"||t60(J)&&n60.call(J)==f60}function py(J){if(typeof J=="number")return J;if(e60(J))return ly;if(v_(J)){var Q=typeof J.valueOf=="function"?J.valueOf():J;J=v_(Q)?Q+"":Q}if(typeof J!="string")return J===0?J:+J;J=J.replace(g60,"");var Z=u60.test(J);return Z||m60.test(J)?c60(J.slice(2),Z?2:8):h60.test(J)?ly:+J}iy.exports=o60});var Jx=fQ((EB0,ey)=>{var J50=200,OD="__lodash_hash_undefined__",Q50=1/0,Z50="[object Function]",q50="[object GeneratorFunction]",X50=/[\\^$.*+?()[\]{}|]/g,K50=/^\[object .+?Constructor\]$/,Y50=typeof global=="object"&&global&&global.Object===Object&&global,W50=typeof self=="object"&&self&&self.Object===Object&&self,LD=Y50||W50||Function("return this")();function z50(J,Q){var Z=J?J.length:0;return!!Z&&H50(J,Q,0)>-1}function G50(J,Q,Z){var q=-1,X=J?J.length:0;while(++q<X)if(Z(Q,J[q]))return!0;return!1}function $50(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 H50(J,Q,Z){if(Q!==Q)return $50(J,_50,Z);var q=Z-1,X=J.length;while(++q<X)if(J[q]===Q)return q;return-1}function _50(J){return J!==J}function F50(J,Q){return J.has(Q)}function U50(J,Q){return J==null?void 0:J[Q]}function V50(J){var Q=!1;if(J!=null&&typeof J.toString!="function")try{Q=!!(J+"")}catch(Z){}return Q}function ry(J){var Q=-1,Z=Array(J.size);return J.forEach(function(q){Z[++Q]=q}),Z}var N50=Array.prototype,B50=Function.prototype,ay=Object.prototype,ND=LD["__core-js_shared__"],sy=function(){var J=/[^.]+$/.exec(ND&&ND.keys&&ND.keys.IE_PROTO||"");return J?"Symbol(src)_1."+J:""}(),oy=B50.toString,DD=ay.hasOwnProperty,O50=ay.toString,L50=RegExp("^"+oy.call(DD).replace(X50,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),D50=N50.splice,M50=MD(LD,"Map"),BD=MD(LD,"Set"),fW=MD(Object,"create");function wq(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 j50(){this.__data__=fW?fW(null):{}}function R50(J){return this.has(J)&&delete this.__data__[J]}function k50(J){var Q=this.__data__;if(fW){var Z=Q[J];return Z===OD?void 0:Z}return DD.call(Q,J)?Q[J]:void 0}function E50(J){var Q=this.__data__;return fW?Q[J]!==void 0:DD.call(Q,J)}function A50(J,Q){var Z=this.__data__;return Z[J]=fW&&Q===void 0?OD:Q,this}wq.prototype.clear=j50;wq.prototype.delete=R50;wq.prototype.get=k50;wq.prototype.has=E50;wq.prototype.set=A50;function lX(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 C50(){this.__data__=[]}function P50(J){var Q=this.__data__,Z=f_(Q,J);if(Z<0)return!1;var q=Q.length-1;if(Z==q)Q.pop();else D50.call(Q,Z,1);return!0}function I50(J){var Q=this.__data__,Z=f_(Q,J);return Z<0?void 0:Q[Z][1]}function w50(J){return f_(this.__data__,J)>-1}function b50(J,Q){var Z=this.__data__,q=f_(Z,J);if(q<0)Z.push([J,Q]);else Z[q][1]=Q;return this}lX.prototype.clear=C50;lX.prototype.delete=P50;lX.prototype.get=I50;lX.prototype.has=w50;lX.prototype.set=b50;function pX(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 T50(){this.__data__={hash:new wq,map:new(M50||lX),string:new wq}}function y50(J){return g_(this,J).delete(J)}function x50(J){return g_(this,J).get(J)}function v50(J){return g_(this,J).has(J)}function S50(J,Q){return g_(this,J).set(J,Q),this}pX.prototype.clear=T50;pX.prototype.delete=y50;pX.prototype.get=x50;pX.prototype.has=v50;pX.prototype.set=S50;function S_(J){var Q=-1,Z=J?J.length:0;this.__data__=new pX;while(++Q<Z)this.add(J[Q])}function f50(J){return this.__data__.set(J,OD),this}function g50(J){return this.__data__.has(J)}S_.prototype.add=S_.prototype.push=f50;S_.prototype.has=g50;function f_(J,Q){var Z=J.length;while(Z--)if(i50(J[Z][0],Q))return Z;return-1}function h50(J){if(!ty(J)||l50(J))return!1;var Q=n50(J)||V50(J)?L50:K50;return Q.test(p50(J))}function u50(J,Q,Z){var q=-1,X=z50,K=J.length,Y=!0,W=[],z=W;if(Z)Y=!1,X=G50;else if(K>=J50){var G=Q?null:m50(J);if(G)return ry(G);Y=!1,X=F50,z=new S_}else z=Q?[]:W;J:while(++q<K){var H=J[q],$=Q?Q(H):H;if(H=Z||H!==0?H:0,Y&&$===$){var _=z.length;while(_--)if(z[_]===$)continue J;if(Q)z.push($);W.push(H)}else if(!X(z,$,Z)){if(z!==W)z.push($);W.push(H)}}return W}var m50=!(BD&&1/ry(new BD([,-0]))[1]==Q50)?s50:function(J){return new BD(J)};function g_(J,Q){var Z=J.__data__;return c50(Q)?Z[typeof Q=="string"?"string":"hash"]:Z.map}function MD(J,Q){var Z=U50(J,Q);return h50(Z)?Z:void 0}function c50(J){var Q=typeof J;return Q=="string"||Q=="number"||Q=="symbol"||Q=="boolean"?J!=="__proto__":J===null}function l50(J){return!!sy&&sy in J}function p50(J){if(J!=null){try{return oy.call(J)}catch(Q){}try{return J+""}catch(Q){}}return""}function d50(J){return J&&J.length?u50(J):[]}function i50(J,Q){return J===Q||J!==J&&Q!==Q}function n50(J){var Q=ty(J)?O50.call(J):"";return Q==Z50||Q==q50}function ty(J){var Q=typeof J;return!!J&&(Q=="object"||Q=="function")}function s50(){}ey.exports=d50});var c1=fQ((gP0,UF)=>{/*!
2
2
  Copyright (c) 2018 Jed Watson.
3
3
  Licensed under the MIT License (MIT), see
4
4
  http://jedwatson.github.io/classnames
@@ -373,7 +373,7 @@ ${Z}
373
373
  `).map((Q)=>Q||" ").join(`
374
374
  `)}}var rY0=/[\u0590-\u05FF\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]/;function zN(J){return rY0.test(J)}function aY0(J){return J.replace(/\t/g,Sp)}function oY0(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 fp={"&amp;":"&","&quot;":'"',"&apos;":"'","&#27;":"'","&#34;":'"',"&#38;":"&","&#39;":"'","&#8211;":"–","&#8212;":"—","&#8216;":"‘","&#8217;":"’","&#8220;":"“","&#8221;":"”","&#8230;":"…"},tY0=new RegExp(Object.keys(fp).join("|"),"g");function pE(J){return J.replace(tY0,(Q)=>fp[Q])}function eY0(J){return J.replace(/[ \t]+$/gm,"").replace(/\n+$/,"")}function gp(J){return eY0(oY0(aY0(J)))}var dE=5000,up=10485760;function iE(J,Q){J.registerExternalAssetHandler("file",async(Z)=>{return mp(J,Z,Q)}),J.registerExternalAssetHandler("url",async(Z)=>{return lp(J,Z,Q)}),J.registerExternalContentHandler("svg-text",async(Z)=>{return pp(J,Z)}),J.registerExternalContentHandler("embed",(Z)=>{return dp(J,Z)}),J.registerExternalContentHandler("files",async(Z)=>{return ip(J,Z,Q)}),J.registerExternalContentHandler("file-replace",async(Z)=>{return cp(J,Z,Q)}),J.registerExternalContentHandler("text",async(Z)=>{return DY(J,Z)}),J.registerExternalContentHandler("url",async(Z)=>{return np(J,Z,Q)}),J.registerExternalContentHandler("tldraw",async(Z)=>{return sp(J,Z)}),J.registerExternalContentHandler("excalidraw",async(Z)=>{return rp(J,Z)})}async function mp(J,{file:Q,assetId:Z},q){if(!GN(J,Q,q))Q0(!1,"File checks failed");let K=await sE(Q);if(!K)Q0(!1,"SVG file contained no safe content");let Y=await $N(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 M9.create(Y)}async function cp(J,{file:Q,shapeId:Z},q){if(!GN(J,Q,q))Q0(!1,"File checks failed");let K=await sE(Q);if(!K)return;let Y=J.getShape(Z);if(!Y)Q0(!1,"Shape not found");let W=u_(await K.arrayBuffer()),z=M9.createId(W);J.createTemporaryAssetPreview(z,K);let G=await $N(J,K,z);if(!G)return;if(J.createAssets([G]),Y.type==="image"){let $=Y,_=$.props.crop,F=G.props.w,U=G.props.h,V=$.x,N=$.y,B=_;if(_){let O=oc($,G.props.w,G.props.h);B=O.crop,F=O.w,U=O.h,V=O.x,N=O.y}J.updateShapes([{id:$.id,type:$.type,props:{assetId:z,crop:B,w:F,h:U},x:V,y:N}])}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 H=await J.getAssetForExternalContent({type:"file",file:K,assetId:z});return J.updateAssets([{...H,id:z}]),H}async function lp(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:M9.createId(yq(Q)),typeName:"asset",type:"bookmark",props:{src:Q,description:X.description,image:X.image,favicon:X.favicon,title:X.title},meta:{}}}async function pp(J,{point:Q,text:Z}){let{sanitizeSvg:q}=await import("/chunk-94m3q9ce.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 H=K.getBoundingClientRect();G.body.removeChild(K),Y=H.width,W=H.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");nE(J,[z],X)}function dp(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 D(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 ip(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 D(Y.x,Y.y),z=[],G=[];for(let H of Z){if(!GN(J,H,q))continue;let _=await sE(H);if(!_){X.addToast({title:K("assets.files.upload-failed"),severity:"error"});continue}let F=await $N(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(H)=>{try{let $=await J.getAssetForExternalContent({type:"file",file:H.file});if(!$)throw Error("Could not create an asset");J.updateAssets([{...$,id:H.asset.id}])}catch($){X.addToast({title:K("assets.files.upload-failed"),severity:"error"}),console.error($),J.deleteAssets([H.asset.id]);return}})),nE(J,z,W)}async function DY(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=gp(Z),W=q?lE(J,q):y1(Y),z,G,H,$="middle",_=S9(J,W),F=W.content.length>1,U=zN(Y);if(F)$=F?U?"end":"start":"middle";let V=J.getCurrentTheme(),N=J.textMeasure.measureHtml(_,{...z5,lineHeight:V.lineHeight,fontFamily:v9(V,K.font),fontSize:V.fontSize*S3[K.size],maxWidth:null}),B=Math.min(F?J.getViewportPageBounds().width*0.9:920,Math.max(200,J.getViewportPageBounds().width*0.9));if(N.w>B){let L=J.textMeasure.measureHtml(_,{...z5,lineHeight:V.lineHeight,fontFamily:v9(V,K.font),fontSize:V.fontSize*S3[K.size],maxWidth:B});z=L.w,G=L.h,H=!1,$=U?"end":"start"}else z=Math.max(N.w,10),G=Math.max(N.h,10),H=!0;if(X.y-G/2<J.getViewportPageBounds().minY+40)X.y=J.getViewportPageBounds().minY+40+G/2;let O=j6(new D(X.x-z/2,X.y-G/2),J),M=l0();J.createShapes([{id:M,type:"text",x:O.x,y:O.y,props:{richText:W,textAlign:$,autoSize:H,w:z}}])}async function np(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 D$(J,{url:Z,center:W})).ok){q.addToast({title:X("assets.url.failed"),severity:"error"});return}}async function sp(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 rp(J,{point:Q,content:Z}){J.run(()=>{rk(J,Z,Q)})}async function nE(J,Q,Z){if(!Q.length)return[];let q=D.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)),ap(J,Z)}})}),X.map((K)=>K.id)}function ap(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=D.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 D(q.minX,q.minY),Y=K.clone().snapToGrid(X),W=D.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 sE(J){if(J.type!=="image/svg+xml")return J;try{let Q=await J.text(),{sanitizeSvg:Z}=await import("/chunk-94m3q9ce.js"),q=Z(Q);if(!q)return null;return new File([q],J.name,{type:J.type,lastModified:J.lastModified})}catch{return null}}function GN(J,Q,Z){let{maxAssetSize:q=up,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=(H)=>{if(H===0)return"0 bytes";let $=["bytes","KB","MB","GB","TB","PB"],_=1024,F=Math.floor(Math.log(H)/Math.log(_)),U=H/Math.pow(_,F);return`${U%1===0?U.toString():U.toFixed(1)} ${$[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 $N(J,Q,Z){if(!Z){let X=u_(await Q.arrayBuffer());Z=M9.createId(X)}let q=J.getAssetUtilForMimeType(Q.type);if(!q)return null;return await q.getAssetFromFile(Q,Z)}async function rE(J,Q,Z){let q=Z.name;if(!q){if(q=`shapes at ${op()}`,Q.length===1){let Y=J.getShape(Q[0]);if(J.isShapeOfType(Y,"frame"))q=Y.props.name||"frame";else q=`${kK(Y.id)} at ${op()}`}}q+=`.${Z.format}`;let{blob:X}=await J.toImage(Q,Z),K=new File([X],q,{type:X.type});HN(K,J.getContainerDocument())}function op(){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 HN(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 _N(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 tp=50;function aE(J,Q,Z={padding:tp}){let q=p.FromPoints(J.flatMap((G)=>{if(!G)return[];let H=Q.getShapeGeometry(G.id);return Q.getShapeLocalTransform(G)?.applyToPoints(H.vertices)??[]})),X=Z.padding??tp,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 MY(J,Q,Z={}){let q=J.getShape(Q);if(!q||!J.isShapeFrameLike(q))return;let X=J.getSortedChildIdsForParent(q.id),K=D0(X.map(($)=>J.getShape($)));if(!K.length)return;let{w:Y,h:W,dx:z,dy:G}=aE(K,J,Z);if(z===0&&G===0&&q.props.w===Y&&q.props.h===W)return;let H=new D(z,G).rot(q.rotation);J.run(()=>{let $=X.map((_)=>{let F=J.getShape(_);return{id:F.id,type:F.type,x:F.x+z,y:F.y+G}});$.push({id:q.id,type:q.type,x:q.x-H.x,y:q.y-H.y,props:{w:Y,h:W}}),J.updateShapes($)})}var Z5=E(c(),1);var O7=E(m(),1);var NP=E(c(),1),Qr=E(c1(),1),Zr=E(m(),1);var i5=E(c(),1);var $8={};T7($8,{createContextMenuScope:()=>ZG0,Trigger:()=>BG0,SubTrigger:()=>wG0,SubContent:()=>bG0,Sub:()=>IG0,Separator:()=>CG0,Root:()=>NG0,RadioItem:()=>EG0,RadioGroup:()=>kG0,Portal:()=>OG0,Label:()=>MG0,ItemIndicator:()=>AG0,Item:()=>jG0,Group:()=>DG0,ContextMenuTrigger:()=>vA,ContextMenuSubTrigger:()=>sA,ContextMenuSubContent:()=>rA,ContextMenuSub:()=>nA,ContextMenuSeparator:()=>dA,ContextMenuRadioItem:()=>lA,ContextMenuRadioGroup:()=>cA,ContextMenuPortal:()=>SA,ContextMenuLabel:()=>hA,ContextMenuItemIndicator:()=>pA,ContextMenuItem:()=>uA,ContextMenuGroup:()=>gA,ContextMenuContent:()=>fA,ContextMenuCheckboxItem:()=>mA,ContextMenuArrow:()=>iA,ContextMenu:()=>xA,Content:()=>LG0,CheckboxItem:()=>RG0,Arrow:()=>PG0});var M4=E(m(),1);var rr0=!!(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 iJ=E(m(),1),ep=E(c(),1);function U4(J,Q=[]){let Z=[];function q(K,Y){let W=iJ.createContext(Y);W.displayName=K+"Context";let z=Z.length;Z=[...Z,Y];let G=($)=>{let{scope:_,children:F,...U}=$,V=_?.[J]?.[z]||W,N=iJ.useMemo(()=>U,Object.values(U));return ep.jsx(V.Provider,{value:N,children:F})};G.displayName=K+"Provider";function H($,_){let F=_?.[J]?.[z]||W,U=iJ.useContext(F);if(U)return U;if(Y!==void 0)return Y;throw Error(`\`${$}\` must be used within \`${K}\``)}return[G,H]}let X=()=>{let K=Z.map((Y)=>{return iJ.createContext(Y)});return function(W){let z=W?.[J]||K;return iJ.useMemo(()=>({[`__scope${J}`]:{...W,[J]:z}}),[W,z])}};return X.scopeName=J,[q,JW0(X,...Q)]}function JW0(...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 $=z(K)[`__scope${G}`];return{...W,...$}},{});return iJ.useMemo(()=>({[`__scope${Q.scopeName}`]:Y}),[Y])}};return Z.scopeName=Q.scopeName,Z}var Xd=E(m(),1),Kd=E(KZ(),1);var jY={};T7(jY,{createSlottable:()=>UN,createSlot:()=>A8,Slottable:()=>ZW0,Slot:()=>QW0,Root:()=>QW0});var l5=E(m(),1);var Qd=E(m(),1);function Jd(J,Q){if(typeof J==="function")return J(Q);else if(J!==null&&J!==void 0)J.current=Q}function g$(...J){return(Q)=>{let Z=!1,q=J.map((X)=>{let K=Jd(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 Jd(J[X],null)}}}}function p0(...J){return Qd.useCallback(g$(...J),J)}function A8(J){let Q=l5.forwardRef((Z,q)=>{let{children:X,...K}=Z,Y=null,W=!1,z=[];if(Zd(X)&&typeof FN==="function")X=FN(X._payload);if(l5.Children.forEach(X,(_)=>{if(YW0(_)){W=!0;let F=_,U="child"in F.props?F.props.child:F.props.children;if(Zd(U)&&typeof FN==="function")U=FN(U._payload);Y=qW0(F,U),z.push(Y?.props?.children)}else z.push(_)}),Y)Y=l5.cloneElement(Y,void 0,z);else if(!W&&l5.Children.count(X)===1&&l5.isValidElement(X))Y=X;let G=Y?KW0(Y):void 0,H=p0(q,G);if(!Y){if(X||X===0)throw Error(W?$W0(J):GW0(J));return X}let $=XW0(K,Y.props??{});if(Y.type!==l5.Fragment)$.ref=q?H:G;return l5.cloneElement(Y,$)});return Q.displayName=`${J}.Slot`,Q}var QW0=A8("Slot"),qd=Symbol.for("radix.slottable");function UN(J){let Q=(Z)=>("child"in Z)?Z.children(Z.child):Z.children;return Q.displayName=`${J}.Slottable`,Q.__radixId=qd,Q}var ZW0=UN("Slottable"),qW0=(J,Q)=>{if("child"in J.props){let Z=J.props.child;if(!l5.isValidElement(Z))return null;return l5.cloneElement(Z,void 0,J.props.children(Z.props.children))}return l5.isValidElement(Q)?Q:null};function XW0(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 KW0(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 YW0(J){return l5.isValidElement(J)&&typeof J.type==="function"&&"__radixId"in J.type&&J.type.__radixId===qd}var WW0=Symbol.for("react.lazy");function Zd(J){return J!=null&&typeof J==="object"&&"$$typeof"in J&&J.$$typeof===WW0&&"_payload"in J&&zW0(J._payload)}function zW0(J){return typeof J==="object"&&J!==null&&"then"in J}var GW0=(J)=>{return`${J} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`},$W0=(J)=>{return`${J} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`},FN=l5[" use ".trim().toString()];var Yd=E(c(),1),HW0=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],_0=HW0.reduce((J,Q)=>{let Z=A8(`Primitive.${Q}`),q=Xd.forwardRef((X,K)=>{let{asChild:Y,...W}=X,z=Y?Z:Q;if(typeof window<"u")window[Symbol.for("radix-ui")]=!0;return Yd.jsx(z,{...W,ref:K})});return q.displayName=`Primitive.${Q}`,{...J,[Q]:q}},{});function RY(J,Q){if(J)Kd.flushSync(()=>J.dispatchEvent(Q))}var T0=E(m(),1);var i7=E(m(),1);var VN=E(c(),1),NN=E(m(),1);var FW0=E(c(),1);function x2(J){let Q=J+"CollectionProvider",[Z,q]=U4(Q),[X,K]=Z(Q,{collectionRef:{current:null},itemMap:new Map}),Y=(V)=>{let{scope:N,children:B}=V,O=i7.useRef(null),M=i7.useRef(new Map).current;return VN.jsx(X,{scope:N,itemMap:M,collectionRef:O,children:B})};Y.displayName=Q;let W=J+"CollectionSlot",z=A8(W),G=i7.forwardRef((V,N)=>{let{scope:B,children:O}=V,M=K(W,B),L=p0(N,M.collectionRef);return VN.jsx(z,{ref:L,children:O})});G.displayName=W;let H=J+"CollectionItemSlot",$="data-radix-collection-item",_=A8(H),F=i7.forwardRef((V,N)=>{let{scope:B,children:O,...M}=V,L=i7.useRef(null),j=p0(N,L),k=K(H,B);return i7.useEffect(()=>{return k.itemMap.set(L,{ref:L,...M}),()=>void k.itemMap.delete(L)}),VN.jsx(_,{...{[$]:""},ref:j,children:O})});F.displayName=H;function U(V){let N=K(J+"CollectionConsumer",V);return i7.useCallback(()=>{let O=N.collectionRef.current;if(!O)return[];let M=Array.from(O.querySelectorAll(`[${$}]`));return Array.from(N.itemMap.values()).sort((k,R)=>M.indexOf(k.ref.current)-M.indexOf(R.ref.current))},[N.collectionRef,N.itemMap])}return[{Provider:Y,Slot:G,ItemSlot:F},U,q]}var Wd=new WeakMap,Ka0=class J extends Map{#J;constructor(Q){super(Q);this.#J=[...super.keys()],Wd.set(this,!0)}set(Q,Z){if(Wd.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=zd(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 H=[...this.#J],$,_=!1;for(let F=W;F<G;F++)if(W===F){let U=H[F];if(H[F]===Z)U=H[F+1];if(X)this.delete(Z);$=this.get(U),this.set(Z,q)}else{if(!_&&H[F-1]===Z)_=!0;let U=H[_?F:F-1],V=$;$=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=oE(this.#J,Q);if(Z!==void 0)return this.get(Z)}entryAt(Q){let Z=oE(this.#J,Q);if(Z!==void 0)return[Z,this.get(Z)]}indexOf(Q){return this.#J.indexOf(Q)}keyAt(Q){return oE(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 oE(J,Q){if("at"in Array.prototype)return Array.prototype.at.call(J,Q);let Z=_W0(J,Q);return Z===-1?void 0:J[Z]}function _W0(J,Q){let Z=J.length,q=zd(Q),X=q>=0?q:Z+q;return X<0||X>=Z?-1:X}function zd(J){return J!==J||J===0?0:Math.trunc(J)}var BN=E(m(),1),UW0=E(c(),1),VW0=BN.createContext(void 0);function G7(J){let Q=BN.useContext(VW0);return J||Q||"ltr"}var W4=E(m(),1);var kY=E(m(),1);function H6(J){let Q=kY.useRef(J);return kY.useEffect(()=>{Q.current=J}),kY.useMemo(()=>(...Z)=>Q.current?.(...Z),[])}var Gd=E(m(),1);function $d(J,Q=globalThis?.document){let Z=H6(J);Gd.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 eE=E(c(),1),NW0="DismissableLayer",tE="dismissableLayer.update",BW0="dismissableLayer.pointerDownOutside",OW0="dismissableLayer.focusOutside",Hd,JA=W4.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),$7=W4.forwardRef((J,Q)=>{let{disableOutsidePointerEvents:Z=!1,deferPointerDownOutside:q=!1,onEscapeKeyDown:X,onPointerDownOutside:K,onFocusOutside:Y,onInteractOutside:W,onDismiss:z,...G}=J,H=W4.useContext(JA),[$,_]=W4.useState(null),F=$?.ownerDocument??globalThis?.document,[,U]=W4.useState({}),V=p0(Q,(A)=>_(A)),N=Array.from(H.layers),[B]=[...H.layersWithOutsidePointerEventsDisabled].slice(-1),O=N.indexOf(B),M=$?N.indexOf($):-1,L=H.layersWithOutsidePointerEventsDisabled.size>0,j=M>=O,k=W4.useRef(!1),R=DW0((A)=>{let w=A.target;if(!(w instanceof Node))return;let C=[...H.branches].some((x)=>x.contains(w));if(!j||C)return;if(K?.(A),W?.(A),!A.defaultPrevented)z?.()},{ownerDocument:F,deferPointerDownOutside:q,isDeferredPointerDownOutsideRef:k,dismissableSurfaces:H.dismissableSurfaces}),I=MW0((A)=>{if(q&&k.current)return;let w=A.target;if([...H.branches].some((x)=>x.contains(w)))return;if(Y?.(A),W?.(A),!A.defaultPrevented)z?.()},F);return $d((A)=>{if(M!==H.layers.size-1)return;if(X?.(A),!A.defaultPrevented&&z)A.preventDefault(),z()},F),W4.useEffect(()=>{if(!$)return;if(Z){if(H.layersWithOutsidePointerEventsDisabled.size===0)Hd=F.body.style.pointerEvents,F.body.style.pointerEvents="none";H.layersWithOutsidePointerEventsDisabled.add($)}return H.layers.add($),_d(),()=>{if(Z){if(H.layersWithOutsidePointerEventsDisabled.delete($),H.layersWithOutsidePointerEventsDisabled.size===0)F.body.style.pointerEvents=Hd}}},[$,F,Z,H]),W4.useEffect(()=>{return()=>{if(!$)return;H.layers.delete($),H.layersWithOutsidePointerEventsDisabled.delete($),_d()}},[$,H]),W4.useEffect(()=>{let A=()=>U({});return document.addEventListener(tE,A),()=>document.removeEventListener(tE,A)},[]),eE.jsx(_0.div,{...G,ref:V,style:{pointerEvents:L?j?"auto":"none":void 0,...J.style},onFocusCapture:Z0(J.onFocusCapture,I.onFocusCapture),onBlurCapture:Z0(J.onBlurCapture,I.onBlurCapture),onPointerDownCapture:Z0(J.onPointerDownCapture,R.onPointerDownCapture)})});$7.displayName=NW0;var LW0="DismissableLayerBranch",Fd=W4.forwardRef((J,Q)=>{let Z=W4.useContext(JA),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]),eE.jsx(_0.div,{...J,ref:X})});Fd.displayName=LW0;function Ud(){let J=W4.useContext(JA),[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 DW0(J,Q){let{ownerDocument:Z=globalThis?.document,deferPointerDownOutside:q=!1,isDeferredPointerDownOutsideRef:X,dismissableSurfaces:K}=Q,Y=H6(J),W=W4.useRef(!1),z=W4.useRef(!1),G=W4.useRef(new Map),H=W4.useRef(()=>{});return W4.useEffect(()=>{function $(){z.current=!1,X.current=!1,G.current.clear()}function _(){return Array.from(G.current.values()).some(Boolean)}function F(O){if(!z.current)return;let M=O.target;if(!(M instanceof Node&&[...K].some((j)=>j.contains(M))))G.current.set(O.type,!0);if(O.type==="click")window.setTimeout(()=>{if(z.current)H.current()},0)}function U(O){if(z.current)G.current.set(O.type,!1)}let V=(O)=>{if(O.target&&!W.current){let L=function(){Z.removeEventListener("click",H.current);let k=_();if($(),!k)Vd(BW0,Y,j,{discrete:!0})};var M=L;let j={originalEvent:O};if(z.current=!0,X.current=q&&O.button===0,G.current.clear(),!q||O.button!==0)L();else Z.removeEventListener("click",H.current),H.current=L,Z.addEventListener("click",H.current,{once:!0})}else Z.removeEventListener("click",H.current),$();W.current=!1},N=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(let O of N)Z.addEventListener(O,F,!0),Z.addEventListener(O,U);let B=window.setTimeout(()=>{Z.addEventListener("pointerdown",V)},0);return()=>{window.clearTimeout(B),Z.removeEventListener("pointerdown",V),Z.removeEventListener("click",H.current);for(let O of N)Z.removeEventListener(O,F,!0),Z.removeEventListener(O,U)}},[Z,Y,q,X,K]),{onPointerDownCapture:()=>W.current=!0}}function MW0(J,Q=globalThis?.document){let Z=H6(J),q=W4.useRef(!1);return W4.useEffect(()=>{let X=(K)=>{if(K.target&&!q.current)Vd(OW0,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 _d(){let J=new CustomEvent(tE);document.dispatchEvent(J)}function Vd(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)RY(X,K);else X.dispatchEvent(K)}var Nd=$7,Bd=Fd;var Ld=E(m(),1),ON=0,EY=null;function bZ(){Ld.useEffect(()=>{if(!EY)EY={start:Od(),end:Od()};let{start:J,end:Q}=EY;if(document.body.firstElementChild!==J)document.body.insertAdjacentElement("afterbegin",J);if(document.body.lastElementChild!==Q)document.body.insertAdjacentElement("beforeend",Q);return ON++,()=>{if(ON===1)EY?.start.remove(),EY?.end.remove(),EY=null;ON=Math.max(0,ON-1)}},[])}function Od(){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 H7=E(m(),1);var kd=E(c(),1),QA="focusScope.autoFocusOnMount",ZA="focusScope.autoFocusOnUnmount",Dd={bubbles:!1,cancelable:!0},RW0="FocusScope",nJ=H7.forwardRef((J,Q)=>{let{loop:Z=!1,trapped:q=!1,onMountAutoFocus:X,onUnmountAutoFocus:K,...Y}=J,[W,z]=H7.useState(null),G=H6(X),H=H6(K),$=H7.useRef(null),_=p0(Q,(V)=>z(V)),F=H7.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;H7.useEffect(()=>{if(q){let O=function(k){if(F.paused||!W)return;let R=k.target;if(W.contains(R))$.current=R;else TZ($.current,{select:!0})},M=function(k){if(F.paused||!W)return;let R=k.relatedTarget;if(R===null)return;if(!W.contains(R))TZ($.current,{select:!0})},L=function(k){if(document.activeElement!==document.body)return;for(let I of k)if(I.removedNodes.length>0)TZ(W)};var V=O,N=M,B=L;document.addEventListener("focusin",O),document.addEventListener("focusout",M);let j=new MutationObserver(L);if(W)j.observe(W,{childList:!0,subtree:!0});return()=>{document.removeEventListener("focusin",O),document.removeEventListener("focusout",M),j.disconnect()}}},[q,W,F.paused]),H7.useEffect(()=>{if(W){jd.add(F);let V=document.activeElement;if(!W.contains(V)){let B=new CustomEvent(QA,Dd);if(W.addEventListener(QA,G),W.dispatchEvent(B),!B.defaultPrevented){if(kW0(IW0(Ed(W)),{select:!0}),document.activeElement===V)TZ(W)}}return()=>{W.removeEventListener(QA,G),setTimeout(()=>{let B=new CustomEvent(ZA,Dd);if(W.addEventListener(ZA,H),W.dispatchEvent(B),!B.defaultPrevented)TZ(V??document.body,{select:!0});W.removeEventListener(ZA,H),jd.remove(F)},0)}}},[W,G,H,F]);let U=H7.useCallback((V)=>{if(!Z&&!q)return;if(F.paused)return;let N=V.key==="Tab"&&!V.altKey&&!V.ctrlKey&&!V.metaKey,B=document.activeElement;if(N&&B){let O=V.currentTarget,[M,L]=EW0(O);if(!(M&&L)){if(B===O)V.preventDefault()}else if(!V.shiftKey&&B===L){if(V.preventDefault(),Z)TZ(M,{select:!0})}else if(V.shiftKey&&B===M){if(V.preventDefault(),Z)TZ(L,{select:!0})}}},[Z,q,F.paused]);return kd.jsx(_0.div,{tabIndex:-1,...Y,ref:_,onKeyDown:U})});nJ.displayName=RW0;function kW0(J,{select:Q=!1}={}){let Z=document.activeElement;for(let q of J)if(TZ(q,{select:Q}),document.activeElement!==Z)return}function EW0(J){let Q=Ed(J),Z=Md(Q,J),q=Md(Q.reverse(),J);return[Z,q]}function Ed(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 Md(J,Q){for(let Z of J)if(!AW0(Z,{upTo:Q}))return Z}function AW0(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 CW0(J){return J instanceof HTMLInputElement&&"select"in J}function TZ(J,{select:Q=!1}={}){if(J&&J.focus){let Z=document.activeElement;if(J.focus({preventScroll:!0}),J!==Z&&CW0(J)&&Q)J.select()}}var jd=PW0();function PW0(){let J=[];return{add(Q){let Z=J[0];if(Q!==Z)Z?.pause();J=Rd(J,Q),J.unshift(Q)},remove(Q){J=Rd(J,Q),J[0]?.resume()}}}function Rd(J,Q){let Z=[...J],q=Z.indexOf(Q);if(q!==-1)Z.splice(q,1);return Z}function IW0(J){return J.filter((Q)=>Q.tagName!=="A")}var qA=E(m(),1);var Ad=E(m(),1),f4=globalThis?.document?Ad.useLayoutEffect:()=>{};var wW0=qA[" useId ".trim().toString()]||(()=>{return}),bW0=0;function o6(J){let[Q,Z]=qA.useState(wW0());return f4(()=>{if(!J)Z((q)=>q??String(bW0++))},[J]),J||(Q?`radix-${Q}`:"")}var p5=E(m(),1);var Cd=E(m(),1);var XA=E(c(),1),TW0="Arrow",Pd=Cd.forwardRef((J,Q)=>{let{children:Z,width:q=10,height:X=5,...K}=J;return XA.jsx(_0.svg,{...K,ref:Q,width:q,height:X,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:J.asChild?Z:XA.jsx("polygon",{points:"0,0 30,0 15,10"})})});Pd.displayName=TW0;var Id=Pd;var wd=E(m(),1);function LN(J){let[Q,Z]=wd.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 yZ=E(c(),1);var KA="Popper",[ud,_7]=U4(KA),[xW0,md]=ud(KA),cd=(J)=>{let{__scopePopper:Q,children:Z}=J,[q,X]=p5.useState(null),[K,Y]=p5.useState(void 0);return yZ.jsx(xW0,{scope:Q,anchor:q,onAnchorChange:X,placementState:K,setPlacementState:Y,children:Z})};cd.displayName=KA;var ld="PopperAnchor",pd=p5.forwardRef((J,Q)=>{let{__scopePopper:Z,virtualRef:q,...X}=J,K=md(ld,Z),Y=p5.useRef(null),W=K.onAnchorChange,z=p5.useCallback((U)=>{if(Y.current=U,U)W(U)},[W]),G=p0(Q,z),H=p5.useRef(null);p5.useEffect(()=>{if(!q)return;let U=H.current;if(H.current=q.current,U!==H.current)W(H.current)});let $=K.placementState&&WA(K.placementState),_=$?.[0],F=$?.[1];return q?null:yZ.jsx(_0.div,{"data-radix-popper-side":_,"data-radix-popper-align":F,...X,ref:G})});pd.displayName=ld;var YA="PopperContent",[vW0,SW0]=ud(YA),dd=p5.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:H=0,sticky:$="partial",hideWhenDetached:_=!1,updatePositionStrategy:F="optimized",onPlaced:U,...V}=J,N=md(YA,Z),[B,O]=p5.useState(null),M=p0(Q,(L0)=>O(L0)),[L,j]=p5.useState(null),k=LN(L),R=k?.width??0,I=k?.height??0,A=q+(K!=="center"?"-"+K:""),w=typeof H==="number"?H:{top:0,right:0,bottom:0,left:0,...H},C=Array.isArray(G)?G:[G],x=C.length>0,f={padding:w,boundary:C.filter(gW0),altBoundary:x},{refs:T,floatingStyles:h,placement:b,isPositioned:v,middlewareData:g}=Td({strategy:"fixed",placement:A,whileElementsMounted:(...L0)=>{return bd(...L0,{animationFrame:F==="always"})},elements:{reference:N.anchor},middleware:[yd({mainAxis:X+I,alignmentAxis:Y}),z&&xd({mainAxis:!0,crossAxis:!1,limiter:$==="partial"?vd():void 0,...f}),z&&Sd({...f}),fd({...f,apply:({elements:L0,rects:Z1,availableWidth:q1,availableHeight:r})=>{let{width:s,height:F0}=Z1.reference,s0=L0.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`)}}),L&&hd({element:L,padding:W}),hW0({arrowWidth:R,arrowHeight:I}),_&&gd({strategy:"referenceHidden",...f,boundary:x?f.boundary:void 0})]}),u=N.setPlacementState;f4(()=>{return u(b),()=>{u(void 0)}},[b,u]);let[n,o]=WA(b),K0=H6(U);f4(()=>{if(v)K0?.()},[v,K0]);let U0=g.arrow?.x,y0=g.arrow?.y,D1=g.arrow?.centerOffset!==0,[j0,Y0]=p5.useState();return f4(()=>{if(B)Y0(window.getComputedStyle(B).zIndex)},[B]),yZ.jsx("div",{ref:T.setFloating,"data-radix-popper-content-wrapper":"",style:{...h,transform:v?h.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:j0,"--radix-popper-transform-origin":[g.transformOrigin?.x,g.transformOrigin?.y].join(" "),...g.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:J.dir,children:yZ.jsx(vW0,{scope:Z,placedSide:n,placedAlign:o,onArrowChange:j,arrowX:U0,arrowY:y0,shouldHideArrow:D1,children:yZ.jsx(_0.div,{"data-side":n,"data-align":o,...V,ref:M,style:{...V.style,animation:!v?"none":void 0}})})})});dd.displayName=YA;var id="PopperArrow",fW0={top:"bottom",right:"left",bottom:"top",left:"right"},nd=p5.forwardRef(function(Q,Z){let{__scopePopper:q,...X}=Q,K=SW0(id,q),Y=fW0[K.placedSide];return yZ.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:yZ.jsx(Id,{...X,ref:Z,style:{...X.style,display:"block"}})})});nd.displayName=id;function gW0(J){return J!==null}var hW0=(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,H]=WA(Z),$={start:"0%",center:"50%",end:"100%"}[H],_=(X.arrow?.x??0)+W/2,F=(X.arrow?.y??0)+z/2,U="",V="";if(G==="bottom")U=Y?$:`${_}px`,V=`${-z}px`;else if(G==="top")U=Y?$:`${_}px`,V=`${q.floating.height+z}px`;else if(G==="right")U=`${-z}px`,V=Y?$:`${F}px`;else if(G==="left")U=`${q.floating.width+z}px`,V=Y?$:`${F}px`;return{data:{x:U,y:V}}}});function WA(J){let[Q,Z="center"]=J.split("-");return[Q,Z]}var sJ=cd,rJ=pd,xZ=dd,vZ=nd;var MN=E(m(),1),sd=E(KZ(),1);var rd=E(c(),1),uW0="Portal",g9=MN.forwardRef((J,Q)=>{let{container:Z,...q}=J,[X,K]=MN.useState(!1);f4(()=>K(!0),[]);let Y=Z||X&&globalThis?.document?.body;return Y?sd.createPortal(rd.jsx(_0.div,{...q,ref:Q}),Y):null});g9.displayName=uW0;var W8=E(m(),1);var od=E(m(),1);function mW0(J,Q){return od.useReducer((Z,q)=>{return Q[Z][q]??Z},J)}var t6=(J)=>{let{present:Q,children:Z}=J,q=cW0(Q),X=typeof Z==="function"?Z({present:q.isPresent}):W8.Children.only(Z),K=lW0(q.ref,pW0(X));return typeof Z==="function"||q.isPresent?W8.cloneElement(X,{ref:K}):null};t6.displayName="Presence";function cW0(J){let[Q,Z]=W8.useState(),q=W8.useRef(null),X=W8.useRef(J),K=W8.useRef("none"),Y=J?"mounted":"unmounted",[W,z]=mW0(Y,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return W8.useEffect(()=>{let G=jN(q.current);K.current=W==="mounted"?G:"none"},[W]),f4(()=>{let G=q.current,H=X.current;if(H!==J){let _=K.current,F=jN(G);if(J)z("MOUNT");else if(F==="none"||G?.display==="none")z("UNMOUNT");else if(H&&_!==F)z("ANIMATION_OUT");else z("UNMOUNT");X.current=J}},[J,z]),f4(()=>{if(Q){let G,H=Q.ownerDocument.defaultView??window,$=(F)=>{let V=jN(q.current).includes(CSS.escape(F.animationName));if(F.target===Q&&V){if(z("ANIMATION_END"),!X.current){let N=Q.style.animationFillMode;Q.style.animationFillMode="forwards",G=H.setTimeout(()=>{if(Q.style.animationFillMode==="forwards")Q.style.animationFillMode=N})}}},_=(F)=>{if(F.target===Q)K.current=jN(q.current)};return Q.addEventListener("animationstart",_),Q.addEventListener("animationcancel",$),Q.addEventListener("animationend",$),()=>{H.clearTimeout(G),Q.removeEventListener("animationstart",_),Q.removeEventListener("animationcancel",$),Q.removeEventListener("animationend",$)}}else z("ANIMATION_END")},[Q,z]),{isPresent:["mounted","unmountSuspended"].includes(W),ref:W8.useCallback((G)=>{q.current=G?getComputedStyle(G):null,Z(G)},[])}}function ad(J,Q){if(typeof J==="function")return J(Q);else if(J!==null&&J!==void 0)J.current=Q}function lW0(...J){let Q=W8.useRef(J);return Q.current=J,W8.useCallback((Z)=>{let q=Q.current,X=!1,K=q.map((Y)=>{let W=ad(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 ad(q[Y],null)}}},[])}function jN(J){return J?.animationName||"none"}function pW0(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 A5=E(m(),1);var F7=E(m(),1);var RN=E(m(),1);var dW0=F7[" useInsertionEffect ".trim().toString()]||f4;function g4({prop:J,defaultProp:Q,onChange:Z=()=>{},caller:q}){let[X,K,Y]=iW0({defaultProp:Q,onChange:Z}),W=J!==void 0,z=W?J:X;{let H=F7.useRef(J!==void 0);F7.useEffect(()=>{let $=H.current;if($!==W)console.warn(`${q} is changing from ${$?"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.`);H.current=W},[W,q])}let G=F7.useCallback((H)=>{if(W){let $=nW0(H)?H(J):H;if($!==J)Y.current?.($)}else K(H)},[W,J,K,Y]);return[z,G]}function iW0({defaultProp:J,onChange:Q}){let[Z,q]=F7.useState(J),X=F7.useRef(Z),K=F7.useRef(Q);return dW0(()=>{K.current=Q},[Q]),F7.useEffect(()=>{if(X.current!==Z)K.current?.(Z),X.current=Z},[Z,X]),[Z,q,K]}function nW0(J){return typeof J==="function"}var ua0=Symbol("RADIX:SYNC_STATE");var SZ=E(c(),1),zA="rovingFocusGroup.onEntryFocus",sW0={bubbles:!1,cancelable:!0},h$="RovingFocusGroup",[GA,td,rW0]=x2(h$),[aW0,aJ]=U4(h$,[rW0]),[oW0,tW0]=aW0(h$),ed=A5.forwardRef((J,Q)=>{return SZ.jsx(GA.Provider,{scope:J.__scopeRovingFocusGroup,children:SZ.jsx(GA.Slot,{scope:J.__scopeRovingFocusGroup,children:SZ.jsx(eW0,{...J,ref:Q})})})});ed.displayName=h$;var eW0=A5.forwardRef((J,Q)=>{let{__scopeRovingFocusGroup:Z,orientation:q,loop:X=!1,dir:K,currentTabStopId:Y,defaultCurrentTabStopId:W,onCurrentTabStopIdChange:z,onEntryFocus:G,preventScrollOnEntryFocus:H=!1,...$}=J,_=A5.useRef(null),F=p0(Q,_),U=G7(K),[V,N]=g4({prop:Y,defaultProp:W??null,onChange:z,caller:h$}),[B,O]=A5.useState(!1),M=H6(G),L=td(Z),j=A5.useRef(!1),[k,R]=A5.useState(0);return A5.useEffect(()=>{let I=_.current;if(I)return I.addEventListener(zA,M),()=>I.removeEventListener(zA,M)},[M]),SZ.jsx(oW0,{scope:Z,orientation:q,dir:U,loop:X,currentTabStopId:V,onItemFocus:A5.useCallback((I)=>N(I),[N]),onItemShiftTab:A5.useCallback(()=>O(!0),[]),onFocusableItemAdd:A5.useCallback(()=>R((I)=>I+1),[]),onFocusableItemRemove:A5.useCallback(()=>R((I)=>I-1),[]),children:SZ.jsx(_0.div,{tabIndex:B||k===0?-1:0,"data-orientation":q,...$,ref:F,style:{outline:"none",...J.style},onMouseDown:Z0(J.onMouseDown,()=>{j.current=!0}),onFocus:Z0(J.onFocus,(I)=>{let A=!j.current;if(I.target===I.currentTarget&&A&&!B){let w=new CustomEvent(zA,sW0);if(I.currentTarget.dispatchEvent(w),!w.defaultPrevented){let C=L().filter((b)=>b.focusable),x=C.find((b)=>b.active),f=C.find((b)=>b.id===V),h=[x,f,...C].filter(Boolean).map((b)=>b.ref.current);Zi(h,H)}}j.current=!1}),onBlur:Z0(J.onBlur,()=>O(!1))})})}),Ji="RovingFocusGroupItem",Qi=A5.forwardRef((J,Q)=>{let{__scopeRovingFocusGroup:Z,focusable:q=!0,active:X=!1,tabStopId:K,children:Y,...W}=J,z=o6(),G=K||z,H=tW0(Ji,Z),$=H.currentTabStopId===G,_=td(Z),{onFocusableItemAdd:F,onFocusableItemRemove:U,currentTabStopId:V}=H;return A5.useEffect(()=>{if(q)return F(),()=>U()},[q,F,U]),SZ.jsx(GA.ItemSlot,{scope:Z,id:G,focusable:q,active:X,children:SZ.jsx(_0.span,{tabIndex:$?0:-1,"data-orientation":H.orientation,...W,ref:Q,onMouseDown:Z0(J.onMouseDown,(N)=>{if(!q)N.preventDefault();else H.onItemFocus(G)}),onFocus:Z0(J.onFocus,()=>H.onItemFocus(G)),onKeyDown:Z0(J.onKeyDown,(N)=>{if(N.key==="Tab"&&N.shiftKey){H.onItemShiftTab();return}if(N.target!==N.currentTarget)return;let B=Zz0(N,H.orientation,H.dir);if(B!==void 0){if(N.metaKey||N.ctrlKey||N.altKey||N.shiftKey)return;N.preventDefault();let M=_().filter((L)=>L.focusable).map((L)=>L.ref.current);if(B==="last")M.reverse();else if(B==="prev"||B==="next"){if(B==="prev")M.reverse();let L=M.indexOf(N.currentTarget);M=H.loop?qz0(M,L+1):M.slice(L+1)}setTimeout(()=>Zi(M))}}),children:typeof Y==="function"?Y({isCurrentTabStop:$,hasTabStop:V!=null}):Y})})});Qi.displayName=Ji;var Jz0={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Qz0(J,Q){if(Q!=="rtl")return J;return J==="ArrowLeft"?"ArrowRight":J==="ArrowRight"?"ArrowLeft":J}function Zz0(J,Q,Z){let q=Qz0(J.key,Z);if(Q==="vertical"&&["ArrowLeft","ArrowRight"].includes(q))return;if(Q==="horizontal"&&["ArrowUp","ArrowDown"].includes(q))return;return Jz0[q]}function Zi(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 qz0(J,Q){return J.map((Z,q)=>J[(Q+q)%J.length])}var AY=ed,n3=Qi;var Xz0=function(J){if(typeof document>"u")return null;var Q=Array.isArray(J)?J[0]:J;return Q.ownerDocument.body},CY=new WeakMap,kN=new WeakMap,EN={},HA=0,qi=function(J){return J&&(J.host||qi(J.parentNode))},Kz0=function(J,Q){return Q.map(function(Z){if(J.contains(Z))return Z;var q=qi(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)})},Yz0=function(J,Q,Z,q){var X=Kz0(Q,Array.isArray(J)?J:[J]);if(!EN[Z])EN[Z]=new WeakMap;var K=EN[Z],Y=[],W=new Set,z=new Set(X),G=function($){if(!$||W.has($))return;W.add($),G($.parentNode)};X.forEach(G);var H=function($){if(!$||z.has($))return;Array.prototype.forEach.call($.children,function(_){if(W.has(_))H(_);else try{var F=_.getAttribute(q),U=F!==null&&F!=="false",V=(CY.get(_)||0)+1,N=(K.get(_)||0)+1;if(CY.set(_,V),K.set(_,N),Y.push(_),V===1&&U)kN.set(_,!0);if(N===1)_.setAttribute(Z,"true");if(!U)_.setAttribute(q,"true")}catch(B){console.error("aria-hidden: cannot operate on ",_,B)}})};return H(Q),W.clear(),HA++,function(){if(Y.forEach(function($){var _=CY.get($)-1,F=K.get($)-1;if(CY.set($,_),K.set($,F),!_){if(!kN.has($))$.removeAttribute(q);kN.delete($)}if(!F)$.removeAttribute(Z)}),HA--,!HA)CY=new WeakMap,CY=new WeakMap,kN=new WeakMap,EN={}}},fZ=function(J,Q,Z){if(Z===void 0)Z="data-aria-hidden";var q=Array.from(Array.isArray(J)?J:[J]),X=Q||Xz0(J);if(!X)return function(){return null};return q.push.apply(q,Array.from(X.querySelectorAll("[aria-live], script"))),Yz0(q,X,Z,"aria-hidden")};var a8=function(){return a8=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},a8.apply(this,arguments)};function AN(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 Xi(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 bN=E(m(),1);var z8=E(m(),1);var s3="right-scroll-bar-position",r3="width-before-scroll-bar",_A="with-scroll-bars-hidden",FA="--removed-body-scroll-bar-size";var PN=E(m(),1);function CN(J,Q){if(typeof J==="function")J(Q);else if(J)J.current=Q;return J}var Ki=E(m(),1);function Yi(J,Q){var Z=Ki.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 Wz0=typeof window<"u"?PN.useLayoutEffect:PN.useEffect,Wi=new WeakMap;function UA(J,Q){var Z=Yi(Q||null,function(q){return J.forEach(function(X){return CN(X,q)})});return Wz0(function(){var q=Wi.get(Z);if(q){var X=new Set(q),K=new Set(J),Y=Z.current;X.forEach(function(W){if(!K.has(W))CN(W,null)}),K.forEach(function(W){if(!X.has(W))CN(W,Y)})}Wi.set(Z,J)},[J]),Z}function zz0(J){return J}function Gz0(J,Q){if(Q===void 0)Q=zz0;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 H=Y;Y=[],H.forEach(K)},G=function(){return Promise.resolve().then(z)};G(),Z={push:function(H){Y.push(H),G()},filter:function(H){return Y=Y.filter(H),Z}}}};return X}function VA(J){if(J===void 0)J={};var Q=Gz0(null);return Q.options=a8({async:!0,ssr:!1},J),Q}var zi=E(m(),1),Gi=function(J){var Q=J.sideCar,Z=AN(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 zi.createElement(q,a8({},Z))};Gi.isSideCarExport=!0;function NA(J,Q){return J.useMedium(Q),Gi}var IN=VA();var BA=function(){return},u$=z8.forwardRef(function(J,Q){var Z=z8.useRef(null),q=z8.useState({onScrollCapture:BA,onWheelCapture:BA,onTouchMoveCapture:BA}),X=q[0],K=q[1],Y=J.forwardProps,W=J.children,z=J.className,G=J.removeScrollBar,H=J.enabled,$=J.shards,_=J.sideCar,F=J.noRelative,U=J.noIsolation,V=J.inert,N=J.allowPinchZoom,B=J.as,O=B===void 0?"div":B,M=J.gapMode,L=AN(J,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),j=_,k=UA([Z,Q]),R=a8(a8({},L),X);return z8.createElement(z8.Fragment,null,H&&z8.createElement(j,{sideCar:IN,removeScrollBar:G,shards:$,noRelative:F,noIsolation:U,inert:V,setCallbacks:K,allowPinchZoom:!!N,lockRef:Z,gapMode:M}),Y?z8.cloneElement(z8.Children.only(W),a8(a8({},R),{ref:k})):z8.createElement(O,a8({},R,{className:z,ref:k}),W))});u$.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};u$.classNames={fullWidth:r3,zeroRight:s3};var s4=E(m(),1);var IY=E(m(),1);var _i=E(m(),1);var $i;var Hi=function(){if($i)return $i;if(typeof __webpack_nonce__<"u")return __webpack_nonce__;return};function $z0(){if(!document)return null;var J=document.createElement("style");J.type="text/css";var Q=Hi();if(Q)J.setAttribute("nonce",Q);return J}function Hz0(J,Q){if(J.styleSheet)J.styleSheet.cssText=Q;else J.appendChild(document.createTextNode(Q))}function _z0(J){var Q=document.head||document.getElementsByTagName("head")[0];Q.appendChild(J)}var OA=function(){var J=0,Q=null;return{add:function(Z){if(J==0){if(Q=$z0())Hz0(Q,Z),_z0(Q)}J++},remove:function(){if(J--,!J&&Q)Q.parentNode&&Q.parentNode.removeChild(Q),Q=null}}};var LA=function(){var J=OA();return function(Q,Z){_i.useEffect(function(){return J.add(Q),function(){J.remove()}},[Q&&Z])}};var m$=function(){var J=LA(),Q=function(Z){var{styles:q,dynamic:X}=Z;return J(q,X),null};return Q};var Fz0={left:0,top:0,right:0,gap:0},DA=function(J){return parseInt(J||"",10)||0},Uz0=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[DA(Z),DA(q),DA(X)]},MA=function(J){if(J===void 0)J="margin";if(typeof window>"u")return Fz0;var Q=Uz0(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 Vz0=m$(),PY="data-scroll-locked",Nz0=function(J,Q,Z,q){var{left:X,top:K,right:Y,gap:W}=J;if(Z===void 0)Z="margin";return`
376
+ `)}var fp={"&amp;":"&","&quot;":'"',"&apos;":"'","&#27;":"'","&#34;":'"',"&#38;":"&","&#39;":"'","&#8211;":"–","&#8212;":"—","&#8216;":"‘","&#8217;":"’","&#8220;":"“","&#8221;":"”","&#8230;":"…"},tY0=new RegExp(Object.keys(fp).join("|"),"g");function pE(J){return J.replace(tY0,(Q)=>fp[Q])}function eY0(J){return J.replace(/[ \t]+$/gm,"").replace(/\n+$/,"")}function gp(J){return eY0(oY0(aY0(J)))}var dE=5000,up=10485760;function iE(J,Q){J.registerExternalAssetHandler("file",async(Z)=>{return mp(J,Z,Q)}),J.registerExternalAssetHandler("url",async(Z)=>{return lp(J,Z,Q)}),J.registerExternalContentHandler("svg-text",async(Z)=>{return pp(J,Z)}),J.registerExternalContentHandler("embed",(Z)=>{return dp(J,Z)}),J.registerExternalContentHandler("files",async(Z)=>{return ip(J,Z,Q)}),J.registerExternalContentHandler("file-replace",async(Z)=>{return cp(J,Z,Q)}),J.registerExternalContentHandler("text",async(Z)=>{return DY(J,Z)}),J.registerExternalContentHandler("url",async(Z)=>{return np(J,Z,Q)}),J.registerExternalContentHandler("tldraw",async(Z)=>{return sp(J,Z)}),J.registerExternalContentHandler("excalidraw",async(Z)=>{return rp(J,Z)})}async function mp(J,{file:Q,assetId:Z},q){if(!GN(J,Q,q))Q0(!1,"File checks failed");let K=await sE(Q);if(!K)Q0(!1,"SVG file contained no safe content");let Y=await $N(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 M9.create(Y)}async function cp(J,{file:Q,shapeId:Z},q){if(!GN(J,Q,q))Q0(!1,"File checks failed");let K=await sE(Q);if(!K)return;let Y=J.getShape(Z);if(!Y)Q0(!1,"Shape not found");let W=u_(await K.arrayBuffer()),z=M9.createId(W);J.createTemporaryAssetPreview(z,K);let G=await $N(J,K,z);if(!G)return;if(J.createAssets([G]),Y.type==="image"){let $=Y,_=$.props.crop,F=G.props.w,U=G.props.h,V=$.x,N=$.y,B=_;if(_){let O=oc($,G.props.w,G.props.h);B=O.crop,F=O.w,U=O.h,V=O.x,N=O.y}J.updateShapes([{id:$.id,type:$.type,props:{assetId:z,crop:B,w:F,h:U},x:V,y:N}])}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 H=await J.getAssetForExternalContent({type:"file",file:K,assetId:z});return J.updateAssets([{...H,id:z}]),H}async function lp(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:M9.createId(yq(Q)),typeName:"asset",type:"bookmark",props:{src:Q,description:X.description,image:X.image,favicon:X.favicon,title:X.title},meta:{}}}async function pp(J,{point:Q,text:Z}){let{sanitizeSvg:q}=await import("/chunk-dfs36zgc.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 H=K.getBoundingClientRect();G.body.removeChild(K),Y=H.width,W=H.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");nE(J,[z],X)}function dp(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 D(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 ip(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 D(Y.x,Y.y),z=[],G=[];for(let H of Z){if(!GN(J,H,q))continue;let _=await sE(H);if(!_){X.addToast({title:K("assets.files.upload-failed"),severity:"error"});continue}let F=await $N(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(H)=>{try{let $=await J.getAssetForExternalContent({type:"file",file:H.file});if(!$)throw Error("Could not create an asset");J.updateAssets([{...$,id:H.asset.id}])}catch($){X.addToast({title:K("assets.files.upload-failed"),severity:"error"}),console.error($),J.deleteAssets([H.asset.id]);return}})),nE(J,z,W)}async function DY(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=gp(Z),W=q?lE(J,q):y1(Y),z,G,H,$="middle",_=S9(J,W),F=W.content.length>1,U=zN(Y);if(F)$=F?U?"end":"start":"middle";let V=J.getCurrentTheme(),N=J.textMeasure.measureHtml(_,{...z5,lineHeight:V.lineHeight,fontFamily:v9(V,K.font),fontSize:V.fontSize*S3[K.size],maxWidth:null}),B=Math.min(F?J.getViewportPageBounds().width*0.9:920,Math.max(200,J.getViewportPageBounds().width*0.9));if(N.w>B){let L=J.textMeasure.measureHtml(_,{...z5,lineHeight:V.lineHeight,fontFamily:v9(V,K.font),fontSize:V.fontSize*S3[K.size],maxWidth:B});z=L.w,G=L.h,H=!1,$=U?"end":"start"}else z=Math.max(N.w,10),G=Math.max(N.h,10),H=!0;if(X.y-G/2<J.getViewportPageBounds().minY+40)X.y=J.getViewportPageBounds().minY+40+G/2;let O=j6(new D(X.x-z/2,X.y-G/2),J),M=l0();J.createShapes([{id:M,type:"text",x:O.x,y:O.y,props:{richText:W,textAlign:$,autoSize:H,w:z}}])}async function np(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 D$(J,{url:Z,center:W})).ok){q.addToast({title:X("assets.url.failed"),severity:"error"});return}}async function sp(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 rp(J,{point:Q,content:Z}){J.run(()=>{rk(J,Z,Q)})}async function nE(J,Q,Z){if(!Q.length)return[];let q=D.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)),ap(J,Z)}})}),X.map((K)=>K.id)}function ap(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=D.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 D(q.minX,q.minY),Y=K.clone().snapToGrid(X),W=D.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 sE(J){if(J.type!=="image/svg+xml")return J;try{let Q=await J.text(),{sanitizeSvg:Z}=await import("/chunk-dfs36zgc.js"),q=Z(Q);if(!q)return null;return new File([q],J.name,{type:J.type,lastModified:J.lastModified})}catch{return null}}function GN(J,Q,Z){let{maxAssetSize:q=up,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=(H)=>{if(H===0)return"0 bytes";let $=["bytes","KB","MB","GB","TB","PB"],_=1024,F=Math.floor(Math.log(H)/Math.log(_)),U=H/Math.pow(_,F);return`${U%1===0?U.toString():U.toFixed(1)} ${$[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 $N(J,Q,Z){if(!Z){let X=u_(await Q.arrayBuffer());Z=M9.createId(X)}let q=J.getAssetUtilForMimeType(Q.type);if(!q)return null;return await q.getAssetFromFile(Q,Z)}async function rE(J,Q,Z){let q=Z.name;if(!q){if(q=`shapes at ${op()}`,Q.length===1){let Y=J.getShape(Q[0]);if(J.isShapeOfType(Y,"frame"))q=Y.props.name||"frame";else q=`${kK(Y.id)} at ${op()}`}}q+=`.${Z.format}`;let{blob:X}=await J.toImage(Q,Z),K=new File([X],q,{type:X.type});HN(K,J.getContainerDocument())}function op(){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 HN(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 _N(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 tp=50;function aE(J,Q,Z={padding:tp}){let q=p.FromPoints(J.flatMap((G)=>{if(!G)return[];let H=Q.getShapeGeometry(G.id);return Q.getShapeLocalTransform(G)?.applyToPoints(H.vertices)??[]})),X=Z.padding??tp,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 MY(J,Q,Z={}){let q=J.getShape(Q);if(!q||!J.isShapeFrameLike(q))return;let X=J.getSortedChildIdsForParent(q.id),K=D0(X.map(($)=>J.getShape($)));if(!K.length)return;let{w:Y,h:W,dx:z,dy:G}=aE(K,J,Z);if(z===0&&G===0&&q.props.w===Y&&q.props.h===W)return;let H=new D(z,G).rot(q.rotation);J.run(()=>{let $=X.map((_)=>{let F=J.getShape(_);return{id:F.id,type:F.type,x:F.x+z,y:F.y+G}});$.push({id:q.id,type:q.type,x:q.x-H.x,y:q.y-H.y,props:{w:Y,h:W}}),J.updateShapes($)})}var Z5=E(c(),1);var O7=E(m(),1);var NP=E(c(),1),Qr=E(c1(),1),Zr=E(m(),1);var i5=E(c(),1);var $8={};T7($8,{createContextMenuScope:()=>ZG0,Trigger:()=>BG0,SubTrigger:()=>wG0,SubContent:()=>bG0,Sub:()=>IG0,Separator:()=>CG0,Root:()=>NG0,RadioItem:()=>EG0,RadioGroup:()=>kG0,Portal:()=>OG0,Label:()=>MG0,ItemIndicator:()=>AG0,Item:()=>jG0,Group:()=>DG0,ContextMenuTrigger:()=>vA,ContextMenuSubTrigger:()=>sA,ContextMenuSubContent:()=>rA,ContextMenuSub:()=>nA,ContextMenuSeparator:()=>dA,ContextMenuRadioItem:()=>lA,ContextMenuRadioGroup:()=>cA,ContextMenuPortal:()=>SA,ContextMenuLabel:()=>hA,ContextMenuItemIndicator:()=>pA,ContextMenuItem:()=>uA,ContextMenuGroup:()=>gA,ContextMenuContent:()=>fA,ContextMenuCheckboxItem:()=>mA,ContextMenuArrow:()=>iA,ContextMenu:()=>xA,Content:()=>LG0,CheckboxItem:()=>RG0,Arrow:()=>PG0});var M4=E(m(),1);var rr0=!!(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 iJ=E(m(),1),ep=E(c(),1);function U4(J,Q=[]){let Z=[];function q(K,Y){let W=iJ.createContext(Y);W.displayName=K+"Context";let z=Z.length;Z=[...Z,Y];let G=($)=>{let{scope:_,children:F,...U}=$,V=_?.[J]?.[z]||W,N=iJ.useMemo(()=>U,Object.values(U));return ep.jsx(V.Provider,{value:N,children:F})};G.displayName=K+"Provider";function H($,_){let F=_?.[J]?.[z]||W,U=iJ.useContext(F);if(U)return U;if(Y!==void 0)return Y;throw Error(`\`${$}\` must be used within \`${K}\``)}return[G,H]}let X=()=>{let K=Z.map((Y)=>{return iJ.createContext(Y)});return function(W){let z=W?.[J]||K;return iJ.useMemo(()=>({[`__scope${J}`]:{...W,[J]:z}}),[W,z])}};return X.scopeName=J,[q,JW0(X,...Q)]}function JW0(...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 $=z(K)[`__scope${G}`];return{...W,...$}},{});return iJ.useMemo(()=>({[`__scope${Q.scopeName}`]:Y}),[Y])}};return Z.scopeName=Q.scopeName,Z}var Xd=E(m(),1),Kd=E(KZ(),1);var jY={};T7(jY,{createSlottable:()=>UN,createSlot:()=>A8,Slottable:()=>ZW0,Slot:()=>QW0,Root:()=>QW0});var l5=E(m(),1);var Qd=E(m(),1);function Jd(J,Q){if(typeof J==="function")return J(Q);else if(J!==null&&J!==void 0)J.current=Q}function g$(...J){return(Q)=>{let Z=!1,q=J.map((X)=>{let K=Jd(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 Jd(J[X],null)}}}}function p0(...J){return Qd.useCallback(g$(...J),J)}function A8(J){let Q=l5.forwardRef((Z,q)=>{let{children:X,...K}=Z,Y=null,W=!1,z=[];if(Zd(X)&&typeof FN==="function")X=FN(X._payload);if(l5.Children.forEach(X,(_)=>{if(YW0(_)){W=!0;let F=_,U="child"in F.props?F.props.child:F.props.children;if(Zd(U)&&typeof FN==="function")U=FN(U._payload);Y=qW0(F,U),z.push(Y?.props?.children)}else z.push(_)}),Y)Y=l5.cloneElement(Y,void 0,z);else if(!W&&l5.Children.count(X)===1&&l5.isValidElement(X))Y=X;let G=Y?KW0(Y):void 0,H=p0(q,G);if(!Y){if(X||X===0)throw Error(W?$W0(J):GW0(J));return X}let $=XW0(K,Y.props??{});if(Y.type!==l5.Fragment)$.ref=q?H:G;return l5.cloneElement(Y,$)});return Q.displayName=`${J}.Slot`,Q}var QW0=A8("Slot"),qd=Symbol.for("radix.slottable");function UN(J){let Q=(Z)=>("child"in Z)?Z.children(Z.child):Z.children;return Q.displayName=`${J}.Slottable`,Q.__radixId=qd,Q}var ZW0=UN("Slottable"),qW0=(J,Q)=>{if("child"in J.props){let Z=J.props.child;if(!l5.isValidElement(Z))return null;return l5.cloneElement(Z,void 0,J.props.children(Z.props.children))}return l5.isValidElement(Q)?Q:null};function XW0(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 KW0(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 YW0(J){return l5.isValidElement(J)&&typeof J.type==="function"&&"__radixId"in J.type&&J.type.__radixId===qd}var WW0=Symbol.for("react.lazy");function Zd(J){return J!=null&&typeof J==="object"&&"$$typeof"in J&&J.$$typeof===WW0&&"_payload"in J&&zW0(J._payload)}function zW0(J){return typeof J==="object"&&J!==null&&"then"in J}var GW0=(J)=>{return`${J} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`},$W0=(J)=>{return`${J} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`},FN=l5[" use ".trim().toString()];var Yd=E(c(),1),HW0=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],_0=HW0.reduce((J,Q)=>{let Z=A8(`Primitive.${Q}`),q=Xd.forwardRef((X,K)=>{let{asChild:Y,...W}=X,z=Y?Z:Q;if(typeof window<"u")window[Symbol.for("radix-ui")]=!0;return Yd.jsx(z,{...W,ref:K})});return q.displayName=`Primitive.${Q}`,{...J,[Q]:q}},{});function RY(J,Q){if(J)Kd.flushSync(()=>J.dispatchEvent(Q))}var T0=E(m(),1);var i7=E(m(),1);var VN=E(c(),1),NN=E(m(),1);var FW0=E(c(),1);function x2(J){let Q=J+"CollectionProvider",[Z,q]=U4(Q),[X,K]=Z(Q,{collectionRef:{current:null},itemMap:new Map}),Y=(V)=>{let{scope:N,children:B}=V,O=i7.useRef(null),M=i7.useRef(new Map).current;return VN.jsx(X,{scope:N,itemMap:M,collectionRef:O,children:B})};Y.displayName=Q;let W=J+"CollectionSlot",z=A8(W),G=i7.forwardRef((V,N)=>{let{scope:B,children:O}=V,M=K(W,B),L=p0(N,M.collectionRef);return VN.jsx(z,{ref:L,children:O})});G.displayName=W;let H=J+"CollectionItemSlot",$="data-radix-collection-item",_=A8(H),F=i7.forwardRef((V,N)=>{let{scope:B,children:O,...M}=V,L=i7.useRef(null),j=p0(N,L),k=K(H,B);return i7.useEffect(()=>{return k.itemMap.set(L,{ref:L,...M}),()=>void k.itemMap.delete(L)}),VN.jsx(_,{...{[$]:""},ref:j,children:O})});F.displayName=H;function U(V){let N=K(J+"CollectionConsumer",V);return i7.useCallback(()=>{let O=N.collectionRef.current;if(!O)return[];let M=Array.from(O.querySelectorAll(`[${$}]`));return Array.from(N.itemMap.values()).sort((k,R)=>M.indexOf(k.ref.current)-M.indexOf(R.ref.current))},[N.collectionRef,N.itemMap])}return[{Provider:Y,Slot:G,ItemSlot:F},U,q]}var Wd=new WeakMap,Ka0=class J extends Map{#J;constructor(Q){super(Q);this.#J=[...super.keys()],Wd.set(this,!0)}set(Q,Z){if(Wd.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=zd(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 H=[...this.#J],$,_=!1;for(let F=W;F<G;F++)if(W===F){let U=H[F];if(H[F]===Z)U=H[F+1];if(X)this.delete(Z);$=this.get(U),this.set(Z,q)}else{if(!_&&H[F-1]===Z)_=!0;let U=H[_?F:F-1],V=$;$=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=oE(this.#J,Q);if(Z!==void 0)return this.get(Z)}entryAt(Q){let Z=oE(this.#J,Q);if(Z!==void 0)return[Z,this.get(Z)]}indexOf(Q){return this.#J.indexOf(Q)}keyAt(Q){return oE(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 oE(J,Q){if("at"in Array.prototype)return Array.prototype.at.call(J,Q);let Z=_W0(J,Q);return Z===-1?void 0:J[Z]}function _W0(J,Q){let Z=J.length,q=zd(Q),X=q>=0?q:Z+q;return X<0||X>=Z?-1:X}function zd(J){return J!==J||J===0?0:Math.trunc(J)}var BN=E(m(),1),UW0=E(c(),1),VW0=BN.createContext(void 0);function G7(J){let Q=BN.useContext(VW0);return J||Q||"ltr"}var W4=E(m(),1);var kY=E(m(),1);function H6(J){let Q=kY.useRef(J);return kY.useEffect(()=>{Q.current=J}),kY.useMemo(()=>(...Z)=>Q.current?.(...Z),[])}var Gd=E(m(),1);function $d(J,Q=globalThis?.document){let Z=H6(J);Gd.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 eE=E(c(),1),NW0="DismissableLayer",tE="dismissableLayer.update",BW0="dismissableLayer.pointerDownOutside",OW0="dismissableLayer.focusOutside",Hd,JA=W4.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),$7=W4.forwardRef((J,Q)=>{let{disableOutsidePointerEvents:Z=!1,deferPointerDownOutside:q=!1,onEscapeKeyDown:X,onPointerDownOutside:K,onFocusOutside:Y,onInteractOutside:W,onDismiss:z,...G}=J,H=W4.useContext(JA),[$,_]=W4.useState(null),F=$?.ownerDocument??globalThis?.document,[,U]=W4.useState({}),V=p0(Q,(A)=>_(A)),N=Array.from(H.layers),[B]=[...H.layersWithOutsidePointerEventsDisabled].slice(-1),O=N.indexOf(B),M=$?N.indexOf($):-1,L=H.layersWithOutsidePointerEventsDisabled.size>0,j=M>=O,k=W4.useRef(!1),R=DW0((A)=>{let w=A.target;if(!(w instanceof Node))return;let C=[...H.branches].some((x)=>x.contains(w));if(!j||C)return;if(K?.(A),W?.(A),!A.defaultPrevented)z?.()},{ownerDocument:F,deferPointerDownOutside:q,isDeferredPointerDownOutsideRef:k,dismissableSurfaces:H.dismissableSurfaces}),I=MW0((A)=>{if(q&&k.current)return;let w=A.target;if([...H.branches].some((x)=>x.contains(w)))return;if(Y?.(A),W?.(A),!A.defaultPrevented)z?.()},F);return $d((A)=>{if(M!==H.layers.size-1)return;if(X?.(A),!A.defaultPrevented&&z)A.preventDefault(),z()},F),W4.useEffect(()=>{if(!$)return;if(Z){if(H.layersWithOutsidePointerEventsDisabled.size===0)Hd=F.body.style.pointerEvents,F.body.style.pointerEvents="none";H.layersWithOutsidePointerEventsDisabled.add($)}return H.layers.add($),_d(),()=>{if(Z){if(H.layersWithOutsidePointerEventsDisabled.delete($),H.layersWithOutsidePointerEventsDisabled.size===0)F.body.style.pointerEvents=Hd}}},[$,F,Z,H]),W4.useEffect(()=>{return()=>{if(!$)return;H.layers.delete($),H.layersWithOutsidePointerEventsDisabled.delete($),_d()}},[$,H]),W4.useEffect(()=>{let A=()=>U({});return document.addEventListener(tE,A),()=>document.removeEventListener(tE,A)},[]),eE.jsx(_0.div,{...G,ref:V,style:{pointerEvents:L?j?"auto":"none":void 0,...J.style},onFocusCapture:Z0(J.onFocusCapture,I.onFocusCapture),onBlurCapture:Z0(J.onBlurCapture,I.onBlurCapture),onPointerDownCapture:Z0(J.onPointerDownCapture,R.onPointerDownCapture)})});$7.displayName=NW0;var LW0="DismissableLayerBranch",Fd=W4.forwardRef((J,Q)=>{let Z=W4.useContext(JA),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]),eE.jsx(_0.div,{...J,ref:X})});Fd.displayName=LW0;function Ud(){let J=W4.useContext(JA),[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 DW0(J,Q){let{ownerDocument:Z=globalThis?.document,deferPointerDownOutside:q=!1,isDeferredPointerDownOutsideRef:X,dismissableSurfaces:K}=Q,Y=H6(J),W=W4.useRef(!1),z=W4.useRef(!1),G=W4.useRef(new Map),H=W4.useRef(()=>{});return W4.useEffect(()=>{function $(){z.current=!1,X.current=!1,G.current.clear()}function _(){return Array.from(G.current.values()).some(Boolean)}function F(O){if(!z.current)return;let M=O.target;if(!(M instanceof Node&&[...K].some((j)=>j.contains(M))))G.current.set(O.type,!0);if(O.type==="click")window.setTimeout(()=>{if(z.current)H.current()},0)}function U(O){if(z.current)G.current.set(O.type,!1)}let V=(O)=>{if(O.target&&!W.current){let L=function(){Z.removeEventListener("click",H.current);let k=_();if($(),!k)Vd(BW0,Y,j,{discrete:!0})};var M=L;let j={originalEvent:O};if(z.current=!0,X.current=q&&O.button===0,G.current.clear(),!q||O.button!==0)L();else Z.removeEventListener("click",H.current),H.current=L,Z.addEventListener("click",H.current,{once:!0})}else Z.removeEventListener("click",H.current),$();W.current=!1},N=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(let O of N)Z.addEventListener(O,F,!0),Z.addEventListener(O,U);let B=window.setTimeout(()=>{Z.addEventListener("pointerdown",V)},0);return()=>{window.clearTimeout(B),Z.removeEventListener("pointerdown",V),Z.removeEventListener("click",H.current);for(let O of N)Z.removeEventListener(O,F,!0),Z.removeEventListener(O,U)}},[Z,Y,q,X,K]),{onPointerDownCapture:()=>W.current=!0}}function MW0(J,Q=globalThis?.document){let Z=H6(J),q=W4.useRef(!1);return W4.useEffect(()=>{let X=(K)=>{if(K.target&&!q.current)Vd(OW0,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 _d(){let J=new CustomEvent(tE);document.dispatchEvent(J)}function Vd(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)RY(X,K);else X.dispatchEvent(K)}var Nd=$7,Bd=Fd;var Ld=E(m(),1),ON=0,EY=null;function bZ(){Ld.useEffect(()=>{if(!EY)EY={start:Od(),end:Od()};let{start:J,end:Q}=EY;if(document.body.firstElementChild!==J)document.body.insertAdjacentElement("afterbegin",J);if(document.body.lastElementChild!==Q)document.body.insertAdjacentElement("beforeend",Q);return ON++,()=>{if(ON===1)EY?.start.remove(),EY?.end.remove(),EY=null;ON=Math.max(0,ON-1)}},[])}function Od(){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 H7=E(m(),1);var kd=E(c(),1),QA="focusScope.autoFocusOnMount",ZA="focusScope.autoFocusOnUnmount",Dd={bubbles:!1,cancelable:!0},RW0="FocusScope",nJ=H7.forwardRef((J,Q)=>{let{loop:Z=!1,trapped:q=!1,onMountAutoFocus:X,onUnmountAutoFocus:K,...Y}=J,[W,z]=H7.useState(null),G=H6(X),H=H6(K),$=H7.useRef(null),_=p0(Q,(V)=>z(V)),F=H7.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;H7.useEffect(()=>{if(q){let O=function(k){if(F.paused||!W)return;let R=k.target;if(W.contains(R))$.current=R;else TZ($.current,{select:!0})},M=function(k){if(F.paused||!W)return;let R=k.relatedTarget;if(R===null)return;if(!W.contains(R))TZ($.current,{select:!0})},L=function(k){if(document.activeElement!==document.body)return;for(let I of k)if(I.removedNodes.length>0)TZ(W)};var V=O,N=M,B=L;document.addEventListener("focusin",O),document.addEventListener("focusout",M);let j=new MutationObserver(L);if(W)j.observe(W,{childList:!0,subtree:!0});return()=>{document.removeEventListener("focusin",O),document.removeEventListener("focusout",M),j.disconnect()}}},[q,W,F.paused]),H7.useEffect(()=>{if(W){jd.add(F);let V=document.activeElement;if(!W.contains(V)){let B=new CustomEvent(QA,Dd);if(W.addEventListener(QA,G),W.dispatchEvent(B),!B.defaultPrevented){if(kW0(IW0(Ed(W)),{select:!0}),document.activeElement===V)TZ(W)}}return()=>{W.removeEventListener(QA,G),setTimeout(()=>{let B=new CustomEvent(ZA,Dd);if(W.addEventListener(ZA,H),W.dispatchEvent(B),!B.defaultPrevented)TZ(V??document.body,{select:!0});W.removeEventListener(ZA,H),jd.remove(F)},0)}}},[W,G,H,F]);let U=H7.useCallback((V)=>{if(!Z&&!q)return;if(F.paused)return;let N=V.key==="Tab"&&!V.altKey&&!V.ctrlKey&&!V.metaKey,B=document.activeElement;if(N&&B){let O=V.currentTarget,[M,L]=EW0(O);if(!(M&&L)){if(B===O)V.preventDefault()}else if(!V.shiftKey&&B===L){if(V.preventDefault(),Z)TZ(M,{select:!0})}else if(V.shiftKey&&B===M){if(V.preventDefault(),Z)TZ(L,{select:!0})}}},[Z,q,F.paused]);return kd.jsx(_0.div,{tabIndex:-1,...Y,ref:_,onKeyDown:U})});nJ.displayName=RW0;function kW0(J,{select:Q=!1}={}){let Z=document.activeElement;for(let q of J)if(TZ(q,{select:Q}),document.activeElement!==Z)return}function EW0(J){let Q=Ed(J),Z=Md(Q,J),q=Md(Q.reverse(),J);return[Z,q]}function Ed(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 Md(J,Q){for(let Z of J)if(!AW0(Z,{upTo:Q}))return Z}function AW0(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 CW0(J){return J instanceof HTMLInputElement&&"select"in J}function TZ(J,{select:Q=!1}={}){if(J&&J.focus){let Z=document.activeElement;if(J.focus({preventScroll:!0}),J!==Z&&CW0(J)&&Q)J.select()}}var jd=PW0();function PW0(){let J=[];return{add(Q){let Z=J[0];if(Q!==Z)Z?.pause();J=Rd(J,Q),J.unshift(Q)},remove(Q){J=Rd(J,Q),J[0]?.resume()}}}function Rd(J,Q){let Z=[...J],q=Z.indexOf(Q);if(q!==-1)Z.splice(q,1);return Z}function IW0(J){return J.filter((Q)=>Q.tagName!=="A")}var qA=E(m(),1);var Ad=E(m(),1),f4=globalThis?.document?Ad.useLayoutEffect:()=>{};var wW0=qA[" useId ".trim().toString()]||(()=>{return}),bW0=0;function o6(J){let[Q,Z]=qA.useState(wW0());return f4(()=>{if(!J)Z((q)=>q??String(bW0++))},[J]),J||(Q?`radix-${Q}`:"")}var p5=E(m(),1);var Cd=E(m(),1);var XA=E(c(),1),TW0="Arrow",Pd=Cd.forwardRef((J,Q)=>{let{children:Z,width:q=10,height:X=5,...K}=J;return XA.jsx(_0.svg,{...K,ref:Q,width:q,height:X,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:J.asChild?Z:XA.jsx("polygon",{points:"0,0 30,0 15,10"})})});Pd.displayName=TW0;var Id=Pd;var wd=E(m(),1);function LN(J){let[Q,Z]=wd.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 yZ=E(c(),1);var KA="Popper",[ud,_7]=U4(KA),[xW0,md]=ud(KA),cd=(J)=>{let{__scopePopper:Q,children:Z}=J,[q,X]=p5.useState(null),[K,Y]=p5.useState(void 0);return yZ.jsx(xW0,{scope:Q,anchor:q,onAnchorChange:X,placementState:K,setPlacementState:Y,children:Z})};cd.displayName=KA;var ld="PopperAnchor",pd=p5.forwardRef((J,Q)=>{let{__scopePopper:Z,virtualRef:q,...X}=J,K=md(ld,Z),Y=p5.useRef(null),W=K.onAnchorChange,z=p5.useCallback((U)=>{if(Y.current=U,U)W(U)},[W]),G=p0(Q,z),H=p5.useRef(null);p5.useEffect(()=>{if(!q)return;let U=H.current;if(H.current=q.current,U!==H.current)W(H.current)});let $=K.placementState&&WA(K.placementState),_=$?.[0],F=$?.[1];return q?null:yZ.jsx(_0.div,{"data-radix-popper-side":_,"data-radix-popper-align":F,...X,ref:G})});pd.displayName=ld;var YA="PopperContent",[vW0,SW0]=ud(YA),dd=p5.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:H=0,sticky:$="partial",hideWhenDetached:_=!1,updatePositionStrategy:F="optimized",onPlaced:U,...V}=J,N=md(YA,Z),[B,O]=p5.useState(null),M=p0(Q,(L0)=>O(L0)),[L,j]=p5.useState(null),k=LN(L),R=k?.width??0,I=k?.height??0,A=q+(K!=="center"?"-"+K:""),w=typeof H==="number"?H:{top:0,right:0,bottom:0,left:0,...H},C=Array.isArray(G)?G:[G],x=C.length>0,f={padding:w,boundary:C.filter(gW0),altBoundary:x},{refs:T,floatingStyles:h,placement:b,isPositioned:v,middlewareData:g}=Td({strategy:"fixed",placement:A,whileElementsMounted:(...L0)=>{return bd(...L0,{animationFrame:F==="always"})},elements:{reference:N.anchor},middleware:[yd({mainAxis:X+I,alignmentAxis:Y}),z&&xd({mainAxis:!0,crossAxis:!1,limiter:$==="partial"?vd():void 0,...f}),z&&Sd({...f}),fd({...f,apply:({elements:L0,rects:Z1,availableWidth:q1,availableHeight:r})=>{let{width:s,height:F0}=Z1.reference,s0=L0.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`)}}),L&&hd({element:L,padding:W}),hW0({arrowWidth:R,arrowHeight:I}),_&&gd({strategy:"referenceHidden",...f,boundary:x?f.boundary:void 0})]}),u=N.setPlacementState;f4(()=>{return u(b),()=>{u(void 0)}},[b,u]);let[n,o]=WA(b),K0=H6(U);f4(()=>{if(v)K0?.()},[v,K0]);let U0=g.arrow?.x,y0=g.arrow?.y,D1=g.arrow?.centerOffset!==0,[j0,Y0]=p5.useState();return f4(()=>{if(B)Y0(window.getComputedStyle(B).zIndex)},[B]),yZ.jsx("div",{ref:T.setFloating,"data-radix-popper-content-wrapper":"",style:{...h,transform:v?h.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:j0,"--radix-popper-transform-origin":[g.transformOrigin?.x,g.transformOrigin?.y].join(" "),...g.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:J.dir,children:yZ.jsx(vW0,{scope:Z,placedSide:n,placedAlign:o,onArrowChange:j,arrowX:U0,arrowY:y0,shouldHideArrow:D1,children:yZ.jsx(_0.div,{"data-side":n,"data-align":o,...V,ref:M,style:{...V.style,animation:!v?"none":void 0}})})})});dd.displayName=YA;var id="PopperArrow",fW0={top:"bottom",right:"left",bottom:"top",left:"right"},nd=p5.forwardRef(function(Q,Z){let{__scopePopper:q,...X}=Q,K=SW0(id,q),Y=fW0[K.placedSide];return yZ.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:yZ.jsx(Id,{...X,ref:Z,style:{...X.style,display:"block"}})})});nd.displayName=id;function gW0(J){return J!==null}var hW0=(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,H]=WA(Z),$={start:"0%",center:"50%",end:"100%"}[H],_=(X.arrow?.x??0)+W/2,F=(X.arrow?.y??0)+z/2,U="",V="";if(G==="bottom")U=Y?$:`${_}px`,V=`${-z}px`;else if(G==="top")U=Y?$:`${_}px`,V=`${q.floating.height+z}px`;else if(G==="right")U=`${-z}px`,V=Y?$:`${F}px`;else if(G==="left")U=`${q.floating.width+z}px`,V=Y?$:`${F}px`;return{data:{x:U,y:V}}}});function WA(J){let[Q,Z="center"]=J.split("-");return[Q,Z]}var sJ=cd,rJ=pd,xZ=dd,vZ=nd;var MN=E(m(),1),sd=E(KZ(),1);var rd=E(c(),1),uW0="Portal",g9=MN.forwardRef((J,Q)=>{let{container:Z,...q}=J,[X,K]=MN.useState(!1);f4(()=>K(!0),[]);let Y=Z||X&&globalThis?.document?.body;return Y?sd.createPortal(rd.jsx(_0.div,{...q,ref:Q}),Y):null});g9.displayName=uW0;var W8=E(m(),1);var od=E(m(),1);function mW0(J,Q){return od.useReducer((Z,q)=>{return Q[Z][q]??Z},J)}var t6=(J)=>{let{present:Q,children:Z}=J,q=cW0(Q),X=typeof Z==="function"?Z({present:q.isPresent}):W8.Children.only(Z),K=lW0(q.ref,pW0(X));return typeof Z==="function"||q.isPresent?W8.cloneElement(X,{ref:K}):null};t6.displayName="Presence";function cW0(J){let[Q,Z]=W8.useState(),q=W8.useRef(null),X=W8.useRef(J),K=W8.useRef("none"),Y=J?"mounted":"unmounted",[W,z]=mW0(Y,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return W8.useEffect(()=>{let G=jN(q.current);K.current=W==="mounted"?G:"none"},[W]),f4(()=>{let G=q.current,H=X.current;if(H!==J){let _=K.current,F=jN(G);if(J)z("MOUNT");else if(F==="none"||G?.display==="none")z("UNMOUNT");else if(H&&_!==F)z("ANIMATION_OUT");else z("UNMOUNT");X.current=J}},[J,z]),f4(()=>{if(Q){let G,H=Q.ownerDocument.defaultView??window,$=(F)=>{let V=jN(q.current).includes(CSS.escape(F.animationName));if(F.target===Q&&V){if(z("ANIMATION_END"),!X.current){let N=Q.style.animationFillMode;Q.style.animationFillMode="forwards",G=H.setTimeout(()=>{if(Q.style.animationFillMode==="forwards")Q.style.animationFillMode=N})}}},_=(F)=>{if(F.target===Q)K.current=jN(q.current)};return Q.addEventListener("animationstart",_),Q.addEventListener("animationcancel",$),Q.addEventListener("animationend",$),()=>{H.clearTimeout(G),Q.removeEventListener("animationstart",_),Q.removeEventListener("animationcancel",$),Q.removeEventListener("animationend",$)}}else z("ANIMATION_END")},[Q,z]),{isPresent:["mounted","unmountSuspended"].includes(W),ref:W8.useCallback((G)=>{q.current=G?getComputedStyle(G):null,Z(G)},[])}}function ad(J,Q){if(typeof J==="function")return J(Q);else if(J!==null&&J!==void 0)J.current=Q}function lW0(...J){let Q=W8.useRef(J);return Q.current=J,W8.useCallback((Z)=>{let q=Q.current,X=!1,K=q.map((Y)=>{let W=ad(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 ad(q[Y],null)}}},[])}function jN(J){return J?.animationName||"none"}function pW0(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 A5=E(m(),1);var F7=E(m(),1);var RN=E(m(),1);var dW0=F7[" useInsertionEffect ".trim().toString()]||f4;function g4({prop:J,defaultProp:Q,onChange:Z=()=>{},caller:q}){let[X,K,Y]=iW0({defaultProp:Q,onChange:Z}),W=J!==void 0,z=W?J:X;{let H=F7.useRef(J!==void 0);F7.useEffect(()=>{let $=H.current;if($!==W)console.warn(`${q} is changing from ${$?"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.`);H.current=W},[W,q])}let G=F7.useCallback((H)=>{if(W){let $=nW0(H)?H(J):H;if($!==J)Y.current?.($)}else K(H)},[W,J,K,Y]);return[z,G]}function iW0({defaultProp:J,onChange:Q}){let[Z,q]=F7.useState(J),X=F7.useRef(Z),K=F7.useRef(Q);return dW0(()=>{K.current=Q},[Q]),F7.useEffect(()=>{if(X.current!==Z)K.current?.(Z),X.current=Z},[Z,X]),[Z,q,K]}function nW0(J){return typeof J==="function"}var ua0=Symbol("RADIX:SYNC_STATE");var SZ=E(c(),1),zA="rovingFocusGroup.onEntryFocus",sW0={bubbles:!1,cancelable:!0},h$="RovingFocusGroup",[GA,td,rW0]=x2(h$),[aW0,aJ]=U4(h$,[rW0]),[oW0,tW0]=aW0(h$),ed=A5.forwardRef((J,Q)=>{return SZ.jsx(GA.Provider,{scope:J.__scopeRovingFocusGroup,children:SZ.jsx(GA.Slot,{scope:J.__scopeRovingFocusGroup,children:SZ.jsx(eW0,{...J,ref:Q})})})});ed.displayName=h$;var eW0=A5.forwardRef((J,Q)=>{let{__scopeRovingFocusGroup:Z,orientation:q,loop:X=!1,dir:K,currentTabStopId:Y,defaultCurrentTabStopId:W,onCurrentTabStopIdChange:z,onEntryFocus:G,preventScrollOnEntryFocus:H=!1,...$}=J,_=A5.useRef(null),F=p0(Q,_),U=G7(K),[V,N]=g4({prop:Y,defaultProp:W??null,onChange:z,caller:h$}),[B,O]=A5.useState(!1),M=H6(G),L=td(Z),j=A5.useRef(!1),[k,R]=A5.useState(0);return A5.useEffect(()=>{let I=_.current;if(I)return I.addEventListener(zA,M),()=>I.removeEventListener(zA,M)},[M]),SZ.jsx(oW0,{scope:Z,orientation:q,dir:U,loop:X,currentTabStopId:V,onItemFocus:A5.useCallback((I)=>N(I),[N]),onItemShiftTab:A5.useCallback(()=>O(!0),[]),onFocusableItemAdd:A5.useCallback(()=>R((I)=>I+1),[]),onFocusableItemRemove:A5.useCallback(()=>R((I)=>I-1),[]),children:SZ.jsx(_0.div,{tabIndex:B||k===0?-1:0,"data-orientation":q,...$,ref:F,style:{outline:"none",...J.style},onMouseDown:Z0(J.onMouseDown,()=>{j.current=!0}),onFocus:Z0(J.onFocus,(I)=>{let A=!j.current;if(I.target===I.currentTarget&&A&&!B){let w=new CustomEvent(zA,sW0);if(I.currentTarget.dispatchEvent(w),!w.defaultPrevented){let C=L().filter((b)=>b.focusable),x=C.find((b)=>b.active),f=C.find((b)=>b.id===V),h=[x,f,...C].filter(Boolean).map((b)=>b.ref.current);Zi(h,H)}}j.current=!1}),onBlur:Z0(J.onBlur,()=>O(!1))})})}),Ji="RovingFocusGroupItem",Qi=A5.forwardRef((J,Q)=>{let{__scopeRovingFocusGroup:Z,focusable:q=!0,active:X=!1,tabStopId:K,children:Y,...W}=J,z=o6(),G=K||z,H=tW0(Ji,Z),$=H.currentTabStopId===G,_=td(Z),{onFocusableItemAdd:F,onFocusableItemRemove:U,currentTabStopId:V}=H;return A5.useEffect(()=>{if(q)return F(),()=>U()},[q,F,U]),SZ.jsx(GA.ItemSlot,{scope:Z,id:G,focusable:q,active:X,children:SZ.jsx(_0.span,{tabIndex:$?0:-1,"data-orientation":H.orientation,...W,ref:Q,onMouseDown:Z0(J.onMouseDown,(N)=>{if(!q)N.preventDefault();else H.onItemFocus(G)}),onFocus:Z0(J.onFocus,()=>H.onItemFocus(G)),onKeyDown:Z0(J.onKeyDown,(N)=>{if(N.key==="Tab"&&N.shiftKey){H.onItemShiftTab();return}if(N.target!==N.currentTarget)return;let B=Zz0(N,H.orientation,H.dir);if(B!==void 0){if(N.metaKey||N.ctrlKey||N.altKey||N.shiftKey)return;N.preventDefault();let M=_().filter((L)=>L.focusable).map((L)=>L.ref.current);if(B==="last")M.reverse();else if(B==="prev"||B==="next"){if(B==="prev")M.reverse();let L=M.indexOf(N.currentTarget);M=H.loop?qz0(M,L+1):M.slice(L+1)}setTimeout(()=>Zi(M))}}),children:typeof Y==="function"?Y({isCurrentTabStop:$,hasTabStop:V!=null}):Y})})});Qi.displayName=Ji;var Jz0={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Qz0(J,Q){if(Q!=="rtl")return J;return J==="ArrowLeft"?"ArrowRight":J==="ArrowRight"?"ArrowLeft":J}function Zz0(J,Q,Z){let q=Qz0(J.key,Z);if(Q==="vertical"&&["ArrowLeft","ArrowRight"].includes(q))return;if(Q==="horizontal"&&["ArrowUp","ArrowDown"].includes(q))return;return Jz0[q]}function Zi(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 qz0(J,Q){return J.map((Z,q)=>J[(Q+q)%J.length])}var AY=ed,n3=Qi;var Xz0=function(J){if(typeof document>"u")return null;var Q=Array.isArray(J)?J[0]:J;return Q.ownerDocument.body},CY=new WeakMap,kN=new WeakMap,EN={},HA=0,qi=function(J){return J&&(J.host||qi(J.parentNode))},Kz0=function(J,Q){return Q.map(function(Z){if(J.contains(Z))return Z;var q=qi(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)})},Yz0=function(J,Q,Z,q){var X=Kz0(Q,Array.isArray(J)?J:[J]);if(!EN[Z])EN[Z]=new WeakMap;var K=EN[Z],Y=[],W=new Set,z=new Set(X),G=function($){if(!$||W.has($))return;W.add($),G($.parentNode)};X.forEach(G);var H=function($){if(!$||z.has($))return;Array.prototype.forEach.call($.children,function(_){if(W.has(_))H(_);else try{var F=_.getAttribute(q),U=F!==null&&F!=="false",V=(CY.get(_)||0)+1,N=(K.get(_)||0)+1;if(CY.set(_,V),K.set(_,N),Y.push(_),V===1&&U)kN.set(_,!0);if(N===1)_.setAttribute(Z,"true");if(!U)_.setAttribute(q,"true")}catch(B){console.error("aria-hidden: cannot operate on ",_,B)}})};return H(Q),W.clear(),HA++,function(){if(Y.forEach(function($){var _=CY.get($)-1,F=K.get($)-1;if(CY.set($,_),K.set($,F),!_){if(!kN.has($))$.removeAttribute(q);kN.delete($)}if(!F)$.removeAttribute(Z)}),HA--,!HA)CY=new WeakMap,CY=new WeakMap,kN=new WeakMap,EN={}}},fZ=function(J,Q,Z){if(Z===void 0)Z="data-aria-hidden";var q=Array.from(Array.isArray(J)?J:[J]),X=Q||Xz0(J);if(!X)return function(){return null};return q.push.apply(q,Array.from(X.querySelectorAll("[aria-live], script"))),Yz0(q,X,Z,"aria-hidden")};var a8=function(){return a8=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},a8.apply(this,arguments)};function AN(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 Xi(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 bN=E(m(),1);var z8=E(m(),1);var s3="right-scroll-bar-position",r3="width-before-scroll-bar",_A="with-scroll-bars-hidden",FA="--removed-body-scroll-bar-size";var PN=E(m(),1);function CN(J,Q){if(typeof J==="function")J(Q);else if(J)J.current=Q;return J}var Ki=E(m(),1);function Yi(J,Q){var Z=Ki.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 Wz0=typeof window<"u"?PN.useLayoutEffect:PN.useEffect,Wi=new WeakMap;function UA(J,Q){var Z=Yi(Q||null,function(q){return J.forEach(function(X){return CN(X,q)})});return Wz0(function(){var q=Wi.get(Z);if(q){var X=new Set(q),K=new Set(J),Y=Z.current;X.forEach(function(W){if(!K.has(W))CN(W,null)}),K.forEach(function(W){if(!X.has(W))CN(W,Y)})}Wi.set(Z,J)},[J]),Z}function zz0(J){return J}function Gz0(J,Q){if(Q===void 0)Q=zz0;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 H=Y;Y=[],H.forEach(K)},G=function(){return Promise.resolve().then(z)};G(),Z={push:function(H){Y.push(H),G()},filter:function(H){return Y=Y.filter(H),Z}}}};return X}function VA(J){if(J===void 0)J={};var Q=Gz0(null);return Q.options=a8({async:!0,ssr:!1},J),Q}var zi=E(m(),1),Gi=function(J){var Q=J.sideCar,Z=AN(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 zi.createElement(q,a8({},Z))};Gi.isSideCarExport=!0;function NA(J,Q){return J.useMedium(Q),Gi}var IN=VA();var BA=function(){return},u$=z8.forwardRef(function(J,Q){var Z=z8.useRef(null),q=z8.useState({onScrollCapture:BA,onWheelCapture:BA,onTouchMoveCapture:BA}),X=q[0],K=q[1],Y=J.forwardProps,W=J.children,z=J.className,G=J.removeScrollBar,H=J.enabled,$=J.shards,_=J.sideCar,F=J.noRelative,U=J.noIsolation,V=J.inert,N=J.allowPinchZoom,B=J.as,O=B===void 0?"div":B,M=J.gapMode,L=AN(J,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),j=_,k=UA([Z,Q]),R=a8(a8({},L),X);return z8.createElement(z8.Fragment,null,H&&z8.createElement(j,{sideCar:IN,removeScrollBar:G,shards:$,noRelative:F,noIsolation:U,inert:V,setCallbacks:K,allowPinchZoom:!!N,lockRef:Z,gapMode:M}),Y?z8.cloneElement(z8.Children.only(W),a8(a8({},R),{ref:k})):z8.createElement(O,a8({},R,{className:z,ref:k}),W))});u$.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};u$.classNames={fullWidth:r3,zeroRight:s3};var s4=E(m(),1);var IY=E(m(),1);var _i=E(m(),1);var $i;var Hi=function(){if($i)return $i;if(typeof __webpack_nonce__<"u")return __webpack_nonce__;return};function $z0(){if(!document)return null;var J=document.createElement("style");J.type="text/css";var Q=Hi();if(Q)J.setAttribute("nonce",Q);return J}function Hz0(J,Q){if(J.styleSheet)J.styleSheet.cssText=Q;else J.appendChild(document.createTextNode(Q))}function _z0(J){var Q=document.head||document.getElementsByTagName("head")[0];Q.appendChild(J)}var OA=function(){var J=0,Q=null;return{add:function(Z){if(J==0){if(Q=$z0())Hz0(Q,Z),_z0(Q)}J++},remove:function(){if(J--,!J&&Q)Q.parentNode&&Q.parentNode.removeChild(Q),Q=null}}};var LA=function(){var J=OA();return function(Q,Z){_i.useEffect(function(){return J.add(Q),function(){J.remove()}},[Q&&Z])}};var m$=function(){var J=LA(),Q=function(Z){var{styles:q,dynamic:X}=Z;return J(q,X),null};return Q};var Fz0={left:0,top:0,right:0,gap:0},DA=function(J){return parseInt(J||"",10)||0},Uz0=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[DA(Z),DA(q),DA(X)]},MA=function(J){if(J===void 0)J="margin";if(typeof window>"u")return Fz0;var Q=Uz0(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 Vz0=m$(),PY="data-scroll-locked",Nz0=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(_A,` {
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 FN0({shape:J,src:Q}){let Z=D5(),q=le(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,H=[new D(0,0),new D(z,0),new D(z,G),new D(0,G)],$=X_(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:H.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:$?{...$}:{transform:K}})})]})}else return C4.jsx("image",{href:Q,width:J.props.w,height:J.props.h,"aria-label":J.props.altText,style:X_(J,{width:J.props.w,height:J.props.h})})}function pe(J){let Q=!1;return{promise:new Promise((q)=>{let X=P7();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 ML=E(c(),1);var UN0=new C1;class jL extends s6{static type="line";static props=cz;static migrations=lz;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]=V2(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=vb(J).toGeometry();return Q0(Q instanceof HY),Q}getHandles(J){return UN0.get(J.props,()=>{let Q=this.getGeometry(J),Z=K_(J),q=Z.map((X)=>({...X,id:X.index,type:"vertex",canSnap:!0}));for(let X=0;X<Z.length-1;X++){let K=i9(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(L4)})}onResize(J,Q){let{scaleX:Z,scaleY:q}=Q;return{props:{points:B5(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 D(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 ML.jsx(e5,{style:{minWidth:50,minHeight:50},children:ML.jsx(de,{shape:J,strokeColor:Z.strokeColor,strokeWidth:Z.strokeWidth})})}getIndicatorPath(J){let Q=k0(this,J).strokeWidth*J.props.scale,Z=vb(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 ML.jsx(de,{shouldScale:!0,shape:J,strokeColor:Z.strokeColor,strokeWidth:Z.strokeWidth})}getHandleSnapGeometry(J){let Q=K_(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(D.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=K_(J),X=K_(Q),K=[],Y=[],W=fq;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 H=Y[G];return[z.id,{...z,x:I0(z.x,H.x,Z),y:I0(z.y,H.y,Z)}]})),scale:I0(J.props.scale,Q.props.scale,Z)}}}function K_(J){return Object.values(J.props.points).sort(L4)}var VN0=new C1;function vb(J){return VN0.get(J,()=>{let Q=K_(J).map(D.From);switch(J.props.spline){case"cubic":return P1.cubicSplineThroughPoints(Q,{endOffsets:0});case"line":return P1.lineThroughPoints(Q,{endOffsets:0})}})}function de({shape:J,shouldScale:Q=!1,forceSolid:Z=!1,strokeColor:q,strokeWidth:X}){let K=vb(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 kL=E(m(),1);var NN0=Object.freeze({start:"start",middle:"center",end:"end","start-legacy":"start","end-legacy":"end","middle-legacy":"center"}),BN0=Object.freeze({start:"start",middle:"middle",end:"end"});class EL extends s6{static type="note";static props=pz;static migrations=dz;options={resizeMode:"none",getDefaultDisplayValues(J,Q,Z,q){let{color:X,labelColor:K,font:Y,size:W,align:z,verticalAlign:G}=Q.props,H=Z.colors[q];return{noteWidth:200,noteHeight:200,noteBackgroundColor:W1(H,X,"noteFill"),borderColor:H.noteBorder,borderWidth:2,labelColor:K==="black"?W1(H,X,"noteText"):W1(H,K,"fill"),labelFontFamily:v9(Z,Y),labelFontSize:Z.fontSize*j$[W],labelLineHeight:Z.lineHeight,labelFontWeight:z5.fontWeight,labelFontVariant:z5.fontVariant,labelFontStyle:z5.fontStyle,labelPadding:mJ,labelHorizontalAlign:NN0[z],labelVerticalAlign:BN0[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:y1(""),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=RL(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=RL(J,X.noteHeight),Y=X.noteWidth*Q,W=Ze/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 wG(J,Q);default:throw h0(Z)}}getText(J){return f9(this.editor,J.props.richText)}getReferencedUserIds(J){return J.props.textLastEditedBy?[J.props.textLastEditedBy]:[]}getFontFaces(J){let Q=r1(J.props.richText)?[]:uJ(this.editor,J.props.richText,{family:`tldraw_${J.props.font}`,weight:"normal",style:"normal"});if(J.props.textLastEditedBy&&!r1(J.props.richText))return[...Q,d3.tldraw_sans.normal.normal];let Z=IZ(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=ON0(Q),G=S("shape rotation",()=>this.editor.getShapePageTransform(Q)?.rotation()??0,[this.editor]),H=z6(),$=k0(this,J,H),_=$.noteWidth*X,F=RL(J,$.noteHeight),U=Oq(0.25/X),V=J.id===this.editor.getOnlySelectedShapeId(),N=sH(this.editor,J.id),B=r1(K),O=S("attribution",()=>{if(!W||B)return null;let M=this.editor.getAttributionDisplayName(W);if(!M)return null;return{short:M.split(" ")[0],full:M}},[W,B,this.editor]);return m1.jsxs(m1.Fragment,{children:[m1.jsxs("div",{id:Q,className:"tl-note__container",style:{width:_,height:F,backgroundColor:$.noteBackgroundColor,borderBottom:U?`${$.borderWidth*X}px solid ${$.borderColor}`:"none",boxShadow:U?"none":LN0(J.id,G,X)},children:[O&&m1.jsx(o8,{content:O.full,side:"bottom",children:m1.jsx("div",{className:"tl-note__attribution",style:{["--note-attribution-scale"]:X,fontSize:11*X,color:$.labelColor,opacity:0.6},children:O.short})}),(V||N||!B)&&m1.jsx(CQ,{shapeId:Q,type:Z,fontFamily:$.labelFontFamily,fontSize:(Y??1)*$.labelFontSize,lineHeight:$.labelLineHeight,textAlign:$.labelHorizontalAlign,verticalAlign:$.labelVerticalAlign,richText:K,isSelected:V,labelColor:$.labelColor,wrap:!0,padding:$.labelPadding,hasCustomTabBehavior:!0,showTextOutline:!1,onKeyDown:z,style:X!==1?{transform:`scale(${X})`,transformOrigin:"top left",width:$.noteWidth,height:$.noteHeight+J.props.growY}:void 0})]}),"url"in J.props&&J.props.url&&m1.jsx(G2,{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,RL(J,Z.noteHeight)),q}toSvg(J,Q){let Z=k0(this,J,Q.colorMode),q=new p(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(PQ,{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:p8(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=S9(this.editor,Z),H=this.editor.textMeasure.measureHtml(G,{...z5,lineHeight:Q.labelLineHeight,fontFamily:Q.labelFontFamily,fontSize:X,maxWidth:Q.noteWidth-Q.labelPadding*2-z,disableOverflowWrapBreaking:!0,measureScrollWidth:!0});if(Y=H.h+Q.labelPadding*2,W=H.w+Q.labelPadding*2,X<=14){let $=S9(this.editor,Z),_=this.editor.textMeasure.measureHtml($,{...z5,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(H.scrollWidth.toFixed(0)===H.w.toFixed(0))break}while(K++<50);return{labelHeight:Y,labelWidth:W,fontSizeAdjustment:X===q?1:X/q}}}function ON0(J){let Q=y(),Z=kL.useContext(O$);return kL.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&&WN(Q)){q.preventDefault();return}if(K||Y){q.preventDefault();let W=Q.getShapePageTransform(J),z=W.rotation(),G=!!(Z?.dir==="rtl"||zN(f9(Q,X.props.richText))),H=Q.getShapeUtil(X),$=k0(H,X),F=(K?$.noteWidth+Q.options.adjacentShapeMargin:$.noteHeight+Q.options.adjacentShapeMargin+(Y&&!q.shiftKey?X.props.growY:0))*X.props.scale,U=new D(K?q.shiftKey!=G?-1:1:0,Y?q.shiftKey?-1:1:0).mul(F).add(new D($.noteWidth/2,$.noteHeight/2).mul(X.props.scale)).rot(z).add(W.point()),V=aO(Q,{shape:X,center:U,pageRotation:z,noteWidth:$.noteWidth,noteHeight:$.noteHeight});if(V)S4(Q,V,{selectAll:!0})}},[J,Q,Z?.dir])}function RL(J,Q){return(Q+J.props.growY)*J.props.scale}function LN0(J,Q,Z){let q=F9(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 Sb=E(c(),1);var ie=E(m(),1);var DN0=0.3,MN0=O9("text size",(J,Q)=>{J.fonts.trackFontsForShape(Q);let Z=J.getShapeUtil(Q),q=k0(Z,Q);return ne(J,Q.props,q)},{areRecordsEqual:(J,Q)=>J.props===Q.props});class AL extends s6{static type="text";static props=iz;static migrations=nz;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:v9(Z,K),fontSize:Z.fontSize*S3[Y],lineHeight:Z.lineHeight,fontWeight:z5.fontWeight,fontStyle:z5.fontStyle,fontVariant:z5.fontVariant}},getCustomDisplayValues(){return{}}};getDefaultProps(){return{color:"black",size:"m",w:8,font:"draw",textAlign:"start",autoSize:!0,scale:1,richText:y1("")}}getMinDimensions(J){return MN0.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=IZ(this.editor.getCurrentTheme(),J.props.font);if(Q)return Q;return uJ(this.editor,J.props.richText,{family:`tldraw_${J.props.font}`,weight:"normal",style:"normal"})}getText(J){return f9(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),H=jN0(Q);return Sb.jsx(CQ,{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:H})}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*DN0),W=new p(-Y,-Y,q+Y*2,X+Y*2);return Sb.jsx(PQ,{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,...wG(J,Q)};else{let W=Math.max(1,Math.abs(q.width*K)),{x:z,y:G}=K<0?D.Sub(Z,D.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(f9(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=ne(this.editor,Q.props,K),W=X.width*J.props.scale,z=X.height*J.props.scale,G=Y.width*Q.props.scale,H=Y.height*Q.props.scale,$;switch(Q.props.textAlign){case"middle":{$=new D((G-W)/2,q?0:(H-z)/2);break}case"end":{$=new D(G-W,q?0:(H-z)/2);break}default:{if(q)break;$=new D(0,(H-z)/2);break}}if($){$.rot(Q.rotation);let{x:_,y:F}=Q;return{...Q,x:_-$.x,y:F-$.y,props:{...Q.props,w:G}}}else return{...Q,props:{...Q.props,w:G}}}}function ne(J,Q,Z){let{richText:q,w:X}=Q,K=16,Y=Q.autoSize?null:Math.max(16,Math.floor(X)),W=S9(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 jN0(J){let Q=y();return ie.useCallback((Z)=>{if(Q.getEditingShapeId()!==J)return;switch(Z.key){case"Enter":{if(Z.ctrlKey||Z.metaKey)Q.complete();break}}},[Q,J])}var T5=E(c(),1);var se=E(c1(),1),A7=E(m(),1);var RN0=new C1;class CL extends d8{static type="video";static props=sz;static migrations=rz;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 T5.jsx(kN0,{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 RN0.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 T5.jsx("image",{href:X,width:Z.w,height:Z.h,"aria-label":J.props.altText})}}var kN0=A7.memo(function({shape:Q}){let Z=y(),q=Z.getShapeGeometry(Q).bounds.w*Z.getEfficientZoomLevel()>=110,X=IJ(Q.id),K=V$(),{Spinner:Y}=T4(),{asset:W,url:z}=Q_({shapeId:Q.id,assetId:Q.props.assetId,width:Q.props.w}),G=A7.useRef(null),[H,$]=A7.useState(!1),_=A7.useCallback((V)=>{if(!V.currentTarget)return;$(!0)},[]),[F,U]=A7.useState(!1);return A7.useEffect(()=>{let V=G.current?.ownerDocument??Z.getContainerDocument(),N=()=>U(V.fullscreenElement===G.current);return V.addEventListener("fullscreenchange",N),()=>V.removeEventListener("fullscreenchange",N)}),A7.useEffect(()=>{let V=G.current;if(!V)return;if(X){if(V.ownerDocument.activeElement!==V)V.focus()}},[X,H]),T5.jsxs(T5.Fragment,{children:[T5.jsx(u8,{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:T5.jsx("div",{className:"tl-counter-scaled",children:T5.jsx("div",{className:"tl-video-container",children:!W?T5.jsx(OL,{}):Y&&!W.props.src?T5.jsx(Y,{}):z?T5.jsxs(T5.Fragment,{children:[T5.jsx("video",{ref:G,style:X?{pointerEvents:"all"}:!H?{display:"none"}:void 0,className:se.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:!H,"aria-label":Q.props.altText,children:T5.jsx("source",{src:z})},z),!H&&Y&&T5.jsx(Y,{})]}):null})})}),"url"in Q.props&&Q.props.url&&T5.jsx(G2,{url:Q.props.url})]})});var bX=[AL,KL,zL,UL,EL,jL,FL,qL,BL,Dq,DL,CL];function fb(J){let Q=J.sideEffects.register({instance:{afterChange:(Z,q)=>{if(Z.cameraState!==q.cameraState&&q.cameraState==="idle")W2(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(),Vq(J)}}class gb 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=p.FromPoints([K,X]).expandBy(W),G=J.getShapeIdsInsideBounds(z);if(G.size===0){J.setErasingShapes(Array.from(Y));return}let $=J.getCurrentPageRenderingShapesSorted().filter((_)=>G.has(_.id));for(let _ of $){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 N=V.clone().invert(),B=N.applyToPoint(K),O=N.applyToPoint(X),{bounds:M}=U;if(M.minX-W>Math.max(B.x,O.x)||M.minY-W>Math.max(B.y,O.y)||M.maxX+W<Math.min(B.x,O.x)||M.maxY+W<Math.min(B.y,O.y))continue;if(U.hitTestLineSegment(B,O,W)){let L=J.getOutermostSelectableShape(_);if(Q.has(L.id))Y.add(J.getOutermostSelectableShape(_,(j)=>!Q.has(j.id)).id);else Y.add(L.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 hb 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 ub 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 H=this.editor.getOutermostSelectableShape(G);if(this.editor.isShapeFrameLike(H)&&K.size>Y)break;if(K.add(H.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 PL extends a{static id="eraser";static initial="idle";static isLockable=!1;static children(){return[hb,ub,gb]}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 mb extends a{static id="dragging";static trackPerformance=!0;initialCamera=new D;onEnter(){this.initialCamera=D.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=D.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 cb 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 lb extends a{static id="one_finger_zooming";anchorScreenPoint=new D;initialCamera=new D;initialZoom=1;originScreenY=0;onEnter(J){let Q=this.editor.getCamera();this.initialCamera=D.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 D(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 pb 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 IL extends a{static id="hand";static initial="idle";static isLockable=!1;static children(){return[cb,pb,mb,lb]}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:L6.easeOutQuint}});break}}}}class db 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 ib 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 wL extends a{static id="laser";static initial="idle";static children(){return[db,ib]}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 nb 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=g1("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=p.FromPoints([q,X]),{corners:H}=G,$,_,F,U,V,N,B=J.getViewportPageBounds().contains(G),O=J.getCurrentPageId(),M=J.getShapeIdsInsideBounds(G);if(M.size===0){let I=J.getInstanceState().brush;if(!I||!G.equals(I))J.updateInstanceState({brush:{...G.toJson()}});let A=J.getSelectedShapeIds();if(A.length!==W.size||A.some((w)=>!W.has(w)))J.setSelectedShapes(Array.from(W));return}let j=(B&&!this.viewportDidChange?J.getCurrentPageRenderingShapesSorted():J.getCurrentPageShapesSorted()).filter((I)=>M.has(I.id));J:for(let I=0,A=j.length;I<A;I++){if(F=j[I],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,O,W,H);continue J}if(z||J.isShapeFrameLike(F))continue J;if(G.collides(U)){if(V=J.getShapePageTransform(F),!V)continue J;N=V.clone().invert().applyToPoints(H);let w=J.getShapeGeometry(F);Q:for(let C=0;C<4;C++)if($=N[C],_=N[(C+1)%4],w.hitTestLineSegment($,_,0)){this.handleHit(F,X,O,W,H);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((I)=>!W.has(I)))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&&!HG(Y,X)&&!n1(Q,Y))return;q.add(K.id)}}var qJ={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 sb extends a{static id="pointing_resize_handle";info={};updateCursor(){let J=qJ[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=qJ[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??s8(),z=k8(J.props,W),H=(Z.onCrop?.bind(Z)??sk)(J,{handle:this.info.handle,change:Y,crop:W,uncroppedSize:z,initialShape:this.snapshot.shape,aspectRatioLocked:q});if(!H)return;this.editor.updateShapes([{id:J.id,type:J.type,...H}]),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=D.RotWith(q.getHandlePoint(this.info.handle),q.point,J),K=D.Sub(Q,X);return{shape:Z,cursorHandleOffset:K}}}class W_ 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=qJ[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 TX(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 AW(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 bL(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}=k8(Q.props,q),W=q.bottomRight.x-q.topLeft.x,z=q.bottomRight.y-q.topLeft.y,G=H1(q),H=1-W,$=1-z;return G.topLeft.x=M0(G.topLeft.x-Z.x/K,0,H),G.topLeft.y=M0(G.topLeft.y-Z.y/Y,0,$),G.bottomRight.x=G.topLeft.x+W,G.bottomRight.y=G.topLeft.y+z,{id:Q.id,type:Q.type,props:{crop:G}}}class rb 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);AW(this.editor)}onExit(){this.editor.setCursor({type:"default",rotation:0})}onPointerMove(){AW(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=TX(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 D(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 D(0,0)))return;if(Z)q.mul(10);let X=this.editor.getShape(this.editor.getCroppingShapeId());if(!X)return;let K=bL(this.editor,X,q);if(K){if(!J)this.editor.markHistoryStoppingPoint("translate crop");this.editor.updateShapes([K])}}}class ab 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 ob 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=bL(this.editor,J,q);if(X)this.editor.updateShapes([X])}}class tb extends a{static id="crop";static initial="idle";static children(){return[rb,ob,ab,W_,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 eb 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 H=this.editor.getMarkIdMatching(`creating:${this.editor.getOnlySelectedShapeId()}`);if(H)this.markId=H}else this.markId=this.editor.markHistoryStoppingPoint("dragging handle");this.initialHandle=H1(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(L4),Y=K.findIndex((H)=>H.id===J.handle.id);if(this.initialAdjacentHandle=null,J.handle.snapReferenceHandleId){let H=K.find(($)=>$.id===J.handle.snapReferenceHandleId);if(H)this.initialAdjacentHandle=H}if(!this.initialAdjacentHandle){for(let H=Y+1;H<K.length;H++){let $=K[H];if($.type==="vertex"&&$.id!=="middle"&&$.id!==J.handle.id){this.initialAdjacentHandle=$;break}}if(!this.initialAdjacentHandle)for(let H=K.length-1;H>=0;H--){let $=K[H];if($.type==="vertex"&&$.id!=="middle"&&$.id!==J.handle.id){this.initialAdjacentHandle=$;break}}}if(this.editor.isShapeOfType(Q,"arrow")){let H=Z4(this.editor,Q)[J.handle.id];if(this.isPrecise=!1,H)if(this.isPrecise=H.props.isPrecise,this.isPrecise)this.isPreciseId=H.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),jX(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(),H=J.inputs.getCtrlKey(),$=J.inputs.getAltKey(),_=J.inputs.getPointerVelocity(),F=this.info.shape,U=J.getShape(Q);if(!U)return;let V=J.getShapeUtil(U),N=J.isShapeOfType(U,"arrow")?Z4(J,U)[q.id]:void 0,B=z.clone().sub(Z).rot(-X).add(q);if(G&&K&&q.id!=="middle"){let k=D.Angle(K,B),I=XZ(k,24)-k;B=D.RotWith(B,K,I)}J.snaps.clearIndicators();let O={...q,x:B.x,y:B.y},M=!1;if(q.canSnap&&q.snapType)eX("canSnap is deprecated. Cannot use both canSnap and snapType together - snapping disabled. Please use only snapType.");else M=q.canSnap||q.snapType!==void 0;if(M&&(Y?!H:H)){if(!J.getShapePageTransform(U.id))throw Error("Expected a page transform");let R=W.handles.snapHandle({currentShapeId:Q,handle:O});if(R)R.nudge.rot(-J.getShapeParentTransform(U).rotation()),B.add(R.nudge),O={...q,x:B.x,y:B.y}}let L=V.onHandleDrag?.(U,{handle:O,isPrecise:this.isPrecise||$,isCreatingShape:!!this.info.isCreating,initial:F}),j={id:U.id,type:U.type,...L};if(q.type==="vertex"&&this.editor.isShapeOfType(U,"arrow")){let k=Z4(J,U)[q.id];if(k){if(N?.toId!==k.toId)this.pointingId=k.toId,this.isPrecise=_.len()<0.5||$,this.isPreciseId=this.isPrecise?k.toId:null,this.resetExactTimeout()}else if(N)this.pointingId=null,this.isPrecise=!1,this.isPreciseId=null,this.resetExactTimeout()}if(L)J.updateShapes([j])}}function TL(J){if(J.isLabel)return[J];if(J instanceof y4)return J.children.filter((Q)=>Q.isLabel);return[]}class JT 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)&&RJ(!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}),W2(this.editor),this.editor.select(Q)}onExit(){let J=!!this.editor.getEditingShapeId();if(this.editor.setEditingShape(null),Vq(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":{W2(this.editor);return}}}onPointerDown(J){switch(this.hitLabelOnShapeForPointerUp=null,this.didPointerDownOnEditingShape=!1,J.target){case"canvas":{let Q=TX(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=TL(q),K=X.length===1?X[0]:void 0,Y=this.editor.isShapeOfType(Z,"text")&&f9(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});W2(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 yX(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:(H)=>z||!H.isLocked});if(G){let H=J.getOutermostSelectableShape(G);if(W&&!K)if(J.cancelDoubleClick(),Z.includes(H.id))J.markHistoryStoppingPoint("deselecting shape"),J.deselect(H);else J.markHistoryStoppingPoint("shift selecting shape"),J.setSelectedShapes([...Z,H.id]);else{let $=void 0;if(H===G)$=G;else if(H.id===J.getFocusedGroupId()||Z.includes(H.id))$=G;else $=H;if($&&!Z.includes($.id))J.markHistoryStoppingPoint("selecting shape"),J.select($.id)}}else if(W)return;else{if(Z.length>0)J.markHistoryStoppingPoint("selecting none"),J.selectNone();let H=J.getFocusedGroupId();if(H4(H)){let $=J.getShape(H);if(!J.isPointInShape($,q,{margin:0,hitInside:!0}))J.setFocusedGroup(null)}}}var EN0=["Delete","Backspace","[","]","Enter"," ","Shift","Tab"];class QT extends a{static id="idle";selectedShapesOnKeyDown=[];onEnter(){if(this.parent.setCurrentToolIdMask(void 0),this.editor.setCursor({type:"default",rotation:0}),!AW(this.editor))W2(this.editor);this.selectedShapesOnKeyDown=[]}onExit(){this.editor.updateInstanceState({isChangingStyle:!1}),Vq(this.editor)}onPointerMove(){if(!AW(this.editor))W2(this.editor);if(x5(()=>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=TX(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(re(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")){yX(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{yX(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(re(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(!EN0.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"),hk(J))S4(q,J,{selectAll:Z});else q.setEditingShape(J);this.parent.transition("editing_shape",Q)}isOverArrowLabelTest(J){if(!J)return!1;return ZL(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:y1(""),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 D(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 D(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*PN0:X:Z?AN0:CN0,Y=this.editor.getSelectedShapeIds();this.editor.nudgeShapes(Y,q.mul(K)),z1(this.editor,Y)}}var AN0=10,CN0=1,PN0=5;function re(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)=>D.RotWith(X,Z.point,q)))}class ZT 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=D.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 D(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=PX(this.editor,Q),X=this.editor.getShapePageTransform(Q.id),K=this.editor.getPointInShapeSpace(Q,this.editor.inputs.getCurrentPagePoint()).add(this._labelDragOffset),Y=QL(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(D.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 qT 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){yX(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 XT 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)OQ({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=ae(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=ae(J,Q,Z,!0);if(K){let Y=J.getPointInParentSpace(K,J.inputs.getOriginPagePoint()).sub(D.Rot(new D(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 ae(J,Q,Z,q){let X=J.getShapeUtil(Q),K=k0(X,Q),Y=J.getShapePageTransform(Q.id),W=Y.point(),z=Y.rotation(),H=Zb(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(H)return aO(J,{shape:Q,center:H,pageRotation:z,noteWidth:K.noteWidth,noteHeight:K.noteHeight,forceNew:q});return}class KT extends a{static id="pointing_rotate_handle";info={};updateCursor(){this.editor.setCursor({type:qJ[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 YT extends a{static id="pointing_selection";info={};onEnter(J){this.info=J}onPointerUp(J){yX(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 WT 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,(H)=>Q.includes(H.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),H=TL(G),$=H.length===1?H[0]:void 0;if($){let _=this.editor.getPointInShapeSpace(W,X);if($.bounds.containsPoint(_,0)&&$.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((H)=>!G.find(($)=>$.id===H)),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(ZL(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 GT 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:H}}=this,$=J.inputs.getAltKey(),F=J.inputs.getShiftKey()||!z;if(q.size===1){let w=[...q.values()][0];if(J.isShapeOfType(w.shape,"text"))F=!(Q.handle==="left"||Q.handle==="right")}let U=J6(J.inputs),V=J.inputs.getCurrentPagePoint().clone().sub(K).sub(this.creationCursorOffset),N=J.inputs.getOriginPagePoint().clone().sub(K);if(J.getInstanceState().isGridMode&&!U){let{gridSize:w}=J.getDocumentSettings();V.snapToGrid(w)}let B=Q.handle,O=oe(B,Math.PI);if(J.snaps.clearIndicators(),(J.user.getIsSnapMode()?!U:U)&&W%F4===0){let{nudge:w}=J.snaps.shapeBounds.snapResizeShapes({dragDelta:D.Sub(V,N),initialSelectionPageBounds:G,handle:oe(B,W),isAspectRatioLocked:F,isResizingFromCenter:$});V.add(w)}let L=D.RotWith($?X.center:X.getHandlePoint(O),X.point,W),j=D.Sub(V,L).rot(-W),k=D.Sub(N,L).rot(-W),R=D.DivV(j,k);if(!Number.isFinite(R.x))R.x=1;if(!Number.isFinite(R.y))R.y=1;let I=B==="top"||B==="bottom",A=B==="left"||B==="right";if(F)if(A)R.y=Math.abs(R.x);else if(I)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(I)R.x=1;if(A)R.y=1}if(!this.info.isCreating)this.updateCursor({dragHandle:B,isFlippedX:R.x<0,isFlippedY:R.y<0,rotation:W});if(q.size>1)fe(this.editor,q,R,W,F);for(let w of H){let C=[];for(let x of w){let f=q.get(x),T=J.getResizeShapePartial(x,R,{initialShape:f.shape,initialBounds:f.bounds,initialPageTransform:f.pageTransform,dragHandle:B,mode:Y.length===1&&x===Y[0]?"resize_bounds":"scale_shape",scaleOrigin:L,isAspectRatioLocked:F,scaleAxisRotation:W,skipStartAndEndCallbacks:!0});if(T)C.push(T)}if(C.length>0)J.updateShapes(C)}if(U){this.didHoldCommand=!0;let w=[];for(let{id:C,children:x}of Z){if(!x.length)continue;let f=q.get(C).shape,T=this.editor.getShape(C);if(!(f&&T))continue;let h=T.x-f.x,b=T.y-f.y,v=new D(h,b).rot(-f.rotation);if(v.x!==0||v.y!==0)for(let g of x)w.push({id:g.id,type:g.type,x:g.x-v.x,y:g.y-v.y})}if(w.length>0)this.editor.updateShapes(w)}else if(this.didHoldCommand){this.didHoldCommand=!1;let w=[];for(let{children:C}of Z)for(let x of C)w.push({id:x.id,type:x.type,x:x.x,y:x.y});if(w.length>0)this.editor.updateShapes(w)}this.updateEnclosureHints()}updateEnclosureHints(){if(!this.info.isCreating)return;let J=this.editor.getOnlySelectedShape();if(!J||!this.editor.isShapeOfType(J,"frame"))return;let Q=aw(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(),Pb(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=D.RotWith(X.getHandlePoint(this.info.handle),X.point,Z),Y=D.Sub(q,K),W=new Map,z=[],G=(U)=>{let V=J.getShape(U);if(!V)return!1;let N=J.getShapeUtil(V);if(N.canResize(V)){let B=J.getShapePageTransform(V);W.set(V.id,{shape:V,bounds:J.getShapeGeometry(V).bounds,pageTransform:B,pageRotation:d.Decompose(B).rotation,isAspectRatioLocked:N.isAspectRatioLocked(V)})}if(J.isShapeFrameLike(V))z.push({id:V.id,children:D0(J.getSortedChildIdsForParent(V).map((B)=>J.getShape(B)))});if(!N.canResizeChildren(V))return!1;return};Q.forEach((U)=>{if(G(U)===!1)return;J.visitDescendants(U,G)});let H=![...W.values()].some((U)=>!eq(U.pageRotation,Z)||U.isAspectRatioLocked),$=[],_=new Map,F=(U)=>{let V=_.get(U);if(V!==void 0)return V;let N=0,B=J.getShape(U)?.parentId;while(B&&H4(B)){if(W.has(B)){N=F(B)+1;break}B=J.getShape(B)?.parentId}return _.set(U,N),N};for(let U of W.keys()){let V=F(U);while($.length<=V)$.push([]);$[V].push(U)}return{shapeSnapshots:W,selectionBounds:X,cursorHandleOffset:Y,selectionRotation:Z,selectedShapeIds:Q,canShapesDeform:H,initialSelectionPageBounds:this.editor.getSelectionPageBounds(),frames:z,resizeLevels:$}}}var zT=["top","top_right","right","bottom_right","bottom","bottom_left","left","top_left"];function oe(J,Q){Q=Q%N1;let Z=Math.round(Q/(B1/4)),q=zT.indexOf(J);return zT[(q+Z)%zT.length]}var te=Math.PI/180;class $T 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=kG({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});H3({editor:this.editor,delta:this._getRotationFromPointerPosition({snapToNearestDegree:!1}),snapshot:this.snapshot,stage:"start"}),this.editor.setCursor({type:qJ[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});H3({editor:this.editor,delta:J,snapshot:this.snapshot,stage:"update"}),this.editor.setCursor({type:qJ[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(){H3({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=XZ(W,24);else if(J){if(W=Math.round(W/te)*te,this.editor.getInstanceState().isCoarsePointer){let z=XZ(W,4),G=EK(W,z);if(Math.abs(G)<yM(5))W=z}}return W-X}}class HT 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=p.FromPoints([X,K]).expandBy(z),H=Q.getShapeIdsInsideBounds(G);if(H.size===0){let L=Q.getSelectedShapeIds(),j=new Set(Z?[...Y,...W]:[...Y]);if(L.length!==j.size||L.some((k)=>!j.has(k)))this.editor.setSelectedShapes(Array.from(j));return}let F=this.editor.getCurrentPageRenderingShapesSorted().filter((L)=>H.has(L.id)),U,V,N,B;for(let L=0,j=F.length;L<j;L++){if(U=F[L],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();N=R.applyToPoint(X),B=R.applyToPoint(K);let{bounds:I}=V;if(I.minX-z>Math.max(N.x,B.x)||I.minY-z>Math.max(N.y,B.y)||I.maxX+z<Math.min(N.x,B.x)||I.maxY+z<Math.min(N.y,B.y))continue;if(V.hitTestLineSegment(N,B,z)){let A=this.editor.getOutermostSelectableShape(U),w=this.editor.getShapeMask(A.id);if(w){if(X3(X,K,w)!==null){if(!n1(K,w))continue}}Y.add(A.id)}}let O=Q.getSelectedShapeIds(),M=new Set(Z?[...Y,...W]:[...Y]);if(O.length!==M.size||O.some((L)=>!M.has(L)))this.editor.setSelectedShapes(Array.from(M))}complete(){this.updateScribbleSelection(!0),this.parent.transition("idle")}cancel(){this.editor.setSelectedShapes([...this.initialSelectedShapeIds]),this.parent.transition("idle")}}var{defineProperty:IN0,getOwnPropertyDescriptor:wN0}=Object,bN0=(J,Q,Z,q)=>{var X=q>1?void 0:q?wN0(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)IN0(Q,Z,X);return X},TN0=320,yN0=60;class yL{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 D;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((H)=>q.getShape(H)));X.add(z);for(let H of G)X.delete(H)}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 H=q.findShapeAncestor(z,($)=>q.isShapeOfType($,"group"));if(H)this.initialGroupIds.set(z.id,H.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?TN0:yN0)}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=ee(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&&H4(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=xN0(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=ee(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}}bN0([S1],yL.prototype,"dispose",1);function ee(J,Q,Z){let q=J.getShapeUtil(Q);return Z.filter((X)=>q.canReceiveNewChildrenOfType(Q,X.type))}function xN0(J,Q,Z){let q=J.getShapeUtil(Q);return Z.filter((X)=>q.canRemoveChildrenOfType(Q,X.type))}var{defineProperty:vN0,getOwnPropertyDescriptor:SN0}=Object,fN0=(J,Q,Z,q)=>{var X=q>1?void 0:q?SN0(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)vN0(Q,Z,X);return X};class xL extends a{static id="translating";static trackPerformance=!0;info={};selectionSnapshot={};snapshot={};markId="";isCloning=!1;isCreating=!1;onCreate(J){return}dragAndDropManager=new yL(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=J00(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=J00(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=D.Average(J.map((X)=>this.editor.getShapePageTransform(X.id).point())),q=D.Sub(Z,this.selectionSnapshot.averagePagePoint);if(!D.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),gN0({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:d.Inverse(J.getShapePageTransform(X.parentId));q.parentTransform=K})}}fN0([S1],xL.prototype,"updateParentTransforms",1);function J00(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(),N=U.rotation();Z.push(V);let B=w4.isId(F.parentId)?null:d.Inverse(J.getShapePageTransform(F.parentId));return{shape:F,pagePoint:V,pageRotation:N,parentTransform:B}})),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,H=J.inputs.getOriginPagePoint(),$=X.filter((_)=>J.isShapeOfType(_.shape,"note")&&J.isPointInShape(_.shape,H));if($.length===0);else if($.length===1)z=$[0];else{let _=J.getCurrentPageShapesSorted();z=$.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=rO(J,{rotation:z.pageRotation,scale:z.shape.props.scale,extraHeight:z.shape.props.growY??0,noteWidth:F.noteWidth,noteHeight:F.noteHeight}),G=new D(F.noteWidth/2,F.noteHeight/2)}return{averagePagePoint:D.Average(Z),movingShapes:Q,shapeSnapshots:X,initialPageBounds:J.getSelectionPageBounds(),initialSnapPoints:Y,noteAdjacentPositions:W,noteSnapshot:z,noteCenterOffset:G}}function gN0({editor:J,snapshot:Q}){let{inputs:Z}=J,{noteSnapshot:q,noteAdjacentPositions:X,noteCenterOffset:K,initialPageBounds:Y,initialSnapPoints:W,shapeSnapshots:z,averagePagePoint:G}=Q,H=J.inputs.getShiftKey(),$=J.inputs.getAccelKey(),_=J.getInstanceState().isGridMode,F=J.getDocumentSettings().gridSize,U=D.Sub(Z.getCurrentPagePoint(),Z.getOriginPagePoint()),V=H?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 N=J.user.getIsSnapMode()?!$:$,B=!1;if(N&&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=sO/J.getZoomLevel(),I=new D(0,0);for(let A of X){let w=D.Sub(k,A),C=w.len();if(C<R)B=!0,R=C,I=w}U.sub(I)}let O=D.Add(G,U),M=J.snaps.getIndicators();if(_&&!$&&!B&&M.length===0)O.snapToGrid(F);let L=D.Sub(O,G);J.updateShapes(D0(z.map(({shape:j,pagePoint:k,parentTransform:R})=>{let I=D.Add(k,L),A=R?d.applyToPoint(R,I):I;return{id:j.id,type:j.type,x:A.x,y:A.y}})))}class vL extends a{static id="select";static initial="idle";static isLockable=!1;reactor=void 0;static children(){return[tb,Y_,QT,qT,WT,xL,nb,HT,W_,YT,sb,JT,GT,$T,KT,ZT,XT,eb]}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=g1("clean duplicate props",()=>{try{this.cleanUpDuplicateProps()}catch(J){console.error(J)}})}onExit(){if(this.reactor?.(),this.editor.getCurrentPageState().editingShapeId)this.editor.setEditingShape(null)}}class _T 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 FT 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 UT extends a{static id="zoom_brushing";info={};zoomBrush=new p;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(p.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 VT extends a{static id="zoom_quick";info={};qzState="idle";initialVpb=new p;initialPp=new D;overviewZoom=1;cleanupZoomReactor(){}nextVpb=new p;onEnter(J){let{editor:Q}=this;this.info=J,this.qzState="idle",this.initialVpb=Q.getViewportPageBounds(),this.initialPp=D.From(Q.inputs.getCurrentPagePoint()),Q.setCursor({type:"zoom-in",rotation:0});let Z=this.initialVpb,q=Q.getCurrentPageBounds(),X=q?p.Expand(Z,q):Z.clone(),K=Q.getViewportScreenBounds(),Y=Q.inputs.getCurrentScreenPoint(),W=Y.x,z=Y.y,{x:G,y:H}=this.initialPp,$=G-X.minX,_=X.maxX-G,F=H-X.minY,U=X.maxY-H,V=Q.getCamera().z;if($>0)V=Math.min(V,W/$);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=g1("zoom change in quick zoom",()=>{Q.getZoomLevel(),this.updateBrush()});let{x:N,y:B,z:O}=Q.getCamera(),M=O/V;if(Q.setCamera(new D((N+G)*M-G,(B+H)*M-H,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(D.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 D(Y.x/K.w,Y.y/K.h);return new p(q-W*Q,X-z*Z,Q,Z)}}class SL extends a{static id="zoom";static initial="idle";static children(){return[_T,FT,UT,VT]}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 NT=[PL,IL,wL,SL,vL];var xX=E(c(),1);var q00=E(c1(),1),X00=E(m(),1);var Q00=E(c(),1);var Z00=E(m(),1),BT=Z00.default.forwardRef(function({isEditing:Q,text:Z,handleFocus:q,handleChange:X,handleKeyDown:K,handlePaste:Y,handleBlur:W,handleInputPointerDown:z,handleDoubleClick:G},H){let $=y();return Q00.jsx("textarea",{ref:H,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:$.markEventAsHandled,onContextMenu:Q?(F)=>F.stopPropagation():void 0,onPointerDown:z,onPaste:Y,onDoubleClick:G,onDragStart:W0})});var hN0=X00.default.memo(function({shapeId:Q,type:Z,text:q,labelColor:X,fontFamily:K,fontSize:Y,lineHeight:W,textAlign:z,verticalAlign:G,wrap:H,isSelected:$,padding:_=0,onKeyDown:F,classNamePrefix:U,style:V,textWidth:N,textHeight:B,showTextOutline:O=!0}){let{rInput:M,isEmpty:L,isEditing:j,isReadyForEditing:k,...R}=_b(Q,Z,q),I=i3.normalizeTextForDom(q||""),A=I.length>0,w=nH(z);if(!j&&!A)return null;let C=U||"tl-text";return xX.jsx("div",{className:`${C}-label tl-text-wrapper tl-plain-text-wrapper`,"aria-hidden":!j,"data-hastext":!L,"data-isediting":j,"data-is-ready-for-editing":k,"data-textwrap":!!H,"data-isselected":$,style:{fontFamily:K,textAlign:z,justifyContent:z==="center"||w?"center":z==="end"?"flex-end":"flex-start",alignItems:G==="middle"?"center":G==="end"?"flex-end":"flex-start",padding:_,...V},children:xX.jsxs("div",{className:`${C}-label__inner tl-text-content__wrapper`,style:{fontSize:Y,lineHeight:`${p8(Y,W)}px`,minHeight:`${p8(Y,W)}px`,minWidth:Math.ceil(N||0),color:X,width:N?Math.ceil(N):void 0,height:B?Math.ceil(B):void 0},children:[xX.jsx("div",{className:q00.default(`${C} tl-text tl-text-content`,O?"tl-text__outline":"tl-text__no-outline"),dir:"auto",children:I.split(`
546
- `).map((x,f)=>xX.jsx("div",{dir:"auto",children:x},f))}),(k||$)&&xX.jsx(BT,{ref:M,text:q,isEditing:j,shapeId:Q,...R,handleKeyDown:F??R.handleKeyDown})]})})});var $9=E(c(),1);var $2=E(m(),1);var Y00=E(m(),1);var K00=E(m(),1),z_={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 fL(J){return K00.useMemo(()=>{if(!J)return z_;return{fonts:{...z_.fonts,...J?.fonts}}},[J])}var OT=["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 G_={...z_,icons:Object.fromEntries(OT.map((J)=>[J,`${Q6()}/icons/icon/0_merged.svg#${J}`])),translations:Object.fromEntries(L2.map((J)=>[J.locale,`${Q6()}/translations/${J.locale}.json`])),embedIcons:Object.fromEntries(mY.map((J)=>[J.type,`${Q6()}/embed-icons/${J.type}.png`]))};function gL(J){return Y00.useMemo(()=>{if(!J)return G_;return{fonts:Object.assign({...G_.fonts},{...J?.fonts}),icons:Object.assign({...G_.icons},{...J?.icons}),embedIcons:Object.assign({...G_.embedIcons},{...J?.embedIcons}),translations:Object.assign({...G_.translations},{...J?.translations})}},[J])}var LT=E(c(),1);function W00(){let{Spinner:J}=T4();return LT.jsx(FR,{children:J?LT.jsx(J,{}):null})}var U1=E(c(),1);var $00=E(c1(),1),c9=E(m(),1);var G9=E(c(),1);var DT=p1(function({overrides:Q,components:Z,assetUrls:q,onUiEvent:X,forceMobile:K,mediaMimeTypes:Y,children:W}){let z=J1();return G9.jsx(rP.Provider,{value:Y,children:G9.jsx(B$,{assetUrls:gL(q),children:G9.jsx(L$,{overrides:TB(Q),locale:z?.user.getLocale()??v6.locale,children:G9.jsx(VP,{children:G9.jsx(jP,{onEvent:X,children:G9.jsx(gP,{children:G9.jsx(SP,{context:"tla",children:G9.jsx(mk,{children:G9.jsx(LP,{forceMobile:K,children:G9.jsx(Iw,{overrides:Z,children:G9.jsx(uN0,{overrides:Q,children:W})})})})})})})})})})})});function uN0({overrides:J,children:Q}){let Z=lr(J);return G9.jsx(Lt,{overrides:Z.actions,children:G9.jsx(ir,{overrides:Z.tools,children:Q})})}var z00=E(m(),1);function G00(){let J=y(),{addToast:Q}=C5();z00.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 MT=c9.default.memo(function({renderDebugMenuItems:Q,children:Z,hideUi:q,components:X,...K}){return U1.jsx(DT,{...K,components:X,children:U1.jsx(mN0,{hideUi:q,renderDebugMenuItems:Q,children:Z})})}),mN0=c9.default.memo(function({children:Q,hideUi:Z,...q}){return Dw(),dP(),U1.jsxs(U1.Fragment,{children:[Q,Z?null:U1.jsx(cN0,{...q})]})}),cN0=c9.default.memo(function(){let Q=y(),Z=t(),q=A1(),X=I6(),K=S("focus",()=>Q.getInstanceState().isFocusMode,[Q]),Y=S("debug",()=>Q.getInstanceState().isDebugMode,[Q]),W=Q1(),z=t0(),G=S("locale",()=>Q.user.getLocale(),[Q]);c9.useEffect(()=>{W.dir=z,W.lang=G},[W,z,G]);let{SharePanel:H,TopPanel:$,MenuPanel:_,StylePanel:F,Toolbar:U,HelpMenu:V,NavigationPanel:N,HelperButtons:B,DebugPanel:O,Toasts:M,Dialogs:L,A11y:j,FollowingIndicator:k}=N4();G00();let R=c9.useRef(!1),I=c9.useRef(-1),[A,w]=c9.useState(!1);FJ("update hide toolbar while delayed",()=>{if(!(S0.isIos||S0.isAndroid))return;if(Q.getEditingShapeId()===null){if(R.current)if(R.current=!1,clearTimeout(I.current),S0.isAndroid)I.current=Q.timers.setTimeout(()=>{w(!1)},150);else w(!1);return}if(!R.current)R.current=!0,clearTimeout(I.current),w(!0)},[]);let{"toggle-focus-mode":C}=f6(),{breakpointsAbove:x,breakpointsBelow:f}=c9.useMemo(()=>{let T=[],h=[];for(let b=0;b<lY.length;b++)if(b<=q)T.push(b);else h.push(b);return{breakpointsAbove:T,breakpointsBelow:h}},[q]);return U1.jsxs("div",{className:$00.default("tlui-layout",{"tlui-layout__mobile":q<e0.TABLET_SM}),role:"document","data-iseditinganything":A,"data-breakpoint":q,"data-breakpoints-above":x.join(" "),"data-breakpoints-below":f.join(" "),children:[U1.jsx(jt,{}),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(_,{}),B&&U1.jsx(B,{})]}),U1.jsx("div",{className:"tlui-layout__top__center",children:$&&U1.jsx($,{})}),U1.jsxs("div",{className:"tlui-layout__top__right",children:[H&&U1.jsx(H,{}),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:[N&&U1.jsx(N,{}),U&&U1.jsx(U,{}),V&&U1.jsx(V,{})]}),Y&&O&&U1.jsx(O,{}),j&&U1.jsx(j,{})]})]}),k&&U1.jsx(k,{}),M&&U1.jsx(M,{}),L&&U1.jsx(L,{})]})});function hL(){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 lN0=[...NT,...Wb];function pN0(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 jT(J){let{children:Q,maxImageDimension:Z,maxAssetSize:q,acceptedImageMimeTypes:X,acceptedVideoMimeTypes:K,onMount:Y,components:W={},shapeUtils:z=[],bindingUtils:G=[],assetUtils:H=[],overlayUtils:$=[],tools:_=[],embeds:F,options:U,locale:V,textOptions:N,...B}=J,O=P9(W),M=W?.InFrontOfTheCanvas,L=$2.useMemo(()=>{if(B.hideUi)return M??null;if(!M)return hL;return()=>$9.jsxs($9.Fragment,{children:[$9.jsx(hL,{}),$9.jsx(M,{})]})},[B.hideUi,M]),j=$2.useMemo(()=>({Spinner:qH,LoadingScreen:W00,...O,InFrontOfTheCanvas:L}),[O,L]),k=m8(z),R=$2.useMemo(()=>F2("type",k,bX),[k]),I=m8(G),A=$2.useMemo(()=>F2("type",I,AX),[I]),w=m8(H),C=$2.useMemo(()=>pN0(F2("type",w,iw),{maxImageDimension:Z,acceptedImageMimeTypes:X,acceptedVideoMimeTypes:K}),[w,Z,X,K]),x=m8($),f=$2.useMemo(()=>F2("type",x,nw),[x]),T=m8(_),h=$2.useMemo(()=>F2("id",T,lN0),[T]),b=m8(X??vq),v=m8(K??nX),g=U?.text??N,u=$2.useMemo(()=>{return{addFontsFromNode:f$,...g,tipTapConfig:{extensions:wZ,...g?.tipTapConfig}}},[g]),n=$2.useMemo(()=>({...U,text:u}),[U,u]),o=$2.useMemo(()=>[...b,...v],[b,v]),K0=fL(B.assetUrls);if(R.find((y0)=>y0.type==="embed")&&F)Dq.setEmbedDefinitions(F);return $9.jsx(B$,{assetUrls:gL(B.assetUrls),children:$9.jsx(L$,{overrides:TB(B.overrides),locale:V??B.user?.userPreferences.get().locale??v6.locale,children:$9.jsx(_R,{initialState:"select",...B,components:j,shapeUtils:R,bindingUtils:A,assetUtils:C,overlayUtils:f,tools:h,options:n,assetUrls:K0,children:$9.jsxs(MT,{...B,components:j,mediaMimeTypes:o,children:[$9.jsx(dN0,{maxImageDimension:Z,maxAssetSize:q,acceptedImageMimeTypes:b,acceptedVideoMimeTypes:v,onMount:Y}),Q]})})})})}function dN0({maxImageDimension:J,maxAssetSize:Q,acceptedImageMimeTypes:Z,acceptedVideoMimeTypes:q,onMount:X}){let K=y(),Y=C5(),W=t(),z=o0();VU(()=>{let $=[];$.push(fb(K)),K.fonts.requestFonts(cE);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"})),iE(K,{maxImageDimension:J,maxAssetSize:Q,acceptedImageMimeTypes:Z,acceptedVideoMimeTypes:q,toasts:Y,msg:W}),$.push(K.store.props.onMount(K)),$.push(X?.(K)),()=>{$.forEach((F)=>F?.())}});let{Canvas:G}=T4(),{ContextMenu:H}=N4();if(H)return $9.jsx(H,{});if(G)return $9.jsx(G,{});return null}var RT=E(c(),1);var l9=E(m(),1);var H00={text:{tipTapConfig:{extensions:wZ},addFontsFromNode:f$}},iN0=l9.memo(function(Q){let[Z,q]=l9.useState(null),[X,K]=l9.useState(null),Y=m8(Q.shapeUtils??[]),W=l9.useMemo(()=>F2("type",Y,bX),[Y]),z=m8(Q.bindingUtils??[]),G=l9.useMemo(()=>F2("type",z,AX),[z]),H=$R({snapshot:Q.snapshot,shapeUtils:W}),{pageId:$,bounds:_,scale:F,pixelRatio:U,background:V,padding:N,darkMode:B,preserveAspectRatio:O,format:M="svg",licenseKey:L,assetUrls:j,options:k,textOptions:R}=Q,I=l9.useMemo(()=>({...H00,...k,text:{...H00.text,...k?.text??R}}),[k,R]),A=fL(j);return l9.useLayoutEffect(()=>{if(!X)return;if(!H)return;let w=!1,C=X.ownerDocument.createElement("div");X.appendChild(C),X.classList.add("tl-container","tl-theme__light");let x=new G0({store:H,shapeUtils:W,bindingUtils:G,tools:[],getContainer:()=>C,licenseKey:L,fontAssetUrls:A.fonts,options:I});if($)x.setCurrentPage($);let f=x.getCurrentPageShapeIds();async function T(){let h=await x.toImage([...f],{bounds:_,scale:F,background:V,padding:N,darkMode:B,preserveAspectRatio:O,format:M});if(!h||w)return;let b=URL.createObjectURL(h.blob);q(b),x.dispose()}return T(),()=>{w=!0}},[M,X,H,W,G,$,_,F,V,N,B,O,L,U,A,I]),l9.useEffect(()=>{return()=>{if(Z)URL.revokeObjectURL(Z)}},[Z]),RT.jsx("div",{ref:K,style:{position:"relative",width:"100%",height:"100%"},children:Z&&RT.jsx("img",{src:Z,referrerPolicy:"strict-origin-when-cross-origin",style:{width:"100%",height:"100%"}})})});var XJ=E(c(),1);var uL=E(m(),1);var nN0=uL.memo(function({children:Q}){let Z=t(),q=A1(),X=uL.useRef(null);r6(X);let K=Q??XJ.jsx(vI,{});if(q<e0.MOBILE)return null;return XJ.jsx("div",{ref:X,className:"tlui-help-menu",children:XJ.jsxs(XQ,{id:"help menu",children:[XJ.jsx(KQ,{children:XJ.jsx(w0,{type:"help",title:Z("help-menu.title"),"data-testid":"help-menu.button",children:XJ.jsx(z0,{icon:"question-mark",small:!0})})}),XJ.jsx(YQ,{side:"top",align:"end",alignOffset:0,sideOffset:8,children:XJ.jsx(z4,{type:"menu",sourceId:"help-menu",children:K})})]})})});var $_=E(c(),1);var _00=E(c1(),1);var F00=E(m(),1);var sN0=F00.forwardRef(function({children:Q,className:Z},q){return $_.jsxs(o$.Trigger,{ref:q,className:_00.default("tlui-button tlui-select__trigger",Z),children:[Q,$_.jsx(o$.Icon,{className:"tlui-select__chevron",children:$_.jsx(S6,{icon:"chevron-down",label:"",small:!0})})]})});var rN0=E(c(),1),kT=E(m(),1);var p9={White:"white",LightGray:"lightGray",Gray:"gray",Black:"black",Green:"green",Cyan:"cyan",Blue:"blue",Indigo:"indigo",Violet:"violet",Red:"red",Orange:"orange",Yellow:"yellow"},vX={Small:"small",Medium:"medium",Large:"large"},H_={Draw:"draw",Solid:"solid",Dashed:"dashed",Dotted:"dotted"},TQ={Start:"start",Middle:"middle",End:"end",Justify:"justify"},__={Script:"script",Sans:"sans",Serif:"serif",Mono:"mono"};var eB1={[p9.White]:"black",[p9.Black]:"black",[p9.LightGray]:"grey",[p9.Gray]:"grey",[p9.Green]:"light-green",[p9.Cyan]:"green",[p9.Blue]:"light-blue",[p9.Indigo]:"blue",[p9.Orange]:"orange",[p9.Yellow]:"yellow",[p9.Red]:"red",[p9.Violet]:"light-violet"},JO1={[__.Mono]:"mono",[__.Sans]:"sans",[__.Script]:"draw",[__.Serif]:"serif"},QO1={[TQ.Start]:"start",[TQ.Middle]:"middle",[TQ.End]:"end",[TQ.Justify]:"start"},ZO1={[TQ.Start]:"start",[TQ.Middle]:"middle",[TQ.End]:"end",[TQ.Justify]:"start"},qO1={[vX.Small]:"s",[vX.Medium]:"l",[vX.Large]:"xl"},XO1={[vX.Small]:"m",[vX.Medium]:"l",[vX.Large]:"xl"},KO1={[H_.Solid]:"solid",[H_.Dashed]:"dashed",[H_.Dotted]:"dotted",[H_.Draw]:"draw"};var oN0=P.object({schemaVersion:P.literal(1),storeVersion:P.positiveInteger,recordVersions:P.dict(P.string,P.object({version:P.positiveInteger,subTypeVersions:P.dict(P.string,P.positiveInteger).optional(),subTypeKey:P.string.optional()}))}),tN0=P.object({schemaVersion:P.literal(2),sequences:P.dict(P.string,P.positiveInteger)}),GO1=P.object({tldrawFileFormatVersion:P.nonZeroInteger,schema:P.numberUnion("schemaVersion",{1:oN0,2:tN0}),records:P.arrayOf(P.object({id:P.string,typeName:P.string}).allowUnknownProperties())});y5("tldraw","5.2.3","esm");var SX=E(m(),1);function eN0(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 U00(J,Q){let Z=eN0(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 V00(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 H9=E(c(),1),N00=null;function JB0(){return N00??=j2({shapeUtils:bX,bindingUtils:AX}).schema,N00}function ET(J,Q){let Z=JB0();try{if(Z.migrateStoreSnapshot(J).type==="success")return null}catch{}let q=U00(J.schema,Z.serialize().sequences);if(q.length>0)return{newer:!0,writer:Q,detail:V00(Q,q)};return{newer:!1,writer:Q,detail:"The saved snapshot failed to load."}}function O00(J){let[Q,Z]=SX.useState(!1),[q,X]=SX.useState(null),K=SX.useRef(void 0);return SX.useEffect(()=>{let Y=!1;return Z(!1),X(null),K.current=void 0,fetch(`/api/workspaces/${J}/scratchpad`).then((W)=>W.json()).then((W)=>{if(Y)return;if(W?.document){let z=ET(W.document,W.writer);if(z)X(z);else K.current=W.document}Z(!0)}).catch(()=>{if(!Y)Z(!0)}),()=>{Y=!0}},[J]),{loaded:Q,snapshot:K.current,skew:q,flagSkew:X}}function L00({skew:J}){return H9.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:H9.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:[H9.jsxs("div",{className:"flex items-center gap-2",children:[H9.jsx(B00,{size:20,stroke:1.5,className:"shrink-0 text-amber-600"}),H9.jsx("h2",{className:"font-medium text-foreground",children:J.newer?"This canvas needs a newer moi":"This canvas couldn’t be loaded"})]}),J.newer?H9.jsxs(H9.Fragment,{children:[H9.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})`:"",".",H9.jsx("br",{})," Please update moi and restart the server:"]}),H9.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"})]}):H9.jsx("p",{className:"text-sm text-muted-foreground",children:J.detail})]})})}var jq=E(m(),1);var u4=E(c(),1),QB0=[{kind:"tool",id:"select",label:"Select",Icon:C00},{kind:"tool",id:"hand",label:"Hand",Icon:k00},{kind:"sep"},{kind:"tool",id:"draw",label:"Pencil",Icon:PT},{kind:"geo",label:"Rectangle",Icon:P00},{kind:"tool",id:"note",label:"Sticker",Icon:I00},{kind:"tool",id:"text",label:"Text",Icon:IT},{kind:"tool",id:"line",label:"Line",Icon:A00},{kind:"tool",id:"arrow",label:"Arrow",Icon:j00},{kind:"sep"},{kind:"tool",id:"highlight",label:"Highlighter",Icon:E00},{kind:"tool",id:"eraser",label:"Eraser",Icon:R00}];function AT({label:J,active:Q,Icon:Z,onClick:q}){return u4.jsx(w00,{type:"button",size:"icon",variant:Q?"default":"ghost","aria-label":J,title:J,onClick:q,className:yQ(!Q&&"text-muted-foreground hover:text-foreground"),children:u4.jsx(Z,{stroke:1.5})})}function D00(J,Q){if(Q==="geo")J.setStyleForNextShapes(T6,"draw"),J.setStyleForNextShapes(e4,"m");else if(Q==="note")J.setStyleForNextShapes(I4,"draw"),J.setStyleForNextShapes(R9,"middle"),J.setStyleForNextShapes(k9,"middle"),M00(J,"sticker","yellow");else if(Q==="text")J.setStyleForNextShapes(I4,"draw"),J.setStyleForNextShapes(R9,"middle"),J.setStyleForNextShapes(k9,"middle");else if(Q==="highlight")M00(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")}}function T00({editor:J}){let[Q,Z]=jq.useState(()=>J.getCurrentToolId());jq.useEffect(()=>{return Z(J.getCurrentToolId()),g1("scratch current tool",()=>Z(J.getCurrentToolId()))},[J]);let q=(K)=>{J.run(()=>{D00(J,K),J.setCurrentTool(K)})},X=()=>{J.run(()=>{J.setStyleForNextShapes(x6,"rectangle"),D00(J,"geo"),J.setCurrentTool("geo")})};return u4.jsx("div",{className:"absolute top-1/2 left-2 z-10 -translate-y-1/2",children:u4.jsx(b00.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:QB0.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(AT,{label:K.label,Icon:K.Icon,active:Q==="geo",onClick:X},"geo");if(K.kind==="menu")return u4.jsx(AT,{label:K.label,Icon:K.Icon,active:!1,onClick:()=>{}},"menu");return u4.jsx(AT,{label:K.label,Icon:K.Icon,active:Q===K.id,onClick:()=>q(K.id)},K.id)})})})}var ZB0=["color","size","dash","fill"],y00={draw:["color","size","dash"],geo:["color","fill"],note:["color","size"],text:["color","size"],line:["color","dash","size"],highlight:["color","size"],arrow:["color","size"]},qB0={draw:["color","size","dash"],geo:["color","fill"],note:["color","size"],text:["color","size"],line:["color","dash","size"],highlight:["color","size"],arrow:["color","size"]},x00={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 XB0(J){let Q=J.getCurrentToolId();if(Q==="highlight")return"highlight";if(Q==="note")return"sticker";if(y00[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 M00(J,Q,Z){if(!x00[Q].swatches.map((X)=>X.value).includes(J.getStyleForNextShape(_1)))J.setStyleForNextShapes(_1,Z)}var KB0=[{value:"m",label:"Small",dot:"size-1.5",glyph:16},{value:"xl",label:"Large",dot:"size-3",glyph:24}],YB0=[{value:"draw",label:"Rough",preview:"border-b-2 border-current"},{value:"dashed",label:"Dash",preview:"border-b-2 border-dashed border-current"}],WB0=[{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 mL(J,Q){if(J.getSelectedShapeIds().length>0)return J.getSharedStyles().getAsKnownValue(Q);return J.getStyleForNextShape(Q)}function cL(J,Q,Z){J.run(()=>{if(J.setStyleForNextShapes(Q,Z),J.getSelectedShapeIds().length>0)J.setStyleForSelectedShapes(Q,Z)})}function zB0(J){let Q=y00[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 qB0[K.type]??[])q.add(Y)}return ZB0.filter((X)=>q.has(X))}function GB0(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 CT(J){return{controls:zB0(J),palette:x00[XB0(J)],color:mL(J,_1),size:mL(J,e4),sizeGlyph:GB0(J),dash:mL(J,T6),fill:mL(J,y6)}}function v00({editor:J}){let[Q,Z]=jq.useState(()=>CT(J));if(jq.useEffect(()=>{return Z(CT(J)),g1("scratch styles",()=>Z(CT(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:()=>cL(J,_1,X.value),className:yQ("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:KB0.map((X)=>u4.jsx("button",{type:"button",title:X.label,onClick:()=>cL(J,e4,X.value),className:yQ("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(PT,{size:20,stroke:1.5}):Q.sizeGlyph==="letter"?u4.jsx(IT,{size:X.glyph,stroke:X.glyph===16?1.75:1.5}):u4.jsx("span",{className:yQ("rounded-full bg-current",X.dot)})},X.value))}),dash:u4.jsx("div",{className:"flex flex-col items-center gap-1 text-foreground",children:YB0.map((X)=>u4.jsx("button",{type:"button",title:X.label,onClick:()=>cL(J,T6,X.value),className:yQ("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:yQ("w-3.5",X.preview)})},X.value))}),fill:u4.jsx("div",{className:"flex flex-col items-center gap-1 text-foreground",children:WB0.map((X)=>u4.jsx("button",{type:"button",title:X.label,onClick:()=>cL(J,y6,X.value),className:yQ("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:yQ("size-4.5 rounded-lg",X.preview)})},X.value))})};return u4.jsx("div",{className:"absolute top-1/2 left-14 z-10 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(jq.Fragment,{children:[K>0&&u4.jsx("div",{className:"h-px w-5 bg-border"}),q[X]]},X))})}var S8=E(c(),1),S00=Math.random().toString(36).slice(2),$B0=500,HB0="tldraw-2026-09-27/WyJlaDdIczMxRSIsWyIqIl0sMTYsIjIwMjYtMDktMjciXQ.6OucDghQHnAFl2Ceg8qf48M2oIis6qHdZfqFsKdBZwd610QixrvG1jUnwCbI1Xs2BoXzptPs+pQYF25NyShFbw";function _B0(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 FB0(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 UB0(){return S8.jsx("div",{className:"absolute inset-0 bg-[color-mix(in_oklch,var(--muted),var(--background)_50%)]"})}function VB0({x:J,y:Q,z:Z,size:q}){let X=D5("scratch-grid"),K=y(),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,H=z>0?z%W:W+z%W,$=G>0?G%W:W+G%W;return S8.jsxs("svg",{className:"tl-grid",version:"1.1",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[S8.jsx("defs",{children:S8.jsx("pattern",{id:X,width:W,height:W,patternUnits:"userSpaceOnUse",children:S8.jsx("circle",{className:"fill-accent",cx:H,cy:$,r:1})})}),S8.jsx("rect",{width:"100%",height:"100%",fill:`url(#${X})`})]})}var NB0={Background:UB0,Grid:VB0,Toolbar:null,StylePanel:null,Minimap:null,MainMenu:null,PageMenu:null,ActionsMenu:null,QuickActions:null,HelpMenu:null,DebugMenu:null,ZoomMenu:null},BB0={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}},OB0={maxPages:1},LB0=33554432,DB0=2048;function sj1(){let J=g00(),Q=H2.useRef(null),Z=H2.useRef(null),q=H2.useRef(null),X=H2.useRef(!1),[K,Y]=H2.useState(null),{loaded:W,snapshot:z,skew:G,flagSkew:H}=O00(J),$=H2.useRef(null);if($.current?.id!==J)$.current={id:J,store:FB0(J)};let _=$.current.store,F=H2.useCallback(()=>{let V=Q.current;if(!V)return;let N;try{N=OG(V.store).document}catch{return}fetch(`/api/workspaces/${J}/scratchpad`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({document:N,origin:S00})}).catch(()=>{})},[J]);f00((V)=>{if(V.type!=="scratchpad:updated"||V.workspaceId!==J)return;if(V.origin&&V.origin===S00)return;if(!Q.current)return;fetch(`/api/workspaces/${J}/scratchpad`).then((N)=>N.json()).then((N)=>{let B=Q.current;if(!B||!N?.document)return;let O=ET(N.document,N.writer);if(O){if(q.current)clearTimeout(q.current);H(O);return}X.current=!0,z3(B.store,{document:N.document})}).catch(()=>{})});let U=H2.useCallback((V)=>{Q.current=V,Y(V),V.updateInstanceState({isGridMode:!0}),V.run(()=>{V.setStyleForNextShapes(I4,"draw"),V.setStyleForNextShapes(R9,"middle"),V.setStyleForNextShapes(k9,"middle"),V.setStyleForNextShapes(y6,"fill")});let N=V.store.listen(()=>{if(X.current){X.current=!1;return}if(q.current)clearTimeout(q.current);q.current=setTimeout(F,$B0)},{source:"user",scope:"document"});wT(J,_B0(V));let B=(M)=>{let L=M.target;if(!!L&&!!Z.current?.contains(L)){if(!V.getIsFocused())V.focus()}else if(V.getIsFocused())V.blur()},O=V.getContainer().ownerDocument;return O.addEventListener("pointerdown",B,!0),V.focus(),()=>{if(N(),O.removeEventListener("pointerdown",B,!0),q.current)clearTimeout(q.current);wT(J,null),Y(null),Q.current=null}},[J,F]);if(!W)return S8.jsx("div",{className:"min-h-0 flex-1 bg-muted/40"});if(G)return S8.jsx(L00,{skew:G});return S8.jsxs("div",{ref:Z,className:"relative min-h-0 flex-1 overflow-hidden",children:[S8.jsx("div",{className:"absolute inset-0",children:S8.jsx(jT,{snapshot:z,assets:_,licenseKey:HB0,onMount:U,components:NB0,overrides:BB0,options:OB0,maxAssetSize:LB0,maxImageDimension:DB0,autoFocus:!1})}),K&&S8.jsx(T00,{editor:K}),K&&S8.jsx(v00,{editor:K})]})}export{sj1 as Scratchpad};
546
+ `).map((x,f)=>xX.jsx("div",{dir:"auto",children:x},f))}),(k||$)&&xX.jsx(BT,{ref:M,text:q,isEditing:j,shapeId:Q,...R,handleKeyDown:F??R.handleKeyDown})]})})});var $9=E(c(),1);var $2=E(m(),1);var Y00=E(m(),1);var K00=E(m(),1),z_={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 fL(J){return K00.useMemo(()=>{if(!J)return z_;return{fonts:{...z_.fonts,...J?.fonts}}},[J])}var OT=["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 G_={...z_,icons:Object.fromEntries(OT.map((J)=>[J,`${Q6()}/icons/icon/0_merged.svg#${J}`])),translations:Object.fromEntries(L2.map((J)=>[J.locale,`${Q6()}/translations/${J.locale}.json`])),embedIcons:Object.fromEntries(mY.map((J)=>[J.type,`${Q6()}/embed-icons/${J.type}.png`]))};function gL(J){return Y00.useMemo(()=>{if(!J)return G_;return{fonts:Object.assign({...G_.fonts},{...J?.fonts}),icons:Object.assign({...G_.icons},{...J?.icons}),embedIcons:Object.assign({...G_.embedIcons},{...J?.embedIcons}),translations:Object.assign({...G_.translations},{...J?.translations})}},[J])}var LT=E(c(),1);function W00(){let{Spinner:J}=T4();return LT.jsx(FR,{children:J?LT.jsx(J,{}):null})}var U1=E(c(),1);var $00=E(c1(),1),c9=E(m(),1);var G9=E(c(),1);var DT=p1(function({overrides:Q,components:Z,assetUrls:q,onUiEvent:X,forceMobile:K,mediaMimeTypes:Y,children:W}){let z=J1();return G9.jsx(rP.Provider,{value:Y,children:G9.jsx(B$,{assetUrls:gL(q),children:G9.jsx(L$,{overrides:TB(Q),locale:z?.user.getLocale()??v6.locale,children:G9.jsx(VP,{children:G9.jsx(jP,{onEvent:X,children:G9.jsx(gP,{children:G9.jsx(SP,{context:"tla",children:G9.jsx(mk,{children:G9.jsx(LP,{forceMobile:K,children:G9.jsx(Iw,{overrides:Z,children:G9.jsx(uN0,{overrides:Q,children:W})})})})})})})})})})})});function uN0({overrides:J,children:Q}){let Z=lr(J);return G9.jsx(Lt,{overrides:Z.actions,children:G9.jsx(ir,{overrides:Z.tools,children:Q})})}var z00=E(m(),1);function G00(){let J=y(),{addToast:Q}=C5();z00.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 MT=c9.default.memo(function({renderDebugMenuItems:Q,children:Z,hideUi:q,components:X,...K}){return U1.jsx(DT,{...K,components:X,children:U1.jsx(mN0,{hideUi:q,renderDebugMenuItems:Q,children:Z})})}),mN0=c9.default.memo(function({children:Q,hideUi:Z,...q}){return Dw(),dP(),U1.jsxs(U1.Fragment,{children:[Q,Z?null:U1.jsx(cN0,{...q})]})}),cN0=c9.default.memo(function(){let Q=y(),Z=t(),q=A1(),X=I6(),K=S("focus",()=>Q.getInstanceState().isFocusMode,[Q]),Y=S("debug",()=>Q.getInstanceState().isDebugMode,[Q]),W=Q1(),z=t0(),G=S("locale",()=>Q.user.getLocale(),[Q]);c9.useEffect(()=>{W.dir=z,W.lang=G},[W,z,G]);let{SharePanel:H,TopPanel:$,MenuPanel:_,StylePanel:F,Toolbar:U,HelpMenu:V,NavigationPanel:N,HelperButtons:B,DebugPanel:O,Toasts:M,Dialogs:L,A11y:j,FollowingIndicator:k}=N4();G00();let R=c9.useRef(!1),I=c9.useRef(-1),[A,w]=c9.useState(!1);FJ("update hide toolbar while delayed",()=>{if(!(S0.isIos||S0.isAndroid))return;if(Q.getEditingShapeId()===null){if(R.current)if(R.current=!1,clearTimeout(I.current),S0.isAndroid)I.current=Q.timers.setTimeout(()=>{w(!1)},150);else w(!1);return}if(!R.current)R.current=!0,clearTimeout(I.current),w(!0)},[]);let{"toggle-focus-mode":C}=f6(),{breakpointsAbove:x,breakpointsBelow:f}=c9.useMemo(()=>{let T=[],h=[];for(let b=0;b<lY.length;b++)if(b<=q)T.push(b);else h.push(b);return{breakpointsAbove:T,breakpointsBelow:h}},[q]);return U1.jsxs("div",{className:$00.default("tlui-layout",{"tlui-layout__mobile":q<e0.TABLET_SM}),role:"document","data-iseditinganything":A,"data-breakpoint":q,"data-breakpoints-above":x.join(" "),"data-breakpoints-below":f.join(" "),children:[U1.jsx(jt,{}),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(_,{}),B&&U1.jsx(B,{})]}),U1.jsx("div",{className:"tlui-layout__top__center",children:$&&U1.jsx($,{})}),U1.jsxs("div",{className:"tlui-layout__top__right",children:[H&&U1.jsx(H,{}),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:[N&&U1.jsx(N,{}),U&&U1.jsx(U,{}),V&&U1.jsx(V,{})]}),Y&&O&&U1.jsx(O,{}),j&&U1.jsx(j,{})]})]}),k&&U1.jsx(k,{}),M&&U1.jsx(M,{}),L&&U1.jsx(L,{})]})});function hL(){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 lN0=[...NT,...Wb];function pN0(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 jT(J){let{children:Q,maxImageDimension:Z,maxAssetSize:q,acceptedImageMimeTypes:X,acceptedVideoMimeTypes:K,onMount:Y,components:W={},shapeUtils:z=[],bindingUtils:G=[],assetUtils:H=[],overlayUtils:$=[],tools:_=[],embeds:F,options:U,locale:V,textOptions:N,...B}=J,O=P9(W),M=W?.InFrontOfTheCanvas,L=$2.useMemo(()=>{if(B.hideUi)return M??null;if(!M)return hL;return()=>$9.jsxs($9.Fragment,{children:[$9.jsx(hL,{}),$9.jsx(M,{})]})},[B.hideUi,M]),j=$2.useMemo(()=>({Spinner:qH,LoadingScreen:W00,...O,InFrontOfTheCanvas:L}),[O,L]),k=m8(z),R=$2.useMemo(()=>F2("type",k,bX),[k]),I=m8(G),A=$2.useMemo(()=>F2("type",I,AX),[I]),w=m8(H),C=$2.useMemo(()=>pN0(F2("type",w,iw),{maxImageDimension:Z,acceptedImageMimeTypes:X,acceptedVideoMimeTypes:K}),[w,Z,X,K]),x=m8($),f=$2.useMemo(()=>F2("type",x,nw),[x]),T=m8(_),h=$2.useMemo(()=>F2("id",T,lN0),[T]),b=m8(X??vq),v=m8(K??nX),g=U?.text??N,u=$2.useMemo(()=>{return{addFontsFromNode:f$,...g,tipTapConfig:{extensions:wZ,...g?.tipTapConfig}}},[g]),n=$2.useMemo(()=>({...U,text:u}),[U,u]),o=$2.useMemo(()=>[...b,...v],[b,v]),K0=fL(B.assetUrls);if(R.find((y0)=>y0.type==="embed")&&F)Dq.setEmbedDefinitions(F);return $9.jsx(B$,{assetUrls:gL(B.assetUrls),children:$9.jsx(L$,{overrides:TB(B.overrides),locale:V??B.user?.userPreferences.get().locale??v6.locale,children:$9.jsx(_R,{initialState:"select",...B,components:j,shapeUtils:R,bindingUtils:A,assetUtils:C,overlayUtils:f,tools:h,options:n,assetUrls:K0,children:$9.jsxs(MT,{...B,components:j,mediaMimeTypes:o,children:[$9.jsx(dN0,{maxImageDimension:Z,maxAssetSize:q,acceptedImageMimeTypes:b,acceptedVideoMimeTypes:v,onMount:Y}),Q]})})})})}function dN0({maxImageDimension:J,maxAssetSize:Q,acceptedImageMimeTypes:Z,acceptedVideoMimeTypes:q,onMount:X}){let K=y(),Y=C5(),W=t(),z=o0();VU(()=>{let $=[];$.push(fb(K)),K.fonts.requestFonts(cE);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"})),iE(K,{maxImageDimension:J,maxAssetSize:Q,acceptedImageMimeTypes:Z,acceptedVideoMimeTypes:q,toasts:Y,msg:W}),$.push(K.store.props.onMount(K)),$.push(X?.(K)),()=>{$.forEach((F)=>F?.())}});let{Canvas:G}=T4(),{ContextMenu:H}=N4();if(H)return $9.jsx(H,{});if(G)return $9.jsx(G,{});return null}var RT=E(c(),1);var l9=E(m(),1);var H00={text:{tipTapConfig:{extensions:wZ},addFontsFromNode:f$}},iN0=l9.memo(function(Q){let[Z,q]=l9.useState(null),[X,K]=l9.useState(null),Y=m8(Q.shapeUtils??[]),W=l9.useMemo(()=>F2("type",Y,bX),[Y]),z=m8(Q.bindingUtils??[]),G=l9.useMemo(()=>F2("type",z,AX),[z]),H=$R({snapshot:Q.snapshot,shapeUtils:W}),{pageId:$,bounds:_,scale:F,pixelRatio:U,background:V,padding:N,darkMode:B,preserveAspectRatio:O,format:M="svg",licenseKey:L,assetUrls:j,options:k,textOptions:R}=Q,I=l9.useMemo(()=>({...H00,...k,text:{...H00.text,...k?.text??R}}),[k,R]),A=fL(j);return l9.useLayoutEffect(()=>{if(!X)return;if(!H)return;let w=!1,C=X.ownerDocument.createElement("div");X.appendChild(C),X.classList.add("tl-container","tl-theme__light");let x=new G0({store:H,shapeUtils:W,bindingUtils:G,tools:[],getContainer:()=>C,licenseKey:L,fontAssetUrls:A.fonts,options:I});if($)x.setCurrentPage($);let f=x.getCurrentPageShapeIds();async function T(){let h=await x.toImage([...f],{bounds:_,scale:F,background:V,padding:N,darkMode:B,preserveAspectRatio:O,format:M});if(!h||w)return;let b=URL.createObjectURL(h.blob);q(b),x.dispose()}return T(),()=>{w=!0}},[M,X,H,W,G,$,_,F,V,N,B,O,L,U,A,I]),l9.useEffect(()=>{return()=>{if(Z)URL.revokeObjectURL(Z)}},[Z]),RT.jsx("div",{ref:K,style:{position:"relative",width:"100%",height:"100%"},children:Z&&RT.jsx("img",{src:Z,referrerPolicy:"strict-origin-when-cross-origin",style:{width:"100%",height:"100%"}})})});var XJ=E(c(),1);var uL=E(m(),1);var nN0=uL.memo(function({children:Q}){let Z=t(),q=A1(),X=uL.useRef(null);r6(X);let K=Q??XJ.jsx(vI,{});if(q<e0.MOBILE)return null;return XJ.jsx("div",{ref:X,className:"tlui-help-menu",children:XJ.jsxs(XQ,{id:"help menu",children:[XJ.jsx(KQ,{children:XJ.jsx(w0,{type:"help",title:Z("help-menu.title"),"data-testid":"help-menu.button",children:XJ.jsx(z0,{icon:"question-mark",small:!0})})}),XJ.jsx(YQ,{side:"top",align:"end",alignOffset:0,sideOffset:8,children:XJ.jsx(z4,{type:"menu",sourceId:"help-menu",children:K})})]})})});var $_=E(c(),1);var _00=E(c1(),1);var F00=E(m(),1);var sN0=F00.forwardRef(function({children:Q,className:Z},q){return $_.jsxs(o$.Trigger,{ref:q,className:_00.default("tlui-button tlui-select__trigger",Z),children:[Q,$_.jsx(o$.Icon,{className:"tlui-select__chevron",children:$_.jsx(S6,{icon:"chevron-down",label:"",small:!0})})]})});var rN0=E(c(),1),kT=E(m(),1);var p9={White:"white",LightGray:"lightGray",Gray:"gray",Black:"black",Green:"green",Cyan:"cyan",Blue:"blue",Indigo:"indigo",Violet:"violet",Red:"red",Orange:"orange",Yellow:"yellow"},vX={Small:"small",Medium:"medium",Large:"large"},H_={Draw:"draw",Solid:"solid",Dashed:"dashed",Dotted:"dotted"},TQ={Start:"start",Middle:"middle",End:"end",Justify:"justify"},__={Script:"script",Sans:"sans",Serif:"serif",Mono:"mono"};var eB1={[p9.White]:"black",[p9.Black]:"black",[p9.LightGray]:"grey",[p9.Gray]:"grey",[p9.Green]:"light-green",[p9.Cyan]:"green",[p9.Blue]:"light-blue",[p9.Indigo]:"blue",[p9.Orange]:"orange",[p9.Yellow]:"yellow",[p9.Red]:"red",[p9.Violet]:"light-violet"},JO1={[__.Mono]:"mono",[__.Sans]:"sans",[__.Script]:"draw",[__.Serif]:"serif"},QO1={[TQ.Start]:"start",[TQ.Middle]:"middle",[TQ.End]:"end",[TQ.Justify]:"start"},ZO1={[TQ.Start]:"start",[TQ.Middle]:"middle",[TQ.End]:"end",[TQ.Justify]:"start"},qO1={[vX.Small]:"s",[vX.Medium]:"l",[vX.Large]:"xl"},XO1={[vX.Small]:"m",[vX.Medium]:"l",[vX.Large]:"xl"},KO1={[H_.Solid]:"solid",[H_.Dashed]:"dashed",[H_.Dotted]:"dotted",[H_.Draw]:"draw"};var oN0=P.object({schemaVersion:P.literal(1),storeVersion:P.positiveInteger,recordVersions:P.dict(P.string,P.object({version:P.positiveInteger,subTypeVersions:P.dict(P.string,P.positiveInteger).optional(),subTypeKey:P.string.optional()}))}),tN0=P.object({schemaVersion:P.literal(2),sequences:P.dict(P.string,P.positiveInteger)}),GO1=P.object({tldrawFileFormatVersion:P.nonZeroInteger,schema:P.numberUnion("schemaVersion",{1:oN0,2:tN0}),records:P.arrayOf(P.object({id:P.string,typeName:P.string}).allowUnknownProperties())});y5("tldraw","5.2.3","esm");var SX=E(m(),1);function eN0(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 U00(J,Q){let Z=eN0(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 V00(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 H9=E(c(),1),N00=null;function JB0(){return N00??=j2({shapeUtils:bX,bindingUtils:AX}).schema,N00}function ET(J,Q){let Z=JB0();try{if(Z.migrateStoreSnapshot(J).type==="success")return null}catch{}let q=U00(J.schema,Z.serialize().sequences);if(q.length>0)return{newer:!0,writer:Q,detail:V00(Q,q)};return{newer:!1,writer:Q,detail:"The saved snapshot failed to load."}}function O00(J){let[Q,Z]=SX.useState(!1),[q,X]=SX.useState(null),K=SX.useRef(void 0);return SX.useEffect(()=>{let Y=!1;return Z(!1),X(null),K.current=void 0,fetch(`/api/workspaces/${J}/scratchpad`).then((W)=>W.json()).then((W)=>{if(Y)return;if(W?.document){let z=ET(W.document,W.writer);if(z)X(z);else K.current=W.document}Z(!0)}).catch(()=>{if(!Y)Z(!0)}),()=>{Y=!0}},[J]),{loaded:Q,snapshot:K.current,skew:q,flagSkew:X}}function L00({skew:J}){return H9.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:H9.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:[H9.jsxs("div",{className:"flex items-center gap-2",children:[H9.jsx(B00,{size:20,stroke:1.5,className:"shrink-0 text-amber-600"}),H9.jsx("h2",{className:"font-medium text-foreground",children:J.newer?"This canvas needs a newer moi":"This canvas couldn’t be loaded"})]}),J.newer?H9.jsxs(H9.Fragment,{children:[H9.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})`:"",".",H9.jsx("br",{})," Please update moi and restart the server:"]}),H9.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"})]}):H9.jsx("p",{className:"text-sm text-muted-foreground",children:J.detail})]})})}var jq=E(m(),1);var u4=E(c(),1),QB0=[{kind:"tool",id:"select",label:"Select",Icon:P00},{kind:"tool",id:"hand",label:"Hand",Icon:E00},{kind:"sep"},{kind:"tool",id:"draw",label:"Pencil",Icon:PT},{kind:"geo",label:"Rectangle",Icon:I00},{kind:"tool",id:"note",label:"Sticker",Icon:w00},{kind:"tool",id:"text",label:"Text",Icon:IT},{kind:"tool",id:"line",label:"Line",Icon:C00},{kind:"tool",id:"arrow",label:"Arrow",Icon:R00},{kind:"sep"},{kind:"tool",id:"highlight",label:"Highlighter",Icon:A00},{kind:"tool",id:"eraser",label:"Eraser",Icon:k00}];function AT({label:J,active:Q,Icon:Z,onClick:q}){return u4.jsx(j00,{type:"button",size:"icon",variant:Q?"default":"ghost","aria-label":J,title:J,onClick:q,className:yQ(!Q&&"text-muted-foreground hover:text-foreground"),children:u4.jsx(Z,{stroke:1.5})})}function D00(J,Q){if(Q==="geo")J.setStyleForNextShapes(T6,"draw"),J.setStyleForNextShapes(e4,"m");else if(Q==="note")J.setStyleForNextShapes(I4,"draw"),J.setStyleForNextShapes(R9,"middle"),J.setStyleForNextShapes(k9,"middle"),M00(J,"sticker","yellow");else if(Q==="text")J.setStyleForNextShapes(I4,"draw"),J.setStyleForNextShapes(R9,"middle"),J.setStyleForNextShapes(k9,"middle");else if(Q==="highlight")M00(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")}}function T00({editor:J}){let[Q,Z]=jq.useState(()=>J.getCurrentToolId());jq.useEffect(()=>{return Z(J.getCurrentToolId()),g1("scratch current tool",()=>Z(J.getCurrentToolId()))},[J]);let q=(K)=>{J.run(()=>{D00(J,K),J.setCurrentTool(K)})},X=()=>{J.run(()=>{J.setStyleForNextShapes(x6,"rectangle"),D00(J,"geo"),J.setCurrentTool("geo")})};return u4.jsx("div",{className:"absolute top-1/2 left-2 -translate-y-1/2",children:u4.jsx(b00.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:QB0.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(AT,{label:K.label,Icon:K.Icon,active:Q==="geo",onClick:X},"geo");if(K.kind==="menu")return u4.jsx(AT,{label:K.label,Icon:K.Icon,active:!1,onClick:()=>{}},"menu");return u4.jsx(AT,{label:K.label,Icon:K.Icon,active:Q===K.id,onClick:()=>q(K.id)},K.id)})})})}var ZB0=["color","size","dash","fill"],y00={draw:["color","size","dash"],geo:["color","fill"],note:["color","size"],text:["color","size"],line:["color","dash","size"],highlight:["color","size"],arrow:["color","size"]},qB0={draw:["color","size","dash"],geo:["color","fill"],note:["color","size"],text:["color","size"],line:["color","dash","size"],highlight:["color","size"],arrow:["color","size"]},x00={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 XB0(J){let Q=J.getCurrentToolId();if(Q==="highlight")return"highlight";if(Q==="note")return"sticker";if(y00[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 M00(J,Q,Z){if(!x00[Q].swatches.map((X)=>X.value).includes(J.getStyleForNextShape(_1)))J.setStyleForNextShapes(_1,Z)}var KB0=[{value:"m",label:"Small",dot:"size-1.5",glyph:16},{value:"xl",label:"Large",dot:"size-3",glyph:24}],YB0=[{value:"draw",label:"Rough",preview:"border-b-2 border-current"},{value:"dashed",label:"Dash",preview:"border-b-2 border-dashed border-current"}],WB0=[{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 mL(J,Q){if(J.getSelectedShapeIds().length>0)return J.getSharedStyles().getAsKnownValue(Q);return J.getStyleForNextShape(Q)}function cL(J,Q,Z){J.run(()=>{if(J.setStyleForNextShapes(Q,Z),J.getSelectedShapeIds().length>0)J.setStyleForSelectedShapes(Q,Z)})}function zB0(J){let Q=y00[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 qB0[K.type]??[])q.add(Y)}return ZB0.filter((X)=>q.has(X))}function GB0(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 CT(J){return{controls:zB0(J),palette:x00[XB0(J)],color:mL(J,_1),size:mL(J,e4),sizeGlyph:GB0(J),dash:mL(J,T6),fill:mL(J,y6)}}function v00({editor:J}){let[Q,Z]=jq.useState(()=>CT(J));if(jq.useEffect(()=>{return Z(CT(J)),g1("scratch styles",()=>Z(CT(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:()=>cL(J,_1,X.value),className:yQ("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:KB0.map((X)=>u4.jsx("button",{type:"button",title:X.label,onClick:()=>cL(J,e4,X.value),className:yQ("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(PT,{size:20,stroke:1.5}):Q.sizeGlyph==="letter"?u4.jsx(IT,{size:X.glyph,stroke:X.glyph===16?1.75:1.5}):u4.jsx("span",{className:yQ("rounded-full bg-current",X.dot)})},X.value))}),dash:u4.jsx("div",{className:"flex flex-col items-center gap-1 text-foreground",children:YB0.map((X)=>u4.jsx("button",{type:"button",title:X.label,onClick:()=>cL(J,T6,X.value),className:yQ("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:yQ("w-3.5",X.preview)})},X.value))}),fill:u4.jsx("div",{className:"flex flex-col items-center gap-1 text-foreground",children:WB0.map((X)=>u4.jsx("button",{type:"button",title:X.label,onClick:()=>cL(J,y6,X.value),className:yQ("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:yQ("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(jq.Fragment,{children:[K>0&&u4.jsx("div",{className:"h-px w-5 bg-border"}),q[X]]},X))})}var S8=E(c(),1),S00=Math.random().toString(36).slice(2),$B0=500,HB0="tldraw-2026-09-27/WyJlaDdIczMxRSIsWyIqIl0sMTYsIjIwMjYtMDktMjciXQ.6OucDghQHnAFl2Ceg8qf48M2oIis6qHdZfqFsKdBZwd610QixrvG1jUnwCbI1Xs2BoXzptPs+pQYF25NyShFbw";function _B0(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 FB0(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 UB0(){return S8.jsx("div",{className:"absolute inset-0 bg-[color-mix(in_oklch,var(--muted),var(--background)_50%)]"})}function VB0({x:J,y:Q,z:Z,size:q}){let X=D5("scratch-grid"),K=y(),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,H=z>0?z%W:W+z%W,$=G>0?G%W:W+G%W;return S8.jsxs("svg",{className:"tl-grid",version:"1.1",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[S8.jsx("defs",{children:S8.jsx("pattern",{id:X,width:W,height:W,patternUnits:"userSpaceOnUse",children:S8.jsx("circle",{className:"fill-accent",cx:H,cy:$,r:1})})}),S8.jsx("rect",{width:"100%",height:"100%",fill:`url(#${X})`})]})}var NB0={Background:UB0,Grid:VB0,Toolbar:null,StylePanel:null,Minimap:null,MainMenu:null,PageMenu:null,ActionsMenu:null,QuickActions:null,HelpMenu:null,DebugMenu:null,ZoomMenu:null},BB0={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}},OB0={maxPages:1},LB0=33554432,DB0=2048;function sj1(){let J=f00(),Q=H2.useRef(null),Z=H2.useRef(null),q=H2.useRef(null),X=H2.useRef(!1),[K,Y]=H2.useState(null),{loaded:W,snapshot:z,skew:G,flagSkew:H}=O00(J),$=H2.useRef(null);if($.current?.id!==J)$.current={id:J,store:FB0(J)};let _=$.current.store,F=H2.useCallback(()=>{let V=Q.current;if(!V)return;let N;try{N=OG(V.store).document}catch{return}fetch(`/api/workspaces/${J}/scratchpad`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({document:N,origin:S00})}).catch(()=>{})},[J]);g00((V)=>{if(V.type!=="scratchpad:updated"||V.workspaceId!==J)return;if(V.origin&&V.origin===S00)return;if(!Q.current)return;fetch(`/api/workspaces/${J}/scratchpad`).then((N)=>N.json()).then((N)=>{let B=Q.current;if(!B||!N?.document)return;let O=ET(N.document,N.writer);if(O){if(q.current)clearTimeout(q.current);H(O);return}X.current=!0,z3(B.store,{document:N.document})}).catch(()=>{})});let U=H2.useCallback((V)=>{Q.current=V,Y(V),V.updateInstanceState({isGridMode:!0}),V.run(()=>{V.setStyleForNextShapes(I4,"draw"),V.setStyleForNextShapes(R9,"middle"),V.setStyleForNextShapes(k9,"middle"),V.setStyleForNextShapes(y6,"fill")});let N=V.store.listen(()=>{if(X.current){X.current=!1;return}if(q.current)clearTimeout(q.current);q.current=setTimeout(F,$B0)},{source:"user",scope:"document"});wT(J,_B0(V));let B=(M)=>{let L=M.target;if(!!L&&!!Z.current?.contains(L)){if(!V.getIsFocused())V.focus()}else if(V.getIsFocused())V.blur()},O=V.getContainer().ownerDocument;return O.addEventListener("pointerdown",B,!0),V.focus(),()=>{if(N(),O.removeEventListener("pointerdown",B,!0),q.current)clearTimeout(q.current);wT(J,null),Y(null),Q.current=null}},[J,F]);if(!W)return S8.jsx("div",{className:"min-h-0 flex-1 bg-muted/40"});if(G)return S8.jsx(L00,{skew:G});return S8.jsxs("div",{ref:Z,className:"relative min-h-0 flex-1 overflow-hidden",children:[S8.jsx("div",{className:"absolute inset-0",children:S8.jsx(jT,{snapshot:z,assets:_,licenseKey:HB0,onMount:U,components:NB0,overrides:BB0,options:OB0,maxAssetSize:LB0,maxImageDimension:DB0,autoFocus:!1})}),K&&S8.jsx(T00,{editor:K}),K&&S8.jsx(v00,{editor:K})]})}export{sj1 as Scratchpad};