@jxsuite/studio 10.5.0 → 10.6.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/data/locales/en/elements.json +434 -0
- package/data/webdata.json +116 -139
- package/dist/chunks/{2020-7sx2vexa.js → 2020-rqm7qrje.js} +3 -3
- package/dist/chunks/adapter-cyy8vbcx.js +4 -0
- package/dist/chunks/add-new-flow-8cgtejv2.js +4 -0
- package/dist/chunks/{cf-account-picker-ajh60k54.js → cf-account-picker-v3qd2dhw.js} +3 -3
- package/dist/chunks/cf-settings-1fnw874z.js +4 -0
- package/dist/chunks/{color-area-gbcftzh3.js → color-area-frd9y9q6.js} +2 -2
- package/dist/chunks/{color-field-85136598.js → color-field-rebpbe33.js} +3 -3
- package/dist/chunks/{color-slider-w1s3ndd8.js → color-slider-6bzmk3s7.js} +2 -2
- package/dist/chunks/color-t2bnnj8y.js +4 -0
- package/dist/chunks/{combobox-dk98wc5x.js → combobox-c49x7gf1.js} +2 -2
- package/dist/chunks/components-y8yhdd7d.js +4 -0
- package/dist/chunks/content-source-9e7qvmsf.js +4 -0
- package/dist/chunks/convert-to-repeater-pd2w4z21.js +4 -0
- package/dist/chunks/editor-mb9jzdrw.js +4 -0
- package/dist/chunks/entry-commands-at0wnx3f.js +4 -0
- package/dist/chunks/extension-sections-4z9qq0gh.js +4 -0
- package/dist/chunks/file-ops-dtdvjmza.js +4 -0
- package/dist/chunks/files-8pf70854.js +4 -0
- package/dist/chunks/format-host-fd3m2y2a.js +4 -0
- package/dist/chunks/fs-events-hrk29vcv.js +4 -0
- package/dist/chunks/grid-open-bh74v82z.js +4 -0
- package/dist/chunks/{grid-view-0v4hjspb.js → grid-view-a51mgzmq.js} +10 -10
- package/dist/chunks/{icons-j9eksgew.js → icons-qp8fn1k8.js} +2 -2
- package/dist/chunks/{iframe-entry-4zqtn3ry.js → iframe-entry-mpwe5pwk.js} +4 -4
- package/dist/chunks/{iframe-entry-2x9bn5ng.js → iframe-entry-msd43x9h.js} +4 -4
- package/dist/chunks/iframe-entry-rt8jz5t8.js +5 -0
- package/dist/chunks/{iframe-entry-54kwwhmg.js → iframe-entry-v40cr813.js} +2 -2
- package/dist/chunks/iframe-host-q0s0wwy3.js +4 -0
- package/dist/chunks/{image-bake-m8gzaan9.js → image-bake-q9ajdjsj.js} +3 -3
- package/dist/chunks/{image-editor-0afyws7c.js → image-editor-ke9std9b.js} +2 -2
- package/dist/chunks/index-57ang7ma.js +4 -0
- package/dist/chunks/index-eytr7av4.js +17 -0
- package/dist/chunks/{index-2q88g57p.js → index-x495reff.js} +3 -3
- package/dist/chunks/{javascript-5sxtr1g7.js → javascript-qe34bvaz.js} +3 -3
- package/dist/chunks/{jsonMode-m6sf47hq.js → jsonMode-m8rseh31.js} +8 -8
- package/dist/chunks/jx-validate-bbd1mary.js +4 -0
- package/dist/chunks/layers-panel-wcjtdqsa.js +4 -0
- package/dist/chunks/layers-yscpys6q.js +4 -0
- package/dist/chunks/{listbox-k5p41049.js → listbox-tktzq5xj.js} +2 -2
- package/dist/chunks/lit-html-qm5wbhqz.js +4 -0
- package/dist/chunks/media-library-2hfff88g.js +4 -0
- package/dist/chunks/media-open-4pb05cne.js +4 -0
- package/dist/chunks/media-picker-bzktmmwr.js +4 -0
- package/dist/chunks/{menu-26nez152.js → menu-xc3cbgsd.js} +2 -2
- package/dist/chunks/{monaco-binding-1s2b8snq.js → monaco-binding-7t38arh9.js} +3 -3
- package/dist/chunks/monaco-buffer-3vz94c9f.js +4 -0
- package/dist/chunks/monaco-setup-fstdew02.js +4 -0
- package/dist/chunks/notify-gbdcckrh.js +4 -0
- package/dist/chunks/parse-fpdzgk4c.js +4 -0
- package/dist/chunks/platform-9g72gdqr.js +4 -0
- package/dist/chunks/{popover-fhdnt4be.js → popover-cnmsav6b.js} +2 -2
- package/dist/chunks/publish-panel-91x1cb5d.js +4 -0
- package/dist/chunks/publish-quick-e2dmf7eg.js +4 -0
- package/dist/chunks/publish-workspace-1x8mnzrj.js +4 -0
- package/dist/chunks/quick-search-2m4y6p1x.js +4 -0
- package/dist/chunks/references-yg1g9rwx.js +4 -0
- package/dist/chunks/right-panel-7mfyhzrk.js +4 -0
- package/dist/chunks/source-control-rrc4jgp5.js +4 -0
- package/dist/chunks/{split-qh21j2b0.js → split-d15yencd.js} +2 -2
- package/dist/chunks/{studio-r5g7fx7q.js → studio-0jhhznxy.js} +6 -6
- package/dist/chunks/studio-0nb57pjg.js +7 -0
- package/dist/chunks/{studio-bpzwhn88.js → studio-0wa4wv4s.js} +4 -4
- package/dist/chunks/studio-0z8kp4xk.js +5 -0
- package/dist/chunks/{studio-jqvke4ac.js → studio-18gc5t3v.js} +4 -4
- package/dist/chunks/{studio-xh6rf05g.js → studio-1b79rpcb.js} +4 -4
- package/dist/chunks/studio-211q5j7m.js +4 -0
- package/dist/chunks/studio-213pyfxh.js +16 -0
- package/dist/chunks/studio-2b1smjvp.js +5 -0
- package/dist/chunks/{studio-dst8y8vh.js → studio-2v6tc9jp.js} +4 -4
- package/dist/chunks/studio-30j0wz99.js +5 -0
- package/dist/chunks/studio-3kmqhwtt.js +5 -0
- package/dist/chunks/studio-44drsmhw.js +5 -0
- package/dist/chunks/{studio-d5f7sskn.js → studio-495b6f2r.js} +4 -4
- package/dist/chunks/{studio-g65t6svn.js → studio-4gthb2fd.js} +4 -4
- package/dist/chunks/{studio-bmwgj8ez.js → studio-4xadhxj1.js} +4 -4
- package/dist/chunks/{studio-zav9hgb3.js → studio-52mzbxqm.js} +4 -4
- package/dist/chunks/{studio-thgexj3w.js → studio-56mmnsw8.js} +7 -7
- package/dist/chunks/studio-59hz8f4r.js +5 -0
- package/dist/chunks/{studio-bk0anq3b.js → studio-5k9mfafh.js} +3 -3
- package/dist/chunks/{studio-qarg1xf9.js → studio-5qez462c.js} +5 -5
- package/dist/chunks/studio-6tnpg0vx.js +5 -0
- package/dist/chunks/studio-6w8mt734.js +6 -0
- package/dist/chunks/studio-7hm04x5z.js +5 -0
- package/dist/chunks/studio-8atmfjjm.js +7 -0
- package/dist/chunks/{studio-69g6a0jn.js → studio-8n99z71s.js} +4 -4
- package/dist/chunks/{studio-ep1384t9.js → studio-8vmad6x2.js} +4 -4
- package/dist/chunks/{studio-6sxnqqw8.js → studio-93p5k4r4.js} +4 -4
- package/dist/chunks/{studio-hy936516.js → studio-9gb0m81w.js} +4 -4
- package/dist/chunks/{studio-ek4fb4eb.js → studio-a4ymg4vd.js} +4 -4
- package/dist/chunks/studio-anc8067x.js +5 -0
- package/dist/chunks/{studio-ketrgtph.js → studio-dbdt67kr.js} +5 -5
- package/dist/chunks/studio-dbex091t.js +5 -0
- package/dist/chunks/{studio-nngc45ct.js → studio-dj8ctxey.js} +4 -4
- package/dist/chunks/{studio-pgze9p34.js → studio-ed9bz68j.js} +5 -5
- package/dist/chunks/{studio-4ncxzw5m.js → studio-fe2d1fp5.js} +4 -4
- package/dist/chunks/{studio-m8hesdrw.js → studio-fgp4cyy3.js} +4 -4
- package/dist/chunks/{studio-151kgn69.js → studio-ft706q02.js} +4 -4
- package/dist/chunks/{studio-pv1ts08p.js → studio-g79s1dyg.js} +5 -5
- package/dist/chunks/{studio-zkkt13qd.js → studio-gahswxp4.js} +4 -4
- package/dist/chunks/{studio-x5ffyssw.js → studio-gbqc12bk.js} +4 -4
- package/dist/chunks/{studio-4jy967rj.js → studio-gxphbetb.js} +5 -5
- package/dist/chunks/studio-hdf01j7q.js +7 -0
- package/dist/chunks/studio-hf259xzd.js +48 -0
- package/dist/chunks/studio-jbva4wxw.js +5 -0
- package/dist/chunks/{studio-td3h1644.js → studio-jj9gf1qc.js} +4 -4
- package/dist/chunks/studio-jsjg3mjv.js +5 -0
- package/dist/chunks/studio-jtvb8hd7.js +5 -0
- package/dist/chunks/{studio-c72v1kwc.js → studio-kp4vzrct.js} +4 -4
- package/dist/chunks/{studio-s4k1v7dt.js → studio-kpx02gaa.js} +6 -6
- package/dist/chunks/{studio-3yr1zdp9.js → studio-kv1728ex.js} +8 -8
- package/dist/chunks/studio-m25ry0mf.js +5 -0
- package/dist/chunks/studio-mcbwmkyh.js +5 -0
- package/dist/chunks/studio-meajkr51.js +5 -0
- package/dist/chunks/studio-mkjrjpr2.js +6 -0
- package/dist/chunks/{studio-nv5eq0f7.js → studio-mr084886.js} +181 -181
- package/dist/chunks/{studio-43pynnhz.js → studio-mrb10hv3.js} +4 -4
- package/dist/chunks/{studio-7qqb7hb8.js → studio-nhpg405j.js} +4 -4
- package/dist/chunks/{studio-n271vdsg.js → studio-nsec0hxm.js} +41 -41
- package/dist/chunks/{studio-ztzf8mce.js → studio-nv0mh0p5.js} +4 -4
- package/dist/chunks/studio-pafmb06w.js +5 -0
- package/dist/chunks/{studio-4s5bka8t.js → studio-pgftd79b.js} +4 -4
- package/dist/chunks/{studio-wn2cmf9q.js → studio-pk961xgz.js} +4 -4
- package/dist/chunks/studio-pzbr7g05.js +5 -0
- package/dist/chunks/{studio-15mfah02.js → studio-qcc5hsw2.js} +6 -6
- package/dist/chunks/studio-qfq58c8n.js +5 -0
- package/dist/chunks/{studio-j3bq30yz.js → studio-qvb2jr83.js} +4 -4
- package/dist/chunks/studio-r85zw6ay.js +5 -0
- package/dist/chunks/{studio-f69wcajk.js → studio-s0kwce5w.js} +5 -5
- package/dist/chunks/studio-s6ymkf3q.js +14 -0
- package/dist/chunks/{studio-8ncm9zwx.js → studio-s7p5ccxa.js} +4 -4
- package/dist/chunks/{studio-zzgp5yka.js → studio-s9jjap3x.js} +4 -4
- package/dist/chunks/{studio-ber1dgte.js → studio-t5hde1ws.js} +4 -4
- package/dist/chunks/studio-vj9yv897.js +5 -0
- package/dist/chunks/{studio-ajfq4fmr.js → studio-wmak8xjw.js} +4 -4
- package/dist/chunks/{studio-k05g7efh.js → studio-wqsmvtqj.js} +4 -4
- package/dist/chunks/studio-x3z3rhej.js +5 -0
- package/dist/chunks/{studio-7qr8k0v2.js → studio-xb55kpmy.js} +4 -4
- package/dist/chunks/{studio-f3awr5nc.js → studio-xxtdajmv.js} +7 -7
- package/dist/chunks/{studio-1a7zshnv.js → studio-xxttcym1.js} +4 -4
- package/dist/chunks/{studio-czpmzs9r.js → studio-y2zsnzye.js} +7 -7
- package/dist/chunks/{studio-9f5vcb4w.js → studio-y3tjh2xb.js} +3 -3
- package/dist/chunks/studio-y4f1rdsj.js +5 -0
- package/dist/chunks/studio-ybkd5w8k.js +5 -0
- package/dist/chunks/{studio-cv6gnjqd.js → studio-yetr4gg1.js} +4 -4
- package/dist/chunks/{studio-ehj3csbm.js → studio-z295anhs.js} +5 -5
- package/dist/chunks/{studio-pte5w7rf.js → studio-z89e6wpg.js} +8 -8
- package/dist/chunks/{studio-4z0cdh16.js → studio-zbwr6prc.js} +3 -3
- package/dist/chunks/{studio-w3aafbpk.js → studio-zdbsv5q2.js} +3 -3
- package/dist/chunks/{studio-eq5vqn1q.js → studio-zvthj8hg.js} +4 -4
- package/dist/chunks/toast-2kn2vrn4.js +4 -0
- package/dist/chunks/{toast-host-g3r2s0kn.js → toast-host-3rxeyj3d.js} +3 -3
- package/dist/chunks/{tooltip-gtx40bjg.js → tooltip-ghkxkasp.js} +2 -2
- package/dist/chunks/{tree-a19s1c05.js → tree-vw4nc63s.js} +2 -2
- package/dist/chunks/{tsMode-3f116hth.js → tsMode-7gngmamr.js} +7 -7
- package/dist/chunks/workspace-gv0hxgsm.js +4 -0
- package/dist/chunks/workspace-home-j7e0mjy5.js +4 -0
- package/dist/chunks/{ws-client-cb49m87s.js → ws-client-vs11sxc5.js} +3 -3
- package/dist/iframe-entry.js +14 -14
- package/dist/manifest.json +84 -83
- package/dist/studio.js +80 -80
- package/package.json +12 -12
- package/src/browse/preview-style.ts +2 -1
- package/src/canvas/canvas-render.ts +6 -1
- package/src/canvas/iframe-drop.ts +84 -1
- package/src/canvas/iframe-entry.ts +9 -6
- package/src/canvas/iframe-render.ts +13 -0
- package/src/collab/collab-session.ts +2 -2
- package/src/commands/levels.ts +1 -1
- package/src/create/add-new-flow.ts +2 -1
- package/src/editor/convert-targets.ts +2 -23
- package/src/editor/slash-menu.ts +35 -17
- package/src/files/files.ts +18 -0
- package/src/format/format-choices.ts +5 -5
- package/src/format/format-host.ts +35 -3
- package/src/grid/redirects-grid.ts +4 -4
- package/src/locale/element-names.ts +131 -0
- package/src/panels/dnd.ts +3 -1
- package/src/panels/elements-panel.ts +93 -36
- package/src/panels/imports-panel.ts +3 -2
- package/src/panels/navigator-panels.ts +10 -10
- package/src/panels/panel-registry.ts +3 -3
- package/src/panels/site-panel.ts +2 -1
- package/src/panels/style-panel.ts +2 -1
- package/src/panels/styles-panel.ts +2 -2
- package/src/platforms/cloud.ts +5 -2
- package/src/services/ai-command-tools.ts +2 -1
- package/src/services/ai-project-tools.ts +18 -5
- package/src/services/jxn-language.ts +110 -0
- package/src/services/model-uri.ts +3 -0
- package/src/services/monaco-setup.ts +6 -2
- package/src/settings/contributed-section.ts +2 -1
- package/src/settings/extension-commands.ts +2 -1
- package/src/settings/general-settings.ts +2 -2
- package/src/settings/settings-document.ts +5 -5
- package/src/shell.ts +1 -1
- package/src/studio.ts +28 -11
- package/src/style/variables-view.ts +2 -2
- package/src/surfaces/panel-elements.json +466 -206
- package/src/surfaces/panel-elements.ts +61 -25
- package/src/tabs/project-config.ts +13 -13
- package/src/tabs/tab.ts +7 -2
- package/src/types.ts +11 -2
- package/src/view.ts +9 -2
- package/src/workspace/tab-workspace.ts +2 -2
- package/src/workspace/workspace-back.ts +2 -2
- package/dist/chunks/adapter-12dxr3z7.js +0 -4
- package/dist/chunks/add-new-flow-any4pw2q.js +0 -4
- package/dist/chunks/cf-settings-hbj16kh3.js +0 -4
- package/dist/chunks/color-thzpppyc.js +0 -4
- package/dist/chunks/components-a98hzqw9.js +0 -4
- package/dist/chunks/content-source-jq3fjs3w.js +0 -4
- package/dist/chunks/convert-to-repeater-g66r6qp1.js +0 -4
- package/dist/chunks/editor-rth1rzj8.js +0 -4
- package/dist/chunks/entry-commands-02j0s19w.js +0 -4
- package/dist/chunks/extension-sections-rqrs7dr0.js +0 -4
- package/dist/chunks/file-ops-6a49er4c.js +0 -4
- package/dist/chunks/files-b2p9y0yz.js +0 -4
- package/dist/chunks/format-host-7xe57k1s.js +0 -4
- package/dist/chunks/fs-events-0xsy168g.js +0 -4
- package/dist/chunks/grid-open-h3q4fjy5.js +0 -4
- package/dist/chunks/iframe-entry-m24fza30.js +0 -5
- package/dist/chunks/iframe-host-8jcmaktg.js +0 -4
- package/dist/chunks/index-7nj2375a.js +0 -4
- package/dist/chunks/jx-validate-808zgbgy.js +0 -4
- package/dist/chunks/layers-0ffdtqjn.js +0 -4
- package/dist/chunks/layers-panel-rw62wtvf.js +0 -4
- package/dist/chunks/lit-html-9bz9rcfv.js +0 -4
- package/dist/chunks/media-library-2a5hdbek.js +0 -4
- package/dist/chunks/media-open-069kzhj4.js +0 -4
- package/dist/chunks/media-picker-4p4pd28y.js +0 -4
- package/dist/chunks/monaco-buffer-m9fd2dka.js +0 -4
- package/dist/chunks/monaco-setup-e0crh3v6.js +0 -4
- package/dist/chunks/notify-re3js157.js +0 -4
- package/dist/chunks/parse-hee7ne9b.js +0 -4
- package/dist/chunks/platform-rywy3tkg.js +0 -4
- package/dist/chunks/publish-panel-czkpg8m4.js +0 -4
- package/dist/chunks/publish-quick-b9wbhqj6.js +0 -4
- package/dist/chunks/publish-workspace-yy6d23b7.js +0 -4
- package/dist/chunks/quick-search-tp7pjnmv.js +0 -4
- package/dist/chunks/references-wd2yj8s1.js +0 -4
- package/dist/chunks/right-panel-x971k0zc.js +0 -4
- package/dist/chunks/source-control-k4p00hpe.js +0 -4
- package/dist/chunks/studio-1d8m5s38.js +0 -16
- package/dist/chunks/studio-35pmfjtx.js +0 -5
- package/dist/chunks/studio-44xqe0b7.js +0 -4
- package/dist/chunks/studio-48yzqzqr.js +0 -5
- package/dist/chunks/studio-5rq3e4q5.js +0 -5
- package/dist/chunks/studio-6hcfm9q3.js +0 -5
- package/dist/chunks/studio-6mf31e16.js +0 -5
- package/dist/chunks/studio-8w5pa88p.js +0 -7
- package/dist/chunks/studio-9c6cbq2c.js +0 -4
- package/dist/chunks/studio-aaw7wxv8.js +0 -5
- package/dist/chunks/studio-afx9brsc.js +0 -5
- package/dist/chunks/studio-dmgh2rrj.js +0 -5
- package/dist/chunks/studio-erjccagy.js +0 -5
- package/dist/chunks/studio-ex1644g2.js +0 -5
- package/dist/chunks/studio-gw83z798.js +0 -7
- package/dist/chunks/studio-j52ks8q7.js +0 -5
- package/dist/chunks/studio-kefs4sz4.js +0 -5
- package/dist/chunks/studio-m3jrjfhy.js +0 -14
- package/dist/chunks/studio-n4pnf0sw.js +0 -5
- package/dist/chunks/studio-ncwx602y.js +0 -5
- package/dist/chunks/studio-nzp0sqjg.js +0 -5
- package/dist/chunks/studio-ph17an19.js +0 -5
- package/dist/chunks/studio-q509sqt8.js +0 -5
- package/dist/chunks/studio-s49y6m5b.js +0 -5
- package/dist/chunks/studio-t46rt6gx.js +0 -5
- package/dist/chunks/studio-veh91hjv.js +0 -5
- package/dist/chunks/studio-vswmz40d.js +0 -6
- package/dist/chunks/studio-w4mfaaam.js +0 -5
- package/dist/chunks/studio-x5py815g.js +0 -5
- package/dist/chunks/studio-z6s56dzz.js +0 -5
- package/dist/chunks/studio-ze1sm147.js +0 -7
- package/dist/chunks/studio-zn7ysyzb.js +0 -5
- package/dist/chunks/toast-w11qpkyz.js +0 -4
- package/dist/chunks/workspace-home-61n1jz3q.js +0 -4
- package/dist/chunks/workspace-sheek6zw.js +0 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{X}from"./studio-9c6cbq2c.js";import{p}from"./studio-xh6rf05g.js";import{w}from"./studio-bk0anq3b.js";import{hh,hs,pR}from"./studio-wn2cmf9q.js";import{Jt,Ut}from"./studio-m3jrjfhy.js";import{sn,dt,Fn}from"./studio-cv6gnjqd.js";import{g,h,Qd}from"./studio-s49y6m5b.js";import{Kd}from"./studio-48yzqzqr.js";import{Jc,La,oR,VA,sR,Hx,Qs,Bx,zA,UA,Vx,Wx,cy,no,zd,Yc,uh,gl,zx}from"./studio-td3h1644.js";import{gO,sx,ax,Xu}from"./studio-j3bq30yz.js";import{PT,Ku}from"./studio-4ncxzw5m.js";import{Vt}from"./studio-w3aafbpk.js";import{N$,D$,O$,A$,Zu,oC,sC,aC,lC}from"./studio-g65t6svn.js";import{xp}from"./studio-vswmz40d.js";import{ze,$n,yt,E,I}from"./studio-1a7zshnv.js";import{Me}from"./studio-bmwgj8ez.js";import{b}from"./studio-9f5vcb4w.js";import{n,S}from"./studio-erjccagy.js";import{ce}from"./studio-7qqb7hb8.js";var R=[{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"}],f0=R.map((e)=>e.key);function re(e){return f0.some((t)=>t===e)}function j(e){return R.find((t)=>t.key===e)?.label??"All media"}var U=[{key:"newest",label:"Newest"},{key:"name",label:"Name"},{key:"size",label:"Size"}],Re=U.map((e)=>e.key);function ne(e){return Re.some((t)=>t===e)}function W(e,t,i){switch(t){case"all":return!0;case"unused":return i!==null&&i.has(e.file);default:return e.kind===t}}function A(e,t){let i=t.trim().toLowerCase();return i===""||e.name.toLowerCase().includes(i)}function q(e,t){return e.filter((a)=>W(a,t.filter,t.unused)&&A(a,t.query)).toSorted((a,r)=>Ae(t.sort,a,r)||a.file.localeCompare(r.file))}function Ae(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 Ie=132,ae=12;function le(e){return Math.max(1,Math.floor((e+ae)/(Ie+ae)))}function se(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 de={$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, Rename, Duplicate 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:"div",attributes:{part:"edit-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/editable"},cases:{yes:{tagName:"jx-button",attributes:{part:"edit-image"},$props:{size:"sm",variant:"secondary"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/editImage"},value:[]}],description:"Withheld, not disabled, for a file the editor cannot write: a refused format is not offered rather than offered and then refused (studio.md §9.5)."},children:[{tagName:"span",textContent:"Edit image"}]},no:{tagName:"span",attributes:{hidden:!0}}}},{tagName:"jx-button",attributes:{part:"rename"},$props:{size:"sm",variant:"secondary"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/rename"},value:[]}]},children:[{tagName:"span",textContent:"Rename"}]},{tagName:"div",attributes:{part:"duplicate-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/duplicable"},cases:{yes:{tagName:"jx-button",attributes:{part:"duplicate"},$props:{size:"sm",variant:"secondary"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/duplicate"},value:[]}],description:"Withheld, not disabled, on a backend that cannot read a file's raw bytes: a copy read as text would be a broken file (studio.md §9.3)."},children:[{tagName:"span",textContent:"Duplicate"}]},no:{tagName:"span",attributes:{hidden:!0}}}},{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>."}]}}}]}]};E("media-library",de);function Oe(){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:"",editable:"no",duplicable:"no",selectedFile:"",sort:"",sortOptions:[],tiles:[],title:"",titleId:"",uploadAccept:"",uploadHint:"",usageFiles:[],usageHeadline:"",usageState:"hidden"}}function pe(e,t){Object.assign(e,t),e.hasUsageFiles=t.usageFiles.length>0}function Ke(e){let t=n(e)?void 0:e.attributes?.part;return n(t)?t:""}function _e(e){let t=e?.$map,i=S(t)&&"item"in t?t.item:void 0;return S(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,d=b({...Oe(),...c,hasUsageFiles:!1});pe(d,t);let f=null,y=!1,M=I("media-library",d,e,{onNodeCreated:(u,s,L,Ee)=>{if(y||!(u instanceof HTMLElement))return;let H=Ke(L);if(H==="tile"){let ie=_e(Ee);if(ie!==null)r(u,ie)}else if(H==="grid")o(u);else if(u instanceof HTMLInputElement&&H==="upload-input")l(u,"upload");else if(u instanceof HTMLInputElement&&H==="replace-input")l(u,"replace")}}).then((u)=>{if(y)u.dispose();else f=u;return u.root});return{attached:()=>{if(y)return!1;let u=f?.root;return u===void 0?!0:u instanceof HTMLElement&&e.contains(u)},dispose(){y=!0,f?.dispose(),f=null},ready:M,update:(u)=>pe(d,u)}}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"}}]};E("media-pick-dialog",ue);var B="media-picker";function We(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(ze,yt("dialog",B)),e.layer.append(t);let i=!1,a=()=>{if(i)return;i=!0,e.closed()},r=()=>i,o=b({...e.view,closed:a,confirm:e.confirm}),l=null,c=I("media-pick-dialog",o,t,{onNodeCreated:(d,f,y)=>{if(!r()&&d instanceof HTMLElement&&We(y)==="library-slot")e.body(d)}}).then(async(d)=>{l=d;let f=d.root;if(r())return d.dispose(),f;if(await sn(f),!r())Jt(f);return f});return{close(){let d=l?.root;if(d instanceof HTMLElement)Ut(d);l?.dispose(),l=null,t.remove(),a()},host:t,ready:c,update(d){Object.assign(o,d)}}}var kF="media-home",ve={audio:"play",document:"file-text",font:"text-aa",image:"image",video:"play"},qe={audio:"Audio",document:"Document",font:"Font",image:"Image",video:"Video"},m={filter:"all",query:"",sort:"newest",selected:null},C=null,F=null,K=0,z=0,O=!1,Y=0;function J(){F=null,O=!1,K=0,z=0,Y+=1}function Ve(){return[...N].some((e)=>!e.disposed&&e.choice.filter==="unused")}async function Be(e){if(O||F!==null||!hh())return;let t=Y;O=!0,K=0,z=e.length;let i=new Set;for(let a of e){let r=await Xu(a.file);if(t!==Y)return;if(!Ve()){J();return}if(r.status==="ready"&&r.result.files.length===0)i.add(a.file);K+=1,x()}F=i,O=!1,x()}var N=new Set,k=new Map,Q=new Set,D=null;function we(){if(D!==null)return;let e=()=>{J(),x()},t=PT(e),i=pR(e);D=()=>{t(),i()}}function Ge(){if(N.size===0&&D)D(),D=null}function v(e){if(!e.disposed){if(e.handle?.update(ee(e)),e.onSelect?.(),Ye(e),e.focusOwed)queueMicrotask(()=>He(e));xe(e)}}function Ye(e){let t=e.reveal,i=t===null?void 0:e.tiles.get(t);if(i?.isConnected){if(e.reveal=null,i.scrollIntoView({block:"nearest"}),e.revealFocus)e.revealFocus=!1,i.focus()}}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 $e(e){return[...e].find((t)=>t.isConnected)??null}function x(){for(let e of N)v(e)}function Z(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(),N.delete(e),Ge()}function ke(e){let t=Ku(),i=t===null?null:e.images?t.filter((r)=>r.isImage):t;return{files:(i??[]).map((r)=>{let o=Yc(r.file);return{bytes:o?.bytes??null,file:r.file,kind:r.kind,modified:o?.modified??null,name:r.name}}),listed:i}}function Je(e){return R.filter((t)=>(t.key!=="unused"||hh())&&(!e.images||t.key==="image"||t.key==="unused"))}function Cb(e){let{filter:t,query:i,selected:a}=e.choice;if(a===null)return null;let r=Ku()?.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 W(o,t,F)&&A(o,i)?r:null}function Qe(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 ${j(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 ${j(i).toLowerCase()}.`,emptyTitle:`No ${j(i).toLowerCase()}`}}function ee(e){let{choice:t}=e,{files:i,listed:a}=ke(e),r=oe(i,F),o=Je(e);if(!o.some((s)=>s.key===t.filter))t.filter=o[0]?.key??"all";let l=q(i,{filter:t.filter,query:t.query,sort:t.sort,unused:F}),c=Ku();if(t.filter==="unused"&&c!==null)Be(c);let d="listed";if(a===null)d="loading";else if(t.filter==="unused"&&F===null)d="counting";else if(i.length===0||l.length===0)d=i.length===0?"empty":"nomatch";let f=Cb(e),y=l.some((s)=>s.file===t.selected)?t.selected:l[0]?.file??null,M=l.map((s)=>{let L=s.kind==="image";return{caption:zx(Yc(s.file))||qe[s.kind],file:s.file,glyph:ve[s.kind],key:s.file,name:s.name,selected:s.file===t.selected?"true":"false",tabindex:s.file===y?"0":"-1",thumbSrc:L&&e.visible.has(s.file)?no(s.file):"",thumbState:L?e.visible.has(s.file)?"image":"pending":"glyph"}}),u=e.images&&t.filter==="image"?"Images":j(t.filter);return{countingLabel:z>0?`Counting references… ${K} of ${z}`:"Counting references…",dropActive:e.dropActive?"true":"false",filters:o.map((s)=>{let L=r[s.key];return{count:L===null?"":String(L),key:s.key,label:e.images&&s.key==="image"?"All images":s.label,pressed:s.key===t.filter?"true":"false"}}),gridState:d,mode:e.mode,query:t.query,region:e.region,sort:t.sort,sortOptions:U.map((s)=>({label:s.label,value:s.key})),tiles:M,title:u,titleId:`media-library-title-${e.region.replaceAll(/[^\w-]/g,"-")}`,uploadAccept:e.images?"image/*":Jc(),uploadHint:`Upload into ${e.uploadDir}/`,...Qe(e,i.length),...Xe(e,f)}}function Xe(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:"",editable:"no",duplicable:"no",selectedFile:"",usageFiles:[],usageHeadline:"",usageState:"hidden"};let i=Yc(t.file),a=ax(t.file);if(!zd(t.file))uh(t.file).then(x);if(a===null||a.status==="pending")Xu(t.file).then(x);let r=N$(t.file),o=r==="image"||r==="video"||r==="audio"||r==="font"?r:"glyph",l=o==="font"?O$(t.file):{fontFace:"",specimen:"",specimenFamily:""};return{detailFacts:D$(t.file,i),detailHint:"",detailName:t.name,detailRef:t.ref,detailState:"shown",previewFontFace:l.fontFace,previewGlyph:ve[t.kind],previewKind:o,previewSpecimen:l.specimen,previewSpecimenFamily:l.specimenFamily,previewSrc:o==="glyph"?"":no(t.file),replaceAccept:zA(t.file),editable:oC(t.file)?"yes":"no",duplicable:sC()?"yes":"no",selectedFile:t.file,...A$(a)}}var me=null,ge=null;function Se(){return me??=(ce("b2p9y0yz"),import("./files-b2p9y0yz.js")),me}function Fe(){return ge??=(ce("6a49er4c"),import("./file-ops-6a49er4c.js")),ge}function te(e){try{e.showPicker()}catch{e.focus()}}function T(e,t){e.choice.selected=t,v(e)}async function he(e,t){let i=await Qs([...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,T(e,a.path)}async function uD(e){let t=e.split("/").pop()??e,{confirmFileDelete:i}=await Fe();if(!await i({name:t,path:e}))return!1;let{markLocalMutation:a}=await (ce("0xsy168g"),import("./fs-events-0xsy168g.js"));try{a(e),await p().deleteFile(e)}catch(l){return w.error(`Could not delete ${t}.`,{detail:X(l),path:e,source:"Media"}),!1}if(Kd([e]),hs(),g.tabs.has(e))Qd(e);for(let l of N)if(l.choice.selected===e)l.choice.selected=null;if(m.selected===e)m.selected=null;let r=cy(e),o=await Ze(r,a);return await Hx(o?cy(r):r),w.success(`Deleted ${t}`),!0}async function Ze(e,t){if(!VA(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}}async function hD(e){if(aC(e,"renamed"))return null;let t=Wx(e),i=cy(e),{commitRename:a,listRenameSiblings:r,notifyMoveOutcome:o,renameStatus:l}=await Se(),c=await r(e,"Media");if(c===null)return null;let{renamePromptMessage:d}=await Fe(),f=await d(e),y=await Fn("Rename",{confirmLabel:"Rename",select:"stem",validate:(s)=>UA(e,s,c),value:t,...f!==void 0&&{message:f}});if(!y||y===t)return null;let M=sR(i,y),u=Yc(e);try{let s=await a(e,M);if(m.selected===e)Le(M);if(await Hx(i),u?.width!=null&&u.height!=null)gl(M,u.width,u.height);return o(l(y,s),s,M),M}catch(s){return w.error(`Could not rename ${t}.`,{detail:X(s),path:e,source:"Media"}),null}}async function pD(e){if(aC(e,"duplicated"))return null;let t=await Bx(e);if(t===null)return null;return Le(t.path),x(),t.path}function Le(e){if(m.selected=e,!A({name:Wx(e)},m.query))m.query="";for(let{mount:t}of k.values())t.reveal=e,t.revealFocus=!0}function Ne(e){return{activate:(t)=>{T(e,t),ye(e,t)},activateSelected:()=>{let{selected:t}=e.choice;if(t!==null)ye(e,t)},contextMenu:(t,i,a)=>et(e,t,i,a),copyRef:()=>{let t=Cb(e);if(t)Te(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)T(e,t)},gridHost:(t)=>{e.grid=t},inputHost:(t,i)=>{e.inputs[i].add(t),xe(e);let a=C;if(e.mode==="manage"&&a?.role===i&&(i==="upload"||a.file===e.choice.selected))C=null,te(t)},key:(t,i)=>tt(e,t,i),measure:(t,i,a)=>{if(gl(t,i,a))x();else if(!zd(t))uh(t).then(x)},openDocument:(t)=>{Se().then(({openFileInTab:i})=>i(t))},openViewer:()=>{let{selected:t}=e.choice;if(t!==null)Zu(t)},editImage:()=>{let{selected:t}=e.choice;if(t!==null)lC(t)},remove:()=>{let{selected:t}=e.choice;if(t!==null)uD(t)},rename:()=>{let{selected:t}=e.choice;if(t!==null)hD(t)},duplicate:()=>{let{selected:t}=e.choice;if(t!==null)pD(t)},replace:(t)=>{let[i]=t.files??[];t.value="";let{selected:a}=e.choice;if(i&&a!==null&&gO(a))Vx(a,i).then((r)=>{if(r)sx(a);x()})},reset:()=>{e.choice.filter=e.images?"image":"all",e.choice.query="",v(e)},select:(t)=>T(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),je.set(t,i),e.observer.observe(t)},upload:(t)=>{let i=[...t.files??[]];if(t.value="",i.length>0)he(e,i)}}}function Te(e){if("clipboard"in navigator)navigator.clipboard.writeText(e.ref)}var P=null;function et(e,t,i,a){T(e,t);let r=Cb(e);if(!r)return;P?.close();let o=(l,c,d,f={})=>({destructive:!1,disabled:!1,dividerAbove:!1,id:l,run:d,title:c,...f});P=Vt({label:`${r.name} actions`,onClosed:(l)=>{if(P===l)P=null},origin:{x:i,y:a},region:"media-tile",rows:[o("open","Open in Viewer",()=>Zu(t)),...oC(t)?[o("edit","Edit Image",()=>lC(t))]:[],o("copy-url","Copy Site URL",()=>Te(r)),o("rename","Rename…",()=>{hD(t)},{dividerAbove:!0}),...sC()?[o("duplicate","Duplicate",()=>{pD(t)})]:[],o("replace","Replace…",()=>tF(t)),o("delete","Delete",()=>{uD(t)},{destructive:!0,dividerAbove:!0})]})}function ye(e,t){if(e.mode==="pick"){let i=Cb(e);if(i)e.onPick?.(i);return}Zu(t)}function tt(e,t,i){let{files:a}=ke(e),r=q(a,{filter:e.choice.filter,query:e.choice.query,sort:e.choice.sort,unused:F}),o=r.findIndex((f)=>f.file===e.choice.selected),l=e.grid?le(Me(e.grid).width):1,c=o===-1?r.length>0?0:null:se(o,t,l,r.length,i),d=c===null?void 0:r[c];if(!d)return;T(e,d.file),e.tiles.get(d.file)?.focus()}var je=new WeakMap;function De(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:xp((c)=>{let d=je.get(c);if(d!==void 0&&!l.visible.has(d))l.visible.add(d),it(l)}),onPick:null,onSelect:null,paneId:a,reveal:null,revealFocus:!1,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 m0(e,t){let i=k.get(e);return i!==void 0&&i.tabId===t.id&&i.wrap.isConnected&&i.mount.handle!==null&&i.mount.handle.attached()}function Cw(e){let t=k.get(e);if(!t)return;Z(t.mount),k.delete(e)}function oT(e,t){let{paneId:i,wrap:a}=e;if(m0(i,t))return;Cw(i);let r=De("manage",m,$n(i,"media-library"),i,!1,La);if(N.add(r),we(),r.handle=V(a,ee(r),Ne(r),{clear:!0}),k.set(i,{mount:r,tabId:t.id,wrap:a}),Q.delete(i))Ce(r)}async function Ce(e){await e.handle?.ready,He(e,!0)}function He(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 sT(e){let t=k.get(e);if(t?.wrap.isConnected&&t.mount.handle?.attached()===!0){Ce(t.mount);return}Q.add(e)}function eF(e){if(e.filter!==void 0)m.filter=e.filter;if(e.query!==void 0)m.query=e.query;if(e.select!==void 0){if(m.selected=e.select,m.filter!=="all")m.filter="all";m.query=""}x()}function EF(){let e=[...k.values()].map((t)=>$e(t.mount.inputs.upload)).find((t)=>t!==null)??null;if(e){te(e);return}C={file:null,role:"upload"}}function tF(e){eF({select:e});let t=null;for(let i of k.values())if(i.mount.choice.selected===e)t??=$e(i.mount.inputs.replace);if(t){te(t);return}C={file:e,role:"replace"}}var _=null;function be(e){let t=Cb(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 g0(){let e=_;if(_=null,e)Z(e.mount),e.dialog.close()}function TF(e){g0();let t={filter:e.images?"image":"all",query:"",selected:null,sort:"newest"},i=De("pick",t,`${yt("dialog",B)}/library`,null,e.images,oR(h.value?.documentPath??null)),a=(o)=>{g0(),e.onPick(o.ref)};i.onPick=a,N.add(i),we();let r=fe({body:(o)=>{i.handle=V(o,ee(i),Ne(i),{clear:!1})},closed:()=>{if(_?.mount===i)g0();else Z(i)},confirm:()=>{let o=Cb(i);if(o)a(o)},layer:dt("dialog"),view:be(i)});i.onSelect=()=>r.update(be(i)),_={dialog:r,mount:i}}function aT(){g0();for(let e of k.keys())Cw(e);m.filter="all",m.query="",m.selected=null,m.sort="newest",C=null,Q.clear(),J()}
|
|
2
|
-
export{
|
|
1
|
+
import{Z}from"./studio-mkjrjpr2.js";import{p}from"./studio-1b79rpcb.js";import{w}from"./studio-5k9mfafh.js";import{mh,ps,_R}from"./studio-pk961xgz.js";import{Gt,Ut}from"./studio-s6ymkf3q.js";import{an,dt,Fn}from"./studio-yetr4gg1.js";import{g,h,tu}from"./studio-ybkd5w8k.js";import{Gd}from"./studio-44drsmhw.js";import{Zc,Ia,fR,tP,mR,Ux,ea,qx,iP,rP,Jx,Kx,py,io,qd,Xc,fh,yl,Gx}from"./studio-jj9gf1qc.js";import{TO,ux,hx,eh}from"./studio-qvb2jr83.js";import{zT,Gu}from"./studio-fe2d1fp5.js";import{Vt}from"./studio-zdbsv5q2.js";import{B$,V$,W$,z$,Qu,pC,fC,mC,gC}from"./studio-4gthb2fd.js";import{Cp}from"./studio-6w8mt734.js";import{ze,$n,yt,E,I}from"./studio-xxttcym1.js";import{Me}from"./studio-4xadhxj1.js";import{b}from"./studio-y3tjh2xb.js";import{n,S}from"./studio-0z8kp4xk.js";import{ce}from"./studio-nhpg405j.js";var R=[{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"}],_S=R.map((e)=>e.key);function re(e){return _S.some((t)=>t===e)}function j(e){return R.find((t)=>t.key===e)?.label??"All media"}var U=[{key:"newest",label:"Newest"},{key:"name",label:"Name"},{key:"size",label:"Size"}],Re=U.map((e)=>e.key);function ne(e){return Re.some((t)=>t===e)}function W(e,t,i){switch(t){case"all":return!0;case"unused":return i!==null&&i.has(e.file);default:return e.kind===t}}function A(e,t){let i=t.trim().toLowerCase();return i===""||e.name.toLowerCase().includes(i)}function q(e,t){return e.filter((a)=>W(a,t.filter,t.unused)&&A(a,t.query)).toSorted((a,r)=>Ae(t.sort,a,r)||a.file.localeCompare(r.file))}function Ae(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 Ie=132,ae=12;function le(e){return Math.max(1,Math.floor((e+ae)/(Ie+ae)))}function se(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 de={$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, Rename, Duplicate 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:"div",attributes:{part:"edit-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/editable"},cases:{yes:{tagName:"jx-button",attributes:{part:"edit-image"},$props:{size:"sm",variant:"secondary"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/editImage"},value:[]}],description:"Withheld, not disabled, for a file the editor cannot write: a refused format is not offered rather than offered and then refused (studio.md §9.5)."},children:[{tagName:"span",textContent:"Edit image"}]},no:{tagName:"span",attributes:{hidden:!0}}}},{tagName:"jx-button",attributes:{part:"rename"},$props:{size:"sm",variant:"secondary"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/rename"},value:[]}]},children:[{tagName:"span",textContent:"Rename"}]},{tagName:"div",attributes:{part:"duplicate-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/duplicable"},cases:{yes:{tagName:"jx-button",attributes:{part:"duplicate"},$props:{size:"sm",variant:"secondary"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/duplicate"},value:[]}],description:"Withheld, not disabled, on a backend that cannot read a file's raw bytes: a copy read as text would be a broken file (studio.md §9.3)."},children:[{tagName:"span",textContent:"Duplicate"}]},no:{tagName:"span",attributes:{hidden:!0}}}},{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>."}]}}}]}]};E("media-library",de);function Oe(){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:"",editable:"no",duplicable:"no",selectedFile:"",sort:"",sortOptions:[],tiles:[],title:"",titleId:"",uploadAccept:"",uploadHint:"",usageFiles:[],usageHeadline:"",usageState:"hidden"}}function pe(e,t){Object.assign(e,t),e.hasUsageFiles=t.usageFiles.length>0}function Ke(e){let t=n(e)?void 0:e.attributes?.part;return n(t)?t:""}function _e(e){let t=e?.$map,i=S(t)&&"item"in t?t.item:void 0;return S(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,d=b({...Oe(),...c,hasUsageFiles:!1});pe(d,t);let f=null,y=!1,M=I("media-library",d,e,{onNodeCreated:(u,s,L,Ee)=>{if(y||!(u instanceof HTMLElement))return;let H=Ke(L);if(H==="tile"){let ie=_e(Ee);if(ie!==null)r(u,ie)}else if(H==="grid")o(u);else if(u instanceof HTMLInputElement&&H==="upload-input")l(u,"upload");else if(u instanceof HTMLInputElement&&H==="replace-input")l(u,"replace")}}).then((u)=>{if(y)u.dispose();else f=u;return u.root});return{attached:()=>{if(y)return!1;let u=f?.root;return u===void 0?!0:u instanceof HTMLElement&&e.contains(u)},dispose(){y=!0,f?.dispose(),f=null},ready:M,update:(u)=>pe(d,u)}}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"}}]};E("media-pick-dialog",ue);var B="media-picker";function We(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(ze,yt("dialog",B)),e.layer.append(t);let i=!1,a=()=>{if(i)return;i=!0,e.closed()},r=()=>i,o=b({...e.view,closed:a,confirm:e.confirm}),l=null,c=I("media-pick-dialog",o,t,{onNodeCreated:(d,f,y)=>{if(!r()&&d instanceof HTMLElement&&We(y)==="library-slot")e.body(d)}}).then(async(d)=>{l=d;let f=d.root;if(r())return d.dispose(),f;if(await an(f),!r())Gt(f);return f});return{close(){let d=l?.root;if(d instanceof HTMLElement)Ut(d);l?.dispose(),l=null,t.remove(),a()},host:t,ready:c,update(d){Object.assign(o,d)}}}var MF="media-home",ve={audio:"play",document:"file-text",font:"text-aa",image:"image",video:"play"},qe={audio:"Audio",document:"Document",font:"Font",image:"Image",video:"Video"},m={filter:"all",query:"",sort:"newest",selected:null},C=null,F=null,K=0,z=0,O=!1,Y=0;function J(){F=null,O=!1,K=0,z=0,Y+=1}function Ve(){return[...N].some((e)=>!e.disposed&&e.choice.filter==="unused")}async function Be(e){if(O||F!==null||!mh())return;let t=Y;O=!0,K=0,z=e.length;let i=new Set;for(let a of e){let r=await eh(a.file);if(t!==Y)return;if(!Ve()){J();return}if(r.status==="ready"&&r.result.files.length===0)i.add(a.file);K+=1,x()}F=i,O=!1,x()}var N=new Set,k=new Map,Q=new Set,D=null;function we(){if(D!==null)return;let e=()=>{J(),x()},t=zT(e),i=_R(e);D=()=>{t(),i()}}function Ge(){if(N.size===0&&D)D(),D=null}function v(e){if(!e.disposed){if(e.handle?.update(ee(e)),e.onSelect?.(),Ye(e),e.focusOwed)queueMicrotask(()=>He(e));xe(e)}}function Ye(e){let t=e.reveal,i=t===null?void 0:e.tiles.get(t);if(i?.isConnected){if(e.reveal=null,i.scrollIntoView({block:"nearest"}),e.revealFocus)e.revealFocus=!1,i.focus()}}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 $e(e){return[...e].find((t)=>t.isConnected)??null}function x(){for(let e of N)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(),N.delete(e),Ge()}function ke(e){let t=Gu(),i=t===null?null:e.images?t.filter((r)=>r.isImage):t;return{files:(i??[]).map((r)=>{let o=Xc(r.file);return{bytes:o?.bytes??null,file:r.file,kind:r.kind,modified:o?.modified??null,name:r.name}}),listed:i}}function Je(e){return R.filter((t)=>(t.key!=="unused"||mh())&&(!e.images||t.key==="image"||t.key==="unused"))}function $b(e){let{filter:t,query:i,selected:a}=e.choice;if(a===null)return null;let r=Gu()?.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 W(o,t,F)&&A(o,i)?r:null}function Qe(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 ${j(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 ${j(i).toLowerCase()}.`,emptyTitle:`No ${j(i).toLowerCase()}`}}function ee(e){let{choice:t}=e,{files:i,listed:a}=ke(e),r=oe(i,F),o=Je(e);if(!o.some((s)=>s.key===t.filter))t.filter=o[0]?.key??"all";let l=q(i,{filter:t.filter,query:t.query,sort:t.sort,unused:F}),c=Gu();if(t.filter==="unused"&&c!==null)Be(c);let d="listed";if(a===null)d="loading";else if(t.filter==="unused"&&F===null)d="counting";else if(i.length===0||l.length===0)d=i.length===0?"empty":"nomatch";let f=$b(e),y=l.some((s)=>s.file===t.selected)?t.selected:l[0]?.file??null,M=l.map((s)=>{let L=s.kind==="image";return{caption:Gx(Xc(s.file))||qe[s.kind],file:s.file,glyph:ve[s.kind],key:s.file,name:s.name,selected:s.file===t.selected?"true":"false",tabindex:s.file===y?"0":"-1",thumbSrc:L&&e.visible.has(s.file)?io(s.file):"",thumbState:L?e.visible.has(s.file)?"image":"pending":"glyph"}}),u=e.images&&t.filter==="image"?"Images":j(t.filter);return{countingLabel:z>0?`Counting references… ${K} of ${z}`:"Counting references…",dropActive:e.dropActive?"true":"false",filters:o.map((s)=>{let L=r[s.key];return{count:L===null?"":String(L),key:s.key,label:e.images&&s.key==="image"?"All images":s.label,pressed:s.key===t.filter?"true":"false"}}),gridState:d,mode:e.mode,query:t.query,region:e.region,sort:t.sort,sortOptions:U.map((s)=>({label:s.label,value:s.key})),tiles:M,title:u,titleId:`media-library-title-${e.region.replaceAll(/[^\w-]/g,"-")}`,uploadAccept:e.images?"image/*":Zc(),uploadHint:`Upload into ${e.uploadDir}/`,...Qe(e,i.length),...Xe(e,f)}}function Xe(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:"",editable:"no",duplicable:"no",selectedFile:"",usageFiles:[],usageHeadline:"",usageState:"hidden"};let i=Xc(t.file),a=hx(t.file);if(!qd(t.file))fh(t.file).then(x);if(a===null||a.status==="pending")eh(t.file).then(x);let r=B$(t.file),o=r==="image"||r==="video"||r==="audio"||r==="font"?r:"glyph",l=o==="font"?W$(t.file):{fontFace:"",specimen:"",specimenFamily:""};return{detailFacts:V$(t.file,i),detailHint:"",detailName:t.name,detailRef:t.ref,detailState:"shown",previewFontFace:l.fontFace,previewGlyph:ve[t.kind],previewKind:o,previewSpecimen:l.specimen,previewSpecimenFamily:l.specimenFamily,previewSrc:o==="glyph"?"":io(t.file),replaceAccept:iP(t.file),editable:pC(t.file)?"yes":"no",duplicable:fC()?"yes":"no",selectedFile:t.file,...z$(a)}}var me=null,ge=null;function Se(){return me??=(ce("8pf70854"),import("./files-8pf70854.js")),me}function Fe(){return ge??=(ce("dtdvjmza"),import("./file-ops-dtdvjmza.js")),ge}function te(e){try{e.showPicker()}catch{e.focus()}}function T(e,t){e.choice.selected=t,v(e)}async function he(e,t){let i=await ea([...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,T(e,a.path)}async function _D(e){let t=e.split("/").pop()??e,{confirmFileDelete:i}=await Fe();if(!await i({name:t,path:e}))return!1;let{markLocalMutation:a}=await (ce("hrk29vcv"),import("./fs-events-hrk29vcv.js"));try{a(e),await p().deleteFile(e)}catch(l){return w.error(`Could not delete ${t}.`,{detail:Z(l),path:e,source:"Media"}),!1}if(Gd([e]),ps(),g.tabs.has(e))tu(e);for(let l of N)if(l.choice.selected===e)l.choice.selected=null;if(m.selected===e)m.selected=null;let r=py(e),o=await Ze(r,a);return await Ux(o?py(r):r),w.success(`Deleted ${t}`),!0}async function Ze(e,t){if(!tP(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}}async function SD(e){if(mC(e,"renamed"))return null;let t=Kx(e),i=py(e),{commitRename:a,listRenameSiblings:r,notifyMoveOutcome:o,renameStatus:l}=await Se(),c=await r(e,"Media");if(c===null)return null;let{renamePromptMessage:d}=await Fe(),f=await d(e),y=await Fn("Rename",{confirmLabel:"Rename",select:"stem",validate:(s)=>rP(e,s,c),value:t,...f!==void 0&&{message:f}});if(!y||y===t)return null;let M=mR(i,y),u=Xc(e);try{let s=await a(e,M);if(m.selected===e)Le(M);if(await Ux(i),u?.width!=null&&u.height!=null)yl(M,u.width,u.height);return o(l(y,s),s,M),M}catch(s){return w.error(`Could not rename ${t}.`,{detail:Z(s),path:e,source:"Media"}),null}}async function CD(e){if(mC(e,"duplicated"))return null;let t=await qx(e);if(t===null)return null;return Le(t.path),x(),t.path}function Le(e){if(m.selected=e,!A({name:Kx(e)},m.query))m.query="";for(let{mount:t}of k.values())t.reveal=e,t.revealFocus=!0}function Ne(e){return{activate:(t)=>{T(e,t),ye(e,t)},activateSelected:()=>{let{selected:t}=e.choice;if(t!==null)ye(e,t)},contextMenu:(t,i,a)=>et(e,t,i,a),copyRef:()=>{let t=$b(e);if(t)Te(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)T(e,t)},gridHost:(t)=>{e.grid=t},inputHost:(t,i)=>{e.inputs[i].add(t),xe(e);let a=C;if(e.mode==="manage"&&a?.role===i&&(i==="upload"||a.file===e.choice.selected))C=null,te(t)},key:(t,i)=>tt(e,t,i),measure:(t,i,a)=>{if(yl(t,i,a))x();else if(!qd(t))fh(t).then(x)},openDocument:(t)=>{Se().then(({openFileInTab:i})=>i(t))},openViewer:()=>{let{selected:t}=e.choice;if(t!==null)Qu(t)},editImage:()=>{let{selected:t}=e.choice;if(t!==null)gC(t)},remove:()=>{let{selected:t}=e.choice;if(t!==null)_D(t)},rename:()=>{let{selected:t}=e.choice;if(t!==null)SD(t)},duplicate:()=>{let{selected:t}=e.choice;if(t!==null)CD(t)},replace:(t)=>{let[i]=t.files??[];t.value="";let{selected:a}=e.choice;if(i&&a!==null&&TO(a))Jx(a,i).then((r)=>{if(r)ux(a);x()})},reset:()=>{e.choice.filter=e.images?"image":"all",e.choice.query="",v(e)},select:(t)=>T(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),je.set(t,i),e.observer.observe(t)},upload:(t)=>{let i=[...t.files??[]];if(t.value="",i.length>0)he(e,i)}}}function Te(e){if("clipboard"in navigator)navigator.clipboard.writeText(e.ref)}var P=null;function et(e,t,i,a){T(e,t);let r=$b(e);if(!r)return;P?.close();let o=(l,c,d,f={})=>({destructive:!1,disabled:!1,dividerAbove:!1,id:l,run:d,title:c,...f});P=Vt({label:`${r.name} actions`,onClosed:(l)=>{if(P===l)P=null},origin:{x:i,y:a},region:"media-tile",rows:[o("open","Open in Viewer",()=>Qu(t)),...pC(t)?[o("edit","Edit Image",()=>gC(t))]:[],o("copy-url","Copy Site URL",()=>Te(r)),o("rename","Rename…",()=>{SD(t)},{dividerAbove:!0}),...fC()?[o("duplicate","Duplicate",()=>{CD(t)})]:[],o("replace","Replace…",()=>pF(t)),o("delete","Delete",()=>{_D(t)},{destructive:!0,dividerAbove:!0})]})}function ye(e,t){if(e.mode==="pick"){let i=$b(e);if(i)e.onPick?.(i);return}Qu(t)}function tt(e,t,i){let{files:a}=ke(e),r=q(a,{filter:e.choice.filter,query:e.choice.query,sort:e.choice.sort,unused:F}),o=r.findIndex((f)=>f.file===e.choice.selected),l=e.grid?le(Me(e.grid).width):1,c=o===-1?r.length>0?0:null:se(o,t,l,r.length,i),d=c===null?void 0:r[c];if(!d)return;T(e,d.file),e.tiles.get(d.file)?.focus()}var je=new WeakMap;function De(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:Cp((c)=>{let d=je.get(c);if(d!==void 0&&!l.visible.has(d))l.visible.add(d),it(l)}),onPick:null,onSelect:null,paneId:a,reveal:null,revealFocus:!1,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 SS(e,t){let i=k.get(e);return i!==void 0&&i.tabId===t.id&&i.wrap.isConnected&&i.mount.handle!==null&&i.mount.handle.attached()}function Lw(e){let t=k.get(e);if(!t)return;X(t.mount),k.delete(e)}function pT(e,t){let{paneId:i,wrap:a}=e;if(SS(i,t))return;Lw(i);let r=De("manage",m,$n(i,"media-library"),i,!1,Ia);if(N.add(r),we(),r.handle=V(a,ee(r),Ne(r),{clear:!0}),k.set(i,{mount:r,tabId:t.id,wrap:a}),Q.delete(i))Ce(r)}async function Ce(e){await e.handle?.ready,He(e,!0)}function He(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 fT(e){let t=k.get(e);if(t?.wrap.isConnected&&t.mount.handle?.attached()===!0){Ce(t.mount);return}Q.add(e)}function hF(e){if(e.filter!==void 0)m.filter=e.filter;if(e.query!==void 0)m.query=e.query;if(e.select!==void 0){if(m.selected=e.select,m.filter!=="all")m.filter="all";m.query=""}x()}function FF(){let e=[...k.values()].map((t)=>$e(t.mount.inputs.upload)).find((t)=>t!==null)??null;if(e){te(e);return}C={file:null,role:"upload"}}function pF(e){hF({select:e});let t=null;for(let i of k.values())if(i.mount.choice.selected===e)t??=$e(i.mount.inputs.replace);if(t){te(t);return}C={file:e,role:"replace"}}var _=null;function be(e){let t=$b(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 CS(){let e=_;if(_=null,e)X(e.mount),e.dialog.close()}function jF(e){CS();let t={filter:e.images?"image":"all",query:"",selected:null,sort:"newest"},i=De("pick",t,`${yt("dialog",B)}/library`,null,e.images,fR(h.value?.documentPath??null)),a=(o)=>{CS(),e.onPick(o.ref)};i.onPick=a,N.add(i),we();let r=fe({body:(o)=>{i.handle=V(o,ee(i),Ne(i),{clear:!1})},closed:()=>{if(_?.mount===i)CS();else X(i)},confirm:()=>{let o=$b(i);if(o)a(o)},layer:dt("dialog"),view:be(i)});i.onSelect=()=>r.update(be(i)),_={dialog:r,mount:i}}function mT(){CS();for(let e of k.keys())Lw(e);m.filter="all",m.query="",m.selected=null,m.sort="newest",C=null,Q.clear(),J()}
|
|
2
|
+
export{_S,MF,$b,_D,SD,CD,SS,Lw,pT,fT,hF,FF,pF,CS,jF,mT};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
5
|
-
//# sourceMappingURL=studio-
|
|
4
|
+
//# debugId=6D4C144640109F3B64756E2164756E21
|
|
5
|
+
//# sourceMappingURL=studio-9gb0m81w.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{p,ve}from"./studio-xh6rf05g.js";import{X}from"./studio-9c6cbq2c.js";import{Ra,fR}from"./studio-wn2cmf9q.js";import{w,xl,sf}from"./studio-bk0anq3b.js";import{oP,ia,xR,Da,Z,Yd,eg,So,d_,u_,g,h,Si}from"./studio-s49y6m5b.js";import{jt,ru,Wi,lf,fn,lo,zR,Ma,UR}from"./studio-ex1644g2.js";import{Ud}from"./studio-k05g7efh.js";import{Vd}from"./studio-td3h1644.js";import{cs,ll,j$,Xu}from"./studio-j3bq30yz.js";import{tI,fM,mM,Nh,qy}from"./studio-m3jrjfhy.js";import{Kr}from"./studio-cv6gnjqd.js";import{Ta,zO,bL}from"./studio-aaw7wxv8.js";import{Ts,Cr}from"./studio-1d8m5s38.js";import{al}from"./studio-thgexj3w.js";import{sO}from"./studio-4jy967rj.js";import{re}from"./studio-151kgn69.js";import{me,Ds,te,b,le}from"./studio-9f5vcb4w.js";import{n,J,qe,S,m}from"./studio-erjccagy.js";function ie(e,o=[]){if(e?.tagName==="slot"){let s=e.attributes?.name;o.push(n(s)?s.trim():"")}if(Array.isArray(e?.children))for(let s of e.children)ie(n(s)?void 0:s,o);return o}function Z0(e){let o=ie(e),s=o.filter((r)=>r==="").length;if(s>1)return`Component has ${s} unnamed <slot> elements — only one default slot is allowed. Give extra slots a name attribute.`;let l=new Set;for(let r of o){if(r&&l.has(r))return`Duplicate slot name "${r}" — slot names must be unique within a component.`;l.add(r)}return null}var se={invokerTags:qy,popoverTags:Nh},N="Popover",Se={display:"document.repairPopoverDisplay","open-display":"document.repairPopoverDisplay",invoker:"document.repairPopoverInvoker",mode:"document.repairPopoverMode"};function ae(e,o,s,l){let r=`${o}.${s}.${l.join("/")}`,d=e.get(r)??0;return e.set(r,d+1),d===0?r:`${r}#${d}`}function H(e,o){xl((d)=>d.source===N);let s=new Map,l=fM(e,se);for(let d of l){let c=d.fix===void 0?void 0:Se[d.fix],C={detail:d.detail,key:ae(s,"popover",d.rule,d.path),source:N,tier:"problem"};if(c!==void 0)C.action=c,C.actionArgs={path:d.path};if(o!==void 0)C.path=o;w(d.severity,d.message,C)}let r=zO(e,se);for(let d of r){let c={detail:d.detail,key:ae(s,"dialog",d.rule,d.path),source:N,tier:"problem"};if(o!==void 0)c.path=o;w(d.severity,d.message,c)}return l.length+r.length}function W(e,o){let s=o?.path;if(!Array.isArray(s))throw RangeError(`command "${e}" needs a "path" argument naming the popover`);return s}function I(e){let o=h.value;if(!o)throw RangeError(`command "${e}" needs an open document`);return o}function xe(){return[{category:"Document",group:"2_document",id:"document.checkPopovers",level:"document",menus:["palette"],requires:"an open document",run:()=>{let e=I("document.checkPopovers"),o=H(e.doc.document,e.documentPath??void 0);w.success(o===0?"No popover problems found in this document.":`${o} popover problem(s) filed.`,{key:"popover.run",source:N})},title:"Check Popovers",when:(e)=>e.document.open,aiTool:{description:"Check the open document for popover defects an author can fix — a base-rule `display` "+"that defeats the browser's own hiding of a closed popover, `popovertarget` on an "+"element that cannot invoke, a target naming no popover, a cut exit animation — and "+"file each as a Problem. The findings come back as data.",name:"check_popovers",report:()=>{let e=sf(N),o=e.length;return{data:e,summary:o===0?"No popover problems found in this document.":`Filed ${o} popover problem${o===1?"":"s"} in Problems.`}}}},{args:{additionalProperties:!1,properties:{path:{items:{type:["string","number"]},type:"array"}},required:["path"],type:"object"},category:"Document",group:"2_document",id:"document.repairPopoverDisplay",level:"document",menus:[],requires:"a popover whose base rule sets display",run:(e,o)=>{let l=I("document.repairPopoverDisplay"),r=W("document.repairPopoverDisplay",o),d=re(l.doc.document,r),c=mM(d?.style);if(!c)throw RangeError(`command "${"document.repairPopoverDisplay"}": nothing to move — this popover sets no display`);Z(l,(C)=>{for(let v of c.base)eg(C,r,v,"");for(let v of c.breakpoints)u_(C,r,[v],"display","");if(c.openDisplay!==null)d_(C,r,":popover-open","display",c.openDisplay)}),w.success("Moved `display` into `:popover-open`.",{key:"popover.repaired.display",source:N})},title:"Move display into :popover-open",when:(e)=>e.document.open},{args:{additionalProperties:!1,properties:{path:{items:{type:["string","number"]},type:"array"}},required:["path"],type:"object"},category:"Document",group:"2_document",id:"document.repairPopoverInvoker",level:"document",menus:[],requires:"an element carrying popovertarget that cannot invoke",run:(e,o)=>{let l=I("document.repairPopoverInvoker"),r=W("document.repairPopoverInvoker",o);Z(l,(d)=>{So(d,r,"popovertarget"),So(d,r,"popovertargetaction")}),w.success("Removed the attributes, which did nothing on this element.",{key:"popover.repaired.invoker",source:N})},title:"Remove the inert popover attributes",when:(e)=>e.document.open},{args:{additionalProperties:!1,properties:{path:{items:{type:["string","number"]},type:"array"}},required:["path"],type:"object"},category:"Document",group:"2_document",id:"document.repairPopoverMode",level:"document",menus:[],requires:"a popover whose mode is not one of the three keywords",run:(e,o)=>{let l=I("document.repairPopoverMode"),r=W("document.repairPopoverMode",o);Z(l,(d)=>{So(d,r,"popover",tI)}),w.success(`Set \`popover\` to "${tI}".`,{key:"popover.repaired.mode",source:N})},title:"Set popover to auto",when:(e)=>e.document.open}]}function tO(e){e.registerAll(xe())}function Jw(e,o){if(e===o)return!0;if(Array.isArray(e)&&Array.isArray(o))return e.length===o.length&&e.every((s,l)=>s===o[l]);if(S(e)&&S(o)&&!Array.isArray(e)&&!Array.isArray(o))return e.$ref===o.$ref;return!1}var A="grid://",Pb={children:[],tagName:"div"};function as(e){switch(e.kind){case"pages":return`${A}pages`;case"collection":return`${A}collection/${encodeURIComponent(e.name)}`;default:return`${A}data/${encodeURIComponent(e.connection)}/${encodeURIComponent(e.table)}`}}function Pe(e){return e.startsWith(A)}function Zl(e){if(!Pe(e))return null;let o=e.slice(A.length).split("/");if(o[0]==="pages"&&o.length===1)return{kind:"pages"};if(o[0]==="collection"&&o.length===2&&o[1])return{kind:"collection",name:decodeURIComponent(o[1])};if(o[0]==="data"&&o.length===3&&o[1]&&o[2])return{connection:decodeURIComponent(o[1]),kind:"data",table:decodeURIComponent(o[2])};return null}function Nm(e){let o=Zl(e);if(!o)return null;switch(o.kind){case"pages":return"Pages · grid";case"collection":return`${o.name} · grid`;default:return`${o.table} @ ${o.connection} · grid`}}var ce=0;function de(e){let o=e.coalesceMs??800,s=e.now??(()=>Date.now()),r=b({deletes:new Set,errors:new Map,inserts:new Map,pending:new Map,redoStack:[],stale:new Set,undoStack:[]}),d=null,c=(t,i,a)=>{let u=r.errors.get(t);if(u)u.set(i,a);else r.errors.set(t,new Map([[i,a]]))},C=(t,i)=>{let a=r.errors.get(t);if(a?.delete(i),a?.size===0)r.errors.delete(t)},v=(t)=>{if(r.redoStack.length=0,d){d.push(t);return}let i=r.undoStack.at(-1);if(t.kind==="cell"&&i?.kind==="cell"&&i.rowKey===t.rowKey&&i.field===t.field&&t.at-i.at<=o){i.after=t.after,i.at=t.at;return}r.undoStack.push(t)},k=(t,i,a)=>{let u=r.inserts.get(t);if(u){if(a===null)delete u[i];else u[i]=a;return}if(Jw(a,e.resolveBaseline(t,i))){let f=r.pending.get(t);if(f?.delete(i),f?.size===0)r.pending.delete(t);return}let y=r.pending.get(t);if(y)y.set(i,{value:a});else r.pending.set(t,new Map([[i,{value:a}]]))},G=(t,i)=>{let a=r.inserts.get(t);if(a)return a[i]??null;let u=r.pending.get(t)?.get(i);return u?u.value:e.resolveBaseline(t,i)},M=(t,i)=>{let a=r.errors.get(t);return a?.get(i)??a?.get("*")??null},F=(t,i)=>{switch(t.kind){case"cell":{k(t.rowKey,t.field,i==="undo"?t.before:t.after);break}case"insert":{if(i==="undo")r.inserts.delete(t.tempKey);else r.inserts.set(t.tempKey,{...t.cells});break}case"drop-insert":{if(i==="undo")r.inserts.set(t.tempKey,{...t.cells});else r.inserts.delete(t.tempKey);break}case"delete":{if(i==="undo")r.deletes.delete(t.rowKey);else r.deletes.add(t.rowKey);break}default:{let a=i==="undo"?t.ops.toReversed():t.ops;for(let u of a)F(u,i);break}}},D=()=>{if(d)throw Error("edit-buffer: groups may not nest");d=[]},P=()=>{let t=d;if(d=null,!t)return;if(t.length===1)r.undoStack.push(t[0]);else if(t.length>1)r.undoStack.push({kind:"group",ops:t})},T=(t)=>{let i=(a)=>{switch(a.kind){case"cell":return t(a.rowKey)?null:a;case"insert":case"drop-insert":return t(a.tempKey)?null:a;case"delete":return t(a.rowKey)?null:a;default:{let u=a.ops.map((y)=>i(y)).filter((y)=>y!==null);return u.length>0?{kind:"group",ops:u}:null}}};r.undoStack=r.undoStack.map(i).filter((a)=>a!==null),r.redoStack=r.redoStack.map(i).filter((a)=>a!==null)};return{applyCommitResult(t){let i=new Set;for(let a of t.cells)if(a.ok){let u=r.pending.get(a.rowKey);if(u?.delete(a.field),u?.size===0)r.pending.delete(a.rowKey);C(a.rowKey,a.field)}else if(c(a.rowKey,a.field,a.error??"Save failed"),a.stale)r.stale.add(a.rowKey);for(let a of t.inserts)if(a.ok)r.inserts.delete(a.tempKey),r.errors.delete(a.tempKey),i.add(a.tempKey);else c(a.tempKey,"*",a.error??"Insert failed");for(let a of t.deletes)if(a.ok)r.deletes.delete(a.rowKey),r.pending.delete(a.rowKey),r.errors.delete(a.rowKey),i.add(a.rowKey);else if(c(a.rowKey,"*",a.error??"Delete failed"),a.stale)r.stale.add(a.rowKey);for(let a of i)r.stale.delete(a);if(i.size>0)T((a)=>i.has(a))},buildBatch(){let t=[];for(let[i,a]of r.pending){if(r.deletes.has(i))continue;for(let[u,y]of a)t.push({baseline:e.resolveBaseline(i,u),field:u,rowKey:i,value:y.value})}return{cells:t,deletes:[...r.deletes].map((i)=>({rowKey:i})),inserts:[...r.inserts].map(([i,a])=>({cells:{...a},tempKey:i}))}},canRedo:()=>r.redoStack.length>0,canUndo:()=>r.undoStack.length>0,cellError:M,cellState(t,i){if(M(t,i)!==null)return"error";if(r.stale.has(t))return"stale";if(r.inserts.has(t)||r.pending.get(t)?.has(i))return"dirty";return"clean"},deleteRow(t){if(r.deletes.has(t))return;let i=r.inserts.get(t);if(i){let a={...i};r.inserts.delete(t),r.errors.delete(t),r.stale.delete(t),v({cells:a,kind:"drop-insert",tempKey:t});return}r.deletes.add(t),v({kind:"delete",rowKey:t})},dirtyCount(){let t=r.inserts.size+r.deletes.size;for(let[i,a]of r.pending)if(!r.deletes.has(i))t+=a.size;return t},discardRow(t){r.pending.delete(t),r.deletes.delete(t),r.inserts.delete(t),r.errors.delete(t),r.stale.delete(t),T((i)=>i===t)},effectiveValue:G,beginGroup:D,endGroup:P,group(t){D();try{t()}finally{P()}},insertRow(t={}){ce+=1;let i=`__new-${ce}`;return r.inserts.set(i,{...t}),v({cells:{...t},kind:"insert",tempKey:i}),i},isDirty:()=>r.pending.size>0||r.inserts.size>0||r.deletes.size>0,isInsertKey:(t)=>r.inserts.has(t),markStale(t){for(let i of t)r.stale.add(i)},redo(){let t=r.redoStack.pop();if(!t)return!1;return F(t,"redo"),r.undoStack.push(t),!0},reset(){r.pending.clear(),r.inserts.clear(),r.deletes.clear(),r.errors.clear(),r.stale.clear(),r.undoStack.length=0,r.redoStack.length=0},rowState(t){if(r.deletes.has(t))return"pending-delete";if(r.inserts.has(t))return"pending-insert";if(r.stale.has(t))return"stale";if(r.pending.has(t)||r.errors.has(t))return"dirty";return"clean"},setCell(t,i,a){let u=G(t,i);if(Jw(u,a))return;k(t,i,a),v({after:a,at:s(),before:u,field:i,kind:"cell",rowKey:t})},state:r,undo(){let t=r.undoStack.pop();if(!t)return!1;return F(t,"undo"),r.redoStack.push(t),!0}}}var ue={array:220,boolean:70,date:130,enum:140,image:180,number:110,readonly:200,reference:200,string:180,text:340};function fe(e){return Math.min(340,Math.max(90,Math.round(e*7.5)))}function Ge(e){if(e.$ref)return"reference";if(e.enum!==void 0&&Array.isArray(e.enum))return"enum";let o=e.type==="array"?void 0:e.format;if(Da(o))return"image";if(o==="date"||o==="date-time")return"date";switch(e.type){case"number":case"integer":return"number";case"boolean":return"boolean";case"array":return"array";case"object":return"readonly";default:return(e.maxLength??0)>200||e.format==="markdown"?"text":"string"}}function pe(e){let o=e.replaceAll(/([a-z0-9])([A-Z])/g,"$1 $2").replaceAll(/[_-]+/g," ").trim();return o.charAt(0).toUpperCase()+o.slice(1)}function Yw(e,o={}){let s=Object.entries(e?.properties??{}),l=new Set(e?.required),r=new Set(o.readonlyFields),d=s.map(([c,C])=>{let v=r.has(c)?"readonly":Ge(C),k=Array.isArray(C.enum)?Math.max(...C.enum.map((G)=>String(G).length),4):0;return{editable:v!=="readonly",field:c,kind:v,pk:c===o.idField,required:l.has(c),schema:C,title:pe(c),widthHint:v==="enum"?fe(k+3):ue[v]}});return d.sort((c,C)=>{let v=(G)=>G.pk?0:G.required?1:2,k=v(c)-v(C);return k===0?0:k}),d}function Zw(e,o=50){let s=e.slice(0,o),l=[];for(let r of s)for(let d of Object.keys(r))if(!l.includes(d))l.push(d);return l.map((r)=>{let d=s.flatMap((v)=>{let k=v[r];return k===null||k===void 0||k===""?[]:[k]}),c=Re(d),C=Math.max(...d.map((v)=>Qr(v).length),r.length,4);return{editable:!0,field:r,kind:c,title:pe(r),widthHint:c==="string"||c==="text"?fe(C):ue[c]}})}function Re(e){if(e.length===0)return"string";if(e.some((s)=>Array.isArray(s)))return"array";let o=e.map(String);if(e.every((s)=>qe(s))||o.every((s)=>/^(true|false)$/i.test(s)))return"boolean";if(e.every((s)=>J(s))||o.every((s)=>s.trim()!==""&&!Number.isNaN(Number(s.replaceAll(/[$€£¥,\s]/g,"")))))return"number";if(o.every((s)=>/^\d{4}-\d{2}-\d{2}([T ].*)?$/.test(s)))return"date";if(o.some((s)=>s.length>200))return"text";return"string"}function $p(e,o){if(e===null||e===void 0)return null;switch(o.kind){case"number":{if(J(e))return Number.isNaN(e)?null:e;let s=String(e).trim().replaceAll(/[$€£¥,\s]/g,"");if(s==="")return null;let l=Number(s);return Number.isNaN(l)?null:l}case"boolean":{if(qe(e))return e;return String(e).trim().toLowerCase()==="true"}case"array":{if(Array.isArray(e))return e.map(String);let s=String(e).trim();return s===""?[]:s.split(",").map((l)=>l.trim()).filter(Boolean)}case"reference":{if(m(e)&&"$ref"in e){let l=e.$ref;return n(l)&&l!==""?l:null}let s=String(e).trim();return s===""?null:s}default:{let s=String(e);return s===""?null:s}}}function Qr(e){if(e===null||e===void 0)return"";if(Array.isArray(e))return e.join(", ");if(S(e))return e.$ref;return String(e)}var Y0="__key",Y=new WeakMap;function eo(e){return e?Y.get(le(e))??null:null}function Lp(e,o){let l=b({columns:[],error:null,grouping:null,loading:!1,query:{},rows:[],saving:!1,total:0}),r=new Map,d=(t)=>{r=new Map(t.map((i)=>[i.key,i]))},c=de({resolveBaseline:(t,i)=>r.get(t)?.cells[i]??null}),C=async()=>{let t=await o.rows(l.query);d(t.rows),l.rows=t.rows,l.total=t.total},v=(t)=>{let i=l.columns.filter((y)=>y.required&&y.editable);if(i.length===0)return null;let a=t.cells.filter((y)=>y.value===null&&i.some((f)=>f.field===y.field)).map((y)=>({error:"Required",field:y.field,ok:!1,rowKey:y.rowKey})),u=t.inserts.filter((y)=>i.some((f)=>y.cells[f.field]===null||y.cells[f.field]===void 0)).map((y)=>({error:`Missing required: ${i.filter((R)=>y.cells[R.field]===null||y.cells[R.field]===void 0).map((R)=>R.field).join(", ")}`,ok:!1,tempKey:y.tempKey}));if(a.length===0&&u.length===0)return null;return{cells:a,deletes:[],inserts:u}},k=(t)=>t===null||t===""||Array.isArray(t)&&t.length===0,G=(t,i,a)=>{if(a==="number")return(J(t)?t:0)-(J(i)?i:0);if(a==="boolean")return(t===!0?1:0)-(i===!0?1:0);return Qr(t).localeCompare(Qr(i))},M=()=>{let t=l.rows.map((u)=>u.key),{dir:i,orderBy:a}=l.query;if(a&&!o.capabilities.remoteSort){let u=l.columns.find((f)=>f.field===a)?.kind,y=i==="desc"?-1:1;t=t.toSorted((f,R)=>{let E=c.effectiveValue(f,a),L=c.effectiveValue(R,a);if(k(E)!==k(L))return k(E)?1:-1;return y*G(E,L,u)})}return l.grouping?[...F(t).values()].flat():t},F=(t)=>{let i=new Map;for(let a of t){let u=Qr(c.effectiveValue(a,l.grouping)),y=i.get(u);if(y)y.push(a);else i.set(u,[a])}return i},D=null,P=()=>D?.refreshData(),T={addRow(t={}){let i=c.insertRow(t);return P(),i},bindView(t){D=t},buffer:c,deleteRows(t){if(t.length===0)return;c.group(()=>{for(let i of t)c.deleteRow(i)}),P()},discardRow(t){c.discardRow(t),P()},replaceAll(t,i){if(t==="")return 0;let a=l.columns.filter((f)=>f.editable&&(f.kind==="string"||f.kind==="text")),u=[...l.rows.map((f)=>f.key),...c.state.inserts.keys()],y=0;if(c.group(()=>{for(let f of u){if(c.rowState(f)==="pending-delete")continue;for(let R of a){let E=c.effectiveValue(f,R.field);if(n(E)&&E.includes(t))c.setCell(f,R.field,E.replaceAll(t,i)),y+=1}}}),y>0)P();return y},effectiveRows(){let t=(u)=>Array.isArray(u)?[...u]:S(u)?{$ref:u.$ref}:u,i=(u)=>{let y=[[Y0,u]];for(let f of l.columns)y.push([f.field,t(c.effectiveValue(u,f.field))]);return Object.fromEntries(y)},a=M().map((u)=>i(u));for(let[u]of c.state.inserts)a.push(i(u));return a},groups(){if(!l.grouping)return[];return[...F(M())].map(([t,i])=>({count:i.length,value:t}))},async load(){l.loading=!0,l.error=null;try{l.columns=await o.columns(),await C()}catch(t){l.error=X(t)}finally{l.loading=!1}P()},async refresh(){if(c.isDirty()){if(!await Kr("Refresh Grid",`Discard ${c.dirtyCount()} pending change(s) and reload?`,{confirmLabel:"Discard & Reload",destructive:!0}))return}c.reset(),await o.refresh?.(),await this.load()},async save(){if(l.saving)return;let t=c.buildBatch(),i=t.cells.length+t.inserts.length+t.deletes.length;if(i===0){w.info("No grid changes to save.",{key:"grid.save"});return}let a=v(t);if(a){c.applyCommitResult(a),w.warn("Required cells are empty — fix the marked rows, then save again.",{key:"grid.save",source:"Data",tier:"problem"});return}if(t.deletes.length>0){if(!await Kr("Delete Rows",`Save will permanently delete ${t.deletes.length} row(s). Continue?`,{confirmLabel:"Delete & Save",destructive:!0}))return}let y=new Set(t.cells.map((f)=>f.rowKey)).size+t.inserts.length+t.deletes.length>5?al({title:"Saving grid"}):null;l.saving=!0;try{let f=await o.commit(t),R=(x,j)=>`${x}\x00${j}`,E=new Map(t.cells.map((x)=>[R(x.rowKey,x.field),x]));for(let x of f.cells){let j=E.get(R(x.rowKey,x.field));if(x.ok&&j){let oe=r.get(x.rowKey);if(oe)oe.cells[x.field]=j.value}}if(c.applyCommitResult(f),f.inserts.some((x)=>x.ok)||f.deletes.some((x)=>x.ok))await C();let z=f.cells.filter((x)=>x.ok).length+f.inserts.filter((x)=>x.ok).length+f.deletes.filter((x)=>x.ok).length,ee=i-z,ne=f.cells.filter((x)=>x.stale).length+f.deletes.filter((x)=>x.stale).length;if(ee===0)w.success(`Saved ${z} change(s).`,{key:"grid.save"});else w.error(`Saved ${z} · ${ee} failed${ne?` (${ne} stale)`:""} — kept pending.`,{action:"file.save",key:"grid.save",source:"Data"})}catch(f){w.error("Could not save the grid.",{action:"file.save",detail:X(f),key:"grid.save",source:"Data"})}finally{l.saving=!1,y?.done(),P()}},serializeForSource(){if(!o.serializeForSource)return null;return o.serializeForSource(c.buildBatch())},async setQuery(t){l.query=t,l.loading=!0;try{await C()}catch(i){l.error=X(i)}finally{l.loading=!1}P()},setGrouping(t){l.grouping=t,P()},async setSort(t){let i={...l.query};if(t)i.orderBy=t.field,i.dir=t.dir;else delete i.orderBy,delete i.dir;if(!o.capabilities.remoteSort){l.query=i,P();return}await this.setQuery(i)},source:o,state:l,tab:e};return e.scope.run(()=>{te(()=>{e.doc.dirty=c.isDirty()}),Yd(e,{canRedo:()=>c.canRedo(),canUndo:()=>c.canUndo(),redo:()=>{c.redo(),P()},undo:()=>{c.undo(),P()}});let t=p();if(t.subscribeFileEvents&&o.backingPaths){let i=t.subscribeFileEvents((a)=>{let u=o.backingPaths(),y=new Set;for(let f of a){if(f.isDir)continue;let R=f.path.replaceAll("\\","/"),E=u.get(R);if(E!==void 0&&!Ud(R))y.add(E)}if(y.size===0)return;if(c.isDirty()){let f=y.has("*")?l.rows.map((R)=>R.key):[...y];c.markStale(f),w.warn("Grid rows changed on disk — marked stale; refresh to reload.",{key:"grid.stale",source:"Data"}),P()}else T.refresh()});Ds(i)}Ds(()=>{Yd(e,null),Y.delete(le(e)),o.dispose?.()})}),Y.set(le(e),T),T}async function Ju(e){let s=eo(e)?.serializeForSource();if(s)return s;await jt();let l=Wi(e.doc.sourceFormat);if(l?.capabilities.serialize){let r=e.doc.content.frontmatter,d=e.doc.document,c={...r,...d,children:d.children??[]};return Ma(l.name,c,{mode:"roundtrip",...e.doc.source!==null&&{source:e.doc.source}})}if(e.doc.mode==="content"){let r=lo();if(r){let d=e.doc.content.frontmatter,c=Object.keys(d).length>0,C={...d,...e.doc.document};return Ma(r.name,C,{frontmatter:c,mode:"roundtrip"})}}return Cr(oP(e.doc.document,e.doc.bareRepeaters??null),e.doc.layout??null)}var Ee=200,Te=500,Oe=2097152,B=new Map,K=!1,q=null,O=null,V=null,Q=null;function Me(){let e=[];for(let o of g.tabs.values())if(o.doc.dirty&&o.documentPath)e.push(o);return e}async function ge(){if(!ve())return;let e=p();if(!e.setPreviewOverlay||!e.clearPreviewOverlay)return;let o=new Set;for(let s of Me()){let l=s.documentPath.replace(/^\.\//,""),r;try{r=await Ju(s)}catch{continue}if(r.length>Oe)continue;if(o.add(l),B.get(l)===r)continue;B.set(l,r),await e.setPreviewOverlay(l,r)}for(let s of B.keys())if(!o.has(s))B.delete(s),await e.clearPreviewOverlay(s)}function ye(){if(!K)return;let e=Date.now();if(V??=e,O)clearTimeout(O);let o=e-V,s=Math.max(0,Math.min(Ee,Te-o));O=setTimeout(()=>{O=null,V=null,Q=ge().finally(()=>{Q=null})},s)}function nO(){ye()}function iO(){if(K)return;K=!0,q=me(),q.run(()=>{te(()=>{for(let e of g.tabs.values())e.doc.dirty,e.doc.document;ye()})})}function rO(){if(K=!1,O)clearTimeout(O),O=null;V=null,q?.stop(),q=null,B.clear()}async function X0(){if(!K)return;if(O)clearTimeout(O),O=null,V=null;await Q,await ge()}var he=/^[A-Za-z0-9][A-Za-z0-9!#$&^_.+-]{0,126}$/,$e=new Set(["vnd","prs","x"]);function Fe(e){if(!n(e))return null;let[o,...s]=e.split(";"),l=(o??"").indexOf("/");if(l===-1)return null;let r=(o??"").slice(0,l).trim().toLowerCase(),d=(o??"").slice(l+1).trim().toLowerCase();if(!he.test(r)||!he.test(d))return null;let c=d.lastIndexOf("+"),C=c===-1?null:d.slice(c+1),v=c===-1?d:d.slice(0,c);if(C==="")return null;let k=v.indexOf("."),G=k===-1?null:v.slice(0,k),M=G!==null&&$e.has(G)?G:null,F=M===null?v:v.slice(M.length+1);if(F==="")return null;let D={};for(let P of s){let T=P.indexOf("=");if(T===-1)return null;let t=P.slice(0,T).trim().toLowerCase(),i=P.slice(T+1).trim();if(t==="")return null;if(i.startsWith('"')&&i.endsWith('"')&&i.length>=2)i=i.slice(1,-1);D[t]=i}return{parameters:D,subtype:F,suffix:C,tree:M,type:r}}function Xw(e){let o=Fe(e);if(o===null)return null;let s=o.tree===null?"":`${o.tree}.`,l=o.suffix===null?"":`+${o.suffix}`;return`${o.type}/${s}${o.subtype}${l}`}var we="text/markdown; variant=GFM",be="application/yaml",Tt={".markdown":`${we}; charset=utf-8`,".md":`${we}; charset=utf-8`,".yaml":`${be}; charset=utf-8`,".yml":`${be}; charset=utf-8`};async function oO(e,o){let s=await zR(e.name,o);return UR(e,s)}async function Bo(e,o){await jt();let s=fn(e);if(!s||!s.capabilities.parse)throw lf(e);return{...await oO(s,o),format:s}}var r$=async(e,o)=>{if(e.documentPath&&fn(e.documentPath)){let l=await Bo(e.documentPath,o);return e.doc.source=o,{document:l.document,frontmatter:l.frontmatter}}let s=Ts(o);return e.doc.layout=s.layout,{document:s.document}};function De(e){return"showOpenFilePicker"in e}function Ne(e){return"showSaveFilePicker"in e}function U(e,o){if(e.documentPath!==null)o.path=e.documentPath;return o}async function NF(){try{await jt();let e=ru(),o=[{accept:{"application/json":[".json"]},description:"Jx Component"},...e.filter((r)=>r.capabilities.parse).map((r)=>({accept:{[Xw(r.mediaType)??"text/plain"]:r.extensions},description:r.name}))],s=[".json",...e.flatMap((r)=>r.extensions)].join(","),l=async(r,d,c=null)=>{let C=c?await sO(r):null,v=fn(r);if(v){let{document:k,frontmatter:G}=await oO(v,d);Si({document:k,documentPath:C,fileHandle:c,frontmatter:G,id:r,source:d,sourceFormat:v.name})}else if(r.endsWith(".json")){let{document:k,layout:G}=Ts(d);Si({document:k,documentPath:C,fileHandle:c,id:r,layout:G})}else throw lf(r)};if(De(window)){let[r]=await window.showOpenFilePicker({types:o}),d=await r.getFile();await l(r.name,await d.text(),r)}else{let r=document.createElement("input");r.type="file",r.accept=s,r.addEventListener("change",async()=>{let d=r.files?.[0];if(!d)return;await l(d.name,await d.text())}),r.click()}}catch(e){if(!(e instanceof Error&&e.name==="AbortError"))w.error("Could not open the file.",{detail:X(e),source:"Open File"})}}var Ce=()=>{};function o$(e){Ce=e}function _(e){let o=e.doc.document;Ce(e.documentPath,o,e);let s=n(o.tagName)&&o.tagName.includes("-")?Z0(o):null;if(s)w.warn(s,U(e,{key:`slots:${e.documentPath??e.id}`,source:"Components",tier:"problem"}));H(o,e.documentPath??void 0)}function Ae(e){return!Vd(e.documentPath??"")}async function Rp(e=h.value){if(!e)return!1;if(await bL(e.id),ia(e))return w.warn(`You have read access to this session — changes to ${e.documentPath??"this document"} stay in your browser and cannot be saved.`,U(e,{action:"file.save",key:`save.readOnly:${e.documentPath??e.id}`,source:"Collaboration"})),!1;if(!Ae(e)){if(Ta(e)===cs||ll(e))return j$(e);return w.warn(`${e.documentPath??"This file"} is a media file, so there is no document for Save to write.`,U(e,{key:`save.notADocument:${e.documentPath??e.id}`,source:"Save"})),!1}let o=eo(e);if(o)return await o.save(),!e.doc.dirty;try{if(await xR(e))return _(e),!0;let s=await Ju(e);if(e.documentPath){if(await p().writeFile(e.documentPath,s),e.doc.dirty=!1,e.doc.sourceFormat!==null)e.doc.source=s;return X0(),_(e),!0}if(e.fileHandle&&"createWritable"in e.fileHandle){let l=await e.fileHandle.createWritable();if(await l.write(s),await l.close(),e.doc.dirty=!1,e.doc.sourceFormat!==null)e.doc.source=s;return _(e),!0}w.warn("This document has no save target — use Export.",{key:"save.noTarget"})}catch(s){if(!(s instanceof Error&&s.name==="AbortError"))w.error(`Could not save ${e.documentPath??e.id}.`,U(e,{action:"file.save",detail:X(s),key:`save:${e.documentPath??e.id}`,source:"Save"}))}return!1}function Be(e){return Wi(e.doc.sourceFormat)??(e.doc.mode==="content"?lo():void 0)}async function s$(){let e=h.value;if(!e)return;try{await jt();let o=Be(e),s=await Ju(e),l=o?Xw(o.mediaType)??"text/plain":"application/json",r=o?o.extensions[0]:".json",d=o?o.name:"Jx Component",c=o?`content${r}`:"component.json";if(Ne(window)){let C=e.documentPath?e.documentPath.split("/").pop():c,v=await window.showSaveFilePicker({suggestedName:C,types:[{accept:{[l]:[r]},description:d}]}),k=await v.createWritable();await k.write(s),await k.close(),e.doc.dirty=!1,_(e),w.success(`Exported as ${v.name}.`)}else{let C=new Blob([s],{type:l}),v=URL.createObjectURL(C),k=document.createElement("a");k.href=v,k.download=c,k.click(),URL.revokeObjectURL(v),e.doc.dirty=!1,_(e),w.success(`Downloaded ${c}.`)}}catch(o){if(!(o instanceof Error&&o.name==="AbortError"))w.error("Could not export the document.",{detail:X(o),source:"Export"})}}async function ke(e,o){let s=Vd(e)?await Xu(e):await Ra({path:e});return fR(s,o)??""}async function Mb(e){let o=await ke(e.path,"delete"),s=`Delete ${e.name}? This cannot be undone.`;return Boolean(await Kr("Delete File",o===""?s:`${s} ${o}`,{confirmLabel:"Delete",destructive:!0}))}async function Fb(e,o="rename"){let s=await ke(e,o);return s===""?void 0:s}
|
|
2
|
-
export{
|
|
1
|
+
import{p,we}from"./studio-1b79rpcb.js";import{Z}from"./studio-mkjrjpr2.js";import{Na,SR}from"./studio-pk961xgz.js";import{w,Sl,cf}from"./studio-5k9mfafh.js";import{yP,ra,RR,Aa,X,Xd,rg,Co,m_,g_,g,h,Si}from"./studio-ybkd5w8k.js";import{jt,su,zi,hf,fn,co,QR,ja,eI}from"./studio-hf259xzd.js";import{Jd}from"./studio-wqsmvtqj.js";import{zd}from"./studio-jj9gf1qc.js";import{ds,dl,K$,eh}from"./studio-qvb2jr83.js";import{dI,TM,$M,Ah,Zy}from"./studio-s6ymkf3q.js";import{Kr}from"./studio-yetr4gg1.js";import{La,tA,EL}from"./studio-m25ry0mf.js";import{cl}from"./studio-56mmnsw8.js";import{bO}from"./studio-gxphbetb.js";import{re}from"./studio-ft706q02.js";import{me,Os,te,b,le}from"./studio-y3tjh2xb.js";import{fs,vr}from"./studio-213pyfxh.js";import{n,J,qe,S,f}from"./studio-0z8kp4xk.js";function ie(e,o=[]){if(e?.tagName==="slot"){let s=e.attributes?.name;o.push(n(s)?s.trim():"")}if(Array.isArray(e?.children))for(let s of e.children)ie(n(s)?void 0:s,o);return o}function oC(e){let o=ie(e),s=o.filter((r)=>r==="").length;if(s>1)return`Component has ${s} unnamed <slot> elements — only one default slot is allowed. Give extra slots a name attribute.`;let l=new Set;for(let r of o){if(r&&l.has(r))return`Duplicate slot name "${r}" — slot names must be unique within a component.`;l.add(r)}return null}var se={invokerTags:Zy,popoverTags:Ah},N="Popover",xe={display:"document.repairPopoverDisplay","open-display":"document.repairPopoverDisplay",invoker:"document.repairPopoverInvoker",mode:"document.repairPopoverMode"};function ae(e,o,s,l){let r=`${o}.${s}.${l.join("/")}`,d=e.get(r)??0;return e.set(r,d+1),d===0?r:`${r}#${d}`}function H(e,o){Sl((d)=>d.source===N);let s=new Map,l=TM(e,se);for(let d of l){let c=d.fix===void 0?void 0:xe[d.fix],C={detail:d.detail,key:ae(s,"popover",d.rule,d.path),source:N,tier:"problem"};if(c!==void 0)C.action=c,C.actionArgs={path:d.path};if(o!==void 0)C.path=o;w(d.severity,d.message,C)}let r=tA(e,se);for(let d of r){let c={detail:d.detail,key:ae(s,"dialog",d.rule,d.path),source:N,tier:"problem"};if(o!==void 0)c.path=o;w(d.severity,d.message,c)}return l.length+r.length}function W(e,o){let s=o?.path;if(!Array.isArray(s))throw RangeError(`command "${e}" needs a "path" argument naming the popover`);return s}function I(e){let o=h.value;if(!o)throw RangeError(`command "${e}" needs an open document`);return o}function Se(){return[{category:"Document",group:"2_document",id:"document.checkPopovers",level:"document",menus:["palette"],requires:"an open document",run:()=>{let e=I("document.checkPopovers"),o=H(e.doc.document,e.documentPath??void 0);w.success(o===0?"No popover problems found in this document.":`${o} popover problem(s) filed.`,{key:"popover.run",source:N})},title:"Check Popovers",when:(e)=>e.document.open,aiTool:{description:"Check the open document for popover defects an author can fix — a base-rule `display` "+"that defeats the browser's own hiding of a closed popover, `popovertarget` on an "+"element that cannot invoke, a target naming no popover, a cut exit animation — and "+"file each as a Problem. The findings come back as data.",name:"check_popovers",report:()=>{let e=cf(N),o=e.length;return{data:e,summary:o===0?"No popover problems found in this document.":`Filed ${o} popover problem${o===1?"":"s"} in Problems.`}}}},{args:{additionalProperties:!1,properties:{path:{items:{type:["string","number"]},type:"array"}},required:["path"],type:"object"},category:"Document",group:"2_document",id:"document.repairPopoverDisplay",level:"document",menus:[],requires:"a popover whose base rule sets display",run:(e,o)=>{let l=I("document.repairPopoverDisplay"),r=W("document.repairPopoverDisplay",o),d=re(l.doc.document,r),c=$M(d?.style);if(!c)throw RangeError(`command "${"document.repairPopoverDisplay"}": nothing to move — this popover sets no display`);X(l,(C)=>{for(let v of c.base)rg(C,r,v,"");for(let v of c.breakpoints)g_(C,r,[v],"display","");if(c.openDisplay!==null)m_(C,r,":popover-open","display",c.openDisplay)}),w.success("Moved `display` into `:popover-open`.",{key:"popover.repaired.display",source:N})},title:"Move display into :popover-open",when:(e)=>e.document.open},{args:{additionalProperties:!1,properties:{path:{items:{type:["string","number"]},type:"array"}},required:["path"],type:"object"},category:"Document",group:"2_document",id:"document.repairPopoverInvoker",level:"document",menus:[],requires:"an element carrying popovertarget that cannot invoke",run:(e,o)=>{let l=I("document.repairPopoverInvoker"),r=W("document.repairPopoverInvoker",o);X(l,(d)=>{Co(d,r,"popovertarget"),Co(d,r,"popovertargetaction")}),w.success("Removed the attributes, which did nothing on this element.",{key:"popover.repaired.invoker",source:N})},title:"Remove the inert popover attributes",when:(e)=>e.document.open},{args:{additionalProperties:!1,properties:{path:{items:{type:["string","number"]},type:"array"}},required:["path"],type:"object"},category:"Document",group:"2_document",id:"document.repairPopoverMode",level:"document",menus:[],requires:"a popover whose mode is not one of the three keywords",run:(e,o)=>{let l=I("document.repairPopoverMode"),r=W("document.repairPopoverMode",o);X(l,(d)=>{Co(d,r,"popover",dI)}),w.success(`Set \`popover\` to "${dI}".`,{key:"popover.repaired.mode",source:N})},title:"Set popover to auto",when:(e)=>e.document.open}]}function hO(e){e.registerAll(Se())}function ex(e,o){if(e===o)return!0;if(Array.isArray(e)&&Array.isArray(o))return e.length===o.length&&e.every((s,l)=>s===o[l]);if(S(e)&&S(o)&&!Array.isArray(e)&&!Array.isArray(o))return e.$ref===o.$ref;return!1}var A="grid://",Hb={children:[],tagName:"div"};function ls(e){switch(e.kind){case"pages":return`${A}pages`;case"collection":return`${A}collection/${encodeURIComponent(e.name)}`;default:return`${A}data/${encodeURIComponent(e.connection)}/${encodeURIComponent(e.table)}`}}function Pe(e){return e.startsWith(A)}function Ql(e){if(!Pe(e))return null;let o=e.slice(A.length).split("/");if(o[0]==="pages"&&o.length===1)return{kind:"pages"};if(o[0]==="collection"&&o.length===2&&o[1])return{kind:"collection",name:decodeURIComponent(o[1])};if(o[0]==="data"&&o.length===3&&o[1]&&o[2])return{connection:decodeURIComponent(o[1]),kind:"data",table:decodeURIComponent(o[2])};return null}function Pm(e){let o=Ql(e);if(!o)return null;switch(o.kind){case"pages":return"Pages · grid";case"collection":return`${o.name} · grid`;default:return`${o.table} @ ${o.connection} · grid`}}var ce=0;function de(e){let o=e.coalesceMs??800,s=e.now??(()=>Date.now()),r=b({deletes:new Set,errors:new Map,inserts:new Map,pending:new Map,redoStack:[],stale:new Set,undoStack:[]}),d=null,c=(t,i,a)=>{let u=r.errors.get(t);if(u)u.set(i,a);else r.errors.set(t,new Map([[i,a]]))},C=(t,i)=>{let a=r.errors.get(t);if(a?.delete(i),a?.size===0)r.errors.delete(t)},v=(t)=>{if(r.redoStack.length=0,d){d.push(t);return}let i=r.undoStack.at(-1);if(t.kind==="cell"&&i?.kind==="cell"&&i.rowKey===t.rowKey&&i.field===t.field&&t.at-i.at<=o){i.after=t.after,i.at=t.at;return}r.undoStack.push(t)},k=(t,i,a)=>{let u=r.inserts.get(t);if(u){if(a===null)delete u[i];else u[i]=a;return}if(ex(a,e.resolveBaseline(t,i))){let m=r.pending.get(t);if(m?.delete(i),m?.size===0)r.pending.delete(t);return}let y=r.pending.get(t);if(y)y.set(i,{value:a});else r.pending.set(t,new Map([[i,{value:a}]]))},G=(t,i)=>{let a=r.inserts.get(t);if(a)return a[i]??null;let u=r.pending.get(t)?.get(i);return u?u.value:e.resolveBaseline(t,i)},M=(t,i)=>{let a=r.errors.get(t);return a?.get(i)??a?.get("*")??null},F=(t,i)=>{switch(t.kind){case"cell":{k(t.rowKey,t.field,i==="undo"?t.before:t.after);break}case"insert":{if(i==="undo")r.inserts.delete(t.tempKey);else r.inserts.set(t.tempKey,{...t.cells});break}case"drop-insert":{if(i==="undo")r.inserts.set(t.tempKey,{...t.cells});else r.inserts.delete(t.tempKey);break}case"delete":{if(i==="undo")r.deletes.delete(t.rowKey);else r.deletes.add(t.rowKey);break}default:{let a=i==="undo"?t.ops.toReversed():t.ops;for(let u of a)F(u,i);break}}},D=()=>{if(d)throw Error("edit-buffer: groups may not nest");d=[]},P=()=>{let t=d;if(d=null,!t)return;if(t.length===1)r.undoStack.push(t[0]);else if(t.length>1)r.undoStack.push({kind:"group",ops:t})},T=(t)=>{let i=(a)=>{switch(a.kind){case"cell":return t(a.rowKey)?null:a;case"insert":case"drop-insert":return t(a.tempKey)?null:a;case"delete":return t(a.rowKey)?null:a;default:{let u=a.ops.map((y)=>i(y)).filter((y)=>y!==null);return u.length>0?{kind:"group",ops:u}:null}}};r.undoStack=r.undoStack.map(i).filter((a)=>a!==null),r.redoStack=r.redoStack.map(i).filter((a)=>a!==null)};return{applyCommitResult(t){let i=new Set;for(let a of t.cells)if(a.ok){let u=r.pending.get(a.rowKey);if(u?.delete(a.field),u?.size===0)r.pending.delete(a.rowKey);C(a.rowKey,a.field)}else if(c(a.rowKey,a.field,a.error??"Save failed"),a.stale)r.stale.add(a.rowKey);for(let a of t.inserts)if(a.ok)r.inserts.delete(a.tempKey),r.errors.delete(a.tempKey),i.add(a.tempKey);else c(a.tempKey,"*",a.error??"Insert failed");for(let a of t.deletes)if(a.ok)r.deletes.delete(a.rowKey),r.pending.delete(a.rowKey),r.errors.delete(a.rowKey),i.add(a.rowKey);else if(c(a.rowKey,"*",a.error??"Delete failed"),a.stale)r.stale.add(a.rowKey);for(let a of i)r.stale.delete(a);if(i.size>0)T((a)=>i.has(a))},buildBatch(){let t=[];for(let[i,a]of r.pending){if(r.deletes.has(i))continue;for(let[u,y]of a)t.push({baseline:e.resolveBaseline(i,u),field:u,rowKey:i,value:y.value})}return{cells:t,deletes:[...r.deletes].map((i)=>({rowKey:i})),inserts:[...r.inserts].map(([i,a])=>({cells:{...a},tempKey:i}))}},canRedo:()=>r.redoStack.length>0,canUndo:()=>r.undoStack.length>0,cellError:M,cellState(t,i){if(M(t,i)!==null)return"error";if(r.stale.has(t))return"stale";if(r.inserts.has(t)||r.pending.get(t)?.has(i))return"dirty";return"clean"},deleteRow(t){if(r.deletes.has(t))return;let i=r.inserts.get(t);if(i){let a={...i};r.inserts.delete(t),r.errors.delete(t),r.stale.delete(t),v({cells:a,kind:"drop-insert",tempKey:t});return}r.deletes.add(t),v({kind:"delete",rowKey:t})},dirtyCount(){let t=r.inserts.size+r.deletes.size;for(let[i,a]of r.pending)if(!r.deletes.has(i))t+=a.size;return t},discardRow(t){r.pending.delete(t),r.deletes.delete(t),r.inserts.delete(t),r.errors.delete(t),r.stale.delete(t),T((i)=>i===t)},effectiveValue:G,beginGroup:D,endGroup:P,group(t){D();try{t()}finally{P()}},insertRow(t={}){ce+=1;let i=`__new-${ce}`;return r.inserts.set(i,{...t}),v({cells:{...t},kind:"insert",tempKey:i}),i},isDirty:()=>r.pending.size>0||r.inserts.size>0||r.deletes.size>0,isInsertKey:(t)=>r.inserts.has(t),markStale(t){for(let i of t)r.stale.add(i)},redo(){let t=r.redoStack.pop();if(!t)return!1;return F(t,"redo"),r.undoStack.push(t),!0},reset(){r.pending.clear(),r.inserts.clear(),r.deletes.clear(),r.errors.clear(),r.stale.clear(),r.undoStack.length=0,r.redoStack.length=0},rowState(t){if(r.deletes.has(t))return"pending-delete";if(r.inserts.has(t))return"pending-insert";if(r.stale.has(t))return"stale";if(r.pending.has(t)||r.errors.has(t))return"dirty";return"clean"},setCell(t,i,a){let u=G(t,i);if(ex(u,a))return;k(t,i,a),v({after:a,at:s(),before:u,field:i,kind:"cell",rowKey:t})},state:r,undo(){let t=r.undoStack.pop();if(!t)return!1;return F(t,"undo"),r.redoStack.push(t),!0}}}var ue={array:220,boolean:70,date:130,enum:140,image:180,number:110,readonly:200,reference:200,string:180,text:340};function fe(e){return Math.min(340,Math.max(90,Math.round(e*7.5)))}function Ge(e){if(e.$ref)return"reference";if(e.enum!==void 0&&Array.isArray(e.enum))return"enum";let o=e.type==="array"?void 0:e.format;if(Aa(o))return"image";if(o==="date"||o==="date-time")return"date";switch(e.type){case"number":case"integer":return"number";case"boolean":return"boolean";case"array":return"array";case"object":return"readonly";default:return(e.maxLength??0)>200||e.format==="markdown"?"text":"string"}}function pe(e){let o=e.replaceAll(/([a-z0-9])([A-Z])/g,"$1 $2").replaceAll(/[_-]+/g," ").trim();return o.charAt(0).toUpperCase()+o.slice(1)}function tx(e,o={}){let s=Object.entries(e?.properties??{}),l=new Set(e?.required),r=new Set(o.readonlyFields),d=s.map(([c,C])=>{let v=r.has(c)?"readonly":Ge(C),k=Array.isArray(C.enum)?Math.max(...C.enum.map((G)=>String(G).length),4):0;return{editable:v!=="readonly",field:c,kind:v,pk:c===o.idField,required:l.has(c),schema:C,title:pe(c),widthHint:v==="enum"?fe(k+3):ue[v]}});return d.sort((c,C)=>{let v=(G)=>G.pk?0:G.required?1:2,k=v(c)-v(C);return k===0?0:k}),d}function nx(e,o=50){let s=e.slice(0,o),l=[];for(let r of s)for(let d of Object.keys(r))if(!l.includes(d))l.push(d);return l.map((r)=>{let d=s.flatMap((v)=>{let k=v[r];return k===null||k===void 0||k===""?[]:[k]}),c=Re(d),C=Math.max(...d.map((v)=>eo(v).length),r.length,4);return{editable:!0,field:r,kind:c,title:pe(r),widthHint:c==="string"||c==="text"?fe(C):ue[c]}})}function Re(e){if(e.length===0)return"string";if(e.some((s)=>Array.isArray(s)))return"array";let o=e.map(String);if(e.every((s)=>qe(s))||o.every((s)=>/^(true|false)$/i.test(s)))return"boolean";if(e.every((s)=>J(s))||o.every((s)=>s.trim()!==""&&!Number.isNaN(Number(s.replaceAll(/[$€£¥,\s]/g,"")))))return"number";if(o.every((s)=>/^\d{4}-\d{2}-\d{2}([T ].*)?$/.test(s)))return"date";if(o.some((s)=>s.length>200))return"text";return"string"}function Ip(e,o){if(e===null||e===void 0)return null;switch(o.kind){case"number":{if(J(e))return Number.isNaN(e)?null:e;let s=String(e).trim().replaceAll(/[$€£¥,\s]/g,"");if(s==="")return null;let l=Number(s);return Number.isNaN(l)?null:l}case"boolean":{if(qe(e))return e;return String(e).trim().toLowerCase()==="true"}case"array":{if(Array.isArray(e))return e.map(String);let s=String(e).trim();return s===""?[]:s.split(",").map((l)=>l.trim()).filter(Boolean)}case"reference":{if(f(e)&&"$ref"in e){let l=e.$ref;return n(l)&&l!==""?l:null}let s=String(e).trim();return s===""?null:s}default:{let s=String(e);return s===""?null:s}}}function eo(e){if(e===null||e===void 0)return"";if(Array.isArray(e))return e.join(", ");if(S(e))return e.$ref;return String(e)}var rC="__key",Y=new WeakMap;function to(e){return e?Y.get(le(e))??null:null}function Np(e,o){let l=b({columns:[],error:null,grouping:null,loading:!1,query:{},rows:[],saving:!1,total:0}),r=new Map,d=(t)=>{r=new Map(t.map((i)=>[i.key,i]))},c=de({resolveBaseline:(t,i)=>r.get(t)?.cells[i]??null}),C=async()=>{let t=await o.rows(l.query);d(t.rows),l.rows=t.rows,l.total=t.total},v=(t)=>{let i=l.columns.filter((y)=>y.required&&y.editable);if(i.length===0)return null;let a=t.cells.filter((y)=>y.value===null&&i.some((m)=>m.field===y.field)).map((y)=>({error:"Required",field:y.field,ok:!1,rowKey:y.rowKey})),u=t.inserts.filter((y)=>i.some((m)=>y.cells[m.field]===null||y.cells[m.field]===void 0)).map((y)=>({error:`Missing required: ${i.filter((R)=>y.cells[R.field]===null||y.cells[R.field]===void 0).map((R)=>R.field).join(", ")}`,ok:!1,tempKey:y.tempKey}));if(a.length===0&&u.length===0)return null;return{cells:a,deletes:[],inserts:u}},k=(t)=>t===null||t===""||Array.isArray(t)&&t.length===0,G=(t,i,a)=>{if(a==="number")return(J(t)?t:0)-(J(i)?i:0);if(a==="boolean")return(t===!0?1:0)-(i===!0?1:0);return eo(t).localeCompare(eo(i))},M=()=>{let t=l.rows.map((u)=>u.key),{dir:i,orderBy:a}=l.query;if(a&&!o.capabilities.remoteSort){let u=l.columns.find((m)=>m.field===a)?.kind,y=i==="desc"?-1:1;t=t.toSorted((m,R)=>{let E=c.effectiveValue(m,a),L=c.effectiveValue(R,a);if(k(E)!==k(L))return k(E)?1:-1;return y*G(E,L,u)})}return l.grouping?[...F(t).values()].flat():t},F=(t)=>{let i=new Map;for(let a of t){let u=eo(c.effectiveValue(a,l.grouping)),y=i.get(u);if(y)y.push(a);else i.set(u,[a])}return i},D=null,P=()=>D?.refreshData(),T={addRow(t={}){let i=c.insertRow(t);return P(),i},bindView(t){D=t},buffer:c,deleteRows(t){if(t.length===0)return;c.group(()=>{for(let i of t)c.deleteRow(i)}),P()},discardRow(t){c.discardRow(t),P()},replaceAll(t,i){if(t==="")return 0;let a=l.columns.filter((m)=>m.editable&&(m.kind==="string"||m.kind==="text")),u=[...l.rows.map((m)=>m.key),...c.state.inserts.keys()],y=0;if(c.group(()=>{for(let m of u){if(c.rowState(m)==="pending-delete")continue;for(let R of a){let E=c.effectiveValue(m,R.field);if(n(E)&&E.includes(t))c.setCell(m,R.field,E.replaceAll(t,i)),y+=1}}}),y>0)P();return y},effectiveRows(){let t=(u)=>Array.isArray(u)?[...u]:S(u)?{$ref:u.$ref}:u,i=(u)=>{let y=[[rC,u]];for(let m of l.columns)y.push([m.field,t(c.effectiveValue(u,m.field))]);return Object.fromEntries(y)},a=M().map((u)=>i(u));for(let[u]of c.state.inserts)a.push(i(u));return a},groups(){if(!l.grouping)return[];return[...F(M())].map(([t,i])=>({count:i.length,value:t}))},async load(){l.loading=!0,l.error=null;try{l.columns=await o.columns(),await C()}catch(t){l.error=Z(t)}finally{l.loading=!1}P()},async refresh(){if(c.isDirty()){if(!await Kr("Refresh Grid",`Discard ${c.dirtyCount()} pending change(s) and reload?`,{confirmLabel:"Discard & Reload",destructive:!0}))return}c.reset(),await o.refresh?.(),await this.load()},async save(){if(l.saving)return;let t=c.buildBatch(),i=t.cells.length+t.inserts.length+t.deletes.length;if(i===0){w.info("No grid changes to save.",{key:"grid.save"});return}let a=v(t);if(a){c.applyCommitResult(a),w.warn("Required cells are empty — fix the marked rows, then save again.",{key:"grid.save",source:"Data",tier:"problem"});return}if(t.deletes.length>0){if(!await Kr("Delete Rows",`Save will permanently delete ${t.deletes.length} row(s). Continue?`,{confirmLabel:"Delete & Save",destructive:!0}))return}let y=new Set(t.cells.map((m)=>m.rowKey)).size+t.inserts.length+t.deletes.length>5?cl({title:"Saving grid"}):null;l.saving=!0;try{let m=await o.commit(t),R=(x,j)=>`${x}\x00${j}`,E=new Map(t.cells.map((x)=>[R(x.rowKey,x.field),x]));for(let x of m.cells){let j=E.get(R(x.rowKey,x.field));if(x.ok&&j){let oe=r.get(x.rowKey);if(oe)oe.cells[x.field]=j.value}}if(c.applyCommitResult(m),m.inserts.some((x)=>x.ok)||m.deletes.some((x)=>x.ok))await C();let z=m.cells.filter((x)=>x.ok).length+m.inserts.filter((x)=>x.ok).length+m.deletes.filter((x)=>x.ok).length,ee=i-z,ne=m.cells.filter((x)=>x.stale).length+m.deletes.filter((x)=>x.stale).length;if(ee===0)w.success(`Saved ${z} change(s).`,{key:"grid.save"});else w.error(`Saved ${z} · ${ee} failed${ne?` (${ne} stale)`:""} — kept pending.`,{action:"file.save",key:"grid.save",source:"Data"})}catch(m){w.error("Could not save the grid.",{action:"file.save",detail:Z(m),key:"grid.save",source:"Data"})}finally{l.saving=!1,y?.done(),P()}},serializeForSource(){if(!o.serializeForSource)return null;return o.serializeForSource(c.buildBatch())},async setQuery(t){l.query=t,l.loading=!0;try{await C()}catch(i){l.error=Z(i)}finally{l.loading=!1}P()},setGrouping(t){l.grouping=t,P()},async setSort(t){let i={...l.query};if(t)i.orderBy=t.field,i.dir=t.dir;else delete i.orderBy,delete i.dir;if(!o.capabilities.remoteSort){l.query=i,P();return}await this.setQuery(i)},source:o,state:l,tab:e};return e.scope.run(()=>{te(()=>{e.doc.dirty=c.isDirty()}),Xd(e,{canRedo:()=>c.canRedo(),canUndo:()=>c.canUndo(),redo:()=>{c.redo(),P()},undo:()=>{c.undo(),P()}});let t=p();if(t.subscribeFileEvents&&o.backingPaths){let i=t.subscribeFileEvents((a)=>{let u=o.backingPaths(),y=new Set;for(let m of a){if(m.isDir)continue;let R=m.path.replaceAll("\\","/"),E=u.get(R);if(E!==void 0&&!Jd(R))y.add(E)}if(y.size===0)return;if(c.isDirty()){let m=y.has("*")?l.rows.map((R)=>R.key):[...y];c.markStale(m),w.warn("Grid rows changed on disk — marked stale; refresh to reload.",{key:"grid.stale",source:"Data"}),P()}else T.refresh()});Os(i)}Os(()=>{Xd(e,null),Y.delete(le(e)),o.dispose?.()})}),Y.set(le(e),T),T}async function Zu(e){let s=to(e)?.serializeForSource();if(s)return s;await jt();let l=zi(e.doc.sourceFormat);if(l?.capabilities.serialize){let r=e.doc.content.frontmatter,d=e.doc.document,c={...r,...d,children:d.children??[]};return ja(l.name,c,{mode:"roundtrip",...e.doc.source!==null&&{source:e.doc.source}})}if(e.doc.mode==="content"){let r=co();if(r){let d=e.doc.content.frontmatter,c=Object.keys(d).length>0,C={...d,...e.doc.document};return ja(r.name,C,{frontmatter:c,mode:"roundtrip"})}}return vr(yP(e.doc.document,e.doc.bareRepeaters??null),e.doc.layout??null)}var Ee=200,Te=500,Oe=2097152,B=new Map,K=!1,q=null,O=null,V=null,Q=null;function Me(){let e=[];for(let o of g.tabs.values())if(o.doc.dirty&&o.documentPath)e.push(o);return e}async function ge(){if(!we())return;let e=p();if(!e.setPreviewOverlay||!e.clearPreviewOverlay)return;let o=new Set;for(let s of Me()){let l=s.documentPath.replace(/^\.\//,""),r;try{r=await Zu(s)}catch{continue}if(r.length>Oe)continue;if(o.add(l),B.get(l)===r)continue;B.set(l,r),await e.setPreviewOverlay(l,r)}for(let s of B.keys())if(!o.has(s))B.delete(s),await e.clearPreviewOverlay(s)}function ye(){if(!K)return;let e=Date.now();if(V??=e,O)clearTimeout(O);let o=e-V,s=Math.max(0,Math.min(Ee,Te-o));O=setTimeout(()=>{O=null,V=null,Q=ge().finally(()=>{Q=null})},s)}function pO(){ye()}function fO(){if(K)return;K=!0,q=me(),q.run(()=>{te(()=>{for(let e of g.tabs.values())e.doc.dirty,e.doc.document;ye()})})}function mO(){if(K=!1,O)clearTimeout(O),O=null;V=null,q?.stop(),q=null,B.clear()}async function sC(){if(!K)return;if(O)clearTimeout(O),O=null,V=null;await Q,await ge()}var he=/^[A-Za-z0-9][A-Za-z0-9!#$&^_.+-]{0,126}$/,$e=new Set(["vnd","prs","x"]);function Fe(e){if(!n(e))return null;let[o,...s]=e.split(";"),l=(o??"").indexOf("/");if(l===-1)return null;let r=(o??"").slice(0,l).trim().toLowerCase(),d=(o??"").slice(l+1).trim().toLowerCase();if(!he.test(r)||!he.test(d))return null;let c=d.lastIndexOf("+"),C=c===-1?null:d.slice(c+1),v=c===-1?d:d.slice(0,c);if(C==="")return null;let k=v.indexOf("."),G=k===-1?null:v.slice(0,k),M=G!==null&&$e.has(G)?G:null,F=M===null?v:v.slice(M.length+1);if(F==="")return null;let D={};for(let P of s){let T=P.indexOf("=");if(T===-1)return null;let t=P.slice(0,T).trim().toLowerCase(),i=P.slice(T+1).trim();if(t==="")return null;if(i.startsWith('"')&&i.endsWith('"')&&i.length>=2)i=i.slice(1,-1);D[t]=i}return{parameters:D,subtype:F,suffix:C,tree:M,type:r}}function ix(e){let o=Fe(e);if(o===null)return null;let s=o.tree===null?"":`${o.tree}.`,l=o.suffix===null?"":`+${o.suffix}`;return`${o.type}/${s}${o.subtype}${l}`}var be="text/markdown; variant=GFM",ve="application/yaml",Tt={".jxn":"text/plain; charset=utf-8",".markdown":`${be}; charset=utf-8`,".md":`${be}; charset=utf-8`,".yaml":`${ve}; charset=utf-8`,".yml":`${ve}; charset=utf-8`};async function gO(e,o){let s=await QR(e.name,o);return eI(e,s)}async function Vo(e,o){await jt();let s=fn(e);if(!s||!s.capabilities.parse)throw hf(e);return{...await gO(s,o),format:s}}var p$=async(e,o)=>{if(e.documentPath&&fn(e.documentPath)){let l=await Vo(e.documentPath,o);return e.doc.source=o,{document:l.document,frontmatter:l.frontmatter}}let s=fs(o);return e.doc.layout=s.layout,{document:s.document}};function De(e){return"showOpenFilePicker"in e}function Ne(e){return"showSaveFilePicker"in e}function U(e,o){if(e.documentPath!==null)o.path=e.documentPath;return o}async function zF(){try{await jt();let e=su(),o=[{accept:{"application/json":[".json"]},description:"Jx Component"},...e.filter((r)=>r.capabilities.parse).map((r)=>({accept:{[ix(r.mediaType)??"text/plain"]:r.extensions},description:r.name}))],s=[".json",...e.flatMap((r)=>r.extensions)].join(","),l=async(r,d,c=null)=>{let C=c?await bO(r):null,v=fn(r);if(v){let{document:k,frontmatter:G}=await gO(v,d);Si({document:k,documentPath:C,fileHandle:c,frontmatter:G,id:r,source:d,sourceFormat:v.name})}else if(r.endsWith(".json")){let{document:k,layout:G}=fs(d);Si({document:k,documentPath:C,fileHandle:c,id:r,layout:G})}else throw hf(r)};if(De(window)){let[r]=await window.showOpenFilePicker({types:o}),d=await r.getFile();await l(r.name,await d.text(),r)}else{let r=document.createElement("input");r.type="file",r.accept=s,r.addEventListener("change",async()=>{let d=r.files?.[0];if(!d)return;await l(d.name,await d.text())}),r.click()}}catch(e){if(!(e instanceof Error&&e.name==="AbortError"))w.error("Could not open the file.",{detail:Z(e),source:"Open File"})}}var Ce=()=>{};function f$(e){Ce=e}function _(e){let o=e.doc.document;Ce(e.documentPath,o,e);let s=n(o.tagName)&&o.tagName.includes("-")?oC(o):null;if(s)w.warn(s,U(e,{key:`slots:${e.documentPath??e.id}`,source:"Components",tier:"problem"}));H(o,e.documentPath??void 0)}function Ae(e){return!zd(e.documentPath??"")}async function Dp(e=h.value){if(!e)return!1;if(await EL(e.id),ra(e))return w.warn(`You have read access to this session — changes to ${e.documentPath??"this document"} stay in your browser and cannot be saved.`,U(e,{action:"file.save",key:`save.readOnly:${e.documentPath??e.id}`,source:"Collaboration"})),!1;if(!Ae(e)){if(La(e)===ds||dl(e))return K$(e);return w.warn(`${e.documentPath??"This file"} is a media file, so there is no document for Save to write.`,U(e,{key:`save.notADocument:${e.documentPath??e.id}`,source:"Save"})),!1}let o=to(e);if(o)return await o.save(),!e.doc.dirty;try{if(await RR(e))return _(e),!0;let s=await Zu(e);if(e.documentPath){if(await p().writeFile(e.documentPath,s),e.doc.dirty=!1,e.doc.sourceFormat!==null)e.doc.source=s;return sC(),_(e),!0}if(e.fileHandle&&"createWritable"in e.fileHandle){let l=await e.fileHandle.createWritable();if(await l.write(s),await l.close(),e.doc.dirty=!1,e.doc.sourceFormat!==null)e.doc.source=s;return _(e),!0}w.warn("This document has no save target — use Export.",{key:"save.noTarget"})}catch(s){if(!(s instanceof Error&&s.name==="AbortError"))w.error(`Could not save ${e.documentPath??e.id}.`,U(e,{action:"file.save",detail:Z(s),key:`save:${e.documentPath??e.id}`,source:"Save"}))}return!1}function Be(e){return zi(e.doc.sourceFormat)??(e.doc.mode==="content"?co():void 0)}async function m$(){let e=h.value;if(!e)return;try{await jt();let o=Be(e),s=await Zu(e),l=o?ix(o.mediaType)??"text/plain":"application/json",r=o?o.extensions[0]:".json",d=o?o.name:"Jx Component",c=o?`content${r}`:"component.json";if(Ne(window)){let C=e.documentPath?e.documentPath.split("/").pop():c,v=await window.showSaveFilePicker({suggestedName:C,types:[{accept:{[l]:[r]},description:d}]}),k=await v.createWritable();await k.write(s),await k.close(),e.doc.dirty=!1,_(e),w.success(`Exported as ${v.name}.`)}else{let C=new Blob([s],{type:l}),v=URL.createObjectURL(C),k=document.createElement("a");k.href=v,k.download=c,k.click(),URL.revokeObjectURL(v),e.doc.dirty=!1,_(e),w.success(`Downloaded ${c}.`)}}catch(o){if(!(o instanceof Error&&o.name==="AbortError"))w.error("Could not export the document.",{detail:Z(o),source:"Export"})}}async function ke(e,o){let s=zd(e)?await eh(e):await Na({path:e});return SR(s,o)??""}async function Bb(e){let o=await ke(e.path,"delete"),s=`Delete ${e.name}? This cannot be undone.`;return Boolean(await Kr("Delete File",o===""?s:`${s} ${o}`,{confirmLabel:"Delete",destructive:!0}))}async function Vb(e,o="rename"){let s=await ke(e,o);return s===""?void 0:s}
|
|
2
|
+
export{ex,Hb,ls,Ql,Pm,tx,nx,Ip,eo,rC,to,Np,oC,hO,Zu,pO,fO,mO,sC,ix,gO,Vo,p$,zF,f$,Dp,m$,Bb,Vb};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
5
|
-
//# sourceMappingURL=studio-
|
|
4
|
+
//# debugId=B2B5EA5C5E34870164756E2164756E21
|
|
5
|
+
//# sourceMappingURL=studio-a4ymg4vd.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{n,J,qe,Q,S,f,Oe,Ir,Gn,Ef,rt}from"./studio-0z8kp4xk.js";var My=400;var of=350,L1=300,sM=30000;function so(e){return Array.isArray(e?.children)?e.children:[]}function Fy(e,t,i=""){if(!S(e))return e;if(Array.isArray(e)){for(let[l,s]of e.entries())Fy(s,t,`${i}/${l}`);return e}let r=e,{children:o}=r;if(Ir(o)){let l=o;t?.(i,l),r.children=[l]}if(Array.isArray(r.children))for(let[l,s]of r.children.entries())Fy(s,t,`${i}/children/${l}`);if(r.$prototype==="Array"&&S(r.map))Fy(r.map,t,`${i}/map`);if(S(r.cases))for(let[l,s]of Object.entries(r.cases))Fy(s,t,`${i}/cases/${JR(l)}`);return e}function JR(e){return String(e).replaceAll("~","~0").replaceAll("/","~1")}function zt(e){return e.length>=2?e.slice(0,-2):null}function Wi(e){return e.at(-1)}function KR(e){return e.join("/")}function Eo(e,t){if(e===t)return!0;if(!e||!t||e.length!==t.length)return!1;return e.every((i,r)=>i===t[r])}function Th(e,t=[],i=0){let r=[];return u(e,t,i,r,!1),r}function u(e,t,i,r,o){if(n(e)||J(e)||qe(e)){if(!o)r.push({depth:i,node:e,nodeType:"text",path:t});return}if(e.$prototype==="Array"){if(!o)r.push({depth:i,node:e,nodeType:"map",path:t});let s=e.map;if(S(s))u(s,[...t,"map"],i+1,r,!1);return}if(!o)r.push({depth:i,node:e,nodeType:"element",path:t});if(e.$props&&rt(e.tagName).includes("-")&&!Array.isArray(e.children))return;let{children:l}=e;if(Array.isArray(l))for(let s=0;s<l.length;s++){let a=[...t,"children",s];u(l[s],a,i+1,r,!1)}else if(Ir(l))u(l,[...t,"children"],i+1,r,!1);if(e.$switch&&S(e.cases))for(let[s,a]of Object.entries(e.cases)){let d=[...t,"cases",s];if(S(a)&&a.$ref)r.push({depth:i+1,node:a,nodeType:"case-ref",path:d});else if(S(a))r.push({depth:i+1,node:a,nodeType:"case",path:d}),u(a,d,i+2,r,!0)}}function To(e){if(!e)return"?";if(e.$prototype==="Array"){let{items:r}=e;return`Repeater → ${(Oe(r)?r.$ref:void 0)||"items"}`}if(e.$title)return e.$title;if(e.$id)return e.$id;if(e.tagName==="slot"){let r=e.attributes?.name;return n(r)&&r.trim()?`slot: ${r.trim()}`:"slot"}let t=rt(e.tagName)||"div",i=e.$switch?" ⇆":"";if(n(e.textContent)&&e.textContent.length>0)return`${t} — ${e.textContent.slice(0,24)}${i}`;return t+i}var x=null;function od(e){x=e}function _n(){return x}function ru(e){return S(e)}function sf(e){if(Array.isArray(e))return e.map((i)=>sf(i));if(!Gn(e))return e;let t={};for(let[i,r]of Object.entries(e)){if(i.startsWith("on")&&Ef(r))continue;if(i==="children")t.children=Array.isArray(r)?r.map((o)=>sf(o)):sf(r);else if(i==="cases"&&ru(r)){let o={};for(let[l,s]of Object.entries(r))o[l]=sf(s);t.cases=o}else if(i==="state"&&ru(r)){let o={};for(let[l,s]of Object.entries(r)){if(f(s)&&s.timing==="server")continue;o[l]=s}t.state=o}else t[i]=r}return t}var R1=null,$h=null,GR=null,YR=null,ZR=null;function c(e){let t=document.querySelector(`#${e}`);return t instanceof HTMLElement?t:null}function aM(){R1=c("activity-bar"),$h=c("left-panel"),GR=c("right-panel"),YR=c("toolbar"),ZR=c("statusbar")}function af(e,t){if(!e)throw TypeError(`#${t} is not in the shell yet; initShellRefs() has not found it`);return e}var dg=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),XR=[":hover",":focus",":active",":focus-within",":focus-visible",":disabled",":first-child",":last-child","::before","::after","::placeholder"];function y_(e){return e.startsWith(":")||e.startsWith(".")||e.startsWith("&")||e.startsWith("[")}var p=new Map;function v_(e,t,i){let r=t??My;return(...o)=>{clearTimeout(p.get(e)),p.set(e,setTimeout(()=>{p.delete(e),i(...o)},r))}}function lM(e){clearTimeout(p.get(e)),p.delete(e)}var b=new Map;function T(e){return(S(e)||Q(e))&&"then"in e&&Q(e.then)}var m=0;function cM(){return m}function h(e,t){m+=1;let i=()=>{m-=1},r=null;try{let o=t();if(T(o))r=o}catch(o){console.error(`Renderer "${e}" failed:`,o)}if(!r){i();return}r.then(i,(o)=>{console.error(`Renderer "${e}" failed:`,o),i()})}function ug(e,t){b.set(e,t)}function ao(){for(let[e,t]of b.entries())h(e,t)}function wn(...e){for(let t of e){let i=b.get(t);if(!i)continue;h(t,i)}}function _l(e,t){if(e){if(t.selection!==void 0)e.session.selection=t.selection;if(t.hover!==void 0)e.session.hover=t.hover;if(t.clipboard!==void 0)e.session.clipboard=t.clipboard;if(t.ui)Object.assign(e.session.ui,t.ui);if(t.canvas)Object.assign(e.session.canvas,t.canvas)}}function Ma(e,t,i){if(e)e.session.ui[t]=i}function dM(e,t){if(e)Object.assign(e.session.canvas,t)}
|
|
2
|
+
export{My,of,L1,sM,so,Fy,JR,zt,Wi,KR,Eo,Th,To,x,od,_n,ru,sf,R1,$h,GR,YR,ZR,aM,af,dg,XR,y_,v_,lM,cM,ug,ao,wn,_l,Ma,dM};
|
|
3
|
+
|
|
4
|
+
//# debugId=404BAA9217B327E764756E2164756E21
|
|
5
|
+
//# sourceMappingURL=studio-anc8067x.js.map
|