/** * @fileoverview Support Helpdesk, Currency Exchange Calculator & Payment Gateways UI Engine * @module ui/support-ui * @description واجهة مركز الدعم المباشر، حاسبة تحويل العملات المباشرة، بوابات الدفع والتحويل البنكي، وتوليد تذاكر الشحن الموثقة. */ (global => { 'use strict'; const SUPPORT_SALT = global.FritreeAppConstants?.SECURITY_SALTS?.SUPPORT_SALT || "FritreeSupportHelpdeskSymmetricValidationMatrix_2026_StrictSecure"; /** * حساب التوقيع الرقمي لسلامة بيانات الدعم الفني * @param {string} accountId * @returns {Promise} */ async function calculateSupportSignature(accountId) { const payloadText = `SUPPORT_HELP:${accountId}:${SUPPORT_SALT}`; if (global.FritreeCrypto && typeof global.FritreeCrypto.sha256 === 'function') { return await global.FritreeCrypto.sha256(payloadText); } let hash = 0; for (let i = 0; i < payloadText.length; i++) { const char = payloadText.charCodeAt(i); hash = ((hash << 5) - hash) + char; hash |= 0; } return "support_sig_fallback_" + Math.abs(hash).toString(16); } /** * بناء الهيكل البصري لقسم الدعم الفني وحاسبة العملات وبوابات الدفع بالـ DOM */ const buildSupportLayout = () => { const contentArea = document.getElementById('s7ihkirolg'); if (!contentArea) return; const sidebar = document.getElementById('bmh59axx92'); if (sidebar && !sidebar.querySelector('[data-target="xrsxtjzo87"]')) { const navItem = document.createElement('div'); navItem.className = 'f2rj8bz2yt'; navItem.setAttribute('data-target', 'xrsxtjzo87'); navItem.innerHTML = ' الدعم والشحن المالي'; sidebar.appendChild(navItem); navItem.addEventListener('click', () => { window.location.hash = 'xrsxtjzo87'; }); } const host = document.getElementById('fritree-dynamic-panes-host') || contentArea; let pane = document.getElementById('xrsxtjzo87'); if (!pane) { pane = document.createElement('section'); pane.className = 'rjiai07g77'; pane.id = 'xrsxtjzo87'; host.appendChild(pane); } else if (pane.parentElement !== host) { host.appendChild(pane); } let grid = pane.querySelector('#ovnw7b9lmg'); if (!grid) { grid = document.createElement('div'); grid.id = 'ovnw7b9lmg'; grid.className = 'xd506q5mar'; grid.style.cssText = 'display: grid; grid-template-columns: repeat(auto-fit, minmax(clamp(280px, 35vw, 1fr), 1fr)); gap: 14px; margin-bottom: 16px; direction: rtl; width: 100%; box-sizing: border-box;'; pane.appendChild(grid); } // 1. العمود الأول: مركز الدعم الفني وشات الواتساب let supportCol = grid.querySelector('#chtnqegnou'); if (!supportCol) { supportCol = document.createElement('div'); supportCol.className = 'd5tp7way8h'; supportCol.id = 'chtnqegnou'; supportCol.style.cssText = 'padding: clamp(14px, 1.8vw, 22px); display: flex; flex-direction: column; height: 100%; direction: rtl; text-align: right; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow-xs); box-sizing: border-box;'; supportCol.innerHTML = `
مركز الدعم الفني والشحن الفوري خدمة 24/7 متواصلة

فريق الدعم المخصص متاح على مدار الساعة للإجابة على استفساراتك وتأكيد شحن أرصدة المحفظة ونقاط النشر والبث فورياً.

+201096896689 متصل الآن
`; grid.appendChild(supportCol); } // 2. العمود الثاني: حاسبة تحويل العملات وتوليد تذاكر الشحن الموثقة let calcCol = grid.querySelector('#p266i7uuqq'); if (!calcCol) { calcCol = document.createElement('div'); calcCol.className = 'd5tp7way8h'; calcCol.id = 'p266i7uuqq'; calcCol.style.cssText = 'padding: clamp(14px, 1.8vw, 22px); display: flex; flex-direction: column; height: 100%; direction: rtl; text-align: right; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow-xs); box-sizing: border-box;'; calcCol.innerHTML = `
حاسبة العملات وتوليد تذاكر الشحن
جاري جلب أحدث أسعار الصرف العالمية الحية...
سعر الصرف المباشر: 1 USD = 50.00 EGP
`; grid.appendChild(calcCol); } buildGatewaysLayout(pane); }; /** * بناء قسم بوابات الدفع البنكية والمحافظ الإلكترونية */ const buildGatewaysLayout = (pane) => { let gatewaysCard = pane.querySelector('#j85twrlin1'); if (gatewaysCard) return; gatewaysCard = document.createElement('div'); gatewaysCard.className = 'd5tp7way8h'; gatewaysCard.id = 'j85twrlin1'; gatewaysCard.style.cssText = 'padding: clamp(14px, 1.8vw, 24px); margin-top: 14px; direction: rtl; text-align: right; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow-xs); box-sizing: border-box;'; gatewaysCard.innerHTML = `
طرق الدفع والتحويل المعتمدة لشحن المحفظة حساب معتمد وموثق
التحويل البنكي
إنستاباي
محفظة رقمية

تحويل بنكي مباشر لحسابنا في البنك التجاري الدولي (CIB). اختر عملة التحويل بالأسفل لنسخ رقم الحساب المخصص.

تحويل مباشر بسعر الصرف الرسمي وبدون أي عمولة
البنك المستلم: البنك التجاري الدولي (CIB - Egypt)
اسم صاحب الحساب: Mohamed Ahmed Mohamed Farouk
رقم الحساب للنسخ:
`; pane.appendChild(gatewaysCard); }; /** * تحديث كود الجهاز في حقل العرض */ const updateWorkspaceIDDisplay = async () => { const idDisplay = document.getElementById('an7xl5rgcc'); if (idDisplay && global.FritreeCrypto && typeof global.FritreeCrypto.getOrGenerateAccountId === 'function') { const currentId = await global.FritreeCrypto.getOrGenerateAccountId(); idDisplay.value = currentId; const computedSignature = await calculateSupportSignature(currentId); if (global.FritreeStorage) { await global.FritreeStorage.set('support_security_checksum', computedSignature); } } }; /** * إطلاق محادثة الدعم والشحن المباشرة عبر واتساب */ const triggerSupportWhatsAppChat = async () => { if (!global.FritreeCrypto) return; const currentAccountId = await global.FritreeCrypto.getOrGenerateAccountId(); const supportNumber = global.FritreeBankingConfig?.RECEIVERS?.SUPPORT_WHATSAPP_CLEAN || "201096896689"; const messageText = `أهلاً يا فريق دعم فريتري، كود جهازي الموثق هو:\n\n${currentAccountId}\n\nأحتاج للاستفسار وتأكيد شحن أرصدة المحفظة ونقاط النشر التلقائي لحسابي. شكراً لكم!`; const waUrl = `https://wa.me/${supportNumber}?text=${encodeURIComponent(messageText)}`; window.open(waUrl, '_blank'); if (typeof window.addLog === 'function') { window.addLog("الدعم الفني: تم فتح محادثة الواتساب المباشرة مع خدمة العملاء بنجاح.", 'success'); } }; /** * ربط أحداث القنوات الفرعية والنسخ وحاسبة العملات */ const bindSupportEventListeners = () => { const chatBtn = document.getElementById('t7zdv53427'); const idDisplayField = document.getElementById('an7xl5rgcc'); const copyIdBtn = document.getElementById('zayjah9bha'); if (chatBtn) chatBtn.onclick = triggerSupportWhatsAppChat; const handleCopy = () => { if (!idDisplayField) return; navigator.clipboard.writeText(idDisplayField.value).then(() => { if (typeof window.addLog === 'function') { window.addLog("نسخ آمن: تم نسخ كود الجهاز بنجاح.", 'success'); } const originalBg = idDisplayField.style.background; idDisplayField.style.background = 'var(--success-light)'; setTimeout(() => { idDisplayField.style.background = originalBg; }, 1500); if (copyIdBtn) { const originalHtml = copyIdBtn.innerHTML; copyIdBtn.innerHTML = ' '; setTimeout(() => { copyIdBtn.innerHTML = originalHtml; }, 1500); } }); }; if (idDisplayField) idDisplayField.onclick = handleCopy; if (copyIdBtn) copyIdBtn.onclick = handleCopy; // 1. ربط حاسبة تحويل العملات const payCurrencySelect = document.getElementById('nakt4bs0fk'); const receiveCurrencySelect = document.getElementById('d0iuamglk9'); const payAmountInput = document.getElementById('rjr8i1f9f3'); const receiveAmountInput = document.getElementById('ln7azkypv1'); const refreshRatesBtn = document.getElementById('btn-refresh-live-rates'); const generateTicketBtn = document.getElementById('btn-generate-purchase-ticket'); if (payCurrencySelect) { payCurrencySelect.onchange = () => { if (global.FritreeExchangeRatesService) { global.FritreeExchangeRatesService.calculateCurrencies('payment'); } }; } if (receiveCurrencySelect) { receiveCurrencySelect.onchange = () => { if (global.FritreeExchangeRatesService) { global.FritreeExchangeRatesService.calculateCurrencies('payment'); } }; } if (payAmountInput) { payAmountInput.oninput = () => { if (global.FritreeExchangeRatesService) { global.FritreeExchangeRatesService.calculateCurrencies('payment'); } }; } if (receiveAmountInput) { receiveAmountInput.oninput = () => { if (global.FritreeExchangeRatesService) { global.FritreeExchangeRatesService.calculateCurrencies('receive'); } }; } if (refreshRatesBtn) { refreshRatesBtn.onclick = () => { if (global.FritreeExchangeRatesService) { global.FritreeExchangeRatesService.syncRates(); } }; } if (generateTicketBtn) { generateTicketBtn.onclick = () => { if (global.FritreeExchangeRatesService) { global.FritreeExchangeRatesService.generateTicket(); } }; } // 2. تبديل تبويبات قنوات الدفع const tabs = document.querySelectorAll('.pfe6btieb6 .n9cqm6ze7d[data-wallet-sub]'); const validGatewayPaneIds = ['p7clpd6ekl', 'de5zx14cj5', 'io4or4ksqt']; tabs.forEach(tab => { tab.addEventListener('click', () => { const targetPaneId = tab.getAttribute('data-wallet-sub'); if (!validGatewayPaneIds.includes(targetPaneId)) return; const siblingTabs = tab.parentNode.querySelectorAll('.n9cqm6ze7d[data-wallet-sub]'); siblingTabs.forEach(t => t.classList.remove('vn5qn7dmpk')); tab.classList.add('vn5qn7dmpk'); const parentGatewaysCard = document.getElementById('j85twrlin1'); if (parentGatewaysCard) { const panes = parentGatewaysCard.querySelectorAll('.gitkevh3xv'); panes.forEach(p => { if (validGatewayPaneIds.includes(p.id)) { p.style.display = (p.id === targetPaneId) ? 'block' : 'none'; } }); } }); }); // 3. ربط تبديل العملات في التحويل البنكي const currencySelect = document.getElementById('guxwjyecsq'); const bankAccountInput = document.getElementById('jfjeb63r79'); const syncToCalcBtn = document.getElementById('cs0slpgdna'); if (currencySelect && bankAccountInput) { currencySelect.onchange = async (e) => { const selected = e.target.value; const accounts = global.FritreeBankingConfig?.BANK_ACCOUNTS || {}; if (accounts[selected]) { bankAccountInput.value = accounts[selected]; if (payCurrencySelect) { payCurrencySelect.value = selected; if (global.FritreeExchangeRatesService) { global.FritreeExchangeRatesService.calculateCurrencies('payment'); } } } }; } if (syncToCalcBtn && currencySelect) { syncToCalcBtn.onclick = () => { const selectedCurr = currencySelect.value; if (payCurrencySelect) { payCurrencySelect.value = selectedCurr; if (global.FritreeExchangeRatesService) { global.FritreeExchangeRatesService.calculateCurrencies('payment'); } } const calcCard = document.getElementById('p266i7uuqq'); if (calcCard) { calcCard.scrollIntoView({ behavior: 'smooth', block: 'center' }); calcCard.style.outline = '2px solid var(--primary)'; setTimeout(() => { calcCard.style.outline = 'none'; }, 2000); } }; } // 4. أزرار نسخ معلومات الدفع const bindCopyBtn = (btnId, inputId, labelNameAr) => { const btn = document.getElementById(btnId); const input = document.getElementById(inputId); if (btn && input) { btn.onclick = () => { navigator.clipboard.writeText(input.value).then(() => { const originalHtml = btn.innerHTML; btn.innerHTML = ' '; if (typeof window.addLog === 'function') { window.addLog(`نسخ آمن: تم نسخ معلومات التحويل الخاصة بـ [${labelNameAr}] بنجاح.`, "success"); } setTimeout(() => { btn.innerHTML = originalHtml; }, 2000); }); }; } }; bindCopyBtn('ucfq23zy85', 'jfjeb63r79', "البنك التجاري الدولي CIB"); bindCopyBtn('teay3xy449', 'ng4bw51trj', "عنوان إنستاباي"); bindCopyBtn('bsx15xd744', 'ta0fqz0p8e', "محفظة فودافون كاش"); }; /** * تهيئة وحدة الدعم الفني والحاسبة */ const initSupport = async () => { const sidebar = document.getElementById('bmh59axx92'); const mainContentArea = document.getElementById('s7ihkirolg'); if (!sidebar || !mainContentArea) return false; buildSupportLayout(); await updateWorkspaceIDDisplay(); bindSupportEventListeners(); if (global.FritreeExchangeRatesService && typeof global.FritreeExchangeRatesService.syncRates === 'function') { global.FritreeExchangeRatesService.syncRates(); } return true; }; /** * تصدير وحدة واجهة الدعم الفني */ global.FritreeSupportUI = { init: initSupport, triggerSupportChat: triggerSupportWhatsAppChat, updateIDDisplay: updateWorkspaceIDDisplay, calculateSignature: calculateSupportSignature }; global.FritreeHelpdesk = global.FritreeSupportUI; global.FritreePaymentGateways = global.FritreeSupportUI; if (typeof document !== 'undefined') { if (!initSupport()) { document.addEventListener('DOMContentLoaded', initSupport); window.addEventListener('load', initSupport); } } })(typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : this);