intelligent-system-design-language 0.3.25 → 0.3.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/out/_backgrounds.scss +17 -17
  2. package/out/_isdlStyles.scss +31 -0
  3. package/out/_vuetifyOverrides.scss +23 -1
  4. package/out/cli/cli-util.js +13 -0
  5. package/out/cli/cli-util.js.map +1 -1
  6. package/out/cli/components/_backgrounds.scss +17 -17
  7. package/out/cli/components/_isdlStyles.scss +31 -0
  8. package/out/cli/components/_vuetifyOverrides.scss +23 -1
  9. package/out/cli/components/css-generator.js +259 -0
  10. package/out/cli/components/css-generator.js.map +1 -1
  11. package/out/cli/components/datamodel-generator.js +8 -8
  12. package/out/cli/components/datamodel-generator.js.map +1 -1
  13. package/out/cli/components/init-hook-generator.js +11 -11
  14. package/out/cli/components/init-hook-generator.js.map +1 -1
  15. package/out/cli/components/language-generator.js +9 -1
  16. package/out/cli/components/language-generator.js.map +1 -1
  17. package/out/cli/components/method-generator.js +8 -7
  18. package/out/cli/components/method-generator.js.map +1 -1
  19. package/out/cli/components/utils.js +18 -12
  20. package/out/cli/components/utils.js.map +1 -1
  21. package/out/cli/components/vue/vue-action-component-generator.js +18 -9
  22. package/out/cli/components/vue/vue-action-component-generator.js.map +1 -1
  23. package/out/cli/components/vue/vue-datatable2-component-generator.js +45 -34
  24. package/out/cli/components/vue/vue-datatable2-component-generator.js.map +1 -1
  25. package/out/cli/components/vue/vue-generator.js +11 -7
  26. package/out/cli/components/vue/vue-generator.js.map +1 -1
  27. package/out/cli/components/vue/vue-prompt-generator.js +4 -4
  28. package/out/cli/components/vue/vue-prompt-generator.js.map +1 -1
  29. package/out/cli/components/vue/vue-sheet-application-generator.js +668 -546
  30. package/out/cli/components/vue/vue-sheet-application-generator.js.map +1 -1
  31. package/out/cli/generator.js +9 -3
  32. package/out/cli/generator.js.map +1 -1
  33. package/out/extension/main.cjs +2851 -790
  34. package/out/extension/main.cjs.map +3 -3
  35. package/out/extension/main.js +10 -3
  36. package/out/extension/main.js.map +1 -1
  37. package/out/extension/package.json +1 -1
  38. package/out/language/generated/ast.js +353 -9
  39. package/out/language/generated/ast.js.map +1 -1
  40. package/out/language/generated/grammar.js +2479 -796
  41. package/out/language/generated/grammar.js.map +1 -1
  42. package/out/language/intelligent-system-design-language-validator.js +87 -2
  43. package/out/language/intelligent-system-design-language-validator.js.map +1 -1
  44. package/out/language/isdl-parser-error-message-provider.js +18 -5
  45. package/out/language/isdl-parser-error-message-provider.js.map +1 -1
  46. package/out/language/main.cjs +2830 -787
  47. package/out/language/main.cjs.map +3 -3
  48. package/out/package.json +1 -1
  49. package/out/styles.scss +33 -4
  50. package/out/test/parsing/table-params.test.js +61 -0
  51. package/out/test/parsing/table-params.test.js.map +1 -0
  52. package/out/test/validating/theme.test.js +120 -0
  53. package/out/test/validating/theme.test.js.map +1 -0
  54. package/package.json +1 -1
@@ -1,17 +1,46 @@
1
1
  import * as path from 'node:path';
2
2
  import * as fs from 'node:fs';
3
3
  import { expandToNode, joinToNode, toString } from 'langium/generate';
4
- import { isAccess, isAction, isActor, isAttributeExp, isAttributeParamMod, isAttributeRollParam, isAttributeFunctionParam, isAttributeStyleParam, isBackgroundParam, isBooleanExp, isBooleanParamValue, isChoiceCustomProperty, isChoiceStringValue, isColorParam, isColumn, isDateExp, isDateTimeExp, isDiceField, isDiceFields, isDieChoicesParam, isDieNoneParam, isDieField, isDocumentChoiceExp, isDocumentChoicesExp, isEntry, isHtmlExp, isIconParam, isImageParam, isLabelParam, isMacroField, isMeasuredTemplateField, isDamageBonusesField, isDamageResistancesField, isPinnedField, isMoneyField, isDamageTrackExp, isDamageTrackTypesParam, isRollVisualizerField, isMethodBlock, isNumberExp, isNumberParamMax, isNumberParamMin, isNumberParamValue, isNumberParamCalculator, isPage, isPaperDollExp, isParentPropertyRefChoiceParam, isParentPropertyRefExp, isSelfPropertyRefExp, isProperty, isResourceExp, isRow, isSection, isSegmentsParameter, isSingleDocumentExp, isSizeParam, isStatusProperty, isStringChoiceField, isDamageTypeChoiceField, isStringChoicesField, isStringExp, isStringExtendedChoice, isStringParamChoices, isStringParamValue, isTableField, isTimeExp, isTrackerExp, isTrackerStyleParameter, isVisibilityParam, isInventoryField, isInventorySlotsParam, isInventoryRowsParam, isInventoryColumnsParam, isInventorySlotSizeParam, isInventoryQuantityParam, isInventoryMoneyParam, isInventorySumParam, isInventorySumMaxParam, isInventorySortParam, isInventoryEmptySlotsParam, isInventorySummaryParam, isWhereParam, isGlobalParam } from "../../../language/generated/ast.js";
4
+ import { isAccess, isAction, isActor, isConfigFlag, isTheme, isThemeFieldParam, isThemePrimaryParam, isThemeSecondaryParam, isThemeTertiaryParam, isAttributeExp, isAttributeParamMod, isAttributeRollParam, isAttributeFunctionParam, isAttributeStyleParam, isBackgroundParam, isBooleanExp, isBooleanParamValue, isChoiceCustomProperty, isChoiceStringValue, isColorParam, isColumn, isDateExp, isDateTimeExp, isDiceField, isDiceFields, isDieChoicesParam, isDieNoneParam, isDieField, isDocumentChoiceExp, isDocumentChoicesExp, isEntry, isHtmlExp, isIconParam, isImageParam, isLabelParam, isMacroField, isMeasuredTemplateField, isDamageBonusesField, isDamageResistancesField, isPinnedField, isMoneyField, isDamageTrackExp, isDamageTrackTypesParam, isRollVisualizerField, isMethodBlock, isNumberExp, isNumberParamMax, isNumberParamMin, isNumberParamValue, isNumberParamCalculator, isPage, isPaperDollExp, isParentPropertyRefChoiceParam, isParentPropertyRefExp, isSelfPropertyRefExp, isProperty, isResourceExp, isRow, isSection, isSegmentsParameter, isSingleDocumentExp, isSizeParam, isStatusProperty, isStringChoiceField, isDamageTypeChoiceField, isStringChoicesField, isStringExp, isStringExtendedChoice, isStringParamChoices, isStringParamValue, isTableField, isTimeExp, isTrackerExp, isTrackerStyleParameter, isVisibilityParam, isInventoryField, isInventorySlotsParam, isInventoryRowsParam, isInventoryColumnsParam, isInventorySlotSizeParam, isInventoryQuantityParam, isInventoryMoneyParam, isInventorySumParam, isInventorySumMaxParam, isInventorySortParam, isInventoryEmptySlotsParam, isInventorySummaryParam, isWhereParam, isGlobalParam } from "../../../language/generated/ast.js";
5
5
  import { getAllOfType, getDocument, getSystemPath, globalGetAllOfType, toMachineIdentifier } from '../utils.js';
6
6
  import { AstUtils } from 'langium';
7
- import { generateActionComponent } from './vue-action-component-generator.js';
7
+ import { generateActionComponent, generateDocumentPromptApps } from './vue-action-component-generator.js';
8
8
  import { generatePinnedVuetifyDatatableComponent } from './vue-pinned-datatable-component-generator.js';
9
9
  // import {generateDocumentChoiceComponent} from './vue-document-choice-component-generator.js';
10
10
  import { generateDocumentChoicesComponent } from './base-components/vue-document-choices.js';
11
11
  import { translateBodyExpressionToJavascript, translateExpression, compileVisualizerFormula } from '../method-generator.js';
12
+ import { themeBlockToInlineStyle } from '../css-generator.js';
12
13
  import { humanize } from "inflection";
13
14
  import { generateVuetifyDatatableComponent } from "./vue-datatable2-component-generator.js";
14
15
  import { generateDocumentChoiceComponent } from "./base-components/vue-document-choice.js";
