Asem75 commited on
Commit
09f5e62
·
verified ·
1 Parent(s): 831fe9c

Upload 7 files

Browse files
README.md CHANGED
@@ -21,9 +21,11 @@ short_description: الساعة الإسلامية — مواقيت وعبادا
21
 
22
  - `README.md`
23
  - `index.html`
 
24
  - `solar_engine.js`
25
  - `personal_reminder_engine.js`
26
  - `hijri_calendar_engine.js`
 
27
  - `registry_app.js`
28
  - `sw.js`
29
  - `visual_states_registry.json`
@@ -41,10 +43,57 @@ short_description: الساعة الإسلامية — مواقيت وعبادا
41
 
42
  الملف الرئيسي هو `index.html`، وأصبح خاصًا بالهيكل والواجهة وتحميل الوحدات فقط.
43
 
44
- - `solar_engine.js`: الحساب الهندسي للشمس والحدود الزمنية الشمسية.
 
45
  - `personal_reminder_engine.js`: تخزين وجدولة التذكيرات الشخصية.
46
- - `hijri_calendar_engine.js`: قراءة التاريخ الهجري ومطابقة قواعد الأحداث.
 
47
  - `registry_app.js`: منسق التطبيق والواجهة وربط المحركات بالسجلات.
48
  - `sw.js`: دعم إشعارات النظام عند التشغيل عبر HTTPS.
49
 
50
  تبقى الأحكام والمحتوى والألوان والمواعيد التعريفية داخل ملفات الـRegistry المالكة لها؛ ملفات JavaScript تستهلكها ولا تنسخها.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  - `README.md`
23
  - `index.html`
24
+ - `astronomy.browser.min.js`
25
  - `solar_engine.js`
26
  - `personal_reminder_engine.js`
27
  - `hijri_calendar_engine.js`
28
+ - `worship_event_engine.js`
29
  - `registry_app.js`
30
  - `sw.js`
31
  - `visual_states_registry.json`
 
43
 
44
  الملف الرئيسي هو `index.html`، وأصبح خاصًا بالهيكل والواجهة وتحميل الوحدات فقط.
45
 
46
+ - `astronomy.browser.min.js`: Astronomy Engine 2.1.19، نسخة محلية أصلية بترخيص MIT المحفوظ داخل الملف.
47
+ - `solar_engine.js`: ربط API المكتبة الفلكية المحلية بالحدود الموجودة في سجل الزمن؛ لا يتصل بخدمة HTTP ولا يرسل إحداثيات المستخدم.
48
  - `personal_reminder_engine.js`: تخزين وجدولة التذكيرات الشخصية.
49
+ - `hijri_calendar_engine.js`: قراءة التاريخ الهجري، تأكيد بداية الشهر محليًا، ومطابقة الأيام والليالي.
50
+ - `worship_event_engine.js`: جدولة مشغلات العبادات والرواتب والمواسم، وحساب الكسوف والخسوف المحلي عبر Astronomy Engine.
51
  - `registry_app.js`: منسق التطبيق والواجهة وربط المحركات بالسجلات.
52
  - `sw.js`: دعم إشعارات النظام عند التشغيل عبر HTTPS.
53
 
54
  تبقى الأحكام والمحتوى والألوان والمواعيد التعريفية داخل ملفات الـRegistry المالكة لها؛ ملفات JavaScript تستهلكها ولا تنسخها.
55
+
56
+ ## إصلاحات 26 سبتمبر 2026
57
+
58
+ - قارئ الشاشة يصل إلى أزرار الساعات ويسمع الساعة فقط، دون التاريخ أو عبارة إعدادات الساعة. عنوان النافذة عند الضغط هو الساعة أيضًا؛ تبقى خيارات الإعداد داخلها متاحة.
59
+ - إدارة التذكيرات ← أذكار الصباح والمساء والنوم: تفعيل مستقل لكل تذكير، موعد يومي أو ربط بصلاة، إزاحة بالدقائق، وصوت اختياري. اختيار «أذكار» عند إضافة تذكير يفتح هذه القائمة، ومنها تذكير أذكار خاص لمرة واحدة. ليست هذه شاشة نصوص أذكار أو تلاوة صوتية.
60
+ - لا تتبع إنجاز للعبادات، ولا تشغيل تلقائي لتلاوة. تبقى بيانات التذكيرات السابقة ومفاتيح تخزينها دون تغيير.
61
+ - الحساب الشمسي يستخدم Astronomy Engine فعلًا عبر Equator/Horizon. تتحرك علامة الوقت على المسطرة وفق الساعة، وتأتي حالة الشمس وارتفاعها وحدودها من المحرك، لا من مواقيت الأذان. زوايا الشفق 15° و18° بقيت تقديرات موروثة تحتاج اعتمادًا رصديًا؛ المحرك الأدق لا يجعلها حقيقة رصدية قطعية.
62
+ - فصل صفوف حدود الشمس بصريًا لمنع تداخل الأحمر والأبيض عند التفاف النص.
63
+ - علامات الأذكار والعبادات والتذكيرات الشخصية في صفوف موازية أسفل مساحة الساعات. ترتيب DOM زمني داخل كل ساعة ثم الساعة التالية، بصرف النظر عن الصف البصري؛ لا يستخدم tabindex موجبًا أو نسخة مكررة مخفية للعلامة. ارتفاع العرض يتسع للصفوف المتزامنة.
64
+ - تنبيهات العبادات والمناسبات متاحة من إدارة التذكيرات ومن نافذة الساعة. تعمل الرواتب والضحى والقيام والوتر والاثنين والخميس والجمعة والأيام البيض، والمواسم الهجرية بعد تحقق شروطها.
65
+ - إعدادات التاريخ الهجري ← تأكيد بداية شهر هجري: السنة والشهر وتاريخ أول يوم ميلادي وعدد أيام الشهر المعتمد. تحفظ محليًا، ولا يؤكد الحساب شهرًا تلقائيًا. عدّل عدد الأيام عند إعلان نهاية الشهر. يبقى تصحيح ±2 أيام مستقلًا للتاريخ المحسوب غير المؤكد.
66
+ - ليالي رمضان تبدأ من غروب اليوم السابق للتاريخ النهاري المقابل. تطبق حدود اليوم/الليلة عبر جميع المشغلات، وتستبعد الليلة الثلاثون في الشهر المؤكد ذي 29 يومًا. يبقى منع اقتراح الصيام في العيدين وأيام التشريق فعالًا.
67
+ - ست شوال: تذكير بداية الموسم، وإعداد اختياري لأيام الأسبوع ووقت التذكير داخله؛ بلا تتبع لعدد أيام الصيام.
68
+ - تذكير السنن القبلية يبدأ عند دخول وقت الفريضة؛ لا تُطرح عشرون أو خمس وعشرون دقيقة قبل دخول الوقت. تذكيرات البعدية مشروطة بأداء الفريضة ولا تفترض أداءها. المرجع: https://binbaz.org.sa/fatwas/17913/حكم-صلاة-السنن-القبلية-للفراىض-قبل-الاذان
69
+ - تذكير الضحى المتأخر وآخر عصر الجمعة اختيار جدولة نسبي داخل النافذة المحسوبة، وموسوم في السجل بسياسة تطبيق؛ ليس تحديدًا شرعيًا بالدقيقة. لا يغيّر الحدود الشمسية أو ألوان المذهب.
70
+ - بطاقة الكسوف والخسوف مرتبطة بالموقع وبمراحل الظاهرة من سجل الفلك. تفحص الظهور فوق الأفق، ويستبعد التذكير بصلاة الخسوف لشبه الظل وحده. التنبؤ لا يثبت المشاهدة الفعلية؛ النص يربط العبادة برؤية الظاهرة، وتنتهي التنبيهات النشطة بانتهاء الجزء المرئي. مصدر البطاقة: https://aliftaa.jo/research-fatwas/3405 . توثيق المحرك: https://github.com/cosinekitty/astronomy/blob/master/source/js/README.md
71
+
72
+ ## نتيجة مراجعة الربط وحدوده
73
+
74
+ السجلات الأساسية الـ12 في قائمة التحميل مستهلكة في التطبيق، لكن تحميلها لا يعني اكتمال كل خصائصها:
75
+
76
+ | السجل | الاستخدام الفعلي |
77
+ | --- | --- |
78
+ | visual_states | النصوص والألوان والرموز ومسارات العرض |
79
+ | fiqh_time | الحدود والحساب وطرق الصلاة وربط مشغلات التنبيه |
80
+ | worship_fiqh | فترات العبادات والأحكام واختلافات المذاهب |
81
+ | islamic_events | جميع صيغ مشغلات العبادات المسجلة وإعدادات الأذكار والمواسم وتأكيد الشهر؛ احترام popup:false للأحكام المعروضة كألوان |
82
+ | religious_content | إحالات التوافق بين القواعد والحدود |
83
+ | contextual_knowledge | المعلومات المرتبطة بالحدود ونافذة المعرفة |
84
+ | user_time_markers | الأنواع والتخزين والتكرار والبومودورو والتأجيل |
85
+ | on_this_day | عرض فهرس الأحداث ومصادرها؛ لا جدولة تلقائية كاملة |
86
+ | announcements_guidance | قراءة وعرض العناصر؛ السجل الحالي خالٍ من العناصر |
87
+ | content_channels | فهرس القنوات؛ لا يوجد جلب/جدولة اشتراكات مكتمل |
88
+ | external_sources | عرض تعريفات ومراجع المزودين؛ ليس اتصالًا حيًا بجميع APIs |
89
+ | astronomy_events | الكسوف والخسوف المحليان مرتبطان ببطاقة العبادة ومراحل التنبيه؛ بقية الظواهر غير التعبدية ما زالت فهرس تعريفات |
90
+
91
+ `fiqh_time_registry_solar_v1_1.json` نسخة مرجعية قديمة، وليست سجل تشغيل ثانٍ؛ لا تُحمّل مع السجل الحالي ولا تُحذف.
92
+
93
+ مرجع `eclipse_prayer` محلول الآن ببطاقة في سجل الأحداث الإسلامية، دون اختراع تفصيل مذهبي لكيفية الصلاة. الأحداث التي تمنع الصيام أو تصف النهي وتحدد `popup:false` تبقى أحكامًا وألوانًا وليست نوافذ منبثقة. الإغلاق الكامل للمتصفح لا يضمن التنبيهات؛ التطبيق المساعد المحلي الاختياري ما زال مرحلة لاحقة.
94
+
95
+ ## التحقق المنفذ
96
+
97
+ نجحت 65 تجربة آلية على JavaScript وDOM محاكى. شملت المحافظة على وظائف الساعة والتذكيرات والبومودورو، العلامات السفلية وترتيب DOM، تغطية كل مشغّل تعبدي مسجل، شروط ثبوت الشهر، رمضان 29/30، الليالي الوترية وغروب اليوم السابق، تعارض الصيام مع العيد والتشريق، حفظ إعداد الموسم وتأكيد الشهر من الواجهة، وتنبؤات كسوف وخسوف فعلية مع استبعاد موقع لا يرى الظاهرة.
98
+
99
+ لم يجر اختبار TalkBack أو الصوت الفعلي على هاتف؛ فحص ترتيب القراءة يعتمد على DOM محاكى. لم تتوفر بيئة Chromium لقياس المظهر بصريًا؛ يلزم اختبار الجهاز بعد الرفع. هذه التغطية تخص العبادات المسجلة، ولا تعني اكتمال قنوات الأخبار والقرآن أو كل الظواهر الفلكية غير التعبدية.
hijri_calendar_engine.js CHANGED
@@ -2,8 +2,14 @@
2
 
