@bigbinary/neeto-commons-frontend 3.0.6 → 3.0.9

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.
Files changed (420) hide show
  1. package/cjs/configs/babel.js +50 -0
  2. package/cjs/configs/eslint/globals.js +14 -0
  3. package/cjs/configs/eslint/helpers/index.js +74 -0
  4. package/cjs/configs/eslint/imports/enforced.js +29 -0
  5. package/cjs/configs/eslint/imports/order.js +65 -0
  6. package/cjs/configs/eslint/index.js +171 -0
  7. package/cjs/configs/eslint/overrides.js +30 -0
  8. package/cjs/configs/eslint/promise.js +8 -0
  9. package/cjs/configs/eslint/react.js +92 -0
  10. package/cjs/configs/nanos/eslint/imports/order.js +25 -0
  11. package/cjs/configs/nanos/eslint/index.js +28 -0
  12. package/cjs/configs/nanos/tailwind.js +11 -0
  13. package/cjs/configs/nanos/webpack/resolve.js +48 -0
  14. package/cjs/configs/nextjs/eslint/imports/order.js +25 -0
  15. package/cjs/configs/nextjs/eslint/index.js +22 -0
  16. package/cjs/configs/nextjs/webpack/resolve.js +1 -0
  17. package/cjs/configs/prettier.js +16 -0
  18. package/cjs/configs/scripts/dead-code-eliminator/constants.js +12 -0
  19. package/cjs/configs/scripts/dead-code-eliminator/index.js +266 -0
  20. package/cjs/configs/scripts/getPkgTranslations.js +45 -0
  21. package/cjs/configs/scripts/jsdoc-builder/constants.mjs +42 -0
  22. package/cjs/configs/scripts/jsdoc-builder/index.mjs +67 -0
  23. package/cjs/configs/scripts/jsdoc-builder/utils.mjs +219 -0
  24. package/cjs/configs/scripts/remove-unused-translation-keys/constants.js +11 -0
  25. package/cjs/configs/scripts/remove-unused-translation-keys/index.js +186 -0
  26. package/cjs/configs/tailwind.js +13 -0
  27. package/cjs/configs/webpack/helpers/customize-default-rules.js +54 -0
  28. package/cjs/configs/webpack/index.js +58 -0
  29. package/cjs/configs/webpack/resolve.js +53 -0
  30. package/cjs/configs/webpack/rules.js +34 -0
  31. package/{constants.cjs.js → cjs/constants/index.js} +11 -10
  32. package/cjs/constants/index.js.map +1 -0
  33. package/cjs/cypress-configs/initializer.js +32 -0
  34. package/cjs/cypress-configs/plugins.js +105 -0
  35. package/cjs/cypress-configs/resolve.js +17 -0
  36. package/cjs/cypress-configs/webpack.config.js +19 -0
  37. package/cjs/cypress-utils/commands.js +276 -0
  38. package/cjs/cypress-utils/commands.js.map +1 -0
  39. package/cjs/cypress-utils/constants/index.js +14 -0
  40. package/cjs/cypress-utils/constants/index.js.map +1 -0
  41. package/cjs/cypress-utils/constants/routes.js +40 -0
  42. package/cjs/cypress-utils/constants/routes.js.map +1 -0
  43. package/cjs/cypress-utils/constants/selectors/common.js +103 -0
  44. package/cjs/cypress-utils/constants/selectors/common.js.map +1 -0
  45. package/cjs/cypress-utils/constants/selectors/editor.js +29 -0
  46. package/cjs/cypress-utils/constants/selectors/editor.js.map +1 -0
  47. package/cjs/cypress-utils/constants/selectors/ipRestriction.js +19 -0
  48. package/cjs/cypress-utils/constants/selectors/ipRestriction.js.map +1 -0
  49. package/cjs/cypress-utils/constants/selectors/login.js +21 -0
  50. package/cjs/cypress-utils/constants/selectors/login.js.map +1 -0
  51. package/cjs/cypress-utils/constants/selectors/member.js +65 -0
  52. package/cjs/cypress-utils/constants/selectors/member.js.map +1 -0
  53. package/cjs/cypress-utils/constants/selectors/navigation.js +28 -0
  54. package/cjs/cypress-utils/constants/selectors/navigation.js.map +1 -0
  55. package/cjs/cypress-utils/constants/selectors/roles.js +24 -0
  56. package/cjs/cypress-utils/constants/selectors/roles.js.map +1 -0
  57. package/cjs/cypress-utils/constants/selectors/signUp.js +23 -0
  58. package/cjs/cypress-utils/constants/selectors/signUp.js.map +1 -0
  59. package/cjs/cypress-utils/constants/selectors/tags.js +31 -0
  60. package/cjs/cypress-utils/constants/selectors/tags.js.map +1 -0
  61. package/cjs/cypress-utils/constants/texts/common.js +40 -0
  62. package/cjs/cypress-utils/constants/texts/common.js.map +1 -0
  63. package/cjs/cypress-utils/constants/texts/member.js +68 -0
  64. package/cjs/cypress-utils/constants/texts/member.js.map +1 -0
  65. package/cjs/cypress-utils/constants/texts/navigation.js +24 -0
  66. package/cjs/cypress-utils/constants/texts/navigation.js.map +1 -0
  67. package/cjs/cypress-utils/constants/texts/roles.js +25 -0
  68. package/cjs/cypress-utils/constants/texts/roles.js.map +1 -0
  69. package/cjs/cypress-utils/constants/texts/signUp.js +14 -0
  70. package/cjs/cypress-utils/constants/texts/signUp.js.map +1 -0
  71. package/cjs/cypress-utils/constants/texts/tags.js +28 -0
  72. package/cjs/cypress-utils/constants/texts/tags.js.map +1 -0
  73. package/cjs/cypress-utils/fixtures/fake.js +177 -0
  74. package/cjs/cypress-utils/fixtures/fake.js.map +1 -0
  75. package/cjs/cypress-utils/index.js +226 -0
  76. package/cjs/cypress-utils/index.js.map +1 -0
  77. package/cjs/cypress-utils/utils/authentication.js +45 -0
  78. package/cjs/cypress-utils/utils/authentication.js.map +1 -0
  79. package/cjs/cypress-utils/utils/common.js +92 -0
  80. package/cjs/cypress-utils/utils/common.js.map +1 -0
  81. package/cjs/cypress-utils/utils/date.js +28 -0
  82. package/cjs/cypress-utils/utils/date.js.map +1 -0
  83. package/cjs/cypress-utils/utils/email.js +165 -0
  84. package/cjs/cypress-utils/utils/email.js.map +1 -0
  85. package/cjs/cypress-utils/utils/member.js +352 -0
  86. package/cjs/cypress-utils/utils/member.js.map +1 -0
  87. package/cjs/cypress-utils/utils/navigation.js +208 -0
  88. package/cjs/cypress-utils/utils/navigation.js.map +1 -0
  89. package/cjs/cypress-utils/utils/organization.js +109 -0
  90. package/cjs/cypress-utils/utils/organization.js.map +1 -0
  91. package/cjs/cypress-utils/utils/validation.js +17 -0
  92. package/cjs/cypress-utils/utils/validation.js.map +1 -0
  93. package/cjs/initializers/axios/index.js +199 -0
  94. package/cjs/initializers/axios/index.js.map +1 -0
  95. package/cjs/initializers/axios/paramsSerializer.js +27 -0
  96. package/cjs/initializers/axios/paramsSerializer.js.map +1 -0
  97. package/cjs/initializers/constants.js +23 -0
  98. package/cjs/initializers/constants.js.map +1 -0
  99. package/cjs/initializers/globalProps.js +15 -0
  100. package/cjs/initializers/globalProps.js.map +1 -0
  101. package/cjs/initializers/i18n.js +74 -0
  102. package/cjs/initializers/i18n.js.map +1 -0
  103. package/cjs/initializers/index.js +51 -0
  104. package/cjs/initializers/index.js.map +1 -0
  105. package/cjs/initializers/logger.js +17 -0
  106. package/cjs/initializers/logger.js.map +1 -0
  107. package/cjs/initializers/reactDevTools.js +26 -0
  108. package/cjs/initializers/reactDevTools.js.map +1 -0
  109. package/cjs/initializers/utils/customFormatters.js +52 -0
  110. package/cjs/initializers/utils/customFormatters.js.map +1 -0
  111. package/cjs/initializers/utils/customPostProcessors.js +21 -0
  112. package/cjs/initializers/utils/customPostProcessors.js.map +1 -0
  113. package/cjs/initializers/utils.js +37 -0
  114. package/cjs/initializers/utils.js.map +1 -0
  115. package/cjs/react-utils/BrowserPushNotifications/devices.js +26 -0
  116. package/cjs/react-utils/BrowserPushNotifications/devices.js.map +1 -0
  117. package/cjs/react-utils/BrowserPushNotifications/index.js +19 -0
  118. package/cjs/react-utils/BrowserPushNotifications/index.js.map +1 -0
  119. package/cjs/react-utils/BrowserPushNotifications/pushHelper.js +116 -0
  120. package/cjs/react-utils/BrowserPushNotifications/pushHelper.js.map +1 -0
  121. package/cjs/react-utils/BrowserPushNotifications/registerServiceWorker.js +146 -0
  122. package/cjs/react-utils/BrowserPushNotifications/registerServiceWorker.js.map +1 -0
  123. package/cjs/react-utils/HoneybadgerErrorBoundary/FallbackComponent.js +153 -0
  124. package/cjs/react-utils/HoneybadgerErrorBoundary/FallbackComponent.js.map +1 -0
  125. package/cjs/react-utils/HoneybadgerErrorBoundary/constants.js +9 -0
  126. package/cjs/react-utils/HoneybadgerErrorBoundary/constants.js.map +1 -0
  127. package/cjs/react-utils/HoneybadgerErrorBoundary/index.js +59 -0
  128. package/cjs/react-utils/HoneybadgerErrorBoundary/index.js.map +1 -0
  129. package/cjs/react-utils/HoneybadgerErrorBoundary/utils.js +17 -0
  130. package/cjs/react-utils/HoneybadgerErrorBoundary/utils.js.map +1 -0
  131. package/cjs/react-utils/PrivateRoute.js +80 -0
  132. package/cjs/react-utils/PrivateRoute.js.map +1 -0
  133. package/cjs/react-utils/constants/constants.js +11 -0
  134. package/cjs/react-utils/constants/constants.js.map +1 -0
  135. package/cjs/react-utils/constants/index.js +28 -0
  136. package/cjs/react-utils/constants/index.js.map +1 -0
  137. package/cjs/react-utils/constants/query.js +11 -0
  138. package/cjs/react-utils/constants/query.js.map +1 -0
  139. package/cjs/react-utils/index.js +242 -0
  140. package/cjs/react-utils/index.js.map +1 -0
  141. package/cjs/react-utils/metaClick.js +16 -0
  142. package/cjs/react-utils/metaClick.js.map +1 -0
  143. package/cjs/react-utils/useDebounce.js +28 -0
  144. package/cjs/react-utils/useDebounce.js.map +1 -0
  145. package/cjs/react-utils/useDisplayErrorPage.js +23 -0
  146. package/cjs/react-utils/useDisplayErrorPage.js.map +1 -0
  147. package/cjs/react-utils/useFetchNeetoApps/apis/neeto_apps.js +17 -0
  148. package/cjs/react-utils/useFetchNeetoApps/apis/neeto_apps.js.map +1 -0
  149. package/cjs/react-utils/useFetchNeetoApps/index.js +14 -0
  150. package/cjs/react-utils/useFetchNeetoApps/index.js.map +1 -0
  151. package/cjs/react-utils/useFetchNeetoApps/useFetchNeetoApps.js +27 -0
  152. package/cjs/react-utils/useFetchNeetoApps/useFetchNeetoApps.js.map +1 -0
  153. package/cjs/react-utils/useFieldSubmit.js +33 -0
  154. package/cjs/react-utils/useFieldSubmit.js.map +1 -0
  155. package/cjs/react-utils/useFuncDebounce.js +27 -0
  156. package/cjs/react-utils/useFuncDebounce.js.map +1 -0
  157. package/cjs/react-utils/useHotKeys/constants.js +36 -0
  158. package/cjs/react-utils/useHotKeys/constants.js.map +1 -0
  159. package/cjs/react-utils/useHotKeys/index.js +14 -0
  160. package/cjs/react-utils/useHotKeys/index.js.map +1 -0
  161. package/cjs/react-utils/useHotKeys/useHotKeys.js +65 -0
  162. package/cjs/react-utils/useHotKeys/useHotKeys.js.map +1 -0
  163. package/cjs/react-utils/useHotKeys/utils.js +37 -0
  164. package/cjs/react-utils/useHotKeys/utils.js.map +1 -0
  165. package/cjs/react-utils/useIsElementVisibleInDom/index.js +14 -0
  166. package/cjs/react-utils/useIsElementVisibleInDom/index.js.map +1 -0
  167. package/cjs/react-utils/useIsElementVisibleInDom/useForceUpdate.js +23 -0
  168. package/cjs/react-utils/useIsElementVisibleInDom/useForceUpdate.js.map +1 -0
  169. package/cjs/react-utils/useIsElementVisibleInDom/useIsElementVisibleInDom.js +34 -0
  170. package/cjs/react-utils/useIsElementVisibleInDom/useIsElementVisibleInDom.js.map +1 -0
  171. package/cjs/react-utils/useKeyboardShortcutsPaneState.js +36 -0
  172. package/cjs/react-utils/useKeyboardShortcutsPaneState.js.map +1 -0
  173. package/cjs/react-utils/useLocalStorage.js +39 -0
  174. package/cjs/react-utils/useLocalStorage.js.map +1 -0
  175. package/cjs/react-utils/useMutationWithInvalidation.js +33 -0
  176. package/cjs/react-utils/useMutationWithInvalidation.js.map +1 -0
  177. package/cjs/react-utils/useOnClickOutside.js +32 -0
  178. package/cjs/react-utils/useOnClickOutside.js.map +1 -0
  179. package/cjs/react-utils/usePersistedQuery.js +59 -0
  180. package/cjs/react-utils/usePersistedQuery.js.map +1 -0
  181. package/cjs/react-utils/usePrevious.js +17 -0
  182. package/cjs/react-utils/usePrevious.js.map +1 -0
  183. package/cjs/react-utils/useQueryParams.js +15 -0
  184. package/cjs/react-utils/useQueryParams.js.map +1 -0
  185. package/cjs/react-utils/useRegisterNavigationCheckpoint.js +43 -0
  186. package/cjs/react-utils/useRegisterNavigationCheckpoint.js.map +1 -0
  187. package/cjs/react-utils/useStateWithDependency.js +23 -0
  188. package/cjs/react-utils/useStateWithDependency.js.map +1 -0
  189. package/cjs/react-utils/useTimer.js +51 -0
  190. package/cjs/react-utils/useTimer.js.map +1 -0
  191. package/cjs/react-utils/useUpdateEffect.js +21 -0
  192. package/cjs/react-utils/useUpdateEffect.js.map +1 -0
  193. package/cjs/react-utils/withImmutableActions.js +29 -0
  194. package/cjs/react-utils/withImmutableActions.js.map +1 -0
  195. package/cjs/react-utils/withT.js +14 -0
  196. package/cjs/react-utils/withT.js.map +1 -0
  197. package/cjs/react-utils/withTitle.js +44 -0
  198. package/cjs/react-utils/withTitle.js.map +1 -0
  199. package/cjs/utils/axios.js +17 -0
  200. package/cjs/utils/axios.js.map +1 -0
  201. package/cjs/utils/createSubscription.js +22 -0
  202. package/cjs/utils/createSubscription.js.map +1 -0
  203. package/cjs/utils/currencyFormat.js +50 -0
  204. package/cjs/utils/currencyFormat.js.map +1 -0
  205. package/cjs/utils/datetime.js +69 -0
  206. package/cjs/utils/datetime.js.map +1 -0
  207. package/cjs/utils/general.js +193 -0
  208. package/cjs/utils/general.js.map +1 -0
  209. package/cjs/utils/index.js +72 -0
  210. package/cjs/utils/index.js.map +1 -0
  211. package/cjs/utils/permissions.js +25 -0
  212. package/cjs/utils/permissions.js.map +1 -0
  213. package/configs/scripts/getPkgTranslations.js +1 -1
  214. package/configs/scripts/jsdoc-builder/constants.mjs +1 -1
  215. package/configs/scripts/jsdoc-builder/index.mjs +1 -1
  216. package/configs/webpack/rules.js +2 -1
  217. package/constants/index.js +13 -0
  218. package/constants/index.js.map +1 -0
  219. package/cypress-utils/commands.js +268 -0
  220. package/cypress-utils/commands.js.map +1 -0
  221. package/cypress-utils/constants/index.js +7 -0
  222. package/cypress-utils/constants/index.js.map +1 -0
  223. package/cypress-utils/constants/routes.js +33 -0
  224. package/cypress-utils/constants/routes.js.map +1 -0
  225. package/cypress-utils/constants/selectors/common.js +94 -0
  226. package/cypress-utils/constants/selectors/common.js.map +1 -0
  227. package/cypress-utils/constants/selectors/editor.js +22 -0
  228. package/cypress-utils/constants/selectors/editor.js.map +1 -0
  229. package/cypress-utils/constants/selectors/ipRestriction.js +12 -0
  230. package/cypress-utils/constants/selectors/ipRestriction.js.map +1 -0
  231. package/cypress-utils/constants/selectors/login.js +14 -0
  232. package/cypress-utils/constants/selectors/login.js.map +1 -0
  233. package/cypress-utils/constants/selectors/member.js +56 -0
  234. package/cypress-utils/constants/selectors/member.js.map +1 -0
  235. package/cypress-utils/constants/selectors/navigation.js +20 -0
  236. package/cypress-utils/constants/selectors/navigation.js.map +1 -0
  237. package/cypress-utils/constants/selectors/roles.js +17 -0
  238. package/cypress-utils/constants/selectors/roles.js.map +1 -0
  239. package/cypress-utils/constants/selectors/signUp.js +16 -0
  240. package/cypress-utils/constants/selectors/signUp.js.map +1 -0
  241. package/cypress-utils/constants/selectors/tags.js +23 -0
  242. package/cypress-utils/constants/selectors/tags.js.map +1 -0
  243. package/cypress-utils/constants/texts/common.js +33 -0
  244. package/cypress-utils/constants/texts/common.js.map +1 -0
  245. package/cypress-utils/constants/texts/member.js +59 -0
  246. package/cypress-utils/constants/texts/member.js.map +1 -0
  247. package/cypress-utils/constants/texts/navigation.js +16 -0
  248. package/cypress-utils/constants/texts/navigation.js.map +1 -0
  249. package/cypress-utils/constants/texts/roles.js +18 -0
  250. package/cypress-utils/constants/texts/roles.js.map +1 -0
  251. package/cypress-utils/constants/texts/signUp.js +7 -0
  252. package/cypress-utils/constants/texts/signUp.js.map +1 -0
  253. package/cypress-utils/constants/texts/tags.js +21 -0
  254. package/cypress-utils/constants/texts/tags.js.map +1 -0
  255. package/cypress-utils/fixtures/fake.js +171 -0
  256. package/cypress-utils/fixtures/fake.js.map +1 -0
  257. package/cypress-utils/index.js +21 -0
  258. package/cypress-utils/index.js.map +1 -0
  259. package/cypress-utils/utils/authentication.js +38 -0
  260. package/cypress-utils/utils/authentication.js.map +1 -0
  261. package/cypress-utils/utils/common.js +75 -0
  262. package/cypress-utils/utils/common.js.map +1 -0
  263. package/cypress-utils/utils/date.js +20 -0
  264. package/cypress-utils/utils/date.js.map +1 -0
  265. package/cypress-utils/utils/email.js +156 -0
  266. package/cypress-utils/utils/email.js.map +1 -0
  267. package/cypress-utils/utils/member.js +344 -0
  268. package/cypress-utils/utils/member.js.map +1 -0
  269. package/cypress-utils/utils/navigation.js +200 -0
  270. package/cypress-utils/utils/navigation.js.map +1 -0
  271. package/cypress-utils/utils/organization.js +102 -0
  272. package/cypress-utils/utils/organization.js.map +1 -0
  273. package/cypress-utils/utils/validation.js +10 -0
  274. package/cypress-utils/utils/validation.js.map +1 -0
  275. package/initializers/axios/index.js +192 -0
  276. package/initializers/axios/index.js.map +1 -0
  277. package/initializers/axios/paramsSerializer.js +18 -0
  278. package/initializers/axios/paramsSerializer.js.map +1 -0
  279. package/initializers/constants.js +13 -0
  280. package/initializers/constants.js.map +1 -0
  281. package/initializers/globalProps.js +8 -0
  282. package/initializers/globalProps.js.map +1 -0
  283. package/initializers/i18n.js +67 -0
  284. package/initializers/i18n.js.map +1 -0
  285. package/initializers/index.js +28 -0
  286. package/initializers/index.js.map +1 -0
  287. package/initializers/logger.js +10 -0
  288. package/initializers/logger.js.map +1 -0
  289. package/initializers/reactDevTools.js +19 -0
  290. package/initializers/reactDevTools.js.map +1 -0
  291. package/initializers/utils/customFormatters.js +43 -0
  292. package/initializers/utils/customFormatters.js.map +1 -0
  293. package/initializers/utils/customPostProcessors.js +14 -0
  294. package/initializers/utils/customPostProcessors.js.map +1 -0
  295. package/initializers/utils.js +29 -0
  296. package/initializers/utils.js.map +1 -0
  297. package/package.json +51 -158
  298. package/pure.d.ts +384 -0
  299. package/react-utils/BrowserPushNotifications/devices.js +18 -0
  300. package/react-utils/BrowserPushNotifications/devices.js.map +1 -0
  301. package/react-utils/BrowserPushNotifications/index.js +1 -0
  302. package/react-utils/BrowserPushNotifications/index.js.map +1 -0
  303. package/react-utils/BrowserPushNotifications/pushHelper.js +107 -0
  304. package/react-utils/BrowserPushNotifications/pushHelper.js.map +1 -0
  305. package/react-utils/BrowserPushNotifications/registerServiceWorker.js +137 -0
  306. package/react-utils/BrowserPushNotifications/registerServiceWorker.js.map +1 -0
  307. package/react-utils/HoneybadgerErrorBoundary/FallbackComponent.js +144 -0
  308. package/react-utils/HoneybadgerErrorBoundary/FallbackComponent.js.map +1 -0
  309. package/react-utils/HoneybadgerErrorBoundary/constants.js +1 -0
  310. package/react-utils/HoneybadgerErrorBoundary/constants.js.map +1 -0
  311. package/react-utils/HoneybadgerErrorBoundary/index.js +52 -0
  312. package/react-utils/HoneybadgerErrorBoundary/index.js.map +1 -0
  313. package/react-utils/HoneybadgerErrorBoundary/utils.js +9 -0
  314. package/react-utils/HoneybadgerErrorBoundary/utils.js.map +1 -0
  315. package/react-utils/PrivateRoute.js +72 -0
  316. package/react-utils/PrivateRoute.js.map +1 -0
  317. package/react-utils/constants/constants.js +3 -0
  318. package/react-utils/constants/constants.js.map +1 -0
  319. package/react-utils/constants/index.js +3 -0
  320. package/react-utils/constants/index.js.map +1 -0
  321. package/react-utils/constants/query.js +4 -0
  322. package/react-utils/constants/query.js.map +1 -0
  323. package/react-utils/index.js +33 -0
  324. package/react-utils/index.js.map +1 -0
  325. package/react-utils/metaClick.js +8 -0
  326. package/react-utils/metaClick.js.map +1 -0
  327. package/react-utils/useDebounce.js +20 -0
  328. package/react-utils/useDebounce.js.map +1 -0
  329. package/react-utils/useDisplayErrorPage.js +15 -0
  330. package/react-utils/useDisplayErrorPage.js.map +1 -0
  331. package/react-utils/useFetchNeetoApps/apis/neeto_apps.js +9 -0
  332. package/react-utils/useFetchNeetoApps/apis/neeto_apps.js.map +1 -0
  333. package/react-utils/useFetchNeetoApps/index.js +1 -0
  334. package/react-utils/useFetchNeetoApps/index.js.map +1 -0
  335. package/react-utils/useFetchNeetoApps/useFetchNeetoApps.js +19 -0
  336. package/react-utils/useFetchNeetoApps/useFetchNeetoApps.js.map +1 -0
  337. package/react-utils/useFieldSubmit.js +26 -0
  338. package/react-utils/useFieldSubmit.js.map +1 -0
  339. package/react-utils/useFuncDebounce.js +20 -0
  340. package/react-utils/useFuncDebounce.js.map +1 -0
  341. package/react-utils/useHotKeys/constants.js +25 -0
  342. package/react-utils/useHotKeys/constants.js.map +1 -0
  343. package/react-utils/useHotKeys/index.js +1 -0
  344. package/react-utils/useHotKeys/index.js.map +1 -0
  345. package/react-utils/useHotKeys/useHotKeys.js +57 -0
  346. package/react-utils/useHotKeys/useHotKeys.js.map +1 -0
  347. package/react-utils/useHotKeys/utils.js +29 -0
  348. package/react-utils/useHotKeys/utils.js.map +1 -0
  349. package/react-utils/useIsElementVisibleInDom/index.js +1 -0
  350. package/react-utils/useIsElementVisibleInDom/index.js.map +1 -0
  351. package/react-utils/useIsElementVisibleInDom/useForceUpdate.js +15 -0
  352. package/react-utils/useIsElementVisibleInDom/useForceUpdate.js.map +1 -0
  353. package/react-utils/useIsElementVisibleInDom/useIsElementVisibleInDom.js +26 -0
  354. package/react-utils/useIsElementVisibleInDom/useIsElementVisibleInDom.js.map +1 -0
  355. package/react-utils/useKeyboardShortcutsPaneState.js +29 -0
  356. package/react-utils/useKeyboardShortcutsPaneState.js.map +1 -0
  357. package/react-utils/useLocalStorage.js +31 -0
  358. package/react-utils/useLocalStorage.js.map +1 -0
  359. package/react-utils/useMutationWithInvalidation.js +25 -0
  360. package/react-utils/useMutationWithInvalidation.js.map +1 -0
  361. package/react-utils/useOnClickOutside.js +25 -0
  362. package/react-utils/useOnClickOutside.js.map +1 -0
  363. package/react-utils/usePersistedQuery.js +51 -0
  364. package/react-utils/usePersistedQuery.js.map +1 -0
  365. package/react-utils/usePrevious.js +10 -0
  366. package/react-utils/usePrevious.js.map +1 -0
  367. package/react-utils/useQueryParams.js +8 -0
  368. package/react-utils/useQueryParams.js.map +1 -0
  369. package/react-utils/useRegisterNavigationCheckpoint.js +35 -0
  370. package/react-utils/useRegisterNavigationCheckpoint.js.map +1 -0
  371. package/react-utils/useStateWithDependency.js +15 -0
  372. package/react-utils/useStateWithDependency.js.map +1 -0
  373. package/react-utils/useTimer.js +43 -0
  374. package/react-utils/useTimer.js.map +1 -0
  375. package/react-utils/useUpdateEffect.js +14 -0
  376. package/react-utils/useUpdateEffect.js.map +1 -0
  377. package/react-utils/withImmutableActions.js +22 -0
  378. package/react-utils/withImmutableActions.js.map +1 -0
  379. package/react-utils/withT.js +7 -0
  380. package/react-utils/withT.js.map +1 -0
  381. package/react-utils/withTitle.js +36 -0
  382. package/react-utils/withTitle.js.map +1 -0
  383. package/react-utils.d.ts +14 -2
  384. package/translations/en.json +100 -0
  385. package/utils/axios.js +10 -0
  386. package/utils/axios.js.map +1 -0
  387. package/utils/createSubscription.js +15 -0
  388. package/utils/createSubscription.js.map +1 -0
  389. package/utils/currencyFormat.js +42 -0
  390. package/utils/currencyFormat.js.map +1 -0
  391. package/utils/datetime.js +60 -0
  392. package/utils/datetime.js.map +1 -0
  393. package/utils/general.js +172 -0
  394. package/utils/general.js.map +1 -0
  395. package/utils/index.js +7 -0
  396. package/utils/index.js.map +1 -0
  397. package/utils/permissions.js +16 -0
  398. package/utils/permissions.js.map +1 -0
  399. package/utils.d.ts +18 -2
  400. package/README.md +0 -173
  401. package/constants.cjs.js.map +0 -1
  402. package/constants.js +0 -15
  403. package/constants.js.map +0 -1
  404. package/cypress-utils.cjs.js +0 -1819
  405. package/cypress-utils.cjs.js.map +0 -1
  406. package/cypress-utils.js +0 -1773
  407. package/cypress-utils.js.map +0 -1
  408. package/initializers.cjs.js +0 -2648
  409. package/initializers.cjs.js.map +0 -1
  410. package/initializers.js +0 -2634
  411. package/initializers.js.map +0 -1
  412. package/react-utils.cjs.js +0 -4915
  413. package/react-utils.cjs.js.map +0 -1
  414. package/react-utils.js +0 -4860
  415. package/react-utils.js.map +0 -1
  416. package/utils.cjs.js +0 -1280
  417. package/utils.cjs.js.map +0 -1
  418. package/utils.js +0 -1248
  419. package/utils.js.map +0 -1
  420. /package/{src → cjs}/translations/en.json +0 -0
