{"version":3,"file":"link.BFhrHoKA.js","sources":["../../../src/lib/analytics-utils.ts","../../../src/components/ui/link.tsx"],"sourcesContent":["/**\n * Checks if an element is visible in the DOM hierarchy, considering parent elements with display: none.\n * @param {Element} element - The element to check for visibility.\n * @returns {boolean} True if the element is visible, false otherwise.\n * @example\n * // Example usage:\n * const element = document.querySelector('.my-element');\n * if (isElementVisible(element)) {\n * console.log('Element is visible');\n * } else {\n * console.log('Element is not visible');\n * }\n */\nfunction isElementVisible(element: Element): boolean {\n // Check if element itself is hidden by display: none\n const computedStyle = window.getComputedStyle(element)\n if (computedStyle.display === 'none') {\n return false\n }\n\n // Check if any parent element is hidden by display: none\n let parent = element.parentElement\n while (parent) {\n const parentComputedStyle = window.getComputedStyle(parent)\n if (parentComputedStyle.display === 'none') {\n return false\n }\n parent = parent.parentElement\n }\n\n return true\n}\n\n/**\n * Finds visible elements matching the provided CSS selector\n * @param {string} selector - The CSS selector for the elements to search for.\n * @returns {Array.} An array containing only the visible elements in the DOM\n * hierarchy matching the selector.\n * @example\n * // Example usage:\n * const enrollNowCtas = findVisibleElements('[data-cta-type=\"enroll-now\"]')\n * console.log(enrollNowCtas) // Array of visible elements with data-cta-type=\"enroll-now\"\n *\n * const visibleImages = findVisibleElements('img')\n * console.log(visibleImages) // Array of visible images\n */\nexport function findVisibleElements(selector: string): Element[] {\n // Select all elements matching the provided selector\n const elements = document.querySelectorAll(selector)\n // Filter out the visible elements\n const visibleElements = Array.from(elements).filter(function (element) {\n return isElementVisible(element)\n })\n // console.log(`Visible elements for ${selector}:`, visibleElements);\n return visibleElements\n}\n\n/**\n * Filters an object to include only the properties that are not undefined or null.\n * @param attributes - The object containing all possible attributes.\n * @returns A new object containing only the attributes with defined and non-null values.\n */\nexport function buildAnalyticsData>(attributes: T): Partial {\n return Object.entries(attributes).reduce((acc, [key, value]) => {\n if (value !== undefined && value !== null) {\n acc[key as keyof T] = value\n }\n return acc\n }, {} as Partial)\n}\n","import { buildAnalyticsData } from '@lib/analytics-utils'\nimport type {\n AnalyticsAttributes,\n ContextPlacement,\n CtaType,\n DesignVersion,\n PlanType\n} from '@lib/analytics.d'\nimport { cn } from '@lib/utils'\nimport { cva } from 'class-variance-authority'\n\nconst linkVariants = cva('cursor-pointer', {\n variants: {\n variant: {\n inline: 'link-variant-inline',\n black: 'link-variant-black',\n blue: 'link-variant-blue',\n gray: 'link-variant-gray',\n white: 'link-variant-white',\n content: 'link-variant-content'\n }\n },\n defaultVariants: {\n variant: 'black'\n }\n})\n\ntype Variant = 'inline' | 'black' | 'blue' | 'gray' | 'white' | 'content'\n\ninterface LinkProps extends React.AnchorHTMLAttributes {\n href: string\n id?: string\n target?: '_blank' | '_self' | '_parent' | '_top'\n variant?: Variant\n className?: string\n children: React.ReactNode\n analyticsContext?: string\n analyticsSubContext?: string\n ctaType?: CtaType\n planId?: number\n planName?: string\n planState?: string\n contextPlacement?: ContextPlacement\n planType?: PlanType\n designVersion?: DesignVersion\n onClick?: React.MouseEventHandler\n userTarget?: string\n}\n\nconst Link = ({\n href,\n id,\n target = '_self',\n variant = 'black',\n className = '',\n children,\n analyticsContext,\n analyticsSubContext,\n ctaType,\n planId,\n planName,\n planState,\n contextPlacement,\n planType,\n designVersion,\n onClick,\n userTarget,\n ...props\n}: LinkProps) => {\n const linkClass = linkVariants({ variant, className })\n\n const attributes: AnalyticsAttributes = {\n 'data-analytics-context': analyticsContext,\n 'data-analytics-sub-context': analyticsSubContext,\n 'data-cta-type': ctaType,\n 'data-plan-id': planId,\n 'data-plan-name': planName,\n 'data-plan-state': planState,\n 'data-context-placement': contextPlacement,\n 'data-plan-type': planType,\n 'data-design-version': designVersion,\n 'data-user-target': userTarget\n }\n\n const analyticsData = buildAnalyticsData(attributes)\n\n return (\n \n {children}\n \n )\n}\n\nexport { linkVariants, Link, type Variant }\n"],"names":["buildAnalyticsData","attributes","acc","key","value","linkVariants","cva","Link","href","id","target","variant","className","children","analyticsContext","analyticsSubContext","ctaType","planId","planName","planState","contextPlacement","planType","designVersion","onClick","userTarget","props","linkClass","analyticsData","jsx","cn"],"mappings":"keA8DO,SAASA,EAAkDC,EAA2B,CACpF,OAAA,OAAO,QAAQA,CAAU,EAAE,OAAO,CAACC,EAAK,CAACC,EAAKC,CAAK,KAC7BA,GAAU,OACnCF,EAAIC,CAAc,EAAIC,GAEjBF,GACN,CAAgB,CAAA,CACrB,CC1DM,MAAAG,EAAeC,EAAI,iBAAkB,CACzC,SAAU,CACR,QAAS,CACP,OAAQ,sBACR,MAAO,qBACP,KAAM,oBACN,KAAM,oBACN,MAAO,qBACP,QAAS,sBACX,CACF,EACA,gBAAiB,CACf,QAAS,OACX,CACF,CAAC,EAwBKC,EAAO,CAAC,CACZ,KAAAC,EACA,GAAAC,EACA,OAAAC,EAAS,QACT,QAAAC,EAAU,QACV,UAAAC,EAAY,GACZ,SAAAC,EACA,iBAAAC,EACA,oBAAAC,EACA,QAAAC,EACA,OAAAC,EACA,SAAAC,EACA,UAAAC,EACA,iBAAAC,EACA,SAAAC,EACA,cAAAC,EACA,QAAAC,EACA,WAAAC,EACA,GAAGC,CACL,IAAiB,CACf,MAAMC,EAAYrB,EAAa,CAAE,QAAAM,EAAS,UAAAC,CAAW,CAAA,EAe/Ce,EAAgB3B,EAbkB,CACtC,yBAA0Bc,EAC1B,6BAA8BC,EAC9B,gBAAiBC,EACjB,eAAgBC,EAChB,iBAAkBC,EAClB,kBAAmBC,EACnB,yBAA0BC,EAC1B,iBAAkBC,EAClB,sBAAuBC,EACvB,mBAAoBE,CAAA,CAG6B,EAGjD,OAAAI,EAAA,IAAC,IAAA,CACC,GAAAnB,EACA,KAAAD,EACA,OAAAE,EACA,QAAAa,EACA,UAAWM,EAAGH,EAAW,OAAO,EAC/B,GAAGC,EACH,GAAGF,EAEH,SAAAZ,CAAA,CAAA,CAGP"}