@arbidocs/blocks 0.5.173 → 0.5.175

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/dist/{ConnectedCallDock-AQRVWENO.cjs → ConnectedCallDock-LW7S4ROJ.cjs} +10 -10
  2. package/dist/{ConnectedCallDock-AQRVWENO.cjs.map → ConnectedCallDock-LW7S4ROJ.cjs.map} +1 -1
  3. package/dist/{ConnectedCallRoom-7M4YQ4KA.cjs → ConnectedCallRoom-YXJUNNUX.cjs} +9 -9
  4. package/dist/{ConnectedCallRoom-7M4YQ4KA.cjs.map → ConnectedCallRoom-YXJUNNUX.cjs.map} +1 -1
  5. package/dist/{ConnectedNativeDocxComparison-KGUSDMDH.cjs → ConnectedNativeDocxComparison-AAQJZYZH.cjs} +9 -9
  6. package/dist/{ConnectedNativeDocxComparison-KGUSDMDH.cjs.map → ConnectedNativeDocxComparison-AAQJZYZH.cjs.map} +1 -1
  7. package/dist/{ConnectedPresentation-FOYVUVM3.cjs → ConnectedPresentation-LNDESKYE.cjs} +6 -6
  8. package/dist/{ConnectedPresentation-FOYVUVM3.cjs.map → ConnectedPresentation-LNDESKYE.cjs.map} +1 -1
  9. package/dist/{ConnectedStreamedWordArtifact-ERKIDFFG.cjs → ConnectedStreamedWordArtifact-CSNA2CJD.cjs} +9 -9
  10. package/dist/{ConnectedStreamedWordArtifact-ERKIDFFG.cjs.map → ConnectedStreamedWordArtifact-CSNA2CJD.cjs.map} +1 -1
  11. package/dist/{DocumentReviewCard-EYJ5Q4F4.cjs → DocumentReviewCard-LOUVMFRX.cjs} +14 -14
  12. package/dist/{DocumentReviewCard-EYJ5Q4F4.cjs.map → DocumentReviewCard-LOUVMFRX.cjs.map} +1 -1
  13. package/dist/{FilesViewerDialog-AZUR4XBV.cjs → FilesViewerDialog-2NZR4MHD.cjs} +14 -14
  14. package/dist/{FilesViewerDialog-AZUR4XBV.cjs.map → FilesViewerDialog-2NZR4MHD.cjs.map} +1 -1
  15. package/dist/{WorkspaceTableView-YQERZOHV.cjs → WorkspaceTableView-LGDLG3TX.cjs} +4 -4
  16. package/dist/{WorkspaceTableView-YQERZOHV.cjs.map → WorkspaceTableView-LGDLG3TX.cjs.map} +1 -1
  17. package/dist/agents/index.cjs +172 -172
  18. package/dist/agents/runs/AgentBar.js +1 -1
  19. package/dist/agents/runs/AgentBar.js.map +2 -2
  20. package/dist/{ai-U2UMKQZO.cjs → ai-NZKIMYW5.cjs} +14 -14
  21. package/dist/ai-NZKIMYW5.cjs.map +1 -0
  22. package/dist/calls/index.cjs +45 -45
  23. package/dist/chat/Message.js +2 -1
  24. package/dist/chat/Message.js.map +2 -2
  25. package/dist/chat/index.cjs +55 -55
  26. package/dist/{chunk-2KGU5G6Z.cjs → chunk-5E6ZQ5EO.cjs} +234 -37
  27. package/dist/chunk-5E6ZQ5EO.cjs.map +1 -0
  28. package/dist/{chunk-D5QGLBQC.cjs → chunk-5G33DATM.cjs} +36 -36
  29. package/dist/{chunk-D5QGLBQC.cjs.map → chunk-5G33DATM.cjs.map} +1 -1
  30. package/dist/{chunk-QHXFXV2F.cjs → chunk-5YLNNO3N.cjs} +4 -4
  31. package/dist/{chunk-QHXFXV2F.cjs.map → chunk-5YLNNO3N.cjs.map} +1 -1
  32. package/dist/{chunk-GPPPH37H.cjs → chunk-6DHDITKK.cjs} +3 -3
  33. package/dist/{chunk-GPPPH37H.cjs.map → chunk-6DHDITKK.cjs.map} +1 -1
  34. package/dist/{chunk-IJBCEBGR.cjs → chunk-7OMRSZOJ.cjs} +28 -28
  35. package/dist/{chunk-IJBCEBGR.cjs.map → chunk-7OMRSZOJ.cjs.map} +1 -1
  36. package/dist/{chunk-IJ4JKHEC.cjs → chunk-7TEHA3JK.cjs} +18 -18
  37. package/dist/{chunk-IJ4JKHEC.cjs.map → chunk-7TEHA3JK.cjs.map} +1 -1
  38. package/dist/{chunk-TNBNDY2J.cjs → chunk-7VUO4QZH.cjs} +4 -4
  39. package/dist/{chunk-TNBNDY2J.cjs.map → chunk-7VUO4QZH.cjs.map} +1 -1
  40. package/dist/{chunk-XGMA7ITI.cjs → chunk-A257IJ5J.cjs} +6 -6
  41. package/dist/{chunk-XGMA7ITI.cjs.map → chunk-A257IJ5J.cjs.map} +1 -1
  42. package/dist/{chunk-CHZ6SPOT.cjs → chunk-DI6UEQCZ.cjs} +4 -4
  43. package/dist/{chunk-CHZ6SPOT.cjs.map → chunk-DI6UEQCZ.cjs.map} +1 -1
  44. package/dist/{chunk-5PZZRBAG.cjs → chunk-DVRAM3J4.cjs} +4 -4
  45. package/dist/{chunk-5PZZRBAG.cjs.map → chunk-DVRAM3J4.cjs.map} +1 -1
  46. package/dist/{chunk-TMK5YVNN.cjs → chunk-EBY2JHL3.cjs} +56 -56
  47. package/dist/{chunk-TMK5YVNN.cjs.map → chunk-EBY2JHL3.cjs.map} +1 -1
  48. package/dist/{chunk-RBNMRU4V.cjs → chunk-GAHGZBBM.cjs} +23 -23
  49. package/dist/{chunk-RBNMRU4V.cjs.map → chunk-GAHGZBBM.cjs.map} +1 -1
  50. package/dist/{chunk-H2BUDSKT.cjs → chunk-HSYRI3JQ.cjs} +6 -6
  51. package/dist/{chunk-H2BUDSKT.cjs.map → chunk-HSYRI3JQ.cjs.map} +1 -1
  52. package/dist/{chunk-O2D4VIWD.cjs → chunk-LYJFE37D.cjs} +11 -11
  53. package/dist/{chunk-O2D4VIWD.cjs.map → chunk-LYJFE37D.cjs.map} +1 -1
  54. package/dist/{chunk-K7JV2OV3.cjs → chunk-MXP32DA2.cjs} +6 -6
  55. package/dist/{chunk-K7JV2OV3.cjs.map → chunk-MXP32DA2.cjs.map} +1 -1
  56. package/dist/{chunk-ZUQGG3FL.cjs → chunk-MZPBZSKS.cjs} +16 -16
  57. package/dist/{chunk-ZUQGG3FL.cjs.map → chunk-MZPBZSKS.cjs.map} +1 -1
  58. package/dist/{chunk-TF3JNVHS.cjs → chunk-NFXHBTAO.cjs} +4 -4
  59. package/dist/{chunk-TF3JNVHS.cjs.map → chunk-NFXHBTAO.cjs.map} +1 -1
  60. package/dist/{chunk-MGI5FR6I.cjs → chunk-NTQJHLYM.cjs} +9 -9
  61. package/dist/{chunk-MGI5FR6I.cjs.map → chunk-NTQJHLYM.cjs.map} +1 -1
  62. package/dist/{chunk-4BOX77K3.cjs → chunk-OIMDCS4Y.cjs} +5 -5
  63. package/dist/{chunk-4BOX77K3.cjs.map → chunk-OIMDCS4Y.cjs.map} +1 -1
  64. package/dist/{chunk-FX5TZ6JU.cjs → chunk-OIYKKUAN.cjs} +3 -3
  65. package/dist/{chunk-FX5TZ6JU.cjs.map → chunk-OIYKKUAN.cjs.map} +1 -1
  66. package/dist/{chunk-7VZHGEA4.cjs → chunk-PUKLWHV6.cjs} +6 -6
  67. package/dist/{chunk-7VZHGEA4.cjs.map → chunk-PUKLWHV6.cjs.map} +1 -1
  68. package/dist/{chunk-U2L4GTMV.cjs → chunk-PXC6RSHQ.cjs} +4 -4
  69. package/dist/{chunk-U2L4GTMV.cjs.map → chunk-PXC6RSHQ.cjs.map} +1 -1
  70. package/dist/{chunk-ZOI4DFSB.cjs → chunk-SZ4U6GYC.cjs} +31 -31
  71. package/dist/{chunk-ZOI4DFSB.cjs.map → chunk-SZ4U6GYC.cjs.map} +1 -1
  72. package/dist/{chunk-6PKP7UT7.cjs → chunk-TAGA6LNP.cjs} +8 -8
  73. package/dist/{chunk-6PKP7UT7.cjs.map → chunk-TAGA6LNP.cjs.map} +1 -1
  74. package/dist/{chunk-QDXZVJWN.cjs → chunk-TNVCTYZI.cjs} +37 -13
  75. package/dist/{chunk-QDXZVJWN.cjs.map → chunk-TNVCTYZI.cjs.map} +1 -1
  76. package/dist/{chunk-THGWHKWR.cjs → chunk-VCVB2OP7.cjs} +54 -47
  77. package/dist/chunk-VCVB2OP7.cjs.map +1 -0
  78. package/dist/{chunk-HYUKPHCT.cjs → chunk-WJIAA6G3.cjs} +12 -3
  79. package/dist/chunk-WJIAA6G3.cjs.map +1 -0
  80. package/dist/{chunk-7FWP7W34.cjs → chunk-Z574BY3H.cjs} +4 -4
  81. package/dist/{chunk-7FWP7W34.cjs.map → chunk-Z574BY3H.cjs.map} +1 -1
  82. package/dist/{chunk-KBRDUFXG.cjs → chunk-ZHLBTIJJ.cjs} +4 -3
  83. package/dist/chunk-ZHLBTIJJ.cjs.map +1 -0
  84. package/dist/{chunk-WQ3GB74G.cjs → chunk-ZSQZZGC7.cjs} +5 -5
  85. package/dist/{chunk-WQ3GB74G.cjs.map → chunk-ZSQZZGC7.cjs.map} +1 -1
  86. package/dist/{chunk-2ZNADJ7G.cjs → chunk-ZT6C4MNX.cjs} +4 -4
  87. package/dist/{chunk-2ZNADJ7G.cjs.map → chunk-ZT6C4MNX.cjs.map} +1 -1
  88. package/dist/collaboration/direct-messages/DmParts.d.ts +3 -1
  89. package/dist/collaboration/direct-messages/DmParts.js +36 -12
  90. package/dist/collaboration/direct-messages/DmParts.js.map +2 -2
  91. package/dist/collaboration/index.cjs +69 -69
  92. package/dist/connect/docx.cjs +12 -12
  93. package/dist/connect/index.cjs +932 -856
  94. package/dist/connect/index.cjs.map +1 -1
  95. package/dist/connect/viewer.cjs +12 -12
  96. package/dist/connection/contacts/ConnectedContactsPanel.js +2 -2
  97. package/dist/connection/contacts/ConnectedContactsPanel.js.map +2 -2
  98. package/dist/connection/contacts/ConnectedInviteContactsDialog.js +2 -2
  99. package/dist/connection/contacts/ConnectedInviteContactsDialog.js.map +2 -2
  100. package/dist/connection/conversation/ConnectedConversation.js +1 -2
  101. package/dist/connection/conversation/ConnectedConversation.js.map +2 -2
  102. package/dist/connection/conversation/MessageLiveSeconds.d.ts +2 -1
  103. package/dist/connection/conversation/MessageLiveSeconds.js +8 -1
  104. package/dist/connection/conversation/MessageLiveSeconds.js.map +2 -2
  105. package/dist/connection/entities/ConnectedUserEntity.js +3 -8
  106. package/dist/connection/entities/ConnectedUserEntity.js.map +2 -2
  107. package/dist/connection/messenger/ConnectedChatMessageBody.d.ts +2 -1
  108. package/dist/connection/messenger/ConnectedChatMessageBody.js +14 -2
  109. package/dist/connection/messenger/ConnectedChatMessageBody.js.map +2 -2
  110. package/dist/connection/messenger/ConnectedChatThread.js +71 -20
  111. package/dist/connection/messenger/ConnectedChatThread.js.map +2 -2
  112. package/dist/connection/messenger/ConnectedMessenger.js +59 -52
  113. package/dist/connection/messenger/ConnectedMessenger.js.map +2 -2
  114. package/dist/connection/messenger/DmAgentProgress.d.ts +2 -1
  115. package/dist/connection/messenger/DmAgentProgress.js +17 -4
  116. package/dist/connection/messenger/DmAgentProgress.js.map +2 -2
  117. package/dist/connection/panels/ConnectedPanelHost.js +1 -1
  118. package/dist/connection/panels/ConnectedPanelHost.js.map +2 -2
  119. package/dist/connection/settings-page/SessionStatusIcon.js +1 -1
  120. package/dist/connection/settings-page/SessionStatusIcon.js.map +1 -1
  121. package/dist/connection/settings-page/featuresSection.js +1 -1
  122. package/dist/connection/settings-page/featuresSection.js.map +2 -2
  123. package/dist/embed/index.cjs +17 -17
  124. package/dist/files/index.cjs +227 -227
  125. package/dist/index.cjs +373 -373
  126. package/dist/pages/index.cjs +18 -18
  127. package/dist/settings/FloatingPanel.js +10 -1
  128. package/dist/settings/FloatingPanel.js.map +2 -2
  129. package/dist/settings/index.cjs +2 -2
  130. package/dist/shell/FloatingAssistantSurface.d.ts +6 -0
  131. package/dist/shell/FloatingAssistantSurface.js +165 -0
  132. package/dist/shell/FloatingAssistantSurface.js.map +7 -0
  133. package/dist/shell/PanelPortal.d.ts +12 -0
  134. package/dist/shell/PanelPortal.js +6 -15
  135. package/dist/shell/PanelPortal.js.map +2 -2
  136. package/dist/shell/floating-assistant-context.d.ts +2 -0
  137. package/dist/shell/floating-assistant-context.js +7 -0
  138. package/dist/shell/floating-assistant-context.js.map +7 -0
  139. package/dist/shell/index.cjs +3 -3
  140. package/dist/shell/useFloatingDrag.d.ts +1 -0
  141. package/dist/shell/useFloatingDrag.js +69 -21
  142. package/dist/shell/useFloatingDrag.js.map +2 -2
  143. package/dist/site/index.cjs +5 -5
  144. package/dist/studio/index.cjs +6 -6
  145. package/dist/styles.css +1 -1
  146. package/dist/workflow-canvas/index.cjs +30 -30
  147. package/node_modules/@arbidocs/coedit/package.json +1 -1
  148. package/package.json +5 -5
  149. package/dist/ai-U2UMKQZO.cjs.map +0 -1
  150. package/dist/chunk-2KGU5G6Z.cjs.map +0 -1
  151. package/dist/chunk-HYUKPHCT.cjs.map +0 -1
  152. package/dist/chunk-KBRDUFXG.cjs.map +0 -1
  153. package/dist/chunk-THGWHKWR.cjs.map +0 -1