@@ -1,2648 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var reactUtils = require('@bigbinary/neeto-commons-frontend/react-utils');
6
- var axios = require('axios');
7
- var i18n = require('i18next');
8
- var neetoCist = require('@bigbinary/neeto-cist');
9
- var utils = require('@bigbinary/neeto-commons-frontend/utils');
10
- var neetoui = require('@bigbinary/neetoui');
11
- var ramda = require('ramda');
12
- var qs = require('qs');
13
- var reactI18next = require('react-i18next');
14
- var Logger = require('js-logger');
15
-
16
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
17
-
18
- var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
19
- var i18n__default = /*#__PURE__*/_interopDefaultLegacy(i18n);
20
- var qs__default = /*#__PURE__*/_interopDefaultLegacy(qs);
21
- var Logger__default = /*#__PURE__*/_interopDefaultLegacy(Logger);
22
-
23
- function _typeof$1(obj) {
24
- "@babel/helpers - typeof";
25
-
26
- return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
27
- return typeof obj;
28
- } : function (obj) {
29
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
30
- }, _typeof$1(obj);
31
- }
32
-
33
- function _toPrimitive$1(input, hint) {
34
- if (_typeof$1(input) !== "object" || input === null) return input;
35
- var prim = input[Symbol.toPrimitive];
36
- if (prim !== undefined) {
37
- var res = prim.call(input, hint || "default");
38
- if (_typeof$1(res) !== "object") return res;
39
- throw new TypeError("@@toPrimitive must return a primitive value.");
40
- }
41
- return (hint === "string" ? String : Number)(input);
42
- }
43
-
44
- function _toPropertyKey$1(arg) {
45
- var key = _toPrimitive$1(arg, "string");
46
- return _typeof$1(key) === "symbol" ? key : String(key);
47
- }
48
-
49
- function _defineProperty(obj, key, value) {
50
- key = _toPropertyKey$1(key);
51
- if (key in obj) {
52
- Object.defineProperty(obj, key, {
53
- value: value,
54
- enumerable: true,
55
- configurable: true,
56
- writable: true
57
- });
58
- } else {
59
- obj[key] = value;
60
- }
61
- return obj;
62
- }
63
-
64
- var setParamsSerializer = function setParamsSerializer() {
65
- axios__default["default"].defaults.paramsSerializer = function (params) {
66
- var modifiedParams = ramda.map(function checkObject(value) {
67
- if (Array.isArray(value)) return ramda.map(checkObject, value);else if (value && _typeof$1(value) === "object") return JSON.stringify(value);
68
- return value;
69
- }, params);
70
- return qs__default["default"].stringify(modifiedParams, {
71
- arrayFormat: "brackets"
72
- });
73
- };
74
- };
75
-
76
- var HEADERS_KEYS = {
77
- xCsrfToken: "X-CSRF-TOKEN",
78
- contentType: "Content-Type",
79
- accept: "Accept"
80
- };
81
- var LOWERCASED = "__LOWERCASED__";
82
- var ANY_CASE = "anyCase";
83
-
84
- var shouldNot = function shouldNot(skip) {
85
- return _typeof$1(skip) === "object" || !skip;
86
- };
87
- var shouldShowToastr = function shouldShowToastr(response) {
88
- return typeof response === "string" || _typeof$1(response) === "object" && ((response === null || response === void 0 ? void 0 : response.notice) || (response === null || response === void 0 ? void 0 : response.noticeCode));
89
- };
90
- var setAuthHeaders = function setAuthHeaders() {
91
- var _document$querySelect, _axios$defaults$heade;
92
- // @ts-ignore
93
- axios__default["default"].defaults.headers = (_axios$defaults$heade = {}, _defineProperty(_axios$defaults$heade, HEADERS_KEYS.accept, "application/json"), _defineProperty(_axios$defaults$heade, HEADERS_KEYS.contentType, "application/json"), _defineProperty(_axios$defaults$heade, HEADERS_KEYS.xCsrfToken, (_document$querySelect = document.querySelector('[name="csrf-token"]')) === null || _document$querySelect === void 0 ? void 0 : _document$querySelect.getAttribute("content")), _axios$defaults$heade);
94
- };
95
-
96
- // pipe function from ramda doesn't accept array of functions.
97
- // We can't use spread operator too. So this is a workaround.
98
- var createPipe = function createPipe(functions) {
99
- return function (data) {
100
- return functions.reduce(function (acc, fn) {
101
- return fn(acc);
102
- }, data);
103
- };
104
- };
105
- var transformResponseKeysToCamelCase = function transformResponseKeysToCamelCase(response) {
106
- var _response$config$tran = response.config.transformResponseCase,
107
- transformResponseCase = _response$config$tran === void 0 ? true : _response$config$tran;
108
- if (response.data && transformResponseCase) {
109
- response.data = neetoCist.keysToCamelCase(response.data);
110
- }
111
- return response;
112
- };
113
- var transformErrorKeysToCamelCase = function transformErrorKeysToCamelCase(error) {
114
- var _error$config, _error$response;
115
- var _ref = (_error$config = error.config) !== null && _error$config !== void 0 ? _error$config : {},
116
- _ref$transformRespons = _ref.transformResponseCase,
117
- transformResponseCase = _ref$transformRespons === void 0 ? true : _ref$transformRespons;
118
- if ((_error$response = error.response) !== null && _error$response !== void 0 && _error$response.data && transformResponseCase) {
119
- error.response.data = neetoCist.keysToCamelCase(error.response.data);
120
- }
121
- return error;
122
- };
123
- var showSuccessToastr = function showSuccessToastr(response) {
124
- var _response$config$show = response.config.showToastr,
125
- showToastr = _response$config$show === void 0 ? true : _response$config$show;
126
- if (!showToastr) return response;
127
- if (neetoCist.matches({
128
- showThumbsUpToastr: true
129
- }, response.data)) {
130
- // @ts-ignore
131
- neetoui.Toastr.success("", {
132
- icon: "👍",
133
- className: "w-20"
134
- });
135
- } else if (neetoCist.matches({
136
- noticeCode: "thumbs_up"
137
- }, response.data)) {
138
- // @ts-ignore
139
- neetoui.Toastr.success("", {
140
- icon: "👍",
141
- className: "w-20"
142
- });
143
- } else if (shouldShowToastr(response.data)) {
144
- neetoui.Toastr.success(response.data);
145
- }
146
- return response;
147
- };
148
- var pullDataFromResponse = function pullDataFromResponse(response) {
149
- var _response$config$incl = response.config.includeMetadataInResponse,
150
- includeMetadataInResponse = _response$config$incl === void 0 ? false : _response$config$incl;
151
- return includeMetadataInResponse ? response : response.data;
152
- };
153
- var buildSuccessResponseHandler = function buildSuccessResponseHandler(skip) {
154
- var interceptors = [];
155
- if (!(skip !== null && skip !== void 0 && skip.transformCase)) interceptors.push(transformResponseKeysToCamelCase);
156
- if (!(skip !== null && skip !== void 0 && skip.showToastr)) interceptors.push(showSuccessToastr);
157
- if (!(skip !== null && skip !== void 0 && skip.pullDataFromResponse)) interceptors.push(pullDataFromResponse);
158
- return createPipe(interceptors);
159
- };
160
- var handleUnauthorizedErrorResponse = function handleUnauthorizedErrorResponse(error) {
161
- var _error$response2, _error$config2;
162
- if (((_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.status) !== 401) return error;
163
- utils.resetAuthTokens();
164
- var _ref2 = (_error$config2 = error.config) !== null && _error$config2 !== void 0 ? _error$config2 : {},
165
- _ref2$redirectOnError = _ref2.redirectOnError,
166
- redirectOnError = _ref2$redirectOnError === void 0 ? true : _ref2$redirectOnError;
167
- if (redirectOnError) {
168
- setTimeout(function () {
169
- var redirectTo = window.location.pathname === "/login" ? "/login" : "/login?redirect_uri=".concat(encodeURIComponent(window.location.href));
170
- // eslint-disable-next-line xss/no-location-href-assign
171
- window.location.href = redirectTo;
172
- }, 300);
173
- }
174
- return error;
175
- };
176
- var showErrorToastr = function showErrorToastr(error) {
177
- var _error$config3, _error$response3;
178
- var _ref3 = (_error$config3 = error.config) !== null && _error$config3 !== void 0 ? _error$config3 : {},
179
- _ref3$showToastr = _ref3.showToastr,
180
- showToastr = _ref3$showToastr === void 0 ? true : _ref3$showToastr;
181
- if (!showToastr) return error;
182
- if (error.message === "Network Error") {
183
- // @ts-ignore
184
- neetoui.Toastr.error(i18n__default["default"].t("neetoCommons.toastr.error.networkError"));
185
- } else if (![403, 404].includes((_error$response3 = error.response) === null || _error$response3 === void 0 ? void 0 : _error$response3.status) && !axios__default["default"].isCancel(error)) {
186
- // we already display a page in case of 403 & 404 and we don't want to show a toastr for cancelled requests.
187
- neetoui.Toastr.error(error);
188
- }
189
- return error;
190
- };
191
- var getUrlPathName = function getUrlPathName(url) {
192
- try {
193
- return new URL(url).pathname;
194
- } catch (_unused) {
195
- return url;
196
- }
197
- };
198
- var handle404ErrorResponse = function handle404ErrorResponse(error) {
199
- var _error$config4, _error$response4;
200
- var _ref4 = (_error$config4 = error.config) !== null && _error$config4 !== void 0 ? _error$config4 : {},
201
- _ref4$show404ErrorPag = _ref4.show404ErrorPage,
202
- show404ErrorPage = _ref4$show404ErrorPag === void 0 ? true : _ref4$show404ErrorPag,
203
- _ref4$show403ErrorPag = _ref4.show403ErrorPage,
204
- show403ErrorPage = _ref4$show403ErrorPag === void 0 ? true : _ref4$show403ErrorPag;
205
- var status = (_error$response4 = error.response) === null || _error$response4 === void 0 ? void 0 : _error$response4.status;
206
- if (status === 404 && show404ErrorPage || status === 403 && show403ErrorPage) {
207
- var _error$request;
208
- var fullUrl = ((_error$request = error.request) === null || _error$request === void 0 ? void 0 : _error$request.responseURL) || error.config.url;
209
- reactUtils.useErrorDisplayStore.setState({
210
- showErrorPage: true,
211
- statusCode: status,
212
- failedApiUrl: fullUrl,
213
- failedApiPath: getUrlPathName(fullUrl)
214
- });
215
- }
216
- return error;
217
- };
218
- var buildErrorResponseHandler = function buildErrorResponseHandler(skip) {
219
- var interceptors = [];
220
- if (!(skip !== null && skip !== void 0 && skip.transformCase)) interceptors.push(transformErrorKeysToCamelCase);
221
- if (!(skip !== null && skip !== void 0 && skip.show404ErrorPage)) interceptors.push(handle404ErrorResponse);
222
- if (!(skip !== null && skip !== void 0 && skip.logoutOn401)) interceptors.push(handleUnauthorizedErrorResponse);
223
- if (!(skip !== null && skip !== void 0 && skip.showToastr)) interceptors.push(showErrorToastr);
224
- interceptors.push(Promise.reject.bind(Promise));
225
- return createPipe(interceptors);
226
- };
227
- var cleanupCredentialsForCrossOrigin = function cleanupCredentialsForCrossOrigin(request) {
228
- if (!request.url.includes("://")) return request;
229
- if (request.url.includes(window.location.hostname)) return request;
230
- return ramda.evolve({
231
- headers: ramda.omit(ramda.values(HEADERS_KEYS))
232
- })(request);
233
- };
234
- var transformDataToSnakeCase = function transformDataToSnakeCase(request) {
235
- var _request$transformReq = request.transformRequestCase,
236
- transformRequestCase = _request$transformReq === void 0 ? true : _request$transformReq;
237
- if (!transformRequestCase) return request;
238
- return ramda.evolve({
239
- data: neetoCist.serializeKeysToSnakeCase,
240
- params: neetoCist.serializeKeysToSnakeCase
241
- }, request);
242
- };
243
- var addRequestInterceptors = function addRequestInterceptors(skip) {
244
- if (!(skip !== null && skip !== void 0 && skip.cleanCredentialsForCrossOrigin)) {
245
- axios__default["default"].interceptors.request.use(cleanupCredentialsForCrossOrigin);
246
- }
247
- if (!(skip !== null && skip !== void 0 && skip.transformCase)) {
248
- axios__default["default"].interceptors.request.use(transformDataToSnakeCase);
249
- }
250
- };
251
- var addResponseInterceptors = function addResponseInterceptors(skip) {
252
- axios__default["default"].interceptors.response.use(buildSuccessResponseHandler(skip), buildErrorResponseHandler(skip));
253
- };
254
- var registerIntercepts = function registerIntercepts(skip) {
255
- if (shouldNot(skip === null || skip === void 0 ? void 0 : skip.request)) addRequestInterceptors(skip === null || skip === void 0 ? void 0 : skip.request);
256
- if (shouldNot(skip === null || skip === void 0 ? void 0 : skip.response)) addResponseInterceptors(skip === null || skip === void 0 ? void 0 : skip.response);
257
- };
258
- function initializeAxios(skip) {
259
- if (!(skip !== null && skip !== void 0 && skip.baseURL)) axios__default["default"].defaults.baseURL = "/";
260
- if (!(skip !== null && skip !== void 0 && skip.authHeaders)) setAuthHeaders();
261
- if (!(skip !== null && skip !== void 0 && skip.paramsSerializer)) setParamsSerializer();
262
- if (shouldNot(skip === null || skip === void 0 ? void 0 : skip.interceptors)) registerIntercepts(skip === null || skip === void 0 ? void 0 : skip.interceptors);
263
- }
264
-
265
- /* eslint-disable @bigbinary/neeto/no-globalProps-reassignment */
266
- function initializeGlobalProps() {
267
- var _document$getElements, _document$getElements2;
268
- window.globalProps = neetoCist.keysToCamelCase(JSON.parse(((_document$getElements = document.getElementsByClassName("root-container")[0]) === null || _document$getElements === void 0 ? void 0 : (_document$getElements2 = _document$getElements.dataset) === null || _document$getElements2 === void 0 ? void 0 : _document$getElements2.reactProps) || "{}"));
269
- neetoCist.deepFreezeObject(window.globalProps);
270
- }
271
-
272
- function _classCallCheck(instance, Constructor) {
273
- if (!(instance instanceof Constructor)) {
274
- throw new TypeError("Cannot call a class as a function");
275
- }
276
- }
277
-
278
- function _typeof(obj) {
279
- "@babel/helpers - typeof";
280
-
281
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
282
- return typeof obj;
283
- } : function (obj) {
284
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
285
- }, _typeof(obj);
286
- }
287
-
288
- function _toPrimitive(input, hint) {
289
- if (_typeof(input) !== "object" || input === null) return input;
290
- var prim = input[Symbol.toPrimitive];
291
- if (prim !== undefined) {
292
- var res = prim.call(input, hint || "default");
293
- if (_typeof(res) !== "object") return res;
294
- throw new TypeError("@@toPrimitive must return a primitive value.");
295
- }
296
- return (hint === "string" ? String : Number)(input);
297
- }
298
-
299
- function _toPropertyKey(arg) {
300
- var key = _toPrimitive(arg, "string");
301
- return _typeof(key) === "symbol" ? key : String(key);
302
- }
303
-
304
- function _defineProperties(target, props) {
305
- for (var i = 0; i < props.length; i++) {
306
- var descriptor = props[i];
307
- descriptor.enumerable = descriptor.enumerable || false;
308
- descriptor.configurable = true;
309
- if ("value" in descriptor) descriptor.writable = true;
310
- Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
311
- }
312
- }
313
- function _createClass(Constructor, protoProps, staticProps) {
314
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
315
- if (staticProps) _defineProperties(Constructor, staticProps);
316
- Object.defineProperty(Constructor, "prototype", {
317
- writable: false
318
- });
319
- return Constructor;
320
- }
321
-
322
- var arr = [];
323
- var each = arr.forEach;
324
- var slice = arr.slice;
325
- function defaults(obj) {
326
- each.call(slice.call(arguments, 1), function (source) {
327
- if (source) {
328
- for (var prop in source) {
329
- if (obj[prop] === undefined) obj[prop] = source[prop];
330
- }
331
- }
332
- });
333
- return obj;
334
- }
335
-
336
- // eslint-disable-next-line no-control-regex
337
- var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
338
- var serializeCookie = function serializeCookie(name, val, options) {
339
- var opt = options || {};
340
- opt.path = opt.path || '/';
341
- var value = encodeURIComponent(val);
342
- var str = "".concat(name, "=").concat(value);
343
- if (opt.maxAge > 0) {
344
- var maxAge = opt.maxAge - 0;
345
- if (Number.isNaN(maxAge)) throw new Error('maxAge should be a Number');
346
- str += "; Max-Age=".concat(Math.floor(maxAge));
347
- }
348
- if (opt.domain) {
349
- if (!fieldContentRegExp.test(opt.domain)) {
350
- throw new TypeError('option domain is invalid');
351
- }
352
- str += "; Domain=".concat(opt.domain);
353
- }
354
- if (opt.path) {
355
- if (!fieldContentRegExp.test(opt.path)) {
356
- throw new TypeError('option path is invalid');
357
- }
358
- str += "; Path=".concat(opt.path);
359
- }
360
- if (opt.expires) {
361
- if (typeof opt.expires.toUTCString !== 'function') {
362
- throw new TypeError('option expires is invalid');
363
- }
364
- str += "; Expires=".concat(opt.expires.toUTCString());
365
- }
366
- if (opt.httpOnly) str += '; HttpOnly';
367
- if (opt.secure) str += '; Secure';
368
- if (opt.sameSite) {
369
- var sameSite = typeof opt.sameSite === 'string' ? opt.sameSite.toLowerCase() : opt.sameSite;
370
- switch (sameSite) {
371
- case true:
372
- str += '; SameSite=Strict';
373
- break;
374
- case 'lax':
375
- str += '; SameSite=Lax';
376
- break;
377
- case 'strict':
378
- str += '; SameSite=Strict';
379
- break;
380
- case 'none':
381
- str += '; SameSite=None';
382
- break;
383
- default:
384
- throw new TypeError('option sameSite is invalid');
385
- }
386
- }
387
- return str;
388
- };
389
- var cookie = {
390
- create: function create(name, value, minutes, domain) {
391
- var cookieOptions = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
392
- path: '/',
393
- sameSite: 'strict'
394
- };
395
- if (minutes) {
396
- cookieOptions.expires = new Date();
397
- cookieOptions.expires.setTime(cookieOptions.expires.getTime() + minutes * 60 * 1000);
398
- }
399
- if (domain) cookieOptions.domain = domain;
400
- document.cookie = serializeCookie(name, encodeURIComponent(value), cookieOptions);
401
- },
402
- read: function read(name) {
403
- var nameEQ = "".concat(name, "=");
404
- var ca = document.cookie.split(';');
405
- for (var i = 0; i < ca.length; i++) {
406
- var c = ca[i];
407
- while (c.charAt(0) === ' ') {
408
- c = c.substring(1, c.length);
409
- }
410
- if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);
411
- }
412
- return null;
413
- },
414
- remove: function remove(name) {
415
- this.create(name, '', -1);
416
- }
417
- };
418
- var cookie$1 = {
419
- name: 'cookie',
420
- lookup: function lookup(options) {
421
- var found;
422
- if (options.lookupCookie && typeof document !== 'undefined') {
423
- var c = cookie.read(options.lookupCookie);
424
- if (c) found = c;
425
- }
426
- return found;
427
- },
428
- cacheUserLanguage: function cacheUserLanguage(lng, options) {
429
- if (options.lookupCookie && typeof document !== 'undefined') {
430
- cookie.create(options.lookupCookie, lng, options.cookieMinutes, options.cookieDomain, options.cookieOptions);
431
- }
432
- }
433
- };
434
-
435
- var querystring = {
436
- name: 'querystring',
437
- lookup: function lookup(options) {
438
- var found;
439
- if (typeof window !== 'undefined') {
440
- var search = window.location.search;
441
- if (!window.location.search && window.location.hash && window.location.hash.indexOf('?') > -1) {
442
- search = window.location.hash.substring(window.location.hash.indexOf('?'));
443
- }
444
- var query = search.substring(1);
445
- var params = query.split('&');
446
- for (var i = 0; i < params.length; i++) {
447
- var pos = params[i].indexOf('=');
448
- if (pos > 0) {
449
- var key = params[i].substring(0, pos);
450
- if (key === options.lookupQuerystring) {
451
- found = params[i].substring(pos + 1);
452
- }
453
- }
454
- }
455
- }
456
- return found;
457
- }
458
- };
459
-
460
- var hasLocalStorageSupport = null;
461
- var localStorageAvailable = function localStorageAvailable() {
462
- if (hasLocalStorageSupport !== null) return hasLocalStorageSupport;
463
- try {
464
- hasLocalStorageSupport = window !== 'undefined' && window.localStorage !== null;
465
- var testKey = 'i18next.translate.boo';
466
- window.localStorage.setItem(testKey, 'foo');
467
- window.localStorage.removeItem(testKey);
468
- } catch (e) {
469
- hasLocalStorageSupport = false;
470
- }
471
- return hasLocalStorageSupport;
472
- };
473
- var localStorage = {
474
- name: 'localStorage',
475
- lookup: function lookup(options) {
476
- var found;
477
- if (options.lookupLocalStorage && localStorageAvailable()) {
478
- var lng = window.localStorage.getItem(options.lookupLocalStorage);
479
- if (lng) found = lng;
480
- }
481
- return found;
482
- },
483
- cacheUserLanguage: function cacheUserLanguage(lng, options) {
484
- if (options.lookupLocalStorage && localStorageAvailable()) {
485
- window.localStorage.setItem(options.lookupLocalStorage, lng);
486
- }
487
- }
488
- };
489
-
490
- var hasSessionStorageSupport = null;
491
- var sessionStorageAvailable = function sessionStorageAvailable() {
492
- if (hasSessionStorageSupport !== null) return hasSessionStorageSupport;
493
- try {
494
- hasSessionStorageSupport = window !== 'undefined' && window.sessionStorage !== null;
495
- var testKey = 'i18next.translate.boo';
496
- window.sessionStorage.setItem(testKey, 'foo');
497
- window.sessionStorage.removeItem(testKey);
498
- } catch (e) {
499
- hasSessionStorageSupport = false;
500
- }
501
- return hasSessionStorageSupport;
502
- };
503
- var sessionStorage = {
504
- name: 'sessionStorage',
505
- lookup: function lookup(options) {
506
- var found;
507
- if (options.lookupSessionStorage && sessionStorageAvailable()) {
508
- var lng = window.sessionStorage.getItem(options.lookupSessionStorage);
509
- if (lng) found = lng;
510
- }
511
- return found;
512
- },
513
- cacheUserLanguage: function cacheUserLanguage(lng, options) {
514
- if (options.lookupSessionStorage && sessionStorageAvailable()) {
515
- window.sessionStorage.setItem(options.lookupSessionStorage, lng);
516
- }
517
- }
518
- };
519
-
520
- var navigator$1 = {
521
- name: 'navigator',
522
- lookup: function lookup(options) {
523
- var found = [];
524
- if (typeof navigator !== 'undefined') {
525
- if (navigator.languages) {
526
- // chrome only; not an array, so can't use .push.apply instead of iterating
527
- for (var i = 0; i < navigator.languages.length; i++) {
528
- found.push(navigator.languages[i]);
529
- }
530
- }
531
- if (navigator.userLanguage) {
532
- found.push(navigator.userLanguage);
533
- }
534
- if (navigator.language) {
535
- found.push(navigator.language);
536
- }
537
- }
538
- return found.length > 0 ? found : undefined;
539
- }
540
- };
541
-
542
- var htmlTag = {
543
- name: 'htmlTag',
544
- lookup: function lookup(options) {
545
- var found;
546
- var htmlTag = options.htmlTag || (typeof document !== 'undefined' ? document.documentElement : null);
547
- if (htmlTag && typeof htmlTag.getAttribute === 'function') {
548
- found = htmlTag.getAttribute('lang');
549
- }
550
- return found;
551
- }
552
- };
553
-
554
- var path = {
555
- name: 'path',
556
- lookup: function lookup(options) {
557
- var found;
558
- if (typeof window !== 'undefined') {
559
- var language = window.location.pathname.match(/\/([a-zA-Z-]*)/g);
560
- if (language instanceof Array) {
561
- if (typeof options.lookupFromPathIndex === 'number') {
562
- if (typeof language[options.lookupFromPathIndex] !== 'string') {
563
- return undefined;
564
- }
565
- found = language[options.lookupFromPathIndex].replace('/', '');
566
- } else {
567
- found = language[0].replace('/', '');
568
- }
569
- }
570
- }
571
- return found;
572
- }
573
- };
574
-
575
- var subdomain = {
576
- name: 'subdomain',
577
- lookup: function lookup(options) {
578
- // If given get the subdomain index else 1
579
- var lookupFromSubdomainIndex = typeof options.lookupFromSubdomainIndex === 'number' ? options.lookupFromSubdomainIndex + 1 : 1;
580
- // get all matches if window.location. is existing
581
- // first item of match is the match itself and the second is the first group macht which sould be the first subdomain match
582
- // is the hostname no public domain get the or option of localhost
583
- var language = typeof window !== 'undefined' && window.location && window.location.hostname && window.location.hostname.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);
584
-
585
- // if there is no match (null) return undefined
586
- if (!language) return undefined;
587
- // return the given group match
588
- return language[lookupFromSubdomainIndex];
589
- }
590
- };
591
-
592
- function getDefaults() {
593
- return {
594
- order: ['querystring', 'cookie', 'localStorage', 'sessionStorage', 'navigator', 'htmlTag'],
595
- lookupQuerystring: 'lng',
596
- lookupCookie: 'i18next',
597
- lookupLocalStorage: 'i18nextLng',
598
- lookupSessionStorage: 'i18nextLng',
599
- // cache user language
600
- caches: ['localStorage'],
601
- excludeCacheFor: ['cimode'],
602
- // cookieMinutes: 10,
603
- // cookieDomain: 'myDomain'
604
-
605
- convertDetectedLanguage: function convertDetectedLanguage(l) {
606
- return l;
607
- }
608
- };
609
- }
610
- var Browser = /*#__PURE__*/function () {
611
- function Browser(services) {
612
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
613
- _classCallCheck(this, Browser);
614
- this.type = 'languageDetector';
615
- this.detectors = {};
616
- this.init(services, options);
617
- }
618
- _createClass(Browser, [{
619
- key: "init",
620
- value: function init(services) {
621
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
622
- var i18nOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
623
- this.services = services || {
624
- languageUtils: {}
625
- }; // this way the language detector can be used without i18next
626
- this.options = defaults(options, this.options || {}, getDefaults());
627
- if (typeof this.options.convertDetectedLanguage === 'string' && this.options.convertDetectedLanguage.indexOf('15897') > -1) {
628
- this.options.convertDetectedLanguage = function (l) {
629
- return l.replace('-', '_');
630
- };
631
- }
632
-
633
- // backwards compatibility
634
- if (this.options.lookupFromUrlIndex) this.options.lookupFromPathIndex = this.options.lookupFromUrlIndex;
635
- this.i18nOptions = i18nOptions;
636
- this.addDetector(cookie$1);
637
- this.addDetector(querystring);
638
- this.addDetector(localStorage);
639
- this.addDetector(sessionStorage);
640
- this.addDetector(navigator$1);
641
- this.addDetector(htmlTag);
642
- this.addDetector(path);
643
- this.addDetector(subdomain);
644
- }
645
- }, {
646
- key: "addDetector",
647
- value: function addDetector(detector) {
648
- this.detectors[detector.name] = detector;
649
- }
650
- }, {
651
- key: "detect",
652
- value: function detect(detectionOrder) {
653
- var _this = this;
654
- if (!detectionOrder) detectionOrder = this.options.order;
655
- var detected = [];
656
- detectionOrder.forEach(function (detectorName) {
657
- if (_this.detectors[detectorName]) {
658
- var lookup = _this.detectors[detectorName].lookup(_this.options);
659
- if (lookup && typeof lookup === 'string') lookup = [lookup];
660
- if (lookup) detected = detected.concat(lookup);
661
- }
662
- });
663
- detected = detected.map(function (d) {
664
- return _this.options.convertDetectedLanguage(d);
665
- });
666
- if (this.services.languageUtils.getBestMatchFromCodes) return detected; // new i18next v19.5.0
667
- return detected.length > 0 ? detected[0] : null; // a little backward compatibility
668
- }
669
- }, {
670
- key: "cacheUserLanguage",
671
- value: function cacheUserLanguage(lng, caches) {
672
- var _this2 = this;
673
- if (!caches) caches = this.options.caches;
674
- if (!caches) return;
675
- if (this.options.excludeCacheFor && this.options.excludeCacheFor.indexOf(lng) > -1) return;
676
- caches.forEach(function (cacheName) {
677
- if (_this2.detectors[cacheName]) _this2.detectors[cacheName].cacheUserLanguage(lng, _this2.options);
678
- });
679
- }
680
- }]);
681
- return Browser;
682
- }();
683
- Browser.type = 'languageDetector';
684
-
685
- function _arrayWithHoles(arr) {
686
- if (Array.isArray(arr)) return arr;
687
- }
688
-
689
- function _iterableToArrayLimit(arr, i) {
690
- var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
691
- if (null != _i) {
692
- var _s,
693
- _e,
694
- _x,
695
- _r,
696
- _arr = [],
697
- _n = !0,
698
- _d = !1;
699
- try {
700
- if (_x = (_i = _i.call(arr)).next, 0 === i) {
701
- if (Object(_i) !== _i) return;
702
- _n = !1;
703
- } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
704
- } catch (err) {
705
- _d = !0, _e = err;
706
- } finally {
707
- try {
708
- if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return;
709
- } finally {
710
- if (_d) throw _e;
711
- }
712
- }
713
- return _arr;
714
- }
715
- }
716
-
717
- function _arrayLikeToArray(arr, len) {
718
- if (len == null || len > arr.length) len = arr.length;
719
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
720
- return arr2;
721
- }
722
-
723
- function _unsupportedIterableToArray(o, minLen) {
724
- if (!o) return;
725
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
726
- var n = Object.prototype.toString.call(o).slice(8, -1);
727
- if (n === "Object" && o.constructor) n = o.constructor.name;
728
- if (n === "Map" || n === "Set") return Array.from(o);
729
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
730
- }
731
-
732
- function _nonIterableRest() {
733
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
734
- }
735
-
736
- function _slicedToArray(arr, i) {
737
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
738
- }
739
-
740
- var getter = function getter(key) {
741
- return function () {
742
- return i18n__default["default"].t("taxonomyDefaultLabels.".concat(key));
743
- };
744
- };
745
- var replaceNullValuesWithGetter = function replaceNullValuesWithGetter(inputObject) {
746
- var parentKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
747
- var result = {};
748
- for (var _i = 0, _Object$entries = Object.entries(inputObject); _i < _Object$entries.length; _i++) {
749
- var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
750
- key = _Object$entries$_i[0],
751
- value = _Object$entries$_i[1];
752
- var transKey = parentKey ? "".concat(parentKey, ".").concat(key) : key;
753
- if (value === null) {
754
- Object.defineProperty(result, key, {
755
- get: getter(transKey)
756
- });
757
- } else if (_typeof$1(value) === "object") {
758
- result[key] = replaceNullValuesWithGetter(value, transKey);
759
- } else {
760
- result[key] = value;
761
- }
762
- }
763
- return result;
764
- };
765
-
766
- /*! @license DOMPurify 3.0.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.0.3/LICENSE */
767
-
768
- const {
769
- entries,
770
- setPrototypeOf,
771
- isFrozen,
772
- getPrototypeOf,
773
- getOwnPropertyDescriptor
774
- } = Object;
775
- let {
776
- freeze,
777
- seal,
778
- create
779
- } = Object; // eslint-disable-line import/no-mutable-exports
780
-
781
- let {
782
- apply,
783
- construct
784
- } = typeof Reflect !== 'undefined' && Reflect;
785
-
786
- if (!apply) {
787
- apply = function apply(fun, thisValue, args) {
788
- return fun.apply(thisValue, args);
789
- };
790
- }
791
-
792
- if (!freeze) {
793
- freeze = function freeze(x) {
794
- return x;
795
- };
796
- }
797
-
798
- if (!seal) {
799
- seal = function seal(x) {
800
- return x;
801
- };
802
- }
803
-
804
- if (!construct) {
805
- construct = function construct(Func, args) {
806
- return new Func(...args);
807
- };
808
- }
809
-
810
- const arrayForEach = unapply(Array.prototype.forEach);
811
- const arrayPop = unapply(Array.prototype.pop);
812
- const arrayPush = unapply(Array.prototype.push);
813
- const stringToLowerCase = unapply(String.prototype.toLowerCase);
814
- const stringToString = unapply(String.prototype.toString);
815
- const stringMatch = unapply(String.prototype.match);
816
- const stringReplace = unapply(String.prototype.replace);
817
- const stringIndexOf = unapply(String.prototype.indexOf);
818
- const stringTrim = unapply(String.prototype.trim);
819
- const regExpTest = unapply(RegExp.prototype.test);
820
- const typeErrorCreate = unconstruct(TypeError);
821
- function unapply(func) {
822
- return function (thisArg) {
823
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
824
- args[_key - 1] = arguments[_key];
825
- }
826
-
827
- return apply(func, thisArg, args);
828
- };
829
- }
830
- function unconstruct(func) {
831
- return function () {
832
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
833
- args[_key2] = arguments[_key2];
834
- }
835
-
836
- return construct(func, args);
837
- };
838
- }
839
- /* Add properties to a lookup table */
840
-
841
- function addToSet(set, array, transformCaseFunc) {
842
- var _transformCaseFunc;
843
-
844
- transformCaseFunc = (_transformCaseFunc = transformCaseFunc) !== null && _transformCaseFunc !== void 0 ? _transformCaseFunc : stringToLowerCase;
845
-
846
- if (setPrototypeOf) {
847
- // Make 'in' and truthy checks like Boolean(set.constructor)
848
- // independent of any properties defined on Object.prototype.
849
- // Prevent prototype setters from intercepting set as a this value.
850
- setPrototypeOf(set, null);
851
- }
852
-
853
- let l = array.length;
854
-
855
- while (l--) {
856
- let element = array[l];
857
-
858
- if (typeof element === 'string') {
859
- const lcElement = transformCaseFunc(element);
860
-
861
- if (lcElement !== element) {
862
- // Config presets (e.g. tags.js, attrs.js) are immutable.
863
- if (!isFrozen(array)) {
864
- array[l] = lcElement;
865
- }
866
-
867
- element = lcElement;
868
- }
869
- }
870
-
871
- set[element] = true;
872
- }
873
-
874
- return set;
875
- }
876
- /* Shallow clone an object */
877
-
878
- function clone(object) {
879
- const newObject = create(null);
880
-
881
- for (const [property, value] of entries(object)) {
882
- newObject[property] = value;
883
- }
884
-
885
- return newObject;
886
- }
887
- /* This method automatically checks if the prop is function
888
- * or getter and behaves accordingly. */
889
-
890
- function lookupGetter(object, prop) {
891
- while (object !== null) {
892
- const desc = getOwnPropertyDescriptor(object, prop);
893
-
894
- if (desc) {
895
- if (desc.get) {
896
- return unapply(desc.get);
897
- }
898
-
899
- if (typeof desc.value === 'function') {
900
- return unapply(desc.value);
901
- }
902
- }
903
-
904
- object = getPrototypeOf(object);
905
- }
906
-
907
- function fallbackValue(element) {
908
- console.warn('fallback value for', element);
909
- return null;
910
- }
911
-
912
- return fallbackValue;
913
- }
914
-
915
- const html$1 = freeze(['a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'decorator', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meter', 'nav', 'nobr', 'ol', 'optgroup', 'option', 'output', 'p', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'section', 'select', 'shadow', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr']); // SVG
916
-
917
- const svg$1 = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']);
918
- const svgFilters = freeze(['feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feDropShadow', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence']); // List of SVG elements that are disallowed by default.
919
- // We still need to know them so that we can do namespace
920
- // checks properly in case one wants to add them to
921
- // allow-list.
922
-
923
- const svgDisallowed = freeze(['animate', 'color-profile', 'cursor', 'discard', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignobject', 'hatch', 'hatchpath', 'mesh', 'meshgradient', 'meshpatch', 'meshrow', 'missing-glyph', 'script', 'set', 'solidcolor', 'unknown', 'use']);
924
- const mathMl$1 = freeze(['math', 'menclose', 'merror', 'mfenced', 'mfrac', 'mglyph', 'mi', 'mlabeledtr', 'mmultiscripts', 'mn', 'mo', 'mover', 'mpadded', 'mphantom', 'mroot', 'mrow', 'ms', 'mspace', 'msqrt', 'mstyle', 'msub', 'msup', 'msubsup', 'mtable', 'mtd', 'mtext', 'mtr', 'munder', 'munderover', 'mprescripts']); // Similarly to SVG, we want to know all MathML elements,
925
- // even those that we disallow by default.
926
-
927
- const mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);
928
- const text = freeze(['#text']);
929
-
930
- const html = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inputmode', 'integrity', 'ismap', 'kind', 'label', 'lang', 'list', 'loading', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'minlength', 'multiple', 'muted', 'name', 'nonce', 'noshade', 'novalidate', 'nowrap', 'open', 'optimum', 'pattern', 'placeholder', 'playsinline', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'xmlns', 'slot']);
931
- const svg = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dur', 'edgemode', 'elevation', 'end', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'targetx', 'targety', 'transform', 'transform-origin', 'text-anchor', 'text-decoration', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']);
932
- const mathMl = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnsalign', 'columnlines', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lspace', 'lquote', 'mathbackground', 'mathcolor', 'mathsize', 'mathvariant', 'maxsize', 'minsize', 'movablelimits', 'notation', 'numalign', 'open', 'rowalign', 'rowlines', 'rowspacing', 'rowspan', 'rspace', 'rquote', 'scriptlevel', 'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator', 'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset', 'width', 'xmlns']);
933
- const xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
934
-
935
- const MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode
936
-
937
- const ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm);
938
- const TMPLIT_EXPR = seal(/\${[\w\W]*}/gm);
939
- const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/); // eslint-disable-line no-useless-escape
940
-
941
- const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
942
-
943
- const IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape
944
- );
945
- const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
946
- const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex
947
- );
948
- const DOCTYPE_NAME = seal(/^html$/i);
949
-
950
- var EXPRESSIONS = /*#__PURE__*/Object.freeze({
951
- __proto__: null,
952
- MUSTACHE_EXPR: MUSTACHE_EXPR,
953
- ERB_EXPR: ERB_EXPR,
954
- TMPLIT_EXPR: TMPLIT_EXPR,
955
- DATA_ATTR: DATA_ATTR,
956
- ARIA_ATTR: ARIA_ATTR,
957
- IS_ALLOWED_URI: IS_ALLOWED_URI,
958
- IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA,
959
- ATTR_WHITESPACE: ATTR_WHITESPACE,
960
- DOCTYPE_NAME: DOCTYPE_NAME
961
- });
962
-
963
- const getGlobal = () => typeof window === 'undefined' ? null : window;
964
- /**
965
- * Creates a no-op policy for internal use only.
966
- * Don't export this function outside this module!
967
- * @param {?TrustedTypePolicyFactory} trustedTypes The policy factory.
968
- * @param {HTMLScriptElement} purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix).
969
- * @return {?TrustedTypePolicy} The policy created (or null, if Trusted Types
970
- * are not supported or creating the policy failed).
971
- */
972
-
973
-
974
- const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) {
975
- if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') {
976
- return null;
977
- } // Allow the callers to control the unique policy name
978
- // by adding a data-tt-policy-suffix to the script element with the DOMPurify.
979
- // Policy creation with duplicate names throws in Trusted Types.
980
-
981
-
982
- let suffix = null;
983
- const ATTR_NAME = 'data-tt-policy-suffix';
984
-
985
- if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {
986
- suffix = purifyHostElement.getAttribute(ATTR_NAME);
987
- }
988
-
989
- const policyName = 'dompurify' + (suffix ? '#' + suffix : '');
990
-
991
- try {
992
- return trustedTypes.createPolicy(policyName, {
993
- createHTML(html) {
994
- return html;
995
- },
996
-
997
- createScriptURL(scriptUrl) {
998
- return scriptUrl;
999
- }
1000
-
1001
- });
1002
- } catch (_) {
1003
- // Policy creation failed (most likely another DOMPurify script has
1004
- // already run). Skip creating the policy, as this will only cause errors
1005
- // if TT are enforced.
1006
- console.warn('TrustedTypes policy ' + policyName + ' could not be created.');
1007
- return null;
1008
- }
1009
- };
1010
-
1011
- function createDOMPurify() {
1012
- let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
1013
-
1014
- const DOMPurify = root => createDOMPurify(root);
1015
- /**
1016
- * Version label, exposed for easier checks
1017
- * if DOMPurify is up to date or not
1018
- */
1019
-
1020
-
1021
- DOMPurify.version = '3.0.3';
1022
- /**
1023
- * Array of elements that DOMPurify removed during sanitation.
1024
- * Empty if nothing was removed.
1025
- */
1026
-
1027
- DOMPurify.removed = [];
1028
-
1029
- if (!window || !window.document || window.document.nodeType !== 9) {
1030
- // Not running in a browser, provide a factory function
1031
- // so that you can pass your own Window
1032
- DOMPurify.isSupported = false;
1033
- return DOMPurify;
1034
- }
1035
-
1036
- const originalDocument = window.document;
1037
- const currentScript = originalDocument.currentScript;
1038
- let {
1039
- document
1040
- } = window;
1041
- const {
1042
- DocumentFragment,
1043
- HTMLTemplateElement,
1044
- Node,
1045
- Element,
1046
- NodeFilter,
1047
- NamedNodeMap = window.NamedNodeMap || window.MozNamedAttrMap,
1048
- HTMLFormElement,
1049
- DOMParser,
1050
- trustedTypes
1051
- } = window;
1052
- const ElementPrototype = Element.prototype;
1053
- const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
1054
- const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
1055
- const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
1056
- const getParentNode = lookupGetter(ElementPrototype, 'parentNode'); // As per issue #47, the web-components registry is inherited by a
1057
- // new document created via createHTMLDocument. As per the spec
1058
- // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
1059
- // a new empty registry is used when creating a template contents owner
1060
- // document, so we use that as our parent document to ensure nothing
1061
- // is inherited.
1062
-
1063
- if (typeof HTMLTemplateElement === 'function') {
1064
- const template = document.createElement('template');
1065
-
1066
- if (template.content && template.content.ownerDocument) {
1067
- document = template.content.ownerDocument;
1068
- }
1069
- }
1070
-
1071
- let trustedTypesPolicy;
1072
- let emptyHTML = '';
1073
- const {
1074
- implementation,
1075
- createNodeIterator,
1076
- createDocumentFragment,
1077
- getElementsByTagName
1078
- } = document;
1079
- const {
1080
- importNode
1081
- } = originalDocument;
1082
- let hooks = {};
1083
- /**
1084
- * Expose whether this browser supports running the full DOMPurify.
1085
- */
1086
-
1087
- DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && implementation.createHTMLDocument !== undefined;
1088
- const {
1089
- MUSTACHE_EXPR,
1090
- ERB_EXPR,
1091
- TMPLIT_EXPR,
1092
- DATA_ATTR,
1093
- ARIA_ATTR,
1094
- IS_SCRIPT_OR_DATA,
1095
- ATTR_WHITESPACE
1096
- } = EXPRESSIONS;
1097
- let {
1098
- IS_ALLOWED_URI: IS_ALLOWED_URI$1
1099
- } = EXPRESSIONS;
1100
- /**
1101
- * We consider the elements and attributes below to be safe. Ideally
1102
- * don't add any new ones but feel free to remove unwanted ones.
1103
- */
1104
-
1105
- /* allowed element names */
1106
-
1107
- let ALLOWED_TAGS = null;
1108
- const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]);
1109
- /* Allowed attribute names */
1110
-
1111
- let ALLOWED_ATTR = null;
1112
- const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);
1113
- /*
1114
- * Configure how DOMPUrify should handle custom elements and their attributes as well as customized built-in elements.
1115
- * @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements)
1116
- * @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list)
1117
- * @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`.
1118
- */
1119
-
1120
- let CUSTOM_ELEMENT_HANDLING = Object.seal(Object.create(null, {
1121
- tagNameCheck: {
1122
- writable: true,
1123
- configurable: false,
1124
- enumerable: true,
1125
- value: null
1126
- },
1127
- attributeNameCheck: {
1128
- writable: true,
1129
- configurable: false,
1130
- enumerable: true,
1131
- value: null
1132
- },
1133
- allowCustomizedBuiltInElements: {
1134
- writable: true,
1135
- configurable: false,
1136
- enumerable: true,
1137
- value: false
1138
- }
1139
- }));
1140
- /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */
1141
-
1142
- let FORBID_TAGS = null;
1143
- /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */
1144
-
1145
- let FORBID_ATTR = null;
1146
- /* Decide if ARIA attributes are okay */
1147
-
1148
- let ALLOW_ARIA_ATTR = true;
1149
- /* Decide if custom data attributes are okay */
1150
-
1151
- let ALLOW_DATA_ATTR = true;
1152
- /* Decide if unknown protocols are okay */
1153
-
1154
- let ALLOW_UNKNOWN_PROTOCOLS = false;
1155
- /* Decide if self-closing tags in attributes are allowed.
1156
- * Usually removed due to a mXSS issue in jQuery 3.0 */
1157
-
1158
- let ALLOW_SELF_CLOSE_IN_ATTR = true;
1159
- /* Output should be safe for common template engines.
1160
- * This means, DOMPurify removes data attributes, mustaches and ERB
1161
- */
1162
-
1163
- let SAFE_FOR_TEMPLATES = false;
1164
- /* Decide if document with <html>... should be returned */
1165
-
1166
- let WHOLE_DOCUMENT = false;
1167
- /* Track whether config is already set on this instance of DOMPurify. */
1168
-
1169
- let SET_CONFIG = false;
1170
- /* Decide if all elements (e.g. style, script) must be children of
1171
- * document.body. By default, browsers might move them to document.head */
1172
-
1173
- let FORCE_BODY = false;
1174
- /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html
1175
- * string (or a TrustedHTML object if Trusted Types are supported).
1176
- * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead
1177
- */
1178
-
1179
- let RETURN_DOM = false;
1180
- /* Decide if a DOM `DocumentFragment` should be returned, instead of a html
1181
- * string (or a TrustedHTML object if Trusted Types are supported) */
1182
-
1183
- let RETURN_DOM_FRAGMENT = false;
1184
- /* Try to return a Trusted Type object instead of a string, return a string in
1185
- * case Trusted Types are not supported */
1186
-
1187
- let RETURN_TRUSTED_TYPE = false;
1188
- /* Output should be free from DOM clobbering attacks?
1189
- * This sanitizes markups named with colliding, clobberable built-in DOM APIs.
1190
- */
1191
-
1192
- let SANITIZE_DOM = true;
1193
- /* Achieve full DOM Clobbering protection by isolating the namespace of named
1194
- * properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules.
1195
- *
1196
- * HTML/DOM spec rules that enable DOM Clobbering:
1197
- * - Named Access on Window (§7.3.3)
1198
- * - DOM Tree Accessors (§3.1.5)
1199
- * - Form Element Parent-Child Relations (§4.10.3)
1200
- * - Iframe srcdoc / Nested WindowProxies (§4.8.5)
1201
- * - HTMLCollection (§4.2.10.2)
1202
- *
1203
- * Namespace isolation is implemented by prefixing `id` and `name` attributes
1204
- * with a constant string, i.e., `user-content-`
1205
- */
1206
-
1207
- let SANITIZE_NAMED_PROPS = false;
1208
- const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-';
1209
- /* Keep element content when removing element? */
1210
-
1211
- let KEEP_CONTENT = true;
1212
- /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead
1213
- * of importing it into a new Document and returning a sanitized copy */
1214
-
1215
- let IN_PLACE = false;
1216
- /* Allow usage of profiles like html, svg and mathMl */
1217
-
1218
- let USE_PROFILES = {};
1219
- /* Tags to ignore content of when KEEP_CONTENT is true */
1220
-
1221
- let FORBID_CONTENTS = null;
1222
- const DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']);
1223
- /* Tags that are safe for data: URIs */
1224
-
1225
- let DATA_URI_TAGS = null;
1226
- const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);
1227
- /* Attributes safe for values like "javascript:" */
1228
-
1229
- let URI_SAFE_ATTRIBUTES = null;
1230
- const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']);
1231
- const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
1232
- const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
1233
- const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
1234
- /* Document namespace */
1235
-
1236
- let NAMESPACE = HTML_NAMESPACE;
1237
- let IS_EMPTY_INPUT = false;
1238
- /* Allowed XHTML+XML namespaces */
1239
-
1240
- let ALLOWED_NAMESPACES = null;
1241
- const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
1242
- /* Parsing of strict XHTML documents */
1243
-
1244
- let PARSER_MEDIA_TYPE;
1245
- const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];
1246
- const DEFAULT_PARSER_MEDIA_TYPE = 'text/html';
1247
- let transformCaseFunc;
1248
- /* Keep a reference to config to pass to hooks */
1249
-
1250
- let CONFIG = null;
1251
- /* Ideally, do not touch anything below this line */
1252
-
1253
- /* ______________________________________________ */
1254
-
1255
- const formElement = document.createElement('form');
1256
-
1257
- const isRegexOrFunction = function isRegexOrFunction(testValue) {
1258
- return testValue instanceof RegExp || testValue instanceof Function;
1259
- };
1260
- /**
1261
- * _parseConfig
1262
- *
1263
- * @param {Object} cfg optional config literal
1264
- */
1265
- // eslint-disable-next-line complexity
1266
-
1267
-
1268
- const _parseConfig = function _parseConfig(cfg) {
1269
- if (CONFIG && CONFIG === cfg) {
1270
- return;
1271
- }
1272
- /* Shield configuration object from tampering */
1273
-
1274
-
1275
- if (!cfg || typeof cfg !== 'object') {
1276
- cfg = {};
1277
- }
1278
- /* Shield configuration object from prototype pollution */
1279
-
1280
-
1281
- cfg = clone(cfg);
1282
- PARSER_MEDIA_TYPE = // eslint-disable-next-line unicorn/prefer-includes
1283
- SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? PARSER_MEDIA_TYPE = DEFAULT_PARSER_MEDIA_TYPE : PARSER_MEDIA_TYPE = cfg.PARSER_MEDIA_TYPE; // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.
1284
-
1285
- transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase;
1286
- /* Set configuration parameters */
1287
-
1288
- ALLOWED_TAGS = 'ALLOWED_TAGS' in cfg ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
1289
- ALLOWED_ATTR = 'ALLOWED_ATTR' in cfg ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
1290
- ALLOWED_NAMESPACES = 'ALLOWED_NAMESPACES' in cfg ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
1291
- URI_SAFE_ATTRIBUTES = 'ADD_URI_SAFE_ATTR' in cfg ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), // eslint-disable-line indent
1292
- cfg.ADD_URI_SAFE_ATTR, // eslint-disable-line indent
1293
- transformCaseFunc // eslint-disable-line indent
1294
- ) // eslint-disable-line indent
1295
- : DEFAULT_URI_SAFE_ATTRIBUTES;
1296
- DATA_URI_TAGS = 'ADD_DATA_URI_TAGS' in cfg ? addToSet(clone(DEFAULT_DATA_URI_TAGS), // eslint-disable-line indent
1297
- cfg.ADD_DATA_URI_TAGS, // eslint-disable-line indent
1298
- transformCaseFunc // eslint-disable-line indent
1299
- ) // eslint-disable-line indent
1300
- : DEFAULT_DATA_URI_TAGS;
1301
- FORBID_CONTENTS = 'FORBID_CONTENTS' in cfg ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
1302
- FORBID_TAGS = 'FORBID_TAGS' in cfg ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : {};
1303
- FORBID_ATTR = 'FORBID_ATTR' in cfg ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : {};
1304
- USE_PROFILES = 'USE_PROFILES' in cfg ? cfg.USE_PROFILES : false;
1305
- ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
1306
-
1307
- ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
1308
-
1309
- ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
1310
-
1311
- ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true
1312
-
1313
- SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false
1314
-
1315
- WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false
1316
-
1317
- RETURN_DOM = cfg.RETURN_DOM || false; // Default false
1318
-
1319
- RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false
1320
-
1321
- RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false
1322
-
1323
- FORCE_BODY = cfg.FORCE_BODY || false; // Default false
1324
-
1325
- SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true
1326
-
1327
- SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false
1328
-
1329
- KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true
1330
-
1331
- IN_PLACE = cfg.IN_PLACE || false; // Default false
1332
-
1333
- IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI;
1334
- NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;
1335
- CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {};
1336
-
1337
- if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) {
1338
- CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck;
1339
- }
1340
-
1341
- if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) {
1342
- CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck;
1343
- }
1344
-
1345
- if (cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === 'boolean') {
1346
- CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements;
1347
- }
1348
-
1349
- if (SAFE_FOR_TEMPLATES) {
1350
- ALLOW_DATA_ATTR = false;
1351
- }
1352
-
1353
- if (RETURN_DOM_FRAGMENT) {
1354
- RETURN_DOM = true;
1355
- }
1356
- /* Parse profile info */
1357
-
1358
-
1359
- if (USE_PROFILES) {
1360
- ALLOWED_TAGS = addToSet({}, [...text]);
1361
- ALLOWED_ATTR = [];
1362
-
1363
- if (USE_PROFILES.html === true) {
1364
- addToSet(ALLOWED_TAGS, html$1);
1365
- addToSet(ALLOWED_ATTR, html);
1366
- }
1367
-
1368
- if (USE_PROFILES.svg === true) {
1369
- addToSet(ALLOWED_TAGS, svg$1);
1370
- addToSet(ALLOWED_ATTR, svg);
1371
- addToSet(ALLOWED_ATTR, xml);
1372
- }
1373
-
1374
- if (USE_PROFILES.svgFilters === true) {
1375
- addToSet(ALLOWED_TAGS, svgFilters);
1376
- addToSet(ALLOWED_ATTR, svg);
1377
- addToSet(ALLOWED_ATTR, xml);
1378
- }
1379
-
1380
- if (USE_PROFILES.mathMl === true) {
1381
- addToSet(ALLOWED_TAGS, mathMl$1);
1382
- addToSet(ALLOWED_ATTR, mathMl);
1383
- addToSet(ALLOWED_ATTR, xml);
1384
- }
1385
- }
1386
- /* Merge configuration parameters */
1387
-
1388
-
1389
- if (cfg.ADD_TAGS) {
1390
- if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
1391
- ALLOWED_TAGS = clone(ALLOWED_TAGS);
1392
- }
1393
-
1394
- addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
1395
- }
1396
-
1397
- if (cfg.ADD_ATTR) {
1398
- if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
1399
- ALLOWED_ATTR = clone(ALLOWED_ATTR);
1400
- }
1401
-
1402
- addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
1403
- }
1404
-
1405
- if (cfg.ADD_URI_SAFE_ATTR) {
1406
- addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
1407
- }
1408
-
1409
- if (cfg.FORBID_CONTENTS) {
1410
- if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
1411
- FORBID_CONTENTS = clone(FORBID_CONTENTS);
1412
- }
1413
-
1414
- addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
1415
- }
1416
- /* Add #text in case KEEP_CONTENT is set to true */
1417
-
1418
-
1419
- if (KEEP_CONTENT) {
1420
- ALLOWED_TAGS['#text'] = true;
1421
- }
1422
- /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */
1423
-
1424
-
1425
- if (WHOLE_DOCUMENT) {
1426
- addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);
1427
- }
1428
- /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */
1429
-
1430
-
1431
- if (ALLOWED_TAGS.table) {
1432
- addToSet(ALLOWED_TAGS, ['tbody']);
1433
- delete FORBID_TAGS.tbody;
1434
- }
1435
-
1436
- if (cfg.TRUSTED_TYPES_POLICY) {
1437
- if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') {
1438
- throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
1439
- }
1440
-
1441
- if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') {
1442
- throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
1443
- } // Overwrite existing TrustedTypes policy.
1444
-
1445
-
1446
- trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY; // Sign local variables required by `sanitize`.
1447
-
1448
- emptyHTML = trustedTypesPolicy.createHTML('');
1449
- } else {
1450
- // Uninitialized policy, attempt to initialize the internal dompurify policy.
1451
- if (trustedTypesPolicy === undefined) {
1452
- trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
1453
- } // If creating the internal policy succeeded sign internal variables.
1454
-
1455
-
1456
- if (trustedTypesPolicy !== null && typeof emptyHTML === 'string') {
1457
- emptyHTML = trustedTypesPolicy.createHTML('');
1458
- }
1459
- } // Prevent further manipulation of configuration.
1460
- // Not available in IE8, Safari 5, etc.
1461
-
1462
-
1463
- if (freeze) {
1464
- freeze(cfg);
1465
- }
1466
-
1467
- CONFIG = cfg;
1468
- };
1469
-
1470
- const MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']);
1471
- const HTML_INTEGRATION_POINTS = addToSet({}, ['foreignobject', 'desc', 'title', 'annotation-xml']); // Certain elements are allowed in both SVG and HTML
1472
- // namespace. We need to specify them explicitly
1473
- // so that they don't get erroneously deleted from
1474
- // HTML namespace.
1475
-
1476
- const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']);
1477
- /* Keep track of all possible SVG and MathML tags
1478
- * so that we can perform the namespace checks
1479
- * correctly. */
1480
-
1481
- const ALL_SVG_TAGS = addToSet({}, svg$1);
1482
- addToSet(ALL_SVG_TAGS, svgFilters);
1483
- addToSet(ALL_SVG_TAGS, svgDisallowed);
1484
- const ALL_MATHML_TAGS = addToSet({}, mathMl$1);
1485
- addToSet(ALL_MATHML_TAGS, mathMlDisallowed);
1486
- /**
1487
- *
1488
- *
1489
- * @param {Element} element a DOM element whose namespace is being checked
1490
- * @returns {boolean} Return false if the element has a
1491
- * namespace that a spec-compliant parser would never
1492
- * return. Return true otherwise.
1493
- */
1494
-
1495
- const _checkValidNamespace = function _checkValidNamespace(element) {
1496
- let parent = getParentNode(element); // In JSDOM, if we're inside shadow DOM, then parentNode
1497
- // can be null. We just simulate parent in this case.
1498
-
1499
- if (!parent || !parent.tagName) {
1500
- parent = {
1501
- namespaceURI: NAMESPACE,
1502
- tagName: 'template'
1503
- };
1504
- }
1505
-
1506
- const tagName = stringToLowerCase(element.tagName);
1507
- const parentTagName = stringToLowerCase(parent.tagName);
1508
-
1509
- if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
1510
- return false;
1511
- }
1512
-
1513
- if (element.namespaceURI === SVG_NAMESPACE) {
1514
- // The only way to switch from HTML namespace to SVG
1515
- // is via <svg>. If it happens via any other tag, then
1516
- // it should be killed.
1517
- if (parent.namespaceURI === HTML_NAMESPACE) {
1518
- return tagName === 'svg';
1519
- } // The only way to switch from MathML to SVG is via`
1520
- // svg if parent is either <annotation-xml> or MathML
1521
- // text integration points.
1522
-
1523
-
1524
- if (parent.namespaceURI === MATHML_NAMESPACE) {
1525
- return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
1526
- } // We only allow elements that are defined in SVG
1527
- // spec. All others are disallowed in SVG namespace.
1528
-
1529
-
1530
- return Boolean(ALL_SVG_TAGS[tagName]);
1531
- }
1532
-
1533
- if (element.namespaceURI === MATHML_NAMESPACE) {
1534
- // The only way to switch from HTML namespace to MathML
1535
- // is via <math>. If it happens via any other tag, then
1536
- // it should be killed.
1537
- if (parent.namespaceURI === HTML_NAMESPACE) {
1538
- return tagName === 'math';
1539
- } // The only way to switch from SVG to MathML is via
1540
- // <math> and HTML integration points
1541
-
1542
-
1543
- if (parent.namespaceURI === SVG_NAMESPACE) {
1544
- return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
1545
- } // We only allow elements that are defined in MathML
1546
- // spec. All others are disallowed in MathML namespace.
1547
-
1548
-
1549
- return Boolean(ALL_MATHML_TAGS[tagName]);
1550
- }
1551
-
1552
- if (element.namespaceURI === HTML_NAMESPACE) {
1553
- // The only way to switch from SVG to HTML is via
1554
- // HTML integration points, and from MathML to HTML
1555
- // is via MathML text integration points
1556
- if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
1557
- return false;
1558
- }
1559
-
1560
- if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
1561
- return false;
1562
- } // We disallow tags that are specific for MathML
1563
- // or SVG and should never appear in HTML namespace
1564
-
1565
-
1566
- return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
1567
- } // For XHTML and XML documents that support custom namespaces
1568
-
1569
-
1570
- if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) {
1571
- return true;
1572
- } // The code should never reach this place (this means
1573
- // that the element somehow got namespace that is not
1574
- // HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES).
1575
- // Return false just in case.
1576
-
1577
-
1578
- return false;
1579
- };
1580
- /**
1581
- * _forceRemove
1582
- *
1583
- * @param {Node} node a DOM node
1584
- */
1585
-
1586
-
1587
- const _forceRemove = function _forceRemove(node) {
1588
- arrayPush(DOMPurify.removed, {
1589
- element: node
1590
- });
1591
-
1592
- try {
1593
- // eslint-disable-next-line unicorn/prefer-dom-node-remove
1594
- node.parentNode.removeChild(node);
1595
- } catch (_) {
1596
- node.remove();
1597
- }
1598
- };
1599
- /**
1600
- * _removeAttribute
1601
- *
1602
- * @param {String} name an Attribute name
1603
- * @param {Node} node a DOM node
1604
- */
1605
-
1606
-
1607
- const _removeAttribute = function _removeAttribute(name, node) {
1608
- try {
1609
- arrayPush(DOMPurify.removed, {
1610
- attribute: node.getAttributeNode(name),
1611
- from: node
1612
- });
1613
- } catch (_) {
1614
- arrayPush(DOMPurify.removed, {
1615
- attribute: null,
1616
- from: node
1617
- });
1618
- }
1619
-
1620
- node.removeAttribute(name); // We void attribute values for unremovable "is"" attributes
1621
-
1622
- if (name === 'is' && !ALLOWED_ATTR[name]) {
1623
- if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
1624
- try {
1625
- _forceRemove(node);
1626
- } catch (_) {}
1627
- } else {
1628
- try {
1629
- node.setAttribute(name, '');
1630
- } catch (_) {}
1631
- }
1632
- }
1633
- };
1634
- /**
1635
- * _initDocument
1636
- *
1637
- * @param {String} dirty a string of dirty markup
1638
- * @return {Document} a DOM, filled with the dirty markup
1639
- */
1640
-
1641
-
1642
- const _initDocument = function _initDocument(dirty) {
1643
- /* Create a HTML document */
1644
- let doc;
1645
- let leadingWhitespace;
1646
-
1647
- if (FORCE_BODY) {
1648
- dirty = '<remove></remove>' + dirty;
1649
- } else {
1650
- /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */
1651
- const matches = stringMatch(dirty, /^[\r\n\t ]+/);
1652
- leadingWhitespace = matches && matches[0];
1653
- }
1654
-
1655
- if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && NAMESPACE === HTML_NAMESPACE) {
1656
- // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)
1657
- dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>';
1658
- }
1659
-
1660
- const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
1661
- /*
1662
- * Use the DOMParser API by default, fallback later if needs be
1663
- * DOMParser not work for svg when has multiple root element.
1664
- */
1665
-
1666
- if (NAMESPACE === HTML_NAMESPACE) {
1667
- try {
1668
- doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
1669
- } catch (_) {}
1670
- }
1671
- /* Use createHTMLDocument in case DOMParser is not available */
1672
-
1673
-
1674
- if (!doc || !doc.documentElement) {
1675
- doc = implementation.createDocument(NAMESPACE, 'template', null);
1676
-
1677
- try {
1678
- doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
1679
- } catch (_) {// Syntax error if dirtyPayload is invalid xml
1680
- }
1681
- }
1682
-
1683
- const body = doc.body || doc.documentElement;
1684
-
1685
- if (dirty && leadingWhitespace) {
1686
- body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
1687
- }
1688
- /* Work on whole document or just its body */
1689
-
1690
-
1691
- if (NAMESPACE === HTML_NAMESPACE) {
1692
- return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];
1693
- }
1694
-
1695
- return WHOLE_DOCUMENT ? doc.documentElement : body;
1696
- };
1697
- /**
1698
- * _createIterator
1699
- *
1700
- * @param {Document} root document/fragment to create iterator for
1701
- * @return {Iterator} iterator instance
1702
- */
1703
-
1704
-
1705
- const _createIterator = function _createIterator(root) {
1706
- return createNodeIterator.call(root.ownerDocument || root, root, // eslint-disable-next-line no-bitwise
1707
- NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT, null, false);
1708
- };
1709
- /**
1710
- * _isClobbered
1711
- *
1712
- * @param {Node} elm element to check for clobbering attacks
1713
- * @return {Boolean} true if clobbered, false if safe
1714
- */
1715
-
1716
-
1717
- const _isClobbered = function _isClobbered(elm) {
1718
- return elm instanceof HTMLFormElement && (typeof elm.nodeName !== 'string' || typeof elm.textContent !== 'string' || typeof elm.removeChild !== 'function' || !(elm.attributes instanceof NamedNodeMap) || typeof elm.removeAttribute !== 'function' || typeof elm.setAttribute !== 'function' || typeof elm.namespaceURI !== 'string' || typeof elm.insertBefore !== 'function' || typeof elm.hasChildNodes !== 'function');
1719
- };
1720
- /**
1721
- * _isNode
1722
- *
1723
- * @param {Node} obj object to check whether it's a DOM node
1724
- * @return {Boolean} true is object is a DOM node
1725
- */
1726
-
1727
-
1728
- const _isNode = function _isNode(object) {
1729
- return typeof Node === 'object' ? object instanceof Node : object && typeof object === 'object' && typeof object.nodeType === 'number' && typeof object.nodeName === 'string';
1730
- };
1731
- /**
1732
- * _executeHook
1733
- * Execute user configurable hooks
1734
- *
1735
- * @param {String} entryPoint Name of the hook's entry point
1736
- * @param {Node} currentNode node to work on with the hook
1737
- * @param {Object} data additional hook parameters
1738
- */
1739
-
1740
-
1741
- const _executeHook = function _executeHook(entryPoint, currentNode, data) {
1742
- if (!hooks[entryPoint]) {
1743
- return;
1744
- }
1745
-
1746
- arrayForEach(hooks[entryPoint], hook => {
1747
- hook.call(DOMPurify, currentNode, data, CONFIG);
1748
- });
1749
- };
1750
- /**
1751
- * _sanitizeElements
1752
- *
1753
- * @protect nodeName
1754
- * @protect textContent
1755
- * @protect removeChild
1756
- *
1757
- * @param {Node} currentNode to check for permission to exist
1758
- * @return {Boolean} true if node was killed, false if left alive
1759
- */
1760
-
1761
-
1762
- const _sanitizeElements = function _sanitizeElements(currentNode) {
1763
- let content;
1764
- /* Execute a hook if present */
1765
-
1766
- _executeHook('beforeSanitizeElements', currentNode, null);
1767
- /* Check if element is clobbered or can clobber */
1768
-
1769
-
1770
- if (_isClobbered(currentNode)) {
1771
- _forceRemove(currentNode);
1772
-
1773
- return true;
1774
- }
1775
- /* Now let's check the element's type and name */
1776
-
1777
-
1778
- const tagName = transformCaseFunc(currentNode.nodeName);
1779
- /* Execute a hook if present */
1780
-
1781
- _executeHook('uponSanitizeElement', currentNode, {
1782
- tagName,
1783
- allowedTags: ALLOWED_TAGS
1784
- });
1785
- /* Detect mXSS attempts abusing namespace confusion */
1786
-
1787
-
1788
- if (currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && (!_isNode(currentNode.content) || !_isNode(currentNode.content.firstElementChild)) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) {
1789
- _forceRemove(currentNode);
1790
-
1791
- return true;
1792
- }
1793
- /* Remove element if anything forbids its presence */
1794
-
1795
-
1796
- if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
1797
- /* Check if we have a custom element to handle */
1798
- if (!FORBID_TAGS[tagName] && _basicCustomElementTest(tagName)) {
1799
- if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) return false;
1800
- if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) return false;
1801
- }
1802
- /* Keep content except for bad-listed elements */
1803
-
1804
-
1805
- if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
1806
- const parentNode = getParentNode(currentNode) || currentNode.parentNode;
1807
- const childNodes = getChildNodes(currentNode) || currentNode.childNodes;
1808
-
1809
- if (childNodes && parentNode) {
1810
- const childCount = childNodes.length;
1811
-
1812
- for (let i = childCount - 1; i >= 0; --i) {
1813
- parentNode.insertBefore(cloneNode(childNodes[i], true), getNextSibling(currentNode));
1814
- }
1815
- }
1816
- }
1817
-
1818
- _forceRemove(currentNode);
1819
-
1820
- return true;
1821
- }
1822
- /* Check whether element has a valid namespace */
1823
-
1824
-
1825
- if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {
1826
- _forceRemove(currentNode);
1827
-
1828
- return true;
1829
- }
1830
- /* Make sure that older browsers don't get noscript mXSS */
1831
-
1832
-
1833
- if ((tagName === 'noscript' || tagName === 'noembed') && regExpTest(/<\/no(script|embed)/i, currentNode.innerHTML)) {
1834
- _forceRemove(currentNode);
1835
-
1836
- return true;
1837
- }
1838
- /* Sanitize element content to be template-safe */
1839
-
1840
-
1841
- if (SAFE_FOR_TEMPLATES && currentNode.nodeType === 3) {
1842
- /* Get the element's text content */
1843
- content = currentNode.textContent;
1844
- content = stringReplace(content, MUSTACHE_EXPR, ' ');
1845
- content = stringReplace(content, ERB_EXPR, ' ');
1846
- content = stringReplace(content, TMPLIT_EXPR, ' ');
1847
-
1848
- if (currentNode.textContent !== content) {
1849
- arrayPush(DOMPurify.removed, {
1850
- element: currentNode.cloneNode()
1851
- });
1852
- currentNode.textContent = content;
1853
- }
1854
- }
1855
- /* Execute a hook if present */
1856
-
1857
-
1858
- _executeHook('afterSanitizeElements', currentNode, null);
1859
-
1860
- return false;
1861
- };
1862
- /**
1863
- * _isValidAttribute
1864
- *
1865
- * @param {string} lcTag Lowercase tag name of containing element.
1866
- * @param {string} lcName Lowercase attribute name.
1867
- * @param {string} value Attribute value.
1868
- * @return {Boolean} Returns true if `value` is valid, otherwise false.
1869
- */
1870
- // eslint-disable-next-line complexity
1871
-
1872
-
1873
- const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
1874
- /* Make sure attribute cannot clobber */
1875
- if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
1876
- return false;
1877
- }
1878
- /* Allow valid data-* attributes: At least one character after "-"
1879
- (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
1880
- XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
1881
- We don't need to check the value; it's always URI safe. */
1882
-
1883
-
1884
- if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR, lcName)) ; else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) {
1885
- if ( // First condition does a very basic check if a) it's basically a valid custom element tagname AND
1886
- // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
1887
- // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
1888
- _basicCustomElementTest(lcTag) && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag)) && (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName) || CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName)) || // Alternative, second condition checks if it's an `is`-attribute, AND
1889
- // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
1890
- lcName === 'is' && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(value))) ; else {
1891
- return false;
1892
- }
1893
- /* Check value is safe. First, is attr inert? If so, is safe */
1894
-
1895
- } else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]) ; else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if (value) {
1896
- return false;
1897
- } else ;
1898
-
1899
- return true;
1900
- };
1901
- /**
1902
- * _basicCustomElementCheck
1903
- * checks if at least one dash is included in tagName, and it's not the first char
1904
- * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name
1905
- * @param {string} tagName name of the tag of the node to sanitize
1906
- */
1907
-
1908
-
1909
- const _basicCustomElementTest = function _basicCustomElementTest(tagName) {
1910
- return tagName.indexOf('-') > 0;
1911
- };
1912
- /**
1913
- * _sanitizeAttributes
1914
- *
1915
- * @protect attributes
1916
- * @protect nodeName
1917
- * @protect removeAttribute
1918
- * @protect setAttribute
1919
- *
1920
- * @param {Node} currentNode to sanitize
1921
- */
1922
-
1923
-
1924
- const _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
1925
- let attr;
1926
- let value;
1927
- let lcName;
1928
- let l;
1929
- /* Execute a hook if present */
1930
-
1931
- _executeHook('beforeSanitizeAttributes', currentNode, null);
1932
-
1933
- const {
1934
- attributes
1935
- } = currentNode;
1936
- /* Check if we have attributes; if not we might have a text node */
1937
-
1938
- if (!attributes) {
1939
- return;
1940
- }
1941
-
1942
- const hookEvent = {
1943
- attrName: '',
1944
- attrValue: '',
1945
- keepAttr: true,
1946
- allowedAttributes: ALLOWED_ATTR
1947
- };
1948
- l = attributes.length;
1949
- /* Go backwards over all attributes; safely remove bad ones */
1950
-
1951
- while (l--) {
1952
- attr = attributes[l];
1953
- const {
1954
- name,
1955
- namespaceURI
1956
- } = attr;
1957
- value = name === 'value' ? attr.value : stringTrim(attr.value);
1958
- lcName = transformCaseFunc(name);
1959
- /* Execute a hook if present */
1960
-
1961
- hookEvent.attrName = lcName;
1962
- hookEvent.attrValue = value;
1963
- hookEvent.keepAttr = true;
1964
- hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set
1965
-
1966
- _executeHook('uponSanitizeAttribute', currentNode, hookEvent);
1967
-
1968
- value = hookEvent.attrValue;
1969
- /* Did the hooks approve of the attribute? */
1970
-
1971
- if (hookEvent.forceKeepAttr) {
1972
- continue;
1973
- }
1974
- /* Remove attribute */
1975
-
1976
-
1977
- _removeAttribute(name, currentNode);
1978
- /* Did the hooks approve of the attribute? */
1979
-
1980
-
1981
- if (!hookEvent.keepAttr) {
1982
- continue;
1983
- }
1984
- /* Work around a security issue in jQuery 3.0 */
1985
-
1986
-
1987
- if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
1988
- _removeAttribute(name, currentNode);
1989
-
1990
- continue;
1991
- }
1992
- /* Sanitize attribute content to be template-safe */
1993
-
1994
-
1995
- if (SAFE_FOR_TEMPLATES) {
1996
- value = stringReplace(value, MUSTACHE_EXPR, ' ');
1997
- value = stringReplace(value, ERB_EXPR, ' ');
1998
- value = stringReplace(value, TMPLIT_EXPR, ' ');
1999
- }
2000
- /* Is `value` valid for this attribute? */
2001
-
2002
-
2003
- const lcTag = transformCaseFunc(currentNode.nodeName);
2004
-
2005
- if (!_isValidAttribute(lcTag, lcName, value)) {
2006
- continue;
2007
- }
2008
- /* Full DOM Clobbering protection via namespace isolation,
2009
- * Prefix id and name attributes with `user-content-`
2010
- */
2011
-
2012
-
2013
- if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name')) {
2014
- // Remove the attribute with this value
2015
- _removeAttribute(name, currentNode); // Prefix the value and later re-create the attribute with the sanitized value
2016
-
2017
-
2018
- value = SANITIZE_NAMED_PROPS_PREFIX + value;
2019
- }
2020
- /* Handle attributes that require Trusted Types */
2021
-
2022
-
2023
- if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function') {
2024
- if (namespaceURI) ; else {
2025
- switch (trustedTypes.getAttributeType(lcTag, lcName)) {
2026
- case 'TrustedHTML':
2027
- {
2028
- value = trustedTypesPolicy.createHTML(value);
2029
- break;
2030
- }
2031
-
2032
- case 'TrustedScriptURL':
2033
- {
2034
- value = trustedTypesPolicy.createScriptURL(value);
2035
- break;
2036
- }
2037
- }
2038
- }
2039
- }
2040
- /* Handle invalid data-* attribute set by try-catching it */
2041
-
2042
-
2043
- try {
2044
- if (namespaceURI) {
2045
- currentNode.setAttributeNS(namespaceURI, name, value);
2046
- } else {
2047
- /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
2048
- currentNode.setAttribute(name, value);
2049
- }
2050
-
2051
- arrayPop(DOMPurify.removed);
2052
- } catch (_) {}
2053
- }
2054
- /* Execute a hook if present */
2055
-
2056
-
2057
- _executeHook('afterSanitizeAttributes', currentNode, null);
2058
- };
2059
- /**
2060
- * _sanitizeShadowDOM
2061
- *
2062
- * @param {DocumentFragment} fragment to iterate over recursively
2063
- */
2064
-
2065
-
2066
- const _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) {
2067
- let shadowNode;
2068
-
2069
- const shadowIterator = _createIterator(fragment);
2070
- /* Execute a hook if present */
2071
-
2072
-
2073
- _executeHook('beforeSanitizeShadowDOM', fragment, null);
2074
-
2075
- while (shadowNode = shadowIterator.nextNode()) {
2076
- /* Execute a hook if present */
2077
- _executeHook('uponSanitizeShadowNode', shadowNode, null);
2078
- /* Sanitize tags and elements */
2079
-
2080
-
2081
- if (_sanitizeElements(shadowNode)) {
2082
- continue;
2083
- }
2084
- /* Deep shadow DOM detected */
2085
-
2086
-
2087
- if (shadowNode.content instanceof DocumentFragment) {
2088
- _sanitizeShadowDOM(shadowNode.content);
2089
- }
2090
- /* Check attributes, sanitize if necessary */
2091
-
2092
-
2093
- _sanitizeAttributes(shadowNode);
2094
- }
2095
- /* Execute a hook if present */
2096
-
2097
-
2098
- _executeHook('afterSanitizeShadowDOM', fragment, null);
2099
- };
2100
- /**
2101
- * Sanitize
2102
- * Public method providing core sanitation functionality
2103
- *
2104
- * @param {String|Node} dirty string or DOM node
2105
- * @param {Object} configuration object
2106
- */
2107
- // eslint-disable-next-line complexity
2108
-
2109
-
2110
- DOMPurify.sanitize = function (dirty) {
2111
- let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2112
- let body;
2113
- let importedNode;
2114
- let currentNode;
2115
- let returnNode;
2116
- /* Make sure we have a string to sanitize.
2117
- DO NOT return early, as this will return the wrong type if
2118
- the user has requested a DOM object rather than a string */
2119
-
2120
- IS_EMPTY_INPUT = !dirty;
2121
-
2122
- if (IS_EMPTY_INPUT) {
2123
- dirty = '<!-->';
2124
- }
2125
- /* Stringify, in case dirty is an object */
2126
-
2127
-
2128
- if (typeof dirty !== 'string' && !_isNode(dirty)) {
2129
- if (typeof dirty.toString === 'function') {
2130
- dirty = dirty.toString();
2131
-
2132
- if (typeof dirty !== 'string') {
2133
- throw typeErrorCreate('dirty is not a string, aborting');
2134
- }
2135
- } else {
2136
- throw typeErrorCreate('toString is not a function');
2137
- }
2138
- }
2139
- /* Return dirty HTML if DOMPurify cannot run */
2140
-
2141
-
2142
- if (!DOMPurify.isSupported) {
2143
- return dirty;
2144
- }
2145
- /* Assign config vars */
2146
-
2147
-
2148
- if (!SET_CONFIG) {
2149
- _parseConfig(cfg);
2150
- }
2151
- /* Clean up removed elements */
2152
-
2153
-
2154
- DOMPurify.removed = [];
2155
- /* Check if dirty is correctly typed for IN_PLACE */
2156
-
2157
- if (typeof dirty === 'string') {
2158
- IN_PLACE = false;
2159
- }
2160
-
2161
- if (IN_PLACE) {
2162
- /* Do some early pre-sanitization to avoid unsafe root nodes */
2163
- if (dirty.nodeName) {
2164
- const tagName = transformCaseFunc(dirty.nodeName);
2165
-
2166
- if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
2167
- throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');
2168
- }
2169
- }
2170
- } else if (dirty instanceof Node) {
2171
- /* If dirty is a DOM element, append to an empty document to avoid
2172
- elements being stripped by the parser */
2173
- body = _initDocument('<!---->');
2174
- importedNode = body.ownerDocument.importNode(dirty, true);
2175
-
2176
- if (importedNode.nodeType === 1 && importedNode.nodeName === 'BODY') {
2177
- /* Node is already a body, use as is */
2178
- body = importedNode;
2179
- } else if (importedNode.nodeName === 'HTML') {
2180
- body = importedNode;
2181
- } else {
2182
- // eslint-disable-next-line unicorn/prefer-dom-node-append
2183
- body.appendChild(importedNode);
2184
- }
2185
- } else {
2186
- /* Exit directly if we have nothing to do */
2187
- if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && // eslint-disable-next-line unicorn/prefer-includes
2188
- dirty.indexOf('<') === -1) {
2189
- return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
2190
- }
2191
- /* Initialize the document to work on */
2192
-
2193
-
2194
- body = _initDocument(dirty);
2195
- /* Check we have a DOM node from the data */
2196
-
2197
- if (!body) {
2198
- return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';
2199
- }
2200
- }
2201
- /* Remove first element node (ours) if FORCE_BODY is set */
2202
-
2203
-
2204
- if (body && FORCE_BODY) {
2205
- _forceRemove(body.firstChild);
2206
- }
2207
- /* Get node iterator */
2208
-
2209
-
2210
- const nodeIterator = _createIterator(IN_PLACE ? dirty : body);
2211
- /* Now start iterating over the created document */
2212
-
2213
-
2214
- while (currentNode = nodeIterator.nextNode()) {
2215
- /* Sanitize tags and elements */
2216
- if (_sanitizeElements(currentNode)) {
2217
- continue;
2218
- }
2219
- /* Shadow DOM detected, sanitize it */
2220
-
2221
-
2222
- if (currentNode.content instanceof DocumentFragment) {
2223
- _sanitizeShadowDOM(currentNode.content);
2224
- }
2225
- /* Check attributes, sanitize if necessary */
2226
-
2227
-
2228
- _sanitizeAttributes(currentNode);
2229
- }
2230
- /* If we sanitized `dirty` in-place, return it. */
2231
-
2232
-
2233
- if (IN_PLACE) {
2234
- return dirty;
2235
- }
2236
- /* Return sanitized string or DOM */
2237
-
2238
-
2239
- if (RETURN_DOM) {
2240
- if (RETURN_DOM_FRAGMENT) {
2241
- returnNode = createDocumentFragment.call(body.ownerDocument);
2242
-
2243
- while (body.firstChild) {
2244
- // eslint-disable-next-line unicorn/prefer-dom-node-append
2245
- returnNode.appendChild(body.firstChild);
2246
- }
2247
- } else {
2248
- returnNode = body;
2249
- }
2250
-
2251
- if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmod) {
2252
- /*
2253
- AdoptNode() is not used because internal state is not reset
2254
- (e.g. the past names map of a HTMLFormElement), this is safe
2255
- in theory but we would rather not risk another attack vector.
2256
- The state that is cloned by importNode() is explicitly defined
2257
- by the specs.
2258
- */
2259
- returnNode = importNode.call(originalDocument, returnNode, true);
2260
- }
2261
-
2262
- return returnNode;
2263
- }
2264
-
2265
- let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
2266
- /* Serialize doctype if allowed */
2267
-
2268
- if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
2269
- serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\n' + serializedHTML;
2270
- }
2271
- /* Sanitize final string template-safe */
2272
-
2273
-
2274
- if (SAFE_FOR_TEMPLATES) {
2275
- serializedHTML = stringReplace(serializedHTML, MUSTACHE_EXPR, ' ');
2276
- serializedHTML = stringReplace(serializedHTML, ERB_EXPR, ' ');
2277
- serializedHTML = stringReplace(serializedHTML, TMPLIT_EXPR, ' ');
2278
- }
2279
-
2280
- return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
2281
- };
2282
- /**
2283
- * Public method to set the configuration once
2284
- * setConfig
2285
- *
2286
- * @param {Object} cfg configuration object
2287
- */
2288
-
2289
-
2290
- DOMPurify.setConfig = function (cfg) {
2291
- _parseConfig(cfg);
2292
-
2293
- SET_CONFIG = true;
2294
- };
2295
- /**
2296
- * Public method to remove the configuration
2297
- * clearConfig
2298
- *
2299
- */
2300
-
2301
-
2302
- DOMPurify.clearConfig = function () {
2303
- CONFIG = null;
2304
- SET_CONFIG = false;
2305
- };
2306
- /**
2307
- * Public method to check if an attribute value is valid.
2308
- * Uses last set config, if any. Otherwise, uses config defaults.
2309
- * isValidAttribute
2310
- *
2311
- * @param {string} tag Tag name of containing element.
2312
- * @param {string} attr Attribute name.
2313
- * @param {string} value Attribute value.
2314
- * @return {Boolean} Returns true if `value` is valid. Otherwise, returns false.
2315
- */
2316
-
2317
-
2318
- DOMPurify.isValidAttribute = function (tag, attr, value) {
2319
- /* Initialize shared config vars if necessary. */
2320
- if (!CONFIG) {
2321
- _parseConfig({});
2322
- }
2323
-
2324
- const lcTag = transformCaseFunc(tag);
2325
- const lcName = transformCaseFunc(attr);
2326
- return _isValidAttribute(lcTag, lcName, value);
2327
- };
2328
- /**
2329
- * AddHook
2330
- * Public method to add DOMPurify hooks
2331
- *
2332
- * @param {String} entryPoint entry point for the hook to add
2333
- * @param {Function} hookFunction function to execute
2334
- */
2335
-
2336
-
2337
- DOMPurify.addHook = function (entryPoint, hookFunction) {
2338
- if (typeof hookFunction !== 'function') {
2339
- return;
2340
- }
2341
-
2342
- hooks[entryPoint] = hooks[entryPoint] || [];
2343
- arrayPush(hooks[entryPoint], hookFunction);
2344
- };
2345
- /**
2346
- * RemoveHook
2347
- * Public method to remove a DOMPurify hook at a given entryPoint
2348
- * (pops it from the stack of hooks if more are present)
2349
- *
2350
- * @param {String} entryPoint entry point for the hook to remove
2351
- * @return {Function} removed(popped) hook
2352
- */
2353
-
2354
-
2355
- DOMPurify.removeHook = function (entryPoint) {
2356
- if (hooks[entryPoint]) {
2357
- return arrayPop(hooks[entryPoint]);
2358
- }
2359
- };
2360
- /**
2361
- * RemoveHooks
2362
- * Public method to remove all DOMPurify hooks at a given entryPoint
2363
- *
2364
- * @param {String} entryPoint entry point for the hooks to remove
2365
- */
2366
-
2367
-
2368
- DOMPurify.removeHooks = function (entryPoint) {
2369
- if (hooks[entryPoint]) {
2370
- hooks[entryPoint] = [];
2371
- }
2372
- };
2373
- /**
2374
- * RemoveAllHooks
2375
- * Public method to remove all DOMPurify hooks
2376
- *
2377
- */
2378
-
2379
-
2380
- DOMPurify.removeAllHooks = function () {
2381
- hooks = {};
2382
- };
2383
-
2384
- return DOMPurify;
2385
- }
2386
-
2387
- var purify = createDOMPurify();
2388
-
2389
- var sanitizer = function sanitizer(array) {
2390
- return purify.sanitize(array, {
2391
- USE_PROFILES: {
2392
- html: true
2393
- }
2394
- });
2395
- };
2396
- var cacheStore = new Map();
2397
- var fetchCachedOrInvoke = function fetchCachedOrInvoke(func, lng, options) {
2398
- var _cacheStore$get;
2399
- var cache = (_cacheStore$get = cacheStore.get(lng)) === null || _cacheStore$get === void 0 ? void 0 : _cacheStore$get.get(options);
2400
- if (cache) return cache;
2401
- cache = func(lng, options);
2402
- var lngCache = cacheStore.get(lng);
2403
- if (lngCache) lngCache.set(options, cache);else cacheStore.set(lng, new Map([[options, cache]]));
2404
- return cache;
2405
- };
2406
- var lowerCaseDynamicTextFormatter = function lowerCaseDynamicTextFormatter(value, format) {
2407
- if (!value || format === ANY_CASE || typeof value !== "string") return value;
2408
- return LOWERCASED + value.toLocaleLowerCase();
2409
- };
2410
- var boldListFormatter = function boldListFormatter(array, lng, options) {
2411
- var formatter = fetchCachedOrInvoke(function (lng, options) {
2412
- return new Intl.ListFormat(lng, options);
2413
- }, lng, options);
2414
- var boldItems = array.map(function (item) {
2415
- return "<strong>".concat(item, "</strong>");
2416
- });
2417
- var sanitizedItems = sanitizer(boldItems).split(",");
2418
- return formatter.format(sanitizedItems);
2419
- };
2420
-
2421
- var sentenceCase = function sentenceCase(value) {
2422
- return value.charAt(0).toLocaleUpperCase() + value.slice(1);
2423
- };
2424
- var sentenceCaseProcessor = {
2425
- type: "postProcessor",
2426
- name: "sentenceCaseProcessor",
2427
- process: function process(value) {
2428
- var shouldSentenceCase = value.startsWith(LOWERCASED);
2429
- value = value.replaceAll(LOWERCASED, "");
2430
- return shouldSentenceCase ? sentenceCase(value) : value;
2431
- }
2432
- };
2433
-
2434
- var generic = {
2435
- error: "Something went wrong. Please try again later."
2436
- };
2437
- var authentication = {
2438
- notLoggedIn: "Could not authenticate, please login to continue!",
2439
- couldNotAuth: "Could not authenticate with the provided {{parameter}}.",
2440
- incorrectPassword: "Current password is incorrect. Please try again.",
2441
- incorrectEmailPassword: "Incorrect email or password. Please try again."
2442
- };
2443
- var authorization = {
2444
- unauthorized: "You are not authorized to perform this action."
2445
- };
2446
- var resource = {
2447
- add_one: "{{entity}} has been added successfully.",
2448
- add_other: "{{entity}} have been added successfully.",
2449
- save: "{{entity}} has been saved successfully.",
2450
- save_one: "{{entity}} has been saved successfully.",
2451
- save_other: "{{entity}} have been saved successfully.",
2452
- update: "{{entity}} has been updated successfully.",
2453
- update_one: "{{entity}} has been updated successfully.",
2454
- update_other: "{{entity}} have been updated successfully.",
2455
- delete_one: "{{entity}} has been deleted successfully.",
2456
- delete_other: "{{entity}} have been deleted successfully.",
2457
- clone: "{{entity}} has been cloned successfully.",
2458
- notFound: "{{entity}} does not exist.",
2459
- remove_one: "{{entity}} has been removed successfully.",
2460
- remove_other: "{{entity}} have been removed successfully.",
2461
- sent: "{{entity}} sent successfully.",
2462
- merged: "{{entity}} have been successfully merged.",
2463
- disconnected: "{{entity}} has been successfully disconnected."
2464
- };
2465
- var otp = {
2466
- sent: "OTP has been sent successfully.",
2467
- invalid: "Invalid OTP",
2468
- verified: "OTP has been verified successfully."
2469
- };
2470
- var upload = {
2471
- error: "An error occurred while uploading the file"
2472
- };
2473
- var image = {
2474
- profile: {
2475
- removalFailed: "Failed to remove profile picture",
2476
- removalSuccess: "Profile picture successfully removed"
2477
- },
2478
- contentTypeInvalid: "Other than jpg, png, svg are not supported",
2479
- sizeOutOfRange: "Should not be more than {{maxSize, number}} MB"
2480
- };
2481
- var userRole = {
2482
- deactivateActiveAdmin: "You cannot deactivate active admin from the organization!"
2483
- };
2484
- var activeRecord = {
2485
- error: {
2486
- blankName: "Name can't be blank",
2487
- blankDescription: "Description can't be blank",
2488
- blankValue: "Value can't be blank",
2489
- prefixType: "Prefix type {{value}} is not valid",
2490
- minimumEntryLimit: "Minimum entry limit must be less than or equal to {{maximumEntryLimit, number}}",
2491
- maximumEntryLimit: "Maximum entry limit must be greater than or equal to {{minimumEntryLimit, number}}"
2492
- }
2493
- };
2494
- var sessions = {
2495
- expiry: "Your session has expired. Please login again."
2496
- };
2497
- var payment = {
2498
- error: {
2499
- incomplete: "Your payment could not be completed"
2500
- }
2501
- };
2502
- var invitations = {
2503
- deleted_one: "Invitation has been deleted successfully",
2504
- deleted_other: "{{count, number}} Invitations have been deleted successfully",
2505
- sent_one: "Invitation has been sent successfully",
2506
- sent_other: "{{count, number}} Invitations have been sent successfully",
2507
- notFound: "{{email}} was not invited to test this website."
2508
- };
2509
- var github = {
2510
- error: {
2511
- webhookPermissionDenied: "Permission denied. Ensure you have permission to create webhooks for the repository.",
2512
- primaryNonDeletable: "Primary Github account cannot be deleted."
2513
- }
2514
- };
2515
- var neetoCommons = {
2516
- fallbackComponent: {
2517
- somethingWentWrong: "Sorry, something went wrong.",
2518
- description: "Please try <reloading>reloading</reloading> the page.<br> If the problem persists, <contactus>contact us</contactus>."
2519
- },
2520
- toastr: {
2521
- success: {
2522
- copiedToClipboard: "Copied to clipboard!"
2523
- },
2524
- error: {
2525
- networkError: "No Internet Connection"
2526
- }
2527
- },
2528
- notice: {
2529
- errorOccurred: "Some error occurred."
2530
- }
2531
- };
2532
- var commonsEn = {
2533
- generic: generic,
2534
- authentication: authentication,
2535
- authorization: authorization,
2536
- resource: resource,
2537
- otp: otp,
2538
- upload: upload,
2539
- image: image,
2540
- userRole: userRole,
2541
- activeRecord: activeRecord,
2542
- sessions: sessions,
2543
- payment: payment,
2544
- invitations: invitations,
2545
- github: github,
2546
- neetoCommons: neetoCommons
2547
- };
2548
-
2549
- // eslint-disable-next-line import/no-mutable-exports
2550
- exports.taxonomies = {};
2551
- var initializeI18n = function initializeI18n(hostTranslations) {
2552
- var _window$globalProps;
2553
- var packageTranslations = preval.require("./configs/scripts/getPkgTranslations.js");
2554
- var commonsTranslations = {
2555
- en: {
2556
- translation: commonsEn
2557
- }
2558
- };
2559
- var resources = [hostTranslations, commonsTranslations, packageTranslations].reduce(ramda.mergeDeepLeft);
2560
- var defaultTaxonomyKeys = Object.keys(resources.en.translation.taxonomyDefaultLabels || {});
2561
- var defaultTaxonomies = Object.fromEntries(defaultTaxonomyKeys.map(function (key) {
2562
- return [key, {
2563
- singular: null,
2564
- plural: null
2565
- }];
2566
- }));
2567
- var hostTaxonomies = ((_window$globalProps = window.globalProps) === null || _window$globalProps === void 0 ? void 0 : _window$globalProps.taxonomies) || {};
2568
- exports.taxonomies = replaceNullValuesWithGetter(ramda.mergeDeepLeft(hostTaxonomies, defaultTaxonomies));
2569
- i18n__default["default"].use(Browser).use(reactI18next.initReactI18next).use(sentenceCaseProcessor).init({
2570
- resources: resources,
2571
- fallbackLng: "en",
2572
- interpolation: {
2573
- defaultVariables: {
2574
- taxonomies: exports.taxonomies
2575
- },
2576
- escapeValue: false,
2577
- skipOnVariables: false,
2578
- alwaysFormat: true,
2579
- format: function format(value, _format, lng, options) {
2580
- var newValue = value;
2581
- if (_format === "boldList") {
2582
- newValue = boldListFormatter(newValue, lng, options);
2583
- return newValue;
2584
- }
2585
- return lowerCaseDynamicTextFormatter(newValue, _format);
2586
- }
2587
- },
2588
- postProcess: [sentenceCaseProcessor.name],
2589
- detection: {
2590
- order: ["querystring", "cookie", "navigator", "path"],
2591
- caches: ["cookie"],
2592
- lookupQuerystring: "lang",
2593
- lookupCookie: "lang"
2594
- }
2595
- });
2596
- };
2597
-
2598
- function initializeLogger() {
2599
- /* eslint react-hooks/rules-of-hooks: "off" */
2600
- Logger__default["default"].useDefaults();
2601
- if (process.env.RAILS_ENV === "production") {
2602
- Logger__default["default"].setLevel(Logger__default["default"].OFF);
2603
- }
2604
- window.logger = Logger__default["default"];
2605
- }
2606
-
2607
- var isObjectOrFunction = function isObjectOrFunction(object) {
2608
- var type = _typeof$1(object);
2609
- return type === "function" || type === "object" && !!object;
2610
- };
2611
- function disableReactDevTools() {
2612
- if (window && window.document) {
2613
- var developerToolsHook = window.__REACT_DEVTOOLS_GLOBAL_HOOK__;
2614
- if (!isObjectOrFunction(developerToolsHook)) return;
2615
- for (var prop in developerToolsHook) {
2616
- if (prop === "renderers") {
2617
- developerToolsHook[prop] = new Map();
2618
- } else {
2619
- developerToolsHook[prop] = typeof developerToolsHook[prop] === "function" ? Function.prototype : null;
2620
- }
2621
- }
2622
- }
2623
- }
2624
-
2625
- // eslint-disable-next-line import/no-mutable-exports
2626
- exports.globalProps = {};
2627
- function initializeApplication(_ref) {
2628
- var translationResources = _ref.translationResources,
2629
- skip = _ref.skip;
2630
- if (!(skip !== null && skip !== void 0 && skip.globalProps)) {
2631
- initializeGlobalProps();
2632
- // eslint-disable-next-line @bigbinary/neeto/no-globalProps-reassignment
2633
- exports.globalProps = window.globalProps;
2634
- }
2635
- if (_typeof$1(skip === null || skip === void 0 ? void 0 : skip.axios) === "object" || !(skip !== null && skip !== void 0 && skip.axios)) {
2636
- initializeAxios(skip === null || skip === void 0 ? void 0 : skip.axios);
2637
- }
2638
- if (!(skip !== null && skip !== void 0 && skip.i18n)) initializeI18n(translationResources);
2639
- if (!(skip !== null && skip !== void 0 && skip.logger)) initializeLogger();
2640
- if (process.env.NODE_ENV === "production") disableReactDevTools();
2641
- }
2642
-
2643
- Object.defineProperty(exports, 'useDisplayErrorPage', {
2644
- enumerable: true,
2645
- get: function () { return reactUtils.useDisplayErrorPage; }
2646
- });
2647
- exports["default"] = initializeApplication;
2648
- //# sourceMappingURL=initializers.cjs.js.map