"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.d = function(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 = function(obj, prop) {
        return Object.prototype.hasOwnProperty.call(obj, prop);
    };
})();
(()=>{
    __webpack_require__.r = function(exports1) {
        if ('undefined' != 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__, {
    RecordIndexProvider: ()=>RecordIndexProvider,
    RecordIndexContext: ()=>RecordIndexContext,
    useRecordIsOwn: ()=>useRecordIsOwn,
    RecordContext_deprecated: ()=>RecordContext_deprecated,
    RecordProvider: ()=>RecordProvider,
    useRecord: ()=>useRecord,
    RecordSimpleProvider: ()=>RecordSimpleProvider,
    useRecordIndex: ()=>useRecordIndex
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
const external_react_namespaceObject = require("react");
const index_js_namespaceObject = require("../collection-manager/index.js");
const external_data_source_index_js_namespaceObject = require("../data-source/index.js");
const external_user_index_js_namespaceObject = require("../user/index.js");
const RecordContext_deprecated = /*#__PURE__*/ (0, external_react_namespaceObject.createContext)({});
RecordContext_deprecated.displayName = 'RecordContext_deprecated';
const RecordIndexContext = /*#__PURE__*/ (0, external_react_namespaceObject.createContext)(null);
RecordIndexContext.displayName = 'RecordIndexContext';
const RecordProvider = (props)=>{
    const { record, children, parent, isNew } = props;
    const { name: __collectionName } = (0, index_js_namespaceObject.useCollection_deprecated)();
    const value = {
        ...record
    };
    value['__parent'] = parent;
    value['__collectionName'] = __collectionName;
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(RecordContext_deprecated.Provider, {
        value: value,
        children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_data_source_index_js_namespaceObject.CollectionRecordProvider, {
            isNew: isNew,
            record: record,
            parentRecord: parent,
            children: children
        })
    });
};
const RecordSimpleProvider = (props)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(RecordContext_deprecated.Provider, {
        ...props
    });
const RecordIndexProvider = (props)=>{
    const { index, children } = props;
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(RecordIndexContext.Provider, {
        value: index,
        children: children
    });
};
function useRecord() {
    return (0, external_react_namespaceObject.useContext)(RecordContext_deprecated);
}
function useRecordIndex() {
    return (0, external_react_namespaceObject.useContext)(RecordIndexContext);
}
const useRecordIsOwn = ()=>{
    var _ctx_data_data, _ctx_data;
    const record = useRecord();
    const ctx = (0, external_user_index_js_namespaceObject.useCurrentUserContext)();
    if (!(null == record ? void 0 : record.createdById)) return false;
    return (null == record ? void 0 : record.createdById) === (null == ctx ? void 0 : null === (_ctx_data = ctx.data) || void 0 === _ctx_data ? void 0 : null === (_ctx_data_data = _ctx_data.data) || void 0 === _ctx_data_data ? void 0 : _ctx_data_data.id);
};
var __webpack_export_target__ = exports;
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
    value: true
});
