@aiquants/contact-map 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,267 @@
1
+ import { b as ContactRecordForTree, C as ContactMapDirectoryEntry } from "./tree-types-Dl6iBQze.mjs";
2
+ export { D as DEFAULT_LIST_LAYOUT_SPEC, c as DEFAULT_TREE_LAYOUT_SPEC, R as ResponsiveLayoutSpec, a as ResponsiveThresholds, d as calculateResponsiveThresholds, g as getHysteresisBreakpointState } from "./tree-types-Dl6iBQze.mjs";
3
+ import { e as SearchResultEntry, C as ContactRecord } from "./wire-BxEK32O0.mjs";
4
+ export { d as ContactMapLogger, c as ContactMapOutletContext, b as ContactMapSearchOutletContext, a as ContactMapStreamPhase, f as ContactMapStreamState, F as FieldPerformanceMetric, I as IndexWorkerMetrics, J as JsonSerialized, L as LevenshteinWorkerMetrics, S as SerializedContactStreamRow, g as StreamChunkWire, h as StreamCursor, i as StreamErrorWire, j as StreamLineWire, k as StreamMetadataWire, l as defaultLogger } from "./wire-BxEK32O0.mjs";
5
+ import { z } from "zod";
6
+ declare class IncrementalTreeBuilder<T extends ContactRecordForTree = ContactRecordForTree> {
7
+ private companyMap;
8
+ private processedPersonIds;
9
+ private allDepts;
10
+ private cachedResult;
11
+ appendRecords(newRecords: ReadonlyArray<T>): void;
12
+ getSnapshot(): {
13
+ tree: ContactMapDirectoryEntry[];
14
+ companyMap: Record<string, ContactMapDirectoryEntry>;
15
+ };
16
+ append(newRecords: ReadonlyArray<T>): void;
17
+ build(): ContactMapDirectoryEntry[];
18
+ reset(): void;
19
+ getUniquePersonCount(): number;
20
+ get size(): number;
21
+ }
22
+ declare const buildDirectoryTree: <T extends ContactRecordForTree>(contacts: ReadonlyArray<T>) => {
23
+ tree: ContactMapDirectoryEntry[];
24
+ companyMap: Record<string, ContactMapDirectoryEntry>;
25
+ };
26
+ declare const normalizeString: (value: string | null | undefined) => string | null;
27
+ type ContactEntrySource = SearchResultEntry | ContactRecord | null | undefined;
28
+ declare const extractContactData: (entry: ContactEntrySource) => ContactRecord | null;
29
+ type EmailFieldKey = "custom_email" | "email";
30
+ type PhoneFieldKey = "custom_mobile_phone_number" | "mobile_phone_number" | "company_phone_number";
31
+ type PreferredValueResult<K> = {
32
+ value: string | null;
33
+ fieldKey: K | null;
34
+ };
35
+ declare const getPrimaryEmail: (contact: ContactRecord | null) => PreferredValueResult<EmailFieldKey>;
36
+ declare const getPrimaryPhone: (contact: ContactRecord | null) => PreferredValueResult<PhoneFieldKey>;
37
+ declare const getPhoneDialHref: (value: string | null | undefined) => string | null;
38
+ declare const getEmailLinkHref: (value: string | null | undefined, preferGmail: boolean) => string | null;
39
+ declare const formatDate: (value: string | number | Date | null | undefined) => string;
40
+ declare const formatDateTime: (value: string | number | Date | null | undefined) => string;
41
+ declare const toDisplayValue: (value: string | number | boolean | Date | null | undefined) => string;
42
+ declare const normalizeLabel: (value: string | null | undefined, fallback: string) => string;
43
+ type DepartmentChain = string[];
44
+ type ParserContext = {
45
+ allKnownDepartments: Set<string>;
46
+ };
47
+ type DepartmentParserMode = "full" | "pure_org";
48
+ type DepartmentParseSource = {
49
+ department: string | null;
50
+ title: string | null;
51
+ };
52
+ interface DepartmentParser {
53
+ name: string;
54
+ parse(contact: DepartmentParseSource, context: ParserContext, mode?: DepartmentParserMode): DepartmentChain[] | null;
55
+ }
56
+ declare const splitDepartment: (dept: string, allDepts: Set<string>) => string[];
57
+ declare const extractDepartmentsFromTitle: (title: string, context: ParserContext) => string[];
58
+ declare const StandardDepartmentParser: DepartmentParser;
59
+ declare const TitleBasedDepartmentParser: DepartmentParser;
60
+ declare const normalizeSearchInput: (value: string) => string;
61
+ declare const schemaContactRecord: z.ZodObject<{
62
+ person_id: z.ZodPipeline<z.ZodEffects<z.ZodUnion<[
63
+ z.ZodString,
64
+ z.ZodNumber
65
+ ]>, number, string | number>, z.ZodNumber>;
66
+ person_id_redirect_to: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodUnion<[
67
+ z.ZodString,
68
+ z.ZodNumber
69
+ ]>>>, number | null, string | number | null | undefined>;
70
+ full_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
71
+ full_name_reading: z.ZodOptional<z.ZodNullable<z.ZodString>>;
72
+ company_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
73
+ company_name_reading: z.ZodOptional<z.ZodNullable<z.ZodString>>;
74
+ department: z.ZodOptional<z.ZodNullable<z.ZodString>>;
75
+ title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
76
+ address: z.ZodOptional<z.ZodNullable<z.ZodString>>;
77
+ postal_code: z.ZodOptional<z.ZodNullable<z.ZodString>>;
78
+ email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
79
+ custom_email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
80
+ company_phone_number: z.ZodOptional<z.ZodNullable<z.ZodString>>;
81
+ custom_company_phone_number: z.ZodOptional<z.ZodNullable<z.ZodString>>;
82
+ company_fax_number: z.ZodOptional<z.ZodNullable<z.ZodString>>;
83
+ mobile_phone_number: z.ZodOptional<z.ZodNullable<z.ZodString>>;
84
+ custom_mobile_phone_number: z.ZodOptional<z.ZodNullable<z.ZodString>>;
85
+ url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
86
+ contacted_at: z.ZodOptional<z.ZodNullable<z.ZodUnion<[
87
+ z.ZodDate,
88
+ z.ZodString
89
+ ]>>>;
90
+ contacted_by: z.ZodOptional<z.ZodNullable<z.ZodString>>;
91
+ is_in_eight: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
92
+ is_contact_synced: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
93
+ is_active: z.ZodBoolean;
94
+ is_incomplete: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
95
+ created_at: z.ZodOptional<z.ZodUnion<[
96
+ z.ZodDate,
97
+ z.ZodString
98
+ ]>>;
99
+ created_by: z.ZodOptional<z.ZodString>;
100
+ updated_at: z.ZodOptional<z.ZodUnion<[
101
+ z.ZodDate,
102
+ z.ZodString
103
+ ]>>;
104
+ updated_by: z.ZodOptional<z.ZodString>;
105
+ }, "strip", z.ZodTypeAny, {
106
+ person_id: number;
107
+ person_id_redirect_to: number | null;
108
+ is_active: boolean;
109
+ custom_email?: string | null | undefined;
110
+ email?: string | null | undefined;
111
+ custom_mobile_phone_number?: string | null | undefined;
112
+ mobile_phone_number?: string | null | undefined;
113
+ company_phone_number?: string | null | undefined;
114
+ full_name?: string | null | undefined;
115
+ full_name_reading?: string | null | undefined;
116
+ company_name?: string | null | undefined;
117
+ company_name_reading?: string | null | undefined;
118
+ department?: string | null | undefined;
119
+ title?: string | null | undefined;
120
+ address?: string | null | undefined;
121
+ postal_code?: string | null | undefined;
122
+ custom_company_phone_number?: string | null | undefined;
123
+ company_fax_number?: string | null | undefined;
124
+ url?: string | null | undefined;
125
+ contacted_at?: string | Date | null | undefined;
126
+ contacted_by?: string | null | undefined;
127
+ is_in_eight?: boolean | null | undefined;
128
+ is_contact_synced?: boolean | null | undefined;
129
+ is_incomplete?: boolean | null | undefined;
130
+ created_at?: string | Date | undefined;
131
+ created_by?: string | undefined;
132
+ updated_at?: string | Date | undefined;
133
+ updated_by?: string | undefined;
134
+ }, {
135
+ person_id: string | number;
136
+ is_active: boolean;
137
+ custom_email?: string | null | undefined;
138
+ email?: string | null | undefined;
139
+ custom_mobile_phone_number?: string | null | undefined;
140
+ mobile_phone_number?: string | null | undefined;
141
+ company_phone_number?: string | null | undefined;
142
+ person_id_redirect_to?: string | number | null | undefined;
143
+ full_name?: string | null | undefined;
144
+ full_name_reading?: string | null | undefined;
145
+ company_name?: string | null | undefined;
146
+ company_name_reading?: string | null | undefined;
147
+ department?: string | null | undefined;
148
+ title?: string | null | undefined;
149
+ address?: string | null | undefined;
150
+ postal_code?: string | null | undefined;
151
+ custom_company_phone_number?: string | null | undefined;
152
+ company_fax_number?: string | null | undefined;
153
+ url?: string | null | undefined;
154
+ contacted_at?: string | Date | null | undefined;
155
+ contacted_by?: string | null | undefined;
156
+ is_in_eight?: boolean | null | undefined;
157
+ is_contact_synced?: boolean | null | undefined;
158
+ is_incomplete?: boolean | null | undefined;
159
+ created_at?: string | Date | undefined;
160
+ created_by?: string | undefined;
161
+ updated_at?: string | Date | undefined;
162
+ updated_by?: string | undefined;
163
+ }>;
164
+ declare const schemaContactRecords: z.ZodArray<z.ZodObject<{
165
+ person_id: z.ZodPipeline<z.ZodEffects<z.ZodUnion<[
166
+ z.ZodString,
167
+ z.ZodNumber
168
+ ]>, number, string | number>, z.ZodNumber>;
169
+ person_id_redirect_to: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodUnion<[
170
+ z.ZodString,
171
+ z.ZodNumber
172
+ ]>>>, number | null, string | number | null | undefined>;
173
+ full_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
174
+ full_name_reading: z.ZodOptional<z.ZodNullable<z.ZodString>>;
175
+ company_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
176
+ company_name_reading: z.ZodOptional<z.ZodNullable<z.ZodString>>;
177
+ department: z.ZodOptional<z.ZodNullable<z.ZodString>>;
178
+ title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
179
+ address: z.ZodOptional<z.ZodNullable<z.ZodString>>;
180
+ postal_code: z.ZodOptional<z.ZodNullable<z.ZodString>>;
181
+ email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
182
+ custom_email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
183
+ company_phone_number: z.ZodOptional<z.ZodNullable<z.ZodString>>;
184
+ custom_company_phone_number: z.ZodOptional<z.ZodNullable<z.ZodString>>;
185
+ company_fax_number: z.ZodOptional<z.ZodNullable<z.ZodString>>;
186
+ mobile_phone_number: z.ZodOptional<z.ZodNullable<z.ZodString>>;
187
+ custom_mobile_phone_number: z.ZodOptional<z.ZodNullable<z.ZodString>>;
188
+ url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
189
+ contacted_at: z.ZodOptional<z.ZodNullable<z.ZodUnion<[
190
+ z.ZodDate,
191
+ z.ZodString
192
+ ]>>>;
193
+ contacted_by: z.ZodOptional<z.ZodNullable<z.ZodString>>;
194
+ is_in_eight: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
195
+ is_contact_synced: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
196
+ is_active: z.ZodBoolean;
197
+ is_incomplete: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
198
+ created_at: z.ZodOptional<z.ZodUnion<[
199
+ z.ZodDate,
200
+ z.ZodString
201
+ ]>>;
202
+ created_by: z.ZodOptional<z.ZodString>;
203
+ updated_at: z.ZodOptional<z.ZodUnion<[
204
+ z.ZodDate,
205
+ z.ZodString
206
+ ]>>;
207
+ updated_by: z.ZodOptional<z.ZodString>;
208
+ }, "strip", z.ZodTypeAny, {
209
+ person_id: number;
210
+ person_id_redirect_to: number | null;
211
+ is_active: boolean;
212
+ custom_email?: string | null | undefined;
213
+ email?: string | null | undefined;
214
+ custom_mobile_phone_number?: string | null | undefined;
215
+ mobile_phone_number?: string | null | undefined;
216
+ company_phone_number?: string | null | undefined;
217
+ full_name?: string | null | undefined;
218
+ full_name_reading?: string | null | undefined;
219
+ company_name?: string | null | undefined;
220
+ company_name_reading?: string | null | undefined;
221
+ department?: string | null | undefined;
222
+ title?: string | null | undefined;
223
+ address?: string | null | undefined;
224
+ postal_code?: string | null | undefined;
225
+ custom_company_phone_number?: string | null | undefined;
226
+ company_fax_number?: string | null | undefined;
227
+ url?: string | null | undefined;
228
+ contacted_at?: string | Date | null | undefined;
229
+ contacted_by?: string | null | undefined;
230
+ is_in_eight?: boolean | null | undefined;
231
+ is_contact_synced?: boolean | null | undefined;
232
+ is_incomplete?: boolean | null | undefined;
233
+ created_at?: string | Date | undefined;
234
+ created_by?: string | undefined;
235
+ updated_at?: string | Date | undefined;
236
+ updated_by?: string | undefined;
237
+ }, {
238
+ person_id: string | number;
239
+ is_active: boolean;
240
+ custom_email?: string | null | undefined;
241
+ email?: string | null | undefined;
242
+ custom_mobile_phone_number?: string | null | undefined;
243
+ mobile_phone_number?: string | null | undefined;
244
+ company_phone_number?: string | null | undefined;
245
+ person_id_redirect_to?: string | number | null | undefined;
246
+ full_name?: string | null | undefined;
247
+ full_name_reading?: string | null | undefined;
248
+ company_name?: string | null | undefined;
249
+ company_name_reading?: string | null | undefined;
250
+ department?: string | null | undefined;
251
+ title?: string | null | undefined;
252
+ address?: string | null | undefined;
253
+ postal_code?: string | null | undefined;
254
+ custom_company_phone_number?: string | null | undefined;
255
+ company_fax_number?: string | null | undefined;
256
+ url?: string | null | undefined;
257
+ contacted_at?: string | Date | null | undefined;
258
+ contacted_by?: string | null | undefined;
259
+ is_in_eight?: boolean | null | undefined;
260
+ is_contact_synced?: boolean | null | undefined;
261
+ is_incomplete?: boolean | null | undefined;
262
+ created_at?: string | Date | undefined;
263
+ created_by?: string | undefined;
264
+ updated_at?: string | Date | undefined;
265
+ updated_by?: string | undefined;
266
+ }>, "many">;
267
+ export { type ContactEntrySource, ContactMapDirectoryEntry, ContactRecord, ContactRecordForTree, type DepartmentChain, type DepartmentParseSource, type DepartmentParser, type DepartmentParserMode, type EmailFieldKey, IncrementalTreeBuilder, type ParserContext, type PhoneFieldKey, type PreferredValueResult, SearchResultEntry, StandardDepartmentParser, TitleBasedDepartmentParser, buildDirectoryTree, extractContactData, extractDepartmentsFromTitle, formatDate, formatDateTime, getEmailLinkHref, getPhoneDialHref, getPrimaryEmail, getPrimaryPhone, normalizeLabel, normalizeSearchInput, normalizeString, schemaContactRecord, schemaContactRecords, splitDepartment, toDisplayValue };
@@ -0,0 +1,267 @@
1
+ import { b as ContactRecordForTree, C as ContactMapDirectoryEntry } from "./tree-types-Dl6iBQze.js";
2
+ export { D as DEFAULT_LIST_LAYOUT_SPEC, c as DEFAULT_TREE_LAYOUT_SPEC, R as ResponsiveLayoutSpec, a as ResponsiveThresholds, d as calculateResponsiveThresholds, g as getHysteresisBreakpointState } from "./tree-types-Dl6iBQze.js";
3
+ import { e as SearchResultEntry, C as ContactRecord } from "./wire-BxEK32O0.js";
4
+ export { d as ContactMapLogger, c as ContactMapOutletContext, b as ContactMapSearchOutletContext, a as ContactMapStreamPhase, f as ContactMapStreamState, F as FieldPerformanceMetric, I as IndexWorkerMetrics, J as JsonSerialized, L as LevenshteinWorkerMetrics, S as SerializedContactStreamRow, g as StreamChunkWire, h as StreamCursor, i as StreamErrorWire, j as StreamLineWire, k as StreamMetadataWire, l as defaultLogger } from "./wire-BxEK32O0.js";
5
+ import { z } from "zod";
6
+ declare class IncrementalTreeBuilder<T extends ContactRecordForTree = ContactRecordForTree> {
7
+ private companyMap;
8
+ private processedPersonIds;
9
+ private allDepts;
10
+ private cachedResult;
11
+ appendRecords(newRecords: ReadonlyArray<T>): void;
12
+ getSnapshot(): {
13
+ tree: ContactMapDirectoryEntry[];
14
+ companyMap: Record<string, ContactMapDirectoryEntry>;
15
+ };
16
+ append(newRecords: ReadonlyArray<T>): void;
17
+ build(): ContactMapDirectoryEntry[];
18
+ reset(): void;
19
+ getUniquePersonCount(): number;
20
+ get size(): number;
21
+ }
22
+ declare const buildDirectoryTree: <T extends ContactRecordForTree>(contacts: ReadonlyArray<T>) => {
23
+ tree: ContactMapDirectoryEntry[];
24
+ companyMap: Record<string, ContactMapDirectoryEntry>;
25
+ };
26
+ declare const normalizeString: (value: string | null | undefined) => string | null;
27
+ type ContactEntrySource = SearchResultEntry | ContactRecord | null | undefined;
28
+ declare const extractContactData: (entry: ContactEntrySource) => ContactRecord | null;
29
+ type EmailFieldKey = "custom_email" | "email";
30
+ type PhoneFieldKey = "custom_mobile_phone_number" | "mobile_phone_number" | "company_phone_number";
31
+ type PreferredValueResult<K> = {
32
+ value: string | null;
33
+ fieldKey: K | null;
34
+ };
35
+ declare const getPrimaryEmail: (contact: ContactRecord | null) => PreferredValueResult<EmailFieldKey>;
36
+ declare const getPrimaryPhone: (contact: ContactRecord | null) => PreferredValueResult<PhoneFieldKey>;
37
+ declare const getPhoneDialHref: (value: string | null | undefined) => string | null;
38
+ declare const getEmailLinkHref: (value: string | null | undefined, preferGmail: boolean) => string | null;
39
+ declare const formatDate: (value: string | number | Date | null | undefined) => string;
40
+ declare const formatDateTime: (value: string | number | Date | null | undefined) => string;
41
+ declare const toDisplayValue: (value: string | number | boolean | Date | null | undefined) => string;
42
+ declare const normalizeLabel: (value: string | null | undefined, fallback: string) => string;
43
+ type DepartmentChain = string[];
44
+ type ParserContext = {
45
+ allKnownDepartments: Set<string>;
46
+ };
47
+ type DepartmentParserMode = "full" | "pure_org";
48
+ type DepartmentParseSource = {
49
+ department: string | null;
50
+ title: string | null;
51
+ };
52
+ interface DepartmentParser {
53
+ name: string;
54
+ parse(contact: DepartmentParseSource, context: ParserContext, mode?: DepartmentParserMode): DepartmentChain[] | null;
55
+ }
56
+ declare const splitDepartment: (dept: string, allDepts: Set<string>) => string[];
57
+ declare const extractDepartmentsFromTitle: (title: string, context: ParserContext) => string[];
58
+ declare const StandardDepartmentParser: DepartmentParser;
59
+ declare const TitleBasedDepartmentParser: DepartmentParser;
60
+ declare const normalizeSearchInput: (value: string) => string;
61
+ declare const schemaContactRecord: z.ZodObject<{
62
+ person_id: z.ZodPipeline<z.ZodEffects<z.ZodUnion<[
63
+ z.ZodString,
64
+ z.ZodNumber
65
+ ]>, number, string | number>, z.ZodNumber>;
66
+ person_id_redirect_to: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodUnion<[
67
+ z.ZodString,
68
+ z.ZodNumber
69
+ ]>>>, number | null, string | number | null | undefined>;
70
+ full_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
71
+ full_name_reading: z.ZodOptional<z.ZodNullable<z.ZodString>>;
72
+ company_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
73
+ company_name_reading: z.ZodOptional<z.ZodNullable<z.ZodString>>;
74
+ department: z.ZodOptional<z.ZodNullable<z.ZodString>>;
75
+ title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
76
+ address: z.ZodOptional<z.ZodNullable<z.ZodString>>;
77
+ postal_code: z.ZodOptional<z.ZodNullable<z.ZodString>>;
78
+ email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
79
+ custom_email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
80
+ company_phone_number: z.ZodOptional<z.ZodNullable<z.ZodString>>;
81
+ custom_company_phone_number: z.ZodOptional<z.ZodNullable<z.ZodString>>;
82
+ company_fax_number: z.ZodOptional<z.ZodNullable<z.ZodString>>;
83
+ mobile_phone_number: z.ZodOptional<z.ZodNullable<z.ZodString>>;
84
+ custom_mobile_phone_number: z.ZodOptional<z.ZodNullable<z.ZodString>>;
85
+ url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
86
+ contacted_at: z.ZodOptional<z.ZodNullable<z.ZodUnion<[
87
+ z.ZodDate,
88
+ z.ZodString
89
+ ]>>>;
90
+ contacted_by: z.ZodOptional<z.ZodNullable<z.ZodString>>;
91
+ is_in_eight: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
92
+ is_contact_synced: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
93
+ is_active: z.ZodBoolean;
94
+ is_incomplete: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
95
+ created_at: z.ZodOptional<z.ZodUnion<[
96
+ z.ZodDate,
97
+ z.ZodString
98
+ ]>>;
99
+ created_by: z.ZodOptional<z.ZodString>;
100
+ updated_at: z.ZodOptional<z.ZodUnion<[
101
+ z.ZodDate,
102
+ z.ZodString
103
+ ]>>;
104
+ updated_by: z.ZodOptional<z.ZodString>;
105
+ }, "strip", z.ZodTypeAny, {
106
+ person_id: number;
107
+ person_id_redirect_to: number | null;
108
+ is_active: boolean;
109
+ custom_email?: string | null | undefined;
110
+ email?: string | null | undefined;
111
+ custom_mobile_phone_number?: string | null | undefined;
112
+ mobile_phone_number?: string | null | undefined;
113
+ company_phone_number?: string | null | undefined;
114
+ full_name?: string | null | undefined;
115
+ full_name_reading?: string | null | undefined;
116
+ company_name?: string | null | undefined;
117
+ company_name_reading?: string | null | undefined;
118
+ department?: string | null | undefined;
119
+ title?: string | null | undefined;
120
+ address?: string | null | undefined;
121
+ postal_code?: string | null | undefined;
122
+ custom_company_phone_number?: string | null | undefined;
123
+ company_fax_number?: string | null | undefined;
124
+ url?: string | null | undefined;
125
+ contacted_at?: string | Date | null | undefined;
126
+ contacted_by?: string | null | undefined;
127
+ is_in_eight?: boolean | null | undefined;
128
+ is_contact_synced?: boolean | null | undefined;
129
+ is_incomplete?: boolean | null | undefined;
130
+ created_at?: string | Date | undefined;
131
+ created_by?: string | undefined;
132
+ updated_at?: string | Date | undefined;
133
+ updated_by?: string | undefined;
134
+ }, {
135
+ person_id: string | number;
136
+ is_active: boolean;
137
+ custom_email?: string | null | undefined;
138
+ email?: string | null | undefined;
139
+ custom_mobile_phone_number?: string | null | undefined;
140
+ mobile_phone_number?: string | null | undefined;
141
+ company_phone_number?: string | null | undefined;
142
+ person_id_redirect_to?: string | number | null | undefined;
143
+ full_name?: string | null | undefined;
144
+ full_name_reading?: string | null | undefined;
145
+ company_name?: string | null | undefined;
146
+ company_name_reading?: string | null | undefined;
147
+ department?: string | null | undefined;
148
+ title?: string | null | undefined;
149
+ address?: string | null | undefined;
150
+ postal_code?: string | null | undefined;
151
+ custom_company_phone_number?: string | null | undefined;
152
+ company_fax_number?: string | null | undefined;
153
+ url?: string | null | undefined;
154
+ contacted_at?: string | Date | null | undefined;
155
+ contacted_by?: string | null | undefined;
156
+ is_in_eight?: boolean | null | undefined;
157
+ is_contact_synced?: boolean | null | undefined;
158
+ is_incomplete?: boolean | null | undefined;
159
+ created_at?: string | Date | undefined;
160
+ created_by?: string | undefined;
161
+ updated_at?: string | Date | undefined;
162
+ updated_by?: string | undefined;
163
+ }>;
164
+ declare const schemaContactRecords: z.ZodArray<z.ZodObject<{
165
+ person_id: z.ZodPipeline<z.ZodEffects<z.ZodUnion<[
166
+ z.ZodString,
167
+ z.ZodNumber
168
+ ]>, number, string | number>, z.ZodNumber>;
169
+ person_id_redirect_to: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodUnion<[
170
+ z.ZodString,
171
+ z.ZodNumber
172
+ ]>>>, number | null, string | number | null | undefined>;
173
+ full_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
174
+ full_name_reading: z.ZodOptional<z.ZodNullable<z.ZodString>>;
175
+ company_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
176
+ company_name_reading: z.ZodOptional<z.ZodNullable<z.ZodString>>;
177
+ department: z.ZodOptional<z.ZodNullable<z.ZodString>>;
178
+ title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
179
+ address: z.ZodOptional<z.ZodNullable<z.ZodString>>;
180
+ postal_code: z.ZodOptional<z.ZodNullable<z.ZodString>>;
181
+ email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
182
+ custom_email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
183
+ company_phone_number: z.ZodOptional<z.ZodNullable<z.ZodString>>;
184
+ custom_company_phone_number: z.ZodOptional<z.ZodNullable<z.ZodString>>;
185
+ company_fax_number: z.ZodOptional<z.ZodNullable<z.ZodString>>;
186
+ mobile_phone_number: z.ZodOptional<z.ZodNullable<z.ZodString>>;
187
+ custom_mobile_phone_number: z.ZodOptional<z.ZodNullable<z.ZodString>>;
188
+ url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
189
+ contacted_at: z.ZodOptional<z.ZodNullable<z.ZodUnion<[
190
+ z.ZodDate,
191
+ z.ZodString
192
+ ]>>>;
193
+ contacted_by: z.ZodOptional<z.ZodNullable<z.ZodString>>;
194
+ is_in_eight: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
195
+ is_contact_synced: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
196
+ is_active: z.ZodBoolean;
197
+ is_incomplete: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
198
+ created_at: z.ZodOptional<z.ZodUnion<[
199
+ z.ZodDate,
200
+ z.ZodString
201
+ ]>>;
202
+ created_by: z.ZodOptional<z.ZodString>;
203
+ updated_at: z.ZodOptional<z.ZodUnion<[
204
+ z.ZodDate,
205
+ z.ZodString
206
+ ]>>;
207
+ updated_by: z.ZodOptional<z.ZodString>;
208
+ }, "strip", z.ZodTypeAny, {
209
+ person_id: number;
210
+ person_id_redirect_to: number | null;
211
+ is_active: boolean;
212
+ custom_email?: string | null | undefined;
213
+ email?: string | null | undefined;
214
+ custom_mobile_phone_number?: string | null | undefined;
215
+ mobile_phone_number?: string | null | undefined;
216
+ company_phone_number?: string | null | undefined;
217
+ full_name?: string | null | undefined;
218
+ full_name_reading?: string | null | undefined;
219
+ company_name?: string | null | undefined;
220
+ company_name_reading?: string | null | undefined;
221
+ department?: string | null | undefined;
222
+ title?: string | null | undefined;
223
+ address?: string | null | undefined;
224
+ postal_code?: string | null | undefined;
225
+ custom_company_phone_number?: string | null | undefined;
226
+ company_fax_number?: string | null | undefined;
227
+ url?: string | null | undefined;
228
+ contacted_at?: string | Date | null | undefined;
229
+ contacted_by?: string | null | undefined;
230
+ is_in_eight?: boolean | null | undefined;
231
+ is_contact_synced?: boolean | null | undefined;
232
+ is_incomplete?: boolean | null | undefined;
233
+ created_at?: string | Date | undefined;
234
+ created_by?: string | undefined;
235
+ updated_at?: string | Date | undefined;
236
+ updated_by?: string | undefined;
237
+ }, {
238
+ person_id: string | number;
239
+ is_active: boolean;
240
+ custom_email?: string | null | undefined;
241
+ email?: string | null | undefined;
242
+ custom_mobile_phone_number?: string | null | undefined;
243
+ mobile_phone_number?: string | null | undefined;
244
+ company_phone_number?: string | null | undefined;
245
+ person_id_redirect_to?: string | number | null | undefined;
246
+ full_name?: string | null | undefined;
247
+ full_name_reading?: string | null | undefined;
248
+ company_name?: string | null | undefined;
249
+ company_name_reading?: string | null | undefined;
250
+ department?: string | null | undefined;
251
+ title?: string | null | undefined;
252
+ address?: string | null | undefined;
253
+ postal_code?: string | null | undefined;
254
+ custom_company_phone_number?: string | null | undefined;
255
+ company_fax_number?: string | null | undefined;
256
+ url?: string | null | undefined;
257
+ contacted_at?: string | Date | null | undefined;
258
+ contacted_by?: string | null | undefined;
259
+ is_in_eight?: boolean | null | undefined;
260
+ is_contact_synced?: boolean | null | undefined;
261
+ is_incomplete?: boolean | null | undefined;
262
+ created_at?: string | Date | undefined;
263
+ created_by?: string | undefined;
264
+ updated_at?: string | Date | undefined;
265
+ updated_by?: string | undefined;
266
+ }>, "many">;
267
+ export { type ContactEntrySource, ContactMapDirectoryEntry, ContactRecord, ContactRecordForTree, type DepartmentChain, type DepartmentParseSource, type DepartmentParser, type DepartmentParserMode, type EmailFieldKey, IncrementalTreeBuilder, type ParserContext, type PhoneFieldKey, type PreferredValueResult, SearchResultEntry, StandardDepartmentParser, TitleBasedDepartmentParser, buildDirectoryTree, extractContactData, extractDepartmentsFromTitle, formatDate, formatDateTime, getEmailLinkHref, getPhoneDialHref, getPrimaryEmail, getPrimaryPhone, normalizeLabel, normalizeSearchInput, normalizeString, schemaContactRecord, schemaContactRecords, splitDepartment, toDisplayValue };
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";var z=Object.defineProperty;var Z=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames;var te=Object.prototype.hasOwnProperty;var ne=(e,t)=>{for(var r in t)z(e,r,{get:t[r],enumerable:!0})},re=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of ee(t))!te.call(e,s)&&s!==r&&z(e,s,{get:()=>t[s],enumerable:!(o=Z(t,s))||o.enumerable});return e};var oe=e=>re(z({},"__esModule",{value:!0}),e);var We={};ne(We,{DEFAULT_LIST_LAYOUT_SPEC:()=>Pe,DEFAULT_TREE_LAYOUT_SPEC:()=>Ce,IncrementalTreeBuilder:()=>L,StandardDepartmentParser:()=>N,TitleBasedDepartmentParser:()=>A,buildDirectoryTree:()=>me,calculateResponsiveThresholds:()=>xe,defaultLogger:()=>ke,extractContactData:()=>fe,extractDepartmentsFromTitle:()=>F,formatDate:()=>De,formatDateTime:()=>X,getEmailLinkHref:()=>be,getHysteresisBreakpointState:()=>Se,getPhoneDialHref:()=>ye,getPrimaryEmail:()=>he,getPrimaryPhone:()=>ge,normalizeLabel:()=>R,normalizeSearchInput:()=>Ee,normalizeString:()=>M,schemaContactRecord:()=>J,schemaContactRecords:()=>Me,splitDepartment:()=>$,toDisplayValue:()=>Te});module.exports=oe(We);var R=(e,t)=>e&&e.trim()||t;var ie={\u672C\u90E8:{rank:10,type:"Organization"},\u30AB\u30F3\u30D1\u30CB\u30FC:{rank:10,type:"Organization"},\u672C\u793E:{rank:10,type:"Location"},\u30D6\u30ED\u30C3\u30AF:{rank:11,type:"Location"},\u652F\u5E97:{rank:12,type:"Location"},\u7814\u7A76\u6240:{rank:15,type:"Location"},\u5DE5\u5834:{rank:15,type:"Location"},\u4E8B\u696D\u90E8:{rank:18,type:"Organization"},\u90E8\u9580:{rank:18,type:"Organization"},\u7D71\u62EC\u90E8:{rank:19,type:"Organization"},\u90E8:{rank:20,type:"Organization"},\u958B\u767A:{rank:20,type:"Organization"},\u30B0\u30EB\u30FC\u30D7:{rank:22,type:"Organization"},\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8:{rank:25,type:"Organization"},\u63A8\u9032:{rank:20,type:"Organization"},\u4E8B\u696D\u6240:{rank:25,type:"Location"},\u55B6\u696D\u6240:{rank:28,type:"Location"},\u5BA4:{rank:30,type:"Organization"},\u8AB2:{rank:30,type:"Organization"},\u30BB\u30F3\u30BF\u30FC:{rank:30,type:"Location"},\u30D3\u30B8\u30CD\u30B9\u30D7\u30ED\u30C7\u30E5\u30FC\u30B9\u30BB\u30F3\u30BF\u30FC:{rank:30,type:"Location"},\u30C1\u30FC\u30E0:{rank:40,type:"Organization"},\u4FC2:{rank:50,type:"Organization"},Department:{rank:20,type:"Organization"},Dept:{rank:20,type:"Organization"},"Dept.":{rank:20,type:"Organization"},Division:{rank:20,type:"Organization"},Div:{rank:20,type:"Organization"},"Div.":{rank:20,type:"Organization"},Section:{rank:30,type:"Organization"},Sect:{rank:30,type:"Organization"},"Sect.":{rank:30,type:"Organization"},Unit:{rank:30,type:"Organization"},Group:{rank:22,type:"Organization"},Team:{rank:40,type:"Organization"},Branch:{rank:12,type:"Location"},Office:{rank:28,type:"Location"},Center:{rank:30,type:"Location"},Centre:{rank:30,type:"Location"},HQ:{rank:10,type:"Organization"},Headquarters:{rank:10,type:"Organization"}},_=e=>{for(let[t,r]of Object.entries(ie))if(e.endsWith(t))return r;return{rank:99,type:"Other"}},v=e=>_(e).rank,ae=["\u30B0\u30EB\u30FC\u30D7","\u30C1\u30FC\u30E0","Group","Team","\u5BA4","\u8AB2","Unit","Area","\u90E8","Department","Dept","Division","Div","\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8","\u63A8\u9032"],E=e=>ae.find(t=>e.endsWith(t)),se=new Set(["&","Quality","Innovation","R&D","Solutions","Development","Laboratory","and","Food","Beverage"]),le=(e,t)=>t>1&&(e.endsWith("\u652F\u5E97")||e.endsWith("\u672C\u90E8")||e.endsWith("\u4E8B\u696D\u6240")||e.endsWith("\u5DE5\u5834")),pe=(e,t)=>{if(!t)return!0;let r=_(e),o=_(t);if(r.rank<o.rank||e.endsWith("\u672C\u90E8")&&t.endsWith("\u672C\u90E8"))return!1;let s=E(e),y=E(t);return!(s&&y&&s!==y)},W=(e,t)=>{if(!e)return[];if(e==="\u517C")return["\u517C"];if(e==="\u517C\u52D9")return["\u517C"];if(e.startsWith("\u517C ")||e.startsWith("\u517C\u3000")){let o=e.slice(1).trim();return["\u517C",...W(o,t)]}if(e.startsWith("\u517C\u52D9 ")||e.startsWith("\u517C\u52D9\u3000")){let o=e.slice(2).trim();return["\u517C",...W(o,t)]}let r="";for(let o=e.length-1;o>0;o--){if(e[o]!==" ")continue;let s=e.slice(0,o);if(!se.has(s)&&t.has(s)){r=s;break}}if(r){let o=r,s=e.slice(r.length),y=/^\s+(and|&)\s+([A-Za-z0-9]+)/i,P=s.match(y);P&&(o=e.slice(0,r.length+P[0].length));let u=e.slice(o.length),n=["Department","Dept","Division","Div","Section","Sect","Unit","Group","Team","Branch","Office","Center","Centre","HQ","Headquarters"];for(let i of n){let g=new RegExp(`^\\s+${i}\\.?(?=$|[\\s,])`,"i"),p=u.match(g);if(p){o=e.slice(0,o.length+p[0].length);break}}let m=e.slice(o.length).trim();return[o,...W(m,t)]}return[e]},$=(e,t)=>{let o=e.replace(/[\s\u3000]+(?:兼務|兼)[\s\u3000]+/g,"\u3000\u517C\u3000").replace(/^(?:兼務|兼)[\s\u3000]+/,"\u517C\u3000").replace(/[\s\u3000]+(?:兼務|兼)$/,"\u3000\u517C").split(/\u3000/),s=[];for(let y of o){let P=y.trim();P&&s.push(...W(P,t))}return s},F=(e,t)=>{let r=[],o=["\u90E8","\u8AB2","\u5BA4","\u672C\u90E8","\u652F\u5E97","\u55B6\u696D\u6240","\u30B0\u30EB\u30FC\u30D7","\u30C1\u30FC\u30E0","\u30BB\u30F3\u30BF\u30FC","\u30AB\u30F3\u30D1\u30CB\u30FC","\u4E8B\u696D\u6240","\u5DE5\u5834","\u7814\u7A76\u6240","\u4FC2","\u90E8\u9580","\u4E8B\u696D\u90E8","\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8","\u63A8\u9032","\u958B\u767A","Department","Dept","Division","Div","Section","Sect","Unit","Group","Team","Branch","Office","Center","Centre","HQ","Headquarters"],s=e.split(/[\s\u3000,()()[\]]+/).filter(Boolean),y=s.length,P=new Set;for(let u=y;u>=1;u--)for(let n=0;n<=y-u;n++){let m=!1;for(let g=n;g<n+u;g++)if(P.has(g)){m=!0;break}if(m)continue;let i=s.slice(n,n+u).join(" ");if(!(i==="\u517C"||i==="\u517C\u52D9"||i==="\u4FC2"||i==="of"||i==="&"||i==="Quality"||i==="Innovation"||i==="R&D"||i==="Solutions"||i==="Development"||i==="Laboratory"||i==="and"||i==="Food"||i==="Beverage")&&t.allKnownDepartments.has(i)){r.push({name:i,index:n});for(let g=n;g<n+u;g++)P.add(g)}}for(let u=0;u<y;u++){if(P.has(u))continue;let n=s[u];for(n.endsWith("\u9577")&&n.length>1?n=n.slice(0,-1):n.endsWith("\u7D71\u62EC")&&n.length>2&&(n=n.slice(0,-2));;){let p=!1;if(n.startsWith("\u62C5\u5F53")&&n.length>2||n.startsWith("\u5C02\u4EFB")&&n.length>2||n.startsWith("\u517C\u52D9")&&n.length>2?(n=n.slice(2),p=!0):(n.startsWith("\u526F")||n.startsWith("\u517C"))&&n.length>1&&(n=n.slice(1),p=!0),!p)break}if(n.includes("\u30FB")&&!t.allKnownDepartments.has(n)){let p=n.split("\u30FB"),b=p[p.length-1],T=o.find(k=>b.endsWith(k));if(T){for(let k of p){let C=k;o.some(a=>C.endsWith(a))||(C=C+T);let x=n!=="\u517C"&&n!=="\u4FC2"&&n!=="of"&&n!=="&"&&n!=="Quality"&&n!=="Innovation"&&n!=="R&D"&&n!=="Solutions"&&n!=="Development"&&n!=="Laboratory"&&n!=="and"&&n!=="Food"&&n!=="Beverage"&&t.allKnownDepartments.has(C),d=o.some(a=>C.endsWith(a)),l=o.includes(C);(x||d&&!l)&&r.push({name:C,index:u})}continue}}let m=n!=="\u517C"&&n!=="\u4FC2"&&n!=="of"&&n!=="&"&&n!=="Quality"&&n!=="Innovation"&&n!=="R&D"&&n!=="Solutions"&&n!=="Development"&&n!=="Laboratory"&&n!=="and"&&n!=="Food"&&n!=="Beverage"&&t.allKnownDepartments.has(n),i=o.some(p=>n.endsWith(p)),g=o.includes(n);(m||i&&!g)&&r.push({name:n,index:u})}return r.sort((u,n)=>u.index-n.index),r.map(u=>u.name)},K=(e,t)=>{let r=0;for(let o of t)r<e.length&&o===e[r]&&r++;return r===e.length},N={name:"Standard",parse:(e,t,r="full")=>{let o=R(e.department,"");if(!o)return null;let s=$(o,t.allKnownDepartments),y=new Map;for(let n of s)y.set(n,(y.get(n)||0)+1);let P=n=>{let m=[],i=[];for(let g=0;g<n.length;g++){let p=n[g];if(p==="\u517C"){i.length>0&&(m.push(i),i=[]);continue}let b=_(p),T=b.rank,k=y.get(p)||0,C=le(p,k);if(i.length===0)i.push(p);else{let x=i[i.length-1],d=_(x),l=d.rank;if(i.includes(p))m.push(i),i=[p];else{let a=!1;if(C)a=!0;else if(d.type===b.type){let h=E(x),f=E(p);h&&f&&h!==f||x.endsWith("\u672C\u90E8")&&p.endsWith("\u672C\u90E8")||x.endsWith("\u90E8\u9580")&&p.endsWith("\u4E8B\u696D\u90E8")||x.endsWith("\u4E8B\u696D\u90E8")&&p.endsWith("\u90E8\u9580")||x.endsWith("\u90E8\u9580")&&p.endsWith("\u672C\u90E8")||d.type==="Other"&&b.type==="Other"?a=!0:a=l<T}else a=T>=10,a&&d.type==="Location"&&b.type==="Organization"&&l>=T&&n.slice(g+1).includes(x)&&(a=!1);a?i.push(p):(m.push(i),i=[p])}}if(C){let x=g+1<n.length?n[g+1]:void 0;pe(p,x)&&i.length>0&&(m.push(i),i=[])}}return i.length>0&&m.push(i),m},u=[];if(r==="full"&&u.push(...P(s)),r==="pure_org"){let n=s.filter(m=>_(m).type!=="Location");n.length>0&&u.push(...P(n))}if(e.title){let m=/[^\x20-\x7E]/.test(e.title)?/[\s\u3000]*(?:兼務|兼)[\s\u3000]*/:/[,;]|(?:兼務|兼)/,i=e.title.split(m).filter(Boolean),g=[],p=(d,l)=>{let a=v(d),h=v(l),f=a<h;if(!f){let D=E(d),S=E(l);if(D&&S&&D!==S)f=!0;else if(d.endsWith("\u672C\u90E8")&&l.endsWith("\u672C\u90E8"))f=!0;else if(d.endsWith("\u90E8\u9580")&&l.endsWith("\u4E8B\u696D\u90E8")||d.endsWith("\u4E8B\u696D\u90E8")&&l.endsWith("\u90E8\u9580"))f=!0;else if(d.endsWith("\u90E8\u9580")&&l.endsWith("\u672C\u90E8"))f=!0;else{let O=_(d),Y=_(l);O.type==="Other"&&Y.type==="Other"&&(f=!0)}}return f};for(let d of i){let l=F(d,t);if(l.length===0)continue;let a=[];for(let h of l)if(a.length===0)a.push(h);else{let f=a[a.length-1];if(p(f,h))a.push(h);else{g.push([...a]);let D=!1;for(let S=a.length-2;S>=0;S--){let O=a[S];if(p(O,h)){a=[...a.slice(0,S+1),h],D=!0;break}}D||(a=[h])}}a.length>0&&g.push(a)}let b=[...u],T=d=>i.some(l=>l.includes(d)&&l.length>d.length);for(let d of g){let l=!1;for(let a of u){let h=a.findIndex(f=>d.includes(f));if(h!==-1){let f=a[h],D=d.indexOf(f);if(h>0&&D===0){let S=a.slice(0,h);b.push([...S,...d]),l=!0}else if(D>0&&h===0){let S=d.slice(0,D);b.push([...S,...a]),b.push(d),l=!0}else d.length>a.length-h,l=!0}if(!l){let f=a[a.length-1],D=d[0];p(f,D)&&(b.push([...a,...d]),l=!0)}}l||b.push(d)}let k=[],C=[],x=new Set;for(let d of b){let l=d.join("|");x.has(l)||(x.add(l),C.push(d))}for(let d=0;d<C.length;d++){let l=C[d],a=!1;for(let h=0;h<C.length;h++){if(d===h)continue;let f=C[h];if(f.length>l.length&&f.slice(0,l.length).join("|")===l.join("|")){let D=l[l.length-1];if(!T(D)){a=!0;break}}if(f.length>l.length&&K(l,f)){let D=l[l.length-1];if(!T(D)){a=!0;break}}if(l.length===1&&f.length>0){let D=l[0],S=f[f.length-1];if(D!==S&&S.endsWith(D)){a=!0;break}}}a||k.push(l)}return k.length>0?k:null}if(u.length>0){let n=[];for(let m=0;m<u.length;m++){let i=u[m],g=!1;for(let p=0;p<u.length;p++){if(m===p)continue;let b=u[p];if(b.length>i.length&&K(i,b)){g=!0;break}}g||n.push(i)}return n.length>0?n:null}return null}},A={name:"TitleBased",parse:(e,t,r="full")=>{let o=e.title;if(!o)return null;let s=F(o,t);return s.length>0?[s]:null}};var ce="\u672A\u5206\u985E",U="\u540D\u524D\u672A\u8A2D\u5B9A",ue=[N,A],de=e=>{let t=R(e.full_name,U),r=R(e.title,"");return r.length>0?`${t} (${r})`:t},j=(e,t)=>`${e} (${t.toLocaleString()})`,B=e=>e.sort((t,r)=>t.label.localeCompare(r.label,"ja")),I=(e,t,r)=>{let o=e.get(t);if(o)return o;let s=r();return e.set(t,s),s},w=e=>encodeURIComponent(e.replace(/\//g,"\uFF0F")),H=e=>e.sort((t,r)=>{let o=!!(t.contact.title&&t.contact.title.trim().length>0),s=!!(r.contact.title&&r.contact.title.trim().length>0);return o&&!s?-1:!o&&s?1:t.label.localeCompare(r.label,"ja")}),Q=e=>{let t=R(e.contact.full_name,U),r=R(e.contact.title,"");return{name:r?`${t} (${r})`:t,type:"file",absolutePath:e.path,relativePath:e.segment,personId:e.contact.person_id,title:e.contact.title||void 0,isPrimary:e.isPrimary}},q=e=>{let t=B(Array.from(e.children.values())).map(q),r=H([...e.persons]).map(Q);return{name:j(e.label,e.personCount),type:"directory",absolutePath:e.path,relativePath:e.segment,children:[...r,...t]}},L=class{constructor(){this.companyMap=new Map;this.processedPersonIds=new Set;this.allDepts=new Set;this.cachedResult=null}appendRecords(t){if(!t||t.length===0)return;let r="full",o=!1;for(let s of t)if(!this.processedPersonIds.has(s.person_id)&&s.department){let y=s.department.split(/\u3000/);for(let P of y){let u=P.trim();if(!u||u==="\u517C"||u==="\u4FC2")continue;if(/[^\x20-\x7E]/.test(u)){let m=u.split(" ").filter(i=>i.length>0&&i!=="\u517C"&&i!=="\u4FC2");for(let i of m)this.allDepts.add(i)}else this.allDepts.add(u)}}for(let s of t){let y=s.person_id;if(!Number.isFinite(y)||this.processedPersonIds.has(y))continue;this.processedPersonIds.add(y),o=!0;let P=R(s.company_name,ce),u=de(s),n=`company:${w(P)}`,m=I(this.companyMap,n,()=>({label:P,segment:n,path:`/${n}`,departments:new Map,persons:[],personCount:0})),i=[],g={allKnownDepartments:this.allDepts};for(let p of ue){let b=p.parse(s,g,r);if(b&&b.length>0){i=b;break}}i.length===0&&i.push([]);for(let p=0;p<i.length;p++){let b=i[p];if(b.length===0){let l=`person:${y}`,a=`${m.path}/${l}`;m.persons.some(f=>f.contact.person_id===y)||m.persons.push({contact:s,label:u,path:a,segment:l,isPrimary:!0});continue}let T=null,k=m.path;if(b.length>0){let l=b[0],a=`department:${w(l)}`;T=I(m.departments,a,()=>({label:l,segment:a,path:`${k}/${a}`,children:new Map,persons:[],personCount:0})),k=T.path,T.personCount+=1;for(let h=1;h<b.length;h++){let f=b[h],D=`department:${w(f)}`;if(!T)throw new Error("Unexpected null currentDepartmentNode");T=I(T.children,D,()=>({label:f,segment:D,path:`${k}/${D}`,children:new Map,persons:[],personCount:0})),k=T.path,T.personCount+=1}}else continue;let C=`person:${y}`,x=`${T.path}/${C}`;T.persons.some(l=>l.contact.person_id===y)||T.persons.push({contact:s,label:u,path:x,segment:C,isPrimary:p===0})}m.personCount+=1}o&&(this.cachedResult=null)}getSnapshot(){if(this.cachedResult)return this.cachedResult;let t={},r=B(Array.from(this.companyMap.values())).map(o=>{let s=B(Array.from(o.departments.values())).map(q),y=H([...o.persons]).map(Q),P={name:j(o.label,o.personCount),type:"directory",absolutePath:o.path,relativePath:o.segment,children:[...y,...s]};return t[o.label]=P,P});return this.cachedResult={tree:r,companyMap:t},this.cachedResult}append(t){this.appendRecords(t)}build(){return this.getSnapshot().tree}reset(){this.companyMap.clear(),this.processedPersonIds.clear(),this.allDepts.clear(),this.cachedResult=null}getUniquePersonCount(){return this.processedPersonIds.size}get size(){return this.processedPersonIds.size}},me=e=>{let t=new L;return t.appendRecords(e),t.getSnapshot()};var M=e=>{if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null},fe=e=>!e||typeof e!="object"?null:"item"in e?e.item??null:"person_id"in e?e:null,V=(e,t)=>{if(!e)return{value:null,fieldKey:null};for(let r of t){let o=M(e[r]);if(o)return{value:o,fieldKey:r}}return{value:null,fieldKey:null}},he=e=>V(e,["custom_email","email"]),ge=e=>V(e,["custom_mobile_phone_number","mobile_phone_number","company_phone_number"]),ye=e=>{let t=M(e);if(!t)return null;let r=t.replace(/[^0-9+#*]/g,"");return r.length===0?null:`tel:${r}`},be=(e,t)=>{let r=M(e);return r?t?`https://mail.google.com/mail/?view=cm&fs=1&to=${encodeURIComponent(r)}`:`mailto:${encodeURIComponent(r)}`:null},De=e=>{if(!e)return"-";let t=typeof e=="string"||typeof e=="number"?new Date(e):e;return!(t instanceof Date)||Number.isNaN(t.getTime())?typeof e=="string"?e:"-":t.toISOString().split("T")[0]},X=e=>{if(!e)return"-";let t=typeof e=="string"||typeof e=="number"?new Date(e):e;return!(t instanceof Date)||Number.isNaN(t.getTime())?typeof e=="string"?e:"-":t.toISOString()},Te=e=>e==null?"-":typeof e=="string"?M(e)??"-":typeof e=="number"?Number.isFinite(e)?String(e):"-":e instanceof Date?X(e):String(e);var Pe={listPanelMinWidth:320,detailPanelMinWidth:260,handleThickness:10,listPaddingAndBorder:0,detailPaddingAndBorder:0,scrollbarSafetyBuffer:20,hysteresisSafetyMargin:35},Ce={listPanelMinWidth:280,detailPanelMinWidth:260,handleThickness:10,listPaddingAndBorder:0,detailPaddingAndBorder:0,scrollbarSafetyBuffer:20,hysteresisSafetyMargin:35};function xe(e){let t=e.listPanelMinWidth+e.detailPanelMinWidth+e.handleThickness+e.listPaddingAndBorder+e.detailPaddingAndBorder,r=t+e.scrollbarSafetyBuffer,o=r+e.hysteresisSafetyMargin,s=o-r;return{physicalMinWidth:t,collapseThreshold:r,expandThreshold:o,hysteresisWidth:s}}function Se(e,t,r){return e<=0||!Number.isFinite(e)?!1:t?e>=r.collapseThreshold:e>=r.expandThreshold}var ke={info:(e,...t)=>console.info(`[contact-map] ${e}`,...t),warn:(e,...t)=>console.warn(`[contact-map] ${e}`,...t),error:(e,...t)=>console.error(`[contact-map] ${e}`,...t)};var G=require("@aiquants/select-box"),_e=/[\u200B\uFEFF]/g,Re=/^[\s\u3000\u00A0]+|[\s\u3000\u00A0]+$/g,Ee=e=>{let t=e.replace(_e,"").replace(Re,"");return(0,G.normalizeText)(t,{convertWidth:!0,convertKana:!0,convertCase:!0,convertRomaji:!0})};var c=require("zod"),J=c.z.object({person_id:c.z.union([c.z.string(),c.z.number()]).transform(e=>{if(typeof e=="number")return e;let t=e.trim();return parseInt(t,10)}).pipe(c.z.number()),person_id_redirect_to:c.z.union([c.z.string(),c.z.number()]).nullable().optional().transform(e=>{if(e==null)return null;if(typeof e=="number")return e;let t=e.trim();if(t.length===0)return null;let r=parseInt(t,10);return Number.isNaN(r)?null:r}),full_name:c.z.string().nullable().optional(),full_name_reading:c.z.string().nullable().optional(),company_name:c.z.string().nullable().optional(),company_name_reading:c.z.string().nullable().optional(),department:c.z.string().nullable().optional(),title:c.z.string().nullable().optional(),address:c.z.string().nullable().optional(),postal_code:c.z.string().nullable().optional(),email:c.z.string().nullable().optional(),custom_email:c.z.string().nullable().optional(),company_phone_number:c.z.string().nullable().optional(),custom_company_phone_number:c.z.string().nullable().optional(),company_fax_number:c.z.string().nullable().optional(),mobile_phone_number:c.z.string().nullable().optional(),custom_mobile_phone_number:c.z.string().nullable().optional(),url:c.z.string().nullable().optional(),contacted_at:c.z.union([c.z.date(),c.z.string()]).nullable().optional(),contacted_by:c.z.string().nullable().optional(),is_in_eight:c.z.boolean().nullable().optional(),is_contact_synced:c.z.boolean().nullable().optional(),is_active:c.z.boolean(),is_incomplete:c.z.boolean().nullable().optional(),created_at:c.z.union([c.z.date(),c.z.string()]).optional(),created_by:c.z.string().optional(),updated_at:c.z.union([c.z.date(),c.z.string()]).optional(),updated_by:c.z.string().optional()}),Me=c.z.array(J);0&&(module.exports={DEFAULT_LIST_LAYOUT_SPEC,DEFAULT_TREE_LAYOUT_SPEC,IncrementalTreeBuilder,StandardDepartmentParser,TitleBasedDepartmentParser,buildDirectoryTree,calculateResponsiveThresholds,defaultLogger,extractContactData,extractDepartmentsFromTitle,formatDate,formatDateTime,getEmailLinkHref,getHysteresisBreakpointState,getPhoneDialHref,getPrimaryEmail,getPrimaryPhone,normalizeLabel,normalizeSearchInput,normalizeString,schemaContactRecord,schemaContactRecords,splitDepartment,toDisplayValue});
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ var R=(e,t)=>e&&e.trim()||t;var V={\u672C\u90E8:{rank:10,type:"Organization"},\u30AB\u30F3\u30D1\u30CB\u30FC:{rank:10,type:"Organization"},\u672C\u793E:{rank:10,type:"Location"},\u30D6\u30ED\u30C3\u30AF:{rank:11,type:"Location"},\u652F\u5E97:{rank:12,type:"Location"},\u7814\u7A76\u6240:{rank:15,type:"Location"},\u5DE5\u5834:{rank:15,type:"Location"},\u4E8B\u696D\u90E8:{rank:18,type:"Organization"},\u90E8\u9580:{rank:18,type:"Organization"},\u7D71\u62EC\u90E8:{rank:19,type:"Organization"},\u90E8:{rank:20,type:"Organization"},\u958B\u767A:{rank:20,type:"Organization"},\u30B0\u30EB\u30FC\u30D7:{rank:22,type:"Organization"},\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8:{rank:25,type:"Organization"},\u63A8\u9032:{rank:20,type:"Organization"},\u4E8B\u696D\u6240:{rank:25,type:"Location"},\u55B6\u696D\u6240:{rank:28,type:"Location"},\u5BA4:{rank:30,type:"Organization"},\u8AB2:{rank:30,type:"Organization"},\u30BB\u30F3\u30BF\u30FC:{rank:30,type:"Location"},\u30D3\u30B8\u30CD\u30B9\u30D7\u30ED\u30C7\u30E5\u30FC\u30B9\u30BB\u30F3\u30BF\u30FC:{rank:30,type:"Location"},\u30C1\u30FC\u30E0:{rank:40,type:"Organization"},\u4FC2:{rank:50,type:"Organization"},Department:{rank:20,type:"Organization"},Dept:{rank:20,type:"Organization"},"Dept.":{rank:20,type:"Organization"},Division:{rank:20,type:"Organization"},Div:{rank:20,type:"Organization"},"Div.":{rank:20,type:"Organization"},Section:{rank:30,type:"Organization"},Sect:{rank:30,type:"Organization"},"Sect.":{rank:30,type:"Organization"},Unit:{rank:30,type:"Organization"},Group:{rank:22,type:"Organization"},Team:{rank:40,type:"Organization"},Branch:{rank:12,type:"Location"},Office:{rank:28,type:"Location"},Center:{rank:30,type:"Location"},Centre:{rank:30,type:"Location"},HQ:{rank:10,type:"Organization"},Headquarters:{rank:10,type:"Organization"}},_=e=>{for(let[t,r]of Object.entries(V))if(e.endsWith(t))return r;return{rank:99,type:"Other"}},A=e=>_(e).rank,X=["\u30B0\u30EB\u30FC\u30D7","\u30C1\u30FC\u30E0","Group","Team","\u5BA4","\u8AB2","Unit","Area","\u90E8","Department","Dept","Division","Div","\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8","\u63A8\u9032"],E=e=>X.find(t=>e.endsWith(t)),G=new Set(["&","Quality","Innovation","R&D","Solutions","Development","Laboratory","and","Food","Beverage"]),J=(e,t)=>t>1&&(e.endsWith("\u652F\u5E97")||e.endsWith("\u672C\u90E8")||e.endsWith("\u4E8B\u696D\u6240")||e.endsWith("\u5DE5\u5834")),Y=(e,t)=>{if(!t)return!0;let r=_(e),o=_(t);if(r.rank<o.rank||e.endsWith("\u672C\u90E8")&&t.endsWith("\u672C\u90E8"))return!1;let p=E(e),y=E(t);return!(p&&y&&p!==y)},M=(e,t)=>{if(!e)return[];if(e==="\u517C")return["\u517C"];if(e==="\u517C\u52D9")return["\u517C"];if(e.startsWith("\u517C ")||e.startsWith("\u517C\u3000")){let o=e.slice(1).trim();return["\u517C",...M(o,t)]}if(e.startsWith("\u517C\u52D9 ")||e.startsWith("\u517C\u52D9\u3000")){let o=e.slice(2).trim();return["\u517C",...M(o,t)]}let r="";for(let o=e.length-1;o>0;o--){if(e[o]!==" ")continue;let p=e.slice(0,o);if(!G.has(p)&&t.has(p)){r=p;break}}if(r){let o=r,p=e.slice(r.length),y=/^\s+(and|&)\s+([A-Za-z0-9]+)/i,P=p.match(y);P&&(o=e.slice(0,r.length+P[0].length));let u=e.slice(o.length),n=["Department","Dept","Division","Div","Section","Sect","Unit","Group","Team","Branch","Office","Center","Centre","HQ","Headquarters"];for(let i of n){let g=new RegExp(`^\\s+${i}\\.?(?=$|[\\s,])`,"i"),l=u.match(g);if(l){o=e.slice(0,o.length+l[0].length);break}}let m=e.slice(o.length).trim();return[o,...M(m,t)]}return[e]},Z=(e,t)=>{let o=e.replace(/[\s\u3000]+(?:兼務|兼)[\s\u3000]+/g,"\u3000\u517C\u3000").replace(/^(?:兼務|兼)[\s\u3000]+/,"\u517C\u3000").replace(/[\s\u3000]+(?:兼務|兼)$/,"\u3000\u517C").split(/\u3000/),p=[];for(let y of o){let P=y.trim();P&&p.push(...M(P,t))}return p},w=(e,t)=>{let r=[],o=["\u90E8","\u8AB2","\u5BA4","\u672C\u90E8","\u652F\u5E97","\u55B6\u696D\u6240","\u30B0\u30EB\u30FC\u30D7","\u30C1\u30FC\u30E0","\u30BB\u30F3\u30BF\u30FC","\u30AB\u30F3\u30D1\u30CB\u30FC","\u4E8B\u696D\u6240","\u5DE5\u5834","\u7814\u7A76\u6240","\u4FC2","\u90E8\u9580","\u4E8B\u696D\u90E8","\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8","\u63A8\u9032","\u958B\u767A","Department","Dept","Division","Div","Section","Sect","Unit","Group","Team","Branch","Office","Center","Centre","HQ","Headquarters"],p=e.split(/[\s\u3000,()()[\]]+/).filter(Boolean),y=p.length,P=new Set;for(let u=y;u>=1;u--)for(let n=0;n<=y-u;n++){let m=!1;for(let g=n;g<n+u;g++)if(P.has(g)){m=!0;break}if(m)continue;let i=p.slice(n,n+u).join(" ");if(!(i==="\u517C"||i==="\u517C\u52D9"||i==="\u4FC2"||i==="of"||i==="&"||i==="Quality"||i==="Innovation"||i==="R&D"||i==="Solutions"||i==="Development"||i==="Laboratory"||i==="and"||i==="Food"||i==="Beverage")&&t.allKnownDepartments.has(i)){r.push({name:i,index:n});for(let g=n;g<n+u;g++)P.add(g)}}for(let u=0;u<y;u++){if(P.has(u))continue;let n=p[u];for(n.endsWith("\u9577")&&n.length>1?n=n.slice(0,-1):n.endsWith("\u7D71\u62EC")&&n.length>2&&(n=n.slice(0,-2));;){let l=!1;if(n.startsWith("\u62C5\u5F53")&&n.length>2||n.startsWith("\u5C02\u4EFB")&&n.length>2||n.startsWith("\u517C\u52D9")&&n.length>2?(n=n.slice(2),l=!0):(n.startsWith("\u526F")||n.startsWith("\u517C"))&&n.length>1&&(n=n.slice(1),l=!0),!l)break}if(n.includes("\u30FB")&&!t.allKnownDepartments.has(n)){let l=n.split("\u30FB"),b=l[l.length-1],T=o.find(k=>b.endsWith(k));if(T){for(let k of l){let C=k;o.some(a=>C.endsWith(a))||(C=C+T);let x=n!=="\u517C"&&n!=="\u4FC2"&&n!=="of"&&n!=="&"&&n!=="Quality"&&n!=="Innovation"&&n!=="R&D"&&n!=="Solutions"&&n!=="Development"&&n!=="Laboratory"&&n!=="and"&&n!=="Food"&&n!=="Beverage"&&t.allKnownDepartments.has(C),d=o.some(a=>C.endsWith(a)),s=o.includes(C);(x||d&&!s)&&r.push({name:C,index:u})}continue}}let m=n!=="\u517C"&&n!=="\u4FC2"&&n!=="of"&&n!=="&"&&n!=="Quality"&&n!=="Innovation"&&n!=="R&D"&&n!=="Solutions"&&n!=="Development"&&n!=="Laboratory"&&n!=="and"&&n!=="Food"&&n!=="Beverage"&&t.allKnownDepartments.has(n),i=o.some(l=>n.endsWith(l)),g=o.includes(n);(m||i&&!g)&&r.push({name:n,index:u})}return r.sort((u,n)=>u.index-n.index),r.map(u=>u.name)},I=(e,t)=>{let r=0;for(let o of t)r<e.length&&o===e[r]&&r++;return r===e.length},B={name:"Standard",parse:(e,t,r="full")=>{let o=R(e.department,"");if(!o)return null;let p=Z(o,t.allKnownDepartments),y=new Map;for(let n of p)y.set(n,(y.get(n)||0)+1);let P=n=>{let m=[],i=[];for(let g=0;g<n.length;g++){let l=n[g];if(l==="\u517C"){i.length>0&&(m.push(i),i=[]);continue}let b=_(l),T=b.rank,k=y.get(l)||0,C=J(l,k);if(i.length===0)i.push(l);else{let x=i[i.length-1],d=_(x),s=d.rank;if(i.includes(l))m.push(i),i=[l];else{let a=!1;if(C)a=!0;else if(d.type===b.type){let h=E(x),f=E(l);h&&f&&h!==f||x.endsWith("\u672C\u90E8")&&l.endsWith("\u672C\u90E8")||x.endsWith("\u90E8\u9580")&&l.endsWith("\u4E8B\u696D\u90E8")||x.endsWith("\u4E8B\u696D\u90E8")&&l.endsWith("\u90E8\u9580")||x.endsWith("\u90E8\u9580")&&l.endsWith("\u672C\u90E8")||d.type==="Other"&&b.type==="Other"?a=!0:a=s<T}else a=T>=10,a&&d.type==="Location"&&b.type==="Organization"&&s>=T&&n.slice(g+1).includes(x)&&(a=!1);a?i.push(l):(m.push(i),i=[l])}}if(C){let x=g+1<n.length?n[g+1]:void 0;Y(l,x)&&i.length>0&&(m.push(i),i=[])}}return i.length>0&&m.push(i),m},u=[];if(r==="full"&&u.push(...P(p)),r==="pure_org"){let n=p.filter(m=>_(m).type!=="Location");n.length>0&&u.push(...P(n))}if(e.title){let m=/[^\x20-\x7E]/.test(e.title)?/[\s\u3000]*(?:兼務|兼)[\s\u3000]*/:/[,;]|(?:兼務|兼)/,i=e.title.split(m).filter(Boolean),g=[],l=(d,s)=>{let a=A(d),h=A(s),f=a<h;if(!f){let D=E(d),S=E(s);if(D&&S&&D!==S)f=!0;else if(d.endsWith("\u672C\u90E8")&&s.endsWith("\u672C\u90E8"))f=!0;else if(d.endsWith("\u90E8\u9580")&&s.endsWith("\u4E8B\u696D\u90E8")||d.endsWith("\u4E8B\u696D\u90E8")&&s.endsWith("\u90E8\u9580"))f=!0;else if(d.endsWith("\u90E8\u9580")&&s.endsWith("\u672C\u90E8"))f=!0;else{let L=_(d),q=_(s);L.type==="Other"&&q.type==="Other"&&(f=!0)}}return f};for(let d of i){let s=w(d,t);if(s.length===0)continue;let a=[];for(let h of s)if(a.length===0)a.push(h);else{let f=a[a.length-1];if(l(f,h))a.push(h);else{g.push([...a]);let D=!1;for(let S=a.length-2;S>=0;S--){let L=a[S];if(l(L,h)){a=[...a.slice(0,S+1),h],D=!0;break}}D||(a=[h])}}a.length>0&&g.push(a)}let b=[...u],T=d=>i.some(s=>s.includes(d)&&s.length>d.length);for(let d of g){let s=!1;for(let a of u){let h=a.findIndex(f=>d.includes(f));if(h!==-1){let f=a[h],D=d.indexOf(f);if(h>0&&D===0){let S=a.slice(0,h);b.push([...S,...d]),s=!0}else if(D>0&&h===0){let S=d.slice(0,D);b.push([...S,...a]),b.push(d),s=!0}else d.length>a.length-h,s=!0}if(!s){let f=a[a.length-1],D=d[0];l(f,D)&&(b.push([...a,...d]),s=!0)}}s||b.push(d)}let k=[],C=[],x=new Set;for(let d of b){let s=d.join("|");x.has(s)||(x.add(s),C.push(d))}for(let d=0;d<C.length;d++){let s=C[d],a=!1;for(let h=0;h<C.length;h++){if(d===h)continue;let f=C[h];if(f.length>s.length&&f.slice(0,s.length).join("|")===s.join("|")){let D=s[s.length-1];if(!T(D)){a=!0;break}}if(f.length>s.length&&I(s,f)){let D=s[s.length-1];if(!T(D)){a=!0;break}}if(s.length===1&&f.length>0){let D=s[0],S=f[f.length-1];if(D!==S&&S.endsWith(D)){a=!0;break}}}a||k.push(s)}return k.length>0?k:null}if(u.length>0){let n=[];for(let m=0;m<u.length;m++){let i=u[m],g=!1;for(let l=0;l<u.length;l++){if(m===l)continue;let b=u[l];if(b.length>i.length&&I(i,b)){g=!0;break}}g||n.push(i)}return n.length>0?n:null}return null}},v={name:"TitleBased",parse:(e,t,r="full")=>{let o=e.title;if(!o)return null;let p=w(o,t);return p.length>0?[p]:null}};var ee="\u672A\u5206\u985E",K="\u540D\u524D\u672A\u8A2D\u5B9A",te=[B,v],ne=e=>{let t=R(e.full_name,K),r=R(e.title,"");return r.length>0?`${t} (${r})`:t},$=(e,t)=>`${e} (${t.toLocaleString()})`,F=e=>e.sort((t,r)=>t.label.localeCompare(r.label,"ja")),O=(e,t,r)=>{let o=e.get(t);if(o)return o;let p=r();return e.set(t,p),p},z=e=>encodeURIComponent(e.replace(/\//g,"\uFF0F")),U=e=>e.sort((t,r)=>{let o=!!(t.contact.title&&t.contact.title.trim().length>0),p=!!(r.contact.title&&r.contact.title.trim().length>0);return o&&!p?-1:!o&&p?1:t.label.localeCompare(r.label,"ja")}),j=e=>{let t=R(e.contact.full_name,K),r=R(e.contact.title,"");return{name:r?`${t} (${r})`:t,type:"file",absolutePath:e.path,relativePath:e.segment,personId:e.contact.person_id,title:e.contact.title||void 0,isPrimary:e.isPrimary}},H=e=>{let t=F(Array.from(e.children.values())).map(H),r=U([...e.persons]).map(j);return{name:$(e.label,e.personCount),type:"directory",absolutePath:e.path,relativePath:e.segment,children:[...r,...t]}},N=class{constructor(){this.companyMap=new Map;this.processedPersonIds=new Set;this.allDepts=new Set;this.cachedResult=null}appendRecords(t){if(!t||t.length===0)return;let r="full",o=!1;for(let p of t)if(!this.processedPersonIds.has(p.person_id)&&p.department){let y=p.department.split(/\u3000/);for(let P of y){let u=P.trim();if(!u||u==="\u517C"||u==="\u4FC2")continue;if(/[^\x20-\x7E]/.test(u)){let m=u.split(" ").filter(i=>i.length>0&&i!=="\u517C"&&i!=="\u4FC2");for(let i of m)this.allDepts.add(i)}else this.allDepts.add(u)}}for(let p of t){let y=p.person_id;if(!Number.isFinite(y)||this.processedPersonIds.has(y))continue;this.processedPersonIds.add(y),o=!0;let P=R(p.company_name,ee),u=ne(p),n=`company:${z(P)}`,m=O(this.companyMap,n,()=>({label:P,segment:n,path:`/${n}`,departments:new Map,persons:[],personCount:0})),i=[],g={allKnownDepartments:this.allDepts};for(let l of te){let b=l.parse(p,g,r);if(b&&b.length>0){i=b;break}}i.length===0&&i.push([]);for(let l=0;l<i.length;l++){let b=i[l];if(b.length===0){let s=`person:${y}`,a=`${m.path}/${s}`;m.persons.some(f=>f.contact.person_id===y)||m.persons.push({contact:p,label:u,path:a,segment:s,isPrimary:!0});continue}let T=null,k=m.path;if(b.length>0){let s=b[0],a=`department:${z(s)}`;T=O(m.departments,a,()=>({label:s,segment:a,path:`${k}/${a}`,children:new Map,persons:[],personCount:0})),k=T.path,T.personCount+=1;for(let h=1;h<b.length;h++){let f=b[h],D=`department:${z(f)}`;if(!T)throw new Error("Unexpected null currentDepartmentNode");T=O(T.children,D,()=>({label:f,segment:D,path:`${k}/${D}`,children:new Map,persons:[],personCount:0})),k=T.path,T.personCount+=1}}else continue;let C=`person:${y}`,x=`${T.path}/${C}`;T.persons.some(s=>s.contact.person_id===y)||T.persons.push({contact:p,label:u,path:x,segment:C,isPrimary:l===0})}m.personCount+=1}o&&(this.cachedResult=null)}getSnapshot(){if(this.cachedResult)return this.cachedResult;let t={},r=F(Array.from(this.companyMap.values())).map(o=>{let p=F(Array.from(o.departments.values())).map(H),y=U([...o.persons]).map(j),P={name:$(o.label,o.personCount),type:"directory",absolutePath:o.path,relativePath:o.segment,children:[...y,...p]};return t[o.label]=P,P});return this.cachedResult={tree:r,companyMap:t},this.cachedResult}append(t){this.appendRecords(t)}build(){return this.getSnapshot().tree}reset(){this.companyMap.clear(),this.processedPersonIds.clear(),this.allDepts.clear(),this.cachedResult=null}getUniquePersonCount(){return this.processedPersonIds.size}get size(){return this.processedPersonIds.size}},ce=e=>{let t=new N;return t.appendRecords(e),t.getSnapshot()};var W=e=>{if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null},de=e=>!e||typeof e!="object"?null:"item"in e?e.item??null:"person_id"in e?e:null,Q=(e,t)=>{if(!e)return{value:null,fieldKey:null};for(let r of t){let o=W(e[r]);if(o)return{value:o,fieldKey:r}}return{value:null,fieldKey:null}},me=e=>Q(e,["custom_email","email"]),fe=e=>Q(e,["custom_mobile_phone_number","mobile_phone_number","company_phone_number"]),he=e=>{let t=W(e);if(!t)return null;let r=t.replace(/[^0-9+#*]/g,"");return r.length===0?null:`tel:${r}`},ge=(e,t)=>{let r=W(e);return r?t?`https://mail.google.com/mail/?view=cm&fs=1&to=${encodeURIComponent(r)}`:`mailto:${encodeURIComponent(r)}`:null},ye=e=>{if(!e)return"-";let t=typeof e=="string"||typeof e=="number"?new Date(e):e;return!(t instanceof Date)||Number.isNaN(t.getTime())?typeof e=="string"?e:"-":t.toISOString().split("T")[0]},re=e=>{if(!e)return"-";let t=typeof e=="string"||typeof e=="number"?new Date(e):e;return!(t instanceof Date)||Number.isNaN(t.getTime())?typeof e=="string"?e:"-":t.toISOString()},be=e=>e==null?"-":typeof e=="string"?W(e)??"-":typeof e=="number"?Number.isFinite(e)?String(e):"-":e instanceof Date?re(e):String(e);var Te={listPanelMinWidth:320,detailPanelMinWidth:260,handleThickness:10,listPaddingAndBorder:0,detailPaddingAndBorder:0,scrollbarSafetyBuffer:20,hysteresisSafetyMargin:35},Pe={listPanelMinWidth:280,detailPanelMinWidth:260,handleThickness:10,listPaddingAndBorder:0,detailPaddingAndBorder:0,scrollbarSafetyBuffer:20,hysteresisSafetyMargin:35};function Ce(e){let t=e.listPanelMinWidth+e.detailPanelMinWidth+e.handleThickness+e.listPaddingAndBorder+e.detailPaddingAndBorder,r=t+e.scrollbarSafetyBuffer,o=r+e.hysteresisSafetyMargin,p=o-r;return{physicalMinWidth:t,collapseThreshold:r,expandThreshold:o,hysteresisWidth:p}}function xe(e,t,r){return e<=0||!Number.isFinite(e)?!1:t?e>=r.collapseThreshold:e>=r.expandThreshold}var ke={info:(e,...t)=>console.info(`[contact-map] ${e}`,...t),warn:(e,...t)=>console.warn(`[contact-map] ${e}`,...t),error:(e,...t)=>console.error(`[contact-map] ${e}`,...t)};import{normalizeText as oe}from"@aiquants/select-box";var ie=/[\u200B\uFEFF]/g,ae=/^[\s\u3000\u00A0]+|[\s\u3000\u00A0]+$/g,Ee=e=>{let t=e.replace(ie,"").replace(ae,"");return oe(t,{convertWidth:!0,convertKana:!0,convertCase:!0,convertRomaji:!0})};import{z as c}from"zod";var se=c.object({person_id:c.union([c.string(),c.number()]).transform(e=>{if(typeof e=="number")return e;let t=e.trim();return parseInt(t,10)}).pipe(c.number()),person_id_redirect_to:c.union([c.string(),c.number()]).nullable().optional().transform(e=>{if(e==null)return null;if(typeof e=="number")return e;let t=e.trim();if(t.length===0)return null;let r=parseInt(t,10);return Number.isNaN(r)?null:r}),full_name:c.string().nullable().optional(),full_name_reading:c.string().nullable().optional(),company_name:c.string().nullable().optional(),company_name_reading:c.string().nullable().optional(),department:c.string().nullable().optional(),title:c.string().nullable().optional(),address:c.string().nullable().optional(),postal_code:c.string().nullable().optional(),email:c.string().nullable().optional(),custom_email:c.string().nullable().optional(),company_phone_number:c.string().nullable().optional(),custom_company_phone_number:c.string().nullable().optional(),company_fax_number:c.string().nullable().optional(),mobile_phone_number:c.string().nullable().optional(),custom_mobile_phone_number:c.string().nullable().optional(),url:c.string().nullable().optional(),contacted_at:c.union([c.date(),c.string()]).nullable().optional(),contacted_by:c.string().nullable().optional(),is_in_eight:c.boolean().nullable().optional(),is_contact_synced:c.boolean().nullable().optional(),is_active:c.boolean(),is_incomplete:c.boolean().nullable().optional(),created_at:c.union([c.date(),c.string()]).optional(),created_by:c.string().optional(),updated_at:c.union([c.date(),c.string()]).optional(),updated_by:c.string().optional()}),Le=c.array(se);export{Te as DEFAULT_LIST_LAYOUT_SPEC,Pe as DEFAULT_TREE_LAYOUT_SPEC,N as IncrementalTreeBuilder,B as StandardDepartmentParser,v as TitleBasedDepartmentParser,ce as buildDirectoryTree,Ce as calculateResponsiveThresholds,ke as defaultLogger,de as extractContactData,w as extractDepartmentsFromTitle,ye as formatDate,re as formatDateTime,ge as getEmailLinkHref,xe as getHysteresisBreakpointState,he as getPhoneDialHref,me as getPrimaryEmail,fe as getPrimaryPhone,R as normalizeLabel,Ee as normalizeSearchInput,W as normalizeString,se as schemaContactRecord,Le as schemaContactRecords,Z as splitDepartment,be as toDisplayValue};