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Aa,EAAE,KAAK;IACpB,gBAAgB,EAAE,CAAC;IACnB,sBAAsB,EAAE,cAAO,CAAC;CACnC,CAAC,CAAA;AASF,MAAM,CAAC,IAAM,0BAA0B,GAAG,UAAC,EAAyD;QAAvD,SAAS,eAAA,EAAE,QAAQ,cAAA,EAAE,YAAY,kBAAA,EAAE,KAAK,WAAA;IACjF,OAAO,YAAY;QACf,CAAC,CAAC,YAAY,CAAC,SAAS,EAAE;YACpB,uBAAuB,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE;YAC7C,KAAK,OAAA;SACR,CAAC;QACJ,CAAC,CAAC,YAAY,CAAC,SAAS,EAAE;YACpB,QAAQ,UAAA;YACR,KAAK,OAAA;SACR,CAAC,CAAA;AACZ,CAAC,CAAA","sourcesContent":["import { PostHog } from '../../posthog-core'\nimport { Survey, SurveyAppearance, MultipleSurveyQuestion, SurveyQuestion } from '../../posthog-surveys-types'\nimport { window as _window, document as _document } from '../../utils/globals'\nimport { VNode, cloneElement, createContext } from 'preact'\n// We cast the types here which is dangerous but protected by the top level generateSurveys call\nconst window = _window as Window & typeof globalThis\nconst document = _document as Document\n\nexport const style = (appearance: SurveyAppearance | null) => {\n    const positions = {\n        left: 'left: 30px;',\n        right: 'right: 30px;',\n        center: `\n            left: 50%;\n            transform: translateX(-50%);\n          `,\n    }\n    return `\n          .survey-form {\n              position: fixed;\n              margin: 0px;\n              bottom: 0px;\n              color: black;\n              font-weight: normal;\n              font-family: -apple-system, BlinkMacSystemFont, \"Inter\", \"Segoe UI\", \"Roboto\", Helvetica, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\";\n              text-align: left;\n              max-width: ${parseInt(appearance?.maxWidth || '300')}px;\n              z-index: ${parseInt(appearance?.zIndex || '99999')};\n              border: 1.5px solid ${appearance?.borderColor || '#c9c6c6'};\n              border-bottom: 0px;\n              width: 100%;\n              ${positions[appearance?.position || 'right'] || 'right: 30px;'}\n          }\n          .form-submit[disabled] {\n              opacity: 0.6;\n              filter: grayscale(50%);\n              cursor: not-allowed;\n          }\n          .survey-form {\n              flex-direction: column;\n              background: ${appearance?.backgroundColor || '#eeeded'};\n              border-top-left-radius: 10px;\n              border-top-right-radius: 10px;\n              box-shadow: -6px 0 16px -8px rgb(0 0 0 / 8%), -9px 0 28px 0 rgb(0 0 0 / 5%), -12px 0 48px 16px rgb(0 0 0 / 3%);\n          }\n          .survey-form textarea {\n              color: #2d2d2d;\n              font-size: 14px;\n              font-family: -apple-system, BlinkMacSystemFont, \"Inter\", \"Segoe UI\", \"Roboto\", Helvetica, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\";\n              background: white;\n              color: black;\n              outline: none;\n              padding-left: 10px;\n              padding-right: 10px;\n              padding-top: 10px;\n              border-radius: 6px;\n              border-color: ${appearance?.borderColor || '#c9c6c6'};\n              margin-top: 14px;\n          }\n          .form-submit {\n              box-sizing: border-box;\n              margin: 0;\n              font-family: inherit;\n              overflow: visible;\n              text-transform: none;\n              position: relative;\n              display: inline-block;\n              font-weight: 700;\n              white-space: nowrap;\n              text-align: center;\n              border: 1.5px solid transparent;\n              cursor: pointer;\n              user-select: none;\n              touch-action: manipulation;\n              padding: 12px;\n              font-size: 14px;\n              border-radius: 6px;\n              outline: 0;\n              background: ${appearance?.submitButtonColor || 'black'} !important;\n              text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.12);\n              box-shadow: 0 2px 0 rgba(0, 0, 0, 0.045);\n              width: 100%;\n          }\n          .form-cancel {\n              float: right;\n              border: none;\n              background: none;\n              cursor: pointer;\n          }\n          .cancel-btn-wrapper {\n              position: absolute;\n              width: 35px;\n              height: 35px;\n              border-radius: 100%;\n              top: 0;\n              right: 0;\n              transform: translate(50%, -50%);\n              background: white;\n              border: 1.5px solid ${appearance?.borderColor || '#c9c6c6'};\n              display: flex;\n              justify-content: center;\n              align-items: center;\n          }\n          .bolded { font-weight: 600; }\n          .buttons {\n              display: flex;\n              justify-content: center;\n          }\n          .footer-branding {\n              font-size: 11px;\n              margin-top: 10px;\n              text-align: center;\n              display: flex;\n              justify-content: center;\n              gap: 4px;\n              align-items: center;\n              font-weight: 500;\n              background: ${appearance?.backgroundColor || '#eeeded'};\n              text-decoration: none;\n          }\n          .survey-box {\n              padding: 20px 25px 10px;\n              display: flex;\n              flex-direction: column;\n              border-radius: 10px;\n          }\n          .survey-question {\n              font-weight: 500;\n              font-size: 14px;\n              background: ${appearance?.backgroundColor || '#eeeded'};\n          }\n          .question-textarea-wrapper {\n              display: flex;\n              flex-direction: column;\n          }\n          .description {\n              font-size: 13px;\n              padding-top: 5px;\n              background: ${appearance?.backgroundColor || '#eeeded'};\n          }\n          .ratings-number {\n              background-color: ${appearance?.ratingButtonColor || 'white'};\n              font-size: 16px;\n              font-weight: 600;\n              padding: 8px 0px;\n              border: none;\n          }\n          .ratings-number:hover {\n              cursor: pointer;\n          }\n          .rating-options {\n              margin-top: 14px;\n          }\n          .rating-options-number {\n              display: grid;\n              border-radius: 6px;\n              overflow: hidden;\n              border: 1.5px solid ${appearance?.borderColor || '#c9c6c6'};\n          }\n          .rating-options-number > .ratings-number {\n              border-right: 1px solid ${appearance?.borderColor || '#c9c6c6'};\n          }\n          .rating-options-number > .ratings-number:last-of-type {\n              border-right: 0px;\n          }\n          .rating-options-number .rating-active {\n              background: ${appearance?.ratingButtonActiveColor || 'black'};\n          }\n          .rating-options-emoji {\n              display: flex;\n              justify-content: space-between;\n          }\n          .ratings-emoji {\n              font-size: 16px;\n              background-color: transparent;\n              border: none;\n              padding: 0px;\n          }\n          .ratings-emoji:hover {\n              cursor: pointer;\n          }\n          .ratings-emoji.rating-active svg {\n              fill: ${appearance?.ratingButtonActiveColor || 'black'};\n          }\n          .emoji-svg {\n              fill: ${appearance?.ratingButtonColor || '#c9c6c6'};\n          }\n          .rating-text {\n              display: flex;\n              flex-direction: row;\n              font-size: 11px;\n              justify-content: space-between;\n              margin-top: 6px;\n              background: ${appearance?.backgroundColor || '#eeeded'};\n              opacity: .60;\n          }\n          .multiple-choice-options {\n              margin-top: 13px;\n              font-size: 14px;\n          }\n          .multiple-choice-options .choice-option {\n              display: flex;\n              align-items: center;\n              gap: 4px;\n              font-size: 13px;\n              cursor: pointer;\n              margin-bottom: 5px;\n              position: relative;\n          }\n          .multiple-choice-options > .choice-option:last-of-type {\n              margin-bottom: 0px;\n          }\n          .multiple-choice-options input {\n              cursor: pointer;\n              position: absolute;\n              opacity: 0;\n          }\n          .choice-check {\n              position: absolute;\n              right: 10px;\n              background: white;\n          }\n          .choice-check svg {\n              display: none;\n          }\n          .multiple-choice-options .choice-option:hover .choice-check svg {\n              display: inline-block;\n              opacity: .25;\n          }\n          .multiple-choice-options input:checked + label + .choice-check svg {\n              display: inline-block;\n              opacity: 100% !important;\n          }\n          .multiple-choice-options input:checked + label {\n              font-weight: bold;\n              border: 1.5px solid rgba(0,0,0);\n          }\n          .multiple-choice-options input:checked + label input {\n              font-weight: bold;\n          }\n          .multiple-choice-options label {\n              width: 100%;\n              cursor: pointer;\n              padding: 10px;\n              border: 1.5px solid rgba(0,0,0,.25);\n              border-radius: 4px;\n              background: white;\n          }\n          .multiple-choice-options .choice-option-open label {\n              padding-right: 30px;\n              display: flex;\n              flex-wrap: wrap;\n              gap: 8px;\n              max-width: 100%;\n          }\n          .multiple-choice-options .choice-option-open label span {\n              width: 100%;\n          }\n          .multiple-choice-options .choice-option-open input:disabled + label {\n              opacity: 0.6;\n          }\n          .multiple-choice-options .choice-option-open label input {\n              position: relative;\n              opacity: 1;\n              flex-grow: 1;\n              border: 0;\n              outline: 0;\n          }\n          .thank-you-message {\n              position: fixed;\n              bottom: 0px;\n              z-index: ${parseInt(appearance?.zIndex || '99999')};\n              box-shadow: -6px 0 16px -8px rgb(0 0 0 / 8%), -9px 0 28px 0 rgb(0 0 0 / 5%), -12px 0 48px 16px rgb(0 0 0 / 3%);\n              font-family: -apple-system, BlinkMacSystemFont, \"Inter\", \"Segoe UI\", \"Roboto\", Helvetica, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\";\n              border-top-left-radius: 10px;\n              border-top-right-radius: 10px;\n              padding: 20px 25px 10px;\n              background: ${appearance?.backgroundColor || '#eeeded'};\n              border: 1.5px solid ${appearance?.borderColor || '#c9c6c6'};\n              text-align: center;\n              max-width: ${parseInt(appearance?.maxWidth || '300')}px;\n              min-width: 150px;\n              width: 100%;\n              ${positions[appearance?.position || 'right'] || 'right: 30px;'}\n          }\n          .thank-you-message-body {\n              margin-top: 6px;\n              font-size: 14px;\n              background: ${appearance?.backgroundColor || '#eeeded'};\n          }\n          .thank-you-message-header {\n              margin: 10px 0px 0px;\n              background: ${appearance?.backgroundColor || '#eeeded'};\n          }\n          .thank-you-message-container .form-submit {\n              margin-top: 20px;\n              margin-bottom: 10px;\n          }\n          .thank-you-message-countdown {\n              margin-left: 6px;\n          }\n          .bottom-section {\n              margin-top: 14px;\n          }\n          `\n}\n\nfunction nameToHex(name: string) {\n    return {\n        aliceblue: '#f0f8ff',\n        antiquewhite: '#faebd7',\n        aqua: '#00ffff',\n        aquamarine: '#7fffd4',\n        azure: '#f0ffff',\n        beige: '#f5f5dc',\n        bisque: '#ffe4c4',\n        black: '#000000',\n        blanchedalmond: '#ffebcd',\n        blue: '#0000ff',\n        blueviolet: '#8a2be2',\n        brown: '#a52a2a',\n        burlywood: '#deb887',\n        cadetblue: '#5f9ea0',\n        chartreuse: '#7fff00',\n        chocolate: '#d2691e',\n        coral: '#ff7f50',\n        cornflowerblue: '#6495ed',\n        cornsilk: '#fff8dc',\n        crimson: '#dc143c',\n        cyan: '#00ffff',\n        darkblue: '#00008b',\n        darkcyan: '#008b8b',\n        darkgoldenrod: '#b8860b',\n        darkgray: '#a9a9a9',\n        darkgreen: '#006400',\n        darkkhaki: '#bdb76b',\n        darkmagenta: '#8b008b',\n        darkolivegreen: '#556b2f',\n        darkorange: '#ff8c00',\n        darkorchid: '#9932cc',\n        darkred: '#8b0000',\n        darksalmon: '#e9967a',\n        darkseagreen: '#8fbc8f',\n        darkslateblue: '#483d8b',\n        darkslategray: '#2f4f4f',\n        darkturquoise: '#00ced1',\n        darkviolet: '#9400d3',\n        deeppink: '#ff1493',\n        deepskyblue: '#00bfff',\n        dimgray: '#696969',\n        dodgerblue: '#1e90ff',\n        firebrick: '#b22222',\n        floralwhite: '#fffaf0',\n        forestgreen: '#228b22',\n        fuchsia: '#ff00ff',\n        gainsboro: '#dcdcdc',\n        ghostwhite: '#f8f8ff',\n        gold: '#ffd700',\n        goldenrod: '#daa520',\n        gray: '#808080',\n        green: '#008000',\n        greenyellow: '#adff2f',\n        honeydew: '#f0fff0',\n        hotpink: '#ff69b4',\n        'indianred ': '#cd5c5c',\n        indigo: '#4b0082',\n        ivory: '#fffff0',\n        khaki: '#f0e68c',\n        lavender: '#e6e6fa',\n        lavenderblush: '#fff0f5',\n        lawngreen: '#7cfc00',\n        lemonchiffon: '#fffacd',\n        lightblue: '#add8e6',\n        lightcoral: '#f08080',\n        lightcyan: '#e0ffff',\n        lightgoldenrodyellow: '#fafad2',\n        lightgrey: '#d3d3d3',\n        lightgreen: '#90ee90',\n        lightpink: '#ffb6c1',\n        lightsalmon: '#ffa07a',\n        lightseagreen: '#20b2aa',\n        lightskyblue: '#87cefa',\n        lightslategray: '#778899',\n        lightsteelblue: '#b0c4de',\n        lightyellow: '#ffffe0',\n        lime: '#00ff00',\n        limegreen: '#32cd32',\n        linen: '#faf0e6',\n        magenta: '#ff00ff',\n        maroon: '#800000',\n        mediumaquamarine: '#66cdaa',\n        mediumblue: '#0000cd',\n        mediumorchid: '#ba55d3',\n        mediumpurple: '#9370d8',\n        mediumseagreen: '#3cb371',\n        mediumslateblue: '#7b68ee',\n        mediumspringgreen: '#00fa9a',\n        mediumturquoise: '#48d1cc',\n        mediumvioletred: '#c71585',\n        midnightblue: '#191970',\n        mintcream: '#f5fffa',\n        mistyrose: '#ffe4e1',\n        moccasin: '#ffe4b5',\n        navajowhite: '#ffdead',\n        navy: '#000080',\n        oldlace: '#fdf5e6',\n        olive: '#808000',\n        olivedrab: '#6b8e23',\n        orange: '#ffa500',\n        orangered: '#ff4500',\n        orchid: '#da70d6',\n        palegoldenrod: '#eee8aa',\n        palegreen: '#98fb98',\n        paleturquoise: '#afeeee',\n        palevioletred: '#d87093',\n        papayawhip: '#ffefd5',\n        peachpuff: '#ffdab9',\n        peru: '#cd853f',\n        pink: '#ffc0cb',\n        plum: '#dda0dd',\n        powderblue: '#b0e0e6',\n        purple: '#800080',\n        red: '#ff0000',\n        rosybrown: '#bc8f8f',\n        royalblue: '#4169e1',\n        saddlebrown: '#8b4513',\n        salmon: '#fa8072',\n        sandybrown: '#f4a460',\n        seagreen: '#2e8b57',\n        seashell: '#fff5ee',\n        sienna: '#a0522d',\n        silver: '#c0c0c0',\n        skyblue: '#87ceeb',\n        slateblue: '#6a5acd',\n        slategray: '#708090',\n        snow: '#fffafa',\n        springgreen: '#00ff7f',\n        steelblue: '#4682b4',\n        tan: '#d2b48c',\n        teal: '#008080',\n        thistle: '#d8bfd8',\n        tomato: '#ff6347',\n        turquoise: '#40e0d0',\n        violet: '#ee82ee',\n        wheat: '#f5deb3',\n        white: '#ffffff',\n        whitesmoke: '#f5f5f5',\n        yellow: '#ffff00',\n        yellowgreen: '#9acd32',\n    }[name.toLowerCase()]\n}\n\nfunction hex2rgb(c: string) {\n    if (c[0] === '#') {\n        const hexColor = c.replace(/^#/, '')\n        const r = parseInt(hexColor.slice(0, 2), 16)\n        const g = parseInt(hexColor.slice(2, 4), 16)\n        const b = parseInt(hexColor.slice(4, 6), 16)\n        return 'rgb(' + r + ',' + g + ',' + b + ')'\n    }\n    return 'rgb(255, 255, 255)'\n}\n\nexport function getContrastingTextColor(color: string = defaultBackgroundColor) {\n    let rgb\n    if (color[0] === '#') {\n        rgb = hex2rgb(color)\n    }\n    if (color.startsWith('rgb')) {\n        rgb = color\n    }\n    // otherwise it's a color name\n    const nameColorToHex = nameToHex(color)\n    if (nameColorToHex) {\n        rgb = hex2rgb(nameColorToHex)\n    }\n    if (!rgb) {\n        return 'black'\n    }\n    const colorMatch = rgb.match(/^rgba?\\((\\d+),\\s*(\\d+),\\s*(\\d+)(?:,\\s*(\\d+(?:\\.\\d+)?))?\\)$/)\n    if (colorMatch) {\n        const r = parseInt(colorMatch[1])\n        const g = parseInt(colorMatch[2])\n        const b = parseInt(colorMatch[3])\n        const hsp = Math.sqrt(0.299 * (r * r) + 0.587 * (g * g) + 0.114 * (b * b))\n        return hsp > 127.5 ? 'black' : 'white'\n    }\n    return 'black'\n}\nexport function getTextColor(el: HTMLElement) {\n    const backgroundColor = window.getComputedStyle(el).backgroundColor\n    if (backgroundColor === 'rgba(0, 0, 0, 0)') {\n        return 'black'\n    }\n    const colorMatch = backgroundColor.match(/^rgba?\\((\\d+),\\s*(\\d+),\\s*(\\d+)(?:,\\s*(\\d+(?:\\.\\d+)?))?\\)$/)\n    if (!colorMatch) return 'black'\n\n    const r = parseInt(colorMatch[1])\n    const g = parseInt(colorMatch[2])\n    const b = parseInt(colorMatch[3])\n    const hsp = Math.sqrt(0.299 * (r * r) + 0.587 * (g * g) + 0.114 * (b * b))\n    return hsp > 127.5 ? 'black' : 'white'\n}\n\nexport const defaultSurveyAppearance: SurveyAppearance = {\n    backgroundColor: '#eeeded',\n    submitButtonColor: 'black',\n    ratingButtonColor: 'white',\n    ratingButtonActiveColor: 'black',\n    borderColor: '#c9c6c6',\n    placeholder: 'Start typing...',\n    whiteLabel: false,\n    displayThankYouMessage: true,\n    thankYouMessageHeader: 'Thank you for your feedback!',\n    position: 'right',\n}\n\nexport const defaultBackgroundColor = '#eeeded'\n\nexport const createShadow = (styleSheet: string, surveyId: string) => {\n    const div = document.createElement('div')\n    div.className = `PostHogSurvey${surveyId}`\n    const shadow = div.attachShadow({ mode: 'open' })\n    if (styleSheet) {\n        const styleElement = Object.assign(document.createElement('style'), {\n            innerText: styleSheet,\n        })\n        shadow.appendChild(styleElement)\n    }\n    document.body.appendChild(div)\n    return shadow\n}\n\nexport const sendSurveyEvent = (\n    responses: Record<string, string | number | string[] | null> = {},\n    survey: Survey,\n    posthog?: PostHog\n) => {\n    if (!posthog) return\n    localStorage.setItem(getSurveySeenKey(survey), 'true')\n\n    posthog.capture('survey sent', {\n        $survey_name: survey.name,\n        $survey_id: survey.id,\n        $survey_iteration: survey.current_iteration,\n        $survey_iteration_start_date: survey.current_iteration_start_date,\n        $survey_questions: survey.questions.map((question) => question.question),\n        sessionRecordingUrl: posthog.get_session_replay_url?.(),\n        ...responses,\n        $set: {\n            [getSurveyInteractionProperty(survey, 'responded')]: true,\n        },\n    })\n    window.dispatchEvent(new Event('PHSurveySent'))\n}\n\nexport const dismissedSurveyEvent = (survey: Survey, posthog?: PostHog, readOnly?: boolean) => {\n    // TODO: state management and unit tests for this would be nice\n    if (readOnly || !posthog) {\n        return\n    }\n    posthog.capture('survey dismissed', {\n        $survey_name: survey.name,\n        $survey_id: survey.id,\n        $survey_iteration: survey.current_iteration,\n        $survey_iteration_start_date: survey.current_iteration_start_date,\n        sessionRecordingUrl: posthog.get_session_replay_url?.(),\n        $set: {\n            [getSurveyInteractionProperty(survey, 'dismissed')]: true,\n        },\n    })\n    localStorage.setItem(getSurveySeenKey(survey), 'true')\n    window.dispatchEvent(new Event('PHSurveyClosed'))\n}\n\n// Use the Fisher-yates algorithm to shuffle this array\n// https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle\nexport const shuffle = (array: any[]) => {\n    return array\n        .map((a) => ({ sort: Math.floor(Math.random() * 10), value: a }))\n        .sort((a, b) => a.sort - b.sort)\n        .map((a) => a.value)\n}\n\nconst reverseIfUnshuffled = (unshuffled: any[], shuffled: any[]): any[] => {\n    if (unshuffled.length === shuffled.length && unshuffled.every((val, index) => val === shuffled[index])) {\n        return shuffled.reverse()\n    }\n\n    return shuffled\n}\n\nexport const getDisplayOrderChoices = (question: MultipleSurveyQuestion): string[] => {\n    if (!question.shuffleOptions) {\n        return question.choices\n    }\n\n    const displayOrderChoices = question.choices\n    let openEndedChoice = ''\n    if (question.hasOpenChoice) {\n        // if the question has an open-ended choice, its always the last element in the choices array.\n        openEndedChoice = displayOrderChoices.pop()!\n    }\n\n    const shuffledOptions = reverseIfUnshuffled(displayOrderChoices, shuffle(displayOrderChoices))\n\n    if (question.hasOpenChoice) {\n        question.choices.push(openEndedChoice)\n        shuffledOptions.push(openEndedChoice)\n    }\n\n    return shuffledOptions\n}\n\nexport const getDisplayOrderQuestions = (survey: Survey): SurveyQuestion[] => {\n    // retain the original questionIndex so we can correlate values in the webapp\n    survey.questions.forEach((question, idx) => {\n        question.originalQuestionIndex = idx\n    })\n\n    if (!survey.appearance || !survey.appearance.shuffleQuestions) {\n        return survey.questions\n    }\n\n    return reverseIfUnshuffled(survey.questions, shuffle(survey.questions))\n}\n\nexport const getSurveySeenKey = (survey: Survey): string => {\n    let surveySeenKey = `seenSurvey_${survey.id}`\n    if (survey.current_iteration && survey.current_iteration > 0) {\n        surveySeenKey = `seenSurvey_${survey.id}_${survey.current_iteration}`\n    }\n\n    return surveySeenKey\n}\n\nconst getSurveyInteractionProperty = (survey: Survey, action: string): string => {\n    let surveyProperty = `$survey_${action}/${survey.id}`\n    if (survey.current_iteration && survey.current_iteration > 0) {\n        surveyProperty = `$survey_${action}/${survey.id}/${survey.current_iteration}`\n    }\n\n    return surveyProperty\n}\n\nexport const SurveyContext = createContext<{\n    isPreviewMode: boolean\n    previewPageIndex: number | undefined\n    handleCloseSurveyPopup: () => void\n}>({\n    isPreviewMode: false,\n    previewPageIndex: 0,\n    handleCloseSurveyPopup: () => {},\n})\n\ninterface RenderProps {\n    component: VNode<{ className: string }>\n    children: string\n    renderAsHtml?: boolean\n    style?: React.CSSProperties\n}\n\nexport const renderChildrenAsTextOrHtml = ({ component, children, renderAsHtml, style }: RenderProps) => {\n    return renderAsHtml\n        ? cloneElement(component, {\n              dangerouslySetInnerHTML: { __html: children },\n              style,\n          })\n        : cloneElement(component, {\n              children,\n              style,\n          })\n}\n"]}