efficient-shell 12.3.0 → 12.4.1

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 (291) hide show
  1. package/README.md +17 -1
  2. package/dist/{Browser-OE7IMID6.js → Browser-24JRQIPQ.js} +14 -14
  3. package/dist/Calculator-AHBFZ4EN.js +29 -0
  4. package/dist/{CurrencyConverter-TLI6PVRE.js → CurrencyConverter-PZYRBADV.js} +8 -8
  5. package/dist/Files-AZ4Q4LMK.js +121 -0
  6. package/dist/{Notepad-TUW4JP7M.js → Notepad-UPHHH3YU.js} +11 -11
  7. package/dist/PdfViewer-GUXUWGMG.js +1 -0
  8. package/dist/{PomodoroTimer-FPGRFPNT.js → PomodoroTimer-WGN2KNSB.js} +7 -7
  9. package/dist/{Preview-BJRRRU4N.js → Preview-K4TNRLKM.js} +61 -61
  10. package/dist/Sidebar-F7HHC5GY.js +44 -0
  11. package/dist/{Stock-P7D5WNKC.js → Stock-5GEEDQVT.js} +3 -3
  12. package/dist/{Weather-OUHUYBZ6.js → Weather-WMQQXWHH.js} +18 -18
  13. package/dist/{WorldClock-WXIV2KC6.js → WorldClock-IK3WTHVW.js} +7 -7
  14. package/dist/ai/index.js +33 -33
  15. package/dist/apps/ImageAnnotator.d.ts +21 -0
  16. package/dist/apps/ImageAnnotator.js +2 -0
  17. package/dist/apps/index.js +1 -1
  18. package/dist/bin/media-host-check.js +1 -1
  19. package/dist/bin/ui-check.js +1 -1
  20. package/dist/brand.css +1 -1
  21. package/dist/charts/BoxPlotChart.js +1 -1
  22. package/dist/charts/CandlestickChart.js +1 -1
  23. package/dist/charts/CartesianPlot.js +1 -1
  24. package/dist/charts/ChartTooltip.js +1 -1
  25. package/dist/charts/ChordChart.js +1 -1
  26. package/dist/charts/ColumnChart.js +1 -1
  27. package/dist/charts/FlowChart.js +1 -1
  28. package/dist/charts/FunnelChart.js +1 -1
  29. package/dist/charts/HeatmapChart.js +1 -1
  30. package/dist/charts/HistogramChart.js +1 -1
  31. package/dist/charts/PieChart.js +1 -1
  32. package/dist/charts/RadarChart.js +1 -1
  33. package/dist/charts/RadialBarChart.js +1 -1
  34. package/dist/charts/RangeChart.js +1 -1
  35. package/dist/charts/SankeyChart.js +1 -1
  36. package/dist/charts/ScatterChart.js +1 -1
  37. package/dist/charts/SpecChart.js +1 -1
  38. package/dist/charts/SunburstChart.js +1 -1
  39. package/dist/charts/TimeSeriesChart.js +1 -1
  40. package/dist/charts/TreemapChart.js +1 -1
  41. package/dist/charts/WaterfallChart.js +1 -1
  42. package/dist/{chunk-NRLTGGCS.js → chunk-2BMGV6DE.js} +8 -8
  43. package/dist/chunk-2YRLRMZH.js +23 -0
  44. package/dist/{chunk-5BV2WW74.js → chunk-3LTZ4N46.js} +11 -11
  45. package/dist/{chunk-MQKUGIN7.js → chunk-3PWI5IH7.js} +13 -13
  46. package/dist/{chunk-Q2MW334M.js → chunk-3UHTHQGK.js} +8 -8
  47. package/dist/{chunk-RQ4UIWWD.js → chunk-4UGFNTZ3.js} +11 -11
  48. package/dist/{chunk-Y7ANTS5W.js → chunk-4ZUV6WQT.js} +1 -1
  49. package/dist/{chunk-P4L74UA5.js → chunk-525O4AUQ.js} +1 -1
  50. package/dist/chunk-56GGBTAD.js +3 -0
  51. package/dist/{chunk-KDWK5WGU.js → chunk-57YY4J6T.js} +1 -1
  52. package/dist/{chunk-KZNJXV5I.js → chunk-5HJIFCDQ.js} +3 -3
  53. package/dist/{chunk-IL56C56I.js → chunk-5JUG74UR.js} +2 -2
  54. package/dist/{chunk-TKXUDCOI.js → chunk-5MO5JBBK.js} +1 -1
  55. package/dist/{chunk-6TLSXBKC.js → chunk-62275PI2.js} +1 -1
  56. package/dist/{chunk-5LZTYOYD.js → chunk-6BATVJBA.js} +17 -17
  57. package/dist/{chunk-SSUZAOGI.js → chunk-6U25ELYF.js} +10 -10
  58. package/dist/{chunk-QOQ6GXVA.js → chunk-75MSXRFY.js} +5 -5
  59. package/dist/{chunk-UDL2A2GT.js → chunk-7RRJPNYN.js} +3 -3
  60. package/dist/{chunk-ZXNJSSRV.js → chunk-A4KQKN32.js} +1 -1
  61. package/dist/chunk-A6WZF65N.js +22 -0
  62. package/dist/{chunk-DONZDILI.js → chunk-AAIUJJDQ.js} +1 -1
  63. package/dist/chunk-BG2OL3MO.js +7 -0
  64. package/dist/{chunk-ZZ67Q5HJ.js → chunk-BKKKIHHV.js} +6 -6
  65. package/dist/chunk-BTFBXZS2.js +1 -0
  66. package/dist/chunk-BUGTNNZQ.js +15 -0
  67. package/dist/chunk-C4IJONGO.js +1 -0
  68. package/dist/chunk-C57PNNAW.js +13 -0
  69. package/dist/{chunk-DULMOL3I.js → chunk-C5LBNLFJ.js} +1 -1
  70. package/dist/chunk-CAXOKGMB.js +27 -0
  71. package/dist/{chunk-WGLHB6WE.js → chunk-CJH2BGXY.js} +1 -1
  72. package/dist/chunk-CURXYF2R.js +9 -0
  73. package/dist/{chunk-ZRLWE3JM.js → chunk-DANLBFBD.js} +1 -1
  74. package/dist/{chunk-JYGUTY6R.js → chunk-DFYXIW4O.js} +1 -1
  75. package/dist/{chunk-GZJ5F7SB.js → chunk-DJ2XDBAO.js} +5 -5
  76. package/dist/{chunk-PFMZL3ZG.js → chunk-DW45EZHA.js} +2 -2
  77. package/dist/{chunk-GYDCXCJT.js → chunk-EB2UE6ZR.js} +1 -1
  78. package/dist/{chunk-OR5HUQSB.js → chunk-EEVLRCMA.js} +7 -7
  79. package/dist/{chunk-KT5LLPUV.js → chunk-EF3NPTHG.js} +1 -1
  80. package/dist/{chunk-FGCIEJPP.js → chunk-EIY6YGEZ.js} +1 -1
  81. package/dist/{chunk-THASH6OO.js → chunk-EUUCNDIS.js} +9 -9
  82. package/dist/{chunk-5PP435FL.js → chunk-EYPKBJYG.js} +1 -1
  83. package/dist/{chunk-ASQX3GXB.js → chunk-FLTPVFKA.js} +5 -5
  84. package/dist/chunk-FPYABAOX.js +69 -0
  85. package/dist/chunk-FVZXRGVM.js +8 -0
  86. package/dist/{chunk-67JHJO6V.js → chunk-G7I255HN.js} +13 -13
  87. package/dist/{chunk-2YBJQUYQ.js → chunk-GEXETMGL.js} +1 -1
  88. package/dist/chunk-GEZ45J4Z.js +2 -0
  89. package/dist/chunk-GUIJCTFJ.js +8 -0
  90. package/dist/{chunk-7JY3YYN4.js → chunk-GZQD6IBV.js} +3 -3
  91. package/dist/chunk-H7HRYFRQ.js +14 -0
  92. package/dist/{chunk-AANXPLMA.js → chunk-I5BS6AP6.js} +4 -4
  93. package/dist/chunk-I5CSYOOZ.js +28 -0
  94. package/dist/chunk-I64TVNHS.js +6 -0
  95. package/dist/{chunk-F44E76EC.js → chunk-IFQXTIMY.js} +4 -4
  96. package/dist/chunk-IHPAYSTJ.js +8 -0
  97. package/dist/{chunk-QTMRW6DK.js → chunk-IXBKWVEP.js} +1 -1
  98. package/dist/{chunk-2KNVUOWJ.js → chunk-J4KYZGHQ.js} +20 -20
  99. package/dist/{chunk-O6H2ZD32.js → chunk-J53LQWWY.js} +7 -7
  100. package/dist/{chunk-IXAYZNOZ.js → chunk-JM2IQC4J.js} +1 -1
  101. package/dist/{chunk-FZM3ZPW3.js → chunk-JPNAEN53.js} +1 -1
  102. package/dist/{chunk-S4FPYCUU.js → chunk-JQBVSPF5.js} +3 -3
  103. package/dist/{chunk-XGVMOV3O.js → chunk-KDTL6VEC.js} +8 -8
  104. package/dist/{chunk-2XQOK3CT.js → chunk-KUEYOJBN.js} +2 -2
  105. package/dist/{chunk-QA33EHHO.js → chunk-LCC3NXQX.js} +6 -6
  106. package/dist/{chunk-7JGR7WPD.js → chunk-LFYZ7NQ4.js} +3 -3
  107. package/dist/chunk-M54OL3YR.js +2 -0
  108. package/dist/chunk-MGW7SX53.js +11 -0
  109. package/dist/{chunk-3QYAYBJE.js → chunk-MOMOZVOW.js} +3 -3
  110. package/dist/{chunk-RYBYTUGZ.js → chunk-N442GPRJ.js} +1 -1
  111. package/dist/{chunk-6NHPL5JL.js → chunk-N6Q7HNAH.js} +1 -1
  112. package/dist/{chunk-RXHTIJ64.js → chunk-N7JX27JE.js} +1 -1
  113. package/dist/{chunk-SKFFBBAG.js → chunk-N7YHXL2F.js} +2 -2
  114. package/dist/{chunk-GR43CABV.js → chunk-ND5IZ37V.js} +5 -5
  115. package/dist/{chunk-LKVS4WCZ.js → chunk-NEYHBQLG.js} +3 -3
  116. package/dist/{chunk-ZDO62V4I.js → chunk-NIBE57KV.js} +1 -1
  117. package/dist/{chunk-6Y2BQI44.js → chunk-NS37Y5CN.js} +3 -3
  118. package/dist/chunk-OLVKHYHV.js +9 -0
  119. package/dist/{chunk-CVLWJBR5.js → chunk-PIWC3CAC.js} +1 -1
  120. package/dist/chunk-PMJMYH5O.js +5 -0
  121. package/dist/{chunk-6GDZUW3L.js → chunk-PVXX77MY.js} +6 -6
  122. package/dist/{chunk-NHNRNT4T.js → chunk-QIUIP6YZ.js} +2 -2
  123. package/dist/{chunk-NJN5IKWO.js → chunk-QQ2LDC6C.js} +1 -1
  124. package/dist/{chunk-FAIHSCOG.js → chunk-RBMZSZOH.js} +1 -1
  125. package/dist/{chunk-53WYJ5LZ.js → chunk-RFKCSRJX.js} +10 -10
  126. package/dist/{chunk-NDLXD4EY.js → chunk-RNQBWWYR.js} +5 -5
  127. package/dist/{chunk-N5KO2IHG.js → chunk-RQDVAUXD.js} +4 -4
  128. package/dist/{chunk-B5OYS65L.js → chunk-RVQUSPXC.js} +1 -1
  129. package/dist/chunk-SBZCJNNP.js +11 -0
  130. package/dist/{chunk-RDKIYORS.js → chunk-SYZLS2JA.js} +1 -1
  131. package/dist/chunk-TQWLJ5VM.js +7 -0
  132. package/dist/{chunk-RM74EAMV.js → chunk-TS36J7RW.js} +2 -2
  133. package/dist/{chunk-ZATTQ3FX.js → chunk-TTQ7K4AJ.js} +1 -1
  134. package/dist/{chunk-FPRQB5W6.js → chunk-UDHJTQBA.js} +12 -12
  135. package/dist/{chunk-P3BLJCTQ.js → chunk-UDVQORQM.js} +3 -3
  136. package/dist/chunk-UGOJLNYR.js +1 -0
  137. package/dist/chunk-UJJXWLHE.js +2 -0
  138. package/dist/{chunk-CF4YOJUQ.js → chunk-UPTKROT7.js} +9 -9
  139. package/dist/{chunk-SGNJ7I7P.js → chunk-UVBX5LEU.js} +4 -4
  140. package/dist/{chunk-HRMG2WMW.js → chunk-UWF45S5L.js} +23 -23
  141. package/dist/chunk-VIOILTE4.js +13 -0
  142. package/dist/{chunk-M3PUAGXJ.js → chunk-VWQNCYGQ.js} +7 -7
  143. package/dist/{chunk-2B4EKAZL.js → chunk-VYMM2BPX.js} +2 -2
  144. package/dist/{chunk-HNQKXOFU.js → chunk-WCPAQHHA.js} +1 -1
  145. package/dist/{chunk-36VIGB6J.js → chunk-WDQI3FV6.js} +6 -6
  146. package/dist/chunk-WUGQAZMC.js +14 -0
  147. package/dist/{chunk-74LZVJND.js → chunk-X32TVINY.js} +1 -1
  148. package/dist/{chunk-LBMC6GR5.js → chunk-XK4SMAVR.js} +1 -1
  149. package/dist/{chunk-U7PXMVIY.js → chunk-XK4U5MAS.js} +3 -3
  150. package/dist/{chunk-S6BGMLXI.js → chunk-XMH2JOZ2.js} +1 -1
  151. package/dist/{chunk-TE6R53YD.js → chunk-XWFLIGDQ.js} +1 -1
  152. package/dist/{chunk-PA273FZF.js → chunk-YMAU4EIK.js} +1 -1
  153. package/dist/{chunk-LDEFEPPL.js → chunk-YRJJKF5H.js} +1 -1
  154. package/dist/{chunk-7TZRICMH.js → chunk-YU6KOO6O.js} +4 -4
  155. package/dist/chunk-YZR4T5FZ.js +7 -0
  156. package/dist/{chunk-NC36LJCA.js → chunk-ZB2H2JJ2.js} +4 -4
  157. package/dist/{chunk-FLYOI6EW.js → chunk-ZOZEQZUA.js} +1 -1
  158. package/dist/data/DataTable.js +1 -1
  159. package/dist/data/EntityList.js +1 -1
  160. package/dist/data/Kanban.js +1 -1
  161. package/dist/data/ListLoadError.js +1 -1
  162. package/dist/data/ResizableTable.js +1 -1
  163. package/dist/format/index.js +1 -1
  164. package/dist/forms/AlignmentGrid.js +1 -1
  165. package/dist/forms/BorderInput.js +1 -1
  166. package/dist/forms/BrandAssetEditor.js +1 -1
  167. package/dist/forms/Button.js +1 -1
  168. package/dist/forms/ColorPicker.js +1 -1
  169. package/dist/forms/ComposerAttachments.js +1 -1
  170. package/dist/forms/CornersInput.js +1 -1
  171. package/dist/forms/DatePicker.js +1 -1
  172. package/dist/forms/DateRangePicker.js +1 -1
  173. package/dist/forms/DisplayChips.js +1 -1
  174. package/dist/forms/FilePicker.js +1 -1
  175. package/dist/forms/IconButton.js +1 -1
  176. package/dist/forms/IconPicker.js +1 -1
  177. package/dist/forms/Input.js +1 -1
  178. package/dist/forms/InputNumber.js +1 -1
  179. package/dist/forms/LinkPicker.js +1 -1
  180. package/dist/forms/MediaLibrary.js +1 -1
  181. package/dist/forms/MediaUploadField.js +1 -1
  182. package/dist/forms/MediaUploadGrid.js +1 -1
  183. package/dist/forms/MediaUsedInList.js +1 -1
  184. package/dist/forms/NumericKeypad.js +1 -1
  185. package/dist/forms/PictureTiles.js +1 -1
  186. package/dist/forms/PositionInput.js +1 -1
  187. package/dist/forms/RenameField.js +1 -1
  188. package/dist/forms/Segmented.js +1 -1
  189. package/dist/forms/Select.js +1 -1
  190. package/dist/forms/SidesInput.js +1 -1
  191. package/dist/forms/Slider.js +1 -1
  192. package/dist/forms/Snippet.js +1 -1
  193. package/dist/forms/SplitButton.js +1 -1
  194. package/dist/forms/TagInput.js +1 -1
  195. package/dist/forms/TextToolbar.js +1 -1
  196. package/dist/forms/WidthsBar.js +1 -1
  197. package/dist/icons/efficient-glyphs.js +1 -1
  198. package/dist/icons/efficient-looks.js +1 -1
  199. package/dist/icons/efficient.js +1 -1
  200. package/dist/icons/looks/map.js +1 -1
  201. package/dist/icons/payment.js +1 -1
  202. package/dist/icons/sets.js +1 -1
  203. package/dist/index.d.ts +2 -19
  204. package/dist/index.js +666 -666
  205. package/dist/map/index.js +2 -2
  206. package/dist/page-tabs/index.js +5 -5
  207. package/dist/pdf/index.js +1 -1
  208. package/dist/shell/AppUpdateBanner.js +1 -1
  209. package/dist/shell/ColoredBadge.js +1 -1
  210. package/dist/shell/ConfirmDialog.js +1 -1
  211. package/dist/shell/ContextMenu.js +1 -1
  212. package/dist/shell/Dialog.js +1 -1
  213. package/dist/shell/Drawer.js +1 -1
  214. package/dist/shell/DropdownMenu.js +1 -1
  215. package/dist/shell/EditableGrid.js +1 -1
  216. package/dist/shell/GlobalSearch.js +1 -1
  217. package/dist/shell/HelpCenter.js +1 -1
  218. package/dist/shell/IconRail.js +1 -1
  219. package/dist/shell/ImageLightbox.js +1 -1
  220. package/dist/shell/ItemCount.js +1 -1
  221. package/dist/shell/LanguageSelect.js +1 -1
  222. package/dist/shell/Markdown.js +1 -1
  223. package/dist/shell/MilestoneTimeline.js +1 -1
  224. package/dist/shell/Popover.js +1 -1
  225. package/dist/shell/PopupMenu.js +1 -1
  226. package/dist/shell/ProductionTimeline.js +1 -1
  227. package/dist/shell/ResizeHandle.js +1 -1
  228. package/dist/shell/SearchableSelect.js +1 -1
  229. package/dist/shell/SettingReset.js +1 -1
  230. package/dist/shell/SettingRow.js +1 -1
  231. package/dist/shell/SidebarLayout.js +1 -1
  232. package/dist/shell/SidebarNav.js +1 -1
  233. package/dist/shell/SortableList.js +1 -1
  234. package/dist/shell/StatusBadge.js +1 -1
  235. package/dist/shell/Tabs.js +1 -1
  236. package/dist/shell/TimelineTrack.js +1 -1
  237. package/dist/shell/Tooltip.js +1 -1
  238. package/dist/shell/TopNav.js +1 -1
  239. package/dist/shell/TransferProgress.js +1 -1
  240. package/dist/shell/Tree.js +1 -1
  241. package/dist/shell/discardGuard.js +1 -1
  242. package/dist/telemetry/index.js +1 -1
  243. package/dist/templates/AuthScreen.js +1 -1
  244. package/dist/templates/ChatTemplate.js +1 -1
  245. package/dist/templates/CheckoutTemplate.js +1 -1
  246. package/dist/templates/DashboardTemplate.js +1 -1
  247. package/dist/templates/DataTablePage.js +1 -1
  248. package/dist/templates/EmailTemplate.js +1 -1
  249. package/dist/templates/ErrorBoundary.js +1 -1
  250. package/dist/templates/FormLayoutPage.js +1 -1
  251. package/dist/templates/GalleryTemplate.js +1 -1
  252. package/dist/ui/index.d.ts +1 -0
  253. package/dist/ui/index.js +1 -1
  254. package/dist/ui.css +10 -0
  255. package/dist/version.js +1 -1
  256. package/package.json +1 -1
  257. package/dist/Calculator-W6YA44OY.js +0 -29
  258. package/dist/Files-5WRVSC5R.js +0 -121
  259. package/dist/PdfViewer-GFQAIHDP.js +0 -1
  260. package/dist/Sidebar-ROMFJHCD.js +0 -44
  261. package/dist/chunk-4DZVWK7U.js +0 -7
  262. package/dist/chunk-5N6AC3LN.js +0 -15
  263. package/dist/chunk-6JKSRXZM.js +0 -8
  264. package/dist/chunk-AUZKIL62.js +0 -23
  265. package/dist/chunk-B3PNZBZM.js +0 -27
  266. package/dist/chunk-DCICBH2L.js +0 -3
  267. package/dist/chunk-DICWZEGH.js +0 -2
  268. package/dist/chunk-EOVXFXVV.js +0 -2
  269. package/dist/chunk-F245EG2A.js +0 -9
  270. package/dist/chunk-FPZBHNZU.js +0 -7
  271. package/dist/chunk-GIUX7WUS.js +0 -7
  272. package/dist/chunk-GMLGR4R6.js +0 -8
  273. package/dist/chunk-IMRGGJIJ.js +0 -22
  274. package/dist/chunk-IWFWPFYQ.js +0 -13
  275. package/dist/chunk-KZD2AFH2.js +0 -13
  276. package/dist/chunk-LE5LWALR.js +0 -1
  277. package/dist/chunk-LJJSFJA2.js +0 -69
  278. package/dist/chunk-M3OEWPXZ.js +0 -1
  279. package/dist/chunk-NPQBJJLP.js +0 -9
  280. package/dist/chunk-NSOAHIQZ.js +0 -11
  281. package/dist/chunk-SEJAT3UE.js +0 -1
  282. package/dist/chunk-SPJIFRNY.js +0 -8
  283. package/dist/chunk-SYDGCECZ.js +0 -14
  284. package/dist/chunk-UCIOCS4X.js +0 -2
  285. package/dist/chunk-UMQLDWSS.js +0 -6
  286. package/dist/chunk-VF53GD6D.js +0 -5
  287. package/dist/chunk-WD3I7AEZ.js +0 -14
  288. package/dist/chunk-YAQ5RF3H.js +0 -28
  289. package/dist/chunk-ZICLAMMR.js +0 -11
  290. /package/dist/{chunk-R3K2BNFF.js → chunk-2762IAB7.js} +0 -0
  291. /package/dist/{chunk-K5A62ZS5.js → chunk-T75VCE6K.js} +0 -0
