"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FileOpenHandler = void 0;
const ipc_1 = require("../ipc");
const FileOpenManager_1 = require("./FileOpenManager");
/**
 * FileOpenHandler
 *
 * Command endpoints for file opening functionality.
 */
let FileOpenHandler = class FileOpenHandler {
    manager;
    constructor(manager) {
        this.manager = manager;
    }
    /**
     * Open a file with its default handler
     */
    async handleOpen(args) {
        const { path } = args;
        return this.manager.openFile(path);
    }
    /**
     * Open a file with a specific app
     */
    async handleOpenWith(args) {
        const { path, appId } = args;
        return this.manager.openFileWith(path, appId);
    }
    /**
     * Get the default handler app for a file extension
     */
    async handleGetHandler(args) {
        const { extension } = args;
        const appId = this.manager.getHandlerForExtension(extension);
        return { appId };
    }
    /**
     * Set user preference for a file extension's default handler
     */
    async handleSetDefaultHandler(args) {
        const { extension, appId } = args;
        await this.manager.setDefaultHandler(extension, appId);
    }
    /**
     * Remove user preference for a file extension (revert to default)
     */
    async handleRemoveDefaultHandler(args) {
        const { extension } = args;
        await this.manager.removeDefaultHandler(extension);
    }
    /**
     * Get all apps that can handle a specific file extension
     */
    async handleGetSupportedHandlers(args) {
        const { extension } = args;
        return this.manager.getSupportedHandlers(extension);
    }
    /**
     * Get all file type associations
     */
    async handleGetAssociations(args) {
        return this.manager.getAllAssociations();
    }
};
exports.FileOpenHandler = FileOpenHandler;
__decorate([
    (0, ipc_1.EdenHandler)("open"),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", Promise)
], FileOpenHandler.prototype, "handleOpen", null);
__decorate([
    (0, ipc_1.EdenHandler)("open-with"),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", Promise)
], FileOpenHandler.prototype, "handleOpenWith", null);
__decorate([
    (0, ipc_1.EdenHandler)("get-handler"),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", Promise)
], FileOpenHandler.prototype, "handleGetHandler", null);
__decorate([
    (0, ipc_1.EdenHandler)("set-default-handler"),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", Promise)
], FileOpenHandler.prototype, "handleSetDefaultHandler", null);
__decorate([
    (0, ipc_1.EdenHandler)("remove-default-handler"),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", Promise)
], FileOpenHandler.prototype, "handleRemoveDefaultHandler", null);
__decorate([
    (0, ipc_1.EdenHandler)("get-supported-handlers"),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", Promise)
], FileOpenHandler.prototype, "handleGetSupportedHandlers", null);
__decorate([
    (0, ipc_1.EdenHandler)("get-associations"),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", Promise)
], FileOpenHandler.prototype, "handleGetAssociations", null);
exports.FileOpenHandler = FileOpenHandler = __decorate([
    (0, ipc_1.EdenNamespace)("file"),
    __metadata("design:paramtypes", [FileOpenManager_1.FileOpenManager])
], FileOpenHandler);
//# sourceMappingURL=FileOpenHandler.js.map