import "./SearchField.css";
import {centerBaseline as $1f4b04be3f24aae3$export$9d7e2342a7e53afa} from "./CenterBaseline.mjs";
import {ClearButton as $f6a62e6e68437458$export$13ec83e50bf04290} from "./ClearButton.mjs";
import {createFocusableRef as $80ecb974df713a30$export$79d69eee6ae4b329} from "./useDOMRef.mjs";
import {FieldGroup as $9afd80978c252040$export$f0fe469072bc6950, FieldLabel as $9afd80978c252040$export$1acdcf5a973a8414, HelpText as $9afd80978c252040$export$a67c0bc59081311a, Input as $9afd80978c252040$export$f5b8910cec6cf069} from "./Field.mjs";
import {FormContext as $9b916426527cebe7$export$c24727297075ec6a, useFormProps as $9b916426527cebe7$export$a6b5be5c6b451665} from "./Form.mjs";
import {IconContext as $ac8c32e6775ddd1f$export$a49f528ae1a4d0ed} from "../../icons/Icon.mjs";
import $279039872474ccc7$export$2e2bcd8739ae039 from "../../icons/Search.mjs";
import {useSpectrumContextProps as $5ce63c423902f47d$export$764f6146fadd77f7} from "../../icons/useSpectrumContextProps.mjs";
import {jsx as $iu0JR$jsx, jsxs as $iu0JR$jsxs, Fragment as $iu0JR$Fragment} from "react/jsx-runtime";
import {SearchField as $iu0JR$SearchField} from "react-aria-components/SearchField";
import {Provider as $iu0JR$Provider} from "react-aria-components/slots";
import {createContext as $iu0JR$createContext, forwardRef as $iu0JR$forwardRef, useContext as $iu0JR$useContext, useRef as $iu0JR$useRef, useImperativeHandle as $iu0JR$useImperativeHandle} from "react";

/*
 * Copyright 2024 Adobe. All rights reserved.
 * This file is licensed to you under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License. You may obtain a copy
 * of the License at http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under
 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
 * OF ANY KIND, either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 */ 