3
  // Pure Hijri-calendar matching. UI preferences and Registry access stay in RegistryApp.
4
  globalThis.HijriCalendarEngine = Object.freeze({
5
- parts(ms,{calendarId='islamic',offsetDays=0,maxOffsetDays=0}={}){
6
  try{
 
 
 
 
 
 
7
  const date=new Date(ms),offset=Number(offsetDays),limit=Number(maxOffsetDays);
8
  if(Number.isInteger(offset)&&Number.isFinite(limit)&&Math.abs(offset)<=limit)date.setDate(date.getDate()+offset);
9
  const formatted=new Intl.DateTimeFormat('en-US',{calendar:calendarId,year:'numeric',month:'numeric',day:'numeric'}).formatToParts(date);
@@ -20,12 +26,18 @@ globalThis.HijriCalendarEngine = Object.freeze({
20
  return calendar.weekday===weekday;
21
  }
22
  if(calendar.calendar!=='hijri')return !calendar.type;
23
- if(calendar.requires_month_confirmation&&!forBlocking)return false;
24
  const hijri=typeof parts==='function'?parts(ms):null;if(!hijri)return false;
 
25
  if(calendar.month!=='every'&&calendar.month!=null&&Number(calendar.month)!==hijri.month)return false;
26
  if(Array.isArray(calendar.days)&&!calendar.days.map(Number).includes(hijri.day))return false;
27
  if(calendar.day!=null&&Number(calendar.day)!==hijri.day)return false;
28
  if(Array.isArray(calendar.day_range)&&(hijri.day<Number(calendar.day_range[0])||hijri.day>Number(calendar.day_range[1])))return false;
 
 
29
  return true;
 
 
 
 
30
  }
31
  });
 
2
 
3
  // Pure Hijri-calendar matching. UI preferences and Registry access stay in RegistryApp.
4
  globalThis.HijriCalendarEngine = Object.freeze({
5
+ parts(ms,{calendarId='islamic',offsetDays=0,maxOffsetDays=0,confirmations=[]}={}){
6
  try{
7
+ const actual=new Date(ms),civilStamp=Date.UTC(actual.getFullYear(),actual.getMonth(),actual.getDate());
8
+ for(const month of confirmations){
9
+ if(!this.validConfirmation(month))continue;
10
+ const elapsed=Math.round((civilStamp-Date.parse(month.start+'T00:00:00Z'))/86400000);
11
+ if(elapsed>=0&&elapsed<month.length)return {year:month.year,month:month.month,day:elapsed+1,confirmed:true};
12
+ }
13
  const date=new Date(ms),offset=Number(offsetDays),limit=Number(maxOffsetDays);
14
  if(Number.isInteger(offset)&&Number.isFinite(limit)&&Math.abs(offset)<=limit)date.setDate(date.getDate()+offset);
15
  const formatted=new Intl.DateTimeFormat('en-US',{calendar:calendarId,year:'numeric',month:'numeric',day:'numeric'}).formatToParts(date);
 
26
  return calendar.weekday===weekday;
27
  }
28
  if(calendar.calendar!=='hijri')return !calendar.type;
 
29
  const hijri=typeof parts==='function'?parts(ms):null;if(!hijri)return false;
30
+ if(calendar.requires_month_confirmation&&!forBlocking&&hijri.confirmed!==true)return false;
31
  if(calendar.month!=='every'&&calendar.month!=null&&Number(calendar.month)!==hijri.month)return false;
32
  if(Array.isArray(calendar.days)&&!calendar.days.map(Number).includes(hijri.day))return false;
33
  if(calendar.day!=null&&Number(calendar.day)!==hijri.day)return false;
34
  if(Array.isArray(calendar.day_range)&&(hijri.day<Number(calendar.day_range[0])||hijri.day>Number(calendar.day_range[1])))return false;
35
+ if(Array.isArray(calendar.night_range)&&(hijri.day<Number(calendar.night_range[0])||hijri.day>Number(calendar.night_range[1])))return false;
36
+ if(Array.isArray(calendar.odd_nights)&&!calendar.odd_nights.map(Number).includes(hijri.day))return false;
37
  return true;
38
+ },
39
+ validConfirmation(value){
40
+ if(!value||!Number.isInteger(value.year)||value.year<1||!Number.isInteger(value.month)||value.month<1||value.month>12||![29,30].includes(value.length)||!/^\d{4}-\d{2}-\d{2}$/.test(value.start||''))return false;
41
+ const date=new Date(value.start+'T00:00:00Z');return Number.isFinite(date.getTime())&&date.toISOString().slice(0,10)===value.start;
42
  }
43
  });
index.html CHANGED
@@ -128,8 +128,9 @@ body{padding-bottom:190px}
128
  .hour .tick{left:0}.hour .label{left:8px;transform:none;pointer-events:none}
129
  .time-track{left:0;right:0;z-index:2}.time-band,.solar-point{pointer-events:auto;cursor:pointer;border:0;padding:0;min-width:3px}
130
  .hour-icons{z-index:3;pointer-events:none}.prayer-entry{pointer-events:auto;font:inherit;color:inherit;background:var(--cell-surface);border:1px solid var(--cell-border);border-radius:6px;padding:4px;cursor:pointer}
131
- .boundary-entries{position:absolute;top:164px;left:3px;right:3px;max-height:98px;overflow-y:auto;display:flex;flex-direction:column;gap:3px;z-index:3}
132
- .boundary-entry{flex-shrink:0;font:inherit;font-size:12px;color:inherit;background:var(--cell-surface);border:1px solid var(--cell-border);border-radius:5px;padding:4px;cursor:pointer;direction:rtl}
 
133
  .now-marker{top:0;padding:0;transform:none;background:transparent!important;z-index:4}
134
  .now-marker::after{top:76px;left:0;height:300px;border-left-width:2px}
135
  .now-marker-label{position:absolute;top:0;left:0;width:270px;max-width:calc(100vw - 32px);white-space:pre-line;text-align:center;line-height:1.65;background:var(--cell-surface);border:1px solid currentColor;border-radius:8px;padding:4px;direction:rtl}
@@ -170,7 +171,8 @@ body{padding-bottom:190px}
170
  <script src="astronomy.browser.min.js?v=20260926-ui2"></script>
171
  <script src="solar_engine.js?v=20260926-ui2"></script>
172
  <script src="personal_reminder_engine.js?v=20260926-ui2"></script>
173
- <script src="hijri_calendar_engine.js?v=20260926-ui2"></script>
174
- <script src="registry_app.js?v=20260926-ui2"></script>
 
175
  </body>
176
  </html>
 
128
  .hour .tick{left:0}.hour .label{left:8px;transform:none;pointer-events:none}
129
  .time-track{left:0;right:0;z-index:2}.time-band,.solar-point{pointer-events:auto;cursor:pointer;border:0;padding:0;min-width:3px}
130
  .hour-icons{z-index:3;pointer-events:none}.prayer-entry{pointer-events:auto;font:inherit;color:inherit;background:var(--cell-surface);border:1px solid var(--cell-border);border-radius:6px;padding:4px;cursor:pointer}
131
+ .boundary-entry{position:absolute;left:3px;right:3px;min-height:36px;max-height:38px;overflow-y:auto;z-index:3;font:inherit;font-size:12px;color:inherit;background:var(--cell-surface);border:1px solid var(--cell-border);border-radius:5px;padding:4px;cursor:pointer;direction:rtl}
132
+ .event-marker,.personal-hour{position:absolute;left:3px;right:3px;height:64px;overflow-y:auto;z-index:3;font:inherit;font-size:14px;color:inherit;background:var(--cell-surface);border:1px solid var(--cell-border);border-radius:7px;padding:6px;cursor:pointer;direction:rtl}
133
+ .reminder-axis{position:absolute;left:0;right:0;border-top:1px solid var(--cell-border);pointer-events:none}
134
  .now-marker{top:0;padding:0;transform:none;background:transparent!important;z-index:4}
135
  .now-marker::after{top:76px;left:0;height:300px;border-left-width:2px}
136
  .now-marker-label{position:absolute;top:0;left:0;width:270px;max-width:calc(100vw - 32px);white-space:pre-line;text-align:center;line-height:1.65;background:var(--cell-surface);border:1px solid currentColor;border-radius:8px;padding:4px;direction:rtl}
 
171
  <script src="astronomy.browser.min.js?v=20260926-ui2"></script>
172
  <script src="solar_engine.js?v=20260926-ui2"></script>
173
  <script src="personal_reminder_engine.js?v=20260926-ui2"></script>
174
+ <script src="hijri_calendar_engine.js?v=20260926-worship1"></script>
175
+ <script src="worship_event_engine.js?v=20260926-worship1"></script>
176
+ <script src="registry_app.js?v=20260926-worship1"></script>
177
  </body>
178
  </html>
islamic_events_registry.json CHANGED
@@ -10,7 +10,32 @@
10
  "offset_limit_minutes": 1440,
11
  "prayer_triggers": ["after_fajr", "after_dhuhr", "after_asr", "after_maghrib", "after_isha"]
12
  },
13
- "schema_version": "islamic_events_registry_v1_1",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  "project": "ساعة المسلم / الخط الزمني الروحي",
15
  "language": "ar",
16
  "direction": "rtl",
@@ -63,6 +88,27 @@
63
  }