@@ -1,28 +1,28 @@
1
- import{computeMaximizedBox as e,isSidebarStripReserved as t,boxFillsWorkArea as n,readAlwaysMaximizedFlag as r,WORK_AREA_CHANGED_EVENT as o,scrollerIsFluid as i,growBoxToWidth as a,widthToFit as s,navIcons as l}from"./chunk-4LXCCZDM.js";import{ROW_HEIGHTS as c}from"./chunk-AW7TOB6N.js";import{reportBoundaryError as u}from"./chunk-KNUR2UEG.js";import{isStaleChunkError as d}from"./chunk-JDCM2VHG.js";import{Result as h}from"./chunk-Y4RERPFN.js";import{CMD_Z as m,CMD_SHIFT_Z as p}from"./chunk-ZDMZM7HD.js";import{CopyButton as f}from"./chunk-HE767CVB.js";import{confirm as w}from"./chunk-B3PNZBZM.js";import{ItemCount as y}from"./chunk-RXHTIJ64.js";import{isInOverlayOver as g}from"./chunk-3DVNXNTF.js";import{dialogA11y as b}from"./chunk-VWGWZY7A.js";import{ColoredBadge as v}from"./chunk-IL56C56I.js";import{LoadingSpinner as x}from"./chunk-SCGBCBXP.js";import{useShellAuth as k}from"./chunk-2QY5BJLA.js";import{useIsMobile as E,useIsPhone as C}from"./chunk-UGTRSRIW.js";import{useShellPrefs as M}from"./chunk-KC3EX26K.js";import{activationOrder as N,activeListeners as S,ModalActionsContext as L,subscribeActive as T,getActiveModalId as z,KEY_ACTIVATED_SELECTOR as A}from"./chunk-F3ZOO23R.js";import{StatusBadge as D}from"./chunk-FZM3ZPW3.js";import{focusableIn as P}from"./chunk-CDAJKLGL.js";import{PopupMenu as I,PopupMenuItem as R,PopupMenuDivider as W,PopupMenuLabel as K}from"./chunk-F44E76EC.js";import{Button_default as $}from"./chunk-EOVXFXVV.js";import{Icon as O}from"./chunk-UIWGVOFH.js";import{LoadingSpinner as j}from"./chunk-R2VKEMZH.js";import{Z_LAYERS as F}from"./chunk-62LW225J.js";import{shellHttp as q,isShellHttpConfigured as B}from"./chunk-STKJA4PV.js";import{useShellStrings as H}from"./chunk-43MCNASD.js";import{runEscapeInterceptors as U}from"./chunk-TWVUQUUD.js";import{createContext as X,useContext as Y,Component as V,useLayoutEffect as _,useRef as G,useEffect as J,useState as Z,useSyncExternalStore as Q,useCallback as ee,isValidElement as te,Fragment as ne,Children as re,cloneElement as oe,useMemo as ie,useId as ae,useReducer as se,Suspense as le}from"react";import{jsxs as ce,jsx as ue,Fragment as de}from"react/jsx-runtime";import{createPortal as he}from"react-dom";import{useLocation as me}from"react-router-dom";import{useQueryClient as pe,useQuery as fe}from"@tanstack/react-query";function we(e){return"component"in e}function ye(e){return"endpoint"in e}var ge={};function be(e){ge=e}var ve=new Proxy({},{get:(e,t)=>ge[t],has:(e,t)=>t in ge,ownKeys:()=>Object.keys(ge),getOwnPropertyDescriptor(e,t){if(t in ge)return{configurable:!0,enumerable:!0,value:ge[t]}}});function xe(){return B()}var ke=q,Ee=X(null);function Ce(){return Y(Ee)?.pageSearch??""}var Me=null,Ne=/* @__PURE__ */new Set;function Se(e){Me!==e&&(Me=e,Ne.forEach(e=>e()))}function Le(){return Me}function Te(e){return Ne.add(e),()=>{Ne.delete(e)}}var ze=null;function Ae(e){ze=e}function De({error:e,onReload:t}){const n=d(e);/* @__PURE__ */
1
+ import{computeMaximizedBox as e,isSidebarStripReserved as t,boxFillsWorkArea as n,readAlwaysMaximizedFlag as r,WORK_AREA_CHANGED_EVENT as o,scrollerIsFluid as i,growBoxToWidth as a,widthToFit as s,navIcons as l}from"./chunk-4LXCCZDM.js";import{ROW_HEIGHTS as c}from"./chunk-AW7TOB6N.js";import{reportBoundaryError as u}from"./chunk-KNUR2UEG.js";import{isStaleChunkError as d}from"./chunk-JDCM2VHG.js";import{Result as h}from"./chunk-Y4RERPFN.js";import{CMD_Z as m,CMD_SHIFT_Z as p}from"./chunk-ZDMZM7HD.js";import{CopyButton as f}from"./chunk-HE767CVB.js";import{confirm as w}from"./chunk-CAXOKGMB.js";import{ItemCount as y}from"./chunk-N7JX27JE.js";import{isInOverlayOver as g}from"./chunk-3DVNXNTF.js";import{dialogA11y as b}from"./chunk-VWGWZY7A.js";import{ColoredBadge as v}from"./chunk-5JUG74UR.js";import{LoadingSpinner as x}from"./chunk-SCGBCBXP.js";import{activationOrder as k,activeListeners as E,ModalActionsContext as C,subscribeActive as M,getActiveModalId as N,KEY_ACTIVATED_SELECTOR as S}from"./chunk-F3ZOO23R.js";import{useShellAuth as L}from"./chunk-2QY5BJLA.js";import{useIsMobile as T,useIsPhone as z}from"./chunk-UGTRSRIW.js";import{useShellPrefs as A}from"./chunk-KC3EX26K.js";import{focusableIn as D}from"./chunk-CDAJKLGL.js";import{StatusBadge as P}from"./chunk-JPNAEN53.js";import{PopupMenu as I,PopupMenuItem as R,PopupMenuDivider as W,PopupMenuLabel as K}from"./chunk-IFQXTIMY.js";import{Button_default as $}from"./chunk-UJJXWLHE.js";import{Icon as O}from"./chunk-UIWGVOFH.js";import{LoadingSpinner as j}from"./chunk-R2VKEMZH.js";import{Z_LAYERS as F}from"./chunk-62LW225J.js";import{shellHttp as q,isShellHttpConfigured as B}from"./chunk-STKJA4PV.js";import{runEscapeInterceptors as H}from"./chunk-TWVUQUUD.js";import{useShellStrings as U}from"./chunk-43MCNASD.js";import{createContext as X,useContext as Y,Component as V,useLayoutEffect as J,useRef as G,useEffect as _,useState as Z,useSyncExternalStore as Q,useCallback as ee,isValidElement as te,Fragment as ne,Children as re,cloneElement as oe,useMemo as ie,useId as ae,useReducer as se,Suspense as le}from"react";import{jsxs as ce,jsx as ue,Fragment as de}from"react/jsx-runtime";import{createPortal as he}from"react-dom";import{useLocation as me}from"react-router-dom";import{useQueryClient as pe,useQuery as fe}from"@tanstack/react-query";function we(e){return"component"in e}function ye(e){return"endpoint"in e}var ge={};function be(e){ge=e}var ve=new Proxy({},{get:(e,t)=>ge[t],has:(e,t)=>t in ge,ownKeys:()=>Object.keys(ge),getOwnPropertyDescriptor(e,t){if(t in ge)return{configurable:!0,enumerable:!0,value:ge[t]}}});function xe(){return B()}var ke=q,Ee=X(null);function Ce(){return Y(Ee)?.pageSearch??""}var Me=null,Ne=/* @__PURE__ */new Set;function Se(e){Me!==e&&(Me=e,Ne.forEach(e=>e()))}function Le(){return Me}function Te(e){return Ne.add(e),()=>{Ne.delete(e)}}var ze=null;function Ae(e){ze=e}function De({error:e,onReload:t}){const n=d(e);/* @__PURE__ */
2
2
  return ce("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 px-6 py-12 text-center",children:[
3
3
  /* @__PURE__ */ue(O,{name:"warning",className:"h-8 w-8 text-amber-500",strokeWidth:1.5}),
4
4
  /* @__PURE__ */ce("div",{className:"min-w-0",children:[
5
5
  /* @__PURE__ */ue("p",{className:"text-sm font-medium text-gray-700",children:n?"This window needs the latest version of the app":"This window crashed"}),
6
6
  /* @__PURE__ */ue("p",{className:"mt-1 text-xs text-gray-400 max-w-sm break-words",children:n?"A new version was deployed while this tab was open. Reload the page to pick it up.":e.message||String(e)})]}),
7
- /* @__PURE__ */ue("button",{type:"button",onClick:n?()=>window.location.reload():t,className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 text-sm font-medium rounded-lg",children:n?"Reload page":"Reload window"})]})}var Pe=class extends V{state={error:null};static getDerivedStateFromError(e){return{error:e instanceof Error?e:new Error(String(e))}}componentDidCatch(e,t){console.error("[efficient-shell] window content crashed:",e,t.componentStack),u(e)}reset=()=>this.setState({error:null});render(){const{error:e}=this.state;return e?this.props.fallback?this.props.fallback(e,this.reset):/* @__PURE__ */ue(De,{error:e,onReload:this.reset}):this.props.children}},Ie=X(null),Re="text-xs text-gray-500 hover:text-gray-700 disabled:opacity-40 disabled:hover:text-gray-500 disabled:cursor-default";function We({className:e="",auto:t=!1}){const n=Y(Ie),r=H().undo,o=n?.claimOwnMount;if(_(()=>{if(!t&&o)return o(!0),()=>o(!1)},[t,o]),!n||!n.enabled)return null;const{undo:i,redo:a,canUndo:s,canRedo:l,undoLabel:c,redoLabel:u}=n;/* @__PURE__ */
7
+ /* @__PURE__ */ue("button",{type:"button",onClick:n?()=>window.location.reload():t,className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 text-sm font-medium rounded-lg",children:n?"Reload page":"Reload window"})]})}var Pe=class extends V{state={error:null};static getDerivedStateFromError(e){return{error:e instanceof Error?e:new Error(String(e))}}componentDidCatch(e,t){console.error("[efficient-shell] window content crashed:",e,t.componentStack),u(e)}reset=()=>this.setState({error:null});render(){const{error:e}=this.state;return e?this.props.fallback?this.props.fallback(e,this.reset):/* @__PURE__ */ue(De,{error:e,onReload:this.reset}):this.props.children}},Ie=X(null),Re="text-xs text-gray-500 hover:text-gray-700 disabled:opacity-40 disabled:hover:text-gray-500 disabled:cursor-default";function We({className:e="",auto:t=!1}){const n=Y(Ie),r=U().undo,o=n?.claimOwnMount;if(J(()=>{if(!t&&o)return o(!0),()=>o(!1)},[t,o]),!n||!n.enabled)return null;const{undo:i,redo:a,canUndo:s,canRedo:l,undoLabel:c,redoLabel:u}=n;/* @__PURE__ */
8
8
  return ce("div",{className:`flex items-center gap-2 ${e}`,"data-undo-controls":t?"shell":"form",children:[
9
9
  /* @__PURE__ */ue("button",{type:"button",onClick:i,disabled:!s,title:s?r.undoStep(c??"",m):r.nothingToUndo,className:Re,children:r.undo}),
10
- /* @__PURE__ */ue("button",{type:"button",onClick:a,disabled:!l,title:l?r.redoStep(u??"",p):r.nothingToRedo,className:Re,children:r.redo})]})}var Ke=/* @__PURE__ */new Set([408,429]);function $e(e){const t=e?.response?.status;return"number"==typeof t?t:void 0}function Oe(e){const t=$e(e);return null!=t&&(t>=400&&t<500&&!Ke.has(t))}function je(e,t){return!Oe(t)&&e<3}function Fe(e){if("page"!==e.type)return!0;const t=e.route?ve[e.route]:void 0;if(!t||!we(t))return!0;const n=t;return!n.widget&&!n.utility}function qe(e){const t=e.route?ve[e.route]:void 0;if(!t||!we(t))return;const n=t;return n.taskbarGroup?n.taskbarGroup:{key:e.route,label:n.label,icon:e.route}}var Be=(e,t)=>!!t&&"page"===e.type&&e.route===t;var He="flex-1 min-h-0";function Ue(){const e=H().record;/* @__PURE__ */
11
- return ue(j,{label:e.loading,padding:"",className:He})}function Xe(e){return e??void 0}function Ye({isPending:e,isFetching:t,enabled:n=!0,error:r,onRetry:o}){const i=H().record;if(t||e&&n)/* @__PURE__ */return ue(Ue,{});if(r){const e=$e(r);if(401===e)/* @__PURE__ */
10
+ /* @__PURE__ */ue("button",{type:"button",onClick:a,disabled:!l,title:l?r.redoStep(u??"",p):r.nothingToRedo,className:Re,children:r.redo})]})}var Ke=/* @__PURE__ */new Set([408,429]);function $e(e){const t=e?.response?.status;return"number"==typeof t?t:void 0}function Oe(e){const t=$e(e);return null!=t&&(t>=400&&t<500&&!Ke.has(t))}function je(e,t){return!Oe(t)&&e<3}function Fe(e){if("page"!==e.type)return!0;const t=e.route?ve[e.route]:void 0;if(!t||!we(t))return!0;const n=t;return!n.widget&&!n.utility}function qe(e){const t=e.route?ve[e.route]:void 0;if(!t||!we(t))return;const n=t;return n.taskbarGroup?n.taskbarGroup:{key:e.route,label:n.label,icon:e.route}}var Be=(e,t)=>!!t&&"page"===e.type&&e.route===t;var He="flex-1 min-h-0";function Ue(){const e=U().record;/* @__PURE__ */
11
+ return ue(j,{label:e.loading,padding:"",className:He})}function Xe(e){return e??void 0}function Ye({isPending:e,isFetching:t,enabled:n=!0,error:r,onRetry:o}){const i=U().record;if(t||e&&n)/* @__PURE__ */return ue(Ue,{});if(r){const e=$e(r);if(401===e)/* @__PURE__ */
12
12
  return ue(h,{status:"warning",title:i.signInRequired,subTitle:i.signInBody,className:He});if(403===e)/* @__PURE__ */
13
13
  return ue(h,{status:"403",className:He});if(404===e||410===e)/* @__PURE__ */
14
14
  return ue(h,{status:"404",title:i.notFound,className:He});const t=null==e||408===e||429===e||e>=500;/* @__PURE__ */
15
15
  return ue(h,{status:"500",title:i.loadFailed,subTitle:t?i.checkConnection:i.rejected,extra:t?/* @__PURE__ */ue($,{variant:"secondary",size:"sm",onClick:o,children:i.retry}):void 0,className:He})}/* @__PURE__ */
16
- return ue(h,{status:"404",title:i.notFound,className:He})}function Ve({entity:e,children:t,...n}){return null!=e?/* @__PURE__ */ue(de,{children:t(e)}):/* @__PURE__ */ue(Ye,{...n})}var _e=/^[a-z]+(?:-[a-z]+)*-\d{13}$/;function Ge(e){return"string"==typeof e&&(e.startsWith("new-")||_e.test(e))}function Je(e){if(Ge(e.entityId))return!0;const t=e.entitySnapshot;return!(!t||"object"!=typeof t||!t._new&&!t._duplicate)}var Ze=X({openWindows:[],openEntity:()=>{},openPage:()=>{},reorderWindows:()=>{},closeEntity:()=>{},minimize:()=>{},items:[],restore:()=>{},remove:()=>{},restoreIfMinimized:()=>!1,openItems:[]}),Qe=X(null);function et(e){const t=Y(Qe),n=G(null);null===n.current&&(n.current=/* @__PURE__ */Symbol("window-dirty")),_(()=>{if(t)return t(n.current,e)},[t,e]),J(()=>{if(!t||!e)return;const n=e=>{e.preventDefault(),e.returnValue=""};return window.addEventListener("beforeunload",n),()=>window.removeEventListener("beforeunload",n)},[t,e])}function tt(){const e=G(/* @__PURE__ */new Map),[t,n]=Z(!1);return{dirty:t,registerDirty:ee((t,r)=>{const o=()=>{const t=Array.from(e.current.values()).some(Boolean);n(e=>e===t?e:t)};return e.current.set(t,r),o(),()=>{e.current.delete(t),o()}},[])}}function nt(){return Y(Ze)}function rt(e){if("page"!==e.type&&Je(e))return null;const t="page"===e.type?"page":e.entityType||"",n="page"===e.type?e.route||"":e.entityId||"";return t&&n?{entityType:t,entityId:n,label:e.label}:null}function ot({item:e,onClose:t,accentRgb:n}){const{dirty:r,registerDirty:o}=tt(),i=ve[e.route];if(!i||!we(i))return null;const a=i,s=a.component;/* @__PURE__ */
17
- return ue(Yr,{open:!0,onClose:t,icon:l[e.route],title:a.label,size:a.size||"2xl",dirty:r,allowPinOnTop:a.allowPinOnTop,initialPosition:a.initialPosition,widget:a.widget,compact:a.compact,appStyle:a.appStyle,flushBody:a.flushBody,autoHeight:a.autoHeight,autoMinHeight:a.autoMinHeight,autoWidth:a.autoWidth,dimensions:a.dimensions,windowKey:e.id,openedFromKey:e.openedFrom,accentRgb:n,children:/* @__PURE__ */ue(Qe.Provider,{value:o,children:/* @__PURE__ */ue(le,{fallback:/* @__PURE__ */ue("div",{className:"flex items-center justify-center py-12",children:/* @__PURE__ */ue(x,{})}),children:/* @__PURE__ */ue(s,{})})})})}function it({entityType:e,entityId:t,label:n}){const r=H(),o=pe(),{data:i}=fe({queryKey:["my-profile-sidebar"],enabled:xe(),queryFn:()=>ke.get("/auth/me/").then(e=>e.data)}),a=(i?.preferences||{}).favorite_documents||[],s=a.some(n=>n.entityType===e&&n.entityId===t);/* @__PURE__ */
18
- return ue("button",{onClick:()=>{const r=s?a.filter(n=>!(n.entityType===e&&n.entityId===t)):[...a,{entityType:e,entityId:t,label:n}];ke.patch("/auth/me/",{preferences:{favorite_documents:r}}).then(()=>{o.invalidateQueries({queryKey:["my-profile-sidebar"]})})},title:s?r.taskbar.removeFromDesktop:r.taskbar.addToDesktop,className:"shrink-0 transition-colors "+(s?"text-yellow-500 hover:text-yellow-600":"text-gray-300 hover:text-yellow-400"),children:/* @__PURE__ */ue(O,{name:"star",className:"h-4 w-4",fill:s?"currentColor":"none",strokeWidth:1.5})})}var at=/* @__PURE__ */new Set,st=()=>"hidden";function lt({item:e,onClose:t,onMinimize:n,accentRgb:r}){const o=ve[e.entityType];if(!o||!ye(o))return null;const i=o,[a,s]=Z(!1),{dirty:c,registerDirty:u}=tt(),d=i.queryKey||i.endpoint.replace(/^\/|\/$/g,"").split("/").pop()||e.entityType,h=e.entitySnapshot?._duplicate,m=Ge(e.entityId),p=!i.selfFetching&&!h&&!m&&xe(),f=fe({queryKey:[d,e.entityId],queryFn:()=>{return ke.get((t=i.endpoint,n=String(e.entityId),`${t}${encodeURIComponent(n)}/`)).then(e=>e.data);var t,n},initialData:Xe(e.entitySnapshot),initialDataUpdatedAt:0,enabled:p,staleTime:0,refetchOnWindowFocus:!0,refetchOnMount:"always",refetchInterval:e=>!Oe(e.state.error)&&6e4,refetchIntervalInBackground:!1,retry:je}),w=f.data,y=f.refetch;J(()=>{var t;if(p)return t=t=>{t!==e.id||at.has(t)||y({cancelRefetch:!1})},Qn.add(t),()=>{Qn.delete(t)}},[y,e.id,p]);const g=ee(()=>{a&&!c?s(!1):t()},[a,c,t]),b=(i.useEdit??st)(w??null),v=!i.useEdit||m||h?void 0:{state:b,editing:a,onEdit:()=>s(!0),onDiscard:()=>s(!1)},k=i.selfFetching?e.label:w?i.title(w,a,s):e.label,E=i.icon,C=E?l[E]:null,M=k,N=!i.selfFetching&&w&&i.footer&&!h?i.footer(w):void 0;return i.rendersOwnModal?i.selfFetching?/* @__PURE__ */ue(le,{fallback:/* @__PURE__ */ue(x,{}),children:i.render(w??e.entitySnapshot,t,e.entityId,a,s)}):null!=w?/* @__PURE__ */ue(le,{fallback:/* @__PURE__ */ue(Yr,{open:!0,onClose:t,title:e.label,size:i.size||"2xl",children:/* @__PURE__ */ue(Ue,{})}),children:i.render(w,t,e.entityId,a,s)}):/* @__PURE__ */ue(Yr,{open:!0,onClose:t,title:e.label,size:i.size||"2xl",children:/* @__PURE__ */ue(Ye,{isPending:f.isPending,isFetching:f.isFetching,enabled:p,error:f.error,onRetry:y})}):/* @__PURE__ */ue(Yr,{open:!0,onClose:g,onMinimize:n,initialBox:e.savedBox,icon:C,title:M,footer:N,copyText:e.label,windowKey:e.id,openedFromKey:e.openedFrom,size:i.size||"2xl",dirty:c,editing:a||m||h,edit:v,dimensions:i.dimensions,autoHeight:i.autoHeight,autoMinHeight:i.autoMinHeight,autoWidth:i.autoWidth,appStyle:i.appStyle,flushBody:i.flushBody,accentRgb:r,children:/* @__PURE__ */ue(Qe.Provider,{value:u,children:/* @__PURE__ */ue(le,{fallback:/* @__PURE__ */ue(Ue,{}),children:i.selfFetching?i.render(null,t,e.entityId,a,s):/* @__PURE__ */ue(Ve,{entity:w,isPending:f.isPending,isFetching:f.isFetching,enabled:p,error:f.error,onRetry:y,children:n=>i.render(n,t,e.entityId,a,s)})})})})}function ct(e){return document.querySelector(`[data-modal-panel][data-window-key="${e}"]`)}function ut(e){return document.querySelector(`[data-modal-panel][data-window-root][data-window-owner="${e}"]`)}function dt(e){const t=ct(e),n=t??ut(e);if(!n)return;if(t&&!dr(t))return r=e,void window.dispatchEvent(new CustomEvent("modal-reveal",{detail:{windowKey:r}}));var r;const o=n.getAttribute("data-modal-id");o&&er(o)}function ht(){const e=z();if(!e)return;const t=document.querySelector(`[data-modal-panel][data-modal-id="${e}"]`);return t?.getAttribute("data-window-key")??void 0}var mt=/* @__PURE__ */new Map;function pt(){const e=ht();if(e)return mt.get(e)}function ft(e){const t=document.querySelectorAll("[data-modal-panel]");for(const n of Array.from(t)){const t=n.querySelector("[data-window-title]");if(t?.textContent?.includes(e))return n}return null}var wt="rosh-peek-style",yt=F.peek,gt=F.taskbarPreview;function bt(e){"undefined"!=typeof document&&(!function(){if("undefined"==typeof document||document.getElementById(wt))return;const e=document.createElement("style");e.id=wt,e.textContent=`body.rosh-peeking [data-modal-panel]{transition:opacity .18s ease}body.rosh-peeking [data-modal-panel]:not([data-peek-focus]){opacity:.4}body.rosh-peeking [data-modal-panel][data-peek-focus]{opacity:1}body.rosh-peeking [data-modal-panel][data-peek-focus]:not([data-pinned-top]){z-index:${yt}!important}html.rosh-reduce-transparency body.rosh-peeking [data-modal-panel]:not([data-peek-focus]){opacity:.92}@media (prefers-reduced-motion:reduce){body.rosh-peeking [data-modal-panel]{transition:none}}`,document.head.appendChild(e)}(),document.querySelectorAll("[data-modal-panel][data-peek-focus]").forEach(e=>e.removeAttribute("data-peek-focus")),e&&e.setAttribute("data-peek-focus",""),document.body.classList.toggle("rosh-peeking",!!e))}function vt(){"undefined"!=typeof document&&(document.body.classList.remove("rosh-peeking"),document.querySelectorAll("[data-modal-panel][data-peek-focus]").forEach(e=>e.removeAttribute("data-peek-focus")))}function xt({id:e,label:t,maxW:n,maxH:r,titleAbove:o=!1,onClick:i,onClose:a}){const s=H(),l=G(null),[c,u]=Z({w:n,h:Math.round(.75*r)}),[d,h]=Z(!1);return _(()=>{const o=l.current;if(!o)return;const i=ct(e)??ft(t);if(!i)return void h(!1);const a=i.getBoundingClientRect();if(0===a.width||0===a.height)return void h(!1);const s=Math.min(n/a.width,r/a.height),c=Math.max(80,Math.round(a.width*s)),d=Math.max(60,Math.round(a.height*s));u({w:c,h:d}),h(!0);const m=i.cloneNode(!0);return m.style.position="absolute",m.style.top="0",m.style.left="0",m.style.right="auto",m.style.bottom="auto",m.style.width=a.width+"px",m.style.height=a.height+"px",m.style.transform=`scale(${s})`,m.style.transformOrigin="top left",m.style.pointerEvents="none",m.style.animation="none",m.style.zIndex="auto",m.removeAttribute("data-modal-panel"),m.removeAttribute("data-modal-id"),m.removeAttribute("data-window-key"),m.removeAttribute("role"),m.removeAttribute("aria-labelledby"),m.removeAttribute("aria-label"),m.querySelectorAll('[role="dialog"], [data-portal]').forEach(e=>{e.style.display="none"}),o.innerHTML="",o.appendChild(m),()=>{o.innerHTML=""}},[e,t,n,r]),/* @__PURE__ */ce("div",{style:{width:c.w,height:c.h},className:"relative rounded-md overflow-hidden bg-white/95 border border-line-strong shadow-(--elevation-panel) cursor-pointer ring-2 ring-transparent group-hover:ring-blue-400 transition shrink-0",onClick:i,children:[
16
+ return ue(h,{status:"404",title:i.notFound,className:He})}function Ve({entity:e,children:t,...n}){return null!=e?/* @__PURE__ */ue(de,{children:t(e)}):/* @__PURE__ */ue(Ye,{...n})}var Je=/^[a-z]+(?:-[a-z]+)*-\d{13}$/;function Ge(e){return"string"==typeof e&&(e.startsWith("new-")||Je.test(e))}function _e(e){if(Ge(e.entityId))return!0;const t=e.entitySnapshot;return!(!t||"object"!=typeof t||!t._new&&!t._duplicate)}var Ze=X({openWindows:[],openEntity:()=>{},openPage:()=>{},reorderWindows:()=>{},closeEntity:()=>{},minimize:()=>{},items:[],restore:()=>{},remove:()=>{},restoreIfMinimized:()=>!1,openItems:[]}),Qe=X(null);function et(e){const t=Y(Qe),n=G(null);null===n.current&&(n.current=/* @__PURE__ */Symbol("window-dirty")),J(()=>{if(t)return t(n.current,e)},[t,e]),_(()=>{if(!t||!e)return;const n=e=>{e.preventDefault(),e.returnValue=""};return window.addEventListener("beforeunload",n),()=>window.removeEventListener("beforeunload",n)},[t,e])}function tt(){const e=G(/* @__PURE__ */new Map),[t,n]=Z(!1);return{dirty:t,registerDirty:ee((t,r)=>{const o=()=>{const t=Array.from(e.current.values()).some(Boolean);n(e=>e===t?e:t)};return e.current.set(t,r),o(),()=>{e.current.delete(t),o()}},[])}}function nt(){return Y(Ze)}function rt(e){if("page"!==e.type&&_e(e))return null;const t="page"===e.type?"page":e.entityType||"",n="page"===e.type?e.route||"":e.entityId||"";return t&&n?{entityType:t,entityId:n,label:e.label}:null}function ot({item:e,onClose:t,accentRgb:n}){const{dirty:r,registerDirty:o}=tt(),i=ve[e.route];if(!i||!we(i))return null;const a=i,s=a.component;/* @__PURE__ */
17
+ return ue(Yr,{open:!0,onClose:t,icon:l[e.route],title:a.label,size:a.size||"2xl",dirty:r,allowPinOnTop:a.allowPinOnTop,initialPosition:a.initialPosition,widget:a.widget,compact:a.compact,appStyle:a.appStyle,flushBody:a.flushBody,autoHeight:a.autoHeight,autoMinHeight:a.autoMinHeight,autoWidth:a.autoWidth,dimensions:a.dimensions,windowKey:e.id,openedFromKey:e.openedFrom,accentRgb:n,children:/* @__PURE__ */ue(Qe.Provider,{value:o,children:/* @__PURE__ */ue(le,{fallback:/* @__PURE__ */ue("div",{className:"flex items-center justify-center py-12",children:/* @__PURE__ */ue(x,{})}),children:/* @__PURE__ */ue(s,{})})})})}function it({entityType:e,entityId:t,label:n}){const r=U(),o=pe(),{data:i}=fe({queryKey:["my-profile-sidebar"],enabled:xe(),queryFn:()=>ke.get("/auth/me/").then(e=>e.data)}),a=(i?.preferences||{}).favorite_documents||[],s=a.some(n=>n.entityType===e&&n.entityId===t);/* @__PURE__ */
18
+ return ue("button",{onClick:()=>{const r=s?a.filter(n=>!(n.entityType===e&&n.entityId===t)):[...a,{entityType:e,entityId:t,label:n}];ke.patch("/auth/me/",{preferences:{favorite_documents:r}}).then(()=>{o.invalidateQueries({queryKey:["my-profile-sidebar"]})})},title:s?r.taskbar.removeFromDesktop:r.taskbar.addToDesktop,className:"shrink-0 transition-colors "+(s?"text-yellow-500 hover:text-yellow-600":"text-gray-300 hover:text-yellow-400"),children:/* @__PURE__ */ue(O,{name:"star",className:"h-4 w-4",fill:s?"currentColor":"none",strokeWidth:1.5})})}var at=/* @__PURE__ */new Set,st=()=>"hidden";function lt({item:e,onClose:t,onMinimize:n,accentRgb:r}){const o=ve[e.entityType];if(!o||!ye(o))return null;const i=o,[a,s]=Z(!1),{dirty:c,registerDirty:u}=tt(),d=i.queryKey||i.endpoint.replace(/^\/|\/$/g,"").split("/").pop()||e.entityType,h=e.entitySnapshot?._duplicate,m=Ge(e.entityId),p=!i.selfFetching&&!h&&!m&&xe(),f=fe({queryKey:[d,e.entityId],queryFn:()=>{return ke.get((t=i.endpoint,n=String(e.entityId),`${t}${encodeURIComponent(n)}/`)).then(e=>e.data);var t,n},initialData:Xe(e.entitySnapshot),initialDataUpdatedAt:0,enabled:p,staleTime:0,refetchOnWindowFocus:!0,refetchOnMount:"always",refetchInterval:e=>!Oe(e.state.error)&&6e4,refetchIntervalInBackground:!1,retry:je}),w=f.data,y=f.refetch;_(()=>{var t;if(p)return t=t=>{t!==e.id||at.has(t)||y({cancelRefetch:!1})},Qn.add(t),()=>{Qn.delete(t)}},[y,e.id,p]);const g=ee(()=>{a&&!c?s(!1):t()},[a,c,t]),b=(i.useEdit??st)(w??null),v=!i.useEdit||m||h?void 0:{state:b,editing:a,onEdit:()=>s(!0),onDiscard:()=>s(!1)},k=i.selfFetching?e.label:w?i.title(w,a,s):e.label,E=i.icon,C=E?l[E]:null,M=k,N=!i.selfFetching&&w&&i.footer&&!h?i.footer(w):void 0;return i.rendersOwnModal?i.selfFetching?/* @__PURE__ */ue(le,{fallback:/* @__PURE__ */ue(x,{}),children:i.render(w??e.entitySnapshot,t,e.entityId,a,s)}):null!=w?/* @__PURE__ */ue(le,{fallback:/* @__PURE__ */ue(Yr,{open:!0,onClose:t,title:e.label,size:i.size||"2xl",children:/* @__PURE__ */ue(Ue,{})}),children:i.render(w,t,e.entityId,a,s)}):/* @__PURE__ */ue(Yr,{open:!0,onClose:t,title:e.label,size:i.size||"2xl",children:/* @__PURE__ */ue(Ye,{isPending:f.isPending,isFetching:f.isFetching,enabled:p,error:f.error,onRetry:y})}):/* @__PURE__ */ue(Yr,{open:!0,onClose:g,onMinimize:n,initialBox:e.savedBox,icon:C,title:M,footer:N,copyText:e.label,windowKey:e.id,openedFromKey:e.openedFrom,size:i.size||"2xl",dirty:c,editing:a||m||h,edit:v,dimensions:i.dimensions,autoHeight:i.autoHeight,autoMinHeight:i.autoMinHeight,autoWidth:i.autoWidth,appStyle:i.appStyle,flushBody:i.flushBody,accentRgb:r,children:/* @__PURE__ */ue(Qe.Provider,{value:u,children:/* @__PURE__ */ue(le,{fallback:/* @__PURE__ */ue(Ue,{}),children:i.selfFetching?i.render(null,t,e.entityId,a,s):/* @__PURE__ */ue(Ve,{entity:w,isPending:f.isPending,isFetching:f.isFetching,enabled:p,error:f.error,onRetry:y,children:n=>i.render(n,t,e.entityId,a,s)})})})})}function ct(e){return document.querySelector(`[data-modal-panel][data-window-key="${e}"]`)}function ut(e){return document.querySelector(`[data-modal-panel][data-window-root][data-window-owner="${e}"]`)}function dt(e){const t=ct(e),n=t??ut(e);if(!n)return;if(t&&!dr(t))return r=e,void window.dispatchEvent(new CustomEvent("modal-reveal",{detail:{windowKey:r}}));var r;const o=n.getAttribute("data-modal-id");o&&er(o)}function ht(){const e=N();if(!e)return;const t=document.querySelector(`[data-modal-panel][data-modal-id="${e}"]`);return t?.getAttribute("data-window-key")??void 0}var mt=/* @__PURE__ */new Map;function pt(){const e=ht();if(e)return mt.get(e)}function ft(e){const t=document.querySelectorAll("[data-modal-panel]");for(const n of Array.from(t)){const t=n.querySelector("[data-window-title]");if(t?.textContent?.includes(e))return n}return null}var wt="rosh-peek-style",yt=F.peek,gt=F.taskbarPreview;function bt(e){"undefined"!=typeof document&&(!function(){if("undefined"==typeof document||document.getElementById(wt))return;const e=document.createElement("style");e.id=wt,e.textContent=`body.rosh-peeking [data-modal-panel]{transition:opacity .18s ease}body.rosh-peeking [data-modal-panel]:not([data-peek-focus]){opacity:.4}body.rosh-peeking [data-modal-panel][data-peek-focus]{opacity:1}body.rosh-peeking [data-modal-panel][data-peek-focus]:not([data-pinned-top]){z-index:${yt}!important}html.rosh-reduce-transparency body.rosh-peeking [data-modal-panel]:not([data-peek-focus]){opacity:.92}@media (prefers-reduced-motion:reduce){body.rosh-peeking [data-modal-panel]{transition:none}}`,document.head.appendChild(e)}(),document.querySelectorAll("[data-modal-panel][data-peek-focus]").forEach(e=>e.removeAttribute("data-peek-focus")),e&&e.setAttribute("data-peek-focus",""),document.body.classList.toggle("rosh-peeking",!!e))}function vt(){"undefined"!=typeof document&&(document.body.classList.remove("rosh-peeking"),document.querySelectorAll("[data-modal-panel][data-peek-focus]").forEach(e=>e.removeAttribute("data-peek-focus")))}function xt({id:e,label:t,maxW:n,maxH:r,titleAbove:o=!1,onClick:i,onClose:a}){const s=U(),l=G(null),[c,u]=Z({w:n,h:Math.round(.75*r)}),[d,h]=Z(!1);return J(()=>{const o=l.current;if(!o)return;const i=ct(e)??ft(t);if(!i)return void h(!1);const a=i.getBoundingClientRect();if(0===a.width||0===a.height)return void h(!1);const s=Math.min(n/a.width,r/a.height),c=Math.max(80,Math.round(a.width*s)),d=Math.max(60,Math.round(a.height*s));u({w:c,h:d}),h(!0);const m=i.cloneNode(!0);return m.style.position="absolute",m.style.top="0",m.style.left="0",m.style.right="auto",m.style.bottom="auto",m.style.width=a.width+"px",m.style.height=a.height+"px",m.style.transform=`scale(${s})`,m.style.transformOrigin="top left",m.style.pointerEvents="none",m.style.animation="none",m.style.zIndex="auto",m.removeAttribute("data-modal-panel"),m.removeAttribute("data-modal-id"),m.removeAttribute("data-window-key"),m.removeAttribute("role"),m.removeAttribute("aria-labelledby"),m.removeAttribute("aria-label"),m.querySelectorAll('[role="dialog"], [data-portal]').forEach(e=>{e.style.display="none"}),o.innerHTML="",o.appendChild(m),()=>{o.innerHTML=""}},[e,t,n,r]),/* @__PURE__ */ce("div",{style:{width:c.w,height:c.h},className:"relative rounded-md overflow-hidden bg-white/95 border border-line-strong shadow-(--elevation-panel) cursor-pointer ring-2 ring-transparent group-hover:ring-blue-400 transition shrink-0",onClick:i,children:[
19
19
  /* @__PURE__ */ue("div",{ref:l,className:"absolute inset-0 z-0 overflow-hidden"}),!d&&/* @__PURE__ */ce("div",{className:"absolute inset-0 flex flex-col items-center justify-center text-gray-400 bg-gray-50",children:[
20
20
  /* @__PURE__ */ue(O,{name:"window",className:"h-6 w-6",strokeWidth:1.5}),
21
- /* @__PURE__ */ue("span",{className:"mt-1 text-3xs uppercase tracking-wide",children:"Hidden"})]}),!o&&/* @__PURE__ */ue("div",{className:"absolute bottom-0 left-0 right-0 z-10 px-2 py-1 text-2xs font-medium text-on-accent bg-gradient-to-t from-black/80 to-transparent truncate pointer-events-none",children:t}),a&&/* @__PURE__ */ue("button",{onClick:e=>{e.stopPropagation(),a()},className:"absolute top-1 right-1 z-20 h-5 w-5 rounded-full bg-gray-900/90 ring-1 ring-white/80 shadow-sm hover:bg-red-500 text-on-accent flex items-center justify-center",title:s.taskbar.closeWindow,children:/* @__PURE__ */ue(O,{name:"close",className:"h-3 w-3",strokeWidth:3})})]})}function kt({items:e,anchorEl:t,onActivate:n,onClose:r,onMouseEnter:o,onMouseLeave:i}){const a=H(),s=e.length>1,l=G(null),[c,u]=Z({left:-9999,top:-9999,ready:!1}),[d,h]=Z(()=>"undefined"!=typeof document&&getComputedStyle(document.documentElement).getPropertyValue("--taskbar-position")?.trim()||"bottom");_(()=>{const e=l.current;if(!e)return;const n=()=>{const n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),o=getComputedStyle(document.documentElement).getPropertyValue("--taskbar-position")?.trim()||"bottom";h(o);let i,a=n.left+n.width/2-r.width/2;"top"===o?i=n.bottom+8:"left"===o?(a=n.right+8,i=n.top+n.height/2-r.height/2):"right"===o?(a=n.left-r.width-8,i=n.top+n.height/2-r.height/2):i=n.top-r.height-8,a=Math.max(8,Math.min(a,window.innerWidth-r.width-8)),i=Math.max(8,Math.min(i,window.innerHeight-r.height-8)),u({left:a,top:i,ready:!0})};n();const r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[t,e.length]),J(()=>vt,[]);const m="top"===d,p=(m?"mt-1":"mb-1")+" max-w-[240px] truncate text-2xs font-medium text-ink-strongest bg-white/80 px-2 py-0.5 rounded shadow-sm ring-2 ring-transparent transition group-hover:ring-blue-400";return he(
21
+ /* @__PURE__ */ue("span",{className:"mt-1 text-3xs uppercase tracking-wide",children:"Hidden"})]}),!o&&/* @__PURE__ */ue("div",{className:"absolute bottom-0 left-0 right-0 z-10 px-2 py-1 text-2xs font-medium text-on-accent bg-gradient-to-t from-black/80 to-transparent truncate pointer-events-none",children:t}),a&&/* @__PURE__ */ue("button",{onClick:e=>{e.stopPropagation(),a()},className:"absolute top-1 right-1 z-20 h-5 w-5 rounded-full bg-gray-900/90 ring-1 ring-white/80 shadow-sm hover:bg-red-500 text-on-accent flex items-center justify-center",title:s.taskbar.closeWindow,children:/* @__PURE__ */ue(O,{name:"close",className:"h-3 w-3",strokeWidth:3})})]})}function kt({items:e,anchorEl:t,onActivate:n,onClose:r,onMouseEnter:o,onMouseLeave:i}){const a=U(),s=e.length>1,l=G(null),[c,u]=Z({left:-9999,top:-9999,ready:!1}),[d,h]=Z(()=>"undefined"!=typeof document&&getComputedStyle(document.documentElement).getPropertyValue("--taskbar-position")?.trim()||"bottom");J(()=>{const e=l.current;if(!e)return;const n=()=>{const n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),o=getComputedStyle(document.documentElement).getPropertyValue("--taskbar-position")?.trim()||"bottom";h(o);let i,a=n.left+n.width/2-r.width/2;"top"===o?i=n.bottom+8:"left"===o?(a=n.right+8,i=n.top+n.height/2-r.height/2):"right"===o?(a=n.left-r.width-8,i=n.top+n.height/2-r.height/2):i=n.top-r.height-8,a=Math.max(8,Math.min(a,window.innerWidth-r.width-8)),i=Math.max(8,Math.min(i,window.innerHeight-r.height-8)),u({left:a,top:i,ready:!0})};n();const r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[t,e.length]),_(()=>vt,[]);const m="top"===d,p=(m?"mt-1":"mb-1")+" max-w-[240px] truncate text-2xs font-medium text-ink-strongest bg-white/80 px-2 py-0.5 rounded shadow-sm ring-2 ring-transparent transition group-hover:ring-blue-400";return he(
22
22
  /* @__PURE__ */ue("div",{ref:l,"data-taskbar-preview":"",style:{position:"fixed",left:c.left,top:c.top,zIndex:gt,maxWidth:"calc(100vw - 16px)",opacity:c.ready?1:0},className:s?"flex gap-2 flex-wrap":"",onMouseEnter:o,onMouseLeave:()=>{vt(),i()},children:e.map(e=>{const t=ct(e.id)??ft(e.label),o=t?function(e){if(dr(e))return null;const t=e.getBoundingClientRect(),n=ir(),r=t.left+t.width/2-(n.x+n.w/2),o=t.top+t.height/2-(n.y+n.h/2);return 180*Math.atan2(o,r)/Math.PI}(t):null;/* @__PURE__ */
23
23
  return ce("div",{className:"group flex flex-col items-center",onMouseEnter:()=>bt(t),children:[!m&&/* @__PURE__ */ue("span",{className:p,children:e.label}),
24
24
  /* @__PURE__ */ue(xt,{id:e.id,label:e.label,maxW:240,maxH:160,titleAbove:!0,onClick:()=>n(e.id),onClose:()=>r(e.id)}),m&&/* @__PURE__ */ue("span",{className:p,children:e.label}),null!==o&&/* @__PURE__ */ce("span",{title:a.taskbar.offscreenHint,className:"mt-1 inline-flex items-center gap-1 rounded bg-amber-500 px-2 py-0.5 text-2xs font-semibold text-on-accent shadow-sm",children:[
25
- /* @__PURE__ */ue(O,{name:"arrow-right",className:"h-3 w-3",style:{transform:`rotate(${o}deg)`},strokeWidth:3}),"Off screen"]})]},e.id)})}),document.body)}function Et(e,t){const n=getComputedStyle(document.documentElement).getPropertyValue("--taskbar-position")?.trim()||"bottom";return"top"===n?{left:Math.min(e,window.innerWidth-220),top:t+4}:"left"===n?{left:e+4,top:Math.min(t,window.innerHeight-160)}:"right"===n?{right:window.innerWidth-e+4,top:Math.min(t,window.innerHeight-160)}:{left:Math.min(e,window.innerWidth-220),bottom:window.innerHeight-t+4}}function Ct({openWindows:e,onRemove:t,onSplitView:n,onActivate:r,onActivateById:o}){const i=H(),[a,s]=Z(null);J(()=>{let e,t;const n=()=>{clearInterval(e),clearTimeout(t),e=void 0},r=()=>{const e=document.getElementById("taskbar-windows");return s(t=>t===e?t:e),!!e},o=()=>{n(),r()||(e=setInterval(()=>{r()&&n()},100),t=setTimeout(n,5e3))};return o(),window.addEventListener("react-os-shell:layout-mode-changed",o),()=>{n(),window.removeEventListener("react-os-shell:layout-mode-changed",o)}},[]);const c=Q(T,z),[,u]=Z(0);J(()=>{const e=()=>u(e=>e+1);return window.addEventListener("modal-geometry",e),window.addEventListener("resize",e),()=>{window.removeEventListener("modal-geometry",e),window.removeEventListener("resize",e)}},[]);const[,d]=Z(0);J(()=>{const e=()=>d(e=>e+1);return window.addEventListener("window-title-update",e),()=>window.removeEventListener("window-title-update",e)},[]);const h=e=>{const t=ft(e),n=t?.querySelector("[data-window-title]");return n?.textContent?.trim()||e},[m,p]=Z(null),[f,w]=Z(null),[g,b]=Z(null),v=G(null),x=()=>{v.current&&(clearTimeout(v.current),v.current=null),v.current=setTimeout(()=>{p(null),w(null)},150)},k=e.filter(e=>!e.route||!ve[e.route]?.utility);if(!a||!a.isConnected||0===k.length)return null;const E=[],C=/* @__PURE__ */new Map;for(const e of k){const t=e.route?ve[e.route]:void 0,n=t?.taskbarGroup,r=n?.key??e.route??`entity:${e.id}`,o=C.get(r);if(void 0!==o)E[o].items.push(e);else{C.set(r,E.length);const o=n?.label??t?.label??e.label;E.push({key:r,route:n?.icon??e.route,label:o,items:[e]})}}return he(
25
+ /* @__PURE__ */ue(O,{name:"arrow-right",className:"h-3 w-3",style:{transform:`rotate(${o}deg)`},strokeWidth:3}),"Off screen"]})]},e.id)})}),document.body)}function Et(e,t){const n=getComputedStyle(document.documentElement).getPropertyValue("--taskbar-position")?.trim()||"bottom";return"top"===n?{left:Math.min(e,window.innerWidth-220),top:t+4}:"left"===n?{left:e+4,top:Math.min(t,window.innerHeight-160)}:"right"===n?{right:window.innerWidth-e+4,top:Math.min(t,window.innerHeight-160)}:{left:Math.min(e,window.innerWidth-220),bottom:window.innerHeight-t+4}}function Ct({openWindows:e,onRemove:t,onSplitView:n,onActivate:r,onActivateById:o}){const i=U(),[a,s]=Z(null);_(()=>{let e,t;const n=()=>{clearInterval(e),clearTimeout(t),e=void 0},r=()=>{const e=document.getElementById("taskbar-windows");return s(t=>t===e?t:e),!!e},o=()=>{n(),r()||(e=setInterval(()=>{r()&&n()},100),t=setTimeout(n,5e3))};return o(),window.addEventListener("react-os-shell:layout-mode-changed",o),()=>{n(),window.removeEventListener("react-os-shell:layout-mode-changed",o)}},[]);const c=Q(M,N),[,u]=Z(0);_(()=>{const e=()=>u(e=>e+1);return window.addEventListener("modal-geometry",e),window.addEventListener("resize",e),()=>{window.removeEventListener("modal-geometry",e),window.removeEventListener("resize",e)}},[]);const[,d]=Z(0);_(()=>{const e=()=>d(e=>e+1);return window.addEventListener("window-title-update",e),()=>window.removeEventListener("window-title-update",e)},[]);const h=e=>{const t=ft(e),n=t?.querySelector("[data-window-title]");return n?.textContent?.trim()||e},[m,p]=Z(null),[f,w]=Z(null),[g,b]=Z(null),v=G(null),x=()=>{v.current&&(clearTimeout(v.current),v.current=null),v.current=setTimeout(()=>{p(null),w(null)},150)},k=e.filter(e=>!e.route||!ve[e.route]?.utility);if(!a||!a.isConnected||0===k.length)return null;const E=[],C=/* @__PURE__ */new Map;for(const e of k){const t=e.route?ve[e.route]:void 0,n=t?.taskbarGroup,r=n?.key??e.route??`entity:${e.id}`,o=C.get(r);if(void 0!==o)E[o].items.push(e);else{C.set(r,E.length);const o=n?.label??t?.label??e.label;E.push({key:r,route:n?.icon??e.route,label:o,items:[e]})}}return he(
26
26
  /* @__PURE__ */ce(de,{children:[E.map(e=>{const n=e.route?l[e.route]:null,r=e.items[e.items.length-1];let a=!1;if(c){const t=document.querySelector(`[data-modal-id="${c}"]`);if(t){const n=t.querySelector("[data-window-title]"),r=n?.textContent??"";a=e.items.some(e=>r.includes(e.label))}}const s=e.items.length>1,u=e.items.some(e=>{const t=ct(e.id)??ft(e.label);return!!t&&!dr(t)});/* @__PURE__ */
27
27
  return ce("button",{onClick:()=>o(r.id),onMouseEnter:t=>{return n=e.items,r=t.currentTarget,void(g||(v.current&&(clearTimeout(v.current),v.current=null),v.current=setTimeout(()=>{p(n),w(r)},350)));var n,r},onMouseLeave:x,onDoubleClick:e=>{e.stopPropagation(),window.dispatchEvent(new CustomEvent("modal-center",{detail:{windowKey:r.id,label:r.label}}))},onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),v.current&&(clearTimeout(v.current),v.current=null),p(null),w(null),s?b({x:t.clientX,y:t.clientY,items:e.items,label:e.label}):window.dispatchEvent(new CustomEvent("modal-context-menu",{detail:{windowKey:r.id,label:r.label,x:t.clientX,y:t.clientY}}))},style:{width:"var(--window-tab-width, 200px)",fontSize:"var(--window-tab-font-size, 12px)"},"data-tab-group":e.key,className:"group relative flex items-center gap-2 rounded-lg px-3 py-2 font-medium transition-all min-w-0 shrink "+(a?"bg-blue-100/60 border border-blue-400/60 text-blue-700":"bg-gray-50/40 border border-gray-200/40 text-gray-700 hover:bg-gray-200/40"),children:[n&&te(n)?oe(n,{className:"h-3.5 w-3.5 shrink-0"}):/* @__PURE__ */ue(O,{name:"expand",className:"h-3.5 w-3.5 shrink-0",strokeWidth:2}),
28
28
  /* @__PURE__ */ue("span",{className:"truncate flex-1",children:s?e.label:h(r.label)}),u&&/* @__PURE__ */ue("span",{title:i.taskbar.offscreenDot,className:"shrink-0 h-1.5 w-1.5 rounded-full bg-amber-500"}),s&&/* @__PURE__ */ue(y,{count:e.items.length,label:i.count.windows(e.items.length)}),!s&&/* @__PURE__ */ue("span",{role:"button",onClick:e=>{e.stopPropagation(),t(r.id)},className:"ml-auto text-gray-400 hover:text-red-500 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",children:/* @__PURE__ */ue(O,{name:"close",className:"h-3 w-3",strokeWidth:2})})]},e.key)}),
@@ -35,20 +35,20 @@ return ce("button",{onClick:()=>o(r.id),onMouseEnter:t=>{return n=e.items,r=t.cu
35
35
  /* @__PURE__ */ue("svg",{className:"h-4 w-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */ue("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 3.75h6.5v6.5h-6.5zM13.75 8.75h6.5v6.5h-6.5z"})}),i.taskbar.restoreAllWindows]}),
36
36
  /* @__PURE__ */ue(W,{}),
37
37
  /* @__PURE__ */ce(R,{danger:!0,onClick:()=>{b(null),g.items.forEach(e=>t(e.id))},children:[
38
- /* @__PURE__ */ue(O,{name:"close",className:"h-4 w-4",strokeWidth:2}),`${i.taskbar.closeAllWindows} (${g.items.length})`]})]}),m&&f&&/* @__PURE__ */ue(kt,{items:m,anchorEl:f,onActivate:e=>{o(e),p(null),w(null)},onClose:e=>{t(e),p(null),w(null)},onMouseEnter:()=>{v.current&&(clearTimeout(v.current),v.current=null)},onMouseLeave:x})]}),a)}var Mt=["/login","/forgot-password","/reset-password","/force-change-password"];function Nt({children:e,windowAccentForRoute:t}){const n=me(),r=Mt.some(e=>n.pathname.startsWith(e)),[o,i]=Z([]),a=G(o);_(()=>{a.current=o},[o]);const s=Q(Te,Le,Le),l=G(/* @__PURE__ */new Map),c=e=>{const t=Fe(e),n=!!s&&"page"===e.type&&e.route===s,r=e.pageSearch||void 0,o=l.current.get(e.id);if(o&&o.tab===t&&o.home===n&&o.pageSearch===r)return o;const i={key:e.id,tab:t,home:n,...r?{pageSearch:r}:{}};return l.current.set(e.id,i),i};J(()=>{mt.clear();for(const e of o)e.route&&mt.set(e.id,e.route)},[o]);const u=ee(e=>{i(t=>t.filter(t=>t.id!==e))},[]),d=ee(e=>{var t;ct(e)||ut(e)?(t=e,window.dispatchEvent(new CustomEvent(Mr,{detail:{windowKey:t}}))):u(e)},[u]),h=(e,t=!1)=>{const n=Pn;t&&at.add(e),setTimeout(()=>{const r=document.querySelector(`[data-modal-panel][data-window-key="${e}"]`),o=r?.getAttribute("data-modal-id");var i,a;!o||(i=o,a=n,(In.get(i)??-1)>a)||er(o),t&&at.delete(e)},50)},m=(e,t,n)=>{const r=ze;if(n||!r)return[...e,t];const o=function(e,t,n){if(!Fe(t))return e.length;if(t.shellOwned&&Be(t,n.home))return 0;const r=Be(t,n.home)?void 0:qe(t)?.key;if(r){let t=-1;if(e.forEach((e,o)=>{Fe(e)&&!Be(e,n.home)&&qe(e)?.key===r&&(t=o)}),t>=0)return t+1}if("page"===t.type&&t.route&&!Be(t,n.home)&&n.favorites.includes(t.route))return e.length>0&&Be(e[0],n.home)?1:0;const o=t.openedFrom?e.findIndex(e=>e.id===t.openedFrom):-1;if(o>=0){const t=/* @__PURE__ */new Set([e[o].id]);let r=o+1;for(;r<e.length&&e[r].openedFrom&&t.has(e[r].openedFrom);)t.add(e[r].id),r++;const i=t=>Fe(e[t])&&!Be(e[t],n.home)?qe(e[t])?.key:void 0;for(;r>0&&r<e.length&&void 0!==i(r)&&i(r)===i(r-1);)r++;return r}return e.length}(e,t,{home:Le(),favorites:r.favorites});return[...e.slice(0,o),t,...e.slice(o)]},p=ee(e=>{i(t=>function(e,t){const n=new Set(t),r=new Map(e.map(e=>[e.id,e])),o=t.map(e=>r.get(e)).filter(e=>!!e);if(o.length!==n.size)return e;let i=0;const a=e.map(e=>n.has(e.id)?o[i++]:e);return a.every((t,n)=>t===e[n])?e:a}(t,e))},[]),f=ee((e,t,n,r,o,a={})=>{if(!ve[e]||!ye(ve[e]))return;const s=`${e}:${t}`,l=ht();i(i=>{const c=i.find(n=>n.entityType===e&&String(n.entityId)===String(t));return c?(h(c.id),i):(h(s,!0),m(i,{id:s,type:"modal",label:r||t,route:o||window.location.pathname,entityType:e,entityId:t,entitySnapshot:Xe(n),openedFrom:l},!!a.append))})},[]),w=ee((e,t={})=>{if(!ve[e]||!we(ve[e]))return;const n=ve[e],{reuse:r=!1,background:o=!1,shellOwned:s,search:l,append:c=!1}=t,u=e=>{var t;o?(t=e,Bn.add(t)):h(e)};if(n.widget){const t=a.current.find(t=>"page"===t.type&&t.route===e);if(t)return void d(t.id)}const p=ht();i(t=>{if(n.multiInstance){const i=t.filter(t=>"page"===t.type&&t.route===e);if(r&&!l&&i.length>0)return o||h(i[i.length-1].id),t;const a=`page:${e}:${Math.random().toString(36).slice(2,8)}`;return u(a),m(t,{id:a,type:"page",label:n.label,route:e,openedFrom:p,...s?{shellOwned:s}:{},...l?{pageSearch:l}:{}},c)}const i=t.find(t=>"page"===t.type&&t.route===e);if(i)return n.widget?t:(o||h(i.id),l&&i.pageSearch!==l?t.map(e=>e===i?{...e,pageSearch:l}:e):t);const a=`page:${e}`;return u(a),m(t,{id:a,type:"page",label:n.label,route:e,openedFrom:p,...s?{shellOwned:s}:{},...l?{pageSearch:l}:{}},c)})},[d]),y=ee(()=>{},[]),g=ee(()=>{},[]),b=d,v=d;/* @__PURE__ */
38
+ /* @__PURE__ */ue(O,{name:"close",className:"h-4 w-4",strokeWidth:2}),`${i.taskbar.closeAllWindows} (${g.items.length})`]})]}),m&&f&&/* @__PURE__ */ue(kt,{items:m,anchorEl:f,onActivate:e=>{o(e),p(null),w(null)},onClose:e=>{t(e),p(null),w(null)},onMouseEnter:()=>{v.current&&(clearTimeout(v.current),v.current=null)},onMouseLeave:x})]}),a)}var Mt=["/login","/forgot-password","/reset-password","/force-change-password"];function Nt({children:e,windowAccentForRoute:t}){const n=me(),r=Mt.some(e=>n.pathname.startsWith(e)),[o,i]=Z([]),a=G(o);J(()=>{a.current=o},[o]);const s=Q(Te,Le,Le),l=G(/* @__PURE__ */new Map),c=e=>{const t=Fe(e),n=!!s&&"page"===e.type&&e.route===s,r=e.pageSearch||void 0,o=l.current.get(e.id);if(o&&o.tab===t&&o.home===n&&o.pageSearch===r)return o;const i={key:e.id,tab:t,home:n,...r?{pageSearch:r}:{}};return l.current.set(e.id,i),i};_(()=>{mt.clear();for(const e of o)e.route&&mt.set(e.id,e.route)},[o]);const u=ee(e=>{i(t=>t.filter(t=>t.id!==e))},[]),d=ee(e=>{var t;ct(e)||ut(e)?(t=e,window.dispatchEvent(new CustomEvent(Mr,{detail:{windowKey:t}}))):u(e)},[u]),h=(e,t=!1)=>{const n=Pn;t&&at.add(e),setTimeout(()=>{const r=document.querySelector(`[data-modal-panel][data-window-key="${e}"]`),o=r?.getAttribute("data-modal-id");var i,a;!o||(i=o,a=n,(In.get(i)??-1)>a)||er(o),t&&at.delete(e)},50)},m=(e,t,n)=>{const r=ze;if(n||!r)return[...e,t];const o=function(e,t,n){if(!Fe(t))return e.length;if(t.shellOwned&&Be(t,n.home))return 0;const r=Be(t,n.home)?void 0:qe(t)?.key;if(r){let t=-1;if(e.forEach((e,o)=>{Fe(e)&&!Be(e,n.home)&&qe(e)?.key===r&&(t=o)}),t>=0)return t+1}if("page"===t.type&&t.route&&!Be(t,n.home)&&n.favorites.includes(t.route))return e.length>0&&Be(e[0],n.home)?1:0;const o=t.openedFrom?e.findIndex(e=>e.id===t.openedFrom):-1;if(o>=0){const t=/* @__PURE__ */new Set([e[o].id]);let r=o+1;for(;r<e.length&&e[r].openedFrom&&t.has(e[r].openedFrom);)t.add(e[r].id),r++;const i=t=>Fe(e[t])&&!Be(e[t],n.home)?qe(e[t])?.key:void 0;for(;r>0&&r<e.length&&void 0!==i(r)&&i(r)===i(r-1);)r++;return r}return e.length}(e,t,{home:Le(),favorites:r.favorites});return[...e.slice(0,o),t,...e.slice(o)]},p=ee(e=>{i(t=>function(e,t){const n=new Set(t),r=new Map(e.map(e=>[e.id,e])),o=t.map(e=>r.get(e)).filter(e=>!!e);if(o.length!==n.size)return e;let i=0;const a=e.map(e=>n.has(e.id)?o[i++]:e);return a.every((t,n)=>t===e[n])?e:a}(t,e))},[]),f=ee((e,t,n,r,o,a={})=>{if(!ve[e]||!ye(ve[e]))return;const s=`${e}:${t}`,l=ht();i(i=>{const c=i.find(n=>n.entityType===e&&String(n.entityId)===String(t));return c?(h(c.id),i):(h(s,!0),m(i,{id:s,type:"modal",label:r||t,route:o||window.location.pathname,entityType:e,entityId:t,entitySnapshot:Xe(n),openedFrom:l},!!a.append))})},[]),w=ee((e,t={})=>{if(!ve[e]||!we(ve[e]))return;const n=ve[e],{reuse:r=!1,background:o=!1,shellOwned:s,search:l,append:c=!1}=t,u=e=>{var t;o?(t=e,Bn.add(t)):h(e)};if(n.widget){const t=a.current.find(t=>"page"===t.type&&t.route===e);if(t)return void d(t.id)}const p=ht();i(t=>{if(n.multiInstance){const i=t.filter(t=>"page"===t.type&&t.route===e);if(r&&!l&&i.length>0)return o||h(i[i.length-1].id),t;const a=`page:${e}:${Math.random().toString(36).slice(2,8)}`;return u(a),m(t,{id:a,type:"page",label:n.label,route:e,openedFrom:p,...s?{shellOwned:s}:{},...l?{pageSearch:l}:{}},c)}const i=t.find(t=>"page"===t.type&&t.route===e);if(i)return n.widget?t:(o||h(i.id),l&&i.pageSearch!==l?t.map(e=>e===i?{...e,pageSearch:l}:e):t);const a=`page:${e}`;return u(a),m(t,{id:a,type:"page",label:n.label,route:e,openedFrom:p,...s?{shellOwned:s}:{},...l?{pageSearch:l}:{}},c)})},[d]),y=ee(()=>{},[]),g=ee(()=>{},[]),b=d,v=d;/* @__PURE__ */
39
39
  return ce(Ze.Provider,{value:{openWindows:o,openEntity:f,openPage:w,reorderWindows:p,closeEntity:b,minimize:y,items:[],openItems:o,restore:g,remove:v,restoreIfMinimized:()=>!1},children:[e,
40
40
  /* @__PURE__ */ue(Ct,{openWindows:o,onRemove:d,onSplitView:Ur,onActivate:e=>{document.querySelectorAll("[data-modal-panel]").forEach(t=>{const n=t.querySelector("[data-window-title]");if(n?.textContent?.includes(e)){const e=t.getAttribute("data-modal-id");e&&er(e)}})},onActivateById:dt}),
41
41
  /* @__PURE__ */ue(Xr,{}),!r&&o.map(e=>{const n=e.route?t?.(e.route):void 0;
42
42
  /* @__PURE__ */
43
- return ue(Ee.Provider,{value:c(e),children:/* @__PURE__ */ue(Pe,{fallback:(t,n)=>/* @__PURE__ */ue(Yr,{open:!0,onClose:()=>u(e.id),title:e.label,size:"md",autoHeight:!0,windowKey:e.id,children:/* @__PURE__ */ue(De,{error:t,onReload:n})}),children:/* @__PURE__ */ue(nn,{spec:rt(e),children:/* @__PURE__ */ue(eo,{windowId:e.id,children:"page"===e.type?/* @__PURE__ */ue(ot,{item:e,onClose:()=>u(e.id),accentRgb:n}):/* @__PURE__ */ue(lt,{item:e,onClose:()=>u(e.id),onMinimize:()=>{},accentRgb:n})})})})},e.id)})]})}var St=400;function Lt({panelRef:e,bodyRef:t,open:n,widget:r,active:o,minimized:i}){const a=G(null),s=G(!1);n&&!s.current&&(a.current="undefined"==typeof document?null:document.activeElement),s.current=n;const l=G(!1),c=G(void 0),u=G(i),d=u.current&&!i;u.current=i;const h=()=>{l.current=!0,clearTimeout(c.current),c.current=setTimeout(()=>{l.current=!1},St)};J(()=>{n&&!r&&h()},[n,r]),J(()=>{d&&n&&!r&&h()},[d]),J(()=>()=>clearTimeout(c.current),[]),J(()=>{if(!n||r||!o||i||!l.current)return;l.current=!1;const a=e.current;if(!a||a.contains(document.activeElement))return;if(document.activeElement?.closest('[aria-modal="true"]'))return;const s=t.current?P(t.current)[0]:void 0;s?s.focus():(a.hasAttribute("tabindex")||a.setAttribute("tabindex","-1"),a.focus())},[n,r,o,i,e,t]),_(()=>{if(!n||r)return;const t=e.current;return()=>{const e=a.current,n=document.activeElement;(!n||n===document.body||!!t?.contains(n))&&e&&e.isConnected&&!t?.contains(e)&&e.focus?.()}},[n,r,e])}var Tt=null,zt=/* @__PURE__ */new Set;function At(){return Tt}function Dt(e){if(Tt!==e){Tt=e;for(const e of zt)e()}}function Pt(e){return zt.add(e),()=>{zt.delete(e)}}var It=!1,Rt={menus:0,submenus:0,menuKey:null,moveMs:0,resizeMs:0},Wt=()=>{};function Kt(e){It=e,Rt={menus:0,submenus:0,menuKey:null,moveMs:0,resizeMs:0}}function $t(e,t){It&&("submenu"===e?Rt.submenus++:Rt.menus++,Rt.menuKey=t)}function Ot(e){if(!It)return Wt;const t=performance.now();let n=!1;return()=>{if(n)return;if(n=!0,!It)return;const r=performance.now()-t;"move"===e?Rt.moveMs+=r:Rt.resizeMs+=r}}function jt(){const e=Rt;return Rt={menus:0,submenus:0,menuKey:null,moveMs:0,resizeMs:0},e}var Ft=/* @__PURE__ */new Set([D,v]),qt=e=>Ft.has(e)||"function"==typeof e&&"badge"===e.titleRole,Bt=/* @__PURE__ */new Set(["button","a","input","select","textarea","kbd"]),Ht=/* @__PURE__ */new Set(["svg"]);function Ut(e){const t=[],n={text:"",accessories:[],badges:[],actions:[]};return Xt(e,n,t),n.text=t.join("").replace(/\s+/g," ").trim(),n}function Xt(e,t,n){if(null==e||"boolean"==typeof e)return;if("string"==typeof e||"number"==typeof e)return void n.push(String(e));if(Array.isArray(e))return void e.forEach(e=>Xt(e,t,n));if(!te(e))return;const r=e;if(r.type===f)return void(void 0===t.copy&&"string"==typeof r.props.text&&r.props.text&&(t.copy=r.props.text));if(r.type===ne)return void re.toArray(r.props.children).forEach(e=>Xt(e,t,n));if("string"==typeof r.type){if(Ht.has(r.type))return;if(!Bt.has(r.type))return n.push(" "),re.toArray(r.props.children).forEach(e=>Xt(e,t,n)),void n.push(" ")}const o=oe(r,{key:`title-part-${t.accessories.length}`});t.accessories.push(o),(qt(r.type)?t.badges:t.actions).push(o)}var Yt=/* @__PURE__ */new Map,Vt=/* @__PURE__ */new Set,_t=0;function Gt(){_t++,Vt.forEach(e=>e())}function Jt(e){return Yt.get(e)}function Zt(e){return Vt.add(e),()=>{Vt.delete(e)}}function Qt(){return _t}var en=X(""),tn=X(null);function nn({spec:e,children:t}){/* @__PURE__ */
44
- return ue(tn.Provider,{value:e,children:t})}var rn=/* @__PURE__ */new Set(["button","input","textarea","select","kbd","svg"]),on='button[type="submit"], button[data-submit], button.btn-submit, button.bg-green-600, button.bg-blue-600';function an(e){return sn(e).replace(/\s+/g," ").trim()}function sn(e){if(null==e||"boolean"==typeof e)return"";if("string"==typeof e)return e;if("number"==typeof e)return String(e);if(Array.isArray(e))return e.map(sn).join("");if(te(e)){const t=e,n="string"==typeof t.type?t.type:"";return rn.has(n)?"":` ${sn(t.props?.children)} `}return""}function ln(e){const t=Y(en);J(()=>{if(!t)return;const n=n=>{n.detail===t&&e()};return window.addEventListener("widget-open-settings",n),()=>window.removeEventListener("widget-open-settings",n)},[e,t])}var cn={};function un(e,t,n){const r=Y(en);J(()=>{if(!r)return;cn[r]||(cn[r]=[]);const o={label:e,icon:n,onClick:t};return cn[r].push(o),()=>{cn[r]=(cn[r]||[]).filter(e=>e!==o)}},[r,e,t,n])}function dn({title:e}){const t=G(null);return J(()=>{const n=setTimeout(()=>{const n=t.current?.closest("[data-modal-id]"),r=n?.getAttribute("data-modal-id");r&&window.dispatchEvent(new CustomEvent("window-title-update",{detail:{id:r,title:e}}))},0);return()=>clearTimeout(n)},[e]),/* @__PURE__ */ue("span",{ref:t,style:{display:"none"},"aria-hidden":"true"})}function hn(e){}function mn(){return Y(en)}function pn({children:e,position:t="right",quiet:n=!1}){const r=Y(L),[o,i]=Z(null);return J(()=>{if(!r)return;const e="left"===t?r.leftRef:r.rightRef,o=()=>!!e.current&&(i(e.current),n||r.notify(),!0);if(o())return;const a=setInterval(()=>{o()&&clearInterval(a)},50),s=setTimeout(()=>clearInterval(a),2e3);return()=>{clearInterval(a),clearTimeout(s)}},[r,t,n]),o?he(e,o):null}function fn({onClick:e,children:t,className:n}){const r=Y(L);/* @__PURE__ */
45
- return ue("button",{type:"button",onClick:async()=>{if(r?.isDirty){const{confirm:e}=await(import("./shell/ConfirmDialog.js"));if(!await e({title:"Discard changes?",message:"You have unsaved changes. Are you sure you want to cancel? All changes will be lost.",confirmLabel:"Discard",cancelLabel:"Keep Editing",variant:"warning"}))return}e()},className:n||"bg-white text-gray-700 border border-gray-300 px-4 py-2 text-sm font-medium rounded-lg hover:bg-gray-50",children:t||"Cancel"})}var wn="erp_window_positions",yn={};try{const e=localStorage.getItem(wn);e&&(yn=JSON.parse(e))}catch{}var gn=null;function bn(){gn&&clearTimeout(gn),gn=setTimeout(()=>{try{localStorage.setItem(wn,JSON.stringify(yn))}catch{}},500)}var vn="erp_activation_order",xn=[];try{const e=localStorage.getItem(vn),t=e?JSON.parse(e):null;Array.isArray(t)&&t.every(e=>"string"==typeof e)&&(xn=t)}catch{}var kn=null;function En(){kn&&clearTimeout(kn),kn=setTimeout(()=>{try{localStorage.setItem(vn,JSON.stringify(xn))}catch{}},500)}function Cn(e,t){yn[e]||(yn[e]=t,bn())}function Mn(e){return yn[e]?{...yn[e]}:null}function Nn(e,t){yn[e]=t,bn()}function Sn(){const r=e(),o=t();let i=!1;for(const e of Object.keys(yn))n(yn[e],r,o)&&(delete yn[e],i=!0);i&&bn()}var Ln={sm:384,md:512,lg:672,xl:896,"2xl":1152,"3xl":1408},Tn=4e3,zn=()=>{if("undefined"==typeof document)return"large";const e=getComputedStyle(document.documentElement).getPropertyValue("--default-window-size")?.trim();return"small"===e||"medium"===e||"maximized"===e?e:"large"},An={small:.8,medium:1,large:1.25,maximized:1.25},Dn=/* @__PURE__ */new Set,Pn=0,In=/* @__PURE__ */new Map;var Rn=0;function Wn(){return Rn}function Kn(){Rn++,S.forEach(e=>e())}var $n=/* @__PURE__ */new Map,On=/* @__PURE__ */new Map,jn=/* @__PURE__ */new Map;function Fn(){for(let e=N.length-1;e>=0;e--){const t=jn.get(N[e]);if(t?.tab)return t.owner}return null}function qn(){return Q(T,Fn,()=>null)}var Bn=/* @__PURE__ */new Set;var Hn=null;function Un(e){Hn=null,er(e)}function Xn(e){Hn=e;const t=$n.get(e);t&&Un(t)}var Yn=/* @__PURE__ */new Map;function Vn(e){return Yn.get(e)?.holdsChanges()??!1}function _n(e){const t=Yn.get(e);return t?t.ask():Promise.resolve(!0)}function Gn(e){Hn===e&&(Hn=null)}function Jn(e,t,n){if(n&&jn.set(e,n),t)if($n.set(t,e),On.set(e,t),Bn.delete(t)){N.unshift(e);const n=xn.indexOf(t);-1!==n&&xn.splice(n,1),xn.unshift(t),En()}else!function(e,t){const n=xn.indexOf(t);if(-1===n)return void N.push(e);let r=N.length;for(let e=0;e<N.length;e++){const t=On.get(N[e]);if(t&&xn.indexOf(t)>n){r=e;break}}N.splice(r,0,e)}(e,t),-1===xn.indexOf(t)&&(xn.push(t),En());else N.push(e);Kn(),window.dispatchEvent(new CustomEvent("modal-reorder")),t&&Hn===t&&Un(e)}function Zn(e){return e?jn.get(e)?.owner??On.get(e)??null:null}var Qn=/* @__PURE__ */new Set;function er(e){const t=Zn(z()),n=N.indexOf(e);-1!==n&&N.splice(n,1),N.push(e);const r=jn.get(e);if(r?.root)for(const[e,t]of jn){if(t.root||t.owner!==r.owner||Dn.has(e))continue;const n=N.indexOf(e);-1!==n&&N.splice(n,1),N.push(e)}Dn.delete(e);const o=On.get(e);if(o){const e=xn.indexOf(o);-1!==e&&xn.splice(e,1),xn.push(o),En(),Hn&&Hn!==o&&(Hn=null)}Kn(),window.dispatchEvent(new CustomEvent("modal-reorder"));const i=Zn(z());i&&i!==t&&Qn.forEach(e=>e(i))}function tr(e){const t=N.indexOf(e);-1!==t&&N.splice(t,1),Dn.add(e),In.set(e,++Pn);const n=On.get(e);if(n){const e=xn.indexOf(n);-1!==e&&(xn.splice(e,1),En())}Kn(),window.dispatchEvent(new CustomEvent("modal-reorder"))}var nr=/* @__PURE__ */new Set;var rr=8,or=32;function ir(){return e()}var ar=c.windowBar,sr=80,lr=384,cr=400;function ur(e,t=ir()){const n=Math.min(Math.max(e.x,t.x+sr-e.w),t.x+t.w-sr),r=Math.min(Math.max(e.y,t.y),t.y+t.h-ar);return n===e.x&&r===e.y?e:{...e,x:n,y:r}}function dr(e){const t=e.getBoundingClientRect();if(0===t.width||0===t.height)return!0;const n=ir();return t.left>=n.x-1&&t.top>=n.y-1&&t.right<=n.x+n.w+1&&t.bottom<=n.y+n.h+1}function hr(e){const t=ir(),n=Math.floor(t.w/2),r=Math.floor(t.h/2);switch(e){case"top":return{x:t.x,y:t.y,w:t.w,h:t.h};case"left":return{x:t.x,y:t.y,w:n,h:t.h};case"right":return{x:t.x+n,y:t.y,w:t.w-n,h:t.h};case"tl":return{x:t.x,y:t.y,w:n,h:r};case"tr":return{x:t.x+n,y:t.y,w:t.w-n,h:r};case"bl":return{x:t.x,y:t.y+r,w:n,h:t.h-r};case"br":return{x:t.x+n,y:t.y+r,w:t.w-n,h:t.h-r}}}var mr=null;function pr(e){const t=(mr||((mr=document.createElement("div")).style.cssText=["position: fixed","pointer-events: none",`z-index: ${F.snapPreview}`,"border-radius: 8px","background: rgba(59, 130, 246, 0.18)","border: 2px solid rgb(59, 130, 246)","transition: left 120ms ease, top 120ms ease, width 120ms ease, height 120ms ease, opacity 120ms ease","opacity: 0","display: none"].join(";"),document.body.appendChild(mr)),mr);t.style.display="block",t.style.left=`${e.x}px`,t.style.top=`${e.y}px`,t.style.width=`${e.w}px`,t.style.height=`${e.h}px`,t.style.opacity="1"}function fr(){mr&&(mr.style.opacity="0",mr.style.display="none")}var wr=[{zone:"left",labelKey:"snapLeft",region:"inset-y-0 left-0 w-1/2"},{zone:"right",labelKey:"snapRight",region:"inset-y-0 right-0 w-1/2"},{zone:"tl",labelKey:"snapTopLeft",region:"top-0 left-0 h-1/2 w-1/2"},{zone:"tr",labelKey:"snapTopRight",region:"top-0 right-0 h-1/2 w-1/2"},{zone:"bl",labelKey:"snapBottomLeft",region:"bottom-0 left-0 h-1/2 w-1/2"},{zone:"br",labelKey:"snapBottomRight",region:"bottom-0 right-0 h-1/2 w-1/2"}],yr=350,gr=200;function br({maximized:e,onToggleMax:t,onSnap:n,buttonClassName:r,strings:o}){const[i,a]=Z(!1),s=G(void 0),l=G(void 0);J(()=>()=>{clearTimeout(s.current),clearTimeout(l.current)},[]);const c=()=>{clearTimeout(l.current),s.current=setTimeout(()=>a(!0),yr)},u=()=>{clearTimeout(s.current),l.current=setTimeout(()=>a(!1),gr)};/* @__PURE__ */
43
+ return ue(Ee.Provider,{value:c(e),children:/* @__PURE__ */ue(Pe,{fallback:(t,n)=>/* @__PURE__ */ue(Yr,{open:!0,onClose:()=>u(e.id),title:e.label,size:"md",autoHeight:!0,windowKey:e.id,children:/* @__PURE__ */ue(De,{error:t,onReload:n})}),children:/* @__PURE__ */ue(nn,{spec:rt(e),children:/* @__PURE__ */ue(eo,{windowId:e.id,children:"page"===e.type?/* @__PURE__ */ue(ot,{item:e,onClose:()=>u(e.id),accentRgb:n}):/* @__PURE__ */ue(lt,{item:e,onClose:()=>u(e.id),onMinimize:()=>{},accentRgb:n})})})})},e.id)})]})}var St=400;function Lt({panelRef:e,bodyRef:t,open:n,widget:r,active:o,minimized:i}){const a=G(null),s=G(!1);n&&!s.current&&(a.current="undefined"==typeof document?null:document.activeElement),s.current=n;const l=G(!1),c=G(void 0),u=G(i),d=u.current&&!i;u.current=i;const h=()=>{l.current=!0,clearTimeout(c.current),c.current=setTimeout(()=>{l.current=!1},St)};_(()=>{n&&!r&&h()},[n,r]),_(()=>{d&&n&&!r&&h()},[d]),_(()=>()=>clearTimeout(c.current),[]),_(()=>{if(!n||r||!o||i||!l.current)return;l.current=!1;const a=e.current;if(!a||a.contains(document.activeElement))return;if(document.activeElement?.closest('[aria-modal="true"]'))return;const s=t.current?D(t.current)[0]:void 0;s?s.focus():(a.hasAttribute("tabindex")||a.setAttribute("tabindex","-1"),a.focus())},[n,r,o,i,e,t]),J(()=>{if(!n||r)return;const t=e.current;return()=>{const e=a.current,n=document.activeElement;(!n||n===document.body||!!t?.contains(n))&&e&&e.isConnected&&!t?.contains(e)&&e.focus?.()}},[n,r,e])}var Tt=null,zt=/* @__PURE__ */new Set;function At(){return Tt}function Dt(e){if(Tt!==e){Tt=e;for(const e of zt)e()}}function Pt(e){return zt.add(e),()=>{zt.delete(e)}}var It=!1,Rt={menus:0,submenus:0,menuKey:null,moveMs:0,resizeMs:0},Wt=()=>{};function Kt(e){It=e,Rt={menus:0,submenus:0,menuKey:null,moveMs:0,resizeMs:0}}function $t(e,t){It&&("submenu"===e?Rt.submenus++:Rt.menus++,Rt.menuKey=t)}function Ot(e){if(!It)return Wt;const t=performance.now();let n=!1;return()=>{if(n)return;if(n=!0,!It)return;const r=performance.now()-t;"move"===e?Rt.moveMs+=r:Rt.resizeMs+=r}}function jt(){const e=Rt;return Rt={menus:0,submenus:0,menuKey:null,moveMs:0,resizeMs:0},e}var Ft=/* @__PURE__ */new Set([P,v]),qt=e=>Ft.has(e)||"function"==typeof e&&"badge"===e.titleRole,Bt=/* @__PURE__ */new Set(["button","a","input","select","textarea","kbd"]),Ht=/* @__PURE__ */new Set(["svg"]);function Ut(e){const t=[],n={text:"",accessories:[],badges:[],actions:[]};return Xt(e,n,t),n.text=t.join("").replace(/\s+/g," ").trim(),n}function Xt(e,t,n){if(null==e||"boolean"==typeof e)return;if("string"==typeof e||"number"==typeof e)return void n.push(String(e));if(Array.isArray(e))return void e.forEach(e=>Xt(e,t,n));if(!te(e))return;const r=e;if(r.type===f)return void(void 0===t.copy&&"string"==typeof r.props.text&&r.props.text&&(t.copy=r.props.text));if(r.type===ne)return void re.toArray(r.props.children).forEach(e=>Xt(e,t,n));if("string"==typeof r.type){if(Ht.has(r.type))return;if(!Bt.has(r.type))return n.push(" "),re.toArray(r.props.children).forEach(e=>Xt(e,t,n)),void n.push(" ")}const o=oe(r,{key:`title-part-${t.accessories.length}`});t.accessories.push(o),(qt(r.type)?t.badges:t.actions).push(o)}var Yt=/* @__PURE__ */new Map,Vt=/* @__PURE__ */new Set,Jt=0;function Gt(){Jt++,Vt.forEach(e=>e())}function _t(e){return Yt.get(e)}function Zt(e){return Vt.add(e),()=>{Vt.delete(e)}}function Qt(){return Jt}var en=X(""),tn=X(null);function nn({spec:e,children:t}){/* @__PURE__ */
44
+ return ue(tn.Provider,{value:e,children:t})}var rn=/* @__PURE__ */new Set(["button","input","textarea","select","kbd","svg"]),on='button[type="submit"], button[data-submit], button.btn-submit, button.bg-green-600, button.bg-blue-600';function an(e){return sn(e).replace(/\s+/g," ").trim()}function sn(e){if(null==e||"boolean"==typeof e)return"";if("string"==typeof e)return e;if("number"==typeof e)return String(e);if(Array.isArray(e))return e.map(sn).join("");if(te(e)){const t=e,n="string"==typeof t.type?t.type:"";return rn.has(n)?"":` ${sn(t.props?.children)} `}return""}function ln(e){const t=Y(en);_(()=>{if(!t)return;const n=n=>{n.detail===t&&e()};return window.addEventListener("widget-open-settings",n),()=>window.removeEventListener("widget-open-settings",n)},[e,t])}var cn={};function un(e,t,n){const r=Y(en);_(()=>{if(!r)return;cn[r]||(cn[r]=[]);const o={label:e,icon:n,onClick:t};return cn[r].push(o),()=>{cn[r]=(cn[r]||[]).filter(e=>e!==o)}},[r,e,t,n])}function dn({title:e}){const t=G(null);return _(()=>{const n=setTimeout(()=>{const n=t.current?.closest("[data-modal-id]"),r=n?.getAttribute("data-modal-id");r&&window.dispatchEvent(new CustomEvent("window-title-update",{detail:{id:r,title:e}}))},0);return()=>clearTimeout(n)},[e]),/* @__PURE__ */ue("span",{ref:t,style:{display:"none"},"aria-hidden":"true"})}function hn(e){}function mn(){return Y(en)}function pn({children:e,position:t="right",quiet:n=!1}){const r=Y(C),[o,i]=Z(null);return _(()=>{if(!r)return;const e="left"===t?r.leftRef:r.rightRef,o=()=>!!e.current&&(i(e.current),n||r.notify(),!0);if(o())return;const a=setInterval(()=>{o()&&clearInterval(a)},50),s=setTimeout(()=>clearInterval(a),2e3);return()=>{clearInterval(a),clearTimeout(s)}},[r,t,n]),o?he(e,o):null}function fn({onClick:e,children:t,className:n}){const r=Y(C);/* @__PURE__ */
45
+ return ue("button",{type:"button",onClick:async()=>{if(r?.isDirty){const{confirm:e}=await(import("./shell/ConfirmDialog.js"));if(!await e({title:"Discard changes?",message:"You have unsaved changes. Are you sure you want to cancel? All changes will be lost.",confirmLabel:"Discard",cancelLabel:"Keep Editing",variant:"warning"}))return}e()},className:n||"bg-white text-gray-700 border border-gray-300 px-4 py-2 text-sm font-medium rounded-lg hover:bg-gray-50",children:t||"Cancel"})}var wn="erp_window_positions",yn={};try{const e=localStorage.getItem(wn);e&&(yn=JSON.parse(e))}catch{}var gn=null;function bn(){gn&&clearTimeout(gn),gn=setTimeout(()=>{try{localStorage.setItem(wn,JSON.stringify(yn))}catch{}},500)}var vn="erp_activation_order",xn=[];try{const e=localStorage.getItem(vn),t=e?JSON.parse(e):null;Array.isArray(t)&&t.every(e=>"string"==typeof e)&&(xn=t)}catch{}var kn=null;function En(){kn&&clearTimeout(kn),kn=setTimeout(()=>{try{localStorage.setItem(vn,JSON.stringify(xn))}catch{}},500)}function Cn(e,t){yn[e]||(yn[e]=t,bn())}function Mn(e){return yn[e]?{...yn[e]}:null}function Nn(e,t){yn[e]=t,bn()}function Sn(){const r=e(),o=t();let i=!1;for(const e of Object.keys(yn))n(yn[e],r,o)&&(delete yn[e],i=!0);i&&bn()}var Ln={sm:384,md:512,lg:672,xl:896,"2xl":1152,"3xl":1408},Tn=4e3,zn=()=>{if("undefined"==typeof document)return"large";const e=getComputedStyle(document.documentElement).getPropertyValue("--default-window-size")?.trim();return"small"===e||"medium"===e||"maximized"===e?e:"large"},An={small:.8,medium:1,large:1.25,maximized:1.25},Dn=/* @__PURE__ */new Set,Pn=0,In=/* @__PURE__ */new Map;var Rn=0;function Wn(){return Rn}function Kn(){Rn++,E.forEach(e=>e())}var $n=/* @__PURE__ */new Map,On=/* @__PURE__ */new Map,jn=/* @__PURE__ */new Map;function Fn(){for(let e=k.length-1;e>=0;e--){const t=jn.get(k[e]);if(t?.tab)return t.owner}return null}function qn(){return Q(M,Fn,()=>null)}var Bn=/* @__PURE__ */new Set;var Hn=null;function Un(e){Hn=null,er(e)}function Xn(e){Hn=e;const t=$n.get(e);t&&Un(t)}var Yn=/* @__PURE__ */new Map;function Vn(e){return Yn.get(e)?.holdsChanges()??!1}function Jn(e){const t=Yn.get(e);return t?t.ask():Promise.resolve(!0)}function Gn(e){Hn===e&&(Hn=null)}function _n(e,t,n){if(n&&jn.set(e,n),t)if($n.set(t,e),On.set(e,t),Bn.delete(t)){k.unshift(e);const n=xn.indexOf(t);-1!==n&&xn.splice(n,1),xn.unshift(t),En()}else!function(e,t){const n=xn.indexOf(t);if(-1===n)return void k.push(e);let r=k.length;for(let e=0;e<k.length;e++){const t=On.get(k[e]);if(t&&xn.indexOf(t)>n){r=e;break}}k.splice(r,0,e)}(e,t),-1===xn.indexOf(t)&&(xn.push(t),En());else k.push(e);Kn(),window.dispatchEvent(new CustomEvent("modal-reorder")),t&&Hn===t&&Un(e)}function Zn(e){return e?jn.get(e)?.owner??On.get(e)??null:null}var Qn=/* @__PURE__ */new Set;function er(e){const t=Zn(N()),n=k.indexOf(e);-1!==n&&k.splice(n,1),k.push(e);const r=jn.get(e);if(r?.root)for(const[e,t]of jn){if(t.root||t.owner!==r.owner||Dn.has(e))continue;const n=k.indexOf(e);-1!==n&&k.splice(n,1),k.push(e)}Dn.delete(e);const o=On.get(e);if(o){const e=xn.indexOf(o);-1!==e&&xn.splice(e,1),xn.push(o),En(),Hn&&Hn!==o&&(Hn=null)}Kn(),window.dispatchEvent(new CustomEvent("modal-reorder"));const i=Zn(N());i&&i!==t&&Qn.forEach(e=>e(i))}function tr(e){const t=k.indexOf(e);-1!==t&&k.splice(t,1),Dn.add(e),In.set(e,++Pn);const n=On.get(e);if(n){const e=xn.indexOf(n);-1!==e&&(xn.splice(e,1),En())}Kn(),window.dispatchEvent(new CustomEvent("modal-reorder"))}var nr=/* @__PURE__ */new Set;var rr=8,or=32;function ir(){return e()}var ar=c.windowBar,sr=80,lr=384,cr=400;function ur(e,t=ir()){const n=Math.min(Math.max(e.x,t.x+sr-e.w),t.x+t.w-sr),r=Math.min(Math.max(e.y,t.y),t.y+t.h-ar);return n===e.x&&r===e.y?e:{...e,x:n,y:r}}function dr(e){const t=e.getBoundingClientRect();if(0===t.width||0===t.height)return!0;const n=ir();return t.left>=n.x-1&&t.top>=n.y-1&&t.right<=n.x+n.w+1&&t.bottom<=n.y+n.h+1}function hr(e){const t=ir(),n=Math.floor(t.w/2),r=Math.floor(t.h/2);switch(e){case"top":return{x:t.x,y:t.y,w:t.w,h:t.h};case"left":return{x:t.x,y:t.y,w:n,h:t.h};case"right":return{x:t.x+n,y:t.y,w:t.w-n,h:t.h};case"tl":return{x:t.x,y:t.y,w:n,h:r};case"tr":return{x:t.x+n,y:t.y,w:t.w-n,h:r};case"bl":return{x:t.x,y:t.y+r,w:n,h:t.h-r};case"br":return{x:t.x+n,y:t.y+r,w:t.w-n,h:t.h-r}}}var mr=null;function pr(e){const t=(mr||((mr=document.createElement("div")).style.cssText=["position: fixed","pointer-events: none",`z-index: ${F.snapPreview}`,"border-radius: 8px","background: rgba(59, 130, 246, 0.18)","border: 2px solid rgb(59, 130, 246)","transition: left 120ms ease, top 120ms ease, width 120ms ease, height 120ms ease, opacity 120ms ease","opacity: 0","display: none"].join(";"),document.body.appendChild(mr)),mr);t.style.display="block",t.style.left=`${e.x}px`,t.style.top=`${e.y}px`,t.style.width=`${e.w}px`,t.style.height=`${e.h}px`,t.style.opacity="1"}function fr(){mr&&(mr.style.opacity="0",mr.style.display="none")}var wr=[{zone:"left",labelKey:"snapLeft",region:"inset-y-0 left-0 w-1/2"},{zone:"right",labelKey:"snapRight",region:"inset-y-0 right-0 w-1/2"},{zone:"tl",labelKey:"snapTopLeft",region:"top-0 left-0 h-1/2 w-1/2"},{zone:"tr",labelKey:"snapTopRight",region:"top-0 right-0 h-1/2 w-1/2"},{zone:"bl",labelKey:"snapBottomLeft",region:"bottom-0 left-0 h-1/2 w-1/2"},{zone:"br",labelKey:"snapBottomRight",region:"bottom-0 right-0 h-1/2 w-1/2"}],yr=350,gr=200;function br({maximized:e,onToggleMax:t,onSnap:n,buttonClassName:r,strings:o}){const[i,a]=Z(!1),s=G(void 0),l=G(void 0);_(()=>()=>{clearTimeout(s.current),clearTimeout(l.current)},[]);const c=()=>{clearTimeout(l.current),s.current=setTimeout(()=>a(!0),yr)},u=()=>{clearTimeout(s.current),l.current=setTimeout(()=>a(!1),gr)};/* @__PURE__ */
46
46
  return ce("span",{className:"relative inline-flex",onMouseEnter:c,onMouseLeave:u,children:[
47
- /* @__PURE__ */ue("button",{onClick:t,onFocus:c,onBlur:u,title:e?o.windowed:o.maximize,className:r,children:e?"❐":"⤢"}),i&&/* @__PURE__ */ue("div",{role:"group","aria-label":o.snapLayouts,onMouseEnter:()=>clearTimeout(l.current),onMouseLeave:u,className:"absolute right-0 top-full z-30 mt-1 grid w-max grid-cols-2 gap-1 rounded-lg border border-line bg-surface p-2 shadow-lg",children:wr.map(({zone:e,labelKey:t,region:r})=>/* @__PURE__ */ue("button",{type:"button","aria-label":o[t],title:o[t],onClick:()=>{a(!1),n(e)},onFocus:()=>clearTimeout(l.current),onBlur:u,className:"relative h-7 w-11 rounded border border-gray-300 bg-gray-50 hover:border-blue-400 focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-400",children:/* @__PURE__ */ue("span",{"aria-hidden":"true",className:`absolute rounded-sm bg-blue-500/70 ${r}`,style:{margin:2}})},e))})]})}var vr="rosh-gesture-style";var xr={se:"nwse-resize",nw:"nwse-resize",sw:"nesw-resize",ne:"nesw-resize",n:"ns-resize",s:"ns-resize",e:"ew-resize",w:"ew-resize"},kr=4;function Er(e,t,n,r){!function(){if("undefined"==typeof document||document.getElementById(vr))return;const e=document.createElement("style");e.id=vr,e.textContent="body.rosh-gesturing [data-modal-panel]{will-change:transform}",document.head.appendChild(e)}();try{e.setPointerCapture(t)}catch{}document.body.classList.add("rosh-gesturing");const o=document.createElement("div");o.setAttribute("data-drag-shield",""),o.style.cssText=`position:fixed;inset:0;z-index:2147483647;cursor:${n};background:transparent;touch-action:none`,document.body.appendChild(o);const i=Ot(r);let a=!1;return()=>{if(!a){a=!0,i();try{e.releasePointerCapture(t)}catch{}o.remove(),document.body.classList.remove("rosh-gesturing")}}}function Cr(e){const t=N.indexOf(e);if(-1===t)return-1;const n=F.window+t*F.windowStep,r=jn.get(e);if(!r||r.root)return n;let o=-1;for(const[e,t]of jn){if(!t.root||t.owner!==r.owner)continue;const n=N.indexOf(e);-1!==n&&(o=Math.max(o,F.window+n*F.windowStep))}return o>=n?o+2+Math.min(t,7):n}"undefined"!=typeof window&&window.addEventListener("deactivate-all-modals",function(){for(let e=N.length-1;e>=0;e--)nr.has(N[e])||N.splice(e,1);xn=xn.filter(e=>{const t=$n.get(e);return null!=t&&nr.has(t)}),En(),Kn(),window.dispatchEvent(new CustomEvent("modal-reorder"))});var Mr="modal-close-request";function Nr(e){Q(T,Wn);const t=Y(L);if(N.length<=1)return!0;if(e){const t=$n.get(e);if(null!=t)return z()===t}return t?.active??null!=z()}var Sr=!1,Lr=/* @__PURE__ */new Set;function Tr(e){return Lr.add(e),()=>Lr.delete(e)}function zr(){return Sr}function Ar(e){Sr!==e&&(Sr=e,Lr.forEach(e=>e()))}function Dr(){Ar(!Sr)}function Pr(){Ar(!1)}var Ir=null,Rr=/* @__PURE__ */new Set;function Wr(e){return Rr.add(e),()=>Rr.delete(e)}function Kr(){return Ir}function $r(e){Ir!==e&&(Ir=e,Rr.forEach(e=>e()))}var Or=null,jr=/* @__PURE__ */new Set;function Fr(e){return jr.add(e),()=>jr.delete(e)}function qr(){return Or}function Br(e){Or!==e&&(Or=e,jr.forEach(e=>e()))}function Hr(){if(!Or)return void Ar(!1);$r(Or),Br(null),Ar(!1)}function Ur(){Ar(!Sr),window.dispatchEvent(new CustomEvent("modal-split-view"))}function Xr(){const e=Q(Tr,zr),[t,n]=Z(e),[r,o]=Z(e);return J(()=>{if(e){n(!0);const e=requestAnimationFrame(()=>o(!0));return()=>cancelAnimationFrame(e)}o(!1);const t=setTimeout(()=>n(!1),280);return()=>clearTimeout(t)},[e]),t&&"undefined"!=typeof document?he(
48
- /* @__PURE__ */ue("div",{onMouseDown:e=>{e.stopPropagation(),Ar(!1)},style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.55)",backdropFilter:"blur(2px)",WebkitBackdropFilter:"blur(2px)",zIndex:F.expose,cursor:"pointer",opacity:r?1:0,transition:"opacity 260ms cubic-bezier(0.2, 0.8, 0.2, 1)",pointerEvents:r?"auto":"none"}}),document.body):null}function Yr({open:t,onClose:l,title:c,icon:u,copyText:d,size:h="lg",dirty:m=!1,onNext:p,onPrev:f,footer:y,bodyScroll:v,onMinimize:x,initialBox:k,actions:S,actionsLeft:D,editing:P=!1,edit:K,allowPinOnTop:j,initialPosition:q,widget:B,compact:X,appStyle:V,flushBody:ne,autoHeight:re,autoMinHeight:se,autoWidth:le,widgetMenu:me,dimensions:pe,windowKey:fe,openedFromKey:we,accentRgb:ye,children:ge}){const[be,ve]=Z(()=>r()),xe=E()&&!be,ke=C()&&!!B,[Ce,Me]=Z(0),[Ne,Se]=Z(!1),Le=G(null),Te=G(0);J(()=>{Te.current=Ce},[Ce]);const ze=ee(e=>{xe&&(Le.current={startX:e.clientX,startY:e.clientY,pointerId:e.pointerId},Se(!0),Dt(we??null))},[xe,we]),Ae=Q(Pt,At);J(()=>{if(!Ne)return;const e=e=>{if(!Le.current)return;const t=e.clientX-Le.current.startX;if(Math.abs(e.clientY-Le.current.startY)>Math.abs(t)+12)return Le.current=null,Se(!1),Me(0),void Dt(null);Me(Math.max(0,t))},t=()=>{if(!Le.current)return;const e=.3*window.innerWidth,t=Te.current>e;Le.current=null,Se(!1),t?(Me(window.innerWidth),setTimeout(()=>{l(),Me(0),Dt(null)},180)):(Me(0),Dt(null))};return window.addEventListener("pointermove",e),window.addEventListener("pointerup",t),window.addEventListener("pointercancel",t),()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",t),window.removeEventListener("pointercancel",t)}},[Ne]);const[De,Re]=Z(c),Ke=H(),$e=Ke.window;J(()=>{Re(c)},[c]);const Oe=ie(()=>an(De).trim()||void 0,[De]),je=ae(),[Fe,qe]=Z(!1),Be=G(!1),[He,Ue]=Z(!1),[Xe,Ye]=Z(null),Ve=Y(tn),_e=Y(Ee),{prefs:Ge,save:Je}=M(),Ze=!!Ge.window_accent_stripe,Qe=Ge.favorite_documents||[],tt=!!Ve&&Qe.some(e=>e.entityType===Ve.entityType&&e.entityId===Ve.entityId),rt=ee(()=>{if(!Ve)return;const e=tt?Qe.filter(e=>!(e.entityType===Ve.entityType&&e.entityId===Ve.entityId)):[...Qe,{entityType:Ve.entityType,entityId:Ve.entityId,label:Ve.label}];Je({favorite_documents:e})},[Ve,tt,Qe,Je]),[ot,it]=Z(null),[at,st]=Z("top-right"===q?"right":"left"),lt=G(!1),ct=G(null);_(()=>{const e=ct.current;e&&(ye?e.style.setProperty("--window-accent-rgb",ye):e.style.removeProperty("--window-accent-rgb"))},[ye]);const ut=G(!1),dt=G(null),ht=G(null),mt=G(null),[pt,ft]=Z(!1),wt=G(null),yt=G(null),gt=G(null),[bt,vt]=Z(!1);_(()=>{const e=yt.current,t=gt.current;if(!e||!t)return;const n=()=>vt(function(e,t){return e.scrollWidth>t.clientWidth}(t,e));if(n(),"undefined"==typeof ResizeObserver)return;const r=new ResizeObserver(n);return r.observe(e),r.observe(t),()=>r.disconnect()},[null!=y&&!1!==y]);const xt=!!K&&!B&&!X&&!V&&(K.editing||"hidden"!==K.state),kt=!!(y||S||D)||pt||xt,Et=Y(Ie),Ct=""!==Y(en),Mt=G(null);Mt.current=_e?{owner:_e.key,tab:_e.tab,root:!Ct}:null;const Nt=fe||(_e&&!Ct?_e.key:null),St=!!Et&&!Ct&&Et.enabled&&Et.hasState&&(P||Et.declaredEditable)&&!Et.handMounted&&kt&&!B&&!X&&!V&&!xe,Tt=/* @__PURE__ */ue(O,{name:"window",className:"h-4 w-4",strokeWidth:1.5}),zt=u&&te(u)?oe(u,{className:`h-4 w-4 ${u.props?.className??""}`.trim()}):u??Tt,It=()=>/* @__PURE__ */ue("button",{onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation();const t=e.currentTarget.getBoundingClientRect();Ye(e=>e?null:{x:t.left,y:t.bottom+4})},className:"shrink-0 p-0.5 rounded hover:bg-gray-200/50 transition-colors",title:"Window menu",children:zt}),Rt=40,{minimize:Wt,items:Kt,restoreIfMinimized:$t,openWindows:Ot}=nt(),jt=G(`modal-${Math.random().toString(36).slice(2,8)}`).current;J(()=>{if(B)return nr.add(jt),()=>{nr.delete(jt)}},[B,jt]),J(()=>{const e=e=>{const t=e.detail;t?.id===jt&&Re(t.title)};return window.addEventListener("window-title-update",e),()=>window.removeEventListener("window-title-update",e)},[jt]);const[Ft,qt]=Z(F.window),Bt=function(e){const t=Q(T,z);return N.length<=1||t===e}(jt),Ht=G(K);Ht.current=K;const Xt=!!K&&!K.editing&&"enabled"===K.state;J(()=>{if(!t||!Bt||!Xt)return;const e=e=>{("KeyE"===e.code||"E"===e.key||"e"===e.key)&&e.altKey&&e.shiftKey&&!e.metaKey&&!e.ctrlKey&&(g(e.target,ct.current)||(e.preventDefault(),e.stopPropagation(),Ht.current?.onEdit()))};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[t,Bt,Xt]);const Vt=function(e){return Q(T,()=>Dn.has(e))}(jt);Lt({panelRef:ct,bodyRef:dt,open:t,widget:!!B,active:Bt,minimized:Vt});const _t=Q(Tr,zr),Jt=Q(Wr,Kr),Zt=Q(Fr,qr),Qt=!j&&!B,nn=_t&&Qt,[rn,sn]=Z(!1),ln=nn&&Zt===jt,[un,dn]=Z(!1),hn=un&&Qt&&Jt===jt?"picked":null,mn=G(nn);J(()=>{if(mn.current&&!nn){dn(!0);const e=setTimeout(()=>{dn(!1),Ir===jt&&$r(null)},700);return mn.current=nn,()=>clearTimeout(e)}mn.current=nn},[nn,jt]),J(()=>{nn||sn(!1)},[nn]),J(()=>{const e=ht.current,t=mt.current;if(!e&&!t)return;const n=e=>e?Array.from(e.children).filter(e=>"shell"!==e.dataset.undoControls).length:0,r=()=>ft(n(e)+n(t)>0);r();const o=new MutationObserver(r);return e&&o.observe(e,{childList:!0}),t&&o.observe(t,{childList:!0}),()=>o.disconnect()},[t]),J(()=>{const e=e=>{if(e.target.closest('button[type="submit"]')&&ct.current){const t=ct.current.querySelector("form");t&&(e.preventDefault(),t.requestSubmit())}},t=ht.current,n=mt.current;return t&&t.addEventListener("click",e),n&&n.addEventListener("click",e),()=>{t&&t.removeEventListener("click",e),n&&n.removeEventListener("click",e)}},[t]);const pn=G(!1),fn=ee(e,[]),wn=ee(()=>{const t=e(),n=pe?pe[0]:Ln[h]||672,o=t.w-80,i=t.h-80,a=Math.min(n,o),s=An[zn()],l=pe?Math.min(pe[1],i):(()=>{const e=("sm"===h?500:"md"===h?600:"lg"===h?700:"xl"===h?800:920)*s;return Math.max(320,Math.min(e,t.h-80))})(),c="cascade"!==(getComputedStyle(document.documentElement).getPropertyValue("--window-position")?.trim()||"cascade")||r()?0:30*(N.length-1),u=Math.max(Rt,(i-l)/2),d=(o-a)/2,m=t.h-Rt-l-u;return"top-right"===q?{x:t.x+t.w-a-Rt,y:t.y+Rt,w:a,h:l}:"top-left"===q?{x:t.x+Rt,y:t.y+Rt,w:a,h:l}:{x:t.x+Math.max(Rt,(o-a)/2+Rt)+Math.min(c,Math.max(0,d)),y:t.y+u+Math.min(c,Math.max(0,m)),w:a,h:l}},[h]),gn=G(!1);t||(gn.current=!1);const vn=fe||d||null;J(()=>{if(!t)return;Jn(jt,vn,Mt.current??void 0),fe||er(jt),pn.current=!1,qt(Cr(jt));const e=()=>{qt(Cr(jt))},n=()=>{},r=e=>{if(!e)return!1;if(e.windowKey)return e.windowKey===fe;if(!e.label)return!1;const t=ct.current?.querySelector("[data-window-title]");return!!t?.textContent?.includes(e.label)},o=e=>{if(!r(e.detail))return;if(er(jt),Wn.current)return;const t=ir(),n=Math.min(Vn.current.w,t.w-40),o=Math.min(Vn.current.h,t.h-40),i=t.x+(t.w-n)/2,a=t.y+(t.h-o)/2;En({x:i,y:a,w:n,h:o}),Xn(!1)},i=e=>{const t=e.detail;r(t)&&(er(jt),Ye({x:t.x,y:t.y}))},a=e=>{if(e.detail?.windowKey!==fe)return;er(jt);const t=Vn.current,n=function(e,t=ir()){const n=Math.min(e.w,t.w),r=Math.min(e.h,t.h);return{w:n,h:r,x:Math.min(Math.max(e.x,t.x),t.x+t.w-n),y:Math.min(Math.max(e.y,t.y),t.y+t.h-r)}}(t);if(n.x===t.x&&n.y===t.y&&n.w===t.w&&n.h===t.h)return;const r=ct.current,o="function"==typeof window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;if(r&&!o){let e=!1;const t=()=>{e||(e=!0,r.style.transition="",window.dispatchEvent(new CustomEvent("modal-geometry")))};r.style.transition="left .28s ease, top .28s ease, width .28s ease, height .28s ease",r.addEventListener("transitionend",t,{once:!0}),window.setTimeout(t,400)}En(n)};return window.addEventListener("modal-reorder",e),window.addEventListener("modal-split-view",n),window.addEventListener("modal-center",o),window.addEventListener("modal-reveal",a),window.addEventListener("modal-context-menu",i),()=>{!function(e){const t=N.indexOf(e);-1!==t&&(N.splice(t,1),Kn()),Dn.delete(e),In.delete(e),jn.delete(e);const n=On.get(e);n&&(On.delete(e),$n.delete(n))}(jt),window.removeEventListener("modal-reorder",e),window.removeEventListener("modal-split-view",n),window.removeEventListener("modal-center",o),window.removeEventListener("modal-reveal",a),window.removeEventListener("modal-context-menu",i),window.dispatchEvent(new CustomEvent("modal-reorder"))}},[t,jt,vn,fn]);const xn=!B&&"maximized"===zn(),[kn,En]=Z(()=>{if(vn&&yn[vn]){const e={...yn[vn]};return pe&&(e.w=pe[0],re||(e.h=pe[1])),ur(e)}return k?{x:k.x,y:k.y,w:k.w,h:k.h}:xn?fn():wn()}),[Cn,Mn]=Z(()=>!re),Nn=G(be),Sn=G(null);J(()=>{const e=()=>{const e=r();e!==Nn.current&&Sn.current?.(e),Nn.current=e,ve(e),qt(Cr(jt))};return window.addEventListener("react-os-shell:layout-mode-changed",e),()=>window.removeEventListener("react-os-shell:layout-mode-changed",e)},[jt]);const Pn=be&&!!_e?.tab&&!Ct&&!B&&!xe,Rn=Pn,Wn=G(Rn);Wn.current=Rn;const Fn=qn(),Bn=be&&!!_e?.tab&&!B&&!xe&&!_t&&Fn!==_e.key,Hn=!!B&&be&&!_t&&null!==Fn,[Un,Xn]=Z(()=>vn&&yn[vn]||k?Rn:Rn||xn),Vn=G(kn);Vn.current=kn;const _n=G(Un);_(()=>{_n.current=Un},[Un]),_(()=>{if(Cn||Pn)return;const e=ct.current,t=dt.current;if(!e||!t)return;const n=se??(B?0:240),r=parseInt(getComputedStyle(document.documentElement).getPropertyValue("--taskbar-height"))||0;let o=0,i=null,a=null;const s=()=>{const c=t.firstElementChild;if(!c||e.offsetHeight<=0)return;c!==a&&(a&&l.unobserve(a),l.observe(c),a=c);const u=e.offsetHeight-t.offsetHeight,d=t.style.flex,h=t.style.overflowY,m=t.style.height;t.style.flex="0 0 auto",t.style.height="auto",t.style.overflowY="visible";const p=t.offsetHeight,f=c.offsetHeight;t.style.flex=d,t.style.height=m,t.style.overflowY=h;const w=c.offsetHeight>f+4,y=Math.max(n,window.innerHeight-r-Math.max(0,Vn.current.y)-24),g=w?Math.min(Vn.current.h,y):Math.min(Math.max(n,u+p),y),b=Math.abs(g-o)>1;b&&(o=g,En(e=>Math.abs(e.h-g)>1?{...e,h:g}:e)),B||(g<=n?i&&(clearTimeout(i),i=null):(b||null===i)&&(i&&clearTimeout(i),i=setTimeout(()=>{const e=o;s(),o===e&&Mn(!0)},160)))},l=new ResizeObserver(s);s(),wt.current&&l.observe(wt.current);const c=new MutationObserver(s);return c.observe(t,{childList:!0,subtree:!0,characterData:!0}),()=>{l.disconnect(),c.disconnect(),i&&clearTimeout(i)}},[Cn,B,se,kt,Pn]),_(()=>{if(!re||!Cn||B||!t)return;const e=wt.current;if(!e)return;let n=e.offsetHeight;const r=new ResizeObserver(()=>{if(!e.isConnected)return;const t=e.offsetHeight,r=t-n,o=t>0!=n>0;if(n=t,!o||0===r||Un)return;if(document.body.classList.contains("rosh-gesturing"))return;const i=se??240,a=parseInt(getComputedStyle(document.documentElement).getPropertyValue("--taskbar-height"))||0,s=Math.max(i,window.innerHeight-a-Math.max(0,Vn.current.y)-24);En(e=>({...e,h:Math.min(Math.max(i,e.h+r),s)}))});return r.observe(e),()=>r.disconnect()},[re,Cn,B,t,Un,se]);const Gn=!1!==le&&!B&&!V&&!xe,[Zn,Qn]=Z(()=>!Gn);_(()=>{if(Zn||!t)return;if(!Gn||Un)return void Qn(!0);const n=ct.current,r=dt.current;if(!n||!r)return;const o=/* @__PURE__ */new WeakSet;let l=Vn.current.w,c=0;const u=()=>Qn(!0),d=()=>{c=0;const t=Vn.current;if(Math.abs(t.w-l)>1||document.body.classList.contains("rosh-gesturing"))return void u();const d=e(),h=d.w-80;if(t.w>=h)return void u();const m=[],p=[];for(const e of[r,...Array.from(r.querySelectorAll("*"))]){const t=e.scrollWidth-e.clientWidth;if(t<=4||o.has(e))continue;const n=getComputedStyle(e).overflowX;"auto"!==n&&"scroll"!==n||(m.push(e),p.push(t))}if(!m.length)return;const f=Math.min(h,t.w+Math.max(...p)),w=f-t.w,y=n.style.width;n.style.width=`${f}px`;const g=m.map((e,t)=>({over:p[t],residual:e.scrollWidth-e.clientWidth}));n.style.width=y,g.forEach((e,t)=>{i(e,w)||o.add(m[t])});const b=a(t,s(t.w,w,g),d,Rt);b!==t&&(l=b.w,En(b))};d();const h=new MutationObserver(()=>{c||(c=requestAnimationFrame(d))});h.observe(r,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["style","class","hidden"]});const m=setTimeout(u,Tn);return()=>{h.disconnect(),c&&cancelAnimationFrame(c),clearTimeout(m)}},[Zn,t,Gn,Un]);const ar=G(null),sr=!(!_e?.tab||Ct||B||xe);Sn.current=t=>{if(!sr)return;if(t)return ar.current||(ar.current={box:{...Vn.current},maximized:_n.current}),void(_n.current=!0);const r=ar.current;ar.current=null;const o=e();if(r?.maximized)return _n.current=!0,Xn(!0),void En(o);const i=r?.box??(vn?yn[vn]:void 0);if(_n.current=!1,Xn(!1),i&&!n(i,o,!1)){const e={...i};pe&&(e.w=pe[0],re||(e.h=pe[1])),En(ur(e))}else En(wn())},J(()=>{Rn&&(_n.current=!0,Xn(!0),En(fn()))},[Rn,fn]),J(()=>{if(B)return;const e=()=>{const e=vn?yn[vn]:void 0;if(_n.current=!1,Xn(!1),e){const t={...e};pe&&(t.w=pe[0],re||(t.h=pe[1])),En(ur(t))}else En(wn())};return window.addEventListener("react-os-shell:restore-windowed",e),()=>window.removeEventListener("react-os-shell:restore-windowed",e)},[B,wn,vn]),J(()=>{t&&vn&&!Pn&&(yn[vn]=kn,bn()),t&&window.dispatchEvent(new CustomEvent("modal-geometry"))},[kn,t,vn,Pn]),J(()=>{if(!t)return;const e=()=>{_n.current?En(fn()):document.body.classList.contains("rosh-gesturing")||En(ur)};window.addEventListener("resize",e),window.addEventListener(o,e);let n=null;return Un&&(n=new MutationObserver(e),n.observe(document.body,{childList:!0,subtree:!1,attributes:!0,attributeFilter:["class"]})),()=>{window.removeEventListener("resize",e),window.removeEventListener(o,e),n?.disconnect()}},[t,Un,fn]),J(()=>{if(t&&(qe(!1),Be.current=!1,lt.current=!1,Qn(!Gn),!Wn.current)){if(vn&&yn[vn]){const e=yn[vn];return void En(t=>ur({...e,...re?{h:t.h}:{},...Gn?{x:t.x,w:t.w}:{}}))}k&&(En({x:k.x,y:k.y,w:k.w,h:k.h}),Xn(k.maximized))}},[t]),J(()=>{if(!t||"auto"!==m)return;let e;const n=t=>{ct.current?.contains(t.target)&&!Be.current&&(Be.current=!0,e=setTimeout(()=>qe(!0),0))};return document.addEventListener("input",n,!0),document.addEventListener("change",n,!0),()=>{clearTimeout(e),document.removeEventListener("input",n,!0),document.removeEventListener("change",n,!0)}},[t,m]);const dr="auto"===m?Fe:!0===m,mr=_e&&!Ct?_e.key:null,wr=ie(()=>Ut(De),[De]),yr=G({shortcutSpec:Ve,isOnDesktop:tt,toggleDesktopShortcut:rt,taskbarStrings:Ke.taskbar});_(()=>{yr.current={shortcutSpec:Ve,isOnDesktop:tt,toggleDesktopShortcut:rt,taskbarStrings:Ke.taskbar}});const gr=G(null);gr.current||(gr.current={open:(e,t)=>Ye({x:e,y:t}),items:()=>{const e=yr.current,t=[];e.shortcutSpec&&t.push({label:e.isOnDesktop?e.taskbarStrings.removeFromDesktop:e.taskbarStrings.addToDesktop,onSelect:e.toggleDesktopShortcut});for(const e of cn[jt]||[])t.push({label:e.label,icon:e.icon,onSelect:e.onClick});return t}}),J(()=>{if(t&&mr)return()=>{return e=mr,void(Yt.delete(e)&&Gt());var e}},[t,mr]),et(!(fe||!t)&&dr);const vr=ee(()=>dr||"auto"===m&&Be.current,[dr,m]),Nr=ee(async e=>{if(lt.current)return!1;if(!vr())return!0;lt.current=!0;const t=Oe,n="close"===e?"Are you sure you want to close?":"discard"===e?"Are you sure you want to stop editing?":"Are you sure you want to continue?",r=await w({title:"Discard changes?",message:t?`“${t}” has unsaved changes. ${n} All changes will be lost.`:`You have unsaved changes. ${n} All changes will be lost.`,confirmLabel:"Discard",cancelLabel:"Keep Editing",variant:"warning"});return lt.current=!1,r},[vr,Oe]),Sr=ee(()=>lt.current?Promise.resolve():vr()?Nr("close").then(e=>{e&&l()}):(l(),Promise.resolve()),[vr,Nr,l]),Lr=ee(async()=>{await Nr("discard")&&(Be.current=!1,qe(!1),Ht.current?.onDiscard())},[Nr]),Dr=ee(async()=>{const e=await Nr("switch");return e&&(Be.current=!1,qe(!1)),e},[Nr]),Pr=G(()=>!1);_(()=>{Pr.current=vr}),_(()=>{if(!t||!fe)return;const e={holdsChanges:()=>Pr.current(),ask:Dr};return Yn.set(fe,e),()=>{Yn.get(fe)===e&&Yn.delete(fe)}},[t,fe,Dr]),_(()=>{if(!t||!Nt)return;const e=e=>{e.detail?.windowKey===Nt&&Sr()};return window.addEventListener(Mr,e),()=>window.removeEventListener(Mr,e)},[t,Nt,Sr]);const Rr=G(null),Or=ee(e=>{if(0!==e.button)return;if(e.target.closest("button, input, a, kbd, select, textarea"))return;if(Ye(null),er(jt),Wn.current)return void e.preventDefault();e.preventDefault();const t=e.currentTarget,n=e.pointerId;let r=null;const o=e.clientX,i=e.clientY,a=ct.current,s=a?.getBoundingClientRect();let l,c,u,d;if(Rr.current){const t=Rr.current;Rr.current=null,d=t.w,u=t.h;const n=s?Math.min(Math.max(20,e.clientX-s.left),t.w-20):t.w/2;l=e.clientX-n,c=e.clientY-12,a&&(a.style.width=`${d}px`,a.style.height=`${u}px`,a.style.left=`${l}px`,a.style.top=`${c}px`)}else l=s?s.left:Vn.current.x,c=s?s.top:Vn.current.y,u=s?s.height:Vn.current.h,d=s?s.width:Vn.current.w;Xn(!1),En(e=>({...e,x:l,y:c,w:d,h:u}));let h=null;const m=e=>{if(!r){if(Math.abs(e.clientX-o)<kr&&Math.abs(e.clientY-i)<kr)return;r=Er(t,n,"move","move"),a&&(a.style.transition="none")}const s=l+e.clientX-o,u=Math.max(0,c+e.clientY-i);if(a&&(a.style.transform=`translate(${s-l}px, ${u-c}px)`),Vn.current={...Vn.current,x:s,y:u},!B){const t=function(e,t){const n=ir(),r=e<=n.x+rr,o=e>=n.x+n.w-rr,i=t<=n.y+rr,a=t>=n.y+n.h-rr,s=e<=n.x+or,l=e>=n.x+n.w-or,c=t<=n.y+or,u=t>=n.y+n.h-or;return i&&s?"tl":i&&l?"tr":a&&s?"bl":a&&l?"br":c&&r?"tl":c&&o?"tr":u&&r?"bl":u&&o?"br":i?"top":r?"left":o?"right":null}(e.clientX,e.clientY);t!==h&&(h=t,t?pr(hr(t)):fr())}},p=()=>{window.removeEventListener("pointermove",m),window.removeEventListener("pointerup",p),r?.(),fr();const e=ur({...Vn.current});if(Vn.current=e,!B&&h){Rr.current={x:l,y:c,w:d,h:u};const e=hr(h);return a&&(a.style.left=`${e.x}px`,a.style.top=`${e.y}px`,a.style.width=`${e.w}px`,a.style.height=`${e.h}px`,a.style.transform="",a.style.transition=""),void En(e)}if(B){const t=e.x+e.w/2,n=window.innerWidth/2;st(t>n?"right":"left")}a&&(a.style.left=`${e.x}px`,a.style.top=`${e.y}px`,a.style.transform="",a.style.transition=""),En(e)};window.addEventListener("pointermove",m),window.addEventListener("pointerup",p)},[]),jr=ee((e,t)=>{if(0!==e.button)return;e.preventDefault(),e.stopPropagation();const n=e.currentTarget,r=e.pointerId;let o=null;const i=e.clientX,a=e.clientY,s=ct.current,l=s?.getBoundingClientRect(),c=l?l.left:Vn.current.x,u=l?l.top:Vn.current.y,d=l?l.width:Vn.current.w,h=l?l.height:Vn.current.h,m="sw"===t||"nw"===t||"w"===t,p="ne"===t||"nw"===t||"n"===t,f="se"===t||"ne"===t||"e"===t,w="se"===t||"sw"===t||"s"===t;Xn(!1),En({x:c,y:u,w:d,h:h}),Vn.current={x:c,y:u,w:d,h:h};let y=0,g=null;const b=()=>{if(y=0,!g)return;const e=g;g=null,Vn.current=e,s&&(s.style.left=`${e.x}px`,s.style.top=`${e.y}px`,s.style.width=`${e.w}px`,s.style.height=`${e.h}px`)},v=e=>{if(!o){if(Math.abs(e.clientX-i)<kr&&Math.abs(e.clientY-a)<kr)return;o=Er(n,r,xr[t],"resize")}g=((e,t)=>{let n=c,r=u,o=d,i=h;if(f&&(o=Math.max(lr,d+e)),w&&(i=Math.max(cr,h+t)),m){const t=Math.max(lr,d-e);n=c+d-t,o=t}if(p){const e=Math.max(cr,h-t);r=u+h-e,i=e}return{x:n,y:r,w:o,h:i}})(e.clientX-i,e.clientY-a),y||(y=requestAnimationFrame(b))},x=()=>{window.removeEventListener("pointermove",v),window.removeEventListener("pointerup",x),y&&cancelAnimationFrame(y),b(),o?.(),En({...Vn.current})};window.addEventListener("pointermove",v),window.addEventListener("pointerup",x)},[]),Br=ee(e=>{if(e.target.closest("button, input, a, kbd, select, textarea"))return;const t={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]}[e.key];if(!t&&"Enter"!==e.key)return;if(e.preventDefault(),e.stopPropagation(),er(jt),"Enter"===e.key)return void(Un?(Xn(!1),En(wn())):(Xn(!0),En(fn())));const[n,r]=t;if(e.ctrlKey||e.metaKey){const e=()=>{Rr.current||(Rr.current={...Vn.current})};if(r<0)return e(),Xn(!0),void En(fn());if(r>0){if(Un)return Xn(!1),void En(wn());if(Rr.current){const e=ur(Rr.current);return Rr.current=null,Vn.current=e,void En(e)}return void tr(jt)}e(),Xn(!1);const t=hr(n<0?"left":"right");return Vn.current=t,void En(t)}if(Un)return;const o=Vn.current,i=e.shiftKey?{...o,w:Math.max(lr,o.w+24*n),h:Math.max(cr,o.h+24*r)}:ur({...o,x:o.x+24*n,y:Math.max(0,o.y+24*r)});Vn.current=i,En(i)},[jt,Un,wn,fn]),Hr=ee(e=>{Rr.current||(Rr.current={...Vn.current}),Xn(!1);const t=hr(e);Vn.current=t,En(t),er(jt)},[jt]),Ur=Rn||nn?{}:{tabIndex:0,role:"group","aria-label":Oe?`${Oe} — ${$e.windowSuffix}`:$e.windowSuffix,"aria-keyshortcuts":"ArrowUp ArrowDown ArrowLeft ArrowRight Shift+ArrowUp Shift+ArrowDown Shift+ArrowLeft Shift+ArrowRight Control+ArrowUp Control+ArrowDown Control+ArrowLeft Control+ArrowRight Enter",onKeyDown:Br},Xr=()=>{Xn(!0),En(fn())},Yr=ee(()=>{const e=ct.current;if(!e)return;const t=e.querySelector("form");if(t)t.requestSubmit();else{const t=e.querySelector(on);t&&!t.disabled&&t.click()}},[]);J(()=>{if(!t)return;if(B)return;const e=e=>{if(N[N.length-1]===jt&&!g(e.target,ct.current)&&"Enter"===e.key){const t=e.target;if("TEXTAREA"===t.tagName||t.isContentEditable)return;if(e.metaKey||e.ctrlKey)e.preventDefault(),Yr();else{if("INPUT"===t.tagName&&t.closest("form"))return;if(!(t instanceof Element&&ct.current?.contains(t)))return;if(t.closest(A))return;e.preventDefault()}}};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[t,Yr,jt,B]),J(()=>{if(!t)return;const e=e=>{N[N.length-1]===jt&&(g(e.target,ct.current)||((e.metaKey||e.ctrlKey)&&"s"===e.key?(e.preventDefault(),document.dispatchEvent(new CustomEvent("modal-save",{detail:{modalId:jt}})),Be.current=!1,qe(!1)):e.altKey&&e.shiftKey&&("KeyD"===e.code||"D"===e.key||"d"===e.key)&&(e.preventDefault(),document.dispatchEvent(new CustomEvent("modal-duplicate",{detail:{modalId:jt}})))))};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[t]),J(()=>{if(!t)return;if(B)return;const e=e=>{if("Escape"===e.key&&N[N.length-1]===jt){if(U(e))return e.preventDefault(),void e.stopPropagation();if(Pn&&!P)return;e.preventDefault(),e.stopPropagation(),Sr()}};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[t,Sr,jt,B,Pn,P]);const Vr=t&&(void 0!==p||void 0!==f),[_r]=Z(()=>{if("undefined"==typeof document)return null;const e=document.createElement("span");return e.className="flex shrink-0 items-center gap-2",e.setAttribute("data-tab-actions",""),e}),Gr=Pn&&!_e?.home&&wr.actions.length>0;J(()=>{t&&mr&&function(e,t){const n=Yt.get(e);n&&n.title===t.title&&n.dirty===t.dirty&&n.copy===t.copy&&n.actions===t.actions&&n.menu===t.menu||(Yt.set(e,t),Gt())}(mr,{title:wr.text||Oe,dirty:dr,copy:wr.copy,actions:Gr&&_r?_r:void 0,menu:gr.current??void 0})},[t,mr,Oe,dr,wr.text,wr.copy,Gr,_r]);const Jr=ee(e=>{const t=document.getElementById("nav-boundary-toast");t&&t.remove();const n="bottom"===e?["That's the last one, chief.","You've hit rock bottom... of the list.","End of the line, buddy.","Nothing left. Go outside.","Congratulations, you scrolled to the void.","There's no more. I checked.","You've reached the edge of the known universe.","Plot twist: there is no next one.","Even scrolling has limits. Unlike your ambition.","Last one. Time to touch grass."]:["Already at the top. Overachiever.","There is no item above this. Trust me.","You're #1. Literally.","Can't go higher. You've peaked.","This is it. The summit. The top.","First item. No VIP lounge above this.","Going up? Nope. Elevator's broken.","You want negative indexes? Bold.","Top of the list. Top of the world.","The only way is down from here."],r=n[Math.floor(Math.random()*n.length)],o=document.createElement("div");o.id="nav-boundary-toast",o.className="fixed bottom-6 left-1/2 -translate-x-1/2 z-(--z-toast) bg-gray-900 text-on-accent flex min-h-10 items-center px-5 py-3 rounded-lg shadow-lg text-sm font-medium transition-opacity duration-300",o.textContent=r,document.body.appendChild(o),setTimeout(()=>{o.style.opacity="0",setTimeout(()=>o.remove(),300)},2e3)},[]);if(J(()=>{if(!t)return;const e=e=>{if(N[N.length-1]!==jt)return;if(g(e.target,ct.current))return;const t=e.target.tagName;"INPUT"!==t&&"TEXTAREA"!==t&&"SELECT"!==t&&(e.target.isContentEditable||("j"===e.key&&Vr&&(e.preventDefault(),p?p():Jr("bottom")),"k"===e.key&&Vr&&(e.preventDefault(),f?f():Jr("top"))))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t,p,f,Vr,Jr,jt]),!t||gn.current)return null;const Zr=nn?function(e){if("undefined"==typeof document)return null;const t=Array.from(document.querySelectorAll("[data-modal-panel]")).filter(e=>{const t=e;return!t.hasAttribute("data-utility")&&!t.hasAttribute("data-widget")&&"none"!==t.style.display});t.sort((e,t)=>(e.getAttribute("data-modal-id")||"").localeCompare(t.getAttribute("data-modal-id")||""));const n=t.findIndex(t=>t.getAttribute("data-modal-id")===e),r=t.length;if(n<0||r<1)return null;const o=Math.ceil(Math.sqrt(r)),i=Math.ceil(r/o),a=Math.floor(n/o),s=n%o,l=r-o*(i-1),c=a===i-1&&l<o,u=ir(),d=(u.w-20*(o+1))/o,h=(u.h-14*(i+1)-22*i)/i,m=c?(o-l)*(d+20)/2:0;return{x:u.x+20+s*(d+20)+m,y:u.y+14+a*(h+14+22),w:d,h:h}}(jt):null,Qr=nn&&Zr?Math.min(Zr.w/kn.w,Zr.h/kn.h):1,eo=(()=>{if(nn&&Zr){const e=Qr,t=kn.w*e,n=kn.h*e,r=Zr.x+(Zr.w-t)/2-kn.x,o=Zr.y+(Zr.h-n)/2-kn.y,i=rn||ln;return{transform:`translate(${r}px, ${o}px) scale(${e})`,transformOrigin:"top left",transition:"transform 280ms cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 280ms",cursor:"pointer",zIndex:F.expose+(i?20:10),boxShadow:i?"0 24px 72px rgba(0,0,0,0.6), 0 0 0 2px rgba(255,255,255,0.55), 0 0 36px 12px rgba(96,165,250,0.85), 0 0 96px 28px rgba(96,165,250,0.55)":"0 16px 48px rgba(0,0,0,0.55)",pointerEvents:"auto"}}if(un&&Qt){const e="picked"===hn;return{transition:e?"transform 640ms cubic-bezier(0.34, 1.42, 0.64, 1), box-shadow 600ms":"transform 600ms cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 600ms",...e?{zIndex:F.expose+30}:{}}}return null})(),to=b({modal:!1,titleId:!B&&(Pn?!_e?.home:!xe)?je:void 0,label:wr.text||Oe}),no=/* @__PURE__ */ce("div",{children:[
49
- /* @__PURE__ */ce("div",{ref:ct,"data-modal-panel":!0,"data-modal-id":jt,"data-window-key":fe||void 0,...j?{"data-utility":""}:{},...He?{"data-pinned-top":""}:{},...B?{"data-widget":""}:{},..._e?{"data-window-owner":_e.key}:{},..._e&&!Ct?{"data-window-root":""}:{},...Pn?{"data-window-tab":""}:{},...to,className:Pn?"fixed flex flex-col overflow-hidden":"fixed rounded-(--radius-window) flex flex-col overflow-hidden "+(B?Bt?"shadow-xl":"shadow-lg":"border "+(Bt?"shadow-xl border-line":"shadow-lg border-line-strong")),onMouseDownCapture:e=>{if(ut.current=!1,nn){if(e.target.closest("[data-expose-close]"))return;return e.preventDefault(),e.stopPropagation(),$r(jt),Ar(!1),void er(jt)}if(!Bt&&!B&&!He&&0===e.button){const t=e.target;t.closest("[data-modal-panel]")===ct.current&&t.closest("button, input, a, select, textarea")&&!t.closest("[data-window-chrome]")&&(e.preventDefault(),e.stopPropagation(),ut.current=!0,Ye(null),er(jt),window.addEventListener("mouseup",()=>{setTimeout(()=>{ut.current=!1},0)},{once:!0}))}},onClickCapture:e=>{ut.current&&(ut.current=!1,e.preventDefault(),e.stopPropagation())},onMouseDown:e=>{if(nn)return;Ye(null);e.target.closest("[data-modal-panel]")===ct.current&&(e.target.closest("button, input, a, select, textarea")||er(jt))},style:xe?{zIndex:Ft+1,top:0,left:0,right:0,bottom:"var(--mobile-bottom-nav, 56px)",width:"auto",height:"auto",transform:`translateX(${Ce}px)`,transition:Ne?"none":"transform 180ms ease-out",...B?{display:"none"}:{},...Ft<0?{display:"none"}:{},...Bt||He||Ae&&fe===Ae?{}:{display:"none"}}:{zIndex:He?F.pinnedWindow:Ft+1,width:kn.w,height:kn.h,top:kn.y,...B&&"right"===at?{right:window.innerWidth-kn.x-kn.w}:{left:kn.x},...Ft<0&&!He?{display:"none"}:{},...ke?{display:"none"}:{},...Bn||Hn?{visibility:"hidden",pointerEvents:"none"}:{},...eo??{}},children:[xe&&!B&&/* @__PURE__ */ue("div",{onPointerDown:ze,className:"absolute top-0 bottom-0 left-0 w-[22px] z-[5]",style:{touchAction:"pan-y"},"aria-hidden":"true"}),B?null:Pn?_e?.home?null:/* @__PURE__ */ce(de,{children:[
50
- /* @__PURE__ */ue("h2",{id:je,"data-window-title":!0,className:"sr-only",children:wr.text||Oe}),Gr&&_r&&he(
51
- /* @__PURE__ */ue(de,{children:wr.actions}),_r),wr.badges.length>0&&/* @__PURE__ */ue("div",{"data-window-chrome":"","data-record-bar":"",className:"flex h-9 shrink-0 select-none items-center gap-2 overflow-hidden border-b border-gray-200 px-4",style:{backgroundColor:"rgb(var(--window-content-rgb))"},children:wr.badges})]}):xe?null:
47
+ /* @__PURE__ */ue("button",{onClick:t,onFocus:c,onBlur:u,title:e?o.windowed:o.maximize,className:r,children:e?"❐":"⤢"}),i&&/* @__PURE__ */ue("div",{role:"group","aria-label":o.snapLayouts,onMouseEnter:()=>clearTimeout(l.current),onMouseLeave:u,className:"absolute right-0 top-full z-30 mt-1 grid w-max grid-cols-2 gap-1 rounded-lg border border-line bg-surface p-2 shadow-lg",children:wr.map(({zone:e,labelKey:t,region:r})=>/* @__PURE__ */ue("button",{type:"button","aria-label":o[t],title:o[t],onClick:()=>{a(!1),n(e)},onFocus:()=>clearTimeout(l.current),onBlur:u,className:"relative h-7 w-11 rounded border border-gray-300 bg-gray-50 hover:border-blue-400 focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-400",children:/* @__PURE__ */ue("span",{"aria-hidden":"true",className:`absolute rounded-sm bg-blue-500/70 ${r}`,style:{margin:2}})},e))})]})}var vr="rosh-gesture-style";var xr={se:"nwse-resize",nw:"nwse-resize",sw:"nesw-resize",ne:"nesw-resize",n:"ns-resize",s:"ns-resize",e:"ew-resize",w:"ew-resize"},kr=4;function Er(e,t,n,r){!function(){if("undefined"==typeof document||document.getElementById(vr))return;const e=document.createElement("style");e.id=vr,e.textContent="body.rosh-gesturing [data-modal-panel]{will-change:transform}",document.head.appendChild(e)}();try{e.setPointerCapture(t)}catch{}document.body.classList.add("rosh-gesturing");const o=document.createElement("div");o.setAttribute("data-drag-shield",""),o.style.cssText=`position:fixed;inset:0;z-index:2147483647;cursor:${n};background:transparent;touch-action:none`,document.body.appendChild(o);const i=Ot(r);let a=!1;return()=>{if(!a){a=!0,i();try{e.releasePointerCapture(t)}catch{}o.remove(),document.body.classList.remove("rosh-gesturing")}}}function Cr(e){const t=k.indexOf(e);if(-1===t)return-1;const n=F.window+t*F.windowStep,r=jn.get(e);if(!r||r.root)return n;let o=-1;for(const[e,t]of jn){if(!t.root||t.owner!==r.owner)continue;const n=k.indexOf(e);-1!==n&&(o=Math.max(o,F.window+n*F.windowStep))}return o>=n?o+2+Math.min(t,7):n}"undefined"!=typeof window&&window.addEventListener("deactivate-all-modals",function(){for(let e=k.length-1;e>=0;e--)nr.has(k[e])||k.splice(e,1);xn=xn.filter(e=>{const t=$n.get(e);return null!=t&&nr.has(t)}),En(),Kn(),window.dispatchEvent(new CustomEvent("modal-reorder"))});var Mr="modal-close-request";function Nr(e){Q(M,Wn);const t=Y(C);if(k.length<=1)return!0;if(e){const t=$n.get(e);if(null!=t)return N()===t}return t?.active??null!=N()}var Sr=!1,Lr=/* @__PURE__ */new Set;function Tr(e){return Lr.add(e),()=>Lr.delete(e)}function zr(){return Sr}function Ar(e){Sr!==e&&(Sr=e,Lr.forEach(e=>e()))}function Dr(){Ar(!Sr)}function Pr(){Ar(!1)}var Ir=null,Rr=/* @__PURE__ */new Set;function Wr(e){return Rr.add(e),()=>Rr.delete(e)}function Kr(){return Ir}function $r(e){Ir!==e&&(Ir=e,Rr.forEach(e=>e()))}var Or=null,jr=/* @__PURE__ */new Set;function Fr(e){return jr.add(e),()=>jr.delete(e)}function qr(){return Or}function Br(e){Or!==e&&(Or=e,jr.forEach(e=>e()))}function Hr(){if(!Or)return void Ar(!1);$r(Or),Br(null),Ar(!1)}function Ur(){Ar(!Sr),window.dispatchEvent(new CustomEvent("modal-split-view"))}function Xr(){const e=Q(Tr,zr),[t,n]=Z(e),[r,o]=Z(e);return _(()=>{if(e){n(!0);const e=requestAnimationFrame(()=>o(!0));return()=>cancelAnimationFrame(e)}o(!1);const t=setTimeout(()=>n(!1),280);return()=>clearTimeout(t)},[e]),t&&"undefined"!=typeof document?he(
48
+ /* @__PURE__ */ue("div",{onMouseDown:e=>{e.stopPropagation(),Ar(!1)},style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.55)",backdropFilter:"blur(2px)",WebkitBackdropFilter:"blur(2px)",zIndex:F.expose,cursor:"pointer",opacity:r?1:0,transition:"opacity 260ms cubic-bezier(0.2, 0.8, 0.2, 1)",pointerEvents:r?"auto":"none"}}),document.body):null}function Yr({open:t,onClose:l,title:c,icon:u,copyText:d,size:h="lg",dirty:m=!1,onNext:p,onPrev:f,footer:y,bodyScroll:v,onMinimize:x,initialBox:E,actions:L,actionsLeft:D,editing:P=!1,edit:K,allowPinOnTop:j,initialPosition:q,widget:B,compact:X,appStyle:V,flushBody:ne,autoHeight:re,autoMinHeight:se,autoWidth:le,widgetMenu:me,dimensions:pe,windowKey:fe,openedFromKey:we,accentRgb:ye,children:ge}){const[be,ve]=Z(()=>r()),xe=T()&&!be,ke=z()&&!!B,[Ce,Me]=Z(0),[Ne,Se]=Z(!1),Le=G(null),Te=G(0);_(()=>{Te.current=Ce},[Ce]);const ze=ee(e=>{xe&&(Le.current={startX:e.clientX,startY:e.clientY,pointerId:e.pointerId},Se(!0),Dt(we??null))},[xe,we]),Ae=Q(Pt,At);_(()=>{if(!Ne)return;const e=e=>{if(!Le.current)return;const t=e.clientX-Le.current.startX;if(Math.abs(e.clientY-Le.current.startY)>Math.abs(t)+12)return Le.current=null,Se(!1),Me(0),void Dt(null);Me(Math.max(0,t))},t=()=>{if(!Le.current)return;const e=.3*window.innerWidth,t=Te.current>e;Le.current=null,Se(!1),t?(Me(window.innerWidth),setTimeout(()=>{l(),Me(0),Dt(null)},180)):(Me(0),Dt(null))};return window.addEventListener("pointermove",e),window.addEventListener("pointerup",t),window.addEventListener("pointercancel",t),()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",t),window.removeEventListener("pointercancel",t)}},[Ne]);const[De,Re]=Z(c),Ke=U(),$e=Ke.window;_(()=>{Re(c)},[c]);const Oe=ie(()=>an(De).trim()||void 0,[De]),je=ae(),[Fe,qe]=Z(!1),Be=G(!1),[He,Ue]=Z(!1),[Xe,Ye]=Z(null),Ve=Y(tn),Je=Y(Ee),{prefs:Ge,save:_e}=A(),Ze=!!Ge.window_accent_stripe,Qe=Ge.favorite_documents||[],tt=!!Ve&&Qe.some(e=>e.entityType===Ve.entityType&&e.entityId===Ve.entityId),rt=ee(()=>{if(!Ve)return;const e=tt?Qe.filter(e=>!(e.entityType===Ve.entityType&&e.entityId===Ve.entityId)):[...Qe,{entityType:Ve.entityType,entityId:Ve.entityId,label:Ve.label}];_e({favorite_documents:e})},[Ve,tt,Qe,_e]),[ot,it]=Z(null),[at,st]=Z("top-right"===q?"right":"left"),lt=G(!1),ct=G(null);J(()=>{const e=ct.current;e&&(ye?e.style.setProperty("--window-accent-rgb",ye):e.style.removeProperty("--window-accent-rgb"))},[ye]);const ut=G(!1),dt=G(null),ht=G(null),mt=G(null),[pt,ft]=Z(!1),wt=G(null),yt=G(null),gt=G(null),[bt,vt]=Z(!1);J(()=>{const e=yt.current,t=gt.current;if(!e||!t)return;const n=()=>vt(function(e,t){return e.scrollWidth>t.clientWidth}(t,e));if(n(),"undefined"==typeof ResizeObserver)return;const r=new ResizeObserver(n);return r.observe(e),r.observe(t),()=>r.disconnect()},[null!=y&&!1!==y]);const xt=!!K&&!B&&!X&&!V&&(K.editing||"hidden"!==K.state),kt=!!(y||L||D)||pt||xt,Et=Y(Ie),Ct=""!==Y(en),Mt=G(null);Mt.current=Je?{owner:Je.key,tab:Je.tab,root:!Ct}:null;const Nt=fe||(Je&&!Ct?Je.key:null),St=!!Et&&!Ct&&Et.enabled&&Et.hasState&&(P||Et.declaredEditable)&&!Et.handMounted&&kt&&!B&&!X&&!V&&!xe,Tt=/* @__PURE__ */ue(O,{name:"window",className:"h-4 w-4",strokeWidth:1.5}),zt=u&&te(u)?oe(u,{className:`h-4 w-4 ${u.props?.className??""}`.trim()}):u??Tt,It=()=>/* @__PURE__ */ue("button",{onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation();const t=e.currentTarget.getBoundingClientRect();Ye(e=>e?null:{x:t.left,y:t.bottom+4})},className:"shrink-0 p-0.5 rounded hover:bg-gray-200/50 transition-colors",title:"Window menu",children:zt}),Rt=40,{minimize:Wt,items:Kt,restoreIfMinimized:$t,openWindows:Ot}=nt(),jt=G(`modal-${Math.random().toString(36).slice(2,8)}`).current;_(()=>{if(B)return nr.add(jt),()=>{nr.delete(jt)}},[B,jt]),_(()=>{const e=e=>{const t=e.detail;t?.id===jt&&Re(t.title)};return window.addEventListener("window-title-update",e),()=>window.removeEventListener("window-title-update",e)},[jt]);const[Ft,qt]=Z(F.window),Bt=function(e){const t=Q(M,N);return k.length<=1||t===e}(jt),Ht=G(K);Ht.current=K;const Xt=!!K&&!K.editing&&"enabled"===K.state;_(()=>{if(!t||!Bt||!Xt)return;const e=e=>{("KeyE"===e.code||"E"===e.key||"e"===e.key)&&e.altKey&&e.shiftKey&&!e.metaKey&&!e.ctrlKey&&(g(e.target,ct.current)||(e.preventDefault(),e.stopPropagation(),Ht.current?.onEdit()))};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[t,Bt,Xt]);const Vt=function(e){return Q(M,()=>Dn.has(e))}(jt);Lt({panelRef:ct,bodyRef:dt,open:t,widget:!!B,active:Bt,minimized:Vt});const Jt=Q(Tr,zr),_t=Q(Wr,Kr),Zt=Q(Fr,qr),Qt=!j&&!B,nn=Jt&&Qt,[rn,sn]=Z(!1),ln=nn&&Zt===jt,[un,dn]=Z(!1),hn=un&&Qt&&_t===jt?"picked":null,mn=G(nn);_(()=>{if(mn.current&&!nn){dn(!0);const e=setTimeout(()=>{dn(!1),Ir===jt&&$r(null)},700);return mn.current=nn,()=>clearTimeout(e)}mn.current=nn},[nn,jt]),_(()=>{nn||sn(!1)},[nn]),_(()=>{const e=ht.current,t=mt.current;if(!e&&!t)return;const n=e=>e?Array.from(e.children).filter(e=>"shell"!==e.dataset.undoControls).length:0,r=()=>ft(n(e)+n(t)>0);r();const o=new MutationObserver(r);return e&&o.observe(e,{childList:!0}),t&&o.observe(t,{childList:!0}),()=>o.disconnect()},[t]),_(()=>{const e=e=>{if(e.target.closest('button[type="submit"]')&&ct.current){const t=ct.current.querySelector("form");t&&(e.preventDefault(),t.requestSubmit())}},t=ht.current,n=mt.current;return t&&t.addEventListener("click",e),n&&n.addEventListener("click",e),()=>{t&&t.removeEventListener("click",e),n&&n.removeEventListener("click",e)}},[t]);const pn=G(!1),fn=ee(e,[]),wn=ee(()=>{const t=e(),n=pe?pe[0]:Ln[h]||672,o=t.w-80,i=t.h-80,a=Math.min(n,o),s=An[zn()],l=pe?Math.min(pe[1],i):(()=>{const e=("sm"===h?500:"md"===h?600:"lg"===h?700:"xl"===h?800:920)*s;return Math.max(320,Math.min(e,t.h-80))})(),c="cascade"!==(getComputedStyle(document.documentElement).getPropertyValue("--window-position")?.trim()||"cascade")||r()?0:30*(k.length-1),u=Math.max(Rt,(i-l)/2),d=(o-a)/2,m=t.h-Rt-l-u;return"top-right"===q?{x:t.x+t.w-a-Rt,y:t.y+Rt,w:a,h:l}:"top-left"===q?{x:t.x+Rt,y:t.y+Rt,w:a,h:l}:{x:t.x+Math.max(Rt,(o-a)/2+Rt)+Math.min(c,Math.max(0,d)),y:t.y+u+Math.min(c,Math.max(0,m)),w:a,h:l}},[h]),gn=G(!1);t||(gn.current=!1);const vn=fe||d||null;_(()=>{if(!t)return;_n(jt,vn,Mt.current??void 0),fe||er(jt),pn.current=!1,qt(Cr(jt));const e=()=>{qt(Cr(jt))},n=()=>{},r=e=>{if(!e)return!1;if(e.windowKey)return e.windowKey===fe;if(!e.label)return!1;const t=ct.current?.querySelector("[data-window-title]");return!!t?.textContent?.includes(e.label)},o=e=>{if(!r(e.detail))return;if(er(jt),Wn.current)return;const t=ir(),n=Math.min(Vn.current.w,t.w-40),o=Math.min(Vn.current.h,t.h-40),i=t.x+(t.w-n)/2,a=t.y+(t.h-o)/2;En({x:i,y:a,w:n,h:o}),Xn(!1)},i=e=>{const t=e.detail;r(t)&&(er(jt),Ye({x:t.x,y:t.y}))},a=e=>{if(e.detail?.windowKey!==fe)return;er(jt);const t=Vn.current,n=function(e,t=ir()){const n=Math.min(e.w,t.w),r=Math.min(e.h,t.h);return{w:n,h:r,x:Math.min(Math.max(e.x,t.x),t.x+t.w-n),y:Math.min(Math.max(e.y,t.y),t.y+t.h-r)}}(t);if(n.x===t.x&&n.y===t.y&&n.w===t.w&&n.h===t.h)return;const r=ct.current,o="function"==typeof window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;if(r&&!o){let e=!1;const t=()=>{e||(e=!0,r.style.transition="",window.dispatchEvent(new CustomEvent("modal-geometry")))};r.style.transition="left .28s ease, top .28s ease, width .28s ease, height .28s ease",r.addEventListener("transitionend",t,{once:!0}),window.setTimeout(t,400)}En(n)};return window.addEventListener("modal-reorder",e),window.addEventListener("modal-split-view",n),window.addEventListener("modal-center",o),window.addEventListener("modal-reveal",a),window.addEventListener("modal-context-menu",i),()=>{!function(e){const t=k.indexOf(e);-1!==t&&(k.splice(t,1),Kn()),Dn.delete(e),In.delete(e),jn.delete(e);const n=On.get(e);n&&(On.delete(e),$n.delete(n))}(jt),window.removeEventListener("modal-reorder",e),window.removeEventListener("modal-split-view",n),window.removeEventListener("modal-center",o),window.removeEventListener("modal-reveal",a),window.removeEventListener("modal-context-menu",i),window.dispatchEvent(new CustomEvent("modal-reorder"))}},[t,jt,vn,fn]);const xn=!B&&"maximized"===zn(),[kn,En]=Z(()=>{if(vn&&yn[vn]){const e={...yn[vn]};return pe&&(e.w=pe[0],re||(e.h=pe[1])),ur(e)}return E?{x:E.x,y:E.y,w:E.w,h:E.h}:xn?fn():wn()}),[Cn,Mn]=Z(()=>!re),Nn=G(be),Sn=G(null);_(()=>{const e=()=>{const e=r();e!==Nn.current&&Sn.current?.(e),Nn.current=e,ve(e),qt(Cr(jt))};return window.addEventListener("react-os-shell:layout-mode-changed",e),()=>window.removeEventListener("react-os-shell:layout-mode-changed",e)},[jt]);const Pn=be&&!!Je?.tab&&!Ct&&!B&&!xe,Rn=Pn,Wn=G(Rn);Wn.current=Rn;const Fn=qn(),Bn=be&&!!Je?.tab&&!B&&!xe&&!Jt&&Fn!==Je.key,Hn=!!B&&be&&!Jt&&null!==Fn,[Un,Xn]=Z(()=>vn&&yn[vn]||E?Rn:Rn||xn),Vn=G(kn);Vn.current=kn;const Jn=G(Un);J(()=>{Jn.current=Un},[Un]),J(()=>{if(Cn||Pn)return;const e=ct.current,t=dt.current;if(!e||!t)return;const n=se??(B?0:240),r=parseInt(getComputedStyle(document.documentElement).getPropertyValue("--taskbar-height"))||0;let o=0,i=null,a=null;const s=()=>{const c=t.firstElementChild;if(!c||e.offsetHeight<=0)return;c!==a&&(a&&l.unobserve(a),l.observe(c),a=c);const u=e.offsetHeight-t.offsetHeight,d=t.style.flex,h=t.style.overflowY,m=t.style.height;t.style.flex="0 0 auto",t.style.height="auto",t.style.overflowY="visible";const p=t.offsetHeight,f=c.offsetHeight;t.style.flex=d,t.style.height=m,t.style.overflowY=h;const w=c.offsetHeight>f+4,y=Math.max(n,window.innerHeight-r-Math.max(0,Vn.current.y)-24),g=w?Math.min(Vn.current.h,y):Math.min(Math.max(n,u+p),y),b=Math.abs(g-o)>1;b&&(o=g,En(e=>Math.abs(e.h-g)>1?{...e,h:g}:e)),B||(g<=n?i&&(clearTimeout(i),i=null):(b||null===i)&&(i&&clearTimeout(i),i=setTimeout(()=>{const e=o;s(),o===e&&Mn(!0)},160)))},l=new ResizeObserver(s);s(),wt.current&&l.observe(wt.current);const c=new MutationObserver(s);return c.observe(t,{childList:!0,subtree:!0,characterData:!0}),()=>{l.disconnect(),c.disconnect(),i&&clearTimeout(i)}},[Cn,B,se,kt,Pn]),J(()=>{if(!re||!Cn||B||!t)return;const e=wt.current;if(!e)return;let n=e.offsetHeight;const r=new ResizeObserver(()=>{if(!e.isConnected)return;const t=e.offsetHeight,r=t-n,o=t>0!=n>0;if(n=t,!o||0===r||Un)return;if(document.body.classList.contains("rosh-gesturing"))return;const i=se??240,a=parseInt(getComputedStyle(document.documentElement).getPropertyValue("--taskbar-height"))||0,s=Math.max(i,window.innerHeight-a-Math.max(0,Vn.current.y)-24);En(e=>({...e,h:Math.min(Math.max(i,e.h+r),s)}))});return r.observe(e),()=>r.disconnect()},[re,Cn,B,t,Un,se]);const Gn=!1!==le&&!B&&!V&&!xe,[Zn,Qn]=Z(()=>!Gn);J(()=>{if(Zn||!t)return;if(!Gn||Un)return void Qn(!0);const n=ct.current,r=dt.current;if(!n||!r)return;const o=/* @__PURE__ */new WeakSet;let l=Vn.current.w,c=0;const u=()=>Qn(!0),d=()=>{c=0;const t=Vn.current;if(Math.abs(t.w-l)>1||document.body.classList.contains("rosh-gesturing"))return void u();const d=e(),h=d.w-80;if(t.w>=h)return void u();const m=[],p=[];for(const e of[r,...Array.from(r.querySelectorAll("*"))]){const t=e.scrollWidth-e.clientWidth;if(t<=4||o.has(e))continue;const n=getComputedStyle(e).overflowX;"auto"!==n&&"scroll"!==n||(m.push(e),p.push(t))}if(!m.length)return;const f=Math.min(h,t.w+Math.max(...p)),w=f-t.w,y=n.style.width;n.style.width=`${f}px`;const g=m.map((e,t)=>({over:p[t],residual:e.scrollWidth-e.clientWidth}));n.style.width=y,g.forEach((e,t)=>{i(e,w)||o.add(m[t])});const b=a(t,s(t.w,w,g),d,Rt);b!==t&&(l=b.w,En(b))};d();const h=new MutationObserver(()=>{c||(c=requestAnimationFrame(d))});h.observe(r,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["style","class","hidden"]});const m=setTimeout(u,Tn);return()=>{h.disconnect(),c&&cancelAnimationFrame(c),clearTimeout(m)}},[Zn,t,Gn,Un]);const ar=G(null),sr=!(!Je?.tab||Ct||B||xe);Sn.current=t=>{if(!sr)return;if(t)return ar.current||(ar.current={box:{...Vn.current},maximized:Jn.current}),void(Jn.current=!0);const r=ar.current;ar.current=null;const o=e();if(r?.maximized)return Jn.current=!0,Xn(!0),void En(o);const i=r?.box??(vn?yn[vn]:void 0);if(Jn.current=!1,Xn(!1),i&&!n(i,o,!1)){const e={...i};pe&&(e.w=pe[0],re||(e.h=pe[1])),En(ur(e))}else En(wn())},_(()=>{Rn&&(Jn.current=!0,Xn(!0),En(fn()))},[Rn,fn]),_(()=>{if(B)return;const e=()=>{const e=vn?yn[vn]:void 0;if(Jn.current=!1,Xn(!1),e){const t={...e};pe&&(t.w=pe[0],re||(t.h=pe[1])),En(ur(t))}else En(wn())};return window.addEventListener("react-os-shell:restore-windowed",e),()=>window.removeEventListener("react-os-shell:restore-windowed",e)},[B,wn,vn]),_(()=>{t&&vn&&!Pn&&(yn[vn]=kn,bn()),t&&window.dispatchEvent(new CustomEvent("modal-geometry"))},[kn,t,vn,Pn]),_(()=>{if(!t)return;const e=()=>{Jn.current?En(fn()):document.body.classList.contains("rosh-gesturing")||En(ur)};window.addEventListener("resize",e),window.addEventListener(o,e);let n=null;return Un&&(n=new MutationObserver(e),n.observe(document.body,{childList:!0,subtree:!1,attributes:!0,attributeFilter:["class"]})),()=>{window.removeEventListener("resize",e),window.removeEventListener(o,e),n?.disconnect()}},[t,Un,fn]),_(()=>{if(t&&(qe(!1),Be.current=!1,lt.current=!1,Qn(!Gn),!Wn.current)){if(vn&&yn[vn]){const e=yn[vn];return void En(t=>ur({...e,...re?{h:t.h}:{},...Gn?{x:t.x,w:t.w}:{}}))}E&&(En({x:E.x,y:E.y,w:E.w,h:E.h}),Xn(E.maximized))}},[t]),_(()=>{if(!t||"auto"!==m)return;let e;const n=t=>{ct.current?.contains(t.target)&&!Be.current&&(Be.current=!0,e=setTimeout(()=>qe(!0),0))};return document.addEventListener("input",n,!0),document.addEventListener("change",n,!0),()=>{clearTimeout(e),document.removeEventListener("input",n,!0),document.removeEventListener("change",n,!0)}},[t,m]);const dr="auto"===m?Fe:!0===m,mr=Je&&!Ct?Je.key:null,wr=ie(()=>Ut(De),[De]),yr=G({shortcutSpec:Ve,isOnDesktop:tt,toggleDesktopShortcut:rt,taskbarStrings:Ke.taskbar});J(()=>{yr.current={shortcutSpec:Ve,isOnDesktop:tt,toggleDesktopShortcut:rt,taskbarStrings:Ke.taskbar}});const gr=G(null);gr.current||(gr.current={open:(e,t)=>Ye({x:e,y:t}),items:()=>{const e=yr.current,t=[];e.shortcutSpec&&t.push({label:e.isOnDesktop?e.taskbarStrings.removeFromDesktop:e.taskbarStrings.addToDesktop,onSelect:e.toggleDesktopShortcut});for(const e of cn[jt]||[])t.push({label:e.label,icon:e.icon,onSelect:e.onClick});return t}}),_(()=>{if(t&&mr)return()=>{return e=mr,void(Yt.delete(e)&&Gt());var e}},[t,mr]),et(!(fe||!t)&&dr);const vr=ee(()=>dr||"auto"===m&&Be.current,[dr,m]),Nr=ee(async e=>{if(lt.current)return!1;if(!vr())return!0;lt.current=!0;const t=Oe,n="close"===e?"Are you sure you want to close?":"discard"===e?"Are you sure you want to stop editing?":"Are you sure you want to continue?",r=await w({title:"Discard changes?",message:t?`“${t}” has unsaved changes. ${n} All changes will be lost.`:`You have unsaved changes. ${n} All changes will be lost.`,confirmLabel:"Discard",cancelLabel:"Keep Editing",variant:"warning"});return lt.current=!1,r},[vr,Oe]),Sr=ee(()=>lt.current?Promise.resolve():vr()?Nr("close").then(e=>{e&&l()}):(l(),Promise.resolve()),[vr,Nr,l]),Lr=ee(async()=>{await Nr("discard")&&(Be.current=!1,qe(!1),Ht.current?.onDiscard())},[Nr]),Dr=ee(async()=>{const e=await Nr("switch");return e&&(Be.current=!1,qe(!1)),e},[Nr]),Pr=G(()=>!1);J(()=>{Pr.current=vr}),J(()=>{if(!t||!fe)return;const e={holdsChanges:()=>Pr.current(),ask:Dr};return Yn.set(fe,e),()=>{Yn.get(fe)===e&&Yn.delete(fe)}},[t,fe,Dr]),J(()=>{if(!t||!Nt)return;const e=e=>{e.detail?.windowKey===Nt&&Sr()};return window.addEventListener(Mr,e),()=>window.removeEventListener(Mr,e)},[t,Nt,Sr]);const Rr=G(null),Or=ee(e=>{if(0!==e.button)return;if(e.target.closest("button, input, a, kbd, select, textarea"))return;if(Ye(null),er(jt),Wn.current)return void e.preventDefault();e.preventDefault();const t=e.currentTarget,n=e.pointerId;let r=null;const o=e.clientX,i=e.clientY,a=ct.current,s=a?.getBoundingClientRect();let l,c,u,d;if(Rr.current){const t=Rr.current;Rr.current=null,d=t.w,u=t.h;const n=s?Math.min(Math.max(20,e.clientX-s.left),t.w-20):t.w/2;l=e.clientX-n,c=e.clientY-12,a&&(a.style.width=`${d}px`,a.style.height=`${u}px`,a.style.left=`${l}px`,a.style.top=`${c}px`)}else l=s?s.left:Vn.current.x,c=s?s.top:Vn.current.y,u=s?s.height:Vn.current.h,d=s?s.width:Vn.current.w;Xn(!1),En(e=>({...e,x:l,y:c,w:d,h:u}));let h=null;const m=e=>{if(!r){if(Math.abs(e.clientX-o)<kr&&Math.abs(e.clientY-i)<kr)return;r=Er(t,n,"move","move"),a&&(a.style.transition="none")}const s=l+e.clientX-o,u=Math.max(0,c+e.clientY-i);if(a&&(a.style.transform=`translate(${s-l}px, ${u-c}px)`),Vn.current={...Vn.current,x:s,y:u},!B){const t=function(e,t){const n=ir(),r=e<=n.x+rr,o=e>=n.x+n.w-rr,i=t<=n.y+rr,a=t>=n.y+n.h-rr,s=e<=n.x+or,l=e>=n.x+n.w-or,c=t<=n.y+or,u=t>=n.y+n.h-or;return i&&s?"tl":i&&l?"tr":a&&s?"bl":a&&l?"br":c&&r?"tl":c&&o?"tr":u&&r?"bl":u&&o?"br":i?"top":r?"left":o?"right":null}(e.clientX,e.clientY);t!==h&&(h=t,t?pr(hr(t)):fr())}},p=()=>{window.removeEventListener("pointermove",m),window.removeEventListener("pointerup",p),r?.(),fr();const e=ur({...Vn.current});if(Vn.current=e,!B&&h){Rr.current={x:l,y:c,w:d,h:u};const e=hr(h);return a&&(a.style.left=`${e.x}px`,a.style.top=`${e.y}px`,a.style.width=`${e.w}px`,a.style.height=`${e.h}px`,a.style.transform="",a.style.transition=""),void En(e)}if(B){const t=e.x+e.w/2,n=window.innerWidth/2;st(t>n?"right":"left")}a&&(a.style.left=`${e.x}px`,a.style.top=`${e.y}px`,a.style.transform="",a.style.transition=""),En(e)};window.addEventListener("pointermove",m),window.addEventListener("pointerup",p)},[]),jr=ee((e,t)=>{if(0!==e.button)return;e.preventDefault(),e.stopPropagation();const n=e.currentTarget,r=e.pointerId;let o=null;const i=e.clientX,a=e.clientY,s=ct.current,l=s?.getBoundingClientRect(),c=l?l.left:Vn.current.x,u=l?l.top:Vn.current.y,d=l?l.width:Vn.current.w,h=l?l.height:Vn.current.h,m="sw"===t||"nw"===t||"w"===t,p="ne"===t||"nw"===t||"n"===t,f="se"===t||"ne"===t||"e"===t,w="se"===t||"sw"===t||"s"===t;Xn(!1),En({x:c,y:u,w:d,h:h}),Vn.current={x:c,y:u,w:d,h:h};let y=0,g=null;const b=()=>{if(y=0,!g)return;const e=g;g=null,Vn.current=e,s&&(s.style.left=`${e.x}px`,s.style.top=`${e.y}px`,s.style.width=`${e.w}px`,s.style.height=`${e.h}px`)},v=e=>{if(!o){if(Math.abs(e.clientX-i)<kr&&Math.abs(e.clientY-a)<kr)return;o=Er(n,r,xr[t],"resize")}g=((e,t)=>{let n=c,r=u,o=d,i=h;if(f&&(o=Math.max(lr,d+e)),w&&(i=Math.max(cr,h+t)),m){const t=Math.max(lr,d-e);n=c+d-t,o=t}if(p){const e=Math.max(cr,h-t);r=u+h-e,i=e}return{x:n,y:r,w:o,h:i}})(e.clientX-i,e.clientY-a),y||(y=requestAnimationFrame(b))},x=()=>{window.removeEventListener("pointermove",v),window.removeEventListener("pointerup",x),y&&cancelAnimationFrame(y),b(),o?.(),En({...Vn.current})};window.addEventListener("pointermove",v),window.addEventListener("pointerup",x)},[]),Br=ee(e=>{if(e.target.closest("button, input, a, kbd, select, textarea"))return;const t={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]}[e.key];if(!t&&"Enter"!==e.key)return;if(e.preventDefault(),e.stopPropagation(),er(jt),"Enter"===e.key)return void(Un?(Xn(!1),En(wn())):(Xn(!0),En(fn())));const[n,r]=t;if(e.ctrlKey||e.metaKey){const e=()=>{Rr.current||(Rr.current={...Vn.current})};if(r<0)return e(),Xn(!0),void En(fn());if(r>0){if(Un)return Xn(!1),void En(wn());if(Rr.current){const e=ur(Rr.current);return Rr.current=null,Vn.current=e,void En(e)}return void tr(jt)}e(),Xn(!1);const t=hr(n<0?"left":"right");return Vn.current=t,void En(t)}if(Un)return;const o=Vn.current,i=e.shiftKey?{...o,w:Math.max(lr,o.w+24*n),h:Math.max(cr,o.h+24*r)}:ur({...o,x:o.x+24*n,y:Math.max(0,o.y+24*r)});Vn.current=i,En(i)},[jt,Un,wn,fn]),Hr=ee(e=>{Rr.current||(Rr.current={...Vn.current}),Xn(!1);const t=hr(e);Vn.current=t,En(t),er(jt)},[jt]),Ur=Rn||nn?{}:{tabIndex:0,role:"group","aria-label":Oe?`${Oe} — ${$e.windowSuffix}`:$e.windowSuffix,"aria-keyshortcuts":"ArrowUp ArrowDown ArrowLeft ArrowRight Shift+ArrowUp Shift+ArrowDown Shift+ArrowLeft Shift+ArrowRight Control+ArrowUp Control+ArrowDown Control+ArrowLeft Control+ArrowRight Enter",onKeyDown:Br},Xr=()=>{Xn(!0),En(fn())},Yr=ee(()=>{const e=ct.current;if(!e)return;const t=e.querySelector("form");if(t)t.requestSubmit();else{const t=e.querySelector(on);t&&!t.disabled&&t.click()}},[]);_(()=>{if(!t)return;if(B)return;const e=e=>{if(k[k.length-1]===jt&&!g(e.target,ct.current)&&"Enter"===e.key){const t=e.target;if("TEXTAREA"===t.tagName||t.isContentEditable)return;if(e.metaKey||e.ctrlKey)e.preventDefault(),Yr();else{if("INPUT"===t.tagName&&t.closest("form"))return;if(!(t instanceof Element&&ct.current?.contains(t)))return;if(t.closest(S))return;e.preventDefault()}}};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[t,Yr,jt,B]),_(()=>{if(!t)return;const e=e=>{k[k.length-1]===jt&&(g(e.target,ct.current)||((e.metaKey||e.ctrlKey)&&"s"===e.key?(e.preventDefault(),document.dispatchEvent(new CustomEvent("modal-save",{detail:{modalId:jt}})),Be.current=!1,qe(!1)):e.altKey&&e.shiftKey&&("KeyD"===e.code||"D"===e.key||"d"===e.key)&&(e.preventDefault(),document.dispatchEvent(new CustomEvent("modal-duplicate",{detail:{modalId:jt}})))))};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[t]),_(()=>{if(!t)return;if(B)return;const e=e=>{if("Escape"===e.key&&k[k.length-1]===jt){if(H(e))return e.preventDefault(),void e.stopPropagation();if(Pn&&!P)return;e.preventDefault(),e.stopPropagation(),Sr()}};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[t,Sr,jt,B,Pn,P]);const Vr=t&&(void 0!==p||void 0!==f),[Jr]=Z(()=>{if("undefined"==typeof document)return null;const e=document.createElement("span");return e.className="flex shrink-0 items-center gap-2",e.setAttribute("data-tab-actions",""),e}),Gr=Pn&&!Je?.home&&wr.actions.length>0;_(()=>{t&&mr&&function(e,t){const n=Yt.get(e);n&&n.title===t.title&&n.dirty===t.dirty&&n.copy===t.copy&&n.actions===t.actions&&n.menu===t.menu||(Yt.set(e,t),Gt())}(mr,{title:wr.text||Oe,dirty:dr,copy:wr.copy,actions:Gr&&Jr?Jr:void 0,menu:gr.current??void 0})},[t,mr,Oe,dr,wr.text,wr.copy,Gr,Jr]);const _r=ee(e=>{const t=document.getElementById("nav-boundary-toast");t&&t.remove();const n="bottom"===e?["That's the last one, chief.","You've hit rock bottom... of the list.","End of the line, buddy.","Nothing left. Go outside.","Congratulations, you scrolled to the void.","There's no more. I checked.","You've reached the edge of the known universe.","Plot twist: there is no next one.","Even scrolling has limits. Unlike your ambition.","Last one. Time to touch grass."]:["Already at the top. Overachiever.","There is no item above this. Trust me.","You're #1. Literally.","Can't go higher. You've peaked.","This is it. The summit. The top.","First item. No VIP lounge above this.","Going up? Nope. Elevator's broken.","You want negative indexes? Bold.","Top of the list. Top of the world.","The only way is down from here."],r=n[Math.floor(Math.random()*n.length)],o=document.createElement("div");o.id="nav-boundary-toast",o.className="fixed bottom-6 left-1/2 -translate-x-1/2 z-(--z-toast) bg-gray-900 text-on-accent flex min-h-10 items-center px-5 py-3 rounded-lg shadow-lg text-sm font-medium transition-opacity duration-300",o.textContent=r,document.body.appendChild(o),setTimeout(()=>{o.style.opacity="0",setTimeout(()=>o.remove(),300)},2e3)},[]);if(_(()=>{if(!t)return;const e=e=>{if(k[k.length-1]!==jt)return;if(g(e.target,ct.current))return;const t=e.target.tagName;"INPUT"!==t&&"TEXTAREA"!==t&&"SELECT"!==t&&(e.target.isContentEditable||("j"===e.key&&Vr&&(e.preventDefault(),p?p():_r("bottom")),"k"===e.key&&Vr&&(e.preventDefault(),f?f():_r("top"))))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t,p,f,Vr,_r,jt]),!t||gn.current)return null;const Zr=nn?function(e){if("undefined"==typeof document)return null;const t=Array.from(document.querySelectorAll("[data-modal-panel]")).filter(e=>{const t=e;return!t.hasAttribute("data-utility")&&!t.hasAttribute("data-widget")&&"none"!==t.style.display});t.sort((e,t)=>(e.getAttribute("data-modal-id")||"").localeCompare(t.getAttribute("data-modal-id")||""));const n=t.findIndex(t=>t.getAttribute("data-modal-id")===e),r=t.length;if(n<0||r<1)return null;const o=Math.ceil(Math.sqrt(r)),i=Math.ceil(r/o),a=Math.floor(n/o),s=n%o,l=r-o*(i-1),c=a===i-1&&l<o,u=ir(),d=(u.w-20*(o+1))/o,h=(u.h-14*(i+1)-22*i)/i,m=c?(o-l)*(d+20)/2:0;return{x:u.x+20+s*(d+20)+m,y:u.y+14+a*(h+14+22),w:d,h:h}}(jt):null,Qr=nn&&Zr?Math.min(Zr.w/kn.w,Zr.h/kn.h):1,eo=(()=>{if(nn&&Zr){const e=Qr,t=kn.w*e,n=kn.h*e,r=Zr.x+(Zr.w-t)/2-kn.x,o=Zr.y+(Zr.h-n)/2-kn.y,i=rn||ln;return{transform:`translate(${r}px, ${o}px) scale(${e})`,transformOrigin:"top left",transition:"transform 280ms cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 280ms",cursor:"pointer",zIndex:F.expose+(i?20:10),boxShadow:i?"0 24px 72px rgba(0,0,0,0.6), 0 0 0 2px rgba(255,255,255,0.55), 0 0 36px 12px rgba(96,165,250,0.85), 0 0 96px 28px rgba(96,165,250,0.55)":"0 16px 48px rgba(0,0,0,0.55)",pointerEvents:"auto"}}if(un&&Qt){const e="picked"===hn;return{transition:e?"transform 640ms cubic-bezier(0.34, 1.42, 0.64, 1), box-shadow 600ms":"transform 600ms cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 600ms",...e?{zIndex:F.expose+30}:{}}}return null})(),to=b({modal:!1,titleId:!B&&(Pn?!Je?.home:!xe)?je:void 0,label:wr.text||Oe}),no=/* @__PURE__ */ce("div",{children:[
49
+ /* @__PURE__ */ce("div",{ref:ct,"data-modal-panel":!0,"data-modal-id":jt,"data-window-key":fe||void 0,...j?{"data-utility":""}:{},...He?{"data-pinned-top":""}:{},...B?{"data-widget":""}:{},...Je?{"data-window-owner":Je.key}:{},...Je&&!Ct?{"data-window-root":""}:{},...Pn?{"data-window-tab":""}:{},...to,className:Pn?"fixed flex flex-col overflow-hidden":"fixed rounded-(--radius-window) flex flex-col overflow-hidden "+(B?Bt?"shadow-xl":"shadow-lg":"border "+(Bt?"shadow-xl border-line":"shadow-lg border-line-strong")),onMouseDownCapture:e=>{if(ut.current=!1,nn){if(e.target.closest("[data-expose-close]"))return;return e.preventDefault(),e.stopPropagation(),$r(jt),Ar(!1),void er(jt)}if(!Bt&&!B&&!He&&0===e.button){const t=e.target;t.closest("[data-modal-panel]")===ct.current&&t.closest("button, input, a, select, textarea")&&!t.closest("[data-window-chrome]")&&(e.preventDefault(),e.stopPropagation(),ut.current=!0,Ye(null),er(jt),window.addEventListener("mouseup",()=>{setTimeout(()=>{ut.current=!1},0)},{once:!0}))}},onClickCapture:e=>{ut.current&&(ut.current=!1,e.preventDefault(),e.stopPropagation())},onMouseDown:e=>{if(nn)return;Ye(null);e.target.closest("[data-modal-panel]")===ct.current&&(e.target.closest("button, input, a, select, textarea")||er(jt))},style:xe?{zIndex:Ft+1,top:0,left:0,right:0,bottom:"var(--mobile-bottom-nav, 56px)",width:"auto",height:"auto",transform:`translateX(${Ce}px)`,transition:Ne?"none":"transform 180ms ease-out",...B?{display:"none"}:{},...Ft<0?{display:"none"}:{},...Bt||He||Ae&&fe===Ae?{}:{display:"none"}}:{zIndex:He?F.pinnedWindow:Ft+1,width:kn.w,height:kn.h,top:kn.y,...B&&"right"===at?{right:window.innerWidth-kn.x-kn.w}:{left:kn.x},...Ft<0&&!He?{display:"none"}:{},...ke?{display:"none"}:{},...Bn||Hn?{visibility:"hidden",pointerEvents:"none"}:{},...eo??{}},children:[xe&&!B&&/* @__PURE__ */ue("div",{onPointerDown:ze,className:"absolute top-0 bottom-0 left-0 w-[22px] z-[5]",style:{touchAction:"pan-y"},"aria-hidden":"true"}),B?null:Pn?Je?.home?null:/* @__PURE__ */ce(de,{children:[
50
+ /* @__PURE__ */ue("h2",{id:je,"data-window-title":!0,className:"sr-only",children:wr.text||Oe}),Gr&&Jr&&he(
51
+ /* @__PURE__ */ue(de,{children:wr.actions}),Jr),wr.badges.length>0&&/* @__PURE__ */ue("div",{"data-window-chrome":"","data-record-bar":"",className:"flex h-9 shrink-0 select-none items-center gap-2 overflow-hidden border-b border-gray-200 px-4",style:{backgroundColor:"rgb(var(--window-content-rgb))"},children:wr.badges})]}):xe?null:
52
52
  /* @__PURE__ */ce("div",X?{onPointerDown:Or,"data-window-chrome":"",...Ur,className:"flex items-center justify-between h-(--row-height-compact-bar) px-3 border-b border-line shrink-0 cursor-move select-none rounded-t-(--radius-window) focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-blue-400 "+(Bt?"backdrop-blur-sm":""),style:{touchAction:"none",backgroundColor:Bt?"rgb(var(--window-header-rgb) / var(--active-header-opacity, 0.8))":"rgb(var(--window-header-rgb) / var(--inactive-header-opacity, 0.7))"},children:[
53
53
  /* @__PURE__ */ce("div",{"data-window-title":!0,title:Oe,className:"text-sm font-medium min-w-0 flex-1 truncate flex items-center gap-2",style:{color:Bt?"var(--window-title-active, rgb(17 24 39))":"var(--window-title-inactive, rgb(156 163 175))"},children:[!nn&&It(),
54
54
  /* @__PURE__ */ue("span",{id:je,className:"truncate",children:nn?an(De):De})]}),!nn&&/* @__PURE__ */ce("div",{className:"flex items-center gap-2 shrink-0 ml-2",children:[j&&/* @__PURE__ */ue("button",{onClick:()=>Ue(e=>!e),title:He?$e.unpin:$e.pinOnTop,className:"p-0.5 rounded hover:bg-gray-200 "+(He?"text-blue-600":"text-gray-400 hover:text-gray-600"),children:/* @__PURE__ */ue(O,{name:"bookmark-square",className:"h-3 w-3",fill:He?"currentColor":"none",strokeWidth:1.5})}),
@@ -61,7 +61,7 @@ return ce("span",{className:"relative inline-flex",onMouseEnter:c,onMouseLeave:u
61
61
  /* @__PURE__ */ue("span",{id:je,className:"truncate",children:nn?an(De):De})]}),!nn&&/* @__PURE__ */ce("div",{className:"flex items-center gap-3 shrink-0 ml-4",children:[j&&/* @__PURE__ */ue("button",{onClick:()=>Ue(e=>!e),title:He?$e.unpin:$e.pinOnTop,className:"text-xs px-2 py-1 rounded hover:bg-gray-200 "+(He?"text-blue-600":"text-gray-400 hover:text-gray-600"),children:/* @__PURE__ */ue(O,{name:"bookmark-square",className:"h-3.5 w-3.5",fill:He?"currentColor":"none",strokeWidth:1.5})}),
62
62
  /* @__PURE__ */ue("button",{onClick:()=>tr(jt),title:$e.minimize,className:"text-gray-400 hover:text-gray-600 text-xs px-2 py-1 rounded hover:bg-gray-200",children:"─"}),!Rn&&/* @__PURE__ */ue(br,{maximized:Un,onToggleMax:()=>{Un?(Xn(!1),En(wn())):Xr()},onSnap:Hr,buttonClassName:"text-gray-400 hover:text-gray-600 text-xs px-2 py-1 rounded hover:bg-gray-200",strings:$e}),
63
63
  /* @__PURE__ */ue("button",{type:"button",onClick:Sr,"aria-label":$e.close,className:"rounded-(--radius-control) text-ink-faintest hover:text-gray-600",children:/* @__PURE__ */ue(O,{name:"close",className:"h-5 w-5"})})]})]}),ye&&Ze&&!B&&!xe&&/* @__PURE__ */ue("div",{"aria-hidden":"true",className:"h-[3px] shrink-0 pointer-events-none",style:{backgroundColor:`rgb(var(--window-accent-rgb) / ${Bt?.9:.55})`}}),
64
- /* @__PURE__ */ue(en.Provider,{value:jt,children:/* @__PURE__ */ue(L.Provider,{value:{rightRef:ht,leftRef:mt,notify:()=>ft(!0),active:Bt,isDirty:dr,footerOpen:kt&&!B&&!X&&!V&&!xe},children:/* @__PURE__ */ue("div",{ref:dt,...B?{onPointerDown:Or,onContextMenu:e=>{e.preventDefault(),it({x:e.clientX,y:e.clientY})}}:{},className:`flex-1 min-h-0 flex flex-col ${B?"p-0 cursor-move":V||ne?"p-0":X?"p-2":"p-4"} ${B||Pn?"":"backdrop-blur-sm"} ${!1===v||V||ne?"overflow-hidden":"overflow-y-auto overscroll-contain"} ${B?"rounded-2xl select-none":""}`,style:{...B?{touchAction:"none"}:{},backgroundColor:B?"transparent":Pn?"rgb(var(--window-content-rgb))":Bt?"rgb(var(--window-content-rgb) / var(--active-content-opacity, 0.9))":"rgb(var(--window-content-rgb) / var(--inactive-content-opacity, 0.8))"},children:/* @__PURE__ */ue(Pe,{children:ge})})})}),B&&ot&&/* @__PURE__ */ce(I,{minWidth:160,style:{left:ot.x,top:ot.y},onClose:()=>it(null),children:[
64
+ /* @__PURE__ */ue(en.Provider,{value:jt,children:/* @__PURE__ */ue(C.Provider,{value:{rightRef:ht,leftRef:mt,notify:()=>ft(!0),active:Bt,isDirty:dr,footerOpen:kt&&!B&&!X&&!V&&!xe},children:/* @__PURE__ */ue("div",{ref:dt,...B?{onPointerDown:Or,onContextMenu:e=>{e.preventDefault(),it({x:e.clientX,y:e.clientY})}}:{},className:`flex-1 min-h-0 flex flex-col ${B?"p-0 cursor-move":V||ne?"p-0":X?"p-2":"p-4"} ${B||Pn?"":"backdrop-blur-sm"} ${!1===v||V||ne?"overflow-hidden":"overflow-y-auto overscroll-contain"} ${B?"rounded-2xl select-none":""}`,style:{...B?{touchAction:"none"}:{},backgroundColor:B?"transparent":Pn?"rgb(var(--window-content-rgb))":Bt?"rgb(var(--window-content-rgb) / var(--active-content-opacity, 0.9))":"rgb(var(--window-content-rgb) / var(--inactive-content-opacity, 0.8))"},children:/* @__PURE__ */ue(Pe,{children:ge})})})}),B&&ot&&/* @__PURE__ */ce(I,{minWidth:160,style:{left:ot.x,top:ot.y},onClose:()=>it(null),children:[
65
65
  /* @__PURE__ */ue(R,{onClick:()=>{it(null),window.dispatchEvent(new CustomEvent("widget-open-settings",{detail:jt}))},children:"Settings"}),
66
66
  /* @__PURE__ */ue(W,{}),me&&/* @__PURE__ */ce(de,{children:[me,
67
67
  /* @__PURE__ */ue(W,{})]}),
@@ -74,7 +74,7 @@ return ce("span",{className:"relative inline-flex",onMouseEnter:c,onMouseLeave:u
74
74
  /* @__PURE__ */ue("div",{ref:mt,"data-modal-actions-left":!0,className:"flex items-center gap-2 shrink-0"}),null!=y&&!1!==y&&
75
75
  /* @__PURE__ */ue("div",{ref:yt,"data-modal-footer-facts":"",className:"min-w-0 flex-1 overflow-hidden",children:/* @__PURE__ */ue("div",{ref:gt,className:"inline-flex items-center gap-2 whitespace-nowrap"+(bt?" invisible":""),children:y})})]}),
76
76
  /* @__PURE__ */ce("div",{"data-modal-footer-right":"",className:"flex items-center gap-2 ml-auto shrink-0",children:[xt&&K&&(K.editing?/* @__PURE__ */ue($,{variant:"secondary",size:"sm","data-modal-discard":"",onClick:()=>{Lr()},children:$e.discard}):"object"==typeof K.state?/* @__PURE__ */ue($,{variant:"secondary",size:"sm","data-modal-edit":"","aria-disabled":!0,disabledReason:K.state.disabledReason,children:$e.edit}):/* @__PURE__ */ue($,{variant:"secondary",size:"sm","data-modal-edit":"",onClick:()=>K.onEdit(),children:$e.edit})),
77
- /* @__PURE__ */ue("div",{ref:ht,"data-modal-actions":!0,className:"flex items-center gap-2"}),S]})]}),!B&&!xe&&!nn&&Bt&&!Rn&&/* @__PURE__ */ce(de,{children:[
77
+ /* @__PURE__ */ue("div",{ref:ht,"data-modal-actions":!0,className:"flex items-center gap-2"}),L]})]}),!B&&!xe&&!nn&&Bt&&!Rn&&/* @__PURE__ */ce(de,{children:[
78
78
  /* @__PURE__ */ue("div",{onPointerDown:e=>jr(e,"se"),className:"absolute bottom-0 right-0 w-3 h-3 cursor-nwse-resize z-10"}),
79
79
  /* @__PURE__ */ue("div",{onPointerDown:e=>jr(e,"sw"),className:"absolute bottom-0 left-0 w-3 h-3 cursor-nesw-resize z-10"}),
80
80
  /* @__PURE__ */ue("div",{onPointerDown:e=>jr(e,"ne"),className:"absolute top-0 right-0 w-3 h-3 cursor-nesw-resize z-10"}),
@@ -88,12 +88,12 @@ return ce("span",{className:"relative inline-flex",onMouseEnter:c,onMouseLeave:u
88
88
  /* @__PURE__ */ue(O,{name:"collapse",className:"h-4 w-4",strokeWidth:1.5}),$e.windowed]}:{onClick:()=>{Xr(),Ye(null)},children:[
89
89
  /* @__PURE__ */ue(O,{name:"expand",className:"h-4 w-4",strokeWidth:1.5}),$e.maximize]})]}),j&&!Pn&&/* @__PURE__ */ce(R,{onClick:()=>{Ue(e=>!e),Ye(null)},children:[
90
90
  /* @__PURE__ */ue(O,{name:"bookmark-square",className:"h-4 w-4 "+(He?"text-blue-600":""),fill:He?"currentColor":"none",strokeWidth:1.5}),He?$e.unpin:$e.pinOnTop]}),Ve&&/* @__PURE__ */ce(R,{onClick:()=>{Ye(null),rt()},children:[
91
- /* @__PURE__ */ue(O,{name:"star",className:"h-4 w-4",fill:tt?"currentColor":"none",strokeWidth:1.5}),tt?Ke.taskbar.removeFromDesktop:Ke.taskbar.addToDesktop]}),(cn[jt]||[]).length>0&&/* @__PURE__ */ue(de,{children:(cn[jt]||[]).map((e,t)=>/* @__PURE__ */ce(R,{onClick:()=>{Ye(null),e.onClick()},children:[e.icon,e.label]},t))}),!(Pn&&_e?.home)&&/* @__PURE__ */ce(de,{children:[
91
+ /* @__PURE__ */ue(O,{name:"star",className:"h-4 w-4",fill:tt?"currentColor":"none",strokeWidth:1.5}),tt?Ke.taskbar.removeFromDesktop:Ke.taskbar.addToDesktop]}),(cn[jt]||[]).length>0&&/* @__PURE__ */ue(de,{children:(cn[jt]||[]).map((e,t)=>/* @__PURE__ */ce(R,{onClick:()=>{Ye(null),e.onClick()},children:[e.icon,e.label]},t))}),!(Pn&&Je?.home)&&/* @__PURE__ */ce(de,{children:[
92
92
  /* @__PURE__ */ue(W,{}),
93
93
  /* @__PURE__ */ce(R,{danger:!0,onClick:()=>{Ye(null),Sr()},children:[
94
94
  /* @__PURE__ */ue(O,{name:"close",className:"h-4 w-4"}),$e.close]})]})]}),oo=!!fe&&Ot.some(e=>e.id===fe),io=!Vt||oo||B?null:/* @__PURE__ */ce("div",{"data-modal-restore-tab":!0,"data-modal-id":jt,className:"fixed left-1/2 z-(--z-restore-tab) flex -translate-x-1/2 items-center gap-1 rounded-lg border border-line-strong bg-surface px-2 py-1 shadow-lg",style:{bottom:"calc(var(--taskbar-height, 0px) + 12px)"},children:[
95
95
  /* @__PURE__ */ue("button",{type:"button",onClick:()=>er(jt),title:$e.restore,className:"max-w-[16rem] truncate rounded px-2 py-0.5 text-sm font-medium text-gray-700 hover:bg-gray-100 hover:text-gray-900",children:Oe||$e.windowSuffix}),
96
96
  /* @__PURE__ */ue("button",{type:"button",onClick:()=>er(jt),title:$e.restore,"aria-label":$e.restore,className:"rounded px-2 py-0.5 text-xs leading-none text-ink-faintest hover:bg-gray-100 hover:text-gray-600",children:"▴"}),
97
97
  /* @__PURE__ */ue("button",{type:"button",onClick:()=>{Sr()},title:$e.close,"aria-label":$e.close,className:"rounded px-2 py-0.5 text-xs leading-none text-ink-faintest hover:bg-gray-100 hover:text-gray-600",children:"✕"})]});return he(
98
- /* @__PURE__ */ce(tn.Provider,{value:null,children:[no,ro,io]}),document.body)}"undefined"!=typeof window&&window.addEventListener("keydown",e=>{Sr&&"Escape"===e.key&&(Br(null),Ar(!1))});var Vr=100,_r={past:[],future:[]};function Gr(e,t){switch(t.type){case"record":{const n=e.past[e.past.length-1];if(null!==t.step.coalesceKey&&n?.coalesceKey===t.step.coalesceKey)return 0===e.future.length?e:{...e,future:[]};const r=[...e.past,t.step];return{past:r.length>Vr?r.slice(r.length-Vr):r,future:[]}}case"undo":return 0===e.past.length?e:{past:e.past.slice(0,-1),future:[t.redoStep,...e.future]};case"redo":return 0===e.future.length?e:{past:[...e.past,t.undoStep],future:e.future.slice(1)};case"clear":return 0===e.past.length&&0===e.future.length?e:_r}}var Jr=/* @__PURE__ */new Set(["INPUT","TEXTAREA","SELECT"]);var Zr=500,Qr=250;function eo({children:e,canEdit:t=!0,perms:n,windowId:r}){const[o,i]=se(Gr,_r),a=G(/* @__PURE__ */new Map),[s,l]=Z(0),c=s>0,[u,d]=Z(0),[h,m]=Z(0),p=h>0,{hasAnyPerm:f}=k(),w=t&&0===u&&(!(n&&n.length>0)||f(n)),y=G(null),g=G(!1),b=ee(()=>{const e={};for(const[t,n]of a.current)e[t]=n.getLast();return e},[]),v=ee((e,t)=>{a.current.has(e)||l(e=>e+1),a.current.set(e,t)},[]),x=ee(e=>{a.current.delete(e)&&l(e=>e-1)},[]),E=ee(e=>{d(t=>t+(e?1:-1))},[]),C=ee(e=>{m(t=>t+(e?1:-1))},[]),[M,N]=Z(0),S=M>0,T=ee(e=>{N(t=>t+(e?1:-1))},[]),z=Y(Ie),A=z?.claimReadOnly;J(()=>{if(A&&!w)return A(!0),()=>A(!1)},[A,w]);const D=z?.claimOwnMount;J(()=>{if(D&&S)return D(!0),()=>D(!1)},[D,S]);const P=G({last:0,count:0,tripped:!1}),I=G(!1),R=ee((e,t,n)=>{if(g.current)return void(n&&function(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||"object"!=typeof t||null===e||null===t)return!1;if(Array.isArray(e)!==Array.isArray(t))return!1;try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}}(n.prev,n.next)||(I.current=!0));if(!w||y.current)return;const r=P.current;if(r.tripped)return;const o=Date.now();if(o-r.last>Qr&&(r.count=0),r.last=o,++r.count>Zr)return r.tripped=!0,void console.error(`[efficient-shell] UndoProvider: "${e}" recorded ${Zr} undo steps with no pause between them, which no user action can do. The value passed to useUndoable for this slice is almost certainly rebuilt on every render (a .map/.filter/object literal in the call) rather than held in state, so it reads as changed every time — and since recording a step re-renders the form, that is a loop. Undo recording is now off for this form to keep the tab responsive.`);y.current={values:b(),label:e,coalesceKey:t},queueMicrotask(()=>{const e=y.current;y.current=null,e&&i({type:"record",step:e})})},[w,b]),W=ee(e=>{for(const[t,n]of Object.entries(e)){const e=a.current.get(t);e&&(e.setLast(n),e.apply(n))}},[]),K=ee(()=>{const e=o.past[o.past.length-1];if(!e)return;const t={values:b(),label:e.label,coalesceKey:null};W(e.values),i({type:"undo",redoStep:t})},[o.past,b,W]),$=ee(()=>{const e=o.future[0];if(!e)return;const t={values:b(),label:e.label,coalesceKey:null};W(e.values),i({type:"redo",undoStep:t})},[o.future,b,W]),[O,j]=Z(0),F=G(0),q=G(0),B=G(!1),H=ee(()=>{g.current=!0,I.current=!1,y.current=null,F.current+=1,q.current=F.current,j(F.current)},[]),U=G(void 0),X=ee(e=>{void 0!==e&&(void 0!==U.current&&e!==U.current&&(B.current=!0),U.current=e),H()},[H]);J(()=>{g.current&&O===q.current&&(g.current=!1,y.current=null,(I.current||B.current)&&i({type:"clear"}),I.current=!1,B.current=!1)},[O]);const V=ee(()=>{B.current=!0,i({type:"clear"}),H()},[H]),_=w&&o.past.length>0,Q=w&&o.future.length>0,te=Nr(r),ne=G({undo:K,redo:$,canUndo:_,canRedo:Q});ne.current={undo:K,redo:$,canUndo:_,canRedo:Q},J(()=>{if(!te||!w)return;const e=e=>{const t=function(e){if(!e.metaKey&&!e.ctrlKey||e.altKey)return null;const t=e.key.toLowerCase(),n="z"===t?e.shiftKey?"redo":"undo":"y"!==t||!e.ctrlKey||e.metaKey||e.shiftKey?null:"redo";if(!n)return null;const r=e.target;return r?.isContentEditable||r?.tagName&&Jr.has(r.tagName.toUpperCase())?null:n}(e);if(!t)return;const n=ne.current;("undo"===t?n.canUndo:n.canRedo)&&(e.preventDefault(),"undo"===t?n.undo():n.redo())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[te,w]);const re=ie(()=>({register:v,unregister:x,record:R,undo:K,redo:$,clear:V,baseline:X,canUndo:_,canRedo:Q,enabled:w,hasState:c,handMounted:S,claimOwnMount:T,claimReadOnly:E,declaredEditable:p,claimEditable:C,undoLabel:_?o.past[o.past.length-1].label:null,redoLabel:Q?o.future[0].label:null}),[v,x,R,K,$,V,X,_,Q,w,c,S,T,E,p,C,o.past,o.future]),oe=""!==mn(),ae=Y(L)?.footerOpen??!1,le=oe&&w&&c&&!S&&ae;/* @__PURE__ */
99
- return ce(Ie.Provider,{value:re,children:[le&&/* @__PURE__ */ue(pn,{position:"left",quiet:!0,children:/* @__PURE__ */ue(We,{auto:!0})}),e]})}function to(){const e=Y(Ie),t=ee(()=>{},[]);return{undo:e?.undo??t,redo:e?.redo??t,clear:e?.clear??t,baseline:e?.baseline??t,canUndo:e?.canUndo??!1,canRedo:e?.canRedo??!1,undoLabel:e?.undoLabel??null,redoLabel:e?.redoLabel??null,enabled:e?.enabled??!1,hasState:e?.hasState??!1}}function no(e){const t=Y(Ie),n=t?.claimReadOnly,r=t?.claimEditable;J(()=>{const t=e?r:n;if(t)return t(!0),()=>t(!1)},[n,r,e])}function ro(e,t,n){const r=Y(Ie),o=ae(),i=G(e),a=G(t);a.current=t,J(()=>{if(r)return r.register(o,{getLast:()=>i.current,setLast:e=>{i.current=e},apply:e=>a.current(e)}),()=>r.unregister(o)},[r,o]);const{label:s,coalesceKey:l=null}=n,c=G(r);c.current=r;const u=G({label:s,coalesceKey:l});u.current={label:s,coalesceKey:l},J(()=>{const t=c.current;t&&(Object.is(e,i.current)||(t.record(u.current.label,u.current.coalesceKey,{prev:i.current,next:e}),i.current=e))},[e])}function oo(e,t){const[n,r]=Z(e);return ro(n,e=>r(()=>e),t),[n,r]}export{fn as CancelButton,it as DocFavStar,Ye as EntityWindowFallback,Ue as EntityWindowLoading,Ve as EntityWindowState,on as MODAL_SUBMIT_SELECTOR,Yr as Modal,pn as ModalActions,We as UndoControls,eo as UndoProvider,ve as WINDOW_REGISTRY,De as WindowCrashedFallback,Pe as WindowErrorBoundary,Nt as WindowManagerProvider,dn as WindowTitle,dt as activateWindowById,Ot as beginWindowGesture,Gn as cancelWindowFront,ke as client_default,Hr as commitExposeHighlight,_n as confirmWindowDiscard,jt as drainPerfEvents,Pr as exitExposeMode,Sn as forgetMaximizedWindowBoxes,pt as getActiveWindowRoute,qr as getExposeHighlight,Qt as getWindowChromeVersion,Mn as getWindowPosition,Ge as isDraftEntityId,Je as isDraftEntityWindow,ye as isEntityEntry,we as isPageEntry,xe as isShellApiClientConfigured,Fe as isTabWindow,$t as markMenuOpen,Jt as readWindowChrome,Xn as requestWindowFront,Br as setExposeHighlight,Kt as setPerfCollecting,Se as setShellHomeRoute,Ae as setShellTabStrip,be as setShellWindowRegistry,Cn as setWindowDefaultPosition,Nn as setWindowPosition,Ut as splitTitle,Fr as subscribeExposeHighlight,Zt as subscribeWindowChrome,qe as tabGroupOf,Dr as toggleExposeMode,qn as useCurrentTabKey,mn as useEnclosingModalId,Nr as useIsActiveWindow,Ce as usePageSearch,to as useUndo,no as useUndoCanEdit,ro as useUndoable,oo as useUndoableState,ln as useWidgetSettings,et as useWindowDirty,nt as useWindowManager,un as useWindowMenuItem,hn as useWindowTitle,Vn as windowHoldsChanges};
98
+ /* @__PURE__ */ce(tn.Provider,{value:null,children:[no,ro,io]}),document.body)}"undefined"!=typeof window&&window.addEventListener("keydown",e=>{Sr&&"Escape"===e.key&&(Br(null),Ar(!1))});var Vr=100,Jr={past:[],future:[]};function Gr(e,t){switch(t.type){case"record":{const n=e.past[e.past.length-1];if(null!==t.step.coalesceKey&&n?.coalesceKey===t.step.coalesceKey)return 0===e.future.length?e:{...e,future:[]};const r=[...e.past,t.step];return{past:r.length>Vr?r.slice(r.length-Vr):r,future:[]}}case"undo":return 0===e.past.length?e:{past:e.past.slice(0,-1),future:[t.redoStep,...e.future]};case"redo":return 0===e.future.length?e:{past:[...e.past,t.undoStep],future:e.future.slice(1)};case"clear":return 0===e.past.length&&0===e.future.length?e:Jr}}var _r=/* @__PURE__ */new Set(["INPUT","TEXTAREA","SELECT"]);var Zr=500,Qr=250;function eo({children:e,canEdit:t=!0,perms:n,windowId:r}){const[o,i]=se(Gr,Jr),a=G(/* @__PURE__ */new Map),[s,l]=Z(0),c=s>0,[u,d]=Z(0),[h,m]=Z(0),p=h>0,{hasAnyPerm:f}=L(),w=t&&0===u&&(!(n&&n.length>0)||f(n)),y=G(null),g=G(!1),b=ee(()=>{const e={};for(const[t,n]of a.current)e[t]=n.getLast();return e},[]),v=ee((e,t)=>{a.current.has(e)||l(e=>e+1),a.current.set(e,t)},[]),x=ee(e=>{a.current.delete(e)&&l(e=>e-1)},[]),k=ee(e=>{d(t=>t+(e?1:-1))},[]),E=ee(e=>{m(t=>t+(e?1:-1))},[]),[M,N]=Z(0),S=M>0,T=ee(e=>{N(t=>t+(e?1:-1))},[]),z=Y(Ie),A=z?.claimReadOnly;_(()=>{if(A&&!w)return A(!0),()=>A(!1)},[A,w]);const D=z?.claimOwnMount;_(()=>{if(D&&S)return D(!0),()=>D(!1)},[D,S]);const P=G({last:0,count:0,tripped:!1}),I=G(!1),R=ee((e,t,n)=>{if(g.current)return void(n&&function(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||"object"!=typeof t||null===e||null===t)return!1;if(Array.isArray(e)!==Array.isArray(t))return!1;try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}}(n.prev,n.next)||(I.current=!0));if(!w||y.current)return;const r=P.current;if(r.tripped)return;const o=Date.now();if(o-r.last>Qr&&(r.count=0),r.last=o,++r.count>Zr)return r.tripped=!0,void console.error(`[efficient-shell] UndoProvider: "${e}" recorded ${Zr} undo steps with no pause between them, which no user action can do. The value passed to useUndoable for this slice is almost certainly rebuilt on every render (a .map/.filter/object literal in the call) rather than held in state, so it reads as changed every time — and since recording a step re-renders the form, that is a loop. Undo recording is now off for this form to keep the tab responsive.`);y.current={values:b(),label:e,coalesceKey:t},queueMicrotask(()=>{const e=y.current;y.current=null,e&&i({type:"record",step:e})})},[w,b]),W=ee(e=>{for(const[t,n]of Object.entries(e)){const e=a.current.get(t);e&&(e.setLast(n),e.apply(n))}},[]),K=ee(()=>{const e=o.past[o.past.length-1];if(!e)return;const t={values:b(),label:e.label,coalesceKey:null};W(e.values),i({type:"undo",redoStep:t})},[o.past,b,W]),$=ee(()=>{const e=o.future[0];if(!e)return;const t={values:b(),label:e.label,coalesceKey:null};W(e.values),i({type:"redo",undoStep:t})},[o.future,b,W]),[O,j]=Z(0),F=G(0),q=G(0),B=G(!1),H=ee(()=>{g.current=!0,I.current=!1,y.current=null,F.current+=1,q.current=F.current,j(F.current)},[]),U=G(void 0),X=ee(e=>{void 0!==e&&(void 0!==U.current&&e!==U.current&&(B.current=!0),U.current=e),H()},[H]);_(()=>{g.current&&O===q.current&&(g.current=!1,y.current=null,(I.current||B.current)&&i({type:"clear"}),I.current=!1,B.current=!1)},[O]);const V=ee(()=>{B.current=!0,i({type:"clear"}),H()},[H]),J=w&&o.past.length>0,Q=w&&o.future.length>0,te=Nr(r),ne=G({undo:K,redo:$,canUndo:J,canRedo:Q});ne.current={undo:K,redo:$,canUndo:J,canRedo:Q},_(()=>{if(!te||!w)return;const e=e=>{const t=function(e){if(!e.metaKey&&!e.ctrlKey||e.altKey)return null;const t=e.key.toLowerCase(),n="z"===t?e.shiftKey?"redo":"undo":"y"!==t||!e.ctrlKey||e.metaKey||e.shiftKey?null:"redo";if(!n)return null;const r=e.target;return r?.isContentEditable||r?.tagName&&_r.has(r.tagName.toUpperCase())?null:n}(e);if(!t)return;const n=ne.current;("undo"===t?n.canUndo:n.canRedo)&&(e.preventDefault(),"undo"===t?n.undo():n.redo())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[te,w]);const re=ie(()=>({register:v,unregister:x,record:R,undo:K,redo:$,clear:V,baseline:X,canUndo:J,canRedo:Q,enabled:w,hasState:c,handMounted:S,claimOwnMount:T,claimReadOnly:k,declaredEditable:p,claimEditable:E,undoLabel:J?o.past[o.past.length-1].label:null,redoLabel:Q?o.future[0].label:null}),[v,x,R,K,$,V,X,J,Q,w,c,S,T,k,p,E,o.past,o.future]),oe=""!==mn(),ae=Y(C)?.footerOpen??!1,le=oe&&w&&c&&!S&&ae;/* @__PURE__ */
99
+ return ce(Ie.Provider,{value:re,children:[le&&/* @__PURE__ */ue(pn,{position:"left",quiet:!0,children:/* @__PURE__ */ue(We,{auto:!0})}),e]})}function to(){const e=Y(Ie),t=ee(()=>{},[]);return{undo:e?.undo??t,redo:e?.redo??t,clear:e?.clear??t,baseline:e?.baseline??t,canUndo:e?.canUndo??!1,canRedo:e?.canRedo??!1,undoLabel:e?.undoLabel??null,redoLabel:e?.redoLabel??null,enabled:e?.enabled??!1,hasState:e?.hasState??!1}}function no(e){const t=Y(Ie),n=t?.claimReadOnly,r=t?.claimEditable;_(()=>{const t=e?r:n;if(t)return t(!0),()=>t(!1)},[n,r,e])}function ro(e,t,n){const r=Y(Ie),o=ae(),i=G(e),a=G(t);a.current=t,_(()=>{if(r)return r.register(o,{getLast:()=>i.current,setLast:e=>{i.current=e},apply:e=>a.current(e)}),()=>r.unregister(o)},[r,o]);const{label:s,coalesceKey:l=null}=n,c=G(r);c.current=r;const u=G({label:s,coalesceKey:l});u.current={label:s,coalesceKey:l},_(()=>{const t=c.current;t&&(Object.is(e,i.current)||(t.record(u.current.label,u.current.coalesceKey,{prev:i.current,next:e}),i.current=e))},[e])}function oo(e,t){const[n,r]=Z(e);return ro(n,e=>r(()=>e),t),[n,r]}export{fn as CancelButton,it as DocFavStar,Ye as EntityWindowFallback,Ue as EntityWindowLoading,Ve as EntityWindowState,on as MODAL_SUBMIT_SELECTOR,Yr as Modal,pn as ModalActions,We as UndoControls,eo as UndoProvider,ve as WINDOW_REGISTRY,De as WindowCrashedFallback,Pe as WindowErrorBoundary,Nt as WindowManagerProvider,dn as WindowTitle,dt as activateWindowById,Ot as beginWindowGesture,Gn as cancelWindowFront,ke as client_default,Hr as commitExposeHighlight,Jn as confirmWindowDiscard,jt as drainPerfEvents,Pr as exitExposeMode,Sn as forgetMaximizedWindowBoxes,pt as getActiveWindowRoute,qr as getExposeHighlight,Qt as getWindowChromeVersion,Mn as getWindowPosition,Ge as isDraftEntityId,_e as isDraftEntityWindow,ye as isEntityEntry,we as isPageEntry,xe as isShellApiClientConfigured,Fe as isTabWindow,$t as markMenuOpen,_t as readWindowChrome,Xn as requestWindowFront,Br as setExposeHighlight,Kt as setPerfCollecting,Se as setShellHomeRoute,Ae as setShellTabStrip,be as setShellWindowRegistry,Cn as setWindowDefaultPosition,Nn as setWindowPosition,Ut as splitTitle,Fr as subscribeExposeHighlight,Zt as subscribeWindowChrome,qe as tabGroupOf,Dr as toggleExposeMode,qn as useCurrentTabKey,mn as useEnclosingModalId,Nr as useIsActiveWindow,Ce as usePageSearch,to as useUndo,no as useUndoCanEdit,ro as useUndoable,oo as useUndoableState,ln as useWidgetSettings,et as useWindowDirty,nt as useWindowManager,un as useWindowMenuItem,hn as useWindowTitle,Vn as windowHoldsChanges};
@@ -0,0 +1,13 @@
1
+ import{copyToClipboard as e,selectionAt as t}from"./chunk-PH3P54QQ.js";import{useTableNav as n}from"./chunk-ATMJ5ZPK.js";import{escapeHtml as r}from"./chunk-G6DKCCWH.js";import{ListFooter as o}from"./chunk-4H5NTMOF.js";import{ListLoadError as l}from"./chunk-YRJJKF5H.js";import{ResizableTable as i}from"./chunk-3PWI5IH7.js";import{Checkbox_default as a}from"./chunk-CGZBDI6C.js";import{LoadingSpinner as c}from"./chunk-SCGBCBXP.js";import{PopupMenu as d,PopupMenuLabel as s,PopupMenuItem as h,PopupMenuDivider as m}from"./chunk-IFQXTIMY.js";import{keepsNativeMenu as u}from"./chunk-5QFPTDQF.js";import{LoadingSpinner as p}from"./chunk-R2VKEMZH.js";import{shellHttp as f}from"./chunk-STKJA4PV.js";import{toast_default as g}from"./chunk-TRWHVG3A.js";import{useShellStrings as y}from"./chunk-43MCNASD.js";import{useState as k,useRef as b}from"react";import{jsx as x,Fragment as w,jsxs as C}from"react/jsx-runtime";function j(e){return Array.from(e.children).filter(e=>void 0!==e.dataset?.colKey&&"_select"!==e.dataset.colKey)}function v(e){return("string"==typeof e.innerText?e.innerText:e.textContent??"").replace(/\s+/g," ").trim()}function S(S){const{items:R,isLoading:N,emptyState:T,totalCount:$,isError:L,onRetry:M,errorTitle:P,errorMessage:A,tableId:F,columns:I,renderCell:K,getRowId:H=e=>e.id,sort:E,onSort:D,selected:U,setSelected:W,onRowClick:B,onRowHover:J,getRowClassName:O,footerLabel:Q,footerExtra:G,sentinelRef:_,isFetchingNextPage:V,saveDefaultPerms:X,exportEndpoint:Y,exportFilename:Z="export.csv",contextActions:z}=S,[q,ee]=k(null),te=b(null),ne=y(),re=ne.entityList,oe=e=>{W(t=>{const n=new Set(t),r=H(e);return n.has(r)?n.delete(r):n.add(r),n})},le=()=>{W(e=>{const t=R.map(H),n=new Set(e);return t.every(t=>e.has(t))?t.forEach(e=>n.delete(e)):t.forEach(e=>n.add(e)),n})},ie=n(R,B,oe,le,(e,t)=>{W(n=>{const r=new Set(n);for(let n=e;n<=t;n++)r.add(H(R[n]));return r})},te),ae=R.filter(e=>U.has(H(e))),ce=()=>{const e=[...te.current?.querySelectorAll("tr[data-row-idx]")??[]].filter(e=>{const t=R[Number(e.dataset.rowIdx)];return void 0!==t&&U.has(H(t))}),t=e.length?j(e[0]).map(e=>e.dataset.colKey??""):[],n=new Map(I.map(e=>[e.key,e.label]));return{keys:t,header:t.map(e=>n.get(e)??e),body:e.map(e=>j(e).map(v))}},de=()=>{ee(null);const{header:t,body:n}=ce();if(!n.length)return;const o=[t,...n].map(e=>e.join("\t")).join("\n"),l="<table><thead><tr>"+t.map(e=>`<th>${r(e)}</th>`).join("")+"</tr></thead><tbody>"+n.map(e=>`<tr>${e.map(e=>`<td>${r(e)}</td>`).join("")}</tr>`).join("")+"</tbody></table>";e(re.copiedRows(n.length),o,l)},se=async()=>{ee(null);const e=ae.map(H);if(!e.length||!Y)return;const t=new URLSearchParams({ids:e.join(",")}),n=(()=>{const e=new Map(I.map(e=>[e.key,e.exportLabel??e.label]));try{const t=localStorage.getItem(`col-config-${F}`);if(t){const n=JSON.parse(t).filter(t=>!t.hidden&&"_select"!==t.key&&e.has(t.key)).map(t=>`${t.key}|${e.get(t.key)}`);if(n.length)return n.join(",")}}catch{}return I.filter(e=>!e.defaultHidden).map(e=>`${e.key}|${e.exportLabel??e.label}`).join(",")})();n&&t.set("cols",n);const r=Y.includes("?")?"&":"?";try{const n=await f.get(`${Y}${r}${t}`,{responseType:"blob"}),o=window.URL.createObjectURL(new Blob([n.data],{type:"text/csv"})),l=document.createElement("a");l.href=o,l.download=Z,l.click(),window.URL.revokeObjectURL(o);const i=n.headers??{},a=Number(i["x-row-count"]);if("true"===String(i["x-truncated"]))return void g.notify(Number.isFinite(a)?re.exportTruncated(a,e.length):re.exportTruncatedUnknown(e.length));g.success(re.exported(e.length))}catch{g.error(re.exportFailed)}};if(N)/* @__PURE__ */return x(c,{});if(L&&0===R.length)/* @__PURE__ */
2
+ return x(l,{title:P,message:A,onRetry:M});if(0===R.length)/* @__PURE__ */return x(w,{children:T});const he=R.length>0&&ae.length===R.length,me=ae.length>0&&!he,ue=U.size-ae.length,pe=[{key:"_select",label:"",defaultWidth:52,minWidth:52,headerNode:/* @__PURE__ */x(a,{"aria-label":ne.table.selectAll,checked:he,indeterminate:me,onChange:le,style:{height:14,width:14}})},...I],fe=/* @__PURE__ */x(o,{selectedCount:ae.length,hiddenSelectedCount:ue,loadedCount:R.length,totalCount:$,label:Q,isFetchingMore:V,extra:G}),ge=_?/* @__PURE__ */C(w,{children:[
3
+ /* @__PURE__ */x("div",{ref:_}),V&&/* @__PURE__ */x(p,{size:"sm",padding:"py-3",label:ne.list.loadingMore})]}):void 0;let ye=null;if(q){const{x:t,y:n,item:r,text:o,firstColumn:l}=q,i=z?z(ae):[],a=ae.length,c=()=>ee(null),u=void 0!==$&&$>R.length;ye=/* @__PURE__ */C(d,{portal:!0,style:{left:t,top:n},onClose:c,minWidth:210,children:[
4
+ /* @__PURE__ */x(s,{children:ue>0?ne.list.selectedNotShown(a,ue):ne.list.selected(a)}),
5
+ /* @__PURE__ */x(h,{className:"font-medium",onClick:()=>{c(),B(r)},children:re.open}),
6
+ /* @__PURE__ */x(m,{}),o&&/* @__PURE__ */x(h,{onClick:()=>{c(),e(re.copiedText,o.text,o.html)},children:re.copy}),l&&/* @__PURE__ */x(h,{onClick:()=>(t=>{ee(null);const{keys:n,body:r}=ce(),o=n.indexOf(t.key);o<0||!r.length||e(t.label,r.map(e=>e[o]).join("\n"))})(l),children:re.copyColumn(l.label)}),
7
+ /* @__PURE__ */x(h,{disabled:0===a,onClick:de,children:re.copyRows(a)}),Y&&/* @__PURE__ */x(h,{onClick:se,children:re.exportSelected}),i.map((e,t)=>/* @__PURE__ */C("div",{children:[(e.divider||0===t)&&/* @__PURE__ */x(m,{}),
8
+ /* @__PURE__ */x(h,{danger:e.danger,disabled:e.disabled,onClick:()=>{c(),e.onClick(ae)},children:e.label})]},t)),
9
+ /* @__PURE__ */x(m,{}),!he&&/* @__PURE__ */x(h,{onClick:()=>{c(),W(e=>/* @__PURE__ */new Set([...e,...R.map(H)]))},children:u?re.selectAllLoaded(R.length):re.selectAll}),
10
+ /* @__PURE__ */x(h,{onClick:()=>{c(),W(/* @__PURE__ */new Set)},children:re.clearSelection}),M&&/* @__PURE__ */x(h,{onClick:()=>{c(),M()},children:re.refresh})]})}/* @__PURE__ */
11
+ return C("div",{className:"flex-1 flex flex-col mb-1 bg-white rounded-lg shadow overflow-hidden",children:[
12
+ /* @__PURE__ */x("div",{className:"flex-1 min-h-0 flex flex-col",children:/* @__PURE__ */x(i,{tableId:F,columns:pe,sort:E,onSort:D,footer:fe,afterBody:ge,saveDefaultPerms:X,children:e=>/* @__PURE__ */x("tbody",{ref:te,className:"divide-y divide-gray-100",children:R.map((n,r)=>{const o=H(n);/* @__PURE__ */
13
+ return x("tr",{"data-row-idx":r,className:`cursor-pointer ${ie===r?"bg-blue-50 ring-1 ring-inset ring-blue-300":U.has(o)?"bg-blue-50 hover:bg-blue-100":"hover:bg-gray-50"} ${O?.(n)??""}`,onClick:()=>B(n),onContextMenu:e=>((e,n)=>{if(e.shiftKey||u(e.target))return;e.preventDefault();const r=H(n);U.has(r)||W(/* @__PURE__ */new Set([r]));const o=j(e.currentTarget)[0]?.dataset.colKey,l=o?I.find(e=>e.key===o)?.label:void 0;ee({x:e.clientX,y:e.clientY,item:n,text:t(e.target),firstColumn:o&&l?{key:o,label:l}:null})})(e,n),onMouseEnter:J?()=>J(n):void 0,children:e.map(e=>/* @__PURE__ */x("td",{"data-col-key":e.key,className:"px-4 py-3 whitespace-nowrap text-sm overflow-hidden",children:"_select"===e.key?/* @__PURE__ */x(a,{"aria-label":ne.table.selectRow,checked:U.has(o),onChange:()=>oe(n),onClick:e=>e.stopPropagation(),style:{height:14,width:14}}):K(n,e.key)},e.key))},o)})})})}),ye]})}export{S as EntityList};
@@ -1,9 +1,9 @@
1
- import{useOverlayTarget as e,usePopupAnchor as r,OverlayLayerProvider as t}from"./chunk-3DVNXNTF.js";import{useDiscardGuard as i}from"./chunk-R3K2BNFF.js";import{dialogA11y as o}from"./chunk-VWGWZY7A.js";import{useDismissPopupsOnOpen as l}from"./chunk-7QSDPSXP.js";import{useFocusTrap as n,useScrollLock as a}from"./chunk-CDAJKLGL.js";import{Icon as s}from"./chunk-UIWGVOFH.js";import{Z_LAYERS as d}from"./chunk-62LW225J.js";import{useHydrated as c}from"./chunk-D65T4H6J.js";import{useShellStrings as m}from"./chunk-43MCNASD.js";import{registerModalEscapeInterceptor as h}from"./chunk-TWVUQUUD.js";import{useRef as f,useId as u,useState as p,useEffect as b}from"react";import{createPortal as g}from"react-dom";import{jsxs as x,Fragment as y,jsx as v}from"react/jsx-runtime";var w={sm:"sm:w-[320px]",md:"sm:w-[448px]",lg:"sm:w-[640px]"},k={right:"inset-y-0 right-0",left:"inset-y-0 left-0",bottom:"inset-x-0 bottom-0"};function N(e,r){const t=window.innerHeight-(r.top+r.height);if("bottom"===e)return{left:r.left,width:r.width,bottom:t};const i={top:r.top,height:r.height};return"left"===e?{...i,left:r.left}:{...i,right:window.innerWidth-(r.left+r.width)}}function j({onClose:e}){const r=m().dialog;/* @__PURE__ */
2
- return v("button",{type:"button",onClick:e,"aria-label":r.close,className:"rounded-(--radius-control) p-1 text-gray-400 hover:bg-gray-100 hover:text-gray-600 rosh-focus-ring focus-visible:ring-2 focus-visible:ring-[color:var(--rosh-focus-ring-solid)]",children:/* @__PURE__ */v(s,{name:"close",className:"h-5 w-5",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true"})})}function C({open:s,onClose:m,side:C="right",size:W="md",title:D,description:F,footer:H,children:L,blocking:U=!1,dirty:V=!1,initialFocus:z,"aria-label":A,"aria-labelledby":B,"aria-describedby":G,className:I=""}){const J=f(null),S=u(),T=u(),K=u(),P=e(c()),[Q,X]=p(null),M=i({open:s,dirty:V,onClose:m,title:D,layer:Q}),O=f(null),R=r(s&&null!==P,O);if(l(s),n(J,s&&null!==P,z),a(s),b(()=>{if(s)return h(()=>(U||M(),!0),()=>J.current)},[s,U,M]),!s||!P)return null;const Y="bottom"===C,Z={...Y?{maxHeight:"85vh"}:{},...R?N(C,R):{}};/* @__PURE__ */
1
+ import{useOverlayTarget as e,usePopupAnchor as r,OverlayLayerProvider as t}from"./chunk-3DVNXNTF.js";import{useDiscardGuard as i}from"./chunk-2762IAB7.js";import{dialogA11y as o}from"./chunk-VWGWZY7A.js";import{useDismissPopupsOnOpen as l}from"./chunk-7QSDPSXP.js";import{useFocusTrap as n,useScrollLock as a}from"./chunk-CDAJKLGL.js";import{Icon as s}from"./chunk-UIWGVOFH.js";import{Z_LAYERS as d}from"./chunk-62LW225J.js";import{useHydrated as c}from"./chunk-D65T4H6J.js";import{registerModalEscapeInterceptor as m}from"./chunk-TWVUQUUD.js";import{useShellStrings as h}from"./chunk-43MCNASD.js";import{useRef as f,useId as u,useState as p,useEffect as b}from"react";import{createPortal as g}from"react-dom";import{jsxs as x,Fragment as y,jsx as v}from"react/jsx-runtime";var w={sm:"sm:w-[320px]",md:"sm:w-[448px]",lg:"sm:w-[640px]"},k={right:"inset-y-0 right-0",left:"inset-y-0 left-0",bottom:"inset-x-0 bottom-0"};function N(e,r){const t=window.innerHeight-(r.top+r.height);if("bottom"===e)return{left:r.left,width:r.width,bottom:t};const i={top:r.top,height:r.height};return"left"===e?{...i,left:r.left}:{...i,right:window.innerWidth-(r.left+r.width)}}function j({onClose:e}){const r=h().dialog;/* @__PURE__ */
2
+ return v("button",{type:"button",onClick:e,"aria-label":r.close,className:"rounded-(--radius-control) p-1 text-gray-400 hover:bg-gray-100 hover:text-gray-600 rosh-focus-ring focus-visible:ring-2 focus-visible:ring-[color:var(--rosh-focus-ring-solid)]",children:/* @__PURE__ */v(s,{name:"close",className:"h-5 w-5",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true"})})}function C({open:s,onClose:h,side:C="right",size:W="md",title:D,description:A,footer:H,children:I,blocking:L=!1,dirty:U=!1,initialFocus:V,"aria-label":z,"aria-labelledby":B,"aria-describedby":F,className:G=""}){const J=f(null),S=u(),T=u(),P=u(),Q=e(c()),[X,K]=p(null),M=i({open:s,dirty:U,onClose:h,title:D,layer:X}),O=f(null),Y=r(s&&null!==Q,O);if(l(s),n(J,s&&null!==Q,V),a(s),b(()=>{if(s)return m(()=>(L||M(),!0),()=>J.current)},[s,L,M]),!s||!Q)return null;const Z="bottom"===C,$={...Z?{maxHeight:"85vh"}:{},...Y?N(C,Y):{}};/* @__PURE__ */
3
3
  return x(y,{children:[/* @__PURE__ */v("span",{ref:O,hidden:!0,"data-popup-anchor":""}),g(
4
- /* @__PURE__ */v(t,{value:Q,children:/* @__PURE__ */x("div",{ref:X,className:"fixed inset-0",style:{zIndex:d.overlay},role:"presentation","data-overlay-layer":"",children:[
5
- /* @__PURE__ */v("div",{className:"fixed inset-0 bg-black/30",onClick:U?void 0:M,"aria-hidden":"true"}),
6
- /* @__PURE__ */x("div",{ref:J,...o({modal:!0,titleId:D?K:void 0,labelledBy:B,label:A}),"aria-describedby":G??(F?T:L?S:void 0),"data-drawer-side":C,"data-popup-panel":"",style:Z,className:["fixed flex flex-col bg-white shadow-xl",Y?"":`w-full max-w-full ${w[W]}`,R?"":k[C],Y?"rounded-t-xl":"",I].filter(Boolean).join(" "),children:[D?/* @__PURE__ */x("div",{className:"flex shrink-0 items-center justify-between gap-4 border-b border-gray-100 px-4 py-3",children:[
4
+ /* @__PURE__ */v(t,{value:X,children:/* @__PURE__ */x("div",{ref:K,className:"fixed inset-0",style:{zIndex:d.overlay},role:"presentation","data-overlay-layer":"",children:[
5
+ /* @__PURE__ */v("div",{className:"fixed inset-0 bg-black/30",onClick:L?void 0:M,"aria-hidden":"true"}),
6
+ /* @__PURE__ */x("div",{ref:J,...o({modal:!0,titleId:D?P:void 0,labelledBy:B,label:z}),"aria-describedby":F??(A?T:I?S:void 0),"data-drawer-side":C,"data-popup-panel":"",style:$,className:["fixed flex flex-col bg-white shadow-xl",Z?"":`w-full max-w-full ${w[W]}`,Y?"":k[C],Z?"rounded-t-xl":"",G].filter(Boolean).join(" "),children:[D?/* @__PURE__ */x("div",{className:"flex shrink-0 items-center justify-between gap-4 border-b border-gray-100 px-4 py-3",children:[
7
7
  /* @__PURE__ */x("div",{className:"min-w-0",children:[
8
- /* @__PURE__ */v("h2",{id:K,className:"text-base font-semibold text-gray-900",children:D}),F&&/* @__PURE__ */v("p",{id:T,className:"mt-0.5 text-sm text-gray-500",children:F})]}),!U&&/* @__PURE__ */v(j,{onClose:M})]}):!U&&/* @__PURE__ */v("div",{className:"absolute right-2 top-2 z-10",children:/* @__PURE__ */v(j,{onClose:M})}),
9
- /* @__PURE__ */x("div",{id:S,className:"min-h-0 flex-1 overflow-y-auto px-4 py-4",children:[F&&!D&&/* @__PURE__ */v("p",{id:T,className:("mb-3 text-sm text-gray-500 "+(U?"":"pr-8")).trim(),children:F}),L]}),H&&/* @__PURE__ */v("div",{className:"flex shrink-0 justify-end gap-3 border-t border-gray-100 px-4 py-3",children:H})]})]})}),P)]})}export{C as Drawer};
8
+ /* @__PURE__ */v("h2",{id:P,className:"text-base font-semibold text-gray-900",children:D}),A&&/* @__PURE__ */v("p",{id:T,className:"mt-0.5 text-sm text-gray-500",children:A})]}),!L&&/* @__PURE__ */v(j,{onClose:M})]}):!L&&/* @__PURE__ */v("div",{className:"absolute right-2 top-2 z-10",children:/* @__PURE__ */v(j,{onClose:M})}),
9
+ /* @__PURE__ */x("div",{id:S,className:"min-h-0 flex-1 overflow-y-auto px-4 py-4",children:[A&&!D&&/* @__PURE__ */v("p",{id:T,className:("mb-3 text-sm text-gray-500 "+(L?"":"pr-8")).trim(),children:A}),I]}),H&&/* @__PURE__ */v("div",{className:"flex shrink-0 justify-end gap-3 border-t border-gray-100 px-4 py-3",children:H})]})]})}),Q)]})}export{C as Drawer};