// CodeB chat -- React wrapper
// Docs: https://www.aloaha.com/chat-embed-cookbook.html
// European Digital Identity Wallet compatible via CodeB OIDC.

import React from "react";

export default function CodeBChat({
  tenantOrigin = "https://phone.your-tenant.example",
  width  = 1180,
  height = 720
}) {
  return (
    <iframe
      src={`${tenantOrigin}/chat.html`}
      title="CodeB chat"
      allow="clipboard-write; microphone; camera"
      width={width}
      height={height}
      style={{ border: 0, maxWidth: "100%" }}
    />
  );
}

// Popup alternative
export function openCodeBChatPopup(tenantOrigin, width = 1180, height = 780) {
  const left = Math.max(0, (screen.width  - width)  / 2);
  const top  = Math.max(0, (screen.height - height) / 2);
  return window.open(
    `${tenantOrigin}/chat.html`,
    "codeb-chat",
    `width=${width},height=${height},left=${left},top=${top},resizable=yes,scrollbars=yes`
  );
}
