@mx-cartographer/experiences 9.7.78 → 9.7.80
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 +14 -0
- package/dist/core/stores/GlobalCopyStore.d.ts +6 -0
- package/dist/core/stores/GlobalCopyStore.es.js +14 -8
- package/dist/core/stores/GlobalCopyStore.es.js.map +1 -1
- package/dist/core/types/localization/InsightsFeedCopy.d.ts +24 -0
- package/dist/insights-v2/actionBlocks/SubscriptionStatusModalBlock.d.ts +6 -0
- package/dist/insights-v2/actionBlocks/SubscriptionStatusModalBlock.es.js +161 -0
- package/dist/insights-v2/actionBlocks/SubscriptionStatusModalBlock.es.js.map +1 -0
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.es.js +86 -61
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/layout.d.ts +7 -1
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/layout.es.js +9 -5
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/blocks/ImageBlocks/SVGImageBlock/SVGImageBlock.es.js +5 -5
- package/dist/insights-v2/components/BaseLayout.es.js +106 -105
- package/dist/insights-v2/components/BaseLayout.es.js.map +1 -1
- package/dist/insights-v2/components/CtaStatus.d.ts +5 -1
- package/dist/insights-v2/components/CtaStatus.es.js +25 -22
- package/dist/insights-v2/components/CtaStatus.es.js.map +1 -1
- package/dist/insights-v2/components/TransactionListCard.d.ts +5 -1
- package/dist/insights-v2/components/TransactionListCard.es.js +61 -45
- package/dist/insights-v2/components/TransactionListCard.es.js.map +1 -1
- package/dist/insights-v2/ctaActions/ctaConfig.es.js +35 -14
- package/dist/insights-v2/ctaActions/ctaConfig.es.js.map +1 -1
- package/dist/insights-v2/ctaActions/subscriptionAnswer.d.ts +9 -1
- package/dist/insights-v2/ctaActions/subscriptionAnswer.es.js +62 -57
- package/dist/insights-v2/ctaActions/subscriptionAnswer.es.js.map +1 -1
- package/dist/insights-v2/ctaActions/types.d.ts +10 -2
- package/dist/insights-v2/ctaActions/useCtaAction.d.ts +5 -2
- package/dist/insights-v2/ctaActions/useCtaAction.es.js +45 -37
- package/dist/insights-v2/ctaActions/useCtaAction.es.js.map +1 -1
- package/dist/insights-v2/mappings/actionBlocksKey.d.ts +1 -0
- package/dist/insights-v2/mappings/actionBlocksKey.es.js +1 -0
- package/dist/insights-v2/mappings/actionBlocksKey.es.js.map +1 -1
- package/dist/insights-v2/mappings/blocks.es.js +82 -76
- package/dist/insights-v2/mappings/blocks.es.js.map +1 -1
- package/dist/microinsights/cards/InsightCard.es.js +92 -83
- package/dist/microinsights/cards/InsightCard.es.js.map +1 -1
- package/dist/microinsights/cards/MicroCtaStatus.d.ts +18 -0
- package/dist/microinsights/cards/MicroCtaStatus.es.js +50 -0
- package/dist/microinsights/cards/MicroCtaStatus.es.js.map +1 -0
- package/dist/microinsights/stores/CopyStore.d.ts +10 -1
- package/dist/microinsights/stores/CopyStore.es.js +20 -11
- package/dist/microinsights/stores/CopyStore.es.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InsightCard.es.js","names":[],"sources":["../../../src/microinsights/cards/InsightCard.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react'\nimport { useInView } from 'react-intersection-observer'\n\nimport Box from '@mui/material/Box'\nimport { alpha, useTheme } from '@mui/material/styles'\n\nimport { BeatIcon } from '../beaticons'\nimport BeatMaterialIcon from '../beaticons/BeatMaterialIcon'\n\nimport { useCopyStore, useEvent, useInsightsMicroWidgetStore } from '../context/hooks'\n\nimport { ON_CLICK_EVENT, ON_VIEW_EVENT, ON_VIEW_FIRST_TIME_EVENT } from '../constants/Analytics'\nimport { VIEW_THRESHOLD } from '../constants/App'\n\nimport type { BeatLikeOffer, MicroInsightCardProps } from '../interfaces'\nimport type { Beat } from '../../core/types/Beat'\n// Leaf imports, not the `core` barrel: that pulls GlobalStore and every feature store into the\n// micro bundle, and through `core/stores` it reintroduces a circular path this module avoids.\nimport { slot } from '../../core/types/Insights'\nimport type { LogoRef } from '../../core/types/Insights'\nimport MicroCardTemplate from '../MicroCardTemplate'\n// Leaf import, not the `common` barrel, which would pull the shared layer into the micro bundle.\nimport { GlobalDataContext } from '../../common/context/GlobalDataProvider'\n// TODO: load this with `React.lazy` to keep the block registry and charts out of the micro bundle,\n// once it is verified in every host that embeds the micro widget.\nimport InlineActionBlock from './InlineActionBlock'\n// Leaf imports on purpose: the `insights-v2` barrel pulls in `mappings/blocks` and its charts.\nimport InsightErrorCard from '../../insights-v2/components/InsightErrorCard'\nimport LogoFromGuid from '../../insights-v2/components/LogoFromGuid'\nimport { statusIconName, statusIconPalette } from '../../insights-v2/components/statusIcon'\nimport { hasDrawerBlock } from '../../insights-v2/mappings/hasDrawerBlock'\nimport { resolveInsightRender } from '../../insights-v2/resolveInsightRender'\n\n/** The legacy micro card's icon tile size (BeatMaterialIcon). */\nconst ICON_SIZE = 32\n\nexport interface InsightCardProps extends MicroInsightCardProps {\n beat: Beat | BeatLikeOffer\n index?: number\n}\n\nexport const InsightCard: React.FC<InsightCardProps> = ({\n ariaLabel,\n beat,\n elevation,\n inDescriptionCtaBehavior = 'external',\n index,\n isActiveCard,\n onCardClick,\n posthog,\n widthOverrides,\n variant,\n showIcon,\n heightOverrides,\n}) => {\n const { ref, inView } = useInView({\n threshold: VIEW_THRESHOLD,\n })\n\n const theme = useTheme()\n\n // *************** Context functions *********************\n const { cardsCopy } = useCopyStore()\n const { onEvent } = useEvent()\n const { updateBeat, updateOffer } = useInsightsMicroWidgetStore()\n\n // ************** Use Effects Hooks **********************\n useEffect(() => {\n if (inView) {\n if (!beat.has_been_displayed) {\n if (beat.guid.startsWith('OFR')) {\n updateOffer({\n ...beat,\n has_been_displayed: true,\n })\n } else {\n updateBeat({\n ...beat,\n has_been_displayed: true,\n })\n }\n onEvent(ON_VIEW_FIRST_TIME_EVENT(beat.template))\n } else {\n onEvent(ON_VIEW_EVENT(beat.template))\n }\n }\n }, [inView])\n\n useEffect(() => {\n if (inView && beat) {\n if (beat.template === 'MarketingOffer') {\n const offerBeat = beat as BeatLikeOffer\n posthog?.capture('viewed_messaging_insight', {\n template: beat.template,\n campaign_guid: offerBeat.campaign_guid,\n campaign_name: offerBeat.pulse_campaign_name,\n offer_guid: offerBeat.guid,\n user_guid: offerBeat.user_guid,\n })\n } else {\n posthog?.capture('viewed_insight', {\n beat_guid: beat.guid,\n template: beat.template,\n position: index,\n })\n }\n }\n }, [beat, index, inView])\n\n const insightRender = resolveInsightRender(beat as Beat)\n const v2Payload = insightRender === 'v2' ? beat.insights_payload : undefined\n // Only a V2 beat whose `in_description_cta` names a drawer block opens in place; everything else\n // keeps the host's behavior. Micro sends its one action as `in_description_cta`.\n // It also needs the host's `GlobalDataProvider`; without one the tap goes to the host instead.\n const hasGlobalData = React.useContext(GlobalDataContext) !== null\n const opensInline =\n inDescriptionCtaBehavior === 'internal' &&\n hasGlobalData &&\n hasDrawerBlock(v2Payload?.in_description_cta?.block)\n\n // *************** Click handlers ************************\n // Taps that opened the beat's own action block.\n const [inlineOpenRequest, setInlineOpenRequest] = useState(0)\n\n const handleClick = () => {\n /* eslint-disable no-unused-expressions */\n // Internal opens the block here and skips the host's `onCardClick`; analytics are unchanged.\n if (opensInline) {\n setInlineOpenRequest((count) => count + 1)\n } else {\n onCardClick && onCardClick(beat)\n }\n onEvent(ON_CLICK_EVENT(beat.template))\n\n if (beat.template === 'MarketingOffer') {\n const offerBeat = beat as BeatLikeOffer\n posthog?.capture('clicked_messaging_insight', {\n template: beat.template,\n campaign_guid: offerBeat.campaign_guid,\n campaign_name: offerBeat.pulse_campaign_name,\n offer_guid: offerBeat.guid,\n user_guid: offerBeat.user_guid,\n })\n } else {\n posthog?.capture('clicked_insight', {\n beat_guid: beat.guid,\n template: beat.template,\n position: index,\n })\n }\n }\n\n if (insightRender === 'error') {\n // Keeps the carousel's slot sizing; the error card does not know about it.\n return (\n <Box\n aria-hidden={!isActiveCard}\n aria-label={ariaLabel}\n aria-roledescription=\"slide\"\n ref={ref}\n role=\"group\"\n sx={{\n height: heightOverrides ? '100%' : 120,\n minWidth: widthOverrides ? `${widthOverrides}px` : '100%',\n my: 1,\n }}\n >\n <InsightErrorCard beat={beat} />\n </Box>\n )\n }\n\n if (v2Payload) {\n // Figma (Micro Widget | Large Transaction) is the legacy micro card's layout fed from the envelope:\n // the slot's logo on the left (merchant, or the category without one), title, description, and the\n // primary CTA as a link. The logo falls back to the insight glyph when the slot carries none.\n // ditto ≥ 1.4.3 words micro's action as in_description_cta instead of primary_cta; either way\n // the label stays the card's tap (`micro-carousel/cta`), never a drawer.\n // A block with no row logo may name a status icon instead (account_block `minimal`: `ICO-error`),\n // drawn in the legacy card's tinted tile (Figma Micro | Low Account Balance).\n // The status tile takes the palette the slot names (Payday's on-track check is `success.main`),\n // falling back to error. `||` on the label: the copy may send the primary label as \"\".\n const rowLogo = slot<LogoRef>(v2Payload.instance_slot.data, 'logo')\n const statusIcon = slot<LogoRef>(v2Payload.instance_slot.data, 'icon')\n const statusName = statusIconName(statusIcon?.guid)\n const statusPalette = statusIconPalette(statusIcon?.color)\n const actionLabel =\n v2Payload.primary_cta?.label || v2Payload.in_description_cta?.label || undefined\n\n const card = (\n <MicroCardTemplate\n aria-roledescription=\"slide\"\n ariaLabel={ariaLabel}\n description={v2Payload.description.html_text}\n elevation={elevation}\n heightOverrides={heightOverrides}\n icon={\n showIcon &&\n (rowLogo ? (\n <LogoFromGuid logo={rowLogo} size={ICON_SIZE} />\n ) : statusName ? (\n <BeatMaterialIcon\n bgColor={alpha(theme.palette[statusPalette].main, 0.15)}\n iconColor={statusPalette}\n name={statusName}\n />\n ) : (\n <BeatMaterialIcon bgColor={alpha(theme.palette.primary.main, 0.15)} name=\"lightbulb\" />\n ))\n }\n isActiveCard={isActiveCard}\n onCardClick={handleClick}\n onPrimaryAction={handleClick}\n primaryActionText={actionLabel}\n ref={ref}\n title={v2Payload.title ?? ''}\n variant={variant}\n widthOverrides={widthOverrides}\n />\n )\n\n if (!opensInline) return card\n\n return (\n <>\n {card}\n {/* Nothing renders until the first tap. */}\n {inlineOpenRequest > 0 && (\n <InlineActionBlock\n beat={beat as Beat}\n openRequest={inlineOpenRequest}\n posthog={posthog}\n />\n )}\n </>\n )\n }\n\n return (\n <MicroCardTemplate\n aria-roledescription=\"slide\"\n ariaLabel={ariaLabel}\n description={\n beat?.html_micro_description && beat?.html_micro_description.length > 0\n ? beat.html_micro_description\n : beat.html_description || ''\n }\n elevation={elevation}\n heightOverrides={heightOverrides}\n icon={showIcon && <BeatIcon beat={beat} />}\n isActiveCard={isActiveCard}\n onCardClick={handleClick}\n onPrimaryAction={handleClick}\n primaryActionText={beat.micro_call_to_action || cardsCopy?.micro_card_cta}\n ref={ref}\n title={beat.micro_title && beat.micro_title.length > 0 ? beat.micro_title : beat.title}\n variant={variant}\n widthOverrides={widthOverrides}\n />\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkCA,IAAM,KAAY,IAOL,KAAA,CAA2C,EACtD,WAAA,GACA,MAAA,GACA,WAAA,GACA,0BAAA,IAA2B,YAC3B,OAAA,GACA,cAAA,GACA,aAAA,GACA,SAAA,GACA,gBAAA,GACA,SAAA,GACA,UAAA,GACA,iBAAA,EAAA,MACI;AACJ,QAAM,EAAE,KAAA,GAAK,QAAA,EAAA,IAAW,GAAU,EAChC,WAAA,EACF,CAAC,GAEK,IAAQ,GAAS,GAGjB,EAAE,WAAA,EAAA,IAAc,EAAa,GAC7B,EAAE,SAAA,EAAA,IAAY,EAAS,GACvB,EAAE,YAAA,GAAY,aAAA,EAAA,IAAgB,EAA4B;AAGhE,EAAA,EAAA,MAAgB;AACd,IAAI,MACG,EAAK,qBAcR,EAAQ,EAAc,EAAK,QAAQ,CAAC,KAbhC,EAAK,KA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MAG5E,cAAA;AAAA,MACd,aAAa;AAAA,MACb,iBAAiB;AAAA,MACjB,mBAAmB;AAAA,MACd,KAAA;AAAA,MACL,OAAO,EAAU,SAAS;AAAA,MACjB,SAAA;AAAA,MACO,gBAAA;AAAA,IACjB,CAAA;AAGH,WAAK,IAGH,gBAAA,GAAA,IAAA,EAAA,UAAA,CACG,GAEA,IAAoB,KACnB,gBAAA,EAAC,GAAD;AAAA,MACQ,MAAA;AAAA,MACN,aAAa;AAAA,MACJ,SAAA;AAAA,IACV,CAAA,CAEH,EAAA,CAAA,IAbqB;AAAA,EAe3B;AAEA,SACE,gBAAA,EAAC,GAAD;AAAA,IACE,wBAAqB;AAAA,IACV,WAAA;AAAA,IACX,aACE,GAAM,0BAA0B,GAAM,uBAAuB,SAAS,IAClE,EAAK,yBACL,EAAK,oBAAoB;AAAA,IAEpB,WAAA;AAAA,IACM,iBAAA;AAAA,IACjB,MAAM,KAAY,gBAAA,EAAC,GAAD,EAAgB,MAAA,EAAO,CAAA;AAAA,IAC3B,cAAA;AAAA,IACd,aAAa;AAAA,IACb,iBAAiB;AAAA,IACjB,mBAAmB,EAAK,wBAAwB,GAAW;AAAA,IACtD,KAAA;AAAA,IACL,OAAO,EAAK,eAAe,EAAK,YAAY,SAAS,IAAI,EAAK,cAAc,EAAK;AAAA,IACxE,SAAA;AAAA,IACO,gBAAA;AAAA,EACjB,CAAA;AAEL"}
|
|
1
|
+
{"version":3,"file":"InsightCard.es.js","names":[],"sources":["../../../src/microinsights/cards/InsightCard.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react'\nimport { useInView } from 'react-intersection-observer'\n\nimport Box from '@mui/material/Box'\nimport { alpha, useTheme } from '@mui/material/styles'\n\nimport { BeatIcon } from '../beaticons'\nimport BeatMaterialIcon from '../beaticons/BeatMaterialIcon'\n\nimport { useCopyStore, useEvent, useInsightsMicroWidgetStore } from '../context/hooks'\n\nimport { ON_CLICK_EVENT, ON_VIEW_EVENT, ON_VIEW_FIRST_TIME_EVENT } from '../constants/Analytics'\nimport { VIEW_THRESHOLD } from '../constants/App'\n\nimport type { BeatLikeOffer, MicroInsightCardProps } from '../interfaces'\nimport type { Beat } from '../../core/types/Beat'\n// Leaf imports, not the `core` barrel: that pulls GlobalStore and every feature store into the\n// micro bundle, and through `core/stores` it reintroduces a circular path this module avoids.\nimport { slot } from '../../core/types/Insights'\nimport type { LogoRef } from '../../core/types/Insights'\nimport MicroCardTemplate from '../MicroCardTemplate'\n// Leaf import, not the `common` barrel, which would pull the shared layer into the micro bundle.\nimport { GlobalDataContext } from '../../common/context/GlobalDataProvider'\n// TODO: load this with `React.lazy` to keep the block registry and charts out of the micro bundle,\n// once it is verified in every host that embeds the micro widget.\nimport InlineActionBlock from './InlineActionBlock'\nimport MicroCtaStatusGate, { type MicroCtaStatus } from './MicroCtaStatus'\n// Leaf imports on purpose: the `insights-v2` barrel pulls in `mappings/blocks` and its charts.\nimport InsightErrorCard from '../../insights-v2/components/InsightErrorCard'\nimport LogoFromGuid from '../../insights-v2/components/LogoFromGuid'\nimport { statusIconName, statusIconPalette } from '../../insights-v2/components/statusIcon'\nimport { hasDrawerBlock } from '../../insights-v2/mappings/hasDrawerBlock'\nimport { resolveInsightRender } from '../../insights-v2/resolveInsightRender'\n\n/** The legacy micro card's icon tile size (BeatMaterialIcon). */\nconst ICON_SIZE = 32\n\nexport interface InsightCardProps extends MicroInsightCardProps {\n beat: Beat | BeatLikeOffer\n index?: number\n}\n\nexport const InsightCard: React.FC<InsightCardProps> = ({\n ariaLabel,\n beat,\n elevation,\n inDescriptionCtaBehavior = 'external',\n index,\n isActiveCard,\n onCardClick,\n posthog,\n widthOverrides,\n variant,\n showIcon,\n heightOverrides,\n}) => {\n const { ref, inView } = useInView({\n threshold: VIEW_THRESHOLD,\n })\n\n const theme = useTheme()\n\n // *************** Context functions *********************\n const { cardsCopy } = useCopyStore()\n const { onEvent } = useEvent()\n const { updateBeat, updateOffer } = useInsightsMicroWidgetStore()\n\n // ************** Use Effects Hooks **********************\n useEffect(() => {\n if (inView) {\n if (!beat.has_been_displayed) {\n if (beat.guid.startsWith('OFR')) {\n updateOffer({\n ...beat,\n has_been_displayed: true,\n })\n } else {\n updateBeat({\n ...beat,\n has_been_displayed: true,\n })\n }\n onEvent(ON_VIEW_FIRST_TIME_EVENT(beat.template))\n } else {\n onEvent(ON_VIEW_EVENT(beat.template))\n }\n }\n }, [inView])\n\n useEffect(() => {\n if (inView && beat) {\n if (beat.template === 'MarketingOffer') {\n const offerBeat = beat as BeatLikeOffer\n posthog?.capture('viewed_messaging_insight', {\n template: beat.template,\n campaign_guid: offerBeat.campaign_guid,\n campaign_name: offerBeat.pulse_campaign_name,\n offer_guid: offerBeat.guid,\n user_guid: offerBeat.user_guid,\n })\n } else {\n posthog?.capture('viewed_insight', {\n beat_guid: beat.guid,\n template: beat.template,\n position: index,\n })\n }\n }\n }, [beat, index, inView])\n\n const insightRender = resolveInsightRender(beat as Beat)\n const v2Payload = insightRender === 'v2' ? beat.insights_payload : undefined\n // Only a V2 beat whose `in_description_cta` names a drawer block opens in place; everything else\n // keeps the host's behavior. Micro sends its one action as `in_description_cta`.\n // It also needs the host's `GlobalDataProvider`; without one the tap goes to the host instead.\n const hasGlobalData = React.useContext(GlobalDataContext) !== null\n const opensInline =\n inDescriptionCtaBehavior === 'internal' &&\n hasGlobalData &&\n hasDrawerBlock(v2Payload?.in_description_cta?.block)\n\n // *************** Click handlers ************************\n // Taps that opened the beat's own action block.\n const [inlineOpenRequest, setInlineOpenRequest] = useState(0)\n\n const handleClick = () => {\n /* eslint-disable no-unused-expressions */\n // Internal opens the block here and skips the host's `onCardClick`; analytics are unchanged.\n if (opensInline) {\n setInlineOpenRequest((count) => count + 1)\n } else {\n onCardClick && onCardClick(beat)\n }\n onEvent(ON_CLICK_EVENT(beat.template))\n\n if (beat.template === 'MarketingOffer') {\n const offerBeat = beat as BeatLikeOffer\n posthog?.capture('clicked_messaging_insight', {\n template: beat.template,\n campaign_guid: offerBeat.campaign_guid,\n campaign_name: offerBeat.pulse_campaign_name,\n offer_guid: offerBeat.guid,\n user_guid: offerBeat.user_guid,\n })\n } else {\n posthog?.capture('clicked_insight', {\n beat_guid: beat.guid,\n template: beat.template,\n position: index,\n })\n }\n }\n\n if (insightRender === 'error') {\n // Keeps the carousel's slot sizing; the error card does not know about it.\n return (\n <Box\n aria-hidden={!isActiveCard}\n aria-label={ariaLabel}\n aria-roledescription=\"slide\"\n ref={ref}\n role=\"group\"\n sx={{\n height: heightOverrides ? '100%' : 120,\n minWidth: widthOverrides ? `${widthOverrides}px` : '100%',\n my: 1,\n }}\n >\n <InsightErrorCard beat={beat} />\n </Box>\n )\n }\n\n if (v2Payload) {\n // Figma (Micro Widget | Large Transaction) is the legacy micro card's layout fed from the envelope:\n // the slot's logo on the left (merchant, or the category without one), title, description, and the\n // primary CTA as a link. The logo falls back to the insight glyph when the slot carries none.\n // ditto ≥ 1.4.3 words micro's action as in_description_cta instead of primary_cta; either way\n // the label stays the card's tap (`micro-carousel/cta`), never a drawer.\n // A block with no row logo may name a status icon instead (account_block `minimal`: `ICO-error`),\n // drawn in the legacy card's tinted tile (Figma Micro | Low Account Balance).\n // The status tile takes the palette the slot names (Payday's on-track check is `success.main`),\n // falling back to error. `||` on the label: the copy may send the primary label as \"\".\n // Answered (mirrors the full card): reviewed title, icon and the Undo label. Display only: the card\n // and its label tap go to the host, which opens the insight with its block; nothing runs here.\n const renderCard = ({ presentation }: MicroCtaStatus) => {\n const answered = presentation?.kind === 'status' ? presentation : undefined\n const rowLogo = slot<LogoRef>(v2Payload.instance_slot.data, 'logo')\n const statusIcon = slot<LogoRef>(\n v2Payload.instance_slot.data,\n answered && slot<LogoRef>(v2Payload.instance_slot.data, 'reviewed_icon')\n ? 'reviewed_icon'\n : 'icon',\n )\n const statusName = statusIconName(statusIcon?.guid)\n const statusPalette = statusIconPalette(statusIcon?.color)\n const actionLabel = presentation\n ? answered?.action?.label\n : v2Payload.primary_cta?.label || v2Payload.in_description_cta?.label || undefined\n const handleHostClick = () => {\n onCardClick && onCardClick(beat)\n onEvent(ON_CLICK_EVENT(beat.template))\n posthog?.capture('clicked_insight', {\n beat_guid: beat.guid,\n template: beat.template,\n position: index,\n })\n }\n\n const card = (\n <MicroCardTemplate\n aria-roledescription=\"slide\"\n ariaLabel={ariaLabel}\n description={v2Payload.description.html_text}\n elevation={elevation}\n heightOverrides={heightOverrides}\n icon={\n showIcon &&\n (rowLogo ? (\n <LogoFromGuid logo={rowLogo} size={ICON_SIZE} />\n ) : statusName ? (\n <BeatMaterialIcon\n bgColor={alpha(theme.palette[statusPalette].main, 0.15)}\n iconColor={statusPalette}\n name={statusName}\n />\n ) : (\n <BeatMaterialIcon\n bgColor={alpha(theme.palette.primary.main, 0.15)}\n name=\"lightbulb\"\n />\n ))\n }\n isActiveCard={isActiveCard}\n onCardClick={presentation ? handleHostClick : handleClick}\n onPrimaryAction={presentation ? handleHostClick : handleClick}\n primaryActionText={actionLabel}\n ref={ref}\n title={presentation?.title || v2Payload.title || ''}\n variant={variant}\n widthOverrides={widthOverrides}\n />\n )\n\n if (!opensInline) return card\n\n return (\n <>\n {card}\n {/* Nothing renders until the first tap. */}\n {inlineOpenRequest > 0 && (\n <InlineActionBlock\n beat={beat as Beat}\n openRequest={inlineOpenRequest}\n posthog={posthog}\n />\n )}\n </>\n )\n }\n\n return (\n <MicroCtaStatusGate beat={beat as Beat} posthog={posthog}>\n {renderCard}\n </MicroCtaStatusGate>\n )\n }\n\n return (\n <MicroCardTemplate\n aria-roledescription=\"slide\"\n ariaLabel={ariaLabel}\n description={\n beat?.html_micro_description && beat?.html_micro_description.length > 0\n ? beat.html_micro_description\n : beat.html_description || ''\n }\n elevation={elevation}\n heightOverrides={heightOverrides}\n icon={showIcon && <BeatIcon beat={beat} />}\n isActiveCard={isActiveCard}\n onCardClick={handleClick}\n onPrimaryAction={handleClick}\n primaryActionText={beat.micro_call_to_action || cardsCopy?.micro_card_cta}\n ref={ref}\n title={beat.micro_title && beat.micro_title.length > 0 ? beat.micro_title : beat.title}\n variant={variant}\n widthOverrides={widthOverrides}\n />\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmCA,IAAM,KAAY,IAOL,KAAA,CAA2C,EACtD,WAAA,GACA,MAAA,GACA,WAAA,GACA,0BAAA,IAA2B,YAC3B,OAAA,GACA,cAAA,GACA,aAAA,GACA,SAAA,GACA,gBAAA,GACA,SAAA,GACA,UAAA,GACA,iBAAA,EAAA,MACI;AACJ,QAAM,EAAE,KAAA,GAAK,QAAA,EAAA,IAAW,GAAU,EAChC,WAAA,EACF,CAAC,GAEK,IAAQ,GAAS,GAGjB,EAAE,WAAA,EAAA,IAAc,EAAa,GAC7B,EAAE,SAAA,EAAA,IAAY,EAAS,GACvB,EAAE,YAAA,GAAY,aAAA,EAAA,IAAgB,GAA4B;AAGhE,EAAA,EAAA,MAAgB;AACd,IAAI,MACG,EAAK,qBAcR,EAAQ,EAAc,EAAK,QAAQ,CAAC,KAbhC,EAAK,KAAK,WAAW,KAAK,IAC5B,EAAY;AAAA,MACV,GAAG;AAAA,MACH,oBAAoB;AAAA,IACtB,CAAC,IAED,EAAW;AAAA,MACT,GAAG;AAAA,MACH,oBAAoB;AAAA,IACtB,CAAC,GAEH,EAAQ,EAAyB,EAAK,QAAQ,CAAC;AAAA,EAKrD,GAAG,CAAC,CAAM,CAAC,GAEX,EAAA,MAAgB;AACd,QAAI,KAAU,EACZ,KAAI,EAAK,aAAa,kBAAkB;AACtC,YAAM,IAAY;AAClB,MAAA,GAAS,QAAQ,4BAA4B;AAAA,QAC3C,UAAU,EAAK;AAAA,QACf,eAAe,EAAU;AAAA,QACzB,eAAe,EAAU;AAAA,QACzB,YAAY,EAAU;AAAA,QACtB,WAAW,EAAU;AAAA,MACvB,CAAC;AAAA,IACH,MACE,CAAA,GAAS,QAAQ,kBAAkB;AAAA,MACjC,WAAW,EAAK;AAAA,MAChB,UAAU,EAAK;AAAA,MACf,UAAU;AAAA,IACZ,C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;AAAA,MACjB,CAAA;AAGH,aAAK,IAGH,gBAAA,GAAA,IAAA,EAAA,UAAA,CACG,GAEA,IAAoB,KACnB,gBAAA,EAAC,IAAD;AAAA,QACQ,MAAA;AAAA,QACN,aAAa;AAAA,QACJ,SAAA;AAAA,MACV,CAAA,CAEH,EAAA,CAAA,IAbqB;AAAA,IAe3B;AAAA,EAKsB,CAAA,IAKtB,gBAAA,EAAC,GAAD;AAAA,IACE,wBAAqB;AAAA,IACV,WAAA;AAAA,IACX,aACE,GAAM,0BAA0B,GAAM,uBAAuB,SAAS,IAClE,EAAK,yBACL,EAAK,oBAAoB;AAAA,IAEpB,WAAA;AAAA,IACM,iBAAA;AAAA,IACjB,MAAM,KAAY,gBAAA,EAAC,GAAD,EAAgB,MAAA,EAAO,CAAA;AAAA,IAC3B,cAAA;AAAA,IACd,aAAa;AAAA,IACb,iBAAiB;AAAA,IACjB,mBAAmB,EAAK,wBAAwB,GAAW;AAAA,IACtD,KAAA;AAAA,IACL,OAAO,EAAK,eAAe,EAAK,YAAY,SAAS,IAAI,EAAK,cAAc,EAAK;AAAA,IACxE,SAAA;AAAA,IACO,gBAAA;AAAA,EACjB,CAAA;AAEL"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { Beat } from '../../core/types/Beat';
|
|
3
|
+
import { CtaPresentation } from '../../insights-v2/ctaActions/types';
|
|
4
|
+
import { TheWholeHog } from '../interfaces';
|
|
5
|
+
export interface MicroCtaStatus {
|
|
6
|
+
/** The micro action's presentation. */
|
|
7
|
+
presentation?: CtaPresentation;
|
|
8
|
+
}
|
|
9
|
+
interface MicroCtaStatusGateProps {
|
|
10
|
+
beat: Beat;
|
|
11
|
+
posthog?: TheWholeHog;
|
|
12
|
+
children: (status: MicroCtaStatus) => React.ReactNode;
|
|
13
|
+
}
|
|
14
|
+
/** Resolves the micro card's link (`in_description_cta`) through the CTA layer when its step opts in (`compactStatus`), as mini does. */
|
|
15
|
+
export declare const MicroCtaStatusGate: (({ beat, posthog, children, }: MicroCtaStatusGateProps) => import("react/jsx-runtime").JSX.Element) & {
|
|
16
|
+
displayName: string;
|
|
17
|
+
};
|
|
18
|
+
export default MicroCtaStatusGate;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { GlobalDataContext as C } from "../../common/context/GlobalDataProvider.es.js";
|
|
2
|
+
import { resolveStep as _ } from "../../insights-v2/ctaActions/runCtaAction.es.js";
|
|
3
|
+
import { useCopyStore as h, useStore as k } from "../context/hooks.es.js";
|
|
4
|
+
import { buildMicroBeatActions as v } from "../beatActions.es.js";
|
|
5
|
+
import { useContext as F, useEffect as n, useMemo as b } from "react";
|
|
6
|
+
import { observer as x } from "mobx-react-lite";
|
|
7
|
+
import { Fragment as d, jsx as u } from "react/jsx-runtime";
|
|
8
|
+
var $ = x(function({ beat: o, posthog: a, children: c }) {
|
|
9
|
+
const y = F(C), p = k(), t = y?.globalStore, r = o.insights_payload?.in_description_cta, s = r?.action_key ? {
|
|
10
|
+
label: r.label,
|
|
11
|
+
block: r.block ?? "",
|
|
12
|
+
action_key: r.action_key
|
|
13
|
+
} : void 0, l = s && _({ cta: s }), e = l?.compactStatus ? l : void 0, S = b(() => v({
|
|
14
|
+
store: p,
|
|
15
|
+
template: o.template,
|
|
16
|
+
posthog: a
|
|
17
|
+
}), [
|
|
18
|
+
p,
|
|
19
|
+
o.template,
|
|
20
|
+
a
|
|
21
|
+
]), i = h(), { insightsFeedCopy: m } = i, f = !!e && !!t && !t.copyStore.copy?.insights_feed;
|
|
22
|
+
if (n(() => {
|
|
23
|
+
f && i.loadInsightsFeedCopy();
|
|
24
|
+
}, [f, i]), n(() => {
|
|
25
|
+
t && t.copyStore.setSection("insights_feed", m);
|
|
26
|
+
}, [t, m]), n(() => {
|
|
27
|
+
t && e?.prepare?.({
|
|
28
|
+
beat: o,
|
|
29
|
+
stores: t
|
|
30
|
+
});
|
|
31
|
+
}, [
|
|
32
|
+
o.guid,
|
|
33
|
+
e?.prepare,
|
|
34
|
+
t
|
|
35
|
+
]), !t || !s || !e?.presenter) return /* @__PURE__ */ u(d, { children: c({}) });
|
|
36
|
+
const g = e.presenter({
|
|
37
|
+
beat: o,
|
|
38
|
+
cta: s,
|
|
39
|
+
slot: "primary",
|
|
40
|
+
stores: t,
|
|
41
|
+
hostActions: S
|
|
42
|
+
});
|
|
43
|
+
return /* @__PURE__ */ u(d, { children: c({ presentation: g }) });
|
|
44
|
+
});
|
|
45
|
+
export {
|
|
46
|
+
$ as MicroCtaStatusGate,
|
|
47
|
+
$ as default
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=MicroCtaStatus.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MicroCtaStatus.es.js","names":[],"sources":["../../../src/microinsights/cards/MicroCtaStatus.tsx"],"sourcesContent":["import React, { useContext, useEffect, useMemo } from 'react'\nimport { observer } from 'mobx-react-lite'\n\n// Leaf imports.\nimport { GlobalDataContext } from '../../common/context/GlobalDataProvider'\nimport type { Beat } from '../../core/types/Beat'\nimport { resolveStep } from '../../insights-v2/ctaActions/runCtaAction'\nimport type { CtaPresentation } from '../../insights-v2/ctaActions/types'\nimport { buildMicroBeatActions } from '../beatActions'\nimport { useCopyStore, useStore } from '../context/hooks'\nimport type { TheWholeHog } from '../interfaces'\n\nexport interface MicroCtaStatus {\n /** The micro action's presentation. */\n presentation?: CtaPresentation\n}\n\ninterface MicroCtaStatusGateProps {\n beat: Beat\n posthog?: TheWholeHog\n children: (status: MicroCtaStatus) => React.ReactNode\n}\n\n/** Resolves the micro card's link (`in_description_cta`) through the CTA layer when its step opts in (`compactStatus`), as mini does. */\nexport const MicroCtaStatusGate = observer(function MicroCtaStatusGate({\n beat,\n posthog,\n children,\n}: MicroCtaStatusGateProps) {\n const globalData = useContext(GlobalDataContext)\n const appStore = useStore()\n const stores = globalData?.globalStore\n const link = beat.insights_payload?.in_description_cta\n const ctaRef = link?.action_key\n ? { label: link.label, block: link.block ?? '', action_key: link.action_key }\n : undefined\n const linkStep = ctaRef && resolveStep({ cta: ctaRef })\n // Only a step that mirrors on compact cards; any other leaves the micro card as it was.\n const step = linkStep?.compactStatus ? linkStep : undefined\n\n // The step's context (the presenter's Undo is never pressed from micro).\n const hostActions = useMemo(\n () => buildMicroBeatActions({ store: appStore, template: beat.template, posthog }),\n [appStore, beat.template, posthog],\n )\n\n // A micro host may not load the global copy. Only a card whose step mirrors here, on a host without\n // insights_feed, fetches it (once per widget) and hands it over, so the presenter reads the same\n // words as on full and mini; no other card makes the request.\n const microCopy = useCopyStore()\n const { insightsFeedCopy } = microCopy\n const needsInsightsFeed = !!step && !!stores && !stores.copyStore.copy?.insights_feed\n\n useEffect(() => {\n if (needsInsightsFeed) void microCopy.loadInsightsFeedCopy()\n }, [needsInsightsFeed, microCopy])\n\n useEffect(() => {\n if (stores) stores.copyStore.setSection('insights_feed', insightsFeedCopy)\n }, [stores, insightsFeedCopy])\n\n useEffect(() => {\n if (stores) step?.prepare?.({ beat, stores })\n // eslint-disable-next-line react-hooks/exhaustive-deps -- once per beat\n }, [beat.guid, step?.prepare, stores])\n\n if (!stores || !ctaRef || !step?.presenter) return <>{children({})}</>\n\n // The step is already resolved: call its presenter (micro is display only, no disabled state).\n const presentation = step.presenter({ beat, cta: ctaRef, slot: 'primary', stores, hostActions })\n\n return <>{children({ presentation })}</>\n})\n\nexport default MicroCtaStatusGate\n"],"mappings":";;;;;;;AAwBA,IAAa,IAAqB,EAAS,SAA4B,EACrE,MAAA,GACA,SAAA,GACA,UAAA,EAAA,GAC0B;AAC1B,QAAM,IAAa,EAAW,CAAiB,GACzC,IAAW,EAAS,GACpB,IAAS,GAAY,aACrB,IAAO,EAAK,kBAAkB,oBAC9B,IAAS,GAAM,aACjB;AAAA,IAAE,OAAO,EAAK;AAAA,IAAO,OAAO,EAAK,SAAS;AAAA,IAAI,YAAY,EAAK;AAAA,EAAW,IAC1E,QACE,IAAW,KAA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roInsightsCopy } from '../../core/types/localization';
|
|
2
|
+
import { InsightsFeedCopy, MicroInsightsCopy } from '../../core/types/localization';
|
|
3
3
|
export declare class CopyStore {
|
|
4
4
|
copyApi: GlobalCopyApi;
|
|
5
5
|
copyObject: MicroInsightsCopy;
|
|
6
6
|
namespace: string;
|
|
7
7
|
translationKey: string;
|
|
8
|
+
/** Insights 2.0 state words (a CTA presenter's title and label), which hosts may not load for micro. */
|
|
9
|
+
insightsFeedKey: string;
|
|
10
|
+
insightsFeedCopy: InsightsFeedCopy | undefined;
|
|
8
11
|
constructor();
|
|
9
12
|
initialize: (endpoint: string, token: string) => Promise<void>;
|
|
10
13
|
loadCopy: () => Promise<void>;
|
|
14
|
+
private insightsFeedRequest;
|
|
15
|
+
/**
|
|
16
|
+
* insights_feed, fetched at most once per widget and only when a card needs it (a step that mirrors
|
|
17
|
+
* on micro, `compactStatus`). Optional: a failure leaves those cards on their unanswered words.
|
|
18
|
+
*/
|
|
19
|
+
loadInsightsFeedCopy: () => Promise<void>;
|
|
11
20
|
get cardsCopy(): any;
|
|
12
21
|
get carouselCopy(): any;
|
|
13
22
|
get zeroStateCopy(): any;
|
|
@@ -1,22 +1,31 @@
|
|
|
1
|
-
import { GlobalCopyApi as
|
|
2
|
-
import { makeAutoObservable as
|
|
3
|
-
var
|
|
4
|
-
copyApi = new
|
|
1
|
+
import { GlobalCopyApi as t } from "../../core/api/GlobalCopyApi.es.js";
|
|
2
|
+
import { makeAutoObservable as o, runInAction as s } from "mobx";
|
|
3
|
+
var p = class {
|
|
4
|
+
copyApi = new t("/", "");
|
|
5
5
|
copyObject = {};
|
|
6
6
|
namespace = "experiences";
|
|
7
7
|
translationKey = "micro_insights";
|
|
8
|
+
insightsFeedKey = "insights_feed";
|
|
9
|
+
insightsFeedCopy = void 0;
|
|
8
10
|
constructor() {
|
|
9
|
-
|
|
11
|
+
o(this);
|
|
10
12
|
}
|
|
11
|
-
initialize = async (
|
|
12
|
-
this.copyApi = new
|
|
13
|
+
initialize = async (e, i) => {
|
|
14
|
+
this.copyApi = new t(e, i), await this.loadCopy();
|
|
13
15
|
};
|
|
14
16
|
loadCopy = async () => {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
this.copyObject =
|
|
17
|
+
const e = await this.copyApi.getGlobalCopy(this.namespace, this.translationKey);
|
|
18
|
+
s(() => {
|
|
19
|
+
this.copyObject = e[this.translationKey];
|
|
18
20
|
});
|
|
19
21
|
};
|
|
22
|
+
insightsFeedRequest = void 0;
|
|
23
|
+
loadInsightsFeedCopy = () => (this.insightsFeedRequest ??= this.copyApi.getGlobalCopy(this.namespace, this.insightsFeedKey).then((e) => {
|
|
24
|
+
s(() => {
|
|
25
|
+
this.insightsFeedCopy = e?.[this.insightsFeedKey];
|
|
26
|
+
});
|
|
27
|
+
}).catch(() => {
|
|
28
|
+
}), this.insightsFeedRequest);
|
|
20
29
|
get cardsCopy() {
|
|
21
30
|
return this.copyObject.cards;
|
|
22
31
|
}
|
|
@@ -28,7 +37,7 @@ var r = class {
|
|
|
28
37
|
}
|
|
29
38
|
};
|
|
30
39
|
export {
|
|
31
|
-
|
|
40
|
+
p as CopyStore
|
|
32
41
|
};
|
|
33
42
|
|
|
34
43
|
//# sourceMappingURL=CopyStore.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CopyStore.es.js","names":[],"sources":["../../../src/microinsights/stores/CopyStore.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from 'mobx'\nimport { GlobalCopyApi } from '../../core/api/GlobalCopyApi'\nimport type { MicroInsightsCopy } from '../../core/types/localization'\n\nexport class CopyStore {\n copyApi: GlobalCopyApi = new GlobalCopyApi('/', '')\n copyObject: MicroInsightsCopy = {} as MicroInsightsCopy\n namespace = 'experiences'\n translationKey = 'micro_insights'\n\n constructor() {\n makeAutoObservable(this)\n }\n\n // NOTE: Not sure if this is special case, but other stores have this deprecation todo\n // DEPRECATED: Initialize api in constructor and use loadCopy instead\n // TODO: Remove this function\n initialize = async (endpoint: string, token: string) => {\n this.copyApi = new GlobalCopyApi(endpoint, token)\n await this.loadCopy()\n }\n\n loadCopy = async () => {\n const copy = await this.copyApi.getGlobalCopy(this.namespace, this.translationKey)\n\n runInAction(() => {\n this.copyObject = copy[this.translationKey]\n })\n }\n\n get cardsCopy(): any {\n return this.copyObject.cards\n }\n\n get carouselCopy(): any {\n return this.copyObject.carousel\n }\n\n get zeroStateCopy(): any {\n return this.copyObject.zero_state\n }\n}\n"],"mappings":";;AAIA,IAAa,IAAb,MAAuB;AAAA,EACrB,UAAyB,IAAI,EAAc,KAAK,EAAE;AAAA,EAClD,aAAgC,CAAC;AAAA,EACjC,YAAY;AAAA,EACZ,iBAAiB;AAAA,EAEjB,cAAc;AACZ,IAAA,EAAmB,IAAI;AAAA,EACzB;AAAA,EAKA,aAAa,OAAO,GAAkB,MAAkB;AACtD,SAAK,UAAU,IAAI,EAAc,GAAU,CAAK,GAChD,MAAM,KAAK,SAAS;AAAA,EACtB;AAAA,EAEA,WAAW,YAAY;AACrB,UAAM,IAAO,MAAM,KAAK,QAAQ,cAAc,KAAK,WAAW,KAAK,cAAc;AAEjF,IAAA,EAAA,MAAkB;AAChB,WAAK,aAAa,EAAK,KAAK,cAAA;AAAA,IAC9B,CAAC;AAAA,EACH;AAAA,EAEA,IAAI,YAAiB;AACnB,WAAO,KAAK,WAAW;AAAA,EACzB;AAAA,EAEA,IAAI,eAAoB;AACtB,WAAO,KAAK,WAAW;AAAA,EACzB;AAAA,EAEA,IAAI,gBAAqB;AACvB,WAAO,KAAK,WAAW;AAAA,EACzB;AACF"}
|
|
1
|
+
{"version":3,"file":"CopyStore.es.js","names":[],"sources":["../../../src/microinsights/stores/CopyStore.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from 'mobx'\nimport { GlobalCopyApi } from '../../core/api/GlobalCopyApi'\nimport type { InsightsFeedCopy, MicroInsightsCopy } from '../../core/types/localization'\n\nexport class CopyStore {\n copyApi: GlobalCopyApi = new GlobalCopyApi('/', '')\n copyObject: MicroInsightsCopy = {} as MicroInsightsCopy\n namespace = 'experiences'\n translationKey = 'micro_insights'\n /** Insights 2.0 state words (a CTA presenter's title and label), which hosts may not load for micro. */\n insightsFeedKey = 'insights_feed'\n insightsFeedCopy: InsightsFeedCopy | undefined = undefined\n\n constructor() {\n makeAutoObservable(this)\n }\n\n // NOTE: Not sure if this is special case, but other stores have this deprecation todo\n // DEPRECATED: Initialize api in constructor and use loadCopy instead\n // TODO: Remove this function\n initialize = async (endpoint: string, token: string) => {\n this.copyApi = new GlobalCopyApi(endpoint, token)\n await this.loadCopy()\n }\n\n loadCopy = async () => {\n const copy = await this.copyApi.getGlobalCopy(this.namespace, this.translationKey)\n\n runInAction(() => {\n this.copyObject = copy[this.translationKey]\n })\n }\n\n private insightsFeedRequest: Promise<void> | undefined = undefined\n\n /**\n * insights_feed, fetched at most once per widget and only when a card needs it (a step that mirrors\n * on micro, `compactStatus`). Optional: a failure leaves those cards on their unanswered words.\n */\n loadInsightsFeedCopy = (): Promise<void> => {\n this.insightsFeedRequest ??= this.copyApi\n .getGlobalCopy(this.namespace, this.insightsFeedKey)\n .then((copy) => {\n runInAction(() => {\n this.insightsFeedCopy = copy?.[this.insightsFeedKey]\n })\n })\n .catch(() => undefined)\n\n return this.insightsFeedRequest\n }\n\n get cardsCopy(): any {\n return this.copyObject.cards\n }\n\n get carouselCopy(): any {\n return this.copyObject.carousel\n }\n\n get zeroStateCopy(): any {\n return this.copyObject.zero_state\n }\n}\n"],"mappings":";;AAIA,IAAa,IAAb,MAAuB;AAAA,EACrB,UAAyB,IAAI,EAAc,KAAK,EAAE;AAAA,EAClD,aAAgC,CAAC;AAAA,EACjC,YAAY;AAAA,EACZ,iBAAiB;AAAA,EAEjB,kBAAkB;AAAA,EAClB,mBAAiD;AAAA,EAEjD,cAAc;AACZ,IAAA,EAAmB,IAAI;AAAA,EACzB;AAAA,EAKA,aAAa,OAAO,GAAkB,MAAkB;AACtD,SAAK,UAAU,IAAI,EAAc,GAAU,CAAK,GAChD,MAAM,KAAK,SAAS;AAAA,EACtB;AAAA,EAEA,WAAW,YAAY;AACrB,UAAM,IAAO,MAAM,KAAK,QAAQ,cAAc,KAAK,WAAW,KAAK,cAAc;AAEjF,IAAA,EAAA,MAAkB;AAChB,WAAK,aAAa,EAAK,KAAK,cAAA;AAAA,IAC9B,CAAC;AAAA,EACH;AAAA,EAEA,sBAAyD;AAAA,EAMzD,uBAAA,OACE,KAAK,wBAAwB,KAAK,QAC/B,cAAc,KAAK,WAAW,KAAK,eAAe,EAClD,KAAA,CAAM,MAAS;AACd,IAAA,EAAA,MAAkB;AAChB,WAAK,mBAAmB,IAAO,KAAK,eAAA;AAAA,IACtC,CAAC;AAAA,EACH,CAAC,EACA,MAAA,MAAA;AAAA,GAAqB,GAEjB,KAAK;AAAA,EAGd,IAAI,YAAiB;AACnB,WAAO,KAAK,WAAW;AAAA,EACzB;AAAA,EAEA,IAAI,eAAoB;AACtB,WAAO,KAAK,WAAW;AAAA,EACzB;AAAA,EAEA,IAAI,gBAAqB;AACvB,WAAO,KAAK,WAAW;AAAA,EACzB;AACF"}
|