"use strict";

exports.__esModule = true;
exports.CairoProvider = CairoProvider;
var _react = _interopRequireWildcard(require("react"));
var _WixPatternsInitialPropsProvider = require("../WixPatternsInitialPropsProvider");
var _WixPatternsContainerProvider = require("../WixPatternsContainerProvider");
var _WixPatternsContainerOverridesContext = require("../WixPatternsContainerOverridesContext");
var _state = require("../../state");
var _jsxFileName = "/home/builduser/work/843658b9f44192f0/packages/core/dist/cjs/providers/CairoProvider/CairoProvider.tsx";
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
function CairoProvider({
  value,
  children,
  localCache = true,
  contextType = 'SITE',
  layoutType,
  ...rest
}) {
  const containerOverrides = (0, _WixPatternsContainerOverridesContext.useWixPatternsContainerOverrides)();
  const initialProps = (0, _WixPatternsInitialPropsProvider.useWixPatternsInitialProps)();
  const [container] = (0, _react.useState)(() => (0, _state.buildWixPatternsContainer)(value, {
    containerOverrides,
    initialProps,
    localCache,
    contextType,
    layoutType,
    ...rest
  }));
  (0, _react.useState)(() => {
    container.initialFetch();
  });
  (0, _react.useEffect)(() => {
    return container.init();
  }, []);
  return /*#__PURE__*/_react.default.createElement(_WixPatternsContainerProvider.WixPatternsContainerProvider, {
    value: container,
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 55,
      columnNumber: 5
    }
  }, children);
}
//# sourceMappingURL=CairoProvider.js.map