@jxsuite/studio 6.0.0 → 6.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (208) hide show
  1. package/dist/chunks/2020-va2wwra4.js +4 -0
  2. package/dist/chunks/adapter-f93pafd7.js +4 -0
  3. package/dist/chunks/{cf-account-picker-bb2yq946.js → cf-account-picker-af1h381v.js} +3 -3
  4. package/dist/chunks/cf-settings-125tdm0w.js +4 -0
  5. package/dist/chunks/components-ax2f1fnn.js +4 -0
  6. package/dist/chunks/content-source-108aqtk1.js +4 -0
  7. package/dist/chunks/{convert-to-repeater-vqkt7s3s.js → convert-to-repeater-ry5rmppr.js} +3 -3
  8. package/dist/chunks/editor-pfgdmkb0.js +4 -0
  9. package/dist/chunks/entry-commands-t0k1q0kx.js +4 -0
  10. package/dist/chunks/{extension-sections-8beq9ac3.js → extension-sections-6mwh2hf8.js} +3 -3
  11. package/dist/chunks/file-ops-meej5mqf.js +4 -0
  12. package/dist/chunks/files-44vp8a2s.js +4 -0
  13. package/dist/chunks/format-host-7q1petb9.js +4 -0
  14. package/dist/chunks/fs-events-h2mwnxaz.js +4 -0
  15. package/dist/chunks/git-panel-zngbymvd.js +4 -0
  16. package/dist/chunks/{grid-view-ca10def6.js → grid-view-sx9vynsp.js} +15 -15
  17. package/dist/chunks/icons-p44xhjf0.js +4 -0
  18. package/dist/chunks/iframe-host-qk3ycq87.js +4 -0
  19. package/dist/chunks/{index-9ydfe04y.js → index-2veqmnhr.js} +3 -3
  20. package/dist/chunks/index-wkyfjeqz.js +4 -0
  21. package/dist/chunks/{javascript-d9pqgc2p.js → javascript-8nbvs12s.js} +3 -3
  22. package/dist/chunks/jsonMode-s8kt9dsj.js +13 -0
  23. package/dist/chunks/jx-validate-psgd7vsx.js +4 -0
  24. package/dist/chunks/layers-panel-1kq2jyfk.js +4 -0
  25. package/dist/chunks/layers-xd92fg8d.js +4 -0
  26. package/dist/chunks/lit-html-ac4cwwr4.js +4 -0
  27. package/dist/chunks/media-picker-0svzkdyb.js +4 -0
  28. package/dist/chunks/menu-5c55ea3d.js +4 -0
  29. package/dist/chunks/{monaco-binding-62dtmgbf.js → monaco-binding-z6r70pdt.js} +3 -3
  30. package/dist/chunks/monaco-buffer-fz6gq5y7.js +4 -0
  31. package/dist/chunks/monaco-setup-q4axkgj7.js +4 -0
  32. package/dist/chunks/notify-0xgtn8q1.js +4 -0
  33. package/dist/chunks/platform-v1qctbe6.js +4 -0
  34. package/dist/chunks/publish-panel-ym1fmgq5.js +4 -0
  35. package/dist/chunks/quick-search-a54e6t5n.js +4 -0
  36. package/dist/chunks/references-gmqp82fs.js +4 -0
  37. package/dist/chunks/right-panel-v7t9awbk.js +4 -0
  38. package/dist/chunks/section-registry-vhyf3zsr.js +4 -0
  39. package/dist/chunks/studio-0bhx5hz6.js +5 -0
  40. package/dist/chunks/studio-0k1ddnyy.js +6 -0
  41. package/dist/chunks/studio-1b04pd0j.js +64 -0
  42. package/dist/chunks/{studio-sxc0zvpt.js → studio-1q1sh2ax.js} +3 -3
  43. package/dist/chunks/studio-4dwbj6gb.js +5 -0
  44. package/dist/chunks/studio-4tanh828.js +5 -0
  45. package/dist/chunks/{studio-fqq890ap.js → studio-55h4mstj.js} +3 -3
  46. package/dist/chunks/studio-5tnvjkz4.js +5 -0
  47. package/dist/chunks/studio-60dqgb0c.js +5 -0
  48. package/dist/chunks/studio-61dp09qg.js +9 -0
  49. package/dist/chunks/studio-63epcrj2.js +5 -0
  50. package/dist/chunks/studio-74k29dy9.js +5 -0
  51. package/dist/chunks/{studio-qa73881a.js → studio-7vg6jcd3.js} +4 -4
  52. package/dist/chunks/studio-7zx31knw.js +9 -0
  53. package/dist/chunks/studio-8bxk97km.js +5 -0
  54. package/dist/chunks/{studio-edbtvcd1.js → studio-8grwxtqk.js} +4 -4
  55. package/dist/chunks/studio-933e30n4.js +5 -0
  56. package/dist/chunks/{studio-rr4xkv81.js → studio-98wnwhbg.js} +4 -4
  57. package/dist/chunks/studio-9mccjwjh.js +14 -0
  58. package/dist/chunks/studio-a2ke1e4t.js +5 -0
  59. package/dist/chunks/studio-e3a2a6v3.js +4 -0
  60. package/dist/chunks/{studio-pwqfmt4p.js → studio-e81q1vb9.js} +4 -4
  61. package/dist/chunks/{studio-7pgy3xaf.js → studio-epgrmqqm.js} +4 -4
  62. package/dist/chunks/studio-g1shz58g.js +5 -0
  63. package/dist/chunks/studio-gf0fz03c.js +5 -0
  64. package/dist/chunks/studio-gjtpe62q.js +6 -0
  65. package/dist/chunks/{studio-tzegmy4w.js → studio-gkskhg7m.js} +4 -4
  66. package/dist/chunks/studio-gx4dnjzd.js +5 -0
  67. package/dist/chunks/{studio-8xcwewjq.js → studio-h46vtzk8.js} +4 -4
  68. package/dist/chunks/studio-j03zga3y.js +9 -0
  69. package/dist/chunks/{studio-4r0sjtx8.js → studio-jhpxeckz.js} +4 -4
  70. package/dist/chunks/{studio-zd4kayn2.js → studio-k01r7ykp.js} +4 -4
  71. package/dist/chunks/{studio-03wwfvyt.js → studio-kggey1jt.js} +4 -4
  72. package/dist/chunks/{studio-hnvnfbdv.js → studio-kk7h30ne.js} +6 -6
  73. package/dist/chunks/{studio-01qza1n3.js → studio-kt1zqney.js} +4 -4
  74. package/dist/chunks/{studio-r3kaka4d.js → studio-m3cwhvye.js} +4 -4
  75. package/dist/chunks/{studio-evwgp1ym.js → studio-mcayt6hz.js} +4 -4
  76. package/dist/chunks/{studio-5vy2wfm5.js → studio-myjcghv3.js} +4 -4
  77. package/dist/chunks/studio-n8bxwc3y.js +4 -0
  78. package/dist/chunks/{studio-ztvcxm3w.js → studio-ngm8gvpb.js} +4 -4
  79. package/dist/chunks/{studio-01kbbqg3.js → studio-nj5a01jy.js} +196 -196
  80. package/dist/chunks/{studio-xkfs0dp2.js → studio-pcgz8heb.js} +4 -4
  81. package/dist/chunks/{studio-0bbxhhce.js → studio-pre0skq6.js} +4 -4
  82. package/dist/chunks/{studio-n78gjfy8.js → studio-qcsq0t15.js} +4 -4
  83. package/dist/chunks/studio-qkstvve9.js +5 -0
  84. package/dist/chunks/studio-qv1pwd3c.js +5 -0
  85. package/dist/chunks/{studio-rmn2dz59.js → studio-rc6dvxjb.js} +5 -5
  86. package/dist/chunks/{studio-st75kn99.js → studio-rv11kfwa.js} +7 -7
  87. package/dist/chunks/studio-s8dmmz66.js +5 -0
  88. package/dist/chunks/studio-sp5xzbj4.js +6 -0
  89. package/dist/chunks/{studio-tmeq6mjb.js → studio-szsjbj0g.js} +4 -4
  90. package/dist/chunks/studio-t1xzawhr.js +16 -0
  91. package/dist/chunks/{studio-mk00zd5d.js → studio-t6b6qe31.js} +4 -4
  92. package/dist/chunks/{studio-bftp4n4b.js → studio-tdcprbqb.js} +4 -4
  93. package/dist/chunks/{studio-ge5fqjth.js → studio-vrmcjf9g.js} +5 -5
  94. package/dist/chunks/studio-vyc0b4he.js +10 -0
  95. package/dist/chunks/{studio-semd1s8s.js → studio-w0cgf6jg.js} +4 -4
  96. package/dist/chunks/{studio-gp02nqnw.js → studio-w3hskzqk.js} +4 -4
  97. package/dist/chunks/{studio-1wvfxkyy.js → studio-wszjyh0j.js} +4 -4
  98. package/dist/chunks/studio-xgrgcdyh.js +9 -0
  99. package/dist/chunks/{studio-y7jehjrp.js → studio-xz2yxfcb.js} +4 -4
  100. package/dist/chunks/{studio-aje966s9.js → studio-y6n42tgs.js} +4 -4
  101. package/dist/chunks/{studio-yr04mv2j.js → studio-yb560vxr.js} +4 -4
  102. package/dist/chunks/{studio-tp642n5g.js → studio-yn9f8vtx.js} +4 -4
  103. package/dist/chunks/studio-yw05w8f0.js +7 -0
  104. package/dist/chunks/{studio-cbr9czkn.js → studio-z16sgavc.js} +4 -4
  105. package/dist/chunks/studio-zey7zsdw.js +12 -0
  106. package/dist/chunks/{studio-1q6amtph.js → studio-zyqn40w4.js} +4 -4
  107. package/dist/chunks/tsMode-2frah6h1.js +14 -0
  108. package/dist/chunks/workspace-zt81g1ms.js +4 -0
  109. package/dist/chunks/ws-client-n2bh4hkf.js +4 -0
  110. package/dist/iframe-entry.js +13 -13
  111. package/dist/manifest.json +62 -62
  112. package/dist/studio.js +87 -87
  113. package/dist/workers/ts.worker.js +3 -3
  114. package/package.json +10 -10
  115. package/src/canvas/canvas-render.ts +4 -1
  116. package/src/canvas/canvas-utils.ts +73 -15
  117. package/src/canvas/iframe-host.ts +67 -21
  118. package/src/canvas/iframe-inline-edit.ts +22 -4
  119. package/src/canvas/iframe-interaction.ts +7 -1
  120. package/src/canvas/iframe-protocol.ts +3 -0
  121. package/src/canvas/iframe-render.ts +5 -2
  122. package/src/commands/defaults.ts +4 -1
  123. package/src/commands/live-context.ts +3 -1
  124. package/src/editor/shortcuts.ts +55 -27
  125. package/src/files/media-paths.ts +3 -1
  126. package/src/new-project/add-repo-modal.ts +459 -59
  127. package/src/panels/editors.ts +3 -1
  128. package/src/panels/style-panel.ts +36 -11
  129. package/src/platforms/cloud.ts +95 -18
  130. package/src/platforms/devserver.ts +47 -12
  131. package/src/publish/pages-service.ts +7 -0
  132. package/src/publish/publish-panel.ts +16 -2
  133. package/src/studio.ts +14 -2
  134. package/src/surfaces/add-repo.json +721 -224
  135. package/src/surfaces/add-repo.ts +196 -31
  136. package/src/surfaces/library-pane.ts +6 -0
  137. package/src/surfaces/rail.json +126 -73
  138. package/src/surfaces/rail.ts +31 -5
  139. package/src/tabs/typing.ts +31 -0
  140. package/src/types.ts +42 -3
  141. package/src/utils/edit-display.ts +30 -1
  142. package/src/utils/project-dir.ts +24 -0
  143. package/src/workspace/workspace.ts +7 -0
  144. package/dist/chunks/2020-cs2sb9t1.js +0 -4
  145. package/dist/chunks/adapter-y5gdq19c.js +0 -4
  146. package/dist/chunks/cf-settings-20dznc3j.js +0 -4
  147. package/dist/chunks/components-q037dya7.js +0 -4
  148. package/dist/chunks/content-source-t0q184js.js +0 -4
  149. package/dist/chunks/editor-j5sq149q.js +0 -4
  150. package/dist/chunks/entry-commands-fxzgcc4k.js +0 -4
  151. package/dist/chunks/file-ops-2n77759h.js +0 -4
  152. package/dist/chunks/files-fjy7zpxt.js +0 -4
  153. package/dist/chunks/format-host-wj3mf3n8.js +0 -4
  154. package/dist/chunks/fs-events-7kcgn4e9.js +0 -4
  155. package/dist/chunks/git-panel-7z2mpt2d.js +0 -4
  156. package/dist/chunks/icons-qbh8akb1.js +0 -4
  157. package/dist/chunks/iframe-host-a0zjd6xp.js +0 -4
  158. package/dist/chunks/index-m0x5ztax.js +0 -4
  159. package/dist/chunks/jsonMode-800yvbem.js +0 -13
  160. package/dist/chunks/jx-validate-zc9zp77s.js +0 -4
  161. package/dist/chunks/layers-p677nrh5.js +0 -4
  162. package/dist/chunks/layers-panel-y4w1dq90.js +0 -4
  163. package/dist/chunks/lit-html-cfn61dn7.js +0 -4
  164. package/dist/chunks/media-picker-xg7yjpz9.js +0 -4
  165. package/dist/chunks/menu-fpekzj6w.js +0 -4
  166. package/dist/chunks/monaco-buffer-nn4dtx27.js +0 -4
  167. package/dist/chunks/monaco-setup-tj13ndtm.js +0 -4
  168. package/dist/chunks/notify-ahs57a2z.js +0 -4
  169. package/dist/chunks/platform-v9xyfkbx.js +0 -4
  170. package/dist/chunks/publish-panel-xtbfgg2r.js +0 -4
  171. package/dist/chunks/quick-search-d3a6m7j3.js +0 -4
  172. package/dist/chunks/references-99ws0b0m.js +0 -4
  173. package/dist/chunks/right-panel-31vbk5xp.js +0 -4
  174. package/dist/chunks/section-registry-b2yzp9sw.js +0 -4
  175. package/dist/chunks/studio-1a99w39s.js +0 -5
  176. package/dist/chunks/studio-3ck2a5c4.js +0 -10
  177. package/dist/chunks/studio-4fde4a0x.js +0 -5
  178. package/dist/chunks/studio-4jj9gme2.js +0 -6
  179. package/dist/chunks/studio-4m50vh74.js +0 -16
  180. package/dist/chunks/studio-4xppwncr.js +0 -4
  181. package/dist/chunks/studio-5d7wfmnp.js +0 -5
  182. package/dist/chunks/studio-5e9zsamh.js +0 -9
  183. package/dist/chunks/studio-5gs9th4b.js +0 -5
  184. package/dist/chunks/studio-7qvs7v0m.js +0 -5
  185. package/dist/chunks/studio-84rtc120.js +0 -5
  186. package/dist/chunks/studio-aekhcdzw.js +0 -7
  187. package/dist/chunks/studio-aqmph6k4.js +0 -5
  188. package/dist/chunks/studio-c6zdm25z.js +0 -9
  189. package/dist/chunks/studio-capk0583.js +0 -9
  190. package/dist/chunks/studio-chdmwwzw.js +0 -5
  191. package/dist/chunks/studio-cp1gbff9.js +0 -14
  192. package/dist/chunks/studio-cqmtbg2p.js +0 -5
  193. package/dist/chunks/studio-e47215hh.js +0 -5
  194. package/dist/chunks/studio-fbx6twps.js +0 -6
  195. package/dist/chunks/studio-fthwn4kf.js +0 -5
  196. package/dist/chunks/studio-g8dsj3d2.js +0 -6
  197. package/dist/chunks/studio-gjknvzam.js +0 -9
  198. package/dist/chunks/studio-hjbg8d5y.js +0 -12
  199. package/dist/chunks/studio-nbxqcgvf.js +0 -5
  200. package/dist/chunks/studio-t1eedsyx.js +0 -4
  201. package/dist/chunks/studio-vavmwshr.js +0 -5
  202. package/dist/chunks/studio-x5g1xk77.js +0 -5
  203. package/dist/chunks/studio-x92tgnee.js +0 -64
  204. package/dist/chunks/studio-xg1942as.js +0 -5
  205. package/dist/chunks/studio-zev8ssp1.js +0 -5
  206. package/dist/chunks/tsMode-k9s9fcag.js +0 -14
  207. package/dist/chunks/workspace-5vmgsagj.js +0 -4
  208. package/dist/chunks/ws-client-0ja08haa.js +0 -4
