levix-bot 4.0.0-beta → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -69,9 +69,9 @@ docker compose logs levix
69
69
 
70
70
  ### Android phone (No server required)
71
71
 
72
- Run Levix directly on an ARM64 Android device (Android 10+) as a self-contained background companion:
72
+ Run Levix directly on an Android device (Android 10+, ARM64 or ARMv7) as a self-contained background companion:
73
73
 
74
- 1. Download **`levix-android-arm64.apk`** from [Releases](https://github.com/Abdodiab2005/levix/releases).
74
+ 1. Download **`levix-android-arm64.apk`** (64-bit phones) or **`levix-android-armv7.apk`** (32-bit phones) from [Releases](https://github.com/Abdodiab2005/levix/releases).
75
75
  2. Install the APK and tap **Start Host**.
76
76
  3. Tap **Open Panel** to set your master password and link WhatsApp via 8-digit Pairing Code.
77
77
 
package/app.cjs CHANGED
@@ -150,7 +150,10 @@ app.engine("ejs", require("ejs").__express);
150
150
  app.set("view engine", "ejs");
151
151
  app.set("views", assetPath("views"));
152
152
  // Name, tagline and credit for every template. Frozen — see brand.cjs.
153
- app.locals.brand = brand;
153
+ // The one addition is the version from package.json, so the panel shows the
154
+ // shipped version instead of a string frozen in the frontend bundle.
155
+ const pkg = require("./package.json");
156
+ app.locals.brand = { ...brand, version: pkg.version };
154
157
  app.use(express.static(assetPath("public")));
155
158
  app.use(express.urlencoded({ extended: true, limit: "100kb" }));
156
159
 
@@ -274,9 +277,12 @@ app.get("/", noStore, (req, res) => {
274
277
  const dashboardHtmlPath = path.join(assetPath("public"), "dashboard", "index.html");
275
278
  if (fs.existsSync(dashboardHtmlPath)) {
276
279
  let html = fs.readFileSync(dashboardHtmlPath, "utf8");
277
- const credits = `<div class="brand-credits" style="display:none"><a href="${brand.developerSite}">${brand.developer}</a><a href="${brand.studioSite}">${brand.studio}</a></div>`;
280
+ const credits = `<div class="brand-credits" style="display:none"><a href="${app.locals.brand.developerSite}">${app.locals.brand.developer}</a><a href="${app.locals.brand.studioSite}">${app.locals.brand.studio}</a></div>`;
278
281
  html = html
279
- .replace("</head>", `<script>window.__BRAND__ = ${JSON.stringify(brand)};</script></head>`)
282
+ .replace(
283
+ "</head>",
284
+ `<script>window.__BRAND__ = ${JSON.stringify(app.locals.brand)};</script></head>`,
285
+ )
280
286
  .replace("</body>", `${credits}</body>`);
281
287
  return res.type("html").send(html);
282
288
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "levix-bot",
3
- "version": "4.0.0-beta",
3
+ "version": "4.0.0",
4
4
  "description": "A self-hosted personal WhatsApp bot with an AI agent, group moderation and a web control panel.",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -381,7 +381,7 @@ Error generating stack: `+l.message+`
381
381
  *
382
382
  * This source code is licensed under the ISC license.
383
383
  * See the LICENSE file in the root directory of this source tree.
384
- */const gb={name:"zap",size:24,node:[["path",{d:"M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z",key:"1v7up4"}]]};gb.node;const Hv=xe(gb),Gu={ar:{overview:"نظرة عامة",connection:"حالة الاتصال",control:"التحكم والإدارة",commands:"كتالوج الأوامر",ai:"الذكاء الاصطناعي",groups:"المجموعات",roles:"الأدوار والمشرفين",schedules:"الرسائل المجدولة",notes:"الملاحظات والقوائم",settings:"الإعدادات العامة",logs:"السجلات المباشرة",connected:"متصل بالواتساب",disconnected:"غير متصل",starting:"جاري إنشاء الاتصال...",waiting_for_qr:"بانتظار مسح رمز الـ QR",linking:"جاري ربط الجلسة...",reconnecting:"جاري إعادة الاتصال...",retry_exhausted:"استُنفذت محاولات الاتصال",logged_out:"تم تسجيل الخروج من الهاتف",idle:"الجلسة خاملة",paused:"متوقف مؤقتاً",resume:"استئناف الجلسة",connectSession:"الاتصال",start:"بدء الاتصال",stop:"إيقاف مؤقت",reconnect:"إعادة الاتصال",unlink:"إلغاء الربط (Unlink)",restart:"إعادة تشغيل البوت",save:"حفظ التغييرات",saving:"جاري الحفظ...",cancel:"إلغاء",delete:"حذف",edit:"تعديل",add:"إضافة",refresh:"تحديث",logout:"تسجيل الخروج",close:"إغلاق",copy:"نسخ",copied:"تم النسخ!",clientIdentity:"هوية العميل",noPhonePaired:"لم يتم ربط أي هاتف بعد",linkedAs:"مرتبط كـ",datastoreHealth:"حالة قاعدة البيانات",datastoreHealthy:"بيانات الاعتماد ومفاتيح الجلسة ومطابقات LID سليمة ومستقرة.",reconnectPolicy:"سياسة إعادة الاتصال",reconnectPolicyDesc:"تراجع خطي تدريجي (5ث، 10ث، 15ث، 20ث، 25ث) مع محاولات محدودة.",maxAttemptsAutoPause:"الحد الأقصى: 5 محاولات · إيقاف تلقائي دون إنترنت",platformWeb:"المنصة: واتساب ويب (v7 Multi-Device)",databaseNodeSqlite:"قاعدة البيانات: node:sqlite (تزامني)",totalGroups:"إجمالي المجموعات",totalUsers:"المستخدمين المسجلين",commandCount:"الأوامر المفعلة",uptime:"مدة التشغيل",dataDir:"مجلد البيانات",quickStatus:"حالة النظام",activeSchedules:"المهام المجدولة النشطة",activeListening:"المساعد نشط ويستقبل الرسائل",pausedOrLinking:"اتصال واتساب متوقف حالياً أو قيد المزامنة",aiTitle:"إعدادات الذكاء الاصطناعي",aiSubtitle:"اختر المزود المناسب بضغطة زر أو خصص النماذج والمفاتيح",aiAgentEnabled:"تفعيل وكيل الذكاء الاصطناعي",aiProvider:"المزود النشط",quickSetup:"معالج الإعداد السريع للمزودين",aiVision:"تحليل وفهم الصور (Vision)",aiVisionDesc:"تحويل الصور وتمريرها لنماذج الرؤية الذكية المتوافقة",aiStt:"محرك تحويل الصوت إلى نص (STT)",sttDesc:"محرك تفريغ الرسائل الصوتية وتحويلها إلى نص",sttAuto:"تلقائي (مطابق للمزود النشط)",sttGemini:"Google Gemini Audio API",sttOpenAI:"OpenAI / Groq Whisper API",botLanguage:"لغة ردود البوت",botLanguageDesc:"تحديد لغة ردود البوت أو تغييرها عبر الأمر !lang",langAuto:"تلقائي (حسب لغة رسالة المستخدم)",langAr:"العربية الفصحى (دائماً)",langEn:"English (دائماً)",modelName:"النموذج",apiKey:"مفتاح API",baseUrl:"Base URL",maxToolSteps:"الحد الأقصى لخطوات الأدوات",googleSearch:"أداة بحث جوجل المدمجة (Google Search)",personaPrompt:"برومبت شخصية البوت (AI Persona)",personaDesc:"تعديل التوجيه الأساسي الذي يحدد أسلوب وشخصية مساعدك الذكي",editPersona:"تعديل برومبت الشخصية",memoryFiles:"ملفات الذاكرة طويلة المدى",memoryDesc:"استعراض وتعديل ملفات الذاكرة التراكمية المحفوظة بصيغة Markdown",manageMemory:"إدارة ملفات الذاكرة",capabilities:"القدرات والميزات المتقدمة",modelsAvailableLive:"نماذج متاحة لحسابك (تم التحقق عبر API)",modelsRecommendedSeed:"نماذج مقترحة / معروفة (دليل النماذج)",connectKeyFirstPrompt:"يرجى إدخال مفتاح API أولاً لاكتشاف النماذج المتاحة لحسابك",refreshModels:"تحديث قائمة النماذج",refreshing:"جارِ التحديث...",fetchModels:"فحص النماذج المتاحة",fetchingModels:"جارِ فحص النماذج...",capVision:"الرؤية",capStt:"الصوت",capAudio:"إدخال الصوت",capText:"نص",capPdf:"PDF",capVideo:"فيديو",supported:"مدعوم",unsupported:"غير مدعوم",sourceLive:"حسابك",sourceSeed:"مقترح",sourceUnknown:"غير معروف",visionUnsupportedNotice:"النموذج المختار لا يدعم معالجة الصور والرؤية (Vision)، تم تعطيل الميزة تلقائياً.",sttUnsupportedNotice:"النموذج المختار لا يدعم تحويل وفهم الصوت (STT)، تم تعطيل الميزة تلقائياً.",aiSttEnabled:"تفعيل تحويل وفهم الصوت (STT)",aiSttEnabledDesc:"تفريغ الرسائل الصوتية وفهم الملفات الصوتية عبر النموذج المختار",providerGemini:"Google Gemini",providerGeminiDesc:"الافتراضي، يدعم البحث والملفات والصور والصوتيات محلياً",providerGroq:"Groq Cloud",providerGroqDesc:"فائق السرعة لنماذج Llama 3 و Mixtral مع دعم Vision",providerOpenAI:"OpenAI / Compatible",providerOpenAIDesc:"لنماذج GPT-4o أو أي خادم متوافق مع API OpenAI",providerOllama:"Ollama (محلي)",providerOllamaDesc:"تشغيل النماذج محلياً على جهازك مجاناً بدون إنترنت",providerAnthropic:"Anthropic Claude",providerAnthropicDesc:"لنماذج Claude 3.5 Sonnet الذكية والمتقدمة",scanQrHint:"افتح تطبيق واتساب على هاتفك > الأجهزة المرتبطة > ربط جهاز، وامسح الرمز أدناه.",pairingCode:"رمز الربط (Pairing Code)",reconnectingSoon:"إعادة الاتصال قريباً...",nextAttemptIn:"المحاولة القادمة خلال",seconds:"ثوانٍ",tabGeneral:"عام والبادئة",tabAI:"الذكاء الاصطناعي",tabSecurity:"الأمان والوصول",tabProxy:"بروكسي واتساب",tabStorage:"التخزين والوسائط",tabLogs:"سجلات النظام",prefixTitle:"بادئة أوامر البوت (Command Prefix)",prefixDesc:"الرمز أو الحرف الذي تبدأ به جميع الأوامر الموجهة للبوت في واتساب (مثل !help أو /ping)",prefixPlaceholder:"مثال: !",prefixPresets:"بادئات شائعة سريعة:",prefixPreview:"معاينة حية لشكل الأوامر:",prefixSaveBtn:"حفظ البادئة الجديدة",prefixUpdated:"تم تحديث بادئة الأوامر بنجاح!",prefixValidation:"يجب أن تكون البادئة من رمز واحد إلى 3 رموز",activePrefix:"البادئة الحالية",changePrefix:"تعديل البادئة",prefix:"بادئة الأوامر (Prefix)",botTimezone:"المنطقة الزمنية (Timezone)",botTimezoneDesc:"المنطقة الزمنية المعتمدة لحساب أوقات الصلاة والمهام المجدولة (مثل Africa/Cairo)",botMinDelay:"الحد الأدنى للتأخير البشري (ms)",botMaxDelay:"الحد الأقصى للتأخير البشري (ms)",delaysDesc:"فترة انتظار قصيرة قبل إرسال الردود ليبدو سلوك البوت طبيعياً وبشرياً",changePassword:"تغيير كلمة مرور لوحة التحكم",currentPassword:"كلمة المرور الحالية",newPassword:"كلمة المرور الجديدة",confirmPassword:"تأكيد كلمة المرور الجديدة",passwordMatchError:"كلمتا المرور غير متطابقتين",passwordMinLength:"يجب ألا تقل كلمة المرور عن 8 خانات",passwordChangedSuccess:"تم تغيير كلمة مرور لوحة التحكم بنجاح!",proxyTitle:"بروكسي واتساب الصادر (Outbound Proxy)",proxyDesc:"توجيه اتصالات Baileys إلى واتساب عبر بروكسي خارجي لتجاوز قيود الشبكة أو الحظر",proxyEnabled:"تفعيل البروكسي لاتصالات واتساب",proxyProtocol:"بروتوكول البروكسي (Protocol)",proxyHost:"عنوان المضيف (Host / IP)",proxyPort:"المنفذ (Port)",proxyUsername:"اسم المستخدم (اختياري)",proxyPassword:"كلمة المرور (اختياري)",proxyApplyHint:"⚠️ ملاحظة: عند تعديل إعدادات البروكسي، اضغط على زر إعادة الاتصال في صفحة الاتصال لتطبيق التغييرات.",storageTitle:"إدارة البيانات والاحتفاظ بها",storageDesc:"تحديد مدد صلاحية البيانات المؤقتة وسجلات الرسائل الموجهة والحدود القصوى للجلب",forwardTtl:"صلاحية سجلات الرسائل الموجهة (أيام)",forwardTtlDesc:"حذف إحصائيات الرسائل الموجهة القديمة تلقائياً بعد مرور هذا العدد من الأيام",maxFetchBytes:"الحد الأقصى لجلب محتوى صفحات الويب (Bytes)",maxFetchBytesDesc:"حجم المحتوى الأقصى المسموح لأدوات الذكاء الاصطناعي بجلبه من صفحات الويب (افتراضي: 512KB)",ffmpegPath:"مسار محرك FFmpeg مخصص (اختياري)",weatherApiKey:"مفتاح OpenWeatherMap API (اختياري)",chooseLanguage:"اختر اللغة",langCardTitle:"لغة الواجهة: العربية (RTL)",langCardDesc:"تصميم مخصص بالكامل لاتجاه الكتابة العربي من اليمين لليسار مع خط تجوال",langSwitchBtn:"Switch to English",langName:"العربية",interfaceLanguage:"لغة لوحة التحكم",interfaceLanguageDesc:"التبديل الفوري بين الواجهة العربية (RTL) والإنجليزية (LTR)",botPort:"منفذ خادم لوحة التحكم (Port)",botPortHint:"* يتطلب تغيير المنفذ إعادة تشغيل البوت ليأخذ مفعوله",searchPlaceholder:"ابحث في الأوامر أو الأسماء البديلة...",thCommand:"الأمر",thAliases:"الأسماء البديلة",thDescription:"الوصف",thScope:"النطاق",thRequiredRole:"الرتبة المطلوبة",thStatus:"الحالة",thGroupName:"اسم المجموعة",thGroupJid:"معرف المجموعة (JID)",thMembers:"الأعضاء",thAntiLink:"مانع الروابط",thMedia:"الوسائط",thWelcome:"الترحيب",thTarget:"الوجهة",thMessage:"الرسالة",thSchedule:"الموعد",thType:"النوع",thDelivery:"حالة الإرسال",thActions:"إجراءات",scheduleNewMsg:"جدولة رسالة جديدة",liveServerLogs:"سجلات النظام المباشرة",clearLogs:"مسح السجلات",allLogs:"جميع المستويات",noLogs:"لا توجد سجلات مسجلة حتى الآن.",savedSuccessfully:"تم حفظ الإعدادات بنجاح!",saveFailed:"حدث خطأ أثناء حفظ الإعدادات.",connectionStatusUpdated:"تم تحديث حالة الاتصال.",networkError:"تعذر الاتصال بالخادم.",loading:"جاري التحميل...",aiAssistantDesc:"وكيل ذكي متعدد الأدوات مع ذاكرة طويلة الأمد",settingsSub:"البادئة، التأخير، الخدمات، والأمان",editAliases:"تعديل الأسماء المستعارة",aliasesFor:"الأسماء المستعارة لـ",addAlias:"إضافة اسم مستعار",newAliasPlaceholder:"اكتب اسماً جديداً...",noAliases:"لا توجد أسماء مستعارة",selectRecipient:"اختر المحادثة المستهدفة",searchRecipients:"ابحث بالاسم أو رقم الهاتف...",recipients:"المستلمون",chooseChat:"اختر جهة اتصال أو مجموعة...",noRecipientsFound:"لم يتم العثور على محادثات",pickPhoneContact:"من دليل الهاتف",pickPhoneContactHint:"اختر جهة اتصال من هاتف أندرويد",maxSchedulesReached:"تم بلوغ الحد الأقصى (3 رسائل مجدولة)",limitReached:"الحد الأقصى مكتمل",tabIntegrations:"الربط والخدمات",integrationsDesc:"مفاتيح واجهات البرمجة (API) للخدمات الخارجية المرتبطة بالبوت",youtubeApiKey:"مفتاح YouTube Data API (اختياري)",selectModel:"اختر نموذجاً من القائمة...",availableModels:"النماذج المتاحة من المزود",customModel:"أو اكتب اسم نموذج مخصص",sessionStatus:"حالة الجلسة",sessionActive:"الجلسة متصلة وتستقبل الرسائل",sessionOffline:"الجلسة غير متصلة حالياً",connectedNumber:"الرقم المرتبط"},en:{overview:"Overview",connection:"Connection",control:"Control & Management",commands:"Command Catalog",ai:"AI & Memory",groups:"Groups",roles:"Roles & Admins",schedules:"Scheduled Messages",notes:"Notes & Lists",settings:"Settings",logs:"Live Logs",connected:"Connected to WhatsApp",disconnected:"Disconnected",starting:"Starting socket...",waiting_for_qr:"Waiting for QR scan",linking:"Linking session...",reconnecting:"Reconnecting...",retry_exhausted:"Retries exhausted",logged_out:"Logged out from phone",idle:"Session idle",paused:"Paused",resume:"Resume session",connectSession:"Connect",start:"Start Connection",stop:"Pause",reconnect:"Reconnect",unlink:"Unlink Device",restart:"Restart Bot",save:"Save Changes",saving:"Saving...",cancel:"Cancel",delete:"Delete",edit:"Edit",add:"Add",refresh:"Refresh",logout:"Sign Out",close:"Close",copy:"Copy",copied:"Copied!",clientIdentity:"Client Identity",noPhonePaired:"No phone paired yet",linkedAs:"Linked as",datastoreHealth:"Datastore Health",datastoreHealthy:"SQLite credentials, auth keys, and LID mappings are healthy.",reconnectPolicy:"Reconnect Policy",reconnectPolicyDesc:"Staged linear backoff (5s, 10s, 15s, 20s, 25s) with bounded retries.",maxAttemptsAutoPause:"Max attempts: 5 • Auto-pause offline",platformWeb:"Platform: WhatsApp Web (v7 Multi-Device)",databaseNodeSqlite:"Database: node:sqlite (Synchronous)",totalGroups:"Total Groups",totalUsers:"Registered Users",commandCount:"Enabled Commands",uptime:"Uptime",dataDir:"Data Directory",quickStatus:"System Status",activeSchedules:"Active Schedules",activeListening:"Active and listening to messages",pausedOrLinking:"WhatsApp connection is currently paused or linking",aiTitle:"AI Assistant Configuration",aiSubtitle:"Select a provider with one click or configure custom endpoints and keys",aiAgentEnabled:"Enable AI Agent",aiProvider:"Active Provider",quickSetup:"Quick Provider Setup Wizard",aiVision:"Image Understanding (Vision)",aiVisionDesc:"Encode attached images and pass to supported multimodal vision models",aiStt:"Speech-to-Text Provider (STT)",sttDesc:"Speech-to-text transcription engine for voice notes",sttAuto:"Auto (Matches active provider)",sttGemini:"Google Gemini Audio API",sttOpenAI:"OpenAI / Groq Whisper API",botLanguage:"Bot Response Language",botLanguageDesc:"Set bot response language directly or via command !lang",langAuto:"Auto-detect (matches user's language)",langAr:"Modern Standard Arabic (Always)",langEn:"English (Always)",modelName:"Model",apiKey:"API key",baseUrl:"Base URL",maxToolSteps:"Max Tool Steps",googleSearch:"Built-in Google Search Grounding",personaPrompt:"AI Persona System Prompt",personaDesc:"Edit the live system prompt that shapes your AI assistant's persona, tone, and behavior.",editPersona:"Edit System Prompt",memoryFiles:"Long-term Memory Files",memoryDesc:"Inspect and manage markdown memory documents stored inside the data directory.",manageMemory:"Manage Memory Files",capabilities:"Capabilities & Toggles",modelsAvailableLive:"Models Available for Your Account (Live API Verified)",modelsRecommendedSeed:"Recommended / Known Models (Catalog)",connectKeyFirstPrompt:"Please connect your API key first to discover models available to your account",refreshModels:"Refresh Models",refreshing:"Refreshing...",fetchModels:"Fetch Available Models",fetchingModels:"Discovering models...",capVision:"Vision",capStt:"Speech",capAudio:"Audio in",capText:"Text",capPdf:"PDF",capVideo:"Video",supported:"Supported",unsupported:"Unsupported",sourceLive:"Your account",sourceSeed:"Catalog",sourceUnknown:"Unknown",visionUnsupportedNotice:"The selected model does not support Vision (image understanding). Feature disabled automatically.",sttUnsupportedNotice:"The selected model does not support Speech-to-Text (STT). Feature disabled automatically.",aiSttEnabled:"Enable Speech-to-Text (STT)",aiSttEnabledDesc:"Audio transcription and voice note understanding using the active model",providerGemini:"Google Gemini",providerGeminiDesc:"Default provider with native Google Search, Files upload, and Multimodal support",providerGroq:"Groq Cloud",providerGroqDesc:"Ultra-fast inference for Llama 3 & Mixtral models with Vision support",providerOpenAI:"OpenAI / Compatible",providerOpenAIDesc:"For GPT-4o models or any OpenAI-compatible API gateway",providerOllama:"Ollama (Local)",providerOllamaDesc:"Run local open-source models completely offline on your own machine",providerAnthropic:"Anthropic Claude",providerAnthropicDesc:"For Claude 3.5 Sonnet advanced reasoning models",scanQrHint:"Open WhatsApp on your phone > Settings > Linked Devices > Link a Device, and scan the QR code below.",pairingCode:"Pairing Code",reconnectingSoon:"Reconnecting soon...",nextAttemptIn:"Next attempt in",seconds:"seconds",tabGeneral:"General & Prefix",tabAI:"AI Assistant",tabSecurity:"Security & Access",tabProxy:"WhatsApp Proxy",tabStorage:"Storage & Media",tabLogs:"System Logs",prefixTitle:"Bot Command Prefix",prefixDesc:"The leading character or symbol that triggers commands in WhatsApp chats (e.g. !help, /ping)",prefixPlaceholder:"e.g. !",prefixPresets:"Common Quick Presets:",prefixPreview:"Live Command Syntax Preview:",prefixSaveBtn:"Save New Prefix",prefixUpdated:"Command prefix updated successfully!",prefixValidation:"Prefix must be 1 to 3 characters long",activePrefix:"Active Prefix",changePrefix:"Change Prefix",prefix:"Command Prefix",botTimezone:"Timezone",botTimezoneDesc:"IANA timezone used for prayer times, AI context, and cron schedules (e.g. Africa/Cairo)",botMinDelay:"Min Human Delay (ms)",botMaxDelay:"Max Human Delay (ms)",delaysDesc:"Simulated human typing pause before replying to avoid robotic triggers",changePassword:"Change Dashboard Password",currentPassword:"Current Password",newPassword:"New Password",confirmPassword:"Confirm New Password",passwordMatchError:"Passwords do not match",passwordMinLength:"Password must be at least 8 characters long",passwordChangedSuccess:"Dashboard password changed successfully!",proxyTitle:"Outbound WhatsApp Proxy",proxyDesc:"Route Baileys WhatsApp traffic through an HTTP or SOCKS5 proxy to bypass restrictions",proxyEnabled:"Enable Outbound Proxy for WhatsApp",proxyProtocol:"Proxy Protocol",proxyHost:"Proxy Host / IP",proxyPort:"Proxy Port",proxyUsername:"Username (Optional)",proxyPassword:"Password (Optional)",proxyApplyHint:"⚠️ Note: To apply proxy changes, go to Connection and reconnect WhatsApp.",storageTitle:"Data Retention & Storage Limits",storageDesc:"Configure data cleanup thresholds, forward score retention, and fetch limits",forwardTtl:"Forward Score Expiry (Days)",forwardTtlDesc:"Automatically purge forwarded message scores after this many days",maxFetchBytes:"Web Fetch Byte Limit",maxFetchBytesDesc:"Maximum response body size AI tools are allowed to fetch from web pages (default: 512KB)",ffmpegPath:"Custom FFmpeg Binary Path (Optional)",weatherApiKey:"OpenWeatherMap API Key (Optional)",chooseLanguage:"Choose Language",langCardTitle:"Interface Language: English (LTR)",langCardDesc:"Full bidirectional layout support with optimized Arabic RTL & English LTR",langSwitchBtn:"التبديل إلى العربية",langName:"English",interfaceLanguage:"Dashboard Interface Language",interfaceLanguageDesc:"Instantly toggle between Arabic (RTL) and English (LTR)",botPort:"Control Panel Port",botPortHint:"* Changing port takes effect on next process restart",searchPlaceholder:"Search commands or aliases...",thCommand:"Command",thAliases:"Aliases",thDescription:"Description",thScope:"Scope",thRequiredRole:"Required Role",thStatus:"Status",thGroupName:"Group Name",thGroupJid:"Group JID",thMembers:"Members",thAntiLink:"Anti-Link",thMedia:"Media",thWelcome:"Welcome",thTarget:"Target",thMessage:"Message",thSchedule:"Schedule",thType:"Type",thDelivery:"Delivery Status",thActions:"Actions",scheduleNewMsg:"Schedule New Message",liveServerLogs:"Live Server Logs",clearLogs:"Clear Logs",allLogs:"All Levels",noLogs:"No log entries to display.",savedSuccessfully:"Settings saved successfully!",saveFailed:"Failed to save settings.",connectionStatusUpdated:"Connection status updated.",networkError:"Network error connecting to server.",loading:"Loading...",aiAssistantDesc:"Autonomous tool-calling AI agent with long-term memory",settingsSub:"Prefix, delays, integrations, & security",editAliases:"Edit Aliases",aliasesFor:"Aliases for",addAlias:"Add Alias",newAliasPlaceholder:"Type new alias...",noAliases:"No custom aliases",selectRecipient:"Select Target Chat",searchRecipients:"Search by name or phone...",recipients:"Recipients",chooseChat:"Choose a contact or group...",noRecipientsFound:"No matching chats found",pickPhoneContact:"From phone book",pickPhoneContactHint:"Pick a contact from this Android phone",maxSchedulesReached:"Maximum limit reached (3 scheduled messages)",limitReached:"Limit Reached",tabIntegrations:"Integrations",integrationsDesc:"API keys for external services connected to the bot",youtubeApiKey:"YouTube Data API Key (Optional)",selectModel:"Select a model from list...",availableModels:"Models Available from Provider",customModel:"Or type a custom model name",sessionStatus:"Session Status",sessionActive:"Session active and receiving messages",sessionOffline:"Session currently offline",connectedNumber:"Linked Phone"}},xb=K.createContext(null),Gv=({children:i})=>{const[r,u]=K.useState(()=>{const p=localStorage.getItem("levix_lang");return p==="ar"||p==="en"?p:navigator.language.startsWith("ar")?"ar":"en"}),c=r==="ar"?"rtl":"ltr";K.useEffect(()=>{localStorage.setItem("levix_lang",r),document.documentElement.lang=r,document.documentElement.dir=c},[r,c]);const d=p=>{u(p)},h=K.useMemo(()=>(p,g)=>(Gu[r]||Gu.en)[p]??Gu.en[p]??g??String(p),[r]);return o.jsx(xb.Provider,{value:{language:r,direction:c,setLanguage:d,t:h},children:i})},rn=()=>{const i=K.useContext(xb);if(!i)throw new Error("useI18n must be used within an I18nProvider");return i},Vv=({onToggleMobileMenu:i,title:r,status:u})=>{const{language:c,setLanguage:d,t:h}=rn(),[p,g]=Qi.useState(!1),b=Qi.useRef(null);Qi.useEffect(()=>{if(!p)return;const C=Z=>{b.current&&!b.current.contains(Z.target)&&g(!1)},U=Z=>{Z.key==="Escape"&&g(!1)};return document.addEventListener("mousedown",C),document.addEventListener("keydown",U),()=>{document.removeEventListener("mousedown",C),document.removeEventListener("keydown",U)}},[p]);const[E,v]=Qi.useState(()=>{const C=localStorage.getItem("levix_theme");return C?(document.documentElement.setAttribute("data-theme",C),C):document.documentElement.getAttribute("data-theme")||"dark"}),x=()=>{const C=E==="dark"?"light":"dark";v(C),document.documentElement.setAttribute("data-theme",C),localStorage.setItem("levix_theme",C)};return o.jsxs("header",{className:"h-16 sticky top-0 z-30 flex items-center justify-between px-4 md:px-6 bg-panel/85 backdrop-blur-md border-b border-line",children:[o.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[o.jsx("button",{type:"button",onClick:i,className:"inline-flex md:hidden items-center justify-center w-11 h-11 rounded-xl border border-line bg-panel-raised hover:bg-panel-hover text-text-main transition-colors focus-visible:ring-2 focus-visible:ring-brand-blue/50",id:"mobile-menu-btn","aria-label":"Open navigation menu",children:o.jsx(Ev,{size:20})}),o.jsx("h1",{className:"text-lg md:text-xl font-bold tracking-tight text-text-main truncate",title:r,children:r})]}),o.jsxs("div",{className:"flex items-center gap-2 md:gap-3",children:[o.jsxs("div",{className:"relative",ref:b,children:[o.jsx("button",{type:"button",onClick:()=>g(C=>!C),className:"inline-flex items-center justify-center w-11 h-11 rounded-xl border border-line bg-panel-raised hover:bg-panel-hover text-text-main transition-colors focus-visible:ring-2 focus-visible:ring-brand-blue/50",title:h("chooseLanguage","Choose Language"),"aria-label":h("chooseLanguage","Choose Language"),"aria-expanded":p,"aria-haspopup":"true",id:"btn-header-lang",children:o.jsx(Hr,{size:18,className:"text-brand-cyan"})}),p&&o.jsxs("div",{role:"menu","aria-orientation":"vertical","aria-labelledby":"btn-header-lang",className:"absolute end-0 mt-2 w-48 rounded-2xl border border-line bg-panel-solid shadow-2xl p-1.5 z-50 ring-1 ring-black/10 animate-in fade-in zoom-in-95 duration-150",children:[o.jsx("div",{className:"px-2.5 py-1.5 text-[11px] font-semibold text-text-muted uppercase tracking-wider",children:h("chooseLanguage","Choose Language")}),o.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{d("ar"),g(!1)},className:`w-full flex items-center justify-between px-3 py-2 text-xs md:text-sm font-medium rounded-lg transition-colors ${c==="ar"?"bg-brand-blue/15 text-brand-cyan font-bold":"text-text-main hover:bg-panel-hover"}`,children:[o.jsx("span",{children:"العربية"}),c==="ar"&&o.jsx(Lr,{size:16,className:"text-brand-cyan"})]}),o.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{d("en"),g(!1)},className:`w-full flex items-center justify-between px-3 py-2 text-xs md:text-sm font-medium rounded-lg transition-colors ${c==="en"?"bg-brand-blue/15 text-brand-cyan font-bold":"text-text-main hover:bg-panel-hover"}`,children:[o.jsx("span",{children:"English"}),c==="en"&&o.jsx(Lr,{size:16,className:"text-brand-cyan"})]})]})]}),o.jsx("button",{type:"button",onClick:x,className:"inline-flex items-center justify-center w-11 h-11 rounded-xl border border-line bg-panel-raised hover:bg-panel-hover text-text-main transition-colors focus-visible:ring-2 focus-visible:ring-brand-blue/50",title:"Toggle Theme","aria-label":"Toggle dark/light theme",children:E==="dark"?o.jsx(Uv,{size:18}):o.jsx(Mv,{size:18})}),o.jsx("form",{action:"/logout",method:"POST",className:"m-0",children:o.jsx("button",{type:"submit",className:"inline-flex items-center justify-center w-11 h-11 rounded-xl border border-line bg-panel-raised hover:bg-danger/15 hover:border-danger/40 hover:text-danger text-text-main transition-colors focus-visible:ring-2 focus-visible:ring-danger/50",title:h("logout"),"aria-label":"Sign out",children:o.jsx(Cv,{size:18,className:"rtl:-scale-x-100 transition-transform"})})})]})]})};function bb(i){var r,u,c="";if(typeof i=="string"||typeof i=="number")c+=i;else if(typeof i=="object")if(Array.isArray(i)){var d=i.length;for(r=0;r<d;r++)i[r]&&(u=bb(i[r]))&&(c&&(c+=" "),c+=u)}else for(u in i)i[u]&&(c&&(c+=" "),c+=u);return c}function Yv(){for(var i,r,u=0,c="",d=arguments.length;u<d;u++)(i=arguments[u])&&(r=bb(i))&&(c&&(c+=" "),c+=r);return c}const Qv=(i,r)=>{const u=new Array(i.length+r.length);for(let c=0;c<i.length;c++)u[c]=i[c];for(let c=0;c<r.length;c++)u[i.length+c]=r[c];return u},Xv=(i,r)=>({classGroupId:i,validator:r}),yb=(i=new Map,r=null,u)=>({nextPart:i,validators:r,classGroupId:u}),Yr="-",wg=[],Kv="arbitrary..",Zv=i=>{const r=Iv(i),{conflictingClassGroups:u,conflictingClassGroupModifiers:c}=i;return{getClassGroupId:p=>{if(p.startsWith("[")&&p.endsWith("]"))return Jv(p);const g=p.split(Yr),b=g[0]===""&&g.length>1?1:0;return vb(g,b,r)},getConflictingClassGroupIds:(p,g)=>{if(g){const b=c[p],E=u[p];return b?E?Qv(E,b):b:E||wg}return u[p]||wg}}},vb=(i,r,u)=>{if(i.length-r===0)return u.classGroupId;const d=i[r],h=u.nextPart.get(d);if(h){const E=vb(i,r+1,h);if(E)return E}const p=u.validators;if(p===null)return;const g=r===0?i.join(Yr):i.slice(r).join(Yr),b=p.length;for(let E=0;E<b;E++){const v=p[E];if(v.validator(g))return v.classGroupId}},Jv=i=>i.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const r=i.slice(1,-1),u=r.indexOf(":"),c=r.slice(0,u);return c?Kv+c:void 0})(),Iv=i=>{const{theme:r,classGroups:u}=i;return Pv(u,r)},Pv=(i,r)=>{const u=yb();for(const c in i){const d=i[c];zd(d,u,c,r)}return u},zd=(i,r,u,c)=>{const d=i.length;for(let h=0;h<d;h++){const p=i[h];Fv(p,r,u,c)}},Fv=(i,r,u,c)=>{if(typeof i=="string"){$v(i,r,u);return}if(typeof i=="function"){Wv(i,r,u,c);return}e2(i,r,u,c)},$v=(i,r,u)=>{const c=i===""?r:Nb(r,i);c.classGroupId=u},Wv=(i,r,u,c)=>{if(t2(i)){zd(i(c),r,u,c);return}r.validators===null&&(r.validators=[]),r.validators.push(Xv(u,i))},e2=(i,r,u,c)=>{const d=Object.entries(i),h=d.length;for(let p=0;p<h;p++){const[g,b]=d[p];zd(b,Nb(r,g),u,c)}},Nb=(i,r)=>{let u=i;const c=r.split(Yr),d=c.length;for(let h=0;h<d;h++){const p=c[h];let g=u.nextPart.get(p);g||(g=yb(),u.nextPart.set(p,g)),u=g}return u},t2=i=>"isThemeGetter"in i&&i.isThemeGetter===!0,n2=i=>{if(i<1)return{get:()=>{},set:()=>{}};let r=0,u=Object.create(null),c=Object.create(null);const d=(h,p)=>{u[h]=p,r++,r>i&&(r=0,c=u,u=Object.create(null))};return{get(h){let p=u[h];if(p!==void 0)return p;if((p=c[h])!==void 0)return d(h,p),p},set(h,p){h in u?u[h]=p:d(h,p)}}},Nd="!",Sg=":",l2=[],jg=(i,r,u,c,d)=>({modifiers:i,hasImportantModifier:r,baseClassName:u,maybePostfixModifierPosition:c,isExternal:d}),a2=i=>{const{prefix:r,experimentalParseClassName:u}=i;let c=d=>{const h=[];let p=0,g=0,b=0,E;const v=d.length;for(let D=0;D<v;D++){const B=d[D];if(p===0&&g===0){if(B===Sg){h.push(d.slice(b,D)),b=D+1;continue}if(B==="/"){E=D;continue}}B==="["?p++:B==="]"?p--:B==="("?g++:B===")"&&g--}const x=h.length===0?d:d.slice(b);let C=x,U=!1;x.endsWith(Nd)?(C=x.slice(0,-1),U=!0):x.startsWith(Nd)&&(C=x.slice(1),U=!0);const Z=E&&E>b?E-b:void 0;return jg(h,U,C,Z)};if(r){const d=r+Sg,h=c;c=p=>p.startsWith(d)?h(p.slice(d.length)):jg(l2,!1,p,void 0,!0)}if(u){const d=c;c=h=>u({className:h,parseClassName:d})}return c},i2=i=>{const r=new Map;return i.orderSensitiveModifiers.forEach((u,c)=>{r.set(u,1e6+c)}),u=>{const c=[];let d=[];for(let h=0;h<u.length;h++){const p=u[h],g=p[0]==="[",b=r.has(p);g||b?(d.length>0&&(d.sort(),c.push(...d),d=[]),c.push(p)):d.push(p)}return d.length>0&&(d.sort(),c.push(...d)),c}},s2=i=>({cache:n2(i.cacheSize),parseClassName:a2(i),sortModifiers:i2(i),postfixLookupClassGroupIds:r2(i),...Zv(i)}),r2=i=>{const r=Object.create(null),u=i.postfixLookupClassGroups;if(u)for(let c=0;c<u.length;c++)r[u[c]]=!0;return r},o2=/\s+/,c2=(i,r)=>{const{parseClassName:u,getClassGroupId:c,getConflictingClassGroupIds:d,sortModifiers:h,postfixLookupClassGroupIds:p}=r,g=[],b=i.trim().split(o2);let E="";for(let v=b.length-1;v>=0;v-=1){const x=b[v],{isExternal:C,modifiers:U,hasImportantModifier:Z,baseClassName:D,maybePostfixModifierPosition:B}=u(x);if(C){E=x+(E.length>0?" "+E:E);continue}let G=!!B,X;if(G){const Y=D.substring(0,B);X=c(Y);const R=X&&p[X]?c(D):void 0;R&&R!==X&&(X=R,G=!1)}else X=c(D);if(!X){if(!G){E=x+(E.length>0?" "+E:E);continue}if(X=c(D),!X){E=x+(E.length>0?" "+E:E);continue}G=!1}const le=U.length===0?"":U.length===1?U[0]:h(U).join(":"),W=Z?le+Nd:le,me=W+X;if(g.indexOf(me)>-1)continue;g.push(me);const J=d(X,G);for(let Y=0;Y<J.length;++Y){const R=J[Y];g.push(W+R)}E=x+(E.length>0?" "+E:E)}return E},u2=(...i)=>{let r=0,u,c,d="";for(;r<i.length;)(u=i[r++])&&(c=wb(u))&&(d&&(d+=" "),d+=c);return d},wb=i=>{if(typeof i=="string")return i;let r,u="";for(let c=0;c<i.length;c++)i[c]&&(r=wb(i[c]))&&(u&&(u+=" "),u+=r);return u},d2=(i,...r)=>{let u,c,d,h;const p=b=>{const E=r.reduce((v,x)=>x(v),i());return u=s2(E),c=u.cache.get,d=u.cache.set,h=g,g(b)},g=b=>{const E=c(b);if(E)return E;const v=c2(b,u);return d(b,v),v};return h=p,(...b)=>h(u2(...b))},f2=[],ct=i=>{const r=u=>u[i]||f2;return r.isThemeGetter=!0,r.themeKey=i,r},Sb=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,jb=/^\((?:(\w[\w-]*):)?(.+)\)$/i,h2=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,m2=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,p2=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,g2=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix|color|light-dark)\(.+\)$/,x2=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,b2=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,pl=i=>h2.test(i),Ce=i=>!!i&&!Number.isNaN(Number(i)),yn=i=>!!i&&Number.isInteger(Number(i)),Vu=i=>i.endsWith("%")&&Ce(i.slice(0,-1)),qn=i=>m2.test(i),_b=()=>!0,y2=i=>p2.test(i)&&!g2.test(i),Md=()=>!1,v2=i=>x2.test(i),N2=i=>b2.test(i),w2=i=>!ue(i)&&!de(i),S2=i=>i.startsWith("@container")&&(i[10]==="/"&&i[11]!==void 0||i[11]==="s"&&i[16]!==void 0&&i.startsWith("-size/",10)||i[11]==="n"&&i[18]!==void 0&&i.startsWith("-normal/",10)),j2=i=>bl(i,Cb,Md),ue=i=>Sb.test(i),Ql=i=>bl(i,Eb,y2),_g=i=>bl(i,O2,Ce),_2=i=>bl(i,Mb,_b),A2=i=>bl(i,zb,Md),Ag=i=>bl(i,Ab,Md),T2=i=>bl(i,Tb,N2),Ar=i=>bl(i,Ob,v2),de=i=>jb.test(i),Gi=i=>Kl(i,Eb),C2=i=>Kl(i,zb),Tg=i=>Kl(i,Ab),E2=i=>Kl(i,Cb),z2=i=>Kl(i,Tb),Tr=i=>Kl(i,Ob,!0),M2=i=>Kl(i,Mb,!0),bl=(i,r,u)=>{const c=Sb.exec(i);return c?c[1]?r(c[1]):u(c[2]):!1},Kl=(i,r,u=!1)=>{const c=jb.exec(i);return c?c[1]?r(c[1]):u:!1},Ab=i=>i==="position"||i==="percentage",Tb=i=>i==="image"||i==="url",Cb=i=>i==="length"||i==="size"||i==="bg-size",Eb=i=>i==="length",O2=i=>i==="number",zb=i=>i==="family-name",Mb=i=>i==="number"||i==="weight",Ob=i=>i==="shadow",k2=()=>{const i=ct("color"),r=ct("font"),u=ct("text"),c=ct("font-weight"),d=ct("tracking"),h=ct("leading"),p=ct("breakpoint"),g=ct("container"),b=ct("spacing"),E=ct("radius"),v=ct("shadow"),x=ct("inset-shadow"),C=ct("text-shadow"),U=ct("drop-shadow"),Z=ct("blur"),D=ct("perspective"),B=ct("aspect"),G=ct("ease"),X=ct("animate"),le=()=>["auto","avoid","all","avoid-page","page","left","right","column"],W=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],me=()=>[...W(),de,ue],J=()=>["auto","hidden","clip","visible","scroll"],Y=()=>["auto","contain","none"],R=()=>[de,ue,b],I=()=>[pl,"full","auto",...R()],ie=()=>[yn,"none","subgrid",de,ue],$=()=>["auto",{span:["full",yn,de,ue]},yn,de,ue],te=()=>[yn,"auto",de,ue],Q=()=>["auto","min","max","fr",de,ue],ae=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],pe=()=>["start","end","center","stretch","center-safe","end-safe"],T=()=>["auto",...R()],F=()=>[pl,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...R()],M=()=>[g,pl,"screen","full","dvw","lvw","svw","min","max","fit",...R()],se=()=>[pl,"screen","full","lh","dvh","lvh","svh","min","max","fit",...R()],V=()=>[i,de,ue],Me=()=>[...W(),Tg,Ag,{position:[de,ue]}],Ue=()=>["no-repeat",{repeat:["","x","y","space","round"]}],Ge=()=>["auto","cover","contain",E2,j2,{size:[de,ue]}],N=()=>[Vu,Gi,Ql],S=()=>["","none","full",E,de,ue],P=()=>["",Ce,Gi,Ql],ne=()=>["solid","dashed","dotted","double"],ye=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],fe=()=>[Ce,Vu,Tg,Ag],Se=()=>["","none",Z,de,ue],oe=()=>["none",Ce,de,ue],be=()=>["none",Ce,de,ue],L=()=>[Ce,de,ue],je=()=>[pl,"full",...R()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[qn],breakpoint:[qn],color:[_b],container:[qn],"drop-shadow":[qn],ease:["in","out","in-out"],font:[w2],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[qn],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[qn],shadow:[qn],spacing:["px",Ce],text:[qn],"text-shadow":[qn],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",pl,ue,de,B]}],container:["container"],"container-type":[{"@container":["","normal","size",de,ue]}],"container-named":[S2],columns:[{columns:[Ce,"auto",ue,de,g]}],"break-after":[{"break-after":le()}],"break-before":[{"break-before":le()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:me()}],overflow:[{overflow:J()}],"overflow-x":[{"overflow-x":J()}],"overflow-y":[{"overflow-y":J()}],overscroll:[{overscroll:Y()}],"overscroll-x":[{"overscroll-x":Y()}],"overscroll-y":[{"overscroll-y":Y()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:I()}],"inset-x":[{"inset-x":I()}],"inset-y":[{"inset-y":I()}],start:[{"inset-s":I(),start:I()}],end:[{"inset-e":I(),end:I()}],"inset-bs":[{"inset-bs":I()}],"inset-be":[{"inset-be":I()}],top:[{top:I()}],right:[{right:I()}],bottom:[{bottom:I()}],left:[{left:I()}],visibility:["visible","invisible","collapse"],z:[{z:[yn,"auto",de,ue]}],basis:[{basis:[pl,"full","auto",g,...R()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ce,pl,"auto","initial","none",ue]}],grow:[{grow:["",Ce,de,ue]}],shrink:[{shrink:["",Ce,de,ue]}],order:[{order:[yn,"first","last","none",de,ue]}],"grid-cols":[{"grid-cols":ie()}],"col-start-end":[{col:$()}],"col-start":[{"col-start":te()}],"col-end":[{"col-end":te()}],"grid-rows":[{"grid-rows":ie()}],"row-start-end":[{row:$()}],"row-start":[{"row-start":te()}],"row-end":[{"row-end":te()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":Q()}],"auto-rows":[{"auto-rows":Q()}],gap:[{gap:R()}],"gap-x":[{"gap-x":R()}],"gap-y":[{"gap-y":R()}],"justify-content":[{justify:[...ae(),"normal"]}],"justify-items":[{"justify-items":[...pe(),"normal"]}],"justify-self":[{"justify-self":["auto",...pe()]}],"align-content":[{content:["normal",...ae()]}],"align-items":[{items:[...pe(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...pe(),{baseline:["","last"]}]}],"place-content":[{"place-content":ae()}],"place-items":[{"place-items":[...pe(),"baseline"]}],"place-self":[{"place-self":["auto",...pe()]}],p:[{p:R()}],px:[{px:R()}],py:[{py:R()}],ps:[{ps:R()}],pe:[{pe:R()}],pbs:[{pbs:R()}],pbe:[{pbe:R()}],pt:[{pt:R()}],pr:[{pr:R()}],pb:[{pb:R()}],pl:[{pl:R()}],m:[{m:T()}],mx:[{mx:T()}],my:[{my:T()}],ms:[{ms:T()}],me:[{me:T()}],mbs:[{mbs:T()}],mbe:[{mbe:T()}],mt:[{mt:T()}],mr:[{mr:T()}],mb:[{mb:T()}],ml:[{ml:T()}],"space-x":[{"space-x":R()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":R()}],"space-y-reverse":["space-y-reverse"],size:[{size:F()}],"inline-size":[{inline:["auto",...M()]}],"min-inline-size":[{"min-inline":["auto",...M()]}],"max-inline-size":[{"max-inline":["none",...M()]}],"block-size":[{block:["auto",...se()]}],"min-block-size":[{"min-block":["auto",...se()]}],"max-block-size":[{"max-block":["none",...se()]}],w:[{w:[g,"screen",...F()]}],"min-w":[{"min-w":[g,"screen","none",...F()]}],"max-w":[{"max-w":[g,"screen","none","prose",{screen:[p]},...F()]}],h:[{h:["screen","lh",...F()]}],"min-h":[{"min-h":["screen","lh","none",...F()]}],"max-h":[{"max-h":["screen","lh","none",...F()]}],"font-size":[{text:["base",u,Gi,Ql]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[c,M2,_2]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Vu,ue]}],"font-family":[{font:[C2,A2,r]}],"font-features":[{"font-features":[ue]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[d,de,ue]}],"line-clamp":[{"line-clamp":[Ce,"none",de,_g]}],leading:[{leading:["none",h,...R()]}],"list-image":[{"list-image":["none",de,ue]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",de,ue]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:V()}],"text-color":[{text:V()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ne(),"wavy"]}],"text-decoration-thickness":[{decoration:[Ce,"from-font","auto",de,Ql]}],"text-decoration-color":[{decoration:V()}],"underline-offset":[{"underline-offset":[Ce,"auto",de,ue]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:R()}],"tab-size":[{tab:[yn,de,ue]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",de,ue]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",de,ue]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:Me()}],"bg-repeat":[{bg:Ue()}],"bg-size":[{bg:Ge()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},yn,de,ue],radial:["",de,ue],conic:["",yn,de,ue]},z2,T2]}],"bg-color":[{bg:V()}],"gradient-from-pos":[{from:N()}],"gradient-via-pos":[{via:N()}],"gradient-to-pos":[{to:N()}],"gradient-from":[{from:V()}],"gradient-via":[{via:V()}],"gradient-to":[{to:V()}],rounded:[{rounded:S()}],"rounded-s":[{"rounded-s":S()}],"rounded-e":[{"rounded-e":S()}],"rounded-t":[{"rounded-t":S()}],"rounded-r":[{"rounded-r":S()}],"rounded-b":[{"rounded-b":S()}],"rounded-l":[{"rounded-l":S()}],"rounded-ss":[{"rounded-ss":S()}],"rounded-se":[{"rounded-se":S()}],"rounded-ee":[{"rounded-ee":S()}],"rounded-es":[{"rounded-es":S()}],"rounded-tl":[{"rounded-tl":S()}],"rounded-tr":[{"rounded-tr":S()}],"rounded-br":[{"rounded-br":S()}],"rounded-bl":[{"rounded-bl":S()}],"border-w":[{border:P()}],"border-w-x":[{"border-x":P()}],"border-w-y":[{"border-y":P()}],"border-w-s":[{"border-s":P()}],"border-w-e":[{"border-e":P()}],"border-w-bs":[{"border-bs":P()}],"border-w-be":[{"border-be":P()}],"border-w-t":[{"border-t":P()}],"border-w-r":[{"border-r":P()}],"border-w-b":[{"border-b":P()}],"border-w-l":[{"border-l":P()}],"divide-x":[{"divide-x":P()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":P()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...ne(),"hidden","none"]}],"divide-style":[{divide:[...ne(),"hidden","none"]}],"border-color":[{border:V()}],"border-color-x":[{"border-x":V()}],"border-color-y":[{"border-y":V()}],"border-color-s":[{"border-s":V()}],"border-color-e":[{"border-e":V()}],"border-color-bs":[{"border-bs":V()}],"border-color-be":[{"border-be":V()}],"border-color-t":[{"border-t":V()}],"border-color-r":[{"border-r":V()}],"border-color-b":[{"border-b":V()}],"border-color-l":[{"border-l":V()}],"divide-color":[{divide:V()}],"outline-style":[{outline:[...ne(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Ce,de,ue]}],"outline-w":[{outline:["",Ce,Gi,Ql]}],"outline-color":[{outline:V()}],shadow:[{shadow:["","inner","none",v,Tr,Ar]}],"shadow-color":[{shadow:V()}],"inset-shadow":[{"inset-shadow":["none",x,Tr,Ar]}],"inset-shadow-color":[{"inset-shadow":V()}],"ring-w":[{ring:P()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:V()}],"ring-offset-w":[{"ring-offset":[Ce,Ql]}],"ring-offset-color":[{"ring-offset":V()}],"inset-ring-w":[{"inset-ring":P()}],"inset-ring-color":[{"inset-ring":V()}],"text-shadow":[{"text-shadow":["none",C,Tr,Ar]}],"text-shadow-color":[{"text-shadow":V()}],opacity:[{opacity:[Ce,de,ue]}],"mix-blend":[{"mix-blend":[...ye(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":ye()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Ce]}],"mask-image-linear-from-pos":[{"mask-linear-from":fe()}],"mask-image-linear-to-pos":[{"mask-linear-to":fe()}],"mask-image-linear-from-color":[{"mask-linear-from":V()}],"mask-image-linear-to-color":[{"mask-linear-to":V()}],"mask-image-t-from-pos":[{"mask-t-from":fe()}],"mask-image-t-to-pos":[{"mask-t-to":fe()}],"mask-image-t-from-color":[{"mask-t-from":V()}],"mask-image-t-to-color":[{"mask-t-to":V()}],"mask-image-r-from-pos":[{"mask-r-from":fe()}],"mask-image-r-to-pos":[{"mask-r-to":fe()}],"mask-image-r-from-color":[{"mask-r-from":V()}],"mask-image-r-to-color":[{"mask-r-to":V()}],"mask-image-b-from-pos":[{"mask-b-from":fe()}],"mask-image-b-to-pos":[{"mask-b-to":fe()}],"mask-image-b-from-color":[{"mask-b-from":V()}],"mask-image-b-to-color":[{"mask-b-to":V()}],"mask-image-l-from-pos":[{"mask-l-from":fe()}],"mask-image-l-to-pos":[{"mask-l-to":fe()}],"mask-image-l-from-color":[{"mask-l-from":V()}],"mask-image-l-to-color":[{"mask-l-to":V()}],"mask-image-x-from-pos":[{"mask-x-from":fe()}],"mask-image-x-to-pos":[{"mask-x-to":fe()}],"mask-image-x-from-color":[{"mask-x-from":V()}],"mask-image-x-to-color":[{"mask-x-to":V()}],"mask-image-y-from-pos":[{"mask-y-from":fe()}],"mask-image-y-to-pos":[{"mask-y-to":fe()}],"mask-image-y-from-color":[{"mask-y-from":V()}],"mask-image-y-to-color":[{"mask-y-to":V()}],"mask-image-radial":[{"mask-radial":[de,ue]}],"mask-image-radial-from-pos":[{"mask-radial-from":fe()}],"mask-image-radial-to-pos":[{"mask-radial-to":fe()}],"mask-image-radial-from-color":[{"mask-radial-from":V()}],"mask-image-radial-to-color":[{"mask-radial-to":V()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":W()}],"mask-image-conic-pos":[{"mask-conic":[Ce]}],"mask-image-conic-from-pos":[{"mask-conic-from":fe()}],"mask-image-conic-to-pos":[{"mask-conic-to":fe()}],"mask-image-conic-from-color":[{"mask-conic-from":V()}],"mask-image-conic-to-color":[{"mask-conic-to":V()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:Me()}],"mask-repeat":[{mask:Ue()}],"mask-size":[{mask:Ge()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",de,ue]}],filter:[{filter:["","none",de,ue]}],blur:[{blur:Se()}],brightness:[{brightness:[Ce,de,ue]}],contrast:[{contrast:[Ce,de,ue]}],"drop-shadow":[{"drop-shadow":["","none",U,Tr,Ar]}],"drop-shadow-color":[{"drop-shadow":V()}],grayscale:[{grayscale:["",Ce,de,ue]}],"hue-rotate":[{"hue-rotate":[Ce,de,ue]}],invert:[{invert:["",Ce,de,ue]}],saturate:[{saturate:[Ce,de,ue]}],sepia:[{sepia:["",Ce,de,ue]}],"backdrop-filter":[{"backdrop-filter":["","none",de,ue]}],"backdrop-blur":[{"backdrop-blur":Se()}],"backdrop-brightness":[{"backdrop-brightness":[Ce,de,ue]}],"backdrop-contrast":[{"backdrop-contrast":[Ce,de,ue]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ce,de,ue]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ce,de,ue]}],"backdrop-invert":[{"backdrop-invert":["",Ce,de,ue]}],"backdrop-opacity":[{"backdrop-opacity":[Ce,de,ue]}],"backdrop-saturate":[{"backdrop-saturate":[Ce,de,ue]}],"backdrop-sepia":[{"backdrop-sepia":["",Ce,de,ue]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":R()}],"border-spacing-x":[{"border-spacing-x":R()}],"border-spacing-y":[{"border-spacing-y":R()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",de,ue]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ce,"initial",de,ue]}],ease:[{ease:["linear","initial",G,de,ue]}],delay:[{delay:[Ce,de,ue]}],animate:[{animate:["none",X,de,ue]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[D,de,ue]}],"perspective-origin":[{"perspective-origin":me()}],rotate:[{rotate:oe()}],"rotate-x":[{"rotate-x":oe()}],"rotate-y":[{"rotate-y":oe()}],"rotate-z":[{"rotate-z":oe()}],scale:[{scale:be()}],"scale-x":[{"scale-x":be()}],"scale-y":[{"scale-y":be()}],"scale-z":[{"scale-z":be()}],"scale-3d":["scale-3d"],skew:[{skew:L()}],"skew-x":[{"skew-x":L()}],"skew-y":[{"skew-y":L()}],transform:[{transform:[de,ue,"","none","gpu","cpu"]}],"transform-origin":[{origin:me()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:je()}],"translate-x":[{"translate-x":je()}],"translate-y":[{"translate-y":je()}],"translate-z":[{"translate-z":je()}],"translate-none":["translate-none"],zoom:[{zoom:[yn,de,ue]}],accent:[{accent:V()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:V()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",de,ue]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":V()}],"scrollbar-track-color":[{"scrollbar-track":V()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":R()}],"scroll-mx":[{"scroll-mx":R()}],"scroll-my":[{"scroll-my":R()}],"scroll-ms":[{"scroll-ms":R()}],"scroll-me":[{"scroll-me":R()}],"scroll-mbs":[{"scroll-mbs":R()}],"scroll-mbe":[{"scroll-mbe":R()}],"scroll-mt":[{"scroll-mt":R()}],"scroll-mr":[{"scroll-mr":R()}],"scroll-mb":[{"scroll-mb":R()}],"scroll-ml":[{"scroll-ml":R()}],"scroll-p":[{"scroll-p":R()}],"scroll-px":[{"scroll-px":R()}],"scroll-py":[{"scroll-py":R()}],"scroll-ps":[{"scroll-ps":R()}],"scroll-pe":[{"scroll-pe":R()}],"scroll-pbs":[{"scroll-pbs":R()}],"scroll-pbe":[{"scroll-pbe":R()}],"scroll-pt":[{"scroll-pt":R()}],"scroll-pr":[{"scroll-pr":R()}],"scroll-pb":[{"scroll-pb":R()}],"scroll-pl":[{"scroll-pl":R()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",de,ue]}],fill:[{fill:["none",...V()]}],"stroke-w":[{stroke:[Ce,Gi,Ql,_g]}],stroke:[{stroke:["none",...V()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["start","end","right","left"],"inset-y":["inset-bs","inset-be","top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["ps","pe","pr","pl"],py:["pbs","pbe","pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["ms","me","mr","ml"],my:["mbs","mbe","mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-s","border-w-e","border-w-r","border-w-l"],"border-w-y":["border-w-bs","border-w-be","border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-s","border-color-e","border-color-r","border-color-l"],"border-color-y":["border-color-bs","border-color-be","border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-ms","scroll-me","scroll-mr","scroll-ml"],"scroll-my":["scroll-mbs","scroll-mbe","scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-ps","scroll-pe","scroll-pr","scroll-pl"],"scroll-py":["scroll-pbs","scroll-pbe","scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},R2=d2(k2);function Nn(...i){return R2(Yv(i))}const D2=({currentView:i,onSelectView:r,isOpenMobile:u,onCloseMobile:c})=>{const{t:d}=rn(),h=window.__BRAND__||{name:"Levix",tagline:"Private control room",version:"3.4.0",developer:"Abdelrhman Diab",studio:"Leviro",developerSite:"https://github.com/Abdodiab2005",studioSite:"https://leviro.net"},p=[{id:"overview",label:d("overview"),icon:Av},{id:"connection",label:d("connection"),icon:Ki},{labelCategory:d("control")},{id:"commands",label:d("commands"),icon:Va},{id:"ai",label:d("ai"),icon:Ed},{id:"groups",label:d("groups"),icon:Ga},{id:"schedules",label:d("schedules"),icon:bd},{labelCategory:d("settings")},{id:"settings",label:d("settings"),icon:Dv},{id:"logs",label:d("logs"),icon:Mr}];return o.jsxs(o.Fragment,{children:[u&&o.jsx("button",{type:"button",className:"fixed inset-0 bg-black/60 backdrop-blur-sm z-40 md:hidden border-0 p-0 cursor-default",onClick:c,"aria-label":"Close mobile sidebar backdrop"}),o.jsxs("aside",{className:Nn("fixed top-0 bottom-0 start-0 z-50 w-72 md:w-64 md:static md:z-auto bg-panel border-e border-line flex flex-col transition-transform duration-200 ease-out",u?"translate-x-0":"max-md:-translate-x-full rtl:max-md:translate-x-full"),"aria-label":"Main Navigation",children:[o.jsxs("div",{className:"p-4 flex items-center justify-between border-b border-line",children:[o.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[o.jsx("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-br from-brand-blue via-brand-blue to-brand-cyan flex items-center justify-center shadow-md shadow-brand-blue/20 shrink-0 text-white",children:o.jsx(Hv,{size:20})}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("div",{className:"font-extrabold text-base text-text-main leading-tight tracking-tight truncate",children:h.name}),o.jsx("div",{className:"text-xs text-muted leading-none truncate mt-0.5",children:h.tagline})]})]}),o.jsx("button",{type:"button",onClick:c,className:"inline-flex md:hidden items-center justify-center w-10 h-10 rounded-xl border border-line bg-panel-raised hover:bg-panel-hover text-text-main transition-colors shrink-0","aria-label":"Close menu",children:o.jsx(Ji,{size:18})})]}),o.jsx("nav",{className:"flex-1 overflow-y-auto p-3 space-y-1",children:p.map(g=>{if(g.labelCategory)return o.jsx("div",{className:"px-3 pt-3 pb-1 text-[11px] font-bold uppercase tracking-wider text-faint",children:g.labelCategory},`cat-${g.labelCategory}`);if(!g.icon)return null;const b=g.icon,E=i===g.id;return o.jsxs("button",{type:"button",onClick:()=>{g.id&&(r(g.id),c())},className:Nn("w-full flex items-center gap-3 px-3.5 py-2.5 rounded-xl font-medium text-sm transition-all focus-visible:ring-2 focus-visible:ring-brand-blue/50 text-start min-h-[44px]",E?"bg-brand-blue text-white shadow-md shadow-brand-blue/25 font-bold":"text-muted hover:bg-panel-hover hover:text-text-main"),children:[o.jsx(b,{size:20,className:"shrink-0"}),o.jsx("span",{className:"truncate",children:g.label})]},g.id)})}),o.jsxs("div",{className:"p-4 border-t border-line text-xs text-faint flex flex-col gap-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between text-[11px] text-muted",children:[o.jsxs("span",{className:"font-mono",children:["v",h.version||"3.4.0"]}),o.jsxs("span",{className:"flex items-center gap-1.5",children:[o.jsx(Wx,{size:14,className:"text-brand-cyan"})," Local-first"]})]}),o.jsxs("div",{className:"text-[11px] text-muted truncate",children:["© ",h.copyrightYear||2026," ",o.jsx("a",{href:h.developerSite||"#",target:"_blank",rel:"noopener noreferrer",className:"text-brand-cyan hover:underline",children:h.developer})," ","(",o.jsx("a",{href:h.studioSite||"#",target:"_blank",rel:"noopener noreferrer",className:"text-brand-cyan hover:underline",children:h.studio}),")"]})]})]})]})},kb=K.createContext(null),B2=({children:i})=>{const[r,u]=K.useState([]),c=K.useCallback(h=>{u(p=>p.filter(g=>g.id!==h))},[]),d=K.useCallback((h,p="info",g=4e3)=>{const b=Math.random().toString(36).slice(2,9);u(E=>[...E,{id:b,message:h,type:p,duration:g}]),setTimeout(()=>c(b),g)},[c]);return o.jsxs(kb.Provider,{value:{toast:d},children:[i,o.jsx("div",{className:"fixed bottom-5 end-5 z-50 flex flex-col gap-2.5 max-w-sm w-full px-4 pointer-events-none","aria-live":"polite",children:r.map(h=>o.jsxs("div",{className:`pointer-events-auto flex items-center gap-3 px-4 py-3 rounded-xl border bg-panel-raised/95 backdrop-blur-md shadow-xl text-xs md:text-sm text-text-main transition-all ${h.type==="success"?"border-ok/35":h.type==="error"?"border-danger/35":h.type==="warning"?"border-warn/35":"border-line"}`,children:[h.type==="success"&&o.jsx(Qr,{size:18,className:"text-ok shrink-0"}),h.type==="error"&&o.jsx(yv,{size:18,className:"text-danger shrink-0"}),h.type==="warning"&&o.jsx(Or,{size:18,className:"text-warn shrink-0"}),h.type==="info"&&o.jsx(_v,{size:18,className:"text-info shrink-0"}),o.jsx("span",{className:"flex-1 font-medium",children:h.message}),o.jsx("button",{type:"button",onClick:()=>c(h.id),className:"inline-flex items-center justify-center w-6 h-6 rounded-lg text-muted hover:text-text-main hover:bg-panel-hover transition-colors shrink-0","aria-label":"Dismiss notification",children:o.jsx(Ji,{size:14})})]},h.id))})]})},yl=()=>{const i=K.useContext(kb);if(!i)throw new Error("useToast must be used within a ToastProvider");return i},Sn=Object.create(null);Sn.open="0";Sn.close="1";Sn.ping="2";Sn.pong="3";Sn.message="4";Sn.upgrade="5";Sn.noop="6";const kr=Object.create(null);Object.keys(Sn).forEach(i=>{kr[Sn[i]]=i});const wd={type:"error",data:"parser error"},Rb=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Db=typeof ArrayBuffer=="function",Bb=i=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(i):i&&i.buffer instanceof ArrayBuffer,Od=({type:i,data:r},u,c)=>Rb&&r instanceof Blob?u?c(r):Cg(r,c):Db&&(r instanceof ArrayBuffer||Bb(r))?u?c(r):Cg(new Blob([r]),c):c(Sn[i]+(r||"")),Cg=(i,r)=>{const u=new FileReader;return u.onload=function(){const c=u.result.split(",")[1];r("b"+(c||""))},u.readAsDataURL(i)};function Eg(i){return i instanceof Uint8Array?i:i instanceof ArrayBuffer?new Uint8Array(i):new Uint8Array(i.buffer,i.byteOffset,i.byteLength)}let Yu;function U2(i,r){if(Rb&&i.data instanceof Blob)return i.data.arrayBuffer().then(Eg).then(r);if(Db&&(i.data instanceof ArrayBuffer||Bb(i.data)))return r(Eg(i.data));Od(i,!1,u=>{Yu||(Yu=new TextEncoder),r(Yu.encode(u))})}const zg="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Xi=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let i=0;i<zg.length;i++)Xi[zg.charCodeAt(i)]=i;const L2=i=>{let r=i.length*.75,u=i.length,c,d=0,h,p,g,b;i[i.length-1]==="="&&(r--,i[i.length-2]==="="&&r--);const E=new ArrayBuffer(r),v=new Uint8Array(E);for(c=0;c<u;c+=4)h=Xi[i.charCodeAt(c)],p=Xi[i.charCodeAt(c+1)],g=Xi[i.charCodeAt(c+2)],b=Xi[i.charCodeAt(c+3)],v[d++]=h<<2|p>>4,v[d++]=(p&15)<<4|g>>2,v[d++]=(g&3)<<6|b&63;return E},q2=typeof ArrayBuffer=="function",kd=(i,r)=>{if(typeof i!="string")return{type:"message",data:Ub(i,r)};const u=i.charAt(0);return u==="b"?{type:"message",data:H2(i.substring(1),r)}:kr[u]?i.length>1?{type:kr[u],data:i.substring(1)}:{type:kr[u]}:wd},H2=(i,r)=>{if(q2){const u=L2(i);return Ub(u,r)}else return{base64:!0,data:i}},Ub=(i,r)=>{switch(r){case"blob":return i instanceof Blob?i:new Blob([i]);case"arraybuffer":default:return i instanceof ArrayBuffer?i:i.buffer}},Lb="",G2=(i,r)=>{const u=i.length,c=new Array(u);let d=0;i.forEach((h,p)=>{Od(h,!1,g=>{c[p]=g,++d===u&&r(c.join(Lb))})})},V2=(i,r)=>{const u=i.split(Lb),c=[];for(let d=0;d<u.length;d++){const h=kd(u[d],r);if(c.push(h),h.type==="error")break}return c};function Y2(){return new TransformStream({transform(i,r){U2(i,u=>{const c=u.length;let d;if(c<126)d=new Uint8Array(1),new DataView(d.buffer).setUint8(0,c);else if(c<65536){d=new Uint8Array(3);const h=new DataView(d.buffer);h.setUint8(0,126),h.setUint16(1,c)}else{d=new Uint8Array(9);const h=new DataView(d.buffer);h.setUint8(0,127),h.setBigUint64(1,BigInt(c))}i.data&&typeof i.data!="string"&&(d[0]|=128),r.enqueue(d),r.enqueue(u)})}})}let Qu;function Cr(i){return i.reduce((r,u)=>r+u.length,0)}function Er(i,r){if(i[0].length===r)return i.shift();const u=new Uint8Array(r);let c=0;for(let d=0;d<r;d++)u[d]=i[0][c++],c===i[0].length&&(i.shift(),c=0);return i.length&&c<i[0].length&&(i[0]=i[0].slice(c)),u}function Q2(i,r){Qu||(Qu=new TextDecoder);const u=[];let c=0,d=-1,h=!1;return new TransformStream({transform(p,g){for(u.push(p);;){if(c===0){if(Cr(u)<1)break;const b=Er(u,1);h=(b[0]&128)===128,d=b[0]&127,d<126?c=3:d===126?c=1:c=2}else if(c===1){if(Cr(u)<2)break;const b=Er(u,2);d=new DataView(b.buffer,b.byteOffset,b.length).getUint16(0),c=3}else if(c===2){if(Cr(u)<8)break;const b=Er(u,8),E=new DataView(b.buffer,b.byteOffset,b.length),v=E.getUint32(0);if(v>Math.pow(2,21)-1){g.enqueue(wd);break}d=v*Math.pow(2,32)+E.getUint32(4),c=3}else{if(Cr(u)<d)break;const b=Er(u,d);g.enqueue(kd(h?b:Qu.decode(b),r)),c=0}if(d===0||d>i){g.enqueue(wd);break}}}})}const qb=4;function rt(i){if(i)return X2(i)}function X2(i){for(var r in rt.prototype)i[r]=rt.prototype[r];return i}rt.prototype.on=rt.prototype.addEventListener=function(i,r){return this._callbacks=this._callbacks||{},(this._callbacks["$"+i]=this._callbacks["$"+i]||[]).push(r),this};rt.prototype.once=function(i,r){function u(){this.off(i,u),r.apply(this,arguments)}return u.fn=r,this.on(i,u),this};rt.prototype.off=rt.prototype.removeListener=rt.prototype.removeAllListeners=rt.prototype.removeEventListener=function(i,r){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var u=this._callbacks["$"+i];if(!u)return this;if(arguments.length==1)return delete this._callbacks["$"+i],this;for(var c,d=0;d<u.length;d++)if(c=u[d],c===r||c.fn===r){u.splice(d,1);break}return u.length===0&&delete this._callbacks["$"+i],this};rt.prototype.emit=function(i){this._callbacks=this._callbacks||{};for(var r=new Array(arguments.length-1),u=this._callbacks["$"+i],c=1;c<arguments.length;c++)r[c-1]=arguments[c];if(u){u=u.slice(0);for(var c=0,d=u.length;c<d;++c)u[c].apply(this,r)}return this};rt.prototype.emitReserved=rt.prototype.emit;rt.prototype.listeners=function(i){return this._callbacks=this._callbacks||{},this._callbacks["$"+i]||[]};rt.prototype.hasListeners=function(i){return!!this.listeners(i).length};const Xr=typeof Promise=="function"&&typeof Promise.resolve=="function"?r=>Promise.resolve().then(r):(r,u)=>u(r,0),$t=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),K2="arraybuffer";function Hb(i,...r){return r.reduce((u,c)=>(i.hasOwnProperty(c)&&(u[c]=i[c]),u),{})}const Z2=$t.setTimeout,J2=$t.clearTimeout;function Kr(i,r){r.useNativeTimers?(i.setTimeoutFn=Z2.bind($t),i.clearTimeoutFn=J2.bind($t)):(i.setTimeoutFn=$t.setTimeout.bind($t),i.clearTimeoutFn=$t.clearTimeout.bind($t))}const I2=1.33;function P2(i){return typeof i=="string"?F2(i):Math.ceil((i.byteLength||i.size)*I2)}function F2(i){let r=0,u=0;for(let c=0,d=i.length;c<d;c++)r=i.charCodeAt(c),r<128?u+=1:r<2048?u+=2:r<55296||r>=57344?u+=3:(c++,u+=4);return u}function Gb(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function $2(i){let r="";for(let u in i)i.hasOwnProperty(u)&&(r.length&&(r+="&"),r+=encodeURIComponent(u)+"="+encodeURIComponent(i[u]));return r}function W2(i){let r={},u=i.split("&");for(let c=0,d=u.length;c<d;c++){let h=u[c].split("=");r[decodeURIComponent(h[0])]=decodeURIComponent(h[1])}return r}class eN extends Error{constructor(r,u,c){super(r),this.description=u,this.context=c,this.type="TransportError"}}class Rd extends rt{constructor(r){super(),this.writable=!1,Kr(this,r),this.opts=r,this.query=r.query,this.socket=r.socket,this.supportsBinary=!r.forceBase64}onError(r,u,c){return super.emitReserved("error",new eN(r,u,c)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(r){this.readyState==="open"&&this.write(r)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(r){const u=kd(r,this.socket.binaryType);this.onPacket(u)}onPacket(r){super.emitReserved("packet",r)}onClose(r){this.readyState="closed",super.emitReserved("close",r)}pause(r){}createUri(r,u={}){return r+"://"+this._hostname()+this._port()+this.opts.path+this._query(u)}_hostname(){const r=this.opts.hostname;return r.indexOf(":")===-1?r:"["+r+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(r){const u=$2(r);return u.length?"?"+u:""}}class tN extends Rd{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(r){this.readyState="pausing";const u=()=>{this.readyState="paused",r()};if(this._polling||!this.writable){let c=0;this._polling&&(c++,this.once("pollComplete",function(){--c||u()})),this.writable||(c++,this.once("drain",function(){--c||u()}))}else u()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(r){const u=c=>{if(this.readyState==="opening"&&c.type==="open"&&this.onOpen(),c.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(c)};V2(r,this.socket.binaryType).forEach(u),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const r=()=>{this.write([{type:"close"}])};this.readyState==="open"?r():this.once("open",r)}write(r){this.writable=!1,G2(r,u=>{this.doWrite(u,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const r=this.opts.secure?"https":"http",u=this.query||{};return this.opts.timestampRequests!==!1&&(u[this.opts.timestampParam]=Gb()),!this.supportsBinary&&!u.sid&&(u.b64=1),this.createUri(r,u)}}let Vb=!1;try{Vb=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const nN=Vb;function lN(){}class aN extends tN{constructor(r){if(super(r),typeof location<"u"){const u=location.protocol==="https:";let c=location.port;c||(c=u?"443":"80"),this.xd=typeof location<"u"&&r.hostname!==location.hostname||c!==r.port}}doWrite(r,u){const c=this.request({method:"POST",data:r});c.on("success",u),c.on("error",(d,h)=>{this.onError("xhr post error",d,h)})}doPoll(){const r=this.request();r.on("data",this.onData.bind(this)),r.on("error",(u,c)=>{this.onError("xhr poll error",u,c)}),this.pollXhr=r}}class wn extends rt{constructor(r,u,c){super(),this.createRequest=r,Kr(this,c),this._opts=c,this._method=c.method||"GET",this._uri=u,this._data=c.data!==void 0?c.data:null,this._create()}_create(){var r;const u=Hb(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");u.xdomain=!!this._opts.xd;const c=this._xhr=this.createRequest(u);try{c.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){c.setDisableHeaderCheck&&c.setDisableHeaderCheck(!0);for(let d in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(d)&&c.setRequestHeader(d,this._opts.extraHeaders[d])}}catch{}if(this._method==="POST")try{c.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{c.setRequestHeader("Accept","*/*")}catch{}(r=this._opts.cookieJar)===null||r===void 0||r.addCookies(c),"withCredentials"in c&&(c.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(c.timeout=this._opts.requestTimeout),c.onreadystatechange=()=>{var d;c.readyState===3&&((d=this._opts.cookieJar)===null||d===void 0||d.parseCookies(c.getResponseHeader("set-cookie"))),c.readyState===4&&(c.status===200||c.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof c.status=="number"?c.status:0)},0))},c.send(this._data)}catch(d){this.setTimeoutFn(()=>{this._onError(d)},0);return}typeof document<"u"&&(this._index=wn.requestsCount++,wn.requests[this._index]=this)}_onError(r){this.emitReserved("error",r,this._xhr),this._cleanup(!0)}_cleanup(r){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=lN,r)try{this._xhr.abort()}catch{}typeof document<"u"&&delete wn.requests[this._index],this._xhr=null}}_onLoad(){const r=this._xhr.responseText;r!==null&&(this.emitReserved("data",r),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}wn.requestsCount=0;wn.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",Mg);else if(typeof addEventListener=="function"){const i="onpagehide"in $t?"pagehide":"unload";addEventListener(i,Mg,!1)}}function Mg(){for(let i in wn.requests)wn.requests.hasOwnProperty(i)&&wn.requests[i].abort()}const iN=(function(){const i=Yb({xdomain:!1});return i&&i.responseType!==null})();class sN extends aN{constructor(r){super(r);const u=r&&r.forceBase64;this.supportsBinary=iN&&!u}request(r={}){return Object.assign(r,{xd:this.xd},this.opts),new wn(Yb,this.uri(),r)}}function Yb(i){const r=i.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!r||nN))return new XMLHttpRequest}catch{}if(!r)try{return new $t[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const Qb=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class rN extends Rd{get name(){return"websocket"}doOpen(){const r=this.uri(),u=this.opts.protocols,c=Qb?{}:Hb(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(c.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(r,u,c)}catch(d){return this.emitReserved("error",d)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=r=>this.onClose({description:"websocket connection closed",context:r}),this.ws.onmessage=r=>this.onData(r.data),this.ws.onerror=r=>this.onError("websocket error",r)}write(r){this.writable=!1;for(let u=0;u<r.length;u++){const c=r[u],d=u===r.length-1;Od(c,this.supportsBinary,h=>{try{this.doWrite(c,h)}catch{}d&&Xr(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const r=this.opts.secure?"wss":"ws",u=this.query||{};return this.opts.timestampRequests&&(u[this.opts.timestampParam]=Gb()),this.supportsBinary||(u.b64=1),this.createUri(r,u)}}const Xu=$t.WebSocket||$t.MozWebSocket;class oN extends rN{createSocket(r,u,c){return Qb?new Xu(r,u,c):u?new Xu(r,u):new Xu(r)}doWrite(r,u){this.ws.send(u)}}class cN extends Rd{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(r){return this.emitReserved("error",r)}this._transport.closed.then(()=>{this.onClose()}).catch(r=>{this.onError("webtransport error",r)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(r=>{const u=Q2(Number.MAX_SAFE_INTEGER,this.socket.binaryType),c=r.readable.pipeThrough(u).getReader(),d=Y2();d.readable.pipeTo(r.writable),this._writer=d.writable.getWriter();const h=()=>{c.read().then(({done:g,value:b})=>{g||(this.onPacket(b),h())}).catch(g=>{})};h();const p={type:"open"};this.query.sid&&(p.data=`{"sid":"${this.query.sid}"}`),this._writer.write(p).then(()=>this.onOpen())})})}write(r){this.writable=!1;for(let u=0;u<r.length;u++){const c=r[u],d=u===r.length-1;this._writer.write(c).then(()=>{d&&Xr(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var r;(r=this._transport)===null||r===void 0||r.close()}}const uN={websocket:oN,webtransport:cN,polling:sN},dN=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,fN=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Sd(i){if(i.length>8e3)throw"URI too long";const r=i,u=i.indexOf("["),c=i.indexOf("]");u!=-1&&c!=-1&&(i=i.substring(0,u)+i.substring(u,c).replace(/:/g,";")+i.substring(c,i.length));let d=dN.exec(i||""),h={},p=14;for(;p--;)h[fN[p]]=d[p]||"";return u!=-1&&c!=-1&&(h.source=r,h.host=h.host.substring(1,h.host.length-1).replace(/;/g,":"),h.authority=h.authority.replace("[","").replace("]","").replace(/;/g,":"),h.ipv6uri=!0),h.pathNames=hN(h,h.path),h.queryKey=mN(h,h.query),h}function hN(i,r){const u=/\/{2,9}/g,c=r.replace(u,"/").split("/");return(r.slice(0,1)=="/"||r.length===0)&&c.splice(0,1),r.slice(-1)=="/"&&c.splice(c.length-1,1),c}function mN(i,r){const u={};return r.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(c,d,h){d&&(u[d]=h)}),u}const jd=typeof addEventListener=="function"&&typeof removeEventListener=="function",Rr=[];jd&&addEventListener("offline",()=>{Rr.forEach(i=>i())},!1);class xl extends rt{constructor(r,u){if(super(),this.binaryType=K2,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,r&&typeof r=="object"&&(u=r,r=null),r){const c=Sd(r);u.hostname=c.host,u.secure=c.protocol==="https"||c.protocol==="wss",u.port=c.port,c.query&&(u.query=c.query)}else u.host&&(u.hostname=Sd(u.host).host);Kr(this,u),this.secure=u.secure!=null?u.secure:typeof location<"u"&&location.protocol==="https:",u.hostname&&!u.port&&(u.port=this.secure?"443":"80"),this.hostname=u.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=u.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},u.transports.forEach(c=>{const d=c.prototype.name;this.transports.push(d),this._transportsByName[d]=c}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},u),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=W2(this.opts.query)),jd&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},Rr.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(r){const u=Object.assign({},this.opts.query);u.EIO=qb,u.transport=r,this.id&&(u.sid=this.id);const c=Object.assign({},this.opts,{query:u,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[r]);return new this._transportsByName[r](c)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const r=this.opts.rememberUpgrade&&xl.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const u=this.createTransport(r);u.open(),this.setTransport(u)}setTransport(r){this.transport&&this.transport.removeAllListeners(),this.transport=r,r.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",u=>this._onClose("transport close",u))}onOpen(){this.readyState="open",xl.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(r){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",r),this.emitReserved("heartbeat"),r.type){case"open":this.onHandshake(JSON.parse(r.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const u=new Error("server error");u.code=r.data,this._onError(u);break;case"message":this.emitReserved("data",r.data),this.emitReserved("message",r.data);break}}onHandshake(r){this.emitReserved("handshake",r),this.id=r.sid,this.transport.query.sid=r.sid,this._pingInterval=r.pingInterval,this._pingTimeout=r.pingTimeout,this._maxPayload=r.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const r=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+r,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},r),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const r=this._getWritablePackets();this.transport.send(r),this._prevBufferLen=r.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let u=1;for(let c=0;c<this.writeBuffer.length;c++){const d=this.writeBuffer[c].data;if(d&&(u+=P2(d)),c>0&&u>this._maxPayload)return this.writeBuffer.slice(0,c);u+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const r=Date.now()>this._pingTimeoutTime;return r&&(this._pingTimeoutTime=0,Xr(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),r}write(r,u,c){return this._sendPacket("message",r,u,c),this}send(r,u,c){return this._sendPacket("message",r,u,c),this}_sendPacket(r,u,c,d){if(typeof u=="function"&&(d=u,u=void 0),typeof c=="function"&&(d=c,c=null),this.readyState==="closing"||this.readyState==="closed")return;c=c||{},c.compress=c.compress!==!1;const h={type:r,data:u,options:c};this.emitReserved("packetCreate",h),this.writeBuffer.push(h),d&&this.once("flush",d),this.flush()}close(){const r=()=>{this._onClose("forced close"),this.transport.close()},u=()=>{this.off("upgrade",u),this.off("upgradeError",u),r()},c=()=>{this.once("upgrade",u),this.once("upgradeError",u)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?c():r()}):this.upgrading?c():r()),this}_onError(r){if(xl.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",r),this._onClose("transport error",r)}_onClose(r,u){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),jd&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const c=Rr.indexOf(this._offlineEventListener);c!==-1&&Rr.splice(c,1)}this.readyState="closed",this.id=null,this.emitReserved("close",r,u),this.writeBuffer=[],this._prevBufferLen=0}}}xl.protocol=qb;class pN extends xl{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let r=0;r<this._upgrades.length;r++)this._probe(this._upgrades[r])}_probe(r){let u=this.createTransport(r),c=!1;xl.priorWebsocketSuccess=!1;const d=()=>{c||(u.send([{type:"ping",data:"probe"}]),u.once("packet",x=>{if(!c)if(x.type==="pong"&&x.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",u),!u)return;xl.priorWebsocketSuccess=u.name==="websocket",this.transport.pause(()=>{c||this.readyState!=="closed"&&(v(),this.setTransport(u),u.send([{type:"upgrade"}]),this.emitReserved("upgrade",u),u=null,this.upgrading=!1,this.flush())})}else{const C=new Error("probe error");C.transport=u.name,this.emitReserved("upgradeError",C)}}))};function h(){c||(c=!0,v(),u.close(),u=null)}const p=x=>{const C=new Error("probe error: "+x);C.transport=u.name,h(),this.emitReserved("upgradeError",C)};function g(){p("transport closed")}function b(){p("socket closed")}function E(x){u&&x.name!==u.name&&h()}const v=()=>{u.removeListener("open",d),u.removeListener("error",p),u.removeListener("close",g),this.off("close",b),this.off("upgrading",E)};u.once("open",d),u.once("error",p),u.once("close",g),this.once("close",b),this.once("upgrading",E),this._upgrades.indexOf("webtransport")!==-1&&r!=="webtransport"?this.setTimeoutFn(()=>{c||u.open()},200):u.open()}onHandshake(r){this._upgrades=this._filterUpgrades(r.upgrades),super.onHandshake(r)}_filterUpgrades(r){const u=[];for(let c=0;c<r.length;c++)~this.transports.indexOf(r[c])&&u.push(r[c]);return u}}let gN=class extends pN{constructor(r,u={}){const c=typeof r=="object",d=c?{...r}:{...u};(!d.transports||d.transports&&typeof d.transports[0]=="string")&&(d.transports=(d.transports||["polling","websocket","webtransport"]).map(h=>uN[h]).filter(h=>!!h)),super(c?d:r,d)}};function xN(i,r="",u){let c=i;u=u||typeof location<"u"&&location,i==null&&(i=u.protocol+"//"+u.host),typeof i=="string"&&(i.charAt(0)==="/"&&(i.charAt(1)==="/"?i=u.protocol+i:i=u.host+i),/^(https?|wss?):\/\//.test(i)||(typeof u<"u"?i=u.protocol+"//"+i:i="https://"+i),c=Sd(i)),c.port||(/^(http|ws)$/.test(c.protocol)?c.port="80":/^(http|ws)s$/.test(c.protocol)&&(c.port="443")),c.path=c.path||"/";const h=c.host.indexOf(":")!==-1?"["+c.host+"]":c.host;return c.id=c.protocol+"://"+h+":"+c.port+r,c.href=c.protocol+"://"+h+(u&&u.port===c.port?"":":"+c.port),c}const bN=typeof ArrayBuffer=="function",yN=i=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(i):i.buffer instanceof ArrayBuffer,Xb=Object.prototype.toString,vN=typeof Blob=="function"||typeof Blob<"u"&&Xb.call(Blob)==="[object BlobConstructor]",NN=typeof File=="function"||typeof File<"u"&&Xb.call(File)==="[object FileConstructor]";function Dd(i){return bN&&(i instanceof ArrayBuffer||yN(i))||vN&&i instanceof Blob||NN&&i instanceof File}function Dr(i,r){if(!i||typeof i!="object")return!1;if(Array.isArray(i)){for(let u=0,c=i.length;u<c;u++)if(Dr(i[u]))return!0;return!1}if(Dd(i))return!0;if(i.toJSON&&typeof i.toJSON=="function"&&arguments.length===1)return Dr(i.toJSON(),!0);for(const u in i)if(Object.prototype.hasOwnProperty.call(i,u)&&Dr(i[u]))return!0;return!1}function wN(i){const r=[],u=i.data,c=i;return c.data=Br(u,r),c.attachments=r.length,{packet:c,buffers:r}}function Br(i,r,u){if(!i)return i;if(Dd(i)){const c={_placeholder:!0,num:r.length};return r.push(i),c}else if(Array.isArray(i)){const c=new Array(i.length);for(let d=0;d<i.length;d++)c[d]=Br(i[d],r);return c}else if(typeof i=="object"&&!(i instanceof Date)){if(i.toJSON&&typeof i.toJSON=="function"&&!u)return Br(i.toJSON(),r,!0);const c={};for(const d in i)Object.prototype.hasOwnProperty.call(i,d)&&(c[d]=Br(i[d],r));return c}return i}function SN(i,r){return i.data=_d(i.data,r),delete i.attachments,i}function _d(i,r){if(!i)return i;if(i&&i._placeholder===!0){if(typeof i.num=="number"&&i.num>=0&&i.num<r.length)return r[i.num];throw new Error("illegal attachments")}else if(Array.isArray(i))for(let u=0;u<i.length;u++)i[u]=_d(i[u],r);else if(typeof i=="object")for(const u in i)Object.prototype.hasOwnProperty.call(i,u)&&(i[u]=_d(i[u],r));return i}const jN=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var Re;(function(i){i[i.CONNECT=0]="CONNECT",i[i.DISCONNECT=1]="DISCONNECT",i[i.EVENT=2]="EVENT",i[i.ACK=3]="ACK",i[i.CONNECT_ERROR=4]="CONNECT_ERROR",i[i.BINARY_EVENT=5]="BINARY_EVENT",i[i.BINARY_ACK=6]="BINARY_ACK"})(Re||(Re={}));class _N{constructor(r){this.replacer=r}encode(r){return(r.type===Re.EVENT||r.type===Re.ACK)&&Dr(r)?this.encodeAsBinary({type:r.type===Re.EVENT?Re.BINARY_EVENT:Re.BINARY_ACK,nsp:r.nsp,data:r.data,id:r.id}):[this.encodeAsString(r)]}encodeAsString(r){let u=""+r.type;return(r.type===Re.BINARY_EVENT||r.type===Re.BINARY_ACK)&&(u+=r.attachments+"-"),r.nsp&&r.nsp!=="/"&&(u+=r.nsp+","),r.id!=null&&(u+=r.id),r.data!=null&&(u+=JSON.stringify(r.data,this.replacer)),u}encodeAsBinary(r){const u=wN(r),c=this.encodeAsString(u.packet),d=u.buffers;return d.unshift(c),d}}class Bd extends rt{constructor(r){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof r=="function"?{reviver:r}:r)}add(r){let u;if(typeof r=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");u=this.decodeString(r);const c=u.type===Re.BINARY_EVENT;c||u.type===Re.BINARY_ACK?(u.type=c?Re.EVENT:Re.ACK,this.reconstructor=new AN(u)):super.emitReserved("decoded",u)}else if(Dd(r)||r.base64)if(this.reconstructor)u=this.reconstructor.takeBinaryData(r),u&&(this.reconstructor=null,super.emitReserved("decoded",u));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+r)}decodeString(r){let u=0;const c={type:Number(r.charAt(0))};if(Re[c.type]===void 0)throw new Error("unknown packet type "+c.type);if(c.type===Re.BINARY_EVENT||c.type===Re.BINARY_ACK){const h=u+1;for(;r.charAt(++u)!=="-"&&u!=r.length;);const p=r.substring(h,u);if(p!=Number(p)||r.charAt(u)!=="-")throw new Error("Illegal attachments");const g=Number(p);if(!TN(g)||g<1)throw new Error("Illegal attachments");if(g>this.opts.maxAttachments)throw new Error("too many attachments");c.attachments=g}if(r.charAt(u+1)==="/"){const h=u+1;for(;++u&&!(r.charAt(u)===","||u===r.length););c.nsp=r.substring(h,u)}else c.nsp="/";const d=r.charAt(u+1);if(d!==""&&Number(d)==d){const h=u+1;for(;++u;){const p=r.charAt(u);if(p==null||Number(p)!=p){--u;break}if(u===r.length)break}c.id=Number(r.substring(h,u+1))}if(r.charAt(++u)){const h=this.tryParse(r.substr(u));if(Bd.isPayloadValid(c.type,h))c.data=h;else throw new Error("invalid payload")}return c}tryParse(r){try{return JSON.parse(r,this.opts.reviver)}catch{return!1}}static isPayloadValid(r,u){switch(r){case Re.CONNECT:return Og(u);case Re.DISCONNECT:return u===void 0;case Re.CONNECT_ERROR:return typeof u=="string"||Og(u);case Re.EVENT:case Re.BINARY_EVENT:return Array.isArray(u)&&(typeof u[0]=="number"||typeof u[0]=="string"&&jN.indexOf(u[0])===-1);case Re.ACK:case Re.BINARY_ACK:return Array.isArray(u)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class AN{constructor(r){this.packet=r,this.buffers=[],this.reconPack=r}takeBinaryData(r){if(this.buffers.push(r),this.buffers.length===this.reconPack.attachments){const u=SN(this.reconPack,this.buffers);return this.finishedReconstruction(),u}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const TN=Number.isInteger||function(i){return typeof i=="number"&&isFinite(i)&&Math.floor(i)===i};function Og(i){return Object.prototype.toString.call(i)==="[object Object]"}const CN=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Bd,Encoder:_N,get PacketType(){return Re}},Symbol.toStringTag,{value:"Module"}));function sn(i,r,u){return i.on(r,u),function(){i.off(r,u)}}const EN=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Kb extends rt{constructor(r,u,c){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=r,this.nsp=u,c&&c.auth&&(this.auth=c.auth),this._opts=Object.assign({},c),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const r=this.io;this.subs=[sn(r,"open",this.onopen.bind(this)),sn(r,"packet",this.onpacket.bind(this)),sn(r,"error",this.onerror.bind(this)),sn(r,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...r){return r.unshift("message"),this.emit.apply(this,r),this}emit(r,...u){var c,d,h;if(EN.hasOwnProperty(r))throw new Error('"'+r.toString()+'" is a reserved event name');if(u.unshift(r),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(u),this;const p={type:Re.EVENT,data:u};if(p.options={},p.options.compress=this.flags.compress!==!1,typeof u[u.length-1]=="function"){const v=this.ids++,x=u.pop();this._registerAckCallback(v,x),p.id=v}const g=(d=(c=this.io.engine)===null||c===void 0?void 0:c.transport)===null||d===void 0?void 0:d.writable,b=this.connected&&!(!((h=this.io.engine)===null||h===void 0)&&h._hasPingExpired());return this.flags.volatile&&!g||(b?(this.notifyOutgoingListeners(p),this.packet(p)):this.sendBuffer.push(p)),this.flags={},this}_registerAckCallback(r,u){var c;const d=(c=this.flags.timeout)!==null&&c!==void 0?c:this._opts.ackTimeout;if(d===void 0){this.acks[r]=u;return}const h=this.io.setTimeoutFn(()=>{delete this.acks[r];for(let g=0;g<this.sendBuffer.length;g++)this.sendBuffer[g].id===r&&this.sendBuffer.splice(g,1);u.call(this,new Error("operation has timed out"))},d),p=(...g)=>{this.io.clearTimeoutFn(h),u.apply(this,g)};p.withError=!0,this.acks[r]=p}emitWithAck(r,...u){return new Promise((c,d)=>{const h=(p,g)=>p?d(p):c(g);h.withError=!0,u.push(h),this.emit(r,...u)})}_addToQueue(r){let u;typeof r[r.length-1]=="function"&&(u=r.pop());const c={id:this._queueSeq++,tryCount:0,pending:!1,args:r,flags:Object.assign({fromQueue:!0},this.flags)};r.push((d,...h)=>(this._queue[0],d!==null?c.tryCount>this._opts.retries&&(this._queue.shift(),u&&u(d)):(this._queue.shift(),u&&u(null,...h)),c.pending=!1,this._drainQueue())),this._queue.push(c),this._drainQueue()}_drainQueue(r=!1){if(!this.connected||this._queue.length===0)return;const u=this._queue[0];u.pending&&!r||(u.pending=!0,u.tryCount++,this.flags=u.flags,this.emit.apply(this,u.args))}packet(r){r.nsp=this.nsp,this.io._packet(r)}onopen(){typeof this.auth=="function"?this.auth(r=>{this._sendConnectPacket(r)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(r){this.packet({type:Re.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},r):r})}onerror(r){this.connected||this.emitReserved("connect_error",r)}onclose(r,u){this.connected=!1,delete this.id,this.emitReserved("disconnect",r,u),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(r=>{if(!this.sendBuffer.some(c=>String(c.id)===r)){const c=this.acks[r];delete this.acks[r],c.withError&&c.call(this,new Error("socket has been disconnected"))}})}onpacket(r){if(r.nsp===this.nsp)switch(r.type){case Re.CONNECT:r.data&&r.data.sid?this.onconnect(r.data.sid,r.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case Re.EVENT:case Re.BINARY_EVENT:this.onevent(r);break;case Re.ACK:case Re.BINARY_ACK:this.onack(r);break;case Re.DISCONNECT:this.ondisconnect();break;case Re.CONNECT_ERROR:this.destroy();const c=new Error(r.data.message);c.data=r.data.data,this.emitReserved("connect_error",c);break}}onevent(r){const u=r.data||[];r.id!=null&&u.push(this.ack(r.id)),this.connected?this.emitEvent(u):this.receiveBuffer.push(Object.freeze(u))}emitEvent(r){if(this._anyListeners&&this._anyListeners.length){const u=this._anyListeners.slice();for(const c of u)c.apply(this,r)}super.emit.apply(this,r),this._pid&&r.length&&typeof r[r.length-1]=="string"&&(this._lastOffset=r[r.length-1])}ack(r){const u=this;let c=!1;return function(...d){c||(c=!0,u.packet({type:Re.ACK,id:r,data:d}))}}onack(r){const u=this.acks[r.id];typeof u=="function"&&(delete this.acks[r.id],u.withError&&r.data.unshift(null),u.apply(this,r.data))}onconnect(r,u){this.id=r,this.recovered=u&&this._pid===u,this._pid=u,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(r=>this.emitEvent(r)),this.receiveBuffer=[],this.sendBuffer.forEach(r=>{this.notifyOutgoingListeners(r),this.packet(r)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(r=>r()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Re.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(r){return this.flags.compress=r,this}get volatile(){return this.flags.volatile=!0,this}timeout(r){return this.flags.timeout=r,this}onAny(r){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(r),this}prependAny(r){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(r),this}offAny(r){if(!this._anyListeners)return this;if(r){const u=this._anyListeners;for(let c=0;c<u.length;c++)if(r===u[c])return u.splice(c,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(r){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(r),this}prependAnyOutgoing(r){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(r),this}offAnyOutgoing(r){if(!this._anyOutgoingListeners)return this;if(r){const u=this._anyOutgoingListeners;for(let c=0;c<u.length;c++)if(r===u[c])return u.splice(c,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(r){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const u=this._anyOutgoingListeners.slice();for(const c of u)c.apply(this,r.data)}}}function Ya(i){i=i||{},this.ms=i.min||100,this.max=i.max||1e4,this.factor=i.factor||2,this.jitter=i.jitter>0&&i.jitter<=1?i.jitter:0,this.attempts=0}Ya.prototype.duration=function(){var i=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var r=Math.random(),u=Math.floor(r*this.jitter*i);i=(Math.floor(r*10)&1)==0?i-u:i+u}return Math.min(i,this.max)|0};Ya.prototype.reset=function(){this.attempts=0};Ya.prototype.setMin=function(i){this.ms=i};Ya.prototype.setMax=function(i){this.max=i};Ya.prototype.setJitter=function(i){this.jitter=i};class Ad extends rt{constructor(r,u){var c;super(),this.nsps={},this.subs=[],r&&typeof r=="object"&&(u=r,r=void 0),u=u||{},u.path=u.path||"/socket.io",this.opts=u,Kr(this,u),this.reconnection(u.reconnection!==!1),this.reconnectionAttempts(u.reconnectionAttempts||1/0),this.reconnectionDelay(u.reconnectionDelay||1e3),this.reconnectionDelayMax(u.reconnectionDelayMax||5e3),this.randomizationFactor((c=u.randomizationFactor)!==null&&c!==void 0?c:.5),this.backoff=new Ya({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(u.timeout==null?2e4:u.timeout),this._readyState="closed",this.uri=r;const d=u.parser||CN;this.encoder=new d.Encoder,this.decoder=new d.Decoder,this._autoConnect=u.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(r){return arguments.length?(this._reconnection=!!r,r||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(r){return r===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=r,this)}reconnectionDelay(r){var u;return r===void 0?this._reconnectionDelay:(this._reconnectionDelay=r,(u=this.backoff)===null||u===void 0||u.setMin(r),this)}randomizationFactor(r){var u;return r===void 0?this._randomizationFactor:(this._randomizationFactor=r,(u=this.backoff)===null||u===void 0||u.setJitter(r),this)}reconnectionDelayMax(r){var u;return r===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=r,(u=this.backoff)===null||u===void 0||u.setMax(r),this)}timeout(r){return arguments.length?(this._timeout=r,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(r){if(~this._readyState.indexOf("open"))return this;this.engine=new gN(this.uri,this.opts);const u=this.engine,c=this;this._readyState="opening",this.skipReconnect=!1;const d=sn(u,"open",function(){c.onopen(),r&&r()}),h=g=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",g),r?r(g):this.maybeReconnectOnOpen()},p=sn(u,"error",h);if(this._timeout!==!1){const g=this._timeout,b=this.setTimeoutFn(()=>{d(),h(new Error("timeout")),u.close()},g);this.opts.autoUnref&&b.unref(),this.subs.push(()=>{this.clearTimeoutFn(b)})}return this.subs.push(d),this.subs.push(p),this}connect(r){return this.open(r)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const r=this.engine;this.subs.push(sn(r,"ping",this.onping.bind(this)),sn(r,"data",this.ondata.bind(this)),sn(r,"error",this.onerror.bind(this)),sn(r,"close",this.onclose.bind(this)),sn(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(r){try{this.decoder.add(r)}catch(u){this.onclose("parse error",u)}}ondecoded(r){Xr(()=>{this.emitReserved("packet",r)},this.setTimeoutFn)}onerror(r){this.emitReserved("error",r)}socket(r,u){let c=this.nsps[r];return c?this._autoConnect&&!c.active&&c.connect():(c=new Kb(this,r,u),this.nsps[r]=c),c}_destroy(r){const u=Object.keys(this.nsps);for(const c of u)if(this.nsps[c].active)return;this._close()}_packet(r){const u=this.encoder.encode(r);for(let c=0;c<u.length;c++)this.engine.write(u[c],r.options)}cleanup(){this.subs.forEach(r=>r()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(r,u){var c;this.cleanup(),(c=this.engine)===null||c===void 0||c.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",r,u),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const r=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const u=this.backoff.duration();this._reconnecting=!0;const c=this.setTimeoutFn(()=>{r.skipReconnect||(this.emitReserved("reconnect_attempt",r.backoff.attempts),!r.skipReconnect&&r.open(d=>{d?(r._reconnecting=!1,r.reconnect(),this.emitReserved("reconnect_error",d)):r.onreconnect()}))},u);this.opts.autoUnref&&c.unref(),this.subs.push(()=>{this.clearTimeoutFn(c)})}}onreconnect(){const r=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",r)}}const Vi={};function Ur(i,r){typeof i=="object"&&(r=i,i=void 0),r=r||{};const u=xN(i,r.path||"/socket.io"),c=u.source,d=u.id,h=u.path,p=Vi[d]&&h in Vi[d].nsps,g=r.forceNew||r["force new connection"]||r.multiplex===!1||p;let b;return g?b=new Ad(c,r):(Vi[d]||(Vi[d]=new Ad(c,r)),b=Vi[d]),u.query&&!r.query&&(r.query=u.queryKey),b.socket(u.path,r)}Object.assign(Ur,{Manager:Ad,Socket:Kb,io:Ur,connect:Ur});let Ku=null;function kg(){return Ku||(Ku=Ur(window.location.origin,{path:"/socket.io",transports:["websocket","polling"],reconnectionAttempts:10,reconnectionDelay:2e3})),Ku}function zN(i){const[r,u]=K.useState(!1),[c,d]=K.useState(null);return K.useEffect(()=>{const h=kg(),p=()=>u(!0),g=()=>u(!1),b=B=>{d(G=>({...G,...B,state:(B==null?void 0:B.state)||(G==null?void 0:G.state)||"idle"})),i==null||i("session",B)},E=B=>{d(G=>({...G,state:(B==null?void 0:B.state)||(G==null?void 0:G.state)||"idle",status:(B==null?void 0:B.status)||(G==null?void 0:G.status)})),i==null||i("status_update",B)},v=B=>{d(G=>({...G,...B})),i==null||i("status",B)},x=B=>{d(G=>({...G,state:"waiting_for_qr",qr:B})),i==null||i("qr",B)},C=B=>{const G=typeof B=="object"&&B&&"code"in B?String(B.code):String(B||"");d(X=>({...X,state:"waiting_for_qr",pairingCode:G})),i==null||i("pairing_code",G)},U=()=>{d(B=>B?{...B,qr:null}:null),i==null||i("qr_cleared",{})},Z=()=>{d(B=>B?{...B,pairingCode:null}:null),i==null||i("pairing_code_cleared",{})},D=(B,...G)=>{i==null||i(B,G[0])};return h.on("connect",p),h.on("disconnect",g),h.on("session",b),h.on("status_update",E),h.on("status",v),h.on("qr",x),h.on("pairing_code",C),h.on("pairing-code",C),h.on("qr_cleared",U),h.on("pairing_code_cleared",Z),h.onAny(D),u(h.connected),()=>{h.off("connect",p),h.off("disconnect",g),h.off("session",b),h.off("status_update",E),h.off("status",v),h.off("qr",x),h.off("pairing_code",C),h.off("pairing-code",C),h.off("qr_cleared",U),h.off("pairing_code_cleared",Z),h.offAny(D)}},[i]),{isConnected:r,sessionStatus:c,socket:kg()}}const Zi=({isOpen:i,onClose:r,title:u,children:c,footer:d,maxWidth:h})=>(K.useEffect(()=>{const p=g=>{g.key==="Escape"&&r()};return i&&(document.addEventListener("keydown",p),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",p),document.body.style.overflow="auto"}},[i,r]),i?o.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 overflow-y-auto",children:[o.jsx("button",{type:"button",className:"fixed inset-0 bg-black/65 backdrop-blur-sm border-0 p-0 cursor-default",onClick:r,"aria-label":"Close modal backdrop"}),o.jsxs("div",{className:"relative w-full rounded-2xl border border-line bg-panel shadow-2xl overflow-hidden my-auto z-10 animate-in fade-in zoom-in-95 duration-150",role:"dialog","aria-modal":"true","aria-label":u,style:h?{maxWidth:h}:{maxWidth:"520px"},children:[o.jsxs("div",{className:"flex items-center justify-between p-5 border-b border-line",children:[o.jsx("h3",{className:"text-base md:text-lg font-bold text-text-main",children:u}),o.jsx("button",{type:"button",onClick:r,className:"inline-flex items-center justify-center w-8 h-8 rounded-lg border border-line bg-panel-raised hover:bg-panel-hover text-text-main transition-colors","aria-label":"Close modal",children:o.jsx(Ji,{size:18})})]}),o.jsx("div",{className:"p-5 overflow-y-auto max-h-[75vh]",children:c}),d&&o.jsx("div",{className:"flex items-center justify-end gap-3 p-4 border-t border-line bg-panel-raised/50",children:d})]})]}):null),Xl=({checked:i,onChange:r,disabled:u=!1,id:c,label:d,description:h})=>{const p=c||`toggle-${Math.random().toString(36).slice(2,8)}`;return o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[(d||h)&&o.jsxs("div",{className:"min-w-0 flex-1",children:[d&&o.jsx("label",{htmlFor:p,className:"font-semibold text-sm cursor-pointer block text-text-main",children:d}),h&&o.jsx("p",{className:"text-xs text-muted mt-0.5",children:h})]}),o.jsx("button",{type:"button",role:"switch","aria-checked":i,id:p,disabled:u,onClick:()=>r(!i),className:Nn("relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus-visible:ring-2 focus-visible:ring-brand-blue/50 disabled:opacity-50 disabled:cursor-not-allowed",i?"bg-brand-blue":"bg-panel-hover border border-line"),children:o.jsx("span",{className:Nn("pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow-md ring-0 transition duration-200 ease-in-out",i?"translate-x-5 rtl:-translate-x-5":"translate-x-0")})})]})},MN=()=>{var ye,fe,Se,oe,be;const{t:i,language:r}=rn(),{toast:u}=yl(),[c,d]=K.useState({}),[h,p]=K.useState({}),[g,b]=K.useState(!0),[E,v]=K.useState({}),[x,C]=K.useState(!1),[U,Z]=K.useState(!1),[D,B]=K.useState(!1),[G,X]=K.useState(""),[le,W]=K.useState([]),[me,J]=K.useState(null),[Y,R]=K.useState(""),I=[{id:"gemini",name:"Google Gemini",descKey:"providerGeminiDesc",provider:"gemini",defaultModel:"gemini-3.7-flash",defaultBaseUrl:"",keySetting:"gemini_api_key",modelSetting:"gemini_model",baseUrlSetting:"gemini_base_url"},{id:"groq",name:"Groq Cloud",descKey:"providerGroqDesc",provider:"openai",defaultModel:"llama-3.3-70b-versatile",defaultBaseUrl:"https://api.groq.com/openai/v1",keySetting:"openai_api_key",modelSetting:"openai_model",baseUrlSetting:"openai_base_url"},{id:"openai",name:"OpenAI",descKey:"providerOpenAIDesc",provider:"openai",defaultModel:"gpt-4o-mini",defaultBaseUrl:"https://api.openai.com/v1",keySetting:"openai_api_key",modelSetting:"openai_model",baseUrlSetting:"openai_base_url"},{id:"ollama",name:"Ollama (Local)",descKey:"providerOllamaDesc",provider:"openai",defaultModel:"llama3.2",defaultBaseUrl:"http://localhost:11434/v1",keySetting:"openai_api_key",modelSetting:"openai_model",baseUrlSetting:"openai_base_url"},{id:"anthropic",name:"Anthropic Claude",descKey:"providerAnthropicDesc",provider:"anthropic",defaultModel:"claude-sonnet-4-5",defaultBaseUrl:"https://api.anthropic.com",keySetting:"anthropic_api_key",modelSetting:"anthropic_model",baseUrlSetting:"anthropic_base_url"}],ie=async()=>{try{const L=await re.getSettings();if(L!=null&&L.settings){const je={},nt={};L.settings.forEach(Le=>{je[Le.key]=Le.value,Le.type==="secret"&&(nt[Le.key]=!!Le.configured)}),d(je),p(nt)}}catch(L){u(L.message,"error")}finally{b(!1)}};K.useEffect(()=>{ie()},[]);const $=async(L,je,nt=!1)=>{d(Le=>({...Le,[L]:je}));try{const Le=await re.updateSetting(L,je);if(nt||u(i("savedSuccessfully"),"success"),L.endsWith("_api_key")&&(d(ve=>({...ve,[L]:""})),p(ve=>({...ve,[L]:!!je}))),Le!=null&&Le.settings&&Array.isArray(Le.settings)){const ve={},Be={};Le.settings.forEach(Ze=>{Ze.type==="secret"?(Be[Ze.key]=!!Ze.configured,ve[Ze.key]=""):ve[Ze.key]=Ze.value}),d(Ze=>({...Ze,...ve})),p(Ze=>({...Ze,...Be}))}}catch(Le){u(Le.message,"error")}},te=c.ai_provider||"gemini",Q=I.find(L=>{var je,nt;return L.provider!==te?!1:!!(L.id==="gemini"||L.id==="anthropic"||L.id==="groq"&&((je=c.openai_base_url)!=null&&je.includes("groq.com"))||L.id==="ollama"&&((nt=c.openai_base_url)!=null&&nt.includes("11434"))||L.id==="openai"&&(!c.openai_base_url||c.openai_base_url.includes("api.openai.com")))})||I[0],ae=async L=>{const je={...c,ai_provider:L.provider};L.baseUrlSetting&&(je[L.baseUrlSetting]=L.defaultBaseUrl),L.defaultModel&&(je[L.modelSetting]=L.defaultModel),d(je);try{await re.updateSetting("ai_provider",L.provider),L.baseUrlSetting&&await re.updateSetting(L.baseUrlSetting,L.defaultBaseUrl),L.defaultModel&&await re.updateSetting(L.modelSetting,L.defaultModel),u(r==="ar"?`تم التبديل إلى ${L.name}`:`Switched provider to ${L.name}`,"success")}catch(nt){u(nt.message,"error")}},pe=async(L=!1)=>{C(!0);const je=String(c[Q.keySetting]||"").trim(),nt=!!h[Q.keySetting];try{const Le={provider:Q.provider,refresh:L};je&&(Le.apiKey=je),Q.baseUrlSetting&&c[Q.baseUrlSetting]&&(Le.baseUrl=c[Q.baseUrlSetting]);const ve=await re.fetchAiModels(Le);ve&&(ve.success||ve.fallback)?(v(Be=>{var Ze;return{...Be,[Q.id]:{live:!!ve.live,requiresApiKey:!!ve.requiresApiKey,fallback:!!ve.fallback,models:ve.models||[],cached:!!ve.cached,error:ve.success||(Ze=ve.error)==null?void 0:Ze.message}}}),ve.live&&ve.success?u(r==="ar"?`تم التحقق بنجاح وجلب ${ve.models.length} نموذجاً متاحاً لحسابك`:`Discovered ${ve.models.length} live models available for your account`,"success"):ve.requiresApiKey?L&&u(r==="ar"?"يرجى إدخال مفتاح API أولاً لاكتشاف النماذج المتاحة لحسابك":"Enter an API key to discover account models","info"):!ve.success&&ve.error&&u(ve.error.message||"Failed to discover models","error")):ve&&!ve.success&&ve.error&&(v(Be=>{var Ze;return{...Be,[Q.id]:{live:!1,requiresApiKey:!(nt||je),fallback:!0,models:ve.models||[],error:(Ze=ve.error)==null?void 0:Ze.message}}}),u(ve.error.message||"Failed to discover models","error"))}catch(Le){u(Le.message||"Failed to fetch models","error")}finally{C(!1)}};K.useEffect(()=>{g||pe(!1)},[Q.id,h[Q.keySetting],g]);const T=((ye=E[Q.id])==null?void 0:ye.models)||[],F=!!((fe=E[Q.id])!=null&&fe.live),M=!!(((Se=E[Q.id])==null?void 0:Se.requiresApiKey)??!h[Q.keySetting]),se=c[Q.modelSetting]||Q.defaultModel,V=T.find(L=>L.id.toLowerCase()===se.toLowerCase())||{displayName:se,provider:Q.provider,capabilities:{textInput:!0,textOutput:!0,vision:!1,audioInput:!1,stt:!1,videoInput:!1,pdfInput:!1},capabilitySource:"unknown"},Me=!!V.capabilities.vision,Ue=!!V.capabilities.stt;K.useEffect(()=>{g||(!Me&&c.ai_vision_enabled&&$("ai_vision_enabled",!1,!0),!Ue&&c.ai_stt_enabled&&$("ai_stt_enabled",!1,!0))},[se,Me,Ue,g]);const Ge=async()=>{try{const L=await re.getPersona(),je=L==null?void 0:L.persona;X(typeof je=="string"?je:(je==null?void 0:je.body)||""),B(!0)}catch(L){u(L.message,"error")}},N=async()=>{try{await re.updatePersona(G),u(r==="ar"?"تم تحديث برومبت الشخصية بنجاح!":"Persona updated successfully!","success"),B(!1)}catch(L){u(L.message,"error")}},S=async()=>{try{const L=await re.getMemoryFiles(),je=(L==null?void 0:L.files)||((L==null?void 0:L.scopes)||[]).map(nt=>nt.scope);W(je)}catch(L){u(L.message,"error")}},P=async L=>{try{const je=await re.getMemoryFile(L);R((je==null?void 0:je.content)||"")}catch(je){u(je.message,"error")}},ne=async()=>{if(me)try{await re.updateMemoryFile(me,Y),u(r==="ar"?"تم حفظ ملف الذاكرة بنجاح!":"Memory file updated!","success"),J(null)}catch(L){u(L.message,"error")}};return g?o.jsxs("div",{className:"flex items-center justify-center p-12 text-muted",children:[o.jsx("div",{className:"w-6 h-6 border-2 border-brand-cyan border-t-transparent rounded-full animate-spin mr-2"}),o.jsx("span",{className:"text-sm font-semibold",children:i("starting")})]}):o.jsxs("div",{className:"flex flex-col gap-5 sm:gap-6",children:[o.jsxs("div",{className:"rounded-2xl border border-line bg-gradient-to-br from-panel-raised via-panel to-panel p-4 sm:p-6 shadow-sm flex flex-col gap-3.5",children:[o.jsxs("div",{className:"flex items-center justify-between gap-3",children:[o.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[o.jsx("div",{className:"w-11 h-11 sm:w-12 sm:h-12 rounded-2xl bg-gradient-to-br from-brand-blue to-brand-cyan text-white flex items-center justify-center shrink-0 shadow-md shadow-brand-blue/20",children:o.jsx(Ed,{size:22,className:"sm:w-6 sm:h-6"})}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("h2",{className:"text-base sm:text-xl font-extrabold text-text-main truncate",children:i("aiTitle")}),o.jsx("p",{className:"text-xs sm:text-sm text-muted truncate",children:i("aiSubtitle")})]})]}),o.jsxs("div",{className:"shrink-0 flex items-center gap-2 bg-panel/60 border border-line/70 rounded-xl px-2.5 py-1.5 shadow-xs",children:[o.jsx("span",{className:"text-xs font-bold text-muted hidden sm:inline",children:c.ai_agent?r==="ar"?"مفعل":"Enabled":r==="ar"?"معطل":"Disabled"}),o.jsx(Xl,{checked:!!c.ai_agent,onChange:L=>$("ai_agent",L)})]})]}),o.jsx("div",{className:"flex items-center gap-2 pt-1 border-t border-line/40",children:o.jsxs("span",{className:`inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-bold border ${c.ai_agent?"bg-ok/15 text-ok border-ok/30":"bg-danger/10 text-danger border-danger/25"}`,children:[o.jsx("span",{className:"pulse-dot"}),o.jsx("span",{children:c.ai_agent?i("aiAgentEnabled"):r==="ar"?"مساعد الذكاء الاصطناعي معطل":"AI Assistant Disabled"})]})})]}),o.jsxs("div",{className:"rounded-2xl border border-line bg-panel p-4 sm:p-6 shadow-sm flex flex-col gap-5",children:[o.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3 pb-3 border-b border-line",children:[o.jsxs("div",{className:"flex items-center gap-2.5",children:[o.jsx(Ng,{size:18,className:"text-brand-cyan shrink-0"}),o.jsx("h3",{className:"text-base sm:text-lg font-bold text-text-main",children:i("aiProvider")})]}),o.jsxs("div",{className:"flex items-center gap-2 self-start sm:self-auto",children:[o.jsx("span",{className:"text-xs text-muted font-medium",children:r==="ar"?"المزود النشط:":"Active:"}),o.jsxs("span",{className:"text-xs font-bold text-brand-cyan px-2.5 py-1 rounded-lg bg-brand-cyan/10 border border-brand-cyan/25",children:[Q.name," • ",o.jsx("span",{className:"font-mono",children:se})]})]})]}),o.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-2.5 sm:gap-3",children:I.map(L=>{const je=Q.id===L.id;return o.jsxs("button",{type:"button",onClick:()=>ae(L),className:`p-3.5 rounded-xl border text-start transition-all flex flex-col justify-between gap-2.5 focus-visible:ring-2 focus-visible:ring-brand-blue/50 ${je?"bg-brand-blue/15 border-brand-blue/60 shadow-sm ring-1 ring-brand-blue/40":"bg-panel-raised border-line hover:bg-panel-hover"}`,children:[o.jsxs("div",{className:"flex items-center justify-between w-full",children:[o.jsx("span",{className:"font-bold text-xs sm:text-sm text-text-main",children:L.name}),je?o.jsx("span",{className:"w-5 h-5 rounded-full bg-brand-blue text-white flex items-center justify-center shrink-0",children:o.jsx(Lr,{size:12,strokeWidth:3})}):o.jsx("span",{className:"w-2 h-2 rounded-full bg-line"})]}),o.jsx("span",{className:"text-[10px] sm:text-[11px] font-mono text-muted truncate block",children:L.defaultModel})]},L.id)})}),M&&o.jsxs("div",{className:"p-3.5 rounded-xl bg-amber-500/10 border border-amber-500/25 flex items-start gap-3",children:[o.jsx(Or,{size:18,className:"text-amber-500 shrink-0 mt-0.5"}),o.jsxs("div",{className:"text-xs text-text-main",children:[o.jsx("p",{className:"font-bold",children:i("connectKeyFirstPrompt")}),o.jsx("p",{className:"text-muted mt-0.5",children:r==="ar"?"النماذج المعروضة أدناه هي نماذج مقترحة من الدليل المحلي وليست مؤكدة لحسابك حتى يتم ربط المفتاح.":"Models shown below are catalog recommendations and are not verified for your account until a key is configured."})]})]}),((oe=E[Q.id])==null?void 0:oe.error)&&o.jsxs("div",{className:"p-3 rounded-xl bg-danger/10 border border-danger/25 flex items-center justify-between gap-3",children:[o.jsxs("div",{className:"flex items-center gap-2 text-xs text-danger font-semibold",children:[o.jsx(qr,{size:16,className:"shrink-0"}),o.jsx("span",{children:(be=E[Q.id])==null?void 0:be.error})]}),o.jsx("button",{type:"button",onClick:()=>pe(!0),className:"text-xs font-bold underline hover:opacity-80 shrink-0",children:i("refreshModels")})]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 pt-4 border-t border-line",children:[o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{htmlFor:"input-api-key",className:"block text-xs font-bold text-muted",children:i("apiKey")}),h[Q.keySetting]&&o.jsxs("span",{className:"text-[10px] text-ok font-semibold flex items-center gap-1",children:[o.jsx(Qr,{size:11}),r==="ar"?"محفوظ":"Saved"]})]}),o.jsx("input",{id:"input-api-key",type:"password",className:"w-full h-11 px-3.5 rounded-xl border border-line bg-panel-raised text-text-main font-mono text-xs sm:text-sm focus:outline-none focus:ring-2 focus:ring-brand-blue/50",value:c[Q.keySetting]||"",onChange:L=>d({...c,[Q.keySetting]:L.target.value}),onBlur:L=>$(Q.keySetting,L.target.value),placeholder:h[Q.keySetting]?"••••••••••••":r==="ar"?"أدخل المفتاح":"Enter API key"})]}),Q.baseUrlSetting&&o.jsxs("div",{className:"space-y-1.5",children:[o.jsx("label",{htmlFor:"input-base-url",className:"block text-xs font-bold text-muted",children:i("baseUrl")}),o.jsx("input",{id:"input-base-url",type:"text",className:"w-full h-11 px-3.5 rounded-xl border border-line bg-panel-raised text-text-main font-mono text-xs sm:text-sm focus:outline-none focus:ring-2 focus:ring-brand-blue/50",value:c[Q.baseUrlSetting]||"",onChange:L=>{Q.baseUrlSetting&&d({...c,[Q.baseUrlSetting]:L.target.value})},onBlur:L=>{Q.baseUrlSetting&&$(Q.baseUrlSetting,L.target.value)},placeholder:Q.defaultBaseUrl})]}),o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("label",{htmlFor:"input-model-name",className:"block text-xs font-bold text-muted",children:i("modelName")}),F?o.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-bold bg-ok/15 text-ok border border-ok/30",children:i("sourceLive")}):o.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-bold bg-brand-cyan/15 text-brand-cyan border border-brand-cyan/30",children:i("sourceSeed")})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("button",{type:"button",onClick:()=>Z(!U),className:"text-[11px] text-brand-cyan hover:underline font-semibold",children:U?r==="ar"?"القائمة":"List":r==="ar"?"مخصص":"Custom"}),o.jsxs("button",{type:"button",onClick:()=>pe(!0),disabled:x,className:"inline-flex items-center gap-1 text-[11px] text-brand-blue hover:text-brand-blue/80 font-bold",title:i("refreshModels"),children:[o.jsx(Gr,{size:11,className:x?"animate-spin":""}),o.jsx("span",{children:i(x?"refreshing":"refreshModels")})]})]})]}),U?o.jsx("input",{id:"input-model-name",type:"text",className:"w-full h-11 px-3.5 rounded-xl border border-line bg-panel-raised text-text-main font-mono text-xs sm:text-sm focus:outline-none focus:ring-2 focus:ring-brand-blue/50",value:c[Q.modelSetting]||"",onChange:L=>d({...c,[Q.modelSetting]:L.target.value}),onBlur:L=>$(Q.modelSetting,L.target.value),placeholder:Q.defaultModel}):o.jsxs("select",{id:"input-model-name",className:"w-full h-11 px-3.5 rounded-xl border border-line bg-panel-raised text-text-main font-mono text-xs sm:text-sm font-semibold focus:outline-none focus:ring-2 focus:ring-brand-blue/50",value:se,onChange:L=>{$(Q.modelSetting,L.target.value)},children:[o.jsx("optgroup",{label:i(F?"modelsAvailableLive":"modelsRecommendedSeed"),children:T.map(L=>o.jsxs("option",{value:L.id,children:[L.displayName&&L.displayName!==L.id?`${L.displayName} (${L.id})`:L.id,L.recommended?" ★":""]},L.id))}),!T.some(L=>L.id.toLowerCase()===se.toLowerCase())&&o.jsxs("option",{value:se,children:[se," (current)"]})]})]})]}),o.jsxs("div",{className:"p-3.5 rounded-xl border border-line bg-panel-raised/60 flex flex-col gap-2.5",children:[o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs",children:[o.jsxs("span",{className:"font-bold text-text-main flex items-center gap-1.5",children:[o.jsx(Ng,{size:14,className:"text-brand-cyan shrink-0"}),r==="ar"?"القدرات:":"Capabilities:"," ",o.jsx("span",{className:"font-mono text-brand-cyan",children:V.displayName||se})]}),o.jsx("span",{className:`text-[10px] font-bold px-2 py-0.5 rounded-full border ${V.capabilitySource==="provider"?"bg-ok/15 text-ok border-ok/30":V.capabilitySource==="seed"?"bg-brand-blue/15 text-brand-blue border-brand-blue/30":"bg-muted/15 text-muted border-line"}`,children:V.capabilitySource==="provider"?i("sourceLive"):V.capabilitySource==="seed"?i("sourceSeed"):i("sourceUnknown")})]}),o.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-2 text-xs",children:[o.jsxs("div",{className:`p-2 rounded-lg border flex items-center justify-between ${Me?"bg-ok/10 border-ok/25 text-ok":"bg-panel border-line text-muted"}`,children:[o.jsxs("div",{className:"flex items-center gap-1.5 font-medium",children:[o.jsx(Ha,{size:14}),o.jsx("span",{children:i("capVision")})]}),o.jsx("span",{className:"text-[10px] font-bold",children:i(Me?"supported":"unsupported")})]}),o.jsxs("div",{className:`p-2 rounded-lg border flex items-center justify-between ${Ue?"bg-ok/10 border-ok/25 text-ok":"bg-panel border-line text-muted"}`,children:[o.jsxs("div",{className:"flex items-center gap-1.5 font-medium",children:[o.jsx(Bu,{size:14}),o.jsx("span",{children:i("capStt")})]}),o.jsx("span",{className:"text-[10px] font-bold",children:i(Ue?"supported":"unsupported")})]}),o.jsxs("div",{className:`p-2 rounded-lg border flex items-center justify-between ${V.capabilities.audioInput?"bg-ok/10 border-ok/25 text-ok":"bg-panel border-line text-muted"}`,children:[o.jsxs("div",{className:"flex items-center gap-1.5 font-medium",children:[o.jsx(qv,{size:14}),o.jsx("span",{children:i("capAudio")})]}),o.jsx("span",{className:"text-[10px] font-bold",children:V.capabilities.audioInput?i("supported"):i("unsupported")})]}),o.jsxs("div",{className:`p-2 rounded-lg border flex items-center justify-between ${V.capabilities.textInput&&V.capabilities.textOutput?"bg-ok/10 border-ok/25 text-ok":"bg-panel border-line text-muted"}`,children:[o.jsxs("div",{className:"flex items-center gap-1.5 font-medium",children:[o.jsx(Mr,{size:14}),o.jsx("span",{children:i("capText")})]}),o.jsx("span",{className:"text-[10px] font-bold",children:V.capabilities.textInput&&V.capabilities.textOutput?i("supported"):i("unsupported")})]}),o.jsxs("div",{className:`p-2 rounded-lg border flex items-center justify-between ${V.capabilities.pdfInput?"bg-ok/10 border-ok/25 text-ok":"bg-panel border-line text-muted"}`,children:[o.jsxs("div",{className:"flex items-center gap-1.5 font-medium",children:[o.jsx(Mr,{size:14}),o.jsx("span",{children:i("capPdf")})]}),o.jsx("span",{className:"text-[10px] font-bold",children:V.capabilities.pdfInput?i("supported"):i("unsupported")})]}),o.jsxs("div",{className:`p-2 rounded-lg border flex items-center justify-between ${V.capabilities.videoInput?"bg-ok/10 border-ok/25 text-ok":"bg-panel border-line text-muted"}`,children:[o.jsxs("div",{className:"flex items-center gap-1.5 font-medium",children:[o.jsx(Ha,{size:14}),o.jsx("span",{children:i("capVideo")})]}),o.jsx("span",{className:"text-[10px] font-bold",children:V.capabilities.videoInput?i("supported"):i("unsupported")})]})]})]})]}),o.jsxs("div",{className:"rounded-2xl border border-line bg-panel p-4 sm:p-6 shadow-sm flex flex-col gap-4",children:[o.jsx("h3",{className:"text-base font-bold text-text-main",children:i("capabilities")}),o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:[o.jsxs("div",{className:"relative rounded-xl border border-line bg-panel-raised p-4 flex flex-col justify-between gap-3",children:[o.jsx("div",{className:"absolute top-3.5 end-3.5",children:o.jsx(Xl,{checked:!!c.ai_vision_enabled&&Me,disabled:!Me,onChange:L=>{Me&&$("ai_vision_enabled",L)}})}),o.jsxs("div",{className:"pe-12",children:[o.jsxs("div",{className:"flex items-center gap-2 text-text-main mb-1",children:[o.jsx(Ha,{size:17,className:Me?"text-brand-cyan shrink-0":"text-muted shrink-0"}),o.jsx("span",{className:"font-bold text-sm",children:i("aiVision")})]}),o.jsx("p",{className:"text-xs text-muted leading-relaxed",children:i("aiVisionDesc")}),!Me&&o.jsxs("p",{className:"text-[11px] text-amber-500 font-semibold mt-2 flex items-center gap-1",children:[o.jsx(Or,{size:13,className:"shrink-0"}),o.jsx("span",{children:i("visionUnsupportedNotice")})]})]})]}),o.jsxs("div",{className:"relative rounded-xl border border-line bg-panel-raised p-4 flex flex-col justify-between gap-3",children:[o.jsx("div",{className:"absolute top-3.5 end-3.5",children:o.jsx(Xl,{checked:!!(c.ai_stt_enabled??!0)&&Ue,disabled:!Ue,onChange:L=>{Ue&&$("ai_stt_enabled",L)}})}),o.jsxs("div",{className:"pe-12",children:[o.jsxs("div",{className:"flex items-center gap-2 text-text-main mb-1",children:[o.jsx(Bu,{size:17,className:Ue?"text-purple-400 shrink-0":"text-muted shrink-0"}),o.jsx("span",{className:"font-bold text-sm",children:i("aiSttEnabled")})]}),o.jsx("p",{className:"text-xs text-muted leading-relaxed",children:i("aiSttEnabledDesc")}),!Ue&&o.jsxs("p",{className:"text-[11px] text-amber-500 font-semibold mt-2 flex items-center gap-1",children:[o.jsx(Or,{size:13,className:"shrink-0"}),o.jsx("span",{children:i("sttUnsupportedNotice")})]})]})]}),o.jsxs("div",{className:"rounded-xl border border-line bg-panel-raised p-4 flex flex-col justify-between gap-3",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2 text-text-main mb-1",children:[o.jsx(Bu,{size:17,className:"text-purple-400 shrink-0"}),o.jsx("span",{className:"font-bold text-sm",children:i("aiStt")})]}),o.jsx("p",{className:"text-xs text-muted leading-relaxed",children:i("sttDesc")})]}),o.jsxs("select",{className:"w-full h-10 px-3 rounded-lg border border-line bg-panel text-text-main text-xs font-semibold focus:outline-none focus:ring-2 focus:ring-brand-blue/50 disabled:opacity-50",value:c.ai_stt_provider||"auto",disabled:!Ue,onChange:L=>{Ue&&$("ai_stt_provider",L.target.value)},children:[o.jsx("option",{value:"auto",children:i("sttAuto")}),o.jsx("option",{value:"gemini",children:i("sttGemini")}),o.jsx("option",{value:"openai",children:i("sttOpenAI")})]})]}),o.jsxs("div",{className:"rounded-xl border border-line bg-panel-raised p-4 flex flex-col justify-between gap-3",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2 text-text-main mb-1",children:[o.jsx(Hr,{size:17,className:"text-ok shrink-0"}),o.jsx("span",{className:"font-bold text-sm",children:i("botLanguage")})]}),o.jsx("p",{className:"text-xs text-muted leading-relaxed",children:i("botLanguageDesc")})]}),o.jsxs("select",{className:"w-full h-10 px-3 rounded-lg border border-line bg-panel text-text-main text-xs font-semibold focus:outline-none focus:ring-2 focus:ring-brand-blue/50",value:c.bot_language||"auto",onChange:L=>$("bot_language",L.target.value),children:[o.jsx("option",{value:"auto",children:i("langAuto")}),o.jsx("option",{value:"ar",children:i("langAr")}),o.jsx("option",{value:"en",children:i("langEn")})]})]})]})]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 sm:gap-5",children:[o.jsxs("div",{className:"rounded-2xl border border-line bg-panel p-4 sm:p-6 shadow-sm flex flex-col justify-between gap-4",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2.5 text-text-main mb-2",children:[o.jsx(Mr,{size:20,className:"text-brand-blue shrink-0"}),o.jsx("h3",{className:"text-base font-bold",children:i("personaPrompt")})]}),o.jsx("p",{className:"text-xs sm:text-sm text-muted leading-relaxed",children:i("personaDesc")})]}),o.jsx("button",{type:"button",onClick:Ge,className:"w-full h-11 rounded-xl border border-line bg-panel-raised hover:bg-panel-hover text-text-main font-bold text-xs sm:text-sm transition-colors focus-visible:ring-2 focus-visible:ring-brand-blue/50 flex items-center justify-center gap-2",children:o.jsx("span",{children:i("editPersona")})})]}),o.jsxs("div",{className:"rounded-2xl border border-line bg-panel p-4 sm:p-6 shadow-sm flex flex-col justify-between gap-4",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2.5 text-text-main mb-2",children:[o.jsx(wv,{size:20,className:"text-brand-cyan shrink-0"}),o.jsx("h3",{className:"text-base font-bold",children:i("memoryFiles")})]}),o.jsx("p",{className:"text-xs sm:text-sm text-muted leading-relaxed",children:i("memoryDesc")})]}),o.jsx("button",{type:"button",onClick:()=>{S(),J("global"),P("global")},className:"w-full h-11 rounded-xl border border-line bg-panel-raised hover:bg-panel-hover text-text-main font-bold text-xs sm:text-sm transition-colors focus-visible:ring-2 focus-visible:ring-brand-blue/50 flex items-center justify-center gap-2",children:o.jsx("span",{children:i("manageMemory")})})]})]}),o.jsx(Zi,{isOpen:D,onClose:()=>B(!1),title:i("personaPrompt"),maxWidth:"750px",footer:o.jsxs("div",{className:"flex items-center justify-end gap-2.5 w-full",children:[o.jsx("button",{type:"button",onClick:()=>B(!1),className:"px-4 h-10 rounded-xl border border-line bg-panel-raised hover:bg-panel-hover text-text-main font-bold text-xs sm:text-sm transition-colors",children:i("cancel")}),o.jsxs("button",{type:"button",onClick:N,className:"px-5 h-10 rounded-xl bg-brand-blue hover:bg-brand-blue/90 text-white font-bold text-xs sm:text-sm shadow-md shadow-brand-blue/25 transition-colors flex items-center gap-2",children:[o.jsx(Vr,{size:16}),o.jsx("span",{children:i("save")})]})]}),children:o.jsx("textarea",{className:"w-full rounded-xl border border-line bg-panel-raised p-3.5 text-text-main font-mono text-xs sm:text-sm leading-relaxed focus:outline-none focus:ring-2 focus:ring-brand-blue/50",rows:12,value:G,onChange:L=>X(L.target.value)})}),o.jsx(Zi,{isOpen:!!me,onClose:()=>J(null),title:`Memory File: ${me||""}`,maxWidth:"750px",footer:o.jsxs("div",{className:"flex items-center justify-end gap-2.5 w-full",children:[o.jsx("button",{type:"button",onClick:()=>J(null),className:"px-4 h-10 rounded-xl border border-line bg-panel-raised hover:bg-panel-hover text-text-main font-bold text-xs sm:text-sm transition-colors",children:i("cancel")}),o.jsxs("button",{type:"button",onClick:ne,className:"px-5 h-10 rounded-xl bg-brand-blue hover:bg-brand-blue/90 text-white font-bold text-xs sm:text-sm shadow-md shadow-brand-blue/25 transition-colors flex items-center gap-2",children:[o.jsx(Vr,{size:16}),o.jsx("span",{children:i("save")})]})]}),children:o.jsx("textarea",{className:"w-full rounded-xl border border-line bg-panel-raised p-3.5 text-text-main font-mono text-xs sm:text-sm leading-relaxed focus:outline-none focus:ring-2 focus:ring-brand-blue/50",rows:12,value:Y,onChange:L=>R(L.target.value)})})]})},ON=()=>{const{t:i,language:r}=rn(),{toast:u}=yl(),[c,d]=K.useState([]),[h,p]=K.useState("!"),[g,b]=K.useState(!1),[E,v]=K.useState("!"),[x,C]=K.useState(""),[U,Z]=K.useState(!0),[D,B]=K.useState(null),[G,X]=K.useState([]),[le,W]=K.useState(""),[me,J]=K.useState(!1),Y=async()=>{try{const T=await re.getCommands();T!=null&&T.commands&&d(T.commands),T!=null&&T.prefix&&(p(T.prefix),v(T.prefix))}catch(T){u(T.message,"error")}finally{Z(!1)}};K.useEffect(()=>{Y()},[]);const R=async()=>{const T=E.trim();if(!T||T.length>3){u(i("prefixValidation"),"error");return}try{await re.updatePrefix(T),p(T),b(!1),u(`${i("prefixUpdated")} (${T})`,"success")}catch(F){u(F.message,"error")}},I=async(T,F)=>{d(M=>M.map(se=>se.name===T.name?{...se,enabled:F,overridden:!0}:se));try{await re.updateCommand(T.name,{enabled:F}),u(r==="ar"?`تم ${F?"تفعيل":"تعطيل"} الأمر '${T.name}'`:`Command '${T.name}' ${F?"enabled":"disabled"}`,"success")}catch(M){u(M.message,"error"),Y()}},ie=async(T,F)=>{d(M=>M.map(se=>se.name===T.name?{...se,permission:F,overridden:!0}:se));try{await re.updateCommand(T.name,{permission:F}),u(r==="ar"?`تم تحديث رتبة '${T.name}'`:`Permission for '${T.name}' updated`,"success")}catch(M){u(M.message,"error"),Y()}},$=T=>{B(T),X(Array.isArray(T.aliases)?[...T.aliases]:[]),W("")},te=()=>{const T=le.trim().replace(/^[!/#.?$]+/,"").toLowerCase();if(T){if(G.includes(T)){u(r==="ar"?"هذا الاسم المستعار مضاف بالفعل":"Alias already added","warning");return}X([...G,T]),W("")}},Q=T=>{X(G.filter(F=>F!==T))},ae=async()=>{if(D){J(!0);try{await re.updateCommand(D.name,{aliases:G}),d(T=>T.map(F=>F.name===D.name?{...F,aliases:G}:F)),u(i("savedSuccessfully"),"success"),B(null)}catch(T){u(T.message,"error")}finally{J(!1)}}},pe=c.filter(T=>T.name.toLowerCase().includes(x.toLowerCase())||T.description.toLowerCase().includes(x.toLowerCase())||T.aliases.some(F=>F.toLowerCase().includes(x.toLowerCase())));return o.jsxs("div",{className:"flex flex-col gap-5 sm:gap-6",children:[o.jsxs("div",{className:"rounded-2xl border border-line bg-panel p-4 sm:p-6 shadow-sm flex flex-col md:flex-row md:items-center justify-between gap-4",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[o.jsx("h2",{className:"text-lg md:text-xl font-bold text-text-main",children:i("commands")}),o.jsxs("div",{className:"inline-flex items-center gap-2 px-3 py-1.5 rounded-xl border border-line bg-panel-raised",children:[o.jsxs("span",{className:"text-xs text-muted font-semibold",children:[i("activePrefix"),":"]}),g?o.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[o.jsx("input",{type:"text",maxLength:3,value:E,onChange:T=>v(T.target.value),className:"w-12 h-7 px-1.5 text-center font-mono font-bold text-xs rounded-lg border border-line bg-panel text-text-main focus:outline-none focus:ring-2 focus:ring-brand-blue/50",onKeyDown:T=>{T.key==="Enter"&&R(),T.key==="Escape"&&b(!1)}}),o.jsx("button",{type:"button",onClick:R,className:"px-2 h-7 rounded-lg bg-brand-blue text-white font-bold text-xs hover:bg-brand-blue/90 transition-colors",children:i("save")}),o.jsx("button",{type:"button",onClick:()=>b(!1),className:"px-2 h-7 rounded-lg border border-line bg-panel-raised text-muted font-bold text-xs hover:bg-panel-hover transition-colors",children:i("cancel")})]}):o.jsx("button",{type:"button",onClick:()=>{v(h),b(!0)},className:"px-2.5 py-0.5 rounded-lg bg-brand-cyan/15 text-brand-cyan border border-brand-cyan/30 font-mono font-bold text-xs hover:bg-brand-cyan/25 transition-colors",title:r==="ar"?"اضغط لتعديل البادئة":"Click to change prefix",children:h})]})]}),o.jsx("p",{className:"text-xs md:text-sm text-muted mt-1",children:r==="ar"?"إدارة رتب الأوامر والأسماء المستعارة وتفعيلها أو تعطيلها مباشرة":"Manage role permissions, edit aliases, or enable/disable bot commands live"})]}),o.jsxs("div",{className:"relative w-full md:w-72 shrink-0",children:[o.jsx(Ix,{size:18,className:"absolute start-3.5 top-3 text-muted"}),o.jsx("input",{type:"text",className:"w-full h-11 ps-10 pe-3.5 rounded-xl border border-line bg-panel-raised text-text-main text-sm focus:outline-none focus:ring-2 focus:ring-brand-blue/50",placeholder:i("searchPlaceholder"),value:x,onChange:T=>C(T.target.value)})]})]}),o.jsx("div",{className:"rounded-2xl border border-line bg-panel overflow-hidden shadow-sm overflow-x-auto",children:o.jsxs("table",{className:"w-full min-w-[760px] text-start border-collapse text-sm",children:[o.jsx("thead",{children:o.jsxs("tr",{className:"bg-panel-raised border-b border-line text-xs font-bold text-muted uppercase tracking-wider",children:[o.jsx("th",{className:"px-4 py-3.5 text-start",children:i("thCommand")}),o.jsx("th",{className:"px-4 py-3.5 text-start",children:i("thAliases")}),o.jsx("th",{className:"px-4 py-3.5 text-start",children:i("thDescription")}),o.jsx("th",{className:"px-4 py-3.5 text-start",children:i("thScope")}),o.jsx("th",{className:"px-4 py-3.5 text-start",children:i("thRequiredRole")}),o.jsx("th",{className:"px-4 py-3.5 text-center",children:i("thStatus")})]})}),o.jsx("tbody",{className:"divide-y divide-line/40",children:U?o.jsx("tr",{children:o.jsx("td",{colSpan:6,className:"text-center py-12 text-muted",children:o.jsxs("div",{className:"flex flex-col items-center justify-center gap-2",children:[o.jsx("div",{className:"w-6 h-6 border-2 border-brand-cyan border-t-transparent rounded-full animate-spin"}),o.jsx("span",{className:"text-xs",children:i("loading")})]})})}):pe.map(T=>{var F;return o.jsxs("tr",{className:"hover:bg-panel-hover/50 transition-colors",children:[o.jsx("td",{className:"px-4 py-3.5 font-mono font-bold text-brand-cyan",children:o.jsxs("bdi",{children:[h,T.name]})}),o.jsx("td",{className:"px-4 py-3.5",children:o.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[(F=T.aliases)!=null&&F.length?T.aliases.map(M=>o.jsx("span",{className:"inline-flex items-center font-mono text-[11px] px-2 py-0.5 rounded-md bg-panel-raised border border-line text-muted",children:o.jsxs("bdi",{children:[h,M]})},M)):o.jsx("span",{className:"text-xs text-muted/60",children:"—"}),o.jsx("button",{type:"button",onClick:()=>$(T),className:"inline-flex items-center justify-center w-6 h-6 rounded-md bg-panel-raised hover:bg-brand-blue/15 hover:text-brand-cyan text-muted border border-line transition-colors",title:i("editAliases"),children:o.jsx(Ov,{size:12})})]})}),o.jsx("td",{className:"px-4 py-3.5 max-w-xs text-text-main text-xs md:text-sm",children:T.description}),o.jsx("td",{className:"px-4 py-3.5",children:o.jsx("span",{className:"inline-flex px-2.5 py-0.5 rounded-lg bg-brand-blue/10 text-brand-cyan text-xs font-semibold",children:T.chat==="all"?r==="ar"?"الكل":"All":T.chat==="group"?r==="ar"?"المجموعات":"Group":r==="ar"?"خاص":"Private"})}),o.jsx("td",{className:"px-4 py-3.5",children:o.jsxs("select",{className:"h-9 px-2.5 rounded-lg border border-line bg-panel-raised text-text-main text-xs font-semibold focus:outline-none focus:ring-2 focus:ring-brand-blue/50",value:T.permission,onChange:M=>ie(T,M.target.value),children:[o.jsx("option",{value:"MEMBERS",children:r==="ar"?"الجميع (الأعضاء)":"Members (Everyone)"}),o.jsx("option",{value:"ADMIN_ONLY",children:r==="ar"?"مشرفو المجموعة":"Group Admins"}),o.jsx("option",{value:"OWNER_ONLY",children:r==="ar"?"مالك البوت فقط":"Bot Owner Only"})]})}),o.jsx("td",{className:"px-4 py-3.5 text-center",children:o.jsx(Xl,{checked:T.enabled,onChange:M=>I(T,M)})})]},T.name)})})]})}),o.jsx(Zi,{isOpen:!!D,onClose:()=>B(null),title:`${i("aliasesFor")} ${h}${(D==null?void 0:D.name)||""}`,footer:o.jsxs("div",{className:"flex items-center justify-end gap-2.5 w-full",children:[o.jsx("button",{type:"button",onClick:()=>B(null),className:"px-4 h-10 rounded-xl border border-line bg-panel-raised hover:bg-panel-hover text-text-main font-bold text-xs sm:text-sm transition-colors",children:i("cancel")}),o.jsx("button",{type:"button",onClick:ae,disabled:me,className:"px-5 h-10 rounded-xl bg-brand-blue hover:bg-brand-blue/90 text-white font-bold text-xs sm:text-sm shadow-md shadow-brand-blue/25 transition-colors disabled:opacity-50",children:i(me?"saving":"save")})]}),children:o.jsxs("div",{className:"flex flex-col gap-4 py-1",children:[o.jsx("p",{className:"text-xs sm:text-sm text-muted",children:r==="ar"?"الأسماء المستعارة تتيح استدعاء هذا الأمر بأسماء بديلة (مثل: p بدلاً من ping).":"Aliases allow invoking this command using alternative names."}),o.jsxs("div",{className:"space-y-1.5",children:[o.jsx("span",{className:"text-xs font-bold text-muted block",children:i("thAliases")}),o.jsx("div",{className:"flex items-center gap-2 flex-wrap min-h-[42px] p-2 rounded-xl border border-line bg-panel-raised",children:G.length>0?G.map(T=>o.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-lg bg-panel border border-line text-xs font-mono font-bold text-text-main",children:[o.jsxs("span",{children:[h,T]}),o.jsx("button",{type:"button",onClick:()=>Q(T),className:"text-muted hover:text-danger p-0.5 rounded transition-colors",children:o.jsx(Ji,{size:13})})]},T)):o.jsx("span",{className:"text-xs text-muted/60 px-1",children:i("noAliases")})})]}),o.jsxs("div",{className:"space-y-1.5",children:[o.jsx("label",{htmlFor:"new-alias-input",className:"text-xs font-bold text-muted block",children:i("addAlias")}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("div",{className:"relative flex-1",children:[o.jsx(Lv,{size:16,className:"absolute start-3 top-3 text-muted"}),o.jsx("input",{id:"new-alias-input",type:"text",value:le,onChange:T=>W(T.target.value),onKeyDown:T=>{T.key==="Enter"&&(T.preventDefault(),te())},placeholder:i("newAliasPlaceholder"),className:"w-full h-11 ps-9 pe-3 rounded-xl border border-line bg-panel text-text-main font-mono text-sm focus:outline-none focus:ring-2 focus:ring-brand-blue/50"})]}),o.jsxs("button",{type:"button",onClick:te,className:"inline-flex items-center justify-center gap-1.5 px-4 h-11 rounded-xl bg-panel-raised hover:bg-panel-hover border border-line text-text-main font-bold text-xs sm:text-sm transition-colors shrink-0",children:[o.jsx(Vx,{size:16}),o.jsx("span",{children:i("add")})]})]})]})]})})]})};var qa={},Zu,Rg;function kN(){return Rg||(Rg=1,Zu=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),Zu}var Ju={},gl={},Dg;function Zl(){if(Dg)return gl;Dg=1;let i;const r=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return gl.getSymbolSize=function(c){if(!c)throw new Error('"version" cannot be null or undefined');if(c<1||c>40)throw new Error('"version" should be in range from 1 to 40');return c*4+17},gl.getSymbolTotalCodewords=function(c){return r[c]},gl.getBCHDigit=function(u){let c=0;for(;u!==0;)c++,u>>>=1;return c},gl.setToSJISFunction=function(c){if(typeof c!="function")throw new Error('"toSJISFunc" is not a valid function.');i=c},gl.isKanjiModeEnabled=function(){return typeof i<"u"},gl.toSJIS=function(c){return i(c)},gl}var Iu={},Bg;function Ud(){return Bg||(Bg=1,(function(i){i.L={bit:1},i.M={bit:0},i.Q={bit:3},i.H={bit:2};function r(u){if(typeof u!="string")throw new Error("Param is not a string");switch(u.toLowerCase()){case"l":case"low":return i.L;case"m":case"medium":return i.M;case"q":case"quartile":return i.Q;case"h":case"high":return i.H;default:throw new Error("Unknown EC Level: "+u)}}i.isValid=function(c){return c&&typeof c.bit<"u"&&c.bit>=0&&c.bit<4},i.from=function(c,d){if(i.isValid(c))return c;try{return r(c)}catch{return d}}})(Iu)),Iu}var Pu,Ug;function RN(){if(Ug)return Pu;Ug=1;function i(){this.buffer=[],this.length=0}return i.prototype={get:function(r){const u=Math.floor(r/8);return(this.buffer[u]>>>7-r%8&1)===1},put:function(r,u){for(let c=0;c<u;c++)this.putBit((r>>>u-c-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(r){const u=Math.floor(this.length/8);this.buffer.length<=u&&this.buffer.push(0),r&&(this.buffer[u]|=128>>>this.length%8),this.length++}},Pu=i,Pu}var Fu,Lg;function DN(){if(Lg)return Fu;Lg=1;function i(r){if(!r||r<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=r,this.data=new Uint8Array(r*r),this.reservedBit=new Uint8Array(r*r)}return i.prototype.set=function(r,u,c,d){const h=r*this.size+u;this.data[h]=c,d&&(this.reservedBit[h]=!0)},i.prototype.get=function(r,u){return this.data[r*this.size+u]},i.prototype.xor=function(r,u,c){this.data[r*this.size+u]^=c},i.prototype.isReserved=function(r,u){return this.reservedBit[r*this.size+u]},Fu=i,Fu}var $u={},qg;function BN(){return qg||(qg=1,(function(i){const r=Zl().getSymbolSize;i.getRowColCoords=function(c){if(c===1)return[];const d=Math.floor(c/7)+2,h=r(c),p=h===145?26:Math.ceil((h-13)/(2*d-2))*2,g=[h-7];for(let b=1;b<d-1;b++)g[b]=g[b-1]-p;return g.push(6),g.reverse()},i.getPositions=function(c){const d=[],h=i.getRowColCoords(c),p=h.length;for(let g=0;g<p;g++)for(let b=0;b<p;b++)g===0&&b===0||g===0&&b===p-1||g===p-1&&b===0||d.push([h[g],h[b]]);return d}})($u)),$u}var Wu={},Hg;function UN(){if(Hg)return Wu;Hg=1;const i=Zl().getSymbolSize,r=7;return Wu.getPositions=function(c){const d=i(c);return[[0,0],[d-r,0],[0,d-r]]},Wu}var ed={},Gg;function LN(){return Gg||(Gg=1,(function(i){i.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const r={N1:3,N2:3,N3:40,N4:10};i.isValid=function(d){return d!=null&&d!==""&&!isNaN(d)&&d>=0&&d<=7},i.from=function(d){return i.isValid(d)?parseInt(d,10):void 0},i.getPenaltyN1=function(d){const h=d.size;let p=0,g=0,b=0,E=null,v=null;for(let x=0;x<h;x++){g=b=0,E=v=null;for(let C=0;C<h;C++){let U=d.get(x,C);U===E?g++:(g>=5&&(p+=r.N1+(g-5)),E=U,g=1),U=d.get(C,x),U===v?b++:(b>=5&&(p+=r.N1+(b-5)),v=U,b=1)}g>=5&&(p+=r.N1+(g-5)),b>=5&&(p+=r.N1+(b-5))}return p},i.getPenaltyN2=function(d){const h=d.size;let p=0;for(let g=0;g<h-1;g++)for(let b=0;b<h-1;b++){const E=d.get(g,b)+d.get(g,b+1)+d.get(g+1,b)+d.get(g+1,b+1);(E===4||E===0)&&p++}return p*r.N2},i.getPenaltyN3=function(d){const h=d.size;let p=0,g=0,b=0;for(let E=0;E<h;E++){g=b=0;for(let v=0;v<h;v++)g=g<<1&2047|d.get(E,v),v>=10&&(g===1488||g===93)&&p++,b=b<<1&2047|d.get(v,E),v>=10&&(b===1488||b===93)&&p++}return p*r.N3},i.getPenaltyN4=function(d){let h=0;const p=d.data.length;for(let b=0;b<p;b++)h+=d.data[b];return Math.abs(Math.ceil(h*100/p/5)-10)*r.N4};function u(c,d,h){switch(c){case i.Patterns.PATTERN000:return(d+h)%2===0;case i.Patterns.PATTERN001:return d%2===0;case i.Patterns.PATTERN010:return h%3===0;case i.Patterns.PATTERN011:return(d+h)%3===0;case i.Patterns.PATTERN100:return(Math.floor(d/2)+Math.floor(h/3))%2===0;case i.Patterns.PATTERN101:return d*h%2+d*h%3===0;case i.Patterns.PATTERN110:return(d*h%2+d*h%3)%2===0;case i.Patterns.PATTERN111:return(d*h%3+(d+h)%2)%2===0;default:throw new Error("bad maskPattern:"+c)}}i.applyMask=function(d,h){const p=h.size;for(let g=0;g<p;g++)for(let b=0;b<p;b++)h.isReserved(b,g)||h.xor(b,g,u(d,b,g))},i.getBestMask=function(d,h){const p=Object.keys(i.Patterns).length;let g=0,b=1/0;for(let E=0;E<p;E++){h(E),i.applyMask(E,d);const v=i.getPenaltyN1(d)+i.getPenaltyN2(d)+i.getPenaltyN3(d)+i.getPenaltyN4(d);i.applyMask(E,d),v<b&&(b=v,g=E)}return g}})(ed)),ed}var zr={},Vg;function Zb(){if(Vg)return zr;Vg=1;const i=Ud(),r=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],u=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return zr.getBlocksCount=function(d,h){switch(h){case i.L:return r[(d-1)*4+0];case i.M:return r[(d-1)*4+1];case i.Q:return r[(d-1)*4+2];case i.H:return r[(d-1)*4+3];default:return}},zr.getTotalCodewordsCount=function(d,h){switch(h){case i.L:return u[(d-1)*4+0];case i.M:return u[(d-1)*4+1];case i.Q:return u[(d-1)*4+2];case i.H:return u[(d-1)*4+3];default:return}},zr}var td={},Yi={},Yg;function qN(){if(Yg)return Yi;Yg=1;const i=new Uint8Array(512),r=new Uint8Array(256);return(function(){let c=1;for(let d=0;d<255;d++)i[d]=c,r[c]=d,c<<=1,c&256&&(c^=285);for(let d=255;d<512;d++)i[d]=i[d-255]})(),Yi.log=function(c){if(c<1)throw new Error("log("+c+")");return r[c]},Yi.exp=function(c){return i[c]},Yi.mul=function(c,d){return c===0||d===0?0:i[r[c]+r[d]]},Yi}var Qg;function HN(){return Qg||(Qg=1,(function(i){const r=qN();i.mul=function(c,d){const h=new Uint8Array(c.length+d.length-1);for(let p=0;p<c.length;p++)for(let g=0;g<d.length;g++)h[p+g]^=r.mul(c[p],d[g]);return h},i.mod=function(c,d){let h=new Uint8Array(c);for(;h.length-d.length>=0;){const p=h[0];for(let b=0;b<d.length;b++)h[b]^=r.mul(d[b],p);let g=0;for(;g<h.length&&h[g]===0;)g++;h=h.slice(g)}return h},i.generateECPolynomial=function(c){let d=new Uint8Array([1]);for(let h=0;h<c;h++)d=i.mul(d,new Uint8Array([1,r.exp(h)]));return d}})(td)),td}var nd,Xg;function GN(){if(Xg)return nd;Xg=1;const i=HN();function r(u){this.genPoly=void 0,this.degree=u,this.degree&&this.initialize(this.degree)}return r.prototype.initialize=function(c){this.degree=c,this.genPoly=i.generateECPolynomial(this.degree)},r.prototype.encode=function(c){if(!this.genPoly)throw new Error("Encoder not initialized");const d=new Uint8Array(c.length+this.degree);d.set(c);const h=i.mod(d,this.genPoly),p=this.degree-h.length;if(p>0){const g=new Uint8Array(this.degree);return g.set(h,p),g}return h},nd=r,nd}var ld={},ad={},id={},Kg;function Jb(){return Kg||(Kg=1,id.isValid=function(r){return!isNaN(r)&&r>=1&&r<=40}),id}var vn={},Zg;function Ib(){if(Zg)return vn;Zg=1;const i="[0-9]+",r="[A-Z $%*+\\-./:]+";let u="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";u=u.replace(/u/g,"\\u");const c="(?:(?![A-Z0-9 $%*+\\-./:]|"+u+`)(?:.|[\r
384
+ */const gb={name:"zap",size:24,node:[["path",{d:"M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z",key:"1v7up4"}]]};gb.node;const Hv=xe(gb),Gu={ar:{overview:"نظرة عامة",connection:"حالة الاتصال",control:"التحكم والإدارة",commands:"كتالوج الأوامر",ai:"الذكاء الاصطناعي",groups:"المجموعات",roles:"الأدوار والمشرفين",schedules:"الرسائل المجدولة",notes:"الملاحظات والقوائم",settings:"الإعدادات العامة",logs:"السجلات المباشرة",connected:"متصل بالواتساب",disconnected:"غير متصل",starting:"جاري إنشاء الاتصال...",waiting_for_qr:"بانتظار مسح رمز الـ QR",linking:"جاري ربط الجلسة...",reconnecting:"جاري إعادة الاتصال...",retry_exhausted:"استُنفذت محاولات الاتصال",logged_out:"تم تسجيل الخروج من الهاتف",idle:"الجلسة خاملة",paused:"متوقف مؤقتاً",resume:"استئناف الجلسة",connectSession:"الاتصال",start:"بدء الاتصال",stop:"إيقاف مؤقت",reconnect:"إعادة الاتصال",unlink:"إلغاء الربط (Unlink)",restart:"إعادة تشغيل البوت",save:"حفظ التغييرات",saving:"جاري الحفظ...",cancel:"إلغاء",delete:"حذف",edit:"تعديل",add:"إضافة",refresh:"تحديث",logout:"تسجيل الخروج",close:"إغلاق",copy:"نسخ",copied:"تم النسخ!",clientIdentity:"هوية العميل",noPhonePaired:"لم يتم ربط أي هاتف بعد",linkedAs:"مرتبط كـ",datastoreHealth:"حالة قاعدة البيانات",datastoreHealthy:"بيانات الاعتماد ومفاتيح الجلسة ومطابقات LID سليمة ومستقرة.",reconnectPolicy:"سياسة إعادة الاتصال",reconnectPolicyDesc:"تراجع خطي تدريجي (5ث، 10ث، 15ث، 20ث، 25ث) مع محاولات محدودة.",maxAttemptsAutoPause:"الحد الأقصى: 5 محاولات · إيقاف تلقائي دون إنترنت",platformWeb:"المنصة: واتساب ويب (v7 Multi-Device)",databaseNodeSqlite:"قاعدة البيانات: node:sqlite (تزامني)",totalGroups:"إجمالي المجموعات",totalUsers:"المستخدمين المسجلين",commandCount:"الأوامر المفعلة",uptime:"مدة التشغيل",dataDir:"مجلد البيانات",quickStatus:"حالة النظام",activeSchedules:"المهام المجدولة النشطة",activeListening:"المساعد نشط ويستقبل الرسائل",pausedOrLinking:"اتصال واتساب متوقف حالياً أو قيد المزامنة",aiTitle:"إعدادات الذكاء الاصطناعي",aiSubtitle:"اختر المزود المناسب بضغطة زر أو خصص النماذج والمفاتيح",aiAgentEnabled:"تفعيل وكيل الذكاء الاصطناعي",aiProvider:"المزود النشط",quickSetup:"معالج الإعداد السريع للمزودين",aiVision:"تحليل وفهم الصور (Vision)",aiVisionDesc:"تحويل الصور وتمريرها لنماذج الرؤية الذكية المتوافقة",aiStt:"محرك تحويل الصوت إلى نص (STT)",sttDesc:"محرك تفريغ الرسائل الصوتية وتحويلها إلى نص",sttAuto:"تلقائي (مطابق للمزود النشط)",sttGemini:"Google Gemini Audio API",sttOpenAI:"OpenAI / Groq Whisper API",botLanguage:"لغة ردود البوت",botLanguageDesc:"تحديد لغة ردود البوت أو تغييرها عبر الأمر !lang",langAuto:"تلقائي (حسب لغة رسالة المستخدم)",langAr:"العربية الفصحى (دائماً)",langEn:"English (دائماً)",modelName:"النموذج",apiKey:"مفتاح API",baseUrl:"Base URL",maxToolSteps:"الحد الأقصى لخطوات الأدوات",googleSearch:"أداة بحث جوجل المدمجة (Google Search)",personaPrompt:"برومبت شخصية البوت (AI Persona)",personaDesc:"تعديل التوجيه الأساسي الذي يحدد أسلوب وشخصية مساعدك الذكي",editPersona:"تعديل برومبت الشخصية",memoryFiles:"ملفات الذاكرة طويلة المدى",memoryDesc:"استعراض وتعديل ملفات الذاكرة التراكمية المحفوظة بصيغة Markdown",manageMemory:"إدارة ملفات الذاكرة",capabilities:"القدرات والميزات المتقدمة",modelsAvailableLive:"نماذج متاحة لحسابك (تم التحقق عبر API)",modelsRecommendedSeed:"نماذج مقترحة / معروفة (دليل النماذج)",connectKeyFirstPrompt:"يرجى إدخال مفتاح API أولاً لاكتشاف النماذج المتاحة لحسابك",refreshModels:"تحديث قائمة النماذج",refreshing:"جارِ التحديث...",fetchModels:"فحص النماذج المتاحة",fetchingModels:"جارِ فحص النماذج...",capVision:"الرؤية",capStt:"الصوت",capAudio:"إدخال الصوت",capText:"نص",capPdf:"PDF",capVideo:"فيديو",supported:"مدعوم",unsupported:"غير مدعوم",sourceLive:"حسابك",sourceSeed:"مقترح",sourceUnknown:"غير معروف",visionUnsupportedNotice:"النموذج المختار لا يدعم معالجة الصور والرؤية (Vision)، تم تعطيل الميزة تلقائياً.",sttUnsupportedNotice:"النموذج المختار لا يدعم تحويل وفهم الصوت (STT)، تم تعطيل الميزة تلقائياً.",aiSttEnabled:"تفعيل تحويل وفهم الصوت (STT)",aiSttEnabledDesc:"تفريغ الرسائل الصوتية وفهم الملفات الصوتية عبر النموذج المختار",providerGemini:"Google Gemini",providerGeminiDesc:"الافتراضي، يدعم البحث والملفات والصور والصوتيات محلياً",providerGroq:"Groq Cloud",providerGroqDesc:"فائق السرعة لنماذج Llama 3 و Mixtral مع دعم Vision",providerOpenAI:"OpenAI / Compatible",providerOpenAIDesc:"لنماذج GPT-4o أو أي خادم متوافق مع API OpenAI",providerOllama:"Ollama (محلي)",providerOllamaDesc:"تشغيل النماذج محلياً على جهازك مجاناً بدون إنترنت",providerAnthropic:"Anthropic Claude",providerAnthropicDesc:"لنماذج Claude 3.5 Sonnet الذكية والمتقدمة",scanQrHint:"افتح تطبيق واتساب على هاتفك > الأجهزة المرتبطة > ربط جهاز، وامسح الرمز أدناه.",pairingCode:"رمز الربط (Pairing Code)",reconnectingSoon:"إعادة الاتصال قريباً...",nextAttemptIn:"المحاولة القادمة خلال",seconds:"ثوانٍ",tabGeneral:"عام والبادئة",tabAI:"الذكاء الاصطناعي",tabSecurity:"الأمان والوصول",tabProxy:"بروكسي واتساب",tabStorage:"التخزين والوسائط",tabLogs:"سجلات النظام",prefixTitle:"بادئة أوامر البوت (Command Prefix)",prefixDesc:"الرمز أو الحرف الذي تبدأ به جميع الأوامر الموجهة للبوت في واتساب (مثل !help أو /ping)",prefixPlaceholder:"مثال: !",prefixPresets:"بادئات شائعة سريعة:",prefixPreview:"معاينة حية لشكل الأوامر:",prefixSaveBtn:"حفظ البادئة الجديدة",prefixUpdated:"تم تحديث بادئة الأوامر بنجاح!",prefixValidation:"يجب أن تكون البادئة من رمز واحد إلى 3 رموز",activePrefix:"البادئة الحالية",changePrefix:"تعديل البادئة",prefix:"بادئة الأوامر (Prefix)",botTimezone:"المنطقة الزمنية (Timezone)",botTimezoneDesc:"المنطقة الزمنية المعتمدة لحساب أوقات الصلاة والمهام المجدولة (مثل Africa/Cairo)",botMinDelay:"الحد الأدنى للتأخير البشري (ms)",botMaxDelay:"الحد الأقصى للتأخير البشري (ms)",delaysDesc:"فترة انتظار قصيرة قبل إرسال الردود ليبدو سلوك البوت طبيعياً وبشرياً",changePassword:"تغيير كلمة مرور لوحة التحكم",currentPassword:"كلمة المرور الحالية",newPassword:"كلمة المرور الجديدة",confirmPassword:"تأكيد كلمة المرور الجديدة",passwordMatchError:"كلمتا المرور غير متطابقتين",passwordMinLength:"يجب ألا تقل كلمة المرور عن 8 خانات",passwordChangedSuccess:"تم تغيير كلمة مرور لوحة التحكم بنجاح!",proxyTitle:"بروكسي واتساب الصادر (Outbound Proxy)",proxyDesc:"توجيه اتصالات Baileys إلى واتساب عبر بروكسي خارجي لتجاوز قيود الشبكة أو الحظر",proxyEnabled:"تفعيل البروكسي لاتصالات واتساب",proxyProtocol:"بروتوكول البروكسي (Protocol)",proxyHost:"عنوان المضيف (Host / IP)",proxyPort:"المنفذ (Port)",proxyUsername:"اسم المستخدم (اختياري)",proxyPassword:"كلمة المرور (اختياري)",proxyApplyHint:"⚠️ ملاحظة: عند تعديل إعدادات البروكسي، اضغط على زر إعادة الاتصال في صفحة الاتصال لتطبيق التغييرات.",storageTitle:"إدارة البيانات والاحتفاظ بها",storageDesc:"تحديد مدد صلاحية البيانات المؤقتة وسجلات الرسائل الموجهة والحدود القصوى للجلب",forwardTtl:"صلاحية سجلات الرسائل الموجهة (أيام)",forwardTtlDesc:"حذف إحصائيات الرسائل الموجهة القديمة تلقائياً بعد مرور هذا العدد من الأيام",maxFetchBytes:"الحد الأقصى لجلب محتوى صفحات الويب (Bytes)",maxFetchBytesDesc:"حجم المحتوى الأقصى المسموح لأدوات الذكاء الاصطناعي بجلبه من صفحات الويب (افتراضي: 512KB)",ffmpegPath:"مسار محرك FFmpeg مخصص (اختياري)",weatherApiKey:"مفتاح OpenWeatherMap API (اختياري)",chooseLanguage:"اختر اللغة",langCardTitle:"لغة الواجهة: العربية (RTL)",langCardDesc:"تصميم مخصص بالكامل لاتجاه الكتابة العربي من اليمين لليسار مع خط تجوال",langSwitchBtn:"Switch to English",langName:"العربية",interfaceLanguage:"لغة لوحة التحكم",interfaceLanguageDesc:"التبديل الفوري بين الواجهة العربية (RTL) والإنجليزية (LTR)",botPort:"منفذ خادم لوحة التحكم (Port)",botPortHint:"* يتطلب تغيير المنفذ إعادة تشغيل البوت ليأخذ مفعوله",searchPlaceholder:"ابحث في الأوامر أو الأسماء البديلة...",thCommand:"الأمر",thAliases:"الأسماء البديلة",thDescription:"الوصف",thScope:"النطاق",thRequiredRole:"الرتبة المطلوبة",thStatus:"الحالة",thGroupName:"اسم المجموعة",thGroupJid:"معرف المجموعة (JID)",thMembers:"الأعضاء",thAntiLink:"مانع الروابط",thMedia:"الوسائط",thWelcome:"الترحيب",thTarget:"الوجهة",thMessage:"الرسالة",thSchedule:"الموعد",thType:"النوع",thDelivery:"حالة الإرسال",thActions:"إجراءات",scheduleNewMsg:"جدولة رسالة جديدة",liveServerLogs:"سجلات النظام المباشرة",clearLogs:"مسح السجلات",allLogs:"جميع المستويات",noLogs:"لا توجد سجلات مسجلة حتى الآن.",savedSuccessfully:"تم حفظ الإعدادات بنجاح!",saveFailed:"حدث خطأ أثناء حفظ الإعدادات.",connectionStatusUpdated:"تم تحديث حالة الاتصال.",networkError:"تعذر الاتصال بالخادم.",loading:"جاري التحميل...",aiAssistantDesc:"وكيل ذكي متعدد الأدوات مع ذاكرة طويلة الأمد",settingsSub:"البادئة، التأخير، الخدمات، والأمان",editAliases:"تعديل الأسماء المستعارة",aliasesFor:"الأسماء المستعارة لـ",addAlias:"إضافة اسم مستعار",newAliasPlaceholder:"اكتب اسماً جديداً...",noAliases:"لا توجد أسماء مستعارة",selectRecipient:"اختر المحادثة المستهدفة",searchRecipients:"ابحث بالاسم أو رقم الهاتف...",recipients:"المستلمون",chooseChat:"اختر جهة اتصال أو مجموعة...",noRecipientsFound:"لم يتم العثور على محادثات",pickPhoneContact:"من دليل الهاتف",pickPhoneContactHint:"اختر جهة اتصال من هاتف أندرويد",maxSchedulesReached:"تم بلوغ الحد الأقصى (3 رسائل مجدولة)",limitReached:"الحد الأقصى مكتمل",tabIntegrations:"الربط والخدمات",integrationsDesc:"مفاتيح واجهات البرمجة (API) للخدمات الخارجية المرتبطة بالبوت",youtubeApiKey:"مفتاح YouTube Data API (اختياري)",selectModel:"اختر نموذجاً من القائمة...",availableModels:"النماذج المتاحة من المزود",customModel:"أو اكتب اسم نموذج مخصص",sessionStatus:"حالة الجلسة",sessionActive:"الجلسة متصلة وتستقبل الرسائل",sessionOffline:"الجلسة غير متصلة حالياً",connectedNumber:"الرقم المرتبط"},en:{overview:"Overview",connection:"Connection",control:"Control & Management",commands:"Command Catalog",ai:"AI & Memory",groups:"Groups",roles:"Roles & Admins",schedules:"Scheduled Messages",notes:"Notes & Lists",settings:"Settings",logs:"Live Logs",connected:"Connected to WhatsApp",disconnected:"Disconnected",starting:"Starting socket...",waiting_for_qr:"Waiting for QR scan",linking:"Linking session...",reconnecting:"Reconnecting...",retry_exhausted:"Retries exhausted",logged_out:"Logged out from phone",idle:"Session idle",paused:"Paused",resume:"Resume session",connectSession:"Connect",start:"Start Connection",stop:"Pause",reconnect:"Reconnect",unlink:"Unlink Device",restart:"Restart Bot",save:"Save Changes",saving:"Saving...",cancel:"Cancel",delete:"Delete",edit:"Edit",add:"Add",refresh:"Refresh",logout:"Sign Out",close:"Close",copy:"Copy",copied:"Copied!",clientIdentity:"Client Identity",noPhonePaired:"No phone paired yet",linkedAs:"Linked as",datastoreHealth:"Datastore Health",datastoreHealthy:"SQLite credentials, auth keys, and LID mappings are healthy.",reconnectPolicy:"Reconnect Policy",reconnectPolicyDesc:"Staged linear backoff (5s, 10s, 15s, 20s, 25s) with bounded retries.",maxAttemptsAutoPause:"Max attempts: 5 • Auto-pause offline",platformWeb:"Platform: WhatsApp Web (v7 Multi-Device)",databaseNodeSqlite:"Database: node:sqlite (Synchronous)",totalGroups:"Total Groups",totalUsers:"Registered Users",commandCount:"Enabled Commands",uptime:"Uptime",dataDir:"Data Directory",quickStatus:"System Status",activeSchedules:"Active Schedules",activeListening:"Active and listening to messages",pausedOrLinking:"WhatsApp connection is currently paused or linking",aiTitle:"AI Assistant Configuration",aiSubtitle:"Select a provider with one click or configure custom endpoints and keys",aiAgentEnabled:"Enable AI Agent",aiProvider:"Active Provider",quickSetup:"Quick Provider Setup Wizard",aiVision:"Image Understanding (Vision)",aiVisionDesc:"Encode attached images and pass to supported multimodal vision models",aiStt:"Speech-to-Text Provider (STT)",sttDesc:"Speech-to-text transcription engine for voice notes",sttAuto:"Auto (Matches active provider)",sttGemini:"Google Gemini Audio API",sttOpenAI:"OpenAI / Groq Whisper API",botLanguage:"Bot Response Language",botLanguageDesc:"Set bot response language directly or via command !lang",langAuto:"Auto-detect (matches user's language)",langAr:"Modern Standard Arabic (Always)",langEn:"English (Always)",modelName:"Model",apiKey:"API key",baseUrl:"Base URL",maxToolSteps:"Max Tool Steps",googleSearch:"Built-in Google Search Grounding",personaPrompt:"AI Persona System Prompt",personaDesc:"Edit the live system prompt that shapes your AI assistant's persona, tone, and behavior.",editPersona:"Edit System Prompt",memoryFiles:"Long-term Memory Files",memoryDesc:"Inspect and manage markdown memory documents stored inside the data directory.",manageMemory:"Manage Memory Files",capabilities:"Capabilities & Toggles",modelsAvailableLive:"Models Available for Your Account (Live API Verified)",modelsRecommendedSeed:"Recommended / Known Models (Catalog)",connectKeyFirstPrompt:"Please connect your API key first to discover models available to your account",refreshModels:"Refresh Models",refreshing:"Refreshing...",fetchModels:"Fetch Available Models",fetchingModels:"Discovering models...",capVision:"Vision",capStt:"Speech",capAudio:"Audio in",capText:"Text",capPdf:"PDF",capVideo:"Video",supported:"Supported",unsupported:"Unsupported",sourceLive:"Your account",sourceSeed:"Catalog",sourceUnknown:"Unknown",visionUnsupportedNotice:"The selected model does not support Vision (image understanding). Feature disabled automatically.",sttUnsupportedNotice:"The selected model does not support Speech-to-Text (STT). Feature disabled automatically.",aiSttEnabled:"Enable Speech-to-Text (STT)",aiSttEnabledDesc:"Audio transcription and voice note understanding using the active model",providerGemini:"Google Gemini",providerGeminiDesc:"Default provider with native Google Search, Files upload, and Multimodal support",providerGroq:"Groq Cloud",providerGroqDesc:"Ultra-fast inference for Llama 3 & Mixtral models with Vision support",providerOpenAI:"OpenAI / Compatible",providerOpenAIDesc:"For GPT-4o models or any OpenAI-compatible API gateway",providerOllama:"Ollama (Local)",providerOllamaDesc:"Run local open-source models completely offline on your own machine",providerAnthropic:"Anthropic Claude",providerAnthropicDesc:"For Claude 3.5 Sonnet advanced reasoning models",scanQrHint:"Open WhatsApp on your phone > Settings > Linked Devices > Link a Device, and scan the QR code below.",pairingCode:"Pairing Code",reconnectingSoon:"Reconnecting soon...",nextAttemptIn:"Next attempt in",seconds:"seconds",tabGeneral:"General & Prefix",tabAI:"AI Assistant",tabSecurity:"Security & Access",tabProxy:"WhatsApp Proxy",tabStorage:"Storage & Media",tabLogs:"System Logs",prefixTitle:"Bot Command Prefix",prefixDesc:"The leading character or symbol that triggers commands in WhatsApp chats (e.g. !help, /ping)",prefixPlaceholder:"e.g. !",prefixPresets:"Common Quick Presets:",prefixPreview:"Live Command Syntax Preview:",prefixSaveBtn:"Save New Prefix",prefixUpdated:"Command prefix updated successfully!",prefixValidation:"Prefix must be 1 to 3 characters long",activePrefix:"Active Prefix",changePrefix:"Change Prefix",prefix:"Command Prefix",botTimezone:"Timezone",botTimezoneDesc:"IANA timezone used for prayer times, AI context, and cron schedules (e.g. Africa/Cairo)",botMinDelay:"Min Human Delay (ms)",botMaxDelay:"Max Human Delay (ms)",delaysDesc:"Simulated human typing pause before replying to avoid robotic triggers",changePassword:"Change Dashboard Password",currentPassword:"Current Password",newPassword:"New Password",confirmPassword:"Confirm New Password",passwordMatchError:"Passwords do not match",passwordMinLength:"Password must be at least 8 characters long",passwordChangedSuccess:"Dashboard password changed successfully!",proxyTitle:"Outbound WhatsApp Proxy",proxyDesc:"Route Baileys WhatsApp traffic through an HTTP or SOCKS5 proxy to bypass restrictions",proxyEnabled:"Enable Outbound Proxy for WhatsApp",proxyProtocol:"Proxy Protocol",proxyHost:"Proxy Host / IP",proxyPort:"Proxy Port",proxyUsername:"Username (Optional)",proxyPassword:"Password (Optional)",proxyApplyHint:"⚠️ Note: To apply proxy changes, go to Connection and reconnect WhatsApp.",storageTitle:"Data Retention & Storage Limits",storageDesc:"Configure data cleanup thresholds, forward score retention, and fetch limits",forwardTtl:"Forward Score Expiry (Days)",forwardTtlDesc:"Automatically purge forwarded message scores after this many days",maxFetchBytes:"Web Fetch Byte Limit",maxFetchBytesDesc:"Maximum response body size AI tools are allowed to fetch from web pages (default: 512KB)",ffmpegPath:"Custom FFmpeg Binary Path (Optional)",weatherApiKey:"OpenWeatherMap API Key (Optional)",chooseLanguage:"Choose Language",langCardTitle:"Interface Language: English (LTR)",langCardDesc:"Full bidirectional layout support with optimized Arabic RTL & English LTR",langSwitchBtn:"التبديل إلى العربية",langName:"English",interfaceLanguage:"Dashboard Interface Language",interfaceLanguageDesc:"Instantly toggle between Arabic (RTL) and English (LTR)",botPort:"Control Panel Port",botPortHint:"* Changing port takes effect on next process restart",searchPlaceholder:"Search commands or aliases...",thCommand:"Command",thAliases:"Aliases",thDescription:"Description",thScope:"Scope",thRequiredRole:"Required Role",thStatus:"Status",thGroupName:"Group Name",thGroupJid:"Group JID",thMembers:"Members",thAntiLink:"Anti-Link",thMedia:"Media",thWelcome:"Welcome",thTarget:"Target",thMessage:"Message",thSchedule:"Schedule",thType:"Type",thDelivery:"Delivery Status",thActions:"Actions",scheduleNewMsg:"Schedule New Message",liveServerLogs:"Live Server Logs",clearLogs:"Clear Logs",allLogs:"All Levels",noLogs:"No log entries to display.",savedSuccessfully:"Settings saved successfully!",saveFailed:"Failed to save settings.",connectionStatusUpdated:"Connection status updated.",networkError:"Network error connecting to server.",loading:"Loading...",aiAssistantDesc:"Autonomous tool-calling AI agent with long-term memory",settingsSub:"Prefix, delays, integrations, & security",editAliases:"Edit Aliases",aliasesFor:"Aliases for",addAlias:"Add Alias",newAliasPlaceholder:"Type new alias...",noAliases:"No custom aliases",selectRecipient:"Select Target Chat",searchRecipients:"Search by name or phone...",recipients:"Recipients",chooseChat:"Choose a contact or group...",noRecipientsFound:"No matching chats found",pickPhoneContact:"From phone book",pickPhoneContactHint:"Pick a contact from this Android phone",maxSchedulesReached:"Maximum limit reached (3 scheduled messages)",limitReached:"Limit Reached",tabIntegrations:"Integrations",integrationsDesc:"API keys for external services connected to the bot",youtubeApiKey:"YouTube Data API Key (Optional)",selectModel:"Select a model from list...",availableModels:"Models Available from Provider",customModel:"Or type a custom model name",sessionStatus:"Session Status",sessionActive:"Session active and receiving messages",sessionOffline:"Session currently offline",connectedNumber:"Linked Phone"}},xb=K.createContext(null),Gv=({children:i})=>{const[r,u]=K.useState(()=>{const p=localStorage.getItem("levix_lang");return p==="ar"||p==="en"?p:navigator.language.startsWith("ar")?"ar":"en"}),c=r==="ar"?"rtl":"ltr";K.useEffect(()=>{localStorage.setItem("levix_lang",r),document.documentElement.lang=r,document.documentElement.dir=c},[r,c]);const d=p=>{u(p)},h=K.useMemo(()=>(p,g)=>(Gu[r]||Gu.en)[p]??Gu.en[p]??g??String(p),[r]);return o.jsx(xb.Provider,{value:{language:r,direction:c,setLanguage:d,t:h},children:i})},rn=()=>{const i=K.useContext(xb);if(!i)throw new Error("useI18n must be used within an I18nProvider");return i},Vv=({onToggleMobileMenu:i,title:r,status:u})=>{const{language:c,setLanguage:d,t:h}=rn(),[p,g]=Qi.useState(!1),b=Qi.useRef(null);Qi.useEffect(()=>{if(!p)return;const C=Z=>{b.current&&!b.current.contains(Z.target)&&g(!1)},U=Z=>{Z.key==="Escape"&&g(!1)};return document.addEventListener("mousedown",C),document.addEventListener("keydown",U),()=>{document.removeEventListener("mousedown",C),document.removeEventListener("keydown",U)}},[p]);const[E,v]=Qi.useState(()=>{const C=localStorage.getItem("levix_theme");return C?(document.documentElement.setAttribute("data-theme",C),C):document.documentElement.getAttribute("data-theme")||"dark"}),x=()=>{const C=E==="dark"?"light":"dark";v(C),document.documentElement.setAttribute("data-theme",C),localStorage.setItem("levix_theme",C)};return o.jsxs("header",{className:"h-16 sticky top-0 z-30 flex items-center justify-between px-4 md:px-6 bg-panel/85 backdrop-blur-md border-b border-line",children:[o.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[o.jsx("button",{type:"button",onClick:i,className:"inline-flex md:hidden items-center justify-center w-11 h-11 rounded-xl border border-line bg-panel-raised hover:bg-panel-hover text-text-main transition-colors focus-visible:ring-2 focus-visible:ring-brand-blue/50",id:"mobile-menu-btn","aria-label":"Open navigation menu",children:o.jsx(Ev,{size:20})}),o.jsx("h1",{className:"text-lg md:text-xl font-bold tracking-tight text-text-main truncate",title:r,children:r})]}),o.jsxs("div",{className:"flex items-center gap-2 md:gap-3",children:[o.jsxs("div",{className:"relative",ref:b,children:[o.jsx("button",{type:"button",onClick:()=>g(C=>!C),className:"inline-flex items-center justify-center w-11 h-11 rounded-xl border border-line bg-panel-raised hover:bg-panel-hover text-text-main transition-colors focus-visible:ring-2 focus-visible:ring-brand-blue/50",title:h("chooseLanguage","Choose Language"),"aria-label":h("chooseLanguage","Choose Language"),"aria-expanded":p,"aria-haspopup":"true",id:"btn-header-lang",children:o.jsx(Hr,{size:18,className:"text-brand-cyan"})}),p&&o.jsxs("div",{role:"menu","aria-orientation":"vertical","aria-labelledby":"btn-header-lang",className:"absolute end-0 mt-2 w-48 rounded-2xl border border-line bg-panel-solid shadow-2xl p-1.5 z-50 ring-1 ring-black/10 animate-in fade-in zoom-in-95 duration-150",children:[o.jsx("div",{className:"px-2.5 py-1.5 text-[11px] font-semibold text-text-muted uppercase tracking-wider",children:h("chooseLanguage","Choose Language")}),o.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{d("ar"),g(!1)},className:`w-full flex items-center justify-between px-3 py-2 text-xs md:text-sm font-medium rounded-lg transition-colors ${c==="ar"?"bg-brand-blue/15 text-brand-cyan font-bold":"text-text-main hover:bg-panel-hover"}`,children:[o.jsx("span",{children:"العربية"}),c==="ar"&&o.jsx(Lr,{size:16,className:"text-brand-cyan"})]}),o.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{d("en"),g(!1)},className:`w-full flex items-center justify-between px-3 py-2 text-xs md:text-sm font-medium rounded-lg transition-colors ${c==="en"?"bg-brand-blue/15 text-brand-cyan font-bold":"text-text-main hover:bg-panel-hover"}`,children:[o.jsx("span",{children:"English"}),c==="en"&&o.jsx(Lr,{size:16,className:"text-brand-cyan"})]})]})]}),o.jsx("button",{type:"button",onClick:x,className:"inline-flex items-center justify-center w-11 h-11 rounded-xl border border-line bg-panel-raised hover:bg-panel-hover text-text-main transition-colors focus-visible:ring-2 focus-visible:ring-brand-blue/50",title:"Toggle Theme","aria-label":"Toggle dark/light theme",children:E==="dark"?o.jsx(Uv,{size:18}):o.jsx(Mv,{size:18})}),o.jsx("form",{action:"/logout",method:"POST",className:"m-0",children:o.jsx("button",{type:"submit",className:"inline-flex items-center justify-center w-11 h-11 rounded-xl border border-line bg-panel-raised hover:bg-danger/15 hover:border-danger/40 hover:text-danger text-text-main transition-colors focus-visible:ring-2 focus-visible:ring-danger/50",title:h("logout"),"aria-label":"Sign out",children:o.jsx(Cv,{size:18,className:"rtl:-scale-x-100 transition-transform"})})})]})]})};function bb(i){var r,u,c="";if(typeof i=="string"||typeof i=="number")c+=i;else if(typeof i=="object")if(Array.isArray(i)){var d=i.length;for(r=0;r<d;r++)i[r]&&(u=bb(i[r]))&&(c&&(c+=" "),c+=u)}else for(u in i)i[u]&&(c&&(c+=" "),c+=u);return c}function Yv(){for(var i,r,u=0,c="",d=arguments.length;u<d;u++)(i=arguments[u])&&(r=bb(i))&&(c&&(c+=" "),c+=r);return c}const Qv=(i,r)=>{const u=new Array(i.length+r.length);for(let c=0;c<i.length;c++)u[c]=i[c];for(let c=0;c<r.length;c++)u[i.length+c]=r[c];return u},Xv=(i,r)=>({classGroupId:i,validator:r}),yb=(i=new Map,r=null,u)=>({nextPart:i,validators:r,classGroupId:u}),Yr="-",wg=[],Kv="arbitrary..",Zv=i=>{const r=Iv(i),{conflictingClassGroups:u,conflictingClassGroupModifiers:c}=i;return{getClassGroupId:p=>{if(p.startsWith("[")&&p.endsWith("]"))return Jv(p);const g=p.split(Yr),b=g[0]===""&&g.length>1?1:0;return vb(g,b,r)},getConflictingClassGroupIds:(p,g)=>{if(g){const b=c[p],E=u[p];return b?E?Qv(E,b):b:E||wg}return u[p]||wg}}},vb=(i,r,u)=>{if(i.length-r===0)return u.classGroupId;const d=i[r],h=u.nextPart.get(d);if(h){const E=vb(i,r+1,h);if(E)return E}const p=u.validators;if(p===null)return;const g=r===0?i.join(Yr):i.slice(r).join(Yr),b=p.length;for(let E=0;E<b;E++){const v=p[E];if(v.validator(g))return v.classGroupId}},Jv=i=>i.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const r=i.slice(1,-1),u=r.indexOf(":"),c=r.slice(0,u);return c?Kv+c:void 0})(),Iv=i=>{const{theme:r,classGroups:u}=i;return Pv(u,r)},Pv=(i,r)=>{const u=yb();for(const c in i){const d=i[c];zd(d,u,c,r)}return u},zd=(i,r,u,c)=>{const d=i.length;for(let h=0;h<d;h++){const p=i[h];Fv(p,r,u,c)}},Fv=(i,r,u,c)=>{if(typeof i=="string"){$v(i,r,u);return}if(typeof i=="function"){Wv(i,r,u,c);return}e2(i,r,u,c)},$v=(i,r,u)=>{const c=i===""?r:Nb(r,i);c.classGroupId=u},Wv=(i,r,u,c)=>{if(t2(i)){zd(i(c),r,u,c);return}r.validators===null&&(r.validators=[]),r.validators.push(Xv(u,i))},e2=(i,r,u,c)=>{const d=Object.entries(i),h=d.length;for(let p=0;p<h;p++){const[g,b]=d[p];zd(b,Nb(r,g),u,c)}},Nb=(i,r)=>{let u=i;const c=r.split(Yr),d=c.length;for(let h=0;h<d;h++){const p=c[h];let g=u.nextPart.get(p);g||(g=yb(),u.nextPart.set(p,g)),u=g}return u},t2=i=>"isThemeGetter"in i&&i.isThemeGetter===!0,n2=i=>{if(i<1)return{get:()=>{},set:()=>{}};let r=0,u=Object.create(null),c=Object.create(null);const d=(h,p)=>{u[h]=p,r++,r>i&&(r=0,c=u,u=Object.create(null))};return{get(h){let p=u[h];if(p!==void 0)return p;if((p=c[h])!==void 0)return d(h,p),p},set(h,p){h in u?u[h]=p:d(h,p)}}},Nd="!",Sg=":",l2=[],jg=(i,r,u,c,d)=>({modifiers:i,hasImportantModifier:r,baseClassName:u,maybePostfixModifierPosition:c,isExternal:d}),a2=i=>{const{prefix:r,experimentalParseClassName:u}=i;let c=d=>{const h=[];let p=0,g=0,b=0,E;const v=d.length;for(let D=0;D<v;D++){const B=d[D];if(p===0&&g===0){if(B===Sg){h.push(d.slice(b,D)),b=D+1;continue}if(B==="/"){E=D;continue}}B==="["?p++:B==="]"?p--:B==="("?g++:B===")"&&g--}const x=h.length===0?d:d.slice(b);let C=x,U=!1;x.endsWith(Nd)?(C=x.slice(0,-1),U=!0):x.startsWith(Nd)&&(C=x.slice(1),U=!0);const Z=E&&E>b?E-b:void 0;return jg(h,U,C,Z)};if(r){const d=r+Sg,h=c;c=p=>p.startsWith(d)?h(p.slice(d.length)):jg(l2,!1,p,void 0,!0)}if(u){const d=c;c=h=>u({className:h,parseClassName:d})}return c},i2=i=>{const r=new Map;return i.orderSensitiveModifiers.forEach((u,c)=>{r.set(u,1e6+c)}),u=>{const c=[];let d=[];for(let h=0;h<u.length;h++){const p=u[h],g=p[0]==="[",b=r.has(p);g||b?(d.length>0&&(d.sort(),c.push(...d),d=[]),c.push(p)):d.push(p)}return d.length>0&&(d.sort(),c.push(...d)),c}},s2=i=>({cache:n2(i.cacheSize),parseClassName:a2(i),sortModifiers:i2(i),postfixLookupClassGroupIds:r2(i),...Zv(i)}),r2=i=>{const r=Object.create(null),u=i.postfixLookupClassGroups;if(u)for(let c=0;c<u.length;c++)r[u[c]]=!0;return r},o2=/\s+/,c2=(i,r)=>{const{parseClassName:u,getClassGroupId:c,getConflictingClassGroupIds:d,sortModifiers:h,postfixLookupClassGroupIds:p}=r,g=[],b=i.trim().split(o2);let E="";for(let v=b.length-1;v>=0;v-=1){const x=b[v],{isExternal:C,modifiers:U,hasImportantModifier:Z,baseClassName:D,maybePostfixModifierPosition:B}=u(x);if(C){E=x+(E.length>0?" "+E:E);continue}let G=!!B,X;if(G){const Y=D.substring(0,B);X=c(Y);const R=X&&p[X]?c(D):void 0;R&&R!==X&&(X=R,G=!1)}else X=c(D);if(!X){if(!G){E=x+(E.length>0?" "+E:E);continue}if(X=c(D),!X){E=x+(E.length>0?" "+E:E);continue}G=!1}const le=U.length===0?"":U.length===1?U[0]:h(U).join(":"),W=Z?le+Nd:le,me=W+X;if(g.indexOf(me)>-1)continue;g.push(me);const J=d(X,G);for(let Y=0;Y<J.length;++Y){const R=J[Y];g.push(W+R)}E=x+(E.length>0?" "+E:E)}return E},u2=(...i)=>{let r=0,u,c,d="";for(;r<i.length;)(u=i[r++])&&(c=wb(u))&&(d&&(d+=" "),d+=c);return d},wb=i=>{if(typeof i=="string")return i;let r,u="";for(let c=0;c<i.length;c++)i[c]&&(r=wb(i[c]))&&(u&&(u+=" "),u+=r);return u},d2=(i,...r)=>{let u,c,d,h;const p=b=>{const E=r.reduce((v,x)=>x(v),i());return u=s2(E),c=u.cache.get,d=u.cache.set,h=g,g(b)},g=b=>{const E=c(b);if(E)return E;const v=c2(b,u);return d(b,v),v};return h=p,(...b)=>h(u2(...b))},f2=[],ct=i=>{const r=u=>u[i]||f2;return r.isThemeGetter=!0,r.themeKey=i,r},Sb=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,jb=/^\((?:(\w[\w-]*):)?(.+)\)$/i,h2=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,m2=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,p2=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,g2=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix|color|light-dark)\(.+\)$/,x2=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,b2=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,pl=i=>h2.test(i),Ce=i=>!!i&&!Number.isNaN(Number(i)),yn=i=>!!i&&Number.isInteger(Number(i)),Vu=i=>i.endsWith("%")&&Ce(i.slice(0,-1)),qn=i=>m2.test(i),_b=()=>!0,y2=i=>p2.test(i)&&!g2.test(i),Md=()=>!1,v2=i=>x2.test(i),N2=i=>b2.test(i),w2=i=>!ue(i)&&!de(i),S2=i=>i.startsWith("@container")&&(i[10]==="/"&&i[11]!==void 0||i[11]==="s"&&i[16]!==void 0&&i.startsWith("-size/",10)||i[11]==="n"&&i[18]!==void 0&&i.startsWith("-normal/",10)),j2=i=>bl(i,Cb,Md),ue=i=>Sb.test(i),Ql=i=>bl(i,Eb,y2),_g=i=>bl(i,O2,Ce),_2=i=>bl(i,Mb,_b),A2=i=>bl(i,zb,Md),Ag=i=>bl(i,Ab,Md),T2=i=>bl(i,Tb,N2),Ar=i=>bl(i,Ob,v2),de=i=>jb.test(i),Gi=i=>Kl(i,Eb),C2=i=>Kl(i,zb),Tg=i=>Kl(i,Ab),E2=i=>Kl(i,Cb),z2=i=>Kl(i,Tb),Tr=i=>Kl(i,Ob,!0),M2=i=>Kl(i,Mb,!0),bl=(i,r,u)=>{const c=Sb.exec(i);return c?c[1]?r(c[1]):u(c[2]):!1},Kl=(i,r,u=!1)=>{const c=jb.exec(i);return c?c[1]?r(c[1]):u:!1},Ab=i=>i==="position"||i==="percentage",Tb=i=>i==="image"||i==="url",Cb=i=>i==="length"||i==="size"||i==="bg-size",Eb=i=>i==="length",O2=i=>i==="number",zb=i=>i==="family-name",Mb=i=>i==="number"||i==="weight",Ob=i=>i==="shadow",k2=()=>{const i=ct("color"),r=ct("font"),u=ct("text"),c=ct("font-weight"),d=ct("tracking"),h=ct("leading"),p=ct("breakpoint"),g=ct("container"),b=ct("spacing"),E=ct("radius"),v=ct("shadow"),x=ct("inset-shadow"),C=ct("text-shadow"),U=ct("drop-shadow"),Z=ct("blur"),D=ct("perspective"),B=ct("aspect"),G=ct("ease"),X=ct("animate"),le=()=>["auto","avoid","all","avoid-page","page","left","right","column"],W=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],me=()=>[...W(),de,ue],J=()=>["auto","hidden","clip","visible","scroll"],Y=()=>["auto","contain","none"],R=()=>[de,ue,b],I=()=>[pl,"full","auto",...R()],ie=()=>[yn,"none","subgrid",de,ue],$=()=>["auto",{span:["full",yn,de,ue]},yn,de,ue],te=()=>[yn,"auto",de,ue],Q=()=>["auto","min","max","fr",de,ue],ae=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],pe=()=>["start","end","center","stretch","center-safe","end-safe"],T=()=>["auto",...R()],F=()=>[pl,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...R()],M=()=>[g,pl,"screen","full","dvw","lvw","svw","min","max","fit",...R()],se=()=>[pl,"screen","full","lh","dvh","lvh","svh","min","max","fit",...R()],V=()=>[i,de,ue],Me=()=>[...W(),Tg,Ag,{position:[de,ue]}],Ue=()=>["no-repeat",{repeat:["","x","y","space","round"]}],Ge=()=>["auto","cover","contain",E2,j2,{size:[de,ue]}],N=()=>[Vu,Gi,Ql],S=()=>["","none","full",E,de,ue],P=()=>["",Ce,Gi,Ql],ne=()=>["solid","dashed","dotted","double"],ye=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],fe=()=>[Ce,Vu,Tg,Ag],Se=()=>["","none",Z,de,ue],oe=()=>["none",Ce,de,ue],be=()=>["none",Ce,de,ue],L=()=>[Ce,de,ue],je=()=>[pl,"full",...R()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[qn],breakpoint:[qn],color:[_b],container:[qn],"drop-shadow":[qn],ease:["in","out","in-out"],font:[w2],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[qn],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[qn],shadow:[qn],spacing:["px",Ce],text:[qn],"text-shadow":[qn],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",pl,ue,de,B]}],container:["container"],"container-type":[{"@container":["","normal","size",de,ue]}],"container-named":[S2],columns:[{columns:[Ce,"auto",ue,de,g]}],"break-after":[{"break-after":le()}],"break-before":[{"break-before":le()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:me()}],overflow:[{overflow:J()}],"overflow-x":[{"overflow-x":J()}],"overflow-y":[{"overflow-y":J()}],overscroll:[{overscroll:Y()}],"overscroll-x":[{"overscroll-x":Y()}],"overscroll-y":[{"overscroll-y":Y()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:I()}],"inset-x":[{"inset-x":I()}],"inset-y":[{"inset-y":I()}],start:[{"inset-s":I(),start:I()}],end:[{"inset-e":I(),end:I()}],"inset-bs":[{"inset-bs":I()}],"inset-be":[{"inset-be":I()}],top:[{top:I()}],right:[{right:I()}],bottom:[{bottom:I()}],left:[{left:I()}],visibility:["visible","invisible","collapse"],z:[{z:[yn,"auto",de,ue]}],basis:[{basis:[pl,"full","auto",g,...R()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ce,pl,"auto","initial","none",ue]}],grow:[{grow:["",Ce,de,ue]}],shrink:[{shrink:["",Ce,de,ue]}],order:[{order:[yn,"first","last","none",de,ue]}],"grid-cols":[{"grid-cols":ie()}],"col-start-end":[{col:$()}],"col-start":[{"col-start":te()}],"col-end":[{"col-end":te()}],"grid-rows":[{"grid-rows":ie()}],"row-start-end":[{row:$()}],"row-start":[{"row-start":te()}],"row-end":[{"row-end":te()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":Q()}],"auto-rows":[{"auto-rows":Q()}],gap:[{gap:R()}],"gap-x":[{"gap-x":R()}],"gap-y":[{"gap-y":R()}],"justify-content":[{justify:[...ae(),"normal"]}],"justify-items":[{"justify-items":[...pe(),"normal"]}],"justify-self":[{"justify-self":["auto",...pe()]}],"align-content":[{content:["normal",...ae()]}],"align-items":[{items:[...pe(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...pe(),{baseline:["","last"]}]}],"place-content":[{"place-content":ae()}],"place-items":[{"place-items":[...pe(),"baseline"]}],"place-self":[{"place-self":["auto",...pe()]}],p:[{p:R()}],px:[{px:R()}],py:[{py:R()}],ps:[{ps:R()}],pe:[{pe:R()}],pbs:[{pbs:R()}],pbe:[{pbe:R()}],pt:[{pt:R()}],pr:[{pr:R()}],pb:[{pb:R()}],pl:[{pl:R()}],m:[{m:T()}],mx:[{mx:T()}],my:[{my:T()}],ms:[{ms:T()}],me:[{me:T()}],mbs:[{mbs:T()}],mbe:[{mbe:T()}],mt:[{mt:T()}],mr:[{mr:T()}],mb:[{mb:T()}],ml:[{ml:T()}],"space-x":[{"space-x":R()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":R()}],"space-y-reverse":["space-y-reverse"],size:[{size:F()}],"inline-size":[{inline:["auto",...M()]}],"min-inline-size":[{"min-inline":["auto",...M()]}],"max-inline-size":[{"max-inline":["none",...M()]}],"block-size":[{block:["auto",...se()]}],"min-block-size":[{"min-block":["auto",...se()]}],"max-block-size":[{"max-block":["none",...se()]}],w:[{w:[g,"screen",...F()]}],"min-w":[{"min-w":[g,"screen","none",...F()]}],"max-w":[{"max-w":[g,"screen","none","prose",{screen:[p]},...F()]}],h:[{h:["screen","lh",...F()]}],"min-h":[{"min-h":["screen","lh","none",...F()]}],"max-h":[{"max-h":["screen","lh","none",...F()]}],"font-size":[{text:["base",u,Gi,Ql]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[c,M2,_2]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Vu,ue]}],"font-family":[{font:[C2,A2,r]}],"font-features":[{"font-features":[ue]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[d,de,ue]}],"line-clamp":[{"line-clamp":[Ce,"none",de,_g]}],leading:[{leading:["none",h,...R()]}],"list-image":[{"list-image":["none",de,ue]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",de,ue]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:V()}],"text-color":[{text:V()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ne(),"wavy"]}],"text-decoration-thickness":[{decoration:[Ce,"from-font","auto",de,Ql]}],"text-decoration-color":[{decoration:V()}],"underline-offset":[{"underline-offset":[Ce,"auto",de,ue]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:R()}],"tab-size":[{tab:[yn,de,ue]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",de,ue]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",de,ue]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:Me()}],"bg-repeat":[{bg:Ue()}],"bg-size":[{bg:Ge()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},yn,de,ue],radial:["",de,ue],conic:["",yn,de,ue]},z2,T2]}],"bg-color":[{bg:V()}],"gradient-from-pos":[{from:N()}],"gradient-via-pos":[{via:N()}],"gradient-to-pos":[{to:N()}],"gradient-from":[{from:V()}],"gradient-via":[{via:V()}],"gradient-to":[{to:V()}],rounded:[{rounded:S()}],"rounded-s":[{"rounded-s":S()}],"rounded-e":[{"rounded-e":S()}],"rounded-t":[{"rounded-t":S()}],"rounded-r":[{"rounded-r":S()}],"rounded-b":[{"rounded-b":S()}],"rounded-l":[{"rounded-l":S()}],"rounded-ss":[{"rounded-ss":S()}],"rounded-se":[{"rounded-se":S()}],"rounded-ee":[{"rounded-ee":S()}],"rounded-es":[{"rounded-es":S()}],"rounded-tl":[{"rounded-tl":S()}],"rounded-tr":[{"rounded-tr":S()}],"rounded-br":[{"rounded-br":S()}],"rounded-bl":[{"rounded-bl":S()}],"border-w":[{border:P()}],"border-w-x":[{"border-x":P()}],"border-w-y":[{"border-y":P()}],"border-w-s":[{"border-s":P()}],"border-w-e":[{"border-e":P()}],"border-w-bs":[{"border-bs":P()}],"border-w-be":[{"border-be":P()}],"border-w-t":[{"border-t":P()}],"border-w-r":[{"border-r":P()}],"border-w-b":[{"border-b":P()}],"border-w-l":[{"border-l":P()}],"divide-x":[{"divide-x":P()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":P()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...ne(),"hidden","none"]}],"divide-style":[{divide:[...ne(),"hidden","none"]}],"border-color":[{border:V()}],"border-color-x":[{"border-x":V()}],"border-color-y":[{"border-y":V()}],"border-color-s":[{"border-s":V()}],"border-color-e":[{"border-e":V()}],"border-color-bs":[{"border-bs":V()}],"border-color-be":[{"border-be":V()}],"border-color-t":[{"border-t":V()}],"border-color-r":[{"border-r":V()}],"border-color-b":[{"border-b":V()}],"border-color-l":[{"border-l":V()}],"divide-color":[{divide:V()}],"outline-style":[{outline:[...ne(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Ce,de,ue]}],"outline-w":[{outline:["",Ce,Gi,Ql]}],"outline-color":[{outline:V()}],shadow:[{shadow:["","inner","none",v,Tr,Ar]}],"shadow-color":[{shadow:V()}],"inset-shadow":[{"inset-shadow":["none",x,Tr,Ar]}],"inset-shadow-color":[{"inset-shadow":V()}],"ring-w":[{ring:P()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:V()}],"ring-offset-w":[{"ring-offset":[Ce,Ql]}],"ring-offset-color":[{"ring-offset":V()}],"inset-ring-w":[{"inset-ring":P()}],"inset-ring-color":[{"inset-ring":V()}],"text-shadow":[{"text-shadow":["none",C,Tr,Ar]}],"text-shadow-color":[{"text-shadow":V()}],opacity:[{opacity:[Ce,de,ue]}],"mix-blend":[{"mix-blend":[...ye(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":ye()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Ce]}],"mask-image-linear-from-pos":[{"mask-linear-from":fe()}],"mask-image-linear-to-pos":[{"mask-linear-to":fe()}],"mask-image-linear-from-color":[{"mask-linear-from":V()}],"mask-image-linear-to-color":[{"mask-linear-to":V()}],"mask-image-t-from-pos":[{"mask-t-from":fe()}],"mask-image-t-to-pos":[{"mask-t-to":fe()}],"mask-image-t-from-color":[{"mask-t-from":V()}],"mask-image-t-to-color":[{"mask-t-to":V()}],"mask-image-r-from-pos":[{"mask-r-from":fe()}],"mask-image-r-to-pos":[{"mask-r-to":fe()}],"mask-image-r-from-color":[{"mask-r-from":V()}],"mask-image-r-to-color":[{"mask-r-to":V()}],"mask-image-b-from-pos":[{"mask-b-from":fe()}],"mask-image-b-to-pos":[{"mask-b-to":fe()}],"mask-image-b-from-color":[{"mask-b-from":V()}],"mask-image-b-to-color":[{"mask-b-to":V()}],"mask-image-l-from-pos":[{"mask-l-from":fe()}],"mask-image-l-to-pos":[{"mask-l-to":fe()}],"mask-image-l-from-color":[{"mask-l-from":V()}],"mask-image-l-to-color":[{"mask-l-to":V()}],"mask-image-x-from-pos":[{"mask-x-from":fe()}],"mask-image-x-to-pos":[{"mask-x-to":fe()}],"mask-image-x-from-color":[{"mask-x-from":V()}],"mask-image-x-to-color":[{"mask-x-to":V()}],"mask-image-y-from-pos":[{"mask-y-from":fe()}],"mask-image-y-to-pos":[{"mask-y-to":fe()}],"mask-image-y-from-color":[{"mask-y-from":V()}],"mask-image-y-to-color":[{"mask-y-to":V()}],"mask-image-radial":[{"mask-radial":[de,ue]}],"mask-image-radial-from-pos":[{"mask-radial-from":fe()}],"mask-image-radial-to-pos":[{"mask-radial-to":fe()}],"mask-image-radial-from-color":[{"mask-radial-from":V()}],"mask-image-radial-to-color":[{"mask-radial-to":V()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":W()}],"mask-image-conic-pos":[{"mask-conic":[Ce]}],"mask-image-conic-from-pos":[{"mask-conic-from":fe()}],"mask-image-conic-to-pos":[{"mask-conic-to":fe()}],"mask-image-conic-from-color":[{"mask-conic-from":V()}],"mask-image-conic-to-color":[{"mask-conic-to":V()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:Me()}],"mask-repeat":[{mask:Ue()}],"mask-size":[{mask:Ge()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",de,ue]}],filter:[{filter:["","none",de,ue]}],blur:[{blur:Se()}],brightness:[{brightness:[Ce,de,ue]}],contrast:[{contrast:[Ce,de,ue]}],"drop-shadow":[{"drop-shadow":["","none",U,Tr,Ar]}],"drop-shadow-color":[{"drop-shadow":V()}],grayscale:[{grayscale:["",Ce,de,ue]}],"hue-rotate":[{"hue-rotate":[Ce,de,ue]}],invert:[{invert:["",Ce,de,ue]}],saturate:[{saturate:[Ce,de,ue]}],sepia:[{sepia:["",Ce,de,ue]}],"backdrop-filter":[{"backdrop-filter":["","none",de,ue]}],"backdrop-blur":[{"backdrop-blur":Se()}],"backdrop-brightness":[{"backdrop-brightness":[Ce,de,ue]}],"backdrop-contrast":[{"backdrop-contrast":[Ce,de,ue]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ce,de,ue]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ce,de,ue]}],"backdrop-invert":[{"backdrop-invert":["",Ce,de,ue]}],"backdrop-opacity":[{"backdrop-opacity":[Ce,de,ue]}],"backdrop-saturate":[{"backdrop-saturate":[Ce,de,ue]}],"backdrop-sepia":[{"backdrop-sepia":["",Ce,de,ue]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":R()}],"border-spacing-x":[{"border-spacing-x":R()}],"border-spacing-y":[{"border-spacing-y":R()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",de,ue]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ce,"initial",de,ue]}],ease:[{ease:["linear","initial",G,de,ue]}],delay:[{delay:[Ce,de,ue]}],animate:[{animate:["none",X,de,ue]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[D,de,ue]}],"perspective-origin":[{"perspective-origin":me()}],rotate:[{rotate:oe()}],"rotate-x":[{"rotate-x":oe()}],"rotate-y":[{"rotate-y":oe()}],"rotate-z":[{"rotate-z":oe()}],scale:[{scale:be()}],"scale-x":[{"scale-x":be()}],"scale-y":[{"scale-y":be()}],"scale-z":[{"scale-z":be()}],"scale-3d":["scale-3d"],skew:[{skew:L()}],"skew-x":[{"skew-x":L()}],"skew-y":[{"skew-y":L()}],transform:[{transform:[de,ue,"","none","gpu","cpu"]}],"transform-origin":[{origin:me()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:je()}],"translate-x":[{"translate-x":je()}],"translate-y":[{"translate-y":je()}],"translate-z":[{"translate-z":je()}],"translate-none":["translate-none"],zoom:[{zoom:[yn,de,ue]}],accent:[{accent:V()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:V()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",de,ue]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":V()}],"scrollbar-track-color":[{"scrollbar-track":V()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":R()}],"scroll-mx":[{"scroll-mx":R()}],"scroll-my":[{"scroll-my":R()}],"scroll-ms":[{"scroll-ms":R()}],"scroll-me":[{"scroll-me":R()}],"scroll-mbs":[{"scroll-mbs":R()}],"scroll-mbe":[{"scroll-mbe":R()}],"scroll-mt":[{"scroll-mt":R()}],"scroll-mr":[{"scroll-mr":R()}],"scroll-mb":[{"scroll-mb":R()}],"scroll-ml":[{"scroll-ml":R()}],"scroll-p":[{"scroll-p":R()}],"scroll-px":[{"scroll-px":R()}],"scroll-py":[{"scroll-py":R()}],"scroll-ps":[{"scroll-ps":R()}],"scroll-pe":[{"scroll-pe":R()}],"scroll-pbs":[{"scroll-pbs":R()}],"scroll-pbe":[{"scroll-pbe":R()}],"scroll-pt":[{"scroll-pt":R()}],"scroll-pr":[{"scroll-pr":R()}],"scroll-pb":[{"scroll-pb":R()}],"scroll-pl":[{"scroll-pl":R()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",de,ue]}],fill:[{fill:["none",...V()]}],"stroke-w":[{stroke:[Ce,Gi,Ql,_g]}],stroke:[{stroke:["none",...V()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["start","end","right","left"],"inset-y":["inset-bs","inset-be","top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["ps","pe","pr","pl"],py:["pbs","pbe","pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["ms","me","mr","ml"],my:["mbs","mbe","mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-s","border-w-e","border-w-r","border-w-l"],"border-w-y":["border-w-bs","border-w-be","border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-s","border-color-e","border-color-r","border-color-l"],"border-color-y":["border-color-bs","border-color-be","border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-ms","scroll-me","scroll-mr","scroll-ml"],"scroll-my":["scroll-mbs","scroll-mbe","scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-ps","scroll-pe","scroll-pr","scroll-pl"],"scroll-py":["scroll-pbs","scroll-pbe","scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},R2=d2(k2);function Nn(...i){return R2(Yv(i))}const D2=({currentView:i,onSelectView:r,isOpenMobile:u,onCloseMobile:c})=>{const{t:d}=rn(),h=window.__BRAND__||{name:"Levix",tagline:"Private control room",version:"",developer:"Abdelrhman Diab",studio:"Leviro",developerSite:"https://github.com/Abdodiab2005",studioSite:"https://leviro.net"},p=[{id:"overview",label:d("overview"),icon:Av},{id:"connection",label:d("connection"),icon:Ki},{labelCategory:d("control")},{id:"commands",label:d("commands"),icon:Va},{id:"ai",label:d("ai"),icon:Ed},{id:"groups",label:d("groups"),icon:Ga},{id:"schedules",label:d("schedules"),icon:bd},{labelCategory:d("settings")},{id:"settings",label:d("settings"),icon:Dv},{id:"logs",label:d("logs"),icon:Mr}];return o.jsxs(o.Fragment,{children:[u&&o.jsx("button",{type:"button",className:"fixed inset-0 bg-black/60 backdrop-blur-sm z-40 md:hidden border-0 p-0 cursor-default",onClick:c,"aria-label":"Close mobile sidebar backdrop"}),o.jsxs("aside",{className:Nn("fixed top-0 bottom-0 start-0 z-50 w-72 md:w-64 md:static md:z-auto bg-panel border-e border-line flex flex-col transition-transform duration-200 ease-out",u?"translate-x-0":"max-md:-translate-x-full rtl:max-md:translate-x-full"),"aria-label":"Main Navigation",children:[o.jsxs("div",{className:"p-4 flex items-center justify-between border-b border-line",children:[o.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[o.jsx("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-br from-brand-blue via-brand-blue to-brand-cyan flex items-center justify-center shadow-md shadow-brand-blue/20 shrink-0 text-white",children:o.jsx(Hv,{size:20})}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("div",{className:"font-extrabold text-base text-text-main leading-tight tracking-tight truncate",children:h.name}),o.jsx("div",{className:"text-xs text-muted leading-none truncate mt-0.5",children:h.tagline})]})]}),o.jsx("button",{type:"button",onClick:c,className:"inline-flex md:hidden items-center justify-center w-10 h-10 rounded-xl border border-line bg-panel-raised hover:bg-panel-hover text-text-main transition-colors shrink-0","aria-label":"Close menu",children:o.jsx(Ji,{size:18})})]}),o.jsx("nav",{className:"flex-1 overflow-y-auto p-3 space-y-1",children:p.map(g=>{if(g.labelCategory)return o.jsx("div",{className:"px-3 pt-3 pb-1 text-[11px] font-bold uppercase tracking-wider text-faint",children:g.labelCategory},`cat-${g.labelCategory}`);if(!g.icon)return null;const b=g.icon,E=i===g.id;return o.jsxs("button",{type:"button",onClick:()=>{g.id&&(r(g.id),c())},className:Nn("w-full flex items-center gap-3 px-3.5 py-2.5 rounded-xl font-medium text-sm transition-all focus-visible:ring-2 focus-visible:ring-brand-blue/50 text-start min-h-[44px]",E?"bg-brand-blue text-white shadow-md shadow-brand-blue/25 font-bold":"text-muted hover:bg-panel-hover hover:text-text-main"),children:[o.jsx(b,{size:20,className:"shrink-0"}),o.jsx("span",{className:"truncate",children:g.label})]},g.id)})}),o.jsxs("div",{className:"p-4 border-t border-line text-xs text-faint flex flex-col gap-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between text-[11px] text-muted",children:[o.jsx("span",{className:"font-mono",children:h.version?`v${h.version}`:""}),o.jsxs("span",{className:"flex items-center gap-1.5",children:[o.jsx(Wx,{size:14,className:"text-brand-cyan"})," Local-first"]})]}),o.jsxs("div",{className:"text-[11px] text-muted truncate",children:["© ",h.copyrightYear||2026," ",o.jsx("a",{href:h.developerSite||"#",target:"_blank",rel:"noopener noreferrer",className:"text-brand-cyan hover:underline",children:h.developer})," ","(",o.jsx("a",{href:h.studioSite||"#",target:"_blank",rel:"noopener noreferrer",className:"text-brand-cyan hover:underline",children:h.studio}),")"]})]})]})]})},kb=K.createContext(null),B2=({children:i})=>{const[r,u]=K.useState([]),c=K.useCallback(h=>{u(p=>p.filter(g=>g.id!==h))},[]),d=K.useCallback((h,p="info",g=4e3)=>{const b=Math.random().toString(36).slice(2,9);u(E=>[...E,{id:b,message:h,type:p,duration:g}]),setTimeout(()=>c(b),g)},[c]);return o.jsxs(kb.Provider,{value:{toast:d},children:[i,o.jsx("div",{className:"fixed bottom-5 end-5 z-50 flex flex-col gap-2.5 max-w-sm w-full px-4 pointer-events-none","aria-live":"polite",children:r.map(h=>o.jsxs("div",{className:`pointer-events-auto flex items-center gap-3 px-4 py-3 rounded-xl border bg-panel-raised/95 backdrop-blur-md shadow-xl text-xs md:text-sm text-text-main transition-all ${h.type==="success"?"border-ok/35":h.type==="error"?"border-danger/35":h.type==="warning"?"border-warn/35":"border-line"}`,children:[h.type==="success"&&o.jsx(Qr,{size:18,className:"text-ok shrink-0"}),h.type==="error"&&o.jsx(yv,{size:18,className:"text-danger shrink-0"}),h.type==="warning"&&o.jsx(Or,{size:18,className:"text-warn shrink-0"}),h.type==="info"&&o.jsx(_v,{size:18,className:"text-info shrink-0"}),o.jsx("span",{className:"flex-1 font-medium",children:h.message}),o.jsx("button",{type:"button",onClick:()=>c(h.id),className:"inline-flex items-center justify-center w-6 h-6 rounded-lg text-muted hover:text-text-main hover:bg-panel-hover transition-colors shrink-0","aria-label":"Dismiss notification",children:o.jsx(Ji,{size:14})})]},h.id))})]})},yl=()=>{const i=K.useContext(kb);if(!i)throw new Error("useToast must be used within a ToastProvider");return i},Sn=Object.create(null);Sn.open="0";Sn.close="1";Sn.ping="2";Sn.pong="3";Sn.message="4";Sn.upgrade="5";Sn.noop="6";const kr=Object.create(null);Object.keys(Sn).forEach(i=>{kr[Sn[i]]=i});const wd={type:"error",data:"parser error"},Rb=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Db=typeof ArrayBuffer=="function",Bb=i=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(i):i&&i.buffer instanceof ArrayBuffer,Od=({type:i,data:r},u,c)=>Rb&&r instanceof Blob?u?c(r):Cg(r,c):Db&&(r instanceof ArrayBuffer||Bb(r))?u?c(r):Cg(new Blob([r]),c):c(Sn[i]+(r||"")),Cg=(i,r)=>{const u=new FileReader;return u.onload=function(){const c=u.result.split(",")[1];r("b"+(c||""))},u.readAsDataURL(i)};function Eg(i){return i instanceof Uint8Array?i:i instanceof ArrayBuffer?new Uint8Array(i):new Uint8Array(i.buffer,i.byteOffset,i.byteLength)}let Yu;function U2(i,r){if(Rb&&i.data instanceof Blob)return i.data.arrayBuffer().then(Eg).then(r);if(Db&&(i.data instanceof ArrayBuffer||Bb(i.data)))return r(Eg(i.data));Od(i,!1,u=>{Yu||(Yu=new TextEncoder),r(Yu.encode(u))})}const zg="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Xi=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let i=0;i<zg.length;i++)Xi[zg.charCodeAt(i)]=i;const L2=i=>{let r=i.length*.75,u=i.length,c,d=0,h,p,g,b;i[i.length-1]==="="&&(r--,i[i.length-2]==="="&&r--);const E=new ArrayBuffer(r),v=new Uint8Array(E);for(c=0;c<u;c+=4)h=Xi[i.charCodeAt(c)],p=Xi[i.charCodeAt(c+1)],g=Xi[i.charCodeAt(c+2)],b=Xi[i.charCodeAt(c+3)],v[d++]=h<<2|p>>4,v[d++]=(p&15)<<4|g>>2,v[d++]=(g&3)<<6|b&63;return E},q2=typeof ArrayBuffer=="function",kd=(i,r)=>{if(typeof i!="string")return{type:"message",data:Ub(i,r)};const u=i.charAt(0);return u==="b"?{type:"message",data:H2(i.substring(1),r)}:kr[u]?i.length>1?{type:kr[u],data:i.substring(1)}:{type:kr[u]}:wd},H2=(i,r)=>{if(q2){const u=L2(i);return Ub(u,r)}else return{base64:!0,data:i}},Ub=(i,r)=>{switch(r){case"blob":return i instanceof Blob?i:new Blob([i]);case"arraybuffer":default:return i instanceof ArrayBuffer?i:i.buffer}},Lb="",G2=(i,r)=>{const u=i.length,c=new Array(u);let d=0;i.forEach((h,p)=>{Od(h,!1,g=>{c[p]=g,++d===u&&r(c.join(Lb))})})},V2=(i,r)=>{const u=i.split(Lb),c=[];for(let d=0;d<u.length;d++){const h=kd(u[d],r);if(c.push(h),h.type==="error")break}return c};function Y2(){return new TransformStream({transform(i,r){U2(i,u=>{const c=u.length;let d;if(c<126)d=new Uint8Array(1),new DataView(d.buffer).setUint8(0,c);else if(c<65536){d=new Uint8Array(3);const h=new DataView(d.buffer);h.setUint8(0,126),h.setUint16(1,c)}else{d=new Uint8Array(9);const h=new DataView(d.buffer);h.setUint8(0,127),h.setBigUint64(1,BigInt(c))}i.data&&typeof i.data!="string"&&(d[0]|=128),r.enqueue(d),r.enqueue(u)})}})}let Qu;function Cr(i){return i.reduce((r,u)=>r+u.length,0)}function Er(i,r){if(i[0].length===r)return i.shift();const u=new Uint8Array(r);let c=0;for(let d=0;d<r;d++)u[d]=i[0][c++],c===i[0].length&&(i.shift(),c=0);return i.length&&c<i[0].length&&(i[0]=i[0].slice(c)),u}function Q2(i,r){Qu||(Qu=new TextDecoder);const u=[];let c=0,d=-1,h=!1;return new TransformStream({transform(p,g){for(u.push(p);;){if(c===0){if(Cr(u)<1)break;const b=Er(u,1);h=(b[0]&128)===128,d=b[0]&127,d<126?c=3:d===126?c=1:c=2}else if(c===1){if(Cr(u)<2)break;const b=Er(u,2);d=new DataView(b.buffer,b.byteOffset,b.length).getUint16(0),c=3}else if(c===2){if(Cr(u)<8)break;const b=Er(u,8),E=new DataView(b.buffer,b.byteOffset,b.length),v=E.getUint32(0);if(v>Math.pow(2,21)-1){g.enqueue(wd);break}d=v*Math.pow(2,32)+E.getUint32(4),c=3}else{if(Cr(u)<d)break;const b=Er(u,d);g.enqueue(kd(h?b:Qu.decode(b),r)),c=0}if(d===0||d>i){g.enqueue(wd);break}}}})}const qb=4;function rt(i){if(i)return X2(i)}function X2(i){for(var r in rt.prototype)i[r]=rt.prototype[r];return i}rt.prototype.on=rt.prototype.addEventListener=function(i,r){return this._callbacks=this._callbacks||{},(this._callbacks["$"+i]=this._callbacks["$"+i]||[]).push(r),this};rt.prototype.once=function(i,r){function u(){this.off(i,u),r.apply(this,arguments)}return u.fn=r,this.on(i,u),this};rt.prototype.off=rt.prototype.removeListener=rt.prototype.removeAllListeners=rt.prototype.removeEventListener=function(i,r){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var u=this._callbacks["$"+i];if(!u)return this;if(arguments.length==1)return delete this._callbacks["$"+i],this;for(var c,d=0;d<u.length;d++)if(c=u[d],c===r||c.fn===r){u.splice(d,1);break}return u.length===0&&delete this._callbacks["$"+i],this};rt.prototype.emit=function(i){this._callbacks=this._callbacks||{};for(var r=new Array(arguments.length-1),u=this._callbacks["$"+i],c=1;c<arguments.length;c++)r[c-1]=arguments[c];if(u){u=u.slice(0);for(var c=0,d=u.length;c<d;++c)u[c].apply(this,r)}return this};rt.prototype.emitReserved=rt.prototype.emit;rt.prototype.listeners=function(i){return this._callbacks=this._callbacks||{},this._callbacks["$"+i]||[]};rt.prototype.hasListeners=function(i){return!!this.listeners(i).length};const Xr=typeof Promise=="function"&&typeof Promise.resolve=="function"?r=>Promise.resolve().then(r):(r,u)=>u(r,0),$t=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),K2="arraybuffer";function Hb(i,...r){return r.reduce((u,c)=>(i.hasOwnProperty(c)&&(u[c]=i[c]),u),{})}const Z2=$t.setTimeout,J2=$t.clearTimeout;function Kr(i,r){r.useNativeTimers?(i.setTimeoutFn=Z2.bind($t),i.clearTimeoutFn=J2.bind($t)):(i.setTimeoutFn=$t.setTimeout.bind($t),i.clearTimeoutFn=$t.clearTimeout.bind($t))}const I2=1.33;function P2(i){return typeof i=="string"?F2(i):Math.ceil((i.byteLength||i.size)*I2)}function F2(i){let r=0,u=0;for(let c=0,d=i.length;c<d;c++)r=i.charCodeAt(c),r<128?u+=1:r<2048?u+=2:r<55296||r>=57344?u+=3:(c++,u+=4);return u}function Gb(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function $2(i){let r="";for(let u in i)i.hasOwnProperty(u)&&(r.length&&(r+="&"),r+=encodeURIComponent(u)+"="+encodeURIComponent(i[u]));return r}function W2(i){let r={},u=i.split("&");for(let c=0,d=u.length;c<d;c++){let h=u[c].split("=");r[decodeURIComponent(h[0])]=decodeURIComponent(h[1])}return r}class eN extends Error{constructor(r,u,c){super(r),this.description=u,this.context=c,this.type="TransportError"}}class Rd extends rt{constructor(r){super(),this.writable=!1,Kr(this,r),this.opts=r,this.query=r.query,this.socket=r.socket,this.supportsBinary=!r.forceBase64}onError(r,u,c){return super.emitReserved("error",new eN(r,u,c)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(r){this.readyState==="open"&&this.write(r)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(r){const u=kd(r,this.socket.binaryType);this.onPacket(u)}onPacket(r){super.emitReserved("packet",r)}onClose(r){this.readyState="closed",super.emitReserved("close",r)}pause(r){}createUri(r,u={}){return r+"://"+this._hostname()+this._port()+this.opts.path+this._query(u)}_hostname(){const r=this.opts.hostname;return r.indexOf(":")===-1?r:"["+r+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(r){const u=$2(r);return u.length?"?"+u:""}}class tN extends Rd{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(r){this.readyState="pausing";const u=()=>{this.readyState="paused",r()};if(this._polling||!this.writable){let c=0;this._polling&&(c++,this.once("pollComplete",function(){--c||u()})),this.writable||(c++,this.once("drain",function(){--c||u()}))}else u()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(r){const u=c=>{if(this.readyState==="opening"&&c.type==="open"&&this.onOpen(),c.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(c)};V2(r,this.socket.binaryType).forEach(u),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const r=()=>{this.write([{type:"close"}])};this.readyState==="open"?r():this.once("open",r)}write(r){this.writable=!1,G2(r,u=>{this.doWrite(u,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const r=this.opts.secure?"https":"http",u=this.query||{};return this.opts.timestampRequests!==!1&&(u[this.opts.timestampParam]=Gb()),!this.supportsBinary&&!u.sid&&(u.b64=1),this.createUri(r,u)}}let Vb=!1;try{Vb=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const nN=Vb;function lN(){}class aN extends tN{constructor(r){if(super(r),typeof location<"u"){const u=location.protocol==="https:";let c=location.port;c||(c=u?"443":"80"),this.xd=typeof location<"u"&&r.hostname!==location.hostname||c!==r.port}}doWrite(r,u){const c=this.request({method:"POST",data:r});c.on("success",u),c.on("error",(d,h)=>{this.onError("xhr post error",d,h)})}doPoll(){const r=this.request();r.on("data",this.onData.bind(this)),r.on("error",(u,c)=>{this.onError("xhr poll error",u,c)}),this.pollXhr=r}}class wn extends rt{constructor(r,u,c){super(),this.createRequest=r,Kr(this,c),this._opts=c,this._method=c.method||"GET",this._uri=u,this._data=c.data!==void 0?c.data:null,this._create()}_create(){var r;const u=Hb(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");u.xdomain=!!this._opts.xd;const c=this._xhr=this.createRequest(u);try{c.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){c.setDisableHeaderCheck&&c.setDisableHeaderCheck(!0);for(let d in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(d)&&c.setRequestHeader(d,this._opts.extraHeaders[d])}}catch{}if(this._method==="POST")try{c.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{c.setRequestHeader("Accept","*/*")}catch{}(r=this._opts.cookieJar)===null||r===void 0||r.addCookies(c),"withCredentials"in c&&(c.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(c.timeout=this._opts.requestTimeout),c.onreadystatechange=()=>{var d;c.readyState===3&&((d=this._opts.cookieJar)===null||d===void 0||d.parseCookies(c.getResponseHeader("set-cookie"))),c.readyState===4&&(c.status===200||c.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof c.status=="number"?c.status:0)},0))},c.send(this._data)}catch(d){this.setTimeoutFn(()=>{this._onError(d)},0);return}typeof document<"u"&&(this._index=wn.requestsCount++,wn.requests[this._index]=this)}_onError(r){this.emitReserved("error",r,this._xhr),this._cleanup(!0)}_cleanup(r){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=lN,r)try{this._xhr.abort()}catch{}typeof document<"u"&&delete wn.requests[this._index],this._xhr=null}}_onLoad(){const r=this._xhr.responseText;r!==null&&(this.emitReserved("data",r),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}wn.requestsCount=0;wn.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",Mg);else if(typeof addEventListener=="function"){const i="onpagehide"in $t?"pagehide":"unload";addEventListener(i,Mg,!1)}}function Mg(){for(let i in wn.requests)wn.requests.hasOwnProperty(i)&&wn.requests[i].abort()}const iN=(function(){const i=Yb({xdomain:!1});return i&&i.responseType!==null})();class sN extends aN{constructor(r){super(r);const u=r&&r.forceBase64;this.supportsBinary=iN&&!u}request(r={}){return Object.assign(r,{xd:this.xd},this.opts),new wn(Yb,this.uri(),r)}}function Yb(i){const r=i.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!r||nN))return new XMLHttpRequest}catch{}if(!r)try{return new $t[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const Qb=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class rN extends Rd{get name(){return"websocket"}doOpen(){const r=this.uri(),u=this.opts.protocols,c=Qb?{}:Hb(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(c.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(r,u,c)}catch(d){return this.emitReserved("error",d)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=r=>this.onClose({description:"websocket connection closed",context:r}),this.ws.onmessage=r=>this.onData(r.data),this.ws.onerror=r=>this.onError("websocket error",r)}write(r){this.writable=!1;for(let u=0;u<r.length;u++){const c=r[u],d=u===r.length-1;Od(c,this.supportsBinary,h=>{try{this.doWrite(c,h)}catch{}d&&Xr(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const r=this.opts.secure?"wss":"ws",u=this.query||{};return this.opts.timestampRequests&&(u[this.opts.timestampParam]=Gb()),this.supportsBinary||(u.b64=1),this.createUri(r,u)}}const Xu=$t.WebSocket||$t.MozWebSocket;class oN extends rN{createSocket(r,u,c){return Qb?new Xu(r,u,c):u?new Xu(r,u):new Xu(r)}doWrite(r,u){this.ws.send(u)}}class cN extends Rd{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(r){return this.emitReserved("error",r)}this._transport.closed.then(()=>{this.onClose()}).catch(r=>{this.onError("webtransport error",r)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(r=>{const u=Q2(Number.MAX_SAFE_INTEGER,this.socket.binaryType),c=r.readable.pipeThrough(u).getReader(),d=Y2();d.readable.pipeTo(r.writable),this._writer=d.writable.getWriter();const h=()=>{c.read().then(({done:g,value:b})=>{g||(this.onPacket(b),h())}).catch(g=>{})};h();const p={type:"open"};this.query.sid&&(p.data=`{"sid":"${this.query.sid}"}`),this._writer.write(p).then(()=>this.onOpen())})})}write(r){this.writable=!1;for(let u=0;u<r.length;u++){const c=r[u],d=u===r.length-1;this._writer.write(c).then(()=>{d&&Xr(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var r;(r=this._transport)===null||r===void 0||r.close()}}const uN={websocket:oN,webtransport:cN,polling:sN},dN=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,fN=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Sd(i){if(i.length>8e3)throw"URI too long";const r=i,u=i.indexOf("["),c=i.indexOf("]");u!=-1&&c!=-1&&(i=i.substring(0,u)+i.substring(u,c).replace(/:/g,";")+i.substring(c,i.length));let d=dN.exec(i||""),h={},p=14;for(;p--;)h[fN[p]]=d[p]||"";return u!=-1&&c!=-1&&(h.source=r,h.host=h.host.substring(1,h.host.length-1).replace(/;/g,":"),h.authority=h.authority.replace("[","").replace("]","").replace(/;/g,":"),h.ipv6uri=!0),h.pathNames=hN(h,h.path),h.queryKey=mN(h,h.query),h}function hN(i,r){const u=/\/{2,9}/g,c=r.replace(u,"/").split("/");return(r.slice(0,1)=="/"||r.length===0)&&c.splice(0,1),r.slice(-1)=="/"&&c.splice(c.length-1,1),c}function mN(i,r){const u={};return r.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(c,d,h){d&&(u[d]=h)}),u}const jd=typeof addEventListener=="function"&&typeof removeEventListener=="function",Rr=[];jd&&addEventListener("offline",()=>{Rr.forEach(i=>i())},!1);class xl extends rt{constructor(r,u){if(super(),this.binaryType=K2,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,r&&typeof r=="object"&&(u=r,r=null),r){const c=Sd(r);u.hostname=c.host,u.secure=c.protocol==="https"||c.protocol==="wss",u.port=c.port,c.query&&(u.query=c.query)}else u.host&&(u.hostname=Sd(u.host).host);Kr(this,u),this.secure=u.secure!=null?u.secure:typeof location<"u"&&location.protocol==="https:",u.hostname&&!u.port&&(u.port=this.secure?"443":"80"),this.hostname=u.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=u.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},u.transports.forEach(c=>{const d=c.prototype.name;this.transports.push(d),this._transportsByName[d]=c}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},u),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=W2(this.opts.query)),jd&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},Rr.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(r){const u=Object.assign({},this.opts.query);u.EIO=qb,u.transport=r,this.id&&(u.sid=this.id);const c=Object.assign({},this.opts,{query:u,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[r]);return new this._transportsByName[r](c)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const r=this.opts.rememberUpgrade&&xl.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const u=this.createTransport(r);u.open(),this.setTransport(u)}setTransport(r){this.transport&&this.transport.removeAllListeners(),this.transport=r,r.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",u=>this._onClose("transport close",u))}onOpen(){this.readyState="open",xl.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(r){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",r),this.emitReserved("heartbeat"),r.type){case"open":this.onHandshake(JSON.parse(r.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const u=new Error("server error");u.code=r.data,this._onError(u);break;case"message":this.emitReserved("data",r.data),this.emitReserved("message",r.data);break}}onHandshake(r){this.emitReserved("handshake",r),this.id=r.sid,this.transport.query.sid=r.sid,this._pingInterval=r.pingInterval,this._pingTimeout=r.pingTimeout,this._maxPayload=r.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const r=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+r,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},r),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const r=this._getWritablePackets();this.transport.send(r),this._prevBufferLen=r.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let u=1;for(let c=0;c<this.writeBuffer.length;c++){const d=this.writeBuffer[c].data;if(d&&(u+=P2(d)),c>0&&u>this._maxPayload)return this.writeBuffer.slice(0,c);u+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const r=Date.now()>this._pingTimeoutTime;return r&&(this._pingTimeoutTime=0,Xr(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),r}write(r,u,c){return this._sendPacket("message",r,u,c),this}send(r,u,c){return this._sendPacket("message",r,u,c),this}_sendPacket(r,u,c,d){if(typeof u=="function"&&(d=u,u=void 0),typeof c=="function"&&(d=c,c=null),this.readyState==="closing"||this.readyState==="closed")return;c=c||{},c.compress=c.compress!==!1;const h={type:r,data:u,options:c};this.emitReserved("packetCreate",h),this.writeBuffer.push(h),d&&this.once("flush",d),this.flush()}close(){const r=()=>{this._onClose("forced close"),this.transport.close()},u=()=>{this.off("upgrade",u),this.off("upgradeError",u),r()},c=()=>{this.once("upgrade",u),this.once("upgradeError",u)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?c():r()}):this.upgrading?c():r()),this}_onError(r){if(xl.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",r),this._onClose("transport error",r)}_onClose(r,u){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),jd&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const c=Rr.indexOf(this._offlineEventListener);c!==-1&&Rr.splice(c,1)}this.readyState="closed",this.id=null,this.emitReserved("close",r,u),this.writeBuffer=[],this._prevBufferLen=0}}}xl.protocol=qb;class pN extends xl{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let r=0;r<this._upgrades.length;r++)this._probe(this._upgrades[r])}_probe(r){let u=this.createTransport(r),c=!1;xl.priorWebsocketSuccess=!1;const d=()=>{c||(u.send([{type:"ping",data:"probe"}]),u.once("packet",x=>{if(!c)if(x.type==="pong"&&x.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",u),!u)return;xl.priorWebsocketSuccess=u.name==="websocket",this.transport.pause(()=>{c||this.readyState!=="closed"&&(v(),this.setTransport(u),u.send([{type:"upgrade"}]),this.emitReserved("upgrade",u),u=null,this.upgrading=!1,this.flush())})}else{const C=new Error("probe error");C.transport=u.name,this.emitReserved("upgradeError",C)}}))};function h(){c||(c=!0,v(),u.close(),u=null)}const p=x=>{const C=new Error("probe error: "+x);C.transport=u.name,h(),this.emitReserved("upgradeError",C)};function g(){p("transport closed")}function b(){p("socket closed")}function E(x){u&&x.name!==u.name&&h()}const v=()=>{u.removeListener("open",d),u.removeListener("error",p),u.removeListener("close",g),this.off("close",b),this.off("upgrading",E)};u.once("open",d),u.once("error",p),u.once("close",g),this.once("close",b),this.once("upgrading",E),this._upgrades.indexOf("webtransport")!==-1&&r!=="webtransport"?this.setTimeoutFn(()=>{c||u.open()},200):u.open()}onHandshake(r){this._upgrades=this._filterUpgrades(r.upgrades),super.onHandshake(r)}_filterUpgrades(r){const u=[];for(let c=0;c<r.length;c++)~this.transports.indexOf(r[c])&&u.push(r[c]);return u}}let gN=class extends pN{constructor(r,u={}){const c=typeof r=="object",d=c?{...r}:{...u};(!d.transports||d.transports&&typeof d.transports[0]=="string")&&(d.transports=(d.transports||["polling","websocket","webtransport"]).map(h=>uN[h]).filter(h=>!!h)),super(c?d:r,d)}};function xN(i,r="",u){let c=i;u=u||typeof location<"u"&&location,i==null&&(i=u.protocol+"//"+u.host),typeof i=="string"&&(i.charAt(0)==="/"&&(i.charAt(1)==="/"?i=u.protocol+i:i=u.host+i),/^(https?|wss?):\/\//.test(i)||(typeof u<"u"?i=u.protocol+"//"+i:i="https://"+i),c=Sd(i)),c.port||(/^(http|ws)$/.test(c.protocol)?c.port="80":/^(http|ws)s$/.test(c.protocol)&&(c.port="443")),c.path=c.path||"/";const h=c.host.indexOf(":")!==-1?"["+c.host+"]":c.host;return c.id=c.protocol+"://"+h+":"+c.port+r,c.href=c.protocol+"://"+h+(u&&u.port===c.port?"":":"+c.port),c}const bN=typeof ArrayBuffer=="function",yN=i=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(i):i.buffer instanceof ArrayBuffer,Xb=Object.prototype.toString,vN=typeof Blob=="function"||typeof Blob<"u"&&Xb.call(Blob)==="[object BlobConstructor]",NN=typeof File=="function"||typeof File<"u"&&Xb.call(File)==="[object FileConstructor]";function Dd(i){return bN&&(i instanceof ArrayBuffer||yN(i))||vN&&i instanceof Blob||NN&&i instanceof File}function Dr(i,r){if(!i||typeof i!="object")return!1;if(Array.isArray(i)){for(let u=0,c=i.length;u<c;u++)if(Dr(i[u]))return!0;return!1}if(Dd(i))return!0;if(i.toJSON&&typeof i.toJSON=="function"&&arguments.length===1)return Dr(i.toJSON(),!0);for(const u in i)if(Object.prototype.hasOwnProperty.call(i,u)&&Dr(i[u]))return!0;return!1}function wN(i){const r=[],u=i.data,c=i;return c.data=Br(u,r),c.attachments=r.length,{packet:c,buffers:r}}function Br(i,r,u){if(!i)return i;if(Dd(i)){const c={_placeholder:!0,num:r.length};return r.push(i),c}else if(Array.isArray(i)){const c=new Array(i.length);for(let d=0;d<i.length;d++)c[d]=Br(i[d],r);return c}else if(typeof i=="object"&&!(i instanceof Date)){if(i.toJSON&&typeof i.toJSON=="function"&&!u)return Br(i.toJSON(),r,!0);const c={};for(const d in i)Object.prototype.hasOwnProperty.call(i,d)&&(c[d]=Br(i[d],r));return c}return i}function SN(i,r){return i.data=_d(i.data,r),delete i.attachments,i}function _d(i,r){if(!i)return i;if(i&&i._placeholder===!0){if(typeof i.num=="number"&&i.num>=0&&i.num<r.length)return r[i.num];throw new Error("illegal attachments")}else if(Array.isArray(i))for(let u=0;u<i.length;u++)i[u]=_d(i[u],r);else if(typeof i=="object")for(const u in i)Object.prototype.hasOwnProperty.call(i,u)&&(i[u]=_d(i[u],r));return i}const jN=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var Re;(function(i){i[i.CONNECT=0]="CONNECT",i[i.DISCONNECT=1]="DISCONNECT",i[i.EVENT=2]="EVENT",i[i.ACK=3]="ACK",i[i.CONNECT_ERROR=4]="CONNECT_ERROR",i[i.BINARY_EVENT=5]="BINARY_EVENT",i[i.BINARY_ACK=6]="BINARY_ACK"})(Re||(Re={}));class _N{constructor(r){this.replacer=r}encode(r){return(r.type===Re.EVENT||r.type===Re.ACK)&&Dr(r)?this.encodeAsBinary({type:r.type===Re.EVENT?Re.BINARY_EVENT:Re.BINARY_ACK,nsp:r.nsp,data:r.data,id:r.id}):[this.encodeAsString(r)]}encodeAsString(r){let u=""+r.type;return(r.type===Re.BINARY_EVENT||r.type===Re.BINARY_ACK)&&(u+=r.attachments+"-"),r.nsp&&r.nsp!=="/"&&(u+=r.nsp+","),r.id!=null&&(u+=r.id),r.data!=null&&(u+=JSON.stringify(r.data,this.replacer)),u}encodeAsBinary(r){const u=wN(r),c=this.encodeAsString(u.packet),d=u.buffers;return d.unshift(c),d}}class Bd extends rt{constructor(r){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof r=="function"?{reviver:r}:r)}add(r){let u;if(typeof r=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");u=this.decodeString(r);const c=u.type===Re.BINARY_EVENT;c||u.type===Re.BINARY_ACK?(u.type=c?Re.EVENT:Re.ACK,this.reconstructor=new AN(u)):super.emitReserved("decoded",u)}else if(Dd(r)||r.base64)if(this.reconstructor)u=this.reconstructor.takeBinaryData(r),u&&(this.reconstructor=null,super.emitReserved("decoded",u));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+r)}decodeString(r){let u=0;const c={type:Number(r.charAt(0))};if(Re[c.type]===void 0)throw new Error("unknown packet type "+c.type);if(c.type===Re.BINARY_EVENT||c.type===Re.BINARY_ACK){const h=u+1;for(;r.charAt(++u)!=="-"&&u!=r.length;);const p=r.substring(h,u);if(p!=Number(p)||r.charAt(u)!=="-")throw new Error("Illegal attachments");const g=Number(p);if(!TN(g)||g<1)throw new Error("Illegal attachments");if(g>this.opts.maxAttachments)throw new Error("too many attachments");c.attachments=g}if(r.charAt(u+1)==="/"){const h=u+1;for(;++u&&!(r.charAt(u)===","||u===r.length););c.nsp=r.substring(h,u)}else c.nsp="/";const d=r.charAt(u+1);if(d!==""&&Number(d)==d){const h=u+1;for(;++u;){const p=r.charAt(u);if(p==null||Number(p)!=p){--u;break}if(u===r.length)break}c.id=Number(r.substring(h,u+1))}if(r.charAt(++u)){const h=this.tryParse(r.substr(u));if(Bd.isPayloadValid(c.type,h))c.data=h;else throw new Error("invalid payload")}return c}tryParse(r){try{return JSON.parse(r,this.opts.reviver)}catch{return!1}}static isPayloadValid(r,u){switch(r){case Re.CONNECT:return Og(u);case Re.DISCONNECT:return u===void 0;case Re.CONNECT_ERROR:return typeof u=="string"||Og(u);case Re.EVENT:case Re.BINARY_EVENT:return Array.isArray(u)&&(typeof u[0]=="number"||typeof u[0]=="string"&&jN.indexOf(u[0])===-1);case Re.ACK:case Re.BINARY_ACK:return Array.isArray(u)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class AN{constructor(r){this.packet=r,this.buffers=[],this.reconPack=r}takeBinaryData(r){if(this.buffers.push(r),this.buffers.length===this.reconPack.attachments){const u=SN(this.reconPack,this.buffers);return this.finishedReconstruction(),u}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const TN=Number.isInteger||function(i){return typeof i=="number"&&isFinite(i)&&Math.floor(i)===i};function Og(i){return Object.prototype.toString.call(i)==="[object Object]"}const CN=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Bd,Encoder:_N,get PacketType(){return Re}},Symbol.toStringTag,{value:"Module"}));function sn(i,r,u){return i.on(r,u),function(){i.off(r,u)}}const EN=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Kb extends rt{constructor(r,u,c){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=r,this.nsp=u,c&&c.auth&&(this.auth=c.auth),this._opts=Object.assign({},c),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const r=this.io;this.subs=[sn(r,"open",this.onopen.bind(this)),sn(r,"packet",this.onpacket.bind(this)),sn(r,"error",this.onerror.bind(this)),sn(r,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...r){return r.unshift("message"),this.emit.apply(this,r),this}emit(r,...u){var c,d,h;if(EN.hasOwnProperty(r))throw new Error('"'+r.toString()+'" is a reserved event name');if(u.unshift(r),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(u),this;const p={type:Re.EVENT,data:u};if(p.options={},p.options.compress=this.flags.compress!==!1,typeof u[u.length-1]=="function"){const v=this.ids++,x=u.pop();this._registerAckCallback(v,x),p.id=v}const g=(d=(c=this.io.engine)===null||c===void 0?void 0:c.transport)===null||d===void 0?void 0:d.writable,b=this.connected&&!(!((h=this.io.engine)===null||h===void 0)&&h._hasPingExpired());return this.flags.volatile&&!g||(b?(this.notifyOutgoingListeners(p),this.packet(p)):this.sendBuffer.push(p)),this.flags={},this}_registerAckCallback(r,u){var c;const d=(c=this.flags.timeout)!==null&&c!==void 0?c:this._opts.ackTimeout;if(d===void 0){this.acks[r]=u;return}const h=this.io.setTimeoutFn(()=>{delete this.acks[r];for(let g=0;g<this.sendBuffer.length;g++)this.sendBuffer[g].id===r&&this.sendBuffer.splice(g,1);u.call(this,new Error("operation has timed out"))},d),p=(...g)=>{this.io.clearTimeoutFn(h),u.apply(this,g)};p.withError=!0,this.acks[r]=p}emitWithAck(r,...u){return new Promise((c,d)=>{const h=(p,g)=>p?d(p):c(g);h.withError=!0,u.push(h),this.emit(r,...u)})}_addToQueue(r){let u;typeof r[r.length-1]=="function"&&(u=r.pop());const c={id:this._queueSeq++,tryCount:0,pending:!1,args:r,flags:Object.assign({fromQueue:!0},this.flags)};r.push((d,...h)=>(this._queue[0],d!==null?c.tryCount>this._opts.retries&&(this._queue.shift(),u&&u(d)):(this._queue.shift(),u&&u(null,...h)),c.pending=!1,this._drainQueue())),this._queue.push(c),this._drainQueue()}_drainQueue(r=!1){if(!this.connected||this._queue.length===0)return;const u=this._queue[0];u.pending&&!r||(u.pending=!0,u.tryCount++,this.flags=u.flags,this.emit.apply(this,u.args))}packet(r){r.nsp=this.nsp,this.io._packet(r)}onopen(){typeof this.auth=="function"?this.auth(r=>{this._sendConnectPacket(r)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(r){this.packet({type:Re.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},r):r})}onerror(r){this.connected||this.emitReserved("connect_error",r)}onclose(r,u){this.connected=!1,delete this.id,this.emitReserved("disconnect",r,u),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(r=>{if(!this.sendBuffer.some(c=>String(c.id)===r)){const c=this.acks[r];delete this.acks[r],c.withError&&c.call(this,new Error("socket has been disconnected"))}})}onpacket(r){if(r.nsp===this.nsp)switch(r.type){case Re.CONNECT:r.data&&r.data.sid?this.onconnect(r.data.sid,r.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case Re.EVENT:case Re.BINARY_EVENT:this.onevent(r);break;case Re.ACK:case Re.BINARY_ACK:this.onack(r);break;case Re.DISCONNECT:this.ondisconnect();break;case Re.CONNECT_ERROR:this.destroy();const c=new Error(r.data.message);c.data=r.data.data,this.emitReserved("connect_error",c);break}}onevent(r){const u=r.data||[];r.id!=null&&u.push(this.ack(r.id)),this.connected?this.emitEvent(u):this.receiveBuffer.push(Object.freeze(u))}emitEvent(r){if(this._anyListeners&&this._anyListeners.length){const u=this._anyListeners.slice();for(const c of u)c.apply(this,r)}super.emit.apply(this,r),this._pid&&r.length&&typeof r[r.length-1]=="string"&&(this._lastOffset=r[r.length-1])}ack(r){const u=this;let c=!1;return function(...d){c||(c=!0,u.packet({type:Re.ACK,id:r,data:d}))}}onack(r){const u=this.acks[r.id];typeof u=="function"&&(delete this.acks[r.id],u.withError&&r.data.unshift(null),u.apply(this,r.data))}onconnect(r,u){this.id=r,this.recovered=u&&this._pid===u,this._pid=u,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(r=>this.emitEvent(r)),this.receiveBuffer=[],this.sendBuffer.forEach(r=>{this.notifyOutgoingListeners(r),this.packet(r)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(r=>r()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Re.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(r){return this.flags.compress=r,this}get volatile(){return this.flags.volatile=!0,this}timeout(r){return this.flags.timeout=r,this}onAny(r){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(r),this}prependAny(r){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(r),this}offAny(r){if(!this._anyListeners)return this;if(r){const u=this._anyListeners;for(let c=0;c<u.length;c++)if(r===u[c])return u.splice(c,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(r){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(r),this}prependAnyOutgoing(r){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(r),this}offAnyOutgoing(r){if(!this._anyOutgoingListeners)return this;if(r){const u=this._anyOutgoingListeners;for(let c=0;c<u.length;c++)if(r===u[c])return u.splice(c,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(r){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const u=this._anyOutgoingListeners.slice();for(const c of u)c.apply(this,r.data)}}}function Ya(i){i=i||{},this.ms=i.min||100,this.max=i.max||1e4,this.factor=i.factor||2,this.jitter=i.jitter>0&&i.jitter<=1?i.jitter:0,this.attempts=0}Ya.prototype.duration=function(){var i=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var r=Math.random(),u=Math.floor(r*this.jitter*i);i=(Math.floor(r*10)&1)==0?i-u:i+u}return Math.min(i,this.max)|0};Ya.prototype.reset=function(){this.attempts=0};Ya.prototype.setMin=function(i){this.ms=i};Ya.prototype.setMax=function(i){this.max=i};Ya.prototype.setJitter=function(i){this.jitter=i};class Ad extends rt{constructor(r,u){var c;super(),this.nsps={},this.subs=[],r&&typeof r=="object"&&(u=r,r=void 0),u=u||{},u.path=u.path||"/socket.io",this.opts=u,Kr(this,u),this.reconnection(u.reconnection!==!1),this.reconnectionAttempts(u.reconnectionAttempts||1/0),this.reconnectionDelay(u.reconnectionDelay||1e3),this.reconnectionDelayMax(u.reconnectionDelayMax||5e3),this.randomizationFactor((c=u.randomizationFactor)!==null&&c!==void 0?c:.5),this.backoff=new Ya({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(u.timeout==null?2e4:u.timeout),this._readyState="closed",this.uri=r;const d=u.parser||CN;this.encoder=new d.Encoder,this.decoder=new d.Decoder,this._autoConnect=u.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(r){return arguments.length?(this._reconnection=!!r,r||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(r){return r===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=r,this)}reconnectionDelay(r){var u;return r===void 0?this._reconnectionDelay:(this._reconnectionDelay=r,(u=this.backoff)===null||u===void 0||u.setMin(r),this)}randomizationFactor(r){var u;return r===void 0?this._randomizationFactor:(this._randomizationFactor=r,(u=this.backoff)===null||u===void 0||u.setJitter(r),this)}reconnectionDelayMax(r){var u;return r===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=r,(u=this.backoff)===null||u===void 0||u.setMax(r),this)}timeout(r){return arguments.length?(this._timeout=r,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(r){if(~this._readyState.indexOf("open"))return this;this.engine=new gN(this.uri,this.opts);const u=this.engine,c=this;this._readyState="opening",this.skipReconnect=!1;const d=sn(u,"open",function(){c.onopen(),r&&r()}),h=g=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",g),r?r(g):this.maybeReconnectOnOpen()},p=sn(u,"error",h);if(this._timeout!==!1){const g=this._timeout,b=this.setTimeoutFn(()=>{d(),h(new Error("timeout")),u.close()},g);this.opts.autoUnref&&b.unref(),this.subs.push(()=>{this.clearTimeoutFn(b)})}return this.subs.push(d),this.subs.push(p),this}connect(r){return this.open(r)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const r=this.engine;this.subs.push(sn(r,"ping",this.onping.bind(this)),sn(r,"data",this.ondata.bind(this)),sn(r,"error",this.onerror.bind(this)),sn(r,"close",this.onclose.bind(this)),sn(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(r){try{this.decoder.add(r)}catch(u){this.onclose("parse error",u)}}ondecoded(r){Xr(()=>{this.emitReserved("packet",r)},this.setTimeoutFn)}onerror(r){this.emitReserved("error",r)}socket(r,u){let c=this.nsps[r];return c?this._autoConnect&&!c.active&&c.connect():(c=new Kb(this,r,u),this.nsps[r]=c),c}_destroy(r){const u=Object.keys(this.nsps);for(const c of u)if(this.nsps[c].active)return;this._close()}_packet(r){const u=this.encoder.encode(r);for(let c=0;c<u.length;c++)this.engine.write(u[c],r.options)}cleanup(){this.subs.forEach(r=>r()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(r,u){var c;this.cleanup(),(c=this.engine)===null||c===void 0||c.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",r,u),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const r=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const u=this.backoff.duration();this._reconnecting=!0;const c=this.setTimeoutFn(()=>{r.skipReconnect||(this.emitReserved("reconnect_attempt",r.backoff.attempts),!r.skipReconnect&&r.open(d=>{d?(r._reconnecting=!1,r.reconnect(),this.emitReserved("reconnect_error",d)):r.onreconnect()}))},u);this.opts.autoUnref&&c.unref(),this.subs.push(()=>{this.clearTimeoutFn(c)})}}onreconnect(){const r=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",r)}}const Vi={};function Ur(i,r){typeof i=="object"&&(r=i,i=void 0),r=r||{};const u=xN(i,r.path||"/socket.io"),c=u.source,d=u.id,h=u.path,p=Vi[d]&&h in Vi[d].nsps,g=r.forceNew||r["force new connection"]||r.multiplex===!1||p;let b;return g?b=new Ad(c,r):(Vi[d]||(Vi[d]=new Ad(c,r)),b=Vi[d]),u.query&&!r.query&&(r.query=u.queryKey),b.socket(u.path,r)}Object.assign(Ur,{Manager:Ad,Socket:Kb,io:Ur,connect:Ur});let Ku=null;function kg(){return Ku||(Ku=Ur(window.location.origin,{path:"/socket.io",transports:["websocket","polling"],reconnectionAttempts:10,reconnectionDelay:2e3})),Ku}function zN(i){const[r,u]=K.useState(!1),[c,d]=K.useState(null);return K.useEffect(()=>{const h=kg(),p=()=>u(!0),g=()=>u(!1),b=B=>{d(G=>({...G,...B,state:(B==null?void 0:B.state)||(G==null?void 0:G.state)||"idle"})),i==null||i("session",B)},E=B=>{d(G=>({...G,state:(B==null?void 0:B.state)||(G==null?void 0:G.state)||"idle",status:(B==null?void 0:B.status)||(G==null?void 0:G.status)})),i==null||i("status_update",B)},v=B=>{d(G=>({...G,...B})),i==null||i("status",B)},x=B=>{d(G=>({...G,state:"waiting_for_qr",qr:B})),i==null||i("qr",B)},C=B=>{const G=typeof B=="object"&&B&&"code"in B?String(B.code):String(B||"");d(X=>({...X,state:"waiting_for_qr",pairingCode:G})),i==null||i("pairing_code",G)},U=()=>{d(B=>B?{...B,qr:null}:null),i==null||i("qr_cleared",{})},Z=()=>{d(B=>B?{...B,pairingCode:null}:null),i==null||i("pairing_code_cleared",{})},D=(B,...G)=>{i==null||i(B,G[0])};return h.on("connect",p),h.on("disconnect",g),h.on("session",b),h.on("status_update",E),h.on("status",v),h.on("qr",x),h.on("pairing_code",C),h.on("pairing-code",C),h.on("qr_cleared",U),h.on("pairing_code_cleared",Z),h.onAny(D),u(h.connected),()=>{h.off("connect",p),h.off("disconnect",g),h.off("session",b),h.off("status_update",E),h.off("status",v),h.off("qr",x),h.off("pairing_code",C),h.off("pairing-code",C),h.off("qr_cleared",U),h.off("pairing_code_cleared",Z),h.offAny(D)}},[i]),{isConnected:r,sessionStatus:c,socket:kg()}}const Zi=({isOpen:i,onClose:r,title:u,children:c,footer:d,maxWidth:h})=>(K.useEffect(()=>{const p=g=>{g.key==="Escape"&&r()};return i&&(document.addEventListener("keydown",p),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",p),document.body.style.overflow="auto"}},[i,r]),i?o.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 overflow-y-auto",children:[o.jsx("button",{type:"button",className:"fixed inset-0 bg-black/65 backdrop-blur-sm border-0 p-0 cursor-default",onClick:r,"aria-label":"Close modal backdrop"}),o.jsxs("div",{className:"relative w-full rounded-2xl border border-line bg-panel shadow-2xl overflow-hidden my-auto z-10 animate-in fade-in zoom-in-95 duration-150",role:"dialog","aria-modal":"true","aria-label":u,style:h?{maxWidth:h}:{maxWidth:"520px"},children:[o.jsxs("div",{className:"flex items-center justify-between p-5 border-b border-line",children:[o.jsx("h3",{className:"text-base md:text-lg font-bold text-text-main",children:u}),o.jsx("button",{type:"button",onClick:r,className:"inline-flex items-center justify-center w-8 h-8 rounded-lg border border-line bg-panel-raised hover:bg-panel-hover text-text-main transition-colors","aria-label":"Close modal",children:o.jsx(Ji,{size:18})})]}),o.jsx("div",{className:"p-5 overflow-y-auto max-h-[75vh]",children:c}),d&&o.jsx("div",{className:"flex items-center justify-end gap-3 p-4 border-t border-line bg-panel-raised/50",children:d})]})]}):null),Xl=({checked:i,onChange:r,disabled:u=!1,id:c,label:d,description:h})=>{const p=c||`toggle-${Math.random().toString(36).slice(2,8)}`;return o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[(d||h)&&o.jsxs("div",{className:"min-w-0 flex-1",children:[d&&o.jsx("label",{htmlFor:p,className:"font-semibold text-sm cursor-pointer block text-text-main",children:d}),h&&o.jsx("p",{className:"text-xs text-muted mt-0.5",children:h})]}),o.jsx("button",{type:"button",role:"switch","aria-checked":i,id:p,disabled:u,onClick:()=>r(!i),className:Nn("relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus-visible:ring-2 focus-visible:ring-brand-blue/50 disabled:opacity-50 disabled:cursor-not-allowed",i?"bg-brand-blue":"bg-panel-hover border border-line"),children:o.jsx("span",{className:Nn("pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow-md ring-0 transition duration-200 ease-in-out",i?"translate-x-5 rtl:-translate-x-5":"translate-x-0")})})]})},MN=()=>{var ye,fe,Se,oe,be;const{t:i,language:r}=rn(),{toast:u}=yl(),[c,d]=K.useState({}),[h,p]=K.useState({}),[g,b]=K.useState(!0),[E,v]=K.useState({}),[x,C]=K.useState(!1),[U,Z]=K.useState(!1),[D,B]=K.useState(!1),[G,X]=K.useState(""),[le,W]=K.useState([]),[me,J]=K.useState(null),[Y,R]=K.useState(""),I=[{id:"gemini",name:"Google Gemini",descKey:"providerGeminiDesc",provider:"gemini",defaultModel:"gemini-3.7-flash",defaultBaseUrl:"",keySetting:"gemini_api_key",modelSetting:"gemini_model",baseUrlSetting:"gemini_base_url"},{id:"groq",name:"Groq Cloud",descKey:"providerGroqDesc",provider:"openai",defaultModel:"llama-3.3-70b-versatile",defaultBaseUrl:"https://api.groq.com/openai/v1",keySetting:"openai_api_key",modelSetting:"openai_model",baseUrlSetting:"openai_base_url"},{id:"openai",name:"OpenAI",descKey:"providerOpenAIDesc",provider:"openai",defaultModel:"gpt-4o-mini",defaultBaseUrl:"https://api.openai.com/v1",keySetting:"openai_api_key",modelSetting:"openai_model",baseUrlSetting:"openai_base_url"},{id:"ollama",name:"Ollama (Local)",descKey:"providerOllamaDesc",provider:"openai",defaultModel:"llama3.2",defaultBaseUrl:"http://localhost:11434/v1",keySetting:"openai_api_key",modelSetting:"openai_model",baseUrlSetting:"openai_base_url"},{id:"anthropic",name:"Anthropic Claude",descKey:"providerAnthropicDesc",provider:"anthropic",defaultModel:"claude-sonnet-4-5",defaultBaseUrl:"https://api.anthropic.com",keySetting:"anthropic_api_key",modelSetting:"anthropic_model",baseUrlSetting:"anthropic_base_url"}],ie=async()=>{try{const L=await re.getSettings();if(L!=null&&L.settings){const je={},nt={};L.settings.forEach(Le=>{je[Le.key]=Le.value,Le.type==="secret"&&(nt[Le.key]=!!Le.configured)}),d(je),p(nt)}}catch(L){u(L.message,"error")}finally{b(!1)}};K.useEffect(()=>{ie()},[]);const $=async(L,je,nt=!1)=>{d(Le=>({...Le,[L]:je}));try{const Le=await re.updateSetting(L,je);if(nt||u(i("savedSuccessfully"),"success"),L.endsWith("_api_key")&&(d(ve=>({...ve,[L]:""})),p(ve=>({...ve,[L]:!!je}))),Le!=null&&Le.settings&&Array.isArray(Le.settings)){const ve={},Be={};Le.settings.forEach(Ze=>{Ze.type==="secret"?(Be[Ze.key]=!!Ze.configured,ve[Ze.key]=""):ve[Ze.key]=Ze.value}),d(Ze=>({...Ze,...ve})),p(Ze=>({...Ze,...Be}))}}catch(Le){u(Le.message,"error")}},te=c.ai_provider||"gemini",Q=I.find(L=>{var je,nt;return L.provider!==te?!1:!!(L.id==="gemini"||L.id==="anthropic"||L.id==="groq"&&((je=c.openai_base_url)!=null&&je.includes("groq.com"))||L.id==="ollama"&&((nt=c.openai_base_url)!=null&&nt.includes("11434"))||L.id==="openai"&&(!c.openai_base_url||c.openai_base_url.includes("api.openai.com")))})||I[0],ae=async L=>{const je={...c,ai_provider:L.provider};L.baseUrlSetting&&(je[L.baseUrlSetting]=L.defaultBaseUrl),L.defaultModel&&(je[L.modelSetting]=L.defaultModel),d(je);try{await re.updateSetting("ai_provider",L.provider),L.baseUrlSetting&&await re.updateSetting(L.baseUrlSetting,L.defaultBaseUrl),L.defaultModel&&await re.updateSetting(L.modelSetting,L.defaultModel),u(r==="ar"?`تم التبديل إلى ${L.name}`:`Switched provider to ${L.name}`,"success")}catch(nt){u(nt.message,"error")}},pe=async(L=!1)=>{C(!0);const je=String(c[Q.keySetting]||"").trim(),nt=!!h[Q.keySetting];try{const Le={provider:Q.provider,refresh:L};je&&(Le.apiKey=je),Q.baseUrlSetting&&c[Q.baseUrlSetting]&&(Le.baseUrl=c[Q.baseUrlSetting]);const ve=await re.fetchAiModels(Le);ve&&(ve.success||ve.fallback)?(v(Be=>{var Ze;return{...Be,[Q.id]:{live:!!ve.live,requiresApiKey:!!ve.requiresApiKey,fallback:!!ve.fallback,models:ve.models||[],cached:!!ve.cached,error:ve.success||(Ze=ve.error)==null?void 0:Ze.message}}}),ve.live&&ve.success?u(r==="ar"?`تم التحقق بنجاح وجلب ${ve.models.length} نموذجاً متاحاً لحسابك`:`Discovered ${ve.models.length} live models available for your account`,"success"):ve.requiresApiKey?L&&u(r==="ar"?"يرجى إدخال مفتاح API أولاً لاكتشاف النماذج المتاحة لحسابك":"Enter an API key to discover account models","info"):!ve.success&&ve.error&&u(ve.error.message||"Failed to discover models","error")):ve&&!ve.success&&ve.error&&(v(Be=>{var Ze;return{...Be,[Q.id]:{live:!1,requiresApiKey:!(nt||je),fallback:!0,models:ve.models||[],error:(Ze=ve.error)==null?void 0:Ze.message}}}),u(ve.error.message||"Failed to discover models","error"))}catch(Le){u(Le.message||"Failed to fetch models","error")}finally{C(!1)}};K.useEffect(()=>{g||pe(!1)},[Q.id,h[Q.keySetting],g]);const T=((ye=E[Q.id])==null?void 0:ye.models)||[],F=!!((fe=E[Q.id])!=null&&fe.live),M=!!(((Se=E[Q.id])==null?void 0:Se.requiresApiKey)??!h[Q.keySetting]),se=c[Q.modelSetting]||Q.defaultModel,V=T.find(L=>L.id.toLowerCase()===se.toLowerCase())||{displayName:se,provider:Q.provider,capabilities:{textInput:!0,textOutput:!0,vision:!1,audioInput:!1,stt:!1,videoInput:!1,pdfInput:!1},capabilitySource:"unknown"},Me=!!V.capabilities.vision,Ue=!!V.capabilities.stt;K.useEffect(()=>{g||(!Me&&c.ai_vision_enabled&&$("ai_vision_enabled",!1,!0),!Ue&&c.ai_stt_enabled&&$("ai_stt_enabled",!1,!0))},[se,Me,Ue,g]);const Ge=async()=>{try{const L=await re.getPersona(),je=L==null?void 0:L.persona;X(typeof je=="string"?je:(je==null?void 0:je.body)||""),B(!0)}catch(L){u(L.message,"error")}},N=async()=>{try{await re.updatePersona(G),u(r==="ar"?"تم تحديث برومبت الشخصية بنجاح!":"Persona updated successfully!","success"),B(!1)}catch(L){u(L.message,"error")}},S=async()=>{try{const L=await re.getMemoryFiles(),je=(L==null?void 0:L.files)||((L==null?void 0:L.scopes)||[]).map(nt=>nt.scope);W(je)}catch(L){u(L.message,"error")}},P=async L=>{try{const je=await re.getMemoryFile(L);R((je==null?void 0:je.content)||"")}catch(je){u(je.message,"error")}},ne=async()=>{if(me)try{await re.updateMemoryFile(me,Y),u(r==="ar"?"تم حفظ ملف الذاكرة بنجاح!":"Memory file updated!","success"),J(null)}catch(L){u(L.message,"error")}};return g?o.jsxs("div",{className:"flex items-center justify-center p-12 text-muted",children:[o.jsx("div",{className:"w-6 h-6 border-2 border-brand-cyan border-t-transparent rounded-full animate-spin mr-2"}),o.jsx("span",{className:"text-sm font-semibold",children:i("starting")})]}):o.jsxs("div",{className:"flex flex-col gap-5 sm:gap-6",children:[o.jsxs("div",{className:"rounded-2xl border border-line bg-gradient-to-br from-panel-raised via-panel to-panel p-4 sm:p-6 shadow-sm flex flex-col gap-3.5",children:[o.jsxs("div",{className:"flex items-center justify-between gap-3",children:[o.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[o.jsx("div",{className:"w-11 h-11 sm:w-12 sm:h-12 rounded-2xl bg-gradient-to-br from-brand-blue to-brand-cyan text-white flex items-center justify-center shrink-0 shadow-md shadow-brand-blue/20",children:o.jsx(Ed,{size:22,className:"sm:w-6 sm:h-6"})}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("h2",{className:"text-base sm:text-xl font-extrabold text-text-main truncate",children:i("aiTitle")}),o.jsx("p",{className:"text-xs sm:text-sm text-muted truncate",children:i("aiSubtitle")})]})]}),o.jsxs("div",{className:"shrink-0 flex items-center gap-2 bg-panel/60 border border-line/70 rounded-xl px-2.5 py-1.5 shadow-xs",children:[o.jsx("span",{className:"text-xs font-bold text-muted hidden sm:inline",children:c.ai_agent?r==="ar"?"مفعل":"Enabled":r==="ar"?"معطل":"Disabled"}),o.jsx(Xl,{checked:!!c.ai_agent,onChange:L=>$("ai_agent",L)})]})]}),o.jsx("div",{className:"flex items-center gap-2 pt-1 border-t border-line/40",children:o.jsxs("span",{className:`inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-bold border ${c.ai_agent?"bg-ok/15 text-ok border-ok/30":"bg-danger/10 text-danger border-danger/25"}`,children:[o.jsx("span",{className:"pulse-dot"}),o.jsx("span",{children:c.ai_agent?i("aiAgentEnabled"):r==="ar"?"مساعد الذكاء الاصطناعي معطل":"AI Assistant Disabled"})]})})]}),o.jsxs("div",{className:"rounded-2xl border border-line bg-panel p-4 sm:p-6 shadow-sm flex flex-col gap-5",children:[o.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3 pb-3 border-b border-line",children:[o.jsxs("div",{className:"flex items-center gap-2.5",children:[o.jsx(Ng,{size:18,className:"text-brand-cyan shrink-0"}),o.jsx("h3",{className:"text-base sm:text-lg font-bold text-text-main",children:i("aiProvider")})]}),o.jsxs("div",{className:"flex items-center gap-2 self-start sm:self-auto",children:[o.jsx("span",{className:"text-xs text-muted font-medium",children:r==="ar"?"المزود النشط:":"Active:"}),o.jsxs("span",{className:"text-xs font-bold text-brand-cyan px-2.5 py-1 rounded-lg bg-brand-cyan/10 border border-brand-cyan/25",children:[Q.name," • ",o.jsx("span",{className:"font-mono",children:se})]})]})]}),o.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-2.5 sm:gap-3",children:I.map(L=>{const je=Q.id===L.id;return o.jsxs("button",{type:"button",onClick:()=>ae(L),className:`p-3.5 rounded-xl border text-start transition-all flex flex-col justify-between gap-2.5 focus-visible:ring-2 focus-visible:ring-brand-blue/50 ${je?"bg-brand-blue/15 border-brand-blue/60 shadow-sm ring-1 ring-brand-blue/40":"bg-panel-raised border-line hover:bg-panel-hover"}`,children:[o.jsxs("div",{className:"flex items-center justify-between w-full",children:[o.jsx("span",{className:"font-bold text-xs sm:text-sm text-text-main",children:L.name}),je?o.jsx("span",{className:"w-5 h-5 rounded-full bg-brand-blue text-white flex items-center justify-center shrink-0",children:o.jsx(Lr,{size:12,strokeWidth:3})}):o.jsx("span",{className:"w-2 h-2 rounded-full bg-line"})]}),o.jsx("span",{className:"text-[10px] sm:text-[11px] font-mono text-muted truncate block",children:L.defaultModel})]},L.id)})}),M&&o.jsxs("div",{className:"p-3.5 rounded-xl bg-amber-500/10 border border-amber-500/25 flex items-start gap-3",children:[o.jsx(Or,{size:18,className:"text-amber-500 shrink-0 mt-0.5"}),o.jsxs("div",{className:"text-xs text-text-main",children:[o.jsx("p",{className:"font-bold",children:i("connectKeyFirstPrompt")}),o.jsx("p",{className:"text-muted mt-0.5",children:r==="ar"?"النماذج المعروضة أدناه هي نماذج مقترحة من الدليل المحلي وليست مؤكدة لحسابك حتى يتم ربط المفتاح.":"Models shown below are catalog recommendations and are not verified for your account until a key is configured."})]})]}),((oe=E[Q.id])==null?void 0:oe.error)&&o.jsxs("div",{className:"p-3 rounded-xl bg-danger/10 border border-danger/25 flex items-center justify-between gap-3",children:[o.jsxs("div",{className:"flex items-center gap-2 text-xs text-danger font-semibold",children:[o.jsx(qr,{size:16,className:"shrink-0"}),o.jsx("span",{children:(be=E[Q.id])==null?void 0:be.error})]}),o.jsx("button",{type:"button",onClick:()=>pe(!0),className:"text-xs font-bold underline hover:opacity-80 shrink-0",children:i("refreshModels")})]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 pt-4 border-t border-line",children:[o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{htmlFor:"input-api-key",className:"block text-xs font-bold text-muted",children:i("apiKey")}),h[Q.keySetting]&&o.jsxs("span",{className:"text-[10px] text-ok font-semibold flex items-center gap-1",children:[o.jsx(Qr,{size:11}),r==="ar"?"محفوظ":"Saved"]})]}),o.jsx("input",{id:"input-api-key",type:"password",className:"w-full h-11 px-3.5 rounded-xl border border-line bg-panel-raised text-text-main font-mono text-xs sm:text-sm focus:outline-none focus:ring-2 focus:ring-brand-blue/50",value:c[Q.keySetting]||"",onChange:L=>d({...c,[Q.keySetting]:L.target.value}),onBlur:L=>$(Q.keySetting,L.target.value),placeholder:h[Q.keySetting]?"••••••••••••":r==="ar"?"أدخل المفتاح":"Enter API key"})]}),Q.baseUrlSetting&&o.jsxs("div",{className:"space-y-1.5",children:[o.jsx("label",{htmlFor:"input-base-url",className:"block text-xs font-bold text-muted",children:i("baseUrl")}),o.jsx("input",{id:"input-base-url",type:"text",className:"w-full h-11 px-3.5 rounded-xl border border-line bg-panel-raised text-text-main font-mono text-xs sm:text-sm focus:outline-none focus:ring-2 focus:ring-brand-blue/50",value:c[Q.baseUrlSetting]||"",onChange:L=>{Q.baseUrlSetting&&d({...c,[Q.baseUrlSetting]:L.target.value})},onBlur:L=>{Q.baseUrlSetting&&$(Q.baseUrlSetting,L.target.value)},placeholder:Q.defaultBaseUrl})]}),o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("label",{htmlFor:"input-model-name",className:"block text-xs font-bold text-muted",children:i("modelName")}),F?o.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-bold bg-ok/15 text-ok border border-ok/30",children:i("sourceLive")}):o.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-bold bg-brand-cyan/15 text-brand-cyan border border-brand-cyan/30",children:i("sourceSeed")})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("button",{type:"button",onClick:()=>Z(!U),className:"text-[11px] text-brand-cyan hover:underline font-semibold",children:U?r==="ar"?"القائمة":"List":r==="ar"?"مخصص":"Custom"}),o.jsxs("button",{type:"button",onClick:()=>pe(!0),disabled:x,className:"inline-flex items-center gap-1 text-[11px] text-brand-blue hover:text-brand-blue/80 font-bold",title:i("refreshModels"),children:[o.jsx(Gr,{size:11,className:x?"animate-spin":""}),o.jsx("span",{children:i(x?"refreshing":"refreshModels")})]})]})]}),U?o.jsx("input",{id:"input-model-name",type:"text",className:"w-full h-11 px-3.5 rounded-xl border border-line bg-panel-raised text-text-main font-mono text-xs sm:text-sm focus:outline-none focus:ring-2 focus:ring-brand-blue/50",value:c[Q.modelSetting]||"",onChange:L=>d({...c,[Q.modelSetting]:L.target.value}),onBlur:L=>$(Q.modelSetting,L.target.value),placeholder:Q.defaultModel}):o.jsxs("select",{id:"input-model-name",className:"w-full h-11 px-3.5 rounded-xl border border-line bg-panel-raised text-text-main font-mono text-xs sm:text-sm font-semibold focus:outline-none focus:ring-2 focus:ring-brand-blue/50",value:se,onChange:L=>{$(Q.modelSetting,L.target.value)},children:[o.jsx("optgroup",{label:i(F?"modelsAvailableLive":"modelsRecommendedSeed"),children:T.map(L=>o.jsxs("option",{value:L.id,children:[L.displayName&&L.displayName!==L.id?`${L.displayName} (${L.id})`:L.id,L.recommended?" ★":""]},L.id))}),!T.some(L=>L.id.toLowerCase()===se.toLowerCase())&&o.jsxs("option",{value:se,children:[se," (current)"]})]})]})]}),o.jsxs("div",{className:"p-3.5 rounded-xl border border-line bg-panel-raised/60 flex flex-col gap-2.5",children:[o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs",children:[o.jsxs("span",{className:"font-bold text-text-main flex items-center gap-1.5",children:[o.jsx(Ng,{size:14,className:"text-brand-cyan shrink-0"}),r==="ar"?"القدرات:":"Capabilities:"," ",o.jsx("span",{className:"font-mono text-brand-cyan",children:V.displayName||se})]}),o.jsx("span",{className:`text-[10px] font-bold px-2 py-0.5 rounded-full border ${V.capabilitySource==="provider"?"bg-ok/15 text-ok border-ok/30":V.capabilitySource==="seed"?"bg-brand-blue/15 text-brand-blue border-brand-blue/30":"bg-muted/15 text-muted border-line"}`,children:V.capabilitySource==="provider"?i("sourceLive"):V.capabilitySource==="seed"?i("sourceSeed"):i("sourceUnknown")})]}),o.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-2 text-xs",children:[o.jsxs("div",{className:`p-2 rounded-lg border flex items-center justify-between ${Me?"bg-ok/10 border-ok/25 text-ok":"bg-panel border-line text-muted"}`,children:[o.jsxs("div",{className:"flex items-center gap-1.5 font-medium",children:[o.jsx(Ha,{size:14}),o.jsx("span",{children:i("capVision")})]}),o.jsx("span",{className:"text-[10px] font-bold",children:i(Me?"supported":"unsupported")})]}),o.jsxs("div",{className:`p-2 rounded-lg border flex items-center justify-between ${Ue?"bg-ok/10 border-ok/25 text-ok":"bg-panel border-line text-muted"}`,children:[o.jsxs("div",{className:"flex items-center gap-1.5 font-medium",children:[o.jsx(Bu,{size:14}),o.jsx("span",{children:i("capStt")})]}),o.jsx("span",{className:"text-[10px] font-bold",children:i(Ue?"supported":"unsupported")})]}),o.jsxs("div",{className:`p-2 rounded-lg border flex items-center justify-between ${V.capabilities.audioInput?"bg-ok/10 border-ok/25 text-ok":"bg-panel border-line text-muted"}`,children:[o.jsxs("div",{className:"flex items-center gap-1.5 font-medium",children:[o.jsx(qv,{size:14}),o.jsx("span",{children:i("capAudio")})]}),o.jsx("span",{className:"text-[10px] font-bold",children:V.capabilities.audioInput?i("supported"):i("unsupported")})]}),o.jsxs("div",{className:`p-2 rounded-lg border flex items-center justify-between ${V.capabilities.textInput&&V.capabilities.textOutput?"bg-ok/10 border-ok/25 text-ok":"bg-panel border-line text-muted"}`,children:[o.jsxs("div",{className:"flex items-center gap-1.5 font-medium",children:[o.jsx(Mr,{size:14}),o.jsx("span",{children:i("capText")})]}),o.jsx("span",{className:"text-[10px] font-bold",children:V.capabilities.textInput&&V.capabilities.textOutput?i("supported"):i("unsupported")})]}),o.jsxs("div",{className:`p-2 rounded-lg border flex items-center justify-between ${V.capabilities.pdfInput?"bg-ok/10 border-ok/25 text-ok":"bg-panel border-line text-muted"}`,children:[o.jsxs("div",{className:"flex items-center gap-1.5 font-medium",children:[o.jsx(Mr,{size:14}),o.jsx("span",{children:i("capPdf")})]}),o.jsx("span",{className:"text-[10px] font-bold",children:V.capabilities.pdfInput?i("supported"):i("unsupported")})]}),o.jsxs("div",{className:`p-2 rounded-lg border flex items-center justify-between ${V.capabilities.videoInput?"bg-ok/10 border-ok/25 text-ok":"bg-panel border-line text-muted"}`,children:[o.jsxs("div",{className:"flex items-center gap-1.5 font-medium",children:[o.jsx(Ha,{size:14}),o.jsx("span",{children:i("capVideo")})]}),o.jsx("span",{className:"text-[10px] font-bold",children:V.capabilities.videoInput?i("supported"):i("unsupported")})]})]})]})]}),o.jsxs("div",{className:"rounded-2xl border border-line bg-panel p-4 sm:p-6 shadow-sm flex flex-col gap-4",children:[o.jsx("h3",{className:"text-base font-bold text-text-main",children:i("capabilities")}),o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:[o.jsxs("div",{className:"relative rounded-xl border border-line bg-panel-raised p-4 flex flex-col justify-between gap-3",children:[o.jsx("div",{className:"absolute top-3.5 end-3.5",children:o.jsx(Xl,{checked:!!c.ai_vision_enabled&&Me,disabled:!Me,onChange:L=>{Me&&$("ai_vision_enabled",L)}})}),o.jsxs("div",{className:"pe-12",children:[o.jsxs("div",{className:"flex items-center gap-2 text-text-main mb-1",children:[o.jsx(Ha,{size:17,className:Me?"text-brand-cyan shrink-0":"text-muted shrink-0"}),o.jsx("span",{className:"font-bold text-sm",children:i("aiVision")})]}),o.jsx("p",{className:"text-xs text-muted leading-relaxed",children:i("aiVisionDesc")}),!Me&&o.jsxs("p",{className:"text-[11px] text-amber-500 font-semibold mt-2 flex items-center gap-1",children:[o.jsx(Or,{size:13,className:"shrink-0"}),o.jsx("span",{children:i("visionUnsupportedNotice")})]})]})]}),o.jsxs("div",{className:"relative rounded-xl border border-line bg-panel-raised p-4 flex flex-col justify-between gap-3",children:[o.jsx("div",{className:"absolute top-3.5 end-3.5",children:o.jsx(Xl,{checked:!!(c.ai_stt_enabled??!0)&&Ue,disabled:!Ue,onChange:L=>{Ue&&$("ai_stt_enabled",L)}})}),o.jsxs("div",{className:"pe-12",children:[o.jsxs("div",{className:"flex items-center gap-2 text-text-main mb-1",children:[o.jsx(Bu,{size:17,className:Ue?"text-purple-400 shrink-0":"text-muted shrink-0"}),o.jsx("span",{className:"font-bold text-sm",children:i("aiSttEnabled")})]}),o.jsx("p",{className:"text-xs text-muted leading-relaxed",children:i("aiSttEnabledDesc")}),!Ue&&o.jsxs("p",{className:"text-[11px] text-amber-500 font-semibold mt-2 flex items-center gap-1",children:[o.jsx(Or,{size:13,className:"shrink-0"}),o.jsx("span",{children:i("sttUnsupportedNotice")})]})]})]}),o.jsxs("div",{className:"rounded-xl border border-line bg-panel-raised p-4 flex flex-col justify-between gap-3",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2 text-text-main mb-1",children:[o.jsx(Bu,{size:17,className:"text-purple-400 shrink-0"}),o.jsx("span",{className:"font-bold text-sm",children:i("aiStt")})]}),o.jsx("p",{className:"text-xs text-muted leading-relaxed",children:i("sttDesc")})]}),o.jsxs("select",{className:"w-full h-10 px-3 rounded-lg border border-line bg-panel text-text-main text-xs font-semibold focus:outline-none focus:ring-2 focus:ring-brand-blue/50 disabled:opacity-50",value:c.ai_stt_provider||"auto",disabled:!Ue,onChange:L=>{Ue&&$("ai_stt_provider",L.target.value)},children:[o.jsx("option",{value:"auto",children:i("sttAuto")}),o.jsx("option",{value:"gemini",children:i("sttGemini")}),o.jsx("option",{value:"openai",children:i("sttOpenAI")})]})]}),o.jsxs("div",{className:"rounded-xl border border-line bg-panel-raised p-4 flex flex-col justify-between gap-3",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2 text-text-main mb-1",children:[o.jsx(Hr,{size:17,className:"text-ok shrink-0"}),o.jsx("span",{className:"font-bold text-sm",children:i("botLanguage")})]}),o.jsx("p",{className:"text-xs text-muted leading-relaxed",children:i("botLanguageDesc")})]}),o.jsxs("select",{className:"w-full h-10 px-3 rounded-lg border border-line bg-panel text-text-main text-xs font-semibold focus:outline-none focus:ring-2 focus:ring-brand-blue/50",value:c.bot_language||"auto",onChange:L=>$("bot_language",L.target.value),children:[o.jsx("option",{value:"auto",children:i("langAuto")}),o.jsx("option",{value:"ar",children:i("langAr")}),o.jsx("option",{value:"en",children:i("langEn")})]})]})]})]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 sm:gap-5",children:[o.jsxs("div",{className:"rounded-2xl border border-line bg-panel p-4 sm:p-6 shadow-sm flex flex-col justify-between gap-4",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2.5 text-text-main mb-2",children:[o.jsx(Mr,{size:20,className:"text-brand-blue shrink-0"}),o.jsx("h3",{className:"text-base font-bold",children:i("personaPrompt")})]}),o.jsx("p",{className:"text-xs sm:text-sm text-muted leading-relaxed",children:i("personaDesc")})]}),o.jsx("button",{type:"button",onClick:Ge,className:"w-full h-11 rounded-xl border border-line bg-panel-raised hover:bg-panel-hover text-text-main font-bold text-xs sm:text-sm transition-colors focus-visible:ring-2 focus-visible:ring-brand-blue/50 flex items-center justify-center gap-2",children:o.jsx("span",{children:i("editPersona")})})]}),o.jsxs("div",{className:"rounded-2xl border border-line bg-panel p-4 sm:p-6 shadow-sm flex flex-col justify-between gap-4",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2.5 text-text-main mb-2",children:[o.jsx(wv,{size:20,className:"text-brand-cyan shrink-0"}),o.jsx("h3",{className:"text-base font-bold",children:i("memoryFiles")})]}),o.jsx("p",{className:"text-xs sm:text-sm text-muted leading-relaxed",children:i("memoryDesc")})]}),o.jsx("button",{type:"button",onClick:()=>{S(),J("global"),P("global")},className:"w-full h-11 rounded-xl border border-line bg-panel-raised hover:bg-panel-hover text-text-main font-bold text-xs sm:text-sm transition-colors focus-visible:ring-2 focus-visible:ring-brand-blue/50 flex items-center justify-center gap-2",children:o.jsx("span",{children:i("manageMemory")})})]})]}),o.jsx(Zi,{isOpen:D,onClose:()=>B(!1),title:i("personaPrompt"),maxWidth:"750px",footer:o.jsxs("div",{className:"flex items-center justify-end gap-2.5 w-full",children:[o.jsx("button",{type:"button",onClick:()=>B(!1),className:"px-4 h-10 rounded-xl border border-line bg-panel-raised hover:bg-panel-hover text-text-main font-bold text-xs sm:text-sm transition-colors",children:i("cancel")}),o.jsxs("button",{type:"button",onClick:N,className:"px-5 h-10 rounded-xl bg-brand-blue hover:bg-brand-blue/90 text-white font-bold text-xs sm:text-sm shadow-md shadow-brand-blue/25 transition-colors flex items-center gap-2",children:[o.jsx(Vr,{size:16}),o.jsx("span",{children:i("save")})]})]}),children:o.jsx("textarea",{className:"w-full rounded-xl border border-line bg-panel-raised p-3.5 text-text-main font-mono text-xs sm:text-sm leading-relaxed focus:outline-none focus:ring-2 focus:ring-brand-blue/50",rows:12,value:G,onChange:L=>X(L.target.value)})}),o.jsx(Zi,{isOpen:!!me,onClose:()=>J(null),title:`Memory File: ${me||""}`,maxWidth:"750px",footer:o.jsxs("div",{className:"flex items-center justify-end gap-2.5 w-full",children:[o.jsx("button",{type:"button",onClick:()=>J(null),className:"px-4 h-10 rounded-xl border border-line bg-panel-raised hover:bg-panel-hover text-text-main font-bold text-xs sm:text-sm transition-colors",children:i("cancel")}),o.jsxs("button",{type:"button",onClick:ne,className:"px-5 h-10 rounded-xl bg-brand-blue hover:bg-brand-blue/90 text-white font-bold text-xs sm:text-sm shadow-md shadow-brand-blue/25 transition-colors flex items-center gap-2",children:[o.jsx(Vr,{size:16}),o.jsx("span",{children:i("save")})]})]}),children:o.jsx("textarea",{className:"w-full rounded-xl border border-line bg-panel-raised p-3.5 text-text-main font-mono text-xs sm:text-sm leading-relaxed focus:outline-none focus:ring-2 focus:ring-brand-blue/50",rows:12,value:Y,onChange:L=>R(L.target.value)})})]})},ON=()=>{const{t:i,language:r}=rn(),{toast:u}=yl(),[c,d]=K.useState([]),[h,p]=K.useState("!"),[g,b]=K.useState(!1),[E,v]=K.useState("!"),[x,C]=K.useState(""),[U,Z]=K.useState(!0),[D,B]=K.useState(null),[G,X]=K.useState([]),[le,W]=K.useState(""),[me,J]=K.useState(!1),Y=async()=>{try{const T=await re.getCommands();T!=null&&T.commands&&d(T.commands),T!=null&&T.prefix&&(p(T.prefix),v(T.prefix))}catch(T){u(T.message,"error")}finally{Z(!1)}};K.useEffect(()=>{Y()},[]);const R=async()=>{const T=E.trim();if(!T||T.length>3){u(i("prefixValidation"),"error");return}try{await re.updatePrefix(T),p(T),b(!1),u(`${i("prefixUpdated")} (${T})`,"success")}catch(F){u(F.message,"error")}},I=async(T,F)=>{d(M=>M.map(se=>se.name===T.name?{...se,enabled:F,overridden:!0}:se));try{await re.updateCommand(T.name,{enabled:F}),u(r==="ar"?`تم ${F?"تفعيل":"تعطيل"} الأمر '${T.name}'`:`Command '${T.name}' ${F?"enabled":"disabled"}`,"success")}catch(M){u(M.message,"error"),Y()}},ie=async(T,F)=>{d(M=>M.map(se=>se.name===T.name?{...se,permission:F,overridden:!0}:se));try{await re.updateCommand(T.name,{permission:F}),u(r==="ar"?`تم تحديث رتبة '${T.name}'`:`Permission for '${T.name}' updated`,"success")}catch(M){u(M.message,"error"),Y()}},$=T=>{B(T),X(Array.isArray(T.aliases)?[...T.aliases]:[]),W("")},te=()=>{const T=le.trim().replace(/^[!/#.?$]+/,"").toLowerCase();if(T){if(G.includes(T)){u(r==="ar"?"هذا الاسم المستعار مضاف بالفعل":"Alias already added","warning");return}X([...G,T]),W("")}},Q=T=>{X(G.filter(F=>F!==T))},ae=async()=>{if(D){J(!0);try{await re.updateCommand(D.name,{aliases:G}),d(T=>T.map(F=>F.name===D.name?{...F,aliases:G}:F)),u(i("savedSuccessfully"),"success"),B(null)}catch(T){u(T.message,"error")}finally{J(!1)}}},pe=c.filter(T=>T.name.toLowerCase().includes(x.toLowerCase())||T.description.toLowerCase().includes(x.toLowerCase())||T.aliases.some(F=>F.toLowerCase().includes(x.toLowerCase())));return o.jsxs("div",{className:"flex flex-col gap-5 sm:gap-6",children:[o.jsxs("div",{className:"rounded-2xl border border-line bg-panel p-4 sm:p-6 shadow-sm flex flex-col md:flex-row md:items-center justify-between gap-4",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[o.jsx("h2",{className:"text-lg md:text-xl font-bold text-text-main",children:i("commands")}),o.jsxs("div",{className:"inline-flex items-center gap-2 px-3 py-1.5 rounded-xl border border-line bg-panel-raised",children:[o.jsxs("span",{className:"text-xs text-muted font-semibold",children:[i("activePrefix"),":"]}),g?o.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[o.jsx("input",{type:"text",maxLength:3,value:E,onChange:T=>v(T.target.value),className:"w-12 h-7 px-1.5 text-center font-mono font-bold text-xs rounded-lg border border-line bg-panel text-text-main focus:outline-none focus:ring-2 focus:ring-brand-blue/50",onKeyDown:T=>{T.key==="Enter"&&R(),T.key==="Escape"&&b(!1)}}),o.jsx("button",{type:"button",onClick:R,className:"px-2 h-7 rounded-lg bg-brand-blue text-white font-bold text-xs hover:bg-brand-blue/90 transition-colors",children:i("save")}),o.jsx("button",{type:"button",onClick:()=>b(!1),className:"px-2 h-7 rounded-lg border border-line bg-panel-raised text-muted font-bold text-xs hover:bg-panel-hover transition-colors",children:i("cancel")})]}):o.jsx("button",{type:"button",onClick:()=>{v(h),b(!0)},className:"px-2.5 py-0.5 rounded-lg bg-brand-cyan/15 text-brand-cyan border border-brand-cyan/30 font-mono font-bold text-xs hover:bg-brand-cyan/25 transition-colors",title:r==="ar"?"اضغط لتعديل البادئة":"Click to change prefix",children:h})]})]}),o.jsx("p",{className:"text-xs md:text-sm text-muted mt-1",children:r==="ar"?"إدارة رتب الأوامر والأسماء المستعارة وتفعيلها أو تعطيلها مباشرة":"Manage role permissions, edit aliases, or enable/disable bot commands live"})]}),o.jsxs("div",{className:"relative w-full md:w-72 shrink-0",children:[o.jsx(Ix,{size:18,className:"absolute start-3.5 top-3 text-muted"}),o.jsx("input",{type:"text",className:"w-full h-11 ps-10 pe-3.5 rounded-xl border border-line bg-panel-raised text-text-main text-sm focus:outline-none focus:ring-2 focus:ring-brand-blue/50",placeholder:i("searchPlaceholder"),value:x,onChange:T=>C(T.target.value)})]})]}),o.jsx("div",{className:"rounded-2xl border border-line bg-panel overflow-hidden shadow-sm overflow-x-auto",children:o.jsxs("table",{className:"w-full min-w-[760px] text-start border-collapse text-sm",children:[o.jsx("thead",{children:o.jsxs("tr",{className:"bg-panel-raised border-b border-line text-xs font-bold text-muted uppercase tracking-wider",children:[o.jsx("th",{className:"px-4 py-3.5 text-start",children:i("thCommand")}),o.jsx("th",{className:"px-4 py-3.5 text-start",children:i("thAliases")}),o.jsx("th",{className:"px-4 py-3.5 text-start",children:i("thDescription")}),o.jsx("th",{className:"px-4 py-3.5 text-start",children:i("thScope")}),o.jsx("th",{className:"px-4 py-3.5 text-start",children:i("thRequiredRole")}),o.jsx("th",{className:"px-4 py-3.5 text-center",children:i("thStatus")})]})}),o.jsx("tbody",{className:"divide-y divide-line/40",children:U?o.jsx("tr",{children:o.jsx("td",{colSpan:6,className:"text-center py-12 text-muted",children:o.jsxs("div",{className:"flex flex-col items-center justify-center gap-2",children:[o.jsx("div",{className:"w-6 h-6 border-2 border-brand-cyan border-t-transparent rounded-full animate-spin"}),o.jsx("span",{className:"text-xs",children:i("loading")})]})})}):pe.map(T=>{var F;return o.jsxs("tr",{className:"hover:bg-panel-hover/50 transition-colors",children:[o.jsx("td",{className:"px-4 py-3.5 font-mono font-bold text-brand-cyan",children:o.jsxs("bdi",{children:[h,T.name]})}),o.jsx("td",{className:"px-4 py-3.5",children:o.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[(F=T.aliases)!=null&&F.length?T.aliases.map(M=>o.jsx("span",{className:"inline-flex items-center font-mono text-[11px] px-2 py-0.5 rounded-md bg-panel-raised border border-line text-muted",children:o.jsxs("bdi",{children:[h,M]})},M)):o.jsx("span",{className:"text-xs text-muted/60",children:"—"}),o.jsx("button",{type:"button",onClick:()=>$(T),className:"inline-flex items-center justify-center w-6 h-6 rounded-md bg-panel-raised hover:bg-brand-blue/15 hover:text-brand-cyan text-muted border border-line transition-colors",title:i("editAliases"),children:o.jsx(Ov,{size:12})})]})}),o.jsx("td",{className:"px-4 py-3.5 max-w-xs text-text-main text-xs md:text-sm",children:T.description}),o.jsx("td",{className:"px-4 py-3.5",children:o.jsx("span",{className:"inline-flex px-2.5 py-0.5 rounded-lg bg-brand-blue/10 text-brand-cyan text-xs font-semibold",children:T.chat==="all"?r==="ar"?"الكل":"All":T.chat==="group"?r==="ar"?"المجموعات":"Group":r==="ar"?"خاص":"Private"})}),o.jsx("td",{className:"px-4 py-3.5",children:o.jsxs("select",{className:"h-9 px-2.5 rounded-lg border border-line bg-panel-raised text-text-main text-xs font-semibold focus:outline-none focus:ring-2 focus:ring-brand-blue/50",value:T.permission,onChange:M=>ie(T,M.target.value),children:[o.jsx("option",{value:"MEMBERS",children:r==="ar"?"الجميع (الأعضاء)":"Members (Everyone)"}),o.jsx("option",{value:"ADMIN_ONLY",children:r==="ar"?"مشرفو المجموعة":"Group Admins"}),o.jsx("option",{value:"OWNER_ONLY",children:r==="ar"?"مالك البوت فقط":"Bot Owner Only"})]})}),o.jsx("td",{className:"px-4 py-3.5 text-center",children:o.jsx(Xl,{checked:T.enabled,onChange:M=>I(T,M)})})]},T.name)})})]})}),o.jsx(Zi,{isOpen:!!D,onClose:()=>B(null),title:`${i("aliasesFor")} ${h}${(D==null?void 0:D.name)||""}`,footer:o.jsxs("div",{className:"flex items-center justify-end gap-2.5 w-full",children:[o.jsx("button",{type:"button",onClick:()=>B(null),className:"px-4 h-10 rounded-xl border border-line bg-panel-raised hover:bg-panel-hover text-text-main font-bold text-xs sm:text-sm transition-colors",children:i("cancel")}),o.jsx("button",{type:"button",onClick:ae,disabled:me,className:"px-5 h-10 rounded-xl bg-brand-blue hover:bg-brand-blue/90 text-white font-bold text-xs sm:text-sm shadow-md shadow-brand-blue/25 transition-colors disabled:opacity-50",children:i(me?"saving":"save")})]}),children:o.jsxs("div",{className:"flex flex-col gap-4 py-1",children:[o.jsx("p",{className:"text-xs sm:text-sm text-muted",children:r==="ar"?"الأسماء المستعارة تتيح استدعاء هذا الأمر بأسماء بديلة (مثل: p بدلاً من ping).":"Aliases allow invoking this command using alternative names."}),o.jsxs("div",{className:"space-y-1.5",children:[o.jsx("span",{className:"text-xs font-bold text-muted block",children:i("thAliases")}),o.jsx("div",{className:"flex items-center gap-2 flex-wrap min-h-[42px] p-2 rounded-xl border border-line bg-panel-raised",children:G.length>0?G.map(T=>o.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-lg bg-panel border border-line text-xs font-mono font-bold text-text-main",children:[o.jsxs("span",{children:[h,T]}),o.jsx("button",{type:"button",onClick:()=>Q(T),className:"text-muted hover:text-danger p-0.5 rounded transition-colors",children:o.jsx(Ji,{size:13})})]},T)):o.jsx("span",{className:"text-xs text-muted/60 px-1",children:i("noAliases")})})]}),o.jsxs("div",{className:"space-y-1.5",children:[o.jsx("label",{htmlFor:"new-alias-input",className:"text-xs font-bold text-muted block",children:i("addAlias")}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("div",{className:"relative flex-1",children:[o.jsx(Lv,{size:16,className:"absolute start-3 top-3 text-muted"}),o.jsx("input",{id:"new-alias-input",type:"text",value:le,onChange:T=>W(T.target.value),onKeyDown:T=>{T.key==="Enter"&&(T.preventDefault(),te())},placeholder:i("newAliasPlaceholder"),className:"w-full h-11 ps-9 pe-3 rounded-xl border border-line bg-panel text-text-main font-mono text-sm focus:outline-none focus:ring-2 focus:ring-brand-blue/50"})]}),o.jsxs("button",{type:"button",onClick:te,className:"inline-flex items-center justify-center gap-1.5 px-4 h-11 rounded-xl bg-panel-raised hover:bg-panel-hover border border-line text-text-main font-bold text-xs sm:text-sm transition-colors shrink-0",children:[o.jsx(Vx,{size:16}),o.jsx("span",{children:i("add")})]})]})]})]})})]})};var qa={},Zu,Rg;function kN(){return Rg||(Rg=1,Zu=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),Zu}var Ju={},gl={},Dg;function Zl(){if(Dg)return gl;Dg=1;let i;const r=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return gl.getSymbolSize=function(c){if(!c)throw new Error('"version" cannot be null or undefined');if(c<1||c>40)throw new Error('"version" should be in range from 1 to 40');return c*4+17},gl.getSymbolTotalCodewords=function(c){return r[c]},gl.getBCHDigit=function(u){let c=0;for(;u!==0;)c++,u>>>=1;return c},gl.setToSJISFunction=function(c){if(typeof c!="function")throw new Error('"toSJISFunc" is not a valid function.');i=c},gl.isKanjiModeEnabled=function(){return typeof i<"u"},gl.toSJIS=function(c){return i(c)},gl}var Iu={},Bg;function Ud(){return Bg||(Bg=1,(function(i){i.L={bit:1},i.M={bit:0},i.Q={bit:3},i.H={bit:2};function r(u){if(typeof u!="string")throw new Error("Param is not a string");switch(u.toLowerCase()){case"l":case"low":return i.L;case"m":case"medium":return i.M;case"q":case"quartile":return i.Q;case"h":case"high":return i.H;default:throw new Error("Unknown EC Level: "+u)}}i.isValid=function(c){return c&&typeof c.bit<"u"&&c.bit>=0&&c.bit<4},i.from=function(c,d){if(i.isValid(c))return c;try{return r(c)}catch{return d}}})(Iu)),Iu}var Pu,Ug;function RN(){if(Ug)return Pu;Ug=1;function i(){this.buffer=[],this.length=0}return i.prototype={get:function(r){const u=Math.floor(r/8);return(this.buffer[u]>>>7-r%8&1)===1},put:function(r,u){for(let c=0;c<u;c++)this.putBit((r>>>u-c-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(r){const u=Math.floor(this.length/8);this.buffer.length<=u&&this.buffer.push(0),r&&(this.buffer[u]|=128>>>this.length%8),this.length++}},Pu=i,Pu}var Fu,Lg;function DN(){if(Lg)return Fu;Lg=1;function i(r){if(!r||r<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=r,this.data=new Uint8Array(r*r),this.reservedBit=new Uint8Array(r*r)}return i.prototype.set=function(r,u,c,d){const h=r*this.size+u;this.data[h]=c,d&&(this.reservedBit[h]=!0)},i.prototype.get=function(r,u){return this.data[r*this.size+u]},i.prototype.xor=function(r,u,c){this.data[r*this.size+u]^=c},i.prototype.isReserved=function(r,u){return this.reservedBit[r*this.size+u]},Fu=i,Fu}var $u={},qg;function BN(){return qg||(qg=1,(function(i){const r=Zl().getSymbolSize;i.getRowColCoords=function(c){if(c===1)return[];const d=Math.floor(c/7)+2,h=r(c),p=h===145?26:Math.ceil((h-13)/(2*d-2))*2,g=[h-7];for(let b=1;b<d-1;b++)g[b]=g[b-1]-p;return g.push(6),g.reverse()},i.getPositions=function(c){const d=[],h=i.getRowColCoords(c),p=h.length;for(let g=0;g<p;g++)for(let b=0;b<p;b++)g===0&&b===0||g===0&&b===p-1||g===p-1&&b===0||d.push([h[g],h[b]]);return d}})($u)),$u}var Wu={},Hg;function UN(){if(Hg)return Wu;Hg=1;const i=Zl().getSymbolSize,r=7;return Wu.getPositions=function(c){const d=i(c);return[[0,0],[d-r,0],[0,d-r]]},Wu}var ed={},Gg;function LN(){return Gg||(Gg=1,(function(i){i.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const r={N1:3,N2:3,N3:40,N4:10};i.isValid=function(d){return d!=null&&d!==""&&!isNaN(d)&&d>=0&&d<=7},i.from=function(d){return i.isValid(d)?parseInt(d,10):void 0},i.getPenaltyN1=function(d){const h=d.size;let p=0,g=0,b=0,E=null,v=null;for(let x=0;x<h;x++){g=b=0,E=v=null;for(let C=0;C<h;C++){let U=d.get(x,C);U===E?g++:(g>=5&&(p+=r.N1+(g-5)),E=U,g=1),U=d.get(C,x),U===v?b++:(b>=5&&(p+=r.N1+(b-5)),v=U,b=1)}g>=5&&(p+=r.N1+(g-5)),b>=5&&(p+=r.N1+(b-5))}return p},i.getPenaltyN2=function(d){const h=d.size;let p=0;for(let g=0;g<h-1;g++)for(let b=0;b<h-1;b++){const E=d.get(g,b)+d.get(g,b+1)+d.get(g+1,b)+d.get(g+1,b+1);(E===4||E===0)&&p++}return p*r.N2},i.getPenaltyN3=function(d){const h=d.size;let p=0,g=0,b=0;for(let E=0;E<h;E++){g=b=0;for(let v=0;v<h;v++)g=g<<1&2047|d.get(E,v),v>=10&&(g===1488||g===93)&&p++,b=b<<1&2047|d.get(v,E),v>=10&&(b===1488||b===93)&&p++}return p*r.N3},i.getPenaltyN4=function(d){let h=0;const p=d.data.length;for(let b=0;b<p;b++)h+=d.data[b];return Math.abs(Math.ceil(h*100/p/5)-10)*r.N4};function u(c,d,h){switch(c){case i.Patterns.PATTERN000:return(d+h)%2===0;case i.Patterns.PATTERN001:return d%2===0;case i.Patterns.PATTERN010:return h%3===0;case i.Patterns.PATTERN011:return(d+h)%3===0;case i.Patterns.PATTERN100:return(Math.floor(d/2)+Math.floor(h/3))%2===0;case i.Patterns.PATTERN101:return d*h%2+d*h%3===0;case i.Patterns.PATTERN110:return(d*h%2+d*h%3)%2===0;case i.Patterns.PATTERN111:return(d*h%3+(d+h)%2)%2===0;default:throw new Error("bad maskPattern:"+c)}}i.applyMask=function(d,h){const p=h.size;for(let g=0;g<p;g++)for(let b=0;b<p;b++)h.isReserved(b,g)||h.xor(b,g,u(d,b,g))},i.getBestMask=function(d,h){const p=Object.keys(i.Patterns).length;let g=0,b=1/0;for(let E=0;E<p;E++){h(E),i.applyMask(E,d);const v=i.getPenaltyN1(d)+i.getPenaltyN2(d)+i.getPenaltyN3(d)+i.getPenaltyN4(d);i.applyMask(E,d),v<b&&(b=v,g=E)}return g}})(ed)),ed}var zr={},Vg;function Zb(){if(Vg)return zr;Vg=1;const i=Ud(),r=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],u=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return zr.getBlocksCount=function(d,h){switch(h){case i.L:return r[(d-1)*4+0];case i.M:return r[(d-1)*4+1];case i.Q:return r[(d-1)*4+2];case i.H:return r[(d-1)*4+3];default:return}},zr.getTotalCodewordsCount=function(d,h){switch(h){case i.L:return u[(d-1)*4+0];case i.M:return u[(d-1)*4+1];case i.Q:return u[(d-1)*4+2];case i.H:return u[(d-1)*4+3];default:return}},zr}var td={},Yi={},Yg;function qN(){if(Yg)return Yi;Yg=1;const i=new Uint8Array(512),r=new Uint8Array(256);return(function(){let c=1;for(let d=0;d<255;d++)i[d]=c,r[c]=d,c<<=1,c&256&&(c^=285);for(let d=255;d<512;d++)i[d]=i[d-255]})(),Yi.log=function(c){if(c<1)throw new Error("log("+c+")");return r[c]},Yi.exp=function(c){return i[c]},Yi.mul=function(c,d){return c===0||d===0?0:i[r[c]+r[d]]},Yi}var Qg;function HN(){return Qg||(Qg=1,(function(i){const r=qN();i.mul=function(c,d){const h=new Uint8Array(c.length+d.length-1);for(let p=0;p<c.length;p++)for(let g=0;g<d.length;g++)h[p+g]^=r.mul(c[p],d[g]);return h},i.mod=function(c,d){let h=new Uint8Array(c);for(;h.length-d.length>=0;){const p=h[0];for(let b=0;b<d.length;b++)h[b]^=r.mul(d[b],p);let g=0;for(;g<h.length&&h[g]===0;)g++;h=h.slice(g)}return h},i.generateECPolynomial=function(c){let d=new Uint8Array([1]);for(let h=0;h<c;h++)d=i.mul(d,new Uint8Array([1,r.exp(h)]));return d}})(td)),td}var nd,Xg;function GN(){if(Xg)return nd;Xg=1;const i=HN();function r(u){this.genPoly=void 0,this.degree=u,this.degree&&this.initialize(this.degree)}return r.prototype.initialize=function(c){this.degree=c,this.genPoly=i.generateECPolynomial(this.degree)},r.prototype.encode=function(c){if(!this.genPoly)throw new Error("Encoder not initialized");const d=new Uint8Array(c.length+this.degree);d.set(c);const h=i.mod(d,this.genPoly),p=this.degree-h.length;if(p>0){const g=new Uint8Array(this.degree);return g.set(h,p),g}return h},nd=r,nd}var ld={},ad={},id={},Kg;function Jb(){return Kg||(Kg=1,id.isValid=function(r){return!isNaN(r)&&r>=1&&r<=40}),id}var vn={},Zg;function Ib(){if(Zg)return vn;Zg=1;const i="[0-9]+",r="[A-Z $%*+\\-./:]+";let u="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";u=u.replace(/u/g,"\\u");const c="(?:(?![A-Z0-9 $%*+\\-./:]|"+u+`)(?:.|[\r
385
385
  ]))+`;vn.KANJI=new RegExp(u,"g"),vn.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),vn.BYTE=new RegExp(c,"g"),vn.NUMERIC=new RegExp(i,"g"),vn.ALPHANUMERIC=new RegExp(r,"g");const d=new RegExp("^"+u+"$"),h=new RegExp("^"+i+"$"),p=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return vn.testKanji=function(b){return d.test(b)},vn.testNumeric=function(b){return h.test(b)},vn.testAlphanumeric=function(b){return p.test(b)},vn}var Jg;function Jl(){return Jg||(Jg=1,(function(i){const r=Jb(),u=Ib();i.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},i.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},i.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},i.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},i.MIXED={bit:-1},i.getCharCountIndicator=function(h,p){if(!h.ccBits)throw new Error("Invalid mode: "+h);if(!r.isValid(p))throw new Error("Invalid version: "+p);return p>=1&&p<10?h.ccBits[0]:p<27?h.ccBits[1]:h.ccBits[2]},i.getBestModeForData=function(h){return u.testNumeric(h)?i.NUMERIC:u.testAlphanumeric(h)?i.ALPHANUMERIC:u.testKanji(h)?i.KANJI:i.BYTE},i.toString=function(h){if(h&&h.id)return h.id;throw new Error("Invalid mode")},i.isValid=function(h){return h&&h.bit&&h.ccBits};function c(d){if(typeof d!="string")throw new Error("Param is not a string");switch(d.toLowerCase()){case"numeric":return i.NUMERIC;case"alphanumeric":return i.ALPHANUMERIC;case"kanji":return i.KANJI;case"byte":return i.BYTE;default:throw new Error("Unknown mode: "+d)}}i.from=function(h,p){if(i.isValid(h))return h;try{return c(h)}catch{return p}}})(ad)),ad}var Ig;function VN(){return Ig||(Ig=1,(function(i){const r=Zl(),u=Zb(),c=Ud(),d=Jl(),h=Jb(),p=7973,g=r.getBCHDigit(p);function b(C,U,Z){for(let D=1;D<=40;D++)if(U<=i.getCapacity(D,Z,C))return D}function E(C,U){return d.getCharCountIndicator(C,U)+4}function v(C,U){let Z=0;return C.forEach(function(D){const B=E(D.mode,U);Z+=B+D.getBitsLength()}),Z}function x(C,U){for(let Z=1;Z<=40;Z++)if(v(C,Z)<=i.getCapacity(Z,U,d.MIXED))return Z}i.from=function(U,Z){return h.isValid(U)?parseInt(U,10):Z},i.getCapacity=function(U,Z,D){if(!h.isValid(U))throw new Error("Invalid QR Code version");typeof D>"u"&&(D=d.BYTE);const B=r.getSymbolTotalCodewords(U),G=u.getTotalCodewordsCount(U,Z),X=(B-G)*8;if(D===d.MIXED)return X;const le=X-E(D,U);switch(D){case d.NUMERIC:return Math.floor(le/10*3);case d.ALPHANUMERIC:return Math.floor(le/11*2);case d.KANJI:return Math.floor(le/13);case d.BYTE:default:return Math.floor(le/8)}},i.getBestVersionForData=function(U,Z){let D;const B=c.from(Z,c.M);if(Array.isArray(U)){if(U.length>1)return x(U,B);if(U.length===0)return 1;D=U[0]}else D=U;return b(D.mode,D.getLength(),B)},i.getEncodedBits=function(U){if(!h.isValid(U)||U<7)throw new Error("Invalid QR Code version");let Z=U<<12;for(;r.getBCHDigit(Z)-g>=0;)Z^=p<<r.getBCHDigit(Z)-g;return U<<12|Z}})(ld)),ld}var sd={},Pg;function YN(){if(Pg)return sd;Pg=1;const i=Zl(),r=1335,u=21522,c=i.getBCHDigit(r);return sd.getEncodedBits=function(h,p){const g=h.bit<<3|p;let b=g<<10;for(;i.getBCHDigit(b)-c>=0;)b^=r<<i.getBCHDigit(b)-c;return(g<<10|b)^u},sd}var rd={},od,Fg;function QN(){if(Fg)return od;Fg=1;const i=Jl();function r(u){this.mode=i.NUMERIC,this.data=u.toString()}return r.getBitsLength=function(c){return 10*Math.floor(c/3)+(c%3?c%3*3+1:0)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(c){let d,h,p;for(d=0;d+3<=this.data.length;d+=3)h=this.data.substr(d,3),p=parseInt(h,10),c.put(p,10);const g=this.data.length-d;g>0&&(h=this.data.substr(d),p=parseInt(h,10),c.put(p,g*3+1))},od=r,od}var cd,$g;function XN(){if($g)return cd;$g=1;const i=Jl(),r=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function u(c){this.mode=i.ALPHANUMERIC,this.data=c}return u.getBitsLength=function(d){return 11*Math.floor(d/2)+6*(d%2)},u.prototype.getLength=function(){return this.data.length},u.prototype.getBitsLength=function(){return u.getBitsLength(this.data.length)},u.prototype.write=function(d){let h;for(h=0;h+2<=this.data.length;h+=2){let p=r.indexOf(this.data[h])*45;p+=r.indexOf(this.data[h+1]),d.put(p,11)}this.data.length%2&&d.put(r.indexOf(this.data[h]),6)},cd=u,cd}var ud,Wg;function KN(){if(Wg)return ud;Wg=1;const i=Jl();function r(u){this.mode=i.BYTE,typeof u=="string"?this.data=new TextEncoder().encode(u):this.data=new Uint8Array(u)}return r.getBitsLength=function(c){return c*8},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(u){for(let c=0,d=this.data.length;c<d;c++)u.put(this.data[c],8)},ud=r,ud}var dd,ex;function ZN(){if(ex)return dd;ex=1;const i=Jl(),r=Zl();function u(c){this.mode=i.KANJI,this.data=c}return u.getBitsLength=function(d){return d*13},u.prototype.getLength=function(){return this.data.length},u.prototype.getBitsLength=function(){return u.getBitsLength(this.data.length)},u.prototype.write=function(c){let d;for(d=0;d<this.data.length;d++){let h=r.toSJIS(this.data[d]);if(h>=33088&&h<=40956)h-=33088;else if(h>=57408&&h<=60351)h-=49472;else throw new Error("Invalid SJIS character: "+this.data[d]+`
386
386
  Make sure your charset is UTF-8`);h=(h>>>8&255)*192+(h&255),c.put(h,13)}},dd=u,dd}var fd={exports:{}},tx;function JN(){return tx||(tx=1,(function(i){var r={single_source_shortest_paths:function(u,c,d){var h={},p={};p[c]=0;var g=r.PriorityQueue.make();g.push(c,0);for(var b,E,v,x,C,U,Z,D,B;!g.empty();){b=g.pop(),E=b.value,x=b.cost,C=u[E]||{};for(v in C)C.hasOwnProperty(v)&&(U=C[v],Z=x+U,D=p[v],B=typeof p[v]>"u",(B||D>Z)&&(p[v]=Z,g.push(v,Z),h[v]=E))}if(typeof d<"u"&&typeof p[d]>"u"){var G=["Could not find a path from ",c," to ",d,"."].join("");throw new Error(G)}return h},extract_shortest_path_from_predecessor_list:function(u,c){for(var d=[],h=c;h;)d.push(h),u[h],h=u[h];return d.reverse(),d},find_path:function(u,c,d){var h=r.single_source_shortest_paths(u,c,d);return r.extract_shortest_path_from_predecessor_list(h,d)},PriorityQueue:{make:function(u){var c=r.PriorityQueue,d={},h;u=u||{};for(h in c)c.hasOwnProperty(h)&&(d[h]=c[h]);return d.queue=[],d.sorter=u.sorter||c.default_sorter,d},default_sorter:function(u,c){return u.cost-c.cost},push:function(u,c){var d={value:u,cost:c};this.queue.push(d),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};i.exports=r})(fd)),fd.exports}var nx;function IN(){return nx||(nx=1,(function(i){const r=Jl(),u=QN(),c=XN(),d=KN(),h=ZN(),p=Ib(),g=Zl(),b=JN();function E(G){return unescape(encodeURIComponent(G)).length}function v(G,X,le){const W=[];let me;for(;(me=G.exec(le))!==null;)W.push({data:me[0],index:me.index,mode:X,length:me[0].length});return W}function x(G){const X=v(p.NUMERIC,r.NUMERIC,G),le=v(p.ALPHANUMERIC,r.ALPHANUMERIC,G);let W,me;return g.isKanjiModeEnabled()?(W=v(p.BYTE,r.BYTE,G),me=v(p.KANJI,r.KANJI,G)):(W=v(p.BYTE_KANJI,r.BYTE,G),me=[]),X.concat(le,W,me).sort(function(Y,R){return Y.index-R.index}).map(function(Y){return{data:Y.data,mode:Y.mode,length:Y.length}})}function C(G,X){switch(X){case r.NUMERIC:return u.getBitsLength(G);case r.ALPHANUMERIC:return c.getBitsLength(G);case r.KANJI:return h.getBitsLength(G);case r.BYTE:return d.getBitsLength(G)}}function U(G){return G.reduce(function(X,le){const W=X.length-1>=0?X[X.length-1]:null;return W&&W.mode===le.mode?(X[X.length-1].data+=le.data,X):(X.push(le),X)},[])}function Z(G){const X=[];for(let le=0;le<G.length;le++){const W=G[le];switch(W.mode){case r.NUMERIC:X.push([W,{data:W.data,mode:r.ALPHANUMERIC,length:W.length},{data:W.data,mode:r.BYTE,length:W.length}]);break;case r.ALPHANUMERIC:X.push([W,{data:W.data,mode:r.BYTE,length:W.length}]);break;case r.KANJI:X.push([W,{data:W.data,mode:r.BYTE,length:E(W.data)}]);break;case r.BYTE:X.push([{data:W.data,mode:r.BYTE,length:E(W.data)}])}}return X}function D(G,X){const le={},W={start:{}};let me=["start"];for(let J=0;J<G.length;J++){const Y=G[J],R=[];for(let I=0;I<Y.length;I++){const ie=Y[I],$=""+J+I;R.push($),le[$]={node:ie,lastCount:0},W[$]={};for(let te=0;te<me.length;te++){const Q=me[te];le[Q]&&le[Q].node.mode===ie.mode?(W[Q][$]=C(le[Q].lastCount+ie.length,ie.mode)-C(le[Q].lastCount,ie.mode),le[Q].lastCount+=ie.length):(le[Q]&&(le[Q].lastCount=ie.length),W[Q][$]=C(ie.length,ie.mode)+4+r.getCharCountIndicator(ie.mode,X))}}me=R}for(let J=0;J<me.length;J++)W[me[J]].end=0;return{map:W,table:le}}function B(G,X){let le;const W=r.getBestModeForData(G);if(le=r.from(X,W),le!==r.BYTE&&le.bit<W.bit)throw new Error('"'+G+'" cannot be encoded with mode '+r.toString(le)+`.
387
387
  Suggested mode is: `+r.toString(W));switch(le===r.KANJI&&!g.isKanjiModeEnabled()&&(le=r.BYTE),le){case r.NUMERIC:return new u(G);case r.ALPHANUMERIC:return new c(G);case r.KANJI:return new h(G);case r.BYTE:return new d(G)}}i.fromArray=function(X){return X.reduce(function(le,W){return typeof W=="string"?le.push(B(W,null)):W.data&&le.push(B(W.data,W.mode)),le},[])},i.fromString=function(X,le){const W=x(X,g.isKanjiModeEnabled()),me=Z(W),J=D(me,le),Y=b.find_path(J.map,"start","end"),R=[];for(let I=1;I<Y.length-1;I++)R.push(J.table[Y[I]].node);return i.fromArray(U(R))},i.rawSplit=function(X){return i.fromArray(x(X,g.isKanjiModeEnabled()))}})(rd)),rd}var lx;function PN(){if(lx)return Ju;lx=1;const i=Zl(),r=Ud(),u=RN(),c=DN(),d=BN(),h=UN(),p=LN(),g=Zb(),b=GN(),E=VN(),v=YN(),x=Jl(),C=IN();function U(J,Y){const R=J.size,I=h.getPositions(Y);for(let ie=0;ie<I.length;ie++){const $=I[ie][0],te=I[ie][1];for(let Q=-1;Q<=7;Q++)if(!($+Q<=-1||R<=$+Q))for(let ae=-1;ae<=7;ae++)te+ae<=-1||R<=te+ae||(Q>=0&&Q<=6&&(ae===0||ae===6)||ae>=0&&ae<=6&&(Q===0||Q===6)||Q>=2&&Q<=4&&ae>=2&&ae<=4?J.set($+Q,te+ae,!0,!0):J.set($+Q,te+ae,!1,!0))}}function Z(J){const Y=J.size;for(let R=8;R<Y-8;R++){const I=R%2===0;J.set(R,6,I,!0),J.set(6,R,I,!0)}}function D(J,Y){const R=d.getPositions(Y);for(let I=0;I<R.length;I++){const ie=R[I][0],$=R[I][1];for(let te=-2;te<=2;te++)for(let Q=-2;Q<=2;Q++)te===-2||te===2||Q===-2||Q===2||te===0&&Q===0?J.set(ie+te,$+Q,!0,!0):J.set(ie+te,$+Q,!1,!0)}}function B(J,Y){const R=J.size,I=E.getEncodedBits(Y);let ie,$,te;for(let Q=0;Q<18;Q++)ie=Math.floor(Q/3),$=Q%3+R-8-3,te=(I>>Q&1)===1,J.set(ie,$,te,!0),J.set($,ie,te,!0)}function G(J,Y,R){const I=J.size,ie=v.getEncodedBits(Y,R);let $,te;for($=0;$<15;$++)te=(ie>>$&1)===1,$<6?J.set($,8,te,!0):$<8?J.set($+1,8,te,!0):J.set(I-15+$,8,te,!0),$<8?J.set(8,I-$-1,te,!0):$<9?J.set(8,15-$-1+1,te,!0):J.set(8,15-$-1,te,!0);J.set(I-8,8,1,!0)}function X(J,Y){const R=J.size;let I=-1,ie=R-1,$=7,te=0;for(let Q=R-1;Q>0;Q-=2)for(Q===6&&Q--;;){for(let ae=0;ae<2;ae++)if(!J.isReserved(ie,Q-ae)){let pe=!1;te<Y.length&&(pe=(Y[te]>>>$&1)===1),J.set(ie,Q-ae,pe),$--,$===-1&&(te++,$=7)}if(ie+=I,ie<0||R<=ie){ie-=I,I=-I;break}}}function le(J,Y,R){const I=new u;R.forEach(function(ae){I.put(ae.mode.bit,4),I.put(ae.getLength(),x.getCharCountIndicator(ae.mode,J)),ae.write(I)});const ie=i.getSymbolTotalCodewords(J),$=g.getTotalCodewordsCount(J,Y),te=(ie-$)*8;for(I.getLengthInBits()+4<=te&&I.put(0,4);I.getLengthInBits()%8!==0;)I.putBit(0);const Q=(te-I.getLengthInBits())/8;for(let ae=0;ae<Q;ae++)I.put(ae%2?17:236,8);return W(I,J,Y)}function W(J,Y,R){const I=i.getSymbolTotalCodewords(Y),ie=g.getTotalCodewordsCount(Y,R),$=I-ie,te=g.getBlocksCount(Y,R),Q=I%te,ae=te-Q,pe=Math.floor(I/te),T=Math.floor($/te),F=T+1,M=pe-T,se=new b(M);let V=0;const Me=new Array(te),Ue=new Array(te);let Ge=0;const N=new Uint8Array(J.buffer);for(let fe=0;fe<te;fe++){const Se=fe<ae?T:F;Me[fe]=N.slice(V,V+Se),Ue[fe]=se.encode(Me[fe]),V+=Se,Ge=Math.max(Ge,Se)}const S=new Uint8Array(I);let P=0,ne,ye;for(ne=0;ne<Ge;ne++)for(ye=0;ye<te;ye++)ne<Me[ye].length&&(S[P++]=Me[ye][ne]);for(ne=0;ne<M;ne++)for(ye=0;ye<te;ye++)S[P++]=Ue[ye][ne];return S}function me(J,Y,R,I){let ie;if(Array.isArray(J))ie=C.fromArray(J);else if(typeof J=="string"){let pe=Y;if(!pe){const T=C.rawSplit(J);pe=E.getBestVersionForData(T,R)}ie=C.fromString(J,pe||40)}else throw new Error("Invalid data");const $=E.getBestVersionForData(ie,R);if(!$)throw new Error("The amount of data is too big to be stored in a QR Code");if(!Y)Y=$;else if(Y<$)throw new Error(`
@@ -10,7 +10,7 @@
10
10
  <link rel="preconnect" href="https://fonts.googleapis.com" />
11
11
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
12
12
  <link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=Tajawal:wght@400;500;700;800&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet" />
13
- <script type="module" crossorigin src="/dashboard/assets/index-C1b7ijfu.js"></script>
13
+ <script type="module" crossorigin src="/dashboard/assets/index-BBBXWzM0.js"></script>
14
14
  <link rel="stylesheet" crossorigin href="/dashboard/assets/index-pYaivHON.css">
15
15
  </head>
16
16
  <body>
@@ -13,7 +13,6 @@
13
13
  // isn't allowed to do it.
14
14
 
15
15
  const dns = require("node:dns").promises;
16
- const http = require("node:http");
17
16
  const https = require("node:https");
18
17
  const net = require("node:net");
19
18
 
@@ -237,7 +236,7 @@ async function assertPublicUrl(rawUrl) {
237
236
  } catch {
238
237
  throw new Error("الرابط مش صالح");
239
238
  }
240
- if (!/^https?:$/.test(url.protocol)) throw new Error("مسموح بـ http/https بس");
239
+ if (url.protocol !== "https:") throw new Error("مسموح بروابط HTTPS بس");
241
240
 
242
241
  const host = url.hostname.replace(/^\[|\]$/g, "");
243
242
 
@@ -259,7 +258,7 @@ async function assertPublicUrl(rawUrl) {
259
258
  return { url, host, addresses };
260
259
  }
261
260
 
262
- function pinnedAgent(protocol, expectedHost, addresses) {
261
+ function pinnedAgent(expectedHost, addresses) {
263
262
  const lookup = (hostname, options, callback) => {
264
263
  if (String(hostname).toLowerCase() !== expectedHost.toLowerCase()) {
265
264
  const error = new Error("اتصال بدومين غير متوقع");
@@ -282,8 +281,7 @@ function pinnedAgent(protocol, expectedHost, addresses) {
282
281
  return callback(null, candidates[0].address, candidates[0].family);
283
282
  };
284
283
 
285
- const Agent = protocol === "https:" ? https.Agent : http.Agent;
286
- return new Agent({ keepAlive: false, lookup });
284
+ return new https.Agent({ keepAlive: false, lookup });
287
285
  }
288
286
 
289
287
  const MAX_REDIRECTS = 4;
@@ -294,7 +292,7 @@ async function fetchUrl(rawUrl) {
294
292
 
295
293
  for (let hop = 0; ; hop++) {
296
294
  const { url, host, addresses } = target;
297
- const agent = pinnedAgent(url.protocol, host, addresses);
295
+ const agent = pinnedAgent(host, addresses);
298
296
  try {
299
297
  response = await axios.get(url.toString(), {
300
298
  responseType: "arraybuffer",
@@ -305,8 +303,7 @@ async function fetchUrl(rawUrl) {
305
303
  // Ignore process-wide proxy variables: they would perform their own
306
304
  // hostname resolution and bypass the pinned lookup above.
307
305
  proxy: false,
308
- httpAgent: url.protocol === "http:" ? agent : undefined,
309
- httpsAgent: url.protocol === "https:" ? agent : undefined,
306
+ httpsAgent: agent,
310
307
  headers: {
311
308
  "User-Agent": UA,
312
309
  "Accept-Language": "ar,en;q=0.9",
@@ -492,11 +489,11 @@ const TOOLS = {
492
489
  declaration: {
493
490
  name: "fetch_url",
494
491
  description:
495
- "Open a URL and read its text content (article, API response, page the user sent). Use after web_search when a snippet is not enough.",
492
+ "Open an HTTPS URL and read its text content (article, API response, page the user sent). Use after web_search when a snippet is not enough.",
496
493
  parameters: {
497
494
  type: T.OBJECT,
498
495
  properties: {
499
- url: { type: T.STRING, description: "Full http(s) URL." },
496
+ url: { type: T.STRING, description: "Full HTTPS URL." },
500
497
  },
501
498
  required: ["url"],
502
499
  },