import type { WebviewsController, WebviewViewProxy } from '../webviewsController.js';
import type { State } from './protocol.js';

export type HomeWebviewShowingArgs = [{ focusAccount: boolean }];

export function registerHomeWebviewView(
	controller: WebviewsController,
): WebviewViewProxy<'gitlens.views.home', HomeWebviewShowingArgs, State> {
	return controller.registerWebviewView<'gitlens.views.home', State, State, HomeWebviewShowingArgs>(
		{
			id: 'gitlens.views.home',
			fileName: 'home.html',
			title: 'Home',
			contextKeyPrefix: `gitlens:webviewView:home`,
			trackingFeature: 'homeView',
			type: 'home',
			plusFeature: false,
			webviewHostOptions: {
				retainContextWhenHidden: true,
			},
		},
		async (container, host) => {
			const { HomeWebviewProvider } = await import(/* webpackChunkName: "webview-home" */ './homeWebview.js');
			return new HomeWebviewProvider(container, host);
		},
	);
}
