import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
import { IRemoteAgentService } from '../../remote/common/remoteAgentService.js';
import { AbstractPathService } from '../common/pathService.js';
import { URI } from '../../../../base/common/uri.js';
import { IWorkbenchEnvironmentService } from '../../environment/common/environmentService.js';
import { IWorkspaceContextService } from '../../../../platform/workspace/common/workspace.js';
import { firstOrDefault } from '../../../../base/common/arrays.js';
import { dirname } from '../../../../base/common/resources.js';
let BrowserPathService = class BrowserPathService extends AbstractPathService {
    constructor(remoteAgentService, environmentService, contextService) {
        super(guessLocalUserHome(environmentService, contextService), remoteAgentService, environmentService, contextService);
    }
};
BrowserPathService = ( __decorate([
    ( __param(0, IRemoteAgentService)),
    ( __param(1, IWorkbenchEnvironmentService)),
    ( __param(2, IWorkspaceContextService))
], BrowserPathService));
function guessLocalUserHome(environmentService, contextService) {
    const workspace = contextService.getWorkspace();
    const firstFolder = firstOrDefault(workspace.folders);
    if (firstFolder) {
        return firstFolder.uri;
    }
    if (workspace.configuration) {
        return dirname(workspace.configuration);
    }
    return ( URI.from({
        scheme: AbstractPathService.findDefaultUriScheme(environmentService, contextService),
        authority: environmentService.remoteAuthority,
        path: '/'
    }));
}
export { BrowserPathService };
