import { Configuration, FrontendApi, IdentityApi } from '@ory/client';
import { PUBLIC_KRATOS_URL } from '$env/static/public';

// Browser-side client (with credentials)
// All browser calls (including admin API) go through Oathkeeper at PUBLIC_KRATOS_URL
export const kratosClient = new FrontendApi(
	new Configuration({
		basePath: PUBLIC_KRATOS_URL || 'http://localhost:7200',
		baseOptions: {
			withCredentials: true
		}
	})
);

// Admin client for administrative operations (with credentials)
// Uses the same proxy but with IdentityApi for admin operations
export const kratosAdminClient = new IdentityApi(
	new Configuration({
		basePath: PUBLIC_KRATOS_URL || 'http://localhost:7200',
		baseOptions: {
			withCredentials: true
		}
	})
);
