@jxsuite/studio 10.0.0 → 10.1.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 (162) hide show
  1. package/dist/chunks/{2020-j56903f1.js → 2020-mkb0qa6p.js} +2 -2
  2. package/dist/chunks/adapter-xcpsmecx.js +4 -0
  3. package/dist/chunks/{add-new-flow-snx1s4b0.js → add-new-flow-ptmhmzr9.js} +3 -3
  4. package/dist/chunks/{cf-account-picker-xyqw0jex.js → cf-account-picker-z1sgwpwd.js} +3 -3
  5. package/dist/chunks/cf-settings-xqvhxxe9.js +4 -0
  6. package/dist/chunks/components-whsc81a7.js +4 -0
  7. package/dist/chunks/content-source-jwtxg78w.js +4 -0
  8. package/dist/chunks/{convert-to-repeater-fhdwyg14.js → convert-to-repeater-f92ey3kp.js} +3 -3
  9. package/dist/chunks/editor-zdqdpq1x.js +4 -0
  10. package/dist/chunks/entry-commands-w8p2fbpt.js +4 -0
  11. package/dist/chunks/{extension-sections-8ez2rrk8.js → extension-sections-y2p1te2r.js} +3 -3
  12. package/dist/chunks/file-ops-13ab4swj.js +4 -0
  13. package/dist/chunks/files-zbc8p6v1.js +4 -0
  14. package/dist/chunks/{format-host-zfjz4rzm.js → format-host-zjsbktbx.js} +3 -3
  15. package/dist/chunks/fs-events-t6x0hch6.js +4 -0
  16. package/dist/chunks/grid-open-fyzdwpkh.js +4 -0
  17. package/dist/chunks/{grid-view-ka55z38f.js → grid-view-r22jsqht.js} +5 -5
  18. package/dist/chunks/{iframe-host-na2mywz4.js → iframe-host-kbyqc7pt.js} +3 -3
  19. package/dist/chunks/index-6nvj89vb.js +4 -0
  20. package/dist/chunks/{index-qb98xhse.js → index-pxwwf00y.js} +2 -2
  21. package/dist/chunks/{javascript-ces13wny.js → javascript-pzqryby6.js} +2 -2
  22. package/dist/chunks/{jsonMode-6md16d4v.js → jsonMode-tcnyxyap.js} +5 -5
  23. package/dist/chunks/jx-validate-5sp8a4rm.js +4 -0
  24. package/dist/chunks/layers-panel-qrxj9vr2.js +4 -0
  25. package/dist/chunks/layers-tpzayggx.js +4 -0
  26. package/dist/chunks/lit-html-x6nrxsx3.js +4 -0
  27. package/dist/chunks/media-library-ywppnjrz.js +4 -0
  28. package/dist/chunks/media-picker-etxgc8qq.js +4 -0
  29. package/dist/chunks/{monaco-binding-p8j80s4w.js → monaco-binding-bqpge64f.js} +2 -2
  30. package/dist/chunks/monaco-buffer-qrnqhk0b.js +4 -0
  31. package/dist/chunks/{monaco-setup-wasktzfg.js → monaco-setup-1mkab762.js} +3 -3
  32. package/dist/chunks/notify-kcv38wwe.js +4 -0
  33. package/dist/chunks/parse-df2kkmhc.js +4 -0
  34. package/dist/chunks/{platform-c16mqvmp.js → platform-dtsysmyd.js} +2 -2
  35. package/dist/chunks/publish-panel-evb1rcxt.js +4 -0
  36. package/dist/chunks/{publish-quick-vr695j26.js → publish-quick-m9vkhahq.js} +3 -3
  37. package/dist/chunks/publish-workspace-ktk9h536.js +4 -0
  38. package/dist/chunks/quick-search-2f47fxcw.js +4 -0
  39. package/dist/chunks/references-5w6ajjv7.js +4 -0
  40. package/dist/chunks/right-panel-kz0a6byf.js +4 -0
  41. package/dist/chunks/source-control-1phx90zk.js +4 -0
  42. package/dist/chunks/{studio-h5tpz5ke.js → studio-07k0geap.js} +4 -4
  43. package/dist/chunks/{studio-7xag4na8.js → studio-0g2sm01j.js} +4 -4
  44. package/dist/chunks/{studio-de1s2x9v.js → studio-0hr000ba.js} +4 -4
  45. package/dist/chunks/{studio-35vrtpdq.js → studio-1wyp7dt5.js} +4 -4
  46. package/dist/chunks/{studio-34jrz12k.js → studio-20ap8dds.js} +4 -4
  47. package/dist/chunks/{studio-d83m0wyq.js → studio-291gqh98.js} +3 -3
  48. package/dist/chunks/{studio-xdpz9rpe.js → studio-37twdaf7.js} +29 -29
  49. package/dist/chunks/{studio-ry81j4q1.js → studio-4nkm4404.js} +4 -4
  50. package/dist/chunks/{studio-3v5cagy9.js → studio-4smcnv33.js} +3 -3
  51. package/dist/chunks/{studio-k3a8rp3d.js → studio-4zqfw5ha.js} +2 -2
  52. package/dist/chunks/{studio-d038kqbs.js → studio-56egy6vf.js} +4 -4
  53. package/dist/chunks/{studio-x3mjr5cc.js → studio-5dmgmyw4.js} +4 -4
  54. package/dist/chunks/{studio-x97ay0v4.js → studio-5e7p1vgd.js} +3 -3
  55. package/dist/chunks/{studio-ndskgqef.js → studio-5m0w815d.js} +3 -3
  56. package/dist/chunks/{studio-pqqq6v85.js → studio-695k95bw.js} +4 -4
  57. package/dist/chunks/{studio-gwrhcrss.js → studio-6vwvshw8.js} +2 -2
  58. package/dist/chunks/{studio-pgm83a2f.js → studio-76t560kn.js} +4 -4
  59. package/dist/chunks/{studio-396srjbk.js → studio-7823f0g8.js} +3 -3
  60. package/dist/chunks/{studio-r17asgs0.js → studio-7vb997ff.js} +4 -4
  61. package/dist/chunks/{studio-et2q4s8n.js → studio-8486jn4r.js} +3 -3
  62. package/dist/chunks/{studio-3w35qvay.js → studio-848rk4p1.js} +4 -4
  63. package/dist/chunks/{studio-5tzgq6fx.js → studio-8jb31dcf.js} +4 -4
  64. package/dist/chunks/{studio-y26hx9re.js → studio-8qejv8yf.js} +4 -4
  65. package/dist/chunks/{studio-h7weqf2q.js → studio-8x8616xd.js} +4 -4
  66. package/dist/chunks/{studio-hcsba201.js → studio-9cp96v90.js} +2 -2
  67. package/dist/chunks/{studio-dx73md4n.js → studio-9rcbvksg.js} +6 -6
  68. package/dist/chunks/{studio-m48v13s3.js → studio-a3s6frde.js} +3 -3
  69. package/dist/chunks/{studio-4kzbrr5t.js → studio-ahf3cspq.js} +3 -3
  70. package/dist/chunks/{studio-zgx7svjd.js → studio-bkmv1h3e.js} +5 -5
  71. package/dist/chunks/{studio-3c8pp7pb.js → studio-brdp85q7.js} +4 -4
  72. package/dist/chunks/{studio-yg3djpnm.js → studio-cgb97rwv.js} +4 -4
  73. package/dist/chunks/{studio-tj2s0tks.js → studio-ch8gt8vt.js} +3 -3
  74. package/dist/chunks/{studio-p1n2xjda.js → studio-cqf1k4qk.js} +4 -4
  75. package/dist/chunks/{studio-jttyqrmh.js → studio-cvz0e00f.js} +4 -4
  76. package/dist/chunks/{studio-5wzdy1jc.js → studio-dbgv4fv9.js} +14 -14
  77. package/dist/chunks/{studio-h310mbqm.js → studio-dy2xtt7a.js} +4 -4
  78. package/dist/chunks/{studio-xkxetm65.js → studio-eesyjg7h.js} +5 -5
  79. package/dist/chunks/studio-et6t8g4m.js +4 -0
  80. package/dist/chunks/{studio-cpkamjdn.js → studio-f2j9et3h.js} +8 -8
  81. package/dist/chunks/{studio-epenqmvk.js → studio-fep7hr66.js} +4 -4
  82. package/dist/chunks/{studio-2ks6ka4g.js → studio-fyf7j57j.js} +3 -3
  83. package/dist/chunks/{studio-rzg8hnkf.js → studio-g5prntab.js} +4 -4
  84. package/dist/chunks/{studio-c1pxszat.js → studio-ga77mf07.js} +4 -4
  85. package/dist/chunks/{studio-9cxmp61c.js → studio-ggm7zf70.js} +3 -3
  86. package/dist/chunks/studio-h7gy12h2.js +5 -0
  87. package/dist/chunks/{studio-9dz76yqc.js → studio-hsr3k06v.js} +5 -5
  88. package/dist/chunks/{studio-vzgmyt0v.js → studio-j933k8nr.js} +4 -4
  89. package/dist/chunks/studio-jgbvqcgh.js +5 -0
  90. package/dist/chunks/{studio-wxhy1yh7.js → studio-jh6t5qz4.js} +3 -3
  91. package/dist/chunks/{studio-88bmt9rh.js → studio-k4xc5g6h.js} +4 -4
  92. package/dist/chunks/{studio-wxdcd42g.js → studio-mwnmzx7g.js} +6 -6
  93. package/dist/chunks/{studio-1e8dw2w2.js → studio-nf0pqpbj.js} +4 -4
  94. package/dist/chunks/{studio-2j86y34y.js → studio-p0nf2e1f.js} +5 -5
  95. package/dist/chunks/{studio-k3bcy02e.js → studio-pd9dsqpq.js} +4 -4
  96. package/dist/chunks/{studio-agyvzfm4.js → studio-pmzg17fj.js} +4 -4
  97. package/dist/chunks/{studio-zg16eeq1.js → studio-pzfa2vmb.js} +4 -4
  98. package/dist/chunks/{studio-hy4ye0dx.js → studio-qyb5bebs.js} +7 -7
  99. package/dist/chunks/{studio-0ydxv2mr.js → studio-rf8d6p9f.js} +6 -6
  100. package/dist/chunks/{studio-45gyxpcq.js → studio-rt498t2v.js} +4 -4
  101. package/dist/chunks/studio-sd07xva5.js +6 -0
  102. package/dist/chunks/{studio-06j4en5h.js → studio-skynbac3.js} +2 -2
  103. package/dist/chunks/{studio-vswcpzk7.js → studio-t3j8htp7.js} +5 -5
  104. package/dist/chunks/{studio-3zge48z4.js → studio-thj81e98.js} +6 -6
  105. package/dist/chunks/{studio-ekgtrndg.js → studio-tpy3rdxn.js} +4 -4
  106. package/dist/chunks/{studio-ewarnzm4.js → studio-va0e63sk.js} +4 -4
  107. package/dist/chunks/{studio-gr36vnte.js → studio-vcz63n42.js} +4 -4
  108. package/dist/chunks/studio-vffwe9k7.js +5 -0
  109. package/dist/chunks/{studio-7dzyz9n8.js → studio-vjhej0w5.js} +103 -103
  110. package/dist/chunks/{studio-hwejq03c.js → studio-vxjap704.js} +4 -4
  111. package/dist/chunks/{studio-03mqh8ax.js → studio-w67vfgy5.js} +2 -2
  112. package/dist/chunks/{studio-ajw4k8hp.js → studio-x2metr13.js} +3 -3
  113. package/dist/chunks/{studio-771k2n12.js → studio-xebavr9s.js} +4 -4
  114. package/dist/chunks/{studio-x08a3m0a.js → studio-yg5n49za.js} +4 -4
  115. package/dist/chunks/{studio-xh683qzy.js → studio-yhz5b313.js} +4 -4
  116. package/dist/chunks/{studio-fy7jzj9j.js → studio-zacvfm31.js} +4 -4
  117. package/dist/chunks/{studio-zkq3r91p.js → studio-zsjpsw08.js} +4 -4
  118. package/dist/chunks/{studio-2hsqbq7b.js → studio-zxm98z2m.js} +6 -6
  119. package/dist/chunks/{tsMode-h6tkz0ea.js → tsMode-6vwhy6ty.js} +5 -5
  120. package/dist/chunks/workspace-d65bz1qk.js +4 -0
  121. package/dist/chunks/workspace-home-vbg9b3jh.js +4 -0
  122. package/dist/chunks/{ws-client-e951my95.js → ws-client-zcxkfgmf.js} +3 -3
  123. package/dist/manifest.json +71 -71
  124. package/dist/studio.js +73 -70
  125. package/package.json +4 -4
  126. package/src/platform-errors.ts +17 -1
  127. package/src/platforms/cloud.ts +14 -0
  128. package/src/publish/publish-changes.ts +136 -4
  129. package/src/types.ts +14 -0
  130. package/dist/chunks/adapter-wc5zvg9a.js +0 -4
  131. package/dist/chunks/cf-settings-hp1pjm0n.js +0 -4
  132. package/dist/chunks/components-nkwphrx3.js +0 -4
  133. package/dist/chunks/content-source-6a253wmk.js +0 -4
  134. package/dist/chunks/editor-wqrc68ca.js +0 -4
  135. package/dist/chunks/entry-commands-nef0wrmp.js +0 -4
  136. package/dist/chunks/file-ops-y3w71k1n.js +0 -4
  137. package/dist/chunks/files-de90apn9.js +0 -4
  138. package/dist/chunks/fs-events-77c0mr0x.js +0 -4
  139. package/dist/chunks/grid-open-4n4fjfpf.js +0 -4
  140. package/dist/chunks/index-ewmgdb7c.js +0 -4
  141. package/dist/chunks/jx-validate-b309c020.js +0 -4
  142. package/dist/chunks/layers-8rn8y6qv.js +0 -4
  143. package/dist/chunks/layers-panel-eyah7h9z.js +0 -4
  144. package/dist/chunks/lit-html-wyqw04y2.js +0 -4
  145. package/dist/chunks/media-library-gs3np47y.js +0 -4
  146. package/dist/chunks/media-picker-tt7dk4tb.js +0 -4
  147. package/dist/chunks/monaco-buffer-wsf6cmnq.js +0 -4
  148. package/dist/chunks/notify-qwst108r.js +0 -4
  149. package/dist/chunks/parse-n8dfxnqf.js +0 -4
  150. package/dist/chunks/publish-panel-d34bhvwj.js +0 -4
  151. package/dist/chunks/publish-workspace-2yr60mt4.js +0 -4
  152. package/dist/chunks/quick-search-e6xsdv0d.js +0 -4
  153. package/dist/chunks/references-gsj6trdv.js +0 -4
  154. package/dist/chunks/right-panel-33jv1knc.js +0 -4
  155. package/dist/chunks/source-control-bj9bejjv.js +0 -4
  156. package/dist/chunks/studio-38g0jdz7.js +0 -5
  157. package/dist/chunks/studio-dbxv7w4s.js +0 -5
  158. package/dist/chunks/studio-psh8mwnw.js +0 -4
  159. package/dist/chunks/studio-v9ywz2se.js +0 -6
  160. package/dist/chunks/studio-yx8hzqja.js +0 -5
  161. package/dist/chunks/workspace-home-zkkrxq3r.js +0 -4
  162. package/dist/chunks/workspace-tdqqjqaa.js +0 -4
@@ -1,7 +1,7 @@
1
- import{te}from"./studio-psh8mwnw.js";import{g,C}from"./studio-4kzbrr5t.js";import{Ot,Nt}from"./studio-cpkamjdn.js";import{Ue,ft,T,R,Yt,tt}from"./studio-jttyqrmh.js";var _={$schema:"https://jxsuite.com/schema/v1",$id:"StudioGithubAuth",$description:"The RFC 8628 device flow's waiting room: the code GitHub minted, the page to type it into, and a Cancel. A `jx-dialog`, so the platform owns modality, Escape, focus restoration and the backdrop — and it is the reason the dialog has no confirm button at all: the answer arrives from GitHub over a poll rather than from anything the reader can press here, so a primary button would be a control with nothing to do. Nothing in this document talks to GitHub: `github/github-auth.ts` keeps the client id, the poll loop, its failure budget and every report the three outcomes raise.",tagName:"jx-dialog",$props:{headline:"Sign in to GitHub",confirmLabel:"",cancelLabel:"Cancel",size:"sm"},attributes:{part:"github-auth"},oncancel:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/cancel"},value:[]}]},onclose:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/closed"},value:[]}]},style:{$description:"Four `.github-auth-*` rules in `styles/overlays.css` become the parts below, and two things in them do not travel. `.github-auth-dialog`'s `padding: 16px 0` was the card's own body padding drawn by hand, and `jx-dialog` already pads its body; `.github-auth-dialog p { font-size: 13px }` was a body size this surface picked for itself, and what the paragraphs now inherit is the dialog's own `--jx-text-md`. The `8px 0` margins go with them — the column is a flex column with a gap, so a margin between two rows would be a second opinion about the same space. The code keeps its 24px, which is above the token scale on purpose: it is a string the reader has to copy onto another screen, and reading it out loud is the whole job of this dialog.",'& [part="device"]':{display:"flex",flexDirection:"column",alignItems:"center",gap:"var(--jx-space-3)",textAlign:"center"},'& [part="lede"], & [part="waiting"]':{margin:"0"},'& [part="code"]':{$description:"`<code>`, not a styled `<div>`: this is a literal string to be transcribed, and the element that says so is also the one a reader's own stylesheet and a screen reader's character-by-character mode already know about. It is this dialog's message, and the one string in it the reader must carry to another screen, so it opts back in to selection against the root's `user-select: none`. `all` rather than `text`: one click selects the whole code, so a copy never leaves a character behind.",userSelect:"all",fontFamily:"var(--font-mono)",fontSize:"24px",fontWeight:"700",letterSpacing:"2px",padding:"var(--jx-space-3) var(--jx-space-4)",background:"var(--hover-bg)",borderRadius:"var(--radius)"},'& [part="link"]':{$description:"The blue this carried as a `var(--accent, …)` fallback is gone: `--accent` is declared on `:root` in `styles/tokens.css`, so the fallback could only ever have painted when the token was missing — which is a theme fault to fix rather than a colour to hard-code.",color:"var(--accent)",textDecoration:"underline"},'& [part="waiting"]':{color:"var(--fg-dim)",fontStyle:"italic"}},children:[{tagName:"div",attributes:{part:"device"},children:[{tagName:"p",attributes:{part:"lede"},textContent:"Enter this code on GitHub to authorize Jx Studio:"},{tagName:"code",attributes:{part:"code"},textContent:"${state.userCode}"},{tagName:"a",attributes:{part:"link",href:"${state.verificationUri}",target:"_blank",rel:"noreferrer"},textContent:"Open ${state.verificationUri}"},{tagName:"p",attributes:{part:"waiting"},textContent:"Waiting for authorization…"}]}]};T("github-auth",_);function A(e){let t=document.createElement("div");t.style.pointerEvents="auto",t.setAttribute(Ue,ft("dialog","github-auth")),e.layer.append(t);let s=!1,l=()=>{if(s)return;s=!0,e.onClosed()},u=()=>s,b=g({cancel:()=>{e.onCancel()},closed:l,userCode:e.userCode,verificationUri:e.verificationUri}),n=null,r=R("github-auth",b,t).then(async(i)=>{n=i;let o=i.root;if(u())return i.dispose(),o;if(await Yt(o),u())return o;return Ot(o),o});return{close(){let i=n?.root;if(i instanceof HTMLElement)Nt(i);n?.dispose(),n=null,t.remove(),l()},host:t,ready:r}}var S="jx_github_token",v="Ov23liYVlMFpgjOEPXJH";function P(e){return typeof e==="object"&&e!==null&&"githubAuth"in e&&e.githubAuth!=null}function p(){let e=globalThis,t="__jxPlatform"in e?e.__jxPlatform:void 0;return P(t)?t.githubAuth:null}var f=null,H=!1;function E(e){f=e}function kT(){return f!==null||H||localStorage.getItem("jx_github_token")!==null}function ET(){return p()?"desktop":"browser"}function y(){return f??localStorage.getItem("jx_github_token")}function TT(){f=null,H=!1,localStorage.removeItem("jx_github_token"),p()?.signOut().catch(()=>{})}var O="github.auth",j="Source Control",N="git.signInToGithub",Y=3,z="The request never reached GitHub. GitHub's device-flow endpoints send no CORS headers, so a "+"browser cannot call them directly — the desktop app can. A machine that is offline fails "+"identically, and the browser does not say which happened.";function I(e){C.error("Could not reach GitHub to sign in.",{action:N,detail:`${z}
1
+ import{ee}from"./studio-et6t8g4m.js";import{g,C}from"./studio-ahf3cspq.js";import{Ot,Nt}from"./studio-f2j9et3h.js";import{Ue,ft,T,R,Yt,tt}from"./studio-cvz0e00f.js";var _={$schema:"https://jxsuite.com/schema/v1",$id:"StudioGithubAuth",$description:"The RFC 8628 device flow's waiting room: the code GitHub minted, the page to type it into, and a Cancel. A `jx-dialog`, so the platform owns modality, Escape, focus restoration and the backdrop — and it is the reason the dialog has no confirm button at all: the answer arrives from GitHub over a poll rather than from anything the reader can press here, so a primary button would be a control with nothing to do. Nothing in this document talks to GitHub: `github/github-auth.ts` keeps the client id, the poll loop, its failure budget and every report the three outcomes raise.",tagName:"jx-dialog",$props:{headline:"Sign in to GitHub",confirmLabel:"",cancelLabel:"Cancel",size:"sm"},attributes:{part:"github-auth"},oncancel:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/cancel"},value:[]}]},onclose:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/closed"},value:[]}]},style:{$description:"Four `.github-auth-*` rules in `styles/overlays.css` become the parts below, and two things in them do not travel. `.github-auth-dialog`'s `padding: 16px 0` was the card's own body padding drawn by hand, and `jx-dialog` already pads its body; `.github-auth-dialog p { font-size: 13px }` was a body size this surface picked for itself, and what the paragraphs now inherit is the dialog's own `--jx-text-md`. The `8px 0` margins go with them — the column is a flex column with a gap, so a margin between two rows would be a second opinion about the same space. The code keeps its 24px, which is above the token scale on purpose: it is a string the reader has to copy onto another screen, and reading it out loud is the whole job of this dialog.",'& [part="device"]':{display:"flex",flexDirection:"column",alignItems:"center",gap:"var(--jx-space-3)",textAlign:"center"},'& [part="lede"], & [part="waiting"]':{margin:"0"},'& [part="code"]':{$description:"`<code>`, not a styled `<div>`: this is a literal string to be transcribed, and the element that says so is also the one a reader's own stylesheet and a screen reader's character-by-character mode already know about. It is this dialog's message, and the one string in it the reader must carry to another screen, so it opts back in to selection against the root's `user-select: none`. `all` rather than `text`: one click selects the whole code, so a copy never leaves a character behind.",userSelect:"all",fontFamily:"var(--font-mono)",fontSize:"24px",fontWeight:"700",letterSpacing:"2px",padding:"var(--jx-space-3) var(--jx-space-4)",background:"var(--hover-bg)",borderRadius:"var(--radius)"},'& [part="link"]':{$description:"The blue this carried as a `var(--accent, …)` fallback is gone: `--accent` is declared on `:root` in `styles/tokens.css`, so the fallback could only ever have painted when the token was missing — which is a theme fault to fix rather than a colour to hard-code.",color:"var(--accent)",textDecoration:"underline"},'& [part="waiting"]':{color:"var(--fg-dim)",fontStyle:"italic"}},children:[{tagName:"div",attributes:{part:"device"},children:[{tagName:"p",attributes:{part:"lede"},textContent:"Enter this code on GitHub to authorize Jx Studio:"},{tagName:"code",attributes:{part:"code"},textContent:"${state.userCode}"},{tagName:"a",attributes:{part:"link",href:"${state.verificationUri}",target:"_blank",rel:"noreferrer"},textContent:"Open ${state.verificationUri}"},{tagName:"p",attributes:{part:"waiting"},textContent:"Waiting for authorization…"}]}]};T("github-auth",_);function A(e){let t=document.createElement("div");t.style.pointerEvents="auto",t.setAttribute(Ue,ft("dialog","github-auth")),e.layer.append(t);let s=!1,l=()=>{if(s)return;s=!0,e.onClosed()},u=()=>s,b=g({cancel:()=>{e.onCancel()},closed:l,userCode:e.userCode,verificationUri:e.verificationUri}),n=null,r=R("github-auth",b,t).then(async(i)=>{n=i;let o=i.root;if(u())return i.dispose(),o;if(await Yt(o),u())return o;return Ot(o),o});return{close(){let i=n?.root;if(i instanceof HTMLElement)Nt(i);n?.dispose(),n=null,t.remove(),l()},host:t,ready:r}}var S="jx_github_token",v="Ov23liYVlMFpgjOEPXJH";function P(e){return typeof e==="object"&&e!==null&&"githubAuth"in e&&e.githubAuth!=null}function p(){let e=globalThis,t="__jxPlatform"in e?e.__jxPlatform:void 0;return P(t)?t.githubAuth:null}var f=null,H=!1;function E(e){f=e}function kT(){return f!==null||H||localStorage.getItem("jx_github_token")!==null}function ET(){return p()?"desktop":"browser"}function y(){return f??localStorage.getItem("jx_github_token")}function TT(){f=null,H=!1,localStorage.removeItem("jx_github_token"),p()?.signOut().catch(()=>{})}var O="github.auth",j="Source Control",N="git.signInToGithub",Y=3,z="The request never reached GitHub. GitHub's device-flow endpoints send no CORS headers, so a "+"browser cannot call them directly — the desktop app can. A machine that is offline fails "+"identically, and the browser does not say which happened.";function I(e){C.error("Could not reach GitHub to sign in.",{action:N,detail:`${z}
2
2
 
3
- ${te(e)}`,key:O,source:j})}function w(e,t){C.warn(e,{action:N,detail:t,key:O,source:j})}async function F(){let e;try{e=await fetch("https://github.com/login/device/code",{body:JSON.stringify({client_id:v,scope:"repo"}),headers:{Accept:"application/json","Content-Type":"application/json"},method:"POST"})}catch(t){return I(t),null}if(!e.ok)return w("GitHub refused to start the sign-in.",`GitHub answered ${e.status}${e.statusText?` ${e.statusText}`:""}.`),null;return await e.json()}async function hS(){let e=y();if(e)return e;let t=p();if(t)try{let{token:r}=await t.signIn();return E(r),r}catch(r){return w("GitHub sign-in was not completed.",te(r)),null}let s=await F();if(!s)return null;let{device_code:l,user_code:u,verification_uri:b,interval:n=5}=s;return new Promise((r)=>{let i=!1,o=null,m=0,k=!1,L=(c)=>{if(k)return;if(k=!0,i=!0,o)clearTimeout(o),o=null;r(c)},x=!1,G=()=>{if(x)return;x=!0,D.close()},d=(c)=>{L(c),G()},h=async()=>{if(i)return;try{let a=await(await fetch("https://github.com/login/oauth/access_token",{body:JSON.stringify({client_id:v,device_code:l,grant_type:"urn:ietf:params:oauth:grant-type:device_code"}),headers:{Accept:"application/json","Content-Type":"application/json"},method:"POST"})).json();if(m=0,a.access_token){localStorage.setItem(S,a.access_token),d(a.access_token);return}if(a.error==="authorization_pending"){o=setTimeout(h,n*1000);return}if(a.error==="slow_down"){o=setTimeout(h,(n+5)*1000);return}w("GitHub sign-in was not completed.",a.error==="access_denied"?"The authorization was declined on GitHub.":a.error==="expired_token"?"The device code expired before it was entered.":`GitHub answered "${a.error??"an unrecognised response"}".`),d(null)}catch(c){if(m+=1,m>=Y){I(c),d(null);return}o=setTimeout(h,n*1000)}},D=A({layer:tt("dialog"),onCancel:()=>{G()},onClosed:()=>{d(null)},userCode:u,verificationUri:b});o=setTimeout(h,n*1000)})}
3
+ ${ee(e)}`,key:O,source:j})}function w(e,t){C.warn(e,{action:N,detail:t,key:O,source:j})}async function F(){let e;try{e=await fetch("https://github.com/login/device/code",{body:JSON.stringify({client_id:v,scope:"repo"}),headers:{Accept:"application/json","Content-Type":"application/json"},method:"POST"})}catch(t){return I(t),null}if(!e.ok)return w("GitHub refused to start the sign-in.",`GitHub answered ${e.status}${e.statusText?` ${e.statusText}`:""}.`),null;return await e.json()}async function hS(){let e=y();if(e)return e;let t=p();if(t)try{let{token:r}=await t.signIn();return E(r),r}catch(r){return w("GitHub sign-in was not completed.",ee(r)),null}let s=await F();if(!s)return null;let{device_code:l,user_code:u,verification_uri:b,interval:n=5}=s;return new Promise((r)=>{let i=!1,o=null,m=0,k=!1,L=(c)=>{if(k)return;if(k=!0,i=!0,o)clearTimeout(o),o=null;r(c)},x=!1,G=()=>{if(x)return;x=!0,D.close()},d=(c)=>{L(c),G()},h=async()=>{if(i)return;try{let a=await(await fetch("https://github.com/login/oauth/access_token",{body:JSON.stringify({client_id:v,device_code:l,grant_type:"urn:ietf:params:oauth:grant-type:device_code"}),headers:{Accept:"application/json","Content-Type":"application/json"},method:"POST"})).json();if(m=0,a.access_token){localStorage.setItem(S,a.access_token),d(a.access_token);return}if(a.error==="authorization_pending"){o=setTimeout(h,n*1000);return}if(a.error==="slow_down"){o=setTimeout(h,(n+5)*1000);return}w("GitHub sign-in was not completed.",a.error==="access_denied"?"The authorization was declined on GitHub.":a.error==="expired_token"?"The device code expired before it was entered.":`GitHub answered "${a.error??"an unrecognised response"}".`),d(null)}catch(c){if(m+=1,m>=Y){I(c),d(null);return}o=setTimeout(h,n*1000)}},D=A({layer:tt("dialog"),onCancel:()=>{G()},onClosed:()=>{d(null)},userCode:u,verificationUri:b});o=setTimeout(h,n*1000)})}
4
4
  export{kT,ET,TT,hS};
