"use strict";
(globalThis["webpackChunkcore_ruffle"] = globalThis["webpackChunkcore_ruffle"] || []).push([["187"], {
392: (function (__unused_webpack_module, exports, __webpack_require__) {
/**
 * @license React
 * react-compiler-runtime.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */


var ReactSharedInternals =
  (__webpack_require__(442)/* .__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE */.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE);
exports.c = function (size) {
  return ReactSharedInternals.H.useMemoCache(size);
};


}),
631: (function (__unused_webpack_module, exports) {
/**
 * @license React
 * react-jsx-runtime.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */


var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
  REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
function jsxProd(type, config, maybeKey) {
  var key = null;
  void 0 !== maybeKey && (key = "" + maybeKey);
  void 0 !== config.key && (key = "" + config.key);
  if ("key" in config) {
    maybeKey = {};
    for (var propName in config)
      "key" !== propName && (maybeKey[propName] = config[propName]);
  } else maybeKey = config;
  config = maybeKey.ref;
  return {
    $$typeof: REACT_ELEMENT_TYPE,
    type: type,
    key: key,
    ref: void 0 !== config ? config : null,
    props: maybeKey
  };
}
exports.Fragment = REACT_FRAGMENT_TYPE;
exports.jsx = jsxProd;
exports.jsxs = jsxProd;


}),
827: (function (module, __unused_webpack_exports, __webpack_require__) {
/**
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */



if (true) {
  module.exports = __webpack_require__(392);
} else {}


}),
893: (function (module, __unused_webpack_exports, __webpack_require__) {


if (true) {
  module.exports = __webpack_require__(631);
} else {}


}),
833: (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
  "default": () => (LauncherEmbedPage)
});
/* ESM import */var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(893);
/* ESM import */var react_compiler_runtime__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(827);
/* ESM import */var react__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(442);
/* ESM import */var react__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_2__);



function LauncherEmbedPage(props) {
    const $ = (0,react_compiler_runtime__WEBPACK_IMPORTED_MODULE_1__.c)(18);
    const [, setRufflePlayer] = (0,react__WEBPACK_IMPORTED_MODULE_2__.useState)();
    const containerRef = react__WEBPACK_IMPORTED_MODULE_2___default().useRef(null);
    const navigate = window.ext.hooks.useNavigate();
    let t0;
    t0 = `${window.ext.utils.getFileServerURL()}/ruffle/webhosted/latest/ruffle.js`;
    const ruffleJsUrl = t0;
    let width;
    let height;
    if (props.game.extData?.nga) {
        width = props.game.extData?.nga.width;
        if (width) {
            width = width + "px";
        }
        height = props.game.extData?.nga.height;
        if (height) {
            height = height + "px";
        }
    }
    let t1;
    if ($[0] !== props.activeData?.launchCommand) {
        t1 = ()=>{
            if (!window.RufflePatched) {
                const elem = document.createElement("script");
                elem.setAttribute("src", ruffleJsUrl);
                elem.onload = ()=>{
                    console.log("js script loaded");
                    if (containerRef.current && window.RufflePlayer) {
                        const lc = props.activeData?.launchCommand;
                        ;
                        try {
                            const ruffle = window.RufflePlayer.newest();
                            const player = ruffle.createPlayer();
                            player.id = "ruffle-player";
                            containerRef.current.appendChild(player);
                            player.load(lc);
                            setRufflePlayer(player);
                            console.log("Ruffle player created and loaded with:", lc);
                        } catch (t2) {
                            const err = t2;
                            console.error("Failed to create Ruffle player:", err);
                        }
                    }
                };
                document.head.append(elem);
                console.log("Patched in Ruffle");
            } else {
                if (containerRef.current && window.RufflePlayer) {
                    const lc_0 = props.activeData?.launchCommand;
                    ;
                    try {
                        containerRef.current.innerHTML = "";
                        const ruffle_0 = window.RufflePlayer.newest();
                        const player_0 = ruffle_0.createPlayer();
                        player_0.id = "ruffle-player";
                        containerRef.current.appendChild(player_0);
                        player_0.load(lc_0);
                        setRufflePlayer(player_0);
                        console.log("Ruffle player created and loaded with:", lc_0);
                    } catch (t3) {
                        const err_0 = t3;
                        console.error("Failed to create Ruffle player:", err_0);
                    }
                }
            }
        };
        $[0] = props.activeData?.launchCommand;
        $[1] = t1;
    } else {
        t1 = $[1];
    }
    let t2;
    if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
        t2 = [];
        $[2] = t2;
    } else {
        t2 = $[2];
    }
    react__WEBPACK_IMPORTED_MODULE_2___default().useEffect(t1, t2);
    let t3;
    if ($[3] !== navigate) {
        t3 = ()=>{
            navigate(-1);
        };
        $[3] = navigate;
        $[4] = t3;
    } else {
        t3 = $[4];
    }
    const onBack = t3;
    let t4;
    if ($[5] !== props.game.title) {
        t4 = /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div", {
            className: "ruffle-title",
            children: props.game.title
        });
        $[5] = props.game.title;
        $[6] = t4;
    } else {
        t4 = $[6];
    }
    let t5;
    if ($[7] !== height || $[8] !== width) {
        t5 = /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div", {
            className: "ruffle-container",
            style: {
                width,
                height
            },
            ref: containerRef
        });
        $[7] = height;
        $[8] = width;
        $[9] = t5;
    } else {
        t5 = $[9];
    }
    let t6;
    if ($[10] !== t4 || $[11] !== t5) {
        t6 = /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
            className: "ruffle-wrapper",
            children: [
                t4,
                t5
            ]
        });
        $[10] = t4;
        $[11] = t5;
        $[12] = t6;
    } else {
        t6 = $[12];
    }
    let t7;
    if ($[13] !== onBack) {
        t7 = /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("button", {
            className: "simple-button ruffle-back-button",
            onClick: onBack,
            children: "Back"
        });
        $[13] = onBack;
        $[14] = t7;
    } else {
        t7 = $[14];
    }
    let t8;
    if ($[15] !== t6 || $[16] !== t7) {
        t8 = /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
            className: "ruffle-page",
            children: [
                t6,
                t7
            ]
        });
        $[15] = t6;
        $[16] = t7;
        $[17] = t8;
    } else {
        t8 = $[17];
    }
    return t8;
}


}),

}]);