dorkos 0.98.0 → 0.101.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/README.md +43 -13
  2. package/dist/bin/cli.js +10649 -8676
  3. package/dist/browser/fresh-verifier.mjs +3 -2
  4. package/dist/browser/native/darwin-journal-worker.mjs +2244 -0
  5. package/dist/browser/native/darwin-process-observer +0 -0
  6. package/dist/browser/native/darwin-process-observer.c +252 -0
  7. package/dist/browser/native/darwin-process-observer.h +37 -0
  8. package/dist/browser/native/darwin-process-observer.manifest.json +1 -0
  9. package/dist/browser/native/darwin-supervisor-worker.mjs +1996 -0
  10. package/dist/browser/native/package-manifest.json +1 -0
  11. package/dist/browser/source-manifest.json +1 -1
  12. package/dist/client/assets/{AboutPage-DqTcRYx5.js → AboutPage-CwxCTicf.js} +1 -1
  13. package/dist/client/assets/ActivityRow-D0QQ0SFu.js +1 -0
  14. package/dist/client/assets/AdapterIcon-CL-MyyKy.js +1 -0
  15. package/dist/client/assets/AdapterSetupWizard-C8HOvHLF.js +2 -0
  16. package/dist/client/assets/AgentRequestCard-BLLmoAES.js +12 -0
  17. package/dist/client/assets/AppearancePage-GqrWckTQ.js +1 -0
  18. package/dist/client/assets/AttentionSignalRow-sEhnIPBB.js +1 -0
  19. package/dist/client/assets/{BaseTanStackRouterDevtoolsPanel-B-iktbLX-Bmlsorom.js → BaseTanStackRouterDevtoolsPanel-B-iktbLX-BXjzhT_D.js} +1 -1
  20. package/dist/client/assets/{BlintzCanvas-BBW7iNEC.js → BlintzCanvas-CXi0fvcM.js} +1 -1
  21. package/dist/client/assets/{CanvasCsvContent-D6qWSQm4.js → CanvasCsvContent-QhDSf8Pd.js} +2 -2
  22. package/dist/client/assets/CanvasFileContent-ZZhdofR4.js +2 -0
  23. package/dist/client/assets/CanvasModel3dContent-DMMMZh4o.js +2 -0
  24. package/dist/client/assets/{CodeMirrorDiff-DsOh9sIB.js → CodeMirrorDiff-BMG7DBg2.js} +1 -1
  25. package/dist/client/assets/{CodeMirrorEditor-BxIWDXqr.js → CodeMirrorEditor-BYdz0ipX.js} +1 -1
  26. package/dist/client/assets/ConnectionAccessLists-PW1uzcGU.js +1 -0
  27. package/dist/client/assets/{ConnectionsPage-DvxSfsfG.js → ConnectionsPage-EwitZwOE.js} +3 -3
  28. package/dist/client/assets/ConventionPage-y-Zq3Klp.js +11 -0
  29. package/dist/client/assets/ExtensionPageRoute-gZKKPhaj.js +6 -0
  30. package/dist/client/assets/{FloatingTanStackRouterDevtools-CqogiFob-BCrkUo51.js → FloatingTanStackRouterDevtools-CqogiFob-CbKIa11X.js} +1 -1
  31. package/dist/client/assets/HandlePage-CL3_n1CI.js +1 -0
  32. package/dist/client/assets/{LexicalField-mvJHHMqo.js → LexicalField-Ceoa9flp.js} +13 -13
  33. package/dist/client/assets/{ManagesPage-DScJn5uY.js → ManagesPage-Dcqdm6I8.js} +1 -1
  34. package/dist/client/assets/Marketplace-DsU-q1ZZ.js +36 -0
  35. package/dist/client/assets/MarketplaceSourcesView-D72YoKNR.js +1 -0
  36. package/dist/client/assets/McpAppFrame-B1ThSf2U.js +6 -0
  37. package/dist/client/assets/McpSigninBody-Btg3PnYN.js +1 -0
  38. package/dist/client/assets/{Model3dViewer-BYNxJNRV.js → Model3dViewer-DlcQ3-LS.js} +1 -1
  39. package/dist/client/assets/NamePage-Bzqj4Eob.js +1 -0
  40. package/dist/client/assets/NewDirectMessageMenu-89yeGqvy.js +1 -0
  41. package/dist/client/assets/{NotificationsPage-CU6oIOwb.js → NotificationsPage-CQQIdLtI.js} +1 -1
  42. package/dist/client/assets/OperatorIdentityForm-BhiB9tQp.js +1 -0
  43. package/dist/client/assets/{PermissionsPage-BIatOhyg.js → PermissionsPage-TX-d7aVQ.js} +1 -1
  44. package/dist/client/assets/PersonalityPicker-C_9JVOva.js +1 -0
  45. package/dist/client/assets/PersonalityPopover-BoTED73t.js +1 -0
  46. package/dist/client/assets/PhotoPage-C3fMlebQ.js +1 -0
  47. package/dist/client/assets/PreviewRefusedNotice-ChCgdKWN.js +1 -0
  48. package/dist/client/assets/PromptSuggestionChips-B_oUtFMI.js +1 -0
  49. package/dist/client/assets/RoomSurface-CgtNuYhl.js +39 -0
  50. package/dist/client/assets/RoomsPage-zOjjpHdA.js +1 -0
  51. package/dist/client/assets/RunsOnPopover-JTm1cYuw.js +1 -0
  52. package/dist/client/assets/SessionsPage-D4kyvHQf.js +6 -0
  53. package/dist/client/assets/SkillsPage-KYUVzuVa.js +1 -0
  54. package/dist/client/assets/TasksPage-BZapA_v6.js +1 -0
  55. package/dist/client/assets/{ToolsPage-BMW27c-X.js → ToolsPage-CWpHMlrR.js} +2 -2
  56. package/dist/client/assets/{TopologyGraph-u-ihEvQa.js → TopologyGraph-BMcPxZsA.js} +3 -3
  57. package/dist/client/assets/TourHost-VY1-sy1Y.js +1 -0
  58. package/dist/client/assets/UnlinkDialog-3p38G_9q.js +1 -0
  59. package/dist/client/assets/UnreadDivider-KSqqcHKN.js +1 -0
  60. package/dist/client/assets/_shell-DAjwimLg.js +93 -0
  61. package/dist/client/assets/_shell._home-Bp_p1VUv.js +1 -0
  62. package/dist/client/assets/_shell._home.activity-tk-XApvX.js +1 -0
  63. package/dist/client/assets/_shell._home.index-BNVhSN0y.js +3 -0
  64. package/dist/client/assets/_shell._home.tasks-BsBH_4tZ.js +1 -0
  65. package/dist/client/assets/_shell._home.workspaces-DuXnjQh0.js +1 -0
  66. package/dist/client/assets/_shell.channels-DWAHkDPV.js +10 -0
  67. package/dist/client/assets/_shell.connections-DIm3mUHy.js +6 -0
  68. package/dist/client/assets/_shell.feedback-requests-Hjv640j9.js +2 -0
  69. package/dist/client/assets/_shell.marketplace-DF6Y7mc0.js +1 -0
  70. package/dist/client/assets/_shell.marketplace_.sources-Do8cm7kq.js +1 -0
  71. package/dist/client/assets/_shell.session-DlN8iOl-.js +43 -0
  72. package/dist/client/assets/_shell.team-ctLQztjw.js +28 -0
  73. package/dist/client/assets/_shell.x._extensionId-0Q1rJtud.js +1 -0
  74. package/dist/client/assets/_shell.x._extensionId_._-0Q1rJtud.js +1 -0
  75. package/dist/client/assets/agent-attention-Dn__3LQE.js +5 -0
  76. package/dist/client/assets/{agent-browser-Bn5EG403.js → agent-browser-CCN16ZOz.js} +1 -1
  77. package/dist/client/assets/banner-DOm9_4l-.js +6 -0
  78. package/dist/client/assets/composer-insert-BpyATrmR.js +1 -0
  79. package/dist/client/assets/dorkbot-templates-cu4wApxb.js +1 -0
  80. package/dist/client/assets/file-drag-GDx2qhdk.js +1 -0
  81. package/dist/client/assets/file-exclamation-point-BKzL0QhY.js +6 -0
  82. package/dist/client/assets/format-duration-BCr6uzby.js +1 -0
  83. package/dist/client/assets/hand-DLUdsiuR.js +6 -0
  84. package/dist/client/assets/{highlighted-body-KPVGNVTW-CL9x-9e4.js → highlighted-body-KPVGNVTW-DTxMTVdP.js} +1 -1
  85. package/dist/client/assets/hover-card-qzuFUCaR.js +1 -0
  86. package/dist/client/assets/{index-nEOi__50.js → index-3lQkXKcq.js} +1 -1
  87. package/dist/client/assets/{index-CpJvQdyn.js → index-B-z7hA9x.js} +1 -1
  88. package/dist/client/assets/{index-C-wQjAlh.js → index-BIMClIrX.js} +1 -1
  89. package/dist/client/assets/{index-lrzDDn8S.js → index-BMOfHKE0.js} +1 -1
  90. package/dist/client/assets/{index-CK35WFBO.js → index-BPcwoJoz.js} +1 -1
  91. package/dist/client/assets/{index-CsQv_9cY.js → index-BW5ce4t8.js} +1 -1
  92. package/dist/client/assets/{index-C2L0bOg6.js → index-BaB-skF0.js} +3 -3
  93. package/dist/client/assets/{index-DAXybyxB.js → index-Bk98IpMn.js} +1 -1
  94. package/dist/client/assets/{index-62aJQhJd.js → index-C3XnoXTY.js} +1 -1
  95. package/dist/client/assets/{index-tY8nAJmx.js → index-C7B2uRgo.js} +2 -2
  96. package/dist/client/assets/index-C8ZMfyGc.js +1 -0
  97. package/dist/client/assets/{index-BSl_jWtK.js → index-CDTumWMC.js} +1 -1
  98. package/dist/client/assets/{index-DuWGfUC7.js → index-CF9fqPef.js} +5 -5
  99. package/dist/client/assets/{index-DEYZcwYZ.js → index-CIPHHziB.js} +1 -1
  100. package/dist/client/assets/{index-DOVEs6Rq.js → index-CIfwPLXd.js} +1 -1
  101. package/dist/client/assets/{index-DnjFcJhW.js → index-CLhD0Bno.js} +36 -36
  102. package/dist/client/assets/index-CQWqpw_G.js +1 -0
  103. package/dist/client/assets/index-CScfHuKF.js +1 -0
  104. package/dist/client/assets/index-CTXNRyRE.js +1 -0
  105. package/dist/client/assets/{index-C3fr7zOo.js → index-CTai_TxZ.js} +1 -1
  106. package/dist/client/assets/{index-CniKYwdp.js → index-CVl132_4.js} +1 -1
  107. package/dist/client/assets/index-CejezM4U.js +1 -0
  108. package/dist/client/assets/{index-Bc9XDEj8.js → index-CmlaXay_.js} +1 -1
  109. package/dist/client/assets/{index-KIOfBCox.js → index-CtOB9fS3.js} +1 -1
  110. package/dist/client/assets/{index-DyFf2nbN.js → index-D3DXMH4x.js} +1 -1
  111. package/dist/client/assets/index-D5uYwabS.js +1 -0
  112. package/dist/client/assets/{index-CaEda4s3.js → index-DA-i3I4q.js} +1 -1
  113. package/dist/client/assets/index-DFMDv6qR.js +1 -0
  114. package/dist/client/assets/index-DMYBI16t.js +1252 -0
  115. package/dist/client/assets/{index-DzBsotRj.js → index-DOxEmnH2.js} +1 -1
  116. package/dist/client/assets/{index-Dxkj6c9m.js → index-DR1JT9Uz.js} +12 -12
  117. package/dist/client/assets/{index-BO-CpekL.js → index-DT_v3O-B.js} +1 -1
  118. package/dist/client/assets/index-DbbZNAKk.js +5 -0
  119. package/dist/client/assets/{index-BBz-vkiB.js → index-Dcs6e-U_.js} +1 -1
  120. package/dist/client/assets/{index-BE54c4kA.js → index-DgH_dl1a.js} +2 -2
  121. package/dist/client/assets/{index-DPGgujWh.js → index-DgtF-nBt.js} +1 -1
  122. package/dist/client/assets/{index-BlbBz069.js → index-DwzSdOh3.js} +1 -1
  123. package/dist/client/assets/index-IgIVF9T_.js +1 -0
  124. package/dist/client/assets/{index-aFkVVlMJ.js → index-WjW-NUCp.js} +1 -1
  125. package/dist/client/assets/layers-CJHXSEKK.js +6 -0
  126. package/dist/client/assets/lightbulb-DWjxw7lb.js +6 -0
  127. package/dist/client/assets/mention-pill-akMU3IVs.js +1 -0
  128. package/dist/client/assets/message-square-off-DEagHpQY.js +6 -0
  129. package/dist/client/assets/owner-notice-CLsx0s7q.js +1 -0
  130. package/dist/client/assets/page-container-W7byjRmk.js +1 -0
  131. package/dist/client/assets/primer-trigger-DuM9vVnV.js +3 -0
  132. package/dist/client/assets/radio-B8Ozjv9U.js +6 -0
  133. package/dist/client/assets/{room-files-source-BXJ2jlgd.js → room-files-source-Bsc3YA91.js} +2 -2
  134. package/dist/client/assets/rotate-ccw-clock-CNcDcTvq.js +6 -0
  135. package/dist/client/assets/rotate-cw-xvfipJLN.js +6 -0
  136. package/dist/client/assets/scroll-area-C95q3ss7.js +1 -0
  137. package/dist/client/assets/search-x-C6SAxw7a.js +6 -0
  138. package/dist/client/assets/session-strategy-labels-C7Wduch3.js +1 -0
  139. package/dist/client/assets/shield-x-DxOGc0dW.js +6 -0
  140. package/dist/client/assets/{soul-file-11avkxYV.js → soul-file-pg0ShYy3.js} +1 -1
  141. package/dist/client/assets/untrusted-text-1hXdPgLA.js +1 -0
  142. package/dist/client/assets/use-delete-binding-CZVeHqn0.js +1 -0
  143. package/dist/client/assets/use-dev-links-Df2WkCic.js +1 -0
  144. package/dist/client/assets/use-external-adapter-catalog-B0gcY-k7.js +1 -0
  145. package/dist/client/assets/use-full-activity-feed-SYcgdMZu.js +1 -0
  146. package/dist/client/assets/use-is-below-desktop-C5_YenEp.js +1 -0
  147. package/dist/client/assets/use-jump-back-in-DWUPb1gi.js +11 -0
  148. package/dist/client/assets/use-mesh-topology-HLzZIgis.js +1 -0
  149. package/dist/client/assets/use-pending-read-BuJknrxG.js +1 -0
  150. package/dist/client/assets/{use-personality-commit-PCN2Kh8p.js → use-personality-commit-OH7d0xl_.js} +1 -1
  151. package/dist/client/assets/use-promo-activation-BgdGasXE.js +11 -0
  152. package/dist/client/assets/use-pulse-freshness-BlD-dM_g.js +1 -0
  153. package/dist/client/assets/use-rename-session-D3MuyK-F.js +1 -0
  154. package/dist/client/assets/use-room-follow-claim-CyjhzbRJ.js +1 -0
  155. package/dist/client/assets/use-roving-tab-list-Be60AWK3.js +1 -0
  156. package/dist/client/assets/use-session-canvas-Bqs6IQO7.js +64 -0
  157. package/dist/client/assets/use-session-diagnostics-CfKdB2iY.js +16 -0
  158. package/dist/client/assets/use-unclaimed-chats-lqMhotUB.js +1 -0
  159. package/dist/client/index.html +1 -1
  160. package/dist/client/manifest.webmanifest +1 -1
  161. package/dist/drizzle/20261005194144_connector_auth_flow_failure_code.sql +1 -0
  162. package/dist/drizzle/20261005230915_task_run_occurrence.sql +2 -0
  163. package/dist/drizzle/20261006231015_audit_events.sql +63 -0
  164. package/dist/drizzle/20261007230701_private_session_identity.sql +15 -0
  165. package/dist/drizzle/meta/20261005194144_snapshot.json +12238 -0
  166. package/dist/drizzle/meta/20261005230915_snapshot.json +12252 -0
  167. package/dist/drizzle/meta/20261006231015_snapshot.json +12519 -0
  168. package/dist/drizzle/meta/20261007230701_snapshot.json +12611 -0
  169. package/dist/drizzle/meta/_journal.json +28 -0
  170. package/dist/server/index.js +161811 -97213
  171. package/dist/server/index.js.map +2 -2
  172. package/package.json +5 -5
  173. package/dist/client/assets/AdapterIcon-CiK683Vv.js +0 -1
  174. package/dist/client/assets/AppearancePage-CBq2_KUY.js +0 -1
  175. package/dist/client/assets/CanvasFileContent-jV63reY5.js +0 -2
  176. package/dist/client/assets/CanvasModel3dContent-DzvsEWGD.js +0 -2
  177. package/dist/client/assets/ConnectionAccessLists-BWuegEtZ.js +0 -1
  178. package/dist/client/assets/ConventionPage-CYV7X_nF.js +0 -11
  179. package/dist/client/assets/HandlePage-CJpRpaLw.js +0 -1
  180. package/dist/client/assets/NamePage-KoYyo25o.js +0 -1
  181. package/dist/client/assets/PersonalityPopover-CFRYfO5E.js +0 -1
  182. package/dist/client/assets/PhotoPage-DkGyFlWQ.js +0 -1
  183. package/dist/client/assets/RoomsPage-ClT030eV.js +0 -1
  184. package/dist/client/assets/RunsOnPopover-CNCO9sZk.js +0 -1
  185. package/dist/client/assets/SessionsPage-5xEcQImi.js +0 -6
  186. package/dist/client/assets/SkillsPage-ic4TDV4I.js +0 -1
  187. package/dist/client/assets/TasksPage-C_GFpRgB.js +0 -1
  188. package/dist/client/assets/index-6COO_Ljw.js +0 -1
  189. package/dist/client/assets/index-BKl9b2dT.js +0 -1
  190. package/dist/client/assets/index-BVtk6Sb_.js +0 -1
  191. package/dist/client/assets/index-Bxrxl2HH.js +0 -1
  192. package/dist/client/assets/index-C6uVMs3w.js +0 -1
  193. package/dist/client/assets/index-DEvFAO8t.js +0 -1
  194. package/dist/client/assets/index-DpSk7iO1.js +0 -1680
