iptv-org.github.io/docs/_app/chunks/store-93a026ed.js
2022-04-22 03:06:56 +03:00

1 line
3.2 KiB
JavaScript

import{D as c,X as b,_ as l,Y as m}from"./vendor-e06f8fa1.js";const $=c(""),w=c(!1),f=c([]),j=c({}),p=c([]);function C(t){const o=t.toLowerCase().match(/(".*?"|[^"\s]+)+(?=\s*|\s*$)/g)||[],n=[];for(let a of o){let h="_key";a.includes(":")&&([h,a]=a.split(":")),a=a.replace(/\"/g,""),h&&a&&n.push({field:h,value:a})}if(!n.length){w.set(!1),p.set(b(f));return}const i=b(f).filter(a=>{for(let h of n){if(!h.value)return!1;const u=new RegExp(h.value,"i");if(!a._searchable[h.field]||!u.test(a._searchable[h.field]))return!1}return!0});p.set(i),w.set(!0),console.log(".")}async function L(){let t=await fetch("https://iptv-org.github.io/api/countries.json").then(e=>e.json()).then(e=>e.length?e:[]).then(e=>e.map(s=>(s.expanded=!1,s))).then(e=>l.keyBy(e,"code")).catch(console.error);j.set(t);let o=await fetch("https://iptv-org.github.io/api/regions.json").then(e=>e.json()).then(e=>e.length?e:[]).then(e=>l.keyBy(e,"code")).catch(console.error),n=await fetch("https://iptv-org.github.io/api/subdivisions.json").then(e=>e.json()).then(e=>e.length?e:[]).then(e=>l.keyBy(e,"code")).catch(console.error),i=await fetch("https://iptv-org.github.io/api/languages.json").then(e=>e.json()).then(e=>e.length?e:[]).then(e=>l.keyBy(e,"code")).catch(console.error),a=await fetch("https://iptv-org.github.io/api/categories.json").then(e=>e.json()).then(e=>e.length?e:[]).then(e=>l.keyBy(e,"id")).catch(console.error),h=await fetch("https://iptv-org.github.io/api/streams.json").then(e=>e.json()).then(e=>e.length?e:[]).then(e=>l.groupBy(e,"channel")).catch(console.error),u=await fetch("https://iptv-org.github.io/api/guides.json").then(e=>e.json()).then(e=>e.length?e:[]).then(e=>l.groupBy(e,"channel")).catch(console.error),d=await fetch("https://iptv-org.github.io/api/channels.json").then(e=>e.json()).then(e=>e.map(s=>{s._raw=JSON.parse(JSON.stringify(s)),s._streams=h[s.id]||[],s._guides=u[s.id]||[];for(let y in s)switch(y){case"languages":s.languages=s.languages.map(r=>i[r]).filter(r=>r);break;case"broadcast_area":s.broadcast_area=s.broadcast_area.map(r=>{const[_,g]=r.split("/");switch(_){case"c":return t[g];case"r":return o[g];case"s":return n[g]}}).filter(r=>r);break;case"categories":s.categories=s.categories.map(r=>a[r]).filter(r=>r);break;case"country":s.country=t[s.country];break;case"subdivision":s.subdivision=n[s.subdivision];break}return s._searchable=k(s),s})).catch(e=>(console.error(e),[]));f.set(d),p.set(d)}function v(t){const o=t.native_name?m(t.native_name):null;return[t.id,t.name,t.native_name,o].map(n=>n||"").filter(n=>n).join("|").toLowerCase()}function k(t){const o={};for(let n in t)n.startsWith("_")||t[n]===null||t[n]===void 0||(Array.isArray(t[n])?o[n]=t[n].map(i=>i.name?i.name.toLowerCase():null).filter(i=>i).join(","):typeof t[n]=="object"&&t[n].name?o[n]=t[n].name.toLowerCase():o[n]=t[n].toString().toLowerCase());return o._key=v(t),o}function x(t,o){if(window.history.pushState){let n=t&&o?`?${t}=${o}`:"";n=n.replace(/\+/g,"%2B");const i=`${window.location.protocol}//${window.location.host}${window.location.pathname}${n}`,a={};a[t]=o,window.history.pushState(a,"",i),B(o)}}function B(t){const o=t?`${t} \xB7 iptv-org`:"iptv-org";document.title=o}export{C as a,B as b,f as c,L as d,j as e,p as f,w as h,$ as q,x as s};