64
  },
65
  "events": [
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  {
67
  "id": "fasting_monday",
68
  "category": "weekly_recurring",
@@ -291,7 +337,7 @@
291
  {
292
  "id": "friday_dua_late_afternoon",
293
  "when": "late_after_asr_until_maghrib",
294
- "timing_authority": "evidence",
295
  "popup": {
296
  "title": "وقت مرجو للدعاء",
297
  "text": "اغتنم آخر نهار الجمعة بالدعاء. لا يعرض التطبيق هذه الفترة على أنها ساعة الإجابة يقينًا.",
@@ -421,7 +467,8 @@
421
  "text": "تذكير بأذكار الصباح.",
422
  "image": "assets/events/morning_adhkar.webp",
423
  "popup": true,
424
- "timeline": false,
 
425
  "notification": "user_configurable"
426
  },
427
  "triggers": [
@@ -474,7 +521,8 @@
474
  "text": "تذكير بأذكار المساء.",
475
  "image": "assets/events/evening_adhkar.webp",
476
  "popup": true,
477
- "timeline": false,
 
478
  "notification": "user_configurable"
479
  },
480
  "triggers": [
@@ -527,7 +575,8 @@
527
  "text": "تذكير بأذكار النوم.",
528
  "image": "assets/events/sleep_adhkar.webp",
529
  "popup": true,
530
- "timeline": false,
 
531
  "notification": "user_configurable"
532
  },
533
  "triggers": [
@@ -559,6 +608,7 @@
559
  },
560
  {
561
  "id": "rawatib_prayers",
 
562
  "category": "prayer_relative",
563
  "rule_type": "recommended",
564
  "action": "sunnah_rawatib",
@@ -582,22 +632,28 @@
582
  "items": [
583
  {
584
  "id": "before_fajr_2",
 
 
585
  "prayer": "fajr",
586
  "relation": "before",
587
  "rakats": 2,
588
- "trigger": "before_fajr",
589
- "offset_minutes": 20
590
  },
591
  {
592
  "id": "before_dhuhr_4",
 
 
593
  "prayer": "dhuhr",
594
  "relation": "before",
595
  "rakats": 4,
596
- "trigger": "before_dhuhr",
597
- "offset_minutes": 25
598
  },
599
  {
600
  "id": "after_dhuhr_2",
 
 
601
  "prayer": "dhuhr",
602
  "relation": "after",
603
  "rakats": 2,
@@ -606,6 +662,8 @@
606
  },
607
  {
608
  "id": "after_maghrib_2",
 
 
609
  "prayer": "maghrib",
610
  "relation": "after",
611
  "rakats": 2,
@@ -614,6 +672,8 @@
614
  },
615
  {
616
  "id": "after_isha_2",
 
 
617
  "prayer": "isha",
618
  "relation": "after",
619
  "rakats": 2,
@@ -640,7 +700,8 @@
640
  }
641
  ],
642
  "notes": [
643
- "لا تخزن ساعات ثابتة؛ PrayerEngine يحدد المواقيت يوميًا."
 
644
  ]
645
  },
646
  {
@@ -656,16 +717,7 @@
656
  "time_rule": {
657
  "type": "solar_relative",
658
  "source_engine": "SolarEngine",
659
- "start": {
660
- "event": "sunrise",
661
- "offset_minutes": 15,
662
- "approximate": true
663
- },
664
- "end": {
665
- "event": "solar_noon",
666
- "offset_minutes": -5,
667
- "approximate": true
668
- },
669
  "preferred_window": {
670
  "type": "late_duha",
671
  "calculation": "solar_altitude_or_late_window"
@@ -688,7 +740,8 @@
688
  {
689
  "id": "preferred_duha",
690
  "when": "preferred_duha_window",
691
- "timing_authority": "engine"
 
692
  }
693
  ],
694
  "repeat_policy": {
@@ -704,7 +757,7 @@
704
  }
705
  ],
706
  "notes": [
707
- "إزاحة 15 دقيقة بعد الشروق و5 دقائق قبل الزوال تقريب للواجهة، وتعرض للمستخدم كوقت تقريبي."
708
  ]
709
  },
710
  {
@@ -770,6 +823,7 @@
770
  },
771
  {
772
  "id": "six_days_shawwal",
 
773
  "category": "hijri_seasonal",
774
  "rule_type": "recommended",
775
  "action": "voluntary_fasting",
@@ -809,6 +863,7 @@
809
  ],
810
  "repeat_policy": {
811
  "mode": "seasonal_policy",
 
812
  "completion_tracking": false
813
  },
814
  "dismiss_behavior": "current_trigger_only",
 
10
  "offset_limit_minutes": 1440,
11
  "prayer_triggers": ["after_fajr", "after_dhuhr", "after_asr", "after_maghrib", "after_isha"]
12
  },
13
+ "calendar_confirmation": {
14
+ "storage_key": "clock_confirmed_hijri_months_v1",
15
+ "authority": "user_confirmation_of_official_month_start",
16
+ "length_options": [29, 30]
17
+ },
18
+ "scheduling_policy": {
19
+ "calendar_day_trigger": "day_start",
20
+ "season_preferences_key": "clock_season_reminders_v1",
21
+ "calendar_triggers": {
22
+ "shawwal_day_2": {"month": 10, "day": 2, "relative": "day_start"},
23
+ "confirmed_month_start": {"day": 1, "relative": "previous_evening"}
24
+ },
25
+ "window_triggers": {
26
+ "preferred_duha_window": {
27
+ "rule_id": "duha", "fraction": 0.6666666666666666,
28
+ "timing_authority": "app_policy",
29
+ "note_ar": "موعد تذكير في الثلث الأخير من نافذة الضحى المحسوبة، وليس حدًا شرعيًا ثابتًا لوقت الفضيلة."
30
+ },
31
+ "late_after_asr_until_maghrib": {
32
+ "start": "asr", "end": "sunset", "fraction": 0.75,
33
+ "timing_authority": "app_policy",
34
+ "note_ar": "موعد تذكير في الربع الأخير بين العصر والغروب؛ لا يجزم بتحديد ساعة الإجابة."
35
+ }
36
+ }
37
+ },
38
+ "schema_version": "islamic_events_registry_v1_2",
39
  "project": "ساعة المسلم / الخط الزمني الروحي",
40
  "language": "ar",
41
  "direction": "rtl",
 
88
  }
89
  },
