@plitzi/sdk-authoring 0.37.1 → 0.37.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -35,6 +35,7 @@ var elementAttributeNames = {
35
35
  "pageParam",
36
36
  "pagination",
37
37
  "query",
38
+ "refreshSeconds",
38
39
  "renderWhileLoading",
39
40
  "resource",
40
41
  "singleRecord",
@@ -469,6 +470,124 @@ var elementAttributeNames = {
469
470
  ]
470
471
  };
471
472
  //#endregion
473
+ //#region ../sdk-elements/dist/Element/helpers/elementConstants.mjs
474
+ var e$21 = {
475
+ onLoad: {
476
+ action: "onLoad",
477
+ title: "On Load",
478
+ type: "trigger",
479
+ preview: {},
480
+ params: {}
481
+ },
482
+ onClick: {
483
+ action: "onClick",
484
+ title: "On Click",
485
+ type: "trigger",
486
+ preview: { propagateEvent: "" },
487
+ params: { propagateEvent: {
488
+ canBind: !1,
489
+ defaultValue: !1,
490
+ type: "boolean",
491
+ label: "Propagate Event"
492
+ } }
493
+ },
494
+ onMouseEnter: {
495
+ action: "onMouseEnter",
496
+ title: "On Mouse Enter",
497
+ type: "trigger",
498
+ preview: { propagateEvent: "" },
499
+ params: { propagateEvent: {
500
+ canBind: !1,
501
+ defaultValue: !1,
502
+ type: "boolean",
503
+ label: "Propagate Event"
504
+ } }
505
+ },
506
+ onMouseLeave: {
507
+ action: "onMouseLeave",
508
+ title: "On Mouse Leave",
509
+ type: "trigger",
510
+ preview: { propagateEvent: "" },
511
+ params: { propagateEvent: {
512
+ canBind: !1,
513
+ defaultValue: !1,
514
+ type: "boolean",
515
+ label: "Propagate Event"
516
+ } }
517
+ },
518
+ onHover: {
519
+ action: "onHover",
520
+ title: "On Hover",
521
+ type: "trigger",
522
+ preview: { propagateEvent: "" },
523
+ params: { propagateEvent: {
524
+ canBind: !1,
525
+ defaultValue: !1,
526
+ type: "boolean",
527
+ label: "Propagate Event"
528
+ } }
529
+ },
530
+ onFocus: {
531
+ action: "onFocus",
532
+ title: "On Focus",
533
+ type: "trigger",
534
+ preview: { propagateEvent: "" },
535
+ params: { propagateEvent: {
536
+ canBind: !1,
537
+ defaultValue: !1,
538
+ type: "boolean",
539
+ label: "Propagate Event"
540
+ } }
541
+ },
542
+ onBlur: {
543
+ action: "onBlur",
544
+ title: "On Blur",
545
+ type: "trigger",
546
+ preview: { propagateEvent: "" },
547
+ params: { propagateEvent: {
548
+ canBind: !1,
549
+ defaultValue: !1,
550
+ type: "boolean",
551
+ label: "Propagate Event"
552
+ } }
553
+ },
554
+ onFlowEnd: {
555
+ action: "onFlowEnd",
556
+ title: "On Server Action End",
557
+ type: "trigger",
558
+ preview: {
559
+ actionId: "",
560
+ runId: "",
561
+ status: "",
562
+ output: {}
563
+ },
564
+ params: {}
565
+ },
566
+ onFlowError: {
567
+ action: "onFlowError",
568
+ title: "On Server Action Error",
569
+ type: "trigger",
570
+ preview: {
571
+ actionId: "",
572
+ runId: "",
573
+ error: "",
574
+ reason: ""
575
+ },
576
+ params: {}
577
+ },
578
+ onFlowProgress: {
579
+ action: "onFlowProgress",
580
+ title: "On Server Action Progress",
581
+ type: "trigger",
582
+ preview: {
583
+ actionId: "",
584
+ runId: "",
585
+ chunk: ""
586
+ },
587
+ params: {}
588
+ }
589
+ };
590
+ //#endregion
472
591
  //#region ../sdk-shared/dist/authoring/declare.mjs
473
592
  var e = () => (e) => e;
474
593
  //#endregion
