'use client';
"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "default", {
    enumerable: true,
    get: function() {
        return _default;
    }
});
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
const _useField = /*#__PURE__*/ _interop_require_default(require("../../useField"));
const _withCondition = require("../../withCondition");
function _interop_require_default(obj) {
    return obj && obj.__esModule ? obj : {
        default: obj
    };
}
function _getRequireWildcardCache(nodeInterop) {
    if (typeof WeakMap !== "function") return null;
    var cacheBabelInterop = new WeakMap();
    var cacheNodeInterop = new WeakMap();
    return (_getRequireWildcardCache = function(nodeInterop) {
        return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
    })(nodeInterop);
}
function _interop_require_wildcard(obj, nodeInterop) {
    if (!nodeInterop && obj && obj.__esModule) {
        return obj;
    }
    if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
        return {
            default: obj
        };
    }
    var cache = _getRequireWildcardCache(nodeInterop);
    if (cache && cache.has(obj)) {
        return cache.get(obj);
    }
    var newObj = {
        __proto__: null
    };
    var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
    for(var key in obj){
        if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
            var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
            if (desc && (desc.get || desc.set)) {
                Object.defineProperty(newObj, key, desc);
            } else {
                newObj[key] = obj[key];
            }
        }
    }
    newObj.default = obj;
    if (cache) {
        cache.set(obj, newObj);
    }
    return newObj;
}
/**
 * This is mainly used to save a value on the form that is not visible to the user.
 * For example, this sets the `ìd` property of a block in the Blocks field.
 */ const HiddenInput = (props)=>{
    const { name, disableModifyingForm = true, path: pathFromProps, value: valueFromProps } = props;
    const { path, setValue, value } = (0, _useField.default)({
        path: pathFromProps || name
    });
    (0, _react.useEffect)(()=>{
        if (valueFromProps !== undefined) {
            setValue(valueFromProps, disableModifyingForm);
        }
    }, [
        valueFromProps,
        setValue,
        disableModifyingForm
    ]);
    return /*#__PURE__*/ _react.default.createElement("input", {
        id: `field-${path?.replace(/\./g, '__')}`,
        name: path,
        onChange: setValue,
        type: "hidden",
        value: value || ''
    });
};
const _default = (0, _withCondition.withCondition)(HiddenInput);

//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9mb3Jtcy9maWVsZHMvSGlkZGVuSW5wdXQvaW5kZXgudHN4Il0sInNvdXJjZXNDb250ZW50IjpbIid1c2UgY2xpZW50J1xuaW1wb3J0IFJlYWN0LCB7IHVzZUVmZmVjdCB9IGZyb20gJ3JlYWN0J1xuXG5pbXBvcnQgdHlwZSB7IFByb3BzIH0gZnJvbSAnLi90eXBlcydcblxuaW1wb3J0IHVzZUZpZWxkIGZyb20gJy4uLy4uL3VzZUZpZWxkJ1xuaW1wb3J0IHsgd2l0aENvbmRpdGlvbiB9IGZyb20gJy4uLy4uL3dpdGhDb25kaXRpb24nXG5cbi8qKlxuICogVGhpcyBpcyBtYWlubHkgdXNlZCB0byBzYXZlIGEgdmFsdWUgb24gdGhlIGZvcm0gdGhhdCBpcyBub3QgdmlzaWJsZSB0byB0aGUgdXNlci5cbiAqIEZvciBleGFtcGxlLCB0aGlzIHNldHMgdGhlIGDDrGRgIHByb3BlcnR5IG9mIGEgYmxvY2sgaW4gdGhlIEJsb2NrcyBmaWVsZC5cbiAqL1xuY29uc3QgSGlkZGVuSW5wdXQ6IFJlYWN0LkZDPFByb3BzPiA9IChwcm9wcykgPT4ge1xuICBjb25zdCB7IG5hbWUsIGRpc2FibGVNb2RpZnlpbmdGb3JtID0gdHJ1ZSwgcGF0aDogcGF0aEZyb21Qcm9wcywgdmFsdWU6IHZhbHVlRnJvbVByb3BzIH0gPSBwcm9wc1xuXG4gIGNvbnN0IHsgcGF0aCwgc2V0VmFsdWUsIHZhbHVlIH0gPSB1c2VGaWVsZCh7XG4gICAgcGF0aDogcGF0aEZyb21Qcm9wcyB8fCBu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