90
  "events": [
91
+ {
92
+ "id": "eclipse_prayer",
93
+ "category": "astronomy_relative",
94
+ "action": "eclipse_prayer",
95
+ "enabled": true,
96
+ "priority": 850,
97
+ "time_rule": {"type": "astronomy_relative", "registry": "astronomy_events", "local_visibility_required": true, "lunar_phase": "umbral"},
98
+ "display": {
99
+ "title": "صلاة الكسوف والخسوف",
100
+ "text": "يرتبط التذكير بإمكان رؤية الظاهرة من موقعك. الحساب تنبؤ فلكي ولا يثبت المشاهدة الفعلية؛ عند رؤية الكسوف أو الخسوف تشرع الصلاة والدعاء، وينتهي السبب بانجلائه. تفاصيل كيفية الصلاة وخلاف المذاهب تؤخذ من المصادر.",
101
+ "popup": true, "timeline": true, "notification": false
102
+ },
103
+ "notice_text": {
104
+ "advance": "تنبؤ بكسوف أو خسوف يمكن رؤيته من موقعك. هذا تذكير مسبق؛ وقت الصلاة متعلق برؤية الظاهرة عند وقوعها.",
105
+ "active": "تشير الحسابات إلى وجود كسوف أو خسوف فوق أفق موقعك الآن. إذا شوهدت الظاهرة فتذكّر الصلاة والدعاء؛ الحساب لا يثبت المشاهدة الفعلية."
106
+ },
107
+ "repeat_policy": {"mode": "astronomy_event_phase", "source": "astronomy_events.defaults.max_popup_per_event_phase"},
108
+ "dismiss_behavior": "current_trigger_only",
109
+ "completion_tracking": false,
110
+ "references": [{"title": "دائرة الإفتاء الأردنية — صلاة الخسوف وما يتعلق بها من أحكام", "url": "https://aliftaa.jo/research-fatwas/3405"}]
111
+ },
112
  {
113
  "id": "fasting_monday",
114
  "category": "weekly_recurring",
 
337
  {
338
  "id": "friday_dua_late_afternoon",
339
  "when": "late_after_asr_until_maghrib",
340
+ "timing_authority": "app_policy",
341
  "popup": {
342
  "title": "وقت مرجو للدعاء",
343
  "text": "اغتنم آخر نهار الجمعة بالدعاء. لا يعرض التطبيق هذه الفترة على أنها ساعة الإجابة يقينًا.",
 
467
  "text": "تذكير بأذكار الصباح.",
468
  "image": "assets/events/morning_adhkar.webp",
469
  "popup": true,
470
+ "timeline": true,
471
+ "timeline_marker": "scheduled_trigger",
472
  "notification": "user_configurable"
473
  },
474
  "triggers": [
 
521
  "text": "تذكير بأذكار المساء.",
522
  "image": "assets/events/evening_adhkar.webp",
523
  "popup": true,
524
+ "timeline": true,
525
+ "timeline_marker": "scheduled_trigger",
526
  "notification": "user_configurable"
527
  },
528
  "triggers": [
 
575
  "text": "تذكير بأذكار النوم.",
576
  "image": "assets/events/sleep_adhkar.webp",
577
  "popup": true,
578
+ "timeline": true,
579
+ "timeline_marker": "scheduled_trigger",
580
  "notification": "user_configurable"
581
  },
582
  "triggers": [
 
608
  },
609
  {
610
  "id": "rawatib_prayers",
611
+ "references": [{"title": "وقت السنن القبلية — تبدأ بعد دخول وقت الفري��ة", "url": "https://binbaz.org.sa/fatwas/17913/حكم-صلاة-السنن-القبلية-للفراىض-قبل-الاذان"}],
612
  "category": "prayer_relative",
613
  "rule_type": "recommended",
614
  "action": "sunnah_rawatib",
 
632
  "items": [
633
  {
634
  "id": "before_fajr_2",
635
+ "title": "سنة الفجر القبلية",
636
+ "popup_text": "دخل وقت الفجر؛ تذكير بسنة الفجر قبل أداء الفريضة.",
637
  "prayer": "fajr",
638
  "relation": "before",
639
  "rakats": 2,
640
+ "trigger": "after_fajr",
641
+ "offset_minutes": 0
642
  },
643
  {
644
  "id": "before_dhuhr_4",
645
+ "title": "سنة الظهر القبلية",
646
+ "popup_text": "دخل وقت الظهر؛ تذكير بالسنة القبلية قبل أداء الفريضة.",
647
  "prayer": "dhuhr",
648
  "relation": "before",
649
  "rakats": 4,
650
+ "trigger": "after_dhuhr",
651
+ "offset_minutes": 0
652
  },
653
  {
654
  "id": "after_dhuhr_2",
655
+ "title": "سنة الظهر البعدية",
656
+ "popup_text": "تذكير بسنة الظهر بعد أداء الفريضة؛ الموعد للتذكير ولا يفترض أنك صليت.",
657
  "prayer": "dhuhr",
658
  "relation": "after",
659
  "rakats": 2,
 
662
  },
663
  {
664
  "id": "after_maghrib_2",
665
+ "title": "سنة المغرب البعدية",
666
+ "popup_text": "تذكير بسنة المغرب بعد أداء الفريضة؛ الموعد للتذكير ولا يفترض أنك صليت.",
667
  "prayer": "maghrib",
668
  "relation": "after",
669
  "rakats": 2,
 
672
  },
673
  {
674
  "id": "after_isha_2",
675
+ "title": "سنة العشاء البعدية",
676
+ "popup_text": "تذكير بسنة العشاء بعد أداء الفريضة؛ الموعد للتذكير ولا يفترض أنك صليت.",
677
  "prayer": "isha",
678
  "relation": "after",
679
  "rakats": 2,
 
700
  }
701
  ],
702
  "notes": [
703
+ "لا تخزن ساعات ثابتة؛ PrayerEngine يحدد المواقيت يوميًا.",
704
+ "القبلية قبل أداء الفريضة وبعد دخول وقتها. الإزاحات للبعدية مواعيد تذكير ولا تثبت أداء الفريضة."
705
  ]
706
  },
707
  {
 
717
  "time_rule": {
718
  "type": "solar_relative",
719
  "source_engine": "SolarEngine",
720
+ "rule_id": "duha",
 
 
 
 
 
 
 
 
 
721
  "preferred_window": {
722
  "type": "late_duha",
723
  "calculation": "solar_altitude_or_late_window"
 
740
  {
741
  "id": "preferred_duha",
742
  "when": "preferred_duha_window",
743
+ "timing_authority": "app_policy",
744
+ "popup_text": "تذكير بصلاة الضحى في الجزء المتأخر من وقتها. موعد التنبيه سياسة تطبيق وليس تحديدًا شرعيًا بالدقيقة."
745
  }
746
  ],
747
  "repeat_policy": {
 
757
  }
758
  ],
759
  "notes": [
760
+ "نافذة الضحى من قاعدة duha في سجل العبادات، وحدودها من المحرك الشمسي؛ لا تستخدم إزاحات ثابتة عن الشروق."
761
  ]
762
  },
763
  {
 
823
  },
824
  {
825
  "id": "six_days_shawwal",
826
+ "user_schedule": {"mode": "weekly_clock", "default_enabled": false},
827
  "category": "hijri_seasonal",
828
  "rule_type": "recommended",
829
  "action": "voluntary_fasting",
 
863
  ],
864
  "repeat_policy": {
865
  "mode": "seasonal_policy",
866
+ "max_per_trigger": 1,
867
  "completion_tracking": false
868
  },
869
  "dismiss_behavior": "current_trigger_only",
registry_app.js CHANGED
@@ -111,6 +111,10 @@ const RegistryApp = (() => {
111
  if(group==='worship')array(x.sources).forEach(id=>{const s=registry('worship_fiqh').sources[id];if(s?.url)link($('adaptivePopupBody'),s.title,s.url);});
112
  if(group==='quran'||group==='providers')link($('adaptivePopupBody'),ui.source+' — '+x.name,x.documentation_url||x.base_url);
113
  if(x.source?.url)link($('adaptivePopupBody'),x.source.name||ui.source,x.source.url);
 
 
 
 
114
  array(x.references).forEach(r=>{if(typeof r==='string')para(r);else if(r.url)link($('adaptivePopupBody'),r.title||ui.source,r.url);});
115
  related(kind,x);back(returnView||(()=>list(kind,group)));
116
  });
@@ -261,6 +265,7 @@ const RegistryApp = (() => {
261
  function hourSettings(start){
262
  show('worship',{title:hourAccessibleLabel(new Date(start).getHours()),compact:true},()=>{
263
  $('adaptivePopupBody').appendChild(button(ui.adhkar.title,()=>adhkarHome(start)));
 
264
  $('adaptivePopupActions').appendChild(button(ru().add,()=>reminderChoose(start)));
265
  $('adaptivePopupBody').appendChild(button(ru().settings,reminderSettings));
266
  $('adaptivePopupBody').appendChild(button(ru().tools,remindersHome));
@@ -308,7 +313,7 @@ const RegistryApp = (() => {
308
  }
309
  function hijriParts(ms){
310
  const id=(visual.runtime_styles.current_time_calendars||[]).find(c=>c.adjustable)?.id||'islamic';
311
- return HijriCalendarEngine.parts(ms,{calendarId:id,offsetDays:getSaved('clock_calendar_adjustment_v1',0),maxOffsetDays:visual.runtime_styles.calendar_adjustment_limit});
312
  }
313
  function eventCalendarMatches(event,ms,forBlocking=false){
314
  return HijriCalendarEngine.matches(event,ms,{parts:hijriParts,forBlocking});
@@ -323,6 +328,23 @@ const RegistryApp = (() => {
323
  const adhkarConfig=()=>registry('islamic_events').reminder_preferences;
324
  const isAdhkar=event=>Boolean(adhkarConfig()&&event.action===adhkarConfig().event_action);
325
  const adhkarReady=()=>adhkarConfig()?.ui_contract_version===2;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
326
  function adhkarPreference(event){
327
  const c=adhkarConfig(),saved=getSaved(c.storage_key,{}),value=saved[event.id];
328
  return {enabled:Boolean(getSaved(event.activation.storage_key,event.activation.default_enabled)),mode:c.default_mode,trigger:event.triggers[0].when,offset:0,time:'',sound:c.default_sound,...(value&&typeof value==='object'?value:{})};
@@ -361,7 +383,8 @@ const RegistryApp = (() => {
361
  return registry('islamic_events').events.filter(e=>{
362
  if(!eventEnabled(e))return false;const c=e.calendar_rule||{},t=e.time_rule||{};
363
  if(e.display?.timeline===false||t.type==='conditional_prayer_relative'||t.type==='trigger_only'||!eventCalendarMatches(e,start)||eventBlockedOn(e,start))return false;
364
- if(t.type==='full_day_worship')return true;
 
365
  if(t.start&&t.end){return solarDays.some(d=>d.boundaries[t.start]!=null&&d.boundaries[t.end]!=null&&d.boundaries[t.start]<end&&d.boundaries[t.end]>start);}
366
  if(Array.isArray(t.windows))return t.windows.some(w=>solarDays.some(d=>d.boundaries[w.start]!=null&&d.boundaries[w.end]!=null&&d.boundaries[w.start]<end&&d.boundaries[w.end]>start));
367
  return false;
@@ -407,26 +430,61 @@ const RegistryApp = (() => {
407
  for(const p of entries){const label=periodIcon(p)+' '+ruleTitle(p.rule)+(style.prayer_entry_markers.show_time?' '+timeText(p.start):'');const entry=button(label,()=>periodDetails(p));entry.setAttribute('aria-label',periodTitle(p)+' — '+timeText(p.start));entry.className='prayer-entry';entry.dataset.ruleId=p.id;entry.dataset.time=String(p.start);entry.dataset.timelineTime=String(p.start);entry.style.position='absolute';entry.style.top='6px';entry.style.left='4px';entry.style.zIndex='3';controls.push(entry);}
408
 
409
  }
410
- const marks=make('div');marks.className='boundary-entries';
411
  for(const d of solarDays)for(const id of style.boundary_markers||[]){
412
  const t=d.boundaries[id],def=boundary(id);if(!def||t==null||t<start||t>=end)continue;
413
  const entry=button((icon(id)?icon(id)+' ':'')+def.label+' '+timeText(t),()=>boundaryInfo(def,t));
414
- entry.dataset.boundaryId=id;entry.dataset.time=String(t);entry.dataset.timelineTime=String(t);entry.className='boundary-entry';marks.appendChild(entry);
 
 
 
 
 
 
 
 
 
 
 
 
415
  }
416
- Array.from(marks.children).sort((a,b)=>Number(a.dataset.time)-Number(b.dataset.time)).forEach(x=>marks.appendChild(x));
417
- if(marks.children.length){marks.dataset.timelineTime=marks.firstElementChild.dataset.time;controls.push(marks);}
418
  controls.sort((a,b)=>Number(a.dataset.timelineTime)-Number(b.dataset.timelineTime)).forEach(x=>cell.appendChild(x));
419
  }
420
  function calendarText(c,now){
421
  try{const date=new Date(now),offset=Number(getSaved('clock_calendar_adjustment_v1',0));
 
422
  if(c.adjustable&&Number.isInteger(offset)&&Math.abs(offset)<=visual.runtime_styles.calendar_adjustment_limit)date.setDate(date.getDate()+offset);
423
  return new Intl.DateTimeFormat(document.documentElement.lang,{calendar:c.id,year:'numeric',month:'long',day:'numeric'}).format(date)+' '+c.label;
424
  }catch{return ui.calendarUnavailable;}
425
  }
426
  function calendarSettings(){show('worship',{title:ui.calendarSettings,text:ui.calendarNote},()=>{
427
  const value=reminderField(ui.calendarAdjustment,'number',getSaved('clock_calendar_adjustment_v1',0));value.min=-visual.runtime_styles.calendar_adjustment_limit;value.max=visual.runtime_styles.calendar_adjustment_limit;value.step=1;
428
- $('adaptivePopupActions').appendChild(button(ui.apply,()=>{const n=Number(value.value);if(!Number.isInteger(n)||Math.abs(n)>visual.runtime_styles.calendar_adjustment_limit){para(ui.calendarInvalid);return;}save('clock_calendar_adjustment_v1',n);updateCurrentMarker(Date.now());close();}));
 
429
  });}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
430
  function updateCurrentMarker(now){
431
  const width=Number($('ruler').dataset.cellWidth),marker=$('nowMarker');
432
  if(marker){marker.style.left=((now-timelineStart)/3600000*width)+'px';marker.hidden=now<timelineStart||now>=timelineStart+layout.total_hours*3600000;
@@ -467,41 +525,24 @@ const RegistryApp = (() => {
467
  function buildNotices(){
468
  timedNotices=[];const runtime=profile()?.notice_runtime;if(!runtime)return;
469
  const localToday=new Date();localToday.setHours(0,0,0,0);
470
- const noticeDays=Array.from({length:6},(_,i)=>{const date=new Date(localToday);date.setDate(date.getDate()+i-2);return Date.UTC(date.getFullYear(),date.getMonth(),date.getDate());});
471
- for(const stamp of noticeDays){
472
- const day=solarDays.find(d=>d.day===stamp)||{day:stamp,boundaries:{}};
473
- const utc=new Date(stamp),civil=new Date(utc.getUTCFullYear(),utc.getUTCMonth(),utc.getUTCDate(),12);
474
- for(const event of registry('islamic_events').events){
475
- if(!eventEnabled(event)||event.display?.popup===false)continue;
476
- if(!eventCalendarMatches(event,civil.getTime())||eventBlockedOn(event,civil.getTime()))continue;
477
- if(event.time_rule?.type==='conditional_prayer_relative')continue;
478
- const preference=isAdhkar(event)?adhkarPreference(event):null;
479
- for(const original of event.triggers||[]){
480
- const trigger=preference?{...original,when:preference.trigger,offset_minutes:preference.offset}:original;
481
- if(preference?.mode==='clock'){
482
- if(!/^([01]\d|2[0-3]):[0-5]\d$/.test(preference.time))continue;
483
- const [h,m]=preference.time.split(':').map(Number),at=new Date(civil);at.setHours(h,m,0,0);
484
- const max=event.repeat_policy?.max_per_trigger;if(!Number.isInteger(max)||max<1)continue;
485
- timedNotices.push({key:event.id+':'+trigger.id+':'+day.day,at:at.getTime(),max,event,trigger,sound:preference.sound,priority:event.priority||0});continue;
486
- }
487
- if(!observer||(methodChoice()&&!prayerEngineReady))continue;
488
- const binding=runtime.trigger_bindings[trigger.when];if(!binding)continue;
489
- const source=solarDays.find(d=>d.day===day.day+(binding.day_shift||0)*86400000);
490
- const at=source?.boundaries[binding.boundary];if(at==null)continue;
491
- const due=at+(trigger.offset_minutes||0)*60000*(binding.offset_sign||1);
492
- const max=event.repeat_policy?.max_per_trigger;if(!Number.isInteger(max)||max<1)continue;
493
- timedNotices.push({key:event.id+':'+trigger.id+':'+day.day,at:due,max,event,trigger,sound:preference?.sound,priority:event.priority||0});
494
- }
495
- }
496
- }
497
  timedNotices.sort((a,b)=>a.at-b.at||b.priority-a.priority);
498
  for(const [key,pending] of pendingTimedNotices)if(!timedNotices.some(n=>n.key===key&&n.at===pending.at))pendingTimedNotices.delete(key);
499
  }
500
  function tickNotices(now){
501
  const runtime=profile()?.notice_runtime;if(!runtime)return;
502
  const ledger=getSaved('clock_popup_impressions_v1',{});
503
- for(const n of timedNotices)if(now>=n.at&&now-n.at<runtime.due_window_seconds*1000&&(ledger[n.key]?.count||0)<n.max)pendingTimedNotices.set(n.key,n);
504
  if(!document.hidden&&$('adaptivePopup').hidden===false)return;
 
505
  const due=[...pendingTimedNotices.values()].filter(n=>eventEnabled(n.event)&&(ledger[n.key]?.count||0)<n.max).sort((a,b)=>b.priority-a.priority||a.at-b.at)[0];
506
  if(!due)return;
507
  pendingTimedNotices.delete(due.key);
@@ -509,7 +550,7 @@ const RegistryApp = (() => {
509
  for(const [key,value] of Object.entries(ledger))if(now-value.at>7*86400000)delete ledger[key];
510
  ledger[due.key]={count:(ledger[due.key]?.count||0)+1,at:now};save('clock_popup_impressions_v1',ledger);
511
  const popup=due.trigger.popup||{};
512
- const kind=eventScreen(due.event),noticeTitle=popup.title||title(due.event),noticeText=popup.text||due.trigger.popup_text||due.event.display?.text||'';
513
  if(due.sound!==false)playReminderSound();notifySystem(noticeTitle,noticeText,{kind,eventId:due.event.id});
514
  if(!document.hidden&&$('adaptivePopup').hidden!==false)show(kind,{title:noticeTitle,text:noticeText,media:icon(visual.event_action_mapping[due.event.action])},()=>{
515
  back(()=>detail(kind,'events',due.event));
@@ -550,6 +591,7 @@ const RegistryApp = (() => {
550
  $('adaptivePopupActions').appendChild(button(ru().add,()=>reminderChoose(selectedHour)));
551
  $('adaptivePopupActions').appendChild(button(ru().settings,reminderSettings));
552
  $('adaptivePopupActions').appendChild(button(ui.adhkar.title,()=>adhkarHome(selectedHour)));
 
553
  if(s.items.length)$('adaptivePopupActions').appendChild(button(ru().removeSelected,()=>remindersRemoveSelected(selectedHour)));
554
  if(!s.items.length)para(ru().empty);
555
  s.items.slice().sort((a,b)=>Boolean(b.notice)-Boolean(a.notice)||reminderMoment(a)-reminderMoment(b)).forEach(x=>{
@@ -634,7 +676,7 @@ const RegistryApp = (() => {
634
  const live=$('reminderDialogNotice');if(live){if(live.textContent!==message)live.textContent=message;live.hidden=!count;}
635
  b.hidden=!count;
636
  const signature=JSON.stringify(s.items.map(x=>[x.id,x.target,x.end,x.lastNotified,x.notice,x.active]));
637
- if(signature!==personalSignature){personalSignature=signature;const ruler=$('ruler');for(const cell of Array.from(ruler.children).filter(x=>x.className==='hour')){for(const row of Array.from(cell.children).filter(x=>x.className==='personal-hour'))row.remove();paintPersonal(cell,Number(cell.dataset.start));}}
638
  }catch{$('reminderNotice').hidden=false;$('reminderNotice').textContent=ru().storageError;}}
639
  function refreshPersonal(){personalSignature='';tickPersonal();}
640
  function initPersonal(){const c=registry('user_time_markers').reminder_system;
@@ -667,9 +709,24 @@ const RegistryApp = (() => {
667
  const tick=make('span');tick.className='tick';tick.setAttribute('aria-hidden','true');
668
  const caption=make('span',label);caption.className='label';caption.setAttribute('aria-hidden','true');hourButton.append(tick,caption);paintCell(b,date.getTime());paintPersonal(b,date.getTime());ruler.appendChild(b);
669
  }
 
670
  const marker=make('div');marker.id='nowMarker';marker.className='now-marker';marker.setAttribute('aria-hidden','true');const markerLabel=make('span');markerLabel.id='nowMarkerLabel';markerLabel.className='now-marker-label';marker.appendChild(markerLabel);ruler.prepend(marker);
671
  shell.scrollLeft=initialScroll?offset*width:Math.max(0,Math.floor((Date.now()-start.getTime())/3600000)*width);initialScroll=true;updateCurrentMarker(Date.now());
672
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
673
  async function start(){
674
  // No embedded domain-data fallback: a missing registry must remain visible.
675
  const results=await Promise.allSettled(files.map(async name=>{
 
111
  if(group==='worship')array(x.sources).forEach(id=>{const s=registry('worship_fiqh').sources[id];if(s?.url)link($('adaptivePopupBody'),s.title,s.url);});
112
  if(group==='quran'||group==='providers')link($('adaptivePopupBody'),ui.source+' — '+x.name,x.documentation_url||x.base_url);
113
  if(x.source?.url)link($('adaptivePopupBody'),x.source.name||ui.source,x.source.url);
114
+ if(group==='events'){
115
+ if(x.calendar_rule?.requires_month_confirmation){para(ui.monthConfirmation.required);$('adaptivePopupActions').appendChild(button(ui.calendarSettings,calendarSettings));}
116
+ if(x.user_schedule)$('adaptivePopupActions').appendChild(button(ui.seasonSchedule.title,()=>seasonSettings(x)));
117
+ }
118
  array(x.references).forEach(r=>{if(typeof r==='string')para(r);else if(r.url)link($('adaptivePopupBody'),r.title||ui.source,r.url);});
119
  related(kind,x);back(returnView||(()=>list(kind,group)));
120
  });
 
265
  function hourSettings(start){
266
  show('worship',{title:hourAccessibleLabel(new Date(start).getHours()),compact:true},()=>{
267
  $('adaptivePopupBody').appendChild(button(ui.adhkar.title,()=>adhkarHome(start)));
268
+ $('adaptivePopupBody').appendChild(button(ui.worshipSchedules,()=>list('worship','events')));
269
  $('adaptivePopupActions').appendChild(button(ru().add,()=>reminderChoose(start)));
270
  $('adaptivePopupBody').appendChild(button(ru().settings,reminderSettings));
271
  $('adaptivePopupBody').appendChild(button(ru().tools,remindersHome));
 
313
  }
314
  function hijriParts(ms){
315
  const id=(visual.runtime_styles.current_time_calendars||[]).find(c=>c.adjustable)?.id||'islamic';
316
+ return HijriCalendarEngine.parts(ms,{calendarId:id,offsetDays:getSaved('clock_calendar_adjustment_v1',0),maxOffsetDays:visual.runtime_styles.calendar_adjustment_limit,confirmations:getSaved(registry('islamic_events').calendar_confirmation?.storage_key,[])});
317
  }
318
  function eventCalendarMatches(event,ms,forBlocking=false){
319
  return HijriCalendarEngine.matches(event,ms,{parts:hijriParts,forBlocking});
 
328
  const adhkarConfig=()=>registry('islamic_events').reminder_preferences;
329
  const isAdhkar=event=>Boolean(adhkarConfig()&&event.action===adhkarConfig().event_action);
330
  const adhkarReady=()=>adhkarConfig()?.ui_contract_version===2;
331
+ function seasonPreference(event){return getSaved(registry('islamic_events').scheduling_policy.season_preferences_key,{})[event.id]||{enabled:event.user_schedule?.default_enabled===true,weekdays:[],time:''};}
332
+ function seasonSettings(event){
333
+ const labels=ui.seasonSchedule,p=seasonPreference(event);
334
+ show('worship',{title:title(event),text:labels.note},()=>{
335
+ const enabled=reminderField(labels.enable,'checkbox','');enabled.checked=p.enabled;
336
+ const weekdays=labels.weekdays.map((label,index)=>{const field=reminderField(label,'checkbox','');field.checked=p.weekdays.includes(index);return field;});
337
+ const time=reminderField(labels.time,'time',p.time);
338
+ $('adaptivePopupActions').appendChild(button(ru().save,()=>{
339
+ const selected=weekdays.flatMap((field,index)=>field.checked?[index]:[]);
340
+ if(enabled.checked&&(!selected.length||!/^([01]\d|2[0-3]):[0-5]\d$/.test(time.value))){para(labels.invalid);return;}
341
+ const key=registry('islamic_events').scheduling_policy.season_preferences_key,state=getSaved(key,{});
342
+ state[event.id]={enabled:enabled.checked,weekdays:selected,time:time.value};
343
+ try{localStorage.setItem(key,JSON.stringify(state));}catch{para(ru().storageError);return;}
344
+ buildNotices();buildRuler();detail(eventScreen(event),'events',event);
345
+ }));back(()=>detail(eventScreen(event),'events',event));
346
+ });
347
+ }
348
  function adhkarPreference(event){
349
  const c=adhkarConfig(),saved=getSaved(c.storage_key,{}),value=saved[event.id];
350
  return {enabled:Boolean(getSaved(event.activation.storage_key,event.activation.default_enabled)),mode:c.default_mode,trigger:event.triggers[0].when,offset:0,time:'',sound:c.default_sound,...(value&&typeof value==='object'?value:{})};
 
383
  return registry('islamic_events').events.filter(e=>{
384
  if(!eventEnabled(e))return false;const c=e.calendar_rule||{},t=e.time_rule||{};
385
  if(e.display?.timeline===false||t.type==='conditional_prayer_relative'||t.type==='trigger_only'||!eventCalendarMatches(e,start)||eventBlockedOn(e,start))return false;
386
+ if(['full_day_worship','full_day','season_window','month_window'].includes(t.type))return true;
387
+ if(t.rule_id)return solarPeriods.some(p=>p.id===t.rule_id&&p.start<end&&p.end>start);
388
  if(t.start&&t.end){return solarDays.some(d=>d.boundaries[t.start]!=null&&d.boundaries[t.end]!=null&&d.boundaries[t.start]<end&&d.boundaries[t.end]>start);}
389
  if(Array.isArray(t.windows))return t.windows.some(w=>solarDays.some(d=>d.boundaries[w.start]!=null&&d.boundaries[w.end]!=null&&d.boundaries[w.start]<end&&d.boundaries[w.end]>start));
390
  return false;
 
430
  for(const p of entries){const label=periodIcon(p)+' '+ruleTitle(p.rule)+(style.prayer_entry_markers.show_time?' '+timeText(p.start):'');const entry=button(label,()=>periodDetails(p));entry.setAttribute('aria-label',periodTitle(p)+' — '+timeText(p.start));entry.className='prayer-entry';entry.dataset.ruleId=p.id;entry.dataset.time=String(p.start);entry.dataset.timelineTime=String(p.start);entry.style.position='absolute';entry.style.top='6px';entry.style.left='4px';entry.style.zIndex='3';controls.push(entry);}
431
 
432
  }
433
+ const marks=[];
434
  for(const d of solarDays)for(const id of style.boundary_markers||[]){
435
  const t=d.boundaries[id],def=boundary(id);if(!def||t==null||t<start||t>=end)continue;
436
  const entry=button((icon(id)?icon(id)+' ':'')+def.label+' '+timeText(t),()=>boundaryInfo(def,t));
437
+ entry.dataset.boundaryId=id;entry.dataset.time=String(t);entry.dataset.timelineTime=String(t);entry.className='boundary-entry';marks.push(entry);
438
+ }
439
+ marks.sort((a,b)=>Number(a.dataset.time)-Number(b.dataset.time));
440
+ marks.forEach((entry,index)=>{entry.style.top=(164+index*40)+'px';controls.push(entry);});
441
+ const seenNotices=new Set();
442
+ for(const notice of timedNotices){
443
+ const event=notice.event,t=notice.at;
444
+ const key=notice.key+':'+t;
445
+ if(t<start||t>=end||seenNotices.has(key)||!eventEnabled(event)||event.display?.timeline===false)continue;
446
+ seenNotices.add(key);
447
+ const symbol=icon(visual.event_action_mapping[event.action]);
448
+ const entry=button((symbol?symbol+' ':'')+(notice.trigger.popup?.title||notice.trigger.title||title(event))+' '+timeText(t),()=>detail(eventScreen(event),'events',event));
449
+ entry.dataset.eventId=event.id;entry.dataset.time=String(t);entry.dataset.timelineTime=String(t);entry.className='event-marker';controls.push(entry);
450
  }
 
 
451
  controls.sort((a,b)=>Number(a.dataset.timelineTime)-Number(b.dataset.timelineTime)).forEach(x=>cell.appendChild(x));
452
  }
453
  function calendarText(c,now){
454
  try{const date=new Date(now),offset=Number(getSaved('clock_calendar_adjustment_v1',0));
455
+ if(c.adjustable){const h=hijriParts(now);if(h?.confirmed)return [h.day,h.month,h.year].join('/')+' '+c.label;}
456
  if(c.adjustable&&Number.isInteger(offset)&&Math.abs(offset)<=visual.runtime_styles.calendar_adjustment_limit)date.setDate(date.getDate()+offset);
457
  return new Intl.DateTimeFormat(document.documentElement.lang,{calendar:c.id,year:'numeric',month:'long',day:'numeric'}).format(date)+' '+c.label;
458
  }catch{return ui.calendarUnavailable;}
459
  }
460
  function calendarSettings(){show('worship',{title:ui.calendarSettings,text:ui.calendarNote},()=>{
461
  const value=reminderField(ui.calendarAdjustment,'number',getSaved('clock_calendar_adjustment_v1',0));value.min=-visual.runtime_styles.calendar_adjustment_limit;value.max=visual.runtime_styles.calendar_adjustment_limit;value.step=1;
462
+ $('adaptivePopupActions').appendChild(button(ui.apply,()=>{const n=Number(value.value);if(!Number.isInteger(n)||Math.abs(n)>visual.runtime_styles.calendar_adjustment_limit){para(ui.calendarInvalid);return;}save('clock_calendar_adjustment_v1',n);recalculate();close();}));
463
+ $('adaptivePopupBody').appendChild(button(ui.monthConfirmation.title,monthConfirmation));
464
  });}
465
+ function monthConfirmation(){
466
+ const config=registry('islamic_events').calendar_confirmation,labels=ui.monthConfirmation;
467
+ show('worship',{title:labels.title,text:labels.note},()=>{
468
+ const h=hijriParts(Date.now()),year=reminderField(labels.year,'number',h?.year||''),month=reminderField(labels.month,'number',h?.month||'');
469
+ year.min=1;year.step=1;month.min=1;month.max=12;month.step=1;
470
+ const start=reminderField(labels.start,'date',''),length=reminderSelect(labels.length,config.length_options.map(n=>[String(n),String(n)]),String(config.length_options[0]));
471
+ const confirmations=getSaved(config.storage_key,[]);
472
+ confirmations.forEach(item=>{
473
+ para(item.year+'/'+item.month+' — '+item.start+' — '+item.length);
474
+ $('adaptivePopupBody').appendChild(button(labels.remove+' '+item.year+'/'+item.month,()=>{
475
+ save(config.storage_key,confirmations.filter(x=>x!==item));recalculate();monthConfirmation();
476
+ }));
477
+ });
478
+ $('adaptivePopupActions').appendChild(button(labels.save,()=>{
479
+ const item={year:Number(year.value),month:Number(month.value),start:start.value,length:Number(length.value)};
480
+ if(!HijriCalendarEngine.validConfirmation(item)){para(labels.invalid);return;}
481
+ const rest=confirmations.filter(x=>x.year!==item.year||x.month!==item.month),a=Date.parse(item.start+'T00:00:00Z'),z=a+item.length*86400000;
482
+ if(rest.some(x=>{const b=Date.parse(x.start+'T00:00:00Z');return a<b+x.length*86400000&&z>b;})){para(labels.invalid);return;}
483
+ try{localStorage.setItem(config.storage_key,JSON.stringify([...rest,item]));}catch{para(ru().storageError);return;}
484
+ recalculate();monthConfirmation();
485
+ }));back(calendarSettings);
486
+ });
487
+ }
488
  function updateCurrentMarker(now){
489
  const width=Number($('ruler').dataset.cellWidth),marker=$('nowMarker');
490
  if(marker){marker.style.left=((now-timelineStart)/3600000*width)+'px';marker.hidden=now<timelineStart||now>=timelineStart+layout.total_hours*3600000;
 
525
  function buildNotices(){
526
  timedNotices=[];const runtime=profile()?.notice_runtime;if(!runtime)return;
527
  const localToday=new Date();localToday.setHours(0,0,0,0);
528
+ const days=Array.from({length:6},(_,i)=>{const date=new Date(localToday);date.setDate(date.getDate()+i-2);return Date.UTC(date.getFullYear(),date.getMonth(),date.getDate());});
529
+ timedNotices=WorshipEventEngine.compile({events:registry('islamic_events').events,days,solarDays,periods:solarPeriods,runtime,
530
+ policy:registry('islamic_events').scheduling_policy,enabled:eventEnabled,blocked:eventBlockedOn,matches:eventCalendarMatches,parts:hijriParts,
531
+ preference:event=>isAdhkar(event)?adhkarPreference(event):null,seasonPreference,
532
+ solarAvailable:Boolean(observer&&SolarEngine.ready()&&(!methodChoice()||prayerEngineReady)),
533
+ defaultSound:getSaved(registry('user_time_markers').reminder_system?.storage_key,{})?.settings?.sound_enabled===true});
534
+ const end=new Date(localToday);end.setDate(end.getDate()+4);
535
+ const start=new Date(localToday);start.setDate(start.getDate()-2);
536
+ timedNotices.push(...WorshipEventEngine.eclipses({astronomy:registry('astronomy_events'),event:registry('islamic_events').events.find(e=>e.id==='eclipse_prayer'),location:observer,start:start.getTime(),end:end.getTime()}));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
537
  timedNotices.sort((a,b)=>a.at-b.at||b.priority-a.priority);
538
  for(const [key,pending] of pendingTimedNotices)if(!timedNotices.some(n=>n.key===key&&n.at===pending.at))pendingTimedNotices.delete(key);
539
  }
540
  function tickNotices(now){
541
  const runtime=profile()?.notice_runtime;if(!runtime)return;
542
  const ledger=getSaved('clock_popup_impressions_v1',{});
543
+ for(const n of timedNotices)if(now>=n.at&&now-n.at<runtime.due_window_seconds*1000&&(n.expires==null||now<n.expires)&&(ledger[n.key]?.count||0)<n.max)pendingTimedNotices.set(n.key,n);
544
  if(!document.hidden&&$('adaptivePopup').hidden===false)return;
545
+ for(const [key,n]of pendingTimedNotices)if(n.expires!=null&&now>=n.expires)pendingTimedNotices.delete(key);
546
  const due=[...pendingTimedNotices.values()].filter(n=>eventEnabled(n.event)&&(ledger[n.key]?.count||0)<n.max).sort((a,b)=>b.priority-a.priority||a.at-b.at)[0];
547
  if(!due)return;
548
  pendingTimedNotices.delete(due.key);
 
550
  for(const [key,value] of Object.entries(ledger))if(now-value.at>7*86400000)delete ledger[key];
551
  ledger[due.key]={count:(ledger[due.key]?.count||0)+1,at:now};save('clock_popup_impressions_v1',ledger);
552
  const popup=due.trigger.popup||{};
553
+ const kind=eventScreen(due.event),noticeTitle=popup.title||due.trigger.title||title(due.event),noticeText=popup.text||due.trigger.popup_text||due.event.display?.text||'';
554
  if(due.sound!==false)playReminderSound();notifySystem(noticeTitle,noticeText,{kind,eventId:due.event.id});
555
  if(!document.hidden&&$('adaptivePopup').hidden!==false)show(kind,{title:noticeTitle,text:noticeText,media:icon(visual.event_action_mapping[due.event.action])},()=>{
556
  back(()=>detail(kind,'events',due.event));
 
591
  $('adaptivePopupActions').appendChild(button(ru().add,()=>reminderChoose(selectedHour)));
592
  $('adaptivePopupActions').appendChild(button(ru().settings,reminderSettings));
593
  $('adaptivePopupActions').appendChild(button(ui.adhkar.title,()=>adhkarHome(selectedHour)));
594
+ $('adaptivePopupActions').appendChild(button(ui.worshipSchedules,()=>list('worship','events')));
595
  if(s.items.length)$('adaptivePopupActions').appendChild(button(ru().removeSelected,()=>remindersRemoveSelected(selectedHour)));
596
  if(!s.items.length)para(ru().empty);
597
  s.items.slice().sort((a,b)=>Boolean(b.notice)-Boolean(a.notice)||reminderMoment(a)-reminderMoment(b)).forEach(x=>{
 
676
  const live=$('reminderDialogNotice');if(live){if(live.textContent!==message)live.textContent=message;live.hidden=!count;}
677
  b.hidden=!count;
678
  const signature=JSON.stringify(s.items.map(x=>[x.id,x.target,x.end,x.lastNotified,x.notice,x.active]));
679
+ if(signature!==personalSignature){personalSignature=signature;const ruler=$('ruler');for(const cell of Array.from(ruler.children).filter(x=>x.className==='hour')){for(const row of Array.from(cell.children).filter(x=>x.className==='personal-hour'))row.remove();paintPersonal(cell,Number(cell.dataset.start));}positionTimelineRows();}
680
  }catch{$('reminderNotice').hidden=false;$('reminderNotice').textContent=ru().storageError;}}
681
  function refreshPersonal(){personalSignature='';tickPersonal();}
682
  function initPersonal(){const c=registry('user_time_markers').reminder_system;
 
709
  const tick=make('span');tick.className='tick';tick.setAttribute('aria-hidden','true');
710
  const caption=make('span',label);caption.className='label';caption.setAttribute('aria-hidden','true');hourButton.append(tick,caption);paintCell(b,date.getTime());paintPersonal(b,date.getTime());ruler.appendChild(b);
711
  }
712
+ positionTimelineRows();
713
  const marker=make('div');marker.id='nowMarker';marker.className='now-marker';marker.setAttribute('aria-hidden','true');const markerLabel=make('span');markerLabel.id='nowMarkerLabel';markerLabel.className='now-marker-label';marker.appendChild(markerLabel);ruler.prepend(marker);
714
  shell.scrollLeft=initialScroll?offset*width:Math.max(0,Math.floor((Date.now()-start.getTime())/3600000)*width);initialScroll=true;updateCurrentMarker(Date.now());
715
  }
716
+ function positionTimelineRows(){
717
+ const ruler=$('ruler'),cells=[...ruler.querySelectorAll('.hour')];
718
+ const upperHeight=Math.max(270,...cells.map(cell=>164+cell.querySelectorAll('.boundary-entry').length*40));
719
+ let lowerRows=0;
720
+ for(const cell of cells){
721
+ cell.style.height=upperHeight+'px';
722
+ const reminders=[...cell.querySelectorAll('.event-marker,.personal-hour')].sort((a,b)=>Number(a.dataset.timelineTime)-Number(b.dataset.timelineTime));
723
+ reminders.forEach((entry,index)=>{entry.style.top=(upperHeight+20+index*70)+'px';entry.style.bottom='auto';});
724
+ lowerRows=Math.max(lowerRows,reminders.length);
725
+ }
726
+ ruler.querySelector('.reminder-axis')?.remove();
727
+ if(lowerRows){const axis=make('div');axis.className='reminder-axis';axis.setAttribute('aria-hidden','true');axis.style.top=(95+upperHeight+8)+'px';ruler.prepend(axis);}
728
+ ruler.style.height=(95+upperHeight+(lowerRows?20+lowerRows*70:25))+'px';
729
+ }
730
  async function start(){
731
  // No embedded domain-data fallback: a missing registry must remain visible.
732
  const results=await Promise.allSettled(files.map(async name=>{
visual_states_registry.json CHANGED
@@ -266,6 +266,7 @@
266
  }
267
  },
268
  "event_action_mapping": {
 
269
  "voluntary_fasting": "fasting",
270
  "adhkar_reading": "adhkar",
271
  "friday_worship_bundle": "friday",
@@ -649,8 +650,23 @@
649
  },
650
  "hourSettings": "الساعة",
651
  "solarRestrictionEstimate": "هذه نافذة شمسية تقديرية وفق إعدادات الحساب، وليست نهيًا يبدأ بدخول العصر. تفاصيل الاستثناءات في المصادر.",
652
- "calendarSettings": "تصحيح التاريخ الهجري",
653
- "calendarNote": "يعرض التطبيق التاريخ الهجري الذي يحسبه المتصفح. قد يختلف يومًا عن التاريخ الرسمي بسبب اختلاف ثبوت بداية الشهر، لذلك تستطيع تقديمه أو تأخيره يدويًا. هذا التصحيح يغيّر التاريخ المعروض فقط، ولا يغيّر مواقيت الصلاة ولا يعني وجود مشكلة في محرك الصلاة.",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
654
  "calendarAdjustment": "تقديم أو تأخير التاريخ الهجري بالأيام",
655
  "calendarInvalid": "أدخل عدد أيام صحيحًا بين −2 و2.",
656
  "calendarUnavailable": "التقويم غير متاح في هذا المتصفح.",
@@ -780,6 +796,7 @@
780
  "calendar_adjustment_limit": 2
781
  },
782
  "marker_icons": {
 
783
  "alarm": {
784
  "label": "منبّه",
785
  "emoji": "🔔"
 
266
  }
267
  },
268
  "event_action_mapping": {
269
+ "eclipse_prayer": "eclipse",
270
  "voluntary_fasting": "fasting",
271
  "adhkar_reading": "adhkar",
272
  "friday_worship_bundle": "friday",
 
650
  },
651
  "hourSettings": "الساعة",
652
  "solarRestrictionEstimate": "هذه نافذة شمسية تقديرية وفق إعدادات الحساب، وليست نهيًا يبدأ بدخول العصر. تفاصيل الاستثناءات في المصادر.",
653
+ "calendarSettings": "إعدادات التاريخ الهجري",
654
+ "worshipSchedules": "تنبيهات العبادات والمناسبات",
655
+ "calendarNote": "تصحيح الأيام يغيّر التاريخ الهجري ومواعيد المناسبات التابعة له، ولا يغيّر مواقيت الصلاة. للمناسبات المشروطة بثبوت الشهر، أدخل بداية الشهر التي أعلنتها الجهة الرسمية؛ الحساب وحده لا يُعد تأكيدًا.",
656
+ "monthConfirmation": {
657
+ "title": "تأكيد بداية شهر هجري",
658
+ "year": "السنة الهجرية", "month": "رقم الشهر الهجري", "start": "التاريخ الميلادي لأول يوم من الشهر",
659
+ "length": "عدد أيام الشهر المعتمد", "save": "حفظ تأكيد الشهر", "remove": "إزالة التأكيد",
660
+ "invalid": "تحقق من السنة والشهر وتاريخ البداية وعدد الأيام. لا يجوز تداخل شهرين مؤكدين.",
661
+ "note": "استخدم الإعلان الرسمي لبداية الشهر. حدّث عدد أيامه عند ثبوت نهايته؛ لا يفترض التطبيق ثبوت شهر تالٍ تلقائيًا.",
662
+ "required": "تعمل تنبيهات هذا الحدث خلال الشهر الذي أكّدت بدايته في إعدادات التاريخ الهجري."
663
+ },
664
+ "seasonSchedule": {
665
+ "title": "تخصيص تذكير الموسم", "enable": "تفعيل التذكير الأسبوعي داخل الموسم",
666
+ "weekdays": ["الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"],
667
+ "time": "وقت التذكير", "invalid": "اختر يومًا واحدًا على الأقل ووقتًا صحيحًا.",
668
+ "note": "اختر أيام ظهور التذكير ووقته. لا يسجل التطبيق عدد أيام الصيام أو الإنجاز."
669
+ },
670
  "calendarAdjustment": "تقديم أو تأخير التاريخ الهجري بالأيام",
671
  "calendarInvalid": "أدخل عدد أيام صحيحًا بين −2 و2.",
672
  "calendarUnavailable": "التقويم غير متاح في هذا المتصفح.",
 
796
  "calendar_adjustment_limit": 2
797
  },
798
  "marker_icons": {
799
+ "eclipse": {"label": "كسوف أو خسوف", "emoji": "🌘"},
800
  "alarm": {
801
  "label": "منبّه",
802
  "emoji": "🔔"
worship_event_engine.js ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict';
2
+
3
+ // Pure registry scheduler. Solar geometry and religious rules remain in their owners.
4
+ globalThis.WorshipEventEngine = (() => {
5
+ const DAY=86400000,MINUTE=60000;
6
+ const civil=stamp=>{const d=new Date(stamp);return new Date(d.getUTCFullYear(),d.getUTCMonth(),d.getUTCDate(),12);};
7
+ const clock=(date,value)=>{if(!/^([01]\d|2[0-3]):[0-5]\d$/.test(value||''))return null;const d=new Date(date),[h,m]=value.split(':').map(Number);d.setHours(h,m,0,0);return d.getTime();};
8
+ function compile({events,days,solarDays,periods,runtime,policy,enabled,blocked,matches,parts,preference,seasonPreference,solarAvailable,defaultSound=false}){
9
+ const notices=[];
10
+ for(const stamp of days){
11
+ const date=civil(stamp),hijri=parts(date.getTime());
12
+ for(const event of events){
13
+ if(!enabled(event)||event.display?.popup===false||event.time_rule?.type==='astronomy_relative'||!matches(event,date.getTime())||blocked(event,date.getTime()))continue;
14
+ const pref=preference(event),repeat=event.repeat_policy||{};
15
+ const triggers=event.triggers||event.items?.map(item=>({...item,when:item.trigger}))||[];
16
+ for(const original of triggers){
17
+ const trigger=pref?{...original,when:pref.trigger,offset_minutes:pref.offset}:original;
18
+ let when=trigger.when,at=null;
19
+ if(when&&typeof when==='object'){
20
+ if(!hijri||(when.hijri_day!=null&&when.hijri_day!==hijri.day)||(when.hijri_month!=null&&when.hijri_month!==hijri.month))continue;
21
+ when=when.relative||policy.calendar_day_trigger;
22
+ }
23
+ if(pref?.mode==='clock')at=clock(date,pref.time);
24
+ else if(when==='user_configurable_within_season'){
25
+ const setting=seasonPreference(event);
26
+ if(!setting?.enabled||!setting.weekdays?.includes(date.getDay()))continue;
27
+ at=clock(date,setting.time);
28
+ }else{
29
+ const calendarBinding=policy.calendar_triggers?.[when];
30
+ if(calendarBinding){
31
+ if(!hijri||(calendarBinding.day!=null&&hijri.day!==calendarBinding.day)||(calendarBinding.month!=null&&hijri.month!==calendarBinding.month))continue;
32
+ when=calendarBinding.relative;
33
+ }
34
+ if(!solarAvailable)continue;
35
+ const special=policy.window_triggers?.[when];
36
+ if(special){
37
+ let a,z;
38
+ if(special.rule_id){const period=periods.find(p=>p.day===stamp&&p.id===special.rule_id&&!p.preference);a=period?.start;z=period?.end;}
39
+ else{const b=solarDays.find(d=>d.day===stamp)?.boundaries||{};a=b[special.start];z=b[special.end];}
40
+ if(Number.isFinite(a)&&Number.isFinite(z)&&z>a)at=a+(z-a)*special.fraction;
41
+ }else{
42
+ const binding=runtime.trigger_bindings[when];if(!binding)continue;
43
+ // A Hijri night belongs to the following civil day, beginning at the previous sunset.
44
+ const nightShift=event.time_rule?.type==='night_window'?-1:0;
45
+ const source=solarDays.find(d=>d.day===stamp+((binding.day_shift||0)+nightShift)*DAY);
46
+ const boundary=source?.boundaries[binding.boundary];
47
+ if(Number.isFinite(boundary))at=boundary+(trigger.offset_minutes||0)*MINUTE*(binding.offset_sign||1);
48
+ }
49
+ }
50
+ if(!Number.isFinite(at))continue;
51
+ const max=trigger.max_per_trigger??repeat.max_per_trigger??repeat.max_per_day??repeat.max_per_night;
52
+ if(!Number.isInteger(max)||max<1)continue;
53
+ // Aggregate daily/nightly limits across all their triggers; preserve legacy per-trigger keys.
54
+ const scope=repeat.max_per_day!=null?'day':repeat.max_per_night!=null?'night':trigger.id;
55
+ notices.push({key:event.id+':'+scope+':'+stamp,at,max,event,trigger,sound:pref?pref.sound===true:defaultSound,priority:event.priority||0});
56
+ }
57
+ }
58
+ }
59
+ return notices.sort((a,b)=>a.at-b.at||b.priority-a.priority);
60
+ }
61
+ const eclipseCache=new Map();
62
+ function visibleInterval(A,body,observer,start,end){
63
+ const altitude=t=>{const d=new Date(t),eq=A.Equator(body,d,observer,true,true);return A.Horizon(d,observer,eq.ra,eq.dec,'normal').altitude;};
64
+ let first=start;
65
+ // Conservative center-above-horizon visibility, solved by the same engine.
66
+ if(altitude(first)<=0){const rise=A.SearchAltitude(body,observer,1,new Date(start),(end-start)/DAY,0);if(!rise)return null;first=rise.date.getTime();}
67
+ const set=A.SearchAltitude(body,observer,-1,new Date(first+1000),(end-first)/DAY,0);
68
+ const last=set?Math.min(end,set.date.getTime()):end;
69
+ return last>first?{start:first,end:last}:null;
70
+ }
71
+ function eclipses({astronomy,event,location,start,end,A=globalThis.Astronomy}){
72
+ if(!A||!location||!event||event.enabled===false||astronomy.enabled===false)return [];
73
+ const cacheKey=JSON.stringify([location,start,end]);let occurrences=eclipseCache.get(cacheKey);
74
+ if(!occurrences){
75
+ occurrences=[];const observer=new A.Observer(location.lat,location.lng,location.height||0);
76
+ for(const type of astronomy.event_types.filter(t=>t.religious_relation?.practice_id===event.id&&t.enabled!==false)){
77
+ try{
78
+ const solar=type.id==='solar_eclipse';
79
+ let found=solar?A.SearchLocalSolarEclipse(new Date(start-DAY),observer):A.SearchLunarEclipse(new Date(start-DAY));
80
+ for(let i=0;i<8;i++){
81
+ const peak=(solar?found.peak.time:found.peak).date.getTime();if(peak>end+DAY)break;
82
+ const begin=solar?found.partial_begin.time.date.getTime():peak-found.sd_partial*MINUTE;
83
+ const finish=solar?found.partial_end.time.date.getTime():peak+found.sd_partial*MINUTE;
84
+ if(finish>=start&&finish>begin){const visible=visibleInterval(A,solar?'Sun':'Moon',observer,begin,finish);if(visible)occurrences.push({typeId:type.id,peak,...visible});}
85
+ found=solar?A.NextLocalSolarEclipse(found.peak.time,observer):A.NextLunarEclipse(found.peak);
86
+ }
87
+ }catch{/* No invented eclipse when ephemeris calculation fails. */}
88
+ }
89
+ eclipseCache.set(cacheKey,occurrences);if(eclipseCache.size>4)eclipseCache.delete(eclipseCache.keys().next().value);
90
+ }
91
+ const notices=[];
92
+ for(const occurrence of occurrences){
93
+ const type=astronomy.event_types.find(t=>t.id===occurrence.typeId),max=astronomy.defaults.max_popup_per_event_phase;
94
+ if(!Number.isInteger(max)||max<1)continue;
95
+ for(const phase of type.triggers){
96
+ const at=phase.when==='before_event'?occurrence.start-(phase.offset_minutes||0)*MINUTE:phase.when==='event_start'?occurrence.start:phase.when==='event_peak'?occurrence.peak:null;
97
+ if(!Number.isFinite(at)||at<start||at>=end||(phase.when==='event_peak'&&(at<occurrence.start||at>=occurrence.end)))continue;
98
+ const active=phase.when!=='before_event';
99
+ const trigger={...phase,title:type.title,popup_text:active?event.notice_text.active:event.notice_text.advance};
100
+ notices.push({key:event.id+':'+type.id+':'+occurrence.peak+':'+phase.id,at,max,event,trigger,sound:false,priority:type.priority,expires:active?occurrence.end:occurrence.start});
101
+ }
102
+ }
103
+ return notices;
104
+ }
105
+ return Object.freeze({compile,eclipses});
106
+ })();