@jxsuite/studio 10.2.0 → 10.3.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 (271) hide show
  1. package/dist/chunks/{2020-bx702wqa.js → 2020-906vx2dq.js} +3 -3
  2. package/dist/chunks/adapter-hnvad61x.js +4 -0
  3. package/dist/chunks/add-new-flow-3tkn72ey.js +4 -0
  4. package/dist/chunks/cf-account-picker-xb8vvt2h.js +4 -0
  5. package/dist/chunks/cf-settings-mkbcz4z2.js +4 -0
  6. package/dist/chunks/components-w5zqwva1.js +4 -0
  7. package/dist/chunks/content-source-1vzxq1ba.js +4 -0
  8. package/dist/chunks/convert-to-repeater-gwzh9gar.js +4 -0
  9. package/dist/chunks/editor-wvf5e6j9.js +4 -0
  10. package/dist/chunks/entry-commands-mx2whrjx.js +4 -0
  11. package/dist/chunks/extension-sections-338ee35t.js +4 -0
  12. package/dist/chunks/file-ops-9bxvk59j.js +4 -0
  13. package/dist/chunks/files-t07yqqej.js +4 -0
  14. package/dist/chunks/format-host-5ja5gxyk.js +4 -0
  15. package/dist/chunks/fs-events-3424ezp3.js +4 -0
  16. package/dist/chunks/grid-open-1mpq9mzb.js +4 -0
  17. package/dist/chunks/{grid-view-tghcwrrt.js → grid-view-w9nfy203.js} +16 -16
  18. package/dist/chunks/icons-gb967qc8.js +4 -0
  19. package/dist/chunks/iframe-host-wsg0bn73.js +4 -0
  20. package/dist/chunks/image-bake-4afr4y6a.js +4 -0
  21. package/dist/chunks/image-editor-x7t8jbjn.js +4 -0
  22. package/dist/chunks/index-f9qr7kzh.js +4 -0
  23. package/dist/chunks/{index-vr006kbt.js → index-yjrfeks8.js} +3 -3
  24. package/dist/chunks/{javascript-z1g3s9fd.js → javascript-hy2mws8v.js} +3 -3
  25. package/dist/chunks/{jsonMode-7szwg8c4.js → jsonMode-vj30te2h.js} +6 -6
  26. package/dist/chunks/jx-validate-ttr5ewf0.js +4 -0
  27. package/dist/chunks/layers-m49nmwvx.js +4 -0
  28. package/dist/chunks/layers-panel-hvy2e549.js +4 -0
  29. package/dist/chunks/lit-html-k2mb9k0r.js +4 -0
  30. package/dist/chunks/media-library-ae67q4at.js +4 -0
  31. package/dist/chunks/media-open-yp9jm834.js +4 -0
  32. package/dist/chunks/media-picker-s41ngdfr.js +4 -0
  33. package/dist/chunks/{monaco-binding-v42w9c1v.js → monaco-binding-a51py33c.js} +3 -3
  34. package/dist/chunks/monaco-buffer-pa0g6ax7.js +4 -0
  35. package/dist/chunks/{monaco-setup-7bffxd6v.js → monaco-setup-g9kterhx.js} +3 -3
  36. package/dist/chunks/notify-bwehrp7q.js +4 -0
  37. package/dist/chunks/parse-hee7ne9b.js +4 -0
  38. package/dist/chunks/platform-kv0k65cy.js +4 -0
  39. package/dist/chunks/publish-panel-gzfxcm0t.js +4 -0
  40. package/dist/chunks/publish-quick-w3nxd7q4.js +4 -0
  41. package/dist/chunks/publish-workspace-dppd82tc.js +4 -0
  42. package/dist/chunks/quick-search-tdxaam55.js +4 -0
  43. package/dist/chunks/references-vqyr5s9x.js +4 -0
  44. package/dist/chunks/right-panel-0yrw4cgz.js +4 -0
  45. package/dist/chunks/source-control-6fk72me2.js +4 -0
  46. package/dist/chunks/{studio-j3d2fjqz.js → studio-0939t1q1.js} +4 -4
  47. package/dist/chunks/studio-0gvvqj3h.js +5 -0
  48. package/dist/chunks/studio-0khd8xtx.js +4 -0
  49. package/dist/chunks/studio-0w3541dg.js +7 -0
  50. package/dist/chunks/{studio-9b7177jq.js → studio-0x6f3nk9.js} +4 -4
  51. package/dist/chunks/studio-1410q5dw.js +5 -0
  52. package/dist/chunks/{studio-awxwjawq.js → studio-15hwqgd8.js} +4 -4
  53. package/dist/chunks/studio-1ks5d9y4.js +5 -0
  54. package/dist/chunks/{studio-881z1xrx.js → studio-2ggfzrrd.js} +4 -4
  55. package/dist/chunks/{studio-4jhw38b2.js → studio-321ym1tt.js} +4 -4
  56. package/dist/chunks/studio-3c10v2q1.js +5 -0
  57. package/dist/chunks/{studio-bvs9kpst.js → studio-3na1r48j.js} +8 -8
  58. package/dist/chunks/{studio-86r8hp7r.js → studio-3q7mhbgx.js} +5 -5
  59. package/dist/chunks/studio-3qr08sxq.js +4 -0
  60. package/dist/chunks/studio-3xk9zdgb.js +5 -0
  61. package/dist/chunks/{studio-qh8berdz.js → studio-423tfdte.js} +4 -4
  62. package/dist/chunks/{studio-75kcdbsk.js → studio-45mj4jqe.js} +4 -4
  63. package/dist/chunks/studio-4f7thq0p.js +5 -0
  64. package/dist/chunks/studio-4fnb5648.js +5 -0
  65. package/dist/chunks/studio-4zd6an2b.js +5 -0
  66. package/dist/chunks/studio-53wy9ek3.js +5 -0
  67. package/dist/chunks/studio-5n193zqd.js +5 -0
  68. package/dist/chunks/{studio-9rbe2xpw.js → studio-5tet77de.js} +3 -3
  69. package/dist/chunks/{studio-ybnwymxw.js → studio-7rrdbvex.js} +4 -4
  70. package/dist/chunks/studio-8kx6m0rg.js +5 -0
  71. package/dist/chunks/{studio-sxdb9h3q.js → studio-90zkgne5.js} +7 -7
  72. package/dist/chunks/studio-9c6cbq2c.js +4 -0
  73. package/dist/chunks/studio-9dq7rwc7.js +5 -0
  74. package/dist/chunks/{studio-cg1bfyhf.js → studio-9qx1ywbv.js} +8 -8
  75. package/dist/chunks/studio-a65kbs2e.js +9 -0
  76. package/dist/chunks/studio-aam8zt8z.js +5 -0
  77. package/dist/chunks/{studio-er5f383a.js → studio-abh9kfdh.js} +4 -4
  78. package/dist/chunks/studio-b4e0ftkt.js +5 -0
  79. package/dist/chunks/studio-b68k0z00.js +5 -0
  80. package/dist/chunks/{studio-399a25za.js → studio-bct64zmj.js} +4 -4
  81. package/dist/chunks/studio-bz0b5brj.js +6 -0
  82. package/dist/chunks/studio-cfnn70h1.js +5 -0
  83. package/dist/chunks/studio-daksw8kh.js +5 -0
  84. package/dist/chunks/{studio-r7pf0rkv.js → studio-e7vjyp04.js} +7 -7
  85. package/dist/chunks/studio-ea6r1zyr.js +5 -0
  86. package/dist/chunks/studio-egnjpyde.js +9 -0
  87. package/dist/chunks/studio-ejrypvmq.js +5 -0
  88. package/dist/chunks/studio-eqcddvc2.js +928 -0
  89. package/dist/chunks/studio-f8tyeyzt.js +5 -0
  90. package/dist/chunks/studio-fj6c905s.js +5 -0
  91. package/dist/chunks/{studio-646nn2ys.js → studio-fkrr7kgg.js} +5 -5
  92. package/dist/chunks/studio-fspe7m9t.js +5 -0
  93. package/dist/chunks/studio-g0hxtcga.js +5 -0
  94. package/dist/chunks/{studio-th7z3fg7.js → studio-g9brbewz.js} +4 -4
  95. package/dist/chunks/studio-ggx3j7nd.js +5 -0
  96. package/dist/chunks/{studio-43y04qck.js → studio-hfxttkyr.js} +4 -4
  97. package/dist/chunks/studio-hh394phe.js +5 -0
  98. package/dist/chunks/{studio-pjtntksy.js → studio-j0zf5x2x.js} +4 -4
  99. package/dist/chunks/studio-jeb7hth3.js +5 -0
  100. package/dist/chunks/studio-k0xzrse2.js +64 -0
  101. package/dist/chunks/studio-k1xqrgm5.js +5 -0
  102. package/dist/chunks/studio-k2evngrj.js +7 -0
  103. package/dist/chunks/studio-k3we3kqb.js +5 -0
  104. package/dist/chunks/{studio-sevbc3xv.js → studio-n9qba0gx.js} +4 -4
  105. package/dist/chunks/{studio-6hzdjfv0.js → studio-nf8esxxc.js} +4 -4
  106. package/dist/chunks/studio-nn4f9m9c.js +5 -0
  107. package/dist/chunks/studio-nskxe9q1.js +6 -0
  108. package/dist/chunks/{studio-ea74s8c1.js → studio-nvcn2ykc.js} +4 -4
  109. package/dist/chunks/studio-nwynxqtb.js +5 -0
  110. package/dist/chunks/studio-nzemfbkk.js +14 -0
  111. package/dist/chunks/studio-p2a03pgm.js +5 -0
  112. package/dist/chunks/{studio-4g8yb6jn.js → studio-pm17wdc4.js} +4 -4
  113. package/dist/chunks/{studio-71m92v9s.js → studio-q80fg1d6.js} +7 -7
  114. package/dist/chunks/studio-r050sez0.js +6 -0
  115. package/dist/chunks/studio-s7t4vp1d.js +6 -0
  116. package/dist/chunks/studio-s9fng7m8.js +7 -0
  117. package/dist/chunks/studio-sce30r7b.js +4 -0
  118. package/dist/chunks/studio-stahswgb.js +7 -0
  119. package/dist/chunks/studio-swedpd82.js +5 -0
  120. package/dist/chunks/studio-thz5t120.js +5 -0
  121. package/dist/chunks/studio-tpxcryf2.js +5 -0
  122. package/dist/chunks/{studio-wc6za3zs.js → studio-v5wktj6f.js} +4 -4
  123. package/dist/chunks/{studio-kg1abnz0.js → studio-vpevkfxw.js} +4 -4
  124. package/dist/chunks/studio-waekn290.js +5 -0
  125. package/dist/chunks/studio-wfct4h6n.js +5 -0
  126. package/dist/chunks/studio-wgc54sxf.js +5 -0
  127. package/dist/chunks/studio-wqfaqw4m.js +5 -0
  128. package/dist/chunks/studio-wse1rs8t.js +7 -0
  129. package/dist/chunks/studio-x0gsfr1d.js +16 -0
  130. package/dist/chunks/{studio-hhp4x8xf.js → studio-xpx91fby.js} +5 -5
  131. package/dist/chunks/studio-y1b86ast.js +5 -0
  132. package/dist/chunks/studio-yrcrncev.js +5 -0
  133. package/dist/chunks/{studio-rzqaz21g.js → studio-yzpskb0j.js} +4 -4
  134. package/dist/chunks/studio-zfdbmhp3.js +5 -0
  135. package/dist/chunks/{tsMode-f54j66ym.js → tsMode-jg1dtphj.js} +7 -7
  136. package/dist/chunks/workspace-9btkc8tk.js +4 -0
  137. package/dist/chunks/workspace-home-qcc4z5ag.js +4 -0
  138. package/dist/chunks/{ws-client-e8kj684q.js → ws-client-arz2qsy9.js} +3 -3
  139. package/dist/iframe-entry.js +13 -13
  140. package/dist/manifest.json +83 -78
  141. package/dist/studio.js +84 -84
  142. package/package.json +2 -2
  143. package/src/browse/library-pane.ts +44 -29
  144. package/src/browse/library-preview.ts +6 -2
  145. package/src/canvas/asset-refs.ts +13 -4
  146. package/src/canvas/asset-resolve.ts +54 -11
  147. package/src/canvas/canvas-render.ts +25 -0
  148. package/src/canvas/iframe-entry.ts +5 -1
  149. package/src/canvas/iframe-host.ts +16 -6
  150. package/src/canvas/iframe-protocol.ts +9 -1
  151. package/src/commands/context.ts +5 -0
  152. package/src/commands/live-context.ts +5 -2
  153. package/src/editor/shortcuts.ts +3 -0
  154. package/src/files/asset-versions.ts +108 -2
  155. package/src/files/file-ops.ts +11 -1
  156. package/src/files/files.ts +111 -48
  157. package/src/files/media-paths.ts +12 -4
  158. package/src/files/media-upload.ts +195 -21
  159. package/src/files/new-file-name.ts +39 -1
  160. package/src/media/image-bake.ts +164 -0
  161. package/src/media/image-editor.ts +846 -0
  162. package/src/media/image-format.ts +262 -0
  163. package/src/media/image-recipe.ts +651 -0
  164. package/src/media/media-commands.ts +65 -1
  165. package/src/media/media-library-model.ts +1 -1
  166. package/src/media/media-library.ts +175 -15
  167. package/src/media/media-open.ts +156 -3
  168. package/src/media/media-pane.ts +8 -4
  169. package/src/panels/pane-context.ts +6 -1
  170. package/src/panels/tab-strip.ts +12 -3
  171. package/src/studio.ts +13 -2
  172. package/src/surfaces/image-editor.json +1390 -0
  173. package/src/surfaces/image-editor.ts +272 -0
  174. package/src/surfaces/media-library.json +129 -1
  175. package/src/surfaces/media-library.ts +17 -2
  176. package/src/types.ts +2 -1
  177. package/src/workspace/tab-workspace.ts +2 -1
  178. package/src/workspace/workspace-switch.ts +3 -1
  179. package/src/workspace/workspace.ts +22 -1
  180. package/dist/chunks/adapter-pp011m5x.js +0 -4
  181. package/dist/chunks/add-new-flow-ecqmzz76.js +0 -4
  182. package/dist/chunks/cf-account-picker-c07znkqt.js +0 -4
  183. package/dist/chunks/cf-settings-0v2bmqy0.js +0 -4
  184. package/dist/chunks/components-yn0dn2pq.js +0 -4
  185. package/dist/chunks/content-source-g0j41yy6.js +0 -4
  186. package/dist/chunks/convert-to-repeater-sbjk7tgn.js +0 -4
  187. package/dist/chunks/editor-xz02jeh1.js +0 -4
  188. package/dist/chunks/entry-commands-kmt02crp.js +0 -4
  189. package/dist/chunks/extension-sections-0rprf12d.js +0 -4
  190. package/dist/chunks/file-ops-mexj5qed.js +0 -4
  191. package/dist/chunks/files-b2tcppdd.js +0 -4
  192. package/dist/chunks/format-host-btsevv0c.js +0 -4
  193. package/dist/chunks/fs-events-r0apejva.js +0 -4
  194. package/dist/chunks/grid-open-n2a8xkht.js +0 -4
  195. package/dist/chunks/icons-853n6qt3.js +0 -4
  196. package/dist/chunks/iframe-host-gx0ypyh3.js +0 -4
  197. package/dist/chunks/index-bs4k9tr6.js +0 -4
  198. package/dist/chunks/jx-validate-ymf10teh.js +0 -4
  199. package/dist/chunks/layers-p9nfya38.js +0 -4
  200. package/dist/chunks/layers-panel-tt1hzhhf.js +0 -4
  201. package/dist/chunks/lit-html-x18n2sfz.js +0 -4
  202. package/dist/chunks/media-library-0n45gv8r.js +0 -4
  203. package/dist/chunks/media-picker-s09at95z.js +0 -4
  204. package/dist/chunks/monaco-buffer-een2ea0v.js +0 -4
  205. package/dist/chunks/notify-qwb8radt.js +0 -4
  206. package/dist/chunks/parse-v77xtwv7.js +0 -4
  207. package/dist/chunks/platform-8jnez0wr.js +0 -4
  208. package/dist/chunks/publish-panel-aysnj611.js +0 -4
  209. package/dist/chunks/publish-quick-kpbqs9mz.js +0 -4
  210. package/dist/chunks/publish-workspace-nd0a8q99.js +0 -4
  211. package/dist/chunks/quick-search-vg0jkhk2.js +0 -4
  212. package/dist/chunks/references-a7v6a0e2.js +0 -4
  213. package/dist/chunks/right-panel-cvk1vxx5.js +0 -4
  214. package/dist/chunks/source-control-fsqzc6he.js +0 -4
  215. package/dist/chunks/studio-05jfwbmf.js +0 -5
  216. package/dist/chunks/studio-0q5jwddh.js +0 -9
  217. package/dist/chunks/studio-0w2dr0q8.js +0 -5
  218. package/dist/chunks/studio-1tzpds97.js +0 -9
  219. package/dist/chunks/studio-216b27sv.js +0 -4
  220. package/dist/chunks/studio-2ejhqns4.js +0 -5
  221. package/dist/chunks/studio-2r90cts3.js +0 -16
  222. package/dist/chunks/studio-399xknkb.js +0 -6
  223. package/dist/chunks/studio-4ncmwqw5.js +0 -5
  224. package/dist/chunks/studio-5atwjgkj.js +0 -7
  225. package/dist/chunks/studio-5frqk7c0.js +0 -5
  226. package/dist/chunks/studio-6cwj6xrx.js +0 -5
  227. package/dist/chunks/studio-78pywnp2.js +0 -6
  228. package/dist/chunks/studio-886t6ztg.js +0 -5
  229. package/dist/chunks/studio-8wnvtr4z.js +0 -5
  230. package/dist/chunks/studio-8z66jk4z.js +0 -5
  231. package/dist/chunks/studio-b2qpt0xy.js +0 -14
  232. package/dist/chunks/studio-c71806xz.js +0 -7
  233. package/dist/chunks/studio-cbwks69x.js +0 -928
  234. package/dist/chunks/studio-cg710sk9.js +0 -5
  235. package/dist/chunks/studio-cw0wb9qk.js +0 -7
  236. package/dist/chunks/studio-cyheys7k.js +0 -5
  237. package/dist/chunks/studio-ea5m9kg5.js +0 -5
  238. package/dist/chunks/studio-efdxjwyp.js +0 -64
  239. package/dist/chunks/studio-egmw2837.js +0 -5
  240. package/dist/chunks/studio-f746039f.js +0 -5
  241. package/dist/chunks/studio-fmdymd9v.js +0 -5
  242. package/dist/chunks/studio-gcm12z00.js +0 -6
  243. package/dist/chunks/studio-gj98m8gy.js +0 -7
  244. package/dist/chunks/studio-hasbgjah.js +0 -5
  245. package/dist/chunks/studio-hz5n7x27.js +0 -5
  246. package/dist/chunks/studio-jeraxdgv.js +0 -7
  247. package/dist/chunks/studio-jvgek9xt.js +0 -5
  248. package/dist/chunks/studio-jws1a87n.js +0 -5
  249. package/dist/chunks/studio-k2sz13zg.js +0 -5
  250. package/dist/chunks/studio-k3m4jkdk.js +0 -5
  251. package/dist/chunks/studio-kg5ya5r2.js +0 -5
  252. package/dist/chunks/studio-khwbgrtg.js +0 -5
  253. package/dist/chunks/studio-mx6wzh25.js +0 -5
  254. package/dist/chunks/studio-mxs3ar9t.js +0 -5
  255. package/dist/chunks/studio-nm4szey4.js +0 -5
  256. package/dist/chunks/studio-nqxqf8p2.js +0 -4
  257. package/dist/chunks/studio-qn7z4krm.js +0 -5
  258. package/dist/chunks/studio-qyed0ah6.js +0 -5
  259. package/dist/chunks/studio-r4bcdwhq.js +0 -5
  260. package/dist/chunks/studio-rtfnhrdg.js +0 -5
  261. package/dist/chunks/studio-s5tzw84t.js +0 -5
  262. package/dist/chunks/studio-t51y8v1d.js +0 -5
  263. package/dist/chunks/studio-t98vq4r6.js +0 -5
  264. package/dist/chunks/studio-tsxpqvh0.js +0 -6
  265. package/dist/chunks/studio-v1yascv2.js +0 -5
  266. package/dist/chunks/studio-wxq6v5sv.js +0 -5
  267. package/dist/chunks/studio-y60sts62.js +0 -4
  268. package/dist/chunks/studio-zndrqawb.js +0 -5
  269. package/dist/chunks/studio-zwaxn5s2.js +0 -5
  270. package/dist/chunks/workspace-home-x1787wpv.js +0 -4
  271. package/dist/chunks/workspace-zpe1np43.js +0 -4
