@backstage/plugin-search 1.4.10-next.1 → 1.4.11-next.0

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 (46) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/alpha/package.json +1 -1
  3. package/dist/alpha.esm.js +4 -28
  4. package/dist/alpha.esm.js.map +1 -1
  5. package/dist/apis.esm.js +34 -0
  6. package/dist/apis.esm.js.map +1 -0
  7. package/dist/components/HomePageComponent/HomePageSearchBar.esm.js +46 -0
  8. package/dist/components/HomePageComponent/HomePageSearchBar.esm.js.map +1 -0
  9. package/dist/components/HomePageComponent/index.esm.js +2 -0
  10. package/dist/components/HomePageComponent/index.esm.js.map +1 -0
  11. package/dist/{esm/useSearchModal-CaX46YAs.esm.js → components/SearchModal/SearchModal.esm.js} +5 -46
  12. package/dist/components/SearchModal/SearchModal.esm.js.map +1 -0
  13. package/dist/components/SearchModal/useSearchModal.esm.js +46 -0
  14. package/dist/components/SearchModal/useSearchModal.esm.js.map +1 -0
  15. package/dist/components/SearchPage/SearchPage.esm.js +59 -0
  16. package/dist/components/SearchPage/SearchPage.esm.js.map +1 -0
  17. package/dist/components/SearchPage/index.esm.js +2 -0
  18. package/dist/components/SearchPage/index.esm.js.map +1 -0
  19. package/dist/components/SearchType/SearchType.Accordion.esm.js +155 -0
  20. package/dist/components/SearchType/SearchType.Accordion.esm.js.map +1 -0
  21. package/dist/components/SearchType/SearchType.Tabs.esm.js +61 -0
  22. package/dist/components/SearchType/SearchType.Tabs.esm.js.map +1 -0
  23. package/dist/components/SearchType/SearchType.esm.js +84 -0
  24. package/dist/components/SearchType/SearchType.esm.js.map +1 -0
  25. package/dist/components/SidebarSearch/SidebarSearch.esm.js +31 -0
  26. package/dist/components/SidebarSearch/SidebarSearch.esm.js.map +1 -0
  27. package/dist/components/SidebarSearchModal/SidebarSearchModal.esm.js +32 -0
  28. package/dist/components/SidebarSearchModal/SidebarSearchModal.esm.js.map +1 -0
  29. package/dist/components/SidebarSearchModal/index.esm.js +2 -0
  30. package/dist/components/SidebarSearchModal/index.esm.js.map +1 -0
  31. package/dist/components/util.esm.js +20 -0
  32. package/dist/components/util.esm.js.map +1 -0
  33. package/dist/index.esm.js +6 -71
  34. package/dist/index.esm.js.map +1 -1
  35. package/dist/plugin.esm.js +50 -0
  36. package/dist/plugin.esm.js.map +1 -0
  37. package/package.json +14 -14
  38. package/dist/esm/SearchType-BDK6qMj4.esm.js +0 -413
  39. package/dist/esm/SearchType-BDK6qMj4.esm.js.map +0 -1
  40. package/dist/esm/index-4C-7QFYg.esm.js +0 -74
  41. package/dist/esm/index-4C-7QFYg.esm.js.map +0 -1
  42. package/dist/esm/index-By276Am7.esm.js +0 -86
  43. package/dist/esm/index-By276Am7.esm.js.map +0 -1
  44. package/dist/esm/index-LeUeJAxm.esm.js +0 -33
  45. package/dist/esm/index-LeUeJAxm.esm.js.map +0 -1
  46. package/dist/esm/useSearchModal-CaX46YAs.esm.js.map +0 -1
