@cratis/event-models 0.338.0 → 0.339.1

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 (68) hide show
  1. package/dist/screen-editor/{BindingExpressionPropertyEditor-CcIqajvT.js → BindingExpressionPropertyEditor-D63oFTJg.js} +1 -1
  2. package/dist/screen-editor/DataBindingSections-DGWtMxlD.js +1859 -0
  3. package/dist/screen-editor/HookEditors-vV4ycK6R.js +37 -0
  4. package/dist/screen-editor/HookOpensField-Ja5uMCr8.js +231 -0
  5. package/dist/screen-editor/QueryBindingPropertyEditor-QpvyESab.js +148 -0
  6. package/dist/screen-editor/ScreenEditor/Actions/ActionModel.d.ts +3 -1
  7. package/dist/screen-editor/ScreenEditor/Actions/StateChangeSlice.d.ts +4 -0
  8. package/dist/screen-editor/ScreenEditor/Actions/actionBehavior.d.ts +3 -1
  9. package/dist/screen-editor/ScreenEditor/Binding/detailShows.d.ts +18 -0
  10. package/dist/screen-editor/ScreenEditor/Binding/parameterFeeds.d.ts +22 -0
  11. package/dist/screen-editor/ScreenEditor/Binding/queryBindingModel.d.ts +1 -0
  12. package/dist/screen-editor/ScreenEditor/Data/DataField.d.ts +39 -0
  13. package/dist/screen-editor/ScreenEditor/Data/insertDataField.d.ts +29 -0
  14. package/dist/screen-editor/ScreenEditor/Data/queryTables.d.ts +10 -0
  15. package/dist/screen-editor/ScreenEditor/DesignMode/DesignModeFrames.d.ts +3 -1
  16. package/dist/screen-editor/ScreenEditor/DesignMode/DesignModeStrings.d.ts +2 -0
  17. package/dist/screen-editor/ScreenEditor/DesignMode/Outlets/OutletStrings.d.ts +74 -0
  18. package/dist/screen-editor/ScreenEditor/DesignMode/Outlets/createOutletDesign.d.ts +34 -0
  19. package/dist/screen-editor/ScreenEditor/DesignMode/Outlets/outletBindings.d.ts +23 -0
  20. package/dist/screen-editor/ScreenEditor/DesignMode/Outlets/outletDesignModes.d.ts +6 -0
  21. package/dist/screen-editor/ScreenEditor/DesignMode/Outlets/outletDocument.d.ts +15 -0
  22. package/dist/screen-editor/ScreenEditor/DesignMode/Outlets/outletItemOps.d.ts +11 -0
  23. package/dist/screen-editor/ScreenEditor/DesignMode/Outlets/screenOutletChain.d.ts +18 -0
  24. package/dist/screen-editor/ScreenEditor/DesignMode/Outlets/screenOutlets.d.ts +44 -0
  25. package/dist/screen-editor/ScreenEditor/DesignMode/designModeTypes.d.ts +19 -2
  26. package/dist/screen-editor/ScreenEditor/DesignMode/resolveDesignMode.d.ts +2 -0
  27. package/dist/screen-editor/ScreenEditor/DesignMode/useDesignMode.d.ts +2 -0
  28. package/dist/screen-editor/ScreenEditor/Forms/fieldChoices.d.ts +14 -0
  29. package/dist/screen-editor/ScreenEditor/Forms/fieldMarkers.d.ts +8 -0
  30. package/dist/screen-editor/ScreenEditor/Host/ScreenEditorController.d.ts +22 -0
  31. package/dist/screen-editor/ScreenEditor/Host/ScreenEditorHost.d.ts +11 -0
  32. package/dist/screen-editor/ScreenEditor/Host/ScreenEditorWindow.d.ts +2 -1
  33. package/dist/screen-editor/ScreenEditor/Host/openSubject.d.ts +2 -1
  34. package/dist/screen-editor/ScreenEditor/Inspector/ActionEditor.d.ts +3 -1
  35. package/dist/screen-editor/ScreenEditor/Inspector/CommandFormEditor.d.ts +3 -2
  36. package/dist/screen-editor/ScreenEditor/Inspector/DataBindingSections.d.ts +23 -0
  37. package/dist/screen-editor/ScreenEditor/Inspector/FormEditor.d.ts +3 -2
  38. package/dist/screen-editor/ScreenEditor/Inspector/OutletListEditor.d.ts +11 -0
  39. package/dist/screen-editor/ScreenEditor/Inspector/OutletSection.d.ts +12 -0
  40. package/dist/screen-editor/ScreenEditor/Inspector/ScreenEditorStrings.d.ts +31 -0
  41. package/dist/screen-editor/ScreenEditor/Inspector/ScreenOutletsSection.d.ts +9 -0
  42. package/dist/screen-editor/ScreenEditor/Palette/PaletteEntry.d.ts +4 -0
  43. package/dist/screen-editor/ScreenEditor/Placement/HookEnabledField.d.ts +14 -0
  44. package/dist/screen-editor/ScreenEditor/Placement/HookOpensField.d.ts +10 -0
  45. package/dist/screen-editor/ScreenEditor/Placement/PlacementStrings.d.ts +32 -0
  46. package/dist/screen-editor/ScreenEditor/Placement/hookBinding.d.ts +28 -0
  47. package/dist/screen-editor/ScreenEditor/Placement/hookPlacement.d.ts +27 -0
  48. package/dist/screen-editor/ScreenEditor/Placement/opensOptions.d.ts +16 -0
  49. package/dist/screen-editor/ScreenEditor/Placement/placementEnvironment.d.ts +12 -0
  50. package/dist/screen-editor/ScreenEditor/PropertyEditors/Registry/PropertyEditorProps.d.ts +2 -0
  51. package/dist/screen-editor/ScreenEditor/PropertyEditors/Registry/PropertyEditorStrings.d.ts +2 -0
  52. package/dist/screen-editor/ScreenEditor/PropertyEditors/Specific/HookEditors.d.ts +4 -0
  53. package/dist/screen-editor/ScreenEditor/PropertyEditors/Specific/QueryBindingPropertyEditor.d.ts +1 -1
  54. package/dist/screen-editor/ScreenEditor/Surface/ScreenSurface.d.ts +1 -1
  55. package/dist/screen-editor/ScreenEditor/Surface/columnAt.d.ts +6 -0
  56. package/dist/screen-editor/ScreenEditor/Surface/useSurfaceDrop.d.ts +1 -1
  57. package/dist/screen-editor/ScreenEditor/Templates/composeEditorScreen.d.ts +5 -1
  58. package/dist/screen-editor/ScreenEditor/Templates/dialogActionsChrome.d.ts +9 -0
  59. package/dist/screen-editor/ScreenEditor/Templates/slotSections.d.ts +1 -0
  60. package/dist/screen-editor/defaultStructuredEditorStrings-Bwbw58wD.js +116 -0
  61. package/dist/screen-editor/hookBinding-DOpu2dMp.js +171 -0
  62. package/dist/screen-editor/index.js +5478 -4935
  63. package/dist/screen-editor/sceneTree-CNx3I3MJ.js +32 -0
  64. package/dist/screen-editor/screen-editor.css +1 -1
  65. package/package.json +3 -3
  66. package/dist/screen-editor/QueryBindingEditor-MTd0R7iQ.js +0 -40
  67. package/dist/screen-editor/QueryBindingPropertyEditor-Cu4PTcOz.js +0 -169
  68. package/dist/screen-editor/defaultStructuredEditorStrings-BPl2XP8A.js +0 -144
