UNPKG

svelte-pdfz

Version:

svelte-pdf provides a component for rendering PDF documents using PDF.js

5 lines (4 loc) 8.33 kB
import{n as x,r as w,i as j,f as E,h as z,j as O,k as X,l as Y,m as Z,p as tt,q,v as et,w as nt,x as it}from"./scheduler.DkWk2TK-.js";const L=typeof window<"u";let M=L?()=>window.performance.now():()=>Date.now(),P=L?t=>requestAnimationFrame(t):x;const g=new Set;function T(t){g.forEach(e=>{e.c(t)||(g.delete(e),e.f())}),g.size!==0&&P(T)}function H(t){let e;return g.size===0&&P(T),{promise:new Promise(n=>{g.add(e={c:t,f:n})}),abort(){g.delete(e)}}}let k=!1;function rt(){k=!0}function st(){k=!1}function at(t,e,n,i){for(;t<e;){const r=t+(e-t>>1);n(r)<=i?t=r+1:e=r}return t}function lt(t){if(t.hydrate_init)return;t.hydrate_init=!0;let e=t.childNodes;if(t.nodeName==="HEAD"){const a=[];for(let l=0;l<e.length;l++){const u=e[l];u.claim_order!==void 0&&a.push(u)}e=a}const n=new Int32Array(e.length+1),i=new Int32Array(e.length);n[0]=-1;let r=0;for(let a=0;a<e.length;a++){const l=e[a].claim_order,u=(r>0&&e[n[r]].claim_order<=l?r+1:at(1,r,_=>e[n[_]].claim_order,l))-1;i[a]=n[u]+1;const f=u+1;n[f]=a,r=Math.max(f,r)}const c=[],s=[];let o=e.length-1;for(let a=n[r]+1;a!=0;a=i[a-1]){for(c.push(e[a-1]);o>=a;o--)s.push(e[o]);o--}for(;o>=0;o--)s.push(e[o]);c.reverse(),s.sort((a,l)=>a.claim_order-l.claim_order);for(let a=0,l=0;a<s.length;a++){for(;l<c.length&&s[a].claim_order>=c[l].claim_order;)l++;const u=l<c.length?c[l]:null;t.insertBefore(s[a],u)}}function ct(t,e){t.appendChild(e)}function F(t){if(!t)return document;const e=t.getRootNode?t.getRootNode():t.ownerDocument;return e&&e.host?e:t.ownerDocument}function ot(t){const e=V("style");return e.textContent="/* empty */",ft(F(t),e),e.sheet}function ft(t,e){return ct(t.head||t,e),e.sheet}function ut(t,e){if(k){for(lt(t),(t.actual_end_child===void 0||t.actual_end_child!==null&&t.actual_end_child.parentNode!==t)&&(t.actual_end_child=t.firstChild);t.actual_end_child!==null&&t.actual_end_child.claim_order===void 0;)t.actual_end_child=t.actual_end_child.nextSibling;e!==t.actual_end_child?(e.claim_order!==void 0||e.parentNode!==t)&&t.insertBefore(e,t.actual_end_child):t.actual_end_child=e.nextSibling}else(e.parentNode!==t||e.nextSibling!==null)&&t.appendChild(e)}function At(t,e,n){k&&!n?ut(t,e):(e.parentNode!==t||e.nextSibling!=n)&&t.insertBefore(e,n||null)}function U(t){t.parentNode&&t.parentNode.removeChild(t)}function V(t){return document.createElement(t)}function _t(t){return document.createElementNS("http://www.w3.org/2000/svg",t)}function R(t){return document.createTextNode(t)}function St(){return R(" ")}function Ct(){return R("")}function jt(t,e,n,i){return t.addEventListener(e,n,i),()=>t.removeEventListener(e,n,i)}function kt(t,e,n){n==null?t.removeAttribute(e):t.getAttribute(e)!==n&&t.setAttribute(e,n)}function Bt(t){return t.dataset.svelteH}function dt(t){return Array.from(t.childNodes)}function mt(t){t.claim_info===void 0&&(t.claim_info={last_index:0,total_claimed:0})}function W(t,e,n,i,r=!1){mt(t);const c=(()=>{for(let s=t.claim_info.last_index;s<t.length;s++){const o=t[s];if(e(o)){const a=n(o);return a===void 0?t.splice(s,1):t[s]=a,r||(t.claim_info.last_index=s),o}}for(let s=t.claim_info.last_index-1;s>=0;s--){const o=t[s];if(e(o)){const a=n(o);return a===void 0?t.splice(s,1):t[s]=a,r?a===void 0&&t.claim_info.last_index--:t.claim_info.last_index=s,o}}return i()})();return c.claim_order=t.claim_info.total_claimed,t.claim_info.total_claimed+=1,c}function G(t,e,n,i){return W(t,r=>r.nodeName===e,r=>{const c=[];for(let s=0;s<r.attributes.length;s++){const o=r.attributes[s];n[o.name]||c.push(o.name)}c.forEach(s=>r.removeAttribute(s))},()=>i(e))}function Dt(t,e,n){return G(t,e,n,V)}function Pt(t,e,n){return G(t,e,n,_t)}function ht(t,e){return W(t,n=>n.nodeType===3,n=>{const i=""+e;if(n.data.startsWith(i)){if(n.data.length!==i.length)return n.splitText(i.length)}else n.data=i},()=>R(e),!0)}function Rt(t){return ht(t," ")}function It(t,e){e=""+e,t.data!==e&&(t.data=e)}function Ot(t,e){t.value=e??""}function qt(t,e,n,i){n==null?t.style.removeProperty(e):t.style.setProperty(e,n,"")}function pt(t,e,{bubbles:n=!1,cancelable:i=!1}={}){return new CustomEvent(t,{detail:e,bubbles:n,cancelable:i})}function zt(t,e){return new t(e)}const A=new Map;let S=0;function $t(t){let e=5381,n=t.length;for(;n--;)e=(e<<5)-e^t.charCodeAt(n);return e>>>0}function yt(t,e){const n={stylesheet:ot(e),rules:{}};return A.set(t,n),n}function J(t,e,n,i,r,c,s,o=0){const a=16.666/i;let l=`{ `;for(let $=0;$<=1;$+=a){const p=e+(n-e)*c($);l+=$*100+`%{${s(p,1-p)}} `}const u=l+`100% {${s(n,1-n)}} }`,f=`__svelte_${$t(u)}_${o}`,_=F(t),{stylesheet:d,rules:m}=A.get(_)||yt(_,t);m[f]||(m[f]=!0,d.insertRule(`@keyframes ${f} ${u}`,d.cssRules.length));const h=t.style.animation||"";return t.style.animation=`${h?`${h}, `:""}${f} ${i}ms linear ${r}ms 1 both`,S+=1,f}function D(t,e){const n=(t.style.animation||"").split(", "),i=n.filter(e?c=>c.indexOf(e)<0:c=>c.indexOf("__svelte")===-1),r=n.length-i.length;r&&(t.style.animation=i.join(", "),S-=r,S||gt())}function gt(){P(()=>{S||(A.forEach(t=>{const{ownerNode:e}=t.stylesheet;e&&U(e)}),A.clear())})}let v;function K(){return v||(v=Promise.resolve(),v.then(()=>{v=null})),v}function C(t,e,n){t.dispatchEvent(pt(`${e?"intro":"outro"}${n}`))}const b=new Set;let y;function Lt(){y={r:0,c:[],p:y}}function Mt(){y.r||w(y.c),y=y.p}function xt(t,e){t&&t.i&&(b.delete(t),t.i(e))}function Tt(t,e,n,i){if(t&&t.o){if(b.has(t))return;b.add(t),y.c.push(()=>{b.delete(t),i&&(n&&t.d(1),i())}),t.o(e)}else i&&i()}const Q={duration:0};function Ht(t,e,n){const i={direction:"in"};let r=e(t,n,i),c=!1,s,o,a=0;function l(){s&&D(t,s)}function u(){const{delay:_=0,duration:d=300,easing:m=z,tick:h=x,css:$}=r||Q;$&&(s=J(t,0,1,d,_,m,$,a++)),h(0,1);const p=M()+_,N=p+d;o&&o.abort(),c=!0,E(()=>C(t,!0,"start")),o=H(B=>{if(c){if(B>=N)return h(1,0),C(t,!0,"end"),l(),c=!1;if(B>=p){const I=m((B-p)/d);h(I,1-I)}}return c})}let f=!1;return{start(){f||(f=!0,D(t),j(r)?(r=r(i),K().then(u)):u())},invalidate(){f=!1},end(){c&&(l(),c=!1)}}}function Ft(t,e,n){const i={direction:"out"};let r=e(t,n,i),c=!0,s;const o=y;o.r+=1;let a;function l(){const{delay:u=0,duration:f=300,easing:_=z,tick:d=x,css:m}=r||Q;m&&(s=J(t,1,0,f,u,_,m));const h=M()+u,$=h+f;E(()=>C(t,!1,"start")),"inert"in t&&(a=t.inert,t.inert=!0),H(p=>{if(c){if(p>=$)return d(0,1),C(t,!1,"end"),--o.r||w(o.c),!1;if(p>=h){const N=_((p-h)/f);d(1-N,N)}}return c})}return j(r)?K().then(()=>{r=r(i),l()}):l(),{end(u){u&&"inert"in t&&(t.inert=a),u&&r.tick&&r.tick(1,0),c&&(s&&D(t,s),c=!1)}}}function Ut(t){t&&t.c()}function Vt(t,e){t&&t.l(e)}function vt(t,e,n){const{fragment:i,after_update:r}=t.$$;i&&i.m(e,n),E(()=>{const c=t.$$.on_mount.map(et).filter(j);t.$$.on_destroy?t.$$.on_destroy.push(...c):w(c),t.$$.on_mount=[]}),r.forEach(E)}function wt(t,e){const n=t.$$;n.fragment!==null&&(Z(n.after_update),w(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function Nt(t,e){t.$$.dirty[0]===-1&&(nt.push(t),it(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function Wt(t,e,n,i,r,c,s=null,o=[-1]){const a=tt;q(t);const l=t.$$={fragment:null,ctx:[],props:c,update:x,not_equal:r,bound:O(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(a?a.$$.context:[])),callbacks:O(),dirty:o,skip_bound:!1,root:e.target||a.$$.root};s&&s(l.root);let u=!1;if(l.ctx=n?n(t,e.props||{},(f,_,...d)=>{const m=d.length?d[0]:_;return l.ctx&&r(l.ctx[f],l.ctx[f]=m)&&(!l.skip_bound&&l.bound[f]&&l.bound[f](m),u&&Nt(t,f)),_}):[],l.update(),u=!0,w(l.before_update),l.fragment=i?i(l.ctx):!1,e.target){if(e.hydrate){rt();const f=dt(e.target);l.fragment&&l.fragment.l(f),f.forEach(U)}else l.fragment&&l.fragment.c();e.intro&&xt(t.$$.fragment),vt(t,e.target,e.anchor),st(),X()}q(a)}class Gt{$$=void 0;$$set=void 0;$destroy(){wt(this,1),this.$destroy=x}$on(e,n){if(!j(n))return x;const i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(n),()=>{const r=i.indexOf(n);r!==-1&&i.splice(r,1)}}$set(e){this.$$set&&!Y(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const bt="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(bt);export{Ft as A,Bt as B,_t as C,Pt as D,Ot as E,Gt as S,Tt as a,R as b,Dt as c,dt as d,V as e,ht as f,U as g,Rt as h,Wt as i,At as j,ut as k,It as l,Ct as m,Mt as n,kt as o,qt as p,Lt as q,zt as r,St as s,xt as t,Ut as u,Vt as v,vt as w,wt as x,jt as y,Ht as z};