const $e3d0f3db0eb61b92$export$d1c4e4c63cb03a11 = /*#__PURE__*/ (0, $iu0JR$createContext)(null);
const $e3d0f3db0eb61b92$export$b94867ecbd698f21 = /*#__PURE__*/ (0, $iu0JR$forwardRef)(function SearchField(props, ref) {
    [props, ref] = (0, $5ce63c423902f47d$export$764f6146fadd77f7)(props, ref, $e3d0f3db0eb61b92$export$d1c4e4c63cb03a11);
    let formContext = (0, $iu0JR$useContext)((0, $9b916426527cebe7$export$c24727297075ec6a));
    props = (0, $9b916426527cebe7$export$a6b5be5c6b451665)(props);
    let { label: label, description: description, errorMessage: errorMessage, necessityIndicator: necessityIndicator, labelPosition: labelPosition = 'top', labelAlign: labelAlign = 'start', UNSAFE_className: UNSAFE_className = '', UNSAFE_style: UNSAFE_style, ...searchFieldProps } = props;
    let domRef = (0, $iu0JR$useRef)(null);
    let inputRef = (0, $iu0JR$useRef)(null);
    // Expose imperative interface for ref
    (0, $iu0JR$useImperativeHandle)(ref, ()=>({
            ...(0, $80ecb974df713a30$export$79d69eee6ae4b329)(domRef, inputRef),
            select () {
                if (inputRef.current) inputRef.current.select();
            },
            getInputElement () {
                return inputRef.current;
            }
        }));
    return /*#__PURE__*/ (0, $iu0JR$jsx)((0, $iu0JR$SearchField), {
        ...searchFieldProps,
        ref: domRef,
        style: UNSAFE_style,
        className: UNSAFE_className + function anonymous(props, overrides) {
            let rules = " ";
            let gridColumnStart = false;
            let gridColumnEnd = false;
            let matches = String(overrides || '').matchAll(/(?:^|\s)(J|G|I|H|_u|_v|_s|__A|_d|_J|z|y|B|A|_P|_9|W|_l|_A|_z|_6|Z|N|L)[^\s]+/g);
            for (let p of matches){
                if (p[1] === "z") gridColumnStart = true;
                if (p[1] === "y") gridColumnEnd = true;
                rules += p[0];
            }
            rules += ' se12';
            if (props.isInForm) {
                if (!gridColumnStart) rules += ' z2mU12';
            }
            if (props.isInForm) {
                if (props.labelPosition === "side") {
                    if (!gridColumnEnd) rules += ' yvoofG12';
                }
            }
            if (props.isInForm) rules += ' DLwlgod12';
            else {
                if (props.labelPosition === "side") rules += ' DPlN5qb12';
                else if (props.labelPosition === "top") rules += ' DM8Mfn12';
            }
            if (props.labelPosition === "side") rules += ' EPlN5qb12';
            else if (props.labelPosition === "top") rules += ' E4w1sLc12';
            if (props.labelPosition === "side") rules += ' CbRM95c12';
            else if (props.labelPosition === "top") rules += ' Cxaocre12';
            if (props.size === "XL") {
                rules += ' -_6BNtrc-e12';
                rules += ' vx12';
            } else if (props.size === "L") {
                rules += ' -_6BNtrc-d12';
                rules += ' vx12';
            } else if (props.size === "S") {
                rules += ' -_6BNtrc-b12';
                rules += ' vx12';
            } else if (props.size === "XS") {
                rules += ' -_6BNtrc-a12';
                rules += ' vx12';
            } else {
                rules += ' -_6BNtrc-c12';
                rules += ' vx12';
            }
            rules += ' ea12';
            rules += ' _Fd12';
            rules += ' _FnuYUweb12';
            if (props.size === "XL") rules += ' -BhX7R-Fz12';
            else if (props.size === "L") rules += ' -BhX7R-Fv12';
            else if (props.size === "S") rules += ' -BhX7R-Fp12';
            else if (props.size === "XS") rules += ' -BhX7R-Fn12';
            else rules += ' -BhX7R-Fx12';
            rules += ' -AJjOLd-UVkF0Db12';
            rules += ' qg12';
            rules += ' __ca12';
            rules += ' -Qg41Lb-JAxCW0c12';
            if (props.isDisabled) {
                rules += ' pp12';
                rules += ' plc12';
            } else {
                if (props.isPressed) rules += ' po12';
                else if (props.isFocusVisible) rules += ' po12';
                else if (props.isHovered) rules += ' po12';
                else rules += ' pt12';
            }
            return rules;
        }({
            size: props.size,
            labelPosition: labelPosition,
            isInForm: !!formContext
        }, props.styles),
        children: ({ isDisabled: isDisabled, isInvalid: isInvalid, isEmpty: isEmpty })=>/*#__PURE__*/ (0, $iu0JR$jsxs)((0, $iu0JR$Fragment), {
                children: [
                    label && /*#__PURE__*/ (0, $iu0JR$jsx)((0, $9afd80978c252040$export$1acdcf5a973a8414), {
                        isDisabled: isDisabled,
                        isRequired: props.isRequired,
                        size: props.size,
                        labelPosition: labelPosition,
                        labelAlign: labelAlign,
                        necessityIndicator: necessityIndicator,
                        contextualHelp: props.contextualHelp,
                        children: label
                    }),
                    /*#__PURE__*/ (0, $iu0JR$jsxs)((0, $9afd80978c252040$export$f0fe469072bc6950), {
                        isDisabled: isDisabled,
                        size: props.size,
                        styles: " og12 ng12 kg12 jg12 Sw12 Rd12",
                        children: [
                            /*#__PURE__*/ (0, $iu0JR$jsx)((0, $iu0JR$Provider), {
                                values: [
                                    [
                                        (0, $ac8c32e6775ddd1f$export$a49f528ae1a4d0ed),
                                        {
                                            render: (0, $1f4b04be3f24aae3$export$9d7e2342a7e53afa)({
                                                slot: 'icon',
                                                styles: " _va12 Ht12 Hsu12 -_8sjo0b-t5ZbAob12"
                                            }),
                                            styles: " ZuUmpre12 FuUmpre12 I67logd12"
                                        }
                                    ]
                                ],
                                children: /*#__PURE__*/ (0, $iu0JR$jsx)((0, $279039872474ccc7$export$2e2bcd8739ae039), {})
                            }),
                            /*#__PURE__*/ (0, $iu0JR$jsx)((0, $9afd80978c252040$export$f5b8910cec6cf069), {
                                ref: inputRef,
                                UNSAFE_className: "zc3JFe"
                            }),
                            !isEmpty && !searchFieldProps.isReadOnly && /*#__PURE__*/ (0, $iu0JR$jsx)((0, $f6a62e6e68437458$export$13ec83e50bf04290), {
                                size: props.size
                            })
                        ]
                    }),
                    /*#__PURE__*/ (0, $iu0JR$jsx)((0, $9afd80978c252040$export$a67c0bc59081311a), {
                        size: props.size,
                        isDisabled: isDisabled,
                        isInvalid: isInvalid,
                        description: description,
                        children: errorMessage
                    })
                ]
            })
    });
});


export {$e3d0f3db0eb61b92$export$d1c4e4c63cb03a11 as SearchFieldContext, $e3d0f3db0eb61b92$export$b94867ecbd698f21 as SearchField};
//# sourceMappingURL=SearchField.mjs.map