@@ -1,86 +0,0 @@
1
- import React, { useCallback, useState, useRef } from 'react';
2
- import { makeStyles } from '@material-ui/core/styles';
3
- import { SearchBarBase } from '@backstage/plugin-search-react';
4
- import qs from 'qs';
5
- import { useNavigate } from 'react-router-dom';
6
- import { r as rootRouteRef } from './SearchType-BDK6qMj4.esm.js';
7
- import { useRouteRef } from '@backstage/core-plugin-api';
8
- import '@backstage/errors';
9
- import 'react-use/esm/usePrevious';
10
- import '@material-ui/core/Checkbox';
11
- import '@material-ui/core/Chip';
12
- import '@material-ui/core/FormControl';
13
- import '@material-ui/core/InputLabel';
14
- import '@material-ui/core/ListItemText';
15
- import '@material-ui/core/MenuItem';
16
- import '@material-ui/core/Select';
17
- import 'react-use/esm/useEffectOnce';
18
- import '@material-ui/core/Accordion';
19
- import '@material-ui/core/AccordionSummary';
20
- import '@material-ui/core/AccordionDetails';
21
- import '@material-ui/core/Card';
22
- import '@material-ui/core/CardContent';
23
- import '@material-ui/core/CardHeader';
24
- import '@material-ui/core/Divider';
25
- import '@material-ui/core/List';
26
- import '@material-ui/core/ListItem';
27
- import '@material-ui/core/ListItemIcon';
28
- import '@material-ui/icons/ExpandMore';
29
- import '@material-ui/icons/FontDownload';
30
- import 'react-use/esm/useAsync';
31
- import '@material-ui/core/Tab';
32
- import '@material-ui/core/Tabs';
33
-
34
- const useNavigateToQuery = () => {
35
- const searchRoute = useRouteRef(rootRouteRef);
36
- const navigate = useNavigate();
37
- return useCallback(
38
- ({ query }) => {
39
- const queryString = qs.stringify({ query }, { addQueryPrefix: true });
40
- navigate(`${searchRoute()}${queryString}`);
41
- },
42
- [navigate, searchRoute]
43
- );
44
- };
45
-
46
- const useStyles = makeStyles({
47
- searchBarRoot: {
48
- fontSize: "1.5em"
49
- },
50
- searchBarOutline: {
51
- border: "1px solid #555",
52
- borderRadius: "6px"
53
- }
54
- });
55
- const HomePageSearchBar = (props) => {
56
- var _a;
57
- const classes = useStyles(props);
58
- const [query, setQuery] = useState("");
59
- const ref = useRef(null);
60
- const handleSearch = useNavigateToQuery();
61
- const handleSubmit = useCallback(() => {
62
- var _a2, _b;
63
- handleSearch({ query: (_b = (_a2 = ref.current) == null ? void 0 : _a2.value) != null ? _b : "" });
64
- }, [handleSearch]);
65
- return /* @__PURE__ */ React.createElement(
66
- SearchBarBase,
67
- {
68
- value: query,
69
- onSubmit: handleSubmit,
70
- onChange: setQuery,
71
- inputProps: { ref },
72
- InputProps: {
73
- ...props.InputProps,
74
- classes: {
75
- root: classes.searchBarRoot,
76
- notchedOutline: classes.searchBarOutline,
77
- ...(_a = props.InputProps) == null ? void 0 : _a.classes
78
- }
79
- },
80
- ...props
81
- }
82
- );
83
- };
84
-
85
- export { HomePageSearchBar };
86
- //# sourceMappingURL=index-By276Am7.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-By276Am7.esm.js","sources":["../../src/components/util.ts","../../src/components/HomePageComponent/HomePageSearchBar.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport qs from 'qs';\nimport { useCallback } from 'react';\nimport { useNavigate } from 'react-router-dom';\nimport { rootRouteRef } from '../plugin';\n\nimport { useRouteRef } from '@backstage/core-plugin-api';\n\nexport const useNavigateToQuery = () => {\n const searchRoute = useRouteRef(rootRouteRef);\n const navigate = useNavigate();\n return useCallback(\n ({ query }: { query: string }): void => {\n const queryString = qs.stringify({ query }, { addQueryPrefix: true });\n\n navigate(`${searchRoute()}${queryString}`);\n },\n [navigate, searchRoute],\n );\n};\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useCallback, useRef, useState } from 'react';\nimport { makeStyles } from '@material-ui/core/styles';\nimport {\n SearchBarBase,\n SearchBarBaseProps,\n} from '@backstage/plugin-search-react';\nimport { useNavigateToQuery } from '../util';\n\nconst useStyles = makeStyles({\n searchBarRoot: {\n fontSize: '1.5em',\n },\n searchBarOutline: {\n border: '1px solid #555',\n borderRadius: '6px',\n },\n});\n\n/**\n * Props for {@link HomePageSearchBar}.\n *\n * @public\n */\nexport type HomePageSearchBarProps = Partial<\n Omit<SearchBarBaseProps, 'onChange' | 'onSubmit'>\n>;\n\n/**\n * The search bar created specifically for the composable home page.\n */\nexport const HomePageSearchBar = (props: HomePageSearchBarProps) => {\n const classes = useStyles(props);\n const [query, setQuery] = useState('');\n const ref = useRef<HTMLInputElement | null>(null);\n\n const handleSearch = useNavigateToQuery();\n\n // This handler is called when \"enter\" is pressed\n const handleSubmit = useCallback(() => {\n // Using ref to get the current field value without waiting for a query debounce\n handleSearch({ query: ref.current?.value ?? '' });\n }, [handleSearch]);\n\n return (\n <SearchBarBase\n value={query}\n onSubmit={handleSubmit}\n onChange={setQuery}\n inputProps={{ ref }}\n InputProps={{\n ...props.InputProps,\n classes: {\n root: classes.searchBarRoot,\n notchedOutline: classes.searchBarOutline,\n ...props.InputProps?.classes,\n },\n }}\n {...props}\n />\n );\n};\n"],"names":["_a"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBO,MAAM,qBAAqB,MAAM;AACtC,EAAM,MAAA,WAAA,GAAc,YAAY,YAAY,CAAA,CAAA;AAC5C,EAAA,MAAM,WAAW,WAAY,EAAA,CAAA;AAC7B,EAAO,OAAA,WAAA;AAAA,IACL,CAAC,EAAE,KAAA,EAAqC,KAAA;AACtC,MAAM,MAAA,WAAA,GAAc,GAAG,SAAU,CAAA,EAAE,OAAS,EAAA,EAAE,cAAgB,EAAA,IAAA,EAAM,CAAA,CAAA;AAEpE,MAAA,QAAA,CAAS,CAAG,EAAA,WAAA,EAAa,CAAA,EAAG,WAAW,CAAE,CAAA,CAAA,CAAA;AAAA,KAC3C;AAAA,IACA,CAAC,UAAU,WAAW,CAAA;AAAA,GACxB,CAAA;AACF,CAAA;;ACTA,MAAM,YAAY,UAAW,CAAA;AAAA,EAC3B,aAAe,EAAA;AAAA,IACb,QAAU,EAAA,OAAA;AAAA,GACZ;AAAA,EACA,gBAAkB,EAAA;AAAA,IAChB,MAAQ,EAAA,gBAAA;AAAA,IACR,YAAc,EAAA,KAAA;AAAA,GAChB;AACF,CAAC,CAAA,CAAA;AAcY,MAAA,iBAAA,GAAoB,CAAC,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j4.esm.js';
2
- import '@backstage/errors';
3
- import 'qs';
4
- import '@backstage/plugin-search-react';
5
- import '@backstage/core-plugin-api';
6
- import 'react';
7
- import 'react-use/esm/usePrevious';
8
- import 'react-router-dom';
9
- import '@material-ui/core/Checkbox';
10
- import '@material-ui/core/Chip';
11
- import '@material-ui/core/FormControl';
12
- import '@material-ui/core/InputLabel';
13
- import '@material-ui/core/ListItemText';
14
- import '@material-ui/core/MenuItem';
15
- import '@material-ui/core/Select';
16
- import '@material-ui/core/styles';
17
- import 'react-use/esm/useEffectOnce';
18
- import '@material-ui/core/Accordion';
19
- import '@material-ui/core/AccordionSummary';
20
- import '@material-ui/core/AccordionDetails';
21
- import '@material-ui/core/Card';
22
- import '@material-ui/core/CardContent';
23
- import '@material-ui/core/CardHeader';
24
- import '@material-ui/core/Divider';
25
- import '@material-ui/core/List';
26
- import '@material-ui/core/ListItem';
27
- import '@material-ui/core/ListItemIcon';
28
- import '@material-ui/icons/ExpandMore';
29
- import '@material-ui/icons/FontDownload';
30
- import 'react-use/esm/useAsync';
31
- import '@material-ui/core/Tab';
32
- import '@material-ui/core/Tabs';
33
- //# sourceMappingURL=index-LeUeJAxm.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-LeUeJAxm.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"useSearchModal-CaX46YAs.esm.js","sources":["../../src/components/SearchModal/SearchModal.tsx","../../src/components/SearchModal/useSearchModal.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useContent } from '@backstage/core-components';\nimport { useRouteRef } from '@backstage/core-plugin-api';\nimport {\n SearchBar,\n SearchContextProvider,\n SearchResult,\n SearchResultPager,\n} from '@backstage/plugin-search-react';\nimport Dialog from '@material-ui/core/Dialog';\nimport DialogActions from '@material-ui/core/DialogActions';\nimport DialogContent from '@material-ui/core/DialogContent';\nimport DialogTitle from '@material-ui/core/DialogTitle';\nimport Divider from '@material-ui/core/Divider';\nimport Grid from '@material-ui/core/Grid';\nimport { useTheme } from '@material-ui/core/styles';\nimport Box from '@material-ui/core/Box';\nimport Button from '@material-ui/core/Button';\nimport IconButton from '@material-ui/core/IconButton';\nimport { makeStyles } from '@material-ui/core/styles';\nimport ArrowForwardIcon from '@material-ui/icons/ArrowForward';\nimport CloseIcon from '@material-ui/icons/Close';\nimport React, { useCallback, useEffect, useRef } from 'react';\nimport { useNavigate } from 'react-router-dom';\n\nimport { rootRouteRef } from '../../plugin';\n\n/**\n * @public\n */\nexport interface SearchModalChildrenProps {\n /**\n * A function that should be invoked when navigating away from the modal.\n */\n toggleModal: () => void;\n}\n\n/**\n * @public\n */\nexport interface SearchModalProps {\n /**\n * If true, it renders the modal.\n */\n open?: boolean;\n /**\n * This is supposed to be used together with the open prop.\n * If `hidden` is true, it hides the modal.\n * If `open` is false, the value of `hidden` has no effect on the modal.\n * Use `open` for controlling whether the modal should be rendered or not.\n */\n hidden?: boolean;\n /**\n * a function invoked when a search item is pressed or when the dialog\n * should be closed.\n */\n toggleModal: () => void;\n /**\n * A function that returns custom content to render in the search modal in\n * place of the default.\n */\n children?: (props: SearchModalChildrenProps) => JSX.Element;\n}\n\nconst useStyles = makeStyles(theme => ({\n dialogTitle: {\n gap: theme.spacing(1),\n display: 'grid',\n alignItems: 'center',\n gridTemplateColumns: '1fr auto',\n '&> button': {\n marginTop: theme.spacing(1),\n },\n },\n input: {\n flex: 1,\n },\n button: {\n '&:hover': {\n background: 'none',\n },\n },\n // Reduces default height of the modal, keeping a gap of 128px between the top and bottom of the page.\n paperFullWidth: { height: 'calc(100% - 128px)' },\n dialogActionsContainer: { padding: theme.spacing(1, 3) },\n viewResultsLink: { verticalAlign: '0.5em' },\n}));\n\nexport const Modal = ({ toggleModal }: SearchModalChildrenProps) => {\n const classes = useStyles();\n const navigate = useNavigate();\n const { transitions } = useTheme();\n const { focusContent } = useContent();\n\n const searchRootRoute = useRouteRef(rootRouteRef)();\n const searchBarRef = useRef<HTMLInputElement | null>(null);\n\n useEffect(() => {\n searchBarRef?.current?.focus();\n });\n\n const handleSearchResultClick = useCallback(() => {\n setTimeout(focusContent, transitions.duration.leavingScreen);\n }, [focusContent, transitions]);\n\n // This handler is called when \"enter\" is pressed\n const handleSearchBarSubmit = useCallback(() => {\n // Using ref to get the current field value without waiting for a query debounce\n const query = searchBarRef.current?.value ?? '';\n navigate(`${searchRootRoute}?query=${query}`);\n handleSearchResultClick();\n }, [navigate, handleSearchResultClick, searchRootRoute]);\n\n return (\n <>\n <DialogTitle>\n <Box className={classes.dialogTitle}>\n <SearchBar\n className={classes.input}\n inputProps={{ ref: searchBarRef }}\n onSubmit={handleSearchBarSubmit}\n />\n\n <IconButton aria-label=\"close\" onClick={toggleModal}>\n <CloseIcon />\n </IconButton>\n </Box>\n </DialogTitle>\n <DialogContent>\n <Grid\n container\n direction=\"row-reverse\"\n justifyContent=\"flex-start\"\n alignItems=\"center\"\n >\n <Grid item>\n <Button\n className={classes.button}\n color=\"primary\"\n endIcon={<ArrowForwardIcon />}\n onClick={handleSearchBarSubmit}\n disableRipple\n >\n View Full Results\n </Button>\n </Grid>\n </Grid>\n <Divider />\n <SearchResult\n onClick={handleSearchResultClick}\n onKeyDown={handleSearchResultClick}\n />\n </DialogContent>\n <DialogActions className={classes.dialogActionsContainer}>\n <Grid container direction=\"row\">\n <Grid item xs={12}>\n <SearchResultPager />\n </Grid>\n </Grid>\n </DialogActions>\n </>\n );\n};\n\n/**\n * @public\n */\nexport const SearchModal = (props: SearchModalProps) => {\n const { open = true, hidden, toggleModal, children } = props;\n\n const classes = useStyles();\n\n return (\n <Dialog\n classes={{\n paperFullWidth: classes.paperFullWidth,\n }}\n onClose={toggleModal}\n aria-labelledby=\"search-modal-title\"\n fullWidth\n maxWidth=\"lg\"\n open={open}\n hidden={hidden}\n >\n {open && (\n <SearchContextProvider inheritParentContextIfAvailable>\n {(children && children({ toggleModal })) ?? (\n <Modal toggleModal={toggleModal} />\n )}\n </SearchContextProvider>\n )}\n </Dialog>\n );\n};\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { ReactNode, useCallback, useContext, useState } from 'react';\nimport { useLocation } from 'react-router-dom';\nimport {\n createVersionedContext,\n createVersionedValueMap,\n} from '@backstage/version-bridge';\nimport useUpdateEffect from 'react-use/esm/useUpdateEffect';\n\n/**\n * The state of the search modal, as well as functions for changing the modal's\n * visibility.\n *\n * @public\n */\nexport type SearchModalValue = {\n state: {\n hidden: boolean;\n open: boolean;\n };\n toggleModal: () => void;\n setOpen: (open: boolean) => void;\n};\n\nconst SearchModalContext = createVersionedContext<{\n 1: SearchModalValue | undefined;\n}>('search-modal-context');\n\n/**\n * Props for the SearchModalProvider.\n * @public\n */\nexport type SearchModalProviderProps = {\n /**\n * Children which should have access to the SearchModal context and the\n * associated useSearchModal() hook.\n */\n children: ReactNode;\n\n /**\n * Pass true if the modal should be rendered initially.\n */\n showInitially?: boolean;\n};\n\n/**\n * A context provider responsible for storing and managing state related to the\n * search modal.\n *\n * @remarks\n * If you need to control visibility of the search toggle outside of the modal\n * itself, you can optionally place this higher up in the react tree where your\n * custom code and the search modal share the same context.\n *\n * @example\n * ```tsx\n * import {\n * SearchModalProvider,\n * SidebarSearchModal,\n * } from '@backstage/plugin-search';\n *\n * // ...\n *\n * <SearchModalProvider>\n * <KeyboardShortcutSearchToggler />\n * <SidebarSearchModal>\n * {({ toggleModal }) => <SearchModal toggleModal={toggleModal} />}\n * </SidebarSearchModal>\n * </SearchModalProvider>\n * ```\n *\n * @public\n */\nexport const SearchModalProvider = (props: SearchModalProviderProps) => {\n const value = useSearchModal(props.showInitially);\n const versionedValue = createVersionedValueMap({ 1: value });\n return (\n <SearchModalContext.Provider value={versionedValue}>\n {props.children}\n </SearchModalContext.Provider>\n );\n};\n\n/**\n * Use this hook to manage the state of {@link SearchModal}\n * and change its visibility. Monitors route changes setting the hidden state\n * to avoid having to call toggleModal on every result click.\n *\n * @public\n *\n * @param initialState - pass `true` to make the modal initially visible\n * @returns an object containing the state of the modal together with\n * functions for changing the visibility of the modal.\n */\nexport function useSearchModal(initialState = false) {\n const [state, setState] = useState({\n hidden: !initialState,\n open: initialState,\n });\n\n const toggleModal = useCallback(\n () =>\n setState(prevState => ({\n open: true,\n hidden: !prevState.hidden,\n })),\n [],\n );\n\n const setOpen = useCallback(\n (open: boolean) =>\n setState(prevState => ({\n open: prevState.open || open,\n hidden: !open,\n })),\n [],\n );\n\n // Check for any existing parent context.\n const parentContext = useContext(SearchModalContext);\n const parentContextValue = parentContext?.atVersion(1);\n const isParentContextPresent = !!parentContextValue?.state;\n\n // Monitor route changes to automatically hide the modal.\n const location = useLocation();\n const locationKey = `${location.pathname}${location.search}${location.hash}`;\n useUpdateEffect(() => {\n setState(prevState => ({\n open: prevState.open,\n hidden: true,\n }));\n }, [locationKey]);\n\n // Inherit from parent context, if set.\n return isParentContextPresent\n ? parentContextValue\n : { state, toggleModal, setOpen };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AA8EA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,M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