Update to Lucebra
Snapshot Oct 31, 2026 · 12:10 UTC · version 1.0.6
Payment or plan references changed
Package file — Removed: {"sha256":"6f68f653225f9dfb8cc135f2cbbbd774638b4dcd76bb38642e2670486a41739d","size":198}
Observed in published text. Live prices and checkout terms have not been verified by this change.
Up to 3 plugins free · no card required.
All fields and original values.
These are saved file metadata. Open a changed file to read its text edits.
Package file
Oct 27, 2026 · 00:21 UTC
{"sha256":"6f68f653225f9dfb8cc135f2cbbbd774638b4dcd76bb38642e2670486a41739d","size":198}
Oct 31, 2026 · 12:10 UTC
Not present
Package file
Oct 27, 2026 · 00:21 UTC
f313e0e7185885b4988cc72a8339ff386c5b640dcfb1c3717de85458386c6e67
Oct 31, 2026 · 12:10 UTC
a5c2d0d1355849bc825cd5b7c37af9a996603ba4b7a059c2fc6f1fc1a75f5ce4
Package file
Oct 27, 2026 · 00:21 UTC
{"sha256":"e956e3376d1b8ec6f19842d8755443b82e465a728ea85d1122c0b529e1aa4b57","size":324}
Oct 31, 2026 · 12:10 UTC
Not present
Package file
Oct 27, 2026 · 00:21 UTC
{"sha256":"74f5f71269d405dcc83c137044b3711657db5d38e9c1cf263b8be02ad67a5b03","size":228}
Oct 31, 2026 · 12:10 UTC
Not present
Compare saved observations
Download comparison JSONChanged files
Choose a file to see its text changes. Binary or large files show metadata only.
mcp.json →
skills/add_to_cart_and_checkout/SKILL.md →
skills/add_to_wishlist/SKILL.md →
skills/check_business_plan/SKILL.md →
skills/compare_courses/SKILL.md →
skills/enroll_via_business_plan/SKILL.md →
skills/get_course_content/SKILL.md →
skills/get_course_curriculum/SKILL.md →
skills/get_course_details/SKILL.md →
skills/get_course_preview/SKILL.md →
skills/get_course_price/SKILL.md →
skills/get_course_reviews/SKILL.md →
skills/get_instructor_profile/SKILL.md →
skills/get_learning_path/SKILL.md →
skills/get_live_sessions/SKILL.md →
skills/get_my_certificates/SKILL.md →
skills/get_my_learning_progress/SKILL.md →
skills/get_my_wishlist/SKILL.md →
skills/get_practice_exams/SKILL.md →
skills/lucebra-learning-assistant/SKILL.md →
skills/recommend_courses/SKILL.md →
skills/search_courses/SKILL.md →
widgets/course-player.html
− removed · + added
--- before +++ after @@ -1,5 +1,6 @@ <!DOCTYPE html> <html lang="en"> + <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> @@ -19,6 +20,7 @@ --lucebra-text: #f8fafc; --lucebra-text-muted: #94a3b8; --lucebra-star: #f59e0b; + --lucebra-price: #34d399; } * { @@ -39,7 +41,6 @@ padding: 16px; } - /* ChatGPT Message Bubble Frame Simulation */ .chat-bubble-container { width: 100%; max-width: 860px; @@ -50,7 +51,6 @@ box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.05); } - /* Lucebra Brand Header */ .widget-header { display: flex; align-items: center; @@ -58,18 +58,26 @@ margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--lucebra-border); + gap: 10px; + flex-wrap: wrap; } .brand-left { display: flex; align-items: center; - gap: 12px; + gap: 10px; + } + + .brand-logo-link { + display: inline-flex; + align-items: center; + text-decoration: none; } .brand-logo { height: 24px; width: auto; - max-width: 120px; + max-width: 115px; object-fit: contain; display: block; } @@ -80,16 +88,388 @@ color: #38bdf8; font-size: 11px; font-weight: 600; - padding: 2px 8px; + padding: 2px 9px; border-radius: 20px; + white-space: nowrap; + } + + .header-right { + display: flex; + align-items: center; + gap: 10px; + flex-wrap: wrap; } .header-info { font-size: 12px; - color: var(--lucebra-text-muted); + font-weight: 600; + color: #cbd5e1; + background: rgba(255, 255, 255, 0.04); + border: 1px solid rgba(255, 255, 255, 0.08); + padding: 3px 10px; + border-radius: 20px; + } + + .btn-connect-account { + background: rgba(19, 127, 236, 0.14); + border: 1px solid rgba(56, 189, 248, 0.38); + color: #38bdf8; + font-size: 11.5px; + font-weight: 600; + padding: 5px 11px; + border-radius: 20px; + display: inline-flex; + align-items: center; + gap: 6px; + cursor: pointer; + transition: all 0.2s ease; + } + + .btn-connect-account:hover { + background: rgba(19, 127, 236, 0.28); + border-color: #38bdf8; + color: #fff; + transform: translateY(-1px); + } + + .user-profile-badge { + display: none; + align-items: center; + gap: 7px; + background: #162332; + border: 1px solid rgba(52, 211, 153, 0.35); + padding: 3px 8px 3px 4px; + border-radius: 24px; + } + + .user-profile-badge.visible { + display: inline-flex; + } + + .user-badge-avatar-wrap { + position: relative; + width: 24px; + height: 24px; + flex-shrink: 0; + } + + .user-badge-avatar { + width: 24px; + height: 24px; + border-radius: 50%; + object-fit: cover; + border: 1.5px solid #38bdf8; + display: block; + } + + .user-badge-dot { + position: absolute; + right: -1px; + bottom: -1px; + width: 8px; + height: 8px; + border-radius: 50%; + background: #34d399; + border: 1.5px solid #101922; + } + + .user-badge-name { + font-size: 11.5px; + font-weight: 600; + color: #f1f5f9; + max-width: 130px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + } + + .user-badge-plan { + font-size: 9.5px; + font-weight: 700; + text-transform: uppercase; + letter-spacing: 0.3px; + padding: 1.5px 6px; + border-radius: 10px; + background: rgba(56, 189, 248, 0.16); + color: #38bdf8; + border: 1px solid rgba(56, 189, 248, 0.3); + display: none; + } + + .user-badge-plan.visible { + display: inline-block; + } + + .btn-disconnect-account { + background: transparent; + border: none; + color: #94a3b8; + font-size: 14px; + line-height: 1; + cursor: pointer; + padding: 0 2px; + display: inline-flex; + align-items: center; + justify-content: center; + transition: color 0.15s; + } + + .btn-disconnect-account:hover { + color: #f87171; + } + + .lucebra-modal-backdrop { + position: fixed; + inset: 0; + z-index: 50; + background: rgba(5, 8, 12, 0.8); + backdrop-filter: blur(5px); + display: none; + align-items: center; + justify-content: center; + padding: 16px; + } + + .lucebra-modal-backdrop.visible { + display: flex; + } + + .lucebra-modal-card { + width: 100%; + max-width: 390px; + background: #131e2b; + border: 1px solid #263a52; + border-radius: 16px; + padding: 18px 20px; + box-shadow: 0 20px 50px rgba(0, 0, 0, 0.75); + position: relative; + max-height: 92vh; + overflow-y: auto; + } + + .lucebra-modal-header { + display: flex; + align-items: center; + justify-content: space-between; + margin-bottom: 8px; + } + + .lucebra-modal-title { + font-size: 15px; + font-weight: 700; + color: #f8fafc; + display: flex; + align-items: center; + gap: 8px; + } + + .lucebra-modal-close { + background: transparent; + border: none; + color: #94a3b8; + font-size: 18px; + cursor: pointer; + padding: 2px 6px; + border-radius: 6px; + } + + .lucebra-modal-close:hover { + background: rgba(255, 255, 255, 0.06); + color: #fff; + } + + .login-mode-tabs { + display: grid; + grid-template-columns: 1fr 1fr; + gap: 6px; + background: #0b1118; + padding: 4px; + border-radius: 10px; + border: 1px solid #233549; + margin-bottom: 10px; + } + + .login-mode-tab { + background: transparent; + border: none; + color: #94a3b8; + font-size: 11.5px; + font-weight: 600; + padding: 6px 8px; + border-radius: 7px; + cursor: pointer; + transition: all 0.15s ease; + } + + .login-mode-tab.active { + background: var(--lucebra-primary); + color: #fff; + box-shadow: 0 2px 8px rgba(19, 127, 236, 0.35); + } + + .lucebra-modal-sub { + font-size: 11.5px; + color: #94a3b8; + line-height: 1.45; + margin-bottom: 12px; + } + + .lucebra-modal-sub a { + color: #38bdf8; + text-decoration: none; + font-weight: 600; + } + + .lucebra-form-group { + margin-bottom: 10px; + } + + .lucebra-form-label { + display: block; + font-size: 11.5px; + font-weight: 600; + color: #cbd5e1; + margin-bottom: 4px; + } + + .lucebra-form-input { + width: 100%; + padding: 8px 11px; + border-radius: 9px; + border: 1px solid #2a3f58; + background: #0b1118; + color: #f8fafc; + font-size: 12.5px; + outline: none; + } + + .lucebra-form-input:focus { + border-color: var(--lucebra-primary); + } + + .lucebra-login-error { + display: none; + background: rgba(239, 68, 68, 0.14); + border: 1px solid rgba(239, 68, 68, 0.35); + color: #fca5a5; + padding: 8px 10px; + border-radius: 8px; + font-size: 11.5px; + margin-bottom: 10px; + } + + .lucebra-login-error.visible { + display: block; + } + + .btn-modal-submit { + width: 100%; + padding: 9px 14px; + border-radius: 9px; + border: none; + background: linear-gradient(135deg, var(--lucebra-primary) 0%, #0284c7 100%); + color: #fff; + font-size: 12.5px; + font-weight: 700; + cursor: pointer; + transition: opacity 0.2s; + } + + .btn-modal-submit:disabled { + opacity: 0.6; + cursor: not-allowed; + } + + .qr-shortcut-wrap { + margin-top: 10px; + border-top: 1px solid rgba(255, 255, 255, 0.08); + padding-top: 10px; + } + + .btn-qr-toggle { + width: 100%; + padding: 7px 10px; + border-radius: 8px; + border: 1px dashed rgba(56, 189, 248, 0.4); + background: rgba(19, 127, 236, 0.08); + color: #38bdf8; + font-size: 11.5px; + font-weight: 600; + cursor: pointer; + display: flex; + align-items: center; + justify-content: center; + gap: 6px; + transition: all 0.2s; + } + + .btn-qr-toggle:hover { + background: rgba(19, 127, 236, 0.18); + color: #fff; + } + + .qr-panel { + display: none; + margin-top: 8px; + padding: 10px; + border-radius: 10px; + background: #0b1118; + border: 1px solid #233549; + text-align: center; + } + + .qr-panel.visible { + display: block; + } + + .qr-code-box { + width: 136px; + height: 136px; + margin: 0 auto 8px auto; + padding: 6px; + background: #fff; + border-radius: 10px; + display: flex; + align-items: center; + justify-content: center; + } + + .qr-code-box img { + width: 124px; + height: 124px; + display: block; + } + + .qr-status-text { + font-size: 11px; + color: #cbd5e1; + line-height: 1.4; + } + + .qr-status-text a { + color: #38bdf8; + text-decoration: none; + font-weight: 600; + } + + .lucebra-modal-footer { + margin-top: 10px; + text-align: center; + font-size: 11px; + color: #94a3b8; + display: flex; + align-items: center; + justify-content: center; + gap: 10px; + flex-wrap: wrap; + } + + .lucebra-modal-footer a { + color: #38bdf8; + text-decoration: none; + font-weight: 600; } - /* Main Widget Section */ .widget-container { display: flex; height: 410px; @@ -99,7 +479,6 @@ background: var(--lucebra-surface); } - /* Left Column: Course Playlist */ .playlist { width: 44%; background: #131c26; @@ -114,6 +493,7 @@ .playlist::-webkit-scrollbar { width: 5px; } + .playlist::-webkit-scrollbar-thumb { background: #233549; border-radius: 4px; @@ -121,7 +501,7 @@ .course-card { display: flex; - gap: 12px; + gap: 10px; padding: 10px; border-radius: 10px; background: var(--lucebra-surface-card); @@ -195,7 +575,7 @@ } .course-title { - font-size: 13px; + font-size: 12.5px; font-weight: 600; color: #f1f5f9; line-height: 1.35; @@ -209,7 +589,8 @@ .course-meta { display: flex; align-items: center; - gap: 6px; + flex-wrap: wrap; + gap: 5px; font-size: 11px; color: var(--lucebra-text-muted); } @@ -222,7 +603,57 @@ font-weight: 600; } - /* Right Column: Video Player and Details */ + .course-price-old { + color: #64748b; + text-decoration: line-through; + font-size: 10.5px; + } + + .course-price-current { + color: var(--lucebra-price); + font-weight: 700; + font-size: 11px; + } + + .course-discount-badge { + background: rgba(52, 211, 153, 0.16); + border: 1px solid rgba(52, 211, 153, 0.35); + color: #34d399; + font-size: 9px; + font-weight: 700; + padding: 1px 4px; + border-radius: 4px; + text-transform: uppercase; + } + + .card-wishlist-btn { + background: rgba(15, 23, 42, 0.65); + border: 1px solid rgba(255, 255, 255, 0.12); + color: #94a3b8; + width: 28px; + height: 28px; + border-radius: 50%; + display: inline-flex; + align-items: center; + justify-content: center; + cursor: pointer; + flex-shrink: 0; + transition: all 0.18s ease; + } + + .card-wishlist-btn:hover { + background: rgba(244, 63, 94, 0.18); + border-color: rgba(244, 63, 94, 0.45); + color: #fb7185; + transform: scale(1.08); + } + + .card-wishlist-btn.saved { + background: rgba(244, 63, 94, 0.2); + border-color: rgba(244, 63, 94, 0.55); + color: #f43f5e; + } + .player-area { width: 56%; display: flex; @@ -250,15 +681,45 @@ width: 26px; height: 26px; pointer-events: none; - z-index: 2; + z-index: 3; opacity: 0.85; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.7)); } - .video-watermark img { - width: 100%; - height: 100%; - object-fit: contain; + .video-unavailable-overlay { + position: absolute; + inset: 0; + z-index: 2; + display: none; + flex-direction: column; + align-items: center; + justify-content: center; + gap: 8px; + padding: 20px; + text-align: center; + background: rgba(11, 17, 24, 0.82); + backdrop-filter: blur(4px); + } + + .video-unavailable-overlay.visible { + display: flex; + } + + .video-unavailable-badge { + background: rgba(19, 127, 236, 0.18); + border: 1px solid rgba(56, 189, 248, 0.35); + color: #e2e8f0; + font-size: 12.5px; + font-weight: 600; + padding: 6px 12px; + border-radius: 8px; + } + + .video-unavailable-sub { + color: var(--lucebra-text-muted); + font-size: 11.5px; + max-width: 280px; + line-height: 1.4; } video { @@ -281,6 +742,7 @@ align-items: center; gap: 10px; overflow: hidden; + flex: 1; } .instructor-avatar { @@ -294,6 +756,7 @@ .instructor-texts { overflow: hidden; + flex: 1; } .active-course-title { @@ -309,7 +772,8 @@ .active-author-row { display: flex; align-items: center; - gap: 4px; + flex-wrap: wrap; + gap: 5px; font-size: 11.5px; color: var(--lucebra-text-muted); } @@ -333,6 +797,7 @@ align-items: center; gap: 6px; box-shadow: 0 4px 12px var(--lucebra-primary-glow); + flex-shrink: 0; } .btn-learn-more:hover { @@ -341,287 +806,1711 @@ box-shadow: 0 6px 16px var(--lucebra-primary-glow); } - /* Bottom Summary (ChatGPT Message Response) */ .chat-prompt-summary { margin-top: 14px; - font-size: 13.5px; + font-size: 13px; color: #cbd5e1; - line-height: 1.55; + line-height: 1.5; } .chat-prompt-summary b { color: #fff; } + + .widget-actions-bar { + display: flex; + align-items: center; + gap: 7px; + flex-wrap: wrap; + margin-top: 14px; + padding-top: 12px; + border-top: 1px solid rgba(255, 255, 255, 0.08); + } + + .action-chip { + background: rgba(255, 255, 255, 0.05); + border: 1px solid rgba(255, 255, 255, 0.12); + color: #e2e8f0; + padding: 6.5px 12px; + border-radius: 8px; + font-size: 11.5px; + font-weight: 500; + display: inline-flex; + align-items: center; + gap: 6px; + cursor: pointer; + transition: all 0.2s ease; + user-select: none; + } + + .action-chip:hover:not(:disabled) { + background: rgba(19, 127, 236, 0.15); + border-color: var(--lucebra-primary); + color: #fff; + transform: translateY(-1px); + } + + .action-chip.saved-chip { + background: rgba(244, 63, 94, 0.16); + border-color: rgba(244, 63, 94, 0.45); + color: #fda4af; + } + + .action-chip:disabled { + opacity: 0.6; + cursor: not-allowed; + } + + .confirm-modal-actions { + display: flex; + gap: 8px; + margin-top: 14px; + } + + .btn-modal-secondary { + flex: 1; + padding: 8px 12px; + border-radius: 8px; + border: 1px solid #2a3f58; + background: #182636; + color: #e2e8f0; + font-size: 12px; + font-weight: 600; + cursor: pointer; + text-align: center; + text-decoration: none; + } + + .btn-modal-secondary:hover { + background: #223448; + color: #fff; + } + + .btn-modal-primary { + flex: 1; + padding: 8px 12px; + border-radius: 8px; + border: none; + background: linear-gradient(135deg, var(--lucebra-primary) 0%, #0284c7 100%); + color: #fff; + font-size: 12px; + font-weight: 700; + cursor: pointer; + text-align: center; + text-decoration: none; + } + + .widget-container { + display: flex; + flex-direction: row; + height: 410px; + border-radius: 14px; + overflow: hidden; + border: 1px solid var(--lucebra-border); + background: var(--lucebra-surface); + } + + .playlist { + width: 44%; + min-width: 0; + background: #131c26; + overflow-y: auto; + border-right: 1px solid var(--lucebra-border); + padding: 10px; + display: flex; + flex-direction: column; + gap: 8px; + } + + .player-area { + width: 56%; + min-width: 0; + display: flex; + flex-direction: column; + background: var(--lucebra-surface); + padding: 14px; + justify-content: space-between; + } + + .course-info { + min-width: 0; + overflow: hidden; + display: flex; + flex-direction: column; + gap: 3px; + flex: 1; + } + + /* Keep side-by-side layout intact across all screen widths (split-view 974px, iPad, Mac) */ + @media (max-width: 990px) { + .chat-bubble-container { + padding: 12px; + } + .widget-container { + height: 390px; + } + .playlist { + width: 45%; + padding: 8px; + gap: 6px; + } + .player-area { + width: 55%; + padding: 10px; + } + .course-card { + padding: 7px 8px; + gap: 8px; + } + .thumb-wrapper { + width: 48px; + height: 48px; + } + .course-title { + font-size: 11.5px; + line-height: 1.3; + } + .course-meta { + font-size: 10px; + gap: 3px; + } + .instructor-avatar { + width: 36px; + height: 36px; + } + .active-course-title { + font-size: 12.5px; + } + .btn-learn-more { + padding: 8px 14px; + font-size: 11.5px; + } + } + + @media (max-width: 640px) { + body { + padding: 6px; + } + .chat-bubble-container { + padding: 10px; + border-radius: 14px; + } + .widget-container { + height: 360px; + } + .playlist { + width: 46%; + padding: 6px; + gap: 5px; + } + .player-area { + width: 54%; + padding: 8px; + } + .video-container { + height: 200px; + } + .course-card { + padding: 6px 7px; + gap: 6px; + } + .thumb-wrapper { + width: 42px; + height: 42px; + } + .course-title { + font-size: 11px; + } + .btn-learn-more { + padding: 7px 10px; + font-size: 11px; + } + .action-chip { + padding: 5px 8px; + font-size: 10.5px; + } + } </style> </head> + <body> - <!-- ChatGPT Response Card --> <div class="chat-bubble-container"> - - <!-- Lucebra Header --> <div class="widget-header"> <div class="brand-left"> - <img class="brand-logo" src="https://api.lucebra.com/medias/invoice/lucebralogo.png" onerror="this.style.display='none';" alt="Lucebra Logo" /> - <span class="brand-tag">Verified Partner</span> + <a href="https://www.lucebra.com" target="_blank" rel="noopener noreferrer" class="brand-logo-link" + title="Lucebra"> + <img src="https://api.lucebra.com/mcp/assets/logo.png" alt="Lucebra" class="brand-logo" /> + </a> + <span class="brand-tag">Course Player</span> + </div> + <div class="header-right"> + <div class="header-info" id="header-course-count">2K+ Courses, Resources & More</div> + <button type="button" class="btn-connect-account" id="btn-connect-account" + title="Connect your Lucebra account to access Wishlist, Learning Progress, Certificates & Business Plan"> + <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2"> + <path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2" /> + <circle cx="12" cy="7" r="4" /> + </svg> + <span>Connect Account</span> + </button> + <div class="user-profile-badge" id="user-profile-badge" title="Connected Lucebra Account"> + <div class="user-badge-avatar-wrap"> + <img id="user-profile-avatar" class="user-badge-avatar" + src="https://api.lucebra.com/mcp/assets/placeholder-avatar.svg" alt="User" /> + <span class="user-badge-dot"></span> + </div> + <span id="user-profile-name" class="user-badge-name">Lucebra Student</span> + <span id="user-profile-plan" class="user-badge-plan"></span> + <button type="button" class="btn-disconnect-account" id="btn-disconnect-account" + title="Disconnect Lucebra account">×</button> + </div> + </div> + </div> + + <!-- Login Modal (Personal + Organization + Mobile QR Shortcut) --> + <div class="lucebra-modal-backdrop" id="lucebra-login-modal"> + <div class="lucebra-modal-card"> + <div class="lucebra-modal-header"> + <div class="lucebra-modal-title"> + <img src="https://api.lucebra.com/mcp/assets/logo.png" alt="Lucebra" style="height: 18px; width: auto;" /> + <span>Connect Account</span> + </div> + <button type="button" class="lucebra-modal-close" id="btn-close-login-modal" title="Close">×</button> + </div> + + <div class="login-mode-tabs"> + <button type="button" class="login-mode-tab active" id="tab-login-personal">Personal Login</button> + <button type="button" class="login-mode-tab" id="tab-login-org">Organization Login</button> + </div> + + <div class="lucebra-modal-sub" id="login-modal-subtitle"> + Sign in with your Lucebra account to unlock instant Wishlist saving, Learning Progress, Certificates, and + Personal/Team Plan enrollment. + </div> + + <div class="lucebra-login-error" id="login-error-banner"></div> + <form id="lucebra-login-form"> + <div class="lucebra-form-group"> + <label class="lucebra-form-label" id="login-email-label" for="login-email-input">Email or Username</label> + <input class="lucebra-form-input" id="login-email-input" type="text" placeholder="you@example.com" required + autocomplete="username" /> + </div> + <div class="lucebra-form-group"> + <label class="lucebra-form-label" for="login-password-input">Password</label> + <input class="lucebra-form-input" id="login-password-input" type="password" placeholder="••••••••" required + autocomplete="current-password" /> + </div> + <button type="submit" class="btn-modal-submit" id="btn-login-submit">Sign In & Connect</button> + </form> + + <div class="qr-shortcut-wrap"> + <button type="button" class="btn-qr-toggle" id="btn-qr-toggle"> + <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> + <rect x="3" y="3" width="7" height="7" /> + <rect x="14" y="3" width="7" height="7" /> + <rect x="14" y="14" width="7" height="7" /> + <rect x="3" y="14" width="7" height="7" /> + </svg> + <span id="txt-qr-toggle">Login with QR Code (Lucebra Mobile App)</span> + </button> + <div class="qr-panel" id="qr-panel"> + <div class="qr-code-box"> + <img id="qr-code-img" src="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='124' height='124'></svg>" alt="Lucebra QR Code" /> + </div> + <div class="qr-status-text" id="qr-status-text"> + Open the <a href="https://www.lucebra.com/mobile-app" target="_blank" rel="noopener noreferrer">Lucebra + Mobile App</a> and scan this barcode to sign in instantly. + </div> + </div> + </div> + + <div class="lucebra-modal-footer"> + <a id="link-web-personal-login" href="https://www.lucebra.com/login?returnUrl=https%3A%2F%2Fchatgpt.com&source=mcp_widget" target="_blank" rel="noopener noreferrer">Personal Web Login →</a> + <span>•</span> + <a id="link-web-org-login" href="https://www.lucebra.com/organizational-login?returnUrl=https%3A%2F%2Fchatgpt.com&source=mcp_widget" target="_blank" rel="noopener noreferrer">Organization Login →</a> + </div> + </div> + </div> + + <!-- In-Widget Wishlist / Plan Confirmation Modal (No Chat Scroll Needed) --> + <div class="lucebra-modal-backdrop" id="lucebra-wishlist-modal"> + <div class="lucebra-modal-card"> + <div class="lucebra-modal-header"> + <div class="lucebra-modal-title" id="wishlist-modal-title">✓ Saved to Your Lucebra Wishlist</div> + <button type="button" class="lucebra-modal-close" id="btn-close-wishlist-modal" title="Close">×</button> + </div> + <div class="lucebra-modal-sub" id="wishlist-modal-desc" style="margin-bottom: 6px; color: #e2e8f0;"> + This course has been updated in your personal Lucebra Wishlist. You can continue browsing and adding other + courses right here. + </div> + <div class="confirm-modal-actions"> + <button type="button" class="btn-modal-secondary" id="btn-wishlist-continue">Continue Browsing</button> + <a id="btn-wishlist-action-link" class="btn-modal-primary" href="https://www.lucebra.com/explore" + target="_blank" rel="noopener noreferrer">Open Course →</a> + </div> </div> - <div class="header-info" id="header-course-count">4 online courses with preview</div> </div> - <!-- Main Interactive Widget --> <div class="widget-container"> - - <!-- Left: Course Playlist --> <div class="playlist" id="course-list"></div> - <!-- Right: Video Player and Information --> <div class="player-area"> <div class="video-container"> <video id="video-player" preload="none" controls playsinline></video> - <div class="video-watermark" title="Lucebra Learning"> - <img src="https://lucebra.com/assets/lucebra-emblem.png" onerror="this.style.display='none';" alt="Lucebra Emblem" /> + <div id="video-unavailable-overlay" class="video-unavailable-overlay"> + <div class="video-unavailable-badge" id="video-unavailable-title">Preview not available</div> + <div class="video-unavailable-sub" id="video-unavailable-desc">Video preview is not available for this + course. Click "Learn More" below to inspect the full syllabus.</div> + </div> + <div class="video-watermark" title="Course Preview"> + <svg width="24" height="24" viewBox="0 0 24 24" fill="none"> + <rect width="24" height="24" rx="6" fill="#137fec" fill-opacity="0.85" /> + <path d="M9.5 7.5v9l7-4.5-7-4.5z" fill="#fff" /> + </svg> </div> </div> <div class="player-footer"> <div class="instructor-box"> - <img id="instructor-img" class="instructor-avatar" onerror="this.onerror=null; this.src=placeholderAvatar;" src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Ccircle cx='60' cy='60' r='60' fill='%23223448'/%3E%3Ccircle cx='60' cy='45' r='20' fill='%2394a3b8'/%3E%3Cpath d='M30 100c0-16.5 13.5-30 30-30s30 13.5 30 30' fill='%2394a3b8'/%3E%3C/svg%3E" alt="Instructor" /> + <img id="instructor-img" class="instructor-avatar" + src="https://api.lucebra.com/mcp/assets/placeholder-avatar.svg" alt="Instructor" /> <div class="instructor-texts"> <div id="active-title" class="active-course-title">Select a course</div> <div class="active-author-row"> <span id="active-author">Lucebra Instructor</span> <span class="verified-icon"> <svg width="13" height="13" viewBox="0 0 24 24" fill="currentColor"> - <path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"/> + <path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" /> </svg> </span> - <span>•</span> - <span id="active-students" style="color: #94a3b8;">12,400+ students</span> + <span id="active-students-dot" style="display: none;">•</span> + <span id="active-students" style="color: #94a3b8; display: none;"></span> </div> </div> </div> - <!-- Main Lucebra Action Button --> - <a id="learn-btn" class="btn-learn-more" href="https://lucebra.com" target="_blank" rel="noopener noreferrer"> + <a id="learn-btn" class="btn-learn-more" href="https://www.lucebra.com/explore" target="_blank" + rel="noopener noreferrer"> <span>Learn More</span> <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"> - <path d="M5 12h14M12 5l7 7-7 7"/> + <path d="M5 12h14M12 5l7 7-7 7" /> </svg> </a> </div> </div> + </div> + <div class="widget-actions-bar" id="widget-actions-bar"> + <button type="button" class="action-chip" id="btn-show-curriculum" title="View curriculum of the selected course"> + <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> + <path d="M4 6h16M4 12h16M4 18h7" /> + </svg> + <span>View Curriculum</span> + </button> + <button type="button" class="action-chip" id="btn-compare-courses" title="Compare courses"> + <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> + <path d="M16 3h5v5M4 20L21 3M21 16v5h-5M15 15l6 6M4 4l5 5" /> + </svg> + <span>Compare Courses</span> + </button> + <button type="button" class="action-chip" id="btn-course-price" title="Check course price and active discounts"> + <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> + <line x1="12" y1="1" x2="12" y2="23" /> + <path d="M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6" /> + </svg> + <span>Course Price</span> + </button> + <button type="button" class="action-chip" id="btn-instructor-info" + title="View instructor profile, photo, and published courses"> + <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> + <path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2" /> + <circle cx="12" cy="7" r="4" /> + </svg> + <span>Instructor Info</span> + </button> + <button type="button" class="action-chip" id="btn-save-wishlist" + title="Instantly add or toggle this course in your Lucebra Wishlist right inside the widget"> + <svg id="svg-wishlist-heart" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> + <path + d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z" /> + </svg> + <span id="txt-wishlist">Add to Wishlist</span> + </button> + <button type="button" class="action-chip" id="btn-my-wishlist" title="View your saved Lucebra wishlist"> + <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> + <path d="M19 21l-7-5-7 5V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z" /> + </svg> + <span>My Wishlist</span> + </button> + <button type="button" class="action-chip" id="btn-my-progress" + title="Check your enrolled learning progress & Play Now links"> + <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> + <path d="M12 20V10M18 20V4M6 20v-4" /> + </svg> + <span>My Progress</span> + </button> + <button type="button" class="action-chip" id="btn-my-certificates" title="View your earned certificates"> + <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> + <circle cx="12" cy="8" r="7" /> + <polyline points="8.21 13.89 7 23 12 20 17 23 15.79 13.88" /> + </svg> + <span>My Certificates</span> + </button> + <button type="button" class="action-chip" id="btn-business-access" + title="Check Personal Plan, Team Plan, or Enterprise LMS status, assigned courses & deadlines"> + <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> + <rect x="2" y="7" width="20" height="14" rx="2" ry="2" /> + <path d="M16 21V5a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16" /> + </svg> + <span>Business / Plan</span> + </button> + <button type="button" class="action-chip" id="btn-enroll-plan" + title="Immediately enroll in this course for $0.00 under your Personal Plan, Team Plan, or Enterprise LMS"> + <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> + <polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2" /> + </svg> + <span>Enroll with Plan</span> + </button> + <button type="button" class="action-chip" id="btn-practice-exams" + title="Explore Lucebra Exam Center certification exams"> + <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> + <path d="M9 11l3 3L22 4" /> + <path d="M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11" /> + </svg> + <span>Practice Exams</span> + </button> + <button type="button" class="action-chip" id="btn-digital-products" + title="Browse Digital Products (eBooks, audio, kits)"> + <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> + <path d="M4 19.5A2.5 2.5 0 0 1 6.5 17H20" /> + <path d="M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z" /> + </svg> + <span>Digital Products</span> + </button> + <button type="button" class="action-chip" id="btn-live-sessions" title="View upcoming live webinars and sessions"> + <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> + <polygon points="23 7 16 12 23 17 23 7" /> + <rect x="1" y="5" width="15" height="14" rx="2" ry="2" /> + </svg> + <span>Live Sessions</span> + </button> + <button type="button" class="action-chip" id="btn-plans-pricing" + title="Explain Lucebra Personal, Team and Enterprise plans, differences, and current pricing"> + <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> + <rect x="2" y="5" width="20" height="14" rx="2" /> + <line x1="2" y1="10" x2="22" y2="10" /> + </svg> + <span>Plans & Pricing</span> + </button> + <button type="button" class="action-chip" id="btn-get-app" + title="Download the Lucebra Mobile App for iOS and Android"> + <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> + <rect x="5" y="2" width="14" height="20" rx="2" ry="2" /> + <line x1="12" y1="18" x2="12.01" y2="18" /> + </svg> + <span>Get the App</span> + </button> + <button type="button" class="action-chip" id="btn-spotlight-daily" + title="Discover instructors and short course videos on Lucebra Spotlight Daily"> + <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> + <circle cx="12" cy="12" r="10" /> + <polygon points="10 8 16 12 10 16 10 8" /> + </svg> + <span>Spotlight Daily</span> + </button> + <button type="button" class="action-chip" id="btn-write-articles" + title="Write and publish technical articles and guides on Lucebra"> + <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> + <path d="M12 20h9" /> + <path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z" /> + </svg> + <span>Write Articles</span> + </button> </div> - <!-- ChatGPT Summary Section --> <div class="chat-prompt-summary" id="chat-summary-text"> - I found the best-rated courses on <b>Lucebra</b> for you. You can preview introductory video lessons directly in the player above or click <b>Learn More</b> to explore curriculum and certification. + Preview video lessons above, click the heart (♡) icon on any course to save it directly to your Wishlist, or tap + the quick actions below. </div> - </div> <script> - // Global error safety handlers for headless scanner and sandboxed iframe environments - window.onerror = function() { return true; }; - window.onunhandledrejection = function(e) { if (e && e.preventDefault) e.preventDefault(); }; - - const placeholderThumb = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200' viewBox='0 0 200 200'%3E%3Crect width='200' height='200' fill='%231c2a3a'/%3E%3Cpath d='M80 65v70l55-35z' fill='%23137fec'/%3E%3Ctext x='50%25' y='85%25' dominant-baseline='middle' text-anchor='middle' fill='%2394a3b8' font-family='sans-serif' font-size='12'%3ELucebra Course%3C/text%3E%3C/svg%3E"; - const placeholderAvatar = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Ccircle cx='60' cy='60' r='60' fill='%23223448'/%3E%3Ccircle cx='60' cy='45' r='20' fill='%2394a3b8'/%3E%3Cpath d='M30 100c0-16.5 13.5-30 30-30s30 13.5 30 30' fill='%2394a3b8'/%3E%3C/svg%3E"; - - // Initial dynamic courses (injected dynamically by server or populated via ChatGPT toolOutput) - let currentCourses = []; - - function renderPlaylist(courses) { - if (!courses || !Array.isArray(courses)) return; - currentCourses = courses; - - const container = document.getElementById("course-list"); - container.innerHTML = ""; - - const countHeader = document.getElementById("header-course-count"); - if (countHeader) { - countHeader.innerText = courses.length > 0 - ? `${courses.length} online course${courses.length > 1 ? "s" : ""} with preview` - : "No courses found"; - } - - if (courses.length === 0) { - container.innerHTML = ` - <div style="padding: 32px 16px; text-align: center; color: var(--text-muted); font-size: 13px;"> - <p style="margin: 0 0 10px 0;">No matching courses found for this query.</p> - <a href="https://lucebra.com/courses" target="_blank" style="color: var(--primary); text-decoration: underline; font-weight: 500;"> - Explore All Courses on Lucebra → - </a> - </div> - `; - document.getElementById("active-title").innerText = "Discover Courses on Lucebra"; - document.getElementById("active-author").innerText = "Lucebra"; - document.getElementById("active-students").innerText = "Learn in-demand skills"; - document.getElementById("learn-btn").href = "https://lucebra.com/courses"; - return; - } - - courses.forEach((item, index) => { - const card = document.createElement("div"); - card.className = "course-card " + (index === 0 ? "active" : ""); - const thumb = item.thumbnail || placeholderThumb; - const author = item.author || "Lucebra Instructor"; - const rating = item.rating || "4.8"; - - card.innerHTML = ` - <div class="thumb-wrapper"> - <img src="${thumb}" alt="Thumbnail" /> - <div class="thumb-play-icon"> - <svg width="16" height="16" viewBox="0 0 24 24" fill="#fff"> - <path d="M8 5v14l11-7z"/> - </svg> - </div> - </div> - <div class="course-info"> - <div class="course-title">${item.title || "Course"}</div> - <div class="course-meta"> - <span>${author}</span> - <span>•</span> - <span class="course-rating">★ ${rating}</span> - </div> - </div> - `; - card.onclick = () => selectCourse(index, courses, true); - container.appendChild(card); - }); - - selectCourse(0, courses, false); - } - - function selectCourse(index, courses, shouldPlay = false) { - const course = courses[index]; - if (!course) return; - - document.querySelectorAll(".course-card").forEach((card, idx) => { - card.classList.toggle("active", idx === index); - }); - - const player = document.getElementById("video-player"); - if (player) { - player.onerror = () => { - if (player.src && player.src.includes("cdn.lucebra.com/medias/")) { - player.src = player.src.replace("cdn.lucebra.com/medias/", "storagelucebra.blob.core.windows.net/medias/"); - player.load(); + (() => { + const placeholderThumb = "https://api.lucebra.com/mcp/assets/placeholder-thumb.svg"; + const placeholderAvatar = "https://api.lucebra.com/mcp/assets/placeholder-avatar.svg"; + + function sanitizeMediaUrl(rawUrl, fallback = "") { + if (!rawUrl || typeof rawUrl !== "string") return fallback; + const trimmed = rawUrl.trim(); + try { + const base = (window.location.origin && window.location.origin !== "null" && window.location.origin.startsWith("http")) + ? window.location.origin + : "https://api.lucebra.com"; + const parsed = new URL(trimmed, base); + if (parsed.protocol === "https:") { + return parsed.href; } - return true; - }; - if (course.thumbnail) { - player.poster = course.thumbnail; - } - if (course.previewVideoUrl && course.previewVideoUrl.trim() !== "") { - let vUrl = course.previewVideoUrl.trim(); - if (vUrl.includes("cdn.lucebra.com/medias/")) { - vUrl = vUrl.replace("cdn.lucebra.com/medias/", "storagelucebra.blob.core.windows.net/medias/"); - } - player.src = vUrl; - player.preload = "metadata"; - if (shouldPlay) { - try { - player.play().catch(() => {}); - } catch(e) {} + } catch (e) { } + return fallback; + } + + function sanitizeWebUrl(rawUrl, fallback = "https://www.lucebra.com/explore") { + if (!rawUrl || typeof rawUrl !== "string") return fallback; + try { + const parsed = new URL(rawUrl.trim()); + if (parsed.protocol === "https:") { + return parsed.href; } + } catch (e) { } + return fallback; + } + + function setVideoUnavailableState(isUnavailable, messageTitle, messageDesc) { + const overlay = document.getElementById("video-unavailable-overlay"); + const titleEl = document.getElementById("video-unavailable-title"); + const descEl = document.getElementById("video-unavailable-desc"); + if (!overlay) return; + if (isUnavailable) { + if (titleEl) titleEl.textContent = messageTitle || "Preview not available"; + if (descEl) descEl.textContent = messageDesc || "Video preview is not available for this course. Click \"Learn More\" below to inspect the full syllabus."; + overlay.classList.add("visible"); } else { + overlay.classList.remove("visible"); + } + } + + let currentCourses = []; + let currentActiveIndex = 0; + let currentAuthUser = null; + let pendingWishlistCourse = null; + const wishlistSavedCourseIds = new Set(); + + function clearVideoAndMetadata() { + const player = document.getElementById("video-player"); + if (player) { + try { player.pause(); } catch (e) { } player.removeAttribute("src"); + player.removeAttribute("poster"); player.load(); } + setVideoUnavailableState(true, "No course selected", "Select or search for a course to watch its lesson preview."); + const activeTitle = document.getElementById("active-title"); + if (activeTitle) activeTitle.textContent = "Discover Courses on Lucebra"; + const activeAuthor = document.getElementById("active-author"); + if (activeAuthor) activeAuthor.textContent = "Lucebra Instructor"; + const instructorImg = document.getElementById("instructor-img"); + if (instructorImg) instructorImg.src = placeholderAvatar; + const emptyStudents = document.getElementById("active-students"); + if (emptyStudents) { + emptyStudents.textContent = ""; + emptyStudents.style.display = "none"; + } + const emptyDot = document.getElementById("active-students-dot"); + if (emptyDot) emptyDot.style.display = "none"; + const learnBtn = document.getElementById("learn-btn"); + if (learnBtn) learnBtn.href = "https://www.lucebra.com/explore"; + updateWishlistButtonState(null); } - document.getElementById("active-title").innerText = course.title || "Course"; - document.getElementById("active-author").innerText = course.author || "Lucebra Instructor"; - document.getElementById("active-students").innerText = course.students || "10,000+ students"; - - const instructorImg = document.getElementById("instructor-img"); - if (course.instructorPhoto && course.instructorPhoto.trim() !== "" && !course.instructorPhoto.includes("default-avatar.png")) { - instructorImg.onerror = function() { - this.onerror = null; - this.src = placeholderAvatar; - }; - instructorImg.src = course.instructorPhoto; - } else { - instructorImg.src = placeholderAvatar; + function showInWidgetNotificationModal(title, desc, actionLabel, actionHref) { + const modal = document.getElementById("lucebra-wishlist-modal"); + const titleEl = document.getElementById("wishlist-modal-title"); + const descEl = document.getElementById("wishlist-modal-desc"); + const linkEl = document.getElementById("btn-wishlist-action-link"); + if (!modal) return; + if (titleEl) titleEl.textContent = title || "✓ Updated"; + if (descEl) descEl.textContent = desc || ""; + if (linkEl) { + linkEl.textContent = actionLabel || "Open on Lucebra →"; + linkEl.href = sanitizeWebUrl(actionHref, "https://www.lucebra.com/explore"); + } + modal.classList.add("visible"); } - - const learnBtn = document.getElementById("learn-btn"); - learnBtn.href = course.url || `https://lucebra.com/courses/${course.id || ""}`; - } - // Initial render - if (currentCourses.length > 0) { - renderPlaylist(currentCourses); - } + function updateWishlistButtonState(courseId) { + const btnWishlist = document.getElementById("btn-save-wishlist"); + const txtWishlist = document.getElementById("txt-wishlist"); + const svgWishlist = document.getElementById("svg-wishlist-heart"); + if (btnWishlist && txtWishlist) { + if (!courseId) { + btnWishlist.disabled = true; + btnWishlist.classList.remove("saved-chip"); + txtWishlist.textContent = "Add to Wishlist"; + if (svgWishlist) svgWishlist.setAttribute("fill", "none"); + } else if (wishlistSavedCourseIds.has(String(courseId))) { + btnWishlist.disabled = false; + btnWishlist.classList.add("saved-chip"); + txtWishlist.textContent = "Saved in Wishlist"; + if (svgWishlist) svgWishlist.setAttribute("fill", "currentColor"); + } else { + btnWishlist.disabled = false; + btnWishlist.classList.remove("saved-chip"); + txtWishlist.textContent = "Add to Wishlist"; + if (svgWishlist) svgWishlist.setAttribute("fill", "none"); + } + } - // Notify host that MCP UI iframe is ready - function notifyHostReady() { - try { - if (window.parent && window.parent !== window) { - window.parent.postMessage({ jsonrpc: "2.0", method: "ui/initialize" }, "*"); + document.querySelectorAll(".card-wishlist-btn").forEach((btn) => { + const cid = btn.getAttribute("data-course-id"); + const isSaved = cid && wishlistSavedCourseIds.has(String(cid)); + btn.classList.toggle("saved", Boolean(isSaved)); + btn.title = isSaved ? "Saved in your Lucebra Wishlist (Click to remove)" : "Add to your Lucebra Wishlist"; + btn.innerHTML = isSaved + ? '<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor" stroke="currentColor" stroke-width="2"><path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"/></svg>' + : '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"/></svg>'; + }); + } + + async function fetchSavedWishlistIds() { + if (!currentAuthUser) return; + try { + const res = await fetch("https://api.lucebra.com/mcp/widget-wishlist/ids", { + method: "GET", + headers: { "Accept": "application/json" } + }); + if (!res.ok) return; + const data = await res.json(); + const idList = data ? (Array.isArray(data.courseIds) ? data.courseIds : (Array.isArray(data.ids) ? data.ids : null)) : null; + if (idList) { + wishlistSavedCourseIds.clear(); + idList.forEach((id) => wishlistSavedCourseIds.add(String(id))); + const active = currentCourses[currentActiveIndex] || currentCourses[0]; + updateWishlistButtonState(active ? active.id : null); + } + } catch (e) { } + } + + async function toggleCourseWishlistInstant(course) { + if (!course || !course.id) return; + if (!currentAuthUser) { + pendingWishlistCourse = course; + const loginModal = document.getElementById("lucebra-login-modal"); + if (loginModal) loginModal.classList.add("visible"); + return; } - } catch (e) {} - } - if (document.readyState === "loading") { - document.addEventListener("DOMContentLoaded", notifyHostReady); - } else { - notifyHostReady(); - } + const summaryEl = document.getElementById("chat-summary-text"); + try { + const res = await fetch("https://api.lucebra.com/mcp/widget-wishlist/toggle", { + method: "POST", + headers: { "Content-Type": "application/json", "Accept": "application/json" }, + body: JSON.stringify({ courseId: String(course.id) }) + }); + const data = await res.json(); + if (res.status === 401 || (data && data.requiresLogin)) { + pendingWishlistCourse = course; + const loginModal = document.getElementById("lucebra-login-modal"); + if (loginModal) loginModal.classList.add("visible"); + return; + } - // ChatGPT Apps postMessage and MCP Apps protocol bridge - window.addEventListener("message", (event) => { - const payload = event.data; - if (!payload) return; + if (res.ok && data && data.success) { + const cid = String(data.courseId || course.id); + if (data.saved) { + wishlistSavedCourseIds.add(cid); + showInWidgetNotificationModal( + "♥ Added to Your Lucebra Wishlist", + `"${data.courseTitle || course.title}" (${data.discountPrice || data.price || course.discountPrice || course.price || ""}) has been saved to your Wishlist. You can continue adding more courses right here without leaving the player.`, + "View Course Page →", + data.courseUrl || course.url + ); + if (summaryEl) { + summaryEl.textContent = `✓ Saved "${data.courseTitle || course.title}" to your Lucebra Wishlist.`; + } + } else { + wishlistSavedCourseIds.delete(cid); + if (summaryEl) { + summaryEl.textContent = `Removed "${data.courseTitle || course.title}" from your Lucebra Wishlist.`; + } + } + const active = currentCourses[currentActiveIndex] || currentCourses[0]; + updateWishlistButtonState(active ? active.id : null); + } + } catch (e) { + if (summaryEl) { + summaryEl.textContent = "Could not update wishlist right now. Please try again."; + } + } + } - // 1. MCP Apps standard tool-result notification - if (payload.method === "ui/notifications/tool-result") { - const sc = payload.params?.structuredContent || payload.params; - const list = sc?.courses || sc?.courseList || (Array.isArray(sc) ? sc : null); - if (list && Array.isArray(list) && list.length > 0) { - renderPlaylist(list); + async function enrollInCourseWithPlanInstant(course) { + if (!course || !course.id) return; + if (!currentAuthUser) { + const loginModal = document.getElementById("lucebra-login-modal"); + if (loginModal) loginModal.classList.add("visible"); + return; + } + + const summaryEl = document.getElementById("chat-summary-text"); + try { + const res = await fetch("https://api.lucebra.com/mcp/widget-business/enroll", { + method: "POST", + headers: { "Content-Type": "application/json", "Accept": "application/json" }, + body: JSON.stringify({ courseId: String(course.id) }) + }); + const data = await res.json(); + if (res.status === 401 || (data && data.requiresLogin)) { + const loginModal = document.getElementById("lucebra-login-modal"); + if (loginModal) loginModal.classList.add("visible"); + return; + } + + if (res.ok && data && data.enrolled) { + const modalTitle = data.alreadyAssignedByOrganization + ? "✓ Assigned to Your Enterprise LMS Account" + : "⚡ Enrolled via Your Lucebra Plan ($0.00)"; + const actionLabel = data.actionLabel || (data.alreadyAssignedByOrganization ? "Continue on Enterprise LMS →" : "▶ Play Now →"); + const actionHref = data.playNowUrl || "https://www.student.lucebra.com/"; + + showInWidgetNotificationModal( + modalTitle, + data.message || `You can start or continue "${data.courseTitle || course.title}" right away.`, + actionLabel, + actionHref + ); + if (summaryEl) { + summaryEl.textContent = data.alreadyAssignedByOrganization + ? `✓ "${data.courseTitle || course.title}" is assigned to your Enterprise LMS account.` + : `✓ Enrolled in "${data.courseTitle || course.title}" under your plan.`; + } + } else if (data && data.isUnassignedEnterpriseCourse) { + showInWidgetNotificationModal( + "Enterprise LMS — Course Not Assigned by Company", + data.message || `You are an Enterprise LMS member, and "${data.courseTitle || course.title}" is not currently assigned by your organization. To get this course for your own personal account, open its course page below.`, + data.actionLabel || "Open Course Page →", + data.courseUrl || course.url || "https://www.lucebra.com/explore" + ); + if (summaryEl) { + summaryEl.textContent = `"${data.courseTitle || course.title}" is not assigned by your organization. Open the course page to get it for your own account.`; + } + } else { + showInWidgetNotificationModal( + "No Active Business Membership Found", + (data && data.message) ? data.message : "Your account does not currently have an active Business or subscription plan (Personal, Team, or Enterprise LMS). Switch to a Lucebra Business plan to unlock included access.", + "Explore Lucebra Business →", + (data && data.businessUrl) ? data.businessUrl : "https://www.lucebra.com/lucebra-business" + ); + } + } catch (e) { } + } + + function renderPlaylist(courses) { + if (!courses || !Array.isArray(courses)) return; + currentCourses = courses; + + const container = document.getElementById("course-list"); + if (!container) return; + container.replaceChildren(); + + const countHeader = document.getElementById("header-course-count"); + if (countHeader) { + countHeader.textContent = "2K+ Courses, Resources & More"; + } + + if (courses.length === 0) { + const emptyBox = document.createElement("div"); + emptyBox.style.cssText = "padding: 32px 16px; text-align: center; color: var(--lucebra-text-muted); font-size: 13px;"; + + const p = document.createElement("p"); + p.style.cssText = "margin: 0 0 10px 0;"; + p.textContent = "No matching courses found for this query."; + + const link = document.createElement("a"); + link.href = "https://www.lucebra.com/explore"; + link.target = "_blank"; + link.rel = "noopener noreferrer"; + link.style.cssText = "color: var(--lucebra-primary-light); text-decoration: underline; font-weight: 500;"; + link.textContent = "Explore All Courses on Lucebra →"; + + emptyBox.appendChild(p); + emptyBox.appendChild(link); + container.appendChild(emptyBox); + + clearVideoAndMetadata(); return; } + + courses.forEach((item, index) => { + const card = document.createElement("div"); + card.className = "course-card" + (index === 0 ? " active" : ""); + + const thumbWrapper = document.createElement("div"); + thumbWrapper.className = "thumb-wrapper"; + + const thumbImg = document.createElement("img"); + thumbImg.alt = "Course Thumbnail"; + thumbImg.src = sanitizeMediaUrl(item.thumbnail, placeholderThumb); + thumbImg.onerror = function () { + this.onerror = null; + this.src = placeholderThumb; + }; + + const playIcon = document.createElement("div"); + playIcon.className = "thumb-play-icon"; + const svgEl = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + svgEl.setAttribute("width", "16"); + svgEl.setAttribute("height", "16"); + svgEl.setAttribute("viewBox", "0 0 24 24"); + svgEl.setAttribute("fill", "#fff"); + const pathEl = document.createElementNS("http://www.w3.org/2000/svg", "path"); + pathEl.setAttribute("d", "M8 5v14l11-7z"); + svgEl.appendChild(pathEl); + playIcon.appendChild(svgEl); + + thumbWrapper.appendChild(thumbImg); + thumbWrapper.appendChild(playIcon); + + const infoDiv = document.createElement("div"); + infoDiv.className = "course-info"; + + const titleDiv = document.createElement("div"); + titleDiv.className = "course-title"; + titleDiv.textContent = item.title || "Course"; + + const metaDiv = document.createElement("div"); + metaDiv.className = "course-meta"; + + const authorSpan = document.createElement("span"); + authorSpan.textContent = item.author || "Lucebra Instructor"; + + const dotSpan = document.createElement("span"); + dotSpan.textContent = "•"; + + const ratingSpan = document.createElement("span"); + ratingSpan.className = "course-rating"; + ratingSpan.textContent = `★ ${item.rating || "5.0"}`; + + metaDiv.appendChild(authorSpan); + metaDiv.appendChild(dotSpan); + metaDiv.appendChild(ratingSpan); + + let rawPrice = ""; + if (typeof item.price === "number") { + rawPrice = item.price <= 0 ? "Free" : `$${item.price.toFixed(2)}`; + } else if (typeof item.price === "string") { + rawPrice = item.price.trim(); + } + + let rawDisc = ""; + if (typeof item.discountPrice === "number" && item.discountPrice > 0) { + rawDisc = `$${item.discountPrice.toFixed(2)}`; + } else if (typeof item.discountPrice === "string" && item.discountPrice.trim() !== "") { + rawDisc = item.discountPrice.trim(); + } + + const hasDisc = Boolean((item.hasDiscount || rawDisc) && rawDisc && rawDisc !== rawPrice); + + if (rawPrice) { + const priceDot = document.createElement("span"); + priceDot.textContent = "•"; + metaDiv.appendChild(priceDot); + + if (hasDisc) { + const oldPriceSpan = document.createElement("span"); + oldPriceSpan.className = "course-price-old"; + oldPriceSpan.textContent = rawPrice; + metaDiv.appendChild(oldPriceSpan); + + const curPriceSpan = document.createElement("span"); + curPriceSpan.className = "course-price-current"; + curPriceSpan.textContent = rawDisc; + metaDiv.appendChild(curPriceSpan); + + const discBadge = document.createElement("span"); + discBadge.className = "course-discount-badge"; + discBadge.textContent = "SALE"; + metaDiv.appendChild(discBadge); + } else { + const curPriceSpan = document.createElement("span"); + curPriceSpan.className = "course-price-current"; + curPriceSpan.textContent = rawPrice; + metaDiv.appendChild(curPriceSpan); + } + } + + infoDiv.appendChild(titleDiv); + infoDiv.appendChild(metaDiv); + + const heartBtn = document.createElement("button"); + heartBtn.type = "button"; + heartBtn.className = "card-wishlist-btn"; + heartBtn.setAttribute("data-course-id", String(item.id || "")); + heartBtn.onclick = (ev) => { + ev.stopPropagation(); + toggleCourseWishlistInstant(item); + }; + + card.appendChild(thumbWrapper); + card.appendChild(infoDiv); + card.appendChild(heartBtn); + + card.onclick = () => selectCourse(index, courses, true); + container.appendChild(card); + }); + + selectCourse(0, courses, false); + } + + function selectCourse(index, courses, shouldPlay = false) { + const course = courses[index]; + if (!course) return; + currentActiveIndex = index; + updateWishlistButtonState(course.id); + + document.querySelectorAll(".course-card").forEach((card, idx) => { + card.classList.toggle("active", idx === index); + }); + + const player = document.getElementById("video-player"); + const safeThumb = sanitizeMediaUrl(course.thumbnail, placeholderThumb); + const safePreviewUrl = sanitizeMediaUrl(course.previewVideoUrl, ""); + + if (player) { + player.onerror = () => { + setVideoUnavailableState( + true, + "Preview not available", + "Video preview is not available for this course. Click \"Learn More\" below to inspect the full syllabus." + ); + return true; + }; + + if (safeThumb) { + player.poster = safeThumb; + } else { + player.removeAttribute("poster"); + } + + if (safePreviewUrl) { + setVideoUnavailableState(false); + player.src = safePreviewUrl; + player.preload = "metadata"; + if (shouldPlay) { + try { + player.play().catch(() => { }); + } catch (e) { } + } + } else { + try { player.pause(); } catch (e) { } + player.removeAttribute("src"); + player.load(); + setVideoUnavailableState( + true, + "Preview not available", + "Video preview is not available for this course. Click \"Learn More\" below to inspect the full syllabus." + ); + } + } + + const activeTitle = document.getElementById("active-title"); + if (activeTitle) activeTitle.textContent = course.title || "Course"; + const activeAuthor = document.getElementById("active-author"); + if (activeAuthor) activeAuthor.textContent = course.author || "Lucebra Instructor"; + + const studentsEl = document.getElementById("active-students"); + const studentsDot = document.getElementById("active-students-dot"); + if (studentsEl) { + if (course.students && typeof course.students === "string" && course.students.trim() !== "") { + studentsEl.textContent = course.students.trim(); + studentsEl.style.display = "inline"; + if (studentsDot) studentsDot.style.display = "inline"; + } else { + studentsEl.textContent = ""; + studentsEl.style.display = "none"; + if (studentsDot) studentsDot.style.display = "none"; + } + } + + const instructorImg = document.getElementById("instructor-img"); + if (instructorImg) { + const safeAvatar = sanitizeMediaUrl(course.instructorPhoto, placeholderAvatar); + instructorImg.onerror = function () { + this.onerror = null; + this.src = placeholderAvatar; + }; + instructorImg.src = safeAvatar; + } + + const learnBtn = document.getElementById("learn-btn"); + if (learnBtn) { + learnBtn.href = sanitizeWebUrl(course.url, `https://www.lucebra.com/courses/${encodeURIComponent(course.id || "")}`); + } } - // 2. Standard ChatGPT / JSON-RPC result formats - const list = payload.result?.structuredContent?.courses - || payload.result?.courses - || payload.courses - || payload.data?.courses; + let qrCheckTimer = null; + let qrCheckAttempts = 0; - if (list && Array.isArray(list) && list.length > 0) { - renderPlaylist(list); + function stopQrCheckTimer() { + if (qrCheckTimer) { + clearInterval(qrCheckTimer); + qrCheckTimer = null; + } + qrCheckAttempts = 0; } - }); - // OpenAI Apps SDK direct window.openai hook and live toolOutput - if (window.openai?.toolOutput) { - const initialList = window.openai.toolOutput.structuredContent?.courses || window.openai.toolOutput.courses; - if (initialList && Array.isArray(initialList) && initialList.length > 0) { - renderPlaylist(initialList); + function renderUserAuthState(userObj) { + currentAuthUser = userObj || null; + const btnConnect = document.getElementById("btn-connect-account"); + const badge = document.getElementById("user-profile-badge"); + const avatarImg = document.getElementById("user-profile-avatar"); + const nameSpan = document.getElementById("user-profile-name"); + const planSpan = document.getElementById("user-profile-plan"); + const loginModal = document.getElementById("lucebra-login-modal"); + + if (userObj && (userObj.fullName || userObj.email || userObj.userId)) { + if (btnConnect) btnConnect.style.display = "none"; + if (badge) badge.classList.add("visible"); + if (nameSpan) nameSpan.textContent = userObj.fullName || userObj.email || "Lucebra Student"; + if (planSpan) { + const acctType = userObj.accountType || ""; + if (acctType && acctType !== "Personal") { + planSpan.textContent = acctType; + planSpan.classList.add("visible"); + } else { + planSpan.textContent = ""; + planSpan.classList.remove("visible"); + } + } + if (avatarImg) { + const safePhoto = sanitizeMediaUrl(userObj.profilePhoto, placeholderAvatar); + avatarImg.onerror = function () { + this.onerror = null; + this.src = placeholderAvatar; + }; + avatarImg.src = safePhoto; + } + + // Immediately auto-close the login modal & stop QR timer whenever authenticated + if (loginModal && loginModal.classList.contains("visible")) { + loginModal.classList.remove("visible"); + } + stopQrCheckTimer(); + fetchSavedWishlistIds(); + + if (pendingWishlistCourse) { + const targetCourse = pendingWishlistCourse; + pendingWishlistCourse = null; + toggleCourseWishlistInstant(targetCourse); + } + } else { + if (btnConnect) btnConnect.style.display = "inline-flex"; + if (badge) badge.classList.remove("visible"); + if (planSpan) { + planSpan.textContent = ""; + planSpan.classList.remove("visible"); + } + wishlistSavedCourseIds.clear(); + const active = currentCourses[currentActiveIndex] || currentCourses[0]; + updateWishlistButtonState(active ? active.id : null); + } } - } - if (window.openai?.onToolOutput) { - window.openai.onToolOutput((output) => { - const list = output?.structuredContent?.courses || output?.courses; - if (list && Array.isArray(list) && list.length > 0) { + async function checkWidgetAuthStatus() { + try { + const res = await fetch("https://api.lucebra.com/mcp/widget-auth/status", { + method: "GET", + headers: { "Accept": "application/json" } + }); + if (!res.ok) return; + const data = await res.json(); + if (data && data.authenticated) { + renderUserAuthState(data.user || { + userId: data.userId, + fullName: data.fullName, + email: data.email, + profilePhoto: data.profilePhoto, + accountType: data.accountType + }); + } else { + renderUserAuthState(null); + } + } catch (e) { } + } + + function setupModals() { + const btnConnect = document.getElementById("btn-connect-account"); + const modal = document.getElementById("lucebra-login-modal"); + const btnClose = document.getElementById("btn-close-login-modal"); + const form = document.getElementById("lucebra-login-form"); + const emailInput = document.getElementById("login-email-input"); + const emailLabel = document.getElementById("login-email-label"); + const passInput = document.getElementById("login-password-input"); + const errorBanner = document.getElementById("login-error-banner"); + const btnSubmit = document.getElementById("btn-login-submit"); + const btnDisconnect = document.getElementById("btn-disconnect-account"); + const summaryEl = document.getElementById("chat-summary-text"); + + const tabPersonal = document.getElementById("tab-login-personal"); + const tabOrg = document.getElementById("tab-login-org"); + const subtitleEl = document.getElementById("login-modal-subtitle"); + + const btnQrToggle = document.getElementById("btn-qr-toggle"); + const qrPanel = document.getElementById("qr-panel"); + const qrImg = document.getElementById("qr-code-img"); + const qrStatusText = document.getElementById("qr-status-text"); + + let selectedLoginType = "personal"; + + const setLoginTab = (mode) => { + selectedLoginType = mode; + if (tabPersonal) tabPersonal.classList.toggle("active", mode === "personal"); + if (tabOrg) tabOrg.classList.toggle("active", mode === "organization"); + if (mode === "organization") { + if (emailLabel) emailLabel.textContent = "Work / Organization Email"; + if (emailInput) emailInput.placeholder = "name@company.com"; + if (subtitleEl) { + subtitleEl.innerHTML = 'Sign in with your corporate credentials to access <b>Enterprise LMS</b> (<a href="https://www.enterprise.lucebra.com/" target="_blank" rel="noopener noreferrer">enterprise.lucebra.com</a>) or <a href="https://www.lucebra.com/organizational-login" target="_blank" rel="noopener noreferrer">Organization SSO</a>.'; + } + } else { + if (emailLabel) emailLabel.textContent = "Email or Username"; + if (emailInput) emailInput.placeholder = "you@example.com"; + if (subtitleEl) { + subtitleEl.textContent = "Sign in with your Lucebra account to unlock instant Wishlist saving, Learning Progress, Certificates, and Personal/Team Plan enrollment."; + } + } + }; + + if (tabPersonal) tabPersonal.onclick = () => setLoginTab("personal"); + if (tabOrg) tabOrg.onclick = () => setLoginTab("organization"); + + const closeModal = () => { + if (modal) modal.classList.remove("visible"); + if (qrPanel) qrPanel.classList.remove("visible"); + stopQrCheckTimer(); + if (errorBanner) { + errorBanner.textContent = ""; + errorBanner.classList.remove("visible"); + } + }; + + if (btnConnect && modal) { + btnConnect.onclick = () => { + modal.classList.add("visible"); + if (emailInput) setTimeout(() => emailInput.focus(), 50); + }; + } + + if (btnClose) btnClose.onclick = closeModal; + if (modal) { + modal.onclick = (ev) => { + if (ev.target === modal) closeModal(); + }; + } + + // Bounded, lightweight QR Code login shortcut (Uses backend base64 / api.lucebra.com PNG, max 36 checks at 3.5s intervals while QR is open) + if (btnQrToggle && qrPanel) { + btnQrToggle.onclick = async () => { + const isNowVisible = !qrPanel.classList.contains("visible"); + qrPanel.classList.toggle("visible", isNowVisible); + stopQrCheckTimer(); + + if (!isNowVisible) return; + + if (qrStatusText) { + qrStatusText.innerHTML = "Generating secure QR code..."; + } + try { + const res = await fetch("https://api.lucebra.com/mcp/widget-auth/qr", { + method: "GET", + headers: { "Accept": "application/json" } + }); + const data = await res.json(); + if (res.ok && data && data.deviceId) { + const fallbackApiPng = data.qrImageUrl || `https://api.lucebra.com/mcp/widget-auth/qr-image/${encodeURIComponent(data.deviceId)}.png`; + if (qrImg) { + qrImg.onerror = function() { + this.onerror = null; + if (data.qrCode && String(data.qrCode).startsWith("data:image/")) { + this.src = data.qrCode; + } + }; + qrImg.src = fallbackApiPng; + } + if (qrStatusText) { + qrStatusText.innerHTML = 'Scan with the <a href="https://www.lucebra.com/mobile-app" target="_blank" rel="noopener noreferrer">Lucebra Mobile App</a> (iOS & Android) to sign in immediately.'; + } + + qrCheckAttempts = 0; + qrCheckTimer = setInterval(async () => { + if (!modal || !modal.classList.contains("visible") || !qrPanel.classList.contains("visible")) { + stopQrCheckTimer(); + return; + } + qrCheckAttempts++; + if (qrCheckAttempts > 36) { + stopQrCheckTimer(); + if (qrStatusText) { + qrStatusText.innerHTML = 'QR session expired. Click <b>Login with QR Code</b> above to refresh.'; + } + return; + } + try { + const stRes = await fetch(`https://api.lucebra.com/mcp/widget-auth/qr-status/${encodeURIComponent(data.deviceId)}`, { + method: "GET", + headers: { "Accept": "application/json" } + }); + if (!stRes.ok) return; + const stData = await stRes.json(); + if (stData && stData.authenticated) { + stopQrCheckTimer(); + renderUserAuthState(stData.user || stData); + closeModal(); + } + } catch (e) { } + }, 3500); + } + } catch (e) { + if (qrStatusText) { + qrStatusText.textContent = "Could not load QR code right now."; + } + } + }; + } + + // Auto-sync when the user clicks "Personal Web Login →" or "Organization Login →" and signs in on www.lucebra.com + const startWebLoginSyncWatcher = () => { + stopQrCheckTimer(); + qrCheckAttempts = 0; + qrCheckTimer = setInterval(async () => { + qrCheckAttempts++; + if (qrCheckAttempts > 30 || currentAuthUser) { + stopQrCheckTimer(); + return; + } + try { + const stRes = await fetch("https://api.lucebra.com/mcp/widget-auth/status", { + method: "GET", + headers: { "Accept": "application/json" } + }); + if (!stRes.ok) return; + const stData = await stRes.json(); + if (stData && stData.authenticated) { + stopQrCheckTimer(); + renderUserAuthState(stData.user || stData); + closeModal(); + } + } catch (e) { } + }, 3000); + }; + + const linkWebPersonal = document.getElementById("link-web-personal-login"); + const linkWebOrg = document.getElementById("link-web-org-login"); + if (linkWebPersonal) linkWebPersonal.addEventListener("click", startWebLoginSyncWatcher); + if (linkWebOrg) linkWebOrg.addEventListener("click", startWebLoginSyncWatcher); + window.addEventListener("focus", () => { + if (!currentAuthUser && modal && modal.classList.contains("visible")) { + checkWidgetAuthStatusOnce(); + } + }); + + if (form) { + form.onsubmit = async (ev) => { + ev.preventDefault(); + const email = emailInput ? emailInput.value.trim() : ""; + const password = passInput ? passInput.value : ""; + if (!email || !password) return; + + if (errorBanner) { + errorBanner.textContent = ""; + errorBanner.classList.remove("visible"); + } + if (btnSubmit) { + btnSubmit.disabled = true; + btnSubmit.textContent = "Signing in..."; + } + + try { + const res = await fetch("https://api.lucebra.com/mcp/widget-auth/login", { + method: "POST", + headers: { "Content-Type": "application/json", "Accept": "application/json" }, + body: JSON.stringify({ email, password, loginType: selectedLoginType }) + }); + const data = await res.json(); + if (res.ok && data && data.authenticated) { + renderUserAuthState(data.user || { + userId: data.userId, + fullName: data.fullName, + email: data.email, + profilePhoto: data.profilePhoto, + accountType: data.accountType + }); + if (passInput) passInput.value = ""; + closeModal(); + if (summaryEl) { + summaryEl.textContent = `Connected as ${data.fullName || data.email} (${data.accountType || "Personal"}). You can now save courses to your Wishlist with 1 click or check your Progress & Business Plan.`; + } + } else { + if (errorBanner) { + errorBanner.textContent = (data && data.message) ? data.message : "Invalid email or password. Please try again."; + errorBanner.classList.add("visible"); + } + } + } catch (err) { + if (errorBanner) { + errorBanner.textContent = "Could not reach Lucebra authentication service. You can also sign in via the browser link below."; + errorBanner.classList.add("visible"); + } + } finally { + if (btnSubmit) { + btnSubmit.disabled = false; + btnSubmit.textContent = "Sign In & Connect"; + } + } + }; + } + + if (btnDisconnect) { + btnDisconnect.onclick = async () => { + try { + await fetch("https://api.lucebra.com/mcp/widget-auth/logout", { method: "POST" }); + } catch (e) { } + renderUserAuthState(null); + if (summaryEl) { + summaryEl.textContent = "Lucebra account disconnected. Click 'Connect Account' anytime to sign back in."; + } + }; + } + + // Wishlist Confirmation Modal close handlers + const wishModal = document.getElementById("lucebra-wishlist-modal"); + const btnCloseWish = document.getElementById("btn-close-wishlist-modal"); + const btnContWish = document.getElementById("btn-wishlist-continue"); + const closeWishModal = () => { + if (wishModal) wishModal.classList.remove("visible"); + }; + if (btnCloseWish) btnCloseWish.onclick = closeWishModal; + if (btnContWish) btnContWish.onclick = closeWishModal; + if (wishModal) { + wishModal.onclick = (ev) => { + if (ev.target === wishModal) closeWishModal(); + }; + } + + // Event-driven auth sync (Zero request storm: triggers only on postMessage from popup, window focus, or tab visibility) + window.addEventListener("message", (ev) => { + if (ev.data && ev.data.type === "lucebra-auth-connected") { + checkWidgetAuthStatus(); + } + }); + window.addEventListener("focus", () => { + checkWidgetAuthStatus(); + }); + document.addEventListener("visibilitychange", () => { + if (document.visibilityState === "visible") { + checkWidgetAuthStatus(); + } + }); + } + + const updateFromResponse = (response) => { + const sc = response?.structuredContent || response; + if (sc && "currentUser" in sc) { + renderUserAuthState(sc.currentUser); + } + const list = sc?.courses || sc?.courseList || (Array.isArray(sc) ? sc : null); + if (Array.isArray(list)) { renderPlaylist(list); } - }); - } + }; + + let rpcId = 0; + const pendingRequests = new Map(); + let isBridgeInitialized = false; + let bridgeInitPromise = null; + + const rpcNotify = (method, params) => { + if (!window.parent || window.parent === window) return; + window.parent.postMessage({ jsonrpc: "2.0", method, params }, "*"); + }; + + const rpcRequest = (method, params, timeoutMs = 4000) => + new Promise((resolve, reject) => { + if (!window.parent || window.parent === window) { + reject(new Error("No parent host window available for MCP bridge.")); + return; + } + const id = ++rpcId; + const timer = setTimeout(() => { + if (pendingRequests.has(id)) { + pendingRequests.delete(id); + reject(new Error(`RPC request "${method}" timed out after ${timeoutMs}ms.`)); + } + }, timeoutMs); + + pendingRequests.set(id, { resolve, reject, timer }); + window.parent.postMessage( + { jsonrpc: "2.0", id, method, params }, + "*" + ); + }); + + window.addEventListener( + "message", + (event) => { + if (event.source !== window.parent) return; + const message = event.data; + if (!message || message.jsonrpc !== "2.0") return; + + if (typeof message.id === "number" || typeof message.id === "string") { + const pending = pendingRequests.get(message.id); + if (pending) { + clearTimeout(pending.timer); + pendingRequests.delete(message.id); + if (message.error) { + pending.reject(message.error); + return; + } + pending.resolve(message.result); + return; + } + + if (typeof message.method === "string") { + window.parent.postMessage({ jsonrpc: "2.0", id: message.id, result: {} }, "*"); + return; + } + } + + if (typeof message.method !== "string") return; + if (message.method === "ui/notifications/tool-result") { + updateFromResponse(message.params); + } + }, + { passive: true } + ); + + const initializeBridge = async () => { + if (isBridgeInitialized) return true; + if (!window.parent || window.parent === window) return false; + if (bridgeInitPromise) return bridgeInitPromise; + + const protocolVersion = "2026-01-26"; + bridgeInitPromise = (async () => { + try { + await rpcRequest("ui/initialize", { + appInfo: { + name: "lucebra-course-player", + version: "1.0.6" + }, + appCapabilities: {}, + protocolVersion + }); + rpcNotify("ui/notifications/initialized", {}); + isBridgeInitialized = true; + return true; + } catch (error) { + bridgeInitPromise = null; + return false; + } + })(); + + return bridgeInitPromise; + }; - // Support course data passed via URL query parameter - try { - const urlParams = new URLSearchParams(window.location.search); - const dataParam = urlParams.get("data"); - if (dataParam) { - const parsed = JSON.parse(decodeURIComponent(dataParam)); - if (Array.isArray(parsed)) renderPlaylist(parsed); + initializeBridge(); + + async function sendPromptToChat(promptText) { + const summaryEl = document.getElementById("chat-summary-text"); + try { + const ready = await initializeBridge(); + if (ready) { + await rpcRequest("ui/message", { + role: "user", + content: [{ type: "text", text: promptText }], + }); + return true; + } + } catch (err) { + console.warn("ui/message failed:", err); + } + + if (window.openai?.sendFollowUpMessage) { + try { + await window.openai.sendFollowUpMessage({ prompt: promptText }); + return true; + } catch (e) { + console.warn("sendFollowUpMessage failed:", e); + } + } + + if (summaryEl) { + summaryEl.textContent = "Chat host connection is not active in standalone view. Open this widget inside ChatGPT to send quick prompts."; + } + return false; } - } catch(e) {} + + function setupActionChips() { + const btnCurriculum = document.getElementById("btn-show-curriculum"); + const btnCompare = document.getElementById("btn-compare-courses"); + const btnPrice = document.getElementById("btn-course-price"); + const btnInstructor = document.getElementById("btn-instructor-info"); + const btnExams = document.getElementById("btn-practice-exams"); + const btnDigital = document.getElementById("btn-digital-products"); + const btnLive = document.getElementById("btn-live-sessions"); + const btnWishlist = document.getElementById("btn-save-wishlist"); + const btnMyWishlist = document.getElementById("btn-my-wishlist"); + const btnProgress = document.getElementById("btn-my-progress"); + const btnCerts = document.getElementById("btn-my-certificates"); + const btnBusiness = document.getElementById("btn-business-access"); + const btnEnrollPlan = document.getElementById("btn-enroll-plan"); + + if (btnCurriculum) { + btnCurriculum.onclick = async () => { + const active = currentCourses[currentActiveIndex] || currentCourses[0]; + if (active) { + await sendPromptToChat(`Show the curriculum, sections, and lessons for "${active.title}" on Lucebra.`); + } + }; + } + + if (btnCompare) { + btnCompare.onclick = async () => { + if (currentCourses.length >= 2) { + const c1 = currentCourses[currentActiveIndex] || currentCourses[0]; + const c2 = currentActiveIndex === 0 ? currentCourses[1] : currentCourses[0]; + await sendPromptToChat(`Compare these courses on Lucebra side-by-side in a table including instructor, level, content/duration, price (with regular and discount price if any), key topics, learning outcomes, and prerequisites:\n1. "${c1.title}"\n2. "${c2.title}"`); + } else if (currentCourses.length === 1) { + const c1 = currentCourses[0]; + await sendPromptToChat(`Compare the course "${c1.title}" with relevant learning alternatives on Lucebra including price, discounts, duration, and outcomes.`); + } + }; + } + + if (btnPrice) { + btnPrice.onclick = async () => { + const active = currentCourses[currentActiveIndex] || currentCourses[0]; + if (active) { + await sendPromptToChat(`Show the current price, regular price, and any active discounts for "${active.title}" on Lucebra.`); + } + }; + } + + if (btnInstructor) { + btnInstructor.onclick = async () => { + const active = currentCourses[currentActiveIndex] || currentCourses[0]; + const instName = active?.author || active?.title || "Lucebra Instructor"; + await sendPromptToChat(`Show the instructor profile, profile photo, biography, and published courses with prices for "${instName}" on Lucebra.`); + }; + } + + if (btnWishlist) { + btnWishlist.onclick = async () => { + const active = currentCourses[currentActiveIndex] || currentCourses[0]; + if (!active) return; + await toggleCourseWishlistInstant(active); + }; + } + + if (btnMyWishlist) { + btnMyWishlist.onclick = async () => { + await sendPromptToChat("Show the saved courses in my Lucebra wishlist."); + }; + } + + if (btnProgress) { + btnProgress.onclick = async () => { + await sendPromptToChat("Show my enrolled courses and learning progress on Lucebra with Play Now links."); + }; + } + + if (btnCerts) { + btnCerts.onclick = async () => { + await sendPromptToChat("Show my verified course certificates and credentials on Lucebra."); + }; + } + + if (btnBusiness) { + btnBusiness.onclick = async () => { + await sendPromptToChat("Check my Lucebra Business / Enterprise LMS plan access, assigned courses, and remaining deadlines."); + }; + } + + if (btnEnrollPlan) { + btnEnrollPlan.onclick = async () => { + const active = currentCourses[currentActiveIndex] || currentCourses[0]; + if (!active) return; + await enrollInCourseWithPlanInstant(active); + }; + } + + if (btnExams) { + btnExams.onclick = async () => { + await sendPromptToChat("Show Lucebra Exam Center certification categories and available standalone certification exams."); + }; + } + + if (btnDigital) { + btnDigital.onclick = async () => { + const active = currentCourses[currentActiveIndex] || currentCourses[0]; + const topic = active?.category || active?.title || ""; + await sendPromptToChat(topic + ? `Show Digital Products (eBooks, audio guides, and study kits) on Lucebra related to "${topic}".` + : "Show Digital Products (eBooks, audio guides, and study kits) on Lucebra."); + }; + } + + if (btnLive) { + btnLive.onclick = async () => { + await sendPromptToChat("Check if there are any active or upcoming live sessions and webinars on Lucebra right now."); + }; + } + + const btnPlansPricing = document.getElementById("btn-plans-pricing"); + const btnGetApp = document.getElementById("btn-get-app"); + const btnSpotlightDaily = document.getElementById("btn-spotlight-daily"); + const btnWriteArticles = document.getElementById("btn-write-articles"); + + if (btnPlansPricing) { + btnPlansPricing.onclick = async () => { + await sendPromptToChat( + "Explain Lucebra Personal, Team and Enterprise plans, their key differences, and current pricing with billing periods. Share the official plans page." + ); + }; + } + + if (btnGetApp) { + btnGetApp.onclick = async () => { + await sendPromptToChat( + "Tell me about the Lucebra mobile app and share the official iOS and Android download links." + ); + }; + } + + if (btnSpotlightDaily) { + btnSpotlightDaily.onclick = async () => { + await sendPromptToChat( + "What is Lucebra Spotlight Daily, and how can I watch it on the website and in the mobile app?" + ); + }; + } + + if (btnWriteArticles) { + btnWriteArticles.onclick = async () => { + await sendPromptToChat( + "How can I write and publish articles on Lucebra? Explain the available features and share the official page." + ); + }; + } + } + + setupModals(); + setupActionChips(); + checkWidgetAuthStatus(); + const initialInstructorImg = document.getElementById("instructor-img"); + if (initialInstructorImg) { + initialInstructorImg.onerror = function () { + this.onerror = null; + this.src = placeholderAvatar; + }; + } + if (currentCourses.length > 0) { + renderPlaylist(currentCourses); + } else { + setVideoUnavailableState(true, "Select a course", "Choose a course to watch its lesson preview."); + updateWishlistButtonState(null); + } + })(); </script> </body> + </html>
Full technical diff · 41 changed fields
changed /files/.agent-plugin~1plugin.json/sha256
"f313e0e7185885b4988cc72a8339ff386c5b640dcfb1c3717de85458386c6e67"
"a5c2d0d1355849bc825cd5b7c37af9a996603ba4b7a059c2fc6f1fc1a75f5ce4"
changed /files/.agent-plugin~1plugin.json/size
4255
3838
changed /files/.claude-plugin~1plugin.json/sha256
"f313e0e7185885b4988cc72a8339ff386c5b640dcfb1c3717de85458386c6e67"
"a5c2d0d1355849bc825cd5b7c37af9a996603ba4b7a059c2fc6f1fc1a75f5ce4"
changed /files/.claude-plugin~1plugin.json/size
4255
3838
changed /files/.codex-plugin~1plugin.json/sha256
"aea069efc8cd37f7637045afa4018ea3176776c2951a8e617a3d1e62ea9812a3"
"e65d21f345d77070c08849956e00c2c179e2e73d5768b6aaaa01d90351044f3b"
changed /files/.codex-plugin~1plugin.json/size
4280
3780
changed /files/.mcp.json/sha256
"f3d13df0c89313a9b58bdee011db0d72468c6aed78836e15469465cfbb65b68d"
"fda1150bea19ad6df71b456b5826b9d920fa1f6d61b5c68340a0e21d6f0a05db"
changed /files/.mcp.json/size
114
131
changed /files/ai-plugin.json/sha256
"89623e06c8830e3effe747d3ffa0b2b723e8a3cf0f899fa0232df9cda1eac0ac"
"dde52d11578fe46ae4af2db74cdeae8bb87e20ff1cf7a2441e2a0f71d1e390f5"
changed /files/ai-plugin.json/size
932
678
changed /files/chatgpt-app-submission.json/sha256
"500441d7d603780bdd506018ac5c8b8c95927dab416658d6628297d7b7281237"
"61c815f1b1df12444d7962f6f5b280fb0307987ef1e403d5dd550583bfdd8c9b"
changed /files/chatgpt-app-submission.json/size
21045
21676
changed /files/mcp.json/sha256
"f3d13df0c89313a9b58bdee011db0d72468c6aed78836e15469465cfbb65b68d"
"fda1150bea19ad6df71b456b5826b9d920fa1f6d61b5c68340a0e21d6f0a05db"
changed /files/mcp.json/size
114
131
changed /files/plugin.json/sha256
"f313e0e7185885b4988cc72a8339ff386c5b640dcfb1c3717de85458386c6e67"
"a5c2d0d1355849bc825cd5b7c37af9a996603ba4b7a059c2fc6f1fc1a75f5ce4"
changed /files/plugin.json/size
4255
3838
removed /files/skills~1add_to_cart_and_checkout~1SKILL.md
{
"sha256": "213fd631fa7fc81ec200e0da0e8a7012bbfaf9995b919783ddd353b1a790b2d3",
"size": 274
}Field is absent
removed /files/skills~1add_to_wishlist~1SKILL.md
{
"sha256": "86038dff353f73dfeba0afbdd78c0ee60437fb76fa72bc3f80bf68f2f3dfe990",
"size": 202
}Field is absent
removed /files/skills~1check_business_plan~1SKILL.md
{
"sha256": "f5254975484a67484734ad19fdb1949127c5aa5faf5108dbe0e93d155a19aa06",
"size": 242
}Field is absent
removed /files/skills~1compare_courses~1SKILL.md
{
"sha256": "7a8520c77a804203d8a6914dd580e15ab923062a1417585092420e981ec04c54",
"size": 292
}Field is absent
removed /files/skills~1enroll_via_business_plan~1SKILL.md
{
"sha256": "4caadc9589057bc0d8b8a7b1975cd21bab6d07e2ba57705e5e07dc00e8b920b1",
"size": 266
}Field is absent
removed /files/skills~1get_course_content~1SKILL.md
{
"sha256": "e956e3376d1b8ec6f19842d8755443b82e465a728ea85d1122c0b529e1aa4b57",
"size": 324
}Field is absent
removed /files/skills~1get_course_curriculum~1SKILL.md
{
"sha256": "74f5f71269d405dcc83c137044b3711657db5d38e9c1cf263b8be02ad67a5b03",
"size": 228
}Field is absent
removed /files/skills~1get_course_details~1SKILL.md
{
"sha256": "e48f9863d53c480c11dbbbe7ce55c336e46aa2eafe7e73ed34ff635cc44d9db2",
"size": 214
}Field is absent
removed /files/skills~1get_course_preview~1SKILL.md
{
"sha256": "867b3ecf6ce8f1e848a7efd7de5f22ddcbb16473361e69c22ccee793b217d080",
"size": 194
}Field is absent
removed /files/skills~1get_course_price~1SKILL.md
{
"sha256": "6f68f653225f9dfb8cc135f2cbbbd774638b4dcd76bb38642e2670486a41739d",
"size": 198
}Field is absent
removed /files/skills~1get_course_reviews~1SKILL.md
{
"sha256": "08b6feb56a0b062b03c05aafca384a4b2bb5cb92c39837e558057d1ed6e34488",
"size": 208
}Field is absent
removed /files/skills~1get_ebooks~1SKILL.md
{
"sha256": "1bba53442214374edab8a4ff8324affd2f502f594d74d76739aaeda5a3bb1d4a",
"size": 207
}Field is absent
removed /files/skills~1get_instructor_profile~1SKILL.md
{
"sha256": "55216cc8fe95c874247385cfc1858ce55ae9342bc3a46bbe51ee85caf7ddce00",
"size": 250
}Field is absent
removed /files/skills~1get_learning_path~1SKILL.md
{
"sha256": "4bf2b29da2164ad8f1c1ddaf632dbdd794f0720008b0b06757a45d0712dd1574",
"size": 226
}Field is absent
removed /files/skills~1get_live_sessions~1SKILL.md
{
"sha256": "e14aaa93b9a9524c2a047461e3436ffee47e419a54eb57738b5788ef679923e1",
"size": 255
}Field is absent
removed /files/skills~1get_my_certificates~1SKILL.md
{
"sha256": "51b65647f13fa62ff3d3ec0d40c43eadc63f621e05e2167a7d18fbf6d791b0c9",
"size": 246
}Field is absent
removed /files/skills~1get_my_learning_progress~1SKILL.md
{
"sha256": "a49a6aaca55eac5c35539a6b2ace68e217de0e21d409f4515c686f6144b480c3",
"size": 304
}Field is absent
removed /files/skills~1get_my_wishlist~1SKILL.md
{
"sha256": "54e04cd50d4c9d4fde0b9d06f73b3bfbef09c91e5eb3b010b93482611176129f",
"size": 174
}Field is absent
removed /files/skills~1get_practice_exams~1SKILL.md
{
"sha256": "153248ce60fe3c7c8e3e9ecd4e0e55eb426136aad433706ab39e8ece8ed78bca",
"size": 184
}Field is absent
added /files/skills~1lucebra-learning-assistant~1SKILL.md
Field was absent
{
"sha256": "dc2844bb7438f01fe2c51418c3e3c96fae1e29a6e5e49a129c5ba890c200d7b7",
"size": 20675
}removed /files/skills~1recommend_courses~1SKILL.md
{
"sha256": "b5c585a129f29b24c3ca8b3f43bd53b642e3c25e3bf5e25433fdc63dba29b7a6",
"size": 212
}Field is absent
removed /files/skills~1search_courses~1SKILL.md
{
"sha256": "4cb6ce4d8e01e49d783b93a81dca79f0bbac8a6c7f1991155607e9cec190ffcd",
"size": 238
}Field is absent
removed /files/skills~1search_instructors~1SKILL.md
{
"sha256": "7e98ef576bbd7fce671ebe8a272838fe504f2e1729006bf106b2c98c41969379",
"size": 190
}Field is absent
changed /files/widgets~1course-player.html/sha256
"debaa468fbdaf6382300355c60adb82d608e7a4b532bb3af7f4427f6ce7fc502"
"d18f532956933466071f4b4311ca0583cc8b31603c2d2ef7d3bc3a797d6fcbf1"
changed /files/widgets~1course-player.html/size
19498
88899
Full snapshot data
{
"files": {
".agent-plugin/plugin.json": {
"sha256": "a5c2d0d1355849bc825cd5b7c37af9a996603ba4b7a059c2fc6f1fc1a75f5ce4",
"size": 3838
},
".app.json": {
"sha256": "dd9ca28af9d5b55971052b39d96f6cb5b548f42df93328634bd9e43015299036",
"size": 99
},
".claude-plugin/plugin.json": {
"sha256": "a5c2d0d1355849bc825cd5b7c37af9a996603ba4b7a059c2fc6f1fc1a75f5ce4",
"size": 3838
},
".codex-plugin/plugin.json": {
"sha256": "e65d21f345d77070c08849956e00c2c179e2e73d5768b6aaaa01d90351044f3b",
"size": 3780
},
".mcp.json": {
"sha256": "fda1150bea19ad6df71b456b5826b9d920fa1f6d61b5c68340a0e21d6f0a05db",
"size": 131
},
"ai-plugin.json": {
"sha256": "dde52d11578fe46ae4af2db74cdeae8bb87e20ff1cf7a2441e2a0f71d1e390f5",
"size": 678
},
"assets/icon.png": {
"sha256": "4bded4468b8d07692274f68c587cabf349469aa6474c4d70c715afbaf78d88cb",
"size": 34006
},
"assets/logo.png": {
"sha256": "4bded4468b8d07692274f68c587cabf349469aa6474c4d70c715afbaf78d88cb",
"size": 34006
},
"assets/lucebra_store_banner.png": {
"sha256": "90285be0b821ee2b618327c62add8c9584d0cc5edf6cb344301b3c057e7601b2",
"size": 592910
},
"chatgpt-app-submission.json": {
"sha256": "61c815f1b1df12444d7962f6f5b280fb0307987ef1e403d5dd550583bfdd8c9b",
"size": 21676
},
"icon.png": {
"sha256": "4bded4468b8d07692274f68c587cabf349469aa6474c4d70c715afbaf78d88cb",
"size": 34006
},
"logo.png": {
"sha256": "4bded4468b8d07692274f68c587cabf349469aa6474c4d70c715afbaf78d88cb",
"size": 34006
},
"mcp.json": {
"sha256": "fda1150bea19ad6df71b456b5826b9d920fa1f6d61b5c68340a0e21d6f0a05db",
"size": 131
},
"plugin.json": {
"sha256": "a5c2d0d1355849bc825cd5b7c37af9a996603ba4b7a059c2fc6f1fc1a75f5ce4",
"size": 3838
},
"skills/lucebra-learning-assistant/SKILL.md": {
"sha256": "dc2844bb7438f01fe2c51418c3e3c96fae1e29a6e5e49a129c5ba890c200d7b7",
"size": 20675
},
"widgets/course-player.html": {
"sha256": "d18f532956933466071f4b4311ca0583cc8b31603c2d2ef7d3bc3a797d6fcbf1",
"size": 88899
}
}
}SHA-256 of public snapshot: 97e00c9b21ab580a33d520643e5cf2ee236ec094b250b26d6e5f4207537d494e