import { createBranch as apiCreateBranch, listBranches as apiListBranches, getParentSession as apiGetParentSession, getShareStatus as apiGetShareStatus, shareSession as apiShareSession, syncShare as apiSyncShare, } from '@ottocode/api';
import { extractErrorMessage } from './utils';
export const branchesMixin = {
    async createBranch(sessionId, data) {
        const response = await apiCreateBranch({
            path: { sessionId },
            // biome-ignore lint/suspicious/noExplicitAny: API type mismatch
            body: data,
        });
        if (response.error)
            throw new Error(extractErrorMessage(response.error));
        return response.data;
    },
    async listBranches(sessionId) {
        const response = await apiListBranches({ path: { sessionId } });
        if (response.error)
            throw new Error(extractErrorMessage(response.error));
        return response.data;
    },
    async getParentSession(sessionId) {
        const response = await apiGetParentSession({ path: { sessionId } });
        if (response.error)
            throw new Error(extractErrorMessage(response.error));
        return response.data;
    },
    async getShareStatus(sessionId) {
        const response = await apiGetShareStatus({ path: { sessionId } });
        if (response.error)
            return { shared: false };
        return response.data;
    },
    async shareSession(sessionId) {
        const response = await apiShareSession({ path: { sessionId } });
        if (response.error)
            throw new Error(extractErrorMessage(response.error));
        return response.data;
    },
    async syncSession(sessionId) {
        const response = await apiSyncShare({ path: { sessionId } });
        if (response.error)
            throw new Error(extractErrorMessage(response.error));
        return response.data;
    },
};
//# sourceMappingURL=branches.js.map