al-quran.reflectslight.io/build/al-quran/js/loaders/surah-stream-loader.js

1 line
3.1 KiB
JavaScript
Raw Normal View History

2024-08-30 19:58:39 +02:00
(()=>{"use strict";const e=(e,t)=>({priority:1,group:"fonts",requestId:"font",href:t,fontFamily:e}),t=(e,t)=>({priority:4,group:"scripts",requestId:"script",href:e,props:t}),n=(e,t)=>({priority:5,group:"json",requestId:"json",href:e,props:t}),r=e=>e,o={font(e){const{fontFamily:t,href:n}=e;return new FontFace(t,n).load()},script(e,t={}){const{href:n}=e;return fetch(n,t).then((e=>e.text())).then((t=>({type:"application/javascript",text:t,...e.props}))).then((e=>Object.assign(document.createElement("script"),e)))},css(e,t={}){const{href:n}=e;return fetch(n,t).then((e=>e.text())).then((e=>({innerText:e}))).then((e=>Object.assign(document.createElement("style"),e)))},image(e){const{href:t}=e;return new Promise(((e,n)=>{const r=document.createElement("img");r.onload=()=>e(r),r.onerror=n,r.src=t}))},json(e,t={}){const{href:n}=e;return fetch(n,t).then((e=>e.text())).then((e=>({type:"application/json",text:e}))).then((t=>Object.assign(t,e.props||{}))).then((e=>Object.assign(document.createElement("script"),e)))}};var s=Object.defineProperty,a=Object.getOwnPropertySymbols,c=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,u=(e,t,n)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;!function(){const s=document.documentElement,p=s.querySelector("meta[name='revision']").getAttribute("content"),{surahId:l}=document.querySelector(".root").dataset,h={name:s.lang,direction:s.dir,displayName:""},m=s.querySelector(".postman.loader"),f=s.querySelector(".css.postman"),d=m.querySelector("progress"),y=m.querySelector(".percentage");(function(...e){const t=Object.create(null),n={fonts:[],images:[],css:[],scripts:[],json:[]},[r,s]=function(e){const t=[];let n=e=>e;return e.forEach((e=>{"function"==typeof e?n=e:t.push(e)})),[t,n]}(e);r.sort(((e,t)=>e.priority>=t.priority?1:-1));let a=0;const c=e=>(a++,a<=r.length&&s(a/r.length*100),e);return t.fetch=async()=>(await Promise.all((()=>{const e=r.map((e=>{if("fontFamily"in e)return(0,o.font)(e).then((e=>c(e))).then((e=>n.fonts.push(e))).then((()=>n));if("font"!==e.requestId&&"fonts"!==e.group){const t=o[e.requestId],r=n[e.group];return t(e).then((e=>c(e))).then((e=>r.push(e))).then((()=>n))}return null}));return e})()),n),t})(t(`/js/main/vendor.js?v=${p}`,{id:0}),t(`/js/main/surah-stream.js?v=${p}`,{id:1}),e("Kanit Regular","url(/fonts/kanit-regular.ttf)"),n(`/json/${s.lang}/${l}/info.json?v=${p}`,{className:"json surahinfo"}),n(`/json/${s.lang}/${l}/surah.json?v=${p}`,{className:"json surah"}),n(`/json/durations/${l}.json?v=${p}`,{className:"json durations"}),r((e=>{d.value=e,y.innerText=function(e,t,n={}){const r="ar"===e.name?"ar-SA":e.name;return new Intl.NumberFormat(r,((e,t)=>{for(var n in t||(t={}))c.call(t,n)&&u(e,n,t[n]);if(a)for(var n of a(t))i.call(t,n)&&u(e,n,t[n]);return e})({maximumFractionDigits:1},n)).format(t)}(h,Number(e.toFixed(0)))}))).fetch().then((e=>{[m,f].forEach((e=>e.remove())),e.fonts.forEach((e=>document.fonts.add(e))),e.css.forEach((e=>document.head.appendChild(e))),e.json.forEach((e=>document.body.appendChild(e))),e.scripts.sort((e=>e.id)).forEach((e=>{document.body.removeChild(document.body.appendChild(e))}))}))}()})();