@mx-cartographer/experiences 9.7.17 → 9.7.18
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.
- package/CHANGELOG.md +6 -0
- package/dist/core/api/BeatApi.d.ts +15 -2
- package/dist/core/api/BeatApi.es.js +8 -7
- package/dist/core/api/BeatApi.es.js.map +1 -1
- package/dist/core/constants/ApiEndpoints.d.ts +1 -0
- package/dist/core/constants/ApiEndpoints.es.js +1 -0
- package/dist/core/constants/ApiEndpoints.es.js.map +1 -1
- package/dist/core/stores/BeatStore.d.ts +2 -2
- package/dist/core/stores/BeatStore.es.js +29 -29
- package/dist/core/stores/BeatStore.es.js.map +1 -1
- package/dist/microinsights/InsightsMicroWidget.es.js +39 -38
- package/dist/microinsights/InsightsMicroWidget.es.js.map +1 -1
- package/dist/microinsights/beatActions.d.ts +21 -0
- package/dist/microinsights/beatActions.es.js +23 -0
- package/dist/microinsights/beatActions.es.js.map +1 -0
- package/dist/microinsights/cards/InlineActionBlock.d.ts +16 -0
- package/dist/microinsights/cards/InlineActionBlock.es.js +41 -0
- package/dist/microinsights/cards/InlineActionBlock.es.js.map +1 -0
- package/dist/microinsights/cards/InsightCard.es.js +68 -61
- package/dist/microinsights/cards/InsightCard.es.js.map +1 -1
- package/dist/microinsights/carousel/BeatList.es.js +17 -16
- package/dist/microinsights/carousel/BeatList.es.js.map +1 -1
- package/dist/microinsights/carousel/MicroBeatCarousel.d.ts +1 -0
- package/dist/microinsights/carousel/MicroBeatCarousel.es.js +34 -33
- package/dist/microinsights/carousel/MicroBeatCarousel.es.js.map +1 -1
- package/dist/microinsights/context/hooks.es.js +11 -6
- package/dist/microinsights/context/hooks.es.js.map +1 -1
- package/dist/microinsights/interfaces.d.ts +12 -0
- package/dist/microinsights/stores/InsightsMicroWidgetStore.d.ts +3 -1
- package/dist/microinsights/stores/InsightsMicroWidgetStore.es.js +18 -17
- package/dist/microinsights/stores/InsightsMicroWidgetStore.es.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## [9.7.18] - 10-21-2026
|
|
2
|
+
|
|
3
|
+
- **ADDED** - `inDescriptionCtaBehavior?: 'internal' | 'external'` (default `'external'`) on `InsightsMicroWidget`. With `'internal'`, tapping an Insights 2.0 card opens the `insights_payload.in_description_cta` block in place instead of calling `onCardClick`; legacy beats and V2 beats with no drawer block there keep the host redirect. Analytics still fire. Without a `GlobalDataProvider` around the widget, a tap keeps the host's `onCardClick` instead of throwing (WEC-1999)
|
|
4
|
+
- **CHANGED** - `BeatApi.getBeats` and `BeatStore.loadBeats` take a `widgetType` (default `'micro'`) and send it as `widget_type` on `GET /beats`, so firefly returns the micro envelope for Insights 2.0 beats. Callers that pass nothing now get `micro` (WEC-1999)
|
|
5
|
+
- **ADDED** - `buildMicroBeatActions` supplies the host actions for the in-place block: `onAnalyticsEvent` routes to the micro analytics session and PostHog, and `onSubmitFeedback` posts the survey answer to firefly (`BeatApi.sendBeatFeedback`, `POST /beat_feedback`; a failed request rejects so the survey shows its error and Try Again) (WEC-1999)
|
|
6
|
+
|
|
1
7
|
## [9.7.17] - 10-20-2026
|
|
2
8
|
|
|
3
9
|
- **CHANGED** - `withdrawal_block` reads the Emergency Fund Withdrawal card flat from `instance_slot` (`amount`, `amount_label`, `withdrawal_date`, `balance`, `balance_label` beside `block` and `variant`, no `data.series`), matching ditto's `WithdrawalBlock`. `InstanceSlot` declares the four new fields and the mock mirrors the envelope tupac sends (WEC-1941)
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import { Fetch } from '../utils';
|
|
2
|
-
import { Beat, GlobalErrorHandler } from '..';
|
|
2
|
+
import { Beat, GlobalErrorHandler, WidgetType } from '..';
|
|
3
|
+
/** Body of `POST /beat_feedback` (firefly permits these four; `rating` is 1 to 5 and optional). */
|
|
4
|
+
export interface BeatFeedbackRequest {
|
|
5
|
+
beat_guid: string;
|
|
6
|
+
template: string;
|
|
7
|
+
comments: string;
|
|
8
|
+
rating?: number;
|
|
9
|
+
}
|
|
3
10
|
export declare class BeatApi {
|
|
4
11
|
fetchInstance: Fetch;
|
|
5
12
|
constructor(endpoint: string, token: string, onError?: GlobalErrorHandler);
|
|
6
|
-
|
|
13
|
+
/** `widgetType` picks the envelope firefly returns for an Insights 2.0 beat; defaults to `micro`. */
|
|
14
|
+
getBeats: (pageNum?: number, perPage?: number, widgetType?: WidgetType) => Promise<any>;
|
|
7
15
|
/**
|
|
8
16
|
* The transactions widget's one beat fetch: the row pill and the details-drawer card both render
|
|
9
17
|
* from what it returns, so it asks for the `embedded` envelope (Insights 2.0). A flagged beat
|
|
@@ -14,4 +22,9 @@ export declare class BeatApi {
|
|
|
14
22
|
getOffers: () => Promise<any>;
|
|
15
23
|
updateBeat: (beat: Beat) => Promise<any>;
|
|
16
24
|
updateOffer: (beat: Beat) => Promise<any>;
|
|
25
|
+
/**
|
|
26
|
+
* Rejects with an `ApiError` when firefly does not accept the feedback, so a caller (the survey
|
|
27
|
+
* dialog) can show its error state and offer a retry.
|
|
28
|
+
*/
|
|
29
|
+
sendBeatFeedback: (feedback: BeatFeedbackRequest) => Promise<any>;
|
|
17
30
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { ApiEndpoints as n } from "../constants/ApiEndpoints.es.js";
|
|
2
|
-
import { Fetch as
|
|
3
|
-
var
|
|
2
|
+
import { Fetch as r } from "../utils/Fetch.es.js";
|
|
3
|
+
var o = class {
|
|
4
4
|
fetchInstance;
|
|
5
5
|
constructor(t, e, s) {
|
|
6
|
-
this.fetchInstance = new
|
|
6
|
+
this.fetchInstance = new r(t, e, void 0, s);
|
|
7
7
|
}
|
|
8
|
-
getBeats = async (t, e) => {
|
|
9
|
-
const
|
|
10
|
-
return this.fetchInstance.get(`${n.BEATS}?${
|
|
8
|
+
getBeats = async (t, e, s = "micro") => {
|
|
9
|
+
const a = `page=${t || 1}&per_page=${e || 5}&widget_type=${s}`;
|
|
10
|
+
return this.fetchInstance.get(`${n.BEATS}?${a}`).then((c) => c.beats);
|
|
11
11
|
};
|
|
12
12
|
getBeatsWithAssociatedTransaction = async (t) => {
|
|
13
13
|
let e = "has_associated_transaction_guid=true&widget_type=embedded";
|
|
@@ -16,9 +16,10 @@ var h = class {
|
|
|
16
16
|
getOffers = async () => this.fetchInstance.get(`${n.OFFERS}/${n.PULSE_COMMUNICATIONS}`).then((t) => t.pulse_communications);
|
|
17
17
|
updateBeat = async (t) => this.fetchInstance.put(`${n.BEATS}/${t.guid}`, t).then((e) => e.beat);
|
|
18
18
|
updateOffer = async (t) => this.fetchInstance.put(`${n.OFFERS}/${t.guid}`, t).then((e) => e.beat);
|
|
19
|
+
sendBeatFeedback = async (t) => this.fetchInstance.post(n.BEAT_FEEDBACK, t);
|
|
19
20
|
};
|
|
20
21
|
export {
|
|
21
|
-
|
|
22
|
+
o as BeatApi
|
|
22
23
|
};
|
|
23
24
|
|
|
24
25
|
//# sourceMappingURL=BeatApi.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BeatApi.es.js","names":[],"sources":["../../../src/core/api/BeatApi.ts"],"sourcesContent":["import { Fetch } from '../utils'\nimport { ApiEndpoints } from '../constants'\nimport type { Beat, GlobalErrorHandler } from '..'\n\nexport class BeatApi {\n fetchInstance: Fetch\n\n constructor(endpoint: string, token: string, onError?: GlobalErrorHandler) {\n this.fetchInstance = new Fetch(endpoint, token, undefined, onError)\n }\n\n getBeats = async (pageNum?: number, perPage?: number) => {\n const beatParams = `page=${pageNum ? pageNum : 1}&per_page=${perPage ? perPage : 5}`\n\n return this.fetchInstance.get(`${ApiEndpoints.BEATS}?${beatParams}`).then((data) => data.beats)\n }\n\n /**\n * The transactions widget's one beat fetch: the row pill and the details-drawer card both render\n * from what it returns, so it asks for the `embedded` envelope (Insights 2.0). A flagged beat\n * arrives with `is_insights_v2: true` and its `insights_payload` (`pill`, compact slot); a legacy\n * beat is unchanged. There is deliberately no per-drawer fetch and no pills endpoint.\n */\n getBeatsWithAssociatedTransaction = async (fromDate?: string) => {\n let beatParams = 'has_associated_transaction_guid=true&widget_type=embedded'\n beatParams += fromDate ? `&from_date=${fromDate}` : ''\n\n return this.fetchInstance.get(`${ApiEndpoints.BEATS}?${beatParams}`).then((data) => data.beats)\n }\n\n getOffers = async () => {\n return this.fetchInstance\n .get(`${ApiEndpoints.OFFERS}/${ApiEndpoints.PULSE_COMMUNICATIONS}`)\n .then((data) => data.pulse_communications)\n }\n\n updateBeat = async (beat: Beat) => {\n return this.fetchInstance\n .put(`${ApiEndpoints.BEATS}/${beat.guid}`, beat)\n .then((data) => data.beat)\n }\n\n updateOffer = async (beat: Beat) => {\n return this.fetchInstance\n .put(`${ApiEndpoints.OFFERS}/${beat.guid}`, beat)\n .then((data) => data.beat)\n }\n}\n"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"BeatApi.es.js","names":[],"sources":["../../../src/core/api/BeatApi.ts"],"sourcesContent":["import { Fetch } from '../utils'\nimport { ApiEndpoints } from '../constants'\nimport type { Beat, GlobalErrorHandler, WidgetType } from '..'\n\n/** Body of `POST /beat_feedback` (firefly permits these four; `rating` is 1 to 5 and optional). */\nexport interface BeatFeedbackRequest {\n beat_guid: string\n template: string\n comments: string\n rating?: number\n}\n\nexport class BeatApi {\n fetchInstance: Fetch\n\n constructor(endpoint: string, token: string, onError?: GlobalErrorHandler) {\n this.fetchInstance = new Fetch(endpoint, token, undefined, onError)\n }\n\n /** `widgetType` picks the envelope firefly returns for an Insights 2.0 beat; defaults to `micro`. */\n getBeats = async (pageNum?: number, perPage?: number, widgetType: WidgetType = 'micro') => {\n const beatParams = `page=${pageNum ? pageNum : 1}&per_page=${perPage ? perPage : 5}&widget_type=${widgetType}`\n\n return this.fetchInstance.get(`${ApiEndpoints.BEATS}?${beatParams}`).then((data) => data.beats)\n }\n\n /**\n * The transactions widget's one beat fetch: the row pill and the details-drawer card both render\n * from what it returns, so it asks for the `embedded` envelope (Insights 2.0). A flagged beat\n * arrives with `is_insights_v2: true` and its `insights_payload` (`pill`, compact slot); a legacy\n * beat is unchanged. There is deliberately no per-drawer fetch and no pills endpoint.\n */\n getBeatsWithAssociatedTransaction = async (fromDate?: string) => {\n let beatParams = 'has_associated_transaction_guid=true&widget_type=embedded'\n beatParams += fromDate ? `&from_date=${fromDate}` : ''\n\n return this.fetchInstance.get(`${ApiEndpoints.BEATS}?${beatParams}`).then((data) => data.beats)\n }\n\n getOffers = async () => {\n return this.fetchInstance\n .get(`${ApiEndpoints.OFFERS}/${ApiEndpoints.PULSE_COMMUNICATIONS}`)\n .then((data) => data.pulse_communications)\n }\n\n updateBeat = async (beat: Beat) => {\n return this.fetchInstance\n .put(`${ApiEndpoints.BEATS}/${beat.guid}`, beat)\n .then((data) => data.beat)\n }\n\n updateOffer = async (beat: Beat) => {\n return this.fetchInstance\n .put(`${ApiEndpoints.OFFERS}/${beat.guid}`, beat)\n .then((data) => data.beat)\n }\n\n /**\n * Rejects with an `ApiError` when firefly does not accept the feedback, so a caller (the survey\n * dialog) can show its error state and offer a retry.\n */\n sendBeatFeedback = async (feedback: BeatFeedbackRequest) => {\n return this.fetchInstance.post(ApiEndpoints.BEAT_FEEDBACK, feedback)\n }\n}\n"],"mappings":";;AAYA,IAAa,IAAb,MAAqB;AAAA,EACnB;AAAA,EAEA,YAAY,GAAkB,GAAe,GAA8B;AACzE,SAAK,gBAAgB,IAAI,EAAM,GAAU,GAAO,QAAW,CAAO;AAAA,EACpE;AAAA,EAGA,WAAW,OAAO,GAAkB,GAAkB,IAAyB,YAAY;AACzF,UAAM,IAAa,QAAQ,KAAoB,CAAA,aAAc,KAAoB,CAAA,gBAAiB,CAAA;AAElG,WAAO,KAAK,cAAc,IAAI,GAAG,EAAa,KAAA,IAAS,CAAA,EAAY,EAAE,KAAA,CAAM,MAAS,EAAK,KAAK;AAAA,EAChG;AAAA,EAQA,oCAAoC,OAAO,MAAsB;AAC/D,QAAI,IAAa;AACjB,WAAA,KAAc,IAAW,cAAc,CAAA,KAAa,IAE7C,KAAK,cAAc,IAAI,GAAG,EAAa,KAAA,IAAS,CAAA,EAAY,EAAE,KAAA,CAAM,MAAS,EAAK,KAAK;AAAA,EAChG;AAAA,EAEA,YAAY,YACH,KAAK,cACT,IAAI,GAAG,EAAa,MAAA,IAAU,EAAa,oBAAA,EAAsB,EACjE,KAAA,CAAM,MAAS,EAAK,oBAAoB;AAAA,EAG7C,aAAa,OAAO,MACX,KAAK,cACT,IAAI,GAAG,EAAa,KAAA,IAAS,EAAK,IAAA,IAAQ,CAAI,EAC9C,KAAA,CAAM,MAAS,EAAK,IAAI;AAAA,EAG7B,cAAc,OAAO,MACZ,KAAK,cACT,IAAI,GAAG,EAAa,MAAA,IAAU,EAAK,IAAA,IAAQ,CAAI,EAC/C,KAAA,CAAM,MAAS,EAAK,IAAI;AAAA,EAO7B,mBAAmB,OAAO,MACjB,KAAK,cAAc,KAAK,EAAa,eAAe,CAAQ;AAEvE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiEndpoints.es.js","names":[],"sources":["../../../src/core/constants/ApiEndpoints.ts"],"sourcesContent":["export const ApiEndpoints = {\n ACCOUNTS: 'accounts',\n AGREEMENT: 'agreement',\n ANALYTICS_EVENTS: 'analytics_events',\n ANALYTICS_FEATURE_VISITS: 'feature_visits',\n ANALYTICS_PAGEVIEWS: 'analytics_pageviews',\n ANALYTICS_SESSION: 'analytics_sessions',\n APP_DATA: 'raja/data?type=master',\n BEATS: 'beats',\n BUDGETS: 'budgets',\n CATEGORIES: 'categories',\n CHANGE_PASSWORD: 'user/change_password',\n DATE_RANGE_CATEGORY_TOTALS: 'date_range_category_totals',\n DEVICES: 'devices',\n EMAIL_VERIFICATIONS: 'email_verifications',\n GOALS: 'goals',\n HEALTH_SCORES: 'health_scores',\n HOLDINGS: 'holdings',\n INSTITUTIONS: 'institutions',\n INSIGHTS_NOTIFICATION_PROFILES: 'insight_notification_profiles',\n LOCALIZED_COPY: 'localized_copies',\n LOCALIZED_CONTENT: 'localized_content',\n MEMBERS: 'members',\n MERCHANTS: 'merchants',\n MERCHANT_BUDGETS: 'merchant_budgets',\n MONTHLY_CASH_FLOW_PROFILE: 'monthly_cash_flow_profile',\n MONTHLY_CATEGORY_TOTALS: 'monthly_category_totals',\n OFFERS: 'offers',\n NOTIFICATION_PROFILES: 'notification_profiles',\n NOTIFICATIONS: 'notifications',\n PHONE_VERIFICATIONS: 'sms_verification',\n PULSE_COMMUNICATIONS: 'pulse_communications',\n REPEATING_TRANSACTIONS: 'repeating_transactions',\n RETIREMENT_GOALS: 'retirement_goals',\n RETIREMENT_GOAL_ACCOUNTS: 'retirement_goal_accounts',\n SCHEDULED_PAYMENTS: 'scheduled_payments',\n SPENDING_PLANS: 'spending_plans',\n SUPPORT_TICKETS: 'support_tickets',\n TAGGINGS: 'taggings',\n TAGS: 'tags',\n TRANSACTION_RULES: 'transaction_rules',\n TRANSACTIONS: 'transactions',\n USER: 'user',\n USER_COMMUNICATION_PROFILE: 'user_communication_profile',\n USER_FEATURES: 'user_features',\n USER_INSIGHT_PROFILE: 'user_insight_profile',\n USER_PROFILES: 'user_profiles',\n WIDGET_URLS: 'widget_urls',\n}\n"],"mappings":"AAAA,IAAa,IAAe;AAAA,EAC1B,UAAU;AAAA,EACV,WAAW;AAAA,EACX,kBAAkB;AAAA,EAClB,0BAA0B;AAAA,EAC1B,qBAAqB;AAAA,EACrB,mBAAmB;AAAA,EACnB,UAAU;AAAA,EACV,OAAO;AAAA,EACP,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,4BAA4B;AAAA,EAC5B,SAAS;AAAA,EACT,qBAAqB;AAAA,EACrB,OAAO;AAAA,EACP,eAAe;AAAA,EACf,UAAU;AAAA,EACV,cAAc;AAAA,EACd,gCAAgC;AAAA,EAChC,gBAAgB;AAAA,EAChB,mBAAmB;AAAA,EACnB,SAAS;AAAA,EACT,WAAW;AAAA,EACX,kBAAkB;AAAA,EAClB,2BAA2B;AAAA,EAC3B,yBAAyB;AAAA,EACzB,QAAQ;AAAA,EACR,uBAAuB;AAAA,EACvB,eAAe;AAAA,EACf,qBAAqB;AAAA,EACrB,sBAAsB;AAAA,EACtB,wBAAwB;AAAA,EACxB,kBAAkB;AAAA,EAClB,0BAA0B;AAAA,EAC1B,oBAAoB;AAAA,EACpB,gBAAgB;AAAA,EAChB,iBAAiB;AAAA,EACjB,UAAU;AAAA,EACV,MAAM;AAAA,EACN,mBAAmB;AAAA,EACnB,cAAc;AAAA,EACd,MAAM;AAAA,EACN,4BAA4B;AAAA,EAC5B,eAAe;AAAA,EACf,sBAAsB;AAAA,EACtB,eAAe;AAAA,EACf,aAAa;AACf"}
|
|
1
|
+
{"version":3,"file":"ApiEndpoints.es.js","names":[],"sources":["../../../src/core/constants/ApiEndpoints.ts"],"sourcesContent":["export const ApiEndpoints = {\n ACCOUNTS: 'accounts',\n AGREEMENT: 'agreement',\n ANALYTICS_EVENTS: 'analytics_events',\n ANALYTICS_FEATURE_VISITS: 'feature_visits',\n ANALYTICS_PAGEVIEWS: 'analytics_pageviews',\n ANALYTICS_SESSION: 'analytics_sessions',\n APP_DATA: 'raja/data?type=master',\n BEAT_FEEDBACK: 'beat_feedback',\n BEATS: 'beats',\n BUDGETS: 'budgets',\n CATEGORIES: 'categories',\n CHANGE_PASSWORD: 'user/change_password',\n DATE_RANGE_CATEGORY_TOTALS: 'date_range_category_totals',\n DEVICES: 'devices',\n EMAIL_VERIFICATIONS: 'email_verifications',\n GOALS: 'goals',\n HEALTH_SCORES: 'health_scores',\n HOLDINGS: 'holdings',\n INSTITUTIONS: 'institutions',\n INSIGHTS_NOTIFICATION_PROFILES: 'insight_notification_profiles',\n LOCALIZED_COPY: 'localized_copies',\n LOCALIZED_CONTENT: 'localized_content',\n MEMBERS: 'members',\n MERCHANTS: 'merchants',\n MERCHANT_BUDGETS: 'merchant_budgets',\n MONTHLY_CASH_FLOW_PROFILE: 'monthly_cash_flow_profile',\n MONTHLY_CATEGORY_TOTALS: 'monthly_category_totals',\n OFFERS: 'offers',\n NOTIFICATION_PROFILES: 'notification_profiles',\n NOTIFICATIONS: 'notifications',\n PHONE_VERIFICATIONS: 'sms_verification',\n PULSE_COMMUNICATIONS: 'pulse_communications',\n REPEATING_TRANSACTIONS: 'repeating_transactions',\n RETIREMENT_GOALS: 'retirement_goals',\n RETIREMENT_GOAL_ACCOUNTS: 'retirement_goal_accounts',\n SCHEDULED_PAYMENTS: 'scheduled_payments',\n SPENDING_PLANS: 'spending_plans',\n SUPPORT_TICKETS: 'support_tickets',\n TAGGINGS: 'taggings',\n TAGS: 'tags',\n TRANSACTION_RULES: 'transaction_rules',\n TRANSACTIONS: 'transactions',\n USER: 'user',\n USER_COMMUNICATION_PROFILE: 'user_communication_profile',\n USER_FEATURES: 'user_features',\n USER_INSIGHT_PROFILE: 'user_insight_profile',\n USER_PROFILES: 'user_profiles',\n WIDGET_URLS: 'widget_urls',\n}\n"],"mappings":"AAAA,IAAa,IAAe;AAAA,EAC1B,UAAU;AAAA,EACV,WAAW;AAAA,EACX,kBAAkB;AAAA,EAClB,0BAA0B;AAAA,EAC1B,qBAAqB;AAAA,EACrB,mBAAmB;AAAA,EACnB,UAAU;AAAA,EACV,eAAe;AAAA,EACf,OAAO;AAAA,EACP,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,4BAA4B;AAAA,EAC5B,SAAS;AAAA,EACT,qBAAqB;AAAA,EACrB,OAAO;AAAA,EACP,eAAe;AAAA,EACf,UAAU;AAAA,EACV,cAAc;AAAA,EACd,gCAAgC;AAAA,EAChC,gBAAgB;AAAA,EAChB,mBAAmB;AAAA,EACnB,SAAS;AAAA,EACT,WAAW;AAAA,EACX,kBAAkB;AAAA,EAClB,2BAA2B;AAAA,EAC3B,yBAAyB;AAAA,EACzB,QAAQ;AAAA,EACR,uBAAuB;AAAA,EACvB,eAAe;AAAA,EACf,qBAAqB;AAAA,EACrB,sBAAsB;AAAA,EACtB,wBAAwB;AAAA,EACxB,kBAAkB;AAAA,EAClB,0BAA0B;AAAA,EAC1B,oBAAoB;AAAA,EACpB,gBAAgB;AAAA,EAChB,iBAAiB;AAAA,EACjB,UAAU;AAAA,EACV,MAAM;AAAA,EACN,mBAAmB;AAAA,EACnB,cAAc;AAAA,EACd,MAAM;AAAA,EACN,4BAA4B;AAAA,EAC5B,eAAe;AAAA,EACf,sBAAsB;AAAA,EACtB,eAAe;AAAA,EACf,aAAa;AACf"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BeatApi } from '../api';
|
|
2
|
-
import { Beat } from '../types';
|
|
2
|
+
import { Beat, WidgetType } from '../types';
|
|
3
3
|
import { GlobalStore } from './GlobalStore';
|
|
4
4
|
export declare class BeatStore {
|
|
5
5
|
globalStore: GlobalStore;
|
|
@@ -7,7 +7,7 @@ export declare class BeatStore {
|
|
|
7
7
|
beats: Beat[];
|
|
8
8
|
isLoading: boolean;
|
|
9
9
|
constructor(globalStore: GlobalStore);
|
|
10
|
-
loadBeats: () => Promise<void>;
|
|
10
|
+
loadBeats: (widgetType?: WidgetType) => Promise<void>;
|
|
11
11
|
/**
|
|
12
12
|
* Persists changes to an offer-backed beat (pulse marketing offers, `PUT offers/:guid`),
|
|
13
13
|
* e.g. flagging `has_been_clicked` when its CTA is pressed. Rethrows so callers driving
|
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
import { BeatApi as
|
|
1
|
+
import { BeatApi as s } from "../api/BeatApi.es.js";
|
|
2
2
|
import { orderArray as o, transformOfferIntoBeatLikeObject as n } from "../utils/BeatUtils.es.js";
|
|
3
|
-
import { makeAutoObservable as f, runInAction as
|
|
4
|
-
var
|
|
3
|
+
import { makeAutoObservable as f, runInAction as i } from "mobx";
|
|
4
|
+
var d = class {
|
|
5
5
|
globalStore;
|
|
6
|
-
api = new
|
|
6
|
+
api = new s("/", "");
|
|
7
7
|
beats = [];
|
|
8
8
|
isLoading = !1;
|
|
9
|
-
constructor(
|
|
10
|
-
this.globalStore =
|
|
9
|
+
constructor(e) {
|
|
10
|
+
this.globalStore = e, this.api = new s(e.endpoint, e.sessionToken, e.onError), f(this);
|
|
11
11
|
}
|
|
12
|
-
loadBeats = async () => {
|
|
12
|
+
loadBeats = async (e = "micro") => {
|
|
13
13
|
this.isLoading = !0;
|
|
14
14
|
try {
|
|
15
|
-
const t = await this.api.getBeats(
|
|
16
|
-
|
|
17
|
-
this.beats = o(t,
|
|
15
|
+
const t = await this.api.getBeats(void 0, void 0, e), r = (await this.api.getOffers()).map((a) => n(a));
|
|
16
|
+
i(() => {
|
|
17
|
+
this.beats = o(t, r, "active_at", "desc");
|
|
18
18
|
});
|
|
19
19
|
} catch (t) {
|
|
20
20
|
this.captureError("loadBeats", t);
|
|
21
21
|
} finally {
|
|
22
|
-
|
|
22
|
+
i(() => {
|
|
23
23
|
this.isLoading = !1;
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
|
-
updateOffer = async (
|
|
27
|
+
updateOffer = async (e) => {
|
|
28
28
|
try {
|
|
29
|
-
const
|
|
30
|
-
return
|
|
31
|
-
this.beats = this.beats.map((r) => r.guid ===
|
|
29
|
+
const t = await this.api.updateOffer(e);
|
|
30
|
+
return i(() => {
|
|
31
|
+
this.beats = this.beats.map((r) => r.guid === e.guid ? {
|
|
32
32
|
...r,
|
|
33
|
-
...
|
|
33
|
+
...t
|
|
34
34
|
} : r);
|
|
35
|
-
}),
|
|
36
|
-
} catch (
|
|
37
|
-
throw this.captureError("updateOffer",
|
|
35
|
+
}), t;
|
|
36
|
+
} catch (t) {
|
|
37
|
+
throw this.captureError("updateOffer", t), t;
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
|
-
getFilteredBeats(
|
|
41
|
-
const { categoryGuids:
|
|
40
|
+
getFilteredBeats(e) {
|
|
41
|
+
const { categoryGuids: t, templates: r } = e;
|
|
42
42
|
let a = this.beats;
|
|
43
|
-
return
|
|
43
|
+
return t && (a = this.filterBeatsByCategory(a, t)), r && (a = this.filterBeatsByTemplate(a, r)), a;
|
|
44
44
|
}
|
|
45
|
-
filterBeatsByCategory(
|
|
46
|
-
return
|
|
45
|
+
filterBeatsByCategory(e, t) {
|
|
46
|
+
return e.filter((r) => r.category_guids?.some((a) => t.includes(a)));
|
|
47
47
|
}
|
|
48
|
-
filterBeatsByTemplate(
|
|
49
|
-
return
|
|
48
|
+
filterBeatsByTemplate(e, t) {
|
|
49
|
+
return e.filter((r) => t.some((a) => r.template === a));
|
|
50
50
|
}
|
|
51
|
-
captureError = (
|
|
51
|
+
captureError = (e, t) => this.globalStore.captureException(t, {
|
|
52
52
|
store: "BeatStore",
|
|
53
|
-
action:
|
|
53
|
+
action: e
|
|
54
54
|
});
|
|
55
55
|
};
|
|
56
56
|
export {
|
|
57
|
-
|
|
57
|
+
d as BeatStore
|
|
58
58
|
};
|
|
59
59
|
|
|
60
60
|
//# sourceMappingURL=BeatStore.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BeatStore.es.js","names":[],"sources":["../../../src/core/stores/BeatStore.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from 'mobx'\n\nimport { BeatApi } from '../api'\nimport type { Beat, Offer } from '../types'\nimport { orderArray, transformOfferIntoBeatLikeObject } from '../utils/BeatUtils'\n\nimport { GlobalStore } from './GlobalStore'\n\nexport class BeatStore {\n globalStore: GlobalStore\n api: BeatApi = new BeatApi('/', '')\n beats: Beat[] = []\n isLoading = false\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.api = new BeatApi(globalStore.endpoint, globalStore.sessionToken, globalStore.onError)\n\n makeAutoObservable(this)\n }\n\n loadBeats = async () => {\n this.isLoading = true\n try {\n const beats = await this.api.getBeats()\n const offers = await this.api.getOffers()\n const beatLikeOffers = offers.map((o: Offer) => transformOfferIntoBeatLikeObject(o))\n\n runInAction(() => {\n this.beats = orderArray(beats, beatLikeOffers, 'active_at', 'desc')\n })\n } catch (error) {\n this.captureError('loadBeats', error)\n } finally {\n runInAction(() => {\n this.isLoading = false\n })\n }\n }\n\n /**\n * Persists changes to an offer-backed beat (pulse marketing offers, `PUT offers/:guid`),\n * e.g. flagging `has_been_clicked` when its CTA is pressed. Rethrows so callers driving\n * UI state can surface the failure.\n */\n updateOffer = async (beat: Beat) => {\n try {\n const updated = await this.api.updateOffer(beat)\n\n runInAction(() => {\n this.beats = this.beats.map((b) => (b.guid === beat.guid ? { ...b, ...updated } : b))\n })\n\n return updated\n } catch (error) {\n this.captureError('updateOffer', error)\n throw error\n }\n }\n\n getFilteredBeats(filter: { categoryGuids?: string[]; templates?: string[] }): Beat[] {\n const { categoryGuids, templates } = filter\n let filteredBeats = this.beats\n if (categoryGuids) filteredBeats = this.filterBeatsByCategory(filteredBeats, categoryGuids)\n if (templates) filteredBeats = this.filterBeatsByTemplate(filteredBeats, templates)\n return filteredBeats\n }\n\n // Return beats with any beat.category_guids that are in categoryGuids\n filterBeatsByCategory(beats: Beat[], categoryGuids: string[]): Beat[] {\n return beats.filter((beat) => {\n return beat.category_guids?.some((guid) => categoryGuids.includes(guid))\n })\n }\n\n // Return beats with a beat.template that is in templates\n filterBeatsByTemplate(beats: Beat[], templates: string[]): Beat[] {\n return beats.filter((beat) => {\n return templates.some((template) => beat.template === template)\n })\n }\n\n private captureError = (action: string, error: unknown) =>\n this.globalStore.captureException(error, { store: 'BeatStore', action })\n}\n"],"mappings":";;;AAQA,IAAa,IAAb,MAAuB;AAAA,EACrB;AAAA,EACA,MAAe,IAAI,EAAQ,KAAK,EAAE;AAAA,EAClC,QAAgB,CAAC;AAAA,EACjB,YAAY;AAAA,EAEZ,YAAY,GAA0B;AACpC,SAAK,cAAc,GACnB,KAAK,MAAM,IAAI,EAAQ,EAAY,UAAU,EAAY,cAAc,EAAY,OAAO,GAE1F,EAAmB,IAAI;AAAA,EACzB;AAAA,EAEA,YAAY,YAAY;
|
|
1
|
+
{"version":3,"file":"BeatStore.es.js","names":[],"sources":["../../../src/core/stores/BeatStore.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from 'mobx'\n\nimport { BeatApi } from '../api'\nimport type { Beat, Offer, WidgetType } from '../types'\nimport { orderArray, transformOfferIntoBeatLikeObject } from '../utils/BeatUtils'\n\nimport { GlobalStore } from './GlobalStore'\n\nexport class BeatStore {\n globalStore: GlobalStore\n api: BeatApi = new BeatApi('/', '')\n beats: Beat[] = []\n isLoading = false\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.api = new BeatApi(globalStore.endpoint, globalStore.sessionToken, globalStore.onError)\n\n makeAutoObservable(this)\n }\n\n loadBeats = async (widgetType: WidgetType = 'micro') => {\n this.isLoading = true\n try {\n const beats = await this.api.getBeats(undefined, undefined, widgetType)\n const offers = await this.api.getOffers()\n const beatLikeOffers = offers.map((o: Offer) => transformOfferIntoBeatLikeObject(o))\n\n runInAction(() => {\n this.beats = orderArray(beats, beatLikeOffers, 'active_at', 'desc')\n })\n } catch (error) {\n this.captureError('loadBeats', error)\n } finally {\n runInAction(() => {\n this.isLoading = false\n })\n }\n }\n\n /**\n * Persists changes to an offer-backed beat (pulse marketing offers, `PUT offers/:guid`),\n * e.g. flagging `has_been_clicked` when its CTA is pressed. Rethrows so callers driving\n * UI state can surface the failure.\n */\n updateOffer = async (beat: Beat) => {\n try {\n const updated = await this.api.updateOffer(beat)\n\n runInAction(() => {\n this.beats = this.beats.map((b) => (b.guid === beat.guid ? { ...b, ...updated } : b))\n })\n\n return updated\n } catch (error) {\n this.captureError('updateOffer', error)\n throw error\n }\n }\n\n getFilteredBeats(filter: { categoryGuids?: string[]; templates?: string[] }): Beat[] {\n const { categoryGuids, templates } = filter\n let filteredBeats = this.beats\n if (categoryGuids) filteredBeats = this.filterBeatsByCategory(filteredBeats, categoryGuids)\n if (templates) filteredBeats = this.filterBeatsByTemplate(filteredBeats, templates)\n return filteredBeats\n }\n\n // Return beats with any beat.category_guids that are in categoryGuids\n filterBeatsByCategory(beats: Beat[], categoryGuids: string[]): Beat[] {\n return beats.filter((beat) => {\n return beat.category_guids?.some((guid) => categoryGuids.includes(guid))\n })\n }\n\n // Return beats with a beat.template that is in templates\n filterBeatsByTemplate(beats: Beat[], templates: string[]): Beat[] {\n return beats.filter((beat) => {\n return templates.some((template) => beat.template === template)\n })\n }\n\n private captureError = (action: string, error: unknown) =>\n this.globalStore.captureException(error, { store: 'BeatStore', action })\n}\n"],"mappings":";;;AAQA,IAAa,IAAb,MAAuB;AAAA,EACrB;AAAA,EACA,MAAe,IAAI,EAAQ,KAAK,EAAE;AAAA,EAClC,QAAgB,CAAC;AAAA,EACjB,YAAY;AAAA,EAEZ,YAAY,GAA0B;AACpC,SAAK,cAAc,GACnB,KAAK,MAAM,IAAI,EAAQ,EAAY,UAAU,EAAY,cAAc,EAAY,OAAO,GAE1F,EAAmB,IAAI;AAAA,EACzB;AAAA,EAEA,YAAY,OAAO,IAAyB,YAAY;AACtD,SAAK,YAAY;AACjB,QAAI;AACF,YAAM,IAAQ,MAAM,KAAK,IAAI,SAAS,QAAW,QAAW,CAAU,GAEhE,KAAiB,MADF,KAAK,IAAI,UAAU,GACV,IAAA,CAAK,MAAa,EAAiC,CAAC,CAAC;AAEnF,MAAA,EAAA,MAAkB;AAChB,aAAK,QAAQ,EAAW,GAAO,GAAgB,aAAa,MAAM;AAAA,MACpE,CAAC;AAAA,IACH,SAAS,GAAO;AACd,WAAK,aAAa,aAAa,CAAK;AAAA,IACtC,UAAA;AACE,MAAA,EAAA,MAAkB;AAChB,aAAK,YAAY;AAAA,MACnB,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EAOA,cAAc,OAAO,MAAe;AAClC,QAAI;AACF,YAAM,IAAU,MAAM,KAAK,IAAI,YAAY,CAAI;AAE/C,aAAA,EAAA,MAAkB;AAChB,aAAK,QAAQ,KAAK,MAAM,IAAA,CAAK,MAAO,EAAE,SAAS,EAAK,OAAO;AAAA,UAAE,GAAG;AAAA,UAAG,GAAG;AAAA,QAAQ,IAAI,CAAE;AAAA,MACtF,CAAC,GAEM;AAAA,IACT,SAAS,GAAO;AACd,iBAAK,aAAa,eAAe,CAAK,GAChC;AAAA,IACR;AAAA,EACF;AAAA,EAEA,iBAAiB,GAAoE;AACnF,UAAM,EAAE,eAAA,GAAe,WAAA,EAAA,IAAc;AACrC,QAAI,IAAgB,KAAK;AACzB,WAAI,MAAe,IAAgB,KAAK,sBAAsB,GAAe,CAAa,IACtF,MAAW,IAAgB,KAAK,sBAAsB,GAAe,CAAS,IAC3E;AAAA,EACT;AAAA,EAGA,sBAAsB,GAAe,GAAiC;AACpE,WAAO,EAAM,OAAA,CAAQ,MACZ,EAAK,gBAAgB,KAAA,CAAM,MAAS,EAAc,SAAS,CAAI,CAAC,CACxE;AAAA,EACH;AAAA,EAGA,sBAAsB,GAAe,GAA6B;AAChE,WAAO,EAAM,OAAA,CAAQ,MACZ,EAAU,KAAA,CAAM,MAAa,EAAK,aAAa,CAAQ,CAC/D;AAAA,EACH;AAAA,EAEA,eAAA,CAAwB,GAAgB,MACtC,KAAK,YAAY,iBAAiB,GAAO;AAAA,IAAE,OAAO;AAAA,IAAa,QAAA;AAAA,EAAO,CAAC;AAC3E"}
|
|
@@ -1,55 +1,56 @@
|
|
|
1
|
-
import { useCombineEvents as
|
|
2
|
-
import { useWidgetLoadTimer as
|
|
3
|
-
import { AppStore as
|
|
4
|
-
import { InsightsMicroWidgetDataProvider as
|
|
5
|
-
import { SUPPORTED_CAROUSEL_HEIGHTS as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import { NoRelevantInsightsCard as
|
|
10
|
-
import { ZeroStateCard as
|
|
11
|
-
import
|
|
1
|
+
import { useCombineEvents as j, useCombinePageviews as $ } from "../common/hooks/useCombineEvents.es.js";
|
|
2
|
+
import { useWidgetLoadTimer as U } from "../common/hooks/useWidgetLoadTimer.es.js";
|
|
3
|
+
import { AppStore as Y } from "./stores/AppStore.es.js";
|
|
4
|
+
import { InsightsMicroWidgetDataProvider as Z } from "./context/InsightsMicroWidgetDataProvider.es.js";
|
|
5
|
+
import { SUPPORTED_CAROUSEL_HEIGHTS as q } from "./constants/App.es.js";
|
|
6
|
+
import B from "./carousel/MicroBeatCarousel.es.js";
|
|
7
|
+
import F from "./carousel/CarouselHeader.es.js";
|
|
8
|
+
import J from "./MicroWidgetContainer.es.js";
|
|
9
|
+
import { NoRelevantInsightsCard as K } from "./cards/NoRelevantInsightsCard.es.js";
|
|
10
|
+
import { ZeroStateCard as Q } from "./cards/ZeroStateCard.es.js";
|
|
11
|
+
import y from "./Spinner.es.js";
|
|
12
12
|
import { TRENDS_ANALYTICS_METADATA as D } from "../trends/constants/TrendsWidget.es.js";
|
|
13
13
|
import c, { useState as p } from "react";
|
|
14
|
-
import { observer as
|
|
14
|
+
import { observer as k } from "mobx-react-lite";
|
|
15
15
|
import M from "@mui/material/Stack";
|
|
16
|
-
import { jsx as e, jsxs as
|
|
17
|
-
var t = new
|
|
16
|
+
import { jsx as e, jsxs as O } from "react/jsx-runtime";
|
|
17
|
+
var t = new Y(), ee = ({ allowSingleCardPeeking: P = !0, areBeatsLoading: d = !1, beats: l = [], cardStyle: a = "elevation 1", endpoint: u = "/", headerSx: L, heightOverrides: n, inDescriptionCtaBehavior: _ = "external", logOutUser: g = () => {
|
|
18
18
|
}, onCardClick: f = () => {
|
|
19
|
-
}, onEvent:
|
|
20
|
-
}, onPageview:
|
|
21
|
-
}, posthog: m, showCarouselControls:
|
|
19
|
+
}, onEvent: C = () => {
|
|
20
|
+
}, onPageview: H = () => {
|
|
21
|
+
}, posthog: m, showCarouselControls: N, showHeader: h, showIcon: v, showWithMargin: E = !0, token: A = "", userHasFullInsightFeedBeats: W, visibleCardsCount: w = 1, widthOverrides: i }) => {
|
|
22
22
|
const I = (() => {
|
|
23
23
|
if (a === "border") return "outlined";
|
|
24
24
|
if (a === "elevation 1") return "elevation";
|
|
25
25
|
if (a !== "flat")
|
|
26
26
|
return "elevation";
|
|
27
|
-
})(), R = a === "flat" ? 0 : 1, [S, s] = p("STANDARD"), [r,
|
|
28
|
-
|
|
27
|
+
})(), R = a === "flat" ? 0 : 1, [S, s] = p("STANDARD"), [r, G] = p(!1), [x, z] = p(!1), V = j([C], t), X = $([H], t);
|
|
28
|
+
U({
|
|
29
29
|
widgetName: "InsightsMicroWidget",
|
|
30
30
|
isLoaded: r
|
|
31
31
|
}), c.useEffect(() => {
|
|
32
|
-
!t.isInitialized && !
|
|
32
|
+
!t.isInitialized && !x && (t.initialize(u, A, g).catch(() => z(!1)), z(!0));
|
|
33
33
|
}, [
|
|
34
34
|
u,
|
|
35
35
|
A,
|
|
36
36
|
g,
|
|
37
37
|
t.isInitialized,
|
|
38
|
-
|
|
38
|
+
x
|
|
39
39
|
]), c.useEffect(() => {
|
|
40
40
|
const o = window.innerHeight;
|
|
41
41
|
o < 180 ? s("STANDARD") : o >= 180 && o < 200 ? s("LARGE") : o >= 200 && o < 248 ? s("XLARGE") : o >= 248 && s("XXLARGE");
|
|
42
42
|
}, [window.innerHeight]), c.useEffect(() => {
|
|
43
|
-
|
|
43
|
+
G(!d && t.isInitialized);
|
|
44
44
|
}, [d, t.isInitialized]);
|
|
45
|
-
const
|
|
45
|
+
const b = {
|
|
46
46
|
heightOverrides: n,
|
|
47
|
+
inDescriptionCtaBehavior: _,
|
|
47
48
|
onCardClick: f,
|
|
48
49
|
posthog: m,
|
|
49
50
|
showIcon: v,
|
|
50
51
|
showWithMargin: E,
|
|
51
52
|
widthOverrides: i
|
|
52
|
-
},
|
|
53
|
+
}, T = {
|
|
53
54
|
carouselSize: S,
|
|
54
55
|
elevation: R,
|
|
55
56
|
variant: I,
|
|
@@ -58,31 +59,31 @@ var t = new U(), O = ({ allowSingleCardPeeking: P = !0, areBeatsLoading: d = !1,
|
|
|
58
59
|
posthog: m,
|
|
59
60
|
showIcon: v
|
|
60
61
|
};
|
|
61
|
-
return /* @__PURE__ */ e(
|
|
62
|
-
onEvent:
|
|
63
|
-
onPageview:
|
|
62
|
+
return /* @__PURE__ */ e(Z, {
|
|
63
|
+
onEvent: V,
|
|
64
|
+
onPageview: X,
|
|
64
65
|
store: t,
|
|
65
|
-
children: /* @__PURE__ */
|
|
66
|
+
children: /* @__PURE__ */ O(J, {
|
|
66
67
|
heightOverrides: n,
|
|
67
68
|
widthOverrides: i,
|
|
68
69
|
children: [
|
|
69
|
-
!r && /* @__PURE__ */ e(
|
|
70
|
-
r &&
|
|
70
|
+
!r && /* @__PURE__ */ e(y, {}),
|
|
71
|
+
r && h && /* @__PURE__ */ e(F, {
|
|
71
72
|
analyticsMetadata: D,
|
|
72
73
|
headerSx: L,
|
|
73
74
|
onCardClick: f,
|
|
74
75
|
posthog: m,
|
|
75
76
|
widthOverrides: i
|
|
76
77
|
}),
|
|
77
|
-
r && !!l.length && /* @__PURE__ */ e(
|
|
78
|
+
r && !!l.length && /* @__PURE__ */ e(B, {
|
|
78
79
|
allowSingleCardPeeking: P,
|
|
79
80
|
analyticsMetadata: D,
|
|
80
81
|
beats: l,
|
|
81
82
|
elevation: R,
|
|
82
|
-
showCarouselControls:
|
|
83
|
+
showCarouselControls: N,
|
|
83
84
|
variant: I,
|
|
84
|
-
visibleCardsCount:
|
|
85
|
-
...
|
|
85
|
+
visibleCardsCount: w,
|
|
86
|
+
...b
|
|
86
87
|
}),
|
|
87
88
|
r && !l.length && /* @__PURE__ */ e(M, {
|
|
88
89
|
sx: {
|
|
@@ -92,18 +93,18 @@ var t = new U(), O = ({ allowSingleCardPeeking: P = !0, areBeatsLoading: d = !1,
|
|
|
92
93
|
},
|
|
93
94
|
children: /* @__PURE__ */ e(M, {
|
|
94
95
|
sx: {
|
|
95
|
-
height: `calc(${
|
|
96
|
+
height: `calc(${q[S]}px - 44px)`,
|
|
96
97
|
width: E ? `calc(${i}px - 32px)` : "100%"
|
|
97
98
|
},
|
|
98
|
-
children:
|
|
99
|
+
children: W ? /* @__PURE__ */ e(K, { ...T }) : /* @__PURE__ */ e(Q, { ...T })
|
|
99
100
|
})
|
|
100
101
|
})
|
|
101
102
|
]
|
|
102
103
|
})
|
|
103
104
|
});
|
|
104
|
-
},
|
|
105
|
+
}, Ae = k(ee);
|
|
105
106
|
export {
|
|
106
|
-
|
|
107
|
+
Ae as default
|
|
107
108
|
};
|
|
108
109
|
|
|
109
110
|
//# sourceMappingURL=InsightsMicroWidget.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InsightsMicroWidget.es.js","names":[],"sources":["../../src/microinsights/InsightsMicroWidget.tsx"],"sourcesContent":["import React, { useState } from 'react'\n\nimport { observer } from 'mobx-react-lite'\nimport Stack from '@mui/material/Stack'\n\nimport { useCombineEvents, useCombinePageviews, useWidgetLoadTimer } from '../common/hooks'\nimport { InsightsMicroWidgetDataProvider } from './context/InsightsMicroWidgetDataProvider'\n\nimport CarouselHeader from './carousel/CarouselHeader'\nimport MicroWidgetContainer from './MicroWidgetContainer'\nimport MicroBeatCarousel from './carousel/MicroBeatCarousel'\nimport { NoRelevantInsightsCard } from './cards/NoRelevantInsightsCard'\nimport { ZeroStateCard } from './cards/ZeroStateCard'\nimport Spinner from './Spinner'\n\nimport { AppStore } from './stores/AppStore'\n\nimport type { MicroWidgetProps } from './interfaces'\nimport { TRENDS_ANALYTICS_METADATA } from '../trends/constants/TrendsWidget'\nimport { SUPPORTED_CAROUSEL_HEIGHTS } from './constants/App'\n\nconst store = new AppStore()\n\n/*\n This is the parent component / starting point for the general availabile insights micro widget. The Legacy/Cibc version is in a seperate repo\n called insights micro widget. The difference between the No relevent and zero state component is that No relevant is a zero state theat lets the\n user know that although there are no micro insights available but the user has fill insights available and zero state lets the user know that there\n aren't any micro or full insights available.\n*/\n\nconst InsightsMicroWidget: React.FC<MicroWidgetProps> = ({\n allowSingleCardPeeking = true,\n areBeatsLoading = false,\n beats = [], // This also determines the length of the carousel controls (beat.length + 1)\n cardStyle = 'elevation 1',\n endpoint = '/',\n headerSx,\n heightOverrides,\n logOutUser = () => {},\n onCardClick = () => {},\n onEvent: onConsumerEvent = () => {},\n onPageview: onConsumerPageview = () => {},\n posthog,\n showCarouselControls,\n showHeader,\n showIcon,\n showWithMargin = true,\n token = '',\n userHasFullInsightFeedBeats,\n visibleCardsCount = 1,\n widthOverrides,\n}) => {\n // ************** Derived Props ****************************\n const getResolvedVariant = () => {\n if (cardStyle === 'border') return 'outlined' as const\n if (cardStyle === 'elevation 1') return 'elevation' as const\n if (cardStyle === 'flat') return undefined\n return 'elevation'\n }\n const resolvedVariant = getResolvedVariant()\n const resolvedElevation = cardStyle === 'flat' ? 0 : 1\n\n // ************** Use States Hooks ***********************\n const [carouselSize, setCarouselSize] = useState<string>('STANDARD')\n const [isLoaded, setIsLoaded] = useState(false)\n const [triedInitializing, setTriedInitializing] = useState(false)\n\n // ************** Use Custom Hooks ***********************\n const onEvent = useCombineEvents([onConsumerEvent], store)\n const onPageview = useCombinePageviews([onConsumerPageview], store)\n\n useWidgetLoadTimer({\n widgetName: 'InsightsMicroWidget',\n isLoaded: isLoaded,\n })\n\n // ************** Use Effects Hooks **********************\n React.useEffect(() => {\n if (!store.isInitialized && !triedInitializing) {\n store.initialize(endpoint, token, logOutUser).catch(() => setTriedInitializing(false))\n setTriedInitializing(true)\n }\n }, [endpoint, token, logOutUser, store.isInitialized, triedInitializing])\n\n React.useEffect(() => {\n const pageHeight = window.innerHeight\n\n if (pageHeight < 180) {\n setCarouselSize('STANDARD')\n } else if (pageHeight >= 180 && pageHeight < 200) {\n setCarouselSize('LARGE')\n } else if (pageHeight >= 200 && pageHeight < 248) {\n setCarouselSize('XLARGE')\n } else if (pageHeight >= 248) {\n setCarouselSize('XXLARGE')\n }\n }, [window.innerHeight])\n\n React.useEffect(() => {\n setIsLoaded(!areBeatsLoading && store.isInitialized)\n }, [areBeatsLoading, store.isInitialized])\n\n // ************** Spreadable Props ***********************\n const generalProps = {\n heightOverrides,\n onCardClick,\n posthog,\n showIcon,\n showWithMargin,\n widthOverrides,\n }\n\n const zeroStateProps = {\n carouselSize,\n elevation: resolvedElevation,\n variant: resolvedVariant,\n heightOverrides,\n onCardClick,\n posthog,\n showIcon,\n }\n\n return (\n <InsightsMicroWidgetDataProvider onEvent={onEvent} onPageview={onPageview} store={store}>\n <MicroWidgetContainer heightOverrides={heightOverrides} widthOverrides={widthOverrides}>\n {!isLoaded && <Spinner />}\n\n {isLoaded && showHeader && (\n <CarouselHeader\n analyticsMetadata={TRENDS_ANALYTICS_METADATA}\n headerSx={headerSx}\n onCardClick={onCardClick}\n posthog={posthog}\n widthOverrides={widthOverrides}\n />\n )}\n\n {isLoaded && !!beats.length && (\n <MicroBeatCarousel\n allowSingleCardPeeking={allowSingleCardPeeking}\n analyticsMetadata={TRENDS_ANALYTICS_METADATA}\n beats={beats}\n elevation={resolvedElevation}\n showCarouselControls={showCarouselControls}\n variant={resolvedVariant}\n visibleCardsCount={visibleCardsCount}\n {...generalProps}\n />\n )}\n\n {isLoaded && !beats.length && (\n <Stack\n sx={{\n alignItems: 'center',\n height: heightOverrides,\n width: widthOverrides ? widthOverrides : '100%',\n }}\n >\n <Stack\n sx={{\n height: `calc(${SUPPORTED_CAROUSEL_HEIGHTS[carouselSize]}px - 44px)`,\n width: showWithMargin ? `calc(${widthOverrides}px - 32px)` : '100%',\n }}\n >\n {userHasFullInsightFeedBeats ? (\n <NoRelevantInsightsCard {...zeroStateProps} />\n ) : (\n <ZeroStateCard {...zeroStateProps} />\n )}\n </Stack>\n </Stack>\n )}\n </MicroWidgetContainer>\n </InsightsMicroWidgetDataProvider>\n )\n}\n\nexport default observer(InsightsMicroWidget)\n"],"mappings":";;;;;;;;;;;;;;;;AAqBA,IAAM,IAAQ,IAAI,EAAS,GASrB,
|
|
1
|
+
{"version":3,"file":"InsightsMicroWidget.es.js","names":[],"sources":["../../src/microinsights/InsightsMicroWidget.tsx"],"sourcesContent":["import React, { useState } from 'react'\n\nimport { observer } from 'mobx-react-lite'\nimport Stack from '@mui/material/Stack'\n\nimport { useCombineEvents, useCombinePageviews, useWidgetLoadTimer } from '../common/hooks'\nimport { InsightsMicroWidgetDataProvider } from './context/InsightsMicroWidgetDataProvider'\n\nimport CarouselHeader from './carousel/CarouselHeader'\nimport MicroWidgetContainer from './MicroWidgetContainer'\nimport MicroBeatCarousel from './carousel/MicroBeatCarousel'\nimport { NoRelevantInsightsCard } from './cards/NoRelevantInsightsCard'\nimport { ZeroStateCard } from './cards/ZeroStateCard'\nimport Spinner from './Spinner'\n\nimport { AppStore } from './stores/AppStore'\n\nimport type { MicroWidgetProps } from './interfaces'\nimport { TRENDS_ANALYTICS_METADATA } from '../trends/constants/TrendsWidget'\nimport { SUPPORTED_CAROUSEL_HEIGHTS } from './constants/App'\n\nconst store = new AppStore()\n\n/*\n This is the parent component / starting point for the general availabile insights micro widget. The Legacy/Cibc version is in a seperate repo\n called insights micro widget. The difference between the No relevent and zero state component is that No relevant is a zero state theat lets the\n user know that although there are no micro insights available but the user has fill insights available and zero state lets the user know that there\n aren't any micro or full insights available.\n*/\n\nconst InsightsMicroWidget: React.FC<MicroWidgetProps> = ({\n allowSingleCardPeeking = true,\n areBeatsLoading = false,\n beats = [], // This also determines the length of the carousel controls (beat.length + 1)\n cardStyle = 'elevation 1',\n endpoint = '/',\n headerSx,\n heightOverrides,\n inDescriptionCtaBehavior = 'external',\n logOutUser = () => {},\n onCardClick = () => {},\n onEvent: onConsumerEvent = () => {},\n onPageview: onConsumerPageview = () => {},\n posthog,\n showCarouselControls,\n showHeader,\n showIcon,\n showWithMargin = true,\n token = '',\n userHasFullInsightFeedBeats,\n visibleCardsCount = 1,\n widthOverrides,\n}) => {\n // ************** Derived Props ****************************\n const getResolvedVariant = () => {\n if (cardStyle === 'border') return 'outlined' as const\n if (cardStyle === 'elevation 1') return 'elevation' as const\n if (cardStyle === 'flat') return undefined\n return 'elevation'\n }\n const resolvedVariant = getResolvedVariant()\n const resolvedElevation = cardStyle === 'flat' ? 0 : 1\n\n // ************** Use States Hooks ***********************\n const [carouselSize, setCarouselSize] = useState<string>('STANDARD')\n const [isLoaded, setIsLoaded] = useState(false)\n const [triedInitializing, setTriedInitializing] = useState(false)\n\n // ************** Use Custom Hooks ***********************\n const onEvent = useCombineEvents([onConsumerEvent], store)\n const onPageview = useCombinePageviews([onConsumerPageview], store)\n\n useWidgetLoadTimer({\n widgetName: 'InsightsMicroWidget',\n isLoaded: isLoaded,\n })\n\n // ************** Use Effects Hooks **********************\n React.useEffect(() => {\n if (!store.isInitialized && !triedInitializing) {\n store.initialize(endpoint, token, logOutUser).catch(() => setTriedInitializing(false))\n setTriedInitializing(true)\n }\n }, [endpoint, token, logOutUser, store.isInitialized, triedInitializing])\n\n React.useEffect(() => {\n const pageHeight = window.innerHeight\n\n if (pageHeight < 180) {\n setCarouselSize('STANDARD')\n } else if (pageHeight >= 180 && pageHeight < 200) {\n setCarouselSize('LARGE')\n } else if (pageHeight >= 200 && pageHeight < 248) {\n setCarouselSize('XLARGE')\n } else if (pageHeight >= 248) {\n setCarouselSize('XXLARGE')\n }\n }, [window.innerHeight])\n\n React.useEffect(() => {\n setIsLoaded(!areBeatsLoading && store.isInitialized)\n }, [areBeatsLoading, store.isInitialized])\n\n // ************** Spreadable Props ***********************\n const generalProps = {\n heightOverrides,\n inDescriptionCtaBehavior,\n onCardClick,\n posthog,\n showIcon,\n showWithMargin,\n widthOverrides,\n }\n\n const zeroStateProps = {\n carouselSize,\n elevation: resolvedElevation,\n variant: resolvedVariant,\n heightOverrides,\n onCardClick,\n posthog,\n showIcon,\n }\n\n return (\n <InsightsMicroWidgetDataProvider onEvent={onEvent} onPageview={onPageview} store={store}>\n <MicroWidgetContainer heightOverrides={heightOverrides} widthOverrides={widthOverrides}>\n {!isLoaded && <Spinner />}\n\n {isLoaded && showHeader && (\n <CarouselHeader\n analyticsMetadata={TRENDS_ANALYTICS_METADATA}\n headerSx={headerSx}\n onCardClick={onCardClick}\n posthog={posthog}\n widthOverrides={widthOverrides}\n />\n )}\n\n {isLoaded && !!beats.length && (\n <MicroBeatCarousel\n allowSingleCardPeeking={allowSingleCardPeeking}\n analyticsMetadata={TRENDS_ANALYTICS_METADATA}\n beats={beats}\n elevation={resolvedElevation}\n showCarouselControls={showCarouselControls}\n variant={resolvedVariant}\n visibleCardsCount={visibleCardsCount}\n {...generalProps}\n />\n )}\n\n {isLoaded && !beats.length && (\n <Stack\n sx={{\n alignItems: 'center',\n height: heightOverrides,\n width: widthOverrides ? widthOverrides : '100%',\n }}\n >\n <Stack\n sx={{\n height: `calc(${SUPPORTED_CAROUSEL_HEIGHTS[carouselSize]}px - 44px)`,\n width: showWithMargin ? `calc(${widthOverrides}px - 32px)` : '100%',\n }}\n >\n {userHasFullInsightFeedBeats ? (\n <NoRelevantInsightsCard {...zeroStateProps} />\n ) : (\n <ZeroStateCard {...zeroStateProps} />\n )}\n </Stack>\n </Stack>\n )}\n </MicroWidgetContainer>\n </InsightsMicroWidgetDataProvider>\n )\n}\n\nexport default observer(InsightsMicroWidget)\n"],"mappings":"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"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BeatActions } from '../insights-v2/beatActions';
|
|
2
|
+
import { AppStore } from './stores/AppStore';
|
|
3
|
+
import { TheWholeHog } from './interfaces';
|
|
4
|
+
interface MicroBeatActionsDeps {
|
|
5
|
+
store: Pick<AppStore, 'session' | 'insightsMicroWidgetStore'>;
|
|
6
|
+
template: string;
|
|
7
|
+
posthog?: TheWholeHog;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Host callbacks for an action block opened from a micro card, built from what the widget already
|
|
11
|
+
* owns (analytics session, beat API, `posthog`), so the host supplies nothing more.
|
|
12
|
+
*
|
|
13
|
+
* - `onAnalyticsEvent`: Firefly half via the analytics session, PostHog half via `posthog`.
|
|
14
|
+
* Fire-and-forget.
|
|
15
|
+
* - `onSubmitFeedback`: `POST /beat_feedback` with pulse's body (`detail`, else the option, else
|
|
16
|
+
* `No feedback`). A rejection drives the survey's error state.
|
|
17
|
+
*
|
|
18
|
+
* Other host effects (`onCtaAction`, `onUpdate`, ...) are not provided and no-op.
|
|
19
|
+
*/
|
|
20
|
+
export declare const buildMicroBeatActions: ({ store, template, posthog, }: MicroBeatActionsDeps) => BeatActions;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
var d = ({ store: i, template: c, posthog: s }) => ({
|
|
2
|
+
onAnalyticsEvent: ({ action: e, category: a, label: n, postHog: t }) => {
|
|
3
|
+
i.session && (e || a) && i.session.sendAnalyticEvent({
|
|
4
|
+
action: e ?? "",
|
|
5
|
+
category: a ?? "",
|
|
6
|
+
label: n ?? "",
|
|
7
|
+
value: null
|
|
8
|
+
}).catch(() => {
|
|
9
|
+
}), t?.eventName && s?.capture(t.eventName, t.properties);
|
|
10
|
+
},
|
|
11
|
+
onSubmitFeedback: async ({ beatGuid: e, option: a, detail: n }) => {
|
|
12
|
+
await i.insightsMicroWidgetStore.sendBeatFeedback({
|
|
13
|
+
beat_guid: e,
|
|
14
|
+
template: c,
|
|
15
|
+
comments: n || a || "No feedback"
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
export {
|
|
20
|
+
d as buildMicroBeatActions
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=beatActions.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"beatActions.es.js","names":[],"sources":["../../src/microinsights/beatActions.ts"],"sourcesContent":["import type { BeatActions } from '../insights-v2/beatActions'\n\nimport type { AppStore } from './stores/AppStore'\nimport type { TheWholeHog } from './interfaces'\n\ninterface MicroBeatActionsDeps {\n store: Pick<AppStore, 'session' | 'insightsMicroWidgetStore'>\n template: string\n posthog?: TheWholeHog\n}\n\n/**\n * Host callbacks for an action block opened from a micro card, built from what the widget already\n * owns (analytics session, beat API, `posthog`), so the host supplies nothing more.\n *\n * - `onAnalyticsEvent`: Firefly half via the analytics session, PostHog half via `posthog`.\n * Fire-and-forget.\n * - `onSubmitFeedback`: `POST /beat_feedback` with pulse's body (`detail`, else the option, else\n * `No feedback`). A rejection drives the survey's error state.\n *\n * Other host effects (`onCtaAction`, `onUpdate`, ...) are not provided and no-op.\n */\nexport const buildMicroBeatActions = ({\n store,\n template,\n posthog,\n}: MicroBeatActionsDeps): BeatActions => ({\n onAnalyticsEvent: ({ action, category, label, postHog }) => {\n if (store.session && (action || category)) {\n store.session\n .sendAnalyticEvent({\n action: action ?? '',\n category: category ?? '',\n label: label ?? '',\n value: null,\n })\n .catch(() => {})\n }\n\n if (postHog?.eventName) {\n posthog?.capture(postHog.eventName, postHog.properties)\n }\n },\n onSubmitFeedback: async ({ beatGuid, option, detail }) => {\n await store.insightsMicroWidgetStore.sendBeatFeedback({\n beat_guid: beatGuid,\n template,\n comments: detail || option || 'No feedback',\n })\n },\n})\n"],"mappings":"AAsBA,IAAa,IAAA,CAAyB,EACpC,OAAA,GACA,UAAA,GACA,SAAA,EAAA,OACwC;AAAA,EACxC,kBAAA,CAAmB,EAAE,QAAA,GAAQ,UAAA,GAAU,OAAA,GAAO,SAAA,EAAA,MAAc;AAC1D,IAAI,EAAM,YAAY,KAAU,MAC9B,EAAM,QACH,kBAAkB;AAAA,MACjB,QAAQ,KAAU;AAAA,MAClB,UAAU,KAAY;AAAA,MACtB,OAAO,KAAS;AAAA,MAChB,OAAO;AAAA,IACT,CAAC,EACA,MAAA,MAAY;AAAA,IAAC,CAAC,GAGf,GAAS,aACX,GAAS,QAAQ,EAAQ,WAAW,EAAQ,UAAU;AAAA,EAE1D;AAAA,EACA,kBAAkB,OAAO,EAAE,UAAA,GAAU,QAAA,GAAQ,QAAA,EAAA,MAAa;AACxD,UAAM,EAAM,yBAAyB,iBAAiB;AAAA,MACpD,WAAW;AAAA,MACX,UAAA;AAAA,MACA,UAAU,KAAU,KAAU;AAAA,IAChC,CAAC;AAAA,EACH;AACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { Beat } from '../../core/types/Beat';
|
|
3
|
+
import { TheWholeHog } from '../interfaces';
|
|
4
|
+
interface InlineActionBlockProps {
|
|
5
|
+
beat: Beat;
|
|
6
|
+
/** Counts the card's taps; each one, the first included, opens the block. */
|
|
7
|
+
openRequest: number;
|
|
8
|
+
posthog?: TheWholeHog;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Renders the action block a micro card's `in_description_cta` names, in place of the host's
|
|
12
|
+
* redirect (`inDescriptionCtaBehavior="internal"`). Needs the host's `GlobalDataProvider`: the
|
|
13
|
+
* block, its copy and the drawer state live on the shared `GlobalStore`.
|
|
14
|
+
*/
|
|
15
|
+
declare const InlineActionBlock: React.FC<InlineActionBlockProps>;
|
|
16
|
+
export default InlineActionBlock;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useInsightsV2Store as s } from "../../common/context/hooks.es.js";
|
|
2
|
+
import { BeatActionsProvider as p } from "../../insights-v2/beatActions.es.js";
|
|
3
|
+
import { useStore as f } from "../context/hooks.es.js";
|
|
4
|
+
import { buildMicroBeatActions as u } from "../beatActions.es.js";
|
|
5
|
+
import { ActionBlockLayer as a } from "../../insights-v2/actionBlocks/ActionBlockLayer.es.js";
|
|
6
|
+
import m from "react";
|
|
7
|
+
import { jsx as c } from "react/jsx-runtime";
|
|
8
|
+
var k = ({ beat: o, openRequest: r, posthog: t }) => {
|
|
9
|
+
const i = f(), { openActionDrawer: e } = s();
|
|
10
|
+
m.useEffect(() => {
|
|
11
|
+
r > 0 && e({
|
|
12
|
+
guid: o.guid,
|
|
13
|
+
trigger: "inDescriptionCta"
|
|
14
|
+
});
|
|
15
|
+
}, [
|
|
16
|
+
o.guid,
|
|
17
|
+
e,
|
|
18
|
+
r
|
|
19
|
+
]);
|
|
20
|
+
const n = m.useMemo(() => ({
|
|
21
|
+
...u({
|
|
22
|
+
store: i,
|
|
23
|
+
template: o.template,
|
|
24
|
+
posthog: t
|
|
25
|
+
}),
|
|
26
|
+
beat: o
|
|
27
|
+
}), [
|
|
28
|
+
i,
|
|
29
|
+
o,
|
|
30
|
+
t
|
|
31
|
+
]);
|
|
32
|
+
return /* @__PURE__ */ c(p, {
|
|
33
|
+
value: n,
|
|
34
|
+
children: /* @__PURE__ */ c(a, { beat: o })
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
export {
|
|
38
|
+
k as default
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=InlineActionBlock.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InlineActionBlock.es.js","names":[],"sources":["../../../src/microinsights/cards/InlineActionBlock.tsx"],"sourcesContent":["import React from 'react'\n\nimport { useInsightsV2Store } from '../../common'\nimport type { Beat } from '../../core/types/Beat'\nimport { ActionBlockLayer } from '../../insights-v2/actionBlocks/ActionBlockLayer'\nimport { BeatActionsProvider } from '../../insights-v2/beatActions'\n\nimport { buildMicroBeatActions } from '../beatActions'\nimport { useStore } from '../context/hooks'\nimport type { TheWholeHog } from '../interfaces'\n\ninterface InlineActionBlockProps {\n beat: Beat\n /** Counts the card's taps; each one, the first included, opens the block. */\n openRequest: number\n posthog?: TheWholeHog\n}\n\n/**\n * Renders the action block a micro card's `in_description_cta` names, in place of the host's\n * redirect (`inDescriptionCtaBehavior=\"internal\"`). Needs the host's `GlobalDataProvider`: the\n * block, its copy and the drawer state live on the shared `GlobalStore`.\n */\nconst InlineActionBlock: React.FC<InlineActionBlockProps> = ({ beat, openRequest, posthog }) => {\n const appStore = useStore()\n const { openActionDrawer } = useInsightsV2Store()\n\n React.useEffect(() => {\n if (openRequest > 0) {\n openActionDrawer({ guid: beat.guid, trigger: 'inDescriptionCta' })\n }\n }, [beat.guid, openActionDrawer, openRequest])\n\n // The provider value must stay stable: blocks list `useAnalyticsEvent()` in effect dependencies.\n const beatActions = React.useMemo(\n () => ({\n ...buildMicroBeatActions({ store: appStore, template: beat.template, posthog }),\n beat,\n }),\n [appStore, beat, posthog],\n )\n\n return (\n <BeatActionsProvider value={beatActions}>\n <ActionBlockLayer beat={beat} />\n </BeatActionsProvider>\n )\n}\n\nexport default InlineActionBlock\n"],"mappings":";;;;;;;AAuBA,IAAM,IAAA,CAAuD,EAAE,MAAA,GAAM,aAAA,GAAa,SAAA,EAAA,MAAc;AAC9F,QAAM,IAAW,EAAS,GACpB,EAAE,kBAAA,EAAA,IAAqB,EAAmB;AAEhD,EAAA,EAAM,UAAA,MAAgB;AACpB,IAAI,IAAc,KAChB,EAAiB;AAAA,MAAE,MAAM,EAAK;AAAA,MAAM,SAAS;AAAA,IAAmB,CAAC;AAAA,EAErE,GAAG;AAAA,IAAC,EAAK;AAAA,IAAM;AAAA,IAAkB;AAAA,EAAW,CAAC;AAG7C,QAAM,IAAc,EAAM,QAAA,OACjB;AAAA,IACL,GAAG,EAAsB;AAAA,MAAE,OAAO;AAAA,MAAU,UAAU,EAAK;AAAA,MAAU,SAAA;AAAA,IAAQ,CAAC;AAAA,IAC9E,MAAA;AAAA,EACF,IACA;AAAA,IAAC;AAAA,IAAU;AAAA,IAAM;AAAA,EAAO,CAC1B;AAEA,SACE,gBAAA,EAAC,GAAD;AAAA,IAAqB,OAAO;AAAA,IAC1B,UAAA,gBAAA,EAAC,GAAD,EAAwB,MAAA,EAAO,CAAA;AAAA,EACZ,CAAA;AAEzB"}
|