@@ -105,6 +105,7 @@ function useFloatingDrag(panelId, enabled) {
105
105
  const ref = react.useRef(null);
106
106
  const previewRef = react.useRef(null);
107
107
  const frame = react.useRef(null);
108
+ const suppressClick = react.useRef(false);
108
109
  const storageKey = `arbi:floating-panel-position:${panelId}`;
109
110
  const [position, setPosition] = react.useState(() => {
110
111
  try {
@@ -115,13 +116,17 @@ function useFloatingDrag(panelId, enabled) {
115
116
  }
116
117
  });
117
118
  const current = react.useRef(position);
119
+ const preferred = react.useRef(position);
118
120
  const drag = react.useRef(null);
119
- const boundsOf = (node) => ({
120
- minX: 48 - node.offsetLeft,
121
- maxX: node.parentElement.clientWidth - 12 - node.offsetLeft - node.offsetWidth,
122
- minY: 12 - node.offsetTop,
123
- maxY: node.parentElement.clientHeight - 12 - node.offsetTop - node.offsetHeight
124
- });
121
+ const boundsOf = (node) => {
122
+ const parent = node.parentElement.getBoundingClientRect();
123
+ return {
124
+ minX: 12 - parent.left - node.offsetLeft,
125
+ maxX: window.innerWidth - 12 - parent.left - node.offsetLeft - node.offsetWidth,
126
+ minY: 12 - node.offsetTop,
127
+ maxY: parent.height - 12 - node.offsetTop - node.offsetHeight
128
+ };
129
+ };
125
130
  const move = react.useCallback(
126
131
  (next, persist = false) => {
127
132
  if (!ref.current) return;
@@ -131,6 +136,7 @@ function useFloatingDrag(panelId, enabled) {
131
136
  (previous) => previous.x === value.x && previous.y === value.y ? previous : value
132
137
  );
133
138
  if (persist) {
139
+ preferred.current = value;
134
140
  try {
135
141
  localStorage.setItem(storageKey, JSON.stringify(value));
136
142
  } catch {
@@ -144,17 +150,17 @@ function useFloatingDrag(panelId, enabled) {
144
150
  frame.current = null;
145
151
  }, []);
146
152
  const cancel = react.useCallback(() => {
147
- const pointer = drag.current?.pointer;
153
+ const gesture = drag.current;
148
154
  drag.current = null;
149
155
  cancelFrame();
150
156
  setIsDragging(false);
151
- if (pointer !== void 0 && ref.current?.hasPointerCapture(pointer))
152
- ref.current.releasePointerCapture(pointer);
157
+ if (gesture?.capture.hasPointerCapture(gesture.pointer))
158
+ gesture.capture.releasePointerCapture(gesture.pointer);
153
159
  }, [cancelFrame]);
154
160
  react.useLayoutEffect(() => {
155
161
  if (!enabled) return;
156
162
  const measure = () => {
157
- if (!drag.current) move(current.current);
163
+ if (!drag.current) move(preferred.current);
158
164
  };
159
165
  measure();
160
166
  const observer = new ResizeObserver(measure);
@@ -171,7 +177,7 @@ function useFloatingDrag(panelId, enabled) {
171
177
  if (!isDragging) return;
172
178
  const cursor = document.body.style.cursor;
173
179
  const select = document.body.style.userSelect;
174
- document.body.style.cursor = "grabbing";
180
+ document.body.style.cursor = "move";
175
181
  document.body.style.userSelect = "none";
176
182
  const escape = (event) => {
177
183
  if (event.key === "Escape") {
@@ -189,7 +195,14 @@ function useFloatingDrag(panelId, enabled) {
189
195
  window.removeEventListener("blur", cancel);
190
196
  };
191
197
  }, [isDragging, cancel]);
192
- const isHandle = (target) => target instanceof Element && !!target.closest("[data-floating-drag-handle]");
198
+ const handleOf = (target) => {
199
+ if (!(target instanceof Element) || target.closest("[data-floating-no-drag]")) return null;
200
+ const handle = target.closest("[data-floating-drag-handle]");
201
+ const control = target.closest(
202
+ "button,a,input,textarea,select,[contenteditable=true],[role=button]"
203
+ );
204
+ return handle && (!control || control === handle) ? handle : null;
205
+ };
193
206
  const targetOf = (event) => {
194
207
  const start = drag.current;
195
208
  return clamp(
@@ -210,8 +223,10 @@ function useFloatingDrag(panelId, enabled) {
210
223
  } : void 0,
211
224
  style: enabled ? { transform: `translate3d(${position.x}px, ${position.y}px, 0)` } : void 0,
212
225
  onPointerDownCapture: (event) => {
213
- if (!enabled || event.button !== 0 || !isHandle(event.target)) return;
214
- event.preventDefault();
226
+ if (drag.current) return;
227
+ suppressClick.current = false;
228
+ const handle = handleOf(event.target);
229
+ if (!enabled || event.button !== 0 || !handle) return;
215
230
  const node = event.currentTarget;
216
231
  drag.current = {
217
232
  x: event.clientX,
@@ -219,6 +234,8 @@ function useFloatingDrag(panelId, enabled) {
219
234
  position: current.current,
220
235
  preview: current.current,
221
236
  pointer: event.pointerId,
237
+ capture: handle,
238
+ active: false,
222
239
  bounds: boundsOf(node),
223
240
  box: {
224
241
  left: node.offsetLeft,
@@ -227,11 +244,35 @@ function useFloatingDrag(panelId, enabled) {
227
244
  height: node.offsetHeight
228
245
  }
229
246
  };
230
- setIsDragging(true);
231
- node.setPointerCapture(event.pointerId);
247
+ handle.setPointerCapture(event.pointerId);
232
248
  },
233
249
  onPointerMove: (event) => {
234
250
  if (drag.current?.pointer !== event.pointerId) return;
251
+ if (!drag.current.active) {
252
+ if (Math.hypot(event.clientX - drag.current.x, event.clientY - drag.current.y) < 4) return;
253
+ const node = ref.current;
254
+ const surface = node.querySelector("[data-floating-surface]");
255
+ const box = surface?.getBoundingClientRect();
256
+ if (box?.width) {
257
+ const parent = node.parentElement.getBoundingClientRect();
258
+ drag.current.box = {
259
+ left: box.left - parent.left - current.current.x,
260
+ top: box.top - parent.top - current.current.y,
261
+ width: box.width,
262
+ height: box.height
263
+ };
264
+ drag.current.bounds = {
265
+ minX: current.current.x + 12 - box.left,
266
+ maxX: current.current.x + window.innerWidth - 12 - box.right,
267
+ minY: current.current.y + parent.top + 12 - box.top,
268
+ maxY: current.current.y + parent.bottom - 12 - box.bottom
269
+ };
270
+ }
271
+ drag.current.active = true;
272
+ suppressClick.current = true;
273
+ if (document.activeElement === drag.current.capture) drag.current.capture.blur();
274
+ setIsDragging(true);
275
+ }
235
276
  drag.current.preview = targetOf(event);
236
277
  if (frame.current === null)
237
278
  frame.current = requestAnimationFrame(() => {
@@ -243,18 +284,25 @@ function useFloatingDrag(panelId, enabled) {
243
284
  },
244
285
  onPointerUp: (event) => {
245
286
  if (drag.current?.pointer !== event.pointerId) return;
246
- const next = targetOf(event);
287
+ const gesture = drag.current;
288
+ const next = gesture.active ? targetOf(event) : null;
247
289
  drag.current = null;
248
290
  cancelFrame();
249
- move(next, true);
291
+ if (next) move(next, true);
250
292
  setIsDragging(false);
251
- if (event.currentTarget.hasPointerCapture(event.pointerId))
252
- event.currentTarget.releasePointerCapture(event.pointerId);
293
+ if (gesture.capture.hasPointerCapture(event.pointerId))
294
+ gesture.capture.releasePointerCapture(event.pointerId);
295
+ },
296
+ onClickCapture: (event) => {
297
+ if (!suppressClick.current) return;
298
+ suppressClick.current = false;
299
+ event.preventDefault();
300
+ event.stopPropagation();
253
301
  },
254
302
  onPointerCancel: cancel,
255
303
  onLostPointerCapture: cancel,
256
304
  onKeyDownCapture: (event) => {
257
- if (!enabled || !isHandle(event.target)) return;
305
+ if (!enabled || !handleOf(event.target)) return;
258
306
  const amount = event.shiftKey ? 50 : 10;
259
307
  const deltas = {
260
308
  ArrowLeft: { x: -amount, y: 0 },
@@ -278,6 +326,163 @@ function useFloatingDrag(panelId, enabled) {
278
326
  }
279
327
  };
280
328
  }
329
+ var FloatingAssistantIdentity = react.createContext(null);
330
+ function FloatingAssistantSurface({
331
+ children,
332
+ dragging,
333
+ position
334
+ }) {
335
+ const root = react.useRef(null);
336
+ const surfaceId = react.useId();
337
+ const lastSize = react.useRef({ width: 400, height: 380 });
338
+ const preferredDirection = react.useRef({ up: true, left: true });
339
+ const wasDragging = react.useRef(false);
340
+ const [identity, setIdentity] = react.useState({ name: "Assistant", working: false });
341
+ const updateIdentity = react.useCallback((name, working) => {
342
+ setIdentity((old) => old.name === name && old.working === working ? old : { name, working });
343
+ }, []);
344
+ const [hovered, setHovered] = react.useState(false);
345
+ const [focused, setFocused] = react.useState(false);
346
+ const [expanded, setExpanded] = react.useState(false);
347
+ const [placement, setPlacement] = react.useState({ up: true, left: true, width: 400, height: 380 });
348
+ react.useLayoutEffect(() => {
349
+ if (dragging) {
350
+ wasDragging.current = true;
351
+ return;
352
+ }
353
+ if (!root.current) return;
354
+ const dropped = wasDragging.current;
355
+ wasDragging.current = false;
356
+ const measure = () => {
357
+ const box = root.current.getBoundingClientRect();
358
+ const boundary = root.current.closest("[data-floating-boundary]")?.getBoundingClientRect();
359
+ const top = (boundary?.top ?? 0) + 12;
360
+ const bottom = Math.min(window.innerHeight, boundary?.bottom ?? window.innerHeight) - 12;
361
+ const surface = root.current.querySelector("[data-floating-surface]")?.getBoundingClientRect();
362
+ if (surface?.width && surface.height) lastSize.current = surface;
363
+ setPlacement(() => {
364
+ const preferred = preferredDirection.current;
365
+ const keepHorizontal = preferred.left ? box.right - 12 >= lastSize.current.width : window.innerWidth - box.left - 12 >= lastSize.current.width;
366
+ const keepVertical = preferred.up ? box.bottom - top >= lastSize.current.height : bottom - box.top >= lastSize.current.height;
367
+ const up = keepVertical ? preferred.up : box.top >= (top + bottom) / 2;
368
+ const left = keepHorizontal ? preferred.left : box.left >= window.innerWidth / 2;
369
+ if (dropped) preferredDirection.current = { up, left };
370
+ return {
371
+ up,
372
+ left,
373
+ width: Math.min(400, left ? box.right - 12 : window.innerWidth - box.left - 12),
374
+ height: Math.max(96, Math.min(380, up ? box.bottom - top : bottom - box.top))
375
+ };
376
+ });
377
+ };
378
+ measure();
379
+ window.addEventListener("resize", measure);
380
+ return () => window.removeEventListener("resize", measure);
381
+ }, [dragging, position, expanded]);
382
+ react.useEffect(() => {
383
+ const surface = root.current.querySelector("[data-floating-surface]");
384
+ const observer = new ResizeObserver(() => {
385
+ const box = surface.getBoundingClientRect();
386
+ if (box.width && box.height) lastSize.current = box;
387
+ });
388
+ observer.observe(surface);
389
+ return () => observer.disconnect();
390
+ }, []);
391
+ react.useEffect(() => {
392
+ if (dragging) return;
393
+ const timer = setTimeout(() => setExpanded(hovered || focused), hovered || focused ? 80 : 350);
394
+ return () => clearTimeout(timer);
395
+ }, [hovered, focused, dragging]);
396
+ const open = () => {
397
+ setExpanded(true);
398
+ requestAnimationFrame(() => root.current?.querySelector("textarea")?.focus());
399
+ };
400
+ const reserveLauncher = placement.left ? "pr-16" : "pl-16";
401
+ return /* @__PURE__ */ jsxRuntime.jsx(FloatingAssistantIdentity.Provider, { value: updateIdentity, children: /* @__PURE__ */ jsxRuntime.jsxs(
402
+ "div",
403
+ {
404
+ ref: root,
405
+ "data-testid": "floating-assistant",
406
+ "data-expanded": expanded,
407
+ className: "relative size-12 pointer-events-none",
408
+ onPointerEnter: () => setHovered(true),
409
+ onPointerLeave: () => {
410
+ setHovered(false);
411
+ if (!document.activeElement || document.activeElement === document.body || !document.activeElement.isConnected)
412
+ setFocused(false);
413
+ },
414
+ onFocusCapture: () => setFocused(true),
415
+ onBlurCapture: (event) => {
416
+ if (!event.currentTarget.contains(event.relatedTarget)) setFocused(false);
417
+ },
418
+ children: [
419
+ /* @__PURE__ */ jsxRuntime.jsxs(
420
+ "section",
421
+ {
422
+ id: surfaceId,
423
+ "data-floating-surface": true,
424
+ "data-floating-drag-handle": true,
425
+ "data-testid": "floating-assistant-surface",
426
+ "aria-label": `${identity.name} compact assistant`,
427
+ hidden: !expanded,
428
+ inert: !expanded,
429
+ className: `${expanded ? "flex animate-in fade-in duration-150 motion-reduce:animate-none" : "hidden"} absolute pointer-events-auto cursor-move flex-col overflow-hidden rounded-none border border-border/60 bg-card text-card-foreground shadow-lg [&_button:not([data-floating-drag-handle])]:cursor-pointer [&_button:disabled]:cursor-default [&_a]:cursor-pointer [&_textarea]:cursor-text [&_input]:cursor-text ${placement.up ? placement.left ? "[&_[data-testid=arbi-dm-composer]]:pr-16" : "[&_[data-testid=arbi-dm-composer]]:pl-16" : ""}`,
430
+ style: {
431
+ width: placement.width,
432
+ maxHeight: placement.height,
433
+ ...placement.up ? { bottom: 0 } : { top: 0 },
434
+ ...placement.left ? { right: 0 } : { left: 0 }
435
+ },
436
+ children: [
437
+ /* @__PURE__ */ jsxRuntime.jsxs(
438
+ "button",
439
+ {
440
+ type: "button",
441
+ "data-floating-drag-handle": true,
442
+ "aria-label": `Move ${identity.name}`,
443
+ "aria-controls": surfaceId,
444
+ "aria-keyshortcuts": "ArrowUp ArrowDown ArrowLeft ArrowRight Home",
445
+ onClick: open,
446
+ title: "Drag to move \xB7 Arrow keys to position \xB7 Home to reset",
447
+ className: `shrink-0 cursor-move select-none touch-none flex items-center gap-2 px-4 py-3 text-left text-sm font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring ${!placement.up ? reserveLauncher : ""}`,
448
+ children: [
449
+ /* @__PURE__ */ jsxRuntime.jsx(ui.ArbiBotHeadIcon, { className: "size-4 text-primary" }),
450
+ identity.name
451
+ ]
452
+ }
453
+ ),
454
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex min-h-0 flex-1 flex-col", children })
455
+ ]
456
+ }
457
+ ),
458
+ /* @__PURE__ */ jsxRuntime.jsxs(
459
+ "button",
460
+ {
461
+ type: "button",
462
+ "data-testid": "floating-assistant-launcher",
463
+ "data-floating-drag-handle": true,
464
+ "aria-label": `Open ${identity.name}`,
465
+ "aria-expanded": expanded,
466
+ "aria-controls": surfaceId,
467
+ title: `${identity.name} \xB7 Drag to move`,
468
+ onClick: open,
469
+ className: `absolute inset-0 z-10 flex size-12 cursor-move touch-none items-center justify-center rounded-full pointer-events-auto bg-primary text-primary-foreground hover:bg-primary/90 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ${expanded ? "" : "shadow-md"}`,
470
+ children: [
471
+ /* @__PURE__ */ jsxRuntime.jsx(ui.ArbiBotHeadIcon, { className: "size-6" }),
472
+ identity.working && /* @__PURE__ */ jsxRuntime.jsx(
473
+ "span",
474
+ {
475
+ "aria-label": "Working",
476
+ className: "absolute right-0 top-0 size-2.5 animate-pulse rounded-full border-2 border-card bg-primary"
477
+ }
478
+ )
479
+ ]
480
+ }
481
+ )
482
+ ]
483
+ }
484
+ ) });
485
+ }
281
486
  var OVERLAY_DEFAULT_PX = 544;
282
487
  var OVERLAY_MIN_PX = 360;
283
488
  function OverlaySheet({
@@ -371,6 +576,7 @@ function OverlaySheet({
371
576
  className: `${scoped ? "absolute inset-0" : "fixed inset-0"} ${floating ? "z-[45] pointer-events-none" : scoped ? "z-40" : "z-50"}`,
372
577
  style: !floating && dockInset ? { right: dockInset } : void 0,
373
578
  "data-testid": `${panelId}-overlay`,
579
+ "data-floating-boundary": floating || void 0,
374
580
  children: [
375
581
  floating && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
376
582
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -388,7 +594,7 @@ function OverlaySheet({
388
594
  style: previewStyle,
389
595
  "aria-hidden": "true",
390
596
  "data-testid": `${panelId}-move-outline`,
391
- className: "absolute z-50 pointer-events-none rounded-[26px] border-2 border-dashed border-primary/80 bg-primary/[0.04] will-change-transform"
597
+ className: "absolute z-50 pointer-events-none rounded-none border-2 border-dashed border-primary/80 bg-primary/[0.04] will-change-transform"
392
598
  }
393
599
  )
394
600
  ] }),
@@ -410,7 +616,8 @@ function OverlaySheet({
410
616
  ...floatingHandlers,
411
617
  "data-dragging": isDragging || void 0,
412
618
  style: floating ? {
413
- width: Math.min(width, 480),
619
+ width: 48,
620
+ height: 48,
414
621
  maxWidth: "calc(100% - 32px)",
415
622
  maxHeight: "calc(100% - 32px)",
416
623
  ...floatingPosition
@@ -429,18 +636,7 @@ function OverlaySheet({
429
636
  "data-testid": `${panelId}-overlay-resize-handle`
430
637
  }
431
638
  ),
432
- floating && /* @__PURE__ */ jsxRuntime.jsx(
433
- "button",
434
- {
435
- type: "button",
436
- "data-floating-drag-handle": true,
437
- "aria-label": "Move conversation",
438
- title: "Drag to move \xB7 Arrow keys to position \xB7 Home to reset",
439
- className: "absolute -left-10 bottom-4 flex h-7 w-10 cursor-grab touch-none items-center justify-start rounded-full bg-transparent text-muted-foreground opacity-0 pointer-events-none transition-opacity duration-150 group-hover/floating:opacity-100 group-hover/floating:pointer-events-auto group-data-[dragging=true]/floating:opacity-100 focus-visible:opacity-100 focus-visible:pointer-events-auto focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring active:cursor-grabbing",
440
- children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex size-7 items-center justify-center rounded-full bg-card", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Move, { className: "size-3.5" }) })
441
- }
442
- ),
443
- children
639
+ floating ? /* @__PURE__ */ jsxRuntime.jsx(FloatingAssistantSurface, { dragging: isDragging, position: floatingPosition?.transform, children }) : children
444
640
  ]
445
641
  }
446
642
  ),
@@ -561,7 +757,8 @@ function PanelPortal({
561
757
  return null;
562
758
  }
563
759
 
760
+ exports.FloatingAssistantIdentity = FloatingAssistantIdentity;
564
761
  exports.PanelModeSwitcher = PanelModeSwitcher;
565
762
  exports.PanelPortal = PanelPortal;
566
- //# sourceMappingURL=chunk-2KGU5G6Z.cjs.map
567
- //# sourceMappingURL=chunk-2KGU5G6Z.cjs.map
763
+ //# sourceMappingURL=chunk-5E6ZQ5EO.cjs.map
764
+ //# sourceMappingURL=chunk-5E6ZQ5EO.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/shell/PanelModeSwitcher.tsx","../src/shell/useFloatingDrag.ts","../src/shell/floating-assistant-context.ts","../src/shell/FloatingAssistantSurface.tsx","../src/shell/PanelPortal.tsx"],"names":["jsx","Button","Tooltip","TooltipTrigger","TooltipContent","useIsPhone","useMediaQuery","X","jsxs","ExternalLink","PanelRight","PictureInPicture2","useState","useRef","useCallback","useLayoutEffect","useEffect","createContext","useId","ArbiBotHeadIcon","DEFAULT_OVERLAY_ZONE_ID","children","Fragment","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,WAAA,KAAgB,IAAA;AAAA,UACxB,QAAA;AAAA,UAEC;AAAA;AAAA,OACH;AAAA,MACA,eAAe,QAAA,CAAS;AAAA,KAC1B;AAAA,EACF;AAGA,EAAA,IAAI,SAAS,MAAA,EAAQ;AACnB,IAAA,MAAM,QAAA,GAAW,YAAA;AACjB,IAAA,IAAI,QAAA,EAAU;AACZ,MAAA,OAAOwB,qBAAA,CAAa,UAAU,QAAQ,CAAA;AAAA,IACxC;AAAA,EACF;AAGA,EAAA,MAAM,QAAA,GAAW,YAAA;AACjB,EAAA,IAAI,QAAA,EAAU;AACZ,IAAA,OAAOA,qBAAA,CAAa,UAAU,QAAQ,CAAA;AAAA,EACxC;AAGA,EAAA,OAAO,IAAA;AACT","file":"chunk-5E6ZQ5EO.cjs","sourcesContent":["/**\n * PanelModeSwitcher Component\n *\n * User-selectable placements are: popped out, docked, or overlay. `main` is\n * NOT user-selectable — the system decides which surfaces render full-width\n * (e.g. the DM modal); the user just moves floating panels between popout /\n * docked / overlay. The switcher shows a button for each placement you're not\n * currently in (plus close):\n * - Popout/pop-in toggle (unless disablePopout).\n * - Split-screen button (when not docked).\n * - Float-as-overlay button (when not overlay).\n * - Popout mode shows just the pop-in toggle (the window has its own close).\n */\n\nimport { Button, Tooltip, TooltipContent, TooltipTrigger } from '@arbidocs/react/ui'\nimport { ExternalLink, PanelRight, PictureInPicture2, X } from 'lucide-react'\nimport type { MouseEvent, ReactNode } from 'react'\nimport type { ArbiPanelMode as PanelMode } from '@arbidocs/react'\nimport { useIsPhone, useMediaQuery } from '../lib/use-media-query'\n\nconst btnClass = 'h-7 w-7 p-0 text-muted-foreground hover:text-foreground'\n\ninterface SwitcherButtonProps {\n label: string\n /** True when rendered inside a popout window (see note below). */\n inPopout?: boolean\n onClick: (event: MouseEvent) => void\n testId: string\n children: ReactNode\n}\n\n// Icon-only buttons get a visible tooltip with their label, so the icon's meaning\n// is readable on hover and on keyboard focus. Radix tooltips portal into the main\n// window, which would misplace them inside a popout window, so there we fall back\n// to a native title.\nfunction SwitcherButton({\n label,\n inPopout = false,\n onClick,\n testId,\n children,\n}: SwitcherButtonProps) {\n const button = (\n <Button\n variant=\"ghost\"\n size=\"sm\"\n className={btnClass}\n aria-label={label}\n title={inPopout ? label : undefined}\n onClick={onClick}\n data-testid={testId}\n >\n {children}\n </Button>\n )\n if (inPopout) return button\n return (\n <Tooltip>\n <TooltipTrigger asChild>{button}</TooltipTrigger>\n <TooltipContent>{label}</TooltipContent>\n </Tooltip>\n )\n}\n\n// \"Open in new window\" (popout) and \"Float as overlay\" are desktop-only\n// window-management concepts — a tablet has no multi-window/overlay chrome to\n// pop into. 1024px mirrors the common tablet/small-laptop cutoff (Tailwind's\n// `lg`), the usual convention for viewport-driven chrome (as opposed to\n// DocumentViewer's container-width ResizeObserver, which fits ITS OWN toolbar buttons reflowing inside a panel\n// that can be split narrow on a wide desktop — PanelModeSwitcher instead needs\n// to know the actual device class, since popping into \"a new window\" or\n// \"floating overlay\" is meaningless on a touch tablet regardless of how the\n// panel happens to be sized in that moment). Deliberately separate from\n// `useIsPhone` (640px, phones only): this only needs to hide these two\n// buttons, not collapse the whole switcher, at tablet widths.\nconst TABLET_AND_BELOW_QUERY = '(max-width: 1024px)'\n\ninterface PanelModeSwitcherProps {\n mode: PanelMode\n onModeChange: (mode: PanelMode) => void\n onClose?: () => void\n /** When true, hides the popout button (e.g. for panels whose content breaks in a popup window) */\n disablePopout?: boolean\n /**\n * Override the close-button data-testid. Defaults to `dialog-close-button`\n * for backwards compatibility. Use a panel-specific value (e.g.\n * `close-viewer-button`) when there are multiple PanelModeSwitchers in the\n * DOM at once and tests need to disambiguate.\n */\n closeTestId?: string\n}\n\nexport function PanelModeSwitcher({\n mode,\n onModeChange,\n onClose,\n disablePopout,\n closeTestId = 'dialog-close-button',\n}: PanelModeSwitcherProps) {\n const isPopout = mode === 'popout'\n const isSmallScreen = useIsPhone()\n const isTabletAndBelow = useMediaQuery(TABLET_AND_BELOW_QUERY)\n\n // Closing is not a click into the panel: the panel's own click handler would focus the panel\n // that just closed, and the page's nav would lose its active row.\n const closeButton = onClose && (\n <SwitcherButton\n label=\"Close (Esc)\"\n onClick={(event) => {\n event.stopPropagation()\n onClose()\n }}\n testId={closeTestId}\n >\n <X className=\"w-3.5 h-3.5\" />\n </SwitcherButton>\n )\n\n // Phones: every panel is an overlay and mode-switching is disabled, so only\n // the close ✕ is meaningful.\n if (isSmallScreen) {\n return <div className=\"flex items-center gap-0.5 flex-shrink-0\">{closeButton}</div>\n }\n\n return (\n <div className=\"flex items-center gap-0.5 flex-shrink-0\">\n {/* Popout / pop-in toggle — hidden when disablePopout is set, or on\n tablet-and-below where \"a new window\" isn't a real concept. */}\n {!disablePopout && !isTabletAndBelow && (\n <SwitcherButton\n label={isPopout ? 'Pop back in' : 'Open in new window'}\n inPopout={isPopout}\n onClick={() => onModeChange(isPopout ? 'docked' : 'popout')}\n testId={isPopout ? 'pop-into-main-window-button' : 'open-in-new-window-button'}\n >\n <ExternalLink className=\"w-3.5 h-3.5\" />\n </SwitcherButton>\n )}\n\n {/* Split-screen (docked to the side) — shown when not already in it */}\n {!isPopout && mode !== 'docked' && (\n <SwitcherButton\n label=\"Split screen\"\n onClick={() => onModeChange('docked')}\n testId=\"dock-panel-button\"\n >\n <PanelRight className=\"w-3.5 h-3.5\" />\n </SwitcherButton>\n )}\n\n {/* Float as an overlay sheet — shown when not already an overlay, and\n not on tablet-and-below (no floating-window chrome to speak of). */}\n {!isPopout && mode !== 'overlay' && !isTabletAndBelow && (\n <SwitcherButton\n label=\"Float as overlay\"\n onClick={() => onModeChange('overlay')}\n testId=\"overlay-panel-button\"\n >\n <PictureInPicture2 className=\"w-3.5 h-3.5\" />\n </SwitcherButton>\n )}\n\n {/* All non-popout modes: ✕ to close */}\n {!isPopout && closeButton}\n </div>\n )\n}\n","import {\n useCallback,\n useLayoutEffect,\n useEffect,\n useRef,\n useState,\n type PointerEvent,\n type KeyboardEvent,\n} from 'react'\n\ntype Position = { x: number; y: number }\ntype Bounds = { minX: number; maxX: number; minY: number; maxY: number }\nconst ORIGIN: Position = { x: 0, y: 0 }\nconst clamp = (position: Position, bounds: Bounds): Position => ({\n x: Math.max(bounds.minX, Math.min(position.x, bounds.maxX)),\n y: Math.max(bounds.minY, Math.min(position.y, bounds.maxY)),\n})\n\n/** Move a cheap outline during the gesture; commit the chat's position only on release. */\nexport function useFloatingDrag(panelId: string, enabled: boolean) {\n const [isDragging, setIsDragging] = useState(false)\n const ref = useRef<HTMLDivElement>(null)\n const previewRef = useRef<HTMLDivElement>(null)\n const frame = useRef<number | null>(null)\n const suppressClick = useRef(false)\n const storageKey = `arbi:floating-panel-position:${panelId}`\n const [position, setPosition] = useState<Position>(() => {\n try {\n const saved = JSON.parse(localStorage.getItem(storageKey) ?? 'null')\n return saved && Number.isFinite(saved.x) && Number.isFinite(saved.y) ? saved : ORIGIN\n } catch {\n return ORIGIN\n }\n })\n const current = useRef(position)\n // Keep the user's preferred offset while temporarily clamping a smaller viewport.\n const preferred = useRef(position)\n const drag = useRef<{\n x: number\n y: number\n position: Position\n preview: Position\n pointer: number\n bounds: Bounds\n box: { left: number; top: number; width: number; height: number }\n active: boolean\n capture: HTMLElement\n } | null>(null)\n const boundsOf = (node: HTMLDivElement): Bounds => {\n const parent = node.parentElement!.getBoundingClientRect()\n return {\n minX: 12 - parent.left - node.offsetLeft,\n maxX: window.innerWidth - 12 - parent.left - node.offsetLeft - node.offsetWidth,\n minY: 12 - node.offsetTop,\n maxY: parent.height - 12 - node.offsetTop - node.offsetHeight,\n }\n }\n const move = useCallback(\n (next: Position, persist = false) => {\n if (!ref.current) return\n const value = clamp(next, boundsOf(ref.current))\n current.current = value\n setPosition((previous) =>\n previous.x === value.x && previous.y === value.y ? previous : value\n )\n if (persist) {\n preferred.current = value\n try {\n localStorage.setItem(storageKey, JSON.stringify(value))\n } catch {\n /* Storage may be unavailable. */\n }\n }\n },\n [storageKey]\n )\n const cancelFrame = useCallback(() => {\n if (frame.current !== null) cancelAnimationFrame(frame.current)\n frame.current = null\n }, [])\n const cancel = useCallback(() => {\n const gesture = drag.current\n drag.current = null\n cancelFrame()\n setIsDragging(false)\n if (gesture?.capture.hasPointerCapture(gesture.pointer))\n gesture.capture.releasePointerCapture(gesture.pointer)\n }, [cancelFrame])\n useLayoutEffect(() => {\n if (!enabled) return\n const measure = () => {\n if (!drag.current) move(preferred.current)\n }\n measure()\n const observer = new ResizeObserver(measure)\n if (ref.current) observer.observe(ref.current)\n if (ref.current?.parentElement) observer.observe(ref.current.parentElement)\n window.addEventListener('resize', measure)\n return () => {\n observer.disconnect()\n window.removeEventListener('resize', measure)\n cancelFrame()\n }\n }, [enabled, move, cancelFrame])\n useEffect(() => {\n if (!isDragging) return\n const cursor = document.body.style.cursor\n const select = document.body.style.userSelect\n document.body.style.cursor = 'move'\n document.body.style.userSelect = 'none'\n const escape = (event: globalThis.KeyboardEvent) => {\n if (event.key === 'Escape') {\n event.preventDefault()\n event.stopImmediatePropagation()\n cancel()\n }\n }\n window.addEventListener('keydown', escape, true)\n window.addEventListener('blur', cancel)\n return () => {\n document.body.style.cursor = cursor\n document.body.style.userSelect = select\n window.removeEventListener('keydown', escape, true)\n window.removeEventListener('blur', cancel)\n }\n }, [isDragging, cancel])\n const handleOf = (target: EventTarget | null) => {\n if (!(target instanceof Element) || target.closest('[data-floating-no-drag]')) return null\n const handle = target.closest<HTMLElement>('[data-floating-drag-handle]')\n const control = target.closest(\n 'button,a,input,textarea,select,[contenteditable=true],[role=button]'\n )\n return handle && (!control || control === handle) ? handle : null\n }\n const targetOf = (event: PointerEvent<HTMLDivElement>) => {\n const start = drag.current!\n return clamp(\n {\n x: start.position.x + event.clientX - start.x,\n y: start.position.y + event.clientY - start.y,\n },\n start.bounds\n )\n }\n return {\n isDragging,\n ref,\n previewRef,\n previewStyle: drag.current\n ? {\n ...drag.current.box,\n transform: `translate3d(${drag.current.position.x}px, ${drag.current.position.y}px, 0)`,\n }\n : undefined,\n style: enabled ? { transform: `translate3d(${position.x}px, ${position.y}px, 0)` } : undefined,\n onPointerDownCapture: (event: PointerEvent<HTMLDivElement>) => {\n if (drag.current) return\n suppressClick.current = false\n const handle = handleOf(event.target)\n if (!enabled || event.button !== 0 || !handle) return\n const node = event.currentTarget\n drag.current = {\n x: event.clientX,\n y: event.clientY,\n position: current.current,\n preview: current.current,\n pointer: event.pointerId,\n capture: handle,\n active: false,\n bounds: boundsOf(node),\n box: {\n left: node.offsetLeft,\n top: node.offsetTop,\n width: node.offsetWidth,\n height: node.offsetHeight,\n },\n }\n handle.setPointerCapture(event.pointerId)\n },\n onPointerMove: (event: PointerEvent<HTMLDivElement>) => {\n if (drag.current?.pointer !== event.pointerId) return\n if (!drag.current.active) {\n if (Math.hypot(event.clientX - drag.current.x, event.clientY - drag.current.y) < 4) return\n const node = ref.current!\n const surface = node.querySelector<HTMLElement>('[data-floating-surface]')\n const box = surface?.getBoundingClientRect()\n if (box?.width) {\n const parent = node.parentElement!.getBoundingClientRect()\n drag.current.box = {\n left: box.left - parent.left - current.current.x,\n top: box.top - parent.top - current.current.y,\n width: box.width,\n height: box.height,\n }\n drag.current.bounds = {\n minX: current.current.x + 12 - box.left,\n maxX: current.current.x + window.innerWidth - 12 - box.right,\n minY: current.current.y + parent.top + 12 - box.top,\n maxY: current.current.y + parent.bottom - 12 - box.bottom,\n }\n }\n drag.current.active = true\n suppressClick.current = true\n if (document.activeElement === drag.current.capture) drag.current.capture.blur()\n setIsDragging(true)\n }\n drag.current.preview = targetOf(event)\n // No React state or layout reads here: update only the outline, once per frame.\n if (frame.current === null)\n frame.current = requestAnimationFrame(() => {\n frame.current = null\n const next = drag.current?.preview\n if (next && previewRef.current)\n previewRef.current.style.transform = `translate3d(${next.x}px, ${next.y}px, 0)`\n })\n },\n onPointerUp: (event: PointerEvent<HTMLDivElement>) => {\n if (drag.current?.pointer !== event.pointerId) return\n const gesture = drag.current\n const next = gesture.active ? targetOf(event) : null\n drag.current = null\n cancelFrame()\n if (next) move(next, true)\n setIsDragging(false)\n if (gesture.capture.hasPointerCapture(event.pointerId))\n gesture.capture.releasePointerCapture(event.pointerId)\n },\n onClickCapture: (event: React.MouseEvent<HTMLDivElement>) => {\n if (!suppressClick.current) return\n suppressClick.current = false\n event.preventDefault()\n event.stopPropagation()\n },\n onPointerCancel: cancel,\n onLostPointerCapture: cancel,\n onKeyDownCapture: (event: KeyboardEvent<HTMLDivElement>) => {\n if (!enabled || !handleOf(event.target)) return\n const amount = event.shiftKey ? 50 : 10\n const deltas: Record<string, Position> = {\n ArrowLeft: { x: -amount, y: 0 },\n ArrowRight: { x: amount, y: 0 },\n ArrowUp: { x: 0, y: -amount },\n ArrowDown: { x: 0, y: amount },\n }\n if (event.key === 'Home') {\n event.preventDefault()\n move(ORIGIN, true)\n } else if (deltas[event.key]) {\n event.preventDefault()\n move(\n {\n x: current.current.x + deltas[event.key].x,\n y: current.current.y + deltas[event.key].y,\n },\n true\n )\n }\n },\n }\n}\n","import { createContext } from 'react'\n\n/** The chat supplies identity and activity; the compact shell owns presentation. */\nexport const FloatingAssistantIdentity = createContext<\n ((name: string, working: boolean) => void) | null\n>(null)\n","import { useCallback, useEffect, useId, useLayoutEffect, useRef, useState } from 'react'\nimport { ArbiBotHeadIcon } from '@arbidocs/react/ui'\nimport { FloatingAssistantIdentity } from './floating-assistant-context'\n\n/** A persistent launcher and one compact surface; collapsing never discards the conversation. */\nexport function FloatingAssistantSurface({\n children,\n dragging,\n position,\n}: {\n children: React.ReactNode\n dragging: boolean\n position?: string\n}) {\n const root = useRef<HTMLDivElement>(null)\n const surfaceId = useId()\n const lastSize = useRef({ width: 400, height: 380 })\n const preferredDirection = useRef({ up: true, left: true })\n const wasDragging = useRef(false)\n const [identity, setIdentity] = useState({ name: 'Assistant', working: false })\n const updateIdentity = useCallback((name: string, working: boolean) => {\n setIdentity((old) => (old.name === name && old.working === working ? old : { name, working }))\n }, [])\n const [hovered, setHovered] = useState(false)\n const [focused, setFocused] = useState(false)\n const [expanded, setExpanded] = useState(false)\n const [placement, setPlacement] = useState({ up: true, left: true, width: 400, height: 380 })\n\n useLayoutEffect(() => {\n if (dragging) {\n wasDragging.current = true\n return\n }\n if (!root.current) return\n const dropped = wasDragging.current\n wasDragging.current = false\n const measure = () => {\n const box = root.current!.getBoundingClientRect()\n const boundary = root.current!.closest('[data-floating-boundary]')?.getBoundingClientRect()\n const top = (boundary?.top ?? 0) + 12\n const bottom = Math.min(window.innerHeight, boundary?.bottom ?? window.innerHeight) - 12\n const surface = root\n .current!.querySelector('[data-floating-surface]')\n ?.getBoundingClientRect()\n if (surface?.width && surface.height) lastSize.current = surface\n setPlacement(() => {\n const preferred = preferredDirection.current\n const keepHorizontal = preferred.left\n ? box.right - 12 >= lastSize.current.width\n : window.innerWidth - box.left - 12 >= lastSize.current.width\n const keepVertical = preferred.up\n ? box.bottom - top >= lastSize.current.height\n : bottom - box.top >= lastSize.current.height\n const up = keepVertical ? preferred.up : box.top >= (top + bottom) / 2\n const left = keepHorizontal ? preferred.left : box.left >= window.innerWidth / 2\n if (dropped) preferredDirection.current = { up, left }\n return {\n up,\n left,\n width: Math.min(400, left ? box.right - 12 : window.innerWidth - box.left - 12),\n height: Math.max(96, Math.min(380, up ? box.bottom - top : bottom - box.top)),\n }\n })\n }\n measure()\n window.addEventListener('resize', measure)\n return () => window.removeEventListener('resize', measure)\n }, [dragging, position, expanded])\n\n useEffect(() => {\n const surface = root.current!.querySelector<HTMLElement>('[data-floating-surface]')!\n const observer = new ResizeObserver(() => {\n const box = surface.getBoundingClientRect()\n if (box.width && box.height) lastSize.current = box\n })\n observer.observe(surface)\n return () => observer.disconnect()\n }, [])\n\n useEffect(() => {\n if (dragging) return\n const timer = setTimeout(() => setExpanded(hovered || focused), hovered || focused ? 80 : 350)\n return () => clearTimeout(timer)\n }, [hovered, focused, dragging])\n\n const open = () => {\n setExpanded(true)\n requestAnimationFrame(() => root.current?.querySelector('textarea')?.focus())\n }\n const reserveLauncher = placement.left ? 'pr-16' : 'pl-16'\n return (\n <FloatingAssistantIdentity.Provider value={updateIdentity}>\n <div\n ref={root}\n data-testid=\"floating-assistant\"\n data-expanded={expanded}\n className=\"relative size-12 pointer-events-none\"\n onPointerEnter={() => setHovered(true)}\n onPointerLeave={() => {\n setHovered(false)\n // A focused Send button can unmount while submitting without firing blur.\n // Retain React's logical focus for portaled menus outside this DOM subtree.\n if (\n !document.activeElement ||\n document.activeElement === document.body ||\n !document.activeElement.isConnected\n )\n setFocused(false)\n }}\n onFocusCapture={() => setFocused(true)}\n onBlurCapture={(event) => {\n if (!event.currentTarget.contains(event.relatedTarget)) setFocused(false)\n }}\n >\n <section\n id={surfaceId}\n data-floating-surface\n data-floating-drag-handle\n data-testid=\"floating-assistant-surface\"\n aria-label={`${identity.name} compact assistant`}\n hidden={!expanded}\n inert={!expanded}\n className={`${expanded ? 'flex animate-in fade-in duration-150 motion-reduce:animate-none' : 'hidden'} absolute pointer-events-auto cursor-move flex-col overflow-hidden rounded-none border border-border/60 bg-card text-card-foreground shadow-lg [&_button:not([data-floating-drag-handle])]:cursor-pointer [&_button:disabled]:cursor-default [&_a]:cursor-pointer [&_textarea]:cursor-text [&_input]:cursor-text ${placement.up ? (placement.left ? '[&_[data-testid=arbi-dm-composer]]:pr-16' : '[&_[data-testid=arbi-dm-composer]]:pl-16') : ''}`}\n style={{\n width: placement.width,\n maxHeight: placement.height,\n ...(placement.up ? { bottom: 0 } : { top: 0 }),\n ...(placement.left ? { right: 0 } : { left: 0 }),\n }}\n >\n <button\n type=\"button\"\n data-floating-drag-handle\n aria-label={`Move ${identity.name}`}\n aria-controls={surfaceId}\n aria-keyshortcuts=\"ArrowUp ArrowDown ArrowLeft ArrowRight Home\"\n onClick={open}\n title=\"Drag to move · Arrow keys to position · Home to reset\"\n className={`shrink-0 cursor-move select-none touch-none flex items-center gap-2 px-4 py-3 text-left text-sm font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring ${!placement.up ? reserveLauncher : ''}`}\n >\n <ArbiBotHeadIcon className=\"size-4 text-primary\" />\n {identity.name}\n </button>\n <div className=\"flex min-h-0 flex-1 flex-col\">{children}</div>\n </section>\n <button\n type=\"button\"\n data-testid=\"floating-assistant-launcher\"\n data-floating-drag-handle\n aria-label={`Open ${identity.name}`}\n aria-expanded={expanded}\n aria-controls={surfaceId}\n title={`${identity.name} · Drag to move`}\n onClick={open}\n className={`absolute inset-0 z-10 flex size-12 cursor-move touch-none items-center justify-center rounded-full pointer-events-auto bg-primary text-primary-foreground hover:bg-primary/90 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ${expanded ? '' : 'shadow-md'}`}\n >\n <ArbiBotHeadIcon className=\"size-6\" />\n {identity.working && (\n <span\n aria-label=\"Working\"\n className=\"absolute right-0 top-0 size-2.5 animate-pulse rounded-full border-2 border-card bg-primary\"\n />\n )}\n </button>\n </div>\n </FloatingAssistantIdentity.Provider>\n )\n}\n","/**\n * PanelPortal Component\n *\n * Thin portal layer that renders children into the right target based on panel mode:\n * - docked: portal to #dock-zone element\n * - overlay: portal to <body> as a slide-out sheet over a backdrop\n * - popout: portal to a separate browser window\n * - main: portal to #main-zone element\n *\n * Manages popup window lifecycle for popout mode.\n * Content-agnostic — just handles where things render.\n */\n\nimport { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react'\nimport { useFloatingDrag } from './useFloatingDrag'\nimport { FloatingAssistantSurface } from './FloatingAssistantSurface'\nimport { createPortal } from 'react-dom'\nimport { DEFAULT_OVERLAY_ZONE_ID } from './Shell'\nimport { usePanelHostSupport } from './panel-host'\nimport { PortalContainerProvider } from '@arbidocs/react/ui'\nimport type { FloatingPanelMode as PanelMode } from '../settings/FloatingPanel'\n\n// Overlay sheet sizing — defaults match the docked width (DEFAULT_DOCK_PX) so a\n// panel is the same size whether pinned or floating, and stays draggable here.\nconst OVERLAY_DEFAULT_PX = 544\nconst OVERLAY_MIN_PX = 360\n\nexport interface PanelPortalProps {\n panelId: string\n mode: PanelMode\n isOpen: boolean\n /** True while the overlay is animating out before unmounting. */\n isExiting?: boolean\n /** Called when popup window is closed externally (user closes the window) */\n onPopupClosed?: () => void\n /** Dismisses the panel — used by the overlay backdrop. */\n onClose?: () => void\n /** Window title for popout mode */\n popoutTitle?: string\n /** Initial overlay width in px (defaults to OVERLAY_DEFAULT_PX). */\n defaultWidth?: number\n floating?: boolean\n children: React.ReactNode\n}\n\n/**\n * Overlay sheet — a slide-out panel over the still-visible page, resizable by\n * dragging its left edge. Slides in on mount and out (via isExiting) before\n * unmounting, mirroring the left sidebar's animation.\n */\nfunction OverlaySheet({\n panelId,\n isExiting,\n onClose,\n defaultWidth,\n scoped,\n floating,\n children,\n}: {\n panelId: string\n isExiting?: boolean\n onClose?: () => void\n defaultWidth?: number\n /** Rendered inside the layout's overlay zone (below the topbar) rather than\n * over the whole viewport. */\n scoped?: boolean\n floating?: boolean\n children: React.ReactNode\n}) {\n const floatingDrag = useFloatingDrag(panelId, !!floating)\n const {\n style: floatingPosition,\n isDragging,\n previewRef,\n previewStyle,\n ...floatingHandlers\n } = floatingDrag\n const [width, setWidth] = useState(defaultWidth ?? OVERLAY_DEFAULT_PX)\n const [dockInset, setDockInset] = useState(0)\n useEffect(() => {\n if (!scoped || floating) return\n const dock = document.getElementById('dock-zone')\n const region = document.getElementById(DEFAULT_OVERLAY_ZONE_ID)?.parentElement\n if (!dock || !region) return\n // A host can retain a working conversation beside a temporary overlay. Keep both the\n // sheet and its backdrop within the main area so the conversation remains interactive.\n const measure = () => {\n const rect = dock.getBoundingClientRect()\n setDockInset(\n dock.childElementCount && rect.width > 0 && window.innerWidth > 640\n ? Math.max(0, region.getBoundingClientRect().right - rect.left)\n : 0\n )\n }\n measure()\n const sizes = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(measure)\n sizes?.observe(dock)\n sizes?.observe(region)\n window.addEventListener('resize', measure)\n const children = new MutationObserver(measure)\n children.observe(dock, { childList: true, attributes: true, attributeFilter: ['style'] })\n return () => {\n sizes?.disconnect()\n children.disconnect()\n window.removeEventListener('resize', measure)\n }\n }, [scoped, floating])\n const [isResizing, setIsResizing] = useState(false)\n // Live cursor position while dragging. The panel keeps its committed `width`\n // during the drag — only this thin preview line moves — so the heavy panel\n // content never reflows mid-drag (matching DockZone's split-screen handle).\n // The width is committed once on mouse-up.\n const [dragWidth, setDragWidth] = useState<number | null>(null)\n const dragWidthRef = useRef<number | null>(null)\n // Once the slide-in has played we drop the entry class, so later re-renders\n // don't restart the animation.\n const [hasEntered, setHasEntered] = useState(false)\n\n const handleResizeStart = useCallback((e: React.MouseEvent) => {\n e.preventDefault()\n setHasEntered(true)\n setIsResizing(true)\n setDragWidth(null)\n dragWidthRef.current = null\n }, [])\n\n useEffect(() => {\n if (!isResizing) return\n const handleMouseMove = (e: MouseEvent) => {\n // Anchored to the right edge — width grows as the cursor moves left.\n const max = window.innerWidth * 0.92\n const next = Math.min(\n Math.max(window.innerWidth - dockInset - e.clientX, OVERLAY_MIN_PX),\n max\n )\n dragWidthRef.current = next\n setDragWidth(next)\n }\n const handleMouseUp = () => {\n if (dragWidthRef.current !== null) setWidth(dragWidthRef.current)\n setIsResizing(false)\n setDragWidth(null)\n dragWidthRef.current = null\n }\n document.addEventListener('mousemove', handleMouseMove)\n document.addEventListener('mouseup', handleMouseUp)\n document.body.style.cursor = 'col-resize'\n document.body.style.userSelect = 'none'\n return () => {\n document.removeEventListener('mousemove', handleMouseMove)\n document.removeEventListener('mouseup', handleMouseUp)\n document.body.style.cursor = ''\n document.body.style.userSelect = ''\n }\n }, [isResizing, dockInset])\n\n return (\n // Scoped: absolute within the layout's overlay zone (below the topbar).\n // Unscoped fallback: fixed over the whole viewport, as before.\n <div\n // A floating conversation stays above a temporary sheet opened over it, and stays usable.\n className={`${scoped ? 'absolute inset-0' : 'fixed inset-0'} ${floating ? 'z-[45] pointer-events-none' : scoped ? 'z-40' : 'z-50'}`}\n // A compact conversation keeps its anchor when a document opens beside the page.\n style={!floating && dockInset ? { right: dockInset } : undefined}\n data-testid={`${panelId}-overlay`}\n data-floating-boundary={floating || undefined}\n >\n {floating && (\n <>\n <div\n aria-hidden=\"true\"\n data-testid={`${panelId}-move-backdrop`}\n className={`absolute inset-0 z-40 pointer-events-none bg-black/15 dark:bg-black/30 transition-opacity duration-150 motion-reduce:transition-none ${isDragging ? 'opacity-100' : 'opacity-0'}`}\n />\n {isDragging && (\n <div\n ref={previewRef}\n style={previewStyle}\n aria-hidden=\"true\"\n data-testid={`${panelId}-move-outline`}\n className=\"absolute z-50 pointer-events-none rounded-none border-2 border-dashed border-primary/80 bg-primary/[0.04] will-change-transform\"\n />\n )}\n </>\n )}\n {/* In dark mode a 40% black veil crushes the light page text behind the sheet to\n mid-grey, so the veil is lighter there and the page stays readable underneath. */}\n <div\n className={`${floating ? 'hidden' : ''} absolute inset-0 bg-black/40 dark:bg-black/20 duration-200 ${\n // fill-mode-forwards holds the exit end-state — without it the\n // element snaps back fully visible for the frames between the\n // animation finishing and React unmounting it (a flicker).\n isExiting ? 'animate-out fade-out fill-mode-forwards' : 'animate-in fade-in'\n }`}\n onClick={onClose}\n aria-hidden=\"true\"\n data-testid={`${panelId}-overlay-backdrop`}\n />\n <div\n {...floatingHandlers}\n data-dragging={isDragging || undefined}\n style={\n floating\n ? {\n width: 48,\n height: 48,\n maxWidth: 'calc(100% - 32px)',\n maxHeight: 'calc(100% - 32px)',\n ...floatingPosition,\n }\n : { width, maxWidth: '100%' }\n }\n onAnimationEnd={() => !isExiting && setHasEntered(true)}\n className={`${floating ? 'group/floating absolute bottom-6 right-6 max-sm:bottom-3 max-sm:right-4 pointer-events-none flex flex-col transition-none' : 'absolute right-0 top-0 bottom-0 flex max-w-[92vw] flex-col border-l max-sm:!w-full max-sm:!max-w-full max-sm:border-l-0 border-border bg-muted shadow-2xl'} duration-200 ${\n isExiting\n ? 'animate-out slide-out-to-right fill-mode-forwards'\n : // Suppress the slide transform once entered so it doesn't replay.\n hasEntered || floating\n ? ''\n : 'animate-in slide-in-from-right'\n }`}\n >\n {/* Drag handle on the left edge to resize the sheet. */}\n <div\n className={`${floating ? 'hidden' : ''} absolute left-0 top-0 bottom-0 z-10 w-1.5 -translate-x-1/2 cursor-col-resize hover:bg-primary/40`}\n onMouseDown={handleResizeStart}\n data-testid={`${panelId}-overlay-resize-handle`}\n />\n {floating ? (\n <FloatingAssistantSurface dragging={isDragging} position={floatingPosition?.transform}>\n {children}\n </FloatingAssistantSurface>\n ) : (\n children\n )}\n </div>\n\n {/* Preview line — tracks the cursor during the drag; the panel resizes\n to this position only on release. */}\n {isResizing && dragWidth !== null && (\n <div\n className=\"absolute top-0 bottom-0 z-[60] w-0.5 bg-primary pointer-events-none\"\n style={{ right: dragWidth }}\n />\n )}\n {/* Transparent capture layer so the drag isn't interrupted by elements\n (iframes, the grid) swallowing pointer events. */}\n {isResizing && <div className=\"absolute inset-0 z-[55] cursor-col-resize\" />}\n </div>\n )\n}\n\nexport function PanelPortal({\n panelId,\n mode,\n isOpen,\n isExiting,\n onPopupClosed,\n onClose,\n popoutTitle,\n defaultWidth,\n floating = false,\n children,\n}: PanelPortalProps) {\n const { windows: windowManager } = usePanelHostSupport()\n // A shell can mount its zones in the same commit as an already-open panel.\n // Resolve again after that commit instead of relying on a later session update.\n const [portalTarget, setPortalTarget] = useState<HTMLElement | null>(null)\n useLayoutEffect(() => {\n const id =\n mode === 'overlay' ? DEFAULT_OVERLAY_ZONE_ID : mode === 'main' ? 'main-zone' : 'dock-zone'\n setPortalTarget(document.getElementById(id))\n }, [mode, isOpen])\n const [popupRoot, setPopupRoot] = useState<HTMLElement | null>(null)\n const popupWindowIdRef = useRef<string | null>(null)\n\n // Open popup window when switching to popout mode\n useEffect(() => {\n if (!isOpen || mode !== 'popout') {\n // Close popup if we're leaving popout mode (intentional mode switch, not user closing)\n if (popupWindowIdRef.current) {\n // Clear the onClose callback before closing so it doesn't trigger onPopupClosed\n windowManager.clearOnClose(popupWindowIdRef.current)\n windowManager.closeWindow(popupWindowIdRef.current)\n popupWindowIdRef.current = null\n setPopupRoot(null)\n }\n return\n }\n\n // Already have a popup open\n if (popupWindowIdRef.current) return\n\n const windowId = windowManager.createPopupWindow(\n `panel-${panelId}`,\n () => {\n popupWindowIdRef.current = null\n setPopupRoot(null)\n onPopupClosed?.()\n },\n popoutTitle || panelId\n )\n\n if (windowId) {\n const rootElement = windowManager.getRootElement(windowId)\n if (rootElement) {\n popupWindowIdRef.current = windowId\n setPopupRoot(rootElement)\n windowManager.getWindow(windowId)?.focus()\n }\n }\n }, [isOpen, mode, panelId, popoutTitle, onPopupClosed, windowManager])\n\n // Close the window on unmount, a moment later: a remount straight after (React's StrictMode\n // replays mount effects) keeps it instead. Closing it and opening another would need a second\n // click's permission to open a window, and the browser would block the new one as a pop-up.\n const pendingClose = useRef<ReturnType<typeof setTimeout> | null>(null)\n useEffect(() => {\n if (pendingClose.current) {\n clearTimeout(pendingClose.current)\n pendingClose.current = null\n }\n return () => {\n const windowId = popupWindowIdRef.current\n if (!windowId) return\n popupWindowIdRef.current = null\n pendingClose.current = setTimeout(() => {\n pendingClose.current = null\n // Taken up again by the remount (the open effect reuses a window that is still open).\n if (popupWindowIdRef.current === windowId) return\n windowManager.closeWindow(windowId)\n }, 0)\n }\n }, [windowManager])\n\n if (!isOpen && !isExiting) return null\n\n // Popout: render into popup window. Its dialogs and menus open there too, not in the window\n // behind it (where the Sign dialog used to open, out of sight).\n if (mode === 'popout' && popupRoot) {\n return createPortal(\n <PortalContainerProvider container={popupRoot}>{children}</PortalContainerProvider>,\n popupRoot\n )\n }\n\n // Overlay: a slide-out sheet over the still-visible page. Rendered into the\n // layout's #app-overlay-zone — the content region BELOW the app topbar — so\n // the bar stays visible and interactive above every overlay. Falls back to\n // <body> (viewport-covering) when no zone is mounted (e.g. embedded shells).\n if (mode === 'overlay') {\n const overlayZone = portalTarget\n return createPortal(\n <OverlaySheet\n panelId={panelId}\n isExiting={isExiting}\n onClose={onClose}\n defaultWidth={defaultWidth}\n scoped={overlayZone !== null}\n floating={floating}\n >\n {children}\n </OverlaySheet>,\n overlayZone ?? document.body\n )\n }\n\n // Main: render into main content zone\n if (mode === 'main') {\n const mainZone = portalTarget\n if (mainZone) {\n return createPortal(children, mainZone)\n }\n }\n\n // Docked: render into dock zone\n const dockZone = portalTarget\n if (dockZone) {\n return createPortal(children, dockZone)\n }\n\n // No target zone mounted yet — render nothing\n return null\n}\n"]}