@procore/ai-translations 0.6.0 → 0.6.2

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.
@@ -2,6 +2,35 @@ import * as _tanstack_react_query from '@tanstack/react-query';
2
2
  import * as react_jsx_runtime from 'react/jsx-runtime';
3
3
  import React, { ReactNode } from 'react';
4
4
 
5
+ /** Shape of an analytic event passed to the MFE's `onTrackAnalyticsEvent` callback. */
6
+ interface AnalyticEvent {
7
+ key: string;
8
+ properties: Record<string, unknown>;
9
+ }
10
+ /** Function provided by the MFE that sends the event to the analytics destination. */
11
+ type AIAnalyticsTracker = (event: AnalyticEvent) => void;
12
+ /** Feature scope: `'project'` for project-level tools, `'company'` for company-level tools. */
13
+ type Scope = 'project' | 'company';
14
+ /**
15
+ * Parts needed to build an event key following the pattern:
16
+ * `ux.web.feature.{scope}.{tool}.{object}.{action}`
17
+ */
18
+ interface EventKeyParts {
19
+ scope: Scope;
20
+ tool: string;
21
+ object: string;
22
+ action: string;
23
+ }
24
+ /** Standard properties included in every AI analytics event. */
25
+ interface AIAnalyticsEventProperties {
26
+ user_locale: string;
27
+ project_locale?: string;
28
+ company_locale?: string;
29
+ tool: string;
30
+ page: string;
31
+ [key: string]: unknown;
32
+ }
33
+
5
34
  interface TranslationProgress {
6
35
  /**
7
36
  * Progress percentage (0-100)
@@ -39,12 +68,22 @@ interface ModelDownloadProgress {
39
68
  interface AITranslationContextValue {
40
69
  ait: (text: string) => Promise<string>;
41
70
  locale: string;
71
+ /** Company-level locale from environment metadata (e.g. `"de-DE"`). */
72
+ companyLocale?: string;
73
+ /** Project-level locale from environment metadata (e.g. `"fr-CA"`). */
74
+ projectLocale?: string;
42
75
  renderVersion?: number;
43
76
  /** Batch-translation progress; `null` while the queue is idle. */
44
77
  translationProgress: TranslationProgress | null;
45
78
  /** Chrome AI model download progress; `null` until a download begins. */
46
79
  modelDownloadProgress: ModelDownloadProgress | null;
47
80
  tool: string;
81
+ /** Called by `useAIAnalytics` with a fully assembled event. The MFE is responsible for sending it. */
82
+ onTrackAnalyticsEvent?: AIAnalyticsTracker;
83
+ /** Page context used to build the event key object segment (e.g. `'view'`, `'list_column_description'`). */
84
+ page?: string;
85
+ /** Feature scope: `'project'` or `'company'`. */
86
+ scope?: Scope;
48
87
  }
49
88
 
