@nocobase/plugin-flow-engine 2.1.0-alpha.28 → 2.1.0-alpha.29

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.
@@ -93,6 +93,9 @@ var import_service_utils = require("./service-utils");
93
93
  var import_field_type_resolver = require("./field-type-resolver");
94
94
  var import_template_compatibility = require("./template-compatibility");
95
95
  var import_template_service_utils = require("./template-service-utils");
96
+ var import_hidden_popup_contract = require("./hidden-popup-contract");
97
+ var import_hidden_popup_calendar = require("./hidden-popup-calendar");
98
+ var import_hidden_popup_kanban = require("./hidden-popup-kanban");
96
99
  const FORM_BLOCK_USES = /* @__PURE__ */ new Set(["FormBlockModel", "CreateFormModel", "EditFormModel", ...import_approval.APPROVAL_FORM_BLOCK_USES]);
97
100
  const AUTO_SUBMIT_FORM_BLOCK_USES = /* @__PURE__ */ new Set(["CreateFormModel", "EditFormModel"]);
98
101
  const FLOW_SURFACE_DEFAULT_ACTION_SETTINGS_KEYS = /* @__PURE__ */ new Set(["filter"]);
@@ -121,12 +124,6 @@ const DEFAULT_CALENDAR_DATE_TIME_FIELD_TYPES = [
121
124
  ];
122
125
  const CALENDAR_DEFAULT_VIEWS = /* @__PURE__ */ new Set(["month", "week", "day"]);
123
126
  const CALENDAR_WEEK_STARTS = /* @__PURE__ */ new Set([0, 1]);