@@ -0,0 +1,5 @@
1
+ import{ge,dl,Q,y,oe,tu,C}from"./studio-55h4mstj.js";import{qd}from"./studio-epgrmqqm.js";import{p}from"./studio-xz2yxfcb.js";import{_i,Qt,Fo}from"./studio-5tnvjkz4.js";import{K,Wm,ht,Cn,Qr,il,D}from"./studio-yn9f8vtx.js";import{Oe,Bc,Vm,k1}from"./studio-mcayt6hz.js";import{La,yh,vh}from"./studio-s8dmmz66.js";import{me}from"./studio-pre0skq6.js";var wt=new Set(["Adlm","Arab","Aran","Armi","Avst","Cprt","Egyd","Egyh","Elym","Gara","Hatr","Hebr","Hluw","Hung","Khar","Lydi","Mand","Mani","Mend","Merc","Mero","Narb","Nbat","Nkoo","Orkh","Palm","Phli","Phlp","Phnx","Prti","Rohg","Samr","Sarb","Sogd","Sogo","Syrc","Thaa","Todr","Yezi"]),Hx="^[A-Za-z]{2,8}(-[A-Za-z0-9]{1,8})*$";function Yr(e){if(typeof e!=="string"||e.trim()==="")return null;try{return new Intl.Locale(e.trim()).toString()}catch{return null}}function vy(e){return Yr(e)!==null}function NL(e){let t=Yr(e);if(t===null)return"ltr";let n=new Intl.Locale(t),o=n.script??n.maximize().script;return o!==void 0&&wt.has(o)?"rtl":"ltr"}function hn(e){let t=Yr(e);if(t===null)return typeof e==="string"?e:"";return new Intl.DisplayNames([t],{type:"language"}).of(t)??t}var St="prefix-except-default";function Or(e){let t=e.i18n,n=[];if(!t||typeof t!=="object")return{errors:n,i18n:null};let o=Array.isArray(t.locales)?t.locales:[],r=[];for(let a of o){let l=Yr(a);if(l===null){n.push(`i18n.locales: "${String(a)}" is not a well-formed BCP 47 language tag.`);continue}if(!r.includes(l))r.push(l)}let i=Yr(t.defaultLocale)??r[0]??null;if(t.defaultLocale!==void 0&&Yr(t.defaultLocale)===null)n.push(`i18n.defaultLocale: "${String(t.defaultLocale)}" is not a well-formed BCP 47 language tag.`);if(i===null)return n.push("i18n is declared with no usable locale — set `defaultLocale` or `locales`."),{errors:n,i18n:null};if(!r.includes(i))r.unshift(i);let s=t.routing==="prefix-always"||t.routing==="prefix-except-default"?t.routing:St;return{errors:n,i18n:{defaultLocale:i,locales:r,routing:s}}}function nh(e,t){let n=se(F(e),t);if(n===-1||t===null)return null;return Yr(F(e)[n])}function OL(e,t){let n=nh(e,t);if(n!==null||t===null||t.routing!=="prefix-except-default")return n;return F(e)[0]==="pages"?t.defaultLocale:null}function r1(e,t){let n=F(e),o=se(n,t);return o===-1?n.join("/"):n.filter((r,i)=>i!==o).join("/")}function ih(e,t,n){if(n===null)return null;let o=Yr(t);if(o===null||!n.locales.includes(o))return null;let r=F(e),i=se(r,n),s=i===-1?Ct(r):i;if(s===-1)return null;let a=i===-1?r:r.filter((l,c)=>c!==i);if(o===n.defaultLocale&&n.routing==="prefix-except-default")return a.join("/");return a.toSpliced(s,0,o.toLowerCase()).join("/")}function F(e){return e.replace(/^\.\//,"").split("/").filter(Boolean)}function se(e,t){if(t===null)return-1;return e.findIndex((n)=>{let o=Yr(n);return o!==null&&t.locales.includes(o)})}function Ct(e){if(e[0]==="pages"&&e.length>1)return 1;if(e[0]==="content"&&e.length>2)return 2;return-1}var Rt={design:"canvas",edit:"canvas",entry:"entry","git-diff":"diff",grid:"grid",manage:"library",media:"media",preview:"canvas",settings:"config",source:"code",stylebook:"config"},wy={canvas:"Canvas",code:"Code",config:"Project Styles",diff:"Diff",entry:"Entry",grid:"Grid",media:"Media",library:"Library",none:"None"};function _a(e){return Rt[e]??"canvas"}var At={design:"design",edit:"edit",preview:"preview"};function AL(e){return At[e]??"design"}var xy=(e)=>e.editor.kind==="canvas",Vd=(e)=>xy(e)&&e.selection.count>0,_y=(e)=>Vd(e)&&!e.selection.isRoot;function Dm(){return{project:{open:!1,isSite:!1,isRepo:!1,isMultilingual:!1},git:{ahead:0,behind:0,dirtyCount:0},document:{open:!1,dirty:!1,mode:"",canUndo:!1,canRedo:!1},editor:{kind:"none"},canvas:{view:"design"},pane:{count:1,derived:!1},selection:{count:0,paths:[],kind:"",isRoot:!1,isComponentInstance:!1,isLayoutNode:!1,isRepeater:!1},caret:{active:!1,inCanvas:!1},focus:{region:"pane"},modal:{open:!1},collab:{attached:!1,readOnly:!1,sourceCanonical:!1},ai:{configured:!1,streaming:!1,waiting:!1},capability:{gitClone:!1,importSite:!1,openProjectInNewWindow:!1,dataRows:!1,windowControls:!1,findReferences:!1,readFileBytes:!1}}}function Bx(e={}){let t=Dm();for(let n of Object.keys(e)){let o=e[n];if(o)Object.assign(t[n],o)}return t}var kt=["palette"],Jt=["caret","global"],jt=["dock","global"],It=["canvas","global"],Dt=["grid","global"],Et=["code","global"],Ae=["global"];function PL(e){if(e.modal.open)return kt;if(e.caret.active)return Jt;if(e.focus.region!=="pane")return jt;switch(e.editor.kind){case"grid":return Dt;case"code":return Et;case"canvas":return e.canvas.view==="preview"?Ae:It;default:return Ae}}var ae=y(new Set);function $p(e){ae.add(e)}function Sy(e){ae.delete(e)}function Wx(e){return ae.has(e)}function Nm(e,t){return{success:!0,data:e,summary:t}}function zi(e){return{success:!1,error:e}}function Yi({name:e,description:t,parameters:n,strict:o=!0,llmStrict:r=!1,interactive:i,execute:s}){return{name:e,description:t,parameters:n,strict:o,llmStrict:r,...i===void 0?{}:{interactive:i},execute:s}}function Cy(e){let t=[];return{record(n){t.push(n),e?.(n)},writes:t}}function zd(e=null,t={}){let n=new Map(Object.entries(t));return{sessionId:e,get:(o)=>n.get(o),set:(o,r)=>{n.set(o,r)},toJSON:()=>Object.fromEntries(n)}}var Lt=new AbortController().signal;function ky(e={}){let t=e.session??zd();return{actor:e.actor??{id:`assistant:${t.sessionId??"local"}:`,kind:"assistant",sessionId:t.sessionId,turnId:""},callId:e.callId??"",ledger:e.ledger??Cy(),progress:e.progress??(()=>{}),session:t,signal:e.signal??Lt}}function ML(e){let t=new AbortController;if(e.aborted)return t.abort(e.reason),{release:()=>{},signal:t.signal};let n=()=>{t.abort(e.reason)};return e.addEventListener("abort",n,{once:!0}),{release:()=>{e.removeEventListener("abort",n)},signal:t.signal}}function o1(){let e=new Map;return{register(t){if(e.has(t.name))console.warn(`Tool "${t.name}" is being re-registered.`);e.set(t.name,t)},list(){return[...e.values()]},listForLLM(){return[...e.values()].map((t)=>({type:"function",function:{name:t.name,description:t.description,parameters:t.parameters,...t.llmStrict===!0?{strict:!0}:{}}}))},getDefinition(t){return e.get(t)},validate(t,n){let o=e.get(t);if(!o)return{valid:!1,errors:[`Unknown tool: "${t}"`]};if(!o.strict)return{valid:!0};let r=o.parameters;if(!r||!r.properties)return{valid:!0};let i=[],s=r.properties,a=r.required||[],l=n;for(let c of a)if(!(c in n)||l[c]===void 0||l[c]===null)i.push(`Missing required argument: "${c}"`);for(let[c,d]of Object.entries(l)){let g=s[c];if(!g)continue;let h=g.type;if(!h)continue;let b=Array.isArray(d)?"array":typeof d;if(h==="number"||h==="integer"){if(b==="number")continue;if(b==="string"){if(!Number.isNaN(Number(d)))continue;i.push(`Argument "${c}" should be a number, got non-numeric string "${d}"`);continue}i.push(`Argument "${c}" should be a number, got ${b}`);continue}if(h==="string"&&b!=="string")i.push(`Argument "${c}" should be a string, got ${b}`);else if(h==="boolean"&&b!=="boolean")i.push(`Argument "${c}" should be a boolean, got ${b}`);else if(h==="array"&&b!=="array")i.push(`Argument "${c}" should be an array, got ${b}`);else if(h==="object"&&b!=="object")i.push(`Argument "${c}" should be an object, got ${b}`)}return i.length>0?{valid:!1,errors:i}:{valid:!0}},async execute(t,n,o=ky()){let r=e.get(t);if(!r)return zi(`Unknown tool: "${t}"`);let i=this.validate(t,n);if(!i.valid)return zi(`Validation failed: ${(i.errors||[]).join("; ")}`);try{return await r.execute(n,o)}catch(s){return zi(`Tool "${t}" execution error: ${s.message}`)}}}}function Mt(e){return JSON.parse(JSON.stringify(e))}function $t(e){if(!e)return{};let t=JSON.parse(e);if(t===null||typeof t!=="object"||Array.isArray(t)){let n=t===null?"null":Array.isArray(t)?"array":typeof t;throw TypeError(`arguments must be a JSON object, got ${n}`)}return t}async function FL(e,t,n){let o=!1,r;try{let i=$t(t.argumentsText);o=!0,r=await e.execute(t.name,i,n)}catch(i){r=zi(`Failed to parse arguments: ${i.message}`)}try{return{status:"done",result:Mt(r),executed:o}}catch(i){let s=i.message;return{status:"done",result:zi(`Tool "${t.name}" returned a result that cannot be serialized: ${s}`),executed:o}}}var W=[],Nt=50;function jL(e){return Object.assign(Cy(),{turnId:e})}function HL(e,t){if(t.length===0)return[];let n={id:e,writes:[...t]};W.push(n);while(W.length>Nt)W.shift();return n.writes}function Vx(e){return W.find((t)=>t.id===e)?.writes??[]}function BL(e){let t=e.filter((a)=>a.ok),n=new Set(t.map((a)=>a.path)),o=e.length-t.length;if(n.size===0)return o>0?`${o} change${o===1?"":"s"} failed`:"";let r=`Changed ${n.size} file${n.size===1?"":"s"}`,i=new Set(t.filter((a)=>a.disk).map((a)=>a.path)),s=[r];if(i.size>0)s.push(`${i.size} written to disk — undo cannot reach ${i.size===1?"it":"them"}`);if(o>0)s.push(`${o} failed`);return s.join(" · ")}function zx(){W.splice(0)}function WL(e,t){let n=null;for(let o=e.length-1;o>=0;o--){let r=e[o];if(r.id===t)return n;let i=r.role==="assistant"&&(r.content||(r.toolCalls?.length??0)>0);if(n===null&&i)n=r.id}return t===void 0?n:null}var Kx="{locale}";function Je(e){return e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}function B(e){return e.replaceAll("\\","/").replace(/^\.\//,"").replace(/\/+$/,"")}function je(e){return e??D?.projectConfig??null}function Ie(e){return e?.content??{}}function _t(e){let t=Or(e??{}).i18n?.locales??[];return t.length>0?[...t]:null}function De(e){if(e.endsWith("/"))return!1;let t=e.slice(e.lastIndexOf("/")+1);return/\.[a-z\d]+$/i.test(t)}function Ee(e){if(e.format==="json")return{ext:".json",unresolvedFormat:null};if(e.format===void 0||e.format==="")return{ext:Fo()?.extensions[0]??".json",unresolvedFormat:null};let t=_i(e.format);return t?.extensions[0]===void 0?{ext:null,unresolvedFormat:e.format}:{ext:t.extensions[0],unresolvedFormat:null}}function Ft(e,t){let n=t===null?"[^/]+":`(?:${t.map((r)=>Je(r)).join("|")})`,o=B(e).split(Kx).map((r)=>Je(r)).join(n);return new RegExp(`^${o}(?:/|$)`,"i")}function Wt(e,t,n){let o=Ft(e,n).exec(t);if(!o)return null;return o[0].replace(/\/$/,"")}function Bt(e){return B(e).replaceAll(Kx,"").length}function Op(e,t){if(e===null||e===void 0||e==="")return null;let n=je(t),o=_t(n),r=B(e),i=null,s=-1;for(let[a,l]of Object.entries(Ie(n))){let{source:c}=l;if(c===void 0||c===""||De(c))continue;let d=Bt(c);if(d<=s)continue;let g=Wt(c,r,o);if(g===null)continue;i={def:l,dir:r,fileBacked:!1,isSourceRoot:r.length===g.length,name:a,...Ee(l)},s=d}return i}function Jx(e,t){if(e===null||e===void 0||e==="")return null;let n=je(t),o=B(e),r=o.toLowerCase();for(let[i,s]of Object.entries(Ie(n))){let{source:a}=s;if(a===void 0||a===""||!De(a))continue;let l=B(a).toLowerCase();if(r===l||r.endsWith(`/${l}`))return{def:s,dir:o.includes("/")?o.slice(0,o.lastIndexOf("/")):".",fileBacked:!0,isSourceRoot:!1,name:i,...Ee(s)}}return Op(o.includes("/")?o.slice(0,o.lastIndexOf("/")):".",n)}function Kl(e){return e.replaceAll(/([A-Z])/g," $1").replace(/^./,(t)=>t.toUpperCase())}function Fy(e){return e.replaceAll(/[^a-zA-Z0-9]+(.)?/g,(t,n)=>n?n.toUpperCase():"").replace(/^[A-Z]/,(t)=>t.toLowerCase())}function jy(e){return e.replaceAll(/(^|-)(\w)/g,(t,n,o)=>(n?" ":"")+o.toUpperCase())}function Yx(e,t){return e?.$label||Kl(t)}function uR(e,t){if(e?.$label)return e.$label;if(t.includes("-"))return t.replaceAll(/(^|-)(\w)/g,(n,o,r)=>(o?" ":"")+r.toUpperCase());return Kl(t)}function ka(e){return e==="image"||e==="uri-reference"}function Ud(e){if(e.$shorthand===!0)return"shorthand";if(e.$input==="button-group")return"button-group";if(e.$input==="media")return"media";if(e.format==="color")return"color";if(ka(e.format))return"media";if(e.$units!==void 0)return"number-unit";if(e.type==="number")return"number";if(Array.isArray(e.enum))return"select";if(Array.isArray(e.examples)||Array.isArray(e.presets))return"combobox";return"text"}function sh(e,t){if(!e||!t?.content)return null;let n=Jx(e,t);if(!n||!n.def.schema)return null;if(!n.fileBacked){let o=n.ext??Fo()?.extensions[0]??".json";if(!e.toLowerCase().endsWith(o.toLowerCase()))return null}return{name:n.name,schema:n.def.schema}}function Pm(e,t){let n=e.trim().toLowerCase().replaceAll(/[^a-z0-9\s-]/g,"").replaceAll(/\s+/g,"-").replaceAll(/-+/g,"-").replaceAll(/^-|-$/g,"");if(!n)return"";return`${t}${n}`}function Hy(e,t){return e.replace(new RegExp(`^${t.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}`),"").replace(/^--/,"").replaceAll("-"," ").replaceAll(/\b\w/g,(n)=>n.toUpperCase())||e}function hR(e){if(!e)return{kind:"text"};let t=e.trim().replaceAll(/\s*\|\s*undefined\b/g,"").trim();if(t==="boolean")return{kind:"boolean"};if(t==="number")return{kind:"number"};if(t.match(/^'[^']*'(\s*\|\s*'[^']*')+$/))return{kind:"combobox",options:[...t.matchAll(/'([^']*)'/g)].map((r)=>r[1])};return{kind:"text"}}function Pr(e){return JSON.parse(JSON.stringify(e))}function Le(e){return e&&e.length>0?e.at(-1):null}function UL(e){return e&&e.length>0?e[0]:null}function Ty(e,t){if(!t||!e)return!1;return e.some((n)=>Qr(n,t))}function xs(e){return E(e)}function E(e){let t=[];for(let n of e)t.push([...n]);return t}function Ly(e,t){if(Ty(e,t))return E(e.filter((n)=>!Qr(n,t)));return[...E(e),[...t]]}function qL(e,t,n){let o=e.findIndex((s)=>Qr(s,n)),r=t?e.findIndex((s)=>Qr(s,t)):-1;if(o===-1||r===-1)return[[...n]];let i=r<=o?e.slice(r,o+1):e.slice(o,r+1).toReversed();return E(i)}function Me(e,t){return E(e.filter((n)=>!il(t,n)))}function Vt(e,t){let n=Math.min(e.length,t.length);for(let o=0;o<n;o++){let r=e[o],i=t[o];if(r===i)continue;if(typeof r==="number"&&typeof i==="number")return r-i;return String(r)<String(i)?-1:1}return e.length-t.length}function Kt(e){return E(e.filter((t)=>!e.some((n)=>!Qr(n,t)&&il(n,t))))}function ql(e){return e.at(-2)==="children"&&typeof e.at(-1)==="number"}function Ry(e){return Kt(e).filter((t)=>ql(t)).toSorted((t,n)=>Vt(n,t))}function GL(e){let t=[];for(let n of e)if(!t.some((o)=>Qr(o,n)))t.push([...n]);return t}function Dp(e){if(e.length===0)return{mixed:!1,value:void 0};let t=e[0],n=JSON.stringify(t??null);for(let o=1;o<e.length;o++)if(JSON.stringify(e[o]??null)!==n)return{mixed:!0,value:void 0};return{mixed:!1,value:t}}var $e=null;function KL(e){$e=e}function Ne(){return $e}var V=null,U=null,G=null,le=!0;function _e(){V=[],U=[],G=[],le=!0}function f(e){if(V)V.push(e)}function wi(e){if(U)U.push(e)}function Fe(e){if(G)G.push(e)}function We(){let e={docOps:U??[],fmOps:G??[],invertible:le,ops:V??[]};return V=null,U=null,G=null,le=!0,e}var Be=100,Ut=20;function H(){try{return typeof localStorage>"u"||!localStorage.getItem("jx-legacy-history")}catch{return!0}}function P(e,t,n,o){return{forward:{key:t,op:"set-key",path:e,value:o},inverse:{key:t,op:"set-key",path:e,value:n}}}function Gt(e,t,n,o,r){let i=e.length;if(!(i<t.length&&e.every((c,d)=>c===t[d]))||t[i]!=="children"||typeof t[i+1]!=="number")return t;let a=t[i+1];if(r?a<n:a<=n)return t;let l=[...t];return l[i+1]=a+o,l}var Ve=null;function Ke(e){Ve=e}var Ge=null;function qe(e){Ge=e}function Ht(e,t,n,o){for(let r=t.docOps.length-1;r>=0;r--)Vm(e.doc.document,oe(t.docOps[r].inverse));for(let r=t.fmOps.length-1;r>=0;r--){let i=t.fmOps[r];fe(e,i.field,i.before)}e.doc.document={...oe(e.doc.document)},e.session.selection=n,e.doc.dirty=o}function q(e,t,{skipHistory:n=!1,origin:o="user",coalesceKey:r=null}={}){if(!e)return!1;if(o!=="remote"&&Ge?.(e,o))return!1;let i=xs(e.session.selection),s=e.doc.dirty;_e();let a,l=null;try{t(e)}catch(b){l={error:b}}finally{a=We()}if(l)throw Ht(e,a,i,s),l.error;let c=oe(e.doc.document),d={...c},g=Ne(),h=g===null?{patchable:!1,reason:"no-patch-consumer"}:a.ops.length===0?{patchable:!1,reason:"unrecorded-mutation"}:g.classify(e,a.ops);if(h.patchable)g.markConsumed(d,e);if(e.doc.document=d,h.patchable)try{g.apply(e,a.ops,a)}catch(b){g.escalate(`patch-apply-failed: ${b instanceof Error?b.message:String(b)}`,e)}if(!n&&!L)qt(e,c,a,i,r);return e.doc.dirty=!0,Ve?.(e,a,o),!0}function qt(e,t,n,o,r=null){let i=e.history.snapshots.slice(0,e.history.index+1),s=H()&&n.invertible&&(n.docOps.length>0||n.fmOps.length>0),a=i.at(-1);if(r&&s&&a&&a.coalesceKey===r&&a.inverseOps){if(a.forwardOps=[...a.forwardOps??[],...n.docOps.map((c)=>c.forward)],a.inverseOps=[...a.inverseOps,...n.docOps.map((c)=>c.inverse)],a.selection=xs(e.session.selection),a.document)a.document=Pr(t);e.history.snapshots=i,e.history.index=i.length-1;return}let l=!s||i.length%Ut===0;if(i.push({document:l?Pr(t):null,fmOps:s&&n.fmOps.length>0?n.fmOps:null,forwardOps:s?n.docOps.map((c)=>c.forward):null,inverseOps:s?n.docOps.map((c)=>c.inverse):null,coalesceKey:r,selection:xs(e.session.selection),selectionBefore:o}),i.length>Be){if(!i[1].document)i[1].document=ce(i,1);i.shift()}e.history.snapshots=i,e.history.index=i.length-1}function ce(e,t){let n=t;while(n>=0&&!e[n].document)n-=1;if(n<0)throw Error("history-missing-checkpoint");let o=Pr(e[n].document);for(let r=n+1;r<=t;r++)for(let i of e[r].forwardOps??[])Vm(o,i);return o}function qs(e,t,n){return q(e,(o)=>t(o.doc.document),n)}function ue(e,t){q(e,(n)=>{for(let o of t)de(n,o)},{origin:"remote",skipHistory:!0})}var zt=new Set(["state","$media","$head","$elements","imports","$layout"]);function de(e,t){let n=t.op==="set-key"?K(e.doc.document,t.path)?.[t.key]:null;switch(Vm(e.doc.document,t),wi({forward:t,inverse:t}),t.op){case"set-key":{if(zt.has(t.key))f({key:t.key,op:"doc-meta"});else if(t.key==="style")f({op:"set-style",path:t.path});else if(t.key==="textContent")f({op:"set-text",path:t.path});else if(t.key==="attributes"||t.key==="cases"||t.key==="$props")f({op:"replace",path:t.path});else{let o=t.key.startsWith("on")&&(vh(t.value)||vh(n));f({isEvent:o,key:t.key,op:"set-prop",path:t.path})}return}case"insert-child":{f({index:t.index,op:"insert",parentPath:t.parentPath});return}case"remove-child":{f({op:"remove",path:[...t.parentPath,"children",t.index]});return}case"set-child":{f({op:"replace",path:[...t.parentPath,"children",t.index]});return}case"move-child":{f({fromPath:[...t.fromParentPath,"children",t.fromIndex],op:"move",toIndex:t.toIndex,toParentPath:t.toParentPath});break}default:break}}var L=null,ze=null;function Ye(e){ze=e}function $y(e){L=e}function Iy(){let e=L;if(e&&!j.has(e)){let t=oe(e.doc.document),n={document:Pr(t),selection:xs(e.session.selection)},o=e.history.snapshots.slice(0,e.history.index+1);if(o.push(n),o.length>Be)o.shift();e.history.snapshots=o,e.history.index=o.length-1}if(L=null,e)ze?.(e)}function Ux(){return L!==null}function JL(){return L}var j=new WeakMap;function Om(e,t){if(t)j.set(e,t);else j.delete(e)}function YL(e){let t=j.get(e);return t?t.canUndo(e):e.history.index>0}function ZL(e){let t=j.get(e);return t?t.canRedo(e):e.history.index<e.history.snapshots.length-1}function Ze(e,t){let{snapshots:n}=e.history;e.doc.document=ce(n,t);let o=n[t];e.session.selection=xs(oe(o.selection))}function Xe(e,t){try{if(typeof localStorage>"u"||!localStorage.getItem("jx-canvas-debug"))return}catch{return}let n=JSON.stringify(ce(e.history.snapshots,t)),o=JSON.stringify(Pr(oe(e.doc.document)));if(n!==o)console.error("jx history: ops-based undo/redo diverged from checkpoint replay",{index:t})}function qx(e){let t=j.get(e);if(t){t.undo(e);return}if(e.history.index<=0)return;let n=e.history.snapshots[e.history.index],o=H()?n.inverseOps:null,r=H()?n.fmOps:null;if(o&&o.length>0||r&&r.length>0){if(!q(e,(s)=>{if(o)for(let a=o.length-1;a>=0;a--)de(s,oe(o[a]));if(r)for(let a=r.length-1;a>=0;a--){let l=oe(r[a]);fe(s,l.field,l.before)}},{origin:"history",skipHistory:!0}))return;e.session.selection=xs(oe(n.selectionBefore??[])),e.history.index-=1,Xe(e,e.history.index)}else e.history.index-=1,Ze(e,e.history.index);e.doc.dirty=!0}function XL(e){let t=j.get(e);if(t){t.redo(e);return}if(e.history.index>=e.history.snapshots.length-1)return;let n=e.history.snapshots[e.history.index+1],o=H()?n.forwardOps:null,r=H()?n.fmOps:null;if(o&&o.length>0||r&&r.length>0){if(!q(e,(s)=>{if(o)for(let a of o)de(s,oe(a));if(r)for(let a of r){let l=oe(a);fe(s,l.field,l.after)}},{origin:"history",skipHistory:!0}))return;e.session.selection=xs(oe(n.selection)),e.history.index+=1,Xe(e,e.history.index)}else e.history.index+=1,Ze(e,e.history.index);e.doc.dirty=!0}function Zi(e,t,n,o){let r=K(e.doc.document,t);if(!r)return;Bc(r).splice(n,0,structuredClone(o)),f({index:n,op:"insert",parentPath:t}),wi({forward:{index:n,node:Oe(o),op:"insert-child",parentPath:t},inverse:{index:n,op:"remove-child",parentPath:t}})}function rh(e,t){if(!t||!ql(t))return;let n=ht(t),o=Cn(t),[r]=K(e.doc.document,n).children.splice(o,1);f({op:"remove",path:t}),wi({forward:{index:o,op:"remove-child",parentPath:n},inverse:{index:o,node:Oe(r),op:"insert-child",parentPath:n}}),e.session.selection=Me(e.session.selection,t)}function a1(e,t){if(!t||!ql(t))return;let n=K(e.doc.document,t);if(!n)return;let o=ht(t),r=Cn(t),i=structuredClone(oe(n));K(e.doc.document,o).children.splice(r+1,0,i),f({index:r+1,op:"insert",parentPath:o}),wi({forward:{index:r+1,node:Oe(i),op:"insert-child",parentPath:o},inverse:{index:r+1,op:"remove-child",parentPath:o}}),e.session.selection=[[...o,"children",r+1]]}function Np(e,t){for(let n of Ry(t))rh(e,n)}function Dy(e,t){let n=[];for(let o of Ry(t)){let r=e.session.selection;a1(e,o);let i=Le(e.session.selection);if(!i||e.session.selection===r)continue;let s=ht(i),a=Cn(i);n=n.map((l)=>Gt(s,l,a,1,!0)),n.unshift(i)}if(n.length>0)e.session.selection=n}function QL(e,t,n="div"){if(!t||!ql(t))return;let o=K(e.doc.document,t);if(!o)return;let r=ht(t),i=Cn(t),s={children:[structuredClone(oe(o))],tagName:n},a=Oe(o);K(e.doc.document,r).children.splice(i,1,s),f({op:"replace",path:t}),wi({forward:{index:i,node:Oe(s),op:"set-child",parentPath:r},inverse:{index:i,node:a,op:"set-child",parentPath:r}}),e.session.selection=[[...r,"children",i]]}function Sa(e,t,n,o){let r=e.doc.document,i=ht(t),s=Cn(t);if(!i||typeof s!=="number")return;let a=K(r,i),l=K(r,n);if(!a||!Array.isArray(a.children)||!l)return;if(a.children[s]===void 0)return;let c=o;if(a===l&&s<o)c-=1;let d={fromIndex:s,fromParentPath:i,op:"move-child",toIndex:c,toParentPath:n},g=k1(r,d),[h]=a.children.splice(s,1);if(Bc(l).splice(c,0,h),f({fromPath:t,op:"move",toIndex:c,toParentPath:n}),wi({forward:d,inverse:g}),Qr(Le(e.session.selection),t)){let b=o;if(i.length===n.length&&i.every((_,I)=>_===n[I])&&s<o)b=o-1;e.session.selection=[[...n,"children",b]]}}function Ue(e,t,n,o){let r=K(e.doc.document,t);if(!r)return;let i=r[n],s=Oe(i);if(o===void 0||o===null||o==="")delete r[n];else r[n]=o;if(wi(P(t,n,s,Oe(r[n]))),n==="textContent")f({op:"set-text",path:t});else if(n==="style")f({op:"set-style",path:t});else{let a=o===void 0||o===null||o===""?i:o,l=n.startsWith("on")&&vh(a);f({isEvent:l,key:n,op:"set-prop",path:t})}}function Pc(e,t,n,o){let r=K(e.doc.document,t),i=Oe(r.style);if(!r.style)r.style={};if(o===void 0||o==="")delete r.style[n];else r.style[n]=o;if(Object.keys(r.style).length===0)delete r.style;wi(P(t,"style",i,Oe(r.style))),f({op:"set-style",path:t})}function Zr(e,t,n,o){let r=K(e.doc.document,t),i=Oe(r.attributes);if(!r.attributes)r.attributes={};if(o===void 0||o==="")delete r.attributes[n];else r.attributes[n]=o;if(Object.keys(r.attributes).length===0)delete r.attributes;wi(P(t,"attributes",i,Oe(r.attributes))),f({attr:n,op:"set-attr",path:t})}function eR(e,t,n,o,r){if(!n)return Pc(e,t,o,r);let i=K(e.doc.document,t),s=Oe(i.style);if(!i.style)i.style={};let a=`@${n}`,l=yh(i.style,a);if(r===void 0||r===""){if(delete l[o],Object.keys(l).length===0)delete i.style[a]}else l[o]=r;if(Object.keys(i.style).length===0)delete i.style;wi(P(t,"style",s,Oe(i.style))),f({op:"set-style",path:t})}function Ny(e,t,n,o,r){let i=K(e.doc.document,t),s=Oe(i.style);if(!i.style)i.style={};let a=yh(i.style,n);if(r===void 0||r===""){if(delete a[o],Object.keys(a).length===0)delete i.style[n]}else a[o]=r;if(Object.keys(i.style).length===0)delete i.style;wi(P(t,"style",s,Oe(i.style))),f({op:"set-style",path:t})}function tR(e,t,n,o,r,i){let s=K(e.doc.document,t),a=Oe(s.style);if(!s.style)s.style={};let l=`@${n}`,c=yh(s.style,l),d=yh(c,o);if(i===void 0||i===""){if(delete d[r],Object.keys(d).length===0)delete c[o];if(Object.keys(c).length===0)delete s.style[l]}else d[r]=i;if(Object.keys(s.style).length===0)delete s.style;wi(P(t,"style",a,Oe(s.style))),f({op:"set-style",path:t})}function Qe(e,t){let n=[e];for(let o of t){let r=La(n.at(-1),o);if(!r)break;n.push(r)}for(let o=n.length-2;o>=0;o--){let r=n[o],i=t[o],s=La(r,i);if(s&&Object.keys(s).length===0)delete r[i]}}function Oy(e,t,n,o,r){let i=K(e.doc.document,t),s=Oe(i.style);if(!i.style)i.style={};let a=i.style;for(let l of n)a=yh(a,l);if(r===void 0||r==="")delete a[o],Qe(i.style,n);else a[o]=r;if(Object.keys(i.style).length===0)delete i.style;wi(P(t,"style",s,Oe(i.style))),f({op:"set-style",path:t})}function nR(e,t,n,o,r,i){let s=K(e.doc.document,t),a=Oe(s.style);if(!s.style)s.style={};let l=`@${n}`,c=yh(s.style,l),d=c;for(let g of o)d=yh(d,g);if(i===void 0||i===""){if(delete d[r],Qe(c,o),Object.keys(c).length===0)delete s.style[l]}else d[r]=i;if(Object.keys(s.style).length===0)delete s.style;wi(P(t,"style",a,Oe(s.style))),f({op:"set-style",path:t})}function iR(e,t,n){let o=K(e.doc.document,t),r=Oe(o.style);if(n&&Object.keys(n).length>0)o.style=n;else delete o.style;wi(P(t,"style",r,Oe(o.style))),f({op:"set-style",path:t})}function Gs(e,t,n){let o=e.doc.document,r=Oe(o.state);if(!o.state)o.state={};o.state[t]=n,wi(P([],"state",r,Oe(o.state))),f({key:"state",op:"doc-meta"})}function Ay(e,t){let n=e.doc.document;if(n.state){let o=Oe(n.state);if(delete n.state[t],Object.keys(n.state).length===0)delete n.state;wi(P([],"state",o,Oe(n.state))),f({key:"state",op:"doc-meta"})}}function wo(e,t,n){let o=e.doc.document,r=Oe(o.state);if(!o.state)o.state={};let i=o.state[t],s=i==null?{}:typeof i!=="object"||Array.isArray(i)?{default:i}:i;o.state[t]=s,Object.assign(s,n);for(let a of Object.keys(s))if(s[a]===void 0||s[a]===null)delete s[a];wi(P([],"state",r,Oe(o.state))),f({key:"state",op:"doc-meta"})}function rR(e,t,n){let o=e.doc.document;if(!o.state||!o.state[t])return;let r=Oe(o.state);o.state[n]=o.state[t],delete o.state[t],wi(P([],"state",r,Oe(o.state))),f({key:"state",op:"doc-meta"})}function oh(e,t,n,o){let r=K(e.doc.document,t),i=Oe(r.$props);if(!r.$props)r.$props={};if(o===void 0||o===null||o==="")delete r.$props[n];else r.$props[n]=o;if(Object.keys(r.$props).length===0)delete r.$props;wi(P(t,"$props",i,Oe(r.$props))),f({op:"replace",path:t})}function oR(e,t,n,o){let r=K(e.doc.document,t),i=Oe(r.cases);if(!r.cases)r.cases={};r.cases[n]=o||{tagName:"div",textContent:n},wi(P(t,"cases",i,Oe(r.cases))),f({op:"replace",path:t})}function sR(e,t,n){let o=K(e.doc.document,t);if(o.cases){let r=Oe(o.cases);delete o.cases[n],wi(P(t,"cases",r,Oe(o.cases))),f({op:"replace",path:t})}}function aR(e,t,n,o){let r=K(e.doc.document,t);if(!r.cases||!r.cases[n])return;let i=Oe(r.cases);r.cases[o]=r.cases[n],delete r.cases[n],wi(P(t,"cases",i,Oe(r.cases))),f({op:"replace",path:t})}function Gl(e,t,n){let o=e.doc.content.frontmatter,r=Object.hasOwn(o,t)?Oe(o[t]):void 0,i=n===void 0||n===null||n==="";if(i)delete o[t];else o[t]=n;let s=i?void 0:Oe(n);Fe({after:s,before:r,field:t}),e.doc.dirty=!0}function fe(e,t,n){if(n===void 0)delete e.doc.content.frontmatter[t];else e.doc.content.frontmatter[t]=n}var ci="project.json";function Yt(e,t=!1){return{activeMedia:null,activeSelector:null,openPopover:null,openDialog:null,canvasMode:e,editZoom:1,editingFormula:null,editingFunction:null,featureToggles:{},inspectorSections:{},pendingInlineEdit:null,preview:t,previewColorScheme:"auto",previewLocale:null,previewParams:{},previewProps:null,rightTab:"properties",showLayout:!0,styleFilter:"",styleSections:{},dataRows:{},dataLimits:{},styleShorthands:{},zoom:1}}var Zt=["edit","design","preview","source","stylebook","git-diff"];function Ey({id:e,documentPath:t=null,fileHandle:n=null,document:o,frontmatter:r,sourceFormat:i=null,capabilities:s,openedFrom:a=null,preview:l=!1,layout:c=null}){let d=ge();Wm(o);let g=s?.modes??Xt(t,i),h=g.find((I)=>I!=="preview")??"edit",b=g[0]==="preview";return d.run(()=>({capabilities:{modes:g},doc:y({content:{frontmatter:r||{}},dirty:!1,document:o,handlersSource:null,layout:c,mode:en(t,i),sourceFormat:i}),documentPath:t,fileHandle:n,history:y({index:0,snapshots:[{document:structuredClone(o),selection:[]}]}),id:e,pinned:!1,preview:l,scope:d,session:y({canvas:{refreshing:!1,error:null,livePreviews:null,pendingInlineEdit:null,scope:null,status:"idle"},clipboard:null,hover:null,openedFrom:a,selection:[],ui:Yt(h,b)})}))}function Xt(e,t){if(e===ci)return["stylebook","source"];let n=_i(t)??Qt(e);if(n)return n.studio?.modes??["edit","design","preview","source"];return Zt}function en(e,t){let n=_i(t)??Qt(e);if(n)return n.studio?.documentMode?.default??"content";return"component"}function s1(e){return _a(e.session.ui.canvasMode)}function VL(e){let t=[];for(let n of e.capabilities.modes){if(n==="preview")continue;let o=_a(n);if(!t.includes(o))t.push(o)}return t}function zL(e,t){return e.capabilities.modes.find((n)=>n!=="preview"&&_a(n)===t)}function Ip(e){e.scope.stop()}var et=new WeakMap,M=new Map;function Sn(e){let t=oe(e),n=et.get(t);if(!n)n=y({active:!1,attachError:"",peers:[],readOnly:!1,sourceCanonical:!1,status:"unavailable"}),et.set(t,n);return n}function tt(e){M.set(e,(M.get(e)??0)+1)}function nt(e){let t=M.get(e)??0;if(t<=1)M.delete(e);else M.set(e,t-1)}function Am(e){return M.has(e.replaceAll("\\","/"))}var tn=8000,nn=800,on=2500,ot=null;function rn(){return ot??=(me("wkyfjeqz"),import("./index-wkyfjeqz.js")),ot}function st(){try{return p()}catch{return null}}var N=null;function pR(e){N=e}var be=null;function fR(e){be=e}var at=()=>{};function mR(e){at=e??(()=>{})}var ye=new WeakMap;function lt(e){return oe(e)}function R(e){return ye.get(lt(e))}function ve(e){let t=lt(e),n=ye.get(t);if(!n)n={attaching:null,generation:0,optedOut:y({value:!1}),session:null,watcherInstalled:!1},ye.set(t,n);return n}var it=!1;function sn(){if(it)return;it=!0,Ke(an),Ye(ln),qe((e)=>{if(R(e)?.session?.synced&&Sn(e).sourceCanonical)return at("Source editing in progress — structural edits are paused"),"source-canonical";return null})}function an(e,t,n){let o=R(e)?.session;if(!o||!o.synced)return;if(o.lastSeenRef=oe(e.doc.document),n==="remote"){ee(o);return}if(o.canWrite)cn(o,t),ee(o)}function ln(e){let t=R(e)?.session;if(!t?.synced||t.batchOps===null)return;let{batchOps:n,batchNeedsDiff:o}=t;if(t.batchOps=null,t.batchNeedsDiff=!1,!t.canWrite)return;if(t.undoManager?.stopCapturing(),o)z(t);else if(n.length>0)try{t.collab.applyDocOpsToY(t.handle.doc,n,t.collab.LOCAL_ORIGIN)}catch{z(t)}t.undoManager?.stopCapturing()}function cn(e,t){let n=t.docOps.map((o)=>o.forward);if(Ux()){if(e.batchOps??=[],n.length===0)e.batchNeedsDiff=!0;else e.batchOps.push(...n);return}if(n.length===0){z(e);return}try{e.collab.applyDocOpsToY(e.handle.doc,n,e.collab.LOCAL_ORIGIN)}catch{z(e)}}function z(e){let{collab:t,handle:n,tab:o}=e,r=t.yDocToJson(n.doc),i=Pr(oe(o.doc.document)),s=t.diffDocs(r,i);if(s===null)t.replaceYStructure(n.doc,i,t.LOCAL_ORIGIN);else if(s.length>0)try{t.applyDocOpsToY(n.doc,s,t.LOCAL_ORIGIN)}catch{t.replaceYStructure(n.doc,i,t.LOCAL_ORIGIN)}}function pe(e){let t=e.collab.yDocToJson(e.handle.doc);q(e.tab,(n)=>{let o=n.doc.document;for(let r of Object.keys(o))if(!(r in t))delete o[r];Object.assign(o,t)},{origin:"remote",skipHistory:!0})}function un(e){if(!e.canWrite)return!1;let{awareness:t}=e.handle,n=t.clientID;for(let[o,r]of t.getStates())if(r.canWrite!==!1&&o<n)n=o;return n===e.handle.awareness.clientID}function ee(e){if(!N||!un(e))return;if(e.collab.canonicalOf(e.handle.doc)==="source")return;let t=Date.now();if(e.lastMirrorAt??=t,t-e.lastMirrorAt>=on){if(e.mirrorTimer)clearTimeout(e.mirrorTimer),e.mirrorTimer=null;e.lastMirrorAt=t,he(e);return}if(e.mirrorTimer)clearTimeout(e.mirrorTimer);e.mirrorTimer=setTimeout(()=>{e.mirrorTimer=null,e.lastMirrorAt=Date.now(),he(e)},nn)}async function he(e){if(!N||!e.synced)return;try{let t=await N(e.tab);e.collab.updateSourceText(e.handle.doc,t,e.collab.MIRROR_ORIGIN)}catch{}}async function ct(e){if(!be||!e.synced||!e.canWrite)return;let{collab:t,handle:n,tab:o}=e,r=t.canonicalRevOf(n.doc),i=t.sourceText(n.doc).toString(),s;try{s=await be(o,i)}catch{return}if(!e.synced||t.canonicalRevOf(n.doc)!==r)return;let a=t.diffDocs(t.yDocToJson(n.doc),s.document);if(a===null)t.replaceYStructure(n.doc,s.document,t.MIRROR_ORIGIN);else if(a.length>0)try{t.applyDocOpsToY(n.doc,a,t.MIRROR_ORIGIN)}catch{t.replaceYStructure(n.doc,s.document,t.MIRROR_ORIGIN)}let l=t.frontmatterMap(n.doc),c=s.frontmatter??{};n.doc.transact(()=>{let d=[...l.keys()];for(let g of d)if(!(g in c))l.delete(g);for(let[g,h]of Object.entries(c))if(!t.deepEqual(l.get(g),h))l.set(g,h)},t.MIRROR_ORIGIN)}function gR(e){let t=R(e)?.session;if(!t?.synced)return null;let{collab:n,handle:o}=t,r=null,i=()=>r!==null&&t.sourceLockOwner===r;return{awareness:o.awareness,enter:async()=>{r={},t.sourceLockOwner=r;let s=o.awareness.getLocalState();if(s)o.awareness.setLocalState({...s,mode:"source"});if(!t.canWrite)return;let a=null;if(N)try{a=await N(e)}catch{a=null}if(!i())return;n.acquireSourceCanonical(o.doc,a??n.sourceText(o.doc).toString(),n.LOCAL_ORIGIN)},leave:()=>{if(!i()){r=null;return}r=null,t.sourceLockOwner=null;let s=o.awareness.getLocalState();if(s)o.awareness.setLocalState({...s,mode:"structure"});if(!t.canWrite)return;if(n.otherSourceEditors(o.awareness,t.path,o.awareness.clientID).filter((l)=>o.awareness.getStates().get(l)?.canWrite!==!1).length===0)ct(t).then(()=>{n.releaseSourceCanonical(o.doc,n.LOCAL_ORIGIN)})},localOrigin:n.LOCAL_ORIGIN,readOnly:!t.canWrite,text:n.sourceText(o.doc)}}function Mm(e){let t=Sn(e);return t.active&&t.readOnly}async function d1(e){let t=R(e)?.session;if(!t?.synced||!t.canWrite)return!1;if(t.mirrorTimer)clearTimeout(t.mirrorTimer),t.mirrorTimer=null;return await he(t),await t.handle.flush(),!0}async function u1(){for(let e of xe)if(R(e)?.session?.synced)await d1(e)}var xe=new Set;function Y(e){if(!st()?.collab||!e.documentPath||e.documentPath===ci)return;let n=ve(e);if(n.watcherInstalled)return;n.watcherInstalled=!0,sn(),xe.add(e),e.scope.run(()=>{Q(()=>{if(n.optedOut.value)te(e);else Te(e)}),dl(()=>{xe.delete(e),te(e)})})}function h1(e,t){let n=ve(e);if(n.optedOut.value===!t)return;if(n.optedOut.value=!t,!n.watcherInstalled&&t)Y(e)}function p1(e){return R(e)?.optedOut.value!==!0}function ut(e){if(!R(e)?.watcherInstalled){Y(e);return}te(e),Te(e)}async function Te(e){let t=ve(e);if(t.session||t.attaching)return;let{documentPath:n}=e,o=st();if(!n||!o?.collab){Sn(e).status="unavailable";return}let{generation:r}=t,i=Sn(e);i.status="connecting",i.attachError="";let s=(async()=>{try{let[a,l]=await Promise.all([rn(),o.collab(n)]);if(!l){i.status="detached";return}if(t.generation!==r){l.destroy();return}let c=null,d=new Promise((g,h)=>{c=setTimeout(()=>h(Error("collab-sync-timeout")),tn)});try{await Promise.race([l.whenSynced,d])}finally{if(c)clearTimeout(c)}if(t.generation!==r){l.destroy();return}t.session=dn(e,n,a,l),i.active=!0,i.status="synced",i.readOnly=!t.session.canWrite,i.attachError="",tt(n)}catch(a){i.status="failed",i.active=!1,i.attachError=a instanceof Error?a.message:String(a),C.warn(`Live collaboration is not available for "${n}" — ${i.attachError}`,{key:`collab:${n}`,path:n,source:"Collaboration"})}finally{t.attaching=null}})();t.attaching=s,await s}function te(e){let t=R(e);if(!t)return;t.generation+=1;let{session:n}=t;t.session=null;let o=Sn(e);if(o.active=!1,o.status="detached",o.attachError="",o.peers=[],!n)return;if(nt(n.path),n.mirrorTimer)clearTimeout(n.mirrorTimer);if(n.sourceParseTimer)clearTimeout(n.sourceParseTimer);for(let r of n.disposers)try{r()}catch{}Om(e,null),e.history.snapshots=[{document:Pr(oe(e.doc.document)),selection:xs(e.session.selection)}],e.history.index=0,n.undoManager?.destroy(),n.handle.destroy()}function dn(e,t,n,o){let r=o.identity(),i={applyingRemoteFrontmatter:!1,batchNeedsDiff:!1,batchOps:null,canWrite:r?r.permission!=="read":!0,collab:n,disposers:[],handle:o,lastSeenRef:oe(e.doc.document),mirrorTimer:null,path:t,sourceLockOwner:null,sourceParseTimer:null,synced:!1,tab:e,undoManager:null};if(n.metaMap(o.doc).get("structureSeeded")===!0){let x=n.yDocToJson(o.doc),v=Pr(oe(e.doc.document));if(!n.deepEqual(x,v)){let w=n.diffDocs(v,x);if(w===null)i.synced=!0,pe(i),i.synced=!1;else if(w.length>0)ue(e,w)}i.applyingRemoteFrontmatter=!0;let T=n.frontmatterMap(o.doc);for(let[w,J]of T.entries())e.doc.content.frontmatter[w]=J;i.applyingRemoteFrontmatter=!1}else if(i.canWrite)n.seedStructure(o.doc,Pr(oe(e.doc.document)),{frontmatter:Pr(oe(e.doc.content.frontmatter)),origin:n.SEED_ORIGIN,sourceFormat:e.doc.sourceFormat});i.lastSeenRef=oe(e.doc.document),i.disposers.push(o.onDirty((x)=>{e.doc.dirty=x})),o.awareness.setLocalState({canWrite:i.canWrite,focusedPath:t,structuralSelection:null,user:r?{avatarUrl:r.avatarUrl,color:r.color,login:r.login,name:r.name}:{color:n.colorForKey(String(o.awareness.clientID)),login:`guest-${o.awareness.clientID%1000}`}});let a=new n.UndoManager([n.structureMap(o.doc),n.frontmatterMap(o.doc)],{trackedOrigins:new Set([n.LOCAL_ORIGIN])});i.undoManager=a;let l=({stackItem:x})=>{x.meta.set("selection",xs(e.session.selection))},c=({stackItem:x})=>{let v=x.meta.get("selection");e.session.selection=xs(v??[])};a.on("stack-item-added",l),a.on("stack-item-popped",c),i.disposers.push(()=>{a.off("stack-item-added",l),a.off("stack-item-popped",c)}),Om(e,{canRedo:()=>a.canRedo(),canUndo:()=>a.canUndo(),redo:()=>{a.redo()},undo:()=>{a.undo()}});let d=n.structureMap(o.doc),g=(x,v)=>{if(v.origin===n.LOCAL_ORIGIN||!i.synced)return;let T=n.yEventsToDocOps(x);if(T===null){pe(i);return}if(T.length===0)return;try{ue(e,T)}catch{pe(i)}};d.observeDeep(g),i.disposers.push(()=>d.unobserveDeep(g));let h=Sn(e);h.sourceCanonical=n.canonicalOf(o.doc)==="source";let b=n.metaMap(o.doc),_=()=>{h.sourceCanonical=n.canonicalOf(o.doc)==="source"};b.observe(_),i.disposers.push(()=>b.unobserve(_));let I=n.sourceText(o.doc),Se=(x,v)=>{if(v.origin===n.MIRROR_ORIGIN||!i.synced)return;if(n.canonicalOf(o.doc)!=="source")return;if(!n.isSourceReconciler(o.awareness,i.path))return;if(i.sourceParseTimer)clearTimeout(i.sourceParseTimer);i.sourceParseTimer=setTimeout(()=>{i.sourceParseTimer=null,ct(i)},600)};I.observe(Se),i.disposers.push(()=>I.unobserve(Se));let k=n.frontmatterMap(o.doc),Ce=(x,v)=>{if(v.origin===n.LOCAL_ORIGIN||!i.synced)return;i.applyingRemoteFrontmatter=!0;try{for(let[T,w]of x.changes.keys)if(w.action==="delete")delete e.doc.content.frontmatter[T];else e.doc.content.frontmatter[T]=k.get(T)}finally{i.applyingRemoteFrontmatter=!1}};k.observe(Ce),i.disposers.push(()=>k.unobserve(Ce)),e.scope.run(()=>{let x=JSON.stringify(e.doc.content.frontmatter);Q(()=>{let v=JSON.stringify(e.doc.content.frontmatter);if(v===x)return;if(x=v,i.applyingRemoteFrontmatter||!i.synced||!i.canWrite)return;let T=JSON.parse(v);o.doc.transact(()=>{let w=[...k.keys()];for(let J of w)if(!(J in T))k.delete(J);for(let[J,Re]of Object.entries(T))if(!n.deepEqual(k.get(J),Re))k.set(J,Re)},n.LOCAL_ORIGIN),ee(i)}),Q(()=>{let v=e.session.selection.length>0?xs(e.session.selection):null,T=o.awareness.getLocalState();if(T)o.awareness.setLocalState({...T,structuralSelection:v})}),Q(()=>{let v=oe(e.doc.document);queueMicrotask(()=>{if(R(e)?.session!==i||!i.synced||!i.canWrite)return;let w=oe(e.doc.document);if(w!==v||w===i.lastSeenRef)return;i.lastSeenRef=w,z(i),ee(i)})})});let re=Sn(e),ie=()=>{let x=[];for(let[v,T]of o.awareness.getStates())if(v!==o.awareness.clientID&&T.user)x.push({clientId:v,state:T});re.peers=x};return ie(),o.awareness.on("change",ie),i.disposers.push(()=>o.awareness.off("change",ie),o.onStatus((x)=>{if(x==="offline"||x==="connecting")re.status="offline";else if(i.synced)re.status="synced"}),o.onReset(()=>{te(e),Te(e)})),i.synced=!0,i}function S(e,t,n){return RangeError(`command "${e}" argument "${t}": ${n}`)}function O(e){if(e===void 0)return"missing";return typeof e==="string"?`"${e}"`:`${typeof e} ${JSON.stringify(e)}`}function rt(e,t,n){let o=t[n];if(typeof o!=="string"||o==="")throw S(e,n,`expected a non-empty string, got ${O(o)}`);return o}function Xr(e,t,n){if(t[n]===void 0)return;return rt(e,t,n)}function ft(e,t,n){let o=t[n];if(typeof o!=="number"||!Number.isFinite(o))throw S(e,n,`expected a finite number, got ${O(o)}`);return o}function dt(e,t,n){let o=t[n];if(typeof o!=="number"||!Number.isInteger(o))throw S(e,n,`expected an integer, got ${O(o)}`);return o}function Py(e,t,n,o,r){let i=ft(e,t,n);if(i<o||i>r)throw S(e,n,`${i} is outside the supported range ${o}–${r}`);return i}function xi(e,t,n){let o=t[n];if(typeof o!=="boolean")throw S(e,n,`expected a boolean, got ${O(o)}`);return o}function di(e,t,n,o){let r=t[n];if(typeof r!=="string"||!o.includes(r))throw S(e,n,`${O(r)} is not declared — declared: ${o.join(", ")||"none"}`);return r}function Gx(e,t,n){let o=t[n];if(!Array.isArray(o)||!o.every((r)=>typeof r==="string"||typeof r==="number"))throw S(e,n,`expected an array of path segments (strings or numbers), got ${O(o)}`);return o}function lR(e,t,n){if(t[n]===null)return null;return Gx(e,t,n)}function l1(e,t,n){let o=t[n];if(!Array.isArray(o))throw S(e,n,`expected an array of document paths, got ${O(o)}`);return o.map((r,i)=>{if(!Array.isArray(r)||!r.every((s)=>typeof s==="string"||typeof s==="number"))throw S(e,n,`entry ${i} is not a document path — expected an array of segments, got ${O(r)}`);return r})}function ke(e,t=Object.keys(e)){return{additionalProperties:!1,properties:e,required:[...t],type:"object"}}function Ar(e,t){return{description:t,enum:[...e],type:"string"}}function Ca(e,t){return{description:t,get enum(){return[...e()]},type:"string"}}function c1(e,t={}){return{description:e,type:"number",...t}}function sr(e){return{description:e,type:"boolean"}}function My(e,t=!1){let n={items:{type:["string","number"]},type:"array"};return t?{description:e,oneOf:[n,{type:"null"}]}:{description:e,...n}}function cR(e){return{description:e,items:{items:{type:["string","number"]},type:"array"},type:"array"}}function He(e){return{description:e,type:"string"}}function fn(e){return e.length===2&&e.includes("string")&&e.includes("number")}function Pe(e){return Array.isArray(e)?e:[e]}function pt(e){let t=e;if("enum"in t)return"enum";if("const"in t)return"const";if(Array.isArray(t.oneOf))return"one-of";if(Array.isArray(t.type))return"typed";switch(t.type){case"boolean":return"boolean";case"number":case"integer":{if(t.minimum!==void 0&&t.maximum!==void 0)return"bounded-number";return t.type==="integer"?"integer":"number"}case"string":return"string";case"array":{let n=t.items?.type;if(Array.isArray(n))return fn(n)?"path":"pass-through";return n==="array"?"path-list":"pass-through"}case"null":case"object":return"typed";default:break}return"pass-through"}function mt(e,t){switch(e){case"null":return t===null;case"boolean":return typeof t==="boolean";case"string":return typeof t==="string";case"number":return typeof t==="number"&&Number.isFinite(t);case"integer":return typeof t==="number"&&Number.isInteger(t);case"array":return Array.isArray(t);case"object":return typeof t==="object"&&t!==null&&!Array.isArray(t);default:break}return!1}function gt(e){if(e.length<=1)return e.join("");return`${e.slice(0,-1).join(", ")} or ${e.at(-1)}`}function pn(e,t,n,o){let r=t[n];if(!o.some((i)=>mt(i,r)))throw S(e,n,`expected ${gt(o)}, got ${O(r)}`);return r}function bt(e){switch(pt(e)){case"enum":return`one of ${(e.enum??[]).map((t)=>O(t)).join(" | ")}`;case"const":return`the constant ${O(e.const)}`;case"one-of":return(e.oneOf??[]).map((t)=>bt(t)).join(" or ");case"typed":return gt(Pe(e.type??[]));case"boolean":return"a boolean";case"bounded-number":return`a number from ${e.minimum} to ${e.maximum}`;case"number":return"a finite number";case"integer":return"an integer";case"string":return"a non-empty string";case"path":return"a document path";case"path-list":return"a list of document paths";default:return"anything"}}function mn(e,t,n,o){let r=t[n],i=[];for(let s of o){if(s.type!==void 0&&!Pe(s.type).some((a)=>mt(a,r)))continue;try{return yt(e,t,n,s)}catch(a){i.push(a)}}if(i.length===1)throw i[0];throw S(e,n,`expected ${o.map((s)=>bt(s)).join(" or ")}, got ${O(r)}`)}function yt(e,t,n,o){switch(pt(o)){case"enum":return di(e,t,n,o.enum??[]);case"const":{let r=t[n];if(r!==o.const)throw S(e,n,`expected the constant ${O(o.const)}, got ${O(r)}`);return r}case"one-of":return mn(e,t,n,o.oneOf??[]);case"typed":return pn(e,t,n,Pe(o.type??[]));case"boolean":return xi(e,t,n);case"bounded-number":{if(o.type==="integer")dt(e,t,n);return Py(e,t,n,o.minimum,o.maximum)}case"number":return ft(e,t,n);case"integer":return dt(e,t,n);case"string":return rt(e,t,n);case"path":return Gx(e,t,n);case"path-list":return l1(e,t,n);default:return t[n]}}function dR(e,t,n){let o=t,r=o.properties??{},i=Object.keys(r),s=o.required??[],a={};for(let[l,c]of Object.entries(n)){if(c===void 0||Object.hasOwn(r,l))continue;if(o.additionalProperties===!1)throw S(e,l,`not declared — declared: ${i.join(", ")||"none"}`);a[l]=c}for(let l of i){if(n[l]===void 0&&!s.includes(l))continue;a[l]=yt(e,n,l,r[l])}return a}var gn=20,ti="primary",Ap="secondary",f1=2,m=y({activePaneId:ti,clipboard:null,closedTabs:[],componentRegistry:[],mruOrder:[],fileTree:{dirs:new Map,expanded:new Set,searchQuery:"",selectedPath:null},panes:[{activeTabId:null,derived:null,id:ti,tabOrder:[]}],projectConfig:null,projectRoot:null,styleClipboard:null,tabs:new Map,ui:{activityBar:"files"},get activeTabId(){let e=Po();return e.derived?.kind==="lens"?Wn(e.derived.sourcePaneId)?.activeTabId??null:e.activeTabId},get tabOrder(){return Po().tabOrder}}),u=tu(()=>m.activeTabId?m.tabs.get(m.activeTabId)??null:null);function Po(){let{panes:e}=m;return e.find((t)=>t.id===m.activePaneId)??e[0]}function Wn(e){return m.panes.find((t)=>t.id===e)}function ah(e){return m.panes.find((t)=>t.tabOrder.includes(e))}function Mo(e){let t=Wn(e);if(!t||t.id===m.activePaneId)return;m.activePaneId=t.id,A();let{activeTabId:n}=t;if(n){we(n);let o=m.tabs.get(n);if(o)Tt(o)}}function Pp(e){return m.activePaneId===e}function Zx(e){let t=e??Po().activeTabId,n=t?m.tabs.get(t):null;if(!t||!n)return null;let o=ah(t);if(!o)return null;let r=Jl(o.id);return jp(t),lh(r,t),r.activeTabId=t,m.activePaneId=r.id,A(),we(t),r}function Xx(e){return m.panes.find((t)=>t.id!==e)??bn(Ap)}function Jl(e){let t=Xx(e);if(t.derived)t.derived=null;return t}function bn(e){let t=Wn(e);if(t)return t;return m.panes=[...m.panes,{activeTabId:null,derived:null,id:e,tabOrder:[]}],Wn(e)}function Mp(e){if(m.panes.length<2)return;let t=e===ti?m.panes.find((r)=>r.id!==ti)?.id:e,n=t===void 0?void 0:Wn(t),o=m.panes.find((r)=>r.id!==t);if(!n||!o)return;for(let r of n.tabOrder)lh(o,r);if(o.activeTabId=m.activePaneId===n.id?n.activeTabId??o.activeTabId:o.activeTabId??n.activeTabId,m.activePaneId=o.id,o.derived?.sourcePaneId===n.id)o.derived=null;m.panes=m.panes.filter((r)=>r.id!==n.id),A()}function Fp(e){return e.tabOrder.length===0&&e.derived===null}function jp(e){let t=[];for(let n of m.panes){if(!n.tabOrder.includes(e))continue;if(n.tabOrder=n.tabOrder.filter((o)=>o!==e),n.activeTabId===e)n.activeTabId=n.tabOrder.at(-1)??null;if(n.id!==ti&&Fp(n))t.push(n.id)}for(let n of t)Mp(n)}function lh(e,t,n){if(e.tabOrder.includes(t))return;let o=n??xn(e,t);e.tabOrder=[...e.tabOrder.slice(0,o),t,...e.tabOrder.slice(o)]}function yn(e){let t=0;for(let n of e.tabOrder){if(m.tabs.get(n)?.pinned!==!0)break;t+=1}return t}function xn(e,t){return m.tabs.get(t)?.pinned===!0?yn(e):e.tabOrder.length}function nl(e,t=null){if(m.projectRoot&&e!==m.projectRoot)zx();m.projectRoot=e,m.projectConfig=t}function Hp(e){let t=u.value;return e!==null&&t!==null&&oe(t)===oe(e)}function Mc(e){if(!e)return!1;let t=m.tabs.get(e.id);return t!==void 0&&oe(t)===oe(e)}function we(e){m.mruOrder=[e,...m.mruOrder.filter((t)=>t!==e)]}var ne=null,Z=0;function A(){ne=null,Z=0}function Tt(e){if(D&&e.documentPath)D.selectedPath=e.documentPath}function X(e,t={}){let n=m.tabs.get(e),o=ah(e);if(!n||!o)return;if(o.activeTabId=e,t.focus===!1)return;if(m.activePaneId=o.id,!t.cycling)A(),we(e);Tt(n)}function Mr(e){let t=m.tabs.get(e.id),n=e.preview===!0&&t?.pinned!==!0,o=Ey({...e,preview:n}),r=(e.paneId===void 0?void 0:Wn(e.paneId))??Po(),i;if(t)o.pinned=t.pinned,Ip(t);else{if(n){let a=xt(r),l=a?m.tabs.get(a):null;if(l)qd(l);Qx()}let s=n?xt(r):null;if(s)i=r.tabOrder.indexOf(s),e_(s);lh(r,o.id,i)}return m.tabs.set(o.id,o),X(o.id,{focus:e.focus!==!1}),Y(o),o}function xt(e){return e.tabOrder.find((t)=>m.tabs.get(t)?.preview===!0)??null}function Yl(e){let t=m.tabs.get(e);if(t?.preview===!0)t.preview=!1}function Qx(){for(let[e,t]of m.tabs)if(t.preview&&t.doc.dirty)Yl(e)}function By(e,t){let n=m.tabs.get(e),o=ah(e);if(!n||!o)return;if(n.pinned=t,t)n.preview=!1;let r=o.tabOrder.filter((s)=>s!==e),i=r.filter((s)=>m.tabs.get(s)?.pinned===!0).length;o.tabOrder=[...r.slice(0,i),e,...r.slice(i)]}function m1(e,t){let n=m.tabs.get(e),o=ah(e);if(!n||!o)return;o.tabOrder=Pt(o,e,t)}function Pt(e,t,n){let o=m.tabs.get(t);if(!o)return e.tabOrder;let r=e.tabOrder.filter((c)=>c!==t),i=r.filter((c)=>m.tabs.get(c)?.pinned===!0).length,s=o.pinned?0:i,a=o.pinned?i:r.length,l=Math.min(Math.max(n,s),a);return[...r.slice(0,l),t,...r.slice(l)]}function e_(e){let t=m.tabs.get(e);if(!t)return;let n=ah(e),o=n?.activeTabId===e;if(vn(t),Ip(t),m.tabs.delete(e),Sy(e),jp(e),m.mruOrder=m.mruOrder.filter((s)=>s!==e),A(),n&&Fp(n))Mp(n.id);if(!o)return;let r=Po(),i=m.mruOrder.find((s)=>r.tabOrder.includes(s))??r.tabOrder.at(-1)??null;if(i)X(i)}function g1(){let e=[...m.tabs.values()];m.tabs.clear(),Ot(),m.mruOrder=[],A();for(let t of e)Ip(t)}function Ot(){m.panes=[{activeTabId:null,derived:null,id:ti,tabOrder:[]}],m.activePaneId=ti}function vn(e){if(!e.documentPath)return;let t=e.documentPath;m.closedTabs=[{documentPath:t},...m.closedTabs.filter((n)=>n.documentPath!==t)].slice(0,gn)}function Tn(){let[e]=m.closedTabs;if(!e)return;return m.closedTabs=m.closedTabs.slice(1),e.documentPath}function vt(e){if(!ne)ne=m.mruOrder.filter((o)=>m.tabs.has(o)),Z=0;let t=ne;if(t.length<2)return;Z=((Z+e)%t.length+t.length)%t.length;let n=t[Z];return X(n,{cycling:!0}),n}function b1(e){let t=[...m.tabs.keys()],n=[...m.tabs.values()],o=Ey(e);m.tabs.set(o.id,o),Ot(),m.panes[0].tabOrder=[o.id],m.mruOrder=[],A(),X(o.id),Y(o);for(let r of t){if(r===o.id)continue;m.tabs.delete(r)}for(let r of n)Ip(r);return o}function ui(e,t={}){X(e,t)}function Fm(e,t,n){let o=Wn(t);if(!o||!m.tabs.has(e))return null;if(o.tabOrder.includes(e)){if(n!==void 0)o.tabOrder=Pt(o,e,n);return o}return jp(e),lh(o,e,n),o}function Wy(e,t,n){let o=m.tabs.get(e);if(!o)return;if(o.id=t,o.documentPath=n,Wx(e))Sy(e),$p(t);m.tabs.delete(e),m.tabs.set(t,o);for(let r of m.panes)if(r.tabOrder=r.tabOrder.map((i)=>i===e?t:i),r.activeTabId===e)r.activeTabId=t;m.mruOrder=m.mruOrder.map((r)=>r===e?t:r),A(),ut(o)}function y1(e,t){e.registerAll([...Pn(t),...On(t)])}function Pn(e){let t=()=>m.tabs.size>1;return[{id:"document.nextTab",title:"Next Tab",category:"Document",level:"document",keybinding:["ctrl+tab","mod+tab"],menus:["palette"],group:"2_navigate",when:(n)=>n.document.open,enablement:t,requires:"a second open document",run:()=>{vt(1)}},{id:"document.previousTab",title:"Previous Tab",category:"Document",level:"document",keybinding:["ctrl+shift+tab","mod+shift+tab"],menus:["palette"],group:"2_navigate",when:(n)=>n.document.open,enablement:t,requires:"a second open document",run:()=>{vt(-1)}},{args:ke({path:He('Project-relative path of the file to open, e.g. "pages/about.json" or "components/nav-bar.json". It must exist.')}),id:"document.open",title:"Open Document",category:"Document",level:"project",menus:["palette"],group:"1_file",when:(n)=>n.project.open,requires:"an open project",aiTool:{description:"Open a project file as the active document; the document tools then operate on it. Use it when the user should SEE the page, or for iterative visual refinement after creating a page or component.",name:"open_document",report:({after:n,args:o})=>{let r=rt("document.open",o,"path"),i=u.value?.documentPath??null;if(i!==r)return`Opened "${r}", but the active document is ${i===null?"none":`"${i}"`}.`;let s=n.editor.kind==="canvas"?"on the canvas; the document tools now operate on it":`in the ${wy[n.editor.kind]} editor, which is not an element tree the document tools can edit`;return`"${r}" is the active document, ${s}.`}},run:async(n,o)=>{let r=rt("document.open",o,"path");if(await e.openFile(r),![...m.tabs.values()].some((i)=>i.documentPath===r))throw RangeError(`command "document.open" argument "path": "${r}" could not be opened — it does `+"not exist, or no editor claims its format. Problems has the reason.")}},{args:ke({file:He('Project-relative path of the file to open in the other pane, e.g. "pages/about.json". It must exist.')}),id:"document.openToSide",title:"Open to the Side",category:"Document",level:"project",menus:["context/file","palette"],group:"1_file",when:(n)=>n.project.open,requires:"an open project",undo:"none",run:async(n,o)=>{let r=rt("document.openToSide",o,"file"),i=Jl(Po().id);if(await e.openFile(r,{paneId:i.id}),![...m.tabs.values()].some((s)=>s.documentPath===r)){if(Fp(i)&&i.id!==ti)Mp(i.id);throw RangeError(`command "document.openToSide" argument "file": "${r}" could not be opened — it `+"does not exist, or no editor claims its format. Problems has the reason.")}}},{id:"document.reopenClosed",title:"Reopen Closed Document",category:"Document",level:"document",keybinding:"mod+shift+t",menus:["context/tab","palette"],group:"1_file",enablement:()=>m.closedTabs.length>0,requires:"a document closed in this session",run:async()=>{let n=Tn();if(n)await e.openFile(n)}},{id:"document.togglePinned",title:"Pin / Unpin Document",category:"Document",level:"document",menus:["context/tab","palette"],group:"1_file",when:(n)=>n.document.open,requires:"an open document",run:()=>{let n=m.activeTabId,o=n?m.tabs.get(n):null;if(n&&o)By(n,!o.pinned)}},{args:ke({pinned:sr("True to pin the active document's tab, false to unpin it.")}),id:"document.setPinned",title:"Set Document Pinned",category:"Document",level:"document",menus:["palette"],group:"1_file",when:(n)=>n.document.open,requires:"an open document",run:(n,o)=>{let r=m.activeTabId;if(r&&m.tabs.get(r))By(r,xi("document.setPinned",o,"pinned"))}},{id:"document.keepOpen",title:"Keep Document Open",category:"Document",level:"document",menus:["context/tab","palette"],group:"1_file",when:(n)=>n.document.open,enablement:()=>{let n=m.activeTabId;return n!==null&&m.tabs.get(n)?.preview===!0},requires:"a preview document — one opened by a single click",run:()=>{let n=m.activeTabId;if(n)Yl(n)}}]}function On(e){let t=()=>m.panes.length>1;return[{id:"pane.splitRight",title:"Split Right",category:"View",level:"document",keybinding:"mod+\\",menus:["context/pane","context/tab","palette"],group:"5_pane",when:(n)=>n.document.open,enablement:()=>m.activeTabId!==null,requires:"an open document",undo:"none",run:()=>{Zx()}},{args:ke({path:He("Project-relative path of the document to open beside this one.")}),id:"pane.compareWith",title:"Compare With…",category:"View",level:"document",menus:["context/pane","context/tab","palette"],group:"5_pane",when:(n)=>n.document.open,enablement:()=>m.activeTabId!==null,requires:"an open document",undo:"none",run:async(n,o)=>{let r=rt("pane.compareWith",o,"path"),i=Po();if((i.activeTabId?m.tabs.get(i.activeTabId):null)?.documentPath===r)throw RangeError(`command "pane.compareWith" argument "path": "${r}" is the document this pane is `+"already showing — name a different one");await e.openFileInPane(Jl(i.id).id,r)}},{id:"pane.focusPrimary",title:"Focus Primary Pane",category:"View",level:"document",keybinding:"mod+0",menus:["palette"],group:"5_pane",enablement:t,requires:"a split pane grid",undo:"none",run:()=>{Mo(ti)}},{id:"pane.focusSecondary",title:"Focus Side Pane",category:"View",level:"document",keybinding:"mod+alt+0",menus:["palette"],group:"5_pane",enablement:t,requires:"a split pane grid",undo:"none",run:()=>{Mo(Ap)}},{id:"pane.unsplit",title:"Close Side Pane",category:"View",level:"document",menus:["context/pane","palette"],group:"5_pane",enablement:t,requires:"a second pane",undo:"none",run:wn}]}function wn(){let e=m.panes.find((t)=>t.derived!==null);if(e?.id===ti){if(e.derived=null,!Fp(e))return}Mp(e?.id??Ap)}
2
+ export{Hx,Yr,vy,NL,hn,Or,nh,OL,r1,ih,wy,_a,AL,xy,Vd,_y,Dm,Bx,PL,$p,Sy,Wx,Nm,zi,Yi,Cy,zd,ky,ML,o1,FL,jL,HL,Vx,BL,zx,WL,ci,Ey,s1,VL,zL,Ip,Le,UL,Ty,xs,Ly,qL,ql,Ry,GL,Dp,KL,wi,q,qs,$y,Iy,Ux,JL,Om,YL,ZL,qx,XL,Zi,rh,a1,Np,Dy,QL,Sa,Ue,Pc,Zr,eR,Ny,tR,Oy,nR,iR,Gs,Ay,wo,rR,oh,oR,sR,aR,Gl,Sn,Am,rt,Xr,Py,xi,di,Gx,lR,l1,ke,Ar,Ca,c1,sr,My,cR,He,dR,Kx,Op,Jx,Kl,Fy,jy,Yx,uR,ka,Ud,sh,Pm,Hy,hR,Pr,pR,fR,mR,gR,Mm,d1,u1,h1,p1,ti,Ap,f1,m,u,Po,Wn,ah,Mo,Pp,Zx,Xx,Jl,Mp,Fp,jp,lh,nl,Hp,Mc,Mr,Yl,Qx,By,m1,e_,g1,b1,ui,Fm,Wy,y1};
3
+
4
+ //# debugId=DCD89E7A8740D2F764756E2164756E21
5
+ //# sourceMappingURL=studio-a2ke1e4t.js.map
@@ -0,0 +1,4 @@
1
+ import{Zg,Bs,sw,Zo,aw,ps}from"./studio-j03zga3y.js";var Sk="meta",Ck="frontmatter",kk="structure",Ek="source",Tk=2;function cd(t){return t.getMap(Sk)}function Lk(t){return t.getMap(Ck)}function jf(t){return t.getMap(kk)}function Rk(t){return t.getText(Ek)}function f(t){return JSON.parse(JSON.stringify(t))}function h(t){return typeof t==="object"&&t!==null&&!Array.isArray(t)}var y=new Set(["textContent"]),m=new Set(["style","attributes","$props"]);function g(t,e){let n=t.toString();if(n===e)return!1;let r=0,o=Math.min(n.length,e.length);while(r<o&&n[r]===e[r])r+=1;let i=n.length,a=e.length;while(i>r&&a>r&&n[i-1]===e[a-1])i-=1,a-=1;if(i>r)t.delete(r,i-r);if(a>r)t.insert(r,e.slice(r,a));return!0}function l(t){let e=new Zo;for(let[n,r]of Object.entries(t)){if(r===void 0)continue;e.set(n,h(r)?l(r):f(r))}return e}function Y(t,e){for(let n of[...t.keys()])if(!(n in e)||e[n]===void 0)t.delete(n);for(let[n,r]of Object.entries(e)){if(r===void 0)continue;let o=t.get(n);if(h(r))if(o instanceof Zo)Y(o,r);else t.set(n,l(r));else if(!b(o,r))t.set(n,f(r))}}function b(t,e){if(t===e)return!0;if(t instanceof Zo||t instanceof Bs||t instanceof ps)return!1;return JSON.stringify(t??null)===JSON.stringify(e??null)}function p(t){return typeof t==="string"?new ps(t):$k(t)}function ip(t){let e=new Bs;return e.insert(0,t.map((n)=>p(n))),e}function $k(t){if(!h(t))throw TypeError("collab-schema: a document node must be a plain object");let e=new Zo;for(let[n,r]of Object.entries(t)){if(r===void 0)continue;if(n==="children"&&Array.isArray(r))e.set(n,ip(r));else if(y.has(n)&&typeof r==="string")e.set(n,new ps(r));else if(m.has(n)&&h(r))e.set(n,l(r));else e.set(n,f(r))}return e}function dd(t){if(t instanceof Zo){let e={};for(let[n,r]of t.entries())e[n]=dd(r);return e}if(t instanceof Bs)return t.toArray().map((e)=>dd(e));if(t instanceof ps)return t.toString();return t}function eI(t){return dd(jf(t))}function rw(t,e){let n=jf(t);for(let r of e)if(n instanceof Zo)n=n.get(String(r));else if(n instanceof Bs){let o=typeof r==="number"?r:Number(r);if(!Number.isInteger(o)||o<0||o>=n.length)return;n=n.get(o)}else return;return n}function I0(t,e,n){let r=Rk(t);if(r.toString()===e)return!1;return t.transact(()=>{g(r,e)},n),!0}function tI(t,e,n={}){let r=cd(t);if(r.get("structureSeeded")===!0)return!1;return t.transact(()=>{let o=jf(t);for(let[a,s]of Object.entries(e)){if(s===void 0)continue;if(a==="children"&&Array.isArray(s))o.set(a,ip(s));else o.set(a,f(s))}let i=Lk(t);for(let[a,s]of Object.entries(n.frontmatter??{}))if(s!==void 0)i.set(a,f(s));r.set("schemaVersion",Tk),r.set("canonical","structure"),r.set("canonicalRev",0),r.set("sourceFormat",n.sourceFormat??null),r.set("structureSeeded",!0)},n.origin),!0}var nI="jx-local",iI="jx-mirror",rI="jx-seed";class ud extends Error{constructor(t){super(`collab-path-unresolved:${t.join("/")}`);this.name="CollabPathError"}}function w(t,e){let n=rw(t,e);if(!(n instanceof Zo))throw new ud(e);return n}function d(t,e,n){let r=w(t,e),o=r.get("children");if(o instanceof Bs)return o;if(n&&o===void 0){let i=new Bs;return r.set("children",i),i}throw new ud([...e,"children"])}function R(t){return JSON.parse(JSON.stringify(t))}function P(t){return typeof t==="object"&&t!==null&&!Array.isArray(t)}function M(t,e,n){let r=t.get(e);if(e==="children"&&Array.isArray(n)){t.set(e,ip(n));return}if(y.has(e)&&typeof n==="string"){if(r instanceof ps)g(r,n);else t.set(e,new ps(n));return}if(m.has(e)&&P(n)){if(r instanceof Zo)Y(r,n);else t.set(e,l(n));return}t.set(e,R(n))}function D(t,e){switch(e.op){case"set-key":{let n=w(t,e.path);if(e.value===void 0)n.delete(e.key);else M(n,e.key,e.value);return}case"insert-child":{let n=d(t,e.parentPath,!0);if(e.index<0||e.index>n.length)throw new ud([...e.parentPath,"children",e.index]);n.insert(e.index,[p(e.node)]);return}case"remove-child":{let n=d(t,e.parentPath,!1);if(e.index<0||e.index>=n.length)throw new ud([...e.parentPath,"children",e.index]);n.delete(e.index,1);return}case"set-child":{let n=d(t,e.parentPath,!1);if(e.index<0||e.index>=n.length)throw new ud([...e.parentPath,"children",e.index]);let r=n.get(e.index);if(r instanceof ps&&typeof e.node==="string"){g(r,e.node);return}n.delete(e.index,1),n.insert(e.index,[p(e.node)]);return}case"move-child":{let n=d(t,e.fromParentPath,!1),r=d(t,e.toParentPath,!0);if(e.fromIndex<0||e.fromIndex>=n.length)throw new ud([...e.fromParentPath,"children",e.fromIndex]);let o=dd(n.get(e.fromIndex));if(n.delete(e.fromIndex,1),e.toIndex<0||e.toIndex>r.length)throw new ud([...e.toParentPath,"children",e.toIndex]);r.insert(e.toIndex,[p(o)]);return}default:throw Error(`unknown-doc-op:${e.op}`)}}function oI(t,e,n){t.transact(()=>{for(let r of e)D(t,r)},n)}function C(t){for(let e=0;e<t.length;e++){let n=t[e];if(typeof n!=="string")continue;if(m.has(n))return{key:n,nodePath:t.slice(0,e)};if(y.has(n))return{key:n,nodePath:t.slice(0,e)}}return null}function J(t){return t.every((e)=>typeof e==="string"||typeof e==="number")}function sI(t){if(t.length===0)return[];let e=t.map((o)=>o.path);if(!e.every((o)=>J(o)))return null;for(let o=0;o<e.length;o++)for(let i=0;i<e.length;i++){if(o===i)continue;let a=e[o],s=e[i];if(a.length<=s.length&&a.every((c,u)=>c===s[u]))return null}if(t.filter((o)=>o instanceof Zg).length>1)return null;let r=[];for(let o of t){let i=o.path,a=C(i);if(a){let{doc:s}=o.target;if(!s)return null;let c=rw(s,[...a.nodePath,a.key]);if(c===void 0)return null;r.push({key:a.key,op:"set-key",path:a.nodePath,value:dd(c)});continue}if(o instanceof aw){let s=i.at(-1);if(i.at(-2)==="children"&&typeof s==="number"){r.push({index:s,node:o.target.toString(),op:"set-child",parentPath:i.slice(0,-2)});continue}return null}if(o instanceof sw){let s=o.target;for(let[c,u]of o.changes.keys)if(u.action==="delete")r.push({key:c,op:"set-key",path:i});else r.push({key:c,op:"set-key",path:i,value:dd(s.get(c))})}else if(o instanceof Zg){if(i.at(-1)!=="children")return null;let s=i.slice(0,-1),c=0;for(let u of o.changes.delta)if(u.retain!==void 0)c+=u.retain;else if(u.delete!==void 0)for(let x=0;x<u.delete;x++)r.push({index:c,op:"remove-child",parentPath:s});else if(u.insert!==void 0){let x=Array.isArray(u.insert)?u.insert:[u.insert];for(let O of x)r.push({index:c,node:dd(O),op:"insert-child",parentPath:s}),c+=1}}else return null}return r}function aI(t,e,n){t.transact(()=>{let r=jf(t),o=e,i=[...r.keys()];for(let s of i)if(!(s in o)||o[s]===void 0)r.delete(s);for(let[s,c]of Object.entries(o)){if(c===void 0)continue;if(s==="children"&&Array.isArray(c))r.set(s,ip(c));else r.set(s,JSON.parse(JSON.stringify(c)))}let a=cd(t);a.set("canonicalRev",Number(a.get("canonicalRev")??0)+1)},n)}function D0(t){return cd(t).get("canonical")==="source"?"source":"structure"}function N0(t){return Number(cd(t).get("canonicalRev")??0)}function lI(t,e,n){if(D0(t)==="source")return!1;return t.transact(()=>{I0(t,e,n);let r=cd(t);r.set("canonical","source"),r.set("canonicalRev",N0(t)+1)},n),!0}function cI(t,e){if(D0(t)!=="source")return!1;return t.transact(()=>{let n=cd(t);n.set("canonical","structure"),n.set("canonicalRev",N0(t)+1)},e),!0}function dI(t,e,n){let r=[];for(let[o,i]of t.getStates()){let a=i;if(o!==n&&a.mode==="source"&&a.focusedPath===e)r.push(o)}return r}function uI(t,e){let n=t.clientID,r=t.getStates().get(n);if(r?.mode!=="source"||r.focusedPath!==e)return!1;let o=n;for(let[i,a]of t.getStates()){let s=a;if(s.mode==="source"&&s.focusedPath===e&&s.canWrite!==!1&&i<o)o=i}return o===n}var O0=["#4f9cf9","#e5484d","#30a46c","#f5a524","#8e4ec6","#00a2c7","#e93d82","#a8845c"];function hI(t){let e=5381;for(let r=0;r<t.length;r++)e=Math.imul(e,33)+(t.codePointAt(r)??0);let n=Math.abs(e)%O0.length;return O0[n]}export{Sk,Ck,kk,Ek,Tk,cd,Lk,jf,Rk,ip,$k,dd,eI,rw,I0,tI,nI,iI,rI,ud,oI,sI,aI,D0,N0,lI,cI,dI,uI,O0,hI};
2
+
3
+ //# debugId=6B6C2B6C7738377E64756E2164756E21
4
+ //# sourceMappingURL=studio-e3a2a6v3.js.map
@@ -1,5 +1,5 @@
1
- import{p}from"./studio-y7jehjrp.js";import{D}from"./studio-tp642n5g.js";function u(n,r=[]){if(!n||typeof n!=="object"||Array.isArray(n))return r;let t=n;if(t.tagName==="slot"){let o=t.attributes?.name,l=typeof o==="string"?o.trim():"",{children:a}=t;r.push({name:l,...Array.isArray(a)&&a.length>0?{fallback:a}:{}})}if(Array.isArray(t.children))for(let e of t.children)u(e,r);return r}function m(n){if(n==null)return!1;if(typeof n!=="object")return!0;let r=n;return!r.$prototype&&!r.$handler&&!r.$compute}function Cx(n,r){if(!n||typeof n!=="object"||Array.isArray(n))return null;let t=n,{tagName:e}=t;if(typeof e!=="string"||!e.includes("-"))return null;let o=u(t),l=t.state??{};return{$id:typeof t.$id==="string"&&t.$id?t.$id:null,hasElements:Array.isArray(t.$elements)&&t.$elements.length>0,path:r,props:Object.entries(l).filter(([,a])=>m(a)).map(([a,s])=>{if(typeof s!=="object"||s===null)return{default:s,name:a,type:typeof s};let i=s;return{default:i.default,format:i.format,name:a,type:i.type}}),...o.length>0?{slots:o}:{},tagName:e}}var st=[],c=!1;async function Dl(){try{st=await p().discoverComponents(D?.projectRoot||void 0),c=!0}catch{c=!0}}function MC(n,r){if(!n)return!1;let t=st.findIndex((l)=>l.path===n),e=Cx(r,n);if(!e){if(t===-1)return!1;return st.splice(t,1),!0}let o=e;if(t===-1)st.push(o);else st[t]=o;return!0}function um(n){let r=Object.fromEntries((n.props??[]).map((e)=>[e.name,e.default!==void 0?e.default:""])),t=[];for(let e of n.slots??[])for(let o of structuredClone(e.fallback??[]))if(!e.name)t.push(o);else if(typeof o==="object"&&o!==null&&typeof o.tagName==="string")o.attributes={slot:e.name,...o.attributes},t.push(o);else t.push({attributes:{slot:e.name},children:[o],tagName:"span"});return{$props:r,tagName:n.tagName,...t.length>0?{children:t}:{}}}function xc(n,r){if(!n)return`./${r}`;let t=n.replaceAll("\\","/"),e=r.replaceAll("\\","/"),l=(t.includes("/")?t.slice(0,t.lastIndexOf("/")):"").split("/").filter(Boolean),a=e.split("/").filter(Boolean),s=0;while(s<l.length&&s<a.length&&l[s]===a[s])s+=1;let i=l.length-s,f=a.slice(s);return(i>0?"../".repeat(i):"./")+f.join("/")}
2
- export{Cx,st,Dl,MC,um,xc};
1
+ import{p}from"./studio-xz2yxfcb.js";import{D}from"./studio-yn9f8vtx.js";function u(n,r=[]){if(!n||typeof n!=="object"||Array.isArray(n))return r;let t=n;if(t.tagName==="slot"){let o=t.attributes?.name,l=typeof o==="string"?o.trim():"",{children:a}=t;r.push({name:l,...Array.isArray(a)&&a.length>0?{fallback:a}:{}})}if(Array.isArray(t.children))for(let e of t.children)u(e,r);return r}function m(n){if(n==null)return!1;if(typeof n!=="object")return!0;let r=n;return!r.$prototype&&!r.$handler&&!r.$compute}function Fx(n,r){if(!n||typeof n!=="object"||Array.isArray(n))return null;let t=n,{tagName:e}=t;if(typeof e!=="string"||!e.includes("-"))return null;let o=u(t),l=t.state??{};return{$id:typeof t.$id==="string"&&t.$id?t.$id:null,hasElements:Array.isArray(t.$elements)&&t.$elements.length>0,path:r,props:Object.entries(l).filter(([,a])=>m(a)).map(([a,s])=>{if(typeof s!=="object"||s===null)return{default:s,name:a,type:typeof s};let i=s;return{default:i.default,format:i.format,name:a,type:i.type}}),...o.length>0?{slots:o}:{},tagName:e}}var st=[],c=!1;async function zl(){try{st=await p().discoverComponents(D?.projectRoot||void 0),c=!0}catch{c=!0}}function QC(n,r){if(!n)return!1;let t=st.findIndex((l)=>l.path===n),e=Fx(r,n);if(!e){if(t===-1)return!1;return st.splice(t,1),!0}let o=e;if(t===-1)st.push(o);else st[t]=o;return!0}function Em(n){let r=Object.fromEntries((n.props??[]).map((e)=>[e.name,e.default!==void 0?e.default:""])),t=[];for(let e of n.slots??[])for(let o of structuredClone(e.fallback??[]))if(!e.name)t.push(o);else if(typeof o==="object"&&o!==null&&typeof o.tagName==="string")o.attributes={slot:e.name,...o.attributes},t.push(o);else t.push({attributes:{slot:e.name},children:[o],tagName:"span"});return{$props:r,tagName:n.tagName,...t.length>0?{children:t}:{}}}function Nc(n,r){if(!n)return`./${r}`;let t=n.replaceAll("\\","/"),e=r.replaceAll("\\","/"),l=(t.includes("/")?t.slice(0,t.lastIndexOf("/")):"").split("/").filter(Boolean),a=e.split("/").filter(Boolean),s=0;while(s<l.length&&s<a.length&&l[s]===a[s])s+=1;let i=l.length-s,f=a.slice(s);return(i>0?"../".repeat(i):"./")+f.join("/")}
2
+ export{Fx,st,zl,QC,Em,Nc};
3
3
 
4
- //# debugId=77DA259515EEB11764756E2164756E21
5
- //# sourceMappingURL=studio-pwqfmt4p.js.map
4
+ //# debugId=D183A483CB062D9164756E2164756E21
5
+ //# sourceMappingURL=studio-e81q1vb9.js.map
@@ -1,5 +1,5 @@
1
- import{re,k}from"./studio-fqq890ap.js";var Je={functionEditor:null,blockActionBarEl:null,selDragCleanup:null,dndCleanups:[],elementsCollapsed:new Set,elementsFilter:"",_currentDropTargetRow:null,layerDragSourceHeight:0,_completionRegistered:!1,_layersCollapsed:null};var m=0;function eI(){return m+=1,m}var l=new Map;function Yi(e){let n=l.get(e);if(!n)n=g(e),l.set(e,n);return n}function g(e){return{centerObserver:null,monacoDiffEditor:null,monacoEditor:null,needsCenter:!0,panX:0,panY:0,panels:[],paneId:e,panzoomWrap:null,stage:null,prevCanvasMode:null,prevStylebookCustomizedOnly:null,prevStylebookFilter:null,renderGeneration:0,sourceCollabCleanup:null,stageScrollbar:null,wrap:null}}function Ju(){return[...l.values()]}function jl(e){if(!e)return null;for(let n of l.values())if(n.wrap?.contains(e))return n;return null}function v(e){for(let n of e.panels)n.renderScope?.stop(),n.renderScope=null;e.panels.length=0,e.prevCanvasMode=null}function tI(e,n){let r=Yi(e);return r.wrap=n,v(r),r}function nI(e){if(l.get(e))nk(e);let r=g(e);return l.set(e,r),r}var S=null;function iI(e){S=e}function nk(e){let n=l.get(e);if(!n)return;S?.(n),v(n),h(e)}function h(e){l.delete(e)}var Yu="commit";function km(e){let n=new Map,r=new Map,o=new Map,a=!1,u=!1,c=!1;function f(t,i){if(typeof i?.then!=="function")return i;let s=i.finally(()=>{if(o.get(t)===s)o.delete(t)});return o.set(t,s),s}let d={arm(t,i,s){clearTimeout(n.get(t)),r.set(t,s),n.set(t,setTimeout(()=>{n.delete(t),r.delete(t),f(t,s())},i))},cancel(){for(let t of n.values())clearTimeout(t);n.clear(),r.clear()},flush(t){let i=r.get(t);if(!i)return o.get(t);return clearTimeout(n.get(t)),n.delete(t),r.delete(t),f(t,i())},ahead:()=>a,markAhead(){a=!0},typed:()=>u,markTyped(){a=!0,u=!0},markSettled(){a=!1,u=!1},shared:()=>c,markShared(){c=!0}};return e._writes=d,d}var w={logic:{holds:"The handler you were typing",reached:"written into",source:"Logic"},source:{holds:"The source you were typing",reached:"parsed into",source:"Editor"}};function p(e,n,r){if(e._writes?.typed()!==!0)return!0;let a=e._editingTab??null,u=a?.documentPath??"Untitled",{holds:c,reached:f,source:d}=w[n];return k.warn(`${c} was discarded — it was never ${f} "${u}".`,{...r?{detail:C(r.error)}:{},key:`buffer-discarded:${n}:${a?.id??"none"}`,source:d,...a?.documentPath?{path:a.documentPath}:{}}),!1}function C(e){return e instanceof Error?e.stack??e.message:String(e)}function Sm(e,n){let r=e?._writes;if(!e||!r)return!0;let o;try{o=r.flush(Yu)}catch(a){return r.cancel(),p(e,n,{error:a})}if(r.cancel(),typeof o?.then==="function")return o.then(()=>p(e,n,null),(a)=>p(e,n,{error:a})),!0;return p(e,n,null)}function ik(e){e?._writes?.cancel()}function Ec(e){return Boolean(e?.getModel())}function Zu(e,n){if(!Ec(e)||e.hasTextFocus()||e._writes?.ahead()||e._writes?.shared())return!0;return n!==void 0&&e.getValue()!==n}function b(e){let n=re(e);return[...Ju().map((o)=>o.monacoEditor),Je.functionEditor].filter((o)=>o!=null&&o._editingTab!=null&&re(o._editingTab)===n&&Ec(o))}async function kp(e){for(let n of b(e)){if(!Ec(n))continue;try{await n._writes?.flush(Yu)}catch(r){k.error(`Could not save the editor's contents into "${e.documentPath??"Untitled"}".`,{detail:r instanceof Error?r.stack??r.message:String(r),key:`buffer-commit:${e.id}`,source:"Editor",...e.documentPath?{path:e.documentPath}:{}})}}}function Em(e){return b(e).some((n)=>n._writes?.typed()===!0)}
2
- export{Je,eI,Yi,Ju,jl,tI,nI,iI,nk,Yu,km,Sm,ik,Ec,Zu,kp,Em};
1
+ import{oe,C}from"./studio-55h4mstj.js";var Je={functionEditor:null,blockActionBarEl:null,selDragCleanup:null,dndCleanups:[],elementsCollapsed:new Set,elementsFilter:"",_currentDropTargetRow:null,layerDragSourceHeight:0,_completionRegistered:!1,_layersCollapsed:null};var m=0;function bR(){return m+=1,m}var l=new Map;function Xi(e){let n=l.get(e);if(!n)n=g(e),l.set(e,n);return n}function g(e){return{centerObserver:null,monacoDiffEditor:null,monacoEditor:null,needsCenter:!0,panX:0,panY:0,panels:[],paneId:e,panzoomWrap:null,stage:null,prevCanvasMode:null,prevStylebookCustomizedOnly:null,prevStylebookFilter:null,renderGeneration:0,sourceCollabCleanup:null,stageScrollbar:null,wrap:null}}function ch(){return[...l.values()]}function Zl(e){if(!e)return null;for(let n of l.values())if(n.wrap?.contains(e))return n;return null}function v(e){for(let n of e.panels)n.renderScope?.stop(),n.renderScope=null;e.panels.length=0,e.prevCanvasMode=null}function yR(e,n){let r=Xi(e);return r.wrap=n,v(r),r}function vR(e){if(l.get(e))v1(e);let r=g(e);return l.set(e,r),r}var S=null;function wR(e){S=e}function v1(e){let n=l.get(e);if(!n)return;S?.(n),v(n),h(e)}function h(e){l.delete(e)}var dh="commit";function jm(e){let n=new Map,r=new Map,o=new Map,a=!1,u=!1,c=!1;function f(t,i){if(typeof i?.then!=="function")return i;let s=i.finally(()=>{if(o.get(t)===s)o.delete(t)});return o.set(t,s),s}let d={arm(t,i,s){clearTimeout(n.get(t)),r.set(t,s),n.set(t,setTimeout(()=>{n.delete(t),r.delete(t),f(t,s())},i))},cancel(){for(let t of n.values())clearTimeout(t);n.clear(),r.clear()},flush(t){let i=r.get(t);if(!i)return o.get(t);return clearTimeout(n.get(t)),n.delete(t),r.delete(t),f(t,i())},ahead:()=>a,markAhead(){a=!0},typed:()=>u,markTyped(){a=!0,u=!0},markSettled(){a=!1,u=!1},shared:()=>c,markShared(){c=!0}};return e._writes=d,d}var w={logic:{holds:"The handler you were typing",reached:"written into",source:"Logic"},source:{holds:"The source you were typing",reached:"parsed into",source:"Editor"}};function p(e,n,r){if(e._writes?.typed()!==!0)return!0;let a=e._editingTab??null,u=a?.documentPath??"Untitled",{holds:c,reached:f,source:d}=w[n];return C.warn(`${c} was discarded — it was never ${f} "${u}".`,{...r?{detail:y(r.error)}:{},key:`buffer-discarded:${n}:${a?.id??"none"}`,source:d,...a?.documentPath?{path:a.documentPath}:{}}),!1}function y(e){return e instanceof Error?e.stack??e.message:String(e)}function Hm(e,n){let r=e?._writes;if(!e||!r)return!0;let o;try{o=r.flush(dh)}catch(a){return r.cancel(),p(e,n,{error:a})}if(r.cancel(),typeof o?.then==="function")return o.then(()=>p(e,n,null),(a)=>p(e,n,{error:a})),!0;return p(e,n,null)}function w1(e){e?._writes?.cancel()}function Fc(e){return Boolean(e?.getModel())}function uh(e,n){if(!Fc(e)||e.hasTextFocus()||e._writes?.ahead()||e._writes?.shared())return!0;return n!==void 0&&e.getValue()!==n}function b(e){let n=oe(e);return[...ch().map((o)=>o.monacoEditor),Je.functionEditor].filter((o)=>o!=null&&o._editingTab!=null&&oe(o._editingTab)===n&&Fc(o))}async function qd(e){for(let n of b(e)){if(!Fc(n))continue;try{await n._writes?.flush(dh)}catch(r){C.error(`Could not save the editor's contents into "${e.documentPath??"Untitled"}".`,{detail:r instanceof Error?r.stack??r.message:String(r),key:`buffer-commit:${e.id}`,source:"Editor",...e.documentPath?{path:e.documentPath}:{}})}}}function Bp(e){return b(e).some((n)=>n._writes?.typed()===!0)}
2
+ export{Je,bR,Xi,ch,Zl,yR,vR,wR,v1,dh,jm,Hm,w1,Fc,uh,qd,Bp};
3
3
 
4
- //# debugId=A7D5719267DE823264756E2164756E21
5
- //# sourceMappingURL=studio-7pgy3xaf.js.map
4
+ //# debugId=B84513010BB3364A64756E2164756E21
5
+ //# sourceMappingURL=studio-epgrmqqm.js.map
@@ -0,0 +1,5 @@
1
+ import{AR,i_,pn,an,Zm,HR,ne}from"./studio-9mccjwjh.js";import{tt,Pi}from"./studio-1q1sh2ax.js";import{ge,Q,y,Wc,C,nu}from"./studio-55h4mstj.js";import{te}from"./studio-ery42sqr.js";var A=new Map,B=1;function Y(e){let t=B;return B+=1,A.set(t,{...e,id:t}),t}function k(e){A.delete(e)}function X(){return[...A.values()]}function ER(e){let t=e.toLowerCase();return X().filter((o)=>o.elements.has(t))}function TR(e){return X().filter((t)=>t.name===e)}var H=null;function $1(e=document){return H??=HR({document:e}),H}function Z(){return H??$1()}var ot="data-jx-region",ce=["rail","navigator","inspector","pane","dock.bottom","statusbar","commandbar","overlay"],de=new Set(["dock.bottom"]);function ue(e){let t=e.indexOf("/"),o=t===-1?e:e.slice(0,t),n=t===-1?void 0:e.slice(t+1);if(n===""||o==="")return null;let a=o,i;if(!de.has(o)){let s=o.indexOf(".");if(s!==-1){if(a=o.slice(0,s),i=o.slice(s+1),i==="")return null}}if(!ce.includes(a))return null;return i===void 0?n===void 0?{surface:a}:{part:n,surface:a}:n===void 0?{instance:i,surface:a}:{instance:i,part:n,surface:a}}function fe(e){return ue(e)!==null}function me(e){if(e==="pane")return"pane.primary";return e.startsWith("pane/")?`pane.primary/${e.slice(5)}`:e}function ee(e){return e??document}var pe=[{locate:([,e],t)=>{let n=qp(`inspector/field:${e}`,t)?.querySelector('[part="browse"]');return n?[n]:[]},pattern:/^inspector\/field:(.+)\/browse$/},{locate:([,e],t)=>{let o=qp("inspector",t);return o?[...o.querySelectorAll(`[data-prop="${CSS.escape(e)}"]`)]:[]},pattern:/^inspector\/field:(.+)$/}];function ve(e,t){let o=me(e);if(!fe(o))return[];let n=[...ee(t).querySelectorAll(`[data-jx-region="${CSS.escape(o)}"]`)];if(n.length>0)return n;for(let a of pe){let i=o.match(a.pattern);if(i)return a.locate(i,ee(t))}return[]}function qp(e,t){return ve(e,t).at(-1)??null}var I1={dock:"dock.bottom",inspector:"inspector",navigator:"navigator",pane:"pane.primary",rail:"rail",status:"statusbar"};function Qi(e,t){return t?`pane.${e}/${t}`:`pane.${e}`}function LR(e){return Qi(e,"tabs")}function RR(e){return`navigator/panel:${e}`}function $R(e){return`inspector/tab:${e}`}var IR="navigator/statements";function DR(e){return`inspector/statements:${e}`}function Gy(e){return`dock.bottom/panel:${e}`}var he={dialog:"dialog",modal:"dialog",popover:"menu",toast:"toasts"};function zt(e,t){let o=he[e];return t?`overlay.${o}:${t}`:`overlay.${o}`}var S="jx-studio:/surfaces/",R=new Map;function T(e,t){R.set(e,t),i_(ye(e),t)}function ye(e){return`${S}${e}.json`}function NR(e){return R.get(e)}function be(e){if(!e.startsWith(S)||!e.endsWith(".json"))return;return R.get(e.slice(S.length,-5))}async function I(e,t,o,n={}){let a=R.get(e);if(!a)throw Error(`Studio surface "${e}" is not registered`);if(await Z(),n.region)o.setAttribute(ot,n.region);let i=await AR(a,o,{scope:t,base:S,resolver:be,...n.onNodeCreated?{onNodeCreated:n.onNodeCreated}:{},...n.onNodeMoved?{onNodeMoved:n.onNodeMoved}:{},...n.signal?{signal:n.signal}:{}}),s=(r)=>({dispose:r,elements:i.elements,root:i.root,scope:i.scope});if(n.signal?.aborted)return s(i.dispose);let d=0,l=()=>{i.dispose(),k(d)};return d=Y({elements:i.elements,host:o,name:e,remount:async()=>{l(),await I(e,t,o,n)}}),n.signal?.addEventListener("abort",()=>k(d),{once:!0}),s(l)}var oe={$schema:"https://jxsuite.com/schema/v1",$id:"StudioDialog",$description:"Studio's confirm, save-or-discard and prompt dialogs: one jx-dialog whose body is projected from the adapter's scope. `message` is a sentence; `choice` is a `jx-select` over the options; `field` is the prompt's jx-textfield with its refusal. The four answers call the host's functions, and the host decides when the dialog closes.",tagName:"jx-dialog",$props:{headline:{$ref:"#/state/headline"},confirmLabel:{$ref:"#/state/confirmLabel"},secondaryLabel:{$ref:"#/state/secondaryLabel"},cancelLabel:{$ref:"#/state/cancelLabel"},destructive:{$ref:"#/state/destructive"},size:{$ref:"#/state/size"}},attributes:{headline:"${state.headline}","confirm-label":"${state.confirmLabel || null}","secondary-label":"${state.secondaryLabel || null}","cancel-label":"${state.cancelLabel || null}",part:"dialog-host"},onconfirm:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/confirm"},value:[]}]},onsecondary:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/secondary"},value:[]}]},oncancel:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/cancel"},value:[]}]},onclose:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/closed"},value:[]}]},style:{'& [part="message"]':{$description:"The one part of a dialog that is text rather than interface, so it opts back in to selection. The root sets `user-select: none` and `styles/tokens.json` restates it on every `dialog`, so the headline, the labels and the buttons around this sentence stay unselectable; a message is often the thing a reader copies into a search or a bug report.",margin:"0 0 var(--jx-space-3)",userSelect:"text"},'& [part="message"]:last-child':{margin:"0"},'& [part="island"] > p, & [part="island"] > span, & [part="island"] > strong, & [part="island"] > em, & [part="island"] > code':{$description:"The island's own prose is the message's other form — a body richer than a sentence, written straight into the island from a lit template (studio-ui-guidelines.md §9.4) — so it is selectable for the same reason `[part=\"message\"]` is. The opt-in stops at those children because the island is ALSO the mount point for a whole document: the Open Grid picker and Push Schema's plan put their surfaces here, and `user-select` inherits, so a rule on the island itself would hand selection to every heading, source row and button they draw, which is the interface the policy exists to keep unselectable. A mounted surface roots a `div`; a message writes paragraphs and text-level spans, so the two forms are told apart by the child that arrives.",userSelect:"text"},'& [part="island"]:empty':{display:"none"},'& [part="message-slot"], & [part="choice-slot"], & [part="field-slot"]':{display:"contents"},'& [part="choice-row"]':{display:"flex",flexDirection:"column",gap:"var(--jx-space-1)",margin:"0 0 var(--jx-space-3)"},'& [part="choice-label"]':{fontSize:"var(--jx-text-sm)",color:"var(--jx-fg-dim)"},"& jx-textfield":{width:"100%"}},children:[{tagName:"div",attributes:{part:"message-slot",role:"none"},$switch:{$ref:"#/state/hasMessage"},cases:{true:{tagName:"p",attributes:{part:"message"},textContent:"${state.message}"}}},{tagName:"div",attributes:{part:"island"}},{tagName:"div",attributes:{part:"choice-slot",role:"none"},$switch:{$ref:"#/state/hasChoice"},cases:{true:{tagName:"div",attributes:{part:"choice-row"},children:[{tagName:"span",attributes:{part:"choice-label"},textContent:"${state.choiceLabel}"},{tagName:"jx-select",$props:{label:{$ref:"#/state/choiceLabel"},options:{$ref:"#/state/options"},value:{$ref:"#/state/chosen"}},attributes:{part:"choice"},onchange:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/pick"},value:[{$ref:"event#/target/value"}]}]}}]}}},{tagName:"div",attributes:{part:"field-slot",role:"none"},$switch:{$ref:"#/state/hasField"},cases:{true:{tagName:"jx-textfield",$props:{label:{$ref:"#/state/headline"},value:{$ref:"#/state/value"},placeholder:{$ref:"#/state/placeholder"},invalid:{$ref:"#/state/invalid"},error:{$ref:"#/state/error"},multiline:{$ref:"#/state/multiline"},rows:{$ref:"#/state/rows"},mono:{$ref:"#/state/mono"}},attributes:{part:"field"},oninput:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/input"},value:[{$ref:"event#/target/value"}]}]},onkeydown:{$prototype:"Function",body:[{$switch:{$ref:"#/state/singleLine"},cases:{true:[{$switch:{$ref:"event#/key"},cases:{Enter:[{preventDefault:!0},{operator:"call",target:{$ref:"#/state/confirm"},value:[]}]}}]}}]},$description:"The prompt's one field. `multiline` is what makes it a paste box rather than a line: an import the author copied out of a `_redirects` file is column-aligned, so it also asks for `mono`. A multiline field takes Enter as a newline, which is why the Enter-confirms handler below is guarded on it — a paste box whose second line submits the dialog cannot be typed into."}}}]};T("dialog",oe);function An(e){if(e.querySelector('[part="dialog"]'))return Promise.resolve(e);return new Promise((t)=>{e.addEventListener("jx-ready",function o(n){if(n.target!==e&&!e.querySelector('[part="dialog"]'))return;e.removeEventListener("jx-ready",o),t(e)})})}function Ss(e){let t=document.createElement("div");t.style.pointerEvents="auto",t.setAttribute(ot,zt("dialog",e.region)),e.layer.append(t);let o=y({cancel:()=>{e.onCancel()},cancelLabel:e.cancelLabel,choiceLabel:e.choice?.label??"",chosen:e.choice?.chosen??"",closed:()=>{e.onClosed()},confirm:()=>{e.onConfirm()},confirmLabel:e.confirmLabel,destructive:e.destructive===!0,error:"",hasChoice:e.choice!==void 0,hasField:e.field!==void 0,mono:e.field?.mono===!0,multiline:e.field?.multiline===!0,rows:e.field?.rows??"3",singleLine:e.field!==void 0&&e.field.multiline!==!0?"true":"false",hasMessage:e.message!==void 0&&e.message!=="",headline:e.headline,input:(r)=>{o.value=r,e.onInput?.(r)},invalid:!1,message:e.message??"",options:e.choice?.options??[],pick:(r)=>{e.onPick?.(r)},placeholder:e.field?.placeholder??"",secondary:()=>{e.onSecondary?.()},secondaryLabel:e.secondaryLabel??"",size:e.size??"sm",value:e.field?.value??""}),n=null,a=!1,i=()=>{},s=new Promise((r)=>{i=r}),l=I("dialog",o,t).then(async(r)=>{let c=r.root;if(a)return r.dispose(),c;if(n=r,await Promise.race([An(c),s]),a)return c;if(e.island?.(c.querySelector('[part="island"]')??c),pn(c),e.field){let h=c.querySelector("jx-textfield");if(h)setTimeout(()=>{if(!a)Zm(h,e.field?.select??"all")},0)}return c});return{close(){if(a)return;a=!0,i();let r=n?.root;if(r instanceof HTMLElement)an(r);n?.dispose(),n=null,t.remove()},host:t,ready:l,update(r){if(r.confirmLabel!==void 0)o.confirmLabel=r.confirmLabel;if(r.cancelLabel!==void 0)o.cancelLabel=r.cancelLabel;if(r.secondaryLabel!==void 0)o.secondaryLabel=r.secondaryLabel;if(r.message!==void 0)o.message=r.message,o.hasMessage=r.message!=="";if(r.value!==void 0)o.value=r.value;if(r.placeholder!==void 0)o.placeholder=r.placeholder;if(r.invalid!==void 0)o.invalid=r.invalid;if(r.error!==void 0)if(r.error!==""&&r.error===o.error){o.error="";let c=r.error;queueMicrotask(()=>{o.error=c})}else o.error=r.error;if(r.options!==void 0)o.options=r.options;if(r.chosen!==void 0)o.chosen=r.chosen}}}var re={$schema:"https://jxsuite.com/schema/v1",$id:"StudioToasts",$description:"The toast stack: a rendering of the notification service's toasts, newest last. Each row is projected by ui/layers.ts with its severity glyph and, where a recovery command exists, that command's title and gate; the two buttons call back into the host, which owns the records and their timers.",tagName:"div",attributes:{part:"stack"},style:{position:"absolute",right:"var(--jx-space-4)",bottom:"36px",display:"flex",flexDirection:"column",gap:"var(--jx-space-3)",alignItems:"flex-end",maxWidth:"min(420px, calc(100vw - 24px))",'& [part="toast"]':{display:"flex",alignItems:"center",gap:"var(--jx-space-3)",pointerEvents:"auto",padding:"var(--jx-space-3)",border:"1px solid var(--jx-border)",borderLeft:"3px solid var(--jx-fg-dim)",borderRadius:"var(--jx-radius-md)",background:"var(--jx-bg-panel)",color:"var(--jx-fg)",fontSize:"var(--jx-text-sm)",lineHeight:"var(--jx-leading-sm)",boxShadow:"var(--jx-shadow-popover)"},'& [part="toast"][data-severity="success"]':{borderLeftColor:"var(--jx-success)"},'& [part="toast"][data-severity="info"]':{borderLeftColor:"var(--jx-accent)"},'& [part="toast"][data-severity="warn"]':{borderLeftColor:"var(--jx-warning)"},'& [part="toast"][data-severity="error"]':{borderLeftColor:"var(--jx-danger)"},'& [part="icon"]':{flex:"none",width:"14px",textAlign:"center",fontWeight:"700"},'& [data-severity="success"] [part="icon"]':{color:"var(--jx-success)"},'& [data-severity="info"] [part="icon"]':{color:"var(--jx-accent)"},'& [data-severity="warn"] [part="icon"]':{color:"var(--jx-warning)"},'& [data-severity="error"] [part="icon"]':{color:"var(--jx-danger)"},'& [part="message"]':{flex:"1",minWidth:"0",overflow:"hidden",display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:"3"},'& [part="action-slot"]':{display:"contents"},'& [part="action"] > [part="control"]':{color:"var(--jx-accent)"}},children:[{$prototype:"Array",items:{$ref:"#/state/toasts"},key:{$ref:"$map/item/id"},map:{tagName:"div",attributes:{part:"toast","data-severity":"${$map.item.severity}"},children:[{tagName:"span",attributes:{part:"icon","aria-hidden":"true"},textContent:"${$map.item.icon}"},{tagName:"span",attributes:{part:"message"},textContent:"${$map.item.message}"},{tagName:"span",attributes:{part:"action-slot",role:"none"},$switch:{$ref:"$map/item/hasAction"},cases:{true:{tagName:"jx-button",$props:{size:"sm",quiet:!0,disabled:{$ref:"$map/item/actionDisabled"}},attributes:{part:"action",title:"${$map.item.actionTitle}"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/runAction"},value:[{$ref:"$map/item/id"}]}]},children:[{tagName:"span",textContent:"${$map.item.actionLabel}"}]}}},{tagName:"jx-action-button",$props:{label:"Dismiss notification",hint:"Dismiss notification",icon:"x",size:"sm"},attributes:{part:"dismiss"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/dismissToast"},value:[{$ref:"$map/item/id"}]}]}}]}}]};function $e(e){return e instanceof RangeError||e instanceof Error&&e.name==="CommandUnavailableError"}function sn(e,t,o,n=t){let a=(s)=>{if(!$e(s))console.error(`${n}: command "${t}" failed`,s);C.error(te(s),{key:`command.run:${t}`,source:n})},i;try{i=e.run(t,o)}catch(s){return a(s),Promise.resolve()}return Promise.resolve(i).catch(a)}function sl(e,t,o){let n=ne();return n?sn(n,e,t,o):Promise.resolve()}var se,F,q,w;function Ct(e){return(e==="popover"?se:e==="modal"?F:e==="toast"?w:q)||document.body}function D1(){se=document.querySelector("#layer-popover"),F=document.querySelector("#layer-modal"),q=document.querySelector("#layer-dialog"),w=document.querySelector("#layer-toast"),Ce()}var ae="jx-dialog[data-open], dialog[open]";function Gm(){return Boolean(q?.querySelector(ae)||F?.querySelector(ae))}function to(e,t,o={}){let{confirmLabel:n="Confirm",cancelLabel:a="Cancel",destructive:i=!1}=o;return new Promise((s)=>{let d=!1,l=(c)=>{if(d)return;d=!0,r.close(),s(c)},r=Ss({cancelLabel:a,confirmLabel:n,destructive:i,headline:e,layer:Ct("dialog"),...G(t),onCancel:()=>l(!1),onClosed:()=>l(!1),onConfirm:()=>l(!0)})})}function n_(e,t,o={}){let{saveLabel:n="Save",discardLabel:a="Discard",cancelLabel:i="Cancel"}=o;return new Promise((s)=>{let d=!1,l=(c)=>{if(d)return;d=!0,r.close(),s(c)},r=Ss({cancelLabel:i,confirmLabel:n,headline:e,layer:Ct("dialog"),...G(t),onCancel:()=>l("cancel"),onClosed:()=>l("cancel"),onConfirm:()=>l("save"),onSecondary:()=>l("discard"),secondaryLabel:a})})}function G(e){if(typeof e==="string")return{message:e};return{island:(t)=>{Pi(e,t)}}}function Pn(e,t={}){let{cancelLabel:o="Cancel",choice:n,confirmLabel:a="OK",message:i,mono:s=!1,multiline:d=!1,placeholder:l="",rows:r="3",select:c="all",size:h,validate:J,value:le=""}=t,D=(m)=>J?J(m,b):m.trim()?"":"Enter a value.",p=le,b=n?.initial??"",f="",U=!1,z=()=>typeof l==="function"?l():l,W=()=>n?n.options().map((m)=>({label:m.label,value:m.value})):[];return new Promise((m)=>{let V=!1,O=(u)=>{if(V)return;V=!0,N.close(),m(u)},K=(u)=>{f=u,N.update({error:f,invalid:f!==""})},N=Ss({cancelLabel:o,confirmLabel:a,headline:e,layer:Ct("dialog"),...i===void 0?{}:G(i),...n?{choice:{chosen:b,label:n.label,options:W()}}:{},field:{mono:s,multiline:d,placeholder:z(),rows:r,select:c,value:p},...h===void 0?{}:{size:h},onCancel:()=>O(null),onClosed:()=>O(null),onConfirm:()=>{let u=D(p);if(u){K(u);return}O(p.trim())},onInput:(u)=>{U=!0,p=u;let x=D(p);if(x!==f)K(x)},onPick:(u)=>{b=u,n?.onChange?.(u);let x=D(p);f=U||f?x:"",N.update({chosen:b,error:f,invalid:f!=="",options:W(),placeholder:z()})}})})}var E=new Map;function Cs(e,t){let o=`${e}:${t}`,n=E.get(o);if(n&&n.parentElement)return n;return n=document.createElement("div"),n.style.pointerEvents="auto",n.setAttribute(ot,zt(e,t)),Ct(e).append(n),E.set(o,n),n}function Km(e,t){let o=`${e}:${t}`,n=E.get(o);if(n)Pi(tt,n),n.remove(),E.delete(o)}var Re=180,Le={error:"✕",info:"ℹ",success:"✓",warn:"!"},M=null,v=new Map,g=new Set;function Te(){return globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches===!0}function we(){try{return new URLSearchParams(globalThis.location?.search??"").get("automation")==="1"}catch{return!1}}function N1(){return[...g].map((e)=>`overlay: toast ${e} settling in`)}function P(e){let t=v.get(e);if(t!==void 0)clearTimeout(t),v.delete(e);g.delete(e),nu(e)}function Ee(e){if(v.has(e.id)||g.has(e.id))return;let t=Te()?0:Re;if(t>0)g.add(e.id),setTimeout(()=>g.delete(e.id),t);let o=e.timeoutMs??0;if(o<=0||we())return;v.set(e.id,setTimeout(()=>P(e.id),o))}T("toasts",re);var _=null,j=null,L=null;function ie(){return _??=y({dismissToast:(e)=>{P(e)},runAction:(e)=>{let t=Wc.find((n)=>n.id===e),o=ne();if(!t?.action||!o)return;P(e),sn(o,t.action,t.actionArgs,"Notifications")},toasts:[]}),_}function Me(e){let t=e.action===void 0?null:ne(),o=e.action,n=t&&o!==void 0?t.get(o):void 0,a=n&&o!==void 0&&t.isVisible(o)?n:null,i=a&&o!==void 0?t.disabledReason(o):void 0;return{actionDisabled:i!==void 0,actionLabel:a?.title??"",actionTitle:a===null||a===void 0?"":i===void 0?a.title:`${a.title} — requires ${i}`,hasAction:a!==null&&a!==void 0,icon:Le[e.severity],id:e.id,message:e.message,severity:e.severity}}function Ce(){if(je(),!w)return;M=ge(),M.run(()=>{Q(()=>{Wc.length,ne();for(let e of Wc)Ee(e);ie().toasts=Wc.map((e)=>Me(e))})}),j=I("toasts",ie(),w),j.then((e)=>{L=e})}function je(){M?.stop(),M=null;for(let t of v.values())clearTimeout(t);v.clear(),g.clear();let e=j;if(j=null,L)L.dispose(),L=null;else if(e)e.then((t)=>t.dispose());_=null}
2
+ export{ER,TR,$1,ot,qp,I1,Qi,LR,RR,$R,IR,DR,Gy,zt,T,NR,I,An,Ss,sn,sl,Ct,D1,Gm,to,n_,Pn,Cs,Km,N1};
3
+
4
+ //# debugId=6DE78C93330ECDAC64756E2164756E21
5
+ //# sourceMappingURL=studio-g1shz58g.js.map
@@ -0,0 +1,5 @@
1
+ import{NL,Le,xs,Ly,q,qs,Zi,rh,Sa,Ue,oh,Sn,rt,Py,xi,di,ke,Ar,c1,sr,He,ti,m,u,Wn,Mo,Hp}from"./studio-a2ke1e4t.js";import{ge,Q,oe,C}from"./studio-55h4mstj.js";import{Je,Xi,ch,Zl}from"./studio-epgrmqqm.js";import{p,Ve}from"./studio-xz2yxfcb.js";import{Yd,_i}from"./studio-5tnvjkz4.js";import{Yy,Kp,Ym,tc,es,ar,ts,Qs,gh,ll,Xm,MR,no,Xd,Qm,ne}from"./studio-9mccjwjh.js";import{st,Em,Nc}from"./studio-e81q1vb9.js";import{n1,Wd}from"./studio-pcgz8heb.js";import{Ea,xo,Ks,Js,_s}from"./studio-rv11kfwa.js";import{Oi,hL,sy,pL,vs,Vl,ay,fL,v,XC}from"./studio-t1xzawhr.js";import{Lm,Lp,Rm}from"./studio-74k29dy9.js";import{K,Cr,ht,Cn,Qr,il,D,hh,ph,Ai}from"./studio-yn9f8vtx.js";import{Ie,Ky}from"./studio-0bhx5hz6.js";import{qe,Qp}from"./studio-s8dmmz66.js";import{ov}from"./studio-8grwxtqk.js";var BT="fullRender",WT="mountCanvas",VT="patchBatch",Pt="prepareRender",Sr={derivedResolves:0,derivedRetargets:0,escalations:0,fullRenders:0,hostRenderPosts:0,lastEscalationReason:"",lastFullRenderMs:0,p95FullRenderMs:0,panelRenders:0,patchedOps:0,renderPreparations:0,skippedFullRenders:0,timings:{}};globalThis.__jxCanvasPerf=Sr;var wt=new Map;function Et(){try{return typeof localStorage<"u"&&Boolean(localStorage.getItem("jx-canvas-debug"))}catch{return!1}}function Ct(){return typeof performance<"u"&&typeof performance.now==="function"?performance.now():0}function St(e,t){if(Et())console.debug(`[jx-canvas] ${e}`,t??"")}function Jb(e){Sr.escalations+=1,Sr.lastEscalationReason=e,St("escalation",e)}function to(e){if(e.length===0)return 0;let t=e.toSorted((o,r)=>o-r),n=Math.min(t.length-1,Math.ceil(t.length*0.95)-1);return t[Math.max(0,n)]??0}function oo(e,t){let n=Number.isFinite(t)&&t>0?t:0,o=wt.get(e);if(!o)o=[],wt.set(e,o);if(o.push(n),o.length>128)o.shift();let r=Sr.timings[e],i={count:(r?.count??0)+1,lastMs:n,maxMs:Math.max(r?.maxMs??0,n),p95Ms:to(o),totalMs:(r?.totalMs??0)+n};if(Sr.timings[e]=i,e==="fullRender")Sr.lastFullRenderMs=i.lastMs,Sr.p95FullRenderMs=i.p95Ms;St(`span:${e}`,`${n.toFixed(2)}ms`)}function Tt(e){let t=Ct(),n=Et(),o=`jx-${e}-start`;if(n)try{performance.mark(o)}catch{}let r=!1;return()=>{if(r)return Sr.timings[e]?.lastMs??0;r=!0;let i=Ct()-t;if(n)try{performance.measure(`jx-${e}`,o),performance.clearMarks(o)}catch{}return oo(e,i),i}}function bx(e,t){let n=Tt(e);try{return t()}finally{n()}}async function yx(e,t){let n=Tt(e);try{return await t()}finally{n()}}function mo(){return Xi(m.activePaneId)}function lt(e){let t=Wn(e),n=t?.derived,o=n?.kind==="lens"?Wn(n.sourcePaneId)?.activeTabId:t?.activeTabId;return o?m.tabs.get(o)??null:null}function go(e){return Wn(e)?.derived??null}function fx(e){if(!e)return[];let t=[];for(let n of m.panes)if(lt(n.id)?.id===e.id)t.push(Xi(n.id));return t}function _(e){for(let t of ch()){let n=t.panels.find((o)=>o.canvas===e);if(n)return{panel:n,surface:t}}return null}function Mt(e){let t=e.canvas,n=t?_(t):null;return n?lt(n.surface.paneId):null}function jl(e){let t=e?.session.ui,n=t?.canvasMode??"design";return t?.preview&&(n==="edit"||n==="design")?"preview":n}function _r(e){let t=go(e);if(t?.kind==="lens"){let n=t.mode;return lt(e)?.session.ui?.preview&&(n==="edit"||n==="design")?"preview":n}return jl(lt(e))}function Ku(e){let t=go(e);if(t?.kind==="lens"&&t.preset==="breakpoint")return t.media;return lt(e)?.session.ui.activeMedia??null}function Gb(e){return Zl(e)?.paneId??ti}function ym(e){return lt(Gb(e))}function Zb(e){return Yy(e)!==null}function Ju(e){return Yy(e)}function bo(e){if(!e)return{baseWidth:320,featureQueries:[],sizeBreakpoints:[]};let t=[],n=[],o=320;for(let[r,i]of Object.entries(e)){if(r==="--"){let l=String(i).match(/^(\d+)\s*px$/);o=l?Number(l[1]):320;continue}let s=i.match(/min-width:\s*([\d.]+)px/),a=i.match(/max-width:\s*([\d.]+)px/);if(s)n.push({name:r,query:i,type:"min",width:Number(s[1])});else if(a)n.push({name:r,query:i,type:"max",width:Number(a[1])});else t.push({name:r,query:i})}return n.sort((r,i)=>r.type==="min"?r.width-i.width:i.width-r.width),{baseWidth:o,featureQueries:t,sizeBreakpoints:n}}function ro(e,t){let n=new Set;for(let o of e)if(o.type==="min"&&t>=o.width)n.add(o.name);else if(o.type==="max"&&t<=o.width)n.add(o.name);return n}function Nt(e,t){let n=ro(e,t),o=null;for(let r of e){if(!n.has(r.name))continue;let i=Math.abs(r.width-t);if(o===null){o=r;continue}let s=Math.abs(o.width-t);if(i<s||i===s&&r.width<o.width)o=r}return o?.name??null}function KT(e,t,n=8){let o=null;for(let r of t){let i=Math.abs(r-e);if(i>n)continue;if(o===null||i<Math.abs(o-e))o=r}return o??e}var Dd={$id:"elements-meta",title:"HTML Element Metadata",description:"Inline scoping and inline toolbar action metadata for HTML elements.",$convertGroups:{text:["p","h1","h2","h3","h4","h5","h6","blockquote"],container:["div","section","article","aside","main","header","footer","nav","search"],list:["ul","ol"]},$defs:{p:{$convertTo:"text",$convertToWhenEmpty:["text","container"],$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:[{tag:"strong",label:"Bold",command:"bold"},{tag:"em",label:"Italic",command:"italic"},{tag:"u",label:"Underline",command:"underline"},{tag:"del",label:"Strikethrough",command:"strikethrough"},{tag:"sup",label:"Superscript",command:"superscript"},{tag:"sub",label:"Subscript",command:"subscript"},{tag:"code",label:"Code",command:"code"},{tag:"a",label:"Link",command:"link"}]},h1:{$convertTo:"text",$inlineChildren:["em","strong","code","a","span","br","b","i","u","sub","sup"],$inlineActions:[{tag:"strong",label:"Bold",command:"bold"},{tag:"em",label:"Italic",command:"italic"},{tag:"code",label:"Code",command:"code"},{tag:"a",label:"Link",command:"link"}]},h2:{$convertTo:"text",$inlineChildren:["em","strong","code","a","span","br","b","i","u","sub","sup"],$inlineActions:"h1"},h3:{$convertTo:"text",$inlineChildren:["em","strong","code","a","span","br","b","i","u","sub","sup"],$inlineActions:"h1"},h4:{$convertTo:"text",$inlineChildren:["em","strong","code","a","span","br","b","i","u","sub","sup"],$inlineActions:"h1"},h5:{$convertTo:"text",$inlineChildren:["em","strong","code","a","span","br","b","i","u","sub","sup"],$inlineActions:"h1"},h6:{$convertTo:"text",$inlineChildren:["em","strong","code","a","span","br","b","i","u","sub","sup"],$inlineActions:"h1"},li:{$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:"p"},td:{$inlineChildren:["em","strong","del","code","a","span","br","b","i","u","sub","sup","s"],$inlineActions:"p"},th:{$inlineChildren:["em","strong","del","code","a","span","br","b","i","u","sub","sup","s"],$inlineActions:"p"},blockquote:{$convertTo:"text",$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:"p"},figcaption:{$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:"p"},caption:{$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:"p"},summary:{$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:"p"},dt:{$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:"p"},dd:{$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:"p"},label:{$inlineChildren:["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"],$inlineActions:"p"},a:{$inlineChildren:["em","strong","code","span","br","b","i","u","sub","sup"],$inlineActions:[{tag:"strong",label:"Bold",command:"bold"},{tag:"em",label:"Italic",command:"italic"},{tag:"code",label:"Code",command:"code"}]},span:{$inlineChildren:["em","strong","del","code","a","br","b","i","u","sub","sup","s"],$inlineActions:"p"},div:{$convertTo:"container",$convertToWhenEmpty:["container","text"],$inlineChildren:[]},section:{$convertTo:"container",$inlineChildren:[]},article:{$convertTo:"container",$inlineChildren:[]},nav:{$convertTo:"container",$inlineChildren:[]},main:{$convertTo:"container",$inlineChildren:[]},header:{$convertTo:"container",$inlineChildren:[]},footer:{$convertTo:"container",$inlineChildren:[]},aside:{$convertTo:"container",$inlineChildren:[]},ul:{$convertTo:"list",$inlineChildren:[]},ol:{$convertTo:"list",$inlineChildren:[]},pre:{$inlineChildren:["code"]},table:{$inlineChildren:[]},thead:{$inlineChildren:[]},tbody:{$inlineChildren:[]},tr:{$inlineChildren:[]}}};var ao=new Set(["pre"]),hi=new Set(Object.entries(Dd.$defs).filter(([e,t])=>!ao.has(e)&&(t.$inlineChildren?.length??0)>0).map(([e])=>e));var kt=new Set(["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"]);function De(e,t){if(!t)return kt.has(e);let n=Dd.$defs[t];if(!n||!n.$inlineChildren)return!1;return n.$inlineChildren.includes(e)}function UT(e){let t=Dd.$defs[e];if(!t)return null;let n=t.$inlineActions;if(typeof n==="string")n=Dd.$defs[n]?.$inlineActions??void 0;if(!Array.isArray(n))return null;return n}var so=null;function vx(e,t){if(!e||typeof e!=="object")return!1;let n=(qe(e.tagName)||"div").toLowerCase();if(t){let o=(qe(t.tagName)||"div").toLowerCase();return De(n,o)}return kt.has(n)}function qT(){return so!==null}function ce(e){return!e||e==="base"?null:e}function Yb(e){let t=e.panels;if(t.length===0)return null;if(t.length===1)return t[0];let n=Ku(e.paneId);for(let o of t){if(n===null&&(o.mediaName==="base"||o.mediaName===null))return o;if(o.mediaName===n)return o}return t[0]}function Rt(){return Yb(mo())}function GT(e,t){if(!e)return t;let n=t;while(n.length>=2){let o=K(e,n),r=ht(n),i=r?K(e,r):null;if(!o||!i)break;let s=(qe(o.tagName)||"div").toLowerCase(),a=(qe(i.tagName)||"div").toLowerCase();if(!De(s,a))break;n=r}return n}var Sp=240,JT=8,YT=16,ue=new Map;function _e(e){return bo(Oi(e.doc.document?.$media))}function wx(e){let{baseWidth:t,sizeBreakpoints:n}=_e(e),o=e.session.ui.activeMedia;return n.find((r)=>r.name===o)?.width??t}function lo(e,t){let n=ue.get(e);if(!n)return null;if(!t||n.tabId!==t.id||n.media!==t.session.ui.activeMedia)return ue.delete(e),null;return n.width}function ZT(e,t){let n=t?wx(t):0;return lo(e.paneId,t)??n}function xx(e){ue.delete(e)}function XT(e){let{baseWidth:t,sizeBreakpoints:n}=_e(e);return[t,...n.map((o)=>o.width)]}function _x(e,t,n){let{sizeBreakpoints:o}=_e(t),r=Nt(o,n);return t.session.ui.activeMedia=r,ue.set(e,{media:r,tabId:t.id,width:n}),r}var je={invokerTags:Qm,popoverTags:Xd};function dC(e,t){if(!e||!t)return null;for(let n=t.length;n>=0;n-=1){let o=t.slice(0,n),r=K(e,o);if(r&&typeof r==="object"&&Qs(r,je))return o}return null}function Ot(e,t){let n=e.doc.document;if(!n)return null;if(t){let o=K(n,t);return o&&typeof o==="object"&&Qs(o,je)?t:null}return dC(n,Le(e.session.selection))}function At(){let e=u.value?.doc.document;return e?MR(e,je):!1}var It=["toggle-popover","show-popover","hide-popover","show-modal","close","request-close"],Fe=new Set(["show-modal","close","request-close"]),We=new Set(["toggle-popover","show-popover","hide-popover"]),co=["any","closerequest","none"],uo=new Set(["button"]),A="See docs/framework/concepts/overlays.";function H(e){return ar(e)==="dialog"}function $t(e){return e.startsWith("--")}function po(e){let t=[];for(let{node:n}of ll(e)){let o=gh(n);if(H(n)&&o!==null&&!t.includes(o))t.push(o)}return t}function Dt(e){for(let{node:t}of ll(e))if(H(t))return!0;return!1}function fo(e){let t=e.oncommand;return t!==void 0&&t!==null}function ho(e,t){for(let{node:n}of ll(e)){if(n===e)continue;let o=ar(n);if(o==="button"){let r=es(n,"command"),i=es(n,"commandfor");if(r!==null&&(r==="close"||r==="request-close")&&(i===null||i===t))return!0}if(o==="form"&&es(n,"method")?.toLowerCase()==="dialog")return!0}return!1}function AT(e,t){let n=[...ll(e,[],null,t)],o=po(e),r=Xm(e,t),i=o.length>0||r.length>0,s=new Map,a=new Map;for(let{node:c}of n){let d=gh(c);if(d!==null&&!s.has(d))s.set(d,c);if(ar(c)==="button"){let f=es(c,"commandfor"),h=es(c,"command");if(f!==null){let b=a.get(f)??new Set;b.add(h??""),a.set(f,b)}}}let l=[];for(let{node:c,path:d}of n)if(l.push(...vo(c,d,s,o,r,i,t)),H(c))l.push(...yo(c,d,a));return l}function vo(e,t,n,o,r,i,s){let a=[],l=ar(e),c=s?.invokerTags?.has(l)??!1,d=es(e,"command"),f=es(e,"commandfor");if(!(d!==null||f!==null||("command"in tc(e))||("commandfor"in tc(e))))return a;let b=ts(e,"the element");if(!uo.has(l)&&!c)return a.push({detail:"`command` and `commandfor` are attributes of `HTMLButtonElement` and of no other "+"interface — not even `<input>`, which `popovertarget` does allow. Elsewhere they parse "+`and do nothing. Make it a <button>, or remove both attributes. ${A}`,fix:"invoker",message:`<${l||"element"}> carries command/commandfor, which only <button> supports.`,path:t,rule:"invoker-not-button",severity:"error"}),a;if(d!==null&&!It.includes(d)&&!$t(d))return a.push({detail:`\`command\` is an enumerated attribute taking ${It.map((M)=>`\`${M}\``).join(", ")}, or a custom command starting with \`--\`. Anything else is the invalid-value state, and a button in that state does nothing when clicked. ${A}`,message:`${b} declares command="${d}", which is not a built-in or --custom command.`,path:t,rule:"command-invalid",severity:"error"}),a;if(f!==null){let M=n.get(f),R=o.includes(f),O=r.includes(f);if(!M&&i){let U=[...o,...r].map((w)=>`"${w}"`).join(", ");return a.push({detail:`No element in this document has the id "${f}". The dialogs and popovers here are: ${U}. A commandfor that names nothing does nothing, silently. ${A}`,message:`commandfor="${f}" names nothing in this document.`,path:t,rule:"command-target-missing",severity:"error"}),a}if(d!==null&&M){if(Fe.has(d)&&!H(M))a.push({detail:`\`${d}\` acts on a <dialog>, and "${f}" is ${O?"a popover":`a <${ar(M)||"element"}>`}. The click is ignored. ${O?"Use `toggle-popover`, `show-popover` or `hide-popover` for a popover.":"Point it at a dialog, or make the target one."} ${A}`,message:`${b} sends ${d} to "${f}", which is not a dialog.`,path:t,rule:"command-target-mismatch",severity:"error"});else if(We.has(d)&&!Qs(M,s))a.push({detail:`\`${d}\` acts on a popover, and "${f}" is ${R?"a dialog":`a <${ar(M)||"element"}>`} that declares no \`popover\`. The click is ignored. ${R?"Use `show-modal`, `close` or `request-close` for a dialog.":"Give the target a `popover` attribute, or point the button elsewhere."} ${A}`,message:`${b} sends ${d} to "${f}", which is not a popover.`,path:t,rule:"command-target-mismatch",severity:"error"});else if($t(d)&&!fo(M))a.push({detail:`A custom command is a \`CommandEvent\` dispatched at its target, and "${f}" has no `+"`oncommand` handler to answer it — so the click does nothing. Add one that switches on "+`\`event#/command\`, or use a built-in command. ${A}`,message:`${b} sends ${d} to "${f}", which handles no command.`,path:t,rule:"custom-command-unhandled",severity:"warn"})}}return a}function yo(e,t,n){let o=[],r=ts(e,"the dialog"),i=gh(e),{style:s}=e,a=es(e,"closedby");if(a!==null&&!co.includes(a))o.push({detail:`\`closedby\` is an enumerated attribute taking \`any\` (light dismiss and Escape), \`closerequest\` (Escape only, the default for a modal) or \`none\`. Anything else is the invalid-value default, \`auto\`, which is the same as leaving it out. ${A}`,message:`${r} declares closedby="${a}", which is not any, closerequest or none.`,path:t,rule:"dialog-closedby-invalid",severity:"error"});if(no(s,"display")!==null)o.push({detail:`A closed dialog is hidden by the browser's own \`dialog:not([open]) { display: none }\`. That rule is UA-origin, so any author \`display\` beats it, and the dialog is laid out on every page whether or not anyone opened it. \`display\` belongs in the \`&[open]\` rule and nowhere else. ${A}`,fix:"display",message:`${r} sets display in its base rule.`,path:t,rule:"dialog-display",severity:"error"});let l=i===null?void 0:n.get(i),c=es(e,"open")!==null||tc(e).open===!0||e.open===!0;if(i!==null&&!l?.has("show-modal")&&!c)o.push({detail:`No <button> in this document opens it with \`command="show-modal"\`. If it is opened from another file or from a function that calls \`showModal()\`, this is fine; otherwise there is no way for a reader to open it. ${A}`,message:`${r} has no invoker in this document.`,path:t,rule:"dialog-no-invoker",severity:"warn"});if(l?.has("show-modal")&&a==="none"&&!ho(e,i))o.push({detail:`A modal dialog makes everything outside it inert, so the only ways out are the ones it offers: \`closedby="none"\` turns off Escape and light dismiss, and nothing inside it closes it. A reader who opens it cannot leave. Add a <button command="close"> inside, or drop \`closedby="none"\`. ${A}`,message:`${r} opens modally, closes on nothing, and has no close button.`,path:t,rule:"modal-without-close",severity:"error"});return o}function uC(e,t){if(!e||!t)return null;for(let n=t.length;n>=0;n-=1){let o=t.slice(0,n),r=K(e,o);if(r&&typeof r==="object"&&H(r))return o}return null}function Sx(e,t){let n=e.doc.document;if(!n)return null;if(t){let o=K(n,t);return o&&typeof o==="object"&&H(o)?t:null}return uC(n,Le(e.session.selection))}function Ht(){let e=u.value?.doc.document;return e?Dt(e):!1}var wo=/\[\.\.\.(\w+)\]|\[(\w+)\]/g;function Co(e){return e.split("\\").join("/").replace(/^\.\//,"").replace(/^\//,"").replace(/^pages\//,"")}function Jt(e){let t=Co(e),n=t.slice(t.lastIndexOf("/")+1),o=n.lastIndexOf(".");if(o>0)t=t.slice(0,t.length-(n.length-o));if(t.endsWith("/index"))t=t.slice(0,-6)||"/";else if(t==="index")t="/";if(!t.startsWith("/"))t=`/${t}`;let r=[],i=!1,s=!1,a=t.replaceAll(wo,(l,c,d)=>{if(i=!0,c)return s=!0,r.push(c),"*";return r.push(d),`:${d}`});return{isCatchAll:s,isDynamic:i,params:r,urlPattern:a}}function Kb(e){if(!e)return"/";return Jt(e).urlPattern}function Hl(e){if(!e)return[];return Jt(e).params}function MT(e){let t=e.document?.$paths,n=e.frontmatter?.$paths;return t??n??null}var pe=new Map;function FT(){pe.clear()}function jT(e,t){if(!t)return Promise.resolve({});let n=`${e??""}::${JSON.stringify(t)}`,o=pe.get(n);if(!o)o=Po(t).catch((r)=>(pe.delete(n),console.warn("page-params: failed to enumerate $paths values:",r),{})),pe.set(n,o);return o}async function Po(e){if(Array.isArray(e)){let t={};for(let n of e)for(let[o,r]of Object.entries(n))de(t,o,r);return t}if("contentType"in e&&typeof e.contentType==="string"&&e.contentType){let t=e.param??"slug",n=e.field??"id",o=await So(e.contentType),r={[t]:[]};if(!Array.isArray(o))return r;for(let i of o)de(r,t,n==="id"?i.id:i.data?.[n]??i.id);return r}if("values"in e&&Array.isArray(e.values)){let t=e.param??"value",n={[t]:[]};for(let o of e.values)de(n,t,o);return n}if("$ref"in e&&typeof e.$ref==="string"&&e.$ref){let t=e.param??"id",n=e.field??"id",o=await p().readFile(e.$ref.replace(/^\.\//,"")),r=JSON.parse(o),i={[t]:[]};if(!Array.isArray(r))return i;for(let s of r)de(i,t,s?.[n]??s?.id??s);return i}return{}}async function Eo(){let e=await Yd();for(let t of e){let n=t.classes?.find((o)=>o.name==="ContentCollection");if(n)return n.path}return"@jxsuite/parser/ContentCollection.class.json"}async function So(e){let t={$prototype:"ContentCollection",$src:await Eo(),contentType:e},n=p();if(n.resolveClass)return n.resolveClass(t);return fetch("/__jx_resolve__",{body:JSON.stringify(t),headers:{"content-type":"application/json"},method:"POST"}).then((o)=>{if(!o.ok)throw Error(`Class resolution failed: ${o.status}`);return o.json()})}function de(e,t,n){if(n===null||n===void 0||n==="")return;let o=String(n);e[t]??=[];let r=e[t];if(!r.includes(o))r.push(o)}function Lt(e,t,n){if(Object.keys(t).length===0)return e;let o=Be(e,t);return o.state??={},o.state.$page={params:{...t},title:typeof o.title==="string"?o.title:"",url:Kb(n)},o}function _t(e){if(!e)return[];return Object.keys(e).filter((t)=>{let n=e[t];return n&&typeof n==="object"&&typeof n.$prototype==="string"&&typeof n.$src==="string"&&JSON.stringify(n).includes('"#/$params/')})}async function jt(e,t,n){if(t.length===0)return;let o=p();if(!o.resolveClass)return;let{state:r}=e;if(!r)return;await Promise.all(t.map(async(i)=>{let s=r[i];if(!s||typeof s!=="object")return;try{r[i]=await o.resolveClass({...s,...n?{$base:n}:{}})}catch(a){console.warn(`page-params: failed to resolve state.${i} for preview:`,a)}}))}function Be(e,t){let n=To(e,t);if(n!==null)return n;if(!e||typeof e!=="object")return e;if(Array.isArray(e))return e.map((r)=>Be(r,t));let o={};for(let[r,i]of Object.entries(e))o[r]=Be(i,t);return o}function To(e,t){if(!e||typeof e!=="object"||Array.isArray(e))return null;let n=e.$ref;if(typeof n!=="string"||!n.startsWith("#/$params/"))return null;return t[n.slice(10)]??null}function W(e){return lt(e.paneId)}function Y(e){let t=go(e.paneId);if(t?.kind==="lens")return t.zoom;return W(e)?.session.ui.zoom??1}function Cp(e=mo()){return Y(e)}function fe(e,t){let n=go(e.paneId);if(n?.kind==="lens"){n.zoom=t;return}let o=W(e);if(o)o.session.ui.zoom=t}function Yu(e,t,n,o=null){let r={_width:o||null,canvas:null,element:null,mediaName:e||"",ready:!1,renderScope:null,scrollContainer:null,viewport:null},i=[];if(o&&!n)i.push(`--panel-viewport-w:${o}px`);if(o)i.push(`--panel-canvas-w:${o}px`);return{item:{fullWidth:n,header:t?"shown":"hidden",key:e??"",label:t??"",mediaAttr:e,widthVars:i.join(";")},panel:r}}function QT(e,t){for(let{item:n,panel:o}of e)o.element=t.panelNode(n.key,"panel"),o.viewport=t.panelNode(n.key,"panel-viewport"),o.canvas=t.panelNode(n.key,"panel-canvas")}function eL(e,t){let n=e.find((r)=>r.item.key===t);if(!n)return;let o=Mt(n.panel);if(o)o.session.ui.activeMedia=ce(n.item.mediaAttr)}function Ze(e){if(!e.panzoomWrap)return;let t=e.wrap.clientWidth,n=e.panzoomWrap.scrollWidth,o=Y(e),r=n*o;e.panX=Math.max(16,(t-r)/2),e.panY=0}function Xb(e){if(e.centerObserver)e.centerObserver.disconnect(),e.centerObserver=null;if(!e.panzoomWrap)return;e.needsCenter=!0,e.centerObserver=new ResizeObserver(()=>{if(!e.needsCenter){e.centerObserver?.disconnect(),e.centerObserver=null;return}Ze(e),bs(e)}),e.centerObserver.observe(e.panzoomWrap),Ze(e)}function bs(e){if(!e.panzoomWrap)return;let t=Y(e);e.panzoomWrap.style.transform=`translate(${e.panX}px, ${e.panY}px) scale(${t})`,Ai("overlays")}var Xe=0.25,Ye=3;function Wt(e){return Math.min(Ye,Math.max(Xe,e))}function No(e,t,n){let o=e.wrap.querySelector('[part="edit-canvas"]'),r=e.panels[0]?.canvas;if(!o||!r)return null;let i=e.wrap.querySelector('[part="edit-column"]'),s=i?Ie(i).width:0,a=t&&s>0?s/t:1,l=n;if(l===null){let c=Ie(o);l=c.top+c.height/2}return{layoutY:Math.max(0,(l-Ie(r).top)/a),scroller:o,zoom:a}}function Nd(e=mo(),t=null){if(_r(e.paneId)!=="edit")return;let[n]=e.panels;if(!n?.canvas||!n.viewport)return;let o=n.canvas,r=o.querySelector("iframe"),i=W(e)?.session.ui.editZoom??1,s=No(e,n._width??null,t);if(i===1){if(n._width=null,o.style.width="",o.style.transform="",o.style.transformOrigin="",r)r.style.width="100%";n.viewport.style.height=""}else{let a=e.wrap.querySelector('[part="edit-column"]');if(!a)return;let l=Ie(a).width;if(l<=0)return;let c=l/i;if(n._width=c,o.style.width=`${c}px`,o.style.transform=`scale(${i})`,o.style.transformOrigin="top left",r)r.style.width=`${c}px`,n.viewport.style.height=`${r.offsetHeight*i}px`}if(s)s.scroller.scrollTop+=s.layoutY*(i-s.zoom);Ai("overlays")}function Zu(e,t=mo()){let n=W(t);if(!n)return;n.session.ui.editZoom=Wt(e),Nd(t)}var ze=new Map,Ke=new Map;function tL(e,t=mo(),n=null){let o=W(t);if(!o)return;if(o.session.ui.editZoom=Wt(e),Ke.set(t.paneId,n),ze.has(t.paneId))return;ze.set(t.paneId,requestAnimationFrame(()=>{ze.delete(t.paneId);let r=Ke.get(t.paneId)??null;Ke.delete(t.paneId),Nd(t,r)}))}function Vt(e,t,n){if(!e.panzoomWrap)return;let o=e.wrap.clientWidth,r=e.wrap.clientHeight,i=24,s=32,a=0,{panels:l}=e;for(let y of l)a+=y._width||800;a+=i*Math.max(0,l.length-1)+s;let c=Y(e),h=Ie(e.panzoomWrap).height/c+s,b=o/a,M=r/h,R=t==="width"?b:Math.min(b,M),O=Math.min(n,Math.max(j,R));fe(e,O);let U=a*O,w=h*O;e.panX=Math.max(0,(o-U)/2),e.panY=Math.max(0,(r-w)/2),bs(e)}function nL({maxZoom:e=F,surface:t=mo()}={}){me("page",t),Vt(t,"page",e)}var j=0.05,F=5;function Bt(e){return Math.min(F,Math.max(j,e))}var ko="page",Qe=["width","page","none"];function Ro(e,t,n){let o=t[n];if(typeof o==="string"&&Qe.includes(o))return o;if(typeof o==="number"&&o>=j&&o<=F)return o;throw RangeError(`command "${e}" argument "${n}": expected ${Qe.map((r)=>`"${r}"`).join(" | ")} or a number in [${j}, ${F}], got ${JSON.stringify(o)}`)}var zt=new Map;function Kt(e){let t=W(e);if(!t)return null;let n=go(e.paneId)?.kind==="lens"?`::${e.paneId}`:"";return`${t.id}::${t.documentPath??""}${n}`}function me(e,t){let n=Kt(t);if(n)zt.set(n,e)}function Cx(e=mo()){let t=Kt(e);return(t===null?void 0:zt.get(t))??ko}function Ut(e,t=mo()){let n=e??Cx(t);if(n==="none"){bs(t);return}if(typeof n==="number"){fe(t,Bt(n)),bs(t);return}Vt(t,n,1)}function hC(e,t=mo()){me(e,t),Ut(e,t)}function kp(e,t=mo(),n=null){if(!W(t))return;let r=Bt(e),i=r/Y(t);if(me(r,t),t.panzoomWrap&&i!==1){let s=Ie(t.panzoomWrap),a=Ie(t.wrap),l=n?.clientX??a.left+a.width/2,c=n?.clientY??a.top+a.height/2;t.panX+=(l-s.left)*(1-i),t.panY+=(c-s.top)*(1-i),t.needsCenter=!1}fe(t,r),bs(t)}function kx(e){if(e.wrap.clientWidth<=0){bs(e);return}Ut(Cx(e),e)}function iL(e=mo()){if(me(1,e),!e.panzoomWrap)return;fe(e,1),Ze(e),bs(e)}function Oo(e,t){let n=Ie(Gt(e)??e.wrap),o=t.top+t.height/2-n.top;return n.height/2-o}function Gt(e){return Yb(e)?.scrollContainer??null}function Ao(e,t,n){let o=Gt(e);if(!o){Io(e,t);return}let r=o.scrollTop-t;if(n){o.scrollTo({behavior:"smooth",top:r});return}o.scrollTop=r}function Qb(e,t=mo()){Ao(t,Oo(t,e),!1)}function Io(e,t){let n=e.panY,o=n+t,r=performance.now(),i=250,s=(a)=>{let l=Math.min((a-r)/250,1),c=l*(2-l);if(e.panY=n+(o-n)*c,bs(e),l<1)requestAnimationFrame(s)};requestAnimationFrame(s)}var Ge=["edit","design","preview","source","stylebook","grid","git-diff"],he=new Set(["edit","design"]),$o=["edit","design","preview"];function Do(e){return $o.filter((t)=>e.capabilities.modes.includes(t))}function rL(e){return Do(e).filter((t)=>t!=="preview")}function pC(e){let t=e.session.ui.canvasMode;return he.has(t)?t:null}function fC(e){return{available:e.capabilities.modes.includes("preview")&&he.has(e.session.ui.canvasMode),on:e.session.ui.preview===!0}}function mC(e,t,n){if(t==="preview"){if(he.has(e.session.ui.canvasMode))e.session.ui.preview=!0;return}if(e.session.ui.preview=!1,e.session.ui.canvasMode!==t)n(e,t)}var qt=new Set(["design","stylebook","git-diff"]),k=(e)=>e.document.open,Ft=["auto","light","dark"];function Ho(e){function t(s){let a=u.value;if(!a)throw RangeError(`command "${s}" needs an open document; no tab is active`);return a}function n(s,a){let{pane:l}=a;if(l===void 0)return t(s);let c=rt(s,a,"pane"),d=lt(c);if(!d)throw RangeError(`command "${s}" argument "pane": "${c}" has no open document`);return d}let o={pane:He("Which pane to render this way. Defaults to the focused one.")};function r(s){e.renderPane(i(s))}function i(s){let{pane:a}=s;return typeof a==="string"?a:m.activePaneId}return[{args:ke({mode:Ar(Ge,"The canvas mode to switch the active pane to.")}),category:"View",id:"canvas.setMode",level:"document",menus:["palette"],group:"3_canvas",requires:"an open document",when:k,aiTool:{description:"Switch the active document's editor mode. edit and design put its element tree on the canvas, where the document tools work; preview renders it as a visitor sees it; source shows the JSON; stylebook, grid and git-diff open other editors. Use it to return a document to edit or design when the tree tools are refused.",name:"set_canvas_mode",report:({after:s,args:a})=>{let l=di("canvas.setMode",a,"mode",Ge),c=s.editor.kind==="canvas"?"the document tools address its element tree":"the tree-editing tools are unavailable until it returns to edit or design";return`The active document is in ${l} mode; ${c}.`}},run:(s,a)=>{let l=di("canvas.setMode",a,"mode",Ge),c=t("canvas.setMode"),{modes:d}=c.capabilities;if(!d.includes(l))throw RangeError(`command "canvas.setMode" argument "mode": "${l}" is not a mode this document `+`supports — it declares: ${d.join(", ")}`);if(l==="preview"){let f=c.session.ui.canvasMode;if(!he.has(f))throw RangeError(`command "canvas.setMode" argument "mode": "preview" composes with the edit and design base modes; this pane is in "${f}"`);c.session.ui.preview=!0;return}c.session.ui.preview=!1,e.setCanvasMode(c,l)},title:"Set Canvas Mode"},{args:ke({zoom:c1("Pan-zoom scale, 1 = 100%.",{maximum:F,minimum:j})}),category:"View",id:"canvas.setZoom",level:"document",menus:["palette"],group:"3_canvas",requires:"a document on the pan-zoom surface",when:k,enablement:()=>qt.has(e.getCanvasMode()),run:(s,a)=>{t("canvas.setZoom"),kp(Py("canvas.setZoom",a,"zoom",j,F))},title:"Set Zoom"},{args:ke({fit:{description:'How the document is framed: "width" | "page" | "none", or a numeric pan-zoom scale.',oneOf:[{enum:[...Qe],type:"string"},{maximum:F,minimum:j,type:"number"}]}}),category:"View",id:"canvas.setFit",level:"document",menus:["palette"],group:"3_canvas",requires:"a document on the pan-zoom surface",when:k,enablement:()=>qt.has(e.getCanvasMode()),run:(s,a)=>{t("canvas.setFit"),hC(Ro("canvas.setFit",a,"fit"))},title:"Set Fit"},{args:ke({zoom:c1("Edit-mode content zoom, 1 = 100%.",{maximum:Ye,minimum:Xe})}),category:"View",id:"canvas.setEditZoom",level:"document",menus:["palette"],group:"3_canvas",requires:"a document in edit mode",when:k,enablement:()=>e.getCanvasMode()==="edit",run:(s,a)=>{t("canvas.setEditZoom"),Zu(Py("canvas.setEditZoom",a,"zoom",Xe,Ye))},title:"Set Edit Zoom"},{args:{additionalProperties:!1,properties:{...o,width:{description:"How wide the Edit column should render, in CSS pixels, or null to go back to the chosen breakpoint's own width.",type:["number","null"]}},required:["width"],type:"object"},category:"View",id:"canvas.setEditWidth",level:"document",menus:["palette"],group:"3_canvas",requires:"a document in edit mode",when:k,enablement:()=>e.getCanvasMode()==="edit",run:(s,a)=>{let l=n("canvas.setEditWidth",a),{width:c}=a;if(c===null){xx(i(a)),r(a);return}_x(i(a),l,Py("canvas.setEditWidth",a,"width",Sp,1e4)),r(a)},title:"Set Edit Width"},{args:{additionalProperties:!1,properties:{...o,media:{description:"A breakpoint key the document renders under, or null for the base rendering.",type:["string","null"]}},required:["media"],type:"object"},category:"View",id:"canvas.setBreakpoint",level:"document",menus:["palette"],group:"3_canvas",requires:"an open document",when:k,run:(s,a)=>{let l=n("canvas.setBreakpoint",a),{media:c}=a;if(c!==null&&typeof c!=="string")throw RangeError('command "canvas.setBreakpoint" argument "media": expected a breakpoint key or null');let d=Object.keys(Oi(l.doc.document?.$media));if(c!==null&&!d.includes(c))throw RangeError(`command "canvas.setBreakpoint" argument "media": "${c}" is not a breakpoint this `+`document defines — it defines: ${d.length>0?d.join(", "):"nothing"}`);l.session.ui.activeMedia=c,r(a)},title:"Set Breakpoint"},{args:ke({...o,scheme:Ar(Ft,"Which color scheme the canvas renders in.")},["scheme"]),category:"View",id:"canvas.setColorScheme",level:"document",menus:["palette"],group:"3_canvas",requires:"an open document",when:k,run:(s,a)=>{let l=n("canvas.setColorScheme",a);l.session.ui.previewColorScheme=di("canvas.setColorScheme",a,"scheme",Ft),r(a)},title:"Set Color Scheme"},{args:ke({...o,locale:He("BCP 47 tag this pane renders as.")},["locale"]),category:"View",id:"i18n.switchLocale",level:"document",menus:["palette"],group:"3_canvas",requires:"an open document in a project that declares more than one locale",when:(s)=>s.document.open&&s.project.isMultilingual,run:(s,a)=>{let l=n("i18n.switchLocale",a),c=rt("i18n.switchLocale",a,"locale"),d=vs();if(d===null||!d.locales.includes(c))throw RangeError(`command "i18n.switchLocale" argument "locale": "${c}" is not a locale this `+`project declares — it declares: ${d===null?"nothing":d.locales.join(", ")}`);l.session.ui.previewLocale=c,r(a)},title:"Set Rendering Language"},{args:ke({...o,visible:sr("True to draw the page's layout elements, false to hide them.")},["visible"]),category:"View",id:"canvas.setLayoutVisible",level:"document",menus:["palette"],group:"3_canvas",requires:"an open document",when:k,run:(s,a)=>{let l=n("canvas.setLayoutVisible",a);l.session.ui.showLayout=xi("canvas.setLayoutVisible",a,"visible"),r(a)},title:"Show Layout Elements"},{args:ke({...o,open:sr("True to draw the popover open, false to close it."),path:{description:"Document path of the popover. Defaults to the popover the selection is in or at.",items:{type:["string","number"]},type:"array"}},[]),category:"View",enablement:()=>At(),group:"3_canvas",id:"canvas.setPopoverOpen",level:"document",menus:["palette"],requires:"a popover in the open document",run:(s,a)=>{let l=n("canvas.setPopoverOpen",a),c=a??{},d=c.open===void 0?!0:xi("canvas.setPopoverOpen",a,"open");if(!d&&c.path===void 0){e.setOpenPopover(l,null);return}let f=Ot(l,c.path);if(f===null)throw RangeError('command "canvas.setPopoverOpen" argument "path": names no popover in this document — '+"a popover is an element with a `popover` attribute, and <dialog> is not one");e.setOpenPopover(l,d?f:null)},title:"Show Popover",when:k},{args:ke({...o,open:sr("True to draw the dialog open, false to close it."),path:{description:"Document path of the dialog. Defaults to the dialog the selection is in or at.",items:{type:["string","number"]},type:"array"}},[]),category:"View",enablement:()=>Ht(),group:"3_canvas",id:"canvas.setDialogOpen",level:"document",menus:["palette"],requires:"a dialog in the open document",run:(s,a)=>{let l=n("canvas.setDialogOpen",a),c=a??{},d=c.open===void 0?!0:xi("canvas.setDialogOpen",a,"open");if(!d&&c.path===void 0){e.setOpenDialog(l,null);return}let f=Sx(l,c.path);if(f===null)throw RangeError('command "canvas.setDialogOpen" argument "path": names no dialog in this document — '+"a dialog is a <dialog> element, and a popover is not one");e.setOpenDialog(l,d?f:null)},title:"Show Dialog",when:k},{args:{additionalProperties:!1,properties:{...o,open:{default:!0,description:"True to open the resolving-with popover, false to close it.",type:"boolean"}},required:[],type:"object"},category:"View",id:"canvas.setResolvingOpen",level:"document",menus:["palette"],group:"3_canvas",requires:"an open document",when:k,run:(s,a)=>{n("canvas.setResolvingOpen",a);let{open:l,pane:c}=a;e.setResolvingOpen(typeof c==="string"?c:m.activePaneId,l===void 0||xi("canvas.setResolvingOpen",a,"open"))},title:"Show Resolving Values"},{args:{additionalProperties:!1,properties:{...o,name:He("The prop's name, as the component's state declares it."),value:{description:"The test value — any JSON. Null clears it and the prop returns to its default.",type:["string","number","boolean","array","object","null"]}},required:["name"],type:"object"},category:"View",id:"canvas.setTestProp",level:"document",menus:["palette"],group:"3_canvas",requires:"an open component document",when:k,run:(s,a)=>{let l=n("canvas.setTestProp",a),c=rt("canvas.setTestProp",a,"name"),d=Object.keys(l.doc.document?.state??{});if(!d.includes(c))throw RangeError(`command "canvas.setTestProp" argument "name": "${c}" is not a prop this component `+`declares — it declares: ${d.length>0?d.join(", "):"nothing"}`);let{value:f}=a,h={...l.session.ui.previewProps};if(f===null||f===void 0)delete h[c];else h[c]=f;l.session.ui.previewProps=Object.keys(h).length>0?h:null,r(a)},title:"Set Test Value"},{args:{additionalProperties:!1,properties:{...o,name:He("The route parameter's name, without brackets."),value:He("The value to preview the route with. Empty clears it.")},required:["name","value"],type:"object"},category:"View",id:"canvas.setRouteParam",level:"document",menus:["palette"],group:"3_canvas",requires:"an open page with a dynamic route",when:k,run:(s,a)=>{let l=n("canvas.setRouteParam",a),c=rt("canvas.setRouteParam",a,"name"),d=Hl(l.documentPath);if(!d.includes(c))throw RangeError(`command "canvas.setRouteParam" argument "name": "${c}" is not a parameter of this `+`route — it has: ${d.length>0?d.join(", "):"none"}`);l.session.ui.previewParams={...l.session.ui.previewParams,[c]:rt("canvas.setRouteParam",a,"value")},r(a)},title:"Set Route Parameter"}]}function oL(e,t){e.registerAll(Ho(t))}function ey(e=mo()){let t=Ku(e.paneId);for(let n of e.panels){let o=n.element?.querySelector('[part="panel-header"]');if(o){let r=t===null&&n.mediaName==="base"||t===null&&n.mediaName===null||t===n.mediaName;o.toggleAttribute("data-active",r)}}}function Zt(e){let{target:t,source:n,targetOrigin:o,acceptOrigin:r,token:i}=e,s=new Set,a=(l)=>{if(r!=="*"&&l.origin!==r)return;let c=l.data;if(!c||typeof c!=="object"||c["jx:canvas"]!==i)return;for(let d of s)d(c.payload)};return n.addEventListener("message",a),{dispose(){s.clear(),n.removeEventListener("message",a)},onMessage(l){return s.add(l),()=>s.delete(l)},post(l){t.postMessage({["jx:canvas"]:i,payload:l},o)}}}var Jo=null;function mx(){return Jo}var ve=new Set(["img","video","source","iframe","audio"]),ye="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",tt="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='32'%20height='32'%3E%3Crect%20width='32'%20height='32'%20fill='%23d0d0d0'/%3E%3C/svg%3E";function PT(e,t){e.addEventListener("error",(n)=>{let{target:o}=n;if(o instanceof HTMLImageElement&&o.getAttribute("src")!==tt)o.setAttribute("src",tt),o.removeAttribute("srcset"),o.dataset.placeholder=""},{capture:!0,signal:t})}var Lo=/(src|poster|image|bg|background|icon|logo|photo|avatar|thumbnail|cover|banner)$/i;function _o(e){return Lo.test(e)}var jo=new Set(["p","h1","h2","h3","h4","h5","h6","blockquote","li","dt","dd","th","td","span","strong","em","small","mark","code","abbr","q","sub","sup","time","a","button","label","legend","caption","summary","pre","option"]),qo=new Set(["div","section","article","aside","header","footer","main","nav","figure","figcaption","details","fieldset","form","ul","ol","dl","table"]);function Fo(e){if(!e.tagName||e.textContent||e.innerHTML)return null;if(e.$__layout)return null;if(Array.isArray(e.children)&&e.children.length>0)return null;if(jo.has(qe(e.tagName)))return"empty-text-placeholder";if(qo.has(qe(e.tagName)))return"empty-container-placeholder";return null}function et(e){return e.replaceAll(/\$\{([^}]+)\}/g,"❪ $1 ❫")}function Wo(e){let t=e.map;return{children:t&&typeof t==="object"?[I(t)]:[],className:"repeater-perimeter",tagName:"div"}}function I(e){if(!e||typeof e!=="object")return e;if(Array.isArray(e))return e.map((s)=>I(s));if(e.$prototype==="Array")return Wo(e);let t=e,n={},o=!1,r=ve.has(t.tagName||"");if(r){let{attributes:s,src:a}=t,l=s?.src,c=t.poster,d=s?.poster;if(!(a&&a!==""||l&&l!=="")&&!(c&&c!==""||d&&d!==""))o=!0}for(let[s,a]of Object.entries(t))if(s==="state"||s==="$media"||s==="$elements")n[s]=a;else if(s==="$props"&&a&&typeof a==="object"){let l={};for(let[c,d]of Object.entries(a))if(typeof d==="string"&&d.includes("${"))if(_o(c))l[c]=tt;else if(c==="href"||c==="action")l[c]="";else l[c]=et(d);else if(d&&typeof d==="object"&&d.$ref){let f=d.$ref,h=f.startsWith("#/state/")?f.slice(8):f;l[c]=`{${h}}`}else l[c]=d;n[s]=l}else if(s==="children")if(Array.isArray(a))n.children=a.map((l)=>I(l));else if(a&&typeof a==="object"&&a.$prototype==="Array")n.children=[I(a)];else n.children=I(a);else if(s==="cases"&&t.$switch&&a&&typeof a==="object"){let l=Object.keys(a);if(l.length>0){let c=a[l[0]];n.children=c&&typeof c==="object"&&!c.$ref?[I(c)]:[{style:{background:"color-mix(in srgb, var(--danger) 8%, transparent)",border:"1px dashed color-mix(in srgb, var(--danger) 40%, transparent)",borderRadius:"4px",color:"var(--danger)",fontFamily:"'JetBrains Mono', 'SF Mono', 'Fira Code', monospace",fontSize:"11px",fontStyle:"italic",padding:"6px 10px"},tagName:"div",textContent:`[$switch: ${l.join(" | ")}]`}]}}else if(s==="attributes"&&r&&a&&typeof a==="object"){let l=a,c={};for(let[d,f]of Object.entries(l))if(d==="src"||d==="poster")if(typeof f==="string"&&f!==""&&!f.includes("${"))c[d]=f;else o=!0,c[d]=ye;else if(typeof f==="string"&&f.includes("${")){let h=d==="href"||d==="action";c[d]=h?"":et(f)}else if(f&&typeof f==="object"&&f.$ref){let h=f.$ref,b=h.startsWith("#/state/")?h.slice(8):h;c[d]=`{${b}}`}else c[d]=f;n.attributes=c}else if(s==="style")if(a&&typeof a==="object"){let l={};for(let[c,d]of Object.entries(a))if(typeof d!=="string"||!d.includes("${"))l[c]=d;n.style=l}else n.style=a;else if(typeof a==="string"&&a.includes("${"))if((s==="src"||s==="poster")&&ve.has(t.tagName||""))o=!0,n[s]=ye;else{let c=s==="src"||s==="href"||s==="poster"||s==="action";n[s]=c?"":et(a)}else if(a&&typeof a==="object"&&a.$ref){let l=a.$ref,c=l.startsWith("#/state/")?l.slice(8):l;if((s==="src"||s==="poster")&&ve.has(t.tagName||""))o=!0,n[s]=ye;else n[s]=`{${c}}`}else if((s==="src"||s==="poster")&&a===""&&ve.has(t.tagName||""))o=!0,n[s]=ye;else n[s]=I(a);let i=Fo(n);if(i)n.className=n.className?`${n.className} ${i}`:i;if(o){let s=n.className||"";if(!s.includes("empty-media-placeholder"))n.className=s?`${s} empty-media-placeholder`:"empty-media-placeholder"}return n}function gx(e){return typeof e?.tagName==="string"&&e.tagName.includes("-")}function Xt(e){if(e===null||typeof e==="number"||typeof e==="boolean")return"literal";if(typeof e==="string")return e.includes("${")?null:"literal";if(Array.isArray(e))return"literal";if(typeof e==="object"){let t=e;if(t.$expression||t.$compute||t.$prototype||t.$handler)return null;return"default"in t||"type"in t?"signal":"literal"}return null}function HT(e){let t=e?.state??{},n=[];for(let[o,r]of Object.entries(t)){if(Qp(o))continue;let i=Xt(r);if(!i)continue;let s=i==="signal"?r.default:r;n.push({name:o,value:s})}return n}function Yt(e,t){let n={...e.state??{}},o=!1;for(let[r,i]of Object.entries(t)){let s=Xt(n[r]);if(!s)continue;n[r]=s==="signal"?{...n[r],default:i}:i,o=!0}if(!o)return e;return{...e,state:n}}function Qt(e,t=[]){if(!e||typeof e!=="object")return null;if(Array.isArray(e.children)){let n=e.children.findIndex((o)=>o&&typeof o==="object"&&!o.$__layout);if(n!==-1)return{offset:n,prefix:[...t,"children"]};for(let o=0;o<e.children.length;o++){let r=e.children[o];if(r&&typeof r==="object"&&r.$__layout){let i=Qt(r,[...t,"children",o]);if(i)return i}}}return null}function nt(e,t,n=[]){if(!e||typeof e!=="object")return;if(e.$__layout={file:t,path:n},Array.isArray(e.children))for(let[o,r]of e.children.entries()){if(typeof r==="string")continue;nt(r,t,[...n,"children",o])}if(Array.isArray(e.$elements)){for(let[o,r]of e.$elements.entries())if(typeof r!=="string")nt(r,t,[...n,"$elements",o])}}async function en(e,t,n=null){let o={documentPath:t?.documentPath,mode:t?.doc.mode},r=n??jl(t),i=r==="preview"?structuredClone(oe(e)):I(hh(e)),s=!1,a=o.documentPath&&D?.isSiteProject&&(o.documentPath.startsWith("pages/")||o.documentPath.startsWith("./pages/")),l=null,c=0;if(a&&t?.session.ui.showLayout!==!1){let w=Vl(e.$layout);if(w){let y=await ay(w);if(y){nt(y,w.replace(/^\.\//,""));let P=r==="preview"?structuredClone(oe(e)):i,x=fL(y,P);i=r==="preview"?x:I(hh(x)),s=!0;let T=Qt(x);l=T?.prefix??null,c=T?.offset??0}}}let d=Lp(D?.projectRoot),f=o.documentPath?new URL(o.documentPath,d).href:void 0,h=Rm(o.documentPath,{fileBaseUrl:d,...Ve()?{space:p().assetSpace}:{}});if(a&&t){let{previewParams:w}=t.session.ui;if(w&&Object.keys(w).length>0){let y=_t(e.state??null);i=Lt(i,w,o.documentPath),await jt(i,y,f)}}if(!a&&t&&gx(i)){let{previewProps:w}=t.session.ui;if(w&&Object.keys(w).length>0)i=Yt(i,w)}let b=new Set;if(r!=="preview")(function w(y,P){if(!y||typeof y!=="object")return;if(y.$prototype==="Array"){b.add(P.join("/"));let x=y.map;if(x&&typeof x==="object")w(x,[...P,"map"]);return}if(Array.isArray(y.children))for(let x=0;x<y.children.length;x++){let T=y.children[x];if(typeof T==="string")continue;w(T,[...P,"children",x])}else if(y.children&&typeof y.children==="object"&&y.children.$prototype==="Array")w(y.children,[...P,"children"]);if(y.$switch&&y.cases)for(let[x,T]of Object.entries(y.cases))w(T,[...P,"cases",x])})(e,[]);let M=o.documentPath!=null&&(o.documentPath.startsWith("layouts/")||o.documentPath.startsWith("./layouts/")),R=sy(i.$elements);if((o.mode==="content"||s||M)&&st.length>0){let w=new Set(R.map((P)=>typeof P==="string"?P:P?.$ref)),y=(P)=>{let x=new Set;if(!P||typeof P!=="object")return x;if(P.tagName)x.add(qe(P.tagName));if(Array.isArray(P.children)){for(let T of P.children)if(typeof T!=="string")for(let eo of y(T))x.add(eo)}return x};for(let P of y(i)){let x=st.find((T)=>T.tagName===P);if(x&&x.source!=="npm"&&x.path){let T=Nc(o.documentPath??null,x.path);if(!w.has(T))R.push({$ref:T}),w.add(T)}}}if(R.length>0)i.$elements=R;i.imports=hL(i.imports);let O=Oi(i.$media);if(O===void 0)delete i.$media;else i.$media=O;let U=pL(i.$head);if(U===void 0)delete i.$head;else i.$head=U;return{assets:h,docBase:f,mapperCtx:{arrayPaths:[...b],canvasMode:r,layoutWrapped:s,pageContentOffset:c,pageContentPrefix:l},renderDoc:i,siteStyle:D?.projectConfig?.style??null}}function vi(e){if(e==="--")return"Base";return e.replace(/^--/,"").replaceAll("-"," ").replaceAll(/\b\w/g,(t)=>t.toUpperCase())||e}var tn=new Set(["script","style","link","iframe","object","embed"]);function Id(e){let t={tagName:e};if(/^h[1-6]$/.test(e))t.textContent="Heading";else if(e==="p")t.textContent="Paragraph text";else if(e==="span"||e==="strong"||e==="em"||e==="small"||e==="mark"||e==="code"||e==="abbr"||e==="q"||e==="sub"||e==="sup"||e==="time")t.textContent="Text";else if(e==="a")t.textContent="Link",t.attributes={href:"#"};else if(e==="button")t.textContent="Button";else if(e==="label")t.textContent="Label";else if(e==="legend")t.textContent="Legend";else if(e==="caption")t.textContent="Caption";else if(e==="summary")t.textContent="Summary";else if(e==="li"||e==="dt"||e==="dd"||e==="th"||e==="td"||e==="option")t.textContent="Item";else if(e==="blockquote")t.textContent="Quote";else if(e==="pre")t.textContent="Preformatted text";else if(e==="input")t.attributes={placeholder:"Enter text...",type:"text"};else if(e==="img")t.attributes={alt:"Image"};else if(e==="iframe")t.attributes={src:""};else if(e==="slot")t.children=[{tagName:"p",textContent:"Slot content"}];else if(e==="select")t.children=[{tagName:"option",textContent:"Option 1"}];else if(e==="ul"||e==="ol")t.children=[{tagName:"li",textContent:"Item"}];else if(e==="dl")t.children=[{tagName:"dt",textContent:"Term"},{tagName:"dd",textContent:"Definition"}];else if(e==="table")t.children=[{children:[{children:[{tagName:"th",textContent:"Header"}],tagName:"tr"}],tagName:"thead"},{children:[{children:[{tagName:"td",textContent:"Cell"}],tagName:"tr"}],tagName:"tbody"}];else if(e==="details")t.children=[{tagName:"summary",textContent:"Summary"},{tagName:"p",textContent:"Detail content"}];return t}function V(e){if(!e)return[];if(Array.isArray(e.children))return e.children;return typeof e.textContent==="string"&&e.textContent.length>0?[e.textContent]:[]}function ee(e){let t=0;for(let n of e)t+=typeof n==="string"?n.length:ee(V(n));return t}function ot(e,t,n){let o=[],r=0;for(let i of e){if(r>=n)break;if(typeof i==="string"){let c=r+i.length;if(c>t){let d=i.slice(Math.max(0,t-r),Math.max(0,Math.min(n,c)-r));if(d)o.push(d)}r=c;continue}let s=V(i),a=ee(s),l=r+a;if(a===0){if(r>=t&&r<n)o.push({...i})}else if(l>t){let c=ot(s,Math.max(0,t-r),Math.min(n,l)-r);if(c.length>0)o.push(Vo(i,c))}r=l}return o}function Vo(e,t){let{children:n,textContent:o,...r}=e;if(t.length===0)return{...r,textContent:""};if(t.length===1&&typeof t[0]==="string")return{...r,textContent:t[0]};return{...r,children:t}}function nn(e){let t=[];for(let n of e){if(typeof n==="string"){if(n.length===0)continue;let o=t.at(-1);if(typeof o==="string"){t[t.length-1]=o+n;continue}}t.push(n)}return t}function on(e,t,n,o,r=""){return nn([...ot(e,0,t),...r?[r]:[],...ot(n,o,ee(n))])}function it(e){let t=nn(e);if(t.length===0)return{textContent:""};if(t.length===1&&typeof t[0]==="string")return{textContent:t[0]};return{children:t}}function Bo(e){if(!e)return!0;if(e.textContent!=null&&e.textContent.trim()==="")return!0;let t=e.children;if(!t)return!1;if(t.length===0)return!0;if(t.length===1&&typeof t[0]==="string"&&t[0].trim()==="")return!0;return t.length===1&&typeof t[0]==="object"&&t[0]?.tagName==="br"}function rn(e,t,n,o,r={}){if(!e)return;let i=K(e.doc.document,t);if(n){if(i&&JSON.stringify(i.children)===JSON.stringify(n))return;q(e,(s)=>{if(i?.textContent!=null)Ue(s,t,"textContent");Ue(s,t,"children",n)},{coalesceKey:r.coalesceKey??null})}else if(o!=null){if(i&&i.textContent===o&&!i.children)return;q(e,(s)=>{if(i?.children)Ue(s,t,"children");Ue(s,t,"textContent",o)},{coalesceKey:r.coalesceKey??null})}}function an(e,t,n,o){if(!e)return!1;let r=K(e.doc.document,t);if(!r)return!1;if(`${r.$props?.[n]??""}`===o)return!1;return q(e,(s)=>{oh(s,t,n,o)}),!0}function sn(e,t,n){if(!e)return null;let o=K(e.doc.document,t),r=K(e.doc.document,n);if(!o||!r)return null;if(il(t,n)||il(n,t))return null;let i=V(r),s=V(o),a=ee(i),l=it([...i,...s]);return q(e,(c)=>{if(l.children){if(r.textContent!=null)Ue(c,n,"textContent");Ue(c,n,"children",l.children)}else{if(r.children)Ue(c,n,"children");Ue(c,n,"textContent",l.textContent??"")}if(rh(c,t),ln(c,ht(t)),Hp(e))c.session.selection=[n]}),{offset:a,path:n}}function ln(e,t){let n=t;while(n.length>0){let o=K(e.doc.document,n),r=o?.children;if(!o||!Array.isArray(r)||r.length>0)return;let i=ht(n);if(rh(e,n),!i)return;n=i}}function cn(e,t,n,o){let r=ht(t),i=Cn(t),s=[...r,"children",i+1];if(!e)return s;let a={tagName:"p"};if(o.textContent!=null)a.textContent=o.textContent;else if(o.children)a.children=o.children;else a.textContent="";return q(e,(l)=>{if(n.textContent!=null)Ue(l,t,"children"),Ue(l,t,"textContent",n.textContent);else if(n.children)Ue(l,t,"textContent"),Ue(l,t,"children",n.children);if(Zi(l,r,i+1,a),Hp(e))l.session.selection=[s]}),s}function un(e,t,n,o){if(Bo(o)){if(!e)return t;return q(e,(l)=>{Ue(l,t,"tagName",n.tag),Ue(l,t,"children");let c=Id(n.tag);if(c.textContent&&c.textContent!=="Paragraph text")Ue(l,t,"textContent",c.textContent);else Ue(l,t,"textContent");if(Hp(e))l.session.selection=[t]}),t}let r=ht(t),i=Cn(t),s=[...r,"children",i+1];if(!e)return s;let a=Id(n.tag);return q(e,(l)=>{if(o?.children)Ue(l,t,"textContent"),Ue(l,t,"children",o.children);else if(o?.textContent!=null)Ue(l,t,"children"),Ue(l,t,"textContent",o.textContent);if(Zi(l,r,i+1,structuredClone(a)),Hp(e))l.session.selection=[s]}),s}function dn(e,t,n,o,r){if(!e)return null;let i=K(e.doc.document,t.path),s=K(e.doc.document,n.path);if(!i||!s)return null;if(il(t.path,n.path)||il(n.path,t.path))return null;let a=it(on(V(i),t.offset,V(s),n.offset,r)),l=[...o,n.path].toSorted(zo);return q(e,(c)=>{if(a.children){if(i.textContent!=null)Ue(c,t.path,"textContent");Ue(c,t.path,"children",a.children)}else{if(i.children)Ue(c,t.path,"children");Ue(c,t.path,"textContent",a.textContent??"")}for(let d of l)if(K(c.doc.document,d))rh(c,d),ln(c,ht(d));if(Hp(e))c.session.selection=[t.path]}),{offset:t.offset+r.length,path:t.path}}function zo(e,t){let n=Math.min(e.length,t.length);for(let o=0;o<n;o++){let r=e[o],i=t[o];if(r===i)continue;if(typeof r==="number"&&typeof i==="number")return i-r;return String(i).localeCompare(String(r))}return t.length-e.length}function N(e,t=1){return{height:e.height*t,left:e.x*t,top:e.y*t,width:e.width*t}}function zT(e,t,n=1){return{x:(e.x-t.left)/n,y:(e.y-t.top)/n}}function be(e,t){if(!t){e.style.display="none";return}e.style.display="block",e.style.left=`${t.left}px`,e.style.top=`${t.top}px`,e.style.width=`${t.width}px`,e.style.height=`${t.height}px`}function pn(e=document){let t=e.createElement("div");t.className="jx-canvas-iframe-overlay",t.style.cssText="position:absolute;inset:0;pointer-events:none;overflow:hidden;z-index:2";let n=e.createElement("div");n.className="overlay-box overlay-selection",n.style.display="none";let o=e.createElement("div");o.className="overlay-label",o.style.display="none",n.append(o);let r=e.createElement("div");r.className="overlay-box overlay-hover",r.style.display="none";let i=e.createElement("div");i.className="canvas-drop-indicator",i.style.display="none";let s=e.createElement("button");s.className="insertion-helper",s.textContent="+",s.style.pointerEvents="auto",s.style.display="none";let a=e.createElement("div");a.className="canvas-replace-target",a.style.display="none";let l=e.createElement("div");l.className="overlay-presence-group";let c=e.createElement("div");return c.className="overlay-coselection-group",t.append(r,n,c,i,a,s,l),{dispose:()=>t.remove(),insertButton:s,root:t,setDropIndicator:(d,f="inside")=>Uo(i,d,f),setHover:(d)=>be(r,d),setInsertZone:(d,f="center")=>Ko(s,d,f),setReplaceTarget:(d)=>be(a,d),setSuppressed:(d)=>{t.style.display=d?"none":""},setCoSelection:(d)=>{c.replaceChildren();for(let f of d){let h=e.createElement("div");h.className="overlay-box overlay-selection overlay-coselection",be(h,f),c.append(h)}},setPresence:(d)=>{l.replaceChildren();for(let f of d){let h=e.createElement("div");h.className="overlay-box overlay-presence",h.style.cssText=`position:absolute;display:block;pointer-events:none;outline:1.5px solid ${f.color};outline-offset:1px;left:${f.placement.left}px;top:${f.placement.top}px;width:${f.placement.width}px;height:${f.placement.height}px`;let b=e.createElement("div");b.className="overlay-presence-tag",b.textContent=f.label,b.style.cssText=`position:absolute;top:-18px;left:-2px;padding:1px 5px;border-radius:3px;font:10px/1.4 sans-serif;color:#fff;white-space:nowrap;background:${f.color}`,h.append(b),l.append(h)}},setSelection:(d,f=null)=>{if(be(n,d),d&&f)o.textContent=f,o.style.display="block";else o.style.display="none"}}}function Ko(e,t,n){if(!t){e.style.display="none",e.classList.remove("visible");return}e.dataset.edge=n,e.classList.add("visible"),e.style.display="grid",e.style.left=`${t.left+t.width/2}px`,e.style.top=`${t.top+t.height/2}px`,e.style.translate="-50% -50%"}function Uo(e,t,n){if(!t){e.style.display="none";return}if(e.style.display="block",e.style.left=`${t.left}px`,e.style.width=`${t.width}px`,n==="inside"){e.className="canvas-drop-indicator inside",e.style.top=`${t.top}px`,e.style.height=`${t.height}px`;return}e.className="canvas-drop-indicator line",e.style.height="",e.style.top=`${n==="top"?t.top:t.top+t.height}px`}function Bl(e){return JSON.stringify(e)}var J=null;function Go(e){if(J?.isConnected)return J;let t=e.createElement("div");return t.className="jx-drag-ghost",t.style.cssText="position:fixed;left:0;top:0;z-index:9999;pointer-events:none;display:none;padding:2px 8px;border-radius:4px;font-size:12px;line-height:1.4;white-space:nowrap;background:var(--accent,#3b82f6);color:var(--accent-fg,#fff);box-shadow:0 2px 8px rgba(0,0,0,0.25);transform:translate(8px,8px)",e.body.append(t),J=t,t}function gC(e,t,n,o=document){let r=Go(o);r.textContent=e,r.style.left=`${t}px`,r.style.top=`${n}px`,r.style.display="block"}function Ex(e,t){if(!J||J.style.display==="none")return;J.style.left=`${e}px`,J.style.top=`${t}px`}function Od(){if(J)J.style.display="none"}var fn=function(){if(typeof window>"u")return null;var e=new Image;return e.src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==",e}();function Dc(e){var t=e.nativeSetDragImage;if(t&&fn)t(fn,0,0)}function mn(e,t){if(e==null)return{};var n={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(t.indexOf(o)!==-1)continue;n[o]=e[o]}return n}function hn(e,t){if(e==null)return{};var n,o,r=mn(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o<i.length;o++)n=i[o],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function xe(e,t){var n=Object.keys(e),o=Object.keys(t);if(n.length!==o.length)return!1;return n.every(function(r){return Object.is(e[r],t[r])})}function gn(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:xe,t=null;return function(n){if(t&&e(t.value,n))return t.value;return t={value:n},t.value}}var Zo=["block"];function vn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),n.push.apply(n,o)}return n}function yn(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?vn(Object(n),!0).forEach(function(o){Ea(e,o,n[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):vn(Object(n)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(n,o))})}return e}function Xo(e){return{x:(e.right+e.left)/2,y:(e.bottom+e.top)/2}}function at(e){var{client:t,borderBox:n}=e,o=n.height/4;if(t.y<=n.top+o)return"reorder-above";if(t.y>=n.bottom-o)return"reorder-below";return"make-child"}function Yo(e){var{element:t,input:n,currentLevel:o,indentPerLevel:r,mode:i}=e,s={x:n.clientX,y:n.clientY},a=t.getBoundingClientRect();if(i==="standard"){var l=at({borderBox:a,client:s});return{type:l,indentPerLevel:r,currentLevel:o}}var c=Xo(a);if(i==="expanded"){var d=at({borderBox:a,client:s});return{type:d==="reorder-above"?d:"make-child",indentPerLevel:r,currentLevel:o}}var f=r*o;if(s.x<a.left+f){if(s.y<c.y)return{type:"reorder-above",indentPerLevel:r,currentLevel:o};var h=(s.x-a.left)/r,b=Math.max(Math.floor(h),0);return{type:"reparent",desiredLevel:b,indentPerLevel:r,currentLevel:o}}return{type:at({borderBox:a,client:s}),indentPerLevel:r,currentLevel:o}}function bn(e,t){if(e.type!==t.type)return!1;if(e.type==="instruction-blocked"&&t.type==="instruction-blocked")return bn(e.desired,t.desired);return xe(e,t)}var Qo=gn(bn);function er(e){var{desired:t,block:n}=e;if(n!==null&&n!==void 0&&n.includes(t.type)&&t.type!=="instruction-blocked"){var o={type:"instruction-blocked",desired:t};return o}return t}function ty(e,t){var n=t.block,o=hn(t,Zo),r=Yo(o),i=er({desired:r,block:n}),s=Qo(i);return yn(yn({},e),{},Ea({},we,s))}function Xu(e){var t;return(t=e[we])!==null&&t!==void 0?t:null}var we=Symbol("tree-item-instruction");function ct(e){return typeof e==="object"&&e!==null&&typeof e.$ref==="string"?e.$ref:null}function Ce(e){if(e.source!=="npm"||!e.package)return null;return e.modulePath?`${e.package}/${e.modulePath}`:e.package}function tr(e,t){let n=Ce(e);if(n)return n;return e.path?{$ref:Nc(t,e.path)}:null}function bC(e,t,n){let o=Ce(t);if(o)return e.some((i)=>typeof i==="string"&&(i===o||i===t.package));if(!t.path)return!1;let r=G(Nc(n,t.path));return e.some((i)=>{let s=ct(i);return s!==null&&G(s)===r})}function G(e){return e.replace(/^(?:\.\/)+/,"")}function vm(e,t,n){let o=tr(t,n);if(!o)return[...e];let i=Ce(t)&&t.modulePath?e.filter((s)=>s!==t.package):[...e];return bC(i,t,n)?i:[...i,o]}function yC(e,t,n){let o=Ce(t);if(o)return e.filter((i)=>!(typeof i==="string"&&(i===o||i===t.package)));if(!t.path)return[...e];let r=G(Nc(n,t.path));return e.filter((i)=>{let s=ct(i);return s===null||G(s)!==r})}function sL(e,t){return e.filter((n)=>typeof n!=="string"||!(n===t||n.startsWith(`${t}/`)))}function aL(e,t){let n=G(t);return e.filter((o)=>{let r=ct(o);return r===null||G(r)!==n})}async function Tx(e){Kp(!0);try{if(e.source==="npm"){if(!customElements.get(e.tagName))return ut(e.tagName)}else{if(e.path&&!e.path.endsWith(".json"))return ut(e.tagName);let n=D?.projectRoot,o=`${location.origin}/${n?`${n}/`:""}${e.path}`;await Ym(o)}let t=document.createElement(e.tagName);for(let n of e.props||[])if(n.default!==void 0&&n.default!=="false"&&n.default!=="''"){let o=String(n.default).replaceAll(/^'|'$/g,"");t.setAttribute(n.name,o)}return t}catch(t){return console.warn("Component preview failed:",e.tagName,t),ut(e.tagName)}}function ut(e){let t=document.createElement("div");return t.style.cssText="padding:12px;border:1px dashed var(--border);border-radius:var(--radius);color:var(--fg-dim)",t.textContent=`<${e}>`,t}var nr='[part="outline"]',dt='[part="row"]',or='[part="verbs"]',Pe=null;function lL(){if(Pe!==null)cancelAnimationFrame(Pe);for(let e of Je.dndCleanups)e();Je.dndCleanups=[],Pe=requestAnimationFrame(()=>{Pe=null;let e=ph?.querySelector(nr);if(!e)return;for(let n of e.querySelectorAll("[data-dnd-row]")){let o=n.dataset.value.split("/").map((l)=>/^\d+$/.test(l)?Math.trunc(Number(l)):l),r=Math.trunc(Number(n.dataset.dndDepth))||0,i=Object.hasOwn(n.dataset,"dndVoid"),s=Object.hasOwn(n.dataset,"dndExpanded"),a=xo(_s({canDrag({element:l,input:c}){if(Ky(c.clientX,c.clientY)?.closest(or))return!1;return!0},element:n,getInitialData(){return{path:o,type:"tree-node"}},onGenerateDragPreview({nativeSetDragImage:l}){Dc({nativeSetDragImage:l})},onDragStart(){if(n.dataset.dragging="",Je.layerDragSourceHeight=n.offsetHeight,s)rr(n,e)},onDrop(){if(delete n.dataset.dragging,s)Ai("leftPanel")}}),Ks({element:n,canDrop({source:l}){let c=l.data.path;if(c&&il(c,o))return!1;return!0},getData({input:l,element:c}){return ty({path:o},{block:i?["make-child"]:[],currentLevel:r,element:c,indentPerLevel:16,input:l,mode:s?"expanded":"standard"})},onDragEnter({self:l}){xn(n,l.data,e)},onDrag({self:l}){xn(n,l.data,e)},onDrop(){te(e)}}));Je.dndCleanups.push(a)}let t=Js({onDrop({source:n,location:o}){te(e);let[r]=o.current.dropTargets;if(!r)return;let i=Xu(r.data);if(!i||i.type==="instruction-blocked")return;let s=n.data,a=r.data.path,l=s.type==="tree-node"&&n.element,c=l&&Object.hasOwn(l.dataset,"dndExpanded");if(wm(u.value,i,s,a),c){let d=u.value,f=Le(d?.session.selection);if(f)Je._layersCollapsed||=new Set,Je._layersCollapsed.add(f.join("/"))}},onDropTargetChange({location:n}){let[o]=n.current.dropTargets;if(o&&!Xu(o.data))te(e)}});Je.dndCleanups.push(t)})}function cL(){requestAnimationFrame(()=>{let e=ph?.querySelector(".components-section");if(!e)return;for(let t of e.querySelectorAll("[data-component-tag]")){let n=t.dataset.componentTag;if(!n)continue;let o=st.find((a)=>a.tagName===n);if(!o)continue;let r=t.querySelector(".element-card-preview");if(r&&!r.querySelector(n))Tx(o).then((a)=>{r.textContent="",r.append(a)});let i=Em(o),s=_s({element:t,getInitialData(){return{fragment:structuredClone(i),type:"block"}},onGenerateDragPreview({nativeSetDragImage:a}){Dc({nativeSetDragImage:a})}});Je.dndCleanups.push(s)}})}function dL(){requestAnimationFrame(()=>{let e=ph?.querySelector('[part="content"]');if(!e)return;for(let t of e.querySelectorAll("[data-block-tag]")){let n=t.dataset.blockTag,o=t.querySelector(".element-card-preview");if(o&&!o.firstChild){let s=document.createElement(tn.has(n)?"span":n);s.textContent=n,o.append(s)}let r=Id(n),i=_s({element:t,getInitialData(){return{fragment:structuredClone(r),type:"block"}},onGenerateDragPreview({nativeSetDragImage:s}){Dc({nativeSetDragImage:s})}});Je.dndCleanups.push(i)}})}function rr(e,t){let n=`${e.dataset.value}/`,o=t.querySelectorAll(dt);for(let r of o)if(r.dataset.value?.startsWith(n))r.style.display="none"}function xn(e,t,n){let o=Xu(t);if(Je._currentDropTargetRow&&Je._currentDropTargetRow!==e)delete Je._currentDropTargetRow.dataset.drop;if(!o||o.type==="instruction-blocked"){te(n);return}if(o.type==="make-child"){te(n),e.dataset.drop="",Je._currentDropTargetRow=e;return}delete e.dataset.drop,Je._currentDropTargetRow=e;let r=[...n.querySelectorAll(dt)],i=r.indexOf(e),s=Je.layerDragSourceHeight;for(let a=0;a<r.length;a++){if(r[a].dataset.dragging!==void 0)continue;if(o.type==="reorder-above")r[a].style.transform=a>=i?`translateY(${s}px)`:"";else r[a].style.transform=a>i?`translateY(${s}px)`:""}}function te(e){if(Je._currentDropTargetRow)delete Je._currentDropTargetRow.dataset.drop,Je._currentDropTargetRow=null;let t=e.querySelectorAll(dt);for(let n of t)n.style.transform="",n.style.display=""}function wm(e,t,n,o){if(!e)return;let r=e.doc.document;if(n.type==="tree-node"){let i=n.path,s=ht(o),a=Cn(o);if(t.type!=="make-child"&&(!s||typeof a!=="number"))return;switch(t.type){case"reorder-above":{q(e,(l)=>Sa(l,i,s,a));break}case"reorder-below":{q(e,(l)=>Sa(l,i,s,a+1));break}case"make-child":{let l=K(r,o),c=Cr(l).length;q(e,(d)=>Sa(d,i,o,c));break}default:break}}else if(n.type==="block"){let i=ht(o),s=Cn(o);if(t.type!=="make-child"&&(!i||typeof s!=="number"))return;switch(t.type){case"reorder-above":{q(e,(c)=>Zi(c,i,s,structuredClone(n.fragment)));break}case"reorder-below":{q(e,(c)=>Zi(c,i,s+1,structuredClone(n.fragment)));break}case"make-child":{let c=K(r,o),d=Cr(c).length;q(e,(f)=>Zi(f,o,d,structuredClone(n.fragment)));break}default:break}let l=n.fragment?.tagName;if(qe(l).includes("-")){let c=st.find((h)=>h.tagName===l),d=e.doc.document?.$elements??[],f=c?vm(d,c,e.documentPath??null):d;if(f.length!==d.length)qs(e,(h)=>{h.$elements=f})}}}function wn(e){let t={};for(let[n,o]of Object.entries(e?.nesting??{}))if(n!=="_root")t[n]=o?.inline===!0;for(let n of e?.inline??[])t[n]=!1;return t}var Re=new WeakMap,g=new Set,z=0,ie=new Map,Dn=-1,Hn=0,ir=600;function vC(e){return Dn===e&&Date.now()-Hn<=ir}var Pn=0,Jn=new Set;function lr(e,t){let n;try{n=new URL(e,t.iframe.src||Lm())}catch{return}if(!["http:","https:","mailto:","tel:"].includes(n.protocol))return;let o=n.href,r=mx();if(r){r(o);return}window.open(o,"_blank","noopener,noreferrer")}function wC(e){Jn.add(e)}function cr(e){return Jn.delete(e)}var L=new Map,Z=new Map,ae=new Map,ur=300;function xC(e,t,n,o=ur){let r=null;for(let a of g){if(!a.iframe.isConnected){g.delete(a);continue}if(a.ready&&!a.stylebook&&e!==null&&a.tabId===e){r=a;break}}if(!r)return Promise.resolve(null);Pn+=1;let i=Pn,s=JSON.parse(JSON.stringify(t));return r.channel.post({contextPath:n?[...n]:null,exprs:s,gen:r.lastRenderedGen,kind:"evalExpr",reqId:i}),new Promise((a)=>{let l=setTimeout(()=>{L.delete(i),Z.delete(i),a(null)},o);Z.set(i,r),L.set(i,(c)=>{clearTimeout(l),Z.delete(i),a(c)})})}var En=0,X=new Map,dr=250;function _C(e,t=dr){let n=[];for(let o of g){if(!o.iframe.isConnected){g.delete(o);continue}if(o.ready&&!o.stylebook&&e!==null&&o.tabId===e)n.push(o)}if(n.length===0)return Promise.resolve();return new Promise((o)=>{let r=n.length,i=setTimeout(()=>{for(let l of a)X.delete(l),ae.delete(l);o()},t),s=()=>{if(r-=1,r===0)clearTimeout(i),o()},a=[];for(let l of n){En+=1;let c=En;a.push(c),X.set(c,s),ae.set(c,l),l.channel.post({kind:"flushEdits",reqId:c})}})}function Lx(e){return Re.get(e)??null}function xm(e){for(let t of g){if(!t.iframe.isConnected)continue;let n=Ie(t.iframe);if(e.x>=n.left&&e.x<=n.right&&e.y>=n.top&&e.y<=n.bottom)return t}return null}function _m(e,t,n){z+=1,ie.set(z,n);let o=t.type==="tree-node"?{path:[...t.path],type:"tree-node"}:{type:t.type};return e.channel.post({dragSeq:z,gen:e.lastRenderedGen,kind:"dragStart",src:o}),z}function Rx(){return z}function Qa(e){let t=Ie(e.iframe),n=e.iframe.clientWidth>0?t.width/e.iframe.clientWidth:1;return{rect:t,scale:n}}function Ln(e){if(e.stylebook)return"stylebook";return e.tabId??"unbound"}function SC(){let e=[];for(let t of g){if(!t.iframe.isConnected){g.delete(t);continue}let n=`canvas[${Ln(t)}]`;if(!t.ready){e.push(`${n}: frame has not handshaked`);continue}let o=[...t.pendingTabIds.keys()];if(o.length>0)e.push(`${n}: gen ${o.join(", ")} unacked`);if(t.pendingPatches>0)e.push(`${n}: ${t.pendingPatches} unacked patch(es)`);if(t.pendingMeasures.size>0)e.push(`${n}: ${t.pendingMeasures.size} measure(s) in flight`);let{idle:r}=t;if(!r){e.push(`${n}: no quiescence report yet`);continue}if(r.gen!==t.lastRenderedGen)e.push(`${n}: quiescence is for gen ${r.gen}, DOM is gen ${t.lastRenderedGen}`);if(!r.fonts)e.push(`${n}: fonts still loading`);if(r.animations>0)e.push(`${n}: ${r.animations} running animation(s)`);if(r.images>0)e.push(`${n}: ${r.images} pending image retry(ies)`)}if(L.size>0)e.push(`canvas: ${L.size} expression eval(s) in flight`);return e}var pr=500,fr=2,mr=40;function _n(){let e=u.value?.id??null,t=null;for(let n of g){if(!n.iframe.isConnected){g.delete(n);continue}if(!n.ready||n.stylebook)continue;if(n.tabId===e)return n;t??=n}return t}function jn(e,t){let{rect:n,scale:o}=Qa(e),r=n.left+t.x*o,i=n.top+t.y*o,s=t.width*o,a=t.height*o;return{height:a,left:r,top:i,width:s,x:r+s/2,y:i+a/2}}function se(e,t){return new Promise((n)=>{e.selReqId+=1;let o=e.selReqId,r=setTimeout(()=>{e.pendingMeasures.delete(o),n(null)},pr);e.pendingMeasures.set(o,(i)=>{clearTimeout(r);let[s]=i;n(s?jn(e,s.rect):null)}),e.channel.post({kind:"measure",paths:[[...t]],reqId:o})})}function CC(e){let t=Lx(e),n=t?.lastHover;if(!t||!n)return null;return{settle:async()=>(await se(t,n.path))?.top??null,top:jn(t,n.rect).top}}function kC(e){let t=_n();return t?se(t,e):Promise.resolve(null)}function hr(e){return new Promise((t)=>{let n=Number.NaN,o=0,r=0,i=()=>{let{top:s}=Ie(e.iframe);if(o=s===n?o+1:0,n=s,r+=1,o>=fr||r>=mr){t();return}requestAnimationFrame(i)};requestAnimationFrame(i)})}async function Sm(e){let t=_n();return t?vI(t,e):null}async function vI(e,t){let n=await se(e,t);if(!n)return null;let o=_(e.canvasEl)?.surface;return Qb({height:n.height,top:n.top},o),await hr(e),se(e,t)}function OI(e,t){let n=Lx(e);return n?se(n,t):Promise.resolve(null)}function gr(e){let t=e.canvasEl.parentElement;if(!t)return;let n=/scale\(([\d.]+)\)/.exec(e.canvasEl.style.transform),o=n?Number(n[1]):1;t.style.height=o===1?"":`${e.iframe.offsetHeight*o}px`}function qn(e){if(e.preview){e.iframe.style.height="100%",e.iframe.style.minHeight="0px";return}if(e.contentHeight===null)return;e.iframe.style.height=`${e.contentHeight}px`,e.iframe.style.minHeight=e.contentFragment?"0px":"480px",gr(e)}function vt(e,t){if(e.preview=t,e.overlay.setSuppressed(t),t)e.pendingEnterEdit=null;qn(e)}function EC(e,t){vt(bt(e),t)}function Wl(e,t){if(!e.iframe.isConnected)return;e.channel.post(t)}function ny(e){ie.delete(e)}function iy(e){e.overlay.setDropIndicator(null)}var Fn=null;function TC(e){Fn=e}var vr=300,Vn=null;function LC(e){Vn=e}var yt=null;function RC(e){yt=e}function yr(e,t,n){if((t?br(t.tagName):!1)&&t){e.overlay.setDropIndicator(null),e.overlay.setReplaceTarget(N(t.rect));return}e.overlay.setReplaceTarget(null),e.overlay.setDropIndicator(n?N(n.referenceRect):null,n?.edge)}function Tn(e){e.overlay.setReplaceTarget(null),e.overlay.setDropIndicator(null)}function br(e){return e==="img"||e==="video"||e==="source"}function xr(e,t){if(e.dataset.jxGutterDrop==="1")return;e.dataset.jxGutterDrop="1",e.addEventListener("dragover",(n)=>{if(![...n.dataTransfer?.types??[]].includes("Files"))return;if(n.preventDefault(),n.dataTransfer)n.dataTransfer.dropEffect="copy"}),e.addEventListener("drop",(n)=>{let o=n.dataTransfer?.files,r=t();if(!o?.length||!r||r.stylebook)return;n.preventDefault(),yt?.(E(r),[...o],null,null)})}var Te=null;function $C(e){Te=e}var Me=null;function IC(e){Me=e}var Bn=null;function DC(e){Bn=e}function Mn(e,t){let n=[...t];for(;;){let o=e.get(Bl(n));if(o)return o;if(n.length<2)return null;n=n.slice(0,-2)}}var S=null;function NC(){let e=S;return Boolean(e?.editing&&e.iframe.isConnected)}var Ne=null;function OC(e){Ne=e}var gt=null;function AC(e){gt=e}var Nn=null,zn=null;function PC(e){zn=e}function MC(e,t){for(let n of g){if(!n.iframe.isConnected){g.delete(n);continue}if(n.ready&&n.tabId===e.id&&!n.preview)n.popoverOpen=t,n.channel.post({kind:"setPopoverOpen",path:t})}}function FC(e,t){for(let n of g){if(!n.iframe.isConnected){g.delete(n);continue}if(n.ready&&n.tabId===e.id&&!n.preview)n.dialogOpen=t,n.channel.post({kind:"setDialogOpen",path:t})}}function $x(e,t){let n=0;for(let o of g){if(!o.iframe.isConnected){g.delete(o);continue}if(o.ready&&o.tabId===t){let r=_(o.canvasEl)?.surface;if(!r){Jb("host-stage-unresolved");continue}let i=r.renderGeneration,s=Oe?.host===o?Oe.paths:void 0;Ae(o),o.channel.post(s?{echoPaths:s,forwardOps:e,gen:i,kind:"patch"}:{forwardOps:e,gen:i,kind:"patch"}),o.pendingPatches+=1,n+=1}}return n}var Oe=null,wr=0;function kn(e,t,n){Oe={host:e,paths:t};try{n()}finally{Oe=null}}var pt=null,ft=null;function Pr(e,t,n){return!e&&t===n}function Er(e,t){let n=E(e);if(!n)return;let o=K(n.doc.document,t);if(!o)return;$x([{key:"$props",op:"set-key",path:t,value:o.$props}],n.id)}function E(e){return e.tabId?m.tabs.get(e.tabId)??null:null}function jC(e){return E(e)}function Ee(e){let t=_(e.canvasEl)?.surface.paneId;if(t)Mo(t)}var Tr=Object.freeze([]);function Mr(){let e=new Map;for(let t of m.panes){let n=t.activeTabId?m.tabs.get(t.activeTabId):null;if(!n)continue;let o=n.session.selection??[];o.map((r)=>r.join("/")).join("|"),e.set(n.id,o)}return e}function Nr(){if(Nn)return;let e=ge(!0);e.run(()=>{Q(()=>{let t=Mr();v.stylebook.selection;for(let n of g)$e(n,(n.tabId?t.get(n.tabId):null)??Tr)})}),Nn={stop:()=>e.stop()}}function Ae(e){if(!e.ready)return;let t=Wd();if(t===e.postedVersions)return;if(e.postedVersions===null&&Object.keys(t).length===0){e.postedVersions=t;return}e.postedVersions=t,e.channel.post({kind:"assetVersions",versions:t})}var Rn=!1,mt=!1;function kr(){if(Rn)return;Rn=!0,ge(!0).run(()=>{Q(()=>{if(n1.value,mt)return;mt=!0,queueMicrotask(()=>{mt=!1,Rr()})})})}function Rr(){for(let e of g){if(!e.iframe.isConnected){g.delete(e);continue}Ae(e)}}var On=!1,Se=null;function Or(){if(On)return;On=!0,ge(!0).run(()=>{Q(()=>{for(let t of m.panes){let n=t.activeTabId?m.tabs.get(t.activeTabId):null;if(!n)continue;let{peers:o}=Sn(n);o.map((r)=>JSON.stringify(r.state.structuralSelection??null)).join("|")}if(Se)clearTimeout(Se);Se=setTimeout(()=>{Se=null;for(let t of g)Kn(t)},100)})})}function Kn(e){if(e.stylebook||!e.ready||!e.iframe.isConnected)return;let t=E(e),n=t?Sn(t).peers:[];e.presenceMeta.clear();let o=[];for(let r of n){let{structuralSelection:i}=r.state;if(!i||r.state.focusedPath!==t?.documentPath)continue;for(let s of i){let a=[...s];o.push(a),e.presenceMeta.set(JSON.stringify(a),{color:r.state.user.color,label:r.state.user.name??r.state.user.login})}}if(o.length===0){e.presenceReqId=-1,e.overlay.setPresence([]);return}e.selReqId+=1,e.presenceReqId=e.selReqId,e.channel.post({kind:"measure",paths:o,reqId:e.presenceReqId})}function $e(e,t){if(e.stylebook){Ir(e);return}let n=Le(t);if(e.selectionPath=n,e.selectionPaths=t,!e.iframe.isConnected){g.delete(e);return}if(!n){e.coSelectionKeys.clear(),e.overlay.setSelection(null),e.overlay.setCoSelection([]);return}if(!e.ready)return;let o=xs(t.slice(0,-1));e.coSelectionKeys=new Set(o.map((r)=>JSON.stringify(r))),e.selReqId+=1,e.channel.post({kind:"measure",paths:[[...n],...o],reqId:e.selReqId})}function Ir(e){if(!e.iframe.isConnected){g.delete(e);return}let t=v.stylebook.selection,n=t?e.stylebook?.tagToCardPath.get(t):void 0;if(!t||!n){e.overlay.setSelection(null);return}if(!e.ready)return;e.selReqId+=1,e.channel.post({kind:"measure",paths:[[...n]],reqId:e.selReqId})}function An(){return ov("../canvas.html")}var $r="about:blank";function Un(e){e.channel.dispose();for(let[t,n]of L)if(Z.get(t)===e)L.delete(t),Z.delete(t),n(null);for(let[t,n]of X)if(ae.get(t)===e)X.delete(t),ae.delete(t),n();for(let[,t]of e.pendingMeasures)t([]);if(e.pendingMeasures.clear(),e.pendingTabIds.clear(),le(e),S===e)S=null;e.overlay.root.remove(),e.iframe.remove(),Re.delete(e.canvasEl),g.delete(e)}function Dr(){if(!Ve())return An();let e=p();if(e.canvasUrl)return e.canvasUrl;return e.canvasUrlDeferred?$r:An()}function Cm(e){let t=0;for(let n of new Set(g))if(e.contains(n.canvasEl))Un(n),t+=1;return t}function bt(e){let t=Dr(),n=Re.get(e);if(n){if(n.canvasUrl===t)return n;Un(n)}let o=location.origin,r=crypto.randomUUID(),i=new URL(t,location.href).origin,s=document.createElement("iframe");s.className="jx-canvas-iframe",s.title="Canvas — live page render",s.style.cssText="width:100%;min-height:480px;height:100%;border:0;display:block;background:#fff";let a=new URL(t,location.href);if(a.searchParams.set("token",r),location.protocol==="http:"||location.protocol==="https:")a.searchParams.set("parentOrigin",o);if(s.src=i===o?`${a.pathname}${a.search}`:a.href,!e.style.position)e.style.position="relative";let l=pn(document);e.replaceChildren(s,l.root),xr(e,()=>Lx(e));let c=Zt({acceptOrigin:i,source:window,target:{postMessage:(f,h)=>s.contentWindow?.postMessage(f,h)},targetOrigin:i,token:r}),d={canvasEl:e,canvasUrl:t,channel:c,contentFragment:!1,contentHeight:null,hiddenPaths:new Set,popoverOpen:null,dialogOpen:null,editing:!1,editingProp:null,iframe:s,insertHideTimer:null,insertHover:!1,coSelectionKeys:new Set,insertZone:null,lastRenderedGen:-1,lastHover:null,lastSelectionRect:null,lastSnapshotSeq:0,overlay:l,panReqId:-1,pending:null,postedVersions:null,idle:null,pendingEnterEdit:null,pendingMeasures:new Map,pendingPatches:0,pendingTabIds:new Map,presenceMeta:new Map,presenceReqId:-1,preview:!1,ready:!1,selectionPath:null,selectionPaths:[],selReqId:0,snapshot:null,stylebook:null,tabId:null};return l.insertButton.addEventListener("click",(f)=>Lr(d,f)),l.insertButton.addEventListener("mouseenter",()=>{d.insertHover=!0,le(d)}),l.insertButton.addEventListener("mouseleave",()=>{d.insertHover=!1,Zn(d)}),c.onMessage((f)=>qr(d,f)),Re.set(e,d),g.add(d),Nr(),Or(),kr(),d}function Hr(e,t){le(e),e.insertZone=t,e.overlay.setInsertZone(N(t.rect),t.edge)}function Gn(e){le(e),e.insertZone=null,e.insertHover=!1,e.overlay.setInsertZone(null)}function Jr(e){let t=e.overlay.insertButton;return e.insertHover||typeof t.matches==="function"&&t.matches(":hover")}function Zn(e){le(e),e.insertHideTimer=setTimeout(()=>{if(e.insertHideTimer=null,Jr(e))return;Gn(e)},vr)}function le(e){if(e.insertHideTimer!==null)clearTimeout(e.insertHideTimer),e.insertHideTimer=null}function Lr(e,t){t.stopPropagation(),t.preventDefault();let n=e.insertZone;if(!n)return;Vn?.(e.overlay.insertButton,n)}var jr=new Set(["contextMenu","dragOver","dropResult","editCommit","editCommitProp","editInput","editInsert","editMerge","editRangeReplace","editSplit","editStart","fileDragOver","fileDrop","hit","hover","insertZones","layoutHit","nativeDragEnter"]);function qr(e,t){if(e.preview&&jr.has(t.kind))return;switch(t.kind){case"ready":{e.ready=!0;let n=xt?.();if(n)e.channel.post({chords:n.chords,kind:"keymap",mac:n.mac});if(e.postedVersions=null,Ae(e),e.pending)e.channel.post(e.pending),e.pending=null;$e(e,e.selectionPaths);return}case"paneFocus":{Ee(e),gt?.();return}case"popoverTargetClick":{let n=E(e);if(!n||e.preview)return;let o=JSON.stringify(n.session.ui.openPopover)===JSON.stringify(t.targetPath),r=t.action==="show"||t.action==="toggle"&&!o;if(r||o)ne()?.run("canvas.setPopoverOpen",{open:r,path:t.targetPath});return}case"commandTargetClick":{let n=E(e);if(!n||e.preview)return;let o=(i)=>JSON.stringify(i)===JSON.stringify(t.targetPath),r=K(n.doc.document,t.targetPath);if(!r||typeof r!=="object")return;if(We.has(t.command)){if(!Qs(r))return;let i=t.command==="show-popover"||t.command==="toggle-popover"&&!o(n.session.ui.openPopover);if(i||o(n.session.ui.openPopover))ne()?.run("canvas.setPopoverOpen",{open:i,path:t.targetPath})}else if(Fe.has(t.command)){if(!H(r))return;let i=t.command==="show-modal";if(i||o(n.session.ui.openDialog))ne()?.run("canvas.setDialogOpen",{open:i,path:t.targetPath})}return}case"hit":{Ee(e),gt?.(),XC(null);let n=null,o=_(e.canvasEl)?.panel;if(o?.mediaName&&!o.mediaName.startsWith("git-diff")){n=ce(o.mediaName);let i=E(e);if(i)i.session.ui.activeMedia=n}if(Me?.dismiss(),e.stylebook){let i=Mn(e.stylebook.pathToTag,t.hit.path);if(Bn?.(i,n),i){let s=N(t.hit.rect);e.overlay.setSelection(s,`<${i}>`),e.lastSelectionRect=s}else e.overlay.setSelection(null);return}e.selectionPath=t.hit.path,e.selectionPaths=[t.hit.path];let r=E(e);if(r)r.session.selection=t.additive?Ly(r.session.selection,t.hit.path):[t.hit.path];{let i=N(t.hit.rect);e.overlay.setSelection(i),e.lastSelectionRect=i}return}case"layoutHit":{if(e.stylebook)return;Ee(e),Me?.dismiss(),XC(t.hit),e.selectionPath=null,e.selectionPaths=[];let n=E(e);if(n)n.session.selection=[];let o=N(t.hit.rect);e.overlay.setSelection(o,`LAYOUT · ${t.hit.layoutFile}`),e.lastSelectionRect=o,Ai("rightPanel");return}case"hover":{if(e.stylebook){let n=t.hit?Mn(e.stylebook.pathToTag,t.hit.path):null,o=v.stylebook.selection;if(t.hit&&n&&n!==o)e.overlay.setHover(N(t.hit.rect));else e.overlay.setHover(null);return}e.lastHover=t.hit,Br(e,t.hit);return}case"insertZones":{if(e.stylebook)return;let n=t.zones?.[0]??null;if(n)Hr(e,n);else Zn(e);return}case"geometry":{let n=e.pendingMeasures.get(t.reqId);if(n){e.pendingMeasures.delete(t.reqId),n(t.hits);return}if(t.reqId===e.presenceReqId){e.presenceReqId=-1;let o=[];for(let r of t.hits){let i=e.presenceMeta.get(JSON.stringify(r.path));if(i)o.push({...i,placement:N(r.rect)})}e.overlay.setPresence(o);return}if(t.reqId===e.panReqId){e.panReqId=-1;let[o]=t.hits;if(o){let{rect:r,scale:i}=Qa(e);Qb({height:o.rect.height*i,top:o.rect.y*i+r.top})}return}if(t.reqId===e.selReqId){let o=JSON.stringify(e.selectionPath),r=[],i=null;if(e.stylebook){let[a]=t.hits;i=a?N(a.rect):null}else for(let a of t.hits){let l=JSON.stringify(a.path);if(l===o)i=N(a.rect);else if(e.coSelectionKeys.has(l))r.push(N(a.rect))}let s=e.stylebook?v.stylebook.selection:null;e.overlay.setSelection(i,s?`<${s}>`:null),e.overlay.setCoSelection(r),e.lastSelectionRect=i,e.hiddenPaths=new Set((t.hidden??[]).map((a)=>JSON.stringify(a)))}return}case"evalResult":{let n=L.get(t.reqId);if(!n)return;L.delete(t.reqId),Z.delete(t.reqId),n(t.gen===e.lastRenderedGen?t.results:null);return}case"renderComplete":{if(e.pendingTabIds.has(t.gen))e.tabId=e.pendingTabIds.get(t.gen)??null;for(let n of e.pendingTabIds.keys())if(n<=t.gen)e.pendingTabIds.delete(n);In(e,t.gen);return}case"patchComplete":{e.pendingPatches=Math.max(0,e.pendingPatches-1),In(e,t.gen);return}case"idle":{e.idle={animations:t.animations,fonts:t.fonts,gen:t.gen,images:t.images};return}case"renderError":{e.pendingTabIds.delete(t.gen);let n=E(e);if(n)n.session.canvas.refreshing=!1,Ai("leftPanel");C.error("The page could not be rendered.",{detail:t.message,key:`canvas.render:${Ln(e)}`,source:"Canvas"});return}case"dataScope":{if(t.gen!==e.lastRenderedGen)return;let n=E(e);if(n)n.session.canvas.scope=t.scope,n.session.canvas.refreshing=!1;Ai("leftPanel");return}case"contentHeight":{e.contentHeight=t.height,e.contentFragment=t.fragment,qn(e);return}case"dragOver":{if(t.dragSeq!==z)return;if(t.cursor)Dn=t.dragSeq,Hn=Date.now();if(t.gen!==e.lastRenderedGen)return;if(t.preview)e.overlay.setDropIndicator(N(t.preview.referenceRect),t.preview.edge);else e.overlay.setDropIndicator(null);if(t.cursor){let n=Qa(e);Ex(t.cursor.x*n.scale+n.rect.left,t.cursor.y*n.scale+n.rect.top)}return}case"nativeDragEnter":{if(e.stylebook)return;Fn?.(e);return}case"dragEnd":{e.overlay.setDropIndicator(null),Od(),ie.delete(t.dragSeq);return}case"dropResult":{if(t.dragSeq!==z||t.gen!==e.lastRenderedGen)return;if(t.instruction&&t.targetPath){let n=ie.get(t.dragSeq);if(n)wm(E(e),{type:t.instruction},n,t.targetPath)}ie.delete(t.dragSeq),e.overlay.setDropIndicator(null),Od();return}case"fileDragOver":{if(e.stylebook)return;yr(e,t.hit,t.preview);return}case"fileDragLeave":{Tn(e);return}case"fileDrop":{if(Tn(e),e.stylebook)return;yt?.(E(e),t.files,t.hit,t.preview);return}case"patchError":{e.pendingPatches=Math.max(0,e.pendingPatches-1);let n=_(e.canvasEl)?.surface;if(n)zn?.(n.paneId);return}case"forwardKey":{Vr(t.event);return}case"forwardWheel":{Wr(e,t);return}case"editStart":{if(S&&S!==e)S.editing=!1,S.editingProp=null,S.snapshot=null;if(S=e,t.prop!==void 0&&ft===Bl(t.path))re(e,t.path,void 0,t.prop);ft=null,wr+=1,e.editing=!0,e.editingProp=t.prop??null,e.snapshot=null,e.lastSnapshotSeq=0,Ne?.();return}case"selectionChanged":{if(t.seq<=e.lastSnapshotSeq)return;if(e.lastSnapshotSeq=t.seq,e.snapshot=t,!e.editing)e.editing=!0,S=e;Ne?.();return}case"flushComplete":{let n=X.get(t.reqId);if(n)X.delete(t.reqId),ae.delete(t.reqId),n();return}case"editInput":{let n=E(e);if(n)n.doc.dirty=!0;return}case"editCommit":{let n=()=>rn(E(e),t.path,t.children,t.textContent);if(t.inPlace)kn(e,[t.path],n);else n();return}case"editCommitProp":{let n=()=>an(E(e),t.path,t.prop,t.value);if(t.inPlace){kn(e,[t.path],n),pt=Bl(t.path);return}let o=n();if(Pr(o,pt,Bl(t.path)))Er(e,t.path);pt=null,ft=o?Bl(t.path):null;return}case"editMerge":{let n=sn(E(e),t.fromPath,t.intoPath);if(n)re(e,n.path,n.offset);return}case"editRangeReplace":{let n=dn(E(e),t.from,t.to,t.between,t.text);if(n)re(e,n.path,n.offset);return}case"editSplit":{re(e,cn(E(e),t.path,t.before,t.after));return}case"editInsert":{re(e,un(E(e),t.path,t.cmd,t.commitData));return}case"slashShow":{let{rect:n,scale:o}=Qa(e),r=t.rect.x*o+n.left,i=t.rect.y*o+n.top;Te?.show({filter:t.filter,...t.showFilter===!0?{showFilter:!0}:{},onDismiss:()=>e.channel.post({kind:"slashDismissed"}),onSelect:(s)=>e.channel.post({cmd:{...s},kind:"slashSelect"}),rect:{bottom:i+t.rect.height*o,height:t.rect.height*o,left:r,top:i,width:t.rect.width*o}});return}case"slashNav":{Te?.nav(t.key);return}case"slashDismiss":{Te?.dismiss();return}case"previewNavigate":{lr(t.href,e);return}case"contextMenu":{if(e.stylebook)return;Ee(e);let{rect:n,scale:o}=Qa(e);Me?.show({clientX:t.x*o+n.left,clientY:t.y*o+n.top,path:t.path?[...t.path]:null});return}case"editEnd":{if(!e.editing)return;if(e.editing=!1,e.editingProp=null,e.snapshot=null,S===e)S=null;Ne?.();break}default:break}}function In(e,t){if(e.lastRenderedGen=t,$e(e,e.selectionPaths),Kn(e),Gn(e),e.pendingEnterEdit&&t>=e.pendingEnterEdit.minGen){let{offset:n,path:o,prop:r}=e.pendingEnterEdit;if(e.pendingEnterEdit=null,e.tabId!==null&&e.tabId===ym(e.canvasEl)?.id)Fr(e,o,n,r)}}function re(e,t,n,o){e.pendingEnterEdit={minGen:e.lastRenderedGen,path:[...t],...n===void 0?{}:{offset:n},...o===void 0?{}:{prop:o}}}function Fr(e,t,n,o){e.channel.post({kind:"enterEdit",path:[...t],...n===void 0?{}:{offset:n},...o===void 0?{}:{prop:o}})}function Wr(e,t){let{rect:n,scale:o}=Qa(e),r=Zl(e.canvasEl)?.wrap;if(!r)return;r.dispatchEvent(new WheelEvent("wheel",{bubbles:!0,cancelable:!0,clientX:n.left+t.x*o,clientY:n.top+t.y*o,ctrlKey:t.ctrlKey,deltaX:t.deltaX,deltaY:t.deltaY,metaKey:t.metaKey,shiftKey:t.shiftKey}))}function Vr(e){document.dispatchEvent(new KeyboardEvent("keydown",{altKey:e.altKey,bubbles:!0,cancelable:!0,code:e.code,ctrlKey:e.ctrlKey,key:e.key,metaKey:e.metaKey,shiftKey:e.shiftKey}))}function Br(e,t){if(!t||Qr(t.path,e.selectionPath)){e.overlay.setHover(null);return}e.overlay.setHover(N(t.rect))}var zr=4,B=new Map;function Kr(e){let t=B.get(e);if(t)return B.delete(e),B.set(e,t),t;let n=new Map;B.set(e,n);for(let o of B.keys()){if(B.size<=zr)break;B.delete(o)}return n}function Ur(e,t,n,o,r,i=null){let s=Kr(e),a=o?.id??null,l=s.get(t);if(l&&l.tabId===n&&l.viewTabId===a&&l.mode===i)return l.payload;let c=cr(r),d=yx(Pt,async()=>{Sr.renderPreparations+=1;let f=await en(t,o,i),h=JSON.parse(JSON.stringify(f.renderDoc)),b=JSON.parse(JSON.stringify(t)),M=n?m.tabs.get(n)??null:null,R=_i(M?.doc.sourceFormat)?.studio?.elements,O=R?wn(R):void 0;return{assets:f.assets,doc:h,docBase:f.docBase??`${Lm()}/`,mapperCtx:f.mapperCtx,mode:f.mapperCtx.canvasMode,shadowDoc:b,siteStyle:f.siteStyle,...O?{editableTags:O}:{},...c?{allowAutoRequests:!0}:{}}});return s.set(t,{mode:i,payload:d,tabId:n,viewTabId:a}),d}async function HC(e,t,n,o,r=null,i=ym(n),s=null,a=null){let l=bt(n);l.pendingTabIds.set(e,r),l.stylebook=null,l.iframe.style.width=o?`${o}px`:"100%";let d={...await Ur(e,t,r,i,Gb(n),s),colorScheme:Yn(i),...a?{diffMarks:a}:{},gen:e,kind:"render",popoverOpen:i?.session.ui.openPopover??null,dialogOpen:i?.session.ui.openDialog??null};l.popoverOpen=d.popoverOpen??null,l.dialogOpen=d.dialogOpen??null,vt(l,d.mode==="preview"),Xn(l,d)}function Xn(e,t){if(Sr.hostRenderPosts+=1,e.ready)Ae(e),e.channel.post(t);else e.pending=t}function BC(e,t,n,o){let r=bt(n);r.pendingTabIds.set(e,null),r.stylebook={pathToTag:t.pathToTag,tagToCardPath:t.tagToCardPath},vt(r,!1),r.pendingEnterEdit=null,r.iframe.style.width=o?`${o}px`:"100%";let i=JSON.parse(JSON.stringify(t.doc)),s=JSON.parse(JSON.stringify(t.doc)),a={assets:null,colorScheme:Yn(ym(n)),doc:i,docBase:`${Lm()}/`,gen:e,kind:"render",mapperCtx:{arrayPaths:[],canvasMode:"stylebook",layoutWrapped:!1,pageContentOffset:null,pageContentPrefix:null},mode:"stylebook",shadowDoc:s,siteStyle:null};Xn(r,a)}function Yn(e){let t=e?.session.ui.previewColorScheme;return t==="light"||t==="dark"?t:null}function WC(e,t){for(let n of g){if(!n.iframe.isConnected){g.delete(n);continue}if(t&&!t.contains(n.iframe))continue;if(n.ready)n.channel.post({kind:"setColorScheme",scheme:e})}}function VC(e,t){let n=NL(e);for(let o of g){if(!o.iframe.isConnected){g.delete(o);continue}if(t&&!t.contains(o.iframe))continue;if(o.ready)o.channel.post({dir:n,kind:"setLocale",locale:e})}}function zC(e,t){let n=JSON.parse(JSON.stringify(e)),o=0;for(let r of g){if(!r.iframe.isConnected){g.delete(r);continue}if(r.ready)r.channel.post({base:t,doc:n,kind:"redefineElement"}),o+=1}return o}function UC(){let e=D?.projectConfig;if(!e)return;let t=JSON.parse(JSON.stringify(e.style??null)),n=JSON.parse(JSON.stringify(e.$media??{}));for(let o of g){if(!o.iframe.isConnected){g.delete(o);continue}if(o.ready&&!o.stylebook)o.channel.post({kind:"siteStyleUpdate",media:n,siteStyle:t})}}function ry(e){let t=0,n=JSON.parse(JSON.stringify(e));for(let o of g){if(!o.iframe.isConnected){g.delete(o);continue}if(o.ready&&o.stylebook)o.channel.post({gen:o.lastRenderedGen,kind:"styleUpdate",style:n}),t+=1,$e(o,o.selectionPaths)}return t}function qC(e){let t=Qn();if(!t?.stylebook||!t.ready)return;let n=t.stylebook.tagToCardPath.get(e);if(!n)return;t.selReqId+=1,t.panReqId=t.selReqId,t.channel.post({kind:"measure",paths:[[...n]],reqId:t.selReqId})}function el(){let e=S;if(!e||!e.iframe.isConnected)return{editing:!1,editingProp:null,snapshot:null};return{editing:e.editing,editingProp:e.editingProp,snapshot:e.snapshot}}var xt=null;function GC(e,t){xt=e,t?.(()=>$n()),$n()}function $n(){let e=xt?.();if(!e)return;for(let t of g){if(!t.iframe.isConnected){g.delete(t);continue}if(t.ready)t.channel.post({chords:e.chords,kind:"keymap",mac:e.mac})}}function Ad(e){let t=S;if(!t||!t.ready)return;t.channel.post({intent:e,kind:"applyFormat"})}function KC(){let e=S;if(!e||!e.ready)return;e.channel.post({kind:"openSlash"})}function oy(){let e=S;if(e?.editing&&e.ready&&e.iframe.isConnected)e.channel.post({kind:"endEdit"})}function Qn(){let e=Rt();return e?Lx(e.canvas):null}function Ix(){let e=S,t=e??Qn();if(!t)return null;let{rect:n,scale:o}=Qa(t);if(t.lastSelectionRect)return{height:t.lastSelectionRect.height*o,left:t.lastSelectionRect.left*o+n.left,top:t.lastSelectionRect.top*o+n.top,width:t.lastSelectionRect.width*o};let r=t===e?t.snapshot?.rect:null;if(r)return{height:r.height*o,left:r.x*o+n.left,top:r.y*o+n.top,width:r.width*o};return null}
2
+ export{mo,lt,go,fx,jl,_r,Ku,Gb,ym,AT,mx,PT,Kb,Hl,MT,FT,jT,gx,HT,BT,WT,VT,Sr,Jb,bx,yx,vi,Id,zT,Bl,Dd,UT,vx,qT,Yb,GT,Zb,Ju,bo,KT,Sp,JT,YT,wx,ZT,xx,XT,_x,dC,uC,Sx,Cp,Yu,QT,eL,Xb,bs,Nd,Zu,tL,nL,Cx,hC,kp,kx,iL,Qb,rL,pC,fC,mC,oL,ey,gC,Ex,Od,Dc,ty,Xu,bC,vm,yC,sL,aL,Tx,lL,cL,dL,wm,vC,wC,xC,_C,Lx,xm,_m,Rx,Qa,SC,CC,kC,Sm,vI,OI,EC,Wl,ny,iy,TC,LC,RC,$C,IC,DC,NC,OC,AC,PC,MC,FC,$x,jC,Cm,HC,BC,WC,VC,zC,UC,ry,qC,el,GC,Ad,KC,oy,Ix};
3
+
4
+ //# debugId=AE56D17B5931057F64756E2164756E21
5
+ //# sourceMappingURL=studio-gf0fz03c.js.map
@@ -0,0 +1,6 @@
1
+ import{p}from"./studio-xz2yxfcb.js";import{K,D}from"./studio-yn9f8vtx.js";import{mh}from"./studio-5tnvjkz4.js";import{nt,ev}from"./studio-s8dmmz66.js";async function Mb(e,s){let o=p();if(!o.codeService)return null;return o.codeService(e,s)}var Lc=new Map;async function Fb(e,s){let o=e.$prototype?D?.projectConfig?.imports?.[e.$prototype]:null,t=e.$src||o;if(!t||!e.$prototype)return null;let r=`${t}::${e.$prototype}`;if(Lc.has(r))return Lc.get(r);try{let n=p();if(!n.fetchPluginSchema)return Lc.set(r,null),null;let i=!o&&s.documentPath?`${location.origin}/${s.documentPath}`:void 0,a=await n.fetchPluginSchema(t,e.$prototype,i);return Lc.set(r,a),a}catch{return Lc.set(r,null),null}}function QS(e,s){let o=e.getModel();if(!o)return;let t=mh();if(!t)return;let r=s.map((n)=>{let i=n.labels?.[0];if(!i)return null;let{line:a,column:l,length:c}=i.span;return{code:n.url?{target:t.Uri.parse(n.url),value:n.code}:n.code,endColumn:l+(c||1),endLineNumber:a,message:n.message+(n.help?`
2
+ ${n.help}`:""),severity:n.severity==="error"?t.MarkerSeverity.Error:t.MarkerSeverity.Warning,source:"oxlint",startColumn:l,startLineNumber:a}}).filter(Boolean);t.editor.setModelMarkers(o,"oxlint",r)}function lT(e,s){let o=(t)=>{if(!nt(t))return null;let r=t.parameters;if(!Array.isArray(r)||r.length===0)return null;return ev(r)};if(e.type==="def"){let t=e.defName?o(s?.state?.[e.defName]):null;if(t)return t}else if(e.type==="event"){if(!s||!e.path)return["state","event"];let t=K(s,e.path),r=t&&e.eventKey?o(t[e.eventKey]):null;if(r)return r}return["state","event"]}
3
+ export{Mb,Lc,Fb,QS,lT};
4
+
5
+ //# debugId=73E1334181382A3564756E2164756E21
6
+ //# sourceMappingURL=studio-gjtpe62q.js.map
@@ -1,5 +1,5 @@
1
- class f extends Error{name="MaxOpsExceededError"}function d(n){return typeof n==="object"&&n!==null&&!Array.isArray(n)}function ls(n,e){if(n===e)return!0;if(Array.isArray(n)&&Array.isArray(e))return n.length===e.length&&n.every((t,r)=>ls(t,e[r]));if(d(n)&&d(e)){let t=Object.keys(n),r=Object.keys(e);return t.length===r.length&&t.every((i)=>(i in e)&&ls(n[i],e[i]))}return!1}function A(n){let e=5381;for(let t=0;t<n.length;t++)e=Math.imul(e,33)+(n.codePointAt(t)??0);return e.toString(36)}function m(n){return typeof n==="string"?`s:${n}`:`n:${A(JSON.stringify(n))}`}function x(n){if(typeof n==="string")return"s";let e=n,{attributes:t,$props:r}=e,i=(d(t)?t.id:void 0)??(d(r)?r.key:void 0)??"";return`w:${String(e.tagName??"")}:${String(i)}`}function y(n,e,t=Number.POSITIVE_INFINITY){let r=n.length,i=e.length;if(r===0||i===0||r*i>t)return[];let c=Array.from({length:r+1},()=>Array.from({length:i+1},()=>0));for(let s=r-1;s>=0;s--)for(let l=i-1;l>=0;l--)c[s][l]=n[s]===e[l]?c[s+1][l+1]+1:Math.max(c[s+1][l],c[s][l+1]);let o=[],a=0,u=0;while(a<r&&u<i)if(n[a]===e[u])o.push([a,u]),a+=1,u+=1;else if(c[a+1][u]>=c[a][u+1])a+=1;else u+=1;return o}function r1(n,e,t={}){let r=t.maxCells??Number.POSITIVE_INFINITY,i=y(n.map((s)=>m(s)),e.map((s)=>m(s)),r),c=[],o=-1,a=-1,u=[];for(let[s,l]of i)u.push([o+1,s,a+1,l]),c.push({aIndex:s,bIndex:l,identical:!0}),o=s,a=l;u.push([o+1,n.length,a+1,e.length]);for(let[s,l,p,k]of u){let w=n.slice(s,l),O=e.slice(p,k);for(let[b,I]of y(w.map((h)=>x(h)),O.map((h)=>x(h)),r))c.push({aIndex:s+b,bIndex:p+I,identical:!1})}return c.toSorted((s,l)=>s.aIndex-l.aIndex)}class g{ops=[];maxOps;constructor(n){this.maxOps=n}result(){return this.ops}push(n){if(this.ops.length>=this.maxOps)throw new f;this.ops.push(n)}diffNode(n,e,t){for(let c of new Set([...Object.keys(e),...Object.keys(t)])){if(c==="children")continue;if(!(c in t))this.push({key:c,op:"set-key",path:n});else if(!ls(e[c],t[c]))this.push({key:c,op:"set-key",path:n,value:t[c]})}let r=e.children,i=t.children;if(Array.isArray(r)&&Array.isArray(i))this.diffChildren(n,r,i);else if(!ls(r,i))this.push({key:"children",op:"set-key",path:n,value:i})}diffChildren(n,e,t){let r=r1(e,t),i=new Set(r.map((o)=>o.aIndex)),c=new Map(r.map((o)=>[o.bIndex,o]));for(let o=e.length-1;o>=0;o--)if(!i.has(o))this.push({index:o,op:"remove-child",parentPath:n});for(let o=0;o<t.length;o++){let a=c.get(o);if(!a){this.push({index:o,node:t[o],op:"insert-child",parentPath:n});continue}if(a.identical)continue;let u=e[a.aIndex],s=t[o];if(d(u)&&d(s))this.diffNode([...n,"children",o],u,s);else if(!ls(u,s))this.push({index:o,node:s,op:"set-child",parentPath:n})}}}function f$(n,e,t={}){let r=new g(t.maxOps??500);try{r.diffNode([],n,e)}catch(i){if(i instanceof f)return null;throw i}return r.result()}
2
- export{ls,r1,f$};
1
+ class f extends Error{name="MaxOpsExceededError"}function d(n){return typeof n==="object"&&n!==null&&!Array.isArray(n)}function fs(n,e){if(n===e)return!0;if(Array.isArray(n)&&Array.isArray(e))return n.length===e.length&&n.every((t,r)=>fs(t,e[r]));if(d(n)&&d(e)){let t=Object.keys(n),r=Object.keys(e);return t.length===r.length&&t.every((i)=>(i in e)&&fs(n[i],e[i]))}return!1}function A(n){let e=5381;for(let t=0;t<n.length;t++)e=Math.imul(e,33)+(n.codePointAt(t)??0);return e.toString(36)}function m(n){return typeof n==="string"?`s:${n}`:`n:${A(JSON.stringify(n))}`}function x(n){if(typeof n==="string")return"s";let e=n,{attributes:t,$props:r}=e,i=(d(t)?t.id:void 0)??(d(r)?r.key:void 0)??"";return`w:${String(e.tagName??"")}:${String(i)}`}function y(n,e,t=Number.POSITIVE_INFINITY){let r=n.length,i=e.length;if(r===0||i===0||r*i>t)return[];let c=Array.from({length:r+1},()=>Array.from({length:i+1},()=>0));for(let s=r-1;s>=0;s--)for(let l=i-1;l>=0;l--)c[s][l]=n[s]===e[l]?c[s+1][l+1]+1:Math.max(c[s+1][l],c[s][l+1]);let o=[],a=0,u=0;while(a<r&&u<i)if(n[a]===e[u])o.push([a,u]),a+=1,u+=1;else if(c[a+1][u]>=c[a][u+1])a+=1;else u+=1;return o}function _S(n,e,t={}){let r=t.maxCells??Number.POSITIVE_INFINITY,i=y(n.map((s)=>m(s)),e.map((s)=>m(s)),r),c=[],o=-1,a=-1,u=[];for(let[s,l]of i)u.push([o+1,s,a+1,l]),c.push({aIndex:s,bIndex:l,identical:!0}),o=s,a=l;u.push([o+1,n.length,a+1,e.length]);for(let[s,l,p,k]of u){let w=n.slice(s,l),O=e.slice(p,k);for(let[b,I]of y(w.map((h)=>x(h)),O.map((h)=>x(h)),r))c.push({aIndex:s+b,bIndex:p+I,identical:!1})}return c.toSorted((s,l)=>s.aIndex-l.aIndex)}class g{ops=[];maxOps;constructor(n){this.maxOps=n}result(){return this.ops}push(n){if(this.ops.length>=this.maxOps)throw new f;this.ops.push(n)}diffNode(n,e,t){for(let c of new Set([...Object.keys(e),...Object.keys(t)])){if(c==="children")continue;if(!(c in t))this.push({key:c,op:"set-key",path:n});else if(!fs(e[c],t[c]))this.push({key:c,op:"set-key",path:n,value:t[c]})}let r=e.children,i=t.children;if(Array.isArray(r)&&Array.isArray(i))this.diffChildren(n,r,i);else if(!fs(r,i))this.push({key:"children",op:"set-key",path:n,value:i})}diffChildren(n,e,t){let r=_S(e,t),i=new Set(r.map((o)=>o.aIndex)),c=new Map(r.map((o)=>[o.bIndex,o]));for(let o=e.length-1;o>=0;o--)if(!i.has(o))this.push({index:o,op:"remove-child",parentPath:n});for(let o=0;o<t.length;o++){let a=c.get(o);if(!a){this.push({index:o,node:t[o],op:"insert-child",parentPath:n});continue}if(a.identical)continue;let u=e[a.aIndex],s=t[o];if(d(u)&&d(s))this.diffNode([...n,"children",o],u,s);else if(!fs(u,s))this.push({index:o,node:s,op:"set-child",parentPath:n})}}}function II(n,e,t={}){let r=new g(t.maxOps??500);try{r.diffNode([],n,e)}catch(i){if(i instanceof f)return null;throw i}return r.result()}
2
+ export{fs,_S,II};
3
3
 
4
- //# debugId=D8287AACA826507164756E2164756E21
5
- //# sourceMappingURL=studio-tzegmy4w.js.map
4
+ //# debugId=6892A3C5FC99B3D464756E2164756E21
5
+ //# sourceMappingURL=studio-gkskhg7m.js.map