<!-- Although this is in the root of the bundle, it is loaded into
      the import/ directory. -->

<!DOCTYPE html>
<html>
  <head>
    <link rel="stylesheet" href="/c/sys/skins/w93.css" >
    <!-- <link rel="stylesheet" lhref="../main.css"> -->
    <style>
      html {
        /* For some reason the status messages cause the scrollbars to appear */
        overflow: hidden;
      }

      body {
        margin: 0;
        background: #000;
      }

      #canvas {
        height: 100vh;
        width: auto;
        margin: auto;
      }

      #status {
        position: absolute;
        bottom: 0;
        left: 0;
        color: #f0b418;
        background: rgba(0, 0, 0, .5);
      }
    </style>
  </head>

  <body>
    <canvas style="display:none" class="emscripten" id="canvas" oncontextmenu="event.preventDefault()"></canvas>
    <code id="status"></code>

    <script>
      {
        // const { indexedDb } = window

        // window.indexedDB = new Proxy(indexedDb, {
        //   get(target, prop) {
        //     if(prop == 'open') {
        //       return function(...args) {
        //         if(args[0] == 'UPLINK') {
        //           console.log('Preventing IDB cache')
        //           return {}
        //         } else {
        //           return indexedDb.open.call(this, ...args) 
        //         }
        //       }
        //     } else {
        //       return indexedDb[prop]
        //     }
        //   }
        // })

        // indexedDB.open('UPLINK', 1)
      }
    </script>
    <script type='text/javascript' lsrc='../init.js'></script>
		<script>
			// Causes the app to freeze. Maybe make async?
      function loadingDone() {
        (function() {
          // locateFile will handle the uri conversion on this one
          var memoryInitializer = 'xash.html.mem';
          if (typeof Module['locateFile'] === 'function') {
            memoryInitializer = Module['locateFile'](memoryInitializer);
          } else if (Module['memoryInitializerPrefixURL']) {
            memoryInitializer = Module['memoryInitializerPrefixURL'] + memoryInitializer;
          }
          // Send it the request so it can handle the data
          var xhr = Module['memoryInitializerRequest'] = new XMLHttpRequest();
          xhr.open('GET', memoryInitializer, true);
          xhr.responseType = 'arraybuffer';
          xhr.send(null);
        })();

        var script = document.createElement('script');
        script.src = instance.import['xash.js'];
        document.body.appendChild(script);
      }
		</script>

  </body>
</html>