50
89
  interface ConfigurationResponse {
@@ -117,6 +156,61 @@ declare function useConfig(toolName: string, options?: UseConfigOptions): _tanst
117
156
  */
118
157
  declare function useAITranslation(): AITranslationContextValue;
119
158
 
159
+ /** Button type identifiers for the event key `object` segment. */
160
+ declare const BUTTON_TYPE: {
161
+ readonly TRANSLATE: "translate";
162
+ readonly HIGHLIGHT: "highlight";
163
+ };
164
+ type ButtonType = (typeof BUTTON_TYPE)[keyof typeof BUTTON_TYPE];
165
+ /** Action identifiers for the event key `action` segment. */
166
+ declare const ACTION: {
167
+ readonly CLICKED: "clicked";
168
+ };
169
+ type Action = (typeof ACTION)[keyof typeof ACTION];
170
+ /**
171
+ * Builds the `object` segment: `{pageContext}_{buttonType}_button`
172
+ * e.g. `buildObject('view', 'translate')` → `'view_translate_button'`
173
+ */
174
+ declare function buildObject(pageContext: string, buttonType: ButtonType): string;
175
+ /**
176
+ * Builds a fully-qualified event key:
177
+ * `ux.web.feature.{scope}.{tool}.{object}.{action}`
178
+ */
179
+ declare function buildEventKey(parts: EventKeyParts): string;
180
+ interface BuildAnalyticEventParams {
181
+ scope: Scope;
182
+ tool: string;
183
+ /** Prefix for the object segment, matches the Provider `page` prop (e.g. `'view'`). */
184
+ pageContext: string;
185
+ buttonType: ButtonType;
186
+ baseProperties: AIAnalyticsEventProperties;
187
+ /** Defaults to `'clicked'` if omitted. */
188
+ action?: Action;
189
+ additionalProperties?: Record<string, unknown>;
190
+ }
191
+ /** Assembles a complete `AnalyticEvent` (key + merged properties) ready for `onTrackAnalyticsEvent`. */
192
+ declare function buildAnalyticEvent(params: BuildAnalyticEventParams): AnalyticEvent;
193
+
194
+ interface UseAIAnalyticsReturn {
195
+ /** Fires `ux.web.feature.{scope}.{tool}.{page}_translate_button.clicked`. */
196
+ trackTranslateButtonClicked: (additionalProperties?: Record<string, unknown>) => void;
197
+ /** Fires `ux.web.feature.{scope}.{tool}.{page}_highlight_button.clicked`. */
198
+ trackHighlightButtonClicked: (additionalProperties?: Record<string, unknown>) => void;
199
+ /** Generic tracking for custom button types or actions. */
200
+ trackCustomEvent: (buttonType: ButtonType | string, action?: Action | string, additionalProperties?: Record<string, unknown>) => void;
201
+ /** `true` when `onTrackAnalyticsEvent` was provided to `AITranslationProvider`. */
202
+ isTrackingEnabled: boolean;
203
+ }
204
+ /**
205
+ * Returns analytics tracking helpers pre-wired to the Provider context.
206
+ * All functions no-op if `onTrackAnalyticsEvent` was not supplied.
207
+ *
208
+ * @throws if called outside of an `AITranslationProvider`.
209
+ */
210
+ declare function useAIAnalytics(): UseAIAnalyticsReturn;
211
+
212
+ declare function isSupportedBrowser(): boolean;
213
+
120
214
  interface AITranslationProviderProps {
121
215
  children: ReactNode;
122
216
  locale: string;
@@ -125,6 +219,16 @@ interface AITranslationProviderProps {
125
219
  userId: number;
126
220
  projectId: number;
127
221
  enableAIT?: boolean;
222
+ /** Company-level locale from environment metadata (e.g. `"de-DE"`). Passed through to context for downstream consumers such as Amplitude. */
223
+ companyLocale?: string;
224
+ /** Project-level locale from environment metadata (e.g. `"fr-CA"`). Passed through to context for downstream consumers such as Amplitude. */
225
+ projectLocale?: string;
226
+ /** Called by `useAIAnalytics` with a pre-assembled event. The MFE sends it to the analytics API. */
227
+ onTrackAnalyticsEvent?: AIAnalyticsTracker;
228
+ /** Page context for the event key object segment (e.g. `'view'`, `'list_column_description'`). */
229
+ page?: string;
230
+ /** Feature scope: `'project'` or `'company'`. */
231
+ scope?: Scope;
128
232
  }
129
233
  declare function AITranslationProvider(props: AITranslationProviderProps): react_jsx_runtime.JSX.Element;
130
234
 
@@ -177,4 +281,4 @@ declare global {
177
281
  var _BACKEND_AI_TRANSLATION_IN_PROGRESS_: boolean;
178
282
  }
179
283
 
180
- export { AITranslateText, type AITranslateTextProps, AITranslationProvider, AI_TRANSLATION_FEATURE_FLAG_KEY, type TranslatedIconProps, type UseConfigOptions, getAITranslationLDId, useAITranslation, useConfig };
284
+ export { ACTION, type AIAnalyticsEventProperties, type AIAnalyticsTracker, AITranslateText, type AITranslateTextProps, AITranslationProvider, AI_TRANSLATION_FEATURE_FLAG_KEY, type Action, type AnalyticEvent, BUTTON_TYPE, type BuildAnalyticEventParams, type ButtonType, type EventKeyParts, type Scope, type TranslatedIconProps, type UseAIAnalyticsReturn, type UseConfigOptions, buildAnalyticEvent, buildEventKey, buildObject, getAITranslationLDId, isSupportedBrowser, useAIAnalytics, useAITranslation, useConfig };
@@ -2,6 +2,35 @@ import * as _tanstack_react_query from '@tanstack/react-query';
2
2
  import * as react_jsx_runtime from 'react/jsx-runtime';
3
3
  import React, { ReactNode } from 'react';
4
4
 
5
+ /** Shape of an analytic event passed to the MFE's `onTrackAnalyticsEvent` callback. */
6
+ interface AnalyticEvent {
7
+ key: string;
8
+ properties: Record<string, unknown>;
9
+ }
10
+ /** Function provided by the MFE that sends the event to the analytics destination. */
11
+ type AIAnalyticsTracker = (event: AnalyticEvent) => void;
12
+ /** Feature scope: `'project'` for project-level tools, `'company'` for company-level tools. */
13
+ type Scope = 'project' | 'company';
14
+ /**
15
+ * Parts needed to build an event key following the pattern:
16
+ * `ux.web.feature.{scope}.{tool}.{object}.{action}`
17
+ */
18
+ interface EventKeyParts {
19
+ scope: Scope;
20
+ tool: string;
21
+ object: string;
22
+ action: string;
23
+ }
24
+ /** Standard properties included in every AI analytics event. */
25
+ interface AIAnalyticsEventProperties {
26
+ user_locale: string;
27
+ project_locale?: string;
28
+ company_locale?: string;
29
+ tool: string;
30
+ page: string;
31
+ [key: string]: unknown;
32
+ }
33
+
5
34
  interface TranslationProgress {
6
35
  /**
7
36
  * Progress percentage (0-100)
@@ -39,12 +68,22 @@ interface ModelDownloadProgress {
39
68
  interface AITranslationContextValue {
40
69
  ait: (text: string) => Promise<string>;
41
70
  locale: string;
71
+ /** Company-level locale from environment metadata (e.g. `"de-DE"`). */
72
+ companyLocale?: string;
73
+ /** Project-level locale from environment metadata (e.g. `"fr-CA"`). */
74
+ projectLocale?: string;
42
75
  renderVersion?: number;
43
76
  /** Batch-translation progress; `null` while the queue is idle. */
44
77
  translationProgress: TranslationProgress | null;
45
78
  /** Chrome AI model download progress; `null` until a download begins. */
46
79
  modelDownloadProgress: ModelDownloadProgress | null;
47
80
  tool: string;
81
+ /** Called by `useAIAnalytics` with a fully assembled event. The MFE is responsible for sending it. */
82
+ onTrackAnalyticsEvent?: AIAnalyticsTracker;
83
+ /** Page context used to build the event key object segment (e.g. `'view'`, `'list_column_description'`). */
84
+ page?: string;
85
+ /** Feature scope: `'project'` or `'company'`. */
86
+ scope?: Scope;
48
87
  }
49
88
 
50
89
  interface ConfigurationResponse {
@@ -117,6 +156,61 @@ declare function useConfig(toolName: string, options?: UseConfigOptions): _tanst
117
156
  */
118
157
  declare function useAITranslation(): AITranslationContextValue;
119
158
 
159
+ /** Button type identifiers for the event key `object` segment. */
160
+ declare const BUTTON_TYPE: {
161
+ readonly TRANSLATE: "translate";
162
+ readonly HIGHLIGHT: "highlight";
163
+ };
164
+ type ButtonType = (typeof BUTTON_TYPE)[keyof typeof BUTTON_TYPE];
165
+ /** Action identifiers for the event key `action` segment. */
166
+ declare const ACTION: {
167
+ readonly CLICKED: "clicked";
168
+ };
169
+ type Action = (typeof ACTION)[keyof typeof ACTION];
170
+ /**
171
+ * Builds the `object` segment: `{pageContext}_{buttonType}_button`
172
+ * e.g. `buildObject('view', 'translate')` → `'view_translate_button'`
173
+ */
174
+ declare function buildObject(pageContext: string, buttonType: ButtonType): string;
175
+ /**
176
+ * Builds a fully-qualified event key:
177
+ * `ux.web.feature.{scope}.{tool}.{object}.{action}`
178
+ */
179
+ declare function buildEventKey(parts: EventKeyParts): string;
180
+ interface BuildAnalyticEventParams {
181
+ scope: Scope;
182
+ tool: string;
183
+ /** Prefix for the object segment, matches the Provider `page` prop (e.g. `'view'`). */
184
+ pageContext: string;
185
+ buttonType: ButtonType;
186
+ baseProperties: AIAnalyticsEventProperties;
187
+ /** Defaults to `'clicked'` if omitted. */
188
+ action?: Action;
189
+ additionalProperties?: Record<string, unknown>;
190
+ }
191
+ /** Assembles a complete `AnalyticEvent` (key + merged properties) ready for `onTrackAnalyticsEvent`. */
192
+ declare function buildAnalyticEvent(params: BuildAnalyticEventParams): AnalyticEvent;
193
+
194
+ interface UseAIAnalyticsReturn {
195
+ /** Fires `ux.web.feature.{scope}.{tool}.{page}_translate_button.clicked`. */
196
+ trackTranslateButtonClicked: (additionalProperties?: Record<string, unknown>) => void;
197
+ /** Fires `ux.web.feature.{scope}.{tool}.{page}_highlight_button.clicked`. */
198
+ trackHighlightButtonClicked: (additionalProperties?: Record<string, unknown>) => void;
199
+ /** Generic tracking for custom button types or actions. */
200
+ trackCustomEvent: (buttonType: ButtonType | string, action?: Action | string, additionalProperties?: Record<string, unknown>) => void;
201
+ /** `true` when `onTrackAnalyticsEvent` was provided to `AITranslationProvider`. */
202
+ isTrackingEnabled: boolean;
203
+ }
204
+ /**
205
+ * Returns analytics tracking helpers pre-wired to the Provider context.
206
+ * All functions no-op if `onTrackAnalyticsEvent` was not supplied.
207
+ *
208
+ * @throws if called outside of an `AITranslationProvider`.
209
+ */
210
+ declare function useAIAnalytics(): UseAIAnalyticsReturn;
211
+
212
+ declare function isSupportedBrowser(): boolean;
213
+
120
214
  interface AITranslationProviderProps {
121
215
  children: ReactNode;
122
216
  locale: string;
@@ -125,6 +219,16 @@ interface AITranslationProviderProps {
125
219
  userId: number;
126
220
  projectId: number;
127
221
  enableAIT?: boolean;
222
+ /** Company-level locale from environment metadata (e.g. `"de-DE"`). Passed through to context for downstream consumers such as Amplitude. */
223
+ companyLocale?: string;
224
+ /** Project-level locale from environment metadata (e.g. `"fr-CA"`). Passed through to context for downstream consumers such as Amplitude. */
225
+ projectLocale?: string;
226
+ /** Called by `useAIAnalytics` with a pre-assembled event. The MFE sends it to the analytics API. */
227
+ onTrackAnalyticsEvent?: AIAnalyticsTracker;
228
+ /** Page context for the event key object segment (e.g. `'view'`, `'list_column_description'`). */
229
+ page?: string;
230
+ /** Feature scope: `'project'` or `'company'`. */
231
+ scope?: Scope;
128
232
  }
129
233
  declare function AITranslationProvider(props: AITranslationProviderProps): react_jsx_runtime.JSX.Element;
130
234
 
@@ -177,4 +281,4 @@ declare global {
177
281
  var _BACKEND_AI_TRANSLATION_IN_PROGRESS_: boolean;
178
282
  }
179
283
 
180
- export { AITranslateText, type AITranslateTextProps, AITranslationProvider, AI_TRANSLATION_FEATURE_FLAG_KEY, type TranslatedIconProps, type UseConfigOptions, getAITranslationLDId, useAITranslation, useConfig };
284
+ export { ACTION, type AIAnalyticsEventProperties, type AIAnalyticsTracker, AITranslateText, type AITranslateTextProps, AITranslationProvider, AI_TRANSLATION_FEATURE_FLAG_KEY, type Action, type AnalyticEvent, BUTTON_TYPE, type BuildAnalyticEventParams, type ButtonType, type EventKeyParts, type Scope, type TranslatedIconProps, type UseAIAnalyticsReturn, type UseConfigOptions, buildAnalyticEvent, buildEventKey, buildObject, getAITranslationLDId, isSupportedBrowser, useAIAnalytics, useAITranslation, useConfig };
@@ -20,10 +20,17 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
+ ACTION: () => ACTION,
23
24
  AITranslateText: () => AITranslateText,
24
25
  AITranslationProvider: () => AITranslationProvider,
25
26
  AI_TRANSLATION_FEATURE_FLAG_KEY: () => AI_TRANSLATION_FEATURE_FLAG_KEY,
27
+ BUTTON_TYPE: () => BUTTON_TYPE,
28
+ buildAnalyticEvent: () => buildAnalyticEvent,
29
+ buildEventKey: () => buildEventKey,
30
+ buildObject: () => buildObject,
26
31
  getAITranslationLDId: () => getAITranslationLDId,
32
+ isSupportedBrowser: () => isSupportedBrowser,
33
+ useAIAnalytics: () => useAIAnalytics,
27
34
  useAITranslation: () => useAITranslation,
28
35
  useConfig: () => useConfig
29
36
  });
@@ -1426,6 +1433,7 @@ var aitFunction = async (text, translationRegistry, config2, tool) => {
1426
1433
  };
1427
1434
 
1428
1435
  // src/utils/browser.ts
1436
+ var supportedBrowsers = ["chrome", "arc", "opera"];
1429
1437
  function detectBrowser() {
1430
1438
  const ua = navigator.userAgent;
1431
1439
  if (ua.includes("Arc/")) return "arc";
@@ -1436,6 +1444,10 @@ function detectBrowser() {
1436
1444
  if (ua.includes("Chrome/")) return "chrome";
1437
1445
  return "unknown";
1438
1446
  }
1447
+ function isSupportedBrowser() {
1448
+ const browser = detectBrowser();
1449
+ return supportedBrowsers.includes(browser);
1450
+ }
1439
1451
 
1440
1452
  // src/Provider.tsx
1441
1453
  var import_react_query2 = require("@tanstack/react-query");
@@ -1449,7 +1461,12 @@ function AITranslationInnerProvider(props) {
1449
1461
  companyId,
1450
1462
  userId,
1451
1463
  projectId,
1452
- enableAIT = true
1464
+ enableAIT = true,
1465
+ companyLocale,
1466
+ projectLocale,
1467
+ onTrackAnalyticsEvent,
1468
+ page,
1469
+ scope
1453
1470
  } = props;
1454
1471
  const [translationProgress, setTranslationProgress] = (0, import_react.useState)(null);
1455
1472
  const [modelDownloadProgress, setModelDownloadProgress] = (0, import_react.useState)(null);
@@ -1526,10 +1543,15 @@ function AITranslationInnerProvider(props) {
1526
1543
  const contextValue = {
1527
1544
  ait,
1528
1545
  locale,
1546
+ companyLocale,
1547
+ projectLocale,
1529
1548
  renderVersion: renderVersionManager.getVersion(),
1530
1549
  translationProgress,
1531
1550
  modelDownloadProgress,
1532
- tool
1551
+ tool,
1552
+ onTrackAnalyticsEvent,
1553
+ page,
1554
+ scope
1533
1555
  };
1534
1556
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AITranslationContext.Provider, { value: contextValue, children });
1535
1557
  }
@@ -1549,15 +1571,143 @@ function useAITranslation() {
1549
1571
  return ctx;
1550
1572
  }
1551
1573
 
1574
+ // src/hooks/useAIAnalytics.ts
1575
+ var import_react3 = require("react");
1576
+
1577
+ // src/analytics/events.ts
1578
+ var BUTTON_TYPE = {
1579
+ TRANSLATE: "translate",
1580
+ HIGHLIGHT: "highlight"
1581
+ };
1582
+ var ACTION = {
1583
+ CLICKED: "clicked"
1584
+ };
1585
+ function buildObject(pageContext, buttonType) {
1586
+ return `${pageContext}_${buttonType}_button`;
1587
+ }
1588
+ function buildEventKey(parts) {
1589
+ const { scope, tool, object, action } = parts;
1590
+ return `ux.web.feature.${scope}.${tool}.${object}.${action}`;
1591
+ }
1592
+ function buildAnalyticEvent(params) {
1593
+ const {
1594
+ scope,
1595
+ tool,
1596
+ pageContext,
1597
+ buttonType,
1598
+ baseProperties,
1599
+ action,
1600
+ additionalProperties
1601
+ } = params;
1602
+ const resolvedAction = action ?? ACTION.CLICKED;
1603
+ const object = buildObject(pageContext, buttonType);
1604
+ const key = buildEventKey({
1605
+ scope,
1606
+ tool,
1607
+ object,
1608
+ action: resolvedAction
1609
+ });
1610
+ const properties = {
1611
+ ...baseProperties,
1612
+ ...additionalProperties
1613
+ };
1614
+ return { key, properties };
1615
+ }
1616
+
1617
+ // src/hooks/useAIAnalytics.ts
1618
+ function useAIAnalytics() {
1619
+ const ctx = (0, import_react3.useContext)(AITranslationContext);
1620
+ if (!ctx) {
1621
+ throw new Error(
1622
+ "useAIAnalytics must be used inside an AITranslationProvider"
1623
+ );
1624
+ }
1625
+ const {
1626
+ locale,
1627
+ companyLocale,
1628
+ projectLocale,
1629
+ tool,
1630
+ page,
1631
+ scope,
1632
+ onTrackAnalyticsEvent
1633
+ } = ctx;
1634
+ const isTrackingEnabled = Boolean(onTrackAnalyticsEvent);
1635
+ const buildBaseProperties = (0, import_react3.useCallback)(() => {
1636
+ const props = {
1637
+ user_locale: locale,
1638
+ tool,
1639
+ page: page ?? ""
1640
+ };
1641
+ if (companyLocale) props.company_locale = companyLocale;
1642
+ if (projectLocale) props.project_locale = projectLocale;
1643
+ return props;
1644
+ }, [locale, tool, page, companyLocale, projectLocale]);
1645
+ const trackTranslateButtonClicked = (0, import_react3.useCallback)(
1646
+ (additionalProperties) => {
1647
+ if (!onTrackAnalyticsEvent || !page || !scope) return;
1648
+ onTrackAnalyticsEvent(
1649
+ buildAnalyticEvent({
1650
+ scope,
1651
+ tool,
1652
+ pageContext: page,
1653
+ buttonType: BUTTON_TYPE.TRANSLATE,
1654
+ baseProperties: buildBaseProperties(),
1655
+ additionalProperties
1656
+ })
1657
+ );
1658
+ },
1659
+ [onTrackAnalyticsEvent, tool, page, scope, buildBaseProperties]
1660
+ );
1661
+ const trackHighlightButtonClicked = (0, import_react3.useCallback)(
1662
+ (additionalProperties) => {
1663
+ if (!onTrackAnalyticsEvent || !page || !scope) return;
1664
+ onTrackAnalyticsEvent(
1665
+ buildAnalyticEvent({
1666
+ scope,
1667
+ tool,
1668
+ pageContext: page,
1669
+ buttonType: BUTTON_TYPE.HIGHLIGHT,
1670
+ baseProperties: buildBaseProperties(),
1671
+ additionalProperties
1672
+ })
1673
+ );
1674
+ },
1675
+ [onTrackAnalyticsEvent, tool, page, scope, buildBaseProperties]
1676
+ );
1677
+ const trackCustomEvent = (0, import_react3.useCallback)(
1678
+ (buttonType, action, additionalProperties) => {
1679
+ if (!onTrackAnalyticsEvent || !page || !scope) return;
1680
+ onTrackAnalyticsEvent(
1681
+ buildAnalyticEvent({
1682
+ scope,
1683
+ tool,
1684
+ pageContext: page,
1685
+ buttonType,
1686
+ baseProperties: buildBaseProperties(),
1687
+ action,
1688
+ additionalProperties
1689
+ })
1690
+ );
1691
+ },
1692
+ [onTrackAnalyticsEvent, tool, page, scope, buildBaseProperties]
1693
+ );
1694
+ return {
1695
+ trackTranslateButtonClicked,
1696
+ trackHighlightButtonClicked,
1697
+ trackCustomEvent,
1698
+ isTrackingEnabled
1699
+ };
1700
+ }
1701
+
1552
1702
  // src/components/AITranslateText.tsx
1553
- var import_react4 = require("react");
1703
+ var import_react5 = require("react");
1554
1704
 
1555
1705
  // src/components/TranslatedIcon.tsx
1556
- var import_react3 = require("react");
1706
+ var import_react4 = require("react");
1557
1707
  var import_jsx_runtime2 = require("react/jsx-runtime");
1558
1708
  var TranslatedIcon = ({
1559
- width = 14,
1560
- height = 14,
1709
+ width = 24,
1710
+ height = 24,
1561
1711
  className,
1562
1712
  color = "#000000"
1563
1713
  }) => {
@@ -1575,7 +1725,7 @@ var TranslatedIcon = ({
1575
1725
  "path",
1576
1726
  {
1577
1727
  fill: color,
1578
- d: "M12.87,15.07l-2.54,-2.51 0.03,-0.03c1.74,-1.94 2.98,-4.17 3.71,-6.53L17,6L17,4h-7L10,2L8,2v2L1,4v1.99h11.17C11.5,7.92 10.44,9.75 9,11.35 8.07,10.32 7.3,9.19 6.69,8h-2c0.73,1.63 1.73,3.17 2.98,4.56l-5.09,5.02L4,19l5,-5 3.11,3.11 0.76,-2.04zM18.5,10h-2L12,22h2l1.12,-3h4.75L21,22h2l-4.5,-12zM15.88,17l1.62,-4.33L19.12,17h-3.24z"
1728
+ d: "M12 2C6.48 2 2 6.48 2 12C2 17.52 6.48 22 12 22C17.52 22 22 17.52 22 12C22 6.48 17.52 2 12 2ZM11 19.93C7.05 19.44 4 16.08 4 12C4 11.38 4.08 10.79 4.21 10.21L9 15V16C9 17.1 9.9 18 11 18V19.93ZM17.9 17.39C17.64 16.58 16.9 16 16 16H15V13C15 12.45 14.55 12 14 12H8V10H10C10.55 10 11 9.55 11 9V7H13C14.1 7 15 6.1 15 5V4.59C17.93 5.78 20 8.65 20 12C20 14.08 19.2 15.97 17.9 17.39Z"
1579
1729
  }
1580
1730
  )
1581
1731
  }
@@ -1590,11 +1740,11 @@ var AITranslateText = ({
1590
1740
  showHighlight = false,
1591
1741
  translatedIconProps
1592
1742
  }) => {
1593
- const context = (0, import_react4.useContext)(AITranslationContext);
1594
- const [displayText, setDisplayText] = (0, import_react4.useState)(text ?? "");
1595
- const [showHighlightState, setShowHighlightState] = (0, import_react4.useState)(showHighlight);
1596
- const eventHandlerRef = (0, import_react4.useRef)(null);
1597
- (0, import_react4.useEffect)(() => {
1743
+ const context = (0, import_react5.useContext)(AITranslationContext);
1744
+ const [displayText, setDisplayText] = (0, import_react5.useState)(text ?? "");
1745
+ const [showHighlightState, setShowHighlightState] = (0, import_react5.useState)(showHighlight);
1746
+ const eventHandlerRef = (0, import_react5.useRef)(null);
1747
+ (0, import_react5.useEffect)(() => {
1598
1748
  if (!context) return;
1599
1749
  if (!eventHandlerRef.current) {
1600
1750
  eventHandlerRef.current = new EventHandler(context.tool);
@@ -1613,14 +1763,14 @@ var AITranslateText = ({
1613
1763
  );
1614
1764
  return () => unsubscribe();
1615
1765
  }, [context, text, showHighlight]);
1616
- const reset = (0, import_react4.useCallback)(
1766
+ const reset = (0, import_react5.useCallback)(
1617
1767
  (displayValue = text) => {
1618
1768
  setDisplayText(displayValue);
1619
1769
  setShowHighlightState(false);
1620
1770
  },
1621
1771
  [text]
1622
1772
  );
1623
- (0, import_react4.useEffect)(() => {
1773
+ (0, import_react5.useEffect)(() => {
1624
1774
  if (text == null || text === "") {
1625
1775
  reset(text ?? "");
1626
1776
  return;
@@ -1672,10 +1822,17 @@ var getAITranslationLDId = (domain) => {
1672
1822
  };
1673
1823
  // Annotate the CommonJS export names for ESM import in node:
1674
1824
  0 && (module.exports = {
1825
+ ACTION,
1675
1826
  AITranslateText,
1676
1827
  AITranslationProvider,
1677
1828
  AI_TRANSLATION_FEATURE_FLAG_KEY,
1829
+ BUTTON_TYPE,
1830
+ buildAnalyticEvent,
1831
+ buildEventKey,
1832
+ buildObject,
1678
1833
  getAITranslationLDId,
1834
+ isSupportedBrowser,
1835
+ useAIAnalytics,
1679
1836
  useAITranslation,
1680
1837
  useConfig
1681
1838
  });