Files
sm-bm-plugin/public/assets/remote-aOKX75Mt.js

2 lines
7.4 KiB
JavaScript

const b="remote.action",m="remote.state",x=300,G=1e4;const U=15e3;const F=1e4,Y=1e3;const S=["next","prev","first","last","goto","speak","notes","sources","special","back","clock-pause","clock","clock-reset","toolbar","scheme","sync"],y=/^[A-Za-z0-9_-]{8,64}$/;const A=new Set(S),M=new Set(["say","notes","srcs"]),k={next:"ArrowRight",prev:"ArrowLeft",first:"Home",last:"End",speak:"p",notes:"n",sources:"z",special:"s",back:"Escape","clock-pause":"t",clock:"c","clock-reset":"r",toolbar:"h",scheme:"j"};function Z(e){const n=k[e];return!n||n.toLowerCase()==="f"?null:n}function p(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function c(e,n,t){return typeof e=="number"&&Number.isInteger(e)&&e>=n&&e<=t}function N(e){if(!p(e))return null;const n=e.action,t=e.tab;if(typeof n!="string"||!A.has(n)||typeof t!="string"||t!==""&&!y.test(t))return null;const r=n;return r==="goto"?c(e.number,1,9999)?{action:r,number:e.number,tab:t}:null:e.number!==void 0?null:{action:r,tab:t}}function I(e){if(!p(e))return null;const{elapsed:n,slide_elapsed:t,paused:r,hidden:o,idle:l}=e;return!c(n,0,86400)||!c(t,0,86400)||typeof r!="boolean"||typeof o!="boolean"||typeof l!="boolean"?null:{elapsed:n,slide_elapsed:t,paused:r,hidden:o,idle:l}}function w(e){if(!p(e))return null;const{tab:n,claim:t,bye:r,number:o,total:l,special:i,has_special:a,panel:s,toolbar_hidden:u}=e;if(typeof n!="string"||!y.test(n)||typeof t!="boolean"||typeof r!="boolean"||!c(o,0,9999)||!c(l,0,9999)||o>l||typeof i!="boolean"||typeof a!="boolean"||typeof u!="boolean"||s!==null&&(typeof s!="string"||!M.has(s)))return null;const f=e.light===void 0?!1:e.light;if(typeof f!="boolean")return null;const d=I(e.clock);return d?{tab:n,claim:t,bye:r,number:o,total:l,special:i,has_special:a,panel:s,toolbar_hidden:u,light:f,clock:d}:null}function B(e){if(!p(e))return null;if(e.event===b){const n=N(e.payload);return n?{event:b,payload:n}:null}if(e.event===m){const n=w(e.payload);return n?{event:m,payload:n}:null}return null}function $(){const e=globalThis.crypto;if(e&&typeof e.randomUUID=="function")return e.randomUUID();const n=new Uint8Array(16);if(e&&typeof e.getRandomValues=="function")e.getRandomValues(n);else for(let t=0;t<n.length;t++)n[t]=Math.floor(Math.random()*256);return Array.from(n,t=>t.toString(16).padStart(2,"0")).join("")}function h(e){return!Number.isFinite(e)||e<=0?0:Math.min(86400,Math.floor(e))}function E(e){return!Number.isFinite(e)||e<=0?0:Math.min(9999,Math.floor(e))}function q(e,n,t,r={}){const o=E(e.total),l=Math.min(E(e.number),o);return{tab:t,claim:!!r.claim,bye:!!r.bye,number:l,total:o,special:e.special,has_special:e.hasSpecial,panel:e.panel,toolbar_hidden:e.toolbarHidden,light:!!r.light,clock:n?{elapsed:h(n.elapsed),slide_elapsed:h(n.slideElapsed),paused:n.paused,hidden:n.hidden,idle:n.idle}:{elapsed:0,slide_elapsed:0,paused:!1,hidden:!1,idle:!0}}}function W(e){let n=null;return{observe(t){const r=n===e;return t.bye?(t.tab===n&&(n=null),!1):((t.claim||n===null&&t.tab!==e)&&(n=t.tab),!r&&n===e)},activeTab:()=>n,isActive:()=>n===e,shouldApply(t){return n===e&&(t.tab===""||t.tab===e)}}}function J(e,n=!1){const t=Number.isFinite(e)?Math.min(Math.max(e,0),1):0;return(n?800:2*800)+Math.floor(t*(800/2))}function Q(){let e=null,n=0,t=null;return{observe(r,o){const l=e===null||e.bye||o-n>=25e3;return(r.claim&&!r.bye||t===null||l)&&(t=r.tab),r.tab!==t?!1:(e=r,n=o,r.bye&&(t=null),!0)},current:()=>e,receivedAt:()=>n,actionTab:()=>t??"",live(r){return e!==null&&!e.bye&&r-n<25e3},release(){t=null}}}function ee(e,n){return e>0&&n-e<45e3}const z={now:()=>Date.now(),setTimeout:(e,n)=>globalThis.setTimeout(e,n),clearTimeout:e=>globalThis.clearTimeout(e)};function ne(e,n,t=z){let r=Number.NEGATIVE_INFINITY,o=null;function l(){r=t.now(),e()}function i(){o!==null&&t.clearTimeout(o),o=null}return{call(){if(o!==null)return;const a=r+n-t.now();if(a<=0){l();return}o=t.setTimeout(()=>{o=null,l()},a)},flush(){i(),l()},cancel:i}}const O=/<h([1-3])\b[^>]*>([\s\S]*?)<\/h\1\s*>/gi,R=/<br\s*\/?>/gi,C=/<[^>]*>/g,P=/&(#x[0-9a-f]+|#[0-9]+|amp|lt|gt|quot|apos|nbsp);/gi,g={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" "};function _(e){return e.replace(P,(n,t)=>{const r=t.toLowerCase();if(r in g)return g[r];const o=r.startsWith("#x")?parseInt(r.slice(2),16):parseInt(r.slice(1),10);return!Number.isFinite(o)||o<=0||o>1114111?n:o===160?" ":String.fromCodePoint(o)})}function D(e){return _(e.replace(R," ").replace(C,"")).replace(/\s+/g," ").trim()}function T(e,n){const t=e.findIndex(r=>r.number===n);return t<0?0:t}function te(e){const n=e.body_html??"";for(const r of n.matchAll(O)){const o=D(r[2]??"");if(o)return o}const t=(e.section_label??"").trim();return t||`Slajd ${e.number}`}const j={say:"Na ekranie: Powiedz",notes:"Na ekranie: Notatki",srcs:"Na ekranie: Źródła"};function re(e){const n=[];return e.special&&n.push("Specjalny"),e.panel&&n.push(j[e.panel]),e.toolbar_hidden&&n.push("Pasek ukryty"),e.clock.hidden&&n.push("Zegar ukryty"),n}const L={connecting:"Łączenie…",waiting:"Czekam na komputer",live:"Połączono",reconnecting:"Ponowne łączenie…",unavailable:"Pilot niedostępny"};function oe(e){return L[e]}function le(e,n,t,r,o,l){const{clock:i}=e,s=!i.paused&&!i.idle?Math.max(0,(l-o)/1e3):0;return{budgets:n,targetSeconds:t,index:r,slideElapsed:i.slide_elapsed+s,elapsed:i.elapsed+s,idle:i.idle,paused:i.paused,hidden:i.hidden}}function ie(e,n,t="deck"){const r=H(e,n);return t!=="cast"?r:r.map(o=>o.action==="notes"?{...o,label:"Komentarz"}:o.action==="speak"||o.action==="scheme"||o.action==="toolbar"?{...o,enabled:!1,pressed:!1}:o)}function H(e,n){const t=n&&e!==null,r=e?.panel??null,o=!!e?.special,l=(i,a,s,u,f=null)=>({action:i,label:a,kbd:s,enabled:t&&u,pressed:f});return[l("prev","Wstecz","",!0),l("next","Dalej","",!0),l("sources","Źródła","Z",!0,r==="srcs"),l("notes","Notatki","N",!0,r==="notes"),l("special","Specjalny","S",!!e?.has_special||o,o),l("back","Powrót","Esc",o),l("clock-pause",e?.clock.paused?"Wznów":"Pauza","T",!e?.clock.idle),l("clock-reset","Zeruj","R",!0),l("clock",e?.clock.hidden?"Pokaż zegar":"Ukryj zegar","C",!0),l("toolbar","Pasek","H",!0,e?!e.toolbar_hidden:!1),l("speak","Powiedz","P",!0,r==="say"),l("scheme","Jasny","J",!0,!!e?.light),l("first","Początek","Home",!0),l("last","Koniec","End",!0)]}function se(e){return e===0?"Nie wysłano: brak połączenia z internetem. Naciśnij ponownie.":e===429?"Za dużo naciśnięć naraz. Odczekaj chwilę i naciśnij ponownie.":e===503?"Pilot jest teraz niedostępny. Steruj klawiaturą na komputerze.":"Nie wysłano polecenia. Naciśnij ponownie."}const V=/<img\b((?:[^>"']|"[^"]*"|'[^']*')*)>/gi,K=/([^\s"'=<>/]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/g;function v(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function X(e){const n=new Map;for(const t of e.matchAll(K)){const r=(t[1]??"").toLowerCase();!r||n.has(r)||n.set(r,t[2]??t[3]??t[4]??"")}return n}function ae(e){return e?e.replace(V,(n,t)=>{const r=X(t);if(!r.has("data-deck-image"))return n;const o=_(r.get("alt")??"").replace(/\s+/g," ").trim();return`<em class="drawer-image">${o?`[obraz: ${v(o)}]`:"[obraz]"}</em>`}):""}function ce(e,n,t,r){if(e.slides.length===0)return null;if(t&&n){const o=e.slides[T(e.slides,n.number)]??null;return o&&n.special&&o.special?o.special:o}return e.slides[T(e.slides,r)]??null}export{Y as C,F as D,G as H,m as R,x as S,ne as a,B as b,W as c,q as d,ae as e,te as f,ce as g,ie as h,oe as i,U as j,Q as k,se as l,re as m,$ as n,le as o,ee as p,Z as r,T as s,J as t};