import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
import _extends from "@babel/runtime/helpers/esm/extends";
var _excluded = ["children"];

/* eslint-disable @typescript-eslint/ban-types */

/* eslint-disable @typescript-eslint/no-unused-expressions */
import React, { useState, useEffect } from 'react';
import { Background, Debug, Fog, Stats, Inspector, VrModeUI, Screenshot, Pool, KeyboardShortcuts, Embedded, DeviceOrientationPermissionUI, GLTFModel, Shadow, Renderer } from '../components/scene';

function toProps(props) {
  var defaultKeys = ['id', 'className', 'fog', 'inspector', 'background', 'vrModeUI', 'stats', 'screenshot', 'pool', 'keyboardShortcuts', 'embedded', 'deviceOrientationPermissionUI', 'debug', 'gltfModel', 'shadow', 'renderer', 'children'];
  var extraKeys = Object.keys(props).filter(function (key) {
    return !defaultKeys.includes(key);
  });
  var extraProps = extraKeys.reduce(function (acc, key) {
    var _extends2;

    return _extends({}, acc, (_extends2 = {}, _extends2[key] = props[key], _extends2));
  }, {});
  var id = props.id,
      className = props.className,
      fog = props.fog,
      inspector = props.inspector,
      background = props.background,
      vrModeUI = props.vrModeUI,
      stats = props.stats,
      screenshot = props.screenshot,
      pool = props.pool,
      keyboardShortcuts = props.keyboardShortcuts,
      embedded = props.embedded,
      deviceOrientationPermissionUI = props.deviceOrientationPermissionUI,
      debug = props.debug,
      gltfModel = props.gltfModel,
      shadow = props.shadow,
      renderer = props.renderer;
  return _extends({
    id: id,
    class: className,
    background: background && new Background(background).toString(),
    debug: debug !== undefined ? new Debug(debug).toString() : undefined,
    fog: fog && new Fog(fog).toString(),
    inspector: inspector && new Inspector(inspector).toString(),
    'vr-mode-ui': vrModeUI && new VrModeUI(vrModeUI).toString(),
    stats: stats !== undefined ? new Stats(stats).toString() : undefined,
    screenshot: screenshot && new Screenshot(screenshot).toString(),
    pool: pool && new Pool(pool).toString(),
    'keyboard-shortcuts': keyboardShortcuts && new KeyboardShortcuts(keyboardShortcuts).toString(),
    embedded: embedded !== undefined ? new Embedded(embedded).toString() : undefined,
    'device-orientation-permission-ui': deviceOrientationPermissionUI && new DeviceOrientationPermissionUI(deviceOrientationPermissionUI).toString(),
    'gltf-model': gltfModel && new GLTFModel(gltfModel).toString(),
    shadow: shadow && new Shadow(shadow).toString(),
    renderer: renderer && new Renderer(renderer).toString()
  }, extraProps);
}
/**
 * A scene is represented by the `<a-scene>` element. The scene is the global root object, and all [entities](https://aframe.io/docs/1.3.0/core/entity.html) are contained within the scene.
 *
 * The scene inherits from the [Entity](https://aframe.io/docs/1.3.0/core/entity.html) class so it inherits all of its properties, its methods, the ability to attach components, and the behavior to wait for all of its child nodes (e.g., `<a-assets>` and `<a-entity>`) to load before kicking off the render loop.
 *
 * @see https://aframe.io/docs/1.3.0/core/scene.html
 */


var Scene = function Scene(props) {
  var children = props.children,
      restProps = _objectWithoutPropertiesLoose(props, _excluded);

  var _useState = useState(false),
      domReady = _useState[0],
      setDomReady = _useState[1];

  useEffect(function () {
    var domElm = document.getElementById('assets-management');

    if (domElm) {
      setDomReady(true);
    }

    var sceneEl = document.querySelector('a-scene');

    if (process.env.NODE_ENV === 'production') {
      sceneEl.addEventListener('loaded', function () {
        sceneEl.components.inspector.remove();
      });
    }
  }, []);
  return /*#__PURE__*/React.createElement("a-scene", toProps(restProps), /*#__PURE__*/React.createElement("a-assets", {
    id: "assets-management"
  }), domReady && children);
};

export default Scene;