{"version":3,"file":"umd.js","sources":["../src/Common.jsx"],"sourcesContent":["import PropTypes from 'prop-types';\nimport { connect, Provider, useSelector } from 'react-redux';\nimport React from 'react';\nimport Parser from 'html-react-parser';\n\nfunction CommonRenderProp(props) {\n\treturn props.render(props.commonData);\n}\n\nCommonRenderProp.propTypes = {\n\trender: PropTypes.func.isRequired,\n\tcommonData: PropTypes.shape({\n\t\tlabels: PropTypes.shape({}).isRequired,\n\t\tsitemap: PropTypes.shape({}).isRequired,\n\t\tprefs: PropTypes.shape({}).isRequired,\n\t\tflags: PropTypes.shape({}).isRequired\n\t}).isRequired\n};\n\nCommonRenderProp.displayName = 'CommonRenderProp';\n\nconst labelAsHTML = (label, Tag = React.Fragment) => {\n\tconst html = Parser(label);\n\treturn {html};\n};\n\nconst labelMethods = (labels) => {\n\treturn {\n\t\thas: (key) => labels[key] !== undefined,\n\t\tget: (key) => labels[key] || key,\n\t\tgetKeys: () => Object.keys(labels),\n\t\tgetAll: () => labels,\n\t\tgetHTML: (key, Tag) => labelAsHTML(labels[key] || key, Tag)\n\t};\n};\n\nconst sitemapMethods = (sitemap) => {\n\treturn {\n\t\thas: (alias) => sitemap[alias] !== undefined,\n\t\tget: (alias) => sitemap[alias] || null,\n\t\tgetAll: () => sitemap\n\t};\n};\n\nexport const useFlags = () => useSelector((state) => state.flags);\n\nexport const useLabels = () => {\n\tconst labels = useSelector((state) => state.labels);\n\treturn labelMethods(labels);\n};\n\nexport const usePrefs = () => useSelector((state) => state.prefs);\n\nexport const useRequestData = () => useSelector((state) => state.requestData);\n\nexport const useSitemap = () => {\n\tconst sitemap = useSelector((state) => state.sitemap);\n\treturn sitemapMethods(sitemap);\n};\n\nconst mapStateToProps = (state) => {\n\treturn {\n\t\tcommonData: {\n\t\t\tlabels: labelMethods(state.labels),\n\t\t\tsitemap: sitemapMethods(state.sitemap),\n\t\t\tprefs: state.prefs,\n\t\t\tflags: state.flags\n\t\t}\n\t};\n};\n\nexport const Common = connect(\n\tmapStateToProps,\n\tnull, // mapDispatchToProps\n\tnull, // mergeProps\n\t{ pure: false }\n)(CommonRenderProp);\n\nCommon.displayName = 'Common';\n\nexport function createStore(state) {\n\treturn {\n\t\tsubscribe: () => {},\n\t\tdispatch: () => {},\n\t\tgetState: () => state\n\t};\n}\n\nexport function CommonTester(props) {\n\tconst { initialState, flags, labels, sitemap, prefs, render } = props;\n\tconst store = createStore({\n\t\t...initialState,\n\t\tflags,\n\t\tlabels,\n\t\tsitemap,\n\t\tprefs\n\t});\n\n\treturn {render()};\n}\n\nCommonTester.displayName = 'CommonTester';\n\nCommonTester.propTypes = {\n\trender: PropTypes.func.isRequired,\n\tlabels: PropTypes.shape({}),\n\tsitemap: PropTypes.shape({}),\n\tprefs: PropTypes.shape({}),\n\tflags: PropTypes.shape({}),\n\tinitialState: PropTypes.shape({})\n};\n\nCommonTester.defaultProps = {\n\tlabels: {},\n\tsitemap: {},\n\tprefs: {},\n\tflags: {},\n\tinitialState: {}\n};\n"],"names":["CommonRenderProp","props","render","commonData","propTypes","PropTypes","func","isRequired","shape","labels","sitemap","prefs","flags","displayName","labelMethods","has","key","undefined","get","getKeys","Object","keys","getAll","getHTML","Tag","label","React","Fragment","html","Parser","labelAsHTML","sitemapMethods","alias","Common","connect","state","pure","createStore","subscribe","dispatch","getState","CommonTester","initialState","store","Provider","defaultProps","useSelector","requestData"],"mappings":"yjBAKA,SAASA,EAAiBC,UAClBA,EAAMC,OAAOD,EAAME,YAG3BH,EAAiBI,UAAY,CAC5BF,OAAQG,UAAUC,KAAKC,WACvBJ,WAAYE,UAAUG,MAAM,CAC3BC,OAAQJ,UAAUG,MAAM,IAAID,WAC5BG,QAASL,UAAUG,MAAM,IAAID,WAC7BI,MAAON,UAAUG,MAAM,IAAID,WAC3BK,MAAOP,UAAUG,MAAM,IAAID,aACzBA,YAGJP,EAAiBa,YAAc,mBAE/B,MAKMC,EAAgBL,IACd,CACNM,IAAMC,QAAwBC,IAAhBR,EAAOO,GACrBE,IAAMF,GAA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