5
5
 
6
- //# debugId=71230E3FAF07DF7764756E2164756E21
7
- //# sourceMappingURL=studio-epenqmvk.js.map
6
+ //# debugId=C45E50FFB981EFD364756E2164756E21
7
+ //# sourceMappingURL=studio-fep7hr66.js.map
@@ -1,5 +1,5 @@
1
- import{St,Qn,Ce,We,bh,m,_i,jt}from"./studio-vzgmyt0v.js";import{g}from"./studio-4kzbrr5t.js";import{p}from"./studio-03mqh8ax.js";import{Ht,fn}from"./studio-3w35qvay.js";import{T,R,Ys,tt}from"./studio-jttyqrmh.js";import{Ta,Hd}from"./studio-h310mbqm.js";import{Id,eT,rS,nT,iT}from"./studio-wxdcd42g.js";import{xb,ls,Bl,Tw,Lw,vp,Qo,yp}from"./studio-c1pxszat.js";import{S}from"./studio-45gyxpcq.js";import{n,Z,Q,lf}from"./studio-zkq3r91p.js";var j={$schema:"https://jxsuite.com/schema/v1",$id:"StudioGridOpen",$description:"Every grid-able source a project has, grouped by where it comes from: the project's own pages and content collections first, then each connection's tables. It is the ISLAND of a confirm dialog rather than a dialog of its own — `ui/layers.ts`'s dialog owns the headline, the cancel button, modality and focus, and this document is only the list — because a second answer to \"what is a dialog\" is a defect (studio-ui-guidelines.md §12.5). Group headings are why it is not the kit menu: a menu row can carry a divider above it and cannot carry a name for the run it opens.",tagName:"div",attributes:{part:"sources"},style:{display:"flex",flexDirection:"column",gap:"var(--jx-space-3)",minWidth:"280px",fontFamily:"var(--jx-font-sans)",fontSize:"var(--jx-text-md)",color:"var(--fg)",'& [part="group-title"]':{margin:"0",fontSize:"var(--jx-text-xs)",fontWeight:"600",textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--fg-dim)"},'& [part="rows"]':{display:"flex",flexDirection:"column",gap:"1px",marginTop:"var(--jx-space-1)"},'& [part="source"]':{textAlign:"left",background:"none",border:"none",color:"var(--fg)",font:"inherit",padding:"var(--jx-space-2) var(--jx-space-2)",borderRadius:"var(--jx-radius-sm)",cursor:"pointer"},'& [part="source"]:hover':{background:"var(--bg-hover)"},'& [part="source"]:focus-visible':{outline:"var(--jx-focus-ring)",outlineOffset:"-2px"},'& [part="group-empty"]':{margin:"0",padding:"var(--jx-space-2)",color:"var(--fg-dim)",fontSize:"var(--jx-text-sm)"}},children:[{$prototype:"Array",items:{$ref:"#/state/groups"},key:{$ref:"$map/item/key"},map:{$description:"One origin of grid-able sources. A connection with no tables says why it has none instead of drawing an empty box — an author who has not pushed a schema yet is exactly the reader who needs the sentence.",tagName:"section",attributes:{part:"group","data-group":"${$map.item.key}"},children:[{tagName:"h3",attributes:{part:"group-title"},textContent:"${$map.item.title}"},{tagName:"div",attributes:{part:"rows"},$switch:{$ref:"$map/item/state"},cases:{listed:{tagName:"div",attributes:{part:"rows-list",role:"none"},style:{display:"contents"},children:[{$prototype:"Array",items:{$ref:"$map/item/rows"},key:{$ref:"$map/item/id"},map:{tagName:"button",attributes:{part:"source",type:"button","data-source":"${$map.item.id}"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/open"},value:[{$ref:"$map/item/id"}]}]},textContent:"${$map.item.label}"}}]},empty:{tagName:"p",attributes:{part:"group-empty"},textContent:"${$map.item.emptyMessage}"}}}]}}]};T("grid-open",j);function I(e,r,t){let o=g({groups:r,open:t}),i=null,s=!1,c=R("grid-open",o,e).then((y)=>{let a=y.root;if(s)return y.dispose(),a;return i=y,a});return{dispose(){s=!0,i?.dispose(),i=null},ready:c}}function x(){try{return p()}catch{return null}}function nS(){return Q(x()?.dataRows)}async function K(){let e=x();if(!Q(e?.dataConnections))return null;return e.dataConnections()}async function HD(e){let r=x();if(!Q(r?.dataConnectionTest))return{error:"Connection tests are not supported by this backend",ok:!1};try{return await r.dataConnectionTest(e)}catch(t){return{error:t instanceof Error?t.message:String(t),ok:!1}}}async function YE(e){let r=x();if(!Q(r?.dataPush))return{applied:!1,errors:["Schema push is not supported by this backend"],plan:[]};try{return await r.dataPush(e)}catch(t){return{applied:!1,errors:[t instanceof Error?t.message:String(t)],plan:[]}}}function k(e){let t=x()?.[e];if(t===void 0)throw Error(`The ${String(e)} surface is not supported by this backend`);return t}function v(e){return k("dataRows")(e)}function M(e){return k("dataInsertRow")(e)}function E(e){return k("dataUpdateRow")(e)}function O(e){return k("dataDeleteRow")(e)}function BD(e,r,t){let o=(c)=>c.replaceAll(/([a-z0-9])([A-Z])/g,"$1_$2").replaceAll(/[^A-Za-z0-9]+/g,"_").replaceAll(/^_+|_+$/g,"").toUpperCase(),s=[r??e,t.replace(/Env$/,"")].flatMap((c)=>{let y=o(c);return y?[y]:[]}).join("_")||"SECRET";return/^\d/.test(s)?`JX_${s}`:s}var H=["id","sku","slug","Slug"];function L(e){let r=new Set;return e.map((t,o)=>{let i=t.trim()===""?`column${o+1}`:t;if(r.has(i))i=`${i}__${o+1}`;return r.add(i),i})}function J(e,r){for(let t of H){let o=e.indexOf(t);if(o===-1)continue;let i=r.rows.map((s)=>s[o]??"");if(i.every((s)=>s!=="")&&new Set(i).size===i.length)return t}return null}function A(e,r){let t=Id(e),o=L(t.headers),i=J(o,t),s=i?o.indexOf(i):-1,c=t.rows.map((d,u)=>s===-1?String(u):d[s]),y=new Map(c.map((d,u)=>[d,u])),a=bh(r,S?.projectConfig),l=a?.schema.properties??{},b=t.rows.slice(0,50).map((d)=>{let u={};for(let[C,G]of o.entries())u[G]=d[C]??"";return u}),f=new Map(Lw(b).map((d)=>[d.field,d])),w=new Map(Tw(a?.schema,{idField:i??void 0}).map((d)=>[d.field,d]));return{columns:o.map((d,u)=>{let G=(d in l?w.get(d):void 0)??f.get(d)??{editable:!0,field:d,kind:"string",title:t.headers[u]||d};return{...G,pk:d===i,title:t.headers[u]?.trim()||G.title}}),doc:t,fields:o,keys:c,keyToIndex:y,loadText:e}}function z(e,r){let t={},o=e.doc.rows[r]??[];for(let[i,s]of e.fields.entries()){let c=e.columns[i],y=o[i]??"";t[s]=c.kind==="string"||c.kind==="text"||c.kind==="readonly"?y:vp(y,c)}return t}function F(e,r){let t=e.doc.rows.map((s)=>[...s]),o=(s)=>e.fields.indexOf(s);for(let s of r.cells){let c=e.keyToIndex.get(s.rowKey),y=o(s.field);if(c===void 0||y===-1)continue;t[c][y]=Qo(s.value)}for(let s of r.inserts){let c=e.fields.map((y)=>Qo(s.cells[y]??null));t.push(c)}let i=r.deletes.map((s)=>e.keyToIndex.get(s.rowKey)).filter((s)=>s!==void 0).toSorted((s,c)=>c-s);for(let s of i)t.splice(s,1);return{...e.doc,rows:t}}function _(e,r){return{cells:e.cells.map((t)=>({field:t.field,rowKey:t.rowKey,...r})),deletes:e.deletes.map((t)=>({rowKey:t.rowKey,...r})),inserts:e.inserts.map((t)=>({error:r.error,ok:r.ok,tempKey:t.tempKey}))}}function iS(e){let r=null,t=(o=!1)=>{if(!o&&r)return r;return r=p().readFile(e).then((i)=>A(i,e)),r};return{backingPaths:()=>new Map([[e,"*"]]),capabilities:{delete:!0,insert:!0,remotePaging:!1,remoteSort:!1},async columns(){return(await t()).columns},async commit(o){let i=await t(),s=p(),c=null;try{c=await s.readFile(e)}catch{c=null}if(c!==i.loadText&&!Hd(e))return _(o,{error:"File changed on disk — refresh to reload",ok:!1,stale:!0});let y=F(i,o),a=eT(y);return Ta(e),await s.writeFile(e,a),r=Promise.resolve(A(a,e)),_(o,{ok:!0})},id:e,label:e.split("/").pop()??e,async refresh(){await t(!0)},async rows(){let o=await t(),i=o.doc.rows.map((s,c)=>({cells:z(o,c),key:o.keys[c]}));return{rows:i,total:i.length}},async serializeForSource(o){let i=await t();return eT(F(i,o))}}}var U=50;function q(e){let r=e.toLowerCase();if(/(int|real|floa|doub|num|dec)/.test(r))return"number";if(r.includes("bool"))return"boolean";if(/(timestamp|datetime|date)/.test(r))return"date";return"string"}function W(e){return!e.pk&&e.name!=="created_at"&&e.name!=="updated_at"}function X(e){if(e===void 0)return null;if(lf(e))return e;return JSON.stringify(e)}function N(e,r){let t=[],o="id",i=new Map,s=(a)=>{if(a.length>0)t=a,o=a.find((l)=>l.pk)?.name??"id"},c=(a)=>{let l={table:r};if(e)l.connection=e;if(l.limit=a?.limit??U,l.offset=a?.offset??0,a?.orderBy)l.dir=a.dir??"asc",l.orderBy=a.orderBy;return l},y=(a,l)=>{let b=a[o];if(n(b)||Z(b))return i.set(String(b),b),String(b);return`row-${l}`};return{capabilities:{delete:!0,insert:!0,remotePaging:!0,remoteSort:!0},async columns(){if(t.length===0){let a=await v(c({limit:1,offset:0}));s(a.columns)}return t.map((a)=>{let l=W(a)?q(a.type):"readonly";return{editable:l!=="readonly",field:a.name,kind:l,pk:a.pk===!0,title:a.name,widthHint:a.pk?80:void 0}})},async commit(a){let l={cells:[],deletes:[],inserts:[]},b=new Map;for(let f of a.cells){let w=b.get(f.rowKey)??[];w.push({field:f.field,value:f.value}),b.set(f.rowKey,w)}for(let[f,w]of b){let h=i.get(f),d=(u,C)=>{for(let G of w)l.cells.push({error:C,field:G.field,ok:u,rowKey:f})};if(h===void 0){d(!1,"Row has no primary key — refresh the grid");continue}try{let u={};for(let G of w)u[G.field]=G.value;let C={pk:h,set:u,table:r};if(e)C.connection=e;await E(C),d(!0)}catch(u){d(!1,u instanceof Error?u.message:String(u))}}for(let f of a.inserts)try{let w={};for(let[G,P]of Object.entries(f.cells))if(P!==null)w[G]=P;let h={table:r,values:w};if(e)h.connection=e;let{row:d}=await M(h),u=d[o],C;if(n(u)||Z(u))C=String(u),i.set(C,u);l.inserts.push({newKey:C,ok:!0,tempKey:f.tempKey})}catch(w){l.inserts.push({error:w instanceof Error?w.message:String(w),ok:!1,tempKey:f.tempKey})}for(let f of a.deletes){let w=i.get(f.rowKey);if(w===void 0){l.deletes.push({error:"Row has no primary key — refresh the grid",ok:!1,rowKey:f.rowKey});continue}try{let h={pk:w,table:r};if(e)h.connection=e;await O(h),l.deletes.push({ok:!0,rowKey:f.rowKey})}catch(h){l.deletes.push({error:h instanceof Error?h.message:String(h),ok:!1,rowKey:f.rowKey})}}return l},id:ls({connection:e??"default",kind:"data",table:r}),label:r,async refresh(){t=[],i.clear()},async rows(a){let l=await v(c(a));return s(l.columns),{rows:l.rows.map((f,w)=>{let h=y(f,w),d={};for(let u of t)d[u.name]=X(f[u.name]);return{cells:d,key:h}}),total:l.total}}}}async function ZE(e,r={}){let t=m.tabs.get(e);if(t)return jt(e,{focus:r.focus!==!1}),t;try{await Ht()}catch{}let o=iS(e),i=_i({capabilities:{modes:["grid","source"]},document:structuredClone(xb),documentPath:e,id:e,sourceFormat:fn(e)?.name??null,...r.paneId!==void 0&&{paneId:r.paneId},...r.preview===!0&&{preview:!0},...r.focus===!1&&{focus:!1}});return yp(i,o).load(),i}function D(e){let r=_i({capabilities:{modes:["grid"]},document:structuredClone(xb),documentPath:null,id:e.id});return yp(r,e).load(),r}function zD(e){let r=ls({kind:"collection",name:e}),t=m.tabs.get(r);if(t)return jt(r),t;return D(nT(e))}function oS(){let e=ls({kind:"pages"}),r=m.tabs.get(e);if(r)return jt(e),r;return D(iT())}function V(e,r){let t=ls({connection:e??"default",kind:"data",table:r}),o=m.tabs.get(t);if(o)return jt(t),o;return D(N(e,r))}function Y(e){let r=Bl(e);if(r?.kind==="pages")oS();else if(r?.kind==="collection")zD(r.name);else if(r?.kind==="data")V(r.connection,r.table)}function ee(e,r){return[{emptyMessage:"",key:"project",rows:[{id:ls({kind:"pages"}),label:"Pages"},...e.map(({name:t})=>({id:ls({kind:"collection",name:t}),label:`Collection: ${t}`}))],state:"listed",title:"Project"},...r.map((t)=>({emptyMessage:"No tables — push a schema first.",key:`data:${t.name}`,rows:t.tables.map((o)=>({id:ls({connection:t.name,kind:"data",table:o}),label:o})),state:t.tables.length===0?"empty":"listed",title:`Data · ${t.name}`}))]}async function XE(){let e=rS(),r=[];if(nS())r=(await K().catch(()=>null))?.connections??[];let t=null,o=Ys({cancelLabel:"Cancel",confirmLabel:"",headline:"Open Grid",island:(i)=>{t=I(i,ee(e,r),(s)=>{o.close(),Y(s)})},layer:tt("dialog"),onCancel:()=>o.close(),onClosed:()=>{t?.dispose(),t=null},onConfirm:()=>{},region:"grid/open"});o.ready}function te(){return[{args:Ce({name:We("The content collection's name, as project.json declares it.")}),category:"Project",id:"collection.editInGrid",level:"project",menus:["context/file","palette"],group:"5_data",requires:"a project that declares content collections",when:(e)=>e.project.open,run:(e,r)=>{let t=St("collection.editInGrid",r,"name"),o=rS().map((i)=>i.name);if(!o.includes(t))throw RangeError(`command "collection.editInGrid" argument "name": "${t}" is not a content `+"collection this project declares — it declares: "+`${o.length>0?o.join(", "):"none"}`);zD(t)},title:"Edit Collection in Grid"},{args:{additionalProperties:!1,properties:{connection:We('The connection name from project.json. Defaults to "default".'),table:We("The table to open.")},required:["table"],type:"object"},category:"Project",id:"data.openGrid",level:"project",menus:["palette"],group:"5_data",requires:"a platform that serves the data routes",when:(e)=>e.project.open,enablement:(e)=>e.capability.dataRows,run:(e,r)=>{let t=St("data.openGrid",r,"table");V(Qn("data.openGrid",r,"connection"),t)},title:"Open Data Grid"}]}function QE(e){e.registerAll(te())}
1
+ import{St,ei,Ce,We,bh,m,_i,jt}from"./studio-j933k8nr.js";import{g}from"./studio-ahf3cspq.js";import{p}from"./studio-w67vfgy5.js";import{Ht,fn}from"./studio-848rk4p1.js";import{T,R,Zs,tt}from"./studio-cvz0e00f.js";import{Ta,Bd}from"./studio-dy2xtt7a.js";import{Rd,eT,rS,nT,iT}from"./studio-mwnmzx7g.js";import{xb,ls,Bl,Tw,Lw,vp,Qo,yp}from"./studio-ga77mf07.js";import{S}from"./studio-rt498t2v.js";import{n,Z,Q,lf}from"./studio-zsjpsw08.js";var j={$schema:"https://jxsuite.com/schema/v1",$id:"StudioGridOpen",$description:"Every grid-able source a project has, grouped by where it comes from: the project's own pages and content collections first, then each connection's tables. It is the ISLAND of a confirm dialog rather than a dialog of its own — `ui/layers.ts`'s dialog owns the headline, the cancel button, modality and focus, and this document is only the list — because a second answer to \"what is a dialog\" is a defect (studio-ui-guidelines.md §12.5). Group headings are why it is not the kit menu: a menu row can carry a divider above it and cannot carry a name for the run it opens.",tagName:"div",attributes:{part:"sources"},style:{display:"flex",flexDirection:"column",gap:"var(--jx-space-3)",minWidth:"280px",fontFamily:"var(--jx-font-sans)",fontSize:"var(--jx-text-md)",color:"var(--fg)",'& [part="group-title"]':{margin:"0",fontSize:"var(--jx-text-xs)",fontWeight:"600",textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--fg-dim)"},'& [part="rows"]':{display:"flex",flexDirection:"column",gap:"1px",marginTop:"var(--jx-space-1)"},'& [part="source"]':{textAlign:"left",background:"none",border:"none",color:"var(--fg)",font:"inherit",padding:"var(--jx-space-2) var(--jx-space-2)",borderRadius:"var(--jx-radius-sm)",cursor:"pointer"},'& [part="source"]:hover':{background:"var(--bg-hover)"},'& [part="source"]:focus-visible':{outline:"var(--jx-focus-ring)",outlineOffset:"-2px"},'& [part="group-empty"]':{margin:"0",padding:"var(--jx-space-2)",color:"var(--fg-dim)",fontSize:"var(--jx-text-sm)"}},children:[{$prototype:"Array",items:{$ref:"#/state/groups"},key:{$ref:"$map/item/key"},map:{$description:"One origin of grid-able sources. A connection with no tables says why it has none instead of drawing an empty box — an author who has not pushed a schema yet is exactly the reader who needs the sentence.",tagName:"section",attributes:{part:"group","data-group":"${$map.item.key}"},children:[{tagName:"h3",attributes:{part:"group-title"},textContent:"${$map.item.title}"},{tagName:"div",attributes:{part:"rows"},$switch:{$ref:"$map/item/state"},cases:{listed:{tagName:"div",attributes:{part:"rows-list",role:"none"},style:{display:"contents"},children:[{$prototype:"Array",items:{$ref:"$map/item/rows"},key:{$ref:"$map/item/id"},map:{tagName:"button",attributes:{part:"source",type:"button","data-source":"${$map.item.id}"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/open"},value:[{$ref:"$map/item/id"}]}]},textContent:"${$map.item.label}"}}]},empty:{tagName:"p",attributes:{part:"group-empty"},textContent:"${$map.item.emptyMessage}"}}}]}}]};T("grid-open",j);function I(e,r,t){let o=g({groups:r,open:t}),i=null,s=!1,c=R("grid-open",o,e).then((y)=>{let a=y.root;if(s)return y.dispose(),a;return i=y,a});return{dispose(){s=!0,i?.dispose(),i=null},ready:c}}function x(){try{return p()}catch{return null}}function nS(){return Q(x()?.dataRows)}async function K(){let e=x();if(!Q(e?.dataConnections))return null;return e.dataConnections()}async function HD(e){let r=x();if(!Q(r?.dataConnectionTest))return{error:"Connection tests are not supported by this backend",ok:!1};try{return await r.dataConnectionTest(e)}catch(t){return{error:t instanceof Error?t.message:String(t),ok:!1}}}async function YE(e){let r=x();if(!Q(r?.dataPush))return{applied:!1,errors:["Schema push is not supported by this backend"],plan:[]};try{return await r.dataPush(e)}catch(t){return{applied:!1,errors:[t instanceof Error?t.message:String(t)],plan:[]}}}function k(e){let t=x()?.[e];if(t===void 0)throw Error(`The ${String(e)} surface is not supported by this backend`);return t}function v(e){return k("dataRows")(e)}function M(e){return k("dataInsertRow")(e)}function E(e){return k("dataUpdateRow")(e)}function O(e){return k("dataDeleteRow")(e)}function BD(e,r,t){let o=(c)=>c.replaceAll(/([a-z0-9])([A-Z])/g,"$1_$2").replaceAll(/[^A-Za-z0-9]+/g,"_").replaceAll(/^_+|_+$/g,"").toUpperCase(),s=[r??e,t.replace(/Env$/,"")].flatMap((c)=>{let y=o(c);return y?[y]:[]}).join("_")||"SECRET";return/^\d/.test(s)?`JX_${s}`:s}var H=["id","sku","slug","Slug"];function L(e){let r=new Set;return e.map((t,o)=>{let i=t.trim()===""?`column${o+1}`:t;if(r.has(i))i=`${i}__${o+1}`;return r.add(i),i})}function J(e,r){for(let t of H){let o=e.indexOf(t);if(o===-1)continue;let i=r.rows.map((s)=>s[o]??"");if(i.every((s)=>s!=="")&&new Set(i).size===i.length)return t}return null}function A(e,r){let t=Rd(e),o=L(t.headers),i=J(o,t),s=i?o.indexOf(i):-1,c=t.rows.map((d,u)=>s===-1?String(u):d[s]),y=new Map(c.map((d,u)=>[d,u])),a=bh(r,S?.projectConfig),l=a?.schema.properties??{},b=t.rows.slice(0,50).map((d)=>{let u={};for(let[C,G]of o.entries())u[G]=d[C]??"";return u}),f=new Map(Lw(b).map((d)=>[d.field,d])),w=new Map(Tw(a?.schema,{idField:i??void 0}).map((d)=>[d.field,d]));return{columns:o.map((d,u)=>{let G=(d in l?w.get(d):void 0)??f.get(d)??{editable:!0,field:d,kind:"string",title:t.headers[u]||d};return{...G,pk:d===i,title:t.headers[u]?.trim()||G.title}}),doc:t,fields:o,keys:c,keyToIndex:y,loadText:e}}function z(e,r){let t={},o=e.doc.rows[r]??[];for(let[i,s]of e.fields.entries()){let c=e.columns[i],y=o[i]??"";t[s]=c.kind==="string"||c.kind==="text"||c.kind==="readonly"?y:vp(y,c)}return t}function F(e,r){let t=e.doc.rows.map((s)=>[...s]),o=(s)=>e.fields.indexOf(s);for(let s of r.cells){let c=e.keyToIndex.get(s.rowKey),y=o(s.field);if(c===void 0||y===-1)continue;t[c][y]=Qo(s.value)}for(let s of r.inserts){let c=e.fields.map((y)=>Qo(s.cells[y]??null));t.push(c)}let i=r.deletes.map((s)=>e.keyToIndex.get(s.rowKey)).filter((s)=>s!==void 0).toSorted((s,c)=>c-s);for(let s of i)t.splice(s,1);return{...e.doc,rows:t}}function _(e,r){return{cells:e.cells.map((t)=>({field:t.field,rowKey:t.rowKey,...r})),deletes:e.deletes.map((t)=>({rowKey:t.rowKey,...r})),inserts:e.inserts.map((t)=>({error:r.error,ok:r.ok,tempKey:t.tempKey}))}}function iS(e){let r=null,t=(o=!1)=>{if(!o&&r)return r;return r=p().readFile(e).then((i)=>A(i,e)),r};return{backingPaths:()=>new Map([[e,"*"]]),capabilities:{delete:!0,insert:!0,remotePaging:!1,remoteSort:!1},async columns(){return(await t()).columns},async commit(o){let i=await t(),s=p(),c=null;try{c=await s.readFile(e)}catch{c=null}if(c!==i.loadText&&!Bd(e))return _(o,{error:"File changed on disk — refresh to reload",ok:!1,stale:!0});let y=F(i,o),a=eT(y);return Ta(e),await s.writeFile(e,a),r=Promise.resolve(A(a,e)),_(o,{ok:!0})},id:e,label:e.split("/").pop()??e,async refresh(){await t(!0)},async rows(){let o=await t(),i=o.doc.rows.map((s,c)=>({cells:z(o,c),key:o.keys[c]}));return{rows:i,total:i.length}},async serializeForSource(o){let i=await t();return eT(F(i,o))}}}var U=50;function q(e){let r=e.toLowerCase();if(/(int|real|floa|doub|num|dec)/.test(r))return"number";if(r.includes("bool"))return"boolean";if(/(timestamp|datetime|date)/.test(r))return"date";return"string"}function W(e){return!e.pk&&e.name!=="created_at"&&e.name!=="updated_at"}function X(e){if(e===void 0)return null;if(lf(e))return e;return JSON.stringify(e)}function N(e,r){let t=[],o="id",i=new Map,s=(a)=>{if(a.length>0)t=a,o=a.find((l)=>l.pk)?.name??"id"},c=(a)=>{let l={table:r};if(e)l.connection=e;if(l.limit=a?.limit??U,l.offset=a?.offset??0,a?.orderBy)l.dir=a.dir??"asc",l.orderBy=a.orderBy;return l},y=(a,l)=>{let b=a[o];if(n(b)||Z(b))return i.set(String(b),b),String(b);return`row-${l}`};return{capabilities:{delete:!0,insert:!0,remotePaging:!0,remoteSort:!0},async columns(){if(t.length===0){let a=await v(c({limit:1,offset:0}));s(a.columns)}return t.map((a)=>{let l=W(a)?q(a.type):"readonly";return{editable:l!=="readonly",field:a.name,kind:l,pk:a.pk===!0,title:a.name,widthHint:a.pk?80:void 0}})},async commit(a){let l={cells:[],deletes:[],inserts:[]},b=new Map;for(let f of a.cells){let w=b.get(f.rowKey)??[];w.push({field:f.field,value:f.value}),b.set(f.rowKey,w)}for(let[f,w]of b){let h=i.get(f),d=(u,C)=>{for(let G of w)l.cells.push({error:C,field:G.field,ok:u,rowKey:f})};if(h===void 0){d(!1,"Row has no primary key — refresh the grid");continue}try{let u={};for(let G of w)u[G.field]=G.value;let C={pk:h,set:u,table:r};if(e)C.connection=e;await E(C),d(!0)}catch(u){d(!1,u instanceof Error?u.message:String(u))}}for(let f of a.inserts)try{let w={};for(let[G,P]of Object.entries(f.cells))if(P!==null)w[G]=P;let h={table:r,values:w};if(e)h.connection=e;let{row:d}=await M(h),u=d[o],C;if(n(u)||Z(u))C=String(u),i.set(C,u);l.inserts.push({newKey:C,ok:!0,tempKey:f.tempKey})}catch(w){l.inserts.push({error:w instanceof Error?w.message:String(w),ok:!1,tempKey:f.tempKey})}for(let f of a.deletes){let w=i.get(f.rowKey);if(w===void 0){l.deletes.push({error:"Row has no primary key — refresh the grid",ok:!1,rowKey:f.rowKey});continue}try{let h={pk:w,table:r};if(e)h.connection=e;await O(h),l.deletes.push({ok:!0,rowKey:f.rowKey})}catch(h){l.deletes.push({error:h instanceof Error?h.message:String(h),ok:!1,rowKey:f.rowKey})}}return l},id:ls({connection:e??"default",kind:"data",table:r}),label:r,async refresh(){t=[],i.clear()},async rows(a){let l=await v(c(a));return s(l.columns),{rows:l.rows.map((f,w)=>{let h=y(f,w),d={};for(let u of t)d[u.name]=X(f[u.name]);return{cells:d,key:h}}),total:l.total}}}}async function ZE(e,r={}){let t=m.tabs.get(e);if(t)return jt(e,{focus:r.focus!==!1}),t;try{await Ht()}catch{}let o=iS(e),i=_i({capabilities:{modes:["grid","source"]},document:structuredClone(xb),documentPath:e,id:e,sourceFormat:fn(e)?.name??null,...r.paneId!==void 0&&{paneId:r.paneId},...r.preview===!0&&{preview:!0},...r.focus===!1&&{focus:!1}});return yp(i,o).load(),i}function D(e){let r=_i({capabilities:{modes:["grid"]},document:structuredClone(xb),documentPath:null,id:e.id});return yp(r,e).load(),r}function zD(e){let r=ls({kind:"collection",name:e}),t=m.tabs.get(r);if(t)return jt(r),t;return D(nT(e))}function oS(){let e=ls({kind:"pages"}),r=m.tabs.get(e);if(r)return jt(e),r;return D(iT())}function V(e,r){let t=ls({connection:e??"default",kind:"data",table:r}),o=m.tabs.get(t);if(o)return jt(t),o;return D(N(e,r))}function Y(e){let r=Bl(e);if(r?.kind==="pages")oS();else if(r?.kind==="collection")zD(r.name);else if(r?.kind==="data")V(r.connection,r.table)}function ee(e,r){return[{emptyMessage:"",key:"project",rows:[{id:ls({kind:"pages"}),label:"Pages"},...e.map(({name:t})=>({id:ls({kind:"collection",name:t}),label:`Collection: ${t}`}))],state:"listed",title:"Project"},...r.map((t)=>({emptyMessage:"No tables — push a schema first.",key:`data:${t.name}`,rows:t.tables.map((o)=>({id:ls({connection:t.name,kind:"data",table:o}),label:o})),state:t.tables.length===0?"empty":"listed",title:`Data · ${t.name}`}))]}async function XE(){let e=rS(),r=[];if(nS())r=(await K().catch(()=>null))?.connections??[];let t=null,o=Zs({cancelLabel:"Cancel",confirmLabel:"",headline:"Open Grid",island:(i)=>{t=I(i,ee(e,r),(s)=>{o.close(),Y(s)})},layer:tt("dialog"),onCancel:()=>o.close(),onClosed:()=>{t?.dispose(),t=null},onConfirm:()=>{},region:"grid/open"});o.ready}function te(){return[{args:Ce({name:We("The content collection's name, as project.json declares it.")}),category:"Project",id:"collection.editInGrid",level:"project",menus:["context/file","palette"],group:"5_data",requires:"a project that declares content collections",when:(e)=>e.project.open,run:(e,r)=>{let t=St("collection.editInGrid",r,"name"),o=rS().map((i)=>i.name);if(!o.includes(t))throw RangeError(`command "collection.editInGrid" argument "name": "${t}" is not a content `+"collection this project declares — it declares: "+`${o.length>0?o.join(", "):"none"}`);zD(t)},title:"Edit Collection in Grid"},{args:{additionalProperties:!1,properties:{connection:We('The connection name from project.json. Defaults to "default".'),table:We("The table to open.")},required:["table"],type:"object"},category:"Project",id:"data.openGrid",level:"project",menus:["palette"],group:"5_data",requires:"a platform that serves the data routes",when:(e)=>e.project.open,enablement:(e)=>e.capability.dataRows,run:(e,r)=>{let t=St("data.openGrid",r,"table");V(ei("data.openGrid",r,"connection"),t)},title:"Open Data Grid"}]}function QE(e){e.registerAll(te())}
2
2
  export{nS,HD,YE,BD,iS,ZE,zD,oS,XE,QE};
3
3
 
4
- //# debugId=D0EF90634B3E5AF864756E2164756E21
5
- //# sourceMappingURL=studio-2ks6ka4g.js.map
4
+ //# debugId=3A5A4F20D7428D6464756E2164756E21
5
+ //# sourceMappingURL=studio-fyf7j57j.js.map
@@ -1,5 +1,5 @@
1
- import{Ht,Wi,fn,lr,Aa}from"./studio-3w35qvay.js";import{C}from"./studio-4kzbrr5t.js";import{Pn,Kc,St,Hi,Ce,To,We,Wd,u}from"./studio-vzgmyt0v.js";import{Lo}from"./studio-ry81j4q1.js";import{te}from"./studio-psh8mwnw.js";import{lm}from"./studio-zg16eeq1.js";import{_a}from"./studio-34jrz12k.js";import{WD,tT}from"./studio-wxdcd42g.js";import{Co}from"./studio-5wzdy1jc.js";import{yr,Zu}from"./studio-pqqq6v85.js";import{lw,lb}from"./studio-jw0q5j6k.js";import{ab}from"./studio-zgx7svjd.js";import{Ml}from"./studio-dbxv7w4s.js";import{ya,Ic,GE}from"./studio-d038kqbs.js";import{as,fb}from"./studio-s0fg2wav.js";import{v}from"./studio-zkq3r91p.js";import{le}from"./studio-7xag4na8.js";var nb=["page","collection","template","component","media","entry"],nw={collection:{cta:"Create collection",hint:"Posts, products, team… with a page each",icon:"stack",id:"collection",label:"Collection",nameLabel:"Collection name",placeholder:"Recipes"},component:{cta:"Create component",hint:"A reusable block for any page",icon:"cube",id:"component",label:"Component",nameLabel:"Component name",placeholder:"Pricing table"},entry:{cta:"Create entry",hint:"A new item in a collection",icon:"file-text",id:"entry",label:"Entry",nameLabel:"Entry name",placeholder:"My first post"},media:{cta:"Upload",hint:"Images, video, documents",icon:"image",id:"media",label:"Media",nameLabel:"",placeholder:""},page:{cta:"Create page",hint:"A new URL on your site",icon:"file",id:"page",label:"Page",nameLabel:"Page name",placeholder:"Pricing"},template:{cta:"Create template",hint:"Shared frame that pages sit inside",icon:"frame-corners",id:"template",label:"Template",nameLabel:"Template name",placeholder:"Landing"}},Hs="blank",$c="article",P_="selection",sm="copy",iw=["title","image","richText","date","tags","number","link"],F_={date:{key:"date",label:"Date",schema:{format:"date",type:"string"}},image:{key:"cover",label:"Image",schema:{format:"image",type:"string"}},link:{key:"link",label:"Link",schema:{format:"uri",type:"string"}},number:{key:"number",label:"Number",schema:{type:"number"}},richText:{key:null,label:"Rich text",schema:null},tags:{key:"tags",label:"Tags",schema:{items:{type:"string"},type:"array"}},title:{key:"title",label:"Title",schema:{type:"string"}}},hE=["title","image","richText"];function p(e,n){return e==="."||e===""?n:`${e}/${n}`}function Qa(e){return e.replace(/^\.\//,"")}function j_(e,n){let t=n.defaultLayout;if(e===Hs||e==="")return t?!1:void 0;if(t&&Qa(t)===Qa(e))return;return e}function Mu(e){let n=e.defaultLayout;if(n)return e.layouts.find((r)=>Qa(r.ref)===Qa(n))?.ref??n;return e.layouts[0]?.ref??Hs}function H_(e,n){let t=Pn(n??"");if(t!==null){let r=e.layouts.find((o)=>Qa(o.ref).replace(/\.json$/i,"").split("/").some((l)=>Pn(l)===t));if(r)return r.ref}return Mu(e)}function R(e){return e.trim().replaceAll("\\","/").split("/").map((n)=>as(n)).filter((n)=>n!=="")}function I(e){let n={};for(let r of iw){let o=F_[r];if(e.includes(r)&&o.key!==null&&o.schema!==null)n[o.key]={...o.schema}}let t={properties:n,type:"object"};if(e.includes("title"))t.required=["title"];return t}function cD(e,n){let t=e?.properties??{};return iw.filter((r)=>{let{key:o}=F_[r];return o===null?n:Object.hasOwn(t,o)})}function w(e,n){let t=GE(e.schema);if(n!==void 0&&n!==""&&e.schema?.properties?.title!==void 0)t.title=n;if(e.ext===".json"||e.formatName===null)return{doc:t,format:null};return{doc:{...t,children:[]},format:e.formatName,frontmatter:Object.keys(t).length>0}}function pE(e,n,t,r){let o=[];if(n.includes("title"))o.push({tagName:"h1",textContent:"${state.entry.data.title}"});if(n.includes("image"))o.push({attributes:{alt:n.includes("title")?"${state.entry.data.title}":"",loading:"lazy",src:"${state.entry.data.cover}"},tagName:"img"});if(n.includes("richText")&&r.contentFormat!==null)o.push({children:"${state.entry.$children}",tagName:"div"});let i={};if(t!==void 0)i.$layout=t;return i.$paths={contentType:e,field:"id",param:"slug"},i.title=n.includes("title")?"${state.entry.data.title}":Zu(e),i.state={entry:{$prototype:"ContentEntry",$src:"@jxsuite/parser/ContentEntry.class.json",contentType:e,field:"id",id:{$ref:"#/$params/slug"}}},i.tagName="article",i.children=o,i}function am(e,n){let t=n.i18n??null,r=Pn(e);return t!==null&&r!==null&&t.locales.includes(r)?r:null}function ib(e){return e.dir.includes(Lo)}function _(e,n){return e.localeDirs?.[n]??e.dir.replace(Lo,n.toLowerCase())}function E(e,n,t){let r=t.i18n??null;if(n===null||r===null)return e;return Kc(e,n,{...r,locales:[...r.locales]})??e}function J(e){let n=e.lastIndexOf("/");return n===-1?[".",e]:[e.slice(0,n),e.slice(n+1)]}function W(e,n,t){if(n.startFrom===sm&&n.copyOf!==void 0){let r=t.componentDocs?.get(n.copyOf);if(r){let o=JSON.parse(JSON.stringify(r));return delete o.$id,o.tagName=e,o}}return{children:[],tagName:e}}function B(e,n,t){let r=n.startFrom??Mu(t),o=r===$c&&t.article!==null?t.article:null,i=o?.ext??".json",l=n.url===void 0?[as(e)].filter((m)=>m!==""):R(n.url),a=l.length===0?n.url===void 0?"":"index":l.at(-1),s=["pages",...l.slice(0,-1)].join("/"),c=a===""?"":`${a}${i}`,f=am(n.locale,t),d=c===""?p(s,c):E(p(s,c),f,t),b=c===""?s:J(d)[0],g=e.trim(),y;if(o)y={doc:{children:[{tagName:"h1",textContent:g}],title:g},format:o.name,frontmatter:!0};else{let m={},h=j_(r===$c?Hs:r,t);if(h!==void 0)m.$layout=h;m.title=g,m.tagName="main",m.children=[{tagName:"h1",textContent:g}],y={doc:m,format:null}}let N=c===""?"":yr(d).urlPattern;return{content:y,dir:b,ext:i,extraWrites:[],fileName:c,kind:"page",path:d,route:N,saved:c===""?"":`Saved as ${d} · opens at ${N}`}}function K(e,n,t){let r=as(e),o=n.fields??hE,i=t.i18n??null,l=i!==null&&n.localized!==!1,a=`content/${r}`,s=l?`${a}/${i.defaultLocale.toLowerCase()}`:a,c=t.contentFormat,f=c?.ext??".json",d=Zu(r),b=r===""?"":`first-${d.replaceAll(" ","-")}${f}`,g=I(o),y=structuredClone(g),N={format:c?.name??"json",schema:v(y)?y:{},source:l?`./${a}/${Lo}`:`./${a}`},m=w({ext:f,formatName:c?.name??null,schema:g},`First ${d}`),h=[],k,L="";if(n.ownPage!==!1&&r!==""){let j=n.pageTemplate??Mu(t),D=l?[i.defaultLocale,...i.locales.filter((x)=>x!==i.defaultLocale)]:[null],T=[];for(let x of D){let O=E(`pages/${r}/[slug].json`,x,t),A=x===null||j!==Mu(t)?j:H_(t,x);k??=yr(O).urlPattern,h.push({body:{doc:pE(r,o,j_(A,t),t),format:null},path:O}),T.push(O)}L=T.length===1?`, and ${T[0]} at ${k}`:`, and a page in each language (${T.join(", ")})`}let P={config:{entry:N,name:r},content:m,dir:s,ext:f,extraWrites:h,fileName:b,kind:"collection",path:p(s,b),saved:r===""?"":l?`Adds a “${r}” collection to project.json with one folder per language under ${a}/, a first entry in ${s}/${L}.`:`Adds a “${r}” collection to project.json, a ${s}/ folder with a first entry${L}.`};if(k!==void 0)P.route=k;return P}function M(e,n){let t=as(e),r=t===""?"":`${t}.json`,o=p("layouts",r),i={},l=n.startFrom??"";if(l!==""&&l!==Hs)i.$layout=l;return i.tagName="div",i.children=[{children:[{tagName:"slot"}],tagName:"main"}],{content:{doc:i,format:null},dir:"layouts",ext:".json",extraWrites:[],fileName:r,kind:"template",path:o,saved:r===""?"":`Saved as ${o} with one slot.`}}function z(e,n,t){let r=lb(e),o=r===""?"":`${r}.json`,i=p("components",o);return{content:{doc:W(r,n,t),format:null},dir:"components",ext:".json",extraWrites:[],fileName:o,kind:"component",path:i,saved:o===""?"":`Saved as ${i} with tag <${r}>.`,tag:r}}function U(e,n,t){let r=t.collections.find((d)=>d.name===n.collection)??null,o=as(e),i=r?.ext??".json",l=am(n.locale,t),a=r!==null&&ib(r)&&l===null,s=r===null?"content":ib(r)&&l!==null?_(r,l):r.dir,c=o===""||r===null||a?"":`${o}${i}`,f=p(s,c);return{content:r?w(r,e.trim()):{doc:{},format:null},dir:s,ext:i,extraWrites:[],fileName:c,kind:"entry",path:f,saved:c===""?"":`Saved as ${f} in ${r.name}.`}}function fE(e,n,t,r){switch(e){case"page":return B(n,t,r);case"collection":return K(n,t,r);case"template":return M(n,t);case"component":return z(n,t,r);case"entry":return U(n,t,r);default:{let o=t.files??0;return{content:{doc:{},format:null},dir:_a,ext:"",extraWrites:[],fileName:"",kind:e,path:_a,saved:o===0?`Saved under ${_a}/. No folder to choose.`:`${o===1?"1 file":`${o} files`} will be saved under ${_a}/.`}}}}function q(e,n){let t=e.lastIndexOf("/"),r=t===-1?".":e.slice(0,t),o=n(r);return fb(e.slice(t+1),"",{dir:r,taken:o??new Set})}function S(e){if(e.kind!=="page"||e.fileName==="")return[];let n=e.fileName.slice(0,e.fileName.length-e.ext.length);if(n!=="index")return[{dir:e.dir,stem:n},{dir:p(e.dir,n),stem:"index"}];let t=e.dir.lastIndexOf("/");if(t===-1)return[{dir:e.dir,stem:n}];return[{dir:e.dir,stem:n},{dir:e.dir.slice(0,t),stem:e.dir.slice(t+1)}]}function V(e,n){let t=e.fileName.toLowerCase();for(let{dir:r,stem:o}of S(e)){let i=`${o.toLowerCase()}.`;for(let l of n(r)??[])if(l.startsWith(i)&&!(r===e.dir&&l===t))return p(r,l)}return null}function H(e){return fb(e,"",{choice:{ext:"",kind:"fixed"},dir:".",taken:new Set})}function mE(e,n,t,r,o){if(e.kind==="media")return(t.files??0)===0?"Drop files here, or browse for them.":"";let i=H(n);if(i!=="")return i;switch(e.kind){case"page":{if(t.url!==void 0){if(t.url.replaceAll("\\","/").split("/").includes(".."))return"A URL cannot step outside the site.";if(!t.url.trim().startsWith("/"))return"A URL starts with a slash, such as /pricing."}let a=V(e,o);if(a!==null)return`${a} already opens at ${e.route??"/"}.`;break}case"component":{let a=e.tag??"",s=lw(a);if(s!=="")return s;if(r.componentTags.includes(a))return`A component named <${a}> already exists.`;if(t.startFrom===P_&&r.hasSelection!==!0)return"Select an element on the canvas to make a component from it.";if(t.startFrom===sm&&(t.copyOf===void 0||r.componentDocs?.get(t.copyOf)===void 0))return"Choose the component to copy.";break}case"collection":{let a=e.config?.name??"";if(r.declaredContent.includes(a))return`A collection named “${a}” already exists.`;if(o("content")?.has(a)===!0)return`content/${a}/ already exists.`;break}case"entry":{let a=r.collections.find((s)=>s.name===t.collection);if(!a)return"Choose the collection this entry belongs to.";if(ib(a)&&am(t.locale,r)===null)return`Choose the language this ${Zu(a.name)} is written in.`;break}default:break}let l=[...e.kind==="collection"?[]:[e.path],...e.extraWrites.map((a)=>a.path)];for(let a of l){let s=q(a,o);if(s!=="")return s}return""}function gE(e){let n=new Set,t=(r)=>{let o=r.lastIndexOf("/");n.add(o===-1?".":r.slice(0,o))};if(e.kind==="media")return[];if(e.kind==="collection")n.add("content");else if(e.fileName!=="")t(e.path);for(let r of e.extraWrites)t(r.path);for(let{dir:r}of S(e))n.add(r);return[...n]}function dD(e){let n=(r)=>r==="."?0:r.split("/").length,t=new Map;for(let r of e){let o=n(r);t.set(o,[...t.get(o)??[],r])}return[...t.entries()].toSorted(([r],[o])=>r-o).map(([,r])=>r)}function uD(e,n){if(e===".")return!1;let t=e.lastIndexOf("/"),r=n.get(t===-1?".":e.slice(0,t));return r!==void 0&&!r.has(e.slice(t+1).toLowerCase())}function B_(e){if(e.ext===".json")return null;return(e.def.format?Wi(e.def.format)?.name:void 0)??fn(`untitled${e.ext}`)?.name??lr()?.name??null}async function G(e){let n=w({ext:e.ext,formatName:B_(e),schema:e.schema});if(n.format===null)return Co(n.doc,null);return Aa(n.format,n.doc,{frontmatter:n.frontmatter??!1,mode:"roundtrip"})}async function Z2(e,n={}){let t=ya(e);if(!t)return C.error(`No content collection named "${e}" to create an entry in.`,{detail:"A collection needs a `content` entry in project.json whose `source` is a directory. A collection whose source names a single file (a CSV catalogue) has rows, not entry files.",source:"Content"}),null;await Ht().catch(()=>{});let r;try{r=await G(t)}catch(s){return C.error(`Could not prepare a new ${t.name} entry.`,{detail:te(s),path:t.dir,source:"Content"}),null}let o=n.dir,i=o!==void 0&&Wd(o)?.name===t.name?o:t.dir;if(i.includes(Lo))return C.error(`"${t.name}" is a localized collection.`,{detail:`Its entries live in one directory per language (${t.dir}). Open the folder for the language you are writing in and create the entry there.`,path:t.dir,source:"Content"}),null;let{createFileIn:l}=await (le("de90apn9"),import("./files-de90apn9.js")),a=await l({content:r,dir:i,format:{ext:t.ext,kind:"fixed"},source:"Content",suggestedName:"untitled",title:`New ${t.name} entry`});if(a===null)return null;return lm(t.name),await Ml(a),a}function F(){let e=u.value;return e&&Ic(e.documentPath)?e:null}function Y(){return[{args:Ce({path:We("Project-relative path of the entry file to open.")}),category:"File",id:"content.openEntry",level:"project",menus:["context/file","palette"],group:"1_file",requires:"an open project",when:(e)=>e.project.open,run:async(e,n)=>{await Ml(St("content.openEntry",n,"path"))},title:"Open Entry"},{args:Ce({draft:To("True marks the open entry a draft; false marks it published. Written as a `draft` field on the entry.")}),category:"Document",id:"content.setDraft",level:"document",menus:["context/tab","palette"],group:"3_document",requires:"a content entry open",when:(e)=>e.document.open,enablement:()=>F()!==null,undo:"document",run:(e,n)=>{let t=F();if(!t)throw Error("content.setDraft: the active document is not a content entry");ab(t,Hi("content.setDraft",n,"draft"))},title:"Set Draft"},{args:Ce({include:To("True lists entries marked `draft: true` alongside the rest.")}),category:"View",id:"content.setIncludeDrafts",level:"project",menus:["palette"],group:"2_view",requires:"an open project",when:(e)=>e.project.open,run:async(e,n)=>{WD(Hi("content.setIncludeDrafts",n,"include")),await tT()},title:"Include Drafts"}]}function bE(e){e.registerAll(Y())}
2
- export{nb,nw,Hs,$c,P_,sm,iw,F_,hE,Qa,j_,Mu,H_,cD,pE,am,ib,fE,mE,gE,dD,uD,B_,Z2,bE};
1
+ import{Ht,Wi,fn,lr,Aa}from"./studio-848rk4p1.js";import{C}from"./studio-ahf3cspq.js";import{Pn,Jc,St,Hi,Ce,To,We,Vd,h}from"./studio-j933k8nr.js";import{Lo}from"./studio-4nkm4404.js";import{ee}from"./studio-et6t8g4m.js";import{lm}from"./studio-pzfa2vmb.js";import{_a}from"./studio-20ap8dds.js";import{WD,tT}from"./studio-mwnmzx7g.js";import{Co}from"./studio-dbgv4fv9.js";import{yr,Zu}from"./studio-695k95bw.js";import{lw,lb}from"./studio-jw0q5j6k.js";import{ab}from"./studio-bkmv1h3e.js";import{Ml}from"./studio-jgbvqcgh.js";import{wa,Rc,GE}from"./studio-56egy6vf.js";import{as,fb}from"./studio-s0fg2wav.js";import{v}from"./studio-zsjpsw08.js";import{le}from"./studio-0g2sm01j.js";var nb=["page","collection","template","component","media","entry"],nw={collection:{cta:"Create collection",hint:"Posts, products, team… with a page each",icon:"stack",id:"collection",label:"Collection",nameLabel:"Collection name",placeholder:"Recipes"},component:{cta:"Create component",hint:"A reusable block for any page",icon:"cube",id:"component",label:"Component",nameLabel:"Component name",placeholder:"Pricing table"},entry:{cta:"Create entry",hint:"A new item in a collection",icon:"file-text",id:"entry",label:"Entry",nameLabel:"Entry name",placeholder:"My first post"},media:{cta:"Upload",hint:"Images, video, documents",icon:"image",id:"media",label:"Media",nameLabel:"",placeholder:""},page:{cta:"Create page",hint:"A new URL on your site",icon:"file",id:"page",label:"Page",nameLabel:"Page name",placeholder:"Pricing"},template:{cta:"Create template",hint:"Shared frame that pages sit inside",icon:"frame-corners",id:"template",label:"Template",nameLabel:"Template name",placeholder:"Landing"}},Bs="blank",Ic="article",P_="selection",sm="copy",iw=["title","image","richText","date","tags","number","link"],F_={date:{key:"date",label:"Date",schema:{format:"date",type:"string"}},image:{key:"cover",label:"Image",schema:{format:"image",type:"string"}},link:{key:"link",label:"Link",schema:{format:"uri",type:"string"}},number:{key:"number",label:"Number",schema:{type:"number"}},richText:{key:null,label:"Rich text",schema:null},tags:{key:"tags",label:"Tags",schema:{items:{type:"string"},type:"array"}},title:{key:"title",label:"Title",schema:{type:"string"}}},hE=["title","image","richText"];function f(e,n){return e==="."||e===""?n:`${e}/${n}`}function Qa(e){return e.replace(/^\.\//,"")}function j_(e,n){let t=n.defaultLayout;if(e===Bs||e==="")return t?!1:void 0;if(t&&Qa(t)===Qa(e))return;return e}function Mu(e){let n=e.defaultLayout;if(n)return e.layouts.find((r)=>Qa(r.ref)===Qa(n))?.ref??n;return e.layouts[0]?.ref??Bs}function H_(e,n){let t=Pn(n??"");if(t!==null){let r=e.layouts.find((o)=>Qa(o.ref).replace(/\.json$/i,"").split("/").some((l)=>Pn(l)===t));if(r)return r.ref}return Mu(e)}function R(e){return e.trim().replaceAll("\\","/").split("/").map((n)=>as(n)).filter((n)=>n!=="")}function I(e){let n={};for(let r of iw){let o=F_[r];if(e.includes(r)&&o.key!==null&&o.schema!==null)n[o.key]={...o.schema}}let t={properties:n,type:"object"};if(e.includes("title"))t.required=["title"];return t}function cD(e,n){let t=e?.properties??{};return iw.filter((r)=>{let{key:o}=F_[r];return o===null?n:Object.hasOwn(t,o)})}function w(e,n){let t=GE(e.schema);if(n!==void 0&&n!==""&&e.schema?.properties?.title!==void 0)t.title=n;if(e.ext===".json"||e.formatName===null)return{doc:t,format:null};return{doc:{...t,children:[]},format:e.formatName,frontmatter:Object.keys(t).length>0}}function pE(e,n,t,r){let o=[];if(n.includes("title"))o.push({tagName:"h1",textContent:"${state.entry.data.title}"});if(n.includes("image"))o.push({attributes:{alt:n.includes("title")?"${state.entry.data.title}":"",loading:"lazy",src:"${state.entry.data.cover}"},tagName:"img"});if(n.includes("richText")&&r.contentFormat!==null)o.push({children:"${state.entry.$children}",tagName:"div"});let i={};if(t!==void 0)i.$layout=t;return i.$paths={contentType:e,field:"id",param:"slug"},i.title=n.includes("title")?"${state.entry.data.title}":Zu(e),i.state={entry:{$prototype:"ContentEntry",$src:"@jxsuite/parser/ContentEntry.class.json",contentType:e,field:"id",id:{$ref:"#/$params/slug"}}},i.tagName="article",i.children=o,i}function am(e,n){let t=n.i18n??null,r=Pn(e);return t!==null&&r!==null&&t.locales.includes(r)?r:null}function ib(e){return e.dir.includes(Lo)}function _(e,n){return e.localeDirs?.[n]??e.dir.replace(Lo,n.toLowerCase())}function E(e,n,t){let r=t.i18n??null;if(n===null||r===null)return e;return Jc(e,n,{...r,locales:[...r.locales]})??e}function J(e){let n=e.lastIndexOf("/");return n===-1?[".",e]:[e.slice(0,n),e.slice(n+1)]}function W(e,n,t){if(n.startFrom===sm&&n.copyOf!==void 0){let r=t.componentDocs?.get(n.copyOf);if(r){let o=JSON.parse(JSON.stringify(r));return delete o.$id,o.tagName=e,o}}return{children:[],tagName:e}}function B(e,n,t){let r=n.startFrom??Mu(t),o=r===Ic&&t.article!==null?t.article:null,i=o?.ext??".json",l=n.url===void 0?[as(e)].filter((u)=>u!==""):R(n.url),a=l.length===0?n.url===void 0?"":"index":l.at(-1),s=["pages",...l.slice(0,-1)].join("/"),c=a===""?"":`${a}${i}`,m=am(n.locale,t),d=c===""?f(s,c):E(f(s,c),m,t),b=c===""?s:J(d)[0],p=e.trim(),g;if(o)g={doc:{children:[{tagName:"h1",textContent:p}],title:p},format:o.name,frontmatter:!0};else{let u={},y=j_(r===Ic?Bs:r,t);if(y!==void 0)u.$layout=y;u.title=p,u.tagName="main",u.children=[{tagName:"h1",textContent:p}],g={doc:u,format:null}}let N=c===""?"":yr(d).urlPattern;return{content:g,dir:b,ext:i,extraWrites:[],fileName:c,kind:"page",path:d,route:N,saved:c===""?"":`Saved as ${d} · opens at ${N}`}}function K(e,n,t){let r=as(e),o=n.fields??hE,i=t.i18n??null,l=i!==null&&n.localized!==!1,a=`content/${r}`,s=l?`${a}/${i.defaultLocale.toLowerCase()}`:a,c=t.contentFormat,m=c?.ext??".json",d=Zu(r),b=r===""?"":`first-${d.replaceAll(" ","-")}${m}`,p=I(o),g=structuredClone(p),N={format:c?.name??"json",schema:v(g)?g:{},source:l?`./${a}/${Lo}`:`./${a}`},u=w({ext:m,formatName:c?.name??null,schema:p},`First ${d}`),y=[],k,L="";if(n.ownPage!==!1&&r!==""){let j=n.pageTemplate??Mu(t),D=l?[i.defaultLocale,...i.locales.filter((x)=>x!==i.defaultLocale)]:[null],T=[];for(let x of D){let O=E(`pages/${r}/[slug].json`,x,t),A=x===null||j!==Mu(t)?j:H_(t,x);k??=yr(O).urlPattern,y.push({body:{doc:pE(r,o,j_(A,t),t),format:null},path:O}),T.push(O)}L=T.length===1?`, and ${T[0]} at ${k}`:`, and a page in each language (${T.join(", ")})`}let P={config:{entry:N,name:r},content:u,dir:s,ext:m,extraWrites:y,fileName:b,kind:"collection",path:f(s,b),saved:r===""?"":l?`Adds a “${r}” collection to project.json with one folder per language under ${a}/, a first entry in ${s}/${L}.`:`Adds a “${r}” collection to project.json, a ${s}/ folder with a first entry${L}.`};if(k!==void 0)P.route=k;return P}function M(e,n){let t=as(e),r=t===""?"":`${t}.json`,o=f("layouts",r),i={},l=n.startFrom??"";if(l!==""&&l!==Bs)i.$layout=l;return i.tagName="div",i.children=[{children:[{tagName:"slot"}],tagName:"main"}],{content:{doc:i,format:null},dir:"layouts",ext:".json",extraWrites:[],fileName:r,kind:"template",path:o,saved:r===""?"":`Saved as ${o} with one slot.`}}function z(e,n,t){let r=lb(e),o=r===""?"":`${r}.json`,i=f("components",o);return{content:{doc:W(r,n,t),format:null},dir:"components",ext:".json",extraWrites:[],fileName:o,kind:"component",path:i,saved:o===""?"":`Saved as ${i} with tag <${r}>.`,tag:r}}function U(e,n,t){let r=t.collections.find((d)=>d.name===n.collection)??null,o=as(e),i=r?.ext??".json",l=am(n.locale,t),a=r!==null&&ib(r)&&l===null,s=r===null?"content":ib(r)&&l!==null?_(r,l):r.dir,c=o===""||r===null||a?"":`${o}${i}`,m=f(s,c);return{content:r?w(r,e.trim()):{doc:{},format:null},dir:s,ext:i,extraWrites:[],fileName:c,kind:"entry",path:m,saved:c===""?"":`Saved as ${m} in ${r.name}.`}}function fE(e,n,t,r){switch(e){case"page":return B(n,t,r);case"collection":return K(n,t,r);case"template":return M(n,t);case"component":return z(n,t,r);case"entry":return U(n,t,r);default:{let o=t.files??0;return{content:{doc:{},format:null},dir:_a,ext:"",extraWrites:[],fileName:"",kind:e,path:_a,saved:o===0?`Saved under ${_a}/. No folder to choose.`:`${o===1?"1 file":`${o} files`} will be saved under ${_a}/.`}}}}function q(e,n){let t=e.lastIndexOf("/"),r=t===-1?".":e.slice(0,t),o=n(r);return fb(e.slice(t+1),"",{dir:r,taken:o??new Set})}function S(e){if(e.kind!=="page"||e.fileName==="")return[];let n=e.fileName.slice(0,e.fileName.length-e.ext.length);if(n!=="index")return[{dir:e.dir,stem:n},{dir:f(e.dir,n),stem:"index"}];let t=e.dir.lastIndexOf("/");if(t===-1)return[{dir:e.dir,stem:n}];return[{dir:e.dir,stem:n},{dir:e.dir.slice(0,t),stem:e.dir.slice(t+1)}]}function V(e,n){let t=e.fileName.toLowerCase();for(let{dir:r,stem:o}of S(e)){let i=`${o.toLowerCase()}.`;for(let l of n(r)??[])if(l.startsWith(i)&&!(r===e.dir&&l===t))return f(r,l)}return null}function H(e){return fb(e,"",{choice:{ext:"",kind:"fixed"},dir:".",taken:new Set})}function mE(e,n,t,r,o){if(e.kind==="media")return(t.files??0)===0?"Drop files here, or browse for them.":"";let i=H(n);if(i!=="")return i;switch(e.kind){case"page":{if(t.url!==void 0){if(t.url.replaceAll("\\","/").split("/").includes(".."))return"A URL cannot step outside the site.";if(!t.url.trim().startsWith("/"))return"A URL starts with a slash, such as /pricing."}let a=V(e,o);if(a!==null)return`${a} already opens at ${e.route??"/"}.`;break}case"component":{let a=e.tag??"",s=lw(a);if(s!=="")return s;if(r.componentTags.includes(a))return`A component named <${a}> already exists.`;if(t.startFrom===P_&&r.hasSelection!==!0)return"Select an element on the canvas to make a component from it.";if(t.startFrom===sm&&(t.copyOf===void 0||r.componentDocs?.get(t.copyOf)===void 0))return"Choose the component to copy.";break}case"collection":{let a=e.config?.name??"";if(r.declaredContent.includes(a))return`A collection named “${a}” already exists.`;if(o("content")?.has(a)===!0)return`content/${a}/ already exists.`;break}case"entry":{let a=r.collections.find((s)=>s.name===t.collection);if(!a)return"Choose the collection this entry belongs to.";if(ib(a)&&am(t.locale,r)===null)return`Choose the language this ${Zu(a.name)} is written in.`;break}default:break}let l=[...e.kind==="collection"?[]:[e.path],...e.extraWrites.map((a)=>a.path)];for(let a of l){let s=q(a,o);if(s!=="")return s}return""}function gE(e){let n=new Set,t=(r)=>{let o=r.lastIndexOf("/");n.add(o===-1?".":r.slice(0,o))};if(e.kind==="media")return[];if(e.kind==="collection")n.add("content");else if(e.fileName!=="")t(e.path);for(let r of e.extraWrites)t(r.path);for(let{dir:r}of S(e))n.add(r);return[...n]}function dD(e){let n=(r)=>r==="."?0:r.split("/").length,t=new Map;for(let r of e){let o=n(r);t.set(o,[...t.get(o)??[],r])}return[...t.entries()].toSorted(([r],[o])=>r-o).map(([,r])=>r)}function uD(e,n){if(e===".")return!1;let t=e.lastIndexOf("/"),r=n.get(t===-1?".":e.slice(0,t));return r!==void 0&&!r.has(e.slice(t+1).toLowerCase())}function B_(e){if(e.ext===".json")return null;return(e.def.format?Wi(e.def.format)?.name:void 0)??fn(`untitled${e.ext}`)?.name??lr()?.name??null}async function G(e){let n=w({ext:e.ext,formatName:B_(e),schema:e.schema});if(n.format===null)return Co(n.doc,null);return Aa(n.format,n.doc,{frontmatter:n.frontmatter??!1,mode:"roundtrip"})}async function X2(e,n={}){let t=wa(e);if(!t)return C.error(`No content collection named "${e}" to create an entry in.`,{detail:"A collection needs a `content` entry in project.json whose `source` is a directory. A collection whose source names a single file (a CSV catalogue) has rows, not entry files.",source:"Content"}),null;await Ht().catch(()=>{});let r;try{r=await G(t)}catch(s){return C.error(`Could not prepare a new ${t.name} entry.`,{detail:ee(s),path:t.dir,source:"Content"}),null}let o=n.dir,i=o!==void 0&&Vd(o)?.name===t.name?o:t.dir;if(i.includes(Lo))return C.error(`"${t.name}" is a localized collection.`,{detail:`Its entries live in one directory per language (${t.dir}). Open the folder for the language you are writing in and create the entry there.`,path:t.dir,source:"Content"}),null;let{createFileIn:l}=await (le("zbc8p6v1"),import("./files-zbc8p6v1.js")),a=await l({content:r,dir:i,format:{ext:t.ext,kind:"fixed"},source:"Content",suggestedName:"untitled",title:`New ${t.name} entry`});if(a===null)return null;return lm(t.name),await Ml(a),a}function F(){let e=h.value;return e&&Rc(e.documentPath)?e:null}function Y(){return[{args:Ce({path:We("Project-relative path of the entry file to open.")}),category:"File",id:"content.openEntry",level:"project",menus:["context/file","palette"],group:"1_file",requires:"an open project",when:(e)=>e.project.open,run:async(e,n)=>{await Ml(St("content.openEntry",n,"path"))},title:"Open Entry"},{args:Ce({draft:To("True marks the open entry a draft; false marks it published. Written as a `draft` field on the entry.")}),category:"Document",id:"content.setDraft",level:"document",menus:["context/tab","palette"],group:"3_document",requires:"a content entry open",when:(e)=>e.document.open,enablement:()=>F()!==null,undo:"document",run:(e,n)=>{let t=F();if(!t)throw Error("content.setDraft: the active document is not a content entry");ab(t,Hi("content.setDraft",n,"draft"))},title:"Set Draft"},{args:Ce({include:To("True lists entries marked `draft: true` alongside the rest.")}),category:"View",id:"content.setIncludeDrafts",level:"project",menus:["palette"],group:"2_view",requires:"an open project",when:(e)=>e.project.open,run:async(e,n)=>{WD(Hi("content.setIncludeDrafts",n,"include")),await tT()},title:"Include Drafts"}]}function bE(e){e.registerAll(Y())}
2
+ export{nb,nw,Bs,Ic,P_,sm,iw,F_,hE,Qa,j_,Mu,H_,cD,pE,am,ib,fE,mE,gE,dD,uD,B_,X2,bE};
3
3
 
4
- //# debugId=A865AAF439BEFE2764756E2164756E21
5
- //# sourceMappingURL=studio-rzg8hnkf.js.map
4
+ //# debugId=866B64AB89DBA13064756E2164756E21
5
+ //# sourceMappingURL=studio-g5prntab.js.map
@@ -1,5 +1,5 @@
1
- import{p,_e}from"./studio-03mqh8ax.js";import{te}from"./studio-psh8mwnw.js";import{La,T$}from"./studio-de1s2x9v.js";import{ge,Qs,ne,g,de,C,dl,tf}from"./studio-4kzbrr5t.js";import{rO,hv,O$,Ia,Y,fv,Bm,Cr,Px,Fx,m,u,_i}from"./studio-vzgmyt0v.js";import{Ht,Xd,Wi,of,fn,lr,oI,Aa,rI}from"./studio-3w35qvay.js";import{Od}from"./studio-34jrz12k.js";import{S$,KA,JA,uh,Xb}from"./studio-cpkamjdn.js";import{qo}from"./studio-jttyqrmh.js";import{vN,hL}from"./studio-pqqq6v85.js";import{Hd}from"./studio-h310mbqm.js";import{ks,Co}from"./studio-5wzdy1jc.js";import{el,Gu}from"./studio-hy4ye0dx.js";import{tN}from"./studio-gwrhcrss.js";import{oe}from"./studio-ekgtrndg.js";import{n,Z,Ze,_,v}from"./studio-zkq3r91p.js";function ie(e,o=[]){if(e?.tagName==="slot"){let s=e.attributes?.name;o.push(n(s)?s.trim():"")}if(Array.isArray(e?.children))for(let s of e.children)ie(n(s)?void 0:s,o);return o}function xS(e){let o=ie(e),s=o.filter((r)=>r==="").length;if(s>1)return`Component has ${s} unnamed <slot> elements — only one default slot is allowed. Give extra slots a name attribute.`;let l=new Set;for(let r of o){if(r&&l.has(r))return`Duplicate slot name "${r}" — slot names must be unique within a component.`;l.add(r)}return null}var se={invokerTags:Xb,popoverTags:uh},D="Popover",ke={display:"document.repairPopoverDisplay","open-display":"document.repairPopoverDisplay",invoker:"document.repairPopoverInvoker",mode:"document.repairPopoverMode"};function ae(e,o,s,l){let r=`${o}.${s}.${l.join("/")}`,d=e.get(r)??0;return e.set(r,d+1),d===0?r:`${r}#${d}`}function W(e,o){dl((d)=>d.source===D);let s=new Map,l=KA(e,se);for(let d of l){let c=d.fix===void 0?void 0:ke[d.fix],b={detail:d.detail,key:ae(s,"popover",d.rule,d.path),source:D,tier:"problem"};if(c!==void 0)b.action=c,b.actionArgs={path:d.path};if(o!==void 0)b.path=o;C(d.severity,d.message,b)}let r=vN(e,se);for(let d of r){let c={detail:d.detail,key:ae(s,"dialog",d.rule,d.path),source:D,tier:"problem"};if(o!==void 0)c.path=o;C(d.severity,d.message,c)}return l.length+r.length}function z(e,o){let s=o?.path;if(!Array.isArray(s))throw RangeError(`command "${e}" needs a "path" argument naming the popover`);return s}function J(e){let o=u.value;if(!o)throw RangeError(`command "${e}" needs an open document`);return o}function Se(){return[{category:"Document",group:"2_document",id:"document.checkPopovers",level:"document",menus:["palette"],requires:"an open document",run:()=>{let e=J("document.checkPopovers"),o=W(e.doc.document,e.documentPath??void 0);C.success(o===0?"No popover problems found in this document.":`${o} popover problem(s) filed.`,{key:"popover.run",source:D})},title:"Check Popovers",when:(e)=>e.document.open,aiTool:{description:"Check the open document for popover defects an author can fix — a base-rule `display` "+"that defeats the browser's own hiding of a closed popover, `popovertarget` on an "+"element that cannot invoke, a target naming no popover, a cut exit animation — and "+"file each as a Problem. The findings come back as data.",name:"check_popovers",report:()=>{let e=tf(D),o=e.length;return{data:e,summary:o===0?"No popover problems found in this document.":`Filed ${o} popover problem${o===1?"":"s"} in Problems.`}}}},{args:{additionalProperties:!1,properties:{path:{items:{type:["string","number"]},type:"array"}},required:["path"],type:"object"},category:"Document",group:"2_document",id:"document.repairPopoverDisplay",level:"document",menus:[],requires:"a popover whose base rule sets display",run:(e,o)=>{let l=J("document.repairPopoverDisplay"),r=z("document.repairPopoverDisplay",o),d=oe(l.doc.document,r),c=JA(d?.style);if(!c)throw RangeError(`command "${"document.repairPopoverDisplay"}": nothing to move — this popover sets no display`);Y(l,(b)=>{for(let w of c.base)Bm(b,r,w,"");for(let w of c.breakpoints)Fx(b,r,[w],"display","");if(c.openDisplay!==null)Px(b,r,":popover-open","display",c.openDisplay)}),C.success("Moved `display` into `:popover-open`.",{key:"popover.repaired.display",source:D})},title:"Move display into :popover-open",when:(e)=>e.document.open},{args:{additionalProperties:!1,properties:{path:{items:{type:["string","number"]},type:"array"}},required:["path"],type:"object"},category:"Document",group:"2_document",id:"document.repairPopoverInvoker",level:"document",menus:[],requires:"an element carrying popovertarget that cannot invoke",run:(e,o)=>{let l=J("document.repairPopoverInvoker"),r=z("document.repairPopoverInvoker",o);Y(l,(d)=>{Cr(d,r,"popovertarget"),Cr(d,r,"popovertargetaction")}),C.success("Removed the attributes, which did nothing on this element.",{key:"popover.repaired.invoker",source:D})},title:"Remove the inert popover attributes",when:(e)=>e.document.open},{args:{additionalProperties:!1,properties:{path:{items:{type:["string","number"]},type:"array"}},required:["path"],type:"object"},category:"Document",group:"2_document",id:"document.repairPopoverMode",level:"document",menus:[],requires:"a popover whose mode is not one of the three keywords",run:(e,o)=>{let l=J("document.repairPopoverMode"),r=z("document.repairPopoverMode",o);Y(l,(d)=>{Cr(d,r,"popover",S$)}),C.success(`Set \`popover\` to "${S$}".`,{key:"popover.repaired.mode",source:D})},title:"Set popover to auto",when:(e)=>e.document.open}]}function YD(e){e.registerAll(Se())}function Ew(e,o){if(e===o)return!0;if(Array.isArray(e)&&Array.isArray(o))return e.length===o.length&&e.every((s,l)=>s===o[l]);if(_(e)&&_(o)&&!Array.isArray(e)&&!Array.isArray(o))return e.$ref===o.$ref;return!1}var N="grid://",xb={children:[],tagName:"div"};function ls(e){switch(e.kind){case"pages":return`${N}pages`;case"collection":return`${N}collection/${encodeURIComponent(e.name)}`;default:return`${N}data/${encodeURIComponent(e.connection)}/${encodeURIComponent(e.table)}`}}function xe(e){return e.startsWith(N)}function Bl(e){if(!xe(e))return null;let o=e.slice(N.length).split("/");if(o[0]==="pages"&&o.length===1)return{kind:"pages"};if(o[0]==="collection"&&o.length===2&&o[1])return{kind:"collection",name:decodeURIComponent(o[1])};if(o[0]==="data"&&o.length===3&&o[1]&&o[2])return{connection:decodeURIComponent(o[1]),kind:"data",table:decodeURIComponent(o[2])};return null}function vm(e){let o=Bl(e);if(!o)return null;switch(o.kind){case"pages":return"Pages · grid";case"collection":return`${o.name} · grid`;default:return`${o.table} @ ${o.connection} · grid`}}var le=0;function ce(e){let o=e.coalesceMs??800,s=e.now??(()=>Date.now()),r=g({deletes:new Set,errors:new Map,inserts:new Map,pending:new Map,redoStack:[],stale:new Set,undoStack:[]}),d=null,c=(t,i,a)=>{let f=r.errors.get(t);if(f)f.set(i,a);else r.errors.set(t,new Map([[i,a]]))},b=(t,i)=>{let a=r.errors.get(t);if(a?.delete(i),a?.size===0)r.errors.delete(t)},w=(t)=>{if(r.redoStack.length=0,d){d.push(t);return}let i=r.undoStack.at(-1);if(t.kind==="cell"&&i?.kind==="cell"&&i.rowKey===t.rowKey&&i.field===t.field&&t.at-i.at<=o){i.after=t.after,i.at=t.at;return}r.undoStack.push(t)},k=(t,i,a)=>{let f=r.inserts.get(t);if(f){if(a===null)delete f[i];else f[i]=a;return}if(Ew(a,e.resolveBaseline(t,i))){let y=r.pending.get(t);if(y?.delete(i),y?.size===0)r.pending.delete(t);return}let h=r.pending.get(t);if(h)h.set(i,{value:a});else r.pending.set(t,new Map([[i,{value:a}]]))},P=(t,i)=>{let a=r.inserts.get(t);if(a)return a[i]??null;let f=r.pending.get(t)?.get(i);return f?f.value:e.resolveBaseline(t,i)},O=(t,i)=>{let a=r.errors.get(t);return a?.get(i)??a?.get("*")??null},M=(t,i)=>{switch(t.kind){case"cell":{k(t.rowKey,t.field,i==="undo"?t.before:t.after);break}case"insert":{if(i==="undo")r.inserts.delete(t.tempKey);else r.inserts.set(t.tempKey,{...t.cells});break}case"drop-insert":{if(i==="undo")r.inserts.set(t.tempKey,{...t.cells});else r.inserts.delete(t.tempKey);break}case"delete":{if(i==="undo")r.deletes.delete(t.rowKey);else r.deletes.add(t.rowKey);break}default:{let a=i==="undo"?t.ops.toReversed():t.ops;for(let f of a)M(f,i);break}}},F=()=>{if(d)throw Error("edit-buffer: groups may not nest");d=[]},x=()=>{let t=d;if(d=null,!t)return;if(t.length===1)r.undoStack.push(t[0]);else if(t.length>1)r.undoStack.push({kind:"group",ops:t})},E=(t)=>{let i=(a)=>{switch(a.kind){case"cell":return t(a.rowKey)?null:a;case"insert":case"drop-insert":return t(a.tempKey)?null:a;case"delete":return t(a.rowKey)?null:a;default:{let f=a.ops.map((h)=>i(h)).filter((h)=>h!==null);return f.length>0?{kind:"group",ops:f}:null}}};r.undoStack=r.undoStack.map(i).filter((a)=>a!==null),r.redoStack=r.redoStack.map(i).filter((a)=>a!==null)};return{applyCommitResult(t){let i=new Set;for(let a of t.cells)if(a.ok){let f=r.pending.get(a.rowKey);if(f?.delete(a.field),f?.size===0)r.pending.delete(a.rowKey);b(a.rowKey,a.field)}else if(c(a.rowKey,a.field,a.error??"Save failed"),a.stale)r.stale.add(a.rowKey);for(let a of t.inserts)if(a.ok)r.inserts.delete(a.tempKey),r.errors.delete(a.tempKey),i.add(a.tempKey);else c(a.tempKey,"*",a.error??"Insert failed");for(let a of t.deletes)if(a.ok)r.deletes.delete(a.rowKey),r.pending.delete(a.rowKey),r.errors.delete(a.rowKey),i.add(a.rowKey);else if(c(a.rowKey,"*",a.error??"Delete failed"),a.stale)r.stale.add(a.rowKey);for(let a of i)r.stale.delete(a);if(i.size>0)E((a)=>i.has(a))},buildBatch(){let t=[];for(let[i,a]of r.pending){if(r.deletes.has(i))continue;for(let[f,h]of a)t.push({baseline:e.resolveBaseline(i,f),field:f,rowKey:i,value:h.value})}return{cells:t,deletes:[...r.deletes].map((i)=>({rowKey:i})),inserts:[...r.inserts].map(([i,a])=>({cells:{...a},tempKey:i}))}},canRedo:()=>r.redoStack.length>0,canUndo:()=>r.undoStack.length>0,cellError:O,cellState(t,i){if(O(t,i)!==null)return"error";if(r.stale.has(t))return"stale";if(r.inserts.has(t)||r.pending.get(t)?.has(i))return"dirty";return"clean"},deleteRow(t){if(r.deletes.has(t))return;let i=r.inserts.get(t);if(i){let a={...i};r.inserts.delete(t),r.errors.delete(t),r.stale.delete(t),w({cells:a,kind:"drop-insert",tempKey:t});return}r.deletes.add(t),w({kind:"delete",rowKey:t})},dirtyCount(){let t=r.inserts.size+r.deletes.size;for(let[i,a]of r.pending)if(!r.deletes.has(i))t+=a.size;return t},discardRow(t){r.pending.delete(t),r.deletes.delete(t),r.inserts.delete(t),r.errors.delete(t),r.stale.delete(t),E((i)=>i===t)},effectiveValue:P,beginGroup:F,endGroup:x,group(t){F();try{t()}finally{x()}},insertRow(t={}){le+=1;let i=`__new-${le}`;return r.inserts.set(i,{...t}),w({cells:{...t},kind:"insert",tempKey:i}),i},isDirty:()=>r.pending.size>0||r.inserts.size>0||r.deletes.size>0,isInsertKey:(t)=>r.inserts.has(t),markStale(t){for(let i of t)r.stale.add(i)},redo(){let t=r.redoStack.pop();if(!t)return!1;return M(t,"redo"),r.undoStack.push(t),!0},reset(){r.pending.clear(),r.inserts.clear(),r.deletes.clear(),r.errors.clear(),r.stale.clear(),r.undoStack.length=0,r.redoStack.length=0},rowState(t){if(r.deletes.has(t))return"pending-delete";if(r.inserts.has(t))return"pending-insert";if(r.stale.has(t))return"stale";if(r.pending.has(t)||r.errors.has(t))return"dirty";return"clean"},setCell(t,i,a){let f=P(t,i);if(Ew(f,a))return;k(t,i,a),w({after:a,at:s(),before:f,field:i,kind:"cell",rowKey:t})},state:r,undo(){let t=r.undoStack.pop();if(!t)return!1;return M(t,"undo"),r.redoStack.push(t),!0}}}var ue={array:220,boolean:70,date:130,enum:140,image:180,number:110,readonly:200,reference:200,string:180,text:340};function fe(e){return Math.min(340,Math.max(90,Math.round(e*7.5)))}function Pe(e){if(e.$ref)return"reference";if(e.enum!==void 0&&Array.isArray(e.enum))return"enum";let o=e.type==="array"?void 0:e.format;if(Ia(o))return"image";if(o==="date"||o==="date-time")return"date";switch(e.type){case"number":case"integer":return"number";case"boolean":return"boolean";case"array":return"array";case"object":return"readonly";default:return(e.maxLength??0)>200||e.format==="markdown"?"text":"string"}}function me(e){let o=e.replaceAll(/([a-z0-9])([A-Z])/g,"$1 $2").replaceAll(/[_-]+/g," ").trim();return o.charAt(0).toUpperCase()+o.slice(1)}function Tw(e,o={}){let s=Object.entries(e?.properties??{}),l=new Set(e?.required),r=new Set(o.readonlyFields),d=s.map(([c,b])=>{let w=r.has(c)?"readonly":Pe(b),k=Array.isArray(b.enum)?Math.max(...b.enum.map((P)=>String(P).length),4):0;return{editable:w!=="readonly",field:c,kind:w,pk:c===o.idField,required:l.has(c),schema:b,title:me(c),widthHint:w==="enum"?fe(k+3):ue[w]}});return d.sort((c,b)=>{let w=(P)=>P.pk?0:P.required?1:2,k=w(c)-w(b);return k===0?0:k}),d}function Lw(e,o=50){let s=e.slice(0,o),l=[];for(let r of s)for(let d of Object.keys(r))if(!l.includes(d))l.push(d);return l.map((r)=>{let d=s.flatMap((w)=>{let k=w[r];return k===null||k===void 0||k===""?[]:[k]}),c=Ge(d),b=Math.max(...d.map((w)=>Qo(w).length),r.length,4);return{editable:!0,field:r,kind:c,title:me(r),widthHint:c==="string"||c==="text"?fe(b):ue[c]}})}function Ge(e){if(e.length===0)return"string";if(e.some((s)=>Array.isArray(s)))return"array";let o=e.map(String);if(e.every((s)=>Ze(s))||o.every((s)=>/^(true|false)$/i.test(s)))return"boolean";if(e.every((s)=>Z(s))||o.every((s)=>s.trim()!==""&&!Number.isNaN(Number(s.replaceAll(/[$€£¥,\s]/g,"")))))return"number";if(o.every((s)=>/^\d{4}-\d{2}-\d{2}([T ].*)?$/.test(s)))return"date";if(o.some((s)=>s.length>200))return"text";return"string"}function vp(e,o){if(e===null||e===void 0)return null;switch(o.kind){case"number":{if(Z(e))return Number.isNaN(e)?null:e;let s=String(e).trim().replaceAll(/[$€£¥,\s]/g,"");if(s==="")return null;let l=Number(s);return Number.isNaN(l)?null:l}case"boolean":{if(Ze(e))return e;return String(e).trim().toLowerCase()==="true"}case"array":{if(Array.isArray(e))return e.map(String);let s=String(e).trim();return s===""?[]:s.split(",").map((l)=>l.trim()).filter(Boolean)}case"reference":{if(v(e)&&"$ref"in e){let l=e.$ref;return n(l)&&l!==""?l:null}let s=String(e).trim();return s===""?null:s}default:{let s=String(e);return s===""?null:s}}}function Qo(e){if(e===null||e===void 0)return"";if(Array.isArray(e))return e.join(", ");if(_(e))return e.$ref;return String(e)}var wS="__key",H=new WeakMap;function er(e){return e?H.get(de(e))??null:null}function yp(e,o){let l=g({columns:[],error:null,grouping:null,loading:!1,query:{},rows:[],saving:!1,total:0}),r=new Map,d=(t)=>{r=new Map(t.map((i)=>[i.key,i]))},c=ce({resolveBaseline:(t,i)=>r.get(t)?.cells[i]??null}),b=async()=>{let t=await o.rows(l.query);d(t.rows),l.rows=t.rows,l.total=t.total},w=(t)=>{let i=l.columns.filter((h)=>h.required&&h.editable);if(i.length===0)return null;let a=t.cells.filter((h)=>h.value===null&&i.some((y)=>y.field===h.field)).map((h)=>({error:"Required",field:h.field,ok:!1,rowKey:h.rowKey})),f=t.inserts.filter((h)=>i.some((y)=>h.cells[y.field]===null||h.cells[y.field]===void 0)).map((h)=>({error:`Missing required: ${i.filter((G)=>h.cells[G.field]===null||h.cells[G.field]===void 0).map((G)=>G.field).join(", ")}`,ok:!1,tempKey:h.tempKey}));if(a.length===0&&f.length===0)return null;return{cells:a,deletes:[],inserts:f}},k=(t)=>t===null||t===""||Array.isArray(t)&&t.length===0,P=(t,i,a)=>{if(a==="number")return(Z(t)?t:0)-(Z(i)?i:0);if(a==="boolean")return(t===!0?1:0)-(i===!0?1:0);return Qo(t).localeCompare(Qo(i))},O=()=>{let t=l.rows.map((f)=>f.key),{dir:i,orderBy:a}=l.query;if(a&&!o.capabilities.remoteSort){let f=l.columns.find((y)=>y.field===a)?.kind,h=i==="desc"?-1:1;t=t.toSorted((y,G)=>{let R=c.effectiveValue(y,a),U=c.effectiveValue(G,a);if(k(R)!==k(U))return k(R)?1:-1;return h*P(R,U,f)})}return l.grouping?[...M(t).values()].flat():t},M=(t)=>{let i=new Map;for(let a of t){let f=Qo(c.effectiveValue(a,l.grouping)),h=i.get(f);if(h)h.push(a);else i.set(f,[a])}return i},F=null,x=()=>F?.refreshData(),E={addRow(t={}){let i=c.insertRow(t);return x(),i},bindView(t){F=t},buffer:c,deleteRows(t){if(t.length===0)return;c.group(()=>{for(let i of t)c.deleteRow(i)}),x()},discardRow(t){c.discardRow(t),x()},replaceAll(t,i){if(t==="")return 0;let a=l.columns.filter((y)=>y.editable&&(y.kind==="string"||y.kind==="text")),f=[...l.rows.map((y)=>y.key),...c.state.inserts.keys()],h=0;if(c.group(()=>{for(let y of f){if(c.rowState(y)==="pending-delete")continue;for(let G of a){let R=c.effectiveValue(y,G.field);if(n(R)&&R.includes(t))c.setCell(y,G.field,R.replaceAll(t,i)),h+=1}}}),h>0)x();return h},effectiveRows(){let t=(f)=>Array.isArray(f)?[...f]:_(f)?{$ref:f.$ref}:f,i=(f)=>{let h=[[wS,f]];for(let y of l.columns)h.push([y.field,t(c.effectiveValue(f,y.field))]);return Object.fromEntries(h)},a=O().map((f)=>i(f));for(let[f]of c.state.inserts)a.push(i(f));return a},groups(){if(!l.grouping)return[];return[...M(O())].map(([t,i])=>({count:i.length,value:t}))},async load(){l.loading=!0,l.error=null;try{l.columns=await o.columns(),await b()}catch(t){l.error=te(t)}finally{l.loading=!1}x()},async refresh(){if(c.isDirty()){if(!await qo("Refresh Grid",`Discard ${c.dirtyCount()} pending change(s) and reload?`,{confirmLabel:"Discard & Reload",destructive:!0}))return}c.reset(),await o.refresh?.(),await this.load()},async save(){if(l.saving)return;let t=c.buildBatch(),i=t.cells.length+t.inserts.length+t.deletes.length;if(i===0){C.info("No grid changes to save.",{key:"grid.save"});return}let a=w(t);if(a){c.applyCommitResult(a),C.warn("Required cells are empty — fix the marked rows, then save again.",{key:"grid.save",source:"Data",tier:"problem"});return}if(t.deletes.length>0){if(!await qo("Delete Rows",`Save will permanently delete ${t.deletes.length} row(s). Continue?`,{confirmLabel:"Delete & Save",destructive:!0}))return}let h=new Set(t.cells.map((y)=>y.rowKey)).size+t.inserts.length+t.deletes.length>5?el({title:"Saving grid"}):null;l.saving=!0;try{let y=await o.commit(t),G=(S,j)=>`${S}\x00${j}`,R=new Map(t.cells.map((S)=>[G(S.rowKey,S.field),S]));for(let S of y.cells){let j=R.get(G(S.rowKey,S.field));if(S.ok&&j){let re=r.get(S.rowKey);if(re)re.cells[S.field]=j.value}}if(c.applyCommitResult(y),y.inserts.some((S)=>S.ok)||y.deletes.some((S)=>S.ok))await b();let L=y.cells.filter((S)=>S.ok).length+y.inserts.filter((S)=>S.ok).length+y.deletes.filter((S)=>S.ok).length,X=i-L,ee=y.cells.filter((S)=>S.stale).length+y.deletes.filter((S)=>S.stale).length;if(X===0)C.success(`Saved ${L} change(s).`,{key:"grid.save"});else C.error(`Saved ${L} · ${X} failed${ee?` (${ee} stale)`:""} — kept pending.`,{action:"file.save",key:"grid.save",source:"Data"})}catch(y){C.error("Could not save the grid.",{action:"file.save",detail:te(y),key:"grid.save",source:"Data"})}finally{l.saving=!1,h?.done(),x()}},serializeForSource(){if(!o.serializeForSource)return null;return o.serializeForSource(c.buildBatch())},async setQuery(t){l.query=t,l.loading=!0;try{await b()}catch(i){l.error=te(i)}finally{l.loading=!1}x()},setGrouping(t){l.grouping=t,x()},async setSort(t){let i={...l.query};if(t)i.orderBy=t.field,i.dir=t.dir;else delete i.orderBy,delete i.dir;if(!o.capabilities.remoteSort){l.query=i,x();return}await this.setQuery(i)},source:o,state:l,tab:e};return e.scope.run(()=>{ne(()=>{e.doc.dirty=c.isDirty()}),fv(e,{canRedo:()=>c.canRedo(),canUndo:()=>c.canUndo(),redo:()=>{c.redo(),x()},undo:()=>{c.undo(),x()}});let t=p();if(t.subscribeFileEvents&&o.backingPaths){let i=t.subscribeFileEvents((a)=>{let f=o.backingPaths(),h=new Set;for(let y of a){if(y.isDir)continue;let G=y.path.replaceAll("\\","/"),R=f.get(G);if(R!==void 0&&!Hd(G))h.add(R)}if(h.size===0)return;if(c.isDirty()){let y=h.has("*")?l.rows.map((G)=>G.key):[...h];c.markStale(y),C.warn("Grid rows changed on disk — marked stale; refresh to reload.",{key:"grid.stale",source:"Data"}),x()}else E.refresh()});Qs(i)}Qs(()=>{fv(e,null),H.delete(de(e)),o.dispose?.()})}),H.set(de(e),E),E}async function Vu(e){let s=er(e)?.serializeForSource();if(s)return s;await Ht();let l=Wi(e.doc.sourceFormat);if(l?.capabilities.serialize){let r=e.doc.content.frontmatter,d=e.doc.document,c={...r,...d,children:d.children??[]};return Aa(l.name,c,{mode:"roundtrip",...e.doc.source!==null&&{source:e.doc.source}})}if(e.doc.mode==="content"){let r=lr();if(r){let d=e.doc.content.frontmatter,c=Object.keys(d).length>0,b={...d,...e.doc.document};return Aa(r.name,b,{frontmatter:c,mode:"roundtrip"})}}return Co(rO(e.doc.document,e.doc.bareRepeaters??null),e.doc.layout??null)}var Re=200,Ee=500,Te=2097152,A=new Map,V=!1,I=null,T=null,B=null,Q=null;function Oe(){let e=[];for(let o of m.tabs.values())if(o.doc.dirty&&o.documentPath)e.push(o);return e}async function pe(){if(!_e())return;let e=p();if(!e.setPreviewOverlay||!e.clearPreviewOverlay)return;let o=new Set;for(let s of Oe()){let l=s.documentPath.replace(/^\.\//,""),r;try{r=await Vu(s)}catch{continue}if(r.length>Te)continue;if(o.add(l),A.get(l)===r)continue;A.set(l,r),await e.setPreviewOverlay(l,r)}for(let s of A.keys())if(!o.has(s))A.delete(s),await e.clearPreviewOverlay(s)}function ye(){if(!V)return;let e=Date.now();if(B??=e,T)clearTimeout(T);let o=e-B,s=Math.max(0,Math.min(Re,Ee-o));T=setTimeout(()=>{T=null,B=null,Q=pe().finally(()=>{Q=null})},s)}function ZD(){ye()}function XD(){if(V)return;V=!0,I=ge(),I.run(()=>{ne(()=>{for(let e of m.tabs.values())e.doc.dirty,e.doc.document;ye()})})}function QD(){if(V=!1,T)clearTimeout(T),T=null;B=null,I?.stop(),I=null,A.clear()}async function _S(){if(!V)return;if(T)clearTimeout(T),T=null,B=null;await Q,await pe()}var he=/^[A-Za-z0-9][A-Za-z0-9!#$&^_.+-]{0,126}$/,Me=new Set(["vnd","prs","x"]);function $e(e){if(!n(e))return null;let[o,...s]=e.split(";"),l=(o??"").indexOf("/");if(l===-1)return null;let r=(o??"").slice(0,l).trim().toLowerCase(),d=(o??"").slice(l+1).trim().toLowerCase();if(!he.test(r)||!he.test(d))return null;let c=d.lastIndexOf("+"),b=c===-1?null:d.slice(c+1),w=c===-1?d:d.slice(0,c);if(b==="")return null;let k=w.indexOf("."),P=k===-1?null:w.slice(0,k),O=P!==null&&Me.has(P)?P:null,M=O===null?w:w.slice(O.length+1);if(M==="")return null;let F={};for(let x of s){let E=x.indexOf("=");if(E===-1)return null;let t=x.slice(0,E).trim().toLowerCase(),i=x.slice(E+1).trim();if(t==="")return null;if(i.startsWith('"')&&i.endsWith('"')&&i.length>=2)i=i.slice(1,-1);F[t]=i}return{parameters:F,subtype:M,suffix:b,tree:O,type:r}}function $w(e){let o=$e(e);if(o===null)return null;let s=o.tree===null?"":`${o.tree}.`,l=o.suffix===null?"":`+${o.suffix}`;return`${o.type}/${s}${o.subtype}${l}`}var we="text/markdown; variant=GFM",be="application/yaml",Tt={".markdown":`${we}; charset=utf-8`,".md":`${we}; charset=utf-8`,".yaml":`${be}; charset=utf-8`,".yml":`${be}; charset=utf-8`};async function eN(e,o){let s=await oI(e.name,o);return rI(e,s)}async function jr(e,o){await Ht();let s=fn(e);if(!s||!s.capabilities.parse)throw of(e);return{...await eN(s,o),format:s}}var AT=async(e,o)=>{if(e.documentPath&&fn(e.documentPath)){let l=await jr(e.documentPath,o);return e.doc.source=o,{document:l.document,frontmatter:l.frontmatter}}let s=ks(o);return e.doc.layout=s.layout,{document:s.document}};function Fe(e){return"showOpenFilePicker"in e}function De(e){return"showSaveFilePicker"in e}function q(e,o){if(e.documentPath!==null)o.path=e.documentPath;return o}async function rP(){try{await Ht();let e=Xd(),o=[{accept:{"application/json":[".json"]},description:"Jx Component"},...e.filter((r)=>r.capabilities.parse).map((r)=>({accept:{[$w(r.mediaType)??"text/plain"]:r.extensions},description:r.name}))],s=[".json",...e.flatMap((r)=>r.extensions)].join(","),l=async(r,d,c=null)=>{let b=c?await tN(r):null,w=fn(r);if(w){let{document:k,frontmatter:P}=await eN(w,d);_i({document:k,documentPath:b,fileHandle:c,frontmatter:P,id:r,source:d,sourceFormat:w.name})}else if(r.endsWith(".json")){let{document:k,layout:P}=ks(d);_i({document:k,documentPath:b,fileHandle:c,id:r,layout:P})}else throw of(r)};if(Fe(window)){let[r]=await window.showOpenFilePicker({types:o}),d=await r.getFile();await l(r.name,await d.text(),r)}else{let r=document.createElement("input");r.type="file",r.accept=s,r.addEventListener("change",async()=>{let d=r.files?.[0];if(!d)return;await l(d.name,await d.text())}),r.click()}}catch(e){if(!(e instanceof Error&&e.name==="AbortError"))C.error("Could not open the file.",{detail:te(e),source:"Open File"})}}var ve=()=>{};function OT(e){ve=e}function K(e){let o=e.doc.document;ve(e.documentPath,o,e);let s=n(o.tagName)&&o.tagName.includes("-")?xS(o):null;if(s)C.warn(s,q(e,{key:`slots:${e.documentPath??e.id}`,source:"Components",tier:"problem"}));W(o,e.documentPath??void 0)}function Ne(e){return!Od(e.documentPath??"")}async function wp(e=u.value){if(!e)return!1;if(await hL(e.id),hv(e))return C.warn(`You have read access to this session — changes to ${e.documentPath??"this document"} stay in your browser and cannot be saved.`,q(e,{action:"file.save",key:`save.readOnly:${e.documentPath??e.id}`,source:"Collaboration"})),!1;if(!Ne(e))return C.warn(`${e.documentPath??"This file"} is a media file, so there is no document for Save to write.`,q(e,{key:`save.notADocument:${e.documentPath??e.id}`,source:"Save"})),!1;let o=er(e);if(o)return await o.save(),!e.doc.dirty;try{if(await O$(e))return K(e),!0;let s=await Vu(e);if(e.documentPath){if(await p().writeFile(e.documentPath,s),e.doc.dirty=!1,e.doc.sourceFormat!==null)e.doc.source=s;return _S(),K(e),!0}if(e.fileHandle&&"createWritable"in e.fileHandle){let l=await e.fileHandle.createWritable();if(await l.write(s),await l.close(),e.doc.dirty=!1,e.doc.sourceFormat!==null)e.doc.source=s;return K(e),!0}C.warn("This document has no save target — use Export.",{key:"save.noTarget"})}catch(s){if(!(s instanceof Error&&s.name==="AbortError"))C.error(`Could not save ${e.documentPath??e.id}.`,q(e,{action:"file.save",detail:te(s),key:`save:${e.documentPath??e.id}`,source:"Save"}))}return!1}function Ae(e){return Wi(e.doc.sourceFormat)??(e.doc.mode==="content"?lr():void 0)}async function MT(){let e=u.value;if(!e)return;try{await Ht();let o=Ae(e),s=await Vu(e),l=o?$w(o.mediaType)??"text/plain":"application/json",r=o?o.extensions[0]:".json",d=o?o.name:"Jx Component",c=o?`content${r}`:"component.json";if(De(window)){let b=e.documentPath?e.documentPath.split("/").pop():c,w=await window.showSaveFilePicker({suggestedName:b,types:[{accept:{[l]:[r]},description:d}]}),k=await w.createWritable();await k.write(s),await k.close(),e.doc.dirty=!1,K(e),C.success(`Exported as ${w.name}.`)}else{let b=new Blob([s],{type:l}),w=URL.createObjectURL(b),k=document.createElement("a");k.href=w,k.download=c,k.click(),URL.revokeObjectURL(w),e.doc.dirty=!1,K(e),C.success(`Downloaded ${c}.`)}}catch(o){if(!(o instanceof Error&&o.name==="AbortError"))C.error("Could not export the document.",{detail:te(o),source:"Export"})}}async function Ce(e,o){let s=Od(e)?await Gu(e):await La({path:e});return T$(s,o)??""}async function _b(e){let o=await Ce(e.path,"delete"),s=`Delete ${e.name}? This cannot be undone.`;return Boolean(await qo("Delete File",o===""?s:`${s} ${o}`,{confirmLabel:"Delete",destructive:!0}))}async function Sb(e,o="rename"){let s=await Ce(e,o);return s===""?void 0:s}
2
- export{Ew,xb,ls,Bl,vm,Tw,Lw,vp,Qo,wS,er,yp,xS,YD,Vu,ZD,XD,QD,_S,$w,eN,jr,AT,rP,OT,wp,MT,_b,Sb};
1
+ import{p,_e}from"./studio-w67vfgy5.js";import{ee}from"./studio-et6t8g4m.js";import{La,T$}from"./studio-0hr000ba.js";import{ge,ea,ne,g,de,C,dl,tf}from"./studio-ahf3cspq.js";import{sO,hv,O$,Ia,Y,fv,Bm,Cr,Px,Fx,m,h,_i}from"./studio-j933k8nr.js";import{Ht,Qd,Wi,of,fn,lr,oI,Aa,rI}from"./studio-848rk4p1.js";import{Md}from"./studio-20ap8dds.js";import{S$,JA,YA,uh,Xb}from"./studio-f2j9et3h.js";import{qo}from"./studio-cvz0e00f.js";import{vN,hL}from"./studio-695k95bw.js";import{Bd}from"./studio-dy2xtt7a.js";import{Es,Co}from"./studio-dbgv4fv9.js";import{el,Gu}from"./studio-qyb5bebs.js";import{tN}from"./studio-6vwvshw8.js";import{oe}from"./studio-tpy3rdxn.js";import{n,Z,Ze,_,v}from"./studio-zsjpsw08.js";function ie(e,o=[]){if(e?.tagName==="slot"){let s=e.attributes?.name;o.push(n(s)?s.trim():"")}if(Array.isArray(e?.children))for(let s of e.children)ie(n(s)?void 0:s,o);return o}function xS(e){let o=ie(e),s=o.filter((r)=>r==="").length;if(s>1)return`Component has ${s} unnamed <slot> elements — only one default slot is allowed. Give extra slots a name attribute.`;let l=new Set;for(let r of o){if(r&&l.has(r))return`Duplicate slot name "${r}" — slot names must be unique within a component.`;l.add(r)}return null}var se={invokerTags:Xb,popoverTags:uh},D="Popover",ke={display:"document.repairPopoverDisplay","open-display":"document.repairPopoverDisplay",invoker:"document.repairPopoverInvoker",mode:"document.repairPopoverMode"};function ae(e,o,s,l){let r=`${o}.${s}.${l.join("/")}`,d=e.get(r)??0;return e.set(r,d+1),d===0?r:`${r}#${d}`}function W(e,o){dl((d)=>d.source===D);let s=new Map,l=JA(e,se);for(let d of l){let c=d.fix===void 0?void 0:ke[d.fix],b={detail:d.detail,key:ae(s,"popover",d.rule,d.path),source:D,tier:"problem"};if(c!==void 0)b.action=c,b.actionArgs={path:d.path};if(o!==void 0)b.path=o;C(d.severity,d.message,b)}let r=vN(e,se);for(let d of r){let c={detail:d.detail,key:ae(s,"dialog",d.rule,d.path),source:D,tier:"problem"};if(o!==void 0)c.path=o;C(d.severity,d.message,c)}return l.length+r.length}function z(e,o){let s=o?.path;if(!Array.isArray(s))throw RangeError(`command "${e}" needs a "path" argument naming the popover`);return s}function J(e){let o=h.value;if(!o)throw RangeError(`command "${e}" needs an open document`);return o}function Se(){return[{category:"Document",group:"2_document",id:"document.checkPopovers",level:"document",menus:["palette"],requires:"an open document",run:()=>{let e=J("document.checkPopovers"),o=W(e.doc.document,e.documentPath??void 0);C.success(o===0?"No popover problems found in this document.":`${o} popover problem(s) filed.`,{key:"popover.run",source:D})},title:"Check Popovers",when:(e)=>e.document.open,aiTool:{description:"Check the open document for popover defects an author can fix — a base-rule `display` "+"that defeats the browser's own hiding of a closed popover, `popovertarget` on an "+"element that cannot invoke, a target naming no popover, a cut exit animation — and "+"file each as a Problem. The findings come back as data.",name:"check_popovers",report:()=>{let e=tf(D),o=e.length;return{data:e,summary:o===0?"No popover problems found in this document.":`Filed ${o} popover problem${o===1?"":"s"} in Problems.`}}}},{args:{additionalProperties:!1,properties:{path:{items:{type:["string","number"]},type:"array"}},required:["path"],type:"object"},category:"Document",group:"2_document",id:"document.repairPopoverDisplay",level:"document",menus:[],requires:"a popover whose base rule sets display",run:(e,o)=>{let l=J("document.repairPopoverDisplay"),r=z("document.repairPopoverDisplay",o),d=oe(l.doc.document,r),c=YA(d?.style);if(!c)throw RangeError(`command "${"document.repairPopoverDisplay"}": nothing to move — this popover sets no display`);Y(l,(b)=>{for(let w of c.base)Bm(b,r,w,"");for(let w of c.breakpoints)Fx(b,r,[w],"display","");if(c.openDisplay!==null)Px(b,r,":popover-open","display",c.openDisplay)}),C.success("Moved `display` into `:popover-open`.",{key:"popover.repaired.display",source:D})},title:"Move display into :popover-open",when:(e)=>e.document.open},{args:{additionalProperties:!1,properties:{path:{items:{type:["string","number"]},type:"array"}},required:["path"],type:"object"},category:"Document",group:"2_document",id:"document.repairPopoverInvoker",level:"document",menus:[],requires:"an element carrying popovertarget that cannot invoke",run:(e,o)=>{let l=J("document.repairPopoverInvoker"),r=z("document.repairPopoverInvoker",o);Y(l,(d)=>{Cr(d,r,"popovertarget"),Cr(d,r,"popovertargetaction")}),C.success("Removed the attributes, which did nothing on this element.",{key:"popover.repaired.invoker",source:D})},title:"Remove the inert popover attributes",when:(e)=>e.document.open},{args:{additionalProperties:!1,properties:{path:{items:{type:["string","number"]},type:"array"}},required:["path"],type:"object"},category:"Document",group:"2_document",id:"document.repairPopoverMode",level:"document",menus:[],requires:"a popover whose mode is not one of the three keywords",run:(e,o)=>{let l=J("document.repairPopoverMode"),r=z("document.repairPopoverMode",o);Y(l,(d)=>{Cr(d,r,"popover",S$)}),C.success(`Set \`popover\` to "${S$}".`,{key:"popover.repaired.mode",source:D})},title:"Set popover to auto",when:(e)=>e.document.open}]}function YD(e){e.registerAll(Se())}function Ew(e,o){if(e===o)return!0;if(Array.isArray(e)&&Array.isArray(o))return e.length===o.length&&e.every((s,l)=>s===o[l]);if(_(e)&&_(o)&&!Array.isArray(e)&&!Array.isArray(o))return e.$ref===o.$ref;return!1}var N="grid://",xb={children:[],tagName:"div"};function ls(e){switch(e.kind){case"pages":return`${N}pages`;case"collection":return`${N}collection/${encodeURIComponent(e.name)}`;default:return`${N}data/${encodeURIComponent(e.connection)}/${encodeURIComponent(e.table)}`}}function xe(e){return e.startsWith(N)}function Bl(e){if(!xe(e))return null;let o=e.slice(N.length).split("/");if(o[0]==="pages"&&o.length===1)return{kind:"pages"};if(o[0]==="collection"&&o.length===2&&o[1])return{kind:"collection",name:decodeURIComponent(o[1])};if(o[0]==="data"&&o.length===3&&o[1]&&o[2])return{connection:decodeURIComponent(o[1]),kind:"data",table:decodeURIComponent(o[2])};return null}function vm(e){let o=Bl(e);if(!o)return null;switch(o.kind){case"pages":return"Pages · grid";case"collection":return`${o.name} · grid`;default:return`${o.table} @ ${o.connection} · grid`}}var le=0;function ce(e){let o=e.coalesceMs??800,s=e.now??(()=>Date.now()),r=g({deletes:new Set,errors:new Map,inserts:new Map,pending:new Map,redoStack:[],stale:new Set,undoStack:[]}),d=null,c=(t,i,a)=>{let u=r.errors.get(t);if(u)u.set(i,a);else r.errors.set(t,new Map([[i,a]]))},b=(t,i)=>{let a=r.errors.get(t);if(a?.delete(i),a?.size===0)r.errors.delete(t)},w=(t)=>{if(r.redoStack.length=0,d){d.push(t);return}let i=r.undoStack.at(-1);if(t.kind==="cell"&&i?.kind==="cell"&&i.rowKey===t.rowKey&&i.field===t.field&&t.at-i.at<=o){i.after=t.after,i.at=t.at;return}r.undoStack.push(t)},k=(t,i,a)=>{let u=r.inserts.get(t);if(u){if(a===null)delete u[i];else u[i]=a;return}if(Ew(a,e.resolveBaseline(t,i))){let f=r.pending.get(t);if(f?.delete(i),f?.size===0)r.pending.delete(t);return}let y=r.pending.get(t);if(y)y.set(i,{value:a});else r.pending.set(t,new Map([[i,{value:a}]]))},P=(t,i)=>{let a=r.inserts.get(t);if(a)return a[i]??null;let u=r.pending.get(t)?.get(i);return u?u.value:e.resolveBaseline(t,i)},O=(t,i)=>{let a=r.errors.get(t);return a?.get(i)??a?.get("*")??null},M=(t,i)=>{switch(t.kind){case"cell":{k(t.rowKey,t.field,i==="undo"?t.before:t.after);break}case"insert":{if(i==="undo")r.inserts.delete(t.tempKey);else r.inserts.set(t.tempKey,{...t.cells});break}case"drop-insert":{if(i==="undo")r.inserts.set(t.tempKey,{...t.cells});else r.inserts.delete(t.tempKey);break}case"delete":{if(i==="undo")r.deletes.delete(t.rowKey);else r.deletes.add(t.rowKey);break}default:{let a=i==="undo"?t.ops.toReversed():t.ops;for(let u of a)M(u,i);break}}},F=()=>{if(d)throw Error("edit-buffer: groups may not nest");d=[]},x=()=>{let t=d;if(d=null,!t)return;if(t.length===1)r.undoStack.push(t[0]);else if(t.length>1)r.undoStack.push({kind:"group",ops:t})},E=(t)=>{let i=(a)=>{switch(a.kind){case"cell":return t(a.rowKey)?null:a;case"insert":case"drop-insert":return t(a.tempKey)?null:a;case"delete":return t(a.rowKey)?null:a;default:{let u=a.ops.map((y)=>i(y)).filter((y)=>y!==null);return u.length>0?{kind:"group",ops:u}:null}}};r.undoStack=r.undoStack.map(i).filter((a)=>a!==null),r.redoStack=r.redoStack.map(i).filter((a)=>a!==null)};return{applyCommitResult(t){let i=new Set;for(let a of t.cells)if(a.ok){let u=r.pending.get(a.rowKey);if(u?.delete(a.field),u?.size===0)r.pending.delete(a.rowKey);b(a.rowKey,a.field)}else if(c(a.rowKey,a.field,a.error??"Save failed"),a.stale)r.stale.add(a.rowKey);for(let a of t.inserts)if(a.ok)r.inserts.delete(a.tempKey),r.errors.delete(a.tempKey),i.add(a.tempKey);else c(a.tempKey,"*",a.error??"Insert failed");for(let a of t.deletes)if(a.ok)r.deletes.delete(a.rowKey),r.pending.delete(a.rowKey),r.errors.delete(a.rowKey),i.add(a.rowKey);else if(c(a.rowKey,"*",a.error??"Delete failed"),a.stale)r.stale.add(a.rowKey);for(let a of i)r.stale.delete(a);if(i.size>0)E((a)=>i.has(a))},buildBatch(){let t=[];for(let[i,a]of r.pending){if(r.deletes.has(i))continue;for(let[u,y]of a)t.push({baseline:e.resolveBaseline(i,u),field:u,rowKey:i,value:y.value})}return{cells:t,deletes:[...r.deletes].map((i)=>({rowKey:i})),inserts:[...r.inserts].map(([i,a])=>({cells:{...a},tempKey:i}))}},canRedo:()=>r.redoStack.length>0,canUndo:()=>r.undoStack.length>0,cellError:O,cellState(t,i){if(O(t,i)!==null)return"error";if(r.stale.has(t))return"stale";if(r.inserts.has(t)||r.pending.get(t)?.has(i))return"dirty";return"clean"},deleteRow(t){if(r.deletes.has(t))return;let i=r.inserts.get(t);if(i){let a={...i};r.inserts.delete(t),r.errors.delete(t),r.stale.delete(t),w({cells:a,kind:"drop-insert",tempKey:t});return}r.deletes.add(t),w({kind:"delete",rowKey:t})},dirtyCount(){let t=r.inserts.size+r.deletes.size;for(let[i,a]of r.pending)if(!r.deletes.has(i))t+=a.size;return t},discardRow(t){r.pending.delete(t),r.deletes.delete(t),r.inserts.delete(t),r.errors.delete(t),r.stale.delete(t),E((i)=>i===t)},effectiveValue:P,beginGroup:F,endGroup:x,group(t){F();try{t()}finally{x()}},insertRow(t={}){le+=1;let i=`__new-${le}`;return r.inserts.set(i,{...t}),w({cells:{...t},kind:"insert",tempKey:i}),i},isDirty:()=>r.pending.size>0||r.inserts.size>0||r.deletes.size>0,isInsertKey:(t)=>r.inserts.has(t),markStale(t){for(let i of t)r.stale.add(i)},redo(){let t=r.redoStack.pop();if(!t)return!1;return M(t,"redo"),r.undoStack.push(t),!0},reset(){r.pending.clear(),r.inserts.clear(),r.deletes.clear(),r.errors.clear(),r.stale.clear(),r.undoStack.length=0,r.redoStack.length=0},rowState(t){if(r.deletes.has(t))return"pending-delete";if(r.inserts.has(t))return"pending-insert";if(r.stale.has(t))return"stale";if(r.pending.has(t)||r.errors.has(t))return"dirty";return"clean"},setCell(t,i,a){let u=P(t,i);if(Ew(u,a))return;k(t,i,a),w({after:a,at:s(),before:u,field:i,kind:"cell",rowKey:t})},state:r,undo(){let t=r.undoStack.pop();if(!t)return!1;return M(t,"undo"),r.redoStack.push(t),!0}}}var ue={array:220,boolean:70,date:130,enum:140,image:180,number:110,readonly:200,reference:200,string:180,text:340};function fe(e){return Math.min(340,Math.max(90,Math.round(e*7.5)))}function Pe(e){if(e.$ref)return"reference";if(e.enum!==void 0&&Array.isArray(e.enum))return"enum";let o=e.type==="array"?void 0:e.format;if(Ia(o))return"image";if(o==="date"||o==="date-time")return"date";switch(e.type){case"number":case"integer":return"number";case"boolean":return"boolean";case"array":return"array";case"object":return"readonly";default:return(e.maxLength??0)>200||e.format==="markdown"?"text":"string"}}function me(e){let o=e.replaceAll(/([a-z0-9])([A-Z])/g,"$1 $2").replaceAll(/[_-]+/g," ").trim();return o.charAt(0).toUpperCase()+o.slice(1)}function Tw(e,o={}){let s=Object.entries(e?.properties??{}),l=new Set(e?.required),r=new Set(o.readonlyFields),d=s.map(([c,b])=>{let w=r.has(c)?"readonly":Pe(b),k=Array.isArray(b.enum)?Math.max(...b.enum.map((P)=>String(P).length),4):0;return{editable:w!=="readonly",field:c,kind:w,pk:c===o.idField,required:l.has(c),schema:b,title:me(c),widthHint:w==="enum"?fe(k+3):ue[w]}});return d.sort((c,b)=>{let w=(P)=>P.pk?0:P.required?1:2,k=w(c)-w(b);return k===0?0:k}),d}function Lw(e,o=50){let s=e.slice(0,o),l=[];for(let r of s)for(let d of Object.keys(r))if(!l.includes(d))l.push(d);return l.map((r)=>{let d=s.flatMap((w)=>{let k=w[r];return k===null||k===void 0||k===""?[]:[k]}),c=Ge(d),b=Math.max(...d.map((w)=>Qo(w).length),r.length,4);return{editable:!0,field:r,kind:c,title:me(r),widthHint:c==="string"||c==="text"?fe(b):ue[c]}})}function Ge(e){if(e.length===0)return"string";if(e.some((s)=>Array.isArray(s)))return"array";let o=e.map(String);if(e.every((s)=>Ze(s))||o.every((s)=>/^(true|false)$/i.test(s)))return"boolean";if(e.every((s)=>Z(s))||o.every((s)=>s.trim()!==""&&!Number.isNaN(Number(s.replaceAll(/[$€£¥,\s]/g,"")))))return"number";if(o.every((s)=>/^\d{4}-\d{2}-\d{2}([T ].*)?$/.test(s)))return"date";if(o.some((s)=>s.length>200))return"text";return"string"}function vp(e,o){if(e===null||e===void 0)return null;switch(o.kind){case"number":{if(Z(e))return Number.isNaN(e)?null:e;let s=String(e).trim().replaceAll(/[$€£¥,\s]/g,"");if(s==="")return null;let l=Number(s);return Number.isNaN(l)?null:l}case"boolean":{if(Ze(e))return e;return String(e).trim().toLowerCase()==="true"}case"array":{if(Array.isArray(e))return e.map(String);let s=String(e).trim();return s===""?[]:s.split(",").map((l)=>l.trim()).filter(Boolean)}case"reference":{if(v(e)&&"$ref"in e){let l=e.$ref;return n(l)&&l!==""?l:null}let s=String(e).trim();return s===""?null:s}default:{let s=String(e);return s===""?null:s}}}function Qo(e){if(e===null||e===void 0)return"";if(Array.isArray(e))return e.join(", ");if(_(e))return e.$ref;return String(e)}var wS="__key",H=new WeakMap;function er(e){return e?H.get(de(e))??null:null}function yp(e,o){let l=g({columns:[],error:null,grouping:null,loading:!1,query:{},rows:[],saving:!1,total:0}),r=new Map,d=(t)=>{r=new Map(t.map((i)=>[i.key,i]))},c=ce({resolveBaseline:(t,i)=>r.get(t)?.cells[i]??null}),b=async()=>{let t=await o.rows(l.query);d(t.rows),l.rows=t.rows,l.total=t.total},w=(t)=>{let i=l.columns.filter((y)=>y.required&&y.editable);if(i.length===0)return null;let a=t.cells.filter((y)=>y.value===null&&i.some((f)=>f.field===y.field)).map((y)=>({error:"Required",field:y.field,ok:!1,rowKey:y.rowKey})),u=t.inserts.filter((y)=>i.some((f)=>y.cells[f.field]===null||y.cells[f.field]===void 0)).map((y)=>({error:`Missing required: ${i.filter((G)=>y.cells[G.field]===null||y.cells[G.field]===void 0).map((G)=>G.field).join(", ")}`,ok:!1,tempKey:y.tempKey}));if(a.length===0&&u.length===0)return null;return{cells:a,deletes:[],inserts:u}},k=(t)=>t===null||t===""||Array.isArray(t)&&t.length===0,P=(t,i,a)=>{if(a==="number")return(Z(t)?t:0)-(Z(i)?i:0);if(a==="boolean")return(t===!0?1:0)-(i===!0?1:0);return Qo(t).localeCompare(Qo(i))},O=()=>{let t=l.rows.map((u)=>u.key),{dir:i,orderBy:a}=l.query;if(a&&!o.capabilities.remoteSort){let u=l.columns.find((f)=>f.field===a)?.kind,y=i==="desc"?-1:1;t=t.toSorted((f,G)=>{let R=c.effectiveValue(f,a),U=c.effectiveValue(G,a);if(k(R)!==k(U))return k(R)?1:-1;return y*P(R,U,u)})}return l.grouping?[...M(t).values()].flat():t},M=(t)=>{let i=new Map;for(let a of t){let u=Qo(c.effectiveValue(a,l.grouping)),y=i.get(u);if(y)y.push(a);else i.set(u,[a])}return i},F=null,x=()=>F?.refreshData(),E={addRow(t={}){let i=c.insertRow(t);return x(),i},bindView(t){F=t},buffer:c,deleteRows(t){if(t.length===0)return;c.group(()=>{for(let i of t)c.deleteRow(i)}),x()},discardRow(t){c.discardRow(t),x()},replaceAll(t,i){if(t==="")return 0;let a=l.columns.filter((f)=>f.editable&&(f.kind==="string"||f.kind==="text")),u=[...l.rows.map((f)=>f.key),...c.state.inserts.keys()],y=0;if(c.group(()=>{for(let f of u){if(c.rowState(f)==="pending-delete")continue;for(let G of a){let R=c.effectiveValue(f,G.field);if(n(R)&&R.includes(t))c.setCell(f,G.field,R.replaceAll(t,i)),y+=1}}}),y>0)x();return y},effectiveRows(){let t=(u)=>Array.isArray(u)?[...u]:_(u)?{$ref:u.$ref}:u,i=(u)=>{let y=[[wS,u]];for(let f of l.columns)y.push([f.field,t(c.effectiveValue(u,f.field))]);return Object.fromEntries(y)},a=O().map((u)=>i(u));for(let[u]of c.state.inserts)a.push(i(u));return a},groups(){if(!l.grouping)return[];return[...M(O())].map(([t,i])=>({count:i.length,value:t}))},async load(){l.loading=!0,l.error=null;try{l.columns=await o.columns(),await b()}catch(t){l.error=ee(t)}finally{l.loading=!1}x()},async refresh(){if(c.isDirty()){if(!await qo("Refresh Grid",`Discard ${c.dirtyCount()} pending change(s) and reload?`,{confirmLabel:"Discard & Reload",destructive:!0}))return}c.reset(),await o.refresh?.(),await this.load()},async save(){if(l.saving)return;let t=c.buildBatch(),i=t.cells.length+t.inserts.length+t.deletes.length;if(i===0){C.info("No grid changes to save.",{key:"grid.save"});return}let a=w(t);if(a){c.applyCommitResult(a),C.warn("Required cells are empty — fix the marked rows, then save again.",{key:"grid.save",source:"Data",tier:"problem"});return}if(t.deletes.length>0){if(!await qo("Delete Rows",`Save will permanently delete ${t.deletes.length} row(s). Continue?`,{confirmLabel:"Delete & Save",destructive:!0}))return}let y=new Set(t.cells.map((f)=>f.rowKey)).size+t.inserts.length+t.deletes.length>5?el({title:"Saving grid"}):null;l.saving=!0;try{let f=await o.commit(t),G=(S,j)=>`${S}\x00${j}`,R=new Map(t.cells.map((S)=>[G(S.rowKey,S.field),S]));for(let S of f.cells){let j=R.get(G(S.rowKey,S.field));if(S.ok&&j){let re=r.get(S.rowKey);if(re)re.cells[S.field]=j.value}}if(c.applyCommitResult(f),f.inserts.some((S)=>S.ok)||f.deletes.some((S)=>S.ok))await b();let L=f.cells.filter((S)=>S.ok).length+f.inserts.filter((S)=>S.ok).length+f.deletes.filter((S)=>S.ok).length,X=i-L,te=f.cells.filter((S)=>S.stale).length+f.deletes.filter((S)=>S.stale).length;if(X===0)C.success(`Saved ${L} change(s).`,{key:"grid.save"});else C.error(`Saved ${L} · ${X} failed${te?` (${te} stale)`:""} — kept pending.`,{action:"file.save",key:"grid.save",source:"Data"})}catch(f){C.error("Could not save the grid.",{action:"file.save",detail:ee(f),key:"grid.save",source:"Data"})}finally{l.saving=!1,y?.done(),x()}},serializeForSource(){if(!o.serializeForSource)return null;return o.serializeForSource(c.buildBatch())},async setQuery(t){l.query=t,l.loading=!0;try{await b()}catch(i){l.error=ee(i)}finally{l.loading=!1}x()},setGrouping(t){l.grouping=t,x()},async setSort(t){let i={...l.query};if(t)i.orderBy=t.field,i.dir=t.dir;else delete i.orderBy,delete i.dir;if(!o.capabilities.remoteSort){l.query=i,x();return}await this.setQuery(i)},source:o,state:l,tab:e};return e.scope.run(()=>{ne(()=>{e.doc.dirty=c.isDirty()}),fv(e,{canRedo:()=>c.canRedo(),canUndo:()=>c.canUndo(),redo:()=>{c.redo(),x()},undo:()=>{c.undo(),x()}});let t=p();if(t.subscribeFileEvents&&o.backingPaths){let i=t.subscribeFileEvents((a)=>{let u=o.backingPaths(),y=new Set;for(let f of a){if(f.isDir)continue;let G=f.path.replaceAll("\\","/"),R=u.get(G);if(R!==void 0&&!Bd(G))y.add(R)}if(y.size===0)return;if(c.isDirty()){let f=y.has("*")?l.rows.map((G)=>G.key):[...y];c.markStale(f),C.warn("Grid rows changed on disk — marked stale; refresh to reload.",{key:"grid.stale",source:"Data"}),x()}else E.refresh()});ea(i)}ea(()=>{fv(e,null),H.delete(de(e)),o.dispose?.()})}),H.set(de(e),E),E}async function Vu(e){let s=er(e)?.serializeForSource();if(s)return s;await Ht();let l=Wi(e.doc.sourceFormat);if(l?.capabilities.serialize){let r=e.doc.content.frontmatter,d=e.doc.document,c={...r,...d,children:d.children??[]};return Aa(l.name,c,{mode:"roundtrip",...e.doc.source!==null&&{source:e.doc.source}})}if(e.doc.mode==="content"){let r=lr();if(r){let d=e.doc.content.frontmatter,c=Object.keys(d).length>0,b={...d,...e.doc.document};return Aa(r.name,b,{frontmatter:c,mode:"roundtrip"})}}return Co(sO(e.doc.document,e.doc.bareRepeaters??null),e.doc.layout??null)}var Re=200,Ee=500,Te=2097152,A=new Map,V=!1,I=null,T=null,B=null,Q=null;function Oe(){let e=[];for(let o of m.tabs.values())if(o.doc.dirty&&o.documentPath)e.push(o);return e}async function pe(){if(!_e())return;let e=p();if(!e.setPreviewOverlay||!e.clearPreviewOverlay)return;let o=new Set;for(let s of Oe()){let l=s.documentPath.replace(/^\.\//,""),r;try{r=await Vu(s)}catch{continue}if(r.length>Te)continue;if(o.add(l),A.get(l)===r)continue;A.set(l,r),await e.setPreviewOverlay(l,r)}for(let s of A.keys())if(!o.has(s))A.delete(s),await e.clearPreviewOverlay(s)}function ye(){if(!V)return;let e=Date.now();if(B??=e,T)clearTimeout(T);let o=e-B,s=Math.max(0,Math.min(Re,Ee-o));T=setTimeout(()=>{T=null,B=null,Q=pe().finally(()=>{Q=null})},s)}function ZD(){ye()}function XD(){if(V)return;V=!0,I=ge(),I.run(()=>{ne(()=>{for(let e of m.tabs.values())e.doc.dirty,e.doc.document;ye()})})}function QD(){if(V=!1,T)clearTimeout(T),T=null;B=null,I?.stop(),I=null,A.clear()}async function _S(){if(!V)return;if(T)clearTimeout(T),T=null,B=null;await Q,await pe()}var he=/^[A-Za-z0-9][A-Za-z0-9!#$&^_.+-]{0,126}$/,Me=new Set(["vnd","prs","x"]);function $e(e){if(!n(e))return null;let[o,...s]=e.split(";"),l=(o??"").indexOf("/");if(l===-1)return null;let r=(o??"").slice(0,l).trim().toLowerCase(),d=(o??"").slice(l+1).trim().toLowerCase();if(!he.test(r)||!he.test(d))return null;let c=d.lastIndexOf("+"),b=c===-1?null:d.slice(c+1),w=c===-1?d:d.slice(0,c);if(b==="")return null;let k=w.indexOf("."),P=k===-1?null:w.slice(0,k),O=P!==null&&Me.has(P)?P:null,M=O===null?w:w.slice(O.length+1);if(M==="")return null;let F={};for(let x of s){let E=x.indexOf("=");if(E===-1)return null;let t=x.slice(0,E).trim().toLowerCase(),i=x.slice(E+1).trim();if(t==="")return null;if(i.startsWith('"')&&i.endsWith('"')&&i.length>=2)i=i.slice(1,-1);F[t]=i}return{parameters:F,subtype:M,suffix:b,tree:O,type:r}}function $w(e){let o=$e(e);if(o===null)return null;let s=o.tree===null?"":`${o.tree}.`,l=o.suffix===null?"":`+${o.suffix}`;return`${o.type}/${s}${o.subtype}${l}`}var we="text/markdown; variant=GFM",be="application/yaml",Tt={".markdown":`${we}; charset=utf-8`,".md":`${we}; charset=utf-8`,".yaml":`${be}; charset=utf-8`,".yml":`${be}; charset=utf-8`};async function eN(e,o){let s=await oI(e.name,o);return rI(e,s)}async function jr(e,o){await Ht();let s=fn(e);if(!s||!s.capabilities.parse)throw of(e);return{...await eN(s,o),format:s}}var AT=async(e,o)=>{if(e.documentPath&&fn(e.documentPath)){let l=await jr(e.documentPath,o);return e.doc.source=o,{document:l.document,frontmatter:l.frontmatter}}let s=Es(o);return e.doc.layout=s.layout,{document:s.document}};function Fe(e){return"showOpenFilePicker"in e}function De(e){return"showSaveFilePicker"in e}function q(e,o){if(e.documentPath!==null)o.path=e.documentPath;return o}async function sP(){try{await Ht();let e=Qd(),o=[{accept:{"application/json":[".json"]},description:"Jx Component"},...e.filter((r)=>r.capabilities.parse).map((r)=>({accept:{[$w(r.mediaType)??"text/plain"]:r.extensions},description:r.name}))],s=[".json",...e.flatMap((r)=>r.extensions)].join(","),l=async(r,d,c=null)=>{let b=c?await tN(r):null,w=fn(r);if(w){let{document:k,frontmatter:P}=await eN(w,d);_i({document:k,documentPath:b,fileHandle:c,frontmatter:P,id:r,source:d,sourceFormat:w.name})}else if(r.endsWith(".json")){let{document:k,layout:P}=Es(d);_i({document:k,documentPath:b,fileHandle:c,id:r,layout:P})}else throw of(r)};if(Fe(window)){let[r]=await window.showOpenFilePicker({types:o}),d=await r.getFile();await l(r.name,await d.text(),r)}else{let r=document.createElement("input");r.type="file",r.accept=s,r.addEventListener("change",async()=>{let d=r.files?.[0];if(!d)return;await l(d.name,await d.text())}),r.click()}}catch(e){if(!(e instanceof Error&&e.name==="AbortError"))C.error("Could not open the file.",{detail:ee(e),source:"Open File"})}}var ve=()=>{};function OT(e){ve=e}function K(e){let o=e.doc.document;ve(e.documentPath,o,e);let s=n(o.tagName)&&o.tagName.includes("-")?xS(o):null;if(s)C.warn(s,q(e,{key:`slots:${e.documentPath??e.id}`,source:"Components",tier:"problem"}));W(o,e.documentPath??void 0)}function Ne(e){return!Md(e.documentPath??"")}async function wp(e=h.value){if(!e)return!1;if(await hL(e.id),hv(e))return C.warn(`You have read access to this session — changes to ${e.documentPath??"this document"} stay in your browser and cannot be saved.`,q(e,{action:"file.save",key:`save.readOnly:${e.documentPath??e.id}`,source:"Collaboration"})),!1;if(!Ne(e))return C.warn(`${e.documentPath??"This file"} is a media file, so there is no document for Save to write.`,q(e,{key:`save.notADocument:${e.documentPath??e.id}`,source:"Save"})),!1;let o=er(e);if(o)return await o.save(),!e.doc.dirty;try{if(await O$(e))return K(e),!0;let s=await Vu(e);if(e.documentPath){if(await p().writeFile(e.documentPath,s),e.doc.dirty=!1,e.doc.sourceFormat!==null)e.doc.source=s;return _S(),K(e),!0}if(e.fileHandle&&"createWritable"in e.fileHandle){let l=await e.fileHandle.createWritable();if(await l.write(s),await l.close(),e.doc.dirty=!1,e.doc.sourceFormat!==null)e.doc.source=s;return K(e),!0}C.warn("This document has no save target — use Export.",{key:"save.noTarget"})}catch(s){if(!(s instanceof Error&&s.name==="AbortError"))C.error(`Could not save ${e.documentPath??e.id}.`,q(e,{action:"file.save",detail:ee(s),key:`save:${e.documentPath??e.id}`,source:"Save"}))}return!1}function Ae(e){return Wi(e.doc.sourceFormat)??(e.doc.mode==="content"?lr():void 0)}async function MT(){let e=h.value;if(!e)return;try{await Ht();let o=Ae(e),s=await Vu(e),l=o?$w(o.mediaType)??"text/plain":"application/json",r=o?o.extensions[0]:".json",d=o?o.name:"Jx Component",c=o?`content${r}`:"component.json";if(De(window)){let b=e.documentPath?e.documentPath.split("/").pop():c,w=await window.showSaveFilePicker({suggestedName:b,types:[{accept:{[l]:[r]},description:d}]}),k=await w.createWritable();await k.write(s),await k.close(),e.doc.dirty=!1,K(e),C.success(`Exported as ${w.name}.`)}else{let b=new Blob([s],{type:l}),w=URL.createObjectURL(b),k=document.createElement("a");k.href=w,k.download=c,k.click(),URL.revokeObjectURL(w),e.doc.dirty=!1,K(e),C.success(`Downloaded ${c}.`)}}catch(o){if(!(o instanceof Error&&o.name==="AbortError"))C.error("Could not export the document.",{detail:ee(o),source:"Export"})}}async function Ce(e,o){let s=Md(e)?await Gu(e):await La({path:e});return T$(s,o)??""}async function _b(e){let o=await Ce(e.path,"delete"),s=`Delete ${e.name}? This cannot be undone.`;return Boolean(await qo("Delete File",o===""?s:`${s} ${o}`,{confirmLabel:"Delete",destructive:!0}))}async function Sb(e,o="rename"){let s=await Ce(e,o);return s===""?void 0:s}
2
+ export{Ew,xb,ls,Bl,vm,Tw,Lw,vp,Qo,wS,er,yp,xS,YD,Vu,ZD,XD,QD,_S,$w,eN,jr,AT,sP,OT,wp,MT,_b,Sb};
3
3
 
4
- //# debugId=5BAD2E3D787BF64764756E2164756E21
5
- //# sourceMappingURL=studio-c1pxszat.js.map
4
+ //# debugId=409DA507035DDBFB64756E2164756E21
5
+ //# sourceMappingURL=studio-ga77mf07.js.map
@@ -1,7 +1,7 @@
1
- import{pt,Uo,Np,xr}from"./studio-771k2n12.js";import{g}from"./studio-4kzbrr5t.js";import{h}from"./studio-5wzdy1jc.js";import{ln,sv,u}from"./studio-vzgmyt0v.js";import{S}from"./studio-45gyxpcq.js";var kb=["application","project","document","selection"],pN=["global","canvas","caret","grid","code","dock","palette"],fN=["File","Edit","Selection","Insert","View","Document","Project","Source Control","Publish","Assistant","Collaborate","Help"],v=["commandbar/primary","commandbar/overflow","statusbar/project","statusbar/document","statusbar/selection","context/element","context/file","context/layer","context/tab","context/pane","blockbar","blockbar/format","outline/row","settings/menu","palette","never"],P={"commandbar/primary":{admits:["application","document"],note:"document only for Save / Undo / Redo / Open in Browser, by frequency; ≤5 total"},"commandbar/overflow":{admits:["application","project","document"],note:"never selection — the Command Bar is not a selection surface"},"statusbar/project":{admits:["project"],note:"the status bar's left field"},"statusbar/document":{admits:["document"],note:"the status bar's centre field"},"statusbar/selection":{admits:["selection"],note:"the status bar's right field"},"context/element":{admits:["selection"],note:"the canvas element menu acts on a selection"},"context/file":{admits:["project"],note:"a file row addresses the project's file set"},"context/layer":{admits:["selection"],note:"an outline row IS a selection"},"context/tab":{admits:["document"],note:"a tab addresses one document"},"context/pane":{admits:["document"],note:"a pane hosts one document"},blockbar:{admits:["selection"],note:"the floating bar owns selection-scoped verbs"},"blockbar/format":{admits:["selection"],note:"the bar's inline-format cluster — a range inside the selection is still the selection"},"outline/row":{admits:["selection"],note:"row actions act on the row's node"},"settings/menu":{admits:["application","project"],note:"the rail foot's gear menu — the settings family. It is a MENU, not a pinned slot, so it "+"may host two levels for the reason commandbar/overflow does: a menu prints each row's own name, chord and gate, and draws a divider where the level changes. The rail's PINNED groups stay single-level, in PANEL_PLACEMENT_MATRIX"},palette:{admits:["application","project","document","selection"],note:"the level-agnostic surface; it groups rows by level"},never:{admits:["application","project","document","selection"],note:"keyboard- and API-only; no rendered surface to be misplaced in"}},b=["rail/project","rail/document","navigator","inspector","dock.bottom"],x={"rail/project":{admits:["project"],note:"the rail's upper group — Site, and Files with the developer panels on"},"rail/document":{admits:["document"],note:"the rail's lower group — Outline, Data, and Packages with the developer panels on"},navigator:{admits:["project","document"],note:"whichever level the hosted panel declares; the panel header prints it"},inspector:{admits:["document","selection"],note:"Page is the open document's tab, Element the selection's (§6)"},"dock.bottom":{admits:["project","document"],note:"the panel header states which"}};function y(e){return e==="bottom"?"dock.bottom":e}function w(e){let t=[y(e.dock)];if(e.rail!==!1)t.push(`rail/${e.level}`);return t}function E(e){return b.some((t)=>t===e)}function c(e){let t=[];if(!d(e.level))return t.push({panelId:e.id,placement:"—",level:String(e.level),message:`declares unknown level "${String(e.level)}" (expected one of: ${kb.join(", ")})`}),t;for(let n of w(e)){if(!E(n)){t.push({panelId:e.id,placement:n,level:e.level,message:`is level "${e.level}" and would render in "${n}", which is not a panel `+"placement — the rail has a group for project and one for document, and nothing else"});continue}let o=x[n];if(!o.admits.includes(e.level))t.push({panelId:e.id,placement:n,level:e.level,message:`is level "${e.level}" but "${n}" admits only ${o.admits.join(", ")} — ${o.note}`})}return t}function C(e){return v.some((t)=>t===e)}function d(e){return kb.some((t)=>t===e)}function mN(e){let t=[];if(!d(e.level))return t.push({commandId:e.id,placement:"—",level:String(e.level),message:`declares unknown level "${String(e.level)}" (expected one of: ${kb.join(", ")})`}),t;for(let n of e.menus??[]){if(!C(n)){t.push({commandId:e.id,placement:String(n),level:e.level,message:`declares unknown placement "${String(n)}"`});continue}let o=P[n];if(!o.admits.includes(e.level))t.push({commandId:e.id,placement:n,level:e.level,message:`is level "${e.level}" but "${n}" admits only ${o.admits.join(", ")} — ${o.note}`})}return t}var l="true",i=g({on:Uo(pt.developerPanels)===l});Np((e)=>{if(e.includes(pt.developerPanels.key))i.on=Uo(pt.developerPanels)===l});function CS(){return i.on}function gN(e){i.on=e,xr(pt.developerPanels,e?l:"")}function Ku(){let e=sv();return e.project.open=S!==null,e.project.isMultilingual=(ln(S?.projectConfig??{}).i18n?.locales.length??0)>1,e.git.dirtyCount=h.git.status?.files.length??0,e.workspace.id=h.workspace,e.document.open=u.value!==null,e}var L=/^[a-z][\w-]*$/,a=new Map;function Xn(e){if(!L.test(e.id))throw Error(`Panel id "${e.id}" is malformed — expected /^[a-z][\\w-]*$/, because the id is also `+`the region "navigator/panel:${e.id}" and the value view.setActivity accepts.`);if(a.has(e.id))throw Error(`Panel "${e.id}" is already registered — a second definition site is the defect this `+"registry exists to prevent.");let t=c({id:e.id,level:e.level,dock:e.dock,rail:e.rail});if(t.length>0){let n=t.map((o)=>` ✗ ${e.id} ${o.message}`).join(`
1
+ import{pt,Uo,Np,xr}from"./studio-xebavr9s.js";import{g}from"./studio-ahf3cspq.js";import{u}from"./studio-dbgv4fv9.js";import{ln,sv,h}from"./studio-j933k8nr.js";import{S}from"./studio-rt498t2v.js";var kb=["application","project","document","selection"],pN=["global","canvas","caret","grid","code","dock","palette"],fN=["File","Edit","Selection","Insert","View","Document","Project","Source Control","Publish","Assistant","Collaborate","Help"],v=["commandbar/primary","commandbar/overflow","statusbar/project","statusbar/document","statusbar/selection","context/element","context/file","context/layer","context/tab","context/pane","blockbar","blockbar/format","outline/row","settings/menu","palette","never"],P={"commandbar/primary":{admits:["application","document"],note:"document only for Save / Undo / Redo / Open in Browser, by frequency; ≤5 total"},"commandbar/overflow":{admits:["application","project","document"],note:"never selection — the Command Bar is not a selection surface"},"statusbar/project":{admits:["project"],note:"the status bar's left field"},"statusbar/document":{admits:["document"],note:"the status bar's centre field"},"statusbar/selection":{admits:["selection"],note:"the status bar's right field"},"context/element":{admits:["selection"],note:"the canvas element menu acts on a selection"},"context/file":{admits:["project"],note:"a file row addresses the project's file set"},"context/layer":{admits:["selection"],note:"an outline row IS a selection"},"context/tab":{admits:["document"],note:"a tab addresses one document"},"context/pane":{admits:["document"],note:"a pane hosts one document"},blockbar:{admits:["selection"],note:"the floating bar owns selection-scoped verbs"},"blockbar/format":{admits:["selection"],note:"the bar's inline-format cluster — a range inside the selection is still the selection"},"outline/row":{admits:["selection"],note:"row actions act on the row's node"},"settings/menu":{admits:["application","project"],note:"the rail foot's gear menu — the settings family. It is a MENU, not a pinned slot, so it "+"may host two levels for the reason commandbar/overflow does: a menu prints each row's own name, chord and gate, and draws a divider where the level changes. The rail's PINNED groups stay single-level, in PANEL_PLACEMENT_MATRIX"},palette:{admits:["application","project","document","selection"],note:"the level-agnostic surface; it groups rows by level"},never:{admits:["application","project","document","selection"],note:"keyboard- and API-only; no rendered surface to be misplaced in"}},b=["rail/project","rail/document","navigator","inspector","dock.bottom"],x={"rail/project":{admits:["project"],note:"the rail's upper group — Site, and Files with the developer panels on"},"rail/document":{admits:["document"],note:"the rail's lower group — Outline, Data, and Packages with the developer panels on"},navigator:{admits:["project","document"],note:"whichever level the hosted panel declares; the panel header prints it"},inspector:{admits:["document","selection"],note:"Page is the open document's tab, Element the selection's (§6)"},"dock.bottom":{admits:["project","document"],note:"the panel header states which"}};function y(e){return e==="bottom"?"dock.bottom":e}function w(e){let t=[y(e.dock)];if(e.rail!==!1)t.push(`rail/${e.level}`);return t}function E(e){return b.some((t)=>t===e)}function c(e){let t=[];if(!d(e.level))return t.push({panelId:e.id,placement:"—",level:String(e.level),message:`declares unknown level "${String(e.level)}" (expected one of: ${kb.join(", ")})`}),t;for(let n of w(e)){if(!E(n)){t.push({panelId:e.id,placement:n,level:e.level,message:`is level "${e.level}" and would render in "${n}", which is not a panel `+"placement — the rail has a group for project and one for document, and nothing else"});continue}let o=x[n];if(!o.admits.includes(e.level))t.push({panelId:e.id,placement:n,level:e.level,message:`is level "${e.level}" but "${n}" admits only ${o.admits.join(", ")} — ${o.note}`})}return t}function C(e){return v.some((t)=>t===e)}function d(e){return kb.some((t)=>t===e)}function mN(e){let t=[];if(!d(e.level))return t.push({commandId:e.id,placement:"—",level:String(e.level),message:`declares unknown level "${String(e.level)}" (expected one of: ${kb.join(", ")})`}),t;for(let n of e.menus??[]){if(!C(n)){t.push({commandId:e.id,placement:String(n),level:e.level,message:`declares unknown placement "${String(n)}"`});continue}let o=P[n];if(!o.admits.includes(e.level))t.push({commandId:e.id,placement:n,level:e.level,message:`is level "${e.level}" but "${n}" admits only ${o.admits.join(", ")} — ${o.note}`})}return t}var l="true",i=g({on:Uo(pt.developerPanels)===l});Np((e)=>{if(e.includes(pt.developerPanels.key))i.on=Uo(pt.developerPanels)===l});function CS(){return i.on}function gN(e){i.on=e,xr(pt.developerPanels,e?l:"")}function Ku(){let e=sv();return e.project.open=S!==null,e.project.isMultilingual=(ln(S?.projectConfig??{}).i18n?.locales.length??0)>1,e.git.dirtyCount=u.git.status?.files.length??0,e.workspace.id=u.workspace,e.document.open=h.value!==null,e}var L=/^[a-z][\w-]*$/,a=new Map;function Xn(e){if(!L.test(e.id))throw Error(`Panel id "${e.id}" is malformed — expected /^[a-z][\\w-]*$/, because the id is also `+`the region "navigator/panel:${e.id}" and the value view.setActivity accepts.`);if(a.has(e.id))throw Error(`Panel "${e.id}" is already registered — a second definition site is the defect this `+"registry exists to prevent.");let t=c({id:e.id,level:e.level,dock:e.dock,rail:e.rail});if(t.length>0){let n=t.map((o)=>` ✗ ${e.id} ${o.message}`).join(`
2
2
  `);throw Error(`Panel "${e.id}" violates the level × placement matrix:
3
3
  ${n}`)}if(e.railLabel!==void 0&&(e.railLabel.trim()===""||!e.title.startsWith(e.railLabel)))throw Error(`Panel "${e.id}" declares railLabel "${e.railLabel}", which is not a leading part of its title "${e.title}": the rail button's accessible name is the title, and the words on screen must be inside it (WCAG 2.5.3, Label in Name).`);a.set(e.id,e)}function Sp(e){return a.get(e)}function Mw(e){let t=[...a.values()];return e?t.filter((n)=>n.dock===e):t}function Pw(e,t){return e.when?e.when(t):!0}var m=[{level:"project",label:"Project"},{level:"document",label:"Document"}];function p(){return Mw().filter((e)=>e.rail!==!1)}function JT(e){let t=CS(),n=p().filter((o)=>o.rail!=="developer"||t);return m.flatMap(({level:o,label:f})=>{let r=n.filter((s)=>s.level===o&&Pw(s,e));return r.length>0?[{level:o,label:f,panels:r}]:[]})}function bN(){let e=p();return m.flatMap(({level:t})=>e.filter((n)=>n.level===t))}
4
4
  export{kb,pN,fN,mN,CS,gN,Ku,Xn,Sp,Mw,Pw,JT,bN};
5
5
 
6
- //# debugId=0ED6B88C34071E3E64756E2164756E21
7
- //# sourceMappingURL=studio-9cxmp61c.js.map
6
+ //# debugId=69CF7F353EB47BD064756E2164756E21
7
+ //# sourceMappingURL=studio-ggm7zf70.js.map
@@ -0,0 +1,5 @@
1
+ import{pt,Uo,xr,Ap}from"./studio-xebavr9s.js";function db(){return Uo(pt.cfToken)}function DE(t){xr(pt.cfToken,t||"")}function NE(){return Uo(pt.cfAccountId)}function Q2(t){xr(pt.cfAccountId,t||"")}function AE(){Ap([pt.cfToken,pt.cfAccountId])}
2
+ export{db,DE,NE,Q2,AE};
3
+
4
+ //# debugId=D4568931CAC8F09264756E2164756E21
5
+ //# sourceMappingURL=studio-h7gy12h2.js.map
@@ -1,9 +1,9 @@
1
- import{Mp}from"./studio-cpkamjdn.js";import{Ox,u}from"./studio-vzgmyt0v.js";import{g}from"./studio-4kzbrr5t.js";import{to,wr,Qw,h}from"./studio-5wzdy1jc.js";import{Ne}from"./studio-1e8dw2w2.js";import{T,R}from"./studio-jttyqrmh.js";import{vt,tl,ji,Mc,Ep,Br,RL,ML}from"./studio-pqqq6v85.js";import{gS,RT,bS}from"./studio-pgm83a2f.js";import{S,cl}from"./studio-45gyxpcq.js";import{Qd}from"./studio-ekgtrndg.js";import{n,Z,_,Di,ed}from"./studio-zkq3r91p.js";import{le}from"./studio-7xag4na8.js";var Ay="Project Styles",$u="stylebook",Zf="tokens",Y="source",Ug={elements:$u,variables:Zf,code:Y},h_=["elements","variables","code"],CR=h_.map((e)=>Ug[e]),p_=[{id:"color",prefix:"--color-",title:"Colors"},{id:"font",prefix:"--font-",title:"Fonts"},{id:"size",prefix:"--size-",title:"Sizes & Spacing"},{id:"other",prefix:"--",title:"Other"}];function f_(e){if(e.startsWith("--color"))return"color";if(e.startsWith("--font"))return"font";if(e.startsWith("--size")||e.startsWith("--spacing")||e.startsWith("--radius"))return"size";return"other"}function K(e){let o=f_(e);if(o==="other")return e;let{prefix:t}=p_.find((r)=>r.id===o);return Ox(e,t)}function Q(e){if(!e)return[];let o=[];for(let[t,r]of Object.entries(e)){if(!t.startsWith("--"))continue;if(!n(r)&&!Z(r))continue;o.push({group:f_(t),label:K(t),name:t,value:r})}return o}function m_(e){let o=Q(e);return p_.map((t)=>({group:t,tokens:o.filter((r)=>r.group===t.id)}))}function g_(e){if(!e)return[];let{featureQueries:o,sizeBreakpoints:t}=Br(e),r=[],a=[];for(let{name:l,query:d}of o){let k=Ep(d);if(k)r.push({key:`@${l}`,kind:"scheme",label:k==="dark"?"Dark":"Light",name:l,scheme:k});else a.push({key:`@${l}`,kind:"feature",label:`@${l}`,name:l})}let i=t.map(({name:l})=>({key:`@${l}`,kind:"size",label:`@${l}`,name:l}));return[...r,...i,...a]}function J(e,o){return Di(e,o.key)}function Oy(e,o,t){let r=J(e,o)?.[t];return n(r)||Z(r)?r:void 0}function Nk(e,o,t,r){if(r){ed(e,o.key)[t]=r;return}let a=J(e,o);if(!a)return;if(delete a[t],Object.keys(a).length===0)delete e[o.key]}function kR(e,o,t,r=[]){let a=new Set(r.map((i)=>i.name));return o.filter((i)=>!a.has(i.name)&&Oy(e,i,t)===void 0)}var lp={$sections:[{label:"Headings",elements:[{tag:"h1",text:"Code Is Poetry"},{tag:"h2",text:"Code Is Poetry"},{tag:"h3",text:"Code Is Poetry"},{tag:"h4",text:"Code Is Poetry"},{tag:"h5",text:"Code Is Poetry"},{tag:"h6",text:"Code Is Poetry"}]},{label:"Paragraph",elements:[{tag:"p",text:"In a village of La Mancha, the name of which I have no desire to call to mind, there lived not long since one of those gentlemen that keep a lance in the lance-rack, an old buckler, a lean hack, and a greyhound for coursing."}]},{label:"List",elements:[{tag:"ul",children:[{tag:"li",text:"Alice."},{tag:"li",text:"The White Rabbit."},{tag:"li",text:"The Cheshire Cat."},{tag:"li",text:"The Mad Hatter."},{tag:"li",text:"The Queen of Hearts."}]},{tag:"ol",children:[{tag:"li",text:"First item"},{tag:"li",text:"Second item"},{tag:"li",text:"Third item"}]}]},{label:"Quote",elements:[{tag:"blockquote",children:[{tag:"p",text:"In quoting others, we cite ourselves.",style:"font-size:1.25em;font-style:italic"},{tag:"p",text:"— Julio Cortázar"}]}]},{label:"Code",elements:[{tag:"pre",children:[{tag:"code",text:`// A "block" is the abstract term used
1
+ import{Mp}from"./studio-f2j9et3h.js";import{Ox,h}from"./studio-j933k8nr.js";import{g}from"./studio-ahf3cspq.js";import{to,wr,Qw,u}from"./studio-dbgv4fv9.js";import{Ne}from"./studio-nf0pqpbj.js";import{T,R}from"./studio-cvz0e00f.js";import{vt,tl,ji,Pc,Ep,Br,RL,ML}from"./studio-695k95bw.js";import{gS,RT,bS}from"./studio-76t560kn.js";import{S,cl}from"./studio-rt498t2v.js";import{eu}from"./studio-tpy3rdxn.js";import{n,Z,_,Di,td}from"./studio-zsjpsw08.js";import{le}from"./studio-0g2sm01j.js";var Ay="Project Styles",$u="stylebook",Zf="tokens",Y="source",Ug={elements:$u,variables:Zf,code:Y},h_=["elements","variables","code"],CR=h_.map((e)=>Ug[e]),p_=[{id:"color",prefix:"--color-",title:"Colors"},{id:"font",prefix:"--font-",title:"Fonts"},{id:"size",prefix:"--size-",title:"Sizes & Spacing"},{id:"other",prefix:"--",title:"Other"}];function f_(e){if(e.startsWith("--color"))return"color";if(e.startsWith("--font"))return"font";if(e.startsWith("--size")||e.startsWith("--spacing")||e.startsWith("--radius"))return"size";return"other"}function K(e){let o=f_(e);if(o==="other")return e;let{prefix:t}=p_.find((r)=>r.id===o);return Ox(e,t)}function Q(e){if(!e)return[];let o=[];for(let[t,r]of Object.entries(e)){if(!t.startsWith("--"))continue;if(!n(r)&&!Z(r))continue;o.push({group:f_(t),label:K(t),name:t,value:r})}return o}function m_(e){let o=Q(e);return p_.map((t)=>({group:t,tokens:o.filter((r)=>r.group===t.id)}))}function g_(e){if(!e)return[];let{featureQueries:o,sizeBreakpoints:t}=Br(e),r=[],a=[];for(let{name:l,query:d}of o){let k=Ep(d);if(k)r.push({key:`@${l}`,kind:"scheme",label:k==="dark"?"Dark":"Light",name:l,scheme:k});else a.push({key:`@${l}`,kind:"feature",label:`@${l}`,name:l})}let i=t.map(({name:l})=>({key:`@${l}`,kind:"size",label:`@${l}`,name:l}));return[...r,...i,...a]}function J(e,o){return Di(e,o.key)}function Oy(e,o,t){let r=J(e,o)?.[t];return n(r)||Z(r)?r:void 0}function Nk(e,o,t,r){if(r){td(e,o.key)[t]=r;return}let a=J(e,o);if(!a)return;if(delete a[t],Object.keys(a).length===0)delete e[o.key]}function kR(e,o,t,r=[]){let a=new Set(r.map((i)=>i.name));return o.filter((i)=>!a.has(i.name)&&Oy(e,i,t)===void 0)}var lp={$sections:[{label:"Headings",elements:[{tag:"h1",text:"Code Is Poetry"},{tag:"h2",text:"Code Is Poetry"},{tag:"h3",text:"Code Is Poetry"},{tag:"h4",text:"Code Is Poetry"},{tag:"h5",text:"Code Is Poetry"},{tag:"h6",text:"Code Is Poetry"}]},{label:"Paragraph",elements:[{tag:"p",text:"In a village of La Mancha, the name of which I have no desire to call to mind, there lived not long since one of those gentlemen that keep a lance in the lance-rack, an old buckler, a lean hack, and a greyhound for coursing."}]},{label:"List",elements:[{tag:"ul",children:[{tag:"li",text:"Alice."},{tag:"li",text:"The White Rabbit."},{tag:"li",text:"The Cheshire Cat."},{tag:"li",text:"The Mad Hatter."},{tag:"li",text:"The Queen of Hearts."}]},{tag:"ol",children:[{tag:"li",text:"First item"},{tag:"li",text:"Second item"},{tag:"li",text:"Third item"}]}]},{label:"Quote",elements:[{tag:"blockquote",children:[{tag:"p",text:"In quoting others, we cite ourselves.",style:"font-size:1.25em;font-style:italic"},{tag:"p",text:"— Julio Cortázar"}]}]},{label:"Code",elements:[{tag:"pre",children:[{tag:"code",text:`// A "block" is the abstract term used
2
2
  // to describe units of markup that
3
3
  // when composed together, form the
4
4
  // content or layout of a page.
5
- registerBlockType( name, settings );`}]}]},{label:"Inline",elements:[{tag:"a",text:"Visit the documentation",attributes:{href:"#"}},{tag:"strong",text:"Bold text emphasis"},{tag:"em",text:"Italic text emphasis"},{tag:"small",text:"Fine print and legal text"},{tag:"mark",text:"Highlighted text"},{tag:"code",text:"const x = 42;"},{tag:"abbr",text:"HTML",attributes:{title:"HyperText Markup Language"}},{tag:"sub",text:"subscript"},{tag:"sup",text:"superscript"}]},{label:"Form",elements:[{tag:"input",attributes:{type:"text",placeholder:"Enter text…"}},{tag:"button",text:"Click Me"},{tag:"select",children:[{tag:"option",text:"Option 1"},{tag:"option",text:"Option 2"},{tag:"option",text:"Option 3"}]},{tag:"textarea",attributes:{placeholder:"Enter longer text…",rows:"3"}}]},{label:"Table",elements:[{tag:"table",children:[{tag:"thead",children:[{tag:"tr",children:[{tag:"th",text:"Name"},{tag:"th",text:"Role"},{tag:"th",text:"Status"}]}]},{tag:"tbody",children:[{tag:"tr",children:[{tag:"td",text:"Alice"},{tag:"td",text:"Developer"},{tag:"td",text:"Active"}]},{tag:"tr",children:[{tag:"td",text:"Bob"},{tag:"td",text:"Designer"},{tag:"td",text:"Away"}]},{tag:"tr",children:[{tag:"td",text:"Carol"},{tag:"td",text:"Manager"},{tag:"td",text:"Active"}]}]}]}]},{label:"Interactive",elements:[{tag:"details",attributes:{open:""},children:[{tag:"summary",text:"Click to expand details"},{tag:"p",text:"Additional detail content revealed when the disclosure widget is toggled open."}]}]},{label:"Media",elements:[{tag:"img",attributes:{alt:"Placeholder image"},style:"width:100%;max-width:400px;height:200px;background:#e0e0e0;display:block;border-radius:4px"},{tag:"video",attributes:{controls:""},style:"width:100%;max-width:400px;height:200px;background:#e0e0e0;display:block;border-radius:4px"},{tag:"audio",attributes:{controls:""},style:"width:100%"}]}],$variables:{color:{label:"Color",prefix:"--color-",placeholder:"#007acc"},font:{label:"Font",prefix:"--font-",placeholder:"system-ui, sans-serif"},size:{label:"Size",prefix:"--size-",placeholder:"16px"},other:{label:"Other",prefix:"--",placeholder:"value"}}};var D={$schema:"https://jxsuite.com/schema/v1",$id:"StudioStylebookChrome",$description:"The bar across the top of the Project Styles canvas: the filter that narrows the specimen catalogue, and the toggle that reduces it to the elements this file has already styled. Both are shell state rather than document state — the adapter owns which — and the two names come in as values, because the surface is called Project Styles and the canvas view it draws is the wire word `stylebook`; nothing a reader sees here may be spelled from that. **The bar IS the kit's toolbar now.** It used to write `role=\"toolbar\"` and its own `aria-label` on a `<div>`, which is a role with none of the behaviour under it: two controls, two tab stops, and no arrow key between them. `jx-action-group` is not the element for it — that one roves `jx-action-button` and this bar's first control is a `jx-textfield` — so `jx-toolbar` is, and the field keeps its own arrows while its caret still has text to walk (ui.md §5.5).",tagName:"jx-toolbar",attributes:{part:"chrome"},$props:{label:{$ref:"#/state/title"}},style:{$description:'What `.sb-chrome` said in `styles/overlays.css`, plus the six inline declarations the template carried beside it, plus `.tb-toggle` — all three go dead with this conversion, and none of them is shared with another surface. Three repairs on the way. The bar is one element rather than a positioned box wrapping a `role="toolbar"` row that declared the same flex layout again. The flex layout is not declared here EITHER any more: `display: flex`, `align-items: center`, the `--jx-space-2` gap, the sans face and the foreground colour are all `jx-toolbar`\'s own, so what is left below is only what a positioned BAND is. And `.tb-toggle` read `var(--spectrum-font-size-50, 11px)`, which the kit spells `--jx-text-sm` at the same value; the rest of its drawing is a `jx-action-button` reaching in through `part="control"`, because what it has to look like is a small bordered chip and every fill and control height the kit draws would otherwise have to be taken back off.',position:"absolute",top:"0",left:"0",right:"0",zIndex:"15",flexShrink:"0",padding:"var(--jx-space-2) var(--jx-space-3)",background:"var(--bg-panel)",borderBottom:"1px solid var(--border)",'& [part="filter"]':{flex:"1",maxWidth:"200px"},'& [part="customized"] > [part="control"]':{$description:"Bordered, unfilled and dimmed until it is on, which is what says it is a filter rather than an action: the catalogue it narrows is the thing the reader is looking at, so the control has to be quieter than its subject.",padding:"3px var(--jx-space-3)",border:"1px solid var(--border)",borderRadius:"var(--radius)",background:"transparent",color:"var(--fg-dim)",fontSize:"var(--jx-text-sm)",":hover":{background:"var(--hover-bg)"}},'& [part="customized"][data-selected] > [part="control"]':{$description:"`data-selected` and not `selected`: the kit reflects the pressed state as a data attribute (`jx-action-button.json`), and the property this document binds never reaches the attribute of the same name.",borderColor:"var(--accent)",background:"var(--accent-15)",color:"var(--accent)"}},children:[{tagName:"jx-textfield",attributes:{part:"filter"},$props:{size:"sm",type:"search",clearable:!0,label:{$ref:"#/state/filterLabel"},placeholder:"Filter…",value:{$ref:"#/state/filter"}},oninput:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/setFilter"},value:[{$ref:"event#/target/value"}]}]}},{tagName:"jx-action-button",$description:"`onchange` and not `onclick`: a `toggles` button owns its own pressed state and says so with `change` (`jx-action-button.json`), and an `onclick` written here would replace the element's own click handler on the same property — the toggle would stop flipping and stop announcing `aria-pressed`.",attributes:{part:"customized"},$props:{size:"sm",toggles:!0,selected:{$ref:"#/state/customizedOnly"},label:{$ref:"#/state/customizedLabel"},hint:{$ref:"#/state/customizedHint"}},onchange:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/toggleCustomized"},value:[]}]},children:[{tagName:"span",textContent:"${state.customizedLabel}"}]}]};T("stylebook-chrome",D);function W(e,o){let t=document.createElement("div");t.style.display="contents";let r=g({...e,...o}),a=null,i=!1;function l(){i=!0,R("stylebook-chrome",r,t).then((d)=>{i=!1,a=d})}return l(),{host:t,update(d){if(Object.assign(r,d),i||a!==null&&t.contains(a.root))return;a?.dispose(),a=null,t.textContent="",l()}}}function L(e){return!e.startsWith(":")&&!e.startsWith(".")&&!e.startsWith("&")&&!e.startsWith("[")&&!e.startsWith("@")&&!e.startsWith("--")}function j(e){return _(e)&&!Array.isArray(e)}var A="& .element-card-preview";function My(e){let o={},t=(r)=>{let a={};for(let[i,l]of Object.entries(r))if(i!=="@--")a[i]=l;return a};for(let[r,a]of Object.entries(e)){if(!j(a)){o[r]=a;continue}if(r==="@--")continue;if(Mp(r)){o[r]=a;continue}if(r.startsWith("@")){let i={};for(let[l,d]of Object.entries(a))if(j(d)&&L(l))i[`${A} ${l}`]=t(d);else i[l]=d;o[r]=i;continue}if(L(r)){o[`${A} ${r}`]=t(a);continue}o[r]=a}return o}function B(e,o){let t=o.split(" "),r=e;for(let a of t){if(!j(r))return null;r=r[a]}return j(r)?r:null}function Py(e,o){let t=B(e,o);if(t&&Object.keys(t).length>0)return!0;for(let[r,a]of Object.entries(e)){if(!r.startsWith("@")||!j(a))continue;let i=B(a,o);if(i&&Object.keys(i).length>0)return!0}return!1}function te(e){if(!e)return null;return e.split(" ").pop()??null}function Fy(e,o){let t=te(o),r=[],a=(i,l,d)=>{let k=d?`${d} ${i.tag}`:i.tag;r.push({depth:l,entry:i,path:k,selected:i.tag===t,tag:i.tag});let w=i.children?[...new Map(i.children.map((v)=>[v.tag,v])).values()]:[];for(let v of w)a(v,l+1,k)};for(let i of e)a(i,0,"");return r}function H(e){let o=new Map,t=new Map,r=e.filter.toLowerCase(),a=(s,p,f)=>{let c=s.tag===f?f:`${f} ${s.tag}`;o.set(Mc(p),c);let b=s.children??[];for(let[y,N]of b.entries())a(N,[...p,"children",y],f)},i=(s)=>{let p={...s.attributes};if(s.style)p.style=s.style;let f={tagName:s.tag};if(s.text)f.textContent=s.text;if(Object.keys(p).length>0)f.attributes=p;if(s.children)f.children=s.children.map(i);return f},l=(s,p,f,c,b)=>{o.set(Mc(c),s),o.set(Mc([...c,"children",0]),s);let y=[...c,"children",0,"children",0];if(b)a(b,y,s);else o.set(Mc(y),s);if(!t.has(s))t.set(s,c);return{attributes:{class:"element-card"},children:[{attributes:{class:"element-card-preview"},children:[f],tagName:"div"},{attributes:{class:"element-card-label"},tagName:"div",textContent:p}],tagName:"div"}},d=[],k=(s,p)=>({attributes:{class:"sb-section"},children:[{attributes:{class:"sb-label"},tagName:"div",textContent:s},{attributes:{class:"sb-body"},children:p,tagName:"div"}],tagName:"div"}),w=()=>["children",d.length,"children",1];for(let s of e.meta.$sections){let p=s.elements;if(r)p=p.filter((b)=>b.tag.includes(r)||s.label.toLowerCase().includes(r));if(e.customizedOnly)p=p.filter((b)=>Py(e.effectiveStyle,b.tag));if(p.length===0)continue;let f=w(),c=p.map((b,y)=>l(b.tag,`<${b.tag}>`,i(b),[...f,"children",y],b));d.push(k(s.label,c))}let v=[];{let s=e.components;if(r)s=s.filter((p)=>p.tagName.toLowerCase().includes(r));if(e.customizedOnly)s=s.filter((p)=>Py(e.effectiveStyle,p.tagName));if(s.length>0){let p=w(),f=s.map((c,b)=>{let y=[...p,"children",b];if(c.source!=="npm"&&c.path?.endsWith(".json")){v.push({$ref:`/${e.projectRoot?`${e.projectRoot}/`:""}${c.path}`.replace(/^\/+/,"/")});let P=e.specimens?.get(c.tagName);if(P?.kind==="props"){let m={$props:P.props,tagName:c.tagName};return l(c.tagName,`<${c.tagName}>`,m,y,null)}if(P?.kind!=="none"){let m={};for(let E of c.props??[])if(E.default!==void 0&&E.default!=="false"&&E.default!=="''")m[E.name]=String(E.default).replaceAll(/^'|'$/g,"");let O={tagName:c.tagName};if(Object.keys(m).length>0)O.attributes=m;return l(c.tagName,`<${c.tagName}>`,O,y,null)}}let M={attributes:{class:"sb-fallback"},tagName:"div",textContent:`<${c.tagName}>`};return l(c.tagName,`<${c.tagName}>`,M,y,null)});d.push(k("Components",f))}}if(d.length===0)d.push({attributes:{class:"sb-empty"},tagName:"div",textContent:e.customizedOnly?"No customized elements":"No matching elements"});let x={};if(v.length>0)x.$elements=v;if(e.effectiveHead&&e.effectiveHead.length>0)x.$head=e.effectiveHead;return x.$media=e.effectiveMedia,x.attributes={class:"sb-root"},x.children=d,x.style=My(e.effectiveStyle),x.tagName="div",{doc:x,pathToTag:o,tagToCardPath:t}}var V=new WeakMap;async function oe(e){let{path:o}=e;if(e.source==="npm"||!o?.endsWith(".json"))return{kind:"bare"};let t=await RT(o);if(!t)return{kind:"bare"};let r=gS(t);if(r.size>0&&await bS(t,o,r))return{kind:"props",props:Object.fromEntries(r)};return await bS(t,o,new Map)?{kind:"bare"}:{kind:"none"}}async function q(e,o=oe){let t=V.get(e);if(!t)t=new Map,V.set(e,t);let r=t,a=await Promise.all(e.map(async(i)=>{let l=i.path??i.tagName,d=r.get(l);if(!d)d=o(i).catch(()=>({kind:"bare"})),r.set(l,d);return[i.tagName,await d]}));return new Map(a)}var F=new WeakMap;function ne(e){let o={customizedHint:"Show only the elements this file has already styled",customizedLabel:"Customized",customizedOnly:h.stylebook.customizedOnly,filter:h.stylebook.filter,filterLabel:`Filter the ${Ay} catalogue`,title:Ay},t=F.get(e);if(t)return t.update(o),t.host;let r=W(o,{setFilter:(a)=>{h.stylebook.filter=a},toggleCustomized:()=>{h.stylebook.customizedOnly=!h.stylebook.customizedOnly}});return F.set(e,r),r.host}function re(e,o){let t=e.filter((r)=>r.name===(o??"base"));return t.length>0?t:e.slice(0,1)}async function ER(e,o){let t=e.wrap,r=vt(e.paneId),a=h.stylebook.filter.toLowerCase(),{customizedOnly:i}=h.stylebook,l=e.renderGeneration,d=Ne,k=q(d),w=to(r?.doc.document?.$media),{sizeBreakpoints:v,baseWidth:x}=Br(w),s=v.length>0,p=ne(e);t.style.overflow="hidden";let f=[];if(s){f.push({displayName:ji("--"),name:"base",width:x});for(let m of v)f.push({displayName:ji(m.name),name:m.name,width:m.width})}let c;if(!s){let m=w["--"],O=m?`${ji("--")} (${x}px)`:null;c=[o.canvasPanelEntry(m?"base":null,O,!m,m?x:void 0)]}else c=re(f,tl(e.paneId)).map((m)=>o.canvasPanelEntry(m.name,`${m.displayName} (${m.width}px)`,!1,m.width));if(!await o.drawStage(e,{frame:"boards",framePart:"panzoom",frameVars:"--boards-inset:40px",handles:"hidden",hug:!1,innerPart:"boards",lead:"chrome",panels:c.map((m)=>m.item)},c))return;let y=o.stageHost(e,"chrome-host");if(y&&y.firstChild!==p)y.replaceChildren(p);let N=await k;if(e.renderGeneration!==l)return;let M=H({components:d,specimens:N,customizedOnly:Boolean(i),effectiveHead:Qw(r?.doc.document?.$head),effectiveMedia:w,effectiveStyle:wr(r?.doc.document?.style),filter:a,meta:lp,projectRoot:S?.projectRoot??null}),{panels:P}=e;for(let{panel:m}of c)P.push(m),RL(e.renderGeneration,M,m.canvas,m._width);if(s)o.updateActivePanelHeaders(e);o.applyTransform(e),o.observeCenterUntilStable(e)}function wd(e,o,{panCanvas:t=!1}={}){let r={activeSelector:e,rightTab:"style"};if(o!==void 0)r.activeMedia=o;if(cl(u.value,{selection:[],ui:r}),h.stylebook.selection=e,e&&t)ML(e)}var b_=[{id:"page",strip:"page",title:"Page"},{id:"properties",strip:"element",title:"Content"},{id:"style",strip:"element",title:"Style"},{id:"events",strip:"element",title:"Logic"},{id:"assistant",strip:"assistant",title:"Assistant"}],Ak=[{id:"page",title:"Page"},{id:"element",title:"Element"},{id:"assistant",title:"Assistant"}];function v_(){return{saveDocument:()=>{},undo:()=>{},redo:()=>{},openInBrowser:()=>{},buildSite:()=>{},closeDocument:()=>{},duplicateSelection:()=>{},deleteSelection:()=>{},selectParent:()=>{},toggleDock:()=>{},toggleZen:()=>{},openPalette:()=>{},openProject:()=>{},newWindow:()=>{},panelRoster:[],focusPanel:()=>{},focusInspectorTab:()=>{},cycleRegion:()=>{}}}var C=(e)=>e.document.open,I=(e)=>e.selection.count>0&&e.editor.kind==="canvas",z=(e)=>!e.selection.isRoot&&e.selection.paths.every((o)=>Qd(o)),G="an element selected on the canvas that has a sibling position: not the document root, a repeater's template or a switch case",U=(e)=>e.map((o)=>`[${o.join(", ")}]`).join(" and ");function Xf(e){return[{id:"file.save",title:"Save",category:"File",level:"document",icon:"floppy-disk",keybinding:"mod+s",menus:["commandbar/primary","statusbar/document","palette"],group:"1_file",undo:"none",when:C,enablement:(t)=>t.document.dirty,requires:"unsaved changes",run:()=>e.saveDocument()},{id:"document.close",title:"Close Document",category:"Document",level:"document",keybinding:"mod+w",menus:["context/tab","palette"],group:"1_file",when:C,requires:"an open document",run:()=>e.closeDocument()},{id:"view.openInBrowser",title:"Open in Browser",category:"View",level:"document",icon:"arrow-square-out",keybinding:"mod+shift+o",menus:["commandbar/primary","statusbar/document","palette"],group:"2_output",when:(t)=>t.project.isSite,enablement:C,requires:"a page to preview",run:()=>e.openInBrowser()},{id:"project.buildSite",title:"Build Site",category:"Project",level:"project",menus:["commandbar/overflow","palette"],group:"2_output",when:(t)=>t.project.isSite,requires:"a site project",run:()=>e.buildSite()},{id:"edit.undo",title:"Undo",category:"Edit",level:"document",icon:"arrow-u-up-left",keybinding:"mod+z",menus:["commandbar/primary","palette"],group:"1_history",order:1,when:C,enablement:(t)=>t.document.canUndo,requires:"a change to undo",run:()=>e.undo()},{id:"edit.redo",title:"Redo",category:"Edit",level:"document",icon:"arrow-u-up-right",keybinding:["mod+shift+z","mod+y"],menus:["commandbar/primary","palette"],group:"1_history",order:2,when:C,enablement:(t)=>t.document.canRedo,requires:"a change to redo",run:()=>e.redo()},{id:"selection.duplicate",title:"Duplicate",category:"Selection",level:"selection",keyScope:"canvas",keybinding:"mod+d",menus:["blockbar","context/element","context/layer","outline/row","palette"],group:"3_structure",undo:"document",when:I,enablement:z,requires:G,aiTool:{name:"duplicate_node",description:"Duplicate elements in the document, inserting each copy after its original, as one undoable step. The copies become the selection.",report:({after:t})=>{let r=t.selection.paths.length;return`Duplicated ${r} element${r===1?"":"s"}; the ${r===1?"copy is":"copies are"} selected at ${U(t.selection.paths)}.`}},run:()=>e.duplicateSelection()},{id:"selection.repeat",title:"Repeat...",category:"Selection",level:"selection",keyScope:"canvas",menus:["context/element","palette"],group:"3_structure",undo:"document",when:I,enablement:(t)=>z(t)&&!t.selection.isRepeater,requires:"an element with a sibling position that is not already a repeater",run:()=>{(le("fhdwyg14"),import("./convert-to-repeater-fhdwyg14.js")).then(({convertToRepeater:t})=>t())}},{id:"selection.delete",title:"Delete",category:"Selection",level:"selection",keyScope:"canvas",keybinding:["delete","backspace"],menus:["blockbar","context/element","context/layer","outline/row","palette"],group:"9_danger",destructive:!0,undo:"document",when:I,enablement:z,requires:G,aiTool:{name:"delete_node",description:"Delete elements from the document as one undoable step.",report:({before:t,after:r})=>{let a=t.selection.paths.length;return`Deleted ${a} element${a===1?"":"s"} at ${U(t.selection.paths)} in one undo step; the selection is now ${r.selection.count===0?"empty":"elsewhere"}.`}},run:()=>e.deleteSelection()},{id:"selection.selectParent",title:"Select Parent",category:"Selection",level:"selection",keyScope:"canvas",keybinding:["escape","arrowleft"],menus:["palette"],group:"2_navigate",when:I,requires:"an element selection",run:()=>e.selectParent()},{id:"view.toggleNavigator",title:"Toggle Navigator Dock",category:"View",level:"application",keybinding:"mod+b",menus:["commandbar/overflow","palette"],group:"4_docks",run:()=>e.toggleDock("navigator")},{id:"view.toggleInspector",title:"Toggle Inspector Dock",category:"View",level:"application",keybinding:"mod+alt+b",menus:["commandbar/overflow","palette"],group:"4_docks",run:()=>e.toggleDock("inspector")},{id:"view.zen",title:"Zen Mode",category:"View",level:"application",keybinding:"mod+.",menus:["commandbar/overflow","palette"],group:"4_docks",run:()=>e.toggleZen()},{id:"palette.open",title:"Open Command Center",category:"View",level:"application",keybinding:"mod+k",menus:["palette"],group:"5_palette",run:()=>e.openPalette("picker")},{id:"palette.openFiles",title:"Go to File…",category:"File",level:"application",keybinding:"mod+p",menus:["palette"],group:"5_palette",run:()=>e.openPalette("files")},{id:"palette.openCommands",title:"Run Command…",category:"View",level:"application",keybinding:"mod+shift+p",menus:["palette"],group:"5_palette",run:()=>e.openPalette("commands")},{id:"palette.openNodes",title:"Go to Symbol in Document…",category:"Selection",level:"document",menus:["palette"],group:"5_palette",when:C,requires:"an open document",run:()=>e.openPalette("nodes")},{id:"project.open",title:"Open Project…",category:"Project",level:"project",keybinding:"mod+o",menus:["commandbar/overflow","statusbar/project","palette"],group:"1_file",when:(t)=>t.capability.openProject,requires:"a host that can open a project from a dialog",run:()=>e.openProject()},{id:"view.newWindow",title:"New Window",category:"View",level:"application",keybinding:"mod+shift+n",menus:["commandbar/overflow","palette"],group:"1_file",when:(t)=>t.capability.windowControls,requires:"a host that can hold more than one window",run:()=>e.newWindow()},{id:"project.openRecent",title:"Open Recent…",category:"Project",level:"project",menus:["commandbar/overflow","statusbar/project","palette"],group:"1_file",run:()=>e.openPalette("projects")},...ae(e),...ie(e),{id:"view.cycleRegion",title:"Focus Next Region",category:"View",level:"application",keybinding:"f6",menus:["palette"],group:"4_docks",run:()=>e.cycleRegion(1)},{id:"view.cycleRegionBack",title:"Focus Previous Region",category:"View",level:"application",keybinding:"shift+f6",menus:["palette"],group:"4_docks",run:()=>e.cycleRegion(-1)}]}function ae(e){return e.panelRoster.map((o)=>({id:`panel.focus.${o.id}`,title:`Show ${o.title}`,category:"View",level:"application",menus:["palette"],group:"4_docks",requires:"an open project",when:(t)=>t.project.open&&(o.when?.(t)??!0),run:()=>e.focusPanel(o.id)}))}function ie(e){return b_.map((o,t)=>({id:`inspector.focus.${o.id}`,title:`Show ${o.title}`,category:"View",level:"document",keybinding:`mod+shift+${t+1}`,menus:["palette"],group:"4_docks",requires:"an open document",when:(a)=>a.document.open,run:()=>e.focusInspectorTab(o.id)}))}
6
- export{Ay,$u,Zf,Ug,h_,CR,p_,f_,m_,g_,Oy,Nk,kR,My,Py,Fy,lp,ER,wd,b_,Ak,v_,Xf};
5
+ registerBlockType( name, settings );`}]}]},{label:"Inline",elements:[{tag:"a",text:"Visit the documentation",attributes:{href:"#"}},{tag:"strong",text:"Bold text emphasis"},{tag:"em",text:"Italic text emphasis"},{tag:"small",text:"Fine print and legal text"},{tag:"mark",text:"Highlighted text"},{tag:"code",text:"const x = 42;"},{tag:"abbr",text:"HTML",attributes:{title:"HyperText Markup Language"}},{tag:"sub",text:"subscript"},{tag:"sup",text:"superscript"}]},{label:"Form",elements:[{tag:"input",attributes:{type:"text",placeholder:"Enter text…"}},{tag:"button",text:"Click Me"},{tag:"select",children:[{tag:"option",text:"Option 1"},{tag:"option",text:"Option 2"},{tag:"option",text:"Option 3"}]},{tag:"textarea",attributes:{placeholder:"Enter longer text…",rows:"3"}}]},{label:"Table",elements:[{tag:"table",children:[{tag:"thead",children:[{tag:"tr",children:[{tag:"th",text:"Name"},{tag:"th",text:"Role"},{tag:"th",text:"Status"}]}]},{tag:"tbody",children:[{tag:"tr",children:[{tag:"td",text:"Alice"},{tag:"td",text:"Developer"},{tag:"td",text:"Active"}]},{tag:"tr",children:[{tag:"td",text:"Bob"},{tag:"td",text:"Designer"},{tag:"td",text:"Away"}]},{tag:"tr",children:[{tag:"td",text:"Carol"},{tag:"td",text:"Manager"},{tag:"td",text:"Active"}]}]}]}]},{label:"Interactive",elements:[{tag:"details",attributes:{open:""},children:[{tag:"summary",text:"Click to expand details"},{tag:"p",text:"Additional detail content revealed when the disclosure widget is toggled open."}]}]},{label:"Media",elements:[{tag:"img",attributes:{alt:"Placeholder image"},style:"width:100%;max-width:400px;height:200px;background:#e0e0e0;display:block;border-radius:4px"},{tag:"video",attributes:{controls:""},style:"width:100%;max-width:400px;height:200px;background:#e0e0e0;display:block;border-radius:4px"},{tag:"audio",attributes:{controls:""},style:"width:100%"}]}],$variables:{color:{label:"Color",prefix:"--color-",placeholder:"#007acc"},font:{label:"Font",prefix:"--font-",placeholder:"system-ui, sans-serif"},size:{label:"Size",prefix:"--size-",placeholder:"16px"},other:{label:"Other",prefix:"--",placeholder:"value"}}};var D={$schema:"https://jxsuite.com/schema/v1",$id:"StudioStylebookChrome",$description:"The bar across the top of the Project Styles canvas: the filter that narrows the specimen catalogue, and the toggle that reduces it to the elements this file has already styled. Both are shell state rather than document state — the adapter owns which — and the two names come in as values, because the surface is called Project Styles and the canvas view it draws is the wire word `stylebook`; nothing a reader sees here may be spelled from that. **The bar IS the kit's toolbar now.** It used to write `role=\"toolbar\"` and its own `aria-label` on a `<div>`, which is a role with none of the behaviour under it: two controls, two tab stops, and no arrow key between them. `jx-action-group` is not the element for it — that one roves `jx-action-button` and this bar's first control is a `jx-textfield` — so `jx-toolbar` is, and the field keeps its own arrows while its caret still has text to walk (ui.md §5.5).",tagName:"jx-toolbar",attributes:{part:"chrome"},$props:{label:{$ref:"#/state/title"}},style:{$description:'What `.sb-chrome` said in `styles/overlays.css`, plus the six inline declarations the template carried beside it, plus `.tb-toggle` — all three go dead with this conversion, and none of them is shared with another surface. Three repairs on the way. The bar is one element rather than a positioned box wrapping a `role="toolbar"` row that declared the same flex layout again. The flex layout is not declared here EITHER any more: `display: flex`, `align-items: center`, the `--jx-space-2` gap, the sans face and the foreground colour are all `jx-toolbar`\'s own, so what is left below is only what a positioned BAND is. And `.tb-toggle` read `var(--spectrum-font-size-50, 11px)`, which the kit spells `--jx-text-sm` at the same value; the rest of its drawing is a `jx-action-button` reaching in through `part="control"`, because what it has to look like is a small bordered chip and every fill and control height the kit draws would otherwise have to be taken back off.',position:"absolute",top:"0",left:"0",right:"0",zIndex:"15",flexShrink:"0",padding:"var(--jx-space-2) var(--jx-space-3)",background:"var(--bg-panel)",borderBottom:"1px solid var(--border)",'& [part="filter"]':{flex:"1",maxWidth:"200px"},'& [part="customized"] > [part="control"]':{$description:"Bordered, unfilled and dimmed until it is on, which is what says it is a filter rather than an action: the catalogue it narrows is the thing the reader is looking at, so the control has to be quieter than its subject.",padding:"3px var(--jx-space-3)",border:"1px solid var(--border)",borderRadius:"var(--radius)",background:"transparent",color:"var(--fg-dim)",fontSize:"var(--jx-text-sm)",":hover":{background:"var(--hover-bg)"}},'& [part="customized"][data-selected] > [part="control"]':{$description:"`data-selected` and not `selected`: the kit reflects the pressed state as a data attribute (`jx-action-button.json`), and the property this document binds never reaches the attribute of the same name.",borderColor:"var(--accent)",background:"var(--accent-15)",color:"var(--accent)"}},children:[{tagName:"jx-textfield",attributes:{part:"filter"},$props:{size:"sm",type:"search",clearable:!0,label:{$ref:"#/state/filterLabel"},placeholder:"Filter…",value:{$ref:"#/state/filter"}},oninput:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/setFilter"},value:[{$ref:"event#/target/value"}]}]}},{tagName:"jx-action-button",$description:"`onchange` and not `onclick`: a `toggles` button owns its own pressed state and says so with `change` (`jx-action-button.json`), and an `onclick` written here would replace the element's own click handler on the same property — the toggle would stop flipping and stop announcing `aria-pressed`.",attributes:{part:"customized"},$props:{size:"sm",toggles:!0,selected:{$ref:"#/state/customizedOnly"},label:{$ref:"#/state/customizedLabel"},hint:{$ref:"#/state/customizedHint"}},onchange:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/toggleCustomized"},value:[]}]},children:[{tagName:"span",textContent:"${state.customizedLabel}"}]}]};T("stylebook-chrome",D);function W(e,o){let t=document.createElement("div");t.style.display="contents";let r=g({...e,...o}),a=null,i=!1;function l(){i=!0,R("stylebook-chrome",r,t).then((d)=>{i=!1,a=d})}return l(),{host:t,update(d){if(Object.assign(r,d),i||a!==null&&t.contains(a.root))return;a?.dispose(),a=null,t.textContent="",l()}}}function L(e){return!e.startsWith(":")&&!e.startsWith(".")&&!e.startsWith("&")&&!e.startsWith("[")&&!e.startsWith("@")&&!e.startsWith("--")}function j(e){return _(e)&&!Array.isArray(e)}var A="& .element-card-preview";function My(e){let o={},t=(r)=>{let a={};for(let[i,l]of Object.entries(r))if(i!=="@--")a[i]=l;return a};for(let[r,a]of Object.entries(e)){if(!j(a)){o[r]=a;continue}if(r==="@--")continue;if(Mp(r)){o[r]=a;continue}if(r.startsWith("@")){let i={};for(let[l,d]of Object.entries(a))if(j(d)&&L(l))i[`${A} ${l}`]=t(d);else i[l]=d;o[r]=i;continue}if(L(r)){o[`${A} ${r}`]=t(a);continue}o[r]=a}return o}function B(e,o){let t=o.split(" "),r=e;for(let a of t){if(!j(r))return null;r=r[a]}return j(r)?r:null}function Py(e,o){let t=B(e,o);if(t&&Object.keys(t).length>0)return!0;for(let[r,a]of Object.entries(e)){if(!r.startsWith("@")||!j(a))continue;let i=B(a,o);if(i&&Object.keys(i).length>0)return!0}return!1}function te(e){if(!e)return null;return e.split(" ").pop()??null}function Fy(e,o){let t=te(o),r=[],a=(i,l,d)=>{let k=d?`${d} ${i.tag}`:i.tag;r.push({depth:l,entry:i,path:k,selected:i.tag===t,tag:i.tag});let w=i.children?[...new Map(i.children.map((v)=>[v.tag,v])).values()]:[];for(let v of w)a(v,l+1,k)};for(let i of e)a(i,0,"");return r}function H(e){let o=new Map,t=new Map,r=e.filter.toLowerCase(),a=(s,p,f)=>{let c=s.tag===f?f:`${f} ${s.tag}`;o.set(Pc(p),c);let b=s.children??[];for(let[y,N]of b.entries())a(N,[...p,"children",y],f)},i=(s)=>{let p={...s.attributes};if(s.style)p.style=s.style;let f={tagName:s.tag};if(s.text)f.textContent=s.text;if(Object.keys(p).length>0)f.attributes=p;if(s.children)f.children=s.children.map(i);return f},l=(s,p,f,c,b)=>{o.set(Pc(c),s),o.set(Pc([...c,"children",0]),s);let y=[...c,"children",0,"children",0];if(b)a(b,y,s);else o.set(Pc(y),s);if(!t.has(s))t.set(s,c);return{attributes:{class:"element-card"},children:[{attributes:{class:"element-card-preview"},children:[f],tagName:"div"},{attributes:{class:"element-card-label"},tagName:"div",textContent:p}],tagName:"div"}},d=[],k=(s,p)=>({attributes:{class:"sb-section"},children:[{attributes:{class:"sb-label"},tagName:"div",textContent:s},{attributes:{class:"sb-body"},children:p,tagName:"div"}],tagName:"div"}),w=()=>["children",d.length,"children",1];for(let s of e.meta.$sections){let p=s.elements;if(r)p=p.filter((b)=>b.tag.includes(r)||s.label.toLowerCase().includes(r));if(e.customizedOnly)p=p.filter((b)=>Py(e.effectiveStyle,b.tag));if(p.length===0)continue;let f=w(),c=p.map((b,y)=>l(b.tag,`<${b.tag}>`,i(b),[...f,"children",y],b));d.push(k(s.label,c))}let v=[];{let s=e.components;if(r)s=s.filter((p)=>p.tagName.toLowerCase().includes(r));if(e.customizedOnly)s=s.filter((p)=>Py(e.effectiveStyle,p.tagName));if(s.length>0){let p=w(),f=s.map((c,b)=>{let y=[...p,"children",b];if(c.source!=="npm"&&c.path?.endsWith(".json")){v.push({$ref:`/${e.projectRoot?`${e.projectRoot}/`:""}${c.path}`.replace(/^\/+/,"/")});let P=e.specimens?.get(c.tagName);if(P?.kind==="props"){let m={$props:P.props,tagName:c.tagName};return l(c.tagName,`<${c.tagName}>`,m,y,null)}if(P?.kind!=="none"){let m={};for(let E of c.props??[])if(E.default!==void 0&&E.default!=="false"&&E.default!=="''")m[E.name]=String(E.default).replaceAll(/^'|'$/g,"");let O={tagName:c.tagName};if(Object.keys(m).length>0)O.attributes=m;return l(c.tagName,`<${c.tagName}>`,O,y,null)}}let M={attributes:{class:"sb-fallback"},tagName:"div",textContent:`<${c.tagName}>`};return l(c.tagName,`<${c.tagName}>`,M,y,null)});d.push(k("Components",f))}}if(d.length===0)d.push({attributes:{class:"sb-empty"},tagName:"div",textContent:e.customizedOnly?"No customized elements":"No matching elements"});let x={};if(v.length>0)x.$elements=v;if(e.effectiveHead&&e.effectiveHead.length>0)x.$head=e.effectiveHead;return x.$media=e.effectiveMedia,x.attributes={class:"sb-root"},x.children=d,x.style=My(e.effectiveStyle),x.tagName="div",{doc:x,pathToTag:o,tagToCardPath:t}}var V=new WeakMap;async function oe(e){let{path:o}=e;if(e.source==="npm"||!o?.endsWith(".json"))return{kind:"bare"};let t=await RT(o);if(!t)return{kind:"bare"};let r=gS(t);if(r.size>0&&await bS(t,o,r))return{kind:"props",props:Object.fromEntries(r)};return await bS(t,o,new Map)?{kind:"bare"}:{kind:"none"}}async function q(e,o=oe){let t=V.get(e);if(!t)t=new Map,V.set(e,t);let r=t,a=await Promise.all(e.map(async(i)=>{let l=i.path??i.tagName,d=r.get(l);if(!d)d=o(i).catch(()=>({kind:"bare"})),r.set(l,d);return[i.tagName,await d]}));return new Map(a)}var F=new WeakMap;function ne(e){let o={customizedHint:"Show only the elements this file has already styled",customizedLabel:"Customized",customizedOnly:u.stylebook.customizedOnly,filter:u.stylebook.filter,filterLabel:`Filter the ${Ay} catalogue`,title:Ay},t=F.get(e);if(t)return t.update(o),t.host;let r=W(o,{setFilter:(a)=>{u.stylebook.filter=a},toggleCustomized:()=>{u.stylebook.customizedOnly=!u.stylebook.customizedOnly}});return F.set(e,r),r.host}function re(e,o){let t=e.filter((r)=>r.name===(o??"base"));return t.length>0?t:e.slice(0,1)}async function ER(e,o){let t=e.wrap,r=vt(e.paneId),a=u.stylebook.filter.toLowerCase(),{customizedOnly:i}=u.stylebook,l=e.renderGeneration,d=Ne,k=q(d),w=to(r?.doc.document?.$media),{sizeBreakpoints:v,baseWidth:x}=Br(w),s=v.length>0,p=ne(e);t.style.overflow="hidden";let f=[];if(s){f.push({displayName:ji("--"),name:"base",width:x});for(let m of v)f.push({displayName:ji(m.name),name:m.name,width:m.width})}let c;if(!s){let m=w["--"],O=m?`${ji("--")} (${x}px)`:null;c=[o.canvasPanelEntry(m?"base":null,O,!m,m?x:void 0)]}else c=re(f,tl(e.paneId)).map((m)=>o.canvasPanelEntry(m.name,`${m.displayName} (${m.width}px)`,!1,m.width));if(!await o.drawStage(e,{frame:"boards",framePart:"panzoom",frameVars:"--boards-inset:40px",handles:"hidden",hug:!1,innerPart:"boards",lead:"chrome",panels:c.map((m)=>m.item)},c))return;let y=o.stageHost(e,"chrome-host");if(y&&y.firstChild!==p)y.replaceChildren(p);let N=await k;if(e.renderGeneration!==l)return;let M=H({components:d,specimens:N,customizedOnly:Boolean(i),effectiveHead:Qw(r?.doc.document?.$head),effectiveMedia:w,effectiveStyle:wr(r?.doc.document?.style),filter:a,meta:lp,projectRoot:S?.projectRoot??null}),{panels:P}=e;for(let{panel:m}of c)P.push(m),RL(e.renderGeneration,M,m.canvas,m._width);if(s)o.updateActivePanelHeaders(e);o.applyTransform(e),o.observeCenterUntilStable(e)}function xd(e,o,{panCanvas:t=!1}={}){let r={activeSelector:e,rightTab:"style"};if(o!==void 0)r.activeMedia=o;if(cl(h.value,{selection:[],ui:r}),u.stylebook.selection=e,e&&t)ML(e)}var b_=[{id:"page",strip:"page",title:"Page"},{id:"properties",strip:"element",title:"Content"},{id:"style",strip:"element",title:"Style"},{id:"events",strip:"element",title:"Logic"},{id:"assistant",strip:"assistant",title:"Assistant"}],Ak=[{id:"page",title:"Page"},{id:"element",title:"Element"},{id:"assistant",title:"Assistant"}];function v_(){return{saveDocument:()=>{},undo:()=>{},redo:()=>{},openInBrowser:()=>{},buildSite:()=>{},closeDocument:()=>{},duplicateSelection:()=>{},deleteSelection:()=>{},selectParent:()=>{},toggleDock:()=>{},toggleZen:()=>{},openPalette:()=>{},openProject:()=>{},newWindow:()=>{},panelRoster:[],focusPanel:()=>{},focusInspectorTab:()=>{},cycleRegion:()=>{}}}var C=(e)=>e.document.open,I=(e)=>e.selection.count>0&&e.editor.kind==="canvas",z=(e)=>!e.selection.isRoot&&e.selection.paths.every((o)=>eu(o)),G="an element selected on the canvas that has a sibling position: not the document root, a repeater's template or a switch case",U=(e)=>e.map((o)=>`[${o.join(", ")}]`).join(" and ");function Xf(e){return[{id:"file.save",title:"Save",category:"File",level:"document",icon:"floppy-disk",keybinding:"mod+s",menus:["commandbar/primary","statusbar/document","palette"],group:"1_file",undo:"none",when:C,enablement:(t)=>t.document.dirty,requires:"unsaved changes",run:()=>e.saveDocument()},{id:"document.close",title:"Close Document",category:"Document",level:"document",keybinding:"mod+w",menus:["context/tab","palette"],group:"1_file",when:C,requires:"an open document",run:()=>e.closeDocument()},{id:"view.openInBrowser",title:"Open in Browser",category:"View",level:"document",icon:"arrow-square-out",keybinding:"mod+shift+o",menus:["commandbar/primary","statusbar/document","palette"],group:"2_output",when:(t)=>t.project.isSite,enablement:C,requires:"a page to preview",run:()=>e.openInBrowser()},{id:"project.buildSite",title:"Build Site",category:"Project",level:"project",menus:["commandbar/overflow","palette"],group:"2_output",when:(t)=>t.project.isSite,requires:"a site project",run:()=>e.buildSite()},{id:"edit.undo",title:"Undo",category:"Edit",level:"document",icon:"arrow-u-up-left",keybinding:"mod+z",menus:["commandbar/primary","palette"],group:"1_history",order:1,when:C,enablement:(t)=>t.document.canUndo,requires:"a change to undo",run:()=>e.undo()},{id:"edit.redo",title:"Redo",category:"Edit",level:"document",icon:"arrow-u-up-right",keybinding:["mod+shift+z","mod+y"],menus:["commandbar/primary","palette"],group:"1_history",order:2,when:C,enablement:(t)=>t.document.canRedo,requires:"a change to redo",run:()=>e.redo()},{id:"selection.duplicate",title:"Duplicate",category:"Selection",level:"selection",keyScope:"canvas",keybinding:"mod+d",menus:["blockbar","context/element","context/layer","outline/row","palette"],group:"3_structure",undo:"document",when:I,enablement:z,requires:G,aiTool:{name:"duplicate_node",description:"Duplicate elements in the document, inserting each copy after its original, as one undoable step. The copies become the selection.",report:({after:t})=>{let r=t.selection.paths.length;return`Duplicated ${r} element${r===1?"":"s"}; the ${r===1?"copy is":"copies are"} selected at ${U(t.selection.paths)}.`}},run:()=>e.duplicateSelection()},{id:"selection.repeat",title:"Repeat...",category:"Selection",level:"selection",keyScope:"canvas",menus:["context/element","palette"],group:"3_structure",undo:"document",when:I,enablement:(t)=>z(t)&&!t.selection.isRepeater,requires:"an element with a sibling position that is not already a repeater",run:()=>{(le("f92ey3kp"),import("./convert-to-repeater-f92ey3kp.js")).then(({convertToRepeater:t})=>t())}},{id:"selection.delete",title:"Delete",category:"Selection",level:"selection",keyScope:"canvas",keybinding:["delete","backspace"],menus:["blockbar","context/element","context/layer","outline/row","palette"],group:"9_danger",destructive:!0,undo:"document",when:I,enablement:z,requires:G,aiTool:{name:"delete_node",description:"Delete elements from the document as one undoable step.",report:({before:t,after:r})=>{let a=t.selection.paths.length;return`Deleted ${a} element${a===1?"":"s"} at ${U(t.selection.paths)} in one undo step; the selection is now ${r.selection.count===0?"empty":"elsewhere"}.`}},run:()=>e.deleteSelection()},{id:"selection.selectParent",title:"Select Parent",category:"Selection",level:"selection",keyScope:"canvas",keybinding:["escape","arrowleft"],menus:["palette"],group:"2_navigate",when:I,requires:"an element selection",run:()=>e.selectParent()},{id:"view.toggleNavigator",title:"Toggle Navigator Dock",category:"View",level:"application",keybinding:"mod+b",menus:["commandbar/overflow","palette"],group:"4_docks",run:()=>e.toggleDock("navigator")},{id:"view.toggleInspector",title:"Toggle Inspector Dock",category:"View",level:"application",keybinding:"mod+alt+b",menus:["commandbar/overflow","palette"],group:"4_docks",run:()=>e.toggleDock("inspector")},{id:"view.zen",title:"Zen Mode",category:"View",level:"application",keybinding:"mod+.",menus:["commandbar/overflow","palette"],group:"4_docks",run:()=>e.toggleZen()},{id:"palette.open",title:"Open Command Center",category:"View",level:"application",keybinding:"mod+k",menus:["palette"],group:"5_palette",run:()=>e.openPalette("picker")},{id:"palette.openFiles",title:"Go to File…",category:"File",level:"application",keybinding:"mod+p",menus:["palette"],group:"5_palette",run:()=>e.openPalette("files")},{id:"palette.openCommands",title:"Run Command…",category:"View",level:"application",keybinding:"mod+shift+p",menus:["palette"],group:"5_palette",run:()=>e.openPalette("commands")},{id:"palette.openNodes",title:"Go to Symbol in Document…",category:"Selection",level:"document",menus:["palette"],group:"5_palette",when:C,requires:"an open document",run:()=>e.openPalette("nodes")},{id:"project.open",title:"Open Project…",category:"Project",level:"project",keybinding:"mod+o",menus:["commandbar/overflow","statusbar/project","palette"],group:"1_file",when:(t)=>t.capability.openProject,requires:"a host that can open a project from a dialog",run:()=>e.openProject()},{id:"view.newWindow",title:"New Window",category:"View",level:"application",keybinding:"mod+shift+n",menus:["commandbar/overflow","palette"],group:"1_file",when:(t)=>t.capability.windowControls,requires:"a host that can hold more than one window",run:()=>e.newWindow()},{id:"project.openRecent",title:"Open Recent…",category:"Project",level:"project",menus:["commandbar/overflow","statusbar/project","palette"],group:"1_file",run:()=>e.openPalette("projects")},...ae(e),...ie(e),{id:"view.cycleRegion",title:"Focus Next Region",category:"View",level:"application",keybinding:"f6",menus:["palette"],group:"4_docks",run:()=>e.cycleRegion(1)},{id:"view.cycleRegionBack",title:"Focus Previous Region",category:"View",level:"application",keybinding:"shift+f6",menus:["palette"],group:"4_docks",run:()=>e.cycleRegion(-1)}]}function ae(e){return e.panelRoster.map((o)=>({id:`panel.focus.${o.id}`,title:`Show ${o.title}`,category:"View",level:"application",menus:["palette"],group:"4_docks",requires:"an open project",when:(t)=>t.project.open&&(o.when?.(t)??!0),run:()=>e.focusPanel(o.id)}))}function ie(e){return b_.map((o,t)=>({id:`inspector.focus.${o.id}`,title:`Show ${o.title}`,category:"View",level:"document",keybinding:`mod+shift+${t+1}`,menus:["palette"],group:"4_docks",requires:"an open document",when:(a)=>a.document.open,run:()=>e.focusInspectorTab(o.id)}))}
6
+ export{Ay,$u,Zf,Ug,h_,CR,p_,f_,m_,g_,Oy,Nk,kR,My,Py,Fy,lp,ER,xd,b_,Ak,v_,Xf};
7
7
 
8
- //# debugId=65DB2446777F3D1A64756E2164756E21
9
- //# sourceMappingURL=studio-9dz76yqc.js.map
8
+ //# debugId=5223474000EA5C4A64756E2164756E21
9
+ //# sourceMappingURL=studio-hsr3k06v.js.map