@@ -0,0 +1 @@
1
+ import{Q as h,ad as E,r as T,bh as p,ah as a,bi as y,bj as m,bk as A}from"./index-DMYBI16t.js";import{A as D}from"./use-full-activity-feed-SYcgdMZu.js";const f=15,g=["dashboard-activity"],k=["Today","Yesterday","This week","Earlier"];function w(d){const s=new Date,e=new Date(s);e.setHours(0,0,0,0);const _=new Date(e);_.setDate(_.getDate()-1);const o=new Date(e);o.setDate(o.getDate()-o.getDay());const l=new Map;for(const n of d){const c=new Date(n.occurredAt);let i;c>=e?i="Today":c>=_?i="Yesterday":c>=o?i="This week":i="Earlier";const u=l.get(i)??[];u.push(n),l.set(i,u)}return k.filter(n=>l.has(n)).map(n=>({label:n,items:l.get(n)}))}function b(){const d=h(),{data:s,isLoading:e}=E({queryKey:g,queryFn:()=>d.listActivityEvents({limit:f}),staleTime:3e4,refetchOnWindowFocus:!0});return{groups:T.useMemo(()=>w((s==null?void 0:s.items)??[]),[s==null?void 0:s.items]),hasMore:(s==null?void 0:s.nextCursor)!=null,isLoading:e}}const r=[g,D],t={relay_message:r,relay_flow:r,relay_adapters_changed:r,relay_bindings_changed:r,extension_reloaded:r,task_run_failed:[...r,y],task_run_updated:[y],relay_dead_letter:[m],mesh_liveness_changed:[A],tasks_changed:r},I=1200;function v(d=I){const s=p({coalesceMs:d}),e=_=>s(_.map(o=>({queryKey:o})));a("relay_message",()=>e(t.relay_message)),a("relay_flow",()=>e(t.relay_flow)),a("relay_adapters_changed",()=>e(t.relay_adapters_changed)),a("relay_bindings_changed",()=>e(t.relay_bindings_changed)),a("extension_reloaded",()=>e(t.extension_reloaded)),a("task_run_failed",()=>e(t.task_run_failed)),a("task_run_updated",()=>e(t.task_run_updated)),a("relay_dead_letter",()=>e(t.relay_dead_letter)),a("mesh_liveness_changed",()=>e(t.mesh_liveness_changed)),a("tasks_changed",()=>e(t.tasks_changed))}export{v as a,b as u};
@@ -0,0 +1 @@
1
+ import{Q as h,R as d,T as p,U as Q,V as i,W as f}from"./index-DMYBI16t.js";function S(r){const m=h(),t=d(),{ownResolvedAccount:c,nameFor:v}=p();return Q({mutationFn:({sessionId:a,title:o})=>m.updateSession(a,{title:o},r??void 0),onMutate:async({sessionId:a,title:o})=>{var y;await t.cancelQueries({queryKey:i.listRoot});const s=t.getQueryData(i.list(r)),e=(y=s==null?void 0:s.find(u=>u.id===a))==null?void 0:y.account,n=e===void 0||c!==void 0&&e===c;return n&&t.setQueryData(i.list(r),u=>u==null?void 0:u.map(l=>l.id===a?{...l,title:o}:l)),{previous:s,account:e,showsInList:n}},onSuccess:(a,o,s)=>{const e=s==null?void 0:s.account;if(!e||s!=null&&s.showsInList)return;const n=v(e);f.success(`Renamed on ${n}`,{description:c?"Shows once you switch to that account.":`Shows while ${n} is the active account.`})},onError:(a,o,s)=>{s!=null&&s.previous&&t.setQueryData(i.list(r),s.previous)},onSettled:()=>{t.invalidateQueries({queryKey:i.listRoot})},meta:{errorLabel:"Couldn’t rename that session"}})}export{S as u};
@@ -0,0 +1 @@
1
+ import{ax as a,r,Q as p,ay as E,az as F}from"./index-DMYBI16t.js";function g(e){const n=a(l=>l.forgetRoom);r.useEffect(()=>{if(e!==null)return()=>n(e)},[e,n])}function L(e){const n=p(),l=a(t=>{var o;return e?((o=t.intent[e])==null?void 0:o.leaderId)??null:null}),u=a(t=>t.startFollowing),s=a(t=>t.stopFollowing),c=a(t=>t.sweep),f=r.useCallback(t=>{e&&u(e,t)},[e,u]),w=r.useCallback(()=>{e&&s(e)},[e,s]);return r.useEffect(()=>{const t=setInterval(()=>c(),E);return()=>clearInterval(t)},[c]),r.useEffect(()=>{if(!e||l===null)return;let t=!0;const o=()=>{n.followRoomMember(e,l).catch(()=>{t&&s(e)})};o();const v=setInterval(o,F),i=()=>s(e);return window.addEventListener("blur",i),window.addEventListener("pagehide",i),()=>{t=!1,clearInterval(v),window.removeEventListener("blur",i),window.removeEventListener("pagehide",i),n.unfollowRoomMember(e).catch(()=>{})}},[n,e,l,s]),{following:l,follow:f,stop:w}}export{g as a,L as u};
@@ -0,0 +1 @@
1
+ import{r as p}from"./index-DMYBI16t.js";function x({orderedIds:n,activeId:l,onActivate:a,onClose:f,getFallbackFocus:s}){const o=p.useRef(new Map),k=l&&n.includes(l)?l:n[0]??null,c=p.useCallback(e=>{var b;e&&((b=o.current.get(e))==null||b.focus())},[]),u=p.useCallback(e=>{a(e,"keyboard"),c(e)},[a,c]);return{getTabProps:p.useCallback(e=>({ref:t=>{t?o.current.set(e,t):o.current.delete(e)},tabIndex:e===k?0:-1,onClick:()=>a(e,"pointer"),onKeyDown:t=>{var i;const r=n.indexOf(e);if(r===-1)return;const D=n.length-1;switch(t.key){case"ArrowRight":t.preventDefault(),u(n[r===D?0:r+1]);break;case"ArrowLeft":t.preventDefault(),u(n[r===0?D:r-1]);break;case"Home":t.preventDefault(),u(n[0]);break;case"End":t.preventDefault(),u(n[D]);break;case"Delete":{if(!f)return;t.preventDefault();const w=n[r+1]??n[r-1]??null;f(e,"keyboard"),w?c(w):(i=s==null?void 0:s())==null||i.focus();break}}},...f?{"aria-keyshortcuts":"Delete"}:{}}),[n,k,a,f,s,u,c])}}export{x as u};
@@ -0,0 +1,64 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/BlintzCanvas-CXi0fvcM.js","assets/index-DMYBI16t.js","assets/index-Dgp1LmEk.css","assets/index-DR1JT9Uz.js","assets/BlintzCanvas-GgiCXV7C.css","assets/CanvasFileContent-ZZhdofR4.js","assets/rotate-cw-xvfipJLN.js","assets/McpAppFrame-B1ThSf2U.js","assets/CanvasModel3dContent-DMMMZh4o.js","assets/CanvasCsvContent-QhDSf8Pd.js","assets/index-CejezM4U.js"])))=>i.map(i=>d[i]);
2
+ var Hn=Object.defineProperty;var vr=e=>{throw TypeError(e)};var Un=(e,r,t)=>r in e?Hn(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var ee=(e,r,t)=>Un(e,typeof r!="symbol"?r+"":r,t),Zn=(e,r,t)=>r.has(e)||vr("Cannot "+t);var gr=(e,r,t)=>r.has(e)?vr("Cannot add the same private member more than once"):r instanceof WeakSet?r.add(e):r.set(e,t);var xe=(e,r,t)=>(Zn(e,r,"access private method"),t);import{Y as St,m2 as Pt,z as ie,J as Q,G as br,D as Ge,F as et,m3 as Vn,m4 as Gn,m5 as $n,aH as je,Q as pe,r as g,bN as Kt,m6 as Jn,aD as K,i3 as Qn,j as h,gw as Kn,gx as In,es as ei,aa as It,I as ti,f9 as ri,B as mt,aF as qr,aG as Hr,C as ni,i7 as kt,m7 as ii,m8 as oi,m9 as ai,ma as si,mb as Ur,mc as Wt,md as gt,me as Zr,_ as wr,mf as li,A as yr,mg as ui,mh as ci,mi as te,mj as di,mk as Cr}from"./index-DMYBI16t.js";import{R as fi}from"./rotate-cw-xvfipJLN.js";import{M as pi}from"./McpAppFrame-B1ThSf2U.js";/**
3
+ * @license lucide-react v1.48.0 - ISC
4
+ *
5
+ * This source code is licensed under the ISC license.
6
+ * See the LICENSE file in the root directory of this source tree.
7
+ */const Vr={name:"file-code",size:24,node:[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]]};Vr.node;const wl=St(Vr);/**
8
+ * @license lucide-react v1.48.0 - ISC
9
+ *
10
+ * This source code is licensed under the ISC license.
11
+ * See the LICENSE file in the root directory of this source tree.
12
+ */const Gr={name:"maximize",size:24,node:[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]};Gr.node;const hi=St(Gr);/**
13
+ * @license lucide-react v1.48.0 - ISC
14
+ *
15
+ * This source code is licensed under the ISC license.
16
+ * See the LICENSE file in the root directory of this source tree.
17
+ */const $r={name:"zoom-in",size:24,node:[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]};$r.node;const mi=St($r);/**
18
+ * @license lucide-react v1.48.0 - ISC
19
+ *
20
+ * This source code is licensed under the ISC license.
21
+ * See the LICENSE file in the root directory of this source tree.
22
+ */const Jr={name:"zoom-out",size:24,node:[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]};Jr.node;const vi=St(Jr),ze={pending:64,queueBytes:1048576,batchMs:300,frames:62,imageChars:9e5,imageEdge:1568,resourceErrors:1e4},bt=et().min(1).max(128),Le={bridgeGeneration:bt},gi=ie({...Le,__dorkosDevtools:Q("capture-result"),requestId:bt,dataUrl:et().max(9e5).optional(),error:et().max(2048).optional()}),bi=Vn.omit({hostOutcome:!0}).extend({...Le,__dorkosDevtools:Q("act-result"),dataUrl:et().max(9e5).optional()}),wi=Gn.extend({status:Ge().int().min(0).max(599),durationMs:Ge().min(0),responseSize:Ge().int().min(0).max(Number.MAX_SAFE_INTEGER).optional(),timestamp:Ge().min(0)}),yi=$n.refine(e=>e.timestamp>=0),Ci=Pt("__dorkosDevtools",[ie({__dorkosDevtools:Q("hello"),pageInstanceId:bt,bridgeVersion:Q(2)}),ie({...Le,__dorkosDevtools:Q("ready"),pageInstanceId:bt}),ie({...Le,__dorkosDevtools:Q("navigated")}),ie({...Le,__dorkosDevtools:Q("resource-error")}),ie({...Le,__dorkosDevtools:Q("batch"),seq:Ge().int().min(0).max(Number.MAX_SAFE_INTEGER),console:br(yi).max(500),network:br(wi).max(200)}),gi,bi]);function Si(e){const r=new Set;let t=0,n=0;const i=s=>(n+=s)<=16384;function o(s){if(!i(2))return!1;for(let l=0;l<s.length;l++){const c=s.charCodeAt(l);if(c>=55296&&c<=56319&&l+1<s.length&&s.charCodeAt(l+1)>=56320&&s.charCodeAt(l+1)<=57343){if(!i(2))return!1;l++;continue}const u=c===34||c===92||[8,9,10,12,13].includes(c)?2:c<32||c>=55296&&c<=57343?6:1;if(!i(u))return!1}return!0}function a(s,l){if(++t>2048||l>8)return!1;if(s===null)return i(4);if(typeof s=="boolean")return i(s?4:5);if(typeof s=="string")return o(s);if(typeof s=="number")return Number.isFinite(s)&&i(String(s).length);if(typeof s!="object"||r.has(s))return!1;const c=Object.getPrototypeOf(s);if(c!==Object.prototype&&c!==null&&c!==Array.prototype)return!1;const u=Array.isArray(s);if(u&&s.length>2048||Object.getOwnPropertySymbols(s).length||!i(2))return!1;r.add(s);let d=0;for(const f in s){if(!Object.prototype.hasOwnProperty.call(s,f))continue;if(++d>2048||u&&(!/^\d+$/.test(f)||Number(f)>=s.length))return!1;const p=Object.getOwnPropertyDescriptor(s,f);if(["__proto__","constructor","prototype"].includes(f)||!("value"in p)||!p.enumerable||d>1&&!i(1)||!u&&(!o(f)||!i(1))||!a(p.value,l+1))return!1}return r.delete(s),!u||d===s.length}try{return a(e,0)}catch{return!1}}function Pi(e){try{if(!e||typeof e!="object")return null;const r=e;if(r.__dorkosDevtools==="capture-result"&&r.dataUrl===void 0&&r.error===void 0)return null;if(r.__dorkosDevtools==="batch"){if(!Array.isArray(r.console)||r.console.length>500||!Array.isArray(r.network)||r.network.length>200)return null;for(const i of r.console){if(!i||typeof i!="object")return null;const o=i.args;if(o!==void 0&&(!Array.isArray(o)||o.length>50||!Si(o)))return null}}const t=Ci.safeParse(e);if(!t.success)return null;const n=t.data;return"dataUrl"in n&&n.dataUrl!==void 0&&!Qr(n.dataUrl)?null:n}catch{return null}}function Qr(e){if(e.length>9e5||!/^data:image\/png;base64,[A-Za-z0-9+/]+={0,2}$/.test(e))return null;try{const r=atob(e.slice(e.indexOf(",")+1));if(r.length<24||r.slice(0,8)!==`‰PNG\r
23
+ 
24
+ `||r.slice(12,16)!=="IHDR")return null;const t=o=>r.charCodeAt(o)*2**24+(r.charCodeAt(o+1)<<16)+(r.charCodeAt(o+2)<<8)+r.charCodeAt(o+3),n=t(16),i=t(20);return n>0&&i>0&&n<=1568&&i<=1568?{width:n,height:i}:null}catch{return null}}let jt=null;async function Sr(){return jt===null&&(jt=(await je(()=>import("./html-to-image-cl8bZGTj.js"),[])).default),jt}let At=null;async function ki(){if(At===null){const e=await je(()=>import("./gifenc.esm-sOOlYEo8.js"),[]);At={GIFEncoder:e.GIFEncoder,quantize:e.quantize,applyPalette:e.applyPalette}}return At}async function Pr(e,r,t=()=>{}){if(e.length===0)return{ok:!1,error:"The recording has no frames in it."};t();const{GIFEncoder:n,quantize:i,applyPalette:o}=await ki();t();const a=e[0],s=e[e.length-1],l=new Uint8ClampedArray(a.data.length+s.data.length);l.set(a.data,0),l.set(s.data,a.data.length);const c=i(l,256),u=n();for(let f=0;f<e.length;f++){t();const p=e[f];if(u.writeFrame(o(p.data,c),p.width,p.height,{...f===0?{palette:c,repeat:0}:{},delay:r.frameMs}),u.bytesView().byteLength>r.maxBytes)return{ok:!1,error:`The recording came out bigger than ${Math.round(r.maxBytes/1024/1024)} MB, so it was not saved.`}}u.finish();const d=u.bytes();return d.byteLength>r.maxBytes?{ok:!1,error:`The recording came out bigger than ${Math.round(r.maxBytes/1024/1024)} MB, so it was not saved.`}:{ok:!0,bytes:d}}async function Ei(e,r,t=()=>{}){const n=[],i=document.createElement("canvas");let o=0,a=0;try{for(let s=0;s<Math.min(e.length,62);s++){t();const l=e[s];if(!Qr(l)){e[s]="";continue}const c=await Oi(l);e[s]="";try{if(t(),!c)continue;if(!o){const f=Math.min(1,Math.min(800,r)/Math.max(c.width,c.height,1));o=Math.max(1,Math.round(c.width*f)),a=Math.max(1,Math.round(c.height*f)),i.width=o,i.height=a}const u=i.getContext("2d",{willReadFrequently:!0});if(!u)return[];u.fillStyle="#ffffff",u.fillRect(0,0,o,a);const d=Math.min(o/c.width,a/c.height);u.drawImage(c,0,0,Math.round(c.width*d),Math.round(c.height*d)),t(),n.push({data:u.getImageData(0,0,o,a).data,width:o,height:a})}finally{c&&(c.src="")}}return n}catch(s){throw n.length=0,s}finally{e.length=0,i.width=0,i.height=0}}function Ti(e,r=()=>{}){const t=document.createElement("canvas"),n=document.createElement("canvas");try{for(let i=0;i<e.length;i++){r();const o=e[i];n.width=o.width,n.height=o.height,t.width=Math.max(1,Math.round(o.width/2)),t.height=Math.max(1,Math.round(o.height/2));const a=n.getContext("2d"),s=t.getContext("2d",{willReadFrequently:!0});if(!a||!s)throw new Error("Canvas pixels are unavailable");a.putImageData(new ImageData(new Uint8ClampedArray(o.data),o.width,o.height),0,0),s.drawImage(n,0,0,t.width,t.height),e[i]={data:s.getImageData(0,0,t.width,t.height).data,width:t.width,height:t.height}}}finally{n.width=n.height=t.width=t.height=0}}function Oi(e){return new Promise(r=>{const t=new Image;t.onload=()=>{t.onload=t.onerror=null,r(t)},t.onerror=()=>{t.onload=t.onerror=null,t.src="",r(null)},t.src=e})}function kr(e,r,t){const n=t.slice().buffer;return{name:e,type:r,size:t.byteLength,arrayBuffer:async()=>n}}function _i(e){const r=atob(e.slice(e.indexOf(",")+1));return Uint8Array.from(r,t=>t.charCodeAt(0))}const ji=8e3;function Ai(e){const r=pe(),t=g.useRef(r);g.useLayoutEffect(()=>{t.current=r});const[n]=Kt(),[i,o]=g.useState(0),a=g.useRef(null),s=g.useRef(new Map),l=g.useRef(null),c=g.useRef({console:[],network:[],entryBytes:0,overheadBytes:0}),u=g.useRef(null),d=g.useRef(-1),f=g.useRef(null),p=g.useRef(null),v=g.useRef(!1),m=g.useRef(-1/0),P=g.useRef(!1),w=g.useRef(null),A=g.useRef(0),C=g.useRef(null),O=g.useRef(null),z=g.useRef(!1),Y=g.useRef(null),N=g.useRef({...e,sessionId:n}),M=g.useRef(Promise.resolve()),W=g.useRef(()=>{}),q=g.useRef({initialize:R,retire:E,consume:we,register:se,eligiblePending:le,refuseRequest:G,live:Z,captureFrame:He,valid:Be,reportRecordingStart:Xe,cancelReservation:We,finish:ct});g.useLayoutEffect(()=>{q.current={initialize:R,retire:E,consume:we,register:se,eligiblePending:le,refuseRequest:G,live:Z,captureFrame:He,valid:Be,reportRecordingStart:Xe,cancelReservation:We,finish:ct}});const B=k=>Y.current===k||K.getState().openDocuments.some(b=>b.id===k&&b.openedHere);function y(k,{active:b,activation:T=!1,keepalive:S=!1,reset:x=!1}){if(!k.sessionId)return;const $={documentId:k.documentId,logicalUrl:k.logicalUrl,bridgeGeneration:k.generation,seq:Math.max(0,d.current),console:[],network:[],active:b,activation:T,instrumented:k.ready&&!k.retired,...x?{reset:!0}:{}};M.current=M.current.then(()=>t.current.ingestDevtoolsCapture(k.sessionId,$,S?{keepalive:!0}:void 0)).catch(()=>{})}function E(){var T;const k=a.current;k&&(k.retired=!0),a.current=null,u.current!==null&&clearTimeout(u.current),u.current=null,l.current=null,c.current={console:[],network:[],entryBytes:0,overheadBytes:0},d.current=-1,m.current=-1/0,P.current=!1;for(const[S,x]of s.current)x.life.sessionId&&x.deadline>Date.now()&&x.kind!=="frame"&&G(S,x.kind,x.life,"The frame changed while this request was pending."),clearTimeout(x.timer),(T=x.resolve)==null||T.call(x,null);s.current.clear(),k&&y(k,{active:!1});const b=w.current;b&&(clearTimeout(b.reservationTimer),b.cancelled=!0,b.abort.abort(),b.frames.length=0,b.finishing||(b.drawn.length=0,w.current=null)),C.current!==null&&cancelAnimationFrame(C.current),C.current=null,A.current=0,o(0)}function R({loadActivation:k,reset:b=!1}={}){var H,ne;const T=N.current,S=(H=T.iframeRef.current)==null?void 0:H.contentWindow;if(v.current||!S||!T.bridgeEligibility||!T.resolvedSource)return;const x={generation:crypto.randomUUID(),frame:S,sessionId:T.sessionId,documentId:T.documentId,logicalUrl:T.logicalUrl,source:T.resolvedSource,origin:T.bridgeEligibility==="served-document"?"null":T.previewOrigin,ready:!1,activation:!1,retired:!1};a.current=x;const $=k??(z.current||O.current!==x.documentId&&B(x.documentId));x.activation=$,z.current=!1,O.current=x.documentId,y(x,{active:!0,activation:$,reset:b}),((ne=f.current)==null?void 0:ne.frame)===S&&f.current.source===T.resolvedSource&&f.current.reload===T.reloadNonce&&f.current.documentId===T.documentId&&f.current.logicalUrl===T.logicalUrl&&S.postMessage({__dorkosDevtools:"init",bridgeGeneration:x.generation},"*")}g.useLayoutEffect(()=>{var S;N.current={...e,sessionId:n};const k={frame:(S=e.iframeRef.current)==null?void 0:S.contentWindow,sessionId:n,documentId:e.documentId,logicalUrl:e.logicalUrl,source:e.resolvedSource,eligibility:e.bridgeEligibility,origin:e.previewOrigin,reload:e.reloadNonce},b=p.current;if(!b||Object.keys(k).some(x=>k[x]!==b[x])){const x=!b||b.frame!==k.frame||b.documentId!==k.documentId||b.logicalUrl!==k.logicalUrl||b.source!==k.source||b.reload!==k.reload;p.current=k,v.current=!1,E(),R({reset:x})}});const _=g.useCallback(()=>{var $,H,ne;const{initialize:k,retire:b}=q.current,T=N.current,S=($=T.iframeRef.current)==null?void 0:$.contentWindow,x=(H=a.current)!=null&&H.ready?!1:(ne=a.current)==null?void 0:ne.activation;S&&T.resolvedSource&&(f.current={frame:S,source:T.resolvedSource,reload:T.reloadNonce,documentId:T.documentId,logicalUrl:T.logicalUrl}),v.current=!1,b(),k({loadActivation:x,reset:!0})},[]),D=g.useCallback(()=>{const k=a.current;z.current=!0,Y.current=N.current.documentId,k&&W.current({active:!0,activation:!0})},[]);g.useLayoutEffect(()=>{W.current=k=>{a.current&&y(a.current,k)}});function Z(k){return a.current===k&&!k.retired}function G(k,b,T,S){if(!T.sessionId)return;const x={requestId:k,bridgeGeneration:T.generation,documentId:T.documentId,hostOutcome:"host",error:S};b==="action"?t.current.postDevtoolsAction(T.sessionId,{...x,ok:!1}).catch(()=>{}):t.current.ingestDevtoolsCapture(T.sessionId,{...x,logicalUrl:T.logicalUrl,seq:Math.max(0,d.current),console:[],network:[],screenshot:{requestId:k,error:S}}).catch(()=>{})}function se(k,b,T,{capture:S=!1,resolve:x,timeoutMs:$=8e3}={}){if(s.current.size>=ze.pending||s.current.has(k))return null;const H=setTimeout(()=>me(k,ne),$),ne={kind:b,life:T,capture:S,deadline:Date.now()+$,timer:H,resolve:x};return s.current.set(k,ne),ne}function me(k,b){var T;s.current.get(k)===b&&(s.current.delete(k),clearTimeout(b.timer),(T=b.resolve)==null||T.call(b,null))}function le(k,b,T){return s.current.get(k)!==b||b.life!==T||!Z(T)?!1:Date.now()>=b.deadline?(me(k,b),!1):!0}function we(k,b,T){const S=s.current.get(k);return!S||S.life!==T||S.kind!==b&&!(b==="capture"&&S.kind==="frame")||!le(k,S,T)?null:(s.current.delete(k),clearTimeout(S.timer),S)}g.useEffect(()=>{const{initialize:k,retire:b,consume:T}=q.current;function S(){u.current=null;const he=l.current;l.current=null,c.current={console:[],network:[],entryBytes:0,overheadBytes:0};const j=a.current;he&&j&&!j.retired&&j.sessionId&&he.bridgeGeneration===j.generation&&t.current.ingestDevtoolsCapture(j.sessionId,he)}function x(he){var cr,dr,fr,pr;const j=a.current;if(!j||j.retired||he.source!==j.frame||he.origin!==j.origin||((cr=f.current)==null?void 0:cr.frame)!==j.frame||f.current.source!==j.source||f.current.reload!==N.current.reloadNonce||f.current.documentId!==j.documentId||f.current.logicalUrl!==j.logicalUrl)return;const X=he.data;if(!X||typeof X!="object"||typeof X.__dorkosDevtools!="string"||!["hello","ready","navigated","resource-error","batch","capture-result","act-result"].includes(X.__dorkosDevtools)||X.__dorkosDevtools!=="hello"&&X.bridgeGeneration!==j.generation)return;const oe=X.__dorkosDevtools==="batch";if(oe){if(!j.ready||!j.sessionId||X.bridgeGeneration!==j.generation||!Number.isSafeInteger(X.seq)||X.seq<0||X.seq<=d.current)return;const V=Date.now();if(V-m.current<ze.batchMs){l.current?l.current.dropped=!0:P.current=!0;return}m.current=V}const U=Pi(X);if(!U){oe&&(P.current=!0);return}if(U.__dorkosDevtools==="hello"){j.frame.postMessage({__dorkosDevtools:"init",bridgeGeneration:j.generation},"*");return}if(U.bridgeGeneration!==j.generation)return;if(U.__dorkosDevtools==="ready"){j.ready||(j.ready=!0,j.activation=!1,y(j,{active:!0}));return}if(!j.ready)return;if(U.__dorkosDevtools==="navigated"){v.current=!0,b();return}if(U.__dorkosDevtools==="resource-error"){A.current=Math.min(ze.resourceErrors,A.current+1),C.current===null&&(C.current=requestAnimationFrame(()=>{C.current=null,Z(j)&&o(A.current)}));return}if(!j.sessionId)return;if(U.__dorkosDevtools==="batch"){if(U.seq<=d.current)return;d.current=U.seq;const V=l.current??{documentId:j.documentId,logicalUrl:j.logicalUrl,bridgeGeneration:j.generation,seq:U.seq,console:[],network:[]};V.seq=U.seq,P.current&&(V.dropped=!0),P.current=!1;const ke=c.current,hr=new TextEncoder;if(l.current||(ke.overheadBytes=hr.encode(JSON.stringify({...V,seq:Number.MAX_SAFE_INTEGER,dropped:!0,console:[],network:[]})).length),ke.overheadBytes>ze.queueBytes){l.current=null,c.current={console:[],network:[],entryBytes:0,overheadBytes:0},P.current=!0;return}for(const[Ze,Fn]of[["console",U.console],["network",U.network]])for(const qn of Fn){const mr=hr.encode(JSON.stringify(qn)).length;ke[Ze].push(mr),ke.entryBytes+=mr}V.console.push(...U.console),V.network.push(...U.network);const Ln=()=>ke.overheadBytes+ke.entryBytes+Math.max(0,V.console.length-1)+Math.max(0,V.network.length-1);for(;V.console.length>500||V.network.length>200||Ln()>ze.queueBytes;){V.dropped=!0;const Ze=(((dr=V.console[0])==null?void 0:dr.timestamp)??1/0)<=(((fr=V.network[0])==null?void 0:fr.timestamp)??1/0)?"console":"network";if(!V[Ze].length)break;V[Ze].shift(),ke.entryBytes-=ke[Ze].shift()}l.current=V,u.current===null&&(u.current=setTimeout(S,ze.batchMs));return}if(U.__dorkosDevtools==="capture-result"){const V=T(U.requestId,"capture",j);if(!V)return;if(V.kind==="frame"){(pr=V.resolve)==null||pr.call(V,U.dataUrl??null);return}t.current.ingestDevtoolsCapture(j.sessionId,{bridgeGeneration:j.generation,documentId:j.documentId,logicalUrl:j.logicalUrl,seq:Math.max(0,d.current),console:[],network:[],hostOutcome:"page-reported",screenshot:{requestId:U.requestId,dataUrl:U.dataUrl,error:U.error}});return}const Ue=T(U.requestId,"action",j);if(!Ue)return;const Re=w.current,ur=Ue.capture&&U.dataUrl!==void 0&&Re!==null&&Re.life===j&&Re.activated&&!Re.finishing&&!Re.cancelled&&Re.frames.length<61;ur&&Re.frames.push(U.dataUrl);const{__dorkosDevtools:pl,dataUrl:hl,...Bn}=U;t.current.postDevtoolsAction(j.sessionId,{...Bn,hostOutcome:"page-reported",documentId:j.documentId,captured:ur||void 0})}window.addEventListener("message",x);const $=setInterval(()=>W.current({active:!0}),15e3),H=()=>{a.current||k(),W.current({active:!0,activation:!0})},ne=()=>{W.current({active:!1,keepalive:!0}),b()},ae=()=>{document.visibilityState==="visible"&&H()};return window.addEventListener("focus",H),window.addEventListener("pagehide",ne),window.addEventListener("pageshow",H),document.addEventListener("visibilitychange",ae),()=>{window.removeEventListener("message",x),clearInterval($),window.removeEventListener("focus",H),window.removeEventListener("pagehide",ne),window.removeEventListener("pageshow",H),document.removeEventListener("visibilitychange",ae),b()}},[]),g.useEffect(()=>Jn.subscribeSessionEvent((k,b)=>{if(b.type!=="devtools_capture_request"&&b.type!=="devtools_action_request"&&b.type!=="devtools_recording_request")return;const{register:T,eligiblePending:S,refuseRequest:x,captureFrame:$,valid:H,finish:ne,reportRecordingStart:ae,cancelReservation:he}=q.current,j=a.current;if(!(!(j!=null&&j.ready)||!j.sessionId||j.retired||b.targetClientId!==t.current.clientId||b.documentId!==j.documentId||b.bridgeGeneration!==j.generation)){if(b.type==="devtools_capture_request"||b.type==="devtools_action_request"){const X=b.type==="devtools_action_request",oe=T(b.requestId,X?"action":"capture",j,{capture:X&&!!b.capture,timeoutMs:X&&b.command.action==="wait_for"?Math.min(1e4,b.command.timeoutMs)+2e3:8e3});if(!oe){s.current.has(b.requestId)||x(b.requestId,X?"action":"capture",j,"Too many browser requests are waiting. Try again when one finishes.");return}const U=Ue=>{S(b.requestId,oe,j)&&j.frame.postMessage(X?{__dorkosDevtools:"act-request",bridgeGeneration:j.generation,requestId:b.requestId,documentId:j.documentId,command:b.command,...b.capture?{capture:!0,lib:Ue}:{}}:{__dorkosDevtools:"capture-request",bridgeGeneration:j.generation,requestId:b.requestId,lib:Ue},"*")};!X||b.capture?Sr().then(U,()=>U()):U()}if(b.type==="devtools_recording_request"){if(b.action==="cancel-start"){he(b.recordingId,b.requestId,j);return}if(b.action==="confirm-start"){const X=w.current;if(!X||X.id!==b.recordingId||X.startRequestId!==b.requestId||X.life!==j||X.finishing||!H(X))return;if(!X.activated){if(performance.now()>=X.reservationDeadline){he(X.id,X.startRequestId,j),ae(b,j,{phase:"started",ok:!1,error:"This recording reservation expired before capture could start."});return}clearTimeout(X.reservationTimer),X.activated=!0,X.startedAt=Date.now(),$(j).then(oe=>{oe&&H(X)&&X.frames.push(oe)})}ae(b,j,{phase:"started",ok:!0});return}if(b.action==="start"){const X=b.reservationTimeoutMs;if(!Number.isSafeInteger(X)||!X||X<1||X>ji){ae(b,j,{phase:"reserved",ok:!1,error:"This recording request has no valid reservation timeout."});return}if(w.current){ae(b,j,{phase:"reserved",ok:!1,error:"Another recording in this window is still running or being saved. Wait for it to finish, then start again."});return}const oe={id:b.recordingId,startRequestId:b.requestId,activated:!1,reservationDeadline:performance.now()+X,life:j,startedAt:Date.now(),frames:[],drawn:[],finishing:!1,cancelled:!1,abort:new AbortController};w.current=oe,oe.reservationTimer=setTimeout(()=>{w.current===oe&&!oe.activated&&he(oe.id,oe.startRequestId,j)},X),ae(b,j,{phase:"reserved",ok:!0})}else ne(b.requestId,b.recordingId,j)}}}),[]);function Xe(k,b,T){!Z(b)||!b.sessionId||t.current.ingestDevtoolsCapture(b.sessionId,{hostOutcome:"host",documentId:b.documentId,bridgeGeneration:b.generation,seq:0,console:[],network:[],recordingStart:{...T,requestId:k.requestId,recordingId:k.recordingId}}).catch(()=>{})}function We(k,b,T){var x;const S=w.current;if(!(!S||S.id!==k||S.startRequestId!==b||S.life!==T||S.finishing)){clearTimeout(S.reservationTimer),S.cancelled=!0,S.abort.abort(),S.frames.length=0,S.drawn.length=0;for(const[$,H]of s.current)H.life===T&&H.kind==="frame"&&(clearTimeout(H.timer),(x=H.resolve)==null||x.call(H,null),s.current.delete($));w.current=null}}function Be(k){return w.current===k&&!k.cancelled&&Z(k.life)}function He(k){const b=`frame-${crypto.randomUUID()}`;return new Promise(T=>{const S=se(b,"frame",k,{resolve:T});if(!S){T(null);return}Sr().then(x=>{le(b,S,k)&&k.frame.postMessage({__dorkosDevtools:"capture-request",bridgeGeneration:k.generation,requestId:b,lib:x},"*")},()=>{me(b,S)})})}async function ct(k,b,T){const S=w.current;if(!S||!S.activated||S.id!==b||S.life!==T){Z(T)&&await t.current.uploadDevtoolsRecording(T.sessionId,{requestId:k,bridgeGeneration:T.generation,documentId:T.documentId,hostOutcome:"host",error:"The window showing that page stopped recording before it could be saved."}).catch(()=>{});return}if(S.finishing)return;S.finishing=!0;const x=()=>{if(!Be(S))throw new Error("retired")},$={requestId:k,bridgeGeneration:T.generation,documentId:T.documentId};try{const H=await He(T);x(),H&&S.frames.length<ze.frames&&S.frames.push(H);const ne=S.frames.length?_i(S.frames[S.frames.length-1]):new Uint8Array;S.drawn=await Ei(S.frames,800,x),x();let ae=await Pr(S.drawn,{frameMs:500,maxBytes:8*1024*1024},x);if(x(),!ae.ok&&S.drawn.length&&(Ti(S.drawn,x),ae=await Pr(S.drawn,{frameMs:500,maxBytes:8*1024*1024},x),x()),!ae.ok){await t.current.uploadDevtoolsRecording(T.sessionId,{...$,hostOutcome:"host",error:ae.error},{signal:S.abort.signal}),x();return}x(),await t.current.uploadDevtoolsRecording(T.sessionId,{...$,frames:S.drawn.length,durationMs:Date.now()-S.startedAt,recording:kr(`${b}.gif`,"image/gif",ae.bytes),keyframe:kr(`${b}.png`,"image/png",ne)},{signal:S.abort.signal}),x()}catch{Be(S)&&await t.current.uploadDevtoolsRecording(T.sessionId,{...$,hostOutcome:"host",error:"This window could not turn that recording into a file."},{signal:S.abort.signal}).catch(()=>{})}finally{S.frames.length=0,S.drawn.length=0,w.current===S&&(w.current=null)}}return{resourceErrorCount:i,notePersonNavigated:D,noteFrameLoaded:_}}const Ri=15e3;function xi(e){const r=e instanceof Error?e.message.trim():"";return r.length>0?r:"Couldn’t reach DorkOS. Check your network and try again."}function zi(e){const r=pe();return{open:g.useCallback(async t=>{await r.openRoomCanvasDocument(e,t)},[r,e]),update:g.useCallback(async(t,n)=>{await r.updateRoomCanvasDocument(e,t,{content:n})},[r,e]),pin:g.useCallback(async(t,n)=>{await r.updateRoomCanvasDocument(e,t,{pinned:n})},[r,e]),close:g.useCallback(async t=>{await r.closeRoomCanvasDocument(e,t)},[r,e])}}function Di(e,r){const t=pe(),n=K(i=>i.setRoomCanvasEditing);g.useEffect(()=>{if(n(e,r),r===null)return;const i=a=>{t.setRoomCanvasEditing(e,r,a).catch(s=>{console.warn("[room-canvas] edit lock failed",{roomId:e,documentId:r,err:s})})};i(!0);const o=setInterval(()=>i(!0),Ri);return()=>{clearInterval(o),i(!1),n(e,null)}},[t,e,r,n])}const Ni=400;function yl(e,r){const t=pe(),n=K(i=>i.roomCanvasPresenceEpoch[e]??0);g.useEffect(()=>{const i=s=>{t.setRoomCanvasViewing(e,s).catch(l=>{console.warn("[room-canvas] could not say where we are looking",{roomId:e,err:l})})};let o=!1;const a=setTimeout(()=>{o=!0,i(r)},Ni);return()=>{clearTimeout(a),o&&i(null)}},[t,e,r,n])}const Mi="allow-scripts allow-forms allow-popups allow-modals",Rt="allow-scripts allow-same-origin allow-popups allow-forms allow-modals allow-downloads",Yi=new Set(["javascript:","data:","blob:"]),Xi=new Set(["localhost","127.0.0.1","0.0.0.0","[::1]","::1"]);function er(e){return Xi.has(e)||e.endsWith(".localhost")}function Wi(e){return er(e)?"direct":"server"}function Bi(e,r){let t;try{t=new URL(e)}catch{return null}const n=t.searchParams.get(Er),i=new URL(t.origin),o=r.indexOf("?");return i.pathname=(o===-1?r:r.slice(0,o))||"/",i.search=o===-1?"":r.slice(o),n!==null&&i.searchParams.set(Er,n),i.toString()}const Er="__dorkos_preview",Li="/__dorkos_preview/health";function Fi(e){return e==="https:"?443:80}function Kr(e){let r;try{r=new URL(e)}catch{return{mode:"serve",path:e}}if(Yi.has(r.protocol))return{mode:"blocked"};if(r.protocol==="file:")return{mode:"serve",path:decodeURIComponent(r.pathname)};if(r.protocol==="http:"||r.protocol==="https:"){if(er(r.hostname)){const t=r.port?Number(r.port):Fi(r.protocol);return{mode:"proxy",hostname:r.hostname,port:t,path:`${r.pathname}${r.search}`}}return{mode:"external",url:e}}return{mode:"blocked"}}function qi(e){const r=e.trim();if(r===""||/^[a-z][a-z0-9+.-]*:\/\//i.test(r)||r.startsWith("/")||r.startsWith("./")||r.startsWith("../"))return r;const t=r.split("/")[0];if(r.includes("/")&&!t.includes(".")&&!t.includes(":"))return r;const i=t.split(":")[0];return`${er(i)?"http":"https"}://${r}`}function Hi(e){const r=Kr(e);if(r.mode==="serve")return{kind:"local",path:r.path};if(r.mode==="blocked")return{kind:"raw",text:e};try{const t=new URL(e),n=t.host.replace(/^www\./,""),i=t.pathname==="/"&&t.search===""&&t.hash===""?"":`${t.pathname}${t.search}${t.hash}`;return{kind:"url",host:n,rest:i}}catch{return{kind:"raw",text:e}}}const Ui=2e3;async function Tr(e,r=globalThis.fetch,t=Ui){const n=new AbortController,i=setTimeout(()=>n.abort(),t);try{return await r(e,{mode:"no-cors",cache:"no-store",signal:n.signal}),!0}catch{return n.signal.aborted}finally{clearTimeout(i)}}function Zi({target:e,currentUrl:r,strategy:t,cwd:n,reloadNonce:i}){const o=JSON.stringify([r,t,n,i]),[a,s]=g.useState(null),[l,c]=g.useState(null),[u,d]=g.useState(null),f=pe(),p=g.useRef(f);return g.useEffect(()=>{p.current=f}),g.useEffect(()=>{const v=p.current;let m=!1;const P=O=>{s(o),c(O)};async function w(O){if(n===null){d({kind:"no-session"});return}try{const z=await v.createServeUrl(n,O);if(m)return;z===null?d({kind:"unsupported"}):P({src:z,sandbox:Mi,previewOrigin:null,bridgeEligibility:"served-document"})}catch{m||d({kind:"failed"})}}async function A(O,z){let Y;try{const M=await v.probeLoopbackPort(O);Y=M===null?"unknown":M.listening}catch{Y="unknown"}if(m)return;let N=null;if(Y!==!1){let M=null;try{M=await v.createProxyUrl(O)}catch{if(m)return;N={kind:"failed"}}if(m)return;if((M==null?void 0:M.unavailable)==="tunnel"){d({kind:"tunnel"});return}if((M==null?void 0:M.unavailable)==="no-port"&&(N={kind:"no-port"}),M!=null&&M.url){const W=new URL(M.url);if(await Tr(`${W.origin}${Li}`)){if(m)return;const q=Bi(M.url,z);if(q!==null){P({src:q,sandbox:Rt,previewOrigin:W.origin,bridgeEligibility:"preview-listener"});return}}if(m)return;N={kind:"origin-unreachable",host:W.hostname,listenPort:W.port}}}if(t==="direct"&&await Tr(r)){if(m)return;P({src:r,sandbox:Rt,previewOrigin:null,bridgeEligibility:null});return}m||d(N??{kind:"no-upstream"})}async function C(){if(d(null),c(null),e.mode!=="blocked"){if(e.mode==="external"){P({src:e.url,sandbox:Rt,previewOrigin:null,bridgeEligibility:null});return}return e.mode==="serve"?w(e.path):A(e.port,e.path)}}return C(),()=>{m=!0}},[e,r,t,n,i,o]),{resolved:a===o?l:null,resolveError:u}}const Vi=1e4;function Gi(e,r){if(e&&e.contentUrl===r&&e.stack.length>0){const t=Math.min(Math.max(e.cursor,0),e.stack.length-1);return{stack:e.stack,cursor:t}}return{stack:[r],cursor:0}}function $i({documentId:e,content:r}){const t=K(_=>_.selectedCwd),n=K(_=>_.writeBrowserHistory),[i]=g.useState(()=>Gi(K.getState().browserHistories[e],r.url)),[o,a]=g.useState(i.stack),[s,l]=g.useState(i.cursor),[c,u]=g.useState(0);g.useEffect(()=>{n(e,{contentUrl:r.url,stack:o,cursor:s})},[e,r.url,o,s,n]);const d=o[s],f=g.useMemo(()=>Kr(d),[d]),p=g.useMemo(()=>f.mode==="proxy"?Wi(window.location.hostname):null,[f]),v=g.useRef(null),{resolved:m,resolveError:P}=Zi({target:f,currentUrl:d,strategy:p,cwd:t,reloadNonce:c}),{resourceErrorCount:w,notePersonNavigated:A,noteFrameLoaded:C}=Ai({iframeRef:v,documentId:e,logicalUrl:d,reloadNonce:c,previewOrigin:(m==null?void 0:m.previewOrigin)??null,bridgeEligibility:(m==null?void 0:m.bridgeEligibility)??null,resolvedSource:(m==null?void 0:m.src)??null}),O=K(_=>_.roomCanvasLiveRoomId),{open:z}=zi(O??""),[Y,N]=g.useState(null),M=g.useCallback(_=>{a(D=>[...D.slice(0,s+1),_]),l(D=>D+1)},[s]),W=Qn(O),q=K(_=>O?_.roomCanvasEditing[O]??null:null);g.useEffect(()=>{if(W===null||q!==null||W.documentId!==e)return;const _=W.url;_===void 0||_===d||M(_)},[W,q,e,d,M]);const B=s>0,y=s<o.length-1,E=g.useCallback(_=>{const D=qi(_);if(!D||D===d){A(),u(Z=>Z+1);return}if(O){N(null),z({type:"browser",url:D}).catch(Z=>{N({url:D,message:xi(Z)})});return}A(),M(D)},[d,M,O,z,A]),R=()=>ri(d);return h.jsxs("div",{className:"flex h-full flex-col",children:[h.jsxs("div",{className:"border-border/60 flex h-9 items-center gap-1 border-b px-2",children:[h.jsx(dt,{label:"Back",disabled:!B,onClick:()=>l(_=>_-1),children:h.jsx(Kn,{className:"size-4"})}),h.jsx(dt,{label:"Forward",disabled:!y,onClick:()=>l(_=>_+1),children:h.jsx(In,{className:"size-4"})}),h.jsx(dt,{label:"Reload",onClick:()=>u(_=>_+1),children:h.jsx(fi,{className:"size-4"})}),h.jsx(Ji,{url:(Y==null?void 0:Y.url)??d,startEditing:Y!==null,onSubmit:E},Y===null?"address":`retry:${Y.url}`),h.jsx(dt,{label:"Open in system browser",onClick:R,children:h.jsx(ei,{className:"size-4"})})]}),Y!==null&&h.jsx("p",{role:"status",className:"text-destructive border-border/60 border-b px-2 py-1 text-xs",children:Y.message}),h.jsx(eo,{target:f,resolved:m,resolveError:P,reloadNonce:c,resourceErrorCount:w,title:r.title??"Embedded browser",onOpenExternally:R,onReload:()=>{A(),u(_=>_+1)},iframeRef:v,onFrameLoad:C})]})}function Ji({url:e,startEditing:r=!1,onSubmit:t}){const[n,i]=g.useState(r),[o,a]=g.useState(e);if(!n)return h.jsx(Ki,{url:e,onActivate:()=>{a(e),i(!0)}});const s=l=>{l.preventDefault(),i(!1),t(o)};return h.jsx("form",{onSubmit:s,className:"min-w-0 flex-1",children:h.jsx(ti,{"aria-label":"Address",autoFocus:!0,value:o,onChange:l=>a(l.target.value),onFocus:l=>l.currentTarget.select(),onBlur:()=>i(!1),onKeyDown:l=>{l.key==="Escape"&&(l.preventDefault(),i(!1))},spellCheck:!1,autoCapitalize:"off",autoCorrect:"off",className:"h-7 w-full text-sm"})})}function Qi(e){return e.kind==="local"?e.path:e.kind==="url"?`${e.host}${e.rest}`:e.text}function Ki({url:e,onActivate:r}){const t=g.useMemo(()=>Hi(e),[e]);return h.jsxs("button",{type:"button","aria-label":`Address: ${Qi(t)}`,onClick:r,className:"text-muted-foreground hover:bg-muted focus-ring flex h-7 min-w-0 flex-1 items-center gap-1.5 rounded-md px-2 text-left text-sm transition-colors",children:[t.kind==="local"&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"bg-muted-foreground/15 text-3xs rounded px-1 py-0.5 font-medium tracking-wide uppercase",children:"local"}),h.jsx("span",{className:"text-foreground truncate",children:t.path})]}),t.kind==="url"&&h.jsxs("span",{className:"truncate",children:[h.jsx("span",{className:"text-foreground",children:t.host}),h.jsx("span",{className:"text-muted-foreground",children:t.rest})]}),t.kind==="raw"&&h.jsx("span",{className:"truncate",children:t.text})]})}function Ii(e,r){switch(e.kind){case"no-session":return"Open a session to preview local files.";case"unsupported":return"Local previews aren’t available in this environment.";case"failed":return"Couldn’t load this preview. Reload, or open the app in your browser.";case"tunnel":return"Dev server previews don’t work remotely. Open DorkOS on the computer running it.";case"no-port":return"All preview ports are in use. Close a preview, then reload.";case"origin-unreachable":return`This view can’t reach port ${e.listenPort} on ${e.host}. Open DorkOS on the computer running it.`;case"no-upstream":return`Nothing is listening on ${r.mode==="proxy"?`${r.hostname}:${r.port}`:"that address"}. Start the dev server, then reload.`}}function eo({target:e,resolved:r,resolveError:t,reloadNonce:n,resourceErrorCount:i,title:o,onOpenExternally:a,onReload:s,iframeRef:l,onFrameLoad:c}){if(e.mode==="blocked")return h.jsx(xt,{children:"This address is blocked for safety."});if(t!==null)return h.jsxs(xt,{children:[h.jsx("p",{children:Ii(t,e)}),t.kind!=="no-session"&&t.kind!=="unsupported"&&h.jsx("button",{type:"button",onClick:s,className:"text-foreground mt-3 hover:underline",children:"Reload"})]});if(r===null)return h.jsx(xt,{children:"Loading…"});const u=e.mode==="external";return h.jsx(to,{src:r.src,sandbox:r.sandbox,title:o,iframeRef:l,onFrameLoad:c,watchLoadDeadline:!u,resourceErrorCount:i,showEmbedFallback:u,onOpenExternally:a,onReload:s},`${r.src}:${n}`)}function to({src:e,sandbox:r,title:t,iframeRef:n,onFrameLoad:i,watchLoadDeadline:o,resourceErrorCount:a,showEmbedFallback:s,onOpenExternally:l,onReload:c}){const[u,d]=g.useState(!1),[f,p]=g.useState(!1);return g.useEffect(()=>{if(!o)return;const v=setTimeout(()=>p(!0),Vi);return()=>clearTimeout(v)},[o]),h.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[f&&!u&&h.jsx(Or,{onOpenExternally:l,onReload:c,children:"This preview is slow to load."}),a>0&&h.jsxs(Or,{onOpenExternally:l,children:["This page hit ",a===1e4?"at least 10,000":a," ",a===1?"error":"errors"," while loading."]}),h.jsx("iframe",{ref:n,src:e,sandbox:r,onLoad:()=>{d(!0),i()},className:"min-h-0 w-full flex-1 border-0",title:t}),s&&h.jsxs("div",{className:"text-muted-foreground border-border/60 flex items-center justify-between gap-2 border-t px-3 py-1.5 text-xs",children:[h.jsx("span",{children:"This site can’t always be embedded here."}),h.jsx("button",{type:"button",onClick:l,className:"text-foreground hover:underline",children:"Open in system browser"})]})]})}function Or({children:e,onOpenExternally:r,onReload:t}){return h.jsxs("div",{className:"text-muted-foreground border-border/60 flex items-center justify-between gap-2 border-b px-3 py-1.5 text-xs",children:[h.jsx("span",{children:e}),h.jsxs("span",{className:"flex shrink-0 items-center gap-3",children:[t&&h.jsx("button",{type:"button",onClick:t,className:"text-foreground hover:underline",children:"Reload"}),h.jsx("button",{type:"button",onClick:r,className:"text-foreground hover:underline",children:"Open in system browser"})]})]})}function dt({label:e,disabled:r,onClick:t,children:n}){return h.jsx("button",{type:"button","aria-label":e,disabled:r,onClick:t,className:It("text-muted-foreground hover:text-foreground hover:bg-muted focus-ring rounded-md p-1.5 transition-colors",r&&"pointer-events-none opacity-40"),children:n})}function xt({children:e}){return h.jsx("div",{className:"text-muted-foreground flex min-h-0 flex-1 flex-col items-center justify-center p-8 text-center",children:e})}function ro({sourcePath:e,cwd:r,loadedContent:t}){const n=pe(),[i,o]=g.useState("idle"),[a,s]=g.useState(null),l=g.useRef(null),c=g.useRef(t),u=g.useRef(Promise.resolve()),d=!!(e&&r),f=g.useCallback(async(w,A)=>{const C=await n.writeFile(r,e,w,A);if(C.ok){if(typeof C.hash!="string"||C.hash.length===0||C.effect!=="changed"&&C.effect!=="no_op")throw new Error("Invalid file save acknowledgement");return l.current=C.hash,c.current=w,s(null),o("saved"),{status:C.effect,confirmed:{hash:C.hash,content:w}}}return s(C.conflict),o("conflict"),{status:"conflict"}},[n,r,e]),p=g.useCallback(w=>{if(!d)return Promise.resolve({status:"idle"});const A=u.current.catch(()=>{}).then(async()=>{o("saving");try{const C=l.current!==null?{expectedHash:l.current}:{expectedContent:c.current};return await f(w,C)}catch{return o("error"),{status:"error"}}});return u.current=A.then(()=>{}),A},[d,f]),v=g.useCallback(w=>{if(!d||!a)return Promise.resolve({status:"idle"});const A=a.currentHash,C=u.current.catch(()=>{}).then(async()=>{o("saving");try{return await f(w,{expectedHash:A})}catch{return o("error"),{status:"error"}}});return u.current=C.then(()=>{}),C},[d,a,f]),m=g.useCallback(()=>({hash:l.current,content:c.current}),[]),P=g.useCallback(()=>{if(!a)return null;const w=a.currentContent;return l.current=a.currentHash,c.current=w,s(null),o("idle"),w},[a]);return{status:i,conflict:a,canSave:d,save:p,overwrite:v,adoptDisk:P,getConfirmedBase:m}}const no=g.lazy(()=>je(()=>import("./BlintzCanvas-CXi0fvcM.js"),__vite__mapDeps([0,1,2,3,4])).then(e=>({default:e.BlintzCanvas}))),io=500;function oo(e){switch(e){case"saving":return"Saving…";case"saved":return"Saved";case"error":return"Couldn’t save";default:return null}}function ao({content:e,documentId:r,onContentChange:t}){const[n,i]=g.useState(!1),[o,a]=g.useState(e.content),s=K(B=>B.canvasSessionId),l=K(B=>B.setDocumentEditing),c=K(B=>{var y;return((y=B.openDocuments.find(E=>E.id===r))==null?void 0:y.editing)??!1}),u=K(B=>B.selectedCwd),d=n&&c,f=ro({sourcePath:e.sourcePath,cwd:u,loadedContent:e.content}),p=f.canSave,v=g.useRef(null),m=g.useRef(null),P=g.useRef(o),w=g.useRef(e),A=g.useRef(t),C=g.useRef(f.save);g.useEffect(()=>{P.current=o,w.current=e,A.current=t,C.current=f.save});const O=g.useCallback(B=>{K.getState().canvasSessionId===v.current&&(A.current({...w.current,content:B}),C.current(B))},[]),z=g.useCallback(B=>{a(B),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{m.current=null,O(B)},io)},[O]),Y=()=>{v.current=K.getState().canvasSessionId,a(e.content),i(!0),l(r,!0)},N=()=>{m.current&&(clearTimeout(m.current),m.current=null,O(P.current)),i(!1),l(r,!1)};g.useEffect(()=>{d&&s!==v.current&&(m.current&&(clearTimeout(m.current),m.current=null),i(!1),l(r,!1))},[s,d,r,l]),g.useEffect(()=>{d||!m.current||(clearTimeout(m.current),m.current=null)},[d]),g.useEffect(()=>()=>{m.current&&(clearTimeout(m.current),m.current=null,O(P.current)),l(r,!1)},[O,r,l]);const M=()=>{const B=f.adoptDisk();B!=null&&(t({...e,content:B}),a(B))},W=()=>{f.overwrite(P.current)},q=oo(f.status);return h.jsxs("div",{className:"relative flex h-full flex-col",children:[h.jsxs("div",{className:"sticky top-0 z-10 flex h-0 items-start justify-end gap-2 pr-2",children:[p&&q&&h.jsx("span",{className:"text-muted-foreground mt-3 text-xs","aria-live":"polite",children:q}),p&&h.jsx(mt,{type:"button",variant:"ghost",size:"icon-md",className:"text-muted-foreground hover:text-foreground mt-2",onClick:d?N:Y,"aria-label":d?"Finish editing":"Edit document",children:d?h.jsx(qr,{className:"size-4"}):h.jsx(Hr,{className:"size-4"})})]}),f.status==="conflict"&&h.jsxs("div",{className:"bg-destructive/10 text-destructive mx-2 mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 rounded-md px-3 py-2 text-sm",children:[h.jsx("span",{className:"flex-1",children:"This file changed on disk since you opened it."}),h.jsx(mt,{type:"button",variant:"ghost",size:"sm",className:"h-7",onClick:M,children:"Reload"}),h.jsx(mt,{type:"button",variant:"destructive",size:"sm",className:"h-7",onClick:W,children:"Overwrite"})]}),h.jsx("div",{className:"flex-1 px-2 pb-6",children:h.jsx(g.Suspense,{fallback:h.jsx("div",{className:"text-muted-foreground p-4 text-sm",children:"Loading editor…"}),children:h.jsx(no,{value:d?o:e.content,editable:d,onChange:d?z:void 0})})})]})}function so({content:e}){return h.jsx("div",{className:"p-4 font-mono text-sm",children:h.jsx(Ir,{value:e.data,depth:0})})}const lo=20;function Ir({value:e,depth:r,keyName:t}){const[n,i]=g.useState(r>2),o=g.useCallback(()=>i(u=>!u),[]);if(r>=lo)return h.jsx(Ve,{keyName:t,value:"[max depth]",className:"text-muted-foreground"});if(e===null)return h.jsx(Ve,{keyName:t,value:"null",className:"text-muted-foreground"});if(typeof e=="boolean")return h.jsx(Ve,{keyName:t,value:String(e),className:"text-blue-500"});if(typeof e=="number")return h.jsx(Ve,{keyName:t,value:String(e),className:"text-green-500"});if(typeof e=="string")return h.jsx(Ve,{keyName:t,value:`"${e}"`,className:"text-amber-500"});const a=Array.isArray(e),s=a?e.map((u,d)=>[String(d),u]):Object.entries(e),l=a?"[":"{",c=a?"]":"}";return h.jsxs("div",{style:{paddingLeft:r>0?16:0},children:[h.jsxs("button",{type:"button",className:"hover:bg-muted -ml-0.5 inline-flex items-center gap-0.5 rounded px-0.5 transition-colors duration-150",onClick:o,children:[h.jsx(ni,{className:It("size-3 transition-transform",!n&&"rotate-90")}),t!=null&&h.jsxs("span",{className:"text-foreground",children:[t,": "]}),h.jsxs("span",{className:"text-muted-foreground",children:[l,n&&` … ${s.length} items `,n&&c]})]}),!n&&h.jsxs(h.Fragment,{children:[s.map(([u,d])=>h.jsx(Ir,{keyName:a?void 0:u,value:d,depth:r+1},u)),h.jsx("div",{className:"text-muted-foreground",children:c})]})]})}function Ve({keyName:e,value:r,className:t}){return h.jsxs("div",{style:{paddingLeft:16},children:[e!=null&&h.jsxs("span",{className:"text-foreground",children:[e,": "]}),h.jsx("span",{className:t,children:r})]})}var Ce=function(e,r){return Number(e.toFixed(r))},uo=function(e,r){return typeof e=="number"?e:r},F=function(e,r,t){t&&typeof t=="function"&&t(e,r)},co=function(e){return-Math.cos(e*Math.PI)/2+.5},fo=function(e){return e},po=function(e){return e*e},ho=function(e){return e*(2-e)},mo=function(e){return e<.5?2*e*e:-1+(4-2*e)*e},vo=function(e){return e*e*e},go=function(e){return--e*e*e+1},bo=function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},wo=function(e){return e*e*e*e},yo=function(e){return 1- --e*e*e*e},Co=function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},So=function(e){return e*e*e*e*e},Po=function(e){return 1+--e*e*e*e*e},ko=function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e},en={easeOut:co,linear:fo,easeInQuad:po,easeOutQuad:ho,easeInOutQuad:mo,easeInCubic:vo,easeOutCubic:go,easeInOutCubic:bo,easeInQuart:wo,easeOutQuart:yo,easeInOutQuart:Co,easeInQuint:So,easeOutQuint:Po,easeInOutQuint:ko},Eo=function(e){var r=e.animationResolve;e.animationResolve=null,r==null||r()},ue=function(e){e.animationFrame!==null&&cancelAnimationFrame(e.animationFrame),e.animationFrame=null,e.isAnimating=!1,e.animation=null,e.velocity=null,Eo(e)};function tn(e,r,t,n,i){if(!e.mounted){i==null||i();return}var o=new Date().getTime(),a=1;ue(e);var s=function(){if(!(!e.mounted||e.animation!==s)){var l=new Date().getTime()-o,c=l/t,u=en[r],d=u(c);if(l>=t){e.animation=null,e.animationFrame=null;var f=e.animationResolve;e.animationResolve=null,n(a),f==null||f(),e.flushResizeAlignment()}else n(d),e.animationFrame=requestAnimationFrame(s)}};e.animation=s,e.animationResolve=i??null,e.animationFrame=requestAnimationFrame(s)}function To(e){var r=e.scale,t=e.positionX,n=e.positionY;return!(Number.isNaN(r)||Number.isNaN(t)||Number.isNaN(n))}function Ae(e,r,t,n){var i=To(r);if(!e.mounted||!i)return Promise.resolve();var o=e.setState,a=e.state,s=a.scale,l=a.positionX,c=a.positionY,u=r.scale-s,d=r.positionX-l,f=r.positionY-c;return t===0?(o(r.scale,r.positionX,r.positionY),Promise.resolve()):new Promise(function(p){tn(e,n,t,function(v){v!==1?e.isAnimating=!0:e.isAnimating=!1;var m=s+u*v,P=l+d*v,w=c+f*v;o(m,P,w)},p)})}function Oo(e,r,t){var n=e.clientWidth,i=e.clientHeight,o=r.offsetWidth,a=r.offsetHeight,s=o*t,l=a*t,c=n-s,u=i-l;return{wrapperWidth:n,wrapperHeight:i,newContentWidth:s,newDiffWidth:c,newContentHeight:l,newDiffHeight:u}}var _o=function(e,r,t,n,i,o,a){var s=e>r?t*(a?.5:1):0,l=n>i?o*(a?.5:1):0,c=e-r-s,u=s,d=n-i-l,f=l;return{minPositionX:c,maxPositionX:u,minPositionY:d,maxPositionY:f,scaleWidthFactor:s,scaleHeightFactor:l}},tr=function(e,r){var t=e.wrapperComponent,n=e.contentComponent,i=e.setup,o=i.centerZoomedOut,a=i.disablePadding;if(!t||!n)throw new Error("Components are not mounted");var s=Oo(t,n,r),l=s.wrapperWidth,c=s.wrapperHeight,u=s.newContentWidth,d=s.newContentHeight,f=s.newDiffWidth,p=s.newDiffHeight,v=_o(l,u,f,c,d,p,!!o),m=l>=u&&c>=d;a&&m&&!o&&(v.minPositionX=0,v.maxPositionX=0,v.minPositionY=0,v.maxPositionY=0);var P=e.setup,w=P.minPositionX,A=P.maxPositionX,C=P.minPositionY,O=P.maxPositionY;return w!=null&&(v.minPositionX=l*(1-r)+w*r),A!=null&&(v.maxPositionX=A*r),C!=null&&(v.minPositionY=c*(1-r)+C*r),O!=null&&(v.maxPositionY=O*r),v},tt=function(e,r,t,n){return n?e<r?Ce(r,2):e>t?Ce(t,2):Ce(e,2):Ce(e,2)},ce=function(e,r){var t=tr(e,r);return e.bounds=t,t};function Me(e,r,t,n,i,o,a){var s=t.minPositionX,l=t.minPositionY,c=t.maxPositionX,u=t.maxPositionY,d=0,f=0;a&&(d=i,f=o);var p=tt(e,s-d,c+d,n),v=tt(r,l-f,u+f,n);return{x:p,y:v}}function Et(e,r,t,n,i,o){var a=e.state,s=a.scale,l=a.positionX,c=a.positionY,u=n-s;if(!Number.isFinite(r)||!Number.isFinite(t))return console.error("Mouse X and Y position were not provided!"),{x:l,y:c};var d=l-r*u,f=c-t*u,p=Me(d,f,i,o,0,0,null);return p}var _r=1e-7;function Fe(e,r,t,n,i){var o=i?n:0,a=Math.max(r-o,_r),s=t+o;return!Number.isNaN(t)&&e>=s?s:!Number.isNaN(r)&&e<=a?a:Math.max(e,_r)}var jr=function(e,r){var t=e.setup.panning.excluded,n=e.isInitialized,i=e.wrapperComponent,o=r.target,a=function(u){return!!u&&typeof u=="object"&&u.nodeType===1&&typeof u.contains=="function"},s=typeof r.composedPath=="function"?r.composedPath().some(function(u){return a(u)&&!!(i!=null&&i.contains(u))}):!!(i!=null&&i.contains(o)),l=n&&o&&s;if(!l)return!1;var c=qe(o,t);return!(c||sa(o)||ir(o))},Ar=function(e){var r=e.isInitialized,t=e.isPanning,n=e.setup,i=n.panning.disabled,o=r&&t&&!i;return!!o},jo=function(e,r){var t=e.state,n=t.positionX,i=t.positionY;e.isPanning=!0;var o=r.clientX,a=r.clientY;e.startCoords={x:o-n,y:a-i}},Ao=function(e,r){var t=r.touches,n=e.state,i=n.positionX,o=n.positionY;e.isPanning=!0;var a=t.length===1;if(a){var s=t[0].clientX,l=t[0].clientY;e.startCoords={x:s-i,y:l-o}}};function Ro(e){var r=e.state,t=r.positionX,n=r.positionY,i=r.scale,o=e.setup,a=o.disabled,s=o.limitToBounds,l=o.centerZoomedOut,c=e.wrapperComponent;if(!(a||!c||!e.bounds)){var u=e.bounds,d=u.maxPositionX,f=u.minPositionX,p=u.maxPositionY,v=u.minPositionY,m=t>d||t<f,P=n>p||n<v,w=t>d?c.clientWidth:e.setup.minPositionX||0,A=n>p?c.clientHeight:e.setup.minPositionY||0,C=Et(e,w,A,i,e.bounds,s||l),O=C.x,z=C.y;return{scale:i,positionX:m?O:t,positionY:P?z:n}}}function rn(e,r,t,n,i){var o=e.setup.limitToBounds,a=e.wrapperComponent,s=e.bounds,l=e.state,c=l.scale,u=l.positionX,d=l.positionY;if(!(a===null||s===null||r===u&&t===d)){var f=Me(r,t,s,o,n,i,a),p=f.x,v=f.y;e.setState(c,p,v)}}var xo=function(e,r,t){var n=e.startCoords,i=e.state,o=e.setup.panning,a=o.lockAxisX,s=o.lockAxisY,l=i.positionX,c=i.positionY;if(!n)return{x:l,y:c};var u=r-n.x,d=t-n.y,f=a?l:u,p=s?c:d;return{x:f,y:p}},Oe=function(e,r,t){var n=e.setup,i=e.state,o=n.minScale,a=n.disablePadding,s=n.centerZoomedOut,l=t??i.scale;return r>0&&l>=o&&!a&&!s?r:0},Te;(function(e){e.TRACK_PAD="track_pad",e.MOUSE="mouse",e.TOUCH="touch"})(Te||(Te={}));var zo=function(e){var r=e.mounted,t=e.wrapperComponent,n=e.contentComponent,i=e.setup,o=i.disabled,a=i.velocityAnimation,s=i.limitToBounds,l=e.state.scale,c=a.disabled;if(c||o||!r||!t||!n)return!1;if(!s)return!0;var u=t.clientWidth<n.offsetWidth*l||t.clientHeight<n.offsetHeight*l;return u},Do=function(e){var r=e.mounted,t=e.velocity,n=e.bounds,i=e.setup,o=i.disabled,a=i.velocityAnimation,s=a.disabled,l=!s&&!o&&r;return!(!l||!t||!n)};function No(e,r){var t=e.setup.velocityAnimation,n=t.animationTime,i=t.maxAnimationTime,o=t.inertia;return Math.min(n*Math.max(1,Math.abs(r/o)),i)}function Rr(e,r,t,n,i,o,a,s,l,c){if(i){if(r>a&&t>a){var u=a+(e-a)*c;return u>l?l:u<a?a:u}if(r<o&&t<o){var u=o+(e-o)*c;return u<s?s:u>o?o:u}}return n?r:tt(e,o,a,i)}function Mo(e){var r=1,t=e.clientWidth/window.innerWidth;return Number.isNaN(t)?r:Math.min(r,t)}var zt=function(e,r,t){var n=0,i=e*t;return Number.isNaN(i)?n:e<0?Math.max(i,-r):Math.min(i,r)};function Yo(e,r,t){var n,i,o=zo(e);if(o){var a=e.lastMousePosition,s=e.velocityTime,l=e.setup,c=e.wrapperComponent,u=l.velocityAnimation,d=u.maxStrengthMouse,f=u.maxStrengthTouch,p=u.sensitivityTouch,v=u.sensitivityMouse,m=Date.now();if(a&&s&&c){var P=Mo(c),w=(n={},n[Te.TOUCH]=p,n[Te.MOUSE]=v,n)[t],A=(i={},i[Te.TOUCH]=f,i[Te.MOUSE]=d,i)[t],C=r.x-a.x,O=r.y-a.y,z=zt(C/P,A,w),Y=zt(O/P,A,w),N=m-s,M=C*C+O*O,W=zt(Math.sqrt(M)/N,A,w);e.velocity={velocityX:z,velocityY:Y,total:W}}e.lastMousePosition=r,e.velocityTime=m}}function Xo(e){var r=e.velocity,t=e.bounds,n=e.setup,i=e.wrapperComponent,o=Do(e);if(!(!o||!r||!t||!i)){var a=r.velocityX,s=r.velocityY,l=r.total,c=t.maxPositionX,u=t.minPositionX,d=t.maxPositionY,f=t.minPositionY,p=n.limitToBounds,v=n.autoAlignment,m=n.zoomAnimation,P=n.panning,w=P.lockAxisY,A=P.lockAxisX,C=m.animationType,O=v.sizeX,z=v.sizeY,Y=v.velocityAlignmentTime,N=Y,M=No(e,l),W=Math.max(M,N),q=Oe(e,O),B=Oe(e,z),y=q*i.clientWidth/100,E=B*i.clientHeight/100,R=c+y,_=u-y,D=d+E,Z=f-E,G=e.state,se=new Date().getTime();tn(e,C,W,function(me){var le=e.state,we=le.scale,Xe=le.positionX,We=le.positionY,Be=new Date().getTime()-se,He=Be/N,ct=en[v.animationType],k=1-ct(Math.min(1,He)),b=1-me,T=Xe+a*b,S=We+s*b,x=Rr(T,G.positionX,Xe,A,p,u,c,_,R,k),$=Rr(S,G.positionY,We,w,p,f,d,Z,D,k);if(Xe!==T||We!==S){e.setState(we,x,$);var H=e.props.onPanning;H&&H(L(e),{})}})}}function xr(e,r){var t=e.state,n=t.scale,i=t.positionX,o=t.positionY;e.panStartPosition={x:i,y:o},ue(e),ce(e,n),"touches"in r?Ao(e,r):jo(e,r)}function nn(e,r){var t=e.state.scale,n=e.setup,i=n.minScale,o=n.autoAlignment,a=o.disabled,s=o.sizeX,l=o.sizeY,c=o.animationTime,u=o.animationType,d=a||t<i||!s&&!l;if(!d){e.isResizeAlignmentPending&&ce(e,t);var f=Ro(e);if(f){var p=e.state,v=p.positionX,m=p.positionY,P=f.positionX===v&&f.positionY===m;P||Ae(e,f,c,u)}}}function zr(e,r,t,n){var i=e.startCoords,o=e.setup,a=o.autoAlignment,s=a.sizeX,l=a.sizeY;if(i){var c=xo(e,r,t),u=c.x,d=c.y,f=Oe(e,s),p=Oe(e,l);Yo(e,{x:u,y:d},n),rn(e,u,d,f,p)}}function Wo(e,r){if(e.isPanning){var t=e.velocity,n=e.wrapperComponent,i=e.contentComponent;e.isPanning=!1;var o=e.state,a=o.positionX,s=o.positionY,l=o.scale,c=e.panStartPosition;if(e.panStartPosition=null,c){var u=a-c.x,d=s-c.y;if(u*u+d*d<=25)return}e.isAnimating=!1,e.animation=null,e.isResizeAlignmentPending&&ce(e,l);var f=(n==null?void 0:n.clientWidth)||0,p=(n==null?void 0:n.clientHeight)||0,v=((i==null?void 0:i.offsetWidth)||0)*l,m=((i==null?void 0:i.offsetHeight)||0)*l,P=!e.setup.limitToBounds||f<v||p<m,w=!r&&t&&t.total>.1&&P;w?Xo(e):nn(e)}}function Tt(e,r,t,n){var i=e.setup,o=i.minScale,a=i.maxScale,s=i.limitToBounds,l=Fe(Ce(r,2),o,a,0,!1),c=ce(e,l),u=Et(e,t,n,l,c,s),d=u.x,f=u.y;return{scale:l,positionX:d,positionY:f}}function rr(e,r,t){var n=e.state.scale,i=e.wrapperComponent,o=e.setup,a=o.minScale,s=o.maxScale,l=o.limitToBounds,c=o.zoomAnimation,u=c.disabled,d=c.animationTime,f=c.animationType,p=n>=a&&n<=s,v=u||p;if((n>=1||l)&&nn(e),!(v||!i||!e.mounted)){var m=r||i.clientWidth/2,P=t||i.clientHeight/2,w=n<a?a:s,A=Tt(e,w,m,P);A&&Ae(e,A,d,f)}}var de=function(){return de=Object.assign||function(r){for(var t,n=1,i=arguments.length;n<i;n++){t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(r[o]=t[o])}return r},de.apply(this,arguments)};function Dr(e,r,t){for(var n=0,i=r.length,o;n<i;n++)(o||!(n in r))&&(o||(o=Array.prototype.slice.call(r,0,n)),o[n]=r[n]);return e.concat(o||Array.prototype.slice.call(r))}var Dt={scale:1,positionX:0,positionY:0},Ne={disabled:!1,minPositionX:null,maxPositionX:null,minPositionY:null,maxPositionY:null,minScale:1,maxScale:8,limitToBounds:!0,centerZoomedOut:!1,centerOnInit:!1,fitOnInit:!1,disablePadding:!1,smooth:!0,detached:!1,wheel:{step:.015,disabled:!1,wheelDisabled:!1,touchPadDisabled:!1,activationKeys:[],excluded:[]},trackPadPanning:{disabled:!0,velocityDisabled:!1,lockAxisX:!1,lockAxisY:!1,activationKeys:[],excluded:[]},panning:{disabled:!1,velocityDisabled:!1,lockAxisX:!1,lockAxisY:!1,allowLeftClickPan:!0,allowMiddleClickPan:!0,allowRightClickPan:!0,activationKeys:[],excluded:[]},pinch:{step:5,disabled:!1,allowPanning:!0,excluded:[]},keyboard:{disabled:!0,panStep:50,zoomStep:.25,animationTime:100,animationType:"easeOut",excluded:[]},doubleClick:{disabled:!1,step:.7,mode:"zoomIn",animationType:"easeOut",animationTime:200,excluded:[]},zoomAnimation:{disabled:!1,size:.4,animationTime:200,animationType:"easeOut"},autoAlignment:{disabled:!1,sizeX:100,sizeY:100,animationTime:200,velocityAlignmentTime:400,animationType:"easeOut"},velocityAnimation:{disabled:!1,sensitivityMouse:1,sensitivityTouch:1.2,maxStrengthMouse:20,maxStrengthTouch:40,inertia:1,animationTime:300,maxAnimationTime:800,animationType:"easeOut"}},Bt={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},on=function(e){var r,t,n,i,o,a,s,l,c,u=Math.max((r=e.minScale)!==null&&r!==void 0?r:Ne.minScale,1e-7),d=(t=e.maxScale)!==null&&t!==void 0?t:Ne.maxScale,f=(n=e.initialScale)!==null&&n!==void 0?n:Dt.scale,p=Math.min(Math.max(f,u),d),v=tt((i=e.initialPositionX)!==null&&i!==void 0?i:Dt.positionX,(o=e.minPositionX)!==null&&o!==void 0?o:-1/0,(a=e.maxPositionX)!==null&&a!==void 0?a:1/0,e.minPositionX!=null||e.maxPositionX!=null),m=tt((s=e.initialPositionY)!==null&&s!==void 0?s:Dt.positionY,(l=e.minPositionY)!==null&&l!==void 0?l:-1/0,(c=e.maxPositionY)!==null&&c!==void 0?c:1/0,e.minPositionY!=null||e.maxPositionY!=null);return{previousScale:p,scale:p,positionX:v,positionY:m}},Nr=function(e){var r=de({},Ne);return Object.keys(e).forEach(function(t){var n=t,i=typeof e[n]<"u",o=typeof Ne[n]<"u";if(o&&i){var a=Object.prototype.toString.call(Ne[n]),s=a==="[object Object]",l=a==="[object Array]";s?r[n]=de(de({},Ne[n]),e[n]):l?r[n]=Dr(Dr([],Ne[n],!0),e[n]):r[n]=e[n]}}),r.minScale<=0&&(r.minScale=1e-7),r},an=function(e,r,t){var n=e.state.scale,i=e.wrapperComponent,o=e.setup,a=o.maxScale,s=o.minScale,l=o.zoomAnimation,c=l.size;if(!i)throw new Error("Wrapper is not mounted");var u=n+r*t,d=Fe(Ce(u,3),s,a,c,!1);return d};function rt(e,r,t,n){var i,o,a=e.wrapperComponent,s=e.props,l=s.onZoomStart,c=s.onZoom,u=s.onZoomStop,d=new MouseEvent("mousemove",{bubbles:!0}),f=L(e);F(f,d,l),F(f,d,c);var p=Ae(e,r,t,n),v=(o=(i=a==null?void 0:a.ownerDocument)===null||i===void 0?void 0:i.defaultView)!==null&&o!==void 0?o:typeof window<"u"?window:null;return v&&v.setTimeout(function(){e.mounted&&F(L(e),d,u)},t),p}function sn(e,r,t,n,i){var o=e.wrapperComponent,a=e.state,s=a.scale,l=a.positionX,c=a.positionY,u=e.setup.zoomAnimation;if(!o)return console.error("No WrapperComponent found"),Promise.resolve();var d=u.disabled?0:n,f=o.clientWidth,p=o.clientHeight,v=(f/2-l)/s,m=(p/2-c)/s,P=an(e,r,t),w=Tt(e,P,v,m);return w?rt(e,w,d,i):(console.error("Error during zoom event. New transformation state was not calculated."),Promise.resolve())}function Bo(e,r,t,n){var i,o,a=e.wrapperComponent,s=e.props,l=s.onPanningStart,c=s.onPanning,u=s.onPanningStop,d=new MouseEvent("mousemove",{bubbles:!0}),f=L(e);F(f,d,l),F(f,d,c);var p=Ae(e,r,t,n),v=(o=(i=a==null?void 0:a.ownerDocument)===null||i===void 0?void 0:i.defaultView)!==null&&o!==void 0?o:typeof window<"u"?window:null;return v&&v.setTimeout(function(){e.mounted&&F(L(e),d,u)},t),p}function nr(e,r,t,n){r===void 0&&(r="contain");var i=e.wrapperComponent,o=e.contentComponent,a=e.setup;if(!i||!o)return null;var s=o.offsetWidth,l=o.offsetHeight,c=i.clientWidth,u=i.clientHeight;if(!s||!l||!c||!u)return null;var d=c/s,f=u/l,p=r==="cover"?Math.max(d,f):Math.min(d,f);return n!==void 0&&(p=Math.min(p,n)),t!==void 0&&(p=Math.max(p,t)),p=Fe(p,a.minScale,a.maxScale,0,!1),Ot(p,i,o)}function ln(e,r,t,n){var i=e.setup,o=e.wrapperComponent,a=e.contentComponent,s=i.limitToBounds,l=i.centerOnInit,c=i.fitOnInit,u=on(e.props),d=e.state,f=d.scale,p=d.positionX,v=d.positionY;if(!o)return Promise.resolve();if(c){var m=nr(e,c==="cover"?"cover":"contain");if(m)return f===m.scale&&p===m.positionX&&v===m.positionY?Promise.resolve():(n==null||n(),rt(e,m,r,t))}var P=u.positionX,w=u.positionY;if(l&&a){var A=Ot(u.scale,o,a);P=A.positionX,w=A.positionY}var C=tr(e,u.scale),O=Me(P,w,C,s,0,0,o),z={scale:u.scale,positionX:O.x,positionY:O.y};return f===u.scale&&p===u.positionX&&v===u.positionY?Promise.resolve():(n==null||n(),rt(e,z,r,t))}var un=function(e){if("getBoundingClientRect"in e){var r=e.getBoundingClientRect();return{x:r.left,y:r.top,width:r.width,height:r.height}}return e};function Lo(e){var r=e.map(un),t=Math.min.apply(Math,r.map(function(a){return a.x})),n=Math.min.apply(Math,r.map(function(a){return a.y})),i=Math.max.apply(Math,r.map(function(a){return a.x+a.width})),o=Math.max.apply(Math,r.map(function(a){return a.y+a.height}));return{x:t,y:n,width:i-t,height:o-n}}function Fo(e,r,t,n){var i=un(e),o=r.getBoundingClientRect(),a=t.getBoundingClientRect(),s=o.x*n.scale,l=o.y*n.scale;return{x:(i.x-a.x+s)/n.scale,y:(i.y-a.y+l)/n.scale}}function qo(e,r,t,n,i,o,a){n===void 0&&(n=0),i===void 0&&(i=0);var s=e.wrapperComponent,l=e.contentComponent,c=e.state,u=e.setup,d=u.limitToBounds,f=u.minScale,p=u.maxScale;if(!s||!l)return c;var v=s.getBoundingClientRect(),m=Fo(r,s,l,c),P=m.x,w=m.y,A=r.width/c.scale,C=r.height/c.scale,O=s.clientWidth/A,z=s.clientHeight/C,Y=t||Math.min(O,z);a!==void 0&&(Y=Math.min(Y,a)),o!==void 0&&(Y=Math.max(Y,o));var N=Fe(Y,f,p,0,!1),M=(v.width-A*N)/2,W=(v.height-C*N)/2,q=(v.left-P)*N+M+n,B=(v.top-w)*N+W+i,y=tr(e,N),E=Me(q,B,y,d,0,0,s),R=E.x,_=E.y;return{positionX:R,positionY:_,scale:N}}function cn(e,r,t){var n=e.wrapperComponent,i=e.state;if(!n)return{x:0,y:0};var o=n.getBoundingClientRect();return{x:(r-o.left-i.positionX)/i.scale,y:(t-o.top-i.positionY)/i.scale}}function Ho(e,r,t){var n=e.wrapperComponent,i=e.state;if(!n)return{x:0,y:0};var o=n.getBoundingClientRect();return{x:o.left+i.positionX+r*i.scale,y:o.top+i.positionY+t*i.scale}}var Uo=function(e){return function(r,t,n){return r===void 0&&(r=.5),t===void 0&&(t=300),n===void 0&&(n="easeOut"),sn(e,1,r,t,n)}},Zo=function(e){return function(r,t,n){return r===void 0&&(r=.5),t===void 0&&(t=300),n===void 0&&(n="easeOut"),sn(e,-1,r,t,n)}},Vo=function(e){return function(r,t,n,i,o){i===void 0&&(i=300),o===void 0&&(o="easeOut");var a=e.state,s=a.positionX,l=a.positionY,c=a.scale,u=e.wrapperComponent,d=e.contentComponent,f=e.setup.disabled;if(f||!u||!d)return Promise.resolve();var p={positionX:Number.isNaN(r)?s:r,positionY:Number.isNaN(t)?l:t,scale:Number.isNaN(n)?c:n};return Ae(e,p,i,o)}},Go=function(e){return function(r,t){return r===void 0&&(r=200),t===void 0&&(t="easeOut"),ln(e,r,t)}},$o=function(e){return function(r,t,n){t===void 0&&(t=200),n===void 0&&(n="easeOut");var i=e.state,o=e.wrapperComponent,a=e.contentComponent;if(o&&a){var s=Ot(r||i.scale,o,a);return Ae(e,s,t,n)}return Promise.resolve()}},Jo=function(e){return function(r,t,n,i,o){i===void 0&&(i=300),o===void 0&&(o="easeOut");var a=e.wrapperComponent,s=e.contentComponent,l=e.setup;if(l.disabled||!a||!s)return Promise.resolve();var c=cn(e,t,n),u=Tt(e,r,c.x,c.y);if(!u)return Promise.resolve();var d=l.zoomAnimation.disabled?0:i;return rt(e,u,d,o)}},Qo=function(e){return function(r,t){return cn(e,r,t)}},Ko=function(e){return function(r,t){return Ho(e,r,t)}},Io=function(e,r){var t,n=e.wrapperComponent;if(!n)return[];var i=n.getRootNode(),o=i&&"getElementById"in i?i:(t=n.ownerDocument)!==null&&t!==void 0?t:typeof document<"u"?document:null,a=Array.isArray(r)?r:[r];return a.map(function(s){return typeof s=="string"?o==null?void 0:o.getElementById(s):s}).filter(function(s){return!!s&&n.contains(s)})},ea=function(e){return function(r,t,n,i,o,a){var s,l,c,u;n===void 0&&(n=600),i===void 0&&(i="easeOut"),o===void 0&&(o=0),a===void 0&&(a=0),ue(e);var d=typeof t=="object"&&t!==null?t:{scale:t},f=Io(e,r);if(!e.wrapperComponent||f.length===0)return Promise.resolve();var p=qo(e,Lo(f),d.scale,(s=d.offsetX)!==null&&s!==void 0?s:o,(l=d.offsetY)!==null&&l!==void 0?l:a,d.minScale,d.maxScale);return Ae(e,p,(c=d.animationTime)!==null&&c!==void 0?c:n,(u=d.animationType)!==null&&u!==void 0?u:i)}},ta=function(e){return function(r){var t,n,i;r===void 0&&(r={});var o=e.wrapperComponent,a=e.contentComponent,s=e.setup;if(s.disabled||!o||!a)return Promise.resolve();var l=nr(e,(t=r.mode)!==null&&t!==void 0?t:"contain",r.minScale,r.maxScale);if(!l)return Promise.resolve();var c=s.zoomAnimation.disabled?0:(n=r.animationTime)!==null&&n!==void 0?n:200;return rt(e,l,c,(i=r.animationType)!==null&&i!==void 0?i:"easeOut")}},ra=function(e){return function(r,t,n,i){n===void 0&&(n=200),i===void 0&&(i="easeOut");var o=e.wrapperComponent,a=e.contentComponent,s=e.setup,l=e.state;if(s.disabled||!o||!a||!Number.isFinite(r)||!Number.isFinite(t))return Promise.resolve();var c=ce(e,l.scale),u=Me(l.positionX+r,l.positionY+t,c,s.limitToBounds,0,0,o),d=u.x,f=u.y;return d===l.positionX&&f===l.positionY?Promise.resolve():Bo(e,{scale:l.scale,positionX:d,positionY:f},n,i)}},nt=function(e){return{instance:e,state:e.state,zoomIn:Uo(e),zoomOut:Zo(e),setTransform:Vo(e),resetTransform:Go(e),centerView:$o(e),zoomToElement:ea(e),zoomToPoint:Jo(e),clientToContent:Qo(e),contentToClient:Ko(e),fitToView:ta(e),panBy:ra(e)}},na=function(e){return{instance:e,state:e.state}},L=function(e){var r={};return Object.assign(r,na(e)),Object.assign(r,nt(e)),r},Nt=!1;function ft(){try{var e={get passive(){return Nt=!0,!1}};return e}catch{return Nt=!1,Nt}}var pt=".".concat(Bt.wrapperClass),qe=function(e,r){return r.some(function(t){return e.matches("".concat(pt," ").concat(t,", ").concat(pt," .").concat(t,", ").concat(pt," ").concat(t," *, ").concat(pt," .").concat(t," *"))})},ia=new Set(["INPUT","TEXTAREA","SELECT","OPTION"]),oa='[contenteditable=""], [contenteditable="true"], [contenteditable="plaintext-only"]',aa='[draggable="true"]',dn=function(e){return!e||typeof e.closest!="function"?null:e},ir=function(e){var r=dn(e);return r?ia.has(r.tagName)||r.isContentEditable?!0:r.closest(oa)!==null:!1},sa=function(e){var r=dn(e);return r?r.closest(aa)!==null:!1},it=function(e){e&&clearTimeout(e)},la=function(e){return Number.parseFloat(e.toFixed(8))},fn=function(e,r,t){var n=la(t);return"translate(".concat(e,"px, ").concat(r,"px) scale(").concat(n,")")},Ot=function(e,r,t){var n=t.offsetWidth*e,i=t.offsetHeight*e,o=(r.clientWidth-n)/2,a=(r.clientHeight-i)/2;return{scale:e,positionX:o,positionY:a}};function ua(e,r){e!=null&&(typeof e=="function"?e(r):e.current=r)}function ca(e){return function(r){e.forEach(function(t){typeof t=="function"?t(r):t!=null&&(t.current=r)})}}var or=typeof window<"u"?g.useLayoutEffect:g.useEffect,da={panLeft:["ArrowLeft"],panRight:["ArrowRight"],panUp:["ArrowUp"],panDown:["ArrowDown"],zoomIn:["+","="],zoomOut:["-","_"],reset:["0"]},fa=function(e){return Object.values(da).some(function(r){return r.includes(e)})};function pa(e,r){var t=e.setup,n=t.disabled,i=t.keyboard,o=t.panning;if(n||i.disabled||r.defaultPrevented||r.ctrlKey||r.metaKey||r.altKey||!fa(r.key))return!1;var a=r.target;if(ir(a)||a&&typeof a.matches=="function"&&qe(a,i.excluded))return!1;var s=i.panStep,l=i.zoomStep,c=i.animationTime,u=i.animationType,d=nt(e),f=r.key,p=o.lockAxisX?0:s,v=o.lockAxisY?0:s;return f==="ArrowLeft"?d.panBy(p,0,c,u):f==="ArrowRight"?d.panBy(-p,0,c,u):f==="ArrowUp"?d.panBy(0,v,c,u):f==="ArrowDown"?d.panBy(0,-v,c,u):f==="+"||f==="="?d.zoomIn(l,c,u):f==="-"||f==="_"?d.zoomOut(l,c,u):f==="0"&&d.resetTransform(c,u),r.cancelable&&r.preventDefault(),r.stopPropagation(),!0}var Lt=function(e,r){return{wrapperWidth:e.offsetWidth,wrapperHeight:e.offsetHeight,contentWidth:r.offsetWidth,contentHeight:r.offsetHeight}},ha=function(e,r){return!e||e.wrapperWidth!==r.wrapperWidth||e.wrapperHeight!==r.wrapperHeight||e.contentWidth!==r.contentWidth||e.contentHeight!==r.contentHeight},pn=function(e){return e.isPanning||e.isPinching},ma=function(e){return pn(e)||e.wheelStopEventTimer!==null||e.wheelAnimationTimer!==null};function hn(e){var r=e.wrapperComponent,t=e.contentComponent,n=e.setup,i=e.state;if(!r||!t)return null;var o=ce(e,i.scale),a=n.limitToBounds,s=n.centerZoomedOut;if(!a&&!s)return null;var l=Me(i.positionX,i.positionY,o,!0,0,0,r),c=l.x,u=l.y,d=c===Ce(i.positionX,2)&&u===Ce(i.positionY,2);return d?null:{scale:i.scale,positionX:c,positionY:u}}var Ft=function(e){e.animation=null,e.animationFrame=null,e.isAnimating=!1,e.resizeAnimation=null};function va(e){var r=e.setup.autoAlignment.animationTime,t=Math.max(r/5,1);ue(e);var n=Date.now(),i=function(){if(!(!e.mounted||e.animation!==i)){var o=Date.now(),a=Math.max(o-n,1);n=o;var s=hn(e);if(!s){Ft(e);return}var l=e.state,c=l.scale,u=l.positionX,d=l.positionY,f=1-Math.exp(-a/t),p=u+(s.positionX-u)*f,v=d+(s.positionY-d)*f,m=Math.abs(s.positionX-p)<.5&&Math.abs(s.positionY-v)<.5;if(m&&(p=s.positionX,v=s.positionY),e.isAnimating=!m,e.setState(c,p,v),m){Ft(e);return}e.animationFrame=requestAnimationFrame(i)}};e.animation=i,e.resizeAnimation=i,e.animationResolve=null,e.animationFrame=requestAnimationFrame(i)}function mn(e){if(e.setup.disabled){ce(e,e.state.scale);return}if(pn(e)){e.isResizeAlignmentPending=!0;return}var r=e.animation!==null&&e.animation===e.resizeAnimation;if(e.animation&&!r){var t=e.state.scale,n=e.setup,i=n.minScale,o=n.maxScale;if(t<i||t>o){e.isResizeAlignmentPending=!0;return}ue(e)}var a=hn(e);if(!a){r&&Ft(e);return}if(!r){if(e.setup.autoAlignment.animationTime===0){e.setState(a.scale,a.positionX,a.positionY);return}va(e)}}function ga(e){var r=e.wrapperComponent,t=e.contentComponent;if(!(!r||!t)){var n=Lt(r,t);ha(e.measuredSizes,n)&&(e.measuredSizes=n,mn(e))}}var vn=function(e,r){var t=e.setup.wheel,n=t.disabled,i=t.wheelDisabled,o=t.touchPadDisabled,a=t.excluded,s=e.isInitialized,l=e.isPanning,c=r.target,u=s&&!l&&!n&&c;if(!u||r.deltaY===0||i&&!r.ctrlKey||o&&r.ctrlKey)return!1;var d=qe(c,a);if(d)return!1;var f=e.isPressingKeys(e.setup.wheel.activationKeys);return!!f},ba=function(e,r){var t=e.setup,n=t.disabled,i=t.trackPadPanning,o=i.activationKeys,a=i.excluded;if(!e.wrapperComponent||!e.contentComponent||n||i.disabled||r.ctrlKey)return!1;var s=vn(e,r);if(s)return!1;var l=r.target,c=qe(l,a);if(c)return!1;var u=e.isPressingKeys(o);return!!u},wa=function(e){return e?e.deltaY<0?1:-1:0};function ya(e,r){var t=wa(e),n=uo(r,t);return n}function gn(e,r,t){var n=r.getBoundingClientRect(),i=0,o=0;if("clientX"in e)i=(e.clientX-n.left)/t,o=(e.clientY-n.top)/t;else{var a=e.touches[0];i=(a.clientX-n.left)/t,o=(a.clientY-n.top)/t}return Number.isNaN(i)||Number.isNaN(o)?(console.error("No mouse or touch offset found"),{x:0,y:0}):{x:i,y:o}}var Ca=function(e,r,t,n,i){var o=e.state.scale,a=e.wrapperComponent,s=e.setup,l=s.maxScale,c=s.minScale,u=s.zoomAnimation,d=s.disablePadding,f=u.size,p=u.disabled;if(!a)throw new Error("Wrapper is not mounted");var v=o+r*t,m=n?!1:!p,P=Fe(v,c,l,f,m&&!d);return P},bn=function(e,r){var t=e.previousWheelEvent,n=e.state.scale,i=e.setup,o=i.maxScale,a=i.minScale;return t?n<o||n>a||Math.sign(t.deltaY)!==Math.sign(r.deltaY)||t.deltaY>0&&t.deltaY<r.deltaY||t.deltaY<0&&t.deltaY>r.deltaY||Math.sign(t.deltaY)!==Math.sign(r.deltaY):!1},Sa=function(e,r){var t=e.setup.pinch,n=t.disabled,i=t.excluded,o=e.isInitialized,a=r.target,s=o&&!n&&a;if(!s)return!1;var l=qe(a,i);return!l},Pa=function(e){var r=e.setup.pinch.disabled,t=e.isInitialized,n=e.pinchStartDistance,i=t&&!r&&n!==null;return!!i},ka=function(e,r,t){var n=t.getBoundingClientRect(),i=e.touches,o=i[0].clientX-n.left,a=i[0].clientY-n.top,s=i[1].clientX-n.left,l=i[1].clientY-n.top;return{x:(o+s)/2/r,y:(a+l)/2/r}},wn=function(e){return Math.sqrt(Math.pow(e.touches[0].pageX-e.touches[1].pageX,2)+Math.pow(e.touches[0].pageY-e.touches[1].pageY,2))},Ea=5,Ta=function(e,r){var t=e.pinchStartScale,n=e.pinchStartDistance,i=e.setup,o=i.maxScale,a=i.minScale,s=i.zoomAnimation,l=i.disablePadding,c=i.pinch,u=s.size,d=s.disabled,f=c.step;if(!t||n===null)throw new Error("Pinch touches distance was not provided");if(r<0)return e.state.scale;var p=r/n,v=p*t,m=(v-t)*(f/Ea),P=t+m,w=P===1/0?0:Ce(P,10);return Fe(w,a,o,u,!d&&!l)},yn=160,Cn=100,Oa=function(e,r){var t=e.props,n=t.onWheelStart,i=t.onZoomStart;ue(e),e.wheelStopEventTimer||(F(L(e),r,n),F(L(e),r,i))},_a=function(e,r){var t=e.props,n=t.onWheel,i=t.onZoom,o=e.contentComponent,a=e.setup,s=e.state,l=s.scale,c=a.limitToBounds,u=a.centerZoomedOut,d=a.zoomAnimation,f=a.wheel,p=a.disablePadding,v=a.smooth,m=d.size,P=d.disabled,w=f.step;if(!o)throw new Error("Component not mounted");r.cancelable&&r.preventDefault(),r.stopPropagation();var A=ya(r,null),C=v?w*Math.abs(r.deltaY):w,O=Ca(e,A,C,!r.ctrlKey);if(l!==O){var z=ce(e,O),Y=gn(r,o,l),N=P||m===0||u||p,M=c&&N,W=Et(e,Y.x,Y.y,O,z,M),q=W.x,B=W.y;e.previousWheelEvent=r,e.setState(O,q,B),F(L(e),r,n),F(L(e),r,i)}},ja=function(e,r){var t=e.props,n=t.onWheelStop,i=t.onZoomStop;it(e.wheelAnimationTimer),e.wheelAnimationTimer=setTimeout(function(){e.mounted&&(rr(e,r.x,r.y),e.wheelAnimationTimer=null,e.flushResizeAlignment())},Cn);var o=bn(e,r);o&&(it(e.wheelStopEventTimer),e.wheelStopEventTimer=setTimeout(function(){e.mounted&&(e.wheelStopEventTimer=null,F(L(e),r,n),F(L(e),r,i),e.flushResizeAlignment())},yn))},Aa=function(e,r){var t=e.props,n=t.onWheelStart,i=t.onPanningStart;ue(e),e.wheelStopEventTimer||(e.wheelAnimationTimer||ce(e,e.state.scale),F(L(e),r,n),F(L(e),r,i))},Ra=function(e,r){var t=e.props,n=t.onWheelStop,i=t.onPanningStop;it(e.wheelAnimationTimer),e.wheelAnimationTimer=setTimeout(function(){e.mounted&&(rr(e,r.x,r.y),e.wheelAnimationTimer=null,e.flushResizeAlignment())},Cn);var o=bn(e,r);o&&(it(e.wheelStopEventTimer),e.wheelStopEventTimer=setTimeout(function(){e.mounted&&(e.wheelStopEventTimer=null,F(L(e),r,n),F(L(e),r,i),e.flushResizeAlignment())},yn))},Sn=function(e){for(var r=0,t=0,n=0;n<2;n+=1)r+=e.touches[n].clientX,t+=e.touches[n].clientY;var i=r/2,o=t/2;return{x:i,y:o}},xa=function(e,r){var t=wn(r);e.pinchStartDistance=t,e.lastDistance=t,e.pinchStartScale=e.state.scale,e.isPanning=!1,e.isPinching=!0,e.pinchPreviousCenter=Sn(r),ue(e)},za=function(e,r){var t=e.contentComponent,n=e.pinchStartDistance,i=e.wrapperComponent,o=e.pinchPreviousCenter,a=e.state.scale,s=e.setup,l=s.limitToBounds,c=s.centerZoomedOut,u=s.zoomAnimation,d=s.autoAlignment,f=s.pinch,p=s.panning,v=u.disabled,m=u.size,P=f.allowPanning;if(!(n===null||!t)){var w=ka(r,a,t);if(!(!Number.isFinite(w.x)||!Number.isFinite(w.y))){var A=wn(r),C=Ta(e,A),O=Sn(r),z=a/C,Y=(O.x-((o==null?void 0:o.x)||0))*z,N=(O.y-((o==null?void 0:o.y)||0))*z;if(!(C===a&&Y===0&&N===0)){e.pinchPreviousCenter=O;var M=ce(e,C),W=v||m===0||c,q=l&&W,B=Et(e,w.x,w.y,C,M,q),y=B.x,E=B.y;if(e.pinchMidpoint=w,e.lastDistance=A,p.disabled||!P)e.setState(C,y,E);else{var R=d.sizeX,_=d.sizeY,D=Oe(e,R,C),Z=Oe(e,_,C),G=y+Y,se=E+N,me=Me(G,se,M,l,D,Z,i),le=me.x,we=me.y;e.setState(C,le,we)}}}}},Da=function(e){var r=e.pinchMidpoint;e.velocity=null,e.lastDistance=null,e.pinchMidpoint=null,e.pinchStartScale=null,e.pinchStartDistance=null,e.isPinching=!1,rr(e,r==null?void 0:r.x,r==null?void 0:r.y)},Pn=function(e,r){var t=e.props.onZoomStop,n=e.setup.doubleClick.animationTime;it(e.doubleClickStopEventTimer),e.doubleClickStopEventTimer=setTimeout(function(){e.doubleClickStopEventTimer=null,e.mounted&&F(L(e),r,t)},n)},Na=function(e,r){var t=e.props,n=t.onZoomStart,i=t.onZoom,o=e.setup.doubleClick,a=o.animationTime,s=o.animationType;F(L(e),r,n),ln(e,a,s,function(){return F(L(e),r,i)}),Pn(e,r)};function Ma(e,r){return e==="toggle"?r===1?1:-1:e==="zoomOut"?-1:1}function Ya(e,r){var t=e.setup,n=e.doubleClickStopEventTimer,i=e.state,o=e.contentComponent,a=i.scale,s=e.props,l=s.onZoomStart,c=s.onZoom,u=t.doubleClick,d=u.disabled,f=u.mode,p=u.step,v=u.animationTime,m=u.animationType;if(!d&&!n){if(f==="reset")return Na(e,r);if(!o)return console.error("No ContentComponent found");var P=Ma(f,e.state.scale),w=an(e,P,p);if(a!==w){F(L(e),r,l);var A=gn(r,o,a),C=Tt(e,w,A.x,A.y);if(!C)return console.error("Error during zoom event. New transformation state was not calculated.");F(L(e),r,c),Ae(e,C,v,m),Pn(e,r)}}}var Xa=function(e,r){var t=e.isInitialized,n=e.setup,i=e.wrapperComponent,o=n.doubleClick,a=o.disabled,s=o.excluded,l=r.target,c=i==null?void 0:i.contains(l),u=t&&l&&c&&!a;if(!u)return!1;var d=qe(l,s);return!(d||ir(l))},Wa=(function(){function e(r){var t=this;this.mounted=!0,this.onChangeCallbacks=new Set,this.onInitCallbacks=new Set,this.onTransformCallbacks=new Set,this.wrapperComponent=null,this.contentComponent=null,this.isInitialized=!1,this.bounds=null,this.previousWheelEvent=null,this.wheelStopEventTimer=null,this.wheelAnimationTimer=null,this.isPanning=!1,this.isWheelPanning=!1,this.startCoords=null,this.panStartPosition=null,this.lastTouch=null,this.isPinching=!1,this.distance=null,this.lastDistance=null,this.pinchStartDistance=null,this.pinchStartScale=null,this.pinchMidpoint=null,this.pinchPreviousCenter=null,this.doubleClickStopEventTimer=null,this.velocity=null,this.velocityTime=null,this.lastMousePosition=null,this.isAnimating=!1,this.animation=null,this.animationFrame=null,this.animationResolve=null,this.initObserverTimer=null,this.isInitialLayoutPending=!1,this.measuredSizes=null,this.isResizeAlignmentPending=!1,this.resizeAnimation=null,this.pressedKeys={},this.selectionLock=null,this.mount=function(){t.mounted=!0,t.initializeWindowEvents()},this.unmount=function(){t.mounted=!1,t.cleanupWindowEvents()},this.update=function(n){t.props=n,t.setup=Nr(n),t.wrapperComponent&&t.contentComponent&&!ma(t)&&ce(t,t.state.scale)},this.clearTimers=function(){t.wheelStopEventTimer&&clearTimeout(t.wheelStopEventTimer),t.wheelAnimationTimer&&clearTimeout(t.wheelAnimationTimer),t.doubleClickStopEventTimer&&clearTimeout(t.doubleClickStopEventTimer),t.initObserverTimer&&clearTimeout(t.initObserverTimer),t.wheelStopEventTimer=null,t.wheelAnimationTimer=null,t.doubleClickStopEventTimer=null,t.initObserverTimer=null},this.initializeWindowEvents=function(){var n,i,o,a,s=ft(),l=(n=t.wrapperComponent)===null||n===void 0?void 0:n.ownerDocument,c=l==null?void 0:l.defaultView;(i=t.wrapperComponent)===null||i===void 0||i.addEventListener("wheel",t.onWheelPanning,s),(o=t.wrapperComponent)===null||o===void 0||o.addEventListener("keyup",t.setKeyUnPressed,s),(a=t.wrapperComponent)===null||a===void 0||a.addEventListener("keydown",t.setKeyPressed,s),c==null||c.addEventListener("mousedown",t.onPanningStart,s),c==null||c.addEventListener("mousemove",t.onPanning,s),c==null||c.addEventListener("mouseup",t.onPanningStop,s),l==null||l.addEventListener("mouseleave",t.clearPanning,s),c==null||c.addEventListener("keyup",t.setKeyUnPressed,s),c==null||c.addEventListener("keydown",t.setKeyPressed,s),c==null||c.addEventListener("blur",t.handleWindowBlur)},this.cleanupWindowEvents=function(){var n,i,o,a,s,l=ft(),c=(n=t.wrapperComponent)===null||n===void 0?void 0:n.ownerDocument,u=c==null?void 0:c.defaultView;u==null||u.removeEventListener("mousedown",t.onPanningStart,l),u==null||u.removeEventListener("mousemove",t.onPanning,l),u==null||u.removeEventListener("mouseup",t.onPanningStop,l),c==null||c.removeEventListener("mouseleave",t.clearPanning,l),u==null||u.removeEventListener("keyup",t.setKeyUnPressed,l),u==null||u.removeEventListener("keydown",t.setKeyPressed,l),u==null||u.removeEventListener("blur",t.handleWindowBlur),(i=t.wrapperComponent)===null||i===void 0||i.removeEventListener("wheel",t.onWheelPanning,l),(o=t.wrapperComponent)===null||o===void 0||o.removeEventListener("keyup",t.setKeyUnPressed,l),(a=t.wrapperComponent)===null||a===void 0||a.removeEventListener("keydown",t.setKeyPressed,l),t.cleanupWrapperEvents(),t.clearTimers(),ue(t),t.unlockTextSelection(),(s=t.observer)===null||s===void 0||s.disconnect(),t.observer=void 0,t.isInitialLayoutPending=!1,t.isResizeAlignmentPending=!1,t.resizeAnimation=null},this.cleanupWrapperEvents=function(){var n=t.wrapperComponent;if(n){var i=ft();n.removeEventListener("wheel",t.onWheelZoom,i),n.removeEventListener("dblclick",t.onDoubleClick,i),n.removeEventListener("keydown",t.onKeyboardNavigation,i),n.removeEventListener("touchstart",t.onTouchPanningStart,i),n.removeEventListener("touchmove",t.onTouchPanning,i),n.removeEventListener("touchend",t.onTouchPanningStop,i)}},this.handleInitializeWrapperEvents=function(n){var i=ft();n.addEventListener("wheel",t.onWheelZoom,i),n.addEventListener("dblclick",t.onDoubleClick,i),n.addEventListener("keydown",t.onKeyboardNavigation,i),n.addEventListener("touchstart",t.onTouchPanningStart,i),n.addEventListener("touchmove",t.onTouchPanning,i),n.addEventListener("touchend",t.onTouchPanningStop,i)},this.handleInitialize=function(){var n=t.setup,i=n.centerOnInit,o=n.fitOnInit;if(t.applyTransformation(),t.onInitCallbacks.forEach(function(s){return s(L(t))}),i||o){var a=t.applyInitialLayout();t.isInitialLayoutPending=!0,t.initObserverTimer&&clearTimeout(t.initObserverTimer),a&&(t.initObserverTimer=setTimeout(function(){t.initObserverTimer=null,t.isInitialLayoutPending=!1},5e3))}},this.observeSizes=function(n,i){var o;(o=t.observer)===null||o===void 0||o.disconnect(),t.observer=void 0,t.measuredSizes=Lt(n,i),!(typeof ResizeObserver>"u")&&(t.observer=new ResizeObserver(t.onSizeChange),t.observer.observe(n),t.observer.observe(i))},this.onSizeChange=function(){var n=t,i=n.wrapperComponent,o=n.contentComponent;if(!(!t.mounted||!i||!o)){if(t.isInitialLayoutPending){var a=(o.offsetWidth>0||o.offsetHeight>0)&&i.clientWidth>0&&i.clientHeight>0;if(!a)return;t.isInitialLayoutPending=!1,t.initObserverTimer&&clearTimeout(t.initObserverTimer),t.initObserverTimer=null,t.onInitCallbacks.forEach(function(s){return s(L(t))}),t.applyInitialLayout(),t.measuredSizes=Lt(i,o),ce(t,t.state.scale);return}ga(t)}},this.flushResizeAlignment=function(){t.isResizeAlignmentPending&&(t.isResizeAlignmentPending=!1,mn(t))},this.onWheelZoom=function(n){var i=t.setup.disabled;if(!i){t.syncModifierKeys(n);var o=vn(t,n);o&&(Oa(t,n),_a(t,n),ja(t,n))}},this.onWheelPanning=function(n){var i=t.props.onPanning,o=t.setup.trackPadPanning,a=o.lockAxisX,s=o.lockAxisY;t.syncModifierKeys(n);var l=ba(t,n);if(l){n.cancelable&&n.preventDefault(),n.stopPropagation();var c=t.state,u=c.positionX,d=c.positionY,f=u-n.deltaX,p=d-n.deltaY,v=a?u:f,m=s?d:p,P=t.setup.autoAlignment,w=P.sizeX,A=P.sizeY,C=Oe(t,w),O=Oe(t,A);v===u&&m===d||(Aa(t,n),rn(t,v,m,C,O),F(L(t),n,i),Ra(t,n))}},this.onPanningStart=function(n){var i=t.setup,o=i.disabled,a=i.panning,s=t.props.onPanningStart;if(!(o||a.disabled)){t.syncModifierKeys(n);var l=jr(t,n);if(l){var c=t.isPressingKeys(t.setup.panning.activationKeys);c&&(n.button===0&&!t.setup.panning.allowLeftClickPan||n.button===1&&!t.setup.panning.allowMiddleClickPan||n.button===2&&!t.setup.panning.allowRightClickPan||(n.cancelable&&n.preventDefault(),n.stopPropagation(),ue(t),xr(t,n),t.lockTextSelection(),t.focusForKeyboard(),F(L(t),n,s)))}}},this.onPanning=function(n){var i=t.setup.disabled,o=t.props.onPanning;if(!i){if(t.syncModifierKeys(n),t.isPanning&&n.buttons===0){t.clearPanning(n);return}var a=Ar(t);if(a){var s=t.isPressingKeys(t.setup.panning.activationKeys);s&&(n.cancelable&&n.preventDefault(),n.stopPropagation(),zr(t,n.clientX,n.clientY,Te.MOUSE),F(L(t),n,o))}}},this.onPanningStop=function(n){var i=t.setup.panning.velocityDisabled,o=t.props.onPanningStop;t.isPanning&&(t.unlockTextSelection(),Wo(t,i),F(L(t),n,o),t.flushResizeAlignment())},this.onPinchStart=function(n){var i=t.setup.disabled,o=t.props.onPinchStart;if(!i){var a=Sa(t,n);a&&(xa(t,n),ue(t),F(L(t),n,o))}},this.onPinch=function(n){var i=t.setup.disabled,o=t.props.onPinch;if(!i){var a=Pa(t);a&&(n.cancelable&&n.preventDefault(),n.stopPropagation(),za(t,n),F(L(t),n,o))}},this.onPinchStop=function(n){var i=t.props.onPinchStop;t.pinchStartScale&&(Da(t),F(L(t),n,i),t.flushResizeAlignment())},this.onTouchPanningStart=function(n){var i=t.setup,o=i.disabled,a=i.doubleClick,s=t.props.onPanningStart;if(!o){var l=!(a!=null&&a.disabled),c=t.lastTouch&&+new Date-t.lastTouch<200;if(l&&c&&n.touches.length===1)t.lastTouch=null,t.onDoubleClick(n);else{t.lastTouch=+new Date,ue(t);var u=n.touches,d=u.length===1,f=u.length===2,p=jr(t,n);if(d){if(!p||t.setup.panning.disabled)return;ue(t),xr(t,n),t.lockTextSelection(),t.focusForKeyboard(),F(L(t),n,s)}f&&t.onPinchStart(n)}}},this.onTouchPanning=function(n){var i=t.setup.disabled,o=t.props.onPanning;if(t.isPanning&&n.touches.length===1){if(i)return;var a=Ar(t);if(!a)return;n.cancelable&&n.preventDefault(),n.stopPropagation();var s=n.touches[0];zr(t,s.clientX,s.clientY,Te.TOUCH),F(L(t),n,o)}else n.touches.length>1&&t.onPinch(n)},this.onTouchPanningStop=function(n){t.onPanningStop(n),t.onPinchStop(n)},this.onDoubleClick=function(n){var i=t.setup.disabled;if(!i){var o=Xa(t,n);o&&Ya(t,n)}},this.clearPanning=function(n){t.isPanning&&t.onPanningStop(n)},this.handleWindowBlur=function(){t.pressedKeys={},t.isPanning&&(t.isPanning=!1,t.startCoords=null),t.unlockTextSelection(),t.flushResizeAlignment()},this.syncModifierKeys=function(n){var i=n.ctrlKey,o=n.metaKey,a=n.shiftKey,s=n.altKey;typeof i=="boolean"&&(t.pressedKeys.Control=i),typeof o=="boolean"&&(t.pressedKeys.Meta=o),typeof a=="boolean"&&(t.pressedKeys.Shift=a),typeof s=="boolean"&&(t.pressedKeys.Alt=s)},this.setKeyPressed=function(n){t.pressedKeys[n.key]=!0},this.setKeyUnPressed=function(n){t.pressedKeys[n.key]=!1},this.isPressingKeys=function(n){return typeof n=="function"?n(Object.entries(t.pressedKeys).filter(function(i){var o=i[1];return o}).map(function(i){var o=i[0];return o})):n.length?!!n.every(function(i){return t.pressedKeys[i]}):!0},this.onKeyboardNavigation=function(n){pa(t,n)},this.focusForKeyboard=function(){var n,i=t.wrapperComponent;if(!(!i||t.setup.keyboard.disabled)){var o=(n=i.ownerDocument)===null||n===void 0?void 0:n.activeElement;o&&i.contains(o)||typeof i.focus=="function"&&i.focus({preventScroll:!0})}},this.lockTextSelection=function(){var n=t.wrapperComponent;!n||t.selectionLock||(t.selectionLock={userSelect:n.style.userSelect,webkitUserSelect:n.style.webkitUserSelect},n.style.userSelect="none",n.style.webkitUserSelect="none")},this.unlockTextSelection=function(){var n=t.selectionLock;t.selectionLock=null;var i=t.wrapperComponent;!i||!n||(i.style.userSelect=n.userSelect,i.style.webkitUserSelect=n.webkitUserSelect)},this.applyInitialLayout=function(){var n=t.setup.fitOnInit,i=t,o=i.wrapperComponent,a=i.contentComponent,s=!!o&&!!a&&o.clientWidth>0&&o.clientHeight>0&&(a.offsetWidth>0||a.offsetHeight>0);if(n){var l=nr(t,n==="cover"?"cover":"contain");if(l)return t.setState(l.scale,l.positionX,l.positionY),s}return t.setCenter(),s},this.setCenter=function(){if(t.wrapperComponent&&t.contentComponent){var n=Ot(t.state.scale,t.wrapperComponent,t.contentComponent);t.setState(n.scale,n.positionX,n.positionY)}},this.handleTransformStyles=function(n,i,o){return t.props.customTransform?t.props.customTransform(n,i,o):fn(n,i,o)},this.getContext=function(){return L(t)},this.applyTransformation=function(){if(!(!t.mounted||!t.contentComponent)){var n=t.state,i=n.scale,o=n.positionX,a=n.positionY,s=t.handleTransformStyles(o,a,i);t.props.detached||(t.contentComponent.style.transform=s),t.onTransformCallbacks.forEach(function(l){return l({scale:i,positionX:o,positionY:a,previousScale:t.state.previousScale,ref:L(t)})})}},this.setState=function(n,i,o){var a=t.props.onTransform;if(!Number.isNaN(n)&&!Number.isNaN(i)&&!Number.isNaN(o)){var s=Math.max(n,1e-7);s!==t.state.scale&&(t.state.previousScale=t.state.scale,t.state.scale=s),t.state.positionX=i,t.state.positionY=o,t.applyTransformation();var l=L(t);t.onChangeCallbacks.forEach(function(c){return c(l)}),F(l,{scale:t.state.scale,positionX:i,positionY:o},a)}else console.error("Detected NaN set state values")},this.onTransform=function(n){return t.onTransformCallbacks.has(n)||t.onTransformCallbacks.add(n),function(){t.onTransformCallbacks.delete(n)}},this.onChange=function(n){return t.onChangeCallbacks.has(n)||t.onChangeCallbacks.add(n),function(){t.onChangeCallbacks.delete(n)}},this.onInit=function(n){return t.onInitCallbacks.has(n)||t.onInitCallbacks.add(n),function(){t.onInitCallbacks.delete(n)}},this.init=function(n,i){t.mounted=!0,t.cleanupWindowEvents(),t.wrapperComponent=n,t.contentComponent=i,ce(t,t.state.scale),t.handleInitializeWrapperEvents(n),t.handleInitialize(),t.observeSizes(n,i),t.initializeWindowEvents(),t.isInitialized=!0;var o=L(t);F(o,void 0,t.props.onInit),ua(t.props.ref,o)},this.props=r,this.setup=Nr(this.props),this.state=on(this.props)}return e})(),lt=kt.createContext(null),Ba=function(e,r){return typeof e=="function"?e(r):e},La=kt.forwardRef(function(e,r){var t=g.useRef(null);t.current===null&&(t.current=new Wa(e));var n=t.current,i=Ba(e.children,nt(n));return g.useImperativeHandle(r,function(){return nt(n)},[n]),g.useEffect(function(){return n.mount(),function(){n.unmount()}},[n]),g.useEffect(function(){n.update(e)},[n,e]),h.jsx(lt.Provider,de({value:n},{children:i}))});kt.forwardRef(function(e,r){var t=g.useRef(null),n=g.useContext(lt);return or(function(){var i=function(o){if(t.current){var a=0,s=0;t.current.style.transform=n.handleTransformStyles(a,s,1/o)}};return i(n.state.scale),n.onChange(function(o){i(o.instance.state.scale)})},[n]),h.jsx("div",de({},e,{ref:ca([t,r])}))});function Fa(e,r){r===void 0&&(r={});var t=r.insertAt;if(!(typeof document>"u")){var n=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css",t==="top"&&n.firstChild?n.insertBefore(i,n.firstChild):n.appendChild(i),i.styleSheet?i.styleSheet.cssText=e:i.appendChild(document.createTextNode(e))}}var qa=`.transform-component-module_wrapper__SPB86 {
25
+ position: relative;
26
+ width: -moz-fit-content;
27
+ width: fit-content;
28
+ height: -moz-fit-content;
29
+ height: fit-content;
30
+ overflow: hidden;
31
+ -webkit-touch-callout: none; /* iOS Safari */
32
+ /* Text stays selectable (#467); the instance applies an inline lock
33
+ only while a pan gesture is active. */
34
+ margin: 0;
35
+ padding: 0;
36
+ transform: translate3d(0, 0, 0);
37
+ }
38
+ .transform-component-module_content__FBWxo {
39
+ display: flex;
40
+ flex-wrap: wrap;
41
+ width: -moz-fit-content;
42
+ width: fit-content;
43
+ height: -moz-fit-content;
44
+ height: fit-content;
45
+ margin: 0;
46
+ padding: 0;
47
+ transform-origin: 0% 0%;
48
+ }
49
+ .transform-component-module_content__FBWxo img {
50
+ pointer-events: none;
51
+ }
52
+ .transform-component-module_infiniteGrid__Z-aP3 {
53
+ position: absolute;
54
+ inset: 0;
55
+ pointer-events: none;
56
+ background-image: radial-gradient(
57
+ circle,
58
+ rgba(0, 0, 0, 0.12) 1px,
59
+ transparent 1px
60
+ );
61
+ background-size: 20px 20px;
62
+ background-position: 0 0;
63
+ }
64
+ `,Mt={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo",infiniteGrid:"transform-component-module_infiniteGrid__Z-aP3"};Fa(qa);var Ha=function(e){var r,t=e.children,n=e.wrapperClass,i=n===void 0?"":n,o=e.contentClass,a=o===void 0?"":o,s=e.wrapperStyle,l=e.contentStyle,c=e.wrapperProps,u=c===void 0?{}:c,d=e.contentProps,f=d===void 0?{}:d,p=e.infinite,v=p===void 0?!1:p,m=g.useContext(lt),P=m.init,w=m.cleanupWindowEvents,A=g.useRef(null),C=g.useRef(null),O=g.useRef(null);or(function(){var Y=A.current,N=C.current;return Y!==null&&N!==null&&P&&(P==null||P(Y,N)),function(){w==null||w()}},[]),g.useEffect(function(){if(v){var Y=O.current;if(Y){var N=function(){var M=m.state,W=M.positionX,q=M.positionY;Y.style.backgroundPosition="".concat(W,"px ").concat(q,"px")};return N(),m.onChange(N)}}},[v,m]);var z=!(!((r=m.setup.keyboard)===null||r===void 0)&&r.disabled);return h.jsxs("div",de({tabIndex:z?0:void 0},u,{ref:A,className:"".concat(Bt.wrapperClass," ").concat(Mt.wrapper," ").concat(i),style:s},{children:[v&&h.jsx("div",{ref:O,className:Mt.infiniteGrid,"aria-hidden":!0}),h.jsx("div",de({},f,{ref:C,className:"".concat(Bt.contentClass," ").concat(Mt.content," ").concat(a),style:de(de({transformOrigin:"0 0"},l),{transform:fn(m.state.positionX,m.state.positionY,m.state.scale)})},{children:t}))]}))};function Ua(e,r){var t=Math.max(0,Math.min(e.x+e.width,r.x+r.width)-Math.max(e.x,r.x)),n=Math.max(0,Math.min(e.y+e.height,r.y+r.height)-Math.max(e.y,r.y));return t*n}function Za(e){var r=e.elementX,t=e.elementY,n=e.elementWidth,i=e.elementHeight,o=e.scale,a=e.positionX,s=e.positionY,l=e.viewportWidth,c=e.viewportHeight,u=e.margin,d=u===void 0?0:u,f=e.threshold,p=f===void 0?0:f,v={x:-d,y:-d,width:l+2*d,height:c+2*d},m={x:r*o+a,y:t*o+s,width:n*o,height:i*o};if(p<=0){var P=m.x<v.x+v.width&&m.x+m.width>v.x,w=m.y<v.y+v.height&&m.y+m.height>v.y;return P&&w}var A=m.width*m.height;if(A<=0)return!1;var C=Ua(v,m);return C/A>=p}kt.forwardRef(function(e,r){var t=e.x,n=e.y,i=e.width,o=e.height,a=e.margin,s=a===void 0?0:a,l=e.threshold,c=l===void 0?0:l,u=e.placeholder,d=u===void 0?null:u,f=e.onShow,p=e.onHide,v=e.children,m=e.className,P=e.style,w=g.useContext(lt),A=function(){var W=w.wrapperComponent;return W?Za({elementX:t,elementY:n,elementWidth:i,elementHeight:o,scale:w.state.scale,positionX:w.state.positionX,positionY:w.state.positionY,viewportWidth:W.clientWidth,viewportHeight:W.clientHeight,margin:s,threshold:c}):!1},C=g.useState(A),O=C[0],z=C[1],Y=g.useRef(!1),N=g.useRef(f),M=g.useRef(p);return N.current=f,M.current=p,or(function(){var W=function(){var y,E;if(w.wrapperComponent){var R=A();R!==Y.current&&(Y.current=R,z(R),R?(y=N.current)===null||y===void 0||y.call(N):(E=M.current)===null||E===void 0||E.call(M))}};W();var q=w.onChange(W),B;return w.wrapperComponent||(B=w.onInit(function(){return W()})),function(){q(),B==null||B()}},[w,t,n,i,o,s,c]),O?h.jsx("div",de({ref:r,className:m,style:P},{children:v})):d?h.jsx(h.Fragment,{children:d}):null});var Va=function(){var e=g.useContext(lt);if(!e)throw new Error("Transform context must be placed inside TransformWrapper");return e},Ga=function(){var e=Va();return nt(e)};const $a=new Set(["http:","https:"]);function Ja(e){const r=/^([a-zA-Z][a-zA-Z0-9+.-]*):/.exec(e);return!r||r[1].length===1?null:`${r[1].toLowerCase()}:`}const Qa={image:"data:image/",pdf:"data:application/pdf"};function kn(e,r,t){const n=e.trim();if(n.startsWith("data:"))return n.toLowerCase().startsWith(Qa[r])?{url:n,error:null}:{url:null,error:"unsupported-data"};const i=Ja(n);if(i!==null)return $a.has(i)?{url:n,error:null}:{url:null,error:"blocked"};const o=t(n);return o?{url:o,error:null}:{url:null,error:"local-unavailable"}}function En(e,r){switch(e){case"blocked":return`This ${r} source is blocked for safety.`;case"unsupported-data":return`This data URI isn’t a valid ${r} source.`;case"local-unavailable":return`Local ${r} files can’t be displayed here.`}}function Ka({content:e}){const r=pe(),t=K(u=>u.selectedCwd),n=g.useMemo(()=>kn(e.src,"image",u=>r.mediaUrl(t??"",u)),[e.src,r,t]),[i,o]=g.useState("loading"),[a,s]=g.useState(e.src);a!==e.src&&(s(e.src),o("loading"));const l=e.alt??e.title??"Canvas image";if(n.url===null){const u=n.error?En(n.error,"image"):"";return h.jsx(Mr,{children:u})}const c=n.url;return h.jsxs("div",{className:"bg-muted/40 relative flex h-full items-center justify-center",children:[i==="loading"&&h.jsx("p",{className:"text-muted-foreground absolute text-sm","aria-live":"polite",children:"Loading image…"}),i==="error"?h.jsx(Mr,{children:"This image couldn’t be loaded."}):h.jsxs(La,{centerOnInit:!0,doubleClick:{mode:"toggle"},wheel:{step:.15},children:[h.jsx(Ia,{}),h.jsx(Ha,{wrapperClass:"!h-full !w-full",contentClass:"!h-full !w-full flex items-center justify-center",children:h.jsx("img",{src:c,alt:l,onLoad:()=>o("loaded"),onError:()=>o("error"),className:It("max-h-full max-w-full object-contain transition-opacity",i==="loaded"?"opacity-100":"opacity-0")})})]})]})}function Ia(){const{zoomIn:e,zoomOut:r,resetTransform:t}=Ga();return h.jsxs("div",{className:"absolute top-2 right-2 z-10 flex gap-1",children:[h.jsx(Yt,{label:"Zoom in",onClick:()=>e(),children:h.jsx(mi,{className:"size-4"})}),h.jsx(Yt,{label:"Zoom out",onClick:()=>r(),children:h.jsx(vi,{className:"size-4"})}),h.jsx(Yt,{label:"Reset zoom",onClick:()=>t(),children:h.jsx(hi,{className:"size-4"})})]})}function Yt({label:e,onClick:r,children:t}){return h.jsx("button",{type:"button",onClick:r,"aria-label":e,className:"bg-background/80 text-muted-foreground hover:text-foreground focus-ring rounded-md border p-1.5 backdrop-blur transition-colors",children:t})}function Mr({children:e}){return h.jsx("div",{className:"text-muted-foreground flex h-full items-center justify-center p-8 text-center",children:h.jsx("p",{children:e})})}function es({content:e}){const r=pe(),t=K(a=>a.selectedCwd),n=g.useMemo(()=>kn(e.src,"pdf",a=>r.mediaUrl(t??"",a)),[e.src,r,t]);if(n.url===null){const a=n.error?En(n.error,"pdf"):"";return h.jsx("div",{className:"text-muted-foreground flex h-full items-center justify-center p-8 text-center",children:h.jsx("p",{children:a})})}const i=n.url,o=e.title??"PDF document";return h.jsx("object",{data:i,type:"application/pdf",title:o,className:"h-full w-full",children:h.jsxs("div",{className:"text-muted-foreground flex h-full flex-col items-center justify-center gap-3 p-8 text-center",children:[h.jsx("p",{children:"This PDF can’t be shown here."}),h.jsxs("a",{href:i,target:"_blank",rel:"noreferrer",className:"text-foreground focus-ring rounded-md underline underline-offset-4",children:["Open ",o," in a new tab"]})]})})}function ts(e){const r=/^([a-zA-Z][a-zA-Z0-9+.-]*):/.exec(e);return!r||r[1].length===1?null:`${r[1].toLowerCase()}:`}const rs=new Set(["http:","https:","data:"]);function Tn(e,r,t){const n=e.trim(),i=ts(n);return i!==null?rs.has(i)?i==="data:"&&t!==void 0?n.toLowerCase().startsWith(t)?{url:n}:{url:null}:{url:n}:{url:null}:{url:r(n)}}function ns({content:e}){const r=pe(),t=K(o=>o.selectedCwd),n=g.useMemo(()=>Tn(e.src,o=>r.mediaUrl(t??"",o),"data:audio/"),[e.src,r,t]),i=e.title??"Canvas audio";return n.url===null?h.jsx("div",{className:"text-muted-foreground flex h-full items-center justify-center p-8 text-center",children:h.jsx("p",{children:"This audio can’t be played here."})}):h.jsx("div",{className:"bg-muted/40 flex h-full w-full items-center justify-center p-8",children:h.jsx("audio",{controls:!0,src:n.url,"aria-label":i,className:"w-full max-w-2xl",children:h.jsxs("p",{className:"text-muted-foreground text-sm",children:["Your browser can’t play this audio."," ",h.jsxs("a",{href:n.url,className:"text-foreground underline underline-offset-4",children:["Download ",i]}),"."]})})})}function is({content:e}){const r=pe(),t=K(o=>o.selectedCwd),n=g.useMemo(()=>Tn(e.src,o=>r.mediaUrl(t??"",o),"data:video/"),[e.src,r,t]),i=e.title??"Canvas video";return n.url===null?h.jsx("div",{className:"text-muted-foreground flex h-full items-center justify-center p-8 text-center",children:h.jsx("p",{children:"This video can’t be played here."})}):h.jsx("div",{className:"bg-muted/40 flex h-full w-full items-center justify-center",children:h.jsx("video",{controls:!0,src:n.url,"aria-label":i,className:"max-h-full w-full max-w-full object-contain",children:h.jsxs("p",{className:"text-muted-foreground p-8 text-sm",children:["Your browser can’t play this video."," ",h.jsxs("a",{href:n.url,className:"text-foreground underline underline-offset-4",children:["Download ",i]}),"."]})})})}function On({content:e,documentId:r,channel:t}){const[n]=Kt(),i=ii(e.definition),o=g.useMemo(()=>JSON.stringify(e.definition),[e.definition]);return h.jsx("div",{className:"p-4",children:i.ok?h.jsx(oi,{channel:t,document:i.document,sessionId:n??void 0},t?r??t.documentId:o):h.jsx(ai,{error:i.error,raw:i.raw})})}const ot=et().min(1).max(128),ve={protocol:Q("dorkos-doc"),v:Q(1),nonce:ot,requestToken:ot,loadToken:Wt,generation:Ur.shape.generation};Pt("kind",[ie({...ve,kind:Q("challenge")}).strict(),ie({...ve,kind:Q("ack")}).strict(),ie({...ve,kind:Q("connect")}).strict()]);Pt("kind",[ie({...ve,kind:Q("emit"),requestId:ot,event:gt}).strict(),ie({...ve,kind:Q("retire")}).strict()]);Pt("kind",[ie({...ve,kind:Q("receipt"),requestId:ot,receipt:Zr}).strict(),ie({...ve,kind:Q("refused"),requestId:ot,outcome:wr(["cancelled","unconfirmed","refused"])}).strict(),ie({...ve,kind:Q("state"),state:li,stateRev:Wt,docSeq:Wt,reset:yr()}).strict(),ie({...ve,kind:Q("event"),frame:ui}).strict(),ie({...ve,kind:Q("status"),status:wr(["connecting","ready","offline","revoked"]),unconfirmed:yr()}).strict()]);function os(e,r){try{if(si(r,1048576)!==void 0)return null;const t=e.safeParse(r);return t.success?t.data:null}catch{return null}}class as{constructor(){ee(this,"contiguous",0);ee(this,"through",0);ee(this,"pending",new Map)}get highest(){return this.contiguous}get catchUpThrough(){return this.through}get pendingCount(){return this.pending.size}reset(){this.contiguous=0,this.through=0,this.pending.clear()}resetHighest(){this.contiguous=0}advance(r){this.contiguous=Math.max(this.contiguous,r)}markThrough(r){this.through=Math.max(this.through,r)}recordGap(r){return this.markThrough(r.docSeq),this.pending.set(r.docSeq,r),this.pending.size<=200?!1:(this.pending.clear(),!0)}takeNextContiguous(){for(const n of this.pending.keys())n<=this.contiguous&&this.pending.delete(n);const r=this.contiguous+1,t=this.pending.get(r);return t&&this.pending.delete(r),t}clearReachedTarget(){return this.contiguous<this.through?!1:(this.through=0,!0)}}const qt=new WeakMap,ut=new WeakMap,Se=new WeakMap,Ke=new WeakMap;function _e(e){Ye(e);const r=qt.get(e);if(!r)throw new Error("Replay owner lifetime is absent.");return r}function ss(e,r){const t=ut.get(r);if(!t||t.owner!==e)throw new Error("Replay run is foreign.");return t}function _n(e){if(e&&typeof e=="object"&&!Object.isFrozen(e)){for(const r of Object.values(e))_n(r);Object.freeze(e)}return e}function ls(e){if(Ye(e),qt.has(e))throw new Error("Replay owner lifetime is already initialized.");qt.set(e,new as)}function ar(e){const r=_e(e);return Object.freeze({highest:r.highest,through:r.catchUpThrough,pending:r.pendingCount})}function Yr(e){_e(e).reset()}function Xr(e,r){const t=ut.get(r);if(!(!t||t.owner!==e))return Object.freeze({subject:t.subject,epoch:t.epoch,revision:t.revision,observation:t.observation,ended:t.ended})}function us(e,r,t){const n=Se.get(t),i=ut.get(r);if(!(!i||i.owner!==e||!n||n.owner!==e||n.run!==r||n.phase!=="consuming"||n.admissionRead||!re(e,r)))return n.admissionRead=!0,Object.freeze({response:n.response,since:n.since,revision:n.revision,observation:n.observation,targetBirth:i.targetBirth})}function cs(e,r,t){const n=ss(e,r),i=Se.get(t),o=zn(e,r,t);if(!o||!i||i.owner!==e||i.run!==r||i.phase!=="consuming"||!i.admissionRead||n.ended||n.epoch!==o.epoch||n.subject!==o.previous)throw new Error("Replay own issuance is foreign or stale.");n.subject=o.subject}function jn(e,r,t,n){if(!re(e,r))return;if(n){const o=Ke.get(t);return o&&o.owner===e&&o.run===r&&o.phase==="dispatching"&&!o.advanced?o.frame:void 0}const i=Se.get(t);return i&&i.owner===e&&i.run===r&&i.phase==="frames"&&i.dispatching!==void 0&&!i.advanced?i.frames[i.dispatching]:void 0}function ds(e,r,t,n){const i=Xs(e,r,t,n);if(!i||!re(e,r))throw new Error("Replay cursor advance has no genuine core witness.");const o=n?Ke.get(t):Se.get(t);if(!o||o.advanced)throw new Error("Replay frame advance was consumed.");o.advanced=!0,_e(e).advance(i.docSeq)}function fs(e,r){const t=ut.get(r),n=(t==null?void 0:t.lastPage)&&Se.get(t.lastPage);if(!t||t.owner!==e||!re(e,r)||t.target===void 0||!n||n.phase!=="finished"||n.next!==n.frames.length||n.response.events.length>=200&&_e(e).highest<t.target)return;const i=_e(e);return Object.freeze({highest:i.highest,through:i.catchUpThrough,target:t.target})}function ps(e,r){const t=st(e,r);if(!t)throw new Error("Replay notice is foreign or stale.");const n=_e(e),i=t.notification;if(t.mode==="quarantine")n.markThrough(i.type==="canvas_channel_snapshot"?i.snapshot.highWatermark:i.docSeq),i.type!=="canvas_channel_snapshot"&&n.recordGap(i);else{if(t.mode==="gap"&&i.type!=="canvas_channel_snapshot")return n.recordGap(i);t.mode==="event"&&Qs(e,r)}return!1}function hs(e,r){const t=st(e,r);if(!t||t.mode!=="event"||t.notification.type==="canvas_channel_snapshot")throw new Error("Notice cursor advance is foreign.");_e(e).advance(t.notification.docSeq)}function ms(e){const r=fe(e),t=_e(e),n=Object.freeze({}),i={owner:e,subject:r.subject,epoch:r.epoch,revision:r.revision,observation:r.observation,ended:!1,starting:t.highest,succeeded:!1};ut.set(n,i),Fs(e,n);const o=()=>re(e,n),a=()=>fe(e).live?o()?void 0:"restart":"stop";return Object.freeze({async readPage(){if(!o())return null;const s=fe(e),l=t.highest,c=_t(e),u=c.getCanvasChannel;if(!o())return null;const d=await u.call(c,r.documentId,{since:l,limit:200});if(!o())return null;const f=_n(ci.parse(d));if(!o())return null;const p=Object.freeze({});return Se.set(p,{owner:e,run:n,response:f,since:l,revision:s.revision,observation:s.observation,phase:"read",admissionRead:!1,frames:[],next:0,advanced:!1}),p},consumePage(s){const l=Se.get(s);return!o()||!l||l.owner!==e||l.run!==n||l.phase!=="read"?{kind:"done"}:(l.phase="consuming",qs(e,n,s)!=="accepted"||!o()?(l.phase="finished",{kind:"done"}):(i.target??(i.target=l.response.highWatermark),i.targetBirth=l.response.incarnation,l.frames=Object.freeze(l.response.events.filter(u=>u.docSeq<=i.target)),l.phase="frames",i.lastPage=s,l.response.resetRequired&&t.advance(l.response.retentionFloor-1),{kind:"frames",count:l.frames.length}))},advancePageFrame(s,l){const c=Se.get(s);if(!o()||!c||c.owner!==e||c.run!==n||c.phase!=="frames"||l!==c.next||!c.frames[l])return!1;c.next=l+1,c.dispatching=l,c.advanced=!1;try{return Br(e,n,s,!1)&&o()}finally{c.dispatching=void 0}},finishPage(s){const l=Se.get(s);if(!o()||!l||l.owner!==e||l.run!==n||l.phase!=="frames"||l.next!==l.frames.length||i.target===void 0)return"done";if(l.phase="finished",l.response.events.length<200||t.highest>=i.target)return t.advance(i.target),!o()||(Lr(e,n),!o())||(i.succeeded=!0),"done";if(t.highest<=l.since)throw new Error("Document replay made no progress.");return"again"},failed(){o()&&Hs(e,n)},beginFinalization(){return a()??(i.succeeded?"drain":"stop")},takePending(){if(!o())return null;const s=t.takeNextContiguous();if(!s||!o())return null;const l=Object.freeze({});return Ke.set(l,{owner:e,run:n,frame:s,phase:"taken",advanced:!1}),l},advancePending(s){const l=Ke.get(s);if(!o()||!l||l.owner!==e||l.run!==n||l.phase!=="taken")return!1;l.phase="dispatching";try{return Br(e,n,s,!0)&&o()}finally{l.phase="finished",Ke.delete(s)}},finishFinalization(){const s=a();if(s)return s;if(t.clearReachedTarget()){const l=a();if(l)return l;Lr(e,n);const c=a();if(c)return c}if(t.pendingCount||t.catchUpThrough>t.highest){const l=fe(e);if(t.highest>i.starting||l.revision>i.revision||l.observation>i.observation)return"restart";Us(e,n)}return a()??"stop"},current:o,end:()=>{i.ended=!0}})}var be,Ut,$e;class Ht{constructor(){gr(this,be);ee(this,"current",null);ee(this,"token",0);ee(this,"retiring",!1);ee(this,"subscribers",new Set);ee(this,"resources",new Map);ee(this,"doc",null);ee(this,"docClaims",new WeakMap);ee(this,"retiringDoc",!1);ee(this,"docResources",new Map);ee(this,"bindings",new WeakSet)}getCurrent(){return this.current}observeHostContext(r){if(this.retiring)return null;if(!r.transportOwner||typeof r.transportOwner!="object"||!Number.isSafeInteger(r.publisherEpoch)||r.publisherEpoch<0)throw new Error("Explicit transport owner and epoch required.");const t=["frame","documentId","resolvedSource","logicalUrl","reloadKey","sessionId","eligibility","exactOrigin","transportOwner","publisherEpoch"];if(t.some(i=>!Object.hasOwn(r,i))||typeof r.documentId!="string"||!r.documentId||typeof r.logicalUrl!="string"||typeof r.reloadKey!="string")throw new Error("Complete host context required.");const n=this.current;return n&&t.every(i=>Object.is(n[i],r[i]))?n:(this.retire(),this.current=Object.freeze({...r,token:this.token,loaded:!1}),this.current)}observeLoaded(r){return this.retiring||this.current!==r||!r.frame?null:(this.retire(),this.current=Object.freeze({...r,token:this.token,loaded:!0}),this.current)}retire(){if(this.retiring)return;const r=this.current;this.current=null;const t=this.doc;this.doc=null,this.token++,this.retiring=!0;const n=[...r?this.resources.get(r)??[]:[],...t?this.docResources.get(t)??[]:[],...this.subscribers];t&&this.docResources.delete(t),r&&this.resources.delete(r);try{for(const i of n)try{const o=i();o&&typeof o.then=="function"&&Promise.resolve(o).catch(()=>{})}catch{}}finally{this.retiring=!1}}subscribe(r){return this.subscribers.add(r),()=>{this.subscribers.delete(r)}}own(r,t){if(this.retiring||this.current!==r)throw new Error("Frame observation retired.");const n=this.resources.get(r)??new Set;return n.add(t),this.resources.set(r,n),()=>{n.delete(t)}}bindDoc(r,t,n){return xe(this,be,Ut).call(this,r,t,n)}acquireDoc(r,t,n){const i=xe(this,be,Ut).call(this,r,t,n),o=Object.freeze({});this.docClaims.set(i,o);let a=!1;return Object.freeze({binding:i,release:()=>{a||(a=!0,this.docClaims.get(i)===o&&(this.docClaims.delete(i),this.doc===i&&this.bindings.has(i)&&xe(this,be,$e).call(this)))}})}disableDoc(){xe(this,be,$e).call(this)}retireDoc(r){this.doc===r&&this.bindings.has(r)&&xe(this,be,$e).call(this)}ownDoc(r,t){if(!this.isCurrent(r))throw new Error("Doc binding retired.");const n=this.docResources.get(r)??new Set;return n.add(t),this.docResources.set(r,n),()=>{n.delete(t)}}isCurrent(r){return!this.retiring&&!this.retiringDoc&&this.doc===r&&this.bindings.has(r)&&this.current===r.observation}}be=new WeakSet,Ut=function(r,t,n){const i=this.doc,o=this.token,a=os(Ur,t);if(!a)throw this.disableDoc(),new Error("Established server Doc birth required.");const s=a,l=r.exactOrigin,c=r.eligibility==="served-document"?l==="null":r.eligibility==="preview-listener"&&l!==null&&new URL(l).origin===l;if(!r.loaded||!r.frame||typeof r.frame.postMessage!="function"||!r.resolvedSource||!c||r.documentId!==s.documentId||!n||n.length>200)throw new Error("Loaded eligible frame and established Doc birth required.");if(this.retiring||this.retiringDoc||this.current!==r||this.doc!==i||this.token!==o)throw new Error("Frame observation retired during Doc admission.");if(this.doc){if(this.doc.observation!==r)throw new Error("Doc binding belongs to another host load.");if(te(this.doc.incarnation,s)&&this.doc.scope===n)return this.doc;throw this.retire(),new Error("Doc birth changed; a fresh host load is required.")}const u=Object.freeze({observation:r,incarnation:Object.freeze(s),scope:n});try{return this.doc=u,this.bindings.add(u),u}catch(d){throw this.doc===u&&xe(this,be,$e).call(this),d}},$e=function(){if(this.retiringDoc)return;const r=this.doc;this.doc=null,this.retiringDoc=!0;const t=[...r?this.docResources.get(r)??[]:[]];r&&this.docResources.delete(r);try{for(const n of t)try{const i=n();i&&typeof i.then=="function"&&Promise.resolve(i).catch(()=>{})}catch{}}finally{this.retiringDoc=!1}};function vs(e,r,t){if(!t||typeof t.captureOriginal!="function"||typeof t.submit!="function"||typeof t.inspect!="function"||typeof t.isCurrentOwner!="function"||t.owner!==r.observation.transportOwner||t.publisherEpoch!==r.observation.publisherEpoch)throw new Error("Explicit current transport submit and inspect ports required.");const{owner:n,publisherEpoch:i,isCurrentOwner:o,submit:a,inspect:s,captureOriginal:l}=t,c=Object.freeze({expectedGeneration:r.incarnation.generation}),u=()=>{try{return e.isCurrent(r)?o(n,i)===!0&&e.isCurrent(r):!1}catch{return!1}};if(!u())throw new Error("Doc binding unavailable.");const d=()=>{if(!u())throw new Error("Doc binding retired.")};return Object.freeze({binding:r,current:u,captureOriginal:f=>{d();const p=f.id;d();const v=f.bytes;d();const m=Reflect.apply(l,t,[Object.freeze({id:p,bytes:v})]);if(d(),!m)return null;const P=m.id;d();const w=m.bytes;d();const A=m.submit;d();const C=m.inspect;return d(),P!==p||w!==v||typeof A!="function"||typeof C!="function"?null:Object.freeze({id:p,bytes:v,submit:async O=>{d(),O.throwIfAborted();const z=await Reflect.apply(A,m,[O]);return d(),O.throwIfAborted(),z},inspect:async O=>{d(),O.throwIfAborted();const z=await Reflect.apply(C,m,[O]);return d(),O.throwIfAborted(),z}})},retireObservation:()=>{u()&&e.retire()},onRetire:f=>e.ownDoc(r,f),submit:(f,p)=>(d(),p.throwIfAborted(),a(f,c,p)),inspect:(f,p)=>(d(),p.throwIfAborted(),s(f,c,p))})}class gs{constructor(){ee(this,"revision",0);ee(this,"draining",!1);ee(this,"cleanup");ee(this,"subscribers",new Set);ee(this,"retirements",new WeakMap)}captureRetirement(){const r=Object.freeze({}),t=++this.revision,n=this.cleanup;return this.cleanup=void 0,this.retirements.set(r,{revision:t,cleanup:n,callbacks:this.draining?[]:[...this.subscribers]}),r}drainRetirement(r){const t=this.retirements.get(r);if(!t)throw new Error("Frame resource retirement is foreign or consumed.");this.retirements.delete(r);const n=this.draining;this.draining=!0;try{this.drain(t.cleanup);for(const i of t.callbacks)this.drain(i)}finally{this.draining=n}}begin(){const r=this.captureRetirement(),t=this.revision;return this.drainRetirement(r),t}once(r,t,n){let i=!1;return()=>{if(i||(i=!0,!this.current(r)||!t()||!this.current(r)))return null;const o=n();return!this.current(r)||!t()||!this.current(r)?null:o}}drain(r){try{Promise.resolve(r==null?void 0:r()).catch(()=>{})}catch{}}current(r){return this.revision===r}install(r,t){return this.current(r)?(this.cleanup=t,!0):!1}subscribe(r){return this.subscribers.add(r),()=>{this.subscribers.delete(r)}}}function bs(e,r,t){const n=()=>e.current(r)&&t.current()===!0&&e.current(r),i=e.once(r,n,t.complete);return Object.freeze({completeLoad:()=>{const o=i();return!o||!n()||t.accept(o)!==!0||!n()?null:o}})}function ws(e,r,t){const n=()=>e.current(r)&&t.current()===!0&&e.current(r);if(!n())return null;const i=t.acquire();if(!i)return null;let o=!1,a=null,s;try{const l=i.binding;if(n()&&t.bindingCurrent(l)===!0&&n()){const c=t.createPort(l);n()&&t.portCurrent(c)===!0&&n()&&e.install(r,i.release)&&(o=!0,a=c)}}catch(l){s={cause:l}}if(!o)try{i.release()}catch(l){s??(s={cause:l})}if(s)throw s.cause;return a}function ys(e){const r=()=>Object.assign(new Error("Document actions are unavailable."),{status:409}),t=(i,o)=>{if(o.aborted||!e.current(i)||o.aborted)throw r()},n=(i,o)=>{const a=Zr.parse(o);if(a.receipt.id!==i)throw new Error("Document receipt does not match this action.");return a};return Object.freeze({current:e.current,submit:async(i,o)=>{const a=gt.parse(JSON.parse(JSON.stringify(i))),s=a.id;t("submit",o);const l=await e.submit(a,o);t("read",o);const c=n(s,l);return t("read",o),c},inspect:async(i,o)=>{t("read",o);const a=await e.inspect(i,o);t("read",o);const s=n(i,a);return t("read",o),s},captureOriginal:i=>{const o=gt.parse(JSON.parse(JSON.stringify(i))),a=o.id,s=JSON.stringify(o);if(!e.current("submit"))return null;const l=e.capture(o,s);if(!l||!e.current("submit")||!l.current("submit"))return null;let c=!1;const u=d=>l.current(d)===!0;return Object.freeze({id:a,bytes:s,current:u,submit:async d=>{if(c||d.aborted||!u("submit"))throw r();c=!0;const f=await l.submit(JSON.parse(s),d);if(d.aborted||!u("read"))throw r();const p=n(a,f);if(d.aborted||!u("read"))throw r();return p},inspect:async d=>{if(d.aborted||!u("read"))throw r();const f=await l.inspect(a,d);if(d.aborted||!u("read"))throw r();const p=n(a,f);if(d.aborted||!u("read"))throw r();return p}})}})}function Cs(e){return Object.freeze({id:e.id,bytes:e.bytes,submit:async r=>{try{return{kind:"accepted",receipt:await e.submit(r)}}catch{return{kind:"uncertain"}}},inspect:async r=>{try{return{kind:"accepted",receipt:await e.inspect(r)}}catch{return{kind:"unknown"}}}})}function Ss(e,r,t){const n=gt.parse(JSON.parse(e.bytes));if(n.id!==e.id||JSON.stringify(n)!==e.bytes||!t())return null;const i=r(n);return!t()||!i?null:Cs(i)}const Ps=Ht.prototype.acquireDoc,wt=new WeakMap,Zt=new WeakMap;function ks(e,r){const t=_t(e),n=new WeakMap,i=(a,s)=>r.current(s)&&Ee(e,a,!0);return Object.freeze({prepareFrameLoad:(a,s)=>{var f;if(!(a instanceof Ht)||s.loaded)return null;const l=Wr(e),c=l?(f=De(e,l))==null?void 0:f.httpBaseline:void 0,u=r.begin();if(!l||!c||!r.current(u)||!Ee(e,l,!0)||a.getCurrent()!==s||s.transportOwner!==t||!i(l,u))return null;let d=null;return bs(r,u,{current:()=>{var p;return Ee(e,l,!0)&&((p=De(e,l))==null?void 0:p.httpBaseline)===c&&a.getCurrent()===(d??s)&&r.current(u)&&Ee(e,l,!0)},complete:()=>(d=a.observeLoaded(s),d),accept:p=>{var v,m;return!r.current(u)||!Ee(e,l,!0)||((v=De(e,l))==null?void 0:v.httpBaseline)!==c||a.getCurrent()!==p||!r.current(u)||!Ee(e,l,!0)||((m=De(e,l))==null?void 0:m.httpBaseline)!==c?!1:(n.set(p,{record:l,birth:c.birth}),!0)}})},subscribeInvalidation:a=>r.subscribe(a),attachFrame:(a,s)=>{if(!(a instanceof Ht))return null;const l=Wr(e),c=r.begin();if(!l||!r.current(c)||!Ee(e,l,!0)||a.getCurrent()!==s||s.transportOwner!==t||!i(l,c))return null;const u=n.get(s);return!u||u.record!==l||!te(u.birth,De(e,l).birth)?null:ws(r,c,{current:()=>i(l,c),acquire:()=>{const d=Ps.call(a,s,De(e,l).birth,De(e,l).birth.documentId);let f=!1,p=null,v;try{i(l,c)&&a.getCurrent()===s&&i(l,c)&&(p=Object.freeze({binding:d.binding,release:d.release}),f=!0)}catch(m){v={cause:m}}if(!f)try{d.release()}catch(m){v??(v={cause:m})}if(v)throw v.cause;return p},bindingCurrent:d=>a.isCurrent(d)&&i(l,c),createPort:d=>vs(a,d,{owner:t,publisherEpoch:s.publisherEpoch,isCurrentOwner:(f,p)=>f===t&&p===s.publisherEpoch&&r.current(c)&&Ee(e,l),captureOriginal:f=>Ss(f,p=>{var v;return((v=Ls(e,l))==null?void 0:v.captureOriginal(p))??null},()=>i(l,c)),submit:async()=>({kind:"terminal"}),inspect:async()=>({kind:"unknown"})}),portCurrent:d=>d.current()&&i(l,c)})}})}function Es(e){if(Ye(e),wt.has(e))throw new Error("Frame owner is already initialized.");const r=new gs,t=ks(e,r);return wt.set(e,{frames:r,facade:t}),t}function Ts(e){var r;return Ye(e),(r=wt.get(e))==null?void 0:r.facade}function Je(e){Ye(e);const r=wt.get(e);if(!r)return;const t=Object.freeze({});return Zt.set(t,{owner:e,frames:r.frames,ticket:r.frames.captureRetirement()}),t}function Qe(e,r){if(!r)return;const t=Zt.get(r);if(!t||t.owner!==e)throw new Error("Frame retirement is foreign or consumed.");Zt.delete(r),t.frames.drainRetirement(t.ticket)}function An(e,r){const t=ye(e,r),n=Ys(e,r);if(!(!t||!n))return{owner:r,verified:t.verified,...ys(n)}}function ge(e,r){return{documentId:e,transport:r,events:[],available:!1}}function Os(e,r,t,n,i,o){var l,c;const a=e.documentId===t&&e.transport===n?e:ge(t,n);if(a.snapshot&&(r.highWatermark<a.snapshot.highWatermark||r.stateRev<a.snapshot.stateRev))return a;const s=new Map((((l=a.snapshot)==null?void 0:l.receipts)??[]).filter(u=>u.receipt.docSeq>=r.receiptRetentionFloor).map(u=>[u.receipt.id,u]));for(const u of r.receipts)s.set(u.receipt.id,u);return{...a,available:o,snapshot:{...r,...i?{}:{routing:(c=a.snapshot)==null?void 0:c.routing},receipts:[...s.values()].sort((u,d)=>d.receipt.docSeq-u.receipt.docSeq).slice(0,400)},events:r.resetRequired?a.events.filter(u=>u.docSeq>=r.retentionFloor):a.events}}function _s(e){var t,n,i,o,a,s,l,c,u,d,f,p;const r=async()=>{throw Object.assign(new Error("Document actions are unavailable."),{status:409})};return{documentId:e.documentId,enabled:e.available&&((t=e.binding)==null?void 0:t.verified)===!0&&((i=(n=e.snapshot)==null?void 0:n.routing)==null?void 0:i.enabled)===!0,submissionOwner:(o=e.binding)==null?void 0:o.owner,current:((a=e.binding)==null?void 0:a.current)??(()=>!1),approvedEventTypes:e.available?((l=(s=e.snapshot)==null?void 0:s.routing)==null?void 0:l.approvedEventTypes)??[]:[],destinationLabel:e.available?((u=(c=e.snapshot)==null?void 0:c.routing)==null?void 0:u.destinationLabel)??"Actions unavailable":"Actions unavailable",...e.snapshot?{snapshot:e.snapshot}:{},submit:((d=e.binding)==null?void 0:d.submit)??r,inspect:((f=e.binding)==null?void 0:f.inspect)??r,captureOriginal:(p=e.binding)==null?void 0:p.captureOriginal}}function js(e,r,t){return!!(e&&r&&t.incarnation&&te(r,t.incarnation)&&(t.highWatermark<e.highWatermark||t.stateRev<e.stateRev))}function Rn(e,r,t,n){const i=e.documentId===t&&e.transport===n?e:ge(t,n);return{...i,events:[...i.events,r].slice(-200)}}function As(e,r){if(e.incarnation&&(e.incarnation.documentId!==r||e.events.some(t=>t.documentId!==r||!t.incarnation||!te(e.incarnation,t.incarnation))))throw new Error("Document replay identity changed.")}const Vt=new WeakMap;function Rs(e,r,t){const n=us(e,r,t);if(n)return Vt.set(t,{owner:e,run:r,witness:n}),n}const xn=new WeakMap,at=new WeakMap,Gt=new WeakMap,$t=new WeakMap;function Pe(e,r){Ye(e);const t=r??at.get(e),n=t&&xn.get(t);return n&&n.owner===e&&at.get(e)===t&&n.active?n:void 0}function J(e){return Ye(e),at.get(e)}function ye(e,r){const t=Pe(e,r);return t?Object.freeze({birth:t.birth,httpBaseline:t.httpBaseline,snapshot:t.snapshot,verified:t.verified}):void 0}function Ie(e,r,t=!1){var o,a;const n=Pe(e,r),i=fe(e);return!!n&&i.live&&n.verified&&n.transport===_t(e)&&(!t||((a=(o=n.snapshot)==null?void 0:o.routing)==null?void 0:a.enabled)===!0)}function xs(e){const r=Pe(e);at.delete(e),r&&(r.active=!1,r.verified=!1)}function Xt(e,r){const t=Pe(e,r);t&&(t.verified=!1)}function zs(e,r,t){const n=Pe(e,t);return!n||!re(e,r)?!1:(n.verified=!0,re(e,r))}function Ds(e,r,t){const n=Vt.get(t);Vt.delete(t);const i=(n==null?void 0:n.owner)===e&&n.run===r?n.witness:void 0;if(!i||!re(e,r))return!1;const o=i.response.incarnation;let a=Pe(e);if(!a&&!o)return re(e,r);if(!a&&o){const s=fe(e),l=()=>{const v=fe(e);return re(e,r)&&v.epoch===s.epoch&&v.observation===s.observation&&J(e)===s.subject},c=_t(e),u=c.ingestCanvasEvent;if(!l())return!1;const d=Function.prototype.bind.call(u,c),f=c.getCanvasEventReceipt;if(!l())return!1;const p=Function.prototype.bind.call(f,c);if(!l())return!1;a={owner:e,token:Object.freeze({}),birth:Object.freeze({...o}),active:!0,verified:!1,submit:d,inspect:p,transport:c},xn.set(a.token,a),at.set(e,a.token),a.httpBaseline=Object.freeze({birth:a.birth,floor:i.response.receiptRetentionFloor}),Gt.set(t,Object.freeze({owner:e,run:r,epoch:s.epoch,previous:s.subject,subject:a.token}));try{cs(e,r,t)}catch(v){throw Pe(e)===a&&Gs(e,r,t),v}finally{Gt.delete(t)}if(!re(e,r))return!1}else if(a){if(!o||!te(a.birth,o))return!1;a.httpBaseline=Object.freeze({birth:a.birth,floor:i.response.receiptRetentionFloor})}return re(e,r)?(a&&(a.verified=$s(e)||a.verified),!0):!1}function sr(e,r,t){const n=lr(e),i=n.subject,o=()=>Mn(e,n,t);if(!i||!Ie(e,i)){const l=Je(e);Qe(e,l)}if(!o())return;const a=i&&An(e,i),s=Ts(e);n.dispatch(l=>{var d;if(!o())return l;const c=((d=l.binding)==null?void 0:d.owner)===i?l:ge(n.documentId,n.transport),u=typeof r=="function"?r(c):r;return o()?{...u,...u.snapshot?{snapshot:Object.freeze({...u.snapshot})}:{},binding:a,frameAdmission:s}:l})}function Ns(e,r,t,n,i){const o=lr(e),a=Pe(e);Mn(e,o,i)&&(a&&(a.snapshot=r),sr(e,s=>Os(s,r,o.documentId,o.transport,t,n),i))}function Ms(e,r,t,n){const i=jn(e,r,t,n);if(!re(e,r)||!i)return!1;if(i.docSeq<=ar(e).highest)return re(e,r);$t.set(t,{owner:e,run:r,pending:n,frame:i});try{ds(e,r,t,n)}finally{$t.delete(t)}if(!re(e,r))return!1;const o=lr(e);return sr(e,a=>Rn(a,i,o.documentId,o.transport),r),re(e,r)}function Ys(e,r){const t=Pe(e,r);if(!t)return;const n=fe(e).documentId;return{current:i=>Ie(e,r,i==="submit"),submit:(i,o)=>t.submit(n,i,{expectedGeneration:t.birth.generation},o),inspect:(i,o)=>t.inspect(n,i,{expectedGeneration:t.birth.generation},o),capture:()=>{const i=t.httpBaseline;return!i||!Ie(e,r,!0)||!te(i.birth,t.birth)?null:Object.freeze({current:o=>Ie(e,r,o==="submit")&&(o==="read"||t.httpBaseline===i),submit:(o,a)=>t.submit(n,o,{expectedGeneration:i.birth.generation},a),inspect:(o,a)=>t.inspect(n,o,{expectedGeneration:i.birth.generation},a)})}}}function zn(e,r,t){const n=Gt.get(t),i=fe(e);return n&&n.owner===e&&n.run===r&&i.epoch===n.epoch&&i.subject===n.subject&&i.live?n:void 0}function Xs(e,r,t,n){const i=$t.get(t);return i&&i.owner===e&&i.run===r&&i.pending===n&&re(e,r)?i.frame:void 0}const Dn=new WeakMap,yt=new WeakMap;function Ws(e){const r=yt.get(e);if(!r)throw new Error("Document construction ticket is foreign or consumed.");return yt.delete(e),r}function Bs(e,r,t){const n=Object.freeze({});yt.set(n,Object.freeze({documentId:e,transport:r,dispatch:t}));try{const i=Js(n);return Dn.set(n,i),n}finally{yt.delete(n)}}function I(e){const r=Dn.get(e);if(!r)throw new Error("Document owner is foreign.");return r}function Ye(e){I(e)}function fe(e){return I(e).facts()}function _t(e){return I(e).transport()}function Wr(e){return I(e).subject()}function De(e,r){return I(e).subjectFacts(r)}function Ee(e,r,t=!1){return I(e).subjectCurrent(r,t)}function Ls(e,r){return I(e).binding(r)}function Fs(e,r){I(e).reserve(r)}function re(e,r){return I(e).current(r)}function qs(e,r,t){return I(e).admit(r,t)}function Br(e,r,t,n){return I(e).frame(r,t,n)}function Lr(e,r){return I(e).qualify(r)}function Hs(e,r){I(e).failed(r)}function Us(e,r){I(e).unavailable(r)}function Zs(e,r){I(e).start(r)}function Vs(e){I(e).dispose()}const Nn=new WeakMap;function lr(e){const r=Object.freeze(I(e).projection());return Nn.set(r,Object.freeze({custodyKey:e,capture:r})),r}function Mn(e,r,t){const n=Nn.get(r);return(n==null?void 0:n.custodyKey)===e&&n.capture===r&&I(e).projectionCurrent(r.epoch,r.subject,t)}function Gs(e,r,t){I(e).abortAdmission(r,t)}function $s(e){return I(e).qualified()}const Jt=new WeakMap;function Js(e){const{documentId:r,transport:t,dispatch:n}=Ws(e);let i,o=!1,a;const s={live:!0};let l=0,c,u,d=!1,f,p,v=0;const m=()=>s.live,P=()=>xs(e);let w=0;const A=()=>ar(e),C=y=>{const E=Xr(e,y);return!!E&&!E.ended&&m()&&i===y&&E.epoch===l&&E.subject===J(e)},O=(y=!1)=>{const E=Je(e);P(),l++,i=void 0,y&&Yr(e),Qe(e,E)},z=(y,E)=>sr(e,y,E),Y=y=>{const E=fs(e,y),R=J(e),_=R&&ye(e,R);return!C(y)||!E||E.through>E.highest||!f||!_||!te(f,_.birth)||!zs(e,y,R)?!1:(f=void 0,z(D=>({...D,available:!0}),y),C(y))},N=(y,E,R)=>{const _=J(e),D=_&&ye(e,_),Z=l,G=()=>m()&&Z===l&&J(e)===_&&(!R||C(R));if(!G()||js(D==null?void 0:D.snapshot,D==null?void 0:D.birth,y))return;const se=E?y.routing:u;y={...y,routing:se&&Object.freeze({enabled:se.enabled,destinationLabel:se.destinationLabel,approvedEventTypes:Object.freeze([...se.approvedEventTypes])})},E&&(u=y.routing),!_&&!y.incarnation&&(d=!0),G()&&Ns(e,y,E,f===void 0,R)},M=(y,E)=>{var we;const R=Rs(e,y,E);if(!C(y)||!R)return"discard";const _=R.response;As(_,r);const D=_.incarnation;if((J(e)||f||p)&&!D)throw new Error("Document replay identity is unavailable.");if(p&&D&&!te(p,D))return O(!0),z(ge(r,t)),"restart";const Z=J(e),G=(Z&&((we=ye(e,Z))==null?void 0:we.birth))??f;if(D&&(G&&!te(G,D)||!G&&d||R.targetBirth&&!te(R.targetBirth,D)))return f=D,d=!1,u=void 0,c=void 0,O(!0),z(ge(r,t)),"restart";const{events:se,...me}=_,le=J(e);return!le&&D&&(f=p??D),!Ds(e,y,E)||!C(y)?"discard":(!le&&D&&(p=void 0),N(me,R.revision===w,y),C(y)?"accepted":"discard")},W=(y,E,R)=>{var G;const _=jn(e,y,E,R),D=J(e),Z=(D&&((G=ye(e,D))==null?void 0:G.birth))??f;return!C(y)||!_||_.documentId!==r||Z&&(!_.incarnation||!te(Z,_.incarnation))?!1:Ms(e,y,E,R)},q=(y,E)=>{const R=Object.freeze({});Jt.set(R,Object.freeze({owner:e,revision:w,observation:v,epoch:l,notification:y,mode:E}));try{return ps(e,R)}finally{Jt.delete(R)}},B=y=>{if(o||!m()||(o=!0,z(ge(r,t)),!m()))return;const E=di(void 0,R=>{if(!m()||R.documentId!==r)return;const _=R.type==="canvas_channel_snapshot"?R.snapshot.incarnation:R.incarnation,D=J(e);if(!D){if(f&&!p&&(!_||!te(f,_))||!_||_.documentId!==r)return;if(!p||!te(p,_)){const Z=!!p||!!f;if(p=Object.freeze({..._}),v++,u=void 0,c=void 0,d=!1,Z&&(O(!0),z(ge(r,t))),!m()||!p||!te(p,_))return}q(R,"quarantine"),m()&&y();return}if(f&&(!_||!te(f,_))){_&&y();return}if(_&&!te(ye(e,D).birth,_)){f=_,d=!1,u=void 0,c=void 0,O(!0),z(ge(r,t)),m()&&y();return}if(_){if(c!==void 0&&c!==R.scope){const Z=Je(e);if(c=R.scope,Xt(e,D),l++,i=void 0,w++,Qe(e,Z),J(e)!==D||!m())return;z(G=>({...G,available:!1})),J(e)===D&&m()&&y();return}c=R.scope,w++,R.type==="canvas_channel_snapshot"?N(R.snapshot,!0):R.docSeq>A().highest+1?(q(R,"gap")&&m()&&z(G=>({...G,available:!1})),m()&&y()):q(R,"event")}},t,()=>{if(!m())return;const R=Je(e),_=J(e);_&&Xt(e,_),l++,i=void 0,w++,Qe(e,R),z(D=>({...D,available:!1})),m()&&y()});m()?a=E:E(),m()&&y()};return Yn.set(e,y=>{const E=st(e,y);if(!E||E.notification.type==="canvas_channel_snapshot")return;const R=J(e),_=l;!R||!E.notification.incarnation||!te(ye(e,R).birth,E.notification.incarnation)||(z(D=>Rn(D,E.notification,r,t)),!m()||_!==l||J(e))}),{facts:()=>Object.freeze({documentId:r,live:m(),epoch:l,revision:w,observation:v,subject:J(e)}),transport:()=>t,subject:()=>J(e),subjectFacts:y=>ye(e,y),subjectCurrent:(y,E)=>Ie(e,y,E),binding:y=>An(e,y),qualified:()=>f===void 0,projection:()=>({documentId:r,transport:t,dispatch:n,epoch:l,run:i,subject:J(e)}),projectionCurrent:(y,E,R)=>m()&&y===l&&E===J(e)&&(!R||i===R),abortAdmission:(y,E)=>{zn(e,y,E)&&O(!0)},reserve:y=>{const E=Xr(e,y);if(!E||E.ended||!m()||E.epoch!==l||E.subject!==J(e))throw new Error("Replay run is foreign or stale.");i=y},current:C,admit:M,frame:W,qualify:Y,failed:y=>{if(!C(y))return;const E=J(e);E&&Xt(e,E),z(R=>({...R,available:!1}),y)},unavailable:y=>{C(y)&&z(E=>({...E,available:!1}),y)},start:B,dispose:()=>{if(!m())return;const y=Je(e);s.live=!1,i=void 0;const E=a;a=void 0,P(),l++,Yr(e);try{Qe(e,y)}finally{E==null||E()}}}}function st(e,r){const t=Jt.get(r),n=fe(e);if(!(!t||t.owner!==e||!n.live||n.epoch!==t.epoch||n.revision!==t.revision||n.observation!==t.observation))return t}function Qs(e,r){var s;const t=st(e,r);if(!t||t.notification.type==="canvas_channel_snapshot")return;const n=t.notification,o=fe(e).subject,a=o&&ye(e,o);!a||!n.incarnation||!te(a.birth,n.incarnation)||n.docSeq<=ar(e).highest||(hs(e,r),!(!st(e,r)||fe(e).subject!==o)&&((s=Yn.get(e))==null||s(r)))}const Yn=new WeakMap;function Ks(e,r,t){const n=Bs(e,r,t);ls(n);const i=Es(n);return Object.freeze({beginRun:()=>ms(n),frameAdmission:i,start:o=>Zs(n,o),dispose:()=>Vs(n)})}function Is(e){let r,t=0;const n=c=>{r===c&&(r=void 0)},i=(c,u)=>{c.settled||(c.settled=!0,u?c.reject(u.cause):c.resolve())},o=()=>{l().catch(()=>{})},a=(c,u)=>{const d=()=>t===c.revision;if(!d())return;const f=u.beginFinalization();if(d()){if(f==="restart"){o();return}if(f==="drain")for(;d();){const p=u.drainOne();if(!d())return;if(p!=="again"){if(p==="restart")o();else if(p==="tail"){const v=u.finishFinalization();d()&&v==="restart"&&o()}return}}}},s=async c=>{let u,d;try{u=e();try{for(;await u.page()==="again";);}catch(f){u.failed(f)}}catch(f){d={cause:f}}finally{n(c);try{u&&a(c,u)}catch(f){d={cause:f}}finally{i(c,d)}}},l=()=>{if(r)return r.promise;let c,u;const d=new Promise((p,v)=>{c=p,u=v}),f={revision:++t,promise:d,resolve:c,reject:u,settled:!1};return r=f,s(f),d};return Object.freeze({request:l})}function el(e,r,t){const n=Ks(e,r,t),i=Is(()=>{const o=n.beginRun();return{async page(){const a=await o.readPage();if(!a)return"done";const s=o.consumePage(a);if(s.kind!=="frames")return s.kind;for(let l=0;l<s.count;l++)if(!o.advancePageFrame(a,l))return"done";return o.finishPage(a)},failed:()=>o.failed(),beginFinalization:()=>{const a=o.beginFinalization();return a!=="drain"&&o.end(),a},drainOne(){if(!o.current())return o.end(),"stop";const a=o.takePending();return a?o.advancePending(a)?"again":(o.end(),"stop"):"tail"},finishFinalization:()=>{try{return o.finishFinalization()}finally{o.end()}}}});return n.start(()=>{i.request().catch(()=>{})}),Object.freeze({dispose:n.dispose})}function tl(e){const r=pe(),[t,n]=g.useState(()=>ge(e,r));g.useLayoutEffect(()=>{const a=el(e,r,n);return()=>a.dispose()},[e,r]);const i=t.documentId===e&&t.transport===r?t:ge(e,r);return{channel:g.useMemo(()=>_s(i),[i]),events:i.events,frameAdmission:i.frameAdmission}}function rl({content:e}){const[r]=Kt();return r?h.jsx("div",{className:"h-full w-full",children:h.jsx(pi,{sessionId:r,serverName:e.serverName,uri:e.uri,title:e.title})}):null}const nl=g.lazy(()=>je(()=>import("./CanvasFileContent-ZZhdofR4.js"),__vite__mapDeps([5,1,2,6,7])).then(e=>({default:e.CanvasFileContent}))),il=g.lazy(()=>je(()=>import("./CanvasModel3dContent-DMMMZh4o.js"),__vite__mapDeps([8,1,2,6,7])).then(e=>({default:e.CanvasModel3dContent}))),ol=g.lazy(()=>je(()=>import("./CanvasCsvContent-QhDSf8Pd.js"),__vite__mapDeps([9,1,2,10,6,7])).then(e=>({default:e.CanvasCsvContent}))),al=g.lazy(()=>je(()=>import("./index-DMYBI16t.js").then(e=>e.t$),__vite__mapDeps([1,2])).then(e=>({default:e.CanvasDiffContent})));function Cl({documentId:e,widgetChannel:r,content:t,onContentChange:n}){switch(t.type){case"url":case"browser":return h.jsx($i,{documentId:e,content:t},`${e}:${t.url}`);case"markdown":return h.jsx(ao,{documentId:e,content:t,onContentChange:n},t.sourcePath??"generated");case"json":return h.jsx(so,{content:t});case"image":return h.jsx(Ka,{content:t});case"pdf":return h.jsx(es,{content:t});case"audio":return h.jsx(ns,{content:t});case"video":return h.jsx(is,{content:t});case"widget":return r?h.jsx(On,{content:t,documentId:e,channel:r}):h.jsx(sl,{documentId:e,content:t});case"mcp_app":return h.jsx(rl,{content:t});case"file":return h.jsx(g.Suspense,{fallback:h.jsx(ht,{}),children:h.jsx(nl,{documentId:e,content:t})});case"model3d":return h.jsx(g.Suspense,{fallback:h.jsx(ht,{}),children:h.jsx(il,{content:t})});case"csv":return h.jsx(g.Suspense,{fallback:h.jsx(ht,{}),children:h.jsx(ol,{content:t})});case"diff":return h.jsx(g.Suspense,{fallback:h.jsx(ht,{}),children:h.jsx(al,{documentId:e,content:t},t.sourcePath)})}}function ht(){return h.jsx("div",{className:"text-muted-foreground p-4 text-sm",children:"Loading…"})}function sl({documentId:e,content:r}){const{channel:t}=tl(e);return h.jsx(On,{documentId:e,content:r,channel:t})}const ll=g.lazy(()=>je(()=>import("./BlintzCanvas-CXi0fvcM.js"),__vite__mapDeps([0,1,2,3,4])).then(e=>({default:e.BlintzCanvas})));function Sl({roomId:e,document:r,content:t,onSave:n}){const[i,o]=g.useState(null),[a,s]=g.useState(!1),[l,c]=g.useState(null),u=i!==null,d=t.sourcePath===void 0;Di(e,u?r.id:null);const f=async()=>{if(i===null)return;if(i===t.content){o(null),c(null);return}s(!0),c(null);const p=await n(r.id,{...t,content:i});s(!1),p?o(null):c("Couldn’t save. Your words are still here. Try again.")};return h.jsxs("div",{className:"flex h-full flex-col",children:[d&&h.jsxs("div",{className:"flex items-center justify-end gap-2 border-b px-2 py-1",children:[u&&h.jsx("span",{className:"text-muted-foreground text-xs",children:a?"Saving…":"Everyone sees your save."}),h.jsx(mt,{type:"button",size:"xs",variant:"ghost",disabled:a,"aria-label":u?"Save for the room":"Edit this document",onClick:()=>u?void f():o(t.content),children:u?h.jsx(qr,{className:"size-3.5"}):h.jsx(Hr,{className:"size-3.5"})})]}),l!==null&&h.jsx("p",{role:"status",className:"text-destructive border-b px-2 py-1 text-xs",children:l}),h.jsx("div",{className:"flex-1 px-2 pb-6",children:h.jsx(g.Suspense,{fallback:h.jsx("div",{className:"text-muted-foreground p-4 text-sm",children:"Loading…"}),children:h.jsx(ll,{value:i??t.content,editable:u,onChange:o},u?"editing":`rev-${r.rev}`)})})]})}const Qt="dorkos-canvas-sessions",ul=1440*60*60*1e3;function Xn(){try{const e=localStorage.getItem(Qt);if(!e)return null;const r=JSON.parse(e);return r===null||typeof r!="object"?null:r}catch{return null}}function Wn(e){try{Object.keys(e).length===0?localStorage.removeItem(Qt):localStorage.setItem(Qt,JSON.stringify(e))}catch{}}function cl(e){return Array.isArray(e.documents)?[...e.documents].sort((r,t)=>(r.openedAt??0)-(t.openedAt??0)).map(r=>r.content).filter(r=>!!r):e.content?[e.content]:[]}function Ct(e){return e===null||typeof e!="object"?JSON.stringify(e)??"null":Array.isArray(e)?`[${e.map(Ct).join(",")}]`:`{${Object.entries(e).filter(([,t])=>t!==void 0).sort(([t],[n])=>t<n?-1:t>n?1:0).map(([t,n])=>`${JSON.stringify(t)}:${Ct(n)}`).join(",")}}`}function dl(e,r){const t=new Set,n=new Map;for(const o of e){const a=Cr(o.content);if(a!==null){t.add(a);continue}const s=Ct(o.content);n.set(s,(n.get(s)??0)+1)}const i=[];for(const o of r){const a=Cr(o);if(a!==null){t.has(a)||i.push(o);continue}const s=Ct(o),l=n.get(s)??0;l>0?n.set(s,l-1):i.push(o)}return i}const vt=new Set;function Pl(){vt.clear()}function kl(e,r={}){const t=pe(),n=r.canonical??!0;g.useEffect(()=>{e&&K.getState().loadCanvasForSession(e)},[e]),g.useEffect(()=>{if(!e||!n||vt.has(e))return;const i=Xn();if(!i)return;const o=i[e];if(!o){fl(i);return}vt.add(e),(async()=>{try{const a=cl(o),s=dl(await t.listSessionCanvas(e),a);if(s.length===0){Fr(e);return}for(const l of s)await t.openSessionCanvasDocument(e,l);Fr(e),K.getState().hydrateCanvasFromSnapshot(e,await t.listSessionCanvas(e))}catch{vt.delete(e)}})()},[e,n,t])}function Fr(e){const r=Xn();if(!r)return;const{[e]:t,...n}=r;Wn(n)}function fl(e){const r=Date.now()-ul,t=Object.entries(e).filter(([,n])=>n.accessedAt===void 0||n.accessedAt>=r);t.length!==Object.keys(e).length&&Wn(Object.fromEntries(t))}export{Cl as C,wl as F,Sl as R,zi as a,xi as b,yl as c,On as d,Pl as e,Ai as f,tl as g,kl as h,Tn as r,ro as u};
@@ -0,0 +1,16 @@
1
+ import{Y as xe,ds as oe,Q as V,R as ge,U as Ms,kr as Rs,hz as F,r as h,ks as As,kt as Je,ku as Ze,kv as es,kw as _s,aD as ne,hC as ss,dt as Ne,w as je,ad as ye,kx as Ds,ky as Os,V as ts,kz as Ps,dw as ns,kA as Is,kB as Ae,kC as Us,kD as Ls,kE as zs,W as Bs,j as s,bd as be,O as ke,aa as T,dM as $s,gd as _e,kF as me,kG as Fs,dj as ee,kH as Gs,hV as rs,kI as Hs,kj as Qs,bm as ve,kJ as Ws,c8 as q,hh as qs,kK as Ks,kL as is,kM as Vs,kN as K,cr as O,cs as P,ct as I,dl as Se,dm as Te,dn as Ce,dp as we,kO as Xs,aB as as,kP as Ys,hy as Js,kQ as Zs,kR as et,kS as G,dy as st,kT as tt,dQ as nt,aX as rt,B as H,kU as it,kV as at,g9 as ot,kW as os,kX as lt,T as ct,kY as De,kZ as ut,hX as dt,hY as mt,k_ as Oe,h_ as pt,h$ as ft,k$ as ht,l0 as xt,i0 as Pe,l1 as gt,f as Nt,l2 as jt,l3 as yt,dC as Ie,hj as ls,l4 as bt,l5 as kt,l6 as cs,l7 as us,l8 as vt,fG as St,fH as Tt,fI as Ct,fJ as wt,a3 as re,fK as Et,fL as Mt,fM as Rt,fN as At,e as J,e6 as ds,dD as Ue,jD as Le,hv as _t,I as Dt,jE as Ot,l9 as Pt,ab as ms,hq as Ee,bO as It,la as ps,dq as ie,lb as Ut,bQ as de,lc as pe,ld as fs,le as hs,bR as xs,lf as Lt,lg as zt,lh as Bt,fP as $t,li as Ft,fR as Gt,bS as Ht,lj as Qt,be as Z,bT as gs,lk as Wt,iD as qt,ir as Kt,ll as Vt,lm as Xt,dR as Yt,ln as Jt,iS as Zt,lo as en,h1 as sn,h2 as tn,gV as nn,aF as rn,X as an,dr as on,ka as ln,fA as cn,hA as un,el as dn,lp as mn,hU as pn,a6 as fn,id as hn,h4 as xn,c5 as gn,lq as Nn,lr as jn,ls as yn,lt as bn,lu as kn,lv as vn,lw as Sn}from"./index-DMYBI16t.js";import{L as Tn}from"./layers-CJHXSEKK.js";import{H as Cn,a as wn,b as En}from"./hover-card-qzuFUCaR.js";/**
2
+ * @license lucide-react v1.48.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const Ns={name:"chart-column",size:24,node:[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]],aliases:["bar-chart-3"]};Ns.node;const Mn=xe(Ns);/**
7
+ * @license lucide-react v1.48.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const js={name:"clipboard-copy",size:24,node:[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]};js.node;const Rn=xe(js);/**
12
+ * @license lucide-react v1.48.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const ys={name:"wifi",size:24,node:[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]};ys.node;const se=xe(ys);function An(e){return e.ambient===!0&&e.status!=="error"}function fi(e){const t=[],n=[];for(const r of e)(r.ambient?n:t).push(r);return{shown:t,ambient:n}}function _n(e){var t;return((t=e==null?void 0:e.ui)==null?void 0:t.statusBar)??As}function Dn(){const{data:e}=oe();return _n(e)}function On(){const e=V(),t=ge(),n=Ms({mutationKey:Rs,mutationFn:i=>e.updateConfig({ui:{statusBar:{pins:[...i]}}}),onMutate:async i=>{await t.cancelQueries({queryKey:F.current()});const o=t.getQueryData(F.current());return t.setQueryData(F.current(),a=>a!=null&&a.ui?{...a,ui:{...a.ui,statusBar:{pins:[...i]}}}:a),{previous:o}},onError:(i,o,a)=>{a&&a.previous!==void 0&&t.setQueryData(F.current(),a.previous)},onSettled:()=>{t.invalidateQueries({queryKey:F.current()})}});return{setPins:h.useCallback(i=>n.mutate(i),[n]),isPending:n.isPending}}function Pn(e){var n;const t=e.cacheStats;return!t||t.cacheReadTokens===0&&t.cacheCreationTokens===0?null:{cacheReadTokens:t.cacheReadTokens,cacheCreationTokens:t.cacheCreationTokens,contextTokens:(n=e.contextUsage)==null?void 0:n.totalTokens}}function In(e){var t,n;return e?{contextPercent:Je((t=e.contextUsage)==null?void 0:t.totalTokens,(n=e.contextUsage)==null?void 0:n.maxTokens),costUsd:e.cost,model:e.model,cacheStatus:Pn(e),usage:e.usage}:{contextPercent:null,costUsd:null,model:null,cacheStatus:null,usage:null}}function bs(e,t,n){if(t)return"streaming";if(e===void 0)return n;switch(e){case"streaming":return"streaming";case"error":return"error";default:return"idle"}}function hi(e,t){var n;return bs((n=e.status)==null?void 0:n.lifecycle,e.triggerPending,t)}function Un(e){const t=Ze(e),n=es(e),r=_s(e);return bs(t,n,r)}function te(e){return!e.isPending||e.fetchStatus==="idle"||e.fetchStatus==="paused"}const Ln=5e3;function zn(e,t){const n=V(),r=ne(k=>k.selectedCwd),{sessions:i,isAnswered:o,isLoading:a}=ss(),c=oe(),f=Ne(),{data:p}=c,{data:m}=f,d=t??(m==null?void 0:m.defaultRuntime)??null,u=je(d),N=e!==null&&o&&!i.some(k=>k.id===e),S=ye({queryKey:ts.storedSettings(e),queryFn:()=>n.getStoredSessionSettings(e),staleTime:Ln,enabled:N,networkMode:"always"}),{data:l}=S;if(r===null)return{mode:void 0,settled:!1};if(a)return{mode:void 0,settled:!1};if(!N)return{mode:void 0,settled:!0};if(!te(S)||!te(c)||!te(f))return{mode:void 0,settled:!1};if((l==null?void 0:l.permissionMode)!==void 0)return{mode:l.permissionMode,settled:!0};if(!d||!(u!=null&&u.permissionModes.supported))return{mode:void 0,settled:!0};const j=Ds(p==null?void 0:p.executionDefaults,d);return{mode:Os(j,u.permissionModes),settled:!0}}function Bn(e,t,n,r){var Q,W;const i=V(),o=ge(),a=ne(y=>y.selectedCwd),c=Ps(e),f=(c==null?void 0:c.cwd)??a,p=ne(y=>y.pendingAccount),{data:m}=ns({sessionId:e??void 0,runtime:r??void 0}),d=Is(e??""),u=Ae(y=>y.apply),N=Ae(y=>y.clear),S=Us(e),{data:l}=S,{sessions:j}=ss(),k=e===null?void 0:j.find(y=>y.id===e),w=zn(e,r),g=((Q=m==null?void 0:m.find(y=>y.isDefault))==null?void 0:Q.value)??((W=m==null?void 0:m[0])==null?void 0:W.value)??"",b=Ls(e??""),R=!r||!(l!=null&&l.runtime)||l.runtime===r?l==null?void 0:l.model:void 0,M=b&&R===b.from?b.to:R,U=d.model??(n?t==null?void 0:t.model:null)??M??g,A=m==null?void 0:m.find(y=>y.value===U),E=(t==null?void 0:t.contextTokens)??(l==null?void 0:l.contextTokens)??null,x=(t==null?void 0:t.contextMaxTokens)??(A==null?void 0:A.contextWindow)??null,B=d.effort??(l==null?void 0:l.effort)??null,$=d.fastMode??(l==null?void 0:l.fastMode)??!1,X=d.permissionMode??(l==null?void 0:l.permissionMode)??(k==null?void 0:k.permissionMode)??w.mode,le=e===null||X!==void 0||te(S)&&w.settled,ce={permissionMode:zs(d.permissionMode,X),permissionModeKnown:le,model:U,effort:B,fastMode:$,costUsd:(t==null?void 0:t.costUsd)??null,contextPercent:Je(E,x),isStreaming:n,cwd:(l==null?void 0:l.cwd)??null},ue=h.useCallback(async(y,C)=>{var Me;if(!e)return;const _={...y.model?{model:y.model}:{},...y.permissionMode?{permissionMode:y.permissionMode}:{},...y.effort?{effort:y.effort}:{},...y.fastMode!==void 0?{fastMode:y.fastMode}:{}};u(e,_);const L=(p==null?void 0:p.sessionId)===e?p.id:void 0,ws={...r?{runtime:r}:{},...L?{account:L}:{},...y};try{const{permissionModePendingUntilNextTurn:Y,runtimeUnbound:Es,...Re}=await i.updateSession(e,ws,f??void 0);return Y&&Bs.warning("Saved · starts on your next message",{description:"The current reply keeps its old setting."}),o.setQueriesData({queryKey:ts.bySession(e)},z=>({...z,...Re,...y.model===void 0?{model:z==null?void 0:z.model}:{},...Es?{runtime:z==null?void 0:z.runtime}:{}})),Re}catch(Y){console.error("[useSessionStatus] updateSession failed for session",e,Y),N(e,_),(Me=C==null?void 0:C.onError)==null||Me.call(C,Y)}},[i,e,r,f,p,o,u,N]);return h.useEffect(()=>{if(!e)return;const y={};d.model!==void 0&&(l==null?void 0:l.model)===d.model&&(y.model=d.model),d.permissionMode!==void 0&&(l==null?void 0:l.permissionMode)===d.permissionMode&&(y.permissionMode=d.permissionMode),d.effort!==void 0&&(l==null?void 0:l.effort)===d.effort&&(y.effort=d.effort),d.fastMode!==void 0&&(l==null?void 0:l.fastMode)===d.fastMode&&(y.fastMode=d.fastMode),Object.keys(y).length>0&&N(e,y)},[e,l==null?void 0:l.model,l==null?void 0:l.permissionMode,l==null?void 0:l.effort,l==null?void 0:l.fastMode,d,N]),{...ce,updateSession:ue}}function $n(e){const t=V();return ye({queryKey:["subagents",e??null],queryFn:()=>t.getSubagents({sessionId:e}),staleTime:1800*1e3})}const Fn={duration:.2,ease:[.4,0,.2,1]},Gn="pointer-coarse:[&_button]:py-3";function xi({items:e,trailing:t}){const n=e.filter(i=>i.cluster==="left"),r=e.filter(i=>i.cluster==="right");return s.jsxs("div",{role:"toolbar","aria-label":"Session status","aria-live":"polite","data-testid":"status-line",className:"text-muted-foreground flex items-center gap-2 overflow-hidden px-1 text-xs whitespace-nowrap pointer-coarse:min-h-11",children:[s.jsx(ze,{items:n,className:"min-w-0 flex-auto"}),s.jsx(ze,{items:r,className:"min-w-0 shrink"}),t!==void 0&&s.jsx("span",{className:"flex shrink-0 items-center",children:t})]})}const Hn=8;function Qn(e,t){return Hn**Math.max(0,t.indexOf(e.key))}function ze({items:e,className:t}){const n=[...e].sort((r,i)=>i.severity-r.severity).map(r=>r.key);return s.jsx("div",{className:T("flex items-center gap-2",t),children:s.jsx(be,{initial:!1,mode:"popLayout",children:e.map((r,i)=>s.jsxs(ke.div,{"data-testid":`status-item-${r.key}`,"data-rigid":r.rigid?"true":void 0,layout:"position",initial:{opacity:0,scale:.8,filter:"blur(4px)"},animate:{opacity:1,scale:1,filter:"blur(0px)"},exit:{opacity:0,scale:.8,filter:"blur(4px)"},transition:Fn,style:r.rigid?void 0:{flexShrink:Qn(r,n)},className:T("inline-flex items-center gap-2",r.rigid?"shrink-0":"min-w-10",Gn),children:[i>0&&s.jsx(Wn,{}),r.node]},r.key))})})}function Wn(){return s.jsx("span",{className:"text-muted-foreground/30 shrink-0","aria-hidden":"true",children:"·"})}function gi({cwd:e}){const t=e.split("/").filter(Boolean).pop()??e;return s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1",title:e,children:[s.jsx($s,{className:"size-(--size-icon-xs) shrink-0"}),s.jsx("span",{className:"truncate",children:t})]})}const qn=Object.freeze({state:"unknown"}),Kn=Object.freeze({state:"no-repo"});function Vn(e){const t=V();return ye({queryKey:["git-status",e],queryFn:()=>t.getGitStatus(e??void 0),enabled:!!e,refetchInterval:_e.GIT_STATUS_REFETCH_MS,refetchIntervalInBackground:!1,staleTime:_e.GIT_STATUS_STALE_TIME_MS})}function Xn(e){return!!e&&!("error"in e)}function Yn(e){return e===void 0?qn:"error"in e?Kn:{state:"repo",branch:e.branch,dirty:!e.clean}}function ae(e){const t=e.trim(),n=Array.from(t);return n.length<=me?t:`${n.slice(0,me-1).join("").trimEnd()}…`}function Jn(e){return e.replace(/\s*\([^()]*\)\s*$/,"").split("·")[0].trim()}function Zn(e,t){return ae(er(e,t))}function er(e,t){const n=t.find(i=>i.value===e);if(n)return Jn(n.displayName);const r=/claude-(\w+)-/.exec(e);return r?`${r[1].charAt(0).toUpperCase()}${r[1].slice(1)}`:e==="default"?"Default":Fs(e)??e}function Ni({data:e,workspace:t,compact:n}){if(!e)return null;if(!Xn(e))return s.jsxs("span",{className:"text-muted-foreground/50 inline-flex min-w-0 items-center gap-1",title:"Not a git repository",children:[s.jsx(ee,{className:"size-(--size-icon-xs) shrink-0"}),s.jsx("span",{className:"truncate",children:"No repo"})]});const r=e.modified+e.staged+e.untracked,i=r===1?"1 change":`${r} changes`,o=[];if(e.modified>0&&o.push(`${e.modified} modified`),e.staged>0&&o.push(`${e.staged} staged`),e.untracked>0&&o.push(`${e.untracked} untracked`),e.conflicted>0&&o.push(`${e.conflicted} conflicted`),t){const c=Gs(t.portBase),f=[`${t.key} · ${t.projectKey}`,`${t.branch??e.branch} · ${t.provider}`,e.ahead>0?`↑${e.ahead}`:"",e.behind>0?`↓${e.behind}`:"",o.length>0?o.join(", "):"clean",`ports ${c.DORKOS_PORT} / ${c.VITE_PORT} / ${c.SITE_PORT}`,t.pinned?"pinned":""].filter(Boolean);return s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1",title:f.join(" · "),children:[s.jsx(ee,{className:"size-(--size-icon-xs) shrink-0"}),s.jsx("span",{className:"max-w-[20ch] truncate font-medium",children:n?ae(t.key):t.key}),!n&&s.jsxs("span",{className:"text-muted-foreground truncate",children:["· ",t.projectKey]}),t.pinned&&s.jsx(rs,{className:"text-muted-foreground size-(--size-icon-xs) shrink-0"}),r>0&&(n?s.jsx(Be,{label:i}):s.jsxs("span",{className:"text-muted-foreground shrink-0",children:["· ",i]}))]})}const a=o.length>0?`${e.branch} · ${o.join(", ")}`:`${e.branch} · clean`;return s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1",title:a,children:[s.jsx(ee,{className:"size-(--size-icon-xs) shrink-0"}),s.jsx("span",{className:"max-w-[25ch] truncate",children:n?ae(e.branch):e.branch}),e.ahead>0&&s.jsxs("span",{className:"text-muted-foreground inline-flex shrink-0 items-center gap-0.5",children:[s.jsx(Hs,{className:"size-(--size-icon-xs)"}),e.ahead]}),e.behind>0&&s.jsxs("span",{className:"text-muted-foreground inline-flex shrink-0 items-center gap-0.5",children:[s.jsx(Qs,{className:"size-(--size-icon-xs)"}),e.behind]}),r>0&&(n?s.jsx(Be,{label:i}):s.jsxs("span",{className:"text-muted-foreground shrink-0",children:["· ",i]}))]})}function Be({label:e}){return s.jsx("span",{role:"img","aria-label":e,title:e,className:"bg-muted-foreground/70 size-1 shrink-0 rounded-full"})}function sr({stop:e,onMakeDefault:t,onDismiss:n,pending:r,error:i,placement:o="inline"}){const a=o==="overlay";return a&&!e?null:s.jsx("div",{className:T("flex items-center px-1",a?"bg-background/95 pointer-events-auto absolute right-0 bottom-full left-0 z-20 mb-1 rounded-md py-0.5 backdrop-blur-sm":"min-h-5"),"data-testid":a?"make-default-slot-overlay":"make-default-slot",children:e&&s.jsxs("p",{role:"status","data-testid":"make-default-offer",className:T("animate-in fade-in-0 flex min-w-0 items-center gap-1.5 text-xs duration-200 motion-reduce:animate-none",i?"text-destructive":"text-muted-foreground"),children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:i?s.jsxs(s.Fragment,{children:[s.jsx(ve,{className:"mr-1 inline size-3 shrink-0 align-[-2px]","aria-hidden":!0}),i]}):s.jsxs(s.Fragment,{children:["Start every new session in ",Ws(e),"?"]})})," ",s.jsxs("span",{className:"flex shrink-0 items-center gap-1 whitespace-nowrap",children:[i?s.jsx("button",{type:"button",disabled:r,onClick:t,"data-testid":"make-default-retry",className:"focus-ring text-foreground rounded-sm underline underline-offset-2 disabled:opacity-50",children:"Try again"}):s.jsx("button",{type:"button",disabled:r,onClick:t,"data-testid":"make-default-confirm",className:"focus-ring text-foreground rounded-sm underline underline-offset-2 disabled:opacity-50",children:"Make default"}),s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx("button",{type:"button",onClick:n,"data-testid":"make-default-dismiss",className:"focus-ring hover:text-foreground rounded-sm underline underline-offset-2",children:"Dismiss"})]})]})})}const tr="Auto mode needs Opus 4.6+ or Sonnet 4.6";function ji({mode:e,onChangeMode:t,disabled:n,pending:r,runtime:i,modelSupportsAutoMode:o,planActive:a,compact:c,makeDefault:f,onOpenChange:p}){var E;const m=je(i),d=ne(x=>x.setControlCenterOpen),u=q(x=>x.open),N=q(x=>x.setOpen),S=q(x=>x.setAvailable),l=!(m&&!m.permissionModes.supported)&&n!==!0&&r!==!0;if(h.useEffect(()=>(S(l),()=>S(!1)),[l,S]),m&&!m.permissionModes.supported)return null;const j=(m==null?void 0:m.permissionModes.values)??[],k=!o&&j.some(x=>x.id==="auto"),w=k?j.filter(x=>x.id!=="auto"):j,g=w.find(x=>x.id===e),b=(g==null?void 0:g.label)??qs(e),D=c?ae(b):b,R=Ks(g),M=(E=is(w).find(x=>x.mode.id===e))==null?void 0:E.stop,U=k&&(M==="act"||e==="auto"),A=s.jsxs("button",{disabled:n,"data-testid":"permission-mode-trigger","aria-label":`Permissions: ${b}`,className:T(K,"items-center gap-1 disabled:cursor-not-allowed disabled:opacity-40",R),children:[s.jsx(Vs,{descriptor:g,className:"size-(--size-icon-xs) shrink-0"}),s.jsx("span",{className:"truncate",children:D})]});return n?s.jsxs(O,{children:[s.jsx(P,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:A})}),s.jsx(I,{side:"top",children:"Send a message first"})]}):r?s.jsxs("span",{"data-testid":"permission-mode-pending","aria-busy":"true","aria-label":"Permissions: still loading",className:T(K,"items-center gap-1 opacity-40"),children:[s.jsx("span",{className:"bg-muted-foreground/30 size-(--size-icon-xs) shrink-0 animate-pulse rounded-full"}),s.jsx("span",{className:"bg-muted-foreground/30 h-2 w-10 animate-pulse rounded"})]}):s.jsxs(Se,{open:u,onOpenChange:x=>{N(x),p==null||p(x)},children:[s.jsx(Te,{asChild:!0,children:A}),s.jsxs(Ce,{side:"top",align:"start",className:"w-80 p-3","aria-label":"Permissions",children:[s.jsx(we,{children:"Permissions"}),s.jsx(Xs,{mode:e,descriptors:w,onChangeMode:t,planActive:a,onUnlock:()=>d(!0)}),f&&s.jsx(sr,{...f}),U&&s.jsxs(O,{children:[s.jsx(P,{asChild:!0,children:s.jsxs("p",{"data-testid":"auto-unsupported-hint",className:"text-muted-foreground text-3xs mt-2 flex items-center gap-1.5 px-1",children:[s.jsx(as,{className:"size-(--size-icon-xs) shrink-0"}),"Auto unavailable on this model"]})}),s.jsx(I,{side:"top",children:tr})]}),s.jsx(Ys,{mode:e,descriptor:g,className:"mt-2 px-1"})]})]})}const nr=6e3;function rr(e){return e instanceof Error&&e.message||"Couldn’t save that. Try again."}function yi(e){var Q,W,y;const{sessionId:t,runtime:n,declaredModes:r,runtimeDefaultMode:i}=e,{data:o}=oe(),{data:a}=Ne(),c=Js(),f=ge(),p=Zs(),m=et(t),d=G(C=>C.dismissDefaultStopOffer),[u,N]=h.useState(null),[S,l]=h.useState(null),[j,k]=h.useState(null),[w,g]=h.useState(t);w!==t&&(g(t),N(null),l(null),k(null));const b=o==null?void 0:o.executionDefaults,D=n??(b==null?void 0:b.runtime),R=(Q=b==null?void 0:b.perRuntime.find(C=>C.runtime===D))==null?void 0:Q.trustStop,M=R??(b==null?void 0:b.trustStop)??null,U=(W=r.find(C=>C.id===i))==null?void 0:W.stop,A=M??U,E=R!=null?(y=st(a,D))==null?void 0:y.configSection:void 0,x=p.canRemember;h.useEffect(()=>{if(!u)return;const C=setTimeout(()=>N(null),nr);return()=>clearTimeout(C)},[u]);const B=h.useCallback(C=>{const _=r.find(L=>L.id===C);!_||tt(_)||!x||m||_.stop!==A&&(k(null),N(_.stop))},[r,x,m,A,N,k]),$=h.useCallback((C,_)=>{k(null),c.mutate({..._?{ui:{autonomyAcknowledgedAt:new Date().toISOString()}}:{},runtimes:E?{[E]:{defaultTrustStop:C}}:{defaultTrustStop:C}},{onSuccess:()=>{f.invalidateQueries({queryKey:F.all}),N(null)},onError:L=>k(rr(L))})},[c,f,E,N,k]),X=h.useCallback(()=>{var C;if(u){if(u==="autonomy"&&p.acknowledgedAt===null){const _=(C=is(r).find(L=>L.stop==="autonomy"))==null?void 0:C.mode;if(_){l(_);return}}$(u,!1)}},[u,p.acknowledgedAt,r,$,l]),le=h.useCallback(()=>{d(t),N(null)},[d,t,N]),ce=h.useCallback(()=>{l(null),$("autonomy",!0)},[$,l]),ue=h.useCallback(()=>{l(null),N(null)},[l,N]);return{line:x?{stop:u,onMakeDefault:X,onDismiss:le,pending:c.isPending,error:j}:null,offerFor:B,pendingDescriptor:S,confirm:ce,cancel:ue}}function bi({runtimeLabel:e,onShown:t,onDismiss:n}){const r=q(o=>o.available),i=q(o=>o.setOpen);return h.useEffect(()=>{t==null||t()},[t]),s.jsxs(nt,{"data-slot":"read-only-mode-notice","data-testid":"read-only-mode-notice",gap:"none",className:"flex-row flex-wrap items-center gap-x-3 gap-y-2 px-3 py-2",children:[s.jsx(rt,{className:"text-muted-foreground size-4 shrink-0","aria-hidden":!0}),s.jsxs("p",{className:"text-muted-foreground min-w-0 flex-1 text-xs",children:["In this mode, ",e," reads files but won’t change them. Asking won’t help."]}),s.jsxs("div",{className:"flex w-full shrink-0 flex-wrap items-center justify-end gap-1.5 sm:w-auto",children:[s.jsx(H,{variant:"ghost",size:"sm",responsive:!1,className:"h-7 px-2 text-xs",onClick:n,children:"Dismiss"}),r&&s.jsx(H,{variant:"outline",size:"sm",responsive:!1,className:"h-7 px-2 text-xs",onClick:()=>i(!0),children:"Change permissions"})]})]})}function ki(e,t,n){const r=je(t??void 0),i=G(d=>d.recordReadOnlyHintShown),o=G(d=>d.spendReadOnlyHint),a=it(e??""),c=r==null?void 0:r.permissionModes.values.find(d=>d.id===n),f=c!==void 0&&at(c);h.useEffect(()=>{f||!e||a!=="shown"||o(e)},[f,e,a,o]);const p=h.useCallback(()=>{e&&i(e)},[e,i]),m=h.useCallback(()=>{e&&o(e)},[e,o]);return h.useMemo(()=>({eligible:!!e&&f&&a!=="spent",runtimeLabel:t?ot(t):"This agent",markShown:p,dismiss:m}),[e,f,a,t,p,m])}function vi({descriptor:e,active:t,onToggle:n,disabled:r}){return s.jsxs(O,{children:[s.jsx(P,{asChild:!0,children:s.jsxs("button",{type:"button","aria-pressed":t,disabled:r,onClick:()=>n(!t),className:T(K,"items-center gap-1","disabled:cursor-not-allowed disabled:opacity-40",t&&"text-foreground"),children:[s.jsx(os,{className:"size-(--size-icon-xs) shrink-0","aria-hidden":!0}),s.jsx("span",{className:"truncate",children:e.label})]})}),s.jsx(I,{side:"top",children:r?"Send a message first":e.promise})]})}function Si({runtime:e,model:t,onChangeRuntime:n,canSelect:r,compact:i,account:o}){const{data:a}=Ne(),{data:c}=lt(),{nameFor:f}=ct(),[p,m]=h.useState({open:!1}),d=Object.keys((a==null?void 0:a.capabilities)??{}),u=d.filter(g=>De(c,g)),N=d.filter(g=>!De(c,g)),S=a!==void 0&&Object.values(ut).some(g=>g.setup&&!d.includes(g.type)),l=!!n&&(d.length>1||N.length>0||S),j=i?null:t,k=s.jsx(Oe,{runtime:e,model:j,iconClassName:"size-(--size-icon-xs)"}),w=o?`Account: ${f(o)}`:null;return r?l?s.jsxs(s.Fragment,{children:[s.jsxs(dt,{children:[s.jsx(mt,{asChild:!0,children:s.jsx("button",{className:K,children:s.jsx(Oe,{runtime:e,model:j,iconClassName:"size-(--size-icon-xs)"})})}),s.jsxs(pt,{side:"top",align:"start",className:"w-56",children:[s.jsx(ft,{children:"Runs on"}),s.jsx(ht,{value:e,onValueChange:g=>n==null?void 0:n(g),children:u.map(g=>{const b=Ie(g);return s.jsx(xt,{value:g,icon:b.icon,children:b.label},g)})}),N.map(g=>{const b=Ie(g);return s.jsx(Pe,{icon:b.icon,description:"Connect",onSelect:()=>m({open:!0,runtime:g}),children:b.label},g)}),S&&s.jsxs(s.Fragment,{children:[s.jsx(gt,{}),s.jsx(Pe,{icon:Nt,onSelect:()=>m({open:!0}),children:"Add a runtime"})]})]})]}),s.jsx(jt,{runtime:p.runtime,open:p.open,onOpenChange:g=>m(b=>({...b,open:g})),renderConnect:yt,showConnectSuccess:!0,onRuntimeReady:g=>{n==null||n(g)}})]}):w?s.jsxs(O,{children:[s.jsx(P,{asChild:!0,children:k}),s.jsx(I,{side:"top",children:w})]}):k:s.jsxs(O,{children:[s.jsx(P,{asChild:!0,children:k}),s.jsxs(I,{side:"top",children:[s.jsx("span",{className:"block",children:"Set when the session starts. It can’t change after."}),w&&s.jsx("span",{className:"block",children:w})]})]})}function Ti(e,t,n){const r=ls(),i=bt(e),o=new Date(r),a=t.pending?null:t.usage;return{...kt({liveTurnUsage:n,liveTurnAt:i,accountStatus:vt(a,o),accountObservedAt:cs(us(a))}),accountUsage:a}}function Ci({open:e,onOpenChange:t,onConfirm:n}){return s.jsx(St,{open:e,onOpenChange:t,children:s.jsxs(Tt,{children:[s.jsxs(Ct,{children:[s.jsxs(wt,{className:"flex items-center gap-2",children:[s.jsx(as,{className:"text-muted-foreground size-4"}),"Turn on Auto mode?",s.jsx(re,{size:"xs",variant:"secondary",className:"tracking-wide uppercase",children:"Preview"})]}),s.jsx(Et,{children:"Asks only before risky steps, like deleting files. Switch back anytime."})]}),s.jsxs(Mt,{children:[s.jsx(Rt,{children:"Cancel"}),s.jsx(At,{onClick:n,children:"Turn on Auto mode"})]})]})})}const $e=[{slug:"frontier",label:"Frontier"},{slug:"solid-coders",label:"Solid coders"},{slug:"quick-helpers",label:"Quick helpers"},{slug:"more-models",label:"More models"},{slug:"no-tools",label:"Can’t do agent work"}],ir=10,ar="Can’t use tools, so it can’t read files or run commands.",or="Makes images DorkOS can’t show yet.",lr=["openrouter/openrouter/auto","openrouter/auto"];function cr(e){return lr.some(t=>e.value===t||e.value.startsWith(`${t}-`))}function ks(e){return e.supportsToolUse!==!1}function ur(e){return e.supportsImageOutput===!0&&!cr(e)?or:ks(e)?null:ar}function dr(e){if(!ks(e))return"no-tools";switch(e.tier){case"frontier":return"frontier";case"solid-coder":return"solid-coders";case"quick-helper":return"quick-helpers";default:return"more-models"}}function mr(e){return e.some(t=>t.tier!=null)||e.length>ir}function pr(e,t){const n=t.trim().toLowerCase();return n?e.value.toLowerCase().includes(n)||e.displayName.toLowerCase().includes(n):!0}function fr(e){const t=new Map($e.map(n=>[n.slug,[]]));for(const n of e)t.get(dr(n)).push(n);return $e.map(n=>({...n,models:t.get(n.slug)})).filter(n=>n.models.length>0)}function hr(e){return e>=1e6?`${Math.round(e/1e6)}M`:e>=1e3?`${Math.round(e/1e3)}K`:String(e)}function xr(){return s.jsx("div",{className:"space-y-2","data-testid":"model-cards-skeleton",children:Array.from({length:3}).map((e,t)=>s.jsxs("div",{className:"flex items-center gap-3 rounded-xl p-3",children:[s.jsx(J,{className:"size-4 rounded-full"}),s.jsxs("div",{className:"flex-1 space-y-1.5",children:[s.jsx(J,{className:"h-3.5 w-24"}),s.jsx(J,{className:"h-2.5 w-32"})]}),s.jsx(J,{className:"h-5 w-10 rounded-md"})]},t))})}function gr({onRetry:e,message:t}){return s.jsxs("div",{className:"flex flex-col items-center gap-3 py-6 text-center","data-testid":"model-load-error",children:[s.jsx(ve,{className:"text-muted-foreground size-5"}),s.jsx("p",{className:"text-muted-foreground text-xs",children:t??"Couldn’t load the model list."}),s.jsxs("button",{onClick:e,className:"text-foreground hover:bg-accent inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs transition-colors",children:[s.jsx(ds,{className:"size-3"}),"Retry"]})]})}function Nr(e){const t=e.slice(e.lastIndexOf(" ")+1);return t.includes("/")||t.includes(":")}function vs({text:e,className:t}){return Nr(e)?s.jsx("div",{dir:"rtl",className:T("truncate text-left",t),title:e,children:s.jsx("bdi",{dir:"ltr",children:e})}):s.jsx("div",{className:T("truncate",t),title:e,children:e})}function Fe({model:e,isSelected:t}){const n=ur(e);return s.jsxs("label",{className:T("flex w-full cursor-pointer items-center gap-3 rounded-xl border p-3 transition-colors duration-150",t?"bg-secondary border-foreground/15":"border-border hover:border-muted-foreground/30 hover:bg-muted/50 opacity-70"),children:[s.jsx(Ot,{value:e.value,className:"shrink-0"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"text-foreground line-clamp-2 text-sm font-medium break-words",children:[e.displayName,e.local&&s.jsxs("span",{className:"text-muted-foreground text-3xs ml-1.5 font-normal",children:[Pt()," · private"]})]}),s.jsx(vs,{text:e.description,className:"text-muted-foreground text-2xs leading-tight"}),n&&s.jsx("div",{className:"text-2xs text-status-warning-fg mt-0.5 leading-tight","data-testid":`model-limitation-${e.value}`,children:n})]}),e.contextWindow&&s.jsx(re,{size:"xs",variant:"secondary",className:"shrink-0",children:hr(e.contextWindow)})]})}function jr({value:e}){return s.jsxs("div",{className:"space-y-1.5","data-testid":"model-unavailable-saved",children:[s.jsxs("div",{className:"border-border flex w-full items-center gap-3 rounded-xl border border-dashed p-3 opacity-80",children:[s.jsx(ve,{className:"text-status-warning-fg size-4 shrink-0"}),s.jsxs("div",{className:"flex min-w-0 flex-1 items-baseline gap-1.5",children:[s.jsx(vs,{text:e,className:"text-foreground min-w-0 text-sm font-medium"}),s.jsx("span",{className:"text-muted-foreground text-2xs shrink-0 font-normal",children:"(not available)"})]})]}),s.jsx("p",{className:"text-muted-foreground text-2xs leading-snug",children:"This model isn’t available anymore. Pick another."})]})}function yr({slug:e,label:t}){return s.jsx("div",{className:"text-muted-foreground text-2xs mt-2 mb-1 font-medium tracking-wide uppercase first:mt-0","data-testid":`model-group-${e}`,children:t})}function br({models:e,selectedModel:t,onChangeModel:n,emptyMessage:r}){const[i,o]=h.useState(""),a=mr(e),f=e.length>0&&t.length>0&&!e.some(u=>u.value===t)?s.jsx(jr,{value:t}):null,p=e.some(u=>u.unverified),m=h.useMemo(()=>a?e.filter(u=>pr(u,i)):e,[e,i,a]),d=h.useMemo(()=>a?fr(m):[],[m,a]);return e.length===0?s.jsx("div",{className:"border-border text-muted-foreground text-2xs rounded-xl border border-dashed p-3 leading-snug","data-testid":"model-catalog-unavailable",children:r??"Couldn’t load models. Check Settings, then try again."}):a?s.jsxs("div",{className:"space-y-2",children:[f,p&&s.jsx(Ue,{}),s.jsxs("div",{className:"relative",children:[s.jsx(_t,{className:"text-muted-foreground pointer-events-none absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2"}),s.jsx(Dt,{type:"text",value:i,onChange:u=>o(u.target.value),placeholder:"Search models…","aria-label":"Search models","data-testid":"model-search",className:"h-8 pl-8 text-xs"})]}),d.length===0?s.jsx("p",{className:"text-muted-foreground py-4 text-center text-xs","data-testid":"model-search-empty",children:p?"No match in this short list. Connect a provider to see more.":"No models match"}):s.jsx(Le,{value:t,onValueChange:n,className:"grid-cols-1 gap-1.5","aria-label":"Model selection","data-testid":"model-card-list",children:d.map(u=>s.jsxs(h.Fragment,{children:[s.jsx(yr,{slug:u.slug,label:u.label}),u.models.map(N=>s.jsx(Fe,{model:N,isSelected:N.value===t},N.value))]},u.slug))})]}):s.jsxs("div",{className:"space-y-2",children:[f,p&&s.jsx(Ue,{}),s.jsx(Le,{value:t,onValueChange:n,className:"grid-cols-1 gap-1.5","aria-label":"Model selection","data-testid":"model-card-list",children:e.map(u=>s.jsx(Fe,{model:u,isSelected:u.value===t},u.value))})]})}const fe={none:{label:"None",description:"No reasoning"},minimal:{label:"Minimal",description:"Near-zero thinking"},low:{label:"Low",description:"Fastest responses"},medium:{label:"Medium",description:"Moderate thinking"},high:{label:"High",description:"Deep reasoning"},max:{label:"Max",description:"Maximum thinking"},xhigh:{label:"XHigh",description:"Beyond maximum"}},kr={duration:.15,ease:"easeOut"};function vr({effortLevels:e,effort:t,onChangeEffort:n}){return s.jsxs("div",{children:[s.jsx("div",{className:"text-muted-foreground text-2xs mb-2 font-medium tracking-wide uppercase",children:"Effort"}),s.jsxs("div",{className:"flex flex-wrap gap-1.5",role:"radiogroup","aria-label":"Effort level",children:[s.jsx(he,{role:"radio",label:"Default",isSelected:t===null,onClick:()=>n(null)}),e.map(r=>s.jsx(he,{role:"radio",label:fe[r].label,description:fe[r].description,isSelected:t===r,onClick:()=>n(r)},r))]})]})}function Sr({supportsFastMode:e,fastMode:t,onChangeFastMode:n}){return e?s.jsxs("div",{children:[s.jsx("div",{className:"text-muted-foreground text-2xs mb-2 font-medium tracking-wide uppercase",children:"Mode"}),s.jsx("div",{className:"flex gap-1.5",children:s.jsx(he,{role:"switch",label:"Fast",icon:s.jsx(Ee,{className:"size-3"}),isSelected:t,onClick:()=>n(!t)})})]}):null}function he({role:e,label:t,description:n,icon:r,isSelected:i,onClick:o}){const a=s.jsxs("button",{role:e,"aria-checked":i,onClick:o,className:T("inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-xs font-medium transition-colors duration-150",i?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-muted/80 hover:text-foreground"),children:[r,t]});return n?s.jsxs(O,{children:[s.jsx(P,{asChild:!0,children:a}),s.jsx(I,{side:"top",className:"text-xs",children:n})]}):a}function wi({model:e,onChangeModel:t,effort:n,onChangeEffort:r,fastMode:i,onChangeFastMode:o,disabled:a,sessionId:c,runtime:f,onCredits:p,compact:m}){var R;const{data:d,isLoading:u,isError:N,refetch:S}=ns({sessionId:c,runtime:f??void 0}),l=d??[],j=l.find(M=>M.value===e),k=!!(j!=null&&j.supportsEffort&&(((R=j.supportedEffortLevels)==null?void 0:R.length)??0)>0),w=(j==null?void 0:j.supportsFastMode)??!1,g=!m&&k&&n?fe[n].label:null,b=!m&&i,D=s.jsxs("button",{disabled:a,className:T(K,"items-center gap-1 disabled:cursor-not-allowed disabled:opacity-40"),"data-testid":"model-config-trigger",children:[s.jsx(ms,{className:"size-(--size-icon-xs) shrink-0"}),s.jsx("span",{className:"truncate",children:Zn(e,l)}),g&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-muted-foreground text-2xs",children:"·"}),s.jsx(re,{size:"xs",variant:"secondary",children:g})]}),b&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-muted-foreground text-2xs",children:"·"}),s.jsxs(re,{size:"xs",variant:"secondary",children:[s.jsx(Ee,{className:"mr-0.5 inline size-2.5"}),"Fast"]})]})]});return a?s.jsxs(O,{children:[s.jsx(P,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:D})}),s.jsx(I,{side:"top",children:"Send a message first"})]}):s.jsxs(Se,{children:[s.jsx(Te,{asChild:!0,children:D}),s.jsxs(Ce,{side:"top",align:"start",className:"w-120 max-w-[calc(100vw-1.5rem)] p-3","data-testid":"model-config-popover",children:[s.jsx(we,{children:"Model"}),l.some(M=>M.paidFromCredits)&&s.jsx("p",{className:"text-muted-foreground text-2xs mb-2","data-testid":"model-credits-note",children:l.some(M=>M.creditsListOutOfDate)?"Models your DorkOS credits cover. This list may be out of date.":"Models your DorkOS credits cover"}),u&&s.jsx(xr,{}),N&&s.jsx(gr,{onRetry:()=>S(),message:p?"Couldn’t load the models DorkOS credits cover. Your model stays as it is.":void 0}),!u&&!N&&s.jsx(br,{models:l,selectedModel:e,onChangeModel:t,emptyMessage:p?"DorkOS credits don’t cover a model for this runtime yet.":void 0}),s.jsx(be,{children:!u&&!N&&(k||w)&&s.jsxs(ke.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:4},transition:kr,children:[s.jsx(It,{className:"my-3"}),s.jsx("div",{className:"text-muted-foreground text-2xs mb-3 font-medium tracking-wide uppercase",children:"Configuration"}),s.jsxs("div",{className:"space-y-3",children:[k&&s.jsx(vr,{effortLevels:j.supportedEffortLevels,effort:n,onChangeEffort:r}),w&&s.jsx(Sr,{supportsFastMode:(j==null?void 0:j.supportsFastMode)??!1,fastMode:i,onChangeFastMode:o})]})]},"config")})]})]})}function Ei({percent:e,contextUsage:t,compact:n,reading:r,now:i}){const o=ps(e,t)??e,a=Ut(o),c=a==="critical"?ie.error:a==="warning"?ie.warning:"",f=n!=null&&o>=hs,p=t?{total:t.totalTokens,max:t.maxTokens}:r&&r.maxTokens>0?{total:r.totalTokens,max:r.maxTokens}:null,m=(r==null?void 0:r.observedAt)??null,d=p!==null,u=s.jsxs("span",{"aria-label":d?"Context window usage":void 0,className:T("inline-flex shrink-0 items-center gap-1",d&&"cursor-default",c),children:[s.jsx(Tn,{className:"size-(--size-icon-xs) shrink-0"}),s.jsxs("span",{children:[o,"%"]})]});return s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[p?s.jsx(Tr,{totals:p,categories:(t==null?void 0:t.categories)??[],observedAt:m,now:i,children:u}):u,s.jsx(be,{initial:!1,children:f&&s.jsxs(ke.button,{type:"button",onClick:n.onCompact,disabled:n.pending,"aria-label":n.pending?"Compacting conversation…":`Context ${o}% full. Compact now`,"aria-busy":n.pending,"data-testid":"compaction-chip",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.15},className:"bg-secondary text-muted-foreground hover:text-foreground hover:bg-muted inline-flex min-w-0 shrink items-center gap-1 rounded-md px-1.5 py-0.5 transition-colors duration-150 disabled:cursor-not-allowed disabled:opacity-60",children:[s.jsx(ds,{"aria-hidden":"true",className:T("size-(--size-icon-xs) shrink-0",n.pending&&"animate-spin")}),s.jsx("span",{className:"truncate",children:"Compact"})]},"compact")})]})}function Tr({totals:e,categories:t,observedAt:n,now:r,children:i}){const o=t.filter(a=>a.tokens>0).sort((a,c)=>c.tokens-a.tokens);return s.jsxs(O,{children:[s.jsx(P,{asChild:!0,children:i}),s.jsx(I,{side:"top",className:"max-w-64",children:s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"text-xs font-medium",children:[de(e.total)," / ",de(e.max)," tokens"]}),o.length>0&&s.jsx("div",{className:"space-y-0.5",children:o.map(a=>s.jsxs("div",{className:"text-3xs flex items-center justify-between gap-3",children:[s.jsxs("span",{className:"flex items-center gap-1 truncate",children:[s.jsx("span",{className:"inline-block size-1.5 shrink-0 rounded-full",style:{backgroundColor:a.color}}),a.name]}),s.jsx("span",{className:T(pe,"shrink-0"),children:de(a.tokens)})]},a.name))}),n!==null&&s.jsx(fs,{observedAt:n,now:r,surface:"tooltip"})]})})]})}function Mi({usage:e,accountUsage:t=null,observedAt:n=null,open:r,onOpenChange:i,now:o}){const a=ls(),c=o??new Date(a),f=us(t),p=f.length>0?cs(f):n,m=e!=null&&xs(e);let d;return f.length>0?d=s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"text-xs font-medium",children:"Subscription usage"}),s.jsx("div",{className:"flex flex-col gap-2.5",children:f.map(u=>s.jsx(Lt,{window:u,label:zt(u.key,u.label),now:c},u.key))}),e&&s.jsx("div",{className:"text-3xs space-y-0.5",children:s.jsx(Bt,{usage:e})})]}):m?d=s.jsx(Ht,{usage:e}):d=s.jsx("p",{className:"text-muted-foreground text-xs",children:"No usage yet."}),s.jsxs($t,{open:r,onOpenChange:i,children:[s.jsx(Ft,{asChild:!0,children:s.jsx("span",{"aria-hidden":!0,className:"inline-block h-0 w-0"})}),s.jsx(Gt,{side:"top",align:"end",className:"w-72 max-w-[calc(100vw-1.5rem)]","aria-label":"Usage and cost",children:s.jsxs("div",{className:"space-y-2",children:[d,p!==null&&(f.length>0||m)&&s.jsx(fs,{observedAt:p,now:c})]})})]})}const Cr={connecting:{color:Z.warning,label:"Connecting",shortLabel:"Connecting",icon:se,tasks:!0},connected:{color:Z.success,label:"Connected",shortLabel:"Connected",icon:se,tasks:!1},reconnecting:{color:Z.warning,label:"Reconnecting",shortLabel:"Reconnecting",icon:se,tasks:!0},disconnected:{color:Z.error,label:"Live updates lost",shortLabel:"Offline",icon:Qt,tasks:!1}};function Ri({connectionState:e,compact:t}){const n=Cr[e],r=n.icon;return s.jsxs(Cn,{openDelay:200,children:[s.jsx(wn,{asChild:!0,children:s.jsxs("span",{className:"flex min-w-0 cursor-default items-center gap-1.5 text-xs",children:[s.jsx("span",{className:T("size-1.5 shrink-0 rounded-full",n.color,n.tasks&&"animate-breath")}),s.jsx("span",{className:"text-muted-foreground truncate",children:t?n.shortLabel:n.label})]})}),s.jsx(En,{side:"top",align:"center",className:"w-72 p-3",children:s.jsxs("div",{className:"flex items-start gap-2.5",children:[s.jsx(r,{className:T("mt-0.5 size-4 shrink-0",e==="disconnected"?ie.error:ie.warning)}),s.jsxs("div",{className:"min-w-0 space-y-1.5",children:[s.jsx("p",{className:"text-sm font-medium",children:n.label}),s.jsx(wr,{connectionState:e})]})]})})]})}function wr({connectionState:e}){const t="text-muted-foreground text-xs leading-relaxed";return e==="connecting"?s.jsx("p",{className:t,children:"Connecting to live updates. New messages appear once connected."}):e==="reconnecting"?s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("p",{className:t,children:"Live updates dropped and are reconnecting. Nothing is lost."}),s.jsx("p",{className:T(t,"text-muted-foreground/70"),children:"No action needed."})]}):s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("p",{className:t,children:"Couldn’t reconnect live updates. New messages won’t appear until they’re back."}),s.jsx("p",{className:T(t,"text-muted-foreground/70"),children:"Refresh the page. If that doesn’t help, check that DorkOS is running."})]})}function Ai({count:e,running:t,waiting:n}){const r=e===1?"":"s",i=e-t.length,o=`${e} subagent${r} running`;return s.jsxs(O,{children:[s.jsx(P,{asChild:!0,children:s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1","aria-label":o,children:[s.jsx(gs,{className:"size-(--size-icon-xs) shrink-0"}),s.jsx("span",{className:"shrink-0 tabular-nums",children:e})]})}),s.jsxs(I,{side:"top",className:"max-w-64",children:[n&&s.jsx("p",{className:"mb-1 font-medium",children:"Still working. The agent continues when they finish."}),s.jsx("ul",{className:"space-y-1",children:t.map(a=>s.jsxs("li",{children:[s.jsx("span",{className:"font-medium",children:a.description??"Working…"}),s.jsxs("p",{className:T(pe,"text-3xs leading-tight"),children:[a.toolUses??0," tool",a.toolUses===1?"":"s",a.lastToolName?` · last ${a.lastToolName}`:""]})]},a.taskId))}),i>0&&s.jsx("p",{className:T(pe,"text-3xs leading-tight"),children:t.length>0?`and ${i} more`:`${i} task${r} from earlier`})]})]})}const Er=new Set(["main","master"]);function _i(e,t,n){return{dirty:!t,onDefaultBranch:!n&&Er.has(e)}}const v={AGENT_ANCHOR:1e3,CONNECTION_LOST:100,CONTEXT_CRITICAL:90,ACCOUNT_ATTENTION:85,USAGE_EXHAUSTED:80,PERMISSION_BYPASS:70,CONTEXT_WARNING:50,USAGE_WARNING:50,PERMISSION_ELEVATED:40,PLAN_ACTIVE:40,SUBAGENTS_RUNNING:35,EXTENSION_ITEM:35,RUNTIME_NON_DEFAULT:30,GIT_DIRTY:20,MODEL:10,CWD:5,QUIET:0},Mr={session:"Session",diagnostics:"Diagnostics"};function Ge(e){return e.runtime&&!e.runtime.isDefault?v.RUNTIME_NON_DEFAULT:v.QUIET}function Rr(e){return e.account!==null}const Ar=new Set(["near","model-out","out"]);function He(e){return e.permissionDescriptor?e.permissionDescriptor.stop!=="ask":e.permissionMode!=="default"}const Ss=[{key:"agent",label:"Agent",description:"Who you are talking to",cluster:"left",group:null,icon:qt,promote:()=>!0,severity:()=>v.AGENT_ANCHOR},{key:"cwd",label:"Directory",description:"The folder this session can touch",cluster:"left",group:"session",icon:Kt,promote:e=>e.cwd!==null,severity:()=>v.CWD},{key:"git",label:"Git",description:"Branch and uncommitted changes",cluster:"left",group:"session",icon:ee,promote:e=>e.git!==null&&(e.git.dirty||!e.git.onDefaultBranch),severity:e=>{var t;return(t=e.git)!=null&&t.dirty?v.GIT_DIRTY:v.QUIET}},{key:"runtime",label:"Runs on",description:"What runs this session",cluster:"right",group:"session",icon:Vt,promote:e=>e.runtime!==null&&(!e.runtime.isDefault||e.runtime.canSelect),severity:Ge},{key:"account",label:"Account",description:"Which Claude account this uses, and what’s left",cluster:"right",group:null,icon:Xt,promote:e=>e.account!==null,severity:e=>e.account&&Ar.has(e.account.chipState)?v.ACCOUNT_ATTENTION:Ge(e)},{key:"extensions",label:"Add-ons",description:"What your extensions show here",cluster:"right",group:null,icon:Yt,promote:e=>e.extensionItems.some(t=>t.visible),severity:e=>e.extensionItems.some(t=>t.visible&&t.urgent)?v.ACCOUNT_ATTENTION:v.EXTENSION_ITEM},{key:"model",label:"Model",description:"The model answering you",cluster:"right",group:"session",icon:ms,promote:()=>!0,severity:()=>v.MODEL},{key:"cache",label:"Cache",description:"How much came from cache",cluster:"right",group:"session",icon:Ee,promote:()=>!1,severity:()=>v.QUIET,neverInLine:!0},{key:"context",label:"Context",description:"How full the conversation window is",cluster:"right",group:"session",icon:Mn,rigid:!0,promote:e=>e.contextPercent!==null,severity:e=>e.contextPercent===null?v.QUIET:e.contextPercent>=hs?v.CONTEXT_CRITICAL:e.contextPercent>=en?v.CONTEXT_WARNING:v.QUIET},{key:"usage",label:"Usage & cost",description:"Plan limits or session cost",cluster:"right",group:"session",icon:Jt,rigid:!0,promote:e=>e.usage!==null&&xs(e.usage)&&!Rr(e),wide:e=>e.usageStale,severity:e=>{var t,n;return((t=e.usage)==null?void 0:t.state)==="exhausted"?v.USAGE_EXHAUSTED:((n=e.usage)==null?void 0:n.state)==="warning"?v.USAGE_WARNING:v.QUIET}},{key:"permission",label:"Permissions",description:"How freely the agent acts",cluster:"right",group:"session",icon:Zt,promote:e=>He(e),severity:e=>(e.permissionDescriptor?sn(e.permissionDescriptor):tn(e.permissionMode))?v.PERMISSION_BYPASS:He(e)?v.PERMISSION_ELEVATED:v.QUIET},{key:"plan",label:"Plan",description:"Plan first, change nothing until approved",cluster:"right",group:"session",icon:os,promote:e=>e.plan!==null,severity:e=>{var t;return(t=e.plan)!=null&&t.active?v.PLAN_ACTIVE:v.QUIET}},{key:"subagents",label:"Subagents",description:"Subagents working on this turn",cluster:"right",group:"diagnostics",icon:gs,rigid:!0,promote:e=>e.subagentsInFlight>0,severity:e=>e.subagentsInFlight>0?v.SUBAGENTS_RUNNING:v.QUIET},{key:"connection",label:"Live updates",description:"The live link that delivers messages",cluster:"right",group:"diagnostics",icon:se,promote:e=>e.connectionState!=="connected",severity:e=>e.connectionState==="connected"?v.QUIET:v.CONNECTION_LOST}];function Ts(e){return e.group==="session"&&e.neverInLine!==!0}function _r(){const{pins:e}=Dn(),{setPins:t}=On(),n=h.useCallback(i=>{const o=Wt.find(a=>a===i);o&&t(e.includes(o)?e.filter(a=>a!==o):[...e,o])},[e,t]),r=h.useCallback(()=>t([]),[t]);return{pins:e,toggle:n,reset:r}}function Dr(){return["session","diagnostics"].map(t=>({group:t,label:Mr[t],items:Ss.filter(n=>n.group===t)})).filter(t=>t.items.length>0)}function Cs(e){const t=e.contextTokens??e.readTokens+e.creationTokens;return t<=0?0:Math.round(e.readTokens/t*100)}function Or(e){return e?e.kind==="subscription"&&e.utilization!=null?`${Math.round(e.utilization*100)}% of ${e.windowLabel??"your plan"}`:e.costUsd!=null?`$${e.costUsd.toFixed(2)}`:null:null}function Pr(e){return e.split("/").filter(Boolean).pop()??e}function Ir(e,t){switch(e){case"cwd":return t.cwd?Pr(t.cwd):null;case"git":return t.git.state==="unknown"?null:t.git.state==="no-repo"?"No repo":t.git.dirty?`${t.git.branch} · changed`:t.git.branch;case"runtime":return t.runtime;case"model":return t.model;case"context":return t.contextPercent===null?null:`${t.contextPercent}% full`;case"cache":return t.cache===null?null:`${Cs(t.cache)}% from cache`;case"usage":return Or(t.usage);case"permission":return t.permissionMode;case"connection":return`${t.connectionState} · event ${t.lastEventSeq}`;default:return null}}function Ur(e){return JSON.stringify({sessionId:e.sessionId,cwd:e.cwd,git:e.git,runtime:e.runtime,model:e.model,selectedModel:e.selectedModel,effort:e.effort,fastMode:e.fastMode,permissionMode:e.permissionMode,contextPercent:e.contextPercent,contextUsage:e.contextUsage,cache:e.cache===null?null:{readTokens:e.cache.readTokens,creationTokens:e.cache.creationTokens,contextTokens:e.cache.contextTokens??null,hitPercent:Cs(e.cache)},usage:e.usage,connectionState:e.connectionState,streaming:e.streaming,lifecycle:e.lifecycle,triggerPending:e.triggerPending,lastEventSeq:e.lastEventSeq,snapshotCursor:e.snapshotCursor,lastEventAt:e.lastEventAt===null?null:new Date(e.lastEventAt).toISOString(),queueDepth:e.queueDepth,subagents:e.subagents.map(t=>t.name),activeSubagents:e.activeSubagents,runningSubagentCount:e.runningSubagentCount,clientVersion:e.clientVersion,capturedAt:new Date().toISOString()},null,2)}function Lr({copied:e,failed:t}){return e?s.jsx(rn,{className:"text-status-success size-3.5","aria-hidden":!0}):t?s.jsx(an,{className:"text-destructive size-3.5","aria-hidden":!0}):s.jsx(Rn,{className:"size-3.5","aria-hidden":!0})}function zr(e,t){return e?"Copied":t?"Couldn’t copy":"Copy diagnostics"}function Br({diagnostics:e,className:t}){const{copied:n,failed:r,copy:i}=nn(),o=()=>void i(Ur(e));return s.jsxs(H,{variant:"ghost",size:"sm",className:T("gap-1.5 text-xs",t),onClick:o,children:[s.jsx(Lr,{copied:n,failed:r}),zr(n,r)]})}function Di({open:e,onOpenChange:t,diagnostics:n,controls:r,promotionContext:i,urgentAction:o,overflowCount:a=0,addOns:c}){const f=on(),{pins:p,toggle:m,reset:d}=_r(),u=Dr(),N=new Set(p),S=a>0;return s.jsxs(Se,{open:e,onOpenChange:t,children:[s.jsx(ln,{children:s.jsxs(O,{children:[s.jsx(Te,{asChild:!0,children:s.jsx(P,{asChild:!0,children:s.jsxs("button",{type:"button","data-testid":"status-reveal","aria-label":S?`Session details, ${a} more`:"Session details",className:"text-muted-foreground/50 hover:text-muted-foreground inline-flex shrink-0 items-center justify-center gap-0.5 transition-colors duration-150 pointer-coarse:min-h-11 pointer-coarse:min-w-11",children:[s.jsx(cn,{className:"size-4"}),S&&s.jsxs("span",{className:"tabular-nums",children:["+",a]})]})})}),s.jsx(I,{side:"top",children:S?`Session details, ${a} more`:"Session details"})]})}),s.jsxs(Ce,{side:"top",align:"end",className:"w-80 p-3","aria-label":"Session",children:[s.jsx(we,{children:"Session"}),o&&s.jsx(H,{variant:"secondary",className:"mb-3 w-full",disabled:o.pending,onClick:()=>{o.onAction(),t(!1)},children:o.label}),s.jsxs("div",{className:"flex flex-col gap-4",children:[c&&s.jsxs("section",{className:"space-y-1","data-testid":"session-add-ons",children:[s.jsx("h3",{className:"text-muted-foreground px-1 text-xs font-medium tracking-wide uppercase",children:"Add-ons"}),c]}),u.map(l=>s.jsxs("section",{className:"space-y-1",children:[s.jsx("h3",{className:"text-muted-foreground px-1 text-xs font-medium tracking-wide uppercase",children:l.label}),$r(Fr(l.items,r),f?i:null).map(j=>s.jsx(Hr,{item:j,value:Ir(j.key,n),pinned:N.has(j.key),onTogglePin:Ts(j)?()=>m(j.key):null,control:Gr(j.key,r)},j.key)),l.group==="diagnostics"&&s.jsxs(s.Fragment,{children:[s.jsx(Qe,{label:"Queued messages",value:String(n.queueDepth)}),s.jsx(Qe,{label:"Session ID",value:n.sessionId||"—"})]})]},l.group))]}),n.sessionId!==""&&s.jsxs(H,{variant:"ghost",size:"sm",className:"text-muted-foreground mt-3 h-7 w-full justify-start gap-1.5 text-xs",onClick:()=>{t(!1),dn({sessionId:n.sessionId})},children:[s.jsx(un,{className:"size-3.5","aria-hidden":!0}),"View notifications"]}),s.jsxs("div",{className:"mt-4 flex items-center justify-between gap-2",children:[s.jsx(Br,{diagnostics:n}),s.jsxs(H,{variant:"ghost",size:"sm",className:"text-muted-foreground gap-1.5 text-xs",disabled:p.length===0,onClick:d,children:[s.jsx(mn,{className:"size-3.5","aria-hidden":!0}),"Reset pins"]})]})]})]})}function $r(e,t){return t?[...e].sort((n,r)=>r.severity(t)-n.severity(t)):e}function Fr(e,t){return e.filter(n=>n.key!=="plan"||t.plan!==null)}function Gr(e,t){return e==="plan"&&t.plan?s.jsx(fn,{checked:t.plan.active,onCheckedChange:t.plan.onToggle,"aria-label":"Plan first, change nothing until approved"}):null}function Hr({item:e,value:t,pinned:n,onTogglePin:r,control:i}){const o=e.icon;return s.jsxs("div",{"data-testid":`session-row-${e.key}`,className:"flex items-center gap-2 px-1 py-1 text-sm",children:[s.jsx(o,{className:"text-muted-foreground size-3.5 shrink-0","aria-hidden":!0}),s.jsx("span",{className:"shrink-0",children:e.label}),s.jsx("span",{className:"min-w-0 flex-1"}),s.jsx("span",{className:"text-muted-foreground truncate text-xs",title:t??void 0,children:t??"—"}),i,r&&s.jsx("button",{type:"button",onClick:r,"aria-pressed":n,"aria-label":n?`Stop keeping ${e.label} in the status bar`:`Keep ${e.label} in the status bar`,className:T("hover:text-foreground inline-flex size-6 shrink-0 items-center justify-center rounded-md transition-colors duration-150",n?"text-foreground":"text-muted-foreground/50"),children:n?s.jsx(rs,{className:"size-3.5"}):s.jsx(pn,{className:"size-3.5"})})]})}function Qe({label:e,value:t}){return s.jsxs("div",{className:"flex items-center gap-2 px-1 py-1 text-sm",children:[s.jsx("span",{className:"w-3.5 shrink-0","aria-hidden":!0}),s.jsx("span",{className:"shrink-0",children:e}),s.jsx("span",{className:"min-w-0 flex-1"}),s.jsx("span",{className:"text-muted-foreground truncate text-xs",title:t,children:t})]})}function Oi(e){const t=h.useRef(e);h.useEffect(()=>{t.current=e},[e]),h.useEffect(()=>{const n=r=>{const i=r.key==="."||r.key===">";(r.metaKey||r.ctrlKey)&&r.shiftKey&&i&&(r.preventDefault(),t.current())};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)},[])}function Qr(e){const t=new Map;for(const r of e){if(r.type!=="subagent_update")continue;const i=t.get(r.taskId);t.set(r.taskId,{taskId:r.taskId,status:r.status,description:r.description??(i==null?void 0:i.description),toolUses:r.toolUses??(i==null?void 0:i.toolUses),lastToolName:r.lastToolName??(i==null?void 0:i.lastToolName),summary:r.summary??(i==null?void 0:i.summary),ambient:r.ambient??(i==null?void 0:i.ambient)})}const n=[];for(const{ambient:r,...i}of t.values())An({ambient:r,status:i.status})||n.push(i);return n}function Pi(e){const t=[],n=[];for(const r of e)r.status==="running"?t.push(r):n.push(r);return{running:t,finished:n}}const We=new WeakMap;function qe(e,t,n){let r=We.get(e);r||(r=new Set,We.set(e,r)),!r.has(t)&&(r.add(t),n())}function Ke(e,t,n){let r;try{r=n()}catch(i){return qe(e,`${t}:throw`,()=>console.warn(`[extensions] ${e.extensionId}'s status-bar item "${e.id}" threw in ${t}(); it is hidden until it stops throwing.`,i)),!1}return typeof r!="boolean"?(qe(e,`${t}:type`,()=>console.warn(`[extensions] ${e.extensionId}'s status-bar item "${e.id}": ${t}() must return true or false, synchronously, reading only its ctx; it returned ${Wr(r)}, read as false.`)),!1):r}function Wr(e){return e instanceof Promise?"a Promise":e===null?"null":typeof e=="object"?"an object":`a ${typeof e}`}function qr(e,t){const n=[],r=[];for(const i of e){const o=i.when?Ke(i,"when",()=>i.when(t)):!0,a=o&&i.urgent?Ke(i,"urgent",()=>i.urgent(t)):!1;n.push({id:i.id,visible:o,urgent:a}),o&&r.push(i)}return r.sort((i,o)=>(i.priority??0)-(o.priority??0)),{promotion:n,visible:r}}function Ii(e){const t=hn("status-bar");return h.useMemo(()=>qr(t,e),[t,e])}function Kr(e){return e!=null&&e!==!1}function Ui({ctx:e,pins:t,nodes:n}){var o;const r=new Set(t),i=[];for(const a of Ss){if(a.neverInLine)continue;const c=n[a.key];if(!Kr(c))continue;const f=r.has(a.key)&&Ts(a);!f&&!a.promote(e)||i.push({key:a.key,cluster:a.cluster,severity:a.severity(e),pinned:f,rigid:a.rigid===!0,wide:((o=a.wide)==null?void 0:o.call(a,e))===!0,node:c})}return i}const Ve=648,Vr=440,Xr=340,Yr=3,Jr=3,Zr=2,ei=4,si=8,ti=20,ni=me*si+ti,ri=Number.POSITIVE_INFINITY,Xe=[],ii=["cwd"],Ye=["cwd","git"];function ai(e){if(e===null||e<=0)return{density:"full",rightBudget:ri,dropped:Xe};if(e>=Ve){const t=Math.floor((e-Ve)/ni);return{density:"full",rightBudget:ei+t,dropped:Xe}}return e>=Vr?{density:"compact",rightBudget:Yr,dropped:ii}:e>=Xr?{density:"identity",rightBudget:Jr,dropped:Ye}:{density:"avatar",rightBudget:Zr,dropped:Ye}}function oi(e,t){return t.severity!==e.severity?t.severity-e.severity:Number(t.pinned)-Number(e.pinned)}const li=2,ci=2;function Li(e,t){const n=new Set(t.dropped),r=e.filter(c=>c.cluster==="right"),i=new Set;let o=0,a=0;for(const c of[...r].sort(oi)){if(a>=t.rightBudget)break;c.rigid&&o>=li||(c.rigid&&(o+=1),i.add(c.key),a+=c.wide?Math.min(ci,t.rightBudget-a):1)}return{items:e.filter(c=>c.cluster==="right"?i.has(c.key):!n.has(c.key)),overflow:r.length-i.size}}function zi(){const e=h.useRef(null),[t,n]=h.useState(null);h.useLayoutEffect(()=>{const i=e.current;if(!i)return;n(i.getBoundingClientRect().width);const o=new ResizeObserver(a=>{var p,m;const c=a.at(0);if(!c)return;const f=((m=(p=c.contentBoxSize)==null?void 0:p.at(0))==null?void 0:m.inlineSize)??c.contentRect.width;n(f)});return o.observe(i),()=>o.disconnect()},[]);const r=h.useMemo(()=>ai(t),[t]);return{ref:e,budget:r}}const ui=[];function Bi(e){const t=xn(e),n=h.useMemo(()=>In(t),[t]),r=Un(e)==="streaming",i=G(h.useCallback(E=>{var x;return((x=E.sessions[e])==null?void 0:x.sessionStatus)??null},[e])),o=gn(e),a=Bn(e||null,i,r,o.runtime),c=G(h.useCallback(E=>{var x;return((x=E.sessions[e])==null?void 0:x.contextUsage)??null},[e])),f=G(Nn(E=>{var B;const x=(B=E.sessions[e])==null?void 0:B.sessionStatus;return!(x!=null&&x.cacheReadTokens)&&!(x!=null&&x.cacheCreationTokens)?null:{cacheReadTokens:x.cacheReadTokens??0,cacheCreationTokens:x.cacheCreationTokens??0,contextTokens:x.contextTokens}})),p=n.cacheStatus??f,{data:m}=Vn(a.cwd),{data:d}=$n(e),{data:u}=oe(),N=jn(e),S=Ze(e),l=yn(e),j=bn(e),k=kn(e),w=es(e),g=vn(e).length,b=Sn(e),D=h.useMemo(()=>{let E=null;return()=>E??(E=Qr(b))},[b]),R=(t==null?void 0:t.runningSubagentCount)??null,M=h.useMemo(()=>Yn(m),[m]),U=ps(n.contextPercent??a.contextPercent,c),A=(o.model??n.model??a.model)||null;return h.useMemo(()=>({sessionId:e,cwd:a.cwd,git:M,runtime:o.runtime,model:A,selectedModel:a.model||null,effort:a.effort??null,fastMode:a.fastMode,permissionMode:a.permissionMode,contextPercent:U,contextUsage:c,cache:p?{readTokens:p.cacheReadTokens,creationTokens:p.cacheCreationTokens,contextTokens:p.contextTokens}:null,usage:n.usage,connectionState:N,streaming:r,lifecycle:S??null,triggerPending:w,lastEventSeq:l,snapshotCursor:k,lastEventAt:j,queueDepth:g,subagents:d??ui,get activeSubagents(){return D()},runningSubagentCount:R,clientVersion:(u==null?void 0:u.version)??null}),[e,a.cwd,a.model,a.effort,a.fastMode,a.permissionMode,M,o.runtime,A,U,c,p,n,N,S,r,w,l,k,j,g,d,D,R,u==null?void 0:u.version])}export{Ci as A,zi as B,Br as C,Ti as D,fi as E,Bn as F,Ni as G,zn as H,hi as I,An as J,sr as M,ji as P,bi as R,Di as S,Mi as U,Cr as a,Ri as b,Cs as c,Ei as d,gi as e,wi as f,vi as g,Si as h,xi as i,Ai as j,Li as k,qr as l,Ur as m,_i as n,Xn as o,Pi as p,Rr as q,ai as r,Ui as s,Ii as t,Bi as u,Vn as v,yi as w,ki as x,Oi as y,_r as z};
@@ -0,0 +1 @@
1
+ import{Q as a,ad as l,R as s,ah as c,U as r,a7 as d}from"./index-DMYBI16t.js";const u=["relay","unclaimed-chats"];function m(e){return[...u,e]}function h(e="pending",t=!0){const n=a();return l({queryKey:m(e),queryFn:()=>n.listUnclaimedChats(e),enabled:t})}function y(){const e=s(),t=()=>{e.invalidateQueries({queryKey:[...u]})};c("relay_chat_unclaimed",t),c("relay_chat_unclaimed_burst",t)}function i(e){e.invalidateQueries({queryKey:[...u]})}function U(){const e=a(),t=s();return r({mutationFn:({id:n,input:o})=>e.claimUnclaimedChat(n,o),meta:{suppressErrorToast:!0},onSuccess:()=>{i(t),t.invalidateQueries({queryKey:[...d]})}})}function p(){const e=a(),t=s();return r({mutationFn:n=>e.ignoreUnclaimedChat(n),meta:{errorLabel:"Couldn’t ignore this chat"},onSuccess:()=>i(t)})}function v(){const e=a(),t=s();return r({mutationFn:n=>e.blockUnclaimedChat(n),meta:{errorLabel:"Couldn’t block this chat"},onSuccess:()=>i(t)})}function q(){const e=a(),t=s();return r({mutationFn:n=>e.leaveUnclaimedChat(n),meta:{errorLabel:"Couldn’t leave this chat"},onSuccess:()=>i(t)})}export{u as U,y as a,U as b,p as c,v as d,q as e,h as u};