'use client';
"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "WatchCondition", {
    enumerable: true,
    get: function() {
        return WatchCondition;
    }
});
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
const _context = require("../Form/context");
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;
}
const WatchCondition = (props)=>{
    const { name, children, path: pathFromProps } = props;
    const path = typeof pathFromProps === 'string' ? pathFromProps : name;
    const field = (0, _context.useFormFields)(([fields])=>fields && fields?.[path] || null);
    const { passesCondition } = field || {};
    if (passesCondition === false) {
        return null;
    }
    return /*#__PURE__*/ _react.default.createElement(_react.Fragment, null, children);
};

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