16
+ // --- Theme-derived color defaults -------------------------------------------
17
+ // The per-document primary/secondary/tertiary color pickers default to the
18
+ // system theme (`config { theme { primary/secondary/tertiary } }`) when set,
19
+ // otherwise to the built-in palette. `userColors = false` in config hides the
20
+ // picker entirely (art-directed systems whose look is fixed by the theme).
21
+ const DEFAULT_PRIMARY = '#1565c0';
22
+ const DEFAULT_SECONDARY = '#4db6ac';
23
+ const DEFAULT_TERTIARY = '#ffb74d';
24
+ function getThemeColorDefaults(entry) {
25
+ const theme = entry.config.body.find(isTheme);
26
+ let primary = DEFAULT_PRIMARY, secondary = DEFAULT_SECONDARY, tertiary = DEFAULT_TERTIARY;
27
+ if (theme) {
28
+ for (const param of theme.params) {
29
+ if (isThemePrimaryParam(param))
30
+ primary = param.value;
31
+ else if (isThemeSecondaryParam(param))
32
+ secondary = param.value;
33
+ else if (isThemeTertiaryParam(param))
34
+ tertiary = param.value;
35
+ }
36
+ }
37
+ return { primary, secondary, tertiary };
38
+ }
39
+ // `userColors = false` disables the per-document color pickers. Default is true.
40
+ function getUserColorsEnabled(entry) {
41
+ const flag = entry.config.body.find(x => isConfigFlag(x) && x.type === 'userColors');
42
+ return flag ? flag.value : true;
43
+ }
15
44
  export function generateDocumentVueComponent(entry, id, document, destination) {
16
45
  const type = isActor(document) ? 'actor' : 'item';
17
46
  const generatedFileDir = path.join(destination, "system", "templates", "vue", type, document.name.toLowerCase());
@@ -19,6 +48,9 @@ export function generateDocumentVueComponent(entry, id, document, destination) {
19
48
  if (!fs.existsSync(generatedFileDir)) {
20
49
  fs.mkdirSync(generatedFileDir, { recursive: true });
21
50
  }
51
+ // Generate prompt apps for every action AND function prompt in this document,
52
+ // unconditionally per document (covers documents with function-prompts but no actions).
53
+ generateDocumentPromptApps(entry, id, document, destination);
22
54
  const fileNode = expandToNode `
23
55
  ${generateVueComponentScript(entry, id, document, destination)}
24
56
  ${generateVueComponentTemplate(entry, id, document)}
@@ -465,15 +497,32 @@ function generateVueComponentScript(entry, id, document, destination) {
465
497
  function generateAttributeRollMethod(attribute) {
466
498
  const rollParam = attribute.params.find(isAttributeRollParam);
467
499
  if (rollParam) {
500
+ // A block-style `roll: { ... }` is a method body: it declares its own variables, runs its
501
+ // own logic, and creates its own `chat` cards. Emit those statements directly. An
502
+ // expression-style `roll: roll(...)` produces a single Roll value we wrap in a chat card.
503
+ // `system` is provided in scope so `self.X` (which compiles to bare `system.x`) and
504
+ // `success:` thresholds resolve, matching the function/action handler convention.
505
+ if (isMethodBlock(rollParam.roll)) {
506
+ return expandToNode `
507
+ const on${toMachineIdentifier(attribute.name)}AttributeRoll = async () => {
508
+ const context = {
509
+ object: document
510
+ };
511
+ let system = context.object.system;
512
+ ${translateExpression(entry, id, rollParam.roll, false, attribute)}
513
+ };
514
+ `;
515
+ }
468
516
  return expandToNode `
469
517
  const on${toMachineIdentifier(attribute.name)}AttributeRoll = async () => {
470
518
  const context = {
471
519
  object: document
472
520
  };
521
+ let system = context.object.system;
473
522
  const roll = ${translateExpression(entry, id, rollParam.roll, false, attribute)};
474
523
  // Create the chat message
475
524
  const ${attribute.name}Description = context.object.description ?? context.object.system.description;
476
- const ${attribute.name}Context = {
525
+ const ${attribute.name}Context = {
477
526
  cssClass: "${id} ${toMachineIdentifier(attribute.name)}",
478
527
  document: context.object,
479
528
  description: ${attribute.name}Description,
@@ -483,7 +532,7 @@ function generateVueComponentScript(entry, id, document, destination) {
483
532
  label: "${humanize(attribute.name)} Attribute Roll",
484
533
  value: roll,
485
534
  isRoll: true,
486
- wide: true,
535
+ wide: true,
487
536
  tooltip: await roll.getTooltip()
488
537
  }
489
538
  ],
@@ -516,6 +565,8 @@ function generateVueComponentScript(entry, id, document, destination) {
516
565
  }
517
566
  return expandToNode ``;
518
567
  }
568
+ const themeColors = getThemeColorDefaults(entry);
569
+ const userColorsEnabled = getUserColorsEnabled(entry);
519
570
  return expandToNode `
520
571
  <script setup>
521
572
  import { ref, watch, inject, computed, watchEffect } from "vue";
@@ -532,10 +583,37 @@ function generateVueComponentScript(entry, id, document, destination) {
532
583
  const props = defineProps(['context']);
533
584
 
534
585
  // Colors
586
+ // Defaults come from the system theme (theme primary/secondary/tertiary tokens);
587
+ // when the theme doesn't set them they fall back to the built-in palette. These feed
588
+ // the Vuetify :color props on fields. userColorsEnabled mirrors the userColors config.
589
+ const userColorsEnabled = ${userColorsEnabled};
590
+ const defaultPrimaryColor = '${themeColors.primary}';
591
+ const defaultSecondaryColor = '${themeColors.secondary}';
592
+ const defaultTertiaryColor = '${themeColors.tertiary}';
593
+
535
594
  let storedColors = game.settings.get('${id}', 'documentColorThemes');
536
- const primaryColor = ref(storedColors[document.uuid]?.primary ?? '#1565c0');
537
- const secondaryColor = ref(storedColors[document.uuid]?.secondary ?? '#4db6ac');
538
- const tertiaryColor = ref(storedColors[document.uuid]?.tertiary ?? '#ffb74d');
595
+ const documentColors = userColorsEnabled ? (storedColors[document.uuid] ?? {}) : {};
596
+ const primaryColor = ref(documentColors.primary ?? defaultPrimaryColor);
597
+ const secondaryColor = ref(documentColors.secondary ?? defaultSecondaryColor);
598
+ const tertiaryColor = ref(documentColors.tertiary ?? defaultTertiaryColor);
599
+
600
+ // Track which colors the user has explicitly chosen. Only an explicit choice is
601
+ // emitted as a CSS variable (below) so it can override the theme default; the ref
602
+ // defaults must NOT leak to --isdl-* or an unthemed sheet would gain a colored edge.
603
+ const primarySet = ref(documentColors.primary != null);
604
+ const secondarySet = ref(documentColors.secondary != null);
605
+ const tertiarySet = ref(documentColors.tertiary != null);
606
+
607
+ // User-chosen colors override the theme's --isdl-primary/secondary/tertiary for this
608
+ // document. Bound inline on <v-app>, which sits inside .${id}.vue-application, so it wins
609
+ // over the theme.css defaults for every descendant field. Keys are omitted unless chosen.
610
+ const userColorVars = computed(() => {
611
+ const vars = {};
612
+ if (primarySet.value) vars['--isdl-primary'] = primaryColor.value;
613
+ if (secondarySet.value) vars['--isdl-secondary'] = secondaryColor.value;
614
+ if (tertiarySet.value) vars['--isdl-tertiary'] = tertiaryColor.value;
615
+ return vars;
616
+ });
539
617
 
540
618
  const setupColors = () => {
541
619
  const colors = {
@@ -546,19 +624,28 @@ function generateVueComponentScript(entry, id, document, destination) {
546
624
  game.settings.set('${id}', 'documentColorThemes', { ...storedColors, [document.uuid]: colors });
547
625
  };
548
626
  const resetColors = () => {
549
- primaryColor.value = '#1565c0';
550
- secondaryColor.value = '#4db6ac';
551
- tertiaryColor.value = '#ffb74d';
552
- setupColors();
627
+ primaryColor.value = defaultPrimaryColor;
628
+ secondaryColor.value = defaultSecondaryColor;
629
+ tertiaryColor.value = defaultTertiaryColor;
630
+ primarySet.value = false;
631
+ secondarySet.value = false;
632
+ tertiarySet.value = false;
633
+ let updated = { ...storedColors };
634
+ delete updated[document.uuid];
635
+ storedColors = updated;
636
+ game.settings.set('${id}', 'documentColorThemes', updated);
553
637
  };
554
638
 
555
639
  watch(primaryColor, () => {
640
+ primarySet.value = true;
556
641
  setupColors();
557
642
  });
558
643
  watch(secondaryColor, () => {
644
+ secondarySet.value = true;
559
645
  setupColors();
560
646
  });
561
647
  watch(tertiaryColor, () => {
648
+ tertiarySet.value = true;
562
649
  setupColors();
563
650
  });
564
651
 
@@ -744,9 +831,10 @@ function generateVueComponentTemplate(entry, id, document) {
744
831
  const firstPageTables = document.body.filter(isTableField); // We explicitly only want top-level tables
745
832
  const firstPagePinned = document.body.filter(isPinnedField); // We explicitly only want top-level pinned fields
746
833
  const firstPageInventories = document.body.filter(isInventoryField); // We explicitly only want top-level inventories
834
+ const userColorsEnabled = getUserColorsEnabled(entry);
747
835
  return expandToNode `
748
836
  <template>
749
- <v-app>
837
+ <v-app :style="userColorVars">
750
838
  <!-- App Bar -->
751
839
  <v-app-bar :color="editModeRef ? 'amber-accent-3' : primaryColor" density="comfortable">
752
840
  <v-app-bar-nav-icon @click="drawer = !drawer"></v-app-bar-nav-icon>
@@ -776,7 +864,7 @@ function generateVueComponentTemplate(entry, id, document) {
776
864
  ${joinToNode(pages, generateNavListItem, { appendNewLineIfNotEmpty: true })}
777
865
  </v-tabs>
778
866
  <template v-slot:append>
779
- <div class="pa-2">
867
+ <div class="pa-2" ${userColorsEnabled ? '' : 'v-if="false"'}>
780
868
  <v-btn block @click="setupColors" :color="secondaryColor" prepend-icon="fa-solid fa-palette">
781
869
  Setup Colors
782
870
 
@@ -1071,11 +1159,16 @@ function generateVueComponentTemplate(entry, id, document) {
1071
1159
  `.appendNewLine();
1072
1160
  }
1073
1161
  function generateElement(element, isTopLevel = false) {
1074
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8;
1162
+ var _a;
1163
+ // A layout container's `theme: { ... }` compiles to an inline `style="..."` of ACTUAL
1164
+ // CSS (not `--isdl-*` vars, which would inherit and leak sizing into nested children).
1165
+ // Section paints the inner <v-card> (border/bg/text live there); row/col paint themselves.
1166
+ const layoutStyle = themeBlockToInlineStyle((_a = element.params) === null || _a === void 0 ? void 0 : _a.find(isThemeFieldParam));
1167
+ const styleAttr = layoutStyle.length > 0 ? ` style="${layoutStyle}"` : '';
1075
1168
  if (isSection(element)) {
1076
1169
  return expandToNode `
1077
- <v-col class="section">
1078
- <v-card variant="outlined" elevation="4">
1170
+ <v-col class="section isdl-section isdl-section-${element.name.toLowerCase()}">
1171
+ <v-card variant="outlined" elevation="4"${styleAttr}>
1079
1172
  <v-card-title>{{ game.i18n.localize('${document.name}.${element.name}') }}</v-card-title>
1080
1173
 
1081
1174
  <v-card-text>
@@ -1089,14 +1182,14 @@ function generateVueComponentTemplate(entry, id, document) {
1089
1182
  }
1090
1183
  if (isRow(element)) {
1091
1184
  return expandToNode `
1092
- <v-row dense>
1185
+ <v-row dense class="isdl-row"${styleAttr}>
1093
1186
  ${joinToNode(element.body, element => generateElement(element), { appendNewLineIfNotEmpty: true })}
1094
1187
  </v-row>
1095
1188
  `;
1096
1189
  }
1097
1190
  if (isColumn(element)) {
1098
1191
  return expandToNode `
1099
- <v-col>
1192
+ <v-col class="isdl-column"${styleAttr}>
1100
1193
  ${joinToNode(element.body, element => generateElement(element), { appendNewLineIfNotEmpty: true })}
1101
1194
  </v-col>
1102
1195
  `;
@@ -1130,9 +1223,15 @@ function generateVueComponentTemplate(entry, id, document) {
1130
1223
  const standardParamsFragment = colorParam ? `:disabled="isDisabled('${element.name.toLowerCase()}')" v-if="!isHidden('${element.name.toLowerCase()}')" color="${colorParam.value}"` : `:disabled="isDisabled('${element.name.toLowerCase()}')" v-if="!isHidden('${element.name.toLowerCase()}')"`;
1131
1224
  const systemPath = getSystemPath(element, [], undefined, false);
1132
1225
  const entry = AstUtils.getContainerOfType(element, isEntry);
1133
- if (isRollVisualizerField(element)) {
1134
- const { formula, data } = compileVisualizerFormula(entry, id, element);
1135
- return expandToNode `
1226
+ // Single choke point for the theme marker: render the field by type, then stamp the
1227
+ // universal `isdl-field` (+ per-field `isdl-field-<name>`) class onto its <i-...> root.
1228
+ // Every field branch returns an <i-...> root, so this reaches ALL field types -- no
1229
+ // per-branch allowlist to drift out of sync as new field types are added.
1230
+ const fieldComponent = (() => {
1231
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8;
1232
+ if (isRollVisualizerField(element)) {
1233
+ const { formula, data } = compileVisualizerFormula(entry, id, element);
1234
+ return expandToNode `
1136
1235
  <i-roll-visualizer
1137
1236
  :context="context"
1138
1237
  label="${label}"
@@ -1144,80 +1243,80 @@ function generateVueComponentTemplate(entry, id, document) {
1144
1243
  v-if="!isHidden('${element.name.toLowerCase()}')">
1145
1244
  </i-roll-visualizer>
1146
1245
  `;
1147
- }
1148
- if (isParentPropertyRefExp(element)) {
1149
- const choicesParam = element.params.find(p => isParentPropertyRefChoiceParam(p));
1150
- let allChoices = [];
1151
- switch (element.propertyType) {
1152
- case "attribute":
1153
- allChoices = globalGetAllOfType(entry, isAttributeExp);
1154
- break;
1155
- case "resource":
1156
- allChoices = globalGetAllOfType(entry, isResourceExp);
1157
- break;
1158
- case "number":
1159
- allChoices = globalGetAllOfType(entry, isNumberExp);
1160
- break;
1161
- case "boolean":
1162
- allChoices = globalGetAllOfType(entry, isBooleanExp);
1163
- break;
1164
- case "date":
1165
- allChoices = globalGetAllOfType(entry, isDateExp);
1166
- break;
1167
- case "time":
1168
- allChoices = globalGetAllOfType(entry, isTimeExp);
1169
- break;
1170
- case "datetime":
1171
- allChoices = globalGetAllOfType(entry, isDateTimeExp);
1172
- break;
1173
- case "die":
1174
- allChoices = globalGetAllOfType(entry, isDieField);
1175
- break;
1176
- case "dice":
1177
- allChoices = globalGetAllOfType(entry, isDiceField);
1178
- break;
1179
- case "string":
1180
- allChoices = globalGetAllOfType(entry, isStringExp);
1181
- break;
1182
- case "tracker":
1183
- allChoices = globalGetAllOfType(entry, isTrackerExp);
1184
- break;
1185
- case "choice":
1186
- allChoices = globalGetAllOfType(entry, isDocumentChoiceExp);
1187
- break;
1188
- case "paperdoll":
1189
- allChoices = globalGetAllOfType(entry, isPaperDollExp);
1190
- break;
1191
- case "html":
1192
- allChoices = globalGetAllOfType(entry, isHtmlExp);
1193
- break;
1194
- //default: console.error("Unsupported parent property type: " + element.propertyType); break;
1195
1246
  }
1196
- let refChoices = allChoices.map(x => {
1197
- let parentDocument = getDocument(x);
1198
- if (choicesParam && choicesParam.choices.length > 0) {
1199
- if (!choicesParam.choices.find(y => {
1200
- var _a, _b;
1201
- const documentNameMatches = ((_a = y.document.ref) === null || _a === void 0 ? void 0 : _a.name.toLowerCase()) == (parentDocument === null || parentDocument === void 0 ? void 0 : parentDocument.name.toLowerCase());
1202
- if (y.property != undefined) {
1203
- const propertyNameMatches = ((_b = y.property.ref) === null || _b === void 0 ? void 0 : _b.name.toLowerCase()) == x.name.toLowerCase();
1204
- return documentNameMatches && propertyNameMatches;
1247
+ if (isParentPropertyRefExp(element)) {
1248
+ const choicesParam = element.params.find(p => isParentPropertyRefChoiceParam(p));
1249
+ let allChoices = [];
1250
+ switch (element.propertyType) {
1251
+ case "attribute":
1252
+ allChoices = globalGetAllOfType(entry, isAttributeExp);
1253
+ break;
1254
+ case "resource":
1255
+ allChoices = globalGetAllOfType(entry, isResourceExp);
1256
+ break;
1257
+ case "number":
1258
+ allChoices = globalGetAllOfType(entry, isNumberExp);
1259
+ break;
1260
+ case "boolean":
1261
+ allChoices = globalGetAllOfType(entry, isBooleanExp);
1262
+ break;
1263
+ case "date":
1264
+ allChoices = globalGetAllOfType(entry, isDateExp);
1265
+ break;
1266
+ case "time":
1267
+ allChoices = globalGetAllOfType(entry, isTimeExp);
1268
+ break;
1269
+ case "datetime":
1270
+ allChoices = globalGetAllOfType(entry, isDateTimeExp);
1271
+ break;
1272
+ case "die":
1273
+ allChoices = globalGetAllOfType(entry, isDieField);
1274
+ break;
1275
+ case "dice":
1276
+ allChoices = globalGetAllOfType(entry, isDiceField);
1277
+ break;
1278
+ case "string":
1279
+ allChoices = globalGetAllOfType(entry, isStringExp);
1280
+ break;
1281
+ case "tracker":
1282
+ allChoices = globalGetAllOfType(entry, isTrackerExp);
1283
+ break;
1284
+ case "choice":
1285
+ allChoices = globalGetAllOfType(entry, isDocumentChoiceExp);
1286
+ break;
1287
+ case "paperdoll":
1288
+ allChoices = globalGetAllOfType(entry, isPaperDollExp);
1289
+ break;
1290
+ case "html":
1291
+ allChoices = globalGetAllOfType(entry, isHtmlExp);
1292
+ break;
1293
+ //default: console.error("Unsupported parent property type: " + element.propertyType); break;
1294
+ }
1295
+ let refChoices = allChoices.map(x => {
1296
+ let parentDocument = getDocument(x);
1297
+ if (choicesParam && choicesParam.choices.length > 0) {
1298
+ if (!choicesParam.choices.find(y => {
1299
+ var _a, _b;
1300
+ const documentNameMatches = ((_a = y.document.ref) === null || _a === void 0 ? void 0 : _a.name.toLowerCase()) == (parentDocument === null || parentDocument === void 0 ? void 0 : parentDocument.name.toLowerCase());
1301
+ if (y.property != undefined) {
1302
+ const propertyNameMatches = ((_b = y.property.ref) === null || _b === void 0 ? void 0 : _b.name.toLowerCase()) == x.name.toLowerCase();
1303
+ return documentNameMatches && propertyNameMatches;
1304
+ }
1305
+ // Just check document name
1306
+ return documentNameMatches;
1307
+ })) {
1308
+ return undefined;
1205
1309
  }
1206
- // Just check document name
1207
- return documentNameMatches;
1208
- })) {
1209
- return undefined;
1210
1310
  }
1211
- }
1212
- return {
1213
- path: `system.${x.name.toLowerCase()}`,
1214
- parent: parentDocument === null || parentDocument === void 0 ? void 0 : parentDocument.name,
1215
- name: x.name
1216
- };
1217
- });
1218
- refChoices = refChoices.filter(x => x != undefined);
1219
- const choices = refChoices.map(c => `{ label: '${c === null || c === void 0 ? void 0 : c.parent} - ${c === null || c === void 0 ? void 0 : c.name}', value: '${c === null || c === void 0 ? void 0 : c.path}' }`).join(", ");
1220
- return expandToNode `
1311
+ return {
1312
+ path: `system.${x.name.toLowerCase()}`,
1313
+ parent: parentDocument === null || parentDocument === void 0 ? void 0 : parentDocument.name,
1314
+ name: x.name
1315
+ };
1316
+ });
1317
+ refChoices = refChoices.filter(x => x != undefined);
1318
+ const choices = refChoices.map(c => `{ label: '${c === null || c === void 0 ? void 0 : c.parent} - ${c === null || c === void 0 ? void 0 : c.name}', value: '${c === null || c === void 0 ? void 0 : c.path}' }`).join(", ");
1319
+ return expandToNode `
1221
1320
  <i-parent-property-reference
1222
1321
  :context="context"
1223
1322
  label="${label}"
@@ -1227,74 +1326,74 @@ function generateVueComponentTemplate(entry, id, document) {
1227
1326
  ${standardParamsFragment}>
1228
1327
  </i-parent-property-reference>
1229
1328
  `;
1230
- }
1231
- if (isSelfPropertyRefExp(element)) {
1232
- const choicesParam = element.params.find(p => p.$type === 'SelfPropertyRefChoiceParam');
1233
- let allChoices = [];
1234
- // Get the current document
1235
- const currentDocument = getDocument(element);
1236
- if (!currentDocument) {
1237
- return expandToNode `
1329
+ }
1330
+ if (isSelfPropertyRefExp(element)) {
1331
+ const choicesParam = element.params.find(p => p.$type === 'SelfPropertyRefChoiceParam');
1332
+ let allChoices = [];
1333
+ // Get the current document
1334
+ const currentDocument = getDocument(element);
1335
+ if (!currentDocument) {
1336
+ return expandToNode `
1238
1337
  <div class="error">Self property reference error: Cannot find current document</div>
1239
1338
  `;
1240
- }
1241
- switch (element.propertyType) {
1242
- case "attribute":
1243
- allChoices = getAllOfType(currentDocument.body, isAttributeExp);
1244
- break;
1245
- case "resource":
1246
- allChoices = getAllOfType(currentDocument.body, isResourceExp);
1247
- break;
1248
- case "number":
1249
- allChoices = getAllOfType(currentDocument.body, isNumberExp);
1250
- break;
1251
- case "boolean":
1252
- allChoices = getAllOfType(currentDocument.body, isBooleanExp);
1253
- break;
1254
- case "date":
1255
- allChoices = getAllOfType(currentDocument.body, isDateExp);
1256
- break;
1257
- case "time":
1258
- allChoices = getAllOfType(currentDocument.body, isTimeExp);
1259
- break;
1260
- case "datetime":
1261
- allChoices = getAllOfType(currentDocument.body, isDateTimeExp);
1262
- break;
1263
- case "die":
1264
- allChoices = getAllOfType(currentDocument.body, isDieField);
1265
- break;
1266
- case "dice":
1267
- allChoices = getAllOfType(currentDocument.body, isDiceField);
1268
- break;
1269
- case "string":
1270
- allChoices = getAllOfType(currentDocument.body, isStringExp);
1271
- break;
1272
- case "tracker":
1273
- allChoices = getAllOfType(currentDocument.body, isTrackerExp);
1274
- break;
1275
- case "choice":
1276
- allChoices = getAllOfType(currentDocument.body, isDocumentChoiceExp);
1277
- break;
1278
- case "paperdoll":
1279
- allChoices = getAllOfType(currentDocument.body, isPaperDollExp);
1280
- break;
1281
- case "html":
1282
- allChoices = getAllOfType(currentDocument.body, isHtmlExp);
1283
- break;
1284
- }
1285
- let refChoices = allChoices.filter(x => x !== element).map(x => {
1286
- return {
1287
- path: `system.${x.name.toLowerCase()}`,
1288
- name: x.name
1289
- };
1290
- });
1291
- // Filter based on choices parameter if provided
1292
- if (choicesParam && ((_a = choicesParam.choices) === null || _a === void 0 ? void 0 : _a.length) > 0) {
1293
- const allowedProperties = choicesParam.choices.map((c) => { var _a; return (_a = c.property.ref) === null || _a === void 0 ? void 0 : _a.name.toLowerCase(); });
1294
- refChoices = refChoices.filter(x => allowedProperties.includes(x.name.toLowerCase()));
1295
- }
1296
- const choices = refChoices.map(c => `{ title: '${c.name}', value: '${c.path}' }`).join(", ");
1297
- return expandToNode `
1339
+ }
1340
+ switch (element.propertyType) {
1341
+ case "attribute":
1342
+ allChoices = getAllOfType(currentDocument.body, isAttributeExp);
1343
+ break;
1344
+ case "resource":
1345
+ allChoices = getAllOfType(currentDocument.body, isResourceExp);
1346
+ break;
1347
+ case "number":
1348
+ allChoices = getAllOfType(currentDocument.body, isNumberExp);
1349
+ break;
1350
+ case "boolean":
1351
+ allChoices = getAllOfType(currentDocument.body, isBooleanExp);
1352
+ break;
1353
+ case "date":
1354
+ allChoices = getAllOfType(currentDocument.body, isDateExp);
1355
+ break;
1356
+ case "time":
1357
+ allChoices = getAllOfType(currentDocument.body, isTimeExp);
1358
+ break;
1359
+ case "datetime":
1360
+ allChoices = getAllOfType(currentDocument.body, isDateTimeExp);
1361
+ break;
1362
+ case "die":
1363
+ allChoices = getAllOfType(currentDocument.body, isDieField);
1364
+ break;
1365
+ case "dice":
1366
+ allChoices = getAllOfType(currentDocument.body, isDiceField);
1367
+ break;
1368
+ case "string":
1369
+ allChoices = getAllOfType(currentDocument.body, isStringExp);
1370
+ break;
1371
+ case "tracker":
1372
+ allChoices = getAllOfType(currentDocument.body, isTrackerExp);
1373
+ break;
1374
+ case "choice":
1375
+ allChoices = getAllOfType(currentDocument.body, isDocumentChoiceExp);
1376
+ break;
1377
+ case "paperdoll":
1378
+ allChoices = getAllOfType(currentDocument.body, isPaperDollExp);
1379
+ break;
1380
+ case "html":
1381
+ allChoices = getAllOfType(currentDocument.body, isHtmlExp);
1382
+ break;
1383
+ }
1384
+ let refChoices = allChoices.filter(x => x !== element).map(x => {
1385
+ return {
1386
+ path: `system.${x.name.toLowerCase()}`,
1387
+ name: x.name
1388
+ };
1389
+ });
1390
+ // Filter based on choices parameter if provided
1391
+ if (choicesParam && ((_a = choicesParam.choices) === null || _a === void 0 ? void 0 : _a.length) > 0) {
1392
+ const allowedProperties = choicesParam.choices.map((c) => { var _a; return (_a = c.property.ref) === null || _a === void 0 ? void 0 : _a.name.toLowerCase(); });
1393
+ refChoices = refChoices.filter(x => allowedProperties.includes(x.name.toLowerCase()));
1394
+ }
1395
+ const choices = refChoices.map(c => `{ title: '${c.name}', value: '${c.path}' }`).join(", ");
1396
+ return expandToNode `
1298
1397
  <i-self-property-reference
1299
1398
  :context="context"
1300
1399
  label="${label}"
@@ -1305,11 +1404,11 @@ function generateVueComponentTemplate(entry, id, document) {
1305
1404
  ${standardParamsFragment}>
1306
1405
  </i-self-property-reference>
1307
1406
  `;
1308
- }
1309
- if (isStringExp(element)) {
1310
- const valueParam = element.params.find(p => isStringParamValue(p));
1311
- if (valueParam !== undefined) {
1312
- return expandToNode `
1407
+ }
1408
+ if (isStringExp(element)) {
1409
+ const valueParam = element.params.find(p => isStringParamValue(p));
1410
+ if (valueParam !== undefined) {
1411
+ return expandToNode `
1313
1412
  <i-string
1314
1413
  :context="context"
1315
1414
  label="${label}"
@@ -1318,8 +1417,8 @@ function generateVueComponentTemplate(entry, id, document) {
1318
1417
  ${standardParamsFragment}>
1319
1418
  </i-string>
1320
1419
  `;
1321
- }
1322
- return expandToNode `
1420
+ }
1421
+ return expandToNode `
1323
1422
  <i-text-field
1324
1423
  label="${label}"
1325
1424
  icon="${iconParam === null || iconParam === void 0 ? void 0 : iconParam.value}"
@@ -1331,46 +1430,46 @@ function generateVueComponentTemplate(entry, id, document) {
1331
1430
  :secondaryColor="secondaryColor">
1332
1431
  </i-text-field>
1333
1432
  `;
1334
- }
1335
- if (isStringChoiceField(element)) {
1336
- const choicesParam = element.params.find(p => isStringParamChoices(p));
1337
- if (!choicesParam) {
1338
- console.warn(`StringChoiceField ${element.name} does not have a choices parameter.`);
1339
- return expandToNode ``;
1340
1433
  }
1341
- if (((_b = choicesParam === null || choicesParam === void 0 ? void 0 : choicesParam.choices) === null || _b === void 0 ? void 0 : _b.length) === 0)
1342
- return expandToNode ``;
1343
- function choiceValue(choice) {
1344
- if (!isStringExtendedChoice(choice.value)) {
1345
- return toMachineIdentifier(choice.value);
1434
+ if (isStringChoiceField(element)) {
1435
+ const choicesParam = element.params.find(p => isStringParamChoices(p));
1436
+ if (!choicesParam) {
1437
+ console.warn(`StringChoiceField ${element.name} does not have a choices parameter.`);
1438
+ return expandToNode ``;
1346
1439
  }
1347
- let value = choice.value.properties.find(isChoiceStringValue);
1348
- if (value) {
1349
- return toMachineIdentifier(value.value);
1350
- }
1351
- let label = choice.value.properties.find(isLabelParam);
1352
- if (label) {
1353
- return toMachineIdentifier(label.value);
1354
- }
1355
- return "unknown";
1356
- }
1357
- function choiceData(choice) {
1358
- var _a, _b, _c, _d;
1359
- let choiceField = element;
1360
- if (!isStringExtendedChoice(choice.value)) {
1361
- return expandToNode `{ label: game.i18n.localize('${document.name}.${choiceField.name}.${choiceValue(choice)}'), value: '${choiceValue(choice)}', icon: '', color: '' }`;
1440
+ if (((_b = choicesParam === null || choicesParam === void 0 ? void 0 : choicesParam.choices) === null || _b === void 0 ? void 0 : _b.length) === 0)
1441
+ return expandToNode ``;
1442
+ function choiceValue(choice) {
1443
+ if (!isStringExtendedChoice(choice.value)) {
1444
+ return toMachineIdentifier(choice.value);
1445
+ }
1446
+ let value = choice.value.properties.find(isChoiceStringValue);
1447
+ if (value) {
1448
+ return toMachineIdentifier(value.value);
1449
+ }
1450
+ let label = choice.value.properties.find(isLabelParam);
1451
+ if (label) {
1452
+ return toMachineIdentifier(label.value);
1453
+ }
1454
+ return "unknown";
1362
1455
  }
1363
- let icon = choice.value.properties.find(isIconParam);
1364
- let color = choice.value.properties.find(isColorParam);
1365
- if (isStringExtendedChoice(choice.value)) {
1366
- let customProperties = choice.value.properties.filter(isChoiceCustomProperty);
1367
- if (customProperties.length > 0) {
1368
- return expandToNode `{ label: game.i18n.localize('${document.name}.${choiceField.name}.${choiceValue(choice)}'), value: '${choiceValue(choice)}', icon: '${(_a = icon === null || icon === void 0 ? void 0 : icon.value) !== null && _a !== void 0 ? _a : ""}', color: '${(_b = color === null || color === void 0 ? void 0 : color.value) !== null && _b !== void 0 ? _b : ""}', customKeys: [${joinToNode(customProperties, custom => `{ key: '${custom.key}', label: '${humanize(custom.key)}', value: ${custom.value} }`, { separator: ',' })}] }`;
1456
+ function choiceData(choice) {
1457
+ var _a, _b, _c, _d;
1458
+ let choiceField = element;
1459
+ if (!isStringExtendedChoice(choice.value)) {
1460
+ return expandToNode `{ label: game.i18n.localize('${document.name}.${choiceField.name}.${choiceValue(choice)}'), value: '${choiceValue(choice)}', icon: '', color: '' }`;
1369
1461
  }
1462
+ let icon = choice.value.properties.find(isIconParam);
1463
+ let color = choice.value.properties.find(isColorParam);
1464
+ if (isStringExtendedChoice(choice.value)) {
1465
+ let customProperties = choice.value.properties.filter(isChoiceCustomProperty);
1466
+ if (customProperties.length > 0) {
1467
+ return expandToNode `{ label: game.i18n.localize('${document.name}.${choiceField.name}.${choiceValue(choice)}'), value: '${choiceValue(choice)}', icon: '${(_a = icon === null || icon === void 0 ? void 0 : icon.value) !== null && _a !== void 0 ? _a : ""}', color: '${(_b = color === null || color === void 0 ? void 0 : color.value) !== null && _b !== void 0 ? _b : ""}', customKeys: [${joinToNode(customProperties, custom => `{ key: '${custom.key}', label: '${humanize(custom.key)}', value: ${custom.value} }`, { separator: ',' })}] }`;
1468
+ }
1469
+ }
1470
+ return expandToNode `{ label: game.i18n.localize('${document.name}.${choiceField.name}.${choiceValue(choice)}'), value: '${choiceValue(choice)}', icon: '${(_c = icon === null || icon === void 0 ? void 0 : icon.value) !== null && _c !== void 0 ? _c : ""}', color: '${(_d = color === null || color === void 0 ? void 0 : color.value) !== null && _d !== void 0 ? _d : ""}' }`;
1370
1471
  }
1371
- return expandToNode `{ label: game.i18n.localize('${document.name}.${choiceField.name}.${choiceValue(choice)}'), value: '${choiceValue(choice)}', icon: '${(_c = icon === null || icon === void 0 ? void 0 : icon.value) !== null && _c !== void 0 ? _c : ""}', color: '${(_d = color === null || color === void 0 ? void 0 : color.value) !== null && _d !== void 0 ? _d : ""}' }`;
1372
- }
1373
- return expandToNode `
1472
+ return expandToNode `
1374
1473
  <i-string-choice
1375
1474
  :context="context"
1376
1475
  label="${label}.label"
@@ -1383,52 +1482,52 @@ function generateVueComponentTemplate(entry, id, document) {
1383
1482
  ${standardParamsFragment}>
1384
1483
  </i-string-choice>
1385
1484
  `;
1386
- }
1387
- if (isDamageTypeChoiceField(element)) {
1388
- const choicesParam = element.params.find(p => isStringParamChoices(p));
1389
- if (!choicesParam) {
1390
- console.warn(`DamageTypeChoiceField ${element.name} does not have a choices parameter.`);
1391
- return expandToNode ``;
1392
1485
  }
1393
- if (((_c = choicesParam === null || choicesParam === void 0 ? void 0 : choicesParam.choices) === null || _c === void 0 ? void 0 : _c.length) === 0)
1394
- return expandToNode ``;
1395
- function choiceValue(choice) {
1396
- if (!isStringExtendedChoice(choice.value)) {
1397
- return toMachineIdentifier(choice.value);
1486
+ if (isDamageTypeChoiceField(element)) {
1487
+ const choicesParam = element.params.find(p => isStringParamChoices(p));
1488
+ if (!choicesParam) {
1489
+ console.warn(`DamageTypeChoiceField ${element.name} does not have a choices parameter.`);
1490
+ return expandToNode ``;
1398
1491
  }
1399
- let value = choice.value.properties.find(isChoiceStringValue);
1400
- if (value) {
1401
- return toMachineIdentifier(value.value);
1402
- }
1403
- let label = choice.value.properties.find(isLabelParam);
1404
- if (label) {
1405
- return toMachineIdentifier(label.value);
1406
- }
1407
- return "unknown";
1408
- }
1409
- function choiceData(choice) {
1410
- var _a, _b, _c, _d;
1411
- let choiceField = element;
1412
- if (!isStringExtendedChoice(choice.value)) {
1413
- return expandToNode `{ label: game.i18n.localize('${document.name}.${choiceField.name}.${choiceValue(choice)}'), value: '${choiceValue(choice)}', icon: '', color: '' }`;
1414
- }
1415
- let icon = choice.value.properties.find(isIconParam);
1416
- let color = choice.value.properties.find(isColorParam);
1417
- function asStringOrVal(value) {
1418
- // If string, return as "value", else just value
1419
- if (typeof value === 'string')
1420
- return `'${value}'`;
1421
- return `${value}`;
1492
+ if (((_c = choicesParam === null || choicesParam === void 0 ? void 0 : choicesParam.choices) === null || _c === void 0 ? void 0 : _c.length) === 0)
1493
+ return expandToNode ``;
1494
+ function choiceValue(choice) {
1495
+ if (!isStringExtendedChoice(choice.value)) {
1496
+ return toMachineIdentifier(choice.value);
1497
+ }
1498
+ let value = choice.value.properties.find(isChoiceStringValue);
1499
+ if (value) {
1500
+ return toMachineIdentifier(value.value);
1501
+ }
1502
+ let label = choice.value.properties.find(isLabelParam);
1503
+ if (label) {
1504
+ return toMachineIdentifier(label.value);
1505
+ }
1506
+ return "unknown";
1422
1507
  }
1423
- if (isStringExtendedChoice(choice.value)) {
1424
- let customProperties = choice.value.properties.filter(isChoiceCustomProperty);
1425
- if (customProperties.length > 0) {
1426
- return expandToNode `{ label: game.i18n.localize('${document.name}.${choiceField.name}.${choiceValue(choice)}'), value: '${choiceValue(choice)}', icon: '${(_a = icon === null || icon === void 0 ? void 0 : icon.value) !== null && _a !== void 0 ? _a : ""}', color: '${(_b = color === null || color === void 0 ? void 0 : color.value) !== null && _b !== void 0 ? _b : ""}', customKeys: [${joinToNode(customProperties, custom => `{ key: '${custom.key}', label: '${humanize(custom.key)}', value: ${asStringOrVal(custom.value)} }`, { separator: ',' })}] }`;
1508
+ function choiceData(choice) {
1509
+ var _a, _b, _c, _d;
1510
+ let choiceField = element;
1511
+ if (!isStringExtendedChoice(choice.value)) {
1512
+ return expandToNode `{ label: game.i18n.localize('${document.name}.${choiceField.name}.${choiceValue(choice)}'), value: '${choiceValue(choice)}', icon: '', color: '' }`;
1513
+ }
1514
+ let icon = choice.value.properties.find(isIconParam);
1515
+ let color = choice.value.properties.find(isColorParam);
1516
+ function asStringOrVal(value) {
1517
+ // If string, return as "value", else just value
1518
+ if (typeof value === 'string')
1519
+ return `'${value}'`;
1520
+ return `${value}`;
1521
+ }
1522
+ if (isStringExtendedChoice(choice.value)) {
1523
+ let customProperties = choice.value.properties.filter(isChoiceCustomProperty);
1524
+ if (customProperties.length > 0) {
1525
+ return expandToNode `{ label: game.i18n.localize('${document.name}.${choiceField.name}.${choiceValue(choice)}'), value: '${choiceValue(choice)}', icon: '${(_a = icon === null || icon === void 0 ? void 0 : icon.value) !== null && _a !== void 0 ? _a : ""}', color: '${(_b = color === null || color === void 0 ? void 0 : color.value) !== null && _b !== void 0 ? _b : ""}', customKeys: [${joinToNode(customProperties, custom => `{ key: '${custom.key}', label: '${humanize(custom.key)}', value: ${asStringOrVal(custom.value)} }`, { separator: ',' })}] }`;
1526
+ }
1427
1527
  }
1528
+ return expandToNode `{ label: game.i18n.localize('${document.name}.${choiceField.name}.${choiceValue(choice)}'), value: '${choiceValue(choice)}', icon: '${(_c = icon === null || icon === void 0 ? void 0 : icon.value) !== null && _c !== void 0 ? _c : ""}', color: '${(_d = color === null || color === void 0 ? void 0 : color.value) !== null && _d !== void 0 ? _d : ""}' }`;
1428
1529
  }
1429
- return expandToNode `{ label: game.i18n.localize('${document.name}.${choiceField.name}.${choiceValue(choice)}'), value: '${choiceValue(choice)}', icon: '${(_c = icon === null || icon === void 0 ? void 0 : icon.value) !== null && _c !== void 0 ? _c : ""}', color: '${(_d = color === null || color === void 0 ? void 0 : color.value) !== null && _d !== void 0 ? _d : ""}' }`;
1430
- }
1431
- return expandToNode `
1530
+ return expandToNode `
1432
1531
  <i-string-choice
1433
1532
  :context="context"
1434
1533
  label="${label}.label"
@@ -1441,49 +1540,49 @@ function generateVueComponentTemplate(entry, id, document) {
1441
1540
  ${standardParamsFragment}>
1442
1541
  </i-string-choice>
1443
1542
  `;
1444
- }
1445
- if (isStringChoicesField(element)) {
1446
- const choicesParam = element.params.find(p => p.$type === 'StringChoicesParamChoices');
1447
- if (!choicesParam) {
1448
- console.warn(`StringChoicesField ${element.name} does not have a choices parameter.`);
1449
- return expandToNode ``;
1450
1543
  }
1451
- if (((_d = choicesParam === null || choicesParam === void 0 ? void 0 : choicesParam.choices) === null || _d === void 0 ? void 0 : _d.length) === 0)
1452
- return expandToNode ``;
1453
- function choiceValue(choice) {
1454
- if (!isStringExtendedChoice(choice.value)) {
1455
- return toMachineIdentifier(choice.value);
1456
- }
1457
- let value = choice.value.properties.find(isChoiceStringValue);
1458
- if (value) {
1459
- return toMachineIdentifier(value.value);
1544
+ if (isStringChoicesField(element)) {
1545
+ const choicesParam = element.params.find(p => p.$type === 'StringChoicesParamChoices');
1546
+ if (!choicesParam) {
1547
+ console.warn(`StringChoicesField ${element.name} does not have a choices parameter.`);
1548
+ return expandToNode ``;
1460
1549
  }
1461
- let label = choice.value.properties.find(isLabelParam);
1462
- if (label) {
1463
- return toMachineIdentifier(label.value);
1464
- }
1465
- return "unknown";
1466
- }
1467
- function choiceData(choice) {
1468
- var _a, _b, _c, _d;
1469
- let choiceField = element;
1470
- if (!isStringExtendedChoice(choice.value)) {
1471
- return expandToNode `{ label: game.i18n.localize('${document.name}.${choiceField.name}.${choiceValue(choice)}'), value: '${choiceValue(choice)}', icon: '', color: '' }`;
1550
+ if (((_d = choicesParam === null || choicesParam === void 0 ? void 0 : choicesParam.choices) === null || _d === void 0 ? void 0 : _d.length) === 0)
1551
+ return expandToNode ``;
1552
+ function choiceValue(choice) {
1553
+ if (!isStringExtendedChoice(choice.value)) {
1554
+ return toMachineIdentifier(choice.value);
1555
+ }
1556
+ let value = choice.value.properties.find(isChoiceStringValue);
1557
+ if (value) {
1558
+ return toMachineIdentifier(value.value);
1559
+ }
1560
+ let label = choice.value.properties.find(isLabelParam);
1561
+ if (label) {
1562
+ return toMachineIdentifier(label.value);
1563
+ }
1564
+ return "unknown";
1472
1565
  }
1473
- let icon = choice.value.properties.find(isIconParam);
1474
- let color = choice.value.properties.find(isColorParam);
1475
- if (isStringExtendedChoice(choice.value)) {
1476
- let customProperties = choice.value.properties.filter(isChoiceCustomProperty);
1477
- if (customProperties.length > 0) {
1478
- return expandToNode `{ label: game.i18n.localize('${document.name}.${choiceField.name}.${choiceValue(choice)}'), value: '${choiceValue(choice)}', icon: '${(_a = icon === null || icon === void 0 ? void 0 : icon.value) !== null && _a !== void 0 ? _a : ""}', color: '${(_b = color === null || color === void 0 ? void 0 : color.value) !== null && _b !== void 0 ? _b : ""}', customKeys: [${joinToNode(customProperties, custom => `{ key: '${custom.key}', label: '${humanize(custom.key)}', value: ${custom.value} }`, { separator: ',' })}] }`;
1566
+ function choiceData(choice) {
1567
+ var _a, _b, _c, _d;
1568
+ let choiceField = element;
1569
+ if (!isStringExtendedChoice(choice.value)) {
1570
+ return expandToNode `{ label: game.i18n.localize('${document.name}.${choiceField.name}.${choiceValue(choice)}'), value: '${choiceValue(choice)}', icon: '', color: '' }`;
1571
+ }
1572
+ let icon = choice.value.properties.find(isIconParam);
1573
+ let color = choice.value.properties.find(isColorParam);
1574
+ if (isStringExtendedChoice(choice.value)) {
1575
+ let customProperties = choice.value.properties.filter(isChoiceCustomProperty);
1576
+ if (customProperties.length > 0) {
1577
+ return expandToNode `{ label: game.i18n.localize('${document.name}.${choiceField.name}.${choiceValue(choice)}'), value: '${choiceValue(choice)}', icon: '${(_a = icon === null || icon === void 0 ? void 0 : icon.value) !== null && _a !== void 0 ? _a : ""}', color: '${(_b = color === null || color === void 0 ? void 0 : color.value) !== null && _b !== void 0 ? _b : ""}', customKeys: [${joinToNode(customProperties, custom => `{ key: '${custom.key}', label: '${humanize(custom.key)}', value: ${custom.value} }`, { separator: ',' })}] }`;
1578
+ }
1479
1579
  }
1580
+ return expandToNode `{ label: game.i18n.localize('${document.name}.${choiceField.name}.${choiceValue(choice)}'), value: '${choiceValue(choice)}', icon: '${(_c = icon === null || icon === void 0 ? void 0 : icon.value) !== null && _c !== void 0 ? _c : ""}', color: '${(_d = color === null || color === void 0 ? void 0 : color.value) !== null && _d !== void 0 ? _d : ""}' }`;
1480
1581
  }
1481
- return expandToNode `{ label: game.i18n.localize('${document.name}.${choiceField.name}.${choiceValue(choice)}'), value: '${choiceValue(choice)}', icon: '${(_c = icon === null || icon === void 0 ? void 0 : icon.value) !== null && _c !== void 0 ? _c : ""}', color: '${(_d = color === null || color === void 0 ? void 0 : color.value) !== null && _d !== void 0 ? _d : ""}' }`;
1482
- }
1483
- // Get maxSelections parameter
1484
- const maxParam = element.params.find(p => p.$type === 'StringChoicesParamMax');
1485
- const maxSelections = maxParam ? maxParam.value : undefined;
1486
- return expandToNode `
1582
+ // Get maxSelections parameter
1583
+ const maxParam = element.params.find(p => p.$type === 'StringChoicesParamMax');
1584
+ const maxSelections = maxParam ? maxParam.value : undefined;
1585
+ return expandToNode `
1487
1586
  <i-string-choices
1488
1587
  :context="context"
1489
1588
  label="${label}.label"
@@ -1497,10 +1596,10 @@ function generateVueComponentTemplate(entry, id, document) {
1497
1596
  ${standardParamsFragment}>
1498
1597
  </i-string-choices>
1499
1598
  `;
1500
- }
1501
- if (isDocumentChoiceExp(element)) {
1502
- const componentName = `${document.name.toLowerCase()}${element.name}DocumentChoice`;
1503
- return expandToNode `
1599
+ }
1600
+ if (isDocumentChoiceExp(element)) {
1601
+ const componentName = `${document.name.toLowerCase()}${element.name}DocumentChoice`;
1602
+ return expandToNode `
1504
1603
  <${componentName}
1505
1604
  label="${label}"
1506
1605
  icon="${iconParam === null || iconParam === void 0 ? void 0 : iconParam.value}"
@@ -1511,10 +1610,10 @@ function generateVueComponentTemplate(entry, id, document) {
1511
1610
  :secondaryColor="secondaryColor">
1512
1611
  </${componentName}>
1513
1612
  `;
1514
- }
1515
- if (isDocumentChoicesExp(element)) {
1516
- const componentName = `${document.name.toLowerCase()}${element.name}DocumentChoices`;
1517
- return expandToNode `
1613
+ }
1614
+ if (isDocumentChoicesExp(element)) {
1615
+ const componentName = `${document.name.toLowerCase()}${element.name}DocumentChoices`;
1616
+ return expandToNode `
1518
1617
  <${componentName}
1519
1618
  label="${label}"
1520
1619
  icon="${iconParam === null || iconParam === void 0 ? void 0 : iconParam.value}"
@@ -1525,9 +1624,9 @@ function generateVueComponentTemplate(entry, id, document) {
1525
1624
  :secondaryColor="secondaryColor">
1526
1625
  </${componentName}>
1527
1626
  `;
1528
- }
1529
- if (isMacroField(element)) {
1530
- return expandToNode `
1627
+ }
1628
+ if (isMacroField(element)) {
1629
+ return expandToNode `
1531
1630
  <i-macro
1532
1631
  label="${label}"
1533
1632
  icon="${iconParam === null || iconParam === void 0 ? void 0 : iconParam.value}"
@@ -1539,9 +1638,9 @@ function generateVueComponentTemplate(entry, id, document) {
1539
1638
  :secondaryColor="secondaryColor">
1540
1639
  </i-macro>
1541
1640
  `;
1542
- }
1543
- if (isHtmlExp(element)) {
1544
- return expandToNode `
1641
+ }
1642
+ if (isHtmlExp(element)) {
1643
+ return expandToNode `
1545
1644
  <i-prosemirror
1546
1645
  label="${label}"
1547
1646
  icon="${iconParam === null || iconParam === void 0 ? void 0 : iconParam.value}"
@@ -1549,9 +1648,9 @@ function generateVueComponentTemplate(entry, id, document) {
1549
1648
  ${standardParamsFragment}>
1550
1649
  </i-prosemirror>
1551
1650
  `;
1552
- }
1553
- if (isMeasuredTemplateField(element)) {
1554
- return expandToNode `
1651
+ }
1652
+ if (isMeasuredTemplateField(element)) {
1653
+ return expandToNode `
1555
1654
  <i-measured-template
1556
1655
  :context="context"
1557
1656
  label="${label}"
@@ -1562,9 +1661,9 @@ function generateVueComponentTemplate(entry, id, document) {
1562
1661
  ${standardParamsFragment}>
1563
1662
  </i-measured-template>
1564
1663
  `;
1565
- }
1566
- if (isDamageBonusesField(element)) {
1567
- return expandToNode `
1664
+ }
1665
+ if (isDamageBonusesField(element)) {
1666
+ return expandToNode `
1568
1667
  <i-bonuses
1569
1668
  :context="context"
1570
1669
  label="${label}"
@@ -1573,9 +1672,9 @@ function generateVueComponentTemplate(entry, id, document) {
1573
1672
  ${standardParamsFragment}>
1574
1673
  </i-bonuses>
1575
1674
  `;
1576
- }
1577
- if (isDamageResistancesField(element)) {
1578
- return expandToNode `
1675
+ }
1676
+ if (isDamageResistancesField(element)) {
1677
+ return expandToNode `
1579
1678
  <i-resistances
1580
1679
  :context="context"
1581
1680
  label="${label}"
@@ -1584,17 +1683,17 @@ function generateVueComponentTemplate(entry, id, document) {
1584
1683
  ${standardParamsFragment}>
1585
1684
  </i-resistances>
1586
1685
  `;
1587
- }
1588
- if (isPinnedField(element)) {
1589
- if (isTopLevel)
1590
- return expandToNode ``;
1591
- const page = AstUtils.getContainerOfType(element, isPage);
1592
- const pageName = (_e = page === null || page === void 0 ? void 0 : page.name) !== null && _e !== void 0 ? _e : document.name;
1593
- const systemPath = getSystemPath(element, [], undefined, false);
1594
- let componentName = `${document.name}${pageName}${element.name}VuetifyDatatable`;
1595
- // Wrap in a drop zone so drag-drop works for pinned tables inside a
1596
- // row/column (same reason as regular tables above).
1597
- return expandToNode `
1686
+ }
1687
+ if (isPinnedField(element)) {
1688
+ if (isTopLevel)
1689
+ return expandToNode ``;
1690
+ const page = AstUtils.getContainerOfType(element, isPage);
1691
+ const pageName = (_e = page === null || page === void 0 ? void 0 : page.name) !== null && _e !== void 0 ? _e : document.name;
1692
+ const systemPath = getSystemPath(element, [], undefined, false);
1693
+ let componentName = `${document.name}${pageName}${element.name}VuetifyDatatable`;
1694
+ // Wrap in a drop zone so drag-drop works for pinned tables inside a
1695
+ // row/column (same reason as regular tables above).
1696
+ return expandToNode `
1598
1697
  <div class="datatable-drop-zone" v-if="!isHidden('${element.name.toLowerCase()}')">
1599
1698
  <${componentName}
1600
1699
  :context="context"
@@ -1605,9 +1704,9 @@ function generateVueComponentTemplate(entry, id, document) {
1605
1704
  </${componentName}>
1606
1705
  </div>
1607
1706
  `;
1608
- }
1609
- if (isBooleanExp(element)) {
1610
- return expandToNode `
1707
+ }
1708
+ if (isBooleanExp(element)) {
1709
+ return expandToNode `
1611
1710
  <i-boolean
1612
1711
  :context="context"
1613
1712
  label="${label}"
@@ -1616,23 +1715,23 @@ function generateVueComponentTemplate(entry, id, document) {
1616
1715
  ${standardParamsFragment}>
1617
1716
  </i-boolean>
1618
1717
  `;
1619
- }
1620
- if (isNumberExp(element)) {
1621
- const valueParam = element.params.find(x => isNumberParamValue(x));
1622
- const minParam = element.params.find(x => isNumberParamMin(x));
1623
- const maxParam = element.params.find(x => isNumberParamMax(x));
1624
- const calculatorParam = element.params.find(x => isNumberParamCalculator(x));
1625
- // Determine if min/max are literal numbers (not MethodBlocks). Literal bounds are
1626
- // bound onto the widget so it clamps input at entry, matching the schema's clamp.
1627
- let minValue = undefined;
1628
- if (minParam && typeof minParam.value === 'number') {
1629
- minValue = minParam.value;
1630
- }
1631
- let maxValue = undefined;
1632
- if (maxParam && typeof maxParam.value === 'number') {
1633
- maxValue = maxParam.value;
1634
1718
  }
1635
- return expandToNode `
1719
+ if (isNumberExp(element)) {
1720
+ const valueParam = element.params.find(x => isNumberParamValue(x));
1721
+ const minParam = element.params.find(x => isNumberParamMin(x));
1722
+ const maxParam = element.params.find(x => isNumberParamMax(x));
1723
+ const calculatorParam = element.params.find(x => isNumberParamCalculator(x));
1724
+ // Determine if min/max are literal numbers (not MethodBlocks). Literal bounds are
1725
+ // bound onto the widget so it clamps input at entry, matching the schema's clamp.
1726
+ let minValue = undefined;
1727
+ if (minParam && typeof minParam.value === 'number') {
1728
+ minValue = minParam.value;
1729
+ }
1730
+ let maxValue = undefined;
1731
+ if (maxParam && typeof maxParam.value === 'number') {
1732
+ maxValue = maxParam.value;
1733
+ }
1734
+ return expandToNode `
1636
1735
  <i-number
1637
1736
  :context="context"
1638
1737
  label="${label}"
@@ -1648,27 +1747,27 @@ function generateVueComponentTemplate(entry, id, document) {
1648
1747
  ${standardParamsFragment}>
1649
1748
  </i-number>
1650
1749
  `;
1651
- }
1652
- if (isMoneyField(element)) {
1653
- const formatParam = element.params.find(p => p.$type === 'MoneyFormatParam');
1654
- const precisionParam = element.params.find(p => p.$type === 'MoneyPrecisionParam');
1655
- const displayParam = element.params.find(p => p.$type === 'MoneyDisplayParam');
1656
- const valueParam = element.params.find(x => isNumberParamValue(x));
1657
- const format = (formatParam === null || formatParam === void 0 ? void 0 : formatParam.value) || 'auto';
1658
- const precision = (precisionParam === null || precisionParam === void 0 ? void 0 : precisionParam.value) || 1;
1659
- const display = (displayParam === null || displayParam === void 0 ? void 0 : displayParam.value) || 'breakdown';
1660
- // Generate denominations array from AST
1661
- let denominationsArray = '[]';
1662
- if (element.denominations && element.denominations.length > 0) {
1663
- const denominations = element.denominations.map(denom => {
1664
- const valueParam = denom.params.find((p) => p.$type === 'MoneyDenominationValueParam');
1665
- const denomIconParam = denom.params.find((p) => p.$type === 'IconParam');
1666
- const denomColorParam = denom.params.find((p) => p.$type === 'ColorParam');
1667
- return `{ name: '${denom.name}', value: ${(valueParam === null || valueParam === void 0 ? void 0 : valueParam.value) || 1}, icon: '${(denomIconParam === null || denomIconParam === void 0 ? void 0 : denomIconParam.value) || ''}', color: '${(denomColorParam === null || denomColorParam === void 0 ? void 0 : denomColorParam.value) || ''}' }`;
1668
- }).join(', ');
1669
- denominationsArray = `[${denominations}]`;
1670
1750
  }
1671
- return expandToNode `
1751
+ if (isMoneyField(element)) {
1752
+ const formatParam = element.params.find(p => p.$type === 'MoneyFormatParam');
1753
+ const precisionParam = element.params.find(p => p.$type === 'MoneyPrecisionParam');
1754
+ const displayParam = element.params.find(p => p.$type === 'MoneyDisplayParam');
1755
+ const valueParam = element.params.find(x => isNumberParamValue(x));
1756
+ const format = (formatParam === null || formatParam === void 0 ? void 0 : formatParam.value) || 'auto';
1757
+ const precision = (precisionParam === null || precisionParam === void 0 ? void 0 : precisionParam.value) || 1;
1758
+ const display = (displayParam === null || displayParam === void 0 ? void 0 : displayParam.value) || 'breakdown';
1759
+ // Generate denominations array from AST
1760
+ let denominationsArray = '[]';
1761
+ if (element.denominations && element.denominations.length > 0) {
1762
+ const denominations = element.denominations.map(denom => {
1763
+ const valueParam = denom.params.find((p) => p.$type === 'MoneyDenominationValueParam');
1764
+ const denomIconParam = denom.params.find((p) => p.$type === 'IconParam');
1765
+ const denomColorParam = denom.params.find((p) => p.$type === 'ColorParam');
1766
+ return `{ name: '${denom.name}', value: ${(valueParam === null || valueParam === void 0 ? void 0 : valueParam.value) || 1}, icon: '${(denomIconParam === null || denomIconParam === void 0 ? void 0 : denomIconParam.value) || ''}', color: '${(denomColorParam === null || denomColorParam === void 0 ? void 0 : denomColorParam.value) || ''}' }`;
1767
+ }).join(', ');
1768
+ denominationsArray = `[${denominations}]`;
1769
+ }
1770
+ return expandToNode `
1672
1771
  <i-money
1673
1772
  :context="context"
1674
1773
  label="${label}"
@@ -1685,26 +1784,26 @@ function generateVueComponentTemplate(entry, id, document) {
1685
1784
  ${standardParamsFragment}>
1686
1785
  </i-money>
1687
1786
  `;
1688
- }
1689
- if (isAttributeExp(element)) {
1690
- const minParam = element.params.find(x => isNumberParamMin(x));
1691
- const min = (_f = minParam === null || minParam === void 0 ? void 0 : minParam.value) !== null && _f !== void 0 ? _f : 0;
1692
- const hasMod = element.params.find(x => isAttributeParamMod(x)) != undefined;
1693
- const modSystemPath = getSystemPath(element, ["mod"], undefined, false);
1694
- const valueSystemPath = getSystemPath(element, ["value"], undefined, false);
1695
- const styleParam = element.params.find(x => isAttributeStyleParam(x));
1696
- const style = (_g = styleParam === null || styleParam === void 0 ? void 0 : styleParam.style) !== null && _g !== void 0 ? _g : "box";
1697
- const rollParam = element.params.find(x => isAttributeRollParam(x));
1698
- const functionParam = element.params.find(x => isAttributeFunctionParam(x));
1699
- // Both `roll:` and `function:` drive the attribute's click overlay. Validation forbids
1700
- // setting both, so at most one of these is defined.
1701
- const clickHandler = rollParam
1702
- ? expandToNode `on${element.name}AttributeRoll`
1703
- : (functionParam ? expandToNode `on${element.name}AttributeFunction` : expandToNode `undefined`);
1704
- // roll: keeps the die icon; function: shows the attribute's own icon (or a generic
1705
- // action bolt) so the overlay reflects what the click actually triggers.
1706
- const clickIcon = functionParam ? ((_h = iconParam === null || iconParam === void 0 ? void 0 : iconParam.value) !== null && _h !== void 0 ? _h : "fa-solid fa-bolt") : "fa-solid fa-dice";
1707
- return expandToNode `
1787
+ }
1788
+ if (isAttributeExp(element)) {
1789
+ const minParam = element.params.find(x => isNumberParamMin(x));
1790
+ const min = (_f = minParam === null || minParam === void 0 ? void 0 : minParam.value) !== null && _f !== void 0 ? _f : 0;
1791
+ const hasMod = element.params.find(x => isAttributeParamMod(x)) != undefined;
1792
+ const modSystemPath = getSystemPath(element, ["mod"], undefined, false);
1793
+ const valueSystemPath = getSystemPath(element, ["value"], undefined, false);
1794
+ const styleParam = element.params.find(x => isAttributeStyleParam(x));
1795
+ const style = (_g = styleParam === null || styleParam === void 0 ? void 0 : styleParam.style) !== null && _g !== void 0 ? _g : "box";
1796
+ const rollParam = element.params.find(x => isAttributeRollParam(x));
1797
+ const functionParam = element.params.find(x => isAttributeFunctionParam(x));
1798
+ // Both `roll:` and `function:` drive the attribute's click overlay. Validation forbids
1799
+ // setting both, so at most one of these is defined.
1800
+ const clickHandler = rollParam
1801
+ ? expandToNode `on${element.name}AttributeRoll`
1802
+ : (functionParam ? expandToNode `on${element.name}AttributeFunction` : expandToNode `undefined`);
1803
+ // roll: keeps the die icon; function: shows the attribute's own icon (or a generic
1804
+ // action bolt) so the overlay reflects what the click actually triggers.
1805
+ const clickIcon = functionParam ? ((_h = iconParam === null || iconParam === void 0 ? void 0 : iconParam.value) !== null && _h !== void 0 ? _h : "fa-solid fa-bolt") : "fa-solid fa-dice";
1806
+ return expandToNode `
1708
1807
  <i-attribute
1709
1808
  label="${label}"
1710
1809
  icon="${iconParam === null || iconParam === void 0 ? void 0 : iconParam.value}"
@@ -1724,28 +1823,28 @@ function generateVueComponentTemplate(entry, id, document) {
1724
1823
  >
1725
1824
  </i-attribute>
1726
1825
  `;
1727
- }
1728
- // if () {
1729
- // return expandToNode`
1730
- // <i-resource
1731
- // label="${label}"
1732
- // icon="${iconParam?.value}"
1733
- // systemPath="system.${element.name.toLowerCase()}"
1734
- // :context="context"
1735
- // ${standardParamsFragment}
1736
- // :primaryColor="primaryColor"
1737
- // :secondaryColor="secondaryColor">
1738
- // </i-resource>
1739
- // `;
1740
- // }
1741
- if (isDamageTrackExp(element)) {
1742
- const typesParam = element.params.find(x => isDamageTrackTypesParam(x));
1743
- const types = (_j = typesParam === null || typesParam === void 0 ? void 0 : typesParam.types) !== null && _j !== void 0 ? _j : [];
1744
- const maxParam = element.params.find(x => isNumberParamMax(x));
1745
- const max = (_k = maxParam === null || maxParam === void 0 ? void 0 : maxParam.value) !== null && _k !== void 0 ? _k : 5;
1746
- const colorParam = element.params.find(x => isColorParam(x));
1747
- const primaryColor = colorParam ? `'${colorParam.value}'` : "primaryColor";
1748
- return expandToNode `
1826
+ }
1827
+ // if () {
1828
+ // return expandToNode`
1829
+ // <i-resource
1830
+ // label="${label}"
1831
+ // icon="${iconParam?.value}"
1832
+ // systemPath="system.${element.name.toLowerCase()}"
1833
+ // :context="context"
1834
+ // ${standardParamsFragment}
1835
+ // :primaryColor="primaryColor"
1836
+ // :secondaryColor="secondaryColor">
1837
+ // </i-resource>
1838
+ // `;
1839
+ // }
1840
+ if (isDamageTrackExp(element)) {
1841
+ const typesParam = element.params.find(x => isDamageTrackTypesParam(x));
1842
+ const types = (_j = typesParam === null || typesParam === void 0 ? void 0 : typesParam.types) !== null && _j !== void 0 ? _j : [];
1843
+ const maxParam = element.params.find(x => isNumberParamMax(x));
1844
+ const max = (_k = maxParam === null || maxParam === void 0 ? void 0 : maxParam.value) !== null && _k !== void 0 ? _k : 5;
1845
+ const colorParam = element.params.find(x => isColorParam(x));
1846
+ const primaryColor = colorParam ? `'${colorParam.value}'` : "primaryColor";
1847
+ return expandToNode `
1749
1848
  <i-damage-track
1750
1849
  label="${label}"
1751
1850
  systemPath="system.${element.name.toLowerCase()}"
@@ -1757,31 +1856,31 @@ function generateVueComponentTemplate(entry, id, document) {
1757
1856
  :max="${max}"
1758
1857
  ></i-damage-track>
1759
1858
  `;
1760
- }
1761
- if (isTrackerExp(element) || isResourceExp(element)) {
1762
- const styleParam = element.params.find(x => isTrackerStyleParameter(x));
1763
- const style = (_l = styleParam === null || styleParam === void 0 ? void 0 : styleParam.style) !== null && _l !== void 0 ? _l : "bar";
1764
- const iconParam = element.params.find(x => isIconParam(x));
1765
- const icon = (_m = iconParam === null || iconParam === void 0 ? void 0 : iconParam.value) !== null && _m !== void 0 ? _m : undefined;
1766
- const minParam = element.params.find(x => isNumberParamMin(x));
1767
- const disableMin = (minParam === null || minParam === void 0 ? void 0 : minParam.value) != undefined;
1768
- let hideMin = false;
1769
- const valueParam = element.params.find(x => isNumberParamValue(x));
1770
- const disableValue = (valueParam === null || valueParam === void 0 ? void 0 : valueParam.value) != undefined;
1771
- const maxParam = element.params.find(x => isNumberParamMax(x));
1772
- const disableMax = (maxParam === null || maxParam === void 0 ? void 0 : maxParam.value) != undefined;
1773
- const colorParam = element.params.find(x => isColorParam(x));
1774
- const primaryColor = colorParam ? `'${colorParam.value}'` : "primaryColor";
1775
- const segmentParm = element.params.find(x => isSegmentsParameter(x));
1776
- const segments = (_o = segmentParm === null || segmentParm === void 0 ? void 0 : segmentParm.segments) !== null && _o !== void 0 ? _o : 1;
1777
- let isHealth = false;
1778
- let isWounds = false;
1779
- if (isResourceExp(element)) {
1780
- hideMin = true;
1781
- isHealth = element.tag == "health";
1782
- isWounds = element.tag == "wounds";
1783
1859
  }
1784
- return expandToNode `
1860
+ if (isTrackerExp(element) || isResourceExp(element)) {
1861
+ const styleParam = element.params.find(x => isTrackerStyleParameter(x));
1862
+ const style = (_l = styleParam === null || styleParam === void 0 ? void 0 : styleParam.style) !== null && _l !== void 0 ? _l : "bar";
1863
+ const iconParam = element.params.find(x => isIconParam(x));
1864
+ const icon = (_m = iconParam === null || iconParam === void 0 ? void 0 : iconParam.value) !== null && _m !== void 0 ? _m : undefined;
1865
+ const minParam = element.params.find(x => isNumberParamMin(x));
1866
+ const disableMin = (minParam === null || minParam === void 0 ? void 0 : minParam.value) != undefined;
1867
+ let hideMin = false;
1868
+ const valueParam = element.params.find(x => isNumberParamValue(x));
1869
+ const disableValue = (valueParam === null || valueParam === void 0 ? void 0 : valueParam.value) != undefined;
1870
+ const maxParam = element.params.find(x => isNumberParamMax(x));
1871
+ const disableMax = (maxParam === null || maxParam === void 0 ? void 0 : maxParam.value) != undefined;
1872
+ const colorParam = element.params.find(x => isColorParam(x));
1873
+ const primaryColor = colorParam ? `'${colorParam.value}'` : "primaryColor";
1874
+ const segmentParm = element.params.find(x => isSegmentsParameter(x));
1875
+ const segments = (_o = segmentParm === null || segmentParm === void 0 ? void 0 : segmentParm.segments) !== null && _o !== void 0 ? _o : 1;
1876
+ let isHealth = false;
1877
+ let isWounds = false;
1878
+ if (isResourceExp(element)) {
1879
+ hideMin = true;
1880
+ isHealth = element.tag == "health";
1881
+ isWounds = element.tag == "wounds";
1882
+ }
1883
+ return expandToNode `
1785
1884
  <i-tracker
1786
1885
  label="${label}"
1787
1886
  systemPath="system.${element.name.toLowerCase()}" :context="context"
@@ -1799,9 +1898,9 @@ function generateVueComponentTemplate(entry, id, document) {
1799
1898
  :isWounds="${isWounds}"
1800
1899
  ></i-tracker>
1801
1900
  `;
1802
- }
1803
- if (isSingleDocumentExp(element)) {
1804
- return expandToNode `
1901
+ }
1902
+ if (isSingleDocumentExp(element)) {
1903
+ return expandToNode `
1805
1904
  <i-document-link
1806
1905
  label="${label}"
1807
1906
  icon="${iconParam === null || iconParam === void 0 ? void 0 : iconParam.value}"
@@ -1812,9 +1911,9 @@ function generateVueComponentTemplate(entry, id, document) {
1812
1911
  :secondaryColor="secondaryColor">
1813
1912
  </i-document-link>
1814
1913
  `;
1815
- }
1816
- if (isDateExp(element)) {
1817
- return expandToNode `
1914
+ }
1915
+ if (isDateExp(element)) {
1916
+ return expandToNode `
1818
1917
  <i-datetime
1819
1918
  type="date"
1820
1919
  label="${label}"
@@ -1825,9 +1924,9 @@ function generateVueComponentTemplate(entry, id, document) {
1825
1924
  :primaryColor="primaryColor" :secondaryColor="secondaryColor">
1826
1925
  </i-datetime>
1827
1926
  `;
1828
- }
1829
- if (isTimeExp(element)) {
1830
- return expandToNode `
1927
+ }
1928
+ if (isTimeExp(element)) {
1929
+ return expandToNode `
1831
1930
  <i-datetime
1832
1931
  type="time"
1833
1932
  label="${label}"
@@ -1838,9 +1937,9 @@ function generateVueComponentTemplate(entry, id, document) {
1838
1937
  :primaryColor="primaryColor" :secondaryColor="secondaryColor">
1839
1938
  </i-datetime>
1840
1939
  `;
1841
- }
1842
- if (isDateTimeExp(element)) {
1843
- return expandToNode `
1940
+ }
1941
+ if (isDateTimeExp(element)) {
1942
+ return expandToNode `
1844
1943
  <i-datetime
1845
1944
  type="datetime-local"
1846
1945
  label="${label}"
@@ -1851,13 +1950,13 @@ function generateVueComponentTemplate(entry, id, document) {
1851
1950
  :primaryColor="primaryColor" :secondaryColor="secondaryColor">
1852
1951
  </i-datetime>
1853
1952
  `;
1854
- }
1855
- if (isPaperDollExp(element)) {
1856
- let sizeParam = element.params.find(x => isSizeParam(x));
1857
- let size = (_q = sizeParam === null || sizeParam === void 0 ? void 0 : sizeParam.value) !== null && _q !== void 0 ? _q : "40px";
1858
- let imageParam = element.params.find(x => isImageParam(x));
1859
- let image = (_r = imageParam === null || imageParam === void 0 ? void 0 : imageParam.value) !== null && _r !== void 0 ? _r : `systems/${id}/img/paperdoll_default.png`;
1860
- return expandToNode `
1953
+ }
1954
+ if (isPaperDollExp(element)) {
1955
+ let sizeParam = element.params.find(x => isSizeParam(x));
1956
+ let size = (_q = sizeParam === null || sizeParam === void 0 ? void 0 : sizeParam.value) !== null && _q !== void 0 ? _q : "40px";
1957
+ let imageParam = element.params.find(x => isImageParam(x));
1958
+ let image = (_r = imageParam === null || imageParam === void 0 ? void 0 : imageParam.value) !== null && _r !== void 0 ? _r : `systems/${id}/img/paperdoll_default.png`;
1959
+ return expandToNode `
1861
1960
  <i-paperdoll
1862
1961
  label="${label}"
1863
1962
  icon="${iconParam === null || iconParam === void 0 ? void 0 : iconParam.value}"
@@ -1869,14 +1968,14 @@ function generateVueComponentTemplate(entry, id, document) {
1869
1968
  :slots="${element.name.toLowerCase()}Slots">
1870
1969
  </i-paperdoll>
1871
1970
  `;
1872
- }
1873
- if (isDiceFields(element)) {
1874
- let choicesParam = element.params.find(x => isDieChoicesParam(x));
1875
- let choices = choicesParam ? `[${choicesParam.choices.join(", ")}]` : "[ 'd4', 'd6', 'd8', 'd10', 'd12', 'd20' ]";
1876
- let noneParam = element.params.find(x => isDieNoneParam(x));
1877
- let noneAttr = (noneParam === null || noneParam === void 0 ? void 0 : noneParam.value) ? `:none="true"` : '';
1878
- if (isDieField(element)) {
1879
- return expandToNode `
1971
+ }
1972
+ if (isDiceFields(element)) {
1973
+ let choicesParam = element.params.find(x => isDieChoicesParam(x));
1974
+ let choices = choicesParam ? `[${choicesParam.choices.join(", ")}]` : "[ 'd4', 'd6', 'd8', 'd10', 'd12', 'd20' ]";
1975
+ let noneParam = element.params.find(x => isDieNoneParam(x));
1976
+ let noneAttr = (noneParam === null || noneParam === void 0 ? void 0 : noneParam.value) ? `:none="true"` : '';
1977
+ if (isDieField(element)) {
1978
+ return expandToNode `
1880
1979
  <i-die
1881
1980
  :context="context"
1882
1981
  label="${label}"
@@ -1887,9 +1986,9 @@ function generateVueComponentTemplate(entry, id, document) {
1887
1986
  ${standardParamsFragment}>
1888
1987
  </i-die>
1889
1988
  `;
1890
- }
1891
- if (isDiceField(element)) {
1892
- return expandToNode `
1989
+ }
1990
+ if (isDiceField(element)) {
1991
+ return expandToNode `
1893
1992
  <i-dice
1894
1993
  label="${label}"
1895
1994
  icon="${iconParam === null || iconParam === void 0 ? void 0 : iconParam.value}"
@@ -1903,113 +2002,113 @@ function generateVueComponentTemplate(entry, id, document) {
1903
2002
  :secondaryColor="secondaryColor"
1904
2003
  />
1905
2004
  `;
2005
+ }
1906
2006
  }
1907
- }
1908
- if (isTableField(element)) {
1909
- if (isTopLevel)
1910
- return expandToNode ``;
1911
- const page = AstUtils.getContainerOfType(element, isPage);
1912
- const pageName = (_s = page === null || page === void 0 ? void 0 : page.name) !== null && _s !== void 0 ? _s : document.name;
1913
- const systemPath = getSystemPath(element, [], undefined, false);
1914
- let componentName = `${document.name}${pageName}${element.name}VuetifyDatatable`;
1915
- // Wrap in a drop zone so drag-drop works for tables inside a row/column.
1916
- // Tables rendered as their own tab are wrapped in .tabs-container (the
1917
- // sheet's drop target); layout-rendered tables aren't, so without this
1918
- // wrapper they have no drop target. The wrapper only exists in the layout
1919
- // case (never nested inside a .tabs-container), so no double drop binding.
1920
- return expandToNode `
2007
+ if (isTableField(element)) {
2008
+ if (isTopLevel)
2009
+ return expandToNode ``;
2010
+ const page = AstUtils.getContainerOfType(element, isPage);
2011
+ const pageName = (_s = page === null || page === void 0 ? void 0 : page.name) !== null && _s !== void 0 ? _s : document.name;
2012
+ const systemPath = getSystemPath(element, [], undefined, false);
2013
+ let componentName = `${document.name}${pageName}${element.name}VuetifyDatatable`;
2014
+ // Wrap in a drop zone so drag-drop works for tables inside a row/column.
2015
+ // Tables rendered as their own tab are wrapped in .tabs-container (the
2016
+ // sheet's drop target); layout-rendered tables aren't, so without this
2017
+ // wrapper they have no drop target. The wrapper only exists in the layout
2018
+ // case (never nested inside a .tabs-container), so no double drop binding.
2019
+ return expandToNode `
1921
2020
  <div class="datatable-drop-zone" v-if="!isHidden('${element.name.toLowerCase()}')">
1922
2021
  <${componentName} systemPath="${systemPath}" :context="context" :primaryColor="primaryColor" :secondaryColor="secondaryColor" :tertiaryColor="tertiaryColor"></${componentName}>
1923
2022
  </div>
1924
2023
  `.appendNewLine();
1925
- }
1926
- if (isInventoryField(element)) {
1927
- if (isTopLevel)
1928
- return expandToNode ``;
1929
- const systemPath = getSystemPath(element, [], undefined, false);
1930
- const iconParam = element.params.find(p => isIconParam(p));
1931
- const labelParam = element.params.find(p => isLabelParam(p));
1932
- const slotsParam = element.params.find(isInventorySlotsParam);
1933
- const rowsParam = element.params.find(isInventoryRowsParam);
1934
- const columnsParam = element.params.find(isInventoryColumnsParam);
1935
- const slotSizeParam = element.params.find(isInventorySlotSizeParam);
1936
- const quantityParam = element.params.find(isInventoryQuantityParam);
1937
- const moneyParam = element.params.find(isInventoryMoneyParam);
1938
- const sumParam = element.params.find(isInventorySumParam);
1939
- const sumMaxParam = element.params.find(isInventorySumMaxParam);
1940
- const sortParam = element.params.find(isInventorySortParam);
1941
- const whereParam = element.params.find(isWhereParam);
1942
- const globalParam = element.params.find(isGlobalParam);
1943
- const emptySlotsParam = element.params.find(isInventoryEmptySlotsParam);
1944
- const summaryParam = element.params.find(isInventorySummaryParam);
1945
- const label = labelParam ? labelParam.value : `${document.name}.${element.name}`;
1946
- const icon = iconParam === null || iconParam === void 0 ? void 0 : iconParam.value;
1947
- const slots = (_t = slotsParam === null || slotsParam === void 0 ? void 0 : slotsParam.value) !== null && _t !== void 0 ? _t : 20;
1948
- const rows = rowsParam === null || rowsParam === void 0 ? void 0 : rowsParam.value;
1949
- const columns = columnsParam === null || columnsParam === void 0 ? void 0 : columnsParam.value;
1950
- const slotSize = slotSizeParam ? parseInt(slotSizeParam.value.replace('px', '')) : 60;
1951
- const documentType = (_u = element.document.ref) === null || _u === void 0 ? void 0 : _u.name.toLowerCase();
1952
- const quantityField = (_v = quantityParam === null || quantityParam === void 0 ? void 0 : quantityParam.field.ref) === null || _v === void 0 ? void 0 : _v.name.toLowerCase();
1953
- const moneyField = (_w = moneyParam === null || moneyParam === void 0 ? void 0 : moneyParam.field.ref) === null || _w === void 0 ? void 0 : _w.name.toLowerCase();
1954
- const moneyFieldLabel = moneyField ? `${document.name}.${(_y = (_x = moneyParam === null || moneyParam === void 0 ? void 0 : moneyParam.field) === null || _x === void 0 ? void 0 : _x.ref) === null || _y === void 0 ? void 0 : _y.name}` : undefined;
1955
- const moneyFieldIcon = moneyField ? (_1 = (_0 = (_z = moneyParam === null || moneyParam === void 0 ? void 0 : moneyParam.field) === null || _z === void 0 ? void 0 : _z.ref) === null || _0 === void 0 ? void 0 : _0.params.find(isIconParam)) === null || _1 === void 0 ? void 0 : _1.value : undefined;
1956
- const sortProperty = (_2 = sortParam === null || sortParam === void 0 ? void 0 : sortParam.property.ref) === null || _2 === void 0 ? void 0 : _2.name;
1957
- const sortOrder = (_3 = sortParam === null || sortParam === void 0 ? void 0 : sortParam.order) !== null && _3 !== void 0 ? _3 : 'asc';
1958
- const globalAllowed = (_4 = globalParam === null || globalParam === void 0 ? void 0 : globalParam.value) !== null && _4 !== void 0 ? _4 : false;
1959
- const emptySlots = (_5 = emptySlotsParam === null || emptySlotsParam === void 0 ? void 0 : emptySlotsParam.value) !== null && _5 !== void 0 ? _5 : 'show';
1960
- const summary = (_6 = summaryParam === null || summaryParam === void 0 ? void 0 : summaryParam.value) !== null && _6 !== void 0 ? _6 : 'full';
1961
- // Handle sum properties (can be single or array)
1962
- let sumProperties = [];
1963
- if (sumParam) {
1964
- if (sumParam.properties.property) {
1965
- sumProperties = [((_7 = sumParam.properties.property.ref) === null || _7 === void 0 ? void 0 : _7.name) || ''];
1966
- }
1967
- else if (sumParam.properties.properties) {
1968
- sumProperties = sumParam.properties.properties
1969
- .map(p => { var _a; return ((_a = p.ref) === null || _a === void 0 ? void 0 : _a.name) || ''; })
1970
- .filter(n => n !== '');
1971
- }
1972
2024
  }
1973
- // Handle sumMax (can be int, expression, or array of ints/expressions)
1974
- let sumMax = undefined;
1975
- if (sumMaxParam) {
1976
- if (sumMaxParam.value !== undefined) {
1977
- // It's a single INT
1978
- sumMax = String(sumMaxParam.value);
1979
- }
1980
- else if (sumMaxParam.expression) {
1981
- // It's a single expression (like self.CarryCapacity), translate it
1982
- const sumMaxNode = translateExpression(entry, id, sumMaxParam.expression);
1983
- if (sumMaxNode) {
1984
- // Prefix with context. so it evaluates correctly in Vue template
1985
- sumMax = `context.${toString(sumMaxNode)}`;
2025
+ if (isInventoryField(element)) {
2026
+ if (isTopLevel)
2027
+ return expandToNode ``;
2028
+ const systemPath = getSystemPath(element, [], undefined, false);
2029
+ const iconParam = element.params.find(p => isIconParam(p));
2030
+ const labelParam = element.params.find(p => isLabelParam(p));
2031
+ const slotsParam = element.params.find(isInventorySlotsParam);
2032
+ const rowsParam = element.params.find(isInventoryRowsParam);
2033
+ const columnsParam = element.params.find(isInventoryColumnsParam);
2034
+ const slotSizeParam = element.params.find(isInventorySlotSizeParam);
2035
+ const quantityParam = element.params.find(isInventoryQuantityParam);
2036
+ const moneyParam = element.params.find(isInventoryMoneyParam);
2037
+ const sumParam = element.params.find(isInventorySumParam);
2038
+ const sumMaxParam = element.params.find(isInventorySumMaxParam);
2039
+ const sortParam = element.params.find(isInventorySortParam);
2040
+ const whereParam = element.params.find(isWhereParam);
2041
+ const globalParam = element.params.find(isGlobalParam);
2042
+ const emptySlotsParam = element.params.find(isInventoryEmptySlotsParam);
2043
+ const summaryParam = element.params.find(isInventorySummaryParam);
2044
+ const label = labelParam ? labelParam.value : `${document.name}.${element.name}`;
2045
+ const icon = iconParam === null || iconParam === void 0 ? void 0 : iconParam.value;
2046
+ const slots = (_t = slotsParam === null || slotsParam === void 0 ? void 0 : slotsParam.value) !== null && _t !== void 0 ? _t : 20;
2047
+ const rows = rowsParam === null || rowsParam === void 0 ? void 0 : rowsParam.value;
2048
+ const columns = columnsParam === null || columnsParam === void 0 ? void 0 : columnsParam.value;
2049
+ const slotSize = slotSizeParam ? parseInt(slotSizeParam.value.replace('px', '')) : 60;
2050
+ const documentType = (_u = element.document.ref) === null || _u === void 0 ? void 0 : _u.name.toLowerCase();
2051
+ const quantityField = (_v = quantityParam === null || quantityParam === void 0 ? void 0 : quantityParam.field.ref) === null || _v === void 0 ? void 0 : _v.name.toLowerCase();
2052
+ const moneyField = (_w = moneyParam === null || moneyParam === void 0 ? void 0 : moneyParam.field.ref) === null || _w === void 0 ? void 0 : _w.name.toLowerCase();
2053
+ const moneyFieldLabel = moneyField ? `${document.name}.${(_y = (_x = moneyParam === null || moneyParam === void 0 ? void 0 : moneyParam.field) === null || _x === void 0 ? void 0 : _x.ref) === null || _y === void 0 ? void 0 : _y.name}` : undefined;
2054
+ const moneyFieldIcon = moneyField ? (_1 = (_0 = (_z = moneyParam === null || moneyParam === void 0 ? void 0 : moneyParam.field) === null || _z === void 0 ? void 0 : _z.ref) === null || _0 === void 0 ? void 0 : _0.params.find(isIconParam)) === null || _1 === void 0 ? void 0 : _1.value : undefined;
2055
+ const sortProperty = (_2 = sortParam === null || sortParam === void 0 ? void 0 : sortParam.property.ref) === null || _2 === void 0 ? void 0 : _2.name;
2056
+ const sortOrder = (_3 = sortParam === null || sortParam === void 0 ? void 0 : sortParam.order) !== null && _3 !== void 0 ? _3 : 'asc';
2057
+ const globalAllowed = (_4 = globalParam === null || globalParam === void 0 ? void 0 : globalParam.value) !== null && _4 !== void 0 ? _4 : false;
2058
+ const emptySlots = (_5 = emptySlotsParam === null || emptySlotsParam === void 0 ? void 0 : emptySlotsParam.value) !== null && _5 !== void 0 ? _5 : 'show';
2059
+ const summary = (_6 = summaryParam === null || summaryParam === void 0 ? void 0 : summaryParam.value) !== null && _6 !== void 0 ? _6 : 'full';
2060
+ // Handle sum properties (can be single or array)
2061
+ let sumProperties = [];
2062
+ if (sumParam) {
2063
+ if (sumParam.properties.property) {
2064
+ sumProperties = [((_7 = sumParam.properties.property.ref) === null || _7 === void 0 ? void 0 : _7.name) || ''];
2065
+ }
2066
+ else if (sumParam.properties.properties) {
2067
+ sumProperties = sumParam.properties.properties
2068
+ .map(p => { var _a; return ((_a = p.ref) === null || _a === void 0 ? void 0 : _a.name) || ''; })
2069
+ .filter(n => n !== '');
1986
2070
  }
1987
2071
  }
1988
- else if ((_8 = sumMaxParam.values) === null || _8 === void 0 ? void 0 : _8.values) {
1989
- // It's an array of ints/expressions
1990
- const maxValues = sumMaxParam.values.values.map((val) => {
1991
- if (typeof val === 'number') {
1992
- return String(val);
2072
+ // Handle sumMax (can be int, expression, or array of ints/expressions)
2073
+ let sumMax = undefined;
2074
+ if (sumMaxParam) {
2075
+ if (sumMaxParam.value !== undefined) {
2076
+ // It's a single INT
2077
+ sumMax = String(sumMaxParam.value);
2078
+ }
2079
+ else if (sumMaxParam.expression) {
2080
+ // It's a single expression (like self.CarryCapacity), translate it
2081
+ const sumMaxNode = translateExpression(entry, id, sumMaxParam.expression);
2082
+ if (sumMaxNode) {
2083
+ // Prefix with context. so it evaluates correctly in Vue template
2084
+ sumMax = `context.${toString(sumMaxNode)}`;
1993
2085
  }
1994
- else {
1995
- // It's an expression, translate it
1996
- const valNode = translateExpression(entry, id, val);
1997
- if (valNode) {
1998
- return `context.${toString(valNode)}`;
2086
+ }
2087
+ else if ((_8 = sumMaxParam.values) === null || _8 === void 0 ? void 0 : _8.values) {
2088
+ // It's an array of ints/expressions
2089
+ const maxValues = sumMaxParam.values.values.map((val) => {
2090
+ if (typeof val === 'number') {
2091
+ return String(val);
1999
2092
  }
2000
- return '0';
2001
- }
2002
- });
2003
- sumMax = `[${maxValues.join(', ')}]`;
2093
+ else {
2094
+ // It's an expression, translate it
2095
+ const valNode = translateExpression(entry, id, val);
2096
+ if (valNode) {
2097
+ return `context.${toString(valNode)}`;
2098
+ }
2099
+ return '0';
2100
+ }
2101
+ });
2102
+ sumMax = `[${maxValues.join(', ')}]`;
2103
+ }
2004
2104
  }
2005
- }
2006
- // Handle where expression
2007
- let whereExpression = undefined;
2008
- if (whereParam) {
2009
- const whereNode = translateExpression(entry, id, whereParam.value);
2010
- whereExpression = whereNode ? toString(whereNode) : undefined;
2011
- }
2012
- return expandToNode `
2105
+ // Handle where expression
2106
+ let whereExpression = undefined;
2107
+ if (whereParam) {
2108
+ const whereNode = translateExpression(entry, id, whereParam.value);
2109
+ whereExpression = whereNode ? toString(whereNode) : undefined;
2110
+ }
2111
+ return expandToNode `
2013
2112
  <i-inventory
2014
2113
  v-if="!isHidden('${element.name.toLowerCase()}')"
2015
2114
  label="${label}"
@@ -2039,14 +2138,37 @@ function generateVueComponentTemplate(entry, id, document) {
2039
2138
  :tertiaryColor="tertiaryColor"
2040
2139
  />
2041
2140
  `.appendNewLine();
2042
- }
2043
- return expandToNode `
2141
+ }
2142
+ return expandToNode `
2044
2143
  <v-alert text="Unknown Property ${element.name}" type="warning" density="compact" class="ga-2 ma-1" variant="outlined"></v-alert>
2045
2144
  `;
2145
+ })();
2146
+ return injectFieldMarker(fieldComponent, element);
2046
2147
  }
2047
2148
  return expandToNode `
2048
2149
  <v-alert text="Unknown Element" type="warning" density="compact" class="ga-2 ma-1" variant="outlined"></v-alert>
2049
2150
  `;
2050
2151
  }
2152
+ // Stamp the universal field marker onto a rendered field's <i-...> component root (the
2153
+ // element that also carries the type + single/double-wide classes via attribute fallthrough).
2154
+ // `.isdl-field` is the one selector theme-token consumption targets; `.isdl-field-<name>` is
2155
+ // the per-field hook + the target a per-field theme override is emitted against.
2156
+ function injectFieldMarker(node, element) {
2157
+ const html = toString(node);
2158
+ const marker = `isdl-field isdl-field-${element.name.toLowerCase()}`;
2159
+ // Stamp the marker onto the FIRST element tag of the rendered field, whatever its name --
2160
+ // <i-number>, a datatable <div class="datatable-drop-zone">, a <DocumentChoice> component,
2161
+ // etc. Insert right after the tag NAME so attribute values (which can contain '>') are never
2162
+ // parsed. If that tag already leads with a `class` attribute, merge into it (no double class).
2163
+ const tag = html.match(/<([A-Za-z][\w.-]*)/);
2164
+ if ((tag === null || tag === void 0 ? void 0 : tag.index) === undefined)
2165
+ return node;
2166
+ const insertAt = tag.index + tag[0].length;
2167
+ const rest = html.slice(insertAt);
2168
+ const injected = /^\s+class="/.test(rest)
2169
+ ? html.slice(0, insertAt) + rest.replace(/^(\s+class=")/, `$1${marker} `)
2170
+ : html.slice(0, insertAt) + ` class="${marker}"` + rest;
2171
+ return expandToNode `${injected}`;
2172
+ }
2051
2173
  }
2052
2174
  //# sourceMappingURL=vue-sheet-application-generator.js.map