@jxsuite/studio 4.0.0 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (613) hide show
  1. package/README.md +1 -1
  2. package/data/elements-meta.json +5 -15
  3. package/data/html-meta.json +51 -6
  4. package/dist/chunks/{2020-xp8vnwma.js → 2020-g79n01v9.js} +14 -14
  5. package/dist/chunks/action-group-sp6tna8v.js +118 -0
  6. package/dist/chunks/adapter-nj7tnjfn.js +13 -0
  7. package/dist/chunks/cf-account-picker-fyf63pmy.js +495 -0
  8. package/dist/chunks/cf-settings-71bv5zn9.js +20 -0
  9. package/dist/chunks/color-area-v17df7b8.js +154 -0
  10. package/dist/chunks/color-field-anwybnkn.js +208 -0
  11. package/dist/chunks/color-slider-44ez96fc.js +79 -0
  12. package/dist/chunks/color-xgg3kfw7.js +35 -0
  13. package/dist/chunks/combobox-5e7jev23.js +236 -0
  14. package/dist/chunks/components-2w1f35qs.js +18 -0
  15. package/dist/chunks/content-source-3wqeas45.js +46 -0
  16. package/dist/chunks/convert-to-repeater-d0cgnb6d.js +639 -0
  17. package/dist/chunks/dialog-s890b918.js +85 -0
  18. package/dist/chunks/editor-3qhbg51x.js +35 -0
  19. package/dist/chunks/entry-commands-d6g50j7s.js +42 -0
  20. package/dist/chunks/extension-sections-fy7q4fe9.js +651 -0
  21. package/dist/chunks/file-ops-3btj6st0.js +47 -0
  22. package/dist/chunks/files-ef8fgs3w.js +72 -0
  23. package/dist/chunks/format-host-3c33nwr8.js +40 -0
  24. package/dist/chunks/fs-events-13tj6sex.js +18 -0
  25. package/dist/chunks/git-panel-4wp2rn9b.js +49 -0
  26. package/dist/chunks/icons-yy10wk9r.js +402 -0
  27. package/dist/chunks/iframe-entry-15g3n6xv.js +114 -0
  28. package/dist/chunks/iframe-entry-b27vq81n.js +203 -0
  29. package/dist/chunks/iframe-entry-nbyxee1y.js +154 -0
  30. package/dist/chunks/iframe-host-jgesd924.js +115 -0
  31. package/dist/chunks/{index-nj44jpzj.js → index-mdmyx6s2.js} +11 -11
  32. package/dist/chunks/index-n4j7qxyr.js +109 -0
  33. package/dist/chunks/{javascript-q8kpmfah.js → javascript-xvrfrpkb.js} +8 -9
  34. package/dist/chunks/{jsonMode-dkr040ga.js → jsonMode-tyx2kj6p.js} +526 -527
  35. package/dist/chunks/jx-validate-j0wxk72w.js +15 -0
  36. package/dist/chunks/layers-1nq5evsh.js +29 -0
  37. package/dist/chunks/layers-panel-ar2gh90g.js +40 -0
  38. package/dist/chunks/listbox-6v2ac08j.js +44 -0
  39. package/dist/chunks/lit-html-m244w9nh.js +17 -0
  40. package/dist/chunks/media-picker-2qbetq73.js +33 -0
  41. package/dist/chunks/menu-q99sy9rf.js +285 -0
  42. package/dist/chunks/menu-rf7n72mf.js +14 -0
  43. package/dist/chunks/{monaco-binding-rj6xpx9y.js → monaco-binding-sw6en4dw.js} +12 -15
  44. package/dist/chunks/monaco-buffer-bhy3hb6m.js +24 -0
  45. package/dist/chunks/{monaco-setup-rws7k4br.js → monaco-setup-8r62fj6y.js} +27 -37
  46. package/dist/chunks/notify-628t0anh.js +21 -0
  47. package/dist/chunks/number-field-5cndyft8.js +72 -0
  48. package/dist/chunks/parse-0zx14y15.js +10 -0
  49. package/dist/chunks/platform-ts9cg1a4.js +15 -0
  50. package/dist/chunks/popover-47z3ytva.js +25 -0
  51. package/dist/chunks/publish-panel-98f7sr3g.js +27 -0
  52. package/dist/chunks/quick-search-srzz83k2.js +45 -0
  53. package/dist/chunks/references-n553f0e1.js +26 -0
  54. package/dist/chunks/right-panel-rrgx2dn3.js +45 -0
  55. package/dist/chunks/section-registry-5pq32t0q.js +25 -0
  56. package/dist/chunks/select-2r16ez41.js +49 -0
  57. package/dist/chunks/split-g7nm1rgb.js +191 -0
  58. package/dist/chunks/studio-0hqbpbd0.js +62 -0
  59. package/dist/chunks/studio-18avnhjp.js +2430 -0
  60. package/dist/chunks/{studio-kryvsw6j.js → studio-1k325pwf.js} +48 -48
  61. package/dist/chunks/{studio-hbtp0eh1.js → studio-25hkdrkw.js} +356 -85
  62. package/dist/chunks/studio-26d7myd1.js +258 -0
  63. package/dist/chunks/{studio-p8j86wag.js → studio-38emantv.js} +22 -5
  64. package/dist/chunks/studio-3gxv60tn.js +422 -0
  65. package/dist/chunks/{studio-8swrjbny.js → studio-3hxkd92t.js} +275 -163
  66. package/dist/chunks/studio-4m0haseg.js +185 -0
  67. package/dist/chunks/{studio-ynxwkrzd.js → studio-4wbb9ct0.js} +1953 -1785
  68. package/dist/chunks/{studio-gv8vvshc.js → studio-5523bpzt.js} +11 -11
  69. package/dist/chunks/{studio-5q69gfag.js → studio-57mf66w2.js} +1753 -2484
  70. package/dist/chunks/studio-5jy81t3s.js +17463 -0
  71. package/dist/chunks/studio-5rt7sqa0.js +1168 -0
  72. package/dist/chunks/studio-5te5tqng.js +81 -0
  73. package/dist/chunks/{studio-p4ngc046.js → studio-6ewqv390.js} +9 -9
  74. package/dist/chunks/{studio-9ab8gqsm.js → studio-6nzaktvy.js} +7 -7
  75. package/dist/chunks/studio-6xa21ej9.js +28 -0
  76. package/dist/chunks/{studio-5ehhackm.js → studio-727xh0e3.js} +19 -19
  77. package/dist/chunks/{studio-eenfkt4e.js → studio-79y5sz51.js} +52 -38
  78. package/dist/chunks/{studio-4q0wznzf.js → studio-7e11jpa9.js} +461 -145
  79. package/dist/chunks/{studio-q7v10cg2.js → studio-7r42c6ca.js} +17 -7
  80. package/dist/chunks/studio-7xptrg0j.js +954 -0
  81. package/dist/chunks/{studio-cft9r4r7.js → studio-81390n6f.js} +22 -22
  82. package/dist/chunks/{studio-q43a5y9h.js → studio-8jn5yhyn.js} +16 -16
  83. package/dist/chunks/studio-8qtrpzr3.js +839 -0
  84. package/dist/chunks/{studio-dg7zyt5x.js → studio-98b3z07n.js} +1 -1
  85. package/dist/chunks/studio-9xxz1q69.js +1356 -0
  86. package/dist/chunks/studio-akbww0j5.js +13615 -0
  87. package/dist/chunks/studio-arfpe389.js +195 -0
  88. package/dist/chunks/{studio-2zkz8evn.js → studio-az3zd49t.js} +473 -281
  89. package/dist/chunks/studio-cpvb2ed1.js +1171 -0
  90. package/dist/chunks/{studio-9r6j5ev1.js → studio-d0300636.js} +5078 -19
  91. package/dist/chunks/{studio-bgxt93ga.js → studio-d055c37e.js} +13 -13
  92. package/dist/chunks/studio-d1ja2x9r.js +362 -0
  93. package/dist/chunks/{studio-b9b6t1dg.js → studio-e1f24eff.js} +5664 -5666
  94. package/dist/chunks/{studio-4pqqxbrt.js → studio-em9nw8eh.js} +301 -112
  95. package/dist/chunks/studio-erdatzvp.js +1190 -0
  96. package/dist/chunks/{studio-g1wdche0.js → studio-esrxgwh6.js} +80 -80
  97. package/dist/chunks/studio-fabxk6r9.js +2811 -0
  98. package/dist/chunks/{studio-3n4ndrzh.js → studio-h4nvnjvz.js} +303 -303
  99. package/dist/chunks/studio-hhvs4sdg.js +195 -0
  100. package/dist/chunks/{studio-68n67094.js → studio-kcgff4r0.js} +15 -18
  101. package/dist/chunks/{studio-685s0ytq.js → studio-nqgawfks.js} +572 -572
  102. package/dist/chunks/{studio-xrapxwwc.js → studio-p1dw8wfw.js} +55 -29
  103. package/dist/chunks/studio-pm6hgy7r.js +4763 -0
  104. package/dist/chunks/studio-q0a3yk4n.js +33 -0
  105. package/dist/chunks/{studio-wcy8trfx.js → studio-q3x06vmj.js} +23 -22
  106. package/dist/chunks/studio-qahxvnan.js +111 -0
  107. package/dist/chunks/{studio-53n8bp04.js → studio-r6xmmtfh.js} +1 -1
  108. package/dist/chunks/{studio-kjjsjak4.js → studio-rkstz940.js} +3661 -6136
  109. package/dist/chunks/{studio-tvgyw9xw.js → studio-rnyf3f8e.js} +83 -250
  110. package/dist/chunks/studio-rpyah2ew.js +2805 -0
  111. package/dist/chunks/studio-rs76k67r.js +12 -0
  112. package/dist/chunks/{studio-yxrkyv8a.js → studio-s6z853aq.js} +12108 -11766
  113. package/dist/chunks/{studio-sf7zjgv1.js → studio-sgdc5pfc.js} +8 -8
  114. package/dist/chunks/studio-tb3ev01j.js +763 -0
  115. package/dist/chunks/{studio-t5wqwzdh.js → studio-tjjk7jvk.js} +1 -1
  116. package/dist/chunks/studio-vhv5tgxm.js +51 -0
  117. package/dist/chunks/{studio-htsf0w6m.js → studio-vz68yn9e.js} +31 -154
  118. package/dist/chunks/studio-wqpngpsk.js +174 -0
  119. package/dist/chunks/{studio-eesa1myv.js → studio-x3rty6tr.js} +58 -58
  120. package/dist/chunks/studio-xsykpvsh.js +8448 -0
  121. package/dist/chunks/{studio-92ab2jqe.js → studio-y9zedyjn.js} +14 -14
  122. package/dist/chunks/studio-yxa81f45.js +12 -0
  123. package/dist/chunks/swatch-group-t0n6h2rn.js +139 -0
  124. package/dist/chunks/tabs-wbp1cdws.js +156 -0
  125. package/dist/chunks/textfield-abk6qyee.js +73 -0
  126. package/dist/chunks/toast-780pvfbv.js +27 -0
  127. package/dist/chunks/toast-host-3sqv46sn.js +116 -0
  128. package/dist/chunks/toolbar-xbh5bhtr.js +194 -0
  129. package/dist/chunks/tooltip-eptb614w.js +369 -0
  130. package/dist/chunks/tree-a73p0pqm.js +367 -0
  131. package/dist/chunks/{tsMode-76kr53q0.js → tsMode-jy4m86rv.js} +83 -85
  132. package/dist/chunks/workspace-wrew8zk4.js +69 -0
  133. package/dist/chunks/{ws-client-6shc5rze.js → ws-client-ny4zc51r.js} +20 -22
  134. package/dist/iframe-entry.js +1812 -698
  135. package/dist/manifest.json +7 -0
  136. package/dist/studio.js +52900 -36573
  137. package/dist/workers/editor.worker.js +1040 -1085
  138. package/dist/workers/json.worker.js +1946 -1991
  139. package/dist/workers/ts.worker.js +4960 -5005
  140. package/favicon.ico +0 -0
  141. package/index.html +2 -0
  142. package/package.json +22 -55
  143. package/src/about/about-modal.ts +73 -123
  144. package/src/browse/library-commands.ts +20 -49
  145. package/src/browse/library-layouts.ts +87 -218
  146. package/src/browse/library-pane.ts +406 -438
  147. package/src/canvas/canvas-helpers.ts +0 -49
  148. package/src/canvas/canvas-live-render.ts +25 -2
  149. package/src/canvas/canvas-render.ts +666 -231
  150. package/src/canvas/canvas-surface.ts +0 -1
  151. package/src/canvas/canvas-utils.ts +310 -117
  152. package/src/canvas/dialog-path.ts +76 -0
  153. package/src/canvas/dialog-state.ts +67 -0
  154. package/src/canvas/diff-marks.ts +252 -0
  155. package/src/canvas/diff-toolbar.ts +349 -0
  156. package/src/canvas/diff-view.ts +123 -0
  157. package/src/canvas/edit-width-drag.ts +187 -0
  158. package/src/canvas/edit-width.ts +150 -0
  159. package/src/canvas/iframe-entry.ts +125 -8
  160. package/src/canvas/iframe-host.ts +271 -15
  161. package/src/canvas/iframe-interaction.ts +133 -13
  162. package/src/canvas/iframe-patch.ts +7 -1
  163. package/src/canvas/iframe-position.ts +5 -6
  164. package/src/canvas/iframe-protocol.ts +106 -5
  165. package/src/canvas/iframe-render.ts +373 -5
  166. package/src/canvas/iframe-slash.ts +2 -2
  167. package/src/canvas/iframe-subtree.ts +5 -8
  168. package/src/canvas/path-mapping.ts +25 -3
  169. package/src/canvas/popover-path.ts +106 -0
  170. package/src/canvas/popover-state.ts +155 -0
  171. package/src/canvas/surface-registry.ts +21 -10
  172. package/src/collab/presence-chips.ts +51 -73
  173. package/src/commands/app-commands.ts +10 -0
  174. package/src/commands/budget.ts +12 -0
  175. package/src/commands/command-args.ts +369 -6
  176. package/src/commands/defaults.ts +44 -14
  177. package/src/commands/live-context.ts +11 -5
  178. package/src/commands/reference.ts +12 -2
  179. package/src/commands/registry.ts +165 -8
  180. package/src/content/entry-commands.ts +16 -23
  181. package/src/content/entry-editor.ts +144 -101
  182. package/src/editor/canvas-slash-bridge.ts +2 -2
  183. package/src/editor/context-menu.ts +49 -200
  184. package/src/editor/convert-to-component.ts +42 -82
  185. package/src/editor/convert-to-repeater.ts +132 -173
  186. package/src/editor/inline-edit.ts +11 -0
  187. package/src/editor/shortcuts.ts +65 -26
  188. package/src/editor/slash-menu.ts +150 -157
  189. package/src/files/file-ops.ts +117 -11
  190. package/src/files/files.ts +949 -664
  191. package/src/files/json-layout.ts +474 -0
  192. package/src/files/media-paths.ts +13 -42
  193. package/src/files/media-usage.ts +41 -131
  194. package/src/files/serialize-document.ts +8 -1
  195. package/src/format/convert-file.ts +16 -10
  196. package/src/format/format-host.ts +50 -1
  197. package/src/github/github-auth.ts +71 -29
  198. package/src/github/github-publish.ts +57 -65
  199. package/src/grid/cell-editors.ts +46 -4
  200. package/src/grid/cell-popovers.ts +65 -62
  201. package/src/grid/grid-open.ts +86 -64
  202. package/src/grid/grid-panel.ts +390 -469
  203. package/src/grid/redirects-grid.ts +40 -44
  204. package/src/hosting/document.ts +2 -0
  205. package/src/hosting/layout.ts +10 -0
  206. package/src/i18n/i18n-commands.ts +127 -62
  207. package/src/media/media-pane.ts +83 -133
  208. package/src/new-project/add-repo-modal.ts +125 -176
  209. package/src/new-project/import-tab.ts +201 -250
  210. package/src/new-project/location-fields.ts +101 -165
  211. package/src/new-project/new-project-modal.ts +376 -367
  212. package/src/packages/jxsuite-update.ts +76 -18
  213. package/src/panels/activity-panel.ts +137 -104
  214. package/src/panels/ai-chat/chat-markdown.ts +15 -13
  215. package/src/panels/ai-chat/chat-view.ts +307 -472
  216. package/src/panels/ai-chat/composer.ts +175 -153
  217. package/src/panels/ai-chat/sessions-view.ts +31 -62
  218. package/src/panels/ai-panel.ts +210 -185
  219. package/src/panels/block-action-bar.ts +437 -643
  220. package/src/panels/bottom-dock.ts +112 -47
  221. package/src/panels/chat-panel.ts +19 -14
  222. package/src/panels/data-explorer.ts +141 -102
  223. package/src/panels/data-grid.ts +183 -150
  224. package/src/panels/dnd.ts +75 -20
  225. package/src/panels/editors.ts +26 -19
  226. package/src/panels/elements-panel.ts +243 -186
  227. package/src/panels/empty-state.ts +26 -42
  228. package/src/panels/events-panel.ts +950 -729
  229. package/src/panels/formula-workspace.ts +434 -207
  230. package/src/panels/frontmatter-fields.ts +185 -153
  231. package/src/panels/frontmatter-panel.ts +411 -187
  232. package/src/panels/git-diff-open.ts +148 -0
  233. package/src/panels/git-panel.ts +679 -605
  234. package/src/panels/head-panel.ts +617 -435
  235. package/src/panels/i18n-panel.ts +153 -133
  236. package/src/panels/imports-panel.ts +388 -414
  237. package/src/panels/jump-bar.ts +174 -147
  238. package/src/panels/layers-panel.ts +785 -671
  239. package/src/panels/left-panel.ts +166 -94
  240. package/src/panels/navigator-panels.ts +1 -1
  241. package/src/panels/pane-context.ts +529 -677
  242. package/src/panels/pane-grid.ts +265 -241
  243. package/src/panels/panel-registry.ts +15 -4
  244. package/src/panels/problems-panel.ts +177 -99
  245. package/src/panels/properties-panel.ts +1525 -966
  246. package/src/panels/provenance.ts +31 -113
  247. package/src/panels/quick-search.ts +217 -172
  248. package/src/panels/right-panel.ts +135 -169
  249. package/src/panels/seo-modal.ts +346 -167
  250. package/src/panels/settings-menu.ts +109 -646
  251. package/src/panels/settings-pane.ts +102 -86
  252. package/src/panels/signals-panel.ts +1318 -1172
  253. package/src/panels/statement-editor.ts +556 -428
  254. package/src/panels/style-panel.ts +1367 -630
  255. package/src/panels/style-utils.ts +36 -32
  256. package/src/panels/stylebook-doc.ts +30 -73
  257. package/src/panels/stylebook-layers-panel.ts +202 -109
  258. package/src/panels/stylebook-panel.ts +124 -88
  259. package/src/panels/tab-strip.ts +385 -287
  260. package/src/platforms/cloud.ts +347 -86
  261. package/src/platforms/devserver.ts +13 -0
  262. package/src/publish/deploy-checklist.ts +124 -78
  263. package/src/publish/publish-commands.ts +4 -12
  264. package/src/publish/publish-panel.ts +165 -299
  265. package/src/services/a11y-report.ts +100 -43
  266. package/src/services/ai-command-tools.ts +468 -0
  267. package/src/services/ai-import-tools.ts +50 -12
  268. package/src/services/ai-models.ts +108 -1
  269. package/src/services/ai-session-store.ts +6 -0
  270. package/src/services/ai-system-prompt.ts +110 -18
  271. package/src/services/ai-tools.ts +28 -143
  272. package/src/services/ai-write-report.ts +174 -0
  273. package/src/services/context-manager.ts +12 -1
  274. package/src/services/document-assistant.ts +50 -2
  275. package/src/services/idle.ts +16 -14
  276. package/src/services/live-surfaces.ts +237 -0
  277. package/src/services/model-uri.ts +75 -0
  278. package/src/services/notify.ts +63 -6
  279. package/src/services/popover-report.ts +325 -0
  280. package/src/services/surface-registry.ts +56 -0
  281. package/src/services/tool-executor.ts +17 -0
  282. package/src/settings/contexts-section.ts +301 -299
  283. package/src/settings/contributed-section.ts +361 -222
  284. package/src/settings/css-vars-editor.ts +320 -325
  285. package/src/settings/defs-editor.ts +572 -535
  286. package/src/settings/dependencies-editor.ts +79 -107
  287. package/src/settings/extension-commands.ts +379 -0
  288. package/src/settings/extension-rows.ts +113 -0
  289. package/src/settings/extensions-section.ts +287 -0
  290. package/src/settings/general-settings.ts +130 -181
  291. package/src/settings/head-editor.ts +10 -305
  292. package/src/settings/locales-section.ts +146 -196
  293. package/src/settings/preferences-accounts.ts +193 -12
  294. package/src/settings/preferences-dialog.ts +384 -307
  295. package/src/settings/project-sections.ts +108 -181
  296. package/src/settings/schema-field-ui.ts +11 -399
  297. package/src/settings/section-registry.ts +8 -1
  298. package/src/settings/settings-document.ts +31 -29
  299. package/src/shell/tree.ts +42 -87
  300. package/src/shell.ts +48 -36
  301. package/src/studio.ts +90 -67
  302. package/src/style/token-ref.ts +0 -39
  303. package/src/surfaces/about.json +263 -0
  304. package/src/surfaces/about.ts +163 -0
  305. package/src/surfaces/add-repo.json +486 -0
  306. package/src/surfaces/add-repo.ts +236 -0
  307. package/src/surfaces/ai-chat.json +2185 -0
  308. package/src/surfaces/ai-chat.ts +549 -0
  309. package/src/surfaces/ai-credentials-form.json +332 -0
  310. package/src/surfaces/ai-credentials-form.ts +151 -0
  311. package/src/surfaces/ai-managed-connect.json +108 -0
  312. package/src/surfaces/ai-managed-connect.ts +123 -0
  313. package/src/surfaces/ai-model-picker.json +114 -0
  314. package/src/surfaces/ai-model-picker.ts +139 -0
  315. package/src/surfaces/block-action-bar.json +640 -0
  316. package/src/surfaces/block-action-bar.ts +368 -0
  317. package/src/surfaces/bottom-dock.json +154 -0
  318. package/src/surfaces/bottom-dock.ts +125 -0
  319. package/src/surfaces/canvas-stage.json +444 -0
  320. package/src/surfaces/canvas-stage.ts +253 -0
  321. package/src/surfaces/cf-account-picker.json +300 -0
  322. package/src/surfaces/cf-account-picker.ts +214 -0
  323. package/src/surfaces/commandbar.json +984 -0
  324. package/src/{panels/toolbar.ts → surfaces/commandbar.ts} +414 -389
  325. package/src/surfaces/convert-repeater.json +309 -0
  326. package/src/surfaces/convert-repeater.ts +276 -0
  327. package/src/surfaces/data-actions.json +157 -0
  328. package/src/surfaces/data-actions.ts +115 -0
  329. package/src/surfaces/dialog.json +289 -0
  330. package/src/surfaces/dialog.ts +343 -0
  331. package/src/surfaces/diff-toolbar.json +266 -0
  332. package/src/surfaces/diff-toolbar.ts +139 -0
  333. package/src/surfaces/doc-header.json +739 -0
  334. package/src/surfaces/doc-header.ts +223 -0
  335. package/src/surfaces/empty-state.json +152 -0
  336. package/src/surfaces/empty-state.ts +173 -0
  337. package/src/surfaces/entry-editor.json +281 -0
  338. package/src/surfaces/entry-editor.ts +191 -0
  339. package/src/surfaces/expression-editor.json +977 -0
  340. package/src/surfaces/expression-editor.ts +266 -0
  341. package/src/surfaces/files-panel.json +592 -0
  342. package/src/surfaces/files-panel.ts +301 -0
  343. package/src/surfaces/formula-palette.json +364 -0
  344. package/src/surfaces/formula-palette.ts +340 -0
  345. package/src/surfaces/git-panel.json +1822 -0
  346. package/src/surfaces/git-panel.ts +272 -0
  347. package/src/surfaces/github-auth.json +112 -0
  348. package/src/surfaces/github-auth.ts +139 -0
  349. package/src/surfaces/github-publish.json +206 -0
  350. package/src/surfaces/github-publish.ts +169 -0
  351. package/src/surfaces/grid-cell.json +218 -0
  352. package/src/surfaces/grid-cell.ts +120 -0
  353. package/src/surfaces/grid-open.json +147 -0
  354. package/src/surfaces/grid-open.ts +87 -0
  355. package/src/surfaces/grid-panel.json +706 -0
  356. package/src/surfaces/grid-panel.ts +206 -0
  357. package/src/surfaces/grid-replace.json +179 -0
  358. package/src/surfaces/grid-replace.ts +89 -0
  359. package/src/surfaces/grid-views.json +446 -0
  360. package/src/surfaces/grid-views.ts +172 -0
  361. package/src/surfaces/inspector-dock.json +187 -0
  362. package/src/surfaces/inspector-dock.ts +161 -0
  363. package/src/surfaces/jump-bar.json +243 -0
  364. package/src/surfaces/jump-bar.ts +129 -0
  365. package/src/surfaces/jxsuite-update.json +146 -0
  366. package/src/surfaces/jxsuite-update.ts +149 -0
  367. package/src/surfaces/library-pane.json +1509 -0
  368. package/src/surfaces/library-pane.ts +363 -0
  369. package/src/surfaces/logic-panel.json +1949 -0
  370. package/src/surfaces/logic-panel.ts +369 -0
  371. package/src/surfaces/logic-workspace.json +685 -0
  372. package/src/surfaces/logic-workspace.ts +238 -0
  373. package/src/surfaces/media-browser.json +303 -0
  374. package/src/surfaces/media-browser.ts +145 -0
  375. package/src/surfaces/media-field.json +163 -0
  376. package/src/surfaces/media-field.ts +116 -0
  377. package/src/surfaces/media-pane.json +513 -0
  378. package/src/surfaces/media-pane.ts +197 -0
  379. package/src/surfaces/menu.json +232 -0
  380. package/src/surfaces/menu.ts +375 -0
  381. package/src/surfaces/navigator-dock.json +113 -0
  382. package/src/surfaces/navigator-dock.ts +130 -0
  383. package/src/surfaces/new-project.json +1654 -0
  384. package/src/surfaces/new-project.ts +411 -0
  385. package/src/surfaces/palette.json +535 -0
  386. package/src/surfaces/pane-context.json +1497 -0
  387. package/src/surfaces/pane-context.ts +513 -0
  388. package/src/surfaces/pane-grid.json +188 -0
  389. package/src/surfaces/pane-grid.ts +250 -0
  390. package/src/surfaces/panel-activity.json +563 -0
  391. package/src/surfaces/panel-activity.ts +187 -0
  392. package/src/surfaces/panel-data.json +141 -0
  393. package/src/surfaces/panel-data.ts +156 -0
  394. package/src/surfaces/panel-deploy-checklist.json +283 -0
  395. package/src/surfaces/panel-deploy-checklist.ts +175 -0
  396. package/src/surfaces/panel-elements.json +367 -0
  397. package/src/surfaces/panel-elements.ts +175 -0
  398. package/src/surfaces/panel-i18n.json +569 -0
  399. package/src/surfaces/panel-i18n.ts +212 -0
  400. package/src/surfaces/panel-imports.json +780 -0
  401. package/src/surfaces/panel-imports.ts +209 -0
  402. package/src/surfaces/panel-outline.json +734 -0
  403. package/src/surfaces/panel-outline.ts +326 -0
  404. package/src/surfaces/panel-page.json +1017 -0
  405. package/src/surfaces/panel-page.ts +240 -0
  406. package/src/surfaces/panel-problems.json +497 -0
  407. package/src/surfaces/panel-problems.ts +157 -0
  408. package/src/surfaces/panel-signals.json +1973 -0
  409. package/src/surfaces/panel-signals.ts +436 -0
  410. package/src/surfaces/panel-stylebook-layers.json +317 -0
  411. package/src/surfaces/panel-stylebook-layers.ts +155 -0
  412. package/src/surfaces/preferences.json +850 -0
  413. package/src/surfaces/preferences.ts +332 -0
  414. package/src/surfaces/progress-modal.json +110 -0
  415. package/src/surfaces/progress-modal.ts +150 -0
  416. package/src/surfaces/properties-panel.json +1578 -0
  417. package/src/surfaces/properties-panel.ts +337 -0
  418. package/src/surfaces/publish.json +945 -0
  419. package/src/surfaces/publish.ts +392 -0
  420. package/src/surfaces/push-plan.json +110 -0
  421. package/src/surfaces/push-plan.ts +87 -0
  422. package/src/surfaces/rail.json +255 -0
  423. package/src/surfaces/rail.ts +206 -0
  424. package/src/surfaces/reference-field.json +191 -0
  425. package/src/surfaces/reference-field.ts +168 -0
  426. package/src/surfaces/schema-builder.json +1011 -0
  427. package/src/surfaces/schema-builder.ts +181 -0
  428. package/src/surfaces/schema-form.json +1013 -0
  429. package/src/surfaces/schema-form.ts +287 -0
  430. package/src/surfaces/secret-field.json +60 -0
  431. package/src/surfaces/secret-field.ts +146 -0
  432. package/src/surfaces/seo.json +932 -0
  433. package/src/surfaces/seo.ts +334 -0
  434. package/src/surfaces/settings-contexts.json +538 -0
  435. package/src/surfaces/settings-contexts.ts +196 -0
  436. package/src/surfaces/settings-contributed.json +489 -0
  437. package/src/surfaces/settings-contributed.ts +199 -0
  438. package/src/surfaces/settings-css-vars.json +820 -0
  439. package/src/surfaces/settings-css-vars.ts +199 -0
  440. package/src/surfaces/settings-defs.json +1363 -0
  441. package/src/surfaces/settings-defs.ts +232 -0
  442. package/src/surfaces/settings-deploy.json +108 -0
  443. package/src/surfaces/settings-deploy.ts +135 -0
  444. package/src/surfaces/settings-extensions.json +486 -0
  445. package/src/surfaces/settings-extensions.ts +201 -0
  446. package/src/surfaces/settings-head.json +779 -0
  447. package/src/surfaces/settings-head.ts +397 -0
  448. package/src/surfaces/settings-locales.json +420 -0
  449. package/src/surfaces/settings-locales.ts +137 -0
  450. package/src/surfaces/settings-overview.json +423 -0
  451. package/src/surfaces/settings-overview.ts +218 -0
  452. package/src/surfaces/settings-packages.json +549 -0
  453. package/src/surfaces/settings-packages.ts +158 -0
  454. package/src/surfaces/settings-pane.json +147 -0
  455. package/src/surfaces/settings-pane.ts +150 -0
  456. package/src/surfaces/settings-rawjson.json +104 -0
  457. package/src/surfaces/settings-rawjson.ts +107 -0
  458. package/src/surfaces/shell.json +99 -0
  459. package/src/surfaces/shell.ts +30 -0
  460. package/src/surfaces/slash-menu.json +180 -0
  461. package/src/surfaces/slash-menu.ts +272 -0
  462. package/src/surfaces/statements.json +607 -0
  463. package/src/surfaces/statements.ts +238 -0
  464. package/src/surfaces/statusbar.json +94 -0
  465. package/src/{panels → surfaces}/statusbar.ts +163 -90
  466. package/src/surfaces/style-panel.json +1643 -0
  467. package/src/surfaces/style-panel.ts +338 -0
  468. package/src/surfaces/stylebook-chrome.json +122 -0
  469. package/src/surfaces/stylebook-chrome.ts +122 -0
  470. package/src/surfaces/tab-strip.json +448 -0
  471. package/src/surfaces/tab-strip.ts +200 -0
  472. package/src/surfaces/target-line.json +419 -0
  473. package/src/surfaces/target-line.ts +349 -0
  474. package/src/surfaces/toasts.json +189 -0
  475. package/src/surfaces/welcome.json +571 -0
  476. package/src/surfaces/welcome.ts +338 -0
  477. package/src/tabs/project-config.ts +71 -15
  478. package/src/tabs/tab.ts +52 -1
  479. package/src/types.ts +49 -3
  480. package/src/ui/ai-credentials-form.ts +104 -100
  481. package/src/ui/ai-managed-connect.ts +116 -49
  482. package/src/ui/ai-model-picker.ts +102 -47
  483. package/src/ui/cf-account-picker.ts +135 -0
  484. package/src/ui/color-selector.ts +80 -301
  485. package/src/ui/dynamic-slot.ts +43 -283
  486. package/src/ui/expression-editor.ts +797 -576
  487. package/src/ui/field-input.ts +8 -181
  488. package/src/ui/form-controls.ts +838 -366
  489. package/src/ui/formula-chips.ts +80 -85
  490. package/src/ui/kit.ts +33 -0
  491. package/src/ui/layers.ts +293 -593
  492. package/src/ui/media-picker.ts +203 -284
  493. package/src/ui/panel-resize.ts +251 -64
  494. package/src/ui/popover-surface.ts +153 -0
  495. package/src/ui/progress-modal.ts +22 -60
  496. package/src/ui/regions.ts +13 -7
  497. package/src/ui/schema-form.ts +906 -440
  498. package/src/ui/surface.ts +122 -0
  499. package/src/ui/unit-selector.ts +15 -131
  500. package/src/ui/value-source.ts +14 -0
  501. package/src/ui/virtual-window.ts +88 -9
  502. package/src/utils/canvas-media.ts +72 -0
  503. package/src/utils/edit-display.ts +7 -2
  504. package/src/utils/element-selectors.ts +69 -0
  505. package/src/utils/link-target.ts +2 -2
  506. package/src/utils/studio-utils.ts +0 -10
  507. package/src/view.ts +15 -0
  508. package/src/workspace/pane-derive.ts +36 -14
  509. package/src/workspace/workspace.ts +15 -6
  510. package/styles/canvas.css +72 -467
  511. package/styles/forced-colors.css +48 -82
  512. package/styles/forced-colors.json +41 -0
  513. package/styles/inspector.css +2 -1301
  514. package/styles/overlays.css +96 -2823
  515. package/styles/panels.css +6 -1423
  516. package/styles/shell-frame.css +272 -0
  517. package/styles/shell-frame.json +227 -0
  518. package/styles/shell.css +0 -1532
  519. package/styles/tokens.css +65 -136
  520. package/styles/tokens.json +84 -0
  521. package/dist/chunks/Overlay.dev-723bv0df.js +0 -23
  522. package/dist/chunks/adapter-jkcyhgtr.js +0 -14
  523. package/dist/chunks/cf-settings-45fgyx8y.js +0 -21
  524. package/dist/chunks/components-zmx10t62.js +0 -21
  525. package/dist/chunks/content-source-t88vb2dr.js +0 -49
  526. package/dist/chunks/convert-to-repeater-dhw1nrz9.js +0 -268
  527. package/dist/chunks/editor-cptq5jp1.js +0 -37
  528. package/dist/chunks/entry-commands-6z6bhxg0.js +0 -46
  529. package/dist/chunks/extension-sections-3ydgjbdy.js +0 -311
  530. package/dist/chunks/file-ops-rskmhxyq.js +0 -48
  531. package/dist/chunks/files-0cratsr0.js +0 -92
  532. package/dist/chunks/flow-qbfgrpeh.js +0 -634
  533. package/dist/chunks/focus-trap.esm-ggawf1hy.js +0 -1024
  534. package/dist/chunks/focus-visible-6eg70z18.js +0 -167
  535. package/dist/chunks/format-host-tgcmfs4p.js +0 -43
  536. package/dist/chunks/fs-events-hrrg328g.js +0 -21
  537. package/dist/chunks/git-panel-0yywyk76.js +0 -58
  538. package/dist/chunks/index-zqxmqxmh.js +0 -109
  539. package/dist/chunks/jx-validate-8q2g05x1.js +0 -19
  540. package/dist/chunks/layers-panel-z3tqe5cd.js +0 -67
  541. package/dist/chunks/layers-q75tj2mf.js +0 -45
  542. package/dist/chunks/lit-html-j055mkh8.js +0 -22
  543. package/dist/chunks/monaco-buffer-dqw0xxpx.js +0 -25
  544. package/dist/chunks/notify-yjm79n4s.js +0 -30
  545. package/dist/chunks/parse-24d0gay3.js +0 -19
  546. package/dist/chunks/platform-ba1j1gbh.js +0 -16
  547. package/dist/chunks/publish-panel-54jvhskq.js +0 -28
  548. package/dist/chunks/quick-search-cgfmjwq5.js +0 -65
  549. package/dist/chunks/references-3qx8fkyp.js +0 -29
  550. package/dist/chunks/right-panel-cqp8bc4v.js +0 -46
  551. package/dist/chunks/section-registry-sx1ykvkw.js +0 -30
  552. package/dist/chunks/sp-overlay.dev-yztmtrs1.js +0 -18
  553. package/dist/chunks/sp-popover.dev-n2etmqdp.js +0 -9
  554. package/dist/chunks/sp-progress-circle.dev-hryhj0es.js +0 -15
  555. package/dist/chunks/sp-tooltip.dev-xcvpnqr0.js +0 -15
  556. package/dist/chunks/sp-tray.dev-tkbscm06.js +0 -199
  557. package/dist/chunks/studio-0a5qrh01.js +0 -3
  558. package/dist/chunks/studio-18j3bmcz.js +0 -14
  559. package/dist/chunks/studio-1hbqnt19.js +0 -1823
  560. package/dist/chunks/studio-4rzyrtjz.js +0 -426
  561. package/dist/chunks/studio-5rywrkxz.js +0 -1903
  562. package/dist/chunks/studio-7afd21nw.js +0 -67
  563. package/dist/chunks/studio-7nte2hj4.js +0 -613
  564. package/dist/chunks/studio-8jpzqk5s.js +0 -128
  565. package/dist/chunks/studio-8q517dfr.js +0 -24
  566. package/dist/chunks/studio-9c4k4vhv.js +0 -357
  567. package/dist/chunks/studio-9n4mrmnb.js +0 -184
  568. package/dist/chunks/studio-a0tswy0w.js +0 -58
  569. package/dist/chunks/studio-ahjfdy6e.js +0 -387
  570. package/dist/chunks/studio-ahnzd9rg.js +0 -23
  571. package/dist/chunks/studio-bw5dz6km.js +0 -608
  572. package/dist/chunks/studio-cb12yz9w.js +0 -15055
  573. package/dist/chunks/studio-d1ks410h.js +0 -175
  574. package/dist/chunks/studio-eqq1w638.js +0 -113
  575. package/dist/chunks/studio-ex8zyp98.js +0 -1813
  576. package/dist/chunks/studio-h4rxscfc.js +0 -10
  577. package/dist/chunks/studio-kyh9avvv.js +0 -28
  578. package/dist/chunks/studio-kyk2v92a.js +0 -659
  579. package/dist/chunks/studio-m3hwn7y1.js +0 -120
  580. package/dist/chunks/studio-mmv72a27.js +0 -4344
  581. package/dist/chunks/studio-n8b9wqwy.js +0 -291
  582. package/dist/chunks/studio-pdfjntbk.js +0 -6939
  583. package/dist/chunks/studio-qq6jym04.js +0 -53
  584. package/dist/chunks/studio-r1r7afxx.js +0 -1066
  585. package/dist/chunks/studio-rdx8jcxy.js +0 -83
  586. package/dist/chunks/studio-rn9ta2mz.js +0 -111
  587. package/dist/chunks/studio-t7qb9db8.js +0 -665
  588. package/dist/chunks/studio-tmc5emrw.js +0 -8
  589. package/dist/chunks/studio-txwkm6p9.js +0 -12
  590. package/dist/chunks/studio-v38hmvx1.js +0 -390
  591. package/dist/chunks/studio-vadzgkrz.js +0 -318
  592. package/dist/chunks/studio-wx5609xd.js +0 -341
  593. package/dist/chunks/studio-z6nw2ek2.js +0 -18
  594. package/dist/chunks/studio-zczps70q.js +0 -378
  595. package/dist/chunks/workspace-xpres40v.js +0 -89
  596. package/src/panels/activity-bar.ts +0 -251
  597. package/src/panels/panel-scheduler.ts +0 -219
  598. package/src/panels/style-inputs.ts +0 -237
  599. package/src/panels/target-line.ts +0 -274
  600. package/src/panels/welcome-screen.ts +0 -346
  601. package/src/ui/button-group.ts +0 -102
  602. package/src/ui/choice-field.ts +0 -72
  603. package/src/ui/field-row.ts +0 -249
  604. package/src/ui/formula-palette.ts +0 -213
  605. package/src/ui/icons.ts +0 -52
  606. package/src/ui/jx-theme.ts +0 -130
  607. package/src/ui/spectrum.ts +0 -340
  608. package/src/ui/value-selector.ts +0 -174
  609. package/src/ui/widgets.ts +0 -172
  610. /package/dist/chunks/{javascript-s56a8dpk.css → javascript-4abzjcy9.css} +0 -0
  611. /package/dist/chunks/{jsonMode-zr9sw0c7.css → jsonMode-vvmpmk34.css} +0 -0
  612. /package/dist/chunks/{monaco-setup-pav68602.css → monaco-setup-8vbyqnhr.css} +0 -0
  613. /package/dist/chunks/{tsMode-ef187txx.css → tsMode-hnxxb73h.css} +0 -0