124
- const CALENDAR_POPUP_ACTION_KEYS = ["quickCreateAction", "eventViewAction"];
125
- const KANBAN_POPUP_ACTION_UID_SUFFIX_BY_KEY = {
126
- quickCreateAction: "-quick-create-action",
127
- cardViewAction: "-card-view-action"
128
- };
129
- const KANBAN_POPUP_ACTION_KEYS = Object.keys(KANBAN_POPUP_ACTION_UID_SUFFIX_BY_KEY);
130
127
  const CANONICAL_BLOCK_HEADER_USES = /* @__PURE__ */ new Set([
131
128
  "TableBlockModel",
132
129
  "CalendarBlockModel",
@@ -391,6 +388,14 @@ const FILTER_FORM_BLOCK_LAYOUT_STEP_PARAM_MIRRORS = [
391
388
  { domain: "props", key: "labelWidth", stepParamsPath: ["formFilterBlockModelSettings", "layout", "labelWidth"] },
392
389
  { domain: "props", key: "labelWrap", stepParamsPath: ["formFilterBlockModelSettings", "layout", "labelWrap"] }
393
390
  ];
391
+ const UPDATE_SETTINGS_POPUP_STEP_PARAM_REPLACE_PATHS_BY_USE = {
392
+ CalendarBlockModel: [
393
+ ["calendarSettings", "quickCreatePopupSettings"],
394
+ ["calendarSettings", "eventPopupSettings"]
395
+ ],
396
+ KanbanBlockModel: [["kanbanSettings", "popup"]],
397
+ KanbanCardItemModel: [["cardSettings", "popup"]]
398
+ };
394
399
  const DIVIDER_ITEM_STEP_PARAM_MIRRORS = [
395
400
  { domain: "props", key: "label", stepParamsPath: ["markdownItemSetting", "title", "label"] },
396
401
  { domain: "props", key: "orientation", stepParamsPath: ["markdownItemSetting", "title", "orientation"] },
@@ -530,6 +535,17 @@ class FlowSurfacesService {
530
535
  syncApprovalRuntimeConfigForSurfaceRoot: (root, transaction) => this.approvalRuntimeConfigService.syncApprovalRuntimeConfigForSurfaceRoot(root, transaction)
531
536
  });
532
537
  }
538
+ get hiddenPopupRuntime() {
539
+ return {
540
+ repository: this.repository,
541
+ buildPopupOpenViewWithTemplate: (input) => this.buildPopupOpenViewWithTemplate(input),
542
+ clearFlowTemplateUsagesForNodeTree: (uid2, transaction) => this.clearFlowTemplateUsagesForNodeTree(uid2, transaction),
543
+ ensurePopupHostDefaultContent: (input) => this.ensurePopupHostDefaultContent(input),
544
+ reconcilePopupOpenViewTransition: (uid2, currentOpenView, nextOpenView, transaction) => this.reconcilePopupOpenViewTransition(uid2, currentOpenView, nextOpenView, transaction),
545
+ removeNodeTreeWithBindings: (uid2, transaction) => this.removeNodeTreeWithBindings(uid2, transaction),
546
+ syncFlowTemplateUsagesForNodeTree: (uid2, transaction) => this.syncFlowTemplateUsagesForNodeTree(uid2, transaction)
547
+ };
548
+ }
533
549
  async setFlowModelNodeAsyncFlag(uid2, asyncFlag, transaction) {
534
550
  var _a, _b;
535
551
  const sequelize = (_a = this.db) == null ? void 0 : _a.sequelize;
@@ -3031,7 +3047,7 @@ class FlowSurfacesService {
3031
3047
  "FLOW_SURFACE_TEMPLATE_POPUP_SOURCE_UNSUPPORTED"
3032
3048
  );
3033
3049
  }
3034
- if (popupTemplateUid && !this.isEditableDefaultActionPopupTemplateReference(node, openView)) {
3050
+ if (this.isPopupTemplateReferenceOpenViewState(openView) && !this.isEditableDefaultActionPopupTemplateReference(node, openView)) {
3035
3051
  (0, import_errors.throwBadRequest)(
3036
3052
  `flowSurfaces ${actionName} target '${node.uid}' already uses a popup template; convert it to copy first`,
3037
3053
  "FLOW_SURFACE_TEMPLATE_SOURCE_ALREADY_TEMPLATED"
@@ -3577,7 +3593,7 @@ class FlowSurfacesService {
3577
3593
  };
3578
3594
  }
3579
3595
  const openViewStep = (0, import_template_service_utils.findFlowTemplateOpenViewStep)(node);
3580
- const popupTemplateUid = String(((_a = openViewStep == null ? void 0 : openViewStep.openView) == null ? void 0 : _a.popupTemplateUid) || "").trim();
3596
+ const popupTemplateUid = this.isPopupTemplateReferenceOpenViewState(openViewStep == null ? void 0 : openViewStep.openView) ? String(((_a = openViewStep == null ? void 0 : openViewStep.openView) == null ? void 0 : _a.popupTemplateUid) || "").trim() : "";
3581
3597
  if (popupTemplateUid) {
3582
3598
  const template = await this.getFlowTemplateOrThrow(actionName, popupTemplateUid, {
3583
3599
  transaction,
@@ -3869,19 +3885,52 @@ class FlowSurfacesService {
3869
3885
  });
3870
3886
  const result = await (0, import_compose_runtime.executeComposeRuntime)(plan, {
3871
3887
  removeExistingItem: async (uid2) => this.removeNodeTreeWithBindings(uid2, options.transaction),
3872
- createBlock: async (payload) => this.addBlock(payload, {
3873
- ...options,
3874
- deferAutoLayout: true,
3875
- enabledPackages,
3876
- skipDefaultBlockActions: true
3877
- }),
3888
+ createBlock: async (payload, spec) => {
3889
+ const calendarPopupSettings = spec.type === "calendar" && spec.settings ? import_lodash.default.pick(spec.settings, [
3890
+ "quickCreatePopup",
3891
+ "eventPopup",
3892
+ "quickCreatePopupSettings",
3893
+ "eventPopupSettings"
3894
+ ]) : {};
3895
+ const kanbanPopupSettings = spec.type === "kanban" && spec.settings ? import_lodash.default.pick(spec.settings, [
3896
+ "groupField",
3897
+ "groupOptions",
3898
+ "groupTitleField",
3899
+ "groupColorField",
3900
+ "styleVariant",
3901
+ "dragEnabled",
3902
+ "dragSortBy",
3903
+ "quickCreateEnabled",
3904
+ "enableCardClick",
3905
+ "quickCreatePopup",
3906
+ "cardPopup",
3907
+ "quickCreatePopupSettings",
3908
+ "cardPopupSettings"
3909
+ ]) : {};
3910
+ const hiddenPopupSettings = {
3911
+ ...calendarPopupSettings,
3912
+ ...kanbanPopupSettings
3913
+ };
3914
+ return this.addBlock(
3915
+ {
3916
+ ...payload,
3917
+ ...Object.keys(hiddenPopupSettings).length ? { settings: hiddenPopupSettings } : {}
3918
+ },
3919
+ {
3920
+ ...options,
3921
+ deferAutoLayout: true,
3922
+ enabledPackages,
3923
+ skipDefaultBlockActions: true
3924
+ }
3925
+ );
3926
+ },
3878
3927
  applyNodeSettings: async (actionName, targetUid, settings) => {
3879
3928
  if (!targetUid) {
3880
3929
  return;
3881
3930
  }
3882
3931
  await this.applyInlineNodeSettings(actionName, targetUid, settings, options);
3883
3932
  },
3884
- resolveBlockSettings: (settings, state) => this.resolveComposeBlockSettings(settings, state.keyMap),
3933
+ resolveBlockSettings: (settings, state, block) => this.resolveComposeBlockSettings(settings, state.keyMap, block),
3885
3934
  createField: async (payload) => this.addField(payload, {
3886
3935
  ...options,
3887
3936
  popupTemplateAliasSession
@@ -4964,7 +5013,7 @@ class FlowSurfacesService {
4964
5013
  };
4965
5014
  }
4966
5015
  async addBlock(values, options = {}) {
4967
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
5016
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
4968
5017
  const templateRef = import_lodash.default.isUndefined(values == null ? void 0 : values.template) ? void 0 : this.normalizeFlowTemplateReference("addBlock", values.template, {
4969
5018
  allowUsage: true,
4970
5019
  expectedType: "block"
@@ -4996,12 +5045,16 @@ class FlowSurfacesService {
4996
5045
  const enabledPackages = await this.resolveEnabledPluginPackages(options);
4997
5046
  const hasInlineFields = Object.prototype.hasOwnProperty.call(values || {}, "fields") || Object.prototype.hasOwnProperty.call(values || {}, "fieldsLayout");
4998
5047
  let resolvedTarget = await this.locator.resolve(target, options);
4999
- let targetNode = await this.loadResolvedNode(resolvedTarget, options.transaction);
5048
+ let targetNode = await this.loadResolvedNode(resolvedTarget, options.transaction, {
5049
+ ensureManagedPopupTemplateTargets: true
5050
+ });
5000
5051
  const targetOpenView = this.resolvePopupHostOpenView(targetNode);
5001
5052
  if (this.isPopupFieldHostUse(targetNode == null ? void 0 : targetNode.use) && !targetOpenView) {
5002
5053
  await this.ensureLocalFieldPopupSurface("addBlock", target.uid, options, { popup: {} });
5003
5054
  resolvedTarget = await this.locator.resolve(target, options);
5004
- targetNode = await this.loadResolvedNode(resolvedTarget, options.transaction);
5055
+ targetNode = await this.loadResolvedNode(resolvedTarget, options.transaction, {
5056
+ ensureManagedPopupTemplateTargets: true
5057
+ });
5005
5058
  }
5006
5059
  const popupProfile = await this.resolvePopupBlockProfile(
5007
5060
  target.uid,
@@ -5059,11 +5112,13 @@ class FlowSurfacesService {
5059
5112
  const blockProps = catalogItem.use === "CalendarBlockModel" ? this.buildCalendarInitialBlockProps({
5060
5113
  actionName: "addBlock",
5061
5114
  resourceInit: effectiveResourceInit,
5062
- props: values.props
5115
+ props: values.props,
5116
+ settings: inlineSettings
5063
5117
  }) : catalogItem.use === "KanbanBlockModel" ? this.buildKanbanInitialBlockProps({
5064
5118
  actionName: "addBlock",
5065
5119
  resourceInit: effectiveResourceInit,
5066
- props: values.props
5120
+ props: values.props,
5121
+ settings: inlineSettings
5067
5122
  }) : values.props;
5068
5123
  const initialGrid = options.deferAutoLayout ? null : await this.repository.findModelById(parentUid, {
5069
5124
  transaction: options.transaction,
@@ -5075,8 +5130,39 @@ class FlowSurfacesService {
5075
5130
  resourceInit: effectiveResourceInit,
5076
5131
  props: blockProps,
5077
5132
  decoratorProps: values.decoratorProps,
5078
- stepParams: values.stepParams
5079
- });
5133
+ stepParams: catalogItem.use === "CalendarBlockModel" ? this.buildCalendarInitialStepParams({
5134
+ stepParams: values.stepParams,
5135
+ props: values.props,
5136
+ settings: inlineSettings
5137
+ }) : catalogItem.use === "KanbanBlockModel" ? this.buildKanbanInitialStepParams({
5138
+ stepParams: values.stepParams,
5139
+ props: values.props,
5140
+ settings: inlineSettings
5141
+ }) : values.stepParams
5142
+ });
5143
+ if (catalogItem.use === "KanbanBlockModel") {
5144
+ const itemNode2 = (0, import_service_utils.getSingleNodeSubModel)((_a = tree.subModels) == null ? void 0 : _a.item);
5145
+ if (itemNode2) {
5146
+ const itemProps = this.buildKanbanInitialItemProps({
5147
+ props: values.props,
5148
+ settings: inlineSettings
5149
+ });
5150
+ const itemStepParams = this.buildKanbanInitialItemStepParams({
5151
+ stepParams: itemNode2.stepParams,
5152
+ props: values.props,
5153
+ settings: inlineSettings
5154
+ });
5155
+ if (Object.keys(itemProps).length) {
5156
+ itemNode2.props = {
5157
+ ...itemNode2.props || {},
5158
+ ...itemProps
5159
+ };
5160
+ }
5161
+ if (Object.keys(itemStepParams).length) {
5162
+ itemNode2.stepParams = itemStepParams;
5163
+ }
5164
+ }
5165
+ }
5080
5166
  this.contractGuard.validateNodeTreeAgainstContract(tree);
5081
5167
  const created = await this.repository.upsertModel(
5082
5168
  {
@@ -5087,13 +5173,13 @@ class FlowSurfacesService {
5087
5173
  },
5088
5174
  { transaction: options.transaction }
5089
5175
  );
5090
- const gridNode = (0, import_service_utils.getSingleNodeSubModel)((_a = tree.subModels) == null ? void 0 : _a.grid);
5091
- const itemNode = (0, import_service_utils.getSingleNodeSubModel)((_b = tree.subModels) == null ? void 0 : _b.item);
5092
- const itemGridNode = (0, import_service_utils.getSingleNodeSubModel)((_c = itemNode == null ? void 0 : itemNode.subModels) == null ? void 0 : _c.grid);
5093
- const columnNodes = (0, import_service_utils.getNodeSubModelList)((_d = tree.subModels) == null ? void 0 : _d.columns);
5176
+ const gridNode = (0, import_service_utils.getSingleNodeSubModel)((_b = tree.subModels) == null ? void 0 : _b.grid);
5177
+ const itemNode = (0, import_service_utils.getSingleNodeSubModel)((_c = tree.subModels) == null ? void 0 : _c.item);
5178
+ const itemGridNode = (0, import_service_utils.getSingleNodeSubModel)((_d = itemNode == null ? void 0 : itemNode.subModels) == null ? void 0 : _d.grid);
5179
+ const columnNodes = (0, import_service_utils.getNodeSubModelList)((_e = tree.subModels) == null ? void 0 : _e.columns);
5094
5180
  const blockGridUid = (gridNode == null ? void 0 : gridNode.uid) || (itemGridNode == null ? void 0 : itemGridNode.uid);
5095
5181
  const popupGridUid = popupSurface == null ? void 0 : popupSurface.gridUid;
5096
- const actionsColumnUid = catalogItem.use === "TableBlockModel" ? await this.ensureTableActionsColumn(created, options.transaction) : (_e = columnNodes.find((item) => item.use === "TableActionsColumnModel")) == null ? void 0 : _e.uid;
5182
+ const actionsColumnUid = catalogItem.use === "TableBlockModel" ? await this.ensureTableActionsColumn(created, options.transaction) : (_f = columnNodes.find((item) => item.use === "TableActionsColumnModel")) == null ? void 0 : _f.uid;
5097
5183
  const result = {
5098
5184
  uid: created,
5099
5185
  parentUid,
@@ -5111,8 +5197,52 @@ class FlowSurfacesService {
5111
5197
  popupGridUid: popupSurface.gridUid
5112
5198
  } : {}
5113
5199
  };
5114
- await this.applyInlineNodeSettings("addBlock", created, inlineSettings, options);
5115
- if ((_f = inlineFields == null ? void 0 : inlineFields.fields) == null ? void 0 : _f.length) {
5200
+ const ensureInitialBlockPopupHosts = async () => {
5201
+ if (catalogItem.use === "CalendarBlockModel") {
5202
+ const calendarNode = await this.repository.findModelById(created, {
5203
+ transaction: options.transaction,
5204
+ includeAsyncNode: true
5205
+ });
5206
+ if (calendarNode == null ? void 0 : calendarNode.uid) {
5207
+ await this.ensureCalendarBlockPopupHosts(calendarNode, options.transaction, {
5208
+ quickCreateAction: this.resolveCalendarInitialPopupOverride(
5209
+ inlineSettings,
5210
+ "quickCreatePopup",
5211
+ "quickCreatePopupSettings"
5212
+ ),
5213
+ eventViewAction: this.resolveCalendarInitialPopupOverride(
5214
+ inlineSettings,
5215
+ "eventPopup",
5216
+ "eventPopupSettings"
5217
+ )
5218
+ });
5219
+ }
5220
+ }
5221
+ if (catalogItem.use === "KanbanBlockModel") {
5222
+ const kanbanNode = await this.repository.findModelById(created, {
5223
+ transaction: options.transaction,
5224
+ includeAsyncNode: true
5225
+ });
5226
+ if (kanbanNode == null ? void 0 : kanbanNode.uid) {
5227
+ await this.ensureKanbanBlockPopupHosts(kanbanNode, options.transaction, {
5228
+ quickCreateAction: this.resolveKanbanInitialPopupOverride(
5229
+ inlineSettings,
5230
+ "quickCreatePopup",
5231
+ "quickCreatePopupSettings"
5232
+ ),
5233
+ cardViewAction: this.resolveKanbanInitialPopupOverride(inlineSettings, "cardPopup", "cardPopupSettings")
5234
+ });
5235
+ }
5236
+ }
5237
+ };
5238
+ await ensureInitialBlockPopupHosts();
5239
+ const inlineSettingsForConfigure = catalogItem.use === "CalendarBlockModel" ? this.omitHiddenPopupSettingsForConfigure(
5240
+ this.normalizeCalendarInlineSettingsForConfigure(inlineSettings),
5241
+ "calendar"
5242
+ ) : catalogItem.use === "KanbanBlockModel" ? this.omitHiddenPopupSettingsForConfigure(inlineSettings, "kanban") : inlineSettings;
5243
+ await this.applyInlineNodeSettings("addBlock", created, inlineSettingsForConfigure, options);
5244
+ await ensureInitialBlockPopupHosts();
5245
+ if ((_g = inlineFields == null ? void 0 : inlineFields.fields) == null ? void 0 : _g.length) {
5116
5246
  const fieldTargetUid = this.resolveComposeFieldContainerUid(inlineFields, result);
5117
5247
  const createdByKey = {};
5118
5248
  for (const fieldSpec of inlineFields.fields) {
@@ -5160,7 +5290,7 @@ class FlowSurfacesService {
5160
5290
  includeAsyncNode: true
5161
5291
  });
5162
5292
  const layoutItems = import_lodash.default.castArray(
5163
- ((_i = (_h = (_g = layoutHost == null ? void 0 : layoutHost.subModels) == null ? void 0 : _g.grid) == null ? void 0 : _h.subModels) == null ? void 0 : _i.items) || ((_j = layoutHost == null ? void 0 : layoutHost.subModels) == null ? void 0 : _j.items) || []
5293
+ ((_j = (_i = (_h = layoutHost == null ? void 0 : layoutHost.subModels) == null ? void 0 : _h.grid) == null ? void 0 : _i.subModels) == null ? void 0 : _j.items) || ((_k = layoutHost == null ? void 0 : layoutHost.subModels) == null ? void 0 : _k.items) || []
5164
5294
  );
5165
5295
  const layoutPayload = this.buildComposeLayoutPayload({
5166
5296
  layout: inlineFields.fieldsLayout,
@@ -6157,8 +6287,30 @@ class FlowSurfacesService {
6157
6287
  shouldAutoSaveDefaultActionPopupTemplate(popup) {
6158
6288
  return (popup == null ? void 0 : popup[import_default_block_actions.FLOW_SURFACE_INTERNAL_AUTO_SAVE_DEFAULT_POPUP_TEMPLATE_KEY]) === true;
6159
6289
  }
6290
+ resolveDefaultActionPopupSemanticUse(use) {
6291
+ const normalizedUse = String(use || "").trim();
6292
+ if (normalizedUse === "CalendarQuickCreateActionModel") {
6293
+ return "AddNewActionModel";
6294
+ }
6295
+ if (normalizedUse === "CalendarEventViewActionModel") {
6296
+ return "ViewActionModel";
6297
+ }
6298
+ if (normalizedUse === "KanbanQuickCreateActionModel") {
6299
+ return "AddNewActionModel";
6300
+ }
6301
+ if (normalizedUse === "KanbanCardViewActionModel") {
6302
+ return "ViewActionModel";
6303
+ }
6304
+ return normalizedUse || void 0;
6305
+ }
6306
+ getDefaultActionPopupConfigForNode(actionNode) {
6307
+ return (0, import_default_action_popup.getFlowSurfaceDefaultActionPopupConfigByUse)(this.resolveDefaultActionPopupSemanticUse(actionNode == null ? void 0 : actionNode.use));
6308
+ }
6309
+ isDefaultActionPopupUseForNode(actionNode) {
6310
+ return !!this.getDefaultActionPopupConfigForNode(actionNode);
6311
+ }
6160
6312
  shouldImplicitlyTemplateDefaultActionPopup(actionNode, popup) {
6161
- if (!(0, import_default_action_popup.isFlowSurfaceDefaultActionPopupUse)(actionNode == null ? void 0 : actionNode.use)) {
6313
+ if (!this.isDefaultActionPopupUseForNode(actionNode)) {
6162
6314
  return false;
6163
6315
  }
6164
6316
  if (import_lodash.default.isPlainObject(popup == null ? void 0 : popup.template) || !import_lodash.default.isUndefined(popup == null ? void 0 : popup.saveAsTemplate)) {
@@ -6190,7 +6342,7 @@ class FlowSurfacesService {
6190
6342
  transaction,
6191
6343
  includeAsyncNode: true
6192
6344
  });
6193
- const actionConfig = (0, import_default_action_popup.getFlowSurfaceDefaultActionPopupConfigByUse)(actionNode == null ? void 0 : actionNode.use);
6345
+ const actionConfig = this.getDefaultActionPopupConfigForNode(actionNode);
6194
6346
  const popupProfile = (actionNode == null ? void 0 : actionNode.uid) ? await this.resolvePopupBlockProfile(actionNode.uid, null, actionNode, transaction).catch(() => null) : null;
6195
6347
  const popupType = actionConfig == null ? void 0 : actionConfig.type;
6196
6348
  const collectionLabel = String(
@@ -6239,10 +6391,13 @@ class FlowSurfacesService {
6239
6391
  if (explicitTitle) {
6240
6392
  return explicitTitle;
6241
6393
  }
6242
- if (!(0, import_default_action_popup.isFlowSurfaceDefaultActionPopupUse)(actionNode == null ? void 0 : actionNode.use)) {
6394
+ if (!this.isDefaultActionPopupUseForNode(actionNode)) {
6243
6395
  return void 0;
6244
6396
  }
6245
- return (0, import_default_action_popup.resolveFlowSurfaceDefaultActionPopupTabTitle)(actionNode == null ? void 0 : actionNode.use, this.getActionButtonTitle(actionNode));
6397
+ return (0, import_default_action_popup.resolveFlowSurfaceDefaultActionPopupTabTitle)(
6398
+ this.resolveDefaultActionPopupSemanticUse(actionNode == null ? void 0 : actionNode.use),
6399
+ this.getActionButtonTitle(actionNode)
6400
+ );
6246
6401
  }
6247
6402
  buildInlinePopupTemplateOpenView(popup, fallbackTitle) {
6248
6403
  const normalizedTitle = this.normalizeOptionalPopupTitle(popup == null ? void 0 : popup.title) || this.normalizeOptionalPopupTitle(fallbackTitle);
@@ -6384,7 +6539,21 @@ class FlowSurfacesService {
6384
6539
  if (this.isPopupFieldHostUse(targetUse)) {
6385
6540
  return ["view", "generic"];
6386
6541
  }
6387
- const actionConfig = (0, import_default_action_popup.getFlowSurfaceDefaultActionPopupConfigByUse)(targetUse);
6542
+ if (targetUse === "CalendarQuickCreateActionModel") {
6543
+ return ["addNew"];
6544
+ }
6545
+ if (targetUse === "CalendarEventViewActionModel") {
6546
+ return ["view", "generic"];
6547
+ }
6548
+ if (targetUse === "KanbanQuickCreateActionModel") {
6549
+ return ["addNew"];
6550
+ }
6551
+ if (targetUse === "KanbanCardViewActionModel") {
6552
+ return ["view", "generic"];
6553
+ }
6554
+ const actionConfig = (0, import_default_action_popup.getFlowSurfaceDefaultActionPopupConfigByUse)(
6555
+ this.resolveDefaultActionPopupSemanticUse(targetUse)
6556
+ );
6388
6557
  if (actionConfig) {
6389
6558
  return actionConfig.type === "view" ? ["view", "generic"] : [actionConfig.type];
6390
6559
  }
@@ -6528,7 +6697,8 @@ class FlowSurfacesService {
6528
6697
  ...popupTemplateHasSourceId && template.sourceId ? { sourceId: template.sourceId } : {},
6529
6698
  popupTemplateHasFilterByTk,
6530
6699
  popupTemplateHasSourceId,
6531
- popupTemplateMode: mode
6700
+ popupTemplateMode: mode,
6701
+ popupTemplateUid: template.uid
6532
6702
  });
6533
6703
  if (mode === "copy") {
6534
6704
  return {
@@ -6536,16 +6706,21 @@ class FlowSurfacesService {
6536
6706
  popupTemplateContext: true
6537
6707
  };
6538
6708
  }
6539
- return {
6540
- ...base,
6541
- popupTemplateUid: template.uid
6542
- };
6709
+ return base;
6543
6710
  }
6544
6711
  isReferencedPopupTemplateOpenView(openView, hostUid) {
6545
- return !!this.resolveExternalPopupHostUid(hostUid, openView) && !!String((openView == null ? void 0 : openView.popupTemplateUid) || "").trim() && !(openView == null ? void 0 : openView.popupTemplateContext);
6712
+ return !!this.resolveExternalPopupHostUid(hostUid, openView) && this.isPopupTemplateReferenceOpenViewState(openView);
6713
+ }
6714
+ isPopupTemplateReferenceOpenViewState(openView) {
6715
+ const popupTemplateUid = String((openView == null ? void 0 : openView.popupTemplateUid) || "").trim();
6716
+ if (!popupTemplateUid || (openView == null ? void 0 : openView.popupTemplateContext)) {
6717
+ return false;
6718
+ }
6719
+ const popupTemplateMode = String((openView == null ? void 0 : openView.popupTemplateMode) || "reference").trim() || "reference";
6720
+ return popupTemplateMode !== "copy";
6546
6721
  }
6547
6722
  isEditableDefaultActionPopupTemplateReference(hostNode, openView) {
6548
- return (0, import_default_action_popup.isFlowSurfaceDefaultActionPopupUse)(hostNode == null ? void 0 : hostNode.use) && this.isReferencedPopupTemplateOpenView(openView, hostNode == null ? void 0 : hostNode.uid);
6723
+ return this.isDefaultActionPopupUseForNode(hostNode) && this.isReferencedPopupTemplateOpenView(openView, hostNode == null ? void 0 : hostNode.uid);
6549
6724
  }
6550
6725
  resolveExternalPopupHostUid(hostUid, openView) {
6551
6726
  const normalizedHostUid = String(hostUid || "").trim();
@@ -6658,8 +6833,11 @@ class FlowSurfacesService {
6658
6833
  if (!normalizedUid) {
6659
6834
  (0, import_errors.throwBadRequest)(`flowSurfaces ${actionName} openView.uid cannot be empty`);
6660
6835
  }
6836
+ const normalizedHostUid = String(options.popupTemplateHostUid || "").trim();
6661
6837
  normalizedOpenView.uid = normalizedUid;
6662
- await this.assertOpenViewUidTarget(actionName, normalizedUid, options);
6838
+ if (normalizedUid !== normalizedHostUid) {
6839
+ await this.assertOpenViewUidTarget(actionName, normalizedUid, options);
6840
+ }
6663
6841
  }
6664
6842
  if (!import_lodash.default.isUndefined(normalizedOpenView.mode)) {
6665
6843
  const rawMode = String(normalizedOpenView.mode || "").trim();
@@ -6849,14 +7027,28 @@ class FlowSurfacesService {
6849
7027
  (0, import_service_utils.rethrowInlineConfigurationError)(error, `flowSurfaces ${actionName} settings invalid`);
6850
7028
  }
6851
7029
  }
6852
- resolveComposeBlockSettings(settings, keyMap) {
6853
- if (!import_lodash.default.isPlainObject(settings == null ? void 0 : settings.connectFields) || !Array.isArray(settings.connectFields.targets)) {
6854
- return settings;
6855
- }
6856
- const nextSettings = import_lodash.default.cloneDeep(settings);
6857
- nextSettings.connectFields = {
6858
- ...nextSettings.connectFields,
6859
- targets: import_lodash.default.castArray(nextSettings.connectFields.targets).map((target) => {
7030
+ resolveComposeBlockSettings(settings, keyMap, block) {
7031
+ var _a, _b;
7032
+ let nextSettings = settings;
7033
+ if (((_a = block == null ? void 0 : block.spec) == null ? void 0 : _a.type) === "calendar") {
7034
+ nextSettings = import_lodash.default.omit(nextSettings, [
7035
+ "quickCreatePopup",
7036
+ "eventPopup",
7037
+ "quickCreatePopupSettings",
7038
+ "eventPopupSettings"
7039
+ ]);
7040
+ } else if (((_b = block == null ? void 0 : block.spec) == null ? void 0 : _b.type) === "kanban") {
7041
+ const omittedKeys = ["quickCreatePopup", "cardPopup", "quickCreatePopupSettings", "cardPopupSettings"];
7042
+ const withoutHiddenPopupSettings = import_lodash.default.omit(nextSettings, omittedKeys);
7043
+ nextSettings = Object.keys(withoutHiddenPopupSettings).length || omittedKeys.every((key) => !import_lodash.default.has(nextSettings, key)) ? withoutHiddenPopupSettings : {};
7044
+ }
7045
+ if (!import_lodash.default.isPlainObject(nextSettings == null ? void 0 : nextSettings.connectFields) || !Array.isArray(nextSettings.connectFields.targets)) {
7046
+ return nextSettings;
7047
+ }
7048
+ const resolvedSettings = import_lodash.default.cloneDeep(nextSettings);
7049
+ resolvedSettings.connectFields = {
7050
+ ...resolvedSettings.connectFields,
7051
+ targets: import_lodash.default.castArray(resolvedSettings.connectFields.targets).map((target) => {
6860
7052
  if (!import_lodash.default.isPlainObject(target) || import_lodash.default.isUndefined(target.target) || target.target === null || target.target === "") {
6861
7053
  return target;
6862
7054
  }
@@ -6868,7 +7060,7 @@ class FlowSurfacesService {
6868
7060
  return nextTarget;
6869
7061
  })
6870
7062
  };
6871
- return nextSettings;
7063
+ return resolvedSettings;
6872
7064
  }
6873
7065
  async applyInlineFieldPopup(actionName, result, popup, options) {
6874
7066
  popup = this.prepareInlinePopupTemplateAliases(actionName, popup, options.popupTemplateAliasSession);
@@ -7302,7 +7494,7 @@ class FlowSurfacesService {
7302
7494
  if (!(actionNode == null ? void 0 : actionNode.uid)) {
7303
7495
  return;
7304
7496
  }
7305
- const actionConfig = (0, import_default_action_popup.getFlowSurfaceDefaultActionPopupConfigByUse)(actionNode.use);
7497
+ const actionConfig = this.getDefaultActionPopupConfigForNode(actionNode);
7306
7498
  if (!actionConfig) {
7307
7499
  return;
7308
7500
  }
@@ -7312,7 +7504,7 @@ class FlowSurfacesService {
7312
7504
  }
7313
7505
  const uniqueKeySource = JSON.stringify(
7314
7506
  (0, import_service_utils.buildDefinedPayload)({
7315
- actionUse: actionNode.use,
7507
+ actionUse: this.resolveDefaultActionPopupSemanticUse(actionNode.use),
7316
7508
  dataSourceKey: openView == null ? void 0 : openView.dataSourceKey,
7317
7509
  collectionName: openView == null ? void 0 : openView.collectionName,
7318
7510
  associationName: openView == null ? void 0 : openView.associationName,
@@ -7349,7 +7541,7 @@ class FlowSurfacesService {
7349
7541
  if (options.autoCompleteDefaultPopup === false) {
7350
7542
  return false;
7351
7543
  }
7352
- if (!(0, import_default_action_popup.isFlowSurfaceDefaultActionPopupUse)(actionNode == null ? void 0 : actionNode.use)) {
7544
+ if (!this.isDefaultActionPopupUseForNode(actionNode)) {
7353
7545
  return false;
7354
7546
  }
7355
7547
  const openView = this.resolvePopupHostOpenView(actionNode);
@@ -7373,14 +7565,17 @@ class FlowSurfacesService {
7373
7565
  if (options.includeFallback === false) {
7374
7566
  return void 0;
7375
7567
  }
7376
- return (0, import_default_action_popup.resolveFlowSurfaceDefaultActionPopupTabTitle)(actionNode == null ? void 0 : actionNode.use, this.getActionButtonTitle(actionNode));
7568
+ return (0, import_default_action_popup.resolveFlowSurfaceDefaultActionPopupTabTitle)(
7569
+ this.resolveDefaultActionPopupSemanticUse(actionNode == null ? void 0 : actionNode.use),
7570
+ this.getActionButtonTitle(actionNode)
7571
+ );
7377
7572
  }
7378
7573
  resolveGeneratedDefaultActionPopupMetadata(actionNode, popup, popupProfile) {
7379
7574
  const explicitTitle = this.normalizeOptionalPopupTitle(popup == null ? void 0 : popup.title);
7380
7575
  if (explicitTitle) {
7381
7576
  return void 0;
7382
7577
  }
7383
- const actionConfig = (0, import_default_action_popup.getFlowSurfaceDefaultActionPopupConfigByUse)(actionNode == null ? void 0 : actionNode.use);
7578
+ const actionConfig = this.getDefaultActionPopupConfigForNode(actionNode);
7384
7579
  if (!actionConfig) {
7385
7580
  return void 0;
7386
7581
  }
@@ -7401,7 +7596,9 @@ class FlowSurfacesService {
7401
7596
  if (!collectionName) {
7402
7597
  return [];
7403
7598
  }
7404
- const actionConfig = (0, import_default_action_popup.getFlowSurfaceDefaultActionPopupConfigByUse)(input.actionUse);
7599
+ const actionConfig = (0, import_default_action_popup.getFlowSurfaceDefaultActionPopupConfigByUse)(
7600
+ this.resolveDefaultActionPopupSemanticUse(input.actionUse)
7601
+ );
7405
7602
  if (!actionConfig) {
7406
7603
  return [];
7407
7604
  }
@@ -7435,7 +7632,7 @@ class FlowSurfacesService {
7435
7632
  }
7436
7633
  buildDefaultActionPopupKeyMap(actionNode, namespace) {
7437
7634
  var _a;
7438
- const actionConfig = (0, import_default_action_popup.getFlowSurfaceDefaultActionPopupConfigByUse)(actionNode == null ? void 0 : actionNode.use);
7635
+ const actionConfig = this.getDefaultActionPopupConfigForNode(actionNode);
7439
7636
  if (!actionConfig || !namespace) {
7440
7637
  return /* @__PURE__ */ new Map();
7441
7638
  }
@@ -7557,7 +7754,7 @@ class FlowSurfacesService {
7557
7754
  enabledPackages
7558
7755
  });
7559
7756
  return this.remapDefaultActionPopupBlocks(
7560
- (0, import_default_action_popup.buildFlowSurfaceDefaultActionPopupBlocks)(actionNode == null ? void 0 : actionNode.use, fields),
7757
+ (0, import_default_action_popup.buildFlowSurfaceDefaultActionPopupBlocks)(this.resolveDefaultActionPopupSemanticUse(actionNode == null ? void 0 : actionNode.use), fields),
7561
7758
  keyMap,
7562
7759
  namespace
7563
7760
  );
@@ -7627,7 +7824,10 @@ class FlowSurfacesService {
7627
7824
  return normalizedTitle || void 0;
7628
7825
  }
7629
7826
  async syncDefaultActionPopupTabTitle(actionNode, popupTab, options) {
7630
- const popupTabTitle = this.normalizeOptionalPopupTitle(options.popupTabTitle) || (0, import_default_action_popup.resolveFlowSurfaceDefaultActionPopupTabTitle)(actionNode == null ? void 0 : actionNode.use, this.getActionButtonTitle(actionNode));
7827
+ const popupTabTitle = this.normalizeOptionalPopupTitle(options.popupTabTitle) || (0, import_default_action_popup.resolveFlowSurfaceDefaultActionPopupTabTitle)(
7828
+ this.resolveDefaultActionPopupSemanticUse(actionNode == null ? void 0 : actionNode.use),
7829
+ this.getActionButtonTitle(actionNode)
7830
+ );
7631
7831
  if (!(popupTab == null ? void 0 : popupTab.uid) || !popupTabTitle || this.resolvePopupTabTitle(popupTab) === popupTabTitle) {
7632
7832
  return;
7633
7833
  }
@@ -7653,7 +7853,10 @@ class FlowSurfacesService {
7653
7853
  });
7654
7854
  const popupPage = (0, import_service_utils.getSingleNodeSubModel)((_a = popupHost == null ? void 0 : popupHost.subModels) == null ? void 0 : _a.page);
7655
7855
  const popupTab = import_lodash.default.castArray(((_b = popupPage == null ? void 0 : popupPage.subModels) == null ? void 0 : _b.tabs) || [])[0];
7656
- const popupTabTitle = this.normalizeOptionalPopupTitle(options.popupTabTitle) || (0, import_default_action_popup.resolveFlowSurfaceDefaultActionPopupTabTitle)(actionNode == null ? void 0 : actionNode.use, this.getActionButtonTitle(actionNode));
7856
+ const popupTabTitle = this.normalizeOptionalPopupTitle(options.popupTabTitle) || (0, import_default_action_popup.resolveFlowSurfaceDefaultActionPopupTabTitle)(
7857
+ this.resolveDefaultActionPopupSemanticUse(actionNode == null ? void 0 : actionNode.use),
7858
+ this.getActionButtonTitle(actionNode)
7859
+ );
7657
7860
  if (!(popupTab == null ? void 0 : popupTab.uid) || !popupTabTitle || this.resolvePopupTabTitle(popupTab) === popupTabTitle) {
7658
7861
  return;
7659
7862
  }
@@ -7685,7 +7888,10 @@ class FlowSurfacesService {
7685
7888
  includeAsyncNode: true
7686
7889
  }) || fallbackActionNode;
7687
7890
  const openViewStep = (0, import_template_service_utils.findFlowTemplateOpenViewStep)(actionNode);
7688
- const openViewTitle = this.normalizeOptionalPopupTitle(options.openViewTitle) || (0, import_default_action_popup.resolveFlowSurfaceDefaultActionPopupTabTitle)(actionNode == null ? void 0 : actionNode.use, this.getActionButtonTitle(actionNode));
7891
+ const openViewTitle = this.normalizeOptionalPopupTitle(options.openViewTitle) || (0, import_default_action_popup.resolveFlowSurfaceDefaultActionPopupTabTitle)(
7892
+ this.resolveDefaultActionPopupSemanticUse(actionNode == null ? void 0 : actionNode.use),
7893
+ this.getActionButtonTitle(actionNode)
7894
+ );
7689
7895
  if (!openViewStep || !openViewTitle) {
7690
7896
  return;
7691
7897
  }
@@ -7815,7 +8021,7 @@ class FlowSurfacesService {
7815
8021
  openViewActionName: actionName
7816
8022
  }
7817
8023
  );
7818
- if ((0, import_default_action_popup.isFlowSurfaceDefaultActionPopupUse)(actionNode == null ? void 0 : actionNode.use) && templateRef.mode === "copy") {
8024
+ if (this.isDefaultActionPopupUseForNode(actionNode) && templateRef.mode === "copy") {
7819
8025
  await this.syncDefaultActionPopupCopiedTemplateTabTitle(actionUid, actionNode, {
7820
8026
  ...options,
7821
8027
  popupTabTitle: templateOpenViewTitle
@@ -7935,6 +8141,14 @@ class FlowSurfacesService {
7935
8141
  current.use
7936
8142
  );
7937
8143
  });
8144
+ this.replaceExplicitPopupStepParamSubtreesForUpdateSettings(
8145
+ current,
8146
+ normalizedValues,
8147
+ nextPayload,
8148
+ options.replacePopupStepParamSubtrees === true
8149
+ );
8150
+ this.syncCalendarPopupPropsForUpdateSettings(current, normalizedValues, nextPayload);
8151
+ this.syncKanbanPopupPropsForUpdateSettings(current, normalizedValues, nextPayload);
7938
8152
  this.syncFilterActionSettingsForUpdateSettings(current, normalizedValues, nextPayload);
7939
8153
  this.syncMirroredStepParamsForUpdateSettings(current, nextPayload);
7940
8154
  const updateActionAssignedValues = this.syncUpdateActionAssignedValuesForUpdateSettings(
@@ -8004,12 +8218,22 @@ class FlowSurfacesService {
8004
8218
  } else if (current.use === "ChartBlockModel" && !import_lodash.default.isUndefined((_b = nextPayload.stepParams) == null ? void 0 : _b.chartSettings)) {
8005
8219
  await this.syncChartDataBindingsForNode(effectiveNode, options.transaction);
8006
8220
  }
8007
- if (current.use === "CalendarBlockModel") {
8221
+ if (!options.skipHiddenPopupHostEnsure && current.use === "CalendarBlockModel") {
8008
8222
  await this.ensureCalendarBlockPopupHosts(effectiveNode, options.transaction);
8009
8223
  }
8010
- if (current.use === "KanbanBlockModel") {
8224
+ if (!options.skipHiddenPopupHostEnsure && current.use === "KanbanBlockModel") {
8011
8225
  await this.ensureKanbanBlockPopupHosts(effectiveNode, options.transaction);
8012
8226
  }
8227
+ if (!options.skipHiddenPopupHostEnsure && current.use === "KanbanCardItemModel") {
8228
+ const parentUid = String(current.parentId || "").trim() || (current.uid ? await this.locator.findParentUid(current.uid, options.transaction).catch(() => "") : "") || void 0;
8229
+ const parentNode = parentUid ? await this.repository.findModelById(parentUid, {
8230
+ transaction: options.transaction,
8231
+ includeAsyncNode: true
8232
+ }) : null;
8233
+ if ((parentNode == null ? void 0 : parentNode.use) === "KanbanBlockModel") {
8234
+ await this.ensureKanbanBlockPopupHosts(parentNode, options.transaction);
8235
+ }
8236
+ }
8013
8237
  await this.syncFlowTemplateUsagesForNodeTree(current.uid, options.transaction);
8014
8238
  if (import_approval.APPROVAL_SINGLETON_ACTION_USES.has(current.use || "")) {
8015
8239
  await this.syncApprovalRuntimeConfigForNode(current.uid, options.transaction);
@@ -8019,6 +8243,172 @@ class FlowSurfacesService {
8019
8243
  updated: Object.keys(import_lodash.default.omit(nextPayload, ["uid"]))
8020
8244
  };
8021
8245
  }
8246
+ syncCalendarPopupPropsForUpdateSettings(current, normalizedValues, nextPayload) {
8247
+ if ((current == null ? void 0 : current.use) !== "CalendarBlockModel" || !import_lodash.default.isPlainObject(normalizedValues == null ? void 0 : normalizedValues.props)) {
8248
+ return;
8249
+ }
8250
+ let nextStepParams;
8251
+ for (const actionKey of import_hidden_popup_calendar.CALENDAR_POPUP_ACTION_KEYS) {
8252
+ const propKey = this.getCalendarPopupPropKey(actionKey);
8253
+ if (!Object.prototype.hasOwnProperty.call(normalizedValues.props, propKey)) {
8254
+ continue;
8255
+ }
8256
+ const value = normalizedValues.props[propKey];
8257
+ if (!import_lodash.default.has(normalizedValues, ["stepParams", "calendarSettings", propKey])) {
8258
+ nextStepParams = nextStepParams ?? import_lodash.default.cloneDeep(nextPayload.stepParams ?? (current == null ? void 0 : current.stepParams) ?? {});
8259
+ const currentSettings = import_lodash.default.get(nextStepParams, ["calendarSettings", propKey]);
8260
+ const popupSettings = import_lodash.default.isPlainObject(value) ? this.normalizeCalendarPopupSettings(
8261
+ actionKey,
8262
+ import_lodash.default.isPlainObject(currentSettings) ? { ...import_lodash.default.cloneDeep(currentSettings), ...import_lodash.default.cloneDeep(value) } : value
8263
+ ) : {};
8264
+ import_lodash.default.set(nextStepParams, ["calendarSettings", propKey], import_lodash.default.cloneDeep(popupSettings));
8265
+ }
8266
+ }
8267
+ this.stripPopupPropsFromPayload(nextPayload, import_hidden_popup_calendar.CALENDAR_POPUP_PROP_KEYS);
8268
+ if (nextStepParams) {
8269
+ nextPayload.stepParams = nextStepParams;
8270
+ }
8271
+ }
8272
+ replaceExplicitPopupStepParamSubtreesForUpdateSettings(current, normalizedValues, nextPayload, replacePopupStepParamSubtrees = false) {
8273
+ const replacePaths = UPDATE_SETTINGS_POPUP_STEP_PARAM_REPLACE_PATHS_BY_USE[(current == null ? void 0 : current.use) || ""];
8274
+ if (!(replacePaths == null ? void 0 : replacePaths.length) || !import_lodash.default.isPlainObject(normalizedValues == null ? void 0 : normalizedValues.stepParams)) {
8275
+ return;
8276
+ }
8277
+ let nextStepParams;
8278
+ for (const path of replacePaths) {
8279
+ const inputPath = ["stepParams", ...path];
8280
+ if (!import_lodash.default.has(normalizedValues, inputPath)) {
8281
+ continue;
8282
+ }
8283
+ nextStepParams = nextStepParams ?? import_lodash.default.cloneDeep(nextPayload.stepParams ?? (current == null ? void 0 : current.stepParams) ?? {});
8284
+ const value = import_lodash.default.get(normalizedValues, inputPath);
8285
+ const currentValue = import_lodash.default.get(nextStepParams, path);
8286
+ import_lodash.default.set(
8287
+ nextStepParams,
8288
+ path,
8289
+ this.normalizePopupStepParamReplacementForUpdateSettings(
8290
+ current,
8291
+ path,
8292
+ value,
8293
+ currentValue,
8294
+ replacePopupStepParamSubtrees
8295
+ )
8296
+ );
8297
+ }
8298
+ if (nextStepParams) {
8299
+ nextPayload.stepParams = nextStepParams;
8300
+ }
8301
+ }
8302
+ normalizePopupStepParamReplacementForUpdateSettings(current, path, value, currentValue, replacePopupStepParamSubtrees = false) {
8303
+ if (!import_lodash.default.isPlainObject(value)) {
8304
+ return {};
8305
+ }
8306
+ const mergedValue = !replacePopupStepParamSubtrees && import_lodash.default.isPlainObject(currentValue) ? { ...import_lodash.default.cloneDeep(currentValue), ...import_lodash.default.cloneDeep(value) } : value;
8307
+ if ((current == null ? void 0 : current.use) === "CalendarBlockModel") {
8308
+ const actionKey = path[1] === "quickCreatePopupSettings" ? "quickCreateAction" : "eventViewAction";
8309
+ return this.normalizeCalendarPopupSettings(actionKey, mergedValue);
8310
+ }
8311
+ if ((current == null ? void 0 : current.use) === "KanbanBlockModel") {
8312
+ return this.normalizeKanbanPopupSettings("quickCreateAction", mergedValue, current.uid);
8313
+ }
8314
+ if ((current == null ? void 0 : current.use) === "KanbanCardItemModel") {
8315
+ const parentUid = String((current == null ? void 0 : current.parentId) || "").trim() || void 0;
8316
+ return this.normalizeKanbanPopupSettings("cardViewAction", mergedValue, parentUid);
8317
+ }
8318
+ return import_lodash.default.cloneDeep(mergedValue);
8319
+ }
8320
+ stripPopupPropsFromPayload(nextPayload, keys) {
8321
+ if (!import_lodash.default.isPlainObject(nextPayload.props)) {
8322
+ return;
8323
+ }
8324
+ for (const key of keys) {
8325
+ if (Object.prototype.hasOwnProperty.call(nextPayload.props, key)) {
8326
+ delete nextPayload.props[key];
8327
+ }
8328
+ }
8329
+ }
8330
+ syncKanbanPopupPropsForUpdateSettings(current, normalizedValues, nextPayload) {
8331
+ if (!import_lodash.default.isPlainObject(normalizedValues == null ? void 0 : normalizedValues.props)) {
8332
+ return;
8333
+ }
8334
+ if ((current == null ? void 0 : current.use) === "KanbanBlockModel") {
8335
+ const propToPopupKey = {
8336
+ popupMode: "mode",
8337
+ popupSize: "size",
8338
+ popupTemplateUid: "popupTemplateUid",
8339
+ popupPageModelClass: "pageModelClass",
8340
+ popupTargetUid: "uid"
8341
+ };
8342
+ const writtenProps = Object.keys(propToPopupKey).filter(
8343
+ (propKey) => Object.prototype.hasOwnProperty.call(normalizedValues.props, propKey)
8344
+ );
8345
+ const hasLegacyPopupSettings = Object.prototype.hasOwnProperty.call(
8346
+ normalizedValues.props,
8347
+ "quickCreatePopupSettings"
8348
+ );
8349
+ if (!writtenProps.length && !hasLegacyPopupSettings) {
8350
+ return;
8351
+ }
8352
+ if (import_lodash.default.has(normalizedValues, ["stepParams", "kanbanSettings", "popup"])) {
8353
+ this.stripPopupPropsFromPayload(nextPayload, import_hidden_popup_kanban.KANBAN_BLOCK_POPUP_PROP_KEYS);
8354
+ return;
8355
+ }
8356
+ const nextStepParams = import_lodash.default.cloneDeep(nextPayload.stepParams ?? (current == null ? void 0 : current.stepParams) ?? {});
8357
+ const currentPopupSettings = import_lodash.default.get(nextStepParams, ["kanbanSettings", "popup"]);
8358
+ const popupSettings = import_lodash.default.cloneDeep(import_lodash.default.isPlainObject(currentPopupSettings) ? currentPopupSettings : {});
8359
+ if (import_lodash.default.isPlainObject(normalizedValues.props.quickCreatePopupSettings)) {
8360
+ Object.assign(popupSettings, import_lodash.default.cloneDeep(normalizedValues.props.quickCreatePopupSettings));
8361
+ }
8362
+ for (const propKey of writtenProps) {
8363
+ popupSettings[propToPopupKey[propKey]] = normalizedValues.props[propKey];
8364
+ }
8365
+ import_lodash.default.set(
8366
+ nextStepParams,
8367
+ ["kanbanSettings", "popup"],
8368
+ this.normalizeKanbanPopupSettings("quickCreateAction", popupSettings, current.uid)
8369
+ );
8370
+ nextPayload.stepParams = nextStepParams;
8371
+ this.stripPopupPropsFromPayload(nextPayload, import_hidden_popup_kanban.KANBAN_BLOCK_POPUP_PROP_KEYS);
8372
+ return;
8373
+ }
8374
+ if ((current == null ? void 0 : current.use) === "KanbanCardItemModel") {
8375
+ const propToPopupKey = {
8376
+ openMode: "mode",
8377
+ popupSize: "size",
8378
+ popupTemplateUid: "popupTemplateUid",
8379
+ pageModelClass: "pageModelClass",
8380
+ popupTargetUid: "uid"
8381
+ };
8382
+ const writtenProps = Object.keys(propToPopupKey).filter(
8383
+ (propKey) => Object.prototype.hasOwnProperty.call(normalizedValues.props, propKey)
8384
+ );
8385
+ const hasLegacyPopupSettings = Object.prototype.hasOwnProperty.call(normalizedValues.props, "cardPopupSettings");
8386
+ if (!writtenProps.length && !hasLegacyPopupSettings) {
8387
+ return;
8388
+ }
8389
+ if (import_lodash.default.has(normalizedValues, ["stepParams", "cardSettings", "popup"])) {
8390
+ this.stripPopupPropsFromPayload(nextPayload, import_hidden_popup_kanban.KANBAN_CARD_POPUP_PROP_KEYS);
8391
+ return;
8392
+ }
8393
+ const parentUid = String((current == null ? void 0 : current.parentId) || "").trim() || void 0;
8394
+ const nextStepParams = import_lodash.default.cloneDeep(nextPayload.stepParams ?? (current == null ? void 0 : current.stepParams) ?? {});
8395
+ const currentPopupSettings = import_lodash.default.get(nextStepParams, ["cardSettings", "popup"]);
8396
+ const popupSettings = import_lodash.default.cloneDeep(import_lodash.default.isPlainObject(currentPopupSettings) ? currentPopupSettings : {});
8397
+ if (import_lodash.default.isPlainObject(normalizedValues.props.cardPopupSettings)) {
8398
+ Object.assign(popupSettings, import_lodash.default.cloneDeep(normalizedValues.props.cardPopupSettings));
8399
+ }
8400
+ for (const propKey of writtenProps) {
8401
+ popupSettings[propToPopupKey[propKey]] = normalizedValues.props[propKey];
8402
+ }
8403
+ import_lodash.default.set(
8404
+ nextStepParams,
8405
+ ["cardSettings", "popup"],
8406
+ this.normalizeKanbanPopupSettings("cardViewAction", popupSettings, parentUid)
8407
+ );
8408
+ nextPayload.stepParams = nextStepParams;
8409
+ this.stripPopupPropsFromPayload(nextPayload, import_hidden_popup_kanban.KANBAN_CARD_POPUP_PROP_KEYS);
8410
+ }
8411
+ }
8022
8412
  syncFilterActionSettingsForUpdateSettings(current, values, nextPayload) {
8023
8413
  if ((current == null ? void 0 : current.use) !== "FilterActionModel") {
8024
8414
  return;
@@ -8943,7 +9333,7 @@ class FlowSurfacesService {
8943
9333
  if (!normalizedUid) {
8944
9334
  return null;
8945
9335
  }
8946
- for (const actionKey of CALENDAR_POPUP_ACTION_KEYS) {
9336
+ for (const actionKey of import_hidden_popup_calendar.CALENDAR_POPUP_ACTION_KEYS) {
8947
9337
  const suffix = `-${actionKey}`;
8948
9338
  if (normalizedUid.endsWith(suffix) && normalizedUid.length > suffix.length) {
8949
9339
  return {
@@ -8959,8 +9349,8 @@ class FlowSurfacesService {
8959
9349
  if (!normalizedUid) {
8960
9350
  return null;
8961
9351
  }
8962
- for (const actionKey of KANBAN_POPUP_ACTION_KEYS) {
8963
- const suffix = KANBAN_POPUP_ACTION_UID_SUFFIX_BY_KEY[actionKey];
9352
+ for (const actionKey of import_hidden_popup_kanban.KANBAN_POPUP_ACTION_KEYS) {
9353
+ const suffix = import_hidden_popup_kanban.KANBAN_POPUP_ACTION_UID_SUFFIX_BY_KEY[actionKey];
8964
9354
  if (normalizedUid.endsWith(suffix) && normalizedUid.length > suffix.length) {
8965
9355
  return {
8966
9356
  kanbanUid: normalizedUid.slice(0, -suffix.length),
@@ -9002,6 +9392,20 @@ class FlowSurfacesService {
9002
9392
  await this.ensureKanbanBlockPopupHosts(kanbanNode, options.transaction);
9003
9393
  }
9004
9394
  }
9395
+ const repairedTarget = await this.repository.findModelById(writeTarget.uid, {
9396
+ transaction: options.transaction,
9397
+ includeAsyncNode: true
9398
+ });
9399
+ if (repairedTarget == null ? void 0 : repairedTarget.uid) {
9400
+ return writeTarget;
9401
+ }
9402
+ const ownerNode = await this.repository.findModelById((parsedCalendarPopupTarget == null ? void 0 : parsedCalendarPopupTarget.calendarUid) || (parsedKanbanPopupTarget == null ? void 0 : parsedKanbanPopupTarget.kanbanUid), {
9403
+ transaction: options.transaction,
9404
+ includeAsyncNode: true
9405
+ }).catch(() => null);
9406
+ if (ownerNode == null ? void 0 : ownerNode.uid) {
9407
+ await this.ensureHiddenPopupBlockHostsInManagedPopupTarget(ownerNode, options.transaction);
9408
+ }
9005
9409
  return writeTarget;
9006
9410
  }
9007
9411
  normalizeRootUidValue(actionName, values) {
@@ -10377,20 +10781,44 @@ class FlowSurfacesService {
10377
10781
  changes,
10378
10782
  resetInvalidExisting: resourceChanged
10379
10783
  });
10380
- const quickCreatePopupSettings = Object.prototype.hasOwnProperty.call(changes, "quickCreatePopup") ? await this.normalizeCalendarPopupConfigureValue({
10784
+ const hasQuickCreatePopupChange = Object.prototype.hasOwnProperty.call(changes, "quickCreatePopup");
10785
+ const hasEventPopupChange = Object.prototype.hasOwnProperty.call(changes, "eventPopup");
10786
+ const quickCreatePopupSettingsInput = hasQuickCreatePopupChange ? await this.normalizeCalendarPopupConfigureValue({
10381
10787
  actionName: "configure calendar quickCreatePopup",
10382
10788
  blockUid: current.uid,
10383
10789
  actionKey: "quickCreateAction",
10384
10790
  value: changes.quickCreatePopup,
10385
10791
  transaction: options.transaction
10386
10792
  }) : void 0;
10387
- const eventPopupSettings = Object.prototype.hasOwnProperty.call(changes, "eventPopup") ? await this.normalizeCalendarPopupConfigureValue({
10793
+ const eventPopupSettingsInput = hasEventPopupChange ? await this.normalizeCalendarPopupConfigureValue({
10388
10794
  actionName: "configure calendar eventPopup",
10389
10795
  blockUid: current.uid,
10390
10796
  actionKey: "eventViewAction",
10391
10797
  value: changes.eventPopup,
10392
10798
  transaction: options.transaction
10393
10799
  }) : void 0;
10800
+ const currentQuickCreatePopupSettings = this.getCalendarPopupStoredSettings(current, "quickCreateAction");
10801
+ const currentEventPopupSettings = this.getCalendarPopupStoredSettings(current, "eventViewAction");
10802
+ const quickCreatePopupSettingsBase = resourceChanged ? this.stripCalendarPopupTargetSettingsForResourceChange("quickCreateAction", currentQuickCreatePopupSettings) : currentQuickCreatePopupSettings;
10803
+ const eventPopupSettingsBase = resourceChanged ? this.stripCalendarPopupTargetSettingsForResourceChange("eventViewAction", currentEventPopupSettings) : currentEventPopupSettings;
10804
+ const quickCreatePopupSettings = hasQuickCreatePopupChange ? import_lodash.default.isNull(changes.quickCreatePopup) ? quickCreatePopupSettingsInput || {} : this.mergeCalendarPopupSettings(
10805
+ "quickCreateAction",
10806
+ quickCreatePopupSettingsBase,
10807
+ quickCreatePopupSettingsInput
10808
+ ) : void 0;
10809
+ const eventPopupSettings = hasEventPopupChange ? import_lodash.default.isNull(changes.eventPopup) ? eventPopupSettingsInput || {} : this.mergeCalendarPopupSettings("eventViewAction", eventPopupSettingsBase, eventPopupSettingsInput) : void 0;
10810
+ const previousQuickCreateOpenView = this.buildCalendarPopupOpenView({
10811
+ blockNode: current,
10812
+ actionKey: "quickCreateAction",
10813
+ resourceInit: currentResourceInit,
10814
+ popupSettings: currentQuickCreatePopupSettings
10815
+ });
10816
+ const previousEventOpenView = this.buildCalendarPopupOpenView({
10817
+ blockNode: current,
10818
+ actionKey: "eventViewAction",
10819
+ resourceInit: currentResourceInit,
10820
+ popupSettings: currentEventPopupSettings
10821
+ });
10394
10822
  const result = await this.updateSettings(
10395
10823
  {
10396
10824
  target,
@@ -10399,9 +10827,7 @@ class FlowSurfacesService {
10399
10827
  defaultView,
10400
10828
  enableQuickCreateEvent: quickCreateEvent,
10401
10829
  showLunar,
10402
- weekStart,
10403
- quickCreatePopupSettings,
10404
- eventPopupSettings
10830
+ weekStart
10405
10831
  }),
10406
10832
  stepParams: {
10407
10833
  ...cardSettings ? { cardSettings } : {},
@@ -10420,7 +10846,10 @@ class FlowSurfacesService {
10420
10846
  "showLunar",
10421
10847
  "weekStart",
10422
10848
  "dataScope",
10423
- "linkageRules"
10849
+ "linkageRules",
10850
+ "quickCreatePopup",
10851
+ "eventPopup",
10852
+ "resource"
10424
10853
  ]) ? {
10425
10854
  calendarSettings: (0, import_service_utils.buildDefinedPayload)({
10426
10855
  ...(0, import_service_utils.hasOwnDefined)(changes, "titleField") ? { titleField: { titleField: fieldNames.title } } : {},
@@ -10432,18 +10861,37 @@ class FlowSurfacesService {
10432
10861
  ...(0, import_service_utils.hasOwnDefined)(changes, "showLunar") ? { showLunar: { showLunar: showLunar === true } } : {},
10433
10862
  ...(0, import_service_utils.hasOwnDefined)(changes, "weekStart") ? { weekStart: { weekStart } } : {},
10434
10863
  ...(0, import_service_utils.hasOwnDefined)(changes, "dataScope") ? { dataScope: { filter: changes.dataScope } } : {},
10435
- ...(0, import_service_utils.hasOwnDefined)(changes, "linkageRules") ? { linkageRules: { value: changes.linkageRules } } : {}
10864
+ ...(0, import_service_utils.hasOwnDefined)(changes, "linkageRules") ? { linkageRules: { value: changes.linkageRules } } : {},
10865
+ ...hasQuickCreatePopupChange ? { quickCreatePopupSettings: quickCreatePopupSettings || {} } : resourceChanged ? { quickCreatePopupSettings: quickCreatePopupSettingsBase } : {},
10866
+ ...hasEventPopupChange ? { eventPopupSettings: eventPopupSettings || {} } : resourceChanged ? { eventPopupSettings: eventPopupSettingsBase } : {}
10436
10867
  })
10437
10868
  } : {}
10438
10869
  }
10439
10870
  },
10440
- options
10871
+ {
10872
+ ...options,
10873
+ replacePopupStepParamSubtrees: resourceChanged,
10874
+ skipHiddenPopupHostEnsure: true
10875
+ }
10441
10876
  );
10442
10877
  const reloaded = await this.repository.findModelById(current.uid, {
10443
10878
  transaction: options.transaction,
10444
10879
  includeAsyncNode: true
10445
10880
  });
10446
- await this.ensureCalendarBlockPopupHosts(reloaded, options.transaction);
10881
+ await this.ensureCalendarBlockPopupHosts(
10882
+ reloaded,
10883
+ options.transaction,
10884
+ {
10885
+ quickCreateAction: hasQuickCreatePopupChange ? quickCreatePopupSettings : resourceChanged ? quickCreatePopupSettingsBase : void 0,
10886
+ eventViewAction: hasEventPopupChange ? eventPopupSettings : resourceChanged ? eventPopupSettingsBase : void 0
10887
+ },
10888
+ {
10889
+ displayFallbackOpenViews: {
10890
+ quickCreateAction: previousQuickCreateOpenView,
10891
+ eventViewAction: previousEventOpenView
10892
+ }
10893
+ }
10894
+ );
10447
10895
  return result;
10448
10896
  }
10449
10897
  async configureTreeBlock(target, current, changes, options) {
@@ -10664,20 +11112,44 @@ class FlowSurfacesService {
10664
11112
  const nextDragEnabled = requestedDragEnabled === true && !!nextDragSortBy;
10665
11113
  const nextStyleVariantProp = (0, import_service_utils.hasOwnDefined)(changes, "styleVariant") ? String(changes.styleVariant || "").trim() === "default" ? "default" : "color" : void 0;
10666
11114
  const nextStyleVariantSetting = (0, import_service_utils.hasOwnDefined)(changes, "styleVariant") ? String(changes.styleVariant || "").trim() : void 0;
10667
- const quickCreatePopup = Object.prototype.hasOwnProperty.call(changes, "quickCreatePopup") ? await this.normalizeKanbanPopupConfigureValue({
11115
+ const shouldWriteQuickCreatePopup = Object.prototype.hasOwnProperty.call(changes, "quickCreatePopup");
11116
+ const shouldWriteCardPopup = Object.prototype.hasOwnProperty.call(changes, "cardPopup");
11117
+ const quickCreatePopupInput = shouldWriteQuickCreatePopup ? await this.normalizeKanbanPopupConfigureValue({
10668
11118
  actionName: "configure kanban quickCreatePopup",
10669
11119
  blockUid: current.uid,
10670
11120
  actionKey: "quickCreateAction",
10671
11121
  value: changes.quickCreatePopup,
10672
11122
  transaction: options.transaction
10673
11123
  }) : void 0;
10674
- const cardPopup = Object.prototype.hasOwnProperty.call(changes, "cardPopup") ? await this.normalizeKanbanPopupConfigureValue({
11124
+ const cardPopupInput = shouldWriteCardPopup ? await this.normalizeKanbanPopupConfigureValue({
10675
11125
  actionName: "configure kanban cardPopup",
10676
11126
  blockUid: current.uid,
10677
11127
  actionKey: "cardViewAction",
10678
11128
  value: changes.cardPopup,
10679
11129
  transaction: options.transaction
10680
11130
  }) : void 0;
11131
+ const currentQuickCreatePopupSettings = this.getKanbanPopupStoredSettings(current, "quickCreateAction");
11132
+ const currentCardPopupSettings = this.getKanbanPopupStoredSettings(current, "cardViewAction");
11133
+ const quickCreatePopupBase = resourceChanged ? this.stripKanbanPopupTargetSettingsForResourceChange(
11134
+ "quickCreateAction",
11135
+ currentQuickCreatePopupSettings,
11136
+ current.uid
11137
+ ) : currentQuickCreatePopupSettings;
11138
+ const cardPopupBase = resourceChanged ? this.stripKanbanPopupTargetSettingsForResourceChange("cardViewAction", currentCardPopupSettings, current.uid) : currentCardPopupSettings;
11139
+ const quickCreatePopup = shouldWriteQuickCreatePopup ? import_lodash.default.isNull(changes.quickCreatePopup) ? quickCreatePopupInput || {} : this.mergeKanbanPopupSettings("quickCreateAction", quickCreatePopupBase, quickCreatePopupInput, current.uid) : void 0;
11140
+ const cardPopup = shouldWriteCardPopup ? import_lodash.default.isNull(changes.cardPopup) ? cardPopupInput || {} : this.mergeKanbanPopupSettings("cardViewAction", cardPopupBase, cardPopupInput, current.uid) : void 0;
11141
+ const previousQuickCreateOpenView = this.buildKanbanPopupOpenView({
11142
+ blockNode: current,
11143
+ actionKey: "quickCreateAction",
11144
+ resourceInit: currentResourceInit,
11145
+ popupSettings: currentQuickCreatePopupSettings
11146
+ });
11147
+ const previousCardOpenView = this.buildKanbanPopupOpenView({
11148
+ blockNode: current,
11149
+ actionKey: "cardViewAction",
11150
+ resourceInit: currentResourceInit,
11151
+ popupSettings: currentCardPopupSettings
11152
+ });
10681
11153
  const nextCardLayout = (0, import_service_utils.hasOwnDefined)(changes, "cardLayout") ? (0, import_service_utils.normalizeSimpleLayoutValue)(changes.cardLayout) : void 0;
10682
11154
  const shouldWriteGrouping = resourceChanged || (0, import_service_utils.hasOwnDefined)(changes, "groupField") || (0, import_service_utils.hasOwnDefined)(changes, "groupTitleField") || (0, import_service_utils.hasOwnDefined)(changes, "groupColorField") || (0, import_service_utils.hasOwnDefined)(changes, "groupOptions") || groupFieldChanged;
10683
11155
  const shouldWriteDrag = resourceChanged || (0, import_service_utils.hasOwnDefined)(changes, "dragEnabled") || (0, import_service_utils.hasOwnDefined)(changes, "dragSortBy") || groupFieldChanged;
@@ -10698,14 +11170,7 @@ class FlowSurfacesService {
10698
11170
  quickCreateEnabled: changes.quickCreateEnabled === true
10699
11171
  } : {},
10700
11172
  ...(0, import_service_utils.hasOwnDefined)(changes, "pageSize") ? { pageSize: changes.pageSize } : {},
10701
- ...(0, import_service_utils.hasOwnDefined)(changes, "columnWidth") ? { columnWidth: changes.columnWidth } : {},
10702
- ...(0, import_service_utils.hasOwnDefined)(changes, "quickCreatePopup") ? {
10703
- popupMode: (quickCreatePopup == null ? void 0 : quickCreatePopup.mode) ?? null,
10704
- popupSize: (quickCreatePopup == null ? void 0 : quickCreatePopup.size) ?? null,
10705
- popupTemplateUid: (quickCreatePopup == null ? void 0 : quickCreatePopup.popupTemplateUid) ?? null,
10706
- popupPageModelClass: (quickCreatePopup == null ? void 0 : quickCreatePopup.pageModelClass) ?? null,
10707
- popupTargetUid: (quickCreatePopup == null ? void 0 : quickCreatePopup.uid) ?? null
10708
- } : {}
11173
+ ...(0, import_service_utils.hasOwnDefined)(changes, "columnWidth") ? { columnWidth: changes.columnWidth } : {}
10709
11174
  });
10710
11175
  const blockStepParams = (0, import_service_utils.buildDefinedPayload)({
10711
11176
  ...blockCardSettings ? { cardSettings: blockCardSettings } : {},
@@ -10714,7 +11179,7 @@ class FlowSurfacesService {
10714
11179
  init: nextResourceInit
10715
11180
  }
10716
11181
  } : {},
10717
- ...shouldWriteGrouping || (0, import_service_utils.hasOwnDefined)(changes, "styleVariant") || (0, import_service_utils.hasOwnDefined)(changes, "sorting") || shouldWriteDrag || (0, import_service_utils.hasOwnDefined)(changes, "quickCreateEnabled") || (0, import_service_utils.hasOwnDefined)(changes, "quickCreatePopup") || (0, import_service_utils.hasOwnDefined)(changes, "pageSize") || (0, import_service_utils.hasOwnDefined)(changes, "columnWidth") || (0, import_service_utils.hasOwnDefined)(changes, "dataScope") ? {
11182
+ ...shouldWriteGrouping || (0, import_service_utils.hasOwnDefined)(changes, "styleVariant") || (0, import_service_utils.hasOwnDefined)(changes, "sorting") || shouldWriteDrag || (0, import_service_utils.hasOwnDefined)(changes, "quickCreateEnabled") || shouldWriteQuickCreatePopup || (0, import_service_utils.hasOwnDefined)(changes, "pageSize") || (0, import_service_utils.hasOwnDefined)(changes, "columnWidth") || (0, import_service_utils.hasOwnDefined)(changes, "dataScope") ? {
10718
11183
  kanbanSettings: (0, import_service_utils.buildDefinedPayload)({
10719
11184
  ...shouldWriteGrouping ? {
10720
11185
  grouping: (0, import_service_utils.buildDefinedPayload)({
@@ -10747,7 +11212,7 @@ class FlowSurfacesService {
10747
11212
  quickCreateEnabled: changes.quickCreateEnabled === true
10748
11213
  }
10749
11214
  } : {},
10750
- ...(0, import_service_utils.hasOwnDefined)(changes, "quickCreatePopup") ? {
11215
+ ...shouldWriteQuickCreatePopup ? {
10751
11216
  popup: quickCreatePopup || {}
10752
11217
  } : {},
10753
11218
  ...(0, import_service_utils.hasOwnDefined)(changes, "pageSize") ? {
@@ -10772,13 +11237,6 @@ class FlowSurfacesService {
10772
11237
  ...(0, import_service_utils.hasOwnDefined)(changes, "enableCardClick") ? {
10773
11238
  enableCardClick: changes.enableCardClick === true
10774
11239
  } : {},
10775
- ...(0, import_service_utils.hasOwnDefined)(changes, "cardPopup") ? {
10776
- openMode: (cardPopup == null ? void 0 : cardPopup.mode) ?? null,
10777
- popupSize: (cardPopup == null ? void 0 : cardPopup.size) ?? null,
10778
- popupTemplateUid: (cardPopup == null ? void 0 : cardPopup.popupTemplateUid) ?? null,
10779
- pageModelClass: (cardPopup == null ? void 0 : cardPopup.pageModelClass) ?? null,
10780
- popupTargetUid: (cardPopup == null ? void 0 : cardPopup.uid) ?? null
10781
- } : {},
10782
11240
  ...(0, import_service_utils.hasOwnDefined)(changes, "cardLayout") ? {
10783
11241
  layout: nextCardLayout
10784
11242
  } : {},
@@ -10788,14 +11246,14 @@ class FlowSurfacesService {
10788
11246
  ...(0, import_service_utils.hasOwnDefined)(changes, "cardColon") ? { colon: changes.cardColon === true } : {}
10789
11247
  });
10790
11248
  const itemStepParams = (0, import_service_utils.buildDefinedPayload)({
10791
- ...(0, import_service_utils.hasOwnDefined)(changes, "enableCardClick") || (0, import_service_utils.hasOwnDefined)(changes, "cardPopup") || (0, import_service_utils.hasOwnDefined)(changes, "cardLayout") || (0, import_service_utils.hasOwnDefined)(changes, "cardLabelAlign") || (0, import_service_utils.hasOwnDefined)(changes, "cardLabelWidth") || (0, import_service_utils.hasOwnDefined)(changes, "cardLabelWrap") || (0, import_service_utils.hasOwnDefined)(changes, "cardColon") ? {
11249
+ ...(0, import_service_utils.hasOwnDefined)(changes, "enableCardClick") || shouldWriteCardPopup || (0, import_service_utils.hasOwnDefined)(changes, "cardLayout") || (0, import_service_utils.hasOwnDefined)(changes, "cardLabelAlign") || (0, import_service_utils.hasOwnDefined)(changes, "cardLabelWidth") || (0, import_service_utils.hasOwnDefined)(changes, "cardLabelWrap") || (0, import_service_utils.hasOwnDefined)(changes, "cardColon") ? {
10792
11250
  cardSettings: (0, import_service_utils.buildDefinedPayload)({
10793
11251
  ...(0, import_service_utils.hasOwnDefined)(changes, "enableCardClick") ? {
10794
11252
  click: {
10795
11253
  enableCardClick: changes.enableCardClick === true
10796
11254
  }
10797
11255
  } : {},
10798
- ...(0, import_service_utils.hasOwnDefined)(changes, "cardPopup") ? {
11256
+ ...shouldWriteCardPopup ? {
10799
11257
  popup: cardPopup || {}
10800
11258
  } : {},
10801
11259
  ...(0, import_service_utils.hasOwnDefined)(changes, "cardLayout") || (0, import_service_utils.hasOwnDefined)(changes, "cardLabelAlign") || (0, import_service_utils.hasOwnDefined)(changes, "cardLabelWidth") || (0, import_service_utils.hasOwnDefined)(changes, "cardLabelWrap") || (0, import_service_utils.hasOwnDefined)(changes, "cardColon") ? {
@@ -10818,7 +11276,11 @@ class FlowSurfacesService {
10818
11276
  props: blockProps,
10819
11277
  stepParams: blockStepParams
10820
11278
  },
10821
- options
11279
+ {
11280
+ ...options,
11281
+ replacePopupStepParamSubtrees: resourceChanged,
11282
+ skipHiddenPopupHostEnsure: true
11283
+ }
10822
11284
  );
10823
11285
  import_lodash.default.castArray((blockResult == null ? void 0 : blockResult.updated) || []).forEach((key) => updated.add(String(key)));
10824
11286
  }
@@ -10831,7 +11293,11 @@ class FlowSurfacesService {
10831
11293
  props: itemProps,
10832
11294
  stepParams: itemStepParams
10833
11295
  },
10834
- options
11296
+ {
11297
+ ...options,
11298
+ replacePopupStepParamSubtrees: resourceChanged,
11299
+ skipHiddenPopupHostEnsure: true
11300
+ }
10835
11301
  );
10836
11302
  import_lodash.default.castArray((itemResult == null ? void 0 : itemResult.updated) || []).forEach((key) => updated.add(String(key)));
10837
11303
  }
@@ -10839,7 +11305,37 @@ class FlowSurfacesService {
10839
11305
  transaction: options.transaction,
10840
11306
  includeAsyncNode: true
10841
11307
  });
10842
- await this.ensureKanbanBlockPopupHosts(reloaded, options.transaction);
11308
+ const popupSettingsStorageNode = reloaded || current;
11309
+ if (resourceChanged && !shouldWriteQuickCreatePopup) {
11310
+ await this.replaceKanbanStoredPopupSettings(
11311
+ popupSettingsStorageNode,
11312
+ "quickCreateAction",
11313
+ quickCreatePopupBase,
11314
+ options.transaction
11315
+ );
11316
+ }
11317
+ if (resourceChanged && !shouldWriteCardPopup) {
11318
+ await this.replaceKanbanStoredPopupSettings(
11319
+ popupSettingsStorageNode,
11320
+ "cardViewAction",
11321
+ cardPopupBase,
11322
+ options.transaction
11323
+ );
11324
+ }
11325
+ await this.ensureKanbanBlockPopupHosts(
11326
+ reloaded,
11327
+ options.transaction,
11328
+ {
11329
+ quickCreateAction: shouldWriteQuickCreatePopup ? quickCreatePopup || {} : resourceChanged ? quickCreatePopupBase : void 0,
11330
+ cardViewAction: shouldWriteCardPopup ? cardPopup || {} : resourceChanged ? cardPopupBase : void 0
11331
+ },
11332
+ {
11333
+ displayFallbackOpenViews: {
11334
+ quickCreateAction: previousQuickCreateOpenView,
11335
+ cardViewAction: previousCardOpenView
11336
+ }
11337
+ }
11338
+ );
10843
11339
  return (0, import_service_utils.buildDefinedPayload)({
10844
11340
  uid: current.uid,
10845
11341
  ...updated.size ? { updated: Array.from(updated) } : {}
@@ -13143,13 +13639,100 @@ class FlowSurfacesService {
13143
13639
  ) || (field == null ? void 0 : field.targetCollection) || null;
13144
13640
  }
13145
13641
  resolvePopupHostOpenView(node) {
13146
- for (const [flowKey, stepKey] of import_template_service_utils.POPUP_HOST_STEP_PARAM_PATHS) {
13147
- const openView = import_lodash.default.get(node, ["stepParams", flowKey, stepKey]);
13148
- if (import_lodash.default.isPlainObject(openView)) {
13149
- return openView;
13642
+ return (0, import_hidden_popup_contract.resolveHiddenPopupHostOpenView)(node);
13643
+ }
13644
+ popupHostHasLocalContent(actionNode) {
13645
+ return (0, import_hidden_popup_contract.hiddenPopupHostHasLocalContent)(actionNode);
13646
+ }
13647
+ shouldAutoBindPopupTemplate(openView, popupSettings, expectedHostUid, hostNode) {
13648
+ return (0, import_hidden_popup_contract.shouldAutoBindHiddenPopupTemplate)(openView, popupSettings, expectedHostUid, {
13649
+ hostHasLocalContent: !!(hostNode == null ? void 0 : hostNode.uid) && this.popupHostHasLocalContent(hostNode)
13650
+ });
13651
+ }
13652
+ async patchPopupOpenViewIfChanged(actionUid, openView, transaction) {
13653
+ const actionNode = await this.repository.findModelById(actionUid, {
13654
+ transaction,
13655
+ includeAsyncNode: true
13656
+ });
13657
+ if (!(actionNode == null ? void 0 : actionNode.uid)) {
13658
+ return false;
13659
+ }
13660
+ const currentOpenView = this.resolvePopupHostOpenView(actionNode);
13661
+ if (import_lodash.default.isEqual(currentOpenView, openView)) {
13662
+ return false;
13663
+ }
13664
+ await this.repository.patch(
13665
+ {
13666
+ uid: actionUid,
13667
+ stepParams: (0, import_hidden_popup_contract.buildHiddenPopupActionStepParams)(actionNode.stepParams, openView)
13668
+ },
13669
+ { transaction }
13670
+ );
13671
+ return true;
13672
+ }
13673
+ async buildPopupOpenViewWithTemplate(input) {
13674
+ var _a;
13675
+ const hasExplicitTargetSettings = (0, import_hidden_popup_contract.hasExplicitHiddenPopupTargetSettings)(input.popupSettings, input.actionUid);
13676
+ const shouldAutoBind = this.shouldAutoBindPopupTemplate(
13677
+ input.openView,
13678
+ input.popupSettings,
13679
+ input.actionUid,
13680
+ input.existingHost
13681
+ );
13682
+ if (!hasExplicitTargetSettings && !shouldAutoBind) {
13683
+ return input.openView;
13684
+ }
13685
+ const openViewForNormalize = shouldAutoBind && String(((_a = input.openView) == null ? void 0 : _a.uid) || "").trim() === input.actionUid ? { ...input.openView, uid: void 0, tryTemplate: true } : shouldAutoBind ? { ...input.openView, tryTemplate: true } : input.openView;
13686
+ const normalized = await this.normalizeOpenView(input.actionName, openViewForNormalize, {
13687
+ transaction: input.transaction,
13688
+ popupTemplateHostUid: input.actionUid,
13689
+ popupActionContext: {
13690
+ hasCurrentRecord: !!input.hasCurrentRecord
13150
13691
  }
13692
+ });
13693
+ const normalizedOpenView = input.normalizePopupSettings(normalized || input.openView);
13694
+ return input.mergeDisplaySettings(
13695
+ (0, import_service_utils.buildDefinedPayload)({
13696
+ ...input.openView,
13697
+ ...normalizedOpenView,
13698
+ uid: normalizedOpenView.uid || input.openView.uid,
13699
+ collectionName: normalizedOpenView.collectionName || input.openView.collectionName,
13700
+ dataSourceKey: normalizedOpenView.dataSourceKey || input.openView.dataSourceKey
13701
+ }),
13702
+ input.popupSettings,
13703
+ input.openView
13704
+ );
13705
+ }
13706
+ async completePopupHostDefaultContent(input) {
13707
+ const popup = (0, import_hidden_popup_contract.buildImplicitHiddenPopupDefaultContent)(input.popupSettings);
13708
+ if (!popup) {
13709
+ return;
13151
13710
  }
13152
- return null;
13711
+ await this.applyInlineActionPopup(input.actionName, input.actionUid, popup, {
13712
+ transaction: input.transaction,
13713
+ popupActionContext: {
13714
+ hasCurrentRecord: !!input.hasCurrentRecord
13715
+ }
13716
+ });
13717
+ }
13718
+ async ensurePopupHostDefaultContent(input) {
13719
+ let actionNode = await this.repository.findModelById(input.actionUid, {
13720
+ transaction: input.transaction,
13721
+ includeAsyncNode: true
13722
+ });
13723
+ const openView = this.resolvePopupHostOpenView(actionNode);
13724
+ if (!this.shouldAutoBindPopupTemplate(openView, input.popupSettings, input.actionUid) || String((openView == null ? void 0 : openView.popupTemplateUid) || "").trim() || this.popupHostHasLocalContent(actionNode)) {
13725
+ return false;
13726
+ }
13727
+ await this.completePopupHostDefaultContent(input);
13728
+ actionNode = await this.repository.findModelById(input.actionUid, {
13729
+ transaction: input.transaction,
13730
+ includeAsyncNode: true
13731
+ });
13732
+ const completedOpenView = this.resolvePopupHostOpenView(actionNode);
13733
+ const mergedCompletedOpenView = input.mergeDisplaySettings(completedOpenView, input.popupSettings, openView);
13734
+ await this.patchPopupOpenViewIfChanged(input.actionUid, mergedCompletedOpenView, input.transaction);
13735
+ return true;
13153
13736
  }
13154
13737
  resolvePopupSourceRecordCollectionName(popupAssociationName, hostContext) {
13155
13738
  var _a, _b, _c;
@@ -13427,108 +14010,59 @@ class FlowSurfacesService {
13427
14010
  });
13428
14011
  }
13429
14012
  normalizeKanbanPopupSettings(actionKey, popupSettings, blockUid) {
13430
- const nextParams = import_lodash.default.cloneDeep(popupSettings || {});
13431
- const actionUid = blockUid && actionKey ? this.getKanbanPopupActionUid(blockUid, actionKey) : void 0;
13432
- const popupTemplateUidProvided = Object.prototype.hasOwnProperty.call(nextParams, "popupTemplateUid");
13433
- const popupTemplateUid = typeof nextParams.popupTemplateUid === "string" ? nextParams.popupTemplateUid.trim() : nextParams.popupTemplateUid;
13434
- if (popupTemplateUidProvided && (popupTemplateUid === void 0 || popupTemplateUid === null || popupTemplateUid === "")) {
13435
- delete nextParams.popupTemplateUid;
13436
- delete nextParams.popupTemplateContext;
13437
- delete nextParams.popupTemplateHasFilterByTk;
13438
- delete nextParams.popupTemplateHasSourceId;
13439
- delete nextParams.uid;
13440
- }
13441
- const normalizedUid = typeof nextParams.uid === "string" ? nextParams.uid.trim() : nextParams.uid;
13442
- if (!normalizedUid || normalizedUid === blockUid || normalizedUid === actionUid) {
13443
- delete nextParams.uid;
13444
- } else {
13445
- nextParams.uid = normalizedUid;
13446
- }
13447
- if (typeof nextParams.mode === "string") {
13448
- nextParams.mode = OPEN_VIEW_MODE_ALIASES[nextParams.mode] || nextParams.mode;
13449
- }
13450
- if (typeof nextParams.size === "string" && !nextParams.size.trim()) {
13451
- delete nextParams.size;
13452
- }
13453
- if (typeof nextParams.pageModelClass === "string" && !nextParams.pageModelClass.trim()) {
13454
- delete nextParams.pageModelClass;
13455
- }
13456
- return nextParams;
13457
- }
13458
- getKanbanPopupActionUse(actionKey) {
13459
- return actionKey === "quickCreateAction" ? "KanbanQuickCreateActionModel" : "KanbanCardViewActionModel";
14013
+ return (0, import_hidden_popup_kanban.normalizeKanbanPopupSettings)(actionKey, popupSettings, blockUid);
13460
14014
  }
13461
14015
  getKanbanPopupActionUid(kanbanUid, actionKey) {
13462
- return `${kanbanUid}${KANBAN_POPUP_ACTION_UID_SUFFIX_BY_KEY[actionKey]}`;
14016
+ return (0, import_hidden_popup_kanban.getKanbanPopupActionUid)(kanbanUid, actionKey);
13463
14017
  }
13464
14018
  getKanbanBlockResourceInit(blockNode) {
13465
- const resourceInit = import_lodash.default.cloneDeep(import_lodash.default.get(blockNode, ["stepParams", "resourceSettings", "init"]) || {});
13466
- if (resourceInit.collectionName && !resourceInit.dataSourceKey) {
13467
- resourceInit.dataSourceKey = "main";
13468
- }
13469
- return resourceInit;
14019
+ return (0, import_hidden_popup_kanban.getKanbanBlockResourceInit)(blockNode);
14020
+ }
14021
+ buildKanbanInitialStepParams(input) {
14022
+ return (0, import_hidden_popup_kanban.buildKanbanInitialStepParams)(input);
14023
+ }
14024
+ buildKanbanInitialItemProps(input) {
14025
+ return (0, import_hidden_popup_kanban.buildKanbanInitialItemProps)(input);
14026
+ }
14027
+ buildKanbanInitialItemStepParams(input) {
14028
+ return (0, import_hidden_popup_kanban.buildKanbanInitialItemStepParams)(input);
13470
14029
  }
13471
14030
  getKanbanPopupStoredSettings(blockNode, actionKey) {
13472
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
13473
- const itemNode = (0, import_service_utils.getSingleNodeSubModel)((_a = blockNode == null ? void 0 : blockNode.subModels) == null ? void 0 : _a.item);
13474
- const rawPopupSettings = actionKey === "quickCreateAction" ? import_lodash.default.get(blockNode, ["stepParams", "kanbanSettings", "popup"]) || {
13475
- mode: (_b = blockNode == null ? void 0 : blockNode.props) == null ? void 0 : _b.popupMode,
13476
- size: (_c = blockNode == null ? void 0 : blockNode.props) == null ? void 0 : _c.popupSize,
13477
- popupTemplateUid: (_d = blockNode == null ? void 0 : blockNode.props) == null ? void 0 : _d.popupTemplateUid,
13478
- pageModelClass: (_e = blockNode == null ? void 0 : blockNode.props) == null ? void 0 : _e.popupPageModelClass,
13479
- uid: (_f = blockNode == null ? void 0 : blockNode.props) == null ? void 0 : _f.popupTargetUid
13480
- } : import_lodash.default.get(itemNode, ["stepParams", "cardSettings", "popup"]) || {
13481
- mode: (_g = itemNode == null ? void 0 : itemNode.props) == null ? void 0 : _g.openMode,
13482
- size: (_h = itemNode == null ? void 0 : itemNode.props) == null ? void 0 : _h.popupSize,
13483
- popupTemplateUid: (_i = itemNode == null ? void 0 : itemNode.props) == null ? void 0 : _i.popupTemplateUid,
13484
- pageModelClass: (_j = itemNode == null ? void 0 : itemNode.props) == null ? void 0 : _j.pageModelClass,
13485
- uid: (_k = itemNode == null ? void 0 : itemNode.props) == null ? void 0 : _k.popupTargetUid
13486
- };
13487
- return this.normalizeKanbanPopupSettings(actionKey, rawPopupSettings, blockNode == null ? void 0 : blockNode.uid);
14031
+ return (0, import_hidden_popup_kanban.getKanbanPopupStoredSettings)(blockNode, actionKey);
14032
+ }
14033
+ mergeKanbanPopupSettings(actionKey, current, value, blockUid) {
14034
+ return (0, import_hidden_popup_kanban.mergeKanbanPopupSettings)(actionKey, current, value, blockUid);
14035
+ }
14036
+ stripKanbanPopupTargetSettingsForResourceChange(actionKey, popupSettings, blockUid) {
14037
+ return (0, import_hidden_popup_kanban.stripKanbanPopupTargetSettingsForResourceChange)(actionKey, popupSettings, blockUid);
13488
14038
  }
13489
14039
  buildKanbanPopupOpenView(input) {
13490
- const actionUid = this.getKanbanPopupActionUid(input.blockNode.uid, input.actionKey);
13491
- const resourceInit = input.resourceInit || this.getKanbanBlockResourceInit(input.blockNode);
13492
- const defaults = (0, import_service_utils.buildDefinedPayload)({
13493
- mode: "drawer",
13494
- size: "medium",
13495
- pageModelClass: "ChildPageModel",
13496
- uid: actionUid,
13497
- collectionName: resourceInit.collectionName,
13498
- dataSourceKey: resourceInit.dataSourceKey || (resourceInit.collectionName ? "main" : void 0)
13499
- });
13500
- const current = this.getKanbanPopupStoredSettings(input.blockNode, input.actionKey);
13501
- return (0, import_service_utils.buildDefinedPayload)({
13502
- ...defaults,
13503
- ...current,
13504
- uid: current.uid || defaults.uid,
13505
- collectionName: current.collectionName || defaults.collectionName,
13506
- dataSourceKey: current.dataSourceKey || defaults.dataSourceKey
13507
- });
14040
+ return (0, import_hidden_popup_kanban.buildKanbanPopupOpenView)(input);
13508
14041
  }
13509
14042
  async normalizeKanbanPopupConfigureValue(input) {
13510
- if (import_lodash.default.isUndefined(input.value)) {
13511
- return void 0;
13512
- }
13513
- if (import_lodash.default.isNull(input.value)) {
13514
- return {};
13515
- }
13516
- const actionUid = this.getKanbanPopupActionUid(input.blockUid, input.actionKey);
13517
- const normalized = await this.normalizeOpenView(input.actionName, input.value, {
13518
- transaction: input.transaction,
13519
- popupTemplateHostUid: actionUid,
13520
- popupActionContext: {
13521
- hasCurrentRecord: input.actionKey === "cardViewAction"
13522
- }
14043
+ return (0, import_hidden_popup_kanban.normalizeKanbanPopupConfigureValue)({
14044
+ ...input,
14045
+ normalizeOpenView: (actionName, value, options) => this.normalizeOpenView(actionName, value, options)
13523
14046
  });
13524
- return this.normalizeKanbanPopupSettings(input.actionKey, normalized || {}, input.blockUid);
13525
14047
  }
13526
14048
  buildKanbanInitialBlockProps(input) {
13527
14049
  const { collection, collectionName, dataSourceKey } = this.assertKanbanCollectionCompatible(
13528
14050
  input.actionName,
13529
14051
  input.resourceInit
13530
14052
  );
13531
- const currentProps = import_lodash.default.cloneDeep(input.props || {});
14053
+ const currentProps = {
14054
+ ...import_lodash.default.isPlainObject(input.settings) ? import_lodash.default.pick(input.settings, [
14055
+ "groupField",
14056
+ "groupOptions",
14057
+ "groupTitleField",
14058
+ "groupColorField",
14059
+ "styleVariant",
14060
+ "dragEnabled",
14061
+ "dragSortBy",
14062
+ "quickCreateEnabled"
14063
+ ]) : {},
14064
+ ...import_lodash.default.cloneDeep(input.props || {})
14065
+ };
13532
14066
  const defaultGroupFieldName = this.getKanbanDefaultGroupFieldName(collection);
13533
14067
  const nextGroupFieldName = String(currentProps.groupField || defaultGroupFieldName || "").trim();
13534
14068
  const nextGroupField = this.getKanbanGroupField(collection, nextGroupFieldName);
@@ -13585,7 +14119,7 @@ class FlowSurfacesService {
13585
14119
  kind: "groupColorField"
13586
14120
  });
13587
14121
  }
13588
- return (0, import_service_utils.buildDefinedPayload)({
14122
+ const props = (0, import_service_utils.buildDefinedPayload)({
13589
14123
  ...currentProps,
13590
14124
  groupField: nextGroupFieldName,
13591
14125
  groupTitleField: nextGroupTitleField,
@@ -13596,6 +14130,23 @@ class FlowSurfacesService {
13596
14130
  dragEnabled: nextDragEnabled,
13597
14131
  dragSortBy: nextDragSortBy || void 0
13598
14132
  });
14133
+ delete props.quickCreatePopup;
14134
+ delete props.quickCreatePopupSettings;
14135
+ delete props.cardPopup;
14136
+ delete props.cardPopupSettings;
14137
+ for (const propKey of import_hidden_popup_kanban.KANBAN_BLOCK_POPUP_PROP_KEYS) {
14138
+ delete props[propKey];
14139
+ }
14140
+ for (const propKey of [
14141
+ "cardOpenMode",
14142
+ "cardPopupSize",
14143
+ "cardPopupTemplateUid",
14144
+ "cardPopupPageModelClass",
14145
+ "cardPopupTargetUid"
14146
+ ]) {
14147
+ delete props[propKey];
14148
+ }
14149
+ return props;
13599
14150
  }
13600
14151
  normalizeCalendarFieldPathInput(value, context, options = {}) {
13601
14152
  if (import_lodash.default.isUndefined(value)) {
@@ -13811,86 +14362,50 @@ class FlowSurfacesService {
13811
14362
  });
13812
14363
  }
13813
14364
  normalizeCalendarPopupSettings(actionKey, popupSettings) {
13814
- const nextParams = import_lodash.default.cloneDeep(popupSettings || {});
13815
- const popupTemplateUidProvided = Object.prototype.hasOwnProperty.call(nextParams, "popupTemplateUid");
13816
- const popupTemplateUid = typeof nextParams.popupTemplateUid === "string" ? nextParams.popupTemplateUid.trim() : nextParams.popupTemplateUid;
13817
- if (popupTemplateUidProvided && (popupTemplateUid === void 0 || popupTemplateUid === null || popupTemplateUid === "")) {
13818
- delete nextParams.popupTemplateUid;
13819
- delete nextParams.popupTemplateContext;
13820
- delete nextParams.popupTemplateHasFilterByTk;
13821
- delete nextParams.popupTemplateHasSourceId;
13822
- delete nextParams.uid;
13823
- }
13824
- if (actionKey === "quickCreateAction") {
13825
- const hasRecordScopedTemplate = !!nextParams.popupTemplateHasFilterByTk || !!nextParams.popupTemplateHasSourceId || !import_lodash.default.isUndefined(nextParams.filterByTk) || !import_lodash.default.isUndefined(nextParams.sourceId) || !!String(nextParams.associationName || "").trim();
13826
- if (hasRecordScopedTemplate) {
13827
- delete nextParams.popupTemplateUid;
13828
- delete nextParams.popupTemplateContext;
13829
- delete nextParams.popupTemplateHasFilterByTk;
13830
- delete nextParams.popupTemplateHasSourceId;
13831
- delete nextParams.uid;
13832
- }
13833
- delete nextParams.associationName;
13834
- delete nextParams.filterByTk;
13835
- delete nextParams.sourceId;
13836
- }
13837
- return nextParams;
13838
- }
13839
- getCalendarPopupActionUse(actionKey) {
13840
- return actionKey === "quickCreateAction" ? "CalendarQuickCreateActionModel" : "CalendarEventViewActionModel";
14365
+ return (0, import_hidden_popup_calendar.normalizeCalendarPopupSettings)(actionKey, popupSettings);
13841
14366
  }
13842
- getCalendarPopupPropKey(actionKey) {
13843
- return actionKey === "quickCreateAction" ? "quickCreatePopupSettings" : "eventPopupSettings";
14367
+ getCalendarBlockResourceInit(blockNode) {
14368
+ return (0, import_hidden_popup_calendar.getCalendarBlockResourceInit)(blockNode);
13844
14369
  }
13845
- getCalendarPopupActionUid(calendarUid, actionKey) {
13846
- return `${calendarUid}-${actionKey}`;
14370
+ getCalendarPopupStoredSettings(blockNode, actionKey) {
14371
+ return (0, import_hidden_popup_calendar.getCalendarPopupStoredSettings)(blockNode, actionKey);
13847
14372
  }
13848
- getCalendarBlockResourceInit(blockNode) {
13849
- const resourceInit = import_lodash.default.cloneDeep(import_lodash.default.get(blockNode, ["stepParams", "resourceSettings", "init"]) || {});
13850
- if (resourceInit.collectionName && !resourceInit.dataSourceKey) {
13851
- resourceInit.dataSourceKey = "main";
13852
- }
13853
- return resourceInit;
14373
+ getCalendarPopupPropKey(actionKey) {
14374
+ return (0, import_hidden_popup_calendar.getCalendarPopupPropKey)(actionKey);
14375
+ }
14376
+ buildCalendarInitialStepParams(input) {
14377
+ return (0, import_hidden_popup_calendar.buildCalendarInitialStepParams)(input);
13854
14378
  }
13855
14379
  buildCalendarPopupOpenView(input) {
13856
- const actionUid = this.getCalendarPopupActionUid(input.blockNode.uid, input.actionKey);
13857
- const resourceInit = input.resourceInit || this.getCalendarBlockResourceInit(input.blockNode);
13858
- const defaults = (0, import_service_utils.buildDefinedPayload)({
13859
- mode: "drawer",
13860
- size: "medium",
13861
- pageModelClass: "ChildPageModel",
13862
- uid: actionUid,
13863
- collectionName: resourceInit.collectionName,
13864
- dataSourceKey: resourceInit.dataSourceKey || (resourceInit.collectionName ? "main" : void 0)
13865
- });
13866
- const current = this.normalizeCalendarPopupSettings(
13867
- input.actionKey,
13868
- import_lodash.default.get(input.blockNode, ["props", this.getCalendarPopupPropKey(input.actionKey)]) || {}
13869
- );
13870
- return (0, import_service_utils.buildDefinedPayload)({
13871
- ...defaults,
13872
- ...current,
13873
- uid: current.uid || defaults.uid,
13874
- collectionName: current.collectionName || defaults.collectionName,
13875
- dataSourceKey: current.dataSourceKey || defaults.dataSourceKey
13876
- });
14380
+ return (0, import_hidden_popup_calendar.buildCalendarPopupOpenView)(input);
14381
+ }
14382
+ mergeCalendarPopupSettings(actionKey, current, value) {
14383
+ return (0, import_hidden_popup_calendar.mergeCalendarPopupSettings)(actionKey, current, value);
14384
+ }
14385
+ stripCalendarPopupTargetSettingsForResourceChange(actionKey, popupSettings) {
14386
+ return (0, import_hidden_popup_calendar.stripCalendarPopupTargetSettingsForResourceChange)(actionKey, popupSettings);
13877
14387
  }
13878
14388
  async normalizeCalendarPopupConfigureValue(input) {
13879
- if (import_lodash.default.isUndefined(input.value)) {
13880
- return void 0;
13881
- }
13882
- if (import_lodash.default.isNull(input.value)) {
13883
- return {};
13884
- }
13885
- const actionUid = this.getCalendarPopupActionUid(input.blockUid, input.actionKey);
13886
- const normalized = await this.normalizeOpenView(input.actionName, input.value, {
13887
- transaction: input.transaction,
13888
- popupTemplateHostUid: actionUid,
13889
- popupActionContext: {
13890
- hasCurrentRecord: input.actionKey === "eventViewAction"
13891
- }
14389
+ return (0, import_hidden_popup_calendar.normalizeCalendarPopupConfigureValue)({
14390
+ ...input,
14391
+ normalizeOpenView: (actionName, value, options) => this.normalizeOpenView(actionName, value, options)
13892
14392
  });
13893
- return this.normalizeCalendarPopupSettings(input.actionKey, normalized || {});
14393
+ }
14394
+ normalizeCalendarInlineSettingsForConfigure(settings) {
14395
+ return (0, import_hidden_popup_calendar.normalizeCalendarInlineSettingsForConfigure)(settings);
14396
+ }
14397
+ omitHiddenPopupSettingsForConfigure(settings, type) {
14398
+ if (!import_lodash.default.isPlainObject(settings)) {
14399
+ return settings;
14400
+ }
14401
+ const omittedKeys = type === "calendar" ? ["quickCreatePopup", "eventPopup", "quickCreatePopupSettings", "eventPopupSettings"] : ["quickCreatePopup", "cardPopup", "quickCreatePopupSettings", "cardPopupSettings"];
14402
+ return import_lodash.default.omit(settings, omittedKeys);
14403
+ }
14404
+ resolveCalendarInitialPopupOverride(settings, primaryKey, legacyKey) {
14405
+ return (0, import_hidden_popup_calendar.resolveCalendarInitialPopupOverride)(settings, primaryKey, legacyKey);
14406
+ }
14407
+ resolveKanbanInitialPopupOverride(settings, primaryKey, legacyKey) {
14408
+ return (0, import_hidden_popup_kanban.resolveKanbanInitialPopupOverride)(settings, primaryKey, legacyKey);
13894
14409
  }
13895
14410
  buildCalendarInitialBlockProps(input) {
13896
14411
  const { collection, collectionName } = this.assertCalendarCollectionCompatible(
@@ -13898,7 +14413,7 @@ class FlowSurfacesService {
13898
14413
  input.resourceInit
13899
14414
  );
13900
14415
  const currentProps = import_lodash.default.cloneDeep(input.props || {});
13901
- return {
14416
+ const props = {
13902
14417
  ...currentProps,
13903
14418
  fieldNames: this.normalizeCalendarFieldNamesForCollection({
13904
14419
  actionName: input.actionName,
@@ -13911,259 +14426,83 @@ class FlowSurfacesService {
13911
14426
  enableQuickCreateEvent: typeof currentProps.enableQuickCreateEvent === "boolean" ? currentProps.enableQuickCreateEvent : true,
13912
14427
  weekStart: typeof currentProps.weekStart === "number" ? currentProps.weekStart : 1
13913
14428
  };
13914
- }
13915
- async ensureCalendarBlockPopupHosts(blockNode, transaction) {
13916
- var _a;
13917
- if (!(blockNode == null ? void 0 : blockNode.uid) || blockNode.use !== "CalendarBlockModel") {
13918
- return blockNode;
13919
- }
13920
- const resourceInit = this.getCalendarBlockResourceInit(blockNode);
13921
- let changed = false;
13922
- for (const actionKey of CALENDAR_POPUP_ACTION_KEYS) {
13923
- const existing = (0, import_service_utils.getSingleNodeSubModel)((_a = blockNode.subModels) == null ? void 0 : _a[actionKey]);
13924
- const expectedUid = this.getCalendarPopupActionUid(blockNode.uid, actionKey);
13925
- const expectedUse = this.getCalendarPopupActionUse(actionKey);
13926
- const openView = this.buildCalendarPopupOpenView({
13927
- blockNode,
13928
- actionKey,
13929
- resourceInit
13930
- });
13931
- const currentOpenView = this.resolvePopupHostOpenView(existing);
13932
- const shouldReplaceExisting = (existing == null ? void 0 : existing.uid) && existing.uid !== expectedUid;
13933
- const shouldUpsert = !(existing == null ? void 0 : existing.uid) || shouldReplaceExisting || existing.use !== expectedUse || !import_lodash.default.isEqual(currentOpenView, openView);
13934
- if (!shouldUpsert) {
13935
- continue;
13936
- }
13937
- if (shouldReplaceExisting) {
13938
- await this.removeNodeTreeWithBindings(existing.uid, transaction);
13939
- }
13940
- if ((existing == null ? void 0 : existing.uid) && existing.uid === expectedUid && !import_lodash.default.isEqual(currentOpenView, openView)) {
13941
- await this.reconcilePopupOpenViewTransition(expectedUid, currentOpenView, openView, transaction);
13942
- }
13943
- const nextActionNode = {
13944
- ...(existing == null ? void 0 : existing.uid) && existing.uid === expectedUid ? import_lodash.default.cloneDeep(existing) : {},
13945
- uid: expectedUid,
13946
- use: expectedUse,
13947
- stepParams: import_lodash.default.merge({}, (existing == null ? void 0 : existing.uid) === expectedUid ? import_lodash.default.cloneDeep(existing.stepParams || {}) : {}, {
13948
- popupSettings: {
13949
- openView
13950
- }
13951
- })
13952
- };
13953
- await this.repository.upsertModel(
13954
- {
13955
- parentId: blockNode.uid,
13956
- subKey: actionKey,
13957
- subType: "object",
13958
- ...nextActionNode
13959
- },
13960
- { transaction }
13961
- );
13962
- changed = true;
13963
- }
13964
- if (!changed) {
13965
- return blockNode;
13966
- }
13967
- return this.repository.findModelById(blockNode.uid, {
14429
+ delete props.quickCreatePopup;
14430
+ delete props.quickCreatePopupSettings;
14431
+ delete props.eventPopup;
14432
+ delete props.eventPopupSettings;
14433
+ return props;
14434
+ }
14435
+ async ensureCalendarBlockPopupHosts(blockNode, transaction, popupSettingsOverrides, options = {}) {
14436
+ return (0, import_hidden_popup_calendar.ensureCalendarBlockPopupHosts)(
14437
+ this.hiddenPopupRuntime,
14438
+ blockNode,
13968
14439
  transaction,
13969
- includeAsyncNode: true
13970
- });
14440
+ popupSettingsOverrides,
14441
+ options
14442
+ );
13971
14443
  }
13972
- async ensureCalendarBlockPopupHostsInTree(node, transaction) {
13973
- if (!node || typeof node !== "object") {
13974
- return node;
13975
- }
13976
- let current = node;
13977
- if (current.use === "CalendarBlockModel") {
13978
- current = await this.ensureCalendarBlockPopupHosts(current, transaction);
13979
- }
13980
- for (const [subKey, value] of Object.entries(current.subModels || {})) {
13981
- if (Array.isArray(value)) {
13982
- const nextItems = [];
13983
- let changed = false;
13984
- for (const item of value) {
13985
- const nextItem = await this.ensureCalendarBlockPopupHostsInTree(item, transaction);
13986
- nextItems.push(nextItem);
13987
- changed = changed || nextItem !== item;
13988
- }
13989
- if (changed) {
13990
- current.subModels[subKey] = nextItems;
13991
- }
13992
- continue;
13993
- }
13994
- const nextValue = await this.ensureCalendarBlockPopupHostsInTree(value, transaction);
13995
- if (nextValue !== value) {
13996
- current.subModels[subKey] = nextValue;
13997
- }
13998
- }
13999
- return current;
14444
+ projectCalendarBlockPopupHostsInTree(node) {
14445
+ return (0, import_hidden_popup_calendar.projectCalendarBlockPopupHostsInTree)(node);
14446
+ }
14447
+ async replaceKanbanStoredPopupSettings(blockNode, actionKey, popupSettings, transaction) {
14448
+ return (0, import_hidden_popup_kanban.replaceKanbanStoredPopupSettings)(
14449
+ this.hiddenPopupRuntime,
14450
+ blockNode,
14451
+ actionKey,
14452
+ popupSettings,
14453
+ transaction
14454
+ );
14000
14455
  }
14001
- projectCalendarBlockPopupHosts(node) {
14002
- var _a;
14003
- if (!node || typeof node !== "object") {
14004
- return node;
14005
- }
14006
- const current = node;
14007
- if (!(current == null ? void 0 : current.uid) || current.use !== "CalendarBlockModel") {
14008
- return node;
14009
- }
14010
- const resourceInit = this.getCalendarBlockResourceInit(current);
14011
- let nextSubModels = current.subModels;
14012
- let changed = false;
14013
- for (const actionKey of CALENDAR_POPUP_ACTION_KEYS) {
14014
- const existing = (0, import_service_utils.getSingleNodeSubModel)((_a = current.subModels) == null ? void 0 : _a[actionKey]);
14015
- const expectedUid = this.getCalendarPopupActionUid(current.uid, actionKey);
14016
- const expectedUse = this.getCalendarPopupActionUse(actionKey);
14017
- const openView = this.buildCalendarPopupOpenView({
14018
- blockNode: current,
14019
- actionKey,
14020
- resourceInit
14021
- });
14022
- const currentOpenView = this.resolvePopupHostOpenView(existing);
14023
- if ((existing == null ? void 0 : existing.uid) === expectedUid && existing.use === expectedUse && import_lodash.default.isEqual(currentOpenView, openView)) {
14024
- continue;
14025
- }
14026
- const nextActionNode = {
14027
- ...(existing == null ? void 0 : existing.uid) === expectedUid ? import_lodash.default.cloneDeep(existing) : {},
14028
- uid: expectedUid,
14029
- use: expectedUse,
14030
- stepParams: import_lodash.default.merge({}, (existing == null ? void 0 : existing.uid) === expectedUid ? import_lodash.default.cloneDeep(existing.stepParams || {}) : {}, {
14031
- popupSettings: {
14032
- openView
14033
- }
14034
- })
14035
- };
14036
- if (!changed) {
14037
- nextSubModels = {
14038
- ...current.subModels || {}
14039
- };
14040
- changed = true;
14041
- }
14042
- nextSubModels[actionKey] = nextActionNode;
14043
- }
14044
- if (!changed) {
14045
- return node;
14046
- }
14047
- return {
14048
- ...current,
14049
- subModels: nextSubModels
14050
- };
14456
+ async ensureKanbanBlockPopupHosts(blockNode, transaction, popupSettingsOverrides, options = {}) {
14457
+ return (0, import_hidden_popup_kanban.ensureKanbanBlockPopupHosts)(
14458
+ this.hiddenPopupRuntime,
14459
+ blockNode,
14460
+ transaction,
14461
+ popupSettingsOverrides,
14462
+ options
14463
+ );
14051
14464
  }
14052
- projectCalendarBlockPopupHostsInTree(node) {
14053
- if (!node || typeof node !== "object") {
14054
- return node;
14465
+ projectKanbanBlockPopupHostsInTree(node) {
14466
+ return (0, import_hidden_popup_kanban.projectKanbanBlockPopupHostsInTree)(node);
14467
+ }
14468
+ resolveManagedPopupTargetUidForHiddenPopupBackfill(hostNode) {
14469
+ const openView = this.resolvePopupHostOpenView(hostNode);
14470
+ const externalPopupHostUid = this.resolveExternalPopupHostUid(hostNode == null ? void 0 : hostNode.uid, openView);
14471
+ if (!externalPopupHostUid) {
14472
+ return void 0;
14055
14473
  }
14056
- let current = this.projectCalendarBlockPopupHosts(node);
14057
- let nextSubModels = current == null ? void 0 : current.subModels;
14058
- let changed = current !== node;
14059
- if (!nextSubModels || typeof nextSubModels !== "object") {
14060
- return current;
14474
+ if ((openView == null ? void 0 : openView.popupTemplateContext) || String((openView == null ? void 0 : openView.popupTemplateUid) || "").trim()) {
14475
+ return externalPopupHostUid;
14061
14476
  }
14062
- for (const [subKey, value] of Object.entries(nextSubModels)) {
14063
- if (Array.isArray(value)) {
14064
- const nextItems = [];
14065
- let itemsChanged = false;
14066
- for (const item of value) {
14067
- const nextItem = this.projectCalendarBlockPopupHostsInTree(item);
14068
- nextItems.push(nextItem);
14069
- itemsChanged = itemsChanged || nextItem !== item;
14070
- }
14071
- if (!itemsChanged) {
14072
- continue;
14073
- }
14074
- if (!changed) {
14075
- current = {
14076
- ...current,
14077
- subModels: {
14078
- ...nextSubModels
14079
- }
14080
- };
14081
- nextSubModels = current.subModels;
14082
- changed = true;
14083
- }
14084
- nextSubModels[subKey] = nextItems;
14085
- continue;
14086
- }
14087
- const nextValue = this.projectCalendarBlockPopupHostsInTree(value);
14088
- if (nextValue === value) {
14089
- continue;
14090
- }
14091
- if (!changed) {
14092
- current = {
14093
- ...current,
14094
- subModels: {
14095
- ...nextSubModels
14096
- }
14097
- };
14098
- nextSubModels = current.subModels;
14099
- changed = true;
14100
- }
14101
- nextSubModels[subKey] = nextValue;
14102
- }
14103
- return current;
14477
+ return void 0;
14104
14478
  }
14105
- async ensureKanbanBlockPopupHosts(blockNode, transaction) {
14106
- var _a;
14107
- if (!(blockNode == null ? void 0 : blockNode.uid) || blockNode.use !== "KanbanBlockModel") {
14108
- return blockNode;
14109
- }
14110
- const resourceInit = this.getKanbanBlockResourceInit(blockNode);
14111
- let changed = false;
14112
- for (const actionKey of KANBAN_POPUP_ACTION_KEYS) {
14113
- const existing = (0, import_service_utils.getSingleNodeSubModel)((_a = blockNode.subModels) == null ? void 0 : _a[actionKey]);
14114
- const expectedUid = this.getKanbanPopupActionUid(blockNode.uid, actionKey);
14115
- const expectedUse = this.getKanbanPopupActionUse(actionKey);
14116
- const openView = this.buildKanbanPopupOpenView({
14117
- blockNode,
14118
- actionKey,
14119
- resourceInit
14120
- });
14121
- const currentOpenView = this.resolvePopupHostOpenView(existing);
14122
- const shouldReplaceExisting = (existing == null ? void 0 : existing.uid) && existing.uid !== expectedUid;
14123
- const shouldUpsert = !(existing == null ? void 0 : existing.uid) || shouldReplaceExisting || existing.use !== expectedUse || !import_lodash.default.isEqual(currentOpenView, openView);
14124
- if (!shouldUpsert) {
14125
- continue;
14126
- }
14127
- if (shouldReplaceExisting) {
14128
- await this.removeNodeTreeWithBindings(existing.uid, transaction);
14129
- }
14130
- if ((existing == null ? void 0 : existing.uid) && existing.uid === expectedUid && !import_lodash.default.isEqual(currentOpenView, openView)) {
14131
- await this.reconcilePopupOpenViewTransition(expectedUid, currentOpenView, openView, transaction);
14132
- }
14133
- const nextActionNode = {
14134
- ...(existing == null ? void 0 : existing.uid) && existing.uid === expectedUid ? import_lodash.default.cloneDeep(existing) : {},
14135
- uid: expectedUid,
14136
- use: expectedUse,
14137
- stepParams: import_lodash.default.merge({}, (existing == null ? void 0 : existing.uid) === expectedUid ? import_lodash.default.cloneDeep(existing.stepParams || {}) : {}, {
14138
- popupSettings: {
14139
- openView
14140
- }
14141
- })
14142
- };
14143
- await this.repository.upsertModel(
14144
- {
14145
- parentId: blockNode.uid,
14146
- subKey: actionKey,
14147
- subType: "object",
14148
- ...nextActionNode
14149
- },
14150
- { transaction }
14151
- );
14152
- changed = true;
14153
- }
14154
- if (!changed) {
14155
- return blockNode;
14479
+ async ensureHiddenPopupBlockHostsInManagedPopupTarget(hostNode, transaction, visitedPopupTargetUids = /* @__PURE__ */ new Set()) {
14480
+ const popupTargetUid = this.resolveManagedPopupTargetUidForHiddenPopupBackfill(hostNode);
14481
+ if (!popupTargetUid || visitedPopupTargetUids.has(popupTargetUid)) {
14482
+ return;
14156
14483
  }
14157
- return this.repository.findModelById(blockNode.uid, {
14484
+ visitedPopupTargetUids.add(popupTargetUid);
14485
+ const popupTarget = await this.repository.findModelById(popupTargetUid, {
14158
14486
  transaction,
14159
14487
  includeAsyncNode: true
14488
+ }).catch(() => null);
14489
+ if (!(popupTarget == null ? void 0 : popupTarget.uid)) {
14490
+ return;
14491
+ }
14492
+ await this.ensureHiddenPopupBlockHostsInTree(popupTarget, transaction, {
14493
+ ensureManagedPopupTemplateTargets: true,
14494
+ visitedPopupTargetUids
14160
14495
  });
14161
14496
  }
14162
- async ensureKanbanBlockPopupHostsInTree(node, transaction) {
14497
+ async ensureHiddenPopupBlockHostsInTree(node, transaction, options = {}) {
14163
14498
  if (!node || typeof node !== "object") {
14164
14499
  return node;
14165
14500
  }
14501
+ const visitedPopupTargetUids = options.visitedPopupTargetUids || /* @__PURE__ */ new Set();
14166
14502
  let current = node;
14503
+ if (current.use === "CalendarBlockModel") {
14504
+ current = await this.ensureCalendarBlockPopupHosts(current, transaction);
14505
+ }
14167
14506
  if (current.use === "KanbanBlockModel") {
14168
14507
  current = await this.ensureKanbanBlockPopupHosts(current, transaction);
14169
14508
  }
@@ -14172,7 +14511,10 @@ class FlowSurfacesService {
14172
14511
  const nextItems = [];
14173
14512
  let changed = false;
14174
14513
  for (const item of value) {
14175
- const nextItem = await this.ensureKanbanBlockPopupHostsInTree(item, transaction);
14514
+ const nextItem = await this.ensureHiddenPopupBlockHostsInTree(item, transaction, {
14515
+ ...options,
14516
+ visitedPopupTargetUids
14517
+ });
14176
14518
  nextItems.push(nextItem);
14177
14519
  changed = changed || nextItem !== item;
14178
14520
  }
@@ -14181,114 +14523,16 @@ class FlowSurfacesService {
14181
14523
  }
14182
14524
  continue;
14183
14525
  }
14184
- const nextValue = await this.ensureKanbanBlockPopupHostsInTree(value, transaction);
14526
+ const nextValue = await this.ensureHiddenPopupBlockHostsInTree(value, transaction, {
14527
+ ...options,
14528
+ visitedPopupTargetUids
14529
+ });
14185
14530
  if (nextValue !== value) {
14186
14531
  current.subModels[subKey] = nextValue;
14187
14532
  }
14188
14533
  }
14189
- return current;
14190
- }
14191
- projectKanbanBlockPopupHosts(node) {
14192
- var _a;
14193
- if (!node || typeof node !== "object") {
14194
- return node;
14195
- }
14196
- const current = node;
14197
- if (!(current == null ? void 0 : current.uid) || current.use !== "KanbanBlockModel") {
14198
- return node;
14199
- }
14200
- const resourceInit = this.getKanbanBlockResourceInit(current);
14201
- let nextSubModels = current.subModels;
14202
- let changed = false;
14203
- for (const actionKey of KANBAN_POPUP_ACTION_KEYS) {
14204
- const existing = (0, import_service_utils.getSingleNodeSubModel)((_a = current.subModels) == null ? void 0 : _a[actionKey]);
14205
- const expectedUid = this.getKanbanPopupActionUid(current.uid, actionKey);
14206
- const expectedUse = this.getKanbanPopupActionUse(actionKey);
14207
- const openView = this.buildKanbanPopupOpenView({
14208
- blockNode: current,
14209
- actionKey,
14210
- resourceInit
14211
- });
14212
- const currentOpenView = this.resolvePopupHostOpenView(existing);
14213
- if ((existing == null ? void 0 : existing.uid) === expectedUid && existing.use === expectedUse && import_lodash.default.isEqual(currentOpenView, openView)) {
14214
- continue;
14215
- }
14216
- const nextActionNode = {
14217
- ...(existing == null ? void 0 : existing.uid) === expectedUid ? import_lodash.default.cloneDeep(existing) : {},
14218
- uid: expectedUid,
14219
- use: expectedUse,
14220
- stepParams: import_lodash.default.merge({}, (existing == null ? void 0 : existing.uid) === expectedUid ? import_lodash.default.cloneDeep(existing.stepParams || {}) : {}, {
14221
- popupSettings: {
14222
- openView
14223
- }
14224
- })
14225
- };
14226
- if (!changed) {
14227
- nextSubModels = {
14228
- ...current.subModels || {}
14229
- };
14230
- changed = true;
14231
- }
14232
- nextSubModels[actionKey] = nextActionNode;
14233
- }
14234
- if (!changed) {
14235
- return node;
14236
- }
14237
- return {
14238
- ...current,
14239
- subModels: nextSubModels
14240
- };
14241
- }
14242
- projectKanbanBlockPopupHostsInTree(node) {
14243
- if (!node || typeof node !== "object") {
14244
- return node;
14245
- }
14246
- let current = this.projectKanbanBlockPopupHosts(node);
14247
- let nextSubModels = current == null ? void 0 : current.subModels;
14248
- let changed = current !== node;
14249
- if (!nextSubModels || typeof nextSubModels !== "object") {
14250
- return current;
14251
- }
14252
- for (const [subKey, value] of Object.entries(nextSubModels)) {
14253
- if (Array.isArray(value)) {
14254
- const nextItems = [];
14255
- let itemsChanged = false;
14256
- for (const item of value) {
14257
- const nextItem = this.projectKanbanBlockPopupHostsInTree(item);
14258
- nextItems.push(nextItem);
14259
- itemsChanged = itemsChanged || nextItem !== item;
14260
- }
14261
- if (!itemsChanged) {
14262
- continue;
14263
- }
14264
- if (!changed) {
14265
- current = {
14266
- ...current,
14267
- subModels: {
14268
- ...nextSubModels
14269
- }
14270
- };
14271
- nextSubModels = current.subModels;
14272
- changed = true;
14273
- }
14274
- nextSubModels[subKey] = nextItems;
14275
- continue;
14276
- }
14277
- const nextValue = this.projectKanbanBlockPopupHostsInTree(value);
14278
- if (nextValue === value) {
14279
- continue;
14280
- }
14281
- if (!changed) {
14282
- current = {
14283
- ...current,
14284
- subModels: {
14285
- ...nextSubModels
14286
- }
14287
- };
14288
- nextSubModels = current.subModels;
14289
- changed = true;
14290
- }
14291
- nextSubModels[subKey] = nextValue;
14534
+ if (options.ensureManagedPopupTemplateTargets) {
14535
+ await this.ensureHiddenPopupBlockHostsInManagedPopupTarget(current, transaction, visitedPopupTargetUids);
14292
14536
  }
14293
14537
  return current;
14294
14538
  }
@@ -15552,10 +15796,9 @@ class FlowSurfacesService {
15552
15796
  if (options.persistCalendarPopupHosts === false) {
15553
15797
  return this.projectKanbanBlockPopupHostsInTree(this.projectCalendarBlockPopupHostsInTree(node));
15554
15798
  }
15555
- return this.ensureKanbanBlockPopupHostsInTree(
15556
- await this.ensureCalendarBlockPopupHostsInTree(node, transaction),
15557
- transaction
15558
- );
15799
+ return this.ensureHiddenPopupBlockHostsInTree(node, transaction, {
15800
+ ensureManagedPopupTemplateTargets: options.ensureManagedPopupTemplateTargets === true
15801
+ });
15559
15802
  }
15560
15803
  normalizePopupTreeShape(node) {
15561
15804
  if (!node || typeof node !== "object") {