@@ -864,6 +983,7 @@ var t$45 = e()({
864
983
  //#region ../sdk-elements/dist/elements/basic/Dropdown/DropdownPopup/declaration.mjs
865
984
  var t$44 = e()({
866
985
  type: "dropdownPopup",
986
+ ancestorType: "dropdown",
867
987
  content: {
868
988
  attributes: {},
869
989
  definition: {
@@ -897,7 +1017,7 @@ var t$44 = e()({
897
1017
  name: "Dropdown Popup",
898
1018
  displayMode: "desktop",
899
1019
  style: { base: { default: {
900
- "background-color": "white",
1020
+ "background-color": "light-dark(white, oklch(0.21 0.006 285.885))",
901
1021
  "padding-right": "4px",
902
1022
  "padding-bottom": "4px",
903
1023
  "padding-left": "4px",
@@ -1259,6 +1379,13 @@ var t$38 = e()({
1259
1379
  //#region ../sdk-elements/dist/elements/basic/ThemeToggle/declaration.mjs
1260
1380
  var t$37 = e()({
1261
1381
  type: "themeToggle",
1382
+ triggers: { onThemeChange: {
1383
+ action: "onThemeChange",
1384
+ title: "On Theme Change",
1385
+ type: "trigger",
1386
+ params: {},
1387
+ preview: { theme: "dark" }
1388
+ } },
1262
1389
  content: {
1263
1390
  attributes: {
1264
1391
  subType: "switch",
@@ -1270,7 +1397,7 @@ var t$37 = e()({
1270
1397
  definition: {
1271
1398
  label: "Theme Toggle",
1272
1399
  type: "themeToggle",
1273
- description: "Lets a visitor choose light or dark. It writes the choice on the document root, where a space stylesheet is already looking for it, and remembers it — so the machine decides until somebody says otherwise. It ships no colours of its own: style it with the space own classes, and use `data-theme-icon` to decide which icon each scheme shows.",
1400
+ description: "Lets a visitor choose light or dark. It writes the choice on the document root, where a space stylesheet is already looking for it, and remembers it — so the machine decides until somebody says otherwise. It ships no colours of its own: style it with the space own classes. It shows the icon of the scheme in use by default; key a rule off `data-theme-icon` to change that.",
1274
1401
  items: [],
1275
1402
  bindings: {},
1276
1403
  styleSelectors: {
@@ -1316,6 +1443,61 @@ var t$37 = e()({
1316
1443
  var t$36 = e()({
1317
1444
  type: "form",
1318
1445
  sourceType: "apiContainer",
1446
+ triggers: { onSubmit: {
1447
+ action: "onSubmit",
1448
+ title: "On Form Submit",
1449
+ type: "trigger",
1450
+ params: {},
1451
+ preview: {
1452
+ values: {},
1453
+ actionUrl: "",
1454
+ method: ""
1455
+ }
1456
+ } },
1457
+ callbacks: {
1458
+ performReset: {
1459
+ action: "performReset",
1460
+ title: "Reset Form",
1461
+ type: "callback",
1462
+ params: {}
1463
+ },
1464
+ setFieldValue: {
1465
+ action: "setFieldValue",
1466
+ title: "Set Field Value",
1467
+ type: "callback",
1468
+ preview: {},
1469
+ params: {
1470
+ name: {
1471
+ label: "Field Name",
1472
+ defaultValue: void 0,
1473
+ type: "select",
1474
+ options: []
1475
+ },
1476
+ value: {
1477
+ type: "text",
1478
+ defaultValue: ""
1479
+ }
1480
+ }
1481
+ },
1482
+ setFieldError: {
1483
+ action: "setFieldError",
1484
+ title: "Set Field Error",
1485
+ type: "callback",
1486
+ preview: {},
1487
+ params: {
1488
+ name: {
1489
+ label: "Field Name",
1490
+ defaultValue: void 0,
1491
+ type: "select",
1492
+ options: []
1493
+ },
1494
+ error: {
1495
+ type: "text",
1496
+ defaultValue: ""
1497
+ }
1498
+ }
1499
+ }
1500
+ },
1319
1501
  content: {
1320
1502
  attributes: {
1321
1503
  method: "get",
@@ -1411,6 +1593,16 @@ var i$13 = {
1411
1593
  };
1412
1594
  var a$10 = e()({
1413
1595
  type: "formControl",
1596
+ triggers: { onChange: {
1597
+ action: "onChange",
1598
+ title: "On Change",
1599
+ type: "trigger",
1600
+ params: {},
1601
+ preview: {
1602
+ value: "",
1603
+ name: ""
1604
+ }
1605
+ } },
1414
1606
  content: {
1415
1607
  attributes: {
1416
1608
  subType: "text",
@@ -1688,6 +1880,17 @@ var t$32 = e()({
1688
1880
  //#region ../sdk-elements/dist/elements/internal/Page/declaration.mjs
1689
1881
  var t$31 = e()({
1690
1882
  type: "page",
1883
+ triggers: { onPageLoad: {
1884
+ action: "onPageLoad",
1885
+ title: "On Page Load",
1886
+ type: "trigger",
1887
+ params: {},
1888
+ preview: {
1889
+ pageId: "",
1890
+ routeParams: "",
1891
+ queryParams: ""
1892
+ }
1893
+ } },
1691
1894
  content: {
1692
1895
  attributes: {
1693
1896
  enabled: !0,
@@ -1899,6 +2102,77 @@ var F = {
1899
2102
  ApiContainer: e()({
1900
2103
  type: "apiContainer",
1901
2104
  sourceType: "apiContainer",
2105
+ triggers: {
2106
+ onApiError: {
2107
+ action: "onApiError",
2108
+ title: "On Api Error",
2109
+ type: "trigger",
2110
+ params: {},
2111
+ preview: {
2112
+ url: "",
2113
+ method: "",
2114
+ status: "",
2115
+ data: ""
2116
+ }
2117
+ },
2118
+ onApiSuccess: {
2119
+ action: "onApiSuccess",
2120
+ title: "On Api Success",
2121
+ type: "trigger",
2122
+ params: {},
2123
+ preview: {
2124
+ url: "",
2125
+ method: "",
2126
+ status: "",
2127
+ data: ""
2128
+ }
2129
+ }
2130
+ },
2131
+ callbacks: {
2132
+ performQuery: {
2133
+ action: "performQuery",
2134
+ title: "Perform Query",
2135
+ type: "callback",
2136
+ preview: {},
2137
+ params: {}
2138
+ },
2139
+ loadMore: {
2140
+ action: "loadMore",
2141
+ title: "Load More",
2142
+ type: "callback",
2143
+ preview: {},
2144
+ params: {}
2145
+ },
2146
+ goToPage: {
2147
+ action: "goToPage",
2148
+ title: "Go To Page",
2149
+ type: "callback",
2150
+ preview: {},
2151
+ params: { page: {
2152
+ label: "Page",
2153
+ defaultValue: "1",
2154
+ type: "text"
2155
+ } }
2156
+ },
2157
+ writeRecord: {
2158
+ action: "writeRecord",
2159
+ title: "Write Record",
2160
+ type: "callback",
2161
+ preview: { action: "create" },
2162
+ params: {
2163
+ action: {
2164
+ label: "Endpoint",
2165
+ defaultValue: "create",
2166
+ type: "text"
2167
+ },
2168
+ recordId: {
2169
+ label: "Record Id",
2170
+ defaultValue: "",
2171
+ type: "text"
2172
+ }
2173
+ }
2174
+ }
2175
+ },
1902
2176
  content: {
1903
2177
  attributes: {
1904
2178
  query: "",
@@ -1922,7 +2196,7 @@ var F = {
1922
2196
  definition: {
1923
2197
  label: "Api Container",
1924
2198
  type: "apiContainer",
1925
- description: "Fetches data from a backend HTTP API (its `query`/`method`/`credentials`) and exposes the response as a data source ITS DESCENDANTS bind to (source `apiContainer_<id>.data`; only elements inside it can consume it). This is how you get backend data into the frontend. Its `mockData` prop is builder-only sample data — the published runtime fetches the real `query`, so always set a real query for production. With `cache: true` a browser request is kept for `staleTime` seconds (default 30) and shared with every provider asking the same thing; it is off unless set. A flow refreshes it with `performQuery` or the global `invalidateQueries` step. Its `subType` (container tag) is empty by default, and then it renders NO element of its own: its children lay out directly in its parent, and any class, variant or style binding on it applies to nothing. To style the provider itself give it a tag (`subType: \"div\"`, `section`, …); otherwise style its parent or a child.",
2199
+ description: "Fetches data from a backend HTTP API (its `query`/`method`/`credentials`) and exposes the response as a data source ITS DESCENDANTS bind to (source `apiContainer_<id>.data`; only elements inside it can consume it). This is how you get backend data into the frontend. Its `mockData` prop is builder-only sample data — the published runtime fetches the real `query`, so always set a real query for production. With `cache: true` a browser request is kept for `staleTime` seconds (default 30) and shared with every provider asking the same thing; it is off unless set. A flow refreshes it with `performQuery` or the global `invalidateQueries` step, and `refreshSeconds` makes it ask again on its own every N seconds (either runtime; paused while the tab is hidden) — the way to keep a queue, feed or status board current without a plugin. Its `subType` (container tag) is empty by default, and then it renders NO element of its own: its children lay out directly in its parent, and any class, variant or style binding on it applies to nothing. To style the provider itself give it a tag (`subType: \"div\"`, `section`, …); otherwise style its parent or a child.",
1926
2200
  items: [],
1927
2201
  bindings: {},
1928
2202
  styleSelectors: { base: "" },
@@ -2002,6 +2276,67 @@ var F = {
2002
2276
  DialogContainer: e()({
2003
2277
  type: "dialogContainer",
2004
2278
  sourceType: "dialogContainer",
2279
+ triggers: {
2280
+ onDialogAccept: {
2281
+ action: "onDialogAccept",
2282
+ title: "On Dialog Accept",
2283
+ type: "trigger",
2284
+ params: { metadata: {
2285
+ type: "text",
2286
+ defaultValue: ""
2287
+ } },
2288
+ preview: { metadata: "" }
2289
+ },
2290
+ onDialogReject: {
2291
+ action: "onDialogReject",
2292
+ title: "On Dialog Reject",
2293
+ type: "trigger",
2294
+ params: { metadata: {
2295
+ type: "text",
2296
+ defaultValue: ""
2297
+ } },
2298
+ preview: { metadata: "" }
2299
+ },
2300
+ onDialogOpen: {
2301
+ action: "onDialogOpen",
2302
+ title: "On Dialog Open",
2303
+ type: "trigger",
2304
+ params: { metadata: {
2305
+ type: "text",
2306
+ defaultValue: ""
2307
+ } },
2308
+ preview: { metadata: "" }
2309
+ },
2310
+ onDialogClose: {
2311
+ action: "onDialogClose",
2312
+ title: "On Dialog Close",
2313
+ type: "trigger",
2314
+ params: { metadata: {
2315
+ type: "text",
2316
+ defaultValue: ""
2317
+ } },
2318
+ preview: { metadata: "" }
2319
+ }
2320
+ },
2321
+ callbacks: {
2322
+ openDialog: {
2323
+ action: "openDialog",
2324
+ title: "Open Dialog",
2325
+ type: "callback",
2326
+ params: { metadata: {
2327
+ type: "text",
2328
+ defaultValue: ""
2329
+ } },
2330
+ preview: { metadata: "" }
2331
+ },
2332
+ closeDialog: {
2333
+ action: "closeDialog",
2334
+ title: "Close Dialog",
2335
+ type: "callback",
2336
+ preview: {},
2337
+ params: {}
2338
+ }
2339
+ },
2005
2340
  content: {
2006
2341
  attributes: {
2007
2342
  headerLabel: "Dialog Header",
@@ -2076,7 +2411,7 @@ var F = {
2076
2411
  left: "50%",
2077
2412
  width: "500px",
2078
2413
  height: "300px",
2079
- "background-color": "white",
2414
+ "background-color": "light-dark(white, oklch(0.21 0.006 285.885))",
2080
2415
  transform: "translate3d(-50%, -50%, 0px)",
2081
2416
  "padding-top": "20px",
2082
2417
  "padding-bottom": "20px",
@@ -2247,6 +2582,44 @@ var F = {
2247
2582
  ModalContainer: e()({
2248
2583
  type: "modalContainer",
2249
2584
  sourceType: "modalContainer",
2585
+ triggers: {
2586
+ onModalOpen: {
2587
+ action: "onModalOpen",
2588
+ title: "On Modal Open",
2589
+ type: "trigger",
2590
+ params: { metadata: {
2591
+ type: "text",
2592
+ defaultValue: ""
2593
+ } },
2594
+ preview: { metadata: "" }
2595
+ },
2596
+ onModalClose: {
2597
+ action: "onModalClose",
2598
+ title: "On Modal Close",
2599
+ type: "trigger",
2600
+ preview: {},
2601
+ params: {}
2602
+ }
2603
+ },
2604
+ callbacks: {
2605
+ openModal: {
2606
+ action: "openModal",
2607
+ title: "Open Modal",
2608
+ type: "callback",
2609
+ params: { metadata: {
2610
+ type: "text",
2611
+ defaultValue: ""
2612
+ } },
2613
+ preview: { metadata: "" }
2614
+ },
2615
+ closeModal: {
2616
+ action: "closeModal",
2617
+ title: "Close Modal",
2618
+ type: "callback",
2619
+ params: {},
2620
+ preview: {}
2621
+ }
2622
+ },
2250
2623
  content: {
2251
2624
  attributes: {
2252
2625
  title: "Modal Header",
@@ -2316,7 +2689,7 @@ var F = {
2316
2689
  left: "50%",
2317
2690
  width: "500px",
2318
2691
  height: "300px",
2319
- "background-color": "white",
2692
+ "background-color": "light-dark(white, oklch(0.21 0.006 285.885))",
2320
2693
  transform: "translate3d(-50%, -50%, 0px)",
2321
2694
  "border-top-left-radius": "8px",
2322
2695
  "border-top-right-radius": "8px",
@@ -2328,7 +2701,7 @@ var F = {
2328
2701
  "align-items": "center",
2329
2702
  "justify-content": "space-between",
2330
2703
  "border-bottom-width": "1px",
2331
- "border-bottom-color": "#d1d5db",
2704
+ "border-bottom-color": "light-dark(#d1d5db, oklch(0.37 0.013 285.805))",
2332
2705
  "border-bottom-style": "solid",
2333
2706
  "padding-left": "20px",
2334
2707
  "padding-right": "20px",
@@ -2373,6 +2746,13 @@ var F = {
2373
2746
  Page: t$31,
2374
2747
  Pagination: e()({
2375
2748
  type: "pagination",
2749
+ triggers: { onPageChange: {
2750
+ action: "onPageChange",
2751
+ title: "On Page Change",
2752
+ type: "trigger",
2753
+ params: {},
2754
+ preview: { page: "1" }
2755
+ } },
2376
2756
  content: {
2377
2757
  attributes: {
2378
2758
  pageInfo: {},
@@ -2471,6 +2851,7 @@ var F = {
2471
2851
  }),
2472
2852
  TabContainerBody: e()({
2473
2853
  type: "tabContainerBody",
2854
+ ancestorType: "tabContainer",
2474
2855
  content: {
2475
2856
  attributes: {},
2476
2857
  definition: {
@@ -2516,6 +2897,7 @@ var F = {
2516
2897
  }),
2517
2898
  TabContainerHeader: e()({
2518
2899
  type: "tabContainerHeader",
2900
+ ancestorType: "tabContainer",
2519
2901
  content: {
2520
2902
  attributes: {},
2521
2903
  definition: {
@@ -2608,6 +2990,139 @@ var F = {
2608
2990
  Video: t$28
2609
2991
  };
2610
2992
  //#endregion
2993
+ //#region ../sdk-shared/dist/helpers/twigWrapper/tokens/tokenPatterns.mjs
2994
+ var e$20 = "[a-zA-Z_][a-zA-Z0-9_]*(?:-[a-zA-Z0-9_]+)*";
2995
+ var t$16 = `(?:${e$20}|\\d+)`;
2996
+ var n$15 = `\\[\\s*(?:\\d+|'[^']*'|"[^"]*"|${e$20}(?:\\.${t$16})*)\\s*\\]`;
2997
+ var r$13 = `${`${e$20}(?:${n$15})*(?:\\??\\.${t$16}(?:${n$15})*)*`}(?:\\s*\\?\\?\\s*[^|{}]+?)?(?:\\s*\\|\\s*[a-zA-Z_]+(?:\\([^)]*\\))?)*`;
2998
+ var i$12 = `\\{\\{\\s*${r$13}\\s*\\}\\}`;
2999
+ var a$9 = `(?:${`\\{\\{\\{\\s*${r$13}\\s*\\}\\}\\}`}|${i$12})`;
3000
+ var o$8 = new RegExp(a$9, "g");
3001
+ var s$6 = RegExp(`^${a$9}$`);
3002
+ //#endregion
3003
+ //#region ../sdk-shared/dist/helpers/twigWrapper/tokens/hasValidToken.mjs
3004
+ var n$14 = (n, r = !1) => {
3005
+ if (typeof n != "string") return !1;
3006
+ let i = r ? s$6 : o$8;
3007
+ return i.lastIndex = 0, i.test(n.trim());
3008
+ };
3009
+ //#endregion
3010
+ //#region ../sdk-shared/dist/authoring/paramSpec.mjs
3011
+ var t$1 = (e, t, n) => {
3012
+ let r = [];
3013
+ for (let [i, a] of Object.entries(n)) a.when && e[i] !== void 0 && !a.when(t) && r.push(i);
3014
+ return r;
3015
+ };
3016
+ var n$1 = (e, t, n) => {
3017
+ let r = [];
3018
+ for (let [i, a] of Object.entries(n)) a.required && e[i] === void 0 && (!a.when || a.when(t)) && r.push(i);
3019
+ return r;
3020
+ };
3021
+ var r$12 = (e) => e.trim() !== "" && Number.isFinite(Number(e));
3022
+ var i$11 = (t) => typeof t == "string" && n$14(t);
3023
+ var a$8 = (e, t) => {
3024
+ switch (t.type) {
3025
+ case "boolean": return typeof e == "boolean";
3026
+ case "number": return typeof e == "number" || typeof e == "string" && r$12(e);
3027
+ case "select": return typeof e == "string" && (!t.options || t.options.includes(e));
3028
+ case "scalar": return typeof e == "string" || typeof e == "number" || typeof e == "boolean";
3029
+ case "text":
3030
+ case "textarea": return typeof e == "string";
3031
+ case "elementIds": return Array.isArray(e) && e.every((e) => typeof e == "string");
3032
+ default: return !0;
3033
+ }
3034
+ };
3035
+ var o = (e, t, n) => {
3036
+ let r = [];
3037
+ for (let [o, s] of Object.entries(n)) {
3038
+ let n = e[o];
3039
+ n === void 0 || i$11(n) || s.when && !s.when(t) || a$8(n, s) || r.push({
3040
+ key: o,
3041
+ expected: s.type,
3042
+ got: n === null ? "null" : typeof n,
3043
+ ...s.options ? { options: s.options } : {}
3044
+ });
3045
+ }
3046
+ return r;
3047
+ };
3048
+ var s = (e, t, n) => {
3049
+ let r = {};
3050
+ for (let [i, a] of Object.entries(e)) (!n || i in t) && (r[i] = a);
3051
+ for (let [e, n] of Object.entries(t)) n.default === void 0 || r[e] !== void 0 || n.when && !n.when(r) || (r[e] = n.default);
3052
+ return r;
3053
+ };
3054
+ //#endregion
3055
+ //#region ../sdk-shared/dist/authoring/elementCallbacks.mjs
3056
+ var t = {
3057
+ setState: {
3058
+ title: "Update Element (set attribute / state)",
3059
+ type: "callback",
3060
+ strictParams: !0,
3061
+ params: {
3062
+ category: {
3063
+ type: "select",
3064
+ description: "What to change on the element: \"attribute\" sets one of its props (the common case — e.g. content, disabled); \"state\" sets element state (visibility or a style selector). REQUIRED — always set it.",
3065
+ default: "attribute",
3066
+ options: ["attribute", "state"],
3067
+ required: !0
3068
+ },
3069
+ key: {
3070
+ type: "text",
3071
+ description: "The field to set. When category=\"attribute\", an attribute/prop key of THIS element (e.g. \"content\", \"disabled\"). When category=\"state\", \"visibility\" or \"styleSelectors.<selector>\". REQUIRED.",
3072
+ required: !0
3073
+ },
3074
+ value: {
3075
+ type: "scalar",
3076
+ description: "The value to set — its type follows the target attribute: a real boolean (true/false) for a boolean attribute, a number for a numeric one, otherwise a string (the strings \"true\"/\"false\" also coerce). There is NO separate `type` param (that belongs to the global state setState, not this one). REQUIRED.",
3077
+ when: (e) => !!e.category,
3078
+ required: !0
3079
+ },
3080
+ revertOnFinish: {
3081
+ type: "boolean",
3082
+ description: "When true, this change is UNDONE automatically when the whole flow finishes. Use it for a TEMPORARY change (a \"loading…\" label, disabling a button while it works) instead of adding manual restore steps at the end of the flow.",
3083
+ default: !1,
3084
+ label: "Revert changes after interaction"
3085
+ }
3086
+ }
3087
+ },
3088
+ toggleState: {
3089
+ title: "Toggle Element (flip attribute / state)",
3090
+ type: "callback",
3091
+ strictParams: !0,
3092
+ params: {
3093
+ category: {
3094
+ type: "select",
3095
+ description: "What to flip on the element: \"attribute\" flips one of its props (e.g. disabled); \"state\" flips element state (\"visibility\", or \"styleSelectors.<selector>\" for an expanded/collapsed look). REQUIRED.",
3096
+ default: "state",
3097
+ options: ["attribute", "state"],
3098
+ required: !0
3099
+ },
3100
+ key: {
3101
+ type: "text",
3102
+ description: "The field to flip. When category=\"attribute\", an attribute/prop key of THIS element. When category=\"state\", \"visibility\" or \"styleSelectors.<selector>\". Anything not already true counts as false, so a field that has never been set flips ON first. REQUIRED.",
3103
+ required: !0
3104
+ },
3105
+ revertOnFinish: {
3106
+ type: "boolean",
3107
+ description: "When true, the flip is UNDONE automatically when the whole flow finishes — a change that lasts only as long as the flow does.",
3108
+ default: !1,
3109
+ label: "Revert changes after interaction"
3110
+ }
3111
+ }
3112
+ }
3113
+ };
3114
+ var n = (e) => Object.hasOwn(t, e) ? t[e] : void 0;
3115
+ var r = (t, r) => {
3116
+ let i = n(t);
3117
+ return i ? {
3118
+ known: !0,
3119
+ params: s(r, i.params, i.strictParams)
3120
+ } : {
3121
+ known: !1,
3122
+ params: r
3123
+ };
3124
+ };
3125
+ //#endregion
2611
3126
  //#region src/elements/catalog.ts
2612
3127
  /** Keyed by the schema `type`, which is what a document and every catalog address a type by. */
2613
3128
  var elementCatalog = Object.fromEntries(Object.values(F).map((declaration) => [declaration.type, {
@@ -2629,16 +3144,45 @@ var elementTypeNames = Object.keys(elementCatalog);
2629
3144
  * keep in step with the runtime.
2630
3145
  */
2631
3146
  var elementSourceTypes = Object.fromEntries(Object.values(F).filter((declaration) => declaration.sourceType).map((declaration) => [declaration.type, declaration.sourceType]));
3147
+ /**
3148
+ * Every trigger each built-in type fires: the ones all elements share, and the ones its declaration adds.
3149
+ *
3150
+ * What lets a flow on the wrong element be refused instead of written. The trigger names an event, and only the
3151
+ * element that fires it ever starts the flow — an `onSubmit` on a form's submit button is saved, looks right beside
3152
+ * the form, and never runs, which is how a working form reads as "forms do not work outside the builder".
3153
+ */
3154
+ var elementTriggers = Object.fromEntries(Object.values(F).map((declaration) => [declaration.type, [...Object.keys(e$21), ...Object.keys(declaration.triggers ?? {})]]));
3155
+ /** The triggers only some types fire, by action name — for a step builder that wants the title the builder shows. */
3156
+ var typeTriggerDefinitions = Object.fromEntries(Object.values(F).flatMap((declaration) => Object.entries(declaration.triggers ?? {})));
3157
+ /**
3158
+ * Every element callback each built-in type answers to: `setState` and `toggleState`, which every element registers,
3159
+ * and the ones its declaration adds.
3160
+ *
3161
+ * A callback runs on the element it names, so aiming it at one of the wrong type is the same silent dead end as a
3162
+ * trigger on the wrong element — the builder offers `openModal` only on a modal, and a hand-written step does not.
3163
+ */
3164
+ var elementCallbacks = Object.fromEntries(Object.values(F).map((declaration) => [declaration.type, [...Object.keys(t), ...Object.keys(declaration.callbacks ?? {})]]));
3165
+ /** The sub-elements that only work inside another type, and that type — see `ElementDeclarationData.ancestorType`. */
3166
+ var elementAncestorTypes = Object.fromEntries(Object.values(F).filter((declaration) => declaration.ancestorType).map((declaration) => [declaration.type, declaration.ancestorType]));
3167
+ /**
3168
+ * The OTHER selectors each type dresses — a modal's `rootContainer`, a form control's `input` — by type.
3169
+ *
3170
+ * Every element carries a class per slot (`plitzi__<type>-<slot>`), and that is what a space's per-type `slots` style
3171
+ * addresses. A document that names only the slots its author styled leaves the rest of them classless, so the style
3172
+ * the space wrote for the TYPE reaches some of its elements and not others — which is a themed modal beside a white one.
3173
+ */
3174
+ var elementSlots = Object.fromEntries(Object.values(F).map((declaration) => [declaration.type, Object.keys(declaration.content?.definition?.styleSelectors ?? {}).filter((slot) => slot !== "base")]));
2632
3175
  //#endregion
2633
3176
  //#region src/elements/element.ts
2634
3177
  var buildSpec = (type, declaration, props) => {
2635
- const { id, class: shared, css, states, variant, slots, bind, visible, flows, runtime, loadStrategy, children, meta, ...attributes } = props;
3178
+ const { id, class: shared, css, states, selector, variant, slots, bind, visible, flows, runtime, loadStrategy, children, meta, ...attributes } = props;
2636
3179
  return {
2637
3180
  type,
2638
3181
  ...id === void 0 ? {} : { id },
2639
3182
  ...shared === void 0 ? {} : { class: shared },
2640
3183
  ...css === void 0 ? {} : { css },
2641
3184
  ...states === void 0 ? {} : { states },
3185
+ ...selector === void 0 ? {} : { selector },
2642
3186
  ...variant === void 0 ? {} : { variant },
2643
3187
  ...slots === void 0 ? {} : { slots },
2644
3188
  ...bind === void 0 ? {} : { bind },
@@ -2731,187 +3275,69 @@ var elements_exports = /* @__PURE__ */ __exportAll({
2731
3275
  video: () => video
2732
3276
  });
2733
3277
  /**
2734
- * A factory per element, named after it.
2735
- *
2736
- * Names only: every attribute type, every default and the builder label come off the element's own declaration, so
2737
- * adding an element here cannot get its types wrong — and forgetting to add one is what `elements.test.ts` fails
2738
- * on, by walking the catalogue.
2739
- *
2740
- * The internal types (`page`, `loading`, `notFound`, `layoutContainer`) have no factory on purpose: a page is
2741
- * declared as a `PageSpec`, and the other three are the machinery's own.
2742
- *
2743
- * The sub-elements are here — a list's row, a dropdown's panel, a tab's three parts. They are real types that
2744
- * appear in real documents, and their components are attached to their parent rather than exported on their own,
2745
- * which is why their declarations had to be written before they could be authored at all.
2746
- */
2747
- var apiContainer = defineElement(F.ApiContainer);
2748
- var blockHtml = defineElement(F.BlockHtml);
2749
- var blockJsx = defineElement(F.BlockJsx);
2750
- var button = defineElement(F.Button);
2751
- var container = defineElement(F.Container);
2752
- var custom = defineElement(F.Custom);
2753
- var dialogContainer = defineElement(F.DialogContainer);
2754
- var dropdown = defineElement(F.Dropdown);
2755
- var dropdownPopup = defineElement(F.DropdownPopup);
2756
- var fontAwesome = defineElement(F.FontAwesome);
2757
- var form = defineElement(F.Form);
2758
- var formControl = defineElement(F.FormControl);
2759
- var heading = defineElement(F.Heading);
2760
- var image = defineElement(F.Image);
2761
- var link = defineElement(F.Link);
2762
- var list = defineElement(F.List);
2763
- var listItem = defineElement(F.ListItem);
2764
- var markdown = defineElement(F.Markdown);
2765
- var modalContainer = defineElement(F.ModalContainer);
2766
- var nodeHtml = defineElement(F.NodeHtml);
2767
- var pagination = defineElement(F.Pagination);
2768
- var paragraph = defineElement(F.Paragraph);
2769
- var reference = defineElement(F.Reference);
2770
- var richText = defineElement(F.RichText);
2771
- var tabContainer = defineElement(F.TabContainer);
2772
- var tabContainerBody = defineElement(F.TabContainerBody);
2773
- var tabContainerHeader = defineElement(F.TabContainerHeader);
2774
- var tabContainerItem = defineElement(F.TabContainerItem);
2775
- var text = defineElement(F.Text);
2776
- var themeToggle = defineElement(F.ThemeToggle);
2777
- var video = defineElement(F.Video);
2778
- //#endregion
2779
- //#region src/elements/plugins.ts
2780
- /**
2781
- * Factories for the element types a plugin publishes.
2782
- *
2783
- * A plugin's `pluginSchema` entry has the same shape as a built-in element's declaration — attributes, definition,
2784
- * builder metadata, default style — which is the whole reason authoring a plugin type costs nothing extra: the
2785
- * manifest a deployment already fetches to render the space is also what makes its types authorable.
2786
- *
2787
- * Types are the caller's to supply, since a manifest is JSON and carries none:
2788
- * `elementsFromManifest<{ chart: ChartAttributes }>(manifest)`.
2789
- */
2790
- var elementsFromManifest = (manifest) => Object.fromEntries(Object.entries(manifest.pluginSchema).map(([type, schema]) => [type, defineElement({
2791
- type,
2792
- content: {
2793
- attributes: schema.attributes,
2794
- definition: { label: schema.definition.label }
2795
- }
2796
- })]));
2797
- //#endregion
2798
- //#region ../sdk-elements/dist/Element/helpers/elementConstants.mjs
2799
- var e$20 = {
2800
- onLoad: {
2801
- action: "onLoad",
2802
- title: "On Load",
2803
- type: "trigger",
2804
- preview: {},
2805
- params: {}
2806
- },
2807
- onClick: {
2808
- action: "onClick",
2809
- title: "On Click",
2810
- type: "trigger",
2811
- preview: { propagateEvent: "" },
2812
- params: { propagateEvent: {
2813
- canBind: !1,
2814
- defaultValue: !1,
2815
- type: "boolean",
2816
- label: "Propagate Event"
2817
- } }
2818
- },
2819
- onMouseEnter: {
2820
- action: "onMouseEnter",
2821
- title: "On Mouse Enter",
2822
- type: "trigger",
2823
- preview: { propagateEvent: "" },
2824
- params: { propagateEvent: {
2825
- canBind: !1,
2826
- defaultValue: !1,
2827
- type: "boolean",
2828
- label: "Propagate Event"
2829
- } }
2830
- },
2831
- onMouseLeave: {
2832
- action: "onMouseLeave",
2833
- title: "On Mouse Leave",
2834
- type: "trigger",
2835
- preview: { propagateEvent: "" },
2836
- params: { propagateEvent: {
2837
- canBind: !1,
2838
- defaultValue: !1,
2839
- type: "boolean",
2840
- label: "Propagate Event"
2841
- } }
2842
- },
2843
- onHover: {
2844
- action: "onHover",
2845
- title: "On Hover",
2846
- type: "trigger",
2847
- preview: { propagateEvent: "" },
2848
- params: { propagateEvent: {
2849
- canBind: !1,
2850
- defaultValue: !1,
2851
- type: "boolean",
2852
- label: "Propagate Event"
2853
- } }
2854
- },
2855
- onFocus: {
2856
- action: "onFocus",
2857
- title: "On Focus",
2858
- type: "trigger",
2859
- preview: { propagateEvent: "" },
2860
- params: { propagateEvent: {
2861
- canBind: !1,
2862
- defaultValue: !1,
2863
- type: "boolean",
2864
- label: "Propagate Event"
2865
- } }
2866
- },
2867
- onBlur: {
2868
- action: "onBlur",
2869
- title: "On Blur",
2870
- type: "trigger",
2871
- preview: { propagateEvent: "" },
2872
- params: { propagateEvent: {
2873
- canBind: !1,
2874
- defaultValue: !1,
2875
- type: "boolean",
2876
- label: "Propagate Event"
2877
- } }
2878
- },
2879
- onFlowEnd: {
2880
- action: "onFlowEnd",
2881
- title: "On Server Action End",
2882
- type: "trigger",
2883
- preview: {
2884
- actionId: "",
2885
- runId: "",
2886
- status: "",
2887
- output: {}
2888
- },
2889
- params: {}
2890
- },
2891
- onFlowError: {
2892
- action: "onFlowError",
2893
- title: "On Server Action Error",
2894
- type: "trigger",
2895
- preview: {
2896
- actionId: "",
2897
- runId: "",
2898
- error: "",
2899
- reason: ""
2900
- },
2901
- params: {}
2902
- },
2903
- onFlowProgress: {
2904
- action: "onFlowProgress",
2905
- title: "On Server Action Progress",
2906
- type: "trigger",
2907
- preview: {
2908
- actionId: "",
2909
- runId: "",
2910
- chunk: ""
2911
- },
2912
- params: {}
3278
+ * A factory per element, named after it.
3279
+ *
3280
+ * Names only: every attribute type, every default and the builder label come off the element's own declaration, so
3281
+ * adding an element here cannot get its types wrong — and forgetting to add one is what `elements.test.ts` fails
3282
+ * on, by walking the catalogue.
3283
+ *
3284
+ * The internal types (`page`, `loading`, `notFound`, `layoutContainer`) have no factory on purpose: a page is
3285
+ * declared as a `PageSpec`, and the other three are the machinery's own.
3286
+ *
3287
+ * The sub-elements are here — a list's row, a dropdown's panel, a tab's three parts. They are real types that
3288
+ * appear in real documents, and their components are attached to their parent rather than exported on their own,
3289
+ * which is why their declarations had to be written before they could be authored at all.
3290
+ */
3291
+ var apiContainer = defineElement(F.ApiContainer);
3292
+ var blockHtml = defineElement(F.BlockHtml);
3293
+ var blockJsx = defineElement(F.BlockJsx);
3294
+ var button = defineElement(F.Button);
3295
+ var container = defineElement(F.Container);
3296
+ var custom = defineElement(F.Custom);
3297
+ var dialogContainer = defineElement(F.DialogContainer);
3298
+ var dropdown = defineElement(F.Dropdown);
3299
+ var dropdownPopup = defineElement(F.DropdownPopup);
3300
+ var fontAwesome = defineElement(F.FontAwesome);
3301
+ var form = defineElement(F.Form);
3302
+ var formControl = defineElement(F.FormControl);
3303
+ var heading = defineElement(F.Heading);
3304
+ var image = defineElement(F.Image);
3305
+ var link = defineElement(F.Link);
3306
+ var list = defineElement(F.List);
3307
+ var listItem = defineElement(F.ListItem);
3308
+ var markdown = defineElement(F.Markdown);
3309
+ var modalContainer = defineElement(F.ModalContainer);
3310
+ var nodeHtml = defineElement(F.NodeHtml);
3311
+ var pagination = defineElement(F.Pagination);
3312
+ var paragraph = defineElement(F.Paragraph);
3313
+ var reference = defineElement(F.Reference);
3314
+ var richText = defineElement(F.RichText);
3315
+ var tabContainer = defineElement(F.TabContainer);
3316
+ var tabContainerBody = defineElement(F.TabContainerBody);
3317
+ var tabContainerHeader = defineElement(F.TabContainerHeader);
3318
+ var tabContainerItem = defineElement(F.TabContainerItem);
3319
+ var text = defineElement(F.Text);
3320
+ var themeToggle = defineElement(F.ThemeToggle);
3321
+ var video = defineElement(F.Video);
3322
+ //#endregion
3323
+ //#region src/elements/plugins.ts
3324
+ /**
3325
+ * Factories for the element types a plugin publishes.
3326
+ *
3327
+ * A plugin's `pluginSchema` entry has the same shape as a built-in element's declaration — attributes, definition,
3328
+ * builder metadata, default style — which is the whole reason authoring a plugin type costs nothing extra: the
3329
+ * manifest a deployment already fetches to render the space is also what makes its types authorable.
3330
+ *
3331
+ * Types are the caller's to supply, since a manifest is JSON and carries none:
3332
+ * `elementsFromManifest<{ chart: ChartAttributes }>(manifest)`.
3333
+ */
3334
+ var elementsFromManifest = (manifest) => Object.fromEntries(Object.entries(manifest.pluginSchema).map(([type, schema]) => [type, defineElement({
3335
+ type,
3336
+ content: {
3337
+ attributes: schema.attributes,
3338
+ definition: { label: schema.definition.label }
2913
3339
  }
2914
- };
3340
+ })]));
2915
3341
  //#endregion
2916
3342
  //#region src/elements/steps.ts
2917
3343
  /**
@@ -2921,8 +3347,12 @@ var e$20 = {
2921
3347
  * may publish triggers of its own — a form's `onSubmit`, a provider's page change — and refusing those would make
2922
3348
  * the builders useless for exactly the flows that matter most.
2923
3349
  */
3350
+ var declaredTrigger = (trigger) => {
3351
+ if (Object.hasOwn(e$21, trigger)) return e$21[trigger];
3352
+ return Object.hasOwn(typeTriggerDefinitions, trigger) ? typeTriggerDefinitions[trigger] : void 0;
3353
+ };
2924
3354
  var on = (trigger, params = {}) => {
2925
- const declared = Object.hasOwn(e$20, trigger) ? e$20[trigger] : void 0;
3355
+ const declared = declaredTrigger(trigger);
2926
3356
  return {
2927
3357
  type: "trigger",
2928
3358
  action: trigger,
@@ -2942,6 +3372,14 @@ var onSubmit = () => on("onSubmit");
2942
3372
  var onClick = (params = {}) => on("onClick", params);
2943
3373
  var onLoad = () => on("onLoad");
2944
3374
  /**
3375
+ * A page has this second load event in addition to {@link onLoad}.
3376
+ *
3377
+ * `onLoad` runs for every mounted element, including a page. `onPageLoad` belongs only to the page and carries its
3378
+ * id plus the current route and query params, so it is the one to use when a flow needs to make a decision from the
3379
+ * address that brought the visitor here.
3380
+ */
3381
+ var onPageLoad = () => on("onPageLoad");
3382
+ /**
2945
3383
  * The end of a server action this element started — the trigger a `detached` run needs, because that step returns
2946
3384
  * the moment the server accepts the work and leaves the page with nothing to react to when it finishes.
2947
3385
  */
@@ -2996,6 +3434,44 @@ var reloadApi = (target) => ({
2996
3434
  params: {}
2997
3435
  });
2998
3436
  /**
3437
+ * Opens a `modalContainer`, by id.
3438
+ *
3439
+ * A modal starts OPEN: declare it `visible: false` — its starting state, not a condition — and open it with this.
3440
+ * `metadata` travels into the modal, which publishes it as its source, so the content can read what opened it
3441
+ * (`{{ modalContainer_<id>.content }}` for a plain value). An element callback, so `target` is the MODAL's id.
3442
+ */
3443
+ var openModal = (target, metadata) => ({
3444
+ type: "callback",
3445
+ action: "openModal",
3446
+ title: "Open Modal",
3447
+ on: target,
3448
+ params: metadata === void 0 ? {} : { metadata }
3449
+ });
3450
+ /** Closes a `modalContainer`, by id — from a button inside it or anywhere else. */
3451
+ var closeModal = (target) => ({
3452
+ type: "callback",
3453
+ action: "closeModal",
3454
+ title: "Close Modal",
3455
+ on: target,
3456
+ params: {}
3457
+ });
3458
+ /** Opens a `dialogContainer`, by id, the way {@link openModal} opens a modal — it starts open too. */
3459
+ var openDialog = (target, metadata) => ({
3460
+ type: "callback",
3461
+ action: "openDialog",
3462
+ title: "Open Dialog",
3463
+ on: target,
3464
+ params: metadata === void 0 ? {} : { metadata }
3465
+ });
3466
+ /** Closes a `dialogContainer`, by id. */
3467
+ var closeDialog = (target) => ({
3468
+ type: "callback",
3469
+ action: "closeDialog",
3470
+ title: "Close Dialog",
3471
+ on: target,
3472
+ params: {}
3473
+ });
3474
+ /**
2999
3475
  * The same write as {@link updateElement}, storing the opposite of what is there — a panel that expands on one click
3000
3476
  * and collapses on the next, from ONE step on ONE trigger.
3001
3477
  *
@@ -3017,7 +3493,7 @@ var e$19 = {
3017
3493
  elements: "Only these containers",
3018
3494
  none: "None — this only reads"
3019
3495
  };
3020
- var t$16 = (t, n = () => !0) => ({
3496
+ var t$15 = (t, n = () => !0) => ({
3021
3497
  invalidateQueries: {
3022
3498
  type: "select",
3023
3499
  description: "What to refresh once the write succeeded, so the page shows the new data: the cached requests to the same site, all of them, only the api containers named in `invalidateElements`, or none for a step that only reads. Containers on screen ask again at once; the rest when they are shown.",
@@ -3039,7 +3515,7 @@ var t$16 = (t, n = () => !0) => ({
3039
3515
  });
3040
3516
  //#endregion
3041
3517
  //#region ../sdk-interactions/dist/sources/ActionsSource/callbacks.mjs
3042
- var t$15 = {
3518
+ var t$14 = {
3043
3519
  runServerAction: {
3044
3520
  source: "actions",
3045
3521
  title: "Run Server Action",
@@ -3080,7 +3556,7 @@ var t$15 = {
3080
3556
  default: "",
3081
3557
  when: (e) => e.mode !== "detached"
3082
3558
  },
3083
- ...t$16([
3559
+ ...t$15([
3084
3560
  "all",
3085
3561
  "elements",
3086
3562
  "none"
@@ -3396,68 +3872,6 @@ var e$14 = {
3396
3872
  }
3397
3873
  };
3398
3874
  //#endregion
3399
- //#region ../sdk-shared/dist/helpers/twigWrapper/tokens/tokenPatterns.mjs
3400
- var e$13 = "[a-zA-Z_][a-zA-Z0-9_]*(?:-[a-zA-Z0-9_]+)*";
3401
- var t$14 = `(?:${e$13}|\\d+)`;
3402
- var n$15 = `\\[\\s*(?:\\d+|'[^']*'|"[^"]*"|${e$13}(?:\\.${t$14})*)\\s*\\]`;
3403
- var r$13 = `${`${e$13}(?:${n$15})*(?:\\??\\.${t$14}(?:${n$15})*)*`}(?:\\s*\\?\\?\\s*[^|{}]+?)?(?:\\s*\\|\\s*[a-zA-Z_]+(?:\\([^)]*\\))?)*`;
3404
- var i$12 = `\\{\\{\\s*${r$13}\\s*\\}\\}`;
3405
- var a$9 = `(?:${`\\{\\{\\{\\s*${r$13}\\s*\\}\\}\\}`}|${i$12})`;
3406
- var o$8 = new RegExp(a$9, "g");
3407
- var s$6 = RegExp(`^${a$9}$`);
3408
- //#endregion
3409
- //#region ../sdk-shared/dist/helpers/twigWrapper/tokens/hasValidToken.mjs
3410
- var n$14 = (n, r = !1) => {
3411
- if (typeof n != "string") return !1;
3412
- let i = r ? s$6 : o$8;
3413
- return i.lastIndex = 0, i.test(n.trim());
3414
- };
3415
- //#endregion
3416
- //#region ../sdk-shared/dist/authoring/paramSpec.mjs
3417
- var t$1 = (e, t, n) => {
3418
- let r = [];
3419
- for (let [i, a] of Object.entries(n)) a.when && e[i] !== void 0 && !a.when(t) && r.push(i);
3420
- return r;
3421
- };
3422
- var n$1 = (e, t, n) => {
3423
- let r = [];
3424
- for (let [i, a] of Object.entries(n)) a.required && e[i] === void 0 && (!a.when || a.when(t)) && r.push(i);
3425
- return r;
3426
- };
3427
- var r$12 = (e) => e.trim() !== "" && Number.isFinite(Number(e));
3428
- var i$11 = (t) => typeof t == "string" && n$14(t);
3429
- var a$8 = (e, t) => {
3430
- switch (t.type) {
3431
- case "boolean": return typeof e == "boolean";
3432
- case "number": return typeof e == "number" || typeof e == "string" && r$12(e);
3433
- case "select": return typeof e == "string" && (!t.options || t.options.includes(e));
3434
- case "scalar": return typeof e == "string" || typeof e == "number" || typeof e == "boolean";
3435
- case "text":
3436
- case "textarea": return typeof e == "string";
3437
- case "elementIds": return Array.isArray(e) && e.every((e) => typeof e == "string");
3438
- default: return !0;
3439
- }
3440
- };
3441
- var o = (e, t, n) => {
3442
- let r = [];
3443
- for (let [o, s] of Object.entries(n)) {
3444
- let n = e[o];
3445
- n === void 0 || i$11(n) || s.when && !s.when(t) || a$8(n, s) || r.push({
3446
- key: o,
3447
- expected: s.type,
3448
- got: n === null ? "null" : typeof n,
3449
- ...s.options ? { options: s.options } : {}
3450
- });
3451
- }
3452
- return r;
3453
- };
3454
- var s = (e, t, n) => {
3455
- let r = {};
3456
- for (let [i, a] of Object.entries(e)) (!n || i in t) && (r[i] = a);
3457
- for (let [e, n] of Object.entries(t)) n.default === void 0 || r[e] !== void 0 || n.when && !n.when(r) || (r[e] = n.default);
3458
- return r;
3459
- };
3460
- //#endregion
3461
3875
  //#region ../sdk-shared/dist/authoring/spaceCallbacks.mjs
3462
3876
  var e$1 = { addNotification: {
3463
3877
  source: "space",
@@ -3530,7 +3944,7 @@ var BUILTIN_GLOBAL_CALLBACKS = {
3530
3944
  ...e$17,
3531
3945
  ...e$16,
3532
3946
  ...e$18,
3533
- ...t$15,
3947
+ ...t$14,
3534
3948
  ...e$15
3535
3949
  };
3536
3950
  /** The built-in globalCallback for an action, or undefined when the action is not a known built-in (a plugin
@@ -3787,7 +4201,7 @@ var BUILTIN_UTILITIES = {
3787
4201
  label: "Fresh for (s)",
3788
4202
  when: (e) => t$13(e) && (e.cache === !0 || e.cache === "true")
3789
4203
  },
3790
- ...t$16([
4204
+ ...t$15([
3791
4205
  "origin",
3792
4206
  "all",
3793
4207
  "elements",
@@ -3817,11 +4231,11 @@ var applyUtility = (action, params) => {
3817
4231
  };
3818
4232
  //#endregion
3819
4233
  //#region ../sdk-shared/dist/actions/failureHandler.mjs
3820
- var e$12 = "flow.onFailure";
4234
+ var e$13 = "flow.onFailure";
3821
4235
  //#endregion
3822
4236
  //#region ../sdk-schema/dist/helpers/elementId.mjs
3823
- var e$11 = /^[A-Za-z](?:[A-Za-z0-9_-]*[A-Za-z0-9_])?$/;
3824
- var t$12 = (t) => e$11.test(t);
4237
+ var e$12 = /^[A-Za-z](?:[A-Za-z0-9_-]*[A-Za-z0-9_])?$/;
4238
+ var t$12 = (t) => e$12.test(t);
3825
4239
  var r$11 = (e) => new Set(Object.keys(e));
3826
4240
  var i$10 = (e, n, r) => t$12(n) ? e[n] && n !== r ? `"${n}" is already used by another element here` : null : `"${n}" is not a valid name: start with a letter, then letters, numbers, hyphens and underscores`;
3827
4241
  var a$7 = (e, t) => {
@@ -3848,13 +4262,13 @@ var l$3 = (e, t) => {
3848
4262
  for (; t(`${n}-${r}`);) r += 1;
3849
4263
  return `${n}-${r}`;
3850
4264
  };
3851
- var u$2 = (e, t) => {
4265
+ var u$3 = (e, t) => {
3852
4266
  if (!t(e)) return e;
3853
4267
  let n = /^(.*[A-Za-z0-9])-(\d+)$/.exec(e), r = n ? n[1] : e, i = n ? Number(n[2]) + 1 : 2;
3854
4268
  for (; t(`${r}-${i}`);) i += 1;
3855
4269
  return `${r}-${i}`;
3856
4270
  };
3857
- var d$2 = {
4271
+ var d$3 = {
3858
4272
  page: [{ attribute: "layout" }, { attribute: "layoutContainer" }],
3859
4273
  reference: [{
3860
4274
  attribute: "referenceId",
@@ -3911,7 +4325,7 @@ var _ = (e, t, n) => {
3911
4325
  t[n.id] && (n.id = t[n.id], e = !0);
3912
4326
  let { definition: r, attributes: o } = n;
3913
4327
  t[r.rootId] && (r.rootId = t[r.rootId], e = !0), r.parentId && t[r.parentId] && (r.parentId = t[r.parentId], e = !0), r.items?.some((e) => t[e]) && (r.items = r.items.map(i), e = !0);
3914
- for (let { attribute: n, when: i } of d$2[r.type] ?? []) {
4328
+ for (let { attribute: n, when: i } of d$3[r.type] ?? []) {
3915
4329
  let r = o[n];
3916
4330
  typeof r == "string" && t[r] && (!i || i(o)) && (o[n] = t[r], e = !0);
3917
4331
  }
@@ -4077,10 +4491,16 @@ var verifyParams = (verify) => verify ? {
4077
4491
  ...verify.timestampHeader ? { signatureTimestampHeader: verify.timestampHeader } : {},
4078
4492
  ...verify.toleranceSeconds === void 0 ? {} : { signatureToleranceSeconds: String(verify.toleranceSeconds) }
4079
4493
  } : {};
4080
- var triggerStep = (spec, id) => ({
4494
+ /**
4495
+ * A way in, as the step the flow starts on. Titled with the action's name: the trigger's title IS what the builder,
4496
+ * the run history and the queue call the action (`actionName`), and left to the default it would read as its kind —
4497
+ * a workspace of actions all called "render".
4498
+ */
4499
+ var triggerStep = (spec, id, name) => ({
4081
4500
  id,
4082
4501
  type: "trigger",
4083
4502
  action: spec.type,
4503
+ title: name,
4084
4504
  params: {
4085
4505
  ..."access" in spec ? accessParams(spec.access) : {},
4086
4506
  ...spec.input ? { input: JSON.stringify(spec.input) } : {},
@@ -4152,7 +4572,7 @@ var defineAction = (spec) => {
4152
4572
  ...step.enabled === void 0 ? {} : { enabled: step.enabled }
4153
4573
  });
4154
4574
  const steps = [
4155
- ...triggers.map((trigger, index) => triggerStep(trigger, triggerIds[index])),
4575
+ ...triggers.map((trigger, index) => triggerStep(trigger, triggerIds[index], spec.name)),
4156
4576
  ...spec.steps.map(taskStep),
4157
4577
  {
4158
4578
  id: "answer",
@@ -4163,7 +4583,7 @@ var defineAction = (spec) => {
4163
4583
  ...undo.length > 0 ? [{
4164
4584
  id: "onFailure",
4165
4585
  type: "task",
4166
- action: e$12,
4586
+ action: e$13,
4167
4587
  params: {}
4168
4588
  }, ...undo.map(taskStep)] : []
4169
4589
  ];
@@ -4293,12 +4713,43 @@ var hiddenWhen = (source) => ({
4293
4713
  }]
4294
4714
  });
4295
4715
  /**
4716
+ * Switches one of a CLASS's variants from a value the data answered — a status pill that turns amber, green or red
4717
+ * as the job it describes moves.
4718
+ *
4719
+ * The variant map is keyed by the SELECTOR the variants belong to, and the obvious guess names a different one:
4720
+ * `text.base` selects the text TYPE's own variants (`text--done`), not the class the element wears
4721
+ * (`statusPill--done`), so the element renders with no variant at all and nothing reports it. Taken from the class
4722
+ * declaration, the key cannot drift from the class it means. The value at `source` names the variant, or `template`
4723
+ * turns it into one.
4724
+ */
4725
+ var variantFrom = (cls, source, options = {}) => {
4726
+ const { slot = "base", template } = options;
4727
+ return {
4728
+ to: "styleVariant",
4729
+ source,
4730
+ category: "initialState",
4731
+ transformers: [...template ? [{
4732
+ action: "twigTemplate",
4733
+ params: { template }
4734
+ }] : [], {
4735
+ action: "styleVariant",
4736
+ params: {
4737
+ key: `${typeof cls === "string" ? cls : cls.name}.${slot}`,
4738
+ variant: "",
4739
+ append: "true"
4740
+ }
4741
+ }]
4742
+ };
4743
+ };
4744
+ /**
4296
4745
  * The bindings an element declared, with its visibility condition among them.
4297
4746
  *
4298
4747
  * Appended rather than prepended so a `visible` written as a field lands where the same condition written into the
4299
4748
  * list would have: a binding's id carries its position, and a space that moves to the field should not move its
4300
4749
  * ids.
4301
4750
  */
4751
+ /** Whether any of these bindings decides the element's visibility — which makes it a condition, authored hidden. */
4752
+ var hasVisibilityBinding = (bindings) => bindings?.some((binding) => binding.to === "visibility" && binding.category === "initialState") ?? false;
4302
4753
  var withVisibility = (spec) => {
4303
4754
  const bound = spec.bind === void 0 ? void 0 : toBindingSpecs(spec.bind);
4304
4755
  if (spec.visible === void 0 || spec.visible === false) return bound;
@@ -4325,6 +4776,28 @@ var groupBindings = (path, bind, sources, where = path) => toBindingSpecs(bind).
4325
4776
  groups[category] = [...groups[category] ?? [], authorBinding(index, resolved)];
4326
4777
  return groups;
4327
4778
  }, {});
4779
+ /**
4780
+ * Marks a navigation entry as the current one on the pages it stands for.
4781
+ *
4782
+ * The page being shown is \`navigation.currentPageId\`, so an entry lights up when that is one of its pages — one
4783
+ * binding, the same on every entry of a menu that lives in a layout, instead of a copy of the menu per page with the
4784
+ * right entry styled by hand. Several ids for one entry: a section and the pages beneath it (\`['spaces',
4785
+ * 'space-record']\`). Every other page wears \`idle\`, a name the class need not declare.
4786
+ *
4787
+ * \`\`\`ts
4788
+ * const navLink = styles('nav-link', { css: { … }, variants: { active: { color: 'var(--accent)' } } });
4789
+ * link({ href: 'docs-data', class: navLink, bind: [activeOn(navLink, 'docs-data')] });
4790
+ * \`\`\`
4791
+ */
4792
+ var activeOn = (cls, pages, options = {}) => {
4793
+ const ids = typeof pages === "string" ? [pages] : pages;
4794
+ const variant = options.variant ?? "active";
4795
+ const list = ids.map((id) => JSON.stringify(id)).join(", ");
4796
+ return variantFrom(cls, "navigation.currentPageId", {
4797
+ ...options.slot ? { slot: options.slot } : {},
4798
+ template: `{{ source in [${list}] ? '${variant}' : 'idle' }}`
4799
+ });
4800
+ };
4328
4801
  //#endregion
4329
4802
  //#region src/schema/handles.ts
4330
4803
  /**
@@ -4336,15 +4809,16 @@ var escapeId = (value) => value.replace(/["\\]/g, "\\$&");
4336
4809
  var selectorFor = (id) => `[data-plitzi-el="${escapeId(id)}"]`;
4337
4810
  /** The route for a slug: authoring stores it bare, and everything that navigates wants it absolute. */
4338
4811
  var pathForSlug = (slug) => slug ? `/${slug}` : "/";
4339
- var buildHandles = (pages) => {
4812
+ var buildHandles = (pages, layouts = {}) => {
4340
4813
  const elements = {};
4341
- for (const page of Object.values(pages)) {
4342
- elements[page.id] = page;
4343
- Object.assign(elements, page.elements);
4814
+ for (const root of [...Object.values(pages), ...Object.values(layouts)]) {
4815
+ elements[root.id] = root;
4816
+ Object.assign(elements, root.elements);
4344
4817
  }
4345
4818
  const bySlug = new Map(Object.values(pages).map((page) => [page.slug, page]));
4346
4819
  return {
4347
4820
  pages,
4821
+ layouts,
4348
4822
  elements,
4349
4823
  element(id) {
4350
4824
  if (!Object.hasOwn(elements, id)) throw new Error(`No element "${id}" in this space${didYouMean(id, Object.keys(elements))}`);
@@ -4400,7 +4874,7 @@ var digest = (value, length) => {
4400
4874
  var slugify = (value, fallback) => value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || fallback;
4401
4875
  //#endregion
4402
4876
  //#region ../sdk-shared/dist/schema/layoutChain.mjs
4403
- var e$10 = (e, t) => {
4877
+ var e$11 = (e, t) => {
4404
4878
  let n = e?.attributes[t];
4405
4879
  return typeof n == "string" ? n : "";
4406
4880
  };
@@ -4408,7 +4882,7 @@ var n$12 = (t, n) => {
4408
4882
  let r = [], i = n;
4409
4883
  for (; i && r.length <= 16;) {
4410
4884
  if (r.includes(i)) return [...r.slice(r.indexOf(i)), i];
4411
- r.push(i), i = e$10(t(i), "layout");
4885
+ r.push(i), i = e$11(t(i), "layout");
4412
4886
  }
4413
4887
  return [];
4414
4888
  };
@@ -4730,34 +5204,40 @@ var n$11 = (n) => {
4730
5204
  }, T = () => {
4731
5205
  let t = new Set(Object.keys(a));
4732
5206
  Object.values(a).forEach((n) => {
4733
- let i = n?.definition.interactions;
4734
- if (!i) return;
4735
- let a = Object.keys(i);
4736
- Object.entries(i).forEach(([i, o]) => {
4737
- t$12(i) || r.push({
5207
+ let a = n?.definition.interactions;
5208
+ if (!a) return;
5209
+ let o = Object.keys(a);
5210
+ Object.entries(a).forEach(([a, s]) => {
5211
+ t$12(a) || r.push({
4738
5212
  code: "INVALID_INTERACTION_ID",
4739
- message: `Interaction "${i}" on element "${n.id}" has a name that must start with a letter, then letters, numbers, hyphens and underscores — a later step reads it as {{ ${i}.field }}`,
5213
+ message: `Interaction "${a}" on element "${n.id}" has a name that must start with a letter, then letters, numbers, hyphens and underscores — a later step reads it as {{ ${a}.field }}`,
4740
5214
  elementId: n.id
4741
- }), o.id !== i && r.push({
5215
+ }), s.id !== a && r.push({
4742
5216
  code: "INTERACTION_ID_MISMATCH",
4743
- message: `Interaction id "${o.id}" on element "${n.id}" doesn't match its key "${i}"`,
5217
+ message: `Interaction id "${s.id}" on element "${n.id}" doesn't match its key "${a}"`,
4744
5218
  elementId: n.id
4745
5219
  }), ["beforeNode", "afterNode"].forEach((e) => {
4746
- let t = o[e];
4747
- t && !a.includes(t) && r.push({
5220
+ let t = s[e];
5221
+ t && !o.includes(t) && r.push({
4748
5222
  code: "BROKEN_FLOW_LINK",
4749
- message: `Interaction "${o.id}" on element "${n.id}" names ${e} "${t}", which is not a node of this flow`,
5223
+ message: `Interaction "${s.id}" on element "${n.id}" names ${e} "${t}", which is not a node of this flow`,
4750
5224
  elementId: n.id
4751
5225
  });
4752
- }), o.flowId && !a.includes(o.flowId) && r.push({
5226
+ }), s.flowId && !o.includes(s.flowId) && r.push({
4753
5227
  code: "BROKEN_FLOW_ID",
4754
- message: `Interaction "${o.id}" on element "${n.id}" belongs to flow "${o.flowId}", which is not a node of this flow`,
5228
+ message: `Interaction "${s.id}" on element "${n.id}" belongs to flow "${s.flowId}", which is not a node of this flow`,
4755
5229
  elementId: n.id
4756
- }), o.type === "callback" && o.elementId && !t.has(o.elementId) && r.push({
5230
+ }), s.type === "callback" && s.elementId && !t.has(s.elementId) && r.push({
4757
5231
  code: "UNRESOLVED_INTERACTION_TARGET",
4758
- message: `Interaction "${o.id}" on element "${n.id}" runs against "${o.elementId}", but no element answers to that name`,
5232
+ message: `Interaction "${s.id}" on element "${n.id}" runs against "${s.elementId}", but no element answers to that name`,
4759
5233
  elementId: n.id
4760
5234
  });
5235
+ let c = s.type === "trigger" && s.action === "onSubmit" && s.enabled ? u(s.elementId ?? n.id) : void 0;
5236
+ c?.definition.type === "form" && c.attributes.managedByInteractions !== !0 && i.push({
5237
+ code: "FORM_SUBMIT_UNMANAGED",
5238
+ message: `Form "${c.id}" has an onSubmit flow but is not managedByInteractions, so the browser submits it natively and the flow never runs — set managedByInteractions: true`,
5239
+ elementId: c.id
5240
+ });
4761
5241
  });
4762
5242
  });
4763
5243
  }, E = () => {
@@ -4800,7 +5280,7 @@ var n$11 = (n) => {
4800
5280
  var r$10 = (e, t) => n$11(e).validate(t);
4801
5281
  //#endregion
4802
5282
  //#region ../../node_modules/@plitzi/plitzi-ui/dist/helpers/lodash/shared.js
4803
- function e$9(e) {
5283
+ function e$10(e) {
4804
5284
  if (typeof e == "string" || typeof e == "number") {
4805
5285
  let t = String(e);
4806
5286
  return t === "" ? null : /^[a-zA-Z0-9_-]+$/.test(t) || /^\d+$/.test(t) ? t : null;
@@ -4812,11 +5292,11 @@ function t$11(t, n) {
4812
5292
  let r = [], i = /([^.[\]]+)|\[(\d+)\]/g, a;
4813
5293
  for (; a = i.exec(t);) if (a[1]) {
4814
5294
  if (!n && a[1] === "") continue;
4815
- let t = e$9(a[1]);
5295
+ let t = e$10(a[1]);
4816
5296
  if (t !== null) r.push(t);
4817
5297
  else if (n) return [];
4818
5298
  } else if (a[2]) {
4819
- let t = e$9(a[2]);
5299
+ let t = e$10(a[2]);
4820
5300
  if (t !== null) r.push(t);
4821
5301
  else if (n) return [];
4822
5302
  }
@@ -4826,7 +5306,7 @@ function n$10(t, n) {
4826
5306
  if (!Array.isArray(t)) return [];
4827
5307
  let r = [];
4828
5308
  for (let i of t) {
4829
- let t = e$9(i);
5309
+ let t = e$10(i);
4830
5310
  if (t !== null) r.push(t);
4831
5311
  else if (n) return [];
4832
5312
  }
@@ -4882,7 +5362,7 @@ function n$9(n, r) {
4882
5362
  }
4883
5363
  //#endregion
4884
5364
  //#region ../sdk-shared/dist/style/styleConstants.mjs
4885
- var e$8 = {
5365
+ var e$9 = {
4886
5366
  platform: {
4887
5367
  desktop: {},
4888
5368
  tablet: {},
@@ -5115,7 +5595,7 @@ var n$7 = {
5115
5595
  pages: [],
5116
5596
  pageFolders: []
5117
5597
  },
5118
- style: e$8,
5598
+ style: e$9,
5119
5599
  definition: { rootId: "" }
5120
5600
  };
5121
5601
  //#endregion
@@ -5162,13 +5642,13 @@ var l$2 = (e) => {
5162
5642
  let t = e.trim();
5163
5643
  return t ? t.length > i$7 ? s$4(`font.family cannot be longer than ${i$7} characters`) : a$6(t) ? s$4("font.family cannot contain control characters") : t : s$4("font.family cannot be empty");
5164
5644
  };
5165
- var u$1 = (e) => {
5645
+ var u$2 = (e) => {
5166
5646
  if (e === void 0) return [400];
5167
5647
  if (!Array.isArray(e) || e.length === 0) return s$4("font.weights must be a non-empty list of numbers");
5168
5648
  let t = e.map((e) => typeof e != "number" || !Number.isInteger(e) || e < 1 || e > 1e3 ? s$4("font.weights must hold whole numbers between 1 and 1000") : e);
5169
5649
  return [...new Set(t)].sort((e, t) => e - t);
5170
5650
  };
5171
- var d$1 = (e) => {
5651
+ var d$2 = (e) => {
5172
5652
  if (e === void 0) return ["normal"];
5173
5653
  if (!Array.isArray(e) || e.length === 0) return s$4("font.styles must be a non-empty list");
5174
5654
  let t = e.map((e) => e !== "normal" && e !== "italic" ? s$4("font.styles may only hold \"normal\" or \"italic\"") : e);
@@ -5203,8 +5683,8 @@ var h = (r) => {
5203
5683
  let g = {
5204
5684
  family: l$2(r.family),
5205
5685
  fallback: a.trim(),
5206
- weights: u$1(r.weights),
5207
- styles: d$1(r.styles),
5686
+ weights: u$2(r.weights),
5687
+ styles: d$2(r.styles),
5208
5688
  ...o === void 0 ? {} : { display: o },
5209
5689
  ...h === void 0 ? {} : { preload: h }
5210
5690
  };
@@ -5249,7 +5729,7 @@ var h = (r) => {
5249
5729
  };
5250
5730
  //#endregion
5251
5731
  //#region ../sdk-shared/dist/style/styleStates.mjs
5252
- var e$7 = [
5732
+ var e$8 = [
5253
5733
  "hover",
5254
5734
  "focus",
5255
5735
  "focus-visible",
@@ -5270,7 +5750,7 @@ var n$5 = {
5270
5750
  disabled: 7
5271
5751
  };
5272
5752
  var r$6 = (e) => Object.hasOwn(n$5, e);
5273
- var i$6 = (t) => r$6(t) ? n$5[t] : e$7.length;
5753
+ var i$6 = (t) => r$6(t) ? n$5[t] : e$8.length;
5274
5754
  var a$5 = (e) => Object.entries(e).sort(([e], [t]) => i$6(e) - i$6(t));
5275
5755
  //#endregion
5276
5756
  //#region ../sdk-style/dist/helpers/calculateInheriting.mjs
@@ -5527,7 +6007,7 @@ var p$1 = class {
5527
6007
  if (!u) return o;
5528
6008
  let d = [e, ...this.childTree(e)].filter((e) => this.flat[e] !== void 0), f = this.takenIds();
5529
6009
  for (let e of d) {
5530
- let t = u$2(e, (e) => f.has(e));
6010
+ let t = u$3(e, (e) => f.has(e));
5531
6011
  f.add(t), l[e] = t;
5532
6012
  }
5533
6013
  let p = {};
@@ -5599,7 +6079,7 @@ var p$1 = class {
5599
6079
  };
5600
6080
  flatAsTemplate = (e, t, n = !1) => {
5601
6081
  let r = {
5602
- ...e$8,
6082
+ ...e$9,
5603
6083
  platform: {
5604
6084
  desktop: {},
5605
6085
  tablet: {},
@@ -5723,121 +6203,146 @@ var p$1 = class {
5723
6203
  };
5724
6204
  };
5725
6205
  //#endregion
6206
+ //#region ../sdk-shared/dist/helpers/twigWrapper/tokens/hasTemplateSyntax.mjs
6207
+ var e$7 = (e) => typeof e == "string" && /\{\{[\s\S]*?\}\}|\{%[\s\S]*?%\}/.test(e);
6208
+ //#endregion
5726
6209
  //#region ../sdk-style/dist/helpers/processSelectorAttributes.mjs
5727
- var e$6 = (e, t, n = !1) => n ? t : `${e}:${t};`;
5728
- var t$5 = (e) => {
6210
+ var e$6 = (e, t, { keepEmpty: n = !1, closeEndsPart: r = !1 } = {}) => {
6211
+ let i = [], a = 0, o = "", s = "", c = () => {
6212
+ (n || s) && i.push(s), s = "";
6213
+ };
6214
+ for (let n of e) {
6215
+ if (o) o = n === o ? "" : o;
6216
+ else if (/["']/.test(n)) o = n;
6217
+ else if (n === "(") a += 1;
6218
+ else if (n === ")") {
6219
+ if (a = Math.max(0, a - 1), r && a === 0) {
6220
+ s += n, c();
6221
+ continue;
6222
+ }
6223
+ } else if (a === 0 && t(n)) {
6224
+ c();
6225
+ continue;
6226
+ }
6227
+ s += n;
6228
+ }
6229
+ return c(), i;
6230
+ };
6231
+ var t$5 = (e) => /\s/.test(e);
6232
+ var n$4 = (e, t, n = !1) => n ? t : `${e}:${t};`;
6233
+ var r$4 = (e) => {
5729
6234
  if (!e) return [];
5730
6235
  let t = [];
5731
6236
  for (let [n, r] of Object.entries(e)) {
5732
- let e = a$3(n, String(r));
6237
+ let e = s$2(n, String(r));
5733
6238
  t.push(...e.variables, e.value);
5734
6239
  }
5735
6240
  return t;
5736
6241
  };
5737
- var n$4 = (t, n, r, i = !1) => {
6242
+ var i$4 = (e, t, r, i = !1) => {
5738
6243
  let a = {
5739
6244
  variables: {},
5740
6245
  value: ""
5741
6246
  }, o = r.replaceAll("\"", "").match(/var\((?<variableName>--[\w-]+)\)(?<extraContent>\S.+)/);
5742
- if (!o || !o.groups) return a.value = e$6(n, r, i), a;
6247
+ if (!o || !o.groups) return a.value = n$4(t, r, i), a;
5743
6248
  let { variableName: s, extraContent: c } = o.groups, l = `${s}-parsed`, u = `var(${s})+"${c}"`;
5744
- return t.variables[l] && t.variables[l] !== u && (l = `${l}-${Object.keys(t.variables).length}`), a.variables[l] = u, a.value = e$6(n, `var(${l})`, i), a;
6249
+ return e.variables[l] && e.variables[l] !== u && (l = `${l}-${Object.keys(e.variables).length}`), a.variables[l] = u, a.value = n$4(t, `var(${l})`, i), a;
5745
6250
  };
5746
- var r$4 = (t, r, i, a, o = !1) => {
6251
+ var a$3 = (e, t, r, a, o = !1) => {
5747
6252
  let s = {
5748
6253
  variables: {},
5749
6254
  value: ""
5750
6255
  };
5751
- if (i === "url") {
5752
- let c = n$4(t, r, a, !0);
6256
+ if (r === "url") {
6257
+ let c = i$4(e, t, a, !0);
5753
6258
  s.variables = {
5754
6259
  ...s.variables,
5755
6260
  ...c.variables
5756
- }, s.value = e$6(r, `${i}(${c.value})`, o);
5757
- } else s.value = e$6(r, `${i}(${a})`, o);
6261
+ }, s.value = n$4(t, `${r}(${c.value})`, o);
6262
+ } else s.value = n$4(t, `${r}(${a})`, o);
5758
6263
  return s;
5759
6264
  };
5760
- var i$4 = (e, t, a, o = !1, s = !1) => {
5761
- let c = {
6265
+ var o$4 = (n, r, s, c = !1, l = !1) => {
6266
+ let u = {
5762
6267
  variables: {},
5763
6268
  value: ""
5764
- }, l = a.replace(/\s*;\s*$/, "").match(/[a-z-]+\((?:[^()]+|\([^()]*\))*\)|[^\s]+/gi);
5765
- if (!o && l && l.length > 1) return l.forEach((n) => {
5766
- let r = i$4(e, t, n, !0, s);
5767
- c.variables = {
5768
- ...c.variables,
5769
- ...r.variables
5770
- }, c.value ? c.value = `${c.value} ${r.value}` : c.value = r.value;
5771
- }), c;
5772
- a = l?.[0] ?? a;
5773
- let u = a.match(/^(?!var\()\s*(?<functionName>[a-z-]+)\s*\(\s*(?<functionContent>[\s\S]*)\s*\)\s*$/i);
5774
- if (!u || !u.groups) return n$4(c, t, a, o || s);
5775
- let { functionName: d, functionContent: f } = u.groups;
5776
- return r$4(e, t, d, f, o || s);
5777
- };
5778
- var a$3 = (e, t) => {
5779
- let n = {
6269
+ }, d = e$6(s.replace(/\s*;\s*$/, ""), t$5, { closeEndsPart: !0 });
6270
+ if (!c && d.length > 1) return d.forEach((e) => {
6271
+ let t = o$4(n, r, e, !0, l);
6272
+ u.variables = {
6273
+ ...u.variables,
6274
+ ...t.variables
6275
+ }, u.value ? u.value = `${u.value} ${t.value}` : u.value = t.value;
6276
+ }), u;
6277
+ s = d[0] ?? s;
6278
+ let f = s.match(/^(?!var\()\s*(?<functionName>[a-z-]+)\s*\(\s*(?<functionContent>[\s\S]*)\s*\)\s*$/i);
6279
+ if (!f || !f.groups) return i$4(u, r, s, c || l);
6280
+ let { functionName: p, functionContent: m } = f.groups;
6281
+ return a$3(n, r, p, m, c || l);
6282
+ };
6283
+ var s$2 = (t, n) => {
6284
+ let r = {
5780
6285
  variables: {},
5781
6286
  value: ""
5782
6287
  };
5783
- return (t?.split(/,(?![^(]*\))/).map((e) => e.trim()) ?? []).forEach((t) => {
5784
- let r = i$4(n, e, t, !1, !0);
5785
- n.variables = {
5786
- ...n.variables,
5787
- ...r.variables
5788
- }, n.value ? n.value = `${n.value},${r.value}` : n.value = r.value;
5789
- }), n.value &&= `${e}:${n.value};`, {
5790
- variables: Object.keys(n.variables).map((e) => `${e}:${n.variables[e]};`),
5791
- value: n.value
6288
+ return (n === void 0 ? [] : e$6(n, (e) => e === ",", { keepEmpty: !0 }).map((e) => e.trim())).forEach((e) => {
6289
+ let n = o$4(r, t, e, !1, !0);
6290
+ r.variables = {
6291
+ ...r.variables,
6292
+ ...n.variables
6293
+ }, r.value ? r.value = `${r.value},${n.value}` : r.value = n.value;
6294
+ }), r.value &&= `${t}:${r.value};`, {
6295
+ variables: Object.keys(r.variables).map((e) => `${e}:${r.variables[e]};`),
6296
+ value: r.value
5792
6297
  };
5793
6298
  };
5794
- var o$4 = (e) => {
6299
+ var c$1 = (e) => {
5795
6300
  if (!e) return;
5796
- let n = {};
5797
- for (let [r, i] of Object.entries(e)) {
5798
- let e = t$5(i);
5799
- e.length && (n[r] = e);
6301
+ let t = {};
6302
+ for (let [n, i] of Object.entries(e)) {
6303
+ let e = r$4(i);
6304
+ e.length && (t[n] = e);
5800
6305
  }
5801
- return Object.keys(n).length ? n : void 0;
6306
+ return Object.keys(t).length ? t : void 0;
5802
6307
  };
5803
- var s$2 = (e) => {
6308
+ var l$1 = (e) => {
5804
6309
  if (!e) return;
5805
- let n = {};
5806
- for (let [r, i] of Object.entries(e)) {
5807
- let e = o$4(i.states);
5808
- n[r] = {
5809
- default: t$5(i.default),
6310
+ let t = {};
6311
+ for (let [n, i] of Object.entries(e)) {
6312
+ let e = c$1(i.states);
6313
+ t[n] = {
6314
+ default: r$4(i.default),
5810
6315
  ...e && { states: e }
5811
6316
  };
5812
6317
  }
5813
- return Object.keys(n).length ? n : void 0;
6318
+ return Object.keys(t).length ? t : void 0;
5814
6319
  };
5815
- var c$1 = (e) => {
6320
+ var u$1 = (e) => {
5816
6321
  if (!e) return;
5817
- let n = {};
5818
- for (let [r, i] of Object.entries(e)) {
5819
- let e = t$5(i.default), a = o$4(i.states), c = s$2(i.variants);
5820
- (e.length || a || c) && (n[r] = {
6322
+ let t = {};
6323
+ for (let [n, i] of Object.entries(e)) {
6324
+ let e = r$4(i.default), a = c$1(i.states), o = l$1(i.variants);
6325
+ (e.length || a || o) && (t[n] = {
5821
6326
  ...e.length && { default: e },
5822
6327
  ...a && { states: a },
5823
- ...c && { variants: c }
6328
+ ...o && { variants: o }
5824
6329
  });
5825
6330
  }
5826
- return Object.keys(n).length ? n : void 0;
6331
+ return Object.keys(t).length ? t : void 0;
5827
6332
  };
5828
- function l$1(e) {
6333
+ function d$1(e) {
5829
6334
  if (!e?.attributes || !Object.keys(e.attributes).length) return { attributes: { base: { default: [] } } };
5830
- let n = {};
5831
- for (let r in e.attributes) {
5832
- let i = e.attributes[r], a = o$4(i.states), l = s$2(i.variants), u = c$1(i.ancestors);
5833
- n[r] = {
5834
- default: t$5(i.default),
6335
+ let t = {};
6336
+ for (let n in e.attributes) {
6337
+ let i = e.attributes[n], a = c$1(i.states), o = l$1(i.variants), s = u$1(i.ancestors);
6338
+ t[n] = {
6339
+ default: r$4(i.default),
5835
6340
  ...a && { states: a },
5836
- ...l && { variants: l },
5837
- ...u && { ancestors: u }
6341
+ ...o && { variants: o },
6342
+ ...s && { ancestors: s }
5838
6343
  };
5839
6344
  }
5840
- return { attributes: n };
6345
+ return { attributes: t };
5841
6346
  }
5842
6347
  //#endregion
5843
6348
  //#region ../sdk-style/dist/helpers/processSelectorName.mjs
@@ -5950,7 +6455,7 @@ var f = (e, t, n = !0, r = i$3) => {
5950
6455
  return n ? `${e}{${a.join("")}}` : `${e} {\n${a.join("\n\n")}\n}`;
5951
6456
  };
5952
6457
  var p = (r, i = !0) => {
5953
- let a = e$5(r), c = t$4(r), l = l$1(r), u = c ? s$1(a, c, i) : void 0;
6458
+ let a = e$5(r), c = t$4(r), l = d$1(r), u = c ? s$1(a, c, i) : void 0;
5954
6459
  c && l.attributes.base.default.push(...c.default);
5955
6460
  let d = f(a, l.attributes, i, 0);
5956
6461
  return u ? o$3(d, u, i) : d;
@@ -6650,7 +7155,7 @@ var toResponsive = (spec) => {
6650
7155
  return { desktop: css(spec) };
6651
7156
  };
6652
7157
  /** The states a selector can react to — the closed list the style editor offers, read from where it is declared. */
6653
- var STYLE_STATES = e$7;
7158
+ var STYLE_STATES = e$8;
6654
7159
  var STYLE_STATE_SET = new Set(STYLE_STATES);
6655
7160
  var RULE_SET_KEYS = /* @__PURE__ */ new Set([
6656
7161
  "css",
@@ -6904,6 +7409,30 @@ var layoutAttributes = (layout) => layout ? {
6904
7409
  layout: layout.id,
6905
7410
  layoutContainer: layout.slot
6906
7411
  } : {};
7412
+ /**
7413
+ * Sources already known on the first render — what a flow wrote, the route, the space's variables, the theme. A
7414
+ * condition on them resolves in the same render that paints the element, so it has no loading frame to flash in.
7415
+ */
7416
+ var SETTLED_SOURCES = /* @__PURE__ */ new Set([
7417
+ "state",
7418
+ "navigation",
7419
+ "variables",
7420
+ "theme"
7421
+ ]);
7422
+ /** Types whose content is prose, where a \`{{ }}\` is far more often a sample of code than a template. */
7423
+ var PROSE_TYPES = /* @__PURE__ */ new Set([
7424
+ "markdown",
7425
+ "richText",
7426
+ "blockHtml",
7427
+ "blockJsx",
7428
+ "nodeHtml"
7429
+ ]);
7430
+ /** Every string inside a value, however deep — a step's params nest objects and lists of them. */
7431
+ var stringsIn = (value) => {
7432
+ if (typeof value === "string") return [value];
7433
+ if (Array.isArray(value)) return value.flatMap(stringsIn);
7434
+ return typeof value === "object" && value !== null ? Object.values(value).flatMap(stringsIn) : [];
7435
+ };
6907
7436
  var SpaceAuthor = class {
6908
7437
  spec;
6909
7438
  options;
@@ -6920,6 +7449,8 @@ var SpaceAuthor = class {
6920
7449
  /** Every name the AUTHOR wrote, collected before the tree is built so a derived `<type>-<n>` never lands on one. */
6921
7450
  authorNames = /* @__PURE__ */ new Set();
6922
7451
  pagePaths = /* @__PURE__ */ new Set();
7452
+ /** Where each id was written, so a second element answering to it can say where the first one is. */
7453
+ authoredAt = /* @__PURE__ */ new Map();
6923
7454
  /** Each folder's route prefix, resolved through its parents. Filled before any page is written. */
6924
7455
  folderPrefixes = /* @__PURE__ */ new Map();
6925
7456
  /**
@@ -6929,14 +7460,19 @@ var SpaceAuthor = class {
6929
7460
  * it out, and the derived `<type>-<n>` exists nowhere until it is minted below.
6930
7461
  */
6931
7462
  handles = {};
7463
+ layoutHandles = {};
6932
7464
  /** Every class this space declares, whether from `classes` or from a `styles()` declaration found in the tree. */
6933
7465
  classRules = /* @__PURE__ */ new Map();
7466
+ /** Every element's own selector, named or derived — each one is that element's alone. */
7467
+ ownSelectors = /* @__PURE__ */ new Set();
6934
7468
  /** Every element in this space that publishes a data source, by id, and the name it publishes it under. */
6935
7469
  sources = /* @__PURE__ */ new Map();
6936
7470
  /** Steps this space names that the vocabulary could not vouch for. Handed back rather than thrown: a plugin is
6937
7471
  * free to register a module of its own, and refusing what this process cannot see would make the check useless
6938
7472
  * for exactly the spaces that need it most. */
6939
7473
  stepWarnings = [];
7474
+ /** Element callback steps, checked once every element exists: a step may target one declared further down. */
7475
+ callbackSteps = [];
6940
7476
  /** Rules that render, and render differently from what they plainly mean — see `warnTabletOnly`. */
6941
7477
  styleWarnings = [];
6942
7478
  constructor(spec, options = {}) {
@@ -6964,17 +7500,21 @@ var SpaceAuthor = class {
6964
7500
  if (page.id) this.authorNames.add(page.id);
6965
7501
  page.body.forEach((child) => this.collectSources(child));
6966
7502
  });
6967
- for (const [name, responsive] of this.classRules) this.writeSelector(name, responsive, `Class "${name}"`);
7503
+ for (const [name, responsive] of this.classRules) {
7504
+ const blocks = BREAKPOINTS.some((breakpoint) => responsive[breakpoint]) ? responsive : { desktop: {} };
7505
+ this.writeSelector(name, blocks, `Class "${name}"`);
7506
+ }
6968
7507
  this.assertAncestorClasses();
6969
7508
  const pageFolders = this.buildPageFolders();
6970
7509
  layouts.forEach((layout) => this.addLayout(layout));
6971
7510
  const pages = this.spec.pages.map((page, index) => this.addPage(page, index));
6972
7511
  layouts.forEach((layout) => this.assertLayoutRef(layout.layout, `Layout "${layout.id}"`));
6973
7512
  this.spec.pages.forEach((page) => this.assertLayoutRef(page.layout, `Page "${page.name}"`));
7513
+ this.assertCallbacksAnswered();
6974
7514
  const style = {
6975
- ...e$8,
6976
- mode: this.spec.mode ?? e$8.mode,
6977
- theme: this.spec.theme ?? e$8.theme,
7515
+ ...e$9,
7516
+ mode: this.spec.mode ?? e$9.mode,
7517
+ theme: this.spec.theme ?? e$9.theme,
6978
7518
  platform: this.platform,
6979
7519
  variables: this.spec.variables ?? {},
6980
7520
  ...this.spec.fonts ? { fonts: this.parseFonts(this.spec.fonts) } : {},
@@ -7003,7 +7543,7 @@ var SpaceAuthor = class {
7003
7543
  return {
7004
7544
  schema,
7005
7545
  style,
7006
- handles: buildHandles(this.handles),
7546
+ handles: buildHandles(this.handles, this.layoutHandles),
7007
7547
  warnings: [
7008
7548
  ...this.stepWarnings,
7009
7549
  ...this.styleWarnings,
@@ -7023,15 +7563,92 @@ var SpaceAuthor = class {
7023
7563
  * one. An action the catalog has never heard of is a warning instead, because a plugin may register a module of
7024
7564
  * its own and this process cannot see it.
7025
7565
  *
7026
- * Triggers, element callbacks and tasks are left alone on purpose: an element type publishes its own triggers and
7027
- * callbacks, and a task belongs to whatever server runs the flow. None of them are knowable from here.
7566
+ * A trigger is held to the element it is declared on, when that is a built-in type: the vocabulary says every
7567
+ * event such a type fires. A plugin's type publishes its own, and element callbacks and tasks belong to an element
7568
+ * or a server this process cannot see, so those are left alone.
7028
7569
  */
7029
- assertStepsKnown(flows, where) {
7570
+ assertStepsKnown(flows, where, type, hostId) {
7030
7571
  const vocabulary = this.options.vocabulary;
7031
- if (!vocabulary || !flows) return;
7032
- for (const steps of flows) for (const step of steps) {
7033
- if (step.type === "globalCallback") this.assertGlobalCallback(step, vocabulary, where);
7034
- if (step.type === "utility") this.assertUtility(step, vocabulary, where);
7572
+ if (!flows) return;
7573
+ for (const steps of flows) {
7574
+ const stepIds = new Set(steps.map((step) => step.id).filter((id) => id !== void 0));
7575
+ for (const step of steps) {
7576
+ if (step.type === "globalCallback" && step.on === "state") this.warnStatePaths(step, where);
7577
+ if (step.type !== "trigger") this.assertFlowSourcesInFull(step, stepIds, where);
7578
+ if (!vocabulary) continue;
7579
+ if (step.type === "globalCallback") this.assertGlobalCallback(step, vocabulary, where);
7580
+ if (step.type === "trigger" && step.on === void 0 && vocabulary.triggers) this.assertTriggerFired(step, type, vocabulary.triggers, where);
7581
+ if (step.type === "callback" && vocabulary.callbacks) this.callbackSteps.push({
7582
+ action: step.action,
7583
+ target: step.on ?? hostId,
7584
+ where
7585
+ });
7586
+ if (step.type === "utility") this.assertUtility(step, vocabulary, where);
7587
+ }
7588
+ }
7589
+ }
7590
+ /**
7591
+ * Whose vocabulary `variant` names: the element type's, unless a class the element wears declares that variant and
7592
+ * the type does not. The variant map is keyed by selector, and the class is the selector those rules live on — keyed
7593
+ * by the type, `avatar--violet` was never worn and the element rendered as if no variant had been asked for.
7594
+ */
7595
+ variantOwner(spec, variant) {
7596
+ if (this.spec.elements?.[spec.type]?.variants?.[variant] !== void 0 || spec.class === void 0) return spec.type;
7597
+ return classNames(spec.class).find((name) => Object.values(this.classRules.get(name) ?? {}).some((block) => block.variants?.[variant] !== void 0)) ?? spec.type;
7598
+ }
7599
+ /**
7600
+ * A source read INSIDE a flow has to be named in full: `{{ list_jobRows.item.id }}`, not `{{ jobRows.item.id }}`.
7601
+ *
7602
+ * A binding's source is a name this module completes — `jobRows.item` becomes `list_jobRows.item` — so the short
7603
+ * form is the one an author learns first. A step's params are templates the runtime resolves against the flow
7604
+ * scope as written, and there the short form names nothing: the token renders empty, the button posts a blank
7605
+ * id, and every layer below reports success. Refused with the name it should have been, rather than rewritten,
7606
+ * because a template is the author's text and a token inside it can be anything twig allows.
7607
+ *
7608
+ * A root that is also a step of the same flow is that step's result, and is left alone.
7609
+ */
7610
+ assertFlowSourcesInFull(step, stepIds, where) {
7611
+ const texts = [];
7612
+ const collect = (value) => {
7613
+ if (typeof value === "string") texts.push(value);
7614
+ else if (Array.isArray(value)) value.forEach(collect);
7615
+ else if (typeof value === "object" && value !== null) Object.values(value).forEach(collect);
7616
+ };
7617
+ collect(step.params);
7618
+ for (const template of texts) for (const [, expression = ""] of template.matchAll(/\{\{([\s\S]*?)\}\}/g)) for (const [, , root = ""] of expression.matchAll(/(^|[^\w.$-])([A-Za-z_][\w-]*)\.[A-Za-z_]/g)) {
7619
+ const prefix = this.sources.get(root);
7620
+ if (prefix && !stepIds.has(root)) throw new Error(`${where}: step "${step.id ?? step.action}" reads "{{ ${expression.trim()} }}". Inside a flow a source is named in full — write "${prefix}_${root}" where it says "${root}". (A binding completes the prefix; a flow's templates are read as written.)`);
7621
+ }
7622
+ }
7623
+ /**
7624
+ * Refused rather than warned: a trigger its element never fires is a flow that is saved, looks right beside the
7625
+ * element it was meant for, and never runs — there is no reading of it that works. The error names the types that
7626
+ * DO fire it, because the usual mistake is one element off: `onSubmit` on the submit button, not the form.
7627
+ */
7628
+ assertTriggerFired(step, type, triggers, where) {
7629
+ const fired = Object.hasOwn(triggers, type) ? triggers[type] : void 0;
7630
+ if (!fired || fired.includes(step.action)) return;
7631
+ const firedBy = Object.keys(triggers).filter((candidate) => triggers[candidate].includes(step.action));
7632
+ const hint = firedBy.length ? ` It is fired by ${firedBy.map((candidate) => `"${candidate}"`).join(", ")}: declare the flow on that element.` : ` No built-in element fires it${didYouMean(step.action, fired) || "."}`;
7633
+ throw new Error(`${where} starts a flow on "${step.action}", which a "${type}" never fires.${hint}`);
7634
+ }
7635
+ /**
7636
+ * An element callback runs on the element it names, and a built-in type says which ones it answers to.
7637
+ *
7638
+ * Refused for the reason a trigger is: `openModal` sent to a plain container is a button that does nothing, saved
7639
+ * and reported nowhere. A target that is missing is the validator's to report, and one of a plugin's type is left
7640
+ * alone — that type registers callbacks nobody here can see.
7641
+ */
7642
+ assertCallbacksAnswered() {
7643
+ const callbacks = this.options.vocabulary?.callbacks;
7644
+ if (!callbacks) return;
7645
+ for (const { action, target, where } of this.callbackSteps) {
7646
+ const type = this.flatMap.flat[target]?.definition.type;
7647
+ const answered = type !== void 0 && Object.hasOwn(callbacks, type) ? callbacks[type] : void 0;
7648
+ if (!answered || answered.includes(action)) continue;
7649
+ const answeredBy = Object.keys(callbacks).filter((candidate) => callbacks[candidate].includes(action));
7650
+ const hint = answeredBy.length ? ` It is a callback of ${answeredBy.map((candidate) => `"${candidate}"`).join(", ")}: aim it at one of those.` : ` No built-in element answers to it${didYouMean(action, answered) || "."}`;
7651
+ throw new Error(`${where} sends "${action}" to "${target}", a "${type}" that never answers to it.${hint}`);
7035
7652
  }
7036
7653
  }
7037
7654
  assertGlobalCallback(step, vocabulary, where) {
@@ -7049,6 +7666,40 @@ var SpaceAuthor = class {
7049
7666
  }
7050
7667
  if (step.on !== declared.source) throw new Error(`${where} runs the global callback "${step.action}" on ${step.on === void 0 ? "no module" : `"${step.on}"`}, but it is registered on "${declared.source}". A global callback names the module that registered it, never the element the flow sits on — the step builders fill this in.`);
7051
7668
  }
7669
+ /**
7670
+ * State callbacks already operate below `runtime.state`.
7671
+ *
7672
+ * Keeping this a warning deliberately preserves the document exactly as authored: a nested `state` object is
7673
+ * possible, even though `key: 'state.genre'` is overwhelmingly a confused binding source rather than an
7674
+ * intentional request for `runtime.state.state.genre`. An agent gets the correction at author time without a
7675
+ * migration or a changed runtime meaning for existing spaces.
7676
+ */
7677
+ warnStatePaths(step, where) {
7678
+ const params = {
7679
+ setState: ["key"],
7680
+ toggleState: ["key"],
7681
+ appendState: ["key"],
7682
+ removeState: ["key"],
7683
+ toggleInState: ["key"],
7684
+ clearState: ["key"],
7685
+ moveState: ["from", "to"]
7686
+ }[step.action] ?? [];
7687
+ for (const param of params) {
7688
+ const value = step.params?.[param];
7689
+ if (typeof value !== "string" || !/^(?:runtime\.)?state\./.test(value)) continue;
7690
+ const bare = value.replace(/^(?:runtime\.)?state\./, "");
7691
+ this.stepWarnings.push({
7692
+ code: "state-key-has-runtime-prefix",
7693
+ message: `${where} passes "${value}" as ${param} to state.${step.action}. State callbacks already write below \`runtime.state\`; use "${bare}" instead, unless you intentionally need \`runtime.state.${value}\`.`,
7694
+ details: {
7695
+ action: step.action,
7696
+ param,
7697
+ value,
7698
+ suggested: bare
7699
+ }
7700
+ });
7701
+ }
7702
+ }
7052
7703
  assertUtility(step, vocabulary, where) {
7053
7704
  if (!Object.hasOwn(vocabulary.utilities, step.action)) {
7054
7705
  this.stepWarnings.push({
@@ -7208,6 +7859,15 @@ var SpaceAuthor = class {
7208
7859
  }
7209
7860
  }
7210
7861
  /**
7862
+ * A name given to an element's own selector has to be one nothing else answers to: a declared class would have its
7863
+ * rules overwritten, and a second element naming it would share rules it never asked for.
7864
+ */
7865
+ assertOwnSelector(name, where) {
7866
+ if (!/^-?[_a-zA-Z][_a-zA-Z0-9-]*$/.test(name)) throw new Error(`${where} names its selector "${name}", which is not a CSS class name.`);
7867
+ if (this.classRules.has(name) || this.ownSelectors.has(name)) throw new Error(`${where} names its selector "${name}", which ${this.classRules.has(name) ? "is a class this space declares" : "another element already names"}. Use \`class\` to share rules; a selector of an element's own is its alone.`);
7868
+ this.ownSelectors.add(name);
7869
+ }
7870
+ /**
7211
7871
  * A shared class when one was named, otherwise a selector of this element's own, named after where it sits.
7212
7872
  *
7213
7873
  * The two are exclusive because an element has exactly one base selector: asking for a shared rule AND a rule of
@@ -7215,14 +7875,24 @@ var SpaceAuthor = class {
7215
7875
  * silence this whole surface exists to remove.
7216
7876
  */
7217
7877
  selectorFor(path, spec) {
7878
+ if (spec.class && spec.selector) throw new Error(`Element "${spec.type}" at ${path} names its own selector ("${spec.selector}") and wears a shared class. A shared class IS its selector: drop one of the two.`);
7218
7879
  if (spec.class) {
7219
7880
  const names = classNames(spec.class);
7220
7881
  names.forEach((name) => this.assertClass(name, `Element "${spec.type}" at ${path}`));
7221
7882
  if (spec.css || spec.states) throw new Error(`Element "${spec.type}" at ${path} declares both a shared class ("${names.join(" ")}") and ${spec.css ? "css" : "states"} of its own. An element has one base selector: either write the rules into the class, or drop the class and keep the rules.`);
7222
7883
  return names.join(" ");
7223
7884
  }
7885
+ if (spec.selector !== void 0) {
7886
+ this.assertOwnSelector(spec.selector, `Element "${spec.type}" at ${path}`);
7887
+ this.writeSelector(spec.selector, toBlocks({
7888
+ css: spec.css,
7889
+ states: spec.states
7890
+ }), `Element "${spec.type}" at ${path}`);
7891
+ return spec.selector;
7892
+ }
7224
7893
  let selector = `${spec.type}-${digest(`plitzi:selector:${this.spec.permanentUrl}:${path}`, 4)}`;
7225
- for (let attempt = 1; this.classRules.has(selector); attempt += 1) selector = `${spec.type}-${digest(`plitzi:selector:${this.spec.permanentUrl}:${path}#${attempt}`, 4)}`;
7894
+ for (let attempt = 1; this.classRules.has(selector) || this.ownSelectors.has(selector); attempt += 1) selector = `${spec.type}-${digest(`plitzi:selector:${this.spec.permanentUrl}:${path}#${attempt}`, 4)}`;
7895
+ this.ownSelectors.add(selector);
7226
7896
  this.writeSelector(selector, toBlocks({
7227
7897
  css: spec.css,
7228
7898
  states: spec.states
@@ -7237,8 +7907,29 @@ var SpaceAuthor = class {
7237
7907
  * belonged to authors perfectly well. The reason it is nearly always declined is a name two elements share,
7238
7908
  * and a name written twice is worth hearing about at the line that wrote it.
7239
7909
  */
7240
- insert(element, to, position) {
7241
- if (!this.flatMap.addElement(element, to, position)) throw new Error(`Could not author element "${element.id}" (${element.definition.type}): the schema refused it, which usually means another element already answers to that name`);
7910
+ insert(element, to, position, path = to) {
7911
+ const earlier = this.authoredAt.get(element.id);
7912
+ if (earlier !== void 0) throw new Error(`Element "${element.id}" (${element.definition.type}) at ${path} uses a name already taken at ${earlier}. Ids are one namespace for the whole space — layouts and every page share it — so an element built by a function called more than once needs its id prefixed by what it is for (\`\${pageId}-foot\`).`);
7913
+ if (!this.flatMap.addElement(element, to, position)) throw new Error(`Could not author element "${element.id}" (${element.definition.type}) at ${path}: the schema refused it`);
7914
+ this.authoredAt.set(element.id, path);
7915
+ }
7916
+ /**
7917
+ * A source read inside a BINDING's template is named in full too: \`{{ apiContainer_stats.data.total }}\`.
7918
+ *
7919
+ * The binding's own \`source\` is completed for you, which is exactly why the short name looks right inside its
7920
+ * template as well. It is not: the template is read as written, the short name resolves to nothing, and the
7921
+ * element renders whatever the empty branch says — every card of a list reading "Shared" because none of them
7922
+ * found the stats it was looking for. Refused with the name it should have been.
7923
+ */
7924
+ assertTemplateSourcesInFull(bindings, where) {
7925
+ for (const binding of bindings ?? []) for (const transformer of binding.transformers ?? []) {
7926
+ const template = transformer.params.template;
7927
+ if (transformer.action !== "twigTemplate" || typeof template !== "string") continue;
7928
+ for (const [, expression = ""] of template.matchAll(/\{[{%]([\s\S]*?)[}%]\}/g)) for (const [, , root = ""] of expression.matchAll(/(^|[^\w.$-])([A-Za-z_][\w-]*)\.[A-Za-z_]/g)) {
7929
+ const prefix = this.sources.get(root);
7930
+ if (prefix && root !== "source") throw new Error(`${where}: a binding of "${binding.to}" reads "${root}" in its template. Inside a template a source is named in full — write "${prefix}_${root}" where it says "${root}". (The binding's own \`source\` is completed for you; its template is read as written.)`);
7931
+ }
7932
+ }
7242
7933
  }
7243
7934
  /**
7244
7935
  * Where a page's ids are derived from — its slug, unless another page already claimed it.
@@ -7298,9 +7989,9 @@ var SpaceAuthor = class {
7298
7989
  }
7299
7990
  addPage(page, index) {
7300
7991
  const path = this.pathFor(page, index);
7301
- this.assertStepsKnown(page.flows, `Page "${page.name}"`);
7302
- if (page.folder !== void 0 && !this.folderPrefixes.has(page.folder)) throw new Error(`Page "${page.name}" is in folder "${page.folder}", which this space does not declare${didYouMean(page.folder, [...this.folderPrefixes.keys()])}`);
7303
7992
  const id = page.id ?? this.nextId("page");
7993
+ this.assertStepsKnown(page.flows, `Page "${page.name}"`, "page", id);
7994
+ if (page.folder !== void 0 && !this.folderPrefixes.has(page.folder)) throw new Error(`Page "${page.name}" is in folder "${page.folder}", which this space does not declare${didYouMean(page.folder, [...this.folderPrefixes.keys()])}`);
7304
7995
  const element = {
7305
7996
  id,
7306
7997
  attributes: {
@@ -7328,12 +8019,13 @@ var SpaceAuthor = class {
7328
8019
  styleSelectors: { base: this.selectorFor(path, {
7329
8020
  type: "page",
7330
8021
  css: page.css,
7331
- class: page.class
8022
+ class: page.class,
8023
+ selector: page.selector
7332
8024
  }) },
7333
8025
  ...page.flows ? { interactions: authorFlows(page.flows, id) } : {}
7334
8026
  }
7335
8027
  };
7336
- this.insert(element, "", "custom");
8028
+ this.insert(element, "", "custom", path);
7337
8029
  this.handles[id] = {
7338
8030
  id,
7339
8031
  type: "page",
@@ -7359,9 +8051,10 @@ var SpaceAuthor = class {
7359
8051
  addLayout(layout) {
7360
8052
  const path = `${this.spec.permanentUrl}/layout:${layout.id}`;
7361
8053
  const where = `Layout "${layout.id}"`;
7362
- this.assertStepsKnown(layout.flows, where);
8054
+ this.assertStepsKnown(layout.flows, where, "layoutContainer", layout.id);
7363
8055
  if (layout.folder && !this.folderPrefixes.has(layout.folder)) throw new Error(`${where} is filed in folder "${layout.folder}", which this space does not declare${didYouMean(layout.folder, [...this.folderPrefixes.keys()])}`);
7364
8056
  const bindings = withVisibility({ bind: layout.bind });
8057
+ this.assertTemplateSourcesInFull(bindings, where);
7365
8058
  const sourceIndex = this.options.sourceTypes ? this.sources : void 0;
7366
8059
  const element = {
7367
8060
  id: layout.id,
@@ -7385,7 +8078,15 @@ var SpaceAuthor = class {
7385
8078
  ...layout.flows ? { interactions: authorFlows(layout.flows, layout.id) } : {}
7386
8079
  }
7387
8080
  };
7388
- this.insert(element, "", "custom");
8081
+ this.insert(element, "", "custom", path);
8082
+ this.layoutHandles[layout.id] = {
8083
+ id: layout.id,
8084
+ type: "layoutContainer",
8085
+ pageId: layout.id,
8086
+ selector: selectorFor(layout.id),
8087
+ named: true,
8088
+ elements: {}
8089
+ };
7389
8090
  layout.body.forEach((child, index) => this.addElement(child, `${path}/${index}`, layout.id, layout.id));
7390
8091
  }
7391
8092
  /**
@@ -7401,6 +8102,17 @@ var SpaceAuthor = class {
7401
8102
  const slot = this.flatMap.flat[layout.slot];
7402
8103
  if (!slot || slot.definition.rootId !== layout.id || slot.id === layout.id) throw new Error(`${where} puts its body in "${layout.slot}", which is not an element inside the layout "${layout.id}". The slot is where the body goes, so it has to be part of the shell.`);
7403
8104
  }
8105
+ /**
8106
+ * The type's other selectors, empty: each one is a `plitzi__<type>-<slot>` class on the element's own markup.
8107
+ *
8108
+ * Named or not, the element wears them — that is what a space's per-type `slots` style addresses. A modal whose
8109
+ * document did not mention `rootContainer` was the SDK's white default in a dark theme, beside a modal that styled
8110
+ * the slot itself and so followed the space.
8111
+ */
8112
+ declaredSlots(type) {
8113
+ const slots = this.options.slotNames?.[type] ?? [];
8114
+ return Object.fromEntries(slots.map((slot) => [slot, ""]));
8115
+ }
7404
8116
  slotSelectors(spec, path) {
7405
8117
  return Object.fromEntries(Object.entries(spec.slots ?? {}).map(([slot, value]) => {
7406
8118
  const names = classNames(value);
@@ -7409,22 +8121,102 @@ var SpaceAuthor = class {
7409
8121
  }));
7410
8122
  }
7411
8123
  /**
7412
- * Files an element under the page it renders on.
8124
+ * Files an element under the root it renders in: its page, or the layout shell it belongs to.
7413
8125
  *
7414
- * `rootId` is that page for everything a page contains — a layout container included, since it is a root the page
7415
- * names rather than a page of its own. An element whose root is not a page it wrote is dropped rather than filed
7416
- * somewhere plausible: a handle that resolves to the wrong page is worse than one that is absent, which the
7417
- * lookup reports by name.
8126
+ * A layout's elements go under the layout and never under a page, because they render on every page that names
8127
+ * it — filed under one, a suite would look for the header only there. An element whose root is neither is dropped
8128
+ * rather than filed somewhere plausible: a handle that resolves to the wrong root is worse than one that is absent,
8129
+ * which the lookup reports by name.
7418
8130
  */
7419
8131
  recordHandle(handle) {
7420
- if (Object.hasOwn(this.handles, handle.pageId)) this.handles[handle.pageId].elements[handle.id] = handle;
8132
+ if (Object.hasOwn(this.handles, handle.pageId)) {
8133
+ this.handles[handle.pageId].elements[handle.id] = handle;
8134
+ return;
8135
+ }
8136
+ if (Object.hasOwn(this.layoutHandles, handle.pageId)) this.layoutHandles[handle.pageId].elements[handle.id] = handle;
8137
+ }
8138
+ /**
8139
+ * A sub-element that reads its parent's context — a dropdown's panel, a tab container's parts — throws on its
8140
+ * first render anywhere else, taking the page down with it. Refused here, where the error can say where it belongs.
8141
+ */
8142
+ assertInsideAncestor(type, parentId, where) {
8143
+ const ancestorTypes = this.options.ancestorTypes;
8144
+ const ancestor = ancestorTypes && Object.hasOwn(ancestorTypes, type) ? ancestorTypes[type] : void 0;
8145
+ if (!ancestor) return;
8146
+ for (let id = parentId; id;) {
8147
+ const element = this.flatMap.flat[id];
8148
+ if (element?.definition.type === ancestor) return;
8149
+ id = element?.definition.parentId;
8150
+ }
8151
+ throw new Error(`${where} only works inside a "${ancestor}": it reads that element's state. Nest it in one.`);
8152
+ }
8153
+ /**
8154
+ * An attribute its component never reads renders nothing and says nothing — a `content` on a `dropdown`, whose
8155
+ * label is a child. A warning, because a plugin's type or a newer element may read what this catalog has not heard of.
8156
+ */
8157
+ /**
8158
+ * A template the runtime will never resolve, left in an attribute.
8159
+ *
8160
+ * An attribute is resolved only when it carries a TOKEN — a name, with filters: \`{{ post.slug }}\`,
8161
+ * \`{{ redirect|url_encode }}\` — because attributes are where prose lives, and a stray brace in a sentence must not
8162
+ * be evaluated. So a condition, a test or a \`{% %}\` block on its own is used as written: a link to
8163
+ * \`/x/{{ on ? 'a' : 'b' }}\`, a class named after the template. A binding's template is where an expression
8164
+ * belongs; there it is evaluated in full. (A step's params are templates by construction and resolve whatever they
8165
+ * hold.)
8166
+ */
8167
+ warnUnresolvedTemplates(values, where) {
8168
+ for (const value of stringsIn(values)) {
8169
+ if (!e$7(value) || n$14(value)) continue;
8170
+ this.stepWarnings.push({
8171
+ code: "template-never-resolved",
8172
+ message: `${where} carries "${value.length > 80 ? `${value.slice(0, 77)}…` : value}", which is never resolved: an attribute only reads a name with filters (\`{{ post.slug|upper }}\`). Move the expression into a binding's \`twigTemplate\`, where it is evaluated in full.`,
8173
+ details: { value }
8174
+ });
8175
+ }
8176
+ }
8177
+ /**
8178
+ * A condition computed from data, on an element that starts on screen.
8179
+ *
8180
+ * Until its provider answers, the template has nothing to decide on and the element is drawn — then hidden a moment
8181
+ * later. That is the flash of an empty state, or of a "get started" card for somebody who did everything, on every
8182
+ * load. \`visible: false\` starts it hidden, and the template then shows it. A plain binding to one value is left
8183
+ * alone: an element shown until a flag says otherwise is a real and common shape.
8184
+ */
8185
+ warnConditionStartsVisible(bindings, where) {
8186
+ if (!bindings?.some((binding) => binding.to === "visibility" && binding.category === "initialState" && !SETTLED_SOURCES.has(binding.source.split(".")[0]) && binding.transformers?.some((transformer) => transformer.action === "twigTemplate"))) return;
8187
+ this.stepWarnings.push({
8188
+ code: "condition-starts-visible",
8189
+ message: `${where} computes its visibility from data but starts on screen, so it is drawn until the data answers and then hidden. Add \`visible: false\` so it waits hidden, and let the template answer 'false' until its source arrives.`,
8190
+ details: {}
8191
+ });
8192
+ }
8193
+ warnUnknownAttributes(spec, where) {
8194
+ const catalog = this.options.attributeNames;
8195
+ const names = catalog && Object.hasOwn(catalog, spec.type) ? catalog[spec.type] : null;
8196
+ if (!names) return;
8197
+ for (const name of Object.keys(spec.attributes ?? {})) {
8198
+ if (names.includes(name)) continue;
8199
+ this.stepWarnings.push({
8200
+ code: "unknown-attribute",
8201
+ message: `${where} sets "${name}", which a "${spec.type}" never reads${didYouMean(name, names) || ""}.`,
8202
+ details: {
8203
+ type: spec.type,
8204
+ attribute: name
8205
+ }
8206
+ });
8207
+ }
7421
8208
  }
7422
8209
  addElement(spec, path, rootId, parentId, insideCondition = false) {
7423
8210
  const id = spec.id ?? this.nextId(spec.type);
7424
- const conditional = insideCondition || spec.visible !== void 0;
7425
8211
  const where = `Element "${spec.type}" (${id}) at ${path}`;
7426
- this.assertStepsKnown(spec.flows, where);
8212
+ this.assertStepsKnown(spec.flows, where, spec.type, id);
8213
+ this.assertInsideAncestor(spec.type, parentId, where);
8214
+ this.warnUnknownAttributes(spec, where);
8215
+ if (!PROSE_TYPES.has(spec.type)) this.warnUnresolvedTemplates(spec.attributes, where);
7427
8216
  const bindings = withVisibility(spec);
8217
+ const conditional = insideCondition || spec.visible !== void 0 || hasVisibilityBinding(bindings);
8218
+ this.assertTemplateSourcesInFull(bindings, where);
8219
+ if (spec.visible === void 0) this.warnConditionStartsVisible(bindings, where);
7428
8220
  const sourceIndex = this.options.sourceTypes ? this.sources : void 0;
7429
8221
  const element = {
7430
8222
  id,
@@ -7437,6 +8229,7 @@ var SpaceAuthor = class {
7437
8229
  items: [],
7438
8230
  styleSelectors: {
7439
8231
  base: this.selectorFor(path, spec),
8232
+ ...this.declaredSlots(spec.type),
7440
8233
  ...this.slotSelectors(spec, path)
7441
8234
  },
7442
8235
  initialState: {
@@ -7447,9 +8240,14 @@ var SpaceAuthor = class {
7447
8240
  * that resolves to nothing writes nothing, and an absent `visibility` is read as visible. So a panel
7448
8241
  * waiting on a selection nobody has made yet, or on any state that only exists once the page is live,
7449
8242
  * was authored on screen with placeholder text in it until something happened.
8243
+ *
8244
+ * A visibility binding written by hand keeps its element on screen until it answers, as it always has —
8245
+ * spaces rely on that (a sidebar's logo bound to a state nobody sets until the sidebar is folded). A
8246
+ * computed one that should wait for its data says so with \`visible: false\`; see
8247
+ * \`warnConditionStartsVisible\`.
7450
8248
  */
7451
8249
  visibility: spec.visible === void 0,
7452
- ...spec.variant ? { styleVariant: { [spec.type]: { base: spec.variant } } } : {}
8250
+ ...spec.variant ? { styleVariant: { [this.variantOwner(spec, spec.variant)]: { base: spec.variant } } } : {}
7453
8251
  },
7454
8252
  ...spec.runtime ? { runtime: spec.runtime } : {},
7455
8253
  ...spec.loadStrategy ? { loadStrategy: spec.loadStrategy } : {},
@@ -7457,7 +8255,7 @@ var SpaceAuthor = class {
7457
8255
  ...spec.flows ? { interactions: authorFlows(spec.flows, id) } : {}
7458
8256
  }
7459
8257
  };
7460
- this.insert(element, parentId, "inside");
8258
+ this.insert(element, parentId, "inside", path);
7461
8259
  this.recordHandle({
7462
8260
  id,
7463
8261
  type: spec.type,
@@ -8125,6 +8923,10 @@ var foldCustomCss = (stylesheet, isClass, accepts = () => true) => {
8125
8923
  const previous = kept.at(-1);
8126
8924
  if (previous !== void 0) kept[kept.length - 1] = previous.replace(/\s*\/\*(?:(?!\*\/)[\s\S])*\*\/\s*$/, "\n\n");
8127
8925
  }
8926
+ if (folded.length === 0) return {
8927
+ folded,
8928
+ remaining: stylesheet
8929
+ };
8128
8930
  const remaining = kept.join("").replace(/\n{3,}/g, "\n\n").trim();
8129
8931
  return {
8130
8932
  folded,
@@ -8218,7 +9020,10 @@ var boxNotation = (values) => {
8218
9020
  * 20px` rather than four declarations — wherever every side is set.
8219
9021
  *
8220
9022
  * Only when expanding the shorthand again gives back exactly those longhands, which is also what keeps a value with
8221
- * a space in it (`calc()`, `rgb()`) written out: the expander would read it as more than one value.
9023
+ * a space in it (`calc()`, `rgb()`) written out: the expander would read it as more than one value — and only when
9024
+ * they already sit together in the order the expansion writes them. Authoring expands a shorthand in that order, so
9025
+ * longhands written any other way (`padding-left` before `padding-top`, a border grouped by side) would come back
9026
+ * reordered: the same rules, and a different document.
8222
9027
  */
8223
9028
  var compact = (rules) => {
8224
9029
  let out = { ...rules };
@@ -8228,6 +9033,10 @@ var compact = (rules) => {
8228
9033
  const notation = boxNotation(values.map(String));
8229
9034
  const expanded = expandShorthand({ [shorthand]: notation });
8230
9035
  if (longhands.some((longhand, index) => String(expanded[longhand]) !== values[index])) continue;
9036
+ const written = Object.keys(out);
9037
+ const order = Object.keys(expanded);
9038
+ const start = written.indexOf(order[0]);
9039
+ if (start < 0 || order.some((longhand, index) => written[start + index] !== longhand)) continue;
8231
9040
  const value = notation === values[0] ? out[longhands[0]] : notation;
8232
9041
  const entries = Object.entries(out);
8233
9042
  const at = entries.findIndex(([property]) => longhands.includes(property));
@@ -8398,7 +9207,7 @@ var unwritableCss = (selector, unwritable, mode) => {
8398
9207
  platform[breakpoint][selector.name] = item;
8399
9208
  }
8400
9209
  return a$1({
8401
- ...e$8,
9210
+ ...e$9,
8402
9211
  mode,
8403
9212
  platform,
8404
9213
  variables: {}
@@ -8618,6 +9427,8 @@ var SpecReader = class {
8618
9427
  ancestorNames;
8619
9428
  elementBlocks = /* @__PURE__ */ new Map();
8620
9429
  selectorUses = /* @__PURE__ */ new Map();
9430
+ /** The element ids authoring would derive on its own, and so the ones an export leaves out (see derivedIds). */
9431
+ derived = /* @__PURE__ */ new Set();
8621
9432
  /** Selectors kept as classes under their own name, rather than written into the one element that uses them. */
8622
9433
  keptClasses = /* @__PURE__ */ new Set();
8623
9434
  keptCss = [];
@@ -8654,6 +9465,7 @@ var SpecReader = class {
8654
9465
  const pageFolders = this.readFolders();
8655
9466
  const roots = this.collectRoots();
8656
9467
  this.countSelectorUses(roots);
9468
+ this.derived = this.derivedIds(roots);
8657
9469
  const elements = this.readElementDefaults(style.mode);
8658
9470
  const layouts = roots.layouts.map((layout) => this.readLayout(layout));
8659
9471
  const pages = roots.pages.map((page, index) => this.readPage(page, index));
@@ -8810,6 +9622,44 @@ var SpecReader = class {
8810
9622
  ...Object.values(block.variants ?? {}).flatMap((variant) => [...Object.keys(variant.default ?? {}), ...Object.values(variant.states ?? {}).flatMap((rules) => Object.keys(rules))])
8811
9623
  ]));
8812
9624
  }
9625
+ /**
9626
+ * The element ids authoring would derive by itself — exactly those, which is what lets an export leave them out.
9627
+ *
9628
+ * Looking like one is not enough. `container-117` has the shape of a derived id, but authoring numbers `<type>-<n>`
9629
+ * by position, per type, stepping over every name written out anywhere — so an id that is not the one its position
9630
+ * would get is a name the author chose, and dropping it renames the element. Walked in authoring's own order
9631
+ * (layouts, then pages, parents before their children). Keeping one id changes what the others would be, since
9632
+ * authoring steps over it, so the pass repeats until nothing more has to be kept; it only ever keeps more, so it ends.
9633
+ */
9634
+ derivedIds(roots) {
9635
+ const order = [];
9636
+ const visit = (element) => {
9637
+ order.push(element);
9638
+ this.childrenOf(element, false).forEach(visit);
9639
+ };
9640
+ [...roots.layouts, ...roots.pages].forEach((root) => this.childrenOf(root, false).forEach(visit));
9641
+ const authoredType = ({ definition: { type } }) => Object.hasOwn(LEGACY_ELEMENT_TYPES, type) ? LEGACY_ELEMENT_TYPES[type].type : type;
9642
+ const named = new Set([...roots.layouts, ...roots.pages].map((root) => root.id));
9643
+ for (const element of order) if (this.references.has(element.id)) named.add(element.id);
9644
+ for (;;) {
9645
+ const counters = /* @__PURE__ */ new Map();
9646
+ const derived = /* @__PURE__ */ new Set();
9647
+ let kept = false;
9648
+ for (const element of order) {
9649
+ if (named.has(element.id)) continue;
9650
+ const type = authoredType(element);
9651
+ let next = (counters.get(type) ?? 0) + 1;
9652
+ while (named.has(`${type}-${next}`)) next += 1;
9653
+ counters.set(type, next);
9654
+ if (element.id === `${type}-${next}`) derived.add(element.id);
9655
+ else {
9656
+ named.add(element.id);
9657
+ kept = true;
9658
+ }
9659
+ }
9660
+ if (!kept) return derived;
9661
+ }
9662
+ }
8813
9663
  countSelectorUses(roots) {
8814
9664
  const visit = (element) => {
8815
9665
  for (const selector of Object.values(element.definition.styleSelectors)) for (const name of selector ? classesOf(selector) : []) this.selectorUses.set(name, (this.selectorUses.get(name) ?? 0) + 1);
@@ -8836,9 +9686,11 @@ var SpecReader = class {
8836
9686
  /**
8837
9687
  * How an element's base selector is written: inline, as a class, or not at all.
8838
9688
  *
8839
- * Inline — the element's own `css` — only when nothing else could notice the name changing: one element uses it,
8840
- * nothing in the document spells it out (a `customCss` rule, a twig template), and it carries nothing the inline
8841
- * form cannot (a variant, a rule the editor cannot hold). Everything else stays a class under its own name.
9689
+ * Inline — the element's own `css` — when one element uses it, nothing in the document spells it out (a `customCss`
9690
+ * rule, a twig template), and it carries nothing the inline form cannot (a variant, a rule the editor cannot hold).
9691
+ * Everything else stays a class under its own name. Inlined, it keeps that name too, as `selector`: authoring would
9692
+ * otherwise derive a new one from where the element sits, and the builder, a stylesheet outside the document and
9693
+ * the next export all know the element by the old one.
8842
9694
  */
8843
9695
  baseStyle(selector, inline) {
8844
9696
  if (!selector) return {};
@@ -8857,7 +9709,8 @@ var SpecReader = class {
8857
9709
  this.readReporting(selector, blocks);
8858
9710
  return {
8859
9711
  ...read.css ? { css: read.css } : {},
8860
- ...read.states ? { states: read.states } : {}
9712
+ ...read.states ? { states: read.states } : {},
9713
+ selector
8861
9714
  };
8862
9715
  }
8863
9716
  /**
@@ -9035,7 +9888,8 @@ var SpecReader = class {
9035
9888
  const style = this.baseStyle(selector, "css");
9036
9889
  return {
9037
9890
  ...style.class ? { class: style.class } : {},
9038
- ...style.css ? { css: style.css } : {}
9891
+ ...style.css ? { css: style.css } : {},
9892
+ ...style.selector ? { selector: style.selector } : {}
9039
9893
  };
9040
9894
  }
9041
9895
  dropField(field) {
@@ -9069,7 +9923,7 @@ var SpecReader = class {
9069
9923
  const { type, legacy } = this.typeOf(element);
9070
9924
  const stored = isRecord(element.attributes) ? element.attributes : {};
9071
9925
  const attributes = this.readAttributes(type, legacy ? legacy.attributes(stored) : stored);
9072
- const keepId = this.options.keepIds === true || !new RegExp(`^${definition.type}-\\d+$`).test(element.id) || this.references.has(element.id);
9926
+ const keepId = this.options.keepIds === true || !this.derived.has(element.id);
9073
9927
  const { base: baseSelector, ...slotSelectors } = definition.styleSelectors;
9074
9928
  const baseStyle = this.baseStyle(baseSelector, "css-and-states");
9075
9929
  const style = legacy?.css && !baseStyle.class && !baseStyle.css ? {
@@ -9144,8 +9998,14 @@ var SpecReader = class {
9144
9998
  for (const key of Object.keys(initialState)) if (key !== "visibility" && key !== "styleVariant") this.correct("dropped-initial-state", `"${element.id}" started with ${key} set, which nothing authored can declare.`, element.id);
9145
9999
  const styleVariant = initialState.styleVariant;
9146
10000
  if (!styleVariant) return;
9147
- const own = styleVariant[element.definition.type] ?? styleVariant[type];
9148
- const others = Object.keys(styleVariant).filter((key) => key !== element.definition.type && key !== type);
10001
+ const worn = element.definition.styleSelectors.base.split(/\s+/).filter((name) => name !== "" && styleVariant[name] !== void 0);
10002
+ const ownKeys = [
10003
+ element.definition.type,
10004
+ type,
10005
+ ...worn
10006
+ ];
10007
+ const own = styleVariant[element.definition.type] ?? styleVariant[type] ?? (worn[0] ? styleVariant[worn[0]] : void 0);
10008
+ const others = Object.keys(styleVariant).filter((key) => !ownKeys.includes(key));
9149
10009
  if (others.length > 0 || own && Object.keys(own).some((selector) => selector !== "base")) this.correct("dropped-initial-state", `"${element.id}" started in a style variant of ${[...others, "its parts"].join(", ")}, which only an element's base can declare.`, element.id);
9150
10010
  const base = own?.base;
9151
10011
  return typeof base === "string" && base ? base : void 0;
@@ -9175,11 +10035,32 @@ var SpecReader = class {
9175
10035
  return `${id}${field}`;
9176
10036
  }
9177
10037
  }
10038
+ /**
10039
+ * An element's bindings in the order they were authored, whatever category files them.
10040
+ *
10041
+ * Authoring numbers a binding by its place in the element's whole list — `initialState-1` then `attributes-2` — and
10042
+ * files it under its category, so reading category by category puts them back in a different order and every id
10043
+ * shifts. The number is the order when every id carries one; a document the builder wrote does not number them that
10044
+ * way, and keeps the category order.
10045
+ */
10046
+ bindingsInOrder(element) {
10047
+ const entries = BINDING_CATEGORIES.flatMap((category) => bindingsOf(element.definition.bindings, category).map((raw) => ({
10048
+ category,
10049
+ raw
10050
+ })));
10051
+ const positions = entries.map(({ category, raw }) => new RegExp(`^${category}-(\\d+)$`).exec(raw.id)?.[1]);
10052
+ if (positions.some((position) => position === void 0)) return entries;
10053
+ return entries.map((entry, index) => ({
10054
+ entry,
10055
+ position: Number(positions[index])
10056
+ })).sort((a, b) => a.position - b.position).map(({ entry }) => entry);
10057
+ }
9178
10058
  readBindings(element) {
9179
10059
  const hidden = element.definition.initialState?.visibility === false;
9180
10060
  const specs = [];
9181
10061
  let visible = hidden ? false : void 0;
9182
- for (const category of BINDING_CATEGORIES) for (const raw of bindingsOf(element.definition.bindings, category)) {
10062
+ const ordered = this.bindingsInOrder(element);
10063
+ for (const [index, { category, raw }] of ordered.entries()) {
9183
10064
  const at = `"${element.id}"`;
9184
10065
  const source = this.sourceOf(raw.source, at);
9185
10066
  if (!source) {
@@ -9197,7 +10078,7 @@ var SpecReader = class {
9197
10078
  ...raw.enabled === false ? { enabled: false } : {}
9198
10079
  };
9199
10080
  const negated = transformers.length === 1 && transformers[0].action === "not" && isEmpty(transformers[0].params);
9200
- if (visible === false && category === "initialState" && raw.to === "visibility" && !when && raw.enabled !== false && (transformers.length === 0 || negated)) {
10081
+ if (visible === false && index === ordered.length - 1 && category === "initialState" && raw.to === "visibility" && !when && raw.enabled !== false && (transformers.length === 0 || negated)) {
9201
10082
  visible = negated ? `!${source}` : source;
9202
10083
  continue;
9203
10084
  }
@@ -9226,7 +10107,8 @@ var SpecReader = class {
9226
10107
  this.correct("broken-flow", `"${element.id}" had a flow with a step that runs nothing (${chain[0].id}); dropped.`, element.id);
9227
10108
  continue;
9228
10109
  }
9229
- flows.push(chain);
10110
+ const live = this.liveSteps(chain, element);
10111
+ if (live.length > 0) flows.push(live);
9230
10112
  }
9231
10113
  const lost = Object.keys(nodes).filter((id) => !reached.has(id));
9232
10114
  if (lost.length > 0) this.correct("broken-flow", `"${element.id}" had steps no flow reaches (${lost.join(", ")}); dropped.`, element.id);
@@ -9240,6 +10122,36 @@ var SpecReader = class {
9240
10122
  const original = flows.flat().map((node) => node.id);
9241
10123
  return { flows: derived.join() === original.join() ? anonymous : named };
9242
10124
  }
10125
+ /**
10126
+ * What of a flow can still run: a trigger its element never fires sinks the whole flow, and a callback its target
10127
+ * never answers to is a step that does nothing.
10128
+ *
10129
+ * Both are what an older builder leaves behind — an animation step from before animations were removed, a submit
10130
+ * flow on a button — and authoring refuses both, so they are dropped here and reported rather than written into a
10131
+ * spec that could not be authored again. Only built-in types are judged: a plugin's registers what nobody here sees.
10132
+ */
10133
+ liveSteps(chain, element) {
10134
+ const typeOf = (id) => {
10135
+ const type = this.flat[id]?.definition.type;
10136
+ return type && Object.hasOwn(LEGACY_ELEMENT_TYPES, type) ? LEGACY_ELEMENT_TYPES[type].type : type;
10137
+ };
10138
+ const offers = (catalog, id, action) => {
10139
+ const type = typeOf(id);
10140
+ return !type || !Object.hasOwn(catalog, type) || catalog[type].includes(action);
10141
+ };
10142
+ const trigger = chain[0];
10143
+ const firedOn = trigger.elementId ?? element.id;
10144
+ if (trigger.type === "trigger" && firedOn === element.id && !offers(elementTriggers, firedOn, trigger.action)) {
10145
+ this.correct("dead-flow", `"${element.id}" had a flow on "${trigger.action}", which a "${String(typeOf(firedOn))}" never fires; dropped.`, element.id);
10146
+ return [];
10147
+ }
10148
+ return chain.filter((node) => {
10149
+ const target = node.elementId ?? element.id;
10150
+ if (node.type !== "callback" || offers(elementCallbacks, target, node.action)) return true;
10151
+ this.correct("dead-step", `"${element.id}" sent "${node.action}" to "${target}", a "${String(typeOf(target))}" that never answers to it; dropped.`, element.id);
10152
+ return false;
10153
+ });
10154
+ }
9243
10155
  readStep(node, host) {
9244
10156
  let on;
9245
10157
  if (node.type === "globalCallback") {
@@ -9287,6 +10199,7 @@ var ELEMENT_FIELDS = [
9287
10199
  "class",
9288
10200
  "css",
9289
10201
  "states",
10202
+ "selector",
9290
10203
  "variant",
9291
10204
  "slots",
9292
10205
  "bind",
@@ -9614,69 +10527,497 @@ var specToSource = (spec, options) => new SourceWriter(spec, options).write();
9614
10527
  * back-references between them — is derived from what is written here, so authoring it twice writes byte-identical
9615
10528
  * documents and there is no generated file to keep in step.
9616
10529
  *
9617
- * It starts as the space Plitzi gives a new account, and it is yours: rename things, change the palette, delete
9618
- * the cards. The four cards are one function called four times, which is not a saving of keystrokes — change
9619
- * `card` and all four follow, and that is the difference between a design and four copies of one.
10530
+ * It starts as the space Plitzi gives a new account, and it is yours: rename things, change the palette, delete the
10531
+ * guides. The guides are one function mapped over one list, which is not a saving of keystrokes — change `guideCard`
10532
+ * and all six follow, add an entry to `GUIDES` and a seventh appears, styled like the rest.
9620
10533
  *
9621
10534
  * Name anything a test, a binding or an agent should be able to point at (`id: 'hero-title'`). An element with no
9622
10535
  * name gets a positional one, which moves the moment something is inserted above it.
9623
10536
  */
9624
- /** The classes the page shares. Declared once, so re-theming a card re-themes every card. */
9625
- var buttonLink = styles("button-link", {
9626
- color: "white",
9627
- "flex-basis": "0px",
9628
- "flex-grow": "1",
9629
- "flex-shrink": "1"
9630
- });
9631
- var titleRow = styles("title-container", {
9632
- display: "flex",
9633
- "align-items": "center"
9634
- });
9635
- /** The arrow slides while the card around it is hovered. */
9636
- var titleIcon = styles("title-icon", {
9637
- css: { "margin-left": "10px" },
9638
- ancestors: { [buttonLink.name]: { states: { hover: {
9639
- transform: "translateX(10px)",
9640
- "transition-property": "transform",
9641
- "transition-timing-function": "cubic-bezier(0.4, 0.2, 1)",
9642
- "transition-duration": "150ms"
9643
- } } } }
9644
- });
10537
+ /** Where the documentation lives. Every link on the page starts here, so moving the docs is one line. */
10538
+ var DOCS = "https://plitzi.com/docs";
10539
+ /** The same outline on everything that can be focused from the keyboard. */
10540
+ var focusRing = {
10541
+ outline: "2px solid var(--primary)",
10542
+ "outline-offset": "3px"
10543
+ };
10544
+ var shell = styles("shell", { css: {
10545
+ desktop: {
10546
+ display: "flex",
10547
+ "flex-direction": "column",
10548
+ width: "100%",
10549
+ "max-width": "1120px",
10550
+ "margin-left": "auto",
10551
+ "margin-right": "auto",
10552
+ "padding-left": "32px",
10553
+ "padding-right": "32px",
10554
+ position: "relative",
10555
+ "z-index": "1"
10556
+ },
10557
+ tablet: {
10558
+ "padding-left": "24px",
10559
+ "padding-right": "24px"
10560
+ },
10561
+ mobile: {
10562
+ "padding-left": "20px",
10563
+ "padding-right": "20px"
10564
+ }
10565
+ } });
9645
10566
  /**
9646
10567
  * The grid behind everything, pinned to the viewport.
9647
10568
  *
9648
- * Four gradients rather than an image: it scales to any screen, costs no request, and follows the theme — the two
9649
- * line colours are variables, so it is faint on light and faint on dark without a second asset.
10569
+ * Two gradients rather than an image: it scales to any screen, costs no request, and follows the theme — the line
10570
+ * colour is a variable, so it is faint on light and faint on dark without a second asset.
9650
10571
  */
9651
- var backdrop = styles("bg-rectangles", {
10572
+ var backdrop = styles("backdrop", {
9652
10573
  top: "0%",
9653
10574
  left: "0%",
9654
10575
  bottom: "0%",
9655
10576
  right: "0%",
9656
10577
  position: "fixed",
9657
- "background-image": "linear-gradient(0deg, var(--grid-big) 1px, transparent 1px), linear-gradient(90deg, var(--grid-big) 1px, transparent 1px), linear-gradient(0deg, var(--grid-small) 1px, transparent 1px), linear-gradient(90deg, var(--grid-small) 1px, transparent 1px)",
9658
- "background-size": "100px 100px, 100px 100px, 10px 10px, 10px 10px",
9659
- "background-position": "0% 0%, 0% 0%, 0% 0%, 0% 0%",
9660
- "background-repeat": "repeat, repeat, repeat, repeat",
9661
- "background-attachment": "scroll, scroll, scroll, scroll",
9662
- "background-clip": "border-box, border-box, border-box, border-box"
10578
+ "background-image": "linear-gradient(0deg, var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px)",
10579
+ "background-size": "48px 48px, 48px 48px",
10580
+ "background-position": "0% 0%, 0% 0%",
10581
+ "background-repeat": "repeat, repeat",
10582
+ "background-attachment": "scroll, scroll",
10583
+ "background-clip": "border-box, border-box"
9663
10584
  });
9664
- /** One of the four links along the bottom: a title with an arrow, and a line about where it goes. */
9665
- var card = (id, title, body, href = "#") => link({
9666
- id,
9667
- href,
9668
- class: buttonLink,
9669
- children: [container({
9670
- class: titleRow,
9671
- children: [heading({
9672
- id: `${id}-title`,
9673
- content: title,
9674
- subType: "h1"
9675
- }), fontAwesome({
9676
- icon: "fas fa-arrow-right",
9677
- class: titleIcon
10585
+ var navLink = styles("nav-link", {
10586
+ css: {
10587
+ display: "flex",
10588
+ "align-items": "center",
10589
+ gap: "8px",
10590
+ color: "var(--muted)",
10591
+ "font-size": "14px",
10592
+ "font-weight": "500",
10593
+ "text-decoration": "none",
10594
+ "border-radius": "8px",
10595
+ "padding-top": "6px",
10596
+ "padding-bottom": "6px",
10597
+ "padding-left": "10px",
10598
+ "padding-right": "10px"
10599
+ },
10600
+ states: {
10601
+ hover: { color: "var(--foreground)" },
10602
+ "focus-visible": focusRing
10603
+ }
10604
+ });
10605
+ /** The theme switch, dressed like the rest of the bar: a browser draws a bare button grey and square. */
10606
+ var iconButton = styles("icon-button", {
10607
+ css: {
10608
+ display: "flex",
10609
+ "align-items": "center",
10610
+ "justify-content": "center",
10611
+ width: "36px",
10612
+ height: "36px",
10613
+ "border-radius": "8px",
10614
+ "border-width": "1px",
10615
+ "border-style": "solid",
10616
+ "border-color": "var(--border)",
10617
+ "background-color": "var(--card)",
10618
+ color: "var(--muted)",
10619
+ "font-size": "16px",
10620
+ cursor: "pointer"
10621
+ },
10622
+ states: {
10623
+ hover: { color: "var(--foreground)" },
10624
+ "focus-visible": focusRing
10625
+ }
10626
+ });
10627
+ /** A call to action. The base is the quiet one; `primary` is the one the eye should land on. */
10628
+ var button$1 = styles("button", {
10629
+ css: {
10630
+ display: "flex",
10631
+ "align-items": "center",
10632
+ "justify-content": "center",
10633
+ gap: "8px",
10634
+ height: "44px",
10635
+ "padding-left": "20px",
10636
+ "padding-right": "20px",
10637
+ "border-radius": "10px",
10638
+ "border-width": "1px",
10639
+ "border-style": "solid",
10640
+ "border-color": "var(--border)",
10641
+ "background-color": "var(--card)",
10642
+ color: "var(--foreground)",
10643
+ "font-size": "15px",
10644
+ "font-weight": "600",
10645
+ "text-decoration": "none",
10646
+ "transition-property": "background-color, border-color, transform",
10647
+ "transition-duration": "150ms",
10648
+ "transition-timing-function": "ease-out"
10649
+ },
10650
+ states: {
10651
+ hover: { "border-color": "var(--muted)" },
10652
+ "focus-visible": focusRing
10653
+ },
10654
+ variants: { primary: {
10655
+ css: {
10656
+ "background-color": "var(--primary)",
10657
+ "border-color": "var(--primary)",
10658
+ color: "var(--primary-foreground)",
10659
+ "box-shadow": "var(--shadow-md)"
10660
+ },
10661
+ states: { hover: {
10662
+ "background-color": "var(--primary-hover)",
10663
+ "border-color": "var(--primary-hover)"
10664
+ } }
10665
+ } }
10666
+ });
10667
+ /** One guide: the whole card is the link, so the target is as large as what it describes. */
10668
+ var card = styles("guide-card", {
10669
+ css: {
10670
+ display: "flex",
10671
+ "flex-direction": "column",
10672
+ gap: "12px",
10673
+ "padding-top": "24px",
10674
+ "padding-bottom": "24px",
10675
+ "padding-left": "24px",
10676
+ "padding-right": "24px",
10677
+ "border-radius": "16px",
10678
+ "border-width": "1px",
10679
+ "border-style": "solid",
10680
+ "border-color": "var(--border)",
10681
+ "background-color": "var(--card)",
10682
+ "box-shadow": "var(--shadow-sm)",
10683
+ "text-decoration": "none",
10684
+ "transition-property": "transform, border-color, box-shadow",
10685
+ "transition-duration": "200ms",
10686
+ "transition-timing-function": "ease-out"
10687
+ },
10688
+ states: {
10689
+ hover: {
10690
+ transform: "translateY(-3px)",
10691
+ "border-color": "var(--primary)",
10692
+ "box-shadow": "var(--shadow-lg)"
10693
+ },
10694
+ "focus-visible": focusRing
10695
+ }
10696
+ });
10697
+ var cardHead = styles("guide-head", {
10698
+ display: "flex",
10699
+ "align-items": "center",
10700
+ gap: "8px"
10701
+ });
10702
+ /** The arrow slides while the card around it is hovered. */
10703
+ var cardArrow = styles("guide-arrow", {
10704
+ css: {
10705
+ color: "var(--muted)",
10706
+ "font-size": "13px",
10707
+ "margin-left": "auto",
10708
+ "transition-property": "transform, color",
10709
+ "transition-duration": "200ms",
10710
+ "transition-timing-function": "ease-out"
10711
+ },
10712
+ ancestors: { [card.name]: { states: { hover: {
10713
+ transform: "translateX(4px)",
10714
+ color: "var(--primary)"
10715
+ } } } }
10716
+ });
10717
+ /** The square an icon sits in. Its colour is a tone, worn beside it: `class: [tile, tones.violet]`. */
10718
+ var tile = styles("tile", {
10719
+ display: "flex",
10720
+ "align-items": "center",
10721
+ "justify-content": "center",
10722
+ width: "40px",
10723
+ height: "40px",
10724
+ "border-radius": "10px",
10725
+ "font-size": "16px"
10726
+ });
10727
+ /** One class per tone, each a pair of palette variables — so a tone is dark-ready the moment it is declared. */
10728
+ var tones = {
10729
+ violet: styles("tone-violet", {
10730
+ color: "var(--tint-violet)",
10731
+ "background-color": "var(--tint-violet-bg)"
10732
+ }),
10733
+ cyan: styles("tone-cyan", {
10734
+ color: "var(--tint-cyan)",
10735
+ "background-color": "var(--tint-cyan-bg)"
10736
+ }),
10737
+ amber: styles("tone-amber", {
10738
+ color: "var(--tint-amber)",
10739
+ "background-color": "var(--tint-amber-bg)"
10740
+ }),
10741
+ emerald: styles("tone-emerald", {
10742
+ color: "var(--tint-emerald)",
10743
+ "background-color": "var(--tint-emerald-bg)"
10744
+ }),
10745
+ rose: styles("tone-rose", {
10746
+ color: "var(--tint-rose)",
10747
+ "background-color": "var(--tint-rose-bg)"
10748
+ }),
10749
+ blue: styles("tone-blue", {
10750
+ color: "var(--tint-blue)",
10751
+ "background-color": "var(--tint-blue-bg)"
10752
+ })
10753
+ };
10754
+ /** Each band of the page wears `shell` for its width, and one of these for what is its own. */
10755
+ var topBarBand = styles("top-bar", {
10756
+ "flex-direction": "row",
10757
+ "align-items": "center",
10758
+ "justify-content": "space-between",
10759
+ "padding-top": "20px",
10760
+ "padding-bottom": "20px"
10761
+ });
10762
+ var heroBand = styles("hero", { css: {
10763
+ desktop: {
10764
+ "align-items": "center",
10765
+ gap: "24px",
10766
+ "padding-top": "96px",
10767
+ "padding-bottom": "80px"
10768
+ },
10769
+ tablet: {
10770
+ "padding-top": "64px",
10771
+ "padding-bottom": "56px"
10772
+ },
10773
+ mobile: {
10774
+ "padding-top": "48px",
10775
+ "padding-bottom": "40px"
10776
+ }
10777
+ } });
10778
+ var guidesBand = styles("guides", {
10779
+ gap: "20px",
10780
+ "padding-bottom": "80px"
10781
+ });
10782
+ var footerBand = styles("footer", { css: {
10783
+ desktop: {
10784
+ "flex-direction": "row",
10785
+ "align-items": "center",
10786
+ "justify-content": "space-between",
10787
+ "margin-top": "auto",
10788
+ "padding-top": "24px",
10789
+ "padding-bottom": "32px",
10790
+ "border-top-width": "1px",
10791
+ "border-top-style": "solid",
10792
+ "border-top-color": "var(--border)"
10793
+ },
10794
+ mobile: {
10795
+ "flex-direction": "column",
10796
+ gap: "8px"
10797
+ }
10798
+ } });
10799
+ /** Where to go next, as data: the grid below is this list, mapped. Each one is a page of the docs. */
10800
+ var GUIDES = [
10801
+ {
10802
+ id: "concepts",
10803
+ title: "Core concepts",
10804
+ body: "Spaces, pages and elements, the two documents behind them, and who owns what.",
10805
+ path: "concepts",
10806
+ icon: "fas fa-shapes",
10807
+ tone: "violet"
10808
+ },
10809
+ {
10810
+ id: "authoring",
10811
+ title: "A space in code",
10812
+ body: "Write this page as TypeScript: one declaration in, two documents out.",
10813
+ path: "authoring",
10814
+ icon: "fas fa-code",
10815
+ tone: "cyan"
10816
+ },
10817
+ {
10818
+ id: "styling",
10819
+ title: "Styling and themes",
10820
+ body: "Shared classes, states, breakpoints, and a palette that follows light and dark.",
10821
+ path: "styling",
10822
+ icon: "fas fa-palette",
10823
+ tone: "rose"
10824
+ },
10825
+ {
10826
+ id: "data",
10827
+ title: "Data and bindings",
10828
+ body: "Fetch from an API and bind what comes back to any element on the page.",
10829
+ path: "data",
10830
+ icon: "fas fa-database",
10831
+ tone: "emerald"
10832
+ },
10833
+ {
10834
+ id: "interactions",
10835
+ title: "Interactions and flows",
10836
+ body: "Clicks, forms and page loads wired to steps — no client code to write.",
10837
+ path: "interactions",
10838
+ icon: "fas fa-bolt",
10839
+ tone: "amber"
10840
+ },
10841
+ {
10842
+ id: "agents",
10843
+ title: "Agents and MCP",
10844
+ body: "Let an AI agent read and edit this space through the same rules you do.",
10845
+ path: "agents",
10846
+ icon: "fas fa-robot",
10847
+ tone: "blue"
10848
+ }
10849
+ ];
10850
+ var guideCard = (guide) => link({
10851
+ id: guide.id,
10852
+ href: `${DOCS}/${guide.path}`,
10853
+ mode: "external",
10854
+ target: "blank",
10855
+ class: card,
10856
+ children: [
10857
+ container({
10858
+ class: cardHead,
10859
+ children: [container({
10860
+ class: [tile, tones[guide.tone]],
10861
+ children: [fontAwesome({ icon: guide.icon })]
10862
+ }), fontAwesome({
10863
+ icon: "fas fa-arrow-right",
10864
+ class: cardArrow
10865
+ })]
10866
+ }),
10867
+ heading({
10868
+ id: `${guide.id}-title`,
10869
+ content: guide.title,
10870
+ subType: "h3",
10871
+ css: {
10872
+ "font-size": "17px",
10873
+ "font-weight": "600",
10874
+ "margin-top": "4px",
10875
+ "margin-bottom": "0px"
10876
+ }
10877
+ }),
10878
+ paragraph({
10879
+ content: guide.body,
10880
+ css: {
10881
+ color: "var(--muted)",
10882
+ "font-size": "14px",
10883
+ "line-height": "1.6",
10884
+ "margin-top": "0px",
10885
+ "margin-bottom": "0px"
10886
+ }
10887
+ })
10888
+ ]
10889
+ });
10890
+ var topBar = container({
10891
+ id: "top-bar",
10892
+ class: [shell, topBarBand],
10893
+ children: [link({
10894
+ id: "brand",
10895
+ href: "https://plitzi.com",
10896
+ mode: "external",
10897
+ target: "blank",
10898
+ class: navLink,
10899
+ children: [image({
10900
+ src: "https://cdn.plitzi.com/resources/img/favicon.svg",
10901
+ css: {
10902
+ width: "24px",
10903
+ height: "24px"
10904
+ }
10905
+ }), text("Plitzi", { css: {
10906
+ color: "var(--foreground)",
10907
+ "font-size": "16px",
10908
+ "font-weight": "700"
10909
+ } })]
10910
+ }), container({
10911
+ id: "top-actions",
10912
+ css: {
10913
+ display: "flex",
10914
+ "align-items": "center",
10915
+ gap: "8px"
10916
+ },
10917
+ children: [link({
10918
+ id: "top-docs",
10919
+ href: DOCS,
10920
+ mode: "external",
10921
+ target: "blank",
10922
+ class: navLink,
10923
+ children: [text("Docs")]
10924
+ }), themeToggle({
10925
+ id: "theme",
10926
+ class: iconButton
9678
10927
  })]
9679
- }), paragraph({ content: body })]
10928
+ })]
10929
+ });
10930
+ var heroEyebrow = container({
10931
+ id: "hero-eyebrow",
10932
+ css: {
10933
+ display: "flex",
10934
+ "align-items": "center",
10935
+ gap: "8px",
10936
+ "padding-top": "6px",
10937
+ "padding-bottom": "6px",
10938
+ "padding-left": "12px",
10939
+ "padding-right": "12px",
10940
+ "border-radius": "999px",
10941
+ "border-width": "1px",
10942
+ "border-style": "solid",
10943
+ "border-color": "var(--border)",
10944
+ "background-color": "var(--card)",
10945
+ "font-size": "13px",
10946
+ "font-weight": "500"
10947
+ },
10948
+ children: [container({ css: {
10949
+ width: "8px",
10950
+ height: "8px",
10951
+ "border-radius": "999px",
10952
+ "background-color": "var(--tint-emerald)"
10953
+ } }), text("Your new space", { css: { color: "var(--muted)" } })]
10954
+ });
10955
+ var heroTitle = heading({
10956
+ id: "hero-title",
10957
+ content: "Welcome to Plitzi",
10958
+ subType: "h1",
10959
+ css: {
10960
+ desktop: {
10961
+ "font-size": "64px",
10962
+ "font-weight": "700",
10963
+ "letter-spacing": "-0.03em",
10964
+ "line-height": "1.05",
10965
+ "text-align": "center",
10966
+ "margin-top": "0px",
10967
+ "margin-bottom": "0px"
10968
+ },
10969
+ tablet: { "font-size": "48px" },
10970
+ mobile: { "font-size": "38px" }
10971
+ }
10972
+ });
10973
+ var heroLede = paragraph({
10974
+ id: "hero-lede",
10975
+ content: "This page is where your space starts. Change it in the builder, in code, or by asking an agent — and when you want to know how something works, the guides below go straight to it.",
10976
+ css: {
10977
+ desktop: {
10978
+ color: "var(--muted)",
10979
+ "font-size": "18px",
10980
+ "line-height": "1.6",
10981
+ "text-align": "center",
10982
+ "max-width": "620px",
10983
+ "margin-top": "0px",
10984
+ "margin-bottom": "0px"
10985
+ },
10986
+ mobile: { "font-size": "16px" }
10987
+ }
10988
+ });
10989
+ var heroActions = container({
10990
+ id: "hero-actions",
10991
+ css: {
10992
+ desktop: {
10993
+ display: "flex",
10994
+ "align-items": "center",
10995
+ "justify-content": "center",
10996
+ gap: "12px",
10997
+ "margin-top": "8px"
10998
+ },
10999
+ mobile: {
11000
+ "flex-direction": "column",
11001
+ "align-items": "stretch",
11002
+ width: "100%"
11003
+ }
11004
+ },
11005
+ children: [link({
11006
+ id: "cta-docs",
11007
+ href: DOCS,
11008
+ mode: "external",
11009
+ target: "blank",
11010
+ class: button$1,
11011
+ variant: "primary",
11012
+ children: [text("Read the docs"), fontAwesome({ icon: "fas fa-arrow-right" })]
11013
+ }), link({
11014
+ id: "cta-quickstart",
11015
+ href: `${DOCS}/quickstart`,
11016
+ mode: "external",
11017
+ target: "blank",
11018
+ class: button$1,
11019
+ children: [fontAwesome({ icon: "fas fa-terminal" }), text("Quickstart")]
11020
+ })]
9680
11021
  });
9681
11022
  var space = {
9682
11023
  name: "New space",
@@ -9689,36 +11030,156 @@ var space = {
9689
11030
  /**
9690
11031
  * Every colour the page uses, per scheme.
9691
11032
  *
9692
- * `default` is what a browser with no preference gets. Nothing below names a colour directly — they are all
11033
+ * `default` is what a browser with no preference gets. Nothing above names a colour directly — they are all
9693
11034
  * `var(--…)` — so switching the palette here re-themes the whole page, in both schemes, without touching a rule.
9694
11035
  */
9695
- variables: { color: {
9696
- foreground: {
9697
- light: "#17171c",
9698
- dark: "#fafafa",
9699
- default: "#17171c"
9700
- },
9701
- "grid-big": {
9702
- light: "#00000010",
9703
- dark: "#ffffff10",
9704
- default: "#00000010"
9705
- },
9706
- "grid-small": {
9707
- light: "#0000000A",
9708
- dark: "#ffffff0A",
9709
- default: "#0000000A"
9710
- },
9711
- "background-outer": {
9712
- light: "#dce6ff",
9713
- dark: "#000000",
9714
- default: "#dce6ff"
9715
- },
9716
- "background-inner": {
9717
- light: "#ffffff",
9718
- dark: "#080866",
9719
- default: "#ffffff"
9720
- }
9721
- } },
11036
+ variables: {
11037
+ color: {
11038
+ background: {
11039
+ light: "#fbfbfd",
11040
+ dark: "#09090b",
11041
+ default: "#fbfbfd"
11042
+ },
11043
+ foreground: {
11044
+ light: "#17171c",
11045
+ dark: "#fafafa",
11046
+ default: "#17171c"
11047
+ },
11048
+ muted: {
11049
+ light: "#5f5f6e",
11050
+ dark: "#a1a1aa",
11051
+ default: "#5f5f6e"
11052
+ },
11053
+ card: {
11054
+ light: "#ffffff",
11055
+ dark: "#111115",
11056
+ default: "#ffffff"
11057
+ },
11058
+ border: {
11059
+ light: "#e6e6ee",
11060
+ dark: "#27272d",
11061
+ default: "#e6e6ee"
11062
+ },
11063
+ primary: {
11064
+ light: "#5b3df5",
11065
+ dark: "#7c66ff",
11066
+ default: "#5b3df5"
11067
+ },
11068
+ "primary-hover": {
11069
+ light: "#4a2de0",
11070
+ dark: "#9180ff",
11071
+ default: "#4a2de0"
11072
+ },
11073
+ "primary-foreground": {
11074
+ light: "#ffffff",
11075
+ dark: "#ffffff",
11076
+ default: "#ffffff"
11077
+ },
11078
+ glow: {
11079
+ light: "rgba(91, 61, 245, 0.16)",
11080
+ dark: "rgba(124, 102, 255, 0.24)",
11081
+ default: "rgba(91, 61, 245, 0.16)"
11082
+ },
11083
+ grid: {
11084
+ light: "#0000000a",
11085
+ dark: "#ffffff0a",
11086
+ default: "#0000000a"
11087
+ },
11088
+ "tint-violet": {
11089
+ light: "#5b3df5",
11090
+ dark: "#b7a6ff",
11091
+ default: "#5b3df5"
11092
+ },
11093
+ "tint-violet-bg": {
11094
+ light: "#efecfe",
11095
+ dark: "#1c1836",
11096
+ default: "#efecfe"
11097
+ },
11098
+ "tint-cyan": {
11099
+ light: "#0e7490",
11100
+ dark: "#67d8ef",
11101
+ default: "#0e7490"
11102
+ },
11103
+ "tint-cyan-bg": {
11104
+ light: "#e0f5fa",
11105
+ dark: "#0c2a33",
11106
+ default: "#e0f5fa"
11107
+ },
11108
+ "tint-amber": {
11109
+ light: "#a45b00",
11110
+ dark: "#f5c169",
11111
+ default: "#a45b00"
11112
+ },
11113
+ "tint-amber-bg": {
11114
+ light: "#fcf0dc",
11115
+ dark: "#2e2314",
11116
+ default: "#fcf0dc"
11117
+ },
11118
+ "tint-rose": {
11119
+ light: "#c2255c",
11120
+ dark: "#f994bc",
11121
+ default: "#c2255c"
11122
+ },
11123
+ "tint-rose-bg": {
11124
+ light: "#fce8f0",
11125
+ dark: "#331623",
11126
+ default: "#fce8f0"
11127
+ },
11128
+ "tint-emerald": {
11129
+ light: "#0f7b55",
11130
+ dark: "#64d6a6",
11131
+ default: "#0f7b55"
11132
+ },
11133
+ "tint-emerald-bg": {
11134
+ light: "#e0f6ee",
11135
+ dark: "#0e2a21",
11136
+ default: "#e0f6ee"
11137
+ },
11138
+ "tint-blue": {
11139
+ light: "#2159c4",
11140
+ dark: "#8ab0f7",
11141
+ default: "#2159c4"
11142
+ },
11143
+ "tint-blue-bg": {
11144
+ light: "#e6edfc",
11145
+ dark: "#13203c",
11146
+ default: "#e6edfc"
11147
+ }
11148
+ },
11149
+ shadow: {
11150
+ "shadow-sm": {
11151
+ light: "0 1px 2px rgba(12, 12, 20, 0.05)",
11152
+ dark: "0 1px 2px rgba(0, 0, 0, 0.5)",
11153
+ default: "0 1px 2px rgba(12, 12, 20, 0.05)"
11154
+ },
11155
+ "shadow-md": {
11156
+ light: "0 1px 2px rgba(12, 12, 20, 0.06), 0 8px 20px -8px rgba(91, 61, 245, 0.45)",
11157
+ dark: "0 1px 2px rgba(0, 0, 0, 0.6), 0 8px 24px -8px rgba(124, 102, 255, 0.55)",
11158
+ default: "0 1px 2px rgba(12, 12, 20, 0.06), 0 8px 20px -8px rgba(91, 61, 245, 0.45)"
11159
+ },
11160
+ "shadow-lg": {
11161
+ light: "0 2px 4px rgba(12, 12, 20, 0.05), 0 24px 48px -20px rgba(12, 12, 20, 0.25)",
11162
+ dark: "0 2px 4px rgba(0, 0, 0, 0.6), 0 28px 56px -22px rgba(0, 0, 0, 0.85)",
11163
+ default: "0 2px 4px rgba(12, 12, 20, 0.05), 0 24px 48px -20px rgba(12, 12, 20, 0.25)"
11164
+ }
11165
+ },
11166
+ custom: { "font-sans": "Geist, ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif" }
11167
+ },
11168
+ /** Loaded by the page itself: a face the space names here is the only one it ever fetches. */
11169
+ fonts: [{
11170
+ family: "Geist",
11171
+ fallback: "ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif",
11172
+ weights: [
11173
+ 400,
11174
+ 500,
11175
+ 600,
11176
+ 700
11177
+ ],
11178
+ styles: ["normal"],
11179
+ display: "swap",
11180
+ preload: true,
11181
+ source: "google"
11182
+ }],
9722
11183
  /**
9723
11184
  * What text is, before any class touches it.
9724
11185
  *
@@ -9726,10 +11187,11 @@ var space = {
9726
11187
  * makes the dark scheme work: a hard-coded colour would win against the theme and leave black text on black.
9727
11188
  */
9728
11189
  elements: {
11190
+ page: { base: { "font-family": "var(--font-sans)" } },
9729
11191
  heading: { base: { color: "var(--foreground)" } },
9730
- text: { base: { color: "var(--foreground)" } },
11192
+ text: { base: { color: "inherit" } },
9731
11193
  paragraph: { base: { color: "var(--foreground)" } },
9732
- fontAwesome: { base: { color: "var(--foreground)" } }
11194
+ fontAwesome: { base: { color: "inherit" } }
9733
11195
  },
9734
11196
  pages: [{
9735
11197
  id: "home",
@@ -9737,110 +11199,84 @@ var space = {
9737
11199
  slug: "",
9738
11200
  isDefault: true,
9739
11201
  css: {
9740
- desktop: {
9741
- "flex-direction": "column",
9742
- "align-items": "center",
9743
- "justify-content": "space-between",
9744
- padding: "100px",
9745
- position: "relative",
9746
- "min-width": "100vw",
9747
- "min-height": "100vh",
9748
- "background-image": "radial-gradient(circle at 50% 50%, var(--background-inner) -30%, var(--background-outer) 100%)",
9749
- "background-size": "auto",
9750
- "background-position": "0% 0%",
9751
- "background-repeat": "no-repeat",
9752
- "background-attachment": "scroll",
9753
- "background-clip": "border-box"
9754
- },
9755
- tablet: {
9756
- "justify-content": "flex-start",
9757
- padding: "60px"
9758
- },
9759
- mobile: {
9760
- "justify-content": "flex-start",
9761
- padding: "40px 24px"
9762
- }
11202
+ "flex-direction": "column",
11203
+ position: "relative",
11204
+ "min-width": "100%",
11205
+ "min-height": "100dvh",
11206
+ color: "var(--foreground)",
11207
+ "background-color": "var(--background)",
11208
+ "background-image": "radial-gradient(60rem 32rem at 50% -8rem, var(--glow), transparent 70%)",
11209
+ "background-repeat": "no-repeat"
9763
11210
  },
9764
11211
  body: [
9765
11212
  container({
9766
11213
  id: "backdrop",
9767
11214
  class: backdrop
9768
11215
  }),
11216
+ topBar,
9769
11217
  container({
9770
- id: "logo",
9771
- css: { desktop: {
9772
- width: "75vw",
9773
- height: "75vh",
9774
- position: "absolute"
9775
- } },
9776
- children: [image({
9777
- src: "https://cdn.plitzi.com/resources/img/favicon.svg",
9778
- css: { desktop: {
9779
- width: "100%",
9780
- height: "100%",
9781
- opacity: "0.45"
9782
- } }
9783
- })]
11218
+ id: "hero",
11219
+ class: [shell, heroBand],
11220
+ children: [
11221
+ heroEyebrow,
11222
+ heroTitle,
11223
+ heroLede,
11224
+ heroActions
11225
+ ]
9784
11226
  }),
9785
11227
  container({
9786
- id: "hero",
9787
- css: { desktop: {
9788
- "z-index": "1",
9789
- color: "white",
9790
- "margin-bottom": "40px"
9791
- } },
11228
+ id: "guides",
11229
+ class: [shell, guidesBand],
9792
11230
  children: [heading({
9793
- id: "hero-title",
9794
- content: "Welcome To Plitzi",
9795
- subType: "h1"
11231
+ id: "guides-title",
11232
+ content: "Where to go next",
11233
+ subType: "h2",
11234
+ css: {
11235
+ "font-size": "14px",
11236
+ "font-weight": "600",
11237
+ color: "var(--muted)",
11238
+ "margin-top": "0px",
11239
+ "margin-bottom": "0px"
11240
+ }
11241
+ }), container({
11242
+ id: "cards",
11243
+ css: {
11244
+ desktop: {
11245
+ display: "grid",
11246
+ "grid-template-columns": "repeat(3, minmax(0, 1fr))",
11247
+ gap: "16px"
11248
+ },
11249
+ tablet: { "grid-template-columns": "repeat(2, minmax(0, 1fr))" },
11250
+ mobile: { "grid-template-columns": "minmax(0, 1fr)" }
11251
+ },
11252
+ children: GUIDES.map(guideCard)
9796
11253
  })]
9797
11254
  }),
9798
11255
  container({
9799
- id: "cards",
9800
- css: {
9801
- desktop: {
9802
- display: "flex",
9803
- "align-items": "center",
9804
- "z-index": "1",
9805
- gap: "40px"
9806
- },
9807
- tablet: {
9808
- "flex-direction": "column",
9809
- "min-height": "auto",
9810
- "min-width": "auto",
9811
- "flex-grow": "1",
9812
- "flex-shrink": "1",
9813
- "flex-basis": "0%",
9814
- "align-items": "flex-start"
9815
- },
9816
- mobile: {
9817
- "flex-direction": "column",
9818
- "min-height": "auto",
9819
- "min-width": "auto",
9820
- "flex-grow": "1",
9821
- "flex-shrink": "1",
9822
- "flex-basis": "0%",
9823
- "align-items": "flex-start",
9824
- gap: "24px"
9825
- }
9826
- },
9827
- children: [
9828
- card("docs", "Docs", "Find in-depth information about Plitzi features and API."),
9829
- card("learn", "Learn", "Learn about Plitzi in an interactive course with quizzes!"),
9830
- card("templates", "Templates", "Explore the Plitzi playground"),
9831
- card("deploy", "Deploy", "Instantly deploy your Plitzi Space")
9832
- ]
11256
+ id: "footer",
11257
+ class: [shell, footerBand],
11258
+ children: [text("Made with Plitzi", { css: {
11259
+ color: "var(--muted)",
11260
+ "font-size": "13px"
11261
+ } }), link({
11262
+ id: "footer-docs",
11263
+ href: DOCS,
11264
+ mode: "external",
11265
+ target: "blank",
11266
+ class: navLink,
11267
+ children: [text("plitzi.com/docs")]
11268
+ })]
9833
11269
  })
9834
11270
  ]
9835
11271
  }]
9836
11272
  };
9837
11273
  //#endregion
9838
11274
  //#region src/spaces/blank/spec.ts?raw
9839
- var spec_default = "import { container, fontAwesome, heading, image, link, paragraph } from '../../elements';\nimport { styles } from '../../style';\n\nimport type { ElementSpec, SpaceSpec } from '../../schema';\n\n/**\n * The space, declared.\n *\n * This is the whole site: a tree, some CSS and a palette. Everything else — element ids, style selector names, the\n * back-references between them — is derived from what is written here, so authoring it twice writes byte-identical\n * documents and there is no generated file to keep in step.\n *\n * It starts as the space Plitzi gives a new account, and it is yours: rename things, change the palette, delete\n * the cards. The four cards are one function called four times, which is not a saving of keystrokes — change\n * `card` and all four follow, and that is the difference between a design and four copies of one.\n *\n * Name anything a test, a binding or an agent should be able to point at (`id: 'hero-title'`). An element with no\n * name gets a positional one, which moves the moment something is inserted above it.\n */\n\n/** The classes the page shares. Declared once, so re-theming a card re-themes every card. */\nconst buttonLink = styles('button-link', {\n color: 'white',\n 'flex-basis': '0px',\n 'flex-grow': '1',\n 'flex-shrink': '1'\n});\n\nconst titleRow = styles('title-container', { display: 'flex', 'align-items': 'center' });\n\n/** The arrow slides while the card around it is hovered. */\nconst titleIcon = styles('title-icon', {\n css: { 'margin-left': '10px' },\n ancestors: {\n [buttonLink.name]: {\n states: {\n hover: {\n transform: 'translateX(10px)',\n 'transition-property': 'transform',\n 'transition-timing-function': 'cubic-bezier(0.4, 0.2, 1)',\n 'transition-duration': '150ms'\n }\n }\n }\n }\n});\n\n/**\n * The grid behind everything, pinned to the viewport.\n *\n * Four gradients rather than an image: it scales to any screen, costs no request, and follows the theme — the two\n * line colours are variables, so it is faint on light and faint on dark without a second asset.\n */\nconst backdrop = styles('bg-rectangles', {\n top: '0%',\n left: '0%',\n bottom: '0%',\n right: '0%',\n position: 'fixed',\n 'background-image':\n 'linear-gradient(0deg, var(--grid-big) 1px, transparent 1px), ' +\n 'linear-gradient(90deg, var(--grid-big) 1px, transparent 1px), ' +\n 'linear-gradient(0deg, var(--grid-small) 1px, transparent 1px), ' +\n 'linear-gradient(90deg, var(--grid-small) 1px, transparent 1px)',\n 'background-size': '100px 100px, 100px 100px, 10px 10px, 10px 10px',\n 'background-position': '0% 0%, 0% 0%, 0% 0%, 0% 0%',\n 'background-repeat': 'repeat, repeat, repeat, repeat',\n 'background-attachment': 'scroll, scroll, scroll, scroll',\n 'background-clip': 'border-box, border-box, border-box, border-box'\n});\n\n/** One of the four links along the bottom: a title with an arrow, and a line about where it goes. */\nconst card = (id: string, title: string, body: string, href = '#'): ElementSpec =>\n link({\n id,\n href,\n class: buttonLink,\n children: [\n container({\n class: titleRow,\n children: [\n heading({ id: `${id}-title`, content: title, subType: 'h1' }),\n fontAwesome({ icon: 'fas fa-arrow-right', class: titleIcon })\n ]\n }),\n paragraph({ content: body })\n ]\n });\n\nexport const space: SpaceSpec = {\n name: 'New space',\n permanentUrl: 'new-space',\n mode: 'desktop-first',\n theme: { default: 'system', schemes: ['light', 'dark'] },\n /**\n * Every colour the page uses, per scheme.\n *\n * `default` is what a browser with no preference gets. Nothing below names a colour directly — they are all\n * `var(--…)` — so switching the palette here re-themes the whole page, in both schemes, without touching a rule.\n */\n variables: {\n color: {\n foreground: { light: '#17171c', dark: '#fafafa', default: '#17171c' },\n 'grid-big': { light: '#00000010', dark: '#ffffff10', default: '#00000010' },\n 'grid-small': { light: '#0000000A', dark: '#ffffff0A', default: '#0000000A' },\n 'background-outer': { light: '#dce6ff', dark: '#000000', default: '#dce6ff' },\n 'background-inner': { light: '#ffffff', dark: '#080866', default: '#ffffff' }\n }\n },\n /**\n * What text is, before any class touches it.\n *\n * Per element TYPE, so every heading and paragraph follows the palette without naming a colour — which is what\n * makes the dark scheme work: a hard-coded colour would win against the theme and leave black text on black.\n */\n elements: {\n heading: { base: { color: 'var(--foreground)' } },\n text: { base: { color: 'var(--foreground)' } },\n paragraph: { base: { color: 'var(--foreground)' } },\n fontAwesome: { base: { color: 'var(--foreground)' } }\n },\n pages: [\n {\n id: 'home',\n name: 'Home',\n slug: '',\n isDefault: true,\n css: {\n desktop: {\n 'flex-direction': 'column',\n 'align-items': 'center',\n 'justify-content': 'space-between',\n padding: '100px',\n position: 'relative',\n 'min-width': '100vw',\n 'min-height': '100vh',\n 'background-image':\n 'radial-gradient(circle at 50% 50%, var(--background-inner) -30%, var(--background-outer) 100%)',\n 'background-size': 'auto',\n 'background-position': '0% 0%',\n 'background-repeat': 'no-repeat',\n 'background-attachment': 'scroll',\n 'background-clip': 'border-box'\n },\n tablet: { 'justify-content': 'flex-start', padding: '60px' },\n // Tablet and mobile are separate ranges: without this a phone gets the desktop's 100px back.\n mobile: { 'justify-content': 'flex-start', padding: '40px 24px' }\n },\n body: [\n container({ id: 'backdrop', class: backdrop }),\n container({\n id: 'logo',\n css: { desktop: { width: '75vw', height: '75vh', position: 'absolute' } },\n children: [\n image({\n src: 'https://cdn.plitzi.com/resources/img/favicon.svg',\n css: { desktop: { width: '100%', height: '100%', opacity: '0.45' } }\n })\n ]\n }),\n container({\n id: 'hero',\n css: { desktop: { 'z-index': '1', color: 'white', 'margin-bottom': '40px' } },\n children: [heading({ id: 'hero-title', content: 'Welcome To Plitzi', subType: 'h1' })]\n }),\n container({\n id: 'cards',\n css: {\n desktop: { display: 'flex', 'align-items': 'center', 'z-index': '1', gap: '40px' },\n tablet: {\n 'flex-direction': 'column',\n 'min-height': 'auto',\n 'min-width': 'auto',\n 'flex-grow': '1',\n 'flex-shrink': '1',\n 'flex-basis': '0%',\n 'align-items': 'flex-start'\n },\n mobile: {\n 'flex-direction': 'column',\n 'min-height': 'auto',\n 'min-width': 'auto',\n 'flex-grow': '1',\n 'flex-shrink': '1',\n 'flex-basis': '0%',\n 'align-items': 'flex-start',\n gap: '24px'\n }\n },\n children: [\n card('docs', 'Docs', 'Find in-depth information about Plitzi features and API.'),\n card('learn', 'Learn', 'Learn about Plitzi in an interactive course with quizzes!'),\n card('templates', 'Templates', 'Explore the Plitzi playground'),\n card('deploy', 'Deploy', 'Instantly deploy your Plitzi Space')\n ]\n })\n ]\n }\n ]\n};\n";
11275
+ var spec_default = "import { container, fontAwesome, heading, image, link, paragraph, text, themeToggle } from '../../elements';\nimport { styles } from '../../style';\n\nimport type { ElementSpec, SpaceSpec } from '../../schema';\n\n/**\n * The space, declared.\n *\n * This is the whole site: a tree, some CSS and a palette. Everything else — element ids, style selector names, the\n * back-references between them — is derived from what is written here, so authoring it twice writes byte-identical\n * documents and there is no generated file to keep in step.\n *\n * It starts as the space Plitzi gives a new account, and it is yours: rename things, change the palette, delete the\n * guides. The guides are one function mapped over one list, which is not a saving of keystrokes — change `guideCard`\n * and all six follow, add an entry to `GUIDES` and a seventh appears, styled like the rest.\n *\n * Name anything a test, a binding or an agent should be able to point at (`id: 'hero-title'`). An element with no\n * name gets a positional one, which moves the moment something is inserted above it.\n */\n\n/** Where the documentation lives. Every link on the page starts here, so moving the docs is one line. */\nconst DOCS = 'https://plitzi.com/docs';\n\n// ── Classes ────────────────────────────────────────────────────────────────────────────────────────────────────\n// Declared once and named by the elements that wear them, so re-theming a card re-themes every card.\n\n/** The same outline on everything that can be focused from the keyboard. */\nconst focusRing = { outline: '2px solid var(--primary)', 'outline-offset': '3px' };\n\nconst shell = styles('shell', {\n css: {\n desktop: {\n display: 'flex',\n 'flex-direction': 'column',\n width: '100%',\n 'max-width': '1120px',\n 'margin-left': 'auto',\n 'margin-right': 'auto',\n 'padding-left': '32px',\n 'padding-right': '32px',\n position: 'relative',\n 'z-index': '1'\n },\n tablet: { 'padding-left': '24px', 'padding-right': '24px' },\n mobile: { 'padding-left': '20px', 'padding-right': '20px' }\n }\n});\n\n/**\n * The grid behind everything, pinned to the viewport.\n *\n * Two gradients rather than an image: it scales to any screen, costs no request, and follows the theme — the line\n * colour is a variable, so it is faint on light and faint on dark without a second asset.\n */\nconst backdrop = styles('backdrop', {\n top: '0%',\n left: '0%',\n bottom: '0%',\n right: '0%',\n position: 'fixed',\n 'background-image':\n 'linear-gradient(0deg, var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px)',\n 'background-size': '48px 48px, 48px 48px',\n 'background-position': '0% 0%, 0% 0%',\n 'background-repeat': 'repeat, repeat',\n 'background-attachment': 'scroll, scroll',\n 'background-clip': 'border-box, border-box'\n});\n\nconst navLink = styles('nav-link', {\n css: {\n display: 'flex',\n 'align-items': 'center',\n gap: '8px',\n color: 'var(--muted)',\n 'font-size': '14px',\n 'font-weight': '500',\n 'text-decoration': 'none',\n 'border-radius': '8px',\n 'padding-top': '6px',\n 'padding-bottom': '6px',\n 'padding-left': '10px',\n 'padding-right': '10px'\n },\n states: { hover: { color: 'var(--foreground)' }, 'focus-visible': focusRing }\n});\n\n/** The theme switch, dressed like the rest of the bar: a browser draws a bare button grey and square. */\nconst iconButton = styles('icon-button', {\n css: {\n display: 'flex',\n 'align-items': 'center',\n 'justify-content': 'center',\n width: '36px',\n height: '36px',\n 'border-radius': '8px',\n 'border-width': '1px',\n 'border-style': 'solid',\n 'border-color': 'var(--border)',\n 'background-color': 'var(--card)',\n color: 'var(--muted)',\n 'font-size': '16px',\n cursor: 'pointer'\n },\n states: { hover: { color: 'var(--foreground)' }, 'focus-visible': focusRing }\n});\n\n/** A call to action. The base is the quiet one; `primary` is the one the eye should land on. */\nconst button = styles('button', {\n css: {\n display: 'flex',\n 'align-items': 'center',\n 'justify-content': 'center',\n gap: '8px',\n height: '44px',\n 'padding-left': '20px',\n 'padding-right': '20px',\n 'border-radius': '10px',\n 'border-width': '1px',\n 'border-style': 'solid',\n 'border-color': 'var(--border)',\n 'background-color': 'var(--card)',\n color: 'var(--foreground)',\n 'font-size': '15px',\n 'font-weight': '600',\n 'text-decoration': 'none',\n 'transition-property': 'background-color, border-color, transform',\n 'transition-duration': '150ms',\n 'transition-timing-function': 'ease-out'\n },\n states: {\n hover: { 'border-color': 'var(--muted)' },\n 'focus-visible': focusRing\n },\n variants: {\n primary: {\n css: {\n 'background-color': 'var(--primary)',\n 'border-color': 'var(--primary)',\n color: 'var(--primary-foreground)',\n 'box-shadow': 'var(--shadow-md)'\n },\n states: { hover: { 'background-color': 'var(--primary-hover)', 'border-color': 'var(--primary-hover)' } }\n }\n }\n});\n\n/** One guide: the whole card is the link, so the target is as large as what it describes. */\nconst card = styles('guide-card', {\n css: {\n display: 'flex',\n 'flex-direction': 'column',\n gap: '12px',\n 'padding-top': '24px',\n 'padding-bottom': '24px',\n 'padding-left': '24px',\n 'padding-right': '24px',\n 'border-radius': '16px',\n 'border-width': '1px',\n 'border-style': 'solid',\n 'border-color': 'var(--border)',\n 'background-color': 'var(--card)',\n 'box-shadow': 'var(--shadow-sm)',\n 'text-decoration': 'none',\n 'transition-property': 'transform, border-color, box-shadow',\n 'transition-duration': '200ms',\n 'transition-timing-function': 'ease-out'\n },\n states: {\n hover: { transform: 'translateY(-3px)', 'border-color': 'var(--primary)', 'box-shadow': 'var(--shadow-lg)' },\n 'focus-visible': focusRing\n }\n});\n\nconst cardHead = styles('guide-head', { display: 'flex', 'align-items': 'center', gap: '8px' });\n\n/** The arrow slides while the card around it is hovered. */\nconst cardArrow = styles('guide-arrow', {\n css: {\n color: 'var(--muted)',\n 'font-size': '13px',\n 'margin-left': 'auto',\n 'transition-property': 'transform, color',\n 'transition-duration': '200ms',\n 'transition-timing-function': 'ease-out'\n },\n ancestors: {\n [card.name]: { states: { hover: { transform: 'translateX(4px)', color: 'var(--primary)' } } }\n }\n});\n\n/** The square an icon sits in. Its colour is a tone, worn beside it: `class: [tile, tones.violet]`. */\nconst tile = styles('tile', {\n display: 'flex',\n 'align-items': 'center',\n 'justify-content': 'center',\n width: '40px',\n height: '40px',\n 'border-radius': '10px',\n 'font-size': '16px'\n});\n\n/** One class per tone, each a pair of palette variables — so a tone is dark-ready the moment it is declared. */\nconst tones = {\n violet: styles('tone-violet', { color: 'var(--tint-violet)', 'background-color': 'var(--tint-violet-bg)' }),\n cyan: styles('tone-cyan', { color: 'var(--tint-cyan)', 'background-color': 'var(--tint-cyan-bg)' }),\n amber: styles('tone-amber', { color: 'var(--tint-amber)', 'background-color': 'var(--tint-amber-bg)' }),\n emerald: styles('tone-emerald', { color: 'var(--tint-emerald)', 'background-color': 'var(--tint-emerald-bg)' }),\n rose: styles('tone-rose', { color: 'var(--tint-rose)', 'background-color': 'var(--tint-rose-bg)' }),\n blue: styles('tone-blue', { color: 'var(--tint-blue)', 'background-color': 'var(--tint-blue-bg)' })\n};\n\n/** Each band of the page wears `shell` for its width, and one of these for what is its own. */\nconst topBarBand = styles('top-bar', {\n 'flex-direction': 'row',\n 'align-items': 'center',\n 'justify-content': 'space-between',\n 'padding-top': '20px',\n 'padding-bottom': '20px'\n});\n\nconst heroBand = styles('hero', {\n css: {\n desktop: { 'align-items': 'center', gap: '24px', 'padding-top': '96px', 'padding-bottom': '80px' },\n tablet: { 'padding-top': '64px', 'padding-bottom': '56px' },\n mobile: { 'padding-top': '48px', 'padding-bottom': '40px' }\n }\n});\n\nconst guidesBand = styles('guides', { gap: '20px', 'padding-bottom': '80px' });\n\nconst footerBand = styles('footer', {\n css: {\n desktop: {\n 'flex-direction': 'row',\n 'align-items': 'center',\n 'justify-content': 'space-between',\n 'margin-top': 'auto',\n 'padding-top': '24px',\n 'padding-bottom': '32px',\n 'border-top-width': '1px',\n 'border-top-style': 'solid',\n 'border-top-color': 'var(--border)'\n },\n mobile: { 'flex-direction': 'column', gap: '8px' }\n }\n});\n\n// ── Content ────────────────────────────────────────────────────────────────────────────────────────────────────\n\ntype Guide = { id: string; title: string; body: string; path: string; icon: string; tone: keyof typeof tones };\n\n/** Where to go next, as data: the grid below is this list, mapped. Each one is a page of the docs. */\nconst GUIDES: Guide[] = [\n {\n id: 'concepts',\n title: 'Core concepts',\n body: 'Spaces, pages and elements, the two documents behind them, and who owns what.',\n path: 'concepts',\n icon: 'fas fa-shapes',\n tone: 'violet'\n },\n {\n id: 'authoring',\n title: 'A space in code',\n body: 'Write this page as TypeScript: one declaration in, two documents out.',\n path: 'authoring',\n icon: 'fas fa-code',\n tone: 'cyan'\n },\n {\n id: 'styling',\n title: 'Styling and themes',\n body: 'Shared classes, states, breakpoints, and a palette that follows light and dark.',\n path: 'styling',\n icon: 'fas fa-palette',\n tone: 'rose'\n },\n {\n id: 'data',\n title: 'Data and bindings',\n body: 'Fetch from an API and bind what comes back to any element on the page.',\n path: 'data',\n icon: 'fas fa-database',\n tone: 'emerald'\n },\n {\n id: 'interactions',\n title: 'Interactions and flows',\n body: 'Clicks, forms and page loads wired to steps — no client code to write.',\n path: 'interactions',\n icon: 'fas fa-bolt',\n tone: 'amber'\n },\n {\n id: 'agents',\n title: 'Agents and MCP',\n body: 'Let an AI agent read and edit this space through the same rules you do.',\n path: 'agents',\n icon: 'fas fa-robot',\n tone: 'blue'\n }\n];\n\nconst guideCard = (guide: Guide): ElementSpec =>\n link({\n id: guide.id,\n href: `${DOCS}/${guide.path}`,\n mode: 'external',\n target: 'blank',\n class: card,\n children: [\n container({\n class: cardHead,\n children: [\n container({ class: [tile, tones[guide.tone]], children: [fontAwesome({ icon: guide.icon })] }),\n fontAwesome({ icon: 'fas fa-arrow-right', class: cardArrow })\n ]\n }),\n heading({\n id: `${guide.id}-title`,\n content: guide.title,\n subType: 'h3',\n css: { 'font-size': '17px', 'font-weight': '600', 'margin-top': '4px', 'margin-bottom': '0px' }\n }),\n paragraph({\n content: guide.body,\n css: {\n color: 'var(--muted)',\n 'font-size': '14px',\n 'line-height': '1.6',\n 'margin-top': '0px',\n 'margin-bottom': '0px'\n }\n })\n ]\n });\n\n// ── The page ───────────────────────────────────────────────────────────────────────────────────────────────────\n\nconst topBar = container({\n id: 'top-bar',\n class: [shell, topBarBand],\n children: [\n link({\n id: 'brand',\n href: 'https://plitzi.com',\n mode: 'external',\n target: 'blank',\n class: navLink,\n children: [\n image({ src: 'https://cdn.plitzi.com/resources/img/favicon.svg', css: { width: '24px', height: '24px' } }),\n text('Plitzi', { css: { color: 'var(--foreground)', 'font-size': '16px', 'font-weight': '700' } })\n ]\n }),\n container({\n id: 'top-actions',\n css: { display: 'flex', 'align-items': 'center', gap: '8px' },\n children: [\n link({\n id: 'top-docs',\n href: DOCS,\n mode: 'external',\n target: 'blank',\n class: navLink,\n children: [text('Docs')]\n }),\n themeToggle({ id: 'theme', class: iconButton })\n ]\n })\n ]\n});\n\nconst heroEyebrow = container({\n id: 'hero-eyebrow',\n css: {\n display: 'flex',\n 'align-items': 'center',\n gap: '8px',\n 'padding-top': '6px',\n 'padding-bottom': '6px',\n 'padding-left': '12px',\n 'padding-right': '12px',\n 'border-radius': '999px',\n 'border-width': '1px',\n 'border-style': 'solid',\n 'border-color': 'var(--border)',\n 'background-color': 'var(--card)',\n 'font-size': '13px',\n 'font-weight': '500'\n },\n children: [\n container({\n css: { width: '8px', height: '8px', 'border-radius': '999px', 'background-color': 'var(--tint-emerald)' }\n }),\n text('Your new space', { css: { color: 'var(--muted)' } })\n ]\n});\n\nconst heroTitle = heading({\n id: 'hero-title',\n content: 'Welcome to Plitzi',\n subType: 'h1',\n css: {\n desktop: {\n 'font-size': '64px',\n 'font-weight': '700',\n 'letter-spacing': '-0.03em',\n 'line-height': '1.05',\n 'text-align': 'center',\n 'margin-top': '0px',\n 'margin-bottom': '0px'\n },\n tablet: { 'font-size': '48px' },\n mobile: { 'font-size': '38px' }\n }\n});\n\nconst heroLede = paragraph({\n id: 'hero-lede',\n content:\n 'This page is where your space starts. Change it in the builder, in code, or by asking an agent — ' +\n 'and when you want to know how something works, the guides below go straight to it.',\n css: {\n desktop: {\n color: 'var(--muted)',\n 'font-size': '18px',\n 'line-height': '1.6',\n 'text-align': 'center',\n 'max-width': '620px',\n 'margin-top': '0px',\n 'margin-bottom': '0px'\n },\n mobile: { 'font-size': '16px' }\n }\n});\n\nconst heroActions = container({\n id: 'hero-actions',\n css: {\n desktop: {\n display: 'flex',\n 'align-items': 'center',\n 'justify-content': 'center',\n gap: '12px',\n 'margin-top': '8px'\n },\n mobile: { 'flex-direction': 'column', 'align-items': 'stretch', width: '100%' }\n },\n children: [\n link({\n id: 'cta-docs',\n href: DOCS,\n mode: 'external',\n target: 'blank',\n class: button,\n variant: 'primary',\n children: [text('Read the docs'), fontAwesome({ icon: 'fas fa-arrow-right' })]\n }),\n link({\n id: 'cta-quickstart',\n href: `${DOCS}/quickstart`,\n mode: 'external',\n target: 'blank',\n class: button,\n children: [fontAwesome({ icon: 'fas fa-terminal' }), text('Quickstart')]\n })\n ]\n});\n\nexport const space: SpaceSpec = {\n name: 'New space',\n permanentUrl: 'new-space',\n mode: 'desktop-first',\n theme: { default: 'system', schemes: ['light', 'dark'] },\n /**\n * Every colour the page uses, per scheme.\n *\n * `default` is what a browser with no preference gets. Nothing above names a colour directly — they are all\n * `var(--…)` — so switching the palette here re-themes the whole page, in both schemes, without touching a rule.\n */\n variables: {\n color: {\n background: { light: '#fbfbfd', dark: '#09090b', default: '#fbfbfd' },\n foreground: { light: '#17171c', dark: '#fafafa', default: '#17171c' },\n muted: { light: '#5f5f6e', dark: '#a1a1aa', default: '#5f5f6e' },\n card: { light: '#ffffff', dark: '#111115', default: '#ffffff' },\n border: { light: '#e6e6ee', dark: '#27272d', default: '#e6e6ee' },\n primary: { light: '#5b3df5', dark: '#7c66ff', default: '#5b3df5' },\n 'primary-hover': { light: '#4a2de0', dark: '#9180ff', default: '#4a2de0' },\n 'primary-foreground': { light: '#ffffff', dark: '#ffffff', default: '#ffffff' },\n glow: { light: 'rgba(91, 61, 245, 0.16)', dark: 'rgba(124, 102, 255, 0.24)', default: 'rgba(91, 61, 245, 0.16)' },\n grid: { light: '#0000000a', dark: '#ffffff0a', default: '#0000000a' },\n 'tint-violet': { light: '#5b3df5', dark: '#b7a6ff', default: '#5b3df5' },\n 'tint-violet-bg': { light: '#efecfe', dark: '#1c1836', default: '#efecfe' },\n 'tint-cyan': { light: '#0e7490', dark: '#67d8ef', default: '#0e7490' },\n 'tint-cyan-bg': { light: '#e0f5fa', dark: '#0c2a33', default: '#e0f5fa' },\n 'tint-amber': { light: '#a45b00', dark: '#f5c169', default: '#a45b00' },\n 'tint-amber-bg': { light: '#fcf0dc', dark: '#2e2314', default: '#fcf0dc' },\n 'tint-rose': { light: '#c2255c', dark: '#f994bc', default: '#c2255c' },\n 'tint-rose-bg': { light: '#fce8f0', dark: '#331623', default: '#fce8f0' },\n 'tint-emerald': { light: '#0f7b55', dark: '#64d6a6', default: '#0f7b55' },\n 'tint-emerald-bg': { light: '#e0f6ee', dark: '#0e2a21', default: '#e0f6ee' },\n 'tint-blue': { light: '#2159c4', dark: '#8ab0f7', default: '#2159c4' },\n 'tint-blue-bg': { light: '#e6edfc', dark: '#13203c', default: '#e6edfc' }\n },\n shadow: {\n 'shadow-sm': {\n light: '0 1px 2px rgba(12, 12, 20, 0.05)',\n dark: '0 1px 2px rgba(0, 0, 0, 0.5)',\n default: '0 1px 2px rgba(12, 12, 20, 0.05)'\n },\n 'shadow-md': {\n light: '0 1px 2px rgba(12, 12, 20, 0.06), 0 8px 20px -8px rgba(91, 61, 245, 0.45)',\n dark: '0 1px 2px rgba(0, 0, 0, 0.6), 0 8px 24px -8px rgba(124, 102, 255, 0.55)',\n default: '0 1px 2px rgba(12, 12, 20, 0.06), 0 8px 20px -8px rgba(91, 61, 245, 0.45)'\n },\n 'shadow-lg': {\n light: '0 2px 4px rgba(12, 12, 20, 0.05), 0 24px 48px -20px rgba(12, 12, 20, 0.25)',\n dark: '0 2px 4px rgba(0, 0, 0, 0.6), 0 28px 56px -22px rgba(0, 0, 0, 0.85)',\n default: '0 2px 4px rgba(12, 12, 20, 0.05), 0 24px 48px -20px rgba(12, 12, 20, 0.25)'\n }\n },\n custom: {\n 'font-sans':\n 'Geist, ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif'\n }\n },\n /** Loaded by the page itself: a face the space names here is the only one it ever fetches. */\n fonts: [\n {\n family: 'Geist',\n fallback: 'ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif',\n weights: [400, 500, 600, 700],\n styles: ['normal'],\n display: 'swap',\n preload: true,\n source: 'google'\n }\n ],\n /**\n * What text is, before any class touches it.\n *\n * Per element TYPE, so every heading and paragraph follows the palette without naming a colour — which is what\n * makes the dark scheme work: a hard-coded colour would win against the theme and leave black text on black.\n */\n elements: {\n page: { base: { 'font-family': 'var(--font-sans)' } },\n heading: { base: { color: 'var(--foreground)' } },\n text: { base: { color: 'inherit' } },\n paragraph: { base: { color: 'var(--foreground)' } },\n fontAwesome: { base: { color: 'inherit' } }\n },\n pages: [\n {\n id: 'home',\n name: 'Home',\n slug: '',\n isDefault: true,\n css: {\n 'flex-direction': 'column',\n position: 'relative',\n 'min-width': '100%',\n 'min-height': '100dvh',\n color: 'var(--foreground)',\n 'background-color': 'var(--background)',\n // A glow over the top of the page, in the palette's primary, so it follows the scheme like everything else.\n 'background-image': 'radial-gradient(60rem 32rem at 50% -8rem, var(--glow), transparent 70%)',\n 'background-repeat': 'no-repeat'\n },\n body: [\n container({ id: 'backdrop', class: backdrop }),\n topBar,\n container({\n id: 'hero',\n class: [shell, heroBand],\n children: [heroEyebrow, heroTitle, heroLede, heroActions]\n }),\n container({\n id: 'guides',\n class: [shell, guidesBand],\n children: [\n heading({\n id: 'guides-title',\n content: 'Where to go next',\n subType: 'h2',\n css: {\n 'font-size': '14px',\n 'font-weight': '600',\n color: 'var(--muted)',\n 'margin-top': '0px',\n 'margin-bottom': '0px'\n }\n }),\n container({\n id: 'cards',\n css: {\n desktop: { display: 'grid', 'grid-template-columns': 'repeat(3, minmax(0, 1fr))', gap: '16px' },\n tablet: { 'grid-template-columns': 'repeat(2, minmax(0, 1fr))' },\n mobile: { 'grid-template-columns': 'minmax(0, 1fr)' }\n },\n children: GUIDES.map(guideCard)\n })\n ]\n }),\n container({\n id: 'footer',\n class: [shell, footerBand],\n children: [\n text('Made with Plitzi', { css: { color: 'var(--muted)', 'font-size': '13px' } }),\n link({\n id: 'footer-docs',\n href: DOCS,\n mode: 'external',\n target: 'blank',\n class: navLink,\n children: [text('plitzi.com/docs')]\n })\n ]\n })\n ]\n }\n ]\n};\n";
9840
11276
  //#endregion
9841
11277
  //#region src/spaces/index.ts
9842
11278
  /**
9843
- * The space a new space starts as — one page with a hero and four cards, not an empty document.
11279
+ * The space a new space starts as — one page with a hero and six guides into the docs, not an empty document.
9844
11280
  *
9845
11281
  * It lives here rather than in the seeds of whichever server happens to create spaces, because two unrelated
9846
11282
  * things need it and they must not drift: the platform's `POST /spaces`, and `plitzi create`, which scaffolds a
@@ -9857,8 +11293,8 @@ var blankSpaceSource = (options = {}) => {
9857
11293
  const portable = toPortableSource(plugin ? withPluginHost(spec_default, plugin) : spec_default);
9858
11294
  return name === void 0 ? portable : renameSpace(portable, name);
9859
11295
  };
9860
- /** The one line in the declaration a `custom` element is hung off — the hero, so it lands under the title. */
9861
- var PLUGIN_ANCHOR = "children: [heading({ id: 'hero-title', content: 'Welcome To Plitzi', subType: 'h1' })]";
11296
+ /** The one line in the declaration a `custom` element is hung off — the hero, so it lands under its buttons. */
11297
+ var PLUGIN_ANCHOR = "children: [heroEyebrow, heroTitle, heroLede, heroActions]";
9862
11298
  /**
9863
11299
  * The copy, with a slot for a component the receiver writes.
9864
11300
  *
@@ -9874,7 +11310,10 @@ var withPluginHost = (source, plugin) => {
9874
11310
  if (!source.includes(PLUGIN_ANCHOR)) throw new Error("blankSpaceSource: cannot host a plugin — the hero's children are not where they were. Update PLUGIN_ANCHOR in src/spaces/index.ts to match the declaration.");
9875
11311
  const settings = JSON.stringify(plugin.settings).replace(/\\/g, "\\\\").replace(/'/g, "\\'");
9876
11312
  const element = `children: [
9877
- heading({ id: 'hero-title', content: 'Welcome To Plitzi', subType: 'h1' }),
11313
+ heroEyebrow,
11314
+ heroTitle,
11315
+ heroLede,
11316
+ heroActions,
9878
11317
  /**
9879
11318
  * A component of YOUR OWN, rendered by the space.
9880
11319
  *
@@ -9886,7 +11325,7 @@ var withPluginHost = (source, plugin) => {
9886
11325
  id: '${plugin.id}',
9887
11326
  renderType: '${plugin.renderType}',
9888
11327
  settings: '${settings}',
9889
- css: { desktop: { 'margin-top': '24px', 'z-index': '1' } }
11328
+ css: { desktop: { 'margin-top': '24px' } }
9890
11329
  })
9891
11330
  ]`;
9892
11331
  return `import { custom } from '../../elements';\n${source.replace(PLUGIN_ANCHOR, element)}`;
@@ -9936,6 +11375,20 @@ var leadingImports = (lines) => {
9936
11375
  end
9937
11376
  };
9938
11377
  };
11378
+ /** The width a scaffolded project formats to. */
11379
+ var PRINT_WIDTH = 120;
11380
+ /**
11381
+ * One import of the package, laid out the way the receiving project's formatter would lay it out.
11382
+ *
11383
+ * Wrapped one name per line past the print width, because a copy that fails its own project's lint on the first
11384
+ * `npm run lint` tells the person who just created it that something is already wrong.
11385
+ */
11386
+ var importOf = (names, kind) => {
11387
+ if (names.size === 0) return "";
11388
+ const sorted = [...names].sort();
11389
+ const line = `import ${kind}{ ${sorted.join(", ")} } from '@plitzi/sdk-authoring';`;
11390
+ return line.length <= PRINT_WIDTH ? line : `import ${kind}{\n${sorted.map((name) => ` ${name}`).join(",\n")}\n} from '@plitzi/sdk-authoring';`;
11391
+ };
9939
11392
  var toPortableSource = (source) => {
9940
11393
  const lines = source.split("\n");
9941
11394
  const { statements, end } = leadingImports(lines);
@@ -9954,8 +11407,8 @@ var toPortableSource = (source) => {
9954
11407
  }
9955
11408
  const portable = [[
9956
11409
  ...kept,
9957
- values.size > 0 ? `import { ${[...values].sort().join(", ")} } from '@plitzi/sdk-authoring';` : "",
9958
- types.size > 0 ? `import type { ${[...types].sort().join(", ")} } from '@plitzi/sdk-authoring';` : ""
11410
+ importOf(values, ""),
11411
+ importOf(types, "type ")
9959
11412
  ].filter(Boolean).join("\n\n"), ...lines.slice(end)].join("\n");
9960
11413
  /**
9961
11414
  * Nothing relative survives, including from below the import block.
@@ -10160,88 +11613,19 @@ var a = (e, t, n, r = {}) => ({
10160
11613
  });
10161
11614
  var o$1 = (e, t, n = {}) => Object.fromEntries(Object.keys(e).map((r) => [r, a(r, e[r], t[r], n[r] ?? {})]));
10162
11615
  //#endregion
10163
- //#region ../sdk-shared/dist/authoring/elementCallbacks.mjs
10164
- var t = {
10165
- setState: {
10166
- title: "Update Element (set attribute / state)",
10167
- type: "callback",
10168
- strictParams: !0,
10169
- params: {
10170
- category: {
10171
- type: "select",
10172
- description: "What to change on the element: \"attribute\" sets one of its props (the common case — e.g. content, disabled); \"state\" sets element state (visibility or a style selector). REQUIRED — always set it.",
10173
- default: "attribute",
10174
- options: ["attribute", "state"],
10175
- required: !0
10176
- },
10177
- key: {
10178
- type: "text",
10179
- description: "The field to set. When category=\"attribute\", an attribute/prop key of THIS element (e.g. \"content\", \"disabled\"). When category=\"state\", \"visibility\" or \"styleSelectors.<selector>\". REQUIRED.",
10180
- required: !0
10181
- },
10182
- value: {
10183
- type: "scalar",
10184
- description: "The value to set — its type follows the target attribute: a real boolean (true/false) for a boolean attribute, a number for a numeric one, otherwise a string (the strings \"true\"/\"false\" also coerce). There is NO separate `type` param (that belongs to the global state setState, not this one). REQUIRED.",
10185
- when: (e) => !!e.category,
10186
- required: !0
10187
- },
10188
- revertOnFinish: {
10189
- type: "boolean",
10190
- description: "When true, this change is UNDONE automatically when the whole flow finishes. Use it for a TEMPORARY change (a \"loading…\" label, disabling a button while it works) instead of adding manual restore steps at the end of the flow.",
10191
- default: !1,
10192
- label: "Revert changes after interaction"
10193
- }
10194
- }
10195
- },
10196
- toggleState: {
10197
- title: "Toggle Element (flip attribute / state)",
10198
- type: "callback",
10199
- strictParams: !0,
10200
- params: {
10201
- category: {
10202
- type: "select",
10203
- description: "What to flip on the element: \"attribute\" flips one of its props (e.g. disabled); \"state\" flips element state (\"visibility\", or \"styleSelectors.<selector>\" for an expanded/collapsed look). REQUIRED.",
10204
- default: "state",
10205
- options: ["attribute", "state"],
10206
- required: !0
10207
- },
10208
- key: {
10209
- type: "text",
10210
- description: "The field to flip. When category=\"attribute\", an attribute/prop key of THIS element. When category=\"state\", \"visibility\" or \"styleSelectors.<selector>\". Anything not already true counts as false, so a field that has never been set flips ON first. REQUIRED.",
10211
- required: !0
10212
- },
10213
- revertOnFinish: {
10214
- type: "boolean",
10215
- description: "When true, the flip is UNDONE automatically when the whole flow finishes — a change that lasts only as long as the flow does.",
10216
- default: !1,
10217
- label: "Revert changes after interaction"
10218
- }
10219
- }
10220
- }
10221
- };
10222
- var n = (e) => Object.hasOwn(t, e) ? t[e] : void 0;
10223
- var r = (t, r) => {
10224
- let i = n(t);
10225
- return i ? {
10226
- known: !0,
10227
- params: s(r, i.params, i.strictParams)
10228
- } : {
10229
- known: !1,
10230
- params: r
10231
- };
10232
- };
10233
- //#endregion
10234
11616
  //#region src/index.ts
10235
- /**
10236
- * What a step may name in a document authored here.
10237
- *
10238
- * The catalogs are declared beside the code that implements each action, and the assembly half cannot read them on
10239
- * its own: `@plitzi/sdk-interactions` depends on `@plitzi/sdk-schema`, so the import would close a cycle. This
10240
- * package is the one place that holds both, which is why the check is composed here rather than there.
10241
- */
10242
- var STEP_VOCABULARY = {
10243
- globalCallbacks: BUILTIN_GLOBAL_CALLBACKS,
10244
- utilities: BUILTIN_UTILITIES
11617
+ /** Everything the composed surface knows about the built-in elements that the assembly half cannot import. */
11618
+ var ELEMENT_CATALOGS = {
11619
+ vocabulary: {
11620
+ globalCallbacks: BUILTIN_GLOBAL_CALLBACKS,
11621
+ utilities: BUILTIN_UTILITIES,
11622
+ triggers: elementTriggers,
11623
+ callbacks: elementCallbacks
11624
+ },
11625
+ sourceTypes: elementSourceTypes,
11626
+ ancestorTypes: elementAncestorTypes,
11627
+ slotNames: elementSlots,
11628
+ attributeNames: elementAttributeNames
10245
11629
  };
10246
11630
  /**
10247
11631
  * `authorSpace`, holding this SDK's own vocabularies.
@@ -10249,15 +11633,16 @@ var STEP_VOCABULARY = {
10249
11633
  * Deliberately shadows the one re-exported above — an explicit export wins over a star — so that everybody who
10250
11634
  * imports from this package gets both checks that need to know what this SDK ships.
10251
11635
  *
10252
- * **Flows.** A step naming a callback on the wrong module is refused; one naming an action no built-in source
10253
- * declares comes back in `warnings`, since a plugin is free to register a module this process cannot see.
11636
+ * **Flows.** A step naming a callback on the wrong module is refused, and so is a flow starting on a trigger its
11637
+ * built-in element never fires, or an element callback aimed at a built-in element that does not answer to it; one
11638
+ * naming an action no built-in source declares comes back in `warnings`, since a plugin is free to register a
11639
+ * module this process cannot see.
10254
11640
  *
10255
11641
  * **Bindings.** A source may name the element alone and the prefix it publishes under is filled in — which
10256
11642
  * is the half an author cannot see, and is not always the element's own type.
10257
11643
  */
10258
11644
  var authorSpace = (spec, options = {}) => authorSpace$1(spec, {
10259
- vocabulary: STEP_VOCABULARY,
10260
- sourceTypes: elementSourceTypes,
11645
+ ...ELEMENT_CATALOGS,
10261
11646
  ...options
10262
11647
  });
10263
11648
  /**
@@ -10278,8 +11663,7 @@ var validateSpace = (space, options = {}) => validateSpace$1(space, {
10278
11663
  * stayed behind. Those are the assembly half's; what this adds is the catalog that tells a real source from a typo.
10279
11664
  */
10280
11665
  var authorTemplate = (spec, options = {}) => authorTemplate$1(spec, {
10281
- vocabulary: STEP_VOCABULARY,
10282
- sourceTypes: elementSourceTypes,
11666
+ ...ELEMENT_CATALOGS,
10283
11667
  ...options
10284
11668
  });
10285
11669
  /** `validateTemplate`, holding this SDK's own source catalog — for a manifest authored elsewhere. */
@@ -10288,4 +11672,4 @@ var validateTemplate = (template, options = {}) => validateTemplate$1(template,
10288
11672
  ...options
10289
11673
  });
10290
11674
  //#endregion
10291
- export { BREAKPOINTS, t as BUILTIN_ELEMENT_CALLBACKS, BUILTIN_GLOBAL_CALLBACKS, BUILTIN_TRANSFORMERS, BUILTIN_UTILITIES, ELEMENT_FIELDS, GLOBAL_SOURCES, SCHEMA_SETTINGS, SPACE_FIELDS, STYLE_STATES, addNotification, apiContainer, appendState, applyBuiltinCallback, r as applyElementCallback, applyUtility, assertSpaceValid, assertTemplateValid, authLogin, authLogout, authRefreshDetails, authorBinding, authorFlow, authorFlows, authorSpace, authorTemplate, blankSpace, blankSpaceSource, space as blankSpaceSpec, blockHtml, blockJsx, buildHandles, button, cancelServerAction, className, classNames, classRefs, clearState, column, compareSpaces, container, css, cssProperties, cssShorthands, custom, defaultAttributes, defaultLabel, defineAction, defineElement, delay, dialogContainer, digest, dropdown, dropdownPopup, element, elementAttributeNames, elementCatalog, e as elementDeclaration, elementSourceTypes, elementTypeNames, elementsFromManifest, expandShorthand, expandShorthandPatch, fontAwesome, form, formControl, n as getElementCallback, getGlobalCallback, getTransformer, getUtility, grid, groupBindings, heading, t$1 as hiddenParams, hiddenWhen, hostAction, image, o as invalidParams, invalidateQueries, isCssProperty, isCustomProperty, isRuleSetSpec, isStyleDeclaration, link, list, listItem, locate, markdown, n$1 as missingRequiredParams, modalContainer, moveState, named, navigate, nodeHtml, on, onClick, onFlowEnd, onFlowError, onFlowProgress, onLoad, onSubmit, pagination, paragraph, pathForSlug, s as reconcileParams, reference, reloadApi, removeState, resetForm, resolveSource, richText, row, runServerAction, sameBlocks, selectorFor, setState, shorthandLonghands, slugify, e$1 as spaceCallbacks, specFromSpace, specToSource, styles, suggestCssProperty, suggestTransformer, tabContainer, tabContainerBody, tabContainerHeader, tabContainerItem, text, themeToggle, toBindingSpecs, toBlocks, i as toBuilderParams, a as toInteractionCallback, o$1 as toInteractionCallbacks, toPortableSource, toResponsive, toggleElement, toggleInState, toggleState, transformerCatalog, twigTemplate, updateElement, validateSpace, validateTemplate, video, visibleWhen, webHook, when, whenFailed, whenSucceeded, withVisibility };
11675
+ export { BREAKPOINTS, t as BUILTIN_ELEMENT_CALLBACKS, BUILTIN_GLOBAL_CALLBACKS, BUILTIN_TRANSFORMERS, BUILTIN_UTILITIES, ELEMENT_FIELDS, GLOBAL_SOURCES, SCHEMA_SETTINGS, SPACE_FIELDS, STYLE_STATES, activeOn, addNotification, apiContainer, appendState, applyBuiltinCallback, r as applyElementCallback, applyUtility, assertSpaceValid, assertTemplateValid, authLogin, authLogout, authRefreshDetails, authorBinding, authorFlow, authorFlows, authorSpace, authorTemplate, blankSpace, blankSpaceSource, space as blankSpaceSpec, blockHtml, blockJsx, buildHandles, button, cancelServerAction, className, classNames, classRefs, clearState, closeDialog, closeModal, column, compareSpaces, container, css, cssProperties, cssShorthands, custom, defaultAttributes, defaultLabel, defineAction, defineElement, delay, dialogContainer, digest, dropdown, dropdownPopup, element, elementAncestorTypes, elementAttributeNames, elementCallbacks, elementCatalog, e as elementDeclaration, elementSlots, elementSourceTypes, elementTriggers, elementTypeNames, elementsFromManifest, expandShorthand, expandShorthandPatch, fontAwesome, form, formControl, n as getElementCallback, getGlobalCallback, getTransformer, getUtility, grid, groupBindings, hasVisibilityBinding, heading, t$1 as hiddenParams, hiddenWhen, hostAction, image, o as invalidParams, invalidateQueries, isCssProperty, isCustomProperty, isRuleSetSpec, isStyleDeclaration, link, list, listItem, locate, markdown, n$1 as missingRequiredParams, modalContainer, moveState, named, navigate, nodeHtml, on, onClick, onFlowEnd, onFlowError, onFlowProgress, onLoad, onPageLoad, onSubmit, openDialog, openModal, pagination, paragraph, pathForSlug, s as reconcileParams, reference, reloadApi, removeState, resetForm, resolveSource, richText, row, runServerAction, sameBlocks, selectorFor, setState, shorthandLonghands, slugify, e$1 as spaceCallbacks, specFromSpace, specToSource, styles, suggestCssProperty, suggestTransformer, tabContainer, tabContainerBody, tabContainerHeader, tabContainerItem, text, themeToggle, toBindingSpecs, toBlocks, i as toBuilderParams, a as toInteractionCallback, o$1 as toInteractionCallbacks, toPortableSource, toResponsive, toggleElement, toggleInState, toggleState, transformerCatalog, twigTemplate, typeTriggerDefinitions, updateElement, validateSpace, validateTemplate, variantFrom, video, visibleWhen, webHook, when, whenFailed, whenSucceeded, withVisibility };