import { asClass, asFunction } from "awilix";
import { CustomerUserService } from "@open-mercato/core/modules/customer_accounts/services/customerUserService";
import { CustomerSessionService } from "@open-mercato/core/modules/customer_accounts/services/customerSessionService";
import { CustomerTokenService } from "@open-mercato/core/modules/customer_accounts/services/customerTokenService";
import { CustomerRbacService } from "@open-mercato/core/modules/customer_accounts/services/customerRbacService";
import { CustomerInvitationService } from "@open-mercato/core/modules/customer_accounts/services/customerInvitationService";
import { DomainMappingService } from "@open-mercato/core/modules/customer_accounts/services/domainMappingService";
function isDomainCacheService(candidate) {
  if (!candidate || typeof candidate !== "object") return false;
  const c = candidate;
  return typeof c.get === "function" && typeof c.set === "function" && typeof c.deleteByTags === "function";
}
function register(container) {
  container.register({ customerUserService: asClass(CustomerUserService).scoped() });
  container.register({ customerSessionService: asClass(CustomerSessionService).scoped() });
  container.register({ customerTokenService: asClass(CustomerTokenService).scoped() });
  container.register({ customerRbacService: asClass(CustomerRbacService).scoped() });
  container.register({ customerInvitationService: asClass(CustomerInvitationService).scoped() });
  container.register({
    domainMappingService: asFunction(
      function domainMappingServiceFactory(em) {
        let cacheService;
        try {
          if (container.hasRegistration("cache")) {
            const candidate = container.resolve("cache");
            if (isDomainCacheService(candidate)) cacheService = candidate;
          }
        } catch {
          cacheService = void 0;
        }
        return new DomainMappingService(em, cacheService ? { cacheService } : void 0);
      }
    ).scoped()
  });
}
export {
  register
};
//# sourceMappingURL=di.js.map