@@ -0,0 +1,2805 @@
1
+ import {
2
+ getPlatform2,
3
+ hasPlatform2
4
+ } from "./studio-6nzaktvy.js";
5
+ import {
6
+ displayTagName
7
+ } from "./studio-7r42c6ca.js";
8
+ import {
9
+ errorMessage2
10
+ } from "./studio-yxa81f45.js";
11
+ import {
12
+ loadUsages2,
13
+ usageWarning2
14
+ } from "./studio-81390n6f.js";
15
+ import {
16
+ effectScope,
17
+ onScopeDispose,
18
+ effect,
19
+ reactive,
20
+ toRaw,
21
+ now,
22
+ problems2,
23
+ notify2,
24
+ clearProblems2,
25
+ problemFindings2,
26
+ problemCount2
27
+ } from "./studio-p1dw8wfw.js";
28
+ import {
29
+ loadFormats2,
30
+ formatByName2,
31
+ noFormatError2,
32
+ formatForPath2,
33
+ defaultContentFormat2,
34
+ formatParse2,
35
+ formatSerialize2,
36
+ splitFormatDocument2
37
+ } from "./studio-79y5sz51.js";
38
+ import {
39
+ getNodeAtPath2,
40
+ childList,
41
+ pathsEqual,
42
+ nodeLabel,
43
+ projectState,
44
+ statusbarEl
45
+ } from "./studio-6ewqv390.js";
46
+ import {
47
+ EDITOR_KIND_LABELS,
48
+ primarySelection,
49
+ transactDoc,
50
+ setHistoryDelegate,
51
+ mutateUpdateStyle,
52
+ mutateUpdateAttribute,
53
+ mutateUpdateNestedStyle,
54
+ mutateUpdateNestedStylePath,
55
+ collabState,
56
+ isMediaFormat,
57
+ collabReadOnly,
58
+ collabSave,
59
+ PRIMARY_PANE2,
60
+ workspace2,
61
+ activeTab2
62
+ } from "./studio-az3zd49t.js";
63
+ import {
64
+ isMediaFile
65
+ } from "./studio-vz68yn9e.js";
66
+ import {
67
+ POPOVER_DEFAULT_MODE,
68
+ findPopoverDefects,
69
+ popoverDisplayRepair,
70
+ POPOVER_TAGS,
71
+ INVOKER_TAGS,
72
+ activeRegistry
73
+ } from "./studio-5jy81t3s.js";
74
+ import {
75
+ paneRegion,
76
+ registerSurface,
77
+ mountSurface,
78
+ showConfirmDialog2
79
+ } from "./studio-erdatzvp.js";
80
+ import {
81
+ openMenu2
82
+ } from "./studio-3gxv60tn.js";
83
+ import {
84
+ parseJsonDocument,
85
+ serializeJson,
86
+ shell
87
+ } from "./studio-25hkdrkw.js";
88
+ import {
89
+ deployStatusItem
90
+ } from "./studio-tb3ev01j.js";
91
+ import {
92
+ tabOfPane,
93
+ derivationOfPane,
94
+ findDialogDefects,
95
+ flushCanvasEdits2
96
+ } from "./studio-rkstz940.js";
97
+ import {
98
+ isRecentLocal2
99
+ } from "./studio-8jn5yhyn.js";
100
+ import {
101
+ showProgressModal,
102
+ loadMediaUsages
103
+ } from "./studio-cpvb2ed1.js";
104
+ import {
105
+ validateComponentSlots
106
+ } from "./studio-q0a3yk4n.js";
107
+ // src/surfaces/jump-bar.json
108
+ var jump_bar_default = {
109
+ $schema: "https://jxsuite.com/schema/v1",
110
+ $id: "StudioJumpBar",
111
+ $description: "⑥ The jump bar: one pane's address, outermost step first, every step a command the adapter has already resolved against the registry. A step is a button when its command can run and a readout when it cannot — an address with a hole in it is a lie about containment, so a step never disappears. A step with more than one place to go carries the chevron that opens its siblings; one alternative is not a choice and draws no control. Nothing here decides what the bar says, which step is where you are, or what a chevron opens.",
112
+ tagName: "nav",
113
+ attributes: {
114
+ part: "bar",
115
+ "aria-label": "Location",
116
+ "data-jx-region": "${state.region}",
117
+ hidden: "${state.empty ? '' : null}"
118
+ },
119
+ style: {
120
+ $description: "The `.jump-bar` rules the bar used to take from `styles/shell.css`, brought here and re-valued onto the kit's own layer. It scrolls rather than wraps — a deep selection must not push the stage down by a second line — and the overflow is taken at the START, because the leaf is the part being read. The height is the one number this file shares with its adapter: the stage's `--jump-bar-h` offset must be the box this rule draws.",
121
+ display: "flex",
122
+ alignItems: "center",
123
+ gap: "1px",
124
+ height: "24px",
125
+ padding: "0 var(--jx-space-3)",
126
+ minWidth: "0",
127
+ overflowX: "auto",
128
+ scrollbarWidth: "none",
129
+ whiteSpace: "nowrap",
130
+ boxSizing: "border-box",
131
+ fontFamily: "var(--jx-font-sans)",
132
+ fontSize: "var(--jx-text-xs)",
133
+ color: "var(--jx-fg-dim)",
134
+ background: "var(--jx-bg-panel)",
135
+ borderBottom: "1px solid var(--jx-border)",
136
+ "&[hidden]": {
137
+ display: "none"
138
+ },
139
+ "&::-webkit-scrollbar": {
140
+ display: "none"
141
+ },
142
+ '& [part="step"]': {
143
+ display: "flex",
144
+ alignItems: "center",
145
+ flexShrink: "0"
146
+ },
147
+ '& [part="separator"]': {
148
+ flexShrink: "0",
149
+ padding: "0 1px",
150
+ color: "var(--jx-fg-dim)",
151
+ opacity: "0.6"
152
+ },
153
+ '& [part="crumb"]': {
154
+ maxWidth: "28ch",
155
+ overflow: "hidden",
156
+ margin: "0",
157
+ padding: "0 var(--jx-space-2)",
158
+ border: "none",
159
+ borderRadius: "var(--jx-radius-xs)",
160
+ background: "transparent",
161
+ color: "inherit",
162
+ font: "inherit",
163
+ lineHeight: "1",
164
+ whiteSpace: "nowrap",
165
+ textOverflow: "ellipsis"
166
+ },
167
+ '& button[part="crumb"]': {
168
+ cursor: "pointer",
169
+ ":hover:not(:disabled)": {
170
+ color: "var(--jx-fg)",
171
+ background: "var(--jx-hover-bg)"
172
+ },
173
+ ":disabled": {
174
+ cursor: "default",
175
+ opacity: "0.6"
176
+ },
177
+ ":focus-visible": {
178
+ outline: "var(--jx-focus-ring)",
179
+ outlineOffset: "-2px"
180
+ }
181
+ },
182
+ '& [part="crumb"][aria-current]': {
183
+ $description: "Where you ARE is stated by weight, not by taking the control away: the leaf still selects, which is how a stray click in the canvas is undone without leaving the bar.",
184
+ color: "var(--jx-fg)"
185
+ },
186
+ '& span[part="crumb"]': {
187
+ $description: "A step with no runnable command is a readout, not a dead button. No hover, no pointer, no promise.",
188
+ cursor: "default"
189
+ },
190
+ '& [part="alternatives"]': {
191
+ padding: "0 1px",
192
+ border: "none",
193
+ borderRadius: "var(--jx-radius-xs)",
194
+ background: "transparent",
195
+ color: "inherit",
196
+ font: "inherit",
197
+ lineHeight: "1",
198
+ cursor: "pointer",
199
+ ":hover": {
200
+ color: "var(--jx-fg)",
201
+ background: "var(--jx-hover-bg)"
202
+ },
203
+ ":focus-visible": {
204
+ outline: "var(--jx-focus-ring)",
205
+ outlineOffset: "-2px"
206
+ }
207
+ }
208
+ },
209
+ children: [
210
+ {
211
+ $prototype: "Array",
212
+ items: {
213
+ $ref: "#/state/segments"
214
+ },
215
+ key: {
216
+ $ref: "$map/item/key"
217
+ },
218
+ map: {
219
+ tagName: "span",
220
+ attributes: {
221
+ part: "step",
222
+ "data-jump-kind": "${$map.item.kind}"
223
+ },
224
+ children: [
225
+ {
226
+ tagName: "span",
227
+ attributes: {
228
+ part: "separator-slot",
229
+ role: "none"
230
+ },
231
+ style: {
232
+ display: "contents"
233
+ },
234
+ $switch: {
235
+ $ref: "$map/item/leading"
236
+ },
237
+ cases: {
238
+ false: {
239
+ tagName: "span",
240
+ attributes: {
241
+ part: "separator",
242
+ "aria-hidden": "true"
243
+ },
244
+ textContent: "›"
245
+ }
246
+ }
247
+ },
248
+ {
249
+ tagName: "span",
250
+ attributes: {
251
+ part: "crumb-slot",
252
+ role: "none"
253
+ },
254
+ style: {
255
+ display: "contents"
256
+ },
257
+ $switch: {
258
+ $ref: "$map/item/control"
259
+ },
260
+ cases: {
261
+ button: {
262
+ tagName: "button",
263
+ attributes: {
264
+ part: "crumb",
265
+ type: "button",
266
+ title: "${$map.item.title}",
267
+ "aria-current": "${$map.item.current ? 'true' : null}",
268
+ disabled: {
269
+ $ref: "$map/item/disabled"
270
+ }
271
+ },
272
+ textContent: "${$map.item.label}",
273
+ onclick: {
274
+ $prototype: "Function",
275
+ body: [
276
+ {
277
+ operator: "call",
278
+ target: {
279
+ $ref: "#/state/run"
280
+ },
281
+ value: [
282
+ {
283
+ $ref: "$map/item/key"
284
+ }
285
+ ]
286
+ }
287
+ ]
288
+ }
289
+ },
290
+ readout: {
291
+ tagName: "span",
292
+ attributes: {
293
+ part: "crumb",
294
+ title: "${$map.item.title}",
295
+ "aria-current": "${$map.item.current ? 'true' : null}"
296
+ },
297
+ textContent: "${$map.item.label}"
298
+ }
299
+ }
300
+ },
301
+ {
302
+ tagName: "span",
303
+ attributes: {
304
+ part: "alternatives-slot",
305
+ role: "none"
306
+ },
307
+ style: {
308
+ display: "contents"
309
+ },
310
+ $switch: {
311
+ $ref: "$map/item/hasChoices"
312
+ },
313
+ cases: {
314
+ true: {
315
+ tagName: "button",
316
+ attributes: {
317
+ part: "alternatives",
318
+ type: "button",
319
+ "aria-haspopup": "menu",
320
+ "aria-label": "${$map.item.altsLabel}",
321
+ title: "${$map.item.altsLabel}"
322
+ },
323
+ textContent: "⌄",
324
+ onclick: {
325
+ $prototype: "Function",
326
+ body: [
327
+ {
328
+ operator: "call",
329
+ target: {
330
+ $ref: "#/state/choose"
331
+ },
332
+ value: [
333
+ {
334
+ $ref: "$map/item/key"
335
+ },
336
+ {
337
+ $ref: "event#/currentTarget"
338
+ }
339
+ ]
340
+ }
341
+ ]
342
+ }
343
+ }
344
+ }
345
+ }
346
+ ]
347
+ }
348
+ }
349
+ ]
350
+ };
351
+
352
+ // src/surfaces/jump-bar.ts
353
+ registerSurface("jump-bar", jump_bar_default);
354
+ function mountJumpBarSurface(host, region, actions) {
355
+ const scope = reactive({
356
+ ...actions,
357
+ empty: true,
358
+ region,
359
+ segments: []
360
+ });
361
+ host.replaceChildren();
362
+ let mounted = null;
363
+ let disposed = false;
364
+ mountSurface("jump-bar", scope, host).then((surface) => {
365
+ if (disposed) {
366
+ surface.dispose();
367
+ return;
368
+ }
369
+ mounted = surface;
370
+ });
371
+ return {
372
+ dispose() {
373
+ disposed = true;
374
+ mounted?.dispose();
375
+ mounted = null;
376
+ host.replaceChildren();
377
+ },
378
+ update(steps) {
379
+ scope.segments = [...steps];
380
+ scope.empty = steps.length === 0;
381
+ }
382
+ };
383
+ }
384
+ // src/surfaces/pane-grid.json
385
+ var pane_grid_default = {
386
+ $schema: "https://jxsuite.com/schema/v1",
387
+ $id: "StudioPaneGrid",
388
+ $description: "The pane grid (studio.md §18.1): one cell per pane, with a splitter before every cell but the first. Every box here is EMPTY by design — the four inside a cell are hosts other modules fill (`panels/tab-strip.ts` the strip, `panels/jump-bar.ts` the jump bar, `panels/pane-context.ts` the chrome layer, `canvas/canvas-render.ts` the stage), and the stage is an ISLAND in the §9.4 sense: the canvas host mounts a cross-origin `<iframe>` into it, so nothing this document draws may ever go inside it. What the document owns is the STRUCTURE and the STYLE — the cell's own two-row grid, the three row-2 children that share its lower cell, and the splitter — which is `styles/shell.css`'s `.pane*` block and `styles/canvas.css`'s `.pane-stage` rule, carried here and keyed on `part`. Two things are load-bearing and easy to undo. (1) **A row that moves reloads an iframe**, so the keyed `$map` is not an optimisation: `workspace.panes[0]` is always the primary and `MAX_PANES` is 2, the key is the pane id, and the runtime's forward-cursor pass therefore never moves a kept row — gaining or losing the side pane leaves the primary's node, and the frame inside it, untouched. (2) **The splitter must sit BETWEEN two cells and inside neither**, so each row is a `display: contents` wrapper holding its own leading splitter and its cell: the wrapper generates no box, so the splitter and the two cells are the grid items of `#pane-grid` in DOM order, and a pointer landing on the splitter is in no cell at all. Every selector below is a `>` chain from the root, because a pane's stage hosts other surface documents and a bare `[part=\"row\"]` descendant rule would reach into them.",
389
+ tagName: "div",
390
+ attributes: {
391
+ part: "grid",
392
+ role: "none"
393
+ },
394
+ style: {
395
+ $description: "The pane's own layout, and the splitter's. The tracks of `#pane-grid` ITSELF are not here and must not be: the track count depends on `workspace.panes.length` and the split on `shell.paneSplit`, which is written on every `pointermove` of a drag — `panels/pane-grid.ts` writes them as one inline `grid-template-columns` on the host, so a drag moves a track edge and never a node. The splitter's own paint is not here either: `jx-split` owns the hairline, the cursors and the drag state it mirrors as `data-dragging`, so this block says only where the element is placed.",
396
+ display: "contents",
397
+ '& > [part="row"]': {
398
+ $description: "One pane's row: its leading splitter and its cell, generating no box of their own so both are grid items of `#pane-grid`.",
399
+ display: "contents"
400
+ },
401
+ '& > [part="row"] > [part="splitter-slot"]': {
402
+ display: "contents"
403
+ },
404
+ '& > [part="row"] > [part="splitter-slot"] > jx-split': {
405
+ $description: "WHERE the splitter sits, and nothing about what it looks like: the hairline, the two cursors, the hover and drag colours and the focus ring are `jx-split`'s own, and the `.dragging` class this block used to name is gone with the module that wrote it — the element mirrors its own gesture as `data-dragging` and paints itself. BOTH grid axes are `auto`: a definite row position — the `2 / 4` a column handle inherits on the APP grid, or the `1 / -1` this rule used to carry — moves the item into an earlier step of CSS Grid's auto-placement, so the splitter claimed column 1 and the two cells flowed around it into the 5px track and the second half. DOM order was already right; the placement algorithm was not reading it. `width: auto` with `justify-self: stretch` is what hands the thickness back to the TRACK `panels/pane-grid.ts` writes, so the element's own 5px default cannot disagree with the column it is placed in.",
406
+ gridRow: "auto",
407
+ gridColumn: "auto",
408
+ justifySelf: "stretch",
409
+ margin: "0",
410
+ width: "auto",
411
+ zIndex: "10"
412
+ },
413
+ '& > [part="row"] > [part="pane"]': {
414
+ $description: 'ONE PANE, and one COLUMN, declared. Three children name `grid-row: 2` in order to share the lower cell, and auto-placement answers that by inventing an implicit column each: the jump bar, the chrome layer and the stage lined up side by side, the stage taking a third of the pane and pinning the document to the right edge. `grid-template-columns` is what makes "share the cell" mean it, and every row-2 child restates `grid-column: 1` so a future fourth one cannot re-open the same hole. No unit test can see this — happy-dom does no layout, so every rect is zero — which is why the screenshot lane is what caught it.',
415
+ display: "grid",
416
+ gridTemplateColumns: "minmax(0, 1fr)",
417
+ gridTemplateRows: "auto minmax(0, 1fr)",
418
+ minWidth: "0",
419
+ minHeight: "0"
420
+ },
421
+ '& > [part="row"] > [part="pane"] > [part="strip"]': {
422
+ gridRow: "1",
423
+ gridColumn: "1",
424
+ minHeight: "0",
425
+ minWidth: "0"
426
+ },
427
+ '& > [part="row"] > [part="pane"] > [part="strip"]:empty': {
428
+ $description: "A pane with nothing to say costs no band. The strip host is empty until `panels/tab-strip.ts` mounts a document into it, and empty again the moment it disposes.",
429
+ display: "none"
430
+ },
431
+ '& > [part="row"] > [part="pane"] > [part="jump"]': {
432
+ $description: "Region ⑥. Like the chrome layer below it this shares the pane's lower cell rather than owning a row, so the two bars stack OVER the stage instead of pushing it down. `align-self: start` is what keeps it the height of its own content instead of the height of the cell, so the bar never covers the stage it sits above.",
433
+ gridRow: "2",
434
+ gridColumn: "1",
435
+ alignSelf: "start",
436
+ position: "relative",
437
+ zIndex: "3",
438
+ minWidth: "0",
439
+ maxWidth: "100%"
440
+ },
441
+ '& > [part="row"] > [part="pane"] > [part="chrome"]': {
442
+ $description: 'Regions ⑦ and ⑩. The layer itself is inert and only its children take the pointer; `surfaces/pane-context.json` owns what they look like. Offset by `--jump-bar-h` for the same reason the stage is: the jump bar is stacked over this same cell, and one projection per bar is what keeps "no tab open" costing no dead band.',
443
+ gridRow: "2",
444
+ gridColumn: "1",
445
+ marginTop: "var(--jump-bar-h, 0px)",
446
+ position: "relative",
447
+ zIndex: "2",
448
+ minWidth: "0",
449
+ display: "flex",
450
+ flexDirection: "column",
451
+ justifyContent: "space-between",
452
+ pointerEvents: "none"
453
+ },
454
+ '& > [part="row"] > [part="pane"] > [part="chrome"] > *': {
455
+ pointerEvents: "auto"
456
+ },
457
+ '& > [part="row"] > [part="pane"] > [part="pane-stage"]': {
458
+ $description: "The stage: the pane's own axis (`styles/canvas.css`) over its placement in the cell (`styles/shell.css`). Offset by the SUM of the two bars stacked over this cell — `--jump-bar-h` (written by `panels/jump-bar.ts`) and `--pane-context-h` (by `panels/pane-context.ts`), both onto the CELL, which is why this reads them by cascade — so neither ever covers the document, and by zero when no tab is open, so the welcome screen does not sit under a band nothing explains. Two variables rather than one total: each bar owns its own answer, and a bar that renders nothing writes 0 without knowing the other exists.",
459
+ gridRow: "2",
460
+ gridColumn: "1",
461
+ marginTop: "calc(var(--jump-bar-h, 0px) + var(--pane-context-h, 0px))",
462
+ position: "relative",
463
+ overflow: "auto",
464
+ background: "var(--bg-panel)",
465
+ minWidth: "0",
466
+ display: "flex",
467
+ gap: "var(--jx-space-6)",
468
+ alignItems: "flex-start"
469
+ }
470
+ },
471
+ children: [
472
+ {
473
+ $description: "Keyed on the PANE ID, and that is the whole of §18.1 rule 1's structural half: the key is what makes the runtime MOVE a kept row rather than rebuild it, and re-parenting is not a move for an `<iframe>` — it reloads, dropping its `iframe-channel` connection, its shadow document and every `ready` panel with it. A row renders complete (its cell, its four hosts and its splitter) inside the row's own effect scope before it is inserted, so there is no frame in which a cell exists with no stage inside it.",
474
+ $prototype: "Array",
475
+ items: { $ref: "#/state/rows" },
476
+ key: { $ref: "$map/item/id" },
477
+ map: {
478
+ tagName: "div",
479
+ attributes: {
480
+ part: "row",
481
+ role: "none"
482
+ },
483
+ children: [
484
+ {
485
+ $description: "Present on every cell but the first. It is a child of the ROW rather than of either cell, so a splitter drag never reaches the cell's pane-focus listener — and it is created and destroyed with the second pane, so nothing re-inserts it while a pointer capture is live.",
486
+ tagName: "div",
487
+ attributes: {
488
+ part: "splitter-slot",
489
+ role: "none"
490
+ },
491
+ $switch: { $ref: "$map/item/split" },
492
+ cases: {
493
+ shown: {
494
+ $description: '`jx-split` (ui.md §5.5), which is where `role="separator"`, the tab stop, `aria-valuenow` and the whole keyboard now live. This document used to write the role on a bare div and hand the div to `ui/panel-resize.ts`, which made the pane split the one dock-sized thing in Studio a reader could not move without a mouse — an SC 2.1.1 failure with a drag handle drawn on it, and an SC 2.5.7 one besides. Every prop below is a CONSTANT except `value`: `min` and `max` are the shell\'s own supported range, and `gap` is the pixel floor the element converts against the track it measures itself, which is why nothing here has to be recomputed when the window resizes. `collapse` is the even split rather than the floor, because both sides of this splitter are real panes: the first Enter or double click is the 50/50 reset this gesture has always been, and the second one is the return trip it never had.',
495
+ tagName: "jx-split",
496
+ attributes: {
497
+ part: "splitter"
498
+ },
499
+ $props: {
500
+ label: "Pane split",
501
+ value: { $ref: "#/state/paneSplit" },
502
+ min: { $ref: "#/state/splitMin" },
503
+ max: { $ref: "#/state/splitMax" },
504
+ gap: { $ref: "#/state/splitGap" },
505
+ collapse: { $ref: "#/state/splitDefault" }
506
+ },
507
+ oninput: {
508
+ $prototype: "Function",
509
+ body: [
510
+ {
511
+ operator: "call",
512
+ target: { $ref: "#/state/move" },
513
+ value: [{ $ref: "event#/target/value" }]
514
+ }
515
+ ]
516
+ },
517
+ onchange: {
518
+ $prototype: "Function",
519
+ body: [
520
+ {
521
+ operator: "call",
522
+ target: { $ref: "#/state/settle" },
523
+ value: []
524
+ }
525
+ ]
526
+ }
527
+ }
528
+ }
529
+ },
530
+ {
531
+ $description: 'One pane\'s cell. `pane.<id>` goes on the STAGE and `pane.<id>/tabs` on the strip, never on this element: nine shots crop `pane.primary` meaning "the canvas", and moving the id up one level would silently widen all nine to include the strip and the two bars, which no gate can tell from an intended crop.',
532
+ tagName: "div",
533
+ attributes: {
534
+ part: "pane",
535
+ "data-pane-id": "${$map.item.id}"
536
+ },
537
+ children: [
538
+ {
539
+ tagName: "div",
540
+ attributes: {
541
+ part: "strip",
542
+ "data-jx-region": "${$map.item.stripRegion}"
543
+ }
544
+ },
545
+ {
546
+ $description: "The jump bar and the context bar are HANDED this box rather than resolving a region into it. They cannot resolve one the way the strip does: nothing inside the strip re-stamps `pane.<id>/tabs`, while both bars stamp `pane.<id>/jump` and `pane.<id>/context` on markup they render INSIDE these two divs — so a region on the wrapper as well would put the same id on two nested elements, and `resolveRegion` takes the LAST match. Sixty shots crop `pane.primary/context`; a second, larger element carrying it is a silently widened crop.",
547
+ tagName: "div",
548
+ attributes: {
549
+ part: "jump"
550
+ }
551
+ },
552
+ {
553
+ tagName: "div",
554
+ attributes: {
555
+ part: "chrome"
556
+ }
557
+ },
558
+ {
559
+ $description: "Drawn EMPTY and left empty. `canvas/canvas-render.ts` is this element's render root and `canvas/iframe-host.ts` mounts the artboards' iframes into it; a node cannot have two owners of its child list.",
560
+ tagName: "div",
561
+ attributes: {
562
+ part: "pane-stage",
563
+ "data-jx-region": "${$map.item.region}"
564
+ }
565
+ }
566
+ ]
567
+ }
568
+ ]
569
+ }
570
+ }
571
+ ]
572
+ };
573
+
574
+ // src/surfaces/pane-grid.ts
575
+ registerSurface("pane-grid", pane_grid_default);
576
+ var PANE_PART = "pane";
577
+ var STAGE_PART = "pane-stage";
578
+ var PANE_SELECTOR = `[part="${PANE_PART}"]`;
579
+ var STAGE_SELECTOR = `[part="${STAGE_PART}"]`;
580
+ var CELL_PARTS = new Map([
581
+ ["pane", "pane"],
582
+ ["strip", "strip"],
583
+ ["jump", "jump"],
584
+ ["chrome", "chrome"],
585
+ ["pane-stage", "stage"]
586
+ ]);
587
+ function partOf(def) {
588
+ const part = typeof def === "string" ? undefined : def.attributes?.["part"];
589
+ return typeof part === "string" ? part : "";
590
+ }
591
+ function paneOf(state) {
592
+ const row = state?.["$map"]?.item;
593
+ return typeof row?.id === "string" ? row.id : "";
594
+ }
595
+ function mountPaneGridSurface(host, rows, split, actions) {
596
+ host.replaceChildren();
597
+ const scope = reactive({
598
+ move: actions.move,
599
+ paneSplit: split.value,
600
+ rows,
601
+ settle: actions.settle,
602
+ splitDefault: split.collapse,
603
+ splitGap: split.gap,
604
+ splitMax: split.max,
605
+ splitMin: split.min
606
+ });
607
+ let mounted = null;
608
+ let disposed = false;
609
+ const ready = mountSurface("pane-grid", scope, host, {
610
+ onNodeCreated: (element, _path, def, state) => {
611
+ const cellPart = CELL_PARTS.get(partOf(def));
612
+ if (cellPart) {
613
+ actions.cellPart(paneOf(state), cellPart, element);
614
+ }
615
+ }
616
+ }).then((surface) => {
617
+ if (disposed) {
618
+ surface.dispose();
619
+ return;
620
+ }
621
+ mounted = surface;
622
+ });
623
+ return {
624
+ dispose() {
625
+ disposed = true;
626
+ mounted?.dispose();
627
+ mounted = null;
628
+ host.replaceChildren();
629
+ },
630
+ ready,
631
+ update(next, value) {
632
+ scope.rows = next;
633
+ scope.paneSplit = value;
634
+ }
635
+ };
636
+ }
637
+
638
+ // src/panels/jump-bar.ts
639
+ var JUMP_BAR_VAR = "--jump-bar-h";
640
+ var JUMP_BAR_HEIGHT = 24;
641
+ function documentLabel(path) {
642
+ if (!path) {
643
+ return "Untitled";
644
+ }
645
+ const root = projectState?.projectRoot;
646
+ return root && path.startsWith(`${root}/`) ? path.slice(root.length + 1) : path;
647
+ }
648
+ function selectionCrumbs(document2, selection) {
649
+ const crumbs = [];
650
+ for (let i = 0;i < selection.length; ) {
651
+ const seg = selection[i];
652
+ const step = seg === "map" ? 1 : 2;
653
+ const path = selection.slice(0, i + step);
654
+ const node = getNodeAtPath2(document2, path);
655
+ const fallbackTag = node?.tag;
656
+ const label = node?.$prototype === "Array" ? "Repeater" : displayTagName(node?.tagName) || (typeof fallbackTag === "string" ? fallbackTag : "") || (seg === "cases" ? String(selection[i + 1]) : `[${selection[i + 1]}]`);
657
+ crumbs.push({ label, path });
658
+ i += step;
659
+ }
660
+ return crumbs;
661
+ }
662
+ function crumbSiblings(document2, crumbs, index) {
663
+ const crumb = crumbs[index];
664
+ if (!crumb) {
665
+ return [];
666
+ }
667
+ const parentPath = index === 0 ? [] : crumbs[index - 1].path;
668
+ const parent = getNodeAtPath2(document2, parentPath);
669
+ const key = crumb.path.at(-2);
670
+ const own = crumb.path;
671
+ if (key === "cases") {
672
+ const cases = parent?.cases;
673
+ if (!cases || typeof cases !== "object") {
674
+ return [];
675
+ }
676
+ return Object.keys(cases).map((name) => {
677
+ const path = [...parentPath, "cases", name];
678
+ return choiceFor(document2, path, name, own);
679
+ });
680
+ }
681
+ if (key !== "children") {
682
+ return [];
683
+ }
684
+ const choices = [];
685
+ for (const [i, child] of childList(parent).entries()) {
686
+ if (typeof child === "string") {
687
+ continue;
688
+ }
689
+ const path = [...parentPath, "children", i];
690
+ choices.push(choiceFor(document2, path, nodeLabel(child), own));
691
+ }
692
+ return choices;
693
+ }
694
+ function choiceFor(document2, path, fallback, own) {
695
+ const node = getNodeAtPath2(document2, path);
696
+ const label = node ? nodeLabel(node) : fallback;
697
+ const choice = { args: { path }, command: "selection.set", label };
698
+ return pathsEqual(path, own) ? { ...choice, current: true } : choice;
699
+ }
700
+ function jumpSegments(tab, derived = null) {
701
+ if (!tab) {
702
+ return [];
703
+ }
704
+ const segments = [];
705
+ const project = projectState;
706
+ if (project) {
707
+ segments.push({
708
+ choices: [],
709
+ command: "project.openRecent",
710
+ kind: "project",
711
+ label: project.name,
712
+ title: project.projectRoot
713
+ });
714
+ }
715
+ segments.push({
716
+ choices: [],
717
+ command: derived ? "pane.pin" : "palette.openFiles",
718
+ kind: "file",
719
+ label: documentLabel(tab.documentPath),
720
+ title: tab.documentPath ?? "Not saved to disk yet"
721
+ });
722
+ const editingFunction = tab.session.ui.editingFunction;
723
+ const editingFormula = tab.session.ui.editingFormula;
724
+ if (editingFunction) {
725
+ segments.push(editorSegment("ƒ", editingFunction));
726
+ return segments;
727
+ }
728
+ if (editingFormula) {
729
+ segments.push(editorSegment("fx", editingFormula));
730
+ return segments;
731
+ }
732
+ const selection = primarySelection(tab.session.selection);
733
+ if (selection && selection.length > 0) {
734
+ const crumbs = selectionCrumbs(tab.doc.document, selection);
735
+ for (const [i, crumb] of crumbs.entries()) {
736
+ const node = getNodeAtPath2(tab.doc.document, crumb.path);
737
+ segments.push({
738
+ args: { path: crumb.path },
739
+ choices: crumbSiblings(tab.doc.document, crumbs, i),
740
+ command: "selection.set",
741
+ kind: "node",
742
+ label: i === crumbs.length - 1 && node ? nodeLabel(node) : crumb.label,
743
+ title: crumb.path.join(" / ")
744
+ });
745
+ }
746
+ }
747
+ return segments;
748
+ }
749
+ function editorSegment(sigil, def) {
750
+ return {
751
+ choices: [],
752
+ command: null,
753
+ kind: "editor",
754
+ label: `${sigil} ${def.defName ?? def.eventKey ?? "editor"}`
755
+ };
756
+ }
757
+ function stepKey(segment) {
758
+ const path = segment.args?.path;
759
+ return segment.kind === "node" && Array.isArray(path) ? `node:${path.join("/")}` : segment.kind;
760
+ }
761
+ function runnable(registry, id) {
762
+ return id !== null && Boolean(registry?.get(id)) && registry.isVisible(id);
763
+ }
764
+ function segmentTitle(registry, segment, id) {
765
+ const command = registry.get(id);
766
+ const reason = registry.disabledReason(id);
767
+ const chord = registry.keymap.formatBinding(id);
768
+ const suffix = reason ? `${command.title} — requires ${reason}` : chord ? `${command.title} (${chord})` : command.title;
769
+ return segment.title ? `${segment.title} · ${suffix}` : suffix;
770
+ }
771
+ function projectStep(registry, segment, first, last) {
772
+ const id = segment.command;
773
+ const live = runnable(registry, id);
774
+ return {
775
+ altsLabel: `Siblings of ${segment.label}`,
776
+ control: live ? "button" : "readout",
777
+ current: last,
778
+ disabled: live && registry.disabledReason(id) !== undefined,
779
+ hasChoices: registry !== null && segment.choices.length > 1,
780
+ key: stepKey(segment),
781
+ kind: segment.kind,
782
+ label: segment.label,
783
+ leading: first,
784
+ title: live ? segmentTitle(registry, segment, id) : segment.title ?? segment.label
785
+ };
786
+ }
787
+ var _bars = new Map;
788
+ var _scope = null;
789
+ var _menu = null;
790
+ function dismissJumpMenu() {
791
+ const menu = _menu;
792
+ _menu = null;
793
+ menu?.close();
794
+ }
795
+ function openChoices(segment, anchor) {
796
+ const registry = activeRegistry();
797
+ if (!registry) {
798
+ return;
799
+ }
800
+ dismissJumpMenu();
801
+ const rows = segment.choices.map((choice, i) => ({
802
+ checked: choice.current === true ? "true" : "false",
803
+ destructive: false,
804
+ disabled: false,
805
+ dividerAbove: false,
806
+ id: String(i),
807
+ run: () => {
808
+ registry.run(choice.command, choice.args);
809
+ },
810
+ title: choice.label
811
+ }));
812
+ const handle = openMenu2({
813
+ label: `Go to a sibling of ${segment.label}`,
814
+ onClosed: (closed) => {
815
+ if (_menu === closed) {
816
+ _menu = null;
817
+ }
818
+ },
819
+ opener: anchor,
820
+ region: "jump-bar",
821
+ rows
822
+ });
823
+ _menu = handle;
824
+ }
825
+ function applyJumpBarOffset(height, host) {
826
+ const target = host?.closest(PANE_SELECTOR) ?? document.documentElement;
827
+ target.style.setProperty(JUMP_BAR_VAR, `${height}px`);
828
+ }
829
+ function projectPane(paneId) {
830
+ const segments = jumpSegments(tabOfPane(paneId), derivationOfPane(paneId));
831
+ const registry = activeRegistry();
832
+ return {
833
+ segments,
834
+ steps: segments.map((segment, i) => projectStep(registry, segment, i === 0, i === segments.length - 1))
835
+ };
836
+ }
837
+ function renderJumpBar(paneId) {
838
+ if (_bars.size === 0) {
839
+ return;
840
+ }
841
+ dismissJumpMenu();
842
+ for (const [id, bar] of _bars) {
843
+ if (paneId !== undefined && id !== paneId) {
844
+ continue;
845
+ }
846
+ const { segments, steps } = projectPane(id);
847
+ bar.segments = new Map(steps.map((step, i) => [step.key, segments[i]]));
848
+ bar.surface.update(steps);
849
+ applyJumpBarOffset(steps.length === 0 ? 0 : JUMP_BAR_HEIGHT, bar.host);
850
+ }
851
+ }
852
+ function attachJumpBarHost(paneId, host) {
853
+ const previous = _bars.get(paneId);
854
+ if (previous?.host === host) {
855
+ return;
856
+ }
857
+ if (previous) {
858
+ previous.surface.dispose();
859
+ applyJumpBarOffset(0, previous.host);
860
+ _bars.delete(paneId);
861
+ }
862
+ if (!host) {
863
+ return;
864
+ }
865
+ const bar = {
866
+ host,
867
+ segments: new Map,
868
+ surface: mountJumpBarSurface(host, paneRegion(paneId, "jump"), {
869
+ choose: (key, anchor) => {
870
+ const segment = _bars.get(paneId)?.segments.get(key);
871
+ if (segment) {
872
+ openChoices(segment, anchor);
873
+ }
874
+ },
875
+ run: (key) => {
876
+ const segment = _bars.get(paneId)?.segments.get(key);
877
+ const registry = activeRegistry();
878
+ if (segment?.command && registry) {
879
+ registry.run(segment.command, segment.args);
880
+ }
881
+ }
882
+ })
883
+ };
884
+ _bars.set(paneId, bar);
885
+ renderJumpBar(paneId);
886
+ }
887
+ function mountJumpBar(host) {
888
+ unmountJumpBar();
889
+ attachJumpBarHost(PRIMARY_PANE2, host);
890
+ _scope = effectScope();
891
+ _scope.run(() => {
892
+ effect(() => {
893
+ activeRegistry();
894
+ projectState?.name;
895
+ for (const pane of workspace2.panes) {
896
+ const tab = tabOfPane(pane.id);
897
+ if (!tab) {
898
+ continue;
899
+ }
900
+ tab.doc.document;
901
+ tab.documentPath;
902
+ tab.session.selection.map((path) => path.join("/")).join("|");
903
+ tab.session.ui.editingFormula;
904
+ tab.session.ui.editingFunction;
905
+ }
906
+ renderJumpBar();
907
+ });
908
+ });
909
+ }
910
+ function unmountJumpBar() {
911
+ dismissJumpMenu();
912
+ _scope?.stop();
913
+ _scope = null;
914
+ for (const bar of _bars.values()) {
915
+ bar.surface.dispose();
916
+ applyJumpBarOffset(0, bar.host);
917
+ }
918
+ _bars.clear();
919
+ applyJumpBarOffset(0);
920
+ }
921
+
922
+ // src/panels/ai-chat/sessions-view.ts
923
+ var MINUTE = 60000;
924
+ var HOUR = 60 * MINUTE;
925
+ var DAY = 24 * HOUR;
926
+ function relativeTime(ts, at = now()) {
927
+ const delta = Math.max(0, at - ts);
928
+ if (delta < MINUTE) {
929
+ return "just now";
930
+ }
931
+ if (delta < HOUR) {
932
+ return `${Math.floor(delta / MINUTE)}m ago`;
933
+ }
934
+ if (delta < DAY) {
935
+ return `${Math.floor(delta / HOUR)}h ago`;
936
+ }
937
+ if (delta < 2 * DAY) {
938
+ return "yesterday";
939
+ }
940
+ if (delta < 7 * DAY) {
941
+ return `${Math.floor(delta / DAY)}d ago`;
942
+ }
943
+ return new Date(ts).toLocaleDateString();
944
+ }
945
+ function projectSession(session) {
946
+ const count = session.messageCount;
947
+ return {
948
+ key: session.id,
949
+ meta: `${relativeTime(session.updatedAt)} · ${count} ${count === 1 ? "message" : "messages"}`,
950
+ title: session.title
951
+ };
952
+ }
953
+ function projectSessions(sessions) {
954
+ return sessions.map((session) => projectSession(session));
955
+ }
956
+ // src/surfaces/statusbar.json
957
+ var statusbar_default = {
958
+ $schema: "https://jxsuite.com/schema/v1",
959
+ $id: "StudioStatusbar",
960
+ $description: "The status bar: ambient state in the shell's level order, PROJECT then DOCUMENT then SELECTION. The adapter hands in `fields`, each with its region and its items; an item with a command is a button that runs it through `run`, and an item without one is a readout. Nothing here decides what the bar says.",
961
+ tagName: "div",
962
+ attributes: { part: "bar" },
963
+ style: {
964
+ display: "flex",
965
+ alignItems: "stretch",
966
+ flex: "1",
967
+ minWidth: "0",
968
+ '& > [part="field"]': {
969
+ display: "flex",
970
+ alignItems: "center",
971
+ gap: "2px",
972
+ minWidth: "0",
973
+ padding: "0 var(--jx-space-3)"
974
+ },
975
+ '& > [part="field"]:last-child': { overflow: "hidden" },
976
+ '& > [part="field"] + [part="field"]': { borderLeft: "1px solid var(--jx-border)" },
977
+ '& [part="item"], & [part="state"]': {
978
+ maxWidth: "32ch",
979
+ overflow: "hidden",
980
+ margin: "0",
981
+ padding: "0 var(--jx-space-2)",
982
+ border: "none",
983
+ borderRadius: "var(--jx-radius-xs)",
984
+ background: "transparent",
985
+ color: "inherit",
986
+ font: "inherit",
987
+ lineHeight: "1",
988
+ whiteSpace: "nowrap",
989
+ textOverflow: "ellipsis"
990
+ },
991
+ '& [part="item"]': {
992
+ cursor: "pointer",
993
+ ":hover:not(:disabled)": { color: "var(--jx-fg)", background: "var(--jx-hover-bg)" },
994
+ ":disabled": { cursor: "default", opacity: "0.6" },
995
+ ":focus-visible": { outline: "var(--jx-focus-ring)", outlineOffset: "-2px" }
996
+ },
997
+ '& [part="state"]': { cursor: "default" }
998
+ },
999
+ children: [
1000
+ {
1001
+ $prototype: "Array",
1002
+ items: { $ref: "#/state/fields" },
1003
+ key: { $ref: "$map/item/id" },
1004
+ map: {
1005
+ tagName: "div",
1006
+ attributes: { part: "field", "data-jx-region": "${$map.item.region}" },
1007
+ children: [
1008
+ {
1009
+ $prototype: "Array",
1010
+ items: { $ref: "$map/item/items" },
1011
+ key: { $ref: "$map/item/key" },
1012
+ map: {
1013
+ tagName: "span",
1014
+ attributes: { part: "slot" },
1015
+ style: { display: "contents" },
1016
+ $switch: { $ref: "$map/item/kind" },
1017
+ cases: {
1018
+ button: {
1019
+ tagName: "button",
1020
+ attributes: {
1021
+ part: "item",
1022
+ type: "button",
1023
+ title: "${$map.item.title}",
1024
+ disabled: { $ref: "$map/item/disabled" }
1025
+ },
1026
+ textContent: "${$map.item.label}",
1027
+ onclick: {
1028
+ $prototype: "Function",
1029
+ body: [
1030
+ {
1031
+ operator: "call",
1032
+ target: { $ref: "#/state/run" },
1033
+ value: [{ $ref: "$map/item/key" }]
1034
+ }
1035
+ ]
1036
+ }
1037
+ },
1038
+ state: {
1039
+ tagName: "span",
1040
+ attributes: { part: "state", title: "${$map.item.title}" },
1041
+ textContent: "${$map.item.label}"
1042
+ }
1043
+ }
1044
+ }
1045
+ }
1046
+ ]
1047
+ }
1048
+ }
1049
+ ]
1050
+ };
1051
+
1052
+ // src/surfaces/statusbar.ts
1053
+ registerSurface("statusbar", statusbar_default);
1054
+ var _scope2 = null;
1055
+ var _savedAt = new Map;
1056
+ function noteDocumentSaved(path) {
1057
+ if (path) {
1058
+ _savedAt.set(path, now());
1059
+ }
1060
+ }
1061
+ function projectItem(registry, region, item) {
1062
+ if (item.command === null) {
1063
+ return {
1064
+ args: undefined,
1065
+ command: null,
1066
+ disabled: false,
1067
+ key: `${region}:${item.label}`,
1068
+ kind: "state",
1069
+ label: item.label,
1070
+ title: item.title ?? item.label
1071
+ };
1072
+ }
1073
+ const id = item.command;
1074
+ if (!registry?.get(id) || !registry.isVisible(id)) {
1075
+ return null;
1076
+ }
1077
+ const command = registry.get(id);
1078
+ const reason = registry.disabledReason(id);
1079
+ const chord = registry.keymap.formatBinding(id);
1080
+ const suffix = reason ? `${command.title} — requires ${reason}` : chord ? `${command.title} (${chord})` : command.title;
1081
+ return {
1082
+ args: item.args,
1083
+ command: id,
1084
+ disabled: reason !== undefined,
1085
+ key: `${region}:${id}`,
1086
+ kind: "button",
1087
+ label: item.label,
1088
+ title: item.title ? `${item.title} · ${suffix}` : suffix
1089
+ };
1090
+ }
1091
+ function projectField(registry, id, items) {
1092
+ const region = `statusbar/${id}`;
1093
+ const live = items.map((item) => item === null ? null : projectItem(registry, region, item)).filter((item) => item !== null);
1094
+ if (live.length === 0) {
1095
+ return null;
1096
+ }
1097
+ return { id, items: live, region };
1098
+ }
1099
+ function aheadBehindLabel(ahead, behind) {
1100
+ return `${ahead > 0 ? ` ↑${ahead}` : ""}${behind > 0 ? ` ↓${behind}` : ""}`;
1101
+ }
1102
+ function projectField_(registry) {
1103
+ const project = projectState;
1104
+ const { status } = shell.git;
1105
+ const count = problemCount2();
1106
+ const deploy = deployStatusItem();
1107
+ const peers = activeTab2.value ? collabState(activeTab2.value).peers.length : 0;
1108
+ return projectField(registry, "project", [
1109
+ project ? { command: "project.openRecent", label: project.name } : { command: "project.open", label: "No project" },
1110
+ status?.isRepo === true && status.branch ? {
1111
+ command: "panel.focus.git",
1112
+ label: `⑂ ${status.branch}${aheadBehindLabel(status.ahead, status.behind)}`,
1113
+ title: `${status.files.length} changed file(s)`
1114
+ } : null,
1115
+ deploy ? { command: deploy.command, label: deploy.label, title: deploy.title } : null,
1116
+ count > 0 ? {
1117
+ args: { tab: "problems" },
1118
+ command: "view.setBottomTab",
1119
+ label: `⚠ ${count}`,
1120
+ title: `${count} problem(s)`
1121
+ } : null,
1122
+ peers > 0 ? {
1123
+ command: "collab.showStatus",
1124
+ label: `${peers} peer${peers === 1 ? "" : "s"}`,
1125
+ title: `${peers} peer${peers === 1 ? "" : "s"} in this document`
1126
+ } : null
1127
+ ]);
1128
+ }
1129
+ function viewLabel(kind, view) {
1130
+ if (kind === "none") {
1131
+ return "";
1132
+ }
1133
+ if (kind !== "canvas") {
1134
+ return EDITOR_KIND_LABELS[kind];
1135
+ }
1136
+ return view.charAt(0).toUpperCase() + view.slice(1);
1137
+ }
1138
+ function saveItem(dirty, readOnly, savedAt) {
1139
+ if (readOnly) {
1140
+ return { command: null, label: "Read-only", title: "A collaborator owns this session's file" };
1141
+ }
1142
+ if (dirty) {
1143
+ return { command: "file.save", label: "Unsaved changes" };
1144
+ }
1145
+ return savedAt === undefined ? { command: null, label: "Saved" } : { command: null, label: `Saved ${relativeTime(savedAt)}` };
1146
+ }
1147
+ function documentField(registry) {
1148
+ const tab = activeTab2.value;
1149
+ if (!tab) {
1150
+ return null;
1151
+ }
1152
+ const ctx = registry?.context() ?? null;
1153
+ const view = ctx ? viewLabel(ctx.editor.kind, ctx.canvas.view) : "";
1154
+ const collab = collabState(tab);
1155
+ const savedAt = tab.documentPath === null ? undefined : _savedAt.get(tab.documentPath);
1156
+ return projectField(registry, "document", [
1157
+ {
1158
+ command: "palette.openFiles",
1159
+ label: documentLabel(tab.documentPath),
1160
+ title: tab.documentPath ?? "Not saved to disk yet"
1161
+ },
1162
+ view ? { command: null, label: view, title: "The pane's view — change it on the pane context bar" } : null,
1163
+ saveItem(tab.doc.dirty, collab.readOnly, savedAt)
1164
+ ]);
1165
+ }
1166
+ function selectionField(registry) {
1167
+ const paths = activeTab2.value?.session.selection ?? [];
1168
+ if (paths.length > 0) {
1169
+ return paths.length > 1 ? projectField(registry, "selection", [
1170
+ {
1171
+ command: null,
1172
+ label: `${paths.length} selected`,
1173
+ title: `${paths.length} elements are selected; the jump bar names the primary`
1174
+ }
1175
+ ]) : null;
1176
+ }
1177
+ return shell.stylebook.selection ? projectField(registry, "selection", [
1178
+ {
1179
+ command: null,
1180
+ label: shell.stylebook.selection.replaceAll(" ", " › "),
1181
+ title: "The style rule being edited"
1182
+ }
1183
+ ]) : null;
1184
+ }
1185
+ function projectBar() {
1186
+ const registry = activeRegistry();
1187
+ return [projectField_(registry), documentField(registry), selectionField(registry)].filter((field) => field !== null);
1188
+ }
1189
+ var _state = null;
1190
+ var _mount = null;
1191
+ var _handle = null;
1192
+ function state() {
1193
+ _state ??= reactive({
1194
+ fields: [],
1195
+ run: (key) => {
1196
+ const item = _state?.fields.flatMap((field) => field.items).find((i) => i.key === key);
1197
+ const registry = activeRegistry();
1198
+ if (item?.command && registry) {
1199
+ registry.run(item.command, item.args);
1200
+ }
1201
+ }
1202
+ });
1203
+ return _state;
1204
+ }
1205
+ function ensureMounted() {
1206
+ if (_mount || !statusbarEl) {
1207
+ return;
1208
+ }
1209
+ _mount = mountSurface("statusbar", state(), statusbarEl);
1210
+ _mount.then((handle) => {
1211
+ _handle = handle;
1212
+ });
1213
+ }
1214
+ function renderStatusbar() {
1215
+ state().fields = projectBar();
1216
+ ensureMounted();
1217
+ }
1218
+ function mountStatusbar() {
1219
+ unmountStatusbar();
1220
+ _scope2 = effectScope();
1221
+ _scope2.run(() => {
1222
+ effect(() => {
1223
+ activeRegistry();
1224
+ shell.stylebook.selection;
1225
+ shell.git.status;
1226
+ problems2.length;
1227
+ const tab = activeTab2.value;
1228
+ if (tab) {
1229
+ tab.doc.document;
1230
+ tab.doc.dirty;
1231
+ tab.doc.mode;
1232
+ tab.documentPath;
1233
+ tab.session.selection.map((path) => path.join("/")).join("|");
1234
+ tab.session.ui.canvasMode;
1235
+ tab.session.ui.preview;
1236
+ collabState(tab).peers.length;
1237
+ collabState(tab).readOnly;
1238
+ }
1239
+ renderStatusbar();
1240
+ });
1241
+ });
1242
+ }
1243
+ function unmountStatusbar() {
1244
+ _scope2?.stop();
1245
+ _scope2 = null;
1246
+ const pending = _mount;
1247
+ _mount = null;
1248
+ if (_handle) {
1249
+ _handle.dispose();
1250
+ _handle = null;
1251
+ } else if (pending) {
1252
+ pending.then((handle) => handle.dispose());
1253
+ }
1254
+ _state = null;
1255
+ }
1256
+
1257
+ // src/services/popover-report.ts
1258
+ var KIT_SCOPE = { invokerTags: INVOKER_TAGS, popoverTags: POPOVER_TAGS };
1259
+ var POPOVER_PROBLEM_SOURCE = "Popover";
1260
+ var REPAIR_COMMAND = {
1261
+ display: "document.repairPopoverDisplay",
1262
+ "open-display": "document.repairPopoverDisplay",
1263
+ invoker: "document.repairPopoverInvoker",
1264
+ mode: "document.repairPopoverMode"
1265
+ };
1266
+ function problemKey(seen, prefix, rule, path) {
1267
+ const base = `${prefix}.${rule}.${path.join("/")}`;
1268
+ const before = seen.get(base) ?? 0;
1269
+ seen.set(base, before + 1);
1270
+ return before === 0 ? base : `${base}#${before}`;
1271
+ }
1272
+ function reportPopoverProblems(doc, path) {
1273
+ clearProblems2((record) => record.source === POPOVER_PROBLEM_SOURCE);
1274
+ const seen = new Map;
1275
+ const defects = findPopoverDefects(doc, KIT_SCOPE);
1276
+ for (const defect of defects) {
1277
+ const action = defect.fix === undefined ? undefined : REPAIR_COMMAND[defect.fix];
1278
+ notify2(defect.severity, defect.message, {
1279
+ detail: defect.detail,
1280
+ key: problemKey(seen, "popover", defect.rule, defect.path),
1281
+ source: POPOVER_PROBLEM_SOURCE,
1282
+ tier: "problem",
1283
+ ...action === undefined ? {} : { action, actionArgs: { path: defect.path } },
1284
+ ...path === undefined ? {} : { path }
1285
+ });
1286
+ }
1287
+ const dialogDefects = findDialogDefects(doc, KIT_SCOPE);
1288
+ for (const defect of dialogDefects) {
1289
+ notify2(defect.severity, defect.message, {
1290
+ detail: defect.detail,
1291
+ key: problemKey(seen, "dialog", defect.rule, defect.path),
1292
+ source: POPOVER_PROBLEM_SOURCE,
1293
+ tier: "problem",
1294
+ ...path === undefined ? {} : { path }
1295
+ });
1296
+ }
1297
+ return defects.length + dialogDefects.length;
1298
+ }
1299
+ function repairPath(id, args) {
1300
+ const path = args?.path;
1301
+ if (!Array.isArray(path)) {
1302
+ throw new RangeError(`command "${id}" needs a "path" argument naming the popover`);
1303
+ }
1304
+ return path;
1305
+ }
1306
+ function repairTab(id) {
1307
+ const tab = activeTab2.value;
1308
+ if (!tab) {
1309
+ throw new RangeError(`command "${id}" needs an open document`);
1310
+ }
1311
+ return tab;
1312
+ }
1313
+ function popoverCommands() {
1314
+ return [
1315
+ {
1316
+ category: "Document",
1317
+ group: "2_document",
1318
+ id: "document.checkPopovers",
1319
+ level: "document",
1320
+ menus: ["palette"],
1321
+ requires: "an open document",
1322
+ run: () => {
1323
+ const tab = repairTab("document.checkPopovers");
1324
+ const filed = reportPopoverProblems(tab.doc.document, tab.documentPath ?? undefined);
1325
+ notify2.success(filed === 0 ? "No popover problems found in this document." : `${filed} popover problem(s) filed.`, { key: "popover.run", source: POPOVER_PROBLEM_SOURCE });
1326
+ },
1327
+ title: "Check Popovers",
1328
+ when: (ctx) => ctx.document.open,
1329
+ aiTool: {
1330
+ description: "Check the open document for popover defects an author can fix — a base-rule `display` " + "that defeats the browser's own hiding of a closed popover, `popovertarget` on an " + "element that cannot invoke, a target naming no popover, a cut exit animation — and " + "file each as a Problem. The findings come back as data.",
1331
+ name: "check_popovers",
1332
+ report: () => {
1333
+ const findings = problemFindings2(POPOVER_PROBLEM_SOURCE);
1334
+ const n = findings.length;
1335
+ return {
1336
+ data: findings,
1337
+ summary: n === 0 ? "No popover problems found in this document." : `Filed ${n} popover problem${n === 1 ? "" : "s"} in Problems.`
1338
+ };
1339
+ }
1340
+ }
1341
+ },
1342
+ {
1343
+ args: {
1344
+ additionalProperties: false,
1345
+ properties: {
1346
+ path: { items: { type: ["string", "number"] }, type: "array" }
1347
+ },
1348
+ required: ["path"],
1349
+ type: "object"
1350
+ },
1351
+ category: "Document",
1352
+ group: "2_document",
1353
+ id: "document.repairPopoverDisplay",
1354
+ level: "document",
1355
+ menus: [],
1356
+ requires: "a popover whose base rule sets display",
1357
+ run: (_ctx, args) => {
1358
+ const id = "document.repairPopoverDisplay";
1359
+ const tab = repairTab(id);
1360
+ const path = repairPath(id, args);
1361
+ const node = getNodeAtPath2(tab.doc.document, path);
1362
+ const repair = popoverDisplayRepair(node?.style);
1363
+ if (!repair) {
1364
+ throw new RangeError(`command "${id}": nothing to move — this popover sets no display`);
1365
+ }
1366
+ transactDoc(tab, (t) => {
1367
+ for (const prop of repair.base) {
1368
+ mutateUpdateStyle(t, path, prop, "");
1369
+ }
1370
+ for (const at of repair.breakpoints) {
1371
+ mutateUpdateNestedStylePath(t, path, [at], "display", "");
1372
+ }
1373
+ if (repair.openDisplay !== null) {
1374
+ mutateUpdateNestedStyle(t, path, ":popover-open", "display", repair.openDisplay);
1375
+ }
1376
+ });
1377
+ notify2.success("Moved `display` into `:popover-open`.", {
1378
+ key: "popover.repaired.display",
1379
+ source: POPOVER_PROBLEM_SOURCE
1380
+ });
1381
+ },
1382
+ title: "Move display into :popover-open",
1383
+ when: (ctx) => ctx.document.open
1384
+ },
1385
+ {
1386
+ args: {
1387
+ additionalProperties: false,
1388
+ properties: {
1389
+ path: { items: { type: ["string", "number"] }, type: "array" }
1390
+ },
1391
+ required: ["path"],
1392
+ type: "object"
1393
+ },
1394
+ category: "Document",
1395
+ group: "2_document",
1396
+ id: "document.repairPopoverInvoker",
1397
+ level: "document",
1398
+ menus: [],
1399
+ requires: "an element carrying popovertarget that cannot invoke",
1400
+ run: (_ctx, args) => {
1401
+ const id = "document.repairPopoverInvoker";
1402
+ const tab = repairTab(id);
1403
+ const path = repairPath(id, args);
1404
+ transactDoc(tab, (t) => {
1405
+ mutateUpdateAttribute(t, path, "popovertarget");
1406
+ mutateUpdateAttribute(t, path, "popovertargetaction");
1407
+ });
1408
+ notify2.success("Removed the attributes, which did nothing on this element.", {
1409
+ key: "popover.repaired.invoker",
1410
+ source: POPOVER_PROBLEM_SOURCE
1411
+ });
1412
+ },
1413
+ title: "Remove the inert popover attributes",
1414
+ when: (ctx) => ctx.document.open
1415
+ },
1416
+ {
1417
+ args: {
1418
+ additionalProperties: false,
1419
+ properties: {
1420
+ path: { items: { type: ["string", "number"] }, type: "array" }
1421
+ },
1422
+ required: ["path"],
1423
+ type: "object"
1424
+ },
1425
+ category: "Document",
1426
+ group: "2_document",
1427
+ id: "document.repairPopoverMode",
1428
+ level: "document",
1429
+ menus: [],
1430
+ requires: "a popover whose mode is not one of the three keywords",
1431
+ run: (_ctx, args) => {
1432
+ const id = "document.repairPopoverMode";
1433
+ const tab = repairTab(id);
1434
+ const path = repairPath(id, args);
1435
+ transactDoc(tab, (t) => {
1436
+ mutateUpdateAttribute(t, path, "popover", POPOVER_DEFAULT_MODE);
1437
+ });
1438
+ notify2.success(`Set \`popover\` to "${POPOVER_DEFAULT_MODE}".`, {
1439
+ key: "popover.repaired.mode",
1440
+ source: POPOVER_PROBLEM_SOURCE
1441
+ });
1442
+ },
1443
+ title: "Set popover to auto",
1444
+ when: (ctx) => ctx.document.open
1445
+ }
1446
+ ];
1447
+ }
1448
+ function registerPopoverCommands(registry) {
1449
+ registry.registerAll(popoverCommands());
1450
+ }
1451
+
1452
+ // src/grid/grid-source.ts
1453
+ function cellValuesEqual(a, b) {
1454
+ if (a === b) {
1455
+ return true;
1456
+ }
1457
+ if (Array.isArray(a) && Array.isArray(b)) {
1458
+ return a.length === b.length && a.every((v, i) => v === b[i]);
1459
+ }
1460
+ if (a !== null && b !== null && typeof a === "object" && typeof b === "object" && !Array.isArray(a) && !Array.isArray(b)) {
1461
+ return a.$ref === b.$ref;
1462
+ }
1463
+ return false;
1464
+ }
1465
+ var GRID_SCHEME = "grid://";
1466
+ function makeGridTabId(ref) {
1467
+ switch (ref.kind) {
1468
+ case "pages": {
1469
+ return `${GRID_SCHEME}pages`;
1470
+ }
1471
+ case "library": {
1472
+ return `${GRID_SCHEME}library`;
1473
+ }
1474
+ case "collection": {
1475
+ return `${GRID_SCHEME}collection/${encodeURIComponent(ref.name)}`;
1476
+ }
1477
+ default: {
1478
+ return `${GRID_SCHEME}data/${encodeURIComponent(ref.connection)}/${encodeURIComponent(ref.table)}`;
1479
+ }
1480
+ }
1481
+ }
1482
+ function isGridTabId(id) {
1483
+ return id.startsWith(GRID_SCHEME);
1484
+ }
1485
+ function parseGridTabId(id) {
1486
+ if (!isGridTabId(id)) {
1487
+ return null;
1488
+ }
1489
+ const parts = id.slice(GRID_SCHEME.length).split("/");
1490
+ if (parts[0] === "pages" && parts.length === 1) {
1491
+ return { kind: "pages" };
1492
+ }
1493
+ if (parts[0] === "library" && parts.length === 1) {
1494
+ return { kind: "library" };
1495
+ }
1496
+ if (parts[0] === "collection" && parts.length === 2 && parts[1]) {
1497
+ return { kind: "collection", name: decodeURIComponent(parts[1]) };
1498
+ }
1499
+ if (parts[0] === "data" && parts.length === 3 && parts[1] && parts[2]) {
1500
+ return {
1501
+ connection: decodeURIComponent(parts[1]),
1502
+ kind: "data",
1503
+ table: decodeURIComponent(parts[2])
1504
+ };
1505
+ }
1506
+ return null;
1507
+ }
1508
+ function gridTabLabel(id) {
1509
+ const ref = parseGridTabId(id);
1510
+ if (!ref) {
1511
+ return null;
1512
+ }
1513
+ switch (ref.kind) {
1514
+ case "pages": {
1515
+ return "Pages · grid";
1516
+ }
1517
+ case "library": {
1518
+ return "Library";
1519
+ }
1520
+ case "collection": {
1521
+ return `${ref.name} · grid`;
1522
+ }
1523
+ default: {
1524
+ return `${ref.table} @ ${ref.connection} · grid`;
1525
+ }
1526
+ }
1527
+ }
1528
+
1529
+ // src/grid/edit-buffer.ts
1530
+ var _tempCounter = 0;
1531
+ function createEditBuffer(opts) {
1532
+ const coalesceMs = opts.coalesceMs ?? 800;
1533
+ const now = opts.now ?? (() => Date.now());
1534
+ const state = reactive({
1535
+ deletes: new Set,
1536
+ errors: new Map,
1537
+ inserts: new Map,
1538
+ pending: new Map,
1539
+ redoStack: [],
1540
+ stale: new Set,
1541
+ undoStack: []
1542
+ });
1543
+ let groupOps = null;
1544
+ const setError = (rowKey, field, message) => {
1545
+ const row = state.errors.get(rowKey);
1546
+ if (row) {
1547
+ row.set(field, message);
1548
+ } else {
1549
+ state.errors.set(rowKey, new Map([[field, message]]));
1550
+ }
1551
+ };
1552
+ const clearCellError = (rowKey, field) => {
1553
+ const row = state.errors.get(rowKey);
1554
+ row?.delete(field);
1555
+ if (row?.size === 0) {
1556
+ state.errors.delete(rowKey);
1557
+ }
1558
+ };
1559
+ const pushOp = (op) => {
1560
+ state.redoStack.length = 0;
1561
+ if (groupOps) {
1562
+ groupOps.push(op);
1563
+ return;
1564
+ }
1565
+ const last = state.undoStack.at(-1);
1566
+ if (op.kind === "cell" && last?.kind === "cell" && last.rowKey === op.rowKey && last.field === op.field && op.at - last.at <= coalesceMs) {
1567
+ last.after = op.after;
1568
+ last.at = op.at;
1569
+ return;
1570
+ }
1571
+ state.undoStack.push(op);
1572
+ };
1573
+ const writeCell = (rowKey, field, value) => {
1574
+ const insertCells = state.inserts.get(rowKey);
1575
+ if (insertCells) {
1576
+ if (value === null) {
1577
+ delete insertCells[field];
1578
+ } else {
1579
+ insertCells[field] = value;
1580
+ }
1581
+ return;
1582
+ }
1583
+ if (cellValuesEqual(value, opts.resolveBaseline(rowKey, field))) {
1584
+ const row = state.pending.get(rowKey);
1585
+ row?.delete(field);
1586
+ if (row?.size === 0) {
1587
+ state.pending.delete(rowKey);
1588
+ }
1589
+ return;
1590
+ }
1591
+ const row = state.pending.get(rowKey);
1592
+ if (row) {
1593
+ row.set(field, { value });
1594
+ } else {
1595
+ state.pending.set(rowKey, new Map([[field, { value }]]));
1596
+ }
1597
+ };
1598
+ const effectiveValue = (rowKey, field) => {
1599
+ const insertCells = state.inserts.get(rowKey);
1600
+ if (insertCells) {
1601
+ return insertCells[field] ?? null;
1602
+ }
1603
+ const pending = state.pending.get(rowKey)?.get(field);
1604
+ return pending ? pending.value : opts.resolveBaseline(rowKey, field);
1605
+ };
1606
+ const cellError = (rowKey, field) => {
1607
+ const row = state.errors.get(rowKey);
1608
+ return row?.get(field) ?? row?.get("*") ?? null;
1609
+ };
1610
+ const applyOp = (op, direction) => {
1611
+ switch (op.kind) {
1612
+ case "cell": {
1613
+ writeCell(op.rowKey, op.field, direction === "undo" ? op.before : op.after);
1614
+ break;
1615
+ }
1616
+ case "insert": {
1617
+ if (direction === "undo") {
1618
+ state.inserts.delete(op.tempKey);
1619
+ } else {
1620
+ state.inserts.set(op.tempKey, { ...op.cells });
1621
+ }
1622
+ break;
1623
+ }
1624
+ case "drop-insert": {
1625
+ if (direction === "undo") {
1626
+ state.inserts.set(op.tempKey, { ...op.cells });
1627
+ } else {
1628
+ state.inserts.delete(op.tempKey);
1629
+ }
1630
+ break;
1631
+ }
1632
+ case "delete": {
1633
+ if (direction === "undo") {
1634
+ state.deletes.delete(op.rowKey);
1635
+ } else {
1636
+ state.deletes.add(op.rowKey);
1637
+ }
1638
+ break;
1639
+ }
1640
+ default: {
1641
+ const ops = direction === "undo" ? op.ops.toReversed() : op.ops;
1642
+ for (const child of ops) {
1643
+ applyOp(child, direction);
1644
+ }
1645
+ break;
1646
+ }
1647
+ }
1648
+ };
1649
+ const beginGroup = () => {
1650
+ if (groupOps) {
1651
+ throw new Error("edit-buffer: groups may not nest");
1652
+ }
1653
+ groupOps = [];
1654
+ };
1655
+ const endGroup = () => {
1656
+ const ops = groupOps;
1657
+ groupOps = null;
1658
+ if (!ops) {
1659
+ return;
1660
+ }
1661
+ if (ops.length === 1) {
1662
+ state.undoStack.push(ops[0]);
1663
+ } else if (ops.length > 1) {
1664
+ state.undoStack.push({ kind: "group", ops });
1665
+ }
1666
+ };
1667
+ const pruneHistory = (dropRow) => {
1668
+ const keep = (op) => {
1669
+ switch (op.kind) {
1670
+ case "cell": {
1671
+ return dropRow(op.rowKey) ? null : op;
1672
+ }
1673
+ case "insert":
1674
+ case "drop-insert": {
1675
+ return dropRow(op.tempKey) ? null : op;
1676
+ }
1677
+ case "delete": {
1678
+ return dropRow(op.rowKey) ? null : op;
1679
+ }
1680
+ default: {
1681
+ const ops = op.ops.map((child) => keep(child)).filter((o) => o !== null);
1682
+ return ops.length > 0 ? { kind: "group", ops } : null;
1683
+ }
1684
+ }
1685
+ };
1686
+ state.undoStack = state.undoStack.map(keep).filter((o) => o !== null);
1687
+ state.redoStack = state.redoStack.map(keep).filter((o) => o !== null);
1688
+ };
1689
+ return {
1690
+ applyCommitResult(result) {
1691
+ const committedRows = new Set;
1692
+ for (const cell of result.cells) {
1693
+ if (cell.ok) {
1694
+ const row = state.pending.get(cell.rowKey);
1695
+ row?.delete(cell.field);
1696
+ if (row?.size === 0) {
1697
+ state.pending.delete(cell.rowKey);
1698
+ }
1699
+ clearCellError(cell.rowKey, cell.field);
1700
+ } else {
1701
+ setError(cell.rowKey, cell.field, cell.error ?? "Save failed");
1702
+ if (cell.stale) {
1703
+ state.stale.add(cell.rowKey);
1704
+ }
1705
+ }
1706
+ }
1707
+ for (const ins of result.inserts) {
1708
+ if (ins.ok) {
1709
+ state.inserts.delete(ins.tempKey);
1710
+ state.errors.delete(ins.tempKey);
1711
+ committedRows.add(ins.tempKey);
1712
+ } else {
1713
+ setError(ins.tempKey, "*", ins.error ?? "Insert failed");
1714
+ }
1715
+ }
1716
+ for (const del of result.deletes) {
1717
+ if (del.ok) {
1718
+ state.deletes.delete(del.rowKey);
1719
+ state.pending.delete(del.rowKey);
1720
+ state.errors.delete(del.rowKey);
1721
+ committedRows.add(del.rowKey);
1722
+ } else {
1723
+ setError(del.rowKey, "*", del.error ?? "Delete failed");
1724
+ if (del.stale) {
1725
+ state.stale.add(del.rowKey);
1726
+ }
1727
+ }
1728
+ }
1729
+ for (const row of committedRows) {
1730
+ state.stale.delete(row);
1731
+ }
1732
+ if (committedRows.size > 0) {
1733
+ pruneHistory((rowKey) => committedRows.has(rowKey));
1734
+ }
1735
+ },
1736
+ buildBatch() {
1737
+ const cells = [];
1738
+ for (const [rowKey, fields] of state.pending) {
1739
+ if (state.deletes.has(rowKey)) {
1740
+ continue;
1741
+ }
1742
+ for (const [field, cell] of fields) {
1743
+ cells.push({
1744
+ baseline: opts.resolveBaseline(rowKey, field),
1745
+ field,
1746
+ rowKey,
1747
+ value: cell.value
1748
+ });
1749
+ }
1750
+ }
1751
+ return {
1752
+ cells,
1753
+ deletes: [...state.deletes].map((rowKey) => ({ rowKey })),
1754
+ inserts: [...state.inserts].map(([tempKey, insertCells]) => ({
1755
+ cells: { ...insertCells },
1756
+ tempKey
1757
+ }))
1758
+ };
1759
+ },
1760
+ canRedo: () => state.redoStack.length > 0,
1761
+ canUndo: () => state.undoStack.length > 0,
1762
+ cellError,
1763
+ cellState(rowKey, field) {
1764
+ if (cellError(rowKey, field) !== null) {
1765
+ return "error";
1766
+ }
1767
+ if (state.stale.has(rowKey)) {
1768
+ return "stale";
1769
+ }
1770
+ if (state.inserts.has(rowKey) || state.pending.get(rowKey)?.has(field)) {
1771
+ return "dirty";
1772
+ }
1773
+ return "clean";
1774
+ },
1775
+ deleteRow(rowKey) {
1776
+ if (state.deletes.has(rowKey)) {
1777
+ return;
1778
+ }
1779
+ const insertCells = state.inserts.get(rowKey);
1780
+ if (insertCells) {
1781
+ const cells = { ...insertCells };
1782
+ state.inserts.delete(rowKey);
1783
+ state.errors.delete(rowKey);
1784
+ state.stale.delete(rowKey);
1785
+ pushOp({ cells, kind: "drop-insert", tempKey: rowKey });
1786
+ return;
1787
+ }
1788
+ state.deletes.add(rowKey);
1789
+ pushOp({ kind: "delete", rowKey });
1790
+ },
1791
+ dirtyCount() {
1792
+ let count = state.inserts.size + state.deletes.size;
1793
+ for (const [rowKey, fields] of state.pending) {
1794
+ if (!state.deletes.has(rowKey)) {
1795
+ count += fields.size;
1796
+ }
1797
+ }
1798
+ return count;
1799
+ },
1800
+ discardRow(rowKey) {
1801
+ state.pending.delete(rowKey);
1802
+ state.deletes.delete(rowKey);
1803
+ state.inserts.delete(rowKey);
1804
+ state.errors.delete(rowKey);
1805
+ state.stale.delete(rowKey);
1806
+ pruneHistory((key) => key === rowKey);
1807
+ },
1808
+ effectiveValue,
1809
+ beginGroup,
1810
+ endGroup,
1811
+ group(fn) {
1812
+ beginGroup();
1813
+ try {
1814
+ fn();
1815
+ } finally {
1816
+ endGroup();
1817
+ }
1818
+ },
1819
+ insertRow(cells = {}) {
1820
+ _tempCounter += 1;
1821
+ const tempKey = `__new-${_tempCounter}`;
1822
+ state.inserts.set(tempKey, { ...cells });
1823
+ pushOp({ cells: { ...cells }, kind: "insert", tempKey });
1824
+ return tempKey;
1825
+ },
1826
+ isDirty: () => state.pending.size > 0 || state.inserts.size > 0 || state.deletes.size > 0,
1827
+ isInsertKey: (rowKey) => state.inserts.has(rowKey),
1828
+ markStale(rowKeys) {
1829
+ for (const rowKey of rowKeys) {
1830
+ state.stale.add(rowKey);
1831
+ }
1832
+ },
1833
+ redo() {
1834
+ const op = state.redoStack.pop();
1835
+ if (!op) {
1836
+ return false;
1837
+ }
1838
+ applyOp(op, "redo");
1839
+ state.undoStack.push(op);
1840
+ return true;
1841
+ },
1842
+ reset() {
1843
+ state.pending.clear();
1844
+ state.inserts.clear();
1845
+ state.deletes.clear();
1846
+ state.errors.clear();
1847
+ state.stale.clear();
1848
+ state.undoStack.length = 0;
1849
+ state.redoStack.length = 0;
1850
+ },
1851
+ rowState(rowKey) {
1852
+ if (state.deletes.has(rowKey)) {
1853
+ return "pending-delete";
1854
+ }
1855
+ if (state.inserts.has(rowKey)) {
1856
+ return "pending-insert";
1857
+ }
1858
+ if (state.stale.has(rowKey)) {
1859
+ return "stale";
1860
+ }
1861
+ if (state.pending.has(rowKey) || state.errors.has(rowKey)) {
1862
+ return "dirty";
1863
+ }
1864
+ return "clean";
1865
+ },
1866
+ setCell(rowKey, field, value) {
1867
+ const before = effectiveValue(rowKey, field);
1868
+ if (cellValuesEqual(before, value)) {
1869
+ return;
1870
+ }
1871
+ writeCell(rowKey, field, value);
1872
+ pushOp({ after: value, at: now(), before, field, kind: "cell", rowKey });
1873
+ },
1874
+ state,
1875
+ undo() {
1876
+ const op = state.undoStack.pop();
1877
+ if (!op) {
1878
+ return false;
1879
+ }
1880
+ applyOp(op, "undo");
1881
+ state.redoStack.push(op);
1882
+ return true;
1883
+ }
1884
+ };
1885
+ }
1886
+
1887
+ // src/grid/schema-columns.ts
1888
+ var KIND_WIDTHS = {
1889
+ array: 220,
1890
+ boolean: 70,
1891
+ date: 130,
1892
+ enum: 140,
1893
+ image: 180,
1894
+ number: 110,
1895
+ readonly: 200,
1896
+ reference: 200,
1897
+ string: 180,
1898
+ text: 340
1899
+ };
1900
+ function clampWidth(maxLen) {
1901
+ return Math.min(340, Math.max(90, Math.round(maxLen * 7.5)));
1902
+ }
1903
+ function kindForProp(prop) {
1904
+ if (prop.$ref) {
1905
+ return "reference";
1906
+ }
1907
+ if (prop.enum !== undefined && Array.isArray(prop.enum)) {
1908
+ return "enum";
1909
+ }
1910
+ const format = prop.type === "array" ? undefined : prop.format;
1911
+ if (isMediaFormat(format)) {
1912
+ return "image";
1913
+ }
1914
+ if (format === "date" || format === "date-time") {
1915
+ return "date";
1916
+ }
1917
+ switch (prop.type) {
1918
+ case "number":
1919
+ case "integer": {
1920
+ return "number";
1921
+ }
1922
+ case "boolean": {
1923
+ return "boolean";
1924
+ }
1925
+ case "array": {
1926
+ return "array";
1927
+ }
1928
+ case "object": {
1929
+ return "readonly";
1930
+ }
1931
+ default: {
1932
+ return (prop.maxLength ?? 0) > 200 || prop.format === "markdown" ? "text" : "string";
1933
+ }
1934
+ }
1935
+ }
1936
+ function titleForField(field) {
1937
+ const spaced = field.replaceAll(/([a-z0-9])([A-Z])/g, "$1 $2").replaceAll(/[_-]+/g, " ").trim();
1938
+ return spaced.charAt(0).toUpperCase() + spaced.slice(1);
1939
+ }
1940
+ function columnsFromSchema(schema, opts = {}) {
1941
+ const props = Object.entries(schema?.properties ?? {});
1942
+ const required = new Set(schema?.required);
1943
+ const readonly = new Set(opts.readonlyFields);
1944
+ const columns = props.map(([field, prop]) => {
1945
+ const kind = readonly.has(field) ? "readonly" : kindForProp(prop);
1946
+ const enumLen = Array.isArray(prop.enum) ? Math.max(...prop.enum.map((v) => String(v).length), 4) : 0;
1947
+ return {
1948
+ editable: kind !== "readonly",
1949
+ field,
1950
+ kind,
1951
+ pk: field === opts.idField,
1952
+ required: required.has(field),
1953
+ schema: prop,
1954
+ title: titleForField(field),
1955
+ widthHint: kind === "enum" ? clampWidth(enumLen + 3) : KIND_WIDTHS[kind]
1956
+ };
1957
+ });
1958
+ columns.sort((a, b) => {
1959
+ const rank = (c) => c.pk ? 0 : c.required ? 1 : 2;
1960
+ const diff = rank(a) - rank(b);
1961
+ return diff === 0 ? 0 : diff;
1962
+ });
1963
+ return columns;
1964
+ }
1965
+ function inferColumnsFromRows(rows, sampleLimit = 50) {
1966
+ const sample = rows.slice(0, sampleLimit);
1967
+ const fields = [];
1968
+ for (const row of sample) {
1969
+ for (const key of Object.keys(row)) {
1970
+ if (!fields.includes(key)) {
1971
+ fields.push(key);
1972
+ }
1973
+ }
1974
+ }
1975
+ return fields.map((field) => {
1976
+ const values = sample.map((row) => row[field]).filter((v) => v !== null && v !== undefined && v !== "");
1977
+ const kind = inferKind(values);
1978
+ const maxLen = Math.max(...values.map((v) => cellToText(v).length), field.length, 4);
1979
+ return {
1980
+ editable: true,
1981
+ field,
1982
+ kind,
1983
+ title: titleForField(field),
1984
+ widthHint: kind === "string" || kind === "text" ? clampWidth(maxLen) : KIND_WIDTHS[kind]
1985
+ };
1986
+ });
1987
+ }
1988
+ function inferKind(values) {
1989
+ if (values.length === 0) {
1990
+ return "string";
1991
+ }
1992
+ if (values.some((v) => Array.isArray(v))) {
1993
+ return "array";
1994
+ }
1995
+ const texts = values.map(String);
1996
+ if (values.every((v) => typeof v === "boolean") || texts.every((t) => /^(true|false)$/i.test(t))) {
1997
+ return "boolean";
1998
+ }
1999
+ if (values.every((v) => typeof v === "number") || texts.every((t) => t.trim() !== "" && !Number.isNaN(Number(t.replaceAll(/[$€£¥,\s]/g, ""))))) {
2000
+ return "number";
2001
+ }
2002
+ if (texts.every((t) => /^\d{4}-\d{2}-\d{2}([T ].*)?$/.test(t))) {
2003
+ return "date";
2004
+ }
2005
+ if (texts.some((t) => t.length > 200)) {
2006
+ return "text";
2007
+ }
2008
+ return "string";
2009
+ }
2010
+ function coerceCellInput(raw, col) {
2011
+ if (raw === null || raw === undefined) {
2012
+ return null;
2013
+ }
2014
+ switch (col.kind) {
2015
+ case "number": {
2016
+ if (typeof raw === "number") {
2017
+ return Number.isNaN(raw) ? null : raw;
2018
+ }
2019
+ const cleaned = String(raw).trim().replaceAll(/[$€£¥,\s]/g, "");
2020
+ if (cleaned === "") {
2021
+ return null;
2022
+ }
2023
+ const n = Number(cleaned);
2024
+ return Number.isNaN(n) ? null : n;
2025
+ }
2026
+ case "boolean": {
2027
+ if (typeof raw === "boolean") {
2028
+ return raw;
2029
+ }
2030
+ return String(raw).trim().toLowerCase() === "true";
2031
+ }
2032
+ case "array": {
2033
+ if (Array.isArray(raw)) {
2034
+ return raw.map(String);
2035
+ }
2036
+ const text = String(raw).trim();
2037
+ return text === "" ? [] : text.split(",").map((s) => s.trim()).filter(Boolean);
2038
+ }
2039
+ case "reference": {
2040
+ if (typeof raw === "object" && raw !== null && "$ref" in raw) {
2041
+ const ref = raw.$ref;
2042
+ return typeof ref === "string" && ref !== "" ? ref : null;
2043
+ }
2044
+ const text = String(raw).trim();
2045
+ return text === "" ? null : text;
2046
+ }
2047
+ default: {
2048
+ const text = String(raw);
2049
+ return text === "" ? null : text;
2050
+ }
2051
+ }
2052
+ }
2053
+ function cellToText(value) {
2054
+ if (value === null || value === undefined) {
2055
+ return "";
2056
+ }
2057
+ if (Array.isArray(value)) {
2058
+ return value.join(", ");
2059
+ }
2060
+ if (typeof value === "object") {
2061
+ return value.$ref;
2062
+ }
2063
+ return String(value);
2064
+ }
2065
+
2066
+ // src/grid/grid-controller.ts
2067
+ var ROW_KEY_FIELD = "__key";
2068
+ var _controllers = new WeakMap;
2069
+ function getGridController(tab) {
2070
+ return tab ? _controllers.get(toRaw(tab)) ?? null : null;
2071
+ }
2072
+ function createGridController(tab, source) {
2073
+ const state = reactive({
2074
+ columns: [],
2075
+ error: null,
2076
+ grouping: null,
2077
+ loading: false,
2078
+ query: {},
2079
+ rows: [],
2080
+ saving: false,
2081
+ total: 0
2082
+ });
2083
+ let rowByKey = new Map;
2084
+ const indexRows = (rows) => {
2085
+ rowByKey = new Map(rows.map((row) => [row.key, row]));
2086
+ };
2087
+ const buffer = createEditBuffer({
2088
+ resolveBaseline: (rowKey, field) => rowByKey.get(rowKey)?.cells[field] ?? null
2089
+ });
2090
+ const reloadRows = async () => {
2091
+ const result = await source.rows(state.query);
2092
+ state.rows = result.rows;
2093
+ state.total = result.total;
2094
+ indexRows(result.rows);
2095
+ };
2096
+ const requiredViolations = (batch) => {
2097
+ const required = state.columns.filter((c) => c.required && c.editable);
2098
+ if (required.length === 0) {
2099
+ return null;
2100
+ }
2101
+ const cells = batch.cells.filter((cell) => cell.value === null && required.some((c) => c.field === cell.field)).map((cell) => ({ error: "Required", field: cell.field, ok: false, rowKey: cell.rowKey }));
2102
+ const inserts = batch.inserts.filter((insert) => required.some((c) => insert.cells[c.field] === null || insert.cells[c.field] === undefined)).map((insert) => {
2103
+ const missing = required.filter((c) => insert.cells[c.field] === null || insert.cells[c.field] === undefined).map((c) => c.field).join(", ");
2104
+ return { error: `Missing required: ${missing}`, ok: false, tempKey: insert.tempKey };
2105
+ });
2106
+ if (cells.length === 0 && inserts.length === 0) {
2107
+ return null;
2108
+ }
2109
+ return { cells, deletes: [], inserts };
2110
+ };
2111
+ const isBlank = (value) => value === null || value === "" || Array.isArray(value) && value.length === 0;
2112
+ const compareCells = (a, b, kind) => {
2113
+ if (kind === "number") {
2114
+ return (typeof a === "number" ? a : 0) - (typeof b === "number" ? b : 0);
2115
+ }
2116
+ if (kind === "boolean") {
2117
+ return (a === true ? 1 : 0) - (b === true ? 1 : 0);
2118
+ }
2119
+ return cellToText(a).localeCompare(cellToText(b));
2120
+ };
2121
+ const orderedKeys = () => {
2122
+ let keys = state.rows.map((row) => row.key);
2123
+ const { dir, orderBy } = state.query;
2124
+ if (orderBy && !source.capabilities.remoteSort) {
2125
+ const kind = state.columns.find((column) => column.field === orderBy)?.kind;
2126
+ const sign = dir === "desc" ? -1 : 1;
2127
+ keys = keys.toSorted((ka, kb) => {
2128
+ const a = buffer.effectiveValue(ka, orderBy);
2129
+ const b = buffer.effectiveValue(kb, orderBy);
2130
+ if (isBlank(a) !== isBlank(b)) {
2131
+ return isBlank(a) ? 1 : -1;
2132
+ }
2133
+ return sign * compareCells(a, b, kind);
2134
+ });
2135
+ }
2136
+ return state.grouping ? [...groupBuckets(keys).values()].flat() : keys;
2137
+ };
2138
+ const groupBuckets = (keys) => {
2139
+ const buckets = new Map;
2140
+ for (const key of keys) {
2141
+ const value = cellToText(buffer.effectiveValue(key, state.grouping));
2142
+ const bucket = buckets.get(value);
2143
+ if (bucket) {
2144
+ bucket.push(key);
2145
+ } else {
2146
+ buckets.set(value, [key]);
2147
+ }
2148
+ }
2149
+ return buckets;
2150
+ };
2151
+ let viewBinding = null;
2152
+ const syncView = () => viewBinding?.refreshData();
2153
+ const controller = {
2154
+ addRow(cells = {}) {
2155
+ const tempKey = buffer.insertRow(cells);
2156
+ syncView();
2157
+ return tempKey;
2158
+ },
2159
+ bindView(view) {
2160
+ viewBinding = view;
2161
+ },
2162
+ buffer,
2163
+ deleteRows(rowKeys) {
2164
+ if (rowKeys.length === 0) {
2165
+ return;
2166
+ }
2167
+ buffer.group(() => {
2168
+ for (const rowKey of rowKeys) {
2169
+ buffer.deleteRow(rowKey);
2170
+ }
2171
+ });
2172
+ syncView();
2173
+ },
2174
+ discardRow(rowKey) {
2175
+ buffer.discardRow(rowKey);
2176
+ syncView();
2177
+ },
2178
+ replaceAll(find, replace) {
2179
+ if (find === "") {
2180
+ return 0;
2181
+ }
2182
+ const textColumns = state.columns.filter((column) => column.editable && (column.kind === "string" || column.kind === "text"));
2183
+ const rowKeys = [...state.rows.map((row) => row.key), ...buffer.state.inserts.keys()];
2184
+ let changed = 0;
2185
+ buffer.group(() => {
2186
+ for (const rowKey of rowKeys) {
2187
+ if (buffer.rowState(rowKey) === "pending-delete") {
2188
+ continue;
2189
+ }
2190
+ for (const column of textColumns) {
2191
+ const value = buffer.effectiveValue(rowKey, column.field);
2192
+ if (typeof value === "string" && value.includes(find)) {
2193
+ buffer.setCell(rowKey, column.field, value.replaceAll(find, replace));
2194
+ changed += 1;
2195
+ }
2196
+ }
2197
+ }
2198
+ });
2199
+ if (changed > 0) {
2200
+ syncView();
2201
+ }
2202
+ return changed;
2203
+ },
2204
+ effectiveRows() {
2205
+ const plain = (value) => Array.isArray(value) ? [...value] : value !== null && typeof value === "object" ? { $ref: value.$ref } : value;
2206
+ const rowObject = (key) => {
2207
+ const cells = { [ROW_KEY_FIELD]: key };
2208
+ for (const column of state.columns) {
2209
+ cells[column.field] = plain(buffer.effectiveValue(key, column.field));
2210
+ }
2211
+ return cells;
2212
+ };
2213
+ const rows = orderedKeys().map((key) => rowObject(key));
2214
+ for (const [tempKey] of buffer.state.inserts) {
2215
+ rows.push(rowObject(tempKey));
2216
+ }
2217
+ return rows;
2218
+ },
2219
+ groups() {
2220
+ if (!state.grouping) {
2221
+ return [];
2222
+ }
2223
+ return [...groupBuckets(orderedKeys())].map(([value, keys]) => ({
2224
+ count: keys.length,
2225
+ value
2226
+ }));
2227
+ },
2228
+ async load() {
2229
+ state.loading = true;
2230
+ state.error = null;
2231
+ try {
2232
+ state.columns = await source.columns();
2233
+ await reloadRows();
2234
+ } catch (error) {
2235
+ state.error = errorMessage2(error);
2236
+ } finally {
2237
+ state.loading = false;
2238
+ }
2239
+ syncView();
2240
+ },
2241
+ async refresh() {
2242
+ if (buffer.isDirty()) {
2243
+ const confirmed = await showConfirmDialog2("Refresh Grid", `Discard ${buffer.dirtyCount()} pending change(s) and reload?`, { confirmLabel: "Discard & Reload", destructive: true });
2244
+ if (!confirmed) {
2245
+ return;
2246
+ }
2247
+ }
2248
+ buffer.reset();
2249
+ await source.refresh?.();
2250
+ await this.load();
2251
+ },
2252
+ async save() {
2253
+ if (state.saving) {
2254
+ return;
2255
+ }
2256
+ const batch = buffer.buildBatch();
2257
+ const changeCount = batch.cells.length + batch.inserts.length + batch.deletes.length;
2258
+ if (changeCount === 0) {
2259
+ notify2.info("No grid changes to save.", { key: "grid.save" });
2260
+ return;
2261
+ }
2262
+ const violations = requiredViolations(batch);
2263
+ if (violations) {
2264
+ buffer.applyCommitResult(violations);
2265
+ notify2.warn("Required cells are empty — fix the marked rows, then save again.", {
2266
+ key: "grid.save",
2267
+ source: "Data",
2268
+ tier: "problem"
2269
+ });
2270
+ return;
2271
+ }
2272
+ if (batch.deletes.length > 0) {
2273
+ const confirmed = await showConfirmDialog2("Delete Rows", `Save will permanently delete ${batch.deletes.length} row(s). Continue?`, { confirmLabel: "Delete & Save", destructive: true });
2274
+ if (!confirmed) {
2275
+ return;
2276
+ }
2277
+ }
2278
+ const affectedRows = new Set(batch.cells.map((c) => c.rowKey)).size + batch.inserts.length + batch.deletes.length;
2279
+ const progress = affectedRows > 5 ? showProgressModal({ title: "Saving grid" }) : null;
2280
+ state.saving = true;
2281
+ try {
2282
+ const result = await source.commit(batch);
2283
+ const cellKey = (rowKey, field) => `${rowKey}\x00${field}`;
2284
+ const batchCells = new Map(batch.cells.map((c) => [cellKey(c.rowKey, c.field), c]));
2285
+ for (const outcome of result.cells) {
2286
+ const cell = batchCells.get(cellKey(outcome.rowKey, outcome.field));
2287
+ if (outcome.ok && cell) {
2288
+ const row = rowByKey.get(outcome.rowKey);
2289
+ if (row) {
2290
+ row.cells[outcome.field] = cell.value;
2291
+ }
2292
+ }
2293
+ }
2294
+ buffer.applyCommitResult(result);
2295
+ const structural = result.inserts.some((r) => r.ok) || result.deletes.some((r) => r.ok);
2296
+ if (structural) {
2297
+ await reloadRows();
2298
+ }
2299
+ const okCount = result.cells.filter((r) => r.ok).length + result.inserts.filter((r) => r.ok).length + result.deletes.filter((r) => r.ok).length;
2300
+ const failed = changeCount - okCount;
2301
+ const staleCount = result.cells.filter((r) => r.stale).length + result.deletes.filter((r) => r.stale).length;
2302
+ if (failed === 0) {
2303
+ notify2.success(`Saved ${okCount} change(s).`, { key: "grid.save" });
2304
+ } else {
2305
+ notify2.error(`Saved ${okCount} · ${failed} failed${staleCount ? ` (${staleCount} stale)` : ""} — kept pending.`, { action: "file.save", key: "grid.save", source: "Data" });
2306
+ }
2307
+ } catch (error) {
2308
+ notify2.error("Could not save the grid.", {
2309
+ action: "file.save",
2310
+ detail: errorMessage2(error),
2311
+ key: "grid.save",
2312
+ source: "Data"
2313
+ });
2314
+ } finally {
2315
+ state.saving = false;
2316
+ progress?.done();
2317
+ syncView();
2318
+ }
2319
+ },
2320
+ serializeForSource() {
2321
+ if (!source.serializeForSource) {
2322
+ return null;
2323
+ }
2324
+ return source.serializeForSource(buffer.buildBatch());
2325
+ },
2326
+ async setQuery(query) {
2327
+ state.query = query;
2328
+ state.loading = true;
2329
+ try {
2330
+ await reloadRows();
2331
+ } catch (error) {
2332
+ state.error = errorMessage2(error);
2333
+ } finally {
2334
+ state.loading = false;
2335
+ }
2336
+ syncView();
2337
+ },
2338
+ setGrouping(field) {
2339
+ state.grouping = field;
2340
+ syncView();
2341
+ },
2342
+ async setSort(sort) {
2343
+ const query = { ...state.query };
2344
+ if (sort) {
2345
+ query.orderBy = sort.field;
2346
+ query.dir = sort.dir;
2347
+ } else {
2348
+ delete query.orderBy;
2349
+ delete query.dir;
2350
+ }
2351
+ if (!source.capabilities.remoteSort) {
2352
+ state.query = query;
2353
+ syncView();
2354
+ return;
2355
+ }
2356
+ await this.setQuery(query);
2357
+ },
2358
+ source,
2359
+ state,
2360
+ tab
2361
+ };
2362
+ tab.scope.run(() => {
2363
+ effect(() => {
2364
+ tab.doc.dirty = buffer.isDirty();
2365
+ });
2366
+ setHistoryDelegate(tab, {
2367
+ canRedo: () => buffer.canRedo(),
2368
+ canUndo: () => buffer.canUndo(),
2369
+ redo: () => {
2370
+ buffer.redo();
2371
+ syncView();
2372
+ },
2373
+ undo: () => {
2374
+ buffer.undo();
2375
+ syncView();
2376
+ }
2377
+ });
2378
+ const platform = getPlatform2();
2379
+ if (platform.subscribeFileEvents && source.backingPaths) {
2380
+ const unsubscribe = platform.subscribeFileEvents((events) => {
2381
+ const backing = source.backingPaths();
2382
+ const hitKeys = new Set;
2383
+ for (const event of events) {
2384
+ if (event.isDir) {
2385
+ continue;
2386
+ }
2387
+ const path = event.path.replaceAll("\\", "/");
2388
+ const rowKey = backing.get(path);
2389
+ if (rowKey !== undefined && !isRecentLocal2(path)) {
2390
+ hitKeys.add(rowKey);
2391
+ }
2392
+ }
2393
+ if (hitKeys.size === 0) {
2394
+ return;
2395
+ }
2396
+ if (buffer.isDirty()) {
2397
+ const keys = hitKeys.has("*") ? state.rows.map((row) => row.key) : [...hitKeys];
2398
+ buffer.markStale(keys);
2399
+ notify2.warn("Grid rows changed on disk — marked stale; refresh to reload.", {
2400
+ key: "grid.stale",
2401
+ source: "Data"
2402
+ });
2403
+ syncView();
2404
+ } else {
2405
+ controller.refresh();
2406
+ }
2407
+ });
2408
+ onScopeDispose(unsubscribe);
2409
+ }
2410
+ onScopeDispose(() => {
2411
+ setHistoryDelegate(tab, null);
2412
+ _controllers.delete(toRaw(tab));
2413
+ source.dispose?.();
2414
+ });
2415
+ });
2416
+ _controllers.set(toRaw(tab), controller);
2417
+ return controller;
2418
+ }
2419
+
2420
+ // src/files/serialize-document.ts
2421
+ async function serializeDocument(tab) {
2422
+ const grid = getGridController(tab);
2423
+ const gridText = grid?.serializeForSource();
2424
+ if (gridText) {
2425
+ return gridText;
2426
+ }
2427
+ await loadFormats2();
2428
+ const sourceFormat = formatByName2(tab.doc.sourceFormat);
2429
+ if (sourceFormat?.capabilities.serialize) {
2430
+ const fm = tab.doc.content?.frontmatter || {};
2431
+ const doc = tab.doc.document;
2432
+ const fullDoc = { ...fm, ...doc, children: doc.children ?? [] };
2433
+ return formatSerialize2(sourceFormat.name, fullDoc, { mode: "roundtrip" });
2434
+ }
2435
+ if (tab.doc.mode === "content") {
2436
+ const format = defaultContentFormat2();
2437
+ if (format) {
2438
+ const fm = tab.doc.content?.frontmatter ?? {};
2439
+ const hasFrontmatter = Object.keys(fm).length > 0;
2440
+ const fullDoc = { ...fm, ...tab.doc.document };
2441
+ return formatSerialize2(format.name, fullDoc, {
2442
+ frontmatter: hasFrontmatter,
2443
+ mode: "roundtrip"
2444
+ });
2445
+ }
2446
+ }
2447
+ return serializeJson(tab.doc.document, tab.doc.layout ?? null);
2448
+ }
2449
+
2450
+ // src/preview/preview-overlay.ts
2451
+ var PUBLISH_DEBOUNCE_MS = 200;
2452
+ var PUBLISH_MAX_WAIT_MS = 500;
2453
+ var MAX_ENTRY_BYTES = 2 * 1024 * 1024;
2454
+ var published = new Map;
2455
+ var armed = false;
2456
+ var scope = null;
2457
+ var timer = null;
2458
+ var burstStartedAt = null;
2459
+ var inFlight = null;
2460
+ function dirtyTabs() {
2461
+ const tabs = [];
2462
+ for (const tab of workspace2.tabs.values()) {
2463
+ if (tab.doc.dirty && tab.documentPath) {
2464
+ tabs.push(tab);
2465
+ }
2466
+ }
2467
+ return tabs;
2468
+ }
2469
+ async function publish() {
2470
+ if (!hasPlatform2()) {
2471
+ return;
2472
+ }
2473
+ const platform = getPlatform2();
2474
+ if (!platform.setPreviewOverlay || !platform.clearPreviewOverlay) {
2475
+ return;
2476
+ }
2477
+ const live = new Set;
2478
+ for (const tab of dirtyTabs()) {
2479
+ const path = tab.documentPath.replace(/^\.\//, "");
2480
+ let text;
2481
+ try {
2482
+ text = await serializeDocument(tab);
2483
+ } catch {
2484
+ continue;
2485
+ }
2486
+ if (text.length > MAX_ENTRY_BYTES) {
2487
+ continue;
2488
+ }
2489
+ live.add(path);
2490
+ if (published.get(path) === text) {
2491
+ continue;
2492
+ }
2493
+ published.set(path, text);
2494
+ await platform.setPreviewOverlay(path, text);
2495
+ }
2496
+ for (const path of published.keys()) {
2497
+ if (!live.has(path)) {
2498
+ published.delete(path);
2499
+ await platform.clearPreviewOverlay(path);
2500
+ }
2501
+ }
2502
+ }
2503
+ function schedule() {
2504
+ if (!armed) {
2505
+ return;
2506
+ }
2507
+ const now = Date.now();
2508
+ burstStartedAt ??= now;
2509
+ if (timer) {
2510
+ clearTimeout(timer);
2511
+ }
2512
+ const waited = now - burstStartedAt;
2513
+ const delay = Math.max(0, Math.min(PUBLISH_DEBOUNCE_MS, PUBLISH_MAX_WAIT_MS - waited));
2514
+ timer = setTimeout(() => {
2515
+ timer = null;
2516
+ burstStartedAt = null;
2517
+ inFlight = publish().finally(() => {
2518
+ inFlight = null;
2519
+ });
2520
+ }, delay);
2521
+ }
2522
+ function notePreviewOverlayEdit() {
2523
+ schedule();
2524
+ }
2525
+ function armPreviewOverlay() {
2526
+ if (armed) {
2527
+ return;
2528
+ }
2529
+ armed = true;
2530
+ scope = effectScope();
2531
+ scope.run(() => {
2532
+ effect(() => {
2533
+ for (const tab of workspace2.tabs.values()) {
2534
+ tab.doc.dirty;
2535
+ tab.doc.document;
2536
+ }
2537
+ schedule();
2538
+ });
2539
+ });
2540
+ }
2541
+ function disarmPreviewOverlay() {
2542
+ armed = false;
2543
+ if (timer) {
2544
+ clearTimeout(timer);
2545
+ timer = null;
2546
+ }
2547
+ burstStartedAt = null;
2548
+ scope?.stop();
2549
+ scope = null;
2550
+ published.clear();
2551
+ }
2552
+ async function flushPreviewOverlay() {
2553
+ if (!armed) {
2554
+ return;
2555
+ }
2556
+ if (timer) {
2557
+ clearTimeout(timer);
2558
+ timer = null;
2559
+ burstStartedAt = null;
2560
+ }
2561
+ await inFlight;
2562
+ await publish();
2563
+ }
2564
+
2565
+ // ../schema/src/media-type.ts
2566
+ var RESTRICTED_NAME = /^[A-Za-z0-9][A-Za-z0-9!#$&^_.+-]{0,126}$/;
2567
+ var KNOWN_TREES = new Set(["vnd", "prs", "x"]);
2568
+ function parseMediaType(value) {
2569
+ if (typeof value !== "string") {
2570
+ return null;
2571
+ }
2572
+ const [essence, ...paramParts] = value.split(";");
2573
+ const slash = (essence ?? "").indexOf("/");
2574
+ if (slash === -1) {
2575
+ return null;
2576
+ }
2577
+ const type = (essence ?? "").slice(0, slash).trim().toLowerCase();
2578
+ const rawSubtype = (essence ?? "").slice(slash + 1).trim().toLowerCase();
2579
+ if (!RESTRICTED_NAME.test(type) || !RESTRICTED_NAME.test(rawSubtype)) {
2580
+ return null;
2581
+ }
2582
+ const plus = rawSubtype.lastIndexOf("+");
2583
+ const suffix = plus === -1 ? null : rawSubtype.slice(plus + 1);
2584
+ const withoutSuffix = plus === -1 ? rawSubtype : rawSubtype.slice(0, plus);
2585
+ if (suffix === "") {
2586
+ return null;
2587
+ }
2588
+ const dot = withoutSuffix.indexOf(".");
2589
+ const facet = dot === -1 ? null : withoutSuffix.slice(0, dot);
2590
+ const tree = facet !== null && KNOWN_TREES.has(facet) ? facet : null;
2591
+ const subtype = tree === null ? withoutSuffix : withoutSuffix.slice(tree.length + 1);
2592
+ if (subtype === "") {
2593
+ return null;
2594
+ }
2595
+ const parameters = {};
2596
+ for (const part of paramParts) {
2597
+ const eq = part.indexOf("=");
2598
+ if (eq === -1) {
2599
+ return null;
2600
+ }
2601
+ const name = part.slice(0, eq).trim().toLowerCase();
2602
+ let paramValue = part.slice(eq + 1).trim();
2603
+ if (name === "") {
2604
+ return null;
2605
+ }
2606
+ if (paramValue.startsWith('"') && paramValue.endsWith('"') && paramValue.length >= 2) {
2607
+ paramValue = paramValue.slice(1, -1);
2608
+ }
2609
+ parameters[name] = paramValue;
2610
+ }
2611
+ return { parameters, subtype, suffix, tree, type };
2612
+ }
2613
+ function mediaTypeEssence(value) {
2614
+ const media = parseMediaType(value);
2615
+ if (media === null) {
2616
+ return null;
2617
+ }
2618
+ const facet = media.tree === null ? "" : `${media.tree}.`;
2619
+ const suffix = media.suffix === null ? "" : `+${media.suffix}`;
2620
+ return `${media.type}/${facet}${media.subtype}${suffix}`;
2621
+ }
2622
+ var MARKDOWN_MEDIA_TYPE = "text/markdown; variant=GFM";
2623
+ var YAML_MEDIA_TYPE = "application/yaml";
2624
+ var MEDIA_TYPE_BY_EXTENSION = {
2625
+ ".markdown": `${MARKDOWN_MEDIA_TYPE}; charset=utf-8`,
2626
+ ".md": `${MARKDOWN_MEDIA_TYPE}; charset=utf-8`,
2627
+ ".yaml": `${YAML_MEDIA_TYPE}; charset=utf-8`,
2628
+ ".yml": `${YAML_MEDIA_TYPE}; charset=utf-8`
2629
+ };
2630
+
2631
+ // src/files/file-ops.ts
2632
+ async function parseFormatSource(format, source) {
2633
+ const doc = await formatParse2(format.name, source);
2634
+ return splitFormatDocument2(format, doc);
2635
+ }
2636
+ async function parseSourceForPath2(path, source) {
2637
+ await loadFormats2();
2638
+ const format = formatForPath2(path);
2639
+ if (!format || !format.capabilities.parse) {
2640
+ throw noFormatError2(path);
2641
+ }
2642
+ const result = await parseFormatSource(format, source);
2643
+ return { ...result, format };
2644
+ }
2645
+ var parseCollabSource2 = async (tab, text) => {
2646
+ if (tab.documentPath && formatForPath2(tab.documentPath)) {
2647
+ const parsed = await parseSourceForPath2(tab.documentPath, text);
2648
+ return { document: parsed.document, frontmatter: parsed.frontmatter };
2649
+ }
2650
+ const parsed = parseJsonDocument(text);
2651
+ tab.doc.layout = parsed.layout;
2652
+ return { document: parsed.document };
2653
+ };
2654
+ var _onDocumentSaved = () => {};
2655
+ function setDocumentSavedListener2(listener) {
2656
+ _onDocumentSaved = listener;
2657
+ }
2658
+ function reportSaved(tab) {
2659
+ noteDocumentSaved(tab.documentPath);
2660
+ const doc = tab.doc.document;
2661
+ _onDocumentSaved(tab.documentPath, doc);
2662
+ const warning = typeof doc.tagName === "string" && doc.tagName.includes("-") ? validateComponentSlots(doc) : null;
2663
+ if (warning) {
2664
+ notify2.warn(warning, {
2665
+ key: `slots:${tab.documentPath ?? tab.id}`,
2666
+ ...tab.documentPath === null ? {} : { path: tab.documentPath },
2667
+ source: "Components",
2668
+ tier: "problem"
2669
+ });
2670
+ }
2671
+ reportPopoverProblems(doc, tab.documentPath ?? undefined);
2672
+ }
2673
+ function hasSerializableDocument(tab) {
2674
+ return !isMediaFile(tab.documentPath ?? "");
2675
+ }
2676
+ async function saveFile2(tab = activeTab2.value) {
2677
+ if (!tab) {
2678
+ return false;
2679
+ }
2680
+ await flushCanvasEdits2(tab.id);
2681
+ if (collabReadOnly(tab)) {
2682
+ notify2.warn(`You have read access to this session — changes to ${tab.documentPath ?? "this document"} ` + `stay in your browser and cannot be saved.`, {
2683
+ action: "file.save",
2684
+ key: `save.readOnly:${tab.documentPath ?? tab.id}`,
2685
+ ...tab.documentPath === null ? {} : { path: tab.documentPath },
2686
+ source: "Collaboration"
2687
+ });
2688
+ return false;
2689
+ }
2690
+ if (!hasSerializableDocument(tab)) {
2691
+ notify2.warn(`${tab.documentPath ?? "This file"} is a media file, so there is no document for Save to write.`, {
2692
+ key: `save.notADocument:${tab.documentPath ?? tab.id}`,
2693
+ ...tab.documentPath === null ? {} : { path: tab.documentPath },
2694
+ source: "Save"
2695
+ });
2696
+ return false;
2697
+ }
2698
+ const grid = getGridController(tab);
2699
+ if (grid) {
2700
+ await grid.save();
2701
+ return !tab.doc.dirty;
2702
+ }
2703
+ try {
2704
+ if (await collabSave(tab)) {
2705
+ reportSaved(tab);
2706
+ return true;
2707
+ }
2708
+ const output = await serializeDocument(tab);
2709
+ if (tab.documentPath) {
2710
+ const platform = getPlatform2();
2711
+ await platform.writeFile(tab.documentPath, output);
2712
+ tab.doc.dirty = false;
2713
+ flushPreviewOverlay();
2714
+ reportSaved(tab);
2715
+ return true;
2716
+ }
2717
+ if (tab.fileHandle && "createWritable" in tab.fileHandle) {
2718
+ const writable = await tab.fileHandle.createWritable();
2719
+ await writable.write(output);
2720
+ await writable.close();
2721
+ tab.doc.dirty = false;
2722
+ reportSaved(tab);
2723
+ return true;
2724
+ }
2725
+ notify2.warn("This document has no save target — use Export.", { key: "save.noTarget" });
2726
+ } catch (error) {
2727
+ if (!(error instanceof Error && error.name === "AbortError")) {
2728
+ notify2.error(`Could not save ${tab.documentPath ?? tab.id}.`, {
2729
+ action: "file.save",
2730
+ detail: errorMessage2(error),
2731
+ key: `save:${tab.documentPath ?? tab.id}`,
2732
+ ...tab.documentPath === null ? {} : { path: tab.documentPath },
2733
+ source: "Save"
2734
+ });
2735
+ }
2736
+ }
2737
+ return false;
2738
+ }
2739
+ function tabFormat(tab) {
2740
+ return formatByName2(tab.doc.sourceFormat) ?? (tab.doc.mode === "content" ? defaultContentFormat2() : undefined);
2741
+ }
2742
+ async function exportFile2() {
2743
+ const tab = activeTab2.value;
2744
+ if (!tab) {
2745
+ return;
2746
+ }
2747
+ try {
2748
+ await loadFormats2();
2749
+ const format = tabFormat(tab);
2750
+ const output = await serializeDocument(tab);
2751
+ const mimeType = format ? mediaTypeEssence(format.mediaType) ?? "text/plain" : "application/json";
2752
+ const ext = format ? format.extensions[0] : ".json";
2753
+ const description = format ? format.name : "Jx Component";
2754
+ const fallbackName = format ? `content${ext}` : "component.json";
2755
+ if ("showSaveFilePicker" in window) {
2756
+ const suggestedName = tab.documentPath ? tab.documentPath.split("/").pop() : fallbackName;
2757
+ const handle = await window.showSaveFilePicker({
2758
+ suggestedName,
2759
+ types: [{ accept: { [mimeType]: [ext] }, description }]
2760
+ });
2761
+ const writable = await handle.createWritable();
2762
+ await writable.write(output);
2763
+ await writable.close();
2764
+ tab.doc.dirty = false;
2765
+ reportSaved(tab);
2766
+ notify2.success(`Exported as ${handle.name}.`);
2767
+ } else {
2768
+ const blob = new Blob([output], { type: mimeType });
2769
+ const url = URL.createObjectURL(blob);
2770
+ const a = document.createElement("a");
2771
+ a.href = url;
2772
+ a.download = fallbackName;
2773
+ a.click();
2774
+ URL.revokeObjectURL(url);
2775
+ tab.doc.dirty = false;
2776
+ reportSaved(tab);
2777
+ notify2.success(`Downloaded ${fallbackName}.`);
2778
+ }
2779
+ } catch (error) {
2780
+ if (!(error instanceof Error && error.name === "AbortError")) {
2781
+ notify2.error("Could not export the document.", {
2782
+ detail: errorMessage2(error),
2783
+ source: "Export"
2784
+ });
2785
+ }
2786
+ }
2787
+ }
2788
+ async function usageLine(path, verb) {
2789
+ const state = isMediaFile(path) ? await loadMediaUsages(path) : await loadUsages2({ path });
2790
+ return usageWarning2(state, verb) ?? "";
2791
+ }
2792
+ async function confirmFileDelete2(file) {
2793
+ const consequence = await usageLine(file.path, "delete");
2794
+ const question = `Delete ${file.name}? This cannot be undone.`;
2795
+ return Boolean(await showConfirmDialog2("Delete File", consequence === "" ? question : `${question} ${consequence}`, { confirmLabel: "Delete", destructive: true }));
2796
+ }
2797
+ async function renamePromptMessage2(path, verb = "rename") {
2798
+ const consequence = await usageLine(path, verb);
2799
+ return consequence === "" ? undefined : consequence;
2800
+ }
2801
+
2802
+ export { cellValuesEqual, makeGridTabId, parseGridTabId, gridTabLabel, columnsFromSchema, inferColumnsFromRows, coerceCellInput, cellToText, ROW_KEY_FIELD, getGridController, createGridController, PANE_SELECTOR, STAGE_SELECTOR, mountPaneGridSurface, attachJumpBarHost, mountJumpBar, projectSessions, renderStatusbar, mountStatusbar, registerPopoverCommands, serializeDocument, notePreviewOverlayEdit, armPreviewOverlay, disarmPreviewOverlay, flushPreviewOverlay, mediaTypeEssence, parseSourceForPath2, parseCollabSource2, setDocumentSavedListener2, saveFile2, exportFile2, confirmFileDelete2, renamePromptMessage2 };
2803
+
2804
+ //# debugId=F690D395FACA498E64756E2164756E21
2805
+ //# sourceMappingURL=studio-rpyah2ew.js.map