@acorex-platform/module-location-management-client 1.0.1 → 2.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/fesm2022/acorex-platform-module-location-management-client-acorex-platform-module-location-management-client-CnENeOgY.mjs +1658 -0
  2. package/fesm2022/acorex-platform-module-location-management-client-acorex-platform-module-location-management-client-CnENeOgY.mjs.map +1 -0
  3. package/fesm2022/acorex-platform-module-location-management-client-address-widget-print.component-MyMPTP7_.mjs +21 -0
  4. package/fesm2022/acorex-platform-module-location-management-client-address-widget-print.component-MyMPTP7_.mjs.map +1 -0
  5. package/fesm2022/{acorex-platform-module-location-management-client-assign-existing-location-to-party.command-DECKrIBR.mjs → acorex-platform-module-location-management-client-assign-existing-location-to-party.command-BvuJiRNy.mjs} +1 -1
  6. package/fesm2022/{acorex-platform-module-location-management-client-assign-existing-location-to-party.command-DECKrIBR.mjs.map → acorex-platform-module-location-management-client-assign-existing-location-to-party.command-BvuJiRNy.mjs.map} +1 -1
  7. package/fesm2022/acorex-platform-module-location-management-client-contracts-entities-location-assignment.mjs +1 -1
  8. package/fesm2022/acorex-platform-module-location-management-client-contracts-entities-location-assignment.mjs.map +1 -1
  9. package/fesm2022/acorex-platform-module-location-management-client-contracts-entities-location-type.mjs +1 -0
  10. package/fesm2022/acorex-platform-module-location-management-client-contracts-entities-location-type.mjs.map +1 -1
  11. package/fesm2022/acorex-platform-module-location-management-client-contracts-entity-catalog-acorex-platform-module-location-management-client-contracts-entity-catalog-CUIKXXZM.mjs +141 -0
  12. package/fesm2022/acorex-platform-module-location-management-client-contracts-entity-catalog-acorex-platform-module-location-management-client-contracts-entity-catalog-CUIKXXZM.mjs.map +1 -0
  13. package/fesm2022/{acorex-platform-module-location-management-client-contracts-entity-catalog-geographic-region.entity-DBsnIXJ2.mjs → acorex-platform-module-location-management-client-contracts-entity-catalog-geographic-region.entity-DeQEPvAb.mjs} +2 -2
  14. package/fesm2022/{acorex-platform-module-location-management-client-contracts-entity-catalog-geographic-region.entity-DBsnIXJ2.mjs.map → acorex-platform-module-location-management-client-contracts-entity-catalog-geographic-region.entity-DeQEPvAb.mjs.map} +1 -1
  15. package/fesm2022/{acorex-platform-module-location-management-client-contracts-entity-catalog-location-assignment.entity-D_of7F2n.mjs → acorex-platform-module-location-management-client-contracts-entity-catalog-location-assignment.entity-Cm55C02R.mjs} +4 -4
  16. package/fesm2022/acorex-platform-module-location-management-client-contracts-entity-catalog-location-assignment.entity-Cm55C02R.mjs.map +1 -0
  17. package/fesm2022/{acorex-platform-module-location-management-client-contracts-entity-catalog-location-assignment.utils-CfwbSQiM.mjs → acorex-platform-module-location-management-client-contracts-entity-catalog-location-assignment.utils-Bp3Axtxi.mjs} +1 -1
  18. package/fesm2022/{acorex-platform-module-location-management-client-contracts-entity-catalog-location-assignment.utils-CfwbSQiM.mjs.map → acorex-platform-module-location-management-client-contracts-entity-catalog-location-assignment.utils-Bp3Axtxi.mjs.map} +1 -1
  19. package/fesm2022/{acorex-platform-module-location-management-client-contracts-entity-catalog-location-role.entity-C735P573.mjs → acorex-platform-module-location-management-client-contracts-entity-catalog-location-role.entity-DfocIVqh.mjs} +2 -2
  20. package/fesm2022/{acorex-platform-module-location-management-client-contracts-entity-catalog-location-role.entity-C735P573.mjs.map → acorex-platform-module-location-management-client-contracts-entity-catalog-location-role.entity-DfocIVqh.mjs.map} +1 -1
  21. package/fesm2022/{acorex-platform-module-location-management-client-contracts-entity-catalog-location-type.entity-B1_lHdxY.mjs → acorex-platform-module-location-management-client-contracts-entity-catalog-location-type.entity-DJzjhezY.mjs} +3 -2
  22. package/fesm2022/acorex-platform-module-location-management-client-contracts-entity-catalog-location-type.entity-DJzjhezY.mjs.map +1 -0
  23. package/fesm2022/{acorex-platform-module-location-management-client-contracts-entity-catalog-location.entity-Bkiyn_GH.mjs → acorex-platform-module-location-management-client-contracts-entity-catalog-location.entity-DKc5CTsC.mjs} +3 -3
  24. package/fesm2022/{acorex-platform-module-location-management-client-contracts-entity-catalog-location.entity-Bkiyn_GH.mjs.map → acorex-platform-module-location-management-client-contracts-entity-catalog-location.entity-DKc5CTsC.mjs.map} +1 -1
  25. package/fesm2022/acorex-platform-module-location-management-client-contracts-entity-catalog.mjs +1 -1
  26. package/fesm2022/acorex-platform-module-location-management-client-contracts.mjs +75 -59
  27. package/fesm2022/acorex-platform-module-location-management-client-contracts.mjs.map +1 -1
  28. package/fesm2022/{acorex-platform-module-location-management-client-create-location-with-assignment.command-Cl6KfruM.mjs → acorex-platform-module-location-management-client-create-location-with-assignment.command-D1l3h2Op.mjs} +23 -10
  29. package/fesm2022/acorex-platform-module-location-management-client-create-location-with-assignment.command-D1l3h2Op.mjs.map +1 -0
  30. package/fesm2022/acorex-platform-module-location-management-client.mjs +1 -1668
  31. package/fesm2022/acorex-platform-module-location-management-client.mjs.map +1 -1
  32. package/package.json +1 -1
  33. package/types/acorex-platform-module-location-management-client-contracts.d.ts +3 -1
  34. package/fesm2022/acorex-platform-module-location-management-client-contracts-entity-catalog-acorex-platform-module-location-management-client-contracts-entity-catalog--lXGk_uE.mjs +0 -70
  35. package/fesm2022/acorex-platform-module-location-management-client-contracts-entity-catalog-acorex-platform-module-location-management-client-contracts-entity-catalog--lXGk_uE.mjs.map +0 -1
  36. package/fesm2022/acorex-platform-module-location-management-client-contracts-entity-catalog-location-assignment.entity-D_of7F2n.mjs.map +0 -1
  37. package/fesm2022/acorex-platform-module-location-management-client-contracts-entity-catalog-location-type.entity-B1_lHdxY.mjs.map +0 -1
  38. package/fesm2022/acorex-platform-module-location-management-client-create-location-with-assignment.command-Cl6KfruM.mjs.map +0 -1