@@ -0,0 +1,5 @@
1
+ import{xh}from"./studio-yrcrncev.js";import{Rb}from"./studio-e7vjyp04.js";import{C}from"./studio-4f7thq0p.js";import{n,_}from"./studio-k3we3kqb.js";function PT(){return Object.keys(C?.projectConfig?.content??{})}function Sa(e){let t=Rb(e);if(!t)return null;if(/\.[a-z\d]+$/i.test(t.dir))return null;return{def:t.def,dir:t.dir,ext:t.ext,name:t.name,schema:t.def.schema??null}}function Bw(){return PT().map((e)=>Sa(e)).filter((e)=>e!==null)}function Fc(e){let t=xh(e??null,C?.projectConfig);return t?Sa(t.name):null}function PN(e){let t=xh(e??null,C?.projectConfig),r=t?Rb(t.name):null;if(!t||!r)return null;return{def:r.def,dir:r.dir,ext:r.ext,name:r.name,schema:t.schema}}function c(e){if(e===null||!_(e))return e;return JSON.parse(JSON.stringify(e))}function u(e){if(n(e.$ref))return"";switch(e.type){case"boolean":return!1;case"integer":case"number":return 0;case"array":return[];case"object":return FT(e);default:return""}}function FT(e){let t=e?.properties;if(!t)return{};let r=new Set(Array.isArray(e.required)?e.required:[]),o={};for(let[i,l]of Object.entries(t))if(l.default!==void 0)o[i]=c(l.default);else if(r.has(i))o[i]=u(l);return o}function FN(e,t){return(Array.isArray(e?.required)?e.required:[]).filter((o)=>t[o]===void 0)}
2
+ export{PT,Sa,Bw,Fc,PN,FT,FN};
3
+
4
+ //# debugId=4648C6745ACF5D3064756E2164756E21
5
+ //# sourceMappingURL=studio-wgc54sxf.js.map
@@ -0,0 +1,5 @@
1
+ import{ja}from"./studio-3qr08sxq.js";var t=ja(null);function jO(e){t.value=e}function ae(){return t.value}
2
+ export{jO,ae};
3
+
4
+ //# debugId=FD3E2412AC5C8C1564756E2164756E21
5
+ //# sourceMappingURL=studio-wqfaqw4m.js.map
@@ -0,0 +1,7 @@
1
+ import{ft}from"./studio-5tet77de.js";import{X}from"./studio-9c6cbq2c.js";import{Tn,nt,Fn}from"./studio-tpxcryf2.js";import{ar,w}from"./studio-sce30r7b.js";import{ae}from"./studio-wqfaqw4m.js";import{cf,p,ye}from"./studio-4fnb5648.js";import{jt,Ih,sc,ou,Aa,lf,fn,wl}from"./studio-aam8zt8z.js";import{us}from"./studio-4zd6an2b.js";import{$s,Um}from"./studio-hh394phe.js";import{Wt,ln,go,Gm,wv,Jd,Gn,fi,m,Da,oc,rc,Si,SI,Ft,kv,CI}from"./studio-yrcrncev.js";import{Wp,PO,FO,Ls}from"./studio-bct64zmj.js";import{rt,Eo,xr}from"./studio-g9brbewz.js";import{Es,fO,z$,yO,Ix,Rx}from"./studio-x0gsfr1d.js";import{sl}from"./studio-a65kbs2e.js";import{ei}from"./studio-3q7mhbgx.js";import{Ea}from"./studio-n9qba0gx.js";import{yf}from"./studio-1ks5d9y4.js";import{Br,Ks,Js,zr}from"./studio-90zkgne5.js";import{Kw,Im,Rm,Fb}from"./studio-8kx6m0rg.js";import{UC,q$,G$,iv,Wm,Jc,Ys}from"./studio-y1b86ast.js";import{HT,HS}from"./studio-fspe7m9t.js";import{Qw}from"./studio-ggx3j7nd.js";import{qN,Fr,Ab,Ob}from"./studio-thz5t120.js";import{jb,Zu}from"./studio-p2a03pgm.js";import{zt}from"./studio-daksw8kh.js";import{Fw,jw,Hw}from"./studio-g0hxtcga.js";import{Fc}from"./studio-wgc54sxf.js";import{Vs}from"./studio-j0zf5x2x.js";import{C,id,_n}from"./studio-4f7thq0p.js";import{E,R}from"./studio-9dq7rwc7.js";import{g}from"./studio-3qr08sxq.js";import{n,_}from"./studio-k3we3kqb.js";import{ce}from"./studio-0939t1q1.js";async function Lb(){if(Kw(location.search))return!1;let e=p();if(!e.dependenciesNeedInstall||!e.installDependencies)return!1;let t=!1;try{t=await e.dependenciesNeedInstall()}catch{return!1}if(!t)return!1;let o=sl({status:"Installing dependencies…",title:"Installing dependencies"});try{let r=await e.installDependencies();if(r.ok)return o.done(),!0;o.fail(r.log??"Install failed")}catch(r){o.fail(r instanceof Error?r.message:String(r))}return!1}var Le=["page","component"],Me={components:"component",pages:"page"};function L(e){return e.replaceAll("\\","/").replace(/^\.\//,"")}function Ae(e){let t=L(e).toLowerCase();for(let[o,r]of Object.entries(Me))if(t.startsWith(`${o}/`))return r;return null}function K(e){return Le.some((t)=>e.includes(t))}function He(e){let t=C?.projectConfig?.layout;if(!n(t))return!1;return L(t).toLowerCase()===L(e).toLowerCase()}function $S(e){let t=[{ext:".json",label:"JSON (.json)"}];for(let o of wl(e)){let r=Aa(o,"parse");if(r&&Aa(o,"serialize"))t.push({ext:o,label:`${r.name} (${o})`})}return t}function ie(){return new Set([".json",...ou().flatMap((e)=>e.extensions)])}function IS(e){if(e===null||e===void 0||e==="")return[];let t=Ae(e);if(t===null||He(e)||Gn(e))return[];let o=fn(e);if(!(o?Boolean(o.capabilities.parse)&&K(o.documentKinds):L(e).toLowerCase().endsWith(".json")))return[];let a=[];if(o)a.push({ext:".json",label:"JSON (.json)"});for(let i of wl()){let s=Aa(i,"serialize");if(!s||s.name===o?.name||!K(s.documentKinds)||!s.documentKinds.includes(t))continue;a.push({ext:i,label:`${s.name} (${i})`})}return a}function RN(){let e=new Set([".json"]);for(let t of ou()){if(!t.capabilities.serialize||!K(t.documentKinds))continue;for(let o of t.extensions)e.add(o)}return[...e].toSorted()}var Y="jx-studio-recent-projects",le="jx-studio-recent-files",se=8,We=10,T=[];function M(){if(!ye())return null;let e=p();return ze(e)?e:null}function ze(e){return Boolean(e.getRecentProjects&&e.saveRecentProjects)}function _e(){try{let e=localStorage.getItem(Y);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function Q(){return M()?T:_e()}function de(e){T=e;let t=M();if(t)t.saveRecentProjects(e);else try{localStorage.setItem(Y,JSON.stringify(e))}catch{}}async function DN(){let e=M();if(!e)return;try{T=await e.getRecentProjects()}catch{T=[]}}function Nw(){return Q().toSorted((e,t)=>t.timestamp-e.timestamp)}function Aw(e,t){let o=Q().filter((r)=>r.root!==t);if(o.unshift({name:e,root:t,timestamp:ar()}),o.length>se)o.length=se;de(o)}function RS(e){de(Q().filter((t)=>t.root!==e))}function NN(){T=[];let e=M();if(e)e.saveRecentProjects([]);else localStorage.removeItem(Y)}function pe(){try{let e=localStorage.getItem(le);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function AN(e){let t=pe().toSorted((o,r)=>r.timestamp-o.timestamp);return e==null?t:t.filter((o)=>o.root===e)}function $b(e){let t=pe().filter((a)=>!(a.root===e.root&&a.path===e.path));t.unshift({name:e.name,path:e.path,root:e.root,timestamp:ar()});let o=new Map,r=[];for(let a of t.toSorted((i,s)=>s.timestamp-i.timestamp)){let i=(o.get(a.root)??0)+1;if(o.set(a.root,i),i<=We)r.push(a)}localStorage.setItem(le,JSON.stringify(r))}var ue={$schema:"https://jxsuite.com/schema/v1",$id:"StudioFilesPanel",$description:'The Navigator\'s Files tree, as a Jx document over the kit. `files/files.ts` keeps every decision — which directories are listed, which entries `.gitignore` masks, which rows the window draws, what a click on a row means, what the context menu offers and what each verb does to the filesystem — and hands this document one projection: a word saying which of three things to draw, a toolbar whose state is already resolved, and rows whose every field is already a string. Nothing here asks what a file is, how tall the Navigator is, or whether a directory has been read. THE TREE IS `jx-tree`, and that is what this document no longer says: `role="tree"`, `role="treeitem"`, `aria-level`, `aria-posinset`, `aria-setsize`, the roving `tabindex` and the five arrow-key cases were each written out here and written out again in `panel-outline.json`, two copies of one keyboard contract with nothing holding them in agreement. The element owns all of it; what is left here is what this tree IS — a flat projection of rows, each already carrying its own level and set counts, because the DOM holds a WINDOW onto the model and an expanded `node_modules` is eleven rows rather than ten thousand. The window reaches the element as `padtop`/`padbottom`, and a caret move past either comes back as `move` for the flow to scroll and repaint. Four facts a row carries are bound against ONE scope field each — the current path, the selected path, the dragged path and the drop target — so moving the caret or dragging a file re-evaluates an attribute per drawn row instead of rebuilding the list under the reader\'s pointer. The pragmatic-drag-and-drop handles are an ISLAND: the document draws the rows and the tree, and the adapter attaches sources and targets to them through `onNodeCreated` (specs/studio-ui-guidelines.md §9.4).',tagName:"div",attributes:{part:"files"},style:{$description:"What the twenty `.file-tree*`, `.files-toolbar`, `.project-header` and `.project-name` rules in `styles/panels.css` said, keyed on `part` and re-pointed at the studio token layer. Three names could not come with the declarations. The five `var(--spectrum-font-size-50 | -75, …)` reads are the kit's `--jx-text-sm` and `--jx-text-md`, which are the same 11px and 12px — a `--spectrum-*` name is declared by `<sp-theme>` and by nothing else in this package, so a document that reads one is a document whose type size changes when a component it does not use is removed. The `.selected`, `.dragging`, `.drag-over` and `.drag-over-root` classes are `data-` attributes on a part, because a part is the handle now and because a state a handler adds and forgets to take off is exactly the defect a cancelled drag used to leave on screen. MOST OF THE ROW'S OWN RULES ARE GONE, and that is the point of the element rather than an omission: `jx-tree-item` declares the flex line, the one-control-height box the window reserves scroll by, the indent (`--jx-tree-indent` times one less than `level` — exactly the `8 + depth * 16` this file composed per row), the hover and focus states, the selected wash and the faded dragged row. What is left here is what is TRUE OF THIS TREE and not of trees in general: it owns its own scrollbar, a click on a row opens it, and the row a drag is over wears the drop mark this file draws.",display:"flex",flexDirection:"column",height:"100%",minHeight:"0",overflow:"hidden",fontFamily:"var(--jx-font-sans)",fontSize:"var(--jx-text-md)",color:"var(--fg)",'& [part="empty"]':{$description:"The two states that are not a tree. They are two states and not one sentence: a window with no project at all and a monorepo root that has not been pointed at a site are different situations, and only the second has anything to offer (studio-ui-guidelines.md §11).",padding:"var(--jx-space-6)",textAlign:"center",color:"var(--fg-dim)",fontSize:"var(--jx-text-md)",display:"flex",flexDirection:"column",alignItems:"center",gap:"var(--jx-space-4)"},'& [part="empty"] p':{margin:"0"},'& [part="frame"]':{display:"flex",flexDirection:"column",height:"100%",minHeight:"0"},'& [part="project-header"]':{display:"flex",alignItems:"center",gap:"var(--jx-space-3)",padding:"var(--jx-space-3) var(--jx-space-4)",borderBottom:"1px solid var(--border)",flexShrink:"0"},'& [part="project-name"]':{fontSize:"var(--jx-text-md)",fontWeight:"600",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},'& [part="toolbar"]':{display:"flex",gap:"var(--jx-space-2)",padding:"var(--jx-space-2) var(--jx-space-3)",borderBottom:"1px solid var(--border)",alignItems:"center",flexShrink:"0"},'& [part="search"]':{flex:"1",minWidth:"0"},'& [part="tree"]':{$description:"The scroller as well as the list. `ui/virtual-window.ts` walks up from the element it is given looking for the nearest thing that scrolls, and finding itself is the shortest answer — which is why the element declares no `overflow` of its own and leaves the question to the two trees that answer it differently. The colour is re-declared because `jx-tree` sets `--jx-fg` on itself, and this panel's text colour is the studio alias of it.",flex:"1",minHeight:"0",overflowY:"auto",color:"var(--fg)"},'& [part="tree"][data-drop="true"]':{background:"var(--hover-bg)"},'& [part="row"]':{$description:"What the element does not decide. A click on a row OPENS it here — a directory unfolds, a file takes a tab — so the pointer is a pointer rather than the element's default arrow; and the gap is the wider one this tree has always drawn between a 16px file glyph and its name.",gap:"var(--jx-space-3)",cursor:"pointer"},'& [part="loading-row"]':{$description:"A directory whose listing has not arrived yet. It holds the place and it is NOT a row: it is not a `jx-tree-item`, so the caret cannot land on it, the set counts do not include it and typeahead cannot match it — and it is replaced by the real rows on the repaint the listing provokes. It draws the same box by hand because it is the only line in this tree the element does not draw, and a placeholder of a different height would desynchronise the window's scroll reservation from the rows it reserves for.",display:"flex",alignItems:"center",boxSizing:"border-box",blockSize:"var(--jx-control-h)",paddingInline:"calc(var(--jx-space-3) + var(--depth, 0) * 16px) var(--jx-space-3)",color:"var(--fg-dim)",fontStyle:"italic",cursor:"default",userSelect:"none",whiteSpace:"nowrap"},'& [part="row-icon"]':{flexShrink:"0",display:"flex",alignItems:"center","--jx-icon-size":"16px"},'& [part="locale"]':{$description:"The language chip. Deliberately declares no block size, no padding and no line height: the row above is one control-height by contract, and a chip that grew the box would desynchronise the window's scroll reservation from the height it reserves by. It only ever shrinks the text. A chip, not a filter term: the search matches the file's name alone, because a query that silently also matched a language would make “why is this file here” unanswerable from what is on screen.",marginInlineStart:"auto",flexShrink:"0",fontSize:"var(--jx-text-sm)",color:"var(--fg-dim)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxInlineSize:"6em"},'& [part="view-slot"], & [part="header-slot"], & [part="locale-slot"]':{$description:"A `$switch` renders its own container, and none of these three is a box: each stands exactly where its case does, so the case's own rule is the only one that lays anything out.",display:"contents"}},children:[{tagName:"div",attributes:{part:"view-slot",role:"none"},$switch:{$ref:"#/state/view"},cases:{none:{tagName:"div",attributes:{part:"empty"},children:[{tagName:"p",textContent:"No project loaded"}]},address:{tagName:"div",attributes:{part:"empty"},children:[{tagName:"p",textContent:"Add ?project= and a project folder's absolute path to this page's address to open it."}]},welcome:{tagName:"div",attributes:{part:"empty"},children:[{tagName:"p",textContent:"Open a project folder to get started."},{tagName:"jx-button",attributes:{part:"open-project"},$props:{variant:"accent",size:"sm"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/openProject"},value:[]}],description:"The declared `project.open` command, run through the registry — not a second opener of this surface's own. It is the one the chord, the palette and the status bar's PROJECT field already run, so a window that opens a project from here reports the outcome the same way they do (studio-ui-guidelines.md §12.5)."},children:[{tagName:"span",textContent:"Open Project"}]}]},tree:{tagName:"div",attributes:{part:"frame"},children:[{tagName:"div",attributes:{part:"header-slot",role:"none"},$switch:{$ref:"#/state/headerState"},cases:{shown:{tagName:"div",attributes:{part:"project-header"},children:[{tagName:"span",attributes:{part:"project-name",title:"${state.projectName}"},textContent:"${state.projectName}"}]}}},{tagName:"div",attributes:{part:"toolbar"},children:[{$description:"A row of quiet tools, so NOT compact. A compact group draws every member's frame and fill whatever its quiet says, which is the segmented look a choice wants and not the borderless one a toolbar wants; Spectrum's group here was `compact quiet`, a combination the kit spells as compact=false with its members' default quiet.",tagName:"jx-action-group",attributes:{part:"toolbar-actions"},$props:{compact:!1,label:"File tree actions"},children:[{tagName:"jx-action-button",attributes:{part:"new-file"},$props:{size:"sm",icon:"plus",label:"New File",hint:"New File"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/newFile"},value:[]}]}},{tagName:"jx-action-button",attributes:{part:"refresh"},$props:{size:"sm",icon:"arrows-clockwise",label:"Refresh",hint:"Refresh"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/refresh"},value:[]}],description:"The rules go with the listings. Refresh is what an author reaches for after editing a `.gitignore` by hand, and a tree that came back still hiding by the old rules would read as the button not having worked."}},{tagName:"jx-action-button",attributes:{part:"show-ignored"},$props:{size:"sm",icon:{$ref:"#/state/ignoredIcon"},label:{$ref:"#/state/ignoredLabel"},hint:{$ref:"#/state/ignoredLabel"},selected:{$ref:"#/state/ignoredSelected"}},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/toggleIgnored"},value:[]}],description:"A repaint and nothing else: the ignored entries were never dropped from the cached listings, only from the rows built out of them."}}]},{tagName:"jx-textfield",attributes:{part:"search"},$props:{label:"Filter files",placeholder:"Filter files…",size:"sm",value:{$ref:"#/state/query"}},oninput:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/search"},value:[{$ref:"event#/target/value"}]}],description:"The query matches a file's NAME and nothing else. A directory is kept whatever it says, because hiding the folder a match sits in would leave the match with nowhere to be drawn."}}]},{$description:'The `role="tree"`, and everything that used to be spelled out under it. The element writes the role, the name, the roving tab stop and every row\'s `aria-level` / `aria-posinset` / `aria-setsize`, and it owns the whole ARIA keyboard: the arrows walk the drawn rows without wrapping, `Home` and `End` reach the ends of the MODEL by way of the pads, `ArrowRight` opens a directory and steps into an open one, `ArrowLeft` closes one and otherwise steps out to its parent, `Enter` activates and a printable character is typeahead. Every chord it does not own — cut, copy, paste, delete, rename — passes straight through to the flow, which is the WCAG 2.5.7 obligation this tree carries because dragging a file is the other way to move it. What reaches this document is five events, and each of them is a decision `files.ts` already owned.',tagName:"jx-tree",attributes:{part:"tree",label:"Project files",current:"${state.currentPath}",padtop:"${state.padTop}",padbottom:"${state.padBottom}","data-drop":"${state.rootDrop || null}"},onselect:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/select"},value:[{$ref:"event#/detail/value"}]}],description:"The reader meant that row. This tree is single-select, so the element resolves every modifier to `replace` before it gets here and the detail's `mode` and `anchor` are answers to a question this tree does not ask. There is no `change` handler beside it on purpose: the element OWNS the caret and keeps it across every repaint that does not change `current`, so a second copy of it in the flow would be a variable that only ever went stale."},onactivate:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/activate"},value:[{$ref:"event#/detail"}]}],description:"`Enter` or a double click. The same verb a single click reaches, by the same name."},onexpand:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/expand"},value:[{$ref:"event#/detail/value"},{$ref:"event#/detail/expanded"}]}],description:"`ArrowRight`, `ArrowLeft` or the twisty, with ONE dispatcher between them: the detail says the state the row should be PUT INTO, so the flow never has to work out which way a toggle was going."},onmove:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/move"},value:[{$ref:"event#/detail/from"},{$ref:"event#/detail/key"}]}],description:"The caret has to reach a row the window did not draw. The element knows only that the pad on that side is not zero; where the row is in the model, and how far to scroll to bring it into view, is the flow's — which is why this is an event and not a `scrollIntoView`."},ontypeahead:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/typeahead"},value:[{$ref:"event#/detail/from"},{$ref:"event#/detail/char"}]}],description:"A printable character, on a windowed tree. The same hand-off as `onmove` and for a sharper reason: a move off the end of the slice announces itself, and a letter never does — the element's own search over the drawn rows always answers, and over a `node_modules` of ten thousand entries the answer is whichever of the eleven painted rows happened to start with that letter. So the element dispatches EVERY such character and the flow answers it over the model."},children:[{$prototype:"Array",items:{$ref:"#/state/rows"},key:{$ref:"$map/item/key"},map:{tagName:"div",attributes:{part:"row-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"$map/item/kind"},cases:{item:{tagName:"jx-tree-item",attributes:{part:"row",value:"${$map.item.path}",label:"${$map.item.name}",level:"${$map.item.level}",posinset:"${$map.item.posInSet}",setsize:"${$map.item.setSize}",expanded:"${$map.item.ariaExpanded}",selected:"${state.selectedPath === $map.item.path ? 'true' : 'false'}","data-type":"${$map.item.type}","data-dragging":"${state.dragPath === $map.item.path ? '' : null}","data-drop":"${state.dropPath === $map.item.path ? '' : null}"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/activate"},value:[{$ref:"$map/item/path"}]}],description:"A single click OPENS the row, which is this tree's own answer and not the element's. `jx-tree` answers a click with `change` and `select`, exactly as it answers an arrow key, and a tree that opened on `select` would open every file the reader arrowed past. So the opening verb is bound here, where a click is a click; what a click MEANS — unfold this directory, take a tab for that file — stays the flow's, and Enter reaches the same verb through `activate`. It does NOT stop the event, which is the correction: the tree's delegated click is what moves the caret and the selection onto the row, so a `stopPropagation` here would leave a reader who clicked a folder with the tab stop still on whatever they had open last. The twisty stops its own click, so opening a directory from the chevron does not also activate the row."},oncontextmenu:{$prototype:"Function",body:[{preventDefault:!0},{stopPropagation:!0},{operator:"call",target:{$ref:"#/state/contextMenu"},value:[{$ref:"$map/item/path"},{$ref:"event#/clientX"},{$ref:"event#/clientY"}]}]},children:[{tagName:"jx-icon",attributes:{slot:"icon",part:"row-icon","aria-hidden":"true"},$props:{name:{$ref:"$map/item/icon"}}},{tagName:"div",attributes:{slot:"status",part:"locale-slot",role:"none"},$switch:{$ref:"$map/item/localeState"},cases:{shown:{tagName:"span",attributes:{part:"locale"},textContent:"${$map.item.locale}"}}}]},loading:{$description:"A directory whose listing has not arrived yet. Deliberately not a `jx-tree-item`: there is no file there to select, open, rename or drag, and a row the caret could land on that answers to none of the verbs the caret offers is a stop in the walk with nothing behind it.",tagName:"div",attributes:{part:"loading-row",role:"none","data-loading":"true",style:"--depth:${$map.item.depth}"},textContent:"Loading…"}}}}]}]}}}]};E("files-panel",ue);function fe(e,t){e.view=t.view,e.headerState=t.headerState,e.projectName=t.projectName,e.query=t.query,e.ignoredLabel=t.ignoredLabel,e.ignoredIcon=t.ignoredIcon,e.ignoredSelected=t.ignoredSelected,e.padTop=t.padTop,e.padBottom=t.padBottom,e.rows=t.rows,e.selectedPath=t.selectedPath,e.dragPath=t.dragPath,e.dropPath=t.dropPath,e.rootDrop=t.rootDrop,e.currentPath=t.currentPath}function A(){return{currentPath:"",dragPath:"",dropPath:"",headerState:"hidden",ignoredIcon:"eye-slash",ignoredLabel:"Show ignored files",ignoredSelected:!1,padBottom:0,padTop:0,projectName:"",query:"",rootDrop:"",rows:[],selectedPath:"",view:"none"}}function Je(e){let t=n(e)?void 0:e.attributes?.part;return n(t)?t:""}function qe(e){let t=e?.$map,o=_(t)&&"item"in t?t.item:void 0;if(!_(o)||!("path"in o)||!n(o.path)||!("type"in o)||!n(o.type))return null;return{path:o.path,type:o.type}}function me(e,t,o){let r=g({...A(),...o});fe(r,t);let a=null,i=!1,s=R("files-panel",r,e,{onNodeCreated:(l,c,d,u)=>{if(i||!(l instanceof HTMLElement))return;let x=Je(d);if(x==="tree"){o.treeHost(l);return}if(x!=="row")return;let y=qe(u);if(y)o.rowHost(l,y.path,y.type)}}).then((l)=>{if(i){l.dispose();return}a=l});return{connected:()=>!i&&(a===null||a.root.parentNode===e),dispose(){i=!0,a?.dispose(),a=null},ready:s,update:(l)=>{fe(r,l)}}}async function rl(e){if(!C)return;try{let t=p(),[o]=await Promise.all([$s(()=>t.listDirectory(e)),PO(e)]);C.dirs.set(e,o)}catch{C.dirs.set(e,[])}}var he=new Set(["pages","layouts","components","content","data","public","styles"]);async function Em(){if(!C)return;await rl(".");let e=[];for(let t of C.dirs.get(".")??[])if(t.type==="directory"&&he.has(t.name))e.push(t.name),C.expanded.add(t.path||t.name),await rl(t.path||t.name);C.projectDirs=e}async function TT(e){let t=new Set(C?.projectDirs);if(!e.some((r)=>{let a=r.replaceAll("\\","/").replace(/^\.\//,"").split("/")[0]??"";return r.includes("/")&&he.has(a)&&!t.has(a)}))return!1;return await Em(),!0}function LT(){return Eo(rt.showIgnoredFiles)==="true"}function VP(e){xr(rt.showIgnoredFiles,e?"true":"")}async function $T(){try{let e=p(),t=await e.probeRootProject();if(!t)return;let{meta:o,info:r}=t;if(Ih(),jt(),sc(e),Wp(),Um(),id({dirs:new Map,expanded:new Set,isSiteProject:r.isSiteProject,name:r.isSiteProject?r.projectConfig?.name||o.name:o.name,projectConfig:(r.isSiteProject?r.projectConfig:null)||null,projectDirs:r.directories||[],projectRoot:".",root:o.root,searchQuery:"",selectedPath:null}),r.isSiteProject)rc(o.root||".",r.projectConfig||null);if(r.isSiteProject){if(Aw(_n().name,o.root),await Rm(),await Lb())Ih(),await jt(),sc(e);await Em(),await Ea(),await Ib(),Im(o.root)}}catch{}}async function IT({renderLeftPanel:e,resetProjectCaches:t}){try{let o=p(),r=await o.openProject?.();if(!r)return!1;let{config:a,handle:i}=r;if(SI({document:{children:[],tagName:"div"},id:"initial"}),qN(),Ih(),jt(),sc(o),Wp(),Um(),id({...C,dirs:new Map,expanded:new Set,isSiteProject:!0,name:a.name||i.name,projectConfig:a,projectRoot:i.root,searchQuery:"",selectedPath:null}),rc(i.root,a),await Rm(),await Lb())Ih(),await jt(),sc(o);return await Em(),await Ea(),Fb(),Rx(),t?.(),Aw(_n().name,_n().projectRoot),e(),await Ib(),Im(_n().projectRoot),!0}catch(o){return w.error("Could not open the project.",{detail:X(o),source:"Open Project"}),!1}}async function RT(e){let t=p();if(t.createDestination!=="path")return!1;try{if(await t.activate(e),(await t.gitStatus()).isRepo)return!1;return await t.gitInit(),w.success("Initialized a git repository for this project."),!0}catch(o){return w.warn("Could not initialize a git repository — the project itself was written.",{detail:X(o),source:"Source Control"}),!1}}async function DS(){await jt();let e=[...wl("page"),".json"],t;try{t=await p().listDirectory("pages")}catch{return null}let o=new Set(t.filter((r)=>r.type==="file").map((r)=>r.name));for(let r of e)if(o.has(`index${r}`))return`pages/index${r}`;return null}async function UP(){let e=await DS();if(e)await _i(e)}async function Ib(){let e=yO(m.projectRoot),t=z$(m.projectRoot),o=await Be(e);return ge?.(t),o}var ge=null;function DT(e){ge=e}async function Be(e){if(Ix(m.projectRoot),e){if(await fO(e,{ensureSecondPane:()=>{oc(fi)},openFile:(o,r)=>_i(o,{focus:!1,paneId:r})})>0)return!0}return await UP(),!1}function Ue(e,t,o){if(t==="directory")return o?"folder-open":"folder";let r=e.split(".").pop()?.toLowerCase();switch(r){case"css":case"js":case"json":case"ts":return"file-code";case"md":return"file-text";default:return r!==void 0&&yf(r)?"image":"file"}}var qP=24,f=[],k=null,j=new Map,z=null,we=null;function oe(){for(let e of j.values())if(e.isConnected&&e.offsetHeight>0)return e.offsetHeight;return qP}function Ge(){for(let[e,t]of j)if(!t.isConnected)j.delete(e),Re(t)}function ve(e){let t=j.get(e);return t?.isConnected===!0?t:null}function B(e){return f.find((t)=>!t.loading&&t.path===e)}function be(e,t,o,r){let a=_n().dirs.get(e);if(!a){rl(e).then(()=>h()),o.push({depth:t,expanded:!1,key:`loading:${e}`,loading:!0,name:"Loading…",path:e,posInSet:1,setSize:1,type:"file"});return}let i=[...a].toSorted((d,u)=>{if(d.type==="directory"&&u.type!=="directory")return-1;if(d.type!=="directory"&&u.type==="directory")return 1;return d.name.localeCompare(u.name)}),s=LT()?i:i.filter((d)=>!FO(e,d.path,d.type==="directory")),l=_n().searchQuery.toLowerCase(),c=l?s.filter((d)=>d.type==="directory"||d.name.toLowerCase().includes(l)):s;for(let[d,u]of c.entries()){let y=u.type==="directory"&&_n().expanded.has(u.path);if(o.push({depth:t,expanded:y,key:u.path,loading:!1,name:u.name,path:u.path,locale:go(u.path,r)??void 0,posInSet:d+1,setSize:c.length,type:u.type}),y)be(u.path,t+1,o,r)}}function xe(e){return e===void 0?-1:f.findIndex((t)=>!t.loading&&t.path===e)}function H(e,t){for(let o=e+t;o>=0&&o<f.length;o+=t)if(!f[o].loading)return o;return-1}function Ke(e){let t=f[e];if(!t)return-1;for(let o=e-1;o>=0;o--){let r=f[o];if(!r.loading&&r.depth<t.depth)return o}return-1}function Ye(){if(k?.isConnected!==!0||S!=="")return;queueMicrotask(h)}function ee(){let e=k;if(e===null)return;z=Hw(z,e,{count:()=>f.length,onChange:Ye,rowHeight:oe})}function Qe(e){let t=String(e.depth+1);if(e.loading)return{ariaExpanded:"",depth:String(e.depth),icon:"",key:e.key,kind:"loading",level:t,locale:"",localeState:"hidden",name:e.name,path:e.path,posInSet:"",setSize:"",type:e.type};return{ariaExpanded:e.type==="directory"?String(e.expanded):"",depth:String(e.depth),icon:Ue(e.path,e.type,e.expanded),key:e.key,kind:"item",level:t,locale:e.locale===void 0?"":Wt(e.locale),localeState:e.locale===void 0?"hidden":"shown",name:e.name,path:e.path,posInSet:String(e.posInSet),setSize:String(e.setSize),type:e.type}}function Xe(){if(Ge(),!C){f=[];let l={...A(),view:"none"};return b=l,l}if(!C.isSiteProject&&C.projectRoot==="."){f=[];let l=cf(p())?"welcome":"address",c={...A(),view:l};return b=c,c}let e=_n();f=[];let{i18n:t}=ln(e.projectConfig??{});be(".",0,f,t);let o=Fw(k,{count:f.length,rowHeight:oe()}),r=f.slice(o.start,o.end),a=(e.selectedPath!==null&&B(e.selectedPath)?e.selectedPath:"")||r.find((l)=>!l.loading)?.path||"",i=LT(),s={currentPath:a,dragPath:S,dropPath:I,headerState:e.isSiteProject?"shown":"hidden",ignoredIcon:i?"eye":"eye-slash",ignoredLabel:i?"Hide ignored files":"Show ignored files",ignoredSelected:i,padBottom:o.padBottom,padTop:o.padTop,projectName:e.projectConfig?.name||e.name,query:e.searchQuery,rootDrop:U,rows:r.map((l)=>Qe(l)),selectedPath:e.selectedPath??"",view:"tree"};return b=s,s}function te(){if(!v||!b)return;b={...b,dragPath:S,dropPath:I,rootDrop:U},v.handle.update(b)}function h(){we?.()}async function Ze(){let e=_n();e.dirs.clear(),Wp(),await rl(".");for(let t of e.expanded)await rl(t);h()}function et(e){let t=B(e);if(!t)return;if(t.type==="directory"){je(e).then(()=>h());return}_i(e)}function tt(e,t){let o=_n();if(B(e)?.type!=="directory"||o.expanded.has(e)===t)return;if(!t){o.expanded.delete(e),h();return}je(e).then(()=>h())}function Pe(e){if(!C||_n().selectedPath===e)return;_n().selectedPath=e,h()}function ot(e,t){let o=xe(e),r;switch(t){case"Home":{r=H(-1,1);break}case"End":{r=H(f.length,-1);break}case"ArrowUp":{r=H(o,-1);break}case"ArrowLeft":{r=Ke(o);break}case"ArrowDown":case"ArrowRight":{r=H(o,1);break}default:return}Fe(r)}function at(e,t){let o=xe(e),r=f.length;for(let a=1;a<=r;a++){let i=(o+a+r)%r,s=f[i];if(s&&!s.loading&&s.name.trim().toLowerCase().startsWith(t)){Fe(i);return}}}function Fe(e){let t=f[e];if(!t)return;if(Pe(t.path),ve(t.path))return;jw(k,e,oe()),h()}async function je(e){let t=_n();if(t.expanded.has(e)){t.expanded.delete(e);return}if(t.expanded.add(e),!t.dirs.has(e))await rl(e)}var N=new Map,V=null,S="",J="",I="",q=!1,U="";function GP(e){return[...e.dataTransfer?.types??[]].includes("Files")}function Se(e,t,o){let r=(s)=>{if(!GP(s))return;if(s.preventDefault(),s.stopPropagation(),s.dataTransfer)s.dataTransfer.dropEffect="copy";o(!0)},a=()=>o(!1),i=(s)=>{o(!1);let l=s.dataTransfer?.files;if(!l?.length)return;s.preventDefault(),s.stopPropagation(),ON(l,t,h)};return e.addEventListener("dragover",r),e.addEventListener("dragleave",a),e.addEventListener("drop",i),()=>{e.removeEventListener("dragover",r),e.removeEventListener("dragleave",a),e.removeEventListener("drop",i)}}function NT(e,t){let o=e.replaceAll("\\","/"),r=t.replaceAll("\\","/");if(!o||o===r)return!1;if(o.startsWith(`${r}/`)||r.startsWith(`${o}/`))return!1;return ne(o)!==r}function Z(e,t,o){let r=e.data.path;return o==="directory"&&n(r)&&NT(r,t)}function F(e,t){let o=t?e:"";if(J===e&&I===o)return;J=e,I=o,$e()}function W(e){if(q===e)return;q=e,$e()}function $e(){U=q&&J===""?"true":"",te()}async function ON(e,t,o){if((await Ys([...e],{dir:t})).length===0)return;if(t!==".")_n().expanded.add(t);o()}function KP(e,t){let o=document.createElement("input");o.type="file",o.multiple=!0,o.accept=Jc(),o.addEventListener("change",()=>{if(o.files?.length)ON(o.files,e,t)}),o.click()}function it(e,t,o){Re(e),j.set(t,e);let r=[zr({element:e,getInitialData(){return{entryType:o,path:t,type:"file-tree"}},onDragStart(){S=t,te()},onDrop(){S="",F("",!1),te()}}),Se(e,o==="directory"?t:ne(t),(a)=>{F(a?t:"",a)}),Ks({canDrop({source:a}){return a.data.type==="file-tree"},element:e,getData({source:a}){return Z(a,t,o)?{targetDir:t,type:"file-tree-target"}:{type:"file-tree-refused"}},onDrag({source:a}){F(t,Z(a,t,o))},onDragEnter({source:a}){F(t,Z(a,t,o))},onDragLeave(){F("",!1)},onDrop(){F("",!1)}})];N.set(e,Br(...r))}function Re(e){let t=N.get(e);if(t)t(),N.delete(e)}function st(e){if(V?.element===e)return;ke(),k=e;let t=Ks({canDrop({source:r}){let a=r.data.path;return r.data.type==="file-tree"&&n(a)&&NT(a,".")},element:e,getData(){return{targetDir:".",type:"file-tree-target"}},onDragEnter(){W(!0)},onDragLeave(){W(!1)},onDrop(){W(!1)}}),o=Js({onDrop({source:r,location:a}){let[i]=a.current.dropTargets;if(!i)return;if(r.data.type!=="file-tree")return;if(i.data.type!=="file-tree-target")return;let s=r.data.path,l=i.data.targetDir;if(!n(s)||!n(l)||!NT(s,l))return;let c=s.split("/").pop(),d=l==="."?c:`${l}/${c}`;lt(s,d,h)}});V={cleanup:Br(t,o,Se(e,".",W)),element:e},ee()}function ke(){V?.cleanup(),V=null;for(let e of N.values())e();N.clear(),z?.window.destroy(),z=null,k=null,S="",J="",I="",q=!1,U=""}async function lt(e,t,o){let r=t.split("/").pop()??t,a=ne(t),i={path:e,source:"Files"},s;try{s=await p().listDirectory(a)}catch(d){w.error(`Could not move ${e}.`,{...i,detail:`The folder could not be read to check for ${r}: ${X(d)}`});return}let l=r.toLowerCase(),c=s.find((d)=>d.name.toLowerCase()===l);if(c!==void 0){let d=a==="."?"The project root":`${a}/`;w.error(`Could not move ${e}.`,{...i,detail:`${d} already has ${c.name}, and a move would replace it.`});return}try{let d=await Pw(e,t);if(a!==".")_n().expanded.add(a);o(),Mw(`Moved to ${t}`,d,t)}catch(d){w.error(`Could not move ${e}.`,{...i,detail:X(d)})}}function ne(e){let t=e.replaceAll("\\","/"),o=t.lastIndexOf("/");return o===-1?".":t.slice(0,o)}var D=null;function Ee(){D?.close(),D=null}function ct(e){let t={};if(e.type==="directory"){let o=Jd(e.path);if(o?.isSourceRoot===!0&&!o.fileBacked)t.name=o.name;return t}if(t.file=e.path,Fc(e.path))t.path=e.path;if(IS(e.path).length>0)t.source=e.path;return t}function P(e,t,o,r={}){return{destructive:!1,disabled:!1,dividerAbove:!1,id:e,run:o,title:t,...r}}function dt(e){let t=ae();if(!t)return[];let o=ct(e),r=[];for(let a of t.forPlacement("context/file")){let i=a.args;if(!(i?.required??[]).every((c)=>(c in o)))continue;let s={};for(let c of Object.keys(i?.properties??{}))if(c in o)s[c]=o[c];let l=t.disabledReason(a.id);r.push(l===void 0?P(a.id,a.title,()=>{Tn(t,a.id,s,"Files")}):{destructive:!1,disabled:!0,dividerAbove:!1,id:a.id,requires:l,title:a.title})}return r}function pt(e){let t=e.type==="directory",o=[];if(t){if(o.push(P("files.newFile","New File…",()=>{Te(e.path,h)}),P("files.upload","Upload Files…",()=>{KP(e.path,h)})),e.path==="pages"||e.path.endsWith("/pages"))o.push(P("files.pagesGrid","Edit Pages in Grid",()=>{HS()}))}else o.push(P("files.open","Open",()=>{_i(e.path)}));return o.push(...dt(e),P("files.rename","Rename…",()=>{yt(e,h)},{dividerAbove:!0}),P("files.delete","Delete",()=>{bt(e,h)},{destructive:!0})),o}function ut(e,t,o){let r=B(e);if(!r)return;Ee();let a=ve(e);D=zt({label:"File actions",onClosed:(i)=>{if(D===i)D=null},opener:a,origin:{x:t,y:o},region:"files",rows:pt({name:r.name,path:r.path,type:r.type})})}var mt=JSON.stringify({children:[{children:[],tagName:"p"}],tagName:"div"},null,2);function ht(e){return[...(e.kind==="locked"?[{ext:e.ext,label:`${Aa(e.ext)?.name??e.ext} (${e.ext})`}]:$S(e.docKind)).map((o)=>({label:o.label,value:o.ext})),{dividerBefore:!0,label:"Other…",value:UC}]}function gt(e,t,o){let r=e.kind==="choose"?e.defaultExt:e.ext;if(r!==void 0&&t.some((i)=>i.value===r))return r;let a=q$(o);if(a!==""&&t.some((i)=>i.value===a))return a;return t[0]?.value??UC}async function JP(e){let{dir:t,format:o,source:r="Files"}=e;await jt();let a=await Ow(t),i=o!==void 0&&o.kind!=="fixed"?o:null,s=i===null?null:ht(i),l=i===null||s===null?"":gt(i,s,e.suggestedName??""),c={choice:o,dir:t,known:ie(),rows:s,taken:a},d=(G,Oe)=>iv(G,Oe,c),u=l,x={confirmLabel:"Create",message:t==="."?"Creating in the project root.":`Creating in ${t}/`,select:s===null?"stem":"all",validate:d,value:e.suggestedName??"untitled.json"};if(s!==null)x.choice={initial:l,label:"Format",onChange:(G)=>{u=G},options:()=>s};if(e.suggestedName!==void 0)x.placeholder=e.suggestedName;let y=await Fn(e.title??"New File",x);if(!y)return null;let O=G$(y,u,o),De=t==="."?O:`${t}/${O}`,re=fn(O),Ne=e.content,Ce=o!==void 0&&u!==UC,Ie=Ne??re?.studio?.newFileTemplate??(re?"":O.toLowerCase().endsWith(".json")?Ce?mt:`{}
2
+ `:"");return NS(De,Ie,{dir:t,source:r})}async function Ow(e){try{let t=await p().listDirectory(e);return new Set(t.map((o)=>o.name.toLowerCase()))}catch{return new Set}}async function NS(e,t,o={}){let r=o.dir??(e.includes("/")?e.slice(0,e.lastIndexOf("/")):".");Ls(e);try{if(await p().writeFile(e,t),await rl(r),o.quiet!==!0)w.success(`Created ${e}`);return e}catch(a){return w.error(`Could not create ${e}.`,{detail:X(a),path:e,source:o.source??"Files"}),null}}async function Te(e,t){await jt();let o=Jd(e);if(o?.unresolvedFormat!=null)w.error(`New files in ${e}/ cannot be constrained to the collection's format.`,{detail:`The "${o.name}" content type declares format "${o.unresolvedFormat}", which no installed extension provides. Install the extension that supplies it, or correct `+"the name in Project Settings › Content Types.",path:e,source:"Files"});let r=o?.ext!=null&&o.unresolvedFormat===null,a=r&&o.isSourceRoot&&o.def.schema!==void 0,i;if(a){let{createEntry:s}=await (ce("mx2whrjx"),import("./entry-commands-mx2whrjx.js"));i=await s(o.name,{dir:e})}else i=await JP({dir:e,format:r&&o.ext!==null?{because:`${o.name} entries are ${o.ext} files, so a document of another format here would not be one.`,ext:o.ext,kind:"locked"}:{defaultExt:".json",kind:"choose"},suggestedName:"untitled"});if(i!==null)t()}async function wt(e,t,o){let r=await Ob(t),a={confirmLabel:"Rename",select:"stem",validate:(i)=>Wm(t,i,o),value:e};if(r!==void 0)a.message=r;return Fn("Rename",a)}function AS(e,t){let o=t.references,r=t.tag?`; tag → <${t.tag.to}> (${t.tag.refsUpdated})`:"";if(o&&o.refsUpdated>0)return`Renamed to ${e}; updated ${o.refsUpdated} reference(s) in ${o.filesChanged} file(s)${r}`;if(r)return`Renamed to ${e}${r}`;return`Renamed to ${e}`}function Mw(e,t,o){let r=t.errors??[];if(r.length===0){w.success(e);return}let a=r.length===1?"1 file":`${r.length} files`;w.warn(`${e} — references in ${a} could not be updated`,{detail:r.map((i)=>`${i.path}: ${i.error}`).join(`
3
+ `),path:o,source:"Files"})}function vt(e,t){for(let o of e.references?.files??[])if(o.path!==t&&m.tabs.has(o.path))Lm(o.path)}function Tm(e){let t=e.replaceAll("\\","/");return t.includes("/")?t.slice(0,t.lastIndexOf("/")):"."}async function YP(e,t,o){us();let r=Tm(e),a=Tm(t);if(await rl(r),a!==r)await rl(a);let i=_n();if(i.selectedPath===e)i.selectedPath=t;else if(i.selectedPath?.startsWith(`${e}/`))i.selectedPath=t+i.selectedPath.slice(e.length);vt(o,t)}async function Pw(e,t){Ls(e,t);let o=await p().renameFile(e,t),r=[...m.tabs.keys()];for(let a of r)if(a===e||a.startsWith(`${e}/`)){let i=t+a.slice(e.length);CI(a,i,i)}return await YP(e,t,o),o}async function OS(e,t){try{let o=await p().listDirectory(Tm(e));return new Set(o.map((r)=>r.name))}catch(o){return w.error(`Could not rename ${e.split("/").pop()??e}.`,{detail:`The folder could not be read to check the new name: ${X(o)}`,path:e,source:t}),null}}async function yt(e,t){let o=Tm(e.path),r=await OS(e.path,"Files");if(r===null)return;let a=await wt(e.name,e.path,r);if(!a||a===e.name)return;let i=o==="."?a:`${o}/${a}`;try{let s=await Pw(e.path,i);t(),Mw(AS(a,s),s,i)}catch(s){w.error(`Could not rename ${e.name}.`,{detail:X(s),path:e.path,source:"Files"})}}async function bt(e,t){if(!await Ab(e))return;try{let r=p();Ls(e.path),await r.deleteFile(e.path),us();let a=e.path.replaceAll("\\","/"),i=a.includes("/")?a.slice(0,a.lastIndexOf("/")):".";if(await rl(i),_n().selectedPath===e.path)_n().selectedPath=null;t(),w.success(`Deleted ${e.name}`)}catch(r){w.error(`Could not delete ${e.name}.`,{detail:X(r),path:e.path,source:"Files"})}}function xt(e,t){let o=t.paneId,r=Da(e);if(o!==void 0&&r){if(r.activeTabId===e&&t.focus===!1)return;kv(e,o)}Ft(e,{focus:t.focus!==!1})}async function _i(e,t={}){let o=t.focus!==!1;for(let[a,i]of m.tabs.entries())if(i.documentPath===e){if(t.canvasMode!==void 0)i.session.ui.canvasMode=t.canvasMode;if(xt(a,t),o)_n().selectedPath=e;return}if(jb(e)){if(Zu(e,t),o)_n().selectedPath=e;$b({name:e.split("/").pop()||e,path:e,root:_n().projectRoot});return}if(e.toLowerCase().endsWith(".csv")){try{if(await HT(e,t),o)_n().selectedPath=e;$b({name:e.split("/").pop()||e,path:e,root:_n().projectRoot})}catch(a){w.error(`Could not open ${e}.`,{detail:X(a),path:e,source:"Open File"})}return}let r=p();try{let a=await r.readFile(e);if(!a){if(await jt(),!fn(e)&&!e.toLowerCase().endsWith(".json"))throw lf(e);return}await jt();let i,s,l=null,c=fn(e);if(c){let u=await Fr(e,a);({document:i}=u),{frontmatter:s}=u}else if(e.endsWith(".json"))({document:i,layout:l}=Es(a));else throw lf(e);if(Si({id:e,documentPath:e,document:i,...s!=null&&{frontmatter:s},layout:l,source:c?a:null,sourceFormat:c?.name??null,...t.paneId!==void 0&&{paneId:t.paneId},...t.preview===!0&&{preview:!0},...t.focus===!1&&{focus:!1},...t.canvasMode!==void 0&&{canvasMode:t.canvasMode}}),o)_n().selectedPath=e;$b({name:e.split("/").pop()||e,path:e,root:_n().projectRoot})}catch(a){w.error(`Could not open ${e}.`,{detail:X(a),path:e,source:"Open File"})}}async function MS(e,t){await _i(t,{focus:!1,paneId:e,preview:!0})}function AT(e){if(wv(e))return;Qw(e);for(let[,t]of m.tabs.entries())if(t.documentPath===e&&!t.doc.dirty){Lm(e);return}}function OT(e){for(let t of e)Lm(t,{onlyIfChanged:!0})}async function Lm(e,t={}){for(let[,o]of m.tabs.entries())if(o.documentPath===e){let r=p(),a=o.doc.dirty,i=()=>!a&&o.doc.dirty||wv(e);try{let s=await r.readFile(e);if(!s)return;if(await jt(),i())return;if(fn(e)){let{document:l,frontmatter:c}=await Fr(e,s);if(i())return;if(t.onlyIfChanged&&Vs(l,o.doc.document)&&Vs(c,o.doc.content.frontmatter))return;o.doc.document=l,o.doc.content.frontmatter=c,o.doc.source=s}else if(e.endsWith(".json")){let l=Es(s);o.doc.layout=l.layout;let c=l.document;if(o.doc.bareRepeaters=Gm(c),t.onlyIfChanged&&Vs(c,o.doc.document))return;o.doc.document=c}o.doc.dirty=!1}catch(s){w.error(`Could not reload ${e} after it changed on disk.`,{detail:X(s),key:`reload:${e}`,path:e,source:"Files"})}return}}function MT(){ei({id:"files",title:"Files",level:"project",dock:"navigator",icon:"folder",rail:"developer",render:()=>ft,afterRender:(e,t)=>{ZP(t,e.rerender)}})}var Pt={activate:et,contextMenu:ut,expand:tt,move:ot,newFile:()=>{Te(".",h)},openProject:()=>{nt("project.open",void 0,"Files")},refresh:()=>{Ze()},rowHost:it,search:(e)=>{_n().searchQuery=e,h()},select:Pe,toggleIgnored:()=>{VP(!LT()),h()},treeHost:st,typeahead:at},v=null,b=null;function ZP(e,t){let o=e.querySelector(".panel-content")??e;if(we=t,v&&(v.host!==o||!v.handle.connected()))XP();let r=Xe();if(v)v.handle.update(r);else{let a=me(o,r,Pt);v={handle:a,host:o},a.ready.then(ee)}queueMicrotask(ee)}function XP(){Ee(),v?.handle.dispose(),v=null,b=null,ke(),j.clear(),f=[]}
4
+ export{Lb,$S,IS,RN,DN,Nw,Aw,RS,NN,AN,$b,rl,Em,TT,LT,VP,$T,IT,RT,DS,UP,Ib,DT,qP,GP,NT,ON,KP,JP,Ow,NS,AS,Mw,Tm,YP,Pw,OS,_i,MS,AT,OT,Lm,MT,ZP,XP};
5
+
6
+ //# debugId=4B109BA3243CC5AB64756E2164756E21
7
+ //# sourceMappingURL=studio-wse1rs8t.js.map
@@ -0,0 +1,16 @@
1
+ import{X}from"./studio-9c6cbq2c.js";import{p}from"./studio-4fnb5648.js";import{BM,w}from"./studio-sce30r7b.js";import{jn,Fx,ln,go,JC,Up,Hx,aI,an,yv,Km,Hi,qn,Se,pi,To,Z,fi,Xm,m,Sr,rc,Ft}from"./studio-yrcrncev.js";import{af}from"./studio-aam8zt8z.js";import{rt,Eo,xr}from"./studio-g9brbewz.js";import{C,id,_n}from"./studio-4f7thq0p.js";import{me,te,Gr,Kr,g,le}from"./studio-3qr08sxq.js";import{n,Y,Ze,Gv,Q,_,v}from"./studio-k3we3kqb.js";import{ce}from"./studio-0939t1q1.js";function F(e){return e.replaceAll("~","~0").replaceAll("/","~1")}var Ve=100;function H(e){let t={blankAfter:new Set,escaped:new Map,inline:new Map},o=0,r=()=>{let l=0;while(o<e.length&&(e[o]===" "||e[o]==="\t"||e[o]==="\r"||e[o]===`
2
+ `)){if(e[o]===`
3
+ `)l+=1;o+=1}return l},s=()=>{let l=o,f=new Set;o+=1;while(o<e.length&&e[o]!=='"')if(e[o]==="\\")if(e[o+1]==="u"){let b=Number.parseInt(e.slice(o+2,o+6),16);if(b>=128)f.add(b);o+=6}else o+=2;else o+=1;return o+=1,{escaped:f,raw:e.slice(l,o)}},i=(l,f)=>{let b=r();if(e[o]===f)return o+=1,!0;if(o+=1,b+=r(),b>=2)t.blankAfter.add(l);return!1},a=(l)=>{r();let f=e[o];if(f==="{"){o+=1;let b=r()>0;if(e[o]==="}"){o+=1;return}t.inline.set(l,!b);while(o<e.length){let c=JSON.parse(s().raw);r(),o+=1;let d=`${l}/${F(c)}`;if(a(d),i(d,"}"))return}}else if(f==="["){if(o+=1,r(),e[o]==="]"){o+=1;return}for(let b=0;o<e.length;b+=1){let c=`${l}/${b}`;if(a(c),i(c,"]"))return}}else if(f==='"'){let{escaped:b}=s();if(b.size>0)t.escaped.set(l,b)}else while(o<e.length&&!`,]} \r
4
+ `.includes(e[o]))o+=1};return a(""),t}function Es(e){return{document:JSON.parse(e),layout:H(e)}}var He=/[^\u0020-\u007E]/,Ge=/^[\p{Mn}\p{Me}\p{Cf}]$/u,Ke=/^\p{Emoji_Presentation}$/u;function qe(e){return e>=4352&&(e<=4447||e===9001||e===9002||e>=11904&&e<=12871&&e!==12351||e>=12880&&e<=19903||e>=19968&&e<=42182||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65131||e>=65281&&e<=65376||e>=65504&&e<=65510||e>=110592&&e<=110593||e>=127488&&e<=127569||e>=131072&&e<=262141)}function be(e){if(!He.test(e))return e.length;let t=0;for(let o of e){if(Ge.test(o))continue;t+=qe(o.codePointAt(0))||Ke.test(o)?2:1}return t}function he(e){return e===void 0||Q(e)||Gv(e)}function U(e){return Object.entries(e).filter(([,t])=>!he(t))}function M(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Ye(e){if(e.length<2)return!1;let t=Array.isArray(e[0])?"array":M(e[0])?"object":null;if(t===null)return!1;return e.every((o)=>t==="array"?Array.isArray(o)&&o.length>1:M(o)&&U(o).length>1)}function Xe(e){return e.length>1&&e.every((t)=>Y(t))}function V(e,t){let o=he(e)?"null":JSON.stringify(e);return t===void 0?o:o.replaceAll(/[\u0080-\uFFFF]/g,(r)=>{let s=r.codePointAt(0);return t.has(s)?`\\u${s.toString(16).padStart(4,"0")}`:r})}function Co(e,t,o=Ve){let r=t?.inline??new Map,s=t?.blankAfter??new Set,i=t?.escaped??new Map,a=(c,d)=>r.get(c)??d,l=(c,d,h)=>{if(Array.isArray(c)){if(c.length===0)return"[]";if(Ye(c))return null;let S=[];for(let[x,P]of c.entries()){let T=`${d}/${x}`,y=s.has(T)?null:l(P,T,h);if(y===null)return null;S.push(y)}return`[${S.join(", ")}]`}if(M(c)){let S=U(c);if(S.length===0)return"{}";if(!a(d,h))return null;let x=[];for(let[P,T]of S){let y=`${d}/${F(P)}`,E=s.has(y)?null:l(T,y,!0);if(E===null)return null;x.push(`${JSON.stringify(P)}: ${E}`)}return`{ ${x.join(", ")} }`}return V(c,i.get(d))},f=(c)=>c.map(({path:d,text:h},S)=>S===c.length-1?h:`${h},
5
+ ${s.has(d)?`
6
+ `:""}`).join(""),b=(c,d,h,S,x,P)=>{if(!Array.isArray(c)&&!M(c))return V(c,i.get(d));let T=l(c,d,x);if(T!==null&&S+be(T)+P<=o)return T;let y=" ".repeat(h+2),E=`
7
+ ${" ".repeat(h)}`;if(Array.isArray(c)){if(Xe(c))return`[
8
+ ${Qe(c,y,o,(A)=>s.has(`${d}/${A}`))}${E}]`;let L=c.map((R,A)=>{let O=`${d}/${A}`,J=A===c.length-1,z=b(R,O,h+2,y.length,x,J?0:1);return{path:O,text:`${y}${z}`}});return`[
9
+ ${f(L)}${E}]`}let ge=U(c),Be=a(d,x),ze=ge.map(([L,R],A)=>{let O=`${d}/${F(L)}`,J=`${JSON.stringify(L)}: `,z=A===ge.length-1,Fe=y.length+be(J),Ue=b(R,O,h+2,Fe,Be,z?0:1);return{path:O,text:`${y}${J}${Ue}`}});return`{
10
+ ${f(ze)}${E}}`};return`${b(e,"",0,0,!1,0)}
11
+ `}function Qe(e,t,o,r){let s=[],i="";for(let[a,l]of e.entries()){let f=`${V(l)}${a===e.length-1?"":","}`;if(i==="")i=`${t}${f}`;else if(i.length+1+f.length<=o)i=`${i} ${f}`;else s.push(i),i=`${t}${f}`;if(r(a)&&a<e.length-1)s.push(i,""),i=""}return s.push(i),s.join(`
12
+ `)}function Hm(e){return Co(e,ve())}var k=null,j=null,N=null,I=null;function ve(){return xe()?.doc.layout??I}var G=null;function xe(){let e=m.tabs.get(an);return e?le(e):null}function et(){if(j)Km(j),j=null;k=null,N=null,I=null,G=null}function Pe(){return G??=(async()=>{try{let e=await p().readFile(an),{document:t,layout:o}=Es(e);I=o,N=Co(t,ve())}catch{N=null}})(),G}async function A$(e){if(await Pe(),e.doc.layout===null&&I!==null)e.doc.layout=I}function tt(e){let t=_n();if(t.projectConfig===e)return;id({...t,projectConfig:e}),rc(m.projectRoot,e)}function ot(){let e=C?.projectConfig;return e?le(e):null}function K(e){return le(e)}function Te(e,t){for(let o of Object.keys(e))delete e[o];Object.assign(e,t)}function ye(e){return k=e,e.scope.run(()=>{te(()=>{let t=e.doc.document;if(k!==e||!C)return;tt(K(t))})}),e}function FC(){let e=_n(),t=xe();if(k&&(k!==(t??j)||le(k.doc.document)!==e.projectConfig))et();if(k)return k;if(t)return ye(t);return j=yv({document:e.projectConfig??{},documentPath:an,id:an}),ye(j)}function we(e){return JSON.stringify(e.extensions??null)}async function nt(){let{loadFormats:e,refreshExtensionUi:t,refreshFormats:o}=await (ce("5ja5gxyk"),import("./format-host-5ja5gxyk.js"));o(),e(),t(p())}async function ic(e){let t=ot(),o=FC();await A$(o);let r=K(o.doc.document),s=Hm(r),i=t&&t!==r&&Hm(t)!==s?t:null;if(i&&o.doc.dirty){let h=Error(`${an} has unsaved changes in its editor tab`);return w.error(`Could not save ${an} — the file is open with unsaved changes. Save or `+"revert that tab, then make the settings change again.",{key:`save:${an}`,path:an,source:"Settings"}),{error:h,ok:!1}}let a=i??r,l=e?{...a,...e}:a,f=Hm(l);if(!i&&!o.doc.dirty&&f===N)return{ok:!0};let b=we(r);Z(o,(h)=>{let S=h.doc.document;if(i)Te(S,i);for(let[x,P]of Object.entries(e??{}))S[x]=P});let c=K(o.doc.document),d=Hm(c);try{await p().writeFile(an,d)}catch(h){return w.error(`Could not save ${an} — ${X(h)}`,{key:`save:${an}`,path:an,source:"Settings"}),{error:h,ok:!1}}if(N=d,o.doc.dirty=!1,we(c)!==b)await nt();return{ok:!0}}async function uO(e,t){if(!C){rc(m.projectRoot,e);return}let o=FC();Z(o,(r)=>Te(r.doc.document,e),{skipHistory:!0}),o.doc.dirty=!1,await Pe(),I=H(t),o.doc.layout=I,N=Hm(e)}function to(e){let t=C?.projectConfig?.$media;if(!t)return e||{};if(!e)return{...t};return{...t,...e}}function wr(e){let t=C?.projectConfig?.style;if(!t)return e||{};if(!e)return{...t};let o={...t};for(let[r,s]of Object.entries(e)){let i=o[r];o[r]=_(s)&&_(i)?{...i,...s}:s}return o}function hO(e,t=[]){return{...O$(t),...C?.projectConfig?.imports,...e}}function O$(e){let t=e.flatMap((o)=>(o.classes??[]).filter((r)=>r.path.endsWith(".class.json")).map((r)=>[r.name,r.path]));return Object.fromEntries(t.toReversed())}function xx(e){let t=C?.projectConfig?.$elements;if(!t?.length)return e||[];if(!e?.length)return[...t];let o=new Set,r=[];for(let s of[...t,...e]){let i=n(s)?s:_(s)?s.$ref:void 0;if(i&&!o.has(i))o.add(i),r.push(s)}return r}function _x(e){let t=C?.projectConfig?.$head;if(!t?.length)return e||[];if(!e?.length)return[...t];let o=new Set,r=[];for(let s of[...t,...e]){let i=_(s)?s.attributes:void 0,a=String(i?.href||i?.src||"")||JSON.stringify(s);if(!o.has(a))o.add(a),r.push(s)}return r}function Ts(){let e=C?.projectConfig;return e?ln(e).i18n:null}function Hp(e,t){let o=Ts();if(o===null)return null;let r=jn(e);if(r!==null&&o.locales.includes(r))return r;return go(t??"",o)??o.defaultLocale}var q=new Map;function pO(){q.clear()}function hl(e){if(e===!1)return null;let t=C?.projectConfig?.defaults?.layout;return e||t||null}async function Sx(e){let t=e.replace(/^\.\//,""),o=q.get(t);if(o!==void 0)return structuredClone(o);try{let s=await p().readFile(t),i=JSON.parse(s);return q.set(t,i),structuredClone(i)}catch{return null}}function M$(e,t){let o=t.children??[],r=Array.isArray(o)?o:[],s=new Map,i=[];for(let a of r){let l=n(a)?void 0:a.attributes?.slot;if(!n(a)&&n(l)&&l){if(!s.has(l))s.set(l,[]);s.get(l).push(a)}else i.push(a)}if(ke(e,s,i),t.state)e.state={...e.state,...t.state};if(t.$media)e.$media={...e.$media,...t.$media};if(t.style)e.style={...e.style,...t.style};if(t.attributes)e.attributes={...e.attributes,...t.attributes};return e}function ke(e,t,o){if(!Array.isArray(e.children))return;let r=[];for(let s of e.children)if(_(s)&&s.tagName==="slot"){let i=s.attributes?.name;if(n(i)&&i&&t.has(i))r.push(...t.get(i)),t.delete(i);else if(!i&&o.length>0)r.push(...o);else if(Array.isArray(s.children))r.push(...s.children)}else{if(_(s))ke(s,t,o);r.push(s)}e.children=r}async function no(e){let t=await ic(e);if(!t.ok)throw t.error}var Ie=new Set([fi,Xm]),it=new Set(["auto","light","dark"]);function st(e){return n(e)&&it.has(e)}function at(e){let{ui:t}=e.session;return{activeMedia:t.activeMedia,canvasMode:t.canvasMode,editZoom:t.editZoom,preview:t.preview,previewColorScheme:t.previewColorScheme,previewLocale:t.previewLocale,showLayout:t.showLayout,zoom:t.zoom}}function _e(){let e={},t=[];for(let o of m.panes){if(o.derived)continue;let r=[];for(let i of o.tabOrder){let a=m.tabs.get(i);if(!a?.documentPath)continue;r.push(a.documentPath),e[a.documentPath]=at(a)}if(r.length===0)continue;let s=o.activeTabId?m.tabs.get(o.activeTabId):null;t.push({activeFile:s?.documentPath??null,files:r,id:o.id})}return{focusedPane:m.activePaneId,panes:t,ui:e}}function lt(e){if(!v(e))return{};let t={};if(n(e.canvasMode))t.canvasMode=e.canvasMode;if(Ze(e.preview))t.preview=e.preview;if(Y(e.zoom)&&Number.isFinite(e.zoom))t.zoom=e.zoom;if(Y(e.editZoom)&&Number.isFinite(e.editZoom))t.editZoom=e.editZoom;if(e.activeMedia===null||n(e.activeMedia))t.activeMedia=e.activeMedia;if(st(e.previewColorScheme))t.previewColorScheme=e.previewColorScheme;if(e.previewLocale===null||n(e.previewLocale)&&Fx(e.previewLocale))t.previewLocale=e.previewLocale;if(Ze(e.showLayout))t.showLayout=e.showLayout;return t}function Ee(e){if(!v(e)||!Array.isArray(e.panes))return null;let t=[];for(let r of e.panes){if(!v(r)||!n(r.id)||!Ie.has(r.id))continue;let s=Array.isArray(r.files)?r.files.filter((i)=>n(i)&&i!==""):[];if(s.length===0)continue;t.push({activeFile:n(r.activeFile)&&s.includes(r.activeFile)?r.activeFile:null,files:s,id:r.id})}if(t.length===0)return null;let o={};if(_(e.ui))for(let[r,s]of Object.entries(e.ui))o[r]=lt(s);return{focusedPane:n(e.focusedPane)&&Ie.has(e.focusedPane)?e.focusedPane:fi,panes:t,ui:o}}async function fO(e,t){let o=0;if(e.panes.some((i)=>i.id===Xm))t.ensureSecondPane();for(let i of e.panes)for(let a of i.files){try{await t.openFile(a,i.id)}catch{}if([...m.tabs.values()].some((l)=>l.documentPath===a))o+=1}if(o===0)return 0;for(let i of m.tabs.values()){let a=i.documentPath?e.ui[i.documentPath]:void 0;if(!a)continue;let{ui:l}=i.session;if(a.canvasMode&&i.capabilities.modes.includes(a.canvasMode))l.canvasMode=a.canvasMode;if(a.preview!==void 0)l.preview=a.preview;if(a.zoom!==void 0)l.zoom=a.zoom;if(a.editZoom!==void 0)l.editZoom=a.editZoom;if(a.activeMedia!==void 0)l.activeMedia=a.activeMedia;if(a.previewColorScheme!==void 0)l.previewColorScheme=a.previewColorScheme;if(a.previewLocale!==void 0)l.previewLocale=a.previewLocale;if(a.showLayout!==void 0)l.showLayout=a.showLayout}let r=m.panes.some((i)=>i.id===e.focusedPane)?e.focusedPane:null,s=null;for(let i of e.panes){let a=m.panes.find((f)=>f.id===i.id);if(!a||!i.activeFile)continue;let l=a.tabOrder.find((f)=>m.tabs.get(f)?.documentPath===i.activeFile);if(!l)continue;if(a.id===r)s=l;else Ft(l,{focus:!1})}if(s)Ft(s);else if(r)Sr(r);return o}var Bm=["review","deploys","branches","hosting"],jC={branches:"Branches",deploys:"Deploys",hosting:"Hosting",review:"Review changes"},ct=["live","review"],Ce="review",Ae="live",ut=new Set(Bm),pt=new Set(ct);function mO(e){return typeof e==="string"&&ut.has(e)}function Cx(e){return typeof e==="string"&&pt.has(e)}var ft={default:{description:"Resume whatever was persisted — layout, recents, settings, chat history.",id:"default",reset:"none"},fresh:{description:"A first-run app: no layout, no recents, no settings, no history.",id:"fresh",reset:"app-state"}},je=new Map(Object.entries(ft)),dt="default",mt=/^jx[-._:]/;function gt(e){return mt.test(e)}function bt(){let e=typeof localStorage>"u"?void 0:localStorage;if(!e)return[];let t=[];try{for(let o=0;o<e.length;o++){let r=e.key(o);if(r&&gt(r))t.push(r)}for(let o of t)e.removeItem(o)}catch{}return t}function ht(e){let t=je.get(e);if(!t)throw RangeError(`unknown startup profile "${e}"; declared: ${[...je.keys()].join(", ")}`);if(t.reset==="app-state")bt();return t}var W=null;function Ne(e){if(W)return W;let t=new URLSearchParams(e??(typeof location>"u"?"":location.search)),o=ht(t.get("profile")??dt),r=t.get("clock");return W={clock:r===null?null:BM(r),profile:o},W}var B=["site","collections","styles","files","search","i18n","layers","data","packages","insert"],St=new Set(["collections","styles"]);function De(e){return e&&!St.has(e)?e:wt}var yt=new Map([["blocks","insert"],["head","site"],["page","site"],["imports","packages"],["git","site"],["state","data"]]),wt="site";function HC(e,t){let o=B.find((r)=>r===e);if(o===void 0)throw Error(`${t}: "${e}" is not a declared Navigator panel id.`);return o}function se(e){if(!n(e))return null;let t=yt.get(e);if(t)return t;return B.find((o)=>o===e)??null}var ne=["page","properties","style","events","assistant"],kx="page",vt=["properties","style","events"],BC="properties";function Ex(e){return typeof e==="string"&&vt.some((t)=>t===e)}function P$(e){return typeof e==="string"&&ne.some((t)=>t===e)}var Tx=["problems","logic","activity"],F$="problems";function j$(e){return typeof e==="string"&&Tx.some((t)=>t===e)}var Lx=["light","dark"],Gc={content:{id:"content",inspector:{open:!1,whileWriting:!0},navigator:{open:!0,panel:"collections"},rail:!1,tabStrip:!0},design:{id:"design",inspector:{open:!0},navigator:{initial:"site",open:!0},rail:!0,tabStrip:!0},media:{id:"media",inspector:{open:!1},navigator:{open:!1},rail:!1,tabStrip:!1},publish:{id:"publish",inspector:{open:!1},navigator:{open:!1},rail:!1,tabStrip:!1},settings:{id:"settings",inspector:{open:!1},navigator:{open:!1},rail:!1,tabStrip:!1},styles:{id:"styles",inspector:{open:!1,tab:"style",whileWriting:!0},navigator:{open:!0,panel:"styles"},rail:!1,tabStrip:!1}},Le="jx-studio-panel-widths",Re="jx-studio-project::",xt="dark";function H$(e){return typeof e==="string"&&Lx.some((t)=>t===e)}function Pt(){let e=Eo(rt.theme);return H$(e)?e:xt}var $x=["left","right","bottom"],D={bottom:{collapsed:!0,size:220},left:{collapsed:!1,size:240},right:{collapsed:!1,size:280}},gO={bottom:D.bottom.size,left:D.left.size,right:D.right.size},Tt={bottom:"--dock-h-bottom",left:"--panel-w-left",right:"--panel-w-right"},kt={bottom:"bottom-collapsed",left:"left-collapsed",right:"right-collapsed"},B$=0.5,zC=0.2,WC=0.8;function It(e){return Y(e)&&e>=zC&&e<=WC?e:B$}function bO(e){u.paneSplit=Math.min(WC,Math.max(zC,e))}function _t(){try{let e=JSON.parse(localStorage.getItem(Le)||"{}");return v(e)?e:{}}catch{return{}}}function Et(e){return{left:e("left"),right:e("right"),bottom:e("bottom")}}function $e(){return{branches:null,commitMessage:"",diffState:null,error:null,lastUpdated:null,loading:!1,logEntries:null,rev:0,status:null}}function Je(){return{build:{for:"",state:"idle",text:""},deploys:{error:"",project:"",rows:[],state:"idle"},destination:Ae,review:{number:0,url:""},tab:Ce}}var Ct="tokens";function Me(){return{customizedOnly:!1,filter:"",selection:null,variable:null,view:Ct}}function At(){let e=_t(),t=Et((o)=>{let r=e[o],s=e[`${o}Collapsed`];return{collapsed:Ze(s)?s:D[o].collapsed,size:Y(r)&&r>0?r:D[o].size}});return{bottomTab:j$(e.bottomTab)?e.bottomTab:F$,docks:t,focusRegion:"pane",paneSplit:It(e.paneSplit),git:$e(),publish:Je(),layoutSelection:null,leftTab:De(se(e.leftTab)),stylebook:Me(),theme:Pt(),workspace:Up}}Ne();var jt=["jx-studio-doc-header-expanded"];function Nt(){try{for(let e of jt)localStorage.removeItem(e)}catch{}}Nt();var u=g(At());function Bd(){try{localStorage.setItem(Le,JSON.stringify({bottom:u.docks.bottom.size,bottomCollapsed:u.docks.bottom.collapsed,bottomTab:u.bottomTab,left:u.docks.left.size,leftCollapsed:u.docks.left.collapsed,leftTab:u.leftTab,paneSplit:u.paneSplit,right:u.docks.right.size,rightCollapsed:u.docks.right.collapsed}))}catch{}}var re,ae={},ue=null;function vO(){return ue}function pe(e){if(!e)return{};try{let t=JSON.parse(localStorage.getItem(`${Re}${e}`)||"{}");return v(t)?t:{}}catch{return{}}}function z$(e){let t=pe(e).workspace;return aI(t)?t:Up}function yO(e){return Ee(pe(e).session)}var fe=null;function Ix(e){fe=e}function wO(){de()}function de(){let e=m.projectRoot;if(!e)return;try{localStorage.setItem(`${Re}${e}`,JSON.stringify({session:e===fe?_e():pe(e).session,workspace:u.workspace}))}catch{}}function Ot(e){if(e===re)return;if(re=e,ae={},ue=null,u.workspace=z$(e),e===null){u.leftTab=De(se(u.leftTab));return}Gr();try{We(u.workspace),Bd()}finally{Kr()}}function W$(e,t){let{inspector:o}=Gc[e];return o.open||o.whileWriting===!0&&t}function We(e,t){let o=Gc[e],r=se(o.navigator.panel??ae[e]??o.navigator.initial??u.leftTab);if(r)u.leftTab=r;if(u.docks.left.collapsed=!o.navigator.open,u.docks.right.collapsed=!W$(e,t?.writingOnCanvas?.()===!0),o.inspector.tab&&t)t.setInspectorTab(o.inspector.tab)}function VC(e,t){if(u.workspace===e)return!1;if(!Gc[u.workspace].navigator.panel)ae[u.workspace]=u.leftTab;return ue=u.workspace,u.workspace=e,We(e,t),Bd(),de(),!0}function zm(e=u.theme){return e==="light"?"vs":"vs-dark"}function Dt(){document.documentElement.dataset.theme=u.theme,af()?.editor.setTheme(zm())}var Lt="rail-hidden",Rt="tabs-hidden";function tv(e=u.workspace){return Gc[e].tabStrip}function $t(){let e=document.documentElement;for(let o of $x)e.style.setProperty(Tt[o],`${u.docks[o].size}px`);let t=document.querySelector("#app");if(!t)return;for(let o of $x)t.classList.toggle(kt[o],u.docks[o].collapsed);t.classList.toggle(Lt,!Gc[u.workspace].rail),t.classList.toggle(Rt,!Gc[u.workspace].tabStrip)}var ee=null,ie=[];function nv(e){if(!ie.includes(e))ie.push(e)}function xO(){if(ee)return;for(let e of ie)e.mount();ee=me(),ee.run(()=>{te(()=>{$t()}),te(()=>{Dt()}),te(()=>{Ot(m.projectRoot)}),te(()=>{let e=m.projectRoot;m.activePaneId;for(let t of m.panes)t.id,t.activeTabId,t.tabOrder.join("\x00");if(e)de()})})}function ko(e,t){if(u.docks[e].collapsed===t){Bd();return}u.docks[e].collapsed=t,Bd()}function Jt(e){ko(e,!u.docks[e].collapsed)}function _O(e,t){u.docks[e].size=t}function Kc(e){u.leftTab=e,ko("left",!1),Bd()}function uh(e){u.bottomTab=e,ko("bottom",!1),Bd()}function V$(e){if(u.theme===e)return;u.theme=e,xr(rt.theme,e)}function SO(e){if(e===u.leftTab&&!u.docks.left.collapsed){ko("left",!0);return}Kc(e)}function U$(e){u.layoutSelection=e}function Rx(){Object.assign(u.git,$e()),Object.assign(u.publish,Je()),Object.assign(u.stylebook,Me()),u.layoutSelection=null,fe=null,re=void 0}function Oe(e,t){if(t.showWorkspace){t.showWorkspace(e);return}VC(e,t)}var oe=(e)=>e.project.open;function Mt(e){return[{args:Se({tab:pi(B,"Which Navigator panel to show.")}),category:"View",id:"view.setActivity",level:"application",menus:["commandbar/overflow","palette"],group:"4_docks",requires:"an open project",when:oe,run:(t,o)=>{let r=qn("view.setActivity",o,"tab",B);if(e.panelAvailable&&!e.panelAvailable(r))throw RangeError(`command "view.setActivity" argument "tab": "${r}" names a panel that is registered but not available right now, so showing it would persist a Navigator tab nothing can draw`);Kc(r)},title:"Show Navigator Panel"},{args:Se({tab:pi(ne,"Which Inspector tab to show.")}),category:"View",id:"view.setRightTab",level:"document",menus:["palette"],group:"4_docks",requires:"an open document",when:(t)=>t.document.open,run:(t,o)=>{e.setInspectorTab(qn("view.setRightTab",o,"tab",ne))},title:"Show Inspector Tab"},{args:Se({open:To("True to show the Navigator dock, false to collapse it.")}),category:"View",id:"view.setNavigator",level:"application",menus:["palette"],group:"4_docks",run:(t,o)=>{ko("left",!Hi("view.setNavigator",o,"open"))},title:"Show Navigator Dock"},{args:Se({open:To("True to show the Inspector dock, false to collapse it.")}),category:"View",id:"view.setRightPanel",level:"application",menus:["palette"],group:"4_docks",run:(t,o)=>{ko("right",!Hi("view.setRightPanel",o,"open"))},title:"Show Inspector Dock"},{args:Se({open:To("True to show the Bottom dock, false to collapse it.")}),category:"View",id:"view.setBottomDock",level:"application",menus:["palette"],group:"4_docks",run:(t,o)=>{ko("bottom",!Hi("view.setBottomDock",o,"open"))},title:"Show Bottom Dock"},{category:"View",id:"view.toggleBottomDock",keybinding:"mod+j",level:"application",menus:["commandbar/overflow","palette"],group:"4_docks",run:()=>{Jt("bottom")},title:"Toggle Bottom Dock"},{args:Se({tab:pi(Tx,"Which Bottom dock tab to show.")}),category:"View",id:"view.setBottomTab",level:"application",menus:["palette"],group:"4_docks",run:(t,o)=>{let r=qn("view.setBottomTab",o,"tab",Tx);if(e.panelAvailable&&!e.panelAvailable(r))throw RangeError(`command "view.setBottomTab" argument "tab": "${r}" names a panel that is registered but not available right now, so showing it would persist a Bottom dock tab nothing can draw`);uh(r)},title:"Show Bottom Dock Tab"},{args:Se({open:To("True to show the Assistant tab, false to step off it.")}),category:"View",id:"view.setAssistant",level:"application",menus:["never"],group:"4_docks",run:(t,o)=>{if(Hi("view.setAssistant",o,"open")){ko("right",!1),e.setInspectorTab("assistant");return}if(e.inspectorTab()==="assistant")e.setInspectorTab(e.restingInspectorTab?.()??kx)},title:"Show Assistant"},{args:Se({workspace:pi(JC,"Which workspace to show.")}),category:"View",id:"view.setWorkspace",level:"application",menus:["never"],group:"4_workspaces",requires:"an open project",when:oe,run:(t,o)=>{Oe(qn("view.setWorkspace",o,"workspace",JC),e)},title:"Switch Workspace"},...Hx.map((t,o)=>({category:"View",id:`workspace.focus.${t.id}`,keybinding:`mod+${o+1}`,level:"application",menus:["palette"],group:"4_workspaces",requires:"an open project",when:oe,run:()=>{Oe(t.id,e)},title:`Go to ${t.title}`})),{args:Se({color:pi(Lx,"The Studio chrome's theme.")}),category:"View",id:"view.setTheme",level:"application",menus:["palette"],group:"6_appearance",run:(t,o)=>{V$(qn("view.setTheme",o,"color",Lx))},title:"Set Theme"}]}function CO(e,t){e.registerAll(Mt(t))}
13
+ export{Es,Co,Hm,A$,FC,ic,uO,to,wr,hO,O$,xx,_x,Ts,Hp,pO,hl,Sx,M$,no,fO,Bm,jC,mO,Cx,HC,kx,BC,Ex,P$,Tx,F$,j$,Lx,Gc,H$,$x,gO,B$,zC,WC,bO,u,Bd,vO,z$,yO,Ix,wO,W$,VC,zm,tv,nv,xO,ko,_O,Kc,uh,V$,SO,U$,Rx,CO};
14
+
15
+ //# debugId=7D77C33BB58CCAD564756E2164756E21
16
+ //# sourceMappingURL=studio-x0gsfr1d.js.map
@@ -1,6 +1,6 @@
1
- import{p,_e}from"./studio-jws1a87n.js";import{rt,Eo,jA,Ap,fx,xr,BA,Op}from"./studio-th7z3fg7.js";import{C}from"./studio-y60sts62.js";import{Zs,dt}from"./studio-0w2dr0q8.js";import{n,Z,Ze,ee,v}from"./studio-8z66jk4z.js";var u=null;async function jd(){if(!_e()||!ee(p().getAccountStatus)){u=null;return}try{u=await p().getAccountStatus?.()??null}catch{u=null}}function sC(){return u}function aC(){return u!==null&&u.installations.length===0&&Boolean(u.appInstallUrl)}function _A(){if(u===null)return null;let e=u.installations.flatMap((r)=>r.manageUrl?[{account:r.account??`Installation ${r.id}`,url:r.manageUrl}]:[]);if(e.length===0&&!u.appInstallUrl)return null;let t={manage:e};if(u.appInstallUrl)t.installUrl=u.appInstallUrl;return t}function SA(){return u?.entries??[]}function s$(){return(u?.notices??[]).filter((e)=>e.display!=="toast")}var X=new Set;function Y(){let e=(u?.notices??[]).filter((t)=>t.display==="toast"&&!X.has(t.id));for(let t of e)X.add(t.id);return e}var Q="https://jxsuite.com/problems/";function N(e){return typeof e==="string"}function fe(e){return typeof e==="object"&&e!==null}function qb(e){if(!N(e)||!e.startsWith("https://jxsuite.com/problems/"))return null;let t=e.slice(29);return t===""?null:t}function nr(e){if(N(e))return e.trim()===""?null:e;if(!fe(e))return null;for(let t of[e.detail,e.error,e.title])if(N(t)&&t.trim()!=="")return t;return null}function ll(e,t){return nr(e)??(t===void 0?"Request failed":`Request failed (${t})`)}var m=(e,t,r,i)=>{let s={status:t,title:r,type:`${Q}${e}`};if(i!==void 0)s.extensions=i;return s},Ne={invalidRequest:m("invalid-request",400,"The request was malformed or incomplete"),notFound:m("not-found",404,"The requested resource does not exist"),methodNotAllowed:m("method-not-allowed",405,"That method is not allowed on this route"),conflict:m("conflict",409,"The request conflicts with the current state",["conflicts"]),payloadTooLarge:m("payload-too-large",413,"The request body is too large"),unauthorized:m("unauthorized",401,"Credentials are missing or not accepted"),forbidden:m("forbidden",403,"The request was refused"),needsInstallationAccess:m("needs-installation-access",403,"The GitHub App is not installed for that account",["installUrl"]),pathOutsideProject:m("path-outside-project",403,"The path resolves outside the active project"),actionRequired:m("action-required",403,"An action is required first",["actions","heading","retry"]),noActiveProject:m("no-active-project",409,"No project is active on this backend"),capabilityUnavailable:m("capability-unavailable",501,"This backend does not provide that capability"),upstreamFailure:m("upstream-failure",502,"An upstream service failed",["upstream"]),internalError:m("internal-error",500,"The backend failed to complete the request")};var o=(e,t,r,i)=>{let s={method:e,path:t,optional:i!==void 0,summary:r};if(i!==void 0)s.degradation=i;return s},Fe={activate:o("POST","/__studio/activate","Bind the backend to a project root"),project:o("GET","/__studio/project","Root project metadata {name, root}"),projectInfo:o("GET","/__studio/project-info","Probe a directory: {isSiteProject, projectConfig?, directories?}"),resolveSite:o("GET","/__studio/resolve-site","Resolve the owning site of a file path {sitePath, projectConfig?, fileRelPath?}"),sites:o("GET","/__studio/sites","Enumerate site projects [{config, path}] (backs listProjects)","The welcome screen's Projects catalogue stays hidden."),createProject:o("POST","/__studio/create-project","Scaffold a project at a caller-chosen destination → {root, config}"),starters:o("GET","/__studio/starters","Starter templates (StarterInfo[])","The New Project picker offers only blank/templates."),importSite:o("POST","/__studio/import-site","Clone a live website into a project; streams NDJSON progress","The New Project Import tab is unavailable."),files:o("GET","/__studio/files","List a directory (DirEntry[]) in stable path order; an entry may carry an opaque content `version` the backend vouches for; with ?glob=<pattern>, search matching files project-wide"),fileRead:o("GET","/__studio/file","Read a file's text content"),filesRead:o("POST","/__studio/files/read","Read many files' text content {paths} → ReadFilesResult {files: [path, {content} | "+"{error: {status, code?, message}}][], omitted}. At most READ_FILES_MAX_PATHS (200) paths and a backend byte budget per call: the excess is listed in `omitted` (never a 400) and the first path is always answered. Per-path errors: 404 missing/deleted, 415 binary, 413 too large, 502 upstream. Allowed for read-only sessions; keeps fileRead's server-side effects","Adapters fall back to one fileRead per path."),fileWrite:o("PUT","/__studio/file","Write a file's text content"),fileDelete:o("DELETE","/__studio/file","Delete a file"),fileUpload:o("POST","/__studio/file/upload","Upload binary content to a path → UploadResult {path, size?}. `path` is the answer, not an "+"echo: a store that de-duplicates, suffixes, or normalizes names reports what it really wrote"),fileBytes:o("GET","/__studio/file/bytes","A project file's raw bytes, undecoded — the read side of `fileUpload`, for a caller that must "+"not go through UTF-8","Studio can only read a project file as text, so any surface that must decode one stays hidden."),documentRaw:o("GET","/__studio/raw/","A project file as its own bytes, at its own URL — the mount a canvas renders against when "+"the editor origin does not serve the site's URL space. The project-relative path is appended to this prefix","The canvas cannot address project files by URL, so a host whose origin does not serve the site URL space renders no component $refs and no images."),fileRename:o("POST","/__studio/file/rename","Rename/move (+ refactor report). `from`/`to` are server-root-relative; every path in the "+"report is relative to the active project (specs/server.md §4.1)"),references:o("GET","/__studio/references","Where a file or a component tag is used (?path=&tag=, at least one) → ReferencesResult "+"{files, filesReferencing, refsTotal} — the read side of the rename refactor's own walker, "+"cached until the backend's watcher sees the tree move (backs findReferences). `?path=` is server-root-relative and every path in the answer is relative to the active project; a "+"target outside that project is a 400, never a zero-result 200 (specs/server.md §4.1)",'Usage counts are hidden: no "Used on N pages" in the inspector, no Selection: Find Usages, and delete/rename confirmations state no reference count.'),locate:o("POST","/__studio/locate","Find a file by name → {path | null}"),collab:o("GET","/__studio/collab","Realtime co-editing: a WebSocket upgrade speaking the @jxsuite/collab wire envelope (one socket per project, documents multiplexed by path; y-protocols sync + project-level "+"awareness in lib0 binary frames — see @jxsuite/collab/envelope for the frame layout and "+"the docEpoch/doc-reset lifecycle). A plain GET (no Upgrade) answers {collab, protocols, version} as the capability probe, and `protocols` is the subprotocol negotiation: the client offers one of them as Sec-WebSocket-Protocol and the server echoes it, or the "+"client offers none when the server advertises none, because RFC 6455 §4.1 fails a "+"connection whose offer went unechoed.","Realtime co-editing is unavailable; Studio edits solo with file-level saves"),components:o("GET","/__studio/components","Discover components (ComponentMeta[])"),cem:o("GET","/__studio/cem","Custom-elements manifest of an npm dependency","Dependency components lose prop/slot metadata."),formats:o("GET","/__studio/formats","The project's format registry entries plus a sibling `extensions` array — per enabled "+"extension its manifest identity and project-section contributions (ExtensionsInfo[]; backs listFormats and listExtensions).","Only .json documents open (backs listFormats); descriptor-contributed settings sections do not appear."),extensionCatalog:o("GET","/__studio/catalog","Extensions this backend can OFFER (ExtensionCatalogEntry[]) — the shipped first-party "+"catalogue plus any package in the project's own dependencies exporting a jx-extension.json, each marked with whether the host resolves it without a project install and whether the project has it installed. A capability rather than a constant: a Worker ships a fixed set "+"of extension packages (specs/extensions.md §5.5). Backs listExtensionCatalog.","The Extensions section offers no catalogue; adding an extension stays a typed package name."),projectSchemas:o("GET","/__studio/project-schemas","The project's generated entry documents (project.schema.json / document.schema.json), "+"PRE-BUNDLED into self-contained schemas — {project, document} (backs fetchProjectSchemas). "+"Regenerated on demand when missing or older than project.json.","The JSON editor falls back to the bundled core schemas (extension sections get no editor validation/completion)."),format:o("POST","/__studio/format","Dispatch a format capability {format, action: parse|serialize, source?|doc?}","Non-JSON documents cannot be parsed/serialized (backs formatAction)."),pluginSchema:o("GET","/__studio/plugin-schema","Extract a $studio schema from a class source","Plugin property panels fall back to generic JSON editing."),codeFormat:o("POST","/__studio/code/format","Format posted source {code, path?} → {code, errors}","Code editors skip format-on-open/save (codeService returns null)."),codeMinify:o("POST","/__studio/code/minify","Minify posted source {code} → {code}","Compiled-output minification is skipped."),codeLint:o("POST","/__studio/code/lint","Lint posted source {code, path?} → {diagnostics}","Code editors show no lint markers."),buildSite:o("POST","/__studio/build","Build or render the site → {routes, files, errors, mode?, url}","Build Site reports that this target cannot build."),previewSite:o("POST","/__studio/preview","Preview the working tree at a route → {routes, files, errors, mode, url, reused}","Open in Browser falls back to buildSite."),previewOverlay:o("POST","/__studio/preview/overlay","Publish (POST) or retract (DELETE) a document's unsaved bytes → 204","A live preview shows the last saved state instead of the editor's."),packages:o("GET","/__studio/packages","List dependencies (PackageInfo[])"),packagesAdd:o("POST","/__studio/packages/add","Add a registry dependency, writing package.json and package-lock.json together"),packagesRemove:o("POST","/__studio/packages/remove","Remove a dependency, writing package.json and package-lock.json together"),packagesInstall:o("POST","/__studio/packages/install","Install the declared dependencies (npm's installer, writing package-lock.json)","Install/reinstall affordances are hidden; add, remove and version updates still work where the backend serves them (a cloud session updates the lockfile without installing)."),packagesNeedsInstall:o("GET","/__studio/packages/needs-install","Whether node_modules is stale","The install-on-open prompt never shows."),packagesVersions:o("GET","/__studio/packages/versions","Newest published version of each dependency (PackageVersionInfo[])","The Latest column stays empty and the update affordances are hidden."),packagesSetVersions:o("POST","/__studio/packages/set-versions","Rewrite dependency ranges and install (lockfile-only where nothing installs)","Bulk version updates are hidden."),gitStatus:o("GET","/__studio/git/status","Working-tree status (GitStatusResult)"),gitBranches:o("GET","/__studio/git/branches","Branch list (GitBranchesResult)"),gitLog:o("GET","/__studio/git/log","Recent commits (GitLogEntry[])"),gitStage:o("POST","/__studio/git/stage","Stage files"),gitUnstage:o("POST","/__studio/git/unstage","Unstage files"),gitCommit:o("POST","/__studio/git/commit","Commit staged (else all dirty) files"),gitPush:o("POST","/__studio/git/push","Push (cloud: sync check — commits land on push)"),gitPull:o("POST","/__studio/git/pull","Pull/fast-forward; 409 {conflicts} on overlap"),gitFetch:o("POST","/__studio/git/fetch","Refresh remote tracking state"),gitCheckout:o("POST","/__studio/git/checkout","Switch branches"),gitCreateBranch:o("POST","/__studio/git/create-branch","Create a branch"),gitCommitBranch:o("POST","/__studio/git/commit-branch","Commit the change set as a NEW branch off the session's base, then take it out of this one "+"→ GitCommitBranchResult; 409 branch_exists","A publish the remote conflicts with reports the conflict alone, and Send for review stays refused on a branch whose every commit is live."),gitDiff:o("GET","/__studio/git/diff","Unified diff of dirty files (or one path)"),gitShow:o("GET","/__studio/git/show","File content at a ref"),gitDiscard:o("POST","/__studio/git/discard","Discard working changes"),gitInit:o("POST","/__studio/git/init","Initialize a repository"),gitAddRemote:o("POST","/__studio/git/add-remote","Add a remote"),gitClone:o("POST","/__studio/git/clone","Clone a repository","The welcome screen hides Clone Git Repository."),gitPr:o("POST","/__studio/git/pr","Open a pull request → PullRequestInfo","Studio falls back to a direct GitHub API call with the user's token."),dataConnections:o("GET","/__studio/data/connections","Connector connections with configured/missingSecrets/isDefault state, reachable table names, and registry-descriptor provider metadata (DataConnectionsResponse; backs dataConnections)","The connections settings section shows no status, and data-domain actions stay hidden."),dataConnectionTest:o("POST","/__studio/data/connections/test","Probe a connection {connection} → DataConnectionTestResult (backs dataConnectionTest)","The Test Connection action is hidden."),dataPush:o("POST","/__studio/data/push","Additive schema push {connection?, dryRun?} → DataPushResult (plan of DataPushStep[], "+"applied, warnings/errors; backs dataPush)","The Push Schema action is hidden; schemas deploy via `jx db push` instead."),dataRows:o("GET","/__studio/data/rows","Page a table (DataRowsQuery params) → DataRowsResult {rows, total, columns} (backs dataRows)","The data grid is unavailable."),dataInsertRow:o("POST","/__studio/data/rows","Insert a row {table, connection?, values} → {row} (backs dataInsertRow)","The data grid hides its add-row footer."),dataUpdateRow:o("PUT","/__studio/data/rows","Update a row keyed on its primary key {table, connection?, pk, set} → {row} (backs "+"dataUpdateRow)","Data grid cells are read-only."),dataDeleteRow:o("DELETE","/__studio/data/rows","Delete a row (?table=&pk=&connection=) → {ok} (backs dataDeleteRow)","The data grid hides row deletion."),secretsList:o("GET","/__studio/secrets","Configured secret env-var NAMES, never values (SecretsListResponse; backs listSecrets)","Secret fields cannot show set/unset state."),secretsSet:o("PUT","/__studio/secrets","Write/remove secrets in the backend store (.dev.vars locally) {set?, remove?} → names "+"(backs setSecrets)","The secret form control renders disabled; secrets are edited in .dev.vars by hand."),aiChat:o("POST","/__studio/ai/chat","StreamEvent SSE chat proxy {messages, tools, systemPrompt, model}"),aiModels:o("GET","/__studio/ai/models","Model catalogue (AiModelsResponse)"),cfProxy:o("POST","/__studio/cf/proxy","Allowlisted Cloudflare API passthrough {path, method?, body?} (backs cfApi)","The Publish panel explains the git-push publishing path instead.")};var a$=200,l$=100,c$=12;var me=new Set(["reload","repeat","none"]);function Np(e){if(!Array.isArray(e))return[];return e.flatMap((r)=>{if(!v(r))return[];let{href:i,id:s,label:d,primary:l}=r;if(!n(s)||!s||!n(d)||!d)return[];let g={id:s,label:d};if(n(i)&&i)g.href=i;if(l===!0)g.primary=!0;return[g]})}function te(e){return n(e)&&me.has(e)}function d$(e){return te(e)?e:void 0}function ge(e){return e.replaceAll("_","-")}function P(e){if(!v(e))return{};let{actions:t,code:r,conflicts:i,heading:s,installUrl:d,retry:l,type:g}=e,a={},c=qb(g)??(n(r)?ge(r):null);if(c!==null)a.code=c;if(n(d))a.installUrl=d;if(t!==void 0)a.actions=Np(t);if(n(s)&&s)a.heading=s;if(te(l))a.retry=l;if(Array.isArray(i))a.conflicts=i.filter((b)=>n(b));return a}function CA(e){let t=P(e);return(t.code==="pull-conflict"||t.code==="conflict")&&t.conflicts?t.conflicts:null}function kA(e){let t=P(e);return t.code==="needs-installation-access"&&t.installUrl?t.installUrl:null}function EA(e){return P(e).code==="action-required"}var B="X-Jx-Ai-Session";var F="X-Api-Provider";function oe(e){return typeof e==="string"}function ye(e){return oe(e)&&e!==""}function w(e){return typeof e==="object"&&e!==null}function be(e){return Array.isArray(e)}function xe(e,t){if(!e)return t;let r;try{r=JSON.parse(e)}catch{return e}if(w(r)){if("error"in r){let{error:i}=r;if(oe(i))return i;if(w(i)&&"message"in i&&Boolean(i.message))return String(i.message)}if("errors"in r&&be(r.errors)){let[i]=r.errors;if(w(i)&&"message"in i&&Boolean(i.message))return String(i.message)}}return e}function Se(e){let t;try{t=JSON.parse(e)}catch{return""}return w(t)&&"code"in t&&ye(t.code)?t.code:""}function ne(e,t){let r=t;if(r.name==="AbortError")return{type:"done",stopReason:"cancelled"};return{type:"error",message:`${e}: ${r.message}`}}function Ae(e){return typeof e==="function"}function u$({chatUrl:e,model:t="gpt-4o",apiKey:r,baseUrl:i,provider:s,sessionId:d}){let l=null;async function*g(a,c,b,A){let S={"Content-Type":"application/json"};if(r)S["X-Api-Key"]=r;if(i)S["X-Api-Base-URL"]=i;if(s&&s!=="openai-compat")S[F]=s;if(d)S[B]=d;l??=Promise.resolve(Ae(e)?e():e);let x;try{x=await l}catch(h){if(A.aborted){yield{type:"done",stopReason:"cancelled"};return}throw h}if(A.aborted){yield{type:"done",stopReason:"cancelled"};return}let f;try{f=await fetch(x,{method:"POST",headers:S,body:JSON.stringify({messages:a,tools:c,systemPrompt:b,model:t}),signal:A})}catch(h){yield ne("Network error",h);return}if(!f.ok){let h="";try{h=await f.text()}catch{}let T=xe(h,f.statusText),M=Se(h);yield{type:"error",message:T,code:M||String(f.status)};return}let y=f.body?.getReader();if(!y){yield{type:"error",message:"No response body"};return}let ue=new TextDecoder,U="";try{for(let h=await y.read();!h.done;h=await y.read()){U+=ue.decode(h.value,{stream:!0});let T=U.split(`
2
- `);U=T.pop()||"";for(let M of T){let L=M.trim();if(!L||!L.startsWith("data: "))continue;let pe=L.slice(6),E;try{E=JSON.parse(pe)}catch{continue}if(yield E,E.type==="done"||E.type==="error")return}}}catch(h){y.cancel(),yield ne("Stream error",h)}}return{streamChat:g}}function sh(){return Eo(rt.aiOpenAiKey)}function TA(e){xr(rt.aiOpenAiKey,e||"")}function dx(){return jA(rt.aiOpenAiKey)}function cl(){return Eo(rt.aiBaseUrl)}function Ca(){return Eo(rt.aiProvider)==="anthropic"?"anthropic":"openai-compat"}function LA(){return Ca()==="openai-compat"?sh():""}function ux(){return Eo(rt.aiModel)}function $A(e){xr(rt.aiModel,e||"")}function G(e){return e==="anthropic"?"anthropic":""}function IA(e){BA([[rt.aiOpenAiKey,e.apiKey],[rt.aiBaseUrl,e.baseUrl],[rt.aiModel,e.model],[rt.aiProvider,G(e.provider)]])}function RA(e){return!Im(rt.aiOpenAiKey,e.apiKey,sh())||!Im(rt.aiBaseUrl,e.baseUrl,cl())||!Im(rt.aiModel,e.model,ux())||G(e.provider)!==G(Ca())}function Im(e,t,r){return fx(e,t)===fx(e,r)}function DA(){Op([rt.aiOpenAiKey,rt.aiBaseUrl,rt.aiModel,rt.aiProvider])}var Pe="claude-opus-5-5";function lC(){return{apiKey:sh(),baseUrl:cl(),provider:Ca()}}function se(e){let t=e.provider??"openai-compat";return`${e.apiKey}\x00${e.baseUrl}\x00${t}`}var _=null,O="",q=!1,j=!1,J="",H,V="",k=null,K=["openai-compat"],W=null,re=new Set,Re=600000,R=0,ie=!1;function ds(){_=null,O="",q=!1,j=!1,J="",H=void 0,V="",k=null,K=["openai-compat"],W=null,R=0}var ve=new Set([rt.aiOpenAiKey.key,rt.aiBaseUrl.key,rt.aiProvider.key,rt.cfToken.key,rt.cfAccountId.key]);Ap((e)=>{if(e.some((t)=>ve.has(t)))ds()});function h$(e){return _&&O===se(e)?_:null}function ae(e){return _?.find((t)=>t.id===e)}function p$(e){return ae(e)?.toolSupport}function NA(e){return ae(e)?.contextWindow}function hx(e){if(e)re.add(e);W??=ah({force:!0}).catch(()=>{}).then(()=>{R=Date.now();for(let t of re)t()})}function Te(){if(!j||R===0||Date.now()-R<Re)return!1;return W=null,R=0,hx(),!0}function Ee(){if(typeof window>"u"||ie)return;ie=!0,window.addEventListener("focus",()=>{Te()})}Ee();function Gb(){return dx()||cC()}function cC(){return q}function AA(){return j}function Rm(){return H}function OA(){return V}function dC(){return k}function MA(){return K}function we(){return J}function Zl(){let e=Ca()==="anthropic"?Pe:rt.aiModel.default;return ux()||we()||e}function Oe(e,t){let r;try{r=new URL(e,"http://jx.invalid")}catch{return e}return r.pathname=r.pathname.replace(/[^/]*$/,t),/^https?:/i.test(e)?r.href:`${r.pathname}${r.search}`}function ke(e){if(e===void 0)return["openai-compat"];return e.filter((t)=>["anthropic","openai-compat"].includes(t))}async function ah(e={}){let t=e.credentials??lC(),r=se(t);if(_&&O===r&&!e.force)return _;let i=p(),s=await Promise.resolve(i.aiChatUrl()),d=Oe(s,"models"),l={};if(t.apiKey)l["X-Api-Key"]=t.apiKey;if(t.baseUrl)l["X-Api-Base-URL"]=t.baseUrl;if(t.provider==="anthropic")l[F]=t.provider;let g=await fetch(d,{headers:l});if(!g.ok)throw Error(`HTTP ${g.status}`);let a=await g.json();if(q=a.configured===!0,j=a.managed===!0,J=a.defaultModel??"",H=a.code,V=a.upstreamError!==void 0?a.upstreamMessage??"":"",k=null,K=ke(a.providers),a.code==="action_required"){let c={actions:Np(a.actions)};if(n(a.detail)&&a.detail)c.detail=a.detail;k=c}return _=(a.models||[]).map((c)=>{let b={id:c.id,name:c.name||c.id};if(Z(c.contextWindow))b.contextWindow=c.contextWindow;if(Ze(c.toolSupport))b.toolSupport=c.toolSupport;return b}),O=r,_}var I=new Set,z=null;function PA(e){if(I.size===0){z=e;return}for(let t of I)t(e)}function ce(e){I.add(e);let t=z;if(z=null,t)e(t);return()=>{I.delete(e)}}function uC(){return _e()&&ee(p().performAction)}function f$(e){let t=e.find((i)=>i.primary)??e[0];if(!t)return null;let r=e.find((i)=>i!==t);return r?{lead:t,other:r}:{lead:t}}var D=null,le=!1;function hC(e){let t=f$(e.actions);if(!uC()||!t)return Promise.resolve(!1);return D??=Ce(e,t).finally(()=>{D=null}),D}async function Dm(e){let t=P(e);if(t.code!=="action-required"||!t.actions?.length)return!1;return hC({actions:t.actions,detail:e instanceof Error?e.message:void 0,heading:t.heading,retry:t.retry})}async function de(){ds(),await jd(),m$()}function Ce(e,t){let r=e.detail??"This needs one more step first.";return new Promise((i)=>{let s="offer",d=(x)=>{if(s==="done")return;s="done",S.close(),i(x)},l=(x)=>{s="offer",S.update({cancelLabel:"Not now",confirmLabel:t.lead.label,message:x,secondaryLabel:t.other?.label??""})},g=async(x)=>{let f;try{f=await x}catch(y){if(s==="waiting")l(y instanceof Error?y.message:String(y));return}if(f?.status==="done"){await de(),d(!0);return}if(s!=="waiting"||!f||f.status==="redirect")return;jd(),l(r)},a=(x)=>{if(s!=="offer")return;s="waiting";let f;try{f=p().performAction(x)}catch(y){l(y instanceof Error?y.message:String(y));return}S.update({cancelLabel:"Cancel",confirmLabel:"Waiting…",message:"Finish in the window that opened. This closes by itself once it is done.",secondaryLabel:""}),g(f)},{lead:c,other:b}=t,A={cancelLabel:"Not now",confirmLabel:c.label,headline:e.heading??"One more step",layer:dt("dialog"),message:r,onCancel:()=>{le=!0,d(!1)},onClosed:()=>{d(!1)},onConfirm:()=>{a(c)},region:"account/action"};if(b)A.onSecondary=()=>{a(b)},A.secondaryLabel=b.label;let S=Zs(A)})}function je(e){if(e==="reload")location.reload();else if(e==="repeat")C.info("Done. Run that again now.",{key:"account.action.retry",source:"Account"})}function FA(){return ce((e)=>{if(le||D)return;hC(e).then((t)=>{if(t)je(e.retry)})})}async function px(e){if(!uC())return!1;let t=p().performAction(e),r;try{r=await t}catch(i){return C.error(i instanceof Error?i.message:String(i),{key:"account.action",source:"Account",tier:"toast"}),!1}if(r?.status==="done")return await de(),!0;if(r?.status!=="redirect")await jd();return!1}function m$(){for(let e of Y()){let t={key:`account.notice.${e.id}`,source:"Account"};if(e.level==="warning")C.warn(e.message,t);else C.info(e.message,t)}}
3
- export{jd,sC,aC,_A,SA,s$,qb,nr,ll,a$,l$,c$,Np,d$,CA,kA,EA,u$,sh,TA,dx,cl,Ca,LA,ux,$A,IA,RA,Im,DA,lC,ds,h$,p$,NA,hx,Gb,cC,AA,Rm,OA,dC,MA,Zl,ah,PA,uC,f$,hC,Dm,FA,px,m$};
1
+ import{p,ye}from"./studio-4fnb5648.js";import{rt,Eo,kO,Bp,Dx,xr,TO,zp}from"./studio-g9brbewz.js";import{w}from"./studio-sce30r7b.js";import{Zs,dt}from"./studio-tpxcryf2.js";import{n,Y,Ze,Q,v}from"./studio-k3we3kqb.js";var u=null;async function Hd(){if(!ye()||!Q(p().getAccountStatus)){u=null;return}try{u=await p().getAccountStatus?.()??null}catch{u=null}}function iC(){return u}function oC(){return u!==null&&u.installations.length===0&&Boolean(u.appInstallUrl)}function dA(){if(u===null)return null;let e=u.installations.flatMap((r)=>r.manageUrl?[{account:r.account??`Installation ${r.id}`,url:r.manageUrl}]:[]);if(e.length===0&&!u.appInstallUrl)return null;let t={manage:e};if(u.appInstallUrl)t.installUrl=u.appInstallUrl;return t}function uA(){return u?.entries??[]}function AL(){return(u?.notices??[]).filter((e)=>e.display!=="toast")}var X=new Set;function Z(){let e=(u?.notices??[]).filter((t)=>t.display==="toast"&&!X.has(t.id));for(let t of e)X.add(t.id);return e}var ee="https://jxsuite.com/problems/";function N(e){return typeof e==="string"}function fe(e){return typeof e==="object"&&e!==null}function Bb(e){if(!N(e)||!e.startsWith("https://jxsuite.com/problems/"))return null;let t=e.slice(29);return t===""?null:t}function tr(e){if(N(e))return e.trim()===""?null:e;if(!fe(e))return null;for(let t of[e.detail,e.error,e.title])if(N(t)&&t.trim()!=="")return t;return null}function ll(e,t){return tr(e)??(t===void 0?"Request failed":`Request failed (${t})`)}var m=(e,t,r,i)=>{let s={status:t,title:r,type:`${ee}${e}`};if(i!==void 0)s.extensions=i;return s},Ne={invalidRequest:m("invalid-request",400,"The request was malformed or incomplete"),notFound:m("not-found",404,"The requested resource does not exist"),methodNotAllowed:m("method-not-allowed",405,"That method is not allowed on this route"),conflict:m("conflict",409,"The request conflicts with the current state",["conflicts"]),payloadTooLarge:m("payload-too-large",413,"The request body is too large"),unauthorized:m("unauthorized",401,"Credentials are missing or not accepted"),forbidden:m("forbidden",403,"The request was refused"),needsInstallationAccess:m("needs-installation-access",403,"The GitHub App is not installed for that account",["installUrl"]),pathOutsideProject:m("path-outside-project",403,"The path resolves outside the active project"),actionRequired:m("action-required",403,"An action is required first",["actions","heading","retry"]),noActiveProject:m("no-active-project",409,"No project is active on this backend"),capabilityUnavailable:m("capability-unavailable",501,"This backend does not provide that capability"),upstreamFailure:m("upstream-failure",502,"An upstream service failed",["upstream"]),internalError:m("internal-error",500,"The backend failed to complete the request")};var o=(e,t,r,i)=>{let s={method:e,path:t,optional:i!==void 0,summary:r};if(i!==void 0)s.degradation=i;return s},Fe={activate:o("POST","/__studio/activate","Bind the backend to a project root"),project:o("GET","/__studio/project","Root project metadata {name, root}"),projectInfo:o("GET","/__studio/project-info","Probe a directory: {isSiteProject, projectConfig?, directories?}"),resolveSite:o("GET","/__studio/resolve-site","Resolve the owning site of a file path {sitePath, projectConfig?, fileRelPath?}"),sites:o("GET","/__studio/sites","Enumerate site projects [{config, path}] (backs listProjects)","The welcome screen's Projects catalogue stays hidden."),createProject:o("POST","/__studio/create-project","Scaffold a project at a caller-chosen destination → {root, config}"),starters:o("GET","/__studio/starters","Starter templates (StarterInfo[])","The New Project picker offers only blank/templates."),importSite:o("POST","/__studio/import-site","Clone a live website into a project; streams NDJSON progress","The New Project Import tab is unavailable."),files:o("GET","/__studio/files","List a directory (DirEntry[]) in stable path order; an entry may carry an opaque content `version` the backend vouches for; with ?glob=<pattern>, search matching files project-wide"),fileRead:o("GET","/__studio/file","Read a file's text content"),filesRead:o("POST","/__studio/files/read","Read many files' text content {paths} → ReadFilesResult {files: [path, {content} | "+"{error: {status, code?, message}}][], omitted}. At most READ_FILES_MAX_PATHS (200) paths and a backend byte budget per call: the excess is listed in `omitted` (never a 400) and the first path is always answered. Per-path errors: 404 missing/deleted, 415 binary, 413 too large, 502 upstream. Allowed for read-only sessions; keeps fileRead's server-side effects","Adapters fall back to one fileRead per path."),fileWrite:o("PUT","/__studio/file","Write a file's text content"),fileDelete:o("DELETE","/__studio/file","Delete a file"),fileUpload:o("POST","/__studio/file/upload","Upload binary content to a path → UploadResult {path, size?}. `path` is the answer, not an "+"echo: a store that de-duplicates, suffixes, or normalizes names reports what it really wrote"),fileBytes:o("GET","/__studio/file/bytes","A project file's raw bytes, undecoded — the read side of `fileUpload`, for a caller that must "+"not go through UTF-8","Studio can only read a project file as text, so any surface that must decode one stays hidden."),documentRaw:o("GET","/__studio/raw/","A project file as its own bytes, at its own URL — the mount a canvas renders against when "+"the editor origin does not serve the site's URL space. The project-relative path is appended to this prefix","The canvas cannot address project files by URL, so a host whose origin does not serve the site URL space renders no component $refs and no images."),fileRename:o("POST","/__studio/file/rename","Rename/move (+ refactor report). `from`/`to` are server-root-relative; every path in the "+"report is relative to the active project (specs/server.md §4.1)"),references:o("GET","/__studio/references","Where a file or a component tag is used (?path=&tag=, at least one) → ReferencesResult "+"{files, filesReferencing, refsTotal} — the read side of the rename refactor's own walker, "+"cached until the backend's watcher sees the tree move (backs findReferences). `?path=` is server-root-relative and every path in the answer is relative to the active project; a "+"target outside that project is a 400, never a zero-result 200 (specs/server.md §4.1)",'Usage counts are hidden: no "Used on N pages" in the inspector, no Selection: Find Usages, and delete/rename confirmations state no reference count.'),locate:o("POST","/__studio/locate","Find a file by name → {path | null}"),collab:o("GET","/__studio/collab","Realtime co-editing: a WebSocket upgrade speaking the @jxsuite/collab wire envelope (one socket per project, documents multiplexed by path; y-protocols sync + project-level "+"awareness in lib0 binary frames — see @jxsuite/collab/envelope for the frame layout and "+"the docEpoch/doc-reset lifecycle). A plain GET (no Upgrade) answers {collab, protocols, version} as the capability probe, and `protocols` is the subprotocol negotiation: the client offers one of them as Sec-WebSocket-Protocol and the server echoes it, or the "+"client offers none when the server advertises none, because RFC 6455 §4.1 fails a "+"connection whose offer went unechoed.","Realtime co-editing is unavailable; Studio edits solo with file-level saves"),components:o("GET","/__studio/components","Discover components (ComponentMeta[])"),cem:o("GET","/__studio/cem","Custom-elements manifest of an npm dependency","Dependency components lose prop/slot metadata."),formats:o("GET","/__studio/formats","The project's format registry entries plus a sibling `extensions` array — per enabled "+"extension its manifest identity and project-section contributions (ExtensionsInfo[]; backs listFormats and listExtensions).","Only .json documents open (backs listFormats); descriptor-contributed settings sections do not appear."),extensionCatalog:o("GET","/__studio/catalog","Extensions this backend can OFFER (ExtensionCatalogEntry[]) — the shipped first-party "+"catalogue plus any package in the project's own dependencies exporting a jx-extension.json, each marked with whether the host resolves it without a project install and whether the project has it installed. A capability rather than a constant: a Worker ships a fixed set "+"of extension packages (specs/extensions.md §5.5). Backs listExtensionCatalog.","The Extensions section offers no catalogue; adding an extension stays a typed package name."),projectSchemas:o("GET","/__studio/project-schemas","The project's generated entry documents (project.schema.json / document.schema.json), "+"PRE-BUNDLED into self-contained schemas — {project, document} (backs fetchProjectSchemas). "+"Regenerated on demand when missing or older than project.json.","The JSON editor falls back to the bundled core schemas (extension sections get no editor validation/completion)."),format:o("POST","/__studio/format","Dispatch a format capability {format, action: parse|serialize, source?|doc?}","Non-JSON documents cannot be parsed/serialized (backs formatAction)."),pluginSchema:o("GET","/__studio/plugin-schema","Extract a $studio schema from a class source","Plugin property panels fall back to generic JSON editing."),codeFormat:o("POST","/__studio/code/format","Format posted source {code, path?} → {code, errors}","Code editors skip format-on-open/save (codeService returns null)."),codeMinify:o("POST","/__studio/code/minify","Minify posted source {code} → {code}","Compiled-output minification is skipped."),codeLint:o("POST","/__studio/code/lint","Lint posted source {code, path?} → {diagnostics}","Code editors show no lint markers."),buildSite:o("POST","/__studio/build","Build or render the site → {routes, files, errors, mode?, url}","Build Site reports that this target cannot build."),previewSite:o("POST","/__studio/preview","Preview the working tree at a route → {routes, files, errors, mode, url, reused}","Open in Browser falls back to buildSite."),previewOverlay:o("POST","/__studio/preview/overlay","Publish (POST) or retract (DELETE) a document's unsaved bytes → 204","A live preview shows the last saved state instead of the editor's."),packages:o("GET","/__studio/packages","List dependencies (PackageInfo[])"),packagesAdd:o("POST","/__studio/packages/add","Add a registry dependency, writing package.json and package-lock.json together"),packagesRemove:o("POST","/__studio/packages/remove","Remove a dependency, writing package.json and package-lock.json together"),packagesInstall:o("POST","/__studio/packages/install","Install the declared dependencies (npm's installer, writing package-lock.json)","Install/reinstall affordances are hidden; add, remove and version updates still work where the backend serves them (a cloud session updates the lockfile without installing)."),packagesNeedsInstall:o("GET","/__studio/packages/needs-install","Whether node_modules is stale","The install-on-open prompt never shows."),packagesVersions:o("GET","/__studio/packages/versions","Newest published version of each dependency (PackageVersionInfo[])","The Latest column stays empty and the update affordances are hidden."),packagesSetVersions:o("POST","/__studio/packages/set-versions","Rewrite dependency ranges and install (lockfile-only where nothing installs)","Bulk version updates are hidden."),gitStatus:o("GET","/__studio/git/status","Working-tree status (GitStatusResult)"),gitBranches:o("GET","/__studio/git/branches","Branch list (GitBranchesResult)"),gitLog:o("GET","/__studio/git/log","Recent commits (GitLogEntry[])"),gitStage:o("POST","/__studio/git/stage","Stage files"),gitUnstage:o("POST","/__studio/git/unstage","Unstage files"),gitCommit:o("POST","/__studio/git/commit","Commit staged (else all dirty) files"),gitPush:o("POST","/__studio/git/push","Push (cloud: sync check — commits land on push)"),gitPull:o("POST","/__studio/git/pull","Pull/fast-forward; 409 {conflicts} on overlap"),gitFetch:o("POST","/__studio/git/fetch","Refresh remote tracking state"),gitCheckout:o("POST","/__studio/git/checkout","Switch branches"),gitCreateBranch:o("POST","/__studio/git/create-branch","Create a branch"),gitCommitBranch:o("POST","/__studio/git/commit-branch","Commit the change set as a NEW branch off the session's base, then take it out of this one "+"→ GitCommitBranchResult; 409 branch_exists","A publish the remote conflicts with reports the conflict alone, and Send for review stays refused on a branch whose every commit is live."),gitDiff:o("GET","/__studio/git/diff","Unified diff of dirty files (or one path)"),gitShow:o("GET","/__studio/git/show","File content at a ref"),gitDiscard:o("POST","/__studio/git/discard","Discard working changes"),gitInit:o("POST","/__studio/git/init","Initialize a repository"),gitAddRemote:o("POST","/__studio/git/add-remote","Add a remote"),gitClone:o("POST","/__studio/git/clone","Clone a repository","The welcome screen hides Clone Git Repository."),gitPr:o("POST","/__studio/git/pr","Open a pull request → PullRequestInfo","Studio falls back to a direct GitHub API call with the user's token."),dataConnections:o("GET","/__studio/data/connections","Connector connections with configured/missingSecrets/isDefault state, reachable table names, and registry-descriptor provider metadata (DataConnectionsResponse; backs dataConnections)","The connections settings section shows no status, and data-domain actions stay hidden."),dataConnectionTest:o("POST","/__studio/data/connections/test","Probe a connection {connection} → DataConnectionTestResult (backs dataConnectionTest)","The Test Connection action is hidden."),dataPush:o("POST","/__studio/data/push","Additive schema push {connection?, dryRun?} → DataPushResult (plan of DataPushStep[], "+"applied, warnings/errors; backs dataPush)","The Push Schema action is hidden; schemas deploy via `jx db push` instead."),dataRows:o("GET","/__studio/data/rows","Page a table (DataRowsQuery params) → DataRowsResult {rows, total, columns} (backs dataRows)","The data grid is unavailable."),dataInsertRow:o("POST","/__studio/data/rows","Insert a row {table, connection?, values} → {row} (backs dataInsertRow)","The data grid hides its add-row footer."),dataUpdateRow:o("PUT","/__studio/data/rows","Update a row keyed on its primary key {table, connection?, pk, set} → {row} (backs "+"dataUpdateRow)","Data grid cells are read-only."),dataDeleteRow:o("DELETE","/__studio/data/rows","Delete a row (?table=&pk=&connection=) → {ok} (backs dataDeleteRow)","The data grid hides row deletion."),secretsList:o("GET","/__studio/secrets","Configured secret env-var NAMES, never values (SecretsListResponse; backs listSecrets)","Secret fields cannot show set/unset state."),secretsSet:o("PUT","/__studio/secrets","Write/remove secrets in the backend store (.dev.vars locally) {set?, remove?} → names "+"(backs setSecrets)","The secret form control renders disabled; secrets are edited in .dev.vars by hand."),aiChat:o("POST","/__studio/ai/chat","StreamEvent SSE chat proxy {messages, tools, systemPrompt, model}"),aiModels:o("GET","/__studio/ai/models","Model catalogue (AiModelsResponse)"),cfProxy:o("POST","/__studio/cf/proxy","Allowlisted Cloudflare API passthrough {path, method?, body?} (backs cfApi)","The Publish panel explains the git-push publishing path instead.")};var OL=200,ML=100,PL=12;var me=new Set(["reload","repeat","none"]);function Dp(e){if(!Array.isArray(e))return[];return e.flatMap((r)=>{if(!v(r))return[];let{href:i,id:s,label:d,primary:l}=r;if(!n(s)||!s||!n(d)||!d)return[];let g={id:s,label:d};if(n(i)&&i)g.href=i;if(l===!0)g.primary=!0;return[g]})}function te(e){return n(e)&&me.has(e)}function FL(e){return te(e)?e:void 0}function ge(e){return e.replaceAll("_","-")}function P(e){if(!v(e))return{};let{actions:t,code:r,conflicts:i,heading:s,installUrl:d,retry:l,type:g}=e,a={},c=Bb(g)??(n(r)?ge(r):null);if(c!==null)a.code=c;if(n(d))a.installUrl=d;if(t!==void 0)a.actions=Dp(t);if(n(s)&&s)a.heading=s;if(te(l))a.retry=l;if(Array.isArray(i))a.conflicts=i.filter((b)=>n(b));return a}function hA(e){let t=P(e);return(t.code==="pull-conflict"||t.code==="conflict")&&t.conflicts?t.conflicts:null}function pA(e){let t=P(e);return t.code==="needs-installation-access"&&t.installUrl?t.installUrl:null}function fA(e){return P(e).code==="action-required"}var B="X-Jx-Ai-Session";var F="X-Api-Provider";function oe(e){return typeof e==="string"}function be(e){return oe(e)&&e!==""}function O(e){return typeof e==="object"&&e!==null}function xe(e){return Array.isArray(e)}function Se(e,t){if(!e)return t;let r;try{r=JSON.parse(e)}catch{return e}if(O(r)){if("error"in r){let{error:i}=r;if(oe(i))return i;if(O(i)&&"message"in i&&Boolean(i.message))return String(i.message)}if("errors"in r&&xe(r.errors)){let[i]=r.errors;if(O(i)&&"message"in i&&Boolean(i.message))return String(i.message)}}return e}function _e(e){let t;try{t=JSON.parse(e)}catch{return""}return O(t)&&"code"in t&&be(t.code)?t.code:""}function ne(e,t){let r=t;if(r.name==="AbortError")return{type:"done",stopReason:"cancelled"};return{type:"error",message:`${e}: ${r.message}`}}function Ae(e){return typeof e==="function"}function jL({chatUrl:e,model:t="gpt-4o",apiKey:r,baseUrl:i,provider:s,sessionId:d}){let l=null;async function*g(a,c,b,A){let S={"Content-Type":"application/json"};if(r)S["X-Api-Key"]=r;if(i)S["X-Api-Base-URL"]=i;if(s&&s!=="openai-compat")S[F]=s;if(d)S[B]=d;l??=Promise.resolve(Ae(e)?e():e);let x;try{x=await l}catch(h){if(A.aborted){yield{type:"done",stopReason:"cancelled"};return}throw h}if(A.aborted){yield{type:"done",stopReason:"cancelled"};return}let f;try{f=await fetch(x,{method:"POST",headers:S,body:JSON.stringify({messages:a,tools:c,systemPrompt:b,model:t}),signal:A})}catch(h){yield ne("Network error",h);return}if(!f.ok){let h="";try{h=await f.text()}catch{}let T=Se(h,f.statusText),M=_e(h);yield{type:"error",message:T,code:M||String(f.status)};return}let y=f.body?.getReader();if(!y){yield{type:"error",message:"No response body"};return}let ue=new TextDecoder,U="";try{for(let h=await y.read();!h.done;h=await y.read()){U+=ue.decode(h.value,{stream:!0});let T=U.split(`
2
+ `);U=T.pop()||"";for(let M of T){let L=M.trim();if(!L||!L.startsWith("data: "))continue;let pe=L.slice(6),E;try{E=JSON.parse(pe)}catch{continue}if(yield E,E.type==="done"||E.type==="error")return}}}catch(h){y.cancel(),yield ne("Stream error",h)}}return{streamChat:g}}function Qu(){return Eo(rt.aiOpenAiKey)}function mA(e){xr(rt.aiOpenAiKey,e||"")}function tx(){return kO(rt.aiOpenAiKey)}function cl(){return Eo(rt.aiBaseUrl)}function Ca(){return Eo(rt.aiProvider)==="anthropic"?"anthropic":"openai-compat"}function gA(){return Ca()==="openai-compat"?Qu():""}function nx(){return Eo(rt.aiModel)}function bA(e){xr(rt.aiModel,e||"")}function G(e){return e==="anthropic"?"anthropic":""}function vA(e){TO([[rt.aiOpenAiKey,e.apiKey],[rt.aiBaseUrl,e.baseUrl],[rt.aiModel,e.model],[rt.aiProvider,G(e.provider)]])}function yA(e){return!Dm(rt.aiOpenAiKey,e.apiKey,Qu())||!Dm(rt.aiBaseUrl,e.baseUrl,cl())||!Dm(rt.aiModel,e.model,nx())||G(e.provider)!==G(Ca())}function Dm(e,t,r){return Dx(e,t)===Dx(e,r)}function wA(){zp([rt.aiOpenAiKey,rt.aiBaseUrl,rt.aiModel,rt.aiProvider])}var Pe="claude-opus-5-5";function rC(){return{apiKey:Qu(),baseUrl:cl(),provider:Ca()}}function se(e){let t=e.provider??"openai-compat";return`${e.apiKey}\x00${e.baseUrl}\x00${t}`}var _=null,k="",q=!1,j=!1,J="",H,V="",C=null,K=["openai-compat"],W=null,re=new Set,Re=600000,R=0,ie=!1;function cs(){_=null,k="",q=!1,j=!1,J="",H=void 0,V="",C=null,K=["openai-compat"],W=null,R=0}var ve=new Set([rt.aiOpenAiKey.key,rt.aiBaseUrl.key,rt.aiProvider.key,rt.cfToken.key,rt.cfAccountId.key]);Bp((e)=>{if(e.some((t)=>ve.has(t)))cs()});function HL(e){return _&&k===se(e)?_:null}function ae(e){return _?.find((t)=>t.id===e)}function BL(e){return ae(e)?.toolSupport}function xA(e){return ae(e)?.contextWindow}function ix(e){if(e)re.add(e);W??=eh({force:!0}).catch(()=>{}).then(()=>{R=Date.now();for(let t of re)t()})}function Te(){if(!j||R===0||Date.now()-R<Re)return!1;return W=null,R=0,ix(),!0}function Ee(){if(typeof window>"u"||ie)return;ie=!0,window.addEventListener("focus",()=>{Te()})}Ee();function zb(){return tx()||sC()}function sC(){return q}function _A(){return j}function Nm(){return H}function SA(){return V}function aC(){return C}function CA(){return K}function we(){return J}function Xl(){let e=Ca()==="anthropic"?Pe:rt.aiModel.default;return nx()||we()||e}function Oe(e,t){let r;try{r=new URL(e,"http://jx.invalid")}catch{return e}return r.pathname=r.pathname.replace(/[^/]*$/,t),/^https?:/i.test(e)?r.href:`${r.pathname}${r.search}`}function ke(e){if(e===void 0)return["openai-compat"];return e.filter((t)=>["anthropic","openai-compat"].includes(t))}async function eh(e={}){let t=e.credentials??rC(),r=se(t);if(_&&k===r&&!e.force)return _;let i=p(),s=await Promise.resolve(i.aiChatUrl()),d=Oe(s,"models"),l={};if(t.apiKey)l["X-Api-Key"]=t.apiKey;if(t.baseUrl)l["X-Api-Base-URL"]=t.baseUrl;if(t.provider==="anthropic")l[F]=t.provider;let g=await fetch(d,{headers:l});if(!g.ok)throw Error(`HTTP ${g.status}`);let a=await g.json();if(q=a.configured===!0,j=a.managed===!0,J=a.defaultModel??"",H=a.code,V=a.upstreamError!==void 0?a.upstreamMessage??"":"",C=null,K=ke(a.providers),a.code==="action_required"){let c={actions:Dp(a.actions)};if(n(a.detail)&&a.detail)c.detail=a.detail;C=c}return _=(a.models||[]).map((c)=>{let b={id:c.id,name:c.name||c.id};if(Y(c.contextWindow))b.contextWindow=c.contextWindow;if(Ze(c.toolSupport))b.toolSupport=c.toolSupport;return b}),k=r,_}var I=new Set,z=null;function kA(e){if(I.size===0){z=e;return}for(let t of I)t(e)}function ce(e){I.add(e);let t=z;if(z=null,t)e(t);return()=>{I.delete(e)}}function lC(){return ye()&&Q(p().performAction)}function zL(e){let t=e.find((i)=>i.primary)??e[0];if(!t)return null;let r=e.find((i)=>i!==t);return r?{lead:t,other:r}:{lead:t}}var D=null,le=!1;function cC(e){let t=zL(e.actions);if(!lC()||!t)return Promise.resolve(!1);return D??=Ce(e,t).finally(()=>{D=null}),D}async function Am(e){let t=P(e);if(t.code!=="action-required"||!t.actions?.length)return!1;return cC({actions:t.actions,detail:e instanceof Error?e.message:void 0,heading:t.heading,retry:t.retry})}async function de(){cs(),await Hd(),WL()}function Ce(e,t){let r=e.detail??"This needs one more step first.";return new Promise((i)=>{let s="offer",d=(x)=>{if(s==="done")return;s="done",S.close(),i(x)},l=(x)=>{s="offer",S.update({cancelLabel:"Not now",confirmLabel:t.lead.label,message:x,secondaryLabel:t.other?.label??""})},g=async(x)=>{let f;try{f=await x}catch(y){if(s==="waiting")l(y instanceof Error?y.message:String(y));return}if(f?.status==="done"){await de(),d(!0);return}if(s!=="waiting"||!f||f.status==="redirect")return;Hd(),l(r)},a=(x)=>{if(s!=="offer")return;s="waiting";let f;try{f=p().performAction(x)}catch(y){l(y instanceof Error?y.message:String(y));return}S.update({cancelLabel:"Cancel",confirmLabel:"Waiting…",message:"Finish in the window that opened. This closes by itself once it is done.",secondaryLabel:""}),g(f)},{lead:c,other:b}=t,A={cancelLabel:"Not now",confirmLabel:c.label,headline:e.heading??"One more step",layer:dt("dialog"),message:r,onCancel:()=>{le=!0,d(!1)},onClosed:()=>{d(!1)},onConfirm:()=>{a(c)},region:"account/action"};if(b)A.onSecondary=()=>{a(b)},A.secondaryLabel=b.label;let S=Zs(A)})}function je(e){if(e==="reload")location.reload();else if(e==="repeat")w.info("Done. Run that again now.",{key:"account.action.retry",source:"Account"})}function EA(){return ce((e)=>{if(le||D)return;cC(e).then((t)=>{if(t)je(e.retry)})})}async function ox(e){if(!lC())return!1;let t=p().performAction(e),r;try{r=await t}catch(i){return w.error(i instanceof Error?i.message:String(i),{key:"account.action",source:"Account",tier:"toast"}),!1}if(r?.status==="done")return await de(),!0;if(r?.status!=="redirect")await Hd();return!1}function WL(){for(let e of Z()){let t={key:`account.notice.${e.id}`,source:"Account"};if(e.level==="warning")w.warn(e.message,t);else w.info(e.message,t)}}
3
+ export{Hd,iC,oC,dA,uA,AL,Bb,tr,ll,OL,ML,PL,Dp,FL,hA,pA,fA,jL,Qu,mA,tx,cl,Ca,gA,nx,bA,vA,yA,Dm,wA,rC,cs,HL,BL,xA,ix,zb,sC,_A,Nm,SA,aC,CA,Xl,eh,kA,lC,zL,cC,Am,EA,ox,WL};
4
4
 
5
- //# debugId=584DA92FF104B84864756E2164756E21
6
- //# sourceMappingURL=studio-hhp4x8xf.js.map
5
+ //# debugId=89C05923FB8BBA4C64756E2164756E21
6
+ //# sourceMappingURL=studio-xpx91fby.js.map
@@ -0,0 +1,5 @@
1
+ import{X}from"./studio-9c6cbq2c.js";import{p,ye}from"./studio-4fnb5648.js";import{w}from"./studio-sce30r7b.js";import{us}from"./studio-4zd6an2b.js";import{fI,Yx,xv,h}from"./studio-yrcrncev.js";import{v1,mi,zv}from"./studio-nvcn2ykc.js";import{$s,Kd,HO,BO,zO}from"./studio-hh394phe.js";import{Ls}from"./studio-bct64zmj.js";import{oa,tR,nR,ra,At}from"./studio-1ks5d9y4.js";import{GC,rI,mh}from"./studio-zfdbmhp3.js";import{C}from"./studio-4f7thq0p.js";import{Y}from"./studio-k3we3kqb.js";var UC="__other__";function ds(t){return t.trim().toLowerCase().replaceAll(/\s+/g,"-").replaceAll(/[^a-z\d-]/g,"")}function q$(t){let e=t.lastIndexOf(".");return e>0?t.slice(e):""}function G$(t,e,n){let r=t.trim();if(n===void 0||e==="__other__")return r;if(n.kind==="fixed"){let i=ds(r);return i===""?"":`${i}${n.ext}`}return r.toLowerCase().endsWith(e.toLowerCase())?r:`${r}${e}`}function iv(t,e,n){let{choice:r,dir:i,known:o=new Set,rows:s=null,taken:a}=n,l=t.trim();if(!l)return r?.kind==="fixed"?"Enter a name.":"Enter a file name.";if(r?.kind==="fixed"&&ds(l)==="")return"Enter at least one letter or number.";let d=l.replaceAll("\\","/");if(d.startsWith("/")||d.endsWith("/"))return"Enter a name, not a path that starts or ends with a slash.";if(d.split("/").includes(".."))return"A name cannot step outside the destination folder.";if(d.includes("/")&&r!==void 0&&e!=="__other__")return`Pick Other… to create a file in a subfolder of ${i==="."?"the project root":i}.`;let u=q$(d);if(e!==""&&e!=="__other__"&&u!==""&&u.toLowerCase()!==e.toLowerCase()&&o.has(u.toLowerCase()))return`You picked ${s?.find((v)=>v.value===e)?.label??e}; this name ends in ${u}.`;if(r?.kind==="locked"&&e==="__other__"){if(u!==""&&u.toLowerCase()!==r.ext.toLowerCase()&&o.has(u.toLowerCase()))return r.because}let m=G$(t,e,r);return a.has(m.toLowerCase())?`${m} already exists in ${i}/.`:""}function Wm(t,e,n){let r=e.trim();if(r==="")return"Enter a file name.";if(/[/\\]/.test(r))return"Enter a name, not a path. A rename keeps the file in its folder.";let i=(t.split("/").pop()??t).toLowerCase();if(r.startsWith(".")&&!i.startsWith("."))return"A name cannot start with a dot: hidden files are not listed, so the file could disappear.";let o=r.toLowerCase();if(o!==i&&[...n].some((s)=>s.toLowerCase()===o))return`${r} already exists in this folder.`;return""}function x(t){let e=["B","KB","MB","GB"],n=t,r=0;while(n>=1024&&r<e.length-1)n/=1024,r+=1;return`${r===0?n:Number(n.toFixed(1))} ${e[r]}`}var R=["image/*","video/*","audio/*",".pdf",".svg",".woff",".woff2",".ttf",".otf"].join(",");function Jc(){return(ye()?p().assetCapabilities?.accept:void 0)??R}function zd(t){return ra.has(At(t))}function Wd(t){let e=t.type??"";if(e.startsWith("image/"))return"image";if(e.startsWith("video/"))return"video";if(e.startsWith("audio/"))return"audio";let n=At(t.name);if(oa.has(n))return"image";if(tR.has(n))return"video";if(nR.has(n))return"audio";return"file"}var K$=new Set([".woff",".woff2",".ttf",".otf"]);function IO(t){if(K$.has(At(t)))return"font";let e=Wd({name:t});return e==="file"?"document":e}var k=/^content\/([^/]+)\//,Ta="public/media";function J$(t){let e=t?k.exec(t.replaceAll("\\","/")):null;return e?`content/${e[1]}/images`:Ta}function RO(t){let e=t.replaceAll("\\","/");return e===Ta||/^content\/[^/]+\/images$/.test(e)}function T(t){let e=t.replaceAll("\\","/");if(e.startsWith("public/"))return e.slice(6);let n=/^content\/[^/]+\/(.+)$/.exec(e);if(n)return`./${n[1]}`;return`./${e}`}function P(t,e){let n=new Set([...e].map((o)=>o.toLowerCase()));if(!n.has(t.toLowerCase()))return t;let r=At(t),i=r?t.slice(0,-r.length):t;for(let o=1;;o++){let s=`${i}-${o}${r}`;if(!n.has(s.toLowerCase()))return s}}function Y$(t,e){let n=t.replaceAll("\\","/").replace(/\/+$/,"");return n==="."||n===""?e:`${n}/${e}`}var y=null;function DO(t){y=t}async function Nx(t,e){await(e===void 0?y?.(t):y?.(t,e))}function M(t){let e=t.replaceAll("\\","/"),n=e.lastIndexOf("/");return n>0?e.slice(0,n):"."}function I(t,e){let n=(o)=>e==="image"?oa.has(At(o.name)):zd(o.name),r=[],i=[];for(let o of t)if(n(o))r.push(o);else i.push(o.name);if(i.length>0)w.warn(i.length===1?`Skipped ${i[0]}`:`Skipped ${i.length} files`,{detail:e==="image"?`Only images can be used here: ${i.join(", ")}.`:`Studio lists images, video, audio, PDFs and fonts as media, so ${i.join(", ")} would not appear in it.`,source:"Media"});return r}async function Ys(t,e={}){let n=e.only===void 0?[...t]:I([...t],e.only);if(n.length===0)return[];let r=p(),i=e.dir??J$(h.value?.documentPath??null),o=e.source??"Media",s;try{let d=await $s(()=>r.listDirectory(i));s=new Set(d.map((u)=>u.name))}catch(d){if(e.dirExists===!0)return w.error(`Could not write to ${i}/.`,{detail:`The folder could not be read to choose a name that overwrites nothing: ${X(d)}`,path:i,source:o}),[];s=new Set}let a=ye()?p().assetCapabilities?.maxUploadBytes:void 0,l=[];for(let d of n){if(a!==void 0&&d.size>a){w.error(`${d.name} is too large.`,{detail:`This backend accepts at most ${x(a)}; that file is ${x(d.size)}.`,source:"Media"});continue}let u=P(d.name,s);s.add(u);let m=Y$(i,u);try{let{path:f}=await(e.write?e.write(m):r.uploadFile(m,d));Kd([f]),l.push({kind:Wd(d),name:u,path:f,ref:T(f)})}catch(f){w.error(`Could not upload ${d.name}.`,{detail:X(f),path:m,source:o})}}if(l.length>0){if(e.quiet!==!0)w.success(l.length===1?`Uploaded ${l[0].name} to ${i}/`:`Uploaded ${l.length} files to ${i}/`);await y?.(i)}return l}function L(t){try{let e=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0}).decode(t);return e.startsWith("\uFEFF")?null:e}catch{return null}}function D(t){let e=t.slice(0,t.length-At(t).length);return`${e.replace(/-copy(?:-\d+)?$/,"")}-copy${t.slice(e.length)}`}async function Ax(t,e={}){let n=t.split("/").pop()??t,r=e.source??"Media",i;try{let a=p();if(a.readFileBytes===void 0)throw Error("This backend cannot read a file's raw bytes.");i=await a.readFileBytes(t)}catch(a){return w.error(`Could not duplicate ${n}.`,{detail:X(a),path:t,source:r}),null}let o=e.document===!0?L(i):null,[s]=await Ys([new File([i],D(n))],{dir:M(t),dirExists:!0,quiet:!0,source:r,...o!==null&&{write:async(a)=>(await p().writeFile(a,o),{path:a})}});if(!s)return null;if(s.path===t)return w.warn(`${n} was not duplicated.`,{detail:"The backend keeps identical files once, so it made no second file.",path:t,source:r}),null;return w.success(`Duplicated ${n} as ${s.name}`),s}var z=[new Set([".jpg",".jpeg"]),new Set([".tif",".tiff"])];function A(t){return z.find((e)=>e.has(t))??new Set([t])}function NO(t){return[...A(At(t))].join(",")}function N(t,e){return A(At(t)).has(At(e.name))}function AO(t,e,n){let r=Wm(t,e,n);if(r!=="")return r;if(!N(t,{name:e.trim()}))return`Keep the ${At(t)} extension. A rename does not convert the file, so another extension would break it on every page.`;return""}async function Ox(t,e,n={}){let r=t.split("/").pop()??t;if(!N(t,e))return w.error(`${e.name} cannot replace ${r}.`,{detail:`${r} is ${At(t)||"a file with no extension"} and ${e.name} is ${At(e.name)||"a file with no extension"}. Every page that uses ${r} would get bytes its address does not describe; choose a file of the same type, or upload it as a new file.`,path:t,source:"Media"}),!1;let i=ye()?p().assetCapabilities?.maxUploadBytes:void 0;if(i!==void 0&&e.size>i)return w.error(`${e.name} is too large.`,{detail:`This backend accepts at most ${x(i)}; that file is ${x(e.size)}.`,source:"Media"}),!1;Ls(t);let o;try{({path:o}=await p().uploadFile(t,e))}catch(s){return w.error(`Could not replace ${r}.`,{detail:X(s),path:t,source:"Media"}),!1}if(Kd([t,o]),o===t)BO(t);if(us(),await(o===t?Nx(M(t),t):Nx(M(t))),o!==t)return w.warn(`${r} was not replaced.`,{detail:`The backend stored the new file as ${o}, so every reference still shows the old one.`,path:t,source:"Media",tier:"problem"}),!1;return w.success(n.note===void 0?`Replaced ${r}`:`Replaced ${r}: ${n.note}`),!0}function Mx(t){let e=mi(t),n=e.lastIndexOf("/");return n===-1?e:e.slice(n+1)}function ov(t){let e=mi(t),n=e.lastIndexOf("/");return n===-1?".":e.slice(0,n)}function B(){return C?.projectConfig?.content??null}function _(t){return xv(t,B(),rI())}function U(t,e){return`${mi(e.urlPrefix)}/${t.slice(e.dir.length+1)}`}function rv(t){let e=mi(t);if(e.startsWith(`${v1}/`))return`/${e.slice(v1.length+1)}`;let n=_(e);return n?`/${U(e,n)}`:`/${e}`}function nr(t){let e=mi(t);if(e==="")return t;let{space:n,fileBaseUrl:r}=mh(),i=zO(e);if(n==="repo")return Yx(fI(`${r}${zv(e)}`,HO(e)),i);let o=zv(rv(e).slice(1));return Yx(GC(`/${o}`),i)}var c=new Map,E=new Map,g=new Map,b=new Set;function S(t){return At(t)===".svg"}function F(t){let e=t===null?null:/^\s*(\d+(?:\.\d+)?)\s*(?:px)?\s*$/.exec(t),n=e?Number(e[1]):Number.NaN;return n>0?n:null}function j(t){let e=new DOMParser().parseFromString(t,"image/svg+xml").documentElement;if(e.localName!=="svg")return null;let n=F(e.getAttribute("width")),r=F(e.getAttribute("height")),i=(e.getAttribute("viewBox")??"").trim().split(/[\s,]+/).map(Number),o=i[2]??Number.NaN,s=i[3]??Number.NaN,a=i.length===4&&o>0&&s>0,l=null;if(n!==null&&r!==null)l={height:r,width:n};else if(a&&n!==null)l={height:n*s/o,width:n};else if(a&&r!==null)l={height:r,width:r*o/s};else if(a)l={height:s,width:o};return l&&{height:Math.round(l.height),width:Math.round(l.width)}}async function K(t){b.add(t);try{let e=j(await p().readFile(t));if(e&&e.width>0&&e.height>0)g.set(t,e)}catch{}}function Vd(t){let e=mi(t);return c.has(e)&&(!S(e)||b.has(e))}function O(t,e){let n=Mx(t),r=g.get(t);return{bytes:Y(e?.size)?e.size:null,ext:At(n),height:r?.height??null,kind:Wd({name:n}),modified:e?.modified??null,name:n,path:t,width:r?.width??null}}function Yc(t){return c.get(mi(t))??null}function OO(t){for(let e of t){if(e.type!=="file")continue;let n=mi(e.path);if(!c.has(n))c.set(n,O(n,e))}}async function hh(t){let e=mi(t),n=c.get(e);if(n&&Vd(e))return n;let r=E.get(e);if(r)return r;let i=(async()=>{if(S(e)&&!b.has(e))await K(e);if(n){let a=g.get(e);return{...n,height:a?.height??null,width:a?.width??null}}let s;try{s=(await $s(()=>p().listDirectory(ov(e)))).find((l)=>mi(l.path)===e)}catch{s=void 0}return O(e,s)})();E.set(e,i);let o=await i;return E.delete(e),c.set(e,o),o}function fl(t,e,n){if(!(e>0&&n>0))return!1;let r=mi(t);if(S(r))return!1;let i=g.get(r);if(i&&i.width===e&&i.height===n)return!1;g.set(r,{height:n,width:e});let o=c.get(r);if(o)c.set(r,{...o,height:n,width:e});return!0}function MO(){c.clear(),g.clear(),b.clear()}function Vm(t){if(t<1024)return`${t} B`;if(t<1048576)return`${Math.round(t/1024)} KB`;return`${(t/1048576).toFixed(1)} MB`}function Px(t){if(!t)return"";let e=[];if(t.width!==null&&t.height!==null)e.push(`${t.width} × ${t.height}`);if(t.bytes!==null)e.push(Vm(t.bytes));return e.join(" · ")}
2
+ export{UC,ds,q$,G$,iv,Wm,Jc,zd,Wd,K$,IO,Ta,J$,RO,Y$,DO,Nx,Ys,Ax,NO,AO,Ox,Mx,ov,rv,nr,Vd,Yc,OO,hh,fl,MO,Vm,Px};
3
+
4
+ //# debugId=44F9FA380FD26FC664756E2164756E21
5
+ //# sourceMappingURL=studio-y1b86ast.js.map
@@ -0,0 +1,5 @@
1
+ import{w}from"./studio-sce30r7b.js";import{nu}from"./studio-swedpd82.js";import{p}from"./studio-4fnb5648.js";import{Wi,fn,lr}from"./studio-aam8zt8z.js";import{qI,b1,$o,o2,g0,GI,KI,JI,zv}from"./studio-nvcn2ykc.js";import{$v,LI,Cr,C}from"./studio-4f7thq0p.js";import{Ce,oe,Ov,Mv,h1,df,p1,na,uf,sg,d0}from"./studio-v5wktj6f.js";import{me,ia,te,g,le,Ph}from"./studio-3qr08sxq.js";import{n,Y,Ze,_,v,Go,Di,ld,xf}from"./studio-k3we3kqb.js";import{ce}from"./studio-0939t1q1.js";var we=g(new Set);function qm(e){we.add(e)}function Vx(e){we.delete(e)}function ZC(e){return we.has(e)}var lI=()=>({kind:"proceed"});function vv(e,t){return{success:!0,data:e,summary:t}}function Hn(e){return{success:!1,error:e}}function Vr({name:e,description:t,parameters:o,strict:r=!0,llmStrict:i=!1,interactive:s,title:a,annotations:l,interaction:c,settle:u,execute:d}){let f={name:e,description:t,parameters:o,strict:r,llmStrict:i,execute:d};if(s!==void 0)f.interactive=s;if(a!==void 0)f.title=a;if(l!==void 0)f.annotations=l;if(c!==void 0)f.interaction=c;if(u!==void 0)f.settle=u;return f}function Ux(e){let t=[];return{record(o){t.push(o),e?.(o)},writes:t}}function yh(e=null,t={}){let o=new Map(Object.entries(t));return{sessionId:e,get:(r)=>o.get(r),set:(r,i)=>{o.set(r,i)},toJSON:()=>Object.fromEntries(o)}}var Qt=new AbortController().signal;function qx(e={}){let t=e.session??yh();return{actor:e.actor??{id:`assistant:${t.sessionId??"local"}:`,kind:"assistant",sessionId:t.sessionId,turnId:""},callId:e.callId??"",ledger:e.ledger??Ux(),progress:e.progress??(()=>{}),session:t,signal:e.signal??Qt}}function GO(e){let t=new AbortController;if(e.aborted)return t.abort(e.reason),{release:()=>{},signal:t.signal};let o=()=>{t.abort(e.reason)};return e.addEventListener("abort",o,{once:!0}),{release:()=>{e.removeEventListener("abort",o)},signal:t.signal}}function Gx(){let e=new Map;return{register(t){if(e.has(t.name))console.warn(`Tool "${t.name}" is being re-registered.`);e.set(t.name,t)},list(){return[...e.values()]},listForLLM(){return[...e.values()].map((t)=>{let o={name:t.name,description:t.description,parameters:t.parameters};if(t.llmStrict===!0)o.strict=!0;return{type:"function",function:o}})},getDefinition(t){return e.get(t)},validate(t,o){let r=e.get(t);if(!r)return{valid:!1,errors:[`Unknown tool: "${t}"`]};if(!r.strict)return{valid:!0};let i=r.parameters;if(!i.properties)return{valid:!0};let s=[],a=i.properties,l=i.required||[];for(let c of l)if(!(c in o)||o[c]===void 0||o[c]===null)s.push(`Missing required argument: "${c}"`);for(let[c,u]of Object.entries(o)){let d=a[c];if(!d)continue;let f=d.type;if(!f)continue;let x=ze(u);if(f==="number"||f==="integer"){if(Re(u,"number"))continue;if(Re(u,"string")){if(!Number.isNaN(Number(u)))continue;s.push(`Argument "${c}" should be a number, got non-numeric string "${u}"`);continue}s.push(`Argument "${c}" should be a number, got ${x}`);continue}if(f==="string"&&x!=="string")s.push(`Argument "${c}" should be a string, got ${x}`);else if(f==="boolean"&&x!=="boolean")s.push(`Argument "${c}" should be a boolean, got ${x}`);else if(f==="array"&&x!=="array")s.push(`Argument "${c}" should be an array, got ${x}`);else if(f==="object"&&x!=="object")s.push(`Argument "${c}" should be an object, got ${x}`)}return s.length>0?{valid:!1,errors:s}:{valid:!0}},async execute(t,o,r=qx()){let i=e.get(t);if(!i)return Hn(`Unknown tool: "${t}"`);let s=this.validate(t,o);if(!s.valid)return Hn(`Validation failed: ${(s.errors||[]).join("; ")}`);try{return await i.execute(o,r)}catch(a){return Hn(`Tool "${t}" execution error: ${ge(a)}`)}}}}var en="The author declined this call.";function tn(e){return JSON.parse(JSON.stringify(e))}function ge(e){return e.message}var nn=["string","number","boolean","undefined"];function Re(e,t){return typeof e===t}function on(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function ze(e){if(Array.isArray(e))return"array";return nn.find((t)=>Re(e,t))??"object"}function rn(e){if(!e)return{};let t=JSON.parse(e);if(!on(t)){let o=t===null?"null":ze(t);throw TypeError(`arguments must be a JSON object, got ${o}`)}return t}async function cI(e,t,o,{approval:r=lI,response:i}={}){let s=!1,a;try{let l=rn(t.argumentsText),c=e.getDefinition(t.name),u=c?sn(e,c,l,r,i):null;if(u?.status==="needs_input")return u;if(u)({result:a}=u);else s=!0,a=await e.execute(t.name,l,o)}catch(l){a=Hn(`Failed to parse arguments: ${ge(l)}`)}try{return{status:"done",result:tn(a),executed:s}}catch(l){let c=ge(l);return{status:"done",result:Hn(`Tool "${t.name}" returned a result that cannot be serialized: ${c}`),executed:s}}}function sn(e,t,o,r,i){let{interaction:s,settle:a}=t;if(s&&a){let c=e.validate(t.name,o);if(!c.valid)return pe(`Validation failed: ${(c.errors||[]).join("; ")}`);if(i)return{status:"done",result:cn(t.name,a,o,i),executed:!1};let u=s(o);return"refusal"in u?pe(u.refusal):{status:"needs_input",request:u}}let l=r(t,o);if(l.kind==="deny")return pe(l.message);if(l.kind==="confirm"){if(!i)return{status:"needs_input",request:{kind:"approval",reason:l.reason,summary:l.summary,title:t.title??t.name,tool:t.name}};if(i.kind!=="approval"||!i.approved)return pe(en)}return null}function pe(e){return{status:"done",result:Hn(e),executed:!1}}function cn(e,t,o,r){try{return t(o,r)}catch(i){return Hn(`Tool "${e}" execution error: ${ge(i)}`)}}var un=new Set(["Adlm","Arab","Aran","Armi","Avst","Cprt","Egyd","Egyh","Elym","Gara","Hatr","Hebr","Hluw","Hung","Khar","Lydi","Mand","Mani","Mend","Merc","Mero","Narb","Nbat","Nkoo","Orkh","Palm","Phli","Phlp","Phnx","Prti","Rohg","Samr","Sarb","Sogd","Sogo","Syrc","Thaa","Todr","Yezi"]),KC="^[A-Za-z]{2,8}(-[A-Za-z0-9]{1,8})*$";function jn(e){if(!n(e)||e.trim()==="")return null;try{return new Intl.Locale(e.trim()).toString()}catch{return null}}function Fx(e){return jn(e)!==null}function fv(e){let t=jn(e);if(t===null)return"ltr";let o=new Intl.Locale(t),r=o.script??o.maximize().script;return r!==void 0&&un.has(r)?"rtl":"ltr"}function Wt(e){let t=jn(e);if(t===null)return n(e)?e:"";return new Intl.DisplayNames([t],{type:"language"}).of(t)??t}var dn="prefix-except-default";function ln(e){let t=e.i18n,o=[];if(!_(t))return{errors:o,i18n:null};let r=Array.isArray(t.locales)?t.locales:[],i=[];for(let l of r){let c=jn(l);if(c===null){o.push(`i18n.locales: "${String(l)}" is not a well-formed BCP 47 language tag.`);continue}if(!i.includes(c))i.push(c)}let s=jn(t.defaultLocale)??i[0]??null;if(t.defaultLocale!==void 0&&jn(t.defaultLocale)===null)o.push(`i18n.defaultLocale: "${String(t.defaultLocale)}" is not a well-formed BCP 47 language tag.`);if(s===null)return o.push("i18n is declared with no usable locale — set `defaultLocale` or `locales`."),{errors:o,i18n:null};if(!i.includes(s))i.unshift(s);let a=t.routing==="prefix-always"||t.routing==="prefix-except-default"?t.routing:dn;return{errors:o,i18n:{defaultLocale:s,locales:i,routing:a}}}function go(e,t){let o=Ae(q(e),t);if(o===-1||t===null)return null;return jn(q(e)[o])}function jx(e,t){let o=go(e,t);if(o!==null||t===null||t.routing!=="prefix-except-default")return o;return q(e)[0]==="pages"?t.defaultLocale:null}function mv(e,t){let o=q(e),r=Ae(o,t);return r===-1?o.join("/"):o.filter((i,s)=>s!==r).join("/")}function Qc(e,t,o){if(o===null)return null;let r=jn(t);if(r===null||!o.locales.includes(r))return null;let i=q(e),s=Ae(i,o),a=s===-1?mn(i):s;if(a===-1)return null;let l=s===-1?i:i.filter((c,u)=>u!==s);if(r===o.defaultLocale&&o.routing==="prefix-except-default")return l.join("/");return l.toSpliced(a,0,r.toLowerCase()).join("/")}function q(e){return e.replace(/^\.\//,"").split("/").filter(Boolean)}function Ae(e,t){if(t===null)return-1;return e.findIndex((o)=>{let r=jn(o);return r!==null&&t.locales.includes(r)})}function mn(e){if(e[0]==="pages"&&e.length>1)return 1;if(e[0]==="content"&&e.length>2)return 2;return-1}function VO(e,t){if(t===null)return null;let o=e.split("/").find(Boolean);if(o===void 0)return t.defaultLocale;let r=jn(o);return r!==null&&t.locales.includes(r)?r:t.defaultLocale}function fI(e,t){return Ye(e,"v",t)}function Yx(e,t){return Ye(e,"r",t)}function Ye(e,t,o){if(!n(o)||o==="")return e;let r=e.indexOf("#"),i=r===-1?"":e.slice(r),s=r===-1?e:e.slice(0,r),a=s.indexOf("?"),l=a===-1?s:s.slice(0,a),u=(a===-1?[]:s.slice(a+1).split("&")).filter((d)=>d!==""&&!gn(d,t));return u.push(`${t}=${encodeURIComponent(o)}`),`${l}?${u.join("&")}${i}`}function gn(e,t){let o=e.indexOf("="),r=o===-1?e:e.slice(0,o);if(r===t)return!0;if(!r.includes("%"))return!1;try{return decodeURIComponent(r)===t}catch{return!1}}function Je(e,t){if(!e||!Object.hasOwn(e,t))return;let o=e[t];return n(o)?o:void 0}function xv(e,t,o=[]){if(!e||!t)return null;let r=e.replaceAll("\\","/").replace(/^\.\//,""),i=null,s=(a,l)=>{if(r.startsWith(`${a}/`)&&(!i||a.length>i.dir.length))i={dir:a,urlPrefix:l}};for(let[a,l]of Object.entries(t)){if(!l?.source||!b1.test(a))continue;let c=bn(l.source);if(c===""||c.startsWith(".."))continue;if(c.includes($o)){let u=yn(r,c,a,o);if(u)s(u.dir,u.urlPrefix);continue}if(/\.[a-z0-9]+$/i.test(c))continue;s(c,`/${qI}/${a}`)}return i}function yn(e,t,o,r){let i=t.indexOf($o),s=t.slice(0,i),a=t.slice(i+$o.length);if(!e.startsWith(s))return null;let l=e.slice(s.length).split("/")[0]??"";if(l===""||!b1.test(l))return null;let c=r.find((d)=>d.toLowerCase()===l.toLowerCase());if(c===void 0||!b1.test(c))return null;return{dir:`${s}${l}${a}`.replace(/\/+$/,""),urlPrefix:`/${qI}/${o}/${c}`}}function bn(e){return e.replaceAll("\\","/").replace(/^\.\//,"").replace(/\/+$/,"")}function _v(e,t){if(!t||e==="")return null;if(t.space==="repo"){if(!t.fileBaseUrl)return null;let s=JI(e,t.documentDir,t.mounts,t.lanes);if(s===null)return null;let{suffix:a}=g0(e);return Yx(fI(`${t.fileBaseUrl}${zv(s)}${a}`,Je(t.versions,s)),Je(t.revisions,s))}let[o]=t.mounts,r=o?Tn(e,t.documentDir,o):null,i=hn(e,t);return i===void 0?r:Yx(r??e,i)}function hn(e,t){if(!t.revisions||Object.keys(t.revisions).length===0)return;let o=JI(e,t.documentDir,t.mounts,t.lanes);return o===null?void 0:Je(t.revisions,o)}function Tn(e,t,o){if(GI(e))return null;let{path:r,suffix:i}=g0(e),s;try{s=decodeURIComponent(r)}catch{return null}let a=KI(t,s);if(a===null)return null;let l=o2([o],a);if(!l)return null;return`${l}${i}`}function Xe(e){return e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}function G(e){return e.replaceAll("\\","/").replace(/^\.\//,"").replace(/\/+$/,"")}function et(e){return e??C?.projectConfig??null}function tt(e){return e?.content??{}}function vn(e){let t=ln(e??{}).i18n?.locales??[];return t.length>0?[...t]:null}function nt(e){if(e.endsWith("/"))return!1;let t=e.slice(e.lastIndexOf("/")+1);return/\.[a-z\d]+$/i.test(t)}function ot(e){if(e.format==="json")return{ext:".json",unresolvedFormat:null};if(e.format===void 0||e.format==="")return{ext:lr()?.extensions[0]??".json",unresolvedFormat:null};let t=Wi(e.format);return t?.extensions[0]===void 0?{ext:null,unresolvedFormat:e.format}:{ext:t.extensions[0],unresolvedFormat:null}}function On(e,t){let o=t===null?"[^/]+":`(?:${t.map((i)=>Xe(i)).join("|")})`,r=G(e).split($o).map((i)=>Xe(i)).join(o);return new RegExp(`^${r}(?:/|$)`,"i")}function Pn(e,t,o){let r=On(e,o).exec(t);if(!r)return null;return r[0].replace(/\/$/,"")}function Sn(e){return G(e).replaceAll($o,"").length}function Jd(e,t){if(e===null||e===void 0||e==="")return null;let o=et(t),r=vn(o),i=G(e),s=null,a=-1;for(let[l,c]of Object.entries(tt(o))){let{source:u}=c;if(u===void 0||u===""||nt(u))continue;let d=Sn(u);if(d<=a)continue;let f=Pn(u,i,r);if(f===null)continue;s={def:c,dir:i,fileBacked:!1,isSourceRoot:i.length===f.length,name:l,...ot(c)},a=d}return s}function Gn(e,t){if(e===null||e===void 0||e==="")return null;let o=et(t),r=G(e),i=r.toLowerCase();for(let[s,a]of Object.entries(tt(o))){let{source:l}=a;if(l===void 0||l===""||!nt(l))continue;let c=G(l).toLowerCase();if(i===c||i.endsWith(`/${c}`))return{def:a,dir:r.includes("/")?r.slice(0,r.lastIndexOf("/")):".",fileBacked:!0,isSourceRoot:!1,name:s,...ot(a)}}return Jd(r.includes("/")?r.slice(0,r.lastIndexOf("/")):".",o)}function ed(e){return e.replaceAll(/([A-Z])/g," $1").replace(/^./,(t)=>t.toUpperCase())}function Qx(e){return e.replaceAll(/[^a-zA-Z0-9]+(.)?/g,(t,o)=>o?o.toUpperCase():"").replace(/^[A-Z]/,(t)=>t.toLowerCase())}function e0(e){return e.replaceAll(/(^|-)(\w)/g,(t,o,r)=>(o?" ":"")+r.toUpperCase())}function e1(e,t){return e?.$label||ed(t)}function lM(e,t){if(e?.$label)return e.$label;if(t.includes("-"))return t.replaceAll(/(^|-)(\w)/g,(o,r,i)=>(r?" ":"")+i.toUpperCase());return ed(t)}function Ra(e){return e==="image"||e==="uri-reference"}function wh(e){if(e.$shorthand===!0)return"shorthand";if(e.$input==="button-group")return"button-group";if(e.$input==="media")return"media";if(e.format==="color")return"color";if(Ra(e.format))return"media";if(e.$units!==void 0)return"number-unit";if(e.type==="number")return"number";if(Array.isArray(e.enum))return"select";if(Array.isArray(e.examples)||Array.isArray(e.presets))return"combobox";return"text"}function xh(e,t){if(!e||!t?.content)return null;let o=Gn(e,t);if(!o||!o.def.schema)return null;if(!o.fileBacked){let r=o.ext??lr()?.extensions[0]??".json";if(!e.toLowerCase().endsWith(r.toLowerCase()))return null}return{name:o.name,schema:o.def.schema}}function Sv(e,t){let o=e.trim().toLowerCase().replaceAll(/[^a-z0-9\s-]/g,"").replaceAll(/\s+/g,"-").replaceAll(/-+/g,"-").replaceAll(/^-|-$/g,"");if(!o)return"";return`${t}${o}`}function t0(e,t){return e.replace(new RegExp(`^${t.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}`),"").replace(/^--/,"").replaceAll("-"," ").replaceAll(/\b\w/g,(o)=>o.toUpperCase())||e}function cM(e){if(!e)return{kind:"text"};let t=e.trim().replaceAll(/\s*\|\s*undefined\b/g,"").trim();if(t==="boolean")return{kind:"boolean"};if(t==="number")return{kind:"number"};if(t.match(/^'[^']*'(\s*\|\s*'[^']*')+$/))return{kind:"combobox",options:[...t.matchAll(/'([^']*)'/g)].map((i)=>i[1])};return{kind:"text"}}function ir(e){return JSON.parse(JSON.stringify(e))}function Oe(e){return e?.at(-1)??null}function YO(e){return e?.[0]??null}function Kx(e,t){if(!t||!e)return!1;return e.some((o)=>Cr(o,t))}function Ia(e){return z(e)}function z(e){let t=[];for(let o of e)t.push([...o]);return t}function Jx(e,t){if(Kx(e,t))return z(e.filter((o)=>!Cr(o,t)));return[...z(e),[...t]]}function ZO(e,t,o){let r=e.findIndex((a)=>Cr(a,o)),i=t?e.findIndex((a)=>Cr(a,t)):-1;if(r===-1||i===-1)return[[...o]];let s=i<=r?e.slice(i,r+1):e.slice(r,i+1).toReversed();return z(s)}function ye(e,t){return z(e.filter((o)=>!na(t,o)))}function XO(e){let t=[];for(let o of e)if(!t.some((r)=>Cr(r,o)))t.push([...o]);return t}function Jm(e){if(e.length===0)return{mixed:!1,value:void 0};let[t]=e,o=JSON.stringify(t??null);for(let r=1;r<e.length;r++)if(JSON.stringify(e[r]??null)!==o)return{mixed:!0,value:void 0};return{mixed:!1,value:t}}var rt=null;function aM(e){rt=e}function it(){return rt}var X=null,Q=null,ee=null,Ie=!0;function st(){X=[],Q=[],ee=[],Ie=!0}function y(e){if(X)X.push(e)}function Bi(e){if(Q)Q.push(e)}function at(e){if(ee)ee.push(e)}function lt(){let e={docOps:Q??[],fmOps:ee??[],invertible:Ie,ops:X??[]};return X=null,Q=null,ee=null,Ie=!0,e}var wn=100,Cn=20;function ne(){try{return typeof localStorage>"u"||!localStorage.getItem("jx-legacy-history")}catch{return!0}}function S(e,t){let o=oe(e,t);if(!o)throw TypeError(`No node at path [${t.join(", ")}]`);return o}function P(e,t,o,r){return{forward:{key:t,op:"set-key",path:e,value:r},inverse:{key:t,op:"set-key",path:e,value:o}}}var ct=null;function ut(e){ct=e}var dt=null;function ft(e){dt=e}function Rn(e,t,o,r){for(let i=t.docOps.length-1;i>=0;i--)Mv(e.doc.document,le(t.docOps[i].inverse));for(let i=t.fmOps.length-1;i>=0;i--){let s=t.fmOps[i];Ee(e,s.field,s.before)}e.doc.document={...le(e.doc.document)},e.session.selection=o,e.doc.dirty=r}function Z(e,t,{skipHistory:o=!1,origin:r="user",coalesceKey:i=null,actor:s=null}={}){if(!e)return!1;if(r!=="remote"&&dt?.(e,r))return!1;let a=s??be;if(r!=="remote")je(e,a);let l=Ia(e.session.selection),c=e.doc.dirty;st();let u,d=null;try{t(e)}catch(A){d={error:A}}finally{u=lt()}if(d)throw Rn(e,u,l,c),d.error;let f=le(e.doc.document),x={...f},k=it(),j=k===null?{patchable:!1,reason:"no-patch-consumer"}:u.ops.length===0?{patchable:!1,reason:"unrecorded-mutation"}:k.classify(e,u.ops);if(j.patchable)k.markConsumed(x,e);if(e.doc.document=x,j.patchable)try{k.apply(e,u.ops,u)}catch(A){k.escalate(`patch-apply-failed: ${A instanceof Error?A.message:String(A)}`,e)}if(!o){let A=a?In(a):null;if(A)kn(A,e,u,l);else pt(e,f,u,l,i)}return e.doc.dirty=!0,ct?.(e,u,r),!0}function pt(e,t,o,r,i=null){let s=e.history.snapshots.slice(0,e.history.index+1),a=ne()&&o.invertible&&(o.docOps.length>0||o.fmOps.length>0),l=s.at(-1);if(i&&a&&l&&l.coalesceKey===i&&l.inverseOps){if(l.forwardOps=[...l.forwardOps??[],...o.docOps.map((u)=>u.forward)],l.inverseOps=[...l.inverseOps,...o.docOps.map((u)=>u.inverse)],l.selection=Ia(e.session.selection),l.document)l.document=ir(t);e.history.snapshots=s,e.history.index=s.length-1;return}let c=!a||s.length%Cn===0;if(s.push({document:c?ir(t):null,fmOps:a&&o.fmOps.length>0?o.fmOps:null,forwardOps:a?o.docOps.map((u)=>u.forward):null,inverseOps:a?o.docOps.map((u)=>u.inverse):null,coalesceKey:i,selection:Ia(e.session.selection),selectionBefore:r}),s.length>wn){if(!s[1].document)s[1].document=ke(s,1);s.shift()}e.history.snapshots=s,e.history.index=s.length-1}function ke(e,t){let o=t;while(o>=0&&!e[o].document)o-=1;let r=o<0?null:e[o].document;if(!r)throw Error("history-missing-checkpoint");let i=ir(r);for(let s=o+1;s<=t;s++)for(let a of e[s].forwardOps??[])Mv(i,a);return i}function Yd(e,t,o){return Z(e,(r)=>t(r.doc.document),o)}function De(e,t){Z(e,(o)=>{for(let r of t)xe(o,r)},{origin:"remote",skipHistory:!0})}function dM(e,t,{actor:o=null,selection:r={kind:"keep"}}={}){if(t.length===0)return"unchanged";return Z(e,(s)=>{for(let a of t)xe(s,a,p1(le(s.doc.document),a));An(s,r)},{actor:o})?"applied":"refused"}function An(e,t){if(t.kind==="prune")for(let o of t.under)e.session.selection=ye(e.session.selection,o);else if(t.kind==="follow"&&Cr(Oe(e.session.selection),t.from))e.session.selection=[[...t.to]]}var Jn=new Set(["state","$media","$head","$elements","imports","$layout"]);function xe(e,t,o=t){let r=null;if(t.op==="set-key")r=oe(e.doc.document,t.path)?.[t.key];switch(Mv(e.doc.document,t),Bi({forward:t,inverse:o}),t.op){case"set-key":{if(Jn.has(t.key))y({key:t.key,op:"doc-meta"});else if(t.key==="style")y({op:"set-style",path:t.path});else if(t.key==="textContent")y({op:"set-text",path:t.path});else if(t.key==="attributes"||t.key==="cases"||t.key==="$props")y({op:"replace",path:t.path});else{let i=t.key.startsWith("on")&&(xf(t.value)||xf(r));y({isEvent:i,key:t.key,op:"set-prop",path:t.path})}return}case"insert-child":{y({index:t.index,op:"insert",parentPath:t.parentPath});return}case"remove-child":{y({op:"remove",path:[...t.parentPath,"children",t.index]});return}case"set-child":{y({op:"replace",path:[...t.parentPath,"children",t.index]});return}case"move-child":{y({fromPath:[...t.fromParentPath,"children",t.fromIndex],op:"move",toIndex:t.toIndex,toParentPath:t.toParentPath});break}default:break}}var V=new Map,M=new Map,be=null,mt=null;function gt(e){mt=e}function uM(e){let t=V.get(e.id);if(t)he(t);let o={owner:e,receipts:[]};return V.set(e.id,o),{owner:e,flush:()=>he(o),close:()=>{if(he(o),V.get(e.id)===o)V.delete(e.id);return[...o.receipts]}}}function bI(e,t){let o=be;be=e;try{return t()}finally{be=o}}function yt(e,t){let o=M.get(e);return o!==void 0&&(!t||o.lane.owner.id===t.id)}function hM(){for(let e of V.values())he(e)}function In(e){return V.get(e.id)??null}function he(e){for(let[t,o]of M)if(o.lane===e)bt(t,o)}function kn(e,t,o,r){let i=M.get(t);if(!i)i={docOps:[],fmOps:[],invertible:!0,lane:e,selectionBefore:r},M.set(t,i);if(i.docOps.push(...o.docOps),i.fmOps.push(...o.fmOps),!o.invertible||o.docOps.length===0&&o.fmOps.length===0)i.invertible=!1}function je(e,t){let o=M.get(e);if(o&&o.lane.owner.id!==t?.id)bt(e,o)}function bt(e,t){M.delete(e);let{owner:o}=t.lane,r=o.turnId??"";if(F.has(e))t.lane.receipts.push({entry:null,tab:e,turnId:r});else{let i={docOps:t.docOps,fmOps:t.fmOps,invertible:t.invertible,ops:[]};pt(e,le(e.doc.document),i,t.selectionBefore);let s=e.history.snapshots[e.history.index];if(s.actor=o.id,o.turnId!==void 0)s.turnId=o.turnId;t.lane.receipts.push({entry:s,tab:e,turnId:r})}mt?.(e)}var F=new WeakMap;function Zd(e,t){if(t)F.set(e,t);else F.delete(e)}function pM(e){let t=F.get(e);return t?t.canUndo(e):e.history.index>0||M.has(e)}function fM(e){let t=F.get(e);return t?t.canRedo(e):!M.has(e)&&e.history.index<e.history.snapshots.length-1}function ht(e,t){let{snapshots:o}=e.history;e.doc.document=ke(o,t);let r=o[t];e.session.selection=Ia(le(r.selection))}function xt(e,t){try{if(typeof localStorage>"u"||!localStorage.getItem("jx-canvas-debug"))return}catch{return}let o=JSON.stringify(ke(e.history.snapshots,t)),r=JSON.stringify(ir(le(e.doc.document)));if(o!==r)console.error("jx history: ops-based undo/redo diverged from checkpoint replay",{index:t})}function t1(e){je(e,null);let t=F.get(e);if(t){t.undo(e);return}if(e.history.index<=0)return;let o=e.history.snapshots[e.history.index],r=ne()?o.inverseOps:null,i=ne()?o.fmOps:null;if(r&&r.length>0||i&&i.length>0){if(!Z(e,(a)=>{if(r)for(let l=r.length-1;l>=0;l--)xe(a,le(r[l]));if(i)for(let l=i.length-1;l>=0;l--){let c=le(i[l]);Ee(a,c.field,c.before)}},{origin:"history",skipHistory:!0}))return;e.session.selection=Ia(le(o.selectionBefore??[])),e.history.index-=1,xt(e,e.history.index)}else e.history.index-=1,ht(e,e.history.index);e.doc.dirty=!0}function mM(e){je(e,null);let t=F.get(e);if(t){t.redo(e);return}if(e.history.index>=e.history.snapshots.length-1)return;let o=e.history.snapshots[e.history.index+1],r=ne()?o.forwardOps:null,i=ne()?o.fmOps:null;if(r&&r.length>0||i&&i.length>0){if(!Z(e,(a)=>{if(r)for(let l of r)xe(a,le(l));if(i)for(let l of i){let c=le(l);Ee(a,c.field,c.after)}},{origin:"history",skipHistory:!0}))return;e.session.selection=Ia(le(o.selection)),e.history.index+=1,xt(e,e.history.index)}else e.history.index+=1,ht(e,e.history.index);e.doc.dirty=!0}function or(e,t,o,r){let i=oe(e.doc.document,t);if(!i)return;let s=Ov(i),a=df(o,s.length);s.splice(a,0,structuredClone(r)),y({index:a,op:"insert",parentPath:t}),Bi({forward:{index:a,node:Ce(r),op:"insert-child",parentPath:t},inverse:{index:a,op:"remove-child",parentPath:t}})}function _h(e,t){let o=uf(t);if(!o)return;let{index:r,parentPath:i}=o,[s]=S(e.doc.document,i).children.splice(r,1);y({op:"remove",path:t}),Bi({forward:{index:r,op:"remove-child",parentPath:i},inverse:{index:r,node:Ce(s),op:"insert-child",parentPath:i}}),e.session.selection=ye(e.session.selection,t)}function vI(e,t){let o=uf(t);if(!o)return;let r=oe(e.doc.document,t);if(!r)return;let{index:i,parentPath:s}=o,a=structuredClone(le(r));S(e.doc.document,s).children.splice(i+1,0,a),y({index:i+1,op:"insert",parentPath:s}),Bi({forward:{index:i+1,node:Ce(a),op:"insert-child",parentPath:s},inverse:{index:i+1,op:"remove-child",parentPath:s}}),e.session.selection=[[...s,"children",i+1]]}function Ym(e,t){for(let o of sg(t))_h(e,o)}function n0(e,t){let o=[];for(let r of sg(t)){let i=e.session.selection;vI(e,r);let s=Oe(e.session.selection),a=uf(s);if(!s||!a||e.session.selection===i)continue;o=o.map((l)=>h1(a.parentPath,l,a.index,1,!0)),o.unshift(s)}if(o.length>0)e.session.selection=o}function gM(e,t,o="div"){let r=uf(t);if(!r)return;let i=oe(e.doc.document,t);if(!i)return;let{index:s,parentPath:a}=r,l={children:[structuredClone(le(i))],tagName:o},c=Ce(i);S(e.doc.document,a).children.splice(s,1,l),y({op:"replace",path:t}),Bi({forward:{index:s,node:Ce(l),op:"set-child",parentPath:a},inverse:{index:s,node:c,op:"set-child",parentPath:a}}),e.session.selection=[[...a,"children",s]]}function Kp(e,t,o,r){let i=e.doc.document,s=d0(i,t,o,r);if(!s)return;let{forward:a,inverse:l}=s,c=oe(i,a.fromParentPath),u=oe(i,o),[d]=c.children.splice(a.fromIndex,1);if(Ov(u).splice(a.toIndex,0,d),y({fromPath:t,op:"move",toIndex:a.toIndex,toParentPath:o}),Bi({forward:a,inverse:l}),Cr(Oe(e.session.selection),t))e.session.selection=[[...l.fromParentPath,"children",l.fromIndex]]}function Qe(e,t,o,r){let i=oe(e.doc.document,t);if(!i)return;let s=i[o],a=Ce(s);if(r===void 0||r===null||r==="")delete i[o];else i[o]=r;if(Bi(P(t,o,a,Ce(i[o]))),o==="children")e.session.selection=ye(e.session.selection,[...t,"children"]);if(o==="textContent")y({op:"set-text",path:t});else if(o==="style")y({op:"set-style",path:t});else{let l=r===void 0||r===null||r===""?s:r,c=o.startsWith("on")&&xf(l);y({isEvent:c,key:o,op:"set-prop",path:t})}}function Zm(e,t,o,r){let i=S(e.doc.document,t),s=Ce(i.style);if(!i.style)i.style={};if(r===void 0||r==="")delete i.style[o];else i.style[o]=r;if(Object.keys(i.style).length===0)delete i.style;Bi(P(t,"style",s,Ce(i.style))),y({op:"set-style",path:t})}function _r(e,t,o,r){let i=S(e.doc.document,t),s=Ce(i.attributes);if(!i.attributes)i.attributes={};if(r===void 0||r==="")delete i.attributes[o];else i.attributes[o]=r;if(Object.keys(i.attributes).length===0)delete i.attributes;Bi(P(t,"attributes",s,Ce(i.attributes))),y({attr:o,op:"set-attr",path:t})}function bM(e,t,o,r,i){if(!o)return Zm(e,t,r,i);let s=S(e.doc.document,t),a=Ce(s.style);if(!s.style)s.style={};let l=`@${o}`,c=ld(s.style,l);if(i===void 0||i===""){if(delete c[r],Object.keys(c).length===0)delete s.style[l]}else c[r]=i;if(Object.keys(s.style).length===0)delete s.style;Bi(P(t,"style",a,Ce(s.style))),y({op:"set-style",path:t})}function i0(e,t,o,r,i){let s=S(e.doc.document,t),a=Ce(s.style);if(!s.style)s.style={};let l=ld(s.style,o);if(i===void 0||i===""){if(delete l[r],Object.keys(l).length===0)delete s.style[o]}else l[r]=i;if(Object.keys(s.style).length===0)delete s.style;Bi(P(t,"style",a,Ce(s.style))),y({op:"set-style",path:t})}function vM(e,t,o,r,i,s){let a=S(e.doc.document,t),l=Ce(a.style);if(!a.style)a.style={};let c=`@${o}`,u=ld(a.style,c),d=ld(u,r);if(s===void 0||s===""){if(delete d[i],Object.keys(d).length===0)delete u[r];if(Object.keys(u).length===0)delete a.style[c]}else d[i]=s;if(Object.keys(a.style).length===0)delete a.style;Bi(P(t,"style",l,Ce(a.style))),y({op:"set-style",path:t})}function Tt(e,t){let o=[e];for(let r of t){let i=Di(o.at(-1),r);if(!i)break;o.push(i)}for(let r=o.length-2;r>=0;r--){let i=o[r],s=t[r],a=Di(i,s);if(a&&Object.keys(a).length===0)delete i[s]}}function o0(e,t,o,r,i){let s=S(e.doc.document,t),a=Ce(s.style);if(!s.style)s.style={};let l=s.style;for(let c of o)l=ld(l,c);if(i===void 0||i==="")delete l[r],Tt(s.style,o);else l[r]=i;if(Object.keys(s.style).length===0)delete s.style;Bi(P(t,"style",a,Ce(s.style))),y({op:"set-style",path:t})}function yM(e,t,o,r,i,s){let a=S(e.doc.document,t),l=Ce(a.style);if(!a.style)a.style={};let c=`@${o}`,u=ld(a.style,c),d=u;for(let f of r)d=ld(d,f);if(s===void 0||s===""){if(delete d[i],Tt(u,r),Object.keys(u).length===0)delete a.style[c]}else d[i]=s;if(Object.keys(a.style).length===0)delete a.style;Bi(P(t,"style",l,Ce(a.style))),y({op:"set-style",path:t})}function wM(e,t,o){let r=S(e.doc.document,t),i=Ce(r.style);if(o&&Object.keys(o).length>0)r.style=o;else delete r.style;Bi(P(t,"style",i,Ce(r.style))),y({op:"set-style",path:t})}function Xd(e,t,o){let r=e.doc.document,i=Ce(r.state);if(!r.state)r.state={};r.state[t]=o,Bi(P([],"state",i,Ce(r.state))),y({key:"state",op:"doc-meta"})}function xM(e,t){let o=e.doc.document;if(o.state){let r=Ce(o.state);if(delete o.state[t],Object.keys(o.state).length===0)delete o.state;Bi(P([],"state",r,Ce(o.state))),y({key:"state",op:"doc-meta"})}}function Ur(e,t,o){let r=e.doc.document,i=Ce(r.state);if(!r.state)r.state={};let s=r.state[t],a=s==null?{}:!_(s)||Array.isArray(s)?{default:s}:s;r.state[t]=a,Object.assign(a,o);for(let l of Object.keys(a))if(a[l]===void 0||a[l]===null)delete a[l];Bi(P([],"state",i,Ce(r.state))),y({key:"state",op:"doc-meta"})}function _M(e,t,o){let r=e.doc.document;if(!r.state||!r.state[t])return;let i=Ce(r.state);r.state[o]=r.state[t],delete r.state[t],Bi(P([],"state",i,Ce(r.state))),y({key:"state",op:"doc-meta"})}function Jp(e,t,o,r){let i=S(e.doc.document,t),s=Ce(i.$props);if(!i.$props)i.$props={};if(r===void 0||r===null||r==="")delete i.$props[o];else i.$props[o]=r;if(Object.keys(i.$props).length===0)delete i.$props;Bi(P(t,"$props",s,Ce(i.$props))),y({op:"replace",path:t})}function SM(e,t,o,r){let i=S(e.doc.document,t),s=Ce(i.cases);if(!i.cases)i.cases={};i.cases[o]=r||{tagName:"div",textContent:o},Bi(P(t,"cases",s,Ce(i.cases))),y({op:"replace",path:t})}function CM(e,t,o){let r=S(e.doc.document,t);if(r.cases){let i=Ce(r.cases);delete r.cases[o],Bi(P(t,"cases",i,Ce(r.cases))),y({op:"replace",path:t})}}function kM(e,t,o,r){let i=S(e.doc.document,t);if(!i.cases||!i.cases[o])return;let s=Ce(i.cases);i.cases[r]=i.cases[o],delete i.cases[o],Bi(P(t,"cases",s,Ce(i.cases))),y({op:"replace",path:t})}function Qd(e,t,o){let r=e.doc.content.frontmatter,i=Object.hasOwn(r,t)?Ce(r[t]):void 0,s=o===void 0||o===null||o==="";if(s)delete r[t];else r[t]=o;let a=s?void 0:Ce(o);at({after:a,before:i,field:t}),e.doc.dirty=!0}function Ee(e,t,o){if(o===void 0)delete e.doc.content.frontmatter[t];else e.doc.content.frontmatter[t]=o}var W=[],Dn=50;function EM(e){return Object.assign(Ux(),{turnId:e})}function TM(e,t,o=[]){if(t.length===0)return[];let r={batches:[...o],id:e,writes:[...t]};W.push(r);while(W.length>Dn)W.shift();return r.writes}function LM(e){return W.find((t)=>t.id===e)?.writes??[]}function $M(e){let t=W.find((s)=>s.id===e),o="There is no longer a record of what that turn changed.";if(!t)return"There is no longer a record of what that turn changed.";let r=t.writes.filter((s)=>s.disk).map((s)=>s.path);if(r.length>0)return`Cannot restore: ${r.join(", ")} ${r.length===1?"was":"were"} written straight to disk, which undo cannot reach.`;if(t.batches.length===0)return"There is no longer a record of what that turn changed.";let i=new Map;for(let s of t.batches)i.set(s.tab,[...i.get(s.tab)??[],s]);for(let[s,a]of i){let l=En(s,a);if(l)return l}for(let[s,a]of i)for(let l of a)t1(s);return[...i.keys()]}function En(e,t){let o=e.documentPath??"(untitled)";if(e.scope.active===!1)return`Cannot restore: ${o} was closed after that turn.`;if(t.some((l)=>l.entry===null))return`Cannot restore: ${o} is shared live, and Restore cannot check its undo history. Undo it in the document instead.`;let{index:r,snapshots:i}=e.history,s=i.slice(r-t.length+1,r+1);if(r-t.length>=0&&t.every((l,c)=>s[c]===l.entry))return null;return i.indexOf(t.at(-1).entry)>r?`Cannot restore: that turn's change to ${o} was already undone.`:`Cannot restore: ${o} has edits made since that turn began, which Restore would undo too.`}function IM(e){let t=e.filter((l)=>l.ok),o=new Set(t.map((l)=>l.path)),r=e.length-t.length;if(o.size===0)return r>0?`${r} change${r===1?"":"s"} failed`:"";let i=`Changed ${o.size} file${o.size===1?"":"s"}`,s=new Set(t.flatMap((l)=>l.disk?[l.path]:[])),a=[i];if(s.size>0)a.push(`${s.size} written to disk — undo cannot reach ${s.size===1?"it":"them"}`);if(r>0)a.push(`${r} failed`);return a.join(" · ")}function n1(){W.splice(0)}function RM(e,t){let o=null;for(let r=e.length-1;r>=0;r--){let i=e[r];if(i.id===t)return o;let s=i.role==="assistant"&&(i.content||(i.toolCalls?.length??0)>0);if(o===null&&s)o=i.id}return t===void 0?o:null}function Gm(e){let t=new Set,o=new Set;return $v(e,(r,i)=>{t.add(r),o.add(JSON.stringify(i))}),t.size===0?null:{fingerprints:o,pointers:t}}function KO(e,t){if(!t)return e;return Me(e,"",t)}function Me(e,t,o){if(Array.isArray(e)){let i=null;for(let[s,a]of e.entries()){let l=Me(a,`${t}/${s}`,o);if(l!==a)i??=[...e],i[s]=l}return i??e}if(!v(e))return e;let r=null;for(let[i,s]of Object.entries(e)){let a=Me(s,`${t}/${LI(i)}`,o);if(i==="children"&&Array.isArray(a)&&a.length===1){let[l]=a;if(Go(l)&&(o.pointers.has(t)||o.fingerprints.has(JSON.stringify(l))))a=l}if(a!==s)r??={...e},r[i]=a}return r??e}var JC=["design","content","media","styles","publish","settings"],Up="design",vt=[{icon:"frame-corners",id:"design",switcher:!0,title:"Design"},{icon:"file-text",id:"content",switcher:!0,title:"Content"},{icon:"image",id:"media",switcher:!0,title:"Media"},{icon:"paint-brush",id:"styles",switcher:!0,title:"Styles"},{icon:"paper-plane-tilt",id:"publish",switcher:!0,title:"Publish"},{icon:"gear-six",id:"settings",switcher:!1,title:"Project settings"}],Hx=vt.filter((e)=>e.switcher);function aI(e){return typeof e==="string"&&JC.some((t)=>t===e)}function bh(e){return vt.find((t)=>t.id===e)}var $e="workspace://",Bx={content:"content-home",media:"media-home",publish:"publish-home",settings:"settings-home"};function qp(e){return Object.hasOwn(Bx,e)}function $a(e){return`${$e}${e}`}function ml(e){if(!e.startsWith($e))return null;let t=e.slice($e.length);return aI(t)&&qp(t)?t:null}function gv(e){let t=ml(e);return t?bh(t).title:null}var Mn=new Map([["design","canvas"],["edit","canvas"],["entry","entry"],["git-diff","diff"],["grid","grid"],["content-home","home"],["media-home","home"],["publish-home","home"],["settings-home","home"],["media","media"],["image","image"],["preview","canvas"],["source","code"],["stylebook","config"],["tokens","tokens"]]),Gp={canvas:"Canvas",code:"Code",config:"Elements",diff:"Diff",entry:"Entry",grid:"Grid",home:"Home",image:"Image",media:"Media",none:"None",tokens:"Variables"};function Qs(e){return Mn.get(e)??"canvas"}var $n=new Map([["design","design"],["edit","edit"],["preview","preview"]]);function UO(e){return $n.get(e)??"design"}var zx=(e)=>e.editor.kind==="canvas",vh=(e)=>zx(e)&&e.selection.count>0,Wx=(e)=>vh(e)&&!e.selection.isRoot;function bv(){return{project:{open:!1,isSite:!1,isRepo:!1,isMultilingual:!1},git:{ahead:0,behind:0,dirtyCount:0},workspace:{id:Up},document:{open:!1,dirty:!1,mode:"",canUndo:!1,canRedo:!1},editor:{kind:"none"},canvas:{view:"design"},pane:{count:1,derived:!1},selection:{count:0,paths:[],kind:"",isRoot:!1,isComponentInstance:!1,isLayoutNode:!1,isRepeater:!1},caret:{active:!1,inCanvas:!1},focus:{region:"pane"},modal:{open:!1},collab:{attached:!1,readOnly:!1,sourceCanonical:!1},ai:{configured:!1,streaming:!1,waiting:!1},capability:{gitClone:!1,importSite:!1,openProjectInNewWindow:!1,openProject:!1,dataRows:!1,windowControls:!1,findReferences:!1,readFileBytes:!1,publish:!1}}}function YC(e={}){let t=bv();for(let o of Object.keys(e)){let r=e[o];if(r)Object.assign(t[o],r)}return t}var Ln=["palette"],Nn=["caret","global"],_n=["dock","global"],Fn=["canvas","global"],Vn=["grid","global"],Wn=["code","global"],Ot=["global"];function qO(e){if(e.modal.open)return Ln;if(e.caret.active)return Nn;if(e.focus.region!=="pane")return _n;switch(e.editor.kind){case"grid":return Vn;case"code":return Wn;case"canvas":return e.canvas.view==="preview"?Ot:Fn;default:return Ot}}var an="project.json";function Bn(e,t=!1){return{activeMedia:null,activeSelector:null,openPopover:null,openDialog:null,canvasMode:e,editZoom:1,editingFormula:null,editingFunction:null,featureToggles:{},inspectorSections:{},pendingInlineEdit:null,preview:t,previewColorScheme:"auto",previewLocale:null,previewParams:{},previewProps:null,rightTab:"page",elementTab:"properties",showLayout:!0,styleFilter:"",styleSections:{},dataRows:{},dataLimits:{},styleShorthands:{},zoom:1}}var Kn=["edit","design","preview","source","stylebook","git-diff"];function yv({id:e,documentPath:t=null,fileHandle:o=null,document:r,frontmatter:i,sourceFormat:s=null,capabilities:a,openedFrom:l=null,preview:c=!1,layout:u=null,source:d=null,canvasMode:f}){let x=me(),k=Gm(r),j=a?.modes??Un(t,s),A=f??j.find((b)=>b!=="preview")??"edit",ue=j[0]==="preview",E={bareRepeaters:k,content:{frontmatter:i||{}},dirty:!1,document:r,handlersSource:null,layout:u,mode:zn(t,s),source:d,sourceFormat:s},de={index:0,snapshots:[{document:structuredClone(r),selection:[]}]},U={canvas:{refreshing:!1,error:null,livePreviews:null,pendingInlineEdit:null,scope:null,status:"idle"},clipboard:null,hover:null,openedFrom:l,selection:[],ui:Bn(A,ue)};return x.run(()=>({capabilities:{modes:j},doc:g(E),documentPath:t,fileHandle:o,history:g(de),id:e,pinned:!1,preview:c,scope:x,session:g(U)}))}function Un(e,t){if(e===an)return["stylebook","tokens","source"];let o=Wi(t)??fn(e);if(o)return o.studio?.modes??["edit","design","preview","source"];return Kn}function zn(e,t){let o=Wi(t)??fn(e);if(o)return o.studio?.documentMode?.default??"content";return"component"}function XC(e){return Qs(e.session.ui.canvasMode)}function dI(e){let t=[];for(let o of e.capabilities.modes){if(o==="preview")continue;let r=Qs(o);if(!t.includes(r))t.push(r)}return t}function JO(e,t){return e.capabilities.modes.find((o)=>o!=="preview"&&Qs(o)===t)}function Km(e){e.scope.stop()}var Pt=new WeakMap,B=new Map;function xn(e){let t=le(e),o=Pt.get(t);if(!o)o=g({active:!1,attachError:"",peers:[],readOnly:!1,sourceCanonical:!1,status:"unavailable"}),Pt.set(t,o);return o}function wt(e){B.set(e,(B.get(e)??0)+1)}function Ct(e){let t=B.get(e)??0;if(t<=1)B.delete(e);else B.set(e,t-1)}function wv(e){return B.has(e.replaceAll("\\","/"))}var Yn=8000,Zn=800,Xn=2500,Rt=null;function Qn(){return Rt??=(ce("f9qr7kzh"),import("./index-f9qr7kzh.js")),Rt}function Jt(){try{return p()}catch{return null}}var H=null;function QO(e){H=e}var Ne=null;function eM(e){Ne=e}var It=()=>{};function tM(e){It=e??(()=>{})}var _e=new WeakMap;function kt(e){return le(e)}function Ve(e,t){return e.frontmatterMap(t)}function eo(e){return e.synced}function D(e){return _e.get(kt(e))}function He(e){let t=kt(e),o=_e.get(t);if(!o)o={attaching:null,generation:0,optedOut:g({value:!1}),session:null,watcherInstalled:!1},_e.set(t,o);return o}var At=!1;function to(){if(At)return;At=!0,ut(no),gt(oo),ft((e)=>{if(D(e)?.session?.synced&&xn(e).sourceCanonical)return It("Source editing in progress — structural edits are paused"),"source-canonical";return null})}function no(e,t,o){let r=D(e)?.session;if(!r||!r.synced)return;if(r.lastSeenRef=le(e.doc.document),o==="remote"){Te(r);return}if(r.canWrite)ro(r,t),Te(r)}function oo(e){let t=D(e)?.session;if(!t?.synced||t.batchOps===null)return;let{batchOps:o,batchNeedsDiff:r}=t;if(t.batchOps=null,t.batchNeedsDiff=!1,!t.canWrite)return;if(t.undoManager?.stopCapturing(),r)re(t);else if(o.length>0)try{t.collab.applyDocOpsToY(t.handle.doc,o,t.collab.LOCAL_ORIGIN)}catch{re(t)}t.undoManager?.stopCapturing()}function ro(e,t){let o=t.docOps.map((r)=>r.forward);if(yt(e.tab)){if(e.batchOps??=[],o.length===0)e.batchNeedsDiff=!0;else e.batchOps.push(...o);return}if(o.length===0){re(e);return}try{e.collab.applyDocOpsToY(e.handle.doc,o,e.collab.LOCAL_ORIGIN)}catch{re(e)}}function re(e){let{collab:t,handle:o,tab:r}=e,i=t.yDocToJson(o.doc),s=ir(le(r.doc.document)),a=t.diffDocs(i,s);if(a===null)t.replaceYStructure(o.doc,s,t.LOCAL_ORIGIN);else if(a.length>0)try{t.applyDocOpsToY(o.doc,a,t.LOCAL_ORIGIN)}catch{t.replaceYStructure(o.doc,s,t.LOCAL_ORIGIN)}}function Le(e){let t=e.collab.yDocToJson(e.handle.doc);Z(e.tab,(o)=>{let r=o.doc.document;for(let i of Object.keys(r))if(!(i in t))delete r[i];Object.assign(r,t)},{origin:"remote",skipHistory:!0})}function io(e){if(!e.canWrite)return!1;let{awareness:t}=e.handle,o=t.clientID;for(let[r,i]of t.getStates())if(i.canWrite!==!1&&r<o)o=r;return o===e.handle.awareness.clientID}function Te(e){if(!H||!io(e))return;if(e.collab.canonicalOf(e.handle.doc)==="source")return;let t=Date.now();if(e.lastMirrorAt??=t,t-e.lastMirrorAt>=Xn){if(e.mirrorTimer)clearTimeout(e.mirrorTimer),e.mirrorTimer=null;e.lastMirrorAt=t,We(e);return}if(e.mirrorTimer)clearTimeout(e.mirrorTimer);e.mirrorTimer=setTimeout(()=>{e.mirrorTimer=null,e.lastMirrorAt=Date.now(),We(e)},Zn)}async function We(e){if(!H||!e.synced)return;try{let t=await H(e.tab);e.collab.updateSourceText(e.handle.doc,t,e.collab.MIRROR_ORIGIN)}catch{}}async function Dt(e){if(!Ne||!e.synced||!e.canWrite)return;let{collab:t,handle:o,tab:r}=e,i=t.canonicalRevOf(o.doc),s=t.sourceText(o.doc).toString(),a;try{a=await Ne(r,s)}catch{return}if(!eo(e)||t.canonicalRevOf(o.doc)!==i)return;let l=t.diffDocs(t.yDocToJson(o.doc),a.document);if(l===null)t.replaceYStructure(o.doc,a.document,t.MIRROR_ORIGIN);else if(l.length>0)try{t.applyDocOpsToY(o.doc,l,t.MIRROR_ORIGIN)}catch{t.replaceYStructure(o.doc,a.document,t.MIRROR_ORIGIN)}let c=Ve(t,o.doc),u=a.frontmatter??{};o.doc.transact(()=>{let d=[...c.keys()];for(let f of d)if(!(f in u))c.delete(f);for(let[f,x]of Object.entries(u))if(!t.deepEqual(c.get(f),x))c.set(f,x)},t.MIRROR_ORIGIN)}function nM(e){let t=D(e)?.session;if(!t?.synced)return null;let{collab:o,handle:r}=t,i=null,s=()=>i!==null&&t.sourceLockOwner===i;return{awareness:r.awareness,enter:async()=>{i={},t.sourceLockOwner=i;let a=r.awareness.getLocalState();if(a)r.awareness.setLocalState({...a,mode:"source"});if(!t.canWrite)return;let l=null;if(H)try{l=await H(e)}catch{l=null}if(!s())return;o.acquireSourceCanonical(r.doc,l??o.sourceText(r.doc).toString(),o.LOCAL_ORIGIN)},leave:()=>{if(!s()){i=null;return}i=null,t.sourceLockOwner=null;let a=r.awareness.getLocalState();if(a)r.awareness.setLocalState({...a,mode:"structure"});if(!t.canWrite)return;if(o.otherSourceEditors(r.awareness,t.path,r.awareness.clientID).filter((c)=>r.awareness.getStates().get(c)?.canWrite!==!1).length===0)Dt(t).then(()=>{o.releaseSourceCanonical(r.doc,o.LOCAL_ORIGIN)})},localOrigin:o.LOCAL_ORIGIN,readOnly:!t.canWrite,text:o.sourceText(r.doc)}}function ea(e){let t=xn(e);return t.active&&t.readOnly}async function uI(e){let t=D(e)?.session;if(!t?.synced||!t.canWrite)return!1;if(t.mirrorTimer)clearTimeout(t.mirrorTimer),t.mirrorTimer=null;return await We(t),await t.handle.flush(),!0}async function iM(){for(let e of Be)if(D(e)?.session?.synced)await uI(e)}var Be=new Set;function ie(e){if(!Jt()?.collab||!e.documentPath||e.documentPath===an)return;let o=He(e);if(o.watcherInstalled)return;o.watcherInstalled=!0,to(),Be.add(e),e.scope.run(()=>{te(()=>{if(o.optedOut.value)ve(e);else Ke(e)}),ia(()=>{Be.delete(e),ve(e)})})}function hI(e,t){let o=He(e);if(o.optedOut.value===!t)return;if(o.optedOut.value=!t,!o.watcherInstalled&&t)ie(e)}function pI(e){return D(e)?.optedOut.value!==!0}function jt(e){if(!D(e)?.watcherInstalled){ie(e);return}ve(e),Ke(e)}async function Ke(e){let t=He(e);if(t.session||t.attaching)return;let{documentPath:o}=e,r=Jt();if(!o||!r?.collab){xn(e).status="unavailable";return}let{generation:i}=t,s=xn(e);s.status="connecting",s.attachError="";let a=(async()=>{try{let[l,c]=await Promise.all([Qn(),r.collab(o)]);if(!c){s.status="detached";return}if(t.generation!==i){c.destroy();return}let u,d=new Promise((f,x)=>{u=setTimeout(()=>x(Error("collab-sync-timeout")),Yn)});try{await Promise.race([c.whenSynced,d])}finally{clearTimeout(u)}if(t.generation!==i){c.destroy();return}t.session=so(e,o,l,c),s.active=!0,s.status="synced",s.readOnly=!t.session.canWrite,s.attachError="",wt(o)}catch(l){s.status="failed",s.active=!1,s.attachError=l instanceof Error?l.message:String(l),w.warn(`Live collaboration is not available for "${o}" — ${s.attachError}`,{key:`collab:${o}`,path:o,source:"Collaboration"})}finally{t.attaching=null}})();t.attaching=a,await a}function ve(e){let t=D(e);if(!t)return;t.generation+=1;let{session:o}=t;t.session=null;let r=xn(e);if(r.active=!1,r.status="detached",r.attachError="",r.peers=[],!o)return;if(Ct(o.path),o.mirrorTimer)clearTimeout(o.mirrorTimer);if(o.sourceParseTimer)clearTimeout(o.sourceParseTimer);for(let i of o.disposers)try{i()}catch{}Zd(e,null),e.history.snapshots=[{document:ir(le(e.doc.document)),selection:Ia(e.session.selection)}],e.history.index=0,o.undoManager?.destroy(),o.handle.destroy()}function so(e,t,o,r){let i=r.identity(),s={applyingRemoteFrontmatter:!1,batchNeedsDiff:!1,batchOps:null,canWrite:i?i.permission!=="read":!0,collab:o,disposers:[],handle:r,lastSeenRef:le(e.doc.document),mirrorTimer:null,path:t,sourceLockOwner:null,sourceParseTimer:null,synced:!1,tab:e,undoManager:null};if(o.metaMap(r.doc).get("structureSeeded")===!0){let b=o.yDocToJson(r.doc),T=ir(le(e.doc.document));if(!o.deepEqual(b,T)){let J=o.diffDocs(T,b);if(J===null)s.synced=!0,Le(s),s.synced=!1;else if(J.length>0)De(e,J)}s.applyingRemoteFrontmatter=!0;let O=Ve(o,r.doc);for(let[J,N]of O.entries())e.doc.content.frontmatter[J]=N;s.applyingRemoteFrontmatter=!1}else if(s.canWrite)o.seedStructure(r.doc,ir(le(e.doc.document)),{frontmatter:ir(le(e.doc.content.frontmatter)),origin:o.SEED_ORIGIN,sourceFormat:e.doc.sourceFormat});s.lastSeenRef=le(e.doc.document),s.disposers.push(r.onDirty((b)=>{e.doc.dirty=b})),r.awareness.setLocalState({canWrite:s.canWrite,focusedPath:t,structuralSelection:null,user:i?{avatarUrl:i.avatarUrl,color:i.color,login:i.login,name:i.name}:{color:o.colorForKey(String(r.awareness.clientID)),login:`guest-${r.awareness.clientID%1000}`}});let l=new o.UndoManager([o.structureMap(r.doc),o.frontmatterMap(r.doc)],{trackedOrigins:new Set([o.LOCAL_ORIGIN])});s.undoManager=l;let c=({stackItem:b})=>{b.meta.set("selection",Ia(e.session.selection))},u=({stackItem:b})=>{let T=b.meta.get("selection");e.session.selection=Ia(T??[])};l.on("stack-item-added",c),l.on("stack-item-popped",u),s.disposers.push(()=>{l.off("stack-item-added",c),l.off("stack-item-popped",u)}),Zd(e,{canRedo:()=>l.canRedo(),canUndo:()=>l.canUndo(),redo:()=>{l.redo()},undo:()=>{l.undo()}});let d=o.structureMap(r.doc),f=(b,T)=>{if(T.origin===o.LOCAL_ORIGIN||!s.synced)return;let O=o.yEventsToDocOps(b);if(O===null){Le(s);return}if(O.length===0)return;try{De(e,O)}catch{Le(s)}};d.observeDeep(f),s.disposers.push(()=>d.unobserveDeep(f));let x=xn(e);x.sourceCanonical=o.canonicalOf(r.doc)==="source";let k=o.metaMap(r.doc),j=()=>{x.sourceCanonical=o.canonicalOf(r.doc)==="source"};k.observe(j),s.disposers.push(()=>k.unobserve(j));let A=o.sourceText(r.doc),ue=(b,T)=>{if(T.origin===o.MIRROR_ORIGIN||!s.synced)return;if(o.canonicalOf(r.doc)!=="source")return;if(!o.isSourceReconciler(r.awareness,s.path))return;if(s.sourceParseTimer)clearTimeout(s.sourceParseTimer);s.sourceParseTimer=setTimeout(()=>{s.sourceParseTimer=null,Dt(s)},600)};A.observe(ue),s.disposers.push(()=>A.unobserve(ue));let E=Ve(o,r.doc),de=(b,T)=>{if(T.origin===o.LOCAL_ORIGIN||!s.synced)return;s.applyingRemoteFrontmatter=!0;try{for(let[O,J]of b.changes.keys)if(J.action==="delete")delete e.doc.content.frontmatter[O];else e.doc.content.frontmatter[O]=E.get(O)}finally{s.applyingRemoteFrontmatter=!1}};E.observe(de),s.disposers.push(()=>E.unobserve(de)),e.scope.run(()=>{let b=JSON.stringify(e.doc.content.frontmatter);te(()=>{let T=JSON.stringify(e.doc.content.frontmatter);if(T===b)return;if(b=T,s.applyingRemoteFrontmatter||!s.synced||!s.canWrite)return;let O=JSON.parse(T);r.doc.transact(()=>{let J=[...E.keys()];for(let N of J)if(!(N in O))E.delete(N);for(let[N,Ge]of Object.entries(O))if(!o.deepEqual(E.get(N),Ge))E.set(N,Ge)},o.LOCAL_ORIGIN),Te(s)}),te(()=>{let T=e.session.selection.length>0?Ia(e.session.selection):null,O=r.awareness.getLocalState();if(O)r.awareness.setLocalState({...O,structuralSelection:T})}),te(()=>{let T=le(e.doc.document);queueMicrotask(()=>{if(D(e)?.session!==s||!s.synced||!s.canWrite)return;let J=le(e.doc.document);if(J!==T||J===s.lastSeenRef)return;s.lastSeenRef=J,re(s),Te(s)})})});let U=xn(e),fe=()=>{let b=[];for(let[T,O]of r.awareness.getStates())if(T!==r.awareness.clientID&&O.user)b.push({clientId:T,state:O});U.peers=b};return fe(),r.awareness.on("change",fe),s.disposers.push(()=>r.awareness.off("change",fe),r.onStatus((b)=>{if(b==="offline"||b==="connecting")U.status="offline";else if(s.synced)U.status="synced"}),r.onReset(()=>{ve(e),Ke(e)})),s.synced=!0,s}function I(e,t,o){return RangeError(`command "${e}" argument "${t}": ${o}`)}function ao(e){if(Y(e))return"number";if(Ze(e))return"boolean";return n(e)?"string":"object"}function R(e){if(e===void 0)return"missing";return n(e)?`"${e}"`:`${ao(e)} ${JSON.stringify(e)}`}function Mt(e){return Array.isArray(e)&&e.every((t)=>n(t)||Y(t))}function St(e,t,o){let r=t[o];if(!n(r)||r==="")throw I(e,o,`expected a non-empty string, got ${R(r)}`);return r}function ti(e,t,o){if(t[o]===void 0)return;return St(e,t,o)}function $t(e,t,o){let r=t[o];if(!Y(r)||!Number.isFinite(r))throw I(e,o,`expected a finite number, got ${R(r)}`);return r}function Et(e,t,o){let r=t[o];if(!Y(r)||!Number.isInteger(r))throw I(e,o,`expected an integer, got ${R(r)}`);return r}function Zx(e,t,o,r,i){let s=$t(e,t,o);if(s<r||s>i)throw I(e,o,`${s} is outside the supported range ${r}–${i}`);return s}function Hi(e,t,o){let r=t[o];if(!Ze(r))throw I(e,o,`expected a boolean, got ${R(r)}`);return r}function qn(e,t,o,r){let i=t[o],s=n(i)?r.find((a)=>a===i):void 0;if(s===void 0)throw I(e,o,`${R(i)} is not declared — declared: ${r.join(", ")||"none"}`);return s}function QC(e,t,o){let r=t[o];if(!Mt(r))throw I(e,o,`expected an array of path segments (strings or numbers), got ${R(r)}`);return r}function oM(e,t,o){if(t[o]===null)return null;return QC(e,t,o)}function mI(e,t,o){let r=t[o];if(!Array.isArray(r))throw I(e,o,`expected an array of document paths, got ${R(r)}`);return r.map((i,s)=>{if(!Mt(i))throw I(e,o,`entry ${s} is not a document path — expected an array of segments, got ${R(i)}`);return i})}function Se(e,t=Object.keys(e)){return{additionalProperties:!1,properties:e,required:[...t],type:"object"}}function pi(e,t){return{description:t,enum:[...e],type:"string"}}function gl(e,t){return{description:t,get enum(){return[...e()]},type:"string"}}function gI(e,t={}){return{description:e,type:"number",...t}}function To(e){return{description:e,type:"boolean"}}function Xx(e,t=!1){let o={items:{type:["string","number"]},type:"array"};return t?{description:e,oneOf:[o,{type:"null"}]}:{description:e,...o}}function rM(e){return{description:e,items:{items:{type:["string","number"]},type:"array"},type:"array"}}function Fe(e){return{description:e,type:"string"}}function lo(e){return e.length===2&&e.includes("string")&&e.includes("number")}function Ue(e){return n(e)?[e]:e}function Lt(e){let t=e;if("enum"in t)return"enum";if("const"in t)return"const";if(Array.isArray(t.oneOf))return"one-of";if(Array.isArray(t.type))return"typed";switch(t.type){case"boolean":return"boolean";case"number":case"integer":{if(t.minimum!==void 0&&t.maximum!==void 0)return"bounded-number";return t.type==="integer"?"integer":"number"}case"string":return"string";case"array":{let o=t.items?.type;if(Array.isArray(o))return lo(o)?"path":"pass-through";return o==="array"?"path-list":"pass-through"}case"null":case"object":return"typed";default:break}return"pass-through"}function Nt(e,t){switch(e){case"null":return t===null;case"boolean":return Ze(t);case"string":return n(t);case"number":return Y(t)&&Number.isFinite(t);case"integer":return Y(t)&&Number.isInteger(t);case"array":return Array.isArray(t);case"object":return _(t)&&!Array.isArray(t);default:break}return!1}function _t(e){if(e.length<=1)return e.join("");return`${e.slice(0,-1).join(", ")} or ${e.at(-1)}`}function co(e,t,o,r){let i=t[o];if(i===void 0||!r.some((s)=>Nt(s,i)))throw I(e,o,`expected ${_t(r)}, got ${R(i)}`);return i}function Vt(e){switch(Lt(e)){case"enum":return`one of ${(e.enum??[]).map((t)=>R(t)).join(" | ")}`;case"const":return`the constant ${R(e.const)}`;case"one-of":return(e.oneOf??[]).map((t)=>Vt(t)).join(" or ");case"typed":return _t(Ue(e.type??[]));case"boolean":return"a boolean";case"bounded-number":return`a number from ${e.minimum} to ${e.maximum}`;case"number":return"a finite number";case"integer":return"an integer";case"string":return"a non-empty string";case"path":return"a document path";case"path-list":return"a list of document paths";default:return"anything"}}function uo(e,t,o,r){let i=t[o],s=[];for(let a of r){if(a.type!==void 0&&!Ue(a.type).some((l)=>Nt(l,i)))continue;try{return Bt(e,t,o,a)}catch(l){s.push(l)}}if(s.length===1)throw s[0];throw I(e,o,`expected ${r.map((a)=>Vt(a)).join(" or ")}, got ${R(i)}`)}function Bt(e,t,o,r){switch(Lt(r)){case"enum":return qn(e,t,o,r.enum??[]);case"const":{let i=t[o];if(i!==r.const)throw I(e,o,`expected the constant ${R(r.const)}, got ${R(i)}`);return i}case"one-of":return uo(e,t,o,r.oneOf??[]);case"typed":return co(e,t,o,Ue(r.type??[]));case"boolean":return Hi(e,t,o);case"bounded-number":{if(r.type==="integer")Et(e,t,o);return Zx(e,t,o,r.minimum,r.maximum)}case"number":return $t(e,t,o);case"integer":return Et(e,t,o);case"string":return St(e,t,o);case"path":return QC(e,t,o);case"path-list":return mI(e,t,o);default:return t[o]}}function sM(e,t,o){let r=t,i=r.properties??{},s=Object.keys(i),a=r.required??[],l={};for(let[c,u]of Object.entries(o)){if(u===void 0||Object.hasOwn(i,c))continue;if(r.additionalProperties===!1)throw I(e,c,`not declared — declared: ${s.join(", ")||"none"}`);l[c]=u}for(let c of s){if(o[c]===void 0&&!a.includes(c))continue;l[c]=Bt(e,o,c,i[c])}return l}var fo=20,fi="primary",Xm="secondary",yI=2,m=g({activePaneId:fi,clipboard:null,closedTabs:[],componentRegistry:[],mruOrder:[],fileTree:{dirs:new Map,expanded:new Set,searchQuery:"",selectedPath:null},panes:[{activeTabId:null,derived:null,id:fi,tabOrder:[]}],projectConfig:null,projectRoot:null,styleClipboard:null,tabs:new Map,ui:{activityBar:"files"},get activeTabId(){let e=qr();return e.derived?.kind==="lens"?pn(e.derived.sourcePaneId)?.activeTabId??null:e.activeTabId},get tabOrder(){return qr().tabOrder}}),h=Ph(()=>m.activeTabId?m.tabs.get(m.activeTabId)??null:null);function qr(){let{panes:e}=m;return e.find((t)=>t.id===m.activePaneId)??e[0]}function pn(e){return m.panes.find((t)=>t.id===e)}function Da(e){return m.panes.find((t)=>t.tabOrder.includes(e))}function Sr(e){let t=pn(e);if(!t||t.id===m.activePaneId)return;m.activePaneId=t.id,L();let{activeTabId:o}=t;if(o){qe(o);let r=m.tabs.get(o);if(r)zt(r)}}function Qm(e){return m.activePaneId===e}function i1(e){let t=e??qr().activeTabId,o=t?m.tabs.get(t):null;if(!t||!o)return null;let r=Da(t);if(!r)return null;let i=oc(r.id);return ng(t),Sh(i,t),i.activeTabId=t,m.activePaneId=i.id,L(),qe(t),i}function o1(e){return m.panes.find((t)=>t.id!==e)??po(Xm)}function oc(e){let t=o1(e);if(t.derived)t.derived=null;return t}function po(e){let t=pn(e);if(t)return t;return m.panes=[...m.panes,{activeTabId:null,derived:null,id:e,tabOrder:[]}],pn(e)}function eg(e){if(m.panes.length<2)return;let t=e===fi?m.panes.find((s)=>s.id!==fi)?.id:e,o=t===void 0?void 0:pn(t),r=m.panes.find((s)=>s.id!==t);if(!o||!r)return;for(let s of o.tabOrder)Sh(r,s);let i=o.activeTabId!==null&&K(o.activeTabId)?o.activeTabId:null;if(r.activeTabId=m.activePaneId===o.id?i??r.activeTabId??o.activeTabId:r.activeTabId??o.activeTabId,m.activePaneId=r.id,r.derived?.sourcePaneId===o.id)r.derived=null;m.panes=m.panes.filter((s)=>s.id!==o.id),L()}function tg(e){return e.tabOrder.length===0&&e.derived===null}var K=()=>!0;function r1(e){K=e??(()=>!0)}var Ut=null;function s1(e){Ut=e}var qt=null;function a1(e){qt=e}function mo(){let e=0;for(let t of m.tabs.keys())if(K(t))e+=1;return e}function Gt(e){return e.tabOrder.findLast((t)=>K(t))??null}function ng(e){let t=[];for(let o of m.panes){if(!o.tabOrder.includes(e))continue;if(o.tabOrder=o.tabOrder.filter((r)=>r!==e),o.activeTabId===e)o.activeTabId=Gt(o);if(o.id!==fi&&tg(o))t.push(o.id)}for(let o of t)eg(o)}function Sh(e,t,o){if(e.tabOrder.includes(t))return;let r=o??bo(e,t);e.tabOrder=[...e.tabOrder.slice(0,r),t,...e.tabOrder.slice(r)]}function yo(e){let t=0;for(let o of e.tabOrder){if(m.tabs.get(o)?.pinned!==!0)break;t+=1}return t}function bo(e,t){return m.tabs.get(t)?.pinned===!0?yo(e):e.tabOrder.length}function rc(e,t=null){if(m.projectRoot&&e!==m.projectRoot)n1();m.projectRoot=e,m.projectConfig=t}function Yp(e){let t=h.value;return e!==null&&t!==null&&le(t)===le(e)}function bl(e){if(!e)return!1;let t=m.tabs.get(e.id);return t!==void 0&&le(t)===le(e)}function qe(e){m.mruOrder=[e,...m.mruOrder.filter((t)=>t!==e)]}var Pe=null,se=0;function L(){Pe=null,se=0}function zt(e){if(C&&e.documentPath)C.selectedPath=e.documentPath}function l1(e){let t=pn(e);if(t)t.activeTabId=null}function ae(e,t={}){let o=m.tabs.get(e),r=Da(e);if(!o||!r)return;if(r.activeTabId=e,t.focus===!1)return;if(m.activePaneId=r.id,!t.cycling)L(),qe(e);zt(o)}function Si(e){if(e.background===!0){let a=m.tabs.get(e.id);if(a)return a;let l=yv({...e,preview:!1}),c=(e.paneId===void 0?void 0:pn(e.paneId))??qr();return Sh(c,l.id),m.tabs.set(l.id,l),l}let t=m.tabs.get(e.id),o=e.preview===!0&&t?.pinned!==!0,r=yv({...e,preview:o}),i=(e.paneId===void 0?void 0:pn(e.paneId))??qr(),s;if(t)r.pinned=t.pinned,Km(t);else{if(o){let l=Ht(i),c=l?m.tabs.get(l):null;if(c)nu(c);c1()}let a=o?Ht(i):null;if(a)s=i.tabOrder.indexOf(a),eu(a);Sh(i,r.id,s)}return m.tabs.set(r.id,r),ae(r.id,{focus:e.focus!==!1}),ie(r),r}function Ht(e){return e.tabOrder.find((t)=>m.tabs.get(t)?.preview===!0)??null}function td(e){let t=m.tabs.get(e);if(t?.preview===!0)t.preview=!1}function c1(){for(let[e,t]of m.tabs)if(t.preview&&(t.doc.dirty||Cv(t)))td(e)}var Yt=null;function wI(e){Yt=e}function Cv(e){return Yt?.(e)??!1}function r0(e,t){let o=m.tabs.get(e),r=Da(e);if(!o||!r)return;if(o.pinned=t,t)o.preview=!1;let i=r.tabOrder.filter((a)=>a!==e),s=i.filter((a)=>m.tabs.get(a)?.pinned===!0).length;r.tabOrder=[...i.slice(0,s),e,...i.slice(s)]}function xI(e,t){let o=m.tabs.get(e),r=Da(e);if(!o||!r)return;r.tabOrder=Zt(r,e,t)}function Zt(e,t,o){let r=m.tabs.get(t);if(!r)return e.tabOrder;let i=e.tabOrder.filter((u)=>u!==t),s=i.filter((u)=>m.tabs.get(u)?.pinned===!0).length,a=r.pinned?0:s,l=r.pinned?s:i.length,c=Math.min(Math.max(o,a),l);return[...i.slice(0,c),t,...i.slice(c)]}function eu(e){let t=m.tabs.get(e);if(!t)return;let o=Da(e),r=o?.activeTabId===e;if(ho(t),Km(t),m.tabs.delete(e),Vx(e),ng(e),m.mruOrder=m.mruOrder.filter((l)=>l!==e),L(),o&&tg(o))eg(o.id);if(!r)return;let i=qr(),s=qt?.(i.id)??null,a=(s!==null&&i.tabOrder.includes(s)?s:null)??m.mruOrder.find((l)=>i.tabOrder.includes(l)&&K(l))??Gt(i);if(a)ae(a);else Ut?.(i.id)}function _I(){let e=[...m.tabs.values()];m.tabs.clear(),Xt(),m.mruOrder=[],L();for(let t of e)Km(t)}function Xt(){m.panes=[{activeTabId:null,derived:null,id:fi,tabOrder:[]}],m.activePaneId=fi}function ho(e){if(!e.documentPath)return;let t=e.documentPath;m.closedTabs=[{documentPath:t},...m.closedTabs.filter((o)=>o.documentPath!==t)].slice(0,fo)}function xo(){let[e]=m.closedTabs;if(!e)return;return m.closedTabs=m.closedTabs.slice(1),e.documentPath}function Kt(e){if(!Pe)Pe=m.mruOrder.filter((r)=>m.tabs.has(r)&&K(r)),se=0;let t=Pe;if(t.length<2)return;se=((se+e)%t.length+t.length)%t.length;let o=t[se];return ae(o,{cycling:!0}),o}function SI(e){let t=[...m.tabs.keys()],o=[...m.tabs.values()],r=yv(e);m.tabs.set(r.id,r),Xt(),m.panes[0].tabOrder=[r.id],m.mruOrder=[],L(),ae(r.id),ie(r);for(let i of t){if(i===r.id)continue;m.tabs.delete(i)}for(let i of o)Km(i);return r}function Ft(e,t={}){ae(e,t)}function kv(e,t,o){let r=pn(t);if(!r||!m.tabs.has(e))return null;if(r.tabOrder.includes(e)){if(o!==void 0)r.tabOrder=Zt(r,e,o);return r}return ng(e),Sh(r,e,o),r}function CI(e,t,o){let r=m.tabs.get(e);if(!r)return;if(r.id=t,r.documentPath=o,ZC(e))Vx(e),qm(t);m.tabs.delete(e),m.tabs.set(t,r);for(let i of m.panes)if(i.tabOrder=i.tabOrder.map((s)=>s===e?t:s),i.activeTabId===e)i.activeTabId=t;m.mruOrder=m.mruOrder.map((i)=>i===e?t:i),L(),jt(r)}function kI(e,t){e.registerAll([...vo(t),...Oo(t)])}function vo(e){let t=()=>mo()>1;return[{id:"document.nextTab",title:"Next Tab",category:"Document",level:"document",keybinding:["ctrl+tab","mod+tab"],menus:["palette"],group:"2_navigate",when:(o)=>o.document.open,enablement:t,requires:"a second open document in this workspace",run:()=>{Kt(1)}},{id:"document.previousTab",title:"Previous Tab",category:"Document",level:"document",keybinding:["ctrl+shift+tab","mod+shift+tab"],menus:["palette"],group:"2_navigate",when:(o)=>o.document.open,enablement:t,requires:"a second open document in this workspace",run:()=>{Kt(-1)}},{args:Se({path:Fe('Project-relative path of the file to open, e.g. "pages/about.json" or "components/nav-bar.json". It must exist.')}),id:"document.open",title:"Open Document",category:"Document",level:"project",menus:["palette"],group:"1_file",when:(o)=>o.project.open,requires:"an open project",aiTool:{description:"Open a project file as the active document; the document tools then operate on it. Use it when the user should SEE the page, or for iterative visual refinement after creating a page or component.",name:"open_document",report:({after:o,args:r})=>{let i=St("document.open",r,"path"),s=h.value?.documentPath??null;if(s!==i)return`Opened "${i}", but the active document is ${s===null?"none":`"${s}"`}.`;let a=o.editor.kind==="canvas"?"on the canvas; the document tools now operate on it":`in the ${Gp[o.editor.kind]} editor, which is not an element tree the document tools can edit`;return`"${i}" is the active document, ${a}.`}},run:async(o,r)=>{let i=St("document.open",r,"path");if(await e.openFile(i),![...m.tabs.values()].some((s)=>s.documentPath===i))throw RangeError(`command "document.open" argument "path": "${i}" could not be opened — it does `+"not exist, or no editor claims its format. Problems has the reason.")}},{args:Se({file:Fe('Project-relative path of the file to open in the other pane, e.g. "pages/about.json". It must exist.')}),id:"document.openToSide",title:"Open to the Side",category:"Document",level:"project",menus:["context/file","palette"],group:"1_file",when:(o)=>o.project.open,requires:"an open project",undo:"none",run:async(o,r)=>{let i=St("document.openToSide",r,"file"),s=oc(qr().id);if(await e.openFile(i,{paneId:s.id}),![...m.tabs.values()].some((a)=>a.documentPath===i)){if(tg(s)&&s.id!==fi)eg(s.id);throw RangeError(`command "document.openToSide" argument "file": "${i}" could not be opened — it `+"does not exist, or no editor claims its format. Problems has the reason.")}}},{id:"document.reopenClosed",title:"Reopen Closed Document",category:"Document",level:"document",keybinding:"mod+shift+t",menus:["context/tab","palette"],group:"1_file",enablement:()=>m.closedTabs.length>0,requires:"a document closed in this session",run:async()=>{let o=xo();if(o)await e.openFile(o)}},{id:"document.togglePinned",title:"Pin / Unpin Document",category:"Document",level:"document",menus:["context/tab","palette"],group:"1_file",when:(o)=>o.document.open,requires:"an open document",run:()=>{let o=m.activeTabId,r=o?m.tabs.get(o):null;if(o&&r)r0(o,!r.pinned)}},{args:Se({pinned:To("True to pin the active document's tab, false to unpin it.")}),id:"document.setPinned",title:"Set Document Pinned",category:"Document",level:"document",menus:["palette"],group:"1_file",when:(o)=>o.document.open,requires:"an open document",run:(o,r)=>{let i=m.activeTabId;if(i&&m.tabs.get(i))r0(i,Hi("document.setPinned",r,"pinned"))}},{id:"document.keepOpen",title:"Keep Document Open",category:"Document",level:"document",menus:["context/tab","palette"],group:"1_file",when:(o)=>o.document.open,enablement:()=>{let o=m.activeTabId;return o!==null&&m.tabs.get(o)?.preview===!0},requires:"a preview document — one opened by a single click",run:()=>{let o=m.activeTabId;if(o)td(o)}}]}function Oo(e){let t=()=>m.panes.length>1;return[{id:"pane.splitRight",title:"Split Right",category:"View",level:"document",keybinding:"mod+\\",menus:["context/pane","context/tab","palette"],group:"5_pane",when:(o)=>o.document.open,enablement:()=>m.activeTabId!==null,requires:"an open document",undo:"none",run:()=>{i1()}},{args:Se({path:Fe("Project-relative path of the document to open beside this one.")}),id:"pane.compareWith",title:"Compare With…",category:"View",level:"document",menus:["context/pane","context/tab","palette"],group:"5_pane",when:(o)=>o.document.open,enablement:()=>m.activeTabId!==null,requires:"an open document",undo:"none",run:async(o,r)=>{let i=St("pane.compareWith",r,"path"),s=qr();if((s.activeTabId?m.tabs.get(s.activeTabId):null)?.documentPath===i)throw RangeError(`command "pane.compareWith" argument "path": "${i}" is the document this pane is `+"already showing — name a different one");await e.openFileInPane(oc(s.id).id,i)}},{id:"pane.focusPrimary",title:"Focus Primary Pane",category:"View",level:"document",keybinding:"mod+0",menus:["palette"],group:"5_pane",enablement:t,requires:"a split pane grid",undo:"none",run:()=>{Sr(fi)}},{id:"pane.focusSecondary",title:"Focus Side Pane",category:"View",level:"document",keybinding:"mod+alt+0",menus:["palette"],group:"5_pane",enablement:t,requires:"a split pane grid",undo:"none",run:()=>{Sr(Xm)}},{id:"pane.unsplit",title:"Close Side Pane",category:"View",level:"document",menus:["context/pane","palette"],group:"5_pane",enablement:t,requires:"a second pane",undo:"none",run:Po}]}function Po(){let e=m.panes.find((t)=>t.derived!==null);if(e?.id===fi){if(e.derived=null,!tg(e))return}eg(e?.id??Xm)}
2
+ export{KC,jn,Fx,fv,Wt,ln,go,jx,mv,Qc,VO,JC,Up,Hx,aI,bh,Bx,qp,$a,ml,gv,Gp,Qs,UO,zx,vh,Wx,bv,YC,qO,qm,Vx,ZC,lI,vv,Hn,Vr,Ux,yh,qx,GO,Gx,cI,Gm,KO,an,yv,XC,dI,JO,Km,xn,wv,Oe,YO,Kx,Ia,Jx,ZO,XO,Jm,QO,eM,tM,nM,ea,uI,iM,hI,pI,fI,Yx,xv,_v,St,ti,Zx,Hi,qn,QC,oM,mI,Se,pi,gl,gI,To,Xx,rM,Fe,sM,aM,Bi,Jd,Gn,ed,Qx,e0,e1,lM,Ra,wh,xh,Sv,t0,cM,ir,Z,Yd,dM,uM,bI,hM,Zd,pM,fM,t1,mM,or,_h,vI,Ym,n0,gM,Kp,Qe,Zm,_r,bM,i0,vM,o0,yM,wM,Xd,xM,Ur,_M,Jp,SM,CM,kM,Qd,EM,TM,LM,$M,IM,n1,RM,fi,Xm,yI,m,h,qr,pn,Da,Sr,Qm,i1,o1,oc,eg,tg,r1,s1,a1,ng,Sh,rc,Yp,bl,l1,Si,td,c1,wI,Cv,r0,xI,eu,_I,SI,Ft,kv,CI,kI};
3
+
4
+ //# debugId=2896DE7491A37F0564756E2164756E21
5
+ //# sourceMappingURL=studio-yrcrncev.js.map