@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
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import{p}from"./studio-1b79rpcb.js";import{H_}from"./studio-mkjrjpr2.js";import{n,J,f}from"./studio-0z8kp4xk.js";import{ce}from"./studio-nhpg405j.js";var Ie=null,ft=null,ct=null,Rn=!1;function dt(e){return ct=e,Rn=!0,Ie?pt():Promise.resolve()}async function pt(){if(!Rn)return;Rn=!1;try{let{applyProjectSchemas:e}=await (ce("fstdew02"),import("./monaco-setup-fstdew02.js"));e(ct)}catch{}}function hg(){if(Ie)return Promise.resolve(Ie);return ft??=(async()=>{let[e]=await Promise.all([(ce("mb9jzdrw"),import("./editor-mb9jzdrw.js")),(ce("fstdew02"),import("./monaco-setup-fstdew02.js"))]);return Ie=e,await pt(),Ie})(),ft}function df(){return Ie}function Hy(e,t,r){if(!e?.isConnected||t)return!1;return r()}var ur=/\0/u,lr=/^[^\s\\/(){};[\]"#=]+/u;class ht{index;text;constructor(e){this.text=e,this.index=e.codePointAt(0)===65279?1:0}get done(){return this.index>=this.text.length}startsWith(e){return this.text.startsWith(e,this.index)}skipLine(){let e=this.text.indexOf(`
|
|
2
|
+
`,this.index);this.index=e===-1?this.text.length:e}skipBlock(){let e=1;this.index+=2;while(!this.done&&e>0)if(this.startsWith("/*"))e+=1,this.index+=2;else if(this.startsWith("*/"))e-=1,this.index+=2;else this.index+=1}skipTrivia(){for(;;){while(!this.done&&/[\s;]/u.test(this.text.charAt(this.index)))this.index+=1;if(this.startsWith("//"))this.skipLine();else if(this.startsWith("/*"))this.skipBlock();else if(this.startsWith("/-"))this.index+=2,this.skipNode();else return}}skipString(){let e=0,t=this.index;while(this.text.charAt(t)==="#")e+=1,t+=1;let r=this.text.startsWith('"""',t),o=r?'"""':'"',s=o+"#".repeat(e);t+=o.length;while(t<this.text.length)if(e===0&&this.text.charAt(t)==="\\")t+=2;else if(this.text.startsWith(s,t))return this.index=t+s.length,!0;else if(!r&&this.text.charAt(t)===`
|
|
3
|
+
`)return!1;else t+=1;return!1}skipNode(){let e=0;while(!this.done){let t=this.text.charAt(this.index);if(t==='"'||t==="#"&&/^#+"/u.test(this.text.slice(this.index,this.index+16))){if(!this.skipString())return!1}else if(this.startsWith("//"))this.skipLine();else if(this.startsWith("/*"))this.skipBlock();else if(t==="{")e+=1,this.index+=1;else if(t==="}"){if(e===0)return!1;e-=1,this.index+=1}else if((t===`
|
|
4
|
+
`||t===";")&&e===0)return this.index+=1,!0;else this.index+=1}return e===0}}function w_(e){if(ur.test(e))return"unreadable";let t=new ht(e);for(;;){if(t.skipTrivia(),t.done)return"document";if(t.startsWith("(")){let r=e.indexOf(")",t.index);if(r===-1)return"unreadable";t.index=r+1}else{let[r]=lr.exec(e.slice(t.index,t.index+256))??[];if(!r)return t.startsWith('"')||t.startsWith("#")?"document":"unreadable";if(!r.startsWith("$"))return r==="project"?"project":"document";if(t.index+=r.length,!t.skipNode())return"unreadable"}}}var ue=1,_e=2,ge=3,rn=4,on=5,Be=6,sn=7,an=8,Ve=9,le=10,F=11,ve=12,Oe=13,un=14,re=15,ln=16,cn=17,xe=18,fe=19,dn=20,pn=21,hn=22,Fe=23,ye=24;var Y=28;function Pe(e){switch(e){case 9:case 32:case 160:case 5760:case 8192:case 8193:case 8194:case 8195:case 8196:case 8197:case 8198:case 8199:case 8200:case 8201:case 8202:case 8239:case 8287:case 12288:return!0}return!1}function de(e){return e===13||e===10||e===133||e===11||e===12||e===8232||e===8233||!1}function mn(e){return e<8||e>=14&&e<=25||e===127||e>=55296&&e<=57343||e>1114111||e===8206||e===8207||e>=8234&&e<=8238||e>=8294&&e<=8297||e===65279}function I(e){return!isNaN(e)&&!Pe(e)&&!de(e)&&e!==61&&e!==92&&e!==47&&e!==40&&e!==41&&e!==123&&e!==125&&e!==59&&e!==91&&e!==93&&e!==34&&e!==35&&!0}function mt(e){return e>=65&&e<91||e>=97&&e<123||!1}function Mn(e){return e>=48&&e<64||e>=65&&e<71||e>=97&&e<103||!1}function Dn(e){return Mn(e)||e===95}function oe(e){return e>=48&&e<58}function be(e){return oe(e)||e===95}function Ln(e){return e>=48&&e<56}function gt(e){return Ln(e)||e===95}function jn(e){return e===48||e===49}function xt(e){return jn(e)||e===95}function yt(e){return e===45||e===43}var fr;function*cr(e){for(let t of(fr??=new Intl.Segmenter("en")).segment(e))yield t.segment}function dr(e){return e[Symbol.iterator]()}function bt(e,{flags:t,graphemeLocations:r=!1}){let o=r?cr(e):dr(e),s=o.next();return{text:e,graphemeLocations:r,line:1,column:1,offset:0,length:e.length,iterator:o,currentIter:s,current:s.done?NaN:s.value.codePointAt(0),start:{line:1,column:1,offset:0},errorsInToken:null,flags:t}}function*wt(e){if(w(e,65279))e.column=1,yield x(e,_e);if(mn(e.current))throw Z(e,`Invalid character \\u${e.current.toString(16)}`)}function _(e){e.offset+=e.currentIter.value.length,e.column++;let t=e.currentIter=e.iterator.next(),r=e.current=t.done?NaN:t.value.codePointAt(0);if(mn(r))if(r>=55296&&r<=57343||r>1114111)Ue(e,`Invalid character \\u${r.toString(16)}`);else Ue(e,`Invalid character \\u${r.toString(16)}, this character is not allowed but can be included in strings as \\u{${r.toString(16)}}`);return r}function z(e,t){if(t(e.current)){let r=e.current;return _(e),r}}function w(e,t){if(e.current===t)return _(e),t}function ke(e){if(!de(e.current))return!1;if(!e.graphemeLocations&&e.current===13&&e.text.codePointAt(e.offset+1)===10)e.iterator.next(),e.offset++;return _(e),e.column=1,e.line++,!0}function Wn(e,t){while(e.current===t)_(e)}function A(e,t){while(t(e.current))_(e)}function x(e,t,r){let{line:o,column:s,offset:i}=e,a={line:o,column:s,offset:i},l=e.start;e.start=a;let u=e.errorsInToken;e.errorsInToken=null;let c={type:t,text:e.text.slice(l.offset,a.offset),start:l,end:a,errors:u};if(r){if(!c.errors)c.errors=[];c.errors.push(new N(r,{token:c}))}return c}function Z(e,t){if(t instanceof N)return t;let{line:r,column:o,offset:s}=e,i={line:r,column:o,offset:s},a;if(s<e.length)if(de(e.current))a={line:r+1,column:1,offset:s+1};else a={line:r,column:o+1,offset:s+1};return new N(`${t}`,{start:i,end:a})}function Ue(e,t){(e.errorsInToken??=[]).push(Z(e,t))}function we(e){return(t)=>(_(t),x(t,e))}function qe(e){return A(e,Pe),x(e,xe)}function Ne(e){return ke(e),x(e,fe)}function pr(e){_(e);let t=!1,r=!1;if(w(e,34)){if(!w(e,34))return x(e,Ve);if(r=!0,e.current===34)throw Z(e,"Multiline strings must start with exactly three quotes");while(!t&&e.offset<e.length)if(w(e,34)){if(w(e,34)&&w(e,34))t=!0}else w(e,92),ke(e)||_(e)}else while(!t&&e.offset<e.length)if(w(e,34))t=!0;else w(e,92),ke(e)||_(e);if(!t)throw Z(e,"Unexpected EOF inside string");return x(e,r?Fe:Ve)}function Nt(e){if(_(e),e.current===35||e.current===34){let t=1;while(w(e,35))t++;if(!w(e,34))throw Z(e,`Expected a quote after ${"#".repeat(t)}`);let r=!1;if(w(e,34))if(w(e,34)){if(e.current===34)throw Z(e,"Multiline strings must start with exactly three quotes");r=!0}else{let o=0;while(w(e,35))o++;if(o===t)return x(e,le)}while(!0){if(e.offset>=e.length)throw Z(e,"Unexpected EOF while parsing raw string");if(w(e,34)){if(r){if(!w(e,34)||!w(e,34))continue}let o=0;while(o<t&&w(e,35))o++;if(o===t)return x(e,r?ye:le)}else ke(e)||_(e)}}else{let t;if(e.current<255){let r=y[e.current];t=r(e)}else if(Pe(e.current))t=qe(e);else if(de(e.current))t=Ne(e);else t=Vn(e);if(t.type!==F)(t.errors??=[]).push(new N("Expected a valid identifier",{token:t}));return t.type=Oe,t}}function hr(e){if(_(e),z(e,oe))return A(e,I),x(e,F,"Invalid identifier, identifiers that start with a sign and a dot must be quoted if the next character is a digit to prevent confusion with decimal numbers");return A(e,I),x(e,F)}function mr(e){if(_(e),w(e,45))return x(e,ge);else if(w(e,47)){while(e.offset<e.length&&!de(e.current))_(e);return x(e,pn)}else if(w(e,42)){let t=1;while(e.offset<e.length)if(w(e,42)){if(w(e,47)){if(t--,t===0)return x(e,hn)}}else if(w(e,47)){if(w(e,42))t++}else ke(e)||_(e);throw Z(e,"Unexpected EOF in multiline comment")}else xn(e)}function Et(e){return _(e),gr(e)}function gr(e){if(oe(e.current))return K(e);else if(w(e,46)){if(z(e,oe))return A(e,I),x(e,F,"Invalid identifier or number, surround with quotes to make it an identifier or add a zero between the sign and the decimal point");return A(e,I),x(e,F)}else return A(e,I),x(e,F)}function Bn(e,t,r,o){return(s)=>{let i=_(s);if(z(s,r))return A(s,o),x(s,t);else if(!s.flags.experimentalSuffixedNumbers){if(w(s,95)){if(A(s,o),!I(s.current))return x(s,t,`Invalid ${e} number, the first character after 0${String.fromCodePoint(i)} cannot be an underscore`)}return A(s,I),x(s,F,`Invalid ${e} number`)}else if(w(s,95)){if(Wn(s,95),r(s.current)){if(A(s,o),!I(s.current))return x(s,t,`Invalid ${e} number, the first character after 0${String.fromCodePoint(i)} cannot be an underscore`)}return A(s,I),x(s,F,"Invalid number with suffix, a suffix cannot start with a letter followed by an underscore")}else if(oe(s.current))return x(s,F,"Invalid number with suffix, a suffix cannot start with a letter followed by a number");else return A(s,I),x(s,Y)}}var gn=Array(256).fill(null);gn[98]=Bn("binary",cn,jn,xt);gn[111]=Bn("octal",ln,Ln,gt);gn[120]=Bn("hexadecimal",un,Mn,Dn);function K(e){if(w(e,48)){let t=gn[e.current];if(t)return t(e)}if(A(e,be),w(e,46)){if(!z(e,oe))if(e.current===95)Ue(e,"Invalid decimal number, the part after the decimal point mustn't start on an underscore");else Ue(e,"Invalid decimal number, a decimal point must be followed by a digit");A(e,be)}if(w(e,101)||w(e,69))if(z(e,yt),z(e,oe)){if(A(e,be),I(e.current))return A(e,I),x(e,F,"Invalid number with suffix, a number with an exponent cannot have a suffix");return x(e,re)}else if(!e.flags.experimentalSuffixedNumbers)if(e.current===95)return A(e,be),x(e,re,"Invalid decimal number, the number after the exponent mustn't start on an underscore");else return A(e,I),x(e,re,"Invalid decimal number, missing a number after the exponent");else if(w(e,95)){if(Wn(e,95),oe(e.current)){if(A(e,be),!I(e.current))return x(e,re,"Invalid decimal number, the number after the exponent mustn't start on an underscore")}return A(e,I),x(e,F,"Invalid number with suffix, a suffix cannot start with a letter followed by an underscore")}else return A(e,I),x(e,Y);else if(e.flags.experimentalSuffixedNumbers)if(e.current===88||e.current===120){_(e);let t=null;if(z(e,Dn))t="Invalid number with suffix, a suffix cannot start with an x followed by a hexidecimal number";return A(e,I),x(e,Y,t)}else if(z(e,mt)){let t=null;if(z(e,be))t="Invalid number with suffix, a suffix cannot start with a letter followed by a digit";return A(e,I),x(e,Y,t)}else if(w(e,44))return A(e,I),x(e,Y,"Invalid number with suffix, a suffix cannot start with a comma");else if(w(e,46))return A(e,I),x(e,Y,"Invalid number with suffix, a suffix cannot start with a dot");else if(z(e,I))return A(e,I),x(e,Y);else return x(e,re);else return x(e,re)}function xr(e){if(_(e),e.current!=35)return A(e,I),x(e,F);let t=Nt(e);t.start.offset--,t.start.column--;let r;switch(t.type){case le:case ye:r='Invalid raw string, the correct syntax is #" "#, not r#" "#';break;default:r="Invalid token, did you forget a whitespace after this r?"}return(t.errors??=[]).push(new N(r,{token:t})),t}function Vn(e){return _(e),A(e,I),x(e,F)}function xn(e){throw Z(e,`Unexpected character ${JSON.stringify(String.fromCodePoint(e.current))}, did you forget to quote an identifier?`)}var y=Array(255);y.fill(Vn);for(let e=0;e<32;e++)y[e]=xn;y[9]=qe;y[10]=Ne;y[11]=Ne;y[12]=Ne;y[13]=Ne;y[32]=qe;y[34]=pr;y[35]=Nt;y[40]=we(rn);y[41]=we(Be);y[43]=Et;y[45]=Et;y[46]=hr;y[47]=mr;y[48]=K;y[49]=K;y[50]=K;y[51]=K;y[52]=K;y[53]=K;y[54]=K;y[55]=K;y[56]=K;y[57]=K;y[59]=we(an);y[61]=we(ve);y[91]=xn;y[92]=we(dn);y[93]=xn;y[114]=xr;y[123]=we(on);y[125]=we(sn);y[133]=Ne;y[160]=qe;function*He(e,t){let r=bt(e,t);yield*wt(r);while(!r.currentIter.done){if(r.current<255){let o=y[r.current];yield o(r);continue}if(Pe(r.current)){yield qe(r);continue}if(de(r.current)){yield Ne(r);continue}yield Vn(r)}yield x(r,ue)}class N extends Error{name="InvalidKdlError";start;end;token;errors;constructor(e,{token:t,start:r=t?.start,end:o=t?.end,errors:s,...i}={}){if(t?.type===ue)e=`${e} at end of input`;else if(r)e=`${e} at ${r.line}:${r.column}`;super(e,i);this.token=t,this.start=r,this.end=o,this.errors=s}*flat(){if(this.errors==null){yield this;return}for(let e of this.errors)yield*e.flat()}}var $t=new WeakMap;function Ce(e){return $t.get(e)}function At(e,{start:t},{end:r}){$t.set(e,{start:t,end:r})}function Tt({experimentalSuffixedNumbers:e=!1}={}){return{experimentalSuffixedNumbers:e}}class G{type="identifier";static type="identifier";representation;constructor(e){this.name=e}getName(){return this.name}setName(e){if(e!==this.name)this.name=e,this.representation=void 0}clone(){let e=new G(this.name);return e.representation=this.representation,e}}class ee{type="tag";static type="tag";representation;leading;trailing;suffix;constructor(e){this.name,Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!1,value:e})}getName(){return this.name}setName(e){if(e!==this.name)this.name=e,this.representation=void 0}clone(){let e=new ee(this.name);return e.representation=this.representation,e.leading=this.leading,e.trailing=this.trailing,e.suffix=this.suffix,e}}class Q{type="value";static type="value";representation;tag=null;betweenTagAndValue;constructor(e){this.value=e}clone(){let e=new Q(this.value);return e.tag=this.tag?.clone()??null,e.betweenTagAndValue=this.betweenTagAndValue,e.representation=this.representation,e}getValue(){return this.value}setValue(e){if(e!==this.value)this.value=e,this.representation=void 0}getTag(){return this.tag?this.tag.name:null}setTag(e){if(e==null)this.tag=null;else if(this.tag!=null)this.tag.setName(e);else this.tag=new ee(e)}}class W{static createArgument(e){return new W(new Q(e),null)}static createProperty(e,t){return new W(new Q(t),new G(e))}type="entry";static type="entry";name;value;leading;trailing;equals;constructor(e,t){this.value=e,this.name=t}clone(){let e=new W(this.value.clone(),this.name?.clone()??null);return e.leading=this.leading,e.trailing=this.trailing,e.equals=this.equals,e}getTag(){return this.value.getTag()}setTag(e){this.value.setTag(e)}getName(){return this.name?this.name.name:null}setName(e){this.name=e!=null?new G(e):null}getValue(){return this.value.value}setValue(e){this.value=new Q(e)}isArgument(){return this.name==null}isProperty(){return this.name!=null}}function*Je(e){for(let t=e.length-1;t>=0;t--)yield e[t]}function Pn(e){return e.children??(e.children=new pe)}class Re{static create(e){return new Re(new G(e))}type="node";static type="node";name;tag=null;entries;children;leading;trailing;beforeChildren;betweenTagAndName;constructor(e,t=[],r=null){this.name=e,this.entries=t,this.children=r}clone({shallow:e=!1}={}){let t=new Re(this.name.clone(),e?[]:this.entries.map((r)=>r.clone()),this.children?.clone({shallow:e}));if(this.tag)t.tag=this.tag.clone();return t.leading=this.leading,t.betweenTagAndName=this.betweenTagAndName,t.beforeChildren=this.beforeChildren,t.trailing=this.trailing,t}getTag(){return this.tag?this.tag.name:null}setTag(e){this.tag=e!=null?new ee(e):null}getName(){return this.name.name}setName(e){this.name.setName(e)}hasArguments(){return this.entries.some((e)=>e.isArgument())}getArguments(){return this.getArgumentEntries().map((e)=>e.getValue())}getArgumentEntries(){return this.entries.filter((e)=>e.isArgument())}hasArgument(e){return this.getArgumentEntry(e)!=null}getArgument(e){return this.getArgumentEntry(e)?.getValue()}getArgumentEntry(e){for(let t of this.entries){if(!t.isArgument())continue;if(e===0)return t;e--}}addArgument(e,t,r){let o=W.createArgument(e);if(o.value.setTag(t),r!=null)for(let[s,i]of this.entries.entries()){if(!i.isArgument())continue;if(r===0){this.entries.splice(s,0,i);return}r--}this.entries.push(o)}removeArgument(e){for(let[t,r]of this.entries.entries()){if(!r.isArgument())continue;if(e===0){this.entries.splice(t,1);return}e--}}hasProperties(){return this.entries.some((e)=>e.isProperty())}getProperties(){return new Map(this.getPropertyEntries().map((e)=>[e.getName(),e.getValue()]))}getPropertyEntries(){return this.entries.filter((e)=>e.isProperty())}getPropertyEntryMap(){return new Map(this.getPropertyEntries().map((e)=>[e.getName(),e]))}hasProperty(e){return this.getPropertyEntry(e)!=null}getProperty(e){return this.getPropertyEntry(e)?.getValue()}getPropertyEntry(e){for(let t of Je(this.entries))if(t.getName()===e)return t;return}setProperty(e,t,r){for(let s of Je(this.entries))if(s.getName()===e){s.setValue(t),s.value.setTag(r);return}let o=W.createProperty(e,t);o.value.setTag(r),this.entries.push(o)}deleteProperty(e){this.entries=this.entries.filter((t)=>t.getName()!==e)}hasChildren(){return this.children!=null&&!this.children.isEmpty()}appendNode(e){Pn(this).appendNode(e)}insertNodeBefore(e,t){Pn(this).insertNodeBefore(e,t)}insertNodeAfter(e,t){Pn(this).insertNodeAfter(e,t)}removeNode(e){if(this.children==null)throw Error("Node to remove is not in document");this.children.removeNode(e)}replaceNode(e,t){if(this.children==null)throw Error("Node to remove is not in document");this.children.replaceNode(e,t)}findNodesByName(e){return this.children!=null?this.children.findNodesByName(e):[]}findNodeByName(e){return this.children?.findNodeByName(e)}findParameterizedNode(e,t){return this.children?.findParameterizedNode(e,t)}removeNodesByName(e){this.children?.removeNodesByName(e)}}function*Me(e){if(e instanceof pe)yield*e.nodes;else yield e}class pe{type="document";static type="document";nodes;trailing;constructor(e=[]){this.nodes=e}clone({shallow:e}={}){let t=new pe(e?[]:this.nodes.map((r)=>r.clone()));return t.trailing=this.trailing,t}appendNode(e){this.nodes.push(...Me(e))}insertNodeBefore(e,t){if(t==null){this.nodes.push(...Me(e));return}let r=this.nodes.indexOf(t);if(r===-1)throw Error("Reference node is not in document");this.nodes.splice(r,0,...Me(e))}insertNodeAfter(e,t){if(t==null){this.nodes.unshift(...Me(e));return}let r=this.nodes.indexOf(t);if(r===-1)throw Error("Reference node is not in document");this.nodes.splice(r+1,0,...Me(e))}removeNode(e){let t=this.nodes.indexOf(e);if(t===-1)throw Error("Node to remove is not in document");this.nodes.splice(t,1)}replaceNode(e,t){let r=this.nodes.indexOf(e);if(r===-1)throw Error("Node to replace is not in document");this.nodes.splice(r,1,...Me(t))}findNodesByName(e){return this.nodes.filter((t)=>t.name.name===e)}findNodeByName(e){for(let t of Je(this.nodes))if(t.name.name===e)return t;return}findParameterizedNode(e,t){for(let r of Je(this.nodes)){if(r.name.name!==e)continue;let o=r.getArguments();if(o.length!==1||t!==void 0&&o[0]!==t)continue;return r}return}removeNodesByName(e){this.nodes=this.nodes.filter((t)=>t.name.name!==e)}isEmpty(){return this.nodes.length===0}}var Zo=new Map([...Array.from({length:32},(e,t)=>[t,`\\u{${t.toString(16).padStart(2,"0")}}`]),[127,"\\u{7f}"],[8206,"\\u{200e}"],[8207,"\\u{200f}"],[8234,"\\u{202a}"],[8235,"\\u{202b}"],[8236,"\\u{202c}"],[8237,"\\u{202d}"],[8238,"\\u{202e}"],[8294,"\\u{2066}"],[8295,"\\u{2067}"],[8296,"\\u{2068}"],[8297,"\\u{2069}"],[65279,"\\u{feff}"],[34,"\\\""],[92,"\\\\"],[10,"\\n"],[11,"\\u{0b}"],[12,"\\f"],[13,"\\r"],[133,"\\u{85}"],[8232,"\\u{2028}"],[8233,"\\u{2029}"],[8,"\\b"],[9,"\\t"]]);var yr=new Map([["\\n",`
|
|
5
|
+
`],["\\r","\r"],["\\t","\t"],["\\\\","\\"],["\\\"",'"'],["\\b","\b"],["\\f","\f"],["\\s"," "]]),De=/\x0D\x0A|[\x0A\x0B\x0C\x0D\x85\u2028\u2029]/,br=/\x0D\x0A|[\x0A\x0B\x0C\x0D\x85\u2028\u2029]/g,wr=/(?:^|[^\\\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000\x0A\x0B\x0C\x0D\x85\u2028\u2029])(?:\\\\)*[\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000\x0A\x0B\x0C\x0D\x85\u2028\u2029]*(\x0D\x0A|[\x0A\x0B\x0C\x0D\x85\u2028\u2029])/s,Nr=/(?:^|[^\\\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000\x0A\x0B\x0C\x0D\x85\u2028\u2029])(?:\\\\)*[\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000\x0A\x0B\x0C\x0D\x85\u2028\u2029]*(\x0D\x0A|[\x0A\x0B\x0C\x0D\x85\u2028\u2029])/dgs;function St(e,t,r){let o;while(o=br.exec(t)){let s=ze(r,t,o.index);e.push(new N("Raw strings with single quotes cannot contain any unescaped newlines, use triple-quotes for multiline strings",{token:r,start:s,end:{offset:s.offset+o[0].length,line:s.line+1,column:1}}))}return t}var Er=/[\x0A\x0B\x0C\x0D\x85\u2028\u2029]([\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]*)$/,$r=/(?:^|[^\\\x0A\x0B\x0C\x0D\x85\u2028\u2029\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000])(?:\\\\)*[\x0A\x0B\x0C\x0D\x85\u2028\u2029\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]*[\x0A\x0B\x0C\x0D\x85\u2028\u2029]([\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]*)(?:\\[\x0A\x0B\x0C\x0D\x85\u2028\u2029\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]*)*$/,Ar=/(\x0D\x0A|[\x0A\x0B\x0C\x0D\x85\u2028\u2029])([\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]*)([^\x0A\x0B\x0C\x0D\x85\u2028\u2029\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]?)/g,Tr=/([^\x0A\x0B\x0C\x0D\x85\u2028\u2029\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000])[\x0A\x0B\x0C\x0D\x85\u2028\u2029\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]*$/;function It(e,t,r){if(!De.test(t))return e.push(new N("Raw strings with three quotes must be multiline strings",{token:r})),t;if(!De.test(t[0]))return e.push(new N("Multi-line strings must start with a newline",{token:r})),t;let o=Er.exec(t)?.[1];if(o==null)return e.push(new N("The final line in a multiline string may only contain whitespace",{token:r})),t;return t.replace(Ar,(s,i,a,l,u)=>{if(!l)return`
|
|
6
|
+
`;if(!a.startsWith(o)){let c=ze(r,t,u+i.length);return e.push(new N("Every non-blank line of a multi-line string must start with the offset defined by the last line of the string",{token:r,start:c,end:{offset:c.offset+o.length,line:c.line,column:c.column+o.length}})),`
|
|
7
|
+
`}return`
|
|
8
|
+
`+a.slice(o.length)+l}).slice(1,-1)}var Sr=/\\(?:$|u\{(0[0-9a-fA-F]{0,5}|10[0-9a-fA-F]{4}|[1-9a-fA-F][0-9a-fA-F]{0,4})\}|u(\{[^}]{1,6}\}?|[0-9a-fA-F]{1,5}|10[0-9a-fA-F]{4})|([\x0A\x0B\x0C\x0D\x85\u2028\u2029\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]+)|.)/g;function _t(e,t,r){let o;while(o=Nr.exec(t)){let s=ze(r,t,o.indices[1][0]);e.push(new N("Strings with single quotes cannot contain any unescaped newlines, use triple-quotes for multiline strings",{token:r,start:s,end:{offset:s.offset+o[1].length,line:s.line+1,column:1}}))}return t.replace(Sr,(s,i,a,l,u)=>Ot(e,t,r,s,i,a,l,u))}var Ir=/(\x0D\x0A|[\x0A\x0B\x0C\x0D\x85\u2028\u2029])([\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]*)|\\(?:$|u\{(0[0-9a-fA-F]{0,5}|10[0-9a-fA-F]{4}|[1-9a-fA-F][0-9a-fA-F]{0,4})\}|u(\{[^}]{1,6}\}?|[0-9a-fA-F]{1,5}|10[0-9a-fA-F]{4})|([\x0A\x0B\x0C\x0D\x85\u2028\u2029\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]+)|.)/g;function vt(e,t,r){if(!wr.test(t))return e.push(new N("Strings with three quotes must be multiline strings",{token:r})),t;if(!De.test(t[0]))return e.push(new N("Multi-line strings must start with a newline",{token:r})),t;let o=$r.exec(t)?.[1];if(o==null){let s=Tr.exec(t),i=s?ze(r,t,s.index):void 0,a="The final line in a multiline string may only contain whitespace";if(s?.[0][0]==="\\")a+=" after removing escaped whitespace";return e.push(new N(a,{token:r,start:i,end:i&&{offset:i.offset,line:i.line,column:i.column+1}})),t}return t.replace(Ir,(s,i,a,l,u,c,d)=>{if(!i)return Ot(e,t,r,s,l,u,c,d);let h=t[d+i.length+(a?a.length:0)];if(De.test(h))return`
|
|
9
|
+
`;if(!a.startsWith(o)){let m=ze(r,t,d+i.length);return e.push(new N("Every non-blank line of a multi-line string must start with the offset defined by the last line of the string",{token:r,start:m,end:{offset:m.offset+o.length,line:m.line,column:m.column+o.length}})),`
|
|
10
|
+
`}return`
|
|
11
|
+
`+a.slice(o.length)}).slice(1,-1)}function Ot(e,t,r,o,s,i,a,l){if(a)return"";if(i){let u=r.text.startsWith('"""'),c=t.slice(0,l).split(De),d={offset:r.start.offset+(u?3:1)+l,line:r.start.line+(c.length-1),column:c.length===1?r.start.column+(u?3:1)+l:c.at(-1).length},h={offset:d.offset+o.length,line:d.line,column:d.column+o.length};if(!i.startsWith("{"))e.push(new N(String.raw`Invalid unicode escape "\u${i}", did you forget to use {}? "\u{${i}}"`,{token:r,start:d,end:h}));else e.push(new N(String.raw`Invalid unicode escape "\u${i.endsWith("}")?i:`${i}...`}"`,{token:r,start:d,end:h}));return""}else if(s){let u=parseInt(s,16);if(u>=55296&&u<=57343)e.push(new N(String.raw`Invalid unicode escape "\u{${s}}, only scalar values can be added using an escape`,{token:r}));return String.fromCodePoint(u)}else{let u=yr.get(o);if(u==null)return e.push(new N(o.length<2?"Invalid whitespace escape at the end of a string":`Invalid escape "${o}"`,{token:r})),"";return u}}function ze(e,t,r){let o=1;switch(e.type){case Fe:o=3;break;case le:o=e.text.indexOf('"')+1;break;case ye:o=e.text.indexOf('"')+3;break}let s=t.slice(0,r).split(De);return{offset:e.start.offset+o+r,line:e.start.line+(s.length-1),column:s.length===1?e.start.column+o+r:1+s[s.length-1].length}}function se(e){if(!e.current.done)e.lastToken=e.current.value;e.current=e.tokens.next();let t=!e.current.done&&e.current.value.errors;if(t)e.errors.push(...t)}function T(e,t){if(!e.current.done&&e.current.value.type===t){let r=e.current.value;return se(e),r}}function b(e,t){let r="current"in e?e.current.value??e.lastToken:e;return new N(t,{token:r})}function D(e,t,r,o=r){if(e.storeLocations)At(t,r,o)}function k(e="",t="",r=""){return e+t+r||void 0}function wn(e,t,{storeLocations:r=!1,flags:o}){let s={type:-1,text:"",start:{offset:0,line:1,column:1},end:{offset:0,line:1,column:1},errors:null},i={text:e,tokens:t[Symbol.iterator](),current:{done:!1,value:s},storeLocations:r,lastToken:s,errors:[],flags:o};return se(i),i}function qn(e,t){if(!t&&!e.current.done&&e.current.value.type!==ue)t=b(e,`Unexpected token ${JSON.stringify(e.current.value.text)}, did you forget to quote an identifier?`);let r=e.errors??[];if(t!=null)if(t instanceof N)if(t.errors)r.push(...t.errors);else r.push(t);else r.push(new N(`An unexpected error occurred, ${String(t)}, this is likely a bug in the KDL parser`,{cause:t}));if(r.length)if(r.length===1)throw r[0];else throw new N("Encountered multiple errors",{errors:r})}function yn(e){switch(e){case"#null":return null;case"#true":return!0;case"#false":return!1;case"#inf":return 1/0;case"#-inf":return-1/0;case"#nan":return NaN}}function Ft(e){return e==="inf"||e==="-inf"||e==="nan"||e==="true"||e==="false"||e==="null"||!1}function Hn(e){let{value:t}=e.current,r,o,s,i,a,l=!1;if(t?.text[0]==="-"||t?.text[0]==="+")a=t.text[0];switch(t?.type){case Y:{if(!e.flags.experimentalSuffixedNumbers)throw new N("Unreachable code: got a suffixed number from the tokenizer but the suffixed number flag is not set",{token:t});let d=a?t.text.slice(1):t.text,h=d.search(/[^0-9._]/);if(o=(a??"")+d.slice(0,h),r=Number.parseFloat(o.replaceAll("_","")),i=s=d.slice(h),Ft(s))e.errors.push(b(e,`Invalid suffix ${s}, values that look like keywords cannot be used as suffix`))}break;case cn:l=!0,r=(a==="-"?-1:1)*Number.parseInt(t.text.slice(a?3:2).replaceAll("_",""),2);break;case ln:l=!0,r=(a==="-"?-1:1)*Number.parseInt(t.text.slice(a?3:2).replaceAll("_",""),8);break;case re:l=!0,r=Number.parseFloat(t.text.replaceAll("_",""));break;case un:l=!0,r=(a==="-"?-1:1)*Number.parseInt(t.text.slice(a?3:2).replaceAll("_",""),16);break;case Oe:if(r=yn(t.text),r===void 0)if(r=null,yn(t.text.toLowerCase())!==void 0)e.errors.push(b(e,`Invalid keyword ${t.text}, keywords are case sensitive, write ${t.text.toLowerCase()} instead`));else switch(t.text.toLowerCase()){case"#nul":case"#nill":e.errors.push(b(e,`Invalid keyword ${t.text}, did you mean #null?`));break;case"#fals":case"#fasle":e.errors.push(b(e,`Invalid keyword ${t.text}, did you mean #false?`));break;case"#ture":case"#treu":e.errors.push(b(e,`Invalid keyword ${t.text}, did you mean #true?`));break;case"#ifn":e.errors.push(b(e,`Invalid keyword ${t.text}, did you mean #inf?`));break;case"#-ifn":e.errors.push(b(e,`Invalid keyword ${t.text}, did you mean #-inf?`));break;default:e.errors.push(b(e,`Invalid keyword ${t.text}, surround it with quotes to use a string`))}break;default:return}se(e);let u=e.flags.experimentalSuffixedNumbers&&T(e,Oe);if(u)if(l){if(i=u.text,yn(i)!==void 0)e.errors.push(b(u,`Invalid number suffix ${i}, did you forget a space between the number and the keyword?`));s=i.slice(1)}else if(s)e.errors.push(b(u,"Unexpected hashed suffix, a number can only have one suffix"));else if(typeof r==="number")e.errors.push(b(u,"Unexpected hashed suffix, you cannot place suffixes on number keywords"));else e.errors.push(b(u,"Unexpected hashed suffix, you can only place suffixes on numbers"));let c=new Q(r);if(c.representation=o??t.text,D(e,c,t),s){let d=new ee(s);d.representation=i,d.suffix=!0,D(e,d,e.lastToken),c.tag=d}return c}function Ke(e){if(e.current.done)return;let{value:t}=e.current,r;switch(t.type){case F:if(se(e),Ft(t.text))e.errors.push(b(e,`Invalid keyword "${t.text}", add a leading # to use the keyword or surround with quotes to make it a string`));r=[t.text,t.text,t];break;case Ve:se(e),r=[_t(e.errors,t.text.slice(1,-1),t),t.text,t];break;case Fe:se(e),r=[vt(e.errors,t.text.slice(3,-3),t),t.text,t];break;case le:{se(e);let o=t.text,s=o.indexOf('"');r=[St(e.errors,o.slice(s+1,-(s+1)),t),o,t];break}case ye:{se(e);let o=t.text,s=o.indexOf('"');r=[It(e.errors,o.slice(s+3,-(s+3)),t),o,t];break}default:return}if(T(e,Oe))e.errors.push(b(e.lastToken,yn(e.lastToken.text)===void 0?"Unexpected hashed suffix on a string, you can only place suffixes on numbers":"Unexpected keyword, did you forget to add whitespace?"));return r}function zn(e){let t=Ke(e);if(!t)return;let r=new G(t[0]);return r.representation=t[1],D(e,r,t[2],e.lastToken),r}function bn(e){let t=Hn(e);if(t)return t;let r=Ke(e);if(!r)return;let o=new Q(r[0]);return o.representation=r[1],D(e,o,r[2],e.lastToken),o}function Ge(e){let t=T(e,pn);if(!t)return;let{value:r}=e.current;return se(e),t.text+(r?.text??"")}function Nn(e){return T(e,hn)?.text}function Kn(e){return T(e,xe)??Nn(e)}function En(e){let t=T(e,dn);if(!t)return;while(Kn(e));if(!Ge(e)&&!T(e,fe)&&!T(e,ue))e.errors.push(b(e,`Expected newline or single-line comment after backslash but got ${e.current.value?.text??"EOF"}`));return e.text.slice(t.start.offset,e.lastToken.end.offset)}function he(e){let t=e.lastToken.end;while(T(e,fe)?.text??Ge(e)??Kn(e)??En(e));if(e.lastToken.end===t)return;return e.text.slice(t.offset,e.lastToken.end.offset)}function O(e){let t=e.lastToken.end;while(Kn(e)??En(e));if(e.lastToken.end===t)return;return e.text.slice(t.offset,e.lastToken.end.offset)}function Un(e){let t=T(e,rn);if(!t)return;let r=O(e),o=Ke(e);if(!o&&e.current.value){let l=e.current.value;if(he(e))e.errors.push(b(l,"This type of whitespace is not allowed inside a tag"));o=Ke(e)}if(!o){if(Hn(e))e.errors.push(b(e,"Invalid tag, did you forget to quote a string?")),o=["error","error"]}if(!o)throw b(e,"Invalid tag, did you forget to quote a string?");let s=O(e),i=T(e,Be);if(!i&&e.current.value){let l=e.current.value;if(he(e))e.errors.push(b(l,"This type of whitespace is not allowed inside a tag"));i=T(e,Be)}if(!i)throw b(e,"Invalid tag, did you forget to quote a string?");let a=new ee(o[0]);return a.representation=o[1],a.leading=r,a.trailing=s,D(e,a,t,e.lastToken),a}function $n(e){return Ge(e)??T(e,fe)?.text??T(e,an)?.text??T(e,ue)?.text}function Gn(e){if(!T(e,on))return;let t=Rt(e);if(!T(e,sn))throw b(e,"Invalid node children");return t}function Le(e){let t=e.current.value;{let h=Un(e);if(h){let m=O(e),g=bn(e);if(!g)throw b(e,"Invalid argument");if(g.tag)e.errors.push(b(e.lastToken,"A number suffix cannot be combined with a regular tag"));g.tag=h,g.betweenTagAndValue=m;let V=new W(g,null);D(e,g,t,e.lastToken),D(e,V,t,e.lastToken);let Te=O(e);if(T(e,ve))e.errors.push(b(e.lastToken,typeof g.value==="string"?"Unexpected equals sign, properties are name=(tag)value not (tag)name=value":"Unexpected equals sign")),Te=k(Te,O(e))||" ";return[V,Te]}}{let h=Hn(e);if(h){let m=new W(h,null);D(e,m,t,e.lastToken);let g=O(e);if(T(e,ve))e.errors.push(b(e.lastToken,"Unexpected equals sign, did you forget to quote the property name?")),g=k(g,O(e))||" ";return[m,g]}}let r=Ke(e);if(!r)return;let o=O(e),s=T(e,ve);if(!s){let h=new Q(r[0]);h.representation=r[1],D(e,h,r[2]);let m=new W(h,null);return D(e,m,t,e.lastToken),[m,o]}let i=new G(r[0]);i.representation=r[1],D(e,i,r[2]);let a=O(e),l=Un(e),u=l&&O(e),c=bn(e);if(!c)throw b(e,"Expected a value");if(l){if(c.tag)e.errors.push(b(e.lastToken,"A number suffix cannot be combined with a regular tag"));c.tag=l,c.betweenTagAndValue=u}let d=new W(c,i);return D(e,d,t,e.lastToken),d.equals=k(o,s.text,a),[d,void 0]}function kt(e){let t=O(e)??"",r;while(r=Ee(e)){let a=e.lastToken.end,l=Le(e);if(!l)throw b(e,"Expected a property or argument");if(!(l[1]??O(e)))throw b(e,"Expected space after slashdashed property or argument");t=t+r+e.text.slice(a.offset,e.lastToken.end.offset)}let o=Le(e);if(!o)return;let s=o[1]??O(e)??"";while(r=Ee(e)){let a=e.lastToken.end,l=Le(e);if(!l)throw b(e,"Expected a property or argument");if(!(l[1]??O(e)))break;s=s+r+e.text.slice(a.offset,e.lastToken.end.offset)}let i=o[0];return i.leading=t,i.trailing=s,i}function Ee(e){let t=T(e,ge)?.text;if(!t)return;return k(t,he(e))}function An(e){let t=e.current.value,r=Un(e),o=r&&O(e),s=zn(e);if(!s)if(r)throw b(e,"Couldn't find node name");else return;let i=O(e),a=i!=null,l=Ee(e),u=[];while(a||l){let m=e.lastToken.end,g=Le(e);if(!g)break;if(l)a=(g[1]||O(e))!=null,i=k(i,l,e.text.slice(m.offset,e.lastToken.end.offset)),l=Ee(e);else{let V=g[0];V.leading=i,u.push(V),i=g[1]||O(e),a=i!=null,l=Ee(e)}}let c,d;while(!0){l??=Ee(e);let m=e.lastToken.end,g=Gn(e);if(!g){if(l)throw b(e,"Unexpected slashdash");break}if(l)i=k(i,l,e.text.slice(m.offset,e.lastToken.end.offset)),l=void 0;else{if(c)e.errors.push(b(e,"A node can only have one children block"));c=g,d=i??"",i=void 0}i=k(i,O(e))}let h=new Re(s,u,c);return h.tag=r??null,h.betweenTagAndName=o,h.beforeChildren=d,h.trailing=i??"",D(e,h,t,e.lastToken),h}function Ct(e){let t=he(e),r=An(e);if(!r)return;let o=k($n(e),he(e));return r.leading=k(t,r.leading),r.trailing=k(r.trailing,o),r}function Jt(e){let t=T(e,_e)?.text,r=Rt(e);if(!t)return r;if(r.nodes[0])r.nodes[0].leading=k(t,r.nodes[0].leading);else r.trailing=k(t,r.trailing);return r}function Rt(e){let t=e.current.value,r=[],o=!0,s=he(e);while(o){let a=e.lastToken.end,l=Ee(e),u=An(e);if(!u){if(l)throw b(e,"Unexpected slashdash");break}let c=O(e),d=$n(e);if(l)s=k(s,e.text.slice(a.offset,e.lastToken.end.offset),he(e));else u.trailing=k(u.trailing,c,d)??"",r.push(u),u.leading=s??"",s=he(e);o=d!=null}let i=new pe(r);return D(e,i,t,e.lastToken),i.trailing=s??"",i}function Mt(e,t){let r=[],o;while(o=t(e))r.push(o);return r.length>0?r:void 0}function _r(e){{let t=T(e,_e);if(t)return{type:"bom",text:t.text}}{let t=T(e,fe);if(t)return{type:"newline",text:t.text}}{let t=T(e,xe);if(t)return{type:"space",text:t.text}}{let t=Ge(e);if(t)return{type:"singleline",text:t}}{let t=Nn(e);if(t)return{type:"multiline",text:t}}return}function Tn(e){{let t=En(e);if(t)return{type:"line-escape",text:t}}{let t=T(e,xe);if(t)return{type:"space",text:t.text}}{let t=Nn(e);if(t)return{type:"multiline",text:t}}return}function Dt(e){let t=[];while(!0){{let r=_r(e);if(r){t.push(r);continue}}if(T(e,ge)?.text){let o,s=Mt(e,Tn)??[],i=An(e);if(!i)throw b(e,"Invalid slashdash, expected a commented node");i.trailing=k(i.trailing,Mt(e,Tn)?.map((a)=>a.text).join(""),$n(e)),t.push({type:"slashdash",preface:s,value:i});continue}break}return t}function vr(e){let t=T(e,ge);if(t==null)return;let r,o=[];while(r=Tn(e))o.push(r);let s,i,a="";if(i=Le(e)){if(s=i[0],i[1])a=i[1]}else if(i=Gn(e))s=i;else throw b(t,"Couldn't find argument, property, or children that were commented by slashdash");return[{type:"slashdash",preface:o,value:s},a]}function Qn(e){let t=[];while(!0){let r=Tn(e);if(!r)break;let o=!0;t.push(r);while(o){let s=vr(e);if(!s)break;if(t.push(s[0]),s[1][0])t.push(...Qn(wn(s[1][0],He(s[1][0],{flags:e.flags}),{flags:e.flags})));o=!!s[1][0]}}return t}var Or={value:bn,identifier:zn,node:Ct,entry:kt,document:Jt,"whitespace in document":Dt,"whitespace in node":Qn};function me(e,{as:t="document",flags:r,...o}={}){let s=Or[t];if(s==null)throw TypeError(`Invalid "as" target passed: ${JSON.stringify(t)}`);if(typeof e!=="string"){if(typeof TextDecoder!=="function")throw TypeError("Uint8Array input is only supported on platforms that include TextDecoder");e=new TextDecoder("utf-8",{fatal:!0}).decode(e)}let i=Tt(r),a=He(e,{...o,flags:i}),l=wn(e,a,{...o,flags:i}),u;try{u=s(l)}catch(c){qn(l,c)}if(qn(l),!u)throw new N(`Expected ${/^[aeiouy]/.exec(t)?"an":"a"} ${t}`);return u}class L extends Error{column;line;offset;reason;constructor(e,t=null){super(t?`${e} (line ${t.line}, column ${t.column})`:e);this.name="JxnError",this.column=t?.column??null,this.line=t?.line??null,this.offset=t?.offset??null,this.reason=e}inFile(e){let t=this.line!==null&&this.column!==null&&this.offset!==null?{column:this.column,line:this.line,offset:this.offset}:null;return new L(`${e}: ${this.reason}`,t)}}function Qe(e,t){let r=e.slice(0,t),o=r.split(`
|
|
12
|
+
`).length;return{column:t-r.lastIndexOf(`
|
|
13
|
+
`),line:o,offset:t}}var Lt=new Set(["onabort","onactivate","onaddsourcebuffer","onaddtrack","onadvertisementreceived","onafterprint","onanimationcancel","onanimationend","onanimationiteration","onanimationstart","onappinstalled","onaudioend","onaudioprocess","onaudiostart","onauxclick","onavailabilitychanged","onbackgroundfetchabort","onbackgroundfetchclick","onbackgroundfetchfail","onbackgroundfetchsuccess","onbeforeinput","onbeforeinstallprompt","onbeforematch","onbeforeprint","onbeforetoggle","onbeforexrselect","onbegin","onblocked","onblur","onboundary","onbufferedamountlow","onbufferedchange","oncancel","oncanmakepayment","oncanplay","oncanplaythrough","oncaptureaction","oncapturedmousechange","oncapturehandlechange","onchange","oncharacterboundsupdate","oncharacteristicvaluechanged","onchargingchange","onchargingtimechange","onclick","onclose","onclosing","oncommand","oncomplete","oncompositionend","oncompositionstart","onconfigurationchange","onconnect","onconnecting","onconnectionavailable","onconnectionstatechange","oncontentdelete","oncontextlost","oncontextmenu","oncontextoverflow","oncontextrestored","oncontrollerchange","oncookiechange","oncopy","oncuechange","oncurrententrychange","oncurrentscreenchange","oncut","ondataavailable","ondatachannel","ondblclick","ondequeue","ondevicechange","ondevicemotion","ondeviceorientation","ondeviceorientationabsolute","ondischargingtimechange","ondisconnect","ondispose","ondownloadprogress","ondrag","ondragend","ondragenter","ondragleave","ondragover","ondragstart","ondrop","ondurationchange","onemptied","onencrypted","onend","onended","onendstreaming","onenter","onenterpictureinpicture","onerror","onexit","onfencedtreeclick","onfetch","onfinish","onfocus","onformdata","onframeratechange","onfreeze","onfullscreenchange","onfullscreenerror","ongamepadconnected","ongamepaddisconnected","ongatheringstatechange","ongattserverdisconnected","ongeometrychange","ongotpointercapture","onhashchange","onicecandidate","onicecandidateerror","oniceconnectionstatechange","onicegatheringstatechange","oninput","oninputreport","oninputsourceschange","oninstall","oninstallresult","oninvalid","onisolationchange","onkeydown","onkeyframerequest","onkeypress","onkeystatuseschange","onkeyup","onlanguagechange","onlayoutchange","onleavepictureinpicture","onlevelchange","onload","onloadeddata","onloadedmetadata","onloadend","onloading","onloadingdone","onloadingerror","onloadstart","onlocation","onlostpointercapture","onmanagedconfigurationchange","onmark","onmessage","onmessageerror","onmidimessage","onmousedown","onmouseenter","onmouseleave","onmousemove","onmouseout","onmouseover","onmouseup","onmute","onnavigate","onnavigateerror","onnavigatesuccess","onnegotiationneeded","onnomatch","onnotificationclick","onnotificationclose","onoffline","ononline","onopen","onorientationchange","onpagehide","onpagereveal","onpageshow","onpageswap","onpaste","onpause","onpayerdetailchange","onpaymentmethodchange","onpaymentrequest","onperiodicsync","onplay","onplaying","onpointercancel","onpointerdown","onpointerenter","onpointerleave","onpointerlockchange","onpointerlockerror","onpointermove","onpointerout","onpointerover","onpointerrawupdate","onpointerup","onpopstate","onportalactivate","onprerenderingchange","onprioritychange","onprocessorerror","onprogress","onpromptaction","onpromptdismiss","onpush","onpushsubscriptionchange","onquotaoverflow","onratechange","onreading","onreadingerror","onreadystatechange","onredraw","onreflectionchange","onrejectionhandled","onrelease","onremove","onremovesourcebuffer","onremovetrack","onrepeat","onreset","onresize","onresourcetimingbufferfull","onresult","onresume","onrtctransform","onscreenschange","onscroll","onscrollend","onsecuritypolicyviolation","onseeked","onseeking","onselect","onselectedcandidatepairchange","onselectend","onselectionchange","onselectstart","onserviceadded","onservicechanged","onserviceremoved","onshippingaddresschange","onshippingoptionchange","onshow","onsignalingstatechange","onsinkchange","onslotchange","onsnapchanged","onsnapchanging","onsoundend","onsoundstart","onsourceclose","onsourceended","onsourceopen","onspeechend","onspeechstart","onsqueeze","onsqueezeend","onsqueezestart","onstalled","onstart","onstartstreaming","onstatechange","onstop","onstorage","onstream","onsubmit","onsuccess","onsuspend","onsync","onterminate","ontextformatupdate","ontextupdate","ontimeout","ontimeupdate","ontoggle","ontonechange","ontoolactivated","ontoolcancel","ontoolchange","ontouchcancel","ontouchend","ontouchmove","ontouchstart","ontrack","ontransitioncancel","ontransitionend","ontransitionrun","ontransitionstart","onuncapturederror","onunhandledrejection","onunload","onunmute","onupdate","onupdateend","onupdatefound","onupdatestart","onupgradeneeded","onvalidationstatuschange","onversionchange","onvisibilitychange","onvoiceschanged","onvolumechange","onwaiting","onwaitingforkey","onwebkitanimationend","onwebkitanimationiteration","onwebkitanimationstart","onwebkittransitionend","onwheel","onzoomlevelchange"]);var Fr=/(?![\t\n\v\f\r])\p{Cc}/u,kr=new Set(["array","fn","object","on","ref"]),Cr=new Set(["attributes","script","state","style"]);function E(e,t,r,o,s){let i=t.normalize("NFC");if(i==="__proto__")throw S(o,s,'"__proto__" cannot be a key: it would not be data');if(Object.hasOwn(e,i))throw S(o,s,`"${i}" is written twice, and one of them would be lost`);e[i]=r}function S(e,t,r){let o=Wt(t)?.start;return new L(r,o===void 0?null:Qe(e.text,o))}function Wt(e){let t=Ce(e);return t?{end:t.end.offset,start:t.start.offset}:null}function j(e,t,r){let o=e.spans?Wt(r):null;if(o)e.spans?.set(t,o)}function X(e){return e.replaceAll("~","~0").replaceAll("/","~1")}function In(e,t){let r=t.getTag();if(r!==null&&!kr.has(r))throw S(e,t,`(${r}) is not an annotation Jx Notation has`);if(r==="ref")throw S(e,t,"(ref) annotates a value, and this is a name");return r}function je(e,t){let r=t.getTag(),o=t.getValue();if(r!==null&&r!=="ref")throw S(e,t,`(${r}) cannot annotate a value here; only (ref) can`);if(J(o)){if(!Number.isFinite(o))throw S(e,t,"JSON has no way to hold #inf or #nan");if(Number.isInteger(o)&&!Number.isSafeInteger(o))throw S(e,t,"This number is too large to survive being read as JSON")}if(r==="ref"){if(!n(o))throw S(e,t,"(ref) needs a string");return{$ref:o}}return o}function $e(e,t){return t.entries.filter((r)=>!r.name).map((r)=>je(e,r))}function Ae(e){return e.entries.filter((t)=>t.name)}function P(e){return e.children?.nodes??[]}function Xe(e){return e.getName()??""}function Jr(e,t,r){let o={$prototype:"Function"},s=$e(e,t),i=P(t);for(let a of Ae(t))E(o,Xe(a),je(e,a),e,a);if(i.length>0){if(s.length>0)E(o,"parameters",s,e,t);E(o,"body",Xn(e,i,`${r}/body`),e,t)}else if(s.length>0){let a=s.at(-1)??null,l=s.slice(0,-1);if(l.length>0)E(o,"parameters",l,e,t);E(o,"body",a,e,t)}return j(e,r,t),o}function Xn(e,t,r){return t.map((o,s)=>{if(o.getName()!=="-")throw S(e,o,`A list holds only "-" items, and this is "${o.getName()}"`);return ne(e,o,`${r}/${s}`)})}function ne(e,t,r){let o=In(e,t);if(j(e,r,t),o==="fn")return Jr(e,t,r);let s=$e(e,t),i=Ae(t),a=P(t);if(o==="array"){if(i.length>0)throw S(e,t,"(array) holds items, and these are named");return[...s,...Xn(e,a,r)]}if(o!=="object"){if(s.length>1){if(i.length>0||a.length>0)throw S(e,t,"A list of values cannot also have names or a block");return s}if(s.length===1){if(i.length>0||a.length>0)throw S(e,t,"A value cannot also have names or a block");return s[0]??null}if(a.length>0&&i.length===0&&a.every((u)=>u.getName()==="-"))return Xn(e,a,r)}else if(s.length>0)throw S(e,t,"(object) holds names, and this is a value");let l={};for(let u of i){let c=Xe(u);E(l,c,je(e,u),e,u),j(e,`${r}/${X(c)}`,u)}for(let u of a){let c=u.getName();E(l,c,ne(e,u,`${r}/${X(c)}`),e,u)}return l}function Bt(e,t,r){let o={};if(j(e,r,t),$e(e,t).length>0)throw S(e,t,"A style block holds declarations, and this is a value");for(let s of Ae(t)){let i=Xe(s);E(o,i,je(e,s),e,s),j(e,`${r}/${X(i)}`,s)}for(let s of P(t)){let i=s.getName(),a=`${r}/${X(i)}`,l=P(s);if(s.getTag()==="array"||l.length>0&&l.every((c)=>c.getName()==="-")){E(o,i,ne(e,s,a),e,s);continue}let u=$e(e,s);if(u.length>1)throw S(e,s,`"${i}" has more than one value. A selector with a space in it needs quotes`);if(u.length===1){if(Ae(s).length>0||P(s).length>0)throw S(e,s,`"${i}" has a value and names. A selector with a space in it needs quotes`);E(o,i,u[0]??null,e,s),j(e,a,s)}else E(o,i,Bt(e,s,a),e,s)}return o}function Sn(e,t,r){let o=P(t);if(o.length!==1||!o[0])throw S(e,t,`"${t.getName()}" holds one element`);return Pt(e,o[0],r)}function Vt(e,t,r){let o={$prototype:"Array"};if(j(e,r,t),$e(e,t).length>0)throw S(e,t,"$array holds names and one element, and this is a value");for(let s of Ae(t)){let i=Xe(s);E(o,i.startsWith(".")?i.slice(1):i,je(e,s),e,s)}if(P(t).length>0)E(o,"map",Sn(e,t,`${r}/map`),e,t);return o}function Pt(e,t,r){let o=t.getName();if(o==="-"){let s=$e(e,t);if(s.length!==1||Ae(t).length>0||P(t).length>0)throw S(e,t,'"-" is one piece of text or one (ref)');return j(e,r,t),s[0]??null}if(o==="$array")return Vt(e,t,r);return Yn(e,t,r)}function Rr(e,t,r,o){let s=In(e,r);if(t==="map")return Sn(e,r,o);if(t==="cases"){let i={};for(let a of P(r)){let l=a.getName();E(i,l,Sn(e,a,`${o}/${X(l)}`),e,a)}return i}if(t==="children"&&s!=="array"&&P(r).length>0)return Sn(e,r,o);return ne(e,r,o)}function Yn(e,t,r){let o={},s=t.getName(),i=In(e,t);if(j(e,r,t),i!==null)throw S(e,t,`(${i}) cannot annotate an element`);let a=$e(e,t);if(s==="$element"){let[u,c,...d]=a;if(d.length>0)throw S(e,t,"$element takes at most a tag and a text value");if(u!==void 0)E(o,"tagName",u,e,t);if(c!==void 0)E(o,"textContent",c,e,t)}else{if(s.startsWith("$"))throw S(e,t,`"${s}" is not a kind of element`);if(E(o,"tagName",s,e,t),a.length>1)throw S(e,t,"An element has one text value. A list of them needs a block");if(a[0]!==void 0)E(o,"textContent",a[0],e,t),j(e,`${r}/textContent`,t)}Mr(e,t,o,r);let l=[];for(let u of P(t))Dr(e,u,o,l,r);if(l.length>0)E(o,"children",l,e,t);return o}function Ut(e){let{attributes:t}=e;if(f(t))return t;let r={};return e.attributes=r,r}function Mr(e,t,r,o){for(let s of Ae(t)){let i=Xe(s),a=s.getTag();if(a==="fn")throw S(e,s,"A function has a block form: (fn)name, on a line of its own");let l=je(e,s);if(i.startsWith(".")||i.startsWith("$")){let u=i.startsWith(".")?i.slice(1):i;E(r,u,l,e,s),j(e,`${o}/${X(u)}`,s)}else if(i.startsWith("on")&&a==="ref")E(r,i,l,e,s),j(e,`${o}/${X(i)}`,s);else if(i.startsWith("on")&&Lt.has(i))throw S(e,s,`${i} needs (ref)"pointer", or a function on a line of its own: (fn)${i} "…"`);else E(Ut(r),i,l,e,s),j(e,`${o}/attributes/${X(i)}`,s)}}function Dr(e,t,r,o,s){let i=t.getName(),a=In(e,t),l=(u)=>`${s}/${X(u)}`;if(a==="fn"||a==="on"){if(!i.startsWith("on"))throw S(e,t,`(${a}) in an element marks a handler, and "${i}" is not one`);E(r,i,ne(e,t,l(i)),e,t)}else if(i==="script")throw S(e,t,'"script" is reserved. A <script> element is $element "script"');else if(i==="state")E(r,"state",ne(e,t,l("state")),e,t);else if(i==="style")E(r,"style",Bt(e,t,l("style")),e,t);else if(i==="attributes"){let u=ne(e,t,l("attributes"));if(f(u))for(let[c,d]of Object.entries(u))E(Ut(r),c,d,e,t);else E(r,"attributes",u,e,t)}else if(i.startsWith(".")){let u=i.slice(1);E(r,u,Rr(e,u,t,l(u)),e,t)}else if(i.startsWith("$")&&i!=="$array"&&i!=="$element")E(r,i,ne(e,t,l(i)),e,t);else{if(Cr.has(i))throw S(e,t,`"${i}" is reserved here`);o.push(Pt(e,t,`${s}/children/${o.length}`))}}function Lr(e,t){return P(t).map((r,o)=>{let s=`/$head/${o}`;return r.getName()==="-"?ne(e,r,s):Yn(e,r,s)})}function jr(e){let t=Fr.exec(e);if(t)throw new L(`A raw control character (U+${t[0].codePointAt(0)?.toString(16).toUpperCase().padStart(4,"0")}) cannot be in a Jx Notation file. Escape it, as \\u{1b}`,Qe(e,t.index));try{return me(e,{storeLocations:!0})}catch(r){let s=(r instanceof N?r.errors?.[0]??r:null)?.start,i=r instanceof Error?r.message:String(r);throw new L(i.split(`
|
|
14
|
+
`)[0]??i,s?Qe(e,s.offset):null)}}function qt(e){if(w_(e.text)==="project")throw new L('This is a project file: its first node is "project". A document has an element there, and a <project> element is $element "project"');let r=jr(e.text),o={},s=null;for(let i of r.nodes){let a=i.getName();if(a==="$head"&&i.getTag()===null)E(o,a,Lr(e,i),e,i);else if(a.startsWith("$")&&a!=="$array"&&a!=="$element")E(o,a,ne(e,i,`/${X(a)}`),e,i),j(e,`/${X(a)}`,i);else if(s)throw S(e,i,"A document has one root element, and this is a second");else s=i}if(s){let i=s.getName()==="$array"?Vt(e,s,""):Yn(e,s,"");for(let[a,l]of Object.entries(i))E(o,a,l,e,s)}return H_(o)}function uf(e,t){try{return qt({spans:null,text:e})}catch(r){throw t!==void 0&&r instanceof L?r.inFile(t):r}}function Zn(e){let t=new Map;return{document:qt({spans:t,text:e}),spans:t}}function By(e){return e.toLowerCase().endsWith(".jxn")}function x_(e){return e.endsWith(".json")||By(e)}var qs=new Map([["b",String.raw`\b in a quoted string is a backspace, not a word boundary. Use a raw string, like #"…"#, if this is a pattern.`],["s",String.raw`\s in a quoted string is a space, not whitespace. Use a raw string, like #"…"#, if this is a pattern.`]]);function We(e,t=!1){if(Array.isArray(e))return`[${e.map((s)=>We(s,t)).join(",")}]`;if(!f(e))return e===void 0?"null":JSON.stringify(e);return`{${(t?Object.keys(e):Object.keys(e).toSorted()).map((s)=>`${JSON.stringify(s)}:${We(e[s],t||s==="style")}`).join(",")}}`}function Wr(e,t){let r=e;for(let o of t.split("/").slice(1)){let s=o.replaceAll("~1","/").replaceAll("~0","~");if(Array.isArray(r))r=r[Number(s)];else r=f(r)?r[s]:void 0}return r}function Br({spans:e}){let t=new Map;for(let[r,o]of e){let s=t.get(o.start);if(s===void 0||r.length<s.length)t.set(o.start,r)}return t}function Ht(e,t){let r=Br(e),o=new Map;for(let[s,i]of r)o.set(s,We(Wr(e.document,i)));return{meanings:o,pointers:r,text:t}}function ie(e){let t=Ce(e);return{end:t?.end.offset??0,start:t?.start.offset??0}}function vn(e,t){let{end:r,start:o}=ie(e);return t.slice(o,r).trimEnd()}function _n(e,t){let{end:r,start:o}=ie(e);return`${e.leading??" "}${t.slice(o,r).trimEnd()}`}function rt(e){return e.children?.nodes??[]}function et(e){let t=e.entries.map((i)=>`${i.getName()??""}=(${i.getTag()??""})${JSON.stringify(i.getValue())}`),r=t.filter((i)=>!i.startsWith("=")).toSorted(),o=t.filter((i)=>i.startsWith("=")),s=rt(e).map((i)=>et(i));return`(${e.getTag()??""})${e.getName()} ${[...r,...o].join(" ")} {${s.join(";")}}`}function nt(e,t,r){if(et(t)===et(r))return!0;let o=e.previous.meanings.get(ie(t).start);return o!==void 0&&o===e.next.meanings.get(ie(r).start)}function zt(e){let r=e.entries.filter((o)=>["$id","key"].includes(o.getName()??"")).map((o)=>JSON.stringify(o.getValue()));return`(${e.getTag()??""})${e.getName()} ${r.join(" ")}`}function Kt(e,t,r){let o=e.length+1,s=t.length+1,i=new Int32Array(o*s);for(let c=e.length-1;c>=0;c-=1)for(let d=t.length-1;d>=0;d-=1){let h=e[c],m=t[d];i[c*s+d]=h!==void 0&&m!==void 0&&r(h,m)?(i[(c+1)*s+d+1]??0)+1:Math.max(i[(c+1)*s+d]??0,i[c*s+d+1]??0)}let a=[],l=0,u=0;while(l<e.length&&u<t.length){let c=e[l],d=t[u];if(c!==void 0&&d!==void 0&&r(c,d))a.push([l,u]),l+=1,u+=1;else if((i[(l+1)*s+u]??0)>=(i[l*s+u+1]??0))l+=1;else u+=1}return a}function Vr(e,t,r){let o=new Map,s=new Set,i=(c,d)=>{let h=t[c];if(h)o.set(d,h),s.add(c)},a=Kt(t,r,(c,d)=>nt(e,c,d)),l=0,u=0;for(let[c,d]of[...a,[t.length,r.length]]){let h=Kt(t.slice(l,c),r.slice(u,d),(m,g)=>zt(m)===zt(g));for(let[m,g]of h)i(l+m,u+g);if(c<t.length)i(c,d);l=c+1,u=d+1}for(let[c,d]of r.entries())if(!o.has(c)){let h=t.findIndex((m,g)=>!s.has(g)&&nt(e,m,d));if(h!==-1)i(h,c)}return o}function ot(e){let t=e.leading??"";return t.slice(t.lastIndexOf(`
|
|
15
|
+
`)+1)}function Pr(e,t,r){return e.split(`
|
|
16
|
+
`).map((o,s)=>s>0&&o.startsWith(t)?r+o.slice(t.length):o).join(`
|
|
17
|
+
`)}function Ur(e,t,r){let o=[...r],s=(a)=>{let l=a.getName(),u=o.findIndex((c)=>c.getName()===l);return u===-1?void 0:o.splice(u,1)[0]},i="";for(let a of t.entries){let l=s(a);if(l){let u=l.getTag()===a.getTag()&&l.getValue()===a.getValue();i+=u?_n(a,e.previous.text):`${a.leading??" "}${_n(l,e.next.text).trimStart()}`}}for(let a of o)i+=` ${_n(a,e.next.text).trimStart()}`;return i}function qr(e,t,r){let o=new Map;for(let i of rt(t)){let a=e.previous.pointers.get(ie(i).start);if(a!==void 0)o.set(a,i)}let s=new Map;for(let i of r.entries){let a=e.next.pointers.get(ie(i).start),l=a===void 0?void 0:o.get(a);if(l&&i.getName()!==null)s.set(l,i)}return s}function Hr(e,t,r){let{text:o}=e.previous,s=_n(r,e.next.text).trimStart().slice(`${r.getName()}=`.length),[i]=t.entries;if(i?.getName()===null&&t.entries.length===1&&!t.children){if(i.getValue()===r.getValue()&&i.getTag()===r.getTag())return vn(t,o);return`${tt(t,o)}${i.leading??" "}${s}`}return`${tt(t,o)} ${s}`}function tt(e,t){let{start:r}=ie(e),[o]=e.entries;if(o)return t.slice(r,ie(o).start-(o.leading??"").length);let s=e.children&&Ce(e.children);if(s)return t.slice(r,s.start.offset-1).trimEnd();return vn(e,t)}function zr(e,t,r,o){let s=qr(e,t,r),i=new Set(s.values()),a=r.entries.filter((g)=>!i.has(g)),l=`${tt(t,e.previous.text)}${Ur(e,t,a)}`,u=rt(r);if(u.length===0&&s.size===0)return l;let c=u[0]?ot(u[0]):`${o} `,d=t.children,h=t.beforeChildren===""?" ":t.beforeChildren??" ";if(d&&d.nodes.length>0&&Gr(d,e.previous.text,t)){let g=`${o}${Kr(d,o)}`;return`${l}${h}{${Qt(e,d,u,g,c,s)}}`}let m=u.map((g)=>Gt(e,g,c,`${o} `));return`${l}${h}{
|
|
18
|
+
${m.join("")}${o}}`}function Kr(e,t){let[r]=e.nodes,o=r?ot(r):"";return o.startsWith(t)?o.slice(t.length):" "}function Gr(e,t,r){let{end:o,start:s}=ie(r),[i]=e.nodes;return i!==void 0&&(i.leading??"").includes(`
|
|
19
|
+
`)&&t.slice(s,o).includes(`
|
|
20
|
+
`)}function Gt(e,t,r,o){return`${o}${Pr(vn(t,e.next.text),r,o)}
|
|
21
|
+
`}function Qt(e,t,r,o,s,i){let a=t.nodes.filter((H)=>!i.has(H)),l=Vr(e,a,r),u=t.nodes[0]?.leading??"",c=u.indexOf(`
|
|
22
|
+
`),d=c===-1?"":u.slice(0,c+1),h=d,m=-1,g=()=>{if(h!==""&&!h.endsWith(`
|
|
23
|
+
`)&&!h.endsWith(";"))h+=`
|
|
24
|
+
`},V=(H,te)=>{let C=t.nodes.indexOf(H),Se=C===m+1||C>m;m=Math.max(m,C);let tn=H===t.nodes[0]?u.slice(d.length):H.leading??"";if(Se&&(tn.includes(`
|
|
25
|
+
`)||h===d||h.endsWith(";"))){h+=`${tn}${te}${H.trailing??""}`;return}if(!h.endsWith(`
|
|
26
|
+
`))h+=`
|
|
27
|
+
`;let ar=(H.trailing??"").replace(/^;/u,"");h+=`${tn.includes(`
|
|
28
|
+
`)?tn:o}${te}${ar}`},Te=(H)=>{for(let[te,C]of t.nodes.entries()){let Se=i.get(C);if(Se&&te<H&&te>m)g(),V(C,Hr(e,C,Se))}};for(let[H,te]of r.entries()){let C=l.get(H);if(C){Te(t.nodes.indexOf(C)),g();let Se=nt(e,C,te)?vn(C,e.previous.text):zr(e,C,te,ot(C));V(C,Se)}else g(),h+=Gt(e,te,s,o)}return Te(t.nodes.length),`${h}${t.trailing??""}`}function st(e,t,r){let o;try{o=r(e)}catch{return t}let s=r(t),i=We(s.document);if(We(o.document)===i)return e;let a={next:Ht(s,t),previous:Ht(o,e)},l=Qt(a,me(e,{storeLocations:!0}),me(t,{storeLocations:!0}).nodes,"","",new Map);try{return We(r(l).document)===i?l:t}catch{return t}}var R=" ",it=100,Yt=/^(?![-+]?\.?\d)(?!(?:true|false|null|inf|-inf|nan)$)[^\s\\/(){};[\]"#=,\p{Cc}\p{Cf}\p{Zl}\p{Zp}]+$/u,Zt=/[\p{Cc}\p{Zl}\p{Zp}--]/u,Qr=/(?!\n)\p{Cc}|[\p{Zl}\p{Zp}--]/u,Xr=new Set(["-","attributes","script","state","style"]),q=(e)=>f(e),On=(e)=>q(e)&&n(e.$ref)&&Object.keys(e).length===1;function er(e){return!/\p{Cs}/u.test(e)}function nr(e,t){try{return me(`x ${e}`).nodes[0]?.entries[0]?.getValue()===t}catch{return!1}}function Fn(e){let t='"';for(let r of e)if(r==='"')t+=String.raw`\"`;else if(r==="\\")t+=String.raw`\\`;else if(r===`
|
|
29
|
+
`)t+=String.raw`\n`;else if(r==="\t")t+=String.raw`\t`;else if(r==="\r")t+=String.raw`\r`;else if(Zt.test(r))t+=`\\u{${r.codePointAt(0)?.toString(16)}}`;else t+=r;return`${t}"`}function tr(e,t){let r="#";while(e.includes(t+r))r+="#";return r}function Yr(e,t){if(Qr.test(e))return null;let r=tr(e,'"""'),o=`${t}${R}`,s=e.split(`
|
|
30
|
+
`).map((a)=>a===""?"":o+a),i=`${r}"""
|
|
31
|
+
${s.join(`
|
|
32
|
+
`)}
|
|
33
|
+
${o}"""${r}`;return nr(i,e)?i:null}function at(e,t,r){if(!er(e))throw new L(`${r} holds a lone surrogate, which Jx Notation has no way to spell`);if(Yt.test(e))return e;if(e.includes(`
|
|
34
|
+
`)){let o=Yr(e,t);if(o)return o}else if((e.includes("\\")||e.includes('"'))&&!Zt.test(e)){let o=tr(e,'"'),s=`${o}"${e}"${o}`;if(nr(s,e))return s}return Fn(e)}function B(e,t){if(!er(e))throw new L(`${t} is a key with a lone surrogate, which Jx Notation cannot spell`);return Yt.test(e)?e:Fn(e)}function M(e,t,r){if(e===null)return"#null";if(e===!0)return"#true";if(e===!1)return"#false";if(J(e))return Object.is(e,-0)?"-0":String(e);if(n(e))return at(e,t,r);return On(e)?`(ref)${Fn(e.$ref)}`:null}var v=(e,t)=>`${e}/${String(t).replaceAll("~","~0").replaceAll("/","~1")}`;function rr(e){if(!q(e)||e.$prototype!=="Function")return!1;let{$prototype:t,body:r,parameters:o,...s}=e,i=Object.values(s).every((c)=>M(c,"","")!==null),a=o===void 0||Array.isArray(o)&&o.length>0&&o.every((c)=>n(c))&&r!==void 0,l=r===void 0||n(r)||Array.isArray(r),u=Array.isArray(r)&&r.length===0;return i&&a&&l&&!u}function or(e,t,r,o){let{$prototype:s,body:i,parameters:a,...l}=t,u=[`${r}(fn)${B(e,o)}`];for(let[c,d]of Object.entries(l))u.push(`${B(c,o)}=${M(d,r,v(o,c))}`);if(Array.isArray(a))for(let c of a)u.push(at(String(c),r,v(o,"parameters")));if(n(i))u.push(at(i,r,v(o,"body")));else if(Array.isArray(i))return[`${u.join(" ")} {`,...i.flatMap((c,d)=>U("-",c,r+R,v(v(o,"body"),d))),`${r}}`];return[u.join(" ")]}function U(e,t,r,o){let s=B(e,o),i=r+s,a=M(t,r,o);if(a!==null)return[`${i} ${a}`];if(rr(t))return or(e,t,r,o);if(Array.isArray(t)){if(t.length===0)return[`${r}(array)${s}`];let d=t.map((m,g)=>M(m,r,v(o,g)));if(t.length>1&&d.every((m)=>m!==null&&!m.includes(`
|
|
35
|
+
`))){let m=`${i} ${d.join(" ")}`;if(m.length<=it)return[m]}return[`${i} {`,...t.flatMap((m,g)=>U("-",m,r+R,v(o,g))),`${r}}`]}let l=q(t)?Object.entries(t):[];if(l.length===0)return[`${i} {}`];let u=l.every(([d])=>d==="-")?`${r}(object)${s}`:i,c=l.map(([d,h])=>{let m=M(h,r,v(o,d));return m===null||m.includes(`
|
|
36
|
+
`)?null:`${B(d,o)}=${m}`});if(c.every((d)=>d!==null)){let d=`${u} ${c.join(" ")}`;if(d.length<=it)return[d]}return[`${u} {`,...l.flatMap(([d,h])=>U(d,h,r+R,v(o,d))),`${r}}`]}function sr(e,t,r,o){let s=Object.entries(t),i=r+B(e,o);if(s.length===0)return[`${i} {}`];let a=[],l=0;for(let[m,g]of s){let V=M(g,r,v(o,m));if(V===null||V.includes(`
|
|
37
|
+
`))break;a.push(`${B(m,o)}=${V}`),l+=1}let u=`${i} ${a.join(" ")}`,c=a.length>0&&u.length<=it,d=c?l:0,h=s.slice(d).flatMap(([m,g])=>{if(q(g)&&!On(g))return sr(m,g,r+R,v(o,m));return U(m,g,r+R,v(o,m))});if(c&&h.length===0)return[u];return[`${c?u:i} {`,...h,`${r}}`]}function Zr(e){if(!q(e)||e.$prototype!=="Array"||!q(e.map))return!1;let{$prototype:t,map:r,...o}=e;return Object.values(o).every((s)=>{let i=M(s,"","");return i!==null&&!i.includes(`
|
|
38
|
+
`)})}function eo(e,t,r){let{$prototype:o,map:s,...i}=e,a=[`${t}$array`];for(let[l,u]of Object.entries(i))a.push(`${B(l,r)}=${M(u,t,v(r,l))}`);return[`${a.join(" ")} {`,...Ye(s??null,t+R,v(r,"map")),`${t}}`]}function Ye(e,t,r){let o=M(e,t,r);if(o!==null)return[`${t}- ${o}`];if(Zr(e))return eo(e,t,r);if(q(e))return ut(e,t,r);throw new L(`${r} is a list inside a list of children, which has no spelling`)}function no(e,t,r){let{tagName:o}=e;if(!n(o))return`${t}$element`;if(Xr.has(o)||o.startsWith("$")||o.startsWith("."))return`${t}$element ${Fn(o)}`;return t+B(o,r)}function to(e,t){return t!==null&&!t.includes(`
|
|
39
|
+
`)&&!e.startsWith("on")&&!e.startsWith("$")&&!e.startsWith(".")}function ut(e,t,r){let o=[no(e,t,r)],s=t+R,i=[],a={},l=null;for(let[u,c]of Object.entries(e)){let d=v(r,u);if(u==="tagName"&&n(c))continue;if(u==="children")continue;if(u==="textContent"){let h=M(c,t,d);if(h===null||!n(e.tagName))Xt(o,i,u,c,s,t,d);else l=h}else if(u==="attributes"&&q(c))for(let[h,m]of Object.entries(c)){let g=M(m,t,v(d,h));if(to(h,g))o.push(`${B(h,d)}=${g}`);else a[h]=m}else if(u==="state")i.push(...U("state",c,s,d));else if(u==="style"&&q(c))i.push(...sr("style",c,s,d));else if(u.startsWith("on")&&On(c))o.push(`${B(u,d)}=${M(c,t,d)}`);else if(u.startsWith("on"))i.push(...rr(c)?or(u,c,s,d):U(u,c,s,d).map((h,m)=>m===0?h.replace(s,`${s}(on)`):h));else if(u.startsWith("$")){let h=M(c,t,d);if(h===null||h.includes(`
|
|
40
|
+
`))i.push(...U(u,c,s,d));else o.push(`${B(u,d)}=${h}`)}else Xt(o,i,u,c,s,t,d)}if(Object.keys(a).length>0)i.push(...U("attributes",a,s,v(r,"attributes")));if(i.push(...ro(e.children,s,v(r,"children"))),l!==null)o.push(l);return i.length===0?[o.join(" ")]:[`${o.join(" ")} {`,...i,`${t}}`]}function ro(e,t,r){if(e===void 0)return[];if(Array.isArray(e)){if(e.length===0)return[`${t}(array).children`];return e.flatMap((s,i)=>Ye(s,t,v(r,i)))}let o=M(e,t,r);if(o!==null)return[`${t}.children ${o}`];return[`${t}.children {`,...Ye(e,t+R,r),`${t}}`]}function Xt(e,t,r,o,s,i,a){let l=B(`.${r}`,a);if(r==="map"&&q(o)){t.push(`${s}${l} {`,...Ye(o,s+R,a),`${s}}`);return}if(r==="cases"&&q(o)){t.push(`${s}${l} {`);for(let[c,d]of Object.entries(o))t.push(`${s}${R}${B(c,a)} {`,...Ye(d,s+R+R,v(a,c)),`${s}${R}}`);t.push(`${s}}`);return}let u=M(o,i,a);if(u===null||u.includes(`
|
|
41
|
+
`))t.push(...U(`.${r}`,o,s,a));else e.push(`${l}=${u}`)}function oo(e,t){return["$head {",...e.flatMap((r,o)=>q(r)&&!On(r)&&n(r.tagName)&&!r.$ref?ut(r,t,`/$head/${o}`):U("-",r,t,`/$head/${o}`)),"}"]}function so(e){let{document:t,spans:r}=Zn(e);return{document:f(t)?t:null,spans:r}}function lt(e,t){let r=io(e);return t===void 0?r:st(t,r,so)}function io(e){if(!f(e))throw new L("A document is an object");let t=e,r=["/- kdl-version 2"],o={};for(let[s,i]of Object.entries(t))if(s==="$head"&&Array.isArray(i))r.push(...oo(i,R));else if(s==="$head")r.push(`(object)${U(s,i,"","/$head").join(`
|
|
42
|
+
`)}`);else if(s.startsWith("$"))r.push(...U(s,i,"",v("",s)));else o[s]=i;if(Object.keys(o).length>0)r.push("",...ut(o,"",""));return`${r.join(`
|
|
43
|
+
`)}
|
|
44
|
+
`}var nn={capabilities:{parse:{identifier:"parse",timing:["compiler","server"]},serialize:{identifier:"serialize",timing:["compiler","server"]}},documentKinds:["page","component"],exportTarget:!1,extensions:[".jxn"],mediaType:null,name:"jxn",remote:!1,studio:{documentMode:{default:"component"}}},ae=[],kn=null;function jt(){if(!kn)kn=(async()=>{try{ae=await p().listFormats?.()??[]}catch{ae=[]}return ae})();return kn}function Ih(){kn=null,ae=[],Cn=null,Ze=[],Jn=null,en=[]}var Ze=[],Cn=null;function sd(){if(!Cn)Cn=(async()=>{try{Ze=await p().listExtensions?.()??[]}catch{Ze=[]}return Ze})();return Cn}function Vy(){return Ze}var en=[],Jn=null;function ao(){if(!Jn)Jn=(async()=>{try{en=await p().listExtensionCatalog?.()??[]}catch{en=[]}return en})();return Jn}function __(){return en}async function uo(e){let t=null;try{t=await e.fetchProjectSchemas?.()??null}catch{}dt(t),await (ce("bbd1mary"),import("./jx-validate-bbd1mary.js")).then(({applyProjectSchemas:r})=>r(t)).catch(()=>!1)}function dc(e){uo(e),ao(),(ce("4z9qq0gh"),import("./extension-sections-4z9qq0gh.js")).then(({syncExtensionSettingsSections:t})=>t()).catch(()=>{})}function su(){return ae}function Fa(e,t){let r=e.startsWith(".")?e.toLowerCase():`.${e.toLowerCase()}`;if(r===".jxn")return nn;return ae.find((o)=>o.extensions.includes(r)&&(!t||o.capabilities[t]))}function zi(e){if(!e)return;return e===nn.name?nn:ae.find((t)=>t.name===e)}function hf(e){return Error(`No format class imported for "${e}" — add one to project.json imports `+`(e.g. "Markdown": "@jxsuite/parser/Markdown.class.json") and make sure the project's dependencies are installed`)}function fn(e){if(!e)return;let t=e.lastIndexOf(".");if(t===-1)return;return Fa(e.slice(t))}function Cl(e){let t=new Set;for(let r of ae){if(e&&!r.documentKinds.includes(e))continue;for(let o of r.extensions)t.add(o)}return t.delete(".json"),[...t]}async function Wy(){return await jt(),[".json",...Cl("page")]}function co(){return ae.find((e)=>e.capabilities.serialize&&e.documentKinds.includes("content"))}async function ir(e){let t=p();if(!t.formatAction)throw Error("Platform does not support format actions");return t.formatAction(e)}async function QR(e,t,r){if(e===nn.name)return uf(t);return await ir({action:"parse",format:e,options:r,source:t})}async function ja(e,t,r){if(e===nn.name)return lt(t,r?.source);return await ir({action:"serialize",doc:t,format:e,options:r})}function eI(e,t){let r=e?.studio?.documentMode,o=r?.componentWhen;if(o?.frontmatterKey){let u=t[o.frontmatterKey],c=o.matches?new RegExp(o.matches):/./;if(n(u)&&c.test(u))return{document:t,frontmatter:{},mode:"component"}}if(r?.default==="component")return{document:t,frontmatter:{},mode:"component"};let s=t.children??[];if(Array.isArray(s)&&s.length===0)s.push({children:[],tagName:"p"});let i=new Set(["state","imports"]),a={children:s},l={};for(let[u,c]of Object.entries(t)){if(u==="children")continue;if(i.has(u))a[u]=c;else l[u]=c}return{document:a,frontmatter:l,mode:"content"}}
|
|
45
|
+
export{hg,df,Hy,w_,uf,By,x_,jt,Ih,sd,Vy,__,dc,su,Fa,zi,hf,fn,Cl,Wy,co,QR,ja,eI};
|
|
46
|
+
|
|
47
|
+
//# debugId=A585A4E4637E470D64756E2164756E21
|
|
48
|
+
//# sourceMappingURL=studio-hf259xzd.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{Jn,g,Ft}from"./studio-ybkd5w8k.js";import{VD}from"./studio-z89e6wpg.js";import{sh}from"./studio-m25ry0mf.js";import{ce}from"./studio-nhpg405j.js";var e="edit",a=new Set(["edit","design"]);function r(t){for(let i of g.tabs.values())if(i.documentPath===t)return i;return null}async function Kl(t){if(!sh(t)){let o=Jn(t);if(o&&!o.fileBacked)return VD(t);let{openFileInTab:s}=await (ce("8pf70854"),import("./files-8pf70854.js"));return await s(t),r(t)}let{openFileInTab:i}=await (ce("8pf70854"),import("./files-8pf70854.js"));await i(t);let n=r(t);if(!n)return null;if(!a.has(n.session.ui.canvasMode)&&n.capabilities.modes.includes(e))n.session.ui.canvasMode=e,n.session.ui.preview=!1;return Ft(n.id),n}
|
|
2
|
+
export{Kl};
|
|
3
|
+
|
|
4
|
+
//# debugId=5D401367746C1FE664756E2164756E21
|
|
5
|
+
//# sourceMappingURL=studio-jbva4wxw.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{X}from"./studio-9c6cbq2c.js";import{p,ve}from"./studio-xh6rf05g.js";import{w}from"./studio-bk0anq3b.js";import{hs}from"./studio-wn2cmf9q.js";import{CR,i_,Ey,h}from"./studio-s49y6m5b.js";import{L1,mi,Ky}from"./studio-zav9hgb3.js";import{Rs,Kd,ZA,XA,QA}from"./studio-48yzqzqr.js";import{Ls}from"./studio-k05g7efh.js";import{aa,uI,hI,la,Ot}from"./studio-z6s56dzz.js";import{r1,mR,fh}from"./studio-w4mfaaam.js";import{x}from"./studio-zn7ysyzb.js";import{J}from"./studio-erjccagy.js";var n1="__other__";function us(t){return t.trim().toLowerCase().replaceAll(/\s+/g,"-").replaceAll(/[^a-z\d-]/g,"")}function nR(t){let e=t.lastIndexOf(".");return e>0?t.slice(e):""}function iR(t,e,n){let r=t.trim();if(n===void 0||e==="__other__")return r;if(n.kind==="fixed"){let i=us(r);return i===""?"":`${i}${n.ext}`}return r.toLowerCase().endsWith(e.toLowerCase())?r:`${r}${e}`}function ly(t,e,n){let{choice:r,dir:i,known:o=new Set,rows:s=null,taken:a}=n,l=t.trim();if(!l)return r?.kind==="fixed"?"Enter a name.":"Enter a file name.";if(r?.kind==="fixed"&&us(l)==="")return"Enter at least one letter or number.";let d=l.replaceAll("\\","/");if(d.startsWith("/")||d.endsWith("/"))return"Enter a name, not a path that starts or ends with a slash.";if(d.split("/").includes(".."))return"A name cannot step outside the destination folder.";if(d.includes("/")&&r!==void 0&&e!=="__other__")return`Pick Other… to create a file in a subfolder of ${i==="."?"the project root":i}.`;let u=nR(d);if(e!==""&&e!=="__other__"&&u!==""&&u.toLowerCase()!==e.toLowerCase()&&o.has(u.toLowerCase()))return`You picked ${s?.find((v)=>v.value===e)?.label??e}; this name ends in ${u}.`;if(r?.kind==="locked"&&e==="__other__"){if(u!==""&&u.toLowerCase()!==r.ext.toLowerCase()&&o.has(u.toLowerCase()))return r.because}let m=iR(t,e,r);return a.has(m.toLowerCase())?`${m} already exists in ${i}/.`:""}function qm(t,e,n){let r=e.trim();if(r==="")return"Enter a file name.";if(/[/\\]/.test(r))return"Enter a name, not a path. A rename keeps the file in its folder.";let i=(t.split("/").pop()??t).toLowerCase();if(r.startsWith(".")&&!i.startsWith("."))return"A name cannot start with a dot: hidden files are not listed, so the file could disappear.";let o=r.toLowerCase();if(o!==i&&[...n].some((s)=>s.toLowerCase()===o))return`${r} already exists in this folder.`;return""}function y(t){let e=["B","KB","MB","GB"],n=t,r=0;while(n>=1024&&r<e.length-1)n/=1024,r+=1;return`${r===0?n:Number(n.toFixed(1))} ${e[r]}`}var R=["image/*","video/*","audio/*",".pdf",".svg",".woff",".woff2",".ttf",".otf"].join(",");function Jc(){return(ve()?p().assetCapabilities?.accept:void 0)??R}function Vd(t){return la.has(Ot(t))}function Wd(t){let e=t.type??"";if(e.startsWith("image/"))return"image";if(e.startsWith("video/"))return"video";if(e.startsWith("audio/"))return"audio";let n=Ot(t.name);if(aa.has(n))return"image";if(uI.has(n))return"video";if(hI.has(n))return"audio";return"file"}var rR=new Set([".woff",".woff2",".ttf",".otf"]);function BA(t){if(rR.has(Ot(t)))return"font";let e=Wd({name:t});return e==="file"?"document":e}var k=/^content\/([^/]+)\//,La="public/media";function oR(t){let e=t?k.exec(t.replaceAll("\\","/")):null;return e?`content/${e[1]}/images`:La}function VA(t){let e=t.replaceAll("\\","/");return e===La||/^content\/[^/]+\/images$/.test(e)}function T(t){let e=t.replaceAll("\\","/");if(e.startsWith("public/"))return e.slice(6);let n=/^content\/[^/]+\/(.+)$/.exec(e);if(n)return`./${n[1]}`;return`./${e}`}function P(t,e){let n=new Set([...e].map((o)=>o.toLowerCase()));if(!n.has(t.toLowerCase()))return t;let r=Ot(t),i=r?t.slice(0,-r.length):t;for(let o=1;;o++){let s=`${i}-${o}${r}`;if(!n.has(s.toLowerCase()))return s}}function sR(t,e){let n=t.replaceAll("\\","/").replace(/\/+$/,"");return n==="."||n===""?e:`${n}/${e}`}var b=null;function WA(t){b=t}async function Hx(t,e){await(e===void 0?b?.(t):b?.(t,e))}function E(t){let e=t.replaceAll("\\","/"),n=e.lastIndexOf("/");return n>0?e.slice(0,n):"."}function I(t,e){let n=(o)=>e==="image"?aa.has(Ot(o.name)):Vd(o.name),r=[],i=[];for(let o of t)if(n(o))r.push(o);else i.push(o.name);if(i.length>0)w.warn(i.length===1?`Skipped ${i[0]}`:`Skipped ${i.length} files`,{detail:e==="image"?`Only images can be used here: ${i.join(", ")}.`:`Studio lists images, video, audio, PDFs and fonts as media, so ${i.join(", ")} would not appear in it.`,source:"Media"});return r}async function Qs(t,e={}){let n=e.only===void 0?[...t]:I([...t],e.only);if(n.length===0)return[];let r=p(),i=e.dir??oR(h.value?.documentPath??null),o=e.source??"Media",s;try{let d=await Rs(()=>r.listDirectory(i));s=new Set(d.map((u)=>u.name))}catch(d){if(e.dirExists===!0)return w.error(`Could not write to ${i}/.`,{detail:`The folder could not be read to choose a name that overwrites nothing: ${X(d)}`,path:i,source:o}),[];s=new Set}let a=ve()?p().assetCapabilities?.maxUploadBytes:void 0,l=[];for(let d of n){if(a!==void 0&&d.size>a){w.error(`${d.name} is too large.`,{detail:`This backend accepts at most ${y(a)}; that file is ${y(d.size)}.`,source:"Media"});continue}let u=P(d.name,s);s.add(u);let m=sR(i,u);try{let{path:f}=await(e.write?e.write(m):r.uploadFile(m,d));Kd([f]),l.push({kind:Wd(d),name:u,path:f,ref:T(f)})}catch(f){w.error(`Could not upload ${d.name}.`,{detail:X(f),path:m,source:o})}}if(l.length>0){if(e.quiet!==!0)w.success(l.length===1?`Uploaded ${l[0].name} to ${i}/`:`Uploaded ${l.length} files to ${i}/`);await b?.(i)}return l}function L(t){try{let e=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0}).decode(t);return e.startsWith("\uFEFF")?null:e}catch{return null}}function D(t){let e=t.slice(0,t.length-Ot(t).length);return`${e.replace(/-copy(?:-\d+)?$/,"")}-copy${t.slice(e.length)}`}async function Bx(t,e={}){let n=t.split("/").pop()??t,r=e.source??"Media",i;try{let a=p();if(a.readFileBytes===void 0)throw Error("This backend cannot read a file's raw bytes.");i=await a.readFileBytes(t)}catch(a){return w.error(`Could not duplicate ${n}.`,{detail:X(a),path:t,source:r}),null}let o=e.document===!0?L(i):null,[s]=await Qs([new File([i],D(n))],{dir:E(t),dirExists:!0,quiet:!0,source:r,...o!==null&&{write:async(a)=>(await p().writeFile(a,o),{path:a})}});if(!s)return null;if(s.path===t)return w.warn(`${n} was not duplicated.`,{detail:"The backend keeps identical files once, so it made no second file.",path:t,source:r}),null;return w.success(`Duplicated ${n} as ${s.name}`),s}var z=[new Set([".jpg",".jpeg"]),new Set([".tif",".tiff"])];function N(t){return z.find((e)=>e.has(t))??new Set([t])}function zA(t){return[...N(Ot(t))].join(",")}function F(t,e){return N(Ot(t)).has(Ot(e.name))}function UA(t,e,n){let r=qm(t,e,n);if(r!=="")return r;if(!F(t,{name:e.trim()}))return`Keep the ${Ot(t)} extension. A rename does not convert the file, so another extension would break it on every page.`;return""}async function Vx(t,e,n={}){let r=t.split("/").pop()??t;if(!F(t,e))return w.error(`${e.name} cannot replace ${r}.`,{detail:`${r} is ${Ot(t)||"a file with no extension"} and ${e.name} is ${Ot(e.name)||"a file with no extension"}. Every page that uses ${r} would get bytes its address does not describe; choose a file of the same type, or upload it as a new file.`,path:t,source:"Media"}),!1;let i=ve()?p().assetCapabilities?.maxUploadBytes:void 0;if(i!==void 0&&e.size>i)return w.error(`${e.name} is too large.`,{detail:`This backend accepts at most ${y(i)}; that file is ${y(e.size)}.`,source:"Media"}),!1;Ls(t);let o;try{({path:o}=await p().uploadFile(t,e))}catch(s){return w.error(`Could not replace ${r}.`,{detail:X(s),path:t,source:"Media"}),!1}if(Kd([t,o]),o===t)XA(t);if(hs(),await(o===t?Hx(E(t),t):Hx(E(t))),o!==t)return w.warn(`${r} was not replaced.`,{detail:`The backend stored the new file as ${o}, so every reference still shows the old one.`,path:t,source:"Media",tier:"problem"}),!1;return w.success(n.note===void 0?`Replaced ${r}`:`Replaced ${r}: ${n.note}`),!0}function Wx(t){let e=mi(t),n=e.lastIndexOf("/");return n===-1?e:e.slice(n+1)}function cy(t){let e=mi(t),n=e.lastIndexOf("/");return n===-1?".":e.slice(0,n)}function B(){return x?.projectConfig?.content??null}function _(t){return Ey(t,B(),mR())}function U(t,e){return`${mi(e.urlPrefix)}/${t.slice(e.dir.length+1)}`}function dy(t){let e=mi(t);if(e.startsWith(`${L1}/`))return`/${e.slice(L1.length+1)}`;let n=_(e);return n?`/${U(e,n)}`:`/${e}`}function no(t){let e=mi(t);if(e==="")return t;let{space:n,fileBaseUrl:r}=fh(),i=QA(e);if(n==="repo")return i_(CR(`${r}${Ky(e)}`,ZA(e)),i);let o=Ky(dy(e).slice(1));return i_(r1(`/${o}`),i)}var c=new Map,S=new Map,g=new Map,M=new Set;function A(t){return Ot(t)===".svg"}function C(t){let e=t===null?null:/^\s*(\d+(?:\.\d+)?)\s*(?:px)?\s*$/.exec(t),n=e?Number(e[1]):Number.NaN;return n>0?n:null}function j(t){let e=new DOMParser().parseFromString(t,"image/svg+xml").documentElement;if(e.localName!=="svg")return null;let n=C(e.getAttribute("width")),r=C(e.getAttribute("height")),i=(e.getAttribute("viewBox")??"").trim().split(/[\s,]+/).map(Number),o=i[2]??Number.NaN,s=i[3]??Number.NaN,a=i.length===4&&o>0&&s>0,l=null;if(n!==null&&r!==null)l={height:r,width:n};else if(a&&n!==null)l={height:n*s/o,width:n};else if(a&&r!==null)l={height:r,width:r*o/s};else if(a)l={height:s,width:o};return l&&{height:Math.round(l.height),width:Math.round(l.width)}}async function K(t){M.add(t);try{let e=j(await p().readFile(t));if(e&&e.width>0&&e.height>0)g.set(t,e)}catch{}}function zd(t){let e=mi(t);return c.has(e)&&(!A(e)||M.has(e))}function O(t,e){let n=Wx(t),r=g.get(t);return{bytes:J(e?.size)?e.size:null,ext:Ot(n),height:r?.height??null,kind:Wd({name:n}),modified:e?.modified??null,name:n,path:t,width:r?.width??null}}function Yc(t){return c.get(mi(t))??null}function qA(t){for(let e of t){if(e.type!=="file")continue;let n=mi(e.path);if(!c.has(n))c.set(n,O(n,e))}}async function uh(t){let e=mi(t),n=c.get(e);if(n&&zd(e))return n;let r=S.get(e);if(r)return r;let i=(async()=>{if(A(e)&&!M.has(e))await K(e);if(n){let a=g.get(e);return{...n,height:a?.height??null,width:a?.width??null}}let s;try{s=(await Rs(()=>p().listDirectory(cy(e)))).find((l)=>mi(l.path)===e)}catch{s=void 0}return O(e,s)})();S.set(e,i);let o=await i;return S.delete(e),c.set(e,o),o}function gl(t,e,n){if(!(e>0&&n>0))return!1;let r=mi(t);if(A(r))return!1;let i=g.get(r);if(i&&i.width===e&&i.height===n)return!1;g.set(r,{height:n,width:e});let o=c.get(r);if(o)c.set(r,{...o,height:n,width:e});return!0}function KA(){c.clear(),g.clear(),M.clear()}function Km(t){if(t<1024)return`${t} B`;if(t<1048576)return`${Math.round(t/1024)} KB`;return`${(t/1048576).toFixed(1)} MB`}function zx(t){if(!t)return"";let e=[];if(t.width!==null&&t.height!==null)e.push(`${t.width} × ${t.height}`);if(t.bytes!==null)e.push(Km(t.bytes));return e.join(" · ")}
|
|
2
|
-
export{
|
|
1
|
+
import{Z}from"./studio-mkjrjpr2.js";import{p,we}from"./studio-1b79rpcb.js";import{w}from"./studio-5k9mfafh.js";import{ps}from"./studio-pk961xgz.js";import{DR,l_,Ry,h}from"./studio-ybkd5w8k.js";import{M1,gi,Xy}from"./studio-52mzbxqm.js";import{Is,Gd,dP,uP,hP}from"./studio-44drsmhw.js";import{Rs}from"./studio-wqsmvtqj.js";import{la,wI,xI,ca,Ot}from"./studio-6tnpg0vx.js";import{h1,CR,bh}from"./studio-meajkr51.js";import{x}from"./studio-anc8067x.js";import{J}from"./studio-0z8kp4xk.js";var d1="__other__";function hs(t){return t.trim().toLowerCase().replaceAll(/\s+/g,"-").replaceAll(/[^a-z\d-]/g,"")}function uR(t){let e=t.lastIndexOf(".");return e>0?t.slice(e):""}function hR(t,e,n){let r=t.trim();if(n===void 0||e==="__other__")return r;if(n.kind==="fixed"){let i=hs(r);return i===""?"":`${i}${n.ext}`}return r.toLowerCase().endsWith(e.toLowerCase())?r:`${r}${e}`}function hy(t,e,n){let{choice:r,dir:i,known:o=new Set,rows:s=null,taken:a}=n,l=t.trim();if(!l)return r?.kind==="fixed"?"Enter a name.":"Enter a file name.";if(r?.kind==="fixed"&&hs(l)==="")return"Enter at least one letter or number.";let d=l.replaceAll("\\","/");if(d.startsWith("/")||d.endsWith("/"))return"Enter a name, not a path that starts or ends with a slash.";if(d.split("/").includes(".."))return"A name cannot step outside the destination folder.";if(d.includes("/")&&r!==void 0&&e!=="__other__")return`Pick Other… to create a file in a subfolder of ${i==="."?"the project root":i}.`;let u=uR(d);if(e!==""&&e!=="__other__"&&u!==""&&u.toLowerCase()!==e.toLowerCase()&&o.has(u.toLowerCase()))return`You picked ${s?.find((v)=>v.value===e)?.label??e}; this name ends in ${u}.`;if(r?.kind==="locked"&&e==="__other__"){if(u!==""&&u.toLowerCase()!==r.ext.toLowerCase()&&o.has(u.toLowerCase()))return r.because}let m=hR(t,e,r);return a.has(m.toLowerCase())?`${m} already exists in ${i}/.`:""}function Ym(t,e,n){let r=e.trim();if(r==="")return"Enter a file name.";if(/[/\\]/.test(r))return"Enter a name, not a path. A rename keeps the file in its folder.";let i=(t.split("/").pop()??t).toLowerCase();if(r.startsWith(".")&&!i.startsWith("."))return"A name cannot start with a dot: hidden files are not listed, so the file could disappear.";let o=r.toLowerCase();if(o!==i&&[...n].some((s)=>s.toLowerCase()===o))return`${r} already exists in this folder.`;return""}function y(t){let e=["B","KB","MB","GB"],n=t,r=0;while(n>=1024&&r<e.length-1)n/=1024,r+=1;return`${r===0?n:Number(n.toFixed(1))} ${e[r]}`}var R=["image/*","video/*","audio/*",".pdf",".svg",".woff",".woff2",".ttf",".otf"].join(",");function Zc(){return(we()?p().assetCapabilities?.accept:void 0)??R}function zd(t){return ca.has(Ot(t))}function Ud(t){let e=t.type??"";if(e.startsWith("image/"))return"image";if(e.startsWith("video/"))return"video";if(e.startsWith("audio/"))return"audio";let n=Ot(t.name);if(la.has(n))return"image";if(wI.has(n))return"video";if(xI.has(n))return"audio";return"file"}var pR=new Set([".woff",".woff2",".ttf",".otf"]);function eP(t){if(pR.has(Ot(t)))return"font";let e=Ud({name:t});return e==="file"?"document":e}var k=/^content\/([^/]+)\//,Ia="public/media";function fR(t){let e=t?k.exec(t.replaceAll("\\","/")):null;return e?`content/${e[1]}/images`:Ia}function tP(t){let e=t.replaceAll("\\","/");return e===Ia||/^content\/[^/]+\/images$/.test(e)}function T(t){let e=t.replaceAll("\\","/");if(e.startsWith("public/"))return e.slice(6);let n=/^content\/[^/]+\/(.+)$/.exec(e);if(n)return`./${n[1]}`;return`./${e}`}function P(t,e){let n=new Set([...e].map((o)=>o.toLowerCase()));if(!n.has(t.toLowerCase()))return t;let r=Ot(t),i=r?t.slice(0,-r.length):t;for(let o=1;;o++){let s=`${i}-${o}${r}`;if(!n.has(s.toLowerCase()))return s}}function mR(t,e){let n=t.replaceAll("\\","/").replace(/\/+$/,"");return n==="."||n===""?e:`${n}/${e}`}var b=null;function nP(t){b=t}async function Ux(t,e){await(e===void 0?b?.(t):b?.(t,e))}function E(t){let e=t.replaceAll("\\","/"),n=e.lastIndexOf("/");return n>0?e.slice(0,n):"."}function I(t,e){let n=(o)=>e==="image"?la.has(Ot(o.name)):zd(o.name),r=[],i=[];for(let o of t)if(n(o))r.push(o);else i.push(o.name);if(i.length>0)w.warn(i.length===1?`Skipped ${i[0]}`:`Skipped ${i.length} files`,{detail:e==="image"?`Only images can be used here: ${i.join(", ")}.`:`Studio lists images, video, audio, PDFs and fonts as media, so ${i.join(", ")} would not appear in it.`,source:"Media"});return r}async function ea(t,e={}){let n=e.only===void 0?[...t]:I([...t],e.only);if(n.length===0)return[];let r=p(),i=e.dir??fR(h.value?.documentPath??null),o=e.source??"Media",s;try{let d=await Is(()=>r.listDirectory(i));s=new Set(d.map((u)=>u.name))}catch(d){if(e.dirExists===!0)return w.error(`Could not write to ${i}/.`,{detail:`The folder could not be read to choose a name that overwrites nothing: ${Z(d)}`,path:i,source:o}),[];s=new Set}let a=we()?p().assetCapabilities?.maxUploadBytes:void 0,l=[];for(let d of n){if(a!==void 0&&d.size>a){w.error(`${d.name} is too large.`,{detail:`This backend accepts at most ${y(a)}; that file is ${y(d.size)}.`,source:"Media"});continue}let u=P(d.name,s);s.add(u);let m=mR(i,u);try{let{path:f}=await(e.write?e.write(m):r.uploadFile(m,d));Gd([f]),l.push({kind:Ud(d),name:u,path:f,ref:T(f)})}catch(f){w.error(`Could not upload ${d.name}.`,{detail:Z(f),path:m,source:o})}}if(l.length>0){if(e.quiet!==!0)w.success(l.length===1?`Uploaded ${l[0].name} to ${i}/`:`Uploaded ${l.length} files to ${i}/`);await b?.(i)}return l}function L(t){try{let e=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0}).decode(t);return e.startsWith("\uFEFF")?null:e}catch{return null}}function D(t){let e=t.slice(0,t.length-Ot(t).length);return`${e.replace(/-copy(?:-\d+)?$/,"")}-copy${t.slice(e.length)}`}async function qx(t,e={}){let n=t.split("/").pop()??t,r=e.source??"Media",i;try{let a=p();if(a.readFileBytes===void 0)throw Error("This backend cannot read a file's raw bytes.");i=await a.readFileBytes(t)}catch(a){return w.error(`Could not duplicate ${n}.`,{detail:Z(a),path:t,source:r}),null}let o=e.document===!0?L(i):null,[s]=await ea([new File([i],D(n))],{dir:E(t),dirExists:!0,quiet:!0,source:r,...o!==null&&{write:async(a)=>(await p().writeFile(a,o),{path:a})}});if(!s)return null;if(s.path===t)return w.warn(`${n} was not duplicated.`,{detail:"The backend keeps identical files once, so it made no second file.",path:t,source:r}),null;return w.success(`Duplicated ${n} as ${s.name}`),s}var z=[new Set([".jpg",".jpeg"]),new Set([".tif",".tiff"])];function N(t){return z.find((e)=>e.has(t))??new Set([t])}function iP(t){return[...N(Ot(t))].join(",")}function F(t,e){return N(Ot(t)).has(Ot(e.name))}function rP(t,e,n){let r=Ym(t,e,n);if(r!=="")return r;if(!F(t,{name:e.trim()}))return`Keep the ${Ot(t)} extension. A rename does not convert the file, so another extension would break it on every page.`;return""}async function Jx(t,e,n={}){let r=t.split("/").pop()??t;if(!F(t,e))return w.error(`${e.name} cannot replace ${r}.`,{detail:`${r} is ${Ot(t)||"a file with no extension"} and ${e.name} is ${Ot(e.name)||"a file with no extension"}. Every page that uses ${r} would get bytes its address does not describe; choose a file of the same type, or upload it as a new file.`,path:t,source:"Media"}),!1;let i=we()?p().assetCapabilities?.maxUploadBytes:void 0;if(i!==void 0&&e.size>i)return w.error(`${e.name} is too large.`,{detail:`This backend accepts at most ${y(i)}; that file is ${y(e.size)}.`,source:"Media"}),!1;Rs(t);let o;try{({path:o}=await p().uploadFile(t,e))}catch(s){return w.error(`Could not replace ${r}.`,{detail:Z(s),path:t,source:"Media"}),!1}if(Gd([t,o]),o===t)uP(t);if(ps(),await(o===t?Ux(E(t),t):Ux(E(t))),o!==t)return w.warn(`${r} was not replaced.`,{detail:`The backend stored the new file as ${o}, so every reference still shows the old one.`,path:t,source:"Media",tier:"problem"}),!1;return w.success(n.note===void 0?`Replaced ${r}`:`Replaced ${r}: ${n.note}`),!0}function Kx(t){let e=gi(t),n=e.lastIndexOf("/");return n===-1?e:e.slice(n+1)}function py(t){let e=gi(t),n=e.lastIndexOf("/");return n===-1?".":e.slice(0,n)}function B(){return x?.projectConfig?.content??null}function _(t){return Ry(t,B(),CR())}function U(t,e){return`${gi(e.urlPrefix)}/${t.slice(e.dir.length+1)}`}function fy(t){let e=gi(t);if(e.startsWith(`${M1}/`))return`/${e.slice(M1.length+1)}`;let n=_(e);return n?`/${U(e,n)}`:`/${e}`}function io(t){let e=gi(t);if(e==="")return t;let{space:n,fileBaseUrl:r}=bh(),i=hP(e);if(n==="repo")return l_(DR(`${r}${Xy(e)}`,dP(e)),i);let o=Xy(fy(e).slice(1));return l_(h1(`/${o}`),i)}var c=new Map,S=new Map,g=new Map,M=new Set;function A(t){return Ot(t)===".svg"}function C(t){let e=t===null?null:/^\s*(\d+(?:\.\d+)?)\s*(?:px)?\s*$/.exec(t),n=e?Number(e[1]):Number.NaN;return n>0?n:null}function j(t){let e=new DOMParser().parseFromString(t,"image/svg+xml").documentElement;if(e.localName!=="svg")return null;let n=C(e.getAttribute("width")),r=C(e.getAttribute("height")),i=(e.getAttribute("viewBox")??"").trim().split(/[\s,]+/).map(Number),o=i[2]??Number.NaN,s=i[3]??Number.NaN,a=i.length===4&&o>0&&s>0,l=null;if(n!==null&&r!==null)l={height:r,width:n};else if(a&&n!==null)l={height:n*s/o,width:n};else if(a&&r!==null)l={height:r,width:r*o/s};else if(a)l={height:s,width:o};return l&&{height:Math.round(l.height),width:Math.round(l.width)}}async function K(t){M.add(t);try{let e=j(await p().readFile(t));if(e&&e.width>0&&e.height>0)g.set(t,e)}catch{}}function qd(t){let e=gi(t);return c.has(e)&&(!A(e)||M.has(e))}function O(t,e){let n=Kx(t),r=g.get(t);return{bytes:J(e?.size)?e.size:null,ext:Ot(n),height:r?.height??null,kind:Ud({name:n}),modified:e?.modified??null,name:n,path:t,width:r?.width??null}}function Xc(t){return c.get(gi(t))??null}function oP(t){for(let e of t){if(e.type!=="file")continue;let n=gi(e.path);if(!c.has(n))c.set(n,O(n,e))}}async function fh(t){let e=gi(t),n=c.get(e);if(n&&qd(e))return n;let r=S.get(e);if(r)return r;let i=(async()=>{if(A(e)&&!M.has(e))await K(e);if(n){let a=g.get(e);return{...n,height:a?.height??null,width:a?.width??null}}let s;try{s=(await Is(()=>p().listDirectory(py(e)))).find((l)=>gi(l.path)===e)}catch{s=void 0}return O(e,s)})();S.set(e,i);let o=await i;return S.delete(e),c.set(e,o),o}function yl(t,e,n){if(!(e>0&&n>0))return!1;let r=gi(t);if(A(r))return!1;let i=g.get(r);if(i&&i.width===e&&i.height===n)return!1;g.set(r,{height:n,width:e});let o=c.get(r);if(o)c.set(r,{...o,height:n,width:e});return!0}function sP(){c.clear(),g.clear(),M.clear()}function Zm(t){if(t<1024)return`${t} B`;if(t<1048576)return`${Math.round(t/1024)} KB`;return`${(t/1048576).toFixed(1)} MB`}function Gx(t){if(!t)return"";let e=[];if(t.width!==null&&t.height!==null)e.push(`${t.width} × ${t.height}`);if(t.bytes!==null)e.push(Zm(t.bytes));return e.join(" · ")}
|
|
2
|
+
export{d1,hs,uR,hR,hy,Ym,Zc,zd,Ud,pR,eP,Ia,fR,tP,mR,nP,Ux,ea,qx,iP,rP,Jx,Kx,py,fy,io,qd,Xc,oP,fh,yl,sP,Zm,Gx};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
5
|
-
//# sourceMappingURL=studio-
|
|
4
|
+
//# debugId=8907CFCFC19AE97F64756E2164756E21
|
|
5
|
+
//# sourceMappingURL=studio-jj9gf1qc.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{Z}from"./studio-mkjrjpr2.js";import{Pe,ro,Zd,h}from"./studio-ybkd5w8k.js";import{w}from"./studio-5k9mfafh.js";import{p}from"./studio-1b79rpcb.js";import{De,Ra,Kc}from"./studio-mrb10hv3.js";import{Fn}from"./studio-yetr4gg1.js";import{Ow,Nb}from"./studio-0wa4wv4s.js";import{oC}from"./studio-a4ymg4vd.js";import{zt,Wi}from"./studio-anc8067x.js";import{re}from"./studio-ft706q02.js";import{vr}from"./studio-213pyfxh.js";import{S,rt}from"./studio-0z8kp4xk.js";function yw(){let t=h.value,e=Pe(t?.session.selection);if(!t||!e||e.length<2)return null;let o=re(t.doc.document,e);if(!o||!o.tagName)return null;return{node:o,path:e}}async function mm(){let t=yw();if(!t)return;let e=await b(g(t.node));if(!e)return;await zE(e.toLowerCase())}async function zE(t){let e=h.value,o=yw();if(!e||!o)return null;let{node:m,path:f}=o,l=v(m);l.tagName=t;let r=`components/${t}.json`,c=Kc(e.documentPath,r),u=f;if(!Zd(e,(n)=>{let s=zt(u)??[],d=Wi(u),a=n;for(let i of s)a=a[i];if(!Array.isArray(a.children))a.children=[];if(a.children[d]={tagName:t},!n.$elements)n.$elements=[];if(!n.$elements.some((i)=>S(i)&&("$ref"in i)&&i.$ref===c))n.$elements.push({$ref:c})}))return null;try{await p().writeFile(r,vr(l,null)),await Ra();let s=oC(l);if(w.success(`Converted to <${t}>`),s)w.warn(`<${t}> has a slot problem: ${s}`,{path:r,source:"Components",tier:"problem"});return r}catch(n){return w.error(`Could not save the <${t}> component.`,{detail:Z(n),path:r,source:"Components"}),null}}function g(t){if(t.$id){let o=Nb(t.$id);if(o!=="")return o}let e=(rt(t.tagName)||"div").toLowerCase();return e.includes("-")?e:Nb(e)}function v(t){let e=ro(t);return delete e.$id,delete e.$layout,delete e.$paths,e}function N(t){let e=t.trim().toLowerCase(),o=Ow(e);if(o!=="")return o;return De.some((m)=>m.tagName===e)?`Component <${e}> already exists`:""}function b(t){return Fn("Convert to Component",{confirmLabel:"Convert",message:"Enter a hyphenated tag name for the new component.",placeholder:"my-component",validate:N,value:t})}
|
|
2
|
+
export{yw,mm,zE};
|
|
3
|
+
|
|
4
|
+
//# debugId=9E5EFA93F8BA2D3864756E2164756E21
|
|
5
|
+
//# sourceMappingURL=studio-jsjg3mjv.js.map
|