{"version":3,"file":"utils.cjs","sources":["../../../../src/components/feedback/utils.ts"],"sourcesContent":["import React, { type JSXElementConstructor, type FC } from \"react\";\nimport {\n    CheckboxQuestion,\n    RadioQuestion,\n    SmileyQuestion,\n    TextQuestion,\n} from \"./questions/index.js\";\nimport type { QuestionProps, QuestionType } from \"./types.js\";\n\nexport function getChildrenOfType<P>(\n    ...allowedTypes: Array<string | JSXElementConstructor<P>>\n) {\n    return (\n        children: React.ReactNode,\n    ):\n        | React.ReactElement<P, string | React.JSXElementConstructor<unknown>>[]\n        | null\n        | undefined =>\n        React.Children.map(children, (child) => {\n            if (\n                React.isValidElement<P>(child) &&\n                allowedTypes.includes(child.type)\n            ) {\n                return child;\n            }\n            return undefined;\n        });\n}\n\nexport const getQuestionFromType = (type: QuestionType): FC<QuestionProps> => {\n    switch (type) {\n        case \"radio\":\n            return RadioQuestion;\n        case \"checkbox\":\n            return CheckboxQuestion;\n        case \"text\":\n            return TextQuestion;\n        case \"smiley\":\n            return SmileyQuestion;\n\n        default:\n            return RadioQuestion;\n    }\n};\n"],"names":["allowedTypes","children","React","Children","map","child","isValidElement","includes","type","RadioQuestion","CheckboxQuestion","TextQuestion","SmileyQuestion"],"mappings":"ijBASO,YACAA,GAEH,OACIC,GAKAC,EAAMC,SAASC,IAAIH,EAAWI,IAC1B,GACIH,EAAMI,eAAkBD,IACxBL,EAAaO,SAASF,EAAMG,MAE5B,OAAOH,GAIvB,8BAEoCG,IAChC,OAAQA,GACJ,IAAK,QASL,QACI,OAAOC,EAAAA,cARX,IAAK,WACD,OAAOC,EAAAA,iBACX,IAAK,OACD,OAAOC,EAAAA,aACX,IAAK,SACD,OAAOC,EAAAA"}