"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.n = (module)=>{
        var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
        __webpack_require__.d(getter, {
            a: getter
        });
        return getter;
    };
})();
(()=>{
    __webpack_require__.d = (exports1, definition)=>{
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
    __webpack_require__.r = (exports1)=>{
        if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    PickerTrigger: ()=>PickerTrigger
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
const KeyboardArrowDown_namespaceObject = require("@mui/icons-material/KeyboardArrowDown");
var KeyboardArrowDown_default = /*#__PURE__*/ __webpack_require__.n(KeyboardArrowDown_namespaceObject);
const Box_namespaceObject = require("@mui/material/Box");
var Box_default = /*#__PURE__*/ __webpack_require__.n(Box_namespaceObject);
const ButtonBase_namespaceObject = require("@mui/material/ButtonBase");
var ButtonBase_default = /*#__PURE__*/ __webpack_require__.n(ButtonBase_namespaceObject);
const Typography_namespaceObject = require("@mui/material/Typography");
var Typography_default = /*#__PURE__*/ __webpack_require__.n(Typography_namespaceObject);
const apollo_core_namespaceObject = require("@uipath/apollo-core");
const index_cjs_namespaceObject = require("../../../../i18n/index.cjs");
const external_ModelTagChip_cjs_namespaceObject = require("../ModelTagChip.cjs");
const external_utils_cjs_namespaceObject = require("../utils.cjs");
const PickerTrigger = ({ id, selected, unknownValue, placeholder = 'Select a model', disabled, open, invalid, tagContext, tagVariants, extra, onClick, triggerRef, hideTagKinds, controlsId, describedById, required, className, 'data-testid': dataTestId })=>{
    const { _ } = (0, index_cjs_namespaceObject.useSafeLingui)();
    const effectiveCtx = tagContext ?? {
        i18n: {
            _
        }
    };
    const inlineTags = selected ? (0, external_utils_cjs_namespaceObject.deriveModelTags)(selected, effectiveCtx).filter((t)=>!hideTagKinds?.includes(t.kind)) : [];
    const primary = selected ? selected.displayName ?? selected.modelName : null;
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Box_default(), {
        sx: {
            display: 'flex',
            flexDirection: 'column',
            width: '100%'
        },
        children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(ButtonBase_default(), {
            id: id,
            ref: triggerRef,
            type: "button",
            disabled: disabled,
            onClick: onClick,
            className: className,
            "data-testid": dataTestId,
            "aria-haspopup": "listbox",
            "aria-expanded": open,
            "aria-controls": open && controlsId ? controlsId : void 0,
            "aria-invalid": invalid ? true : void 0,
            "aria-required": required ? true : void 0,
            "aria-describedby": describedById,
            focusRipple: true,
            sx: {
                width: '100%',
                minHeight: 44,
                px: 1.5,
                py: 1,
                display: 'flex',
                alignItems: 'center',
                gap: 1.25,
                justifyContent: 'flex-start',
                textAlign: 'left',
                backgroundColor: `var(--color-background-raised, ${apollo_core_namespaceObject.Colors.ColorWhite})`,
                borderRadius: '9px',
                border: `1.5px solid ${invalid ? `var(--color-error-text, ${apollo_core_namespaceObject.Colors.ColorRed700})` : `var(--color-primary, ${apollo_core_namespaceObject.Colors.ColorBlue500})`}`,
                boxShadow: open ? "0 0 0 3px var(--color-primary-focused, rgba(0, 103, 223, 0.15))" : 'none',
                transition: 'border-color 120ms, box-shadow 120ms',
                color: `var(--color-foreground, ${apollo_core_namespaceObject.Colors.ColorGray850})`,
                '&:hover': {
                    borderColor: invalid ? `var(--color-error-text, ${apollo_core_namespaceObject.Colors.ColorRed700})` : `var(--color-primary-hover, ${apollo_core_namespaceObject.Colors.ColorBlue600})`
                },
                '&.Mui-disabled': {
                    opacity: 0.5
                }
            },
            children: [
                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Box_default(), {
                    sx: {
                        flex: 1,
                        minWidth: 0,
                        display: 'flex',
                        alignItems: 'center',
                        gap: 0.75,
                        flexWrap: 'nowrap'
                    },
                    children: selected ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
                        children: [
                            /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Typography_default(), {
                                variant: "body1",
                                sx: {
                                    fontWeight: 600,
                                    fontSize: 14,
                                    whiteSpace: 'nowrap',
                                    overflow: 'hidden',
                                    textOverflow: 'ellipsis',
                                    maxWidth: '100%',
                                    color: `var(--color-foreground, ${apollo_core_namespaceObject.Colors.ColorGray850})`
                                },
                                children: primary
                            }),
                            inlineTags.map((t)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Box_default(), {
                                    sx: {
                                        flexShrink: 0
                                    },
                                    children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_ModelTagChip_cjs_namespaceObject.ModelTagChip, {
                                        tag: t,
                                        variants: tagVariants
                                    })
                                }, `${t.kind}-${t.label}`))
                        ]
                    }) : unknownValue ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Typography_default(), {
                        variant: "body1",
                        sx: {
                            fontWeight: 600,
                            fontSize: 14,
                            whiteSpace: 'nowrap',
                            overflow: 'hidden',
                            textOverflow: 'ellipsis',
                            maxWidth: '100%',
                            color: `var(--color-error-text, ${apollo_core_namespaceObject.Colors.ColorRed700})`
                        },
                        title: _({
                            id: 'modelPicker.trigger.unknownValueTooltip',
                            message: '"{value}" is no longer available in this catalog. Pick a replacement to ensure your workflow continues to run.',
                            values: {
                                value: unknownValue
                            }
                        }),
                        children: unknownValue
                    }) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Typography_default(), {
                        variant: "body1",
                        sx: {
                            color: `var(--color-foreground-disable, ${apollo_core_namespaceObject.Colors.ColorGray500})`,
                            fontSize: 14
                        },
                        children: placeholder
                    })
                }),
                extra && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Box_default(), {
                    sx: {
                        flexShrink: 0,
                        display: 'flex',
                        alignItems: 'center'
                    },
                    onClick: (e)=>e.stopPropagation(),
                    children: extra
                }),
                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(KeyboardArrowDown_default(), {
                    sx: {
                        color: `var(--color-foreground-de-emp, ${apollo_core_namespaceObject.Colors.ColorGray550})`,
                        transition: 'transform 150ms',
                        transform: open ? 'rotate(180deg)' : 'rotate(0)',
                        flexShrink: 0,
                        fontSize: 18
                    }
                })
            ]
        })
    });
};
exports.PickerTrigger = __webpack_exports__.PickerTrigger;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "PickerTrigger"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
