import { _ as __rest } from './tslib.es6-es.js';
import React__default from 'react';
import { B as Button } from './Button-es.js';
import { m as mergeProps } from './useRenderElement-es.js';

function assignRef(ref, instance) {
    if (!ref) {
        return;
    }
    if (typeof ref === "function") {
        ref(instance);
        return;
    }
    ref.current = instance;
}
function mergeRefs(...refs) {
    return (instance) => {
        refs.forEach(ref => {
            assignRef(ref, instance);
        });
    };
}
function getElementRef(element) {
    return element.ref;
}
function normalizeBaseUiButtonProps(props) {
    const rest = __rest(props, ["type"]);
    return rest;
}
function isAtlantisButtonRenderTarget(element) {
    return React__default.isValidElement(element) && element.type === Button;
}
function renderAtlantisButtonTarget(element) {
    return function renderButtonTarget(props) {
        const mergedProps = mergeProps(normalizeBaseUiButtonProps(props), element.props);
        return (React__default.createElement(Button, Object.assign({}, mergedProps, { ref: mergeRefs(props.ref, getElementRef(element)), key: element.key })));
    };
}
function stripNativeTypeFromButtonRenderTarget(element) {
    const nativeType = element.props.type;
    if (nativeType !== "button" &&
        nativeType !== "submit" &&
        nativeType !== "reset") {
        return element;
    }
    return React__default.cloneElement(element, {
        type: undefined,
    });
}

export { isAtlantisButtonRenderTarget as i, normalizeBaseUiButtonProps as n, renderAtlantisButtonTarget as r, stripNativeTypeFromButtonRenderTarget as s };