@@ -0,0 +1,1859 @@
1
+ import { r as Ye, t as Ge } from "./sceneTree-CNx3I3MJ.js";
2
+ import { a as Je, c as Ze, i as Xe, n as et, r as tt, t as nt } from "./hookBinding-DOpu2dMp.js";
3
+ import { useMemo as M } from "react";
4
+ import { Fragment as rt, jsx as T, jsxs as _ } from "react/jsx-runtime";
5
+ import { EditingScopeKind as oe, FilterControl as se, HorizontalAlignment as ot, OutletItemKind as O, OutletKind as E, OutletMode as R, OutletSubject as st, PropertyEditorKind as K, PropertyValueType as F, QueryResultShape as Ce, SceneEditKind as it, ScreenFit as Oe, ValueSource as ce, VerticalAlignment as at, Visibility as lt, componentIcon as je, dialogActionsOutletName as $e } from "@cratis/scene.model";
6
+ import { NavigationEditKind as Se, OutletDiagnosticCode as dt, OutletItemSource as we, OutletLevelKind as $, OutletRemoval as ct, addNavigationItem as ut, applicationNavigationLevel as mt, diagnoseNavigationOutlets as pt, dialogTemplateOutlets as ft, effectiveNavigation as ht, effectiveOutlet as gt, elementNodeId as vt, findComponentDescriptor as bt, isExternalComponent as yt, outletChainOf as Ot, outletItemsComponentName as Ee, ownOutletItems as St, switchOutletMode as wt } from "@cratis/scene.engine";
7
+ import { itemEditableRule as Fe, itemInheritedReason as xe, navigationDesignMode as kt, toolbarDesignMode as It } from "@cratis/scene.react";
8
+ var ue = {
9
+ name: "StudioScreen",
10
+ slots: [{ name: "content" }]
11
+ }, P = "content", q = "Screen", Un = "template-root", zn = "screen-root", Me = () => ({
12
+ layouts: [ue],
13
+ screenTemplates: [],
14
+ dialogTemplates: [],
15
+ screens: [],
16
+ exposures: [],
17
+ instanceContributions: []
18
+ });
19
+ function Kn(e, t) {
20
+ return {
21
+ ...Me(),
22
+ screens: [{
23
+ name: q,
24
+ layout: ue.name,
25
+ slotContent: { [P]: [e] },
26
+ forms: [],
27
+ contributions: [],
28
+ ...t ? { screenTemplate: t } : {}
29
+ }]
30
+ };
31
+ }
32
+ function Qn(e, t, n) {
33
+ return {
34
+ ...Me(),
35
+ screenTemplates: [{
36
+ name: e,
37
+ slots: [{ name: P }],
38
+ content: { [P]: [t] },
39
+ ...n ? { fitsSlot: n } : {}
40
+ }]
41
+ };
42
+ }
43
+ function Yn(e, t) {
44
+ return (t === void 0 ? e.screens.find((n) => n.name === q)?.slotContent : e.screenTemplates.find((n) => n.name === t)?.content)?.[P]?.[0];
45
+ }
46
+ function Gn(e, t = !1) {
47
+ return t && e !== void 0 ? {
48
+ kind: oe.ScreenTemplate,
49
+ name: e,
50
+ layout: ue.name
51
+ } : {
52
+ kind: oe.Screen,
53
+ name: q
54
+ };
55
+ }
56
+ function Jn(e) {
57
+ return { types: e };
58
+ }
59
+ var Zn = ({ diagnostics: e, label: t }) => {
60
+ if (e.length === 0) return null;
61
+ const n = [...e].sort((r, o) => +(o.severity === "error") - +(r.severity === "error"));
62
+ return /* @__PURE__ */ T("div", {
63
+ className: "studio-editor-diagnostics__announce",
64
+ role: "alert",
65
+ "aria-label": t,
66
+ children: /* @__PURE__ */ T("ul", {
67
+ className: "studio-editor-diagnostics",
68
+ children: n.map((r, o) => /* @__PURE__ */ _("li", {
69
+ "data-severity": r.severity,
70
+ "data-code": r.code,
71
+ children: [
72
+ r.severityLabel && /* @__PURE__ */ T("strong", {
73
+ className: "studio-editor-diagnostics__severity",
74
+ children: r.severityLabel
75
+ }),
76
+ /* @__PURE__ */ T("span", {
77
+ className: "studio-editor-diagnostics__message",
78
+ children: r.message
79
+ }),
80
+ r.where && /* @__PURE__ */ T("span", {
81
+ className: "studio-editor-diagnostics__where",
82
+ children: r.where
83
+ }),
84
+ r.jump && /* @__PURE__ */ T("button", {
85
+ type: "button",
86
+ className: "studio-editor-diagnostics__jump",
87
+ onClick: r.jump.onJump,
88
+ children: r.jump.label
89
+ })
90
+ ]
91
+ }, `${r.code}:${r.path ?? ""}:${o}`))
92
+ })
93
+ });
94
+ }, Re = () => globalThis.crypto.randomUUID(), Tt = {
95
+ kinds: {
96
+ actions: "actions",
97
+ filters: "filters",
98
+ tabs: "tabs",
99
+ stats: "stats",
100
+ navigation: "navigation"
101
+ },
102
+ newItem: {
103
+ button: "New button",
104
+ filter: "New filter",
105
+ tab: "New tab",
106
+ stat: "New stat",
107
+ navigation: "New item",
108
+ menuEntry: "New entry",
109
+ separator: "Separator",
110
+ group: "New group"
111
+ },
112
+ frameName: (e, t) => `outlet ${e} · ${t}`,
113
+ tagLong: (e, t) => `${e} · ${t}`,
114
+ title: (e, t) => `Outlet · ${e} ${t}`,
115
+ declaredBy: (e) => `From ${e}.`,
116
+ editingAs: "Editing as",
117
+ levels: {
118
+ module: "module",
119
+ feature: "feature",
120
+ slice: "slice",
121
+ screen: "screen",
122
+ template: "template",
123
+ layout: "layout"
124
+ },
125
+ levelName: (e, t) => `${e} ${t}`,
126
+ everyScreenBelow: (e) => `Every screen in ${e} gets this.`,
127
+ modeTitle: "How this level takes the outlet",
128
+ modes: {
129
+ inherit: {
130
+ title: "Inherit",
131
+ description: (e) => `${e}'s items, unchanged.`
132
+ },
133
+ extend: {
134
+ title: "Extend",
135
+ description: (e) => `${e}'s items, then yours. Hide the ones you don't want.`
136
+ },
137
+ override: {
138
+ title: "Override",
139
+ description: (e) => `Only your items. ${e}'s stay listed, struck through, so you can bring one back.`
140
+ }
141
+ },
142
+ copyPrompt: "Copy the inherited items, so you start from them?",
143
+ copyYes: "Copy them",
144
+ copyNo: "Start empty",
145
+ extendsNotice: "This level now extends the inherited items",
146
+ items: "Items",
147
+ add: (e) => `Add ${e}`,
148
+ own: "yours",
149
+ fromLevel: (e) => `from ${e}`,
150
+ contributedBy: (e) => `contributed by ${e}`,
151
+ hiddenHere: "hidden here",
152
+ overriddenHere: "overridden here",
153
+ hide: "Hide",
154
+ bringBack: "Bring back",
155
+ contributionNote: "Contributed items belong to the feature that adds them; they always come after the inherited items.",
156
+ nothingYet: "No items yet.",
157
+ bindings: {
158
+ title: "Title",
159
+ sets: "Sets",
160
+ control: "Control",
161
+ controls: {
162
+ search: "Search",
163
+ choice: "Choice chips",
164
+ range: "Range",
165
+ date: "Date"
166
+ },
167
+ shows: "Shows",
168
+ valueFrom: "Value from",
169
+ trend: "Trend from",
170
+ target: "Navigate to",
171
+ slot: "Render into slot",
172
+ icon: "Icon",
173
+ opens: "Opens",
174
+ opensChoices: {
175
+ automatic: "Automatic",
176
+ none: "Run directly",
177
+ dialog: "Dialog",
178
+ drawer: "Drawer",
179
+ slot: "In a slot"
180
+ },
181
+ chooseParameter: "Choose parameter",
182
+ chooseScreen: "Choose screen",
183
+ chooseField: "Choose field",
184
+ automatic: "Automatic",
185
+ noQuery: "The screen shows no query yet, so there is nothing to bind to."
186
+ },
187
+ otherOutlets: "Other outlets on this screen",
188
+ modeOf: {
189
+ inherit: "inherits",
190
+ extend: "extends",
191
+ override: "overrides",
192
+ declares: "declares"
193
+ },
194
+ added: (e) => `+${e}`,
195
+ template: {
196
+ slots: "Slots",
197
+ outlets: "Outlets",
198
+ name: "Name",
199
+ kind: "Kind",
200
+ subject: "Acts on",
201
+ subjects: {
202
+ "": "The screen",
203
+ item: "The selected item",
204
+ screen: "The screen"
205
+ },
206
+ slot: "In slot",
207
+ noSlot: "No slot",
208
+ defaults: "Defaults",
209
+ defaultsCount: (e) => e === 1 ? "1 default" : `${e} defaults`,
210
+ addOutlet: "Add outlet",
211
+ removeOutlet: "Remove outlet",
212
+ removeDefault: "Remove",
213
+ newOutletName: "outlet",
214
+ routed: "routed",
215
+ primary: "primary",
216
+ optional: "optional"
217
+ }
218
+ }, Nt = {
219
+ toolbarLabel: (e) => `Actions for ${e}`,
220
+ slotName: (e) => `slot: ${e}`,
221
+ titleField: "Title",
222
+ notLinked: "Not linked",
223
+ chooseSlice: "Choose slice",
224
+ mainArea: "Main area",
225
+ emphasis: {
226
+ primary: "Primary",
227
+ secondary: "Secondary",
228
+ quiet: "Quiet"
229
+ },
230
+ noSliceWarning: "No slice is linked to this button",
231
+ readOnlyReasons: { "item.inherited": "Inherited from the template" },
232
+ inheritedFrom: (e) => `Inherited from ${e}`,
233
+ editAtOwner: "Edit at application level",
234
+ choiceLabel: (e) => e,
235
+ toolbar: {
236
+ toolbarButton: "Toolbar button",
237
+ opensAsDialog: "opens as dialog",
238
+ dialogFromSlice: (e) => `Opens the slice's own dialog template, ${e}.`,
239
+ dialogDefault: (e) => `The slice names no dialog template, so it opens the default ${e}.`,
240
+ sliceHelp: "Only State Change slices can be picked. State Views and Automations never take user input, so they are listed as unavailable.",
241
+ stateChangeHeading: "State Change slices",
242
+ notInvokableHeading: "Not invokable from a toolbar",
243
+ upgrade: "Upgrade to the slice",
244
+ upgradeNote: (e) => `This button names a command. The slice that accepts it is ${e}, and that is what it runs. `,
245
+ shows: "Shows",
246
+ showsHelp: "An icon-only button keeps its title as its accessible name and tooltip.",
247
+ displays: {
248
+ iconAndTitle: "Icon and title",
249
+ icon: "Icon only",
250
+ title: "Title only"
251
+ }
252
+ },
253
+ navigation: {
254
+ application: "Application",
255
+ extendsNotice: "Region now extends the inherited items",
256
+ overrideHere: "Override here",
257
+ editAtApplication: "Edit at application level",
258
+ backToModule: (e) => `Back to ${e}`,
259
+ tagLong: (e, t) => `${e === "sidebar" ? "Sidebar" : "Topbar"} · ${t === "defined here" ? "defined here" : t === "inherited" ? "inherits the application" : t.endsWith(" only") ? "overrides the application" : "extends application"}`,
260
+ regionName: {
261
+ topbar: "topbar",
262
+ sidebar: "sidebar"
263
+ },
264
+ inheritedFromApplication: "Inherited from Application",
265
+ inheritedNote: (e) => `This item comes from the Application. Override this region to edit a copy in ${e}.`,
266
+ definedIn: (e) => `defined in ${e}`,
267
+ inheritedReadOnly: "inherited · read-only",
268
+ navigationItem: "Navigation item",
269
+ hierarchy: "Where it appears",
270
+ label: "Label",
271
+ navigateTo: "Navigate to",
272
+ renderIntoSlot: "Render into slot",
273
+ icon: "Icon",
274
+ notLinked: "Not linked",
275
+ mainArea: "Main area",
276
+ sidePanel: "Side panel",
277
+ modeTitle: (e, t) => `${e} · ${t}`,
278
+ modeDescription: (e) => `How this module relates to the application-level ${e} items.`,
279
+ modes: {
280
+ inherit: {
281
+ title: "Inherit",
282
+ description: "Use the application items as they are. Removes items added in this module."
283
+ },
284
+ extend: {
285
+ title: "Extend",
286
+ description: "Application items first, then this module's own items."
287
+ },
288
+ override: {
289
+ title: "Override",
290
+ description: "Only this module's items. Switching copies the application items so you can edit them."
291
+ }
292
+ },
293
+ copyPrompt: "Copy the application items so you can edit them?",
294
+ copyYes: "Copy them",
295
+ copyNo: "Start empty",
296
+ logo: "Logo",
297
+ logoTitle: "Name",
298
+ logoImage: "Image",
299
+ logoLocked: "The logo is defined at the application level only.",
300
+ target: {
301
+ heading: "Navigate to",
302
+ application: "Application",
303
+ module: "module",
304
+ unresolved: (e) => `${e} no longer exists`
305
+ },
306
+ problems: {
307
+ navTargetMissing: "This item leads nowhere yet.",
308
+ navTargetOutOfScope: "A module can only link to itself.",
309
+ navModuleWithoutFeatures: "That module has no feature to open.",
310
+ navSlotUnknown: "The layout has no such slot.",
311
+ navDuplicateId: "Another item uses this identity."
312
+ }
313
+ },
314
+ close: "Close",
315
+ outlets: Tt,
316
+ announce: {
317
+ added: (e) => `Added ${e}`,
318
+ moved: (e, t, n) => `Moved ${e} to position ${t} of ${n}`,
319
+ duplicated: (e) => `Duplicated ${e}`,
320
+ removed: (e) => `Removed ${e}`,
321
+ refused: (e) => `Not possible: ${e}`
322
+ }
323
+ }, d = {
324
+ addItem: "addItem",
325
+ addButton: "addButton",
326
+ rename: "rename",
327
+ target: "target",
328
+ slot: "slot",
329
+ slice: "slice",
330
+ emphasis: "emphasis",
331
+ display: "display",
332
+ addFilter: "addFilter",
333
+ addTab: "addTab",
334
+ addStat: "addStat",
335
+ sets: "sets",
336
+ control: "control",
337
+ shows: "shows",
338
+ valueFrom: "valueFrom",
339
+ opens: "opens",
340
+ enabled: "enabled",
341
+ moveEarlier: "moveEarlier",
342
+ moveLater: "moveLater",
343
+ duplicate: "duplicate",
344
+ delete: "delete",
345
+ addSubItem: "addSubItem"
346
+ }, Le = /* @__PURE__ */ (function(e) {
347
+ return e.Elements = "elements", e.Collection = "collection", e.Region = "region", e.Outlet = "outlet", e;
348
+ })({}), At = (e) => "rejected" in e;
349
+ function Ct(e, t) {
350
+ return {
351
+ id: e,
352
+ name: t,
353
+ visibility: lt.Visible,
354
+ isEnabled: !0,
355
+ opacity: 1,
356
+ size: {},
357
+ zIndex: 0,
358
+ minimumSize: {},
359
+ maximumSize: {},
360
+ margin: {
361
+ left: 0,
362
+ top: 0,
363
+ right: 0,
364
+ bottom: 0
365
+ },
366
+ horizontalAlignment: ot.Stretch,
367
+ verticalAlignment: at.Stretch,
368
+ properties: {}
369
+ };
370
+ }
371
+ function jt(e, t, n, r = {}, o = {}) {
372
+ return {
373
+ ...Ct(e, t),
374
+ componentName: n,
375
+ properties: r,
376
+ slots: o
377
+ };
378
+ }
379
+ var $t = "dialog-actions-chrome";
380
+ function Et(e) {
381
+ const t = e.screens.find((n) => n.name === q)?.fits;
382
+ return !t || t.length === 0 || t.includes(Oe.Dialog) || t.includes(Oe.Drawer);
383
+ }
384
+ function Ft(e) {
385
+ const t = e.dialogTemplates ?? [];
386
+ return t.find((n) => n.name === "FormDialog") ?? t[0] ?? {
387
+ name: "FormDialog",
388
+ slots: []
389
+ };
390
+ }
391
+ function xt(e, t = [], n = []) {
392
+ if (!Et(e)) return !1;
393
+ const r = e.screens.find((s) => s.name === q), o = r?.screenTemplate ? [...e.screenTemplates, ...t].find((s) => s.name === r.screenTemplate) : void 0, i = r?.layout ? [...e.layouts, ...n].find((s) => s.name === r.layout) : void 0;
394
+ return ![...o?.outlets ?? [], ...i?.outlets ?? []].some((s) => s.name === $e);
395
+ }
396
+ function Xn(e, t) {
397
+ if (t.length === 0) return e;
398
+ const n = e.screens.map((r) => {
399
+ if (r.name !== "Screen") return r;
400
+ const o = r.slotContent?.[P]?.[0];
401
+ return o ? {
402
+ ...r,
403
+ slotContent: {
404
+ ...r.slotContent,
405
+ [P]: [{
406
+ ...o,
407
+ children: [...o.children ?? [], ...t]
408
+ }, ...r.slotContent[P].slice(1)]
409
+ }
410
+ } : r;
411
+ });
412
+ return {
413
+ ...e,
414
+ screens: n
415
+ };
416
+ }
417
+ function er() {
418
+ return jt($t, "Dialog actions", Ee, {
419
+ name: $e,
420
+ kind: "actions",
421
+ items: []
422
+ });
423
+ }
424
+ function Mt({ document: e, screen: t, slices: n, queries: r, templates: o = [], layouts: i = [] }) {
425
+ return {
426
+ slices: n,
427
+ slots: Ze(e, o, i, t),
428
+ itemFields: new Set(r.filter((s) => s.resultShape === Ce.Collection).flatMap((s) => s.resultFields.map((c) => c.name))),
429
+ routeParameters: []
430
+ };
431
+ }
432
+ function Rt(e, t) {
433
+ switch (e.availability) {
434
+ case void 0:
435
+ return !0;
436
+ case Fe:
437
+ return !t.readOnly;
438
+ default:
439
+ return !1;
440
+ }
441
+ }
442
+ var Q = xe;
443
+ function tr(e, t) {
444
+ if (!Rt(e, t)) return {
445
+ visible: !1,
446
+ enabled: !1
447
+ };
448
+ switch (e.id) {
449
+ case d.moveEarlier:
450
+ return {
451
+ visible: !0,
452
+ enabled: t.index > 0
453
+ };
454
+ case d.moveLater:
455
+ return {
456
+ visible: !0,
457
+ enabled: t.index < t.count - 1
458
+ };
459
+ case d.addSubItem:
460
+ return {
461
+ visible: !0,
462
+ enabled: t.parentId === void 0
463
+ };
464
+ default:
465
+ return {
466
+ visible: !0,
467
+ enabled: !0
468
+ };
469
+ }
470
+ }
471
+ var me = (e, t, n) => e.flatMap((r) => {
472
+ if (r.id === t) {
473
+ const o = n(r);
474
+ return o ? [o] : [];
475
+ }
476
+ return [r.children ? {
477
+ ...r,
478
+ children: me(r.children, t, n)
479
+ } : r];
480
+ }), Lt = (e) => Object.fromEntries(Object.entries(e).filter(([, t]) => t !== void 0)), G = (e, t, n) => me(e, t, (r) => Lt({
481
+ ...r,
482
+ ...n
483
+ })), Bt = (e, t) => me(e, t, () => {
484
+ });
485
+ function J(e, t) {
486
+ for (const n of e) {
487
+ if (n.id === t) return n;
488
+ const r = n.children ? J(n.children, t) : void 0;
489
+ if (r) return r;
490
+ }
491
+ }
492
+ function Y(e, t) {
493
+ if (e.some((n) => n.id === t)) return e;
494
+ for (const n of e) {
495
+ const r = n.children ? Y(n.children, t) : void 0;
496
+ if (r) return r;
497
+ }
498
+ }
499
+ function Dt(e, t, n) {
500
+ const r = Y(e, t);
501
+ if (!r) return [...e];
502
+ const o = r.findIndex((c) => c.id === t);
503
+ if (o < 0 || n < 0 || n >= r.length || o === n) return [...e];
504
+ const i = [...r], [s] = i.splice(o, 1);
505
+ return i.splice(n, 0, s), r === e ? i : pe(e, r, i);
506
+ }
507
+ function pe(e, t, n) {
508
+ return e.map((r) => r.children === t ? {
509
+ ...r,
510
+ children: n
511
+ } : r.children ? {
512
+ ...r,
513
+ children: pe(r.children, t, n)
514
+ } : r);
515
+ }
516
+ var Be = (e, t) => ({
517
+ ...structuredClone(e),
518
+ id: t(),
519
+ ...e.children ? { children: e.children.map((n) => Be(n, t)) } : {}
520
+ });
521
+ function _t(e, t, n) {
522
+ const r = J(e, t), o = Y(e, t);
523
+ if (!r || !o) return { items: [...e] };
524
+ const i = Be(r, n), s = o.findIndex((l) => l.id === t) + 1, c = [
525
+ ...o.slice(0, s),
526
+ i,
527
+ ...o.slice(s)
528
+ ];
529
+ return {
530
+ items: o === e ? c : pe(e, o, c),
531
+ copy: i
532
+ };
533
+ }
534
+ var qt = () => ({
535
+ application: { outlets: [] },
536
+ modules: []
537
+ }), fe = (e) => e.navigation ?? qt(), Ht = (e, t) => ({
538
+ ...e,
539
+ navigation: t
540
+ });
541
+ function Pt(e, t, n) {
542
+ return St(e, t, n).filter((r) => r.kind === O.Navigation);
543
+ }
544
+ var Vt = (e) => e === R.Inherits ? "inherit" : e === R.Extends ? "extend" : e === R.Overrides ? "override" : void 0;
545
+ function De(e, t) {
546
+ if (!t?.module) return;
547
+ const n = e.modules.find((i) => i.id === t.module);
548
+ if (!n) return t.module;
549
+ if (!t.feature) return n.name;
550
+ const r = [];
551
+ let o = n.features;
552
+ for (const i of t.feature.split(".")) {
553
+ const s = o.find((c) => c.id === i);
554
+ r.push(s?.name ?? i), o = s?.features ?? [];
555
+ }
556
+ return [n.name, ...r].join(" › ");
557
+ }
558
+ function nr(e) {
559
+ const { region: t, module: n, navigation: r, structure: o, newId: i, slots: s, startingLabel: c, strings: l } = e, f = ht(o, r, n, t), y = Pt(r, n, t), h = pt(o, r, { slots: [...s] }), g = (k) => `${n ?? "application"}:${t}:${k}`, p = [], I = (k, v) => {
560
+ const S = k.filter((u) => !u.readOnly);
561
+ k.forEach((u) => {
562
+ const C = J(y, u.id)?.target ?? (u.target ? {
563
+ module: u.target.module,
564
+ ...u.target.feature ? { feature: u.target.feature } : {}
565
+ } : void 0), z = u.readOnly ? -1 : S.indexOf(u), ee = De(o, C), V = h.filter((W) => W.entry === g(u.id)).map((W) => ({
566
+ code: W.code,
567
+ message: W.message
568
+ }));
569
+ p.push({
570
+ id: u.id,
571
+ label: u.title,
572
+ index: z,
573
+ count: S.length,
574
+ ...v ? { parentId: v } : {},
575
+ readOnly: u.readOnly,
576
+ ...u.readOnly ? {
577
+ readOnlyReason: Q,
578
+ origin: l.application
579
+ } : {},
580
+ values: {
581
+ target: C,
582
+ slot: u.slot,
583
+ icon: u.icon,
584
+ children: u.children?.length
585
+ },
586
+ chips: {
587
+ target: ee ?? "",
588
+ slot: u.slot === "content" || u.slot === "" ? l.mainArea : u.slot
589
+ },
590
+ ...V.length > 0 ? { problems: V } : {},
591
+ unlinked: C === void 0 && !(u.children && u.children.length > 0)
592
+ }), u.children && I(u.children, u.id);
593
+ });
594
+ };
595
+ I(f.items);
596
+ const L = t, j = (k, v, S, u = {}) => v.rejected ? { rejected: v.rejected } : {
597
+ label: k,
598
+ edits: [],
599
+ navigationEdits: v.edits,
600
+ ...S ? { select: S } : {},
601
+ ...u
602
+ }, w = (k) => ({ edits: [{
603
+ kind: Se.SetOutletItems,
604
+ ...n !== void 0 ? { module: n } : {},
605
+ outlet: t,
606
+ items: k
607
+ }] }), A = (k) => {
608
+ const v = i(), S = ut(r, n, t, {
609
+ kind: O.Navigation,
610
+ id: v,
611
+ title: c
612
+ }, k), u = S.edits.some((C) => C.kind === Se.SetOutletMode);
613
+ return j("Add", S, { itemId: v }, {
614
+ renameNext: !0,
615
+ ...u ? { notice: l.extendsNotice } : {}
616
+ });
617
+ };
618
+ return {
619
+ kind: Le.Region,
620
+ items: p,
621
+ regionTag: {
622
+ text: f.sources.label,
623
+ long: l.tagLong(t, f.sources.label),
624
+ kind: f.sources.kind
625
+ },
626
+ region: {
627
+ region: L,
628
+ ...n !== void 0 ? { module: n } : {},
629
+ ...f.mode ? { mode: Vt(f.mode) } : {}
630
+ },
631
+ add: (k) => k === d.addItem ? A() : { rejected: k },
632
+ act: (k, v) => {
633
+ switch (k) {
634
+ case d.addSubItem:
635
+ return v.parentId !== void 0 ? { rejected: "subItemOfSubItem" } : A(v.id);
636
+ case d.moveEarlier:
637
+ case d.moveLater: {
638
+ const S = v.index + (k === d.moveEarlier ? -1 : 1), u = Y(y, v.id);
639
+ return !u || S < 0 || S >= u.length ? { rejected: "noWhere" } : j("Move", w(Dt(y, v.id, S)), { itemId: v.id });
640
+ }
641
+ case d.duplicate: {
642
+ const S = _t(y, v.id, i);
643
+ return S.copy ? j("Duplicate", w(S.items), { itemId: S.copy.id }) : { rejected: k };
644
+ }
645
+ case d.delete: {
646
+ const S = Y(y, v.id) ?? [], u = S.findIndex((z) => z.id === v.id), C = S[u + 1] ?? S[u - 1];
647
+ return j("Remove", w(Bt(y, v.id)), { itemId: C?.id ?? null });
648
+ }
649
+ default:
650
+ return { rejected: k };
651
+ }
652
+ },
653
+ rename: (k, v) => j("Rename", w(G(y, k.id, { title: v })), { itemId: k.id }),
654
+ choice: (k, v) => {
655
+ const S = J(y, v.id);
656
+ if (S) {
657
+ if (k === d.target) return {
658
+ property: ne("target", "Navigate to", "navigationItemTarget", S.target),
659
+ plan: (u) => j("Link", w(G(y, v.id, { target: Wt(u) ? u : void 0 })), { itemId: v.id })
660
+ };
661
+ if (k === d.slot) return {
662
+ property: ne("slot", "Render into slot", "renderingSlot", S.slot ?? "content"),
663
+ plan: (u) => j("Change", w(G(y, v.id, { slot: typeof u == "string" && u !== "content" ? u : void 0 })), { itemId: v.id })
664
+ };
665
+ if (k === "icon") return {
666
+ property: ne("icon", "Icon", "icon", S.icon),
667
+ plan: (u) => j("Change", w(G(y, v.id, { icon: typeof u == "string" && u !== "" ? u : void 0 })), { itemId: v.id })
668
+ };
669
+ }
670
+ },
671
+ readOnlyActions: () => n === void 0 ? [] : [{
672
+ id: "overrideHere",
673
+ label: l.overrideHere,
674
+ plan: () => j("Override", wt(r, n, t, R.Overrides, { copy: !0 }))
675
+ }, {
676
+ id: "editAtApplication",
677
+ label: l.editAtApplication,
678
+ plan: () => ({
679
+ label: "Edit at application level",
680
+ edits: [],
681
+ editAtApplication: !0
682
+ })
683
+ }]
684
+ };
685
+ }
686
+ var Wt = (e) => typeof e == "object" && e !== null && typeof e.module == "string";
687
+ function ne(e, t, n, r) {
688
+ return {
689
+ descriptor: {
690
+ path: e,
691
+ label: t,
692
+ group: "Content",
693
+ valueType: F.String,
694
+ editorKind: n
695
+ },
696
+ currentValue: r,
697
+ effectiveValue: r,
698
+ source: ce.Local,
699
+ editable: !0
700
+ };
701
+ }
702
+ function Z(e, t) {
703
+ const n = e;
704
+ return {
705
+ ...typeof n.slice == "string" && n.slice !== "" ? { slice: n.slice } : typeof n.command == "string" && n.command !== "" ? { slice: n.command } : {},
706
+ ...n.opens ? { opens: n.opens } : {},
707
+ ...typeof n.opensIn == "string" && n.opensIn !== "" ? { opensIn: n.opensIn } : {},
708
+ subject: n.subject ?? t.outletSubject ?? st.Screen,
709
+ ...typeof n.enabledWhen == "string" && n.enabledWhen !== "" ? { enabledWhen: n.enabledWhen } : {}
710
+ };
711
+ }
712
+ var Ut = (e) => {
713
+ switch (e) {
714
+ case O.Button:
715
+ case O.MenuEntry:
716
+ return [
717
+ d.slice,
718
+ d.opens,
719
+ d.enabled,
720
+ d.emphasis,
721
+ d.display
722
+ ];
723
+ case O.Filter:
724
+ return [d.sets, d.control];
725
+ case O.Tab:
726
+ return [d.shows];
727
+ case O.Stat:
728
+ return [d.valueFrom];
729
+ case O.Navigation:
730
+ return [
731
+ d.target,
732
+ d.slot,
733
+ "icon"
734
+ ];
735
+ default:
736
+ return [];
737
+ }
738
+ }, he = (e, t) => `${e}.${t}`, ke = (e) => {
739
+ if (typeof e != "string") return;
740
+ const t = e.lastIndexOf(".");
741
+ return t > 0 && t < e.length - 1 ? {
742
+ first: e.slice(0, t),
743
+ second: e.slice(t + 1)
744
+ } : void 0;
745
+ }, D = (e, t, n, r, o, i, s) => ({
746
+ descriptor: {
747
+ path: e,
748
+ label: t,
749
+ group: "Behavior",
750
+ valueType: n,
751
+ editorKind: r,
752
+ ...i ? { choices: [...i] } : {},
753
+ ...s ? { editorOptions: s } : {}
754
+ },
755
+ currentValue: o,
756
+ effectiveValue: o,
757
+ source: ce.Local,
758
+ editable: !0
759
+ }), zt = (e) => e.flatMap((t) => t.parameters.map((n) => ({
760
+ value: he(t.name, n.name),
761
+ label: `${t.name} › ${n.name}`
762
+ }))), Kt = (e) => e.filter((t) => t.resultShape !== Ce.Collection).flatMap((t) => t.resultFields.map((n) => ({
763
+ value: he(t.name, n.name),
764
+ label: `${t.name} › ${n.name}`
765
+ })));
766
+ function Qt(e, t, n) {
767
+ const r = t, o = n.strings, i = (s) => {
768
+ const c = s;
769
+ return c?.query ? he(c.query, c.parameter ?? c.field ?? "") : void 0;
770
+ };
771
+ switch (e) {
772
+ case d.sets:
773
+ return D("sets", o.sets, F.Enum, K.Enum, i(r.sets), zt(n.queries));
774
+ case d.control:
775
+ return D("control", o.control, F.Enum, K.Enum, r.control ?? se.Search, Object.values(se).map((s) => ({
776
+ value: s,
777
+ label: o.controls[s] ?? s
778
+ })));
779
+ case d.shows:
780
+ return D("shows", o.shows, F.Enum, K.Enum, r.shows, n.screens.map((s) => ({
781
+ value: s.id,
782
+ label: s.label
783
+ })));
784
+ case d.valueFrom:
785
+ return D("valueFrom", o.valueFrom, F.Enum, K.Enum, i(r.valueFrom), Kt(n.queries));
786
+ case d.target:
787
+ return D("target", o.target, F.String, "navigationItemTarget", r.target);
788
+ case d.slot:
789
+ return D("slot", o.slot, F.String, "renderingSlot", r.slot ?? "content");
790
+ case "icon":
791
+ return D("icon", o.icon, F.String, "icon", r.icon);
792
+ case d.opens:
793
+ return D("opens", n.placementStrings?.opens ?? o.opens, F.String, "hookOpens", {
794
+ value: Je(r.opens, r.opensIn),
795
+ hook: Z(t, n)
796
+ });
797
+ case d.enabled:
798
+ return D("enabled", n.placementStrings?.enabled ?? "Enabled", F.String, "hookEnabled", {
799
+ subject: r.subject,
800
+ enabledWhen: r.enabledWhen,
801
+ hook: Z(t, n),
802
+ ...n.outletSubject ? { outletSubject: n.outletSubject } : {}
803
+ });
804
+ case d.slice:
805
+ case d.emphasis:
806
+ case d.display: {
807
+ const s = n.actionProperties.find((c) => c.path === e);
808
+ return s ? {
809
+ descriptor: s,
810
+ currentValue: r[e],
811
+ effectiveValue: r[e] ?? s.default,
812
+ source: ce.Local,
813
+ editable: !0
814
+ } : e === d.slice ? D("slice", "Slice", F.String, K.Slice, r.slice) : void 0;
815
+ }
816
+ default:
817
+ return;
818
+ }
819
+ }
820
+ function Yt(e, t) {
821
+ const n = t == null || t === "";
822
+ switch (e) {
823
+ case d.sets: {
824
+ const r = ke(t);
825
+ return n ? { sets: void 0 } : r ? { sets: {
826
+ query: r.first,
827
+ parameter: r.second
828
+ } } : void 0;
829
+ }
830
+ case d.valueFrom: {
831
+ const r = ke(t);
832
+ return n ? { valueFrom: void 0 } : r ? { valueFrom: {
833
+ query: r.first,
834
+ field: r.second
835
+ } } : void 0;
836
+ }
837
+ case d.control:
838
+ return { control: n ? void 0 : t };
839
+ case d.shows:
840
+ return typeof t == "string" && t !== "" ? { shows: t } : void 0;
841
+ case d.target:
842
+ return { target: typeof t == "object" && t !== null && typeof t.module == "string" ? t : void 0 };
843
+ case d.slot:
844
+ return { slot: typeof t == "string" && t !== "content" && t !== "" ? t : void 0 };
845
+ case d.opens:
846
+ return tt(t);
847
+ case d.enabled:
848
+ return nt(t);
849
+ case "icon":
850
+ case d.slice:
851
+ case d.emphasis:
852
+ case d.display:
853
+ return { [e]: n ? void 0 : t };
854
+ default:
855
+ return;
856
+ }
857
+ }
858
+ function Gt(e, t) {
859
+ const n = e, r = t.strings, o = {}, i = n.sets, s = n.valueFrom;
860
+ switch (e.kind) {
861
+ case O.Filter:
862
+ o[d.sets] = i?.query ? `${i.query} › ${i.parameter ?? ""}` : r.chooseParameter, o[d.control] = r.controls[String(n.control ?? se.Search)] ?? String(n.control);
863
+ break;
864
+ case O.Tab:
865
+ o[d.shows] = typeof n.shows == "string" && n.shows !== "" ? t.screens.find((c) => c.id === n.shows)?.label ?? n.shows : r.chooseScreen;
866
+ break;
867
+ case O.Stat:
868
+ o[d.valueFrom] = s?.query ? `${s.query} › ${s.field ?? ""}` : r.chooseField;
869
+ break;
870
+ case O.Navigation: {
871
+ const c = n.target;
872
+ o[d.target] = (t.structure ? De(t.structure, c) : c?.module) ?? "";
873
+ break;
874
+ }
875
+ case O.Button:
876
+ case O.MenuEntry:
877
+ o[d.opens] = t.placement ? Xe(Z(e, t), t.placement, t.placementStrings) : r.opensChoices[String(n.opens ?? "automatic")] ?? r.automatic, o[d.enabled] = et(Z(e, t), t.outletSubject, t.placementStrings);
878
+ }
879
+ return o;
880
+ }
881
+ function Jt(e) {
882
+ const t = e;
883
+ switch (e.kind) {
884
+ case O.Button:
885
+ case O.MenuEntry:
886
+ return !t.slice && !t.command && !t.navigateTo && !t.builtIn;
887
+ case O.Filter:
888
+ return !t.sets;
889
+ case O.Tab:
890
+ return !t.shows;
891
+ case O.Stat:
892
+ return !t.valueFrom;
893
+ case O.Navigation:
894
+ return !t.target && !(Array.isArray(t.children) && t.children.length > 0);
895
+ default:
896
+ return !1;
897
+ }
898
+ }
899
+ var x = (e, t, n) => ({
900
+ id: e,
901
+ icon: je(t),
902
+ title: n,
903
+ availability: Fe,
904
+ readOnlyReason: xe
905
+ }), Zt = [
906
+ x(d.moveEarlier, "arrow-left", "Move earlier"),
907
+ x(d.moveLater, "arrow-right", "Move later"),
908
+ x(d.duplicate, "copy", "Duplicate"),
909
+ x(d.delete, "trash", "Delete")
910
+ ], ie = {
911
+ [E.Actions]: {
912
+ id: d.addButton,
913
+ item: O.Button
914
+ },
915
+ [E.Filters]: {
916
+ id: d.addFilter,
917
+ item: O.Filter
918
+ },
919
+ [E.Tabs]: {
920
+ id: d.addTab,
921
+ item: O.Tab
922
+ },
923
+ [E.Stats]: {
924
+ id: d.addStat,
925
+ item: O.Stat
926
+ },
927
+ [E.Navigation]: {
928
+ id: d.addItem,
929
+ item: O.Navigation
930
+ }
931
+ }, re = (e, t, n) => ({
932
+ addActions: [{
933
+ id: ie[e].id,
934
+ label: t,
935
+ icon: je("plus")
936
+ }],
937
+ itemToolbar: [
938
+ x(d.rename, "pencil", "Rename"),
939
+ ...n,
940
+ ...Zt
941
+ ]
942
+ });
943
+ function Xt(e) {
944
+ switch (e) {
945
+ case E.Actions: {
946
+ const t = It(), n = t.itemToolbar.findIndex((i) => i.id === d.emphasis), r = [x(d.opens, "panel-right-open", "Opens"), x(d.enabled, "toggle-right", "Enabled")], o = n < 0 ? [...t.itemToolbar, ...r] : [
947
+ ...t.itemToolbar.slice(0, n),
948
+ ...r,
949
+ ...t.itemToolbar.slice(n)
950
+ ];
951
+ return {
952
+ ...t,
953
+ itemToolbar: o
954
+ };
955
+ }
956
+ case E.Navigation:
957
+ return kt({ sidebar: !0 });
958
+ case E.Filters:
959
+ return re(e, "Add filter", [x(d.sets, "filter", "Sets"), x(d.control, "sliders-horizontal", "Control")]);
960
+ case E.Tabs:
961
+ return re(e, "Add tab", [x(d.shows, "app-window", "Shows")]);
962
+ case E.Stats:
963
+ return re(e, "Add stat", [x(d.valueFrom, "hash", "Value from")]);
964
+ }
965
+ }
966
+ var _e = (e, t) => e !== void 0 && t !== void 0 && e.kind === t.kind && e.name === t.name, ge = (e) => e.outletLevels ?? [];
967
+ function en(e, t) {
968
+ const { outletLevels: n, ...r } = e, o = t.filter((i) => (i.refinements ?? []).length > 0 || (i.contributions ?? []).length > 0 || (i.outlets ?? []).length > 0);
969
+ return o.length === 0 ? r : {
970
+ ...r,
971
+ outletLevels: o
972
+ };
973
+ }
974
+ function tn(e, t, n) {
975
+ return t.kind === $.Module ? fe(e).modules.find((r) => r.module === t.name)?.refinements?.find((r) => r.outlet === n) : ge(e).find((r) => r.kind === t.kind && r.name === t.name)?.refinements?.find((r) => r.outlet === n);
976
+ }
977
+ function nn(e, t, n, r) {
978
+ const o = (s) => {
979
+ const c = (s ?? []).filter((l) => l.outlet !== n);
980
+ return r ? [...c, r] : c;
981
+ };
982
+ if (t.kind === $.Module) {
983
+ const s = fe(e), c = (s.modules.some((l) => l.module === t.name) ? s.modules : [...s.modules, { module: t.name }]).flatMap((l) => {
984
+ if (l.module !== t.name) return [l];
985
+ const { refinements: f, ...y } = l, h = o(l.refinements), g = h.length > 0 ? {
986
+ ...y,
987
+ refinements: h
988
+ } : y;
989
+ return g.refinements || g.contributions ? [g] : [];
990
+ });
991
+ return Ht(e, {
992
+ ...s,
993
+ modules: c
994
+ });
995
+ }
996
+ const i = ge(e);
997
+ return en(e, (i.some((s) => s.kind === t.kind && s.name === t.name) ? i : [...i, {
998
+ kind: t.kind,
999
+ name: t.name
1000
+ }]).map((s) => {
1001
+ if (s.kind !== t.kind || s.name !== t.name) return s;
1002
+ const { refinements: c, ...l } = s, f = o(s.refinements);
1003
+ return f.length > 0 ? {
1004
+ ...l,
1005
+ refinements: f
1006
+ } : l;
1007
+ }));
1008
+ }
1009
+ function rr(e, t, n) {
1010
+ return {
1011
+ ...e,
1012
+ screenTemplates: e.screenTemplates.map((r) => {
1013
+ if (r.name !== t) return r;
1014
+ const { outlets: o, ...i } = r;
1015
+ return n.length > 0 ? {
1016
+ ...i,
1017
+ outlets: [...n]
1018
+ } : i;
1019
+ })
1020
+ };
1021
+ }
1022
+ var U = (e) => {
1023
+ const t = e;
1024
+ if (Array.isArray(t.children)) return {
1025
+ key: "children",
1026
+ items: t.children
1027
+ };
1028
+ if (Array.isArray(t.items)) return {
1029
+ key: "items",
1030
+ items: t.items
1031
+ };
1032
+ }, rn = (e) => Object.fromEntries(Object.entries(e).filter(([, t]) => t !== void 0));
1033
+ function X(e, t, n) {
1034
+ return e.flatMap((r) => {
1035
+ if (r.id === t) {
1036
+ const i = n(r);
1037
+ return i ? [i] : [];
1038
+ }
1039
+ const o = U(r);
1040
+ return [o ? {
1041
+ ...r,
1042
+ [o.key]: X(o.items, t, n)
1043
+ } : r];
1044
+ });
1045
+ }
1046
+ function ve(e, t) {
1047
+ for (const n of e) {
1048
+ if (n.id === t) return n;
1049
+ const r = U(n), o = r ? ve(r.items, t) : void 0;
1050
+ if (o) return o;
1051
+ }
1052
+ }
1053
+ function ae(e, t) {
1054
+ if (e.some((n) => n.id === t)) return e;
1055
+ for (const n of e) {
1056
+ const r = U(n), o = r ? ae(r.items, t) : void 0;
1057
+ if (o) return o;
1058
+ }
1059
+ }
1060
+ var Ie = (e, t, n) => X(e, t, (r) => rn({
1061
+ ...r,
1062
+ ...n
1063
+ })), on = (e, t) => X(e, t, () => {
1064
+ });
1065
+ function sn(e, t, n) {
1066
+ const r = (o) => {
1067
+ const i = o.findIndex((l) => l.id === t);
1068
+ if (i < 0) return o.map((l) => {
1069
+ const f = U(l);
1070
+ return f ? {
1071
+ ...l,
1072
+ [f.key]: r(f.items)
1073
+ } : l;
1074
+ });
1075
+ const s = [...o], [c] = s.splice(i, 1);
1076
+ return s.splice(Math.max(0, Math.min(n, s.length)), 0, c), s;
1077
+ };
1078
+ return r(e);
1079
+ }
1080
+ function an(e, t, n) {
1081
+ const r = ve(e, t);
1082
+ if (!r) return { items: [...e] };
1083
+ const o = (c) => {
1084
+ const l = U(c), f = {
1085
+ ...c,
1086
+ id: n()
1087
+ };
1088
+ return l ? {
1089
+ ...f,
1090
+ [l.key]: l.items.map(o)
1091
+ } : f;
1092
+ }, i = o(r), s = (c) => c.flatMap((l) => {
1093
+ if (l.id === t) return [l, i];
1094
+ const f = U(l);
1095
+ return [f ? {
1096
+ ...l,
1097
+ [f.key]: s(f.items)
1098
+ } : l];
1099
+ });
1100
+ return {
1101
+ items: s(e),
1102
+ copy: i
1103
+ };
1104
+ }
1105
+ var ln = (e, t, n) => X(e, t, (r) => ({
1106
+ ...r,
1107
+ children: [...r.children ?? [], n]
1108
+ })), Te = (e, t) => [...e, ...(t ?? []).filter((n) => !e.some((r) => r.name === n.name))];
1109
+ function dn({ document: e, screen: t, path: n, templates: r, layouts: o, dialogTemplate: i }) {
1110
+ const s = ge(e), c = s.find((p) => p.kind === $.Screen && p.name === t), l = e.screens.map((p) => p.name === t && !p.path && n && n.length > 0 ? {
1111
+ ...p,
1112
+ path: [...n]
1113
+ } : p), { chain: f, contributors: y } = Ot({
1114
+ layouts: Te(e.layouts, o),
1115
+ screenTemplates: Te(e.screenTemplates, r),
1116
+ screens: l,
1117
+ navigation: fe(e),
1118
+ levels: s.filter((p) => p.kind !== $.Screen)
1119
+ }, t), h = i ? cn(f, i) : f;
1120
+ if (h.length === 0 || !c?.refinements) return {
1121
+ chain: h,
1122
+ contributors: y
1123
+ };
1124
+ const g = h[h.length - 1];
1125
+ return {
1126
+ chain: [...h.slice(0, -1), {
1127
+ ...g,
1128
+ refinements: [...g.refinements ?? [], ...c.refinements]
1129
+ }],
1130
+ contributors: y
1131
+ };
1132
+ }
1133
+ function cn(e, t) {
1134
+ const n = new Set(e.flatMap((s) => (s.outlets ?? []).map((c) => c.name))), r = ft(t).filter((s) => !n.has(s.name));
1135
+ if (r.length === 0) return [...e];
1136
+ const o = e.findIndex((s) => s.kind === $.Module || s.kind === $.Feature || s.kind === $.Slice || s.kind === $.Screen), i = o < 0 ? e.length : o;
1137
+ return [
1138
+ ...e.slice(0, i),
1139
+ {
1140
+ kind: $.Template,
1141
+ name: t.name,
1142
+ outlets: r
1143
+ },
1144
+ ...e.slice(i)
1145
+ ];
1146
+ }
1147
+ var un = (e) => e.filter((t) => t.kind === $.Module || t.kind === $.Feature || t.kind === $.Slice || t.kind === $.Screen).map((t) => ({
1148
+ kind: t.kind,
1149
+ name: t.name
1150
+ }));
1151
+ function mn(e, t) {
1152
+ if (!t) return e;
1153
+ const n = pn(e.chain, (o) => _e(o, t));
1154
+ if (n < 0 || n === e.chain.length - 1) return e;
1155
+ const r = e.chain.slice(n + 1).filter((o) => (o.contributions ?? []).length > 0).map((o) => ({
1156
+ kind: o.kind,
1157
+ name: o.name,
1158
+ contributions: o.contributions
1159
+ }));
1160
+ return {
1161
+ chain: e.chain.slice(0, n + 1),
1162
+ contributors: [...e.contributors, ...r]
1163
+ };
1164
+ }
1165
+ function pn(e, t) {
1166
+ for (let n = e.length - 1; n >= 0; n--) if (t(e[n])) return n;
1167
+ return -1;
1168
+ }
1169
+ var fn = (e) => e.flatMap((t) => (t.outlets ?? []).map((n) => ({
1170
+ outlet: n,
1171
+ level: t
1172
+ }))), hn = (e) => e === R.Overrides ? "override" : e === R.Extends ? "extend" : "inherit", gn = {
1173
+ inherit: R.Inherits,
1174
+ extend: R.Extends,
1175
+ override: R.Overrides
1176
+ }, Ne = (e) => {
1177
+ const t = e.title;
1178
+ return typeof t == "string" ? t : "";
1179
+ }, vn = (e) => {
1180
+ const t = e.children;
1181
+ return Array.isArray(t) ? t : [];
1182
+ };
1183
+ function bn(e, t) {
1184
+ return e.chain.some((n) => (n.outlets ?? []).some((r) => r.name === t));
1185
+ }
1186
+ function yn(e) {
1187
+ const { document: t, outlet: n, level: r, newId: o, binding: i, strings: s } = e, c = mn(e.outlets, r);
1188
+ if (!bn(c, n)) return;
1189
+ const l = gt(c.chain, n, c.contributors), f = l.subject ? {
1190
+ ...i,
1191
+ outletSubject: l.subject
1192
+ } : i;
1193
+ if (l.diagnostics.some((a) => a.code === dt.UnknownOutlet) || !l.kind) return;
1194
+ const y = l.kind, h = tn(t, r, n), g = h?.items ?? [], p = h?.hide ?? [], I = hn(l.mode), L = (a) => l.diagnostics.filter((m) => m.item === a).map((m) => ({
1195
+ code: m.code,
1196
+ message: m.message
1197
+ })), j = [], w = g.map((a) => a.id), A = (a, m, b, N) => {
1198
+ const B = b ? ae(g, a.id) ?? [] : [], H = L(a.id);
1199
+ j.push({
1200
+ id: a.id,
1201
+ label: Ne(a),
1202
+ index: b ? B.findIndex((te) => te.id === a.id) : -1,
1203
+ count: b ? B.length : 0,
1204
+ ...N ? { parentId: N } : {},
1205
+ readOnly: !b,
1206
+ ...b ? {} : {
1207
+ readOnlyReason: Q,
1208
+ origin: m.owner
1209
+ },
1210
+ values: {
1211
+ ...a,
1212
+ provenance: m
1213
+ },
1214
+ chips: Gt(a, f),
1215
+ ...H.length > 0 ? { problems: H } : {},
1216
+ unlinked: Jt(a),
1217
+ provenance: m
1218
+ }), vn(a).forEach((te) => A(te, m, b, a.id));
1219
+ };
1220
+ l.items.forEach((a) => {
1221
+ const m = a.provenance.source === we.Own && a.editable && w.includes(a.item.id);
1222
+ A(a.item, {
1223
+ owner: a.provenance.owner,
1224
+ level: a.provenance.level,
1225
+ source: a.provenance.source
1226
+ }, m);
1227
+ });
1228
+ const k = l.removed.map((a) => ({
1229
+ id: a.item.id,
1230
+ label: Ne(a.item),
1231
+ index: -1,
1232
+ count: 0,
1233
+ readOnly: !0,
1234
+ readOnlyReason: Q,
1235
+ origin: a.provenance.owner,
1236
+ values: { ...a.item },
1237
+ unlinked: !1,
1238
+ provenance: {
1239
+ owner: a.provenance.owner,
1240
+ level: a.provenance.level,
1241
+ source: a.provenance.source
1242
+ },
1243
+ removal: a.removal === ct.Hidden ? "hidden" : "overridden"
1244
+ })), v = (a) => {
1245
+ const m = {
1246
+ ...h ?? { outlet: n },
1247
+ ...a,
1248
+ outlet: n
1249
+ };
1250
+ return (!m.items || m.items.length === 0) && delete m.items, (!m.hide || m.hide.length === 0) && delete m.hide, m.mode === void 0 && delete m.mode, m.items || m.hide || m.mode !== void 0 ? m : void 0;
1251
+ }, S = (a, m, b, N = {}) => ({
1252
+ label: a,
1253
+ edits: [],
1254
+ documentChange: (B) => nn(B, r, n, m),
1255
+ ...b ? { select: b } : {},
1256
+ ...N
1257
+ }), u = () => I === "inherit" ? { mode: R.Extends } : {}, C = (a, m, b, N = {}) => {
1258
+ const B = I === "inherit" && m.length > g.length;
1259
+ return S(a, v({
1260
+ items: m,
1261
+ ...u()
1262
+ }), { itemId: b }, {
1263
+ ...N,
1264
+ ...B ? { notice: s.extendsNotice } : {}
1265
+ });
1266
+ }, z = () => {
1267
+ const a = o(), m = ie[y].item, b = s.newItem[m] ?? s.newItem.button;
1268
+ switch (m) {
1269
+ case O.Tab: {
1270
+ const N = i.screens[0];
1271
+ return N ? {
1272
+ kind: O.Tab,
1273
+ id: a,
1274
+ title: b,
1275
+ shows: N.id
1276
+ } : { rejected: "noScreenForTab" };
1277
+ }
1278
+ case O.Filter:
1279
+ return {
1280
+ kind: O.Filter,
1281
+ id: a,
1282
+ title: b
1283
+ };
1284
+ case O.Stat:
1285
+ return {
1286
+ kind: O.Stat,
1287
+ id: a,
1288
+ title: b
1289
+ };
1290
+ case O.Navigation:
1291
+ return {
1292
+ kind: O.Navigation,
1293
+ id: a,
1294
+ title: b
1295
+ };
1296
+ default:
1297
+ return {
1298
+ kind: O.Button,
1299
+ id: a,
1300
+ title: b
1301
+ };
1302
+ }
1303
+ }, ee = (a) => "rejected" in a, V = (a) => a.readOnly ? void 0 : ve(g, a.id), W = Xt(y), be = (a) => a.readOnly ? p.includes(a.id) ? { rejected: "alreadyHidden" } : S("Hide", v({
1304
+ hide: [...p, a.id],
1305
+ ...u()
1306
+ }), { itemId: null }) : { rejected: "ownItem" }, ye = (a) => {
1307
+ if (p.includes(a.id)) return S("Bring back", v({ hide: p.filter((m) => m !== a.id) }), { itemId: a.id });
1308
+ if (a.removal === "overridden") {
1309
+ const m = l.removed.find((b) => b.item.id === a.id)?.item;
1310
+ return m ? S("Bring back", v({ items: [...g, structuredClone(m)] }), { itemId: a.id }) : { rejected: "notRemoved" };
1311
+ }
1312
+ return { rejected: "notRemoved" };
1313
+ }, Ke = (a, m = !1) => {
1314
+ if (a === I) return { rejected: "sameMode" };
1315
+ if (a === "inherit") return S("Inherit", void 0, { itemId: null });
1316
+ if (a === "extend") return S("Extend", v({ mode: R.Extends }));
1317
+ const b = m ? l.items.filter((N) => N.provenance.source !== we.Contribution && !w.includes(N.item.id)).map((N) => structuredClone(N.item)) : [];
1318
+ return S("Override", v({
1319
+ mode: gn.override,
1320
+ items: [...b, ...g],
1321
+ hide: []
1322
+ }));
1323
+ }, Qe = (a) => a.removal ? [{
1324
+ id: "bringBack",
1325
+ label: s.bringBack,
1326
+ plan: () => ye(a)
1327
+ }] : a.parentId !== void 0 ? [] : [{
1328
+ id: "hide",
1329
+ label: s.hide,
1330
+ plan: () => be(a)
1331
+ }];
1332
+ return {
1333
+ kind: Le.Outlet,
1334
+ items: j,
1335
+ removed: k,
1336
+ name: n,
1337
+ ...l.subject ? { subject: l.subject } : {},
1338
+ ...l.slot ? { slot: l.slot } : {},
1339
+ ...l.declaredBy ? { declaredBy: l.declaredBy } : {},
1340
+ outletKind: y,
1341
+ level: r,
1342
+ mode: I,
1343
+ effective: l,
1344
+ designMode: W,
1345
+ regionTag: {
1346
+ text: l.summary,
1347
+ long: s.tagLong(n, l.summary),
1348
+ kind: I
1349
+ },
1350
+ addItem: (a) => C("Add", [...g, a], a.id),
1351
+ add: (a) => {
1352
+ if (a !== ie[y].id) return { rejected: a };
1353
+ const m = z();
1354
+ return ee(m) ? m : C("Add", [...g, m], m.id, { renameNext: !0 });
1355
+ },
1356
+ act: (a, m) => {
1357
+ if (!V(m)) return { rejected: m.readOnlyReason ?? Q };
1358
+ switch (a) {
1359
+ case d.moveEarlier:
1360
+ case d.moveLater: {
1361
+ const b = m.index + (a === d.moveEarlier ? -1 : 1);
1362
+ return b < 0 || b >= m.count ? { rejected: "noWhere" } : C("Move", sn(g, m.id, b), m.id);
1363
+ }
1364
+ case d.duplicate: {
1365
+ const b = an(g, m.id, o);
1366
+ return b.copy ? C("Duplicate", b.items, b.copy.id) : { rejected: a };
1367
+ }
1368
+ case d.delete: {
1369
+ const b = ae(g, m.id) ?? [], N = b.findIndex((H) => H.id === m.id), B = b[N + 1] ?? b[N - 1];
1370
+ return C("Remove", on(g, m.id), B?.id ?? null);
1371
+ }
1372
+ case d.addSubItem: {
1373
+ if (y !== E.Navigation || m.parentId !== void 0) return { rejected: "subItemOfSubItem" };
1374
+ const b = {
1375
+ kind: O.Navigation,
1376
+ id: o(),
1377
+ title: s.newItem.navigation
1378
+ };
1379
+ return C("Add", ln(g, m.id, b), b.id, { renameNext: !0 });
1380
+ }
1381
+ default:
1382
+ return { rejected: a };
1383
+ }
1384
+ },
1385
+ rename: (a, m) => V(a) ? C("Rename", Ie(g, a.id, { title: m }), a.id) : { rejected: a.readOnlyReason ?? Q },
1386
+ choice: (a, m) => {
1387
+ const b = V(m);
1388
+ if (!b || !Ut(b.kind).includes(a)) return;
1389
+ const N = Qt(a, b, f);
1390
+ if (N)
1391
+ return {
1392
+ property: N,
1393
+ plan: (B) => {
1394
+ const H = Yt(a, B);
1395
+ return H ? C("Bind", Ie(g, m.id, H), m.id) : { rejected: a };
1396
+ }
1397
+ };
1398
+ },
1399
+ readOnlyActions: Qe,
1400
+ setMode: Ke,
1401
+ hide: be,
1402
+ bringBack: ye
1403
+ };
1404
+ }
1405
+ function On(e, t) {
1406
+ const n = /* @__PURE__ */ new Set(), r = (i) => {
1407
+ if (Array.isArray(i)) {
1408
+ i.forEach(r);
1409
+ return;
1410
+ }
1411
+ if (typeof i != "object" || i === null) return;
1412
+ const s = i;
1413
+ typeof s.queryId == "string" && n.add(s.queryId), typeof s.queryId == "string" && typeof s.query == "string" && n.add(s.query), Object.values(s).forEach(r);
1414
+ };
1415
+ r(e.screens.find((i) => i.name === q));
1416
+ const o = t.filter((i) => n.has(i.id) || n.has(i.name));
1417
+ return o.length > 0 ? o : [...t];
1418
+ }
1419
+ function Sn(e) {
1420
+ return bt(e, Ee)?.properties.find((t) => t.path === "items")?.item?.properties ?? [];
1421
+ }
1422
+ function wn(e) {
1423
+ const { document: t, catalog: n, strings: r } = e, o = dn({
1424
+ document: t,
1425
+ screen: q,
1426
+ ...e.path ? { path: e.path } : {},
1427
+ ...e.templates ? { templates: e.templates } : {},
1428
+ ...e.layouts ? { layouts: e.layouts } : {},
1429
+ ...e.dialogTemplate ? { dialogTemplate: e.dialogTemplate } : {}
1430
+ }), i = un(o.chain), s = i.find((h) => h.kind === $.Screen), c = i.find((h) => _e(h, e.requestedLevel)) ?? s, l = {
1431
+ queries: On(t, e.queries),
1432
+ screens: e.screens,
1433
+ actionProperties: Sn(n),
1434
+ ...e.slices ? { placement: Mt({
1435
+ document: t,
1436
+ screen: q,
1437
+ slices: e.slices,
1438
+ queries: e.queries,
1439
+ ...e.templates ? { templates: e.templates } : {},
1440
+ ...e.layouts ? { layouts: e.layouts } : {}
1441
+ }) } : {},
1442
+ ...e.structure ? { structure: e.structure } : {},
1443
+ strings: r.bindings
1444
+ }, f = fn(o.chain).map(({ outlet: h, level: g }) => ({
1445
+ name: h.name,
1446
+ kind: h.kind,
1447
+ owner: g.name,
1448
+ shell: g.kind === $.Layout && g.name === mt
1449
+ })), y = e.newId ?? Re;
1450
+ return {
1451
+ outlets: o,
1452
+ levels: i,
1453
+ level: c,
1454
+ declared: f,
1455
+ binding: l,
1456
+ design: (h) => c ? yn({
1457
+ document: t,
1458
+ outlets: o,
1459
+ outlet: h,
1460
+ level: c,
1461
+ newId: y,
1462
+ binding: l,
1463
+ strings: r
1464
+ }) : void 0
1465
+ };
1466
+ }
1467
+ function kn(e, t, n) {
1468
+ const { document: r, context: o, outletLevel: i, structure: s } = e, c = t.location?.path, l = M(() => [...t.ownTemplates ?? [], ...t.runtime.bundles.flatMap((p) => p.screenTemplates ?? [])], [t.ownTemplates, t.runtime.bundles]), f = M(() => t.runtime.bundles.flatMap((p) => p.layouts ?? []), [t.runtime.bundles]), y = M(() => t.destinations.map((p) => ({
1469
+ id: p.id,
1470
+ label: p.label
1471
+ })), [t.destinations]), h = o.scope.kind === oe.Screen, g = M(() => h && xt(r, l, f) ? Ft(r) : void 0, [
1472
+ r,
1473
+ h,
1474
+ l,
1475
+ f
1476
+ ]);
1477
+ return M(() => wn({
1478
+ document: r,
1479
+ catalog: o.catalog,
1480
+ templates: l,
1481
+ layouts: f,
1482
+ ...g ? { dialogTemplate: g } : {},
1483
+ queries: t.queryCandidates,
1484
+ slices: t.stateChangeSlices,
1485
+ screens: y,
1486
+ strings: n,
1487
+ ...c ? { path: c } : {},
1488
+ ...i ? { requestedLevel: i } : {},
1489
+ ...s.modules.length > 0 ? { structure: s } : {}
1490
+ }), [
1491
+ r,
1492
+ o.catalog,
1493
+ l,
1494
+ f,
1495
+ t.queryCandidates,
1496
+ t.stateChangeSlices,
1497
+ y,
1498
+ n,
1499
+ c,
1500
+ i,
1501
+ s,
1502
+ g
1503
+ ]);
1504
+ }
1505
+ function or(e) {
1506
+ return {
1507
+ queryId: e.id,
1508
+ query: e.name,
1509
+ arguments: [],
1510
+ results: []
1511
+ };
1512
+ }
1513
+ function In(e) {
1514
+ const t = e;
1515
+ return !!t && typeof t == "object" && typeof t.queryId == "string" && Array.isArray(t.arguments) && Array.isArray(t.results);
1516
+ }
1517
+ function Tn(e, t, n) {
1518
+ const r = e.arguments.filter((o) => o.parameter !== t);
1519
+ return {
1520
+ ...e,
1521
+ arguments: n.trim() === "" ? r : [...r, {
1522
+ parameter: t,
1523
+ source: { path: n.trim() }
1524
+ }]
1525
+ };
1526
+ }
1527
+ function sr(e, t, n = t) {
1528
+ return e.results.some((r) => r.field === t) ? e : {
1529
+ ...e,
1530
+ results: [...e.results, {
1531
+ target: n,
1532
+ field: t
1533
+ }]
1534
+ };
1535
+ }
1536
+ function ir(e, t, n, r = t) {
1537
+ const o = e.results.findIndex((f) => f.field === t), i = e.results.filter((f) => f.field !== t), s = o >= 0 ? e.results[o] : {
1538
+ target: r,
1539
+ field: t
1540
+ }, c = n === void 0 ? o >= 0 ? o : i.length : o >= 0 && o < n ? n - 1 : n, l = Math.max(0, Math.min(i.length, c));
1541
+ return {
1542
+ ...e,
1543
+ results: [
1544
+ ...i.slice(0, l),
1545
+ s,
1546
+ ...i.slice(l)
1547
+ ]
1548
+ };
1549
+ }
1550
+ function ar(e, t) {
1551
+ return {
1552
+ ...e,
1553
+ results: e.results.filter((n) => n.field !== t)
1554
+ };
1555
+ }
1556
+ var Nn = (e, t) => e.arguments.find((n) => n.parameter === t.name)?.source.path ?? "", lr = (e, t) => e.results.some((n) => n.field === t.name), le = (e) => {
1557
+ const t = e.values.sets;
1558
+ return t !== null && typeof t == "object" && typeof t.query == "string" && typeof t.parameter == "string" ? t : void 0;
1559
+ };
1560
+ function An(e, t, n, r) {
1561
+ return t.filter((o) => o.values.kind === O.Filter && le(o)?.query === n && le(o)?.parameter === r).map((o) => ({
1562
+ outlet: e,
1563
+ id: o.id,
1564
+ title: o.label
1565
+ }));
1566
+ }
1567
+ var dr = (e, t) => e.filter((n) => n.values.kind === O.Filter && le(n)?.query === t);
1568
+ function Cn(e, t, n) {
1569
+ return {
1570
+ kind: O.Filter,
1571
+ id: n,
1572
+ title: t.charAt(0).toUpperCase() + t.slice(1),
1573
+ sets: {
1574
+ query: e,
1575
+ parameter: t
1576
+ }
1577
+ };
1578
+ }
1579
+ var jn = (e, t, n) => {
1580
+ const r = e.arguments.find((o) => o.parameter === t)?.source.path;
1581
+ return n.find((o) => o.path === r);
1582
+ }, $n = (e, t, n) => Tn(e, t, n?.path ?? ""), qe = /^show\s+(\S+)\s+by\s+(\S+)\s+from\s+(\S+?)\.selection\s*$/, En = (e) => `show ${e.screen} by ${e.by} from ${e.element}.selection`;
1583
+ function Fn(e) {
1584
+ const t = [...e].filter((n) => /[A-Za-z0-9_]/.test(n)).join("");
1585
+ return t.length === 0 ? "Unnamed" : /^[0-9]/.test(t) ? `_${t}` : t;
1586
+ }
1587
+ var He = (e) => e.screens.find((t) => t.name === q);
1588
+ function xn(e) {
1589
+ const t = He(e)?.native?.slots ?? {};
1590
+ return Object.entries(t).flatMap(([n, r]) => r.flatMap((o) => {
1591
+ const i = qe.exec(o.text.trim());
1592
+ return i ? [{
1593
+ slot: n,
1594
+ screen: i[1],
1595
+ by: i[2],
1596
+ element: i[3]
1597
+ }] : [];
1598
+ }));
1599
+ }
1600
+ function Ae(e, t, n) {
1601
+ const r = He(e);
1602
+ if (!r) return e;
1603
+ const o = r.native ?? {}, i = (o.slots?.[t] ?? []).filter((I) => !qe.test(I.text.trim())), s = n ? [...i, {
1604
+ at: (r.slotContent[t] ?? []).length,
1605
+ text: En(n)
1606
+ }] : i, c = {
1607
+ ...o.slots ?? {},
1608
+ [t]: s
1609
+ };
1610
+ s.length === 0 && delete c[t];
1611
+ const { slots: l, ...f } = o, y = {
1612
+ ...f,
1613
+ ...Object.keys(c).length > 0 ? { slots: c } : {}
1614
+ }, { native: h, ...g } = r, p = Object.keys(y).length > 0 ? {
1615
+ ...g,
1616
+ native: y
1617
+ } : g;
1618
+ return {
1619
+ ...e,
1620
+ screens: e.screens.map((I) => I === r ? p : I)
1621
+ };
1622
+ }
1623
+ function Pe(e, t, n) {
1624
+ const r = e.screens.find((o) => o.name === q);
1625
+ return (r?.screenTemplate ? t.find((o) => o.name === r.screenTemplate)?.slots : n.find((o) => o.name === r?.layout)?.slots) ?? [];
1626
+ }
1627
+ var Mn = (e, t, n) => Pe(e, t, n).some((r) => r.routed === !0);
1628
+ function Ve(e, t, n) {
1629
+ return Pe(e, t, n).filter((r) => r.routed === !0 && (r.routedBy ?? []).length > 0).map((r) => ({
1630
+ name: r.name,
1631
+ routedBy: r.routedBy ?? []
1632
+ }));
1633
+ }
1634
+ var Rn = [
1635
+ "dataTable",
1636
+ "table",
1637
+ "observableDataTable"
1638
+ ], We = "query", Ln = (e) => e.slice(e.lastIndexOf(":") + 1);
1639
+ function de(e) {
1640
+ if (!yt(e)) return;
1641
+ const t = e, n = t.properties?.[We];
1642
+ return Rn.includes(Ln(t.componentName)) && In(n) ? {
1643
+ elementId: t.id,
1644
+ binding: n
1645
+ } : void 0;
1646
+ }
1647
+ function Bn(e) {
1648
+ return e.flatMap((t) => [...de(t) ? [de(t)] : [], ...Bn(Ge(t))]);
1649
+ }
1650
+ var cr = (e, t) => ({
1651
+ kind: it.SetProperty,
1652
+ nodeId: vt(e),
1653
+ path: We,
1654
+ value: t
1655
+ }), Ue = (e, t) => [
1656
+ ...t.screenTemplates,
1657
+ ...e.ownTemplates ?? [],
1658
+ ...e.runtime.bundles.flatMap((n) => n.screenTemplates ?? [])
1659
+ ], ze = (e, t) => [...t.layouts, ...e.runtime.bundles.flatMap((n) => n.layouts ?? [])], ur = ({ controller: e, environment: t, strings: n, binding: r, candidate: o, disabled: i, onChange: s }) => {
1660
+ const c = n.properties.dataBinding, l = n.designMode ?? Nt, f = kn(e, t, l.outlets), y = M(() => Ue(t, e.document), [t, e.document]), h = M(() => ze(t, e.document), [t, e.document]), g = M(() => Ve(e.document, y, h), [
1661
+ e.document,
1662
+ y,
1663
+ h
1664
+ ]), p = g.flatMap((w) => w.routedBy.map((A) => ({
1665
+ slot: w.name,
1666
+ parameter: A,
1667
+ path: `route.${A}`
1668
+ }))), I = f.declared.filter((w) => w.kind === E.Filters && !w.shell);
1669
+ if (o.parameters.length === 0) return null;
1670
+ const L = I.flatMap((w) => (f.design(w.name)?.items ?? []).map((A) => ({
1671
+ outlet: w.name,
1672
+ item: {
1673
+ id: A.id,
1674
+ label: A.label,
1675
+ values: A.values
1676
+ }
1677
+ }))), j = (w) => {
1678
+ const A = I[0] && f.design(I[0].name);
1679
+ if (!A) return;
1680
+ const k = A.addItem(Cn(o.name, w, Re()));
1681
+ !At(k) && k.documentChange && e.changeDocument(k.documentChange, k.label);
1682
+ };
1683
+ return /* @__PURE__ */ _("div", {
1684
+ className: "studio-editor-query__group",
1685
+ "data-parameter-feeds": o.name,
1686
+ children: [
1687
+ /* @__PURE__ */ T("strong", { children: c.feedsTitle }),
1688
+ /* @__PURE__ */ T("ul", {
1689
+ className: "studio-editor-query__feeds",
1690
+ children: o.parameters.map((w) => {
1691
+ const A = L.flatMap((u) => An(u.outlet, [u.item], o.name, w.name)), k = g.filter((u) => u.routedBy.includes(w.name)), v = Nn(r, w), S = A.length > 0 || k.length > 0 || v !== "";
1692
+ return /* @__PURE__ */ _("li", {
1693
+ "data-fed": S,
1694
+ children: [
1695
+ /* @__PURE__ */ T("span", { children: w.name }),
1696
+ A.map((u) => /* @__PURE__ */ T("span", {
1697
+ className: "studio-editor-properties__chip",
1698
+ "data-feed": "filter",
1699
+ children: c.fedByFilter(u.title)
1700
+ }, u.id)),
1701
+ k.map((u) => /* @__PURE__ */ T("span", {
1702
+ className: "studio-editor-properties__chip",
1703
+ "data-feed": "route",
1704
+ children: c.fedByRoute(w.name, u.name)
1705
+ }, u.name)),
1706
+ v !== "" && /* @__PURE__ */ T("span", {
1707
+ className: "studio-editor-properties__chip",
1708
+ "data-feed": "mapping",
1709
+ children: c.fedByMapping(v)
1710
+ }),
1711
+ !S && /* @__PURE__ */ T("span", {
1712
+ className: "studio-editor-properties__chip",
1713
+ "data-feed": "none",
1714
+ children: c.fedByNothing
1715
+ }),
1716
+ !S && I.length > 0 && /* @__PURE__ */ T("button", {
1717
+ type: "button",
1718
+ onClick: () => j(w.name),
1719
+ children: c.addFilter
1720
+ }),
1721
+ s && p.length > 0 && /* @__PURE__ */ _("select", {
1722
+ "aria-label": c.routeSource(w.name),
1723
+ "data-route-source": w.name,
1724
+ disabled: i,
1725
+ value: jn(r, w.name, p)?.path ?? "",
1726
+ onChange: (u) => s($n(r, w.name, p.find((C) => C.path === u.target.value)), w, u.target.value),
1727
+ children: [/* @__PURE__ */ T("option", {
1728
+ value: "",
1729
+ children: c.routeSourceNone
1730
+ }), p.map((u) => /* @__PURE__ */ T("option", {
1731
+ value: u.path,
1732
+ children: c.routeSourceOption(u.parameter, u.slot)
1733
+ }, `${u.slot}.${u.parameter}`))]
1734
+ })
1735
+ ]
1736
+ }, w.name);
1737
+ })
1738
+ }),
1739
+ L.length > 0 && Mn(e.document, y, h) && /* @__PURE__ */ T("p", {
1740
+ className: "studio-editor-properties__hint",
1741
+ children: c.filtersInAddress
1742
+ })
1743
+ ]
1744
+ });
1745
+ }, mr = ({ controller: e, environment: t, strings: n, elementId: r, disabled: o }) => {
1746
+ const i = n.properties.dataBinding, s = M(() => Ue(t, e.document), [t, e.document]), c = M(() => ze(t, e.document), [t, e.document]), l = M(() => Ve(e.document, s, c), [
1747
+ e.document,
1748
+ s,
1749
+ c
1750
+ ]), f = Ye(e.composition.roots, r);
1751
+ if (!(f && de(f))) return null;
1752
+ const y = Fn(r), h = xn(e.document).filter((p) => p.element === y)[0], g = (p, I, L) => e.changeDocument((j) => {
1753
+ const w = h && h.slot !== p ? Ae(j, h.slot, void 0) : j;
1754
+ return Ae(w, p, I === "" ? void 0 : {
1755
+ screen: I,
1756
+ by: L,
1757
+ element: y
1758
+ });
1759
+ }, i.selectionTitle);
1760
+ return /* @__PURE__ */ _("fieldset", {
1761
+ className: "studio-editor-query",
1762
+ disabled: o,
1763
+ "data-selection-detail": r,
1764
+ children: [
1765
+ /* @__PURE__ */ T("legend", { children: i.selectionTitle }),
1766
+ l.length === 0 && /* @__PURE__ */ T("p", {
1767
+ className: "studio-editor-properties__hint",
1768
+ children: i.selectionNoSlot
1769
+ }),
1770
+ l.length > 0 && /* @__PURE__ */ _(rt, { children: [
1771
+ /* @__PURE__ */ T("p", {
1772
+ className: "studio-editor-properties__hint",
1773
+ children: i.selectionHint
1774
+ }),
1775
+ /* @__PURE__ */ _("label", { children: [/* @__PURE__ */ T("span", { children: i.selectionSlot }), /* @__PURE__ */ T("select", {
1776
+ value: h?.slot ?? l[0].name,
1777
+ onChange: (p) => h && g(p.target.value, h.screen, l.find((I) => I.name === p.target.value)?.routedBy[0] ?? h.by),
1778
+ children: l.map((p) => /* @__PURE__ */ _("option", {
1779
+ value: p.name,
1780
+ children: [
1781
+ p.name,
1782
+ " (",
1783
+ p.routedBy.join(", "),
1784
+ ")"
1785
+ ]
1786
+ }, p.name))
1787
+ })] }),
1788
+ /* @__PURE__ */ _("label", { children: [/* @__PURE__ */ T("span", { children: i.selectionScreen }), /* @__PURE__ */ _("select", {
1789
+ value: h?.screen ?? "",
1790
+ onChange: (p) => {
1791
+ const I = l.find((L) => L.name === (h?.slot ?? l[0].name)) ?? l[0];
1792
+ g(I.name, p.target.value, I.routedBy[0]);
1793
+ },
1794
+ children: [/* @__PURE__ */ T("option", {
1795
+ value: "",
1796
+ children: i.selectionNone
1797
+ }), t.destinations.map((p) => /* @__PURE__ */ T("option", {
1798
+ value: p.label,
1799
+ children: p.label
1800
+ }, p.id))]
1801
+ })] }),
1802
+ h && /* @__PURE__ */ T("p", {
1803
+ className: "studio-editor-query__preview",
1804
+ role: "status",
1805
+ children: i.selectionSummary(h.screen, h.slot, h.by)
1806
+ })
1807
+ ] })
1808
+ ]
1809
+ });
1810
+ };
1811
+ export {
1812
+ jt as A,
1813
+ P as B,
1814
+ Ht as C,
1815
+ er as D,
1816
+ Mt as E,
1817
+ Nt as F,
1818
+ zn as G,
1819
+ Qn as H,
1820
+ Re as I,
1821
+ ue as K,
1822
+ Zn as L,
1823
+ Le as M,
1824
+ d as N,
1825
+ Xn as O,
1826
+ At as P,
1827
+ Jn as R,
1828
+ fe as S,
1829
+ Q as T,
1830
+ Gn as U,
1831
+ Kn as V,
1832
+ q as W,
1833
+ mn as _,
1834
+ Bn as a,
1835
+ Ut as b,
1836
+ or as c,
1837
+ sr as d,
1838
+ Tn as f,
1839
+ kn as g,
1840
+ ar as h,
1841
+ de as i,
1842
+ Ct as j,
1843
+ xt as k,
1844
+ lr as l,
1845
+ Nn as m,
1846
+ mr as n,
1847
+ Rn as o,
1848
+ ir as p,
1849
+ Un as q,
1850
+ cr as r,
1851
+ dr as s,
1852
+ ur as t,
1853
+ In as u,
1854
+ rr as v,
1855
+ tr as w,
1856
+ nr as x,
1857
+ ie as y,
1858
+ Yn as z
1859
+ };