<!-- Copyright (C) Microsoft Corporation. All rights reserved. -->
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />

		<!-- Disable pinch zooming -->
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">

		<!-- Content Security Policy -->
		<meta
			http-equiv="Content-Security-Policy"
			content="
				default-src 'self';
				img-src 'self' https: data: blob:;
				media-src 'none';
				script-src 'self' 'unsafe-eval' https: 'sha256-bpJydy1E+3Mx9MyBtkOIA3yyzM2wdyIz115+Sgq21+0=' 'sha256-meDZW3XhN5JmdjFUrWGhTouRKBiWYtXHltaKnqn/WMo=';
				child-src 'self';
				frame-src 'self';
				worker-src 'self';
				style-src 'self' 'unsafe-inline';
				connect-src 'self' ws: wss: https:;
				font-src 'self' blob:;
				manifest-src 'self';
		">

		<!-- Workbench Configuration -->
		<meta id="vscode-workbench-web-configuration" data-settings="{{WORKBENCH_WEB_CONFIGURATION}}">

		<!-- Workarounds/Hacks (remote user data uri) -->
		<meta id="vscode-remote-user-data-uri" data-settings="{{REMOTE_USER_DATA_URI}}">
		<!-- NOTE@coder: Added the commit for use in caching, the product for the
		extensions gallery URL, and nls for language support. -->
		<meta id="vscode-remote-commit" data-settings="{{COMMIT}}">
		<meta id="vscode-remote-product-configuration" data-settings="{{PRODUCT_CONFIGURATION}}">
		<meta id="vscode-remote-nls-configuration" data-settings="{{NLS_CONFIGURATION}}">

		<!-- Workbench Icon/Manifest/CSS -->
		<link rel="icon" href="./favicon.ico" type="image/x-icon" />
		<link rel="manifest" href="./manifest.json">
		<link rel="apple-touch-icon" href="./static-{{COMMIT}}/out/vs/server/src/media/code-server.png" />
		<link data-name="vs/workbench/workbench.web.api" rel="stylesheet" href="./static-{{COMMIT}}/out/vs/workbench/workbench.web.api.css">

		<!-- Prefetch to avoid waterfall -->
		<link rel="prefetch" href="./static-{{COMMIT}}/node_modules/semver-umd/lib/semver-umd.js">
		<link rel="prefetch" href="./static-{{COMMIT}}/node_modules/@microsoft/applicationinsights-web/dist/applicationinsights-web.js">
	</head>

	<body aria-label="">
	</body>

	<!-- Startup (do not modify order of script tags!) -->
	<!-- NOTE:coder: Modified to work against the current path and use the commit for caching. -->
	<script>
		// NOTE: Changes to inline scripts require update of content security policy
		const basePath = window.location.pathname.replace(/\/+$/, '');
		const base = window.location.origin  + basePath;
		const el = document.getElementById('vscode-remote-commit');
		const commit = el ? el.getAttribute('data-settings') : "";
		const staticBase = base + '/static-' + commit;
		let nlsConfig;
		try {
			nlsConfig = JSON.parse(document.getElementById('vscode-remote-nls-configuration').getAttribute('data-settings'));
			if (nlsConfig._resolvedLanguagePackCoreLocation) {
				const bundles = Object.create(null);
				nlsConfig.loadBundle = (bundle, language, cb) => {
					let result = bundles[bundle];
					if (result) {
						return cb(undefined, result);
					}
					// FIXME: Only works if path separators are /.
					const path = nlsConfig._resolvedLanguagePackCoreLocation
								+ '/' + bundle.replace(/\//g, '!') + '.nls.json';
					fetch(`${base}/resource/?path=${encodeURIComponent(path)}`)
						.then((response) => response.json())
						.then((json) => {
							bundles[bundle] = json;
							cb(undefined, json);
						})
						.catch(cb);
				};
			}
		} catch (error) { /* Probably fine. */ }
		self.require = {
			baseUrl: `${staticBase}/out`,
			paths: {
				'vscode-textmate': `${staticBase}/node_modules/vscode-textmate/release/main`,
				'onigasm-umd': `${staticBase}/node_modules/onigasm-umd/release/main`,
				'xterm': `${staticBase}/node_modules/xterm/lib/xterm.js`,
				'xterm-addon-search': `${staticBase}/node_modules/xterm-addon-search/lib/xterm-addon-search.js`,
				'xterm-addon-web-links': `${staticBase}/node_modules/xterm-addon-web-links/lib/xterm-addon-web-links.js`,
				'semver-umd': `${staticBase}/node_modules/semver-umd/lib/semver-umd.js`,
				'@microsoft/applicationinsights-web': `${staticBase}/node_modules/@microsoft/applicationinsights-web/dist/applicationinsights-web.js`,
			},
			'vs/nls': nlsConfig,
		};
	</script>
	<script src="./static-{{COMMIT}}/out/vs/loader.js"></script>
	<script src="./static-{{COMMIT}}/out/vs/workbench/workbench.web.api.nls.js"></script>
	<script src="./static-{{COMMIT}}/out/vs/workbench/workbench.web.api.js"></script>
	<!-- TODO@coder: This errors with multiple anonymous define calls (one is
	workbench.js and one is semver-umd.js). For now use the same method found in
	workbench-dev.html. Appears related to the timing of the script load events. -->
	<!-- <script src="./static-{{COMMIT}}/out/vs/workbench/workbench.js"></script> -->
	<script>
		// NOTE: Changes to inline scripts require update of content security policy
		require(['vs/code/browser/workbench/workbench'], function() {});
	</script>
</html>
