import { FolkShape } from "./folk-shape"; import { css, html } from "./tags"; const styles = css` :host { background: #1e1e1e; border-radius: 8px; box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3); min-width: 400px; min-height: 350px; } .header { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: linear-gradient(135deg, #059669, #10b981); color: white; border-radius: 8px 8px 0 0; font-size: 12px; font-weight: 600; cursor: move; } .header-title { display: flex; align-items: center; gap: 6px; } .header-actions { display: flex; gap: 4px; } .header-actions button { background: transparent; border: none; color: white; cursor: pointer; padding: 2px 6px; border-radius: 4px; font-size: 14px; } .header-actions button:hover { background: rgba(255, 255, 255, 0.2); } .content { display: flex; flex-direction: column; height: calc(100% - 36px); background: #1e1e1e; border-radius: 0 0 8px 8px; } .video-container { flex: 1; display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; padding: 12px; background: #0a0a0a; } .video-slot { background: #2d2d2d; border-radius: 8px; aspect-ratio: 16/9; display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; } .video-slot video { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; } .video-placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; color: #6b7280; gap: 8px; } .video-placeholder-icon { font-size: 32px; opacity: 0.5; } .participant-name { position: absolute; bottom: 8px; left: 8px; background: rgba(0, 0, 0, 0.6); color: white; padding: 4px 8px; border-radius: 4px; font-size: 11px; } .controls { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 12px; background: #1e1e1e; border-top: 1px solid #2d2d2d; } .control-btn { width: 48px; height: 48px; border-radius: 50%; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 20px; transition: all 0.2s; } .control-btn.primary { background: #10b981; color: white; } .control-btn.primary:hover { background: #059669; } .control-btn.secondary { background: #374151; color: white; } .control-btn.secondary:hover { background: #4b5563; } .control-btn.danger { background: #ef4444; color: white; } .control-btn.danger:hover { background: #dc2626; } .control-btn.muted { background: #ef4444 !important; } .join-screen { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 24px; } .join-icon { font-size: 48px; } .join-title { color: white; font-size: 18px; font-weight: 600; } .join-subtitle { color: #9ca3af; font-size: 13px; text-align: center; } .room-input { padding: 10px 16px; border: 2px solid #374151; border-radius: 8px; background: #2d2d2d; color: white; font-size: 14px; width: 200px; text-align: center; outline: none; } .room-input:focus { border-color: #10b981; } .join-btn { padding: 12px 32px; background: #10b981; color: white; border: none; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; transition: background 0.2s; } .join-btn:hover { background: #059669; } .join-btn:disabled { opacity: 0.5; cursor: not-allowed; } .status-bar { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: #0a0a0a; font-size: 11px; color: #9ca3af; } .recording-indicator { display: flex; align-items: center; gap: 4px; color: #ef4444; } .recording-dot { width: 8px; height: 8px; background: #ef4444; border-radius: 50%; animation: pulse 1.5s infinite; } @keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } } `; interface Participant { id: string; name: string; videoEnabled: boolean; audioEnabled: boolean; } declare global { interface HTMLElementTagNameMap { "folk-video-chat": FolkVideoChat; } } export class FolkVideoChat extends FolkShape { static override tagName = "folk-video-chat"; static { const sheet = new CSSStyleSheet(); const parentRules = Array.from(FolkShape.styles.cssRules) .map((r) => r.cssText) .join("\n"); const childRules = Array.from(styles.cssRules) .map((r) => r.cssText) .join("\n"); sheet.replaceSync(`${parentRules}\n${childRules}`); this.styles = sheet; } #roomId: string | null = null; #isJoined = false; #isMuted = false; #isVideoOff = false; #isRecording = false; #participants: Participant[] = []; #localStream: MediaStream | null = null; get roomId() { return this.#roomId; } set roomId(value: string | null) { this.#roomId = value; } override createRenderRoot() { const root = super.createRenderRoot(); const wrapper = document.createElement("div"); wrapper.innerHTML = html`