@@ -0,0 +1,1658 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Injectable, inject, signal, effect, computed, HostBinding, ChangeDetectionStrategy, Component, NgModule } from '@angular/core';
3
+ import { AXP_FEATURE_DEFINITION_PROVIDER } from '@acorex-platform/framework-client/core';
4
+ import { AXPEntityService, AXP_ENTITY_STORAGE_MIDDLEWARE } from '@acorex-platform/framework-client/layout/entity';
5
+ import { RootConfig, AXPPeopleOrganizationPermissionKeys, AXPLocationManagementMenuKeys, buildLocationAssignmentLocationSnapshot, buildLocationAssignmentPersonSnapshot } from '@acorex-platform/module-location-management-client/contracts';
6
+ import { AXPSearchCommandProvider, createEntityCommandOptions, AXPSettingsService, AXPClipBoardService, AXP_MENU_PROVIDER, AXP_SETTING_DEFINITION_PROVIDER, AXP_SEARCH_PROVIDER } from '@acorex-platform/framework-client/common';
7
+ import { AXP_PERMISSION_DEFINITION_PROVIDER } from '@acorex-platform/framework-client/auth';
8
+ import { AXP_WIDGETS_EDITOR_SUB_COMPOSITE, AXP_WIDGETS_EDITOR_CATEGORY, AXPValueWidgetComponent, AXPColumnWidgetComponent, AXPWidgetCoreModule, AXP_WIDGET_DEFINITION_PROVIDER } from '@acorex-platform/framework-client/layout/widget-core';
9
+ import * as i1 from '@angular/common';
10
+ import { CommonModule } from '@angular/common';
11
+ import { provideCommandSetups } from '@acorex-platform/framework-client/runtime';
12
+ import { AXPCommonPermissionGroupKeys, AXPCommonMenuKeys } from '@acorex-platform/module-common-client/contracts';
13
+ import { get, set, defaultTo, isEmpty, isEqual, isNil, isNull } from 'lodash';
14
+ import { widgetPrint, AXPPlatformScope, formatAddressData, extractValue, resolveMultiLanguageString } from '@acorex-platform/framework-shared/core';
15
+ import { createSelectProperty, createBooleanProperty, AXPWidgetGroupEnum } from '@acorex-platform/framework-shared/widget-core';
16
+ import { AXP_NAME_PROPERTY, AXP_DATA_PATH_PROPERTY, AXP_DISABLED_PROPERTY, AXP_HAS_LABEL_PROPERTY, AXP_PLACEHOLDER_PROPERTY, AXP_BEHAVIOR_PROPERTY_GROUP } from '@acorex-platform/framework-client/layout/widgets';
17
+ import * as i6 from '@acorex/components/button';
18
+ import { AXButtonModule } from '@acorex/components/button';
19
+ import * as i4 from '@acorex/components/decorators';
20
+ import { AXDecoratorModule } from '@acorex/components/decorators';
21
+ import * as i3 from '@acorex/components/form';
22
+ import { AXFormModule } from '@acorex/components/form';
23
+ import * as i5 from '@acorex/components/text-box';
24
+ import { AXTextBoxModule } from '@acorex/components/text-box';
25
+ import { AXTranslationService, AXTranslationModule } from '@acorex/core/translation';
26
+ import { AXValidationModule } from '@acorex/core/validation';
27
+ import { AXPLayoutBuilderService, AXPLayoutRendererComponent } from '@acorex-platform/framework-client/layout/builder';
28
+ import * as i2 from '@angular/forms';
29
+ import { FormsModule } from '@angular/forms';
30
+ import * as i7 from '@acorex/components/accordion';
31
+ import { AXAccordionModule } from '@acorex/components/accordion';
32
+ import * as i1$1 from '@acorex/components/badge';
33
+ import { AXBadgeModule } from '@acorex/components/badge';
34
+
35
+ //#endregion
36
+ //#region ---- Permission Definition Provider ----
37
+ /**
38
+ * Ensures People & Organization root exists for location-management.
39
+ */
40
+ class AXMLocationManagementPermissionDefinitionProvider {
41
+ async define(context) {
42
+ const groups = AXPCommonPermissionGroupKeys;
43
+ const G = '@common:permission-groups';
44
+ context.addGroup(groups.PeopleOrganization.Root, `${G}.people-organization.title`, `${G}.people-organization.description`, { order: 10 });
45
+ }
46
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXMLocationManagementPermissionDefinitionProvider, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
47
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXMLocationManagementPermissionDefinitionProvider }); }
48
+ }
49
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXMLocationManagementPermissionDefinitionProvider, decorators: [{
50
+ type: Injectable
51
+ }] });
52
+
53
+ //#region ---- Imports ----
54
+ //#endregion
55
+ //#region ---- Menu Provider ----
56
+ class AXMLocationManagementMenuProvider {
57
+ constructor() {
58
+ this.entityService = inject(AXPEntityService);
59
+ }
60
+ async provide(context) {
61
+ const module = RootConfig.module;
62
+ const keys = AXPPeopleOrganizationPermissionKeys;
63
+ const contactsMenu = context.find(AXPCommonMenuKeys.Contacts);
64
+ if (!contactsMenu.exists) {
65
+ context.addItems([
66
+ {
67
+ name: AXPCommonMenuKeys.Contacts,
68
+ priority: 8010,
69
+ text: '@general:menus.contacts.title',
70
+ icon: 'fa-light fa-address-book',
71
+ type: 'menu',
72
+ children: [],
73
+ },
74
+ ]);
75
+ }
76
+ context.find(AXPCommonMenuKeys.Contacts).addItems([
77
+ {
78
+ name: AXPLocationManagementMenuKeys.Locations,
79
+ text: RootConfig.entities.location.titlePlural,
80
+ path: this.entityService.createPath(module.name, RootConfig.entities.location.name),
81
+ icon: RootConfig.entities.location.icon,
82
+ priority: 40,
83
+ policy: {
84
+ features: [module.name],
85
+ permissions: [keys.Setup],
86
+ },
87
+ },
88
+ ]);
89
+ context.find(AXPCommonMenuKeys.Region).addItems([
90
+ {
91
+ name: AXPLocationManagementMenuKeys.LocationTypes,
92
+ text: '@location-management:location-types.menus.location-types.title',
93
+ path: this.entityService.createPath(module.name, RootConfig.entities.locationType.name),
94
+ icon: RootConfig.entities.locationType.icon,
95
+ priority: 1,
96
+ policy: {
97
+ features: [module.name],
98
+ permissions: [keys.Setup],
99
+ },
100
+ },
101
+ {
102
+ name: AXPLocationManagementMenuKeys.LocationRoles,
103
+ text: '@location-management:location-roles.menus.location-roles.title',
104
+ path: this.entityService.createPath(module.name, RootConfig.entities.locationRole.name),
105
+ icon: RootConfig.entities.locationRole.icon,
106
+ priority: 2,
107
+ policy: {
108
+ features: [module.name],
109
+ permissions: [keys.Setup],
110
+ },
111
+ },
112
+ {
113
+ name: AXPLocationManagementMenuKeys.GeographicRegions,
114
+ text: '@location-management:geographic-regions.menus.geographic-regions.title',
115
+ path: this.entityService.createPath(module.name, RootConfig.entities.geographicRegion.name),
116
+ icon: RootConfig.entities.geographicRegion.icon,
117
+ priority: 3,
118
+ policy: {
119
+ features: [module.name],
120
+ permissions: [keys.Setup],
121
+ },
122
+ },
123
+ ]);
124
+ }
125
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXMLocationManagementMenuProvider, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
126
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXMLocationManagementMenuProvider }); }
127
+ }
128
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXMLocationManagementMenuProvider, decorators: [{
129
+ type: Injectable
130
+ }] });
131
+
132
+ class AXMSettingProvider {
133
+ async provide(context) {
134
+ // context
135
+ // // Add Form Template Group
136
+ // .addGroup('form-template', 'Form Template', 'Settings related to form templates.', RootConfig.module.icon)
137
+ // // Start Interface Section
138
+ // .addSection('interface', 'UI Interface', 'Customize the user interface for forms.')
139
+ // .addSetting({
140
+ // key: 'history-panel',
141
+ // title: 'Show History Panel',
142
+ // scope: 'U',
143
+ // isInherited: true,
144
+ // defaultValue: false,
145
+ // widget: {
146
+ // type: AXPWidgetsCatalog.toggle,
147
+ // },
148
+ // description: 'Enable or disable the history panel for forms.',
149
+ // validationRules: [
150
+ // {
151
+ // rule: 'required',
152
+ // },
153
+ // ],
154
+ // })
155
+ // .endSection()
156
+ // .endGroup();
157
+ }
158
+ }
159
+
160
+ class AXMSearchCommandProvider extends AXPSearchCommandProvider {
161
+ constructor() {
162
+ super(...arguments);
163
+ this.commands = [
164
+ {
165
+ id: 'create-location-role',
166
+ group: 'command',
167
+ title: RootConfig.entities.locationRole.title,
168
+ icon: RootConfig.entities.locationRole.icon,
169
+ description: RootConfig.entities.locationRole.titlePlural,
170
+ command: {
171
+ name: 'Entity:Create',
172
+ options: createEntityCommandOptions(`${RootConfig.module.name}.${RootConfig.entities.locationRole.name}`, {
173
+ name: RootConfig.entities.locationRole.name,
174
+ module: RootConfig.module.name,
175
+ title: RootConfig.entities.locationRole.title,
176
+ }),
177
+ },
178
+ },
179
+ {
180
+ id: 'create-location-type',
181
+ group: 'command',
182
+ title: RootConfig.entities.locationType.title,
183
+ icon: RootConfig.entities.locationType.icon,
184
+ description: RootConfig.entities.locationType.titlePlural,
185
+ command: {
186
+ name: 'Entity:Create',
187
+ options: createEntityCommandOptions(`${RootConfig.module.name}.${RootConfig.entities.locationType.name}`, {
188
+ name: RootConfig.entities.locationType.name,
189
+ module: RootConfig.module.name,
190
+ title: RootConfig.entities.locationType.title,
191
+ }),
192
+ },
193
+ },
194
+ {
195
+ id: 'create-geographic-region',
196
+ group: 'command',
197
+ title: RootConfig.entities.geographicRegion.title,
198
+ icon: RootConfig.entities.geographicRegion.icon,
199
+ description: RootConfig.entities.geographicRegion.titlePlural,
200
+ command: {
201
+ name: 'Entity:Create',
202
+ options: createEntityCommandOptions(`${RootConfig.module.name}.${RootConfig.entities.geographicRegion.name}`, {
203
+ name: RootConfig.entities.geographicRegion.name,
204
+ module: RootConfig.module.name,
205
+ title: RootConfig.entities.geographicRegion.title,
206
+ }),
207
+ },
208
+ },
209
+ ];
210
+ }
211
+ }
212
+
213
+ //#region ---- Imports ----
214
+ //#endregion
215
+ //#region ---- Feature Definition Provider ----
216
+ /**
217
+ * Location Management Feature Definition Provider.
218
+ * Provides feature definitions for the Location Management module.
219
+ */
220
+ class AXMLocationManagementFeatureDefinitionProvider {
221
+ async provide(context) {
222
+ // Management feature removed - module name is used directly as feature key
223
+ }
224
+ }
225
+ //#endregion
226
+
227
+ //#region ---- LocationAssignment nested hydration ----
228
+ const LOCATION_ASSIGNMENT_ENTITY = `${RootConfig.module.name}.${RootConfig.entities.locationAssignment.name}`;
229
+ const LOCATION_ENTITY = `${RootConfig.module.name}.${RootConfig.entities.location.name}`;
230
+ const PERSON_ENTITY = 'PersonCore.Person';
231
+ /**
232
+ * Hydrates nested `location` and `person` on LocationAssignment rows so consumers
233
+ * (e.g. party location lists) receive computed fields such as `fullAddress` and `fullName`.
234
+ */
235
+ const locationAssignmentLocationHydrateMiddleware = {
236
+ target: { ops: ['getOne', 'getAll', 'query'], order: 13 },
237
+ execute: async (ctx, next) => {
238
+ const backend = ctx.entities;
239
+ await next();
240
+ if (ctx.entityName !== LOCATION_ASSIGNMENT_ENTITY) {
241
+ return;
242
+ }
243
+ try {
244
+ const rows = Array.isArray(ctx.result)
245
+ ? ctx.result
246
+ : Array.isArray(ctx.result?.items)
247
+ ? (ctx.result.items ?? [])
248
+ : ctx.result
249
+ ? [ctx.result]
250
+ : [];
251
+ if (!rows.length) {
252
+ return;
253
+ }
254
+ const locationIds = Array.from(new Set(rows.map((row) => get(row, 'locationId')).filter((id) => id != null)));
255
+ const personIds = Array.from(new Set(rows.map((row) => get(row, 'personId')).filter((id) => id != null)));
256
+ const locationMap = new Map();
257
+ if (locationIds.length) {
258
+ const locationResponse = await backend.query(LOCATION_ENTITY, {
259
+ skip: 0,
260
+ take: locationIds.length,
261
+ filter: { field: 'id', operator: { type: 'in' }, value: locationIds },
262
+ });
263
+ for (const item of locationResponse?.items ?? []) {
264
+ const record = item;
265
+ locationMap.set(get(record, 'id'), record);
266
+ }
267
+ }
268
+ const personMap = new Map();
269
+ if (personIds.length) {
270
+ const personResponse = await backend.query(PERSON_ENTITY, {
271
+ skip: 0,
272
+ take: personIds.length,
273
+ filter: { field: 'id', operator: { type: 'in' }, value: personIds },
274
+ });
275
+ for (const item of personResponse?.items ?? []) {
276
+ const record = item;
277
+ personMap.set(get(record, 'id'), record);
278
+ }
279
+ }
280
+ for (const row of rows) {
281
+ const locationId = get(row, 'locationId');
282
+ if (locationId != null) {
283
+ const location = locationMap.get(locationId);
284
+ if (location) {
285
+ set(row, 'location', buildLocationAssignmentLocationSnapshot(location, locationId));
286
+ }
287
+ }
288
+ const personId = get(row, 'personId');
289
+ if (personId != null) {
290
+ const person = personMap.get(personId);
291
+ if (person) {
292
+ set(row, 'person', buildLocationAssignmentPersonSnapshot(person, personId));
293
+ }
294
+ }
295
+ }
296
+ }
297
+ catch {
298
+ // swallow to avoid breaking main flow
299
+ }
300
+ },
301
+ };
302
+ //#endregion
303
+
304
+ const displayExpression = `value && typeof value === 'object' ? [value.address, value.line1, value.city, value.state, value.country, value.postalCode].map(display).filter(Boolean).join(', ') || display(value) : display(value)`;
305
+ const render = (c) => widgetPrint.printValue(c, displayExpression);
306
+
307
+ const AXPAddressWidget = {
308
+ name: 'address-editor',
309
+ title: '@platform-layout-widgets:widgets.address-editor.title',
310
+ description: '@platform-layout-widgets:widgets.address-editor.description',
311
+ categories: AXP_WIDGETS_EDITOR_CATEGORY,
312
+ subCategory: AXP_WIDGETS_EDITOR_SUB_COMPOSITE,
313
+ groups: [AXPWidgetGroupEnum.FormElement],
314
+ icon: 'fa-light fa-location-dot',
315
+ defaultFilterWidgetName: 'string-filter',
316
+ type: 'editor',
317
+ properties: [
318
+ AXP_NAME_PROPERTY,
319
+ AXP_DATA_PATH_PROPERTY,
320
+ createSelectProperty({
321
+ name: 'mode',
322
+ title: 'Mode',
323
+ group: AXP_BEHAVIOR_PROPERTY_GROUP,
324
+ dataSource: [
325
+ { id: 'simple', title: 'Single line' },
326
+ { id: 'popup', title: 'Popup editor' },
327
+ { id: 'expandable', title: 'Expandable panel' },
328
+ ],
329
+ defaultValue: { id: 'simple', title: 'Single line' },
330
+ path: 'options.mode',
331
+ }),
332
+ createBooleanProperty({
333
+ name: 'hasLabel',
334
+ title: 'Has Label',
335
+ group: AXP_BEHAVIOR_PROPERTY_GROUP,
336
+ defaultValue: false,
337
+ path: 'options.hasLabel',
338
+ }),
339
+ createBooleanProperty({
340
+ name: 'hasMap',
341
+ title: 'Has Map',
342
+ group: AXP_BEHAVIOR_PROPERTY_GROUP,
343
+ defaultValue: true,
344
+ path: 'options.hasMap',
345
+ }),
346
+ AXP_DISABLED_PROPERTY,
347
+ AXP_HAS_LABEL_PROPERTY,
348
+ AXP_PLACEHOLDER_PROPERTY,
349
+ ],
350
+ components: {
351
+ formPrint: { component: () => import('./acorex-platform-module-location-management-client-address-widget-print.component-MyMPTP7_.mjs').then(m => m.AXPAddressEditorPrintComponent) },
352
+ view: {
353
+ component: () => Promise.resolve().then(function () { return addressWidgetView_component; }).then((c) => c.AXPAddressWidgetViewComponent),
354
+ },
355
+ edit: {
356
+ component: () => Promise.resolve().then(function () { return addressWidgetEdit_component; }).then((c) => c.AXPAddressWidgetEditComponent),
357
+ },
358
+ column: {
359
+ component: () => Promise.resolve().then(function () { return addressWidgetColumn_component; }).then((c) => c.AXPAddressWidgetColumnComponent),
360
+ },
361
+ designer: {
362
+ component: () => Promise.resolve().then(function () { return addressWidgetEdit_component; }).then((c) => c.AXPAddressWidgetEditComponent),
363
+ },
364
+ },
365
+ toString: displayExpression,
366
+ };
367
+
368
+ //#endregion
369
+
370
+ const TENANT_ORGANIZATION_ADDRESS_SETTINGS = {
371
+ street1: 'OrganizationManagement:Setting:Organization.Street1',
372
+ street2: 'OrganizationManagement:Setting:Organization.Street2',
373
+ countryId: 'OrganizationManagement:Setting:Organization.CountryId',
374
+ stateId: 'OrganizationManagement:Setting:Organization.StateId',
375
+ cityId: 'OrganizationManagement:Setting:Organization.CityId',
376
+ postalCode: 'OrganizationManagement:Setting:Organization.PostalCode',
377
+ };
378
+ const GEOGRAPHIC_REGION_ENTITY = 'LocationManagement.GeographicRegion';
379
+ //#region ---- Service ----
380
+ class AXPAddressWidgetService {
381
+ constructor() {
382
+ //#region ---- Services & Dependencies ----
383
+ this.layoutBuilder = inject(AXPLayoutBuilderService);
384
+ this.translationService = inject(AXTranslationService);
385
+ this.settingsService = inject(AXPSettingsService);
386
+ this.entityService = inject(AXPEntityService);
387
+ this.settingsService.onChanged.subscribe((event) => {
388
+ const settingKeys = Object.values(TENANT_ORGANIZATION_ADDRESS_SETTINGS);
389
+ if (event.keys.some((key) => settingKeys.includes(key))) {
390
+ this.invalidateGeographicDefaultsCache();
391
+ }
392
+ });
393
+ }
394
+ //#endregion
395
+ //#region ---- Shared address form layout (dialog + inline renderer) ----
396
+ /**
397
+ * Builds the address form content (street1, street2, country, state, city, postalCode, label, map).
398
+ * Used by both the dialog and the expandable inline layout via create().flex().build().
399
+ */
400
+ buildAddressFormContent(flex, options) {
401
+ const { hasLabel, labelEntity, hasMap, addressData } = options;
402
+ const showLabel = !!hasLabel && !!labelEntity;
403
+ flex.mode('edit').setDirection('column').setGap('12px');
404
+ //#region ---- Row 1: label + show map ----
405
+ if (showLabel || hasMap) {
406
+ flex.grid((metaRow) => {
407
+ metaRow.setColumns(12).setGap('12px');
408
+ if (showLabel) {
409
+ metaRow.formField('@location-management:locations.entities.location.fields.label', (field) => {
410
+ field.path('labelId');
411
+ field.layout(3);
412
+ field.customWidget('lookup-editor', {
413
+ entity: labelEntity,
414
+ look: 'select',
415
+ textField: 'title',
416
+ valueField: 'id',
417
+ hasClearButton: true,
418
+ allowCreate: 'quick',
419
+ create: {
420
+ enable: true,
421
+ title: '@location-management:locations.entities.location.fields.label-create-title',
422
+ },
423
+ expose: [
424
+ { source: 'id', target: 'label.id' },
425
+ { source: 'title', target: 'label.title' },
426
+ ],
427
+ validations: [{ rule: 'required', message: '@general:validation.messages.required' }],
428
+ });
429
+ });
430
+ }
431
+ if (hasMap) {
432
+ metaRow.formField('@location-management:locations.entities.location.fields.show-map', (field) => {
433
+ field.path('showMap');
434
+ field.layout(3);
435
+ field.toggleSwitch({
436
+ defaultValue: !!addressData?.coordinates,
437
+ });
438
+ });
439
+ }
440
+ });
441
+ }
442
+ //#endregion
443
+ //#region ---- Row 2: street address + address line 2 ----
444
+ flex.grid((streetRow) => {
445
+ streetRow.setColumns(12).setGap('12px');
446
+ streetRow
447
+ .formField('@location-management:locations.entities.location.fields.street1', (field) => {
448
+ field.path('street1');
449
+ field.layout(6);
450
+ field.textBox({
451
+ validations: [{ rule: 'required', message: '@general:validation.messages.required' }],
452
+ });
453
+ })
454
+ .formField('@location-management:locations.entities.location.fields.street2', (field) => {
455
+ field.path('street2');
456
+ field.layout(6);
457
+ field.textBox({});
458
+ });
459
+ });
460
+ //#endregion
461
+ //#region ---- Row 3: postal code + country + state + city ----
462
+ flex.grid((geoRow) => {
463
+ geoRow.setColumns(12).setGap('12px');
464
+ geoRow
465
+ .formField('@location-management:locations.entities.location.fields.postal-code', (field) => {
466
+ field.path('postalCode');
467
+ field.layout(3);
468
+ field.textBox({ placeholder: 'Enter postal code' });
469
+ })
470
+ .formField('@location-management:locations.entities.location.fields.country', (field) => {
471
+ field.path('countryId');
472
+ field.layout(3);
473
+ field.customWidget('lookup-editor', {
474
+ entity: 'LocationManagement.GeographicRegion',
475
+ look: 'select',
476
+ textField: 'title',
477
+ valueField: 'id',
478
+ hasClearButton: true,
479
+ allowCreate: 'quick',
480
+ create: {
481
+ enable: true,
482
+ },
483
+ expose: [
484
+ { source: 'id', target: 'country.id' },
485
+ { source: 'title', target: 'country.title' },
486
+ ],
487
+ filter: {
488
+ logic: 'and',
489
+ filters: [{ field: 'type.code', operator: { type: 'equal' }, value: 'country' }],
490
+ },
491
+ });
492
+ })
493
+ .formField('@location-management:locations.entities.location.fields.state', (field) => {
494
+ field.path('stateId');
495
+ field.layout(3);
496
+ field.customWidget('lookup-editor', {
497
+ entity: 'LocationManagement.GeographicRegion',
498
+ look: 'select',
499
+ textField: 'title',
500
+ valueField: 'id',
501
+ hasClearButton: true,
502
+ allowCreate: 'quick',
503
+ disabled: '{{ !context.eval("countryId") }}',
504
+ create: {
505
+ enable: true,
506
+ context: {
507
+ parentId: '{{ context.eval("countryId") }}',
508
+ type: { code: 'state' },
509
+ },
510
+ },
511
+ expose: [
512
+ { source: 'id', target: 'state.id' },
513
+ { source: 'title', target: 'state.title' },
514
+ ],
515
+ filter: {
516
+ logic: 'and',
517
+ filters: [
518
+ { field: 'parentId', operator: { type: 'equal' }, value: '{{ context.eval("countryId") }}' },
519
+ { field: 'type.code', operator: { type: 'equal' }, value: 'state' },
520
+ ],
521
+ },
522
+ triggers: [
523
+ {
524
+ event: "{{ events.context('countryId') }}",
525
+ action: "{{ widget.setValue(null); context.set('state.title', null); context.set('cityId', null); context.set('city.id', null); context.set('city.title', null); widget.refresh(); }}",
526
+ },
527
+ ],
528
+ });
529
+ })
530
+ .formField('@location-management:locations.entities.location.fields.city', (field) => {
531
+ field.path('cityId');
532
+ field.layout(3);
533
+ field.customWidget('lookup-editor', {
534
+ entity: 'LocationManagement.GeographicRegion',
535
+ look: 'select',
536
+ textField: 'title',
537
+ valueField: 'id',
538
+ hasClearButton: true,
539
+ allowCreate: 'quick',
540
+ disabled: '{{ !context.eval("stateId") }}',
541
+ create: {
542
+ enable: true,
543
+ context: {
544
+ parentId: '{{ context.eval("stateId") }}',
545
+ type: { code: 'city' },
546
+ },
547
+ },
548
+ expose: [
549
+ { source: 'id', target: 'city.id' },
550
+ { source: 'title', target: 'city.title' },
551
+ ],
552
+ filter: {
553
+ logic: 'and',
554
+ filters: [
555
+ { field: 'parentId', operator: { type: 'equal' }, value: '{{ context.eval("stateId") }}' },
556
+ { field: 'type.code', operator: { type: 'equal' }, value: 'city' },
557
+ ],
558
+ },
559
+ triggers: [
560
+ {
561
+ event: "{{ events.context('stateId') }}",
562
+ action: "{{ widget.setValue(null); context.set('city.title', null); widget.refresh(); }}",
563
+ },
564
+ {
565
+ event: "{{ events.context('countryId') }}",
566
+ action: "{{ widget.setValue(null); context.set('city.title', null); widget.refresh(); }}",
567
+ },
568
+ ],
569
+ });
570
+ });
571
+ });
572
+ //#endregion
573
+ //#region ---- Map picker (when show map is enabled) ----
574
+ if (hasMap) {
575
+ flex.grid((mapRow) => {
576
+ mapRow.setColumns(12).setGap('12px');
577
+ mapRow.formField('@location-management:locations.entities.location.fields.coordinates', (field) => {
578
+ field.path('coordinates');
579
+ field.layout(12);
580
+ field.visible('{{ context.eval("showMap") }}');
581
+ field.customWidget('map', { hasDraw: true, maxPolygon: 0 });
582
+ });
583
+ });
584
+ }
585
+ //#endregion
586
+ }
587
+ /**
588
+ * Returns the address form layout node using layoutBuilder.create().flex().build() for use in axp-layout-renderer.
589
+ */
590
+ getAddressFormLayout(options) {
591
+ return this.layoutBuilder
592
+ .create()
593
+ .flex((flex) => this.buildAddressFormContent(flex, options))
594
+ .build();
595
+ }
596
+ //#endregion
597
+ //#region ---- Geographic Defaults Methods ----
598
+ /** Loads geographic defaults from tenant organization address settings. */
599
+ async getGeographicDefaults() {
600
+ return this.loadGeographicDefaultsFromSettings();
601
+ }
602
+ async loadGeographicDefaultsFromSettings() {
603
+ const tenantScope = this.settingsService.scope(AXPPlatformScope.Tenant);
604
+ const [countryId, stateId, cityId, street1, street2, postalCode] = await Promise.all([
605
+ tenantScope.get(TENANT_ORGANIZATION_ADDRESS_SETTINGS.countryId),
606
+ tenantScope.get(TENANT_ORGANIZATION_ADDRESS_SETTINGS.stateId),
607
+ tenantScope.get(TENANT_ORGANIZATION_ADDRESS_SETTINGS.cityId),
608
+ tenantScope.get(TENANT_ORGANIZATION_ADDRESS_SETTINGS.street1),
609
+ tenantScope.get(TENANT_ORGANIZATION_ADDRESS_SETTINGS.street2),
610
+ tenantScope.get(TENANT_ORGANIZATION_ADDRESS_SETTINGS.postalCode),
611
+ ]);
612
+ const resolvedCountry = this.resolveSettingLookupSnapshot(countryId);
613
+ const resolvedState = this.resolveSettingLookupSnapshot(stateId);
614
+ const resolvedCity = this.resolveSettingLookupSnapshot(cityId);
615
+ const resolvedStreet1 = defaultTo(street1, '').trim();
616
+ const resolvedStreet2 = defaultTo(street2, '').trim();
617
+ const resolvedPostalCode = defaultTo(postalCode, '').trim();
618
+ if (isEmpty(resolvedCountry?.id) &&
619
+ isEmpty(resolvedState?.id) &&
620
+ isEmpty(resolvedCity?.id) &&
621
+ isEmpty(resolvedStreet1) &&
622
+ isEmpty(resolvedStreet2) &&
623
+ isEmpty(resolvedPostalCode)) {
624
+ return null;
625
+ }
626
+ return {
627
+ street1: resolvedStreet1 || undefined,
628
+ street2: resolvedStreet2 || undefined,
629
+ postalCode: resolvedPostalCode || undefined,
630
+ countryId: resolvedCountry?.id,
631
+ stateId: resolvedState?.id,
632
+ cityId: resolvedCity?.id,
633
+ country: resolvedCountry,
634
+ state: resolvedState,
635
+ city: resolvedCity,
636
+ };
637
+ }
638
+ /** Clears cached defaults (e.g. after tenant settings change). */
639
+ /** @deprecated Settings and entity reads own their invalidation. */
640
+ invalidateGeographicDefaultsCache() { }
641
+ /**
642
+ * Applies tenant/platform geographic defaults to empty address fields only.
643
+ * Returns whether any field was updated.
644
+ */
645
+ async applyGeographicDefaultsIfNeeded(value, options) {
646
+ if (options?.enabled === false) {
647
+ return { value, applied: false };
648
+ }
649
+ const defaults = await this.getGeographicDefaults();
650
+ if (!defaults) {
651
+ return { value, applied: false };
652
+ }
653
+ const merged = this.mergeGeographicDefaults(value, defaults);
654
+ const enriched = await this.enrichGeographicLookupTitles(merged);
655
+ const applied = !isEqual(this.snapshotGeographicFields(value), this.snapshotGeographicFields(enriched));
656
+ return { value: enriched, applied };
657
+ }
658
+ /** Merges defaults into empty country/state/city (and optional street/postal) fields. */
659
+ mergeGeographicDefaults(value, defaults) {
660
+ const result = { ...value };
661
+ if (this.isLookupEmpty(result.country) && defaults.country?.id) {
662
+ result.country = defaults.country;
663
+ }
664
+ if (this.isLookupEmpty(result.state) && defaults.state?.id) {
665
+ result.state = defaults.state;
666
+ }
667
+ if (this.isLookupEmpty(result.city) && defaults.city?.id) {
668
+ result.city = defaults.city;
669
+ }
670
+ if (!result.street1?.trim() && defaults.street1?.trim()) {
671
+ result.street1 = defaults.street1;
672
+ }
673
+ if (!result.street2?.trim() && defaults.street2?.trim()) {
674
+ result.street2 = defaults.street2;
675
+ }
676
+ if (!result.postalCode?.trim() && defaults.postalCode?.trim()) {
677
+ result.postalCode = defaults.postalCode;
678
+ }
679
+ return result;
680
+ }
681
+ /** Ensures country/state/city snapshots include titles required for formatted address text. */
682
+ async enrichGeographicLookupTitles(value) {
683
+ const [country, state, city] = await Promise.all([this.enrichLookupField(value.country), this.enrichLookupField(value.state), this.enrichLookupField(value.city)]);
684
+ if (country === value.country && state === value.state && city === value.city) {
685
+ return value;
686
+ }
687
+ return { ...value, country, state, city };
688
+ }
689
+ //#endregion
690
+ //#region ---- Geographic Cascade Methods ----
691
+ /**
692
+ * Builds layout context with flat lookup ids (countryId/stateId/cityId/labelId) required for cascade triggers.
693
+ * Same pattern as LocationManagement.Location entity fields.
694
+ */
695
+ buildAddressFormContext(addressData, options) {
696
+ return {
697
+ ...addressData,
698
+ countryId: addressData.country?.id,
699
+ stateId: addressData.state?.id,
700
+ cityId: addressData.city?.id,
701
+ labelId: addressData.label?.id,
702
+ showMap: (options?.hasMap ?? false) && !!addressData.coordinates,
703
+ };
704
+ }
705
+ /**
706
+ * Clears dependent geographic fields when a parent selection changes.
707
+ * Mirrors Location entity cascade: state depends on country, city depends on state.
708
+ */
709
+ applyGeographicCascade(previous, next) {
710
+ const result = { ...next };
711
+ const previousCountryId = previous.countryId ?? previous.country?.id;
712
+ const nextCountryId = result.countryId ?? result.country?.id;
713
+ const previousStateId = previous.stateId ?? previous.state?.id;
714
+ const nextStateId = result.stateId ?? result.state?.id;
715
+ if (previousCountryId !== nextCountryId) {
716
+ result.state = undefined;
717
+ result.city = undefined;
718
+ result.stateId = undefined;
719
+ result.cityId = undefined;
720
+ }
721
+ else if (previousStateId !== nextStateId) {
722
+ result.city = undefined;
723
+ result.cityId = undefined;
724
+ }
725
+ return result;
726
+ }
727
+ //#endregion
728
+ //#region ---- Address Formatting Methods ----
729
+ /**
730
+ * Formats address data into full address string
731
+ * Format: [street1], [street2], [country] - [state], [city], [postalCode]
732
+ * Uses titles from exposed fields, excludes coordinates
733
+ */
734
+ formatAddress(data) {
735
+ return formatAddressData(data, this.translationService.getActiveLang() || 'en-US');
736
+ }
737
+ /**
738
+ * Collapse header parts: label title (semibold in template) + full address.
739
+ */
740
+ async resolveCollapsibleHeader(value, options) {
741
+ const enriched = await this.enrichGeographicLookupTitles(value);
742
+ const full = (enriched.full?.trim() || this.formatAddress(enriched)).trim();
743
+ const addressText = full !== '' ? full : options.placeholder;
744
+ const labelText = enriched.label?.title?.trim() || null;
745
+ return { labelText, addressText };
746
+ }
747
+ //#endregion
748
+ //#region ---- Dialog & UI Methods ----
749
+ /**
750
+ * Shows address details popup dialog using the shared address form layout.
751
+ */
752
+ async showAddressDetailsPopup(addressData, options = {}) {
753
+ const { hasMap = true, hasLabel, labelEntity, useGeographicDefaults = true } = options;
754
+ const { value: addressWithDefaults } = await this.applyGeographicDefaultsIfNeeded(addressData, {
755
+ enabled: useGeographicDefaults,
756
+ });
757
+ const initialContext = this.buildAddressFormContext(addressWithDefaults, { hasMap });
758
+ const dialogTitle = await this.translationService.translateAsync('@general:terms.geography.address');
759
+ const ref = await this.layoutBuilder
760
+ .create()
761
+ .dialog((dialog) => {
762
+ dialog
763
+ .setTitle(dialogTitle)
764
+ .setSize('lg')
765
+ .setContext(initialContext)
766
+ .content((layoutBuilder) => {
767
+ layoutBuilder.flex((flex) => this.buildAddressFormContent(flex, {
768
+ hasLabel,
769
+ labelEntity,
770
+ hasMap,
771
+ addressData: addressWithDefaults,
772
+ }));
773
+ })
774
+ .setActions((actions) => {
775
+ actions.cancel('@general:actions.cancel.title').submit('@general:actions.apply.title');
776
+ });
777
+ })
778
+ .show();
779
+ if (ref.action() === 'cancel') {
780
+ ref.close();
781
+ return null;
782
+ }
783
+ const result = this.applyGeographicCascade(initialContext, this.normalizeAddressData(ref.context()));
784
+ ref.close();
785
+ return result;
786
+ }
787
+ //#endregion
788
+ //#region ---- Data Normalization Methods ----
789
+ /**
790
+ * Normalizes address data from various input formats
791
+ */
792
+ normalizeAddressData(value) {
793
+ if (typeof value === 'object' && value !== null) {
794
+ const contextValue = value;
795
+ return {
796
+ street1: contextValue.street1 ?? '',
797
+ street2: contextValue.street2,
798
+ country: contextValue.country,
799
+ state: contextValue.state,
800
+ city: contextValue.city,
801
+ postalCode: contextValue.postalCode,
802
+ coordinates: contextValue.coordinates,
803
+ full: contextValue.full ?? this.formatAddress(contextValue),
804
+ label: this.resolveLabel(contextValue),
805
+ };
806
+ }
807
+ // Simple string format
808
+ return {
809
+ street1: '',
810
+ street2: '',
811
+ country: undefined,
812
+ state: undefined,
813
+ city: undefined,
814
+ postalCode: '',
815
+ coordinates: undefined,
816
+ full: value?.toString() || '',
817
+ label: undefined,
818
+ };
819
+ }
820
+ /** Resolves persisted label snapshot from lookup expose or transient labelId. */
821
+ resolveLabel(value) {
822
+ const exposed = value.label;
823
+ if (exposed?.id) {
824
+ return { id: exposed.id, title: exposed.title };
825
+ }
826
+ if (value.labelId) {
827
+ return { id: value.labelId, title: exposed?.title };
828
+ }
829
+ return undefined;
830
+ }
831
+ isLookupEmpty(value) {
832
+ return isNil(value?.id) || value.id === '';
833
+ }
834
+ snapshotGeographicFields(value) {
835
+ return {
836
+ street1: value.street1,
837
+ street2: value.street2,
838
+ postalCode: value.postalCode,
839
+ country: value.country,
840
+ state: value.state,
841
+ city: value.city,
842
+ };
843
+ }
844
+ resolveSettingLookupSnapshot(value) {
845
+ if (isNil(value) || value === '') {
846
+ return undefined;
847
+ }
848
+ if (typeof value === 'object') {
849
+ const record = value;
850
+ const id = extractValue(record.id ?? value);
851
+ const title = extractValue(record.title);
852
+ if (!id?.trim()) {
853
+ return undefined;
854
+ }
855
+ return {
856
+ id: id.trim(),
857
+ title: title?.trim() || undefined,
858
+ };
859
+ }
860
+ const id = extractValue(value);
861
+ return id?.trim() ? { id: id.trim() } : undefined;
862
+ }
863
+ async enrichLookupField(field) {
864
+ if (!field?.id) {
865
+ return field;
866
+ }
867
+ const locale = this.translationService.getActiveLang() || 'en-US';
868
+ const existing = resolveMultiLanguageString(field.title, locale).trim();
869
+ if (existing) {
870
+ return { id: field.id, title: existing };
871
+ }
872
+ const title = await this.resolveGeographicRegionTitle(field.id);
873
+ return title ? { id: field.id, title } : { id: field.id };
874
+ }
875
+ async resolveGeographicRegionTitle(id) {
876
+ try {
877
+ const row = await this.entityService.withEntity(GEOGRAPHIC_REGION_ENTITY).data().byKey(id);
878
+ const locale = this.translationService.getActiveLang() || 'en-US';
879
+ const raw = get(row, 'title');
880
+ const normalized = resolveMultiLanguageString(raw, locale).trim();
881
+ return normalized || undefined;
882
+ }
883
+ catch {
884
+ return undefined;
885
+ }
886
+ }
887
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXPAddressWidgetService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
888
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXPAddressWidgetService, providedIn: 'root' }); }
889
+ }
890
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXPAddressWidgetService, decorators: [{
891
+ type: Injectable,
892
+ args: [{ providedIn: 'root' }]
893
+ }], ctorParameters: () => [] });
894
+
895
+ class AXPAddressWidgetEditComponent extends AXPValueWidgetComponent {
896
+ constructor() {
897
+ super(...arguments);
898
+ this.addressService = inject(AXPAddressWidgetService);
899
+ /** Collapsible mode: true = panel collapsed (only full address visible), false = expanded (edit button visible) */
900
+ this.collapsibleCollapsed = signal(true, /* @ts-ignore */
901
+ ...(ngDevMode ? [{ debugName: "collapsibleCollapsed" }] : /* istanbul ignore next */ []));
902
+ this.collapsibleHeaderLabel = signal(null, /* @ts-ignore */
903
+ ...(ngDevMode ? [{ debugName: "collapsibleHeaderLabel" }] : /* istanbul ignore next */ []));
904
+ this.collapsibleHeaderAddress = signal('', /* @ts-ignore */
905
+ ...(ngDevMode ? [{ debugName: "collapsibleHeaderAddress" }] : /* istanbul ignore next */ []));
906
+ /** Bumped on parent discard so the nested layout renderer remounts with reverted context. */
907
+ this.layoutRendererGeneration = signal(0, /* @ts-ignore */
908
+ ...(ngDevMode ? [{ debugName: "layoutRendererGeneration" }] : /* istanbul ignore next */ []));
909
+ this.parentContextWasRestored = false;
910
+ this.geographicDefaultsInitialized = false;
911
+ this.suppressContextSync = false;
912
+ /** Blocks ax-collapse from auto-collapsing while a new empty row is opening. */
913
+ this.blockAutoCollapseUntil = 0;
914
+ /** Expand new repeater rows so users can enter values without clicking the header again. */
915
+ this.#expandEmptyAddressEffect = effect(() => {
916
+ if (this.addressMode() !== 'expandable') {
917
+ return;
918
+ }
919
+ if (this.shouldKeepExpandedForEntry(this.valueAsObject())) {
920
+ this.collapsibleCollapsed.set(false);
921
+ this.blockAutoCollapseUntil = Date.now() + 300;
922
+ }
923
+ }, /* @ts-ignore */
924
+ ...(ngDevMode ? [{ debugName: "#expandEmptyAddressEffect" }] : /* istanbul ignore next */ []));
925
+ this.#resetNestedFormOnDiscard = effect(() => {
926
+ if (this.addressMode() !== 'expandable') {
927
+ return;
928
+ }
929
+ const isRestored = this.contextService.changeEvent().state === 'restored';
930
+ if (isRestored && !this.parentContextWasRestored) {
931
+ this.layoutRendererGeneration.update((generation) => generation + 1);
932
+ }
933
+ this.parentContextWasRestored = isRestored;
934
+ }, /* @ts-ignore */
935
+ ...(ngDevMode ? [{ debugName: "#resetNestedFormOnDiscard" }] : /* istanbul ignore next */ []));
936
+ this.#collapsibleHeaderEffect = effect(() => {
937
+ const value = this.valueAsObject();
938
+ this.formattedAddress();
939
+ const placeholder = this.placeholder();
940
+ void this.addressService
941
+ .resolveCollapsibleHeader(value, { placeholder })
942
+ .then((header) => {
943
+ this.collapsibleHeaderLabel.set(header.labelText);
944
+ this.collapsibleHeaderAddress.set(header.addressText);
945
+ });
946
+ }, /* @ts-ignore */
947
+ ...(ngDevMode ? [{ debugName: "#collapsibleHeaderEffect" }] : /* istanbul ignore next */ []));
948
+ this.#applyGeographicDefaultsEffect = effect(() => {
949
+ if (!this.useGeographicDefaults() || this.geographicDefaultsInitialized) {
950
+ return;
951
+ }
952
+ const value = this.valueAsObject();
953
+ void this.addressService
954
+ .applyGeographicDefaultsIfNeeded(value, { enabled: true })
955
+ .then(({ value: merged, applied }) => {
956
+ this.geographicDefaultsInitialized = true;
957
+ if (!applied) {
958
+ return;
959
+ }
960
+ const normalized = this.addressService.normalizeAddressData(merged);
961
+ normalized.full = this.addressService.formatAddress(normalized);
962
+ this.commitAddressValue(normalized);
963
+ });
964
+ }, /* @ts-ignore */
965
+ ...(ngDevMode ? [{ debugName: "#applyGeographicDefaultsEffect" }] : /* istanbul ignore next */ []));
966
+ this.addressMode = computed(() => extractValue(this.options()['mode']) || 'simple', /* @ts-ignore */
967
+ ...(ngDevMode ? [{ debugName: "addressMode" }] : /* istanbul ignore next */ []));
968
+ this.placeholder = computed(() => this.options()['placeholder'] || 'Enter address...', /* @ts-ignore */
969
+ ...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
970
+ this.labelEntity = computed(() => this.options()['labelEntity'], /* @ts-ignore */
971
+ ...(ngDevMode ? [{ debugName: "labelEntity" }] : /* istanbul ignore next */ []));
972
+ this.useGeographicDefaults = computed(() => this.options()['useGeographicDefaults'] ?? true, /* @ts-ignore */
973
+ ...(ngDevMode ? [{ debugName: "useGeographicDefaults" }] : /* istanbul ignore next */ []));
974
+ this.disabled = computed(() => this.options()['disabled'] ?? false, /* @ts-ignore */
975
+ ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
976
+ this.hasLabel = computed(() => this.options()['hasLabel'] ?? false, /* @ts-ignore */
977
+ ...(ngDevMode ? [{ debugName: "hasLabel" }] : /* istanbul ignore next */ []));
978
+ this.hasMap = computed(() => this.options()['hasMap'] ?? true, /* @ts-ignore */
979
+ ...(ngDevMode ? [{ debugName: "hasMap" }] : /* istanbul ignore next */ []));
980
+ this.format = computed(() => {
981
+ if (this.hasLabel() ||
982
+ this.addressMode() === 'popup' ||
983
+ this.addressMode() === 'expandable') {
984
+ return 'object';
985
+ }
986
+ return 'string';
987
+ }, /* @ts-ignore */
988
+ ...(ngDevMode ? [{ debugName: "format" }] : /* istanbul ignore next */ []));
989
+ this.valueAsObject = computed(() => this.toObject(this.getValue()), /* @ts-ignore */
990
+ ...(ngDevMode ? [{ debugName: "valueAsObject" }] : /* istanbul ignore next */ []));
991
+ this.formattedAddress = computed(() => {
992
+ const value = this.valueAsObject();
993
+ return value.full || this.addressService.formatAddress(value);
994
+ }, /* @ts-ignore */
995
+ ...(ngDevMode ? [{ debugName: "formattedAddress" }] : /* istanbul ignore next */ []));
996
+ /** Layout node from create().flex().build() for inline renderer (expandable mode). */
997
+ this.addressFormLayout = computed(() => this.addressService.getAddressFormLayout({
998
+ hasLabel: this.hasLabel(),
999
+ labelEntity: this.labelEntity(),
1000
+ hasMap: this.hasMap(),
1001
+ }), /* @ts-ignore */
1002
+ ...(ngDevMode ? [{ debugName: "addressFormLayout" }] : /* istanbul ignore next */ []));
1003
+ /** Context for inline address form (expandable); includes showMap for map toggle. */
1004
+ this.collapsibleFormContext = computed(() => this.addressService.buildAddressFormContext(this.valueAsObject(), {
1005
+ hasMap: this.hasMap(),
1006
+ }), /* @ts-ignore */
1007
+ ...(ngDevMode ? [{ debugName: "collapsibleFormContext" }] : /* istanbul ignore next */ []));
1008
+ }
1009
+ /** Expand new repeater rows so users can enter values without clicking the header again. */
1010
+ #expandEmptyAddressEffect;
1011
+ #resetNestedFormOnDiscard;
1012
+ #collapsibleHeaderEffect;
1013
+ #applyGeographicDefaultsEffect;
1014
+ onCollapsibleFormContextChange(ctx) {
1015
+ if (ctx == null || this.suppressContextSync) {
1016
+ return;
1017
+ }
1018
+ const previous = this.addressService.buildAddressFormContext(this.valueAsObject(), {
1019
+ hasMap: this.hasMap(),
1020
+ });
1021
+ void (async () => {
1022
+ const normalized = this.addressService.normalizeAddressData(this.addressService.applyGeographicCascade(previous, ctx));
1023
+ const enriched = await this.addressService.enrichGeographicLookupTitles(normalized);
1024
+ enriched.full = this.addressService.formatAddress(enriched);
1025
+ if (isEqual(enriched, this.valueAsObject())) {
1026
+ return;
1027
+ }
1028
+ this.commitAddressValue(enriched);
1029
+ })();
1030
+ }
1031
+ onCollapsedChange(collapsed) {
1032
+ if (collapsed &&
1033
+ (Date.now() < this.blockAutoCollapseUntil ||
1034
+ this.shouldKeepExpandedForEntry(this.valueAsObject()))) {
1035
+ return;
1036
+ }
1037
+ this.collapsibleCollapsed.set(collapsed);
1038
+ }
1039
+ async handleValueChange(e) {
1040
+ const { name, value, isUserInteraction } = e;
1041
+ if (isUserInteraction) {
1042
+ const newValues = { ...this.valueAsObject(), [name]: value };
1043
+ this.setValue(this.setFormattedValue(newValues));
1044
+ }
1045
+ }
1046
+ async showDetailsPopup() {
1047
+ const currentValue = this.valueAsObject();
1048
+ const result = await this.addressService.showAddressDetailsPopup(currentValue, {
1049
+ hasMap: this.hasMap(),
1050
+ hasLabel: this.hasLabel(),
1051
+ labelEntity: this.labelEntity(),
1052
+ useGeographicDefaults: this.useGeographicDefaults(),
1053
+ });
1054
+ if (result) {
1055
+ result.full = this.addressService.formatAddress(result);
1056
+ this.setValue(this.setFormattedValue(result));
1057
+ }
1058
+ }
1059
+ generateClasses(element) {
1060
+ const isValue = element === 'value';
1061
+ const hasLabel = this.hasLabel();
1062
+ const baseClass = 'col-span-12';
1063
+ if (!hasLabel) {
1064
+ return baseClass;
1065
+ }
1066
+ return {
1067
+ [baseClass]: true,
1068
+ 'lg:col-span-7': isValue,
1069
+ 'lg:col-span-5': !isValue,
1070
+ };
1071
+ }
1072
+ commitAddressValue(value) {
1073
+ this.suppressContextSync = true;
1074
+ if (this.shouldKeepExpandedForEntry(value)) {
1075
+ this.blockAutoCollapseUntil = Date.now() + 300;
1076
+ this.collapsibleCollapsed.set(false);
1077
+ }
1078
+ this.setValue(this.setFormattedValue(value));
1079
+ window.setTimeout(() => {
1080
+ this.suppressContextSync = false;
1081
+ }, 50);
1082
+ }
1083
+ /** True while the row has no user-entered content (ignores geographic defaults). */
1084
+ shouldKeepExpandedForEntry(value) {
1085
+ return (!value.street1?.trim() &&
1086
+ !value.street2?.trim() &&
1087
+ !value.postalCode?.trim() &&
1088
+ !value.label?.id);
1089
+ }
1090
+ toObject(item) {
1091
+ return this.addressService.normalizeAddressData(item);
1092
+ }
1093
+ setFormattedValue(item) {
1094
+ if (this.format() === 'string') {
1095
+ return item.full;
1096
+ }
1097
+ return item;
1098
+ }
1099
+ get __class() {
1100
+ return 'block flex-1';
1101
+ }
1102
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXPAddressWidgetEditComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
1103
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.8", type: AXPAddressWidgetEditComponent, isStandalone: true, selector: "axp-address-widget-edit", host: { properties: { "class": "this.__class" } }, usesInheritance: true, ngImport: i0, template: `
1104
+ @if (addressMode() === 'simple') {
1105
+ <div class="grid grid-cols-12 gap-4 auto-cols-max">
1106
+ <ax-text-box
1107
+ [ngModel]="valueAsObject().full"
1108
+ (onValueChanged)="handleValueChange($event)"
1109
+ type="text"
1110
+ name="full"
1111
+ [placeholder]="placeholder()"
1112
+ [ngClass]="generateClasses('value')"
1113
+ [disabled]="disabled()"
1114
+ >
1115
+ @for (validation of validationRules(); track $index) {
1116
+ <ax-validation-rule
1117
+ [rule]="validation.rule"
1118
+ [message]="$safeNavigationMigration(validation.options?.message)"
1119
+ [options]="validation.options"
1120
+ [disabled]="validation.disabled === true"></ax-validation-rule>
1121
+ }
1122
+ </ax-text-box>
1123
+ </div>
1124
+ } @else if (addressMode() === 'expandable') {
1125
+ <div class="w-full">
1126
+ <ax-accordion-group>
1127
+ <ax-accordion-item
1128
+ [headerTemplate]="collapseHeaderTemplate"
1129
+ [isCollapsed]="collapsibleCollapsed()"
1130
+ (isCollapsedChange)="onCollapsedChange($event)"
1131
+ >
1132
+ <div class="pt-1">
1133
+ @for (formKey of [layoutRendererGeneration()]; track formKey) {
1134
+ <axp-layout-renderer
1135
+ [layout]="addressFormLayout()"
1136
+ [context]="collapsibleFormContext()"
1137
+ (contextChange)="onCollapsibleFormContextChange($event)"
1138
+ />
1139
+ }
1140
+ </div>
1141
+ </ax-accordion-item>
1142
+ </ax-accordion-group>
1143
+ </div>
1144
+
1145
+ <ng-template #collapseHeaderTemplate>
1146
+ <div class="ax-accordion-header-container">
1147
+ <div class="ax-accordion-header-start">
1148
+ <span
1149
+ class="ax-accordion-header-icon fa-light fa-map-marker-alt"
1150
+ ></span>
1151
+ <span>
1152
+ @if (collapsibleHeaderLabel()) {
1153
+ <span class="font-semibold">{{
1154
+ collapsibleHeaderLabel()
1155
+ }}</span>
1156
+ @if (collapsibleHeaderAddress()) {
1157
+ <span> · {{ collapsibleHeaderAddress() }}</span>
1158
+ }
1159
+ } @else {
1160
+ {{ collapsibleHeaderAddress() }}
1161
+ }
1162
+ </span>
1163
+ </div>
1164
+ <div class="ax-accordion-header-end">
1165
+ <span
1166
+ class="ax-icon ax-icon-chevron-left ax-accordion-arrow"
1167
+ [class]="collapsibleCollapsed() ? '-rotation-90' : 'rotation-90'"
1168
+ ></span>
1169
+ </div>
1170
+ </div>
1171
+ </ng-template>
1172
+ } @else {
1173
+ <div class="grid grid-cols-12 gap-4 auto-cols-max">
1174
+ <div class="flex items-center gap-2 col-span-12">
1175
+ <ax-text-box
1176
+ [ngModel]="formattedAddress()"
1177
+ type="text"
1178
+ [readonly]="true"
1179
+ [placeholder]="placeholder()"
1180
+ class="flex-1"
1181
+ [disabled]="disabled()"
1182
+ >
1183
+ <ax-prefix>
1184
+ <ax-icon icon="fa-light fa-map-marker-alt" />
1185
+ </ax-prefix>
1186
+ <ax-suffix>
1187
+ <ax-button
1188
+ look="flat"
1189
+ size="sm"
1190
+ [disabled]="disabled()"
1191
+ (onClick)="showDetailsPopup()"
1192
+ >
1193
+ <ax-icon icon="fa-light fa-cog" />
1194
+ </ax-button>
1195
+ </ax-suffix>
1196
+ </ax-text-box>
1197
+ </div>
1198
+ </div>
1199
+ }
1200
+ `, isInline: true, dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: AXFormModule }, { kind: "directive", type: i3.AXValidationRuleDirective, selector: "ax-validation-rule", inputs: ["rule", "options", "message", "disabled"] }, { kind: "ngmodule", type: AXDecoratorModule }, { kind: "component", type: i4.AXDecoratorIconComponent, selector: "ax-icon", inputs: ["icon"] }, { kind: "component", type: i4.AXDecoratorGenericComponent, selector: "ax-footer, ax-header, ax-content, ax-divider, ax-form-hint, ax-prefix, ax-suffix, ax-text, ax-title, ax-subtitle, ax-placeholder, ax-overlay" }, { kind: "ngmodule", type: AXTextBoxModule }, { kind: "component", type: i5.AXTextBoxComponent, selector: "ax-text-box", inputs: ["disabled", "tabIndex", "readonly", "value", "state", "name", "id", "placeholder", "maxLength", "allowNull", "type", "autoComplete", "look", "maskPattern", "customTokens", "class"], outputs: ["onBlur", "onFocus", "valueChange", "stateChange", "onValueChanged", "readonlyChange", "disabledChange", "onKeyDown", "onKeyUp", "onKeyPress", "onMaskChanged"] }, { kind: "ngmodule", type: AXValidationModule }, { kind: "ngmodule", type: AXTranslationModule }, { kind: "ngmodule", type: AXButtonModule }, { kind: "component", type: i6.AXButtonComponent, selector: "ax-button", inputs: ["disabled", "tabIndex", "color", "look", "text", "toggleable", "selected", "iconOnly", "type", "loadingText"], outputs: ["onBlur", "onFocus", "onClick", "selectedChange", "toggleableChange", "lookChange", "colorChange", "disabledChange", "loadingTextChange"] }, { kind: "ngmodule", type: AXAccordionModule }, { kind: "component", type: i7.AXAccordionItemComponent, selector: "ax-accordion-item", inputs: ["isCollapsed", "icon", "textdecoration", "caption", "isLoading", "headerTemplate", "look", "disabled"], outputs: ["isCollapsedChange", "isLoadingChange", "onClick"] }, { kind: "component", type: i7.AXAccordionGroupComponent, selector: "ax-accordion-group", inputs: ["accordion", "activeIndex", "look", "collapsedOnItemClick"], outputs: ["activeIndexChange"] }, { kind: "component", type: AXPLayoutRendererComponent, selector: "axp-layout-renderer", inputs: ["layout", "context", "look", "mode", "reveal"], outputs: ["contextChange", "contextInitiated", "validityChange", "revealed"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
1201
+ }
1202
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXPAddressWidgetEditComponent, decorators: [{
1203
+ type: Component,
1204
+ args: [{
1205
+ selector: 'axp-address-widget-edit',
1206
+ template: `
1207
+ @if (addressMode() === 'simple') {
1208
+ <div class="grid grid-cols-12 gap-4 auto-cols-max">
1209
+ <ax-text-box
1210
+ [ngModel]="valueAsObject().full"
1211
+ (onValueChanged)="handleValueChange($event)"
1212
+ type="text"
1213
+ name="full"
1214
+ [placeholder]="placeholder()"
1215
+ [ngClass]="generateClasses('value')"
1216
+ [disabled]="disabled()"
1217
+ >
1218
+ @for (validation of validationRules(); track $index) {
1219
+ <ax-validation-rule
1220
+ [rule]="validation.rule"
1221
+ [message]="$safeNavigationMigration(validation.options?.message)"
1222
+ [options]="validation.options"
1223
+ [disabled]="validation.disabled === true"></ax-validation-rule>
1224
+ }
1225
+ </ax-text-box>
1226
+ </div>
1227
+ } @else if (addressMode() === 'expandable') {
1228
+ <div class="w-full">
1229
+ <ax-accordion-group>
1230
+ <ax-accordion-item
1231
+ [headerTemplate]="collapseHeaderTemplate"
1232
+ [isCollapsed]="collapsibleCollapsed()"
1233
+ (isCollapsedChange)="onCollapsedChange($event)"
1234
+ >
1235
+ <div class="pt-1">
1236
+ @for (formKey of [layoutRendererGeneration()]; track formKey) {
1237
+ <axp-layout-renderer
1238
+ [layout]="addressFormLayout()"
1239
+ [context]="collapsibleFormContext()"
1240
+ (contextChange)="onCollapsibleFormContextChange($event)"
1241
+ />
1242
+ }
1243
+ </div>
1244
+ </ax-accordion-item>
1245
+ </ax-accordion-group>
1246
+ </div>
1247
+
1248
+ <ng-template #collapseHeaderTemplate>
1249
+ <div class="ax-accordion-header-container">
1250
+ <div class="ax-accordion-header-start">
1251
+ <span
1252
+ class="ax-accordion-header-icon fa-light fa-map-marker-alt"
1253
+ ></span>
1254
+ <span>
1255
+ @if (collapsibleHeaderLabel()) {
1256
+ <span class="font-semibold">{{
1257
+ collapsibleHeaderLabel()
1258
+ }}</span>
1259
+ @if (collapsibleHeaderAddress()) {
1260
+ <span> · {{ collapsibleHeaderAddress() }}</span>
1261
+ }
1262
+ } @else {
1263
+ {{ collapsibleHeaderAddress() }}
1264
+ }
1265
+ </span>
1266
+ </div>
1267
+ <div class="ax-accordion-header-end">
1268
+ <span
1269
+ class="ax-icon ax-icon-chevron-left ax-accordion-arrow"
1270
+ [class]="collapsibleCollapsed() ? '-rotation-90' : 'rotation-90'"
1271
+ ></span>
1272
+ </div>
1273
+ </div>
1274
+ </ng-template>
1275
+ } @else {
1276
+ <div class="grid grid-cols-12 gap-4 auto-cols-max">
1277
+ <div class="flex items-center gap-2 col-span-12">
1278
+ <ax-text-box
1279
+ [ngModel]="formattedAddress()"
1280
+ type="text"
1281
+ [readonly]="true"
1282
+ [placeholder]="placeholder()"
1283
+ class="flex-1"
1284
+ [disabled]="disabled()"
1285
+ >
1286
+ <ax-prefix>
1287
+ <ax-icon icon="fa-light fa-map-marker-alt" />
1288
+ </ax-prefix>
1289
+ <ax-suffix>
1290
+ <ax-button
1291
+ look="flat"
1292
+ size="sm"
1293
+ [disabled]="disabled()"
1294
+ (onClick)="showDetailsPopup()"
1295
+ >
1296
+ <ax-icon icon="fa-light fa-cog" />
1297
+ </ax-button>
1298
+ </ax-suffix>
1299
+ </ax-text-box>
1300
+ </div>
1301
+ </div>
1302
+ }
1303
+ `,
1304
+ changeDetection: ChangeDetectionStrategy.OnPush,
1305
+ imports: [
1306
+ CommonModule,
1307
+ FormsModule,
1308
+ AXFormModule,
1309
+ AXDecoratorModule,
1310
+ AXTextBoxModule,
1311
+ AXValidationModule,
1312
+ AXTranslationModule,
1313
+ AXButtonModule,
1314
+ AXAccordionModule,
1315
+ AXPLayoutRendererComponent,
1316
+ ],
1317
+ }]
1318
+ }], propDecorators: { __class: [{
1319
+ type: HostBinding,
1320
+ args: ['class']
1321
+ }] } });
1322
+
1323
+ var addressWidgetEdit_component = /*#__PURE__*/Object.freeze({
1324
+ __proto__: null,
1325
+ AXPAddressWidgetEditComponent: AXPAddressWidgetEditComponent
1326
+ });
1327
+
1328
+ class AXPAddressWidgetViewComponent extends AXPValueWidgetComponent {
1329
+ constructor() {
1330
+ super(...arguments);
1331
+ this.addressService = inject(AXPAddressWidgetService);
1332
+ this.hasLabel = computed(() => this.options()['hasLabel'] ?? false, /* @ts-ignore */
1333
+ ...(ngDevMode ? [{ debugName: "hasLabel" }] : /* istanbul ignore next */ []));
1334
+ this.internalValue = computed(() => this.addressService.normalizeAddressData(this.getValue()), /* @ts-ignore */
1335
+ ...(ngDevMode ? [{ debugName: "internalValue" }] : /* istanbul ignore next */ []));
1336
+ this.labelText = computed(() => this.internalValue().label?.title?.trim() ?? '', /* @ts-ignore */
1337
+ ...(ngDevMode ? [{ debugName: "labelText" }] : /* istanbul ignore next */ []));
1338
+ this.formattedAddress = computed(() => {
1339
+ const value = this.internalValue();
1340
+ return value.full || this.addressService.formatAddress(value);
1341
+ }, /* @ts-ignore */
1342
+ ...(ngDevMode ? [{ debugName: "formattedAddress" }] : /* istanbul ignore next */ []));
1343
+ this.hasValue = computed(() => {
1344
+ const rawValue = this.getValue();
1345
+ if (isNull(rawValue))
1346
+ return false;
1347
+ const value = this.addressService.normalizeAddressData(rawValue);
1348
+ return !isEmpty(value.full);
1349
+ }, /* @ts-ignore */
1350
+ ...(ngDevMode ? [{ debugName: "hasValue" }] : /* istanbul ignore next */ []));
1351
+ }
1352
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXPAddressWidgetViewComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
1353
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.8", type: AXPAddressWidgetViewComponent, isStandalone: true, selector: "axp-address-widget-view", usesInheritance: true, ngImport: i0, template: `
1354
+ @if (hasValue()) {
1355
+ <div class="flex gap-2 items-center">
1356
+ <div class="flex gap-2 group items-center justify-center truncate">
1357
+ <span class="truncate">{{ formattedAddress() }}</span>
1358
+ </div>
1359
+ @if (hasLabel() && labelText()) {
1360
+ <div><ax-badge color="primary" [look]="'twotone'" [text]="labelText()"></ax-badge></div>
1361
+ }
1362
+ </div>
1363
+ } @else {
1364
+ <span class="text-muted">---</span>
1365
+ }
1366
+ `, isInline: true, dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "ngmodule", type: AXBadgeModule }, { kind: "component", type: i1$1.AXBadgeComponent, selector: "ax-badge", inputs: ["color", "look", "text"] }, { kind: "ngmodule", type: AXDecoratorModule }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
1367
+ }
1368
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXPAddressWidgetViewComponent, decorators: [{
1369
+ type: Component,
1370
+ args: [{
1371
+ selector: 'axp-address-widget-view',
1372
+ template: `
1373
+ @if (hasValue()) {
1374
+ <div class="flex gap-2 items-center">
1375
+ <div class="flex gap-2 group items-center justify-center truncate">
1376
+ <span class="truncate">{{ formattedAddress() }}</span>
1377
+ </div>
1378
+ @if (hasLabel() && labelText()) {
1379
+ <div><ax-badge color="primary" [look]="'twotone'" [text]="labelText()"></ax-badge></div>
1380
+ }
1381
+ </div>
1382
+ } @else {
1383
+ <span class="text-muted">---</span>
1384
+ }
1385
+ `,
1386
+ changeDetection: ChangeDetectionStrategy.OnPush,
1387
+ imports: [FormsModule, AXBadgeModule, AXDecoratorModule],
1388
+ }]
1389
+ }] });
1390
+
1391
+ var addressWidgetView_component = /*#__PURE__*/Object.freeze({
1392
+ __proto__: null,
1393
+ AXPAddressWidgetViewComponent: AXPAddressWidgetViewComponent
1394
+ });
1395
+
1396
+ class AXPAddressWidgetColumnComponent extends AXPColumnWidgetComponent {
1397
+ constructor() {
1398
+ super(...arguments);
1399
+ this.clipboard = inject(AXPClipBoardService);
1400
+ this.addressService = inject(AXPAddressWidgetService);
1401
+ this.normalizedValue = computed(() => {
1402
+ const raw = this.rawValue;
1403
+ if (!raw)
1404
+ return null;
1405
+ return this.addressService.normalizeAddressData(raw);
1406
+ }, /* @ts-ignore */
1407
+ ...(ngDevMode ? [{ debugName: "normalizedValue" }] : /* istanbul ignore next */ []));
1408
+ this.formattedAddress = computed(() => {
1409
+ const value = this.normalizedValue();
1410
+ if (!value)
1411
+ return '';
1412
+ return value.full || this.addressService.formatAddress(value);
1413
+ }, /* @ts-ignore */
1414
+ ...(ngDevMode ? [{ debugName: "formattedAddress" }] : /* istanbul ignore next */ []));
1415
+ this.hasValue = computed(() => {
1416
+ const value = this.normalizedValue();
1417
+ if (!value)
1418
+ return false;
1419
+ return !isEmpty(value.full);
1420
+ }, /* @ts-ignore */
1421
+ ...(ngDevMode ? [{ debugName: "hasValue" }] : /* istanbul ignore next */ []));
1422
+ }
1423
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXPAddressWidgetColumnComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
1424
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.8", type: AXPAddressWidgetColumnComponent, isStandalone: true, selector: "axp-address-widget-column", inputs: { rawValue: "rawValue", rowData: "rowData" }, usesInheritance: true, ngImport: i0, template: `
1425
+ @if (hasValue()) {
1426
+ <div class="flex justify-start items-center gap-2 group w-fit">
1427
+ <span class="truncate" [title]="formattedAddress()">{{ formattedAddress() }}</span>
1428
+ <i
1429
+ (click)="clipboard.copy('Address', formattedAddress())"
1430
+ class="fa-solid fa-copy text-neutral-400 dark:hover:text-neutral-100 hover:text-neutral-900 group-hover:visible invisible"
1431
+ ></i>
1432
+ </div>
1433
+ } @else {
1434
+ <span class="text-muted">---</span>
1435
+ }
1436
+ `, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
1437
+ }
1438
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXPAddressWidgetColumnComponent, decorators: [{
1439
+ type: Component,
1440
+ args: [{
1441
+ selector: 'axp-address-widget-column',
1442
+ template: `
1443
+ @if (hasValue()) {
1444
+ <div class="flex justify-start items-center gap-2 group w-fit">
1445
+ <span class="truncate" [title]="formattedAddress()">{{ formattedAddress() }}</span>
1446
+ <i
1447
+ (click)="clipboard.copy('Address', formattedAddress())"
1448
+ class="fa-solid fa-copy text-neutral-400 dark:hover:text-neutral-100 hover:text-neutral-900 group-hover:visible invisible"
1449
+ ></i>
1450
+ </div>
1451
+ } @else {
1452
+ <span class="text-muted">---</span>
1453
+ }
1454
+ `,
1455
+ changeDetection: ChangeDetectionStrategy.OnPush,
1456
+ inputs: ['rawValue', 'rowData'],
1457
+ }]
1458
+ }] });
1459
+
1460
+ var addressWidgetColumn_component = /*#__PURE__*/Object.freeze({
1461
+ __proto__: null,
1462
+ AXPAddressWidgetColumnComponent: AXPAddressWidgetColumnComponent
1463
+ });
1464
+
1465
+ //#endregion
1466
+ //#region ---- Location Management Widgets Provider ----
1467
+ const LOCATION_WIDGETS = [AXPAddressWidget];
1468
+ /**
1469
+ * Provider for location-management widgets (Address editor).
1470
+ * The address widget lives here because its service depends on `@acorex-platform/framework-client/layout/entity`,
1471
+ * which would otherwise create a circular dependency with `@acorex-platform/framework-client/layout/widgets`.
1472
+ */
1473
+ class AXMLocationManagementWidgetsProvider {
1474
+ getWidgets() {
1475
+ return LOCATION_WIDGETS;
1476
+ }
1477
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXMLocationManagementWidgetsProvider, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1478
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXMLocationManagementWidgetsProvider }); }
1479
+ }
1480
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXMLocationManagementWidgetsProvider, decorators: [{
1481
+ type: Injectable
1482
+ }] });
1483
+
1484
+ class AXMLocationManagementModule {
1485
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXMLocationManagementModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
1486
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "22.0.8", ngImport: i0, type: AXMLocationManagementModule, imports: [CommonModule,
1487
+ AXPWidgetCoreModule] }); }
1488
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXMLocationManagementModule, providers: [
1489
+ // Provider references (now using tokens)
1490
+ {
1491
+ provide: AXP_PERMISSION_DEFINITION_PROVIDER,
1492
+ useClass: AXMLocationManagementPermissionDefinitionProvider,
1493
+ multi: true,
1494
+ },
1495
+ {
1496
+ provide: AXP_MENU_PROVIDER,
1497
+ useClass: AXMLocationManagementMenuProvider,
1498
+ multi: true,
1499
+ },
1500
+ {
1501
+ provide: AXP_ENTITY_STORAGE_MIDDLEWARE,
1502
+ multi: true,
1503
+ useValue: locationAssignmentLocationHydrateMiddleware,
1504
+ },
1505
+ {
1506
+ provide: AXP_SETTING_DEFINITION_PROVIDER,
1507
+ useClass: AXMSettingProvider,
1508
+ multi: true,
1509
+ },
1510
+ {
1511
+ provide: AXP_SEARCH_PROVIDER,
1512
+ useClass: AXMSearchCommandProvider,
1513
+ multi: true,
1514
+ },
1515
+ {
1516
+ provide: AXP_FEATURE_DEFINITION_PROVIDER,
1517
+ useClass: AXMLocationManagementFeatureDefinitionProvider,
1518
+ multi: true,
1519
+ },
1520
+ {
1521
+ provide: AXP_WIDGET_DEFINITION_PROVIDER,
1522
+ useClass: AXMLocationManagementWidgetsProvider,
1523
+ multi: true,
1524
+ },
1525
+ provideCommandSetups([
1526
+ {
1527
+ key: `${RootConfig.module.name}.${RootConfig.entities.locationAssignment.name}:AssignExistingLocation`,
1528
+ command: () => import('./acorex-platform-module-location-management-client-assign-existing-location-to-party.command-BvuJiRNy.mjs').then((c) => c.AXMLocationAssignmentAssignExistingLocationCommand),
1529
+ },
1530
+ {
1531
+ key: `${RootConfig.module.name}.${RootConfig.entities.locationAssignment.name}:CreateWithNewLocation`,
1532
+ command: () => import('./acorex-platform-module-location-management-client-create-location-with-assignment.command-D1l3h2Op.mjs').then((c) => c.AXMLocationAssignmentCreateWithNewLocationCommand),
1533
+ },
1534
+ ]),
1535
+ ], imports: [CommonModule,
1536
+ AXPWidgetCoreModule] }); }
1537
+ }
1538
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXMLocationManagementModule, decorators: [{
1539
+ type: NgModule,
1540
+ args: [{
1541
+ imports: [
1542
+ CommonModule,
1543
+ AXPWidgetCoreModule,
1544
+ ],
1545
+ exports: [],
1546
+ declarations: [],
1547
+ providers: [
1548
+ // Provider references (now using tokens)
1549
+ {
1550
+ provide: AXP_PERMISSION_DEFINITION_PROVIDER,
1551
+ useClass: AXMLocationManagementPermissionDefinitionProvider,
1552
+ multi: true,
1553
+ },
1554
+ {
1555
+ provide: AXP_MENU_PROVIDER,
1556
+ useClass: AXMLocationManagementMenuProvider,
1557
+ multi: true,
1558
+ },
1559
+ {
1560
+ provide: AXP_ENTITY_STORAGE_MIDDLEWARE,
1561
+ multi: true,
1562
+ useValue: locationAssignmentLocationHydrateMiddleware,
1563
+ },
1564
+ {
1565
+ provide: AXP_SETTING_DEFINITION_PROVIDER,
1566
+ useClass: AXMSettingProvider,
1567
+ multi: true,
1568
+ },
1569
+ {
1570
+ provide: AXP_SEARCH_PROVIDER,
1571
+ useClass: AXMSearchCommandProvider,
1572
+ multi: true,
1573
+ },
1574
+ {
1575
+ provide: AXP_FEATURE_DEFINITION_PROVIDER,
1576
+ useClass: AXMLocationManagementFeatureDefinitionProvider,
1577
+ multi: true,
1578
+ },
1579
+ {
1580
+ provide: AXP_WIDGET_DEFINITION_PROVIDER,
1581
+ useClass: AXMLocationManagementWidgetsProvider,
1582
+ multi: true,
1583
+ },
1584
+ provideCommandSetups([
1585
+ {
1586
+ key: `${RootConfig.module.name}.${RootConfig.entities.locationAssignment.name}:AssignExistingLocation`,
1587
+ command: () => import('./acorex-platform-module-location-management-client-assign-existing-location-to-party.command-BvuJiRNy.mjs').then((c) => c.AXMLocationAssignmentAssignExistingLocationCommand),
1588
+ },
1589
+ {
1590
+ key: `${RootConfig.module.name}.${RootConfig.entities.locationAssignment.name}:CreateWithNewLocation`,
1591
+ command: () => import('./acorex-platform-module-location-management-client-create-location-with-assignment.command-D1l3h2Op.mjs').then((c) => c.AXMLocationAssignmentCreateWithNewLocationCommand),
1592
+ },
1593
+ ]),
1594
+ ]
1595
+ }]
1596
+ }] });
1597
+
1598
+ class AXMLocationManagementService {
1599
+ constructor() {
1600
+ this.entityService = inject(AXPEntityService);
1601
+ this.translationService = inject(AXTranslationService);
1602
+ this.geographicRegionDataAccessor = this.entityService
1603
+ .withEntity(RootConfig.module.name, RootConfig.entities.geographicRegion.name)
1604
+ .data();
1605
+ }
1606
+ async getCountries() {
1607
+ const result = await this.geographicRegionDataAccessor.query({
1608
+ skip: 0,
1609
+ take: 1000,
1610
+ filter: { field: 'type', operator: { type: 'equal' }, value: 'country' },
1611
+ sort: [{ field: 'title', dir: 'asc' }],
1612
+ });
1613
+ return result.items.map((m) => this.toGeoLocation(m));
1614
+ }
1615
+ async getProvinces(countryId) {
1616
+ const result = await this.geographicRegionDataAccessor.query({
1617
+ skip: 0,
1618
+ take: 1000,
1619
+ filter: { field: 'type', operator: { type: 'equal' }, value: 'state' },
1620
+ sort: [{ field: 'title', dir: 'asc' }],
1621
+ });
1622
+ return result.items.map((m) => this.toGeoLocation(m));
1623
+ }
1624
+ async getCities(filter) {
1625
+ const result = await this.geographicRegionDataAccessor.query({
1626
+ skip: 0,
1627
+ take: 1000,
1628
+ filter: { field: 'type', operator: { type: 'equal' }, value: 'city' },
1629
+ sort: [{ field: 'title', dir: 'asc' }],
1630
+ });
1631
+ return result.items.map((m) => this.toGeoLocation(m));
1632
+ }
1633
+ toGeoLocation(row) {
1634
+ const locale = this.translationService.getActiveLang() || 'en-US';
1635
+ const timezone = typeof row.timezone === 'string' ? row.timezone : (row.timezone?.code ?? undefined);
1636
+ return {
1637
+ id: row.id,
1638
+ code: row.code,
1639
+ title: resolveMultiLanguageString(row.title, locale),
1640
+ timezone,
1641
+ };
1642
+ }
1643
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXMLocationManagementService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1644
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXMLocationManagementService, providedIn: 'root' }); }
1645
+ }
1646
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXMLocationManagementService, decorators: [{
1647
+ type: Injectable,
1648
+ args: [{
1649
+ providedIn: 'root',
1650
+ }]
1651
+ }] });
1652
+
1653
+ /**
1654
+ * Generated bundle index. Do not edit.
1655
+ */
1656
+
1657
+ export { AXMLocationManagementMenuProvider as A, AXMLocationManagementModule as a, AXMLocationManagementService as b, AXMSearchCommandProvider as c, AXMSettingProvider as d, render as r };
1658
+ //# sourceMappingURL=acorex-platform-module-location-management-client-acorex-platform-module-location-management-client-CnENeOgY.mjs.map