@zeniai/web-app-ui 5.4.10-dev → 5.4.11-dev

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 (153) hide show
  1. package/dist/assets/{AccountMappingScreen-BT4O8HTD.js → AccountMappingScreen-CMj3JkGt.js} +2 -2
  2. package/dist/assets/ActualMatchingMatchDetailScreen-Dd_vJSSr.js +1 -0
  3. package/dist/assets/AddressRoutes-7FdlQcLM.js +1 -0
  4. package/dist/assets/AddressScreen-BbgME8aO.js +9 -0
  5. package/dist/assets/{AiCfoScreen-RbcUBAdM.js → AiCfoScreen-CU1e2Oi8.js} +5 -5
  6. package/dist/assets/{AppDrawer-Sa4LLULj.js → AppDrawer-Dm9C8j__.js} +1 -1
  7. package/dist/assets/{BillPayApprovalRoutes-BbNV-MR5.js → BillPayApprovalRoutes-GN_PKZBM.js} +1 -1
  8. package/dist/assets/{BillPayRoutes-uNYLvj5o.js → BillPayRoutes-7abJ7Y81.js} +8 -8
  9. package/dist/assets/{BusinessVerificationPageScreen-ibSIK2nI.js → BusinessVerificationPageScreen-8VbyEZWD.js} +2 -2
  10. package/dist/assets/CardsAiCfoScreen-BcEHiZtA.js +14 -0
  11. package/dist/assets/{ChargeCardRoutes-CO87Ou5-.js → ChargeCardRoutes-BR5_qY8y.js} +9 -9
  12. package/dist/assets/CompanyPassportScreen-L6OY8AwA.js +1 -0
  13. package/dist/assets/ConnectionAuthScreen-F-iZ536h.js +11 -0
  14. package/dist/assets/CustomerOnboardingAuthScreen-Gnqx1b1N.js +1 -0
  15. package/dist/assets/{CustomerOnboardingRoutes-BynW3iC3.js → CustomerOnboardingRoutes-3OH4ZWPk.js} +3 -3
  16. package/dist/assets/{DashboardRoutes-ndbO6Qws.js → DashboardRoutes-X31R7cQf.js} +4 -4
  17. package/dist/assets/{DefaultTenantHome-2hNb0a3U.js → DefaultTenantHome-FpeIWNLr.js} +1 -1
  18. package/dist/assets/DomesticWireDetailScreen-BZbvzqXc.js +18 -0
  19. package/dist/assets/{DrawerScreen-b7QdOhuW.js → DrawerScreen-CmgVB1Zi.js} +1 -1
  20. package/dist/assets/EntityDetailRoutes-5IMi-E-b.js +1 -0
  21. package/dist/assets/{ExpenseAutomationRoutes-C6_zyg5Q.js → ExpenseAutomationRoutes-DH5uN2wQ.js} +6 -6
  22. package/dist/assets/{FeaturePreviewScreen-B5U7lEG-.js → FeaturePreviewScreen-Cnh2Fe6t.js} +1 -1
  23. package/dist/assets/HubSpotOAuthCallbackScreen-C94ZBMtd.js +1 -0
  24. package/dist/assets/InboxNotificationsProvider-CJt6vmnU.js +1 -0
  25. package/dist/assets/{InvoicingRoutes-C4zfN1Wc.js → InvoicingRoutes-Q-6aUqgu.js} +2 -2
  26. package/dist/assets/{MagicLinkRoutes-BDl3Flj2.js → MagicLinkRoutes-CR6ShXCQ.js} +20 -20
  27. package/dist/assets/MagicLinkSignInScreen-CBjgwG_1.js +12 -0
  28. package/dist/assets/{MobileAppDrawer-DVldqyUl.js → MobileAppDrawer-B4_Hh2uX.js} +1 -1
  29. package/dist/assets/NotFoundScreen-CxVO6BUm.js +1 -0
  30. package/dist/assets/{NotificationRoutes-UAhv091T.js → NotificationRoutes-CDa5TISi.js} +1 -1
  31. package/dist/assets/OAuthConsentScreen-D8WvwiVN.js +1 -0
  32. package/dist/assets/PandLWithForecastRoutes-CiaozOzI.js +1 -0
  33. package/dist/assets/PaymentLinkScreen-BN13u2tw.js +21 -0
  34. package/dist/assets/PeopleRoutes-B5eZw1Xs.js +22 -0
  35. package/dist/assets/PerformanceRoutes-B5KqyHoS.js +1 -0
  36. package/dist/assets/{Preview-CU7aguP4.js → Preview-gj_-pUjR.js} +1 -1
  37. package/dist/assets/QBOConnectionScreen-BD6w4pxT.js +101 -0
  38. package/dist/assets/{ReimbursementApprovalRoutes-DrsMWkl8.js → ReimbursementApprovalRoutes-_wQ1m-SZ.js} +1 -1
  39. package/dist/assets/{ReimbursementApprovalRuleDetailScreen-Dw7QQEoQ.js → ReimbursementApprovalRuleDetailScreen-CQJ7WhRf.js} +1 -1
  40. package/dist/assets/ReimbursementRoutes-mHGAbMEo.js +68 -0
  41. package/dist/assets/{ReportsRoutes-B5lACyrL.js → ReportsRoutes-DNdr9gVu.js} +1 -1
  42. package/dist/assets/RewardsRoutes-CRQaDmuu.js +1 -0
  43. package/dist/assets/{ScheduleDetailsPrepaidExpensesScreen-LwZh192V.js → ScheduleDetailsPrepaidExpensesScreen-Bgrqk-Br.js} +5 -5
  44. package/dist/assets/ScreenRoutes-Cix6ynkH.js +2 -0
  45. package/dist/assets/{SettingsRoutes-DEHUtOgG.js → SettingsRoutes-CXzUd0P6.js} +6 -6
  46. package/dist/assets/{SetupPagesScreen-Dv6lGRG5.js → SetupPagesScreen-DzLiX5R5.js} +5 -5
  47. package/dist/assets/SignInScreen-VX0iUVME.js +1 -0
  48. package/dist/assets/SignOutScreen-BXVxv4o-.js +9 -0
  49. package/dist/assets/{TaskListScreen-8hq6cEbk.js → TaskListScreen-Dv5TjArL.js} +2 -2
  50. package/dist/assets/TaskRoutes-aDI7RZCK.js +9 -0
  51. package/dist/assets/TransactionDetailRoutes-C0gGgGik.js +1 -0
  52. package/dist/assets/{TransactionDetailScreen-It6ORIbN.js → TransactionDetailScreen-BsGN3Yd5.js} +2 -2
  53. package/dist/assets/{TransactionListRoutes-BTjkHFVX.js → TransactionListRoutes-_bc9UoMG.js} +1 -1
  54. package/dist/assets/{TreasuryRoutes-Bys8F57E.js → TreasuryRoutes-C7ABXX2A.js} +6 -6
  55. package/dist/assets/{VendorsRoutes-abjQ1HGQ.js → VendorsRoutes-BlorNbi4.js} +11 -11
  56. package/dist/assets/WiseConfirmationScreen-DhPTIeWc.js +12 -0
  57. package/dist/assets/{ZeniAccountRoutes-DlvpS2Bq.js → ZeniAccountRoutes-QObrERl4.js} +11 -11
  58. package/dist/assets/ZeniAccountStatementScreen-BHlw6cTG.js +9 -0
  59. package/dist/assets/{accountMappingHelper-C9fFA6EC.js → accountMappingHelper-BbISzw1n.js} +1 -1
  60. package/dist/assets/{analytics-C3OBHjEG.js → analytics-C4ICDJLl.js} +1 -1
  61. package/dist/assets/{analyticsHelper-exrV7AE9.js → analyticsHelper-CPHVprda.js} +1 -1
  62. package/dist/assets/{core-o-ca34AJ.js → core-C4Vfz6Ll.js} +1 -1
  63. package/dist/assets/{decodeURIComponentSafe-CdLVPaCS.js → decodeURIComponentSafe-CYsmEPcV.js} +1 -1
  64. package/dist/assets/{dnd-sqKp8sUm.js → dnd-kAQqqaX2.js} +1 -1
  65. package/dist/assets/{empty-CynSKeaU.js → empty-asCy4wrm.js} +1 -1
  66. package/dist/assets/{empty-BnmFWJHQ.js → empty-uRyODf4S.js} +1 -1
  67. package/dist/assets/{emptyVideoElement-BUTaximG.js → emptyVideoElement-79iYt27c.js} +1 -1
  68. package/dist/assets/epic-B2pHLhBD.js +2 -0
  69. package/dist/assets/expenseAutomationHelper-hmRJBbGd.js +1 -0
  70. package/dist/assets/{getLocaleForTenant-CBmE-ohA.js → getLocaleForTenant-DJIJUZ-c.js} +1 -1
  71. package/dist/assets/{index-BLrePuqf.js → index-BTd7WWV0.js} +1 -1
  72. package/dist/assets/{index-Btt0Zihe.js → index-B_kv_EmZ.js} +1 -1
  73. package/dist/assets/{index-Bqod5kmp.js → index-Bg8f4cim.js} +1 -1
  74. package/dist/assets/{index-Bx2gJO4r.js → index-CJ_pjNEa.js} +7 -7
  75. package/dist/assets/{index-j2p4Lnj3.js → index-Doknm_HP.js} +1 -1
  76. package/dist/assets/index-E3novWwq.js +1 -0
  77. package/dist/assets/{index-D4vHXZ_y.js → index-UMoTq5JU.js} +2 -2
  78. package/dist/assets/index-pA4BduR_.js +1 -0
  79. package/dist/assets/{lexical-CEO4_NFb.js → lexical-SeD-pdYj.js} +1 -1
  80. package/dist/assets/liveblocks-DZUXZ-JO.js +59 -0
  81. package/dist/assets/{lottie-Dl8uwTmw.js → lottie-txhqSe8x.js} +1 -1
  82. package/dist/assets/{mui-cK5UWUvi.js → mui-C0PYnbt1.js} +1 -1
  83. package/dist/assets/{pathToGoBack-Bk8jMuE9.js → pathToGoBack-DF1y-0ht.js} +1 -1
  84. package/dist/assets/{pdf-BNJo5ucI.js → pdf-bOGTjHnz.js} +5 -5
  85. package/dist/assets/{pdf-lib-C69QvBGc.js → pdf-lib-BsfRp21l.js} +1 -1
  86. package/dist/assets/{plaid-C8bTkbCG.js → plaid-hQES7k9Y.js} +1 -1
  87. package/dist/assets/{pusher-C6PXikRK.js → pusher-BoH5mrch.js} +1 -1
  88. package/dist/assets/{react-BgHw6ZMD.js → react-BQ6jUfzX.js} +1 -1
  89. package/dist/assets/{react-BCP4YdKf.js → react-BgJrrMxk.js} +1 -1
  90. package/dist/assets/{react-BfzBm-jN.js → react-Boil267a.js} +1 -1
  91. package/dist/assets/{react-CTNewL67.js → react-DXSBT-1v.js} +1 -1
  92. package/dist/assets/{react-UiIuY6Fo.js → react-ZM05SSz2.js} +1 -1
  93. package/dist/assets/{react-ixvlVzZ9.js → react-qLaRPrw4.js} +1 -1
  94. package/dist/assets/{recharts-DK1tbN_A.js → recharts-rN5v_P87.js} +1 -1
  95. package/dist/assets/{reportTimeframe-6FnDbaGY.js → reportTimeframe-C5AD1AL2.js} +1 -1
  96. package/dist/assets/{routePaths-DBf4ybcn.js → routePaths-DYebh4Li.js} +1 -1
  97. package/dist/assets/{sentry-Buwow292.js → sentry-DfoGRlTp.js} +1 -1
  98. package/dist/assets/{stripSplatSuffix-BKbpznmZ.js → stripSplatSuffix-Db8ayksN.js} +1 -1
  99. package/dist/assets/{url-B_oojQRK.js → url-B-JScRaX.js} +1 -1
  100. package/dist/assets/{url-C7oPARVv.js → url-BtS-4pap.js} +1 -1
  101. package/dist/assets/{useActualMatchingMatchDetail-DBoUtV2d.js → useActualMatchingMatchDetail-DPtaMcdm.js} +1 -1
  102. package/dist/assets/{useAiCfoDashboardSuggestedQuestionsChips-D_VhexUa.js → useAiCfoDashboardSuggestedQuestionsChips-D2InIpSO.js} +1 -1
  103. package/dist/assets/useAskAiCfoHostNavButtonProps-k11tYjVi.js +1 -0
  104. package/dist/assets/{useChargeCardPusherEvents-B6OwhCNo.js → useChargeCardPusherEvents-Bf7Vv0PE.js} +1 -1
  105. package/dist/assets/{useDeviceId-CeB6LWI8.js → useDeviceId-_3Ay4Sah.js} +1 -1
  106. package/dist/assets/useEmailConnectResultRefresh-BCLtP2Ad.js +1 -0
  107. package/dist/assets/useEnsureVendorListLoaded-Bud-c91I.js +1 -0
  108. package/dist/assets/{useInitialThreadRequest-C3w5IRp7.js → useInitialThreadRequest-BVMcY486.js} +1 -1
  109. package/dist/assets/useTaskManagerAccess-Cp8R2Cu9.js +1 -0
  110. package/dist/assets/{useTaskManagerPusherEvents-LOx5aVW8.js → useTaskManagerPusherEvents-p1TIydvw.js} +1 -1
  111. package/dist/assets/utils-CmKqkYr5.js +36 -0
  112. package/dist/assets/{withTransactionSidePanel-CVCleugc.js → withTransactionSidePanel-btBdqPWA.js} +5 -5
  113. package/dist/assets/{zeni-epic-state-MQ0qdl-Q.js → zeni-epic-state-DmXGRK_Y.js} +4 -4
  114. package/dist/index.html +1 -1
  115. package/package.json +1 -1
  116. package/dist/assets/ActualMatchingMatchDetailScreen-Ce_XDU4u.js +0 -1
  117. package/dist/assets/AddressRoutes-BQEPn0Yr.js +0 -1
  118. package/dist/assets/AddressScreen-D2FVWJY-.js +0 -9
  119. package/dist/assets/CardsAiCfoScreen-CkEc2DEo.js +0 -14
  120. package/dist/assets/CompanyPassportScreen-DJeoMdCg.js +0 -1
  121. package/dist/assets/ConnectionAuthScreen-Bf2Ucb1Q.js +0 -11
  122. package/dist/assets/CustomerOnboardingAuthScreen-D3RbfqTk.js +0 -1
  123. package/dist/assets/DomesticWireDetailScreen-BqDioG6P.js +0 -18
  124. package/dist/assets/EntityDetailRoutes-aGFvyTv5.js +0 -1
  125. package/dist/assets/HubSpotOAuthCallbackScreen-Dr1Xep8u.js +0 -1
  126. package/dist/assets/InboxNotificationsProvider-Cph6MP0g.js +0 -1
  127. package/dist/assets/MagicLinkSignInScreen-Bie6nkkJ.js +0 -12
  128. package/dist/assets/NotFoundScreen-BXfz4Cwt.js +0 -1
  129. package/dist/assets/OAuthConsentScreen-yv2un5zc.js +0 -1
  130. package/dist/assets/PandLWithForecastRoutes-DZO_Ak_R.js +0 -1
  131. package/dist/assets/PaymentLinkScreen-DgjQbdJS.js +0 -21
  132. package/dist/assets/PeopleRoutes-CBBW0nYr.js +0 -22
  133. package/dist/assets/PerformanceRoutes-CIoRY1pR.js +0 -1
  134. package/dist/assets/QBOConnectionScreen-CI47ZrlS.js +0 -100
  135. package/dist/assets/ReimbursementRoutes-BiacT-VJ.js +0 -68
  136. package/dist/assets/RewardsRoutes-26PBDRkk.js +0 -1
  137. package/dist/assets/ScreenRoutes-CdEeBqiV.js +0 -2
  138. package/dist/assets/SignInScreen-CzvdRg4U.js +0 -1
  139. package/dist/assets/SignOutScreen-DfTRMdjb.js +0 -9
  140. package/dist/assets/TaskRoutes-C1KzEFV7.js +0 -9
  141. package/dist/assets/TransactionDetailRoutes-BB45JvGj.js +0 -1
  142. package/dist/assets/WiseConfirmationScreen-DewxnFTy.js +0 -12
  143. package/dist/assets/ZeniAccountStatementScreen-DVR6RIK2.js +0 -9
  144. package/dist/assets/epic-bBvrG0DE.js +0 -2
  145. package/dist/assets/expenseAutomationHelper-8n6GRk1T.js +0 -1
  146. package/dist/assets/index-BzW-Y7Lk.js +0 -1
  147. package/dist/assets/index-Cmb8jqqj.js +0 -1
  148. package/dist/assets/liveblocks-BdMPZzDQ.js +0 -59
  149. package/dist/assets/useAskAiCfoHostNavButtonProps-B6lOnQ69.js +0 -1
  150. package/dist/assets/useEmailConnectResultRefresh-t37-D3lN.js +0 -1
  151. package/dist/assets/useEnsureVendorListLoaded-BmranjK0.js +0 -1
  152. package/dist/assets/useTaskManagerAccess-By_NjZen.js +0 -1
  153. package/dist/assets/utils-D4KfE2cr.js +0 -36
@@ -0,0 +1,59 @@
1
+ var ed=e=>{throw TypeError(e)};var td=(e,t,n)=>t.has(e)||ed("Cannot "+n);var bt=(e,t,n)=>(td(e,t,"read from private field"),n?n.call(e):t.get(e)),nd=(e,t,n)=>t.has(e)?ed("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),wa=(e,t,n,r)=>(td(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);import{r as p1,a as m,b as vu,e as No,g as m1,R as _e}from"./sentry-DfoGRlTp.js";import{r as Mi,R as g1}from"./core-C4Vfz6Ll.js";import{t as v1,d as y1}from"./recharts-rN5v_P87.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="c3820026-4d79-4bb4-9b3a-7530a200ea47",e._sentryDebugIdIdentifier="sentry-dbid-c3820026-4d79-4bb4-9b3a-7530a200ea47")}catch{}})();var rd,od,id={exports:{}},Zo={},v=(od||(od=1,id.exports=(function(){if(rd)return Zo;rd=1;var e=p1(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function s(a,u,c){var f,l={},d=null,h=null;for(f in c!==void 0&&(d=""+c),u.key!==void 0&&(d=""+u.key),u.ref!==void 0&&(h=u.ref),u)r.call(u,f)&&!i.hasOwnProperty(f)&&(l[f]=u[f]);if(a&&a.defaultProps)for(f in u=a.defaultProps)l[f]===void 0&&(l[f]=u[f]);return{$$typeof:t,type:a,key:d,ref:h,props:l,_owner:o.current}}return Zo.Fragment=n,Zo.jsx=s,Zo.jsxs=s,Zo})()),id.exports);function d5(e){const[t,n]=m.useState(!1);return m.useEffect((()=>{n(!0)}),[]),v.jsx(m.Suspense,{fallback:e.fallback,children:t?typeof e.children=="function"?e.children():e.children:e.fallback})}var b1=Object.defineProperty,ea="3.24.0",Zi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:vu!==void 0?vu:{};function Ip(e,t,n){const r=Symbol.for(e),o=`${t} (${n})`;Zi[r]?Zi[r]===o||(function(i){console.error(i)})(["Multiple copies of Liveblocks are being loaded in your project. This will cause issues! See https://liveblocks.io/docs/errors/dupes ","","Conflicts:",`- ${e} ${Zi[r]} (already loaded)`,`- ${e} ${o} (trying to load this now)`].join(`
2
+ `)):Zi[r]=o}function Ue(){const e=new Set;function t(o){return e.add(o),()=>e.delete(o)}function n(o){const i=t((s=>(i(),o(s))));return i}async function r(o){let i;return new Promise((s=>{i=t((a=>{(o===void 0||o(a))&&s(a)}))})).finally((()=>i?.()))}return{notify:function(o){let i=!1;for(const s of e)s(o),i=!0;return i},subscribe:t,subscribeOnce:n,count:function(){return e.size},waitUntil:r,dispose(){e.clear()},observable:{subscribe:t,subscribeOnce:n,waitUntil:r}}}function hn(e){throw new Error(e)}function kc(e){return Object.entries(e)}function Hn(e){try{return JSON.parse(e)}catch{return}}function Ci(e){return JSON.parse(JSON.stringify(e))}function yu(e){return e.filter((t=>t!=null))}function wi(e){const t={...e};return Object.keys(e).forEach((n=>{const r=n;t[r]===void 0&&delete t[r]})),t}function C1(e){return new Promise((t=>setTimeout(t,e)))}async function sd(e,t,n){let r;const o=new Promise(((i,s)=>{r=setTimeout((()=>{s(new Error(n))}),t)}));return Promise.race([e,o]).finally((()=>clearTimeout(r)))}function ad(e){let t=null;return()=>(t===null&&(t=e().catch((n=>{throw setTimeout((()=>{t=null}),5e3),n}))),t)}function Tp(e,t){for(let n=e.length-1;n>=0;n--)if(t(e[n],n,e))return n;return-1}var Cr=Symbol("kSinks"),Rs=Symbol("kTrigger"),ho=null,Sr=null;function Xe(e){if(ho===null){ho=new Set;try{e()}finally{for(const t of ho)t[Rs]();ho=null}}else e()}function _c(e){ho||hn("Expected to be in an active batch"),ho.add(e)}function kp(e,t){let n=!1;const r={...e};return Object.keys(t).forEach((o=>{const i=o,s=t[i];r[i]!==s&&(s===void 0?delete r[i]:r[i]=s,n=!0)})),n?r:e}var Bc=class{equals;#e;[Cr];constructor(e){this.equals=e??Object.is,this.#e=Ue(),this[Cr]=new Set,this.get=this.get.bind(this),this.subscribe=this.subscribe.bind(this),this.subscribeOnce=this.subscribeOnce.bind(this)}dispose(){this.#e.dispose(),this.#e="(disposed)",this.equals="(disposed)"}get hasWatchers(){if(this.#e.count()>0)return!0;for(const e of this[Cr])if(e.hasWatchers)return!0;return!1}[Rs](){this.#e.notify();for(const e of this[Cr])_c(e)}subscribe(e){return this.#e.count()===0&&this.get(),this.#e.subscribe(e)}subscribeOnce(e){const t=this.subscribe((()=>(t(),e())));return t}waitUntil(){throw new Error("waitUntil not supported on Signals")}markSinksDirty(){for(const e of this[Cr])e.markDirty()}addSink(e){this[Cr].add(e)}removeSink(e){this[Cr].delete(e)}asReadonly(){return this}},Tt=class extends Bc{#e;constructor(e,t){super(t),this.#e=e}dispose(){super.dispose(),this.#e="(disposed)"}get(){return Sr?.add(this),this.#e}set(e){Xe((()=>{typeof e=="function"&&(e=e(this.#e)),this.equals(this.#e,e)||(this.#e=e,this.markSinksDirty(),_c(this))}))}},w1=class extends Tt{constructor(e){super(wi(e))}set(){throw new Error("Don't call .set() directly, use .patch()")}patch(e){super.set((t=>kp(t,e)))}},E1=Symbol(),$e=class bu extends Bc{#e;#t;#n;#r;#o;static from(...t){const n=t.pop();if(typeof n!="function"&&hn("Invalid .from() call, last argument expected to be a function"),typeof t[t.length-1]=="function"){const r=n,o=t.pop();return new bu(t,o,r)}return new bu(t,n)}constructor(t,n,r){super(r),this.#t=!0,this.#e=E1,this.#r=t,this.#n=new Set,this.#o=n}dispose(){for(const t of this.#n)t.removeSink(this);this.#e="(disposed)",this.#n="(disposed)",this.#r="(disposed)",this.#o="(disposed)"}get isDirty(){return this.#t}#i(){const t=Sr;let n;Sr=new Set;try{n=this.#o(...this.#r.map((r=>r.get())))}finally{const r=this.#n;this.#n=new Set;for(const o of Sr)this.#n.add(o),r.delete(o);for(const o of r)o.removeSink(this);for(const o of this.#n)o.addSink(this);Sr=t}return this.#t=!1,!this.equals(this.#e,n)&&(this.#e=n,!0)}markDirty(){this.#t||(this.#t=!0,this.markSinksDirty())}get(){return this.#t&&this.#i(),Sr?.add(this),this.#e}[Rs](){this.hasWatchers&&this.#i()&&super[Rs]()}},Ot=class extends Bc{#e;constructor(e){super(),this.#e=e}dispose(){super.dispose(),this.#e="(disposed)"}get(){return Sr?.add(this),this.#e}mutate(e){Xe((()=>{const t=!e||e(this.#e);t!==null&&typeof t=="object"&&"then"in t&&hn("MutableSignal.mutate() does not support async callbacks"),t!==!1&&(this.markSinksDirty(),_c(this))}))}};function ud(e,t,n){let r=0,o=e.length;for(;r<o;){const i=r+(o-r>>1);n(t,e[i])?o=i:r=i+1}return r}var ar=class ri{#e;#t;constructor(t,n){this.#t=n,this.#e=t}static with(t){return ri.fromAlreadySorted([],t)}static from(t,n){const r=new ri([],n);for(const o of t)r.add(o);return r}static fromAlreadySorted(t,n){return new ri(t,n)}clone(){return new ri(this.#e.slice(),this.#t)}add(t){const n=ud(this.#e,t,this.#t);return this.#e.splice(n,0,t),n}clear(){const t=this.#e.length>0;return this.#e.length=0,t}removeBy(t,n=Number.POSITIVE_INFINITY){let r=0;for(let o=0;o<this.#e.length;o++)if(t(this.#e[o])){if(this.#e.splice(o,1),r++,r>=n)break;o--}return r>0}remove(t){const n=this.#e.indexOf(t);return n>=0&&(this.#e.splice(n,1),!0)}removeAt(t){if(t<0||t>=this.#e.length)return;const[n]=this.#e.splice(t,1);return n}reposition(t){const n=this.#e.indexOf(t);if(n<0)throw new Error("Cannot reposition item that is not in the list");const r=this.#e[n-1],o=this.#e[n+1],i=r===void 0||this.#t(r,t),s=o===void 0||this.#t(t,o);if(i&&s)return n;let a=n;for(;a>0&&this.#t(t,this.#e[a-1]);)this.#e[a]=this.#e[a-1],a--;if(a<n)return this.#e[a]=t,a;for(;a<this.#e.length-1&&!this.#t(t,this.#e[a+1]);)this.#e[a]=this.#e[a+1],a++;return a!==n&&(this.#e[a]=t),a}at(t){return this.#e[t]}get length(){return this.#e.length}includes(t){for(let n=ud(this.#e,t,this.#t)-1;n>=0&&!this.#t(this.#e[n],t);n--)if(this.#e[n]===t)return!0;return!1}*filter(t){for(const n of this.#e)t(n)&&(yield n)}*findAllRight(t){for(let n=this.#e.length-1;n>=0;n--){const r=this.#e[n];t(r,n)&&(yield r)}}[Symbol.iterator](){return this.#e[Symbol.iterator]()}*iterReversed(){for(let t=this.#e.length-1;t>=0;t--)yield this.#e[t]}find(t,n){const r=this.findIndex(t,n);return r>-1?this.#e.at(r):void 0}findIndex(t,n=0){for(let r=Math.max(0,n);r<this.#e.length;r++)if(t(this.#e[r],r))return r;return-1}findRight(t,n){const r=this.findIndexRight(t,n);return r>-1?this.#e.at(r):void 0}findIndexRight(t,n=this.#e.length-1){for(let r=Math.min(n,this.#e.length-1);r>=0;r--)if(t(this.#e[r],r))return r;return-1}get rawArray(){return this.#e}},D1=class{#e;#t;signal;constructor(){this.#e=new Map,this.#t=ar.from([],((e,t)=>{const n=t.lastMessageAt??t.createdAt,r=e.lastMessageAt??e.createdAt;return n<r||n===r&&t.id<e.id})),this.signal=new Ot(this)}getEvenIfDeleted(e){return this.signal.get(),this.#e.get(e)}markDeleted(e){const t=this.#e.get(e);t!==void 0&&t.deletedAt===void 0&&this.upsert({...t,deletedAt:new Date().toISOString()})}upsert(e){this.signal.mutate((()=>{const t=this.#e.get(e.id);if(t!==void 0){if(t.deletedAt!==void 0)return!1;this.#t.remove(t),this.#e.delete(t.id)}return e.deletedAt===void 0&&this.#t.add(e),this.#e.set(e.id,e),!0}))}findMany(e){return Array.from(this.#t.filter((t=>{if(e.metadata===void 0)return!0;for(const[n,r]of Object.entries(e.metadata))if(r===null){if(n in t.metadata)return!1}else if(typeof r=="string"){if(t.metadata[n]!==r)return!1}else{const o=t.metadata[n];if(!Array.isArray(o)||!r.every((i=>o.includes(i))))return!1}return!0})))}};function Cu(e){const t=e.editedAt?new Date(e.editedAt):void 0,n=new Date(e.createdAt),r=e.reactions.map((o=>({...o,createdAt:new Date(o.createdAt)})));if(e.body)return{...e,reactions:r,createdAt:n,editedAt:t};{const o=new Date(e.deletedAt);return{...e,reactions:r,createdAt:n,editedAt:t,deletedAt:o}}}function Yn(e){const t=new Date(e.createdAt),n=new Date(e.updatedAt),r=e.comments.map((o=>Cu(o)));return{...e,createdAt:t,updatedAt:n,comments:r}}function wr(e){const t=new Date(e.notifiedAt),n=e.readAt?new Date(e.readAt):null;if("activities"in e){const r=e.activities.map((o=>({...o,createdAt:new Date(o.createdAt)})));return{...e,notifiedAt:t,readAt:n,activities:r}}return{...e,notifiedAt:t,readAt:n}}function Qn(e){const t=new Date(e.createdAt);return{...e,createdAt:t}}function Ea(e){const t=new Date(e.deletedAt);return{...e,deletedAt:t}}function Da(e){const t=new Date(e.deletedAt);return{...e,deletedAt:t}}function Aa(e){const t=new Date(e.deletedAt);return{...e,deletedAt:t}}function cd(e){const t=new Date(e.createdAt),n=new Date(e.updatedAt),r=e.members.map((o=>({...o,addedAt:new Date(o.addedAt)})));return{...e,createdAt:t,updatedAt:n,members:r}}function Ye(e,t){throw new Error(t)}function ye(e,t="Expected value to be non-nullable"){return e}var st=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce(((t,n)=>t+((n&=63)<36?n.toString(36):n<62?(n-26).toString(36).toUpperCase():n<63?"_":"-")),""),ue=Object.freeze({INIT:0,SET_PARENT_KEY:1,CREATE_LIST:2,UPDATE_OBJECT:3,CREATE_OBJECT:4,DELETE_CRDT:5,DELETE_OBJECT_KEY:6,CREATE_MAP:7,CREATE_REGISTER:8,CREATE_TEXT:9,UPDATE_TEXT:10,CREATE_FILE:11});function wu(e){return e.type===ue.CREATE_OBJECT||e.type===ue.CREATE_REGISTER||e.type===ue.CREATE_FILE||e.type===ue.CREATE_MAP||e.type===ue.CREATE_LIST||e.type===ue.CREATE_TEXT}var je=Object.freeze({OBJECT:0,LIST:1,MAP:2,REGISTER:3,TEXT:4,FILE:5});function A1(e){return e[0]==="root"}function _p(e){return e[1].type===je.OBJECT}function Bp(e){return e[1].type===je.LIST}function Fp(e){return e[1].type===je.MAP}function Rp(e){return e[1].type===je.REGISTER}function jp(e){return e[1].type===je.TEXT}function Mp(e){return e[1].type===je.FILE}function x1(e){return e[0]==="root"}function*O1(e){for(const t of e)if(x1(t))yield[t[0],{type:je.OBJECT,data:t[1]}];else switch(t[1]){case je.OBJECT:yield[t[0],{type:je.OBJECT,parentId:t[2],parentKey:t[3],data:t[4]}];break;case je.LIST:yield[t[0],{type:je.LIST,parentId:t[2],parentKey:t[3]}];break;case je.MAP:yield[t[0],{type:je.MAP,parentId:t[2],parentKey:t[3]}];break;case je.REGISTER:yield[t[0],{type:je.REGISTER,parentId:t[2],parentKey:t[3],data:t[4]}];break;case je.TEXT:yield[t[0],{type:je.TEXT,parentId:t[2],parentKey:t[3],data:t[4],version:t[5]}];break;case je.FILE:yield[t[0],{type:je.FILE,parentId:t[2],parentKey:t[3],data:t[4]}]}}var Oe=Symbol(),Xt={};((e,t)=>{for(var n in t)b1(e,n,{get:t[n],enumerable:!0})})(Xt,{error:()=>Vn,errorWithTitle:()=>Up,warn:()=>mt,warnWithTitle:()=>S1});var Pp="background:#0e0d12;border-radius:9999px;color:#fff;padding:3px 7px;font-family:sans-serif;font-weight:600;";function Np(e){return typeof window>"u"?console[e]:(t,...n)=>console[e]("%cLiveblocks",Pp,t,...n)}var mt=Np("warn"),Vn=Np("error");function Lp(e){return typeof window>"u"?console[e]:(t,n,...r)=>console[e](`%cLiveblocks%c ${t}`,Pp,"font-weight:600",n,...r)}var S1=Lp("warn"),Up=Lp("error"),Ut=32,kr=126,ta=Fc(0),so=Fc(1),I1=ta+Fc(-1);function Fc(e){const t=Ut+(e<0?95+e:e);if(t<Ut||t>kr)throw new Error(`Invalid n value: ${e}`);return String.fromCharCode(t)}function yn(e,t){return e!==void 0&&t!==void 0?(function(n,r){if(n<r)return Eu(n,r);if(n>r)return Eu(r,n);throw new Error("Cannot compute value between two equal positions")})(e,t):e!==void 0?(function(n){for(let s=0;s<n.length;s++){const a=n.charCodeAt(s);if(a<Ut||a>kr)return n+so}for(;n.length>1&&n.charCodeAt(n.length-1)===Ut;)n=n.slice(0,-1);if(n.length===0||n===ta)return so;let r=Xi;n.length>Xi&&(r=Xi+Math.ceil((n.length-Xi)/xa)*xa);const o=ld(n,r);if(o!==null)return o;r+=xa;const i=ld(n,r);return i!==null?i:n+so})(e):t!==void 0?(function(n){const r=n.length-1;for(let o=0;o<=r;o++){const i=n.charCodeAt(o);if(!(i<=Ut))return o===r?i===33?n.substring(0,o)+I1:n.substring(0,o)+String.fromCharCode(i-1):n.substring(0,o+1)}return so})(t):so}var Xi=2,xa=3;function ld(e,t){const n=[];for(let i=0;i<t;i++)i<e.length?n.push(e.charCodeAt(i)-Ut):n.push(0);let r=1;for(let i=t-1;i>=0&&r;i--){const s=n[i]+r;s>=95?(n[i]=0,r=1):(n[i]=s,r=0)}if(r)return null;let o="";for(const i of n)o+=String.fromCharCode(i+Ut);for(;o.length>1&&o.charCodeAt(o.length-1)===Ut;)o=o.slice(0,-1);return o}function Eu(e,t){let n=0;const r=e.length,o=t.length;for(;;){const i=n<r?e.charCodeAt(n):Ut,s=n<o?t.charCodeAt(n):kr;if(i!==s){if(s-i==1){const a=n+1;let u=e.substring(0,a);return u.length<a&&(u+=ta.repeat(a-u.length)),u+Eu(e.substring(a),"")}return T1(e,n)+String.fromCharCode(s+i>>1)}n++}}function T1(e,t){return t<e.length?e.substring(0,t):e+ta.repeat(t-e.length)}function Ei(e){return(function(t){if(t==="")return!1;const n=t.length-1,r=t.charCodeAt(n);if(r<33||r>kr)return!1;for(let o=0;o<n;o++){const i=t.charCodeAt(o);if(i<Ut||i>kr)return!1}return!0})(e)?e:(function(t){const n=[];for(let r=0;r<t.length;r++){const o=t.charCodeAt(r);n.push(o<Ut?Ut:o>kr?kr:o)}for(;n.length>0&&n[n.length-1]===Ut;)n.length--;return n.length>0?String.fromCharCode(...n):so})(e)}var qt={origin:"remote"},St={origin:"local",via:"edit"},k1={origin:"local",via:"undo"},_1={origin:"local",via:"redo"};function un(e){return e.origin==="remote"?e:{origin:"local",via:e.via}}var Hp=class{#e=new Map;#t=new Map;#n=new Map;#r=new Set;#o(e,t){return`${e}
3
+ ${t}`}get size(){return this.#e.size}get(e){return this.#e.get(e)}add(e){if(this.#e.set(e.opId,e),wu(e)){const t=this.#o(e.parentId,e.parentKey);let n=this.#t.get(t);n===void 0&&(n=new Map,this.#t.set(t,n)),n.set(e.opId,e);let r=this.#n.get(e.parentId);r===void 0&&(r=new Map,this.#n.set(e.parentId,r)),r.set(e.opId,e)}}delete(e){const t=this.#e.get(e);if(t!==void 0&&(this.#e.delete(e),this.#r.delete(e),wu(t))){const n=this.#o(t.parentId,t.parentKey),r=this.#t.get(n);r?.delete(e),r!==void 0&&r.size===0&&this.#t.delete(n);const o=this.#n.get(t.parentId);o?.delete(e),o!==void 0&&o.size===0&&this.#n.delete(t.parentId)}}getByParentIdAndKey(e,t){return this.#t.get(this.#o(e,t))?.values()??[]}getByParentId(e){return this.#n.get(e)?.values()??[]}values(){return this.#e.values()}isPossiblyStored(e){return this.#r.has(e)}markAllAsPossiblyStored(){for(const e of this.#e.keys())this.#r.add(e)}},dd=new WeakSet;function Vp(e){const{getCurrentConnectionId:t,onDispatch:n,isStorageWritable:r=()=>!0,unacknowledgedOps:o=new Hp}=e;let i=0,s=0;const a=new Map;return{nodes:a,getNode:u=>a.get(u),addNode:(u,c)=>{a.set(u,c)},deleteNode:u=>{a.delete(u)},generateId:()=>`${t()}:${i++}`,generateOpId:()=>`${t()}:${s++}`,dispatch(u,c,f,l){n?.(u,c,f,l)},assertStorageIsWritable:()=>{if(!r())throw new Error("Cannot write to storage with a read only user, please ensure the user has write permissions")},unacknowledgedOps:o}}function fd(e,t,n=Ei(t)){return Object.freeze({type:"HasParent",node:e,key:t,pos:n})}var hd=Object.freeze({type:"NoParent"}),Lo=class{#e;#t;#n=hd;constructor(){Object.defineProperty(this,Oe,{value:{getId:()=>this.#t},enumerable:!1})}_getParentKeyOrThrow(){switch(this.parent.type){case"HasParent":return this.parent.key;case"NoParent":throw new Error("Parent key is missing");case"Orphaned":return this.parent.oldKey;default:return Ye(this.parent,"Unknown state")}}get _parentPos(){switch(this.parent.type){case"HasParent":return this.parent.pos;case"NoParent":throw new Error("Parent key is missing");case"Orphaned":return this.parent.oldPos;default:return Ye(this.parent,"Unknown state")}}get _pool(){return this.#e}get _id(){return this.#t}get parent(){return this.#n}_warnIfOrphaned(){const e=this;this.parent.type!=="Orphaned"||dd.has(e)||(dd.add(e),mt("Cannot sync changes made to this Live structure because it is no longer part of Storage. Retrieve the current value from its parent before mutating it.",{type:e.constructor.name,formerParentKey:this.parent.oldKey}))}get _parentKey(){switch(this.parent.type){case"HasParent":return this.parent.key;case"NoParent":return null;case"Orphaned":return this.parent.oldKey;default:return Ye(this.parent,"Unknown state")}}_apply(e,t){return e.type===ue.DELETE_CRDT&&this.parent.type==="HasParent"?this.parent.node._detachChild(this,un(t)):{modified:!1}}_setParentLink(e,t){switch(this.parent.type){case"HasParent":if(this.parent.node!==e)throw new Error("Cannot set parent: node already has a parent");return void(this.#n=fd(e,t));case"Orphaned":case"NoParent":return void(this.#n=fd(e,t));default:return Ye(this.parent,"Unknown state")}}_attach(e,t){if(this.#t||this.#e)throw new Error("Cannot attach node: already attached");t.addNode(e,this),this.#t=e,this.#e=t}_detach(){switch(this.#e&&this.#t&&this.#e.deleteNode(this.#t),this.parent.type){case"HasParent":this.#n=(function(e,t=Ei(e)){return Object.freeze({type:"Orphaned",oldKey:e,oldPos:t})})(this.parent.key,this.parent.pos);break;case"NoParent":this.#n=hd;break;case"Orphaned":break;default:Ye(this.parent,"Unknown state")}this.#e=void 0}_toOpsWithOpId(e,t,n){return this._toOps(e,t).map((r=>({opId:n.generateOpId(),...r})))}#r;#o;#i;invalidate(){this.#r===void 0&&this.#i===void 0||(this.#r=void 0,this.#i=void 0,this.parent.type==="HasParent"&&this.parent.node.invalidate())}toTreeNode(e){return this.#i!==void 0&&this.#o===e||(this.#o=e,this.#i=this._toTreeNode(e)),this.#i}hasCache(e){return this.#r!==void 0&&this.#r===e}toJSON(){return this.#r===void 0&&(this.#r=this._toJSON()),this.#r}};function B1(e){return typeof e=="string"?e:e.id}var vr=class Du extends Lo{#e;constructor(t){super(),this.#e=Object.freeze({...t})}get data(){return this.#e}get id(){return this.#e.id}get name(){return this.#e.name}get size(){return this.#e.size}get mimeType(){return this.#e.mimeType}static _deserialize([t,n],r,o){const i=new Du(n.data);return i._attach(t,o),i}_toOps(t,n){if(this._id===void 0)throw new Error("Cannot serialize LiveFile if parent is missing");return[{type:ue.CREATE_FILE,id:this._id,parentId:t,parentKey:n,data:this.#e}]}_serialize(){if(this.parent.type!=="HasParent")throw new Error("Cannot serialize LiveFile if parent is missing");return{type:je.FILE,parentId:ye(this.parent.node._id,"Parent node expected to have ID"),parentKey:this.parent.key,data:this.#e}}_attachChild(t){throw new Error("A LiveFile node cannot have children")}_detachChild(t){throw new Error("A LiveFile node cannot have children")}_apply(t,n){return super._apply(t,n)}_toTreeNode(t){return{type:"LiveFile",id:this._id??st(),key:t,payload:this.#e}}_toJSON(){return this.#e}clone(){return new Du(this.#e)}};function F1(e){return e!=null}function gt(e){return e!==null&&typeof e=="object"&&Object.prototype.toString.call(e)==="[object Object]"}function Au(e){return gt(e)&&typeof e.startsWith=="string"}function xu(e){return gt(e)&&(typeof e.lt=="number"||typeof e.gt=="number"||typeof e.lte=="number"||typeof e.gte=="number")}var Uo=class $p extends Error{response;details;constructor(t,n,r){super(t),this.name="HttpError",this.response=n,this.details=r}static async fromResponse(t){let n;try{n=await t.text()}catch{}const r=n?Hn(n):void 0;let o;gt(r)&&(o=r);let i,s="";s||=typeof o?.message=="string"?o.message:"",s||=typeof o?.error=="string"?o.error:"",r===void 0&&(s||=n||""),s||=t.statusText;try{i=new URL(t.url).pathname}catch{}return s+=i!==void 0?` (got status ${t.status} from ${i})`:` (got status ${t.status})`,new $p(s,t,o)}get status(){return this.response.status}},R1=e=>e instanceof Uo&&e.status>=400&&e.status<500;async function po(e,t,n,r=R1){const o=n.length>0?n[n.length-1]:0;let i=0;for(;;){i++;try{return await e()}catch(a){if(r(a))throw a;if(i>=t)throw new Error(`Failed after ${t} attempts: ${String(a)}`)}const s=n[i-1]??o;mt(`Attempt ${i} was unsuccessful. Retrying in ${s} milliseconds.`),await C1(s)}}function Wp(){let e,t;return[new Promise(((n,r)=>{e=n,t=r})),e,t]}function mo(){const[e,t,n]=Wp();return{promise:e,resolve:t,reject:n}}function j1(e,t){return t===null||typeof t!="object"||Array.isArray(t)?t:Object.keys(t).sort().reduce(((n,r)=>(n[r]=t[r],n)),{})}function Yt(e){return JSON.stringify(e,j1)}function Pr(e){try{return JSON.stringify(e)}catch(t){throw console.error(`Could not stringify: ${t.message}`),console.error(e),t}}var M1=class{input;resolve;reject;promise;constructor(e){this.input=e;const{promise:t,resolve:n,reject:r}=mo();this.promise=t,this.resolve=n,this.reject=r}},sr=class{#e=[];#t;#n;#r;#o;error=!1;constructor(e,t){this.#t=e,this.#n=t.size??50,this.#r=t.delay}#i(){this.#o!==void 0&&(clearTimeout(this.#o),this.#o=void 0)}#s(){this.#e.length===this.#n?this.#u():this.#e.length===1&&(this.#i(),this.#o=setTimeout((()=>{this.#u()}),this.#r))}async#u(){if(this.#e.length===0)return;const e=this.#e.splice(0),t=e.map((n=>n.input));try{const n=await this.#t(t);this.error=!1,e.forEach(((r,o)=>{const i=n?.[o];Array.isArray(n)?e.length!==n.length?r.reject(new Error(`Callback must return an array of the same length as the number of provided items. Expected ${e.length}, but got ${n.length}.`)):i instanceof Error?r.reject(i):r.resolve(i):r.reject(new Error("Callback must return an array."))}))}catch(n){this.error=!0,e.forEach((r=>{r.reject(n)}))}}get(e){const t=this.#e.find((r=>Yt(r.input)===Yt(e)));if(t)return t.promise;const n=new M1(e);return this.#e.push(n),this.#s(),n.promise}clear(){this.#e=[],this.error=!1,this.#i()}};function yo(e,t){const n=new Ot(new Map),r=new Map,o=new Map;function i(f){return Yt(f)}function s(f){n.mutate((l=>{if(Array.isArray(f))for(const d of f)l.set(d.key,d.state);else l.set(f.key,f.state)}))}function a(f){const l=r.get(f);l!==void 0&&(clearTimeout(l),r.delete(f))}function u(f,l){const d=i(f);if(a(d),l===void 0||!Number.isFinite(l))return;const h=setTimeout((()=>{r.delete(d),c([f])}),Math.max(0,l-Date.now()));r.set(d,h)}function c(f){if(Array.isArray(f))for(const l of f){const d=i(l);a(d),o.delete(d)}else{for(const l of r.values())clearTimeout(l);r.clear(),o.clear()}n.mutate((l=>{if(Array.isArray(f))for(const d of f)l.delete(i(d));else l.clear()}))}return{subscribe:n.subscribe,enqueue:function(f){const l=i(f),d=o.get(l);if(d!==void 0)return d.promise;if(n.get().has(l))return Promise.resolve();const h=e.get(f),g=Symbol(),y=(async function(p,w,b,C){try{const E=await b;if(o.get(w)?.id!==C)return;s({key:w,state:{isLoading:!1,data:E}}),u(p,t?.getCacheExpiry?.(E))}catch(E){if(o.get(w)?.id!==C)return;u(p,t?.getErrorCacheExpiry?.(E)),s({key:w,state:{isLoading:!1,error:E}})}finally{o.get(w)?.id===C&&o.delete(w)}})(f,l,h,g);return o.set(l,{id:g,promise:y}),s({key:l,state:{isLoading:!0}}),y},setData:function(f){s(f.map((l=>({key:i(l[0]),state:{isLoading:!1,data:l[1]}}))));for(const[l,d]of f)u(l,t?.getCacheExpiry?.(d))},getItemState:function(f){const l=i(f);return n.get().get(l)},getData:function(f){const l=i(f);return n.get().get(l)?.data},waitUntilItemCacheExpires:function(f){const l=i(f);if(!r.has(l))return;const d=n.get().get(l);return new Promise((h=>{const g=n.subscribe((()=>{n.get().get(l)!==d&&(g(),h())}))}))},invalidate:c,batch:e,_cacheKeys:function(){return[...n.get().keys()]}}}function na(e){return`${e}_${st()}`}function zp(){return na("th")}function js(){return na("cm")}function Kp(){return na("at")}var He=class extends Map{#e;constructor(e,t){super(t),this.#e=e}getOrCreate(e,t){if(super.has(e))return super.get(e);{const n=(t??this.#e??hn("DefaultMap used without a factory function"))(e);return this.set(e,n),n}}},P1=/^[a-zA-Z_][a-zA-Z0-9_]*$/;function Zr(e){let t=[];const n=Object.entries(e),r=[],o=[],i=[];return n.forEach((([s,a])=>{if(!P1.test(s))throw new Error("Key must only contain letters, numbers, _");gd(a)?r.push([s,a]):gt(a)&&(Au(a)||xu(a)?o.push([s,a]):i.push([s,a]))})),t=[...pd(r),...md(o)],i.forEach((([s,a])=>{const u=Object.entries(a),c=[],f=[];u.forEach((([l,d])=>{if(N1(l))throw new Error("Key cannot be empty");gd(d)?c.push([vd(s,l),d]):(Au(d)||xu(d))&&f.push([vd(s,l),d])})),t=[...t,...pd(c),...md(f)]})),t.map((({key:s,operator:a,value:u})=>`${s}${a}${qp(u)}`)).join(" ")}var pd=e=>{const t=[];return e.forEach((([n,r])=>{t.push({key:n,operator:":",value:r})})),t},md=e=>{const t=[];return e.forEach((([n,r])=>{"startsWith"in r&&typeof r.startsWith=="string"&&t.push({key:n,operator:"^",value:r.startsWith}),"lt"in r&&typeof r.lt=="number"&&t.push({key:n,operator:"<",value:r.lt}),"gt"in r&&typeof r.gt=="number"&&t.push({key:n,operator:">",value:r.gt}),"gte"in r&&typeof r.gte=="number"&&t.push({key:n,operator:">=",value:r.gte}),"lte"in r&&typeof r.lte=="number"&&t.push({key:n,operator:"<=",value:r.lte})})),t},gd=e=>typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null,vd=(e,t)=>t?`${e}[${qp(t)}]`:e,N1=e=>!e||e.toString().trim()==="";function qp(e){const t=JSON.stringify(e);return typeof e!="string"||t.includes("'")?t:`'${t.slice(1,-1).replace(/\\"/g,'"')}'`}var L1=/^[a-zA-Z][a-zA-Z\d+\-.]*?:/,U1=/\/(?:(?:\?|#).*)?$/;function H1(e,t,n){const r=new URL(t,e);return n!==void 0&&(r.search=(n instanceof URLSearchParams?n:(function(o){const i=new URLSearchParams;for(const[s,a]of Object.entries(o))a!=null&&i.set(s,a.toString());return i})(n)).toString()),r.toString()}function De(e,...t){return e.reduce(((n,r,o)=>n+encodeURIComponent(t[o-1]??"")+r))}function Gp(e){if(e.startsWith("www.")&&(e="https://"+e),e==="#")return e;try{const t=L1.test(e),n=new URL(e,t?void 0:"https://localhost:9999");if(n.protocol!=="http:"&&n.protocol!=="https:")return null;const r=U1.test(e),o=(t?n.origin:"")+(n.pathname==="/"?r?"/":"":r&&!n.pathname.endsWith("/")?n.pathname+"/":n.pathname)+n.search+n.hash;return o!==""?o:null}catch{return null}}var yd=5242880,Yi=[2e3,2e3,2e3,2e3,2e3,2e3,2e3,2e3,2e3,2e3],bd=class extends Error{};async function Cd({file:e,signal:t,abortErrorMessage:n,retryMultipartCompletion:r,uploadSingle:o,createMultipartUpload:i,uploadMultipartPart:s,completeMultipartUpload:a,abortMultipartUpload:u}){const c=(function(b){if(typeof DOMException=="function")return new DOMException(b,"AbortError");const C=new Error(b);return C.name="AbortError",C})(n);if(t?.aborted)throw c;const f=b=>{if(t?.aborted)throw c;return b instanceof Uo&&b.status>=400&&b.status<500};if(e.size<=yd)return po(o,10,Yi,f);let l;const d=[],h=await po(i,10,Yi,f),g=new AbortController,y=g.signal,p=b=>{g.abort(b)},w=()=>p();t?.aborted?w():t?.addEventListener("abort",w,{once:!0});try{if(l=h.uploadId,t?.aborted)throw c;const b=(function(E,A){const x=[];for(let I=0,T=E.length;I<T;I+=A)x.push(E.slice(I,I+A));return x})((function(E){const A=[];let x=0;for(;x<E.size;){const I=Math.min(x+yd,E.size);A.push({partNumber:A.length+1,part:E.slice(x,I)}),x=I}return A})(e),5);for(const E of b){const A={},x=[];for(const{part:T,partNumber:B}of E)x.push(po((()=>s(h.uploadId,B,T,y)),10,Yi,(S=>{if(t?.aborted)throw c;return y.aborted||f(S)})).catch((S=>{throw A.value===void 0&&(A.value={error:S},p(S)),S})));const I=await Promise.allSettled(x);if(A.value!==void 0)throw A.value.error;for(const T of I)T.status==="fulfilled"&&d.push(T.value)}if(t?.aborted)throw c;const C=d.sort(((E,A)=>E.partNumber-A.partNumber));return r?po((()=>a(h.uploadId,C)),10,Yi,f):a(l,C)}catch(b){if(l)try{await u(l)}catch{}throw b}finally{t?.removeEventListener("abort",w)}}function Kt(e){return e==="private"?"comments:private":e==="public"?"comments:public":"comments"}function V1({baseUrl:e,authManager:t,fetchPolyfill:n}){const r=new $1(e,n),o=new He((d=>yo(new sr((async h=>{const g=h.flat(),{urls:y}=await r.post(De`/v2/c/rooms/${d}/attachments/presigned-urls`,await t.getAuthValue({roomId:d,resource:"comments",access:"read"}),{attachmentIds:g});return y.map((p=>p??new Error("There was an error while getting this attachment's URL")))}),{delay:50}))));function i(d){return o.getOrCreate(d)}const s=new He((d=>{const h=new Map,g=new sr((async y=>{const p=y.flat(),{urls:w,expiresAt:b}=await r.post(De`/v2/c/rooms/${d}/storage/files/presigned-urls`,await t.getAuthValue({roomId:d,resource:"storage",access:"read"}),{fileIds:p}),C=Date.parse(b);return w.map(((E,A)=>{const x=p[A];return E===!1?(I=>{const T=h.get(I);T!==void 0&&clearTimeout(T.cleanupTimeoutId);const B=(T?.count??0)+1;return B>=3?(h.delete(I),!1):(h.set(I,{count:B,cleanupTimeoutId:setTimeout((()=>h.delete(I)),3e4)}),!0)})(x)?new bd("There was an error while getting this file's URL"):new Error("There was an error while getting this file's URL"):((I=>{const T=h.get(I);T!==void 0&&(clearTimeout(T.cleanupTimeoutId),h.delete(I))})(x),E!==null?{url:E,expiresAt:C}:new Error("There was an error while getting this file's URL"))}))}),{delay:50});return yo(g,{getCacheExpiry:({expiresAt:y})=>y-3e4,getErrorCacheExpiry:y=>y instanceof bd?Date.now()+1e3:void 0})}));function a(d){return s.getOrCreate(d)}const u=new He((d=>new sr((async h=>{const g=h.flat();return await r.post(De`/v2/c/rooms/${d}/inbox-notifications/read`,await t.getAuthValue({roomId:d,resource:"comments",access:"read"}),{inboxNotificationIds:g}),g}),{delay:50}))),c=new sr((async d=>{const h=d.flat();return await(async function(g){await r.post(De`/v2/c/inbox-notifications/read`,await t.getAuthValue({resource:"personal",access:"write"}),{inboxNotificationIds:g})})(h),h}),{delay:50}),f=new sr((async d=>{const h=d.flat(),{groups:g}=await r.post(De`/v2/c/groups/find`,await t.getAuthValue({resource:"personal",access:"write"}),{groupIds:h}),y=new Map;for(const p of g)y.set(p.id,cd(p));return h.map((p=>y.get(p)))}),{delay:50}),l=yo(f);return{getThreads:async function(d){let h;d.query&&(h=Zr(d.query));try{const g=await r.get(De`/v2/c/rooms/${d.roomId}/threads`,await t.getAuthValue({roomId:d.roomId,resource:Kt(d.query?.visibility),access:"read"}),{cursor:d.cursor,query:h,limit:50});return{threads:g.data.map(Yn),inboxNotifications:g.inboxNotifications.map(wr),subscriptions:g.subscriptions.map(Qn),nextCursor:g.meta.nextCursor,requestedAt:new Date(g.meta.requestedAt),permissionHints:g.meta.permissionHints}}catch(g){if(g instanceof Uo&&g.status===404)return{threads:[],inboxNotifications:[],subscriptions:[],nextCursor:null,requestedAt:new Date(Date.now()-216e5),permissionHints:{}};throw g}},getThreadsSince:async function(d){const h=await r.get(De`/v2/c/rooms/${d.roomId}/threads/delta`,await t.getAuthValue({roomId:d.roomId,resource:"comments",access:"read"}),{since:d.since.toISOString()},{signal:d.signal});return{threads:{updated:h.data.map(Yn),deleted:h.deletedThreads.map(Ea)},inboxNotifications:{updated:h.inboxNotifications.map(wr),deleted:h.deletedInboxNotifications.map(Da)},subscriptions:{updated:h.subscriptions.map(Qn),deleted:h.deletedSubscriptions.map(Aa)},requestedAt:new Date(h.meta.requestedAt),permissionHints:h.meta.permissionHints}},searchComments:async function(d,h){return await r.get(De`/v2/c/rooms/${d.roomId}/threads/comments/search`,await t.getAuthValue({roomId:d.roomId,resource:"comments",access:"read"}),{text:d.query.text,query:Zr({threadMetadata:d.query.threadMetadata,threadResolved:d.query.threadResolved,hasAttachments:d.query.hasAttachments,hasMentions:d.query.hasMentions})},{signal:h?.signal})},createThread:async function(d){const h=d.commentId??js(),g=d.threadId??zp();return Yn(await r.post(De`/v2/c/rooms/${d.roomId}/threads`,await t.getAuthValue({roomId:d.roomId,resource:Kt(d.visibility??"public"),access:"write"}),{id:g,visibility:d.visibility,comment:{id:h,body:d.body,metadata:d.commentMetadata,attachmentIds:d.attachmentIds},metadata:d.metadata}))},getThread:async function(d){const h=await r.rawGet(De`/v2/c/rooms/${d.roomId}/thread-with-notification/${d.threadId}`,await t.getAuthValue({roomId:d.roomId,resource:"comments",access:"read"}));if(h.ok){const g=await h.json();return{thread:Yn(g.thread),inboxNotification:g.inboxNotification?wr(g.inboxNotification):void 0,subscription:g.subscription?Qn(g.subscription):void 0}}if(h.status===404)return{thread:void 0,inboxNotification:void 0,subscription:void 0};throw new Error(`There was an error while getting thread ${d.threadId}.`)},deleteThread:async function(d){await r.delete(De`/v2/c/rooms/${d.roomId}/threads/${d.threadId}`,await t.getAuthValue({roomId:d.roomId,resource:Kt(d.visibility),access:"write"}))},editThreadMetadata:async function(d){return await r.post(De`/v2/c/rooms/${d.roomId}/threads/${d.threadId}/metadata`,await t.getAuthValue({roomId:d.roomId,resource:Kt(d.visibility),access:"write"}),d.metadata)},createComment:async function(d){const h=d.commentId??js();return Cu(await r.post(De`/v2/c/rooms/${d.roomId}/threads/${d.threadId}/comments`,await t.getAuthValue({roomId:d.roomId,resource:Kt(d.visibility),access:"write"}),{id:h,body:d.body,metadata:d.metadata,attachmentIds:d.attachmentIds}))},editComment:async function(d){return Cu(await r.post(De`/v2/c/rooms/${d.roomId}/threads/${d.threadId}/comments/${d.commentId}`,await t.getAuthValue({roomId:d.roomId,resource:Kt(d.visibility),access:"write"}),{body:d.body,attachmentIds:d.attachmentIds,metadata:d.metadata}))},editCommentMetadata:async function(d){return await r.post(De`/v2/c/rooms/${d.roomId}/threads/${d.threadId}/comments/${d.commentId}/metadata`,await t.getAuthValue({roomId:d.roomId,resource:Kt(d.visibility),access:"write"}),d.metadata)},deleteComment:async function(d){await r.delete(De`/v2/c/rooms/${d.roomId}/threads/${d.threadId}/comments/${d.commentId}`,await t.getAuthValue({roomId:d.roomId,resource:Kt(d.visibility),access:"write"}))},addReaction:async function(d){return g=await r.post(De`/v2/c/rooms/${d.roomId}/threads/${d.threadId}/comments/${d.commentId}/reactions`,await t.getAuthValue({roomId:d.roomId,resource:Kt(d.visibility),access:"write"}),{emoji:d.emoji}),{...g,createdAt:new Date(g.createdAt)};var g},removeReaction:async function(d){await r.delete(De`/v2/c/rooms/${d.roomId}/threads/${d.threadId}/comments/${d.commentId}/reactions/${d.emoji}`,await t.getAuthValue({roomId:d.roomId,resource:Kt(d.visibility),access:"write"}))},markThreadAsResolved:async function(d){await r.post(De`/v2/c/rooms/${d.roomId}/threads/${d.threadId}/mark-as-resolved`,await t.getAuthValue({roomId:d.roomId,resource:Kt(d.visibility),access:"write"}))},markThreadAsUnresolved:async function(d){await r.post(De`/v2/c/rooms/${d.roomId}/threads/${d.threadId}/mark-as-unresolved`,await t.getAuthValue({roomId:d.roomId,resource:Kt(d.visibility),access:"write"}))},subscribeToThread:async function(d){return Qn(await r.post(De`/v2/c/rooms/${d.roomId}/threads/${d.threadId}/subscribe`,await t.getAuthValue({roomId:d.roomId,resource:"comments",access:"read"})))},unsubscribeFromThread:async function(d){await r.post(De`/v2/c/rooms/${d.roomId}/threads/${d.threadId}/unsubscribe`,await t.getAuthValue({roomId:d.roomId,resource:"comments",access:"read"}))},markRoomInboxNotificationAsRead:async function(d){return u.getOrCreate(d.roomId).get(d.inboxNotificationId)},getSubscriptionSettings:async function(d){return r.get(De`/v2/c/rooms/${d.roomId}/subscription-settings`,await t.getAuthValue({roomId:d.roomId,resource:"comments",access:"read"}),void 0,{signal:d.signal})},updateSubscriptionSettings:async function(d){return r.post(De`/v2/c/rooms/${d.roomId}/subscription-settings`,await t.getAuthValue({roomId:d.roomId,resource:"comments",access:"read"}),d.settings)},createTextMention:async function(d){if(d.mention.kind!=="user"&&d.mention.kind!=="group")return Ye(d.mention,"Unexpected mention kind");await r.rawPost(De`/v2/c/rooms/${d.roomId}/text-mentions`,await t.getAuthValue({roomId:d.roomId,resource:"storage",access:"write"}),{userId:d.mention.kind==="user"?d.mention.id:void 0,groupId:d.mention.kind==="group"?d.mention.id:void 0,userIds:d.mention.kind==="group"?d.mention.userIds:void 0,mentionId:d.mentionId})},deleteTextMention:async function(d){await r.rawDelete(De`/v2/c/rooms/${d.roomId}/text-mentions/${d.mentionId}`,await t.getAuthValue({roomId:d.roomId,resource:"storage",access:"write"}))},fetchStorageHistoryVersion:async function(d){return r.rawGet(De`/v2/c/rooms/${d.roomId}/versions/${d.versionId}/storage`,await t.getAuthValue({roomId:d.roomId,resource:"storage",access:"read"}))},fetchYjsHistoryVersion:async function(d){return r.rawGet(De`/v2/c/rooms/${d.roomId}/versions/${d.versionId}/yjs`,await t.getAuthValue({roomId:d.roomId,resource:"storage",access:"read"}))},createVersionHistorySnapshot:async function(d){await r.rawPost(De`/v2/c/rooms/${d.roomId}/versions`,await t.getAuthValue({roomId:d.roomId,resource:"storage",access:"write"}))},deleteHistoryVersion:async function(d){await r.delete(De`/v2/c/rooms/${d.roomId}/versions/${d.versionId}`,await t.getAuthValue({roomId:d.roomId,resource:"storage",access:"write"}))},reportTextEditor:async function(d){await r.rawPost(De`/v2/c/rooms/${d.roomId}/text-metadata`,await t.getAuthValue({roomId:d.roomId,resource:"storage",access:"read"}),{type:d.type,rootKey:d.rootKey})},listHistoryVersions:async function(d){const h=await r.get(De`/v2/c/rooms/${d.roomId}/versions`,await t.getAuthValue({roomId:d.roomId,resource:"storage",access:"read"}));return{versions:h.versions.map((({createdAt:g,...y})=>({createdAt:new Date(g),...y}))),requestedAt:new Date(h.meta.requestedAt)}},listHistoryVersionsSince:async function(d){const h=await r.get(De`/v2/c/rooms/${d.roomId}/versions/delta`,await t.getAuthValue({roomId:d.roomId,resource:"storage",access:"read"}),{since:d.since.toISOString()},{signal:d.signal});return{versions:h.versions.map((({createdAt:g,...y})=>({createdAt:new Date(g),...y}))),requestedAt:new Date(h.meta.requestedAt)}},getAttachmentUrl:function(d){return i(d.roomId).batch.get(d.attachmentId)},uploadAttachment:async function(d){const h=d.roomId,g=d.attachment;return Cd({file:g.file,signal:d.signal,abortErrorMessage:`Upload of attachment ${g.id} was aborted.`,retryMultipartCompletion:!1,uploadSingle:async()=>r.putBlob(De`/v2/c/rooms/${h}/attachments/${g.id}/upload/${g.name}`,await t.getAuthValue({roomId:h,resource:"comments",access:"write"}),g.file,{fileSize:g.size},{signal:d.signal}),createMultipartUpload:async()=>r.post(De`/v2/c/rooms/${h}/attachments/${g.id}/multipart/${g.name}`,await t.getAuthValue({roomId:h,resource:"comments",access:"write"}),void 0,{signal:d.signal},{fileSize:g.size}),uploadMultipartPart:async(y,p,w,b)=>r.putBlob(De`/v2/c/rooms/${h}/attachments/${g.id}/multipart/${y}/${String(p)}`,await t.getAuthValue({roomId:h,resource:"comments",access:"write"}),w,void 0,{signal:b}),completeMultipartUpload:async(y,p)=>r.post(De`/v2/c/rooms/${h}/attachments/${g.id}/multipart/${y}/complete`,await t.getAuthValue({roomId:h,resource:"comments",access:"write"}),{parts:p},{signal:d.signal}),abortMultipartUpload:async y=>{await r.rawDelete(De`/v2/c/rooms/${h}/attachments/${g.id}/multipart/${y}`,await t.getAuthValue({roomId:h,resource:"comments",access:"write"}))}})},getOrCreateAttachmentUrlsStore:i,getFileUrl:async function(d){return(await a(d.roomId).batch.get(d.fileId)).url},uploadFile:async function(d){const h=d.roomId,g=d.file,y=na("fl"),p=await Cd({file:g,signal:d.signal,abortErrorMessage:`Upload of file ${y} was aborted.`,retryMultipartCompletion:!0,uploadSingle:async()=>r.putBlob(De`/v2/c/rooms/${h}/storage/files/${y}/upload/${g.name}`,await t.getAuthValue({roomId:h,resource:"storage",access:"write"}),g,{fileSize:g.size},{signal:d.signal}),createMultipartUpload:async()=>r.post(De`/v2/c/rooms/${h}/storage/files/${y}/multipart/${g.name}`,await t.getAuthValue({roomId:h,resource:"storage",access:"write"}),void 0,{signal:d.signal},{fileSize:g.size}),uploadMultipartPart:async(w,b,C,E)=>r.putBlob(De`/v2/c/rooms/${h}/storage/files/${y}/multipart/${w}/${String(b)}`,await t.getAuthValue({roomId:h,resource:"storage",access:"write"}),C,void 0,{signal:E}),completeMultipartUpload:async(w,b)=>r.post(De`/v2/c/rooms/${h}/storage/files/${y}/multipart/${w}/complete`,await t.getAuthValue({roomId:h,resource:"storage",access:"write"}),{parts:b},{signal:d.signal}),abortMultipartUpload:async w=>{await r.rawDelete(De`/v2/c/rooms/${h}/storage/files/${y}/multipart/${w}`,await t.getAuthValue({roomId:h,resource:"storage",access:"write"}))}});return new vr(p)},getOrCreateFileUrlsStore:a,streamStorage:async function(d){return await(await r.rawGet(De`/v2/c/rooms/${d.roomId}/storage`,await t.getAuthValue({roomId:d.roomId,resource:"storage",access:"read"}))).json()},getInboxNotifications:async function(d){let h;d?.query&&(h=Zr(d.query));const g=await r.get(De`/v2/c/inbox-notifications`,await t.getAuthValue({resource:"personal",access:"write"}),{cursor:d?.cursor,limit:50,query:h}),y=g.groups.map(cd);return l.setData(y.map((p=>[p.id,p]))),{inboxNotifications:g.inboxNotifications.map(wr),threads:g.threads.map(Yn),subscriptions:g.subscriptions.map(Qn),nextCursor:g.meta.nextCursor,requestedAt:new Date(g.meta.requestedAt)}},getInboxNotificationsSince:async function(d){let h;d?.query&&(h=Zr(d.query));const g=await r.get(De`/v2/c/inbox-notifications/delta`,await t.getAuthValue({resource:"personal",access:"write"}),{since:d.since.toISOString(),query:h},{signal:d.signal});return{inboxNotifications:{updated:g.inboxNotifications.map(wr),deleted:g.deletedInboxNotifications.map(Da)},threads:{updated:g.threads.map(Yn),deleted:g.deletedThreads.map(Ea)},subscriptions:{updated:g.subscriptions.map(Qn),deleted:g.deletedSubscriptions.map(Aa)},requestedAt:new Date(g.meta.requestedAt)}},getUnreadInboxNotificationsCount:async function(d){let h;d?.query&&(h=Zr(d.query));const{count:g}=await r.get(De`/v2/c/inbox-notifications/count`,await t.getAuthValue({resource:"personal",access:"write"}),{query:h},{signal:d?.signal});return g},markAllInboxNotificationsAsRead:async function(){await r.post(De`/v2/c/inbox-notifications/read`,await t.getAuthValue({resource:"personal",access:"write"}),{inboxNotificationIds:"all"})},markInboxNotificationAsRead:async function(d){await c.get(d)},deleteAllInboxNotifications:async function(){await r.delete(De`/v2/c/inbox-notifications`,await t.getAuthValue({resource:"personal",access:"write"}))},deleteInboxNotification:async function(d){await r.delete(De`/v2/c/inbox-notifications/${d}`,await t.getAuthValue({resource:"personal",access:"write"}))},getNotificationSettings:async function(d){return r.get(De`/v2/c/notification-settings`,await t.getAuthValue({resource:"personal",access:"write"}),void 0,{signal:d?.signal})},updateNotificationSettings:async function(d){return r.post(De`/v2/c/notification-settings`,await t.getAuthValue({resource:"personal",access:"write"}),d)},getUserThreads_experimental:async function(d){let h;d?.query&&(h=Zr(d.query));const g=await r.get(De`/v2/c/threads`,await t.getAuthValue({resource:"personal",access:"write"}),{cursor:d?.cursor,query:h,limit:50});return{threads:g.threads.map(Yn),inboxNotifications:g.inboxNotifications.map(wr),subscriptions:g.subscriptions.map(Qn),nextCursor:g.meta.nextCursor,requestedAt:new Date(g.meta.requestedAt),permissionHints:g.meta.permissionHints}},getUserThreadsSince_experimental:async function(d){const h=await r.get(De`/v2/c/threads/delta`,await t.getAuthValue({resource:"personal",access:"write"}),{since:d.since.toISOString()},{signal:d.signal});return{threads:{updated:h.threads.map(Yn),deleted:h.deletedThreads.map(Ea)},inboxNotifications:{updated:h.inboxNotifications.map(wr),deleted:h.deletedInboxNotifications.map(Da)},subscriptions:{updated:h.subscriptions.map(Qn),deleted:h.deletedSubscriptions.map(Aa)},requestedAt:new Date(h.meta.requestedAt),permissionHints:h.meta.permissionHints}},groupsStore:l,getGroup:function(d){return f.get(d)},executeContextualPrompt:async function(d){const h=await r.post(De`/v2/c/rooms/${d.roomId}/ai/contextual-prompt`,await t.getAuthValue({roomId:d.roomId,resource:"storage",access:"read"}),{prompt:d.prompt,context:{beforeSelection:d.context.beforeSelection,selection:d.context.selection,afterSelection:d.context.afterSelection},previous:d.previous},{signal:d.signal});if(!h||h.content.length===0)throw new Error("No content returned from server");return h.content[0].text},getUrlMetadata:async function(d){const{metadata:h}=await r.get(De`/v2/c/urls/metadata`,await t.getAuthValue({resource:"personal",access:"write"}),{url:d});return h}}}function Rc(e){return e.type==="public"?e.publicApiKey:e.token.raw}var $1=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}async#n(e,t,n,r){e.startsWith("/v2/c/")||hn("This client can only be used to make /v2/c/* requests");const o=H1(this.#e,e,r),i=await this.#t(o,{...n,headers:{"Content-Type":"application/json; charset=utf-8",...n?.headers,Authorization:`Bearer ${Rc(t)}`,"X-LB-Client":ea}}),s=i.headers.get("X-LB-Warn");if(s){const a=`${s} (${n?.method?.toUpperCase()??"GET"} ${e})`;i.ok?mt(a):Vn(a)}return i}async#r(e,t,n,r){const o=await this.#n(e,t,n,r);if(!o.ok)throw await Uo.fromResponse(o);let i;try{i=await o.json()}catch{i={}}return i}async rawGet(e,t,n,r){return await this.#n(e,t,r,n)}async rawPost(e,t,n){return await this.#n(e,t,{method:"POST",body:Pr(n)})}async rawDelete(e,t){return await this.#n(e,t,{method:"DELETE"})}async get(e,t,n,r){return await this.#r(e,t,r,n)}async post(e,t,n,r,o){return await this.#r(e,t,{...r,method:"POST",body:Pr(n)},o)}async delete(e,t){return await this.#r(e,t,{method:"DELETE"})}async putBlob(e,t,n,r,o){return await this.#r(e,t,{...o,method:"PUT",headers:{"Content-Type":"application/octet-stream"},body:n},r)}},_r=Symbol("fsm.ignore"),W1=class{#e;constructor(e){this.#e=e}get current(){return this.#e}allowPatching(e){const t=this;let n=!0;e({...this.#e,patch(r){if(!n)throw new Error("Can no longer patch stale context");t.#e=Object.assign({},t.#e,r);for(const o of Object.entries(r)){const[i,s]=o;i!=="patch"&&(this[i]=s)}}}),n=!1}},z1=1,Jp=class{id;#e;#t;#n;#r;#o;#i;events;#s;#u;#a;#c;get#f(){const e=this.#n.values()[Symbol.iterator]().next();if(e.done)throw new Error("No states defined yet");return e.value}get currentState(){if(this.#r===null)throw this.#e===0?new Error("Not started yet"):new Error("Already stopped");return this.#r}start(){if(this.#e!==0)throw new Error("State machine has already started");return this.#e=1,this.#r=this.#f,this.#h(null),this}stop(){if(this.#e!==1)throw new Error("Cannot stop a state machine that hasn't started yet");this.#p(null),this.#e=2,this.#r=null}constructor(e){this.id=z1++,this.#e=0,this.#r=null,this.#n=new Set,this.#a=new Map,this.#s=[],this.#u=[],this.#c=new Set,this.#o=new Map,this.#t=new W1(e),this.#i={didReceiveEvent:Ue(),willTransition:Ue(),didIgnoreUnexpectedEvent:Ue(),willExitState:Ue(),didEnterState:Ue(),didExitState:Ue()},this.events={didReceiveEvent:this.#i.didReceiveEvent.observable,willTransition:this.#i.willTransition.observable,didIgnoreUnexpectedEvent:this.#i.didIgnoreUnexpectedEvent.observable,willExitState:this.#i.willExitState.observable,didEnterState:this.#i.didEnterState.observable,didExitState:this.#i.didExitState.observable}}get context(){return this.#t.current}addState(e){if(this.#e!==0)throw new Error("Already started");return this.#n.add(e),this}onEnter(e,t){if(this.#e!==0)throw new Error("Already started");if(this.#a.has(e))throw new Error(`enter/exit function for ${e} already exists`);return this.#a.set(e,t),this}onEnterAsync(e,t,n,r,o){return this.onEnter(e,(()=>{const i=new AbortController,s=i.signal,a=o?setTimeout((()=>{const c=new Error("Timed out");this.#d({type:"ASYNC_ERROR",reason:c},r)}),o):void 0;let u=!1;return t(this.#t.current,s).then((c=>{s.aborted||(u=!0,this.#d({type:"ASYNC_OK",data:c},n))}),(c=>{s.aborted||(u=!0,this.#d({type:"ASYNC_ERROR",reason:c},r))})),()=>{clearTimeout(a),u||i.abort()}}))}#m(e){const t=[];if(e==="*")for(const n of this.#n)t.push(n);else if(e.endsWith(".*")){const n=e.slice(0,-1);for(const r of this.#n)r.startsWith(n)&&t.push(r)}else{const n=e;this.#n.has(n)&&t.push(n)}if(t.length===0)throw new Error(`No states match ${JSON.stringify(e)}`);return t}addTransitions(e,t){if(this.#e!==0)throw new Error("Already started");for(const n of this.#m(e)){let r=this.#o.get(n);r===void 0&&(r=new Map,this.#o.set(n,r));for(const[o,i]of Object.entries(t)){if(r.has(o))throw new Error(`Trying to set transition "${o}" on "${n}" (via "${e}"), but a transition already exists there.`);const s=i;if(this.#c.add(o),s!==void 0)if(s===_r)r.set(o,_r);else{const a=typeof s=="function"?s:()=>s;r.set(o,a)}}}return this}addTimedTransition(e,t,n){return this.onEnter(e,(()=>{const r=typeof t=="function"?t(this.#t.current):t,o=setTimeout((()=>{this.#d({type:"TIMER"},n)}),r);return()=>{clearTimeout(o)}}))}#g(e){return this.#o.get(this.currentState)?.get(e)}#p(e){this.#i.willExitState.notify(this.currentState);const t=performance.now(),n=this.currentState.split(".");this.#t.allowPatching((r=>{e=e??this.#s.length;for(let o=0;o<e;o++){this.#s.pop()?.(r);const i=this.#u.pop();if(i!==void 0&&this.#i.didExitState.count()>0){const s=this.#u.length;if(s===0)continue;const a=s===n.length?this.currentState:`${n.slice(0,s).join(".")}.*`;this.#i.didExitState.notify({state:a,durationMs:t-i})}}}))}#h(e){const t=(function(r,o){const i=r.split(".");if(o<1||o>i.length+1)throw new Error("Invalid number of levels");const s=[];o>i.length&&s.push("*");for(let a=i.length-o+1;a<i.length;a++){const u=i.slice(0,a);u.length>0&&s.push(u.join(".")+".*")}return s.push(r),s})(this.currentState,e??this.currentState.split(".").length+1),n=performance.now();this.#t.allowPatching((r=>{for(const o of t){const i=this.#a.get(o),s=i?.(r);typeof s=="function"?this.#s.push(s):this.#s.push(null),this.#u.push(n)}})),this.#i.didEnterState.notify(this.currentState)}send(e){if(!this.#c.has(e.type))throw new Error(`Invalid event ${JSON.stringify(e.type)}`);if(this.#e===2)return;const t=this.#g(e.type);return t!==_r?t!==void 0?this.#d(e,t):void this.#i.didIgnoreUnexpectedEvent.notify(e):void 0}#d(e,t){this.#i.didReceiveEvent.notify(e);const n=this.currentState,r=(typeof t=="function"?t:()=>t)(e,this.#t.current);let o,i;if(r===_r)return;if(typeof r=="string"?o=r:(o=r.target,i=Array.isArray(r.effect)?r.effect:[r.effect]),!this.#n.has(o))throw new Error(`Invalid next state name: ${JSON.stringify(o)}`);this.#i.willTransition.notify({from:n,to:o});const[s,a]=(function(u,c){if(u===c)return[0,0];const f=u.split("."),l=c.split("."),d=Math.min(f.length,l.length);let h=0;for(;h<d&&f[h]===l[h];h++);return[f.length-h,l.length-h]})(this.currentState,o);if(s>0&&this.#p(s),this.#r=o,i!==void 0){const u=i;this.#t.allowPatching((c=>{for(const f of u)typeof f=="function"?f(c,e):c.patch(f)}))}a>0&&this.#h(a)}},xe=Object.freeze({UPDATE_PRESENCE:100,USER_JOINED:101,USER_LEFT:102,BROADCASTED_EVENT:103,ROOM_STATE:104,STORAGE_STATE_V7:200,STORAGE_CHUNK:210,STORAGE_STREAM_END:211,UPDATE_STORAGE:201,UPDATE_YDOC:300,THREAD_CREATED:400,THREAD_DELETED:407,THREAD_METADATA_UPDATED:401,THREAD_UPDATED:408,COMMENT_CREATED:402,COMMENT_EDITED:403,COMMENT_DELETED:404,COMMENT_REACTION_ADDED:405,COMMENT_REACTION_REMOVED:406,COMMENT_METADATA_UPDATED:409,FEEDS_LIST:500,FEEDS_ADDED:501,FEEDS_UPDATED:502,FEED_DELETED:503,FEED_MESSAGES_LIST:504,FEED_MESSAGES_ADDED:505,FEED_MESSAGES_UPDATED:506,FEED_MESSAGES_DELETED:507,FEED_REQUEST_FAILED:508,REJECT_STORAGE_OP:299});function wd(e){return e===4999||e>=4e3&&e<4100}function Ed(e){return e===1013||e>=4200&&e<4300}function Zp(e){switch(e.currentState){case"@ok.connected":case"@ok.awaiting-pong":return"connected";case"@idle.initial":return"initial";case"@auth.busy":case"@auth.backoff":case"@connecting.busy":case"@connecting.backoff":case"@idle.zombie":return e.context.successCount>0?"reconnecting":"connecting";case"@idle.failed":return"disconnected";default:return Ye(0,"Unknown state")}}var Xp=[250,500,1e3,2e3,4e3,8e3,1e4],Qi=Xp[0]-1,K1=[2e3,3e4,6e4,3e5],Pn=class extends Error{constructor(e){super(e)}};function Yp(e,t){return t.find((n=>n>e))??t[t.length-1]}function Xr(e){e.patch({backoffDelay:Yp(e.backoffDelay,Xp)})}function Dd(e){e.patch({backoffDelay:Yp(e.backoffDelay,K1)})}function Ad(e){e.patch({successCount:0})}function ao(e,t){const n=e===2?Vn:e===1?mt:()=>{};return()=>{n(t)}}function xd(e){const t="Connection to Liveblocks websocket server";return n=>{Qp(e)?mt(`${t} closed prematurely (code: ${e.code}). Retrying in ${n.backoffDelay}ms.`):mt(`${t} could not be established.`,e)}}function Oa(e){const t=[`code: ${e.code}`];return e.reason&&t.push(`reason: ${e.reason}`),n=>{mt(`Connection to Liveblocks websocket server closed (${t.join(", ")}). Retrying in ${n.backoffDelay}ms.`)}}var q1=ao(1,"Connection to WebSocket closed permanently. Won't retry.");function Qp(e){return!(e instanceof Error)&&e.type==="close"}var es=e=>t=>t.patch(e);function G1(e,t){const n=(function(){const w=Ue();let b=null;return{...w,notify:function(C){return b!==null?(b.push(C),!1):w.notify(C)},pause:function(){b=[]},unpause:function(){if(b!==null){for(const C of b)w.notify(C);b=null}},dispose(){w.dispose(),b!==null&&(b.length=0)}}})();n.pause();const r=Ue();function o(w,b){return()=>{r.notify({message:w,code:b})}}const i=new Jp({successCount:0,authValue:null,socket:null,backoffDelay:Qi}).addState("@idle.initial").addState("@idle.failed").addState("@idle.zombie").addState("@auth.busy").addState("@auth.backoff").addState("@connecting.busy").addState("@connecting.backoff").addState("@ok.connected").addState("@ok.awaiting-pong");i.addTransitions("*",{RECONNECT:{target:"@auth.backoff",effect:[Xr,Ad]},DISCONNECT:"@idle.initial"}),i.onEnter("@idle.*",Ad).addTransitions("@idle.*",{CONNECT:(w,b)=>b.authValue!==null?"@connecting.busy":"@auth.busy"}),i.addTransitions("@auth.backoff",{NAVIGATOR_ONLINE:{target:"@auth.busy",effect:es({backoffDelay:Qi})}}).addTimedTransition("@auth.backoff",(w=>w.backoffDelay),"@auth.busy").onEnterAsync("@auth.busy",(()=>sd(e.authenticate(),1e4,"Timed out during auth")),(w=>({target:"@connecting.busy",effect:es({authValue:w.data})})),(w=>w.reason instanceof Pn?{target:"@idle.failed",effect:[ao(2,w.reason.message),o(w.reason.message,-1)]}:{target:"@auth.backoff",effect:[Xr,ao(2,`Authentication failed: ${w.reason instanceof Error?w.reason.message:String(w.reason)}`)]}));const s=w=>i.send({type:"EXPLICIT_SOCKET_ERROR",event:w}),a=w=>i.send({type:"EXPLICIT_SOCKET_CLOSE",event:w}),u=w=>{i.send({type:"ALIVE"}),w.data!=="pong"&&n.notify(w)};function c(w){w&&(w.removeEventListener("error",s),w.removeEventListener("close",a),w.removeEventListener("message",u),w.close())}i.addTransitions("@connecting.backoff",{NAVIGATOR_ONLINE:{target:"@connecting.busy",effect:es({backoffDelay:Qi})}}).addTimedTransition("@connecting.backoff",(w=>w.backoffDelay),"@connecting.busy").onEnterAsync("@connecting.busy",(async(w,b)=>{const C=performance.now();let E=null,A=null,x=null;return sd(new Promise(((I,T)=>{if(w.authValue===null)throw new Error("No auth authValue");const B=e.createSocket(w.authValue);function S(H){A=H,B.removeEventListener("message",u),T(H)}x=B;const[k,R]=Wp();function M(H){if(Hn(H.data)?.type===xe.ROOM_STATE){if(t.enableDebugLogging&&E!==null){const G=performance.now()-E;mt(`[FSM #${i.id}] Socket open → ROOM_STATE: ${G.toFixed(0)}ms`)}R()}}t.waitForActorId||R(),B.addEventListener("message",u),t.waitForActorId&&B.addEventListener("message",M),B.addEventListener("error",S),B.addEventListener("close",S),B.addEventListener("open",(()=>{if(E=performance.now(),t.enableDebugLogging){const W=E-C;mt(`[FSM #${i.id}] Socket epoch → open: ${W.toFixed(0)}ms`)}B.addEventListener("error",s),B.addEventListener("close",a);const H=()=>{B.removeEventListener("error",S),B.removeEventListener("close",S),B.removeEventListener("message",M)};k.then((()=>{I([B,H])}))}))})),2e4,"Timed out during websocket connection").then((([I,T])=>{if(T(),b.aborted)throw new Error("Aborted");if(A)throw A;return I})).catch((I=>{throw c(x),I}))}),(w=>({target:"@ok.connected",effect:es({socket:w.data,backoffDelay:Qi})})),(w=>{const b=w.reason;if(b instanceof Pn)return{target:"@idle.failed",effect:[ao(2,b.message),o(b.message,-1)]};if(Qp(b)){if(b.code===4109)return"@auth.busy";if(Ed(b.code))return{target:"@connecting.backoff",effect:[Dd,xd(b)]};if(wd(b.code))return{target:"@idle.failed",effect:[ao(2,b.reason),o(b.reason,b.code)]}}return{target:"@auth.backoff",effect:[Xr,xd(b)]}})).addTransitions("@connecting.busy",{ALIVE:_r});const f={target:"@ok.awaiting-pong",effect:w=>{w.socket?.send("ping")}},l=()=>(typeof document<"u"?document:void 0)?.visibilityState==="hidden"&&e.canZombie()?"@idle.zombie":f;if(i.addTimedTransition("@ok.connected",3e4,l).addTransitions("@ok.connected",{NAVIGATOR_OFFLINE:l,WINDOW_GOT_FOCUS:f,ALIVE:_r}),i.addTransitions("@idle.zombie",{WINDOW_GOT_FOCUS:"@connecting.backoff"}),i.onEnter("@ok.*",(w=>{w.patch({successCount:w.successCount+1});const b=setTimeout(n.unpause,0);return C=>{c(C.socket),C.patch({socket:null}),clearTimeout(b),n.pause()}})).addTransitions("@ok.awaiting-pong",{ALIVE:"@ok.connected"}).addTimedTransition("@ok.awaiting-pong",2e3,{target:"@connecting.busy",effect:ao(1,"Received no pong from server, assume implicit connection loss.")}).addTransitions("@ok.*",{EXPLICIT_SOCKET_ERROR:(w,b)=>b.socket?.readyState===1?_r:{target:"@connecting.backoff",effect:Xr},EXPLICIT_SOCKET_CLOSE:w=>{return wd(w.event.code)?{target:"@idle.failed",effect:[q1,o(w.event.reason,w.event.code)]}:(b=w.event.code)>=4100&&b<4200?w.event.code===4109?"@auth.busy":{target:"@auth.backoff",effect:[Xr,Oa(w.event)]}:Ed(w.event.code)?{target:"@connecting.backoff",effect:[Dd,Oa(w.event)]}:{target:"@connecting.backoff",effect:[Xr,Oa(w.event)]};var b}}),typeof document<"u"){const w=typeof document<"u"?document:void 0,b=typeof window<"u"?window:void 0,C=b??w;i.onEnter("*",(E=>{function A(){i.send({type:"NAVIGATOR_OFFLINE"})}function x(){i.send({type:"NAVIGATOR_ONLINE"})}function I(){w?.visibilityState==="visible"&&i.send({type:"WINDOW_GOT_FOCUS"})}return b?.addEventListener("online",x),b?.addEventListener("offline",A),C?.addEventListener("visibilitychange",I),()=>{C?.removeEventListener("visibilitychange",I),b?.removeEventListener("online",x),b?.removeEventListener("offline",A),c(E.socket)}}))}const d=[],{statusDidChange:h,didConnect:g,didDisconnect:y,unsubscribe:p}=(function(w){const b=Ue(),C=Ue(),E=Ue();let A=null;const x=w.events.didEnterState.subscribe((()=>{const I=Zp(w);I!==A&&b.notify(I),A==="connected"&&I!=="connected"?E.notify():A!=="connected"&&I==="connected"&&C.notify(),A=I}));return{statusDidChange:b.observable,didConnect:C.observable,didDisconnect:E.observable,unsubscribe:x}})(i);return d.push(p),t.enableDebugLogging&&d.push((function(w){function b(...E){mt(`[FSM #${w.id}]`,...E)}const C=[w.events.didReceiveEvent.subscribe((E=>b(`Event ${E.type}`))),w.events.willTransition.subscribe((({from:E,to:A})=>b("Transitioning",E,"→",A))),w.events.didExitState.subscribe((({state:E,durationMs:A})=>b(`Exited ${E} after ${A.toFixed(0)}ms`))),w.events.didIgnoreUnexpectedEvent.subscribe((E=>b("Ignored unexpected event",E.type,E,"(no transition declared)")))];return()=>{for(const E of C)E()}})(i)),i.start(),{machine:i,cleanups:d,events:{statusDidChange:h,didConnect:g,didDisconnect:y,onMessage:n.observable,onConnectionError:r.observable}}}var em=class{#e;#t;events;constructor(e,t=!1,n=!0){const{machine:r,events:o,cleanups:i}=G1(e,{waitForActorId:n,enableDebugLogging:t});this.#e=r,this.events=o,this.#t=i}getStatus(){try{return Zp(this.#e)}catch{return"initial"}}get authValue(){return this.#e.context.authValue}connect(){this.#e.send({type:"CONNECT"})}reconnect(){this.#e.send({type:"RECONNECT"})}disconnect(){this.#e.send({type:"DISCONNECT"})}destroy(){let e;for(this.#e.stop();e=this.#t.pop();)e()}send(e){const t=this.#e.context?.socket;t===null?mt("Cannot send: not connected yet",e):t.readyState!==1?mt("Cannot send: WebSocket no longer open",e):t.send(e)}_privateSendMachineEvent(e){this.#e.send(e)}},Od=Object.freeze({}),J1=Array.from(new Set("null")),Z1=Array.from(new Set("true")),X1=Array.from(new Set("false")),Y1=Array.from(new Set("nulltruefalse"));function Sa(e,t){const n=e[e.length-1];return t.includes(n)?e.slice(0,-1):e}var Q1=class{#e="";#t;#n=0;#r=!1;#o=-1;#i=-1;#s=[];constructor(e=""){this.append(e)}get source(){return this.#e}get json(){return this.#t===void 0&&(this.#t=this.#f()),this.#t}get#u(){return this.#o>=0}append(e){e&&(this.#e===""&&(e=e.trimStart()),this.#e+=e,this.#t=void 0)}#a(e){if(this.#u)return"";const t=e.charAt(e.length-1);if(t==="")return"";if(t==="-")return"0";if(!Y1.includes(t))return"";if(J1.includes(t)){if(e.endsWith("nul"))return"l";if(e.endsWith("nu"))return"ll";if(e.endsWith("n"))return"ull"}if(Z1.includes(t)){if(e.endsWith("tru"))return"e";if(e.endsWith("tr"))return"ue";if(e.endsWith("t"))return"rue"}if(X1.includes(t)){if(e.endsWith("fals"))return"e";if(e.endsWith("fal"))return"se";if(e.endsWith("fa"))return"lse";if(e.endsWith("f"))return"alse"}return""}#c(){const e=this.#e.slice(this.#n);for(let t=0;t<e.length;t++){const n=e[t],r=this.#n+t;this.#u?this.#r?this.#r=!1:n==="\\"?this.#r=!0:n==='"'&&(this.#i=this.#o,this.#o=-1):n==='"'?this.#o=r:n==="{"?this.#s.push("}"):n==="["?this.#s.push("]"):(n==="}"&&this.#s.length>0&&this.#s[this.#s.length-1]==="}"||n==="]"&&this.#s.length>0&&this.#s[this.#s.length-1]==="]")&&this.#s.pop()}this.#n=this.#e.length}#f(){this.#c();let e=this.#e;if(e.charAt(0)!=="{")return Od;if(e.endsWith("}")){const n=Hn(e);if(n)return n}this.#u&&(this.#r&&(e=e.slice(0,-1)),e+='"'),e=e.trimEnd(),e=Sa(e,",."),e+=this.#a(e);const t=this.#s.reduceRight(((n,r)=>n+r),"");{const n=Hn(e+t);if(n)return n}return this.#u?e=e.slice(0,this.#o):(e=Sa(e,":"),e.endsWith('"')&&(e=e.slice(0,this.#i))),e=Sa(e,","),e+=t,Hn(e)??Od}};function lt(e,t){if(Object.is(e,t))return!0;const n=Array.isArray(e),r=Array.isArray(t);return n||r?!(!n||!r)&&(function(o,i){if(o.length!==i.length)return!1;for(let s=0;s<o.length;s++)if(!Object.is(o[s],i[s]))return!1;return!0})(e,t):(function(o,i){if(!gt(o)||!gt(i))return!1;const s=Object.keys(o);return s.length===Object.keys(i).length&&s.every((a=>Object.prototype.hasOwnProperty.call(i,a)&&Object.is(o[a],i[a])))})(e,t)}function uo(e,t){if(!gt(e)||!gt(t))return lt(e,t);const n=Object.keys(e);return n.length===Object.keys(t).length&&n.every((r=>Object.prototype.hasOwnProperty.call(t,r)&&lt(e[r],t[r])))}var ey=class{#e;#t;#n;#r;#o;#i;constructor(e,t,n){this.#r=e,this.#o=t,this.#i=n,this.#e=new Map,this.#t=new He((()=>new Set)),this.#n=ar.with(n)}get(e){return this.#e.get(e)}getOrThrow(e){return this.get(e)??hn(`Item with id ${e} not found`)}get sorted(){return this.#n}getParentId(e){const t=this.getOrThrow(e);return this.#o(t)}getParent(e){const t=this.getParentId(e);return t?this.getOrThrow(t):null}getChildren(e){const t=this.#t.get(e);return t?Array.from(t).map((n=>this.#e.get(n))):[]}*walkUp(e,t){let n=e;do{const r=this.getOrThrow(n);t&&!t(r)||(yield r),n=this.#o(r)}while(n!==null)}*walkLeft(e,t){const n=this.getOrThrow(e),r=ar.from(this.getSiblings(e),this.#i);for(const o of r.iterReversed())this.#i(n,o)||t&&!t(o)||(yield o)}*walkRight(e,t){const n=this.getOrThrow(e),r=ar.from(this.getSiblings(e),this.#i);for(const o of r)this.#i(o,n)||t&&!t(o)||(yield o)}*walkDown(e,t){const n=ar.from(this.getChildren(e),this.#i).rawArray;for(let r=n.length-1;r>=0;r--){const o=n[r];yield*this.walkDown(this.#r(o),t),t&&!t(o)||(yield o)}}getSiblings(e){const t=this.getOrThrow(e),n=this.getParentId(e);return this.getChildren(n).filter((r=>r!==t))}[Symbol.iterator](){return this.#n[Symbol.iterator]()}upsert(e){const t=this.#r(e),n=this.#e.get(t);if(n){if(this.#o(n)!==this.#o(e))throw new Error("Cannot upsert parent ID changes that change the tree structure. Remove the entry first, and recreate it");this.#n.remove(n)}this.#e.set(t,e),this.#n.add(e);const r=this.#o(e);this.#t.getOrCreate(r).add(t)}remove(e){const t=this.#e.get(e);if(!t)return!1;if(this.#t.get(e))throw new Error(`Cannot remove item '${e}' while it still has children. Remove children first.`);const n=this.#o(t),r=this.#t.get(n);return r&&(r.delete(e),r.size===0&&this.#t.delete(n)),this.#n.remove(t),this.#t.delete(e),this.#e.delete(e),!0}clear(){return this.#e.size!==0&&(this.#t.clear(),this.#e.clear(),this.#n.clear(),!0)}},ty=class{#e;#t;#n;constructor(){this.#e=new Set,this.#t=new He((()=>new Map)),this.#n=void 0}registerLayer(e){const t=e;return this.#e.has(t)&&hn(`Layer '${t}' already exists, provide a unique layer id`),this.#e.add(t),t}deregisterLayer(e){this.#e.delete(e);let t=!1;for(const[n,r]of this.#t)r.delete(e)&&(t=!0),r.size===0&&this.#t.delete(n);t&&this.invalidate()}get(){return this.#n??=this.#r()}invalidate(){this.#n=void 0}#r(){return Array.from(this.#t.values()).flatMap((e=>Array.from(e.values()).slice(-1).filter(F1)))}updateKnowledge(e,t,n){this.#e.has(e)||hn(`Unknown layer key: ${e}`),this.#t.getOrCreate(t).set(e,n),this.invalidate()}};function Ia(){return new Date().toISOString()}var ci=Symbol("*");function ny(){const e=new He((n=>new He((r=>new Tt(void 0))))),t=new He((n=>{const[r,o]=Hn(n);return $e.from((()=>(o!==void 0?e.getOrCreate(o).getOrCreate(r):void 0)?.get()??e.getOrCreate(ci).getOrCreate(r).get()))}));return{getToolDescriptions:function(n){const r=e.get(ci),o=e.get(n);return Array.from([...r?.entries()??[],...o?.entries()??[]]).flatMap((([i,s])=>{const a=s.get();return a&&(a.enabled??1)?[{name:i,description:a.description,parameters:a.parameters}]:[]}))},getToolΣ:function(n,r){const o=JSON.stringify(r!==void 0?[n,r]:[n]);return t.getOrCreate(o)},registerTool:function(n,r,o){if(!r.execute&&!r.render)throw new Error("A tool definition must have an execute() function, a render() function, or both.");const i=o??ci;return e.getOrCreate(i).getOrCreate(n).set(r),()=>(function(s,a){const u=e.get(s);if(u===void 0)return;const c=u.get(a);c!==void 0&&c.set(void 0)})(i,n)}}}function ry(e,t){const n=new Set,r=new Set,o=new He((l=>new Ot(new ey((d=>d.id),(d=>d.parentId),((d,h)=>d.createdAt<h.createdAt))))),i=new Ot(new Map);function s(l){Xe((()=>{for(const d of l)a(d)}))}function a(l){Xe((()=>{if(o.getOrCreate(l.chatId).mutate((d=>d.upsert(l))),l.role==="assistant"&&l.status==="generating"?i.mutate((d=>{d.set(l.id,structuredClone(l))})):i.mutate((d=>{d.delete(l.id)})),l.role==="assistant"&&l.status==="awaiting-tool"){if(n.has(l.id))for(const d of l.contentSoFar.filter((h=>h.type==="tool-invocation"&&h.stage==="executing"))){if(r.has(d.invocationId))continue;r.add(d.invocationId);const h=e.getToolΣ(d.name,l.chatId).get()?.execute;h&&(async()=>{const g=await h(d.args,{name:d.name,invocationId:d.invocationId});return await t(l.chatId,l.id,d.invocationId,g??{data:{}},{copilotId:l.copilotId})})().catch((g=>{Vn(`Error trying to respond to tool-call: ${String(g)} (in execute())`)}))}}else l.role==="assistant"&&l.status==="generating"||n.delete(l.id)}))}function u(l){for(const d of o.values()){const h=d.get().get(l);if(h)return h}}function c(l){const d=l.next();return d.done?void 0:d.value}const f=new He((l=>new He((d=>{const h=$e.from((()=>(function(g,y){function p(E){if(!E.deletedAt)return!0;for(const A of g.walkDown(E.id,(x=>!x.deletedAt)))return!0;return!1}function w(E){const A=[];let x=null;for(const I of g.walkUp(E.id)){const T=c(g.walkLeft(I.id,p))?.id??null,B=c(g.walkRight(I.id,p))?.id??null;if(!I.deletedAt||T||B){const S={...I,navigation:{parent:null,prev:T,next:B}};x!==null&&(x.navigation.parent=S.id),x=S,A.push(S)}}return A.reverse()}function b(){const E=g.sorted.findRight((A=>!A.deletedAt));return E?w(E):[]}if(y===null)return b();const C=g.get(y);if(!C)return b();for(const E of g.walkUp(C.id)){for(const A of g.walkDown(E.id,(x=>!x.deletedAt)))return w(A);if(!E.deletedAt)return w(E)}return b()})(o.getOrCreate(l).get(),d)),uo);return $e.from((()=>{const g=i.get();return h.get().map((y=>{if(y.role!=="assistant"||y.status!=="generating")return y;const p=g.get(y.id);return p===void 0?y:{...y,contentSoFar:p.contentSoFar}}))}),lt)}))));return{getMessageById:u,getChatMessagesForBranchΣ:function(l,d){return f.getOrCreate(l).getOrCreate(d||null)},getLastUsedCopilotId:function(l){return o.getOrCreate(l).get().sorted.findRight((h=>h.role==="assistant"&&!h.deletedAt))?.copilotId},createOptimistically:function(l,d,h,g){const y=`ms_${st()}`,p=Ia();return a(d==="user"?{id:y,chatId:l,role:d,parentId:h,createdAt:p,content:g,_optimistic:!0}:{id:y,chatId:l,role:d,parentId:h,createdAt:p,status:"generating",contentSoFar:[],copilotId:g,_optimistic:!0}),y},upsert:a,upsertMany:s,remove:function(l,d){const h=o.get(l);if(!h)return;const g=h.get().get(d);g&&!g.deletedAt&&(g.role==="assistant"&&g.status!=="completed"?a({...g,deletedAt:Ia(),contentSoFar:[]}):a({...g,deletedAt:Ia(),content:[]}))},removeByChatId:function(l){const d=o.get(l);d!==void 0&&d.mutate((h=>h.clear()))},addDelta:function(l,d){i.mutate((h=>{const g=h.get(l);return g!==void 0&&((function(y,p){if(p===null)return;const w=y.filter((A=>A.type!=="sources")),b=y.filter((A=>A.type==="sources")).flatMap((A=>A.sources)),C=new Date().toISOString(),E=w[w.length-1];switch(p.type){case"text-delta":E?.type==="text"?E.text+=p.textDelta:(Ou(E,C),w.push({type:"text",text:p.textDelta}));break;case"reasoning-delta":E?.type==="reasoning"?E.text+=p.textDelta:(Ou(E,C),w.push({type:"reasoning",text:p.textDelta,startedAt:C}));break;case"tool-stream":{const A=(function(x,I,T=""){const B=new Q1(T);return{type:"tool-invocation",stage:"receiving",invocationId:x,name:I,get partialArgsText(){return B.source},get partialArgs(){return B.json},__appendDelta(S){B.append(S)}}})(p.invocationId,p.name);w.push(A);break}case"tool-delta":E?.type==="tool-invocation"&&E.stage==="receiving"&&E.__appendDelta?.(p.delta);break;case"tool-invocation":Sd(w,p,(A=>A.invocationId),C);break;case"retrieval":Sd(w,p,(A=>A.id),C);break;case"source":b.push(p);break;default:return Ye(0,"Unhandled case")}b.length>0&&w.push({type:"sources",sources:b}),y.length=0,y.push(...w)})(g.contentSoFar,d),h.set(l,g),!0)}))},failAllPending:function(){Xe((()=>{i.mutate((l=>{let d=!1;for(const[h,g]of l)g._optimistic||(l.delete(h),d=!0);return d})),s(Array.from((function*(){for(const l of o.values())for(const d of l.get())d.role!=="assistant"||d.status!=="generating"||d._optimistic||(yield d)})()).map((l=>({...l,status:"failed",errorReason:"Lost connection"}))))}))},markMine(l){n.add(l)},*getAutoExecutingMessageIds(){for(const l of n){const d=u(l);d?.role==="assistant"&&d.status==="awaiting-tool"&&d.contentSoFar.some((h=>h.type==="tool-invocation"&&h.stage==="executing"?typeof e.getToolΣ(h.name,d.chatId).get()?.execute=="function":!1))&&(yield d.id)}}}}function oy(e){const t=new em(e.delegates,e.enableDebugLogging,!1),n=(function(){const w=new D1;return{getChatById:function(b){return w.getEvenIfDeleted(b)},findMany:function(b){return w.signal.get().findMany(b)},upsert:function(b){w.upsert(b)},upsertMany:function(b){Xe((()=>{for(const C of b)w.upsert(C)}))},markDeleted:function(b){w.markDeleted(b)}}})(),r=ny(),o=(function(){const w=new He((b=>new ty));return{getKnowledgeStack:function(b){return w.getOrCreate(b??ci)},getKnowledgeForChat:function(b){return[...w.getOrCreate(ci).get(),...w.get(b)?.get()??[]]}}})(),i=ry(r,y),s={staticSessionInfoSig:new Tt(null),dynamicSessionInfoSig:new Tt(null),pendingCmds:new Map,chatsStore:n,messagesStore:i,toolsStore:r,knowledgeStore:o},a=new Tt("initial");let u,c,f=[],l=null;function d(){const w=f;f=[],l!==null&&(clearTimeout(l),l=null),Xe((()=>{for(const{id:b,delta:C}of w)s.messagesStore.addDelta(b,C)}))}function h(){t.getStatus()==="initial"&&t.connect()}async function g(w){h(),t.getStatus()!=="connected"&&await t.events.didConnect.waitUntil();const{promise:b,resolve:C,reject:E}=mo(),A=AbortSignal.timeout(4e3);A.addEventListener("abort",(()=>E(A.reason)),{once:!0});const x=st(7);return s.pendingCmds.set(x,{resolve:C,reject:E}),(function(I){t.send(JSON.stringify({...I}))})({...w,cmdId:x}),b.finally((()=>{s.pendingCmds.delete(x)})).catch((I=>{throw Vn(I.message),I}))}async function y(w,b,C,E,A){const x=s.knowledgeStore.getKnowledgeForChat(w),I=s.toolsStore.getToolDescriptions(w),T=await g({cmd:"set-tool-result",chatId:w,messageId:b,invocationId:C,result:E,generationOptions:{copilotId:A?.copilotId,stream:A?.stream,timeout:A?.timeout,knowledge:x.length>0?x:void 0,tools:I.length>0?I:void 0}});T.ok&&i.markMine(T.message.id)}return t.events.onMessage.subscribe((function(w){if(typeof w.data!="string")return;const b=Hn(w.data);if(!b)return;const C="cmdId"in b?b.cmdId:b.event==="cmd-failed"?b.failedCmdId:void 0,E=s.pendingCmds.get(C);if(!C||E){if("event"in b)if(b.event==="delta"){const{id:A,delta:x}=b;(function(I,T){f.push({id:I,delta:T}),l===null&&(l=setTimeout(d,25))})(A,x)}else Xe((()=>{switch(d(),b.event){case"cmd-failed":E?.reject(new Error(b.error));break;case"settle":s.messagesStore.upsert(b.message);break;case"warning":mt(b.message);break;case"error":Vn(b.error);break;case"rebooted":s.messagesStore.failAllPending();break;case"sync":for(const A of b["-messages"]??[])s.messagesStore.remove(A.chatId,A.id);for(const A of b["-chats"]??[])s.chatsStore.markDeleted(A),s.messagesStore.removeByChatId(A);for(const A of b.clear??[])s.messagesStore.removeByChatId(A);b.chats&&s.chatsStore.upsertMany(b.chats),b.messages&&s.messagesStore.upsertMany(b.messages);break;default:return Ye(0,"Unhandled case")}}));else switch(b.cmd){case"get-chats":s.chatsStore.upsertMany(b.chats);break;case"get-or-create-chat":s.chatsStore.upsert(b.chat);break;case"delete-chat":s.chatsStore.markDeleted(b.chatId),s.messagesStore.removeByChatId(b.chatId);break;case"get-message-tree":s.chatsStore.upsert(b.chat),s.messagesStore.upsertMany(b.messages);break;case"delete-message":s.messagesStore.remove(b.chatId,b.messageId);break;case"clear-chat":s.messagesStore.removeByChatId(b.chatId);break;case"ask-in-chat":b.sourceMessage&&s.messagesStore.upsert(b.sourceMessage),s.messagesStore.upsert(b.targetMessage);break;case"abort-ai":break;case"set-tool-result":b.ok&&s.messagesStore.upsert(b.message);break;default:return Ye(0,"Unhandled case")}E?.resolve(b)}else mt("Ignoring unexpected command response. Already timed out, or not for us?",b)})),t.events.statusDidChange.subscribe((function(w){const b=t.authValue;if(b!==null){const C=Rc(b);if(C!==u)if(u=C,b.type==="secret"){const E=b.token.parsed;s.staticSessionInfoSig.set({userId:E.uid,userInfo:E.ui})}else s.staticSessionInfoSig.set({userId:void 0,userInfo:void 0})}a.set(w)})),t.events.statusDidChange.subscribe((function(w){w==="reconnecting"?c=setTimeout((()=>{}),e.lostConnectionTimeout):clearTimeout(c)})),t.events.didConnect.subscribe((function(){})),t.events.didDisconnect.subscribe((function(){d()})),t.events.onConnectionError.subscribe((({message:w,code:b})=>{})),(typeof window<"u"?window:void 0)?.addEventListener("beforeunload",(function(){for(const w of s.messagesStore.getAutoExecutingMessageIds())g({cmd:"abort-ai",messageId:w}).catch((()=>{}))}),{once:!0}),Object.defineProperty({[Oe]:{context:s},connectInitially:h,disconnect:()=>t.disconnect(),getChats:function(w={}){return g({cmd:"get-chats",cursor:w.cursor,query:w.query})},getOrCreateChat:function(w,b){return g({cmd:"get-or-create-chat",id:w,options:b})},deleteChat:w=>g({cmd:"delete-chat",chatId:w}),getMessageTree:function(w){return g({cmd:"get-message-tree",chatId:w})},deleteMessage:(w,b)=>g({cmd:"delete-message",chatId:w,messageId:b}),clearChat:w=>g({cmd:"clear-chat",chatId:w}),askUserMessageInChat:async(w,b,C,E)=>{const A=[...s.knowledgeStore.getKnowledgeForChat(w),...E?.knowledge||[]],x=s.toolsStore.getToolDescriptions(w);return i.markMine(C),await g({cmd:"ask-in-chat",chatId:w,sourceMessage:b,targetMessageId:C,generationOptions:{copilotId:E?.copilotId,stream:E?.stream,timeout:E?.timeout,knowledge:A.length>0?A:void 0,tools:x.length>0?x:void 0}})},abort:w=>g({cmd:"abort-ai",messageId:w}),setToolResult:y,getStatus:()=>t.getStatus(),signals:{getChatMessagesForBranchΣ:s.messagesStore.getChatMessagesForBranchΣ,getToolΣ:s.toolsStore.getToolΣ,statusΣ:a},getChatById:s.chatsStore.getChatById,queryChats:s.chatsStore.findMany,getLastUsedCopilotId:s.messagesStore.getLastUsedCopilotId,registerKnowledgeLayer:(w,b)=>{const C=s.knowledgeStore.getKnowledgeStack(b),E=C.registerLayer(w);return{layerKey:E,deregister:()=>C.deregisterLayer(E)}},updateKnowledge:(w,b,C,E)=>{s.knowledgeStore.getKnowledgeStack(E).updateKnowledge(w,C??st(),b)},registerTool:s.toolsStore.registerTool},Oe,{enumerable:!1})}function iy(e,t){return n=>{const r=t??(typeof WebSocket>"u"?void 0:WebSocket);if(r===void 0)throw new Pn("To use Liveblocks client in a non-DOM environment, you need to provide a WebSocket polyfill.");const o=new URL(e);if(o.protocol=o.protocol==="http:"?"ws":"wss",o.pathname="/ai/v7",n.type!=="secret"){if(n.type==="public")throw new Error("Public key not supported with AI Copilots");return Ye(0,"Unhandled case")}return o.searchParams.set("tok",n.token.raw),o.searchParams.set("version",ea),new r(o.toString())}}function Sd(e,t,n,r){const o=Tp(e,(i=>i.type===t.type&&n(i)===n(t)));o>-1?e[o]=t:(Ou(e[e.length-1],r),e.push(t))}function Ou(e,t){e?.type==="reasoning"&&(e.endedAt??=t)}var rt={Read:"*:read",Write:"*:write",RoomWrite:"room:write",RoomRead:"room:read",StorageRead:"storage:read",StorageWrite:"storage:write",StorageNone:"storage:none",CommentsWrite:"comments:write",CommentsRead:"comments:read",CommentsNone:"comments:none",CommentsPublicWrite:"comments:public:write",CommentsPublicRead:"comments:public:read",CommentsPublicNone:"comments:public:none",CommentsPrivateWrite:"comments:private:write",CommentsPrivateRead:"comments:private:read",CommentsPrivateNone:"comments:private:none",FeedsRead:"feeds:read",FeedsWrite:"feeds:write",FeedsNone:"feeds:none",LegacyRoomPresenceWrite:"room:presence:write"},sy=["none","read","write"],Ir={none:0,read:1,write:2},ay={room:{read:[rt.Read,rt.RoomRead],write:[rt.Write,rt.RoomWrite]},storage:{write:[rt.StorageWrite],read:[rt.StorageRead],none:[rt.StorageNone]},comments:{write:[rt.CommentsWrite],read:[rt.CommentsRead],none:[rt.CommentsNone]},"comments:public":{write:[rt.CommentsPublicWrite],read:[rt.CommentsPublicRead],none:[rt.CommentsPublicNone]},"comments:private":{write:[rt.CommentsPrivateWrite],read:[rt.CommentsPrivateRead],none:[rt.CommentsPrivateNone]},feeds:{write:[rt.FeedsWrite],read:[rt.FeedsRead],none:[rt.FeedsNone]}},uy={room:"none",storage:"none",comments:"none","comments:public":"none","comments:private":"none",feeds:"none",personal:"none"},tm=["storage","comments","comments:public","comments:private","feeds"],cy=new Set(Object.values(rt));function ly(e){return cy.has(e)}function Id(e,t){const n=ay[t];let r;for(const o of sy){const i=n[o];i!==void 0&&i.some((s=>e.includes(s)))&&(r=o)}return r}function nm(e){const t={},n=Id(e,"room");n!==void 0&&(t.room=n);for(const r of tm){const o=Id(e,r);o!==void 0&&(t[r]=o)}return t}function rm(e){const t=e.room;if(t===void 0)return{...uy};const n=e.comments??t;return{room:t,storage:e.storage??t,comments:n,"comments:public":e["comments:public"]??n,"comments:private":e["comments:private"]??n,feeds:e.feeds??t,personal:"write"}}function jc(e){return rm(nm(e))}function fr(e,t,n){const r=Ir[n];if(t==="comments")return Math.max(Ir[e.comments??"none"],Ir[e["comments:public"]??"none"],Ir[e["comments:private"]??"none"])>=r;const o=e[t]??"none";return Ir[o]>=r}function Mc(e){if(!Array.isArray(e))throw new Error("Permission list must be an array");const t=[];for(const n of e){if(!ly(n))throw new Error(`Not a valid permission: ${n}`);t.push(n)}return t}function dy(e,t){return e[t]??((function(n){return n.startsWith("comments:")})(t)?e.comments:void 0)}function Td(e,t){return Ir[t]>Ir[e]?t:e}function kd(e){const t=e.split(".");if(t.length!==3)throw new Error("Authentication error: invalid JWT token");const n=Hn((function(o){try{const i=o.replace(/-/g,"+").replace(/_/g,"/");return decodeURIComponent(atob(i).split("").map((function(s){return"%"+("00"+s.charCodeAt(0).toString(16)).slice(-2)})).join(""))}catch{return atob(o)}})(t[1]));if(!n||!gt(r=n)||r.k!=="acc"&&r.k!=="id")throw new Error("Authentication error: expected a valid token but did not get one. Hint: if you are using a callback, ensure the room is passed when creating the token. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClientCallback");var r;return{raw:e,parsed:n}}var fy=[400,401,403,404,405,410,412,414,422,431,451];function hy(e,t){const n=(function(u){const{publicApiKey:c,authEndpoint:f}=u;if(f!==void 0&&c!==void 0)throw new Error("You cannot simultaneously use `publicApiKey` and `authEndpoint` options. Please pick one and leave the other option unspecified. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClient");if(typeof c=="string"){if(c.startsWith("sk_"))throw new Error("Invalid `publicApiKey` option. The value you passed is a secret key, which should not be used from the client. Please only ever pass a public key here. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClientPublicKey");if(!c.startsWith("pk_"))throw new Error("Invalid key. Please use the public key format: pk_<public key>. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClientPublicKey");return{type:"public",publicApiKey:c}}if(typeof f=="string")return{type:"private",url:f};if(typeof f=="function")return{type:"custom",callback:f};throw f!==void 0?new Error("The `authEndpoint` option must be a string or a function. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClientAuthEndpoint"):new Error("Invalid Liveblocks client options. Please provide either a `publicApiKey` or `authEndpoint` option. They cannot both be empty. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClient")})(e),r=new Set,o=[],i=new Map;function s(u){const c=Math.ceil(Date.now()/1e3);for(let f=o.length-1;f>=0;f--){const l=o[f];if(l.expiresAt<=c)o.splice(f,1);else if(py(l,u))return l.token}}async function a(u){const c=e.polyfills?.fetch??(typeof window>"u"?void 0:window.fetch);if(n.type==="private"){if(c===void 0)throw new Pn("To use Liveblocks client in a non-DOM environment with a url as auth endpoint, you need to provide a fetch polyfill.");const f=kd((await(async function(l,d,h){const g=await l(d,{method:"POST",headers:{"Content-Type":"application/json"},body:Pr(h)});if(!g.ok){const w=`${(await g.text()).trim()||"reason not provided in auth response"} (${g.status} returned by POST ${d})`;throw fy.includes(g.status)?new Pn(`Unauthorized: ${w}`):new Error(`Failed to authenticate: ${w}`)}let y;try{y=await g.json()}catch(w){throw new Error(`Expected a JSON response when doing a POST request on "${d}". ${String(w)}`)}if(!gt(y)||typeof y.token!="string")throw new Error(`Expected a JSON response of the form \`{ token: "..." }\` when doing a POST request on "${d}", but got ${Pr(y)}`);const{token:p}=y;return{token:p}})(c,n.url,{room:u.roomId})).token);if(r.has(f.raw)){const l=s(u);if(l?.raw===f.raw)return l;throw new Pn("The same Liveblocks auth token was issued from the backend before. Caching Liveblocks tokens is not supported.")}return t?.(f.parsed),f}if(n.type==="custom"){const f=await n.callback(u.roomId);if(f&&typeof f=="object"){if(typeof f.token=="string"){const l=kd(f.token);return t?.(l.parsed),l}if(typeof f.error=="string"){const l=`Authentication failed: ${"reason"in f&&typeof f.reason=="string"?f.reason:"Forbidden"}`;throw f.error==="forbidden"?new Pn(l):new Error(l)}}throw new Error('Your authentication callback function should return a token, but it did not. Hint: the return value should look like: { token: "..." }')}throw new Error("Unexpected authentication type. Must be private or custom.")}return{reset:function(){r.clear(),o.length=0,i.clear()},getAuthValue:async function(u){if(n.type==="public")return{type:"public",publicApiKey:n.publicApiKey};const c=s(u);if(c!==void 0)return{type:"secret",token:c};let f;const l=(function(d){if(d.roomId!==void 0)return`${d.roomId}:${d.resource}:${d.access}`})(u);l!==void 0?(f=i.get(l),f===void 0&&(f=a(u),i.set(l,f))):(f=i.get("liveblocks-user-token"),f===void 0&&(f=a(u),i.set("liveblocks-user-token",f)));try{const d=await f,h=30,g=Math.floor(Date.now()/1e3)+(d.parsed.exp-d.parsed.iat)-h;r.add(d.raw);const y=(function(p,w){return p.parsed.k==="acc"?{token:p,expiresAt:w,permissions:Object.entries(p.parsed.perms).map((([b,C])=>({pattern:b,scopes:Mc(C)})))}:{token:p,expiresAt:w}})(d,g);return o.push(y),{type:"secret",token:d}}finally{l!==void 0?i.delete(l):i.delete("liveblocks-user-token")}}}}function py(e,t){if(e.token.parsed.k==="id"||t.resource==="personal")return!0;if(t.roomId===void 0)return!1;const n=(function(r,o){const i=r.filter((u=>(function(c,f){return c.includes("*")?f.startsWith(c.replace("*","")):c===f})(u.pattern,o)));if(i.length===0)return;const s={},a={};for(const u of i){const c=nm(u.scopes),f=u.pattern.replace("*","").length;c.room!==void 0&&(s.room=Td(s.room??"none",c.room));for(const l of tm){const d=dy(c,l);if(d===void 0)continue;const h=a[l]??-1;f>h?(s[l]=d,a[l]=f):f===h&&(s[l]=Td(s[l]??"none",d))}}return rm(s)})(e.permissions??[],t.roomId);return n!==void 0&&fr(n,t.resource,t.access)}var On="@",qn=class om extends Lo{#e;constructor(t){super(),this.#e=t}get data(){return this.#e}static _deserialize([t,n],r,o){const i=new om(n.data);return i._attach(t,o),i}_toOps(t,n){if(this._id===void 0)throw new Error("Cannot serialize register if parentId or parentKey is undefined");return[{type:ue.CREATE_REGISTER,id:this._id,parentId:t,parentKey:n,data:this.data}]}_serialize(){if(this.parent.type!=="HasParent")throw new Error("Cannot serialize LiveRegister if parent is missing");return{type:je.REGISTER,parentId:ye(this.parent.node._id,"Parent node expected to have ID"),parentKey:this.parent.key,data:this.data}}_attachChild(t){throw new Error("Method not implemented.")}_detachChild(t){throw new Error("Method not implemented.")}_apply(t,n){return super._apply(t,n)}_toTreeNode(t){return{type:"Json",id:this._id??st(),key:t,payload:this.#e}}_toJSON(){return this.#e}clone(){return Ci(this.data)}};function my(e,t){return e._parentPos<t._parentPos}var yr=class Su extends Lo{#e;#t;constructor(t){super(),this.#t=new WeakSet;const n=[];let r;for(const o of t){const i=yn(r),s=bo(o);s._setParentLink(this,i),n.push(s),r=i}this.#e=ar.fromAlreadySorted(n,my)}static _deserialize([t,n],r,o){const i=new Su([]);i._attach(t,o);const s=r.get(t);if(s===void 0)return i;for(const a of s){const u=a[1],c=lm(a,r,o);c._setParentLink(i,u.parentKey),i.#n(c)}return i}_toOps(t,n){if(this._id===void 0)throw new Error("Cannot serialize item is not attached");const r=[],o={id:this._id,type:ue.CREATE_LIST,parentId:t,parentKey:n};r.push(o);for(const i of this.#e){const s=i._getParentKeyOrThrow(),a=Xo(i._toOps(this._id,s),"set");for(const u of a)r.push(u)}return r}#n(t){const n=this.#e.add(t);return this.invalidate(),n}#r(t,n){t._setParentLink(this,n),this.#e.reposition(t),this.invalidate()}#o(t,n){const r=ye(this.#e.at(t));this.#r(r,n)}_indexOfPosition(t){return this.#e.findIndex((n=>n._getParentKeyOrThrow()===t))}#i(t){if(this._pool===void 0||this._id===void 0)return;let n;for(const r of this._pool.unacknowledgedOps.getByParentIdAndKey(this._id,t))r.intent==="set"&&(n=r.opId);return n}_attach(t,n){super._attach(t,n);for(const r of this.#e)r._attach(n.generateId(),n)}_detach(){super._detach();for(const t of this.#e)t._detach()}#s(t){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");const{id:n,parentKey:r}=t,o=oi(t);o._attach(n,this._pool),o._setParentLink(this,r);const i=t.deletedId,s=this._indexOfPosition(r);if(s!==-1){const a=ye(this.#e.removeAt(s));if(a._id===i)return a._detach(),this.#e.add(o),{modified:ze(this,[Yr(s,o)],qt),reverse:[]};{this.#t.add(a),this.#e.remove(a),this.#e.add(o);const u=[Yr(s,o)],c=this.#a(t.deletedId,qt);return c&&u.push(c),{modified:ze(this,u,qt),reverse:[]}}}{const a=[],u=this.#a(t.deletedId,qt);return u&&a.push(u),this.#n(o),a.push(tn(this._indexOfPosition(r),o)),{reverse:[],modified:ze(this,a,qt)}}}#u(t,n){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");const r=[],o=this.#a(t.deletedId,n);o&&r.push(o);const i=this.#i(t.parentKey);if(i!==void 0&&i!==t.opId)return r.length===0?{modified:!1}:{modified:ze(this,r,n),reverse:[]};const s=this._indexOfPosition(t.parentKey),a=this.#e.find((u=>u._id===t.id));if(a!==void 0){if(a._parentKey===t.parentKey)return{modified:r.length>0&&ze(this,r,n),reverse:[]};if(s!==-1){const f=ye(this.#e.removeAt(s));this.#t.add(f),r.push(ts(s,f))}const u=this.#e.findIndex((f=>f===a));this.#r(a,t.parentKey);const c=this.#e.findIndex((f=>f===a));return c!==u&&r.push(er(u,c,a)),{modified:r.length>0&&ze(this,r,n),reverse:[]}}{const u=this._pool.getNode(t.id);if(u&&this.#t.has(u)){u._setParentLink(this,t.parentKey),this.#t.delete(u);const c=this.#n(u);return{modified:ze(this,[s===-1?tn(c,u):Yr(c,u),...r],n),reverse:[]}}{if(s!==-1){const l=ye(this.#e.removeAt(s));this.#t.add(l)}const{newItem:c,newIndex:f}=this.#b(t,t.parentKey);return{modified:ze(this,[s===-1?tn(f,c):Yr(f,c),...r],n),reverse:[]}}}}#a(t,n){if(t===void 0||this._pool===void 0)return null;const r=this._pool.getNode(t);if(r===void 0)return null;const o=this._detachChild(r,n);return o.modified===!1?null:o.modified.updates[0]}#c(t){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");const n=Ei(t.parentKey),r=this._indexOfPosition(n);r!==-1&&this.#C(r,n);const{newItem:o,newIndex:i}=this.#b(t,n),s=this.#m(n);return{modified:ze(this,[tn(i,o),...s],qt),reverse:[]}}*#f(){if(this._pool!==void 0&&this._id!==void 0)for(const t of this._pool.unacknowledgedOps.getByParentId(this._id)){if(t.intent!=="push"||this._pool.unacknowledgedOps.isPossiblyStored(t.opId))continue;const n=this._pool.getNode(t.id);n!==void 0&&this.#e.includes(n)&&(yield n)}}#m(t){const n=new Set(this.#f());if(n.size===0)return[];let r,o;for(const s of n){const a=s._parentPos;(r===void 0||a<r)&&(r=a)}if(t<ye(r))return[];for(const s of this.#e)n.has(s)||(o=s._parentPos);const i=[];for(const s of n){const a=this.#e.findIndex((c=>c===s));o=yn(o),this.#r(s,o);const u=this.#e.findIndex((c=>c===s));u!==a&&i.push(er(a,u,s))}return i}#g(t,n){const r=this.#e.find((s=>s._id===t.id)),o=Ei(t.parentKey),i=this._indexOfPosition(o);if(r){if(r._parentKey===o)return{modified:!1};{const s=this.#e.findIndex((u=>u===r));i!==-1&&this.#C(i,o),this.#r(r,o);const a=this._indexOfPosition(o);return a===s?{modified:!1}:{modified:ze(this,[er(s,a,r)],n),reverse:[]}}}{const s=ye(this._pool).getNode(t.id);if(s&&this.#t.has(s))return s._setParentLink(this,o),this.#t.delete(s),this.#n(s),{modified:ze(this,[tn(this._indexOfPosition(o),s)],n),reverse:[]};{i!==-1&&this.#C(i,o);const{newItem:a,newIndex:u}=this.#b(t,o);return{modified:ze(this,[tn(u,a)],n),reverse:[]}}}}#p(t,n){const{id:r,parentKey:o}=t,i=oi(t);if(this._pool?.getNode(r)!==void 0)return{modified:!1};i._attach(r,ye(this._pool)),i._setParentLink(this,o);const s=this._indexOfPosition(o);let a=o;if(s!==-1){const u=this.#e.at(s)?._parentPos,c=this.#e.at(s+1)?._parentPos;a=yn(u,c),i._setParentLink(this,a)}return this.#n(i),{modified:ze(this,[tn(this._indexOfPosition(a),i)],n),reverse:[{type:ue.DELETE_CRDT,id:r}]}}#h(t,n){const{id:r,parentKey:o}=t,i=oi(t);if(this._pool?.getNode(r)!==void 0)return{modified:!1};const s=this._indexOfPosition(o);i._attach(r,ye(this._pool)),i._setParentLink(this,o);const a=o;if(s!==-1){const u=this.#e.at(s);u._detach(),this.#e.remove(u),this.#e.add(i);const c=Xo(u._toOps(ye(this._id),o),"set",t.id),f=[Yr(s,i)],l=this.#a(t.deletedId,n);return l&&f.push(l),{modified:ze(this,f,n),reverse:c}}{this.#n(i),this.#a(t.deletedId,n);const u=this._indexOfPosition(a);return{reverse:[{type:ue.DELETE_CRDT,id:r}],modified:ze(this,[tn(u,i)],n)}}}_attachChild(t,n){const r=un(n);if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");let o;return o=t.intent==="set"?n.origin==="remote"?this.#s(t):n.optimistic?this.#h(t,r):this.#u(t,r):n.origin==="remote"?this.#c(t):n.optimistic?this.#p(t,r):this.#g(t,r),o.modified!==!1&&this.invalidate(),o}_detachChild(t,n){if(t){const r=ye(t._parentKey),o=t._toOps(ye(this._id),r),i=this.#e.findIndex((a=>a===t));if(i===-1)return{modified:!1};const s=this.#e.at(i);return this.#e.remove(t),this.invalidate(),t._detach(),{modified:ze(this,[ts(i,s)],n),reverse:o}}return{modified:!1}}#d(t,n){if(this.#t.has(n))return this.#t.delete(n),n._setParentLink(this,t),{modified:ze(this,[tn(this.#n(n),n)],qt),reverse:[]};if(t===n._parentKey)return{modified:!1};const r=this._indexOfPosition(t);if(r===-1){const o=this.#e.findIndex((s=>s===n));this.#r(n,t);const i=this.#e.findIndex((s=>s===n));return i===o?{modified:!1}:{modified:ze(this,[er(o,i,n)],qt),reverse:[]}}{this.#o(r,yn(t,this.#e.at(r+1)?._parentPos));const o=this.#e.findIndex((s=>s===n));this.#r(n,t);const i=this.#e.findIndex((s=>s===n));return i===o?{modified:!1}:{modified:ze(this,[er(o,i,n)],qt),reverse:[]}}}#v(t,n,r){const o=ye(n._parentKey);if(this.#t.has(n)){const i=this._indexOfPosition(t);if(this.#t.delete(n),i!==-1){const s=this.#e.at(i);s._setParentLink(this,yn(t,this.#e.at(i+1)?._parentPos)),this.#e.reposition(s)}return n._setParentLink(this,t),{modified:ze(this,[tn(this.#n(n),n)],r),reverse:[]}}{if(t===o)return{modified:!1};const i=this.#e.findIndex((u=>u===n)),s=this._indexOfPosition(t);s!==-1&&this.#o(s,yn(t,this.#e.at(s+1)?._parentPos)),this.#r(n,t);const a=this.#e.findIndex((u=>u===n));return i===a?{modified:!1}:{modified:ze(this,[er(i,a,n)],r),reverse:[]}}}#y(t,n,r){const o=ye(n._parentKey),i=this.#e.findIndex((c=>c===n)),s=this._indexOfPosition(t);let a=t;s!==-1&&(a=yn(t,this.#e.at(s+1)?._parentPos)),this.#r(n,a);const u=this.#e.findIndex((c=>c===n));return i===u?{modified:!1}:{modified:ze(this,[er(i,u,n)],r),reverse:[{type:ue.SET_PARENT_KEY,id:ye(n._id),parentKey:o}]}}_setChildKey(t,n,r){const o=un(r);return r.origin==="remote"?this.#d(t,n):r.optimistic?this.#y(t,n,o):this.#v(t,n,o)}_apply(t,n){return super._apply(t,n)}_serialize(){if(this.parent.type!=="HasParent")throw new Error("Cannot serialize LiveList if parent is missing");return{type:je.LIST,parentId:ye(this.parent.node._id,"Parent node expected to have ID"),parentKey:this.parent.key}}get length(){return this.#e.length}push(t){return this.#w(t,this.length,"push")}insert(t,n){return this.#w(t,n,"insert")}#w(t,n,r){if(this._warnIfOrphaned(),this._pool?.assertStorageIsWritable(),n<0||n>this.#e.length)throw new Error(`Cannot insert list item at index "${n}". index should be between 0 and ${this.#e.length}`);const o=this.#e.at(n-1)?._parentPos,i=this.#e.at(n)?._parentPos,s=yn(o,i),a=bo(t);if(a._setParentLink(this,s),this.#n(a),this._pool&&this._id){const u=this._pool.generateId();a._attach(u,this._pool);const c=a._toOpsWithOpId(this._id,s,this._pool);this._pool.dispatch(r==="push"?Xo(c,"push"):c,[{type:ue.DELETE_CRDT,id:u}],new Map([[this._id,ze(this,[tn(n,a)],St)]]))}}move(t,n){if(this._warnIfOrphaned(),this._pool?.assertStorageIsWritable(),n<0)throw new Error("targetIndex cannot be less than 0");if(n>=this.#e.length)throw new Error("targetIndex cannot be greater or equal than the list length");if(t<0)throw new Error("index cannot be less than 0");if(t>=this.#e.length)throw new Error("index cannot be greater or equal than the list length");let r=null,o=null;t<n?(o=n===this.#e.length-1?void 0:this.#e.at(n+1)?._parentPos,r=this.#e.at(n)._parentPos):(o=this.#e.at(n)._parentPos,r=n===0?void 0:this.#e.at(n-1)?._parentPos);const i=yn(r,o),s=this.#e.at(t),a=s._getParentKeyOrThrow();if(this.#o(t,i),this._pool&&this._id){const u=new Map([[this._id,ze(this,[er(t,n,s)],St)]]);this._pool.dispatch([{type:ue.SET_PARENT_KEY,id:ye(s._id),opId:this._pool.generateOpId(),parentKey:i}],[{type:ue.SET_PARENT_KEY,id:ye(s._id),parentKey:a}],u)}}delete(t){if(this._warnIfOrphaned(),this._pool?.assertStorageIsWritable(),t<0||t>=this.#e.length)throw new Error(`Cannot delete list item at index "${t}". index should be between 0 and ${this.#e.length-1}`);const n=this.#e.at(t);if(n._detach(),this.#e.remove(n),this.invalidate(),this._pool){const r=n._id;if(r){const o=new Map;o.set(ye(this._id),ze(this,[ts(t,n)],St)),this._pool.dispatch([{id:r,opId:this._pool.generateOpId(),type:ue.DELETE_CRDT}],n._toOps(ye(this._id),n._getParentKeyOrThrow()),o)}}}clear(){if(this._warnIfOrphaned(),this._pool?.assertStorageIsWritable(),this._pool){const t=[],n=[],r=[];for(const i of this.#e){i._detach();const s=i._id;s&&(t.push({type:ue.DELETE_CRDT,id:s,opId:this._pool.generateOpId()}),n.push(...i._toOps(ye(this._id),i._getParentKeyOrThrow())),r.push(ts(0,i)))}this.#e.clear(),this.invalidate();const o=new Map;o.set(ye(this._id),ze(this,r,St)),this._pool.dispatch(t,n,o)}else{for(const t of this.#e)t._detach();this.#e.clear(),this.invalidate()}}set(t,n){if(this._warnIfOrphaned(),this._pool?.assertStorageIsWritable(),t<0||t>=this.#e.length)throw new Error(`Cannot set list item at index "${t}". index should be between 0 and ${this.#e.length-1}`);const r=this.#e.at(t),o=r._getParentKeyOrThrow(),i=r._id;r._detach();const s=bo(n);if(s._setParentLink(this,o),this.#e.remove(r),this.#e.add(s),this.invalidate(),this._pool&&this._id){const a=this._pool.generateId();s._attach(a,this._pool);const u=new Map;u.set(this._id,ze(this,[Yr(t,s)],St));const c=Xo(s._toOpsWithOpId(this._id,o,this._pool),"set",i),f=Xo(r._toOps(this._id,o),"set",a);this._pool.dispatch(c,f,u)}}#l(t){return Tr(t)}every(t){return this.#e.rawArray.every(((n,r)=>t(this.#l(n),r)))}filter(t){const n=[];return this.#e.rawArray.forEach(((r,o)=>{const i=this.#l(r);t(i,o)&&n.push(i)})),n}find(t){for(const[n,r]of this.#e.rawArray.entries()){const o=this.#l(r);if(t(o,n))return o}}findIndex(t){return this.#e.rawArray.findIndex(((n,r)=>t(this.#l(n),r)))}forEach(t){this.#e.rawArray.forEach(((n,r)=>t(this.#l(n),r)))}get(t){const n=this.#e.at(t);return n!==void 0?this.#l(n):void 0}indexOf(t,n){return this.#e.rawArray.findIndex(((r,o)=>o>=(n??0)&&this.#l(r)===t))}lastIndexOf(t,n){const r=this.#e.rawArray;for(let o=n??r.length-1;o>=0;o--)if(this.#l(r[o])===t)return o;return-1}map(t){return this.#e.rawArray.map(((n,r)=>t(this.#l(n),r)))}some(t){return this.#e.rawArray.some(((n,r)=>t(this.#l(n),r)))}*[Symbol.iterator](){for(const t of this.#e)yield this.#l(t)}#b(t,n){const r=oi(t);return r._attach(t.id,ye(this._pool)),r._setParentLink(this,n),this.#n(r),{newItem:r,newIndex:this._indexOfPosition(n)}}#C(t,n){const r=yn(n,this.#e.length>t+1?this.#e.at(t+1)?._parentPos:void 0);this.#o(t,r)}_toTreeNode(t){const n=[];let r=0;for(const o of this.#e)n.push(o.toTreeNode(r.toString())),r++;return{type:"LiveList",id:this._id??st(),key:t,payload:n}}toJSON(){return super.toJSON()}_toJSON(){return Array.from(this.#e,(n=>n.toJSON()))}clone(){return new Su(Array.from(this.#e,(t=>t.clone())))}};function ze(e,t,n){return{node:e,type:"LiveList",updates:t,source:n}}function Yr(e,t){return{index:e,type:"set",item:t instanceof qn?t.data:t}}function ts(e,t){return{type:"delete",index:e,deletedItem:t instanceof qn?t.data:t}}function tn(e,t){return{index:e,type:"insert",item:t instanceof qn?t.data:t}}function er(e,t,n){return{type:"move",index:t,item:n instanceof qn?n.data:n,previousIndex:e}}function Xo(e,t,n){return e.map(((r,o)=>o===0?{...r,intent:t,deletedId:n}:r))}var qr=class Iu extends Lo{#e;#t;constructor(t){if(super(),this.#t=new Map,t){const n=[];for(const[r,o]of t){const i=bo(o);i._setParentLink(this,r),n.push([r,i])}this.#e=new Map(n)}else this.#e=new Map}_toOps(t,n){if(this._id===void 0)throw new Error("Cannot serialize item is not attached");const r=[],o={id:this._id,type:ue.CREATE_MAP,parentId:t,parentKey:n};r.push(o);for(const[i,s]of this.#e)for(const a of s._toOps(this._id,i))r.push(a);return r}static _deserialize([t,n],r,o){const i=new Iu;i._attach(t,o);const s=r.get(t);if(s===void 0)return i;for(const a of s){const u=a[1],c=lm(a,r,o);c._setParentLink(i,u.parentKey),i.#e.set(u.parentKey,c),i.invalidate()}return i}_attach(t,n){super._attach(t,n);for(const[r,o]of this.#e)ot(o)&&o._attach(n.generateId(),n)}_attachChild(t,n){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");const{id:r,parentKey:o,opId:i}=t,s=o,a=oi(t);if(this._pool.getNode(r)!==void 0)return{modified:!1};if(n.origin==="remote")this.#t.delete(s);else if(!n.optimistic){const f=this.#t.get(s);if(f===i)return this.#t.delete(s),{modified:!1};if(f!==void 0)return{modified:!1}}const u=this.#e.get(s);let c;if(u){const f=ye(this._id);c=u._toOps(f,s),u._detach()}else c=[{type:ue.DELETE_CRDT,id:r}];return a._setParentLink(this,s),a._attach(r,this._pool),this.#e.set(s,a),this.invalidate(),{modified:{node:this,type:"LiveMap",updates:{[s]:{type:"update"}},source:un(n)},reverse:c}}_detach(){super._detach();for(const t of this.#e.values())t._detach()}_detachChild(t,n){const r=ye(this._id),o=ye(t._parentKey),i=t._toOps(r,o);for(const[s,a]of this.#e)a===t&&(this.#e.delete(s),this.invalidate());return t._detach(),{modified:{node:this,type:"LiveMap",updates:{[o]:{type:"delete",deletedItem:Tr(t)}},source:n},reverse:i}}_serialize(){if(this.parent.type!=="HasParent")throw new Error("Cannot serialize LiveMap if parent is missing");return{type:je.MAP,parentId:ye(this.parent.node._id,"Parent node expected to have ID"),parentKey:this.parent.key}}get(t){const n=this.#e.get(t);if(n!==void 0)return Tr(n)}set(t,n){this._warnIfOrphaned(),this._pool?.assertStorageIsWritable();const r=this.#e.get(t);r&&r._detach();const o=bo(n);if(o._setParentLink(this,t),this.#e.set(t,o),this.invalidate(),this._pool&&this._id){const i=this._pool.generateId();o._attach(i,this._pool);const s=new Map;s.set(this._id,{node:this,type:"LiveMap",updates:{[t]:{type:"update"}},source:St});const a=o._toOpsWithOpId(this._id,t,this._pool);this.#t.set(t,ye(a[0].opId)),this._pool.dispatch(a,r?r._toOps(this._id,t):[{type:ue.DELETE_CRDT,id:i}],s)}}get size(){return this.#e.size}has(t){return this.#e.has(t)}delete(t){this._warnIfOrphaned(),this._pool?.assertStorageIsWritable();const n=this.#e.get(t);if(n===void 0)return!1;if(n._detach(),this.#e.delete(t),this.invalidate(),this._pool&&n._id){const r=ye(this._id),o=new Map;o.set(r,{node:this,type:"LiveMap",updates:{[t]:{type:"delete",deletedItem:Tr(n)}},source:St}),this._pool.dispatch([{type:ue.DELETE_CRDT,id:n._id,opId:this._pool.generateOpId()}],n._toOps(r,t),o)}return!0}entries(){const t=this.#e.entries();return{[Symbol.iterator](){return this},next(){const n=t.next();return n.done?{done:!0,value:void 0}:{value:[n.value[0],Tr(n.value[1])]}}}}[Symbol.iterator](){return this.entries()}keys(){return this.#e.keys()}values(){const t=this.#e.values();return{[Symbol.iterator](){return this},next(){const n=t.next();return n.done?{done:!0,value:void 0}:{value:Tr(n.value)}}}}forEach(t){for(const n of this)t(n[1],n[0],this)}_toTreeNode(t){return{type:"LiveMap",id:this._id??st(),key:t,payload:Array.from(this.#e.entries()).map((([n,r])=>r.toTreeNode(n)))}}toJSON(){return super.toJSON()}_toJSON(){const t={};for(const[n,r]of this.#e)t[n]=r.toJSON();return t}clone(){return new Iu(Array.from(this.#e).map((([t,n])=>[t,n.clone()])))}};function Nr(e,t){if(Array.isArray(e))return new yr(e.map((n=>Nr(n,t))));if(gt(e)){const n={},r={};for(const i in e){const s=e[i];if(s===void 0)continue;const a=gt(t)?t[i]:t;a===!1?r[i]=s:n[i]=a==="atomic"?s:Nr(s,a)}const o=new Gn(n);for(const i in r)o.setLocal(i,r[i]);return o}return e}function im(e,t,n){return Hc(e)&&gt(t)?Tu(e,t,"full",n):Uc(e)&&Array.isArray(t)?(function(r,o,i){const s=r.length,a=o.length;for(let u=0;u<Math.min(s,a);u++){const c=r.get(u),f=o[u];if(ur(c)){const l=im(c,f,i);l!==c&&r.set(u,l)}else c!==f&&r.set(u,Nr(f,i))}for(let u=s;u<a;u++)r.push(Nr(o[u],i));for(let u=s-1;u>=a;u--)r.delete(u);return r})(e,t,n):dm(e)&&gt(t)?(function(){throw new Error("Reconciling a LiveMap is not supported yet")})():fm(e)&&lt(e.data,t)?e:Nr(t,n)}function Tu(e,t,n,r){const o=e.keys();for(const i in t){o.delete(i);const s=t[i];if(s===void 0){n==="full"&&e.delete(i);continue}const a=gt(r)?r[i]:r;if(a===!1)e.setLocal(i,s);else if(a==="atomic")e.get(i)!==s&&e.set(i,s);else{const u=e.get(i);if(u===void 0)e.set(i,Nr(s,a));else if(ur(u)){const c=im(u,s,a);c!==u&&e.set(i,c)}else u!==s&&e.set(i,Nr(s,a))}}if(n==="full")for(const i of o)e.delete(i);return e}var _d=131072,Gn=class Ar extends Lo{#e;#t=new Map;#n;static detectLargeObjects=!1;static#r(t){const n=new Map;let r=null;for(const o of t)if(A1(o))r=o[1];else{const i=o[1],s=n.get(i.parentId);s!==void 0?s.push(o):n.set(i.parentId,[o])}if(r===null)throw new Error("Root can't be null");return[r,n]}static _fromItems(t,n){const[r,o]=Ar.#r(t);return Ar._deserialize(["root",r],o,n)}constructor(t={}){super(),this.#n=new Map;const n=wi(t);for(const r of Object.keys(n)){const o=n[r];ot(o)&&o._setParentLink(this,r)}this.#e=new Map(Object.entries(n))}_toOps(t,n){if(this._id===void 0)throw new Error("Cannot serialize item is not attached");const r=[],o={type:ue.CREATE_OBJECT,id:this._id,parentId:t,parentKey:n,data:{}};r.push(o);for(const[i,s]of this.#e)if(ot(s))for(const a of s._toOps(this._id,i))r.push(a);else o.data[i]=s;return r}static _deserialize([t,n],r,o){const i=new Ar(n.data);return i._attach(t,o),this._deserializeChildren(i,r,o)}static _deserializeChildren(t,n,r){const o=n.get(ye(t._id));if(o===void 0)return t;for(const i of o){const s=xy(i,n,r),a=i[1];ur(s)&&s._setParentLink(t,a.parentKey),t.#e.set(a.parentKey,s),t.invalidate()}return t}_attach(t,n){super._attach(t,n);for(const[r,o]of this.#e)ot(o)&&o._attach(n.generateId(),n)}_attachChild(t,n){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");const{id:r,opId:o,parentKey:i}=t,s=um(t);if(this._pool.getNode(r)!==void 0)return this.#n.get(i)===o&&this.#n.delete(i),{modified:!1};if(n.origin==="local"&&n.optimistic)this.#n.set(i,ye(o));else if(this.#n.get(i)!==void 0)return this.#n.get(i)===o?(this.#n.delete(i),{modified:!1}):{modified:!1};const a=ye(this._id),u=this.#e.get(i);let c;return ot(u)?(c=u._toOps(a,i),u._detach()):c=u===void 0?[{type:ue.DELETE_OBJECT_KEY,id:a,key:i}]:[{type:ue.UPDATE_OBJECT,id:a,data:{[i]:u}}],this.#t.delete(i),this.#e.set(i,s),this.invalidate(),ur(s)&&(s._setParentLink(this,i),s._attach(r,this._pool)),{reverse:c,modified:{node:this,type:"LiveObject",updates:{[i]:{type:"update"}},source:un(n)}}}_detachChild(t,n){if(t){const r=ye(this._id),o=ye(t._parentKey),i=t._toOps(r,o),s=Tr(t);for(const[a,u]of this.#e)u===t&&(this.#e.delete(a),this.invalidate());return t._detach(),{modified:{node:this,type:"LiveObject",updates:{[o]:{type:"delete",deletedItem:s}},source:n},reverse:i}}return{modified:!1}}_detach(){super._detach();for(const t of this.#e.values())ot(t)&&t._detach()}_apply(t,n){return t.type===ue.UPDATE_OBJECT?this.#o(t,n):t.type===ue.DELETE_OBJECT_KEY?this.#i(t,n):super._apply(t,n)}_serialize(){const t={};for(const[n,r]of this.#e)ot(r)||(t[n]=r);return this.parent.type==="HasParent"&&this.parent.node._id?{type:je.OBJECT,parentId:this.parent.node._id,parentKey:this.parent.key,data:t}:{type:je.OBJECT,data:t}}#o(t,n){let r=!1;const o=ye(this._id),i=[],s={type:ue.UPDATE_OBJECT,id:o,data:{}};for(const u in t.data){const c=this.#e.get(u);if(ot(c)){for(const f of c._toOps(o,u))i.push(f);c._detach()}else c!==void 0?s.data[u]=c:c===void 0&&i.push({type:ue.DELETE_OBJECT_KEY,id:o,key:u})}const a={};for(const u in t.data){const c=t.data[u];if(c===void 0)continue;if(n.origin==="local"&&n.optimistic)this.#n.set(u,ye(t.opId));else{if(this.#n.get(u)!==void 0){if(this.#n.get(u)===t.opId){this.#n.delete(u);continue}continue}r=!0}const f=this.#e.get(u);ot(f)&&f._detach(),r=!0,a[u]={type:"update"},this.#t.delete(u),this.#e.set(u,c),this.invalidate()}return Object.keys(s.data).length!==0&&i.unshift(s),r?{modified:{node:this,type:"LiveObject",updates:a,source:un(n)},reverse:i}:{modified:!1}}#i(t,n){const r=t.key,o=this.#e.get(r);if(o===void 0)return{modified:!1};if((n.origin!=="local"||!n.optimistic)&&this.#n.get(r)!==void 0)return{modified:!1};const i=ye(this._id);let s=[];return ot(o)?(s=o._toOps(i,t.key),o._detach()):o!==void 0&&(s=[{type:ue.UPDATE_OBJECT,id:i,data:{[r]:o}}]),this.#t.delete(r),this.#e.delete(r),this.invalidate(),{modified:{node:this,type:"LiveObject",updates:{[t.key]:{type:"delete",deletedItem:o}},source:un(n)},reverse:s}}keys(){const t=new Set(this.#e.keys());for(const n of this.#t.keys())t.add(n);return t}set(t,n){this.update({[t]:n})}setLocal(t,n){this._warnIfOrphaned(),this._pool?.assertStorageIsWritable();const r=this.#s(t);if(this.#t.set(t,n),this.invalidate(),this._pool!==void 0&&this._id!==void 0){const o=r?.[0]??[],i=r?.[1]??[],s=r?.[2]??new Map,a=s.get(this._id);s.set(this._id,{node:this,type:"LiveObject",updates:{...a?.updates,[t]:{type:"update"}},source:St}),this._pool.dispatch(o,i,s)}}get(t){return this.#t.has(t)?this.#t.get(t):this.#e.get(t)}#s(t){this._warnIfOrphaned(),this._pool?.assertStorageIsWritable();const n=t;if(this.#t.has(n)&&!this.#e.has(n)){const a=this.#t.get(n);if(this.#t.delete(n),this.invalidate(),this._pool!==void 0&&this._id!==void 0){const u=new Map;return u.set(this._id,{node:this,type:"LiveObject",updates:{[n]:{type:"delete",deletedItem:a}},source:St}),[[],[],u]}return null}this.#t.delete(n);const r=this.#e.get(n);if(r===void 0)return null;if(this._pool===void 0||this._id===void 0)return ot(r)&&r._detach(),this.#e.delete(n),this.invalidate(),null;const o=[{type:ue.DELETE_OBJECT_KEY,key:n,id:this._id,opId:this._pool.generateOpId()}];let i;ot(r)?(r._detach(),i=r._toOps(this._id,n)):i=[{type:ue.UPDATE_OBJECT,data:{[n]:r},id:this._id}],this.#e.delete(n),this.invalidate();const s=new Map;return s.set(this._id,{node:this,type:"LiveObject",updates:{[t]:{type:"delete",deletedItem:r}},source:St}),[o,i,s]}delete(t){const n=this.#s(t);if(n){const[r,o,i]=n;this._pool?.dispatch(r,o,i)}}update(t){if(this._warnIfOrphaned(),this._pool?.assertStorageIsWritable(),Ar.detectLargeObjects){const c={};for(const[l,d]of this.#e)ot(d)||(c[l]=d);for(const l of Object.keys(t)){const d=t[l];d!==void 0&&(ot(d)||(c[l]=d))}const f=JSON.stringify(c);if(4*f.length>_d){const l=new TextEncoder().encode(f).length;if(l>_d)throw new Error(`LiveObject size exceeded limit: ${l} bytes > 131072 bytes. See https://liveblocks.io/docs/pricing/limits#Other-limits`)}}if(this._pool===void 0||this._id===void 0){for(const c in t){const f=t[c];if(f===void 0)continue;const l=this.#e.get(c);ot(l)&&l._detach(),ot(f)&&f._setParentLink(this,c),this.#t.delete(c),this.#e.set(c,f),this.invalidate()}return}const n=[],r=[],o=this._pool.generateOpId(),i={},s={id:this._id,type:ue.UPDATE_OBJECT,data:{}},a={};for(const c in t){const f=t[c];if(f===void 0)continue;const l=this.#e.get(c);if(l!==f){if(ot(l)){for(const d of l._toOps(this._id,c))r.push(d);l._detach()}else l===void 0?r.push({type:ue.DELETE_OBJECT_KEY,id:this._id,key:c}):s.data[c]=l;if(ot(f)){f._setParentLink(this,c),f._attach(this._pool.generateId(),this._pool);const d=f._toOpsWithOpId(this._id,c,this._pool),h=d.find((g=>g.parentId===this._id));h&&this.#n.set(c,ye(h.opId));for(const g of d)n.push(g)}else i[c]=f,this.#n.set(c,o);this.#t.delete(c),this.#e.set(c,f),this.invalidate(),a[c]={type:"update"}}}if(Object.keys(s.data).length!==0&&r.unshift(s),Object.keys(i).length!==0&&n.unshift({opId:o,id:this._id,type:ue.UPDATE_OBJECT,data:i}),n.length===0&&r.length===0&&Object.keys(a).length===0)return;const u=new Map;u.set(this._id,{node:this,type:"LiveObject",updates:a,source:St}),this._pool.dispatch(n,r,u)}static from(t,n){if(!gt(t))throw new Error("Expected a JSON object");const r=new Ar({});return r.reconcile(t,n),r}reconcile(t,n){if(!this.hasCache(t)){if(!gt(t))throw new Error("Reconciling the document root expects a plain object value");Tu(this,t,"full",n)}}reconcilePartially(t,n){if(!gt(t))throw new Error("Reconciling the document root expects a plain object value");Tu(this,t,"partial",n)}toTreeNode(t){return super.toTreeNode(t)}_toTreeNode(t){const n=this._id??st();return{type:"LiveObject",id:n,key:t,payload:Array.from(this.#e.entries()).map((([r,o])=>ot(o)?o.toTreeNode(r):{type:"Json",id:`${n}:${r}`,key:r,payload:o}))}}toJSON(){return super.toJSON()}_toJSON(){const t={};for(const[n,r]of this.#e)t[n]=ur(r)?r.toJSON():r;for(const[n,r]of this.#t)t[n]=r;return t}clone(){const t=new Ar(Object.fromEntries(Array.from(this.#e).map((([n,r])=>[n,ur(r)?r.clone():Ci(r)]))));for(const[n,r]of this.#t)t.#t.set(n,Ci(r));return t}};function gy(e,t){if(e===t)return!0;if(e===void 0||t===void 0)return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n)if(e[o]!==t[o])return!1;return!0}function vy(e){return e===void 0?void 0:{...e}}function Oo(e){const t=[];for(const n of e){if(n.text.length===0)continue;const r=t.at(-1),o=vy(n.attributes);r!==void 0&&gy(r.attributes,o)?r.text+=n.text:t.push({text:n.text,attributes:o})}return t}function Bd(e){return Oo(e.map((([t,n])=>({text:t,attributes:n}))))}function Ta(e){return e.map((t=>t.attributes===void 0?[t.text]:[t.text,{...t.attributes}]))}function co(e){return e.reduce(((t,n)=>t+n.text.length),0)}function $n(e,t){const n=[];let r=0;for(const o of e){const i=r+o.text.length;if(t>r&&t<i){const s=o.text.slice(0,t-r),a=o.text.slice(t-r);n.push({text:s,attributes:o.attributes}),n.push({text:a,attributes:o.attributes})}else n.push({text:o.text,attributes:o.attributes});r=i}return n}function ku(e,t,n){const r=Math.max(0,Math.min(e,n));return{index:r,length:Math.max(r,Math.min(e+t,n))-r}}function _u(e,t){const n=e.charCodeAt(t-1),r=e.charCodeAt(t);return n>=55296&&n<=56319&&r>=56320&&r<=57343}function sm(e,t){const n=Math.max(0,Math.min(t,e.length));return _u(e,n)?n-1:n}function ka(e,t,n){const r=ku(t,n,e.length);if(r.length===0)return{index:sm(e,r.index),length:0};const o=r.index+r.length,i=_u(e,r.index)?r.index-1:r.index;return{index:i,length:(_u(e,o)?o+1:o)-i}}function Pc(e,t,n,r){if(n.length===0)return Oo(e);const o=$n(e,t),i=[];let s=0,a=!1;for(const u of o)a||s!==t||(i.push({text:n,attributes:r}),a=!0),i.push(u),s+=u.text.length;return a||i.push({text:n,attributes:r}),Oo(i)}function am(e,t,n){const r=$n($n(e,t),t+n),o=[];let i=0;for(const s of r){const a=i+s.text.length;i>=t&&a<=t+n&&o.push({text:s.text,attributes:s.attributes}),i=a}return Oo(o)}function Nc(e,t,n){const r=am(e,t,n),o=$n($n(e,t),t+n),i=[];let s=0,a="";for(const u of o){const c=s+u.text.length;s>=t&&c<=t+n?a+=u.text:i.push(u),s=c}return{segments:Oo(i),deletedText:a,deletedSegments:r}}function Lc(e,t,n,r){const o=$n($n(e,t),t+n),i=[];let s=0;for(const a of o){const u=s+a.text.length;if(s>=t&&u<=t+n){const c={...a.attributes??{}};for(const[f,l]of Object.entries(r))l===null?delete c[f]:c[f]=l;i.push({text:a.text,attributes:Object.keys(c).length===0?void 0:c})}else i.push(a);s=u}return Oo(i)}function yy(e,t,n,r){const o=$n($n(e,t),t+n),i=[];let s=0;for(const a of o){const u=s+a.text.length;if(s>=t&&u<=t+n){const c={},f=a.attributes??{};for(const l of Object.keys(r)){const d=Object.hasOwn(f,l)?f[l]:void 0;c[l]=d??null}i.push({type:"format",index:s,length:a.text.length,attributes:c})}s=u}return i}function by(e,t){return t.type==="insert"?t.index<=e?e+t.text.length:e:t.type==="delete"?t.index>=e?e:Math.max(t.index,e-t.length):e}function _a(e,t){let n=e;for(const r of t)n=by(n,r);return n}function Cy(e,t){return t.type==="insert"?e<=t.index?e:Math.max(t.index,e-t.text.length):t.type==="delete"&&t.index<=e?e+t.length:e}function Fd(e,t){let n=e;for(let r=t.length-1;r>=0;r--)n=Cy(n,t[r]);return n}function wy(e){return e==="before"?"after":"before"}function Yo(e,t,n){return t>=e?e:Math.max(t,e-n)}function Rd(e,t,n){switch(e.type){case"insert":return(function(r,o,i){return o.type==="insert"?[o.index<r.index||o.index===r.index&&i==="after"?{...r,index:r.index+o.text.length}:{...r}]:o.type==="delete"?[{...r,index:Yo(r.index,o.index,o.length)}]:[{...r}]})(e,t,n);case"delete":return(function(r,o){const i=r.index,s=r.index+r.length;if(o.type==="insert"){const a=o.index,u=o.text.length;return a<=i?[{...r,index:i+u}]:a>=s?[{...r}]:[{type:"delete",index:i,length:a-i},{type:"delete",index:i+u,length:s-a}]}if(o.type==="delete"){const a=Yo(i,o.index,o.length),u=Yo(s,o.index,o.length);return u-a>0?[{type:"delete",index:a,length:u-a}]:[]}return[{...r}]})(e,t);case"format":return(function(r,o,i){const s=r.index,a=r.index+r.length;if(o.type==="insert"){const u=o.index,c=o.text.length;return u<=s?[{...r,index:s+c}]:u>=a?[{...r}]:[{type:"format",index:s,length:u-s,attributes:r.attributes},{type:"format",index:u+c,length:a-u,attributes:r.attributes}]}if(o.type==="delete"){const u=Yo(s,o.index,o.length),c=Yo(a,o.index,o.length);return c-u>0?[{type:"format",index:u,length:c-u,attributes:r.attributes}]:[]}{if(i==="after")return[{...r}];const u=Math.max(s,o.index),c=Math.min(a,o.index+o.length);if(u>=c)return[{...r}];if(!Object.keys(r.attributes).some((d=>Object.hasOwn(o.attributes,d))))return[{...r}];const f={};for(const[d,h]of Object.entries(r.attributes))Object.hasOwn(o.attributes,d)||(f[d]=h);const l=[];return s<u&&l.push({type:"format",index:s,length:u-s,attributes:r.attributes}),Object.keys(f).length>0&&l.push({type:"format",index:u,length:c-u,attributes:f}),c<a&&l.push({type:"format",index:c,length:a-c,attributes:r.attributes}),l}})(e,t,n)}}function Br(e,t,n){if(e.length===0||t.length===0)return[[...e],[...t]];if(e.length===1&&t.length===1)return[Rd(e[0],t[0],n),Rd(t[0],e[0],wy(n))];if(e.length>1){const[a,u]=Br([e[0]],t,n),[c,f]=Br(e.slice(1),u,n);return[[...a,...c],f]}const[r,o]=Br(e,[t[0]],n),[i,s]=Br(r,t.slice(1),n);return[i,[...o,...s]]}function Ey(e,t,n){return Br(e,t,n)[0]}function Ba(e,t){let n=[...e];for(const r of t)if(r.type==="insert")n=Pc(n,Math.max(0,Math.min(r.index,co(n))),r.text,r.attributes);else if(r.type==="delete"){const o=ku(Math.max(0,Math.min(r.index,co(n))),r.length,co(n));n=Nc(n,o.index,o.length).segments}else{const o=ku(Math.max(0,Math.min(r.index,co(n))),r.length,co(n));n=Lc(n,o.index,o.length,r.attributes)}return n}function Dy(e,t){let n=[...e];const r=[];for(const o of t)if(o.type==="insert")n=Pc(n,o.index,o.text,o.attributes),r.unshift({type:"delete",index:o.index,length:o.text.length});else if(o.type==="delete"){const i=am(n,o.index,o.length);n=Nc(n,o.index,o.length).segments;const s=[];let a=o.index;for(const u of i)s.push({type:"insert",index:a,text:u.text,attributes:u.attributes}),a+=u.text.length;for(let u=s.length-1;u>=0;u--)r.unshift(s[u])}else{const i=yy(n,o.index,o.length,o.attributes);n=Lc(n,o.index,o.length,o.attributes),r.unshift(...i.reverse())}return r}var Ho=class Bu extends Lo{#e;#t;#n;#r;#o=[];#i=[];#s=[];constructor(t="",n=0){super(),this.#e=typeof t=="string"?t.length===0?[]:[{text:t}]:Bd(t),this.#t=[...this.#e],this.#n=n,Object.assign(this[Oe],{encodeIndex:r=>this.#u(r),decodeIndex:(r,o)=>this.#a(r,o)})}get version(){return this.#n}get length(){return co(this.#e)}static _deserialize([t,n],r,o){const i=new Bu(n.data,n.version);return i._attach(t,o),i}_toOps(t,n){if(this._id===void 0)throw new Error("Cannot serialize LiveText if it is not attached");return[{type:ue.CREATE_TEXT,id:this._id,parentId:t,parentKey:n,data:this.toJSON(),version:this.#n}]}_serialize(){if(this.parent.type!=="HasParent")throw new Error("Cannot serialize LiveText if parent is missing");return{type:je.TEXT,parentId:ye(this.parent.node._id,"Parent node expected to have ID"),parentKey:this.parent.key,data:this.toJSON(),version:this.#n}}_attachChild(t){throw new Error("LiveText cannot contain child nodes")}_detachChild(t){throw new Error("LiveText cannot contain child nodes")}_apply(t,n){return t.type!==ue.UPDATE_TEXT?super._apply(t,n):n.origin==="local"&&n.optimistic?this.#f(t,un(n)):t.opId!==void 0&&t.opId===this.#r?this.#m(t,un(n)):t.opId!==void 0&&this.#s.some((r=>r.opId===t.opId))?(this.#n=Math.max(this.#n,t.version??t.baseVersion+1),{modified:!1}):this.#g(t,un(n))}insert(t,n,r){const o=sm(this.toString(),t);this.#c([{type:"insert",index:o,text:n,attributes:r}])}delete(t,n){const r=ka(this.toString(),t,n);r.length!==0&&this.#c([{type:"delete",index:r.index,length:r.length}])}replace(t,n,r,o){const i=ka(this.toString(),t,n),s=[];i.length>0&&s.push({type:"delete",index:i.index,length:i.length}),r.length>0&&s.push({type:"insert",index:i.index,text:r,attributes:o}),this.#c(s)}#u(t){let n=Math.max(0,Math.min(t,this.length));return n=Fd(n,this.#i),n=Fd(n,this.#o),n}#a(t,n){if(n>this.#n)return null;if(n<this.#n){const o=this.#s[0]?.version;if(o===void 0||o>n+1)return null}let r=t;for(const o of this.#s)if(!(o.version<=n)){if(o.version>this.#n)break;o.ops.length!==0&&(r=_a(r,o.ops))}return r=_a(r,this.#o),r=_a(r,this.#i),Math.max(0,Math.min(r,this.length))}format(t,n,r){const o=ka(this.toString(),t,n);o.length!==0&&this.#c([{type:"format",index:o.index,length:o.length,attributes:r}])}#c(t){if(t.length===0)return;this._warnIfOrphaned(),this._pool?.assertStorageIsWritable();const n=this._pool!==void 0&&this._id!==void 0,r=n?this.#y(t):[],o=this.#v(t);if(!n)return;const i=ye(this._pool),s=ye(this._id),a=new Map([[s,{type:"LiveText",node:this,version:this.#n,updates:o,source:St}]]);if(this.#r===void 0){const u=i.generateOpId();this.#r=u,this.#o=[...t],i.dispatch([{type:ue.UPDATE_TEXT,id:s,opId:u,baseVersion:this.#n,ops:[...t]}],r,a)}else this.#i.push(...t),i.dispatch([],r,a,{clearRedoStack:!0})}#f(t,n){const r=t;if(t.opId!==void 0&&t.opId===this.#r)return this.#o=[...this.#o,...this.#i],this.#i=[],r.baseVersion=this.#n,r.ops=[...this.#o],{modified:!1};let o=t.ops;for(const a of this.#s)a.version>t.baseVersion&&a.ops.length>0&&(o=Ey(o,a.ops,"after"));const i=this.#y(o),s=this.#v(o);return this.#r===void 0&&o.length>0?(this.#r=ye(t.opId,"Local ops must have an opId"),this.#o=[...o],r.baseVersion=this.#n,r.ops=[...o]):(this.#i.push(...o),r.baseVersion=this.#n,r.ops=[]),s.length===0?{modified:!1}:{reverse:i,modified:{type:"LiveText",node:this,version:this.#n,updates:s,source:n}}}#m(t,n){const r=t.version??Math.max(this.#n,t.baseVersion+1),o=this.#o,i=this.#r;this.#t=Ba(this.#t,t.ops),this.#r=void 0,this.#o=[];let s=[],a={modified:!1};if((u=t.ops)!==(c=o)&&Yt(u)!==Yt(c)){Vn("LiveText: acknowledgement did not match the local prediction; resynchronizing");const f=this.#h();s=f.appliedOps,f.changes.length>0&&(a={reverse:[],modified:{type:"LiveText",node:this,version:r,updates:f.changes,source:n}})}var u,c;return this.#n=Math.max(this.#n,r),this.#d(r,s,i),this.#p(),a}#g(t,n){const r=t.version??this.#n+1;this.#t=Ba(this.#t,t.ops);const[o,i]=Br(t.ops,this.#o,"before"),[s,a]=Br(o,this.#i,"before");if(this.#o=i,this.#i=a,this.#d(r,s,t.opId),s.length===0)return this.#n=Math.max(this.#n,r),{modified:!1};const u=this.#y(s),c=this.#v(s);return this.#n=Math.max(this.#n,r),{reverse:u,modified:{type:"LiveText",node:this,version:this.#n,updates:c,source:n}}}#p(){if(this.#i.length===0||this._pool===void 0||this._id===void 0)return;const t=this._pool.generateOpId();this.#r=t,this.#o=this.#i,this.#i=[],this._pool.dispatch([{type:ue.UPDATE_TEXT,id:this._id,opId:t,baseVersion:this.#n,ops:[...this.#o]}],[],new Map,{clearRedoStack:!1})}#h(){const t=this.#e,n=Ba(this.#t,[...this.#o,...this.#i]);if(Yt(Ta(t))===Yt(Ta(n)))return this.#e=n,{appliedOps:[],changes:[]};const r=t.map((a=>a.text)).join("");this.#e=n,this.invalidate();const o=[],i=[];r.length>0&&(o.push({type:"delete",index:0,length:r.length}),i.push({type:"delete",index:0,length:r.length,deletedText:r}));let s=0;for(const a of n)o.push({type:"insert",index:s,text:a.text,attributes:a.attributes}),i.push({type:"insert",index:s,text:a.text,attributes:a.attributes}),s+=a.text.length;return{appliedOps:o,changes:i}}_resyncText(t,n,r){this.#t=Bd(t),this.#n=n,this.#s=[];const o=this.#h();if(o.changes.length!==0)return{type:"LiveText",node:this,version:this.#n,updates:o.changes,source:r}}_rejectPendingOp(t){t===this.#r&&(this.#r=void 0,this.#o=[],this.#i=[])}#d(t,n,r){this.#s.some((o=>o.version===t))||(this.#s.push({version:t,opId:r,ops:[...n]}),this.#s.sort(((o,i)=>o.version-i.version)),this.#s.length>1e3&&this.#s.splice(0,this.#s.length-1e3))}#v(t){const n=[];for(const r of t)if(r.type==="insert")this.#e=Pc(this.#e,r.index,r.text,r.attributes),n.push({type:"insert",index:r.index,text:r.text,attributes:r.attributes});else if(r.type==="delete"){const o=Nc(this.#e,r.index,r.length);this.#e=o.segments,n.push({type:"delete",index:r.index,length:r.length,deletedText:o.deletedText})}else this.#e=Lc(this.#e,r.index,r.length,r.attributes),n.push({type:"format",index:r.index,length:r.length,attributes:r.attributes});return this.invalidate(),n}#y(t){return[{type:ue.UPDATE_TEXT,id:ye(this._id),baseVersion:this.#n,ops:Dy(this.#e,t)}]}toString(){return this.#e.map((t=>t.text)).join("")}toJSON(){return super.toJSON()}_toJSON(){return Ta(this.#e)}toTreeNode(t){return super.toTreeNode(t)}_toTreeNode(t){const n=this._id??st(),r=this.toJSON().map(((o,i)=>({type:"Json",id:`${n}:${i}`,key:String(i),payload:o})));return r.push({type:"Json",id:`${n}:version`,key:"version",payload:this.version}),{type:"LiveText",id:n,key:t,payload:r}}clone(){return new Bu(this.toJSON(),this.#n)}};function oi(e){return bo(um(e))}function um(e){switch(e.type){case ue.CREATE_FILE:return new vr(e.data);case ue.CREATE_REGISTER:return e.data;case ue.CREATE_OBJECT:return new Gn(e.data);case ue.CREATE_MAP:return new qr;case ue.CREATE_LIST:return new yr([]);case ue.CREATE_TEXT:return new Ho(e.data,e.version);default:return Ye(0,"Unknown creation Op")}}function cm(e,t){return e===t||e.parent.type==="HasParent"&&cm(e.parent.node,t)}function Ay(e){const t=Vp({getCurrentConnectionId:()=>{throw new Error("Cannot mutate a historic storage version: it is a read-only snapshot")}});return Gn._fromItems(e,t)}function lm(e,t,n){if(_p(e))return Gn._deserialize(e,t,n);if(Bp(e))return yr._deserialize(e,t,n);if(Fp(e))return qr._deserialize(e,t,n);if(Rp(e))return qn._deserialize(e,t,n);if(jp(e))return Ho._deserialize(e,t,n);if(Mp(e))return vr._deserialize(e,t,n);throw new Error("Unexpected CRDT type")}function xy(e,t,n){if(_p(e))return Gn._deserialize(e,t,n);if(Bp(e))return yr._deserialize(e,t,n);if(Fp(e))return qr._deserialize(e,t,n);if(Rp(e))return e[1].data;if(jp(e))return Ho._deserialize(e,t,n);if(Mp(e))return vr._deserialize(e,t,n);throw new Error("Unexpected CRDT type")}function ur(e){return Uc(e)||dm(e)||Hc(e)||Fu(e)||fm(e)}function ot(e){return ur(e)||(function(t){return t instanceof qn})(e)}function Uc(e){return e instanceof yr}function dm(e){return e instanceof qr}function Hc(e){return e instanceof Gn}function Fu(e){return e instanceof Ho}function fm(e){return e instanceof vr}function Tr(e){return e instanceof qn?e.data:e instanceof yr||e instanceof qr||e instanceof Gn||e instanceof Ho||e instanceof vr?e:Ye(0,"Unknown AbstractCrdt")}function bo(e){return e instanceof Gn||e instanceof qr||e instanceof yr||e instanceof Ho||e instanceof vr?e:new qn(e)}function Ms(e,t){if(e===t)return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(Array.isArray(e)||Array.isArray(t)){if(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!Ms(e[r],t[r]))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Ms(e[r],t[r]))return!1;return!0}function Oy(e,t){const n=[],r=e.reduce(((i,[s])=>i+s.length),0);r>0&&n.push({type:"delete",index:0,length:r});let o=0;for(const[i,s]of t)i.length!==0&&(n.push({type:"insert",index:o,text:i,attributes:s}),o+=i.length);return n}function Sy(e,t,n){const r=[],o=new Set;t.forEach(((u,c)=>{const f=e.get(c);f!==void 0&&(f.type===u.type&&(f.type!==je.FILE||u.type!==je.FILE||f.data.id===u.data.id&&f.data.name===u.data.name&&f.data.size===u.data.size&&f.data.mimeType===u.data.mimeType)||o.add(c))}));let i=!0;for(;i;){i=!1;for(const u of[e,t])u.forEach(((c,f)=>{!o.has(f)&&c.parentId!==void 0&&o.has(c.parentId)&&(o.add(f),i=!0)}))}e.forEach(((u,c)=>{const f=u.parentId!==void 0&&o.has(u.parentId);t.has(c)&&!o.has(c)||f||r.push({type:ue.DELETE_CRDT,id:c})}));const s=new Set;function a(u,c){if(s.has(u))return;s.add(u);const f=c.parentId;if(f!==void 0&&(!e.has(f)||o.has(f))){const l=t.get(f);l!==void 0&&a(f,l)}switch(c.type){case je.REGISTER:r.push({type:ue.CREATE_REGISTER,id:u,parentId:c.parentId,parentKey:c.parentKey,data:c.data});break;case je.FILE:r.push({type:ue.CREATE_FILE,id:u,parentId:c.parentId,parentKey:c.parentKey,data:c.data});break;case je.LIST:r.push({type:ue.CREATE_LIST,id:u,parentId:c.parentId,parentKey:c.parentKey});break;case je.OBJECT:if(c.parentId===void 0||c.parentKey===void 0)throw new Error("Internal error. Cannot serialize storage root into an operation");r.push({type:ue.CREATE_OBJECT,id:u,parentId:c.parentId,parentKey:c.parentKey,data:c.data});break;case je.MAP:r.push({type:ue.CREATE_MAP,id:u,parentId:c.parentId,parentKey:c.parentKey});break;case je.TEXT:r.push({type:ue.CREATE_TEXT,id:u,parentId:c.parentId,parentKey:c.parentKey,data:c.data,version:c.version})}}return t.forEach(((u,c)=>{const f=e.get(c);if(f&&!o.has(c)){if(u.type===je.OBJECT&&f.type===je.OBJECT){const l=new Map;for(const d of Object.keys(u.data)){const h=u.data[d];h===void 0||Ms(h,f.data[d])||l.set(d,h)}l.size>0&&r.push({type:ue.UPDATE_OBJECT,id:c,data:Object.fromEntries(l)});for(const d of Object.keys(f.data))d in u.data||r.push({type:ue.DELETE_OBJECT_KEY,id:c,key:d})}n?.includeLiveTextUpdates!==!0||u.type!==je.TEXT||f.type!==je.TEXT||Ms(u.data,f.data)||r.push({type:ue.UPDATE_TEXT,id:c,baseVersion:f.version,ops:Oy(f.data,u.data)}),u.parentKey!==f.parentKey&&r.push({type:ue.SET_PARENT_KEY,id:c,parentKey:ye(u.parentKey,"Parent key must not be missing")})}else a(c,u)})),r}function Iy(e,t){const n=e.updates;for(const[r,o]of kc(t.updates))n[r]=o;return{...t,updates:n}}function Ty(e,t){const n=e.updates;for(const[r,o]of kc(t.updates))n[r]=o;return{...t,updates:n}}function ky(e,t){const n=e.updates;return{...t,updates:n.concat(t.updates)}}function _y(e,t){return{...t,updates:e.updates.concat(t.updates)}}function ns(e,t){if(e===void 0)return t;const n=(function(r,o){return r.origin==="remote"||o.origin==="remote"?qt:o.via!=="edit"?o:r.via!=="edit"?r:St})(e.source,t.source);return e.type==="LiveObject"&&t.type==="LiveObject"?{...Iy(e,t),source:n}:e.type==="LiveMap"&&t.type==="LiveMap"?{...Ty(e,t),source:n}:e.type==="LiveList"&&t.type==="LiveList"?{...ky(e,t),source:n}:e.type==="LiveText"&&t.type==="LiveText"?{..._y(e,t),source:n}:{...t,source:n}}function Fa(e,t,n=t){typeof e=="function"&&e()}Ue().observable;var li=Symbol("notification-settings-plain");function Ps(e){const t=["email","slack","teams","webPush"],n={[li]:{value:e,enumerable:!1}};for(const r of t)n[r]={enumerable:!0,get(){const o=this[li][r];return o===void 0?(Vn(`In order to use the '${r}' channel, please set up your project first. For more information: https://liveblocks.io/docs/errors/enable-a-notification-channel`),null):o}};return(function(r,o){return o!==void 0?Object.create(r,o):Object.create(r)})(null,n)}function By(e,t){const n=Ps({...e[li]});for(const o of(r=t,Object.keys(r))){const i=t[o];if(i!==void 0){const s=Object.fromEntries(kc(i).filter((([,a])=>a!==void 0)));n[li][o]={...n[li][o],...s}}}var r;return n}var tr="12px",Ra=class{#e;#t;#n;#r;constructor(){this.#e={},this.#t=0,this.#n=1,this.#r=0}get length(){return this.#r}*[Symbol.iterator](){const e=this.#r,t=this.#t;for(let n=0;n<e;n++)yield this.#e[t+n]}push(e){const t=Array.isArray(e)?e:[e];this.#n>Number.MAX_SAFE_INTEGER-t.length-1&&hn("Deque full");for(const n of t)this.#e[this.#n++-1]=n;this.#r+=t.length}pop(){if(this.#r<1)return;this.#n--;const e=this.#e[this.#n-1];return delete this.#e[this.#n-1],this.#r--,e}pushLeft(e){const t=Array.isArray(e)?e:[e];this.#t<Number.MIN_SAFE_INTEGER+t.length&&hn("Deque full");for(let n=t.length-1;n>=0;n--)this.#e[--this.#t]=t[n];this.#r+=t.length}popLeft(){if(this.#r<1)return;const e=this.#e[this.#t];return delete this.#e[this.#t],this.#t++,this.#r--,e}};function jd(e){return Array.isArray(e)}var at=Object.freeze({UPDATE_PRESENCE:100,BROADCAST_EVENT:103,FETCH_STORAGE:200,UPDATE_STORAGE:201,FETCH_YDOC:300,UPDATE_YDOC:301,FETCH_FEEDS:510,FETCH_FEED_MESSAGES:511,ADD_FEED:512,UPDATE_FEED:513,DELETE_FEED:514,ADD_FEED_MESSAGE:515,UPDATE_FEED_MESSAGE:516,DELETE_FEED_MESSAGE:517}),Fy=class{#e;#t;signal;constructor(){this.#e=new Ot({connections:new Map,presences:new Map}),this.signal=$e.from(this.#e,(e=>yu(Array.from(this.#e.get().presences.keys()).map((t=>this.getUser(Number(t))))))),this.#t=new Map}get(){return this.signal.get()}connectionIds(){return this.#e.get().connections.keys()}clearOthers(){this.#e.mutate((e=>{e.connections.clear(),e.presences.clear(),this.#t.clear()}))}#n(e){const t=this.#e.get(),n=t.connections.get(e),r=t.presences.get(e);if(n!==void 0&&r!==void 0)return(function(o,i){const{connectionId:s,id:a,info:u,access:c}=o,{canWrite:f,canComment:l}=c;return wi({connectionId:s,id:a,info:u,canWrite:f,canComment:l,isReadOnly:!f,presence:i})})(n,r)}getUser(e){const t=this.#t.get(e);if(t)return t;const n=this.#n(e);return n?(this.#t.set(e,n),n):void 0}#r(e){this.#t.delete(e)}setConnection(e,t,n,r){this.#e.mutate((o=>(o.connections.set(e,{connectionId:e,id:t,info:n,access:r}),!!o.presences.has(e)&&this.#r(e))))}removeConnection(e){this.#e.mutate((t=>{t.connections.delete(e),t.presences.delete(e),this.#r(e)}))}setOther(e,t){this.#e.mutate((n=>(n.presences.set(e,wi(t)),!!n.connections.has(e)&&this.#r(e))))}patchOther(e,t){this.#e.mutate((n=>{const r=n.presences.get(e);if(r===void 0)return!1;const o=kp(r,t);return r!==o&&(n.presences.set(e,o),this.#r(e))}))}},Ru=class hm extends Error{context;constructor(t,n,r){super(t,{cause:r}),this.context=n,this.name="LiveblocksError"}get roomId(){return this.context.roomId}get code(){return this.context.code}static from(t,n){return new hm((function(r){switch(r.type){case"ROOM_CONNECTION_ERROR":switch(r.code){case 4001:return"Not allowed to connect to the room";case 4005:return"Room is already full";case 4006:return"Kicked out of the room, because the room ID changed";default:return"Could not connect to the room"}case"AI_CONNECTION_ERROR":return r.code===4001?"Not allowed to connect to ai":"Could not connect to the room";case"CREATE_THREAD_ERROR":return"Could not create new thread";case"DELETE_THREAD_ERROR":return"Could not delete thread";case"EDIT_THREAD_METADATA_ERROR":return"Could not edit thread metadata";case"EDIT_COMMENT_METADATA_ERROR":return"Could not edit comment metadata";case"MARK_THREAD_AS_RESOLVED_ERROR":return"Could not mark thread as resolved";case"MARK_THREAD_AS_UNRESOLVED_ERROR":return"Could not mark thread as unresolved";case"SUBSCRIBE_TO_THREAD_ERROR":return"Could not subscribe to thread";case"UNSUBSCRIBE_FROM_THREAD_ERROR":return"Could not unsubscribe from thread";case"CREATE_COMMENT_ERROR":return"Could not create new comment";case"EDIT_COMMENT_ERROR":return"Could not edit comment";case"DELETE_COMMENT_ERROR":return"Could not delete comment";case"ADD_REACTION_ERROR":return"Could not add reaction";case"REMOVE_REACTION_ERROR":return"Could not remove reaction";case"MARK_INBOX_NOTIFICATION_AS_READ_ERROR":return"Could not mark inbox notification as read";case"DELETE_INBOX_NOTIFICATION_ERROR":return"Could not delete inbox notification";case"MARK_ALL_INBOX_NOTIFICATIONS_AS_READ_ERROR":return"Could not mark all inbox notifications as read";case"DELETE_ALL_INBOX_NOTIFICATIONS_ERROR":return"Could not delete all inbox notifications";case"UPDATE_ROOM_SUBSCRIPTION_SETTINGS_ERROR":return"Could not update room subscription settings";case"UPDATE_NOTIFICATION_SETTINGS_ERROR":return"Could not update notification settings";case"LARGE_MESSAGE_ERROR":return"Could not send large message";case"FEED_REQUEST_ERROR":return r.reason??"Feed request failed";default:return Ye(0,"Unhandled case")}})(t),t,n)}},ja=5e3;function Md(e){const t=jc(Mc(e));return{canWrite:fr(t,"storage","write"),canComment:fr(t,"comments","write")}}function Pd(e,t){return{type:"User",id:`${t.connectionId}`,key:e,payload:{connectionId:t.connectionId,id:t.id,info:t.info,presence:t.presence,isReadOnly:!t.canWrite}}}function Ry(e,t){const n=t.roomId,r=e.initialPresence,o=e.initialStorage,i=t.roomHttpClient,[s,a]=(function(){const O=typeof document<"u"?document:void 0,P={current:null};function j(){P.current=O?.visibilityState==="hidden"?P.current??Date.now():null}return O?.addEventListener("visibilitychange",j),[P,()=>{O?.removeEventListener("visibilitychange",j)}]})(),u={...t.delegates,canZombie:()=>t.backgroundKeepAliveTimeout!==void 0&&s.current!==null&&Date.now()>s.current+t.backgroundKeepAliveTimeout&&ut.getStatus()!=="synchronizing"&&Go.getStatus()!=="synchronizing"},c=new em(u,t.enableDebugLogging),f=new Hp,l={buffer:{flushTimerID:void 0,lastFlushedAt:0,presenceUpdates:{type:"full",data:r},messages:[],storageOperations:[]},staticSessionInfoSig:new Tt(null),dynamicSessionInfoSig:new Tt(null),myPresence:new w1(r),others:new Fy,initialStorage:o,idFactory:null,yjsProvider:void 0,yjsProviderDidChange:Ue(),pool:Vp({getCurrentConnectionId:function(){const O=l.dynamicSessionInfoSig.get();if(O)return O.actor;throw new Error("Internal. Tried to get connection id but connection was never open")},onDispatch:function(O,P,j,L){if(l.activeBatch){for(const N of O)l.activeBatch.ops.push(N);for(const[N,ce]of j)l.activeBatch.updates.storageUpdates.set(N,ns(l.activeBatch.updates.storageUpdates.get(N),ce));l.activeBatch.reverseOps.pushLeft(P),L?.clearRedoStack&&(l.activeBatch.clearRedoStack=!0)}else P.length>0&&H(P),(L?.clearRedoStack??O.length>0)&&R(),O.length>0&&we(O),W({storageUpdates:j})},isStorageWritable:function(){const O=l.dynamicSessionInfoSig.get()?.permissionMatrix;return O===void 0||fr(O,"storage","write")},unacknowledgedOps:f}),root:void 0,undoStack:[],redoStack:[],pausedHistory:null,activeBatch:null,unacknowledgedOps:f};let d=0,h=0;const g=(function(){let O=new Map;return{append(P){for(const[j,L]of P)O.set(j,L)},take(){const P=O;return O=new Map,P}}})(),y=t.enableDebugLogging?(function(){let O,P=0,j=0;function L(N=performance.now()){O.push(N-j),j=N}return{start:function(){O=[],P=performance.now(),j=P},lap:L,stop:function(){const N=performance.now();return L(N),{total:N-P,laps:O}}}})():void 0;let p,w,b=!1;c.events.onMessage.subscribe(pe),c.events.statusDidChange.subscribe((function(O){const P=c.authValue;if(P!==null){const j=Rc(P);if(j!==p)if(p=j,P.type==="secret"){const L=P.token.parsed;l.staticSessionInfoSig.set({userId:L.uid,userInfo:L.ui})}else l.staticSessionInfoSig.set({userId:void 0,userInfo:void 0})}C.status.notify(O),I()})),c.events.statusDidChange.subscribe((function(O){O==="reconnecting"?w=setTimeout((()=>{C.lostConnection.notify("lost"),b=!0,l.others.clearOthers(),W({others:[{type:"reset"}]})}),t.lostConnectionTimeout):(clearTimeout(w),b&&(O==="disconnected"?C.lostConnection.notify("failed"):C.lostConnection.notify("restored"),b=!1))})),c.events.didConnect.subscribe((function(){l.buffer.presenceUpdates={type:"full",data:{...l.myPresence.get()}},Ce!==null&&ge(),fe()})),c.events.didDisconnect.subscribe((function(){clearTimeout(l.buffer.flushTimerID),l.unacknowledgedOps.markAllAsPossiblyStored()})),c.events.onConnectionError.subscribe((({message:O,code:P})=>{const j=new Ru(O,{type:"ROOM_CONNECTION_ERROR",code:P,roomId:n});t.errorEventSource.notify(j)}));const C={status:Ue(),lostConnection:Ue(),customEvent:Ue(),self:Ue(),myPresence:Ue(),others:Ue(),storageBatch:Ue(),history:Ue(),privateHistory:Ue(),storageDidLoad:Ue(),storageStatus:Ue(),ydoc:Ue(),comments:Ue(),feeds:Ue(),roomWillDestroy:Ue()};function E(O){c.send(Pr(O))}const A=$e.from(l.staticSessionInfoSig,l.dynamicSessionInfoSig,l.myPresence,((O,P,j)=>{if(O===null||P===null)return null;{const L=fr(P.permissionMatrix,"storage","write");return{connectionId:P.actor,id:O.userId,info:O.userInfo,presence:j,canWrite:L,canComment:fr(P.permissionMatrix,"comments","write")}}}));let x;function I(){const O=A.get();O!==null&&O!==x&&(C.self.notify(O),x=O)}const T=$e.from(A,(O=>O!==null?Pd("Me",O):null));function B(O,P){const j=new Map;for(const[L,N]of l.pool.nodes)j.set(L,N._serialize());return Sy(j,O,P)}function S(O){if(O.size===0)throw new Error("Internal error: cannot load storage without items");if(l.root!==void 0){const N=V(B(O));for(const[ce,Ee]of O)if(Ee.type===je.TEXT){const Fe=l.pool.nodes.get(ce);if(Fe!==void 0&&Fu(Fe)){const be=Fe._resyncText(Ee.data,Ee.version,qt);be!==void 0&&N.updates.storageUpdates.set(ce,ns(N.updates.storageUpdates.get(ce),be))}}W(N.updates)}else l.root=Gn._fromItems(O,l.pool);const P=A.get()?.canWrite??!0,j=(function(N){const ce=new Set,Ee=N.get("root");for(const Fe in Ee?.data)ce.add(Fe);for(const Fe of N.values())Fe.parentId==="root"&&ce.add(Fe.parentKey);return ce})(O),L=l.root;et((()=>{for(const ce in l.initialStorage)j.has(ce)||(P?L.set(ce,(N=l.initialStorage[ce])===void 0?void 0:ur(N)?N.clone():Ci(N)):mt(`Attempted to populate missing storage key '${ce}', but current user has no write access`));var N}))}function k(O){h>0||C.privateHistory.notify(O)}function R(){if(l.redoStack.length===0)return;const O=l.redoStack.map((P=>P.id));l.redoStack.length=0,k({action:"discard",ids:O})}function M(O){if(l.undoStack.length>=50){const j=l.undoStack.shift();j!==void 0&&k({action:"discard",ids:[j.id]})}const P=d++;l.undoStack.push({id:P,frames:O}),k({action:"push",id:P}),X()}function H(O){l.pausedHistory!==null?l.pausedHistory.pushLeft(O):M(O)}function W(O){const P=O.storageUpdates,j=O.others;if(j!==void 0&&j.length>0){const L=l.others.get();for(const N of j)C.others.notify({...N,others:L})}if(O.presence&&(I(),C.myPresence.notify(l.myPresence.get())),P!==void 0&&P.size>0){const L=Array.from(P.values(),(N=>({...N,source:un(N.source)})));C.storageBatch.notify(L)}Zn()}const G=new Map;function q(O){const P=G.get(O);return P===void 0?"edit":(G.delete(O),P)}function $(O,P=St){const[j,L]=(function(be,tt){const _t=[],Bt=[];let qe=0;for(const vn of be)tt(vn,qe++)?_t.push(vn):Bt.push(vn);return[_t,Bt]})(O,(be=>be.type==="presence")),N=new Map;for(const be of L)be.type!==ue.CREATE_TEXT||be.opId!==void 0||l.pool.nodes.get(be.id)!==void 0||N.has(be.id)||N.set(be.id,l.pool.generateId());const ce=(N.size===0?L:L.map((be=>{if(be.opId!==void 0)return be;const tt=N.get(be.id);if(wu(be)){const _t=N.get(be.parentId),Bt=be.deletedId===void 0?void 0:N.get(be.deletedId);return tt===void 0&&_t===void 0&&Bt===void 0?be:be.type===ue.CREATE_TEXT&&tt!==void 0?{...be,id:tt,version:0,..._t===void 0?{}:{parentId:_t},...Bt===void 0?{}:{deletedId:Bt}}:{...be,...tt===void 0?{}:{id:tt},..._t===void 0?{}:{parentId:_t},...Bt===void 0?{}:{deletedId:Bt}}}return tt===void 0?be:{...be,id:tt}}))).map((be=>be.opId===void 0?{...be,opId:l.pool.generateOpId()}:be));if(P.via!=="edit")for(const be of ce)G.set(be.opId,P.via);const{reverse:Ee,updates:Fe}=Q(j,ce,!0,P);return{opsToEmit:ce,reverse:Ee,updates:Fe}}function V(O){return Q([],O,!1)}function Q(O,P,j,L=St){const N={reverse:new Ra,storageUpdates:new Map,presence:!1};for(const Ee of O){const Fe={type:"presence",data:{}};for(const be in Ee.data)Fe.data[be]=l.myPresence.get()[be];if(l.myPresence.patch(Ee.data),l.buffer.presenceUpdates===null)l.buffer.presenceUpdates={type:"partial",data:Ee.data};else for(const be in Ee.data)l.buffer.presenceUpdates.data[be]=Ee.data[be];N.reverse.pushLeft(Fe),N.presence=!0}const ce=new Set;for(const Ee of P){let Fe;j?Fe={...L,optimistic:!0}:Ee.opId!==void 0?(l.unacknowledgedOps.delete(Ee.opId),Fe={origin:"local",via:q(Ee.opId),optimistic:!1}):Fe=qt;const be=ae(Ee,Fe);if(be.modified){const tt=be.modified.node._id;tt&&ce.has(tt)||(N.storageUpdates.set(ye(be.modified.node._id),ns(N.storageUpdates.get(ye(be.modified.node._id)),be.modified)),N.reverse.pushLeft(be.reverse)),Ee.type!==ue.CREATE_LIST&&Ee.type!==ue.CREATE_MAP&&Ee.type!==ue.CREATE_OBJECT&&Ee.type!==ue.CREATE_TEXT&&Ee.type!==ue.CREATE_FILE||ce.add(Ee.id)}}return{reverse:Array.from(N.reverse),updates:{storageUpdates:N.storageUpdates,presence:N.presence}}}function ae(O,P){if((function(j){return j.type===ue.DELETE_CRDT&&j.id==="ACK"})(O))return{modified:!1};switch(O.type){case ue.DELETE_OBJECT_KEY:case ue.UPDATE_OBJECT:case ue.UPDATE_TEXT:case ue.DELETE_CRDT:{const j=l.pool.nodes.get(O.id);return j===void 0?{modified:!1}:j._apply(O,P)}case ue.SET_PARENT_KEY:{const j=l.pool.nodes.get(O.id);return j===void 0?{modified:!1}:j.parent.type==="HasParent"&&Uc(j.parent.node)?j.parent.node._setChildKey(Ei(O.parentKey),j,P):{modified:!1}}case ue.CREATE_OBJECT:case ue.CREATE_LIST:case ue.CREATE_MAP:case ue.CREATE_TEXT:case ue.CREATE_FILE:case ue.CREATE_REGISTER:{if(O.parentId===void 0)return{modified:!1};const j=l.pool.nodes.get(O.parentId);return j===void 0?{modified:!1}:j._attachChild(O,P)}default:return{modified:!1}}}function ie(O){if(O.targetActor!==void 0){const j=l.others.getUser(O.actor);l.others.setOther(O.actor,O.data);const L=l.others.getUser(O.actor);if(j===void 0&&L!==void 0)return{type:"enter",user:L}}else l.others.patchOther(O.actor,O.data);const P=l.others.getUser(O.actor);return P?{type:"update",updates:O.data,user:P}:void 0}function Se(O){const P=l.others.getUser(O.actor);return P?(l.others.removeConnection(O.actor),{type:"leave",user:P}):null}function Ie(O){l.dynamicSessionInfoSig.set({actor:O.actor,nonce:O.nonce,permissionMatrix:jc(Mc(O.scopes)),meta:O.meta}),l.idFactory=(function(P){let j=0;return()=>`${P}:${j++}`})(O.actor),I(),O.meta.showBrand===!0&&((P="bottom-right")=>{if(typeof document>"u"||document.getElementById("liveblocks-badge"))return;const j=document.createElement("div");switch(j.id="liveblocks-badge",j.style.position="fixed",j.style.opacity="0",j.style.transition="opacity 300ms",j.style.zIndex="9999",P){case"top-right":j.style.top=tr,j.style.right=tr;break;case"bottom-right":j.style.bottom=tr,j.style.right=tr;break;case"bottom-left":j.style.bottom=tr,j.style.left=tr;break;case"top-left":j.style.top=tr,j.style.left=tr}j.onmouseenter=()=>{const Xn=document.getElementById("liveblocks-badge-hide-button");Xn&&(Xn.style.opacity="0.3")},j.onmouseleave=()=>{const Xn=document.getElementById("liveblocks-badge-hide-button");Xn&&(Xn.style.opacity="0")};const L=document.createElement("a");L.href="https://lblcks.io/badge",L.target="_blank",L.rel="noopener noreferrer",L.title="Liveblocks";const N=document.createElementNS("http://www.w3.org/2000/svg","svg");N.setAttribute("width","111"),N.setAttribute("height","38"),N.setAttribute("viewBox","0 0 111 38"),N.setAttribute("fill","none");const ce=document.createElementNS("http://www.w3.org/2000/svg","rect");ce.setAttribute("x","1"),ce.setAttribute("y","1"),ce.setAttribute("width","109"),ce.setAttribute("height","36"),ce.setAttribute("rx","8"),ce.setAttribute("fill","white"),N.appendChild(ce);const Ee=document.createElementNS("http://www.w3.org/2000/svg","rect");Ee.setAttribute("x","0.5"),Ee.setAttribute("y","0.5"),Ee.setAttribute("width","110"),Ee.setAttribute("height","37"),Ee.setAttribute("rx","8.5"),Ee.setAttribute("stroke","black"),Ee.setAttribute("stroke-opacity","0.1"),N.appendChild(Ee);const Fe=document.createElementNS("http://www.w3.org/2000/svg","path");Fe.setAttribute("d","M39.8256 18.0832H38L38.0005 28.9009H39.8256V18.0832ZM43.213 21.1757H41.3879V28.9009H43.213V21.1757ZM43.213 18H41.3879V19.9688H43.213V18ZM45.8916 21.1757H43.9302L46.6915 28.9009H48.7283L51.4896 21.1757H49.5581L48.4039 24.8348C48.3739 24.93 48.2657 25.3024 48.0795 25.9511L47.7099 27.1959C47.4914 26.406 47.2626 25.6189 47.0237 24.8348L45.8916 21.1757ZM58.9659 23.59C58.8147 23.0721 58.5934 22.6317 58.3014 22.2694C57.9743 21.8628 57.5598 21.5482 57.0571 21.3268C56.5589 21.1004 56.0058 20.9877 55.3973 20.9877C54.2407 20.9877 53.3152 21.3495 52.6212 22.0735C52.275 22.4476 52.0103 22.8896 51.844 23.3715C51.6731 23.8691 51.5876 24.4199 51.5876 25.0233C51.5876 26.3157 51.9322 27.3142 52.6217 28.0184C53.3203 28.7323 54.2509 29.0894 55.4125 29.0894C56.4083 29.0894 57.2151 28.8658 57.8342 28.4181C58.453 27.9704 58.8628 27.3068 59.0638 26.4266L57.2834 26.2908C57.198 26.7685 57.0016 27.1257 56.6948 27.3618C56.3879 27.5933 55.9555 27.7093 55.3973 27.7093C54.1201 27.7093 53.4663 26.9899 53.4363 25.5514H59.1844L59.1922 25.295C59.1922 24.6763 59.1165 24.108 58.9659 23.59ZM53.8434 23.0471C54.1654 22.5943 54.6834 22.3679 55.3973 22.3679C55.7443 22.3679 56.0363 22.4155 56.2725 22.5111C56.509 22.6067 56.7128 22.7601 56.8837 22.9713C57.0167 23.1352 57.1189 23.3218 57.1855 23.5221C57.2605 23.731 57.3062 23.9493 57.3213 24.1708H53.451C53.4964 23.7231 53.6271 23.3484 53.8434 23.0471ZM66.2836 21.4779C65.7656 21.1406 65.1673 20.9724 64.4885 20.9724H64.4875C63.995 20.9724 63.5449 21.0727 63.1374 21.2742C62.7364 21.4696 62.3931 21.7659 62.1412 22.1341V18.0832H60.316V28.9009H62.1416V27.8373C62.373 28.2195 62.7008 28.5342 63.0921 28.7499C63.4996 28.9763 63.9497 29.0894 64.4422 29.0894C65.1266 29.0894 65.7324 28.9259 66.2614 28.5992C66.7891 28.2726 67.1989 27.8045 67.4905 27.1959C67.7871 26.5823 67.9359 25.8634 67.9359 25.0386C67.9359 24.2337 67.7895 23.5248 67.4984 22.9113C67.2115 22.2926 66.8066 21.8148 66.2836 21.4779ZM65.5064 27.0828C65.2148 27.5254 64.7172 27.7463 64.0125 27.7463C63.3786 27.7463 62.9013 27.5175 62.5797 27.0601C62.2576 26.6026 62.0968 25.9336 62.0968 25.0534C62.0968 24.2032 62.24 23.5397 62.5265 23.0619C62.8185 22.579 63.3088 22.3378 63.9978 22.3378C64.7019 22.3378 65.2023 22.5592 65.499 23.0013C65.7961 23.4389 65.944 24.1181 65.944 25.0386C65.944 25.9585 65.7985 26.6401 65.5064 27.0828ZM70.901 18.0832H69.0754V28.9009H70.901V18.0832ZM73.8582 28.6066C74.452 28.9286 75.1558 29.0894 75.9708 29.0894C76.7554 29.0894 77.4444 28.9208 78.0377 28.5844C78.6268 28.2569 79.1068 27.7637 79.4183 27.1659C79.745 26.5523 79.9086 25.843 79.9086 25.0386C79.9086 24.2642 79.7478 23.5697 79.4257 22.9565C79.117 22.3516 78.6404 21.8487 78.0529 21.508C77.4592 21.161 76.7652 20.9872 75.9708 20.9872C75.171 20.9872 74.4719 21.161 73.8735 21.508C73.2876 21.8472 72.811 22.3471 72.5002 22.9486C72.1837 23.5572 72.0252 24.254 72.0252 25.0386C72.0252 25.8735 72.181 26.5948 72.4929 27.2033C72.7962 27.798 73.2722 28.2871 73.8582 28.6066ZM77.4869 27.0906C77.18 27.5231 76.6746 27.7393 75.9708 27.7393C75.493 27.7393 75.1082 27.6437 74.8166 27.4524C74.5246 27.2565 74.3134 26.9621 74.1826 26.5699C74.0518 26.1725 73.9867 25.6619 73.9867 25.0381C73.9867 24.1029 74.1401 23.419 74.4469 22.9866C74.7588 22.5541 75.2667 22.3378 75.9708 22.3378C76.6699 22.3378 77.1727 22.5541 77.4795 22.9866C77.7914 23.419 77.9471 24.1029 77.9471 25.0386C77.9471 25.9738 77.7937 26.6576 77.4869 27.0906ZM82.3982 28.6066C82.9869 28.9286 83.6883 29.0894 84.5033 29.0894C85.1369 29.0894 85.7029 28.9791 86.2005 28.7577C86.6989 28.5364 87.1031 28.2272 87.4152 27.8299C87.7279 27.4249 87.9329 26.9471 88.0109 26.4414L86.2534 26.2607C86.1328 26.7431 85.9316 27.1031 85.6497 27.3392C85.3683 27.5757 84.9857 27.694 84.5033 27.694C84.0103 27.694 83.6232 27.5933 83.3413 27.3918C83.0598 27.1858 82.8635 26.8919 82.7531 26.5093C82.6422 26.1221 82.5872 25.6318 82.5872 25.0386C82.5872 24.455 82.6422 23.9722 82.7531 23.59C82.8635 23.2028 83.0571 22.9062 83.3339 22.6997C83.6157 22.4884 84.0053 22.3831 84.5033 22.3831C85.0362 22.3831 85.4312 22.5314 85.6877 22.8281C85.949 23.1196 86.1354 23.5193 86.2456 24.0276L87.9735 23.718C87.8078 22.8932 87.4326 22.232 86.8491 21.7344C86.2708 21.2363 85.489 20.9877 84.5033 20.9877C83.6985 20.9877 83.0021 21.1587 82.4134 21.5006C81.8322 21.8351 81.3625 22.3337 81.0633 22.9339C80.7514 23.5424 80.5952 24.2439 80.5952 25.0386C80.5952 25.8781 80.7486 26.6026 81.0554 27.2112C81.3673 27.8197 81.8151 28.285 82.3982 28.6066ZM90.8104 26.0343L91.6627 25.2192L93.9257 28.9009H96.0308L92.8999 24.0498L95.9328 21.1757H93.5634L90.8104 23.9976V18.0832H88.9845V28.9009H90.8104V26.0343ZM97.6304 28.8103C98.1436 28.9965 98.7142 29.0894 99.3428 29.0894C100.303 29.0894 101.095 28.8981 101.719 28.5165C102.348 28.1339 102.663 27.5101 102.663 26.6451C102.663 26.0818 102.516 25.6392 102.225 25.3176C101.933 24.9905 101.586 24.7566 101.184 24.6157C100.786 24.4702 100.245 24.3219 99.562 24.1707C99.1642 24.0853 98.8502 24.0049 98.6188 23.9295C98.3873 23.8538 98.201 23.7558 98.0604 23.6352C97.925 23.5141 97.8567 23.3584 97.8567 23.1676C97.8567 22.8858 97.9824 22.6723 98.2338 22.5263C98.4853 22.3803 98.7973 22.3073 99.1694 22.3073C99.6619 22.3073 100.047 22.4255 100.324 22.6621C100.605 22.8987 100.756 23.2531 100.776 23.7258L102.466 23.4467C102.385 22.5817 102.046 21.9556 101.447 21.568C100.854 21.1812 100.095 20.9872 99.1694 20.9872C98.6258 20.9872 98.1236 21.0699 97.6607 21.2362C97.2029 21.397 96.8335 21.6511 96.5517 21.9986C96.27 22.3451 96.1294 22.7827 96.1294 23.3109C96.1294 23.7988 96.25 24.1934 96.4911 24.4951C96.7368 24.8001 97.0527 25.0408 97.4118 25.1965C97.7838 25.3578 98.2512 25.5112 98.8147 25.6567L99.2828 25.7699C99.5949 25.844 99.9044 25.9295 100.211 26.0264C100.421 26.092 100.595 26.1826 100.731 26.2981C100.867 26.4136 100.935 26.5647 100.935 26.7509C100.935 27.0776 100.799 27.3294 100.527 27.505C100.261 27.6815 99.8708 27.7693 99.3583 27.7693C98.8347 27.7693 98.4176 27.6385 98.1055 27.377C97.7941 27.1154 97.6355 26.7384 97.6304 26.2454L95.9109 26.4413C95.9302 27.0351 96.094 27.5304 96.4009 27.9278C96.7129 28.3252 97.1223 28.619 97.6304 28.8103Z"),Fe.setAttribute("fill","black"),N.appendChild(Fe);const be=document.createElementNS("http://www.w3.org/2000/svg","path");be.setAttribute("d","M37.6392 15V9.18182H39.7131C40.1657 9.18182 40.5407 9.2642 40.8381 9.42898C41.1354 9.59375 41.358 9.81913 41.5057 10.1051C41.6534 10.3892 41.7273 10.7093 41.7273 11.0653C41.7273 11.4233 41.6525 11.7453 41.5028 12.0312C41.3551 12.3153 41.1316 12.5407 40.8324 12.7074C40.535 12.8722 40.161 12.9545 39.7102 12.9545H38.2841V12.2102H39.6307C39.9167 12.2102 40.1487 12.161 40.3267 12.0625C40.5047 11.9621 40.6354 11.8258 40.7188 11.6534C40.8021 11.4811 40.8438 11.285 40.8438 11.0653C40.8438 10.8456 40.8021 10.6506 40.7188 10.4801C40.6354 10.3097 40.5038 10.1761 40.3239 10.0795C40.1458 9.98295 39.911 9.93466 39.6193 9.93466H38.517V15H37.6392ZM44.4716 15.0881C44.0625 15.0881 43.7055 14.9943 43.4006 14.8068C43.0956 14.6193 42.8589 14.357 42.6903 14.0199C42.5218 13.6828 42.4375 13.2888 42.4375 12.8381C42.4375 12.3854 42.5218 11.9896 42.6903 11.6506C42.8589 11.3116 43.0956 11.0483 43.4006 10.8608C43.7055 10.6733 44.0625 10.5795 44.4716 10.5795C44.8807 10.5795 45.2377 10.6733 45.5426 10.8608C45.8475 11.0483 46.0843 11.3116 46.2528 11.6506C46.4214 11.9896 46.5057 12.3854 46.5057 12.8381C46.5057 13.2888 46.4214 13.6828 46.2528 14.0199C46.0843 14.357 45.8475 14.6193 45.5426 14.8068C45.2377 14.9943 44.8807 15.0881 44.4716 15.0881ZM44.4744 14.375C44.7396 14.375 44.9593 14.3049 45.1335 14.1648C45.3078 14.0246 45.4366 13.8381 45.5199 13.6051C45.6051 13.3722 45.6477 13.1155 45.6477 12.8352C45.6477 12.5568 45.6051 12.3011 45.5199 12.0682C45.4366 11.8333 45.3078 11.6449 45.1335 11.5028C44.9593 11.3608 44.7396 11.2898 44.4744 11.2898C44.2074 11.2898 43.9858 11.3608 43.8097 11.5028C43.6354 11.6449 43.5057 11.8333 43.4205 12.0682C43.3371 12.3011 43.2955 12.5568 43.2955 12.8352C43.2955 13.1155 43.3371 13.3722 43.4205 13.6051C43.5057 13.8381 43.6354 14.0246 43.8097 14.1648C43.9858 14.3049 44.2074 14.375 44.4744 14.375ZM48.267 15L46.983 10.6364H47.8608L48.7159 13.8409H48.7585L49.6165 10.6364H50.4943L51.3466 13.8267H51.3892L52.2386 10.6364H53.1165L51.8352 15H50.9688L50.0824 11.8494H50.017L49.1307 15H48.267ZM55.6705 15.0881C55.2405 15.0881 54.8703 14.9962 54.5597 14.8125C54.2509 14.6269 54.0123 14.3665 53.8438 14.0312C53.6771 13.6941 53.5938 13.2992 53.5938 12.8466C53.5938 12.3996 53.6771 12.0057 53.8438 11.6648C54.0123 11.3239 54.2472 11.0578 54.5483 10.8665C54.8513 10.6752 55.2055 10.5795 55.6108 10.5795C55.857 10.5795 56.0956 10.6203 56.3267 10.7017C56.5578 10.7831 56.7652 10.911 56.9489 11.0852C57.1326 11.2595 57.2775 11.4858 57.3835 11.7642C57.4896 12.0407 57.5426 12.3769 57.5426 12.7727V13.0739H54.0739V12.4375H56.7102C56.7102 12.214 56.6648 12.0161 56.5739 11.8438C56.483 11.6695 56.3551 11.5322 56.1903 11.4318C56.0275 11.3314 55.8362 11.2812 55.6165 11.2812C55.3778 11.2812 55.1695 11.34 54.9915 11.4574C54.8153 11.5729 54.679 11.7244 54.5824 11.9119C54.4877 12.0975 54.4403 12.2992 54.4403 12.517V13.0142C54.4403 13.3059 54.4915 13.554 54.5938 13.7585C54.6979 13.9631 54.8428 14.1193 55.0284 14.2273C55.214 14.3333 55.4309 14.3864 55.679 14.3864C55.84 14.3864 55.9867 14.3636 56.1193 14.3182C56.2519 14.2708 56.3665 14.2008 56.4631 14.108C56.5597 14.0152 56.6335 13.9006 56.6847 13.7642L57.4886 13.9091C57.4242 14.1458 57.3087 14.3532 57.142 14.5312C56.9773 14.7074 56.7699 14.8447 56.5199 14.9432C56.2718 15.0398 55.9886 15.0881 55.6705 15.0881ZM58.4851 15V10.6364H59.3061V11.3295H59.3516C59.4311 11.0947 59.5713 10.91 59.772 10.7756C59.9747 10.6392 60.2038 10.571 60.4595 10.571C60.5125 10.571 60.575 10.5729 60.647 10.5767C60.7209 10.5805 60.7786 10.5852 60.8203 10.5909V11.4034C60.7862 11.3939 60.7256 11.3835 60.6385 11.3722C60.5514 11.3589 60.4643 11.3523 60.3771 11.3523C60.1764 11.3523 59.9974 11.3949 59.8402 11.4801C59.6849 11.5634 59.5618 11.6799 59.4709 11.8295C59.38 11.9773 59.3345 12.1458 59.3345 12.3352V15H58.4851ZM63.2798 15.0881C62.8499 15.0881 62.4796 14.9962 62.169 14.8125C61.8603 14.6269 61.6217 14.3665 61.4531 14.0312C61.2865 13.6941 61.2031 13.2992 61.2031 12.8466C61.2031 12.3996 61.2865 12.0057 61.4531 11.6648C61.6217 11.3239 61.8565 11.0578 62.1577 10.8665C62.4607 10.6752 62.8149 10.5795 63.2202 10.5795C63.4664 10.5795 63.705 10.6203 63.9361 10.7017C64.1671 10.7831 64.3745 10.911 64.5582 11.0852C64.742 11.2595 64.8868 11.4858 64.9929 11.7642C65.099 12.0407 65.152 12.3769 65.152 12.7727V13.0739H61.6832V12.4375H64.3196C64.3196 12.214 64.2741 12.0161 64.1832 11.8438C64.0923 11.6695 63.9645 11.5322 63.7997 11.4318C63.6368 11.3314 63.4455 11.2812 63.2259 11.2812C62.9872 11.2812 62.7789 11.34 62.6009 11.4574C62.4247 11.5729 62.2884 11.7244 62.1918 11.9119C62.0971 12.0975 62.0497 12.2992 62.0497 12.517V13.0142C62.0497 13.3059 62.1009 13.554 62.2031 13.7585C62.3073 13.9631 62.4522 14.1193 62.6378 14.2273C62.8234 14.3333 63.0402 14.3864 63.2884 14.3864C63.4493 14.3864 63.5961 14.3636 63.7287 14.3182C63.8613 14.2708 63.9759 14.2008 64.0724 14.108C64.169 14.0152 64.2429 13.9006 64.294 13.7642L65.098 13.9091C65.0336 14.1458 64.9181 14.3532 64.7514 14.5312C64.5866 14.7074 64.3793 14.8447 64.1293 14.9432C63.8812 15.0398 63.598 15.0881 63.2798 15.0881ZM67.728 15.0852C67.3757 15.0852 67.0613 14.9953 66.7848 14.8153C66.5102 14.6335 66.2943 14.375 66.1371 14.0398C65.9818 13.7027 65.9041 13.2983 65.9041 12.8267C65.9041 12.3551 65.9827 11.9517 66.1399 11.6165C66.299 11.2812 66.5168 11.0246 66.7933 10.8466C67.0698 10.6686 67.3833 10.5795 67.7337 10.5795C68.0045 10.5795 68.2223 10.625 68.3871 10.7159C68.5537 10.8049 68.6825 10.9091 68.7734 11.0284C68.8662 11.1477 68.9382 11.2528 68.9893 11.3438H69.0405V9.18182H69.8899V15H69.0604V14.321H68.9893C68.9382 14.4138 68.8643 14.5199 68.7678 14.6392C68.6731 14.7585 68.5424 14.8627 68.3757 14.9517C68.209 15.0407 67.9931 15.0852 67.728 15.0852ZM67.9155 14.3608C68.1598 14.3608 68.3662 14.2964 68.5348 14.1676C68.7053 14.0369 68.834 13.8561 68.9212 13.625C69.0102 13.3939 69.0547 13.125 69.0547 12.8182C69.0547 12.5152 69.0111 12.25 68.924 12.0227C68.8369 11.7955 68.709 11.6184 68.5405 11.4915C68.3719 11.3646 68.1636 11.3011 67.9155 11.3011C67.6598 11.3011 67.4467 11.3674 67.2763 11.5C67.1058 11.6326 66.977 11.8134 66.8899 12.0426C66.8047 12.2718 66.7621 12.5303 66.7621 12.8182C66.7621 13.1098 66.8056 13.3722 66.8928 13.6051C66.9799 13.8381 67.1087 14.0227 67.2791 14.1591C67.4515 14.2936 67.6636 14.3608 67.9155 14.3608ZM73.2876 15V9.18182H74.1371V11.3438H74.1882C74.2375 11.2528 74.3085 11.1477 74.4013 11.0284C74.4941 10.9091 74.6229 10.8049 74.7876 10.7159C74.9524 10.625 75.1702 10.5795 75.4411 10.5795C75.7933 10.5795 76.1077 10.6686 76.3842 10.8466C76.6607 11.0246 76.8776 11.2812 77.0348 11.6165C77.1939 11.9517 77.2734 12.3551 77.2734 12.8267C77.2734 13.2983 77.1948 13.7027 77.0376 14.0398C76.8804 14.375 76.6645 14.6335 76.3899 14.8153C76.1153 14.9953 75.8018 15.0852 75.4496 15.0852C75.1844 15.0852 74.9676 15.0407 74.799 14.9517C74.6323 14.8627 74.5017 14.7585 74.407 14.6392C74.3123 14.5199 74.2393 14.4138 74.1882 14.321H74.1172V15H73.2876ZM74.12 12.8182C74.12 13.125 74.1645 13.3939 74.2536 13.625C74.3426 13.8561 74.4714 14.0369 74.6399 14.1676C74.8085 14.2964 75.0149 14.3608 75.2592 14.3608C75.513 14.3608 75.7251 14.2936 75.8956 14.1591C76.0661 14.0227 76.1948 13.8381 76.282 13.6051C76.371 13.3722 76.4155 13.1098 76.4155 12.8182C76.4155 12.5303 76.3719 12.2718 76.2848 12.0426C76.1996 11.8134 76.0708 11.6326 75.8984 11.5C75.728 11.3674 75.5149 11.3011 75.2592 11.3011C75.013 11.3011 74.8047 11.3646 74.6342 11.4915C74.4657 11.6184 74.3378 11.7955 74.2507 12.0227C74.1636 12.25 74.12 12.5152 74.12 12.8182ZM78.6158 16.6364C78.4889 16.6364 78.3733 16.6259 78.2692 16.6051C78.165 16.5862 78.0874 16.5653 78.0362 16.5426L78.2408 15.8466C78.3961 15.8883 78.5343 15.9063 78.6555 15.9006C78.7768 15.8949 78.8838 15.8494 78.9766 15.7642C79.0713 15.679 79.1546 15.5398 79.2266 15.3466L79.3317 15.0568L77.7351 10.6364H78.6442L79.7493 14.0227H79.7947L80.8999 10.6364H81.8118L80.0135 15.5824C79.9302 15.8097 79.8241 16.0019 79.6953 16.1591C79.5665 16.3182 79.4131 16.4375 79.2351 16.517C79.0571 16.5966 78.8506 16.6364 78.6158 16.6364Z"),be.setAttribute("fill","black"),be.setAttribute("fill-opacity","0.5"),N.appendChild(be);const tt=document.createElementNS("http://www.w3.org/2000/svg","rect");tt.setAttribute("x","7"),tt.setAttribute("y","7"),tt.setAttribute("width","24"),tt.setAttribute("height","24"),tt.setAttribute("rx","3"),tt.setAttribute("fill","black"),N.appendChild(tt);const _t=document.createElementNS("http://www.w3.org/2000/svg","path");_t.setAttribute("fill-rule","evenodd"),_t.setAttribute("clip-rule","evenodd"),_t.setAttribute("d","M22.0455 15H12.2273L15.1364 17.9091V21.9091L22.0455 15Z"),_t.setAttribute("fill","white"),N.appendChild(_t);const Bt=document.createElementNS("http://www.w3.org/2000/svg","path");Bt.setAttribute("fill-rule","evenodd"),Bt.setAttribute("clip-rule","evenodd"),Bt.setAttribute("d","M16.9546 22.9999H26.7728L23.8637 20.0908V16.0908L16.9546 22.9999Z"),Bt.setAttribute("fill","white"),N.appendChild(Bt),L.appendChild(N),j.appendChild(L);const qe=document.createElement("button");qe.id="liveblocks-badge-hide-button",qe.style.position="absolute",qe.style.top="0",qe.style.right="0",qe.style.border="none",qe.style.padding="0",qe.style.margin="0",qe.style.background="none",qe.style.font="inherit",qe.style.cursor="pointer",qe.style.outline="none",qe.style.setProperty("-webkit-appearance","none"),qe.style.setProperty("-moz-appearance","none"),qe.style.setProperty("appearance","none"),qe.style.opacity="0",qe.onclick=()=>{const Xn=document.getElementById("liveblocks-badge");Xn&&(Xn.style.display="none")},qe.onmouseenter=()=>{qe.style.opacity="0.5"},qe.onmouseleave=()=>{qe.style.opacity="0.3"};const vn=document.createElementNS("http://www.w3.org/2000/svg","svg");vn.setAttribute("width","18"),vn.setAttribute("height","18"),vn.setAttribute("viewBox","0 0 18 18"),vn.setAttribute("fill","none");const Ca=document.createElementNS("http://www.w3.org/2000/svg","path");Ca.setAttribute("d","M6 6L9 9M12 12L9 9M9 9L12 6M9 9L6 12"),Ca.setAttribute("stroke","black"),vn.appendChild(Ca),qe.appendChild(vn),j.appendChild(qe),document.body.appendChild(j),requestAnimationFrame((()=>{requestAnimationFrame((()=>{j.style.opacity="1"}))}))})(t.badgeLocation??"bottom-right");for(const P of l.others.connectionIds())O.users[P]===void 0&&l.others.removeConnection(P);for(const P in O.users){const j=O.users[P],L=Number(P);l.others.setConnection(L,j.id,j.info,Md(j.scopes))}return{type:"reset"}}function ne(){return l.undoStack.length>0}function _(){return l.redoStack.length>0}function X(){h>0||C.history.notify({canUndo:ne(),canRedo:_()})}function K(O){l.others.setConnection(O.actor,O.id,O.info,Md(O.scopes)),l.buffer.messages.push({type:at.UPDATE_PRESENCE,data:l.myPresence.get(),targetActor:O.actor}),fe();const P=l.others.getUser(O.actor);return P?{type:"enter",user:P}:void 0}function Y(O){return(function(P){return!(function(j){return j===null||typeof j=="string"||typeof j=="number"||typeof j=="boolean"})(P)&&!jd(P)})(O)?O:null}function de(O){return O.type===xe.FEED_REQUEST_FAILED}function pe(O){if(typeof O.data!="string")return;const P=(function(L){const N=Hn(L);return N===void 0?null:jd(N)?yu(N.map((ce=>Y(ce)))):yu([Y(N)])})(O.data);if(P===null||P.length===0)return;const j={storageUpdates:new Map,others:[]};for(const L of P)switch(L.type){case xe.USER_JOINED:{const N=K(L);N&&j.others.push(N);break}case xe.UPDATE_PRESENCE:{const N=ie(L);N&&j.others.push(N);break}case xe.BROADCASTED_EVENT:{const N=l.others.get();C.customEvent.notify({connectionId:L.actor,user:L.actor<0?null:N.find((ce=>ce.connectionId===L.actor))??null,event:L.event});break}case xe.USER_LEFT:{const N=Se(L);N&&j.others.push(N);break}case xe.UPDATE_YDOC:C.ydoc.notify(L);break;case xe.ROOM_STATE:j.others.push(Ie(L));break;case xe.STORAGE_CHUNK:y?.lap(),g.append(O1(L.nodes));break;case xe.STORAGE_STREAM_END:{const N=y?.stop();if(N){const ce=Fe=>`${Fe.toFixed(1)}ms`,Ee=N.laps.slice(1);mt(`Storage chunk arrival: ${[`total=${ce(N.total)}`,`first=${ce(N.laps[0])}`,`rest.n=${Ee.length}`,`rest.avg=${ce(Ee.reduce(((Fe,be)=>Fe+be),0)/Ee.length)}`,`rest.max=${ce(Ee.reduce(((Fe,be)=>Math.max(Fe,be)),0))}`].join(", ")}`)}oe(g.take());break}case xe.UPDATE_STORAGE:{const N=V(L.ops);for(const[ce,Ee]of N.updates.storageUpdates)j.storageUpdates.set(ce,ns(j.storageUpdates.get(ce),Ee));break}case xe.REJECT_STORAGE_OP:{Up("Storage mutation rejection error",L.reason);let N=!1;for(const ce of L.opIds){const Ee=l.unacknowledgedOps.get(ce);if(l.unacknowledgedOps.delete(ce),l.buffer.storageOperations=l.buffer.storageOperations.filter((Fe=>Fe.opId!==ce)),G.delete(ce),Ee!==void 0&&Ee.type===ue.UPDATE_TEXT){const Fe=l.pool.nodes.get(Ee.id);Fe!==void 0&&Fu(Fe)&&(Fe._rejectPendingOp(ce),N=!0)}}N&&(ge(),fe());break}case xe.THREAD_CREATED:case xe.THREAD_DELETED:case xe.THREAD_METADATA_UPDATED:case xe.THREAD_UPDATED:case xe.COMMENT_REACTION_ADDED:case xe.COMMENT_REACTION_REMOVED:case xe.COMMENT_CREATED:case xe.COMMENT_EDITED:case xe.COMMENT_DELETED:case xe.COMMENT_METADATA_UPDATED:C.comments.notify(L);break;case xe.FEEDS_LIST:{const N=L,ce=te.get(N.requestId);ce&&(ce.resolve({feeds:N.feeds,nextCursor:N.nextCursor}),te.delete(N.requestId)),C.feeds.notify(N);break}case xe.FEEDS_ADDED:{const N=L;C.feeds.notify(N),J(N);break}case xe.FEEDS_UPDATED:{const N=L;C.feeds.notify(N),J(N);break}case xe.FEED_DELETED:C.feeds.notify(L),J(L);break;case xe.FEED_MESSAGES_LIST:{const N=L,ce=me.get(N.requestId);ce&&(ce.resolve({messages:N.messages,nextCursor:N.nextCursor}),me.delete(N.requestId)),C.feeds.notify(N);break}case xe.FEED_MESSAGES_ADDED:{const N=L;C.feeds.notify(N),J(N);break}case xe.FEED_MESSAGES_UPDATED:{const N=L;C.feeds.notify(N),J(N);break}case xe.FEED_MESSAGES_DELETED:C.feeds.notify(L),J(L);break;case xe.FEED_REQUEST_FAILED:{if(!de(L))break;const{requestId:N,code:ce,reason:Ee}=L,Fe=new Ru(Ee??"Feed request failed",{type:"FEED_REQUEST_ERROR",roomId:n,requestId:N,code:ce,reason:Ee});if(Ae.has(N))Be(N,"error",Fe);else if(te.has(N)){const be=te.get(N);te.delete(N),be?.reject(Fe)}else if(me.has(N)){const be=me.get(N);me.delete(N),be?.reject(Fe)}C.feeds.notify(L);break}case xe.STORAGE_STATE_V7:}W(j)}function fe(){const O=l.buffer.storageOperations;if(O.length>0){for(const L of O)l.unacknowledgedOps.add(L);Zn()}if(c.getStatus()!=="connected")return void(l.buffer.storageOperations=[]);const P=Date.now(),j=P-l.buffer.lastFlushedAt;if(j>=t.throttleDelay){const L=(function(){const N=[];l.buffer.presenceUpdates&&N.push(l.buffer.presenceUpdates.type==="full"?{type:at.UPDATE_PRESENCE,targetActor:-1,data:l.buffer.presenceUpdates.data}:{type:at.UPDATE_PRESENCE,data:l.buffer.presenceUpdates.data});for(const ce of l.buffer.messages)N.push(ce);return l.buffer.storageOperations.length>0&&N.push({type:at.UPDATE_STORAGE,ops:l.buffer.storageOperations}),N})();if(L.length===0)return;E(L),l.buffer={flushTimerID:void 0,lastFlushedAt:P,messages:[],storageOperations:[],presenceUpdates:null}}else clearTimeout(l.buffer.flushTimerID),l.buffer.flushTimerID=setTimeout(fe,t.throttleDelay-j)}function we(O){const{storageOperations:P}=l.buffer;for(const j of O)P.push(j);fe()}let Ce=null,se=null;const te=new Map,me=new Map,Ae=new Map,Pe=new Map;function Be(O,P,j){const L=Ae.get(O);if(L!==void 0){if(clearTimeout(L.timeoutId),Ae.delete(O),L.kind==="add-message"&&!L.expectedClientMessageId){const N=Pe.get(L.feedId);if(N!==void 0){const ce=N.indexOf(O);ce>=0&&N.splice(ce,1),N.length===0&&Pe.delete(L.feedId)}}P==="ok"?L.resolve():L.reject(j??new Error("Feed mutation failed"))}}function re(O,P,j,L){const{promise:N,resolve:ce,reject:Ee}=mo(),Fe=setTimeout((()=>{Ae.has(O)&&Be(O,"error",new Error("Feed mutation timeout"))}),ja);if(Ae.set(O,{resolve:ce,reject:Ee,timeoutId:Fe,kind:P,feedId:j,messageId:L?.messageId,expectedClientMessageId:L?.expectedClientMessageId}),P==="add-message"&&L?.expectedClientMessageId===void 0){const be=Pe.get(j)??[];be.push(O),Pe.set(j,be)}return N}function J(O){switch(O.type){case xe.FEEDS_ADDED:for(const P of O.feeds)for(const[j,L]of[...Ae])if(L.kind==="add-feed"&&L.feedId===P.feedId){Be(j,"ok");break}break;case xe.FEEDS_UPDATED:for(const P of O.feeds)for(const[j,L]of[...Ae])L.kind==="update-feed"&&L.feedId===P.feedId&&Be(j,"ok");break;case xe.FEED_DELETED:for(const[P,j]of[...Ae])if(j.kind==="delete-feed"&&j.feedId===O.feedId){Be(P,"ok");break}break;case xe.FEED_MESSAGES_ADDED:for(const P of O.messages){let j=!1;for(const[L,N]of[...Ae])if(N.kind==="add-message"&&N.feedId===O.feedId&&N.expectedClientMessageId===P.id){Be(L,"ok"),j=!0;break}if(!j){const L=Pe.get(O.feedId),N=L?.[0];if(N!==void 0){const ce=Ae.get(N);ce?.kind==="add-message"&&ce.expectedClientMessageId===void 0&&Be(N,"ok")}}}break;case xe.FEED_MESSAGES_UPDATED:for(const P of O.messages)for(const[j,L]of[...Ae])L.kind==="update-message"&&L.feedId===O.feedId&&L.messageId===P.id&&Be(j,"ok");break;case xe.FEED_MESSAGES_DELETED:for(const P of O.messageIds)for(const[j,L]of[...Ae])L.kind==="delete-message"&&L.feedId===O.feedId&&L.messageId===P&&Be(j,"ok")}}function oe(O){const P=[...l.unacknowledgedOps.values()];S(O),(function(j){if(j.length===0)return;const L=[],N=$(j);L.push({type:at.UPDATE_STORAGE,ops:N.opsToEmit}),W(N.updates),E(L)})(P),se?.(),Zn(),C.storageDidLoad.notify()}function ge(){const O=l.buffer.messages;O.some((P=>P.type===at.FETCH_STORAGE))||(O.push({type:at.FETCH_STORAGE}),g.take(),y?.start())}function ve(){return Ce===null&&(ge(),fe(),Ce=new Promise((O=>{se=O})),Zn()),Ce}function Te(){const O=l.root;return O!==void 0?O:(ve(),null)}async function We(){return l.root!==void 0?Promise.resolve({root:l.root}):(await ve(),{root:ye(l.root)})}function Le(){const O=l.pausedHistory;l.pausedHistory=null,O!==null&&O.length>0&&M(Array.from(O))}function et(O){const P=l.undoStack,j=l.redoStack,L=[],N=[];l.undoStack=L,l.redoStack=N,h++;try{return O()}finally{if(h--,l.undoStack!==L||l.redoStack!==N)throw new Error("unexpected stack swap during history.disable()");l.undoStack=P,l.redoStack=j}}const ut=t.createSyncSource();function Nt(){return l.root===void 0?Ce===null?"not-loaded":"loading":l.unacknowledgedOps.size===0?"synchronized":"synchronizing"}let mn=Nt();function Zn(){const O=Nt();mn!==O&&(mn=O,C.storageStatus.notify(O)),ut.setSyncStatus(O==="synchronizing"?"synchronizing":"synchronized")}function gn(){return A.get()!==null}function qi(){return Te()!==null}const ba=$e.from(l.others.signal,(O=>O.map(((P,j)=>Pd(`Other ${j}`,P))))),qo={status:C.status.observable,lostConnection:C.lostConnection.observable,customEvent:C.customEvent.observable,others:C.others.observable,self:C.self.observable,myPresence:C.myPresence.observable,storageBatch:C.storageBatch.observable,history:C.history.observable,storageDidLoad:C.storageDidLoad.observable,storageStatus:C.storageStatus.observable,ydoc:C.ydoc.observable,comments:C.comments.observable,feeds:C.feeds.observable,roomWillDestroy:C.roomWillDestroy.observable};function Gi(O){return i.getSubscriptionSettings({roomId:n,signal:O?.signal})}function Ji(O){return i.updateSubscriptionSettings({roomId:n,settings:O})}const Go=t.createSyncSource();function Jo(O){return Go.setSyncStatus(O==="synchronizing"||O==="loading"?"synchronizing":"synchronized")}return Object.defineProperty({[Oe]:{get presenceBuffer(){return Ci(l.buffer.presenceUpdates?.data??null)},get undoStack(){return structuredClone(l.undoStack.map((O=>({id:O.id,frames:O.frames}))))},get redoStack(){return structuredClone(l.redoStack.map((O=>({id:O.id,frames:O.frames}))))},get nodeCount(){return l.pool.nodes.size},history:C.privateHistory.observable,getYjsProvider:()=>l.yjsProvider,setYjsProvider(O){l.yjsProvider?.off("status",Jo),l.yjsProvider=O,O?.on("status",Jo),l.yjsProviderDidChange.notify()},yjsProviderDidChange:l.yjsProviderDidChange.observable,reportTextEditor:async function(O,P){await i.reportTextEditor({roomId:n,type:O,rootKey:P})},getPermissionMatrix:()=>l.dynamicSessionInfoSig.get()?.permissionMatrix,createTextMention:async function(O,P){return i.createTextMention({roomId:n,mentionId:O,mention:P})},deleteTextMention:async function(O){return i.deleteTextMention({roomId:n,mentionId:O})},listHistoryVersions:async function(){return i.listHistoryVersions({roomId:n})},listHistoryVersionsSince:async function(O){return i.listHistoryVersionsSince({roomId:n,since:O.since,signal:O.signal})},fetchStorageHistoryVersion:async function(O){return i.fetchStorageHistoryVersion({roomId:n,versionId:O})},fetchYjsHistoryVersion:async function(O){return i.fetchYjsHistoryVersion({roomId:n,versionId:O})},liveObjectFromNodeStream:Ay,reconcileStorageWithNodes:function(O){if(l.root===void 0)throw new Error("Cannot reconcile storage before it is loaded");const P=B(new Map(O),{includeLiveTextUpdates:!0});if(P.length===0)return;const j=$(P);j.reverse.length>0&&H(j.reverse),l.redoStack.length=0;for(const L of j.opsToEmit)l.buffer.storageOperations.push(L);W(j.updates),X(),fe()},createVersionHistorySnapshot:async function(){return i.createVersionHistorySnapshot({roomId:n})},deleteHistoryVersion:async function(O){return i.deleteHistoryVersion({roomId:n,versionId:O})},executeContextualPrompt:async function(O){return i.executeContextualPrompt({roomId:n,...O})},getSelf_forDevTools:()=>T.get(),getOthers_forDevTools:()=>ba.get(),simulate:{explicitClose:O=>c._privateSendMachineEvent({type:"EXPLICIT_SOCKET_CLOSE",event:O}),rawSend:O=>c.send(O),incomingMessage:O=>pe(new MessageEvent("message",{data:O}))},attachmentUrlsStore:i.getOrCreateAttachmentUrlsStore(n),fileUrlsStore:i.getOrCreateFileUrlsStore(n)},id:n,subscribe:jy(n,C,t.errorEventSource),connect:()=>c.connect(),reconnect:()=>c.reconnect(),disconnect:()=>c.disconnect(),_dump:()=>{const O=l.pool.nodes.size;return`Room "${n}" (${O} node${O===1?"":"s"}):
4
+ ${(function(P){const j=Array.from(P.nodes.values(),(L=>{const N=L.parent,ce=N.type==="HasParent"?N.node._id??"?":N.type==="Orphaned"?"<orphaned>":"-";let Ee;return Ee=L instanceof qn?Pr(L.data):L instanceof yr?"<LiveList>":L instanceof qr?"<LiveMap>":L instanceof vr?Pr(L.data):"<LiveObject>",{id:ye(L._id),parentId:ce,key:L._parentKey??"",value:Ee}}));return j.sort(((L,N)=>L.parentId!==N.parentId?L.parentId<N.parentId?-1:1:L.key!==N.key?L.key<N.key?-1:1:0)),j.map((L=>` ${L.id} parent=${L.parentId} key=${L.key||"—"} ${L.value}`)).join(`
5
+ `)})(l.pool)}`},destroy:()=>{te.forEach((j=>j.reject(new Error("Room destroyed")))),me.forEach((j=>j.reject(new Error("Room destroyed"))));const{roomWillDestroy:O,...P}=C;for(const j of Object.values(P))j.dispose();C.roomWillDestroy.notify(),l.yjsProvider?.off("status",Jo),ut.destroy(),Go.destroy(),a(),c.destroy(),O.dispose()},updatePresence:function(O,P){const j={};l.buffer.presenceUpdates===null&&(l.buffer.presenceUpdates={type:"partial",data:{}});for(const L in O){const N=O[L];N!==void 0&&(l.buffer.presenceUpdates.data[L]=N,j[L]=l.myPresence.get()[L])}l.myPresence.patch(O),l.activeBatch?(P?.addToHistory&&l.activeBatch.reverseOps.pushLeft({type:"presence",data:j}),l.activeBatch.updates.presence=!0):(fe(),P?.addToHistory&&H([{type:"presence",data:j}]),W({presence:!0}))},updateYDoc:function(O,P,j){const L={type:at.UPDATE_YDOC,update:O,guid:P,v2:j};l.buffer.messages.push(L),C.ydoc.notify(L),fe()},broadcastEvent:function(O,P={shouldQueueEventIfNotReady:!1}){(c.getStatus()==="connected"||P.shouldQueueEventIfNotReady)&&(l.buffer.messages.push({type:at.BROADCAST_EVENT,event:O}),fe())},batch:function(O){if(l.activeBatch)return O();let P;l.activeBatch={ops:[],updates:{storageUpdates:new Map,presence:!1,others:[]},reverseOps:new Ra,scheduleHistoryResume:!1};try{P=O()}finally{const j=l.activeBatch;l.activeBatch=null,j.reverseOps.length>0&&H(Array.from(j.reverseOps)),j.scheduleHistoryResume&&Le(),(j.ops.length>0||j.clearRedoStack)&&R(),j.ops.length>0&&we(j.ops),W(j.updates),fe()}return P},history:{undo:function(){if(l.activeBatch)throw new Error("undo is not allowed during a batch");const O=l.undoStack.pop();if(O===void 0)return;l.pausedHistory=null;const P=$(O.frames,k1);l.redoStack.push({id:O.id,frames:P.reverse}),k({action:"undo",id:O.id}),W(P.updates),X();for(const j of P.opsToEmit)l.buffer.storageOperations.push(j);fe()},redo:function(){if(l.activeBatch)throw new Error("redo is not allowed during a batch");const O=l.redoStack.pop();if(O===void 0)return;l.pausedHistory=null;const P=$(O.frames,_1);l.undoStack.push({id:O.id,frames:P.reverse}),k({action:"redo",id:O.id}),W(P.updates),X();for(const j of P.opsToEmit)l.buffer.storageOperations.push(j);fe()},canUndo:ne,canRedo:_,clear:function(){l.undoStack.length=0,l.redoStack.length=0,k({action:"clear"}),X()},pause:function(){l.pausedHistory===null&&(l.pausedHistory=new Ra)},resume:function(){l.activeBatch===null?Le():l.activeBatch.scheduleHistoryResume=!0},disable:et},fetchYDoc:function(O,P,j){l.buffer.messages.find((L=>L.type===at.FETCH_YDOC&&L.vector===O&&L.guid===P&&L.v2===j))||l.buffer.messages.push({type:at.FETCH_YDOC,vector:O,guid:P,v2:j}),fe()},fetchFeeds:async function(O){const P=st(),{promise:j,resolve:L,reject:N}=mo();te.set(P,{resolve:L,reject:N});const ce={type:at.FETCH_FEEDS,requestId:P,cursor:O?.cursor,since:O?.since,limit:O?.limit,metadata:O?.metadata};return l.buffer.messages.push(ce),fe(),setTimeout((()=>{te.has(P)&&(te.delete(P),N(new Error("Feeds fetch timeout")))}),ja),j},fetchFeedMessages:async function(O,P){const j=st(),{promise:L,resolve:N,reject:ce}=mo();me.set(j,{resolve:N,reject:ce});const Ee={type:at.FETCH_FEED_MESSAGES,requestId:j,feedId:O,cursor:P?.cursor,since:P?.since,limit:P?.limit};return l.buffer.messages.push(Ee),fe(),setTimeout((()=>{me.has(j)&&(me.delete(j),ce(new Error("Feed messages fetch timeout")))}),ja),L},addFeed:function(O,P){const j=st(),L=re(j,"add-feed",O),N={type:at.ADD_FEED,requestId:j,feedId:O,metadata:P?.metadata,createdAt:P?.createdAt};return l.buffer.messages.push(N),fe(),L},updateFeed:function(O,P){const j=st(),L=re(j,"update-feed",O),N={type:at.UPDATE_FEED,requestId:j,feedId:O,metadata:P};return l.buffer.messages.push(N),fe(),L},deleteFeed:function(O){const P=st(),j=re(P,"delete-feed",O),L={type:at.DELETE_FEED,requestId:P,feedId:O};return l.buffer.messages.push(L),fe(),j},addFeedMessage:function(O,P,j){const L=st(),N=re(L,"add-message",O,{expectedClientMessageId:j?.id}),ce={type:at.ADD_FEED_MESSAGE,requestId:L,feedId:O,data:P,id:j?.id,createdAt:j?.createdAt};return l.buffer.messages.push(ce),fe(),N},updateFeedMessage:function(O,P,j,L){const N=st(),ce=re(N,"update-message",O,{messageId:P}),Ee={type:at.UPDATE_FEED_MESSAGE,requestId:N,feedId:O,messageId:P,data:j,updatedAt:L?.updatedAt};return l.buffer.messages.push(Ee),fe(),ce},deleteFeedMessage:function(O,P){const j=st(),L=re(j,"delete-message",O,{messageId:P}),N={type:at.DELETE_FEED_MESSAGE,requestId:j,feedId:O,messageId:P};return l.buffer.messages.push(N),fe(),L},getStorage:We,getStorageOrNull:Te,getStorageSnapshot:Te,getStorageStatus:Nt,isPresenceReady:gn,isStorageReady:qi,waitUntilPresenceReady:ad((async function(){for(;!gn();){const{promise:O,resolve:P}=mo(),j=qo.self.subscribeOnce(P),L=qo.status.subscribeOnce(P);await O,j(),L()}})),waitUntilStorageReady:ad((async function(){for(;!qi();)await We()})),events:qo,getStatus:()=>c.getStatus(),getSelf:()=>A.get(),getPresence:()=>l.myPresence.get(),getOthers:()=>l.others.get(),getThreads:async function(O){return i.getThreads({roomId:n,query:O?.query,cursor:O?.cursor})},getThreadsSince:async function(O){return i.getThreadsSince({roomId:n,since:O.since,signal:O.signal})},getThread:async function(O){return i.getThread({roomId:n,threadId:O})},createThread:async function(O){return i.createThread({roomId:n,threadId:O.threadId,commentId:O.commentId,visibility:O.visibility,metadata:O.metadata,body:O.body,commentMetadata:O.commentMetadata,attachmentIds:O.attachmentIds})},deleteThread:async function(O){return i.deleteThread({roomId:n,threadId:O})},editThreadMetadata:async function({metadata:O,threadId:P}){return i.editThreadMetadata({roomId:n,threadId:P,metadata:O})},markThreadAsResolved:async function(O){return i.markThreadAsResolved({roomId:n,threadId:O})},markThreadAsUnresolved:async function(O){return i.markThreadAsUnresolved({roomId:n,threadId:O})},subscribeToThread:async function(O){return i.subscribeToThread({roomId:n,threadId:O})},unsubscribeFromThread:async function(O){return i.unsubscribeFromThread({roomId:n,threadId:O})},createComment:async function(O){return i.createComment({roomId:n,threadId:O.threadId,commentId:O.commentId,body:O.body,metadata:O.metadata,attachmentIds:O.attachmentIds})},editComment:async function(O){return i.editComment({roomId:n,threadId:O.threadId,commentId:O.commentId,body:O.body,metadata:O.metadata,attachmentIds:O.attachmentIds})},editCommentMetadata:async function({threadId:O,commentId:P,metadata:j}){return i.editCommentMetadata({roomId:n,threadId:O,commentId:P,metadata:j})},deleteComment:async function({threadId:O,commentId:P}){return i.deleteComment({roomId:n,threadId:O,commentId:P})},addReaction:async function({threadId:O,commentId:P,emoji:j}){return i.addReaction({roomId:n,threadId:O,commentId:P,emoji:j})},removeReaction:async function({threadId:O,commentId:P,emoji:j}){return await i.removeReaction({roomId:n,threadId:O,commentId:P,emoji:j})},prepareAttachment:function(O){return{type:"localAttachment",status:"idle",id:Kp(),name:O.name,size:O.size,mimeType:O.type,file:O}},uploadAttachment:async function(O,P={}){return i.uploadAttachment({roomId:n,attachment:O,signal:P.signal})},getAttachmentUrl:function(O){return i.getAttachmentUrl({roomId:n,attachmentId:O})},uploadFile:function(O,P={}){return i.uploadFile({roomId:n,file:O,signal:P.signal})},getFileUrl:function(O){return i.getFileUrl({roomId:n,fileId:B1(O)})},getNotificationSettings:Gi,getSubscriptionSettings:Gi,updateNotificationSettings:Ji,updateSubscriptionSettings:Ji,markInboxNotificationAsRead:async function(O){await i.markRoomInboxNotificationAsRead({roomId:n,inboxNotificationId:O})}},Oe,{enumerable:!1})}function jy(e,t,n){function r(o,i){return t.storageBatch.subscribe((s=>{const a=s.filter((u=>cm(u.node,o)));a.length>0&&i(a)}))}return function(o,i,s){if(typeof o=="string"&&((a=o)==="my-presence"||a==="others"||a==="event"||a==="error"||a==="history"||a==="status"||a==="storage-status"||a==="lost-connection"||a==="connection"||a==="comments")){if(typeof i!="function")throw new Error("Second argument must be a callback function");const u=i;switch(o){case"event":return t.customEvent.subscribe(u);case"my-presence":return t.myPresence.subscribe(u);case"others":{const c=u;return t.others.subscribe((f=>{const{others:l,...d}=f;return c(l,d)}))}case"error":return n.subscribe((c=>{if(c.roomId===e)return u(c)}));case"status":return t.status.subscribe(u);case"lost-connection":return t.lostConnection.subscribe(u);case"history":return t.history.subscribe(u);case"storage-status":return t.storageStatus.subscribe(u);case"comments":return t.comments.subscribe(u);default:return Ye(0,`"${String(o)}" is not a valid event name`)}}var a;if(i===void 0||typeof o=="function"){if(typeof o=="function"){const u=o;return t.storageBatch.subscribe(u)}throw new Error("Please specify a listener callback")}if(ot(o)){const u=o;return s?.isDeep?r(u,i):(function(c,f){return t.storageBatch.subscribe((l=>{for(const d of l)d.node._id===c._id&&f(d.node)}))})(u,i)}throw new Error(`${String(o)} is not a value that can be subscribed to.`)}}function My(e,t){return async()=>t.getAuthValue({roomId:e,resource:"room",access:"read"})}function Py(e,t,n){return r=>{const o=n??(typeof WebSocket>"u"?void 0:WebSocket);if(o===void 0)throw new Pn("To use Liveblocks client in a non-DOM environment, you need to provide a WebSocket polyfill.");const i=new URL(t);if(i.protocol=i.protocol==="http:"?"ws":"wss",i.pathname="/v8",i.searchParams.set("roomId",e),r.type==="secret")i.searchParams.set("tok",r.token.raw);else{if(r.type!=="public")return Ye(0,"Unhandled case");i.searchParams.set("pubkey",r.publicApiKey)}return i.searchParams.set("version",ea),new o(i.toString())}}function Ny(e){const t=e,n=(function(S){return typeof S=="string"&&S.startsWith("http")?S:"https://api.liveblocks.io"})(t.baseUrl),r=ju("throttle",t.throttle??100,16,1e3),o=(function(S){return ju("lostConnectionTimeout",S,200,3e4,1e3)})(t.lostConnectionTimeout??5e3),i=Nd(t.backgroundKeepAliveTimeout),s=new Tt(void 0),a=hy(e,(S=>{s.set((()=>S.uid))})),u=t.polyfills?.fetch||globalThis.fetch?.bind(globalThis),c=V1({baseUrl:n,fetchPolyfill:u,authManager:a}),f=new Map,l=oy({userId:s.get(),lostConnectionTimeout:o,backgroundKeepAliveTimeout:Nd(t.backgroundKeepAliveTimeout),polyfills:t.polyfills,delegates:{createSocket:iy(n,t.polyfills?.WebSocket),authenticate:async()=>{const S=await a.getAuthValue({resource:"personal",access:"write"});if(S.type==="public")throw new Pn("Cannot use AI Copilots with a public API key");return S},canZombie:()=>!1}});function d(S){const k=()=>{const R=k;var M;S.unsubs.delete(R)?S.unsubs.size===0&&((M=S.room).id,f.delete(M.id),M.destroy()):mt("This leave function was already called. Calling it more than once has no effect.")};return S.unsubs.add(k),{room:S.room,leave:k}}const h=t.resolveUsers,g=yo(new sr((async S=>{const k=S.flat(),R=await h?.({userIds:k});return Fa(!h,"Set the resolveUsers option in createClient to specify user info."),R??k.map((()=>{}))}),{delay:50})),y=t.resolveRoomsInfo,p=yo(new sr((async S=>{const k=S.flat(),R=await y?.({roomIds:k});return Fa(!y,"Set the resolveRoomsInfo option in createClient to specify room info."),R??k.map((()=>{}))}),{delay:50})),w=t.resolveGroupsInfo,b=yo(new sr((async S=>{const k=S.flat(),R=await w?.({groupIds:k});return Fa(!w,"Set the resolveGroupsInfo option in createClient to specify group info."),R??k.map((()=>{}))}),{delay:50})),C=new Map,E=[],A=new Tt("synchronized"),x=Ue();function I(){A.set(E.some((S=>S.get()==="synchronizing"))?"synchronizing":E.some((S=>S.get()==="has-local-changes"))?"has-local-changes":"synchronized")}function T(){const S=new Tt("synchronized");E.push(S);const k=S.subscribe((()=>I()));return{setSyncStatus:function(R){S.set(R)},getStatus:function(){return S.get()},destroy:function(){k();const R=E.findIndex((M=>M===S));if(R>-1){const[M]=E.splice(R,1);M.get()!=="synchronized"&&I()}}}}{const S=R=>{t.preventUnsavedChanges&&A.get()!=="synchronized"&&R.preventDefault()};(typeof window<"u"?window:void 0)?.addEventListener("beforeunload",S)}const B=Object.defineProperty({enterRoom:function(S,...k){const R=f.get(S);if(R!==void 0)return d(R);const M=k[0]??{},H=(typeof M.initialPresence=="function"?M.initialPresence(S):M.initialPresence)??{},W=(typeof M.initialStorage=="function"?M.initialStorage(S):M.initialStorage)??{};let G;if(Hc(W)){const V={};for(const Q of W.keys())V[Q]=W.get(Q);G=V}else G=W;const q=Ry({initialPresence:H,initialStorage:G},{roomId:S,throttleDelay:r,lostConnectionTimeout:o,backgroundKeepAliveTimeout:i,polyfills:t.polyfills,delegates:t.mockedDelegates??{createSocket:Py(S,n,t.polyfills?.WebSocket),authenticate:My(S,a)},enableDebugLogging:t.enableDebugLogging,baseUrl:n,errorEventSource:x,roomHttpClient:c,createSyncSource:T,badgeLocation:t.badgeLocation??"bottom-right"}),$={room:q,unsubs:new Set};if(f.set(S,$),M.autoConnect??!0){if(typeof atob>"u"){if(t.polyfills?.atob===void 0)throw new Error("You need to polyfill atob to use the client in your environment. Please follow the instructions at https://liveblocks.io/docs/errors/liveblocks-client/atob-polyfill");vu.atob=t.polyfills.atob}q.connect()}return d($)},getRoom:function(S){return f.get(S)?.room||null},_dump:()=>Array.from(f.values(),(({room:S})=>S._dump())).join(`
6
+
7
+ `),logout:function(){a.reset(),s.set((()=>{}));for(const{room:k}of f.values())(S=k.getStatus())!=="initial"&&S!=="disconnected"&&k.reconnect();var S},getInboxNotifications:c.getInboxNotifications,getInboxNotificationsSince:c.getInboxNotificationsSince,getUnreadInboxNotificationsCount:c.getUnreadInboxNotificationsCount,markAllInboxNotificationsAsRead:c.markAllInboxNotificationsAsRead,markInboxNotificationAsRead:c.markInboxNotificationAsRead,deleteAllInboxNotifications:c.deleteAllInboxNotifications,deleteInboxNotification:c.deleteInboxNotification,getNotificationSettings:async function(S){return Ps(await c.getNotificationSettings(S))},updateNotificationSettings:async function(S){return Ps(await c.updateNotificationSettings(S))},resolvers:{invalidateUsers:function(S){g.invalidate(S)},invalidateRoomsInfo:function(S){p.invalidate(S)},invalidateGroupsInfo:function(S){b.invalidate(S)},invalidateMentionSuggestions:function(){C.clear()}},getSyncStatus:function(){const S=A.get();return S==="synchronizing"?S:"synchronized"},events:{error:x,syncStatus:A},[Oe]:{currentUserId:s,mentionSuggestionsCache:C,ai:l,resolveMentionSuggestions:t.resolveMentionSuggestions,usersStore:g,roomsInfoStore:p,groupsInfoStore:b,getRoomIds:()=>Array.from(f.keys()),httpClient:c,as:()=>B,createSyncSource:T,emitError:(S,k)=>{const R=Ru.from(S,k);x.notify(R)||Vn(R.message)}}},Oe,{enumerable:!1});return B}function ju(e,t,n,r,o){if(typeof t!="number"||t<n||r!==void 0&&t>r)throw new Error(r!==void 0?`${e} should be between ${o??n} and ${r}.`:`${e} should be at least ${o??n}.`);return t}function Nd(e){if(e!==void 0)return ju("backgroundKeepAliveTimeout",e,15e3)}function pm(e){return"type"in e&&e.type==="mention"}function mm(e){return"type"in e&&e.type==="link"}new RegExp(Object.keys({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"}).map((e=>`\\${e}`)).join("|"),"g");new RegExp(Object.keys({_:"\\_","*":"\\*","#":"\\#","`":"\\`","~":"\\~","!":"\\!","|":"\\|","(":"\\(",")":"\\)","{":"\\{","}":"\\}","[":"\\[","]":"\\]"}).map((e=>`\\${e}`)).join("|"),"g");var Ma=[1e3,2e3,4e3,8e3,1e4];function Fr(e,t,n){const r=performance.now(),o=typeof document<"u"?document:void 0,i=typeof window<"u"?window:void 0,s=n?.maxStaleTimeMs??Number.POSITIVE_INFINITY,a={inForeground:o?.visibilityState!=="hidden",lastSuccessfulPollAt:r,count:0,backoff:0};function u(){return a.count>0&&a.inForeground}const c=new Jp({}).addState("@idle").addState("@enabled").addState("@polling");function f(){u()?c.send({type:"START"}):c.send({type:"STOP"})}function l(){performance.now()-a.lastSuccessfulPollAt>s&&c.send({type:"POLL"})}function d(g){a.inForeground=g,f(),l()}function h(){d(o?.visibilityState!=="hidden")}return c.addTransitions("@idle",{START:"@enabled"}),c.addTransitions("@enabled",{STOP:"@idle",POLL:"@polling"}),c.addTimedTransition("@enabled",(()=>{const g=a.lastSuccessfulPollAt+t;return Math.max(0,g-performance.now())+a.backoff}),"@polling"),c.onEnterAsync("@polling",(async(g,y)=>{await e(y),y.aborted||(a.lastSuccessfulPollAt=performance.now())}),(()=>({target:u()?"@enabled":"@idle",effect:()=>{a.backoff=0}})),(()=>({target:u()?"@enabled":"@idle",effect:()=>{a.backoff=Ma.find((g=>g>a.backoff))??Ma[Ma.length-1]}})),3e4),o?.addEventListener("visibilitychange",h),i?.addEventListener("online",h),i?.addEventListener("focus",l),c.start(),{inc:function(){a.count++,f()},dec:function(){a.count--,a.count<0&&(a.count=0),f()},pollNowIfStale:l,markAsStale:function(){a.lastSuccessfulPollAt=performance.now()-s-1},setInForeground:d}}function Rr(e,t){return typeof e=="string"?`${e}:${t}`:`${e.kind}:${e.subjectId}`}Ip("@liveblocks/core",ea,"esm");var gm=m.createContext(null);function Vc(){return m.useContext(gm)}function Ve(){return Vc()??hn("LiveblocksProvider is missing from the React tree.")}var Gr=m.createContext(null);function ra(e){const t=m.useRef(e);return m.useEffect((()=>{t.current=e}),[e]),t}function rn(e,t){return m.useMemo((()=>e),[t])}function Qo(e,t){const n=rn(e,t),r=ra(e),o=m.useCallback(((...i)=>r.current(...i)),[r]);return typeof n=="function"?o:n}function Pi(e,t,n,r,o){const i=m.useRef(null);let s;i.current===null?(s={hasValue:!1,value:null},i.current=s):s=i.current;const[a,u]=m.useMemo((()=>{let f,l,d=!1;const h=y=>{if(!d){d=!0,f=y;const b=r(y);if(o!==void 0&&s.hasValue){const C=s.value;if(o(C,b))return l=C,C}return l=b,b}const p=l;if((function(b,C){return b===C&&(b!==0||1/b==1/C)||b!=b&&C!=C})(f,y))return p;const w=r(y);return o!==void 0&&o(p,w)?(f=y,p):(f=y,l=w,w)},g=n===void 0?null:n;return[()=>h(t()),g===null?void 0:()=>h(g())]}),[t,n,r,o]),c=m.useSyncExternalStore(e,a,u);return m.useEffect((()=>{s.hasValue=!0,s.value=c}),[c]),m.useDebugValue(c),c}m.memo((function(e){const t=m.useId(),n=Ve()[Oe].ai,{description:r,value:o,chatId:i}=e,[s,a]=m.useState();m.useEffect((()=>{const{layerKey:f,deregister:l}=n.registerKnowledgeLayer(t,i);return a(f),()=>{l(),a(void 0)}}),[n,t,i]);const u=m.useState(st)[0],c=e.id??u;return m.useEffect((()=>{s!==void 0&&n.updateKnowledge(s,{description:r,value:o},c,i)}),[n,s,c,r,o,i]),null})),m.memo((function({chatId:e,name:t,tool:n,enabled:r}){const o=Ve()[Oe].ai;return m.useEffect((()=>{const i=r!==void 0?{...n,enabled:r}:n;return o.registerTool(t,i,e)}),[o,e,t,n,r]),null}));var Ly=e=>e;function Vo(e,t,n){if(e instanceof Ot)throw new Error("Using a mutable Signal with useSignal will likely not work as expected.");return Pi(e.subscribe,e.get,e.get,t??Ly,n)}var Ft={NOTIFICATIONS_POLL_INTERVAL:6e4,NOTIFICATIONS_MAX_STALE_TIME:5e3,ROOM_THREADS_POLL_INTERVAL:3e5,ROOM_THREADS_MAX_STALE_TIME:5e3,USER_THREADS_POLL_INTERVAL:6e4,USER_THREADS_MAX_STALE_TIME:3e4,HISTORY_VERSIONS_POLL_INTERVAL:6e4,HISTORY_VERSIONS_MAX_STALE_TIME:5e3,ROOM_SUBSCRIPTION_SETTINGS_POLL_INTERVAL:6e4,ROOM_SUBSCRIPTION_SETTINGS_MAX_STALE_TIME:5e3,USER_NOTIFICATION_SETTINGS_INTERVAL:3e5,USER_NOTIFICATION_SETTINGS_MAX_STALE_TIME:6e4},Ns=Object.freeze({isLoading:!0}),vm=e=>Object.freeze({isLoading:!1,error:e});function on(e,t){return arguments.length===1?Object.freeze({isLoading:!1,data:e}):Object.freeze({isLoading:!1,[e]:t})}function $c(e){const t=new Set;t.add("constructor");let n=e.constructor.prototype;do for(const r of Reflect.ownKeys(n)){if(t.has(r))continue;typeof Reflect.getOwnPropertyDescriptor(n,r)?.value=="function"&&(t.add(r),e[r]=e[r].bind(e))}while((n=Reflect.getPrototypeOf(n))&&n!==Object.prototype)}function Uy(e,t){return n=>(function(r,o,i){let s;return i&&(s=i?.[Rr("thread",r.id)]),(o.resolved===void 0||r.resolved===o.resolved)&&(o.visibility===void 0||r.visibility===o.visibility)&&(o.subscribed===void 0||o.subscribed===!0&&s!==void 0||o.subscribed===!1&&s===void 0)})(n,e,t)&&(function(r,o){const i=r.metadata;return o.metadata===void 0||Object.entries(o.metadata).every((([s,a])=>a===void 0||(function(u,c){return c===null?u===void 0:Au(c)?typeof u=="string"&&u.startsWith(c.startsWith):xu(c)?typeof u=="number"&&(function(f,l){return(l.lt===void 0||f<l.lt)&&(l.gt===void 0||f>l.gt)&&(l.lte===void 0||f<=l.lte)&&(l.gte===void 0||f>=l.gte)})(u,c):u===c})(i[s],a)))})(n,e)}var Hy=class ym{#e;#t;#n;signal;constructor(){this.#t=ar.from([],((t,n)=>{const r=t.createdAt,o=n.createdAt;return r<o||r===o&&t.id<n.id})),this.#n=ar.from([],((t,n)=>{const r=n.updatedAt,o=t.updatedAt;return r<o||r===o&&n.id<t.id})),this.#e=new Map,this.signal=new Ot(this)}clone(){const t=new ym;return t.#e=new Map(this.#e),t.#t=this.#t.clone(),t.#n=this.#n.clone(),t}get(t){const n=this.getEvenIfDeleted(t);return n?.deletedAt?void 0:n}getEvenIfDeleted(t){return this.#e.get(t)}upsert(t){this.signal.mutate((()=>{const n=(t=(function(o){return o.deletedAt&&o.comments.length>0?{...o,comments:[]}:o.comments.some((i=>!i.deletedAt))?o:{...o,deletedAt:new Date,comments:[]}})(t)).id,r=this.#e.get(n);if(r){if(r.deletedAt)return!1;this.#t.remove(r),this.#n.remove(r)}return t.deletedAt||(this.#t.add(t),this.#n.add(t)),this.#e.set(n,t),!0}))}upsertIfNewer(t){const n=this.get(t.id);(!n||t.updatedAt>=n.updatedAt)&&this.upsert(t)}applyDelta(t,n){Xe((()=>{for(const r of t)this.upsertIfNewer(r);for(const{id:r,deletedAt:o}of n)this.getEvenIfDeleted(r)&&this.delete(r,o)}))}delete(t,n){const r=this.#e.get(t);r&&!r.deletedAt&&this.upsert({...r,deletedAt:n,updatedAt:n})}findMany(t,n,r,o){const i=r==="desc"?this.#n:this.#t,s=[];return t!==void 0&&s.push((a=>a.roomId===t)),n!==void 0&&s.push(Uy(n,o)),Array.from(i.filter((a=>s.every((u=>u(a))))))}};function bm(e){if("status"in e)return e;const t=e;return t.status="pending",t.then((n=>{t.status="fulfilled",t.value=n}),(n=>{t.status="rejected",t.reason=n})),t}var Vy=Promise.resolve(),Qr=class{#e;signal;#t;#n;#r;constructor(e,t){this.#e=new Tt(Ns),this.#t=e,this.#n=null,this.#r=t?.autoRetry??!0,this.signal=this.#e.asReadonly(),$c(this)}get(){return this.#e.get()}#o(e){const t=this.#e.get();t.data!==void 0&&this.#e.set(on({...t.data,...e}))}async#i(){const e=this.#e.get();if(e.data?.cursor&&!e.data.isFetchingMore){this.#o({isFetchingMore:!0});try{const t=await this.#t(e.data.cursor);this.#n=null,this.#o({cursor:t,hasFetchedAll:t===null,fetchMoreError:void 0,isFetchingMore:!1})}catch(t){this.#n=null,this.#o({isFetchingMore:!1,fetchMoreError:t})}}}fetchMore(){return this.#e.get().data?.cursor?(this.#n||(this.#n=this.#i()),this.#n):Vy}#s=null;waitUntilLoaded(){if(this.#s)return this.#s;const e=bm(this.#r?po((()=>this.#t(void 0)),5,[5e3,5e3,1e4,15e3]):Promise.resolve().then((()=>this.#t(void 0))));return e.then((t=>{this.#e.set(on({cursor:t,hasFetchedAll:t===null,isFetchingMore:!1,fetchMoreError:void 0,fetchMore:this.fetchMore}))}),(t=>{this.#e.set(vm(t)),this.#r&&setTimeout((()=>{this.#s=null,this.#e.set(Ns)}),5e3)})),this.#s=e,this.#s}},Er=class{#e;signal;#t;#n=!0;constructor(e,t=!0){this.#e=new Tt(Ns),this.signal=this.#e.asReadonly(),this.#t=e,this.#n=t,$c(this)}get(){return this.#e.get()}#r=null;waitUntilLoaded(){if(this.#r)return this.#r;const e=bm(this.#n?po((()=>this.#t()),5,[5e3,5e3,1e4,15e3]):this.#t());return e.then((()=>{this.#e.set(on(void 0))}),(t=>{this.#e.set(vm(t)),this.#n&&setTimeout((()=>{this.#r=null,this.#e.set(Ns)}),5e3)})),this.#r=e,e}};function $y(e,t){const n=new Ot(new Map);return{signal:$e.from(n,e,((r,o)=>(function(i,s,a){const u=Object.fromEntries(i);for(const c of a)if(c.type==="update-room-subscription-settings"){if(!c.settings.threads)continue;const f=s.findMany(c.roomId,void 0,"desc",void 0);for(const l of f){const d=Rr("thread",l.id);switch(c.settings.threads){case"all":u[d]={kind:"thread",subjectId:l.id,createdAt:new Date};break;case"none":delete u[d];break;case"replies_and_mentions":break;default:Ye(c.settings.threads,"Unexpected thread subscription settings.")}}}return u})(r,t,o))),applyDelta:function(r,o){n.mutate((i=>{let s=!1;for(const a of r)i.set(Rr(a),a),s=!0;for(const a of o)i.delete(Rr(a)),s=!0;return s}))},create:function(r){n.mutate((o=>{o.set(Rr(r),r)}))},delete:function(r){n.mutate((o=>{o.delete(r)}))}}}function Wy(e){const t=new Ot(new Map);return{signal:$e.from(t,e,((n,r)=>(function(o,i){const s=Object.fromEntries(o);for(const a of i)switch(a.type){case"update-room-subscription-settings":{const u=s[a.roomId];if(u===void 0)break;s[a.roomId]={...u,...a.settings}}}return s})(n,r))),update:function(n,r){t.mutate((o=>{o.set(n,r)}))}}}function zy(e){const t=new Tt(Ps({}));return{signal:$e.from(t,e,((n,r)=>(function(o,i){let s=o;for(const a of i)a.type==="update-notification-settings"&&(s=By(s,a.settings));return s})(n,r))),update:function(n){t.set(n)}}}var Ky=new Set(["mark-inbox-notification-as-read"]),qy=class{#e;threads;notifications;subscriptions;roomSubscriptionSettings;historyVersions;unreadNotificationsCount;urlsMetadata;permissionHints;notificationSettings;optimisticUpdates;outputs;#t=null;#n=new Map;#r=null;#o=new Map;#i;#s=(function(){const e=new Ot(new Map);return{signal:e,upsert:function(t,n){e.mutate((r=>{let o=r.get(t);o||(o=new Map,r.set(t,o));for(const i of n)o.set(i.feedId,i)}))},delete:function(t,n){e.mutate((r=>{r.get(t)?.delete(n)}))},findMany:function(t,n,r){const o=Array.from(t.get(n)?.values()??[]).filter((i=>{if(r?.since!==void 0&&i.updatedAt<r.since&&i.createdAt<r.since)return!1;if(r?.metadata!==void 0){const s=i.metadata;if(!Object.entries(r.metadata).every((([a,u])=>s[a]===u)))return!1}return!0}));return o.sort(((i,s)=>{const a=i.createdAt-s.createdAt;return a!==0?a:i.feedId<s.feedId?-1:i.feedId>s.feedId?1:0})),o}}})();#u=(function(){const e=new Ot(new Map);return{signal:e,upsert:function(t,n){e.mutate((r=>{let o=r.get(t);o||(o=new Map,r.set(t,o));for(const i of n)o.set(i.id,i)}))},delete:function(t,n){e.mutate((r=>{const o=r.get(t);if(o)for(const i of n)o.delete(i)}))},findMany:function(t,n){return Array.from(t.get(n)?.values()??[]).sort(((r,o)=>r.createdAt-o.createdAt))}}})();constructor(e){this.#e=e[Oe].as(),this.optimisticUpdates=(function(b){const C=new Tt([]),E=b[Oe].createSyncSource();return C.subscribe((()=>E.setSyncStatus(C.get().some((A=>!Ky.has(A.type)))?"synchronizing":"synchronized"))),{signal:C.asReadonly(),add:function(A){const x=st(),I={...A,id:x};return C.set((T=>[...T,I])),x},remove:function(A){C.set((x=>x.filter((I=>I.id!==A))))}}})(this.#e),this.permissionHints=(function(){const b=new He((()=>new Tt(void 0)));return{getPermissionForRoomΣ:function(C){return b.getOrCreate(C)},update:function(C,E,A){Xe((()=>{const x=A===void 0?Object.keys(C):new Set([...A,...Object.keys(C)]);for(const I of x){const T=b.getOrCreate(I),B=T.get();B!==void 0&&B.requestedAt>E||T.set({requestedAt:E,permissions:jc(C[I]??[])})}}))}}})(),this.notificationSettings=zy(this.optimisticUpdates.signal),this.#i=new Er((async()=>{const b=await this.#e.getNotificationSettings();this.notificationSettings.update(b)})),this.threads=new Hy,this.subscriptions=$y(this.optimisticUpdates.signal,this.threads),this.notifications=(function(){const b=new Ot(new Map);return{signal:b.asReadonly(),markAllRead:function(C){b.mutate((E=>{for(const A of E.values())A.readAt=C}))},markRead:function(C,E){b.mutate((A=>{const x=A.get(C);return!!x&&(A.set(C,{...x,readAt:E}),!0)}))},delete:function(C){b.mutate((E=>E.delete(C)))},applyDelta:function(C,E){b.mutate((A=>{let x=!1;for(const I of C){const T=A.get(I.id);T&&Gy(T,I)===1||(A.set(I.id,I),x=!0)}for(const I of E)A.delete(I.id),x=!0;return x}))},clear:function(){b.mutate((C=>C.clear()))},updateAssociatedNotification:function(C){b.mutate((E=>{const A=(function(x,I){for(const T of x)if(I(T))return T})(E.values(),(x=>x.kind==="thread"&&x.threadId===C.threadId));return!!A&&(E.set(A.id,{...A,notifiedAt:C.createdAt,readAt:C.createdAt}),!0)}))},upsert:function(C){b.mutate((E=>{E.set(C.id,C)}))}}})(),this.roomSubscriptionSettings=Wy(this.optimisticUpdates.signal),this.historyVersions=(function(){const b=new Ot(new He((()=>new Map)));return{signal:$e.from(b,(C=>Object.fromEntries([...C].map((([E,A])=>[E,Object.fromEntries(A)]))))),update:function(C,E){b.mutate((A=>{const x=A.getOrCreate(C);for(const I of E)x.set(I.id,I)}))}}})(),this.unreadNotificationsCount=(function(){const b=new Ot(new Map);return{signal:$e.from(b,(C=>Object.fromEntries(C))),update:function(C,E){b.mutate((A=>{A.set(C,E)}))}}})(),this.urlsMetadata=(function(){const b=new Ot(new Map);return{signal:$e.from(b,(C=>Object.fromEntries(C))),update:function(C,E){b.mutate((A=>{A.set(C,E)}))}}})();const t=$e.from(this.threads.signal,this.notifications.signal,this.optimisticUpdates.signal,((b,C,E)=>(function(A,x,I){const T=A.clone();let B=Object.fromEntries(x);for(const S of I)switch(S.type){case"create-thread":T.upsert(S.thread);break;case"edit-thread-metadata":{const k=T.get(S.threadId);if(k===void 0||k.updatedAt>S.updatedAt)break;T.upsert({...k,updatedAt:S.updatedAt,metadata:{...k.metadata,...S.metadata}});break}case"mark-thread-as-resolved":{const k=T.get(S.threadId);if(k===void 0)break;T.upsert({...k,resolved:!0});break}case"mark-thread-as-unresolved":{const k=T.get(S.threadId);if(k===void 0)break;T.upsert({...k,resolved:!1});break}case"create-comment":{const k=T.get(S.comment.threadId);if(k===void 0)break;T.upsert(ei(k,S.comment));const R=Object.values(B).find((M=>M.kind==="thread"&&M.threadId===k.id));if(R===void 0)break;B[R.id]={...R,notifiedAt:S.comment.createdAt,readAt:S.comment.createdAt};break}case"edit-comment":{const k=T.get(S.comment.threadId);if(k===void 0)break;T.upsert(ei(k,S.comment));break}case"edit-comment-metadata":{const k=T.get(S.threadId);if(k===void 0||k.updatedAt>S.updatedAt)break;const R=k.comments.find((M=>M.id===S.commentId));if(R===void 0)break;T.upsert(ei(k,{...R,metadata:{...R.metadata,...S.metadata}}));break}case"delete-comment":{const k=T.get(S.threadId);if(k===void 0)break;T.upsert(Ld(k,S.commentId,S.deletedAt));break}case"delete-thread":{const k=T.get(S.threadId);if(k===void 0)break;T.upsert({...k,deletedAt:S.deletedAt,updatedAt:S.deletedAt,comments:[]});break}case"add-reaction":{const k=T.get(S.threadId);if(k===void 0)break;T.upsert(Ud(k,S.commentId,S.reaction));break}case"remove-reaction":{const k=T.get(S.threadId);if(k===void 0)break;T.upsert(Hd(k,S.commentId,S.emoji,S.userId,S.removedAt));break}case"mark-inbox-notification-as-read":{const k=B[S.inboxNotificationId];if(k===void 0)break;B[S.inboxNotificationId]={...k,readAt:S.readAt};break}case"mark-all-inbox-notifications-as-read":for(const k in B){const R=B[k];if(R===void 0)break;B[k]={...R,readAt:S.readAt}}break;case"delete-inbox-notification":delete B[S.inboxNotificationId];break;case"delete-all-inbox-notifications":B={}}return{sortedNotifications:Object.values(B).filter((S=>S.kind!=="thread"||T.get(S.threadId)!==void 0)).sort(((S,k)=>k.notifiedAt.getTime()-S.notifiedAt.getTime())),notificationsById:B,threadsDB:T}})(b,C,E))),n=$e.from(t,(b=>b.threadsDB)),r=$e.from(t,(b=>({sortedNotifications:b.sortedNotifications,notificationsById:b.notificationsById})),lt),o=$e.from(r,this.subscriptions.signal,((b,C)=>({subscriptions:C,notifications:b.sortedNotifications}))),i=new He((b=>{const C=JSON.parse(b),E=new Qr((async A=>{const x=await this.#e[Oe].httpClient.getUserThreads_experimental({cursor:A,query:C});return this.updateThreadifications(x.threads,x.inboxNotifications,x.subscriptions),this.permissionHints.update(x.permissionHints,x.requestedAt),this.#r===null&&(this.#r=x.requestedAt),x.nextCursor}));return{signal:$e.from((()=>{const A=E.get();if(A.isLoading||A.error)return A;const x=o.get().subscriptions,I=this.outputs.threads.get().findMany(void 0,C??{},"desc",x),T=A.data;return{isLoading:!1,threads:I,hasFetchedAll:T.hasFetchedAll,isFetchingMore:T.isFetchingMore,fetchMoreError:T.fetchMoreError,fetchMore:T.fetchMore}}),uo),waitUntilLoaded:E.waitUntilLoaded}})),s=new He((b=>{const[C,E]=JSON.parse(b),A=new Qr((async x=>{const I=await this.#e[Oe].httpClient.getThreads({roomId:C,cursor:x,query:E});this.updateThreadifications(I.threads,I.inboxNotifications,I.subscriptions),this.permissionHints.update(I.permissionHints,I.requestedAt,[C]);const T=this.#n.get(C);return(T===void 0||T>I.requestedAt)&&this.#n.set(C,I.requestedAt),I.nextCursor}));return{signal:$e.from((()=>{const x=A.get();if(x.isLoading||x.error)return x;const I=o.get().subscriptions,T=this.outputs.threads.get().findMany(C,E??{},"asc",I),B=x.data;return{isLoading:!1,threads:T,hasFetchedAll:B.hasFetchedAll,isFetchingMore:B.isFetchingMore,fetchMoreError:B.fetchMoreError,fetchMore:B.fetchMore}}),uo),waitUntilLoaded:A.waitUntilLoaded}})),a=new He((b=>{const C=JSON.parse(b),E=new Qr((async x=>{const I=await this.#e.getInboxNotifications({cursor:x,query:C});return this.updateThreadifications(I.threads,I.inboxNotifications,I.subscriptions),this.#t===null&&(this.#t=I.requestedAt),I.nextCursor}));return{signal:$e.from((()=>{const x=E.get();if(x.isLoading||x.error)return x;const I=[];C!==void 0&&I.push((function(S){return k=>(function(R,M){return!(M.roomId!==void 0&&M.roomId!==R.roomId||M.kind!==void 0&&M.kind!==R.kind)})(k,S)})(C));const T=this.outputs.notifications.get().sortedNotifications.filter((S=>I.every((k=>k(S))))),B=x.data;return{isLoading:!1,inboxNotifications:T,hasFetchedAll:B.hasFetchedAll,isFetchingMore:B.isFetchingMore,fetchMoreError:B.fetchMoreError,fetchMore:B.fetchMore}}),uo),waitUntilLoaded:E.waitUntilLoaded}})),u=new He((b=>{const C=JSON.parse(b),E=new Er((async()=>{const A=await this.#e.getUnreadInboxNotificationsCount({query:C});this.unreadNotificationsCount.update(b,A)}));return{signal:$e.from((()=>{const A=E.get();return A.isLoading||A.error?A:on("count",ye(this.unreadNotificationsCount.signal.get()[b]))}),lt),waitUntilLoaded:E.waitUntilLoaded}})),c=new He((b=>{const C=new Er((async()=>{const E=this.#e.getRoom(b);if(E===null)throw new Error(`Room '${b}' is not available on client`);const A=await E.getSubscriptionSettings();this.roomSubscriptionSettings.update(b,A)}));return{signal:$e.from((()=>{const E=C.get();return E.isLoading||E.error?E:on("settings",ye(this.roomSubscriptionSettings.signal.get()[b]))}),lt),waitUntilLoaded:C.waitUntilLoaded}})),f=new He((b=>{const C=new Er((async()=>{const E=this.#e.getRoom(b);if(E===null)throw new Error(`Room '${b}' is not available on client`);const A=await E[Oe].listHistoryVersions();this.historyVersions.update(b,A.versions);const x=this.#o.get(b);(x===void 0||x>A.requestedAt)&&this.#o.set(b,A.requestedAt)}));return{signal:$e.from((()=>{const E=C.get();return E.isLoading||E.error?E:on("versions",Object.values(this.historyVersions.signal.get()[b]??{}))}),lt),waitUntilLoaded:C.waitUntilLoaded}})),l={signal:$e.from((()=>{const b=this.#i.get();return b.isLoading||b.error?b:on("settings",ye(this.notificationSettings.signal.get()))}),lt),waitUntilLoaded:this.#i.waitUntilLoaded},d=new He((b=>{const C=JSON.parse(b),E=new Qr((async A=>(await this.#e[Oe].ai.getChats({cursor:A,query:C})).nextCursor));return{signal:$e.from((()=>{const A=E.get();return A.isLoading||A.error?A:{isLoading:!1,chats:this.#e[Oe].ai.queryChats(C),hasFetchedAll:A.data.hasFetchedAll,isFetchingMore:A.data.isFetchingMore,fetchMore:A.data.fetchMore,fetchMoreError:A.data.fetchMoreError}}),lt),waitUntilLoaded:E.waitUntilLoaded}})),h=new He((b=>{const C=new Er((async()=>{await this.#e[Oe].ai.getMessageTree(b)}));return new He((E=>({signal:$e.from((()=>{const A=C.get();return A.isLoading||A.error?A:on("messages",this.#e[Oe].ai.signals.getChatMessagesForBranchΣ(b,E??void 0).get())})),waitUntilLoaded:C.waitUntilLoaded})))})),g=new He((b=>{const C=new Er((async()=>{await this.#e[Oe].ai.getOrCreateChat(b)}));return{signal:$e.from((()=>{if(this.#e[Oe].ai.getChatById(b)===void 0){const E=C.get();return E.isLoading||E.error?E:on("chat",ye(this.#e[Oe].ai.getChatById(b)))}return on("chat",ye(this.#e[Oe].ai.getChatById(b)))}),lt),waitUntilLoaded:C.waitUntilLoaded}})),y=new He((b=>{const C=new Er((async()=>{const E=await this.#e[Oe].httpClient.getUrlMetadata(b);this.urlsMetadata.update(b,E)}),!1);return{signal:$e.from((()=>{const E=C.get();return E.isLoading||E.error?E:on("metadata",ye(this.urlsMetadata.signal.get()[b]))}),lt),waitUntilLoaded:C.waitUntilLoaded}})),p=new He((b=>{const[C,E]=JSON.parse(b),A=new Qr((async x=>{const I=this.#e.getRoom(C);if(I===null)throw new Error(`Room '${C}' is not available on client. Make sure you're calling useFeeds inside a RoomProvider.`);const T=await I.fetchFeeds({cursor:x,since:E?.since,metadata:E?.metadata,limit:E?.limit});return this.upsertFeeds(C,T.feeds),T.nextCursor??null}),{autoRetry:!1});return{signal:$e.from(A.signal,this.#s.signal,((x,I)=>{if(x.isLoading||x.error)return x;const T=this.#s.findMany(I,C,E),B=x.data;return{isLoading:!1,feeds:T,hasFetchedAll:B.hasFetchedAll,isFetchingMore:B.isFetchingMore,fetchMoreError:B.fetchMoreError,fetchMore:B.fetchMore}}),uo),waitUntilLoaded:A.waitUntilLoaded}})),w=new He((b=>{const[C,E,A]=JSON.parse(b),x=new Qr((async I=>{const T=this.#e.getRoom(C);if(T===null)throw new Error(`Room '${C}' is not available on client. Make sure you're calling useFeedMessages inside a RoomProvider.`);const B=await T.fetchFeedMessages(E,{cursor:I,limit:A?.limit});return this.upsertFeedMessages(C,E,B.messages),B.nextCursor??null}),{autoRetry:!1});return{signal:$e.from(x.signal,this.#u.signal,((I,T)=>{if(I.isLoading||I.error)return I;const B=this.#u.findMany(T,E),S=I.data;return{isLoading:!1,messages:B,hasFetchedAll:S.hasFetchedAll,isFetchingMore:S.isFetchingMore,fetchMoreError:S.fetchMoreError,fetchMore:S.fetchMore}}),uo),waitUntilLoaded:x.waitUntilLoaded}}));this.outputs={threadifications:t,threads:n,loadingRoomThreads:s,loadingUserThreads:i,notifications:r,loadingNotifications:a,unreadNotificationsCount:u,roomSubscriptionSettingsByRoomId:c,versionsByRoomId:f,notificationSettings:l,threadSubscriptions:o,aiChats:d,messagesByChatId:h,aiChatById:g,urlMetadataByUrl:y,loadingFeeds:p,loadingFeedMessages:w},$c(this)}markInboxNotificationRead(e,t,n){Xe((()=>{this.optimisticUpdates.remove(n),this.notifications.markRead(e,t)}))}markAllInboxNotificationsRead(e,t){Xe((()=>{this.optimisticUpdates.remove(e),this.notifications.markAllRead(t)}))}deleteInboxNotification(e,t){Xe((()=>{this.optimisticUpdates.remove(t),this.notifications.delete(e)}))}deleteAllInboxNotifications(e){Xe((()=>{this.optimisticUpdates.remove(e),this.notifications.clear()}))}createSubscription(e,t){Xe((()=>{this.optimisticUpdates.remove(t),this.subscriptions.create(e)}))}deleteSubscription(e,t){Xe((()=>{this.optimisticUpdates.remove(t),this.subscriptions.delete(e)}))}createThread(e,t){Xe((()=>{this.optimisticUpdates.remove(e),this.threads.upsert(t)}))}#a(e,t,n,r){Xe((()=>{t!==null&&this.optimisticUpdates.remove(t);const o=this.threads,i=o.get(e);i&&(r&&i.updatedAt>r||o.upsert(n(i)))}))}patchThread(e,t,n,r){return this.#a(e,t,(o=>({...o,...wi(n)})),r)}addReaction(e,t,n,r,o){this.#a(e,t,(i=>Ud(i,n,r)),o)}removeReaction(e,t,n,r,o,i){this.#a(e,t,(s=>Hd(s,n,r,o,i)),i)}deleteThread(e,t){return this.#a(e,t,(n=>({...n,updatedAt:new Date,deletedAt:new Date})))}createComment(e,t){Xe((()=>{this.optimisticUpdates.remove(t);const n=this.threads.get(e.threadId);n&&(this.threads.upsert(ei(n,e)),this.notifications.updateAssociatedNotification(e))}))}editComment(e,t,n){return this.#a(e,t,(r=>ei(r,n)))}editCommentMetadata(e,t,n,r,o){return this.#a(e,n,(i=>i.comments.find((s=>s.id===t))===void 0?i:{...i,updatedAt:o,comments:i.comments.map((s=>s.id===t?{...s,metadata:r}:s))}),o)}deleteComment(e,t,n,r){return this.#a(e,t,(o=>Ld(o,n,r)),r)}updateThreadifications(e,t,n,r=[],o=[],i=[]){Xe((()=>{this.threads.applyDelta(e,r),this.notifications.applyDelta(t,o),this.subscriptions.applyDelta(n,i)}))}updateRoomSubscriptionSettings(e,t,n){Xe((()=>{this.optimisticUpdates.remove(t),this.roomSubscriptionSettings.update(e,n)}))}async fetchNotificationsDeltaUpdate(e){const t=this.#t;if(t===null)return;const n=await this.#e.getInboxNotificationsSince({since:t,signal:e});t<n.requestedAt&&(this.#t=n.requestedAt),this.updateThreadifications(n.threads.updated,n.inboxNotifications.updated,n.subscriptions.updated,n.threads.deleted,n.inboxNotifications.deleted,n.subscriptions.deleted)}upsertFeeds(e,t){this.#s.upsert(e,t)}deleteFeed(e,t){this.#s.delete(e,t)}upsertFeedMessages(e,t,n){this.#u.upsert(t,n)}deleteFeedMessages(e,t,n){this.#u.delete(t,n)}async fetchUnreadNotificationsCount(e,t){const n=JSON.parse(e),r=await this.#e.getUnreadInboxNotificationsCount({query:n,signal:t});this.unreadNotificationsCount.update(e,r)}async fetchRoomThreadsDeltaUpdate(e,t){const n=this.#n.get(e);if(n===void 0)return;const r=await this.#e[Oe].httpClient.getThreadsSince({roomId:e,since:n,signal:t});this.updateThreadifications(r.threads.updated,r.inboxNotifications.updated,r.subscriptions.updated,r.threads.deleted,r.inboxNotifications.deleted,r.subscriptions.deleted),this.permissionHints.update(r.permissionHints,r.requestedAt),n<r.requestedAt&&this.#n.set(e,r.requestedAt)}async fetchUserThreadsDeltaUpdate(e){const t=this.#r;if(t===null)return;const n=await this.#e[Oe].httpClient.getUserThreadsSince_experimental({since:t,signal:e});t<n.requestedAt&&(this.#t=n.requestedAt),this.updateThreadifications(n.threads.updated,n.inboxNotifications.updated,n.subscriptions.updated,n.threads.deleted,n.inboxNotifications.deleted,n.subscriptions.deleted),this.permissionHints.update(n.permissionHints,n.requestedAt)}async fetchRoomVersionsDeltaUpdate(e,t){const n=this.#o.get(e);if(n===void 0)return;const r=ye(this.#e.getRoom(e),`Room with id ${e} is not available on client`),o=await r[Oe].listHistoryVersionsSince({since:n,signal:t});this.historyVersions.update(e,o.versions),n<o.requestedAt&&this.#o.set(e,o.requestedAt)}async refreshRoomSubscriptionSettings(e,t){const n=ye(this.#e.getRoom(e),`Room with id ${e} is not available on client`),r=await n.getSubscriptionSettings({signal:t});this.roomSubscriptionSettings.update(e,r)}async refreshNotificationSettings(e){const t=await this.#e.getNotificationSettings({signal:e});this.notificationSettings.update(t)}updateNotificationSettings_confirmOptimisticUpdate(e,t){Xe((()=>{this.optimisticUpdates.remove(t),this.notificationSettings.update(e)}))}};function Gy(e,t){return e.notifiedAt>t.notifiedAt?1:e.notifiedAt<t.notifiedAt?-1:e.readAt&&t.readAt?e.readAt>t.readAt?1:e.readAt<t.readAt?-1:0:e.readAt||t.readAt?e.readAt?1:-1:0}function ei(e,t){if(e.deletedAt!==void 0)return e;if(t.threadId!==e.id)return Xt.warn(`Comment ${t.id} does not belong to thread ${e.id}`),e;const n=e.comments.find((r=>r.id===t.id));if(n===void 0){const r=new Date(Math.max(e.updatedAt.getTime(),t.createdAt.getTime()));return{...e,updatedAt:r,comments:[...e.comments,t]}}if(n.deletedAt!==void 0){const r={...n,metadata:{...n.metadata,...t.metadata}},o=e.comments.map((i=>i.id===t.id?r:i));return{...e,comments:o}}if(n.editedAt===void 0||t.editedAt===void 0||n.editedAt<=t.editedAt){const r=e.comments.map((o=>o.id===t.id?t:o));return{...e,updatedAt:new Date(Math.max(e.updatedAt.getTime(),t.editedAt?.getTime()||t.createdAt.getTime())),comments:r}}return e}function Ld(e,t,n){if(e.deletedAt!==void 0)return e;const r=e.comments.find((i=>i.id===t));if(r===void 0||r.deletedAt!==void 0)return e;const o=e.comments.map((i=>i.id===t?{...i,deletedAt:n,body:void 0,attachments:[]}:i));return o.every((i=>i.deletedAt!==void 0))?{...e,deletedAt:n,updatedAt:n}:{...e,updatedAt:n,comments:o}}function Ud(e,t,n){if(e.deletedAt!==void 0)return e;const r=e.comments.find((i=>i.id===t));if(r===void 0||r.deletedAt!==void 0)return e;const o=e.comments.map((i=>i.id===t?{...i,reactions:Jy(i.reactions,n)}:i));return{...e,updatedAt:new Date(Math.max(n.createdAt.getTime(),e.updatedAt.getTime())),comments:o}}function Hd(e,t,n,r,o){if(e.deletedAt!==void 0)return e;const i=e.comments.find((a=>a.id===t));if(i===void 0||i.deletedAt!==void 0)return e;const s=e.comments.map((a=>a.id===t?{...a,reactions:a.reactions.map((u=>u.emoji===n?{...u,users:u.users.filter((c=>c.id!==r))}:u)).filter((u=>u.users.length>0))}:a));return{...e,updatedAt:new Date(Math.max(o.getTime(),e.updatedAt.getTime())),comments:s}}function Jy(e,t){const n=e.find((r=>r.emoji===t.emoji));return n===void 0?[...e,{emoji:t.emoji,createdAt:t.createdAt,users:[{id:t.userId}]}]:n.users.some((r=>r.id===t.userId))===!1?e.map((r=>r.emoji===t.emoji?{...r,users:[...r.users,{id:t.userId}]}:r)):e}function Zy(e){return new Error(`resolveUsers didn't return anything for user '${e}'`)}function Xy(e){return new Error(`resolveGroupsInfo didn't return anything for group '${e}'`)}function Yy(e){return e}var Vd=new WeakMap,$d=new WeakMap;function Cm(e){let t=Vd.get(e);return t||(t=new qy(e),Vd.set(e,t)),t}function Wc(e){let t=$d.get(e);return t||(t=(function(n){const r=Cm(n),o=Fr((async u=>{try{return await r.fetchNotificationsDeltaUpdate(u)}catch(c){throw Xt.warn(`Polling new inbox notifications failed: ${String(c)}`),c}}),Ft.NOTIFICATIONS_POLL_INTERVAL,{maxStaleTimeMs:Ft.NOTIFICATIONS_MAX_STALE_TIME}),i=new He((u=>Fr((async c=>{try{return await r.fetchUnreadNotificationsCount(u,c)}catch(f){throw Xt.warn(`Polling unread inbox notifications countfailed: ${String(f)}`),f}}),Ft.NOTIFICATIONS_POLL_INTERVAL,{maxStaleTimeMs:Ft.NOTIFICATIONS_MAX_STALE_TIME}))),s=Fr((async u=>{try{return await r.fetchUserThreadsDeltaUpdate(u)}catch(c){throw Xt.warn(`Polling new user threads failed: ${String(c)}`),c}}),Ft.USER_THREADS_POLL_INTERVAL,{maxStaleTimeMs:Ft.USER_THREADS_MAX_STALE_TIME}),a=Fr((async u=>{try{return await r.refreshNotificationSettings(u)}catch(c){throw Xt.warn(`Polling new notification settings failed: ${String(c)}`),c}}),Ft.USER_NOTIFICATION_SETTINGS_INTERVAL,{maxStaleTimeMs:Ft.USER_NOTIFICATION_SETTINGS_MAX_STALE_TIME});return{store:r,notificationsPoller:o,userThreadsPoller:s,notificationSettingsPoller:a,unreadNotificationsCountPollersByQueryKey:i}})(e),$d.set(e,t)),t}function Qy(e,t,n,r){const{store:o,notificationsPoller:i}=Wc(e),s=Yt({});return m.useEffect((()=>{o.outputs.loadingNotifications.getOrCreate(s).waitUntilLoaded()})),m.useEffect((()=>(i.inc(),i.pollNowIfStale(),()=>{i.dec()})),[i]),Vo(o.outputs.loadingNotifications.getOrCreate(s).signal,t,n)}function eb(e,t){const n=e[Oe].usersStore,r=m.useCallback((()=>n.getItemState(t)),[n,t]),o=m.useCallback((s=>(function(a,u){return a===void 0||a?.isLoading?a??{isLoading:!0}:a.error?a:a.data?{isLoading:!1,user:a.data}:{isLoading:!1,error:Zy(u)}})(s,t)),[t]),i=Pi(n.subscribe,r,r,o,lt);return m.useEffect((()=>{n.enqueue(t)})),i}function tb(e,t){const n=e[Oe].groupsInfoStore,r=m.useCallback((()=>n.getItemState(t)),[n,t]),o=m.useCallback((s=>(function(a,u){return a===void 0||a?.isLoading?a??{isLoading:!0}:a.error?a:a.data?{isLoading:!1,info:a.data}:{isLoading:!1,error:Xy(u)}})(s,t)),[t]),i=Pi(n.subscribe,r,r,o,lt);return m.useEffect((()=>{n.enqueue(t)})),i}function nb(e){return(function(t){const n=Vc();if(!t?.allowNesting&&n!==null)throw new Error("You cannot nest multiple LiveblocksProvider instances in the same React tree.")})(e),v.jsx(gm.Provider,{value:e.client,children:e.children})}function f5(e){const{children:t,...n}=e,r={publicApiKey:rn(n.publicApiKey),throttle:rn(n.throttle),lostConnectionTimeout:rn(n.lostConnectionTimeout),backgroundKeepAliveTimeout:rn(n.backgroundKeepAliveTimeout),polyfills:rn(n.polyfills),preventUnsavedChanges:rn(n.preventUnsavedChanges),badgeLocation:rn(n.badgeLocation),authEndpoint:Qo(n.authEndpoint),resolveMentionSuggestions:Qo(n.resolveMentionSuggestions),resolveUsers:Qo(n.resolveUsers),resolveRoomsInfo:Qo(n.resolveRoomsInfo),resolveGroupsInfo:Qo(n.resolveGroupsInfo),baseUrl:rn(n.baseUrl),enableDebugLogging:rn(n.enableDebugLogging)},o=m.useMemo((()=>Ny(r)),[]);return m.useEffect((()=>()=>{o[Oe].ai.disconnect()}),[o]),v.jsx(nb,{client:o,children:t})}function h5(e){return Qy(Ve(),Yy,lt)}function p5(){return e=Ve(),m.useCallback((t=>{const{store:n,unreadNotificationsCountPollersByQueryKey:r}=Wc(e),o=new Date,i=n.optimisticUpdates.add({type:"mark-inbox-notification-as-read",inboxNotificationId:t,readAt:o});e.markInboxNotificationAsRead(t).then((()=>{n.markInboxNotificationRead(t,o,i);for(const s of r.values())s.markAsStale(),s.pollNowIfStale()}),(s=>{n.optimisticUpdates.remove(i),e[Oe].emitError({type:"MARK_INBOX_NOTIFICATION_AS_READ_ERROR",inboxNotificationId:t},s)}))}),[e]);var e}function zc(e){return tb(Ve(),e)}var wm=function(e){return eb(Ve(),e)},m5=function(e={}){const t=Ve(),{store:n,userThreadsPoller:r}=Wc(t),o=Yt(e.query??{});return m.useEffect((()=>{n.outputs.loadingUserThreads.getOrCreate(o).waitUntilLoaded()})),m.useEffect((()=>(r.inc(),r.pollNowIfStale(),()=>{r.dec()})),[r]),Vo(n.outputs.loadingUserThreads.getOrCreate(o).signal)};function rb(e,t){m.useEffect((()=>{(function(n,r){if(n===!1||!r.threads||typeof window>"u")return;const o=window.location.hash.slice(1);if(!o.startsWith("cm_"))return;const i=document.getElementById(o);i!==null&&r.threads.flatMap((s=>s.comments)).some((s=>s.id===o))&&i.scrollIntoView()})(e,t)}),[t.isLoading])}function oa(e){const t=e[Oe].currentUserId.get();return t===void 0?"anonymous":t}var Wd=new WeakMap;function Et(e){let t=Wd.get(e);return t||(t=(function(n){const r=Cm(n);function o(u,c,f){if(r.optimisticUpdates.remove(u),!(f instanceof Uo))throw f;if(f.status===403){const l=[f.message,f.details?.suggestion,f.details?.docs].filter(Boolean).join(`
8
+ `);Xt.error(l)}n[Oe].emitError(c,f)}const i=new He((u=>Fr((async c=>{try{return await r.fetchRoomThreadsDeltaUpdate(u,c)}catch(f){throw Xt.warn(`Polling new threads for '${u}' failed: ${String(f)}`),f}}),Ft.ROOM_THREADS_POLL_INTERVAL,{maxStaleTimeMs:Ft.ROOM_THREADS_MAX_STALE_TIME}))),s=new He((u=>Fr((async c=>{try{return await r.fetchRoomVersionsDeltaUpdate(u,c)}catch(f){throw Xt.warn(`Polling new history versions for '${u}' failed: ${String(f)}`),f}}),Ft.HISTORY_VERSIONS_POLL_INTERVAL,{maxStaleTimeMs:Ft.HISTORY_VERSIONS_MAX_STALE_TIME}))),a=new He((u=>Fr((async c=>{try{return await r.refreshRoomSubscriptionSettings(u,c)}catch(f){throw Xt.warn(`Polling subscription settings for '${u}' failed: ${String(f)}`),f}}),Ft.ROOM_SUBSCRIPTION_SETTINGS_POLL_INTERVAL,{maxStaleTimeMs:Ft.ROOM_SUBSCRIPTION_SETTINGS_MAX_STALE_TIME})));return{store:r,onMutationFailure:o,pollThreadsForRoomId:u=>{const c=i.getOrCreate(u);c&&(c.markAsStale(),c.pollNowIfStale())},getOrCreateThreadsPollerForRoomId:i.getOrCreate.bind(i),getOrCreateVersionsPollerForRoomId:s.getOrCreate.bind(s),getOrCreateSubscriptionSettingsPollerForRoomId:a.getOrCreate.bind(a)}})(e),Wd.set(e,t)),t}function So(e,t){return e.outputs.threads.get().getEvenIfDeleted(t)?.visibility}function ob(e){const t=Ve(),{id:n,stableEnterRoom:r,BoundRoomContext:o}=e,i=rn({initialPresence:e.initialPresence,initialStorage:e.initialStorage,autoConnect:e.autoConnect??typeof window<"u"},n),[{room:s},a]=m.useState((()=>r(n,{...i,autoConnect:!1})));return m.useEffect((()=>{const{store:u}=Et(t);return s.events.comments.subscribe((c=>{(async function(f){if(f.type===xe.THREAD_DELETED)return void u.deleteThread(f.threadId,null);const l=await s.getThread(f.threadId);if(!l.thread)return void u.deleteThread(f.threadId,null);const{thread:d,inboxNotification:h,subscription:g}=l,y=u.outputs.threads.get().getEvenIfDeleted(f.threadId);switch(f.type){case xe.COMMENT_EDITED:case xe.THREAD_METADATA_UPDATED:case xe.THREAD_UPDATED:case xe.COMMENT_REACTION_ADDED:case xe.COMMENT_REACTION_REMOVED:case xe.COMMENT_DELETED:case xe.COMMENT_METADATA_UPDATED:if(!y)break;u.updateThreadifications([d],h?[h]:[],g?[g]:[]);break;case xe.COMMENT_CREATED:u.updateThreadifications([d],h?[h]:[],g?[g]:[])}})(c)}))}),[t,s]),m.useEffect((()=>{const{store:u}=Et(t);return s.events.feeds.subscribe((c=>{(function(f){switch(f.type){case xe.FEEDS_ADDED:case xe.FEEDS_UPDATED:u.upsertFeeds(s.id,f.feeds);break;case xe.FEED_DELETED:u.deleteFeed(s.id,f.feedId);break;case xe.FEED_MESSAGES_ADDED:case xe.FEED_MESSAGES_UPDATED:u.upsertFeedMessages(s.id,f.feedId,f.messages);break;case xe.FEED_MESSAGES_DELETED:u.deleteFeedMessages(s.id,f.feedId,f.messageIds)}})(c)}))}),[t,s]),m.useEffect((()=>{const u=r(n,i);a(u);const{room:c,leave:f}=u;return i.autoConnect&&c.connect(),()=>{f()}}),[n,i,r]),v.jsx(Gr.Provider,{value:s,children:o?v.jsx(o.Provider,{value:s,children:e.children}):e.children})}function Ni(e,t){const n=(function(r=Gr){return m.useContext(r)})(e);if(n===null&&!t?.allowOutsideRoom)throw new Error("RoomProvider is missing from the React tree.");return n}function Kc(){return Ve()[Oe].resolveMentionSuggestions}function ib(e,t={}){const{scrollOnLoad:n=!0}=t,r=Ve(),o=Ni(e),{store:i,getOrCreateThreadsPollerForRoomId:s}=Et(r),a=(u=o.id,c=t.query,Yt([u,c??{}]));var u,c;const f=s(o.id);m.useEffect((()=>{i.outputs.loadingRoomThreads.getOrCreate(a).waitUntilLoaded()})),m.useEffect((()=>(f.inc(),f.pollNowIfStale(),()=>f.dec())),[f]);const l=Vo(i.outputs.loadingRoomThreads.getOrCreate(a).signal);return rb(n,l),l}function Em(e){const t=Ve();return m.useCallback((n=>{const r=n.body,o=n.metadata??{},i=n.commentMetadata??{},s=n.attachments,a=n.visibility??"public",u=zp(),c=js(),f=new Date,l={id:c,threadId:u,roomId:e,createdAt:f,type:"comment",userId:oa(t),body:r,reactions:[],attachments:s??[],metadata:i},d={id:u,type:"thread",createdAt:f,updatedAt:f,roomId:e,metadata:o,comments:[l],resolved:!1,visibility:a},{store:h,onMutationFailure:g}=Et(t),y=h.optimisticUpdates.add({type:"create-thread",thread:d,roomId:e}),p=s?.map((w=>w.id));return t[Oe].httpClient.createThread({roomId:e,threadId:u,commentId:c,body:r,visibility:a,metadata:o,commentMetadata:i,attachmentIds:p}).then((w=>{h.createThread(y,w)}),(w=>g(y,{type:"CREATE_THREAD_ERROR",roomId:e,threadId:u,commentId:c,body:r,visibility:a,metadata:o,commentMetadata:i},w))),d}),[t,e])}function Dm(e){const t=Ve();return m.useCallback((n=>{const{threadId:r,body:o}=n,i=n.metadata??{},s=n.attachments??[],a=js(),u={id:a,threadId:r,roomId:e,type:"comment",createdAt:new Date,userId:oa(t),body:o,reactions:[],attachments:s??[],metadata:i},{store:c,onMutationFailure:f}=Et(t),l=c.optimisticUpdates.add({type:"create-comment",comment:u}),d=s?.map((h=>h.id));return t[Oe].httpClient.createComment({roomId:e,threadId:r,commentId:a,body:o,metadata:i,attachmentIds:d,visibility:So(c,r)}).then((h=>{c.createComment(h,l)}),(h=>f(l,{type:"CREATE_COMMENT_ERROR",roomId:e,threadId:r,commentId:a,body:o,metadata:i},h))),u}),[t,e])}function Am(e){const t=Ve();return m.useCallback((({threadId:n,commentId:r,body:o,attachments:i,metadata:s})=>{const a=new Date,{store:u,onMutationFailure:c}=Et(t),f=u.outputs.threads.get().getEvenIfDeleted(n);if(f===void 0)return void Xt.warn(`Internal unexpected behavior. Cannot edit comment in thread "${n}" because the thread does not exist in the cache.`);const l=f.comments.find((y=>y.id===r));if(l===void 0||l.deletedAt!==void 0)return void Xt.warn(`Internal unexpected behavior. Cannot edit comment "${r}" in thread "${n}" because the comment does not exist in the cache.`);const d=s!==void 0?{...l.metadata,...s}:l.metadata,h=u.optimisticUpdates.add({type:"edit-comment",comment:{...l,editedAt:a,body:o,attachments:i??[],metadata:d}}),g=i?.map((y=>y.id));t[Oe].httpClient.editComment({roomId:e,threadId:n,commentId:r,body:o,attachmentIds:g,metadata:s,visibility:f.visibility}).then((y=>{u.editComment(n,h,y)}),(y=>c(h,{type:"EDIT_COMMENT_ERROR",roomId:e,threadId:n,commentId:r,body:o,metadata:d},y)))}),[t,e])}function xm(e){const t=Ve();return m.useCallback((({threadId:n,commentId:r,emoji:o})=>{const i=new Date,s=oa(t),{store:a,onMutationFailure:u}=Et(t),c=a.optimisticUpdates.add({type:"add-reaction",threadId:n,commentId:r,reaction:{emoji:o,userId:s,createdAt:i}});t[Oe].httpClient.addReaction({roomId:e,threadId:n,commentId:r,emoji:o,visibility:So(a,n)}).then((f=>{a.addReaction(n,c,r,f,i)}),(f=>u(c,{type:"ADD_REACTION_ERROR",roomId:e,threadId:n,commentId:r,emoji:o},f)))}),[t,e])}function Om(e){const t=Ve();return m.useCallback((({threadId:n,commentId:r,emoji:o})=>{const i=oa(t),s=new Date,{store:a,onMutationFailure:u}=Et(t),c=a.optimisticUpdates.add({type:"remove-reaction",threadId:n,commentId:r,emoji:o,userId:i,removedAt:s});t[Oe].httpClient.removeReaction({roomId:e,threadId:n,commentId:r,emoji:o,visibility:So(a,n)}).then((()=>{a.removeReaction(n,c,r,o,i,s)}),(f=>u(c,{type:"REMOVE_REACTION_ERROR",roomId:e,threadId:n,commentId:r,emoji:o},f)))}),[t,e])}function sb(e,t){const n=Ve(),{store:r}=Et(n),o=m.useMemo((()=>Rr("thread",t)),[t]),i=(function(c){const f=Ve();return m.useCallback((l=>{const d=new Date,{store:h,onMutationFailure:g}=Et(f),y=h.optimisticUpdates.add({type:"subscribe-to-thread",threadId:l,subscribedAt:d});f[Oe].httpClient.subscribeToThread({roomId:c,threadId:l}).then((p=>{h.createSubscription(p,y)}),(p=>g(y,{type:"SUBSCRIBE_TO_THREAD_ERROR",roomId:c,threadId:l},p)))}),[f,c])})(e),s=(function(c){const f=Ve();return m.useCallback((l=>{const d=new Date,{store:h,onMutationFailure:g}=Et(f),y=h.optimisticUpdates.add({type:"unsubscribe-from-thread",threadId:l,unsubscribedAt:d});f[Oe].httpClient.unsubscribeFromThread({roomId:c,threadId:l}).then((()=>{h.deleteSubscription(Rr("thread",l),y)}),(p=>g(y,{type:"UNSUBSCRIBE_FROM_THREAD_ERROR",roomId:c,threadId:l},p)))}),[f,c])})(e),a=m.useCallback((()=>i(t)),[i,t]),u=m.useCallback((()=>s(t)),[s,t]);return Vo(r.outputs.threadSubscriptions,m.useCallback((c=>{const f=c.subscriptions[o],l=c.notifications.find((d=>d.kind==="thread"&&d.threadId===t));return f===void 0?{status:"not-subscribed",subscribe:a,unsubscribe:u}:{status:"subscribed",unreadSince:l?.readAt??null,subscribe:a,unsubscribe:u}}),[o,t,a,u]),lt)}function ab(e){return e===void 0||e?.isLoading?e??{isLoading:!0}:e.error?e:(e.data,{isLoading:!1,url:e.data})}function ia(e,t){const n=Ve()[Oe].httpClient.getOrCreateAttachmentUrlsStore(t),r=m.useCallback((()=>n.getItemState(e)),[n,e]);return m.useEffect((()=>{n.enqueue(e)}),[n,e]),Pi(n.subscribe,r,r,ab,lt)}function qc(e,t,n){const r=(function(i){const s=Et(Ve()).store;return Vo(s.permissionHints.getPermissionForRoomΣ(i))?.permissions})(e),o=(function(i,s,a){const u=Ni(Gr,{allowOutsideRoom:!0}),c=m.useCallback((l=>u===null||u.id!==i?()=>{}:u.events.self.subscribe(l)),[u,i]),f=m.useCallback((()=>{const l=s==="comments"||s==="comments:public"||s==="comments:private";if(u?.id===i){const d=u[Oe].getPermissionMatrix();if(d!==void 0)return fr(d,s,a)}return!(!l&&s!=="storage")}),[s,a,u,i]);return m.useSyncExternalStore(c,f,f)})(e,t,n);return r!==void 0?fr(r,t,n):o}var g5=function(e){const t=Ve(),[n]=m.useState((()=>new Map)),r=m.useCallback(((o,i)=>{const s=n.get(o);if(s)return s;const a=t.enterRoom(o,i),u=a.leave;return a.leave=()=>{u(),n.delete(o)},n.set(o,a),a}),[t,n]);return v.jsx(ob,{...e,stableEnterRoom:r})},Sm=function(e){return Ni(Gr,e)},v5=function(){return Em(Ni(Gr).id)},y5=function(){return Dm(Ni(Gr).id)},b5=function(e={}){return ib(Gr,e)};Ip("@liveblocks/react","3.24.0","esm");var Sn=typeof window<"u"?m.useLayoutEffect:m.useEffect;function ub(e){return e===void 0||e?.isLoading?e??{isLoading:!0}:e.error?e:{isLoading:!1,group:e.data}}function cb(e,t){const[n,r]=m.useState(),o=m.useRef(),i=Kc(),s=Ve()[Oe].mentionSuggestionsCache;return m.useEffect((()=>{if(t===void 0||!i)return;const a={text:t,roomId:e},u=Yt(a);let c,f=!1;const l=async()=>{try{o.current=performance.now();const d=await i(a);if(!f){const h=d.map((g=>typeof g=="string"?{kind:"user",id:g}:g));r(h),s.set(u,h)}}catch(d){console.error(d?.message)}};if(s.has(u)){const d=s.get(u);r(d)}else!o.current||Math.abs(performance.now()-o.current)>500?l():c=window.setTimeout((()=>{l()}),500);return()=>{f=!0,window.clearTimeout(c)}}),[t,e,i,s]),n}function Ne(...e){return e.filter((t=>typeof t=="string"||typeof t=="number")).join(" ")}const Gc=m.forwardRef((({emoji:e,className:t,style:n,...r},o)=>v.jsx("span",{role:"img","aria-label":e,"data-emoji":e,className:Ne("lb-emoji",t),style:{...n,fontFamily:"'Apple Color Emoji', 'Noto Color Emoji', 'Twemoji Mozilla', 'Android Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', EmojiSymbols, sans-serif"},...r,ref:o,children:e})));var lb=Object.defineProperty,Pa=(e,t)=>lb(e,"name",{value:t,configurable:!0});function Mu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Im(...e){return t=>{let n=!1;const r=e.map((o=>{const i=Mu(o,t);return n||typeof i!="function"||(n=!0),i}));if(n)return()=>{for(let o=0;o<r.length;o++){const i=r[o];typeof i=="function"?i():Mu(e[o],null)}}}}function Qe(...e){return m.useCallback(Im(...e),e)}Pa(Mu,"setRef"),Pa(Im,"composeRefs"),Pa(Qe,"useComposedRefs");var db=Object.defineProperty,cn=(e,t)=>db(e,"name",{value:t,configurable:!0});function Wn(e){const t=m.forwardRef(((n,r)=>{let{children:o,...i}=n,s=null,a=!1;const u=[];Pu(o)&&typeof rs=="function"&&(o=rs(o._payload)),m.Children.forEach(o,(d=>{if(Bm(d)){a=!0;const h=d;let g="child"in h.props?h.props.child:h.props.children;Pu(g)&&typeof rs=="function"&&(g=rs(g._payload)),s=hb(h,g),u.push(s?.props?.children)}else u.push(d)})),s?s=m.cloneElement(s,void 0,u):!a&&m.Children.count(o)===1&&m.isValidElement(o)&&(s=o);const c=s?_m(s):void 0,f=Qe(r,c);if(!s){if(o||o===0)throw new Error(a?gb(e):mb(e));return o}const l=km(i,s.props??{});return s.type!==m.Fragment&&(l.ref=r?f:c),m.cloneElement(s,l)}));return t.displayName=`${e}.Slot`,t}cn(Wn,"createSlot");var vt=Wn("Slot"),Tm=Symbol.for("radix.slottable");function Jc(e){const t=cn((n=>"child"in n?n.children(n.child):n.children),"Slottable");return t.displayName=`${e}.Slottable`,t.__radixId=Tm,t}cn(Jc,"createSlottable");var fb=Jc("Slottable"),hb=cn(((e,t)=>{if("child"in e.props){const n=e.props.child;return m.isValidElement(n)?m.cloneElement(n,void 0,e.props.children(n.props.children)):null}return m.isValidElement(t)?t:null}),"getSlottableElementFromSlottable");function km(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...s)=>{const a=i(...s);return o(...s),a}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function _m(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function Bm(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Tm}cn(km,"mergeProps"),cn(_m,"getElementRef"),cn(Bm,"isSlottable");var pb=Symbol.for("react.lazy");function Pu(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===pb&&"_payload"in e&&Fm(e._payload)}function Fm(e){return typeof e=="object"&&e!==null&&"then"in e}cn(Pu,"isLazyComponent"),cn(Fm,"isPromiseLike");var mb=cn((e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`),"createSlotError"),gb=cn((e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`),"createSlottableError"),rs=No[" use ".trim().toString()],vb=Object.defineProperty,Wt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce(((e,t)=>{const n=Wn(`Primitive.${t}`),r=m.forwardRef(((o,i)=>{const{asChild:s,...a}=o,u=s?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),v.jsx(u,{...a,ref:i})}));return r.displayName=`Primitive.${t}`,{...e,[t]:r}}),{});function Zc(e,t){e&&Mi.flushSync((()=>e.dispatchEvent(t)))}vb(Zc,"name",{value:"dispatchDiscreteCustomEvent",configurable:!0});var yb=Object.defineProperty,bb=(e,t)=>yb(e,"name",{value:t,configurable:!0}),Cb=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),wb=m.forwardRef(bb((function(e,t){return v.jsx(Wt.span,{...e,ref:t,style:{...Cb,...e.style}})}),"VisuallyHidden")),Eb=Object.defineProperty,Jt=(e,t)=>Eb(e,"name",{value:t,configurable:!0});function Jn(e,t=[]){let n=[];function r(i,s){const a=m.createContext(s);a.displayName=i+"Context";const u=n.length;n=[...n,s];const c=Jt((l=>{const{scope:d,children:h,...g}=l,y=d?.[e]?.[u]||a,p=m.useMemo((()=>g),Object.values(g));return v.jsx(y.Provider,{value:p,children:h})}),"Provider");function f(l,d,h={}){const{optional:g=!1}=h,y=d?.[e]?.[u]||a,p=m.useContext(y);if(p)return p;if(s!==void 0)return s;if(!g)throw new Error(`\`${l}\` must be used within \`${i}\``)}return c.displayName=i+"Provider",Jt(f,"useContext"),[c,f]}Jt(r,"createContext");const o=Jt((()=>{const i=n.map((s=>m.createContext(s)));return Jt((function(s){const a=s?.[e]||i;return m.useMemo((()=>({[`__scope${e}`]:{...s,[e]:a}})),[s,a])}),"useScope")}),"createScope");return o.scopeName=e,[r,Rm(o,...t)]}function Rm(...e){const t=e[0];if(e.length===1)return t;const n=Jt((()=>{const r=e.map((o=>({useScope:o(),scopeName:o.scopeName})));return Jt((function(o){const i=r.reduce(((s,{useScope:a,scopeName:u})=>({...s,...a(o)[`__scope${u}`]})),{});return m.useMemo((()=>({[`__scope${t.scopeName}`]:i})),[i])}),"useComposedScopes")}),"createScope");return n.scopeName=t.scopeName,n}Jt((function(e,t){const n=m.createContext(t);n.displayName=e+"Context";const r=Jt((i=>{const{children:s,...a}=i,u=m.useMemo((()=>a),Object.values(a));return v.jsx(n.Provider,{value:u,children:s})}),"Provider");function o(i,s={}){const{optional:a=!1}=s,u=m.useContext(n);if(u)return u;if(t!==void 0)return t;if(!a)throw new Error(`\`${i}\` must be used within \`${e}\``)}return r.displayName=e+"Provider",Jt(o,"useContext"),[r,o]}),"createContext"),Jt(Jn,"createContextScope"),Jt(Rm,"composeContextScopes");var Db=Object.defineProperty,ct=(e,t)=>Db(e,"name",{value:t,configurable:!0});function Xc(e){const t=e+"CollectionProvider",[n,r]=Jn(t),[o,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),s=ct((y=>{const{scope:p,children:w}=y,b=m.useRef(null),C=m.useRef(new Map).current;return v.jsx(o,{scope:p,itemMap:C,collectionRef:b,children:w})}),"CollectionProvider");s.displayName=t;const a=e+"CollectionSlot",u=Wn(a),c=m.forwardRef(((y,p)=>{const{scope:w,children:b}=y,C=Qe(p,i(a,w).collectionRef);return v.jsx(u,{ref:C,children:b})}));c.displayName=a;const f=e+"CollectionItemSlot",l="data-radix-collection-item",d=Wn(f),h=m.forwardRef(((y,p)=>{const{scope:w,children:b,...C}=y,E=m.useRef(null),A=Qe(p,E),x=i(f,w);return m.useEffect((()=>(x.itemMap.set(E,{ref:E,...C}),()=>{x.itemMap.delete(E)}))),v.jsx(d,{[l]:"",ref:A,children:b})}));function g(y){const p=i(e+"CollectionConsumer",y);return m.useCallback((()=>{const w=p.collectionRef.current;if(!w)return[];const b=Array.from(w.querySelectorAll(`[${l}]`));return Array.from(p.itemMap.values()).sort(((C,E)=>b.indexOf(C.ref.current)-b.indexOf(E.ref.current)))}),[p.collectionRef,p.itemMap])}return h.displayName=f,ct(g,"useCollection"),[{Provider:s,Slot:c,ItemSlot:h},g,r]}ct(Xc,"createCollection");var zd=new WeakMap,it,Lt,Na=(Lt=class extends Map{constructor(n){super(n);nd(this,it);wa(this,it,[...super.keys()]),zd.set(this,!0)}set(n,r){return zd.get(this)&&(this.has(n)?bt(this,it)[bt(this,it).indexOf(n)]=n:bt(this,it).push(n)),super.set(n,r),this}insert(n,r,o){const i=this.has(r),s=bt(this,it).length,a=Yc(n);let u=a>=0?a:s+a;const c=u<0||u>=s?-1:u;if(c===this.size||i&&c===this.size-1||c===-1)return this.set(r,o),this;const f=this.size+(i?0:1);a<0&&u++;const l=[...bt(this,it)];let d,h=!1;for(let g=u;g<f;g++)if(u===g){let y=l[g];l[g]===r&&(y=l[g+1]),i&&this.delete(r),d=this.get(y),this.set(r,o)}else{h||l[g-1]!==r||(h=!0);const y=l[h?g:g-1],p=d;d=this.get(y),this.delete(y),this.set(y,p)}return this}with(n,r,o){const i=new Lt(this);return i.insert(n,r,o),i}before(n){const r=bt(this,it).indexOf(n)-1;if(!(r<0))return this.entryAt(r)}setBefore(n,r,o){const i=bt(this,it).indexOf(n);return i===-1?this:this.insert(i,r,o)}after(n){let r=bt(this,it).indexOf(n);if(r=r===-1||r===this.size-1?-1:r+1,r!==-1)return this.entryAt(r)}setAfter(n,r,o){const i=bt(this,it).indexOf(n);return i===-1?this:this.insert(i+1,r,o)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return wa(this,it,[]),super.clear()}delete(n){const r=super.delete(n);return r&&bt(this,it).splice(bt(this,it).indexOf(n),1),r}deleteAt(n){const r=this.keyAt(n);return r!==void 0&&this.delete(r)}at(n){const r=ws(bt(this,it),n);if(r!==void 0)return this.get(r)}entryAt(n){const r=ws(bt(this,it),n);if(r!==void 0)return[r,this.get(r)]}indexOf(n){return bt(this,it).indexOf(n)}keyAt(n){return ws(bt(this,it),n)}from(n,r){const o=this.indexOf(n);if(o===-1)return;let i=o+r;return i<0&&(i=0),i>=this.size&&(i=this.size-1),this.at(i)}keyFrom(n,r){const o=this.indexOf(n);if(o===-1)return;let i=o+r;return i<0&&(i=0),i>=this.size&&(i=this.size-1),this.keyAt(i)}find(n,r){let o=0;for(const i of this){if(Reflect.apply(n,r,[i,o,this]))return i;o++}}findIndex(n,r){let o=0;for(const i of this){if(Reflect.apply(n,r,[i,o,this]))return o;o++}return-1}filter(n,r){const o=[];let i=0;for(const s of this)Reflect.apply(n,r,[s,i,this])&&o.push(s),i++;return new Lt(o)}map(n,r){const o=[];let i=0;for(const s of this)o.push([s[0],Reflect.apply(n,r,[s,i,this])]),i++;return new Lt(o)}reduce(...n){const[r,o]=n;let i=0,s=o??this.at(0);for(const a of this)s=i===0&&n.length===1?a:Reflect.apply(r,this,[s,a,i,this]),i++;return s}reduceRight(...n){const[r,o]=n;let i=o??this.at(-1);for(let s=this.size-1;s>=0;s--){const a=this.at(s);i=s===this.size-1&&n.length===1?a:Reflect.apply(r,this,[i,a,s,this])}return i}toSorted(n){const r=[...this.entries()].sort(n);return new Lt(r)}toReversed(){const n=new Lt;for(let r=this.size-1;r>=0;r--){const o=this.keyAt(r),i=this.get(o);n.set(o,i)}return n}toSpliced(...n){const r=[...this.entries()];return r.splice(...n),new Lt(r)}slice(n,r){const o=new Lt;let i=this.size-1;if(n===void 0)return o;n<0&&(n+=this.size),r!==void 0&&r>0&&(i=r-1);for(let s=n;s<=i;s++){const a=this.keyAt(s),u=this.get(a);o.set(a,u)}return o}every(n,r){let o=0;for(const i of this){if(!Reflect.apply(n,r,[i,o,this]))return!1;o++}return!0}some(n,r){let o=0;for(const i of this){if(Reflect.apply(n,r,[i,o,this]))return!0;o++}return!1}},it=new WeakMap,ct(Lt,"OrderedDict"),Lt);function ws(e,t){if("at"in Array.prototype)return Array.prototype.at.call(e,t);const n=jm(e,t);return n===-1?void 0:e[n]}function jm(e,t){const n=e.length,r=Yc(t),o=r>=0?r:n+r;return o<0||o>=n?-1:o}function Yc(e){return e!=e||e===0?0:Math.trunc(e)}function Kd(e,t){if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e==null||t==null)return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||e[o]!==t[o])return!1;return!0}function Mm(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}function La(e,t){return e[1].element&&t[1].element?Mm(e[1].element,t[1].element)?-1:1:0}function qd(e){return new MutationObserver((t=>{for(const n of t)if(n.type==="childList")return void e()}))}ct(ws,"at"),ct(jm,"toSafeIndex"),ct(Yc,"toSafeInteger"),ct((function(e){const t=e+"CollectionProvider",[n,r]=Jn(t),[o,i]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new Na,setItemMap:ct((()=>{}),"setItemMap")}),s=ct((({state:b,...C})=>b?v.jsx(u,{...C,state:b}):v.jsx(a,{...C})),"CollectionProvider");s.displayName=t;const a=ct((b=>{const C=p();return v.jsx(u,{...b,state:C})}),"CollectionInit");a.displayName=t+"Init";const u=ct((b=>{const{scope:C,children:E,state:A}=b,x=m.useRef(null),[I,T]=m.useState(null),B=Qe(x,T),[S,k]=A;return m.useEffect((()=>{if(!I)return;const R=qd((()=>{}));return R.observe(I,{childList:!0,subtree:!0}),()=>{R.disconnect()}}),[I]),v.jsx(o,{scope:C,itemMap:S,setItemMap:k,collectionRef:B,collectionRefObject:x,collectionElement:I,children:E})}),"CollectionProviderImpl");u.displayName=t+"Impl";const c=e+"CollectionSlot",f=Wn(c),l=m.forwardRef(((b,C)=>{const{scope:E,children:A}=b,x=Qe(C,i(c,E).collectionRef);return v.jsx(f,{ref:x,children:A})}));l.displayName=c;const d=e+"CollectionItemSlot",h="data-radix-collection-item",g=Wn(d),y=m.forwardRef(((b,C)=>{const{scope:E,children:A,...x}=b,I=m.useRef(null),[T,B]=m.useState(null),S=Qe(C,I,B),k=i(d,E),{setItemMap:R}=k,M=m.useRef(x);Kd(M.current,x)||(M.current=x);const H=M.current;return m.useEffect((()=>{const W=H;return R((G=>T?G.has(T)?G.set(T,{...W,element:T}).toSorted(La):(G.set(T,{...W,element:T}),G.toSorted(La)):G)),()=>{R((G=>T&&G.has(T)?(G.delete(T),new Na(G)):G))}}),[T,H,R]),v.jsx(g,{[h]:"",ref:S,children:A})}));function p(){return m.useState(new Na)}function w(b){const{itemMap:C}=i(e+"CollectionConsumer",b);return C}return y.displayName=d,ct(p,"useInitCollection"),ct(w,"useCollection"),[{Provider:s,Slot:l,ItemSlot:y},{createCollectionScope:r,useCollection:w,useInitCollection:p}]}),"createCollection"),ct(Kd,"shallowEqual"),ct(Mm,"isElementPreceding"),ct(La,"sortByDocumentPosition"),ct(qd,"getChildListObserver");var Ab=Object.defineProperty,lo=(e,t)=>Ab(e,"name",{value:t,configurable:!0}),Pm=!(typeof window>"u"||!window.document||!window.document.createElement);function Me(e,t,{checkForDefaultPrevented:n=!0}={}){return lo((function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)}),"handleEvent")}function Ua(e){if(!Pm)throw new Error("Cannot access document outside of the DOM");return e?.ownerDocument??document}function Gd(e){return e.tagName==="IFRAME"}lo(Me,"composeEventHandlers"),lo((function(e){if(!Pm)throw new Error("Cannot access window outside of the DOM");return e?.ownerDocument?.defaultView??window}),"getOwnerWindow"),lo(Ua,"getOwnerDocument"),lo((function e(t,n=!1){const{activeElement:r}=Ua(t);if(!r?.nodeName)return null;if(Gd(r)&&r.contentDocument)return e(r.contentDocument.body,n);if(n){const o=r.getAttribute("aria-activedescendant");if(o){const i=Ua(r).getElementById(o);if(i)return i}}return r}),"getActiveElement"),lo(Gd,"isFrame");var Qt=globalThis?.document?m.useLayoutEffect:()=>{},xb=Object.defineProperty,Jd=No[" useEffectEvent ".trim().toString()],Zd=No[" useInsertionEffect ".trim().toString()];function Nm(e){if(typeof Jd=="function")return Jd(e);const t=m.useRef((()=>{throw new Error("Cannot call an event handler while rendering.")}));return typeof Zd=="function"?Zd((()=>{t.current=e})):Qt((()=>{t.current=e})),m.useMemo((()=>(...n)=>t.current?.(...n)),[])}((e,t)=>{xb(e,"name",{value:t,configurable:!0})})(Nm,"useEffectEvent");var Ob=Object.defineProperty,di=(e,t)=>Ob(e,"name",{value:t,configurable:!0}),Sb=No[" useInsertionEffect ".trim().toString()]||Qt;function $o({prop:e,defaultProp:t,onChange:n=di((()=>{}),"onChange"),caller:r}){const[o,i,s]=Lm({defaultProp:t,onChange:n}),a=e!==void 0;return[a?e:o,m.useCallback((u=>{if(a){const c=Um(u)?u(e):u;c!==e&&s.current?.(c)}else i(u)}),[a,e,i,s])]}function Lm({defaultProp:e,onChange:t}){const[n,r]=m.useState(e),o=m.useRef(n),i=m.useRef(t);return Sb((()=>{i.current=t}),[t]),m.useEffect((()=>{o.current!==n&&(i.current?.(n),o.current=n)}),[n,o]),[n,r,i]}function Um(e){return typeof e=="function"}di($o,"useControllableState"),di(Lm,"useUncontrolledState"),di(Um,"isFunction");var Xd=Symbol("RADIX:SYNC_STATE");di((function(e,t,n,r){const{prop:o,defaultProp:i,onChange:s,caller:a}=t,u=o!==void 0,c=Nm(s),f=[{...n,state:i}];r&&f.push(r);const[l,d]=m.useReducer(((p,w)=>{if(w.type===Xd)return{...p,state:w.state};const b=e(p,w);return u&&!Object.is(b.state,p.state)&&c(b.state),b}),...f),h=l.state,g=m.useRef(h);m.useEffect((()=>{g.current!==h&&(g.current=h,u||c(h))}),[h,g,u]);const y=m.useMemo((()=>o!==void 0?{...l,state:o}:l),[l,o]);return m.useEffect((()=>{u&&!Object.is(o,l.state)&&d({type:Xd,state:o})}),[o,l.state,u]),[y,d]}),"useControllableStateReducer");var Ib=Object.defineProperty,Mn=(e,t)=>Ib(e,"name",{value:t,configurable:!0});function Hm(e,t){return m.useReducer(((n,r)=>t[n][r]??n),e)}Mn(Hm,"useStateMachine");var Wo=Mn((e=>{const{present:t,children:n}=e,r=Vm(t),o=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),i=$m(r.ref,Wm(o));return typeof n=="function"||r.isPresent?m.cloneElement(o,{ref:i}):null}),"Presence");function Vm(e){const[t,n]=m.useState(),r=m.useRef(null),o=m.useRef(e),i=m.useRef("none"),s=m.useRef(void 0),a=e?"mounted":"unmounted",[u,c]=Hm(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect((()=>{u==="mounted"?(i.current=s.current??fo(r.current),s.current=void 0):i.current="none"}),[u]),Qt((()=>{const f=r.current,l=o.current;if(l!==e){const d=i.current,h=fo(f);e?(s.current=h,c("MOUNT")):h==="none"||f?.display==="none"?c("UNMOUNT"):c(l&&d!==h?"ANIMATION_OUT":"UNMOUNT"),o.current=e}}),[e,c]),Qt((()=>{if(t){let f;const l=t.ownerDocument.defaultView??window,d=Mn((g=>{const y=fo(r.current).includes(CSS.escape(g.animationName));if(g.target===t&&y&&(c("ANIMATION_END"),!o.current)){const p=t.style.animationFillMode;t.style.animationFillMode="forwards",f=l.setTimeout((()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=p)}))}}),"handleAnimationEnd"),h=Mn((g=>{g.target===t&&(i.current=fo(r.current))}),"handleAnimationStart");return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{l.clearTimeout(f),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}c("ANIMATION_END")}),[t,c]),{isPresent:["mounted","unmountSuspended"].includes(u),ref:m.useCallback((f=>{if(f){const l=getComputedStyle(f);r.current=l,s.current=fo(l)}else r.current=null;n(f)}),[])}}function Nu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function $m(...e){const t=m.useRef(e);return t.current=e,m.useCallback((n=>{const r=t.current;let o=!1;const i=r.map((s=>{const a=Nu(s,n);return o||typeof a!="function"||(o=!0),a}));if(o)return()=>{for(let s=0;s<i.length;s++){const a=i[s];typeof a=="function"?a():Nu(r[s],null)}}}),[])}function fo(e){return e?.animationName||"none"}function Wm(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}Mn(Vm,"usePresence"),Mn(Nu,"setRef"),Mn($m,"useStableComposedRefs"),Mn(fo,"getAnimationName"),Mn(Wm,"getElementRef");var Tb=Object.defineProperty,kb=No[" useId ".trim().toString()]||(()=>{}),_b=0;function Io(e){const[t,n]=m.useState(kb());return Qt((()=>{e||n((r=>r??String(_b++)))}),[e]),e||(t?`radix-${t}`:"")}((e,t)=>{Tb(e,"name",{value:t,configurable:!0})})(Io,"useId");var Bb=Object.defineProperty,Fb=m.createContext(void 0);function Qc(e){const t=m.useContext(Fb);return e||t||"ltr"}((e,t)=>{Bb(e,"name",{value:t,configurable:!0})})(Qc,"useDirection");var Rb=Object.defineProperty;function zn(e){const t=m.useRef(e);return m.useEffect((()=>{t.current=e})),m.useMemo((()=>(...n)=>t.current?.(...n)),[])}((e,t)=>{Rb(e,"name",{value:t,configurable:!0})})(zn,"useCallbackRef");var Yd,jb=Object.defineProperty,dt=(e,t)=>jb(e,"name",{value:t,configurable:!0}),Lu="dismissableLayer.update",zm=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),el=m.forwardRef(dt((function(e,t){const{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:o,onPointerDownOutside:i,onFocusOutside:s,onInteractOutside:a,onDismiss:u,...c}=e,f=m.useContext(zm),[l,d]=m.useState(null),h=l?.ownerDocument??globalThis?.document,[,g]=m.useState({}),y=Qe(t,d),p=Array.from(f.layers),[w]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),b=w?p.indexOf(w):-1,C=l?p.indexOf(l):-1,E=f.layersWithOutsidePointerEventsDisabled.size>0,A=C>=b,x=m.useRef(!1),I=Km((k=>{i?.(k),a?.(k),k.defaultPrevented||u?.()}),{ownerDocument:h,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:x,dismissableSurfaces:f.dismissableSurfaces,shouldHandlePointerDownOutside:m.useCallback((k=>{if(!(k instanceof Node))return!1;const R=[...f.branches].some((M=>M.contains(k)));return A&&!R}),[f.branches,A])}),T=qm((k=>{if(r&&x.current)return;const R=k.target;[...f.branches].some((M=>M.contains(R)))||(s?.(k),a?.(k),k.defaultPrevented||u?.())}),h),B=!!l&&C===p.length-1,S=zn((k=>{k.key==="Escape"&&(o?.(k),!k.defaultPrevented&&u&&(k.preventDefault(),u()))}));return m.useEffect((()=>{if(B)return h.addEventListener("keydown",S,{capture:!0}),()=>h.removeEventListener("keydown",S,{capture:!0})}),[h,B,S]),m.useEffect((()=>{if(l)return n&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(Yd=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(l)),f.layers.add(l),Uu(),()=>{n&&(f.layersWithOutsidePointerEventsDisabled.delete(l),f.layersWithOutsidePointerEventsDisabled.size===0&&(h.body.style.pointerEvents=Yd))}}),[l,h,n,f]),m.useEffect((()=>()=>{l&&(f.layers.delete(l),f.layersWithOutsidePointerEventsDisabled.delete(l),Uu())}),[l,f]),m.useEffect((()=>{const k=dt((()=>g({})),"handleUpdate");return document.addEventListener(Lu,k),()=>document.removeEventListener(Lu,k)}),[]),v.jsx(Wt.div,{...c,ref:y,style:{pointerEvents:E?A?"auto":"none":void 0,...e.style},onFocusCapture:Me(e.onFocusCapture,T.onFocusCapture),onBlurCapture:Me(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:Me(e.onPointerDownCapture,I.onPointerDownCapture)})}),"DismissableLayer"));dt((function(){const e=m.useContext(zm),[t,n]=m.useState(null);return m.useEffect((()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}}),[t,e.dismissableSurfaces]),n}),"useDismissableLayerSurface");var Mb=dt((()=>!0),"IS_TRUE");function Km(e,t){const{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:o,dismissableSurfaces:i,shouldHandlePointerDownOutside:s=Mb}=t,a=zn(e),u=m.useRef(!1),c=m.useRef(!1),f=m.useRef(new Map),l=m.useRef((()=>{}));return m.useEffect((()=>{function d(){c.current=!1,o.current=!1,f.current.clear()}function h(){return Array.from(f.current.values()).some(Boolean)}function g(C){if(!c.current)return;const E=C.target;E instanceof Node&&[...i].some((A=>A.contains(E)))||f.current.set(C.type,!0),C.type==="click"&&window.setTimeout((()=>{c.current&&l.current()}),0)}function y(C){c.current&&f.current.set(C.type,!1)}dt(d,"resetOutsideInteraction"),dt(h,"isOutsideInteractionIntercepted"),dt(g,"handleInteractionCapture"),dt(y,"handleInteractionBubble");const p=dt((C=>{if(C.target&&!u.current){let E=function(){n.removeEventListener("click",l.current);const x=h();d(),x||tl("dismissableLayer.pointerDownOutside",a,A,{discrete:!0})};if(dt(E,"handleAndDispatchPointerDownOutsideEvent"),!s(C.target))return n.removeEventListener("click",l.current),d(),void(u.current=!1);const A={originalEvent:C};c.current=!0,o.current=r&&C.button===0,f.current.clear(),r&&C.button===0?(n.removeEventListener("click",l.current),l.current=E,n.addEventListener("click",l.current,{once:!0})):E()}else n.removeEventListener("click",l.current),d();u.current=!1}),"handlePointerDown"),w=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const C of w)n.addEventListener(C,g,!0),n.addEventListener(C,y);const b=window.setTimeout((()=>{n.addEventListener("pointerdown",p)}),0);return()=>{window.clearTimeout(b),n.removeEventListener("pointerdown",p),n.removeEventListener("click",l.current);for(const C of w)n.removeEventListener(C,g,!0),n.removeEventListener(C,y)}}),[n,a,r,o,i,s]),{onPointerDownCapture:dt((()=>u.current=!0),"onPointerDownCapture")}}function qm(e,t=globalThis?.document){const n=zn(e),r=m.useRef(!1);return m.useEffect((()=>{const o=dt((i=>{i.target&&!r.current&&tl("dismissableLayer.focusOutside",n,{originalEvent:i},{discrete:!1})}),"handleFocus");return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)}),[t,n]),{onFocusCapture:dt((()=>r.current=!0),"onFocusCapture"),onBlurCapture:dt((()=>r.current=!1),"onBlurCapture")}}function Uu(){const e=new CustomEvent(Lu);document.dispatchEvent(e)}function tl(e,t,n,{discrete:r}){const o=n.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Zc(o,i):o.dispatchEvent(i)}dt(Km,"usePointerDownOutside"),dt(qm,"useFocusOutside"),dt(Uu,"dispatchUpdate"),dt(tl,"handleAndDispatchCustomEvent");var Pb=Object.defineProperty,xt=(e,t)=>Pb(e,"name",{value:t,configurable:!0}),Ha="focusScope.autoFocusOnMount",Va="focusScope.autoFocusOnUnmount",Qd={bubbles:!1,cancelable:!0},Gm=m.forwardRef(xt((function(e,t){const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:i,...s}=e,[a,u]=m.useState(null),c=zn(o),f=zn(i),l=m.useRef(null),d=Qe(t,u),h=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect((()=>{if(r){let y=function(C){if(h.paused||!a)return;const E=C.target;a.contains(E)?l.current=E:jn(l.current,{select:!0})},p=function(C){if(h.paused||!a)return;const E=C.relatedTarget;E!==null&&(a.contains(E)||jn(l.current,{select:!0}))},w=function(C){if(document.activeElement===document.body)for(const E of C)E.removedNodes.length>0&&jn(a)};xt(y,"handleFocusIn"),xt(p,"handleFocusOut"),xt(w,"handleMutations"),document.addEventListener("focusin",y),document.addEventListener("focusout",p);const b=new MutationObserver(w);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",y),document.removeEventListener("focusout",p),b.disconnect()}}}),[r,a,h.paused]),m.useEffect((()=>{if(a){ef.add(h);const y=document.activeElement;if(!a.contains(y)){const p=new CustomEvent(Ha,Qd);a.addEventListener(Ha,c),a.dispatchEvent(p),p.defaultPrevented||(Jm(eg(nl(a)),{select:!0}),document.activeElement===y&&jn(a))}return()=>{a.removeEventListener(Ha,c),setTimeout((()=>{const p=new CustomEvent(Va,Qd);a.addEventListener(Va,f),a.dispatchEvent(p),p.defaultPrevented||jn(y??document.body,{select:!0}),a.removeEventListener(Va,f),ef.remove(h)}),0)}}}),[a,c,f,h]);const g=m.useCallback((y=>{if(!n&&!r||h.paused)return;const p=y.key==="Tab"&&!y.altKey&&!y.ctrlKey&&!y.metaKey,w=document.activeElement;if(p&&w){const b=y.currentTarget,[C,E]=Zm(b);C&&E?y.shiftKey||w!==E?y.shiftKey&&w===C&&(y.preventDefault(),n&&jn(E,{select:!0})):(y.preventDefault(),n&&jn(C,{select:!0})):w===b&&y.preventDefault()}}),[n,r,h.paused]);return v.jsx(Wt.div,{tabIndex:-1,...s,ref:d,onKeyDown:g})}),"FocusScope"));function Jm(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(jn(r,{select:t}),document.activeElement!==n)return}function Zm(e){const t=nl(e);return[Hu(t,e),Hu(t.reverse(),e)]}function nl(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:xt((r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}),"acceptNode")});for(;n.nextNode();)t.push(n.currentNode);return t}function Hu(e,t){const n=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(const r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):Xm(r,{upTo:t})))return r}function Xm(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Ym(e){return e instanceof HTMLInputElement&&"select"in e}function jn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Ym(e)&&t&&e.select()}}xt(Jm,"focusFirst"),xt(Zm,"getTabbableEdges"),xt(nl,"getTabbableCandidates"),xt(Hu,"findVisible"),xt(Xm,"isHidden"),xt(Ym,"isSelectableInput"),xt(jn,"focus");var ef=Qm();function Qm(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=Vu(e,t),e.unshift(t)},remove(t){e=Vu(e,t),e[0]?.resume()}}}function Vu(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function eg(e){return e.filter((t=>t.tagName!=="A"))}xt(Qm,"createFocusScopesStack"),xt(Vu,"arrayRemove"),xt(eg,"removeLinks");var Nb=Object.defineProperty,Lb=(e,t)=>Nb(e,"name",{value:t,configurable:!0}),rl=m.forwardRef(Lb((function(e,t){const{container:n,...r}=e,[o,i]=m.useState(!1);Qt((()=>i(!0)),[]);const s=n||o&&globalThis?.document?.body;return s?Mi.createPortal(v.jsx(Wt.div,{...r,ref:t}),s):null}),"Portal")),Ub=Object.defineProperty,$a=(e,t)=>Ub(e,"name",{value:t,configurable:!0}),os=0,eo=null;function Ls(){m.useEffect((()=>{eo||(eo={start:$u(),end:$u()});const{start:e,end:t}=eo;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),os++,()=>{os===1&&(eo?.start.remove(),eo?.end.remove(),eo=null),os=Math.max(0,os-1)}}),[])}function $u(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}$a((function(e){return Ls(),e.children}),"FocusGuards"),$a(Ls,"useFocusGuards"),$a($u,"createFocusGuard");var Dn=function(){return Dn=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Dn.apply(this,arguments)};function tg(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function"){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}var Es="right-scroll-bar-position",Ds="width-before-scroll-bar";function Wa(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}var Hb=typeof window<"u"?m.useLayoutEffect:m.useEffect,tf=new WeakMap;function Vb(e,t){var n,r,o,i=(n=null,r=function(s){return e.forEach((function(a){return Wa(a,s)}))},o=m.useState((function(){return{value:n,callback:r,facade:{get current(){return o.value},set current(s){var a=o.value;a!==s&&(o.value=s,o.callback(s,a))}}}}))[0],o.callback=r,o.facade);return Hb((function(){var s=tf.get(i);if(s){var a=new Set(s),u=new Set(e),c=i.current;a.forEach((function(f){u.has(f)||Wa(f,null)})),u.forEach((function(f){a.has(f)||Wa(f,c)}))}tf.set(i,e)}),[e]),i}function $b(e){return e}var ng=function(e){var t=e.sideCar,n=tg(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return m.createElement(r,Dn({},n))};ng.isSideCarExport=!0;var rg=(function(e){e===void 0&&(e={});var t=(function(n,r){r===void 0&&(r=$b);var o=[],i=!1,s={read:function(){if(i)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return o.length?o[o.length-1]:n},useMedium:function(a){var u=r(a,i);return o.push(u),function(){o=o.filter((function(c){return c!==u}))}},assignSyncMedium:function(a){for(i=!0;o.length;){var u=o;o=[],u.forEach(a)}o={push:function(c){return a(c)},filter:function(){return o}}},assignMedium:function(a){i=!0;var u=[];if(o.length){var c=o;o=[],c.forEach(a),u=o}var f=function(){var d=u;u=[],d.forEach(a)},l=function(){return Promise.resolve().then(f)};l(),o={push:function(d){u.push(d),l()},filter:function(d){return u=u.filter(d),o}}}};return s})(null);return t.options=Dn({async:!0,ssr:!1},e),t})(),za=function(){},Us=m.forwardRef((function(e,t){var n=m.useRef(null),r=m.useState({onScrollCapture:za,onWheelCapture:za,onTouchMoveCapture:za}),o=r[0],i=r[1],s=e.forwardProps,a=e.children,u=e.className,c=e.removeScrollBar,f=e.enabled,l=e.shards,d=e.sideCar,h=e.noRelative,g=e.noIsolation,y=e.inert,p=e.allowPinchZoom,w=e.as,b=w===void 0?"div":w,C=e.gapMode,E=tg(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),A=d,x=Vb([n,t]),I=Dn(Dn({},E),o);return m.createElement(m.Fragment,null,f&&m.createElement(A,{sideCar:rg,removeScrollBar:c,shards:l,noRelative:h,noIsolation:g,inert:y,setCallbacks:i,allowPinchZoom:!!p,lockRef:n,gapMode:C}),s?m.cloneElement(m.Children.only(a),Dn(Dn({},I),{ref:x})):m.createElement(b,Dn({},I,{className:u,ref:x}),a))}));Us.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Us.classNames={fullWidth:Ds,zeroRight:Es};function Wb(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=(function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__})();return t&&e.setAttribute("nonce",t),e}var zb=function(){var e=0,t=null;return{add:function(n){var r,o;e==0&&(t=Wb())&&(o=n,(r=t).styleSheet?r.styleSheet.cssText=o:r.appendChild(document.createTextNode(o)),(function(i){(document.head||document.getElementsByTagName("head")[0]).appendChild(i)})(t)),e++},remove:function(){!--e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},og=function(){var e,t=(e=zb(),function(n,r){m.useEffect((function(){return e.add(n),function(){e.remove()}}),[n&&r])});return function(n){var r=n.styles,o=n.dynamic;return t(r,o),null}},Kb={left:0,top:0,right:0,gap:0},Ka=function(e){return parseInt(e||"",10)||0},qb=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Kb;var t=(function(o){var i=window.getComputedStyle(document.body),s=i[o==="padding"?"paddingLeft":"marginLeft"],a=i[o==="padding"?"paddingTop":"marginTop"],u=i[o==="padding"?"paddingRight":"marginRight"];return[Ka(s),Ka(a),Ka(u)]})(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Gb=og(),Co="data-scroll-locked",Jb=function(e,t,n,r){var o=e.left,i=e.top,s=e.right,a=e.gap;return n===void 0&&(n="margin"),`
9
+ .`.concat("with-scroll-bars-hidden",` {
10
+ overflow: hidden `).concat(r,`;
11
+ padding-right: `).concat(a,"px ").concat(r,`;
12
+ }
13
+ body[`).concat(Co,`] {
14
+ overflow: hidden `).concat(r,`;
15
+ overscroll-behavior: contain;
16
+ `).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
17
+ padding-left: `.concat(o,`px;
18
+ padding-top: `).concat(i,`px;
19
+ padding-right: `).concat(s,`px;
20
+ margin-left:0;
21
+ margin-top:0;
22
+ margin-right: `).concat(a,"px ").concat(r,`;
23
+ `),n==="padding"&&"padding-right: ".concat(a,"px ").concat(r,";")].filter(Boolean).join(""),`
24
+ }
25
+
26
+ .`).concat(Es,` {
27
+ right: `).concat(a,"px ").concat(r,`;
28
+ }
29
+
30
+ .`).concat(Ds,` {
31
+ margin-right: `).concat(a,"px ").concat(r,`;
32
+ }
33
+
34
+ .`).concat(Es," .").concat(Es,` {
35
+ right: 0 `).concat(r,`;
36
+ }
37
+
38
+ .`).concat(Ds," .").concat(Ds,` {
39
+ margin-right: 0 `).concat(r,`;
40
+ }
41
+
42
+ body[`).concat(Co,`] {
43
+ `).concat("--removed-body-scroll-bar-size",": ").concat(a,`px;
44
+ }
45
+ `)},nf=function(){var e=parseInt(document.body.getAttribute(Co)||"0",10);return isFinite(e)?e:0},Zb=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;m.useEffect((function(){return document.body.setAttribute(Co,(nf()+1).toString()),function(){var s=nf()-1;s<=0?document.body.removeAttribute(Co):document.body.setAttribute(Co,s.toString())}}),[]);var i=m.useMemo((function(){return qb(o)}),[o]);return m.createElement(Gb,{styles:Jb(i,!t,o,n?"":"!important")})},Wu=!1;if(typeof window<"u")try{var is=Object.defineProperty({},"passive",{get:function(){return Wu=!0,!0}});window.addEventListener("test",is,is),window.removeEventListener("test",is,is)}catch{Wu=!1}var to=!!Wu&&{passive:!1},rf=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!(function(r){return r.tagName==="TEXTAREA"})(e)&&n[t]==="visible")},of=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host),ig(e,r)){var o=sg(e,r);if(o[1]>o[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},ig=function(e,t){return e==="v"?(function(n){return rf(n,"overflowY")})(t):(function(n){return rf(n,"overflowX")})(t)},sg=function(e,t){return e==="v"?[(n=t).scrollTop,n.scrollHeight,n.clientHeight]:(function(r){return[r.scrollLeft,r.scrollWidth,r.clientWidth]})(t);var n},ss=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},sf=function(e){return[e.deltaX,e.deltaY]},af=function(e){return e&&"current"in e?e.current:e},Xb=function(e){return`
46
+ .block-interactivity-`.concat(e,` {pointer-events: none;}
47
+ .allow-interactivity-`).concat(e,` {pointer-events: all;}
48
+ `)},Yb=0,no=[];function Qb(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const eC=(uf=function(e){var t=m.useRef([]),n=m.useRef([0,0]),r=m.useRef(),o=m.useState(Yb++)[0],i=m.useState(og)[0],s=m.useRef(e);m.useEffect((function(){s.current=e}),[e]),m.useEffect((function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var y=(function(p,w,b){if(b||arguments.length===2)for(var C,E=0,A=w.length;E<A;E++)!C&&E in w||(C||(C=Array.prototype.slice.call(w,0,E)),C[E]=w[E]);return p.concat(C||Array.prototype.slice.call(w))})([e.lockRef.current],(e.shards||[]).map(af),!0).filter(Boolean);return y.forEach((function(p){return p.classList.add("allow-interactivity-".concat(o))})),function(){document.body.classList.remove("block-interactivity-".concat(o)),y.forEach((function(p){return p.classList.remove("allow-interactivity-".concat(o))}))}}}),[e.inert,e.lockRef.current,e.shards]);var a=m.useCallback((function(y,p){if("touches"in y&&y.touches.length===2||y.type==="wheel"&&y.ctrlKey)return!s.current.allowPinchZoom;var w,b=ss(y),C=n.current,E="deltaX"in y?y.deltaX:C[0]-b[0],A="deltaY"in y?y.deltaY:C[1]-b[1],x=y.target,I=Math.abs(E)>Math.abs(A)?"h":"v";if("touches"in y&&I==="h"&&x.type==="range")return!1;var T=window.getSelection(),B=T&&T.anchorNode;if(B&&(B===x||B.contains(x)))return!1;var S=of(I,x);if(!S)return!0;if(S?w=I:(w=I==="v"?"h":"v",S=of(I,x)),!S)return!1;if(!r.current&&"changedTouches"in y&&(E||A)&&(r.current=w),!w)return!0;var k=r.current||w;return(function(R,M,H,W){var G=(function(K,Y){return K==="h"&&Y==="rtl"?-1:1})(R,window.getComputedStyle(M).direction),q=G*W,$=H.target,V=M.contains($),Q=!1,ae=q>0,ie=0,Se=0;do{if(!$)break;var Ie=sg(R,$),ne=Ie[0],_=Ie[1]-Ie[2]-G*ne;(ne||_)&&ig(R,$)&&(ie+=_,Se+=ne);var X=$.parentNode;$=X&&X.nodeType===Node.DOCUMENT_FRAGMENT_NODE?X.host:X}while(!V&&$!==document.body||V&&(M.contains($)||M===$));return(ae&&Math.abs(ie)<1||!ae&&Math.abs(Se)<1)&&(Q=!0),Q})(k,p,y,k==="h"?E:A)}),[]),u=m.useCallback((function(y){var p=y;if(no.length&&no[no.length-1]===i){var w="deltaY"in p?sf(p):ss(p),b=t.current.filter((function(E){return E.name===p.type&&(E.target===p.target||p.target===E.shadowParent)&&(function(A,x){return A[0]===x[0]&&A[1]===x[1]})(E.delta,w)}))[0];if(b&&b.should)p.cancelable&&p.preventDefault();else if(!b){var C=(s.current.shards||[]).map(af).filter(Boolean).filter((function(E){return E.contains(p.target)}));(C.length>0?a(p,C[0]):!s.current.noIsolation)&&p.cancelable&&p.preventDefault()}}}),[]),c=m.useCallback((function(y,p,w,b){var C={name:y,delta:p,target:w,should:b,shadowParent:Qb(w)};t.current.push(C),setTimeout((function(){t.current=t.current.filter((function(E){return E!==C}))}),1)}),[]),f=m.useCallback((function(y){n.current=ss(y),r.current=void 0}),[]),l=m.useCallback((function(y){c(y.type,sf(y),y.target,a(y,e.lockRef.current))}),[]),d=m.useCallback((function(y){c(y.type,ss(y),y.target,a(y,e.lockRef.current))}),[]);m.useEffect((function(){return no.push(i),e.setCallbacks({onScrollCapture:l,onWheelCapture:l,onTouchMoveCapture:d}),document.addEventListener("wheel",u,to),document.addEventListener("touchmove",u,to),document.addEventListener("touchstart",f,to),function(){no=no.filter((function(y){return y!==i})),document.removeEventListener("wheel",u,to),document.removeEventListener("touchmove",u,to),document.removeEventListener("touchstart",f,to)}}),[]);var h=e.removeScrollBar,g=e.inert;return m.createElement(m.Fragment,null,g?m.createElement(i,{styles:Xb(o)}):null,h?m.createElement(Zb,{noRelative:e.noRelative,gapMode:e.gapMode}):null)},rg.useMedium(uf),ng);var uf,ol=m.forwardRef((function(e,t){return m.createElement(Us,Dn({},e,{ref:t,sideCar:eC}))}));ol.classNames=Us.classNames;var ro=new WeakMap,as=new WeakMap,us={},cf=0,ag=function(e){return e&&(e.host||ag(e.parentNode))},tC=function(e,t,n,r){var o=(function(l,d){return d.map((function(h){if(l.contains(h))return h;var g=ag(h);return g&&l.contains(g)?g:(console.error("aria-hidden",h,"in not contained inside",l,". Doing nothing"),null)})).filter((function(h){return!!h}))})(t,Array.isArray(e)?e:[e]);us[n]||(us[n]=new WeakMap);var i=us[n],s=[],a=new Set,u=new Set(o),c=function(l){l&&!a.has(l)&&(a.add(l),c(l.parentNode))};o.forEach(c);var f=function(l){l&&!u.has(l)&&Array.prototype.forEach.call(l.children,(function(d){if(a.has(d))f(d);else try{var h=d.getAttribute(r),g=h!==null&&h!=="false",y=(ro.get(d)||0)+1,p=(i.get(d)||0)+1;ro.set(d,y),i.set(d,p),s.push(d),y===1&&g&&as.set(d,!0),p===1&&d.setAttribute(n,"true"),g||d.setAttribute(r,"true")}catch(w){console.error("aria-hidden: cannot operate on ",d,w)}}))};return f(t),a.clear(),cf++,function(){s.forEach((function(l){var d=ro.get(l)-1,h=i.get(l)-1;ro.set(l,d),i.set(l,h),d||(as.has(l)||l.removeAttribute(r),as.delete(l)),h||l.removeAttribute(n)})),--cf||(ro=new WeakMap,ro=new WeakMap,as=new WeakMap,us={})}},ug=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=(function(i){return typeof document>"u"?null:(Array.isArray(i)?i[0]:i).ownerDocument.body})(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live]"))),tC(r,o,n,"aria-hidden")):function(){return null}},nC=Object.defineProperty;function cg(e){const[t,n]=m.useState(void 0);return Qt((()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver((o=>{if(!Array.isArray(o)||!o.length)return;const i=o[0];let s,a;if("borderBoxSize"in i){const u=i.borderBoxSize,c=Array.isArray(u)?u[0]:u;s=c.inlineSize,a=c.blockSize}else s=e.offsetWidth,a=e.offsetHeight;n({width:s,height:a})}));return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}n(void 0)}),[e]),t}((e,t)=>{nC(e,"name",{value:t,configurable:!0})})(cg,"useSize");const rC=["top","right","bottom","left"],pn=Math.min,wt=Math.max,Hs=Math.round,cs=Math.floor,An=e=>({x:e,y:e}),oC={left:"right",right:"left",bottom:"top",top:"bottom"},iC={start:"end",end:"start"};function zu(e,t,n){return wt(e,pn(t,n))}function In(e,t){return typeof e=="function"?e(t):e}function ln(e){return e.split("-")[0]}function To(e){return e.split("-")[1]}function il(e){return e==="x"?"y":"x"}function sl(e){return e==="y"?"height":"width"}function Kn(e){return["top","bottom"].includes(ln(e))?"y":"x"}function al(e){return il(Kn(e))}function qa(e){return e.replace(/start|end/g,(t=>iC[t]))}function ls(e){return e.replace(/left|right|bottom|top/g,(t=>oC[t]))}function ul(e){return typeof e!="number"?(function(t){return{top:0,right:0,bottom:0,left:0,...t}})(e):{top:e,right:e,bottom:e,left:e}}function ko(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function lf(e,t,n){let{reference:r,floating:o}=e;const i=Kn(t),s=al(t),a=sl(s),u=ln(t),c=i==="y",f=r.x+r.width/2-o.width/2,l=r.y+r.height/2-o.height/2,d=r[a]/2-o[a]/2;let h;switch(u){case"top":h={x:f,y:r.y-o.height};break;case"bottom":h={x:f,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:l};break;case"left":h={x:r.x-o.width,y:l};break;default:h={x:r.x,y:r.y}}switch(To(t)){case"start":h[s]-=d*(n&&c?-1:1);break;case"end":h[s]+=d*(n&&c?-1:1)}return h}async function Di(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:i,rects:s,elements:a,strategy:u}=e,{boundary:c="clippingAncestors",rootBoundary:f="viewport",elementContext:l="floating",altBoundary:d=!1,padding:h=0}=In(t,e),g=ul(h),y=a[d?l==="floating"?"reference":"floating":l],p=ko(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(y)))==null||n?y:y.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(a.floating)),boundary:c,rootBoundary:f,strategy:u})),w=l==="floating"?{x:r,y:o,width:s.floating.width,height:s.floating.height}:s.reference,b=await(i.getOffsetParent==null?void 0:i.getOffsetParent(a.floating)),C=await(i.isElement==null?void 0:i.isElement(b))&&await(i.getScale==null?void 0:i.getScale(b))||{x:1,y:1},E=ko(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:b,strategy:u}):w);return{top:(p.top-E.top+g.top)/C.y,bottom:(E.bottom-p.bottom+g.bottom)/C.y,left:(p.left-E.left+g.left)/C.x,right:(E.right-p.right+g.right)/C.x}}function df(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function ff(e){return rC.some((t=>e[t]>=0))}function hf(e){const t=pn(...e.map((r=>r.left))),n=pn(...e.map((r=>r.top)));return{x:t,y:n,width:wt(...e.map((r=>r.right)))-t,height:wt(...e.map((r=>r.bottom)))-n}}function sa(){return typeof window<"u"}function _o(e){return lg(e)?(e.nodeName||"").toLowerCase():"#document"}function Ht(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function xn(e){var t;return(t=(lg(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function lg(e){return!!sa()&&(e instanceof Node||e instanceof Ht(e).Node)}function dn(e){return!!sa()&&(e instanceof Element||e instanceof Ht(e).Element)}function Tn(e){return!!sa()&&(e instanceof HTMLElement||e instanceof Ht(e).HTMLElement)}function pf(e){return!(!sa()||typeof ShadowRoot>"u")&&(e instanceof ShadowRoot||e instanceof Ht(e).ShadowRoot)}function Ai(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=fn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(o)}function sC(e){return["table","td","th"].includes(_o(e))}function Vs(e){return[":popover-open",":modal"].some((t=>{try{return e.matches(t)}catch{return!1}}))}function Ku(e){const t=cl(),n=dn(e)?fn(e):e;return["transform","translate","scale","rotate","perspective"].some((r=>!!n[r]&&n[r]!=="none"))||!!n.containerType&&n.containerType!=="normal"||!t&&!!n.backdropFilter&&n.backdropFilter!=="none"||!t&&!!n.filter&&n.filter!=="none"||["transform","translate","scale","rotate","perspective","filter"].some((r=>(n.willChange||"").includes(r)))||["paint","layout","strict","content"].some((r=>(n.contain||"").includes(r)))}function cl(){return!(typeof CSS>"u"||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function wo(e){return["html","body","#document"].includes(_o(e))}function fn(e){return Ht(e).getComputedStyle(e)}function aa(e){return dn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function cr(e){if(_o(e)==="html")return e;const t=e.assignedSlot||e.parentNode||pf(e)&&e.host||xn(e);return pf(t)?t.host:t}function dg(e){const t=cr(e);return wo(t)?e.ownerDocument?e.ownerDocument.body:e.body:Tn(t)&&Ai(t)?t:dg(t)}function xi(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=dg(e),i=o===((r=e.ownerDocument)==null?void 0:r.body),s=Ht(o);if(i){const a=qu(s);return t.concat(s,s.visualViewport||[],Ai(o)?o:[],a&&n?xi(a):[])}return t.concat(o,xi(o,[],n))}function qu(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function fg(e){const t=fn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Tn(e),i=o?e.offsetWidth:n,s=o?e.offsetHeight:r,a=Hs(n)!==i||Hs(r)!==s;return a&&(n=i,r=s),{width:n,height:r,$:a}}function ll(e){return dn(e)?e:e.contextElement}function Eo(e){const t=ll(e);if(!Tn(t))return An(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:i}=fg(t);let s=(i?Hs(n.width):n.width)/r,a=(i?Hs(n.height):n.height)/o;return s&&Number.isFinite(s)||(s=1),a&&Number.isFinite(a)||(a=1),{x:s,y:a}}const aC=An(0);function hg(e){const t=Ht(e);return cl()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:aC}function Wr(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),i=ll(e);let s=An(1);t&&(r?dn(r)&&(s=Eo(r)):s=Eo(e));const a=(function(d,h,g){return h===void 0&&(h=!1),!(!g||h&&g!==Ht(d))&&h})(i,n,r)?hg(i):An(0);let u=(o.left+a.x)/s.x,c=(o.top+a.y)/s.y,f=o.width/s.x,l=o.height/s.y;if(i){const d=Ht(i),h=r&&dn(r)?Ht(r):r;let g=d,y=qu(g);for(;y&&r&&h!==g;){const p=Eo(y),w=y.getBoundingClientRect(),b=fn(y),C=w.left+(y.clientLeft+parseFloat(b.paddingLeft))*p.x,E=w.top+(y.clientTop+parseFloat(b.paddingTop))*p.y;u*=p.x,c*=p.y,f*=p.x,l*=p.y,u+=C,c+=E,g=Ht(y),y=qu(g)}}return ko({width:f,height:l,x:u,y:c})}function dl(e,t){const n=aa(e).scrollLeft;return t?t.left+n:Wr(xn(e)).left+n}function pg(e,t,n){n===void 0&&(n=!1);const r=e.getBoundingClientRect();return{x:r.left+t.scrollLeft-(n?0:dl(e,r)),y:r.top+t.scrollTop}}function mf(e,t,n){let r;if(t==="viewport")r=(function(o,i){const s=Ht(o),a=xn(o),u=s.visualViewport;let c=a.clientWidth,f=a.clientHeight,l=0,d=0;if(u){c=u.width,f=u.height;const h=cl();(!h||h&&i==="fixed")&&(l=u.offsetLeft,d=u.offsetTop)}return{width:c,height:f,x:l,y:d}})(e,n);else if(t==="document")r=(function(o){const i=xn(o),s=aa(o),a=o.ownerDocument.body,u=wt(i.scrollWidth,i.clientWidth,a.scrollWidth,a.clientWidth),c=wt(i.scrollHeight,i.clientHeight,a.scrollHeight,a.clientHeight);let f=-s.scrollLeft+dl(o);const l=-s.scrollTop;return fn(a).direction==="rtl"&&(f+=wt(i.clientWidth,a.clientWidth)-u),{width:u,height:c,x:f,y:l}})(xn(e));else if(dn(t))r=(function(o,i){const s=Wr(o,!0,i==="fixed"),a=s.top+o.clientTop,u=s.left+o.clientLeft,c=Tn(o)?Eo(o):An(1);return{width:o.clientWidth*c.x,height:o.clientHeight*c.y,x:u*c.x,y:a*c.y}})(t,n);else{const o=hg(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return ko(r)}function mg(e,t){const n=cr(e);return!(n===t||!dn(n)||wo(n))&&(fn(n).position==="fixed"||mg(n,t))}function uC(e,t,n){const r=Tn(t),o=xn(t),i=n==="fixed",s=Wr(e,!0,i,t);let a={scrollLeft:0,scrollTop:0};const u=An(0);if(r||!r&&!i)if((_o(t)!=="body"||Ai(o))&&(a=aa(t)),r){const f=Wr(t,!0,i,t);u.x=f.x+t.clientLeft,u.y=f.y+t.clientTop}else o&&(u.x=dl(o));const c=!o||r||i?An(0):pg(o,a);return{x:s.left+a.scrollLeft-u.x-c.x,y:s.top+a.scrollTop-u.y-c.y,width:s.width,height:s.height}}function Ga(e){return fn(e).position==="static"}function gf(e,t){if(!Tn(e)||fn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return xn(e)===n&&(n=n.ownerDocument.body),n}function vf(e,t){const n=Ht(e);if(Vs(e))return n;if(!Tn(e)){let o=cr(e);for(;o&&!wo(o);){if(dn(o)&&!Ga(o))return o;o=cr(o)}return n}let r=gf(e,t);for(;r&&sC(r)&&Ga(r);)r=gf(r,t);return r&&wo(r)&&Ga(r)&&!Ku(r)?n:r||(function(o){let i=cr(o);for(;Tn(i)&&!wo(i);){if(Ku(i))return i;if(Vs(i))return null;i=cr(i)}return null})(e)||n}const cC={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const i=o==="fixed",s=xn(r),a=!!t&&Vs(t.floating);if(r===s||a&&i)return n;let u={scrollLeft:0,scrollTop:0},c=An(1);const f=An(0),l=Tn(r);if((l||!l&&!i)&&((_o(r)!=="body"||Ai(s))&&(u=aa(r)),Tn(r))){const h=Wr(r);c=Eo(r),f.x=h.x+r.clientLeft,f.y=h.y+r.clientTop}const d=!s||l||i?An(0):pg(s,u,!0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-u.scrollLeft*c.x+f.x+d.x,y:n.y*c.y-u.scrollTop*c.y+f.y+d.y}},getDocumentElement:xn,getClippingRect:function(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=n==="clippingAncestors"?Vs(t)?[]:(function(c,f){const l=f.get(c);if(l)return l;let d=xi(c,[],!1).filter((p=>dn(p)&&_o(p)!=="body")),h=null;const g=fn(c).position==="fixed";let y=g?cr(c):c;for(;dn(y)&&!wo(y);){const p=fn(y),w=Ku(y);w||p.position!=="fixed"||(h=null),(g?!w&&!h:!w&&p.position==="static"&&h&&["absolute","fixed"].includes(h.position)||Ai(y)&&!w&&mg(c,y))?d=d.filter((b=>b!==y)):h=p,y=cr(y)}return f.set(c,d),d})(t,this._c):[].concat(n),s=[...i,r],a=s[0],u=s.reduce(((c,f)=>{const l=mf(t,f,o);return c.top=wt(l.top,c.top),c.right=pn(l.right,c.right),c.bottom=pn(l.bottom,c.bottom),c.left=wt(l.left,c.left),c}),mf(t,a,o));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}},getOffsetParent:vf,getElementRects:async function(e){const t=this.getOffsetParent||vf,n=this.getDimensions,r=await n(e.floating);return{reference:uC(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}},getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){const{width:t,height:n}=fg(e);return{width:t,height:n}},getScale:Eo,isElement:dn,isRTL:function(e){return fn(e).direction==="rtl"}};function yf(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function gg(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,c=ll(e),f=o||i?[...c?xi(c):[],...xi(t)]:[];f.forEach((p=>{o&&p.addEventListener("scroll",n,{passive:!0}),i&&p.addEventListener("resize",n)}));const l=c&&a?(function(p,w){let b,C=null;const E=xn(p);function A(){var x;clearTimeout(b),(x=C)==null||x.disconnect(),C=null}return(function x(I,T){I===void 0&&(I=!1),T===void 0&&(T=1),A();const B=p.getBoundingClientRect(),{left:S,top:k,width:R,height:M}=B;if(I||w(),!R||!M)return;const H={rootMargin:-cs(k)+"px "+-cs(E.clientWidth-(S+R))+"px "+-cs(E.clientHeight-(k+M))+"px "+-cs(S)+"px",threshold:wt(0,pn(1,T))||1};let W=!0;function G(q){const $=q[0].intersectionRatio;if($!==T){if(!W)return x();$?x(!1,$):b=setTimeout((()=>{x(!1,1e-7)}),1e3)}$!==1||yf(B,p.getBoundingClientRect())||x(),W=!1}try{C=new IntersectionObserver(G,{...H,root:E.ownerDocument})}catch{C=new IntersectionObserver(G,H)}C.observe(p)})(!0),A})(c,n):null;let d,h=-1,g=null;s&&(g=new ResizeObserver((p=>{let[w]=p;w&&w.target===c&&g&&(g.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame((()=>{var b;(b=g)==null||b.observe(t)}))),n()})),c&&!u&&g.observe(c),g.observe(t));let y=u?Wr(e):null;return u&&(function p(){const w=Wr(e);y&&!yf(y,w)&&n(),y=w,d=requestAnimationFrame(p)})(),n(),()=>{var p;f.forEach((w=>{o&&w.removeEventListener("scroll",n),i&&w.removeEventListener("resize",n)})),l?.(),(p=g)==null||p.disconnect(),g=null,u&&cancelAnimationFrame(d)}}const lC=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:i,placement:s,middlewareData:a}=t,u=await(async function(c,f){const{placement:l,platform:d,elements:h}=c,g=await(d.isRTL==null?void 0:d.isRTL(h.floating)),y=ln(l),p=To(l),w=Kn(l)==="y",b=["left","top"].includes(y)?-1:1,C=g&&w?-1:1,E=In(f,c);let{mainAxis:A,crossAxis:x,alignmentAxis:I}=typeof E=="number"?{mainAxis:E,crossAxis:0,alignmentAxis:null}:{mainAxis:E.mainAxis||0,crossAxis:E.crossAxis||0,alignmentAxis:E.alignmentAxis};return p&&typeof I=="number"&&(x=p==="end"?-1*I:I),w?{x:x*C,y:A*b}:{x:A*b,y:x*C}})(t,e);return s===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+u.x,y:i+u.y,data:{...u,placement:s}}}}},dC=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:i=!0,crossAxis:s=!1,limiter:a={fn:p=>{let{x:w,y:b}=p;return{x:w,y:b}}},...u}=In(e,t),c={x:n,y:r},f=await Di(t,u),l=Kn(ln(o)),d=il(l);let h=c[d],g=c[l];if(i){const p=d==="y"?"bottom":"right";h=zu(h+f[d==="y"?"top":"left"],h,h-f[p])}if(s){const p=l==="y"?"bottom":"right";g=zu(g+f[l==="y"?"top":"left"],g,g-f[p])}const y=a.fn({...t,[d]:h,[l]:g});return{...y,data:{x:y.x-n,y:y.y-r,enabled:{[d]:i,[l]:s}}}}}},fC=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:i,rects:s,initialPlacement:a,platform:u,elements:c}=t,{mainAxis:f=!0,crossAxis:l=!0,fallbackPlacements:d,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:y=!0,...p}=In(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const w=ln(o),b=Kn(a),C=ln(a)===a,E=await(u.isRTL==null?void 0:u.isRTL(c.floating)),A=d||(C||!y?[ls(a)]:(function(H){const W=ls(H);return[qa(H),W,qa(W)]})(a)),x=g!=="none";!d&&x&&A.push(...(function(H,W,G,q){const $=To(H);let V=(function(Q,ae,ie){const Se=["left","right"],Ie=["right","left"],ne=["top","bottom"],_=["bottom","top"];switch(Q){case"top":case"bottom":return ie?ae?Ie:Se:ae?Se:Ie;case"left":case"right":return ae?ne:_;default:return[]}})(ln(H),G==="start",q);return $&&(V=V.map((Q=>Q+"-"+$)),W&&(V=V.concat(V.map(qa)))),V})(a,y,g,E));const I=[a,...A],T=await Di(t,p),B=[];let S=((r=i.flip)==null?void 0:r.overflows)||[];if(f&&B.push(T[w]),l){const H=(function(W,G,q){q===void 0&&(q=!1);const $=To(W),V=al(W),Q=sl(V);let ae=V==="x"?$===(q?"end":"start")?"right":"left":$==="start"?"bottom":"top";return G.reference[Q]>G.floating[Q]&&(ae=ls(ae)),[ae,ls(ae)]})(o,s,E);B.push(T[H[0]],T[H[1]])}if(S=[...S,{placement:o,overflows:B}],!B.every((H=>H<=0))){var k,R;const H=(((k=i.flip)==null?void 0:k.index)||0)+1,W=I[H];if(W)return{data:{index:H,overflows:S},reset:{placement:W}};let G=(R=S.filter((q=>q.overflows[0]<=0)).sort(((q,$)=>q.overflows[1]-$.overflows[1]))[0])==null?void 0:R.placement;if(!G)switch(h){case"bestFit":{var M;const q=(M=S.filter(($=>{if(x){const V=Kn($.placement);return V===b||V==="y"}return!0})).map(($=>[$.placement,$.overflows.filter((V=>V>0)).reduce(((V,Q)=>V+Q),0)])).sort((($,V)=>$[1]-V[1]))[0])==null?void 0:M[0];q&&(G=q);break}case"initialPlacement":G=a}if(o!==G)return{reset:{placement:G}}}return{}}}},hC=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:i,platform:s,elements:a}=t,{apply:u=()=>{},...c}=In(e,t),f=await Di(t,c),l=ln(o),d=To(o),h=Kn(o)==="y",{width:g,height:y}=i.floating;let p,w;l==="top"||l==="bottom"?(p=l,w=d===(await(s.isRTL==null?void 0:s.isRTL(a.floating))?"start":"end")?"left":"right"):(w=l,p=d==="end"?"top":"bottom");const b=y-f.top-f.bottom,C=g-f.left-f.right,E=pn(y-f[p],b),A=pn(g-f[w],C),x=!t.middlewareData.shift;let I=E,T=A;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(T=C),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(I=b),x&&!d){const S=wt(f.left,0),k=wt(f.right,0),R=wt(f.top,0),M=wt(f.bottom,0);h?T=g-2*(S!==0||k!==0?S+k:wt(f.left,f.right)):I=y-2*(R!==0||M!==0?R+M:wt(f.top,f.bottom))}await u({...t,availableWidth:T,availableHeight:I});const B=await s.getDimensions(a.floating);return g!==B.width||y!==B.height?{reset:{rects:!0}}:{}}}},pC=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=In(e,t);switch(r){case"referenceHidden":{const i=df(await Di(t,{...o,elementContext:"reference"}),n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:ff(i)}}}case"escaped":{const i=df(await Di(t,{...o,altBoundary:!0}),n.floating);return{data:{escapedOffsets:i,escaped:ff(i)}}}default:return{}}}}},bf=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:i,platform:s,elements:a,middlewareData:u}=t,{element:c,padding:f=0}=In(e,t)||{};if(c==null)return{};const l=ul(f),d={x:n,y:r},h=al(o),g=sl(h),y=await s.getDimensions(c),p=h==="y",w=p?"top":"left",b=p?"bottom":"right",C=p?"clientHeight":"clientWidth",E=i.reference[g]+i.reference[h]-d[h]-i.floating[g],A=d[h]-i.reference[h],x=await(s.getOffsetParent==null?void 0:s.getOffsetParent(c));let I=x?x[C]:0;I&&await(s.isElement==null?void 0:s.isElement(x))||(I=a.floating[C]||i.floating[g]);const T=E/2-A/2,B=I/2-y[g]/2-1,S=pn(l[w],B),k=pn(l[b],B),R=S,M=I-y[g]-k,H=I/2-y[g]/2+T,W=zu(R,H,M),G=!u.arrow&&To(o)!=null&&H!==W&&i.reference[g]/2-(H<R?S:k)-y[g]/2<0,q=G?H<R?H-R:H-M:0;return{[h]:d[h]+q,data:{[h]:W,centerOffset:H-W-q,...G&&{alignmentOffset:q}},reset:G}}}),mC=function(e){return e===void 0&&(e={}),{name:"inline",options:e,async fn(t){const{placement:n,elements:r,rects:o,platform:i,strategy:s}=t,{padding:a=2,x:u,y:c}=In(e,t),f=Array.from(await(i.getClientRects==null?void 0:i.getClientRects(r.reference))||[]),l=(function(y){const p=y.slice().sort(((C,E)=>C.y-E.y)),w=[];let b=null;for(let C=0;C<p.length;C++){const E=p[C];!b||E.y-b.y>b.height/2?w.push([E]):w[w.length-1].push(E),b=E}return w.map((C=>ko(hf(C))))})(f),d=ko(hf(f)),h=ul(a),g=await i.getElementRects({reference:{getBoundingClientRect:function(){if(l.length===2&&l[0].left>l[1].right&&u!=null&&c!=null)return l.find((y=>u>y.left-h.left&&u<y.right+h.right&&c>y.top-h.top&&c<y.bottom+h.bottom))||d;if(l.length>=2){if(Kn(n)==="y"){const A=l[0],x=l[l.length-1],I=ln(n)==="top",T=A.top,B=x.bottom,S=I?A.left:x.left,k=I?A.right:x.right;return{top:T,bottom:B,left:S,right:k,width:k-S,height:B-T,x:S,y:T}}const y=ln(n)==="left",p=wt(...l.map((A=>A.right))),w=pn(...l.map((A=>A.left))),b=l.filter((A=>y?A.left===w:A.right===p)),C=b[0].top,E=b[b.length-1].bottom;return{top:C,bottom:E,left:w,right:p,width:p-w,height:E-C,x:w,y:C}}return d}},floating:r.floating,strategy:s});return o.reference.x!==g.reference.x||o.reference.y!==g.reference.y||o.reference.width!==g.reference.width||o.reference.height!==g.reference.height?{reset:{rects:g}}:{}}}},gC=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:i,middlewareData:s}=t,{offset:a=0,mainAxis:u=!0,crossAxis:c=!0}=In(e,t),f={x:n,y:r},l=Kn(o),d=il(l);let h=f[d],g=f[l];const y=In(a,t),p=typeof y=="number"?{mainAxis:y,crossAxis:0}:{mainAxis:0,crossAxis:0,...y};if(u){const C=d==="y"?"height":"width",E=i.reference[d]-i.floating[C]+p.mainAxis,A=i.reference[d]+i.reference[C]-p.mainAxis;h<E?h=E:h>A&&(h=A)}if(c){var w,b;const C=d==="y"?"width":"height",E=["top","left"].includes(ln(o)),A=i.reference[l]-i.floating[C]+(E&&((w=s.offset)==null?void 0:w[l])||0)+(E?0:p.crossAxis),x=i.reference[l]+i.reference[C]+(E?0:((b=s.offset)==null?void 0:b[l])||0)-(E?p.crossAxis:0);g<A?g=A:g>x&&(g=x)}return{[d]:h,[l]:g}}}},vC=(e,t,n)=>{const r=new Map,o={platform:cC,...n},i={...o.platform,_c:r};return(async(s,a,u)=>{const{placement:c="bottom",strategy:f="absolute",middleware:l=[],platform:d}=u,h=l.filter(Boolean),g=await(d.isRTL==null?void 0:d.isRTL(a));let y=await d.getElementRects({reference:s,floating:a,strategy:f}),{x:p,y:w}=lf(y,c,g),b=c,C={},E=0;for(let A=0;A<h.length;A++){const{name:x,fn:I}=h[A],{x:T,y:B,data:S,reset:k}=await I({x:p,y:w,initialPlacement:c,placement:b,strategy:f,middlewareData:C,rects:y,platform:d,elements:{reference:s,floating:a}});p=T??p,w=B??w,C={...C,[x]:{...C[x],...S}},k&&E<=50&&(E++,typeof k=="object"&&(k.placement&&(b=k.placement),k.rects&&(y=k.rects===!0?await d.getElementRects({reference:s,floating:a,strategy:f}):k.rects),{x:p,y:w}=lf(y,b,g)),A=-1)}return{x:p,y:w,placement:b,strategy:f,middlewareData:C}})(e,t,{...o,platform:i})};var As=typeof document<"u"?m.useLayoutEffect:m.useEffect;function $s(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!=0;)if(!$s(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!=0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!=0;){const i=o[r];if((i!=="_owner"||!e.$$typeof)&&!$s(e[i],t[i]))return!1}return!0}return e!=e&&t!=t}function vg(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Cf(e,t){const n=vg(e);return Math.round(t*n)/n}function Ja(e){const t=m.useRef(e);return As((()=>{t.current=e})),t}function yg(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:i,floating:s}={},transform:a=!0,whileElementsMounted:u,open:c}=e,[f,l]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[d,h]=m.useState(r);$s(d,r)||h(r);const[g,y]=m.useState(null),[p,w]=m.useState(null),b=m.useCallback(($=>{$!==x.current&&(x.current=$,y($))}),[]),C=m.useCallback(($=>{$!==I.current&&(I.current=$,w($))}),[]),E=i||g,A=s||p,x=m.useRef(null),I=m.useRef(null),T=m.useRef(f),B=u!=null,S=Ja(u),k=Ja(o),R=Ja(c),M=m.useCallback((()=>{if(!x.current||!I.current)return;const $={placement:t,strategy:n,middleware:d};k.current&&($.platform=k.current),vC(x.current,I.current,$).then((V=>{const Q={...V,isPositioned:R.current!==!1};H.current&&!$s(T.current,Q)&&(T.current=Q,Mi.flushSync((()=>{l(Q)})))}))}),[d,t,n,k,R]);As((()=>{c===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,l(($=>({...$,isPositioned:!1}))))}),[c]);const H=m.useRef(!1);As((()=>(H.current=!0,()=>{H.current=!1})),[]),As((()=>{if(E&&(x.current=E),A&&(I.current=A),E&&A){if(S.current)return S.current(E,A,M);M()}}),[E,A,M,S,B]);const W=m.useMemo((()=>({reference:x,floating:I,setReference:b,setFloating:C})),[b,C]),G=m.useMemo((()=>({reference:E,floating:A})),[E,A]),q=m.useMemo((()=>{const $={position:n,left:0,top:0};if(!G.floating)return $;const V=Cf(G.floating,f.x),Q=Cf(G.floating,f.y);return a?{...$,transform:"translate("+V+"px, "+Q+"px)",...vg(G.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:V,top:Q}}),[n,a,G.floating,f.x,f.y]);return m.useMemo((()=>({...f,update:M,refs:W,elements:G,floatingStyles:q})),[f,M,W,G,q])}const yC=e=>({name:"arrow",options:e,fn(t){const{element:n,padding:r}=typeof e=="function"?e(t):e;return n&&(function(o){return{}.hasOwnProperty.call(o,"current")})(n)?n.current!=null?bf({element:n.current,padding:r}).fn(t):{}:n?bf({element:n,padding:r}).fn(t):{}}}),bg=(e,t)=>({...lC(e),options:[e,t]}),Cg=(e,t)=>({...dC(e),options:[e,t]}),wg=(e,t)=>({...gC(e),options:[e,t]}),Eg=(e,t)=>({...fC(e),options:[e,t]}),Dg=(e,t)=>({...hC(e),options:[e,t]}),Ag=(e,t)=>({...pC(e),options:[e,t]}),bC=(e,t)=>({...mC(e),options:[e,t]}),CC=(e,t)=>({...yC(e),options:[e,t]});var wC=Object.defineProperty,hr=(e,t)=>wC(e,"name",{value:t,configurable:!0}),xg="Popper",[Og,zo]=Jn(xg),[EC,Sg]=Og(xg),DC=hr((e=>{const{__scopePopper:t,children:n}=e,[r,o]=m.useState(null),[i,s]=m.useState(void 0);return v.jsx(EC,{scope:t,anchor:r,onAnchorChange:o,placementState:i,setPlacementState:s,children:n})}),"Popper"),AC=m.forwardRef(hr((function(e,t){const{__scopePopper:n,virtualRef:r,...o}=e,i=Sg("PopperAnchor",n),s=m.useRef(null),a=i.onAnchorChange,u=m.useCallback((g=>{s.current=g,g&&a(g)}),[a]),c=Qe(t,u),f=m.useRef(null);m.useEffect((()=>{if(!r)return;const g=f.current;f.current=r.current,g!==f.current&&a(f.current)}));const l=i.placementState&&ua(i.placementState),d=l?.[0],h=l?.[1];return r?null:v.jsx(Wt.div,{"data-radix-popper-side":d,"data-radix-popper-align":h,...o,ref:c})}),"PopperAnchor")),Ig="PopperContent",[xC,C5]=Og(Ig),OC=m.forwardRef(hr((function(e,t){const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:i="center",alignOffset:s=0,arrowPadding:a=0,avoidCollisions:u=!0,collisionBoundary:c=[],collisionPadding:f=0,sticky:l="partial",hideWhenDetached:d=!1,updatePositionStrategy:h="optimized",onPlaced:g,...y}=e,p=Sg(Ig,n),[w,b]=m.useState(null),C=Qe(t,b),[E,A]=m.useState(null),x=cg(E),I=x?.width??0,T=x?.height??0,B=r+(i!=="center"?"-"+i:""),S=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},k=Array.isArray(c)?c:[c],R=k.length>0,M={padding:S,boundary:k.filter(Tg),altBoundary:R},{refs:H,floatingStyles:W,placement:G,isPositioned:q,middlewareData:$}=yg({strategy:"fixed",placement:B,whileElementsMounted:hr(((...K)=>gg(...K,{animationFrame:h==="always"})),"whileElementsMounted"),elements:{reference:p.anchor},middleware:[bg({mainAxis:o+T,alignmentAxis:s}),u&&Cg({mainAxis:!0,crossAxis:!1,limiter:l==="partial"?wg():void 0,...M}),u&&Eg({...M}),Dg({...M,apply:hr((({elements:K,rects:Y,availableWidth:de,availableHeight:pe})=>{const{width:fe,height:we}=Y.reference,Ce=K.floating.style;Ce.setProperty("--radix-popper-available-width",`${de}px`),Ce.setProperty("--radix-popper-available-height",`${pe}px`),Ce.setProperty("--radix-popper-anchor-width",`${fe}px`),Ce.setProperty("--radix-popper-anchor-height",`${we}px`)}),"apply")}),E&&CC({element:E,padding:a}),SC({arrowWidth:I,arrowHeight:T}),d&&Ag({strategy:"referenceHidden",...M,boundary:R?M.boundary:void 0})]}),V=p.setPlacementState;Qt((()=>(V(G),()=>{V(void 0)})),[G,V]);const[Q,ae]=ua(G),ie=zn(g);Qt((()=>{q&&ie?.()}),[q,ie]);const Se=$.arrow?.x,Ie=$.arrow?.y,ne=$.arrow?.centerOffset!==0,[_,X]=m.useState();return Qt((()=>{w&&X(window.getComputedStyle(w).zIndex)}),[w]),v.jsx("div",{ref:H.setFloating,"data-radix-popper-content-wrapper":"",style:{...W,transform:q?W.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:_,"--radix-popper-transform-origin":[$.transformOrigin?.x,$.transformOrigin?.y].join(" "),...$.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:v.jsx(xC,{scope:n,placedSide:Q,placedAlign:ae,onArrowChange:A,arrowX:Se,arrowY:Ie,shouldHideArrow:ne,children:v.jsx(Wt.div,{"data-side":Q,"data-align":ae,...y,ref:C,style:{...y.style,animation:q?y.style?.animation:"none"}})})})}),"PopperContent"));function Tg(e){return e!==null}hr(Tg,"isNotNull");var SC=hr((e=>({name:"transformOrigin",options:e,fn(t){const{placement:n,rects:r,middlewareData:o}=t,i=o.arrow?.centerOffset!==0,s=i?0:e.arrowWidth,a=i?0:e.arrowHeight,[u,c]=ua(n),f={start:"0%",center:"50%",end:"100%"}[c],l=(o.arrow?.x??0)+s/2,d=(o.arrow?.y??0)+a/2;let h="",g="";return u==="bottom"?(h=i?f:`${l}px`,g=-a+"px"):u==="top"?(h=i?f:`${l}px`,g=`${r.floating.height+a}px`):u==="right"?(h=-a+"px",g=i?f:`${d}px`):u==="left"&&(h=`${r.floating.width+a}px`,g=i?f:`${d}px`),{data:{x:h,y:g}}}})),"transformOrigin");function ua(e){const[t,n="center"]=e.split("-");return[t,n]}hr(ua,"getSideAndAlignFromPlacement");var fl=DC,hl=AC,pl=OC,IC=Object.defineProperty,Gu=(e,t)=>IC(e,"name",{value:t,configurable:!0}),Za=!1;function kg(){const[e,t]=m.useState(Za);return m.useEffect((()=>{Za||(Za=!0,t(!0))}),[]),e}Gu(kg,"useIsHydrated");var _g=No[" useSyncExternalStore ".trim().toString()];function Bg(){return()=>{}}function Fg(){return _g(Bg,(()=>!0),(()=>!1))}Gu(Bg,"subscribe"),Gu(Fg,"useIsHydratedModern");var TC=typeof _g=="function"?Fg:kg,kC=Object.defineProperty,jr=(e,t)=>kC(e,"name",{value:t,configurable:!0}),Xa="rovingFocusGroup.onEntryFocus",_C={bubbles:!1,cancelable:!0},ca="RovingFocusGroup",[Ju,Rg,BC]=Xc(ca),[FC,jg]=Jn(ca,[BC]),[RC,jC]=FC(ca),MC=m.forwardRef(jr((function(e,t){return v.jsx(Ju.Provider,{scope:e.__scopeRovingFocusGroup,children:v.jsx(Ju.Slot,{scope:e.__scopeRovingFocusGroup,children:v.jsx(PC,{...e,ref:t})})})}),"RovingFocusGroup")),PC=m.forwardRef(jr((function(e,t){const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:i,currentTabStopId:s,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:u,onEntryFocus:c,preventScrollOnEntryFocus:f=!1,...l}=e,d=m.useRef(null),h=Qe(t,d),g=Qc(i),[y,p]=$o({prop:s,defaultProp:a??null,onChange:u,caller:ca}),[w,b]=m.useState(!1),C=zn(c),E=Rg(n),A=m.useRef(!1),[x,I]=m.useState(0);return m.useEffect((()=>{const T=d.current;if(T)return T.addEventListener(Xa,C),()=>T.removeEventListener(Xa,C)}),[C]),v.jsx(RC,{scope:n,orientation:r,dir:g,loop:o,currentTabStopId:y,onItemFocus:m.useCallback((T=>p(T)),[p]),onItemShiftTab:m.useCallback((()=>b(!0)),[]),onFocusableItemAdd:m.useCallback((()=>I((T=>T+1))),[]),onFocusableItemRemove:m.useCallback((()=>I((T=>T-1))),[]),children:v.jsx(Wt.div,{tabIndex:w||x===0?-1:0,"data-orientation":r,...l,ref:h,style:{outline:"none",...e.style},onMouseDown:Me(e.onMouseDown,(()=>{A.current=!0})),onFocus:Me(e.onFocus,(T=>{const B=!A.current;if(T.target===T.currentTarget&&B&&!w){const S=new CustomEvent(Xa,_C);if(T.currentTarget.dispatchEvent(S),!S.defaultPrevented){const k=E().filter((R=>R.focusable));ml([k.find((R=>R.active)),k.find((R=>R.id===y)),...k].filter(Boolean).map((R=>R.ref.current)),f)}}A.current=!1})),onBlur:Me(e.onBlur,(()=>b(!1)))})})}),"RovingFocusGroupImpl")),NC=m.forwardRef(jr((function(e,t){const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:i,children:s,...a}=e,u=Io(),c=i||u,f=jC("RovingFocusGroupItem",n),l=f.currentTabStopId===c,d=Rg(n),{onFocusableItemAdd:h,onFocusableItemRemove:g,currentTabStopId:y}=f,p=TC();return Qt((()=>{if(p&&r)return h(),()=>g()}),[p,r,h,g]),m.useEffect((()=>{if(!p&&r)return h(),()=>g()}),[p,r,h,g]),v.jsx(Ju.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:v.jsx(Wt.span,{tabIndex:l?0:-1,"data-orientation":f.orientation,...a,ref:t,onMouseDown:Me(e.onMouseDown,(w=>{r?f.onItemFocus(c):w.preventDefault()})),onFocus:Me(e.onFocus,(()=>f.onItemFocus(c))),onKeyDown:Me(e.onKeyDown,(w=>{if(w.key==="Tab"&&w.shiftKey)return void f.onItemShiftTab();if(w.target!==w.currentTarget)return;const b=Pg(w,f.orientation,f.dir);if(b!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let C=d().filter((E=>E.focusable)).map((E=>E.ref.current));if(b==="last")C.reverse();else if(b==="prev"||b==="next"){b==="prev"&&C.reverse();const E=C.indexOf(w.currentTarget);C=f.loop?Ng(C,E+1):C.slice(E+1)}setTimeout((()=>ml(C)))}})),children:typeof s=="function"?s({isCurrentTabStop:l,hasTabStop:y!=null}):s})})}),"RovingFocusGroupItem")),LC={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Mg(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Pg(e,t,n){const r=Mg(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r)||t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return LC[r]}function ml(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Ng(e,t){return e.map(((n,r)=>e[(t+r)%e.length]))}jr(Mg,"getDirectionAwareKey"),jr(Pg,"getFocusIntent"),jr(ml,"focusFirst"),jr(Ng,"wrapArray");var UC=MC,HC=NC,VC=Object.defineProperty,Ke=(e,t)=>VC(e,"name",{value:t,configurable:!0}),$C=["Enter"," "],Lg=["ArrowUp","PageDown","End"],WC=["ArrowDown","PageUp","Home",...Lg],la="Menu",[Zu,zC,KC]=Xc(la),[Jr,Ug]=Jn(la,[KC,zo,jg]),gl=zo(),Hg=jg(),[qC,Li]=Jr(la),[GC,vl]=Jr(la),JC=Ke((e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:i,modal:s=!0}=e,a=gl(t),[u,c]=m.useState(null),f=m.useRef(!1),l=zn(i),d=Qc(o);return m.useEffect((()=>{const h=Ke((()=>{f.current=!0,document.addEventListener("pointerdown",g,{capture:!0,once:!0}),document.addEventListener("pointermove",g,{capture:!0,once:!0})}),"handleKeyDown"),g=Ke((()=>f.current=!1),"handlePointer");return document.addEventListener("keydown",h,{capture:!0}),()=>{document.removeEventListener("keydown",h,{capture:!0}),document.removeEventListener("pointerdown",g,{capture:!0}),document.removeEventListener("pointermove",g,{capture:!0})}}),[]),m.useEffect((()=>{if(!n)return;const h=Ke((()=>l(!1)),"handleBlur");return window.addEventListener("blur",h),()=>window.removeEventListener("blur",h)}),[n,l]),v.jsx(fl,{...a,children:v.jsx(qC,{scope:t,open:n,onOpenChange:l,content:u,onContentChange:c,children:v.jsx(GC,{scope:t,onClose:m.useCallback((()=>l(!1)),[l]),isUsingKeyboardRef:f,dir:d,modal:s,children:r})})})}),"Menu"),ZC=m.forwardRef(Ke((function(e,t){const{__scopeMenu:n,...r}=e,o=gl(n);return v.jsx(hl,{...o,...r,ref:t})}),"MenuAnchor")),Vg="MenuPortal",[XC,YC]=Jr(Vg,{forceMount:void 0}),QC=Ke((e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,i=Li(Vg,t);return v.jsx(XC,{scope:t,forceMount:n,children:v.jsx(Wo,{present:n||i.open,children:v.jsx(rl,{asChild:!0,container:o,children:r})})})}),"MenuPortal"),pr="MenuContent",[ew,$g]=Jr(pr),tw=m.forwardRef(Ke((function(e,t){const n=YC(pr,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,i=Li(pr,e.__scopeMenu),s=vl(pr,e.__scopeMenu);return v.jsx(Zu.Provider,{scope:e.__scopeMenu,children:v.jsx(Wo,{present:r||i.open,children:v.jsx(Zu.Slot,{scope:e.__scopeMenu,children:s.modal?v.jsx(nw,{...o,ref:t}):v.jsx(rw,{...o,ref:t})})})})}),"MenuContent")),nw=m.forwardRef(Ke((function(e,t){const n=Li(pr,e.__scopeMenu),r=m.useRef(null),o=Qe(t,r);return m.useEffect((()=>{const i=r.current;if(i)return ug(i)}),[]),v.jsx(Wg,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Me(e.onFocusOutside,(i=>i.preventDefault()),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),"MenuRootContentModal")),rw=m.forwardRef(Ke((function(e,t){const n=Li(pr,e.__scopeMenu);return v.jsx(Wg,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),"MenuRootContentNonModal")),ow=Wn("MenuContent.ScrollLock"),Wg=m.forwardRef(Ke((function(e,t){const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:i,onCloseAutoFocus:s,disableOutsidePointerEvents:a,onEntryFocus:u,onEscapeKeyDown:c,onPointerDownOutside:f,onFocusOutside:l,onInteractOutside:d,onDismiss:h,disableOutsideScroll:g,...y}=e,p=Li(pr,n),w=vl(pr,n),b=gl(n),C=Hg(n),E=zC(n),[A,x]=m.useState(null),I=m.useRef(null),T=Qe(t,I,p.onContentChange),B=m.useRef(0),S=m.useRef(""),k=m.useRef(0),R=m.useRef(null),M=m.useRef("right"),H=m.useRef(0),W=g?ol:m.Fragment,G=g?{as:ow,allowPinchZoom:!0}:void 0,q=Ke((V=>{const Q=S.current+V,ae=E().filter((_=>!_.disabled)),ie=document.activeElement,Se=ae.find((_=>_.ref.current===ie))?.textValue,Ie=Gg(ae.map((_=>_.textValue)),Q,Se),ne=ae.find((_=>_.textValue===Ie))?.ref.current;Ke((function _(X){S.current=X,window.clearTimeout(B.current),X!==""&&(B.current=window.setTimeout((()=>_("")),1e3))}),"updateSearch")(Q),ne&&setTimeout((()=>ne.focus()))}),"handleTypeaheadSearch");m.useEffect((()=>()=>window.clearTimeout(B.current)),[]),Ls();const $=m.useCallback((V=>M.current===R.current?.side&&Zg(V,R.current?.area)),[]);return v.jsx(ew,{scope:n,searchRef:S,onItemEnter:m.useCallback((V=>{$(V)&&V.preventDefault()}),[$]),onItemLeave:m.useCallback((V=>{$(V)||(I.current?.focus(),x(null))}),[$]),onTriggerLeave:m.useCallback((V=>{$(V)&&V.preventDefault()}),[$]),pointerGraceTimerRef:k,onPointerGraceIntentChange:m.useCallback((V=>{R.current=V}),[]),children:v.jsx(W,{...G,children:v.jsx(Gm,{asChild:!0,trapped:o,onMountAutoFocus:Me(i,(V=>{V.preventDefault(),I.current?.focus({preventScroll:!0})})),onUnmountAutoFocus:s,children:v.jsx(el,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:f,onFocusOutside:l,onInteractOutside:d,onDismiss:h,children:v.jsx(UC,{asChild:!0,...C,dir:w.dir,orientation:"vertical",loop:r,currentTabStopId:A,onCurrentTabStopIdChange:x,onEntryFocus:Me(u,(V=>{w.isUsingKeyboardRef.current||V.preventDefault()})),preventScrollOnEntryFocus:!0,children:v.jsx(pl,{role:"menu","aria-orientation":"vertical","data-state":zg(p.open),"data-radix-menu-content":"",dir:w.dir,...b,...y,ref:T,style:{outline:"none",...y.style},onKeyDown:Me(y.onKeyDown,(V=>{const Q=V.target.closest("[data-radix-menu-content]")===V.currentTarget,ae=V.ctrlKey||V.altKey||V.metaKey,ie=V.key.length===1;Q&&(V.key==="Tab"&&V.preventDefault(),!ae&&ie&&q(V.key));const Se=I.current;if(V.target!==Se||!WC.includes(V.key))return;V.preventDefault();const Ie=E().filter((ne=>!ne.disabled)).map((ne=>ne.ref.current));Lg.includes(V.key)&&Ie.reverse(),Kg(Ie)})),onBlur:Me(e.onBlur,(V=>{V.currentTarget.contains(V.target)||(window.clearTimeout(B.current),S.current="")})),onPointerMove:Me(e.onPointerMove,Ws((V=>{const Q=V.target,ae=H.current!==V.clientX;if(V.currentTarget.contains(Q)&&ae){const ie=V.clientX>H.current?"right":"left";M.current=ie,H.current=V.clientX}})))})})})})})})}),"MenuContentImpl")),Xu="MenuItem",wf="menu.itemSelect",iw=m.forwardRef(Ke((function(e,t){const{disabled:n=!1,onSelect:r,...o}=e,i=m.useRef(null),s=vl(Xu,e.__scopeMenu),a=$g(Xu,e.__scopeMenu),u=Qe(t,i),c=m.useRef(!1),f=Ke((()=>{const l=i.current;if(!n&&l){const d=new CustomEvent(wf,{bubbles:!0,cancelable:!0});l.addEventListener(wf,(h=>r?.(h)),{once:!0}),Zc(l,d),d.defaultPrevented?c.current=!1:s.onClose()}}),"handleSelect");return v.jsx(sw,{...o,ref:u,disabled:n,onClick:Me(e.onClick,f),onPointerDown:l=>{e.onPointerDown?.(l),c.current=!0},onPointerUp:Me(e.onPointerUp,(l=>{c.current||l.currentTarget?.click()})),onKeyDown:Me(e.onKeyDown,(l=>{n||l.target!==l.currentTarget||a.searchRef.current!==""&&l.key===" "||$C.includes(l.key)&&(l.currentTarget.click(),l.preventDefault())}))})}),"MenuItem")),sw=m.forwardRef(Ke((function(e,t){const{__scopeMenu:n,disabled:r=!1,textValue:o,...i}=e,s=$g(Xu,n),a=Hg(n),u=m.useRef(null),c=Qe(t,u),[f,l]=m.useState(!1),[d,h]=m.useState("");return m.useEffect((()=>{const g=u.current;g&&h((g.textContent??"").trim())}),[i.children]),v.jsx(Zu.ItemSlot,{scope:n,disabled:r,textValue:o??d,children:v.jsx(HC,{asChild:!0,...a,focusable:!r,children:v.jsx(Wt.div,{role:"menuitem","data-highlighted":f?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...i,ref:c,onPointerMove:Me(e.onPointerMove,Ws((g=>{r?s.onItemLeave(g):(s.onItemEnter(g),!g.defaultPrevented&&g.currentTarget.focus({preventScroll:!0}))}))),onPointerLeave:Me(e.onPointerLeave,Ws((g=>s.onItemLeave(g)))),onFocus:Me(e.onFocus,(()=>l(!0))),onBlur:Me(e.onBlur,(()=>l(!1)))})})})}),"MenuItemImpl")),[w5,E5]=Jr("MenuRadioGroup",{value:void 0,onValueChange:Ke((()=>{}),"onValueChange")}),[D5,A5]=Jr("MenuItemIndicator",{checked:!1}),[x5,O5]=Jr("MenuSub");function zg(e){return e?"open":"closed"}function Ef(e){return e==="indeterminate"}function Kg(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function qg(e,t){return e.map(((n,r)=>e[(t+r)%e.length]))}function Gg(e,t,n){const r=t.length>1&&Array.from(t).every((a=>a===t[0]))?t[0]:t,o=n?e.indexOf(n):-1;let i=qg(e,Math.max(o,0));r.length===1&&(i=i.filter((a=>a!==n)));const s=i.find((a=>a.toLowerCase().startsWith(r.toLowerCase())));return s!==n?s:void 0}function Jg(e,t){const{x:n,y:r}=e;let o=!1;for(let i=0,s=t.length-1;i<t.length;s=i++){const a=t[i],u=t[s],c=a.x,f=a.y,l=u.x,d=u.y;f>r!=d>r&&n<(l-c)*(r-f)/(d-f)+c&&(o=!o)}return o}function Zg(e,t){return t?Jg({x:e.clientX,y:e.clientY},t):!1}function Ws(e){return t=>t.pointerType==="mouse"?e(t):void 0}Ke(zg,"getOpenState"),Ke(Ef,"isIndeterminate"),Ke((function(e){return Ef(e)?"indeterminate":e?"checked":"unchecked"}),"getCheckedState"),Ke(Kg,"focusFirst"),Ke(qg,"wrapArray"),Ke(Gg,"getNextMatch"),Ke(Jg,"isPointInPolygon"),Ke(Zg,"isPointerInGraceArea"),Ke(Ws,"whenMouse");var aw=JC,uw=ZC,cw=QC,lw=tw,dw=iw,fw=Object.defineProperty,Ui=(e,t)=>fw(e,"name",{value:t,configurable:!0}),yl="DropdownMenu",[hw,S5]=Jn(yl,[Ug]),Hi=Ug(),[pw,Xg]=hw(yl),mw=Ui((e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:i,onOpenChange:s,modal:a=!0}=e,u=Hi(t),c=m.useRef(null),[f,l]=$o({prop:o,defaultProp:i??!1,onChange:s,caller:yl});return v.jsx(pw,{scope:t,triggerId:Io(),triggerRef:c,contentId:Io(),open:f,onOpenChange:l,onOpenToggle:m.useCallback((()=>l((d=>!d))),[l]),modal:a,children:v.jsx(aw,{...u,open:f,onOpenChange:l,dir:r,modal:a,children:n})})}),"DropdownMenu"),gw=m.forwardRef(Ui((function(e,t){const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,i=Xg("DropdownMenuTrigger",n),s=Hi(n),a=Qe(t,i.triggerRef);return v.jsx(uw,{asChild:!0,...s,children:v.jsx(Wt.button,{type:"button",id:i.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":i.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:a,onPointerDown:Me(e.onPointerDown,(u=>{r||u.button!==0||u.ctrlKey!==!1||(i.onOpenToggle(),i.open||u.preventDefault())})),onKeyDown:Me(e.onKeyDown,(u=>{r||(["Enter"," "].includes(u.key)&&i.onOpenToggle(),u.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(u.key)&&u.preventDefault())}))})})}),"DropdownMenuTrigger")),vw=Ui((e=>{const{__scopeDropdownMenu:t,...n}=e,r=Hi(t);return v.jsx(cw,{...r,...n})}),"DropdownMenuPortal"),yw=m.forwardRef(Ui((function(e,t){const{__scopeDropdownMenu:n,...r}=e,o=Xg("DropdownMenuContent",n),i=Hi(n),s=m.useRef(!1);return v.jsx(lw,{id:o.contentId,"aria-labelledby":o.triggerId,...i,...r,ref:t,onCloseAutoFocus:Me(e.onCloseAutoFocus,(a=>{s.current||o.triggerRef.current?.focus(),s.current=!1,a.preventDefault()})),onInteractOutside:Me(e.onInteractOutside,(a=>{const u=a.detail.originalEvent,c=u.button===0&&u.ctrlKey===!0,f=u.button===2||c;o.modal&&!f||(s.current=!0)})),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})}),"DropdownMenuContent")),bw=m.forwardRef(Ui((function(e,t){const{__scopeDropdownMenu:n,...r}=e,o=Hi(n);return v.jsx(dw,{...o,...r,ref:t})}),"DropdownMenuItem")),Cw=mw,ww=gw,Ew=vw,Dw=yw,Aw=Object.defineProperty,br=(e,t)=>Aw(e,"name",{value:t,configurable:!0}),bl="Popover",[Yg,I5]=Jn(bl,[zo]),Cl=zo(),[xw,Ko]=Yg(bl),Ow=br((e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:o,onOpenChange:i,modal:s=!1}=e,a=Cl(t),u=m.useRef(null),[c,f]=m.useState(!1),[l,d]=$o({prop:r,defaultProp:o??!1,onChange:i,caller:bl});return v.jsx(fl,{...a,children:v.jsx(xw,{scope:t,contentId:Io(),triggerRef:u,open:l,onOpenChange:d,onOpenToggle:m.useCallback((()=>d((h=>!h))),[d]),hasCustomAnchor:c,onCustomAnchorAdd:m.useCallback((()=>f(!0)),[]),onCustomAnchorRemove:m.useCallback((()=>f(!1)),[]),modal:s,children:n})})}),"Popover"),Sw=m.forwardRef(br((function(e,t){const{__scopePopover:n,...r}=e,o=Ko("PopoverTrigger",n),i=Cl(n),s=Qe(t,o.triggerRef),a=v.jsx(Wt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":wl(o.open),...r,ref:s,onClick:Me(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?a:v.jsx(hl,{asChild:!0,...i,children:a})}),"PopoverTrigger")),Qg="PopoverPortal",[Iw,Tw]=Yg(Qg,{forceMount:void 0}),kw=br((e=>{const{__scopePopover:t,forceMount:n,children:r,container:o}=e,i=Ko(Qg,t);return v.jsx(Iw,{scope:t,forceMount:n,children:v.jsx(Wo,{present:n||i.open,children:v.jsx(rl,{asChild:!0,container:o,children:r})})})}),"PopoverPortal"),Oi="PopoverContent",_w=m.forwardRef(br((function(e,t){const n=Tw(Oi,e.__scopePopover),{forceMount:r=n.forceMount,...o}=e,i=Ko(Oi,e.__scopePopover);return v.jsx(Wo,{present:r||i.open,children:i.modal?v.jsx(Fw,{...o,ref:t}):v.jsx(Rw,{...o,ref:t})})}),"PopoverContent")),Bw=Wn("PopoverContent.RemoveScroll"),Fw=m.forwardRef(br((function(e,t){const n=Ko(Oi,e.__scopePopover),r=m.useRef(null),o=Qe(t,r),i=m.useRef(!1);return m.useEffect((()=>{const s=r.current;if(s)return ug(s)}),[]),v.jsx(ol,{as:Bw,allowPinchZoom:!0,children:v.jsx(e0,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Me(e.onCloseAutoFocus,(s=>{s.preventDefault(),i.current||n.triggerRef.current?.focus()})),onPointerDownOutside:Me(e.onPointerDownOutside,(s=>{const a=s.detail.originalEvent,u=a.button===0&&a.ctrlKey===!0,c=a.button===2||u;i.current=c}),{checkForDefaultPrevented:!1}),onFocusOutside:Me(e.onFocusOutside,(s=>s.preventDefault()),{checkForDefaultPrevented:!1})})})}),"PopoverContentModal")),Rw=m.forwardRef(br((function(e,t){const n=Ko(Oi,e.__scopePopover),r=m.useRef(!1),o=m.useRef(!1);return v.jsx(e0,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),i.defaultPrevented||(r.current||n.triggerRef.current?.focus(),i.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const s=i.target;n.triggerRef.current?.contains(s)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&o.current&&i.preventDefault()}})}),"PopoverContentNonModal")),e0=m.forwardRef(br((function(e,t){const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:i,disableOutsidePointerEvents:s,onEscapeKeyDown:a,onPointerDownOutside:u,onFocusOutside:c,onInteractOutside:f,...l}=e,d=Ko(Oi,n),h=Cl(n);return Ls(),v.jsx(Gm,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:i,children:v.jsx(el,{asChild:!0,disableOutsidePointerEvents:s,onInteractOutside:f,onEscapeKeyDown:a,onPointerDownOutside:u,onFocusOutside:c,onDismiss:()=>d.onOpenChange(!1),deferPointerDownOutside:!0,children:v.jsx(pl,{"data-state":wl(d.open),role:"dialog",id:d.contentId,...h,...l,ref:t,style:{...l.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),"PopoverContentImpl"));function wl(e){return e?"open":"closed"}br(wl,"getState");var jw=Ow,Mw=Sw,Pw=kw,Nw=_w,Lw=Object.defineProperty,Uw=(e,t)=>Lw(e,"name",{value:t,configurable:!0}),El=m.forwardRef(Uw((function(e,t){const{pressed:n,defaultPressed:r,onPressedChange:o,...i}=e,[s,a]=$o({prop:n,onChange:o,defaultProp:r??!1,caller:"Toggle"});return v.jsx(Wt.button,{type:"button","aria-pressed":s,"data-state":s?"on":"off","data-disabled":e.disabled?"":void 0,...i,ref:t,onClick:Me(e.onClick,(()=>{e.disabled||a(!s)}))})}),"Toggle")),Hw=Object.defineProperty,pt=(e,t)=>Hw(e,"name",{value:t,configurable:!0}),[Dl,T5]=Jn("Tooltip",[zo]),Al=zo(),Vw=700,Yu="tooltip.open",[$w,xl]=Dl("TooltipProvider"),Ww=pt((e=>{const{__scopeTooltip:t,delayDuration:n=Vw,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:i}=e,s=m.useRef(!0),a=m.useRef(!1),u=m.useRef(0);return m.useEffect((()=>{const c=u.current;return()=>window.clearTimeout(c)}),[]),v.jsx($w,{scope:t,isOpenDelayedRef:s,delayDuration:n,onOpen:m.useCallback((()=>{r<=0||(window.clearTimeout(u.current),s.current=!1)}),[r]),onClose:m.useCallback((()=>{r<=0||(window.clearTimeout(u.current),u.current=window.setTimeout((()=>s.current=!0),r))}),[r]),isPointerInTransitRef:a,onPointerInTransitChange:m.useCallback((c=>{a.current=c}),[]),disableHoverableContent:o,children:i})}),"TooltipProvider"),Qu="Tooltip",[zw,Vi]=Dl(Qu),Kw=pt((e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:i,disableHoverableContent:s,delayDuration:a}=e,u=xl(Qu,e.__scopeTooltip),c=Al(t),[f,l]=m.useState(null),[d,h]=m.useState(void 0),g=Io(),y=m.useRef(0),p=s??u.disableHoverableContent,w=a??u.delayDuration,b=m.useRef(!1),[C,E]=$o({prop:r,defaultProp:o??!1,onChange:pt((S=>{S?(u.onOpen(),document.dispatchEvent(new CustomEvent(Yu))):u.onClose(),i?.(S)}),"onChange"),caller:Qu}),A=m.useMemo((()=>C?b.current?"delayed-open":"instant-open":"closed"),[C]),x=m.useCallback((()=>{window.clearTimeout(y.current),y.current=0,b.current=!1,E(!0)}),[E]),I=m.useCallback((()=>{window.clearTimeout(y.current),y.current=0,E(!1)}),[E]),T=m.useCallback((()=>{window.clearTimeout(y.current),y.current=window.setTimeout((()=>{b.current=!0,E(!0),y.current=0}),w)}),[w,E]);m.useEffect((()=>()=>{y.current&&(window.clearTimeout(y.current),y.current=0)}),[]);const B=d??g;return v.jsx(fl,{...c,children:v.jsx(zw,{scope:t,contentId:B,setContentId:h,open:C,stateAttribute:A,trigger:f,onTriggerChange:l,onTriggerEnter:m.useCallback((()=>{u.isOpenDelayedRef.current?T():x()}),[u.isOpenDelayedRef,T,x]),onTriggerLeave:m.useCallback((()=>{p?I():(window.clearTimeout(y.current),y.current=0)}),[I,p]),onOpen:x,onClose:I,disableHoverableContent:p,children:n})})}),"Tooltip"),Df="TooltipTrigger",qw=m.forwardRef(pt((function(e,t){const{__scopeTooltip:n,...r}=e,o=Vi(Df,n),i=xl(Df,n),s=Al(n),a=Qe(t,m.useRef(null),o.onTriggerChange),u=m.useRef(!1),c=m.useRef(!1),f=m.useCallback((()=>u.current=!1),[]);return m.useEffect((()=>()=>document.removeEventListener("pointerup",f)),[f]),v.jsx(hl,{asChild:!0,...s,children:v.jsx(Wt.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:a,onPointerMove:Me(e.onPointerMove,(l=>{l.pointerType!=="touch"&&(c.current||i.isPointerInTransitRef.current||(o.onTriggerEnter(),c.current=!0))})),onPointerLeave:Me(e.onPointerLeave,(()=>{o.onTriggerLeave(),c.current=!1})),onPointerDown:Me(e.onPointerDown,(()=>{o.open&&o.onClose(),u.current=!0,document.addEventListener("pointerup",f,{once:!0})})),onFocus:Me(e.onFocus,(()=>{u.current||o.onOpen()})),onBlur:Me(e.onBlur,o.onClose),onClick:Me(e.onClick,o.onClose)})})}),"TooltipTrigger")),t0="TooltipPortal",[Gw,Jw]=Dl(t0,{forceMount:void 0}),Zw=pt((e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:o}=e,i=Vi(t0,t);return v.jsx(Gw,{scope:t,forceMount:n,children:v.jsx(Wo,{present:n||i.open,children:v.jsx(rl,{asChild:!0,container:o,children:r})})})}),"TooltipPortal"),Si="TooltipContent",Xw=m.forwardRef(pt((function(e,t){const n=Jw(Si,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...i}=e,s=Vi(Si,e.__scopeTooltip);return v.jsx(Wo,{present:r||s.open,children:s.disableHoverableContent?v.jsx(n0,{side:o,...i,ref:t}):v.jsx(Yw,{side:o,...i,ref:t})})}),"TooltipContent")),Yw=m.forwardRef(pt((function(e,t){const n=Vi(Si,e.__scopeTooltip),r=xl(Si,e.__scopeTooltip),o=m.useRef(null),i=Qe(t,o),[s,a]=m.useState(null),{trigger:u,onClose:c}=n,f=o.current,{onPointerInTransitChange:l}=r,d=m.useCallback((()=>{a(null),l(!1)}),[l]),h=m.useCallback(((g,y)=>{const p=g.currentTarget,w={x:g.clientX,y:g.clientY},b=a0([...o0(w,r0(w,p.getBoundingClientRect())),...i0(y.getBoundingClientRect())]);a(b),l(!0)}),[l]);return m.useEffect((()=>()=>d()),[d]),m.useEffect((()=>{if(u&&f){const g=pt((p=>h(p,f)),"handleTriggerLeave"),y=pt((p=>h(p,u)),"handleContentLeave");return u.addEventListener("pointerleave",g),f.addEventListener("pointerleave",y),()=>{u.removeEventListener("pointerleave",g),f.removeEventListener("pointerleave",y)}}}),[u,f,h,d]),m.useEffect((()=>{if(s){const g=pt((y=>{const p=y.target,w={x:y.clientX,y:y.clientY},b=u?.contains(p)||f?.contains(p),C=!s0(w,s);b?d():C&&(d(),c())}),"handleTrackPointerGrace");return document.addEventListener("pointermove",g),()=>document.removeEventListener("pointermove",g)}}),[u,f,s,c,d]),v.jsx(n0,{...e,ref:i})}),"TooltipContentHoverable")),Qw=Jc("TooltipContent"),n0=m.forwardRef(pt((function(e,t){const{__scopeTooltip:n,children:r,"aria-label":o,id:i,onEscapeKeyDown:s,onPointerDownOutside:a,...u}=e,c=Vi(Si,n),f=Al(n),{onClose:l}=c;m.useEffect((()=>(document.addEventListener(Yu,l),()=>document.removeEventListener(Yu,l))),[l]),m.useEffect((()=>{if(c.trigger){const h=pt((g=>{g.target instanceof Node&&g.target.contains(c.trigger)&&l()}),"handleScroll");return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}}),[c.trigger,l]);const{setContentId:d}=c;return Qt((()=>(d(i),()=>{d(void 0)})),[i,d]),v.jsx(el,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:h=>h.preventDefault(),onDismiss:l,children:v.jsxs(pl,{"data-state":c.stateAttribute,role:o?void 0:"tooltip",id:o?void 0:c.contentId,...f,...u,ref:t,style:{...u.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[v.jsx(Qw,{children:r}),o?v.jsx(wb,{id:c.contentId,role:"tooltip",children:o}):null]})})}),"TooltipContentImpl"));function r0(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(n,r,o,i)){case i:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function o0(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n})}return r}function i0(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function s0(e,t){const{x:n,y:r}=e;let o=!1;for(let i=0,s=t.length-1;i<t.length;s=i++){const a=t[i],u=t[s],c=a.x,f=a.y,l=u.x,d=u.y;f>r!=d>r&&n<(l-c)*(r-f)/(d-f)+c&&(o=!o)}return o}function a0(e){const t=e.slice();return t.sort(((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0)),u0(t)}function u0(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const i=t[t.length-1],s=t[t.length-2];if(!((i.x-s.x)*(o.y-s.y)>=(i.y-s.y)*(o.x-s.x)))break;t.pop()}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const i=n[n.length-1],s=n[n.length-2];if(!((i.x-s.x)*(o.y-s.y)>=(i.y-s.y)*(o.x-s.x)))break;n.pop()}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}pt(r0,"getExitSideFromRect"),pt(o0,"getPaddedExitPoints"),pt(i0,"getPointsFromRect"),pt(s0,"isPointInPolygon"),pt(a0,"getHull"),pt(u0,"getHullPresorted");var eE=Ww,tE=Kw,nE=qw,rE=Zw,oE=Xw;function da(e){const t=new Map;return(...n)=>{const r=JSON.stringify(n.map((s=>Yt(s)))),o=t.get(r);if(o!==void 0)return o;const i=e(...n);return t.set(r,i),i}}const c0=da(((...e)=>new Intl.DateTimeFormat(...e))),Af=da(((...e)=>new Intl.RelativeTimeFormat(...e))),iE=da(((...e)=>new Intl.ListFormat(...e))),Lr=da(((...e)=>new Intl.NumberFormat(...e)));function l0(e,t){const n=m.useRef(e);m.useEffect((()=>{n.current=e}),[e]),m.useEffect((()=>{if(!t&&t!==0)return;const r=setInterval((()=>{n.current()===!1&&clearInterval(r)}),t);return()=>clearInterval(r)}),[t])}function d0(){const[e,t]=m.useReducer((n=>n+1),0);return[t,e]}function Ol(e){let t=Math.max(e,0);const n=t%1e3;t=Math.floor(t/1e3);const r=t%60;t=Math.floor(t/60);const o=t%60;t=Math.floor(t/60);const i=t%24;t=Math.floor(t/24);const s=t%7;return{weeks:Math.floor(t/7),days:s,hours:i,minutes:o,seconds:r,milliseconds:n}}const f0={weeks:"week",days:"day",hours:"hour",minutes:"minute",seconds:"second",milliseconds:"millisecond"};function sE(e,t){let n;t?n=t:n=Lr().resolvedOptions().locale;const r=Ol(e),o=[];for(const[i,s]of Object.entries(r)){if(s===0||i==="milliseconds")continue;const a=Lr(n,{style:"unit",unit:f0[i],unitDisplay:"narrow"});o.push(a.format(s))}return o.length||o.push(Lr(n,{style:"unit",unit:"second",unitDisplay:"narrow"}).format(0)),o.join(" ")}function aE(e,t){let n;t?n=t:n=Lr().resolvedOptions().locale;const r=Ol(e),o=[];for(const[i,s]of Object.entries(r)){if(s===0||i==="milliseconds")continue;const a=Lr(n,{style:"unit",unit:f0[i],unitDisplay:"long"});o.push(a.format(s))}return o.length||o.push(Lr(n,{style:"unit",unit:"second",unitDisplay:"long"}).format(0)),o.join(" ")}function xf(e){return e instanceof Date?e.getTime():new Date(e).getTime()}function h0(e,t){return xf(t)-xf(e)}const Ya=m.forwardRef((({duration:e,from:t,to:n,locale:r,dateTime:o,title:i=aE,children:s=sE,interval:a=500,asChild:u,...c},f)=>{const l=u?vt:"time",[d,h]=d0(),g=m.useMemo((()=>e!==void 0?e:t!==void 0?h0(t,n??Date.now()):0),[e,t,n,h]),y=m.useMemo((()=>(function(b){const C=Math.max(b,0);if(C===0)return"PT0S";const{weeks:E,days:A,hours:x,minutes:I,seconds:T,milliseconds:B}=Ol(C);let S="P";return E>0&&(S+=`${E}W`),A>0&&(S+=`${A}D`),(x>0||I>0||T>0||B>0)&&(S+="T",x>0&&(S+=`${x}H`),I>0&&(S+=`${I}M`),(T>0||B>0)&&(S+=B>0?`${T}.${B.toString().padStart(3,"0").replace(/0+$/,"")}S`:`${T}S`)),S})(g)),[g]),p=m.useMemo((()=>typeof i=="function"?i(g,r):i),[i,g,r]),w=m.useMemo((()=>typeof s=="function"?s(g,r):s),[s,g,r]);return l0(d,t!==void 0&&n===void 0&&a),v.jsx(l,{...c,ref:f,dateTime:o??y,title:p,children:w})}));function ds(e,t,n){return e===1?t:n??`${t}s`}function Qa(e,t){return h0(e,t??Date.now())>=3e3}const uE={locale:"en",dir:"ltr",USER_SELF:"you",USER_UNKNOWN:"Anonymous",COPY_TO_CLIPBOARD:"Copy",LIST_REMAINING:e=>`${e} more`,LIST_REMAINING_USERS:e=>`${e} ${ds(e,"other")}`,LIST_REMAINING_COMMENTS:e=>`${e} more ${ds(e,"comment")}`,EMOJI_PICKER_SEARCH_PLACEHOLDER:"Search…",EMOJI_PICKER_EMPTY:"No emoji found.",EMOJI_PICKER_ERROR:()=>"There was an error while getting the list of emoji.",EMOJI_PICKER_CHANGE_SKIN_TONE:"Change skin tone",ATTACHMENT_TOO_LARGE:e=>e?`The file is larger than ${e}`:"The file is too large",ATTACHMENT_ERROR:()=>"The file couldn’t be uploaded.",COMPOSER_INSERT_MENTION:"Mention someone",COMPOSER_INSERT_EMOJI:"Add emoji",COMPOSER_ATTACH_FILES:"Attach files",COMPOSER_REMOVE_ATTACHMENT:"Remove attachment",COMPOSER_PLACEHOLDER:"Write a comment…",COMPOSER_SEND:"Send",COMPOSER_TOGGLE_MARK:e=>{switch(e){case"bold":return"Bold";case"italic":return"Italic";case"strikethrough":return"Strikethrough";case"code":return"Inline code";default:return Ye(0,"Unexpected mark")}},COMMENT_EDITED:"(edited)",COMMENT_DELETED:"This comment has been deleted.",COMMENT_MORE:"More",COMMENT_EDIT:"Edit comment",COMMENT_EDIT_COMPOSER_PLACEHOLDER:"Edit comment…",COMMENT_EDIT_COMPOSER_CANCEL:"Cancel",COMMENT_EDIT_COMPOSER_SAVE:"Save",COMMENT_DELETE:"Delete comment",COMMENT_DELETE_ATTACHMENT:"Delete attachment",COMMENT_ADD_REACTION:"Add reaction",COMMENT_REACTION_LIST:(e,t)=>v.jsxs(v.Fragment,{children:[e," reacted with ",v.jsx(Gc,{emoji:t})]}),COMMENT_REACTION_DESCRIPTION:(e,t)=>`${t} ${ds(t,"reaction")}, react with ${e}`,THREAD_RESOLVE:"Resolve thread",THREAD_UNRESOLVE:"Re-open thread",THREAD_SUBSCRIBE:"Subscribe to thread",THREAD_UNSUBSCRIBE:"Unsubscribe from thread",THREAD_NEW_INDICATOR:"New",THREAD_NEW_INDICATOR_DESCRIPTION:"New comments",THREAD_SHOW_MORE_COMMENTS:e=>`Show ${e} more ${ds(e,"reply","replies")}`,THREAD_COMPOSER_PLACEHOLDER:"Reply to thread…",THREAD_COMPOSER_SEND:"Reply",INBOX_NOTIFICATION_MORE:"More",INBOX_NOTIFICATION_MARK_AS_READ:"Mark as read",INBOX_NOTIFICATION_DELETE:"Delete notification",INBOX_NOTIFICATION_THREAD_COMMENTS_LIST:(e,t)=>v.jsxs(v.Fragment,{children:[e," commented",t?v.jsxs(v.Fragment,{children:[" in ",t]}):v.jsx(v.Fragment,{children:" in a thread"})]}),INBOX_NOTIFICATION_THREAD_MENTION:(e,t)=>v.jsxs(v.Fragment,{children:[e," mentioned you",t?v.jsxs(v.Fragment,{children:[" in ",t]}):null]}),INBOX_NOTIFICATION_TEXT_MENTION:(e,t)=>v.jsxs(v.Fragment,{children:[e," mentioned you",t?v.jsxs(v.Fragment,{children:[" in ",t]}):null]}),HISTORY_VERSION_SUMMARY_AUTHORS_LIST:e=>e===void 0?"Unattributed":e,HISTORY_VERSION_PREVIEW_AUTHORS_LIST:e=>e===void 0?"Unattributed edits":v.jsxs(v.Fragment,{children:["Edits from ",e]}),HISTORY_VERSION_PREVIEW_RESTORE:"Restore",HISTORY_VERSION_PREVIEW_EMPTY:"No content.",HISTORY_VERSION_PREVIEW_ERROR:()=>"There was an error while getting this version.",AI_COMPOSER_PLACEHOLDER:"Ask anything…",AI_COMPOSER_SEND:"Send",AI_COMPOSER_ABORT:"Abort response",AI_CHAT_MESSAGE_DELETED:"This message has been deleted.",AI_CHAT_MESSAGE_THINKING:"Thinking…",AI_CHAT_MESSAGE_REASONING:(e,t)=>e?v.jsx(v.Fragment,{children:"Reasoning…"}):v.jsxs(v.Fragment,{children:["Reasoned",Qa(t.startedAt,t.endedAt)?v.jsxs(v.Fragment,{children:[" ","for"," ",v.jsx(Ya,{className:"lb-duration lb-ai-chat-message-reasoning-duration",from:t.startedAt,to:t.endedAt})]}):null]}),AI_CHAT_MESSAGE_RETRIEVAL:(e,t)=>t.kind==="knowledge"?e?v.jsxs(v.Fragment,{children:["Searching"," ",v.jsx("span",{className:"lb-ai-chat-message-retrieval-query",children:t.query}),"…"]}):v.jsxs(v.Fragment,{children:["Searched"," ",v.jsx("span",{className:"lb-ai-chat-message-retrieval-query",children:t.query}),Qa(t.startedAt,t.endedAt)?v.jsxs(v.Fragment,{children:[" ","for"," ",v.jsx(Ya,{className:"lb-duration lb-ai-chat-message-retrieval-duration",from:t.startedAt,to:t.endedAt})]}):null]}):t.kind==="web"?e?v.jsxs(v.Fragment,{children:["Searching the web",t.query?v.jsxs(v.Fragment,{children:[" ","for"," ",v.jsx("span",{className:"lb-ai-chat-message-retrieval-query",children:t.query})]}):null,"…"]}):v.jsxs(v.Fragment,{children:["Searched the web",t.query?v.jsxs(v.Fragment,{children:[" ","for"," ",v.jsx("span",{className:"lb-ai-chat-message-retrieval-query",children:t.query})]}):null,Qa(t.startedAt,t.endedAt)?v.jsxs(v.Fragment,{children:[" ","for"," ",v.jsx(Ya,{className:"lb-duration lb-ai-chat-message-retrieval-duration",from:t.startedAt,to:t.endedAt})]}):null]}):Ye(0,"Unexpected retrieval kind"),AI_CHAT_MESSAGES_ERROR:()=>"There was an error while getting the messages.",AI_TOOL_CONFIRMATION_CONFIRM:"Confirm",AI_TOOL_CONFIRMATION_CANCEL:"Cancel"},cE=m.createContext(void 0);function Mt(e){const t=m.useContext(cE);return m.useMemo((()=>({...uE,...t,...e})),[t,e])}function Of(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}const p0={Anchor:"a"},ec=m.createContext(void 0);function lE({children:e,components:t}){const n=m.useContext(ec),r=m.useMemo((()=>({...p0,...n,...t})),[n,t]);return v.jsx(ec.Provider,{value:r,children:e})}const dE=m.createContext({});function $i(){return m.useContext(dE)}const fE=/Mac|iPod|iPhone|iPad/;function m0(){return typeof window<"u"&&fE.test(window.navigator.platform)}const hE={title:"Alt",key:"⌥"},eu={title:"Command",key:"⌘"},tu={title:"Ctrl",key:"⌃"},pE={title:"Shift",key:"⇧"},mE={title:"Enter",key:"⏎"},Sf={title:"Space",key:"␣"},If={title:"Escape",key:"⎋"},g0={alt:()=>hE,mod:()=>m0()?eu:tu,control:()=>tu,ctrl:()=>tu,command:()=>eu,cmd:()=>eu,shift:()=>pE,enter:()=>mE," ":()=>Sf,space:()=>Sf,escape:()=>If,esc:()=>If},jt=m.forwardRef((({children:e,content:t,multiline:n,className:r,...o},i)=>{const{portalContainer:s}=$i();return v.jsxs(tE,{disableHoverableContent:!0,children:[v.jsx(nE,{asChild:!0,ref:i,children:e}),v.jsx(rE,{container:s,children:v.jsx(oE,{className:Ne("lb-root lb-portal lb-tooltip",n&&"lb-tooltip:multiline",r),side:"top",align:"center",updatePositionStrategy:"always",sideOffset:6,collisionPadding:10,...o,children:t})})]})})),Sl=m.forwardRef((({children:e,content:t,shortcut:n,...r},o)=>{const i=m.useMemo((()=>n?(function(s){const a=s.split("-");return v.jsx(v.Fragment,{children:a.map(((u,c)=>{const f=u.toLowerCase();return f in g0?v.jsx(gE,{name:f},c):v.jsx("span",{children:u},c)}))})})(n):null),[n]);return v.jsx(jt,{content:v.jsxs(v.Fragment,{children:[t,i&&v.jsx("kbd",{className:"lb-tooltip-shortcut",children:i})]}),...r,ref:o,children:e})}));function gE({name:e,...t}){const{title:n,key:r}=m.useMemo((()=>g0[e]?.()),[e]);return v.jsx("abbr",{title:n,...t,children:r})}const fa=eE;function ha({src:e,name:t,className:n,children:r,tooltip:o,outline:i,style:s,...a}){const u=m.useMemo((()=>t?(function(l){return l.trim().split(" ").reduce(((d,h,g,y)=>(g!==0&&g!==y.length-1||(d+=h.charAt(0).toLocaleUpperCase()),d)),"")})(t):void 0),[t]),c=typeof i=="object"?i:typeof i=="string"?{color:i}:i===!0?{}:void 0,f=v.jsx("div",{className:Ne("lb-avatar",n),"data-variant":c?"outline":"default",style:{"--lb-avatar-outline-color":c?.color,"--lb-avatar-outline-width":Of(c?.width),"--lb-avatar-outline-gap":Of(c?.gap),...s},...a,children:v.jsx("div",{className:"lb-avatar-content",children:r??(e?v.jsx("img",{className:"lb-avatar-image",src:e,alt:t}):u?v.jsx("span",{className:"lb-avatar-fallback","aria-label":t,title:t,children:u}):null)})});return o?v.jsx(fa,{children:v.jsx(jt,{content:o,sideOffset:6,collisionPadding:10,side:"top",align:"center",children:f})}):f}function vE({userId:e,icon:t,variant:n="default",tooltip:r,...o}){const{user:i,isLoading:s}=wm(e);return v.jsx(ha,{src:i?.avatar,name:s?void 0:i?.name??e,outline:n==="outline"&&typeof i?.color=="string"?i.color:void 0,"data-loading":s?"":void 0,tooltip:r,...o,children:!t||!s&&i?.avatar?null:t})}function yE({groupId:e,icon:t,variant:n="default",tooltip:r,...o}){const{info:i,isLoading:s}=zc(e);return v.jsx(ha,{src:i?.avatar,name:s?void 0:i?.name??e,outline:n==="outline"&&typeof i?.color=="string"?i.color:void 0,"data-loading":s?"":void 0,tooltip:r,...o,children:!t||!s&&i?.avatar?null:t})}function tc({userId:e,icon:t,variant:n="default",...r}){const o=Mt();return e?v.jsx(vE,{userId:e,icon:t,variant:n,...r}):v.jsx(ha,{name:o.USER_UNKNOWN,outline:n==="outline",...r,children:t})}function bE({groupId:e,icon:t,variant:n="default",...r}){return e?v.jsx(yE,{groupId:e,icon:t,variant:n,...r}):v.jsx(ha,{outline:n==="outline",...r,children:t})}function Je({children:e,className:t,...n}){return v.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:20,viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",role:"presentation",className:Ne("lb-icon",t),...n,children:e})}function CE(e){return v.jsx(Je,{...e,children:v.jsx("path",{d:"M14.5 8.5 10 13 5.5 8.5"})})}const Il=m.forwardRef((({variant:e="default",size:t="default",disableable:n=!0,className:r,children:o,...i},s)=>v.jsx("button",{type:"button",className:Ne("lb-button",!n&&"lb-button:non-disableable",r),"data-variant":e,"data-size":t,...i,ref:s,children:o}))),Zt=m.forwardRef((({icon:e,children:t,...n},r)=>v.jsxs(Il,{...n,ref:r,children:[e?v.jsx("span",{className:"lb-icon-container",children:e}):null,t?v.jsx("span",{className:"lb-button-label",children:t}):null]})));function Tl({groupId:e,className:t,children:n,...r}){const{info:o,isLoading:i}=zc(e);return v.jsxs("span",{className:Ne("lb-name lb-group",t),"data-loading":i?"":void 0,...r,children:[i?null:o?.name??e,n]})}function wE({groupId:e,className:t,...n}){const{info:r}=zc(e);return r?.description?v.jsx("span",{className:Ne("lb-group-description",t),...n,children:r.description}):null}m.forwardRef((({icon:e,children:t,className:n,...r},o)=>v.jsxs(Il,{...r,type:"button",className:Ne("lb-select-button",n),ref:o,children:[e?v.jsx("span",{className:"lb-icon-container",children:e}):null,t?v.jsx("span",{className:"lb-button-label",children:t}):null,v.jsx("span",{className:"lb-select-button-chevron",children:v.jsx(CE,{})})]})));const EE=m.forwardRef((({values:e,formatRemaining:t,truncate:n,locale:r,className:o,asChild:i,...s},a)=>{const u=i?vt:"span",c=Mt(),f=t??c.LIST_REMAINING,l=m.useMemo((()=>{const d=n&&n<e.length-1?[...e.slice(0,n),f(e.length-n)]:[...e],h=Array(d.length).fill(".");return iE(r).formatToParts(h).map((g=>g.type==="element"?d.shift():g.value))}),[f,r,n,e]);return v.jsx(u,{className:Ne("lb-list",o),...s,ref:a,children:l})}));function DE(e){return v.jsx(Je,{...e,children:v.jsx("path",{d:"M10 4v12m6-6-6 6-6-6"})})}function v0(e){return v.jsx(Je,{...e,children:v.jsx("path",{d:"m14.077 11.737-3.723 3.62c-1.55 1.507-4.128 1.507-5.678 0-1.543-1.5-1.543-4.02 0-5.52l5.731-5.573c1.034-1.006 2.754-1.007 3.789-.003 1.03 1 1.032 2.682.003 3.684l-5.744 5.572a1.377 1.377 0 0 1-1.893 0 1.283 1.283 0 0 1-.392-.92c0-.345.14-.676.392-.92L10.348 8"})})}function AE(e){return v.jsx(Je,{...e,children:v.jsx("path",{d:"M10 4a3.5 3.5 0 0 0-3.5 3.5c0 3.5-2 6.5-2 6.5h11s-2-3-2-6.5A3.5 3.5 0 0 0 10 4ZM7.55 14a2.5 2.5 0 0 0 4.9 0"})})}function xE(e){return v.jsx(Je,{...e,children:v.jsx("path",{d:"M14 14H4.5s2-3 2-6.5c0-.3.05-.6.12-.88M8.2 4.5a3.5 3.5 0 0 1 5.3 3c0 .96.15 1.88.37 2.7M7.55 14a2.5 2.5 0 0 0 4.9 0M4.5 4.5l11 11"})})}function OE(e){return v.jsx(Je,{...e,children:v.jsx("path",{d:"M5.5 10h6.63m0 5.75H5.5V4.25h5.63M11.125 10a2.875 2.875 0 0 0 0-5.75m1 11.5a2.875 2.875 0 0 0 0-5.75"})})}function SE(e){return v.jsx(Je,{...e,children:v.jsx("path",{d:"M16 6L8 14L4 10"})})}function IE(e){return v.jsxs(Je,{...e,children:[v.jsx("circle",{cx:10,cy:10,r:7}),v.jsx("path",{d:"m13 8-4 4-2-2"})]})}function TE(e){return v.jsxs(Je,{...e,children:[v.jsx("circle",{cx:10,cy:10,r:7,fill:"currentColor"}),v.jsx("path",{d:"m13 8-4 4-2-2",stroke:"var(--lb-icon-background)"})]})}function kE(e){return v.jsx(Je,{...e,children:v.jsx("path",{d:"m7.5 6-4 4 4 4m5-8 4 4-4 4"})})}function kl(e){return v.jsxs(Je,{...e,children:[v.jsx("path",{d:"M15 5L5 15"}),v.jsx("path",{d:"M5 5L15 15"})]})}function _E(e){return v.jsx(Je,{...e,children:v.jsx("path",{d:"M4.5 6.5h11M14 6.5V14a1.5 1.5 0 0 1-1.5 1.5h-5A1.5 1.5 0 0 1 6 14V6.5M7.5 6.5V5a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1v1.5"})})}function BE(e){return v.jsx(Je,{...e,children:v.jsx("path",{d:"m11.784 5.797-6.13 6.138a4 4 0 0 0-1.03 1.775L4 16l2.285-.624a4 4 0 0 0 1.776-1.032l6.145-6.152m-2.422-2.395 1.244-1.246c.608-.608 1.826-.81 2.53-.104.7.7.499 1.893-.122 2.515l-1.23 1.23m-2.422-2.395 2.422 2.395"})})}function FE(e){return v.jsxs(Je,{fill:"currentColor",...e,children:[v.jsx("circle",{cx:5,cy:10,r:.75}),v.jsx("circle",{cx:10,cy:10,r:.75}),v.jsx("circle",{cx:15,cy:10,r:.75})]})}function RE(e){return v.jsxs(Je,{...e,children:[v.jsx("path",{d:"M10 17a7 7 0 1 0 0-14 7 7 0 0 0 0 14Z"}),v.jsx("path",{d:"M7.5 11.5S8.25 13 10 13s2.5-1.5 2.5-1.5M8 8h.007"}),v.jsx("path",{d:"M12 8h.007"}),v.jsx("circle",{cx:8,cy:8,r:.25}),v.jsx("circle",{cx:12,cy:8,r:.25})]})}function Tf(e){return v.jsxs(Je,{...e,children:[v.jsx("path",{d:"M11 3.07A7 7 0 1 0 16.93 9"}),v.jsx("path",{d:"M7.5 11.5S8.25 13 10 13s2.5-1.5 2.5-1.5M8 8h0"}),v.jsx("path",{d:"M12 8h0"}),v.jsx("path",{d:"M13 5h4m-2-2v4"}),v.jsx("circle",{cx:"8",cy:"8",r:".25"}),v.jsx("circle",{cx:"12",cy:"8",r:".25"})]})}function jE(e){return v.jsx(Je,{...e,children:v.jsx("path",{d:"M15 4.25H8m4 11.5H5m6.75-11.5-3.5 11.5"})})}function ME(e){return v.jsxs(Je,{...e,children:[v.jsx("path",{d:"M10 13a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"}),v.jsx("path",{d:"M13 7v3.7c0 1.105.855 2.1 1.9 2.1a2.12 2.12 0 0 0 2.1-2.1V10a7 7 0 1 0-2.8 5.6"})]})}function PE(e){return v.jsx(Je,{...e,children:v.jsx("path",{d:"M9 15A6 6 0 1 0 9 3a6 6 0 0 0 0 12Zm7.5 1.5-3.25-3.25"})})}function NE(e){return v.jsx(Je,{...e,children:v.jsx("path",{d:"m5 16 12-6L5 4l2 6-2 6ZM7 10h10"})})}function Wi(e){return v.jsx(Je,{...e,children:v.jsx("path",{d:"M3 10a7 7 0 0 1 7-7",className:"lb-icon-spinner"})})}function LE(e){return v.jsx(Je,{...e,children:v.jsx("path",{d:"M15.5 10h-11m4.669 0C7.599 9.44 6.5 8.484 6.5 7.125 6.5 5.537 7.79 4.25 10 4.25c1.654 0 2.793.721 3.261 1.75M6.74 14c.468 1.029 1.607 1.75 3.261 1.75 2 0 3.5-1 3.5-2.5 0-.085-.004-.169-.013-.25"})})}function UE(e){return v.jsx(Je,{...e,children:v.jsx("path",{d:"M8 9.75a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Zm0 0c-2.42 0-4.055 1.72-4.422 4.004-.087.545.37.996.922.996h7c.552 0 1.01-.45.922-.996C12.055 11.47 10.42 9.75 8 9.75ZM15 14.75h.5c.552 0 1.004-.45.912-.995-.317-1.888-1.485-4.114-3.412-4.505.863-.222 1.5-1.068 1.5-2a2 2 0 0 0-2-2"})})}function y0(e){return v.jsxs(Je,{...e,children:[v.jsx("path",{d:"m3.794 13.526 5.326-9.89a1 1 0 0 1 1.76 0l5.326 9.89a1 1 0 0 1-.88 1.474H4.674a1 1 0 0 1-.88-1.474ZM10 7.5v2m0 2.5h.007"}),v.jsx("circle",{cx:10,cy:12,r:.25})]})}function mr(){return Vo(Ve()[Oe].currentUserId)??null}function _l(e){return e==="private"?"comments:private":e==="public"?"comments:public":"comments"}function b0({isLoading:e,name:t,className:n,children:r,...o}){return v.jsxs("span",{className:Ne("lb-name lb-user",n),"data-loading":e?"":void 0,...o,children:[e?null:t,r]})}function HE({userId:e,replaceSelf:t,...n}){const r=mr(),{user:o,isLoading:i}=wm(e),s=Mt(),a=m.useMemo((()=>t&&r===e?s.USER_SELF:o?.name??s.USER_UNKNOWN),[t,r,e,s.USER_SELF,s.USER_UNKNOWN,o?.name]);return v.jsx(b0,{isLoading:i,name:a,...n})}function Bo({userId:e,...t}){const n=Mt();return e?v.jsx(HE,{userId:e,...t}):v.jsx(b0,{isLoading:!1,name:n.USER_UNKNOWN,...t})}function nc(e){return e.charAt(0).toUpperCase()+e.slice(1)}const C0=m.forwardRef((({asChild:e,...t},n)=>{const{portalContainer:r}=$i(),o=r??document?.body,i=e?vt:"div";return o?Mi.createPortal(v.jsx(i,{"data-liveblocks-portal":"",...t,ref:n}),o):null}));function Fo(e){const[t]=m.useState(e);return t}function VE(e,t){t&&(typeof e=="function"?e(t):e&&"current"in e&&(e.current=t))}function zi(...e){return m.useCallback((t=>(function(n,...r){for(const o of r)VE(o,n)})(t,...e)),e)}function $E(e,t){const n=t,r=m.useRef(e);return r.current=e,m.useMemo((()=>i=>{const s=r.current;return s?(function(a){return!!(a.prototype&&"isReactComponent"in a.prototype)})(s)?v.jsx(s,{...i}):s(i):v.jsx(n,{...i})}),[n])}function kf(e){return Object.prototype.toString.call(e)==="[object Object]"}function ft(e){var t,n;return kf(e)!==!1&&((t=e.constructor)===void 0||kf(n=t.prototype)!==!1&&n.hasOwnProperty("isPrototypeOf")!==!1)}var w0=Symbol.for("immer-nothing"),_f=Symbol.for("immer-draftable"),Vt=Symbol.for("immer-state");function sn(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Ii=Object.getPrototypeOf;function Ur(e){return!!e&&!!e[Vt]}function zr(e){return!!e&&(E0(e)||Array.isArray(e)||!!e[_f]||!!e.constructor?.[_f]||Ki(e)||ma(e))}var WE=Object.prototype.constructor.toString(),Bf=new WeakMap;function E0(e){if(!e||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);if(t===null||t===Object.prototype)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;if(n===Object)return!0;if(typeof n!="function")return!1;let r=Bf.get(n);return r===void 0&&(r=Function.toString.call(n),Bf.set(n,r)),r===WE}function zs(e,t,n=!0){pa(e)===0?(n?Reflect.ownKeys(e):Object.keys(e)).forEach((r=>{t(r,e[r],e)})):e.forEach(((r,o)=>t(o,r,e)))}function pa(e){const t=e[Vt];return t?t.type_:Array.isArray(e)?1:Ki(e)?2:ma(e)?3:0}function rc(e,t){return pa(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function D0(e,t,n){const r=pa(e);r===2?e.set(t,n):r===3?e.add(n):e[t]=n}function Ki(e){return e instanceof Map}function ma(e){return e instanceof Set}function xr(e){return e.copy_||e.base_}function oc(e,t){if(Ki(e))return new Map(e);if(ma(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const n=E0(e);if(t===!0||t==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(e);delete r[Vt];let o=Reflect.ownKeys(r);for(let i=0;i<o.length;i++){const s=o[i],a=r[s];a.writable===!1&&(a.writable=!0,a.configurable=!0),(a.get||a.set)&&(r[s]={configurable:!0,writable:!0,enumerable:a.enumerable,value:e[s]})}return Object.create(Ii(e),r)}{const r=Ii(e);if(r!==null&&n)return{...e};const o=Object.create(r);return Object.assign(o,e)}}function Bl(e,t=!1){return ga(e)||Ur(e)||!zr(e)||(pa(e)>1&&Object.defineProperties(e,{set:fs,add:fs,clear:fs,delete:fs}),Object.freeze(e),t&&Object.values(e).forEach((n=>Bl(n,!0)))),e}var fs={value:function(){sn(2)}};function ga(e){return e===null||typeof e!="object"||Object.isFrozen(e)}var Ti,zE={};function Kr(e){const t=zE[e];return t||sn(0),t}function Ff(){return Ti}function Rf(e,t){t&&(Kr("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function ic(e){sc(e),e.drafts_.forEach(KE),e.drafts_=null}function sc(e){e===Ti&&(Ti=e.parent_)}function jf(e){return Ti={drafts_:[],parent_:Ti,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function KE(e){const t=e[Vt];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Mf(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return e!==void 0&&e!==n?(n[Vt].modified_&&(ic(t),sn(4)),zr(e)&&(e=Ks(t,e),t.parent_||qs(t,e)),t.patches_&&Kr("Patches").generateReplacementPatches_(n[Vt].base_,e,t.patches_,t.inversePatches_)):e=Ks(t,n,[]),ic(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==w0?e:void 0}function Ks(e,t,n){if(ga(t))return t;const r=e.immer_.shouldUseStrictIteration(),o=t[Vt];if(!o)return zs(t,((i,s)=>Pf(e,o,t,i,s,n)),r),t;if(o.scope_!==e)return t;if(!o.modified_)return qs(e,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;const i=o.copy_;let s=i,a=!1;o.type_===3&&(s=new Set(i),i.clear(),a=!0),zs(s,((u,c)=>Pf(e,o,i,u,c,n,a)),r),qs(e,i,!1),n&&e.patches_&&Kr("Patches").generatePatches_(o,n,e.patches_,e.inversePatches_)}return o.copy_}function Pf(e,t,n,r,o,i,s){if(o==null||typeof o!="object"&&!s)return;const a=ga(o);if(!a||s){if(Ur(o)){const u=Ks(e,o,i&&t&&t.type_!==3&&!rc(t.assigned_,r)?i.concat(r):void 0);if(D0(n,r,u),!Ur(u))return;e.canAutoFreeze_=!1}else s&&n.add(o);if(zr(o)&&!a){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1||t&&t.base_&&t.base_[r]===o&&a)return;Ks(e,o),t&&t.scope_.parent_||typeof r=="symbol"||!(Ki(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))||qs(e,o)}}}function qs(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Bl(t,n)}var ac={get(e,t){if(t===Vt)return e;const n=xr(e);if(!rc(n,t))return(function(o,i,s){const a=Nf(i,s);return a?"value"in a?a.value:a.get?.call(o.draft_):void 0})(e,n,t);const r=n[t];return e.finalized_||!zr(r)?r:r===nu(e.base_,t)?(ru(e),e.copy_[t]=cc(r,e)):r},has:(e,t)=>t in xr(e),ownKeys:e=>Reflect.ownKeys(xr(e)),set(e,t,n){const r=Nf(xr(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const o=nu(xr(e),t),i=o?.[Vt];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if((function(s,a){return s===a?s!==0||1/s==1/a:s!=s&&a!=a})(n,o)&&(n!==void 0||rc(e.base_,t)))return!0;ru(e),uc(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty:(e,t)=>(nu(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,ru(e),uc(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=xr(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:r.enumerable,value:n[t]}},defineProperty(){sn(11)},getPrototypeOf:e=>Ii(e.base_),setPrototypeOf(){sn(12)}},ii={};function nu(e,t){const n=e[Vt];return(n?xr(n):e)[t]}function Nf(e,t){if(!(t in e))return;let n=Ii(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Ii(n)}}function uc(e){e.modified_||(e.modified_=!0,e.parent_&&uc(e.parent_))}function ru(e){e.copy_||(e.copy_=oc(e.base_,e.scope_.immer_.useStrictShallowCopy_))}zs(ac,((e,t)=>{ii[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),ii.deleteProperty=function(e,t){return ii.set.call(this,e,t,void 0)},ii.set=function(e,t,n){return ac.set.call(this,e[0],t,n,e[0])};function cc(e,t){const n=Ki(e)?Kr("MapSet").proxyMap_(e,t):ma(e)?Kr("MapSet").proxySet_(e,t):(function(r,o){const i=Array.isArray(r),s={type_:i?1:0,scope_:o?o.scope_:Ff(),modified_:!1,finalized_:!1,assigned_:{},parent_:o,base_:r,draft_:null,copy_:null,revoke_:null,isManual_:!1};let a=s,u=ac;i&&(a=[s],u=ii);const{revoke:c,proxy:f}=Proxy.revocable(a,u);return s.draft_=f,s.revoke_=c,f})(e,t);return(t?t.scope_:Ff()).drafts_.push(n),n}function A0(e){if(!zr(e)||ga(e))return e;const t=e[Vt];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=oc(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=oc(e,!0);return zs(n,((o,i)=>{D0(n,o,A0(i))}),r),t&&(t.finalized_=!1),n}var ki=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(t,n,r)=>{if(typeof t=="function"&&typeof n!="function"){const i=n;n=t;const s=this;return function(a=i,...u){return s.produce(a,(c=>n.call(this,c,...u)))}}let o;if(typeof n!="function"&&sn(6),r!==void 0&&typeof r!="function"&&sn(7),zr(t)){const i=jf(this),s=cc(t,void 0);let a=!0;try{o=n(s),a=!1}finally{a?ic(i):sc(i)}return Rf(i,r),Mf(o,i)}if(!t||typeof t!="object"){if(o=n(t),o===void 0&&(o=t),o===w0&&(o=void 0),this.autoFreeze_&&Bl(o,!0),r){const i=[],s=[];Kr("Patches").generateReplacementPatches_(t,o,i,s),r(i,s)}return o}sn(1)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(i,...s)=>this.produceWithPatches(i,(a=>t(a,...s)));let r,o;return[this.produce(t,n,((i,s)=>{r=i,o=s})),r,o]},typeof e?.autoFreeze=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof e?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),typeof e?.useStrictIteration=="boolean"&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){zr(e)||sn(8),Ur(e)&&(e=(function(r){return Ur(r)||sn(10),A0(r)})(e));const t=jf(this),n=cc(e,void 0);return n[Vt].isManual_=!0,sc(t),n}finishDraft(e,t){const n=e&&e[Vt];n&&n.isManual_||sn(9);const{scope_:r}=n;return Rf(r,t),Mf(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const o=t[n];if(o.path.length===0&&o.op==="replace"){e=o.value;break}}n>-1&&(t=t.slice(n+1));const r=Kr("Patches").applyPatches_;return Ur(e)?r(e,t):this.produce(e,(o=>r(o,t)))}},Fl=ki.produce,Lf=ki.createDraft.bind(ki),Uf=ki.finishDraft.bind(ki),qE={transform(e,t){var{current:n,affinity:r}=e;if(n!=null){var o=F.transform(n,t,{affinity:r});e.current=o,o==null&&e.unref()}}},GE={transform(e,t){var{current:n,affinity:r}=e;if(n!=null){var o=Re.transform(n,t,{affinity:r});e.current=o,o==null&&e.unref()}}},JE={transform(e,t){var{current:n,affinity:r}=e;if(n!=null){var o=U.transform(n,t,{affinity:r});e.current=o,o==null&&e.unref()}}},Gs=new WeakMap,Js=new WeakMap,fi=new WeakMap,Hf=new WeakMap,Vf=new WeakMap,$f=new WeakMap,Wf=new WeakMap,F={ancestors(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{reverse:n=!1}=t,r=F.levels(e,t);return r=n?r.slice(1):r.slice(0,-1)},common(e,t){for(var n=[],r=0;r<e.length&&r<t.length;r++){var o=e[r];if(o!==t[r])break;n.push(o)}return n},compare(e,t){for(var n=Math.min(e.length,t.length),r=0;r<n;r++){if(e[r]<t[r])return-1;if(e[r]>t[r])return 1}return 0},endsAfter(e,t){var n=e.length-1,r=e.slice(0,n),o=t.slice(0,n),i=e[n],s=t[n];return F.equals(r,o)&&i>s},endsAt(e,t){var n=e.length,r=e.slice(0,n),o=t.slice(0,n);return F.equals(r,o)},endsBefore(e,t){var n=e.length-1,r=e.slice(0,n),o=t.slice(0,n),i=e[n],s=t[n];return F.equals(r,o)&&i<s},equals:(e,t)=>e.length===t.length&&e.every(((n,r)=>n===t[r])),hasPrevious:e=>e[e.length-1]>0,isAfter:(e,t)=>F.compare(e,t)===1,isAncestor:(e,t)=>e.length<t.length&&F.compare(e,t)===0,isBefore:(e,t)=>F.compare(e,t)===-1,isChild:(e,t)=>e.length===t.length+1&&F.compare(e,t)===0,isCommon:(e,t)=>e.length<=t.length&&F.compare(e,t)===0,isDescendant:(e,t)=>e.length>t.length&&F.compare(e,t)===0,isParent:(e,t)=>e.length+1===t.length&&F.compare(e,t)===0,isPath:e=>Array.isArray(e)&&(e.length===0||typeof e[0]=="number"),isSibling(e,t){if(e.length!==t.length)return!1;var n=e.slice(0,-1),r=t.slice(0,-1);return e[e.length-1]!==t[t.length-1]&&F.equals(n,r)},levels(e){for(var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{reverse:n=!1}=t,r=[],o=0;o<=e.length;o++)r.push(e.slice(0,o));return n&&r.reverse(),r},next(e){if(e.length===0)throw new Error("Cannot get the next path of a root path [".concat(e,"], because it has no next index."));var t=e[e.length-1];return e.slice(0,-1).concat(t+1)},operationCanTransformPath(e){switch(e.type){case"insert_node":case"remove_node":case"merge_node":case"split_node":case"move_node":return!0;default:return!1}},parent(e){if(e.length===0)throw new Error("Cannot get the parent path of the root path [".concat(e,"]."));return e.slice(0,-1)},previous(e){if(e.length===0)throw new Error("Cannot get the previous path of a root path [".concat(e,"], because it has no previous index."));var t=e[e.length-1];if(t<=0)throw new Error("Cannot get the previous path of a first child path [".concat(e,"] because it would result in a negative index."));return e.slice(0,-1).concat(t-1)},relative(e,t){if(!F.isAncestor(t,e)&&!F.equals(e,t))throw new Error("Cannot get the relative path of [".concat(e,"] inside ancestor [").concat(t,"], because it is not above or equal to the path."));return e.slice(t.length)},transform(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(!e)return null;var r=[...e],{affinity:o="forward"}=n;if(e.length===0)return r;switch(t.type){case"insert_node":var{path:i}=t;(F.equals(i,r)||F.endsBefore(i,r)||F.isAncestor(i,r))&&(r[i.length-1]+=1);break;case"remove_node":var{path:s}=t;if(F.equals(s,r)||F.isAncestor(s,r))return null;F.endsBefore(s,r)&&(r[s.length-1]-=1);break;case"merge_node":var{path:a,position:u}=t;F.equals(a,r)||F.endsBefore(a,r)?r[a.length-1]-=1:F.isAncestor(a,r)&&(r[a.length-1]-=1,r[a.length]+=u);break;case"split_node":var{path:c,position:f}=t;if(F.equals(c,r)){if(o==="forward")r[r.length-1]+=1;else if(o!=="backward")return null}else F.endsBefore(c,r)?r[c.length-1]+=1:F.isAncestor(c,r)&&e[c.length]>=f&&(r[c.length-1]+=1,r[c.length]-=f);break;case"move_node":var{path:l,newPath:d}=t;if(F.equals(l,d))return r;if(F.isAncestor(l,r)||F.equals(l,r)){var h=d.slice();return F.endsBefore(l,d)&&l.length<d.length&&(h[l.length-1]-=1),h.concat(r.slice(l.length))}F.isSibling(l,d)&&(F.isAncestor(d,r)||F.equals(d,r))?F.endsBefore(l,r)?r[l.length-1]-=1:r[l.length-1]+=1:F.endsBefore(d,r)||F.equals(d,r)||F.isAncestor(d,r)?(F.endsBefore(l,r)&&(r[l.length-1]-=1),r[d.length-1]+=1):F.endsBefore(l,r)&&(F.equals(d,r)&&(r[d.length-1]+=1),r[l.length-1]-=1)}return r}};function hi(e){return hi=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},hi(e)}function ZE(e){var t=(function(n,r){if(hi(n)!=="object"||n===null)return n;var o=n[Symbol.toPrimitive];if(o!==void 0){var i=o.call(n,r);if(hi(i)!=="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(n)})(e,"string");return hi(t)==="symbol"?t:String(t)}function kt(e,t,n){return(t=ZE(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function zf(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable}))),n.push.apply(n,r)}return n}function ti(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?zf(Object(n),!0).forEach((function(r){kt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):zf(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var XE={transform(e,t){e.children=Lf(e.children);var n=e.selection&&Lf(e.selection);try{n=((r,o,i)=>{switch(i.type){case"insert_node":var{path:s,node:a}=i,u=ee.parent(r,s),c=s[s.length-1];if(c>u.children.length)throw new Error('Cannot apply an "insert_node" operation at path ['.concat(s,"] because the destination is past the end of the node."));if(u.children.splice(c,0,a),o)for(var[f,l]of U.points(o))o[l]=Re.transform(f,i);break;case"insert_text":var{path:d,offset:h,text:g}=i;if(g.length===0)break;var y=ee.leaf(r,d),p=y.text.slice(0,h),w=y.text.slice(h);if(y.text=p+g+w,o)for(var[b,C]of U.points(o))o[C]=Re.transform(b,i);break;case"merge_node":var{path:E}=i,A=ee.get(r,E),x=F.previous(E),I=ee.get(r,x),T=ee.parent(r,E),B=E[E.length-1];if(he.isText(A)&&he.isText(I))I.text+=A.text;else{if(he.isText(A)||he.isText(I))throw new Error('Cannot apply a "merge_node" operation at path ['.concat(E,"] to nodes of different interfaces: ").concat(ht.stringify(A)," ").concat(ht.stringify(I)));I.children.push(...A.children)}if(T.children.splice(B,1),o)for(var[S,k]of U.points(o))o[k]=Re.transform(S,i);break;case"move_node":var{path:R,newPath:M}=i;if(F.isAncestor(R,M))throw new Error("Cannot move a path [".concat(R,"] to new path [").concat(M,"] because the destination is inside itself."));var H=ee.get(r,R),W=ee.parent(r,R),G=R[R.length-1];W.children.splice(G,1);var q=F.transform(R,i),$=ee.get(r,F.parent(q)),V=q[q.length-1];if($.children.splice(V,0,H),o)for(var[Q,ae]of U.points(o))o[ae]=Re.transform(Q,i);break;case"remove_node":var{path:ie}=i,Se=ie[ie.length-1];if(ee.parent(r,ie).children.splice(Se,1),o)for(var[Ie,ne]of U.points(o)){var _=Re.transform(Ie,i);if(o!=null&&_!=null)o[ne]=_;else{var X=void 0,K=void 0;for(var[Y,de]of ee.texts(r)){if(F.compare(de,ie)!==-1){K=[Y,de];break}X=[Y,de]}var pe=!1;X&&K&&(pe=F.equals(K[1],ie)?!F.hasPrevious(K[1]):F.common(X[1],ie).length<F.common(K[1],ie).length),X&&!pe?(Ie.path=X[1],Ie.offset=X[0].text.length):K?(Ie.path=K[1],Ie.offset=0):o=null}}break;case"remove_text":var{path:fe,offset:we,text:Ce}=i;if(Ce.length===0)break;var se=ee.leaf(r,fe),te=se.text.slice(0,we),me=se.text.slice(we+Ce.length);if(se.text=te+me,o)for(var[Ae,Pe]of U.points(o))o[Pe]=Re.transform(Ae,i);break;case"set_node":var{path:Be,properties:re,newProperties:J}=i;if(Be.length===0)throw new Error("Cannot set properties on the root node!");var oe=ee.get(r,Be);for(var ge in J){if(ge==="children"||ge==="text")throw new Error('Cannot set the "'.concat(ge,'" property of nodes!'));var ve=J[ge];ve==null?delete oe[ge]:oe[ge]=ve}for(var Te in re)J.hasOwnProperty(Te)||delete oe[Te];break;case"set_selection":var{newProperties:We}=i;if(We==null)o=We;else{if(o==null){if(!U.isRange(We))throw new Error('Cannot apply an incomplete "set_selection" operation properties '.concat(ht.stringify(We)," when there is no current selection."));o=ti({},We)}for(var Le in We){var et=We[Le];if(et==null){if(Le==="anchor"||Le==="focus")throw new Error('Cannot remove the "'.concat(Le,'" selection property'));delete o[Le]}else o[Le]=et}}break;case"split_node":var{path:ut,position:Nt,properties:mn}=i;if(ut.length===0)throw new Error('Cannot apply a "split_node" operation at path ['.concat(ut,"] because the root node cannot be split."));var Zn,gn=ee.get(r,ut),qi=ee.parent(r,ut),ba=ut[ut.length-1];if(he.isText(gn)){var qo=gn.text.slice(0,Nt),Gi=gn.text.slice(Nt);gn.text=qo,Zn=ti(ti({},mn),{},{text:Gi})}else{var Ji=gn.children.slice(0,Nt),Go=gn.children.slice(Nt);gn.children=Ji,Zn=ti(ti({},mn),{},{children:Go})}if(qi.children.splice(ba+1,0,Zn),o)for(var[Jo,O]of U.points(o))o[O]=Re.transform(Jo,i)}return o})(e,n,t)}finally{e.children=Uf(e.children),e.selection=n?Ur(n)?Uf(n):n:null}}},YE={insertNodes(e,t,n){e.insertNodes(t,n)},liftNodes(e,t){e.liftNodes(t)},mergeNodes(e,t){e.mergeNodes(t)},moveNodes(e,t){e.moveNodes(t)},removeNodes(e,t){e.removeNodes(t)},setNodes(e,t,n){e.setNodes(t,n)},splitNodes(e,t){e.splitNodes(t)},unsetNodes(e,t,n){e.unsetNodes(t,n)},unwrapNodes(e,t){e.unwrapNodes(t)},wrapNodes(e,t,n){e.wrapNodes(t,n)}},QE={collapse(e,t){e.collapse(t)},deselect(e){e.deselect()},move(e,t){e.move(t)},select(e,t){e.select(t)},setPoint(e,t,n){e.setPoint(t,n)},setSelection(e,t){e.setSelection(t)}},x0=(e,t)=>{for(var n in e){var r=e[n],o=t[n];if(ft(r)&&ft(o)){if(!x0(r,o))return!1}else if(Array.isArray(r)&&Array.isArray(o)){if(r.length!==o.length)return!1;for(var i=0;i<r.length;i++)if(r[i]!==o[i])return!1}else if(r!==o)return!1}for(var s in t)if(e[s]===void 0&&t[s]!==void 0)return!1;return!0};function Nn(e,t){if(e==null)return{};var n,r,o=(function(s,a){if(s==null)return{};var u,c,f={},l=Object.keys(s);for(c=0;c<l.length;c++)u=l[c],a.indexOf(u)>=0||(f[u]=s[u]);return f})(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var eD=["anchor","focus"];function Kf(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable}))),n.push.apply(n,r)}return n}var U={edges(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{reverse:n=!1}=t,{anchor:r,focus:o}=e;return U.isBackward(e)===n?[r,o]:[o,r]},end(e){var[,t]=U.edges(e);return t},equals:(e,t)=>Re.equals(e.anchor,t.anchor)&&Re.equals(e.focus,t.focus),surrounds(e,t){var n=U.intersection(e,t);return!!n&&U.equals(n,t)},includes(e,t){if(U.isRange(t)){if(U.includes(e,t.anchor)||U.includes(e,t.focus))return!0;var[n,r]=U.edges(e),[o,i]=U.edges(t);return Re.isBefore(n,o)&&Re.isAfter(r,i)}var[s,a]=U.edges(e),u=!1,c=!1;return Re.isPoint(t)?(u=Re.compare(t,s)>=0,c=Re.compare(t,a)<=0):(u=F.compare(t,s.path)>=0,c=F.compare(t,a.path)<=0),u&&c},intersection(e,t){var n=Nn(e,eD),[r,o]=U.edges(e),[i,s]=U.edges(t),a=Re.isBefore(r,i)?i:r,u=Re.isBefore(o,s)?o:s;return Re.isBefore(u,a)?null:(function(c){for(var f=1;f<arguments.length;f++){var l=arguments[f]!=null?arguments[f]:{};f%2?Kf(Object(l),!0).forEach((function(d){kt(c,d,l[d])})):Object.getOwnPropertyDescriptors?Object.defineProperties(c,Object.getOwnPropertyDescriptors(l)):Kf(Object(l)).forEach((function(d){Object.defineProperty(c,d,Object.getOwnPropertyDescriptor(l,d))}))}return c})({anchor:a,focus:u},n)},isBackward(e){var{anchor:t,focus:n}=e;return Re.isAfter(t,n)},isCollapsed(e){var{anchor:t,focus:n}=e;return Re.equals(t,n)},isExpanded:e=>!U.isCollapsed(e),isForward:e=>!U.isBackward(e),isRange:e=>ft(e)&&Re.isPoint(e.anchor)&&Re.isPoint(e.focus),*points(e){yield[e.anchor,"anchor"],yield[e.focus,"focus"]},start(e){var[t]=U.edges(e);return t},transform(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return Fl(e,(r=>{if(r===null)return null;var o,i,{affinity:s="inward"}=n;if(s==="inward"){var a=U.isCollapsed(r);U.isForward(r)?(o="forward",i=a?o:"backward"):(o="backward",i=a?o:"forward")}else s==="outward"?U.isForward(r)?(o="backward",i="forward"):(o="forward",i="backward"):(o=s,i=s);var u=Re.transform(r.anchor,t,{affinity:o}),c=Re.transform(r.focus,t,{affinity:i});if(!u||!c)return null;r.anchor=u,r.focus=c}))}},qf=e=>ft(e)&&ee.isNodeList(e.children)&&!D.isEditor(e),le={isAncestor:e=>ft(e)&&ee.isNodeList(e.children),isElement:qf,isElementList:e=>Array.isArray(e)&&e.every((t=>le.isElement(t))),isElementProps:e=>e.children!==void 0,isElementType:function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"type";return qf(e)&&e[n]===t},matches(e,t){for(var n in t)if(n!=="children"&&e[n]!==t[n])return!1;return!0}},tD=["children"],nD=["text"],Gf=new WeakMap,ee={ancestor(e,t){var n=ee.get(e,t);if(he.isText(n))throw new Error("Cannot get the ancestor node at path [".concat(t,"] because it refers to a text node instead: ").concat(ht.stringify(n)));return n},ancestors(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return(function*(){for(var r of F.ancestors(t,n)){var o=[ee.ancestor(e,r),r];yield o}})()},child(e,t){if(he.isText(e))throw new Error("Cannot get the child of a text node: ".concat(ht.stringify(e)));var n=e.children[t];if(n==null)throw new Error("Cannot get child at index `".concat(t,"` in node: ").concat(ht.stringify(e)));return n},children(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return(function*(){for(var{reverse:r=!1}=n,o=ee.ancestor(e,t),{children:i}=o,s=r?i.length-1:0;r?s>=0:s<i.length;){var a=ee.child(o,s),u=t.concat(s);yield[a,u],s=r?s-1:s+1}})()},common(e,t,n){var r=F.common(t,n);return[ee.get(e,r),r]},descendant(e,t){var n=ee.get(e,t);if(D.isEditor(n))throw new Error("Cannot get the descendant node at path [".concat(t,"] because it refers to the root editor node instead: ").concat(ht.stringify(n)));return n},descendants(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return(function*(){for(var[n,r]of ee.nodes(e,t))r.length!==0&&(yield[n,r])})()},elements(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return(function*(){for(var[n,r]of ee.nodes(e,t))le.isElement(n)&&(yield[n,r])})()},extractProps:e=>le.isAncestor(e)?Nn(e,tD):Nn(e,nD),first(e,t){for(var n=t.slice(),r=ee.get(e,n);r&&!he.isText(r)&&r.children.length!==0;)r=r.children[0],n.push(0);return[r,n]},fragment(e,t){if(he.isText(e))throw new Error("Cannot get a fragment starting from a root text node: ".concat(ht.stringify(e)));var n=Fl({children:e.children},(r=>{var[o,i]=U.edges(t),s=ee.nodes(r,{reverse:!0,pass:d=>{var[,h]=d;return!U.includes(t,h)}});for(var[,a]of s){if(!U.includes(t,a)){var u=ee.parent(r,a),c=a[a.length-1];u.children.splice(c,1)}if(F.equals(a,i.path)){var f=ee.leaf(r,a);f.text=f.text.slice(0,i.offset)}if(F.equals(a,o.path)){var l=ee.leaf(r,a);l.text=l.text.slice(o.offset)}}D.isEditor(r)&&(r.selection=null)}));return n.children},get(e,t){var n=ee.getIf(e,t);if(n===void 0)throw new Error("Cannot find a descendant at path [".concat(t,"] in node: ").concat(ht.stringify(e)));return n},getIf(e,t){for(var n=e,r=0;r<t.length;r++){var o=t[r];if(he.isText(n)||!n.children[o])return;n=n.children[o]}return n},has(e,t){for(var n=e,r=0;r<t.length;r++){var o=t[r];if(he.isText(n)||!n.children[o])return!1;n=n.children[o]}return!0},isNode:e=>he.isText(e)||le.isElement(e)||D.isEditor(e),isNodeList(e){if(!Array.isArray(e))return!1;var t=Gf.get(e);if(t!==void 0)return t;var n=e.every((r=>ee.isNode(r)));return Gf.set(e,n),n},last(e,t){for(var n=t.slice(),r=ee.get(e,n);r&&!he.isText(r)&&r.children.length!==0;){var o=r.children.length-1;r=r.children[o],n.push(o)}return[r,n]},leaf(e,t){var n=ee.get(e,t);if(!he.isText(n))throw new Error("Cannot get the leaf node at path [".concat(t,"] because it refers to a non-leaf node: ").concat(ht.stringify(n)));return n},levels(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return(function*(){for(var r of F.levels(t,n)){var o=ee.get(e,r);yield[o,r]}})()},matches:(e,t)=>le.isElement(e)&&le.isElementProps(t)&&le.matches(e,t)||he.isText(e)&&he.isTextProps(t)&&he.matches(e,t),nodes(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return(function*(){for(var{pass:n,reverse:r=!1}=t,{from:o=[],to:i}=t,s=new Set,a=[],u=e;!i||!(r?F.isBefore(a,i):F.isAfter(a,i));)if(s.has(u)||(yield[u,a]),s.has(u)||he.isText(u)||u.children.length===0||n!=null&&n([u,a])!==!1){if(a.length===0)break;if(!r){var c=F.next(a);if(ee.has(e,c)){a=c,u=ee.get(e,a);continue}}r&&a[a.length-1]!==0?(a=F.previous(a),u=ee.get(e,a)):(a=F.parent(a),u=ee.get(e,a),s.add(u))}else{s.add(u);var f=r?u.children.length-1:0;F.isAncestor(a,o)&&(f=o[a.length]),a=a.concat(f),u=ee.get(e,a)}})()},parent(e,t){var n=F.parent(t),r=ee.get(e,n);if(he.isText(r))throw new Error("Cannot get the parent of path [".concat(t,"] because it does not exist in the root."));return r},string:e=>he.isText(e)?e.text:e.children.map(ee.string).join(""),texts(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return(function*(){for(var[n,r]of ee.nodes(e,t))he.isText(n)&&(yield[n,r])})()}};function Jf(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable}))),n.push.apply(n,r)}return n}function nt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Jf(Object(n),!0).forEach((function(r){kt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Jf(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var lr={isNodeOperation:e=>lr.isOperation(e)&&e.type.endsWith("_node"),isOperation(e){if(!ft(e))return!1;switch(e.type){case"insert_node":case"remove_node":return F.isPath(e.path)&&ee.isNode(e.node);case"insert_text":case"remove_text":return typeof e.offset=="number"&&typeof e.text=="string"&&F.isPath(e.path);case"merge_node":return typeof e.position=="number"&&F.isPath(e.path)&&ft(e.properties);case"move_node":return F.isPath(e.path)&&F.isPath(e.newPath);case"set_node":return F.isPath(e.path)&&ft(e.properties)&&ft(e.newProperties);case"set_selection":return e.properties===null&&U.isRange(e.newProperties)||e.newProperties===null&&U.isRange(e.properties)||ft(e.properties)&&ft(e.newProperties);case"split_node":return F.isPath(e.path)&&typeof e.position=="number"&&ft(e.properties);default:return!1}},isOperationList:e=>Array.isArray(e)&&e.every((t=>lr.isOperation(t))),isSelectionOperation:e=>lr.isOperation(e)&&e.type.endsWith("_selection"),isTextOperation:e=>lr.isOperation(e)&&e.type.endsWith("_text"),inverse(e){switch(e.type){case"insert_node":return nt(nt({},e),{},{type:"remove_node"});case"insert_text":return nt(nt({},e),{},{type:"remove_text"});case"merge_node":return nt(nt({},e),{},{type:"split_node",path:F.previous(e.path)});case"move_node":var{newPath:t,path:n}=e;if(F.equals(t,n))return e;if(F.isSibling(n,t))return nt(nt({},e),{},{path:t,newPath:n});var r=F.transform(n,e),o=F.transform(F.next(n),e);return nt(nt({},e),{},{path:r,newPath:o});case"remove_node":return nt(nt({},e),{},{type:"insert_node"});case"remove_text":return nt(nt({},e),{},{type:"insert_text"});case"set_node":var{properties:i,newProperties:s}=e;return nt(nt({},e),{},{properties:s,newProperties:i});case"set_selection":var{properties:a,newProperties:u}=e;return nt(nt({},e),{},a==null?{properties:u,newProperties:null}:u==null?{properties:null,newProperties:a}:{properties:u,newProperties:a});case"split_node":return nt(nt({},e),{},{type:"merge_node",path:F.next(e.path)})}}},Zf=new WeakMap,D={above:(e,t)=>e.above(t),addMark(e,t,n){e.addMark(t,n)},after:(e,t,n)=>e.after(t,n),before:(e,t,n)=>e.before(t,n),deleteBackward(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{unit:n="character"}=t;e.deleteBackward(n)},deleteForward(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{unit:n="character"}=t;e.deleteForward(n)},deleteFragment(e,t){e.deleteFragment(t)},edges:(e,t)=>e.edges(t),elementReadOnly(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return e.elementReadOnly(t)},end:(e,t)=>e.end(t),first:(e,t)=>e.first(t),fragment:(e,t)=>e.fragment(t),hasBlocks:(e,t)=>e.hasBlocks(t),hasInlines:(e,t)=>e.hasInlines(t),hasPath:(e,t)=>e.hasPath(t),hasTexts:(e,t)=>e.hasTexts(t),insertBreak(e){e.insertBreak()},insertFragment(e,t,n){e.insertFragment(t,n)},insertNode(e,t){e.insertNode(t)},insertSoftBreak(e){e.insertSoftBreak()},insertText(e,t){e.insertText(t)},isBlock:(e,t)=>e.isBlock(t),isEdge:(e,t,n)=>e.isEdge(t,n),isEditor:e=>(t=>{var n=Zf.get(t);if(n!==void 0)return n;if(!ft(t))return!1;var r=typeof t.addMark=="function"&&typeof t.apply=="function"&&typeof t.deleteFragment=="function"&&typeof t.insertBreak=="function"&&typeof t.insertSoftBreak=="function"&&typeof t.insertFragment=="function"&&typeof t.insertNode=="function"&&typeof t.insertText=="function"&&typeof t.isElementReadOnly=="function"&&typeof t.isInline=="function"&&typeof t.isSelectable=="function"&&typeof t.isVoid=="function"&&typeof t.normalizeNode=="function"&&typeof t.onChange=="function"&&typeof t.removeMark=="function"&&typeof t.getDirtyPaths=="function"&&(t.marks===null||ft(t.marks))&&(t.selection===null||U.isRange(t.selection))&&ee.isNodeList(t.children)&&lr.isOperationList(t.operations);return Zf.set(t,r),r})(e),isElementReadOnly:(e,t)=>e.isElementReadOnly(t),isEmpty:(e,t)=>e.isEmpty(t),isEnd:(e,t,n)=>e.isEnd(t,n),isInline:(e,t)=>e.isInline(t),isNormalizing:e=>e.isNormalizing(),isSelectable:(e,t)=>e.isSelectable(t),isStart:(e,t,n)=>e.isStart(t,n),isVoid:(e,t)=>e.isVoid(t),last:(e,t)=>e.last(t),leaf:(e,t,n)=>e.leaf(t,n),levels:(e,t)=>e.levels(t),marks:e=>e.getMarks(),next:(e,t)=>e.next(t),node:(e,t,n)=>e.node(t,n),nodes:(e,t)=>e.nodes(t),normalize(e,t){e.normalize(t)},parent:(e,t,n)=>e.parent(t,n),path:(e,t,n)=>e.path(t,n),pathRef:(e,t,n)=>e.pathRef(t,n),pathRefs:e=>e.pathRefs(),point:(e,t,n)=>e.point(t,n),pointRef:(e,t,n)=>e.pointRef(t,n),pointRefs:e=>e.pointRefs(),positions:(e,t)=>e.positions(t),previous:(e,t)=>e.previous(t),range:(e,t,n)=>e.range(t,n),rangeRef:(e,t,n)=>e.rangeRef(t,n),rangeRefs:e=>e.rangeRefs(),removeMark(e,t){e.removeMark(t)},setNormalizing(e,t){e.setNormalizing(t)},start:(e,t)=>e.start(t),string:(e,t,n)=>e.string(t,n),unhangRange:(e,t,n)=>e.unhangRange(t,n),void:(e,t)=>e.void(t),withoutNormalizing(e,t){e.withoutNormalizing(t)},shouldMergeNodesRemovePrevNode:(e,t,n)=>e.shouldMergeNodesRemovePrevNode(t,n)},rD={isSpan:e=>Array.isArray(e)&&e.length===2&&e.every(F.isPath)};function Xf(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable}))),n.push.apply(n,r)}return n}function Yf(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Xf(Object(n),!0).forEach((function(r){kt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Xf(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var Re={compare(e,t){var n=F.compare(e.path,t.path);return n===0?e.offset<t.offset?-1:e.offset>t.offset?1:0:n},isAfter:(e,t)=>Re.compare(e,t)===1,isBefore:(e,t)=>Re.compare(e,t)===-1,equals:(e,t)=>e.offset===t.offset&&F.equals(e.path,t.path),isPoint:e=>ft(e)&&typeof e.offset=="number"&&F.isPath(e.path),transform(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return Fl(e,(r=>{if(r===null)return null;var{affinity:o="forward"}=n,{path:i,offset:s}=r;switch(t.type){case"insert_node":case"move_node":r.path=F.transform(i,t,n);break;case"insert_text":F.equals(t.path,i)&&(t.offset<s||t.offset===s&&o==="forward")&&(r.offset+=t.text.length);break;case"merge_node":F.equals(t.path,i)&&(r.offset+=t.position),r.path=F.transform(i,t,n);break;case"remove_text":F.equals(t.path,i)&&t.offset<=s&&(r.offset-=Math.min(s-t.offset,t.text.length));break;case"remove_node":if(F.equals(t.path,i)||F.isAncestor(t.path,i))return null;r.path=F.transform(i,t,n);break;case"split_node":if(F.equals(t.path,i)){if(t.position===s&&o==null)return null;(t.position<s||t.position===s&&o==="forward")&&(r.offset-=t.position,r.path=F.transform(i,t,Yf(Yf({},n),{},{affinity:"forward"})))}else r.path=F.transform(i,t,n)}}))}},Qf=void 0,ht={setScrubber(e){Qf=e},stringify:e=>JSON.stringify(e,Qf)},oD=["text"],iD=["anchor","focus"];function eh(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable}))),n.push.apply(n,r)}return n}function Bn(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?eh(Object(n),!0).forEach((function(r){kt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):eh(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var ke,he={equals(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{loose:r=!1}=n;function o(i){return Nn(i,oD)}return x0(r?o(e):e,r?o(t):t)},isText:e=>ft(e)&&typeof e.text=="string",isTextList:e=>Array.isArray(e)&&e.every((t=>he.isText(t))),isTextProps:e=>e.text!==void 0,matches(e,t){for(var n in t)if(n!=="text"&&(!e.hasOwnProperty(n)||e[n]!==t[n]))return!1;return!0},decorations(e,t){var n=[Bn({},e)];for(var r of t){var o=Nn(r,iD),[i,s]=U.edges(r),a=[],u=0,c=i.offset,f=s.offset;for(var l of n){var{length:d}=l.text,h=u;if(u+=d,c<=h&&u<=f)Object.assign(l,o),a.push(l);else if(c!==f&&(c===u||f===h)||c>u||f<h||f===h&&h!==0)a.push(l);else{var g=l,y=void 0,p=void 0;if(f<u){var w=f-h;p=Bn(Bn({},g),{},{text:g.text.slice(w)}),g=Bn(Bn({},g),{},{text:g.text.slice(0,w)})}if(c>h){var b=c-h;y=Bn(Bn({},g),{},{text:g.text.slice(0,b)}),g=Bn(Bn({},g),{},{text:g.text.slice(b)})}Object.assign(g,o),y&&a.push(y),a.push(g),p&&a.push(p)}}n=a}return n}},Rl=e=>e.selection?e.selection:e.children.length>0?D.end(e,[]):[0],oo=(e,t)=>{var[n]=D.node(e,t);return r=>r===n},lc=function(e){var t=arguments.length>1&&arguments[1]!==void 0&&arguments[1],n=!t,r=t?lD(e):e,o=ke.None,i=ke.None,s=0,a=null;for(var u of r){var c=u.codePointAt(0);if(!c)break;var f=ED(u,c);if([o,i]=n?[i,f]:[f,o],go(o,ke.ZWJ)&&go(i,ke.ExtPict)&&!OD(n?e.substring(0,s):e.substring(0,e.length-s))||go(o,ke.RI)&&go(i,ke.RI)&&!(a=a!==null?!a:!!n||ID(e.substring(0,e.length-s)))||o!==ke.None&&i!==ke.None&&AD(o,i))break;s+=u.length}return s||1},sD=/\s/,aD=/[\u002B\u0021-\u0023\u0025-\u002A\u002C-\u002F\u003A\u003B\u003F\u0040\u005B-\u005D\u005F\u007B\u007D\u00A1\u00A7\u00AB\u00B6\u00B7\u00BB\u00BF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E3B\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]/,uD=/['\u2018\u2019]/,dc=(e,t,n)=>{if(n){var r=e.length-t;return[e.slice(r,e.length),e.slice(0,r)]}return[e.slice(0,t),e.slice(t)]},cD=function e(t,n){var r=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(sD.test(t))return!1;if(uD.test(t)){var o=lc(n,r),[i,s]=dc(n,o,r);if(e(i,s,r))return!0}return!aD.test(t)},lD=function*(e){for(var t=e.length-1,n=0;n<e.length;n++){var r=e.charAt(t-n);if(fD(r.charCodeAt(0))){var o=e.charAt(t-n-1);if(dD(o.charCodeAt(0))){yield o+r,n++;continue}}yield r}},dD=e=>e>=55296&&e<=56319,fD=e=>e>=56320&&e<=57343;(function(e){e[e.None=0]="None",e[e.Extend=1]="Extend",e[e.ZWJ=2]="ZWJ",e[e.RI=4]="RI",e[e.Prepend=8]="Prepend",e[e.SpacingMark=16]="SpacingMark",e[e.L=32]="L",e[e.V=64]="V",e[e.T=128]="T",e[e.LV=256]="LV",e[e.LVT=512]="LVT",e[e.ExtPict=1024]="ExtPict",e[e.Any=2048]="Any"})(ke||(ke={}));var hD=/^(?:[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0898-\u089F\u08CA-\u08E1\u08E3-\u0902\u093A\u093C\u0941-\u0948\u094D\u0951-\u0957\u0962\u0963\u0981\u09BC\u09BE\u09C1-\u09C4\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01\u0A02\u0A3C\u0A41\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81\u0A82\u0ABC\u0AC1-\u0AC5\u0AC7\u0AC8\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01\u0B3C\u0B3E\u0B3F\u0B41-\u0B44\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B82\u0BBE\u0BC0\u0BCD\u0BD7\u0C00\u0C04\u0C3C\u0C3E-\u0C40\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81\u0CBC\u0CBF\u0CC2\u0CC6\u0CCC\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00\u0D01\u0D3B\u0D3C\u0D3E\u0D41-\u0D44\u0D4D\u0D57\u0D62\u0D63\u0D81\u0DCA\u0DCF\u0DD2-\u0DD4\u0DD6\u0DDF\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECE\u0F18\u0F19\u0F35\u0F37\u0F39\u0F71-\u0F7E\u0F80-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102D-\u1030\u1032-\u1037\u1039\u103A\u103D\u103E\u1058\u1059\u105E-\u1060\u1071-\u1074\u1082\u1085\u1086\u108D\u109D\u135D-\u135F\u1712-\u1714\u1732\u1733\u1752\u1753\u1772\u1773\u17B4\u17B5\u17B7-\u17BD\u17C6\u17C9-\u17D3\u17DD\u180B-\u180D\u180F\u1885\u1886\u18A9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193B\u1A17\u1A18\u1A1B\u1A56\u1A58-\u1A5E\u1A60\u1A62\u1A65-\u1A6C\u1A73-\u1A7C\u1A7F\u1AB0-\u1ACE\u1B00-\u1B03\u1B34-\u1B3A\u1B3C\u1B42\u1B6B-\u1B73\u1B80\u1B81\u1BA2-\u1BA5\u1BA8\u1BA9\u1BAB-\u1BAD\u1BE6\u1BE8\u1BE9\u1BED\u1BEF-\u1BF1\u1C2C-\u1C33\u1C36\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE0\u1CE2-\u1CE8\u1CED\u1CF4\u1CF8\u1CF9\u1DC0-\u1DFF\u200C\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA825\uA826\uA82C\uA8C4\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA951\uA980-\uA982\uA9B3\uA9B6-\uA9B9\uA9BC\uA9BD\uA9E5\uAA29-\uAA2E\uAA31\uAA32\uAA35\uAA36\uAA43\uAA4C\uAA7C\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEC\uAAED\uAAF6\uABE5\uABE8\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFF9E\uFF9F]|\uD800[\uDDFD\uDEE0\uDF76-\uDF7A]|\uD802[\uDE01-\uDE03\uDE05\uDE06\uDE0C-\uDE0F\uDE38-\uDE3A\uDE3F\uDEE5\uDEE6]|\uD803[\uDD24-\uDD27\uDEAB\uDEAC\uDEFD-\uDEFF\uDF46-\uDF50\uDF82-\uDF85]|\uD804[\uDC01\uDC38-\uDC46\uDC70\uDC73\uDC74\uDC7F-\uDC81\uDCB3-\uDCB6\uDCB9\uDCBA\uDCC2\uDD00-\uDD02\uDD27-\uDD2B\uDD2D-\uDD34\uDD73\uDD80\uDD81\uDDB6-\uDDBE\uDDC9-\uDDCC\uDDCF\uDE2F-\uDE31\uDE34\uDE36\uDE37\uDE3E\uDE41\uDEDF\uDEE3-\uDEEA\uDF00\uDF01\uDF3B\uDF3C\uDF3E\uDF40\uDF57\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC38-\uDC3F\uDC42-\uDC44\uDC46\uDC5E\uDCB0\uDCB3-\uDCB8\uDCBA\uDCBD\uDCBF\uDCC0\uDCC2\uDCC3\uDDAF\uDDB2-\uDDB5\uDDBC\uDDBD\uDDBF\uDDC0\uDDDC\uDDDD\uDE33-\uDE3A\uDE3D\uDE3F\uDE40\uDEAB\uDEAD\uDEB0-\uDEB5\uDEB7\uDF1D-\uDF1F\uDF22-\uDF25\uDF27-\uDF2B]|\uD806[\uDC2F-\uDC37\uDC39\uDC3A\uDD30\uDD3B\uDD3C\uDD3E\uDD43\uDDD4-\uDDD7\uDDDA\uDDDB\uDDE0\uDE01-\uDE0A\uDE33-\uDE38\uDE3B-\uDE3E\uDE47\uDE51-\uDE56\uDE59-\uDE5B\uDE8A-\uDE96\uDE98\uDE99]|\uD807[\uDC30-\uDC36\uDC38-\uDC3D\uDC3F\uDC92-\uDCA7\uDCAA-\uDCB0\uDCB2\uDCB3\uDCB5\uDCB6\uDD31-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD45\uDD47\uDD90\uDD91\uDD95\uDD97\uDEF3\uDEF4\uDF00\uDF01\uDF36-\uDF3A\uDF40\uDF42]|\uD80D[\uDC40\uDC47-\uDC55]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDF4F\uDF8F-\uDF92\uDFE4]|\uD82F[\uDC9D\uDC9E]|\uD833[\uDF00-\uDF2D\uDF30-\uDF46]|\uD834[\uDD65\uDD67-\uDD69\uDD6E-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDC8F\uDD30-\uDD36\uDEAE\uDEEC-\uDEEF]|\uD839[\uDCEC-\uDCEF]|\uD83A[\uDCD0-\uDCD6\uDD44-\uDD4A]|\uD83C[\uDFFB-\uDFFF]|\uDB40[\uDC20-\uDC7F\uDD00-\uDDEF])$/,pD=/^(?:[\u0600-\u0605\u06DD\u070F\u0890\u0891\u08E2\u0D4E]|\uD804[\uDCBD\uDCCD\uDDC2\uDDC3]|\uD806[\uDD3F\uDD41\uDE3A\uDE84-\uDE89]|\uD807\uDD46)$/,mD=/^(?:[\u0903\u093B\u093E-\u0940\u0949-\u094C\u094E\u094F\u0982\u0983\u09BF\u09C0\u09C7\u09C8\u09CB\u09CC\u0A03\u0A3E-\u0A40\u0A83\u0ABE-\u0AC0\u0AC9\u0ACB\u0ACC\u0B02\u0B03\u0B40\u0B47\u0B48\u0B4B\u0B4C\u0BBF\u0BC1\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCC\u0C01-\u0C03\u0C41-\u0C44\u0C82\u0C83\u0CBE\u0CC0\u0CC1\u0CC3\u0CC4\u0CC7\u0CC8\u0CCA\u0CCB\u0D02\u0D03\u0D3F\u0D40\u0D46-\u0D48\u0D4A-\u0D4C\u0D82\u0D83\u0DD0\u0DD1\u0DD8-\u0DDE\u0DF2\u0DF3\u0E33\u0EB3\u0F3E\u0F3F\u0F7F\u1031\u103B\u103C\u1056\u1057\u1084\u1715\u1734\u17B6\u17BE-\u17C5\u17C7\u17C8\u1923-\u1926\u1929-\u192B\u1930\u1931\u1933-\u1938\u1A19\u1A1A\u1A55\u1A57\u1A6D-\u1A72\u1B04\u1B3B\u1B3D-\u1B41\u1B43\u1B44\u1B82\u1BA1\u1BA6\u1BA7\u1BAA\u1BE7\u1BEA-\u1BEC\u1BEE\u1BF2\u1BF3\u1C24-\u1C2B\u1C34\u1C35\u1CE1\u1CF7\uA823\uA824\uA827\uA880\uA881\uA8B4-\uA8C3\uA952\uA953\uA983\uA9B4\uA9B5\uA9BA\uA9BB\uA9BE-\uA9C0\uAA2F\uAA30\uAA33\uAA34\uAA4D\uAAEB\uAAEE\uAAEF\uAAF5\uABE3\uABE4\uABE6\uABE7\uABE9\uABEA\uABEC]|\uD804[\uDC00\uDC02\uDC82\uDCB0-\uDCB2\uDCB7\uDCB8\uDD2C\uDD45\uDD46\uDD82\uDDB3-\uDDB5\uDDBF\uDDC0\uDDCE\uDE2C-\uDE2E\uDE32\uDE33\uDE35\uDEE0-\uDEE2\uDF02\uDF03\uDF3F\uDF41-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF62\uDF63]|\uD805[\uDC35-\uDC37\uDC40\uDC41\uDC45\uDCB1\uDCB2\uDCB9\uDCBB\uDCBC\uDCBE\uDCC1\uDDB0\uDDB1\uDDB8-\uDDBB\uDDBE\uDE30-\uDE32\uDE3B\uDE3C\uDE3E\uDEAC\uDEAE\uDEAF\uDEB6\uDF26]|\uD806[\uDC2C-\uDC2E\uDC38\uDD31-\uDD35\uDD37\uDD38\uDD3D\uDD40\uDD42\uDDD1-\uDDD3\uDDDC-\uDDDF\uDDE4\uDE39\uDE57\uDE58\uDE97]|\uD807[\uDC2F\uDC3E\uDCA9\uDCB1\uDCB4\uDD8A-\uDD8E\uDD93\uDD94\uDD96\uDEF5\uDEF6]|\uD81B[\uDF51-\uDF87\uDFF0\uDFF1]|\uD834[\uDD66\uDD6D])$/,gD=/^[\u1100-\u115F\uA960-\uA97C]$/,vD=/^[\u1160-\u11A7\uD7B0-\uD7C6]$/,yD=/^[\u11A8-\u11FF\uD7CB-\uD7FB]$/,bD=/^[\uAC00\uAC1C\uAC38\uAC54\uAC70\uAC8C\uACA8\uACC4\uACE0\uACFC\uAD18\uAD34\uAD50\uAD6C\uAD88\uADA4\uADC0\uADDC\uADF8\uAE14\uAE30\uAE4C\uAE68\uAE84\uAEA0\uAEBC\uAED8\uAEF4\uAF10\uAF2C\uAF48\uAF64\uAF80\uAF9C\uAFB8\uAFD4\uAFF0\uB00C\uB028\uB044\uB060\uB07C\uB098\uB0B4\uB0D0\uB0EC\uB108\uB124\uB140\uB15C\uB178\uB194\uB1B0\uB1CC\uB1E8\uB204\uB220\uB23C\uB258\uB274\uB290\uB2AC\uB2C8\uB2E4\uB300\uB31C\uB338\uB354\uB370\uB38C\uB3A8\uB3C4\uB3E0\uB3FC\uB418\uB434\uB450\uB46C\uB488\uB4A4\uB4C0\uB4DC\uB4F8\uB514\uB530\uB54C\uB568\uB584\uB5A0\uB5BC\uB5D8\uB5F4\uB610\uB62C\uB648\uB664\uB680\uB69C\uB6B8\uB6D4\uB6F0\uB70C\uB728\uB744\uB760\uB77C\uB798\uB7B4\uB7D0\uB7EC\uB808\uB824\uB840\uB85C\uB878\uB894\uB8B0\uB8CC\uB8E8\uB904\uB920\uB93C\uB958\uB974\uB990\uB9AC\uB9C8\uB9E4\uBA00\uBA1C\uBA38\uBA54\uBA70\uBA8C\uBAA8\uBAC4\uBAE0\uBAFC\uBB18\uBB34\uBB50\uBB6C\uBB88\uBBA4\uBBC0\uBBDC\uBBF8\uBC14\uBC30\uBC4C\uBC68\uBC84\uBCA0\uBCBC\uBCD8\uBCF4\uBD10\uBD2C\uBD48\uBD64\uBD80\uBD9C\uBDB8\uBDD4\uBDF0\uBE0C\uBE28\uBE44\uBE60\uBE7C\uBE98\uBEB4\uBED0\uBEEC\uBF08\uBF24\uBF40\uBF5C\uBF78\uBF94\uBFB0\uBFCC\uBFE8\uC004\uC020\uC03C\uC058\uC074\uC090\uC0AC\uC0C8\uC0E4\uC100\uC11C\uC138\uC154\uC170\uC18C\uC1A8\uC1C4\uC1E0\uC1FC\uC218\uC234\uC250\uC26C\uC288\uC2A4\uC2C0\uC2DC\uC2F8\uC314\uC330\uC34C\uC368\uC384\uC3A0\uC3BC\uC3D8\uC3F4\uC410\uC42C\uC448\uC464\uC480\uC49C\uC4B8\uC4D4\uC4F0\uC50C\uC528\uC544\uC560\uC57C\uC598\uC5B4\uC5D0\uC5EC\uC608\uC624\uC640\uC65C\uC678\uC694\uC6B0\uC6CC\uC6E8\uC704\uC720\uC73C\uC758\uC774\uC790\uC7AC\uC7C8\uC7E4\uC800\uC81C\uC838\uC854\uC870\uC88C\uC8A8\uC8C4\uC8E0\uC8FC\uC918\uC934\uC950\uC96C\uC988\uC9A4\uC9C0\uC9DC\uC9F8\uCA14\uCA30\uCA4C\uCA68\uCA84\uCAA0\uCABC\uCAD8\uCAF4\uCB10\uCB2C\uCB48\uCB64\uCB80\uCB9C\uCBB8\uCBD4\uCBF0\uCC0C\uCC28\uCC44\uCC60\uCC7C\uCC98\uCCB4\uCCD0\uCCEC\uCD08\uCD24\uCD40\uCD5C\uCD78\uCD94\uCDB0\uCDCC\uCDE8\uCE04\uCE20\uCE3C\uCE58\uCE74\uCE90\uCEAC\uCEC8\uCEE4\uCF00\uCF1C\uCF38\uCF54\uCF70\uCF8C\uCFA8\uCFC4\uCFE0\uCFFC\uD018\uD034\uD050\uD06C\uD088\uD0A4\uD0C0\uD0DC\uD0F8\uD114\uD130\uD14C\uD168\uD184\uD1A0\uD1BC\uD1D8\uD1F4\uD210\uD22C\uD248\uD264\uD280\uD29C\uD2B8\uD2D4\uD2F0\uD30C\uD328\uD344\uD360\uD37C\uD398\uD3B4\uD3D0\uD3EC\uD408\uD424\uD440\uD45C\uD478\uD494\uD4B0\uD4CC\uD4E8\uD504\uD520\uD53C\uD558\uD574\uD590\uD5AC\uD5C8\uD5E4\uD600\uD61C\uD638\uD654\uD670\uD68C\uD6A8\uD6C4\uD6E0\uD6FC\uD718\uD734\uD750\uD76C\uD788]$/,CD=/^[\uAC01-\uAC1B\uAC1D-\uAC37\uAC39-\uAC53\uAC55-\uAC6F\uAC71-\uAC8B\uAC8D-\uACA7\uACA9-\uACC3\uACC5-\uACDF\uACE1-\uACFB\uACFD-\uAD17\uAD19-\uAD33\uAD35-\uAD4F\uAD51-\uAD6B\uAD6D-\uAD87\uAD89-\uADA3\uADA5-\uADBF\uADC1-\uADDB\uADDD-\uADF7\uADF9-\uAE13\uAE15-\uAE2F\uAE31-\uAE4B\uAE4D-\uAE67\uAE69-\uAE83\uAE85-\uAE9F\uAEA1-\uAEBB\uAEBD-\uAED7\uAED9-\uAEF3\uAEF5-\uAF0F\uAF11-\uAF2B\uAF2D-\uAF47\uAF49-\uAF63\uAF65-\uAF7F\uAF81-\uAF9B\uAF9D-\uAFB7\uAFB9-\uAFD3\uAFD5-\uAFEF\uAFF1-\uB00B\uB00D-\uB027\uB029-\uB043\uB045-\uB05F\uB061-\uB07B\uB07D-\uB097\uB099-\uB0B3\uB0B5-\uB0CF\uB0D1-\uB0EB\uB0ED-\uB107\uB109-\uB123\uB125-\uB13F\uB141-\uB15B\uB15D-\uB177\uB179-\uB193\uB195-\uB1AF\uB1B1-\uB1CB\uB1CD-\uB1E7\uB1E9-\uB203\uB205-\uB21F\uB221-\uB23B\uB23D-\uB257\uB259-\uB273\uB275-\uB28F\uB291-\uB2AB\uB2AD-\uB2C7\uB2C9-\uB2E3\uB2E5-\uB2FF\uB301-\uB31B\uB31D-\uB337\uB339-\uB353\uB355-\uB36F\uB371-\uB38B\uB38D-\uB3A7\uB3A9-\uB3C3\uB3C5-\uB3DF\uB3E1-\uB3FB\uB3FD-\uB417\uB419-\uB433\uB435-\uB44F\uB451-\uB46B\uB46D-\uB487\uB489-\uB4A3\uB4A5-\uB4BF\uB4C1-\uB4DB\uB4DD-\uB4F7\uB4F9-\uB513\uB515-\uB52F\uB531-\uB54B\uB54D-\uB567\uB569-\uB583\uB585-\uB59F\uB5A1-\uB5BB\uB5BD-\uB5D7\uB5D9-\uB5F3\uB5F5-\uB60F\uB611-\uB62B\uB62D-\uB647\uB649-\uB663\uB665-\uB67F\uB681-\uB69B\uB69D-\uB6B7\uB6B9-\uB6D3\uB6D5-\uB6EF\uB6F1-\uB70B\uB70D-\uB727\uB729-\uB743\uB745-\uB75F\uB761-\uB77B\uB77D-\uB797\uB799-\uB7B3\uB7B5-\uB7CF\uB7D1-\uB7EB\uB7ED-\uB807\uB809-\uB823\uB825-\uB83F\uB841-\uB85B\uB85D-\uB877\uB879-\uB893\uB895-\uB8AF\uB8B1-\uB8CB\uB8CD-\uB8E7\uB8E9-\uB903\uB905-\uB91F\uB921-\uB93B\uB93D-\uB957\uB959-\uB973\uB975-\uB98F\uB991-\uB9AB\uB9AD-\uB9C7\uB9C9-\uB9E3\uB9E5-\uB9FF\uBA01-\uBA1B\uBA1D-\uBA37\uBA39-\uBA53\uBA55-\uBA6F\uBA71-\uBA8B\uBA8D-\uBAA7\uBAA9-\uBAC3\uBAC5-\uBADF\uBAE1-\uBAFB\uBAFD-\uBB17\uBB19-\uBB33\uBB35-\uBB4F\uBB51-\uBB6B\uBB6D-\uBB87\uBB89-\uBBA3\uBBA5-\uBBBF\uBBC1-\uBBDB\uBBDD-\uBBF7\uBBF9-\uBC13\uBC15-\uBC2F\uBC31-\uBC4B\uBC4D-\uBC67\uBC69-\uBC83\uBC85-\uBC9F\uBCA1-\uBCBB\uBCBD-\uBCD7\uBCD9-\uBCF3\uBCF5-\uBD0F\uBD11-\uBD2B\uBD2D-\uBD47\uBD49-\uBD63\uBD65-\uBD7F\uBD81-\uBD9B\uBD9D-\uBDB7\uBDB9-\uBDD3\uBDD5-\uBDEF\uBDF1-\uBE0B\uBE0D-\uBE27\uBE29-\uBE43\uBE45-\uBE5F\uBE61-\uBE7B\uBE7D-\uBE97\uBE99-\uBEB3\uBEB5-\uBECF\uBED1-\uBEEB\uBEED-\uBF07\uBF09-\uBF23\uBF25-\uBF3F\uBF41-\uBF5B\uBF5D-\uBF77\uBF79-\uBF93\uBF95-\uBFAF\uBFB1-\uBFCB\uBFCD-\uBFE7\uBFE9-\uC003\uC005-\uC01F\uC021-\uC03B\uC03D-\uC057\uC059-\uC073\uC075-\uC08F\uC091-\uC0AB\uC0AD-\uC0C7\uC0C9-\uC0E3\uC0E5-\uC0FF\uC101-\uC11B\uC11D-\uC137\uC139-\uC153\uC155-\uC16F\uC171-\uC18B\uC18D-\uC1A7\uC1A9-\uC1C3\uC1C5-\uC1DF\uC1E1-\uC1FB\uC1FD-\uC217\uC219-\uC233\uC235-\uC24F\uC251-\uC26B\uC26D-\uC287\uC289-\uC2A3\uC2A5-\uC2BF\uC2C1-\uC2DB\uC2DD-\uC2F7\uC2F9-\uC313\uC315-\uC32F\uC331-\uC34B\uC34D-\uC367\uC369-\uC383\uC385-\uC39F\uC3A1-\uC3BB\uC3BD-\uC3D7\uC3D9-\uC3F3\uC3F5-\uC40F\uC411-\uC42B\uC42D-\uC447\uC449-\uC463\uC465-\uC47F\uC481-\uC49B\uC49D-\uC4B7\uC4B9-\uC4D3\uC4D5-\uC4EF\uC4F1-\uC50B\uC50D-\uC527\uC529-\uC543\uC545-\uC55F\uC561-\uC57B\uC57D-\uC597\uC599-\uC5B3\uC5B5-\uC5CF\uC5D1-\uC5EB\uC5ED-\uC607\uC609-\uC623\uC625-\uC63F\uC641-\uC65B\uC65D-\uC677\uC679-\uC693\uC695-\uC6AF\uC6B1-\uC6CB\uC6CD-\uC6E7\uC6E9-\uC703\uC705-\uC71F\uC721-\uC73B\uC73D-\uC757\uC759-\uC773\uC775-\uC78F\uC791-\uC7AB\uC7AD-\uC7C7\uC7C9-\uC7E3\uC7E5-\uC7FF\uC801-\uC81B\uC81D-\uC837\uC839-\uC853\uC855-\uC86F\uC871-\uC88B\uC88D-\uC8A7\uC8A9-\uC8C3\uC8C5-\uC8DF\uC8E1-\uC8FB\uC8FD-\uC917\uC919-\uC933\uC935-\uC94F\uC951-\uC96B\uC96D-\uC987\uC989-\uC9A3\uC9A5-\uC9BF\uC9C1-\uC9DB\uC9DD-\uC9F7\uC9F9-\uCA13\uCA15-\uCA2F\uCA31-\uCA4B\uCA4D-\uCA67\uCA69-\uCA83\uCA85-\uCA9F\uCAA1-\uCABB\uCABD-\uCAD7\uCAD9-\uCAF3\uCAF5-\uCB0F\uCB11-\uCB2B\uCB2D-\uCB47\uCB49-\uCB63\uCB65-\uCB7F\uCB81-\uCB9B\uCB9D-\uCBB7\uCBB9-\uCBD3\uCBD5-\uCBEF\uCBF1-\uCC0B\uCC0D-\uCC27\uCC29-\uCC43\uCC45-\uCC5F\uCC61-\uCC7B\uCC7D-\uCC97\uCC99-\uCCB3\uCCB5-\uCCCF\uCCD1-\uCCEB\uCCED-\uCD07\uCD09-\uCD23\uCD25-\uCD3F\uCD41-\uCD5B\uCD5D-\uCD77\uCD79-\uCD93\uCD95-\uCDAF\uCDB1-\uCDCB\uCDCD-\uCDE7\uCDE9-\uCE03\uCE05-\uCE1F\uCE21-\uCE3B\uCE3D-\uCE57\uCE59-\uCE73\uCE75-\uCE8F\uCE91-\uCEAB\uCEAD-\uCEC7\uCEC9-\uCEE3\uCEE5-\uCEFF\uCF01-\uCF1B\uCF1D-\uCF37\uCF39-\uCF53\uCF55-\uCF6F\uCF71-\uCF8B\uCF8D-\uCFA7\uCFA9-\uCFC3\uCFC5-\uCFDF\uCFE1-\uCFFB\uCFFD-\uD017\uD019-\uD033\uD035-\uD04F\uD051-\uD06B\uD06D-\uD087\uD089-\uD0A3\uD0A5-\uD0BF\uD0C1-\uD0DB\uD0DD-\uD0F7\uD0F9-\uD113\uD115-\uD12F\uD131-\uD14B\uD14D-\uD167\uD169-\uD183\uD185-\uD19F\uD1A1-\uD1BB\uD1BD-\uD1D7\uD1D9-\uD1F3\uD1F5-\uD20F\uD211-\uD22B\uD22D-\uD247\uD249-\uD263\uD265-\uD27F\uD281-\uD29B\uD29D-\uD2B7\uD2B9-\uD2D3\uD2D5-\uD2EF\uD2F1-\uD30B\uD30D-\uD327\uD329-\uD343\uD345-\uD35F\uD361-\uD37B\uD37D-\uD397\uD399-\uD3B3\uD3B5-\uD3CF\uD3D1-\uD3EB\uD3ED-\uD407\uD409-\uD423\uD425-\uD43F\uD441-\uD45B\uD45D-\uD477\uD479-\uD493\uD495-\uD4AF\uD4B1-\uD4CB\uD4CD-\uD4E7\uD4E9-\uD503\uD505-\uD51F\uD521-\uD53B\uD53D-\uD557\uD559-\uD573\uD575-\uD58F\uD591-\uD5AB\uD5AD-\uD5C7\uD5C9-\uD5E3\uD5E5-\uD5FF\uD601-\uD61B\uD61D-\uD637\uD639-\uD653\uD655-\uD66F\uD671-\uD68B\uD68D-\uD6A7\uD6A9-\uD6C3\uD6C5-\uD6DF\uD6E1-\uD6FB\uD6FD-\uD717\uD719-\uD733\uD735-\uD74F\uD751-\uD76B\uD76D-\uD787\uD789-\uD7A3]$/,wD=/^(?:[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u2388\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2605\u2607-\u2612\u2614-\u2685\u2690-\u2705\u2708-\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763-\u2767\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC00-\uDCFF\uDD0D-\uDD0F\uDD2F\uDD6C-\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDAD-\uDDE5\uDE01-\uDE0F\uDE1A\uDE2F\uDE32-\uDE3A\uDE3C-\uDE3F\uDE49-\uDFFA]|\uD83D[\uDC00-\uDD3D\uDD46-\uDE4F\uDE80-\uDEFF\uDF74-\uDF7F\uDFD5-\uDFFF]|\uD83E[\uDC0C-\uDC0F\uDC48-\uDC4F\uDC5A-\uDC5F\uDC88-\uDC8F\uDCAE-\uDCFF\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDEFF]|\uD83F[\uDC00-\uDFFD])$/,ED=(e,t)=>{var n=ke.Any;return e.search(hD)!==-1&&(n|=ke.Extend),t===8205&&(n|=ke.ZWJ),t>=127462&&t<=127487&&(n|=ke.RI),e.search(pD)!==-1&&(n|=ke.Prepend),e.search(mD)!==-1&&(n|=ke.SpacingMark),e.search(gD)!==-1&&(n|=ke.L),e.search(vD)!==-1&&(n|=ke.V),e.search(yD)!==-1&&(n|=ke.T),e.search(bD)!==-1&&(n|=ke.LV),e.search(CD)!==-1&&(n|=ke.LVT),e.search(wD)!==-1&&(n|=ke.ExtPict),n};function go(e,t){return!!(e&t)}var DD=[[ke.L,ke.L|ke.V|ke.LV|ke.LVT],[ke.LV|ke.V,ke.V|ke.T],[ke.LVT|ke.T,ke.T],[ke.Any,ke.Extend|ke.ZWJ],[ke.Any,ke.SpacingMark],[ke.Prepend,ke.Any],[ke.ZWJ,ke.ExtPict],[ke.RI,ke.RI]];function AD(e,t){return DD.findIndex((n=>go(e,n[0])&&go(t,n[1])))===-1}var xD=/(?:[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u2388\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2605\u2607-\u2612\u2614-\u2685\u2690-\u2705\u2708-\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763-\u2767\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC00-\uDCFF\uDD0D-\uDD0F\uDD2F\uDD6C-\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDAD-\uDDE5\uDE01-\uDE0F\uDE1A\uDE2F\uDE32-\uDE3A\uDE3C-\uDE3F\uDE49-\uDFFA]|\uD83D[\uDC00-\uDD3D\uDD46-\uDE4F\uDE80-\uDEFF\uDF74-\uDF7F\uDFD5-\uDFFF]|\uD83E[\uDC0C-\uDC0F\uDC48-\uDC4F\uDC5A-\uDC5F\uDC88-\uDC8F\uDCAE-\uDCFF\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDEFF]|\uD83F[\uDC00-\uDFFD])(?:[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0898-\u089F\u08CA-\u08E1\u08E3-\u0902\u093A\u093C\u0941-\u0948\u094D\u0951-\u0957\u0962\u0963\u0981\u09BC\u09BE\u09C1-\u09C4\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01\u0A02\u0A3C\u0A41\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81\u0A82\u0ABC\u0AC1-\u0AC5\u0AC7\u0AC8\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01\u0B3C\u0B3E\u0B3F\u0B41-\u0B44\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B82\u0BBE\u0BC0\u0BCD\u0BD7\u0C00\u0C04\u0C3C\u0C3E-\u0C40\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81\u0CBC\u0CBF\u0CC2\u0CC6\u0CCC\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00\u0D01\u0D3B\u0D3C\u0D3E\u0D41-\u0D44\u0D4D\u0D57\u0D62\u0D63\u0D81\u0DCA\u0DCF\u0DD2-\u0DD4\u0DD6\u0DDF\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECE\u0F18\u0F19\u0F35\u0F37\u0F39\u0F71-\u0F7E\u0F80-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102D-\u1030\u1032-\u1037\u1039\u103A\u103D\u103E\u1058\u1059\u105E-\u1060\u1071-\u1074\u1082\u1085\u1086\u108D\u109D\u135D-\u135F\u1712-\u1714\u1732\u1733\u1752\u1753\u1772\u1773\u17B4\u17B5\u17B7-\u17BD\u17C6\u17C9-\u17D3\u17DD\u180B-\u180D\u180F\u1885\u1886\u18A9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193B\u1A17\u1A18\u1A1B\u1A56\u1A58-\u1A5E\u1A60\u1A62\u1A65-\u1A6C\u1A73-\u1A7C\u1A7F\u1AB0-\u1ACE\u1B00-\u1B03\u1B34-\u1B3A\u1B3C\u1B42\u1B6B-\u1B73\u1B80\u1B81\u1BA2-\u1BA5\u1BA8\u1BA9\u1BAB-\u1BAD\u1BE6\u1BE8\u1BE9\u1BED\u1BEF-\u1BF1\u1C2C-\u1C33\u1C36\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE0\u1CE2-\u1CE8\u1CED\u1CF4\u1CF8\u1CF9\u1DC0-\u1DFF\u200C\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA825\uA826\uA82C\uA8C4\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA951\uA980-\uA982\uA9B3\uA9B6-\uA9B9\uA9BC\uA9BD\uA9E5\uAA29-\uAA2E\uAA31\uAA32\uAA35\uAA36\uAA43\uAA4C\uAA7C\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEC\uAAED\uAAF6\uABE5\uABE8\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFF9E\uFF9F]|\uD800[\uDDFD\uDEE0\uDF76-\uDF7A]|\uD802[\uDE01-\uDE03\uDE05\uDE06\uDE0C-\uDE0F\uDE38-\uDE3A\uDE3F\uDEE5\uDEE6]|\uD803[\uDD24-\uDD27\uDEAB\uDEAC\uDEFD-\uDEFF\uDF46-\uDF50\uDF82-\uDF85]|\uD804[\uDC01\uDC38-\uDC46\uDC70\uDC73\uDC74\uDC7F-\uDC81\uDCB3-\uDCB6\uDCB9\uDCBA\uDCC2\uDD00-\uDD02\uDD27-\uDD2B\uDD2D-\uDD34\uDD73\uDD80\uDD81\uDDB6-\uDDBE\uDDC9-\uDDCC\uDDCF\uDE2F-\uDE31\uDE34\uDE36\uDE37\uDE3E\uDE41\uDEDF\uDEE3-\uDEEA\uDF00\uDF01\uDF3B\uDF3C\uDF3E\uDF40\uDF57\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC38-\uDC3F\uDC42-\uDC44\uDC46\uDC5E\uDCB0\uDCB3-\uDCB8\uDCBA\uDCBD\uDCBF\uDCC0\uDCC2\uDCC3\uDDAF\uDDB2-\uDDB5\uDDBC\uDDBD\uDDBF\uDDC0\uDDDC\uDDDD\uDE33-\uDE3A\uDE3D\uDE3F\uDE40\uDEAB\uDEAD\uDEB0-\uDEB5\uDEB7\uDF1D-\uDF1F\uDF22-\uDF25\uDF27-\uDF2B]|\uD806[\uDC2F-\uDC37\uDC39\uDC3A\uDD30\uDD3B\uDD3C\uDD3E\uDD43\uDDD4-\uDDD7\uDDDA\uDDDB\uDDE0\uDE01-\uDE0A\uDE33-\uDE38\uDE3B-\uDE3E\uDE47\uDE51-\uDE56\uDE59-\uDE5B\uDE8A-\uDE96\uDE98\uDE99]|\uD807[\uDC30-\uDC36\uDC38-\uDC3D\uDC3F\uDC92-\uDCA7\uDCAA-\uDCB0\uDCB2\uDCB3\uDCB5\uDCB6\uDD31-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD45\uDD47\uDD90\uDD91\uDD95\uDD97\uDEF3\uDEF4\uDF00\uDF01\uDF36-\uDF3A\uDF40\uDF42]|\uD80D[\uDC40\uDC47-\uDC55]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDF4F\uDF8F-\uDF92\uDFE4]|\uD82F[\uDC9D\uDC9E]|\uD833[\uDF00-\uDF2D\uDF30-\uDF46]|\uD834[\uDD65\uDD67-\uDD69\uDD6E-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDC8F\uDD30-\uDD36\uDEAE\uDEEC-\uDEEF]|\uD839[\uDCEC-\uDCEF]|\uD83A[\uDCD0-\uDCD6\uDD44-\uDD4A]|\uD83C[\uDFFB-\uDFFF]|\uDB40[\uDC20-\uDC7F\uDD00-\uDDEF])*\u200D$/,OD=e=>e.search(xD)!==-1,SD=/(?:\uD83C[\uDDE6-\uDDFF])+$/g,ID=e=>{var t=e.match(SD);return t!==null&&t[0].length/2%2==1},TD={delete(e,t){e.delete(t)},insertFragment(e,t,n){e.insertFragment(t,n)},insertText(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};D.withoutNormalizing(e,(()=>{var{voids:r=!1}=n,{at:o=Rl(e)}=n;if(F.isPath(o)&&(o=D.range(e,o)),U.isRange(o))if(U.isCollapsed(o))o=o.anchor;else{var i=U.end(o);if(!r&&D.void(e,{at:i}))return;var s=U.start(o),a=D.pointRef(e,s),u=D.pointRef(e,i);z.delete(e,{at:o,voids:r});var c=a.unref(),f=u.unref();o=c||f,z.setSelection(e,{anchor:o,focus:o})}if(!(!r&&D.void(e,{at:o})||D.elementReadOnly(e,{at:o}))){var{path:l,offset:d}=o;t.length>0&&e.apply({type:"insert_text",path:l,offset:d,text:t})}}))}};function th(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable}))),n.push.apply(n,r)}return n}function hs(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?th(Object(n),!0).forEach((function(r){kt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):th(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var z=hs(hs(hs(hs({},XE),YE),QE),TD),xs=new WeakMap;function O0(e,t,n){var r,o,i=Gs.get(e)||[],s=Js.get(e)||new Set,a=f=>{if(f){var l=f.join(",");o.has(l)||(o.add(l),r.push(f))}};if(n)for(var u of(r=[],o=new Set,i))a(n(u));else r=i,o=s;for(var c of t)a(c);Gs.set(e,r),Js.set(e,o)}var kD=(e,t)=>{for(var n of D.pathRefs(e))qE.transform(n,t);for(var r of D.pointRefs(e))GE.transform(r,t);for(var o of D.rangeRefs(e))JE.transform(o,t);if(!(s=>xs.get(s)||!1)(e)){var i=F.operationCanTransformPath(t)?s=>F.transform(s,t):void 0;O0(e,e.getDirtyPaths(t),i)}z.transform(e,t),e.operations.push(t),D.normalize(e,{operation:t}),t.type==="set_selection"&&(e.marks=null),fi.get(e)||(fi.set(e,!0),Promise.resolve().then((()=>{fi.set(e,!1),e.onChange({operation:t}),e.operations=[]})))};function nh(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable}))),n.push.apply(n,r)}return n}function rh(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?nh(Object(n),!0).forEach((function(r){kt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):nh(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}function oh(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable}))),n.push.apply(n,r)}return n}function ih(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?oh(Object(n),!0).forEach((function(r){kt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):oh(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}function sh(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable}))),n.push.apply(n,r)}return n}function ah(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?sh(Object(n),!0).forEach((function(r){kt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):sh(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}function uh(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable}))),n.push.apply(n,r)}return n}function ch(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?uh(Object(n),!0).forEach((function(r){kt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):uh(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}function lh(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable}))),n.push.apply(n,r)}return n}function dh(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?lh(Object(n),!0).forEach((function(r){kt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):lh(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}function fh(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable}))),n.push.apply(n,r)}return n}var S0=function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{selection:r,marks:o}=e;if(r){if(o){var i=(function(s){for(var a=1;a<arguments.length;a++){var u=arguments[a]!=null?arguments[a]:{};a%2?fh(Object(u),!0).forEach((function(c){kt(s,c,u[c])})):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(u)):fh(Object(u)).forEach((function(c){Object.defineProperty(s,c,Object.getOwnPropertyDescriptor(u,c))}))}return s})({text:t},o);z.insertNodes(e,i,{at:n.at,voids:n.voids})}else z.insertText(e,t,n);e.marks=null}},_D=["text"],BD=["text"],FD=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{force:n=!1,operation:r}=t,o=u=>Gs.get(u)||[],i=u=>{var c=o(u).pop(),f=c.join(",");return(l=>Js.get(l)||new Set)(u).delete(f),c};if(D.isNormalizing(e)){if(n){var s=Array.from(ee.nodes(e),(u=>{var[,c]=u;return c})),a=new Set(s.map((u=>u.join(","))));Gs.set(e,s),Js.set(e,a)}o(e).length!==0&&D.withoutNormalizing(e,(()=>{for(var u of o(e))if(ee.has(e,u)){var c=D.node(e,u),[f,l]=c;le.isElement(f)&&f.children.length===0&&e.normalizeNode(c,{operation:r})}for(var d=o(e),h=d.length,g=0;d.length!==0;){if(!e.shouldNormalize({dirtyPaths:d,iteration:g,initialDirtyPathsLength:h,operation:r}))return;var y=i(e);if(ee.has(e,y)){var p=D.node(e,y);e.normalizeNode(p,{operation:r})}g++,d=o(e)}}))}};function RD(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return(function*(){var{at:n=e.selection,unit:r="offset",reverse:o=!1,voids:i=!1,ignoreNonSelectable:s=!1}=t;if(n){var a=D.range(e,n),[u,c]=U.edges(a),f=o?c:u,l=!1,d="",h=0,g=0,y=0;for(var[p,w]of D.nodes(e,{at:n,reverse:o,voids:i,ignoreNonSelectable:s})){if(le.isElement(p)){if(!i&&(e.isVoid(p)||e.isElementReadOnly(p))){yield D.start(e,w);continue}if(e.isInline(p))continue;if(D.hasInlines(e,p)){var b=F.isAncestor(w,c.path)?c:D.end(e,w),C=F.isAncestor(w,u.path)?u:D.start(e,w);d=D.string(e,{anchor:C,focus:b},{voids:i}),l=!0}}if(he.isText(p)){var E=F.equals(w,f.path);for(E?(g=o?f.offset:p.text.length-f.offset,y=f.offset):(g=p.text.length,y=o?g:0),(E||l||r==="offset")&&(yield{path:w,offset:y},l=!1);;){if(h===0){if(d==="")break;h=A(d,r,o),d=dc(d,h,o)[1]}if(y=o?y-h:y+h,(g-=h)<0){h=-g;break}h=0,yield{path:w,offset:y}}}}}function A(x,I,T){return I==="character"?lc(x,T):I==="word"?(function(B){for(var S=arguments.length>1&&arguments[1]!==void 0&&arguments[1],k=0,R=!1;B.length>0;){var M=lc(B,S),[H,W]=dc(B,M,S);if(cD(H,W,S))R=!0,k+=M;else{if(R)break;k+=M}B=W}return k})(x,T):I==="line"||I==="block"?x.length:1}})()}function hh(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable}))),n.push.apply(n,r)}return n}var jD=(e,t)=>{var{selection:n}=e;if(n){var r=(f,l)=>{if(!he.isText(f))return!1;var[d,h]=D.parent(e,l);return!e.isVoid(d)||e.markableVoid(d)},o=U.isExpanded(n),i=!1;if(!o){var[s,a]=D.node(e,n);if(s&&r(s,a)){var[u]=D.parent(e,a);i=u&&e.markableVoid(u)}}if(o||i)z.unsetNodes(e,t,{match:r,split:!0,voids:!0});else{var c=(function(f){for(var l=1;l<arguments.length;l++){var d=arguments[l]!=null?arguments[l]:{};l%2?hh(Object(d),!0).forEach((function(h){kt(f,h,d[h])})):Object.getOwnPropertyDescriptors?Object.defineProperties(f,Object.getOwnPropertyDescriptors(d)):hh(Object(d)).forEach((function(h){Object.defineProperty(f,h,Object.getOwnPropertyDescriptor(d,h))}))}return f})({},D.marks(e)||{});delete c[t],e.marks=c,fi.get(e)||e.onChange()}}};function ph(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable}))),n.push.apply(n,r)}return n}function mh(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?ph(Object(n),!0).forEach((function(r){kt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ph(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var MD=function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};D.withoutNormalizing(e,(()=>{var{hanging:r=!1,voids:o=!1,mode:i="lowest",batchDirty:s=!0}=n,{at:a,match:u,select:c}=n;if(ee.isNode(t)&&(t=[t]),t.length!==0){var[f]=t;if(a||(a=Rl(e),c!==!1&&(c=!0)),c==null&&(c=!1),U.isRange(a))if(r||(a=D.unhangRange(e,a,{voids:o})),U.isCollapsed(a))a=a.anchor;else{var[,l]=U.edges(a),d=D.pointRef(e,l);z.delete(e,{at:a}),a=d.unref()}if(Re.isPoint(a)){u==null&&(u=he.isText(f)?B=>he.isText(B):e.isInline(f)?B=>he.isText(B)||D.isInline(e,B):B=>le.isElement(B)&&D.isBlock(e,B));var[h]=D.nodes(e,{at:a.path,match:u,mode:i,voids:o});if(!h)return;var[,g]=h,y=D.pathRef(e,g),p=D.isEnd(e,a,g);z.splitNodes(e,{at:a,match:u,mode:i,voids:o});var w=y.unref();a=p?F.next(w):w}var b=F.parent(a),C=a[a.length-1];if(o||!D.void(e,{at:b})){if(s){var E=[],A=F.levels(b);((B,S,k)=>{var R=xs.get(B)||!1;xs.set(B,!0);try{S(),k()}finally{xs.set(B,R)}})(e,(()=>{var B=function(){var k=b.concat(C);C++;var R={type:"insert_node",path:k,node:S};e.apply(R),a=F.next(a),E.push(R),he.isText?A.push(...Array.from(ee.nodes(S),(M=>{var[,H]=M;return k.concat(H)}))):A.push(k)};for(var S of t)B()}),(()=>{O0(e,A,(B=>{var S=B;for(var k of E)if(F.operationCanTransformPath(k)&&!(S=F.transform(S,k)))return null;return S}))}))}else for(var x of t){var I=b.concat(C);C++,e.apply({type:"insert_node",path:I,node:x}),a=F.next(a)}if(a=F.previous(a),c){var T=D.end(e,a);T&&z.select(e,T)}}}}))},PD=["text"],ND=["children"],I0=(e,t)=>{if(le.isElement(t)){var n=t;return!!D.isVoid(e,t)||n.children.length===1&&I0(e,n.children[0])}return!D.isEditor(t)},LD=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};D.withoutNormalizing(e,(()=>{var{mode:n="lowest",voids:r=!1}=t,{match:o,at:i=e.selection,height:s=0,always:a=!1}=t;if(o==null&&(o=W=>le.isElement(W)&&D.isBlock(e,W)),U.isRange(i)&&(i=((W,G)=>{if(U.isCollapsed(G))return G.anchor;var[,q]=U.edges(G),$=D.pointRef(W,q);return z.delete(W,{at:G}),$.unref()})(e,i)),F.isPath(i)){var u=i,c=D.point(e,u),[f]=D.parent(e,u);o=W=>W===f,s=c.path.length-u.length+1,i=c,a=!0}if(i){var l,d=D.pointRef(e,i,{affinity:"backward"});try{var[h]=D.nodes(e,{at:i,match:o,mode:n,voids:r});if(!h)return;var g=D.void(e,{at:i,mode:"highest"});if(!r&&g){var[y,p]=g;if(le.isElement(y)&&e.isInline(y)){var w=D.after(e,p);if(!w){var b=F.next(p);z.insertNodes(e,{text:""},{at:b,voids:r}),w=D.point(e,b)}i=w,a=!0}s=i.path.length-p.length+1,a=!0}l=D.pointRef(e,i);var C=i.path.length-s,[,E]=h,A=i.path.slice(0,C),x=s===0?i.offset:i.path[C]+0;for(var[I,T]of D.levels(e,{at:A,reverse:!0,voids:r})){var B=!1;if(T.length<E.length||T.length===0||!r&&le.isElement(I)&&D.isVoid(e,I))break;var S=d.current,k=D.isEnd(e,S,T);if(a||!d||!D.isEdge(e,S,T)){B=!0;var R=ee.extractProps(I);e.apply({type:"split_node",path:T,position:x,properties:R})}x=T[T.length-1]+(B||k?1:0)}if(t.at==null){var M=l.current||D.end(e,[]);z.select(e,M)}}finally{var H;d.unref(),(H=l)===null||H===void 0||H.unref()}}}))};function gh(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable}))),n.push.apply(n,r)}return n}function vh(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?gh(Object(n),!0).forEach((function(r){kt(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):gh(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var ou,yh,T0=()=>{var e={children:[],operations:[],selection:null,marks:null,isElementReadOnly:()=>!1,isInline:()=>!1,isSelectable:()=>!0,isVoid:()=>!1,markableVoid:()=>!1,onChange:()=>{},apply:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return kD(e,...n)},addMark:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i,s)=>{var{selection:a}=o;if(a){var u=(y,p)=>{if(!he.isText(y))return!1;var[w,b]=D.parent(o,p);return!o.isVoid(w)||o.markableVoid(w)},c=U.isExpanded(a),f=!1;if(!c){var[l,d]=D.node(o,a);if(l&&u(l,d)){var[h]=D.parent(o,d);f=h&&o.markableVoid(h)}}if(c||f)z.setNodes(o,{[i]:s},{match:u,split:!0,voids:!0});else{var g=rh(rh({},D.marks(o)||{}),{},{[i]:s});o.marks=g,fi.get(o)||o.onChange()}}})(e,...n)},deleteBackward:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>{var{selection:s}=o;s&&U.isCollapsed(s)&&z.delete(o,{unit:i,reverse:!0})})(e,...n)},deleteForward:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>{var{selection:s}=o;s&&U.isCollapsed(s)&&z.delete(o,{unit:i})})(e,...n)},deleteFragment:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o){var{direction:i="forward"}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{selection:s}=o;s&&U.isExpanded(s)&&z.delete(o,{reverse:i==="backward"})})(e,...n)},getFragment:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(o=>{var{selection:i}=o;return i?ee.fragment(o,i):[]})(e,...n)},insertBreak:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(o=>{z.splitNodes(o,{always:!0})})(e,...n)},insertSoftBreak:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(o=>{z.splitNodes(o,{always:!0})})(e,...n)},insertFragment:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o,i){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};D.withoutNormalizing(o,(()=>{var{hanging:a=!1,voids:u=!1}=s,{at:c=Rl(o),batchDirty:f=!0}=s;if(i.length){if(U.isRange(c))if(a||(c=D.unhangRange(o,c,{voids:u})),U.isCollapsed(c))c=c.anchor;else{var[,l]=U.edges(c);if(!u&&D.void(o,{at:l}))return;var d=D.pointRef(o,l);z.delete(o,{at:c}),c=d.unref()}else F.isPath(c)&&(c=D.start(o,c));if(u||!D.void(o,{at:c})){var h=D.above(o,{at:c,match:_=>le.isElement(_)&&D.isInline(o,_),mode:"highest",voids:u});if(h){var[,g]=h;D.isEnd(o,c,g)?c=D.after(o,g):D.isStart(o,c,g)&&(c=D.before(o,g))}var y=D.above(o,{match:_=>le.isElement(_)&&D.isBlock(o,_),at:c,voids:u}),[,p]=y,w=D.isStart(o,c,p),b=D.isEnd(o,c,p),C=w&&b,E=!w||w&&b,A=!b,[,x]=ee.first({children:i},[]),[,I]=ee.last({children:i},[]),T=[],B=_=>{var[X,K]=_;return!(K.length===0||!C&&(E&&F.isAncestor(K,x)&&le.isElement(X)&&!o.isVoid(X)&&!o.isInline(X)||A&&F.isAncestor(K,I)&&le.isElement(X)&&!o.isVoid(X)&&!o.isInline(X)))};for(var S of ee.nodes({children:i},{pass:B}))B(S)&&T.push(S);var k=[],R=[],M=[],H=!0,W=!1;for(var[G]of T)le.isElement(G)&&!o.isInline(G)?(H=!1,W=!0,R.push(G)):H?k.push(G):M.push(G);var[q]=D.nodes(o,{at:c,match:_=>he.isText(_)||D.isInline(o,_),mode:"highest",voids:u}),[,$]=q,V=D.isStart(o,c,$),Q=D.isEnd(o,c,$),ae=D.pathRef(o,b&&!M.length?F.next(p):p),ie=D.pathRef(o,Q?F.next($):$);z.splitNodes(o,{at:c,match:_=>W?le.isElement(_)&&D.isBlock(o,_):he.isText(_)||D.isInline(o,_),mode:W?"lowest":"highest",always:W&&(!w||k.length>0)&&(!b||M.length>0),voids:u});var Se,Ie=D.pathRef(o,!V||V&&Q?F.next($):$);if(z.insertNodes(o,k,{at:Ie.current,match:_=>he.isText(_)||D.isInline(o,_),mode:"highest",voids:u,batchDirty:f}),C&&!k.length&&R.length&&!M.length&&z.delete(o,{at:p,voids:u}),z.insertNodes(o,R,{at:ae.current,match:_=>le.isElement(_)&&D.isBlock(o,_),mode:"lowest",voids:u,batchDirty:f}),z.insertNodes(o,M,{at:ie.current,match:_=>he.isText(_)||D.isInline(o,_),mode:"highest",voids:u,batchDirty:f}),!s.at&&(M.length>0&&ie.current?Se=F.previous(ie.current):R.length>0&&ae.current?Se=F.previous(ae.current):Ie.current&&(Se=F.previous(Ie.current)),Se)){var ne=D.end(o,Se);z.select(o,ne)}Ie.unref(),ae.unref(),ie.unref()}}}))})(e,...n)},insertNode:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i,s)=>{z.insertNodes(o,i,s)})(e,...n)},insertText:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return S0(e,...n)},normalizeNode:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>{var[s,a]=i;if(!he.isText(s))if(le.isElement(s)&&s.children.length===0)z.insertNodes(o,{text:""},{at:a.concat(0),voids:!0});else for(var u=!D.isEditor(s)&&le.isElement(s)&&(o.isInline(s)||s.children.length===0||he.isText(s.children[0])||o.isInline(s.children[0])),c=0,f=0;f<s.children.length;f++,c++){var l=ee.get(o,a);if(!he.isText(l)){var d=l.children[c],h=l.children[c-1],g=f===s.children.length-1;(he.isText(d)||le.isElement(d)&&o.isInline(d))!==u?(z.removeNodes(o,{at:a.concat(c),voids:!0}),c--):le.isElement(d)?o.isInline(d)&&(h!=null&&he.isText(h)?g&&(z.insertNodes(o,{text:""},{at:a.concat(c+1),voids:!0}),c++):(z.insertNodes(o,{text:""},{at:a.concat(c),voids:!0}),c++)):(he.isText(d)||"children"in d||(d.children=[]),h!=null&&he.isText(h)&&(he.equals(d,h,{loose:!0})?(z.mergeNodes(o,{at:a.concat(c),voids:!0}),c--):h.text===""?(z.removeNodes(o,{at:a.concat(c-1),voids:!0}),c--):d.text===""&&(z.removeNodes(o,{at:a.concat(c),voids:!0}),c--)))}}})(e,...n)},removeMark:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return jD(e,...n)},getDirtyPaths:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>{switch(i.type){case"insert_text":case"remove_text":case"set_node":var{path:s}=i;return F.levels(s);case"insert_node":var{node:a,path:u}=i,c=F.levels(u),f=he.isText(a)?[]:Array.from(ee.nodes(a),(B=>{var[,S]=B;return u.concat(S)}));return[...c,...f];case"merge_node":var{path:l}=i;return[...F.ancestors(l),F.previous(l)];case"move_node":var{path:d,newPath:h}=i;if(F.equals(d,h))return[];var g=[],y=[];for(var p of F.ancestors(d)){var w=F.transform(p,i);g.push(w)}for(var b of F.ancestors(h)){var C=F.transform(b,i);y.push(C)}var E=y[y.length-1],A=h[h.length-1],x=E.concat(A);return[...g,...y,x];case"remove_node":var{path:I}=i;return[...F.ancestors(I)];case"split_node":var{path:T}=i;return[...F.levels(T),F.next(T)];default:return[]}})(e,...n)},shouldNormalize:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>{var{iteration:s,initialDirtyPathsLength:a}=i,u=42*a;if(s>u)throw new Error("Could not completely normalize the editor after ".concat(u," iterations! This is usually due to incorrect normalization logic that leaves a node in an invalid state."));return!0})(e,...n)},above:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{voids:s=!1,mode:a="lowest",at:u=o.selection,match:c}=i;if(u){var f=D.path(o,u),l=a==="lowest";for(var[d,h]of D.levels(o,{at:f,voids:s,match:c,reverse:l}))if(!he.isText(d)){if(U.isRange(u)){if(F.isAncestor(h,u.anchor.path)&&F.isAncestor(h,u.focus.path))return[d,h]}else if(!F.equals(f,h))return[d,h]}}})(e,...n)},after:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o,i){var s,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},u={anchor:D.point(o,i,{edge:"end"}),focus:D.end(o,[])},{distance:c=1}=a,f=0;for(var l of D.positions(o,ih(ih({},a),{},{at:u}))){if(f>c)break;f!==0&&(s=l),f++}return s})(e,...n)},before:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o,i){var s,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},u={anchor:D.start(o,[]),focus:D.point(o,i,{edge:"start"})},{distance:c=1}=a,f=0;for(var l of D.positions(o,ah(ah({},a),{},{at:u,reverse:!0}))){if(f>c)break;f!==0&&(s=l),f++}return s})(e,...n)},collapse:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{edge:s="anchor"}=i,{selection:a}=o;if(a){if(s==="anchor")z.select(o,a.anchor);else if(s==="focus")z.select(o,a.focus);else if(s==="start"){var[u]=U.edges(a);z.select(o,u)}else if(s==="end"){var[,c]=U.edges(a);z.select(o,c)}}})(e,...n)},delete:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};D.withoutNormalizing(o,(()=>{var s,a,{reverse:u=!1,unit:c="character",distance:f=1,voids:l=!1}=i,{at:d=o.selection,hanging:h=!1}=i;if(d){var g=!1;if(U.isRange(d)&&U.isCollapsed(d)&&(g=!0,d=d.anchor),Re.isPoint(d)){var y=D.void(o,{at:d,mode:"highest"});if(!l&&y){var[,p]=y;d=p}else{var w={unit:c,distance:f};d={anchor:d,focus:u?D.before(o,d,w)||D.start(o,[]):D.after(o,d,w)||D.end(o,[])},h=!0}}if(F.isPath(d))z.removeNodes(o,{at:d,voids:l});else if(!U.isCollapsed(d)){if(!h){var[,b]=U.edges(d),C=D.end(o,[]);Re.equals(b,C)||(d=D.unhangRange(o,d,{voids:l}))}var[E,A]=U.edges(d),x=D.above(o,{match:te=>le.isElement(te)&&D.isBlock(o,te),at:E,voids:l}),I=D.above(o,{match:te=>le.isElement(te)&&D.isBlock(o,te),at:A,voids:l}),T=x&&I&&!F.equals(x[1],I[1]),B=F.equals(E.path,A.path),S=l?null:(s=D.void(o,{at:E,mode:"highest"}))!==null&&s!==void 0?s:D.elementReadOnly(o,{at:E,mode:"highest"}),k=l?null:(a=D.void(o,{at:A,mode:"highest"}))!==null&&a!==void 0?a:D.elementReadOnly(o,{at:A,mode:"highest"});if(S){var R=D.before(o,E);R&&x&&F.isAncestor(x[1],R.path)&&(E=R)}if(k){var M=D.after(o,A);M&&I&&F.isAncestor(I[1],M.path)&&(A=M)}var H,W=[];for(var G of D.nodes(o,{at:d,voids:l})){var[q,$]=G;H&&F.compare($,H)===0||(!l&&le.isElement(q)&&(D.isVoid(o,q)||D.isElementReadOnly(o,q))||!F.isCommon($,E.path)&&!F.isCommon($,A.path))&&(W.push(G),H=$)}var V=Array.from(W,(te=>{var[,me]=te;return D.pathRef(o,me)})),Q=D.pointRef(o,E),ae=D.pointRef(o,A),ie="";if(!B&&!S){var Se=Q.current,[Ie]=D.leaf(o,Se),{path:ne}=Se,{offset:_}=E,X=Ie.text.slice(_);X.length>0&&(o.apply({type:"remove_text",path:ne,offset:_,text:X}),ie=X)}if(V.reverse().map((te=>te.unref())).filter((te=>te!==null)).forEach((te=>z.removeNodes(o,{at:te,voids:l}))),!k){var K=ae.current,[Y]=D.leaf(o,K),{path:de}=K,pe=B?E.offset:0,fe=Y.text.slice(pe,A.offset);fe.length>0&&(o.apply({type:"remove_text",path:de,offset:pe,text:fe}),ie=fe)}!B&&T&&ae.current&&Q.current&&z.mergeNodes(o,{at:ae.current,hanging:!0,voids:l}),g&&u&&c==="character"&&ie.length>1&&ie.match(/[\u0E00-\u0E7F]+/)&&z.insertText(o,ie.slice(0,ie.length-f));var we=Q.unref(),Ce=ae.unref(),se=u?we||Ce:Ce||we;i.at==null&&se&&z.select(o,se)}}}))})(e,...n)},deselect:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(o=>{var{selection:i}=o;i&&o.apply({type:"set_selection",properties:i,newProperties:null})})(e,...n)},edges:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>[D.start(o,i),D.end(o,i)])(e,...n)},elementReadOnly:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return D.above(o,ch(ch({},i),{},{match:s=>le.isElement(s)&&D.isElementReadOnly(o,s)}))})(e,...n)},end:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>D.point(o,i,{edge:"end"}))(e,...n)},first:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>{var s=D.path(o,i,{edge:"start"});return D.node(o,s)})(e,...n)},fragment:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>{var s=D.range(o,i);return ee.fragment(o,s)})(e,...n)},getMarks:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o){var{marks:i,selection:s}=o;if(!s)return null;var{anchor:a,focus:u}=s;if(i)return i;if(U.isExpanded(s)){if(U.isBackward(s)&&([u,a]=[a,u]),D.isEnd(o,a,a.path)){var c=D.after(o,a);c&&(a=c)}var[f]=D.nodes(o,{match:he.isText,at:{anchor:a,focus:u}});if(f){var[l]=f;return Nn(l,_D)}return{}}var{path:d}=a,[h]=D.leaf(o,d);if(a.offset===0){var g=D.previous(o,{at:d,match:he.isText}),y=D.above(o,{match:E=>le.isElement(E)&&D.isVoid(o,E)&&o.markableVoid(E)});if(!y){var p=D.above(o,{match:E=>le.isElement(E)&&D.isBlock(o,E)});if(g&&p){var[w,b]=g,[,C]=p;F.isAncestor(C,b)&&(h=w)}}}return Nn(h,BD)})(e,...n)},hasBlocks:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>i.children.some((s=>le.isElement(s)&&D.isBlock(o,s))))(e,...n)},hasInlines:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>i.children.some((s=>he.isText(s)||D.isInline(o,s))))(e,...n)},hasPath:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>ee.has(o,i))(e,...n)},hasTexts:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>i.children.every((s=>he.isText(s))))(e,...n)},insertNodes:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return MD(e,...n)},isBlock:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>!o.isInline(i))(e,...n)},isEdge:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i,s)=>D.isStart(o,i,s)||D.isEnd(o,i,s))(e,...n)},isEmpty:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>{var{children:s}=i,[a]=s;return s.length===0||s.length===1&&he.isText(a)&&a.text===""&&!o.isVoid(i)})(e,...n)},isEnd:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i,s)=>{var a=D.end(o,s);return Re.equals(i,a)})(e,...n)},isNormalizing:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(o=>{var i=Hf.get(o);return i===void 0||i})(e,...n)},isStart:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i,s)=>{if(i.offset!==0)return!1;var a=D.start(o,s);return Re.equals(i,a)})(e,...n)},last:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>{var s=D.path(o,i,{edge:"end"});return D.node(o,s)})(e,...n)},leaf:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o,i){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a=D.path(o,i,s);return[ee.leaf(o,a),a]})(e,...n)},levels:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return(function*(){var{at:s=o.selection,reverse:a=!1,voids:u=!1}=i,{match:c}=i;if(c==null&&(c=()=>!0),s){var f=[],l=D.path(o,s);for(var[d,h]of ee.levels(o,l))if(c(d,h)&&(f.push([d,h]),!u&&le.isElement(d)&&D.isVoid(o,d)))break;a&&f.reverse(),yield*f}})()})(e,...n)},liftNodes:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};D.withoutNormalizing(o,(()=>{var{at:s=o.selection,mode:a="lowest",voids:u=!1}=i,{match:c}=i;if(c==null&&(c=F.isPath(s)?oo(o,s):I=>le.isElement(I)&&D.isBlock(o,I)),s){var f=D.nodes(o,{at:s,match:c,mode:a,voids:u}),l=Array.from(f,(I=>{var[,T]=I;return D.pathRef(o,T)}));for(var d of l){var h=d.unref();if(h.length<2)throw new Error("Cannot lift node at a path [".concat(h,"] because it has a depth of less than `2`."));var g=D.node(o,F.parent(h)),[y,p]=g,w=h[h.length-1],{length:b}=y.children;if(b===1){var C=F.next(p);z.moveNodes(o,{at:h,to:C,voids:u}),z.removeNodes(o,{at:p,voids:u})}else if(w===0)z.moveNodes(o,{at:h,to:p,voids:u});else if(w===b-1){var E=F.next(p);z.moveNodes(o,{at:h,to:E,voids:u})}else{var A=F.next(h),x=F.next(p);z.splitNodes(o,{at:A,voids:u}),z.moveNodes(o,{at:h,to:x,voids:u})}}}}))})(e,...n)},mergeNodes:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};D.withoutNormalizing(o,(()=>{var{match:s,at:a=o.selection}=i,{hanging:u=!1,voids:c=!1,mode:f="lowest"}=i;if(a){if(s==null)if(F.isPath(a)){var[l]=D.parent(o,a);s=M=>l.children.includes(M)}else s=M=>le.isElement(M)&&D.isBlock(o,M);if(!u&&U.isRange(a)&&(a=D.unhangRange(o,a,{voids:c})),U.isRange(a))if(U.isCollapsed(a))a=a.anchor;else{var[,d]=U.edges(a),h=D.pointRef(o,d);z.delete(o,{at:a}),a=h.unref(),i.at==null&&z.select(o,a)}var[g]=D.nodes(o,{at:a,match:s,voids:c,mode:f}),y=D.previous(o,{at:a,match:s,voids:c,mode:f});if(g&&y){var[p,w]=g,[b,C]=y;if(w.length!==0&&C.length!==0){var E,A,x=F.next(C),I=F.common(w,C),T=F.isSibling(w,C),B=Array.from(D.levels(o,{at:w}),(M=>{var[H]=M;return H})).slice(I.length).slice(0,-1),S=D.above(o,{at:w,mode:"highest",match:M=>B.includes(M)&&I0(o,M)}),k=S&&D.pathRef(o,S[1]);if(he.isText(p)&&he.isText(b)){var R=Nn(p,PD);A=b.text.length,E=R}else{if(!le.isElement(p)||!le.isElement(b))throw new Error("Cannot merge the node at path [".concat(w,"] with the previous sibling because it is not the same kind: ").concat(ht.stringify(p)," ").concat(ht.stringify(b)));R=Nn(p,ND),A=b.children.length,E=R}T||z.moveNodes(o,{at:w,to:x,voids:c}),k&&z.removeNodes(o,{at:k.current,voids:c}),D.shouldMergeNodesRemovePrevNode(o,y,g)?z.removeNodes(o,{at:C,voids:c}):o.apply({type:"merge_node",path:x,position:A,properties:E}),k&&k.unref()}}}}))})(e,...n)},move:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{selection:s}=o,{distance:a=1,unit:u="character",reverse:c=!1}=i,{edge:f=null}=i;if(s){f==="start"&&(f=U.isBackward(s)?"focus":"anchor"),f==="end"&&(f=U.isBackward(s)?"anchor":"focus");var{anchor:l,focus:d}=s,h={distance:a,unit:u,ignoreNonSelectable:!0},g={};if(f==null||f==="anchor"){var y=c?D.before(o,l,h):D.after(o,l,h);y&&(g.anchor=y)}if(f==null||f==="focus"){var p=c?D.before(o,d,h):D.after(o,d,h);p&&(g.focus=p)}z.setSelection(o,g)}})(e,...n)},moveNodes:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>{D.withoutNormalizing(o,(()=>{var{to:s,at:a=o.selection,mode:u="lowest",voids:c=!1}=i,{match:f}=i;if(a){f==null&&(f=F.isPath(a)?oo(o,a):w=>le.isElement(w)&&D.isBlock(o,w));var l=D.pathRef(o,s),d=D.nodes(o,{at:a,match:f,mode:u,voids:c}),h=Array.from(d,(w=>{var[,b]=w;return D.pathRef(o,b)}));for(var g of h){var y=g.unref(),p=l.current;y.length!==0&&o.apply({type:"move_node",path:y,newPath:p}),l.current&&F.isSibling(p,y)&&F.isAfter(p,y)&&(l.current=F.next(l.current))}l.unref()}}))})(e,...n)},next:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{mode:s="lowest",voids:a=!1}=i,{match:u,at:c=o.selection}=i;if(c){var f=D.after(o,c,{voids:a});if(f){var[,l]=D.last(o,[]),d=[f.path,l];if(F.isPath(c)&&c.length===0)throw new Error("Cannot get the next node from the root node!");if(u==null)if(F.isPath(c)){var[h]=D.parent(o,c);u=y=>h.children.includes(y)}else u=()=>!0;var[g]=D.nodes(o,{at:d,match:u,mode:s,voids:a});return g}}})(e,...n)},node:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o,i){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a=D.path(o,i,s),u=ee.get(o,a);return[u,a]})(e,...n)},nodes:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return(function*(){var{at:s=o.selection,mode:a="all",universal:u=!1,reverse:c=!1,voids:f=!1,ignoreNonSelectable:l=!1}=i,{match:d}=i;if(d||(d=()=>!0),s){var h,g;if(rD.isSpan(s))h=s[0],g=s[1];else{var y=D.path(o,s,{edge:"start"}),p=D.path(o,s,{edge:"end"});h=c?p:y,g=c?y:p}var w,b=ee.nodes(o,{reverse:c,from:h,to:g,pass:T=>{var[B]=T;return!(!le.isElement(B)||(f||!D.isVoid(o,B)&&!D.isElementReadOnly(o,B))&&(!l||D.isSelectable(o,B)))}}),C=[];for(var[E,A]of b)if(!l||!le.isElement(E)||D.isSelectable(o,E)){var x=w&&F.compare(A,w[1])===0;if(a!=="highest"||!x){if(d(E,A))if(a==="lowest"&&x)w=[E,A];else{var I=a==="lowest"?w:[E,A];I&&(u?C.push(I):yield I),w=[E,A]}else if(u&&!x&&he.isText(E))return}}a==="lowest"&&w&&(u?C.push(w):yield w),u&&(yield*C)}})()})(e,...n)},normalize:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return FD(e,...n)},parent:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o,i){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a=D.path(o,i,s),u=F.parent(a);return D.node(o,u)})(e,...n)},path:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o,i){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{depth:a,edge:u}=s;if(F.isPath(i)){if(u==="start"){var[,c]=ee.first(o,i);i=c}else if(u==="end"){var[,f]=ee.last(o,i);i=f}}return U.isRange(i)&&(i=u==="start"?U.start(i):u==="end"?U.end(i):F.common(i.anchor.path,i.focus.path)),Re.isPoint(i)&&(i=i.path),a!=null&&(i=i.slice(0,a)),i})(e,...n)},pathRef:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o,i){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{affinity:a="forward"}=s,u={current:i,affinity:a,unref(){var{current:c}=u;return D.pathRefs(o).delete(u),u.current=null,c}};return D.pathRefs(o).add(u),u})(e,...n)},pathRefs:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(o=>{var i=Vf.get(o);return i||(i=new Set,Vf.set(o,i)),i})(e,...n)},point:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o,i){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{edge:a="start"}=s;if(F.isPath(i)){var u;if(a==="end"){var[,c]=ee.last(o,i);u=c}else{var[,f]=ee.first(o,i);u=f}var l=ee.get(o,u);if(!he.isText(l))throw new Error("Cannot get the ".concat(a," point in the node at path [").concat(i,"] because it has no ").concat(a," text node."));return{path:u,offset:a==="end"?l.text.length:0}}if(U.isRange(i)){var[d,h]=U.edges(i);return a==="start"?d:h}return i})(e,...n)},pointRef:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o,i){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{affinity:a="forward"}=s,u={current:i,affinity:a,unref(){var{current:c}=u;return D.pointRefs(o).delete(u),u.current=null,c}};return D.pointRefs(o).add(u),u})(e,...n)},pointRefs:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(o=>{var i=$f.get(o);return i||(i=new Set,$f.set(o,i)),i})(e,...n)},positions:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return RD(e,...n)},previous:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{mode:s="lowest",voids:a=!1}=i,{match:u,at:c=o.selection}=i;if(c){var f=D.before(o,c,{voids:a});if(f){var[,l]=D.first(o,[]),d=[f.path,l];if(F.isPath(c)&&c.length===0)throw new Error("Cannot get the previous node from the root node!");if(u==null)if(F.isPath(c)){var[h]=D.parent(o,c);u=y=>h.children.includes(y)}else u=()=>!0;var[g]=D.nodes(o,{reverse:!0,at:d,match:u,mode:s,voids:a});return g}}})(e,...n)},range:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i,s)=>U.isRange(i)&&!s?i:{anchor:D.start(o,i),focus:D.end(o,s||i)})(e,...n)},rangeRef:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o,i){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{affinity:a="forward"}=s,u={current:i,affinity:a,unref(){var{current:c}=u;return D.rangeRefs(o).delete(u),u.current=null,c}};return D.rangeRefs(o).add(u),u})(e,...n)},rangeRefs:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(o=>{var i=Wf.get(o);return i||(i=new Set,Wf.set(o,i)),i})(e,...n)},removeNodes:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};D.withoutNormalizing(o,(()=>{var{hanging:s=!1,voids:a=!1,mode:u="lowest"}=i,{at:c=o.selection,match:f}=i;if(c){f==null&&(f=F.isPath(c)?oo(o,c):p=>le.isElement(p)&&D.isBlock(o,p)),!s&&U.isRange(c)&&(c=D.unhangRange(o,c,{voids:a}));var l=D.nodes(o,{at:c,match:f,mode:u,voids:a}),d=Array.from(l,(p=>{var[,w]=p;return D.pathRef(o,w)}));for(var h of d){var g=h.unref();if(g){var[y]=D.node(o,g);o.apply({type:"remove_node",path:g,node:y})}}}}))})(e,...n)},select:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>{var{selection:s}=o;if(i=D.range(o,i),s)z.setSelection(o,i);else{if(!U.isRange(i))throw new Error("When setting the selection and the current selection is `null` you must provide at least an `anchor` and `focus`, but you passed: ".concat(ht.stringify(i)));o.apply({type:"set_selection",properties:s,newProperties:i})}})(e,...n)},setNodes:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o,i){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};D.withoutNormalizing(o,(()=>{var{match:a,at:u=o.selection,compare:c,merge:f}=s,{hanging:l=!1,mode:d="lowest",split:h=!1,voids:g=!1}=s;if(u){if(a==null&&(a=F.isPath(u)?oo(o,u):k=>le.isElement(k)&&D.isBlock(o,k)),!l&&U.isRange(u)&&(u=D.unhangRange(o,u,{voids:g})),h&&U.isRange(u)){if(U.isCollapsed(u)&&D.leaf(o,u.anchor)[0].text.length>0)return;var y=D.rangeRef(o,u,{affinity:"inward"}),[p,w]=U.edges(u),b=d==="lowest"?"lowest":"highest",C=D.isEnd(o,w,w.path);z.splitNodes(o,{at:w,match:a,mode:b,voids:g,always:!C});var E=D.isStart(o,p,p.path);z.splitNodes(o,{at:p,match:a,mode:b,voids:g,always:!E}),u=y.unref(),s.at==null&&z.select(o,u)}for(var[A,x]of(c||(c=(k,R)=>k!==R),D.nodes(o,{at:u,match:a,mode:d,voids:g}))){var I={},T={};if(x.length!==0){var B=!1;for(var S in i)S!=="children"&&S!=="text"&&c(i[S],A[S])&&(B=!0,A.hasOwnProperty(S)&&(I[S]=A[S]),f?i[S]!=null&&(T[S]=f(A[S],i[S])):i[S]!=null&&(T[S]=i[S]));B&&o.apply({type:"set_node",path:x,properties:I,newProperties:T})}}}}))})(e,...n)},setNormalizing:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>{Hf.set(o,i)})(e,...n)},setPoint:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o,i){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{selection:a}=o,{edge:u="both"}=s;if(a){u==="start"&&(u=U.isBackward(a)?"focus":"anchor"),u==="end"&&(u=U.isBackward(a)?"anchor":"focus");var{anchor:c,focus:f}=a,l=u==="anchor"?c:f;z.setSelection(o,{[u==="anchor"?"anchor":"focus"]:mh(mh({},l),i)})}})(e,...n)},setSelection:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>{var{selection:s}=o,a={},u={};if(s){for(var c in i)(c==="anchor"&&i.anchor!=null&&!Re.equals(i.anchor,s.anchor)||c==="focus"&&i.focus!=null&&!Re.equals(i.focus,s.focus)||c!=="anchor"&&c!=="focus"&&i[c]!==s[c])&&(a[c]=s[c],u[c]=i[c]);Object.keys(a).length>0&&o.apply({type:"set_selection",properties:a,newProperties:u})}})(e,...n)},splitNodes:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return LD(e,...n)},start:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>D.point(o,i,{edge:"start"}))(e,...n)},string:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o,i){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{voids:a=!1}=s,u=D.range(o,i),[c,f]=U.edges(u),l="";for(var[d,h]of D.nodes(o,{at:u,match:he.isText,voids:a})){var g=d.text;F.equals(h,f.path)&&(g=g.slice(0,f.offset)),F.equals(h,c.path)&&(g=g.slice(c.offset)),l+=g}return l})(e,...n)},unhangRange:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o,i){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{voids:a=!1}=s,[u,c]=U.edges(i);if(u.offset!==0||c.offset!==0||U.isCollapsed(i)||F.hasPrevious(c.path))return i;var f=D.above(o,{at:c,match:p=>le.isElement(p)&&D.isBlock(o,p),voids:a}),l=f?f[1]:[],d={anchor:D.start(o,u),focus:c},h=!0;for(var[g,y]of D.nodes(o,{at:d,match:he.isText,reverse:!0,voids:a}))if(h)h=!1;else if(g.text!==""||F.isBefore(y,l)){c={path:y,offset:g.text.length};break}return{anchor:u,focus:c}})(e,...n)},unsetNodes:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o,i){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Array.isArray(i)||(i=[i]);var a={};for(var u of i)a[u]=null;z.setNodes(o,a,s)})(e,...n)},unwrapNodes:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};D.withoutNormalizing(o,(()=>{var{mode:s="lowest",split:a=!1,voids:u=!1}=i,{at:c=o.selection,match:f}=i;if(c){f==null&&(f=F.isPath(c)?oo(o,c):p=>le.isElement(p)&&D.isBlock(o,p)),F.isPath(c)&&(c=D.range(o,c));var l=U.isRange(c)?D.rangeRef(o,c):null,d=D.nodes(o,{at:c,match:f,mode:s,voids:u}),h=Array.from(d,(p=>{var[,w]=p;return D.pathRef(o,w)})).reverse(),g=function(){var p=y.unref(),[w]=D.node(o,p),b=D.range(o,p);a&&l&&(b=U.intersection(l.current,b)),z.liftNodes(o,{at:b,match:C=>le.isAncestor(w)&&w.children.includes(C),voids:u})};for(var y of h)g();l&&l.unref()}}))})(e,...n)},void:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return D.above(o,dh(dh({},i),{},{match:s=>le.isElement(s)&&D.isVoid(o,s)}))})(e,...n)},withoutNormalizing:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>{var s=D.isNormalizing(o);D.setNormalizing(o,!1);try{i()}finally{D.setNormalizing(o,s)}D.normalize(o)})(e,...n)},wrapNodes:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(o,i){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};D.withoutNormalizing(o,(()=>{var{mode:a="lowest",split:u=!1,voids:c=!1}=s,{match:f,at:l=o.selection}=s;if(l){if(f==null&&(f=F.isPath(l)?oo(o,l):o.isInline(i)?b=>le.isElement(b)&&D.isInline(o,b)||he.isText(b):b=>le.isElement(b)&&D.isBlock(o,b)),u&&U.isRange(l)){var[d,h]=U.edges(l),g=D.rangeRef(o,l,{affinity:"inward"});z.splitNodes(o,{at:h,match:f,voids:c}),z.splitNodes(o,{at:d,match:f,voids:c}),l=g.unref(),s.at==null&&z.select(o,l)}var y=Array.from(D.nodes(o,{at:l,match:o.isInline(i)?b=>le.isElement(b)&&D.isBlock(o,b):b=>D.isEditor(b),mode:"lowest",voids:c})),p=function(){var b=U.isRange(l)?U.intersection(l,D.range(o,w)):l;if(!b)return 0;var C=Array.from(D.nodes(o,{at:b,match:f,mode:a,voids:c}));if(C.length>0){var[E]=C,A=C[C.length-1],[,x]=E,[,I]=A;if(x.length===0&&I.length===0)return 0;var T=F.equals(x,I)?F.parent(x):F.common(x,I),B=D.range(o,x,I),S=D.node(o,T),[k]=S,R=T.length+1,M=F.next(I.slice(0,R)),H=vh(vh({},i),{},{children:[]});z.insertNodes(o,H,{at:M,voids:c}),z.moveNodes(o,{at:B,match:W=>le.isAncestor(k)&&k.children.includes(W),to:M.concat(0),voids:c})}};for(var[,w]of y)p()}}))})(e,...n)},shouldMergeNodesRemovePrevNode:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return((o,i)=>{var[s,a]=i;return le.isElement(s)&&D.isEmpty(o,s)||he.isText(s)&&s.text===""&&a[a.length-1]!==0})(e,...n)}};return e},UD={isHistory:e=>ft(e)&&Array.isArray(e.redos)&&Array.isArray(e.undos)&&(e.redos.length===0||lr.isOperationList(e.redos[0].operations))&&(e.undos.length===0||lr.isOperationList(e.undos[0].operations))},iu=new WeakMap,Dr=new WeakMap,ps=new WeakMap,wn={isHistoryEditor:e=>UD.isHistory(e.history)&&D.isEditor(e),isMerging:e=>Dr.get(e),isSplittingOnce:e=>ps.get(e),setSplittingOnce(e,t){ps.set(e,t)},isSaving:e=>iu.get(e),redo(e){e.redo()},undo(e){e.undo()},withMerging(e,t){var n=wn.isMerging(e);Dr.set(e,!0),t(),Dr.set(e,n)},withNewBatch(e,t){var n=wn.isMerging(e);Dr.set(e,!0),ps.set(e,!0),t(),Dr.set(e,n),ps.delete(e)},withoutMerging(e,t){var n=wn.isMerging(e);Dr.set(e,!1),t(),Dr.set(e,n)},withoutSaving(e,t){var n=wn.isSaving(e);iu.set(e,!1),t(),iu.set(e,n)}},HD=(e,t)=>!(!t||e.type!=="insert_text"||t.type!=="insert_text"||e.offset!==t.offset+t.text.length||!F.equals(e.path,t.path))||!(!t||e.type!=="remove_text"||t.type!=="remove_text"||e.offset+e.text.length!==t.offset||!F.equals(e.path,t.path)),VD=(e,t)=>e.type!=="set_selection",$D=(function(){if(yh)return ou;yh=1,ou=function(o){return o=String(o||""),n.test(o)?"rtl":r.test(o)?"ltr":"neutral"};var e="֑-߿יִ-﷽ﹰ-ﻼ",t="A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿",n=new RegExp("^[^"+t+"]*["+e+"]"),r=new RegExp("^[^"+e+"]*["+t+"]");return ou})();const k0=m1($D),bh=e=>typeof e=="object"&&e!=null&&e.nodeType===1,Ch=(e,t)=>(!t||e!=="hidden")&&e!=="visible"&&e!=="clip",su=(e,t)=>{if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){const n=getComputedStyle(e,null);return Ch(n.overflowY,t)||Ch(n.overflowX,t)||(r=>{const o=(i=>{if(!i.ownerDocument||!i.ownerDocument.defaultView)return null;try{return i.ownerDocument.defaultView.frameElement}catch{return null}})(r);return!!o&&(o.clientHeight<r.scrollHeight||o.clientWidth<r.scrollWidth)})(e)}return!1},ms=(e,t,n,r,o,i,s,a)=>i<e&&s>t||i>e&&s<t?0:i<=e&&a<=n||s>=t&&a>=n?i-e-r:s>t&&a<n||i<e&&a>n?s-t+o:0,WD=e=>{const t=e.parentElement;return t??(e.getRootNode().host||null)},wh=(e,t)=>{var n,r,o,i;if(typeof document>"u")return[];const{scrollMode:s,block:a,inline:u,boundary:c,skipOverflowHiddenElements:f}=t,l=typeof c=="function"?c:G=>G!==c;if(!bh(e))throw new TypeError("Invalid target");const d=document.scrollingElement||document.documentElement,h=[];let g=e;for(;bh(g)&&l(g);){if(g=WD(g),g===d){h.push(g);break}g!=null&&g===document.body&&su(g)&&!su(document.documentElement)||g!=null&&su(g,f)&&h.push(g)}const y=(r=(n=window.visualViewport)==null?void 0:n.width)!=null?r:innerWidth,p=(i=(o=window.visualViewport)==null?void 0:o.height)!=null?i:innerHeight,{scrollX:w,scrollY:b}=window,{height:C,width:E,top:A,right:x,bottom:I,left:T}=e.getBoundingClientRect(),{top:B,right:S,bottom:k,left:R}=(G=>{const q=window.getComputedStyle(G);return{top:parseFloat(q.scrollMarginTop)||0,right:parseFloat(q.scrollMarginRight)||0,bottom:parseFloat(q.scrollMarginBottom)||0,left:parseFloat(q.scrollMarginLeft)||0}})(e);let M=a==="start"||a==="nearest"?A-B:a==="end"?I+k:A+C/2-B+k,H=u==="center"?T+E/2-R+S:u==="end"?x+S:T-R;const W=[];for(let G=0;G<h.length;G++){const q=h[G],{height:$,width:V,top:Q,right:ae,bottom:ie,left:Se}=q.getBoundingClientRect();if(s==="if-needed"&&A>=0&&T>=0&&I<=p&&x<=y&&A>=Q&&I<=ie&&T>=Se&&x<=ae)return W;const Ie=getComputedStyle(q),ne=parseInt(Ie.borderLeftWidth,10),_=parseInt(Ie.borderTopWidth,10),X=parseInt(Ie.borderRightWidth,10),K=parseInt(Ie.borderBottomWidth,10);let Y=0,de=0;const pe="offsetWidth"in q?q.offsetWidth-q.clientWidth-ne-X:0,fe="offsetHeight"in q?q.offsetHeight-q.clientHeight-_-K:0,we="offsetWidth"in q?q.offsetWidth===0?0:V/q.offsetWidth:0,Ce="offsetHeight"in q?q.offsetHeight===0?0:$/q.offsetHeight:0;if(d===q)Y=a==="start"?M:a==="end"?M-p:a==="nearest"?ms(b,b+p,p,_,K,b+M,b+M+C,C):M-p/2,de=u==="start"?H:u==="center"?H-y/2:u==="end"?H-y:ms(w,w+y,y,ne,X,w+H,w+H+E,E),Y=Math.max(0,Y+b),de=Math.max(0,de+w);else{Y=a==="start"?M-Q-_:a==="end"?M-ie+K+fe:a==="nearest"?ms(Q,ie,$,_,K+fe,M,M+C,C):M-(Q+$/2)+fe/2,de=u==="start"?H-Se-ne:u==="center"?H-(Se+V/2)+pe/2:u==="end"?H-ae+X+pe:ms(Se,ae,V,ne,X+pe,H,H+E,E);const{scrollLeft:se,scrollTop:te}=q;Y=Ce===0?0:Math.max(0,Math.min(te+Y/Ce,q.scrollHeight-$/Ce+fe)),de=we===0?0:Math.max(0,Math.min(se+de/we,q.scrollWidth-V/we+pe)),M+=te-Y,H+=se-de}W.push({el:q,top:Y,left:de})}return W};function zD(e,t){if(!e.isConnected||!(o=>{let i=o;for(;i&&i.parentNode;){if(i.parentNode===document)return!0;i=i.parentNode instanceof ShadowRoot?i.parentNode.host:i.parentNode}return!1})(e))return;const n=(o=>{const i=window.getComputedStyle(o);return{top:parseFloat(i.scrollMarginTop)||0,right:parseFloat(i.scrollMarginRight)||0,bottom:parseFloat(i.scrollMarginBottom)||0,left:parseFloat(i.scrollMarginLeft)||0}})(e);if((o=>typeof o=="object"&&typeof o.behavior=="function")(t))return t.behavior(wh(e,t));const r=typeof t=="boolean"||t==null?void 0:t.behavior;for(const{el:o,top:i,left:s}of wh(e,(a=>a===!1?{block:"end",inline:"nearest"}:(u=>u===Object(u)&&Object.keys(u).length!==0)(a)?a:{block:"start",inline:"nearest"})(t))){const a=i-n.top+n.bottom,u=s-n.left+n.right;o.scroll({top:a,left:u,behavior:r})}}var _i,Hr=[],Eh="ResizeObserver loop completed with undelivered notifications.";(function(e){e.BORDER_BOX="border-box",e.CONTENT_BOX="content-box",e.DEVICE_PIXEL_CONTENT_BOX="device-pixel-content-box"})(_i||(_i={}));var au,Dh,Vr=function(e){return Object.freeze(e)},KD=function(e,t){this.inlineSize=e,this.blockSize=t,Vr(this)},_0=(function(){function e(t,n,r,o){return this.x=t,this.y=n,this.width=r,this.height=o,this.top=this.y,this.left=this.x,this.bottom=this.top+this.height,this.right=this.left+this.width,Vr(this)}return e.prototype.toJSON=function(){var t=this;return{x:t.x,y:t.y,top:t.top,right:t.right,bottom:t.bottom,left:t.left,width:t.width,height:t.height}},e.fromRect=function(t){return new e(t.x,t.y,t.width,t.height)},e})(),jl=function(e){return e instanceof SVGElement&&"getBBox"in e},B0=function(e){if(jl(e)){var t=e.getBBox(),n=t.width,r=t.height;return!n&&!r}var o=e,i=o.offsetWidth,s=o.offsetHeight;return!(i||s||e.getClientRects().length)},Ah=function(e){var t;if(e instanceof Element)return!0;var n=(t=e?.ownerDocument)===null||t===void 0?void 0:t.defaultView;return!!(n&&e instanceof n.Element)},pi=typeof window<"u"?window:{},gs=new WeakMap,xh=/auto|scroll/,qD=/^tb|vertical/,GD=/msie|trident/i.test(pi.navigator&&pi.navigator.userAgent),bn=function(e){return parseFloat(e||"0")},Do=function(e,t,n){return e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=!1),new KD((n?t:e)||0,(n?e:t)||0)},Oh=Vr({devicePixelContentBoxSize:Do(),borderBoxSize:Do(),contentBoxSize:Do(),contentRect:new _0(0,0,0,0)}),F0=function(e,t){if(t===void 0&&(t=!1),gs.has(e)&&!t)return gs.get(e);if(B0(e))return gs.set(e,Oh),Oh;var n=getComputedStyle(e),r=jl(e)&&e.ownerSVGElement&&e.getBBox(),o=!GD&&n.boxSizing==="border-box",i=qD.test(n.writingMode||""),s=!r&&xh.test(n.overflowY||""),a=!r&&xh.test(n.overflowX||""),u=r?0:bn(n.paddingTop),c=r?0:bn(n.paddingRight),f=r?0:bn(n.paddingBottom),l=r?0:bn(n.paddingLeft),d=r?0:bn(n.borderTopWidth),h=r?0:bn(n.borderRightWidth),g=r?0:bn(n.borderBottomWidth),y=l+c,p=u+f,w=(r?0:bn(n.borderLeftWidth))+h,b=d+g,C=a?e.offsetHeight-b-e.clientHeight:0,E=s?e.offsetWidth-w-e.clientWidth:0,A=o?y+w:0,x=o?p+b:0,I=r?r.width:bn(n.width)-A-E,T=r?r.height:bn(n.height)-x-C,B=I+y+E+w,S=T+p+C+b,k=Vr({devicePixelContentBoxSize:Do(Math.round(I*devicePixelRatio),Math.round(T*devicePixelRatio),i),borderBoxSize:Do(B,S,i),contentBoxSize:Do(I,T,i),contentRect:new _0(l,u,I,T)});return gs.set(e,k),k},R0=function(e,t,n){var r=F0(e,n),o=r.borderBoxSize,i=r.contentBoxSize,s=r.devicePixelContentBoxSize;switch(t){case _i.DEVICE_PIXEL_CONTENT_BOX:return s;case _i.BORDER_BOX:return o;default:return i}},JD=function(e){var t=F0(e);this.target=e,this.contentRect=t.contentRect,this.borderBoxSize=Vr([t.borderBoxSize]),this.contentBoxSize=Vr([t.contentBoxSize]),this.devicePixelContentBoxSize=Vr([t.devicePixelContentBoxSize])},j0=function(e){if(B0(e))return 1/0;for(var t=0,n=e.parentNode;n;)t+=1,n=n.parentNode;return t},ZD=function(){var e=1/0,t=[];Hr.forEach((function(o){if(o.activeTargets.length!==0){var i=[];o.activeTargets.forEach((function(s){var a=new JD(s.target),u=j0(s.target);i.push(a),s.lastReportedSize=R0(s.target,s.observedBox),u<e&&(e=u)})),t.push((function(){o.callback.call(o.observer,i,o.observer)})),o.activeTargets.splice(0,o.activeTargets.length)}}));for(var n=0,r=t;n<r.length;n++)(0,r[n])();return e},Sh=function(e){Hr.forEach((function(t){t.activeTargets.splice(0,t.activeTargets.length),t.skippedTargets.splice(0,t.skippedTargets.length),t.observationTargets.forEach((function(n){n.isActive()&&(j0(n.target)>e?t.activeTargets.push(n):t.skippedTargets.push(n))}))}))},XD=function(){var e,t=0;for(Sh(t);Hr.some((function(n){return n.activeTargets.length>0}));)t=ZD(),Sh(t);return Hr.some((function(n){return n.skippedTargets.length>0}))&&(typeof ErrorEvent=="function"?e=new ErrorEvent("error",{message:Eh}):((e=document.createEvent("Event")).initEvent("error",!1,!1),e.message=Eh),window.dispatchEvent(e)),t>0},Ih=[],YD=function(e){if(!au){var t=0,n=document.createTextNode("");new MutationObserver((function(){return Ih.splice(0).forEach((function(r){return r()}))})).observe(n,{characterData:!0}),au=function(){n.textContent="".concat(t?t--:t++)}}Ih.push(e),au()},fc=0,QD={attributes:!0,characterData:!0,childList:!0,subtree:!0},Th=["resize","load","transitionend","animationend","animationstart","animationiteration","keyup","keydown","mouseup","mousedown","mouseover","mouseout","blur","focus"],kh=function(e){return e===void 0&&(e=0),Date.now()+e},uu=!1,hc=new((function(){function e(){var t=this;this.stopped=!0,this.listener=function(){return t.schedule()}}return e.prototype.run=function(t){var n=this;if(t===void 0&&(t=250),!uu){uu=!0;var r,o=kh(t);r=function(){var i=!1;try{i=XD()}finally{if(uu=!1,t=o-kh(),!fc)return;i?n.run(1e3):t>0?n.run(t):n.start()}},YD((function(){requestAnimationFrame(r)}))}},e.prototype.schedule=function(){this.stop(),this.run()},e.prototype.observe=function(){var t=this,n=function(){return t.observer&&t.observer.observe(document.body,QD)};document.body?n():pi.addEventListener("DOMContentLoaded",n)},e.prototype.start=function(){var t=this;this.stopped&&(this.stopped=!1,this.observer=new MutationObserver(this.listener),this.observe(),Th.forEach((function(n){return pi.addEventListener(n,t.listener,!0)})))},e.prototype.stop=function(){var t=this;this.stopped||(this.observer&&this.observer.disconnect(),Th.forEach((function(n){return pi.removeEventListener(n,t.listener,!0)})),this.stopped=!0)},e})()),_h=function(e){!fc&&e>0&&hc.start(),!(fc+=e)&&hc.stop()},e2=(function(){function e(t,n){this.target=t,this.observedBox=n||_i.CONTENT_BOX,this.lastReportedSize={inlineSize:0,blockSize:0}}return e.prototype.isActive=function(){var t=R0(this.target,this.observedBox,!0);return(function(n){return!jl(n)&&!(function(r){switch(r.tagName){case"INPUT":if(r.type!=="image")break;case"VIDEO":case"AUDIO":case"EMBED":case"OBJECT":case"CANVAS":case"IFRAME":case"IMG":return!0}return!1})(n)&&getComputedStyle(n).display==="inline"})(this.target)&&(this.lastReportedSize=t),this.lastReportedSize.inlineSize!==t.inlineSize||this.lastReportedSize.blockSize!==t.blockSize},e})(),t2=function(e,t){this.activeTargets=[],this.skippedTargets=[],this.observationTargets=[],this.observer=e,this.callback=t},vs=new WeakMap,Bh=function(e,t){for(var n=0;n<e.length;n+=1)if(e[n].target===t)return n;return-1},ys=(function(){function e(){}return e.connect=function(t,n){var r=new t2(t,n);vs.set(t,r)},e.observe=function(t,n,r){var o=vs.get(t),i=o.observationTargets.length===0;Bh(o.observationTargets,n)<0&&(i&&Hr.push(o),o.observationTargets.push(new e2(n,r&&r.box)),_h(1),hc.schedule())},e.unobserve=function(t,n){var r=vs.get(t),o=Bh(r.observationTargets,n),i=r.observationTargets.length===1;o>=0&&(i&&Hr.splice(Hr.indexOf(r),1),r.observationTargets.splice(o,1),_h(-1))},e.disconnect=function(t){var n=this,r=vs.get(t);r.observationTargets.slice().forEach((function(o){return n.unobserve(t,o.target)})),r.activeTargets.splice(0,r.activeTargets.length)},e})(),n2=(function(){function e(t){if(arguments.length===0)throw new TypeError("Failed to construct 'ResizeObserver': 1 argument required, but only 0 present.");if(typeof t!="function")throw new TypeError("Failed to construct 'ResizeObserver': The callback provided as parameter 1 is not a function.");ys.connect(this,t)}return e.prototype.observe=function(t,n){if(arguments.length===0)throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!Ah(t))throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': parameter 1 is not of type 'Element");ys.observe(this,t,n)},e.prototype.unobserve=function(t){if(arguments.length===0)throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!Ah(t))throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element");ys.unobserve(this,t)},e.prototype.disconnect=function(){ys.disconnect(this)},e.toString=function(){return"function ResizeObserver () { [polyfill code] }"},e})(),nn={},cu=(function(){if(Dh)return nn;Dh=1,Object.defineProperty(nn,"__esModule",{value:!0});for(var e=typeof window<"u"&&/Mac|iPod|iPhone|iPad/.test(window.navigator.platform),t={alt:"altKey",control:"ctrlKey",meta:"metaKey",shift:"shiftKey"},n={add:"+",break:"pause",cmd:"meta",command:"meta",ctl:"control",ctrl:"control",del:"delete",down:"arrowdown",esc:"escape",ins:"insert",left:"arrowleft",mod:e?"meta":"control",opt:"alt",option:"alt",return:"enter",right:"arrowright",space:" ",spacebar:" ",up:"arrowup",win:"meta",windows:"meta"},r={backspace:8,tab:9,enter:13,shift:16,control:17,alt:18,pause:19,capslock:20,escape:27," ":32,pageup:33,pagedown:34,end:35,home:36,arrowleft:37,arrowup:38,arrowright:39,arrowdown:40,insert:45,delete:46,meta:91,numlock:144,scrolllock:145,";":186,"=":187,",":188,"-":189,".":190,"/":191,"`":192,"[":219,"\\":220,"]":221,"'":222},o=1;o<20;o++)r["f"+o]=111+o;function i(f,l,d){l&&!("byKey"in l)&&(d=l,l=null),Array.isArray(f)||(f=[f]);var h=f.map((function(y){return s(y,l)})),g=function(y){return h.some((function(p){return a(p,y)}))};return d==null?g:g(d)}function s(f,l){var d=l&&l.byKey,h={},g=(f=f.replace("++","+add")).split("+"),y=g.length;for(var p in t)h[t[p]]=!1;var w=!0,b=!1,C=void 0;try{for(var E,A=g[Symbol.iterator]();!(w=(E=A.next()).done);w=!0){var x=E.value,I=x.endsWith("?")&&x.length>1;I&&(x=x.slice(0,-1));var T=c(x),B=t[T];if(x.length>1&&!B&&!n[x]&&!r[T])throw new TypeError('Unknown modifier: "'+x+'"');y!==1&&B||(d?h.key=T:h.which=u(x)),B&&(h[B]=!I||null)}}catch(S){b=!0,C=S}finally{try{!w&&A.return&&A.return()}finally{if(b)throw C}}return h}function a(f,l){for(var d in f){var h=f[d],g=void 0;if(h!=null&&((g=d==="key"&&l.key!=null?l.key.toLowerCase():d==="which"?h===91&&l.which===93?91:l.which:l[d])!=null||h!==!1)&&g!==h)return!1}return!0}function u(f){return f=c(f),r[f]||f.toUpperCase().charCodeAt(0)}function c(f){return f=f.toLowerCase(),f=n[f]||f}return nn.default=i,nn.isHotkey=i,nn.isCodeHotkey=function(f,l){return i(f,l)},nn.isKeyHotkey=function(f,l){return i(f,{byKey:!0},l)},nn.parseHotkey=s,nn.compareHotkey=a,nn.toKeyCode=u,nn.toKeyName=c,nn})();function Ro(e,t){if(e==null)return{};var n,r,o=(function(s,a){if(s==null)return{};var u,c,f={},l=Object.keys(s);for(c=0;c<l.length;c++)u=l[c],a.indexOf(u)>=0||(f[u]=s[u]);return f})(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function mi(e){return mi=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},mi(e)}function r2(e){var t=(function(n,r){if(mi(n)!=="object"||n===null)return n;var o=n[Symbol.toPrimitive];if(o!==void 0){var i=o.call(n,r);if(mi(i)!=="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(n)})(e,"string");return mi(t)==="symbol"?t:String(t)}function en(e,t,n){return(t=r2(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var lu,du,Ml=m.createContext(null),_n=()=>{var e=m.useContext(Ml);if(!e)throw new Error("The `useSlateStatic` hook must be used inside the <Slate> component's context.");return e},M0=parseInt(_e.version.split(".")[0],10),P0=typeof navigator<"u"&&typeof window<"u"&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Fh=typeof navigator<"u"&&/Mac OS X/.test(navigator.userAgent),It=typeof navigator<"u"&&/Android/.test(navigator.userAgent),vo=typeof navigator<"u"&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),Or=typeof navigator<"u"&&/AppleWebKit(?!.*Chrome)/i.test(navigator.userAgent),o2=typeof navigator<"u"&&/Edge?\/(?:[0-6][0-9]|[0-7][0-8])(?:\.)/i.test(navigator.userAgent),N0=typeof navigator<"u"&&/Chrome/i.test(navigator.userAgent),i2=typeof navigator<"u"&&/Chrome?\/(?:[0-7][0-5]|[0-6][0-9])(?:\.)/i.test(navigator.userAgent),s2=It&&typeof navigator<"u"&&/Chrome?\/(?:[0-5]?\d)(?:\.)/i.test(navigator.userAgent),a2=typeof navigator<"u"&&/^(?!.*Seamonkey)(?=.*Firefox\/(?:[0-7][0-9]|[0-8][0-6])(?:\.)).*/i.test(navigator.userAgent),u2=typeof navigator<"u"&&/.*UCBrowser/.test(navigator.userAgent),c2=typeof navigator<"u"&&/.*Wechat/.test(navigator.userAgent)&&!/.*MacWechat/.test(navigator.userAgent),Os=!(typeof window>"u"||window.document===void 0||window.document.createElement===void 0);typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&/Version\/(\d+)/.test(navigator.userAgent)&&(lu=navigator.userAgent.match(/Version\/(\d+)/))!==null&&lu!==void 0&&lu[1]&&parseInt((du=navigator.userAgent.match(/Version\/(\d+)/))===null||du===void 0?void 0:du[1],10);var nr=(!i2||!s2)&&!o2&&typeof globalThis<"u"&&globalThis.InputEvent&&typeof globalThis.InputEvent.prototype.getTargetRanges=="function",Ao=new WeakMap,Pl=new WeakMap,Nl=new WeakMap,L0=new WeakMap,Ss=new WeakMap,pc=new WeakMap,Bi=new WeakMap,$r=new WeakMap,Zs=new WeakMap,va=new WeakMap,mc=new WeakMap,dr=new WeakMap,Mr=new WeakMap,gi=new WeakMap,gc=new WeakMap,Ll=new WeakMap,an=new WeakMap,Ln=new WeakMap,Rt=new WeakMap,or=new WeakMap,ir=new WeakMap,U0=new WeakMap,jo=Symbol("placeholder"),H0=Symbol("mark-placeholder"),V0=globalThis.Node,l2=globalThis.Text,Ul=e=>e&&e.ownerDocument&&e.ownerDocument.defaultView||null,d2=e=>gr(e)&&e.nodeType===8,Gt=e=>gr(e)&&e.nodeType===1,gr=e=>{var t=Ul(e);return!!t&&e instanceof t.Node},vc=e=>{var t=e&&e.anchorNode&&Ul(e.anchorNode);return!!t&&e instanceof t.Selection},$0=e=>gr(e)&&e.nodeType===3,W0=(e,t,n)=>{for(var{childNodes:r}=e,o=r[t],i=t,s=!1,a=!1;(d2(o)||Gt(o)&&o.childNodes.length===0||Gt(o)&&o.getAttribute("contenteditable")==="false")&&(!s||!a);)i>=r.length?(s=!0,i=t-1,n="backward"):i<0?(a=!0,i=t+1,n="forward"):(o=r[i],t=i,i+=n==="forward"?1:-1);return[o,t]},f2=(e,t,n)=>{var[r]=W0(e,t,n);return r},z0=e=>{var t="";if($0(e)&&e.nodeValue)return e.nodeValue;if(Gt(e)){for(var n of Array.from(e.childNodes))t+=z0(n);var r=getComputedStyle(e).getPropertyValue("display");r!=="block"&&r!=="list"&&e.tagName!=="BR"||(t+=`
49
+ `)}return t},h2=/data-slate-fragment="(.+?)"/m,vi=e=>e.getSelection!=null?e.getSelection():document.getSelection(),Hl=(e,t,n)=>{var{target:r}=t;if(Gt(r)&&r.matches('[contentEditable="false"]'))return!1;var{document:o}=Z.getWindow(e);if(o.contains(r))return Z.hasDOMNode(e,r,{editable:!0});var i=n.find((s=>{var{addedNodes:a,removedNodes:u}=s;for(var c of a)if(c===r||c.contains(r))return!0;for(var f of u)if(f===r||f.contains(r))return!0}));return!(!i||i===t)&&Hl(e,i,n)},Rh=(e,t)=>!!(e.compareDocumentPosition(t)&V0.DOCUMENT_POSITION_PRECEDING),p2=0;class m2{constructor(){en(this,"id",void 0),this.id="".concat(p2++)}}var Z={androidPendingDiffs:e=>Rt.get(e),androidScheduleFlush:e=>{var t;(t=Ll.get(e))===null||t===void 0||t()},blur:e=>{var t=Z.toDOMNode(e,e),n=Z.findDocumentOrShadowRoot(e);dr.set(e,!1),n.activeElement===t&&t.blur()},deselect:e=>{var{selection:t}=e,n=Z.findDocumentOrShadowRoot(e),r=vi(n);r&&r.rangeCount>0&&r.removeAllRanges(),t&&z.deselect(e)},findDocumentOrShadowRoot:e=>{var t=Z.toDOMNode(e,e),n=t.getRootNode();return n instanceof Document||n instanceof ShadowRoot?n:t.ownerDocument},findEventRange:(e,t)=>{"nativeEvent"in t&&(t=t.nativeEvent);var{clientX:n,clientY:r,target:o}=t;if(n==null||r==null)throw new Error("Cannot resolve a Slate range from a DOM event: ".concat(t));var i,s=Z.toSlateNode(e,t.target),a=Z.findPath(e,s);if(le.isElement(s)&&D.isVoid(e,s)){var u=o.getBoundingClientRect(),c=e.isInline(s)?n-u.left<u.left+u.width-n:r-u.top<u.top+u.height-r,f=D.point(e,a,{edge:c?"start":"end"}),l=c?D.before(e,f):D.after(e,f);if(l)return D.range(e,l)}var{document:d}=Z.getWindow(e);if(d.caretRangeFromPoint)i=d.caretRangeFromPoint(n,r);else{var h=d.caretPositionFromPoint(n,r);h&&((i=d.createRange()).setStart(h.offsetNode,h.offset),i.setEnd(h.offsetNode,h.offset))}if(!i)throw new Error("Cannot resolve a Slate range from a DOM event: ".concat(t));return Z.toSlateRange(e,i,{exactMatch:!1,suppressThrow:!1})},findKey:(e,t)=>{var n=Zs.get(t);return n||(n=new m2,Zs.set(t,n)),n},findPath:(e,t)=>{for(var n=[],r=t;;){var o=Nl.get(r);if(o==null){if(D.isEditor(r))return n;break}var i=Pl.get(r);if(i==null)break;n.unshift(i),r=o}throw new Error("Unable to find the path for Slate node: ".concat(ht.stringify(t)))},focus:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{retries:5};if(!dr.get(e)){if(t.retries<=0)throw new Error("Could not set focus, editor seems stuck with pending operations");if(e.operations.length>0)setTimeout((()=>{Z.focus(e,{retries:t.retries-1})}),10);else{var n=Z.toDOMNode(e,e),r=Z.findDocumentOrShadowRoot(e);if(r.activeElement!==n){if(e.selection&&r instanceof Document){var o=vi(r),i=Z.toDOMRange(e,e.selection);o?.removeAllRanges(),o?.addRange(i)}e.selection||z.select(e,D.start(e,[])),dr.set(e,!0),n.focus({preventScroll:!0})}}}},getWindow:e=>{var t=L0.get(e);if(!t)throw new Error("Unable to find a host window element for this editor");return t},hasDOMNode:function(e,t){var n,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{editable:o=!1}=r,i=Z.toDOMNode(e,e);try{n=Gt(t)?t:t.parentElement}catch(s){if(s instanceof Error&&!s.message.includes('Permission denied to access property "nodeType"'))throw s}return!!n&&!(n.closest("[data-slate-editor]")!==i||o&&!n.isContentEditable&&(typeof n.isContentEditable!="boolean"||n.closest('[contenteditable="false"]')!==i)&&!n.getAttribute("data-slate-zero-width"))},hasEditableTarget:(e,t)=>gr(t)&&Z.hasDOMNode(e,t,{editable:!0}),hasRange:(e,t)=>{var{anchor:n,focus:r}=t;return D.hasPath(e,n.path)&&D.hasPath(e,r.path)},hasSelectableTarget:(e,t)=>Z.hasEditableTarget(e,t)||Z.isTargetInsideNonReadonlyVoid(e,t),hasTarget:(e,t)=>gr(t)&&Z.hasDOMNode(e,t),insertData:(e,t)=>{e.insertData(t)},insertFragmentData:(e,t)=>e.insertFragmentData(t),insertTextData:(e,t)=>e.insertTextData(t),isComposing:e=>!!Mr.get(e),isFocused:e=>!!dr.get(e),isReadOnly:e=>!!mc.get(e),isTargetInsideNonReadonlyVoid:(e,t)=>{if(mc.get(e))return!1;var n=Z.hasTarget(e,t)&&Z.toSlateNode(e,t);return le.isElement(n)&&D.isVoid(e,n)},setFragmentData:(e,t,n)=>e.setFragmentData(t,n),toDOMNode:(e,t)=>{var n=va.get(e),r=D.isEditor(t)?Ss.get(e):n?.get(Z.findKey(e,t));if(!r)throw new Error("Cannot resolve a DOM node from Slate node: ".concat(ht.stringify(t)));return r},toDOMPoint:(e,t)=>{var n,[r]=D.node(e,t.path),o=Z.toDOMNode(e,r);D.void(e,{at:t})&&(t={path:t.path,offset:0});for(var i=Array.from(o.querySelectorAll("[data-slate-string], [data-slate-zero-width]")),s=0,a=0;a<i.length;a++){var u=i[a],c=u.childNodes[0];if(c!=null&&c.textContent!=null){var{length:f}=c.textContent,l=u.getAttribute("data-slate-length"),d=s+(l==null?f:parseInt(l,10)),h=i[a+1];if(t.offset===d&&h!=null&&h.hasAttribute("data-slate-mark-placeholder")){var g,y=h.childNodes[0];n=[y instanceof l2?y:h,(g=h.textContent)!==null&&g!==void 0&&g.startsWith("\uFEFF")?1:0];break}if(t.offset<=d){n=[c,Math.min(f,Math.max(0,t.offset-s))];break}s=d}}if(!n)throw new Error("Cannot resolve a DOM point from Slate point: ".concat(ht.stringify(t)));return n},toDOMRange:(e,t)=>{var{anchor:n,focus:r}=t,o=U.isBackward(t),i=Z.toDOMPoint(e,n),s=U.isCollapsed(t)?i:Z.toDOMPoint(e,r),a=Z.getWindow(e).document.createRange(),[u,c]=o?s:i,[f,l]=o?i:s,d=!!(Gt(u)?u:u.parentElement).getAttribute("data-slate-zero-width"),h=!!(Gt(f)?f:f.parentElement).getAttribute("data-slate-zero-width");return a.setStart(u,d?1:c),a.setEnd(f,h?1:l),a},toSlateNode:(e,t)=>{var n=Gt(t)?t:t.parentElement;n&&!n.hasAttribute("data-slate-node")&&(n=n.closest("[data-slate-node]"));var r=n?Bi.get(n):null;if(!r)throw new Error("Cannot resolve a Slate node from DOM node: ".concat(n));return r},toSlatePoint:(e,t,n)=>{var{exactMatch:r,suppressThrow:o,searchDirection:i="backward"}=n,[s,a]=r?t:($=>{var[V,Q]=$;if(Gt(V)&&V.childNodes.length){var ae=Q===V.childNodes.length,ie=ae?Q-1:Q;for([V,ie]=W0(V,ie,ae?"backward":"forward"),ae=ie<Q;Gt(V)&&V.childNodes.length;){var Se=ae?V.childNodes.length-1:0;V=f2(V,Se,ae?"backward":"forward")}Q=ae&&V.textContent!=null?V.textContent.length:0}return[V,Q]})(t),u=s.parentNode,c=null,f=0;if(u){var l,d,h=Z.toDOMNode(e,e),g=u.closest('[data-slate-void="true"]'),y=g&&h.contains(g)?g:null,p=u.closest('[contenteditable="false"]'),w=p&&h.contains(p)?p:null,b=u.closest("[data-slate-leaf]"),C=null;if(b){if(c=b.closest('[data-slate-node="text"]')){var E=Z.getWindow(e).document.createRange();E.setStart(c,0),E.setEnd(s,a);var A=E.cloneContents();[...Array.prototype.slice.call(A.querySelectorAll("[data-slate-zero-width]")),...Array.prototype.slice.call(A.querySelectorAll("[contenteditable=false]"))].forEach(($=>{It&&!r&&$.hasAttribute("data-slate-zero-width")&&$.textContent.length>0&&$.textContext!=="\uFEFF"?$.textContent.startsWith("\uFEFF")&&($.textContent=$.textContent.slice(1)):$.parentNode.removeChild($)})),f=A.textContent.length,C=c}}else if(y){for(var x=y.querySelectorAll("[data-slate-leaf]"),I=0;I<x.length;I++){var T=x[I];if(Z.hasDOMNode(e,T)){b=T;break}}b?(c=b.closest('[data-slate-node="text"]'),f=(C=b).textContent.length,C.querySelectorAll("[data-slate-zero-width]").forEach(($=>{f-=$.textContent.length}))):f=1}else if(w){var B,S,k=$=>$?$.querySelectorAll("[data-slate-leaf]:not(:scope [data-slate-editor] [data-slate-leaf])"):[],R=w.closest('[data-slate-node="element"]');i==="forward"?b=(B=[...k(R),...k(R?.nextElementSibling)].find(($=>((V,Q)=>!!(V.compareDocumentPosition(Q)&V0.DOCUMENT_POSITION_FOLLOWING))(w,$))))!==null&&B!==void 0?B:null:b=(S=[...k(R?.previousElementSibling),...k(R)].findLast(($=>Rh(w,$))))!==null&&S!==void 0?S:null,b&&(c=b.closest('[data-slate-node="text"]'),C=b,i==="forward"?f=0:(f=C.textContent.length,C.querySelectorAll("[data-slate-zero-width]").forEach(($=>{f-=$.textContent.length}))))}C&&f===C.textContent.length&&It&&C.getAttribute("data-slate-zero-width")==="z"&&(l=C.textContent)!==null&&l!==void 0&&l.startsWith("\uFEFF")&&(u.hasAttribute("data-slate-zero-width")||vo&&(d=C.textContent)!==null&&d!==void 0&&d.endsWith(`
50
+
51
+ `))&&f--}if(It&&!c&&!r){var M=u.hasAttribute("data-slate-node")?u:u.closest("[data-slate-node]");if(M&&Z.hasDOMNode(e,M,{editable:!0})){var H=Z.toSlateNode(e,M),{path:W,offset:G}=D.start(e,Z.findPath(e,H));return M.querySelector("[data-slate-leaf]")||(G=a),{path:W,offset:G}}}if(!c){if(o)return null;throw new Error("Cannot resolve a Slate point from DOM point: ".concat(t))}var q=Z.toSlateNode(e,c);return{path:Z.findPath(e,q),offset:f}},toSlateRange:(e,t,n)=>{var r,o,i,s,a,u,{exactMatch:c,suppressThrow:f}=n;if(vc(t)?t.anchorNode:t.startContainer)if(vc(t)){if(vo&&t.rangeCount>1){s=t.focusNode;var l=t.getRangeAt(0),d=t.getRangeAt(t.rangeCount-1);if(s instanceof HTMLTableRowElement&&l.startContainer instanceof HTMLTableRowElement&&d.startContainer instanceof HTMLTableRowElement){let A=function(x){return x.childElementCount>0?A(x.children[0]):x};var h=l.startContainer,g=d.startContainer,y=A(h.children[l.startOffset]),p=A(g.children[d.startOffset]);a=0,o=p.childNodes.length>0?p.childNodes[0]:p,s=y.childNodes.length>0?y.childNodes[0]:y,i=p instanceof HTMLElement?p.innerHTML.length:0}else l.startContainer===s?(o=d.endContainer,i=d.endOffset,a=l.startOffset):(o=l.startContainer,i=l.endOffset,a=d.startOffset)}else o=t.anchorNode,i=t.anchorOffset,s=t.focusNode,a=t.focusOffset;u=N0&&(A=>{for(var x=A&&A.parentNode;x;){if(x.toString()==="[object ShadowRoot]")return!0;x=x.parentNode}return!1})(o)||vo?t.anchorNode===t.focusNode&&t.anchorOffset===t.focusOffset:t.isCollapsed}else o=t.startContainer,i=t.startOffset,s=t.endContainer,a=t.endOffset,u=t.collapsed;if(o==null||s==null||i==null||a==null)throw new Error("Cannot resolve a Slate range from DOM range: ".concat(t));vo&&(r=s.textContent)!==null&&r!==void 0&&r.endsWith(`
52
+
53
+ `)&&a===s.textContent.length&&a--;var w=Z.toSlatePoint(e,[o,i],{exactMatch:c,suppressThrow:f});if(!w)return null;var b=Rh(o,s)||o===s&&a<i,C=u?w:Z.toSlatePoint(e,[s,a],{exactMatch:c,suppressThrow:f,searchDirection:b?"forward":"backward"});if(!C)return null;var E={anchor:w,focus:C};return U.isExpanded(E)&&U.isForward(E)&&Gt(s)&&D.void(e,{at:E.focus,mode:"highest"})&&(E=D.unhangRange(e,E,{voids:!0})),E}};function g2(e,t){var{path:n,diff:r}=t;if(!D.hasPath(e,n))return!1;var o=ee.get(e,n);if(!he.isText(o))return!1;if(r.start!==o.text.length||r.text.length===0)return o.text.slice(r.start,r.start+r.text.length)===r.text;var i=F.next(n);if(!D.hasPath(e,i))return!1;var s=ee.get(e,i);return he.isText(s)&&s.text.startsWith(r.text)}function jh(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return n.reduce(((o,i)=>o.slice(0,i.start)+i.text+o.slice(i.end)),e)}function Mh(e,t){var{start:n,end:r,text:o}=t,i=e.slice(n,r),s=(function(c,f){for(var l=Math.min(c.length,f.length),d=0;d<l;d++)if(c.charAt(d)!==f.charAt(d))return d;return l})(i,o),a=(function(c,f,l){for(var d=Math.min(c.length,f.length,l),h=0;h<d;h++)if(c.charAt(c.length-h-1)!==f.charAt(f.length-h-1))return h;return d})(i,o,Math.min(i.length-s,o.length-s)),u={start:n+s,end:r-a,text:o.slice(s,o.length-a)};return u.start===u.end&&u.text.length===0?null:u}function v2(e){var{path:t,diff:n}=e;return{anchor:{path:t,offset:n.start},focus:{path:t,offset:n.end}}}function yc(e,t){var{path:n,offset:r}=t;if(!D.hasPath(e,n))return null;var o=ee.get(e,n);if(!he.isText(o))return null;var i=D.above(e,{match:a=>le.isElement(a)&&D.isBlock(e,a),at:n});if(!i)return null;for(;r>o.text.length;){var s=D.next(e,{at:n,match:he.isText});if(!s||!F.isDescendant(s[1],i[1]))return null;r-=o.text.length,o=s[0],n=s[1]}return{path:n,offset:r}}function Ph(e,t){var n=yc(e,t.anchor);if(!n)return null;if(U.isCollapsed(t))return{anchor:n,focus:n};var r=yc(e,t.focus);return r?{anchor:n,focus:r}:null}function bc(e,t,n){var r=Rt.get(e),o=r?.find((f=>{var{path:l}=f;return F.equals(l,t.path)}));if(!o||t.offset<=o.diff.start)return Re.transform(t,n,{affinity:"backward"});var{diff:i}=o;if(t.offset<=i.start+i.text.length){var s={path:t.path,offset:i.start},a=Re.transform(s,n,{affinity:"backward"});return a?{path:a.path,offset:a.offset+t.offset-i.start}:null}var u={path:t.path,offset:t.offset-i.text.length+i.end-i.start},c=Re.transform(u,n,{affinity:"backward"});return c?n.type==="split_node"&&F.equals(n.path,t.path)&&u.offset<n.position&&i.start<n.position?c:{path:c.path,offset:c.offset+i.text.length-i.end+i.start}:null}function Nh(e,t,n){var r=bc(e,t.anchor,n);if(!r)return null;if(U.isCollapsed(t))return{anchor:r,focus:r};var o=bc(e,t.focus,n);return o?{anchor:r,focus:o}:null}function Lh(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable}))),n.push.apply(n,r)}return n}function bs(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Lh(Object(n),!0).forEach((function(r){en(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Lh(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}function y2(e){var{editor:t,scheduleOnDOMSelectionChange:n,onDOMSelectionChange:r}=e,o=!1,i=null,s=null,a=null,u=0,c=!1,f=()=>{var C=ir.get(t);if(ir.delete(t),C){var{selection:E}=t,A=Ph(t,C);!A||E&&U.equals(A,E)||z.select(t,A)}},l=()=>{if(s&&(clearTimeout(s),s=null),a&&(clearTimeout(a),a=null),p()||y()){o||(o=!0,setTimeout((()=>o=!1))),y()&&(o="action");var C=t.selection&&D.rangeRef(t,t.selection,{affinity:"forward"});Ln.set(t,t.marks),or.get(t),Rt.get(t);for(var E,A=p();E=(x=Rt.get(t))===null||x===void 0?void 0:x[0];){var x,I,T=an.get(t);T!==void 0&&(an.delete(t),t.marks=T),T&&c===!1&&(c=null);var B=v2(E);t.selection&&U.equals(t.selection,B)||z.select(t,B),E.diff.text?D.insertText(t,E.diff.text):D.deleteFragment(t),Rt.set(t,(I=Rt.get(t))===null||I===void 0?void 0:I.filter((R=>{var{id:M}=R;return M!==E.id}))),g2(t,E)||(A=!1,or.delete(t),Ln.delete(t),o="action",ir.delete(t),n.cancel(),r.cancel(),C?.unref())}var S=C?.unref();if(!S||ir.get(t)||t.selection&&U.equals(S,t.selection)||z.select(t,S),y())(()=>{var R=or.get(t);if(or.delete(t),R){if(R.at){var M=Re.isPoint(R.at)?yc(t,R.at):Ph(t,R.at);if(!M)return;var H=D.range(t,M);t.selection&&U.equals(t.selection,H)||z.select(t,M)}R.run()}})();else{A&&n(),n.flush(),r.flush(),f();var k=Ln.get(t);Ln.delete(t),k!==void 0&&(t.marks=k,t.onChange())}}else f()},d=function(){var C=arguments.length>0&&arguments[0]!==void 0&&arguments[0],E=pc.get(t);E&&(p()||C?E.style.display="none":E.style.removeProperty("display"))},h=(C,E)=>{var A,x=(A=Rt.get(t))!==null&&A!==void 0?A:[];Rt.set(t,x);var I=ee.leaf(t,C),T=x.findIndex((S=>F.equals(S.path,C)));if(T<0)return Mh(I.text,E)&&x.push({path:C,diff:E,id:u++}),void d();var B=(function(S,k,R){var M=Math.min(k.start,R.start),H=Math.max(0,Math.min(k.start+k.text.length,R.end)-R.start),W=jh(S,k,R),G=Math.max(R.start+R.text.length,k.start+k.text.length+(k.start+k.text.length>R.start?R.text.length:0)-H),q=W.slice(M,G);return Mh(S,{start:M,end:Math.max(k.end,R.end-k.text.length+(k.end-k.start)),text:q})})(I.text,x[T].diff,E);if(!B)return x.splice(T,1),void d();x[T]=bs(bs({},x[T]),{},{diff:B})},g=function(C){var{at:E}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};c=!1,ir.delete(t),n.cancel(),r.cancel(),y()&&l(),or.set(t,{at:E,run:C}),a=setTimeout(l)},y=()=>!!or.get(t),p=()=>{var C;return!((C=Rt.get(t))===null||C===void 0||!C.length)},w=C=>{ir.set(t,C),s&&(clearTimeout(s),s=null);var{selection:E}=t;if(C){var A=!E||!F.equals(E.anchor.path,C.anchor.path),x=!E||!F.equals(E.anchor.path.slice(0,-1),C.anchor.path.slice(0,-1));(A&&c||x)&&(c=!1),(A||p())&&(s=setTimeout(l,200))}},b=()=>{y()||(a=setTimeout(l))};return{flush:l,scheduleFlush:b,hasPendingDiffs:p,hasPendingAction:y,hasPendingChanges:()=>y()||p(),isFlushing:()=>o,handleUserSelect:w,handleCompositionEnd:C=>{i&&clearTimeout(i),i=setTimeout((()=>{Mr.set(t,!1),l()}),25)},handleCompositionStart:C=>{Mr.set(t,!0),i&&(clearTimeout(i),i=null)},handleDOMBeforeInput:C=>{var E;if(s&&(clearTimeout(s),s=null),!Ao.get(t)){var{inputType:A}=C,x=null,I=C.dataTransfer||C.data||void 0;c!==!1&&A!=="insertText"&&A!=="insertCompositionText"&&(c=!1);var[T]=C.getTargetRanges();T&&(x=Z.toSlateRange(t,T,{exactMatch:!1,suppressThrow:!0}));var B=Z.getWindow(t).getSelection();if(!x&&B&&(T=B,x=Z.toSlateRange(t,B,{exactMatch:!1,suppressThrow:!0})),x=(E=x)!==null&&E!==void 0?E:t.selection){var S=!0;if(A.startsWith("delete")){if(U.isExpanded(x)){var[k,R]=U.edges(x);if(ee.leaf(t,k.path).text.length===k.offset&&R.offset===0){var M=D.next(t,{at:k.path,match:he.isText});M&&F.equals(M[1],R.path)&&(x={anchor:R,focus:R})}}var H=A.endsWith("Backward")?"backward":"forward",[W,G]=U.edges(x),[q,$]=D.leaf(t,W.path),V={text:"",start:W.offset,end:G.offset},Q=Rt.get(t),ae=Q?.find((se=>F.equals(se.path,$))),ie=ae?[ae.diff,V]:[V];if(jh(q.text,...ie).length===0&&(S=!1),U.isExpanded(x)){if(S&&F.equals(x.anchor.path,x.focus.path)){var Se={path:x.anchor.path,offset:W.offset},Ie=D.range(t,Se,Se);return w(Ie),h(x.anchor.path,{text:"",end:G.offset,start:W.offset})}return g((()=>D.deleteFragment(t,{direction:H})),{at:x})}}switch(A){case"deleteByComposition":case"deleteByCut":case"deleteByDrag":return g((()=>D.deleteFragment(t)),{at:x});case"deleteContent":case"deleteContentForward":var{anchor:ne}=x;if(S&&U.isCollapsed(x)){var _=ee.leaf(t,ne.path);if(ne.offset<_.text.length)return h(ne.path,{text:"",start:ne.offset,end:ne.offset+1})}return g((()=>D.deleteForward(t)),{at:x});case"deleteContentBackward":var X,{anchor:K}=x,Y=vc(T)?T.isCollapsed:!((X=T)===null||X===void 0||!X.collapsed);return S&&Y&&U.isCollapsed(x)&&K.offset>0?h(K.path,{text:"",start:K.offset-1,end:K.offset}):g((()=>D.deleteBackward(t)),{at:x});case"deleteEntireSoftLine":return g((()=>{D.deleteBackward(t,{unit:"line"}),D.deleteForward(t,{unit:"line"})}),{at:x});case"deleteHardLineBackward":return g((()=>D.deleteBackward(t,{unit:"block"})),{at:x});case"deleteSoftLineBackward":return g((()=>D.deleteBackward(t,{unit:"line"})),{at:x});case"deleteHardLineForward":return g((()=>D.deleteForward(t,{unit:"block"})),{at:x});case"deleteSoftLineForward":return g((()=>D.deleteForward(t,{unit:"line"})),{at:x});case"deleteWordBackward":return g((()=>D.deleteBackward(t,{unit:"word"})),{at:x});case"deleteWordForward":return g((()=>D.deleteForward(t,{unit:"word"})),{at:x});case"insertLineBreak":return g((()=>D.insertSoftBreak(t)),{at:x});case"insertParagraph":return g((()=>D.insertBreak(t)),{at:x});case"insertCompositionText":case"deleteCompositionText":case"insertFromComposition":case"insertFromDrop":case"insertFromPaste":case"insertFromYank":case"insertReplacementText":case"insertText":if((se=>se?.constructor.name==="DataTransfer")(I))return g((()=>Z.insertData(t,I)),{at:x});var de=I??"";if(an.get(t)&&(de=de.replace("\uFEFF","")),A==="insertText"&&/.*\n.*\n$/.test(de)&&(de=de.slice(0,-1)),de.includes(`
54
+ `))return g((()=>{var se=de.split(`
55
+ `);se.forEach(((te,me)=>{te&&D.insertText(t,te),me!==se.length-1&&D.insertSoftBreak(t)}))}),{at:x});if(F.equals(x.anchor.path,x.focus.path)){var[pe,fe]=U.edges(x),we={start:pe.offset,end:fe.offset,text:de};if(de&&c&&A==="insertCompositionText"){var Ce=c.start+c.text.search(/\S|$/);we.start+we.text.search(/\S|$/)===Ce+1&&we.end===c.start+c.text.length?(we.start-=1,c=null,b()):c=!1}else c=A==="insertText"&&(c===null?we:!(!c||!U.isCollapsed(x)||c.end+c.text.length!==pe.offset)&&bs(bs({},c),{},{text:c.text+de}));if(S)return void h(pe.path,we)}return g((()=>D.insertText(t,de)),{at:x})}}}},handleKeyDown:C=>{p()||(d(!0),setTimeout(d))},handleDomMutations:C=>{var E;p()||y()||C.some((A=>Hl(t,A,C)))&&((E=U0.get(t))===null||E===void 0||E())},handleInput:()=>{!y()&&p()||l()}}}var Fi=Os?m.useLayoutEffect:m.useEffect,b2=["node"];function Uh(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable}))),n.push.apply(n,r)}return n}var C2={subtree:!0,childList:!0,characterData:!0},w2=It?e=>{var{node:t}=e,n=Ro(e,b2);if(!It)return null;var r,o=_n(),i=(r=m.useRef(!1),m.useEffect((()=>(r.current=!0,()=>{r.current=!1})),[]),r.current),[s]=m.useState((()=>y2((function(a){for(var u=1;u<arguments.length;u++){var c=arguments[u]!=null?arguments[u]:{};u%2?Uh(Object(c),!0).forEach((function(f){en(a,f,c[f])})):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(c)):Uh(Object(c)).forEach((function(f){Object.defineProperty(a,f,Object.getOwnPropertyDescriptor(c,f))}))}return a})({editor:o},n))));return(function(a,u,c){var[f]=m.useState((()=>new MutationObserver(u)));Fi((()=>{f.takeRecords()})),m.useEffect((()=>{if(!a.current)throw new Error("Failed to attach MutationObserver, `node` is undefined");return f.observe(a.current,c),()=>f.disconnect()}),[f,a,c])})(t,s.handleDomMutations,C2),Ll.set(o,s.scheduleFlush),i&&s.flush(),s}:()=>null,E2=["anchor","focus"],D2=["anchor","focus"],K0=(e,t)=>{var n,r,o=Ro(e,E2),i=Ro(t,D2);return e[jo]===t[jo]&&(n=o,r=i,Object.keys(n).length===Object.keys(r).length&&Object.keys(n).every((s=>r.hasOwnProperty(s)&&n[s]===r[s])))};function Hh(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable}))),n.push.apply(n,r)}return n}var A2=e=>{var{isLast:t,leaf:n,parent:r,text:o}=e,i=_n(),s=Z.findPath(i,o),a=F.parent(s),u=!!n[H0];return i.isVoid(r)?_e.createElement(fu,{length:ee.string(r).length}):n.text!==""||r.children[r.children.length-1]!==o||i.isInline(r)||D.string(i,a)!==""?n.text===""?_e.createElement(fu,{isMarkPlaceholder:u}):t&&n.text.slice(-1)===`
56
+ `?_e.createElement(Vh,{isTrailing:!0,text:n.text}):_e.createElement(Vh,{text:n.text}):_e.createElement(fu,{isLineBreak:!0,isMarkPlaceholder:u})},Vh=e=>{var{text:t,isTrailing:n=!1}=e,r=m.useRef(null),o=()=>"".concat(t??"").concat(n?`
57
+ `:""),[i]=m.useState(o);return Fi((()=>{var s=o();r.current&&r.current.textContent!==s&&(r.current.textContent=s)})),_e.createElement(x2,{ref:r},i)},x2=m.memo(m.forwardRef(((e,t)=>_e.createElement("span",{"data-slate-string":!0,ref:t},e.children)))),fu=e=>{var{length:t=0,isLineBreak:n=!1,isMarkPlaceholder:r=!1}=e,o={"data-slate-zero-width":n?"n":"z","data-slate-length":t};return r&&(o["data-slate-mark-placeholder"]=!0),_e.createElement("span",(function(i){for(var s=1;s<arguments.length;s++){var a=arguments[s]!=null?arguments[s]:{};s%2?Hh(Object(a),!0).forEach((function(u){en(i,u,a[u])})):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(a)):Hh(Object(a)).forEach((function(u){Object.defineProperty(i,u,Object.getOwnPropertyDescriptor(a,u))}))}return i})({},o),(It||P0)&&n?null:"\uFEFF",n?_e.createElement("br",null):null)};function $h(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable}))),n.push.apply(n,r)}return n}function q0(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?$h(Object(n),!0).forEach((function(r){en(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):$h(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var O2=It?300:0;function Wh(e){e.current&&(clearTimeout(e.current),e.current=null)}var S2=e=>{var{leaf:t,isLast:n,text:r,parent:o,renderPlaceholder:i,renderLeaf:s=w=>_e.createElement(T2,q0({},w))}=e,a=_n(),u=m.useRef(null),c=m.useRef(null),[f,l]=m.useState(!1),d=m.useRef(null),h=m.useCallback((w=>{if((function(E,A){E.current&&(E.current.disconnect(),A&&(E.current=null))})(u,w==null),w==null){var b;pc.delete(a),(b=t.onPlaceholderResize)===null||b===void 0||b.call(t,null)}else{if(pc.set(a,w),!u.current){var C=window.ResizeObserver||n2;u.current=new C((()=>{var E;(E=t.onPlaceholderResize)===null||E===void 0||E.call(t,w)}))}u.current.observe(w),c.current=w}}),[c,t,a]),g=_e.createElement(A2,{isLast:n,leaf:t,parent:o,text:r}),y=!!t[jo];if(m.useEffect((()=>(y?d.current||(d.current=setTimeout((()=>{l(!0),d.current=null}),O2)):(Wh(d),l(!1)),()=>Wh(d))),[y,l]),y&&f){var p={children:t.placeholder,attributes:{"data-slate-placeholder":!0,style:{position:"absolute",top:0,pointerEvents:"none",width:"100%",maxWidth:"100%",display:"block",opacity:"0.333",userSelect:"none",textDecoration:"none",WebkitUserModify:Or?"inherit":void 0},contentEditable:!1,ref:h}};g=_e.createElement(_e.Fragment,null,i(p),g)}return s({attributes:{"data-slate-leaf":!0},children:g,leaf:t,text:r})},I2=_e.memo(S2,((e,t)=>t.parent===e.parent&&t.isLast===e.isLast&&t.renderLeaf===e.renderLeaf&&t.renderPlaceholder===e.renderPlaceholder&&t.text===e.text&&he.equals(t.leaf,e.leaf)&&t.leaf[jo]===e.leaf[jo])),T2=e=>{var{attributes:t,children:n}=e;return _e.createElement("span",q0({},t),n)},k2=e=>{for(var{decorations:t,isLast:n,parent:r,renderPlaceholder:o,renderLeaf:i,text:s}=e,a=_n(),u=m.useRef(null),c=he.decorations(s,t),f=Z.findKey(a,s),l=[],d=0;d<c.length;d++){var h=c[d];l.push(_e.createElement(I2,{isLast:n&&d===c.length-1,key:"".concat(f.id,"-").concat(d),renderPlaceholder:o,leaf:h,text:s,parent:r,renderLeaf:i}))}var g=m.useCallback((y=>{var p=va.get(a);y?(p?.set(f,y),$r.set(s,y),Bi.set(y,s)):(p?.delete(f),$r.delete(s),u.current&&Bi.delete(u.current)),u.current=y}),[u,a,f,s]);return _e.createElement("span",{"data-slate-node":"text",ref:g},l)},G0=_e.memo(k2,((e,t)=>t.parent===e.parent&&t.isLast===e.isLast&&t.renderLeaf===e.renderLeaf&&t.renderPlaceholder===e.renderPlaceholder&&t.text===e.text&&((n,r)=>{if(n.length!==r.length)return!1;for(var o=0;o<n.length;o++){var i=n[o],s=r[o];if(i.anchor.offset!==s.anchor.offset||i.focus.offset!==s.focus.offset||!K0(i,s))return!1}return!0})(t.decorations,e.decorations)));function zh(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable}))),n.push.apply(n,r)}return n}function Cc(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?zh(Object(n),!0).forEach((function(r){en(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):zh(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var _2=e=>{var{decorations:t,element:n,renderElement:r=b=>_e.createElement(F2,Cc({},b)),renderPlaceholder:o,renderLeaf:i,selection:s}=e,a=_n(),u=R2(),c=a.isInline(n),f=Z.findKey(a,n),l=m.useCallback((b=>{var C=va.get(a);b?(C?.set(f,b),$r.set(n,b),Bi.set(b,n)):(C?.delete(f),$r.delete(n))}),[a,f,n]),d=Y0({decorations:t,node:n,renderElement:r,renderPlaceholder:o,renderLeaf:i,selection:s}),h={"data-slate-node":"element",ref:l};if(c&&(h["data-slate-inline"]=!0),!c&&D.hasInlines(a,n)){var g=ee.string(n),y=k0(g);y==="rtl"&&(h.dir=y)}if(D.isVoid(a,n)){h["data-slate-void"]=!0,!u&&c&&(h.contentEditable=!1);var p=c?"span":"div",[[w]]=ee.texts(n);d=_e.createElement(p,{"data-slate-spacer":!0,style:{height:"0",color:"transparent",outline:"none",position:"absolute"}},_e.createElement(G0,{renderPlaceholder:o,decorations:[],isLast:!1,parent:n,text:w})),Pl.set(w,0),Nl.set(w,n)}return r({attributes:h,children:d,element:n})},B2=_e.memo(_2,((e,t)=>e.element===t.element&&e.renderElement===t.renderElement&&e.renderLeaf===t.renderLeaf&&e.renderPlaceholder===t.renderPlaceholder&&((n,r)=>{if(n.length!==r.length)return!1;for(var o=0;o<n.length;o++){var i=n[o],s=r[o];if(!U.equals(i,s)||!K0(i,s))return!1}return!0})(e.decorations,t.decorations)&&(e.selection===t.selection||!!e.selection&&!!t.selection&&U.equals(e.selection,t.selection)))),F2=e=>{var{attributes:t,children:n,element:r}=e,o=_n().isInline(r)?"span":"div";return _e.createElement(o,Cc(Cc({},t),{},{style:{position:"relative"}}),n)},J0=m.createContext((()=>[])),Z0=m.createContext(!1),X0=()=>m.useContext(Z0),Y0=e=>{var{decorations:t,node:n,renderElement:r,renderPlaceholder:o,renderLeaf:i,selection:s}=e,a=m.useContext(J0),u=_n();Ao.set(u,!1);for(var c=Z.findPath(u,n),f=[],l=le.isElement(n)&&!u.isInline(n)&&D.hasInlines(u,n),d=0;d<n.children.length;d++){var h=c.concat(d),g=n.children[d],y=Z.findKey(u,g),p=D.range(u,h),w=s&&U.intersection(p,s),b=a([g,h]);for(var C of t){var E=U.intersection(C,p);E&&b.push(E)}le.isElement(g)?f.push(_e.createElement(Z0.Provider,{key:"provider-".concat(y.id),value:!!w},_e.createElement(B2,{decorations:b,element:g,key:y.id,renderElement:r,renderPlaceholder:o,renderLeaf:i,selection:w}))):f.push(_e.createElement(G0,{decorations:b,key:y.id,isLast:l&&d===n.children.length-1,parent:n,renderPlaceholder:o,renderLeaf:i,text:g})),Pl.set(g,d),Nl.set(g,n)}return f},Q0=m.createContext(!1),R2=()=>m.useContext(Q0),ev=m.createContext(null),j2={bold:"mod+b",compose:["down","left","right","up","backspace","enter"],moveBackward:"left",moveForward:"right",moveWordBackward:"ctrl+left",moveWordForward:"ctrl+right",deleteBackward:"shift?+backspace",deleteForward:"shift?+delete",extendBackward:"shift+left",extendForward:"shift+right",italic:"mod+i",insertSoftBreak:"shift+enter",splitBlock:"enter",undo:"mod+z"},M2={moveLineBackward:"opt+up",moveLineForward:"opt+down",moveWordBackward:"opt+left",moveWordForward:"opt+right",deleteBackward:["ctrl+backspace","ctrl+h"],deleteForward:["ctrl+delete","ctrl+d"],deleteLineBackward:"cmd+shift?+backspace",deleteLineForward:["cmd+shift?+delete","ctrl+k"],deleteWordBackward:"opt+shift?+backspace",deleteWordForward:"opt+shift?+delete",extendLineBackward:"opt+shift+up",extendLineForward:"opt+shift+down",redo:"cmd+shift+z",transposeCharacter:"ctrl+t"},P2={deleteWordBackward:"ctrl+shift?+backspace",deleteWordForward:"ctrl+shift?+delete",redo:["ctrl+y","ctrl+shift+z"]},Ge=e=>{var t=j2[e],n=M2[e],r=P2[e],o=t&&cu.isHotkey(t),i=n&&cu.isHotkey(n),s=r&&cu.isHotkey(r);return a=>!(!o||!o(a))||!!(Fh&&i&&i(a))||!(Fh||!s||!s(a))},Ze={isBold:Ge("bold"),isCompose:Ge("compose"),isMoveBackward:Ge("moveBackward"),isMoveForward:Ge("moveForward"),isDeleteBackward:Ge("deleteBackward"),isDeleteForward:Ge("deleteForward"),isDeleteLineBackward:Ge("deleteLineBackward"),isDeleteLineForward:Ge("deleteLineForward"),isDeleteWordBackward:Ge("deleteWordBackward"),isDeleteWordForward:Ge("deleteWordForward"),isExtendBackward:Ge("extendBackward"),isExtendForward:Ge("extendForward"),isExtendLineBackward:Ge("extendLineBackward"),isExtendLineForward:Ge("extendLineForward"),isItalic:Ge("italic"),isMoveLineBackward:Ge("moveLineBackward"),isMoveLineForward:Ge("moveLineForward"),isMoveWordBackward:Ge("moveWordBackward"),isMoveWordForward:Ge("moveWordForward"),isRedo:Ge("redo"),isSoftBreak:Ge("insertSoftBreak"),isSplitBlock:Ge("splitBlock"),isTransposeCharacter:Ge("transposeCharacter"),isUndo:Ge("undo")},N2={subtree:!0,childList:!0,characterData:!0,characterDataOldValue:!0};class tv extends m.Component{constructor(){super(...arguments),en(this,"context",null),en(this,"manager",null),en(this,"mutationObserver",null)}observe(){var t,{node:n}=this.props;if(!n.current)throw new Error("Failed to attach MutationObserver, `node` is undefined");(t=this.mutationObserver)===null||t===void 0||t.observe(n.current,N2)}componentDidMount(){var{receivedUserInput:t}=this.props,n=this.context;this.manager=((r,o)=>{var i=[],s=()=>{i=[]};return{registerMutations:a=>{if(o.current){var u=a.filter((c=>Hl(r,c,a)));i.push(...u)}},restoreDOM:function(){i.length>0&&(i.reverse().forEach((a=>{a.type!=="characterData"&&(a.removedNodes.forEach((u=>{a.target.insertBefore(u,a.nextSibling)})),a.addedNodes.forEach((u=>{a.target.removeChild(u)})))})),s())},clear:s}})(n,t),this.mutationObserver=new MutationObserver(this.manager.registerMutations),this.observe()}getSnapshotBeforeUpdate(){var t,n,r,o,i=(t=this.mutationObserver)===null||t===void 0?void 0:t.takeRecords();return i!=null&&i.length&&((o=this.manager)===null||o===void 0||o.registerMutations(i)),(n=this.mutationObserver)===null||n===void 0||n.disconnect(),(r=this.manager)===null||r===void 0||r.restoreDOM(),null}componentDidUpdate(){var t;(t=this.manager)===null||t===void 0||t.clear(),this.observe()}componentWillUnmount(){var t;(t=this.mutationObserver)===null||t===void 0||t.disconnect()}render(){return this.props.children}}en(tv,"contextType",Ml);var L2=It?tv:e=>{var{children:t}=e;return _e.createElement(_e.Fragment,null,t)},U2=m.createContext(!1),H2=["autoFocus","decorate","onDOMBeforeInput","placeholder","readOnly","renderElement","renderLeaf","renderPlaceholder","scrollSelectionIntoView","style","as","disableDefaultStyles"],V2=["text"];function Kh(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable}))),n.push.apply(n,r)}return n}function Cn(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Kh(Object(n),!0).forEach((function(r){en(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Kh(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var $2=e=>_e.createElement(_e.Fragment,null,Y0(e)),W2=m.forwardRef(((e,t)=>{var n=m.useCallback((_=>_e.createElement(z2,Cn({},_))),[]),{autoFocus:r,decorate:o=K2,onDOMBeforeInput:i,placeholder:s,readOnly:a=!1,renderElement:u,renderLeaf:c,renderPlaceholder:f=n,scrollSelectionIntoView:l=q2,style:d={},as:h="div",disableDefaultStyles:g=!1}=e,y=Ro(e,H2),p=(()=>{var _=m.useContext(ev);if(!_)throw new Error("The `useSlate` hook must be used inside the <Slate> component's context.");var{editor:X}=_;return X})(),[w,b]=m.useState(!1),C=m.useRef(null),E=m.useRef([]),[A,x]=m.useState(),I=m.useRef(!1),{onUserInput:T,receivedUserInput:B}=(function(){var _=_n(),X=m.useRef(!1),K=m.useRef(0),Y=m.useCallback((()=>{if(!X.current){X.current=!0;var de=Z.getWindow(_);de.cancelAnimationFrame(K.current),K.current=de.requestAnimationFrame((()=>{X.current=!1}))}}),[_]);return m.useEffect((()=>()=>cancelAnimationFrame(K.current)),[]),{receivedUserInput:X,onUserInput:Y}})(),[,S]=m.useReducer((_=>_+1),0);U0.set(p,S),mc.set(p,a);var k=m.useMemo((()=>({isDraggingInternally:!1,isUpdatingSelection:!1,latestElement:null,hasMarkPlaceholder:!1})),[]);m.useEffect((()=>{C.current&&r&&C.current.focus()}),[r]);var R=m.useRef(),M=m.useMemo((()=>v1((()=>{if(Ao.get(p))M();else{var _=Z.toDOMNode(p,p).getRootNode();if(!I.current&&Or&&_ instanceof ShadowRoot){I.current=!0;var X=(()=>{for(var Ae=document.activeElement;(Pe=Ae)!==null&&Pe!==void 0&&Pe.shadowRoot&&(Be=Ae.shadowRoot)!==null&&Be!==void 0&&Be.activeElement;){var Pe,Be,re;Ae=(re=Ae)===null||re===void 0||(re=re.shadowRoot)===null||re===void 0?void 0:re.activeElement}return Ae})();return X?document.execCommand("indent"):z.deselect(p),void(I.current=!1)}var K=R.current;if((It||!Z.isComposing(p))&&(!k.isUpdatingSelection||K!=null&&K.isFlushing())&&!k.isDraggingInternally){var Y=Z.findDocumentOrShadowRoot(p),{activeElement:de}=Y,pe=Z.toDOMNode(p,p),fe=vi(Y);if(de===pe?(k.latestElement=de,dr.set(p,!0)):dr.delete(p),!fe)return z.deselect(p);var{anchorNode:we,focusNode:Ce}=fe,se=Z.hasEditableTarget(p,we)||Z.isTargetInsideNonReadonlyVoid(p,we),te=Z.hasTarget(p,Ce);if(se&&te){var me=Z.toSlateRange(p,fe,{exactMatch:!1,suppressThrow:!0});me&&(Z.isComposing(p)||K!=null&&K.hasPendingChanges()||K!=null&&K.isFlushing()?K?.handleUserSelect(me):z.select(p,me))}!a||se&&te||z.deselect(p)}}}),100)),[p,a,k]),H=m.useMemo((()=>y1(M,0)),[M]);R.current=w2({node:C,onDOMSelectionChange:M,scheduleOnDOMSelectionChange:H}),Fi((()=>{var _,X,K;C.current&&(K=Ul(C.current))?(L0.set(p,K),Ss.set(p,C.current),$r.set(p,C.current),Bi.set(C.current,p)):$r.delete(p);var{selection:Y}=p,de=Z.findDocumentOrShadowRoot(p),pe=vi(de);if(pe&&Z.isFocused(p)&&((_=R.current)===null||_===void 0||!_.hasPendingAction())){var fe=te=>{var me=pe.type!=="None";if(Y||me){var Ae,Pe=pe.focusNode;if(vo&&pe.rangeCount>1){var Be=pe.getRangeAt(0),re=pe.getRangeAt(pe.rangeCount-1);Ae=Be.startContainer===Pe?re.endContainer:Be.startContainer}else Ae=pe.anchorNode;var J=Ss.get(p),oe=!1;if(J.contains(Ae)&&J.contains(Pe)&&(oe=!0),me&&oe&&Y&&!te){var ge=Z.toSlateRange(p,pe,{exactMatch:!0,suppressThrow:!0});if(ge&&U.equals(ge,Y)){var ve;if(!k.hasMarkPlaceholder||(ve=Ae)!==null&&ve!==void 0&&(ve=ve.parentElement)!==null&&ve!==void 0&&ve.hasAttribute("data-slate-mark-placeholder"))return}}if(!Y||Z.hasRange(p,Y)){k.isUpdatingSelection=!0;var Te=Y&&Z.toDOMRange(p,Y);return Te?(Z.isComposing(p)&&!It?pe.collapseToEnd():U.isBackward(Y)?pe.setBaseAndExtent(Te.endContainer,Te.endOffset,Te.startContainer,Te.startOffset):pe.setBaseAndExtent(Te.startContainer,Te.startOffset,Te.endContainer,Te.endOffset),l(p,Te)):pe.removeAllRanges(),Te}p.selection=Z.toSlateRange(p,pe,{exactMatch:!1,suppressThrow:!0})}};pe.rangeCount<=1&&fe();var we=((X=R.current)===null||X===void 0?void 0:X.isFlushing())==="action";if(It&&we){var Ce=null,se=requestAnimationFrame((()=>{if(we){var te=me=>{try{Z.toDOMNode(p,p).focus(),fe(me)}catch{}};te(),Ce=setTimeout((()=>{te(!0),k.isUpdatingSelection=!1}))}}));return()=>{cancelAnimationFrame(se),Ce&&clearTimeout(Ce)}}setTimeout((()=>{k.isUpdatingSelection=!1}))}}));var W=m.useCallback((_=>{var X=Z.toDOMNode(p,p).getRootNode();if(I!=null&&I.current&&Or&&X instanceof ShadowRoot){var K=_.getTargetRanges()[0],Y=new window.Range;Y.setStart(K.startContainer,K.startOffset),Y.setEnd(K.endContainer,K.endOffset);var de=Z.toSlateRange(p,Y,{exactMatch:!1,suppressThrow:!1});return z.select(p,de),_.preventDefault(),void _.stopImmediatePropagation()}if(T(),!a&&Z.hasEditableTarget(p,_.target)&&!G2(_,i)){var pe;if(R.current)return R.current.handleDOMBeforeInput(_);H.flush(),M.flush();var{selection:fe}=p,{inputType:we}=_,Ce=_.dataTransfer||_.data||void 0,se=we==="insertCompositionText"||we==="deleteCompositionText";if(se&&Z.isComposing(p))return;var te=!1;if(we==="insertText"&&fe&&U.isCollapsed(fe)&&_.data&&_.data.length===1&&/[a-z ]/i.test(_.data)&&fe.anchor.offset!==0&&(te=!0,p.marks&&(te=!1),!Ao.get(p))){var me,Ae,{anchor:Pe}=fe,[Be,re]=Z.toDOMPoint(p,Pe),J=(me=Be.parentElement)===null||me===void 0?void 0:me.closest("a"),oe=Z.getWindow(p);if(te&&J&&Z.hasDOMNode(p,J)){var ge,ve=oe?.document.createTreeWalker(J,NodeFilter.SHOW_TEXT).lastChild();ve===Be&&((ge=ve.textContent)===null||ge===void 0?void 0:ge.length)===re&&(te=!1)}if(te&&Be.parentElement&&(oe==null||(Ae=oe.getComputedStyle(Be.parentElement))===null||Ae===void 0?void 0:Ae.whiteSpace)==="pre"){var Te=D.above(p,{at:Pe.path,match:mn=>le.isElement(mn)&&D.isBlock(p,mn)});Te&&ee.string(Te[0]).includes(" ")&&(te=!1)}}if((!we.startsWith("delete")||we.startsWith("deleteBy"))&&!Ao.get(p)){var[We]=_.getTargetRanges();if(We){var Le=Z.toSlateRange(p,We,{exactMatch:!1,suppressThrow:!1});if(!fe||!U.equals(fe,Le)){te=!1;var et=!se&&p.selection&&D.rangeRef(p,p.selection);z.select(p,Le),et&&gi.set(p,et)}}}if(se)return;if(te||_.preventDefault(),fe&&U.isExpanded(fe)&&we.startsWith("delete")){var ut=we.endsWith("Backward")?"backward":"forward";return void D.deleteFragment(p,{direction:ut})}switch(we){case"deleteByComposition":case"deleteByCut":case"deleteByDrag":D.deleteFragment(p);break;case"deleteContent":case"deleteContentForward":D.deleteForward(p);break;case"deleteContentBackward":D.deleteBackward(p);break;case"deleteEntireSoftLine":D.deleteBackward(p,{unit:"line"}),D.deleteForward(p,{unit:"line"});break;case"deleteHardLineBackward":D.deleteBackward(p,{unit:"block"});break;case"deleteSoftLineBackward":D.deleteBackward(p,{unit:"line"});break;case"deleteHardLineForward":D.deleteForward(p,{unit:"block"});break;case"deleteSoftLineForward":D.deleteForward(p,{unit:"line"});break;case"deleteWordBackward":D.deleteBackward(p,{unit:"word"});break;case"deleteWordForward":D.deleteForward(p,{unit:"word"});break;case"insertLineBreak":D.insertSoftBreak(p);break;case"insertParagraph":D.insertBreak(p);break;case"insertFromComposition":case"insertFromDrop":case"insertFromPaste":case"insertFromYank":case"insertReplacementText":case"insertText":we==="insertFromComposition"&&Z.isComposing(p)&&(b(!1),Mr.set(p,!1)),Ce?.constructor.name==="DataTransfer"?Z.insertData(p,Ce):typeof Ce=="string"&&(te?E.current.push((()=>D.insertText(p,Ce))):D.insertText(p,Ce))}var Nt=(pe=gi.get(p))===null||pe===void 0?void 0:pe.unref();gi.delete(p),!Nt||p.selection&&U.equals(p.selection,Nt)||z.select(p,Nt)}}),[p,M,T,i,a,H]),G=m.useCallback((_=>{_==null?(M.cancel(),H.cancel(),Ss.delete(p),$r.delete(p),C.current&&nr&&C.current.removeEventListener("beforeinput",W)):nr&&_.addEventListener("beforeinput",W),C.current=_,typeof t=="function"?t(_):t&&(t.current=_)}),[M,H,p,W,t]);Fi((()=>{var _=Z.getWindow(p);_.document.addEventListener("selectionchange",H);var X=()=>{k.isDraggingInternally=!1};return _.document.addEventListener("dragend",X),_.document.addEventListener("drop",X),()=>{_.document.removeEventListener("selectionchange",H),_.document.removeEventListener("dragend",X),_.document.removeEventListener("drop",X)}}),[H,k]);var q=o([p,[]]),$=s&&p.children.length===1&&Array.from(ee.texts(p)).length===1&&ee.string(p)===""&&!w,V=m.useCallback((_=>{var X;x(_&&$?(X=_.getBoundingClientRect())===null||X===void 0?void 0:X.height:void 0)}),[$]);if($){var Q=D.start(p,[]);q.push({[jo]:!0,placeholder:s,onPlaceholderResize:V,anchor:Q,focus:Q})}var{marks:ae}=p;if(k.hasMarkPlaceholder=!1,p.selection&&U.isCollapsed(p.selection)&&ae){var{anchor:ie}=p.selection,Se=ee.leaf(p,ie.path),Ie=Ro(Se,V2);if(!he.equals(Se,ae,{loose:!0})){k.hasMarkPlaceholder=!0;var ne=Object.fromEntries(Object.keys(Ie).map((_=>[_,null])));q.push(Cn(Cn(Cn({[H0]:!0},ne),ae),{},{anchor:ie,focus:ie}))}}return m.useEffect((()=>{setTimeout((()=>{var{selection:_}=p;if(_){var{anchor:X}=_,K=ee.leaf(p,X.path);if(ae&&!he.equals(K,ae,{loose:!0}))return void an.set(p,ae)}an.delete(p)}))})),_e.createElement(Q0.Provider,{value:a},_e.createElement(U2.Provider,{value:w},_e.createElement(J0.Provider,{value:o},_e.createElement(L2,{node:C,receivedUserInput:B},_e.createElement(h,Cn(Cn({role:a?void 0:"textbox","aria-multiline":!a||void 0},y),{},{spellCheck:!(!nr&&Os)&&y.spellCheck,autoCorrect:nr||!Os?y.autoCorrect:"false",autoCapitalize:nr||!Os?y.autoCapitalize:"false","data-slate-editor":!0,"data-slate-node":"value",contentEditable:!a,zindex:-1,suppressContentEditableWarning:!0,ref:G,style:Cn(Cn({},g?{}:Cn({position:"relative",whiteSpace:"pre-wrap",wordWrap:"break-word"},A?{minHeight:A}:{})),d),onBeforeInput:m.useCallback((_=>{if(!nr&&!a&&!Dt(_,y.onBeforeInput)&&Z.hasSelectableTarget(p,_.target)&&(_.preventDefault(),!Z.isComposing(p))){var X=_.data;D.insertText(p,X)}}),[y.onBeforeInput,p,a]),onInput:m.useCallback((_=>{if(!Dt(_,y.onInput))if(R.current)R.current.handleInput();else{for(var X of E.current)X();if(E.current=[],!Z.isFocused(p)){var K=_.nativeEvent,Y=p;if(K.inputType==="historyUndo"&&typeof Y.undo=="function")return void Y.undo();if(K.inputType==="historyRedo"&&typeof Y.redo=="function")return void Y.redo()}}}),[y.onInput,p]),onBlur:m.useCallback((_=>{if(!a&&!k.isUpdatingSelection&&Z.hasSelectableTarget(p,_.target)&&!Dt(_,y.onBlur)){var X=Z.findDocumentOrShadowRoot(p);if(k.latestElement!==X.activeElement){var{relatedTarget:K}=_;if(!(K===Z.toDOMNode(p,p)||Gt(K)&&K.hasAttribute("data-slate-spacer"))){if(K!=null&&gr(K)&&Z.hasDOMNode(p,K)){var Y=Z.toSlateNode(p,K);if(le.isElement(Y)&&!p.isVoid(Y))return}if(Or){var de=vi(X);de?.removeAllRanges()}dr.delete(p)}}}}),[a,k.isUpdatingSelection,k.latestElement,p,y.onBlur]),onClick:m.useCallback((_=>{if(Z.hasTarget(p,_.target)&&!Dt(_,y.onClick)&&gr(_.target)){var X=Z.toSlateNode(p,_.target),K=Z.findPath(p,X);if(!D.hasPath(p,K)||ee.get(p,K)!==X)return;if(_.detail===3&&K.length>=1){var Y=K;if(!le.isElement(X)||!D.isBlock(p,X)){var de,pe=D.above(p,{match:Ae=>le.isElement(Ae)&&D.isBlock(p,Ae),at:K});Y=(de=pe?.[1])!==null&&de!==void 0?de:K.slice(0,1)}var fe=D.range(p,Y);return void z.select(p,fe)}if(a)return;var we=D.start(p,K),Ce=D.end(p,K),se=D.void(p,{at:we}),te=D.void(p,{at:Ce});if(se&&te&&F.equals(se[1],te[1])){var me=D.range(p,we);z.select(p,me)}}}),[p,y.onClick,a]),onCompositionEnd:m.useCallback((_=>{if(Z.hasSelectableTarget(p,_.target)){var X;if(Z.isComposing(p)&&Promise.resolve().then((()=>{b(!1),Mr.set(p,!1)})),(X=R.current)===null||X===void 0||X.handleCompositionEnd(_),Dt(_,y.onCompositionEnd)||It)return;if(!Or&&!a2&&!P0&&!c2&&!u2&&_.data){var K=an.get(p);an.delete(p),K!==void 0&&(Ln.set(p,p.marks),p.marks=K),D.insertText(p,_.data);var Y=Ln.get(p);Ln.delete(p),Y!==void 0&&(p.marks=Y)}}}),[y.onCompositionEnd,p]),onCompositionUpdate:m.useCallback((_=>{Z.hasSelectableTarget(p,_.target)&&!Dt(_,y.onCompositionUpdate)&&(Z.isComposing(p)||(b(!0),Mr.set(p,!0)))}),[y.onCompositionUpdate,p]),onCompositionStart:m.useCallback((_=>{if(Z.hasSelectableTarget(p,_.target)){var X;if((X=R.current)===null||X===void 0||X.handleCompositionStart(_),Dt(_,y.onCompositionStart)||It)return;b(!0);var{selection:K}=p;if(K&&U.isExpanded(K))return void D.deleteFragment(p)}}),[y.onCompositionStart,p]),onCopy:m.useCallback((_=>{!Z.hasSelectableTarget(p,_.target)||Dt(_,y.onCopy)||qh(_)||(_.preventDefault(),Z.setFragmentData(p,_.clipboardData,"copy"))}),[y.onCopy,p]),onCut:m.useCallback((_=>{if(!a&&Z.hasSelectableTarget(p,_.target)&&!Dt(_,y.onCut)&&!qh(_)){_.preventDefault(),Z.setFragmentData(p,_.clipboardData,"cut");var{selection:X}=p;if(X)if(U.isExpanded(X))D.deleteFragment(p);else{var K=ee.parent(p,X.anchor.path);D.isVoid(p,K)&&z.delete(p)}}}),[a,p,y.onCut]),onDragOver:m.useCallback((_=>{if(Z.hasTarget(p,_.target)&&!Dt(_,y.onDragOver)){var X=Z.toSlateNode(p,_.target);le.isElement(X)&&D.isVoid(p,X)&&_.preventDefault()}}),[y.onDragOver,p]),onDragStart:m.useCallback((_=>{if(!a&&Z.hasTarget(p,_.target)&&!Dt(_,y.onDragStart)){var X=Z.toSlateNode(p,_.target),K=Z.findPath(p,X);if(le.isElement(X)&&D.isVoid(p,X)||D.void(p,{at:K,voids:!0})){var Y=D.range(p,K);z.select(p,Y)}k.isDraggingInternally=!0,Z.setFragmentData(p,_.dataTransfer,"drag")}}),[a,p,y.onDragStart,k]),onDrop:m.useCallback((_=>{if(!a&&Z.hasTarget(p,_.target)&&!Dt(_,y.onDrop)){_.preventDefault();var X=p.selection,K=Z.findEventRange(p,_),Y=_.dataTransfer;z.select(p,K),k.isDraggingInternally&&(!X||U.equals(X,K)||D.void(p,{at:K,voids:!0})||z.delete(p,{at:X})),Z.insertData(p,Y),Z.isFocused(p)||Z.focus(p)}}),[a,p,y.onDrop,k]),onDragEnd:m.useCallback((_=>{!a&&k.isDraggingInternally&&y.onDragEnd&&Z.hasTarget(p,_.target)&&y.onDragEnd(_)}),[a,k,y,p]),onFocus:m.useCallback((_=>{if(!a&&!k.isUpdatingSelection&&Z.hasEditableTarget(p,_.target)&&!Dt(_,y.onFocus)){var X=Z.toDOMNode(p,p),K=Z.findDocumentOrShadowRoot(p);if(k.latestElement=K.activeElement,vo&&_.target!==X)return void X.focus();dr.set(p,!0)}}),[a,k,p,y.onFocus]),onKeyDown:m.useCallback((_=>{if(!a&&Z.hasEditableTarget(p,_.target)){var X;(X=R.current)===null||X===void 0||X.handleKeyDown(_);var{nativeEvent:K}=_;if(Z.isComposing(p)&&K.isComposing===!1&&(Mr.set(p,!1),b(!1)),Dt(_,y.onKeyDown)||Z.isComposing(p))return;var{selection:Y}=p,de=p.children[Y!==null?Y.focus.path[0]:0],pe=k0(ee.string(de))==="rtl";if(Ze.isRedo(K)){_.preventDefault();var fe=p;return void(typeof fe.redo=="function"&&fe.redo())}if(Ze.isUndo(K)){_.preventDefault();var we=p;return void(typeof we.undo=="function"&&we.undo())}if(Ze.isMoveLineBackward(K))return _.preventDefault(),void z.move(p,{unit:"line",reverse:!0});if(Ze.isMoveLineForward(K))return _.preventDefault(),void z.move(p,{unit:"line"});if(Ze.isExtendLineBackward(K))return _.preventDefault(),void z.move(p,{unit:"line",edge:"focus",reverse:!0});if(Ze.isExtendLineForward(K))return _.preventDefault(),void z.move(p,{unit:"line",edge:"focus"});if(Ze.isMoveBackward(K))return _.preventDefault(),void(Y&&U.isCollapsed(Y)?z.move(p,{reverse:!pe}):z.collapse(p,{edge:pe?"end":"start"}));if(Ze.isMoveForward(K))return _.preventDefault(),void(Y&&U.isCollapsed(Y)?z.move(p,{reverse:pe}):z.collapse(p,{edge:pe?"start":"end"}));if(Ze.isMoveWordBackward(K))return _.preventDefault(),Y&&U.isExpanded(Y)&&z.collapse(p,{edge:"focus"}),void z.move(p,{unit:"word",reverse:!pe});if(Ze.isMoveWordForward(K))return _.preventDefault(),Y&&U.isExpanded(Y)&&z.collapse(p,{edge:"focus"}),void z.move(p,{unit:"word",reverse:pe});if(nr){if((N0||Or)&&Y&&(Ze.isDeleteBackward(K)||Ze.isDeleteForward(K))&&U.isCollapsed(Y)){var Ce=ee.parent(p,Y.anchor.path);if(le.isElement(Ce)&&D.isVoid(p,Ce)&&(D.isInline(p,Ce)||D.isBlock(p,Ce)))return _.preventDefault(),void D.deleteBackward(p,{unit:"block"})}}else{if(Ze.isBold(K)||Ze.isItalic(K)||Ze.isTransposeCharacter(K))return void _.preventDefault();if(Ze.isSoftBreak(K))return _.preventDefault(),void D.insertSoftBreak(p);if(Ze.isSplitBlock(K))return _.preventDefault(),void D.insertBreak(p);if(Ze.isDeleteBackward(K))return _.preventDefault(),void(Y&&U.isExpanded(Y)?D.deleteFragment(p,{direction:"backward"}):D.deleteBackward(p));if(Ze.isDeleteForward(K))return _.preventDefault(),void(Y&&U.isExpanded(Y)?D.deleteFragment(p,{direction:"forward"}):D.deleteForward(p));if(Ze.isDeleteLineBackward(K))return _.preventDefault(),void(Y&&U.isExpanded(Y)?D.deleteFragment(p,{direction:"backward"}):D.deleteBackward(p,{unit:"line"}));if(Ze.isDeleteLineForward(K))return _.preventDefault(),void(Y&&U.isExpanded(Y)?D.deleteFragment(p,{direction:"forward"}):D.deleteForward(p,{unit:"line"}));if(Ze.isDeleteWordBackward(K))return _.preventDefault(),void(Y&&U.isExpanded(Y)?D.deleteFragment(p,{direction:"backward"}):D.deleteBackward(p,{unit:"word"}));if(Ze.isDeleteWordForward(K))return _.preventDefault(),void(Y&&U.isExpanded(Y)?D.deleteFragment(p,{direction:"forward"}):D.deleteForward(p,{unit:"word"}))}}}),[a,p,y.onKeyDown]),onPaste:m.useCallback((_=>{a||!Z.hasEditableTarget(p,_.target)||Dt(_,y.onPaste)||(!nr||(X=>X.clipboardData&&X.clipboardData.getData("text/plain")!==""&&X.clipboardData.types.length===1)(_.nativeEvent)||Or)&&(_.preventDefault(),Z.insertData(p,_.clipboardData))}),[a,p,y.onPaste])}),_e.createElement($2,{decorations:q,node:p,renderElement:u,renderPlaceholder:f,renderLeaf:c,selection:p.selection}))))))})),z2=e=>{var{attributes:t,children:n}=e;return _e.createElement("span",Cn({},t),n,It&&_e.createElement("br",null))},K2=()=>[],q2=(e,t)=>{if(t.getBoundingClientRect&&(!e.selection||e.selection&&U.isCollapsed(e.selection))){var n=t.startContainer.parentElement;n.getBoundingClientRect=t.getBoundingClientRect.bind(t),zD(n,{scrollMode:"if-needed"}),delete n.getBoundingClientRect}},Dt=(e,t)=>{if(!t)return!1;var n=t(e);return n??(e.isDefaultPrevented()||e.isPropagationStopped())},qh=e=>gr(e.target)&&(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement),G2=(e,t)=>{if(!t)return!1;var n=t(e);return n??e.defaultPrevented},J2=m.createContext(!1),Z2=m.createContext({}),X2=["editor","children","onChange","onSelectionChange","onValueChange","initialValue"],Y2=e=>{var{editor:t,children:n,onChange:r,onSelectionChange:o,onValueChange:i,initialValue:s}=e,a=Ro(e,X2),[u,c]=_e.useState((()=>{if(!ee.isNodeList(s))throw new Error("[Slate] initialValue is invalid! Expected a list of elements but got: ".concat(ht.stringify(s)));if(!D.isEditor(t))throw new Error("[Slate] editor is invalid! You passed: ".concat(ht.stringify(t)));return t.children=s,Object.assign(t,a),{v:0,editor:t}})),{selectorContext:f,onChange:l}=(function(y){var p=m.useRef([]).current,w=m.useRef({editor:y}).current,b=m.useCallback((C=>{w.editor=C,p.forEach((E=>E(C)))}),[p,w]);return{selectorContext:m.useMemo((()=>({getSlate:()=>w.editor,addEventListener:C=>(p.push(C),()=>{p.splice(p.indexOf(C),1)})})),[p,w]),onChange:b}})(t),d=m.useCallback((y=>{var p;r&&r(t.children),(y==null||(p=y.operation)===null||p===void 0?void 0:p.type)==="set_selection"?o?.(t.selection):i?.(t.children),c((w=>({v:w.v+1,editor:t}))),l(t)}),[t,l,r,o,i]);m.useEffect((()=>(gc.set(t,d),()=>{gc.set(t,(()=>{}))})),[t,d]);var[h,g]=m.useState(Z.isFocused(t));return m.useEffect((()=>{g(Z.isFocused(t))}),[t]),Fi((()=>{var y=()=>g(Z.isFocused(t));return M0>=17?(document.addEventListener("focusin",y),document.addEventListener("focusout",y),()=>{document.removeEventListener("focusin",y),document.removeEventListener("focusout",y)}):(document.addEventListener("focus",y,!0),document.addEventListener("blur",y,!0),()=>{document.removeEventListener("focus",y,!0),document.removeEventListener("blur",y,!0)})}),[]),_e.createElement(Z2.Provider,{value:f},_e.createElement(ev.Provider,{value:u},_e.createElement(Ml.Provider,{value:u.editor},_e.createElement(J2.Provider,{value:h},n))))},Gh=(e,t)=>{var n=(t.top+t.bottom)/2;return e.top<=n&&e.bottom>=n},Jh=(e,t,n)=>{var r=Z.toDOMRange(e,t).getBoundingClientRect(),o=Z.toDOMRange(e,n).getBoundingClientRect();return Gh(r,o)&&Gh(o,r)};function Zh(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable}))),n.push.apply(n,r)}return n}function Xh(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Zh(Object(n),!0).forEach((function(r){en(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Zh(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var Q2=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"x-slate-fragment",n=e,{apply:r,onChange:o,deleteBackward:i,addMark:s,removeMark:a}=n;return va.set(n,new WeakMap),n.addMark=(u,c)=>{var f,l;(f=Ll.get(n))===null||f===void 0||f(),!an.get(n)&&(l=Rt.get(n))!==null&&l!==void 0&&l.length&&an.set(n,null),Ln.delete(n),s(u,c)},n.removeMark=u=>{var c;!an.get(n)&&(c=Rt.get(n))!==null&&c!==void 0&&c.length&&an.set(n,null),Ln.delete(n),a(u)},n.deleteBackward=u=>{if(u!=="line")return i(u);if(n.selection&&U.isCollapsed(n.selection)){var c=D.above(n,{match:h=>le.isElement(h)&&D.isBlock(n,h),at:n.selection});if(c){var[,f]=c,l=D.range(n,f,n.selection.anchor),d=((h,g)=>{var y=D.range(h,U.end(g)),p=Array.from(D.positions(h,{at:g})),w=0,b=p.length,C=Math.floor(b/2);if(Jh(h,D.range(h,p[w]),y))return D.range(h,p[w],y);if(p.length<2)return D.range(h,p[p.length-1],y);for(;C!==p.length&&C!==w;)Jh(h,D.range(h,p[C]),y)?b=C:w=C,C=Math.floor((w+b)/2);return D.range(h,p[b],y)})(n,l);U.isCollapsed(d)||z.delete(n,{at:d})}}},n.apply=u=>{var c=[],f=[],l=Rt.get(n);if(l!=null&&l.length){var d=l.map((M=>(function(H,W){var{path:G,diff:q,id:$}=H;switch(W.type){case"insert_text":return!F.equals(W.path,G)||W.offset>=q.end?H:W.offset<=q.start?{diff:{start:W.text.length+q.start,end:W.text.length+q.end,text:q.text},id:$,path:G}:{diff:{start:q.start,end:q.end+W.text.length,text:q.text},id:$,path:G};case"remove_text":return!F.equals(W.path,G)||W.offset>=q.end?H:W.offset+W.text.length<=q.start?{diff:{start:q.start-W.text.length,end:q.end-W.text.length,text:q.text},id:$,path:G}:{diff:{start:q.start,end:q.end-W.text.length,text:q.text},id:$,path:G};case"split_node":return!F.equals(W.path,G)||W.position>=q.end?{diff:q,id:$,path:F.transform(G,W,{affinity:"backward"})}:W.position>q.start?{diff:{start:q.start,end:Math.min(W.position,q.end),text:q.text},id:$,path:G}:{diff:{start:q.start-W.position,end:q.end-W.position,text:q.text},id:$,path:F.transform(G,W,{affinity:"forward"})};case"merge_node":return F.equals(W.path,G)?{diff:{start:q.start+W.position,end:q.end+W.position,text:q.text},id:$,path:F.transform(G,W)}:{diff:q,id:$,path:F.transform(G,W)}}var V=F.transform(G,W);return V?{diff:q,path:V,id:$}:null})(M,u))).filter(Boolean);Rt.set(n,d)}var h=ir.get(n);h&&ir.set(n,Nh(n,h,u));var g=or.get(n);if(g!=null&&g.at){var y=Re.isPoint(g?.at)?bc(n,g.at,u):Nh(n,g.at,u);or.set(n,y?Xh(Xh({},g),{},{at:y}):null)}switch(u.type){case"insert_text":case"remove_text":case"set_node":case"split_node":c.push(...io(n,u.path));break;case"set_selection":var p;(p=gi.get(n))===null||p===void 0||p.unref(),gi.delete(n);break;case"insert_node":case"remove_node":c.push(...io(n,F.parent(u.path)));break;case"merge_node":var w=F.previous(u.path);c.push(...io(n,w));break;case"move_node":var b,C=F.common(F.parent(u.path),F.parent(u.newPath));c.push(...io(n,C)),F.isBefore(u.path,u.newPath)?(c.push(...io(n,F.parent(u.path))),b=u.newPath):(c.push(...io(n,F.parent(u.newPath))),b=u.path);var E=ee.get(e,F.parent(b)),A=Z.findKey(n,E),x=D.pathRef(n,F.parent(b));f.push([x,A])}switch(r(u),u.type){case"insert_node":case"remove_node":case"merge_node":case"move_node":case"split_node":Ao.set(n,!0)}for(var[I,T]of c){var[B]=D.node(n,I);Zs.set(B,T)}for(var[S,k]of f){if(S.current){var[R]=D.node(n,S.current);Zs.set(R,k)}S.unref()}},n.setFragmentData=u=>{var{selection:c}=n;if(c){var[f,l]=U.edges(c),d=D.void(n,{at:f.path}),h=D.void(n,{at:l.path});if(!U.isCollapsed(c)||d){var g=Z.toDOMRange(n,c),y=g.cloneContents(),p=y.childNodes[0];if(y.childNodes.forEach((B=>{B.textContent&&B.textContent.trim()!==""&&(p=B)})),h){var[w]=h,b=g.cloneRange(),C=Z.toDOMNode(n,w);b.setEndAfter(C),y=b.cloneContents()}if(d&&(p=y.querySelector("[data-slate-spacer]")),Array.from(y.querySelectorAll("[data-slate-zero-width]")).forEach((B=>{var S=B.getAttribute("data-slate-zero-width")==="n";B.textContent=S?`
58
+ `:""})),$0(p)){var E=p.ownerDocument.createElement("span");E.style.whiteSpace="pre",E.appendChild(p),y.appendChild(E),p=E}var A=n.getFragment(),x=JSON.stringify(A),I=window.btoa(encodeURIComponent(x));p.setAttribute("data-slate-fragment",I),u.setData("application/".concat(t),I);var T=y.ownerDocument.createElement("div");return T.appendChild(y),T.setAttribute("hidden","true"),y.ownerDocument.body.appendChild(T),u.setData("text/html",T.innerHTML),u.setData("text/plain",z0(T)),y.ownerDocument.body.removeChild(T),u}}},n.insertData=u=>{n.insertFragmentData(u)||n.insertTextData(u)},n.insertFragmentData=u=>{var c=u.getData("application/".concat(t))||(d=>{var h=d.getData("text/html"),[,g]=h.match(h2)||[];return g})(u);if(c){var f=decodeURIComponent(window.atob(c)),l=JSON.parse(f);return n.insertFragment(l),!0}return!1},n.insertTextData=u=>{var c=u.getData("text/plain");if(c){var f=c.split(/\r\n|\r|\n/),l=!1;for(var d of f)l&&z.splitNodes(n,{always:!0}),n.insertText(d),l=!0;return!0}return!1},n.onChange=u=>{(M0<18?g1.unstable_batchedUpdates:c=>c())((()=>{var c=gc.get(n);c&&c(u),o(u)}))},n},io=(e,t)=>{var n=[];for(var[r,o]of D.levels(e,{at:t})){var i=Z.findKey(e,r);n.push([o,i])}return n};function Vl(e,t,n=3){if(!(n<=0))try{return Z.toDOMRange(e,t)}catch{return Vl(e,{anchor:t.anchor,focus:t.anchor},n-1)}}function Mo(e){return!e.trim()}function kn(e){return!("type"in e)&&"text"in e&&typeof e.text=="string"}function wc(e){return kn(e)&&Object.keys(e).length===1}function Ec(e,t){for(const n of t)if(kn(n)){if(!Mo(n.text))return!1}else if(n.type==="paragraph"){if(n.children.length>1||n.children[0]&&(!kn(n.children[0])||!Mo(n.children[0].text)))return!1}else if(!D.isEmpty(e,n))return!1;return!0}let Is;const Dc=new WeakMap,Ac=new WeakMap;function Yh(e,t){t?(Ac.get(e)?.unobserve(e),Ac.delete(e)):(Dc.delete(e),Is?.unobserve(e))}function eA(e,t,n){const r=n?.enabled??!0,o=ra(t),{root:i,rootMargin:s,threshold:a}=n??{};m.useEffect((()=>{const u=e.current;if(!u)return;const c={root:i,rootMargin:s,threshold:a};return r?(function(f,l,d){if(d){const h=new IntersectionObserver((g=>{for(const y of g)l?.(y)}),{root:d.root?.current,rootMargin:typeof d.rootMargin=="number"?`${d.rootMargin}px`:d.rootMargin,threshold:d.threshold});Ac.set(f,h),h.observe(f)}else Is||(Is=new IntersectionObserver((h=>{for(const g of h)Dc.get(g.target)?.(g)}))),Dc.set(f,l),Is.observe(f)})(u,(f=>{o.current(f.isIntersecting,f)}),c):Yh(u,c),()=>{Yh(u,c)}}),[e,r,o,i,s,a])}const $l=m.forwardRef((({children:e,asChild:t,...n},r)=>{const o=t?vt:"span";return v.jsx(o,{...n,ref:r,children:e})})),nv=m.forwardRef((({children:e,asChild:t,...n},r)=>{const o=t?vt:"a";return v.jsx(o,{target:"_blank",rel:"noopener noreferrer nofollow",...n,ref:r,children:e})})),tA={Mention:({mention:e})=>v.jsxs($l,{children:[On,e.id]}),Link:({href:e,children:t})=>v.jsx(nv,{href:e,children:t})},nA=m.forwardRef((({body:e,components:t,style:n,asChild:r,...o},i)=>{const s=r?vt:"div",{Mention:a,Link:u}=m.useMemo((()=>({...tA,...t})),[t]);return e&&e?.content?v.jsx(s,{...o,style:{whiteSpace:"break-spaces",...n},ref:i,children:e.content.map(((c,f)=>c.type==="paragraph"?v.jsx("p",{style:{minHeight:"1lh"},children:c.children.map(((l,d)=>{if(pm(l)){const{type:g,...y}=l;return y.id?v.jsx(a,{mention:y},d):null}if(mm(l)){const g=Gp(l.url);return g===null?v.jsx("span",{children:l.text??l.url},d):v.jsx(u,{href:g,children:l.text??l.url},d)}let h=l.text;return l.bold&&(h=v.jsx("strong",{children:h},d)),l.italic&&(h=v.jsx("em",{children:h},d)),l.strikethrough&&(h=v.jsx("s",{children:h},d)),l.code&&(h=v.jsx("code",{children:h},d)),v.jsx("span",{children:h},d)}))},f):null))}):null})),rA={alt:()=>"altKey",ctrl:()=>"ctrlKey",meta:()=>"metaKey",mod:()=>m0()?"metaKey":"ctrlKey",shift:()=>"shiftKey"};function At(e,t,n={}){return e.key!==t?!1:Object.entries(n).filter((([,o])=>typeof o=="boolean")).every((([o,i])=>{const s=rA[o]();return e[s]===i}))}const rv=m.createContext(null);function Wl(){return ye(m.useContext(rv),"Persist is missing from the React tree.")}function ov(e){const[t,n]=Wl(),r=m.useRef(null),o=m.useRef(null);Sn((()=>{const i=e.current;if(!i)return;const s=a=>{a.animationName===o.current&&n(),r.current=a.animationName};return i.addEventListener("animationcancel",s),i.addEventListener("animationend",s),()=>{i.removeEventListener("animationcancel",s),i.removeEventListener("animationend",s)}}),[e,n]),Sn((()=>{const i=e.current;let s;if(i)return t||(s=requestAnimationFrame((()=>{const a=getComputedStyle(i);o.current=a.animationName,a.animationName!=="none"&&a.animationName!==r.current&&a.display!=="none"||n()}))),()=>{cancelAnimationFrame(s)}}),[t,e,n])}function iv({children:e}){const[t,n]=m.useState(!0),r=m.useRef(null),o=(function(s){const a=Array.isArray(s)?m.Children.only(s):s;return m.isValidElement(a)?a:void 0})(e),i=m.useCallback((()=>{Mi.flushSync((()=>n(!1)))}),[]);return Sn((()=>{o&&(n(!0),r.current=o)}),[o]),v.jsx(rv.Provider,{value:[!!o,i],children:o??(t?r.current:null)})}function Qh(e,t,n){return Math.min(Math.max(e,t),n)}function oA(e,t,n){const r=n-t;return r>0?((e-t)%r+r)%r+t:0}const iA={wrap:!0};function zl(e,t){const n=ra(t);m.useEffect((()=>e.subscribe((()=>n.current()))),[e,n])}function Ri(e,t,n={}){const{filterVoids:r}=n,o=D.before(e,t,{unit:"character",voids:r});if(o){const i=D.range(e,o,U.isRange(t)?U.start(t):t),s=D.string(e,i);return{range:i,text:s,void:s.length===0}}}function Kl(e,t,n={}){const{filterVoids:r}=n,o=D.after(e,t,{unit:"character",voids:r});if(o){const i=D.range(e,o,U.isRange(t)?U.end(t):t),s=D.string(e,i);return{range:i,text:s,void:s.length===0}}}const ep={bold:!1,italic:!1,strikethrough:!1,code:!1};function tp(e){if(!e)return{...ep};const t=D.marks(e);return{...ep,...t}}function sv(e){return Object.keys(e??{}).filter((t=>t!=="text"))}function si(e,t){(function(r,o){const i=D.marks(r);return!!i&&i[o]===!0})(e,t)?D.removeMark(e,t):D.addMark(e,t,!0)}function av(e){const t=D.marks(e);if(t)for(const n in t)D.removeMark(e,n)}function np(e,t){e.selection&&U.isCollapsed(e.selection)&&Object.keys(D.marks(e)??{}).length>0&&((t==="start"?Ri(e,e.selection):Kl(e,e.selection))||av(e))}const uv=m.createContext(null),cv=m.createContext(null),lv=m.createContext(null),dv=m.createContext(null),fv=m.createContext(null);function ya(){return ye(m.useContext(cv),"Composer.Form is missing from the React tree.")}function hv(){return m.useContext(lv)}function ql(){return ye(hv(),"Composer.Form is missing from the React tree.")}function Gl(e="useComposerSuggestionsContext"){return ye(m.useContext(dv),`${e} can’t be used outside of Composer.Editor.`)}function zt(){return ye(m.useContext(uv),"Composer.Form is missing from the React tree.")}const sA=/\s/;function Xs(e){return!!e&&sA.test(e)}const rp={direction:"before",allowConsecutiveWhitespace:!0};function pv(e,t,n=[" "],r=rp){const{include:o,direction:i,ignoreTerminator:s,allowConsecutiveWhitespace:a}={...rp,...r};let[u,c]=U.edges(t),f=u,l=!1;function d(h){const g=h==="after"?D.after(e,f,{unit:"character"}):D.before(e,f,{unit:"character"});if(!g||F.compare(g.path,f.path)!==0)return!1;const y=g&&D.string(e,h==="after"?{anchor:f,focus:g}:{anchor:g,focus:f}),p=y&&y[h==="after"?0:y.length-1];return!(!a&&l&&Xs(p))&&!(!g||!p||n.includes(p)&&!s?.(p,g,h))&&(l=Xs(p),f=g,f.offset!==0)}if(i!=="before"){for(f=c;d("after"););c=f}if(i!=="after"){for(f=u;d("before"););u=f}return o?{anchor:i==="before"||i==="both"?D.before(e,u,{unit:"offset"})??u:u,focus:i==="after"||i==="both"?D.after(e,c,{unit:"offset"})??c:c}:{anchor:u,focus:c}}const mv=[{type:"mark",mark:"bold",character:"*"},{type:"mark",mark:"italic",character:"_"},{type:"mark",mark:"strikethrough",character:"~"},{type:"mark",mark:"code",character:"`"}],aA=mv.filter((e=>e.type==="mark")).map((e=>e.character));function uA(e,t,n){if(t!==n.character)return!1;const r=pv(e,e.selection,[n.character]);if(!r||U.isCollapsed(r))return!1;const o=Ri(e,r);if(!o||o.text!==n.character)return!1;const i=Ri(e,o.range);if(i&&!aA.includes(i.text)&&!Mo(i.text))return!1;const s=D.string(e,r);return s.trim()===s&&(z.select(e,r),e.addMark(n.mark,!0),z.collapse(e,{edge:"end"}),e.removeMark(n.mark),z.delete(e,{at:o.range}),!0)}function cA(e){const{isInline:t,normalizeNode:n,insertData:r}=e;return e.isInline=o=>o.type==="custom-link"||t(o),e.normalizeNode=o=>{const[i,s]=o;if(le.isElement(i)&&i.type==="custom-link"&&(i.children.length===0||i.children.length===1&&i.children[0]?.text==="")&&z.removeNodes(e,{at:s}),kn(i)&&Ys(ee.parent(e,s))&&!wc(i)){const a=sv(i);z.unsetNodes(e,a,{at:s})}n(o)},e.insertData=o=>{const{selection:i}=e,s=o.getData("text/plain");let a=!0;i&&!U.isCollapsed(i)&&i.anchor.path[0]===i.focus.path[0]&&(function(u){try{return new URL(u),!0}catch{return!1}})(s)&&((function(u,c){const{selection:f}=u;if(!f)return!1;const l=Array.from(D.nodes(u,{at:f,match:d=>le.isElement(d)&&D.isBlock(u,d),mode:"lowest"}));for(const[,d]of l){const h=U.isRange(f)?U.intersection(f,D.range(u,d)):f;if(!h)continue;if(Array.from(D.nodes(u,{at:h,match:y=>D.isInline(u,y)&&c(y)})).length>0)return!0}return!1})(e,(u=>!kn(u)))||(z.wrapNodes(e,{type:"custom-link",url:s,children:[]},{at:i,split:!0,match:wc}),a=!1)),a&&r(o)},e}function Ys(e){return le.isElement(e)&&e.type==="custom-link"}function xo(e){return le.isElement(e)&&e.type==="auto-link"}const gv=/((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9().@:%_+~#?&//=]*)/,lA=/[.,;!?\s()]/,dA=/^[.?][a-zA-Z0-9]+/,fA=/[()]/;function Qs(e){return lA.test(e)}function vv(e){const t=e[e.length-1];return t!==void 0&&Qs(t)}function yv(e){const t=e[0];return t!==void 0&&Qs(t)}function bv(e,t){const n=D.previous(e,{at:t});return!n||kn(n[0])&&(vv(n[0].text)||n[0].text==="")}function Cv(e,t){const n=D.next(e,{at:t});return!n||kn(n[0])&&(yv(n[0].text)||n[0].text==="")}const hA=(e,t)=>{const[n,r]=t,o=ee.children(e,r);for(const[f]of o)if(!kn(f))return void z.unwrapNodes(e,{at:r});const i=ee.string(n),s=gv.exec(i),a=s?.[0];if(!s||a!==i)return void z.unwrapNodes(e,{at:r});if((u=i)[u.length-1]==="."||u[u.length-1]==="?"){z.unwrapNodes(e,{at:r});const f=i.slice(0,i.length-1);return void z.wrapNodes(e,{type:"auto-link",url:f,children:[]},{at:{anchor:{path:r,offset:0},focus:{path:r,offset:f.length}},split:!0})}var u;const c=(function(f){if(!fA.test(f))return f.length;let l=0,d=0;for(const h of f){if(h==="("&&d++,h===")"&&(d--,d<0))break;l++}return l})(i);if(c<i.length){z.unwrapNodes(e,{at:r});const f=i.slice(0,c);z.wrapNodes(e,{type:"auto-link",url:f,children:[]},{at:{anchor:{path:r,offset:0},focus:{path:r,offset:f.length}},split:!0})}else bv(e,r)&&Cv(e,r)?n.url===i||z.setNodes(e,{url:a},{at:r}):z.unwrapNodes(e,{at:r})},pA=(e,t)=>{const[n,r]=t,o=gv.exec(n.text),i=o?.[0];if(!o||i===void 0)return;const s=o.index,a=s+i.length;(function(u,c,f,l){const[d,h]=c,g=d.text,y=g[f-1],p=f>0&&y?Qs(y):bv(u,h),w=g[l],b=l<g.length&&w?Qs(w):Cv(u,h);return p&&b})(e,t,s,a)&&z.wrapNodes(e,{type:"auto-link",url:i,children:[]},{at:{anchor:{path:r,offset:s},focus:{path:r,offset:a}},split:!0})},mA=(e,t)=>{const[n,r]=t,o=n.text,i=D.previous(e,{at:r});if(i&&xo(i[0])){if(dA.test(o))return z.unwrapNodes(e,{at:i[1]}),void z.mergeNodes(e,{at:r});if(!yv(o))return void z.unwrapNodes(e,{at:i[1]})}const s=D.next(e,{at:r});s&&xo(s[0])&&!vv(o)&&z.unwrapNodes(e,{at:s[1]})},gA=new RegExp("\\p{Extended_Pictographic}|\\p{Emoji_Modifier}|\\uFE0F|\\u200D","u"),vA=new Set(['"',"'",".","!","?",",",";","(",")","[","]","<",">"]);function ai(e){return le.isElement(e)&&e.type==="mention"}function yi(e){return yi=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},yi(e)}function yA(e){var t=(function(n,r){if(yi(n)!=="object"||n===null)return n;var o=n[Symbol.toPrimitive];if(o!==void 0){var i=o.call(n,r);if(yi(i)!=="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(n)})(e,"string");return yi(t)==="symbol"?t:String(t)}function Po(e,t,n){return(t=yA(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var wv=new WeakMap,Ev=new WeakMap;class Jl{}class Ts extends Jl{constructor(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(),Po(this,"offset",void 0),Po(this,"path",void 0);var{offset:n,path:r}=t;this.offset=n,this.path=r}}class ks extends Jl{constructor(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(),Po(this,"offset",void 0),Po(this,"path",void 0);var{offset:n,path:r}=t;this.offset=n,this.path=r}}var bA=e=>Ev.get(e);function op(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable}))),n.push.apply(n,r)}return n}function xc(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?op(Object(n),!0).forEach((function(r){Po(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):op(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var _s=new WeakSet,Bs=e=>{var t=[],n=o=>{if(o!=null){var i=t[t.length-1];if(typeof o=="string"){var s={text:o};_s.add(s),o=s}if(he.isText(o)){var a=o;he.isText(i)&&_s.has(i)&&_s.has(a)&&he.equals(i,a,{loose:!0})?i.text+=a.text:t.push(a)}else if(le.isElement(o))t.push(o);else{if(!(o instanceof Jl))throw new Error("Unexpected hyperscript child object: ".concat(o));var u=t[t.length-1];he.isText(u)||(n(""),u=t[t.length-1]),o instanceof Ts?((c,f)=>{var l=c.text.length;wv.set(c,[l,f])})(u,o):o instanceof ks&&((c,f)=>{var l=c.text.length;Ev.set(c,[l,f])})(u,o)}}};for(var r of e.flat(1/0))n(r);return t};function Dv(e,t,n){return xc(xc({},t),{},{children:Bs(n)})}function ip(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable}))),n.push.apply(n,r)}return n}function bi(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?ip(Object(n),!0).forEach((function(r){Po(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ip(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var sp,CA={anchor:function(e,t,n){return new Ts(t)},cursor:function(e,t,n){return[new Ts(t),new ks(t)]},editor:(sp=T0,(e,t,n)=>{var r,o=[];for(var i of n)U.isRange(i)?r=i:o.push(i);var s,a=Bs(o),u={},c=sp();for(var[f,l]of(Object.assign(c,t),c.children=a,ee.texts(c))){var d=(s=f,wv.get(s)),h=bA(f);if(d!=null){var[g]=d;u.anchor={path:l,offset:g}}if(h!=null){var[y]=h;u.focus={path:l,offset:y}}}if(u.anchor&&!u.focus)throw new Error("Slate hyperscript ranges must have both `<anchor />` and `<focus />` defined if one is defined, but you only defined `<anchor />`. For collapsed selections, use `<cursor />` instead.");if(!u.anchor&&u.focus)throw new Error("Slate hyperscript ranges must have both `<anchor />` and `<focus />` defined if one is defined, but you only defined `<focus />`. For collapsed selections, use `<cursor />` instead.");return r!=null?c.selection=r:U.isRange(u)&&(c.selection=u),c}),element:Dv,focus:function(e,t,n){return new ks(t)},fragment:function(e,t,n){return Bs(n)},selection:function(e,t,n){var r=n.find((i=>i instanceof Ts)),o=n.find((i=>i instanceof ks));if(!r||r.offset==null||r.path==null)throw new Error("The <selection> hyperscript tag must have an <anchor> tag as a child with `path` and `offset` attributes defined.");if(!o||o.offset==null||o.path==null)throw new Error("The <selection> hyperscript tag must have a <focus> tag as a child with `path` and `offset` attributes defined.");return xc({anchor:{offset:r.offset,path:r.path},focus:{offset:o.offset,path:o.path}},t)},text:function(e,t,n){var r=Bs(n);if(r.length>1)throw new Error("The <text> hyperscript tag must only contain a single node's worth of children.");var[o]=r;if(o==null&&(o={text:""}),!he.isText(o))throw new Error(`
59
+ The <text> hyperscript tag can only contain text content as children.`);return _s.delete(o),Object.assign(o,t),o}},wA=e=>function(t,n){for(var r=arguments.length,o=new Array(r>2?r-2:0),i=2;i<r;i++)o[i-2]=arguments[i];var s=e[t];if(!s)throw new Error("No hyperscript creator found for tag: <".concat(t,">"));return n==null&&(n={}),ft(n)||(o=[n].concat(o),n={}),s(t,n,o=o.filter((a=>!!a)).flat())},EA=e=>{var t={},n=function(){var o=e[r];if(typeof o!="object")throw new Error("Properties specified for a hyperscript shorthand should be an object, but for the custom element <".concat(r,"> tag you passed: ").concat(o));t[r]=(i,s,a)=>Dv(0,bi(bi({},o),s),a)};for(var r in e)n();return t},ui=(function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{elements:t={}}=e,n=EA(t),r=bi(bi(bi({},CA),n),e.creators);return wA(r)})();function ji(e){return e!=null}function Av(e){if(!e.types.includes("Files"))return[];let t=Array.from(e.items).map((n=>{const r=n.webkitGetAsEntry();return r&&r.isFile?n.getAsFile():null})).filter(ji);return t.length||(t=Array.from(e.files).filter((n=>n.type!==""))),t}const DA=/[\r\n]/g,AA=/\s+/g;function xA(e,t){try{const n=new URL(e),r=new URL(t);return n.origin===r.origin&&n.pathname===r.pathname}catch{return!1}}const Fn=()=>({type:"paragraph"}),ap={A:e=>{const t=e.getAttribute("href"),n=e.innerText;return{type:t&&xA(t,n)?"auto-link":"custom-link",url:t??""}},P:Fn,BLOCKQUOTE:Fn,H1:Fn,H2:Fn,H3:Fn,H4:Fn,H5:Fn,H6:Fn,LI:Fn},up={CODE:()=>({code:!0}),DEL:()=>({strikethrough:!0}),EM:()=>({italic:!0}),I:()=>({italic:!0}),S:()=>({strikethrough:!0}),STRONG:()=>({bold:!0}),B:()=>({bold:!0})};function xv(e){const t=[];return e.nodeName==="LI"&&t.push(e),e.childNodes.forEach((n=>{n.nodeType===1&&t.push(...xv(n))})),t}function cp(e,t){return e.map((n=>ui("text",t,n)))}function Oc(e){if(e.nodeType===3){let n=e.textContent;const r=n&&DA.test(n);return n&&r&&(n=n.replace(AA," ").trim()),n?{text:n}:null}if(e.nodeType!==1)return null;if(e.nodeName==="BR")return ui("element",{type:"paragraph"},[]);let t=Array.from(e.childNodes).map(Oc).flat();if((e.nodeName==="UL"||e.nodeName==="OL")&&(t=xv(e).map((n=>Oc(n))).flat()),t.length===0&&(t=[{text:""}]),e.nodeName==="BODY")return t.length>0&&t.every((n=>typeof n=="string"))&&(t=[{type:"paragraph",children:[{text:t.join("")}]}]),ui("fragment",{},t.filter((n=>typeof n!="string")));if(ap[e.nodeName]){const n=ap[e.nodeName](e);return ui("element",n,t)}if(up[e.nodeName]){const n=up[e.nodeName](e);return t.some((r=>r&&typeof r!="string"&&"type"in r))?ui("fragment",{},t):cp(t,n)}if(e.nodeName==="SPAN"){const n=e.style,r={};return n.fontWeight!=="bold"&&n.fontWeight!=="700"&&n.fontWeight!=="800"&&n.fontWeight!=="900"||(r.bold=!0),n.fontStyle==="italic"&&(r.italic=!0),n.textDecoration==="line-through"&&(r.strikethrough=!0),cp(t,r)}return t}const OA=[];function SA(e){switch(e){case"start":return"end";case"end":return"start";default:return"center"}}function Ov(e){const[t,n="center"]=e.split("-");return[t,n]}function Sv(){const[e,t]=m.useState(null),n=m.useCallback(t,[t]),[r,o]=m.useState();return Sn((()=>{if(e){const i=window.getComputedStyle(e).zIndex,s=parseInt(i,10);o(Number.isNaN(s)?void 0:s)}}),[e]),[n,r]}function Iv({type:e="bounds",position:t,alignment:n,dir:r,open:o}){return yg({...m.useMemo((()=>{const i={padding:10},s=[e==="range"?bC(i):null,Eg({...i,crossAxis:!1}),Ag(i),Cg({...i,limiter:wg()}),e==="range"?bg(6):null,Dg({...i,apply({availableWidth:a,availableHeight:u,elements:c}){c.floating.style.setProperty("--lb-composer-floating-available-width",`${a}px`),c.floating.style.setProperty("--lb-composer-floating-available-height",`${u}px`)}})];return{strategy:"fixed",placement:n==="center"?t:`${t}-${r==="rtl"?SA(n):n}`,middleware:s,whileElementsMounted:(...a)=>gg(...a,{animationFrame:!0})}}),[n,t,r,e]),open:o})}function Tv({onDragEnter:e,onDragLeave:t,onDragOver:n,onDrop:r,disabled:o}){const{isDisabled:i}=zt(),s=i||o,{createAttachments:a}=ql(),[u,c]=m.useState(!1),f=ra(u);return[u,{onDragEnter:m.useCallback((l=>{e?.(l),!(f.current||s||l.isDefaultPrevented())&&l.dataTransfer.types.includes("Files")&&(l.preventDefault(),l.stopPropagation(),c(!0))}),[e,s]),onDragLeave:m.useCallback((l=>{t?.(l),!f.current||s||l.isDefaultPrevented()||(l.relatedTarget?l.relatedTarget===l.currentTarget||l.currentTarget.contains(l.relatedTarget):l.currentTarget!==l.target)||(l.preventDefault(),l.stopPropagation(),c(!1))}),[t,s]),onDragOver:m.useCallback((l=>{n?.(l),s||l.isDefaultPrevented()||(l.preventDefault(),l.stopPropagation())}),[n,s]),onDrop:m.useCallback((l=>{if(r?.(l),!f.current||s||l.isDefaultPrevented())return;l.preventDefault(),l.stopPropagation(),c(!1);const d=Av(l.dataTransfer);a(d)}),[r,s,a]),"data-drop":u?"":void 0,"data-disabled":s?"":void 0}]}class Sc extends Error{origin;name="AttachmentTooLargeError";constructor(t,n="client"){super(t),this.origin=n}}function lp(e){e.preventDefault()}function IA(e,t){const n=Ve(),r=Fo(e),o=Fo((()=>(function(a,u,c){const f=new Map,l=new Map,d=Ue();let h=null;function g(){h=null,d.notify()}function y(p){const w=new AbortController;l.set(p.id,w),a[Oe].httpClient.uploadAttachment({roomId:u,attachment:p,signal:w.signal}).then((()=>{f.set(p.id,{...p,status:"uploaded"}),g()})).catch((b=>{b instanceof Error&&b.name!=="AbortError"&&b.name!=="TimeoutError"&&(f.set(p.id,{...p,status:"error",error:b instanceof Uo&&b.status===413?new Sc("File is too large.","server"):b}),g())}))}return{addAttachments:function(p){if(p.length===0)return;const w=p.filter((C=>!f.has(C.id))),b=[];for(const C of w)if(C.type==="localAttachment"){if(C.file.size>c.maxFileSize){f.set(C.id,{...C,status:"error",error:new Sc("File is too large.","client")});continue}f.set(C.id,{...C,status:"uploading"}),b.push(C)}else f.set(C.id,C);w.length>0&&g();for(const C of b)y(C)},removeAttachment:function(p){l.get(p)?.abort(),f.delete(p),l.delete(p),g()},getSnapshot:function(){return h||(h=Array.from(f.values())),h},subscribe:d.subscribe,clear:function(){l.forEach((p=>p.abort())),l.clear(),f.clear(),g()}}})(n,t.roomId,t)));m.useEffect((()=>{o.addAttachments(r)}),[r,o]),m.useEffect((()=>()=>{o.clear()}),[o]);const i=m.useSyncExternalStore(o.subscribe,o.getSnapshot,o.getSnapshot),s=m.useMemo((()=>i.some((a=>a.type==="localAttachment"&&a.status==="uploading"))),[i]);return m.useEffect((()=>{if(s)return window.addEventListener("beforeunload",lp),()=>{window.removeEventListener("beforeunload",lp)}}),[s]),{attachments:i,isUploadingAttachments:s,addAttachments:o.addAttachments,removeAttachment:o.removeAttachment,clearAttachments:o.clear}}const TA={version:1,content:[{type:"paragraph",children:[{text:""}]}]};function kA({createAttachments:e,pasteFilesAsAttachments:t}){return(function(n){const{normalizeNode:r}=n;return n.normalizeNode=o=>{const[i,s]=o;if(le.isElement(i)&&i.type==="paragraph"){for(const[a,u]of ee.children(n,s))if(le.isElement(a)&&!n.isInline(a))return void z.unwrapNodes(n,{at:u})}r(o)},n})((function(n){const{isInline:r,isVoid:o,markableVoid:i,deleteBackward:s}=n;return n.isInline=a=>ai(a)||r(a),n.isVoid=a=>ai(a)||o(a),n.markableVoid=a=>ai(a)||i(a),n.deleteBackward=a=>{const{selection:u}=n;if(u&&U.isCollapsed(u)){const[c]=D.nodes(n,{at:a==="character"?D.before(n,u,{unit:"character"}):u,match:ai});s(a),c&&z.insertText(n,On)}else s(a)},n})(cA((function(n){const{isInline:r,normalizeNode:o,deleteBackward:i}=n;return n.isInline=s=>s.type==="auto-link"||r(s),n.normalizeNode=s=>{const[a,u]=s;if(!Ys(a)){if(le.isElement(a)&&a.type==="auto-link"&&(a.children.length===0||a.children.length===1&&a.children[0]?.text==="")&&z.removeNodes(n,{at:u}),kn(a)){const c=ee.parent(n,u);if(Ys(c))return;if(xo(c)){const f=F.parent(u);if(hA(n,[c,f]),!wc(a)){const l=sv(a);z.unsetNodes(n,l,{at:u})}}else pA(n,[a,u]),mA(n,[a,u])}o(s)}},n.deleteBackward=s=>{i(s);const{selection:a}=n;if(!a||!U.isCollapsed(a))return;const[u]=D.nodes(n,{at:a,match:xo,mode:"lowest"});u&&z.unwrapNodes(n,{match:xo})},n})((function(n){const{insertText:r}=n;return n.insertText=(o,i)=>{if(!n.selection||!U.isCollapsed(n.selection))return r(o,i);let s=!0;for(const a of mv)a.type==="mark"&&uA(n,o,a)&&(s=!1);s&&r(o,i)},n})((function(n){const{onChange:r}=n;return n.onChange=o=>{Ec(n,n.children)&&av(n),r(o)},n})((function(n,{createAttachments:r,pasteFilesAsAttachments:o}){const{insertData:i}=n;return n.insertData=s=>{if(s.types.includes("Files")&&o){const a=Av(s);if(a.length>0)return void r(a)}if(s.types.includes("text/html")&&!s.types.includes("application/x-slate-fragment")){const a=s.getData("text/html");try{const{body:u}=new DOMParser().parseFromString(a,"text/html");if(u.querySelector("br.Apple-interchange-newline")?.remove(),u.children.length===1&&u.children[0]?.nodeName==="B"){const f=u.children[0];for(;f.firstChild;)u.insertBefore(f.firstChild,f);u.removeChild(f)}const c=Oc(u);if(c!==null&&Array.isArray(c))return void z.insertFragment(n,c)}catch{}}i(s)},n})((n=>{var r=n,{apply:o}=r;return r.history={undos:[],redos:[]},r.redo=()=>{var{history:i}=r,{redos:s}=i;if(s.length>0){var a=s[s.length-1];a.selectionBefore&&z.setSelection(r,a.selectionBefore),wn.withoutSaving(r,(()=>{D.withoutNormalizing(r,(()=>{for(var u of a.operations)r.apply(u)}))})),i.redos.pop(),r.writeHistory("undos",a)}},r.undo=()=>{var{history:i}=r,{undos:s}=i;if(s.length>0){var a=s[s.length-1];wn.withoutSaving(r,(()=>{D.withoutNormalizing(r,(()=>{var u=a.operations.map(lr.inverse).reverse();for(var c of u)r.apply(c);a.selectionBefore&&z.setSelection(r,a.selectionBefore)}))})),r.writeHistory("redos",a),i.undos.pop()}},r.apply=i=>{var{operations:s,history:a}=r,{undos:u}=a,c=u[u.length-1],f=c&&c.operations[c.operations.length-1],l=wn.isSaving(r),d=wn.isMerging(r);if(l==null&&(l=VD(i)),l){if(d==null&&(d=c!=null&&(s.length!==0||HD(i,f))),wn.isSplittingOnce(r)&&(d=!1,wn.setSplittingOnce(r,void 0)),c&&d)c.operations.push(i);else{var h={operations:[i],selectionBefore:r.selection};r.writeHistory("undos",h)}for(;u.length>100;)u.shift();a.redos=[]}o(i)},r.writeHistory=(i,s)=>{r.history[i].push(s)},r})(Q2(T0())),{createAttachments:e,pasteFilesAsAttachments:t})))))))}function _A({Mention:e,attributes:t,children:n,element:r}){const o=X0(),{children:i,...s}=r;return v.jsxs("span",{...t,children:[r.id?v.jsx(e,{mention:s,isSelected:o}):null,n]})}function BA({Link:e,attributes:t,element:n,children:r}){const o=m.useMemo((()=>Gp(n.url)??""),[n.url]);return v.jsx("span",{...t,children:v.jsx(e,{href:o,children:r})})}function FA({id:e,itemId:t,mentions:n,selectedMentionId:r,setSelectedMentionId:o,mentionDraft:i,setMentionDraft:s,onItemSelect:a,position:u="top",dir:c,MentionSuggestions:f}){const l=_n(),{onEditorChange:d}=ya(),{isFocused:h}=zt(),[g,y]=Sv(),p=h&&i?.range!==void 0&&n!==void 0,{refs:{setReference:w,setFloating:b},strategy:C,isPositioned:E,placement:A,x,y:I,update:T,elements:B}=Iv({position:u,dir:c,alignment:"start",open:p});return zl(d,(()=>{s((function(S){const{selection:k}=S;if(!k||!U.isCollapsed(k))return;const R=pv(S,k,["@"],{include:!0,allowConsecutiveWhitespace:!1,ignoreTerminator:(H,W)=>{const G=Ri(S,W);return!(!G||vA.has(G.text)||gA.test(G.text)||Xs(G.text))}});if(!R)return;const M=D.string(S,R);return!M.startsWith(On)||M.length>1&&Xs(M[1])?void 0:{range:R,text:M.substring(1)}})(l))})),Sn((()=>{if(!i)return void w(null);const S=Vl(l,i.range);w(S??null)}),[w,l,i]),Sn((()=>{if(!p)return;const S=B.floating?.firstChild;if(!S)return;S.style.overflowY="visible",S.style.maxHeight="none",T();const k=requestAnimationFrame((()=>{S.style.overflowY="auto",S.style.maxHeight="var(--lb-composer-floating-available-height)"}));return()=>{cancelAnimationFrame(k)}}),[n?.length,p,B.floating,T]),v.jsx(iv,{children:p?v.jsx(dv.Provider,{value:{id:e,itemId:t,selectedValue:r,setSelectedValue:o,onItemSelect:a,placement:A,dir:c,ref:g},children:v.jsx(C0,{ref:b,style:{position:C,top:0,left:0,transform:E?`translate3d(${Math.round(x)}px, ${Math.round(I)}px, 0)`:"translate3d(0, -200%, 0)",minWidth:"max-content",zIndex:y},children:v.jsx(f,{mentions:n,selectedMentionId:r})})}):null})}function RA({id:e,position:t="top",dir:n,FloatingToolbar:r,hasFloatingToolbarRange:o,setHasFloatingToolbarRange:i}){const s=_n(),{onEditorChange:a}=ya(),{isFocused:u}=zt(),[c,f]=Sv(),[l,d]=m.useState(!1),h=u&&!l&&o,{refs:{setReference:g,setFloating:y},strategy:p,isPositioned:w,placement:b,x:C,y:E}=Iv({type:"range",position:t,dir:n,alignment:"center",open:h});return Sn((()=>{if(!u)return;const A=()=>d(!0),x=()=>d(!1);return document.addEventListener("pointerdown",A),document.addEventListener("pointerup",x),()=>{document.removeEventListener("pointerdown",A),document.removeEventListener("pointerup",x)}}),[u]),zl(a,(()=>{g(null),requestAnimationFrame((()=>{const A=window.getSelection();if(s.selection&&!U.isCollapsed(s.selection)&&A&&A.rangeCount){i(!0);const x=A.getRangeAt(0);g(x)}else i(!1),g(null)}))})),v.jsx(iv,{children:h?v.jsx(fv.Provider,{value:{id:e,placement:b,dir:n,ref:c},children:v.jsx(C0,{ref:y,style:{position:p,top:0,left:0,transform:w?`translate3d(${Math.round(C)}px, ${Math.round(E)}px, 0)`:"translate3d(0, -200%, 0)",minWidth:"max-content",zIndex:f},children:v.jsx(r,{})})}):null})}const jA=m.forwardRef((({children:e,onPointerDown:t,style:n,asChild:r,...o},i)=>{const[s]=Wl(),a=m.useRef(null),{id:u,ref:c,placement:f,dir:l}=(function(w="useComposerFloatingToolbarContext"){return ye(m.useContext(fv),`${w} can’t be used outside of Composer.Editor.`)})("ComposerFloatingToolbar"),d=zi(i,c,a),[h,g]=m.useMemo((()=>Ov(f)),[f]),y=r?vt:"div";ov(a);const p=m.useCallback((w=>{t?.(w),w.preventDefault(),w.stopPropagation()}),[t]);return v.jsx(y,{dir:l,role:"toolbar",id:u,"aria-label":"Floating toolbar",...o,onPointerDown:p,"data-state":s?"open":"closed","data-side":h,"data-align":g,style:{display:"flex",flexDirection:"row",maxWidth:"var(--lb-composer-floating-available-width)",overflowX:"auto",...n},ref:d,children:e})}));function MA({Mention:e,Link:t,...n}){const{attributes:r,children:o,element:i}=n;switch(i.type){case"mention":return v.jsx(_A,{Mention:e,...n});case"auto-link":case"custom-link":return v.jsx(BA,{Link:t,...n});case"paragraph":return v.jsx("p",{...r,style:{position:"relative"},children:o});default:return null}}function PA({attributes:e,children:t,leaf:n}){return n.bold&&(t=v.jsx("strong",{children:t})),n.italic&&(t=v.jsx("em",{children:t})),n.strikethrough&&(t=v.jsx("s",{children:t})),n.code&&(t=v.jsx("code",{children:t})),v.jsx("span",{...e,children:t})}function NA({attributes:e,children:t}){const{opacity:n,...r}=e.style;return v.jsx("span",{...e,style:r,"data-placeholder":"",children:t})}const Zl=m.forwardRef((({children:e,asChild:t,...n},r)=>{const o=t?vt:"span",i=X0();return v.jsx(o,{"data-selected":i||void 0,...n,ref:r,children:e})})),kv=m.forwardRef((({children:e,asChild:t,...n},r)=>{const o=t?vt:"a";return v.jsx(o,{target:"_blank",rel:"noopener noreferrer nofollow",...n,ref:r,children:e})})),_v=m.forwardRef((({children:e,style:t,asChild:n,...r},o)=>{const[i]=Wl(),s=m.useRef(null),{ref:a,placement:u,dir:c}=Gl("ComposerSuggestions"),f=zi(o,a,s),[l,d]=m.useMemo((()=>Ov(u)),[u]),h=n?vt:"div";return ov(s),v.jsx(h,{dir:c,...r,"data-state":i?"open":"closed","data-side":l,"data-align":d,style:{display:"flex",flexDirection:"column",maxHeight:"var(--lb-composer-floating-available-height)",overflowY:"auto",...t},ref:f,children:e})})),Bv=m.forwardRef((({children:e,asChild:t,...n},r)=>{const{id:o}=Gl("ComposerSuggestionsList"),i=t?vt:"ul";return v.jsx(i,{role:"listbox",id:o,"aria-label":"Suggestions list",...n,ref:r,children:e})})),Fv=m.forwardRef((({value:e,children:t,onPointerMove:n,onPointerDown:r,onClick:o,asChild:i,...s},a)=>{const u=m.useRef(null),c=zi(a,u),{selectedValue:f,setSelectedValue:l,itemId:d,onItemSelect:h}=Gl("ComposerSuggestionsListItem"),g=i?vt:"li",y=m.useMemo((()=>f===e),[f,e]),p=m.useMemo((()=>d(e)),[d,e]);m.useEffect((()=>{u?.current&&y&&u.current.scrollIntoView({block:"nearest"})}),[y]);const w=m.useCallback((E=>{n?.(E),E.isDefaultPrevented()||l(e)}),[n,l,e]),b=m.useCallback((E=>{r?.(E),E.preventDefault(),E.stopPropagation()}),[r]),C=m.useCallback((E=>{o?.(E);const A=E.isDefaultPrevented();E.preventDefault(),E.stopPropagation(),A||h(e)}),[o,h,e]);return v.jsx(g,{role:"option",id:p,"data-selected":y||void 0,"aria-selected":y||void 0,onPointerMove:w,onPointerDown:b,onClick:C,...s,ref:c,children:t})})),LA={Link:({href:e,children:t})=>v.jsx(kv,{href:e,children:t}),Mention:({mention:e})=>v.jsxs(Zl,{children:[On,e.id]}),MentionSuggestions:({mentions:e})=>e.length>0?v.jsx(_v,{children:v.jsx(Bv,{children:e.map((t=>v.jsx(Fv,{value:t.id,children:t.id},t.id)))})}):null},UA=m.forwardRef((({defaultValue:e,onKeyDown:t,onFocus:n,onBlur:r,disabled:o,autoFocus:i,components:s,dir:a,...u},c)=>{const f=Vc(),{editor:l,validate:d,setFocused:h,onEditorChange:g,roomId:y}=ya(),{submit:p,focus:w,blur:b,select:C,canSubmit:E,isDisabled:A,isFocused:x}=zt(),I=mr(),T=(function(){const J=Ve();return m.useCallback((oe=>{J[Oe].usersStore.enqueue(oe)}),[J])})(),B=A||o,S=Fo(e??TA),k=m.useMemo((()=>{return(J=S)&&J?.content?J.content.map((oe=>{if(oe.type!=="paragraph")return null;const ge=oe.children.map((ve=>{return pm(ve)?(Te=ve,{...Te,children:[{text:""}]}):mm(ve)?(We=ve).text?{type:"custom-link",url:We.url,children:[{text:We.text}]}:{type:"auto-link",url:We.url,children:[{text:We.url}]}:!("type"in(Le=ve))&&"text"in Le&&typeof Le.text=="string"?ve:null;var Te,We,Le})).filter(ji);return{...oe,children:ge}})).filter(ji):OA;var J}),[S]),{Link:R,Mention:M,MentionSuggestions:H,FloatingToolbar:W}=m.useMemo((()=>({...LA,...s})),[s]),[G,q]=m.useState(!1),$=Kc(),V=!f||$,[Q,ae]=m.useState(),ie=cb(y,Q?.text),[Se,Ie,ne,_]=(function(J,oe,ge){const{wrap:ve}=m.useMemo((()=>({...iA,...ge})),[ge]),Te=m.useMemo((()=>ve?oA:Qh),[ve]),[We,Le]=m.useState(J);return m.useEffect((()=>{Le((et=>Qh(et,0,Math.max(oe-1,0))))}),[oe]),[We,m.useCallback((()=>{Le((et=>Te(et-1,0,Math.max(oe,0))))}),[oe,Te]),m.useCallback((()=>{Le((et=>Te(et+1,0,Math.max(oe,0))))}),[oe,Te]),Le]})(0,ie?.length??0),X=m.useId(),K=`liveblocks-floating-toolbar-${X}`,Y=`liveblocks-suggestions-list-${X}`,de=m.useCallback((J=>J?`liveblocks-suggestions-list-item-${X}-${J}`:void 0),[X]),pe=m.useCallback((J=>v.jsx(MA,{Mention:M,Link:R,...J})),[R,M]),fe=m.useCallback((J=>{d(J),g.notify()}),[d,g]),we=m.useCallback((J=>{Q&&J&&(z.select(l,Q.range),(function(oe,ge){const ve={type:"mention",...ge,children:[{text:""}]};z.insertNodes(oe,ve),z.move(oe);const Te=oe.selection?Kl(oe,oe.selection):void 0;!Te||Te.void?z.insertText(oe," "):Mo(Te.text)&&z.move(oe)})(l,J),ae(void 0),_(0))}),[l,Q,_]),Ce=m.useCallback((J=>{if(t?.(J),!J.isDefaultPrevented())if(At(J,"ArrowLeft")&&np(l,"start"),At(J,"ArrowRight")&&np(l,"end"),Q&&ie?.length){if(At(J,"ArrowDown")&&(J.preventDefault(),ne()),At(J,"ArrowUp")&&(J.preventDefault(),Ie()),At(J,"Enter")||At(J,"Tab")){J.preventDefault();const oe=ie?.[Se];we(oe)}At(J,"Escape")&&(J.preventDefault(),ae(void 0),_(0))}else G&&At(J,"Escape")&&(J.preventDefault(),q(!1)),At(J,"Escape")&&b(),At(J,"Enter",{shift:!1})&&(J.preventDefault(),E&&p()),At(J,"Enter",{shift:!0})&&(J.preventDefault(),l.insertBreak()),At(J,"b",{mod:!0})&&(J.preventDefault(),si(l,"bold")),At(J,"i",{mod:!0})&&(J.preventDefault(),si(l,"italic")),At(J,"s",{mod:!0,shift:!0})&&(J.preventDefault(),si(l,"strikethrough")),At(J,"e",{mod:!0})&&(J.preventDefault(),si(l,"code"))}),[t,Q,ie,G,l,ne,Ie,Se,we,_,b,E,p]),se=m.useCallback((J=>{n?.(J),J.isDefaultPrevented()||(h(!0),I&&T(I))}),[n,h,I,T]),te=m.useCallback((J=>{r?.(J),J.isDefaultPrevented()||h(!1)}),[r,h]),me=ie?.[Se],Ae=me?.id,Pe=m.useCallback((J=>{const oe=ie?.findIndex((ge=>ge.id===J));oe!==void 0&&oe>=0&&_(oe)}),[_,ie]),Be=m.useMemo((()=>Q?{role:"combobox","aria-autocomplete":"list","aria-expanded":!0,"aria-controls":Y,"aria-activedescendant":de(Ae)}:G?{"aria-haspopup":!0,"aria-controls":K}:{}),[Q,Y,de,Ae,G,K]);m.useImperativeHandle(c,(()=>Z.toDOMNode(l,l)),[l]),Sn((()=>{if(!i)return;const J=setTimeout((()=>w()),0);return()=>clearTimeout(J)}),[i,l,w]),Sn((()=>{x&&l.selection===null&&C()}),[l,C,x]);const re=m.useCallback((J=>{const oe=ie?.find((ge=>ge.id===J));we(oe)}),[we,ie]);return v.jsxs(Y2,{editor:l,initialValue:k,onChange:fe,children:[v.jsx(W2,{dir:a,tabIndex:B?-1:0,enterKeyHint:Q?"enter":"send",autoCapitalize:"sentences","aria-label":"Composer editor","data-focused":x||void 0,"data-disabled":B||void 0,...Be,...u,readOnly:B,disabled:B,onKeyDown:Ce,onFocus:se,onBlur:te,renderElement:pe,renderLeaf:PA,renderPlaceholder:NA}),V&&v.jsx(FA,{dir:a,mentionDraft:Q,setMentionDraft:ae,selectedMentionId:Ae,setSelectedMentionId:Pe,mentions:ie,id:Y,itemId:de,onItemSelect:re,MentionSuggestions:H}),W&&v.jsx(RA,{dir:a,id:K,hasFloatingToolbarRange:G,setHasFloatingToolbarRange:q,FloatingToolbar:W})]})})),HA=m.forwardRef((({children:e,onSubmit:t,onComposerSubmit:n,defaultAttachments:r=[],pasteFilesAsAttachments:o,blurOnSubmit:i=!0,preventUnsavedChanges:s=!0,disabled:a,asChild:u,roomId:c,...f},l)=>{const d=u?vt:"form",[h,g]=m.useState(!0),[y,p]=m.useState(!1),[w,b]=m.useState(!1),C=Sm({allowOutsideRoom:!0}),E=c!==void 0?c:C?.id;if(E===void 0)throw new Error("Composer.Form must be a descendant of RoomProvider.");const A=1073741824,{attachments:x,isUploadingAttachments:I,addAttachments:T,removeAttachment:B,clearAttachments:S}=IA(r,{maxFileSize:A,roomId:E}),k=x.length,R=k>=10,M=m.useMemo((()=>y||a===!0),[y,a]),H=m.useMemo((()=>!h&&!I),[h,I]),[W,G]=m.useState(tp),q=m.useRef(null),$=zi(l,q),V=m.useRef(null),Q=(function(){const re=Ve()[Oe].createSyncSource,[J,oe]=m.useState();return m.useEffect((()=>{const ge=re();return oe(ge),()=>ge.destroy()}),[re]),J})(),ae=!!s&&(!h||I||x.length>0);m.useEffect((()=>{Q?.setSyncStatus(ae?"has-local-changes":"synchronized")}),[Q,ae]);const ie=m.useCallback((re=>{if(!re.length)return;const J=Math.max(0,10-k);re.splice(J);const oe=re.map((ge=>(function(ve){return{type:"localAttachment",status:"idle",id:Kp(),name:ve.name,size:ve.size,mimeType:ve.type,file:ve}})(ge)));T(oe)}),[T,10,k]),Se=m.useRef(ie);m.useEffect((()=>{Se.current=ie}),[ie]);const Ie=m.useCallback((re=>{Se.current(re)}),[]),ne=Fo((()=>kA({createAttachments:Ie,pasteFilesAsAttachments:o}))),_=Fo(Ue),X=m.useCallback((re=>{g(Ec(ne,re))}),[ne]),K=m.useCallback((()=>{H&&requestAnimationFrame((()=>{q.current&&(function(re,J){if(typeof re.requestSubmit=="function")return re.requestSubmit(J);J?J.click():((J=document.createElement("input")).type="submit",J.hidden=!0,re.appendChild(J),J.click(),re.removeChild(J))})(q.current)}))}),[H]),Y=m.useCallback((()=>{z.delete(ne,{at:{anchor:D.start(ne,[]),focus:D.end(ne,[])}})}),[ne]),de=m.useCallback((()=>{z.select(ne,D.end(ne,[]))}),[ne]),pe=m.useCallback(((re=!0)=>{try{if(!Z.isFocused(ne)){z.select(ne,re||!ne.selection?D.end(ne,[]):ne.selection);const J=Z.toDOMNode(ne,ne);if(ne.selection){const oe=window.getSelection(),ge=Vl(ne,ne.selection);ge&&(oe?.removeAllRanges(),oe?.addRange(ge))}J.focus({preventScroll:!0})}}catch{}}),[ne]),fe=m.useCallback((()=>{try{Z.blur(ne)}catch{}}),[ne]),we=m.useCallback((()=>{a||(pe(),(function(re){if(!re.selection)return;const J=Ri(re,re.selection,{filterVoids:!0}),oe=Kl(re,re.selection,{filterVoids:!0}),ge=J&&!Mo(J.text),ve=oe&&!Mo(oe.text);if(U.isCollapsed(re.selection)){const Te=(ge?" ":"")+On;re.insertText(Te,{at:U.start(re.selection)}),ve&&re.insertText(" ",{at:U.end(re.selection)}),z.collapse(re,{edge:"end"})}else{const Te=(ge?" ":"")+On+(ve?" ":"");re.insertText(Te),ve&&z.move(re,{distance:1,unit:"character",reverse:!0})}})(ne))}),[a,ne,pe]),Ce=m.useCallback((re=>{a||(pe(!1),S0(ne,re))}),[a,ne,pe]),se=m.useCallback((()=>{a||V.current&&V.current.click()}),[a]),te=m.useCallback((re=>{a||re.target.files&&(ie(Array.from(re.target.files)),re.target.value="")}),[ie,a]),me=m.useCallback((()=>{Y(),S(),p(!1),i&&fe()}),[fe,i,Y,S]),Ae=m.useCallback((re=>{if(a)return;if(Ec(ne,ne.children)||(t?.(re),!n||re.isDefaultPrevented()))return void re.preventDefault();const J=(function(ve){return{version:1,content:ve.map((Te=>{if(Te.type!=="paragraph")return null;const We=Te.children.map((Le=>{return ai(Le)?(function(ut){const{children:Nt,...mn}=ut;return mn})(Le):xo(Le)?{type:"link",url:Le.url}:Ys(Le)?{type:"link",url:(et=Le).url,text:et.children.map((ut=>ut.text)).join("")}:kn(Le)?Le:null;var et})).filter(ji);return{...Te,children:We}})).filter(ji)}})(ne.children),oe=x.filter((ve=>ve.type==="attachment"||ve.type==="localAttachment"&&ve.status==="uploaded")).map((ve=>({id:ve.id,type:"attachment",mimeType:ve.mimeType,size:ve.size,name:ve.name}))),ge=n({body:J,attachments:oe},re);re.preventDefault(),ge?(p(!0),ge.then(me)):me()}),[a,ne,x,n,t,me]),Pe=m.useCallback((re=>{re.stopPropagation()}),[]),Be=m.useCallback((re=>{si(ne,re)}),[ne]);return zl(_,(()=>{G(tp(ne))})),v.jsx(cv.Provider,{value:{editor:ne,validate:X,setFocused:b,onEditorChange:_,roomId:E},children:v.jsx(lv.Provider,{value:{createAttachments:ie,isUploadingAttachments:I,hasMaxAttachments:R,maxAttachments:10,maxAttachmentSize:A},children:v.jsx(uv.Provider,{value:{isDisabled:M,isFocused:w,isEmpty:h,canSubmit:H,submit:K,clear:Y,select:de,focus:pe,blur:fe,createMention:we,insertText:Ce,attachments:x,attachFiles:se,removeAttachment:B,toggleMark:Be,marks:W},children:v.jsxs(d,{...f,onSubmit:Ae,ref:$,children:[v.jsx("input",{type:"file",multiple:!0,ref:V,onChange:te,onClick:Pe,tabIndex:-1,style:{display:"none"}}),v.jsx(fb,{children:e})]})})})})})),Rv=m.forwardRef((({children:e,disabled:t,asChild:n,...r},o)=>{const i=n?vt:"button",{canSubmit:s,isDisabled:a}=zt(),u=a||t||!s;return v.jsx(i,{type:"submit",...r,ref:o,disabled:u,children:e})})),VA=m.forwardRef((({children:e,onClick:t,disabled:n,asChild:r,...o},i)=>{const s=r?vt:"button",{hasMaxAttachments:a}=ql(),{isDisabled:u,attachFiles:c}=zt(),f=u||a||n,l=m.useCallback((d=>{t?.(d),d.isDefaultPrevented()||c()}),[c,t]);return v.jsx(s,{type:"button",...o,onClick:l,ref:i,disabled:f,children:e})}));m.forwardRef((({onDragEnter:e,onDragLeave:t,onDragOver:n,onDrop:r,disabled:o,asChild:i,...s},a)=>{const u=i?vt:"div",{isDisabled:c}=zt(),f=c||o,[,l]=Tv({onDragEnter:e,onDragLeave:t,onDragOver:n,onDrop:r,disabled:f});return v.jsx(u,{...l,"data-disabled":f?"":void 0,...s,ref:a})}));const $A=m.forwardRef((({children:e,mark:t,onValueChange:n,onClick:r,onPointerDown:o,asChild:i,...s},a)=>{const u=i?vt:"button",{marks:c,toggleMark:f}=zt(),l=m.useCallback((h=>{o?.(h),h.preventDefault(),h.stopPropagation()}),[o]),d=m.useCallback((h=>{r?.(h),h.isDefaultPrevented()||(h.preventDefault(),h.stopPropagation(),f(t),n?.(t))}),[t,r,n,f]);return v.jsx(El,{asChild:!0,pressed:c[t],onClick:d,onPointerDown:l,...s,children:v.jsx(u,{...s,ref:a,children:e})})})),dp={seconds:60,minutes:60,hours:24,days:7,weeks:4.34524,months:12};function WA(e,t){return nc(c0(t,{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric"}).format(e))}const zA=["br","fr","nb","nn","no","ro","sv"];function KA(e,t){return Math.abs(e.getTime()-Date.now())<=2592e5?(function(n,r){let o;r?o=r:o=Af().resolvedOptions().locale;const i=zA.some((u=>o===u||o.startsWith(`${u}-`))),s=Af(o,{style:i?"short":"narrow",numeric:"auto"});let a=(n.getTime()-Date.now())/1e3;if(a>-60&&a<dp.seconds)return s.format(0,"seconds");for(const[u,c]of Object.entries(dp)){if(Math.abs(a)<c)return s.format(Math.round(a),u);a/=c}return nc(s.format(Math.round(a),"years"))})(e,t):(function(n,r){return nc(c0(r,{month:"short",day:"numeric"}).format(n))})(e,t)}const qA=m.forwardRef((({date:e,locale:t,children:n=KA,title:r=WA,dateTime:o,interval:i=3e4,asChild:s,...a},u)=>{const c=s?vt:"time",[f,l]=d0(),d=m.useMemo((()=>new Date(e)),[e]),h=m.useMemo((()=>d.toISOString()),[d]),g=m.useMemo((()=>typeof r=="function"?r(d,t):r),[r,d,t,l]),y=m.useMemo((()=>typeof n=="function"?n(d,t):n),[n,d,t,l]);return l0(f,i),v.jsx(c,{...a,ref:u,dateTime:o??h,title:g,children:y})}));function jv(e){const t=Fo(e),n=t.userIds;if(t.kind!=="group")return!1;if(Array.isArray(n)){const r=mr();return m.useMemo((()=>n.some((o=>o===r))),[n,r])}{const r=mr(),{group:o}=(function(i){const s=Ve()[Oe].httpClient.groupsStore,a=m.useCallback((()=>s.getItemState(i)),[s,i]);return m.useEffect((()=>{s.enqueue(i)}),[s,i]),Pi(s.subscribe,a,a,ub,lt)})(t.id);return m.useMemo((()=>!!o?.members.some((i=>i.id===r))),[o,r])}}const hu=["B","KB","MB","GB"];function fp(e,t){if(e===0)return`0 ${hu[1]}`;let n;n=e===0?1:Math.max(1,Math.min(Math.floor(Math.log(Math.abs(e))/Math.log(1e3)),hu.length-1));let r=e/1e3**n,o=1;n===1&&(r>=10&&(o=0),r<.1&&r>0&&(o=2),r<.01&&(r=.01));const i=hu[n];return`${Lr(t,{minimumFractionDigits:0,maximumFractionDigits:o}).format(r)} ${i}`}const Mv=62914560,GA=/^(.+?)(\.[^.]+)?$/,JA=m.memo((({mimeType:e})=>{const t=m.useMemo((()=>(function(n){return n==="application/zip"||n==="application/gzip"||n==="application/vnd.rar"||n==="application/x-rar-compressed"||n==="application/x-7z-compressed"||n==="application/x-zip-compressed"||n==="application/x-tar"||n==="application/x-bzip"||n==="application/x-bzip2"?v.jsx("path",{d:"M13 15h2v1h-1.5a.5.5 0 0 0 0 1H15v1h-1.5a.5.5 0 0 0 0 1H15v1h-1.5a.5.5 0 0 0 0 1h1a.5.5 0 0 0 .5-.5V20h1.5a.5.5 0 0 0 0-1H15v-1h1.5a.5.5 0 0 0 0-1H15v-1h1.5a.5.5 0 0 0 .5-.5V15a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2Z"}):n.startsWith("text/")||n.startsWith("font/")||n.startsWith("application/")?v.jsx("path",{d:"M10 16a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5Zm0 2a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5Zm0 2a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5Zm0 2a.5.5 0 0 1 .5-.5h8a.5.5 0 0 1 0 1h-8a.5.5 0 0 1-.5-.5Z"}):n.startsWith("image/")?v.jsx("path",{d:"M12 16h6a1 1 0 0 1 1 1v3l-1.293-1.293a1 1 0 0 0-1.414 0L14.09 20.91l-.464-.386a1 1 0 0 0-1.265-.013l-1.231.985A.995.995 0 0 1 11 21v-4a1 1 0 0 1 1-1Zm-2 1a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-6a2 2 0 0 1-2-2v-4Zm3 2a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"}):n.startsWith("video/")?v.jsx("path",{d:"M12 15.71a1 1 0 0 1 1.49-.872l4.96 2.79a1 1 0 0 1 0 1.744l-4.96 2.79A1 1 0 0 1 12 21.29v-5.58Z"}):n.startsWith("audio/")?v.jsx("path",{d:"M15 15a.5.5 0 0 0-.5.5v7a.5.5 0 0 0 1 0v-7a.5.5 0 0 0-.5-.5Zm-2.5 2.5a.5.5 0 0 1 1 0v3a.5.5 0 0 1-1 0v-3Zm-2 1a.5.5 0 0 1 1 0v1a.5.5 0 0 1-1 0v-1Zm6-1a.5.5 0 0 1 1 0v3a.5.5 0 0 1-1 0v-3ZM19 16a.5.5 0 0 0-.5.5v5a.5.5 0 0 0 1 0v-5a.5.5 0 0 0-.5-.5Z"}):null})(e)),[e]);return v.jsxs("svg",{className:"lb-attachment-icon",width:30,height:30,viewBox:"0 0 30 30",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd",xmlns:"http://www.w3.org/2000/svg",children:[v.jsx("path",{d:"M6 5a2 2 0 0 1 2-2h5.843a4 4 0 0 1 2.829 1.172l6.156 6.156A4 4 0 0 1 24 13.157V25a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2V5Z",className:"lb-attachment-icon-shadow"}),v.jsx("path",{d:"M6 5a2 2 0 0 1 2-2h5.843a4 4 0 0 1 2.829 1.172l6.156 6.156A4 4 0 0 1 24 13.157V25a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2V5Z",className:"lb-attachment-icon-background"}),v.jsx("path",{d:"M14.382 3.037a4 4 0 0 1 2.29 1.135l6.156 6.157a4 4 0 0 1 1.136 2.289A2 2 0 0 0 22 11h-4a2 2 0 0 1-2-2V5a2 2 0 0 0-1.618-1.963Z",className:"lb-attachment-icon-fold"}),t&&v.jsx("g",{className:"lb-attachment-icon-glyph",children:t})]})}));function ZA({attachment:e,markPreviewAsUnsupported:t,roomId:n}){const{url:r}=ia(e.id,n),[o,i]=m.useState(!1),s=m.useCallback((()=>{i(!0)}),[]);return v.jsxs(v.Fragment,{children:[o?null:v.jsx(Wi,{}),r?v.jsx("div",{className:"lb-attachment-preview-media","data-hidden":o?void 0:"",children:v.jsx("img",{src:r,loading:"lazy",onLoad:s,onError:t})}):null]})}function XA({attachment:e,markPreviewAsUnsupported:t,roomId:n}){const{url:r}=ia(e.id,n),[o,i]=m.useState(!1),s=m.useCallback((()=>{i(!0)}),[]);return v.jsxs(v.Fragment,{children:[o?null:v.jsx(Wi,{}),r?v.jsx("div",{className:"lb-attachment-preview-media","data-hidden":o?void 0:"",children:v.jsx("video",{src:r,onLoadedData:s,onError:t})}):null]})}function Pv({attachment:e,allowMediaPreview:t=!0,roomId:n}){const[r,o]=m.useState(!1),i=e.type==="attachment"||e.status==="uploaded";function s(){o(!0)}if(!r&&t&&i&&e.size<=Mv){if(e.mimeType.startsWith("image/"))return v.jsx(ZA,{attachment:e,markPreviewAsUnsupported:s,roomId:n});if(e.mimeType.startsWith("video/"))return v.jsx(XA,{attachment:e,markPreviewAsUnsupported:s,roomId:n})}return v.jsx(JA,{mimeType:e.mimeType})}function Nv({attachment:e}){const{base:t,extension:n}=m.useMemo((()=>(function(r){const o=r.match(GA);return{base:o?.[1]??r,extension:o?.[2]}})(e.name)),[e.name]);return v.jsxs("span",{className:"lb-attachment-name",title:e.name,children:[v.jsx("span",{className:"lb-attachment-name-base",children:t}),n&&v.jsx("span",{className:"lb-attachment-name-extension",children:n})]})}function Lv(e){return m.useCallback((t=>{if(e?.(t),!t.isDefaultPrevented()&&(t.key==="Enter"||t.key===" ")){t.preventDefault();const n=new MouseEvent("click",{bubbles:!0,cancelable:!0,view:window});t.target.dispatchEvent(n)}}),[e])}function Uv(e,t){const n=Mt(t),r=hv(),o=!!r,i=r?.maxAttachmentSize,s=e.type==="localAttachment"?e.status:void 0,a=s==="uploading",u=s==="error";let c;return c=e.type==="localAttachment"&&e.status==="error"?e.error instanceof Sc?e.error.origin==="server"?n.ATTACHMENT_TOO_LARGE():n.ATTACHMENT_TOO_LARGE(i?fp(i,n.locale):void 0):n.ATTACHMENT_ERROR(e.error):fp(e.size,n.locale),{isUploading:a,isError:u,description:c,deleteLabel:o?n.COMPOSER_REMOVE_ATTACHMENT:n.COMMENT_DELETE_ATTACHMENT}}function YA({attachment:e,overrides:t,onClick:n,onDeleteClick:r,preventFocusOnDelete:o,allowMediaPreview:i=!0,roomId:s,className:a,onKeyDown:u,...c}){const{isUploading:f,isError:l,description:d,deleteLabel:h}=Uv(e,t),g=m.useCallback((p=>{o&&p.preventDefault()}),[o]),y=Lv(u);return v.jsxs("div",{className:Ne("lb-attachment lb-media-attachment",a),"data-error":l?"":void 0,...c,role:n?"button":void 0,onClick:n,tabIndex:n?0:-1,onKeyDown:n?y:void 0,children:[v.jsx("div",{className:"lb-attachment-preview",children:f?v.jsx(Wi,{}):l?v.jsx(y0,{}):v.jsx(Pv,{attachment:e,allowMediaPreview:i,roomId:s})}),v.jsxs("div",{className:"lb-attachment-details",children:[v.jsx(Nv,{attachment:e}),v.jsx("span",{className:"lb-attachment-description",title:d,children:d})]}),r&&v.jsx(jt,{content:h,children:v.jsx("button",{type:"button",className:"lb-attachment-delete",onClick:r,onPointerDown:g,"aria-label":h,children:v.jsx(kl,{})})})]})}function Hv({attachment:e,overrides:t,onClick:n,onDeleteClick:r,preventFocusOnDelete:o,allowMediaPreview:i=!0,roomId:s,className:a,onKeyDown:u,...c}){const{isUploading:f,isError:l,description:d,deleteLabel:h}=Uv(e,t),g=m.useCallback((p=>{o&&p.preventDefault()}),[o]),y=Lv(u);return v.jsxs("div",{className:Ne("lb-attachment lb-file-attachment",a),"data-error":l?"":void 0,...c,role:n?"button":void 0,onClick:n,tabIndex:n?0:-1,onKeyDown:n?y:void 0,children:[v.jsx("div",{className:"lb-attachment-preview",children:f?v.jsx(Wi,{}):l?v.jsx(y0,{}):v.jsx(Pv,{attachment:e,allowMediaPreview:i,roomId:s})}),v.jsxs("div",{className:"lb-attachment-details",children:[v.jsx(Nv,{attachment:e}),v.jsx("span",{className:"lb-attachment-description",title:d,children:d})]}),r&&v.jsx(jt,{content:h,children:v.jsx("button",{type:"button",className:"lb-attachment-delete",onClick:r,onPointerDown:g,"aria-label":h,children:v.jsx(kl,{})})})]})}function QA({className:e,...t}){return v.jsx("a",{href:"https://liveblocks.io",target:"_blank",rel:"noopener noreferrer",className:Ne("lb-composer-attribution",e),...t,children:v.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 384 72","aria-label":"Made with Liveblocks",children:v.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M86 10h-8v50h8V10Zm16 14h-8v36h8V24Zm0-15h-8v9h8V9Zm13 15h-9l12 36h10l13-36h-9l-9 28-8-28Zm44-1c-11 0-18 8-18 19s7 19 18 19c8 0 15-4 17-13h-8c-1 4-5 6-9 6-6 0-9-3-9-10h27c0-10-6-21-18-21Zm0 7c5 0 9 3 9 8h-18c0-5 4-8 9-8Zm42-7c-4 0-8 2-11 6V10h-8v50h8v-5c3 4 7 6 11 6 11 0 16-9 16-19s-5-19-16-19Zm-2 32c-7 0-9-7-9-13s2-13 9-13 9 7 9 13-2 13-9 13Zm32-45h-8v50h8V10Zm24 51c11 0 18-8 18-19s-8-19-18-19c-11 0-19 8-19 19s7 19 19 19Zm0-6c-8 0-10-7-10-13s2-13 10-13c7 0 9 7 9 13s-2 13-9 13Zm39 6c8 0 15-4 17-12l-8-1c-2 4-4 6-9 6-7 0-9-6-9-12s2-12 9-12c5 0 8 3 8 7l9-1c-2-8-9-13-17-13-11 0-18 9-18 19 0 11 7 19 18 19Zm30-14 4-4 10 17h10l-15-23 15-13h-11l-13 13V10h-9v50h9V47Zm39 14c8 0 16-3 16-12 0-8-8-10-15-11-2-1-7-1-7-5 0-3 3-4 6-4 4 0 7 3 7 7l8-1c-1-9-8-12-15-12s-15 3-15 11 9 10 15 11c3 1 8 2 8 5 0 4-4 5-7 5-5 0-8-3-9-7l-8 1c1 8 9 12 16 12ZM41 27H0l12 12v17l29-29ZM20 60h40L48 48V32L20 60Z",fill:"currentColor"})})})}var ex=Object.defineProperty,Rn={};((e,t)=>{for(var n in t)ex(e,n,{get:t[n],enumerable:!0})})(Rn,{ActiveEmoji:()=>c1,Empty:()=>u1,List:()=>i1,Loading:()=>a1,Root:()=>Yv,Search:()=>Qv,SkinTone:()=>l1,SkinToneSelector:()=>s1,Viewport:()=>e1});var Vv="'Apple Color Emoji', 'Noto Color Emoji', 'Twemoji Mozilla', 'Android Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', EmojiSymbols, sans-serif",Xl=["none","light","medium-light","medium","medium-dark","dark"];function pu(e){return e.charAt(0).toUpperCase()+e.slice(1)}var Ct=null;function hp(e){try{Ct??=document.createElement("canvas").getContext("2d",{willReadFrequently:!0})}catch{}if(!Ct||(queueMicrotask((()=>{Ct&&(Ct=null)})),Ct.canvas.width=2,Ct.canvas.height=2,Ct.font=`2px ${Vv}`,Ct.textBaseline="middle",Ct.measureText(e).width>=4))return!1;Ct.fillStyle="#00f",Ct.fillText(e,0,0);let t=Ct.getImageData(0,0,2,2).data;Ct.clearRect(0,0,2,2),Ct.fillStyle="#f00",Ct.fillText(e,0,0);let n=Ct.getImageData(0,0,2,2).data;for(let r=0;r<16;r+=4)if(t[r]!==n[r]||t[r+1]!==n[r+1]||t[r+2]!==n[r+2])return!1;return!0}function pp(e,t,n){try{let r=e.getItem(t);if(!r)throw new Error(`No value found for "${t}".`);return n(JSON.parse(r))}catch{return null}}function $v(e,t,n){e.setItem(t,JSON.stringify(n))}function mp(e){return t=>t===void 0?void 0:e(t)}function gp(e){return t=>t===null?null:e(t)}function yt(e){if(typeof e!="string")throw new Error;return e}function Fs(e){if(typeof e!="number")throw new Error;return e}function Wv(e){if(typeof e!="boolean")throw new Error;return e}function rr(e){return t=>{if(typeof t!="object"||t===null)throw new Error;let n={};for(let r in e){let o=t[r];o===void 0&&e[r](void 0),n[r]=e[r](o)}return n}}function mu(e){return t=>{if(!Array.isArray(t))throw new Error;return t.length>0&&e(t[0]),t}}var zv=(e,t)=>`${e}/${t}/data.json`,Kv=(e,t)=>`${e}/${t}/messages.json`,tx=["bn","da","de","en-gb","en","es-mx","es","et","fi","fr","hi","hu","it","ja","ko","lt","ms","nb","nl","pl","pt","ru","sv","th","uk","vi","zh-hant","zh"],qv=e=>`frimousse/data/${e}`,vp="frimousse/metadata";async function yp(e,t){try{return(await fetch(e,{method:"HEAD",signal:t})).headers.get("etag")}catch{return null}}function nx(e){return e.skins?e.skins.filter((t=>typeof t.tone=="number")).reduce(((t,n)=>(t[Xl[n.tone]]=n.emoji,t)),{}):void 0}async function bp(e,t,n){let{emojis:r,emojisEtag:o,messages:i,messagesEtag:s}=await(async function(g,y,p){let[{emojis:w,emojisEtag:b},{messages:C,messagesEtag:E}]=await Promise.all([fetch(zv(g,y),{signal:p}).then((async A=>({emojis:await A.json(),emojisEtag:A.headers.get("etag")}))),fetch(Kv(g,y),{signal:p}).then((async A=>({messages:await A.json(),messagesEtag:A.headers.get("etag")})))]);return{emojis:w,messages:C,emojisEtag:b,messagesEtag:E}})(e,t,n),a=i.subgroups.find((g=>g.key==="country-flag"||g.key==="subdivision-flag")),u=i.groups.filter((g=>g.key!=="component")),c=r.filter((g=>"group"in g)),f=u.map((g=>({index:g.order,label:pu(g.message)}))),l=i.skinTones.reduce(((g,y)=>(g[y.key]=pu(y.message),g)),{}),d=c.map((g=>({emoji:g.emoji,category:g.group,version:g.version,label:pu(g.label),tags:g.tags??[],countryFlag:a&&g.subgroup===a.order||void 0,skins:nx(g)}))),h={locale:t,emojis:d,categories:f,skinTones:l};return $v(localStorage,qv(t),{data:h,metadata:{emojisEtag:o,messagesEtag:s}}),h}var rx=rr({emojiVersion:Fs,countryFlags:Wv}),ox=rr({data:rr({locale:yt,emojis:mu(rr({emoji:yt,category:Fs,label:yt,version:Fs,tags:mu(yt),countryFlag:mp(Wv),skins:mp(rr({light:yt,"medium-light":yt,medium:yt,"medium-dark":yt,dark:yt}))})),categories:mu(rr({index:Fs,label:yt})),skinTones:rr({light:yt,"medium-light":yt,medium:yt,"medium-dark":yt,dark:yt})}),metadata:rr({emojisEtag:gp(yt),messagesEtag:gp(yt)})});async function ix({locale:e,emojiVersion:t,emojibaseUrl:n,signal:r}){let o,i=typeof n=="string"?n:`https://cdn.jsdelivr.net/npm/emojibase-data@${typeof t=="number"?Math.floor(t):"latest"}`,s=pp(sessionStorage,vp,rx),a=pp(localStorage,qv(e),ox);if(a)if(s)o=a.data;else try{let{emojisEtag:u,messagesEtag:c}=await(async function(f,l,d){let[h,g]=await Promise.all([yp(zv(f,l),d),yp(Kv(f,l),d)]);return{emojisEtag:h,messagesEtag:g}})(i,e,r);o=u&&c&&u===a.metadata.emojisEtag&&c===a.metadata.messagesEtag?a.data:await bp(i,e,r)}catch{o=a.data}else o=await bp(i,e,r);return s??=(function(u,c){let f=new Map;for(let g of u)f.has(g.version)||f.set(g.version,g.emoji);let l=[...f.keys()].sort(((g,y)=>y-g)),d=l[0]??0,h=hp("🇪🇺");if(typeof c=="number")return{emojiVersion:c,countryFlags:h};for(let g of l)if(hp(f.get(g)))return{emojiVersion:g,countryFlags:h};return{emojiVersion:d,countryFlags:h}})(o.emojis,t),$v(sessionStorage,vp,s),{locale:e,emojis:o.emojis.filter((u=>{let c=u.version<=s.emojiVersion;return u.countryFlag?c&&s.countryFlags:c})),categories:o.categories,skinTones:o.skinTones}}function Cp(e){return tx.includes(e)?e:(console.warn(`Locale "${e}" is not supported, using "en" instead.`),"en")}function wp(e){return Xl.includes(e)?e:(console.warn(`Skin tone "${e}" is not valid, using "none" instead.`),"none")}function sx(e,t){let n=[];if(t<=0)return n;for(let r=0,o=e.length;r<o;r+=t)n.push(e.slice(r,r+t));return n}function ax(e,t,n,r){let o=(function(l,d){if(!d)return l;let h=d.toLowerCase().trim(),g=new WeakMap;return l.filter((y=>{let p=0;y.label.toLowerCase().includes(h)&&(p+=10);for(let w of y.tags)w.toLowerCase().includes(h)&&(p+=1);return p>0&&(g.set(y,p),!0)})).sort(((y,p)=>(g.get(p)??0)-(g.get(y)??0)))})(e.emojis,r),i=[],s=[],a=[],u={},c=0,f=0;for(let l of o)u[l.category]||(u[l.category]=[]),u[l.category].push({emoji:n&&n!=="none"&&l.skins?l.skins[n]:l.emoji,label:l.label});for(let l of e.categories){let d=u[l.index];if(!d||d.length===0)continue;let h=sx(Array.from(d),t).map((g=>({categoryIndex:c,emojis:g})));i.push(...h),s.push({label:l.label,rowsCount:h.length,startRowIndex:f}),a.push(f),c++,f+=h.length}return{count:o.length,categories:s,categoriesStartRowIndices:a,rows:i,skinTones:e.skinTones}}function $t(e,t,n=Object.is){let[r,o]=m.useState((()=>t(e.get())));return m.useEffect((()=>e.subscribe((()=>{let i=t(e.get());o((s=>n(s,i)?s:i))}))),[e,t,n]),m.useDebugValue(r),r}function Un(e,t,n){let r=m.useCallback((o=>o[t]),[t]);return $t(e,r,n)}function ux(e,t,n,r){let o=0;return(function(i){let s={},a=null,u=null,c=new Set,f=()=>{if(a){s=a,a=null;for(let h of c)h(s)}u=null},l=()=>a??s,d=h=>{a??=s,Object.assign(a,typeof h=="function"?h(l()):h),u||(u=requestAnimationFrame(f))};return s=i(d,l),{get:l,set:d,subscribe:h=>(c.add(h),()=>c.delete(h))}})(((i,s)=>({locale:t,columns:n,skinTone:r,onEmojiSelect:e,data:null,search:"",interaction:"none",activeColumnIndex:0,activeRowIndex:0,rowHeight:null,categoryHeaderHeight:null,viewportWidth:null,viewportHeight:null,viewportCurrentCategoryIndex:null,viewportStartCategoryIndex:0,viewportStartRowIndex:0,viewportEndRowIndex:0,rootRef:null,searchRef:null,viewportRef:null,listRef:null,updateViewportState:a=>{let u=s(),c=a?.data??u.data,f=a?.categoryHeaderHeight??u.categoryHeaderHeight,l=a?.rowHeight??u.rowHeight,d=a?.viewportHeight??u.viewportHeight;if(!(c&&c.rows.length!==0&&f&&l&&d))return i({...a,viewportStartCategoryIndex:0,viewportStartRowIndex:0,viewportEndRowIndex:0});let h=0,g=0;for(let I of c.categories){if(!(g++*f+I.startRowIndex*l<o))break;h+=f}let y=c.categories.length*f+c.rows.length*l,p=Math.floor(2*l/2),w=Math.ceil(2*l/2),b=Math.min(o-h-p,y-d),C=b+d+w,E=Math.max(0,Math.floor(b/l)),A=Math.min(c.rows.length-1,Math.ceil(C/l)),x=c.rows[E]?.categoryIndex;return i(x===void 0&&a?a:{...a,viewportStartCategoryIndex:x,viewportStartRowIndex:E,viewportEndRowIndex:A})},onDataChange:a=>{s().updateViewportState({data:a,activeColumnIndex:0,activeRowIndex:0})},onSearchChange:a=>{i({search:a,interaction:a?"keyboard":"none"})},onActiveEmojiChange:(a,u,c)=>{if(i({interaction:a,activeColumnIndex:u,activeRowIndex:c}),a!=="keyboard")return;let{listRef:f,viewportRef:l,rowHeight:d,viewportHeight:h,categoryHeaderHeight:g}=s(),y=f?.current,p=l?.current;if(!(y&&p&&d&&g&&h))return;let w=c;w===0&&p.scrollTo({top:0,behavior:"instant"});let b=y.querySelector(`[aria-rowindex="${w}"]`);if(!(b instanceof HTMLElement))return;let C=b.offsetTop,E=getComputedStyle(b),A=Number.parseFloat(E.scrollMarginTop),x=Number.parseFloat(E.scrollMarginBottom),I=o+A;C<o+h/2&&(I+=g),(C<I||C+d>I+h-x)&&p.scrollTo({top:Math.max(C<I+g?C-Math.max(g,A):C-h+d+x,0),behavior:"instant"})},onActiveEmojiReset:()=>{i({interaction:"none",activeColumnIndex:0,activeRowIndex:0})},onRowHeightChange:a=>{s().updateViewportState({rowHeight:a})},onCategoryHeaderHeightChange:a=>{s().updateViewportState({categoryHeaderHeight:a})},onViewportSizeChange:(a,u)=>{s().updateViewportState({viewportWidth:a,viewportHeight:u})},onViewportScroll:a=>{o=a,s().updateViewportState()}})))}var{useStore:Pt,Provider:cx}=(function(e){let t=m.createContext(null);return{useStore:()=>{let n=m.useContext(t);if(!n)throw new Error(e);return n},Provider:({store:n,children:r})=>v.jsx(t.Provider,{value:n,children:r})}})("EmojiPicker.Root is missing.");function lx(e){return e.search}function Yl(e){return e.interaction==="none"?void 0:e.data?.rows[e.activeRowIndex]?.emojis[e.activeColumnIndex]}function dx(e){return e.data===void 0||typeof e.data?.count=="number"&&e.data.count===0}function fx(e){return e.data===null||e.viewportHeight===null||e.rowHeight===null||e.categoryHeaderHeight===null}function Gv(e){return e.data?.rows.length}function hx(e){return e.data?.categories.length}function px(e){return e.data?.categoriesStartRowIndices}function mx(e){return e.data?.skinTones}function Jv(e,t){return e?.emoji===t?.emoji}function gx(e,t){return e?.categoryIndex===t?.categoryIndex&&e?.emojis.length===t?.emojis.length&&!!e?.emojis.every(((n,r)=>Jv(n,t?.emojis[r])))}var ni="‍",Ep=new RegExp("\\p{Emoji_Modifier_Base}","u"),vx=/\uFE0F$/,yx=/\u{1F3FB}|\u{1F3FC}|\u{1F3FD}|\u{1F3FE}|\u{1F3FF}/gu,bx={light:"🏻","medium-light":"🏼",medium:"🏽","medium-dark":"🏾",dark:"🏿"};function Cx(e,t){if(!e.split(ni).some((r=>Ep.test(r))))return e;let n=e.split(ni).map((r=>r.replace(yx,""))).join(ni);return t==="none"?n:n.split(ni).map(((r,o,i)=>{let s=i.length>1;return!Ep.test(r)||s&&r==="🤝"?r:r.replace(vx,"")+bx[t]})).join(ni)}function Zv(){let e=$t(Pt(),Yl,Jv);return m.useDeferredValue(e)}function Xv(e="✋"){let t=Pt(),n=Un(t,"skinTone"),r=m.useMemo((()=>(function(o){return Xl.map((i=>({skinTone:i,emoji:Cx(o,i)})))})(e)),[e]);return[n,m.useCallback((o=>{t.set({skinTone:o})}),[]),r]}function Ql(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||typeof t!="object"||e===null||t===null||Array.isArray(e)!==Array.isArray(t))return!1;let n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every((o=>o in t&&e[o]===t[o]))}function wx(...e){}var En=typeof window<"u"?m.useLayoutEffect:m.useEffect;function Ex({emojiVersion:e,emojibaseUrl:t}){let[n,r]=m.useState(void 0),o=Pt(),i=Un(o,"locale"),s=Un(o,"columns"),a=Un(o,"skinTone"),u=Un(o,"search");return m.useEffect((()=>{let c=new AbortController,f=c.signal;return ix({locale:i,emojiVersion:e,emojibaseUrl:t,signal:f}).then((l=>{r(l)})).catch((l=>{f.aborted||console.error(l)})),()=>{c.abort()}}),[e,t,i]),m.useEffect((()=>{if(n)return(function(c,f){let l=null;if(typeof window.requestIdleCallback=="function")l=window.requestIdleCallback(c,f);else{let d=Date.now();l=window.setTimeout((()=>{c({didTimeout:!1,timeRemaining:()=>Math.max(0,f?.timeout-(Date.now()-d))})}),10)}return()=>{typeof window.cancelIdleCallback=="function"?window.cancelIdleCallback(l):window.clearTimeout(l)}})((()=>{o.get().onDataChange(ax(n,s,a,u))}),{timeout:100})}),[n,s,a,u]),null}var Yv=m.forwardRef((({locale:e="en",columns:t=9,skinTone:n="none",onEmojiSelect:r=wx,emojiVersion:o,emojibaseUrl:i,onFocusCapture:s,onBlurCapture:a,children:u,style:c,...f},l)=>{let d=(function(E){let A=m.useRef(E);return En((()=>{A.current=E})),m.useCallback(((...x)=>A.current(...x)),[])})(r),h=(function(E){let[A]=m.useState(E);return A})((()=>ux(d,Cp(e),t,wp(n)))),[g,y]=m.useState(!1),p=m.useRef(null),w=m.useCallback((E=>{E&&(p.current=E,h.set({rootRef:p}))}),[]);En((()=>{h.set({locale:Cp(e)})}),[e]),En((()=>{h.set({columns:t})}),[t]),En((()=>{h.set({skinTone:wp(n)})}),[n]);let b=m.useCallback((E=>{s?.(E);let{searchRef:A,viewportRef:x}=h.get(),I=E.target===A?.current||E.target.hasAttribute("frimousse-search"),T=E.target===x?.current||E.target.hasAttribute("frimousse-viewport");E.isDefaultPrevented()||(y(I||T),E.isDefaultPrevented()||(y(I||T),T?h.get().onActiveEmojiChange("keyboard",0,0):I&&h.get().search===""&&h.set({interaction:"none"})))}),[s]),C=m.useCallback((E=>{a?.(E),!E.isDefaultPrevented()&&!E.currentTarget.contains(E.relatedTarget)&&y(!1)}),[a]);return En((()=>{g||h.get().onActiveEmojiReset()}),[g]),m.useImperativeHandle(l,(()=>p.current)),m.useEffect((()=>{if(g)return document.addEventListener("keydown",E),()=>{document.removeEventListener("keydown",E)};function E(A){if(A.defaultPrevented||!A.key.startsWith("Arrow")&&A.key!=="Enter")return;let{data:x,onEmojiSelect:I,onActiveEmojiChange:T,interaction:B,activeColumnIndex:S,activeRowIndex:k}=h.get();if(A.key==="Enter"){let R=Yl(h.get());R&&(A.preventDefault(),I(R))}if(A.key.startsWith("Arrow")){let R=S,M=k;if(A.preventDefault(),B!=="none"){if(x?.rows&&x.rows.length>0)switch(A.key){case"ArrowLeft":if(R===0){let H=M-1,W=x.rows[H];W&&(M=H,R=W.emojis.length-1)}else R-=1;break;case"ArrowRight":if(R===x.rows[M].emojis.length-1){let H=M+1;x.rows[H]&&(M=H,R=0)}else R+=1;break;case"ArrowUp":{let H=x.rows[M-1];H&&(M-=1,H.emojis[R]||(R=H.emojis.length-1));break}case"ArrowDown":{let H=x.rows[M+1];H&&(M+=1,H.emojis[R]||(R=H.emojis.length-1));break}}T("keyboard",R,M)}else T("keyboard",0,0)}}}),[g]),En((()=>{let E=null,A=null,x=null,I=null,T=h.subscribe((M=>{p.current&&(E!==M.viewportWidth&&(E=M.viewportWidth,p.current.style.setProperty("--frimousse-viewport-width",`${M.viewportWidth}px`)),A!==M.viewportHeight&&(A=M.viewportHeight,p.current.style.setProperty("--frimousse-viewport-height",`${M.viewportHeight}px`)),x!==M.rowHeight&&(x=M.rowHeight,p.current.style.setProperty("--frimousse-row-height",`${M.rowHeight}px`)),I!==M.categoryHeaderHeight&&(I=M.categoryHeaderHeight,p.current.style.setProperty("--frimousse-category-header-height",`${M.categoryHeaderHeight}px`)))})),{viewportWidth:B,viewportHeight:S,rowHeight:k,categoryHeaderHeight:R}=h.get();return B&&p.current.style.setProperty("--frimousse-viewport-width",`${B}px`),S&&p.current.style.setProperty("--frimousse-viewport-height",`${S}px`),k&&p.current.style.setProperty("--frimousse-row-height",`${k}px`),R&&p.current.style.setProperty("--frimousse-category-header-height",`${R}px`),T}),[]),v.jsx("div",{"data-focused":g?"":void 0,"frimousse-root":"",onBlurCapture:C,onFocusCapture:b,...f,ref:w,style:{"--frimousse-emoji-font":Vv,...c},children:v.jsxs(cx,{store:h,children:[v.jsx(Ex,{emojiVersion:o,emojibaseUrl:i}),u]})})})),Qv=m.forwardRef((({value:e,defaultValue:t,onChange:n,...r},o)=>{let i=Pt(),s=m.useRef(null),a=m.useCallback((l=>{l&&(s.current=l,i.set({searchRef:s}))}),[]),u=typeof e=="string",c=m.useRef(u);m.useEffect((()=>{c.current=u}),[u]),En((()=>{i.set({search:typeof e=="string"?e:typeof t=="string"?t:""})}),[]),En((()=>{typeof e=="string"&&i.get().onSearchChange(e)}),[e]);let f=m.useCallback((l=>{n?.(l),l.isDefaultPrevented()||i.get().onSearchChange(l.target.value)}),[n]);return m.useImperativeHandle(o,(()=>s.current)),v.jsx("input",{autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",enterKeyHint:"done","frimousse-search":"",placeholder:"Search…",spellCheck:!1,type:"search",...r,defaultValue:t,onChange:f,ref:a,value:e})})),Dx=m.memo((()=>{let e=Zv();return e?v.jsx("div",{"aria-live":"polite",style:{border:0,clip:"rect(0, 0, 0, 0)",height:1,margin:-1,overflow:"hidden",padding:0,position:"absolute",whiteSpace:"nowrap",width:1,wordWrap:"normal"},children:e.label}):null})),e1=m.forwardRef((({children:e,onScroll:t,onKeyDown:n,style:r,...o},i)=>{let s=Pt(),a=m.useRef(null),u=m.useCallback((d=>{d&&(a.current=d,s.set({viewportRef:a}))}),[]),c=$t(s,Gv),f=$t(s,hx),l=m.useCallback((d=>{t?.(d),s.get().onViewportScroll(d.currentTarget.scrollTop)}),[t]);return En((()=>{if(!a.current)return;let d=new ResizeObserver((([h])=>{let g=h?.borderBoxSize[0]?.inlineSize??0,y=h?.borderBoxSize[0]?.blockSize??0,{onViewportSizeChange:p,viewportHeight:w,viewportWidth:b}=s.get();(w!==y||b!==g)&&p(g,y)}));return d.observe(a.current),s.get().onViewportSizeChange(a.current.offsetWidth,a.current.clientHeight),()=>{d.disconnect()}}),[]),m.useImperativeHandle(i,(()=>a.current)),v.jsxs("div",{"frimousse-viewport":"",...o,onScroll:l,ref:u,style:{position:"relative",boxSizing:"border-box",contain:"layout paint",containIntrinsicSize:typeof c=="number"&&typeof f=="number"?`var(--frimousse-viewport-width, auto) calc(${c} * var(--frimousse-row-height) + ${f} * var(--frimousse-category-header-height))`:void 0,overflowY:"auto",overscrollBehavior:"contain",scrollbarGutter:"stable",willChange:"scroll-position",...r},children:[v.jsx(Dx,{}),e]})}));function t1(e,t,n){return{emoji:{...e,isActive:n},role:"gridcell","aria-colindex":t,"aria-selected":n||void 0,"aria-label":e.label,"data-active":n?"":void 0,"frimousse-emoji":"",style:{fontFamily:"var(--frimousse-emoji-font)"},tabIndex:-1}}function n1(e,t=!1){return{role:t?void 0:"row","aria-rowindex":t?void 0:e,"frimousse-row":"",style:{contain:t?void 0:"content",height:t?void 0:"var(--frimousse-row-height)",display:"flex"}}}function r1(e,t){return{"frimousse-category":"",style:{contain:"content",top:t?`calc(${e} * var(--frimousse-category-header-height) + ${t.startRowIndex} * var(--frimousse-row-height))`:void 0,height:t?`calc(var(--frimousse-category-header-height) + ${t.rowsCount} * var(--frimousse-row-height))`:void 0,width:"100%",pointerEvents:"none",position:"absolute"}}}function o1(e,t=!1){return{category:e,"frimousse-category-header":"",style:{contain:t?void 0:"layout paint",height:t?void 0:"var(--frimousse-category-header-height)",pointerEvents:"auto",position:"sticky",top:0}}}function Dp(e,t,n,r){return{"frimousse-list-sizer":"",style:{position:"relative",boxSizing:"border-box",height:`calc(${e} * var(--frimousse-row-height) + ${t} * var(--frimousse-category-header-height))`,paddingTop:`calc(${n} * var(--frimousse-row-height) + ${r} * var(--frimousse-category-header-height))`}}}function Ap(e,t,n){return{"aria-colcount":e,"aria-rowcount":t,"frimousse-list":"",style:{"--frimousse-list-columns":e,...n},role:"grid"}}function Ax(e){e.preventDefault()}var xx=m.memo((({Emoji:e,emoji:t,columnIndex:n,rowIndex:r})=>{let o=Pt(),i=$t(o,(c=>Yl(c)?.emoji===t.emoji)),s=m.useCallback((()=>{o.get().onEmojiSelect(t)}),[t]),a=m.useCallback((()=>{o.get().onActiveEmojiChange("pointer",n,r)}),[n,r]),u=m.useCallback((()=>{o.get().onActiveEmojiReset()}),[]);return v.jsx(e,{...t1(t,n,i),onClick:s,onPointerDown:Ax,onPointerEnter:a,onPointerLeave:u})})),Ox=m.memo((({Row:e,Emoji:t,rowIndex:n})=>{let r=$t(Pt(),(o=>o.data?.rows[n]),gx);return r?v.jsx(e,{...n1(n),children:r.emojis.map(((o,i)=>v.jsx(xx,{Emoji:t,columnIndex:i,emoji:o,rowIndex:n},o.label)))}):null})),Sx=m.memo((({CategoryHeader:e,categoryIndex:t})=>{let n=$t(Pt(),(r=>r.data?.categories[t]),Ql);return n?v.jsx("div",{...r1(t,n),children:v.jsx(e,{...o1({label:n.label})})}):null})),xp=m.memo((({CategoryHeader:e,Row:t,Emoji:n})=>{let r=m.useRef(null),o=Pt(),i=Un(o,"columns"),s=m.useMemo((()=>Array(i).fill({emoji:"🙂",label:""})),[i]),a=m.useMemo((()=>({label:"Category"})),[]),u=m.useRef(null),c=m.useRef(null);return En((()=>{let f=r.current?.parentElement?.parentElement;if(!f||!u.current||!c.current)return;let l=new ResizeObserver((g=>{for(let y of g){let p=y.contentRect.height,{onRowHeightChange:w,onCategoryHeaderHeightChange:b,rowHeight:C,categoryHeaderHeight:E}=o.get();y.target===u.current&&C!==p&&w(p),y.target===c.current&&E!==p&&b(p)}}));l.observe(f),l.observe(u.current),l.observe(c.current);let{onRowHeightChange:d,onCategoryHeaderHeightChange:h}=o.get();return d(u.current.clientHeight),h(c.current.clientHeight),()=>{l.disconnect()}}),[]),v.jsxs("div",{"aria-hidden":!0,ref:r,style:{height:0,visibility:"hidden"},children:[v.jsx("div",{"frimousse-row-sizer":"",ref:u,children:v.jsx(t,{...n1(-1,!0),children:s.map(((f,l)=>v.jsx(n,{...t1(f,l,!1)},l)))})}),v.jsx("div",{...r1(-1),children:v.jsx("div",{"frimousse-category-header-sizer":"",ref:c,children:v.jsx(e,{...o1(a,!0)})})})]})}));function Ix({category:e,...t}){return v.jsx("div",{...t,children:e.label})}function Tx({emoji:e,...t}){return v.jsx("button",{type:"button",...t,children:e.emoji})}function kx({...e}){return v.jsx("div",{...e})}var i1=m.forwardRef((({style:e,components:t,...n},r)=>{let o=Pt(),i=m.useRef(null),s=m.useCallback((w=>{w&&(i.current=w,o.set({listRef:i}))}),[]),a=t?.CategoryHeader??Ix,u=t?.Emoji??Tx,c=t?.Row??kx,f=Un(o,"columns"),l=Un(o,"viewportStartRowIndex"),d=Un(o,"viewportEndRowIndex"),h=$t(o,Gv),g=$t(o,px,Ql),y=m.useMemo((()=>g?.filter((w=>w<l)).length??0),[g,l]),p=g?.length??0;return m.useImperativeHandle(r,(()=>i.current)),h&&g&&p!==0?v.jsx("div",{...Ap(f,h,e),...n,ref:s,children:v.jsxs("div",{...Dp(h,p,l,y),children:[v.jsx(xp,{CategoryHeader:a,Emoji:u,Row:c}),Array.from({length:d-l+1},((w,b)=>{let C=l+b,E=g.indexOf(C);return v.jsxs(m.Fragment,{children:[E>=0&&v.jsx("div",{style:{height:"var(--frimousse-category-header-height)"}}),v.jsx(Ox,{Emoji:u,Row:c,rowIndex:C})]},C)})),Array.from({length:p},((w,b)=>v.jsx(Sx,{CategoryHeader:a,categoryIndex:b},b)))]})}):v.jsx("div",{...Ap(f,0,e),...n,children:v.jsx("div",{...Dp(0,0,0,0),children:v.jsx(xp,{CategoryHeader:a,Emoji:u,Row:c})})})})),s1=m.forwardRef((({emoji:e,onClick:t,"aria-label":n="Change skin tone",...r},o)=>{let i=$t(Pt(),mx,Ql),[s,a,u]=Xv(e),c=m.useMemo((()=>Math.max(0,u.findIndex((y=>y.skinTone===s)))),[s,u]),f=u[c],l=u[(c+1)%u.length].skinTone,d=s==="none"?void 0:i?.[s],h=l==="none"?void 0:i?.[l],g=m.useCallback((y=>{t?.(y),y.isDefaultPrevented()||a(l)}),[t,a,l]);return v.jsx("button",{type:"button",...r,"aria-label":n+(h?` (${h})`:""),"aria-live":"polite","aria-valuetext":d,"frimousse-skin-tone-selector":"",onClick:g,ref:o,children:f.emoji})}));function a1({children:e,...t}){return $t(Pt(),fx)?v.jsx("span",{"frimousse-loading":"",...t,children:e}):null}function _x({children:e}){return e({search:$t(Pt(),lx)})}function u1({children:e,...t}){return $t(Pt(),dx)?v.jsx("span",{"frimousse-empty":"",...t,children:typeof e=="function"?v.jsx(_x,{children:e}):e}):null}function c1({children:e}){return e({emoji:Zv()})}function l1({children:e,emoji:t}){let[n,r,o]=Xv(t);return e({skinTone:n,setSkinTone:r,skinToneVariations:o})}function Bx({emoji:e,className:t,...n}){return v.jsx("button",{className:Ne("lb-emoji-picker-emoji",t),...n,children:v.jsx(Gc,{emoji:e.emoji})})}function Fx({children:e,className:t,...n}){return v.jsx("div",{className:Ne("lb-emoji-picker-row",t),...n,children:e})}function Rx({category:e,className:t,...n}){return v.jsx("div",{className:Ne("lb-emoji-picker-category-header",t),...n,children:v.jsx("span",{className:"lb-emoji-picker-category-header-title",children:e.label})})}Yv.displayName="EmojiPicker.Root",Qv.displayName="EmojiPicker.Search",e1.displayName="EmojiPicker.Viewport",i1.displayName="EmojiPicker.List",a1.displayName="EmojiPicker.Loading",u1.displayName="EmojiPicker.Empty",s1.displayName="EmojiPicker.SkinToneSelector",c1.displayName="EmojiPicker.ActiveEmoji",l1.displayName="EmojiPicker.SkinTone";const Ic=m.forwardRef((({onEmojiSelect:e,onOpenChange:t,children:n,className:r,...o},i)=>{const[s,a]=m.useState(!1),{portalContainer:u,emojibaseUrl:c}=$i(),f=Mt(),l=m.useCallback((g=>{a(g),t?.(g)}),[t]),d=m.useCallback((({emoji:g})=>{a(!1),e?.(g)}),[e]),h=m.useCallback((g=>{g.stopPropagation()}),[]);return v.jsxs(jw,{open:s,onOpenChange:l,children:[n,v.jsx(Pw,{container:u,children:v.jsx(Nw,{side:"top",align:"center",updatePositionStrategy:"always",sideOffset:6,collisionPadding:10,className:Ne("lb-root lb-portal lb-elevation lb-emoji-picker",r),...o,ref:i,asChild:!0,children:v.jsxs(Rn.Root,{onEmojiSelect:d,locale:f.locale,columns:10,emojiVersion:15.1,emojibaseUrl:c,onClick:h,children:[v.jsx("div",{className:"lb-emoji-picker-header",children:v.jsxs("div",{className:"lb-emoji-picker-search-container",children:[v.jsx(Rn.Search,{className:"lb-emoji-picker-search",placeholder:f.EMOJI_PICKER_SEARCH_PLACEHOLDER,autoFocus:!0}),v.jsx(PE,{})]})}),v.jsxs(Rn.Viewport,{className:"lb-emoji-picker-content",children:[v.jsx(Rn.Loading,{className:"lb-loading lb-emoji-picker-loading",children:v.jsx(Wi,{})}),v.jsx(Rn.Empty,{className:"lb-empty lb-emoji-picker-empty",children:f.EMOJI_PICKER_EMPTY}),v.jsx(Rn.List,{className:"lb-emoji-picker-list",components:{CategoryHeader:Rx,Row:Fx,Emoji:Bx}})]}),v.jsxs("div",{className:"lb-emoji-picker-footer",children:[v.jsx(Rn.ActiveEmoji,{children:({emoji:g})=>g?v.jsxs(v.Fragment,{children:[v.jsx("div",{className:"lb-emoji-picker-active-emoji",children:g.emoji}),v.jsx("span",{className:"lb-emoji-picker-active-emoji-label",children:g.label})]}):v.jsx("span",{className:"lb-emoji-picker-active-emoji-label lb-emoji-picker-active-emoji-label-placeholder",children:"Select an emoji…"})}),v.jsx(jt,{content:f.EMOJI_PICKER_CHANGE_SKIN_TONE,children:v.jsx(Rn.SkinToneSelector,{className:"lb-button lb-emoji-picker-skin-tone-selector"})})]})]})})})]})})),Tc=Mw;function jx({label:e,tooltipLabel:t,className:n,onClick:r,...o}){const{createMention:i}=zt(),s=m.useCallback((u=>{u.preventDefault()}),[]),a=m.useCallback((u=>{r?.(u),u.isDefaultPrevented()||(u.stopPropagation(),i())}),[i,r]);return v.jsx(jt,{content:t??e,children:v.jsx(Zt,{className:Ne("lb-composer-editor-action",n),onPointerDown:s,onClick:a,"aria-label":e,icon:v.jsx(ME,{}),...o})})}function Mx({label:e,tooltipLabel:t,onPickerOpenChange:n,className:r,...o}){const{insertText:i}=zt(),s=m.useCallback((u=>{u.preventDefault()}),[]),a=m.useCallback((u=>{u.stopPropagation()}),[]);return v.jsx(Ic,{onEmojiSelect:i,onOpenChange:n,children:v.jsx(jt,{content:t??e,children:v.jsx(Tc,{asChild:!0,children:v.jsx(Zt,{className:Ne("lb-composer-editor-action",r),onPointerDown:s,onClick:a,"aria-label":e,icon:v.jsx(RE,{}),...o})})})})}function Px({label:e,tooltipLabel:t,className:n,...r}){const o=m.useCallback((s=>{s.preventDefault()}),[]),i=m.useCallback((s=>{s.stopPropagation()}),[]);return v.jsx(jt,{content:t??e,children:v.jsx(VA,{asChild:!0,children:v.jsx(Zt,{className:Ne("lb-composer-editor-action",n),onPointerDown:o,onClick:i,"aria-label":e,icon:v.jsx(v0,{}),...r})})})}function Nx({mention:e}){return v.jsxs(Zl,{className:"lb-mention lb-composer-mention",children:[v.jsx("span",{className:"lb-mention-symbol",children:On}),v.jsx(Bo,{userId:e.id})]})}function Lx({mention:e}){const t=jv(e);return v.jsxs(Zl,{className:"lb-mention lb-composer-mention","data-self":t?"":void 0,children:[v.jsx("span",{className:"lb-mention-symbol",children:On}),v.jsx(Tl,{groupId:e.id})]})}function Cs({mark:e,icon:t,shortcut:n,children:r,...o}){const i=Mt(),s=m.useMemo((()=>i.COMPOSER_TOGGLE_MARK(e)),[i,e]);return v.jsx(Sl,{content:s,shortcut:n,sideOffset:8,children:v.jsx($A,{mark:e,asChild:!0,...o,children:v.jsx(Zt,{"aria-label":s,variant:"toolbar",icon:t,children:r})})})}const Ux={bold:()=>v.jsx(Cs,{mark:"bold",shortcut:"Mod-B",icon:v.jsx(OE,{})}),italic:()=>v.jsx(Cs,{mark:"italic",shortcut:"Mod-I",icon:v.jsx(jE,{})}),strikethrough:()=>v.jsx(Cs,{mark:"strikethrough",shortcut:"Mod-Shift-S",icon:v.jsx(LE,{})}),code:()=>v.jsx(Cs,{mark:"code",shortcut:"Mod-E",icon:v.jsx(kE,{})})},Hx=Object.entries(Ux).map((([e,t])=>v.jsx(t,{},e)));function Vx(){return v.jsx(jA,{className:"lb-root lb-portal lb-elevation lb-composer-floating-toolbar",children:Hx})}function $x({attachment:e,className:t,overrides:n,...r}){const{removeAttachment:o}=zt(),{roomId:i}=ya(),s=m.useCallback((()=>{o(e.id)}),[e.id,o]);return v.jsx(Hv,{className:Ne("lb-composer-attachment",t),...r,attachment:e,onDeleteClick:s,preventFocusOnDelete:!0,overrides:n,roomId:i})}function Wx({overrides:e,className:t,...n}){const{attachments:r}=zt();return r.length===0?null:v.jsx("div",{className:Ne("lb-composer-attachments",t),...n,children:v.jsx("div",{className:"lb-attachments",children:r.map((o=>v.jsx($x,{attachment:o,overrides:e},o.id)))})})}const zx={Mention:function({mention:e,...t}){switch(e.kind){case"user":return v.jsx(Nx,{mention:e,...t});case"group":return v.jsx(Lx,{mention:e,...t});default:return Ye(0,"Unhandled mention kind")}},MentionSuggestions:function({mentions:e}){return e.length>0?v.jsx(_v,{className:"lb-root lb-portal lb-elevation lb-composer-suggestions lb-composer-mention-suggestions",children:v.jsx(Bv,{className:"lb-composer-suggestions-list lb-composer-mention-suggestions-list",children:e.map((t=>v.jsx(Fv,{className:"lb-composer-suggestions-list-item lb-composer-mention-suggestion",value:t.id,children:t.kind==="user"?v.jsxs(v.Fragment,{children:[v.jsx(tc,{userId:t.id,className:"lb-composer-mention-suggestion-avatar"}),v.jsx(Bo,{userId:t.id,className:"lb-composer-mention-suggestion-user"})]}):t.kind==="group"?v.jsxs(v.Fragment,{children:[v.jsx(bE,{groupId:t.id,className:"lb-composer-mention-suggestion-avatar",icon:v.jsx(UE,{})}),v.jsx(Tl,{groupId:t.id,className:"lb-composer-mention-suggestion-group",children:v.jsx(wE,{groupId:t.id,className:"lb-composer-mention-suggestion-group-description"})})]}):Ye(0,"Unhandled mention kind")},t.id)))})}):null},Link:function({href:e,children:t}){return v.jsx(kv,{href:e,className:"lb-composer-link",children:t})}};function Kx({showAttachments:e=!0,showFormattingControls:t=!0,showAttribution:n,defaultValue:r,isCollapsed:o,overrides:i,actions:s,autoFocus:a,disabled:u,hasResolveMentionSuggestions:c,onEmojiPickerOpenChange:f,onEmptyChange:l,onEditorClick:d}){const{isEmpty:h}=zt(),{hasMaxAttachments:g}=ql(),y=Mt(i),p=m.useMemo((()=>({...zx,FloatingToolbar:t?Vx:void 0})),[t]),[w,b]=Tv({disabled:u||!e||g});Sn((()=>{l(h)}),[h,l]);const C=m.useCallback((A=>{A.preventDefault()}),[]),E=m.useCallback((A=>{A.stopPropagation()}),[]);return v.jsxs("div",{className:"lb-composer-editor-container",...b,children:[v.jsx(UA,{className:"lb-composer-editor",onClick:d,placeholder:y.COMPOSER_PLACEHOLDER,defaultValue:r,autoFocus:a,components:p,disabled:u,dir:y.dir}),e&&v.jsx(Wx,{overrides:i}),(!o||w)&&v.jsxs("div",{className:"lb-composer-footer",children:[v.jsxs("div",{className:"lb-composer-editor-actions",children:[c&&v.jsx(jx,{label:y.COMPOSER_INSERT_MENTION,disabled:u}),v.jsx(Mx,{label:y.COMPOSER_INSERT_EMOJI,onPickerOpenChange:f,disabled:u}),e&&v.jsx(Px,{label:y.COMPOSER_ATTACH_FILES,disabled:u})]}),n&&v.jsx(QA,{}),v.jsx("div",{className:"lb-composer-actions",children:s??v.jsx(v.Fragment,{children:v.jsx(Sl,{content:y.COMPOSER_SEND,shortcut:"Enter",children:v.jsx(Rv,{asChild:!0,children:v.jsx(Zt,{onPointerDown:C,onClick:E,className:"lb-composer-action",variant:"primary","aria-label":y.COMPOSER_SEND,icon:v.jsx(NE,{})})})})})})]}),e&&w&&v.jsx("div",{className:"lb-composer-attachments-drop-area",children:v.jsxs("div",{className:"lb-composer-attachments-drop-area-label",children:[v.jsx(v0,{}),y.COMPOSER_ATTACH_FILES]})})]})}m.createContext(null);const d1=m.forwardRef((({threadId:e,commentId:t,metadata:n,visibility:r,commentMetadata:o,defaultValue:i,defaultAttachments:s,onComposerSubmit:a,collapsed:u,defaultCollapsed:c,onCollapsedChange:f,overrides:l,actions:d,onBlur:h,className:g,onFocus:y,autoFocus:p,disabled:w,blurOnSubmit:b=!0,showAttachments:C=!0,showFormattingControls:E=!0,showAttribution:A,roomId:x,...I},T)=>{const B=Sm({allowOutsideRoom:!0}),S=x!==void 0?x:B?.id;if(S===void 0)throw new Error("Composer must be a descendant of RoomProvider component");const k=Em(S),R=Dm(S),M=Am(S),{preventUnsavedComposerChanges:H}=$i(),W=Kc()!==void 0,G=m.useRef(!0),q=m.useRef(!1),$=Mt(l),[V,Q]=(function(Y,de,pe){const[fe,we]=m.useState(Y),Ce=de!==void 0,se=m.useRef(Ce);return m.useEffect((()=>{se.current=Ce}),[Ce]),[Ce?de:fe,m.useCallback((te=>(Ce||we(te),pe?.(te))),[Ce,pe])]})(c??!1,u,f),ae=u!==void 0||c===!0,ie=qc(S,_l(e===void 0?r??"public":r),"write"),Se=m.useCallback((Y=>{G.current=Y}),[]),Ie=m.useCallback((Y=>{q.current=Y}),[]),ne=m.useCallback((Y=>{y?.(Y),Y.isDefaultPrevented()||G.current&&ie&&Q?.(!1)}),[Q,y,ie]),_=m.useCallback((Y=>{if(h?.(Y),Y.isDefaultPrevented())return;const de=!Y.currentTarget.contains(Y.relatedTarget??document.activeElement);ae&&de&&G.current&&!q.current&&Q?.(!0)}),[h,Q,ae]),X=m.useCallback((Y=>{Y.stopPropagation(),G.current&&ie&&Q?.(!1)}),[Q,ie]),K=m.useCallback(((Y,de)=>{a?.(Y,de),de.isDefaultPrevented()||(de.stopPropagation(),t&&e?M({commentId:t,threadId:e,body:Y.body,metadata:o,attachments:Y.attachments}):e?R({threadId:e,body:Y.body,metadata:o,attachments:Y.attachments}):k({body:Y.body,metadata:n,visibility:r,commentMetadata:o,attachments:Y.attachments}))}),[t,R,k,M,o,n,r,a,e]);return v.jsx(fa,{children:v.jsx(HA,{onComposerSubmit:K,className:Ne("lb-root lb-composer lb-composer-form",g),dir:$.dir,...I,ref:T,"data-collapsed":V?"":void 0,onFocus:ne,onBlur:_,disabled:w||!ie,defaultAttachments:s,pasteFilesAsAttachments:C,preventUnsavedChanges:H,blurOnSubmit:b,roomId:S,children:v.jsx(Kx,{defaultValue:i,actions:d,overrides:l,isCollapsed:V,showAttachments:C,showAttribution:A,showFormattingControls:E,hasResolveMentionSuggestions:W,onEmptyChange:Se,onEmojiPickerOpenChange:Ie,onEditorClick:X,autoFocus:p,disabled:w})})})}));function qx({children:e,content:t,defaultOpen:n,open:r,onOpenChange:o,className:i,...s}){const a=Mt(),{portalContainer:u}=$i();return v.jsxs(Cw,{defaultOpen:n,open:r,onOpenChange:o,dir:a.dir,children:[e,v.jsx(Ew,{container:u,children:v.jsx(Dw,{className:Ne("lb-root lb-portal lb-elevation lb-dropdown",i),sideOffset:6,collisionPadding:10,updatePositionStrategy:"always",...s,children:t})})]})}const Gx=m.forwardRef((({children:e,className:t,icon:n,...r},o)=>v.jsxs(bw,{className:Ne("lb-dropdown-item",t),...r,ref:o,children:[n?v.jsx("span",{className:"lb-dropdown-item-icon lb-icon-container",children:n}):null,e?v.jsx("span",{className:"lb-dropdown-item-label",children:e}):null]}))),Jx=ww;function Op({locale:e,date:t,className:n,...r}){return v.jsx(qA,{locale:e,date:t,className:Ne("lb-date",n),...r})}function Zx({mention:e,className:t,...n}){const r=mr();return v.jsxs($l,{className:Ne("lb-mention lb-comment-mention",t),"data-self":e.id===r?"":void 0,...n,children:[v.jsx("span",{className:"lb-mention-symbol",children:On}),v.jsx(Bo,{userId:e.id})]})}function Xx({mention:e,className:t,...n}){const r=jv(e);return v.jsxs($l,{className:Ne("lb-mention lb-comment-mention",t),"data-self":r?"":void 0,...n,children:[v.jsx("span",{className:"lb-mention-symbol",children:On}),v.jsx(Tl,{groupId:e.id})]})}function Yx({mention:e,...t}){switch(e.kind){case"user":return v.jsx(Zx,{mention:e,...t});case"group":return v.jsx(Xx,{mention:e,...t});default:return Ye(0,"Unhandled mention kind")}}function Qx({href:e,children:t,className:n,...r}){const{Anchor:o}=(function(i){const s=m.useContext(ec);return m.useMemo((()=>({...p0,...s,...i})),[s,i])})();return v.jsx(nv,{className:Ne("lb-comment-link",n),href:e,...r,asChild:!0,children:v.jsx(o,{...r,children:t})})}const f1=m.forwardRef((({reaction:e,overrides:t,className:n,...r},o)=>{const i=Mt(t);return v.jsxs(Il,{className:Ne("lb-comment-reaction",n),variant:"outline","aria-label":i.COMMENT_REACTION_DESCRIPTION(e.emoji,e.users.length),...r,ref:o,children:[v.jsx(Gc,{className:"lb-comment-reaction-emoji",emoji:e.emoji}),v.jsx("span",{className:"lb-comment-reaction-count",children:e.users.length})]})})),e5=m.forwardRef((({comment:e,reaction:t,overrides:n,disabled:r,...o},i)=>{const s=xm(e.roomId),a=Om(e.roomId),u=mr(),c=m.useMemo((()=>t.users.some((g=>g.id===u))),[u,t]),f=Mt(n),l=m.useMemo((()=>v.jsx("span",{children:f.COMMENT_REACTION_LIST(v.jsx(EE,{values:t.users.map((g=>v.jsx(Bo,{userId:g.id,replaceSelf:!0},g.id))),formatRemaining:f.LIST_REMAINING_USERS,truncate:5,locale:f.locale}),t.emoji,t.users.length)})),[f,t]),d=m.useCallback((g=>{g.stopPropagation()}),[]),h=m.useCallback((g=>{g?s({threadId:e.threadId,commentId:e.id,emoji:t.emoji}):a({threadId:e.threadId,commentId:e.id,emoji:t.emoji})}),[s,e.threadId,e.id,t.emoji,a]);return v.jsx(jt,{content:l,multiline:!0,className:"lb-comment-reaction-tooltip",children:v.jsx(El,{asChild:!0,pressed:c,onPressedChange:h,onClick:d,disabled:r,ref:i,children:v.jsx(f1,{"data-self":c?"":void 0,reaction:t,overrides:n,...o})})})}));function h1({attachment:e,url:t}){e.mimeType==="application/pdf"||e.mimeType.startsWith("image/")||e.mimeType.startsWith("video/")||e.mimeType.startsWith("audio/")?window.open(t,"_blank"):(function(n,r){const o=document.createElement("a");o.href=n,o.download=r,o.style.display="none",document.body.appendChild(o),o.click(),document.body.removeChild(o)})(t,e.name)}function t5({attachment:e,onAttachmentClick:t,roomId:n,className:r,overrides:o,...i}){const{url:s}=ia(e.id,n),a=m.useCallback((u=>{if(!s)return;const c={attachment:e,url:s};t?.(c,u),u.isDefaultPrevented()||h1(c)}),[e,t,s]);return v.jsx(YA,{className:Ne("lb-comment-attachment",r),...i,attachment:e,overrides:o,onClick:s?a:void 0,roomId:n})}function n5({attachment:e,onAttachmentClick:t,roomId:n,className:r,overrides:o,...i}){const{url:s}=ia(e.id,n),a=m.useCallback((u=>{if(!s)return;const c={attachment:e,url:s};t?.(c,u),u.isDefaultPrevented()||h1(c)}),[e,t,s]);return v.jsx(Hv,{className:Ne("lb-comment-attachment",r),...i,attachment:e,overrides:o,onClick:s?a:void 0,roomId:n})}m.forwardRef((({reaction:e,overrides:t,...n},r)=>{const o=mr(),i=m.useMemo((()=>e.users.some((s=>s.id===o))),[o,e]);return v.jsx(f1,{disableable:!1,"data-self":i?"":void 0,reaction:e,overrides:t,...n,ref:r})}));const gu=m.forwardRef((({children:e,icon:t,onSelect:n,onClick:r,...o},i)=>{const s=m.useCallback((a=>{r?.(a),a.isDefaultPrevented()||a.stopPropagation()}),[r]);return v.jsx(Gx,{icon:t,onSelect:n,onClick:s,...o,ref:i,children:e})})),Sp=Object.assign(m.forwardRef((({comment:e,visibility:t,indentContent:n=!0,showDeleted:r,showActions:o="hover",showReactions:i=!0,showAttachments:s=!0,showComposerFormattingControls:a=!0,onAuthorClick:u,onMentionClick:c,onAttachmentClick:f,onCommentEdit:l,onCommentDelete:d,dropdownItems:h,overrides:g,components:y,additionalContent:p,body:w,avatar:b,author:C,date:E,className:A,actions:x,actionsClassName:I,internalDropdownItems:T,children:B,...S},k)=>{const R=`${e.id}:body`,M=zi(k,m.useRef(null)),H=mr(),W=(function(J){const oe=Ve();return m.useCallback((({threadId:ge,commentId:ve})=>{const Te=new Date,{store:We,onMutationFailure:Le}=Et(oe),et=We.optimisticUpdates.add({type:"delete-comment",threadId:ge,commentId:ve,deletedAt:Te,roomId:J});oe[Oe].httpClient.deleteComment({roomId:J,threadId:ge,commentId:ve,visibility:So(We,ge)}).then((()=>{We.deleteComment(ge,et,ve,Te)}),(ut=>Le(et,{type:"DELETE_COMMENT_ERROR",roomId:J,threadId:ge,commentId:ve},ut)))}),[oe,J])})(e.roomId),G=Am(e.roomId),q=xm(e.roomId),$=Om(e.roomId),V=Mt(g),[Q,ae]=m.useState(!1),[ie,Se]=m.useState(!1),[Ie,ne]=m.useState(!1),[_,X]=m.useState(!1),{mediaAttachments:K,fileAttachments:Y}=m.useMemo((()=>(function(J){const oe=[],ge=[];for(const ve of J)(ve.mimeType.startsWith("image/")||ve.mimeType.startsWith("video/"))&&ve.size<=Mv?oe.push(ve):ge.push(ve);return{mediaAttachments:oe,fileAttachments:ge}})(e.attachments)),[e.attachments]),de=qc(e.roomId,_l(t),"write"),pe=m.useCallback((J=>{J.stopPropagation()}),[]),fe=m.useCallback((()=>{ae(!0)}),[]),we=m.useCallback((J=>{J.stopPropagation(),ae(!1)}),[]),Ce=m.useCallback((({body:J,attachments:oe},ge)=>{l?.(e),ge.isDefaultPrevented()||(ge.stopPropagation(),ge.preventDefault(),ae(!1),G({commentId:e.id,threadId:e.threadId,body:J,attachments:oe}))}),[e,G,l]),se=m.useCallback((()=>{d?.(e),W({commentId:e.id,threadId:e.threadId})}),[e,W,d]),te=m.useCallback((J=>{u?.(e.userId,J)}),[e.userId,u]),me=m.useCallback((J=>{const oe=e.reactions.findIndex((ge=>ge.emoji===J));oe>=0&&H&&e.reactions[oe]?.users.some((ge=>ge.id===H))?$({threadId:e.threadId,commentId:e.id,emoji:J}):q({threadId:e.threadId,commentId:e.id,emoji:J})}),[q,e.id,e.reactions,e.threadId,$,H]);if(m.useEffect((()=>{typeof window<"u"&&window.location.hash.slice(1)===e.id&&Se(!0)}),[]),!r&&!e.body)return null;const Ae=e.userId===H?v.jsxs(v.Fragment,{children:[v.jsx(gu,{onSelect:fe,icon:v.jsx(BE,{}),children:V.COMMENT_EDIT}),v.jsx(gu,{onSelect:se,icon:v.jsx(_E,{}),children:V.COMMENT_DELETE})]}):null,Pe=T||Ae?v.jsxs(v.Fragment,{children:[T,Ae]}):null,Be=typeof h=="function"?h({children:Pe,comment:e}):Pe||h?v.jsxs(v.Fragment,{children:[Pe,h]}):null;let re;if(Q)re=v.jsx(d1,{className:"lb-comment-composer",threadId:e.threadId,commentId:e.id,visibility:t,onComposerSubmit:Ce,defaultValue:e.body,defaultAttachments:e.attachments,autoFocus:!0,showAttribution:!1,showAttachments:s,showFormattingControls:a,actions:v.jsxs(v.Fragment,{children:[v.jsx(jt,{content:V.COMMENT_EDIT_COMPOSER_CANCEL,"aria-label":V.COMMENT_EDIT_COMPOSER_CANCEL,children:v.jsx(Zt,{className:"lb-composer-action",onClick:we,icon:v.jsx(kl,{})})}),v.jsx(Sl,{content:V.COMMENT_EDIT_COMPOSER_SAVE,shortcut:"Enter",children:v.jsx(Rv,{asChild:!0,children:v.jsx(Zt,{variant:"primary",className:"lb-composer-action",onClick:pe,"aria-label":V.COMMENT_EDIT_COMPOSER_SAVE,icon:v.jsx(SE,{})})})})]}),overrides:{COMPOSER_PLACEHOLDER:V.COMMENT_EDIT_COMPOSER_PLACEHOLDER},roomId:e.roomId});else{const J=v.jsx(nA,{className:"lb-comment-body",id:R,body:e.body,components:{Mention:({mention:oe})=>v.jsx(Yx,{mention:oe,onClick:ge=>c?.(oe,ge),overrides:g}),Link:Qx}});re=e.body?v.jsxs(v.Fragment,{children:[w===void 0?J:typeof w=="function"?w({comment:e,children:J}):w,p,s&&(K.length>0||Y.length>0)?v.jsxs("div",{className:"lb-comment-attachments",children:[K.length>0?v.jsx("div",{className:"lb-attachments",children:K.map((oe=>v.jsx(t5,{attachment:oe,overrides:g,onAttachmentClick:f,roomId:e.roomId},oe.id)))}):null,Y.length>0?v.jsx("div",{className:"lb-attachments",children:Y.map((oe=>v.jsx(n5,{attachment:oe,overrides:g,onAttachmentClick:f,roomId:e.roomId},oe.id)))}):null]}):null,i&&e.reactions.length>0&&v.jsxs("div",{className:"lb-comment-reactions",children:[e.reactions.map((oe=>v.jsx(e5,{comment:e,reaction:oe,overrides:g,disabled:!de},oe.emoji))),de?v.jsx(Ic,{onEmojiSelect:me,children:v.jsx(jt,{content:V.COMMENT_ADD_REACTION,children:v.jsx(Tc,{asChild:!0,children:v.jsx(Zt,{className:"lb-comment-reaction lb-comment-reaction-add",variant:"outline",onClick:pe,"aria-label":V.COMMENT_ADD_REACTION,icon:v.jsx(Tf,{})})})})}):null]})]}):v.jsx("div",{className:"lb-comment-body",children:v.jsx("p",{className:"lb-comment-deleted",children:V.COMMENT_DELETED})}),re=typeof B=="function"?B({comment:e,children:re}):B??re}return v.jsx(fa,{children:v.jsx(lE,{components:y,children:v.jsxs("div",{role:"article",id:e.id,className:Ne("lb-root lb-comment",n&&"lb-comment:indent-content",o==="hover"&&"lb-comment:show-actions-hover",(Ie||_)&&"lb-comment:action-open",A),"data-deleted":e.body?void 0:"","data-editing":Q?"":void 0,"data-target":ie?"":void 0,"aria-labelledby":R,dir:V.dir,...S,ref:M,children:[v.jsxs("div",{className:"lb-comment-header",children:[v.jsxs("div",{className:"lb-comment-details",children:[b?v.jsx("div",{className:"lb-comment-avatar",onClick:te,children:b}):v.jsx(tc,{className:"lb-comment-avatar",userId:e.userId,onClick:te}),v.jsxs("span",{className:"lb-comment-details-labels",children:[C?v.jsx("span",{className:"lb-comment-author",onClick:te,children:C}):v.jsx(Bo,{className:"lb-comment-author",userId:e.userId,onClick:te}),E?v.jsx("span",{className:"lb-comment-date",children:E}):v.jsxs("span",{className:"lb-comment-date",children:[v.jsx(Op,{locale:V.locale,date:e.createdAt,className:"lb-comment-date-created"}),e.editedAt&&e.body&&v.jsxs(v.Fragment,{children:[" ",v.jsx("span",{className:"lb-comment-date-edited",children:V.COMMENT_EDITED})]})]})]})]}),o&&!Q&&v.jsxs("div",{className:Ne("lb-comment-actions",I),children:[x??null,i&&de?v.jsx(Ic,{onEmojiSelect:me,onOpenChange:X,children:v.jsx(jt,{content:V.COMMENT_ADD_REACTION,children:v.jsx(Tc,{asChild:!0,children:v.jsx(Zt,{className:"lb-comment-action",onClick:pe,"aria-label":V.COMMENT_ADD_REACTION,icon:v.jsx(Tf,{})})})})}):null,Be?v.jsx(qx,{open:Ie,onOpenChange:ne,align:"end",content:Be,children:v.jsx(jt,{content:V.COMMENT_MORE,children:v.jsx(Jx,{asChild:!0,children:v.jsx(Zt,{className:"lb-comment-action",disabled:!e.body,onClick:pe,"aria-label":V.COMMENT_MORE,icon:v.jsx(FE,{})})})})}):null]})]}),v.jsx("div",{className:"lb-comment-content",children:re})]})})})})),{DropdownItem:gu,Avatar:function(e){return v.jsx(tc,{...e})},Author:function(e){return v.jsx(Bo,{...e})},Date:Op});function r5(e){return window.addEventListener("blur",e),window.addEventListener("focus",e),()=>{window.removeEventListener("blur",e),window.removeEventListener("focus",e)}}function o5(){return document.hasFocus()}function i5(){return!0}function s5({thread:e}){const{id:t,roomId:n}=e,r=m.useRef(null),o=(function(i){const s=Ve();return m.useCallback((a=>{const{store:u,onMutationFailure:c}=Et(s),f=Object.values(u.outputs.notifications.get().notificationsById).find((h=>h.kind==="thread"&&h.threadId===a));if(!f)return;const l=new Date,d=u.optimisticUpdates.add({type:"mark-inbox-notification-as-read",inboxNotificationId:f.id,readAt:l});s[Oe].httpClient.markRoomInboxNotificationAsRead({roomId:i,inboxNotificationId:f.id}).then((()=>{u.markInboxNotificationRead(f.id,l,d)}),(h=>{c(d,{type:"MARK_INBOX_NOTIFICATION_AS_READ_ERROR",roomId:i,inboxNotificationId:f.id},h)}))}),[s,i])})(n);return eA(r,(i=>{i&&o(t)}),{enabled:m.useSyncExternalStore(r5,o5,i5)}),v.jsx("div",{ref:r,style:{height:0},"aria-hidden":!0,"data-mark-as-read-marker":""})}const k5=m.forwardRef((({thread:e,indentCommentContent:t=!0,showActions:n="hover",showDeletedComments:r,showResolveAction:o=!0,showReactions:i=!0,showComposer:s="collapsed",showAttachments:a=!0,showSubscription:u=!0,showComposerFormattingControls:c=!0,maxVisibleComments:f,commentDropdownItems:l,onResolvedChange:d,onCommentEdit:h,onCommentDelete:g,onThreadDelete:y,onAuthorClick:p,onMentionClick:w,onAttachmentClick:b,onComposerSubmit:C,blurComposerOnSubmit:E,autoFocus:A,overrides:x,components:I,className:T,...B},S)=>{const k=$E(I?.Comment,Sp),R=(function(se){const te=Ve();return m.useCallback((me=>{const Ae=new Date,{store:Pe,onMutationFailure:Be}=Et(te),re=Pe.optimisticUpdates.add({type:"mark-thread-as-resolved",threadId:me,updatedAt:Ae});te[Oe].httpClient.markThreadAsResolved({roomId:se,threadId:me,visibility:So(Pe,me)}).then((()=>{Pe.patchThread(me,re,{resolved:!0},Ae)}),(J=>Be(re,{type:"MARK_THREAD_AS_RESOLVED_ERROR",roomId:se,threadId:me},J)))}),[te,se])})(e.roomId),M=(function(se){const te=Ve();return m.useCallback((me=>{const Ae=new Date,{store:Pe,onMutationFailure:Be}=Et(te),re=Pe.optimisticUpdates.add({type:"mark-thread-as-unresolved",threadId:me,updatedAt:Ae});te[Oe].httpClient.markThreadAsUnresolved({roomId:se,threadId:me,visibility:So(Pe,me)}).then((()=>{Pe.patchThread(me,re,{resolved:!1},Ae)}),(J=>Be(re,{type:"MARK_THREAD_AS_UNRESOLVED_ERROR",roomId:se,threadId:me},J)))}),[te,se])})(e.roomId),H=Mt(x),[W,G]=m.useState(!1),q=m.useMemo((()=>r?0:e.comments.findIndex((se=>se.body))),[r,e.comments]),$=m.useMemo((()=>r?e.comments.length-1:Tp(e.comments,(se=>!!se.body))),[r,e.comments]),V=m.useMemo((()=>r?e.comments.length:e.comments.filter((se=>se.body)).length),[r,e.comments]),Q=m.useMemo((()=>{const se=typeof f=="number"?f:f?.max,te=(typeof f=="object"?f?.show:void 0)??"newest";if(W||se===void 0)return;const me=e.comments.map(((ve,Te)=>({comment:ve,index:Te}))).filter((({comment:ve})=>r||ve.body));if(me.length<=Math.max(se,2))return;const Ae=me[0],Pe=me[me.length-1];if(se<=2)return{firstIndex:me[1]?.index??Ae.index,lastIndex:me[me.length-2]?.index??Pe.index,count:me.slice(1,me.length-1).length};const Be=se-2,re=te==="oldest"?Be:te==="newest"?0:Math.floor(Be/2),J=te==="oldest"?0:te==="newest"?Be:Math.ceil(Be/2),oe=me[1+re],ge=me[me.length-2-J];return!oe||!ge||oe.index>ge.index?void 0:{firstIndex:oe.index,lastIndex:ge.index,count:e.comments.slice(oe.index,ge.index+1).filter((ve=>r||ve.body)).length}}),[f,W,r,e.comments]),{status:ae,unreadSince:ie,subscribe:Se,unsubscribe:Ie}=sb(e.roomId,e.id),ne=m.useMemo((()=>{if(ae!=="subscribed")return;if(ie===null)return q;const se=e.comments.findIndex((te=>(!!r||te.body)&&te.createdAt>ie));return se>=0&&se<e.comments.length?se:void 0}),[q,r,ae,e.comments,ie]),[_,X]=m.useState(),K=_===void 0?ne:_;m.useEffect((()=>{ne&&X((se=>Math.min(se??1/0,ne)))}),[ne]);const Y=qc(e.roomId,_l(e.visibility),"write"),de=m.useCallback((se=>{se.stopPropagation()}),[]),pe=m.useCallback((se=>{d?.(se),se?R(e.id):M(e.id)}),[R,M,d,e.id]),fe=m.useCallback((se=>{g?.(se),e.comments.filter((te=>te.body)).length<=1&&y?.(e)}),[g,y,e]),we=m.useCallback((()=>{ae==="subscribed"?Ie():Se()}),[ae,Se,Ie]);let Ce=0;return v.jsx(fa,{children:v.jsxs("div",{className:Ne("lb-root lb-thread",n==="hover"&&"lb-thread:show-actions-hover",T),"data-resolved":e.resolved?"":void 0,"data-unread":ne!==void 0?"":void 0,dir:H.dir,...B,ref:S,children:[v.jsx("div",{className:"lb-thread-comments",role:"feed",children:e.comments.map(((se,te)=>{const me=r||se.body,Ae=te===q,Pe=ne!==void 0&&te>=ne,Be=Q&&te>=Q.firstIndex&&te<=Q.lastIndex,re=!r&&!se.body;if(Be&&te===Q.firstIndex)return v.jsx("div",{className:"lb-thread-show-more",children:v.jsx(Zt,{variant:"ghost",className:"lb-thread-show-more-button",onClick:()=>G(!0),children:H.THREAD_SHOW_MORE_COMMENTS(Q.count)})},`${se.id}:show-more`);if(Be||re)return null;me&&Ce++;const J=v.jsx(k,{tabIndex:0,"aria-posinset":Ce,"aria-setsize":V,overrides:x,className:"lb-thread-comment","data-unread":Pe?"":void 0,comment:se,visibility:e.visibility,indentContent:t,showDeleted:r,showActions:n,showReactions:i,showAttachments:a,showComposerFormattingControls:c,onCommentEdit:h,onCommentDelete:fe,onAuthorClick:p,onMentionClick:w,onAttachmentClick:b,components:I,actionsClassName:Ae?"lb-thread-actions":void 0,actions:Ae&&o?v.jsx(jt,{content:e.resolved?H.THREAD_UNRESOLVE:H.THREAD_RESOLVE,children:v.jsx(El,{pressed:e.resolved,onPressedChange:pe,asChild:!0,children:v.jsx(Zt,{className:"lb-comment-action",onClick:de,"aria-label":e.resolved?H.THREAD_UNRESOLVE:H.THREAD_RESOLVE,icon:e.resolved?v.jsx(TE,{}):v.jsx(IE,{}),disabled:!Y})})}):null,internalDropdownItems:Ae&&u?v.jsx(Sp.DropdownItem,{onSelect:we,icon:ae==="subscribed"?v.jsx(xE,{}):v.jsx(AE,{}),children:ae==="subscribed"?H.THREAD_UNSUBSCRIBE:H.THREAD_SUBSCRIBE}):void 0,dropdownItems:l},se.id);return te===K&&K!==q&&K<=$?v.jsxs(m.Fragment,{children:[v.jsx("div",{className:"lb-thread-new-indicator","aria-label":H.THREAD_NEW_INDICATOR_DESCRIPTION,children:v.jsxs("span",{className:"lb-thread-new-indicator-label",children:[v.jsx(DE,{className:"lb-thread-new-indicator-label-icon"}),H.THREAD_NEW_INDICATOR]})}),J]},se.id):J}))}),ne!==void 0&&v.jsx(s5,{thread:e}),s&&v.jsx(d1,{className:"lb-thread-composer",threadId:e.id,visibility:e.visibility,defaultCollapsed:s==="collapsed"||void 0,showAttachments:a,showFormattingControls:c,onComposerSubmit:C,blurOnSubmit:E,overrides:{COMPOSER_PLACEHOLDER:H.THREAD_COMPOSER_PLACEHOLDER,COMPOSER_SEND:H.THREAD_COMPOSER_SEND,...x},roomId:e.roomId,autoFocus:A})]})})}));export{d5 as C,f5 as L,qA as T,g5 as _,Sm as a,b5 as b,m5 as c,v5 as d,d1 as e,nA as f,Sp as g,y5 as h,k5 as i,v as j,wm as k,nv as l,$l as m,h5 as n,p5 as o,Mt as u};