"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CurrentTenant = void 0;
const common_1 = require("@nestjs/common");
exports.CurrentTenant = (0, common_1.createParamDecorator)((data, ctx) => {
    const request = ctx.switchToHttp().getRequest();
    if (request.user?.tenant_id) {
        return request.user.tenant_id;
    }
    const tenantId = request.headers['x-tenant-id'];
    if (tenantId) {
        return tenantId;
    }
    const host = request.headers.host || '';
    const subdomain = host.split('.')[0];
    if (subdomain && subdomain !== 'www' && subdomain !== 'api') {
        return subdomain;
    }
    return '';
});
//# sourceMappingURL=tenant.decorator.js.map