export function resolveSheetKey(args) {
    var _a, _b, _c;
    const {vtableSheet: vtableSheet, table: table, cached: cached} = args;
    if (!vtableSheet) return {
        sheetKey: void 0,
        cached: void 0
    };
    if (cached) return {
        sheetKey: cached,
        cached: cached
    };
    try {
        const workSheetInstances = vtableSheet.workSheetInstances;
        if (workSheetInstances && table) for (const [sheetKey, worksheet] of workSheetInstances.entries()) if ((null == worksheet ? void 0 : worksheet.tableInstance) === table) return {
            sheetKey: sheetKey,
            cached: sheetKey
        };
        const active = null === (_a = vtableSheet.getActiveSheet) || void 0 === _a ? void 0 : _a.call(vtableSheet);
        if (null == active ? void 0 : active.getKey) {
            const key = active.getKey();
            return {
                sheetKey: key,
                cached: key
            };
        }
        const activeDefine = null === (_c = null === (_b = vtableSheet.sheetManager) || void 0 === _b ? void 0 : _b.getActiveSheet) || void 0 === _c ? void 0 : _c.call(_b), key = null == activeDefine ? void 0 : activeDefine.sheetKey;
        return {
            sheetKey: key,
            cached: key
        };
    } catch (_d) {
        return {
            sheetKey: void 0,
            cached: void 0
        };
    }
}
//# sourceMappingURL=sheet-key.js.map
