@jxsuite/studio 8.1.0 → 10.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{2020-dg097k3e.js → 2020-j56903f1.js} +3 -3
- package/dist/chunks/adapter-wc5zvg9a.js +4 -0
- package/dist/chunks/add-new-flow-snx1s4b0.js +4 -0
- package/dist/chunks/cf-account-picker-xyqw0jex.js +4 -0
- package/dist/chunks/cf-settings-hp1pjm0n.js +4 -0
- package/dist/chunks/color-04361ttk.js +4 -0
- package/dist/chunks/{color-area-vh9cew51.js → color-area-h8dbasp1.js} +2 -2
- package/dist/chunks/{color-field-e78f16bs.js → color-field-qv5r2b16.js} +3 -3
- package/dist/chunks/{color-slider-fg4yhvk6.js → color-slider-nz2mrzky.js} +2 -2
- package/dist/chunks/components-nkwphrx3.js +4 -0
- package/dist/chunks/content-source-6a253wmk.js +4 -0
- package/dist/chunks/{convert-to-repeater-grnmea6c.js → convert-to-repeater-fhdwyg14.js} +3 -3
- package/dist/chunks/editor-wqrc68ca.js +4 -0
- package/dist/chunks/entry-commands-nef0wrmp.js +4 -0
- package/dist/chunks/{extension-sections-rp7fkega.js → extension-sections-8ez2rrk8.js} +3 -3
- package/dist/chunks/file-ops-y3w71k1n.js +4 -0
- package/dist/chunks/files-de90apn9.js +4 -0
- package/dist/chunks/format-host-zfjz4rzm.js +4 -0
- package/dist/chunks/fs-events-77c0mr0x.js +4 -0
- package/dist/chunks/grid-open-4n4fjfpf.js +4 -0
- package/dist/chunks/{grid-view-x26rfpz1.js → grid-view-ka55z38f.js} +10 -10
- package/dist/chunks/{iframe-entry-pkgmcgp0.js → iframe-entry-2x9bn5ng.js} +4 -4
- package/dist/chunks/{iframe-entry-02wzcyvy.js → iframe-entry-btck0e9s.js} +4 -4
- package/dist/chunks/iframe-host-na2mywz4.js +4 -0
- package/dist/chunks/index-ewmgdb7c.js +4 -0
- package/dist/chunks/{index-203h71wy.js → index-qb98xhse.js} +3 -3
- package/dist/chunks/{javascript-ww5pv5ae.js → javascript-ces13wny.js} +2 -2
- package/dist/chunks/{jsonMode-vwbdwwq3.js → jsonMode-6md16d4v.js} +6 -6
- package/dist/chunks/jx-validate-b309c020.js +4 -0
- package/dist/chunks/layers-8rn8y6qv.js +4 -0
- package/dist/chunks/layers-panel-eyah7h9z.js +4 -0
- package/dist/chunks/lit-html-wyqw04y2.js +4 -0
- package/dist/chunks/media-library-gs3np47y.js +4 -0
- package/dist/chunks/media-picker-tt7dk4tb.js +4 -0
- package/dist/chunks/{monaco-binding-63tqze27.js → monaco-binding-p8j80s4w.js} +3 -3
- package/dist/chunks/monaco-buffer-wsf6cmnq.js +4 -0
- package/dist/chunks/{monaco-setup-zyyynnj8.js → monaco-setup-wasktzfg.js} +3 -3
- package/dist/chunks/notify-qwst108r.js +4 -0
- package/dist/chunks/parse-n8dfxnqf.js +4 -0
- package/dist/chunks/platform-c16mqvmp.js +4 -0
- package/dist/chunks/publish-panel-d34bhvwj.js +4 -0
- package/dist/chunks/{publish-quick-ajzdhhs6.js → publish-quick-vr695j26.js} +3 -3
- package/dist/chunks/publish-workspace-2yr60mt4.js +4 -0
- package/dist/chunks/quick-search-e6xsdv0d.js +4 -0
- package/dist/chunks/references-gsj6trdv.js +4 -0
- package/dist/chunks/right-panel-33jv1knc.js +4 -0
- package/dist/chunks/source-control-bj9bejjv.js +4 -0
- package/dist/chunks/studio-03mqh8ax.js +5 -0
- package/dist/chunks/{studio-957jg8g3.js → studio-06j4en5h.js} +4 -4
- package/dist/chunks/studio-0ydxv2mr.js +7 -0
- package/dist/chunks/{studio-v2ek69cb.js → studio-1e8dw2w2.js} +4 -4
- package/dist/chunks/studio-2hsqbq7b.js +7 -0
- package/dist/chunks/studio-2j86y34y.js +6 -0
- package/dist/chunks/studio-2ks6ka4g.js +5 -0
- package/dist/chunks/studio-34jrz12k.js +5 -0
- package/dist/chunks/{studio-1meqbxns.js → studio-35vrtpdq.js} +4 -4
- package/dist/chunks/studio-38g0jdz7.js +5 -0
- package/dist/chunks/{studio-25a5by3h.js → studio-396srjbk.js} +4 -4
- package/dist/chunks/{studio-zm7dnr9g.js → studio-3c8pp7pb.js} +4 -4
- package/dist/chunks/{studio-x3ge4rts.js → studio-3v5cagy9.js} +4 -4
- package/dist/chunks/studio-3w35qvay.js +5 -0
- package/dist/chunks/studio-3zge48z4.js +7 -0
- package/dist/chunks/studio-45gyxpcq.js +5 -0
- package/dist/chunks/{studio-hw60n5dh.js → studio-4kzbrr5t.js} +3 -3
- package/dist/chunks/{studio-533py3yy.js → studio-5tzgq6fx.js} +4 -4
- package/dist/chunks/studio-5wzdy1jc.js +16 -0
- package/dist/chunks/studio-732mw0g8.js +5 -0
- package/dist/chunks/{studio-3q6n9qvq.js → studio-771k2n12.js} +4 -4
- package/dist/chunks/{studio-z42kysg7.js → studio-7dzyz9n8.js} +137 -137
- package/dist/chunks/{studio-fqs1a22a.js → studio-7xag4na8.js} +4 -4
- package/dist/chunks/{studio-jqrg9xxg.js → studio-881z1xrx.js} +4 -4
- package/dist/chunks/studio-88bmt9rh.js +5 -0
- package/dist/chunks/{studio-8nyw10dp.js → studio-9b7177jq.js} +4 -4
- package/dist/chunks/{studio-nm9qev4p.js → studio-9cxmp61c.js} +5 -5
- package/dist/chunks/{studio-4dsdnan2.js → studio-9dz76yqc.js} +5 -5
- package/dist/chunks/{studio-a6x058ew.js → studio-agyvzfm4.js} +4 -4
- package/dist/chunks/{studio-2b8443ms.js → studio-ajw4k8hp.js} +3 -3
- package/dist/chunks/studio-c1pxszat.js +5 -0
- package/dist/chunks/studio-cpkamjdn.js +14 -0
- package/dist/chunks/studio-d038kqbs.js +5 -0
- package/dist/chunks/studio-d83m0wyq.js +5 -0
- package/dist/chunks/studio-dbxv7w4s.js +5 -0
- package/dist/chunks/studio-de1s2x9v.js +5 -0
- package/dist/chunks/{studio-94ppxeqy.js → studio-dx73md4n.js} +8 -8
- package/dist/chunks/studio-ekgtrndg.js +5 -0
- package/dist/chunks/studio-epenqmvk.js +7 -0
- package/dist/chunks/studio-et2q4s8n.js +5 -0
- package/dist/chunks/{studio-txkx6586.js → studio-ewarnzm4.js} +7 -7
- package/dist/chunks/{studio-bf0rgyf7.js → studio-fy7jzj9j.js} +4 -4
- package/dist/chunks/{studio-332hesdk.js → studio-gr36vnte.js} +4 -4
- package/dist/chunks/{studio-rdnezzkd.js → studio-gwrhcrss.js} +5 -5
- package/dist/chunks/{studio-9wyqyfqy.js → studio-h310mbqm.js} +4 -4
- package/dist/chunks/{studio-zht0x0v3.js → studio-h5tpz5ke.js} +4 -4
- package/dist/chunks/studio-h7weqf2q.js +5 -0
- package/dist/chunks/{studio-1gdfsr49.js → studio-hcsba201.js} +7 -7
- package/dist/chunks/studio-hwejq03c.js +5 -0
- package/dist/chunks/{studio-wcakp5bt.js → studio-hy4ye0dx.js} +7 -7
- package/dist/chunks/{studio-02phtmqn.js → studio-jttyqrmh.js} +4 -4
- package/dist/chunks/{studio-j5jqvyn3.js → studio-jw0q5j6k.js} +4 -4
- package/dist/chunks/studio-k3a8rp3d.js +5 -0
- package/dist/chunks/{studio-hnx1h1pr.js → studio-k3bcy02e.js} +4 -4
- package/dist/chunks/studio-m48v13s3.js +4 -0
- package/dist/chunks/{studio-bqgs90r8.js → studio-ndskgqef.js} +4 -4
- package/dist/chunks/studio-p1n2xjda.js +5 -0
- package/dist/chunks/studio-pgm83a2f.js +6 -0
- package/dist/chunks/studio-pqqq6v85.js +5 -0
- package/dist/chunks/studio-psh8mwnw.js +4 -0
- package/dist/chunks/{studio-cpdzrdgp.js → studio-r17asgs0.js} +4 -4
- package/dist/chunks/{studio-6vrxzkba.js → studio-ry81j4q1.js} +4 -4
- package/dist/chunks/studio-rzg8hnkf.js +5 -0
- package/dist/chunks/{studio-nsv7g1qn.js → studio-s0fg2wav.js} +4 -4
- package/dist/chunks/{studio-v0gsjav0.js → studio-tj2s0tks.js} +4 -4
- package/dist/chunks/studio-tyw7tk0x.js +5 -0
- package/dist/chunks/studio-v9ywz2se.js +6 -0
- package/dist/chunks/{studio-dmn7gpba.js → studio-vswcpzk7.js} +5 -5
- package/dist/chunks/studio-vzgmyt0v.js +5 -0
- package/dist/chunks/{studio-2dtc90zs.js → studio-wxdcd42g.js} +6 -6
- package/dist/chunks/{studio-c5dj3dzk.js → studio-wxhy1yh7.js} +4 -4
- package/dist/chunks/studio-x08a3m0a.js +5 -0
- package/dist/chunks/studio-x3mjr5cc.js +5 -0
- package/dist/chunks/{studio-xddgbwhe.js → studio-x97ay0v4.js} +4 -4
- package/dist/chunks/{studio-mmqr9awv.js → studio-xdpz9rpe.js} +33 -33
- package/dist/chunks/studio-xh683qzy.js +5 -0
- package/dist/chunks/{studio-hxq1ebp0.js → studio-xkxetm65.js} +6 -6
- package/dist/chunks/{studio-73wz63nn.js → studio-y26hx9re.js} +4 -4
- package/dist/chunks/{studio-kdseew9m.js → studio-yg3djpnm.js} +4 -4
- package/dist/chunks/studio-yx8hzqja.js +5 -0
- package/dist/chunks/studio-zg16eeq1.js +5 -0
- package/dist/chunks/studio-zgx7svjd.js +9 -0
- package/dist/chunks/studio-zkq3r91p.js +5 -0
- package/dist/chunks/{toast-host-1yg5ar8d.js → toast-host-g3r2s0kn.js} +2 -2
- package/dist/chunks/toast-w11qpkyz.js +4 -0
- package/dist/chunks/{tsMode-vra2hh7y.js → tsMode-h6tkz0ea.js} +5 -5
- package/dist/chunks/workspace-home-zkkrxq3r.js +4 -0
- package/dist/chunks/workspace-tdqqjqaa.js +4 -0
- package/dist/chunks/{ws-client-72x5n99j.js → ws-client-e951my95.js} +3 -3
- package/dist/iframe-entry.js +13 -13
- package/dist/manifest.json +77 -77
- package/dist/studio.js +91 -92
- package/package.json +11 -12
- package/src/canvas/iframe-editable-root.ts +32 -2
- package/src/collab/collab-session.ts +6 -2
- package/src/commands/context.ts +4 -0
- package/src/commands/defaults.ts +2 -0
- package/src/commands/live-context.ts +2 -0
- package/src/files/files.ts +6 -3
- package/src/format/format-host.ts +1 -1
- package/src/github/github-auth-status.ts +2 -2
- package/src/media/media-library.ts +73 -3
- package/src/new-project/new-project-modal.ts +1 -4
- package/src/packages/ensure-deps.ts +5 -5
- package/src/packages/pull-package-sync.ts +4 -4
- package/src/panels/activity-panel.ts +1 -1
- package/src/panels/ai-panel.ts +27 -34
- package/src/platform.ts +20 -0
- package/src/platforms/cloud.ts +48 -34
- package/src/platforms/devserver.ts +2 -120
- package/src/services/ai-ask.ts +29 -171
- package/src/services/ai-command-tools.ts +40 -50
- package/src/services/ai-import-tools.ts +4 -5
- package/src/services/ai-project-tools.ts +13 -3
- package/src/services/ai-tools.ts +26 -564
- package/src/services/ai-writes.ts +84 -2
- package/src/services/document-assistant.ts +29 -58
- package/src/services/harness/assistant-tools.ts +68 -0
- package/src/services/harness/interaction-store.ts +118 -0
- package/src/services/harness/studio-documents.ts +105 -0
- package/src/services/harness/turn-hooks.ts +1 -6
- package/src/services/project-adoption.ts +8 -16
- package/src/services/tool-executor.ts +25 -22
- package/src/settings/extension-commands.ts +1 -1
- package/src/settings/extension-rows.ts +1 -6
- package/src/settings/extensions-section.ts +3 -6
- package/src/state.ts +3 -13
- package/src/surfaces/block-action-bar.json +1 -3
- package/src/surfaces/files-panel.json +12 -0
- package/src/surfaces/files-panel.ts +5 -2
- package/src/surfaces/media-library.json +35 -0
- package/src/surfaces/media-library.ts +2 -0
- package/src/surfaces/menu.ts +62 -1
- package/src/surfaces/settings-packages.ts +1 -1
- package/src/surfaces/welcome.ts +4 -1
- package/src/tabs/selection.ts +14 -109
- package/src/tabs/tab.ts +10 -1
- package/src/tabs/transact.ts +316 -124
- package/src/types.ts +23 -16
- package/src/ui/layers.ts +1 -1
- package/src/ui/progress-modal.ts +3 -3
- package/dist/chunks/adapter-tck81zft.js +0 -4
- package/dist/chunks/add-new-flow-a1w0bnm6.js +0 -4
- package/dist/chunks/cf-account-picker-ce3kp3x1.js +0 -4
- package/dist/chunks/cf-settings-7ye6x7g2.js +0 -4
- package/dist/chunks/color-4gj49xq6.js +0 -4
- package/dist/chunks/components-qce0v93f.js +0 -4
- package/dist/chunks/content-source-jjx8kgzr.js +0 -4
- package/dist/chunks/editor-bkja5dbv.js +0 -4
- package/dist/chunks/entry-commands-1wh0btvg.js +0 -4
- package/dist/chunks/file-ops-6pe4z7an.js +0 -4
- package/dist/chunks/files-ybpp3j38.js +0 -4
- package/dist/chunks/format-host-3mtbhxk1.js +0 -4
- package/dist/chunks/fs-events-xfanfxds.js +0 -4
- package/dist/chunks/grid-open-dg5qmnaj.js +0 -4
- package/dist/chunks/iframe-host-j2bk2xkc.js +0 -4
- package/dist/chunks/index-fkrm7pdk.js +0 -4
- package/dist/chunks/jx-validate-w7v32f6a.js +0 -4
- package/dist/chunks/layers-g7j732cm.js +0 -4
- package/dist/chunks/layers-panel-gjrsxcck.js +0 -4
- package/dist/chunks/lit-html-jdfz9rhc.js +0 -4
- package/dist/chunks/media-library-9j0v4wmk.js +0 -4
- package/dist/chunks/media-picker-cpyyt2m0.js +0 -4
- package/dist/chunks/monaco-buffer-9wcme176.js +0 -4
- package/dist/chunks/notify-rahnnnv4.js +0 -4
- package/dist/chunks/parse-v77xtwv7.js +0 -4
- package/dist/chunks/platform-b2aqv7v5.js +0 -4
- package/dist/chunks/publish-panel-4yk2461b.js +0 -4
- package/dist/chunks/publish-workspace-mxestzcf.js +0 -4
- package/dist/chunks/quick-search-9g6z65b0.js +0 -4
- package/dist/chunks/references-c26enpxs.js +0 -4
- package/dist/chunks/right-panel-9d0e0yg7.js +0 -4
- package/dist/chunks/source-control-xyn3a8ds.js +0 -4
- package/dist/chunks/studio-0khd0xdw.js +0 -5
- package/dist/chunks/studio-1fvzq9vs.js +0 -5
- package/dist/chunks/studio-1yhz0s8p.js +0 -5
- package/dist/chunks/studio-2c2mjyzj.js +0 -6
- package/dist/chunks/studio-3pndhat0.js +0 -9
- package/dist/chunks/studio-4fjqdzrb.js +0 -6
- package/dist/chunks/studio-5abge3wy.js +0 -5
- package/dist/chunks/studio-74nzv280.js +0 -5
- package/dist/chunks/studio-7cg75gtj.js +0 -14
- package/dist/chunks/studio-89cwmnae.js +0 -5
- package/dist/chunks/studio-8m1t83kn.js +0 -7
- package/dist/chunks/studio-a3evp7f6.js +0 -6
- package/dist/chunks/studio-ana67wax.js +0 -5
- package/dist/chunks/studio-b4xhpcwy.js +0 -4
- package/dist/chunks/studio-c4rcaftm.js +0 -5
- package/dist/chunks/studio-cgjt1zce.js +0 -5
- package/dist/chunks/studio-cq87hree.js +0 -5
- package/dist/chunks/studio-d140sy8e.js +0 -5
- package/dist/chunks/studio-e1g64q43.js +0 -5
- package/dist/chunks/studio-e8pzjjhf.js +0 -5
- package/dist/chunks/studio-f8kz3krj.js +0 -7
- package/dist/chunks/studio-fw3jp9m7.js +0 -5
- package/dist/chunks/studio-g6ysm05p.js +0 -7
- package/dist/chunks/studio-gmhd0j3f.js +0 -5
- package/dist/chunks/studio-gqpty626.js +0 -5
- package/dist/chunks/studio-grp684wx.js +0 -5
- package/dist/chunks/studio-h98520qr.js +0 -5
- package/dist/chunks/studio-hvxt8z79.js +0 -5
- package/dist/chunks/studio-j4e627w1.js +0 -5
- package/dist/chunks/studio-kt2j51sa.js +0 -5
- package/dist/chunks/studio-m4w6sygj.js +0 -16
- package/dist/chunks/studio-nqxqf8p2.js +0 -4
- package/dist/chunks/studio-p89w12s2.js +0 -7
- package/dist/chunks/studio-pbagym4j.js +0 -5
- package/dist/chunks/studio-pr23qhrw.js +0 -5
- package/dist/chunks/studio-r4ya3sb2.js +0 -5
- package/dist/chunks/studio-rm9m3z60.js +0 -5
- package/dist/chunks/studio-tpmnbgmt.js +0 -5
- package/dist/chunks/studio-ttxhq5yt.js +0 -5
- package/dist/chunks/studio-y1x65h5r.js +0 -5
- package/dist/chunks/studio-zf188hnd.js +0 -5
- package/dist/chunks/toast-1gv0h53h.js +0 -4
- package/dist/chunks/workspace-3nt93k48.js +0 -4
- package/dist/chunks/workspace-home-zbgyqqws.js +0 -4
- package/src/services/directory-picker.ts +0 -187
- package/src/services/gated-registry.ts +0 -77
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{te}from"./studio-psh8mwnw.js";import{p}from"./studio-03mqh8ax.js";import{g,C}from"./studio-4kzbrr5t.js";import{hh,Sr,E$}from"./studio-de1s2x9v.js";import{Ot,Nt}from"./studio-cpkamjdn.js";import{Ue,wi,ft,T,R,Yt,tt}from"./studio-jttyqrmh.js";import{m,u,Kd}from"./studio-vzgmyt0v.js";import{zd}from"./studio-k3bcy02e.js";import{He}from"./studio-x3mjr5cc.js";import{zc,_a,XL,uA,QL,Sa,pA,fA,jb,tr}from"./studio-34jrz12k.js";import{Ow,Gu}from"./studio-hy4ye0dx.js";import{NT,Wu}from"./studio-agyvzfm4.js";import{Wt}from"./studio-x97ay0v4.js";import{jT,HT,BT,zT,ym}from"./studio-ndskgqef.js";import{bp}from"./studio-pgm83a2f.js";import{Rd,Dd,qu,_p,Aw}from"./studio-gr36vnte.js";import{n,_}from"./studio-zkq3r91p.js";import{le}from"./studio-7xag4na8.js";var D=[{key:"all",label:"All media"},{key:"image",label:"Images"},{key:"video",label:"Video"},{key:"audio",label:"Audio"},{key:"document",label:"Documents"},{key:"font",label:"Fonts"},{key:"unused",label:"Unused"}],pS=D.map((e)=>e.key);function re(e){return pS.some((t)=>t===e)}function L(e){return D.find((t)=>t.key===e)?.label??"All media"}var z=[{key:"newest",label:"Newest"},{key:"name",label:"Name"},{key:"size",label:"Size"}],Ce=z.map((e)=>e.key);function ne(e){return Ce.some((t)=>t===e)}function U(e,t,i){switch(t){case"all":return!0;case"unused":return i!==null&&i.has(e.file);default:return e.kind===t}}function W(e,t){let i=t.trim().toLowerCase();return i===""||e.name.toLowerCase().includes(i)}function q(e,t){return e.filter((a)=>U(a,t.filter,t.unused)&&W(a,t.query)).toSorted((a,r)=>De(t.sort,a,r)||a.file.localeCompare(r.file))}function De(e,t,i){switch(e){case"name":return t.name.localeCompare(i.name,void 0,{numeric:!0,sensitivity:"base"});case"size":return(i.bytes??-1)-(t.bytes??-1);default:return(i.modified??"").localeCompare(t.modified??"")}}function oe(e,t){let i={all:e.length,audio:0,document:0,font:0,image:0,unused:t===null?null:e.filter((a)=>t.has(a.file)).length,video:0};for(let a of e)i[a.kind]=(i[a.kind]??0)+1;return i}var Ee=132,ae=12;function se(e){return Math.max(1,Math.floor((e+ae)/(Ee+ae)))}function de(e,t,i,a,r=!1){if(a===0)return null;let o=Math.min(Math.max(e,0),a-1),l=o-o%i,c;switch(t){case"ArrowRight":{c=o+1;break}case"ArrowLeft":{c=o-1;break}case"ArrowDown":{c=o+i;break}case"ArrowUp":{c=o-i;break}case"Home":{c=r?0:l;break}case"End":{c=r?a-1:Math.min(l+i-1,a-1);break}default:return null}return c<0||c>=a?o:c}var pe={$schema:"https://jxsuite.com/schema/v1",$id:"StudioMediaLibrary",$description:"The Media workspace's library (`specs/studio.md` §22.6): the project's media as filters, a grid and the selected file's detail. ONE document in two modes. In `manage` it is the Media home tab, with Replace, Open in viewer and Delete under the detail; in `pick` it is the full-size picker inside a `jx-dialog` (`media-pick-dialog.json`), and the dialog's own footer answers Cancel or Use <file>. `media/media-library.ts` keeps every decision (which files a filter keeps, the sort, what a count may claim, where an arrow lands, what Replace writes) and hands this document strings and discriminants. **Unused is drawn with no number until the usage sweep has settled**, and Missing alt text and tags are not drawn at all: each needs a store that does not exist, and a filter that cannot be answered is not shipped as one that always answers nothing.",tagName:"div",attributes:{part:"media-library","data-jx-region":"${state.region}","data-mode":"${state.mode}","data-drop":"${state.dropActive}"},style:{$description:"Three columns over the whole stage: the filters, the grid with its toolbar, and the selected file's detail. Fills the pane's stage by its own geometry, as the workspace home does: the stage is `position: relative` (`pane-grid.json`). In pick mode the same columns fill the dialog's body instead, so the root's box is the only thing that differs between the two modes.",position:"absolute",inset:"0",display:"grid",gridTemplateColumns:"200px minmax(0, 1fr) 300px",boxSizing:"border-box",fontFamily:"var(--jx-font-sans)",fontSize:"var(--jx-text-md)",color:"var(--fg)",background:"var(--bg)",'&[data-mode="pick"]':{$description:"Inside a dialog there is no stage to fill: the box is the dialog body's, at a height the dialog can scroll within.",position:"relative",inset:"auto",height:"min(70vh, 620px)",gridTemplateColumns:"150px minmax(0, 1fr) 210px"},'&[data-drop="true"]':{$description:"The drop affordance is a STATE the flow holds, not a class a handler adds and forgets to take off.",outline:"2px dashed var(--accent)",outlineOffset:"-4px"},'& [part="filters"]':{display:"flex",flexDirection:"column",gap:"2px",padding:"var(--jx-space-3) var(--jx-space-2)",borderRight:"1px solid var(--border)",background:"var(--bg-panel)",overflowY:"auto"},'& [part="filters-heading"]':{margin:"0",padding:"var(--jx-space-2) var(--jx-space-2) var(--jx-space-1)",fontSize:"var(--jx-text-xs)",fontWeight:"600",letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--fg-dim)"},'& [part="filter"]':{display:"flex",alignItems:"center",gap:"var(--jx-space-2)",height:"30px",padding:"0 var(--jx-space-2)",border:"none",borderRadius:"var(--radius)",background:"none",color:"var(--fg)",font:"inherit",textAlign:"left",cursor:"pointer"},'& [part="filter"]:hover':{background:"var(--hover-bg)"},'& [part="filter"][aria-pressed="true"]':{background:"color-mix(in srgb, var(--accent) 16%, transparent)",color:"var(--fg)",fontWeight:"600"},'& [part="filter"]:focus-visible':{outline:"var(--jx-focus-ring)",outlineOffset:"-2px"},'& [part="filter-count"]':{marginLeft:"auto",fontSize:"var(--jx-text-xs)",color:"var(--fg-dim)",fontWeight:"400"},'& [part="main"]':{display:"flex",flexDirection:"column",minWidth:"0",minHeight:"0"},'& [part="toolbar"]':{display:"flex",alignItems:"center",flexWrap:"wrap",gap:"var(--jx-space-3)",padding:"var(--jx-space-3) var(--jx-space-4)",borderBottom:"1px solid var(--border)"},'& [part="title"]':{margin:"0 auto 0 0",fontSize:"var(--jx-text-lg)",fontWeight:"600"},'& [part="search"]':{width:"220px"},'& [part="sort"]':{width:"130px"},'& [part="upload"], & [part="empty-upload"]':{$description:"A LABEL around the file picker, not a button that clicks a hidden one: the picker is the control, so it takes focus, Enter opens it and a screen reader announces a file upload. A plain element because a label forwards a click to the input it contains and a custom element between the two would break that.",position:"relative",display:"inline-flex",alignItems:"center",gap:"6px",height:"28px",padding:"0 var(--jx-space-3)",border:"1px solid var(--border)",borderRadius:"var(--radius)",background:"var(--bg-panel)",color:"var(--fg)",font:"inherit",cursor:"pointer",":hover":{background:"var(--hover-bg)"},":has(:focus-visible)":{outline:"var(--jx-focus-ring)",outlineOffset:"2px"}},'& [part="upload-input"], & [part="replace-input"]':{$description:"Out of the way but still FOCUSABLE: `display: none` would take the control out of the tab order, and the label around it draws the focus ring for it.",position:"absolute",width:"1px",height:"1px",opacity:"0",pointerEvents:"none"},'& [part="upload-glyph"]':{"--jx-icon-size":"16px"},'& [part="body"]':{flex:"1",minHeight:"0",overflowY:"auto",padding:"var(--jx-space-4)"},'& [part="grid"]':{$description:"auto-fill over a minimum tile width; `media/media-library-model.ts` `gridColumns` does the same arithmetic, so ArrowDown lands on the tile drawn under the current one. Keep the two numbers in step.",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(132px, 1fr))",gap:"12px",alignContent:"start"},'& [part="tile"]':{display:"flex",flexDirection:"column",gap:"4px",padding:"4px",borderRadius:"var(--jx-radius-md, 6px)",border:"2px solid transparent",cursor:"pointer",minWidth:"0",outline:"none"},'& [part="tile"]:hover':{background:"var(--hover-bg)"},'& [part="tile"][aria-selected="true"]':{borderColor:"var(--accent)"},'& [part="tile"]:focus-visible':{outline:"var(--jx-focus-ring)",outlineOffset:"2px"},'& [part="thumb"]':{display:"flex",alignItems:"center",justifyContent:"center",aspectRatio:"4 / 3",borderRadius:"var(--radius)",background:"var(--bg-input)",overflow:"hidden",color:"var(--fg-dim)","--jx-icon-size":"28px"},'& [part="thumb-img"]':{width:"100%",height:"100%",objectFit:"cover"},'& [part="tile-name"]':{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"var(--jx-text-sm)"},'& [part="tile-caption"]':{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"var(--jx-text-xs)",color:"var(--fg-dim)",minHeight:"1em"},'& [part="empty"]':{display:"flex",flexDirection:"column",alignItems:"center",gap:"var(--jx-space-3)",padding:"48px var(--jx-space-6)",textAlign:"center",color:"var(--fg-dim)","--jx-icon-size":"40px"},'& [part="empty-title"]':{margin:"0",fontSize:"var(--jx-text-lg)",fontWeight:"600",color:"var(--fg)"},'& [part="empty-detail"]':{margin:"0",maxWidth:"42ch",lineHeight:"1.5"},'& [part="detail"]':{display:"flex",flexDirection:"column",gap:"var(--jx-space-3)",padding:"var(--jx-space-4)",borderLeft:"1px solid var(--border)",background:"var(--bg-panel)",overflowY:"auto",minWidth:"0"},'& [part="detail-hint"]':{margin:"auto 0",textAlign:"center",color:"var(--fg-dim)"},'& [part="detail-preview"]':{display:"flex",alignItems:"center",justifyContent:"center",minHeight:"140px",maxHeight:"220px",borderRadius:"var(--radius)",background:"var(--bg-input)",overflow:"hidden",color:"var(--fg-dim)","--jx-icon-size":"40px"},'& [part="preview-img"], & [part="preview-video"]':{maxWidth:"100%",maxHeight:"220px",objectFit:"contain"},'& [part="preview-audio"]':{width:"100%"},'& [part="preview-specimen"]':{$description:"The viewer's specimen at a side pane's size. The face arrives as the `@font-face` the flow writes under a family name generated from the path (`media/media-pane.ts` `specimenOf`); the element carries only that name, as a custom property, and the fallback stack is a rule, here.",display:"flex",flexDirection:"column",gap:"var(--jx-space-2)",padding:"var(--jx-space-4)",maxWidth:"100%",color:"var(--fg)",fontFamily:"var(--jx-specimen-family, system-ui), system-ui, sans-serif"},'& [part="specimen-line"]':{margin:"0",lineHeight:"1.3",overflowWrap:"anywhere"},'& [part="specimen-line"][data-size="32"]':{fontSize:"32px"},'& [part="specimen-line"][data-size="14"]':{fontSize:"var(--jx-text-md)"},'& [part="detail-name"]':{margin:"0",fontSize:"var(--jx-text-md)",fontWeight:"600",overflowWrap:"anywhere"},'& [part="facts"]':{margin:"0",color:"var(--fg-dim)",fontSize:"var(--jx-text-sm)"},'& [part="group-title"]':{margin:"0",fontSize:"var(--jx-text-xs)",fontWeight:"600",color:"var(--fg-dim)"},'& [part="url"]':{display:"flex",alignItems:"center",gap:"var(--jx-space-2)",minWidth:"0"},'& [part="url-value"]':{flex:"1",minWidth:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:"var(--jx-font-mono)",fontSize:"var(--jx-text-sm)"},'& [part="usage"]':{display:"flex",flexDirection:"column",gap:"var(--jx-space-1)"},'& [part="usage-headline"]':{margin:"0",fontSize:"var(--jx-text-sm)"},'& [part="usage-list"]':{margin:"0",padding:"0",listStyle:"none",display:"flex",flexDirection:"column",gap:"2px"},'& [part="usage-row"]':{display:"flex",alignItems:"center",gap:"var(--jx-space-2)"},'& [part="usage-link"]':{flex:"1",minWidth:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",border:"none",background:"none",padding:"0",color:"var(--accent)",font:"inherit",fontSize:"var(--jx-text-sm)",textAlign:"left",cursor:"pointer",":hover":{textDecoration:"underline"},":focus-visible":{outline:"var(--jx-focus-ring)"}},'& [part="usage-count"]':{fontSize:"var(--jx-text-xs)",color:"var(--fg-dim)"},'& [part="actions"]':{display:"flex",flexWrap:"wrap",gap:"var(--jx-space-2)",marginTop:"var(--jx-space-2)"},'& [part="replace"]':{position:"relative",display:"inline-flex",alignItems:"center",height:"28px",padding:"0 var(--jx-space-3)",border:"1px solid var(--border)",borderRadius:"var(--radius)",background:"var(--bg)",color:"var(--fg)",font:"inherit",cursor:"pointer",":hover":{background:"var(--hover-bg)"},":has(:focus-visible)":{outline:"var(--jx-focus-ring)",outlineOffset:"2px"}}},ondragover:{$prototype:"Function",body:[{preventDefault:!0},{operator:"call",target:{$ref:"#/state/dragOver"},value:[]}],description:"A file dropped ANYWHERE on the library uploads, to the destination the Upload label names before the drop: public/media/."},ondragleave:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/dragOut"},value:[]}]},ondrop:{$prototype:"Function",body:[{preventDefault:!0},{operator:"call",target:{$ref:"#/state/drop"},value:[{$ref:"event#/dataTransfer/files"}]}]},children:[{tagName:"nav",attributes:{part:"filters","aria-label":"Media filters"},children:[{tagName:"h2",attributes:{part:"filters-heading"},textContent:"Library"},{$prototype:"Array",items:{$ref:"#/state/filters"},key:{$ref:"$map/item/key"},map:{tagName:"button",attributes:{part:"filter",type:"button","aria-pressed":"${$map.item.pressed}","data-filter":"${$map.item.key}"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/setFilter"},value:[{$ref:"$map/item/key"}]}]},children:[{tagName:"span",attributes:{part:"filter-label"},textContent:"${$map.item.label}"},{tagName:"span",attributes:{part:"filter-count"},textContent:"${$map.item.count}"}]}}]},{tagName:"section",attributes:{part:"main","aria-labelledby":"${state.titleId}"},children:[{tagName:"header",attributes:{part:"toolbar"},children:[{tagName:"h2",attributes:{part:"title",id:"${state.titleId}"},textContent:"${state.title}"},{tagName:"jx-textfield",attributes:{part:"search"},$props:{type:"search",size:"sm",label:"Search media",placeholder:"Search by name…",autocomplete:"off",value:{$ref:"#/state/query"}},oninput:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/setQuery"},value:[{$ref:"event#/target/value"}]}]}},{tagName:"jx-select",attributes:{part:"sort"},$props:{label:"Sort",size:"sm",options:{$ref:"#/state/sortOptions"},value:{$ref:"#/state/sort"}},onchange:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/setSort"},value:[{$ref:"event#/target/value"}]}]}},{tagName:"label",attributes:{part:"upload",title:"${state.uploadHint}"},children:[{tagName:"input",attributes:{part:"upload-input",type:"file",multiple:!0,accept:"${state.uploadAccept}"},onchange:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/upload"},value:[{$ref:"event#/target"}]}],description:"The picker itself, so the destination in the label's tooltip is visible BEFORE the files are chosen. The flow takes the element rather than the file list because a file input that is not cleared refuses the same file twice."}},{tagName:"jx-icon",attributes:{part:"upload-glyph","aria-hidden":"true"},$props:{name:"upload-simple"}},{tagName:"span",textContent:"Upload"}]}]},{tagName:"div",attributes:{part:"body"},children:[{tagName:"div",attributes:{part:"grid-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/gridState"},cases:{loading:{tagName:"p",attributes:{part:"empty",role:"status"},textContent:"Reading the project's media…"},counting:{tagName:"p",attributes:{part:"empty",role:"status"},textContent:"${state.countingLabel}"},empty:{tagName:"div",attributes:{part:"empty"},children:[{tagName:"jx-icon",attributes:{part:"empty-glyph","aria-hidden":"true"},$props:{name:"image"}},{tagName:"p",attributes:{part:"empty-title"},textContent:"${state.emptyTitle}"},{tagName:"p",attributes:{part:"empty-detail"},textContent:"${state.emptyDetail}"},{tagName:"label",attributes:{part:"empty-upload",title:"${state.uploadHint}"},children:[{tagName:"input",attributes:{part:"upload-input",type:"file",multiple:!0,accept:"${state.uploadAccept}"},onchange:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/upload"},value:[{$ref:"event#/target"}]}],description:"The picker itself, so the destination in the label's tooltip is visible BEFORE the files are chosen. The flow takes the element rather than the file list because a file input that is not cleared refuses the same file twice."}},{tagName:"jx-icon",attributes:{part:"upload-glyph","aria-hidden":"true"},$props:{name:"upload-simple"}},{tagName:"span",textContent:"Upload"}]}]},nomatch:{tagName:"div",attributes:{part:"empty"},children:[{tagName:"jx-icon",attributes:{part:"empty-glyph","aria-hidden":"true"},$props:{name:"image"}},{tagName:"p",attributes:{part:"empty-title"},textContent:"${state.emptyTitle}"},{tagName:"p",attributes:{part:"empty-detail"},textContent:"${state.emptyDetail}"},{tagName:"jx-button",attributes:{part:"reset"},$props:{size:"sm",variant:"secondary"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/reset"},value:[]}]},children:[{tagName:"span",textContent:"Show all media"}]}]},listed:{tagName:"div",attributes:{part:"grid",role:"listbox","aria-labelledby":"${state.titleId}"},onkeydown:{$prototype:"Function",body:[{$switch:{$ref:"event#/key"},cases:{ArrowRight:[{preventDefault:!0},{operator:"call",target:{$ref:"#/state/key"},value:[{$ref:"event#/key"},{$ref:"event#/ctrlKey"}]}],ArrowLeft:[{preventDefault:!0},{operator:"call",target:{$ref:"#/state/key"},value:[{$ref:"event#/key"},{$ref:"event#/ctrlKey"}]}],ArrowDown:[{preventDefault:!0},{operator:"call",target:{$ref:"#/state/key"},value:[{$ref:"event#/key"},{$ref:"event#/ctrlKey"}]}],ArrowUp:[{preventDefault:!0},{operator:"call",target:{$ref:"#/state/key"},value:[{$ref:"event#/key"},{$ref:"event#/ctrlKey"}]}],Home:[{preventDefault:!0},{operator:"call",target:{$ref:"#/state/key"},value:[{$ref:"event#/key"},{$ref:"event#/ctrlKey"}]}],End:[{preventDefault:!0},{operator:"call",target:{$ref:"#/state/key"},value:[{$ref:"event#/key"},{$ref:"event#/ctrlKey"}]}],Enter:[{preventDefault:!0},{operator:"call",target:{$ref:"#/state/activateSelected"},value:[]}]}}],description:"The grid pattern: arrows move one tile, Home and End to the ends of the row, Ctrl+Home and Ctrl+End to the ends of the grid, and Enter opens the selected file (in pick mode, uses it). The flow computes where the move lands; the tile that receives it takes focus, so the roving tabindex follows the selection."},children:[{$prototype:"Array",items:{$ref:"#/state/tiles"},key:{$ref:"$map/item/key"},map:{tagName:"div",attributes:{part:"tile",role:"option","aria-selected":"${$map.item.selected}",tabindex:"${$map.item.tabindex}","data-file":"${$map.item.file}",title:"${$map.item.name}"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/select"},value:[{$ref:"$map/item/file"}]}]},onfocus:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/focusTile"},value:[{$ref:"$map/item/file"}]}],description:"Selection follows focus, the listbox pattern: a Tab onto the grid lands on the roving stop and selects it, so the first Enter opens (in pick mode, uses) the tile the focus ring is on rather than nothing."},ondblclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/activate"},value:[{$ref:"$map/item/file"}]}]},oncontextmenu:{$prototype:"Function",body:[{$switch:{$ref:"#/state/mode"},cases:{manage:[{preventDefault:!0},{operator:"call",target:{$ref:"#/state/contextMenu"},value:[{$ref:"$map/item/file"},{$ref:"event#/clientX"},{$ref:"event#/clientY"}]}]}}],description:"Manage mode only: the detail pane's actions at the pointer. Pick mode's dialog is modal, and a menu in the popover layer outside it would be inert, so its right-click is left to the platform."},children:[{tagName:"div",attributes:{part:"thumb"},children:[{tagName:"div",attributes:{part:"thumb-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"$map/item/thumbState"},cases:{image:{tagName:"img",attributes:{part:"thumb-img",src:"${$map.item.thumbSrc}",alt:"",draggable:"false"},onload:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/measure"},value:[{$ref:"$map/item/file"},{$ref:"event#/target/naturalWidth"},{$ref:"event#/target/naturalHeight"}]}]}},pending:{tagName:"span",attributes:{part:"thumb-pending","aria-hidden":"true"}},glyph:{tagName:"jx-icon",attributes:{part:"thumb-glyph","aria-hidden":"true"},$props:{name:{$ref:"$map/item/glyph"}}}},$description:"The thumbnail is asked for when the tile scrolls into view, not when the grid is built: `pending` until the flow's observer reports the tile, then the picture. A file the browser draws no picture of shows its kind's glyph."}]},{tagName:"span",attributes:{part:"tile-name"},textContent:"${$map.item.name}"},{tagName:"span",attributes:{part:"tile-caption"},textContent:"${$map.item.caption}"}]}}]}}}]}]},{tagName:"aside",attributes:{part:"detail","aria-label":"Details"},children:[{tagName:"div",attributes:{part:"detail-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/detailState"},cases:{none:{tagName:"p",attributes:{part:"detail-hint"},textContent:"${state.detailHint}"},shown:{tagName:"div",attributes:{part:"detail-body",role:"none"},style:{display:"contents"},children:[{tagName:"div",attributes:{part:"detail-preview"},children:[{tagName:"div",attributes:{part:"preview-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/previewKind"},cases:{image:{tagName:"img",attributes:{part:"preview-img",src:"${state.previewSrc}",alt:""},onload:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/measure"},value:[{$ref:"#/state/selectedFile"},{$ref:"event#/target/naturalWidth"},{$ref:"event#/target/naturalHeight"}]}]}},video:{tagName:"video",attributes:{part:"preview-video",src:"${state.previewSrc}",controls:!0}},audio:{tagName:"audio",attributes:{part:"preview-audio",src:"${state.previewSrc}",controls:!0}},font:{tagName:"div",attributes:{part:"preview-specimen",style:"${state.previewSpecimenFamily}"},children:[{tagName:"style",textContent:"${state.previewFontFace}"},{tagName:"p",attributes:{part:"specimen-line","data-size":"32"},textContent:"Aa"},{tagName:"p",attributes:{part:"specimen-line","data-size":"14"},textContent:"${state.previewSpecimen}"}]},glyph:{tagName:"jx-icon",attributes:{part:"preview-glyph","aria-hidden":"true"},$props:{name:{$ref:"#/state/previewGlyph"}}}}}]},{tagName:"h3",attributes:{part:"detail-name"},textContent:"${state.detailName}"},{tagName:"p",attributes:{part:"facts"},textContent:"${state.detailFacts}"},{tagName:"div",attributes:{part:"url-group"},children:[{tagName:"h4",attributes:{part:"group-title"},textContent:"Site URL"},{tagName:"div",attributes:{part:"url"},children:[{tagName:"code",attributes:{part:"url-value"},textContent:"${state.detailRef}"},{tagName:"jx-action-button",attributes:{part:"copy"},$props:{size:"sm",quiet:!0,hint:"Copy the site URL"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/copyRef"},value:[]}]},children:[{tagName:"span",textContent:"Copy"}]}]}]},{tagName:"div",attributes:{part:"usage-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/usageState"},cases:{shown:{tagName:"div",attributes:{part:"usage"},children:[{tagName:"h4",attributes:{part:"group-title"},textContent:"Used on"},{tagName:"p",attributes:{part:"usage-headline"},textContent:"${state.usageHeadline}"},{tagName:"div",attributes:{part:"usage-list-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/hasUsageFiles"},cases:{true:{tagName:"ul",attributes:{part:"usage-list"},children:[{$prototype:"Array",items:{$ref:"#/state/usageFiles"},key:{$ref:"$map/item/path"},map:{tagName:"li",attributes:{part:"usage-row","data-usage":"${$map.item.path}"},children:[{tagName:"button",attributes:{part:"usage-link",type:"button",title:"Open ${$map.item.path}"},textContent:"${$map.item.path}",onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/openDocument"},value:[{$ref:"$map/item/path"}]}]}},{tagName:"span",attributes:{part:"usage-count"},textContent:"${$map.item.count}"}]}}]}}}]}},$description:'Hidden on a host with no reference index, which is a different fact from "nothing uses it": a confident zero is the one answer this pane must never invent.'},{tagName:"div",attributes:{part:"actions-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/mode"},cases:{manage:{tagName:"div",attributes:{part:"actions"},children:[{tagName:"label",attributes:{part:"replace",title:"Replace ${state.detailName} everywhere it is used"},children:[{tagName:"input",attributes:{part:"replace-input",type:"file",accept:"${state.replaceAccept}"},onchange:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/replace"},value:[{$ref:"event#/target"}]}],description:"Replace writes the chosen file over this one's path, so every reference keeps resolving and now shows the new bytes (studio.md §9.3). The element rather than the list, so the input can be cleared."}},{tagName:"span",textContent:"Replace"}]},{tagName:"jx-button",attributes:{part:"open-viewer"},$props:{size:"sm",variant:"secondary"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/openViewer"},value:[]}]},children:[{tagName:"span",textContent:"Open in viewer"}]},{tagName:"jx-button",attributes:{part:"delete"},$props:{size:"sm",variant:"negative"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/remove"},value:[]}]},children:[{tagName:"span",textContent:"Delete"}]}]}},$description:"Manage mode's actions. Pick mode has none here: its answer is the dialog's own footer, Cancel and Use <file>."}]}}}]}]};T("media-library",pe);function Ie(){return{countingLabel:"",detailFacts:"",detailHint:"",detailName:"",detailRef:"",detailState:"none",dropActive:"false",emptyDetail:"",emptyTitle:"",filters:[],gridState:"loading",mode:"manage",previewFontFace:"",previewGlyph:"",previewKind:"glyph",previewSpecimen:"",previewSpecimenFamily:"",previewSrc:"",query:"",region:"",replaceAccept:"",selectedFile:"",sort:"",sortOptions:[],tiles:[],title:"",titleId:"",uploadAccept:"",uploadHint:"",usageFiles:[],usageHeadline:"",usageState:"hidden"}}function ce(e,t){Object.assign(e,t),e.hasUsageFiles=t.usageFiles.length>0}function Re(e){let t=n(e)?void 0:e.attributes?.part;return n(t)?t:""}function Pe(e){let t=e?.$map,i=_(t)&&"item"in t?t.item:void 0;return _(i)&&"file"in i&&n(i.file)?i.file:null}function V(e,t,i,a){if(a.clear)e.replaceChildren();let{tileHost:r,gridHost:o,inputHost:l,...c}=i,s=g({...Ie(),...c,hasUsageFiles:!1});ce(s,t);let h=null,w=!1,K=R("media-library",s,e,{onNodeCreated:(f,d,k,je)=>{if(w||!(f instanceof HTMLElement))return;let H=Re(k);if(H==="tile"){let ie=Pe(je);if(ie!==null)r(f,ie)}else if(H==="grid")o(f);else if(f instanceof HTMLInputElement&&H==="upload-input")l(f,"upload");else if(f instanceof HTMLInputElement&&H==="replace-input")l(f,"replace")}}).then((f)=>{if(w)f.dispose();else h=f;return f.root});return{attached:()=>{if(w)return!1;let f=h?.root;return f===void 0?!0:f instanceof HTMLElement&&e.contains(f)},dispose(){w=!0,h?.dispose(),h=null},ready:K,update:(f)=>ce(s,f)}}var ue={$schema:"https://jxsuite.com/schema/v1",$id:"StudioMediaPickDialog",$description:"The full-size media picker (`specs/studio.md` §9.3): a `jx-dialog` whose body is the Media workspace's own library surface in pick mode, so the picker and the workspace are one surface at two sizes. The dialog owns modality, Escape, the backdrop and focus restoration, and its footer is the answer: Cancel, or Use <file>, disabled until a file is chosen. The body is an ISLAND: this document draws the slot and nothing in it, and `surfaces/media-pick-dialog.ts` mounts `media-library.json` there through `onNodeCreated`.",tagName:"jx-dialog",$props:{headline:{$ref:"#/state/headline"},confirmLabel:{$ref:"#/state/confirmLabel"},confirmDisabled:{$ref:"#/state/blocked"},cancelLabel:"Cancel",dismissible:!0,size:"xl"},attributes:{part:"media-pick"},onconfirm:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/confirm"},value:[]}]},oncancel:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/closed"},value:[]}]},onclose:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/closed"},value:[]}]},children:[{tagName:"div",attributes:{part:"library-slot"},style:{$description:"The library's box in pick mode is its own (`media-library.json`, `data-mode=\"pick\"`); the slot only gives it the dialog body's width.",minWidth:"0"}}]};T("media-pick-dialog",ue);var B="media-picker";function Ke(e){let t=n(e)?void 0:e.attributes?.part;return n(t)?t:""}function fe(e){let t=document.createElement("div");t.style.pointerEvents="auto",t.setAttribute(Ue,ft("dialog",B)),e.layer.append(t);let i=!1,a=()=>{if(i)return;i=!0,e.closed()},r=()=>i,o=g({...e.view,closed:a,confirm:e.confirm}),l=null,c=R("media-pick-dialog",o,t,{onNodeCreated:(s,h,w)=>{if(!r()&&s instanceof HTMLElement&&Ke(w)==="library-slot")e.body(s)}}).then(async(s)=>{l=s;let h=s.root;if(r())return s.dispose(),h;if(await Yt(h),!r())Ot(h);return h});return{close(){let s=l?.root;if(s instanceof HTMLElement)Nt(s);l?.dispose(),l=null,t.remove(),a()},host:t,ready:c,update(s){Object.assign(o,s)}}}var nP="media-home",be={audio:"play",document:"file-text",font:"text-aa",image:"image",video:"play"},ze={audio:"Audio",document:"Document",font:"Font",image:"Image",video:"Video"},y={filter:"all",query:"",sort:"newest",selected:null},j=null,x=null,I=0,P=0,A=!1,Y=0;function J(){x=null,A=!1,I=0,P=0,Y+=1}function _e(){return[...S].some((e)=>!e.disposed&&e.choice.filter==="unused")}async function We(e){if(A||x!==null||!hh())return;let t=Y;A=!0,I=0,P=e.length;let i=new Set;for(let a of e){let r=await Gu(a.file);if(t!==Y)return;if(!_e()){J();return}if(r.status==="ready"&&r.result.files.length===0)i.add(a.file);I+=1,b()}x=i,A=!1,b()}var S=new Set,M=new Map,Q=new Set,N=null;function we(){if(N!==null)return;let e=()=>{J(),b()},t=NT(e),i=E$(e);N=()=>{t(),i()}}function qe(){if(S.size===0&&N)N(),N=null}function v(e){if(!e.disposed){if(e.handle?.update(Z(e)),e.onSelect?.(),Ve(e),e.focusOwed)queueMicrotask(()=>Ne(e));xe(e)}}function Ve(e){let t=e.reveal,i=t===null?void 0:e.tiles.get(t);if(i?.isConnected)e.reveal=null,i.scrollIntoView({block:"nearest"})}function xe(e){if(e.sweepTimer!==null||e.disposed)return;e.sweepTimer=setTimeout(()=>{e.sweepTimer=null,e.observer.releaseDetached();for(let[t,i]of e.tiles)if(!i.isConnected)e.tiles.delete(t);for(let t of[e.inputs.upload,e.inputs.replace])for(let i of t)if(!i.isConnected)t.delete(i)},0)}function Me(e){return[...e].find((t)=>t.isConnected)??null}function b(){for(let e of S)v(e)}function X(e){if(e.disposed=!0,e.sweepTimer!==null)clearTimeout(e.sweepTimer),e.sweepTimer=null;e.inputs.upload.clear(),e.inputs.replace.clear(),e.observer.destroy(),e.handle?.dispose(),e.handle=null,e.tiles.clear(),S.delete(e),qe()}function $e(e){let t=Wu(),i=t===null?null:e.images?t.filter((r)=>r.isImage):t;return{files:(i??[]).map((r)=>{let o=Dd(r.file);return{bytes:o?.bytes??null,file:r.file,kind:r.kind,modified:o?.modified??null,name:r.name}}),listed:i}}function Be(e){return D.filter((t)=>(t.key!=="unused"||hh())&&(!e.images||t.key==="image"||t.key==="unused"))}function wb(e){let{filter:t,query:i,selected:a}=e.choice;if(a===null)return null;let r=Wu()?.find((l)=>l.file===a)??null;if(r===null||e.images&&!r.isImage)return null;let o={bytes:null,file:r.file,kind:r.kind,modified:null,name:r.name};return U(o,t,x)&&W(o,i)?r:null}function Ge(e,t){if(t===0)return{emptyDetail:`Upload files or drop them anywhere here. They are saved under ${e.uploadDir}/, and anything already under public/ or a collection's images/ folder is listed here too.`,emptyTitle:e.images?"No images yet":"No media yet"};let{filter:i,query:a}=e.choice;if(a.trim()!=="")return{emptyDetail:`Nothing in ${L(i)} matches it.`,emptyTitle:`No matches for “${a.trim()}”`};if(i==="unused")return{emptyDetail:"Every file is referenced by at least one document.",emptyTitle:"No unused media"};return{emptyDetail:`${t} ${t===1?"file":"files"} in the project, none of them ${L(i).toLowerCase()}.`,emptyTitle:`No ${L(i).toLowerCase()}`}}function Z(e){let{choice:t}=e,{files:i,listed:a}=$e(e),r=oe(i,x),o=Be(e);if(!o.some((d)=>d.key===t.filter))t.filter=o[0]?.key??"all";let l=q(i,{filter:t.filter,query:t.query,sort:t.sort,unused:x}),c=Wu();if(t.filter==="unused"&&c!==null)We(c);let s="listed";if(a===null)s="loading";else if(t.filter==="unused"&&x===null)s="counting";else if(i.length===0||l.length===0)s=i.length===0?"empty":"nomatch";let h=wb(e),w=l.some((d)=>d.file===t.selected)?t.selected:l[0]?.file??null,K=l.map((d)=>{let k=d.kind==="image";return{caption:Aw(Dd(d.file))||ze[d.kind],file:d.file,glyph:be[d.kind],key:d.file,name:d.name,selected:d.file===t.selected?"true":"false",tabindex:d.file===w?"0":"-1",thumbSrc:k&&e.visible.has(d.file)?tr(d.file):"",thumbState:k?e.visible.has(d.file)?"image":"pending":"glyph"}}),f=e.images&&t.filter==="image"?"Images":L(t.filter);return{countingLabel:P>0?`Counting references… ${I} of ${P}`:"Counting references…",dropActive:e.dropActive?"true":"false",filters:o.map((d)=>{let k=r[d.key];return{count:k===null?"":String(k),key:d.key,label:e.images&&d.key==="image"?"All images":d.label,pressed:d.key===t.filter?"true":"false"}}),gridState:s,mode:e.mode,query:t.query,region:e.region,sort:t.sort,sortOptions:z.map((d)=>({label:d.label,value:d.key})),tiles:K,title:f,titleId:`media-library-title-${e.region.replaceAll(/[^\w-]/g,"-")}`,uploadAccept:e.images?"image/*":zc(),uploadHint:`Upload into ${e.uploadDir}/`,...Ge(e,i.length),...Ye(e,h)}}function Ye(e,t){if(t===null)return{detailFacts:"",detailHint:e.mode==="pick"?"Choose a file to use it.":"Select a file to see its details.",detailName:"",detailRef:"",detailState:"none",previewFontFace:"",previewGlyph:"",previewKind:"glyph",previewSpecimen:"",previewSpecimenFamily:"",previewSrc:"",replaceAccept:"",selectedFile:"",usageFiles:[],usageHeadline:"",usageState:"hidden"};let i=Dd(t.file),a=Ow(t.file);if(!Rd(t.file))qu(t.file).then(b);if(a===null||a.status==="pending")Gu(t.file).then(b);let r=jT(t.file),o=r==="image"||r==="video"||r==="audio"||r==="font"?r:"glyph",l=o==="font"?BT(t.file):{fontFace:"",specimen:"",specimenFamily:""};return{detailFacts:HT(t.file,i),detailHint:"",detailName:t.name,detailRef:t.ref,detailState:"shown",previewFontFace:l.fontFace,previewGlyph:be[t.kind],previewKind:o,previewSpecimen:l.specimen,previewSpecimenFamily:l.specimenFamily,previewSrc:o==="glyph"?"":tr(t.file),replaceAccept:pA(t.file),selectedFile:t.file,...zT(a)}}var me=null,ge=null;function Je(){return me??=(le("de90apn9"),import("./files-de90apn9.js")),me}function Qe(){return ge??=(le("y3w71k1n"),import("./file-ops-y3w71k1n.js")),ge}function ee(e){try{e.showPicker()}catch{e.focus()}}function F(e,t){e.choice.selected=t,v(e)}async function he(e,t){let i=await Sa([...t],{dir:e.uploadDir,only:e.images?"image":"media"}),[a]=i;if(!a)return;if(e.choice.filter!=="all"&&e.choice.filter!==a.kind)e.choice.filter=e.images?"image":"all";e.choice.query="",e.reveal=a.path,F(e,a.path)}async function KD(e){let t=e.split("/").pop()??e,{confirmFileDelete:i}=await Qe();if(!await i({name:t,path:e}))return!1;let{markLocalMutation:a}=await (le("77c0mr0x"),import("./fs-events-77c0mr0x.js"));try{a(e),await p().deleteFile(e)}catch(l){return C.error(`Could not delete ${t}.`,{detail:te(l),path:e,source:"Media"}),!1}if(zd([e]),Sr(),m.tabs.has(e))Kd(e);for(let l of S)if(l.choice.selected===e)l.choice.selected=null;if(y.selected===e)y.selected=null;let r=jb(e),o=await Xe(r,a);return await QL(o?jb(r):r),C.success(`Deleted ${t}`),!0}async function Xe(e,t){if(!uA(e))return!1;let i=p();try{if((await i.listDirectory(e)).length>0)return!1;return t(e),await i.deleteFile(e),!0}catch{return!1}}function ke(e){return{activate:(t)=>{F(e,t),ye(e,t)},activateSelected:()=>{let{selected:t}=e.choice;if(t!==null)ye(e,t)},contextMenu:(t,i,a)=>Ze(e,t,i,a),copyRef:()=>{let t=wb(e);if(t)Se(t)},dragOut:()=>{if(e.dropActive)e.dropActive=!1,v(e)},dragOver:()=>{if(!e.dropActive)e.dropActive=!0,v(e)},drop:(t)=>{if(e.dropActive=!1,v(e),t?.length)he(e,t)},focusTile:(t)=>{if(e.choice.selected!==t)F(e,t)},gridHost:(t)=>{e.grid=t},inputHost:(t,i)=>{e.inputs[i].add(t),xe(e);let a=j;if(e.mode==="manage"&&a?.role===i&&(i==="upload"||a.file===e.choice.selected))j=null,ee(t)},key:(t,i)=>et(e,t,i),measure:(t,i,a)=>{if(_p(t,i,a))b();else if(!Rd(t))qu(t).then(b)},openDocument:(t)=>{Je().then(({openFileInTab:i})=>i(t))},openViewer:()=>{let{selected:t}=e.choice;if(t!==null)ym(t)},remove:()=>{let{selected:t}=e.choice;if(t!==null)KD(t)},replace:(t)=>{let[i]=t.files??[];t.value="";let{selected:a}=e.choice;if(i&&a!==null)fA(a,i).then(b)},reset:()=>{e.choice.filter=e.images?"image":"all",e.choice.query="",v(e)},select:(t)=>F(e,t),setFilter:(t)=>{if(re(t))e.choice.filter=t,v(e)},setQuery:(t)=>{e.choice.query=t,v(e)},setSort:(t)=>{if(ne(t))e.choice.sort=t,v(e)},tileHost:(t,i)=>{e.tiles.set(i,t),Fe.set(t,i),e.observer.observe(t)},upload:(t)=>{let i=[...t.files??[]];if(t.value="",i.length>0)he(e,i)}}}function Se(e){if("clipboard"in navigator)navigator.clipboard.writeText(e.ref)}var E=null;function Ze(e,t,i,a){F(e,t);let r=wb(e);if(!r)return;E?.close();let o=(l,c,s,h={})=>({destructive:!1,disabled:!1,dividerAbove:!1,id:l,run:s,title:c,...h});E=Wt({label:`${r.name} actions`,onClosed:(l)=>{if(E===l)E=null},origin:{x:i,y:a},region:"media-tile",rows:[o("open","Open in Viewer",()=>ym(t)),o("copy-url","Copy Site URL",()=>Se(r)),o("replace","Replace…",()=>P2(t),{dividerAbove:!0}),o("delete","Delete",()=>{KD(t)},{destructive:!0,dividerAbove:!0})]})}function ye(e,t){if(e.mode==="pick"){let i=wb(e);if(i)e.onPick?.(i);return}ym(t)}function et(e,t,i){let{files:a}=$e(e),r=q(a,{filter:e.choice.filter,query:e.choice.query,sort:e.choice.sort,unused:x}),o=r.findIndex((h)=>h.file===e.choice.selected),l=e.grid?se(He(e.grid).width):1,c=o===-1?r.length>0?0:null:de(o,t,l,r.length,i),s=c===null?void 0:r[c];if(!s)return;F(e,s.file),e.tiles.get(s.file)?.focus()}var Fe=new WeakMap;function Le(e,t,i,a,r,o){let l={choice:t,disposed:!1,dropActive:!1,grid:null,handle:null,images:r,inputs:{replace:new Set,upload:new Set},mode:e,observer:bp((c)=>{let s=Fe.get(c);if(s!==void 0&&!l.visible.has(s))l.visible.add(s),it(l)}),onPick:null,onSelect:null,paneId:a,reveal:null,focusOwed:!1,region:i,sweepTimer:null,tiles:new Map,uploadDir:o,visible:new Set};return l}var G=new Set;function it(e){if(G.has(e))return;G.add(e),queueMicrotask(()=>{G.delete(e),v(e)})}function fS(e,t){let i=M.get(e);return i!==void 0&&i.tabId===t.id&&i.wrap.isConnected&&i.mount.handle!==null&&i.mount.handle.attached()}function _w(e){let t=M.get(e);if(!t)return;X(t.mount),M.delete(e)}function LT(e,t){let{paneId:i,wrap:a}=e;if(fS(i,t))return;_w(i);let r=Le("manage",y,wi(i,"media-library"),i,!1,_a);if(S.add(r),we(),r.handle=V(a,Z(r),ke(r),{clear:!0}),M.set(i,{mount:r,tabId:t.id,wrap:a}),Q.delete(i))Te(r)}async function Te(e){await e.handle?.ready,Ne(e,!0)}function Ne(e,t=e.focusOwed){if(!t||e.disposed)return;let{selected:i}=e.choice,a=(i===null?void 0:e.tiles.get(i))??[...e.tiles.values()].find((r)=>r.getAttribute("tabindex")==="0");if(a?.isConnected){e.focusOwed=!1,a.focus();return}e.focusOwed=!0}function $T(e){let t=M.get(e);if(t?.wrap.isConnected&&t.mount.handle?.attached()===!0){Te(t.mount);return}Q.add(e)}function M2(e){if(e.filter!==void 0)y.filter=e.filter;if(e.query!==void 0)y.query=e.query;if(e.select!==void 0){if(y.selected=e.select,y.filter!=="all")y.filter="all";y.query=""}b()}function iP(){let e=[...M.values()].map((t)=>Me(t.mount.inputs.upload)).find((t)=>t!==null)??null;if(e){ee(e);return}j={file:null,role:"upload"}}function P2(e){M2({select:e});let t=null;for(let i of M.values())if(i.mount.choice.selected===e)t??=Me(i.mount.inputs.replace);if(t){ee(t);return}j={file:e,role:"replace"}}var O=null;function ve(e){let t=wb(e);return{blocked:t===null,confirmLabel:t?`Use ${t.name}`:e.images?"Use image":"Use file",headline:e.images?"Choose an image":"Choose media"}}function mS(){let e=O;if(O=null,e)X(e.mount),e.dialog.close()}function oP(e){mS();let t={filter:e.images?"image":"all",query:"",selected:null,sort:"newest"},i=Le("pick",t,`${ft("dialog",B)}/library`,null,e.images,XL(u.value?.documentPath??null)),a=(o)=>{mS(),e.onPick(o.ref)};i.onPick=a,S.add(i),we();let r=fe({body:(o)=>{i.handle=V(o,Z(i),ke(i),{clear:!1})},closed:()=>{if(O?.mount===i)mS();else X(i)},confirm:()=>{let o=wb(i);if(o)a(o)},layer:tt("dialog"),view:ve(i)});i.onSelect=()=>r.update(ve(i)),O={dialog:r,mount:i}}function IT(){mS();for(let e of M.keys())_w(e);y.filter="all",y.query="",y.selected=null,y.sort="newest",j=null,Q.clear(),J()}
|
|
2
|
+
export{pS,nP,wb,KD,fS,_w,LT,$T,M2,iP,P2,mS,oP,IT};
|
|
3
|
+
|
|
4
|
+
//# debugId=72978E599475305164756E2164756E21
|
|
5
|
+
//# sourceMappingURL=studio-p1n2xjda.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{gx,Mp,Pp,Fp,bx,Rm,jd,Jb,jp,w$,lh,Nm,UA,ka}from"./studio-cpkamjdn.js";import{p}from"./studio-03mqh8ax.js";import{ph}from"./studio-k3bcy02e.js";import{uv}from"./studio-vzgmyt0v.js";import{Ht,fn}from"./studio-3w35qvay.js";import{Ne}from"./studio-1e8dw2w2.js";import{rh,Bb,Md,zb,Wb,sh}from"./studio-x3mjr5cc.js";import{qw}from"./studio-pqqq6v85.js";import{jr}from"./studio-c1pxszat.js";import{S}from"./studio-45gyxpcq.js";import{n,Q,_,v,td}from"./studio-zkq3r91p.js";function C(e,t){return new URL(`/node_modules/${e}`,t).href}function x(e){if(e===void 0)return!1;if(n(e))return!e.includes("${");if(Array.isArray(e))return e.every((t)=>x(t));if(v(e))return!("$ref"in e)&&!("$prototype"in e)&&!("$expression"in e)&&Object.values(e).every((t)=>x(t));return!0}function gS(e){let t=new Map;for(let[s,r]of Object.entries(e.state??{})){if(td(s)||!v(r)||!Array.isArray(r.examples))continue;let[o]=r.examples;if(x(o))t.set(s,o)}return t}var k={body:"body",root:":root"};function R(e,t,s,r,o=k){let l=[],a=(i,c)=>{let d={mediaQueries:t,scope:c,transposeValue:s};if(r)d.resolveValue=(m,g)=>r(m,g,c);for(let m of Rm(i,d))l.push(m.text)},y={},h={},b=[],w=[];for(let[i,c]of Object.entries(e)){if(_(c)&&!Array.isArray(c)){if(i.startsWith("@"))b.push([i,c]);else if(!i.startsWith("--"))w.push([i,c]);continue}if(bx(i)||i.startsWith("@"))continue;if(i.startsWith("--")||i==="colorScheme"||i==="color-scheme")y[i]=c;else h[i]=c}a(y,o.root),a(h,o.body);for(let[i,c]of w)if(i.startsWith("&"))a({[i]:c},o.root);else a(c,i);for(let[i,c]of b){if(gx(i)||Mp(i)){a({[i]:c},null);continue}let d={},m={},g=[];for(let[u,f]of Object.entries(c)){if(_(f)&&!Array.isArray(f)){if(!u.startsWith("@"))g.push([u,f]);continue}if(u.startsWith("--"))d[u]=f;else m[u]=f}a({[i]:d},o.root),a({[i]:m},o.body);for(let[u,f]of g)a({[i]:f},u)}if(Object.values(t).some((i)=>Fp(i)!==null)&&!("colorScheme"in e))l.push(`${o.root} { color-scheme: light dark }`,`${o.root}:where([${Pp}="light"]) { color-scheme: light }`,`${o.root}:where([${Pp}="dark"]) { color-scheme: dark }`);return l.join(`
|
|
2
|
+
`)}var T={body:":host",root:":host"},P=new WeakMap,J=new WeakMap;function A(e){let t=e.replaceAll(/:root\b/g,":host").replaceAll(/(^|[\s,>+~(])(?:html|body)(?![\w-])/g,"$1:host").replaceAll(/:host(?:\s*>?\s*:host)+/g,":host");return t===e?null:t}function j(e){for(let t=0;t<e.cssRules.length;t+=1){let s=e.cssRules[t],r=s instanceof CSSStyleRule?A(s.selectorText):null;if(s instanceof CSSStyleRule&&r!==null){let l=`${r}${s.cssText.slice(s.cssText.indexOf("{"))}`;try{e.insertRule(l,t),e.deleteRule(t+1)}catch{}}let o=e.cssRules[t];if(o instanceof CSSGroupingRule)j(o)}}function D(e){let t=[];for(let s of e??[]){if(!_(s)||String(s.tagName).toLowerCase()!=="link")continue;let{href:r,rel:o}=s.attributes??{};if(n(r)&&r!==""&&n(o)&&o.split(/\s+/).includes("stylesheet"))t.push(r)}return t}async function M(e){let t=Wb(e,"project.json");try{let s=await fetch(t);if(!s.ok)return null;let r=new URL(t,location.href).href,o=new CSSStyleSheet({baseURL:r});return o.replaceSync(await s.text()),j(o),o}catch{return null}}async function L(e){let s=(await Promise.all(D(e.$head).map((o)=>M(o)))).filter((o)=>o!==null),{style:r}=e;if(_(r)){let o=new CSSStyleSheet;o.replaceSync(R(r,e.$media??{},(l)=>l,void 0,T)),s.push(o)}return s}function E(){let e=S?.projectConfig;if(!e||!Q(globalThis.CSSStyleSheet))return Promise.resolve([]);let t=P.get(e);if(!t)t=L(e).then((s)=>(J.set(e,s),s)),P.set(e,t);return t}function JD(){let e=S?.projectConfig;return(e&&J.get(e))??[]}var H=150;function Sw(e=H){let t=new Map;function s(){for(let[r,o]of t){if(t.size<=e)break;t.delete(r),o.remove()}}return{clear(){for(let r of t.values())r.remove();t.clear()},get(r){let o=t.get(r);if(o!==void 0)t.delete(r),t.set(r,o);return o},has:(r)=>t.has(r),keys:()=>[...t.keys()],set(r,o){t.delete(r),t.set(r,o),s()},size:()=>t.size}}function O(e){let t=Md(S?.projectRoot);return URL.canParse(t)?new URL(e,t).href:location.href}async function N(e){try{let t=await p().readFile(e);jd(!0);let s=zb(e,sh());await Ht();let r;if(fn(e))r=(await jr(e,t)).document;else r=JSON.parse(t);return await F(r,e,s)}catch{return null}}async function F(e,t,s){jd(!0),Jb(Bb());let r=await lh(e,{},O(t)),o=s&&{...s,versions:ph()};w$((l)=>uv(l,o));try{let l=ka(e,r);return l instanceof HTMLElement?l:null}finally{w$(null)}}async function W(e,t){let s=await RT(t);if(!s)return null;let r=gS(s);return await bS(s,t,r)?qw(e,r):null}async function RT(e){try{let t=JSON.parse(await p().readFile(e));return _(t)&&!Array.isArray(t)?t:null}catch{return null}}async function bS(e,t,s){let r=null;try{jd(!0),Jb(Bb());let o=await lh(e,{},O(t));for(let[y,h]of s)o[y]=h;let l=!1;Nm(()=>{l=!0});let{stop:a}=jp(()=>ka({...e,tagName:"div"},o));return r=a,!l}catch{return!1}finally{Nm(null),r?.()}}function V(e){return e.source!=="npm"&&(e.path?.endsWith(".json")??!1)}async function Cw(e,t){let s=t.get(e);if(s)return s;let r;try{UA((l)=>C(l,`${rh()}/`)),await E();let o=Ne.find((l)=>l.path===e);if(o&&V(o))r=await W(o,e);else r=o?await qw(o):await N(e)}catch{return}if(!r)return;return t.set(e,r),r}function bp(e){if(!Q(globalThis.IntersectionObserver))return{destroy(){},observe:(r)=>e(r),releaseDetached:()=>0};let t=new Set,s=new IntersectionObserver((r)=>{for(let o of r)if(o.isIntersecting)t.delete(o.target),s.unobserve(o.target),e(o.target)},{rootMargin:"200px"});return{destroy(){s.disconnect(),t.clear()},observe(r){if(t.has(r))return;t.add(r),s.observe(r)},releaseDetached(){let r=0;for(let o of t)if(!o.isConnected)t.delete(o),s.unobserve(o),r+=1;return r}}}
|
|
3
|
+
export{gS,JD,Sw,RT,bS,Cw,bp};
|
|
4
|
+
|
|
5
|
+
//# debugId=6A7EA18CA4A7F43864756E2164756E21
|
|
6
|
+
//# sourceMappingURL=studio-pgm83a2f.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{p,_e}from"./studio-03mqh8ax.js";import{Pn,tv,Vt,ln,go,wx,tO,Tn,Oe,$a,Ix,St,Rx,Hi,Vn,Ce,ui,j$,To,We,Un,Y,or,vh,Vp,Qe,Up,hi,m,u,pn,kr,qp}from"./studio-vzgmyt0v.js";import{ge,ne,de,C}from"./studio-4kzbrr5t.js";import{st,bo,Gp,Zc}from"./studio-x08a3m0a.js";import{Qc,Wi}from"./studio-3w35qvay.js";import{YS,Ne,Fc,jc}from"./studio-1e8dw2w2.js";import{L$,ph}from"./studio-k3bcy02e.js";import{He,cx,Js,nn,rh,Md,zb,sh}from"./studio-x3mjr5cc.js";import{Fp,jd,Yb,Gc,Ts,Eo,Ls,Ea,Hp,Jl,Zb,GA,_r,oo,uh,Xb,ae}from"./studio-cpkamjdn.js";import{ol,zr,qs,Gs,Wr}from"./studio-ewarnzm4.js";import{to,XN,HL,Xw,Qw,Es,Ip,il,ex,BL,h,YL}from"./studio-5wzdy1jc.js";import{rr,Ut,zi,Er,S,_h,Xp,Sh,xn}from"./studio-45gyxpcq.js";import{oe,ta}from"./studio-ekgtrndg.js";import{Zx}from"./studio-5tzgq6fx.js";import{n,Z,Q,_,v,Me,Go,Gn,it,td}from"./studio-zkq3r91p.js";import{le}from"./studio-7xag4na8.js";var at="jx:canvas";function Qt(e){let{target:t,source:o,targetOrigin:r,acceptOrigin:i,token:a}=e,l=new Set,s=(c)=>{if(i!=="*"&&c.origin!==i)return;let d=c.data;if(!_(d)||!(at in d)||d[at]!==a)return;let f="payload"in d?d.payload:void 0;for(let g of l)g(f)};return o.addEventListener("message",s),{dispose(){l.clear(),o.removeEventListener("message",s)},onMessage(c){return l.add(c),()=>l.delete(c)},post(c){t.postMessage({[at]:a,payload:c},r)}}}var lt=null;function en(){return lt}function Eb(e){if(lt){lt(e);return}window.open(e,"_blank","noopener,noreferrer")}function vr(){return bo(m.activePaneId)}function vt(e){let t=pn(e),o=t?.derived,r=o?.kind==="lens"?pn(o.sourcePaneId)?.activeTabId:t?.activeTabId;return r?m.tabs.get(r)??null:null}function Hr(e){return pn(e)?.derived??null}function kS(e){if(!e)return[];let t=[];for(let o of m.panes)if(vt(o.id)?.id===e.id)t.push(bo(o.id));return t}function W(e){for(let t of Gp()){let o=t.panels.find((r)=>r.canvas===e);if(o)return{panel:o,surface:t}}return null}function tn(e){let t=e.canvas,o=t?W(t):null;return o?vt(o.surface.paneId):null}function Nc(e){let t=e?.session.ui,o=t?.canvasMode??"design";return t?.preview&&(o==="edit"||o==="design")?"preview":o}function Wo(e){let t=Hr(e);if(t?.kind==="lens"){let o=t.mode;return vt(e)?.session.ui?.preview&&(o==="edit"||o==="design")?"preview":o}return Nc(vt(e))}function tl(e){let t=Hr(e);if(t?.kind==="lens"&&t.preset==="breakpoint")return t.media;return vt(e)?.session.ui.activeMedia??null}function ct(e){return Zc(e)?.paneId??hi}function ce(e){return vt(ct(e))}function Se(e,t,o,r=null,i=null,a=[]){if(!e.state)e.state={};let l={};if(i!==null)l.defaultLocale=i.defaultLocale,l.locales=i.locales;e.state.$site={name:t.name??"Jx Site",url:t.url??"",...l,...t.state};let s=(n(e.$lang)?e.$lang:void 0)??tO(o.urlPattern,i)??t.defaults?.lang,c=a.map((f)=>({code:f.locale,current:f.urlPattern===o.urlPattern,dir:tv(f.locale),label:Vt(f.locale),url:f.urlPattern})),d={params:o._pathParams??{},title:e.title??e._pageTitle??t.name??"",url:o.urlPattern};if(c.length>0)d.alternates=c;if(s!==void 0)d.dir=tv(s),d.locale=s;if(e.state.$page=d,t.state){for(let[f,g]of Object.entries(t.state))if(f!=="$site"&&f!=="$page"&&!(f in e.state))e.state[f]=g}if(t.$media)e.$media={...t.$media,...e.$media};if(t.imports&&Object.keys(t.imports).length>0){if(!e.imports)e.imports={};for(let[f,g]of Object.entries(t.imports))if(!(f in e.imports))e.imports[f]=r&&(g.startsWith("./")||g.startsWith("../"))?r(g,o):g}if(t.$elements?.length)if(!e.$elements?.length)e.$elements=[...t.$elements];else{let f=new Set,g=[];for(let y of[...t.$elements,...e.$elements]){let b=n(y)?y:_(y)?y.$ref:void 0;if(b&&!f.has(b))f.add(b),g.push(y)}e.$elements=g}return e}var Ar=/\[\.\.\.(\w+)\]|\[(\w+)\]/g;function on(e){return e.split("\\").join("/").replace(/^\.\//,"").replace(/^\//,"").replace(/^pages\//,"")}function yr(e){let t=on(e),o=t.slice(t.lastIndexOf("/")+1),r=o.lastIndexOf(".");if(r>0)t=t.slice(0,t.length-(o.length-r));if(t.endsWith("/index"))t=t.slice(0,-6)||"/";else if(t==="index")t="/";if(!t.startsWith("/"))t=`/${t}`;let i=[],a=!1,l=!1,s=t.replaceAll(Ar,(c,d,f)=>{if(a=!0,d)return l=!0,i.push(d),"*";return i.push(f),`:${f}`});return{isCatchAll:l,isDynamic:a,params:i,urlPattern:s}}function Ju(e){if(!e)return"/";return yr(e).urlPattern}function Ac(e){if(!e)return[];return yr(e).params}function Yu(e,t){let o=on(e).split("/");if(!o.every((l)=>l!==""&&l[0]!=="_"))return!1;if(t===void 0)return!0;let r=o.at(-1)??"",i=r.lastIndexOf("."),a=i>0?r.slice(i).toLowerCase():"";return a!==""&&new Set(t).has(a)}function ES(e,t){if(e.isDynamic!==t.isDynamic)return e.isDynamic?1:-1;if(e.isCatchAll!==t.isCatchAll)return e.isCatchAll?1:-1;return e.urlPattern.localeCompare(t.urlPattern)}var $r=new Set(["img","video","source","iframe","audio"]),rn="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",ut="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 yN(e,t){e.addEventListener("error",(o)=>{let{target:r}=o;if(r instanceof HTMLImageElement&&r.getAttribute("src")!==ut)r.setAttribute("src",ut),r.removeAttribute("srcset"),r.dataset.placeholder=""},{capture:!0,signal:t})}var Ir=/(src|poster|image|bg|background|icon|logo|photo|avatar|thumbnail|cover|banner)$/i;function an(e){return Ir.test(e)}var Dr=/(?<![\w$.])(?:item|index|\$map)\b/u;function B(e){if(n(e))return e.includes("${")&&Dr.test(e);return Gn(e)&&n(e.$ref)&&/^(?:#\/)?\$map\//u.test(e.$ref)}function we(e,t){if(e==="href"||e==="action")return"";if(an(e))return ut;if(n(t))return dt(t);return Gn(t)&&n(t.$ref)?fn(t.$ref):""}var Jr=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"]),Lr=new Set(["div","section","article","aside","header","footer","main","nav","figure","figcaption","details","fieldset","form","ul","ol","dl","table"]);var jr=["width","height","inlineSize","blockSize"];function Fr(e){let{style:t}=e;if(!_(t))return!1;return jr.some((o)=>{let r=t[o],i=Z(r)?String(r):n(r)?r.trim():"";return i!==""&&i!=="auto"})}function Vr(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(Fr(e))return null;if(Jr.has(it(e.tagName)))return"empty-text-placeholder";if(Lr.has(it(e.tagName)))return"empty-container-placeholder";return null}function dt(e){return e.replaceAll(/\$\{([^}]+)\}/g,"❪ $1 ❫")}function qr(e,t){let o=e.map;return{children:_(o)?[F(o,Kr(e.items,t))]:[],className:"repeater-perimeter",tagName:"div"}}function sn(e){return JSON.stringify(e)}function cn(e){let t=e.startsWith("#/")?e.slice(2):e,[o,...r]=t.split("/"),i=o==="state"||o==="$map"?o:null;if(i===null)return null;let a=r.map((l)=>l.replaceAll("~1","/").replaceAll("~0","~"));return i+a.map((l)=>`?.[${sn(l)}]`).join("")}function pt(e,t){if(t===null)return`(${e})`;return`((r) => ((item, index, $map) => (${e}))(r, 0, { index: 0, item: r }))(${t})`}function Kr(e,t){if(Array.isArray(e))return`${sn(e)}[0]`;if(Me(e)){let r=cn(e.$ref);return r===null?null:`${pt(r,t)}?.[0]`}let o=n(e)?un(e):[];if(n(e)&&o.length===1&&Ur(e,o[0]))return`${pt(o[0].expr,t)}?.[0]`;return null}function Ur(e,t){return t.start===0&&t.end===e.length-1}function un(e){let t=[],o=e.indexOf("${");while(o!==-1){let r=0,i=-1;for(let a=o+1;a<e.length;a+=1)if(e[a]==="{")r+=1;else if(e[a]==="}"){if(r-=1,r===0){i=a;break}}if(i===-1)break;t.push({end:i,expr:e.slice(o+2,i),start:o}),o=e.indexOf("${",i+1)}return t}function dn(e,t=null){let o=un(e);if(o.length===0)return e;let r="",i=0;for(let{start:a,end:l,expr:s}of o)r+=e.slice(i,a),r+=`\${(() => { try { return ${pt(s,t)}; } catch { return ""; } })()}`,i=l+1;return r+e.slice(i)}function Gr(e,t){let o=e.startsWith("#/")?e.slice(2):e;if(o!=="$map"&&!o.startsWith("$map/"))return{$ref:e};let r=cn(e);return t===null||r===null?void 0:dn(`\${${r}}`,t)}function fn(e){return`{${e.startsWith("#/state/")?e.slice(8):e}}`}function ft(e,t=null){return F(e,t)}function F(e,t){if(Array.isArray(e))return e.map((s)=>F(s,t));if(!Gn(e))return e;if(e.$prototype==="Array")return qr(e,t);let o=e,r={},i=!1,a=n(o.tagName)&&$r.has(o.tagName);if(a){let{attributes:s,src:c}=o,d=s?.src,f=o.poster,g=s?.poster;if(!(c&&c!==""||d&&d!=="")&&!(f&&f!==""||g&&g!==""))i=!0}for(let[s,c]of Object.entries(o))if(s==="state"||s==="$media"||s==="$elements")r[s]=c;else if(s==="$props"&&_h(c)){let d={};for(let[f,g]of Object.entries(c))if(!B(g))d[f]=g;else if(n(g))d[f]=an(f)||f==="href"||f==="action"?we(f,g):dn(g,t);else if(Me(g)){let y=Gr(g.$ref,t);if(y!==void 0)d[f]=y}else d[f]=g;r[s]=d}else if(s==="children")if(Array.isArray(c))r.children=c.map((d)=>F(d,t));else if(Gn(c)&&c.$prototype==="Array")r.children=[F(c,t)];else r.children=F(c,t);else if(s==="cases"&&o.$switch&&_h(c)){let[d]=Object.entries(c);if(d){let[,f]=d;r.children=_h(f)&&!(Gn(f)&&f.$ref)?[F(f,t)]:[{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: ${Object.keys(c).join(" | ")}]`}]}}else if(s==="attributes"&&a&&_h(c)){let d={};for(let[f,g]of Object.entries(c))if((f==="src"||f==="poster")&&(g===""||g==null||B(g)))i=!0,d[f]=rn;else d[f]=B(g)?we(f,g):g;r.attributes=d}else if(s==="attributes"&&_h(c)){let d={};for(let[f,g]of Object.entries(c))d[f]=B(g)?we(f,g):g;r.attributes=d}else if(s==="style")if(_h(c)){let d={};for(let[f,g]of Object.entries(c))if(!B(g))d[f]=g;r.style=d}else r.style=c;else if(s==="$switch"&&n(c)&&c.includes("${"))r[s]=dt(c);else if(s==="textContent"&&n(c)&&c.includes("${"))r[s]=dt(c);else if(s==="textContent"&&Gn(c)&&c.$ref)r[s]=fn(c.$ref);else if(a&&(s==="src"||s==="poster"))if(c===""||c==null||B(c))i=!0,r[s]=rn;else r[s]=c;else if(B(c))r[s]=we(s,c);else if(n(c)||Gn(c)&&c.$ref)r[s]=c;else r[s]=F(c,t);let l=Vr(r);if(l)r.className=r.className?`${r.className} ${l}`:l;if(i){let s=n(r.className)?r.className:"";if(!s.includes("empty-media-placeholder"))r.className=s?`${s} empty-media-placeholder`:"empty-media-placeholder"}return r}function TS(e){let t=e.document?.$paths,o=e.frontmatter?.$paths;return t??o??null}var Te=new Map;function wN(){Te.clear()}function xN(e,t){if(!t)return Promise.resolve({});let o=`${e??""}::${JSON.stringify(t)}`,r=Te.get(o);if(!r)r=Zr(t).catch((i)=>(Te.delete(o),console.warn("page-params: failed to enumerate $paths values:",i),{})),Te.set(o,r);return r}async function Zr(e){if(Array.isArray(e)){let t={};for(let o of e)for(let[r,i]of Object.entries(o))Ee(t,r,i);return t}if("contentType"in e&&n(e.contentType)&&e.contentType){let t=e.param??"slug",o=e.field??"id",r=await Xr(e.contentType),i={[t]:[]};if(!Array.isArray(r))return i;let a=r;for(let l of a)Ee(i,t,o==="id"?l.id:l.data?.[o]??l.id);return i}if("values"in e&&Array.isArray(e.values)){let t=e.param??"value",o={[t]:[]};for(let r of e.values)Ee(o,t,r);return o}if("$ref"in e&&n(e.$ref)&&e.$ref){let t=e.param??"id",o=e.field??"id",r=await p().readFile(e.$ref.replace(/^\.\//,"")),i=JSON.parse(r),a={[t]:[]};if(!Array.isArray(i))return a;for(let l of i)Ee(a,t,v(l)?l[o]??l.id??l:l);return a}return{}}async function Yr(){let e=await Qc();for(let t of e){let o=t.classes?.find((r)=>r.name==="ContentCollection");if(o)return o.path}return"@jxsuite/parser/ContentCollection.class.json"}async function Xr(e){let t={$prototype:"ContentCollection",$src:await Yr(),contentType:e},o=p();if(o.resolveClass)return o.resolveClass(t);return fetch("/__jx_resolve__",{body:JSON.stringify(t),headers:{"content-type":"application/json"},method:"POST"}).then((r)=>{if(!r.ok)throw Error(`Class resolution failed: ${r.status}`);return r.json()})}function Ee(e,t,o){if(o===null||o===void 0||o==="")return;let r=String(o);e[t]??=[];let i=e[t];if(!i.includes(r))i.push(r)}function mn(e,t,o){if(Object.keys(t).length===0)return e;let r=yn(e,t);return r.state??={},r.state.$page={params:{...t},title:n(r.title)?r.title:"",url:Ju(o)},r}function gn(e){if(!e)return[];return Object.keys(e).filter((t)=>{let o=e[t];return v(o)&&n(o.$prototype)&&n(o.$src)&&JSON.stringify(o).includes('"#/$params/')})}async function hn(e,t,o){if(t.length===0)return;let r=p(),{resolveClass:i}=r;if(!i)return;let{state:a}=e;if(!a)return;await Promise.all(t.map(async(l)=>{let s=a[l];if(!v(s))return;let c={...s};if(o)c.$base=o;try{a[l]=await i.call(r,c)}catch(d){console.warn(`page-params: failed to resolve state.${l} for preview:`,d)}}))}function vn(e,t){let o=Qr(e,t);if(o!==null)return o;if(Array.isArray(e))return e.map((r)=>vn(r,t));return v(e)?yn(e,t):e}function yn(e,t){let o={};for(let[r,i]of Object.entries(e))o[r]=vn(i,t);return o}function Qr(e,t){if(!Me(e)||!e.$ref.startsWith("#/$params/"))return null;return t[e.$ref.slice(10)]??null}function LS(e){let t=e?.tagName;return n(t)&&t.includes("-")}function ei(e){return _(e)&&!Array.isArray(e)}function bn(e){if(e===void 0)return null;if(ei(e)){if(e.$expression||e.$compute||e.$prototype||e.$handler)return null;return"default"in e||"type"in e?"signal":"literal"}return n(e)&&e.includes("${")?null:"literal"}function _N(e){let t=e?.state??{},o=[];for(let[r,i]of Object.entries(t)){if(td(r))continue;let a=bn(i);if(!a)continue;let l=a==="signal"?i.default:i;o.push({name:r,value:l})}return o}function Cn(e,t){let o={...e.state},r=!1;for(let[i,a]of Object.entries(t)){let l=o[i],s=bn(l);if(!s)continue;o[i]=s==="signal"?{...l,default:a}:a,r=!0}if(!r)return e;return{...e,state:o}}var ti=new Set(["data","media","metadata","news","series","species"]),ni=new Set(["archive","catalog","catalogue","collection","directory","faq","gallery","inventory","library","menu","portfolio","showcase"]);function $S(e){return e.replaceAll(/[_-]+/g," ").replaceAll(/([a-z\d])([A-Z])/g,"$1 $2").trim().replaceAll(/\s+/g," ").toLowerCase()}function Zu(e){let t=/[_-]|[a-z\d][A-Z]/.test(e)?$S(e):e,o=t.lastIndexOf(" "),r=t.slice(o+1);if(ni.has(r.toLowerCase()))return`${t} item`;return`${t.slice(0,o+1)}${oi(r)}`}function oi(e){if(ti.has(e.toLowerCase()))return e;if(/[^aeiou]ies$/.test(e))return`${e.slice(0,-3)}y`;if(/(?:ss|x|ch|sh|z)es$/.test(e))return e.slice(0,-2);if(/(?:us|is|ss)$/.test(e))return e;if(e.endsWith("s"))return e.slice(0,-1);return e}function Tb(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Lb(e){return(e.replaceAll("\\","/").split("/").pop()??e).replace(/\.[^.]+$/,"").replaceAll(/[-_]+/g," ").replaceAll(/\b\w/g,(o)=>o.toUpperCase())}var di="pages";function mt(){return S?.projectConfig?.content??{}}function Sn(e){return e!==void 0&&/\.[\da-z]+$/i.test(e.replace(/\/+$/,""))}var ri={fileBacked:!1,item:"page",key:di,kind:"pages",title:"Pages"};function wm(){let e=Object.entries(mt()).map(([t,o])=>({fileBacked:Sn(o.source),item:Zu(t),key:t,kind:"collection",title:Tb($S(t))}));return[ri,...e]}function YT(){return wm().map((e)=>e.key)}function Fw(e){let t=mt()[e]?.source;return t!==void 0&&Sn(t)?t.replace(/^\.\//,""):null}function SN(e){return mt()[e]?.schema??null}function Wl(e){return wm().find((t)=>t.key===e)??null}function Vl(e){if(!e)return null;let t=e.replaceAll("\\","/").replace(/^\.\//,"");if(Js.has(nn(t)))return null;if(t.startsWith("pages/"))return Yu(t)?di:null;return Un(t)?.name??null}function Xu(e){if(!e)return!1;let t=Un(e);if(!t||t.fileBacked)return!1;let o=nn(e);return o!==".json"&&o!==".csv"}function CN(e,t){if(e===void 0||t)return{entries:!0,pages:!0,scan:!0};let o=e.map((r)=>r.replaceAll("\\","/").replace(/^\.\//,""));return{entries:o.some((r)=>{let i=Vl(r);return i!==null&&i!==di}),pages:o.some((r)=>r.startsWith("pages/")),scan:!1}}function ii(e,t,o){let r=e?.state??t?.state,i=`#/$params/${o}`;for(let a of Object.values(v(r)?r:{})){if(!v(a)||a.$prototype!=="ContentEntry")continue;let{contentType:l,id:s}=a;if(v(s)&&s.$ref===i&&n(l)&&l!=="")return l}return null}function IS(e,t){let o=TS({document:e,frontmatter:t}),r=null,i=null,a=null,l=null;if(o&&!Array.isArray(o)&&"contentType"in o){let d=o.contentType;r=n(d)&&d!==""?d:null;let f="param"in o?o.param:void 0;i=n(f)&&f!==""?f:null;let g="field"in o?o.field:void 0;a=n(g)&&g!==""&&g!=="id"?g:null}else if(o&&!Array.isArray(o)&&"values"in o){let d="param"in o?o.param:void 0,f=n(d)&&d!==""?d:null;r=f===null?null:ii(e,t,f),i=r===null?null:f;let g=o.values;l=r!==null&&Array.isArray(g)?g.flatMap((y)=>{let b=ht(y);return b===null?[]:[b]}):null}let s=e?.$layout??t?.$layout,c=n(s)||s===!1?s:void 0;return{contentType:r,field:a,layout:c,param:i,...l!==null&&{values:l}}}async function ZT(e){let t={contentType:null,field:null,layout:void 0,param:null};try{let o=await p().readFile(e);if(e.endsWith(".json"))return IS(JSON.parse(o),null);let{parseSourceForPath:r}=await (le("y3w71k1n"),import("./file-ops-y3w71k1n.js")),i=await r(e,o);return IS(i.document,i.frontmatter)}catch{return t}}var V=null,ue=null,gt=0,Re=new Set;async function wn(e,t){let o;try{o=await p().listDirectory(e)}catch{return}await Promise.all(o.map(async(r)=>{if(r.type==="directory")await wn(r.path,t);else t.push(r.path)}))}async function ai(){let e=[];await wn("pages",e);let t=e.filter((a)=>a.includes("[")&&Yu(a)).toSorted(),o=await Promise.all(t.map(async(a)=>[a,await ZT(a)])),{i18n:r}=ln(S?.projectConfig??{}),i=new Map;for(let[a,l]of o)if(l.contentType){let s={field:l.field,layout:l.layout,locale:wx(a,r),param:l.param,path:a,pattern:yr(a).urlPattern,...l.values&&{values:l.values}};i.set(l.contentType,[...i.get(l.contentType)??[],s])}return i}function yt(){if(V)return Promise.resolve(V);if(!_e()||!S)return Promise.resolve(new Map);if(!ue){let e=gt;ue=ai().then((t)=>{if(e===gt){V=t,ue=null;for(let o of Re)o()}return t})}return ue}function En(e,t){if(!e||e.length===0)return null;let o=Pn(t),r=ln(S?.projectConfig??{}).i18n?.defaultLocale??null;return(o===null?void 0:e.find((i)=>i.locale===o))??(r===null?void 0:e.find((i)=>i.locale===r))??e.find((i)=>i.locale===null)??e[0]}function Oc(e){if(!e)return null;return go(e,ln(S?.projectConfig??{}).i18n)}function Qu(e,t){if(!V){yt();return}return En(V.get(e),t)}function kN(e){if(!V){yt();return}return V.get(e)??[]}async function Ae(e,t){let o=await yt();return En(o.get(e),t)}function $b(){gt+=1,V=null,ue=null}function Cp(e){return Re.add(e),()=>{Re.delete(e)}}function ht(e){if(n(e)&&e!=="")return e;return Z(e)&&Number.isFinite(e)?String(e):null}function RS(e,t,o){if(!e)return null;let r=t.split("/").pop()??t,i=r.lastIndexOf("."),a=i>0?r.slice(0,i):r,l=e.field===null?null:ht(o?.[e.field]),s=t.endsWith(".json")?ht(o?.id):null,c=l??s??a;if(e.values&&!e.values.includes(c))return null;if(e.param)return e.pattern.replace(`:${e.param}`,c);return e.pattern.replace(/:[A-Za-z_]\w*/,c)}function DS(e,t){if(e===!1)return null;if(n(e)&&e!=="")return e;if(t?.layout===!1)return null;if(n(t?.layout)&&t.layout!=="")return t.layout;return S?.projectConfig?.defaults?.layout??null}function EN(){$b(),Re.clear()}function si(e,t){let o=t.split("/"),r={};for(let[i,a]of e.split("/").entries()){let l=o[i];if(a.startsWith(":")&&l!==void 0)r[a.slice(1)]=l}return r}async function li(e){let{documentPath:t,fields:o,isEntry:r,params:i}=e;if(!r)return{_pathParams:{...i},sourcePath:t,urlPattern:Ju(t)};let a=Un(t),l=a?await Ae(a.name,Oc(t)):null,s=RS(l,t,o);if(!l||s===null)return{_pathParams:{},sourcePath:t,urlPattern:l?.pattern??"/"};return{_pathParams:si(l.pattern,s),sourcePath:l.path,urlPattern:s}}async function Mn(e,t){if(!t)return null;let o=await li(e),r=e.fields?.title,i=n(e.title)?e.title:n(r)?r:null,a={state:{}};if(i!==null)a.title=i;if(n(e.lang))a.$lang=e.lang;let l=Se(a,t,o,null,ln(t).i18n),{$page:s,$site:c}=l.state??{};return s===void 0||c===void 0?null:{$page:s,$site:c}}var $e=new Map;function NS(){$e=new Map}function ci(e){if(!e.startsWith("#/state/"))return null;let[t]=e.slice(8).split("/");return t?t.replaceAll("~1","/").replaceAll("~0","~"):null}function xt(e){if(n(e))return e.includes("${");if(Array.isArray(e))return e.some((t)=>xt(t));return v(e)&&Object.values(e).some((t)=>xt(t))}function Nn(e,t){if(n(e.$src))return e.$src;return n(e.$prototype)&&Object.hasOwn(t,e.$prototype)?t[e.$prototype]??null:null}function bt(e,t={}){return v(e)&&n(e.$prototype)&&Nn(e,t)!==null&&!xt(e)}function On(e,t){return Object.entries(e.state??{}).filter(([,o])=>v(o)&&!n(o.$src)&&bt(o,t)).map(([o])=>o)}function Rn(e){let t=new Set,o=(i)=>{if(Array.isArray(i)){for(let a of i)o(a);return}if(!Gn(i))return;if(i.$prototype==="Array"&&Me(i.items)){let a=ci(i.items.$ref);if(a)t.add(a)}o(i.map),o(i.children);for(let a of Object.values(i.cases??{}))o(a)};o(e.children);let r=e.state??{};return[...t].filter((i)=>bt(r[i]))}function pi(e,t){return console.warn(`canvas: could not resolve state.${e} before the render:`,t),null}async function An(e,t,o,r={}){let i=p(),{resolveClass:a}=i,l=e.state;if(t.length===0||!a||!l)return e;let s={...l};return await Promise.all(t.map(async(c)=>{let d=s[c];if(!bt(d,r))return;let f={...d,$src:Nn(d,r)};if(o)f.$base=o;let g=JSON.stringify(f),y=$e.get(g);if(!y)y=a.call(i,f).then((T)=>T??null,(T)=>($e.delete(g),pi(c,T))),$e.set(g,y);let b=await y;if(b!==null)s[c]=b})),{...e,state:s}}function $n(e,t=[]){if(!_(e))return null;if(Array.isArray(e.children)){let o=e.children.findIndex((r)=>_(r)&&!r.$__layout);if(o!==-1)return{offset:o,prefix:[...t,"children"]};for(let r=0;r<e.children.length;r++){let i=e.children[r];if(_(i)&&i.$__layout){let a=$n(i,[...t,"children",r]);if(a)return a}}}return null}function Ct(e,t,o=[]){if(!_(e))return;if(e.$__layout={file:t,path:o},Array.isArray(e.children))for(let[r,i]of e.children.entries()){if(n(i))continue;Ct(i,t,[...o,"children",r])}if(Array.isArray(e.$elements)){for(let[r,i]of e.$elements.entries())if(!n(i))Ct(i,t,[...o,"$elements",r])}}async function In(e,t=new Set){let o=e.replace(/^\.\//,"");if(t.has(o))return null;t.add(o);let r=await ex(e);if(!r)return null;Ct(r,o);let i=r.$layout;if(!n(i)||!i)return r;let a=await In(i,t);if(!a)return r;let l=BL(a,r);return delete l.$layout,l}function fi(e,t){for(let o of e??[]){if(!_(o)||!n(o.$ref)||!/^\.\.?\//.test(o.$ref))continue;let r=o.$__layout;if(!v(r)||!n(r.file))continue;let i=new URL(o.$ref,`jx-project:/${r.file}`).pathname.replace(/^\//,"");o.$ref=jc(t,i)}}function Dn(e,t){if(e.$layout!==void 0)return e.$layout;let o=t?.doc.content.frontmatter.$layout;return n(o)||o===!1?o:void 0}async function mi(e,t,o){let r=Dn(e,t),i=o?Un(o):null,a=i?await Ae(i.name,Oc(o)):null;return DS(r,a)}async function kn(e,t,o=null){let r={documentPath:t?.documentPath,mode:t?.doc.mode},i=o??Nc(t),a=i==="preview"?structuredClone(de(e)):ft(Xp(e)),l=!1,s=r.documentPath&&S?.isSiteProject&&(r.documentPath.startsWith("pages/")||r.documentPath.startsWith("./pages/")),c=!s&&Boolean(S?.isSiteProject)&&Xu(r.documentPath),d=null,f=0;if((s||c)&&t?.session.ui.showLayout!==!1){let w=c?await mi(e,t,r.documentPath):il(Dn(e,t));if(w){let M=await In(w);if(M){let D=i==="preview"?structuredClone(de(e)):a,P=BL(M,D);if(a=i==="preview"?P:ft(Xp(P)),l=!0,r.documentPath)fi(a.$elements,r.documentPath);let O=$n(P);d=O?.prefix??null,f=O?.offset??0}}}let g=S?.projectConfig;if(s&&g){if(a={...a,state:{...a.state}},a.imports)a.imports={...a.imports};Se(a,g,{urlPattern:Ju(r.documentPath)})}let y=Md(S?.projectRoot),b=r.documentPath?new URL(r.documentPath,y).href:void 0,T=zb(r.documentPath,sh());if(s&&t){let{previewParams:w}=t.session.ui;if(Object.keys(w).length>0){let M=gn(e.state??null);a=mn(a,w,r.documentPath),await hn(a,M,b)}}if((s||c)&&r.documentPath){let w=await Mn({documentPath:r.documentPath,fields:c?t?.doc.content.frontmatter??null:null,isEntry:c,lang:e.$lang,params:t?.session.ui.previewParams??{},title:e.title},S?.projectConfig);if(w)a={...a,state:{...a.state,...w}}}let k=await Qc(),I=HL(k),J=On(a,I);if(i!=="preview")J.push(...Rn(e));if(a=await An(a,[...new Set(J)],b,I),!s&&t&&LS(a)){let{previewProps:w}=t.session.ui;if(w&&Object.keys(w).length>0)a=Cn(a,w)}let te=new Set;if(i!=="preview")(function w(M,D){if(!_(M))return;if(M.$prototype==="Array"){te.add(D.join("/"));let P=M.map;if(_(P))w(P,[...D,"map"]);return}if(Array.isArray(M.children))for(let[P,O]of M.children.entries()){if(n(O))continue;w(O,[...D,"children",P])}else if(Go(M.children))w(M.children,[...D,"children"]);if(M.$switch&&M.cases)for(let[P,O]of Object.entries(M.cases))w(O,[...D,"cases",P])})(e,[]);let ot=r.documentPath!=null&&(r.documentPath.startsWith("layouts/")||r.documentPath.startsWith("./layouts/")),Pe=Xw(a.$elements);if((r.mode==="content"||l||ot)&&Ne.length>0){let w=new Set(Pe.map((P)=>_(P)?P.$ref:P)),M=new Map(Ne.map((P)=>[P.tagName,P])),D=YS(a);if(a.tagName)D.add(it(a.tagName));for(let P of D)for(let O of M.get(P)?.uses??[])D.add(O);for(let P of D){let O=M.get(P);if(O&&O.source!=="npm"&&O.path){let rt=jc(r.documentPath??null,O.path);if(!w.has(rt))Pe.push({$ref:rt}),w.add(rt)}}}if(Pe.length>0)a.$elements=Pe;return a.imports=XN(a.imports,k),a.$media=to(a.$media),a.$head=Qw(a.$head),{assets:T,docBase:b,mapperCtx:{arrayPaths:[...te],canvasMode:i,layoutWrapped:l,pageContentOffset:f,pageContentPrefix:d},renderDoc:a,siteStyle:S?.projectConfig?.style??null}}var gi=128,XT="fullRender",TN="mountCanvas",LN="patchBatch",Ln="prepareRender",Vo={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=Vo;var Jn=new Map;function _n(){try{return typeof localStorage<"u"&&Boolean(localStorage.getItem("jx-canvas-debug"))}catch{return!1}}function Hn(){return typeof performance<"u"&&Q(performance.now)?performance.now():0}function jn(e,t){if(_n())console.debug(`[jx-canvas] ${e}`,t??"")}function jw(e){Vo.escalations+=1,Vo.lastEscalationReason=e,jn("escalation",e)}function vi(e){if(e.length===0)return 0;let t=e.toSorted((r,i)=>r-i),o=Math.min(t.length-1,Math.ceil(t.length*0.95)-1);return t[Math.max(0,o)]??0}function yi(e,t){let o=Number.isFinite(t)&&t>0?t:0,r=Jn.get(e);if(!r)r=[],Jn.set(e,r);if(r.push(o),r.length>gi)r.shift();let i=Vo.timings[e],a={count:(i?.count??0)+1,lastMs:o,maxMs:Math.max(i?.maxMs??0,o),p95Ms:vi(r),totalMs:(i?.totalMs??0)+o};if(Vo.timings[e]=a,e===XT)Vo.lastFullRenderMs=a.lastMs,Vo.p95FullRenderMs=a.p95Ms;jn(`span:${e}`,`${o.toFixed(2)}ms`)}function Fn(e){let t=Hn(),o=_n(),r=`jx-${e}-start`;if(o)try{performance.mark(r)}catch{}let i=!1;return()=>{if(i)return Vo.timings[e]?.lastMs??0;i=!0;let a=Hn()-t;if(o)try{performance.measure(`jx-${e}`,r),performance.clearMarks(r)}catch{}return yi(e,a),a}}function AS(e,t){let o=Fn(e);try{return t()}finally{o()}}async function OS(e,t){let o=Fn(e);try{return await t()}finally{o()}}function ji(e){if(e==="--")return"Base";return e.replace(/^--/,"").replaceAll("-"," ").replaceAll(/\b\w/g,(t)=>t.toUpperCase())||e}var qn=new Set(["script","style","link","iframe","object","embed"]);function eh(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 Pt(e){return _(e)&&n(e.$ref)?e.$ref:null}function Ie(e){if(e.source!=="npm"||!e.package)return null;return e.modulePath?`${e.package}/${e.modulePath}`:e.package}function xi(e,t){let o=Ie(e);if(o)return o;return e.path?{$ref:jc(t,e.path)}:null}function QT(e,t,o){let r=Ie(t);if(r)return e.some((a)=>n(a)&&(a===r||a===t.package));if(!t.path)return!1;let i=re(jc(o,t.path));return e.some((a)=>{let l=Pt(a);return l!==null&&re(l)===i})}function re(e){return e.replace(/^(?:\.\/)+/,"")}function Ib(e,t,o){let r=xi(t,o);if(!r)return[...e];let a=Ie(t)&&t.modulePath?e.filter((l)=>l!==t.package):[...e];return QT(a,t,o)?a:[...a,r]}function eL(e,t,o){let r=Ie(t);if(r)return e.filter((a)=>!(n(a)&&(a===r||a===t.package)));if(!t.path)return[...e];let i=re(jc(o,t.path));return e.filter((a)=>{let l=Pt(a);return l===null||re(l)!==i})}function $N(e,t){return e.filter((o)=>!n(o)||!(o===t||o.startsWith(`${t}/`)))}function IN(e,t){let o=re(t);return e.filter((r)=>{let i=Pt(r);return i===null||re(i)!==o})}var bi="Components";function kp(e,t){let o=Ci(e,t);if(o)Qe(e,[],"$elements",o)}function Ci(e,t){if(!n(t)||!t.includes("-"))return null;let o=Ne.find((a)=>a.tagName===t);if(!o)return null;let r=e.doc.document.$elements??[],i=Ib(r,o,e.documentPath??null);return i.length===r.length?null:i}function MS(e){let t=Ne.find((o)=>o.tagName===e);return t?Fc(t):null}function RN(){return Ne.map((e)=>({component:!0,description:(e.source==="npm"?e.package:e.path)??"",group:bi,label:`<${e.tagName}>`,tag:e.tagName}))}function z(e){if(!e)return[];if(Array.isArray(e.children))return e.children;return n(e.textContent)&&e.textContent.length>0?[e.textContent]:[]}function pe(e){let t=0;for(let o of e)t+=n(o)?o.length:pe(z(o));return t}function wt(e,t,o){let r=[],i=0;for(let a of e){if(i>=o)break;if(n(a)){let d=i+a.length;if(d>t){let f=a.slice(Math.max(0,t-i),Math.max(0,Math.min(o,d)-i));if(f)r.push(f)}i=d;continue}let l=z(a),s=pe(l),c=i+s;if(s===0){if(i>=t&&i<o)r.push({...a})}else if(c>t){let d=wt(l,Math.max(0,t-i),Math.min(o,c)-i);if(d.length>0)r.push(Pi(a,d))}i=c}return r}function Pi(e,t){let{children:o,textContent:r,...i}=e;if(t.length===0)return{...i,textContent:""};if(t.length===1&&n(t[0]))return{...i,textContent:t[0]};return{...i,children:t}}function Wn(e){let t=[];for(let o of e){if(n(o)){if(o.length===0)continue;let r=t.at(-1);if(n(r)){t[t.length-1]=r+o;continue}}t.push(o)}return t}function Bn(e,t,o,r,i=""){return Wn([...wt(e,0,t),...i?[i]:[],...wt(o,r,pe(o))])}function Et(e){let t=Wn(e);if(t.length===0)return{textContent:""};if(t.length===1&&n(t[0]))return{textContent:t[0]};return{children:t}}function zn(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;let[o]=t;if(t.length===1&&n(o)&&o.trim()==="")return!0;return t.length===1&&_(o)&&o.tagName==="br"}function Tt(e){return{index:zi(e),parentPath:Ut(e)}}function Kn(e,t,o,r,i={}){if(!e)return;let a=oe(e.doc.document,t);if(o){if(a&&JSON.stringify(a.children)===JSON.stringify(o))return;Y(e,(l)=>{if(a?.textContent!=null)Qe(l,t,"textContent");Qe(l,t,"children",o)},{coalesceKey:i.coalesceKey??null})}else if(r!=null){if(a&&a.textContent===r&&!a.children)return;Y(e,(l)=>{if(a?.children)Qe(l,t,"children");Qe(l,t,"textContent",r)},{coalesceKey:i.coalesceKey??null})}}function Zn(e,t,o,r){if(!e)return!1;let i=oe(e.doc.document,t);if(!i)return!1;if(`${i.$props?.[o]??""}`===r)return!1;return Y(e,(l)=>{Up(l,t,o,r)}),!0}function Yn(e,t,o){if(!e)return null;let r=oe(e.doc.document,t),i=oe(e.doc.document,o);if(!r||!i)return null;if(ta(t,o)||ta(o,t))return null;let a=z(i),l=z(r),s=pe(a),c=Et([...a,...l]);return Y(e,(d)=>{if(c.children){if(i.textContent!=null)Qe(d,o,"textContent");Qe(d,o,"children",c.children)}else{if(i.children)Qe(d,o,"children");Qe(d,o,"textContent",c.textContent??"")}if(vh(d,t),Xn(d,Ut(t)),qp(e))d.session.selection=[o]}),{offset:s,path:o}}function Xn(e,t){let o=t;while(o.length>0){let r=oe(e.doc.document,o),i=r?.children;if(!r||!Array.isArray(i)||i.length>0)return;let a=Ut(o);if(vh(e,o),!a)return;o=a}}function Qn(e,t,o,r){let{parentPath:i,index:a}=Tt(t),l=[...i,"children",a+1];if(!e)return l;let s={tagName:"p"};if(r.textContent!=null)s.textContent=r.textContent;else if(r.children)s.children=r.children;else s.textContent="";return Y(e,(c)=>{if(o.textContent!=null)Qe(c,t,"children"),Qe(c,t,"textContent",o.textContent);else if(o.children)Qe(c,t,"textContent"),Qe(c,t,"children",o.children);if(or(c,i,a+1,s),qp(e))c.session.selection=[l]}),l}function Si(e,t,o,r){let{parentPath:i,index:a}=Tt(t),l=zn(r),s=l?a:a+1,c=[...i,"children",s];if(!e)return c;return Y(e,(d)=>{if(l)vh(d,t);else if(r?.children)Qe(d,t,"textContent"),Qe(d,t,"children",r.children);else if(r?.textContent!=null)Qe(d,t,"children"),Qe(d,t,"textContent",r.textContent);if(or(d,i,s,o),kp(d,o.tagName),qp(e))d.session.selection=[c]}),c}function eo(e,t,o,r){let i=o.component===!0?MS(o.tag):null;if(i)return Si(e,t,i,r);if(zn(r)){if(!e)return t;return Y(e,(d)=>{Qe(d,t,"tagName",o.tag),Qe(d,t,"children");let f=eh(o.tag);if(f.textContent&&f.textContent!=="Paragraph text")Qe(d,t,"textContent",f.textContent);else Qe(d,t,"textContent");if(qp(e))d.session.selection=[t]}),t}let{parentPath:a,index:l}=Tt(t),s=[...a,"children",l+1];if(!e)return s;let c=eh(o.tag);return Y(e,(d)=>{if(r?.children)Qe(d,t,"textContent"),Qe(d,t,"children",r.children);else if(r?.textContent!=null)Qe(d,t,"children"),Qe(d,t,"textContent",r.textContent);if(or(d,a,l+1,structuredClone(c)),qp(e))d.session.selection=[s]}),s}function no(e,t,o,r,i){if(!e)return null;let a=oe(e.doc.document,t.path),l=oe(e.doc.document,o.path);if(!a||!l)return null;if(ta(t.path,o.path)||ta(o.path,t.path))return null;let s=Et(Bn(z(a),t.offset,z(l),o.offset,i)),c=[...r,o.path].toSorted(wi);return Y(e,(d)=>{if(s.children){if(a.textContent!=null)Qe(d,t.path,"textContent");Qe(d,t.path,"children",s.children)}else{if(a.children)Qe(d,t.path,"children");Qe(d,t.path,"textContent",s.textContent??"")}for(let f of c)if(oe(d.doc.document,f))vh(d,f),Xn(d,Ut(f));if(qp(e))d.session.selection=[t.path]}),{offset:t.offset+i.length,path:t.path}}function wi(e,t){let o=Math.min(e.length,t.length);for(let r=0;r<o;r++){let i=e[r],a=t[r];if(i===a)continue;if(Z(i)&&Z(a))return a-i;return String(a).localeCompare(String(i))}return t.length-e.length}function R(e,t=1){return{height:e.height*t,left:e.x*t,top:e.y*t,width:e.width*t}}function DN(e,t,o=1){return{x:(e.x-t.left)/o,y:(e.y-t.top)/o}}function De(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 ro(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 o=e.createElement("div");o.className="overlay-box overlay-selection",o.style.display="none";let r=e.createElement("div");r.className="overlay-label",r.style.display="none",o.append(r);let i=e.createElement("div");i.className="overlay-box overlay-hover",i.style.display="none";let a=e.createElement("div");a.className="canvas-drop-indicator",a.style.display="none";let l=e.createElement("button");l.className="insertion-helper",l.textContent="+",l.style.pointerEvents="auto",l.style.display="none";let s=e.createElement("div");s.className="canvas-replace-target",s.style.display="none";let c=e.createElement("div");c.className="overlay-presence-group";let d=e.createElement("div");return d.className="overlay-coselection-group",t.append(i,o,d,a,s,l,c),{dispose:()=>t.remove(),insertButton:l,root:t,setDropIndicator:(f,g="inside")=>Ti(a,f,g),setHover:(f)=>De(i,f),setInsertZone:(f,g="center")=>Ei(l,f,g),setReplaceTarget:(f)=>De(s,f),setSuppressed:(f)=>{t.style.display=f?"none":""},setCoSelection:(f)=>{d.replaceChildren();for(let g of f){let y=e.createElement("div");y.className="overlay-box overlay-selection overlay-coselection",De(y,g),d.append(y)}},setPresence:(f)=>{c.replaceChildren();for(let g of f){let y=e.createElement("div");y.className="overlay-box overlay-presence",y.style.cssText=`position:absolute;display:block;pointer-events:none;outline:1.5px solid ${g.color};outline-offset:1px;left:${g.placement.left}px;top:${g.placement.top}px;width:${g.placement.width}px;height:${g.placement.height}px`;let b=e.createElement("div");b.className="overlay-presence-tag",b.textContent=g.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:${g.color}`,y.append(b),c.append(y)}},setSelection:(f,g=null)=>{if(De(o,f),f&&g)r.textContent=g,r.style.display="block";else r.style.display="none"}}}function Ei(e,t,o){if(!t){e.style.display="none",e.classList.remove("visible");return}e.dataset.edge=o,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 Ti(e,t,o){if(!t){e.style.display="none";return}if(e.style.display="block",e.style.left=`${t.left}px`,e.style.width=`${t.width}px`,o==="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=`${o==="top"?t.top:t.top+t.height}px`}function Mc(e){return JSON.stringify(e)}var PS={$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 xm=PS.$defs,Oi=new Set(["pre"]),pc=new Set(Object.entries(xm).filter(([e,t])=>!Oi.has(e)&&(t.$inlineChildren?.length??0)>0).map(([e])=>e));var io=new Set(["em","strong","del","code","a","span","br","img","b","i","u","sub","sup","s"]);function Mt(e,t){if(!t)return io.has(e);let o=xm[t];if(!o||!o.$inlineChildren)return!1;return o.$inlineChildren.includes(e)}function NN(e){let t=xm[e];if(!t)return null;let o=t.$inlineActions;if(n(o))o=xm[o]?.$inlineActions??void 0;if(!Array.isArray(o))return null;return o}var Ri=null;function Hw(e,t){if(!_(e))return!1;let o=(it(e.tagName)||"div").toLowerCase();if(t){let r=(it(t.tagName)||"div").toLowerCase();return Mt(o,r)}return io.has(o)}function AN(){return Ri!==null}function ke(e){return!e||e==="base"?null:e}function Bw(e){let t=e.panels;if(t.length===0)return null;if(t.length===1)return t[0];let o=tl(e.paneId);for(let r of t){if(o===null&&r.mediaName==="base")return r;if(r.mediaName===o)return r}return t[0]}function ao(){return Bw(vr())}function ON(e,t){if(!e)return t;let o=t;for(let r=Ut(o);r;r=Ut(o)){let i=oe(e,o),a=oe(e,r);if(!i||!a)break;let l=(it(i.tagName)||"div").toLowerCase(),s=(it(a.tagName)||"div").toLowerCase();if(!Mt(l,s))break;o=r}return o}function zw(e){return Fp(e)!==null}function Ep(e){return Fp(e)}function Br(e){if(!e)return{baseWidth:320,featureQueries:[],sizeBreakpoints:[]};let t=[],o=[],r=320;for(let[i,a]of Object.entries(e)){if(i==="--"){let c=String(a).match(/^(\d+)\s*px$/);r=c?Number(c[1]):320;continue}let l=a.match(/min-width:\s*([\d.]+)px/),s=a.match(/max-width:\s*([\d.]+)px/);if(l)o.push({name:i,query:a,type:"min",width:Number(l[1])});else if(s)o.push({name:i,query:a,type:"max",width:Number(s[1])});else t.push({name:i,query:a})}return o.sort((i,a)=>i.type==="min"?i.width-a.width:a.width-i.width),{baseWidth:r,featureQueries:t,sizeBreakpoints:o}}function Ai(e,t){let o=new Set;for(let r of e)if(r.type==="min"&&t>=r.width)o.add(r.name);else if(r.type==="max"&&t<=r.width)o.add(r.name);return o}function so(e,t){let o=Ai(e,t),r=null;for(let i of e){if(!o.has(i.name))continue;let a=Math.abs(i.width-t);if(r===null){r=i;continue}let l=Math.abs(r.width-t);if(a<l||a===l&&i.width<r.width)r=i}return r?.name??null}function MN(e,t,o=8){let r=null;for(let i of t){let a=Math.abs(i-e);if(a>o)continue;if(r===null||a<Math.abs(r-e))r=i}return r??e}var _m=240,PN=8,FN=16,Je=new Map;function Nt(e){return Br(to(e.doc.document.$media))}function FS(e){let{baseWidth:t,sizeBreakpoints:o}=Nt(e),r=e.session.ui.activeMedia;return o.find((i)=>i.name===r)?.width??t}function $i(e,t){let o=Je.get(e);if(!o)return null;if(!t||o.tabId!==t.id||o.media!==t.session.ui.activeMedia)return Je.delete(e),null;return o.width}function jN(e,t){let o=t?FS(t):0;return $i(e.paneId,t)??o}function jS(e){Je.delete(e)}function HN(e){let{baseWidth:t,sizeBreakpoints:o}=Nt(e);return[t,...o.map((r)=>r.width)]}function HS(e,t,o){let{sizeBreakpoints:r}=Nt(t),i=so(r,o);return t.session.ui.activeMedia=i,Je.set(e,{media:i,tabId:t.id,width:o}),i}var Ot={invokerTags:Xb,popoverTags:uh};function tL(e,t){if(!e||!t)return null;for(let o=t.length;o>=0;o-=1){let r=t.slice(0,o),i=oe(e,r);if(_(i)&&Ea(i,Ot))return r}return null}function lo(e,t){let o=e.doc.document;if(!o)return null;if(t){let r=oe(o,t);return _(r)&&Ea(r,Ot)?t:null}return tL(o,Oe(e.session.selection))}function co(){let e=u.value?.doc.document;return e?GA(e,Ot):!1}var po=["toggle-popover","show-popover","hide-popover","show-modal","close","request-close"],Rt=new Set(["show-modal","close","request-close"]),At=new Set(["toggle-popover","show-popover","hide-popover"]),Ii=["any","closerequest","none"],Di=new Set(po),ki=new Set(Ii),Ji=new Set(["button"]);function H(e){return Eo(e)==="dialog"}function uo(e){return e.startsWith("--")}function Li(e){let t=[];for(let{node:o}of Jl(e)){let r=Hp(o);if(H(o)&&r!==null&&!t.includes(r))t.push(r)}return t}function fo(e){for(let{node:t}of Jl(e))if(H(t))return!0;return!1}function _i(e){let t=e.oncommand;return t!==void 0&&t!==null}function Fi(e,t){for(let{node:o}of Jl(e)){if(o===e)continue;let r=Eo(o);if(r==="button"){let i=Ts(o,"command"),a=Ts(o,"commandfor");if(i!==null&&(i==="close"||i==="request-close")&&(a===null||a===t))return!0}if(r==="form"&&Ts(o,"method")?.toLowerCase()==="dialog")return!0}return!1}function vN(e,t){let o=[...Jl(e,[],null,t)],r=Li(e),i=Zb(e,t),a=r.length>0||i.length>0,l=new Map,s=new Map;for(let{node:d}of o){let f=Hp(d);if(f!==null&&!l.has(f))l.set(f,d);if(Eo(d)==="button"){let g=Ts(d,"commandfor"),y=Ts(d,"command");if(g!==null){let b=s.get(g)??new Set;b.add(y??""),s.set(g,b)}}}let c=[];for(let{node:d,path:f}of o)if(c.push(...Vi(d,f,l,r,i,a,t)),H(d))c.push(...qi(d,f,s));return c}function Vi(e,t,o,r,i,a,l){let s=[],c=Eo(e),d=l?.invokerTags?.has(c)??!1,f=Ts(e,"command"),g=Ts(e,"commandfor");if(!(f!==null||g!==null||("command"in Gc(e))||("commandfor"in Gc(e))))return s;let b=Ls(e,"the element");if(!Ji.has(c)&&!d)return s.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. ${oo}`,fix:"invoker",message:`<${c||"element"}> carries command/commandfor, which only <button> supports.`,path:t,rule:"invoker-not-button",severity:"error"}),s;if(f!==null&&!Di.has(f)&&!uo(f))return s.push({detail:`\`command\` is an enumerated attribute taking ${po.map((T)=>`\`${T}\``).join(", ")}, or a custom command starting with \`--\`. Anything else is the invalid-value state, and a button in that state does nothing when clicked. ${oo}`,message:`${b} declares command="${f}", which is not a built-in or --custom command.`,path:t,rule:"command-invalid",severity:"error"}),s;if(g!==null){let T=o.get(g),k=r.includes(g),I=i.includes(g);if(!T&&a){let J=[...r,...i].map((te)=>`"${te}"`).join(", ");return s.push({detail:`No element in this document has the id "${g}". The dialogs and popovers here are: ${J}. A commandfor that names nothing does nothing, silently. ${oo}`,message:`commandfor="${g}" names nothing in this document.`,path:t,rule:"command-target-missing",severity:"error"}),s}if(f!==null&&T){if(Rt.has(f)&&!H(T))s.push({detail:`\`${f}\` acts on a <dialog>, and "${g}" is ${I?"a popover":`a <${Eo(T)||"element"}>`}. The click is ignored. ${I?"Use `toggle-popover`, `show-popover` or `hide-popover` for a popover.":"Point it at a dialog, or make the target one."} ${oo}`,message:`${b} sends ${f} to "${g}", which is not a dialog.`,path:t,rule:"command-target-mismatch",severity:"error"});else if(At.has(f)&&!Ea(T,l))s.push({detail:`\`${f}\` acts on a popover, and "${g}" is ${k?"a dialog":`a <${Eo(T)||"element"}>`} that declares no \`popover\`. The click is ignored. ${k?"Use `show-modal`, `close` or `request-close` for a dialog.":"Give the target a `popover` attribute, or point the button elsewhere."} ${oo}`,message:`${b} sends ${f} to "${g}", which is not a popover.`,path:t,rule:"command-target-mismatch",severity:"error"});else if(uo(f)&&!_i(T))s.push({detail:`A custom command is a \`CommandEvent\` dispatched at its target, and "${g}" 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. ${oo}`,message:`${b} sends ${f} to "${g}", which handles no command.`,path:t,rule:"custom-command-unhandled",severity:"warn"})}}return s}function qi(e,t,o){let r=[],i=Ls(e,"the dialog"),a=Hp(e),{style:l}=e,s=Ts(e,"closedby");if(s!==null&&!ki.has(s))r.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. ${oo}`,message:`${i} declares closedby="${s}", which is not any, closerequest or none.`,path:t,rule:"dialog-closedby-invalid",severity:"error"});if(_r(l,"display")!==null)r.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. ${oo}`,fix:"display",message:`${i} sets display in its base rule.`,path:t,rule:"dialog-display",severity:"error"});let c=a===null?void 0:o.get(a),d=Ts(e,"open")!==null||Gc(e).open===!0||e.open===!0;if(a!==null&&!c?.has("show-modal")&&!d)r.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. ${oo}`,message:`${i} has no invoker in this document.`,path:t,rule:"dialog-no-invoker",severity:"warn"});if(c?.has("show-modal")&&s==="none"&&!Fi(e,a))r.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"\`. ${oo}`,message:`${i} opens modally, closes on nothing, and has no close button.`,path:t,rule:"modal-without-close",severity:"error"});return r}function nL(e,t){if(!e||!t)return null;for(let o=t.length;o>=0;o-=1){let r=t.slice(0,o),i=oe(e,r);if(_(i)&&H(i))return r}return null}function BS(e,t){let o=e.doc.document;if(!o)return null;if(t){let r=oe(o,t);return _(r)&&H(r)?t:null}return nL(o,Oe(e.session.selection))}function mo(){let e=u.value?.doc.document;return e?fo(e):!1}function G(e){return vt(e.paneId)}function fe(e){let t=Hr(e.paneId);if(t?.kind==="lens")return t.zoom;return G(e)?.session.ui.zoom??1}function Sm(e=vr()){return fe(e)}function Le(e,t){let o=Hr(e.paneId);if(o?.kind==="lens"){o.zoom=t;return}let r=G(e);if(r)r.session.ui.zoom=t}function Bi(e){return Boolean(e.canvas&&e.viewport)}function Tp(e,t,o,r=null){let a={_width:r||null,canvas:null,element:null,mediaName:e||"",ready:!1,renderScope:null,scrollContainer:null,viewport:null},l=[];if(r&&!o)l.push(`--panel-viewport-w:${r}px`);if(r)l.push(`--panel-canvas-w:${r}px`);return{item:{fullWidth:o,header:t?"shown":"hidden",key:e??"",label:t??"",mediaAttr:e,widthVars:l.join(";")},panel:a}}function BN(e,t){for(let{item:o,panel:r}of e){let i=(a)=>t.panelNode(o.key,a);r.element=i("panel"),r.viewport=i("panel-viewport"),r.canvas=i("panel-canvas")}}function zN(e,t){let o=e.find((i)=>i.item.key===t);if(!o)return;let r=tn(o.panel);if(r)r.session.ui.activeMedia=ke(o.item.mediaAttr)}function kt(e){if(!e.panzoomWrap)return;let t=e.wrap.clientWidth,o=e.panzoomWrap.scrollWidth,r=fe(e),i=t-o*r;e.panX=i>=0?i/2:16,e.panY=0}function Ww(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}kt(e),Us(e)}),e.centerObserver.observe(e.panzoomWrap),kt(e)}function Us(e){if(!e.panzoomWrap)return;let t=fe(e);e.panzoomWrap.style.transform=`translate(${e.panX}px, ${e.panY}px) scale(${t})`,xn("overlays")}var Jt=0.25,Ht=3;function yo(e){return Math.min(Ht,Math.max(Jt,e))}function Ki(e,t,o){let r=e.wrap.querySelector('[part="edit-canvas"]'),i=e.panels[0]?.canvas;if(!r||!i)return null;let a=e.wrap.querySelector('[part="edit-column"]'),l=a?He(a).width:0,s=t&&l>0?l/t:1,c=o;if(c===null){let d=He(r);c=d.top+d.height/2}return{layoutY:Math.max(0,(c-He(i).top)/s),scroller:r,zoom:s}}function th(e=vr(),t=null){if(Wo(e.paneId)!=="edit")return;let[o]=e.panels;if(!o||!Bi(o))return;let r=o.canvas,i=r.querySelector("iframe"),a=G(e)?.session.ui.editZoom??1,l=Ki(e,o._width??null,t);if(a===1){if(o._width=null,r.style.width="",r.style.transform="",r.style.transformOrigin="",i)i.style.width="100%";o.viewport.style.height=""}else{let s=e.wrap.querySelector('[part="edit-column"]');if(!s)return;let c=He(s).width;if(c<=0)return;let d=c/a;if(o._width=d,r.style.width=`${d}px`,r.style.transform=`scale(${a})`,r.style.transformOrigin="top left",i)i.style.width=`${d}px`,o.viewport.style.height=`${i.offsetHeight*a}px`}if(l)l.scroller.scrollTop+=l.layoutY*(a-l.zoom);xn("overlays")}function Lp(e,t=vr()){let o=G(t);if(!o)return;o.session.ui.editZoom=yo(e),th(t)}var $t=new Map,It=new Map;function WN(e,t=vr(),o=null){let r=G(t);if(!r)return;if(r.session.ui.editZoom=yo(e),It.set(t.paneId,o),$t.has(t.paneId))return;$t.set(t.paneId,requestAnimationFrame(()=>{$t.delete(t.paneId);let i=It.get(t.paneId)??null;It.delete(t.paneId),th(t,i)}))}function Ui(e){let t=getComputedStyle(e).getPropertyValue("--boards-inset").trim(),o=Number(t.replace(/px$/,""));return Number.isFinite(o)?o:0}function xo(e,t,o){if(!e.panzoomWrap)return;let r=e.wrap.clientWidth,i=e.wrap.clientHeight-Ui(e.panzoomWrap),a=24,l=32,s=0,{panels:c}=e;for(let ot of c)s+=ot._width||800;s+=a*Math.max(0,c.length-1)+l;let d=fe(e),y=He(e.panzoomWrap).height/d+l,b=r/s,T=i/y,k=t==="width"?b:Math.min(b,T),I=Math.min(o,Math.max(K,k));Le(e,I);let J=s*I,te=y*I;e.panX=Math.max(0,(r-J)/2),e.panY=Math.max(0,(i-te)/2),Us(e)}function VN({maxZoom:e=U,surface:t=vr()}={}){je("page",t),xo(t,"page",e)}var K=0.05,U=5;function Co(e){return Math.min(U,Math.max(K,e))}var Gi="page",Lt=["width","page","none"];function Zi(e,t,o){let r=t[o];if(Yi(r))return r;if(Z(r)&&r>=K&&r<=U)return r;throw RangeError(`command "${e}" argument "${o}": expected ${Lt.map((i)=>`"${i}"`).join(" | ")} or a number in [${K}, ${U}], got ${JSON.stringify(r)}`)}function Yi(e){return n(e)&&Lt.includes(e)}var Po=new Map;function So(e){let t=G(e);if(!t)return null;let o=Hr(e.paneId)?.kind==="lens"?`::${e.paneId}`:"";return`${t.id}::${t.documentPath??""}${o}`}function je(e,t){let o=So(t);if(o)Po.set(o,e)}function zS(e=vr()){let t=So(e);return(t===null?void 0:Po.get(t))??Gi}function wo(e,t=vr()){let o=e??zS(t);if(o==="none"){Us(t);return}if(Z(o)){Le(t,Co(o)),Us(t);return}xo(t,o,1)}function iL(e,t=vr()){je(e,t),wo(e,t)}function Cm(e,t=vr(),o=null){if(!G(t))return;let i=Co(e),a=i/fe(t);if(je(i,t),t.panzoomWrap&&a!==1){let l=He(t.panzoomWrap),s=He(t.wrap),c=o?.clientX??s.left+s.width/2,d=o?.clientY??s.top+s.height/2;t.panX+=(c-l.left)*(1-a),t.panY+=(d-l.top)*(1-a),t.needsCenter=!1}Le(t,i),Us(t)}function WS(e){if(e.wrap.clientWidth<=0){Us(e);return}wo(zS(e),e)}function UN(e=vr()){if(je(1,e),!e.panzoomWrap)return;Le(e,1),kt(e),Us(e)}function Mo(e,t){let o=He(No(e)??e.wrap),r=t.top+t.height/2-o.top;return o.height/2-r}function No(e){return Bw(e)?.scrollContainer??null}function Xi(e,t,o){let r=No(e);if(!r){Ro(e,t);return}let i=r.scrollTop-t;if(o){r.scrollTo({behavior:"smooth",top:i});return}r.scrollTop=i}function VS(e,t=vr()){Xi(t,Mo(t,e),!1)}function Oo(e,t=vr()){let o=He(t.wrap);if(e.top>=o.top&&e.top+e.height<=o.top+o.height)return;let r=Mo(t,e),i=Math.max(t.panY,0)-t.panY,a=Math.min(r,i);if(a!==0)t.needsCenter=!1,Ro(t,a)}function Ro(e,t){let o=e.panY,r=o+t,i=performance.now(),a=250,l=(s)=>{let c=Math.min((s-i)/250,1),d=c*(2-c);if(e.panY=o+(r-o)*d,Us(e),c<1)requestAnimationFrame(l)};requestAnimationFrame(l)}var Qi=["edit","design","preview","source","stylebook","tokens","grid","git-diff"],Dt=Qi.filter((e)=>e!=="git-diff"),Fe=new Set(["edit","design"]);function ea(e){return Fe.has(e)}var oL=["edit","design","preview"];function na(e){return oL.filter((t)=>e.capabilities.modes.includes(t))}function qN(e){return na(e).filter((t)=>t!=="preview")}function rL(e){let t=e.session.ui.canvasMode;return ea(t)?t:null}function sL(e){return{available:e.capabilities.modes.includes("preview")&&Fe.has(e.session.ui.canvasMode),on:e.session.ui.preview===!0}}function aL(e,t,o){if(t==="preview"){if(Fe.has(e.session.ui.canvasMode))e.session.ui.preview=!0;return}if(e.session.ui.preview=!1,e.session.ui.canvasMode!==t)o(e,t)}var ho=new Set(["design","stylebook","git-diff"]),A=(e)=>e.document.open,vo=["auto","light","dark"];function oa(e){function t(l){let s=u.value;if(!s)throw RangeError(`command "${l}" needs an open document; no tab is active`);return s}function o(l,s){let{pane:c}=s;if(c===void 0)return t(l);let d=St(l,s,"pane"),f=vt(d);if(!f)throw RangeError(`command "${l}" argument "pane": "${d}" has no open document`);return f}let r={pane:We("Which pane to render this way. Defaults to the focused one.")};function i(l){e.renderPane(a(l))}function a(l){let{pane:s}=l;return n(s)?s:m.activePaneId}return[{args:Ce({mode:ui(Dt,"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:A,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, tokens and grid 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:l,args:s})=>{let c=Vn("canvas.setMode",s,"mode",Dt),d=l.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 ${c} mode; ${d}.`}},run:(l,s)=>{let c=Vn("canvas.setMode",s,"mode",Dt),d=t("canvas.setMode"),{modes:f}=d.capabilities;if(!f.includes(c))throw RangeError(`command "canvas.setMode" argument "mode": "${c}" is not a mode this document `+`supports — it declares: ${f.join(", ")}`);if(c==="preview"){let g=d.session.ui.canvasMode;if(!Fe.has(g))throw RangeError(`command "canvas.setMode" argument "mode": "preview" composes with the edit and design base modes; this pane is in "${g}"`);d.session.ui.preview=!0;return}d.session.ui.preview=!1,e.setCanvasMode(d,c)},title:"Set Canvas Mode"},{args:Ce({zoom:j$("Pan-zoom scale, 1 = 100%.",{maximum:U,minimum:K})}),category:"View",id:"canvas.setZoom",level:"document",menus:["palette"],group:"3_canvas",requires:"a document on the pan-zoom surface",when:A,enablement:()=>ho.has(e.getCanvasMode()),run:(l,s)=>{t("canvas.setZoom"),Cm(Rx("canvas.setZoom",s,"zoom",K,U))},title:"Set Zoom"},{args:Ce({fit:{description:'How the document is framed: "width" | "page" | "none", or a numeric pan-zoom scale.',oneOf:[{enum:[...Lt],type:"string"},{maximum:U,minimum:K,type:"number"}]}}),category:"View",id:"canvas.setFit",level:"document",menus:["palette"],group:"3_canvas",requires:"a document on the pan-zoom surface",when:A,enablement:()=>ho.has(e.getCanvasMode()),run:(l,s)=>{t("canvas.setFit"),iL(Zi("canvas.setFit",s,"fit"))},title:"Set Fit"},{args:Ce({zoom:j$("Edit-mode content zoom, 1 = 100%.",{maximum:Ht,minimum:Jt})}),category:"View",id:"canvas.setEditZoom",level:"document",menus:["palette"],group:"3_canvas",requires:"a document in edit mode",when:A,enablement:()=>e.getCanvasMode()==="edit",run:(l,s)=>{t("canvas.setEditZoom"),Lp(Rx("canvas.setEditZoom",s,"zoom",Jt,Ht))},title:"Set Edit Zoom"},{args:{additionalProperties:!1,properties:{...r,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:A,enablement:()=>e.getCanvasMode()==="edit",run:(l,s)=>{let c=o("canvas.setEditWidth",s),{width:d}=s;if(d===null){jS(a(s)),i(s);return}HS(a(s),c,Rx("canvas.setEditWidth",s,"width",_m,1e4)),i(s)},title:"Set Edit Width"},{args:{additionalProperties:!1,properties:{...r,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:A,run:(l,s)=>{let c=o("canvas.setBreakpoint",s),{media:d}=s;if(d!==null&&!n(d))throw RangeError('command "canvas.setBreakpoint" argument "media": expected a breakpoint key or null');let f=Object.keys(to(c.doc.document.$media));if(d!==null&&!f.includes(d))throw RangeError(`command "canvas.setBreakpoint" argument "media": "${d}" is not a breakpoint this `+`document defines — it defines: ${f.length>0?f.join(", "):"nothing"}`);c.session.ui.activeMedia=d,i(s)},title:"Set Breakpoint"},{args:Ce({...r,scheme:ui(vo,"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:A,run:(l,s)=>{let c=o("canvas.setColorScheme",s);c.session.ui.previewColorScheme=Vn("canvas.setColorScheme",s,"scheme",vo),i(s)},title:"Set Color Scheme"},{args:Ce({...r,locale:We("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:(l)=>l.document.open&&l.project.isMultilingual,run:(l,s)=>{let c=o("i18n.switchLocale",s),d=St("i18n.switchLocale",s,"locale"),f=Es();if(f===null||!f.locales.includes(d))throw RangeError(`command "i18n.switchLocale" argument "locale": "${d}" is not a locale this `+`project declares — it declares: ${f===null?"nothing":f.locales.join(", ")}`);c.session.ui.previewLocale=d,i(s)},title:"Set Rendering Language"},{args:Ce({...r,visible:To("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:A,run:(l,s)=>{let c=o("canvas.setLayoutVisible",s);c.session.ui.showLayout=Hi("canvas.setLayoutVisible",s,"visible"),i(s)},title:"Show Layout Elements"},{args:Ce({...r,open:To("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:()=>co(),group:"3_canvas",id:"canvas.setPopoverOpen",level:"document",menus:["palette"],requires:"a popover in the open document",run:(l,s)=>{let c=o("canvas.setPopoverOpen",s),d=s.path,f=s.open===void 0?!0:Hi("canvas.setPopoverOpen",s,"open");if(!f&&d===void 0){e.setOpenPopover(c,null);return}let g=lo(c,d);if(g===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(c,f?g:null)},title:"Show Popover",when:A},{args:Ce({...r,open:To("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:()=>mo(),group:"3_canvas",id:"canvas.setDialogOpen",level:"document",menus:["palette"],requires:"a dialog in the open document",run:(l,s)=>{let c=o("canvas.setDialogOpen",s),d=s.path,f=s.open===void 0?!0:Hi("canvas.setDialogOpen",s,"open");if(!f&&d===void 0){e.setOpenDialog(c,null);return}let g=BS(c,d);if(g===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(c,f?g:null)},title:"Show Dialog",when:A},{args:{additionalProperties:!1,properties:{...r,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:A,run:(l,s)=>{o("canvas.setResolvingOpen",s);let{open:c,pane:d}=s;e.setResolvingOpen(n(d)?d:m.activePaneId,c===void 0||Hi("canvas.setResolvingOpen",s,"open"))},title:"Show Resolving Values"},{args:{additionalProperties:!1,properties:{...r,name:We("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:A,run:(l,s)=>{let c=o("canvas.setTestProp",s),d=St("canvas.setTestProp",s,"name"),f=Object.keys(c.doc.document.state??{});if(!f.includes(d))throw RangeError(`command "canvas.setTestProp" argument "name": "${d}" is not a prop this component `+`declares — it declares: ${f.length>0?f.join(", "):"nothing"}`);let{value:g}=s,y={...c.session.ui.previewProps};if(g===null||g===void 0)delete y[d];else y[d]=g;c.session.ui.previewProps=Object.keys(y).length>0?y:null,i(s)},title:"Set Test Value"},{args:{additionalProperties:!1,properties:{...r,name:We("The route parameter's name, without brackets."),value:We("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:A,run:(l,s)=>{let c=o("canvas.setRouteParam",s),d=St("canvas.setRouteParam",s,"name"),f=Ac(c.documentPath);if(!f.includes(d))throw RangeError(`command "canvas.setRouteParam" argument "name": "${d}" is not a parameter of this `+`route — it has: ${f.length>0?f.join(", "):"none"}`);c.session.ui.previewParams={...c.session.ui.previewParams,[d]:St("canvas.setRouteParam",s,"value")},i(s)},title:"Set Route Parameter"}]}function GN(e,t){e.registerAll(oa(t))}function Vw(e=vr()){let t=tl(e.paneId),o=e.panels;for(let r of o){let i=r.element?.querySelector('[part="panel-header"]');if(i){let a=t===null&&r.mediaName==="base"||t===r.mediaName;i.toggleAttribute("data-active",a)}}}var L=null;function ra(e){if(L?.isConnected)return L;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),L=t,t}function lL(e,t,o,r=document){let i=ra(r);i.textContent=e,i.style.left=`${t}px`,i.style.top=`${o}px`,i.style.display="block"}function US(e,t){if(!L||L.style.display==="none")return;L.style.left=`${e}px`,L.style.top=`${t}px`}function nh(){if(L)L.style.display="none"}var Ao=function(){if(typeof window>"u")return null;var e=new Image;return e.src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==",e}();function nl(e){var t=e.nativeSetDragImage;if(t&&Ao)t(Ao,0,0)}function $o(e,t){if(e==null)return{};var o={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;o[r]=e[r]}return o}function Io(e,t){if(e==null)return{};var o,r,i=$o(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)o=a[r],t.indexOf(o)===-1&&{}.propertyIsEnumerable.call(e,o)&&(i[o]=e[o])}return i}function Ve(e,t){var o=Object.keys(e),r=Object.keys(t);if(o.length!==r.length)return!1;return o.every(function(i){return Object.is(e[i],t[i])})}function Do(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Ve,t=null;return function(o){if(t&&e(t.value,o))return t.value;return t={value:o},t.value}}var ia=["block"];function ko(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),o.push.apply(o,r)}return o}function Jo(e){for(var t=1;t<arguments.length;t++){var o=arguments[t]!=null?arguments[t]:{};t%2?ko(Object(o),!0).forEach(function(r){ol(e,r,o[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):ko(Object(o)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(o,r))})}return e}function aa(e){return{x:(e.right+e.left)/2,y:(e.bottom+e.top)/2}}function _t(e){var{client:t,borderBox:o}=e,r=o.height/4;if(t.y<=o.top+r)return"reorder-above";if(t.y>=o.bottom-r)return"reorder-below";return"make-child"}function sa(e){var{element:t,input:o,currentLevel:r,indentPerLevel:i,mode:a}=e,l={x:o.clientX,y:o.clientY},s=t.getBoundingClientRect();if(a==="standard"){var c=_t({borderBox:s,client:l});return{type:c,indentPerLevel:i,currentLevel:r}}var d=aa(s);if(a==="expanded"){var f=_t({borderBox:s,client:l});return{type:f==="reorder-above"?f:"make-child",indentPerLevel:i,currentLevel:r}}var g=i*r;if(l.x<s.left+g){if(l.y<d.y)return{type:"reorder-above",indentPerLevel:i,currentLevel:r};var y=(l.x-s.left)/i,b=Math.max(Math.floor(y),0);return{type:"reparent",desiredLevel:b,indentPerLevel:i,currentLevel:r}}return{type:_t({borderBox:s,client:l}),indentPerLevel:i,currentLevel:r}}function Ho(e,t){if(e.type!==t.type)return!1;if(e.type==="instruction-blocked"&&t.type==="instruction-blocked")return Ho(e.desired,t.desired);return Ve(e,t)}var la=Do(Ho);function ca(e){var{desired:t,block:o}=e;if(o!==null&&o!==void 0&&o.includes(t.type)&&t.type!=="instruction-blocked"){var r={type:"instruction-blocked",desired:t};return r}return t}function Uw(e,t){var o=t.block,r=Io(t,ia),i=sa(r),a=ca({desired:i,block:o}),l=la(a);return Jo(Jo({},e),{},ol({},qe,l))}function $p(e){var t;return(t=e[qe])!==null&&t!==void 0?t:null}var qe=Symbol("tree-item-instruction");var Lo=`data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="320" height="180" viewBox="0 0 320 180"><rect width="320" height="180" fill="#808080" fill-opacity="0.16"/><g fill="#808080" fill-opacity="0.38"><circle cx="118" cy="64" r="14"/><path d="M60 140l52-50 34 30 38-46 76 66z"/></g></svg>')}`;function ua(e){let t=e.getAttribute("src")?.trim()??"",o=e.getAttribute("srcset")?.trim()??"";if(t!==""||o!=="")return!1;return!(e.parentElement?.localName==="picture"?e.parentElement:null)?.querySelector("source[srcset]:not([srcset=''])")}function jt(e){if(ua(e))e.setAttribute("data-jx-image-placeholder",""),e.setAttribute("src",Lo);else if(e.hasAttribute("data-jx-image-placeholder")&&e.getAttribute("src")!==Lo)e.removeAttribute("data-jx-image-placeholder")}function jo(e){return e.localName==="img"}function _o(e){if(e.nodeType!==e.ELEMENT_NODE||!("querySelectorAll"in e))return[];let t=e,o=[...t.querySelectorAll("img")];return jo(t)?[t,...o]:o}function Fo(e){for(let r of _o(e))jt(r);let o=new(e.ownerDocument.defaultView?.MutationObserver??MutationObserver)((r)=>{for(let i of r){if(i.type==="attributes"){let{target:a}=i;if(a.nodeType===a.ELEMENT_NODE&&"localName"in a){let l=a;if(jo(l))jt(l)}continue}for(let a of i.addedNodes)for(let l of _o(a))jt(l)}});return o.observe(e,{attributeFilter:["src","srcset"],attributes:!0,childList:!0,subtree:!0}),()=>o.disconnect()}async function qw(e,t=new Map){jd(!0);try{if(!await da(e))return qo(e.tagName);let o=document.createElement(e.tagName);for(let i of e.props||[])if(i.default!==void 0&&i.default!=="false"&&i.default!=="''"){let a=String(i.default).replaceAll(/^'|'$/g,"");o.setAttribute(i.name,a)}let r=o;for(let[i,a]of t)r[i]=a;return Fo(o),o}catch(o){return console.warn("Component preview failed:",e.tagName,o),qo(e.tagName)}}async function da(e){if(e.source==="npm")return Boolean(customElements.get(e.tagName));if(e.path&&!e.path.endsWith(".json"))return!1;let t=S?.projectRoot;return await Yb(`${location.origin}/${t?`${t}/`:""}${e.path}`),!0}function qo(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 pa='[part="outline"]',Ft='[part="row"]',fa='[part="verbs"]',Be=null;function KN(){if(Be!==null)cancelAnimationFrame(Be);for(let e of st.dndCleanups)e();st.dndCleanups=[],Be=requestAnimationFrame(()=>{Be=null;let e=Sh?.querySelector(pa);if(!e)return;for(let o of e.querySelectorAll("[data-dnd-row]")){let r=o.dataset.value.split("/").map((c)=>/^\d+$/.test(c)?Math.trunc(Number(c)):c),i=Math.trunc(Number(o.dataset.dndDepth))||0,a=Object.hasOwn(o.dataset,"dndVoid"),l=Object.hasOwn(o.dataset,"dndExpanded"),s=zr(Wr({canDrag({element:c,input:d}){if(cx(d.clientX,d.clientY)?.closest(fa))return!1;return!0},element:o,getInitialData(){return{path:r,type:"tree-node"}},onGenerateDragPreview({nativeSetDragImage:c}){nl({nativeSetDragImage:c})},onDragStart(){if(o.dataset.dragging="",st.layerDragSourceHeight=o.offsetHeight,l)ma(o,e)},onDrop(){if(delete o.dataset.dragging,l)xn("leftPanel")}}),qs({element:o,canDrop({source:c}){let d=c.data.path;if(Array.isArray(d)&&ta(d,r))return!1;return!0},getData({input:c,element:d}){return Uw({path:r},{block:a?["make-child"]:[],currentLevel:i,element:d,indentPerLevel:16,input:c,mode:l?"expanded":"standard"})},onDragEnter({self:c}){Bo(o,c.data,e)},onDrag({self:c}){Bo(o,c.data,e)},onDrop(){me(e)}}));st.dndCleanups.push(s)}let t=Gs({onDrop({source:o,location:r}){me(e);let[i]=r.current.dropTargets;if(!i)return;let a=$p(i.data);if(!a||a.type==="instruction-blocked")return;let l=o.data,s=i.data.path;if(!Array.isArray(s))return;let c=l.type==="tree-node"&&o.element,d=c&&Object.hasOwn(c.dataset,"dndExpanded");if(Rb(u.value,a,l,s),d){let f=u.value,g=Oe(f?.session.selection);if(g)st._layersCollapsed||=new Set,st._layersCollapsed.add(g.join("/"))}},onDropTargetChange({location:o}){let[r]=o.current.dropTargets;if(r&&!$p(r.data))me(e)}});st.dndCleanups.push(t)})}function JN(){requestAnimationFrame(()=>{let e=Sh?.querySelector(".components-section");if(!e)return;for(let t of e.querySelectorAll("[data-component-tag]")){let o=t.dataset.componentTag;if(!o)continue;let r=Ne.find((s)=>s.tagName===o);if(!r)continue;let i=t.querySelector(".element-card-preview");if(i&&!i.querySelector(o))qw(r).then((s)=>{i.textContent="",i.append(s)});let a=Fc(r),l=Wr({element:t,getInitialData(){return{fragment:structuredClone(a),type:"block"}},onGenerateDragPreview({nativeSetDragImage:s}){nl({nativeSetDragImage:s})}});st.dndCleanups.push(l)}})}function YN(){requestAnimationFrame(()=>{let e=Sh?.querySelector('[part="content"]');if(!e)return;for(let t of e.querySelectorAll("[data-block-tag]")){let o=t.dataset.blockTag,r=t.querySelector(".element-card-preview");if(r&&!r.firstChild){let l=document.createElement(qn.has(o)?"span":o);l.textContent=o,r.append(l)}let i=eh(o),a=Wr({element:t,getInitialData(){return{fragment:structuredClone(i),type:"block"}},onGenerateDragPreview({nativeSetDragImage:l}){nl({nativeSetDragImage:l})}});st.dndCleanups.push(a)}})}function ma(e,t){let o=`${e.dataset.value}/`,r=t.querySelectorAll(Ft);for(let i of r)if(i.dataset.value?.startsWith(o))i.style.display="none"}function Bo(e,t,o){let r=$p(t);if(st._currentDropTargetRow&&st._currentDropTargetRow!==e)delete st._currentDropTargetRow.dataset.drop;if(!r||r.type==="instruction-blocked"){me(o);return}if(r.type==="make-child"){me(o),e.dataset.drop="",st._currentDropTargetRow=e;return}delete e.dataset.drop,st._currentDropTargetRow=e;let i=[...o.querySelectorAll(Ft)],a=i.indexOf(e),l=st.layerDragSourceHeight;for(let[s,c]of i.entries()){if(c.dataset.dragging!==void 0)continue;if(r.type==="reorder-above")c.style.transform=s>=a?`translateY(${l}px)`:"";else c.style.transform=s>a?`translateY(${l}px)`:""}}function me(e){if(st._currentDropTargetRow)delete st._currentDropTargetRow.dataset.drop,st._currentDropTargetRow=null;let t=e.querySelectorAll(Ft);for(let o of t)o.style.transform="",o.style.display=""}function zo(e,t,o){if(t==="make-child")return{index:rr(oe(e,o)).length,parent:o};let r=Ut(o),i=zi(o);if(!r||!Z(i))return;if(t==="reorder-above")return{index:i,parent:r};if(t==="reorder-below")return{index:i+1,parent:r};return null}function Rb(e,t,o,r){if(!e)return;if(o.type==="tree-node"){let i=o.path,a=zo(e.doc.document,t.type,r);if(a)Y(e,(l)=>Vp(l,i,a.parent,a.index))}else if(o.type==="block"){let i=zo(e.doc.document,t.type,r);if(i===void 0)return;let a=o.fragment;if(i)Y(e,(l)=>{or(l,i.parent,i.index,structuredClone(a)),kp(l,a.tagName),l.session.selection=[[...i.parent,"children",i.index]]})}}function Ko(e){let t={};for(let[o,r]of Object.entries(e?.nesting??{}))if(o!=="_root")t[o]=r?.inline===!0;for(let o of e?.inline??[])t[o]=!1;return t}function j(e){return JSON.parse(JSON.stringify(e))}var Xe=new WeakMap,x=new Set,ee=0,ve=new Map,lr=-1,cr=0,ga=600;function cL(e){return lr===e&&Date.now()-cr<=ga}var Uo=0,ur=new Set;function ha(e,t){let o;try{o=new URL(e,t.iframe.src||rh())}catch{return}if(!["http:","https:","mailto:","tel:"].includes(o.protocol))return;let r=o.href,i=en();if(i){i(r);return}window.open(r,"_blank","noopener,noreferrer")}function dL(e){ur.add(e)}function va(e){return ur.delete(e)}var q=new Map,ie=new Map,ye=new Map,ya=300;function uL(e,t,o,r=ya){let i=null;for(let s of x){if(!s.iframe.isConnected){x.delete(s);continue}if(s.ready&&!s.stylebook&&e!==null&&s.tabId===e){i=s;break}}if(!i)return Promise.resolve(null);Uo+=1;let a=Uo,l=j(t);return i.channel.post({contextPath:o?[...o]:null,exprs:l,gen:i.lastRenderedGen,kind:"evalExpr",reqId:a}),new Promise((s)=>{let c=setTimeout(()=>{q.delete(a),ie.delete(a),s(null)},r);ie.set(a,i),q.set(a,(d)=>{clearTimeout(c),ie.delete(a),s(d)})})}var Zo=0,se=new Map,xa=250;function hL(e,t=xa){let o=[];for(let r of x){if(!r.iframe.isConnected){x.delete(r);continue}if(r.ready&&!r.stylebook&&e!==null&&r.tabId===e)o.push(r)}if(o.length===0)return Promise.resolve();return new Promise((r)=>{let i=o.length,a=setTimeout(()=>{for(let c of s)se.delete(c),ye.delete(c);r()},t),l=()=>{if(i-=1,i===0)clearTimeout(a),r()},s=[];for(let c of o){Zo+=1;let d=Zo;s.push(d),se.set(d,l),ye.set(d,c),c.channel.post({kind:"flushEdits",reqId:d})}})}function qS(e){return Xe.get(e)??null}function Db(e){for(let t of x){if(!t.iframe.isConnected)continue;let o=He(t.iframe);if(e.x>=o.left&&e.x<=o.right&&e.y>=o.top&&e.y<=o.bottom)return t}return null}function Nb(e,t,o){ee+=1,ve.set(ee,o);let r=t.type==="tree-node"?{path:[...t.path],type:"tree-node"}:{type:t.type};return e.channel.post({dragSeq:ee,gen:e.lastRenderedGen,kind:"dragStart",src:r}),ee}function GS(){return ee}function Ul(e){let t=He(e.iframe),o=e.iframe.clientWidth>0?t.width/e.iframe.clientWidth:1;return{rect:t,scale:o}}function dr(e){if(e.stylebook)return"stylebook";return e.tabId??"unbound"}function pL(){let e=[];for(let t of x){if(!t.iframe.isConnected){x.delete(t);continue}let o=`canvas[${dr(t)}]`;if(!t.ready){e.push(`${o}: frame has not handshaked`);continue}let r=[...t.pendingTabIds.keys()];if(r.length>0)e.push(`${o}: gen ${r.join(", ")} unacked`);if(t.pendingPatches>0)e.push(`${o}: ${t.pendingPatches} unacked patch(es)`);if(t.pendingMeasures.size>0)e.push(`${o}: ${t.pendingMeasures.size} measure(s) in flight`);let{idle:i}=t;if(!i){e.push(`${o}: no quiescence report yet`);continue}if(i.gen!==t.lastRenderedGen)e.push(`${o}: quiescence is for gen ${i.gen}, DOM is gen ${t.lastRenderedGen}`);if(!i.fonts)e.push(`${o}: fonts still loading`);if(i.animations>0)e.push(`${o}: ${i.animations} running animation(s)`);if(i.images>0)e.push(`${o}: ${i.images} pending image retry(ies)`)}if(q.size>0)e.push(`canvas: ${q.size} expression eval(s) in flight`);return e}var ba=500,Ca=2,Pa=40;function pr(){let e=u.value?.id??null,t=null;for(let o of x){if(!o.iframe.isConnected){x.delete(o);continue}if(!o.ready||o.stylebook)continue;if(o.tabId===e)return o;t??=o}return t}function fr(e,t){let{rect:o,scale:r}=Ul(e),i=o.left+t.x*r,a=o.top+t.y*r,l=t.width*r,s=t.height*r;return{height:s,left:i,top:a,width:l,x:i+l/2,y:a+s/2}}function xe(e,t){return new Promise((o)=>{e.measureSeq+=1;let r=e.measureSeq,i=setTimeout(()=>{e.pendingMeasures.delete(r),o(null)},ba);e.pendingMeasures.set(r,(a)=>{clearTimeout(i);let[l]=a;o(l?fr(e,l.rect):null)}),e.channel.post({kind:"measure",paths:[[...t]],reqId:r})})}function fL(e){let t=qS(e),o=t?.lastHover;if(!t||!o)return null;return{settle:async()=>(await xe(t,o.path))?.top??null,top:fr(t,o.rect).top}}function mL(e){let t=pr();return t?xe(t,e):Promise.resolve(null)}function Sa(e){return new Promise((t)=>{let o=Number.NaN,r=0,i=0,a=()=>{let{top:l}=He(e.iframe);if(r=l===o?r+1:0,o=l,i+=1,r>=Ca||i>=Pa){t();return}requestAnimationFrame(a)};requestAnimationFrame(a)})}async function Ab(e){let t=pr();return t?H2(t,e):null}async function H2(e,t){let o=await xe(e,t);if(!o)return null;let r=W(e.canvasEl)?.surface;return VS({height:o.height,top:o.top},r),await Sa(e),xe(e,t)}function sP(e,t){let o=qS(e);return o?xe(o,t):Promise.resolve(null)}function wa(e){let t=e.canvasEl.parentElement;if(!t)return;let o=/scale\(([\d.]+)\)/.exec(e.canvasEl.style.transform),r=o?Number(o[1]):1;t.style.height=r===1?"":`${e.iframe.offsetHeight*r}px`}function mr(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",wa(e)}function Kt(e,t){if(e.preview=t,e.overlay.setSuppressed(t),t)e.pendingEnterEdit=null;mr(e)}function gL(e,t){Kt(Zt(e),t)}function Pc(e,t){if(!e.iframe.isConnected)return;e.channel.post(t)}function Gw(e){ve.delete(e)}function Kw(e){e.overlay.setDropIndicator(null)}var gr=null;function bL(e){gr=e}var Ta=300,hr=null;function vL(e){hr=e}var Gt=null;function yL(e){Gt=e}function Ma(e,t,o){if((t?Na(t.tagName):!1)&&t){e.overlay.setDropIndicator(null),e.overlay.setReplaceTarget(R(t.rect));return}e.overlay.setReplaceTarget(null),e.overlay.setDropIndicator(o?R(o.referenceRect):null,o?.edge)}function Yo(e){e.overlay.setReplaceTarget(null),e.overlay.setDropIndicator(null)}function Na(e){return e==="img"||e==="video"||e==="source"}function Oa(e,t){if(e.dataset.jxGutterDrop==="1")return;e.dataset.jxGutterDrop="1",e.addEventListener("dragover",(o)=>{if(![...o.dataTransfer?.types??[]].includes("Files"))return;if(o.preventDefault(),o.dataTransfer)o.dataTransfer.dropEffect="copy"}),e.addEventListener("drop",(o)=>{let r=o.dataTransfer?.files,i=t();if(!r?.length||!i||i.stylebook)return;o.preventDefault(),Gt?.(E(i),[...r],null,null)})}var Ue=null;function wL(e){Ue=e}var Ge=null;function xL(e){Ge=e}var xr=null;function _L(e){xr=e}function Xo(e,t){let o=[...t];for(;;){let r=e.get(Mc(o));if(r)return r;if(o.length<2)return null;o=o.slice(0,-2)}}var N=null;function SL(){let e=N;return Boolean(e?.editing&&e.iframe.isConnected)}var Ze=null;function CL(e){Ze=e}var zt=null;function kL(e){zt=e}var Qo=null,br=null;function EL(e){br=e}function TL(e,t){for(let o of x){if(!o.iframe.isConnected){x.delete(o);continue}if(o.ready&&o.tabId===e.id&&!o.preview)o.popoverOpen=t,o.channel.post({kind:"setPopoverOpen",path:t})}}function LL(e,t){for(let o of x){if(!o.iframe.isConnected){x.delete(o);continue}if(o.ready&&o.tabId===e.id&&!o.preview)o.dialogOpen=t,o.channel.post({kind:"setDialogOpen",path:t})}}function KS(e,t){let o=0;for(let r of x){if(!r.iframe.isConnected){x.delete(r);continue}if(r.ready&&r.tabId===t){let i=W(r.canvasEl)?.surface;if(!i){jw("host-stage-unresolved");continue}let a=i.renderGeneration,l=et?.host===r?et.paths:void 0;tt(r),r.channel.post(l?{echoPaths:l,forwardOps:e,gen:a,kind:"patch"}:{forwardOps:e,gen:a,kind:"patch"}),r.pendingPatches+=1,o+=1}}return o}var et=null,Ra=0;function er(e,t,o){et={host:e,paths:t};try{o()}finally{et=null}}var qt=null,Wt=null;function Aa(e,t,o){return!e&&t===o}function Ia(e,t){let o=E(e);if(!o)return;let r=oe(o.doc.document,t);if(!r)return;KS([{key:"$props",op:"set-key",path:t,value:r.$props}],o.id)}function E(e){return e.tabId?m.tabs.get(e.tabId)??null:null}function $L(e){return E(e)}function ze(e){let t=W(e.canvasEl)?.surface.paneId;if(t)kr(t)}var Da=Object.freeze([]);function ka(){let e=new Map;for(let t of m.panes){let o=t.activeTabId?m.tabs.get(t.activeTabId):null;if(!o)continue;let r=o.session.selection;r.map((i)=>i.join("/")).join("|"),e.set(o.id,r)}return e}function Ja(){if(Qo)return;let e=ge(!0);e.run(()=>{ne(()=>{let t=ka();h.stylebook.selection;for(let o of x)nt(o,(o.tabId?t.get(o.tabId):null)??Da)})}),Qo={stop:()=>e.stop()}}function tt(e){if(!e.ready)return;let t=ph();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 tr=!1,Bt=!1;function Ha(){if(tr)return;tr=!0,ge(!0).run(()=>{ne(()=>{if(L$.value,Bt)return;Bt=!0,queueMicrotask(()=>{Bt=!1,La()})})})}function La(){for(let e of x){if(!e.iframe.isConnected){x.delete(e);continue}tt(e)}}var nr=!1,Ke=null;function _a(){if(nr)return;nr=!0,ge(!0).run(()=>{ne(()=>{for(let t of m.panes){let o=t.activeTabId?m.tabs.get(t.activeTabId):null;if(!o)continue;let{peers:r}=Tn(o);r.map((i)=>JSON.stringify(i.state.structuralSelection??null)).join("|")}if(Ke)clearTimeout(Ke);Ke=setTimeout(()=>{Ke=null;for(let t of x)Cr(t)},100)})})}function Cr(e){if(e.stylebook||!e.ready||!e.iframe.isConnected)return;let t=E(e),o=t?Tn(t).peers:[];e.presenceMeta.clear();let r=[];for(let i of o){let{structuralSelection:a}=i.state;if(!a||i.state.focusedPath!==t?.documentPath)continue;for(let l of a){let s=[...l];r.push(s),e.presenceMeta.set(JSON.stringify(s),{color:i.state.user.color,label:i.state.user.name??i.state.user.login})}}if(r.length===0){e.presenceReqId=-1,e.overlay.setPresence([]);return}e.measureSeq+=1,e.presenceReqId=e.measureSeq,e.channel.post({kind:"measure",paths:r,reqId:e.presenceReqId})}function nt(e,t){if(e.stylebook){ja(e);return}let o=Oe(t);if(e.selectionPath=o,e.selectionPaths=t,!e.iframe.isConnected){x.delete(e);return}if(!o){e.selReqId=-1,e.coSelectionKeys.clear(),e.overlay.setSelection(null),e.overlay.setCoSelection([]);return}if(!e.ready)return;let r=$a(t.slice(0,-1));e.coSelectionKeys=new Set(r.map((i)=>JSON.stringify(i))),e.measureSeq+=1,e.selReqId=e.measureSeq,e.channel.post({kind:"measure",paths:[[...o],...r],reqId:e.selReqId})}function ja(e){if(!e.iframe.isConnected){x.delete(e);return}let t=h.stylebook.selection,o=t?e.stylebook?.tagToCardPath.get(t):void 0;if(!t||!o){e.selReqId=-1,e.overlay.setSelection(null);return}if(!e.ready)return;e.measureSeq+=1,e.selReqId=e.measureSeq,e.channel.post({kind:"measure",paths:[[...o]],reqId:e.selReqId})}function ir(){return Zx("../canvas.html")}function Pr(e){e.channel.dispose();for(let[t,o]of q)if(ie.get(t)===e)q.delete(t),ie.delete(t),o(null);for(let[t,o]of se)if(ye.get(t)===e)se.delete(t),ye.delete(t),o();for(let[,t]of e.pendingMeasures)t([]);if(e.pendingMeasures.clear(),e.pendingTabIds.clear(),be(e),N===e)N=null;e.overlay.root.remove(),e.iframe.remove(),Xe.delete(e.canvasEl),x.delete(e)}function Fa(){if(!_e())return ir();return p().canvasUrl||ir()}function Ob(e){let t=0;for(let o of new Set(x))if(e.contains(o.canvasEl))Pr(o),t+=1;return t}function Zt(e){let t=Fa(),o=Xe.get(e);if(o){if(o.canvasUrl===t)return o;Pr(o)}let r=location.origin,i=crypto.randomUUID(),a=new URL(t,location.href).origin,l=document.createElement("iframe");l.className="jx-canvas-iframe",l.title="Canvas — live page render",l.style.cssText="width:100%;min-height:480px;height:100%;border:0;display:block;background:#fff";let s=new URL(t,location.href);if(s.searchParams.set("token",i),location.protocol==="http:"||location.protocol==="https:")s.searchParams.set("parentOrigin",r);if(l.src=a===r?`${s.pathname}${s.search}`:s.href,!e.style.position)e.style.position="relative";let c=ro(document);e.replaceChildren(l,c.root),Oa(e,()=>qS(e));let d=Qt({acceptOrigin:a,source:window,target:{postMessage:(g,y)=>l.contentWindow?.postMessage(g,y)},targetOrigin:a,token:i}),f={canvasEl:e,canvasUrl:t,channel:d,contentFragment:!1,contentHeight:null,hiddenPaths:new Set,popoverOpen:null,dialogOpen:null,editing:!1,editingProp:null,iframe:l,insertHideTimer:null,insertHover:!1,coSelectionKeys:new Set,insertZone:null,lastRenderedGen:-1,lastHover:null,lastSelectionRect:null,lastSnapshotSeq:0,measureSeq:0,overlay:c,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:-1,snapshot:null,stylebook:null,tabId:null};return c.insertButton.addEventListener("click",(g)=>Wa(f,g)),c.insertButton.addEventListener("mouseenter",()=>{f.insertHover=!0,be(f)}),c.insertButton.addEventListener("mouseleave",()=>{f.insertHover=!1,wr(f)}),d.onMessage((g)=>za(f,g)),Xe.set(e,f),x.add(f),Ja(),_a(),Ha(),f}function Va(e,t){be(e),e.insertZone=t,e.overlay.setInsertZone(R(t.rect),t.edge)}function Sr(e){be(e),e.insertZone=null,e.insertHover=!1,e.overlay.setInsertZone(null)}function qa(e){let t=e.overlay.insertButton;return e.insertHover||t.matches(":hover")}function wr(e){be(e),e.insertHideTimer=setTimeout(()=>{if(e.insertHideTimer=null,qa(e))return;Sr(e)},Ta)}function be(e){if(e.insertHideTimer!==null)clearTimeout(e.insertHideTimer),e.insertHideTimer=null}function Wa(e,t){t.stopPropagation(),t.preventDefault();let o=e.insertZone;if(!o)return;hr?.(e.overlay.insertButton,o)}var Ba=new Set(["contextMenu","dragOver","dropResult","editCommit","editCommitProp","editInput","editInsert","editMerge","editRangeReplace","editSplit","editStart","fileDragOver","fileDrop","hit","hover","insertZones","layoutHit","nativeDragEnter"]);function za(e,t){if(e.preview&&Ba.has(t.kind))return;switch(t.kind){case"ready":{e.ready=!0;let o=Yt?.();if(o)e.channel.post({chords:o.chords,kind:"keymap",mac:o.mac});if(e.postedVersions=null,tt(e),e.pending)e.channel.post(e.pending),e.pending=null;nt(e,e.selectionPaths);return}case"paneFocus":{ze(e),zt?.();return}case"popoverTargetClick":{let o=E(e);if(!o||e.preview)return;let r=JSON.stringify(o.session.ui.openPopover)===JSON.stringify(t.targetPath),i=t.action==="show"||t.action==="toggle"&&!r;if(i||r)ae()?.run("canvas.setPopoverOpen",{open:i,path:t.targetPath});return}case"commandTargetClick":{let o=E(e);if(!o||e.preview)return;let r=(a)=>JSON.stringify(a)===JSON.stringify(t.targetPath),i=oe(o.doc.document,t.targetPath);if(!Gn(i))return;if(At.has(t.command)){if(!Ea(i))return;let a=t.command==="show-popover"||t.command==="toggle-popover"&&!r(o.session.ui.openPopover);if(a||r(o.session.ui.openPopover))ae()?.run("canvas.setPopoverOpen",{open:a,path:t.targetPath})}else if(Rt.has(t.command)){if(!H(i))return;let a=t.command==="show-modal";if(a||r(o.session.ui.openDialog))ae()?.run("canvas.setDialogOpen",{open:a,path:t.targetPath})}return}case"hit":{ze(e),zt?.(),YL(null);let o=null,r=W(e.canvasEl)?.panel;if(r?.mediaName&&!r.mediaName.startsWith("git-diff")){o=ke(r.mediaName);let a=E(e);if(a)a.session.ui.activeMedia=o}if(Ge?.dismiss(),e.stylebook){let a=Xo(e.stylebook.pathToTag,t.hit.path);if(xr?.(a,o),a){let l=R(t.hit.rect);e.overlay.setSelection(l,`<${a}>`),e.lastSelectionRect=l}else e.overlay.setSelection(null);return}e.selectionPath=t.hit.path,e.selectionPaths=[t.hit.path];let i=E(e);if(i)i.session.selection=t.additive?Ix(i.session.selection,t.hit.path):[t.hit.path];{let a=R(t.hit.rect);e.overlay.setSelection(a),e.lastSelectionRect=a}return}case"layoutHit":{if(e.stylebook)return;ze(e),Ge?.dismiss(),YL(t.hit),e.selectionPath=null,e.selectionPaths=[];let o=E(e);if(o)o.session.selection=[];let r=R(t.hit.rect);e.overlay.setSelection(r,`LAYOUT · ${t.hit.layoutFile}`),e.lastSelectionRect=r,xn("rightPanel");return}case"hover":{if(e.stylebook){let o=t.hit?Xo(e.stylebook.pathToTag,t.hit.path):null,r=h.stylebook.selection;if(t.hit&&o&&o!==r)e.overlay.setHover(R(t.hit.rect));else e.overlay.setHover(null);return}e.lastHover=t.hit,Za(e,t.hit);return}case"insertZones":{if(e.stylebook)return;let o=t.zones?.[0]??null;if(o)Va(e,o);else wr(e);return}case"geometry":{let o=e.pendingMeasures.get(t.reqId);if(o){e.pendingMeasures.delete(t.reqId),o(t.hits);return}if(t.reqId===e.presenceReqId){e.presenceReqId=-1;let r=[];for(let i of t.hits){let a=e.presenceMeta.get(JSON.stringify(i.path));if(a)r.push({...a,placement:R(i.rect)})}e.overlay.setPresence(r);return}if(t.reqId===e.panReqId){e.panReqId=-1;let[r]=t.hits;if(r){let{rect:i,scale:a}=Ul(e);Oo({height:r.rect.height*a,top:r.rect.y*a+i.top})}return}if(t.reqId===e.selReqId){let r=JSON.stringify(e.selectionPath),i=[],a=null;if(e.stylebook){let[s]=t.hits;a=s?R(s.rect):null}else for(let s of t.hits){let c=JSON.stringify(s.path);if(c===r)a=R(s.rect);else if(e.coSelectionKeys.has(c))i.push(R(s.rect))}let l=e.stylebook?h.stylebook.selection:null;e.overlay.setSelection(a,l?`<${l}>`:null),e.overlay.setCoSelection(i),e.lastSelectionRect=a,e.hiddenPaths=new Set((t.hidden??[]).map((s)=>JSON.stringify(s)))}return}case"evalResult":{let o=q.get(t.reqId);if(!o)return;q.delete(t.reqId),ie.delete(t.reqId),o(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 o of e.pendingTabIds.keys())if(o<=t.gen)e.pendingTabIds.delete(o);ar(e,t.gen);return}case"patchComplete":{e.pendingPatches=Math.max(0,e.pendingPatches-1),ar(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 o=E(e);if(o)o.session.canvas.refreshing=!1,xn("leftPanel");C.error("The page could not be rendered.",{detail:t.message,key:`canvas.render:${dr(e)}`,source:"Canvas"});return}case"dataScope":{if(t.gen!==e.lastRenderedGen)return;let o=E(e);if(o)o.session.canvas.scope=t.scope,o.session.canvas.refreshing=!1;xn("leftPanel");return}case"contentHeight":{e.contentHeight=t.height,e.contentFragment=t.fragment,mr(e);return}case"dragOver":{if(t.dragSeq!==ee)return;if(t.cursor)lr=t.dragSeq,cr=Date.now();if(t.gen!==e.lastRenderedGen)return;if(t.preview)e.overlay.setDropIndicator(R(t.preview.referenceRect),t.preview.edge);else e.overlay.setDropIndicator(null);if(t.cursor){let o=Ul(e);US(t.cursor.x*o.scale+o.rect.left,t.cursor.y*o.scale+o.rect.top)}return}case"nativeDragEnter":{if(e.stylebook)return;gr?.(e);return}case"dragEnd":{e.overlay.setDropIndicator(null),nh(),ve.delete(t.dragSeq);return}case"dropResult":{if(t.dragSeq!==ee||t.gen!==e.lastRenderedGen)return;if(t.instruction&&t.targetPath){let o=ve.get(t.dragSeq);if(o)Rb(E(e),{type:t.instruction},o,t.targetPath)}ve.delete(t.dragSeq),e.overlay.setDropIndicator(null),nh();return}case"fileDragOver":{if(e.stylebook)return;Ma(e,t.hit,t.preview);return}case"fileDragLeave":{Yo(e);return}case"fileDrop":{if(Yo(e),e.stylebook)return;Gt?.(E(e),t.files,t.hit,t.preview);return}case"patchError":{e.pendingPatches=Math.max(0,e.pendingPatches-1);let o=W(e.canvasEl)?.surface;if(o)br?.(o.paneId);return}case"forwardKey":{Ga(t.event);return}case"forwardWheel":{Ua(e,t);return}case"editStart":{if(N&&N!==e)N.editing=!1,N.editingProp=null,N.snapshot=null;if(N=e,t.prop!==void 0&&Wt===Mc(t.path))he(e,t.path,void 0,t.prop);Wt=null,Ra+=1,e.editing=!0,e.editingProp=t.prop??null,e.snapshot=null,e.lastSnapshotSeq=0,Ze?.();return}case"selectionChanged":{if(t.seq<=e.lastSnapshotSeq)return;if(e.lastSnapshotSeq=t.seq,e.snapshot=t,!e.editing)e.editing=!0,N=e;Ze?.();return}case"flushComplete":{let o=se.get(t.reqId);if(o)se.delete(t.reqId),ye.delete(t.reqId),o();return}case"editInput":{let o=E(e);if(o)o.doc.dirty=!0;return}case"editCommit":{let o=()=>Kn(E(e),t.path,t.children,t.textContent);if(t.inPlace)er(e,[t.path],o);else o();return}case"editCommitProp":{let o=()=>Zn(E(e),t.path,t.prop,t.value);if(t.inPlace){er(e,[t.path],o),qt=Mc(t.path);return}let r=o();if(Aa(r,qt,Mc(t.path)))Ia(e,t.path);qt=null,Wt=r?Mc(t.path):null;return}case"editMerge":{let o=Yn(E(e),t.fromPath,t.intoPath);if(o)he(e,o.path,o.offset);return}case"editRangeReplace":{let o=no(E(e),t.from,t.to,t.between,t.text);if(o)he(e,o.path,o.offset);return}case"editSplit":{he(e,Qn(E(e),t.path,t.before,t.after));return}case"editInsert":{he(e,eo(E(e),t.path,t.cmd,t.commitData));return}case"slashShow":{let{rect:o,scale:r}=Ul(e),i=t.rect.x*r+o.left,a=t.rect.y*r+o.top,l={filter:t.filter,onDismiss:()=>e.channel.post({kind:"slashDismissed"}),onSelect:(s)=>e.channel.post({cmd:{...s},kind:"slashSelect"}),rect:{bottom:a+t.rect.height*r,height:t.rect.height*r,left:i,top:a,width:t.rect.width*r}};if(t.showFilter===!0)l.showFilter=!0;Ue?.show(l);return}case"slashNav":{Ue?.nav(t.key);return}case"slashDismiss":{Ue?.dismiss();return}case"previewNavigate":{ha(t.href,e);return}case"contextMenu":{if(e.stylebook)return;ze(e);let{rect:o,scale:r}=Ul(e);Ge?.show({clientX:t.x*r+o.left,clientY:t.y*r+o.top,path:t.path?[...t.path]:null});return}case"editEnd":{if(!e.editing)return;if(e.editing=!1,e.editingProp=null,e.snapshot=null,N===e)N=null;Ze?.();break}default:break}}function ar(e,t){if(e.lastRenderedGen=t,nt(e,e.selectionPaths),Cr(e),Sr(e),es(e),e.pendingEnterEdit&&t>=e.pendingEnterEdit.minGen){let{offset:o,path:r,prop:i}=e.pendingEnterEdit;if(e.pendingEnterEdit=null,e.tabId!==null&&e.tabId===ce(e.canvasEl)?.id)Ka(e,r,o,i)}}function he(e,t,o,r){let i={minGen:e.lastRenderedGen,path:[...t]};if(o!==void 0)i.offset=o;if(r!==void 0)i.prop=r;e.pendingEnterEdit=i}function Ka(e,t,o,r){let i={kind:"enterEdit",path:[...t]};if(o!==void 0)i.offset=o;if(r!==void 0)i.prop=r;e.channel.post(i)}function Ua(e,t){let{rect:o,scale:r}=Ul(e),i=Zc(e.canvasEl)?.wrap;if(!i)return;i.dispatchEvent(new WheelEvent("wheel",{bubbles:!0,cancelable:!0,clientX:o.left+t.x*r,clientY:o.top+t.y*r,ctrlKey:t.ctrlKey,deltaX:t.deltaX,deltaY:t.deltaY,metaKey:t.metaKey,shiftKey:t.shiftKey}))}function Ga(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 Za(e,t){if(!t||Er(t.path,e.selectionPath)){e.overlay.setHover(null);return}e.overlay.setHover(R(t.rect))}var Ya=4,X=new Map;function Xa(e){let t=X.get(e);if(t)return X.delete(e),X.set(e,t),t;let o=new Map;X.set(e,o);for(let r of X.keys()){if(X.size<=Ya)break;X.delete(r)}return o}function Qa(e,t,o,r,i,a=null){let l=Xa(e),s=r?.id??null,c=l.get(t);if(c&&c.tabId===o&&c.viewTabId===s&&c.mode===a)return c.payload;let d=va(i),f=OS(Ln,async()=>{Vo.renderPreparations+=1;let g=await kn(t,r,a),y=j(g.renderDoc),b=j(t),T=o?m.tabs.get(o)??null:null,k=Wi(T?.doc.sourceFormat)?.studio?.elements,I=k?Ko(k):void 0,J={assets:g.assets,doc:y,docBase:g.docBase??`${rh()}/`,mapperCtx:g.mapperCtx,mode:g.mapperCtx.canvasMode,shadowDoc:b,siteStyle:g.siteStyle};if(I)J.editableTags=I;if(d)J.allowAutoRequests=!0;return J});return l.set(t,{mode:a,payload:f,tabId:o,viewTabId:s}),f}async function IL(e,t,o,r,i=null,a=ce(o),l=null,s=null){let c=Zt(o);c.pendingTabIds.set(e,i),c.stylebook=null,c.iframe.style.width=r?`${r}px`:"100%";let f={...await Qa(e,t,i,a,ct(o),l),colorScheme:Mr(a),gen:e,kind:"render",locale:Or(a),popoverOpen:a?.session.ui.openPopover??null,dialogOpen:a?.session.ui.openDialog??null};if(s)f.diffMarks=s;c.popoverOpen=f.popoverOpen??null,c.dialogOpen=f.dialogOpen??null,Kt(c,f.mode==="preview"),Tr(c,f)}function Tr(e,t){if(Vo.hostRenderPosts+=1,e.ready){tt(e),e.channel.post(t);return}let o=e.pending;if(o?.kind==="render"&&o.gen>t.gen){e.pendingTabIds.delete(t.gen);return}e.pending=t}function RL(e,t,o,r){let i=Zt(o);i.pendingTabIds.set(e,null),i.stylebook={pathToTag:t.pathToTag,tagToCardPath:t.tagToCardPath},Kt(i,!1),i.pendingEnterEdit=null,i.iframe.style.width=r?`${r}px`:"100%";let a=j(t.doc),l=j(t.doc),s={assets:null,colorScheme:Mr(ce(o)),locale:Or(ce(o)),doc:a,docBase:`${rh()}/`,gen:e,kind:"render",mapperCtx:{arrayPaths:[],canvasMode:"stylebook",layoutWrapped:!1,pageContentOffset:null,pageContentPrefix:null},mode:"stylebook",shadowDoc:l,siteStyle:null};Tr(i,s)}function Mr(e){let t=e?.session.ui.previewColorScheme;return t==="light"||t==="dark"?t:null}function DL(e,t){for(let o of x){if(!o.iframe.isConnected){x.delete(o);continue}if(t&&!t.contains(o.iframe))continue;if(o.ready)o.channel.post({kind:"setColorScheme",scheme:e})}}function Nr(e){return e===null?null:{dir:tv(e),locale:e}}function Or(e){return Nr(e?Ip(e.session.ui.previewLocale,e.documentPath):null)}function NL(e,t){let o=tv(e);for(let r of x){if(!r.iframe.isConnected){x.delete(r);continue}if(t&&!t.contains(r.iframe))continue;if(r.ready)r.channel.post({dir:o,kind:"setLocale",locale:e});else if(r.pending?.kind==="render")r.pending={...r.pending,locale:Nr(e)}}}function AL(e,t){let o=j(e),r=0;for(let i of x){if(!i.iframe.isConnected){x.delete(i);continue}if(i.ready)i.channel.post({base:t,doc:o,kind:"redefineElement"}),r+=1}return r}function OL(){let e=S?.projectConfig;if(!e)return;let t=j(e.style??null),o=j(e.$media??{});for(let r of x){if(!r.iframe.isConnected){x.delete(r);continue}if(r.ready&&!r.stylebook)r.channel.post({kind:"siteStyleUpdate",media:o,siteStyle:t})}}function Jw(e){let t=0,o=j(e);for(let r of x){if(!r.iframe.isConnected){x.delete(r);continue}if(r.ready&&r.stylebook)r.channel.post({gen:r.lastRenderedGen,kind:"styleUpdate",style:o}),t+=1,nt(r,r.selectionPaths)}return t}var Ye=null;function Rr(e,t){if(!e?.stylebook||!e.ready)return!1;let o=e.stylebook.tagToCardPath.get(t);if(!o)return!1;return e.measureSeq+=1,e.panReqId=e.measureSeq,e.channel.post({kind:"measure",paths:[[...o]],reqId:e.panReqId}),!0}function ML(e){Ye=Rr(Xt(),e)?null:e}function es(e){let t=Ye;if(t===null||!e.stylebook)return;if(h.stylebook.selection!==t){Ye=null;return}if(e===Xt()&&Rr(e,t))Ye=null}function ql(){let e=N;if(!e||!e.iframe.isConnected)return{editing:!1,editingProp:null,snapshot:null};return{editing:e.editing,editingProp:e.editingProp,snapshot:e.snapshot}}var Yt=null;function PL(e,t){Yt=e,t?.(()=>sr()),sr()}function sr(){let e=Yt?.();if(!e)return;for(let t of x){if(!t.iframe.isConnected){x.delete(t);continue}if(t.ready)t.channel.post({chords:e.chords,kind:"keymap",mac:e.mac})}}function ih(e){let t=N;if(!t||!t.ready)return;t.channel.post({intent:e,kind:"applyFormat"})}function FL(){let e=N;if(!e||!e.ready)return;e.channel.post({kind:"openSlash"})}function Yw(){let e=N;if(e?.editing&&e.ready&&e.iframe.isConnected)e.channel.post({kind:"endEdit"})}function Xt(){let e=ao();return e?qS(e.canvas):null}function JS(){let e=N,t=e??Xt();if(!t)return null;let{rect:o,scale:r}=Ul(t);if(t.lastSelectionRect)return{height:t.lastSelectionRect.height*r,left:t.lastSelectionRect.left*r+o.left,top:t.lastSelectionRect.top*r+o.top,width:t.lastSelectionRect.width*r};let i=t===e?t.snapshot?.rect:null;if(i)return{height:i.height*r,left:i.x*r+o.left,top:i.y*r+o.top,width:i.width*r};return null}
|
|
2
|
+
export{vN,Eb,vr,vt,Hr,kS,Nc,Wo,tl,yr,Ju,Ac,Yu,ES,yN,TS,wN,xN,LS,_N,$S,Zu,Tb,Lb,di,wm,YT,Fw,SN,Wl,Vl,Xu,CN,IS,ZT,Oc,Qu,kN,$b,Cp,RS,DS,EN,NS,XT,TN,LN,Vo,jw,AS,OS,ji,eh,QT,Ib,eL,$N,IN,kp,MS,RN,DN,Mc,PS,xm,NN,Hw,AN,Bw,ON,zw,Ep,Br,MN,_m,PN,FN,FS,jN,jS,HN,HS,tL,nL,BS,Sm,Tp,BN,zN,Ww,Us,th,Lp,WN,VN,zS,iL,Cm,WS,UN,VS,oL,qN,rL,sL,aL,GN,Vw,lL,US,nh,nl,Uw,$p,qw,KN,JN,YN,Rb,cL,dL,uL,hL,qS,Db,Nb,GS,Ul,pL,fL,mL,Ab,H2,sP,gL,Pc,Gw,Kw,bL,vL,yL,wL,xL,_L,SL,CL,kL,EL,TL,LL,KS,$L,Ob,IL,RL,DL,NL,AL,OL,Jw,ML,ql,PL,ih,FL,Yw,JS};
|
|
3
|
+
|
|
4
|
+
//# debugId=C58D1FBA6B0CFD7F64756E2164756E21
|
|
5
|
+
//# sourceMappingURL=studio-pqqq6v85.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var s=new Set(["project.schema.json","document.schema.json"]);function
|
|
2
|
-
export{
|
|
1
|
+
var s=new Set(["project.schema.json","document.schema.json"]);function lI(e){return s.has(e)?`file:///.jx/generated/${e}`:`file:///${e}`}function rM(e,r){return{head:`file:///.jx/diff/${e}/head/${r}`,work:`file:///.jx/diff/${e}/work/${r}`}}function sM(e){switch(e.slice(e.lastIndexOf(".")+1).toLowerCase()){case"cjs":case"js":case"mjs":return"javascript";case"css":return"css";case"htm":case"html":return"html";case"json":return"json";case"md":return"markdown";case"cts":case"mts":case"ts":return"typescript";case"yaml":case"yml":return"yaml";default:return"plaintext"}}
|
|
2
|
+
export{lI,rM,sM};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
5
|
-
//# sourceMappingURL=studio-
|
|
4
|
+
//# debugId=336EF59C7B8DB82264756E2164756E21
|
|
5
|
+
//# sourceMappingURL=studio-r17asgs0.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var
|
|
2
|
-
export{
|
|
1
|
+
var tI="content",OC=/^[\w.~-]+$/,Lo="{locale}";function u(t){let n=t.replaceAll("\\","/");return n.length>1&&n.endsWith("/")?n.slice(0,-1):n}function p(t){let n=u(t);return n.startsWith("/")?n:`/${n}`}function f(t,n){return[...t].toSorted((e,s)=>s[n].length-e[n].length)}function g(t,n){return t===n||t.startsWith(`${n}/`)}function XO(t,n){let e=u(n);for(let s of f(t,"dir")){let r=u(s.dir);if(!g(e,r)||e===r)continue;let o=e.slice(r.length+1),{filter:i}=s;if(i&&!i(o))return null;let l=o.split("/").map((c)=>encodeURIComponent(c)).join("/");return`${p(s.urlPrefix)}/${l}`}return null}function h(t,n){let e=n.split("#")[0].split("?")[0];if(!e.startsWith("/"))return null;let s;try{s=decodeURIComponent(e)}catch{return null}if(/%2e|%2f/i.test(s))return null;for(let r of f(t,"urlPrefix")){let o=p(r.urlPrefix);if(!s.startsWith(`${o}/`))continue;let l=s.slice(o.length+1).split("/");if(l.some((a)=>a===""||a==="."||a===".."))return null;let{filter:c}=r;if(c&&!c(l.join("/")))return null;return`${u(r.dir)}/${l.join("/")}`}return null}var m=String.raw`"'\s<>()\\`;var MC="public";var QO=["mounts","public"];function Wx(t){let n=t.search(/[#?]/);return n===-1?{path:t,suffix:""}:{path:t.slice(0,n),suffix:t.slice(n)}}function nI(t){return t===""||t.startsWith("/")||t.startsWith("#")||t.includes("${")||/^[a-z][\w+.-]*:/i.test(t)}function Si(t){return t.replaceAll("\\","/").replace(/^\.\//,"").replace(/^\/+/,"").replace(/\/+$/,"")}function eM(t){let n=Si(t),e=n.lastIndexOf("/");return e===-1?"":n.slice(0,e)}function iI(t,n){let s=(t===""||t==="."?[]:Si(t).split("/")).filter((r)=>r!==""&&r!==".");for(let r of n.replaceAll("\\","/").split("/")){if(r===""||r===".")continue;if(r===".."){if(s.length===0)return null;s.pop();continue}s.push(r)}return s.join("/")}function d(t,n,e){let{path:s}=Wx(t);if(!s.startsWith("/"))return[];let r;try{r=decodeURIComponent(s)}catch{return[]}if(/%2e|%2f/i.test(r))return[];let o=r.replace(/^\/+/,"");if(o===""||o.split("/").some((l)=>l==="."||l===".."))return[];let i=[];for(let l of e){if(l==="mounts"){let c=h(n,s);if(c!==null&&!c.startsWith("/")&&!/^[A-Za-z]:/.test(c))i.push(Si(c));continue}i.push(l==="root"?o:`${MC}/${o}`)}return[...new Set(i)]}function tM(t,n,e,s){let{path:r}=Wx(t);if(r==="")return null;if(nI(t))return r.startsWith("/")?d(r,e,s)[0]??null:null;if(r.endsWith("/"))return null;let o;try{o=decodeURIComponent(r)}catch{return null}let i=iI(n,o);if(i===null||i===""||i===Si(n))return null;return i}function wv(t){return t.split("/").map((n)=>encodeURIComponent(n)).join("/")}function nM(t){let n=[],e=0;while(e<t.length){while(e<t.length&&(/\s/.test(t[e])||t[e]===","))e+=1;if(e>=t.length)break;let s=e;while(e<t.length&&!/\s/.test(t[e]))e+=1;let r=t.slice(s,e);if(r.endsWith(",")){n.push({descriptor:"",url:r.replace(/,+$/,"")});continue}while(e<t.length&&/\s/.test(t[e]))e+=1;let o=e;while(e<t.length&&t[e]!==",")e+=1;let i=t.slice(o,e).trim();if(e+=1,r=r.replace(/,+$/,""),r!=="")n.push({descriptor:i,url:r})}return n}function iM(t){return t.map(({url:n,descriptor:e})=>e?`${n} ${e}`:n).join(", ")}
|
|
2
|
+
export{tI,OC,Lo,XO,MC,QO,Wx,nI,Si,eM,iI,tM,wv,nM,iM};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
5
|
-
//# sourceMappingURL=studio-
|
|
4
|
+
//# debugId=00258579A5360F8664756E2164756E21
|
|
5
|
+
//# sourceMappingURL=studio-ry81j4q1.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{Ht,Wi,fn,lr,Aa}from"./studio-3w35qvay.js";import{C}from"./studio-4kzbrr5t.js";import{Pn,Kc,St,Hi,Ce,To,We,Wd,u}from"./studio-vzgmyt0v.js";import{Lo}from"./studio-ry81j4q1.js";import{te}from"./studio-psh8mwnw.js";import{lm}from"./studio-zg16eeq1.js";import{_a}from"./studio-34jrz12k.js";import{WD,tT}from"./studio-wxdcd42g.js";import{Co}from"./studio-5wzdy1jc.js";import{yr,Zu}from"./studio-pqqq6v85.js";import{lw,lb}from"./studio-jw0q5j6k.js";import{ab}from"./studio-zgx7svjd.js";import{Ml}from"./studio-dbxv7w4s.js";import{ya,Ic,GE}from"./studio-d038kqbs.js";import{as,fb}from"./studio-s0fg2wav.js";import{v}from"./studio-zkq3r91p.js";import{le}from"./studio-7xag4na8.js";var nb=["page","collection","template","component","media","entry"],nw={collection:{cta:"Create collection",hint:"Posts, products, team… with a page each",icon:"stack",id:"collection",label:"Collection",nameLabel:"Collection name",placeholder:"Recipes"},component:{cta:"Create component",hint:"A reusable block for any page",icon:"cube",id:"component",label:"Component",nameLabel:"Component name",placeholder:"Pricing table"},entry:{cta:"Create entry",hint:"A new item in a collection",icon:"file-text",id:"entry",label:"Entry",nameLabel:"Entry name",placeholder:"My first post"},media:{cta:"Upload",hint:"Images, video, documents",icon:"image",id:"media",label:"Media",nameLabel:"",placeholder:""},page:{cta:"Create page",hint:"A new URL on your site",icon:"file",id:"page",label:"Page",nameLabel:"Page name",placeholder:"Pricing"},template:{cta:"Create template",hint:"Shared frame that pages sit inside",icon:"frame-corners",id:"template",label:"Template",nameLabel:"Template name",placeholder:"Landing"}},Hs="blank",$c="article",P_="selection",sm="copy",iw=["title","image","richText","date","tags","number","link"],F_={date:{key:"date",label:"Date",schema:{format:"date",type:"string"}},image:{key:"cover",label:"Image",schema:{format:"image",type:"string"}},link:{key:"link",label:"Link",schema:{format:"uri",type:"string"}},number:{key:"number",label:"Number",schema:{type:"number"}},richText:{key:null,label:"Rich text",schema:null},tags:{key:"tags",label:"Tags",schema:{items:{type:"string"},type:"array"}},title:{key:"title",label:"Title",schema:{type:"string"}}},hE=["title","image","richText"];function p(e,n){return e==="."||e===""?n:`${e}/${n}`}function Qa(e){return e.replace(/^\.\//,"")}function j_(e,n){let t=n.defaultLayout;if(e===Hs||e==="")return t?!1:void 0;if(t&&Qa(t)===Qa(e))return;return e}function Mu(e){let n=e.defaultLayout;if(n)return e.layouts.find((r)=>Qa(r.ref)===Qa(n))?.ref??n;return e.layouts[0]?.ref??Hs}function H_(e,n){let t=Pn(n??"");if(t!==null){let r=e.layouts.find((o)=>Qa(o.ref).replace(/\.json$/i,"").split("/").some((l)=>Pn(l)===t));if(r)return r.ref}return Mu(e)}function R(e){return e.trim().replaceAll("\\","/").split("/").map((n)=>as(n)).filter((n)=>n!=="")}function I(e){let n={};for(let r of iw){let o=F_[r];if(e.includes(r)&&o.key!==null&&o.schema!==null)n[o.key]={...o.schema}}let t={properties:n,type:"object"};if(e.includes("title"))t.required=["title"];return t}function cD(e,n){let t=e?.properties??{};return iw.filter((r)=>{let{key:o}=F_[r];return o===null?n:Object.hasOwn(t,o)})}function w(e,n){let t=GE(e.schema);if(n!==void 0&&n!==""&&e.schema?.properties?.title!==void 0)t.title=n;if(e.ext===".json"||e.formatName===null)return{doc:t,format:null};return{doc:{...t,children:[]},format:e.formatName,frontmatter:Object.keys(t).length>0}}function pE(e,n,t,r){let o=[];if(n.includes("title"))o.push({tagName:"h1",textContent:"${state.entry.data.title}"});if(n.includes("image"))o.push({attributes:{alt:n.includes("title")?"${state.entry.data.title}":"",loading:"lazy",src:"${state.entry.data.cover}"},tagName:"img"});if(n.includes("richText")&&r.contentFormat!==null)o.push({children:"${state.entry.$children}",tagName:"div"});let i={};if(t!==void 0)i.$layout=t;return i.$paths={contentType:e,field:"id",param:"slug"},i.title=n.includes("title")?"${state.entry.data.title}":Zu(e),i.state={entry:{$prototype:"ContentEntry",$src:"@jxsuite/parser/ContentEntry.class.json",contentType:e,field:"id",id:{$ref:"#/$params/slug"}}},i.tagName="article",i.children=o,i}function am(e,n){let t=n.i18n??null,r=Pn(e);return t!==null&&r!==null&&t.locales.includes(r)?r:null}function ib(e){return e.dir.includes(Lo)}function _(e,n){return e.localeDirs?.[n]??e.dir.replace(Lo,n.toLowerCase())}function E(e,n,t){let r=t.i18n??null;if(n===null||r===null)return e;return Kc(e,n,{...r,locales:[...r.locales]})??e}function J(e){let n=e.lastIndexOf("/");return n===-1?[".",e]:[e.slice(0,n),e.slice(n+1)]}function W(e,n,t){if(n.startFrom===sm&&n.copyOf!==void 0){let r=t.componentDocs?.get(n.copyOf);if(r){let o=JSON.parse(JSON.stringify(r));return delete o.$id,o.tagName=e,o}}return{children:[],tagName:e}}function B(e,n,t){let r=n.startFrom??Mu(t),o=r===$c&&t.article!==null?t.article:null,i=o?.ext??".json",l=n.url===void 0?[as(e)].filter((m)=>m!==""):R(n.url),a=l.length===0?n.url===void 0?"":"index":l.at(-1),s=["pages",...l.slice(0,-1)].join("/"),c=a===""?"":`${a}${i}`,f=am(n.locale,t),d=c===""?p(s,c):E(p(s,c),f,t),b=c===""?s:J(d)[0],g=e.trim(),y;if(o)y={doc:{children:[{tagName:"h1",textContent:g}],title:g},format:o.name,frontmatter:!0};else{let m={},h=j_(r===$c?Hs:r,t);if(h!==void 0)m.$layout=h;m.title=g,m.tagName="main",m.children=[{tagName:"h1",textContent:g}],y={doc:m,format:null}}let N=c===""?"":yr(d).urlPattern;return{content:y,dir:b,ext:i,extraWrites:[],fileName:c,kind:"page",path:d,route:N,saved:c===""?"":`Saved as ${d} · opens at ${N}`}}function K(e,n,t){let r=as(e),o=n.fields??hE,i=t.i18n??null,l=i!==null&&n.localized!==!1,a=`content/${r}`,s=l?`${a}/${i.defaultLocale.toLowerCase()}`:a,c=t.contentFormat,f=c?.ext??".json",d=Zu(r),b=r===""?"":`first-${d.replaceAll(" ","-")}${f}`,g=I(o),y=structuredClone(g),N={format:c?.name??"json",schema:v(y)?y:{},source:l?`./${a}/${Lo}`:`./${a}`},m=w({ext:f,formatName:c?.name??null,schema:g},`First ${d}`),h=[],k,L="";if(n.ownPage!==!1&&r!==""){let j=n.pageTemplate??Mu(t),D=l?[i.defaultLocale,...i.locales.filter((x)=>x!==i.defaultLocale)]:[null],T=[];for(let x of D){let O=E(`pages/${r}/[slug].json`,x,t),A=x===null||j!==Mu(t)?j:H_(t,x);k??=yr(O).urlPattern,h.push({body:{doc:pE(r,o,j_(A,t),t),format:null},path:O}),T.push(O)}L=T.length===1?`, and ${T[0]} at ${k}`:`, and a page in each language (${T.join(", ")})`}let P={config:{entry:N,name:r},content:m,dir:s,ext:f,extraWrites:h,fileName:b,kind:"collection",path:p(s,b),saved:r===""?"":l?`Adds a “${r}” collection to project.json with one folder per language under ${a}/, a first entry in ${s}/${L}.`:`Adds a “${r}” collection to project.json, a ${s}/ folder with a first entry${L}.`};if(k!==void 0)P.route=k;return P}function M(e,n){let t=as(e),r=t===""?"":`${t}.json`,o=p("layouts",r),i={},l=n.startFrom??"";if(l!==""&&l!==Hs)i.$layout=l;return i.tagName="div",i.children=[{children:[{tagName:"slot"}],tagName:"main"}],{content:{doc:i,format:null},dir:"layouts",ext:".json",extraWrites:[],fileName:r,kind:"template",path:o,saved:r===""?"":`Saved as ${o} with one slot.`}}function z(e,n,t){let r=lb(e),o=r===""?"":`${r}.json`,i=p("components",o);return{content:{doc:W(r,n,t),format:null},dir:"components",ext:".json",extraWrites:[],fileName:o,kind:"component",path:i,saved:o===""?"":`Saved as ${i} with tag <${r}>.`,tag:r}}function U(e,n,t){let r=t.collections.find((d)=>d.name===n.collection)??null,o=as(e),i=r?.ext??".json",l=am(n.locale,t),a=r!==null&&ib(r)&&l===null,s=r===null?"content":ib(r)&&l!==null?_(r,l):r.dir,c=o===""||r===null||a?"":`${o}${i}`,f=p(s,c);return{content:r?w(r,e.trim()):{doc:{},format:null},dir:s,ext:i,extraWrites:[],fileName:c,kind:"entry",path:f,saved:c===""?"":`Saved as ${f} in ${r.name}.`}}function fE(e,n,t,r){switch(e){case"page":return B(n,t,r);case"collection":return K(n,t,r);case"template":return M(n,t);case"component":return z(n,t,r);case"entry":return U(n,t,r);default:{let o=t.files??0;return{content:{doc:{},format:null},dir:_a,ext:"",extraWrites:[],fileName:"",kind:e,path:_a,saved:o===0?`Saved under ${_a}/. No folder to choose.`:`${o===1?"1 file":`${o} files`} will be saved under ${_a}/.`}}}}function q(e,n){let t=e.lastIndexOf("/"),r=t===-1?".":e.slice(0,t),o=n(r);return fb(e.slice(t+1),"",{dir:r,taken:o??new Set})}function S(e){if(e.kind!=="page"||e.fileName==="")return[];let n=e.fileName.slice(0,e.fileName.length-e.ext.length);if(n!=="index")return[{dir:e.dir,stem:n},{dir:p(e.dir,n),stem:"index"}];let t=e.dir.lastIndexOf("/");if(t===-1)return[{dir:e.dir,stem:n}];return[{dir:e.dir,stem:n},{dir:e.dir.slice(0,t),stem:e.dir.slice(t+1)}]}function V(e,n){let t=e.fileName.toLowerCase();for(let{dir:r,stem:o}of S(e)){let i=`${o.toLowerCase()}.`;for(let l of n(r)??[])if(l.startsWith(i)&&!(r===e.dir&&l===t))return p(r,l)}return null}function H(e){return fb(e,"",{choice:{ext:"",kind:"fixed"},dir:".",taken:new Set})}function mE(e,n,t,r,o){if(e.kind==="media")return(t.files??0)===0?"Drop files here, or browse for them.":"";let i=H(n);if(i!=="")return i;switch(e.kind){case"page":{if(t.url!==void 0){if(t.url.replaceAll("\\","/").split("/").includes(".."))return"A URL cannot step outside the site.";if(!t.url.trim().startsWith("/"))return"A URL starts with a slash, such as /pricing."}let a=V(e,o);if(a!==null)return`${a} already opens at ${e.route??"/"}.`;break}case"component":{let a=e.tag??"",s=lw(a);if(s!=="")return s;if(r.componentTags.includes(a))return`A component named <${a}> already exists.`;if(t.startFrom===P_&&r.hasSelection!==!0)return"Select an element on the canvas to make a component from it.";if(t.startFrom===sm&&(t.copyOf===void 0||r.componentDocs?.get(t.copyOf)===void 0))return"Choose the component to copy.";break}case"collection":{let a=e.config?.name??"";if(r.declaredContent.includes(a))return`A collection named “${a}” already exists.`;if(o("content")?.has(a)===!0)return`content/${a}/ already exists.`;break}case"entry":{let a=r.collections.find((s)=>s.name===t.collection);if(!a)return"Choose the collection this entry belongs to.";if(ib(a)&&am(t.locale,r)===null)return`Choose the language this ${Zu(a.name)} is written in.`;break}default:break}let l=[...e.kind==="collection"?[]:[e.path],...e.extraWrites.map((a)=>a.path)];for(let a of l){let s=q(a,o);if(s!=="")return s}return""}function gE(e){let n=new Set,t=(r)=>{let o=r.lastIndexOf("/");n.add(o===-1?".":r.slice(0,o))};if(e.kind==="media")return[];if(e.kind==="collection")n.add("content");else if(e.fileName!=="")t(e.path);for(let r of e.extraWrites)t(r.path);for(let{dir:r}of S(e))n.add(r);return[...n]}function dD(e){let n=(r)=>r==="."?0:r.split("/").length,t=new Map;for(let r of e){let o=n(r);t.set(o,[...t.get(o)??[],r])}return[...t.entries()].toSorted(([r],[o])=>r-o).map(([,r])=>r)}function uD(e,n){if(e===".")return!1;let t=e.lastIndexOf("/"),r=n.get(t===-1?".":e.slice(0,t));return r!==void 0&&!r.has(e.slice(t+1).toLowerCase())}function B_(e){if(e.ext===".json")return null;return(e.def.format?Wi(e.def.format)?.name:void 0)??fn(`untitled${e.ext}`)?.name??lr()?.name??null}async function G(e){let n=w({ext:e.ext,formatName:B_(e),schema:e.schema});if(n.format===null)return Co(n.doc,null);return Aa(n.format,n.doc,{frontmatter:n.frontmatter??!1,mode:"roundtrip"})}async function Z2(e,n={}){let t=ya(e);if(!t)return C.error(`No content collection named "${e}" to create an entry in.`,{detail:"A collection needs a `content` entry in project.json whose `source` is a directory. A collection whose source names a single file (a CSV catalogue) has rows, not entry files.",source:"Content"}),null;await Ht().catch(()=>{});let r;try{r=await G(t)}catch(s){return C.error(`Could not prepare a new ${t.name} entry.`,{detail:te(s),path:t.dir,source:"Content"}),null}let o=n.dir,i=o!==void 0&&Wd(o)?.name===t.name?o:t.dir;if(i.includes(Lo))return C.error(`"${t.name}" is a localized collection.`,{detail:`Its entries live in one directory per language (${t.dir}). Open the folder for the language you are writing in and create the entry there.`,path:t.dir,source:"Content"}),null;let{createFileIn:l}=await (le("de90apn9"),import("./files-de90apn9.js")),a=await l({content:r,dir:i,format:{ext:t.ext,kind:"fixed"},source:"Content",suggestedName:"untitled",title:`New ${t.name} entry`});if(a===null)return null;return lm(t.name),await Ml(a),a}function F(){let e=u.value;return e&&Ic(e.documentPath)?e:null}function Y(){return[{args:Ce({path:We("Project-relative path of the entry file to open.")}),category:"File",id:"content.openEntry",level:"project",menus:["context/file","palette"],group:"1_file",requires:"an open project",when:(e)=>e.project.open,run:async(e,n)=>{await Ml(St("content.openEntry",n,"path"))},title:"Open Entry"},{args:Ce({draft:To("True marks the open entry a draft; false marks it published. Written as a `draft` field on the entry.")}),category:"Document",id:"content.setDraft",level:"document",menus:["context/tab","palette"],group:"3_document",requires:"a content entry open",when:(e)=>e.document.open,enablement:()=>F()!==null,undo:"document",run:(e,n)=>{let t=F();if(!t)throw Error("content.setDraft: the active document is not a content entry");ab(t,Hi("content.setDraft",n,"draft"))},title:"Set Draft"},{args:Ce({include:To("True lists entries marked `draft: true` alongside the rest.")}),category:"View",id:"content.setIncludeDrafts",level:"project",menus:["palette"],group:"2_view",requires:"an open project",when:(e)=>e.project.open,run:async(e,n)=>{WD(Hi("content.setIncludeDrafts",n,"include")),await tT()},title:"Include Drafts"}]}function bE(e){e.registerAll(Y())}
|
|
2
|
+
export{nb,nw,Hs,$c,P_,sm,iw,F_,hE,Qa,j_,Mu,H_,cD,pE,am,ib,fE,mE,gE,dD,uD,B_,Z2,bE};
|
|
3
|
+
|
|
4
|
+
//# debugId=A865AAF439BEFE2764756E2164756E21
|
|
5
|
+
//# sourceMappingURL=studio-rzg8hnkf.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var
|
|
2
|
-
export{
|
|
1
|
+
var tS="__other__";function as(n){return n.trim().toLowerCase().replaceAll(/\s+/g,"-").replaceAll(/[^a-z\d-]/g,"")}function KE(n){let e=n.lastIndexOf(".");return e>0?n.slice(e):""}function JE(n,e,i){let t=n.trim();if(i===void 0||e==="__other__")return t;if(i.kind==="fixed"){let o=as(t);return o===""?"":`${o}${i.ext}`}return t.toLowerCase().endsWith(e.toLowerCase())?t:`${t}${e}`}function fb(n,e,i){let{choice:t,dir:o,known:l=new Set,rows:f=null,taken:u}=i,a=n.trim();if(!a)return t?.kind==="fixed"?"Enter a name.":"Enter a file name.";if(t?.kind==="fixed"&&as(a)==="")return"Enter at least one letter or number.";let s=a.replaceAll("\\","/");if(s.startsWith("/")||s.endsWith("/"))return"Enter a name, not a path that starts or ends with a slash.";if(s.split("/").includes(".."))return"A name cannot step outside the destination folder.";if(s.includes("/")&&t!==void 0&&e!=="__other__")return`Pick Other… to create a file in a subfolder of ${o==="."?"the project root":o}.`;let r=KE(s);if(e!==""&&e!=="__other__"&&r!==""&&r.toLowerCase()!==e.toLowerCase()&&l.has(r.toLowerCase()))return`You picked ${f?.find((g)=>g.value===e)?.label??e}; this name ends in ${r}.`;if(t?.kind==="locked"&&e==="__other__"){if(r!==""&&r.toLowerCase()!==t.ext.toLowerCase()&&l.has(r.toLowerCase()))return t.because}let d=JE(n,e,t);return u.has(d.toLowerCase())?`${d} already exists in ${o}/.`:""}
|
|
2
|
+
export{tS,as,KE,JE,fb};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
5
|
-
//# sourceMappingURL=studio-
|
|
4
|
+
//# debugId=9F59BB64062BA1D364756E2164756E21
|
|
5
|
+
//# sourceMappingURL=studio-s0fg2wav.js.map
|