// Metro module 1822 (f1823).
import Module19, { useEffect, useMemo, useState } from "react";
import { View, StyleSheet } from "react-native";
import * as _Module1823 from "./Module1823";
import * as _Module1824 from "./Module1824";
import { KEYBOARD_HAS_ROUNDED_CORNERS, KEYBOARD_TOOLBAR_HEIGHT, OPENED_OFFSET, TEST_ID_KEYBOARD_TOOLBAR } from "./Module1824";
import { useKeyboardState } from "./useResizeMode";
import _default from "./_default_1825";
import _default2 from "./_default_1826";
import { FocusedInputEvents, RCTKeyboardToolbarGroupView } from "./Module1596";
import * as _Module1827 from "./Module1827";
import { Background, Content, Prev, Next } from "./Module1827";
import { ToolbarContext } from "./Module1831";
import Module1815 from "./Module1815";
let styles;
const _excluded = ["children", "content", "theme", "doneText", "button", "icon", "showArrows", "onNextCallback", "onPrevCallback", "onDoneCallback", "blur", "opacity", "offset", "enabled", "insets"];
const KeyboardToolbar = (props) => {
let r84, r106, r111;
const { children: children2, content, theme = _Module1823.colors } = props;
let isPrevDisabled, isNextDisabled, c13248_9, c13248_10, children, c13248_12, c13248_13;
const colors = theme;
const doneText = props.doneText;
const text = doneText !== void 0 ? doneText : "Done";
let button = props.button;
let icon = props.icon;
const { showArrows = true, onNextCallback, onPrevCallback, onDoneCallback, blur } = props;
let r18 = blur !== void 0 ? blur : null;
let opacity = props.opacity;
if (opacity === void 0) {
opacity = _Module1824.DEFAULT_OPACITY;
}
const DEFAULT_OPACITY = opacity;
let offset = props.offset;
if (offset === void 0) {
offset = {};
}
const { closed = 0, opened = 0 } = offset;
const { enabled: enabled2 = true, insets, ...rest } = props;
const keyboardState = useKeyboardState((a0) => a0.appearance);
const [state, setState] = useState({
current: 0,
count: 0
});
isPrevDisabled = state.current === 0;
isNextDisabled = state.current === state.count - 1;
if (button == null) {
button = _default;
}
if (icon == null) {
icon = _default2;
}
useEffect(() => FocusedInputEvents.addListener("focusDidSet", (a0) => {
setState(a0);
}).remove, []);
const memo = useMemo(() => [styles.toolbar, {
backgroundColor: `${colors[keyboardState].background}${DEFAULT_OPACITY}`
}, KEYBOARD_HAS_ROUNDED_CORNERS ? null : {
paddingLeft: insets?.left,
paddingRight: insets?.right
}, KEYBOARD_HAS_ROUNDED_CORNERS ? styles.floating : null], [keyboardState, DEFAULT_OPACITY, colors, insets]);
const memo2 = useMemo(() => {
const r10 = [styles.sticky, ,];
let r16 = null;
if (KEYBOARD_HAS_ROUNDED_CORNERS) {
let r8 = insets?.left;
if (r8 == null) {
r8 = 0;
}
let r21 = insets?.right;
if (r21 == null) {
r21 = 0;
}
r16 = {
left: r8 + 16,
right: r21 + 16
};
}
r10[1] = r16;
return r10;
}, [insets]);
const memo3 = useMemo(() => ({
closed: closed + KEYBOARD_TOOLBAR_HEIGHT,
opened: opened + OPENED_OFFSET
}), [closed, opened]);
if (children2) {
c13248_9 = null;
c13248_10 = null;
children = null;
c13248_12 = null;
c13248_13 = null;
Module19.Children.forEach(children2, (a0) => {
if (Module19.isValidElement(a0)) {
const type = a0.type;
if (type === Background) {
c13248_13 = a0;
} else if (type === Content) {
children = a0;
} else if (type === Prev) {
c13248_9 = a0;
} else if (type === Next) {
c13248_10 = a0;
} else if (type === _Module1827.Done) {
c13248_12 = a0;
}
}
});
const r117 = c13248_13;
const r118 = c13248_12;
const r121 = c13248_9 ?
{c13248_9}
{c13248_10}
: c13248_10 ?
{c13248_9}
{c13248_10}
: null;
let r130 = children;
if (r130 == null) {
r130 = {children};
}
r111 = r130;
r106 = r118;
r84 = r121;
r18 = r117;
} else {
r84 = showArrows ?
: null;
const r105 = {content};
r106 = text ? <_Module1827.Done button={button} text={text} onPress={onDoneCallback} /> : null;
r111 = r105;
}
return ({
theme: colors,
isPrevDisabled,
isNextDisabled
}), [colors, isPrevDisabled, isNextDisabled])}>
{r18}
{r84}
{r111}
{r106}
;
};
styles = StyleSheet.create({
sticky: {
position: "absolute",
left: 0,
right: 0,
bottom: 0,
height: KEYBOARD_TOOLBAR_HEIGHT
},
toolbar: {
position: "absolute",
bottom: 0,
alignItems: "center",
width: "100%",
flexDirection: "row",
height: KEYBOARD_TOOLBAR_HEIGHT
},
arrows: {
flexDirection: "row",
paddingLeft: 8
},
floating: {
alignSelf: "center",
borderRadius: 20,
overflow: "hidden"
}
});
KeyboardToolbar.Background = Background;
KeyboardToolbar.Content = Content;
KeyboardToolbar.Prev = Prev;
KeyboardToolbar.Next = Next;
KeyboardToolbar.Done = _Module1827.Done;
KeyboardToolbar.Group = RCTKeyboardToolbarGroupView;
export default KeyboardToolbar;
export const DefaultKeyboardToolbarTheme = _Module1823.colors;