var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;li[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let l=require(`obsidian`),u=require(`electron`);u=c(u);let d=require(`path`);d=c(d);let f=require(`os`);f=c(f);var p=c(o(((e,t)=>{var n=function(e){return r(e)&&!i(e)};function r(e){return!!e&&typeof e==`object`}function i(e){var t=Object.prototype.toString.call(e);return t===`[object RegExp]`||t===`[object Date]`||o(e)}var a=typeof Symbol==`function`&&Symbol.for?Symbol.for(`react.element`):60103;function o(e){return e.$$typeof===a}function s(e){return Array.isArray(e)?[]:{}}function c(e,t){return t.clone!==!1&&t.isMergeableObject(e)?g(s(e),e,t):e}function l(e,t,n){return e.concat(t).map(function(e){return c(e,n)})}function u(e,t){if(!t.customMerge)return g;var n=t.customMerge(e);return typeof n==`function`?n:g}function d(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[]}function f(e){return Object.keys(e).concat(d(e))}function p(e,t){try{return t in e}catch{return!1}}function m(e,t){return p(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))}function h(e,t,n){var r={};return n.isMergeableObject(e)&&f(e).forEach(function(t){r[t]=c(e[t],n)}),f(t).forEach(function(i){m(e,i)||(p(e,i)&&n.isMergeableObject(t[i])?r[i]=u(i,n)(e[i],t[i],n):r[i]=c(t[i],n))}),r}function g(e,t,r){r=r||{},r.arrayMerge=r.arrayMerge||l,r.isMergeableObject=r.isMergeableObject||n,r.cloneUnlessOtherwiseSpecified=c;var i=Array.isArray(t);return i===Array.isArray(e)?i?r.arrayMerge(e,t,r):h(e,t,r):c(t,r)}g.all=function(e,t){if(!Array.isArray(e))throw Error(`first argument should be an array`);return e.reduce(function(e,n){return g(e,n,t)},{})},t.exports=g}))()),m={i18n:{en:{exportCurrentFile:`Export current file to PDF`,exportCurrentFileWithPrevious:`Export to PDF with previous Settings`,exportDialog:{filenameAsTitle:`Include file name as title`,pageSize:`Page Size`,margin:`Margin`,downscalePercent:`Downscale Percent`,landscape:`Landscape`,displayHeader:`Display Header`,displayFooter:`Display Footer`,openAfterExport:`Open after export`,cssSnippets:`CSS snippets`},settings:{showTitle:`Add file name as title`,displayHeader:`Display headers`,displayFooter:`Display footer`,printBackground:`Print background`,maxLevel:`Max headings level of the outline`,displayMetadata:`PDF metadata`,headerTemplate:`Header Template`,footerTemplate:`Footer Template`,isTimestamp:`Add timestamp`,enabledCss:`Enable select css snippets`,concurrency:`Limit concurrency`,debugMode:`Debug Mode`,version:`Engine Version`}},zh:{exportCurrentFile:`导出当前文件为PDF`,exportCurrentFileWithPrevious:`使用上一次设置导出为PDF`,exportDialog:{filenameAsTitle:`将笔记名作为标题`,pageSize:`纸张尺寸`,margin:`页边距`,downscalePercent:`缩放`,landscape:`横向打印`,displayHeader:`页眉`,displayFooter:`页脚`,openAfterExport:`导出后打开`,cssSnippets:`CSS代码片段`},settings:{showTitle:`将笔记名作为标题`,displayHeader:`显示页眉`,displayFooter:`显示页脚`,printBackground:`打印背景`,maxLevel:`最大标题级别`,displayMetadata:`PDF元数据`,headerTemplate:`页眉模板`,footerTemplate:`页脚模板`,isTimestamp:`文件名添加时间戳`,enabledCss:`启用CSS片段选择`,concurrency:`限制并发数`,debugMode:`调试模式`,version:`引擎版本`}}},get current(){let e=window.localStorage.getItem(`language`)??`en`;return(0,p.default)(this.i18n.en,this.i18n[e]??{})}},h=Array.isArray,g=Array.prototype.indexOf,_=Array.prototype.includes,v=Array.from,y=Object.defineProperty,b=Object.getOwnPropertyDescriptor,x=Object.getOwnPropertyDescriptors,S=Object.prototype,C=Array.prototype,w=Object.getPrototypeOf,T=Object.isExtensible,E=()=>{};function D(e){for(var t=0;t{e=n,t=r}),resolve:e,reject:t}}function k(e){"@babel/helpers - typeof";return k=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},k(e)}function ee(e,t){if(k(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(k(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function A(e){var t=ee(e,`string`);return k(t)==`symbol`?t:t+``}function j(e,t,n){return(t=A(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var te=1024,ne=2048,re=4096,ie=8192,ae=16384,oe=32768,se=1<<25,ce=65536,le=1<<19,ue=1<<20,M=1<<25,N=65536,de=1<<21,fe=1<<22,pe=1<<23,me=Symbol(`$state`),he=Symbol(`legacy props`),ge=Symbol(``),_e=Symbol(`attributes`),ve=Symbol(`class`),P=Symbol(`style`),ye=Symbol(`text`),be=new class extends Error{constructor(...e){super(...e),j(this,`name`,`StaleReactionError`),j(this,`message`,"The reaction that called `getAbortSignal()` was re-run or destroyed")}},xe=!!globalThis.document?.contentType&&globalThis.document.contentType.includes(`xml`);function F(e){throw Error(`https://svelte.dev/e/lifecycle_outside_component`)}function Se(){throw Error(`https://svelte.dev/e/async_derived_orphan`)}function I(e,t,n){throw Error(`https://svelte.dev/e/each_key_duplicate`)}function Ce(e){throw Error(`https://svelte.dev/e/effect_in_teardown`)}function L(){throw Error(`https://svelte.dev/e/effect_in_unowned_derived`)}function R(e){throw Error(`https://svelte.dev/e/effect_orphan`)}function we(){throw Error(`https://svelte.dev/e/effect_update_depth_exceeded`)}function Te(e){throw Error(`https://svelte.dev/e/props_invalid_value`)}function Ee(){throw Error(`https://svelte.dev/e/state_descriptors_fixed`)}function De(){throw Error(`https://svelte.dev/e/state_prototype_fixed`)}function z(){throw Error(`https://svelte.dev/e/state_unsafe_mutation`)}function Oe(){throw Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`)}var ke={},Ae=Symbol(`uninitialized`);function je(){console.warn(`https://svelte.dev/e/derived_inert`)}function Me(e){console.warn(`https://svelte.dev/e/hydration_mismatch`)}function Ne(){console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`)}var Pe=!1;function Fe(e){Pe=e}var Ie;function Le(e){if(e===null)throw Me(),ke;return Ie=e}function Re(){return Le(br(Ie))}function ze(e){if(Pe){if(br(Ie)!==null)throw Me(),ke;Ie=e}}function Be(e=1){if(Pe){for(var t=e,n=Ie;t--;)n=br(n);Ie=n}}function Ve(e=!0){for(var t=0,n=Ie;;){if(n.nodeType===8){var r=n.data;if(r===`]`){if(t===0)return n;--t}else (r===`[`||r===`[!`||r[0]===`[`&&!isNaN(Number(r.slice(1))))&&(t+=1)}var i=br(n);e&&n.remove(),n=i}}function He(e){if(!e||e.nodeType!==8)throw Me(),ke;return e.data}function Ue(e){return e===this.v}function We(e,t){return e==e?e!==t||typeof e==`object`&&!!e||typeof e==`function`:t==t}function Ge(e){return!We(e,this.v)}var Ke=!1,qe=!1,Je=[];function Ye(e,t=!1,n=!1){return Xe(e,new Map,``,Je,null,n)}function Xe(e,t,n,r,i=null,a=!1){if(typeof e==`object`&&e){var o=t.get(e);if(o!==void 0)return o;if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);if(h(e)){var s=Array(e.length);t.set(e,s),i!==null&&t.set(i,s);for(var c=0;c{t===nt&&rt()})}nt.push(e)}function at(e){var t=si;if(t===null)return ii.f|=pe,e;if(!(t.f&32768)&&!(t.f&4))throw e;ot(e,t)}function ot(e,t){for(;t!==null;){if(t.f&128){if(!(t.f&32768))throw e;try{t.b.error(e);return}catch(t){e=t}}t=t.parent}throw e}var st=~(ne|re|te);function ct(e,t){e.f=e.f&st|t}function lt(e){e.f&512||e.deps===null?ct(e,te):ct(e,re)}function ut(e){if(e!==null)for(let t of e)!(t.f&2)||!(t.f&65536)||(t.f^=N,ut(t.deps))}function dt(e,t,n){e.f&2048?t.add(e):e.f&4096&&n.add(e),ut(e.deps),ct(e,te)}var ft=!1,pt=!1;function mt(e){var t=pt;try{return pt=!1,[e(),pt]}finally{pt=t}}function ht(e){let t=0,n=ir(0),r;return()=>{Mr()&&(H(n),zr(()=>(t===0&&(r=Oi(()=>e(()=>ur(n)))),t+=1,()=>{it(()=>{--t,t===0&&(r?.(),r=void 0,ur(n))})})))}}function gt(e,t){if(t.has(e))throw TypeError(`Cannot initialize the same private elements twice on an object`)}function _t(e,t){gt(e,t),t.add(e)}function vt(e,t,n){gt(e,t),t.set(e,n)}function yt(e,t,n){if(typeof e==`function`?e===t:e.has(t))return arguments.length<3?t:n;throw TypeError(`Private element is not present on this object`)}function B(e,t,n){return e.set(yt(e,t),n),n}function V(e,t){return e.get(yt(e,t))}var bt=ce|le;function xt(e,t,n,r){new zt(e,t,n,r)}var St=new WeakMap,Ct=new WeakMap,wt=new WeakMap,Tt=new WeakMap,Et=new WeakMap,Dt=new WeakMap,Ot=new WeakMap,kt=new WeakMap,At=new WeakMap,jt=new WeakMap,Mt=new WeakMap,Nt=new WeakMap,Pt=new WeakMap,Ft=new WeakMap,It=new WeakMap,Lt=new WeakMap,Rt=new WeakSet,zt=class{constructor(e,t,n,r){_t(this,Rt),j(this,`parent`,void 0),j(this,`is_pending`,!1),j(this,`transform_error`,void 0),vt(this,St,void 0),vt(this,Ct,Pe?Ie:null),vt(this,wt,void 0),vt(this,Tt,void 0),vt(this,Et,void 0),vt(this,Dt,null),vt(this,Ot,null),vt(this,kt,null),vt(this,At,null),vt(this,jt,0),vt(this,Mt,0),vt(this,Nt,!1),vt(this,Pt,new Set),vt(this,Ft,new Set),vt(this,It,null),vt(this,Lt,ht(()=>(B(It,this,ir(V(jt,this))),()=>{B(It,this,null)}))),B(St,this,e),B(wt,this,t),B(Tt,this,e=>{var t=si;t.b=this,t.f|=128,n(e)}),this.parent=si.b,this.transform_error=r??this.parent?.transform_error??(e=>e),B(Et,this,Vr(()=>{if(Pe){let e=V(Ct,this);Re();let t=e.data===`[!`;if(e.data.startsWith(`[?`)){let t=JSON.parse(e.data.slice(2));yt(Rt,this,Vt).call(this,t)}else t?yt(Rt,this,Ht).call(this):yt(Rt,this,Bt).call(this)}else yt(Rt,this,Ut).call(this)},bt)),Pe&&B(St,this,Ie)}defer_effect(e){dt(e,V(Pt,this),V(Ft,this))}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!V(wt,this).pending}update_pending_count(e,t){yt(Rt,this,Kt).call(this,e,t),B(jt,this,V(jt,this)+e),!(!V(It,this)||V(Nt,this))&&(B(Nt,this,!0),it(()=>{B(Nt,this,!1),V(It,this)&&cr(V(It,this),V(jt,this))}))}get_effect_pending(){return V(Lt,this).call(this),H(V(It,this))}error(e){if(!V(wt,this).onerror&&!V(wt,this).failed)throw e;fn?.is_fork?(V(Dt,this)&&fn.skip_effect(V(Dt,this)),V(Ot,this)&&fn.skip_effect(V(Ot,this)),V(kt,this)&&fn.skip_effect(V(kt,this)),fn.oncommit(()=>{yt(Rt,this,qt).call(this,e)})):yt(Rt,this,qt).call(this,e)}};function Bt(){try{B(Dt,this,Hr(()=>V(Tt,this).call(this,V(St,this))))}catch(e){this.error(e)}}function Vt(e){let t=V(wt,this).failed;t&&B(kt,this,Hr(()=>{t(V(St,this),()=>e,()=>()=>{})}))}function Ht(){let e=V(wt,this).pending;e&&(this.is_pending=!0,B(Ot,this,Hr(()=>e(V(St,this)))),it(()=>{var e=B(At,this,document.createDocumentFragment()),t=vr();e.append(t),B(Dt,this,yt(Rt,this,Gt).call(this,()=>Hr(()=>V(Tt,this).call(this,t)))),V(Mt,this)===0&&(V(St,this).before(e),B(At,this,null),Yr(V(Ot,this),()=>{B(Ot,this,null)}),yt(Rt,this,Wt).call(this,fn))}))}function Ut(){try{if(this.is_pending=this.has_pending_snippet(),B(Mt,this,0),B(jt,this,0),B(Dt,this,Hr(()=>{V(Tt,this).call(this,V(St,this))})),V(Mt,this)>0){var e=B(At,this,document.createDocumentFragment());$r(V(Dt,this),e);let t=V(wt,this).pending;B(Ot,this,Hr(()=>t(V(St,this))))}else yt(Rt,this,Wt).call(this,fn)}catch(e){this.error(e)}}function Wt(e){this.is_pending=!1,e.transfer_effects(V(Pt,this),V(Ft,this))}function Gt(e){var t=si,n=ii,r=Ze;ci(V(Et,this)),oi(V(Et,this)),Qe(V(Et,this).ctx);try{return Rn.ensure(),e()}catch(e){return at(e),null}finally{ci(t),oi(n),Qe(r)}}function Kt(e,t){if(!this.has_pending_snippet()){if(this.parent){var n;yt(Rt,n=this.parent,Kt).call(n,e,t)}return}B(Mt,this,V(Mt,this)+e),V(Mt,this)===0&&(yt(Rt,this,Wt).call(this,t),V(Ot,this)&&Yr(V(Ot,this),()=>{B(Ot,this,null)}),V(At,this)&&(V(St,this).before(V(At,this)),B(At,this,null)))}function qt(e){V(Dt,this)&&(Kr(V(Dt,this)),B(Dt,this,null)),V(Ot,this)&&(Kr(V(Ot,this)),B(Ot,this,null)),V(kt,this)&&(Kr(V(kt,this)),B(kt,this,null)),Pe&&(Le(V(Ct,this)),Be(),Le(Ve()));var t=V(wt,this).onerror;let n=V(wt,this).failed;var r=!1,i=!1;let a=()=>{if(r){Ne();return}r=!0,i&&Oe(),V(kt,this)!==null&&Yr(V(kt,this),()=>{B(kt,this,null)}),yt(Rt,this,Gt).call(this,()=>{yt(Rt,this,Ut).call(this)})},o=e=>{try{i=!0,t?.(e,a),i=!1}catch(e){ot(e,V(Et,this)&&V(Et,this).parent)}n&&B(kt,this,yt(Rt,this,Gt).call(this,()=>{try{return Hr(()=>{var t=si;t.b=this,t.f|=128,n(V(St,this),()=>e,()=>a)})}catch(e){return ot(e,V(Et,this).parent),null}}))};it(()=>{var t;try{t=this.transform_error(e)}catch(e){ot(e,V(Et,this)&&V(Et,this).parent);return}typeof t==`object`&&t&&typeof t.then==`function`?t.then(o,e=>ot(e,V(Et,this)&&V(Et,this).parent)):o(t)})}function Jt(e,t,n,r){let i=tt()?Qt:nn;var a=e.filter(e=>!e.settled),o=t.map(i);if(n.length===0&&a.length===0){r(o);return}var s=si,c=Yt(),l=a.length===1?a[0].promise:a.length>1?Promise.all(a.map(e=>e.promise)):null;function u(e){if(!(s.f&16384)){c();try{r([...o,...e])}catch(e){ot(e,s)}Xt()}}var d=Zt();if(n.length===0){l.then(()=>u([])).finally(d);return}function f(){Promise.all(n.map(e=>en(e))).then(u).catch(e=>ot(e,s)).finally(d)}l?l.then(()=>{c(),f(),Xt()}):f()}function Yt(){var e=si,t=ii,n=Ze,r=fn;return function(i=!0){ci(e),oi(t),Qe(n),i&&!(e.f&16384)&&(r?.activate(),r?.apply())}}function Xt(e=!0){ci(null),oi(null),Qe(null),e&&fn?.deactivate()}function Zt(){var e=si,t=e.b,n=fn,r=!!t?.is_rendered();return t?.update_pending_count(1,n),n.increment(r,e),()=>{t?.update_pending_count(-1,n),n.decrement(r,e)}}function Qt(e){var t=2|ne;return si!==null&&(si.f|=le),{ctx:Ze,deps:null,effects:null,equals:Ue,f:t,fn:e,reactions:null,rv:0,v:Ae,wv:0,parent:si,ac:null}}var $t=Symbol(`obsolete`);function en(e,t,n){let r=si;r===null&&Se();var i=void 0,a=ir(Ae),o=!ii,s=new Set;return Rr(()=>{var t=si,n=O();i=n.promise;try{Promise.resolve(e()).then(n.resolve,e=>{e!==be&&n.reject(e)}).finally(Xt)}catch(e){n.reject(e),Xt()}var c=fn;if(o){if(t.f&32768)var l=Zt();if(r.b?.is_rendered())c.async_deriveds.get(t)?.reject($t);else for(let e of s.values())e.reject($t);s.add(n),c.async_deriveds.set(t,n)}let u=(e,t=void 0)=>{l?.(),s.delete(n),t!==$t&&(c.activate(),t?(a.f|=pe,cr(a,t)):(a.f&8388608&&(a.f^=pe),cr(a,e)),c.deactivate())};n.promise.then(u,e=>u(null,e||`unknown`))}),Nr(()=>{for(let e of s)e.reject($t)}),new Promise(e=>{function t(n){function r(){n===i?e(a):t(i)}n.then(r,r)}t(i)})}function tn(e){let t=Qt(e);return Ke||ui(t),t}function nn(e){let t=Qt(e);return t.equals=Ge,t}function rn(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;nthis.schedule(e)){var n=V(Pn,this).get(e);if(n){V(Pn,this).delete(e);for(var r of n.d)ct(r,ne),t(r);for(r of n.m)ct(r,re),t(r)}V(Fn,this).add(e)}capture(e,t,n=!1){e.v!==Ae&&!this.previous.has(e)&&this.previous.set(e,e.v),e.f&8388608||(this.current.set(e,[t,n]),mn?.set(e,t)),this.is_fork||(e.v=t)}activate(){fn=this}deactivate(){fn=null,mn=null}flush(){try{_n=!0,fn=this,yt(Ln,this,Bn).call(this)}finally{bn=0,hn=null,vn=null,yn=null,_n=!1,fn=null,mn=null,nr.clear()}}discard(){for(let e of V(En,this))e(this);V(En,this).clear();for(let e of this.async_deriveds.values())e.reject($t);yt(Ln,this,Kn).call(this),V(kn,this)?.resolve()}register_created_effect(e){V(jn,this).push(e)}increment(e,t){if(B(Dn,this,V(Dn,this)+1),e){let e=V(On,this).get(t)??0;V(On,this).set(t,e+1)}}decrement(e,t){if(B(Dn,this,V(Dn,this)-1),e){let e=V(On,this).get(t)??0;e===1?V(On,this).delete(t):V(On,this).set(t,e-1)}V(In,this)||(B(In,this,!0),it(()=>{B(In,this,!1),this.linked&&this.flush()}))}transfer_effects(e,t){for(let t of e)V(Mn,this).add(t);for(let e of t)V(Nn,this).add(e);e.clear(),t.clear()}oncommit(e){V(Tn,this).add(e)}ondiscard(e){V(En,this).add(e)}settled(){return(V(kn,this)??B(kn,this,O())).promise}static ensure(){if(fn===null){let t=fn=new e;!_n&&!gn&&it(()=>{V(Sn,t)||t.flush()})}return fn}apply(){if(!Ke||!this.is_fork&&V(Cn,this)===null&&V(wn,this)===null){mn=null;return}mn=new Map;for(let[e,[t]]of this.current)mn.set(e,t);for(let t=un;t!==null;t=V(wn,t))if(!(t===this||t.is_fork)){var e=!1;if(t.id1e3&&(yt(Ln,this,Kn).call(this),qn());for(let e of V(Mn,this))V(Nn,this).delete(e),ct(e,ne),this.schedule(e);for(let e of V(Nn,this))ct(e,re),this.schedule(e);let e=V(An,this);B(An,this,[]),this.apply();var t=vn=[],n=[],r=yn=[];for(let r of e)try{yt(Ln,this,Vn).call(this,r,t,n)}catch(e){throw er(r),yt(Ln,this,zn).call(this)||this.discard(),e}if(fn=null,r.length>0){var i=ln.ensure();for(let e of r)i.schedule(e)}if(vn=null,yn=null,yt(Ln,this,zn).call(this)){yt(Ln,this,Wn).call(this,n),yt(Ln,this,Wn).call(this,t);for(let[e,t]of V(Pn,this))$n(e,t);r.length>0&&yt(Ln,fn,Bn).call(fn);return}let a=yt(Ln,this,Hn).call(this);if(a){yt(Ln,this,Wn).call(this,n),yt(Ln,this,Wn).call(this,t),yt(Ln,a,Un).call(a,this);return}V(Mn,this).clear(),V(Nn,this).clear();for(let e of V(Tn,this))e(this);V(Tn,this).clear(),pn=this,Yn(n),Yn(t),pn=null,V(kn,this)?.resolve();var o=fn;if(V(Dn,this)===0&&(V(An,this).length===0||o!==null)&&(yt(Ln,this,Kn).call(this),Ke&&(yt(Ln,this,Gn).call(this),fn=o)),V(An,this).length>0)if(o!==null){let e=o;V(An,e).push(...V(An,this).filter(t=>!V(An,e).includes(t)))}else o=this;o!==null&&yt(Ln,o,Bn).call(o)}function Vn(e,t,n){e.f^=te;for(var r=e.first;r!==null;){var i=r.f,a=(i&96)!=0;if(!(a&&i&1024||i&8192||V(Pn,this).has(r))&&r.fn!==null){a?r.f^=te:i&4?t.push(r):Ke&&i&16777224?n.push(r):bi(r)&&(i&16&&V(Nn,this).add(r),Ti(r));var o=r.first;if(o!==null){r=o;continue}}for(;r!==null;){var s=r.next;if(s!==null){r=s;break}r=r.parent}}}function Hn(){for(var e=V(Cn,this);e!==null;){if(!e.is_fork){for(let[t,[,n]]of this.current)if(e.current.has(t)&&!n)return e}e=V(Cn,e)}return null}function Un(e){for(let[t,n]of e.current)!this.previous.has(t)&&e.previous.has(t)&&this.previous.set(t,e.previous.get(t)),this.current.set(t,n);for(let[t,n]of e.async_deriveds){let e=this.async_deriveds.get(t);e&&n.promise.then(e.resolve).catch(e.reject)}e.async_deriveds.clear(),this.transfer_effects(V(Mn,e),V(Nn,e));let t=e=>{var n=e.reactions;if(n!==null)for(let e of n){var r=e.f;if(r&2)t(e);else{var i=e;r&4194320&&!this.async_deriveds.has(i)&&(V(Nn,this).delete(i),ct(i,ne),this.schedule(i))}}};for(let e of this.current.keys())t(e);this.oncommit(()=>e.discard()),yt(Ln,e,Kn).call(e),fn=this,yt(Ln,this,Bn).call(this)}function Wn(e){for(var t=0;t!u.current.get(e)[1]);if(!(!V(Sn,u)||r.length===0)){var i=r.filter(e=>!this.current.has(e));if(i.length===0)e&&u.discard();else if(t.length>0){if(e)for(let e of V(Fn,this))u.unskip_effect(e,e=>{e.f&4194320?u.schedule(e):yt(Ln,u,Wn).call(u,[e])});u.activate();var a=new Set,o=new Map;for(var s of t)Xn(s,i,a,o);o=new Map;var c=[...u.current].filter(([e,t])=>{let n=this.current.get(e);return n?n[0]!==t[0]||n[1]!==t[1]:!0}).map(([e])=>e);if(c.length>0)for(let e of V(jn,this))!(e.f&155648)&&Zn(e,c,o)&&(e.f&4194320?(ct(e,ne),u.schedule(e)):V(Mn,u).add(e));if(V(An,u).length>0&&!V(In,u)){u.apply();for(var l of V(An,u))yt(Ln,u,Vn).call(u,l,[],[]);B(An,u,[])}u.deactivate()}}}}function Kn(){if(this.linked){var e=V(Cn,this),t=V(wn,this);e===null?un=t:B(wn,e,t),t===null?dn=e:B(Cn,t,e),this.linked=!1}}function qn(){try{we()}catch(e){ot(e,hn)}}var Jn=null;function Yn(e){var t=e.length;if(t!==0){for(var n=0;n0)){nr.clear();for(let e of Jn){if(e.f&24576)continue;let t=[e],n=e.parent;for(;n!==null;)Jn.has(n)&&(Jn.delete(n),t.push(n)),n=n.parent;for(let e=t.length-1;e>=0;e--){let n=t[e];n.f&24576||Ti(n)}}Jn.clear()}}Jn=null}}function Xn(e,t,n,r){if(!n.has(e)&&(n.add(e),e.reactions!==null))for(let i of e.reactions){let e=i.f;e&2?Xn(i,t,n,r):e&4194320&&!(e&2048)&&Zn(i,t,r)&&(ct(i,ne),Qn(i))}}function Zn(e,t,n){let r=n.get(e);if(r!==void 0)return r;if(e.deps!==null)for(let r of e.deps){if(_.call(t,r))return!0;if(r.f&2&&Zn(r,t,n))return n.set(r,!0),!0}return n.set(e,!1),!1}function Qn(e){fn.schedule(e)}function $n(e,t){if(!(e.f&32&&e.f&1024)){e.f&2048?t.d.push(e):e.f&4096&&t.m.push(e),ct(e,te);for(var n=e.first;n!==null;)$n(n,t),n=n.next}}function er(e){ct(e,te);for(var t=e.first;t!==null;)er(t),t=t.next}var tr=new Set,nr=new Map,rr=!1;function ir(e,t){return{f:0,v:e,reactions:null,equals:Ue,rv:0,wv:0}}function ar(e,t){let n=ir(e,t);return ui(n),n}function or(e,t=!1,n=!0){let r=ir(e);if(t||(r.equals=Ge),qe&&n&&Ze!==null&&Ze.l!==null){var i;((i=Ze.l).s??(i.s=[])).push(r)}return r}function sr(e,t,n=!1){return ii!==null&&(!ai||ii.f&131072)&&tt()&&ii.f&4325394&&(li===null||!li.has(e))&&z(),cr(e,n?fr(t):t,yn)}function cr(e,t,n=null){if(!e.equals(t)){nr.set(e,ni?t:e.v);var r=Rn.ensure();if(r.capture(e,t),e.f&2){let t=e;e.f&2048&&an(t),mn===null&<(t)}e.wv=yi(),dr(e,ne,n),tt()&&si!==null&&si.f&1024&&!(si.f&96)&&(pi===null?mi([e]):pi.push(e)),!r.is_fork&&tr.size>0&&!rr&&lr()}return t}function lr(){rr=!1;for(let e of tr){e.f&1024&&ct(e,re);let t;try{t=bi(e)}catch{t=!0}t&&Ti(e)}tr.clear()}function ur(e){sr(e,e.v+1)}function dr(e,t,n){var r=e.reactions;if(r!==null)for(var i=tt(),a=r.length,o=0;o{if(_i===o)return e();var t=ii,n=_i;oi(null),vi(o);var r=e();return oi(t),vi(n),r};return r&&n.set(`length`,ar(e.length,a)),new Proxy(e,{defineProperty(e,t,r){(!(`value`in r)||r.configurable===!1||r.enumerable===!1||r.writable===!1)&&Ee();var i=n.get(t);return i===void 0?s(()=>{var e=ar(r.value,a);return n.set(t,e),e}):sr(i,r.value,!0),!0},deleteProperty(e,t){var r=n.get(t);if(r===void 0){if(t in e){let e=s(()=>ar(Ae,a));n.set(t,e),ur(i)}}else sr(r,Ae),ur(i);return!0},get(t,r,i){if(r===me)return e;var o=n.get(r),c=r in t;if(o===void 0&&(!c||b(t,r)?.writable)&&(o=s(()=>ar(fr(c?t[r]:Ae),a)),n.set(r,o)),o!==void 0){var l=H(o);return l===Ae?void 0:l}return Reflect.get(t,r,i)},getOwnPropertyDescriptor(e,t){var r=Reflect.getOwnPropertyDescriptor(e,t);if(r&&`value`in r){var i=n.get(t);i&&(r.value=H(i))}else if(r===void 0){var a=n.get(t),o=a?.v;if(a!==void 0&&o!==Ae)return{enumerable:!0,configurable:!0,value:o,writable:!0}}return r},has(e,t){if(t===me)return!0;var r=n.get(t),i=r!==void 0&&r.v!==Ae||Reflect.has(e,t);return(r!==void 0||si!==null&&(!i||b(e,t)?.writable))&&(r===void 0&&(r=s(()=>ar(i?fr(e[t]):Ae,a)),n.set(t,r)),H(r)===Ae)?!1:i},set(e,t,o,c){var l=n.get(t),u=t in e;if(r&&t===`length`)for(var d=o;dar(Ae,a)),n.set(d+``,f)):sr(f,Ae)}if(l===void 0)(!u||b(e,t)?.writable)&&(l=s(()=>ar(void 0,a)),sr(l,fr(o)),n.set(t,l));else{u=l.v!==Ae;var p=s(()=>fr(o));sr(l,p)}var m=Reflect.getOwnPropertyDescriptor(e,t);if(m?.set&&m.set.call(c,o),!u){if(r&&typeof t==`string`){var h=n.get(`length`),g=Number(t);Number.isInteger(g)&&g>=h.v&&sr(h,g+1)}ur(i)}return!0},ownKeys(e){H(i);var t=Reflect.ownKeys(e).filter(e=>{var t=n.get(e);return t===void 0||t.v!==Ae});for(var[r,a]of n)a.v!==Ae&&!(r in e)&&t.push(r);return t},setPrototypeOf(){De()}})}var pr,mr,hr,gr;function _r(){if(pr===void 0){pr=window,mr=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;hr=b(t,`firstChild`).get,gr=b(t,`nextSibling`).get,T(e)&&(e[ve]=void 0,e[_e]=null,e[P]=void 0,e.__e=void 0),T(n)&&(n[ye]=void 0)}}function vr(e=``){return document.createTextNode(e)}function yr(e){return hr.call(e)}function br(e){return gr.call(e)}function xr(e,t){if(!Pe)return yr(e);var n=yr(Ie);if(n===null)n=Ie.appendChild(vr());else if(t&&n.nodeType!==3){var r=vr();return n?.before(r),Le(r),r}return t&&Dr(n),Le(n),n}function Sr(e,t=!1){if(!Pe){var n=yr(e);return n instanceof Comment&&n.data===``?br(n):n}if(t){if(Ie?.nodeType!==3){var r=vr();return Ie?.before(r),Le(r),r}Dr(Ie)}return Ie}function Cr(e,t=1,n=!1){let r=Pe?Ie:e;for(var i;t--;)i=r,r=br(r);if(!Pe)return r;if(n){if(r?.nodeType!==3){var a=vr();return r===null?i?.after(a):r.before(a),Le(a),a}Dr(r)}return Le(r),r}function wr(e){e.textContent=``}function Tr(){return!Ke||Jn!==null?!1:(si.f&oe)!==0}function Er(e,t,n){return t==null||t===`http://www.w3.org/1999/xhtml`?n?document.createElement(e,{is:n}):document.createElement(e):n?document.createElementNS(t,e,{is:n}):document.createElementNS(t,e)}function Dr(e){if(e.nodeValue.length<65536)return;let t=e.nextSibling;for(;t!==null&&t.nodeType===3;)t.remove(),e.nodeValue+=t.nodeValue,t=e.nextSibling}function Or(e){var t=ii,n=si;oi(null),ci(null);try{return e()}finally{oi(t),ci(n)}}function kr(e){si===null&&(ii===null&&R(e),L()),ni&&Ce(e)}function Ar(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function jr(e,t){var n=si;n!==null&&n.f&8192&&(e|=ie);var r={ctx:Ze,deps:null,nodes:null,f:e|ne|512,first:null,fn:t,last:null,next:null,parent:n,b:n&&n.b,prev:null,teardown:null,wv:0,ac:null};fn?.register_created_effect(r);var i=r;if(e&4)vn===null?Rn.ensure().schedule(r):vn.push(r);else if(t!==null){try{Ti(r)}catch(e){throw Kr(r),e}i.deps===null&&i.teardown===null&&i.nodes===null&&i.first===i.last&&!(i.f&524288)&&(i=i.first,e&16&&e&65536&&i!==null&&(i.f|=ce))}if(i!==null&&(i.parent=n,n!==null&&Ar(i,n),ii!==null&&ii.f&2&&!(e&64))){var a=ii;(a.effects??(a.effects=[])).push(i)}return r}function Mr(){return ii!==null&&!ai}function Nr(e){let t=jr(8,null);return ct(t,te),t.teardown=e,t}function Pr(e){kr(`$effect`);var t=si.f;if(!ii&&t&32&&Ze!==null&&!Ze.i){var n=Ze;(n.e??(n.e=[])).push(e)}else return Fr(e)}function Fr(e){return jr(4|ue,e)}function Ir(e){Rn.ensure();let t=jr(64|le,e);return(e={})=>new Promise(n=>{e.outro?Yr(t,()=>{Kr(t),n(void 0)}):(Kr(t),n(void 0))})}function Lr(e){return jr(4,e)}function Rr(e){return jr(fe|le,e)}function zr(e,t=0){return jr(8|t,e)}function Br(e,t=[],n=[],r=[]){Jt(r,t,n,t=>{jr(8,()=>{e(...t.map(H))})})}function Vr(e,t=0){return jr(16|t,e)}function Hr(e){return jr(32|le,e)}function Ur(e){var t=e.teardown;if(t!==null){let e=ni,n=ii;ri(!0),oi(null);try{t.call(null)}finally{ri(e),oi(n)}}}function Wr(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){let e=n.ac;e!==null&&Or(()=>{e.abort(be)});var r=n.next;n.f&64?n.parent=null:Kr(n,t),n=r}}function Gr(e){for(var t=e.first;t!==null;){var n=t.next;t.f&32||Kr(t),t=n}}function Kr(e,t=!0){var n=!1;(t||e.f&262144)&&e.nodes!==null&&e.nodes.end!==null&&(qr(e.nodes.start,e.nodes.end),n=!0),e.f|=se,Wr(e,t&&!n),wi(e,0);var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)e.stop();Ur(e),e.f^=se,e.f|=ae;var i=e.parent;i!==null&&i.first!==null&&Jr(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function qr(e,t){for(;e!==null;){var n=e===t?null:br(e);e.remove(),e=n}}function Jr(e){var t=e.parent,n=e.prev,r=e.next;n!==null&&(n.next=r),r!==null&&(r.prev=n),t!==null&&(t.first===e&&(t.first=r),t.last===e&&(t.last=n))}function Yr(e,t,n=!0){var r=[];Xr(e,r,!0);var i=()=>{n&&Kr(e),t&&t()},a=r.length;if(a>0){var o=()=>--a||i();for(var s of r)s.out(o)}else i()}function Xr(e,t,n){if(!(e.f&8192)){e.f^=ie;var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)(e.is_global||n)&&t.push(e);for(var i=e.first;i!==null;){var a=i.next;if(!(i.f&64)){var o=(i.f&65536)!=0||(i.f&32)!=0&&(e.f&16)!=0;Xr(i,t,o?n:!1)}i=a}}}function Zr(e){Qr(e,!0)}function Qr(e,t){if(e.f&8192){e.f^=ie,e.f&1024||(ct(e,ne),Rn.ensure().schedule(e));for(var n=e.first;n!==null;){var r=n.next,i=(n.f&65536)!=0||(n.f&32)!=0;Qr(n,i?t:!1),n=r}var a=e.nodes&&e.nodes.t;if(a!==null)for(let e of a)(e.is_global||t)&&e.in()}}function $r(e,t){if(e.nodes)for(var n=e.nodes.start,r=e.nodes.end;n!==null;){var i=n===r?null:br(n);t.append(n),n=i}}var ei=null,ti=!1,ni=!1;function ri(e){ni=e}var ii=null,ai=!1;function oi(e){ii=e}var si=null;function ci(e){si=e}var li=null;function ui(e){ii!==null&&(!Ke||ii.f&2)&&(li??(li=new Set)).add(e)}var di=null,fi=0,pi=null;function mi(e){pi=e}var hi=1,gi=0,_i=gi;function vi(e){_i=e}function yi(){return++hi}function bi(e){var t=e.f;if(t&2048)return!0;if(t&2&&(e.f&=~N),t&4096){for(var n=e.deps,r=n.length,i=0;ie.wv)return!0}t&512&&mn===null&&ct(e,te)}return!1}function xi(e,t,n=!0){var r=e.reactions;if(r!==null&&!(!Ke&&li!==null&&li.has(e)))for(var i=0;i{e.ac.abort(be)}),e.ac=null);try{e.f|=de;var u=e.fn,d=u();e.f|=oe;var f=e.deps,p=fn?.is_fork;if(di!==null){var m;if(p||wi(e,fi),f!==null&&fi>0)for(f.length=fi+di.length,m=0;m{throw e});throw f}}finally{e[Ni]=t,delete e.currentTarget,oi(u),ci(d)}}}var Bi=globalThis?.window?.trustedTypes&&globalThis.window.trustedTypes.createPolicy(`svelte-trusted-html`,{createHTML:e=>e});function Vi(e){return Bi?.createHTML(e)??e}function Hi(e){var t=Er(`template`);return t.innerHTML=Vi(e.replaceAll(``,``)),t.content}function Ui(e,t){var n=si;n.nodes===null&&(n.nodes={start:e,end:t,a:null,t:null})}function Wi(e,t){var n=(t&1)!=0,r=(t&2)!=0,i,a=!e.startsWith(``);return()=>{if(Pe)return Ui(Ie,null),Ie;i===void 0&&(i=Hi(a?e:``+e),n||(i=yr(i)));var t=r||mr?document.importNode(i,!0):i.cloneNode(!0);if(n){var o=yr(t),s=t.lastChild;Ui(o,s)}else Ui(t,t);return t}}function Gi(e,t){if(Pe){var n=si;(!(n.f&32768)||n.nodes.end===null)&&(n.nodes.end=Ie),Re();return}e!==null&&e.before(t)}function Ki(e,t){var n,r=t==null?``:typeof t==`object`?`${t}`:t;r!==((n=e)[ye]??(n[ye]=e.nodeValue))&&(e[ye]=r,e.nodeValue=`${r}`)}function qi(e,t){return Yi(e,t)}var Ji=new Map;function Yi(e,{target:t,anchor:n,props:r={},events:i,context:a,intro:o=!0,transformError:s}){_r();var c=void 0,l=Ir(()=>{var o=n??t.appendChild(vr());xt(o,{pending:()=>{}},t=>{$e({});var n=Ze;if(a&&(n.c=a),i&&(r.$$events=i),Pe&&Ui(t,null),c=e(t,r)||{},Pe&&(si.nodes.end=Ie,Ie===null||Ie.nodeType!==8||Ie.data!==`]`))throw Me(),ke;et()},s);var l=new Set,u=e=>{for(var n=0;n{for(var e of l)for(let n of[t,document]){var r=Ji.get(n),i=r.get(e);--i==0?(n.removeEventListener(e,zi),r.delete(e),r.size===0&&Ji.delete(n)):r.set(e,i)}Fi.delete(u),o!==n&&o.parentNode?.removeChild(o)}});return Xi.set(c,l),c}var Xi=new WeakMap;function Zi(e,t){let n=Xi.get(e);return n?(Xi.delete(e),n(t)):Promise.resolve()}var Qi=new WeakMap,$i=new WeakMap,ea=new WeakMap,ta=new WeakMap,na=new WeakMap,ra=new WeakMap,ia=new WeakMap,aa=class{constructor(e,t=!0){j(this,`anchor`,void 0),vt(this,Qi,new Map),vt(this,$i,new Map),vt(this,ea,new Map),vt(this,ta,new Set),vt(this,na,!0),vt(this,ra,e=>{if(V(Qi,this).has(e)){var t=V(Qi,this).get(e),n=V($i,this).get(t);if(n)Zr(n),V(ta,this).delete(t);else{var r=V(ea,this).get(t);r&&(Zr(r.effect),V($i,this).set(t,r.effect),V(ea,this).delete(t),r.fragment.lastChild.remove(),this.anchor.before(r.fragment),n=r.effect)}for(let[t,n]of V(Qi,this)){if(V(Qi,this).delete(t),t===e)break;let r=V(ea,this).get(n);r&&(Kr(r.effect),V(ea,this).delete(n))}for(let[e,r]of V($i,this)){if(e===t||V(ta,this).has(e))continue;let i=()=>{if(Array.from(V(Qi,this).values()).includes(e)){var t=document.createDocumentFragment();$r(r,t),t.append(vr()),V(ea,this).set(e,{effect:r,fragment:t})}else Kr(r);V(ta,this).delete(e),V($i,this).delete(e)};V(na,this)||!n?(V(ta,this).add(e),Yr(r,i,!1)):i()}}}),vt(this,ia,e=>{V(Qi,this).delete(e);let t=Array.from(V(Qi,this).values());for(let[e,n]of V(ea,this))t.includes(e)||(Kr(n.effect),V(ea,this).delete(e))}),this.anchor=e,B(na,this,t)}ensure(e,t){var n=fn,r=Tr();if(t&&!V($i,this).has(e)&&!V(ea,this).has(e))if(r){var i=document.createDocumentFragment(),a=vr();i.append(a),V(ea,this).set(e,{effect:Hr(()=>t(a)),fragment:i})}else V($i,this).set(e,Hr(()=>t(this.anchor)));if(V(Qi,this).set(n,e),r){for(let[t,r]of V($i,this))t===e?n.unskip_effect(r):n.skip_effect(r);for(let[t,r]of V(ea,this))t===e?n.unskip_effect(r.effect):n.skip_effect(r.effect);n.oncommit(V(ra,this)),n.ondiscard(V(ia,this))}else Pe&&(this.anchor=Ie),V(ra,this).call(this,n)}};function oa(e,t,n=!1){var r;Pe&&(r=Ie,Re());var i=new aa(e),a=n?ce:0;function o(e,t){if(Pe){var n=He(r);if(e!==parseInt(n.substring(1))){var a=Ve();Le(a),i.anchor=a,Fe(!1),i.ensure(e,t),Fe(!0);return}}i.ensure(e,t)}Vr(()=>{var e=!1;t((t,n=0)=>{e=!0,o(n,t)}),e||o(-1,null)},a)}function sa(e,t){return t}function ca(e,t,n){for(var r=[],i=t.length,a,o=t.length,s=0;s{if(a){if(a.pending.delete(n),a.done.add(n),a.pending.size===0){var t=e.outrogroups;la(e,v(a.done)),t.delete(a),t.size===0&&(e.outrogroups=null)}}else --o},!1)}if(o===0){var c=r.length===0&&n!==null;if(c){var l=n,u=l.parentNode;wr(u),u.append(l),e.items.clear()}la(e,t,!c)}else a={pending:new Set(t),done:new Set},(e.outrogroups??(e.outrogroups=new Set)).add(a)}function la(e,t,n=!0){var r;if(e.pending.size>0){r=new Set;for(let t of e.pending.values())for(let n of t)r.add(e.items.get(n).e)}for(var i=0;i{var e=n();return h(e)?e:e==null?[]:v(e)}),d,f=new Map,p=!0;function m(e){_.effect.f&16384||(_.pending.delete(e),_.fallback=l,pa(_,d,o,t,r),l!==null&&(d.length===0?l.f&33554432?(l.f^=M,ha(l,null,o)):Zr(l):Yr(l,()=>{l=null})))}function g(e){_.pending.delete(e)}var _={effect:Vr(()=>{d=H(u);var e=d.length;let c=!1;Pe&&He(o)===`[!`!=(e===0)&&(o=Ve(),Le(o),Fe(!1),c=!0);for(var h=new Set,_=fn,v=Tr(),y=0;ya(o)):(l=Hr(()=>a(ua??(ua=vr()))),l.f|=M)),e>h.size&&I(``,``,``),Pe&&e>0&&Le(Ve()),!p)if(f.set(_,h),v){for(let[e,t]of s)h.has(e)||_.skip_effect(t.e);_.oncommit(m),_.ondiscard(g)}else m(_);c&&Fe(!0),H(u)}),flags:t,items:s,pending:f,outrogroups:null,fallback:l};p=!1,Pe&&(o=Ie)}function fa(e){for(;e!==null&&!(e.f&32);)e=e.next;return e}function pa(e,t,n,r,i){var a=(r&8)!=0,o=t.length,s=e.items,c=fa(e.effect.first),l,u=null,d,f=[],p=[],m,h,g,_;if(a)for(_=0;_0){var E=r&4&&o===0?n:null;if(a){for(_=0;_{if(d!==void 0)for(g of d)g.nodes?.a?.apply()})}function ma(e,t,n,r,i,a,o,s){var c=o&1?o&16?ir(n):or(n,!1,!1):null,l=o&2?ir(i):null;return{v:c,i:l,e:Hr(()=>(a(t,c??n,l??i,s),()=>{e.delete(r)}))}}function ha(e,t,n){if(e.nodes)for(var r=e.nodes.start,i=e.nodes.end,a=t&&!(t.f&33554432)?t.nodes.start:n;r!==null;){var o=br(r);if(a.before(r),r===i)return;r=o}}function ga(e,t,n){t===null?e.effect.first=n:t.next=n,n===null?e.effect.last=t:n.prev=t}function _a(e,t){Lr(()=>{var n=e.getRootNode(),r=n.host?n:n.head??n.ownerDocument.head;if(!r.querySelector(`#`+t.hash)){let e=Er(`style`);e.id=t.hash,e.textContent=t.code,r.appendChild(e)}})}function va(e,t,n){Lr(()=>{var r=Oi(()=>t(e,n?.())||{});if(n&&r?.update){var i=!1,a={};zr(()=>{var e=n();ki(e),i&&We(a,e)&&(a=e,r.update(e))}),i=!0}if(r?.destroy)return()=>r.destroy()})}var ya=[...` \r\f\xA0\v`];function ba(e,t,n){var r=e==null?``:``+e;if(t&&(r=r?r+` `+t:t),n){for(var i of Object.keys(n))if(n[i])r=r?r+` `+i:i;else if(r.length)for(var a=i.length,o=0;(o=r.indexOf(i,o))>=0;){var s=o+a;(o===0||ya.includes(r[o-1]))&&(s===r.length||ya.includes(r[s]))?r=(o===0?``:r.substring(0,o))+r.substring(s+1):o=s}}return r===``?null:r}function xa(e,t=!1){var n=t?` !important;`:`;`,r=``;for(var i of Object.keys(e)){var a=e[i];a!=null&&a!==``&&(r+=` `+i+`: `+a+n)}return r}function Sa(e){return e[0]!==`-`||e[1]!==`-`?e.toLowerCase():e}function Ca(e,t){if(t){var n=``,r,i;if(Array.isArray(t)?(r=t[0],i=t[1]):r=t,e){e=String(e).replaceAll(/\s*\/\*.*?\*\/\s*/g,``).trim();var a=!1,o=0,s=!1,c=[];r&&c.push(...Object.keys(r).map(Sa)),i&&c.push(...Object.keys(i).map(Sa));var l=0,u=-1;let t=e.length;for(var d=0;d{var n=V(Fa,this).get(e);n.delete(t),n.size===0&&(V(Fa,this).delete(e),V(Ia,this).unobserve(e))}}};Pa=za;function Ba(){return V(Ia,this)??B(Ia,this,new ResizeObserver(e=>{for(var t of e){Pa.entries.set(t.target,t);for(var n of V(Fa,this).get(t.target)||[])n(t)}}))}j(za,`entries`,new WeakMap);function Va(e,t){return e===t||e?.[me]===t}function Ha(e={},t,n,r){var i=Ze.r,a=si;return Lr(()=>{var o,s;return zr(()=>{o=s,s=r?.()||[],Oi(()=>{Va(n(...s),e)||(t(e,...s),o&&Va(n(...o),e)&&t(null,...o))})}),()=>{let r=a;for(;r!==i&&r.parent!==null&&r.parent.f&33554432;)r=r.parent;let o=()=>{s&&Va(n(...s),e)&&t(null,...s)},c=r.teardown;r.teardown=()=>{o(),c?.()}}}),e}function Ua(e,t,n,r){var i=!qe||(n&2)!=0,a=(n&8)!=0,o=(n&16)!=0,s=r,c=!0,l=void 0,u=()=>o&&i?(l??(l=Qt(r)),H(l)):(c&&(c=!1,s=o?Oi(r):r),s);let d;if(a){var f=me in e||he in e;d=b(e,t)?.set??(f&&t in e?n=>e[t]=n:void 0)}var p,m=!1;a?[p,m]=mt(()=>e[t]):p=e[t],p===void 0&&r!==void 0&&(p=u(),d&&(i&&Te(t),d(p)));var h=i?()=>{var n=e[t];return n===void 0?u():(c=!0,n)}:()=>{var n=e[t];return n!==void 0&&(s=void 0),n===void 0?s:n};if(i&&!(n&4))return h;if(d){var g=e.$$legacy;return(function(e,t){return arguments.length>0?((!i||!t||g||m)&&d(t?h():e),e):h()})}var _=!1,v=(n&1?Qt:nn)(()=>(_=!1,h()));a&&H(v);var y=si;return(function(e,t){if(arguments.length>0){let n=t?H(v):i&&a?fr(e):e;return sr(v,n),_=!0,s!==void 0&&(s=n),e}return ni&&_||y.f&16384?v.v:H(v)})}function Wa(e){Ze===null&&F(`onMount`),qe&&Ze.l!==null?Ka(Ze).m.push(e):Pr(()=>{let t=Oi(e);if(typeof t==`function`)return t})}function Ga(e){Ze===null&&F(`onDestroy`),Wa(()=>()=>Oi(e))}function Ka(e){var t=e.l;return t.u??(t.u={a:[],b:[],m:[]})}var qa=class{constructor(e,t,n){this.children=[],this.key=e,this.title=t,this.level=n,this.children=[]}};function Ja(e=document){let t=e.querySelectorAll(`h1, h2, h3, h4, h5, h6`),n=new qa(``,`Root`,0),r=n;return t.forEach(e=>{if(e.style.display==`none`)return;let t=parseInt(e.tagName.slice(1)),n=e.querySelector(`a.md-print-anchor`),i=/^af:\/\/(.+)$/.exec(n?.href??``);if(!i)return;let a=new qa(i[1],e.innerText,t);for(;r.level>=t;)r=r.parent;r.children.push(a),a.parent=r,r=a}),n}function Ya(e){let t=new Map;return e.querySelectorAll(`h1, h2, h3, h4, h5, h6`).forEach((e,n)=>{let r=document.createElement(`a`),i=`${e.tagName.toLowerCase()}-${n}`;r.href=`af://${i}`,r.className=`md-print-anchor`,e.appendChild(r),e.dataset.heading&&t.set(e.dataset.heading,i);let a=e.textContent?.trim();if(a){t.set(a,i),t.set(encodeURIComponent(a),i),t.set(a.replace(/\s+/g,`-`),i),t.set(a.toLowerCase().replace(/\s+/g,`-`),i);let e=a.replace(/[^\w\s-]/g,``).trim();e&&e!==a&&(t.set(e,i),t.set(e.replace(/\s+/g,`-`),i),t.set(e.toLowerCase().replace(/\s+/g,`-`),i))}e.id&&t.set(e.id,i)}),t}function Xa(e){return new Map(Array.from(e).map(([e,t])=>[e?.toLowerCase(),t]))}function Za(e,t,n){let r=Xa(t);e.querySelectorAll(`a.internal-link`).forEach((e,i)=>{let[a,o]=e.dataset.href?.split(`#`)??[];if(o?.startsWith(`^`)&&(e.href=e.dataset.href?.toLowerCase()),o?.length>0){if(a?.length>0&&a!=n)return;let i=t.get(o)||r.get(o?.toLowerCase());i&&!o.startsWith(`^`)&&(e.href=`an://${i}`)}}),e.querySelectorAll(`a[href^='#']`).forEach(e=>{let n=e.getAttribute(`href`);if(!n)return;let i=n.substring(1);if(!i||e.classList.contains(`internal-link`)||i.startsWith(`^`))return;let a=[i,decodeURIComponent(i),i.replace(/-/g,` `),decodeURIComponent(i).replace(/-/g,` `),i.toLowerCase(),decodeURIComponent(i).toLowerCase(),i.toLowerCase().replace(/-/g,` `),decodeURIComponent(i).toLowerCase().replace(/-/g,` `)],o=null;for(let e of a)if(o=t.get(e)||r.get(e.toLowerCase()),o)break;o&&(e.href=`an://${o}`)})}var Qa=e=>Math.round(e*.26458333333719),$a=e=>Math.round(e*3.779527559);function eo(e){if(e instanceof l.TFile)return e.extension==`md`?[e]:[];let t=[];for(let n of e.children)t.push(...eo(n));return t.sort((e,t)=>e.name.localeCompare(t.name)),t}function to(e,t){Array.from(t).forEach(t=>{e.setAttribute(t.name,t.value)})}function no(e,t){return e.replace(/\{\{(.*?)\}\}/g,(e,n)=>t[n.trim()])}function ro(e){return!isNaN(parseFloat(e))}function io(e,t=0){try{let n=parseInt(String(e));return isNaN(n)?t:n}catch{return t}}function ao(e,t=0){try{let n=parseFloat(String(e));return isNaN(n)?t:n}catch{return t}}function oo(){let e=[];return Array.from(document.styleSheets).forEach(t=>{let n=t.ownerNode?.id;if(n?.startsWith(`svelte-`))return;let r=t.ownerNode?.href,i=`/* ----------${n?`id:${n}`:r?`href:${r}`:``}---------- */`;e.push(i);try{Array.from(t?.cssRules??[]).forEach(t=>{e.push(t.cssText)})}catch(e){console.error(e)}}),e.push(...co()),e}var so=` /* ---------- css patch ---------- */ body { overflow: auto !important; } @media print { .print .markdown-preview-view { height: auto !important; } .md-print-anchor, .blockid { white-space: pre !important; border-left: none !important; border-right: none !important; border-top: none !important; border-bottom: none !important; display: inline-block !important; position: absolute !important; width: 1px !important; height: 1px !important; right: 0 !important; outline: 0 !important; background: 0 0 !important; text-decoration: initial !important; text-shadow: initial !important; } } @media print { table { break-inside: auto; } tr { break-inside: avoid; break-after: auto; } } img.__canvas__ { width: 100% !important; height: 100% !important; } `;function co(){return[so,...lo()]}function lo(){let e=[];return Array.from(document.styleSheets).forEach(t=>{try{let n=t?.cssRules??[];Array.from(n).forEach(t=>{if(t.constructor.name==`CSSMediaRule`&&t.conditionText===`print`){let n=t.cssText.replace(/@media print\s*\{(.+)\}/gms,`$1`);e.push(n)}})}catch(e){console.error(e)}}),e}function uo(e){return Array.from({length:e},()=>(16*Math.random()|0).toString(16)).join(``)}function fo(e,t){return e.metadataCache.getFileCache(t)?.frontmatter??{}}async function po({app:e,file:t,config:n,extra:r}){let i=new Date().getTime(),a=e.workspace.getLeaf(!0);await a.openFile(t),a.view;let o=await e.vault.cachedRead(t);o||new l.Notice(`data is empty!`);let s=fo(e,t),c=[];for(let[e,t]of Object.entries(s))(e.toLowerCase()==`cssclass`||e.toLowerCase()==`cssclasses`)&&(Array.isArray(t)?c.push(...t):c.push(t));let u=new l.Component;u.load();let d=document.body.createDiv(`print`),f=d.createDiv({cls:`markdown-preview-view markdown-rendered `+c.join(` `)});f.toggleClass(`rtl`,e.vault.getConfig(`rightToLeft`)),f.toggleClass(`show-properties`,e.vault.getConfig(`propertiesInDocument`)!==`hidden`);let p=r?.title??s?.title??t.basename;f.createEl(`h1`,{text:p},e=>{e.addClass(`__title__`),e.style.display=n?.showTitle?`block`:`none`,e.id=r?.id??``});let m=e.metadataCache.getFileCache(t),h=new Map(Object.entries(m?.blocks??{})),g=(o?.split(` `)??[]).map((e,t)=>{for(let{id:n,position:{start:r,end:i}}of h.values()){let a=`^${n}`;if(e.includes(a)&&t>=r.line&&t<=i.line)return h.delete(n),e.replace(a,` ${a}`)}return e});[...h.values()].forEach(({id:e,position:{start:t,end:n}})=>{let r=t.line;g[r]=`\n\n`+g[r]});let _={children:void 0,appendChild(e){throw this.children=e?.children,Error(`exit`)}},v=[];try{await l.MarkdownRenderer.render(e,g.join(` `),_,t.path,u)}catch{}let y=createFragment();Array.from(_.children).forEach(e=>{y.createDiv({},t=>t.appendChild(e))}),f.appendChild(y),await l.MarkdownRenderer.postProcess(e,{docId:uo(16),sourcePath:t.path,frontmatter:{},promises:v,addChild:function(e){return u.addChild(e)},getSectionInfo:function(){return null},containerEl:f,el:f,displayMode:!0}),await Promise.all(v),d.findAll(`a.internal-link`).forEach(e=>{let[n,r]=e.dataset.href?.split(`#`)??[];(!n||n?.length==0||n==t.basename)&&r?.startsWith(`^`)||e.removeAttribute(`href`)});try{await xo(o,f)}catch{console.warn(`wait timeout`)}So(f);let b=document.implementation.createHTMLDocument(`document`);return b.body.appendChild(d.cloneNode(!0)),d.detach(),u.unload(),d.remove(),b.title=p,a.detach(),console.log(`md render time:${new Date().getTime()-i}ms`),{doc:b,frontMatter:s,file:t}}async function mo({app:e,file:t,config:n,extra:r}){let i=new Date().getTime(),a=await e.vault.cachedRead(t);a||new l.Notice(`${t} content is empty!`);let o=new l.Component;o.load();let s=document.body.createDiv({cls:`print`,attr:{id:t.path}}),{viewEl:c,frontMatter:u}=ho({app:e,file:t,extra:r,config:n,printEl:s});return await _o({app:e,markdown:go({app:e,file:t,data:a}),file:t,comp:o,viewEl:c}),console.log(`md render time:${new Date().getTime()-i}ms`),{doc:s,frontMatter:u,file:t,cleanup:()=>{s.detach(),o.unload(),s.remove()}}}function ho({app:e,file:t,printEl:n,extra:r,config:i}){let a=fo(e,t),o=n.createDiv({cls:`markdown-preview-view markdown-rendered`}),s=Eo(a);o.addClasses(s),o.toggleClass(`rtl`,e.vault.getConfig(`rightToLeft`)),o.toggleClass(`show-properties`,e.vault.getConfig(`propertiesInDocument`)!==`hidden`);let c=r?.title??a?.title??t.basename;return o.createEl(`h1`,{text:c},e=>{e.addClass(`__title__`),e.style.display=i?.showTitle?`block`:`none`,e.id=r?.id??``}),{viewEl:o,frontMatter:a}}function go({app:e,file:t,data:n}){let r=e.metadataCache.getFileCache(t),i=new Map(Object.entries(r?.blocks??{})),a=(n?.split(` `)??[]).map((e,t)=>{for(let{id:n,position:{start:r,end:a}}of i.values()){let o=`^${n}`;if(e.includes(o)&&t>=r.line&&t<=a.line)return i.delete(n),e.replace(o,` ${o}`)}return e});return[...i.values()].forEach(({id:e,position:{start:t,end:n}})=>{let r=t.line;a[r]=`\n\n`+a[r]}),a.join(` `)}async function _o({app:e,markdown:t,file:n,comp:r,viewEl:i}){let a={children:void 0,appendChild(e){throw this.children=e?.children,Error(`exit`)}},o=[];try{await l.MarkdownRenderer.render(e,t,a,n.path,r)}catch{}let s=createFragment();Array.from(a.children).forEach(e=>{s.createDiv({},t=>t.appendChild(e))}),i.appendChild(s),await l.MarkdownRenderer.postProcess(e,{docId:uo(16),sourcePath:n.path,frontmatter:{},promises:o,addChild:function(e){return r.addChild(e)},getSectionInfo:function(){return null},containerEl:i,el:i,displayMode:!0}),await Promise.all(o),i.findAll(`a.internal-link`).forEach(e=>{let[t,r]=e.dataset.href?.split(`#`)??[];(!t||t?.length==0||t==n.basename)&&r?.startsWith(`^`)||e.removeAttribute(`href`)})}function vo(e,t){return Za(e,Ya(e),t),bo(e),e}function yo(e,t){return Za(e,Ya(e),t),e}function bo(e){Array.from(e.querySelectorAll(`span.markdown-embed`)).reverse().forEach(e=>e.innerHTML=encodeURIComponent(e.innerHTML))}async function xo(e,t){(e.includes("```dataview")||e.includes("```gEvent")||e.includes(`![[`))&&await sleep(2e3);try{await wo(t)}catch{await sleep(1e3)}}function So(e){for(let t of Array.from(e.querySelectorAll(`canvas`))){let e=t.toDataURL(),n=document.createElement(`img`);n.src=e,to(n,t.attributes),n.className=`__canvas__`,t.replaceWith(n)}}function Co(e){return` document.body.innerHTML = decodeURIComponent(\`${encodeURIComponent(e.body.innerHTML)}\`); document.head.innerHTML = decodeURIComponent(\`${encodeURIComponent(document.head.innerHTML)}\`); // Function to recursively decode and replace innerHTML of span.markdown-embed elements function decodeAndReplaceEmbed(element) { // Replace the innerHTML with the decoded content element.innerHTML = decodeURIComponent(element.innerHTML); // Check if the new content contains further span.markdown-embed elements const newEmbeds = element.querySelectorAll("span.markdown-embed"); newEmbeds.forEach(decodeAndReplaceEmbed); } // Start the process with all span.markdown-embed elements in the document document.querySelectorAll("span.markdown-embed").forEach(decodeAndReplaceEmbed); document.body.setAttribute("class", \`${document.body.getAttribute(`class`)}\`) document.body.setAttribute("style", \`${document.body.getAttribute(`style`)}\`) document.body.addClass("theme-light"); document.body.removeClass("theme-dark"); document.title = \`${e.title}\`; `}function wo(e,t=2e3,n=200){return new Promise((r,i)=>{let a,o=new MutationObserver(e=>{clearTimeout(a),a=setTimeout(()=>{o.disconnect(),r(!0)},n)});o.observe(e,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),setTimeout(()=>{o.disconnect(),i(Error(`timeout ${t}ms`))},t)})}async function To(e,t){let n=e.win.electron.ipcRenderer;return new Promise(e=>{n.once(`print-to-pdf`,(t,n)=>{e(n)}),n.send(`print-to-pdf`,t)})}function Eo(e){let t=[];for(let[n,r]of Object.entries(e))(n.toLowerCase()==`cssclass`||n.toLowerCase()==`cssclasses`)&&(Array.isArray(r)?t.push(...r):t.push(r));return t}if(typeof window<`u`){var Do,Oo;((Do=(Oo=window).__svelte??(Oo.__svelte={})).v??(Do.v=new Set)).add(`5`)}function ko(e){e.setAttribute(`style`,`width: 100px;`)}function Ao(e){e.setAttribute(`style`,`margin: 0 auto; width: -webkit-fill-available;`)}function jo(e,t){let n=t.settingEl;for(e.classList.add(...Array.from(n.classList));n.firstChild;)e.appendChild(n.firstChild);n.remove()}var Mo=(e,t)=>{let n=new l.Setting(e).setName(t.name);return t.desc&&n.setDesc(t.desc),n.addToggle(e=>{t.tooltip&&e.setTooltip(t.tooltip),e.setValue(t.value).onChange(t.onChange)}),jo(e,n),{destroy(){e.empty()}}},No=(e,t)=>{let n=new l.Setting(e).setName(t.name);return t.desc&&n.setDesc(t.desc),n.addDropdown(e=>{e.addOptions(t.options).setValue(t.value).onChange(t.onChange)}),jo(e,n),{destroy(){e.empty()}}},Po=(e,t)=>(jo(e,new l.Setting(e).setName(t.name).addSlider(e=>{e.setLimits(t.limits[0],t.limits[1],t.limits[2]).setValue(t.value).onChange(n=>{t.onChange(n),e.showTooltip()})})),{destroy(){e.empty()}}),Fo=(e,t)=>{let n=new l.Setting(e).setHeading().addButton(e=>{e.setButtonText(t.text).onClick(t.onClick),t.cta&&e.setCta(),Ao(e.buttonEl)});return t.hidden&&(e.hidden=!0),jo(e,n),{destroy(){e.empty()}}},Io=(e,t)=>(jo(e,new l.Setting(e).setName(t.name).addText(e=>{ko(e.inputEl),e.setPlaceholder(t.input1.placeholder).setValue(t.input1.value);let n=t.input1.isDebounce?(0,l.debounce)(t.input1.onChange,500,!0):t.input1.onChange;e.onChange(n)}).addText(e=>{ko(e.inputEl),e.setPlaceholder(t.input2.placeholder).setValue(t.input2.value);let n=t.input2.isDebounce?(0,l.debounce)(t.input2.onChange,500,!0):t.input2.onChange;e.onChange(n)})),{destroy(){e.empty()}}),Lo=(e,t)=>(t&&(0,l.setIcon)(e,t),{update(t){e.innerHTML=``,(0,l.setIcon)(e,t)}});function Ro(e,t){let n=t=>{e.innerHTML=``;let n=t.cloneNode(!0);n.style.display=`block`,e.appendChild(n)};return n(t),{update:n,destroy(){e.innerHTML=``}}}function zo(e,t){let n=t=>{e.innerHTML=``,t&&(t.style.width=`100%`,e.appendChild(t))};return n(t),{update:n}}var Bo=Wi(`
`),Vo=Wi(`
`,1),Ho=Wi(`
`);function Uo(e,t){$e(t,!0);let n=Ua(t,`config`,15),r=tn(()=>t.plugin.i18n),i=tn(()=>t.plugin.settings),a=tn(()=>n().pageSize===`Custom`),o=tn(()=>n().marginType===`3`),s=Object.fromEntries([`A0`,`A1`,`A2`,`A3`,`A4`,`A5`,`A6`,`Legal`,`Letter`,`Tabloid`,`Ledger`,`Custom`].map(e=>[e,e])),c={0:`None`,1:`Default`,2:`Small`,3:`Custom`},l=tn(()=>t.modal.cssSnippets()),u=tn(()=>Object.keys(H(l)).length>0&&H(i).enabledCss),d=tn(()=>({0:`Not select`,...H(l)}));function f(e){e.key===`Enter`&&t.handleExport()}var p=Ho(),m=xr(p);va(m,(e,t)=>Mo?.(e,t),()=>({name:H(r).exportDialog.filenameAsTitle,tooltip:`Include file name as title`,value:n().showTitle,onChange:e=>{n(n().showTitle=e,!0),t.pdfPreview?.toggleTitle(e)}}));var h=Cr(m,2);va(h,(e,t)=>No?.(e,t),()=>({name:H(r).exportDialog.pageSize,options:s,value:n().pageSize,onChange:async e=>{n(n().pageSize=e,!0),await t.pdfPreview?.handleChangeSize?.()}}));var g=Cr(h,2),_=e=>{var r=Bo();va(r,(e,t)=>Io?.(e,t),()=>({name:`Width/Height`,input1:{placeholder:`width`,value:n().pageWidth??``,isDebounce:!0,onChange:async e=>{n(n().pageWidth=e,!0),await t.pdfPreview?.handleChangeSize?.()}},input2:{placeholder:`height`,value:n().pageHeight??``,onChange:e=>{n(n().pageHeight=e,!0)}}})),Gi(e,r)};oa(g,e=>{H(a)&&e(_)});var v=Cr(g,2);va(v,(e,t)=>No?.(e,t),()=>({name:H(r).exportDialog.margin,desc:`The unit is millimeters.`,options:c,value:n().marginType,onChange:e=>{n(n().marginType=e,!0)}}));var y=Cr(v,2),b=e=>{var t=Vo(),r=Sr(t);va(r,(e,t)=>Io?.(e,t),()=>({name:`Top/Bottom`,input1:{placeholder:`margin top`,value:n().marginTop??``,onChange:e=>{n(n().marginTop=e,!0)}},input2:{placeholder:`margin bottom`,value:n().marginBottom??``,onChange:e=>{n(n().marginBottom=e,!0)}}})),va(Cr(r,2),(e,t)=>Io?.(e,t),()=>({name:`Left/Right`,input1:{placeholder:`margin left`,value:n().marginLeft??``,onChange:e=>{n(n().marginLeft=e,!0)}},input2:{placeholder:`margin right`,value:n().marginRight??``,onChange:e=>{n(n().marginRight=e,!0)}}})),Gi(e,t)};oa(y,e=>{H(o)&&e(b)});var x=Cr(y,2);va(x,(e,t)=>Po?.(e,t),()=>({name:H(r).exportDialog.downscalePercent,limits:[0,200,1],value:n().scale,onChange:e=>{n(n().scale=e,!0)}}));var S=Cr(x,2);va(S,(e,t)=>Mo?.(e,t),()=>({name:H(r).exportDialog.landscape,tooltip:`landscape`,value:n().landscape,onChange:e=>{n(n().landscape=e,!0)}}));var C=Cr(S,2);va(C,(e,t)=>Mo?.(e,t),()=>({name:H(r).exportDialog.displayHeader,tooltip:`Display header`,value:n().displayHeader,onChange:e=>{n(n().displayHeader=e,!0)}}));var w=Cr(C,2);va(w,(e,t)=>Mo?.(e,t),()=>({name:H(r).exportDialog.displayFooter,tooltip:`Display footer`,value:n().displayFooter,onChange:e=>{n(n().displayFooter=e,!0)}}));var T=Cr(w,2);va(T,(e,t)=>Mo?.(e,t),()=>({name:H(r).exportDialog.openAfterExport,tooltip:`Open the exported file after exporting.`,value:n().open,onChange:e=>{n(n().open=e,!0)}}));var E=Cr(T,2),D=e=>{var i=Bo();va(i,(e,t)=>No?.(e,t),()=>({name:H(r).exportDialog.cssSnippets,options:H(d),value:n().cssSnippet??`0`,onChange:async e=>{n(n().cssSnippet=e,!0),await t.pdfPreview?.renderPreview(!1)}})),Gi(e,i)};oa(E,e=>{H(u)&&H(i).version==`1`&&e(D)});var O=Cr(E,2);va(O,(e,t)=>Fo?.(e,t),()=>({text:`Export`,cta:!0,onClick:()=>t.handleExport()}));var k=Cr(O,2),ee=e=>{var n=Bo();va(n,(e,t)=>Fo?.(e,t),()=>({text:`Refresh`,onClick:()=>t.refreshPreview()})),Gi(e,n)};oa(k,e=>{H(i).version==`1`&&e(ee)}),va(Cr(k,2),(e,t)=>Fo?.(e,t),()=>({text:`Debug`,hidden:!H(i)?.debug,onClick:()=>t.pdfPreview?.handleOpenDevTools()})),ze(p),Ii(`keyup`,p,f),Gi(e,p),et()}Li([`keyup`]);var Wo=function(e,t){return Wo=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},Wo(e,t)};function U(e,t){Wo(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Go=function(){return Go=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&a[a.length-1]))&&(o[0]===6||o[0]===2)){n=0;continue}if(o[0]===3&&(!a||o[1]>a[0]&&o[1]>2],t+=Xo[(e[r]&3)<<4|e[r+1]>>4],t+=Xo[(e[r+1]&15)<<2|e[r+2]>>6],t+=Xo[e[r+2]&63];return n%3==2?t=t.substring(0,t.length-1)+`=`:n%3==1&&(t=t.substring(0,t.length-2)+`==`),t},es=function(e){var t=e.length*.75,n=e.length,r,i=0,a,o,s,c;e[e.length-1]===`=`&&(t--,e[e.length-2]===`=`&&t--);var l=new Uint8Array(t);for(r=0;r>4,l[i++]=(o&15)<<4|s>>2,l[i++]=(s&3)<<6|c&63;return l},ts=/^(data)?:?([\w\/\+]+)?;?(charset=[\w-]+|base64)?.*,/i,ns=function(e){var t=e.trim(),n=t.substring(0,100).match(ts);if(!n)return es(t);var r=n[0];return es(t.substring(r.length))},rs=function(e){return e.charCodeAt(0)},is=function(e){return e.codePointAt(0)},as=function(e,t){return ls(e.toString(16),t,`0`).toUpperCase()},os=function(e){return as(e,2)},ss=function(e){return String.fromCharCode(e)},cs=function(e){return ss(parseInt(e,16))},ls=function(e,t,n){for(var r=``,i=0,a=t-e.length;i=55296&&n<=56319&&e.length>i&&(r=e.charCodeAt(i),r>=56320&&r<=57343&&(a=2)),[e.slice(t,t+a),a]},vs=function(e){for(var t=[],n=0,r=e.length;nn&&l(),o+=f,s+=p}}return l(),c},xs=/^D:(\d\d\d\d)(\d\d)?(\d\d)?(\d\d)?(\d\d)?(\d\d)?([+\-Z])?(\d\d)?'?(\d\d)?'?$/,Ss=function(e){var t=e.match(xs);if(t){var n=t[1],r=t[2],i=r===void 0?`01`:r,a=t[3],o=a===void 0?`01`:a,s=t[4],c=s===void 0?`00`:s,l=t[5],u=l===void 0?`00`:l,d=t[6],f=d===void 0?`00`:d,p=t[7],m=p===void 0?`Z`:p,h=t[8],g=h===void 0?`00`:h,_=t[9],v=_===void 0?`00`:_,y=m===`Z`?`Z`:``+m+g+`:`+v;return new Date(n+`-`+i+`-`+o+`T`+c+`:`+u+`:`+f+y)}},Cs=function(e,t){for(var n=0,r;n=0&&e<=65535},Bs=function(e){return e>=65536&&e<=1114111},Vs=function(e){return Math.floor((e-65536)/1024)+55296},Hs=function(e){return(e-65536)%1024+56320},Us;(function(e){e.BigEndian=`BigEndian`,e.LittleEndian=`LittleEndian`})(Us||(Us={}));for(var Ws=`�`.codePointAt(0),Gs=function(e,t){if(t===void 0&&(t=!0),e.length<=1)return String.fromCodePoint(Ws);for(var n=t?Ys(e):Us.BigEndian,r=t?2:0,i=[];e.length-r>=2;){var a=Js(e[r++],e[r++],n);if(Ks(a))if(e.length-r<2)i.push(Ws);else{var o=Js(e[r++],e[r++],n);qs(o)?i.push(a,o):i.push(Ws)}else qs(a)?(r+=2,i.push(Ws)):i.push(a)}return r=55296&&e<=56319},qs=function(e){return e>=56320&&e<=57343},Js=function(e,t,n){if(n===Us.LittleEndian)return t<<8|e;if(n===Us.BigEndian)return e<<8|t;throw Error(`Invalid byteOrder: `+n)},Ys=function(e){return Xs(e)?Us.BigEndian:Zs(e)?Us.LittleEndian:Us.BigEndian},Xs=function(e){return e[0]===254&&e[1]===255},Zs=function(e){return e[0]===255&&e[1]===254},Qs=function(e){return Xs(e)||Zs(e)},$s=function(e){var t=String(e);if(Math.abs(e)<1){var n=parseInt(e.toString().split(`e-`)[1]);if(n){var r=e<0;r&&(e*=-1),e*=10**(n-1),t=`0.`+Array(n).join(`0`)+e.toString().substring(2),r&&(t=`-`+t)}}else{var n=parseInt(e.toString().split(`+`)[1]);n>20&&(n-=20,e/=10**n,t=e.toString()+Array(n+1).join(`0`))}return t},ec=function(e){return Math.ceil(e.toString(2).length/8)},tc=function(e){for(var t=new Uint8Array(ec(e)),n=1;n<=t.length;n++)t[n-1]=e>>(t.length-n)*8;return t},nc=function(e){throw Error(e)},rc=o((e=>{var t=typeof Uint8Array<`u`&&typeof Uint16Array<`u`&&typeof Int32Array<`u`;function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var r=t.shift();if(r){if(typeof r!=`object`)throw TypeError(r+`must be non-object`);for(var i in r)n(r,i)&&(e[i]=r[i])}}return e},e.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var r={arraySet:function(e,t,n,r,i){if(t.subarray&&e.subarray){e.set(t.subarray(n,n+r),i);return}for(var a=0;a{var t=rc(),n=4,r=0,i=1,a=2;function o(e){for(var t=e.length;--t>=0;)e[t]=0}var s=0,c=1,l=2,u=3,d=258,f=29,p=256,m=p+1+f,h=30,g=19,_=2*m+1,v=15,y=16,b=7,x=256,S=16,C=17,w=18,T=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],E=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],D=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],O=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],k=512,ee=Array((m+2)*2);o(ee);var A=Array(h*2);o(A);var j=Array(k);o(j);var te=Array(d-u+1);o(te);var ne=Array(f);o(ne);var re=Array(h);o(re);function ie(e,t,n,r,i){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=e&&e.length}var ae,oe,se;function ce(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function le(e){return e<256?j[e]:j[256+(e>>>7)]}function ue(e,t){e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255}function M(e,t,n){e.bi_valid>y-n?(e.bi_buf|=t<>y-e.bi_valid,e.bi_valid+=n-y):(e.bi_buf|=t<>>=1,n<<=1;while(--t>0);return n>>>1}function fe(e){e.bi_valid===16?(ue(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)}function pe(e,t){var n=t.dyn_tree,r=t.max_code,i=t.stat_desc.static_tree,a=t.stat_desc.has_stree,o=t.stat_desc.extra_bits,s=t.stat_desc.extra_base,c=t.stat_desc.max_length,l,u,d,f,p,m,h=0;for(f=0;f<=v;f++)e.bl_count[f]=0;for(n[e.heap[e.heap_max]*2+1]=0,l=e.heap_max+1;l<_;l++)u=e.heap[l],f=n[n[u*2+1]*2+1]+1,f>c&&(f=c,h++),n[u*2+1]=f,!(u>r)&&(e.bl_count[f]++,p=0,u>=s&&(p=o[u-s]),m=n[u*2],e.opt_len+=m*(f+p),a&&(e.static_len+=m*(i[u*2+1]+p)));if(h!==0){do{for(f=c-1;e.bl_count[f]===0;)f--;e.bl_count[f]--,e.bl_count[f+1]+=2,e.bl_count[c]--,h-=2}while(h>0);for(f=c;f!==0;f--)for(u=e.bl_count[f];u!==0;)d=e.heap[--l],!(d>r)&&(n[d*2+1]!==f&&(e.opt_len+=(f-n[d*2+1])*n[d*2],n[d*2+1]=f),u--)}}function me(e,t,n){var r=Array(v+1),i=0,a,o;for(a=1;a<=v;a++)r[a]=i=i+n[a-1]<<1;for(o=0;o<=t;o++){var s=e[o*2+1];s!==0&&(e[o*2]=de(r[s]++,s))}}function he(){var e,t,n,r,i,a=Array(v+1);for(n=0,r=0;r>=7;r8?ue(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function ve(e,n,r,i){_e(e),i&&(ue(e,r),ue(e,~r)),t.arraySet(e.pending_buf,e.window,n,r,e.pending),e.pending+=r}function P(e,t,n,r){var i=t*2,a=n*2;return e[i]>1;o>=1;o--)ye(e,n,o);l=a;do o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],ye(e,n,1),s=e.heap[1],e.heap[--e.heap_max]=o,e.heap[--e.heap_max]=s,n[l*2]=n[o*2]+n[s*2],e.depth[l]=(e.depth[o]>=e.depth[s]?e.depth[o]:e.depth[s])+1,n[o*2+1]=n[s*2+1]=l,e.heap[1]=l++,ye(e,n,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],pe(e,t),me(n,c,e.bl_count)}function F(e,t,n){var r,i=-1,a,o=t[1],s=0,c=7,l=4;for(o===0&&(c=138,l=3),t[(n+1)*2+1]=65535,r=0;r<=n;r++)a=o,o=t[(r+1)*2+1],!(++s=3&&e.bl_tree[O[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t}function Ce(e,t,n,r){var i;for(M(e,t-257,5),M(e,n-1,5),M(e,r-4,4),i=0;i>>=1)if(t&1&&e.dyn_ltree[n*2]!==0)return r;if(e.dyn_ltree[18]!==0||e.dyn_ltree[20]!==0||e.dyn_ltree[26]!==0)return i;for(n=32;n0?(e.strm.data_type===a&&(e.strm.data_type=L(e)),xe(e,e.l_desc),xe(e,e.d_desc),u=I(e),o=e.opt_len+3+7>>>3,s=e.static_len+3+7>>>3,s<=o&&(o=s)):o=s=r+5,r+4<=o&&t!==-1?Te(e,t,r,i):e.strategy===n||s===o?(M(e,(c<<1)+ +!!i,3),be(e,ee,A)):(M(e,(l<<1)+ +!!i,3),Ce(e,e.l_desc.max_code+1,e.d_desc.max_code+1,u+1),be(e,e.dyn_ltree,e.dyn_dtree)),ge(e),i&&_e(e)}function z(e,t,n){return e.pending_buf[e.d_buf+e.last_lit*2]=t>>>8&255,e.pending_buf[e.d_buf+e.last_lit*2+1]=t&255,e.pending_buf[e.l_buf+e.last_lit]=n&255,e.last_lit++,t===0?e.dyn_ltree[n*2]++:(e.matches++,t--,e.dyn_ltree[(te[n]+p+1)*2]++,e.dyn_dtree[le(t)*2]++),e.last_lit===e.lit_bufsize-1}e._tr_init=we,e._tr_stored_block=Te,e._tr_flush_block=De,e._tr_tally=z,e._tr_align=Ee})),ac=o(((e,t)=>{function n(e,t,n,r){for(var i=e&65535|0,a=e>>>16&65535|0,o=0;n!==0;){o=n>2e3?2e3:n,n-=o;do i=i+t[r++]|0,a=a+i|0;while(--o);i%=65521,a%=65521}return i|a<<16|0}t.exports=n})),oc=o(((e,t)=>{function n(){for(var e,t=[],n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=e&1?3988292384^e>>>1:e>>>1;t[n]=e}return t}var r=n();function i(e,t,n,i){var a=r,o=i+n;e^=-1;for(var s=i;s>>8^a[(e^t[s])&255];return e^-1}t.exports=i})),sc=o(((e,t)=>{t.exports={2:`need dictionary`,1:`stream end`,0:``,"-1":`file error`,"-2":`stream error`,"-3":`data error`,"-4":`insufficient memory`,"-5":`buffer error`,"-6":`incompatible version`}})),cc=o((e=>{var t=rc(),n=ic(),r=ac(),i=oc(),a=sc(),o=0,s=1,c=3,l=4,u=5,d=0,f=1,p=-2,m=-3,h=-5,g=-1,_=1,v=2,y=3,b=4,x=0,S=2,C=8,w=9,T=15,E=8,D=286,O=30,k=19,ee=2*D+1,A=15,j=3,te=258,ne=te+j+1,re=32,ie=42,ae=69,oe=73,se=91,ce=103,le=113,ue=666,M=1,N=2,de=3,fe=4,pe=3;function me(e,t){return e.msg=a[t],t}function he(e){return(e<<1)-(e>4?9:0)}function ge(e){for(var t=e.length;--t>=0;)e[t]=0}function _e(e){var n=e.state,r=n.pending;r>e.avail_out&&(r=e.avail_out),r!==0&&(t.arraySet(e.output,n.pending_buf,n.pending_out,r,e.next_out),e.next_out+=r,n.pending_out+=r,e.total_out+=r,e.avail_out-=r,n.pending-=r,n.pending===0&&(n.pending_out=0))}function ve(e,t){n._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,_e(e.strm)}function P(e,t){e.pending_buf[e.pending++]=t}function ye(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255}function be(e,n,a,o){var s=e.avail_in;return s>o&&(s=o),s===0?0:(e.avail_in-=s,t.arraySet(n,e.input,e.next_in,s,a),e.state.wrap===1?e.adler=r(e.adler,n,s,a):e.state.wrap===2&&(e.adler=i(e.adler,n,s,a)),e.next_in+=s,e.total_in+=s,s)}function xe(e,t){var n=e.max_chain_length,r=e.strstart,i,a,o=e.prev_length,s=e.nice_match,c=e.strstart>e.w_size-ne?e.strstart-(e.w_size-ne):0,l=e.window,u=e.w_mask,d=e.prev,f=e.strstart+te,p=l[r+o-1],m=l[r+o];e.prev_length>=e.good_match&&(n>>=2),s>e.lookahead&&(s=e.lookahead);do{if(i=t,l[i+o]!==m||l[i+o-1]!==p||l[i]!==l[r]||l[++i]!==l[r+1])continue;r+=2,i++;do;while(l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&ro){if(e.match_start=t,o=a,a>=s)break;p=l[r+o-1],m=l[r+o]}}while((t=d[t&u])>c&&--n!==0);return o<=e.lookahead?o:e.lookahead}function F(e){var n=e.w_size,r,i,a,o,s;do{if(o=e.window_size-e.lookahead-e.strstart,e.strstart>=n+(n-ne)){t.arraySet(e.window,e.window,n,n,0),e.match_start-=n,e.strstart-=n,e.block_start-=n,i=e.hash_size,r=i;do a=e.head[--r],e.head[r]=a>=n?a-n:0;while(--i);i=n,r=i;do a=e.prev[--r],e.prev[r]=a>=n?a-n:0;while(--i);o+=n}if(e.strm.avail_in===0)break;if(i=be(e.strm,e.window,e.strstart+e.lookahead,o),e.lookahead+=i,e.lookahead+e.insert>=j)for(s=e.strstart-e.insert,e.ins_h=e.window[s],e.ins_h=(e.ins_h<e.pending_buf_size-5&&(n=e.pending_buf_size-5);;){if(e.lookahead<=1){if(F(e),e.lookahead===0&&t===o)return M;if(e.lookahead===0)break}e.strstart+=e.lookahead,e.lookahead=0;var r=e.block_start+n;if((e.strstart===0||e.strstart>=r)&&(e.lookahead=e.strstart-r,e.strstart=r,ve(e,!1),e.strm.avail_out===0)||e.strstart-e.block_start>=e.w_size-ne&&(ve(e,!1),e.strm.avail_out===0))return M}return e.insert=0,t===l?(ve(e,!0),e.strm.avail_out===0?de:fe):(e.strstart>e.block_start&&(ve(e,!1),e.strm.avail_out),M)}function I(e,t){for(var r,i;;){if(e.lookahead=j&&(e.ins_h=(e.ins_h<=j)if(i=n._tr_tally(e,e.strstart-e.match_start,e.match_length-j),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=j){e.match_length--;do e.strstart++,e.ins_h=(e.ins_h<=j&&(e.ins_h=(e.ins_h<4096)&&(e.match_length=j-1)),e.prev_length>=j&&e.match_length<=e.prev_length){a=e.strstart+e.lookahead-j,i=n._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-j),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=a&&(e.ins_h=(e.ins_h<=j&&e.strstart>0&&(a=e.strstart-1,i=c[a],i===c[++a]&&i===c[++a]&&i===c[++a])){s=e.strstart+te;do;while(i===c[++a]&&i===c[++a]&&i===c[++a]&&i===c[++a]&&i===c[++a]&&i===c[++a]&&i===c[++a]&&i===c[++a]&&ae.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=j?(r=n._tr_tally(e,1,e.match_length-j),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=n._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(ve(e,!1),e.strm.avail_out===0))return M}return e.insert=0,t===l?(ve(e,!0),e.strm.avail_out===0?de:fe):e.last_lit&&(ve(e,!1),e.strm.avail_out===0)?M:N}function R(e,t){for(var r;;){if(e.lookahead===0&&(F(e),e.lookahead===0)){if(t===o)return M;break}if(e.match_length=0,r=n._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(ve(e,!1),e.strm.avail_out===0))return M}return e.insert=0,t===l?(ve(e,!0),e.strm.avail_out===0?de:fe):e.last_lit&&(ve(e,!1),e.strm.avail_out===0)?M:N}function we(e,t,n,r,i){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=i}var Te=[new we(0,0,0,0,Se),new we(4,4,8,4,I),new we(4,5,16,8,I),new we(4,6,32,32,I),new we(4,4,16,16,Ce),new we(8,16,32,32,Ce),new we(8,16,128,128,Ce),new we(8,32,128,256,Ce),new we(32,128,258,1024,Ce),new we(32,258,258,4096,Ce)];function Ee(e){e.window_size=2*e.w_size,ge(e.head),e.max_lazy_match=Te[e.level].max_lazy,e.good_match=Te[e.level].good_length,e.nice_match=Te[e.level].nice_length,e.max_chain_length=Te[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=j-1,e.match_available=0,e.ins_h=0}function De(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=C,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new t.Buf16(ee*2),this.dyn_dtree=new t.Buf16((2*O+1)*2),this.bl_tree=new t.Buf16((2*k+1)*2),ge(this.dyn_ltree),ge(this.dyn_dtree),ge(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new t.Buf16(A+1),this.heap=new t.Buf16(2*D+1),ge(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new t.Buf16(2*D+1),ge(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function z(e){var t;return!e||!e.state?me(e,p):(e.total_in=e.total_out=0,e.data_type=S,t=e.state,t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?ie:le,e.adler=t.wrap===2?0:1,t.last_flush=o,n._tr_init(t),d)}function Oe(e){var t=z(e);return t===d&&Ee(e.state),t}function ke(e,t){return!e||!e.state||e.state.wrap!==2?p:(e.state.gzhead=t,d)}function Ae(e,n,r,i,a,o){if(!e)return p;var s=1;if(n===g&&(n=6),i<0?(s=0,i=-i):i>15&&(s=2,i-=16),a<1||a>w||r!==C||i<8||i>15||n<0||n>9||o<0||o>b)return me(e,p);i===8&&(i=9);var c=new De;return e.state=c,c.strm=e,c.wrap=s,c.gzhead=null,c.w_bits=i,c.w_size=1<u||t<0)return e?me(e,p):p;if(a=e.state,!e.output||!e.input&&e.avail_in!==0||a.status===ue&&t!==l)return me(e,e.avail_out===0?h:p);if(a.strm=e,r=a.last_flush,a.last_flush=t,a.status===ie)if(a.wrap===2)e.adler=0,P(a,31),P(a,139),P(a,8),a.gzhead?(P(a,+!!a.gzhead.text+(a.gzhead.hcrc?2:0)+(a.gzhead.extra?4:0)+(a.gzhead.name?8:0)+(a.gzhead.comment?16:0)),P(a,a.gzhead.time&255),P(a,a.gzhead.time>>8&255),P(a,a.gzhead.time>>16&255),P(a,a.gzhead.time>>24&255),P(a,a.level===9?2:a.strategy>=v||a.level<2?4:0),P(a,a.gzhead.os&255),a.gzhead.extra&&a.gzhead.extra.length&&(P(a,a.gzhead.extra.length&255),P(a,a.gzhead.extra.length>>8&255)),a.gzhead.hcrc&&(e.adler=i(e.adler,a.pending_buf,a.pending,0)),a.gzindex=0,a.status=ae):(P(a,0),P(a,0),P(a,0),P(a,0),P(a,0),P(a,a.level===9?2:a.strategy>=v||a.level<2?4:0),P(a,pe),a.status=le);else{var _=C+(a.w_bits-8<<4)<<8,b=-1;b=a.strategy>=v||a.level<2?0:a.level<6?1:a.level===6?2:3,_|=b<<6,a.strstart!==0&&(_|=re),_+=31-_%31,a.status=le,ye(a,_),a.strstart!==0&&(ye(a,e.adler>>>16),ye(a,e.adler&65535)),e.adler=1}if(a.status===ae)if(a.gzhead.extra){for(m=a.pending;a.gzindex<(a.gzhead.extra.length&65535)&&!(a.pending===a.pending_buf_size&&(a.gzhead.hcrc&&a.pending>m&&(e.adler=i(e.adler,a.pending_buf,a.pending-m,m)),_e(e),m=a.pending,a.pending===a.pending_buf_size));)P(a,a.gzhead.extra[a.gzindex]&255),a.gzindex++;a.gzhead.hcrc&&a.pending>m&&(e.adler=i(e.adler,a.pending_buf,a.pending-m,m)),a.gzindex===a.gzhead.extra.length&&(a.gzindex=0,a.status=oe)}else a.status=oe;if(a.status===oe)if(a.gzhead.name){m=a.pending;do{if(a.pending===a.pending_buf_size&&(a.gzhead.hcrc&&a.pending>m&&(e.adler=i(e.adler,a.pending_buf,a.pending-m,m)),_e(e),m=a.pending,a.pending===a.pending_buf_size)){g=1;break}g=a.gzindexm&&(e.adler=i(e.adler,a.pending_buf,a.pending-m,m)),g===0&&(a.gzindex=0,a.status=se)}else a.status=se;if(a.status===se)if(a.gzhead.comment){m=a.pending;do{if(a.pending===a.pending_buf_size&&(a.gzhead.hcrc&&a.pending>m&&(e.adler=i(e.adler,a.pending_buf,a.pending-m,m)),_e(e),m=a.pending,a.pending===a.pending_buf_size)){g=1;break}g=a.gzindexm&&(e.adler=i(e.adler,a.pending_buf,a.pending-m,m)),g===0&&(a.status=ce)}else a.status=ce;if(a.status===ce&&(a.gzhead.hcrc?(a.pending+2>a.pending_buf_size&&_e(e),a.pending+2<=a.pending_buf_size&&(P(a,e.adler&255),P(a,e.adler>>8&255),e.adler=0,a.status=le)):a.status=le),a.pending!==0){if(_e(e),e.avail_out===0)return a.last_flush=-1,d}else if(e.avail_in===0&&he(t)<=he(r)&&t!==l)return me(e,h);if(a.status===ue&&e.avail_in!==0)return me(e,h);if(e.avail_in!==0||a.lookahead!==0||t!==o&&a.status!==ue){var x=a.strategy===v?R(a,t):a.strategy===y?L(a,t):Te[a.level].func(a,t);if((x===de||x===fe)&&(a.status=ue),x===M||x===de)return e.avail_out===0&&(a.last_flush=-1),d;if(x===N&&(t===s?n._tr_align(a):t!==u&&(n._tr_stored_block(a,0,0,!1),t===c&&(ge(a.head),a.lookahead===0&&(a.strstart=0,a.block_start=0,a.insert=0))),_e(e),e.avail_out===0))return a.last_flush=-1,d}return t===l?a.wrap<=0?f:(a.wrap===2?(P(a,e.adler&255),P(a,e.adler>>8&255),P(a,e.adler>>16&255),P(a,e.adler>>24&255),P(a,e.total_in&255),P(a,e.total_in>>8&255),P(a,e.total_in>>16&255),P(a,e.total_in>>24&255)):(ye(a,e.adler>>>16),ye(a,e.adler&65535)),_e(e),a.wrap>0&&(a.wrap=-a.wrap),a.pending===0?f:d):d}function Ne(e){var t;return!e||!e.state?p:(t=e.state.status,t!==ie&&t!==ae&&t!==oe&&t!==se&&t!==ce&&t!==le&&t!==ue?me(e,p):(e.state=null,t===le?me(e,m):d))}function Pe(e,n){var i=n.length,a,o,s,c,l,u,f,m;if(!e||!e.state||(a=e.state,c=a.wrap,c===2||c===1&&a.status!==ie||a.lookahead))return p;for(c===1&&(e.adler=r(e.adler,n,i,0)),a.wrap=0,i>=a.w_size&&(c===0&&(ge(a.head),a.strstart=0,a.block_start=0,a.insert=0),m=new t.Buf8(a.w_size),t.arraySet(m,n,i-a.w_size,a.w_size,0),n=m,i=a.w_size),l=e.avail_in,u=e.next_in,f=e.input,e.avail_in=i,e.next_in=0,e.input=n,F(a);a.lookahead>=j;){o=a.strstart,s=a.lookahead-(j-1);do a.ins_h=(a.ins_h<{var t=rc(),n=!0,r=!0;try{String.fromCharCode.apply(null,[0])}catch{n=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{r=!1}for(var i=new t.Buf8(256),a=0;a<256;a++)i[a]=a>=252?6:a>=248?5:a>=240?4:a>=224?3:a>=192?2:1;i[254]=i[254]=1,e.string2buf=function(e){var n,r,i,a,o,s=e.length,c=0;for(a=0;a>>6,n[o++]=128|r&63):r<65536?(n[o++]=224|r>>>12,n[o++]=128|r>>>6&63,n[o++]=128|r&63):(n[o++]=240|r>>>18,n[o++]=128|r>>>12&63,n[o++]=128|r>>>6&63,n[o++]=128|r&63);return n};function o(e,i){if(i<65534&&(e.subarray&&r||!e.subarray&&n))return String.fromCharCode.apply(null,t.shrinkBuf(e,i));for(var a=``,o=0;o4){l[r++]=65533,n+=s-1;continue}for(a&=s===2?31:s===3?15:7;s>1&&n1){l[r++]=65533;continue}a<65536?l[r++]=a:(a-=65536,l[r++]=55296|a>>10&1023,l[r++]=56320|a&1023)}return o(l,r)},e.utf8border=function(e,t){var n;for(t=t||e.length,t>e.length&&(t=e.length),n=t-1;n>=0&&(e[n]&192)==128;)n--;return n<0||n===0?t:n+i[e[n]]>t?n:t}})),uc=o(((e,t)=>{function n(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg=``,this.state=null,this.data_type=2,this.adler=0}t.exports=n})),dc=o((e=>{var t=cc(),n=rc(),r=lc(),i=sc(),a=uc(),o=Object.prototype.toString,s=0,c=4,l=0,u=1,d=2,f=-1,p=0,m=8;function h(e){if(!(this instanceof h))return new h(e);this.options=n.assign({level:f,method:m,chunkSize:16384,windowBits:15,memLevel:8,strategy:p,to:``},e||{});var s=this.options;s.raw&&s.windowBits>0?s.windowBits=-s.windowBits:s.gzip&&s.windowBits>0&&s.windowBits<16&&(s.windowBits+=16),this.err=0,this.msg=``,this.ended=!1,this.chunks=[],this.strm=new a,this.strm.avail_out=0;var c=t.deflateInit2(this.strm,s.level,s.method,s.windowBits,s.memLevel,s.strategy);if(c!==l)throw Error(i[c]);if(s.header&&t.deflateSetHeader(this.strm,s.header),s.dictionary){var u=typeof s.dictionary==`string`?r.string2buf(s.dictionary):o.call(s.dictionary)===`[object ArrayBuffer]`?new Uint8Array(s.dictionary):s.dictionary;if(c=t.deflateSetDictionary(this.strm,u),c!==l)throw Error(i[c]);this._dict_set=!0}}h.prototype.push=function(e,i){var a=this.strm,f=this.options.chunkSize,p,m;if(this.ended)return!1;m=i===~~i?i:i===!0?c:s,typeof e==`string`?a.input=r.string2buf(e):o.call(e)===`[object ArrayBuffer]`?a.input=new Uint8Array(e):a.input=e,a.next_in=0,a.avail_in=a.input.length;do{if(a.avail_out===0&&(a.output=new n.Buf8(f),a.next_out=0,a.avail_out=f),p=t.deflate(a,m),p!==u&&p!==l)return this.onEnd(p),this.ended=!0,!1;(a.avail_out===0||a.avail_in===0&&(m===c||m===d))&&(this.options.to===`string`?this.onData(r.buf2binstring(n.shrinkBuf(a.output,a.next_out))):this.onData(n.shrinkBuf(a.output,a.next_out)))}while((a.avail_in>0||a.avail_out===0)&&p!==u);return m===c?(p=t.deflateEnd(this.strm),this.onEnd(p),this.ended=!0,p===l):m===d?(this.onEnd(l),a.avail_out=0,!0):!0},h.prototype.onData=function(e){this.chunks.push(e)},h.prototype.onEnd=function(e){e===l&&(this.options.to===`string`?this.result=this.chunks.join(``):this.result=n.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function g(e,t){var n=new h(t);if(n.push(e,!0),n.err)throw n.msg||i[n.err];return n.result}function _(e,t){return t=t||{},t.raw=!0,g(e,t)}function v(e,t){return t=t||{},t.gzip=!0,g(e,t)}e.Deflate=h,e.deflate=g,e.deflateRaw=_,e.gzip=v})),fc=o(((e,t)=>{var n=30,r=12;t.exports=function(e,t){var i=e.state,a=e.next_in,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D=e.input,O;o=a+(e.avail_in-5),s=e.next_out,O=e.output,c=s-(t-e.avail_out),l=s+(e.avail_out-257),u=i.dmax,d=i.wsize,f=i.whave,p=i.wnext,m=i.window,h=i.hold,g=i.bits,_=i.lencode,v=i.distcode,y=(1<>>24,h>>>=S,g-=S,S=x>>>16&255,S===0)O[s++]=x&65535;else if(S&16){C=x&65535,S&=15,S&&(g>>=S,g-=S),g<15&&(h+=D[a++]<>>24,h>>>=S,g-=S,S=x>>>16&255,S&16){if(w=x&65535,S&=15,gu){e.msg=`invalid distance too far back`,i.mode=n;break top}if(h>>>=S,g-=S,S=s-c,w>S){if(S=w-S,S>f&&i.sane){e.msg=`invalid distance too far back`,i.mode=n;break top}if(T=0,E=m,p===0){if(T+=d-S,S2;)O[s++]=E[T++],O[s++]=E[T++],O[s++]=E[T++],C-=3;C&&(O[s++]=E[T++],C>1&&(O[s++]=E[T++]))}else{T=s-w;do O[s++]=O[T++],O[s++]=O[T++],O[s++]=O[T++],C-=3;while(C>2);C&&(O[s++]=O[T++],C>1&&(O[s++]=O[T++]))}}else if(S&64){e.msg=`invalid distance code`,i.mode=n;break top}else{x=v[(x&65535)+(h&(1<>3,a-=C,g-=C<<3,h&=(1<{var n=rc(),r=15,i=852,a=592,o=0,s=1,c=2,l=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],u=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],d=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],f=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];t.exports=function(e,t,p,m,h,g,_,v){var y=v.bits,b=0,x=0,S=0,C=0,w=0,T=0,E=0,D=0,O=0,k=0,ee,A,j,te,ne,re=null,ie=0,ae,oe=new n.Buf16(r+1),se=new n.Buf16(r+1),ce=null,le=0,ue,M,N;for(b=0;b<=r;b++)oe[b]=0;for(x=0;x=1&&oe[C]===0;C--);if(w>C&&(w=C),C===0)return h[g++]=20971520,h[g++]=20971520,v.bits=1,0;for(S=1;S0&&(e===o||C!==1))return-1;for(se[1]=0,b=1;bi||e===c&&O>a)return 1;for(;;){ue=b-E,_[x]ae?(M=ce[le+_[x]],N=re[ie+_[x]]):(M=96,N=0),ee=1<>E)+A]=ue<<24|M<<16|N|0;while(A!==0);for(ee=1<>=1;if(ee===0?k=0:(k&=ee-1,k+=ee),x++,--oe[b]===0){if(b===C)break;b=t[p+_[x]]}if(b>w&&(k&te)!==j){for(E===0&&(E=w),ne+=S,T=b-E,D=1<i||e===c&&O>a)return 1;j=k&te,h[j]=w<<24|T<<16|ne-g|0}}return k!==0&&(h[ne+k]=b-E<<24|4194304),v.bits=w,0}})),mc=o((e=>{var t=rc(),n=ac(),r=oc(),i=fc(),a=pc(),o=0,s=1,c=2,l=4,u=5,d=6,f=0,p=1,m=2,h=-2,g=-3,_=-4,v=-5,y=8,b=1,x=2,S=3,C=4,w=5,T=6,E=7,D=8,O=9,k=10,ee=11,A=12,j=13,te=14,ne=15,re=16,ie=17,ae=18,oe=19,se=20,ce=21,le=22,ue=23,M=24,N=25,de=26,fe=27,pe=28,me=29,he=30,ge=31,_e=32,ve=852,P=592,ye=15;function be(e){return(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24)}function xe(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new t.Buf16(320),this.work=new t.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function F(e){var n;return!e||!e.state?h:(n=e.state,e.total_in=e.total_out=n.total=0,e.msg=``,n.wrap&&(e.adler=n.wrap&1),n.mode=b,n.last=0,n.havedict=0,n.dmax=32768,n.head=null,n.hold=0,n.bits=0,n.lencode=n.lendyn=new t.Buf32(ve),n.distcode=n.distdyn=new t.Buf32(P),n.sane=1,n.back=-1,f)}function Se(e){var t;return!e||!e.state?h:(t=e.state,t.wsize=0,t.whave=0,t.wnext=0,F(e))}function I(e,t){var n,r;return!e||!e.state||(r=e.state,t<0?(n=0,t=-t):(n=(t>>4)+1,t<48&&(t&=15)),t&&(t<8||t>15))?h:(r.window!==null&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,Se(e))}function Ce(e,t){var n,r;return e?(r=new xe,e.state=r,r.window=null,n=I(e,t),n!==f&&(e.state=null),n):h}function L(e){return Ce(e,ye)}var R=!0,we,Te;function Ee(e){if(R){var n;for(we=new t.Buf32(512),Te=new t.Buf32(32),n=0;n<144;)e.lens[n++]=8;for(;n<256;)e.lens[n++]=9;for(;n<280;)e.lens[n++]=7;for(;n<288;)e.lens[n++]=8;for(a(s,e.lens,0,288,we,0,e.work,{bits:9}),n=0;n<32;)e.lens[n++]=5;a(c,e.lens,0,32,Te,0,e.work,{bits:5}),R=!1}e.lencode=we,e.lenbits=9,e.distcode=Te,e.distbits=5}function De(e,n,r,i){var a,o=e.state;return o.window===null&&(o.wsize=1<=o.wsize?(t.arraySet(o.window,n,r-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):(a=o.wsize-o.wnext,a>i&&(a=i),t.arraySet(o.window,n,r-i,a,o.wnext),i-=a,i?(t.arraySet(o.window,n,r-i,i,0),o.wnext=i,o.whave=o.wsize):(o.wnext+=a,o.wnext===o.wsize&&(o.wnext=0),o.whave>>8&255,P.check=r(P.check,ze,2,0),L=0,R=0,P.mode=x;break}if(P.flags=0,P.head&&(P.head.done=!1),!(P.wrap&1)||(((L&255)<<8)+(L>>8))%31){e.msg=`incorrect header check`,P.mode=he;break}if((L&15)!==y){e.msg=`unknown compression method`,P.mode=he;break}if(L>>>=4,R-=4,Le=(L&15)+8,P.wbits===0)P.wbits=Le;else if(Le>P.wbits){e.msg=`invalid window size`,P.mode=he;break}P.dmax=1<>8&1),P.flags&512&&(ze[0]=L&255,ze[1]=L>>>8&255,P.check=r(P.check,ze,2,0)),L=0,R=0,P.mode=S;case S:for(;R<32;){if(I===0)break inf_leave;I--,L+=ye[F++]<>>8&255,ze[2]=L>>>16&255,ze[3]=L>>>24&255,P.check=r(P.check,ze,4,0)),L=0,R=0,P.mode=C;case C:for(;R<16;){if(I===0)break inf_leave;I--,L+=ye[F++]<>8),P.flags&512&&(ze[0]=L&255,ze[1]=L>>>8&255,P.check=r(P.check,ze,2,0)),L=0,R=0,P.mode=w;case w:if(P.flags&1024){for(;R<16;){if(I===0)break inf_leave;I--,L+=ye[F++]<>>8&255,P.check=r(P.check,ze,2,0)),L=0,R=0}else P.head&&(P.head.extra=null);P.mode=T;case T:if(P.flags&1024&&(z=P.length,z>I&&(z=I),z&&(P.head&&(Le=P.head.extra_len-P.length,P.head.extra||(P.head.extra=Array(P.head.extra_len)),t.arraySet(P.head.extra,ye,F,z,Le)),P.flags&512&&(P.check=r(P.check,ye,z,F)),I-=z,F+=z,P.length-=z),P.length))break inf_leave;P.length=0,P.mode=E;case E:if(P.flags&2048){if(I===0)break inf_leave;z=0;do Le=ye[F+ z++],P.head&&Le&&P.length<65536&&(P.head.name+=String.fromCharCode(Le));while(Le&&z>9&1,P.head.done=!0),e.adler=P.check=0,P.mode=A;break;case k:for(;R<32;){if(I===0)break inf_leave;I--,L+=ye[F++]<>>=R&7,R-=R&7,P.mode=fe;break}for(;R<3;){if(I===0)break inf_leave;I--,L+=ye[F++]<>>=1,--R,L&3){case 0:P.mode=te;break;case 1:if(Ee(P),P.mode=se,ve===d){L>>>=2,R-=2;break inf_leave}break;case 2:P.mode=ie;break;case 3:e.msg=`invalid block type`,P.mode=he}L>>>=2,R-=2;break;case te:for(L>>>=R&7,R-=R&7;R<32;){if(I===0)break inf_leave;I--,L+=ye[F++]<>>16^65535)){e.msg=`invalid stored block lengths`,P.mode=he;break}if(P.length=L&65535,L=0,R=0,P.mode=ne,ve===d)break inf_leave;case ne:P.mode=re;case re:if(z=P.length,z){if(z>I&&(z=I),z>Ce&&(z=Ce),z===0)break inf_leave;t.arraySet(xe,ye,F,z,Se),I-=z,F+=z,Ce-=z,Se+=z,P.length-=z;break}P.mode=A;break;case ie:for(;R<14;){if(I===0)break inf_leave;I--,L+=ye[F++]<>>=5,R-=5,P.ndist=(L&31)+1,L>>>=5,R-=5,P.ncode=(L&15)+4,L>>>=4,R-=4,P.nlen>286||P.ndist>30){e.msg=`too many length or distance symbols`,P.mode=he;break}P.have=0,P.mode=ae;case ae:for(;P.have>>=3,R-=3}for(;P.have<19;)P.lens[He[P.have++]]=0;if(P.lencode=P.lendyn,P.lenbits=7,Be={bits:P.lenbits},Re=a(o,P.lens,0,19,P.lencode,0,P.work,Be),P.lenbits=Be.bits,Re){e.msg=`invalid code lengths set`,P.mode=he;break}P.have=0,P.mode=oe;case oe:for(;P.have>>24,Me=Ae>>>16&255,Ne=Ae&65535,!(je<=R);){if(I===0)break inf_leave;I--,L+=ye[F++]<>>=je,R-=je,P.lens[P.have++]=Ne;else{if(Ne===16){for(Ve=je+2;R>>=je,R-=je,P.have===0){e.msg=`invalid bit length repeat`,P.mode=he;break}Le=P.lens[P.have-1],z=3+(L&3),L>>>=2,R-=2}else if(Ne===17){for(Ve=je+3;R>>=je,R-=je,Le=0,z=3+(L&7),L>>>=3,R-=3}else{for(Ve=je+7;R>>=je,R-=je,Le=0,z=11+(L&127),L>>>=7,R-=7}if(P.have+z>P.nlen+P.ndist){e.msg=`invalid bit length repeat`,P.mode=he;break}for(;z--;)P.lens[P.have++]=Le}}if(P.mode===he)break;if(P.lens[256]===0){e.msg=`invalid code -- missing end-of-block`,P.mode=he;break}if(P.lenbits=9,Be={bits:P.lenbits},Re=a(s,P.lens,0,P.nlen,P.lencode,0,P.work,Be),P.lenbits=Be.bits,Re){e.msg=`invalid literal/lengths set`,P.mode=he;break}if(P.distbits=6,P.distcode=P.distdyn,Be={bits:P.distbits},Re=a(c,P.lens,P.nlen,P.ndist,P.distcode,0,P.work,Be),P.distbits=Be.bits,Re){e.msg=`invalid distances set`,P.mode=he;break}if(P.mode=se,ve===d)break inf_leave;case se:P.mode=ce;case ce:if(I>=6&&Ce>=258){e.next_out=Se,e.avail_out=Ce,e.next_in=F,e.avail_in=I,P.hold=L,P.bits=R,i(e,Te),Se=e.next_out,xe=e.output,Ce=e.avail_out,F=e.next_in,ye=e.input,I=e.avail_in,L=P.hold,R=P.bits,P.mode===A&&(P.back=-1);break}for(P.back=0;Ae=P.lencode[L&(1<>>24,Me=Ae>>>16&255,Ne=Ae&65535,!(je<=R);){if(I===0)break inf_leave;I--,L+=ye[F++]<>Pe)],je=Ae>>>24,Me=Ae>>>16&255,Ne=Ae&65535,!(Pe+je<=R);){if(I===0)break inf_leave;I--,L+=ye[F++]<>>=Pe,R-=Pe,P.back+=Pe}if(L>>>=je,R-=je,P.back+=je,P.length=Ne,Me===0){P.mode=de;break}if(Me&32){P.back=-1,P.mode=A;break}if(Me&64){e.msg=`invalid literal/length code`,P.mode=he;break}P.extra=Me&15,P.mode=le;case le:if(P.extra){for(Ve=P.extra;R>>=P.extra,R-=P.extra,P.back+=P.extra}P.was=P.length,P.mode=ue;case ue:for(;Ae=P.distcode[L&(1<>>24,Me=Ae>>>16&255,Ne=Ae&65535,!(je<=R);){if(I===0)break inf_leave;I--,L+=ye[F++]<>Pe)],je=Ae>>>24,Me=Ae>>>16&255,Ne=Ae&65535,!(Pe+je<=R);){if(I===0)break inf_leave;I--,L+=ye[F++]<>>=Pe,R-=Pe,P.back+=Pe}if(L>>>=je,R-=je,P.back+=je,Me&64){e.msg=`invalid distance code`,P.mode=he;break}P.offset=Ne,P.extra=Me&15,P.mode=M;case M:if(P.extra){for(Ve=P.extra;R>>=P.extra,R-=P.extra,P.back+=P.extra}if(P.offset>P.dmax){e.msg=`invalid distance too far back`,P.mode=he;break}P.mode=N;case N:if(Ce===0)break inf_leave;if(z=Te-Ce,P.offset>z){if(z=P.offset-z,z>P.whave&&P.sane){e.msg=`invalid distance too far back`,P.mode=he;break}z>P.wnext?(z-=P.wnext,Oe=P.wsize-z):Oe=P.wnext-z,z>P.length&&(z=P.length),ke=P.window}else ke=xe,Oe=Se-P.offset,z=P.length;z>Ce&&(z=Ce),Ce-=z,P.length-=z;do xe[Se++]=ke[Oe++];while(--z);P.length===0&&(P.mode=ce);break;case de:if(Ce===0)break inf_leave;xe[Se++]=P.length,Ce--,P.mode=ce;break;case fe:if(P.wrap){for(;R<32;){if(I===0)break inf_leave;I--,L|=ye[F++]<{t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}})),gc=o(((e,t)=>{function n(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name=``,this.comment=``,this.hcrc=0,this.done=!1}t.exports=n})),_c=o((e=>{var t=mc(),n=rc(),r=lc(),i=hc(),a=sc(),o=uc(),s=gc(),c=Object.prototype.toString;function l(e){if(!(this instanceof l))return new l(e);this.options=n.assign({chunkSize:16384,windowBits:0,to:``},e||{});var u=this.options;u.raw&&u.windowBits>=0&&u.windowBits<16&&(u.windowBits=-u.windowBits,u.windowBits===0&&(u.windowBits=-15)),u.windowBits>=0&&u.windowBits<16&&!(e&&e.windowBits)&&(u.windowBits+=32),u.windowBits>15&&u.windowBits<48&&(u.windowBits&15||(u.windowBits|=15)),this.err=0,this.msg=``,this.ended=!1,this.chunks=[],this.strm=new o,this.strm.avail_out=0;var d=t.inflateInit2(this.strm,u.windowBits);if(d!==i.Z_OK||(this.header=new s,t.inflateGetHeader(this.strm,this.header),u.dictionary&&(typeof u.dictionary==`string`?u.dictionary=r.string2buf(u.dictionary):c.call(u.dictionary)===`[object ArrayBuffer]`&&(u.dictionary=new Uint8Array(u.dictionary)),u.raw&&(d=t.inflateSetDictionary(this.strm,u.dictionary),d!==i.Z_OK))))throw Error(a[d])}l.prototype.push=function(e,a){var o=this.strm,s=this.options.chunkSize,l=this.options.dictionary,u,d,f,p,m,h=!1;if(this.ended)return!1;d=a===~~a?a:a===!0?i.Z_FINISH:i.Z_NO_FLUSH,typeof e==`string`?o.input=r.binstring2buf(e):c.call(e)===`[object ArrayBuffer]`?o.input=new Uint8Array(e):o.input=e,o.next_in=0,o.avail_in=o.input.length;do{if(o.avail_out===0&&(o.output=new n.Buf8(s),o.next_out=0,o.avail_out=s),u=t.inflate(o,i.Z_NO_FLUSH),u===i.Z_NEED_DICT&&l&&(u=t.inflateSetDictionary(this.strm,l)),u===i.Z_BUF_ERROR&&h===!0&&(u=i.Z_OK,h=!1),u!==i.Z_STREAM_END&&u!==i.Z_OK)return this.onEnd(u),this.ended=!0,!1;o.next_out&&(o.avail_out===0||u===i.Z_STREAM_END||o.avail_in===0&&(d===i.Z_FINISH||d===i.Z_SYNC_FLUSH))&&(this.options.to===`string`?(f=r.utf8border(o.output,o.next_out),p=o.next_out-f,m=r.buf2string(o.output,f),o.next_out=p,o.avail_out=s-p,p&&n.arraySet(o.output,o.output,f,p,0),this.onData(m)):this.onData(n.shrinkBuf(o.output,o.next_out))),o.avail_in===0&&o.avail_out===0&&(h=!0)}while((o.avail_in>0||o.avail_out===0)&&u!==i.Z_STREAM_END);return u===i.Z_STREAM_END&&(d=i.Z_FINISH),d===i.Z_FINISH?(u=t.inflateEnd(this.strm),this.onEnd(u),this.ended=!0,u===i.Z_OK):d===i.Z_SYNC_FLUSH?(this.onEnd(i.Z_OK),o.avail_out=0,!0):!0},l.prototype.onData=function(e){this.chunks.push(e)},l.prototype.onEnd=function(e){e===i.Z_OK&&(this.options.to===`string`?this.result=this.chunks.join(``):this.result=n.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function u(e,t){var n=new l(t);if(n.push(e,!0),n.err)throw n.msg||a[n.err];return n.result}function d(e,t){return t=t||{},t.raw=!0,u(e,t)}e.Inflate=l,e.inflate=u,e.inflateRaw=d,e.ungzip=u})),vc=c(o(((e,t)=>{var n=rc().assign,r=dc(),i=_c(),a=hc(),o={};n(o,r,i,a),t.exports=o}))()),yc=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,bc=new Uint8Array(256),xc=0;xc>4,l[i++]=(o&15)<<4|s>>2,l[i++]=(s&3)<<6|c&63;return l},Cc=function(e){for(var t=``,n=0;nr)throw Error(Rc(t)+` must be at least `+n+` and at most `+r+`, but was actually `+e)},Xc=function(e,t,n,r){W(e,t,[`number`,`undefined`]),typeof e==`number`&&Yc(e,t,n,r)},Zc=function(e,t,n){if(W(e,t,[`number`]),e%n!==0)throw Error(Rc(t)+` must be a multiple of `+n+`, but was actually `+e)},Qc=function(e,t){if(!Number.isInteger(e))throw Error(Rc(t)+` must be an integer, but was actually `+e)},$c=function(e,t){if(![1,0].includes(Math.sign(e)))throw Error(Rc(t)+` must be a positive number or 0, but was actually `+e)},el=new Uint16Array(256),tl=0;tl<256;tl++)el[tl]=tl;el[22]=rs(``),el[24]=rs(`˘`),el[25]=rs(`ˇ`),el[26]=rs(`ˆ`),el[27]=rs(`˙`),el[28]=rs(`˝`),el[29]=rs(`˛`),el[30]=rs(`˚`),el[31]=rs(`˜`),el[127]=rs(`�`),el[128]=rs(`•`),el[129]=rs(`†`),el[130]=rs(`‡`),el[131]=rs(`…`),el[132]=rs(`—`),el[133]=rs(`–`),el[134]=rs(`ƒ`),el[135]=rs(`⁄`),el[136]=rs(`‹`),el[137]=rs(`›`),el[138]=rs(`−`),el[139]=rs(`‰`),el[140]=rs(`„`),el[141]=rs(`“`),el[142]=rs(`”`),el[143]=rs(`‘`),el[144]=rs(`’`),el[145]=rs(`‚`),el[146]=rs(`™`),el[147]=rs(`fi`),el[148]=rs(`fl`),el[149]=rs(`Ł`),el[150]=rs(`Œ`),el[151]=rs(`Š`),el[152]=rs(`Ÿ`),el[153]=rs(`Ž`),el[154]=rs(`ı`),el[155]=rs(`ł`),el[156]=rs(`œ`),el[157]=rs(`š`),el[158]=rs(`ž`),el[159]=rs(`�`),el[160]=rs(`€`),el[173]=rs(`�`);var nl=function(e){for(var t=Array(e.length),n=0,r=e.length;n=K.ExclamationPoint&&e<=K.Tilde&&!zl[e]},Wl={},Gl=new Map,J=function(e){U(t,e);function t(t,n){var r=this;if(t!==Wl)throw new al(`PDFName`);r=e.call(this)||this;for(var i=`/`,a=0,o=n.length;a=K.Zero&&s<=K.Nine||s>=K.a&&s<=K.f||s>=K.A&&s<=K.F?(t+=o,(t.length===2||!(c>=`0`&&c<=`9`||c>=`a`&&c<=`f`||c>=`A`&&c<=`F`))&&(r(parseInt(t,16)),t=``)):r(s):s===K.Hash?n=!0:r(s)}return new Uint8Array(e)},t.prototype.decodeText=function(){var e=this.asBytes();return String.fromCharCode.apply(String,Array.from(e))},t.prototype.asString=function(){return this.encodedName},t.prototype.value=function(){return this.encodedName},t.prototype.clone=function(){return this},t.prototype.toString=function(){return this.encodedName},t.prototype.sizeInBytes=function(){return this.encodedName.length},t.prototype.copyBytesInto=function(e,t){return t+=us(this.encodedName,e,t),this.encodedName.length},t.of=function(e){var n=Hl(e),r=Gl.get(n);return r||(r=new t(Wl,n),Gl.set(n,r)),r},t.Length=t.of(`Length`),t.FlateDecode=t.of(`FlateDecode`),t.Resources=t.of(`Resources`),t.Font=t.of(`Font`),t.XObject=t.of(`XObject`),t.ExtGState=t.of(`ExtGState`),t.Contents=t.of(`Contents`),t.Type=t.of(`Type`),t.Parent=t.of(`Parent`),t.MediaBox=t.of(`MediaBox`),t.Page=t.of(`Page`),t.Annots=t.of(`Annots`),t.TrimBox=t.of(`TrimBox`),t.ArtBox=t.of(`ArtBox`),t.BleedBox=t.of(`BleedBox`),t.CropBox=t.of(`CropBox`),t.Rotate=t.of(`Rotate`),t.Title=t.of(`Title`),t.Author=t.of(`Author`),t.Subject=t.of(`Subject`),t.Creator=t.of(`Creator`),t.Keywords=t.of(`Keywords`),t.Producer=t.of(`Producer`),t.CreationDate=t.of(`CreationDate`),t.ModDate=t.of(`ModDate`),t}(Nl),Kl=new(function(e){U(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.asNull=function(){return null},t.prototype.clone=function(){return this},t.prototype.toString=function(){return`null`},t.prototype.sizeInBytes=function(){return 4},t.prototype.copyBytesInto=function(e,t){return e[t++]=K.n,e[t++]=K.u,e[t++]=K.l,e[t++]=K.l,4},t}(Nl)),ql=function(e){U(t,e);function t(t,n){var r=e.call(this)||this;return r.dict=t,r.context=n,r}return t.prototype.keys=function(){return Array.from(this.dict.keys())},t.prototype.values=function(){return Array.from(this.dict.values())},t.prototype.entries=function(){return Array.from(this.dict.entries())},t.prototype.set=function(e,t){this.dict.set(e,t)},t.prototype.get=function(e,t){t===void 0&&(t=!1);var n=this.dict.get(e);if(!(n===Kl&&!t))return n},t.prototype.has=function(e){var t=this.dict.get(e);return t!==void 0&&t!==Kl},t.prototype.lookupMaybe=function(e){for(var t,n=[],r=1;r>`,e},t.prototype.sizeInBytes=function(){for(var e=5,t=this.entries(),n=0,r=t.length;nthis.largestObjectNumber&&(this.largestObjectNumber=e.objectNumber)},e.prototype.nextRef=function(){return this.largestObjectNumber+=1,Ql.of(this.largestObjectNumber)},e.prototype.register=function(e){var t=this.nextRef();return this.assign(t,e),t},e.prototype.delete=function(e){return this.indirectObjects.delete(e)},e.prototype.lookupMaybe=function(e){for(var t=[],n=1;n1?(this.subsections.push([e]),this.chunkIdx+=1,this.chunkLength=1):(t.push(e),this.chunkLength+=1)},e.create=function(){return new e({ref:Ql.of(0,65535),offset:0,deleted:!0})},e.createEmpty=function(){return new e},e}(),uu=function(){function e(e){this.lastXRefOffset=String(e)}return e.prototype.toString=function(){return`startxref `+this.lastXRefOffset+` %%EOF`},e.prototype.sizeInBytes=function(){return 16+this.lastXRefOffset.length},e.prototype.copyBytesInto=function(e,t){var n=t;return e[t++]=K.s,e[t++]=K.t,e[t++]=K.a,e[t++]=K.r,e[t++]=K.t,e[t++]=K.x,e[t++]=K.r,e[t++]=K.e,e[t++]=K.f,e[t++]=K.Newline,t+=us(this.lastXRefOffset,e,t),e[t++]=K.Newline,e[t++]=K.Percent,e[t++]=K.Percent,e[t++]=K.E,e[t++]=K.O,e[t++]=K.F,t-n},e.forLastCrossRefSectionOffset=function(t){return new e(t)},e}(),du=function(){function e(e){this.dict=e}return e.prototype.toString=function(){return`trailer `+this.dict.toString()},e.prototype.sizeInBytes=function(){return 8+this.dict.sizeInBytes()},e.prototype.copyBytesInto=function(e,t){var n=t;return e[t++]=K.t,e[t++]=K.r,e[t++]=K.a,e[t++]=K.i,e[t++]=K.l,e[t++]=K.e,e[t++]=K.r,e[t++]=K.Newline,t+=this.dict.copyBytesInto(e,t),t-n},e.of=function(t){return new e(t)},e}(),fu=function(e){U(t,e);function t(t,n,r){r===void 0&&(r=!0);var i=e.call(this,t.obj({}),r)||this;return i.objects=n,i.offsets=i.computeObjectOffsets(),i.offsetsString=i.computeOffsetsString(),i.dict.set(J.of(`Type`),J.of(`ObjStm`)),i.dict.set(J.of(`N`),q.of(i.objects.length)),i.dict.set(J.of(`First`),q.of(i.offsetsString.length)),i}return t.prototype.getObjectsCount=function(){return this.objects.length},t.prototype.clone=function(e){return t.withContextAndObjects(e||this.dict.context,this.objects.slice(),this.encode)},t.prototype.getContentsString=function(){for(var e=this.offsetsString,t=0,n=this.objects.length;t1&&(e.push(t),e.push(a.ref.objectNumber),t=0),t+=1}return e.push(t),e},i.computeEntryTuples=function(){for(var e=Array(i.entries.length),t=0,n=i.entries.length;tt[0]&&(t[0]=l),u>t[1]&&(t[1]=u),d>t[2]&&(t[2]=d)}return t},i.entries=n||[],i.entryTuplesCache=rl.populatedBy(i.computeEntryTuples),i.maxByteWidthsCache=rl.populatedBy(i.computeMaxEntryByteWidths),i.indexCache=rl.populatedBy(i.computeIndex),t.set(J.of(`Type`),J.of(`XRef`)),i}return t.prototype.addDeletedEntry=function(e,t){var n=hu.Deleted;this.entries.push({type:n,ref:e,nextFreeObjectNumber:t}),this.entryTuplesCache.invalidate(),this.maxByteWidthsCache.invalidate(),this.indexCache.invalidate(),this.contentsCache.invalidate()},t.prototype.addUncompressedEntry=function(e,t){var n=hu.Uncompressed;this.entries.push({type:n,ref:e,offset:t}),this.entryTuplesCache.invalidate(),this.maxByteWidthsCache.invalidate(),this.indexCache.invalidate(),this.contentsCache.invalidate()},t.prototype.addCompressedEntry=function(e,t,n){var r=hu.Compressed;this.entries.push({type:r,ref:e,objectStreamRef:t,index:n}),this.entryTuplesCache.invalidate(),this.maxByteWidthsCache.invalidate(),this.indexCache.invalidate(),this.contentsCache.invalidate()},t.prototype.clone=function(e){var n=this,r=n.dict,i=n.entries,a=n.encode;return t.of(r.clone(e),i.slice(),a)},t.prototype.getContentsString=function(){for(var e=this.entryTuplesCache.access(),t=this.maxByteWidthsCache.access(),n=``,r=0,i=e.length;r=0;f--)n+=(l[f]||0).toString(2);for(var f=t[1]-1;f>=0;f--)n+=(u[f]||0).toString(2);for(var f=t[2]-1;f>=0;f--)n+=(d[f]||0).toString(2)}return n},t.prototype.getUnencodedContents=function(){for(var e=this.entryTuplesCache.access(),t=this.maxByteWidthsCache.access(),n=new Uint8Array(this.getUnencodedContentsSize()),r=0,i=0,a=e.length;i=0;p--)n[r++]=u[p]||0;for(var p=t[1]-1;p>=0;p--)n[r++]=d[p]||0;for(var p=t[2]-1;p>=0;p--)n[r++]=f[p]||0}return n},t.prototype.getUnencodedContentsSize=function(){return Ms(this.maxByteWidthsCache.access())*this.entries.length},t.prototype.updateDict=function(){e.prototype.updateDict.call(this);var t=this.maxByteWidthsCache.access(),n=this.indexCache.access(),r=this.dict.context;this.dict.set(J.of(`W`),r.obj(t)),this.dict.set(J.of(`Index`),r.obj(n))},t.create=function(e,n){n===void 0&&(n=!0);var r=new t(e,[],n);return r.addDeletedEntry(Ql.of(0,65535),0),r},t.of=function(e,n,r){return r===void 0&&(r=!0),new t(e,n,r)},t}(nu),_u=function(e){U(t,e);function t(t,n,r,i){var a=e.call(this,t,n)||this;return a.encodeStreams=r,a.objectsPerStream=i,a}return t.prototype.computeBufferSize=function(){return qo(this,void 0,void 0,function(){var e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,c,l,m,d,g,_,v,y;return Jo(this,function(b){switch(b.label){case 0:e=this.context.largestObjectNumber+1,t=Ml.forVersion(1,7),n=t.sizeInBytes()+2,r=gu.create(this.createTrailerDict(),this.encodeStreams),i=[],a=[],o=[],s=this.context.enumerateIndirectObjects(),c=0,l=s.length,b.label=1;case 1:return c`},t.prototype.sizeInBytes=function(){return this.value.length+2},t.prototype.copyBytesInto=function(e,t){return e[t++]=K.LessThan,t+=us(this.value,e,t),e[t++]=K.GreaterThan,this.value.length+2},t.of=function(e){return new t(e)},t.fromText=function(e){for(var n=Rs(e),r=``,i=0,a=n.length;i> def /CMapName /Adobe-Identity-UCS def /CMapType 2 def 1 begincodespacerange <0000> endcodespacerange `+e.length+` beginbfchar `+e.map(function(e){var t=e[0],n=e[1];return t+` `+n}).join(` `)+` endbfchar endcmap CMapName currentdict /CMap defineresource pop end end`},xu=function(){for(var e=[],t=0;t`},Su=function(e){return as(e,4)},Cu=function(e){if(zs(e))return Su(e);if(Bs(e)){var t=Vs(e),n=Hs(e);return``+Su(t)+Su(n)}var r=`0x`+os(e)+` is not a valid UTF-8 or UTF-16 codepoint.`;throw Error(r)},wu=function(e){var t=0,n=function(e){t|=1<=K.Zero&&s<=K.Seven?(t+=o,(t.length===3||!(c>=`0`&&c<=`7`))&&(r(parseInt(t,8)),t=``)):r(s):s===K.BackSlash?n=!0:r(s)}return new Uint8Array(e)},t.prototype.decodeText=function(){var e=this.asBytes();return Qs(e)?Gs(e):nl(e)},t.prototype.decodeDate=function(){var e=this.decodeText(),t=Ss(e);if(!t)throw new pl(e);return t},t.prototype.asString=function(){return this.value},t.prototype.clone=function(){return t.of(this.value)},t.prototype.toString=function(){return`(`+this.value+`)`},t.prototype.sizeInBytes=function(){return this.value.length+2},t.prototype.copyBytesInto=function(e,t){return e[t++]=K.LeftParen,t+=us(this.value,e,t),e[t++]=K.RightParen,this.value.length+2},t.of=function(e){return new t(e)},t.fromDate=function(e){var n=ls(String(e.getUTCFullYear()),4,`0`),r=ls(String(e.getUTCMonth()+1),2,`0`),i=ls(String(e.getUTCDate()),2,`0`),a=ls(String(e.getUTCHours()),2,`0`),o=ls(String(e.getUTCMinutes()),2,`0`),s=ls(String(e.getUTCSeconds()),2,`0`);return new t(`D:`+n+r+i+a+o+s+`Z`)},t}(Nl),Du=function(){function e(e,t,n,r){var i=this;this.allGlyphsInFontSortedById=function(){for(var e=Array(i.font.characterSet.length),t=0,n=e.length;t>3)]>>7-((p&7)<<0)&1,D=3*E;s[y]=b[D],s[y+1]=b[D+1],s[y+2]=b[D+2],s[y+3]=E>2)]>>6-((p&3)<<1)&3,D=3*E;s[y]=b[D],s[y+1]=b[D+1],s[y+2]=b[D+2],s[y+3]=E>1)]>>4-((p&1)<<2)&15,D=3*E;s[y]=b[D],s[y+1]=b[D+1],s[y+2]=b[D+2],s[y+3]=E>>3)]>>>7-(j&7)&1),te=k==g*255?0:255;c[A+j]=te<<24|k<<16|k<<8|k}else if(u==2)for(var j=0;j>>2)]>>>6-((j&3)<<1)&3),te=k==g*85?0:255;c[A+j]=te<<24|k<<16|k<<8|k}else if(u==4)for(var j=0;j>>1)]>>>4-((j&1)<<2)&15),te=k==g*17?0:255;c[A+j]=te<<24|k<<16|k<<8|k}else if(u==8)for(var j=0;j>>2<<3));i==0;){if(i=g(t,f,1),a=g(t,f+1,2),f+=3,a==0){f&7&&(f+=8-(f&7));var w=(f>>>3)+4,T=t[w-4]|t[w-3]<<8;C&&(n=e.H.W(n,d+T)),n.set(new r(t.buffer,t.byteOffset+w,T),d),f=w+T<<3,d+=T;continue}if(C&&(n=e.H.W(n,d+(1<<17))),a==1&&(p=S.J,m=S.h,l=511,u=31),a==2){o=_(t,f,5)+257,s=_(t,f+5,5)+1,c=_(t,f+10,4)+4,f+=14;for(var E=1,D=0;D<38;D+=2)S.Q[D]=0,S.Q[D+1]=0;for(var D=0;DE&&(E=O)}f+=3*c,y(S.Q,E),b(S.Q,E,S.u),p=S.w,m=S.d,f=v(S.u,(1<>>4;if(!(j>>>8))n[d++]=j;else if(j==256)break;else{var te=d+j-254;if(j>264){var ne=S.q[j-257];te=d+(ne>>>3)+_(t,f,ne&7),f+=ne&7}var re=m[x(t,f)&u];f+=re&15;var ie=re>>>4,ae=S.c[ie],oe=(ae>>>4)+g(t,f,ae&15);for(f+=ae&15;d>>4;if(d<=15)o[l]=d,l++;else{var f=0,p=0;d==16?(p=3+s(i,a,2),a+=2,f=o[l-1]):d==17?(p=3+s(i,a,3),a+=3):d==18&&(p=11+s(i,a,7),a+=7);for(var m=l+p;l>>1;ai&&(i=s),a++}for(;a>1,c=t[o+1],l=s<<4|c,u=n-c,d=t[o]<>>15-n;r[p]=l,d++}},e.H.l=function(t,n){for(var r=e.H.m.r,i=15-n,a=0;a>>i},e.H.M=function(e,t,n){n<<=t&7;var r=t>>>3;e[r]|=n,e[r+1]|=n>>>8},e.H.I=function(e,t,n){n<<=t&7;var r=t>>>3;e[r]|=n,e[r+1]|=n>>>8,e[r+2]|=n>>>16},e.H.e=function(e,t,n){return(e[t>>>3]|e[(t>>>3)+1]<<8)>>>(t&7)&(1<>>3]|e[(t>>>3)+1]<<8|e[(t>>>3)+2]<<16)>>>(t&7)&(1<>>3]|e[(t>>>3)+1]<<8|e[(t>>>3)+2]<<16)>>>(t&7)},e.H.i=function(e,t){return(e[t>>>3]|e[(t>>>3)+1]<<8|e[(t>>>3)+2]<<16|e[(t>>>3)+3]<<24)>>>(t&7)},e.H.m=function(){var e=Uint16Array,t=Uint32Array;return{K:new e(16),j:new e(16),X:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],S:[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,999,999,999],T:[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0],q:new e(32),p:[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,65535,65535],z:[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0],c:new t(32),J:new e(512),_:[],h:new e(32),$:[],w:new e(32768),C:[],v:[],d:new e(32768),D:[],u:new e(512),Q:[],r:new e(32768),s:new t(286),Y:new t(30),a:new t(19),t:new t(15e3),k:new e(65536),g:new e(32768)}}(),(function(){for(var t=e.H.m,n=32768,r=0;r>>1|(i&1431655765)<<1,i=(i&3435973836)>>>2|(i&858993459)<<2,i=(i&4042322160)>>>4|(i&252645135)<<4,i=(i&4278255360)>>>8|(i&16711935)<<8,t.r[r]=(i>>>16|i<<16)>>>17}function a(e,t,n){for(;t--!=0;)e.push(0,n)}for(var r=0;r<32;r++)t.q[r]=t.S[r]<<3|t.T[r],t.c[r]=t.p[r]<<4|t.z[r];a(t._,144,8),a(t._,112,9),a(t._,24,7),a(t._,8,8),e.H.n(t._,9),e.H.A(t._,9,t.J),e.H.l(t._,9),a(t.$,32,5),e.H.n(t.$,5),e.H.A(t.$,5,t.h),e.H.l(t.$,5),a(t.Q,19,0),a(t.C,286,0),a(t.D,30,0),a(t.v,320,0)})(),e.H.N}(),X.decode._readInterlace=function(e,t){for(var n=t.width,r=t.height,i=X.decode._getBPP(t),a=i>>3,o=Math.ceil(n*i/8),s=new Uint8Array(r*o),c=0,l=[0,0,4,0,2,0,1],u=[0,4,0,2,0,1,0],d=[8,8,8,4,4,2,2],f=[8,8,4,4,2,2,1],p=0;p<7;){for(var m=d[p],h=f[p],g=0,_=0,v=l[p];v>3];T=T>>7-(w&7)&1,s[S*o+(C>>3)]|=T<<7-((C&7)<<0)}if(i==2){var T=e[w>>3];T=T>>6-(w&7)&3,s[S*o+(C>>2)]|=T<<6-((C&3)<<1)}if(i==4){var T=e[w>>3];T=T>>4-(w&7)&15,s[S*o+(C>>1)]|=T<<4-((C&1)<<2)}if(i>=8)for(var E=S*o+C*a,D=0;D>3)+D];w+=i,C+=h}x++,S+=m}g*_!=0&&(c+=_*(1+b)),p+=1}return s},X.decode._getBPP=function(e){return[1,null,3,1,2,null,4][e.ctype]*e.depth},X.decode._filterZero=function(e,t,n,r,i){var a=X.decode._getBPP(t),o=Math.ceil(r*a/8),s=X.decode._paeth;a=Math.ceil(a/8);var c=0,l=1,u=e[n],d=0;if(u>1&&(e[n]=[0,0,1][u-2]),u==3)for(d=a;d>>1)&255;for(var f=0;f>>1);for(;d>>1)}else{for(;d>8&255,e[t+1]=n&255},readUint:function(e,t){return e[t]*(256*256*256)+(e[t+1]<<16|e[t+2]<<8|e[t+3])},writeUint:function(e,t,n){e[t]=n>>24&255,e[t+1]=n>>16&255,e[t+2]=n>>8&255,e[t+3]=n&255},readASCII:function(e,t,n){for(var r=``,i=0;i=0&&s>=0?(d=p*t+m<<2,f=(s+p)*i+o+m<<2):(d=(-s+p)*t-o+m<<2,f=p*i+m<<2),c==0)r[f]=e[d],r[f+1]=e[d+1],r[f+2]=e[d+2],r[f+3]=e[d+3];else if(c==1){var h=e[d+3]*(1/255),g=e[d]*h,_=e[d+1]*h,v=e[d+2]*h,y=r[f+3]*(1/255),b=r[f]*y,x=r[f+1]*y,S=r[f+2]*y,C=1-h,w=h+y*C,T=w==0?0:1/w;r[f+3]=255*w,r[f+0]=(g+b*C)*T,r[f+1]=(_+x*C)*T,r[f+2]=(v+S*C)*T}else if(c==2){var h=e[d+3],g=e[d],_=e[d+1],v=e[d+2],y=r[f+3],b=r[f],x=r[f+1],S=r[f+2];h==y&&g==b&&_==x&&v==S?(r[f]=0,r[f+1]=0,r[f+2]=0,r[f+3]=0):(r[f]=g,r[f+1]=_,r[f+2]=v,r[f+3]=h)}else if(c==3){var h=e[d+3],g=e[d],_=e[d+1],v=e[d+2],y=r[f+3],b=r[f],x=r[f+1],S=r[f+2];if(h==y&&g==b&&_==x&&v==S)continue;if(h<220&&y>20)return!1}return!0},X.encode=function(e,t,n,r,i,a,o){r??(r=0),o??(o=!1);var s=X.encode.compress(e,t,n,r,[!1,!1,!1,0,o]);return X.encode.compressPNG(s,-1),X.encode._main(s,t,n,i,a)},X.encodeLL=function(e,t,n,r,i,a,o,s){for(var c={ctype:0+(r==1?0:2)+(i==0?0:4),depth:a,frames:[]},l=(r+i)*a,u=l*t,d=0;d1,d=!1,f=33+(u?20:0);if(i.sRGB!=null&&(f+=13),i.pHYs!=null&&(f+=21),e.ctype==3){for(var p=e.plte.length,m=0;m>>24!=255&&(d=!0);f+=8+p*3+4+(d?8+p*1+4:0)}for(var h=0;h>>8&255,C=b>>>16&255;_[l+y+0]=x,_[l+y+1]=S,_[l+y+2]=C}if(l+=p*3,o(_,l,a(_,l-p*3-4,p*3+4)),l+=4,d){o(_,l,p),l+=4,c(_,l,`tRNS`),l+=4;for(var m=0;m>>24&255;l+=p,o(_,l,a(_,l-p-4,p+4)),l+=4}}for(var w=0,h=0;h>2,O>>2));for(var p=0;pA&&te==ee[g-A])j[g]=j[g-A];else{var ne=y[te];if(ne==null&&(y[te]=ne=b.length,b.push(te),b.length>=300))break;j[g]=ne}}}var re=b.length;re<=256&&l==0&&(d=re<=2?1:re<=4?2:re<=16?4:8,d=Math.max(d,c));for(var p=0;p>1)]|=le[M+N]<<4-(N&1)*4;else if(d==2)for(var N=0;N>2)]|=le[M+N]<<6-(N&3)*2;else if(d==1)for(var N=0;N>3)]|=le[M+N]<<7-(N&7)*1}ae=ce,u=3,se=1}else if(_==0&&v.length==1){for(var ce=new Uint8Array(A*ie*3),de=A*ie,g=0;gw&&(w=D),ET&&(T=E))}w==-1&&(S=C=w=T=0),i&&((S&1)==1&&S--,(C&1)==1&&C--);var k=(w-S+1)*(T-C+1);kg&&(g=b),x_&&(_=x))}g==-1&&(m=h=g=_=0),o&&((m&1)==1&&m--,(h&1)==1&&h--),a={x:m,y:h,width:g-m+1,height:_-h+1};var w=r[i];w.rect=a,w.blend=1,w.img=new Uint8Array(a.width*a.height*4),r[i-1].dispose==0?(X._copyTile(l,t,n,w.img,a.width,a.height,-a.x,-a.y,0),X.encode._prepareDiff(f,t,n,w.img,a)):X._copyTile(f,t,n,w.img,a.width,a.height,-a.x,-a.y,0)},X.encode._prepareDiff=function(e,t,n,r,i){X._copyTile(e,t,n,r,i.width,i.height,-i.x,-i.y,2)},X.encode._filterZero=function(e,t,n,r,i,a,o){var s=[],c=[0,1,2,3,4];a==-1?(t*r>5e5||n==1)&&(c=[0]):c=[a];var l;o&&(l={level:0});for(var u=o&&UZIP!=null?UZIP:vc.default,d=0;d>1)+256&255;if(a==4)for(var l=i;l>1)&255;for(var l=i;l>1)&255}if(a==4){for(var l=0;l>>1:n>>>=1;e[t]=n}return e})(),update:function(e,t,n,r){for(var i=0;i>>8;return e},crc:function(e,t,n){return X.crc.update(4294967295,e,t,n)^4294967295}},X.quantize=function(e,t){var n=new Uint8Array(e),r=n.slice(0),i=new Uint32Array(r.buffer),a=X.quantize.getKDtree(r,t),o=a[0],s=a[1];X.quantize.planeDst;for(var c=n,l=i,u=c.length,d=new Uint8Array(n.length>>2),f=0;f>2]=_.ind,l[f>>2]=_.est.rgba}return{abuf:r.buffer,inds:d,plte:s}},X.quantize.getKDtree=function(e,t,n){n??(n=1e-4);var r=new Uint32Array(e.buffer),i={i0:0,i1:e.length,bst:null,est:null,tdst:0,left:null,right:null};i.bst=X.quantize.stats(e,i.i0,i.i1),i.est=X.quantize.estats(i.bst);for(var a=[i];a.lengtho&&(o=a[c].est.L,s=c);if(o=u||l.i1<=u){l.est.L=0;continue}var d={i0:l.i0,i1:u,bst:null,est:null,tdst:0,left:null,right:null};d.bst=X.quantize.stats(e,d.i0,d.i1),d.est=X.quantize.estats(d.bst);var f={i0:u,i1:l.i1,bst:null,est:null,tdst:0,left:null,right:null};f.bst={R:[],m:[],N:l.bst.N-d.bst.N};for(var c=0;c<16;c++)f.bst.R[c]=l.bst.R[c]-d.bst.R[c];for(var c=0;c<4;c++)f.bst.m[c]=l.bst.m[c]-d.bst.m[c];f.est=X.quantize.estats(f.bst),l.left=d,l.right=f,a[s]=d,a.push(f)}a.sort(function(e,t){return t.bst.N-e.bst.N});for(var c=0;c0&&(o=e.right,s=e.left);var c=X.quantize.getNearest(o,t,n,r,i);if(c.tdst<=a*a)return c;var l=X.quantize.getNearest(s,t,n,r,i);return l.tdsta;)r-=4;if(n>=r)break;var s=t[n>>2];t[n>>2]=t[r>>2],t[r>>2]=s,n+=4,r-=4}for(;o(e,n,i)>a;)n-=4;return n+4},X.quantize.vecDot=function(e,t,n){return e[t]*n[0]+e[t+1]*n[1]+e[t+2]*n[2]+e[t+3]*n[3]},X.quantize.stats=function(e,t,n){for(var r=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],i=[0,0,0,0],a=n-t>>2,o=t;o>>0}},X.M4={multVec:function(e,t){return[e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3],e[4]*t[0]+e[5]*t[1]+e[6]*t[2]+e[7]*t[3],e[8]*t[0]+e[9]*t[1]+e[10]*t[2]+e[11]*t[3],e[12]*t[0]+e[13]*t[1]+e[14]*t[2]+e[15]*t[3]]},dot:function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},sml:function(e,t){return[e*t[0],e*t[1],e*t[2],e*t[3]]}},X.encode.concatRGBA=function(e){for(var t=0,n=0;n1)throw Error(`Animated PNGs are not supported`);var r=Iu(new Uint8Array(n[0])),i=r.rgbChannel,a=r.alphaChannel;this.rgbChannel=i,a.some(function(e){return e<255})&&(this.alphaChannel=a),this.type=Fu(t.ctype),this.width=t.width,this.height=t.height,this.bitsPerComponent=8}return e.load=function(t){return new e(t)},e}(),zu=function(){function e(e){this.image=e,this.bitsPerComponent=e.bitsPerComponent,this.width=e.width,this.height=e.height,this.colorSpace=`DeviceRGB`}return e.for=function(t){return qo(this,void 0,void 0,function(){var n;return Jo(this,function(r){return n=Ru.load(t),[2,new e(n)]})})},e.prototype.embedIntoContext=function(e,t){return qo(this,void 0,void 0,function(){var n,r;return Jo(this,function(i){return n=this.embedAlphaChannel(e),r=e.flateStream(this.image.rgbChannel,{Type:`XObject`,Subtype:`Image`,BitsPerComponent:this.image.bitsPerComponent,Width:this.image.width,Height:this.image.height,ColorSpace:this.colorSpace,SMask:n}),t?(e.assign(t,r),[2,t]):[2,e.register(r)]})})},e.prototype.embedAlphaChannel=function(e){if(this.image.alphaChannel){var t=e.flateStream(this.image.alphaChannel,{Type:`XObject`,Subtype:`Image`,Height:this.image.height,Width:this.image.width,BitsPerComponent:this.image.bitsPerComponent,ColorSpace:`DeviceGray`,Decode:[0,1]});return e.register(t)}},e}(),Bu=function(){function e(e,t,n){this.bytes=e,this.start=t||0,this.pos=this.start,this.end=t&&n?t+n:this.bytes.length}return Object.defineProperty(e.prototype,`length`,{get:function(){return this.end-this.start},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,`isEmpty`,{get:function(){return this.length===0},enumerable:!1,configurable:!0}),e.prototype.getByte=function(){return this.pos>=this.end?-1:this.bytes[this.pos++]},e.prototype.getUint16=function(){var e=this.getByte(),t=this.getByte();return e===-1||t===-1?-1:(e<<8)+t},e.prototype.getInt32=function(){var e=this.getByte(),t=this.getByte(),n=this.getByte(),r=this.getByte();return(e<<24)+(t<<16)+(n<<8)+r},e.prototype.getBytes=function(e,t){t===void 0&&(t=!1);var n=this.bytes,r=this.pos,i=this.end;if(e){var a=r+e;a>i&&(a=i),this.pos=a;var o=n.subarray(r,a);return t?new Uint8ClampedArray(o):o}else{var o=n.subarray(r,i);return t?new Uint8ClampedArray(o):o}},e.prototype.peekByte=function(){var e=this.getByte();return this.pos--,e},e.prototype.peekBytes=function(e,t){t===void 0&&(t=!1);var n=this.getBytes(e,t);return this.pos-=n.length,n},e.prototype.skip=function(e){e||(e=1),this.pos+=e},e.prototype.reset=function(){this.pos=this.start},e.prototype.moveStart=function(){this.start=this.pos},e.prototype.makeSubStream=function(t,n){return new e(this.bytes,t,n)},e.prototype.decode=function(){return this.bytes},e}(),Vu=new Uint8Array,Hu=function(){function e(e){if(this.pos=0,this.bufferLength=0,this.eof=!1,this.buffer=Vu,this.minBufferLength=512,e)for(;this.minBufferLengthi&&(n=i)}else{for(;!this.eof;)this.readBlock();n=this.bufferLength}this.pos=n;var a=this.buffer.subarray(r,n);return t&&!(a instanceof Uint8ClampedArray)?new Uint8ClampedArray(a):a},e.prototype.peekByte=function(){var e=this.getByte();return this.pos--,e},e.prototype.peekBytes=function(e,t){t===void 0&&(t=!1);var n=this.getBytes(e,t);return this.pos-=n.length,n},e.prototype.skip=function(e){e||(e=1),this.pos+=e},e.prototype.reset=function(){this.pos=0},e.prototype.makeSubStream=function(e,t){for(var n=e+t;this.bufferLength<=n&&!this.eof;)this.readBlock();return new Bu(this.buffer,e,t)},e.prototype.decode=function(){for(;!this.eof;)this.readBlock();return this.buffer.subarray(0,this.bufferLength)},e.prototype.readBlock=function(){throw new il(this.constructor.name,`readBlock`)},e.prototype.ensureBuffer=function(e){var t=this.buffer;if(e<=t.byteLength)return t;for(var n=this.minBufferLength;n=0;--s)o[a+s]=l&255,l>>=8}},t}(Hu),Gu=function(e){U(t,e);function t(t,n){var r=e.call(this,n)||this;return r.stream=t,r.firstDigit=-1,n&&(n=.5*n),r}return t.prototype.readBlock=function(){var e=this.stream.getBytes(8e3);if(!e.length){this.eof=!0;return}for(var t=e.length+1>>1,n=this.ensureBuffer(this.bufferLength+t),r=this.bufferLength,i=this.firstDigit,a=0,o=e.length;a=48&&s<=57)c=s&15;else if(s>=65&&s<=70||s>=97&&s<=102)c=(s&15)+9;else if(s===62){this.eof=!0;break}else continue;i<0?i=c:(n[r++]=i<<4|c,i=-1)}i>=0&&this.eof&&(n[r++]=i<<4,i=-1),this.firstDigit=i,this.bufferLength=r},t}(Hu),Ku=new Int32Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),qu=new Int32Array([3,4,5,6,7,8,9,10,65547,65549,65551,65553,131091,131095,131099,131103,196643,196651,196659,196667,262211,262227,262243,262259,327811,327843,327875,327907,258,258,258]),Ju=new Int32Array([1,2,3,4,65541,65543,131081,131085,196625,196633,262177,262193,327745,327777,393345,393409,459009,459137,524801,525057,590849,591361,657409,658433,724993,727041,794625,798721,868353,876545]),Yu=[new Int32Array([459008,524368,524304,524568,459024,524400,524336,590016,459016,524384,524320,589984,524288,524416,524352,590048,459012,524376,524312,589968,459028,524408,524344,590032,459020,524392,524328,59e4,524296,524424,524360,590064,459010,524372,524308,524572,459026,524404,524340,590024,459018,524388,524324,589992,524292,524420,524356,590056,459014,524380,524316,589976,459030,524412,524348,590040,459022,524396,524332,590008,524300,524428,524364,590072,459009,524370,524306,524570,459025,524402,524338,590020,459017,524386,524322,589988,524290,524418,524354,590052,459013,524378,524314,589972,459029,524410,524346,590036,459021,524394,524330,590004,524298,524426,524362,590068,459011,524374,524310,524574,459027,524406,524342,590028,459019,524390,524326,589996,524294,524422,524358,590060,459015,524382,524318,589980,459031,524414,524350,590044,459023,524398,524334,590012,524302,524430,524366,590076,459008,524369,524305,524569,459024,524401,524337,590018,459016,524385,524321,589986,524289,524417,524353,590050,459012,524377,524313,589970,459028,524409,524345,590034,459020,524393,524329,590002,524297,524425,524361,590066,459010,524373,524309,524573,459026,524405,524341,590026,459018,524389,524325,589994,524293,524421,524357,590058,459014,524381,524317,589978,459030,524413,524349,590042,459022,524397,524333,590010,524301,524429,524365,590074,459009,524371,524307,524571,459025,524403,524339,590022,459017,524387,524323,589990,524291,524419,524355,590054,459013,524379,524315,589974,459029,524411,524347,590038,459021,524395,524331,590006,524299,524427,524363,590070,459011,524375,524311,524575,459027,524407,524343,590030,459019,524391,524327,589998,524295,524423,524359,590062,459015,524383,524319,589982,459031,524415,524351,590046,459023,524399,524335,590014,524303,524431,524367,590078,459008,524368,524304,524568,459024,524400,524336,590017,459016,524384,524320,589985,524288,524416,524352,590049,459012,524376,524312,589969,459028,524408,524344,590033,459020,524392,524328,590001,524296,524424,524360,590065,459010,524372,524308,524572,459026,524404,524340,590025,459018,524388,524324,589993,524292,524420,524356,590057,459014,524380,524316,589977,459030,524412,524348,590041,459022,524396,524332,590009,524300,524428,524364,590073,459009,524370,524306,524570,459025,524402,524338,590021,459017,524386,524322,589989,524290,524418,524354,590053,459013,524378,524314,589973,459029,524410,524346,590037,459021,524394,524330,590005,524298,524426,524362,590069,459011,524374,524310,524574,459027,524406,524342,590029,459019,524390,524326,589997,524294,524422,524358,590061,459015,524382,524318,589981,459031,524414,524350,590045,459023,524398,524334,590013,524302,524430,524366,590077,459008,524369,524305,524569,459024,524401,524337,590019,459016,524385,524321,589987,524289,524417,524353,590051,459012,524377,524313,589971,459028,524409,524345,590035,459020,524393,524329,590003,524297,524425,524361,590067,459010,524373,524309,524573,459026,524405,524341,590027,459018,524389,524325,589995,524293,524421,524357,590059,459014,524381,524317,589979,459030,524413,524349,590043,459022,524397,524333,590011,524301,524429,524365,590075,459009,524371,524307,524571,459025,524403,524339,590023,459017,524387,524323,589991,524291,524419,524355,590055,459013,524379,524315,589975,459029,524411,524347,590039,459021,524395,524331,590007,524299,524427,524363,590071,459011,524375,524311,524575,459027,524407,524343,590031,459019,524391,524327,589999,524295,524423,524359,590063,459015,524383,524319,589983,459031,524415,524351,590047,459023,524399,524335,590015,524303,524431,524367,590079]),9],Xu=[new Int32Array([327680,327696,327688,327704,327684,327700,327692,327708,327682,327698,327690,327706,327686,327702,327694,0,327681,327697,327689,327705,327685,327701,327693,327709,327683,327699,327691,327707,327687,327703,327695,0]),5],Zu=function(e){U(t,e);function t(t,n){var r=e.call(this,n)||this;r.stream=t;var i=t.getByte(),a=t.getByte();if(i===-1||a===-1)throw Error(`Invalid header in flate stream: `+i+`, `+a);if((i&15)!=8)throw Error(`Unknown compression method in flate stream: `+i+`, `+a);if(((i<<8)+a)%31!=0)throw Error(`Bad FCHECK in flate stream: `+i+`, `+a);if(a&32)throw Error(`FDICT bit set in flate stream: `+i+`, `+a);return r.codeSize=0,r.codeBuf=0,r}return t.prototype.readBlock=function(){var e,t,n=this.stream,r=this.getBits(3);if(r&1&&(this.eof=!0),r>>=1,r===0){var i=void 0;if((i=n.getByte())===-1)throw Error(`Bad block header in flate stream`);var a=i;if((i=n.getByte())===-1||(a|=i<<8,(i=n.getByte())===-1))throw Error(`Bad block header in flate stream`);var o=i;if((i=n.getByte())===-1)throw Error(`Bad block header in flate stream`);if(o|=i<<8,o!==(~a&65535)&&(a!==0||o!==0))throw Error(`Bad uncompressed block length in flate stream`);this.codeBuf=0,this.codeSize=0;var s=this.bufferLength;e=this.ensureBuffer(s+a);var c=s+a;if(this.bufferLength=c,a===0)n.peekByte()===-1&&(this.eof=!0);else for(var l=s;l0;)y[g++]=S}u=this.generateHuffmanTable(y.subarray(0,f)),d=this.generateHuffmanTable(y.subarray(f,v))}else throw Error(`Unknown block type in flate stream`);e=this.buffer;for(var T=e?e.length:0,E=this.bufferLength;;){var D=this.getCode(u);if(D<256){E+1>=T&&(e=this.ensureBuffer(E+1),T=e.length),e[E++]=D;continue}if(D===256){this.bufferLength=E;return}D-=257,D=qu[D];var O=D>>16;O>0&&(O=this.getBits(O)),t=(D&65535)+O,D=this.getCode(d),D=Ju[D],O=D>>16,O>0&&(O=this.getBits(O));var k=(D&65535)+O;E+t>=T&&(e=this.ensureBuffer(E+t),T=e.length);for(var ee=0;ee>e,this.codeSize=n-=e,i},t.prototype.getCode=function(e){for(var t=this.stream,n=e[0],r=e[1],i=this.codeSize,a=this.codeBuf,o;i>16,l=s&65535;if(c<1||i>c,this.codeSize=i-c,l},t.prototype.generateHuffmanTable=function(e){var t=e.length,n=0,r;for(r=0;rn&&(n=e[r]);for(var i=1<>=1;for(r=u;r0;if(!y||y<256)m[0]=y,h=1;else if(y>=258)if(y=0;i--)m[i]=l[a],a=d[a];else m[h++]=m[0];else if(y===256){f=9,c=258,h=0;continue}else{this.eof=!0,delete this.lzwState;break}if(b&&(d[c]=p,u[c]=u[p]+1,l[c]=m[0],c++,f=c+s&c+s-1?f:Math.min(Math.log(c+s)/.6931471805599453+1,12)|0),p=y,g+=h,t>>t&(1<0){var i=this.stream.getBytes(r);t.set(i,n),n+=r}}else{r=257-r;var a=e[1];t=this.ensureBuffer(n+r+1);for(var o=0;ot.size())throw new gl(e,0,t.size());t.remove(e)}else{if(e!==0)throw new gl(e,0,0);this.setKids([])}},t.prototype.normalizedEntries=function(){var e=this.Kids();return e||(e=this.dict.context.obj([this.ref]),this.dict.set(J.of(`Kids`),e)),{Kids:e}},t.fromDict=function(e,n){return new t(e,n)},t}(fd),vd=function(e){U(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.Opt=function(){return this.dict.lookupMaybe(J.of(`Opt`),Eu,Y,Pl)},t.prototype.setOpt=function(e){this.dict.set(J.of(`Opt`),this.dict.context.obj(e))},t.prototype.getExportValues=function(){var e=this.Opt();if(e){if(e instanceof Eu||e instanceof Y)return[e];for(var t=[],n=0,r=e.size();nt.size())throw new gl(e,0,t.size());t.remove(e)}},t.prototype.normalizeExportValues=function(){for(var e=this.getExportValues()??[],t=[],n=this.getWidgets(),r=0,i=n.length;r1){if(!this.hasFlag(wd.MultiSelect))throw new vl;this.dict.set(J.of(`V`),this.dict.context.obj(e))}this.updateSelectedIndices(e)},t.prototype.valuesAreValid=function(e){for(var t=this.getOptions(),n=function(n,r){var i=e[n].decodeText();if(!t.find(function(e){return i===(e.display||e.value).decodeText()}))return{value:!1}},r=0,i=e.length;r1){for(var t=Array(e.length),n=this.getOptions(),r=function(r,i){var a=e[r].decodeText();t[r]=n.findIndex(function(e){return a===(e.display||e.value).decodeText()})},i=0,a=e.length;i0){var a=i.lookup(0,Eu,Y),o=i.lookupMaybe(1,Eu,Y);t.push({value:a,display:o||a})}}return t}return[]},t}(_d),Ed=function(e){U(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.fromDict=function(e,n){return new t(e,n)},t.create=function(e){var n=e.obj({FT:`Ch`,Ff:wd.Combo,Kids:[]});return new t(n,e.register(n))},t}(Td),Dd=function(e){U(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.addField=function(e){this.normalizedEntries().Kids?.push(e)},t.prototype.normalizedEntries=function(){var e=this.Kids();return e||(e=this.dict.context.obj([]),this.dict.set(J.of(`Kids`),e)),{Kids:e}},t.fromDict=function(e,n){return new t(e,n)},t.create=function(e){var n=e.obj({});return new t(n,e.register(n))},t}(fd),Od=function(e){U(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.fromDict=function(e,n){return new t(e,n)},t}(_d),kd=function(e){U(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.MaxLen=function(){var e=this.dict.lookup(J.of(`MaxLen`));if(e instanceof q)return e},t.prototype.Q=function(){var e=this.dict.lookup(J.of(`Q`));if(e instanceof q)return e},t.prototype.setMaxLength=function(e){this.dict.set(J.of(`MaxLen`),q.of(e))},t.prototype.removeMaxLength=function(){this.dict.delete(J.of(`MaxLen`))},t.prototype.getMaxLength=function(){return this.MaxLen()?.asNumber()},t.prototype.setQuadding=function(e){this.dict.set(J.of(`Q`),q.of(e))},t.prototype.getQuadding=function(){return this.Q()?.asNumber()},t.prototype.setValue=function(e){this.dict.set(J.of(`V`),e)},t.prototype.removeValue=function(){this.dict.delete(J.of(`V`))},t.prototype.getValue=function(){var e=this.V();if(e instanceof Eu||e instanceof Y)return e},t.fromDict=function(e,n){return new t(e,n)},t.create=function(e){var n=e.obj({FT:`Tx`,Kids:[]});return new t(n,e.register(n))},t}(_d),Ad=function(e){U(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.fromDict=function(e,n){return new t(e,n)},t.create=function(e){var n=e.obj({FT:`Btn`,Ff:Sd.PushButton,Kids:[]});return new t(n,e.register(n))},t}(vd),jd=function(e){U(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.setValue=function(e){if(!this.getOnValues().includes(e)&&e!==J.of(`Off`))throw new _l;this.dict.set(J.of(`V`),e);for(var t=this.getWidgets(),n=0,r=t.length;ni)throw new ml(n,i);for(var a=n,o=0,s=r.size();oa)return l.insertLeafNode(e,a)||c;a-=l.Count().asNumber()}l instanceof su&&--a}if(a===0){this.insertLeafKid(r.size(),e);return}throw new hl(n,`insertLeafNode`)},t.prototype.removeLeafNode=function(e,n){n===void 0&&(n=!0);var r=this.Kids(),i=this.Count().asNumber();if(e>=i)throw new ml(e,i);for(var a=e,o=0,s=r.size();oa){l.removeLeafNode(a,n),n&&l.Kids().size()===0&&r.remove(o);return}else a-=l.Count().asNumber();if(l instanceof su)if(a===0){this.removeKid(o);return}else --a}throw new hl(e,`removeLeafNode`)},t.prototype.ascend=function(e){e(this);var t=this.Parent();t&&t.ascend(e)},t.prototype.traverse=function(e){for(var n=this.Kids(),r=0,i=n.size();r2**53-1)if(this.capNumbers){var r=`Parsed number that is too large for some PDF readers: `+e+`, using Number.MAX_SAFE_INTEGER instead.`;return console.warn(r),2**53-1}else{var r=`Parsed number that is too large for some PDF readers: `+e+`, not capping.`;console.warn(r)}return n},e.prototype.skipWhitespace=function(){for(;!this.bytes.done()&&Rl[this.bytes.peek()];)this.bytes.next()},e.prototype.skipLine=function(){for(;!this.bytes.done();){var e=this.bytes.peek();if(e===Xd||e===Zd)return;this.bytes.next()}},e.prototype.skipComment=function(){if(this.bytes.peek()!==K.Percent)return!1;for(;!this.bytes.done();){var e=this.bytes.peek();if(e===Xd||e===Zd)return!0;this.bytes.next()}return!0},e.prototype.skipWhitespaceAndComments=function(){for(this.skipWhitespace();this.skipComment();)this.skipWhitespace()},e.prototype.matchKeyword=function(e){for(var t=this.bytes.offset(),n=0,r=e.length;n=this.length},e.prototype.offset=function(){return this.idx},e.prototype.slice=function(e,t){return this.bytes.slice(e,t)},e.prototype.position=function(){return{line:this.line,column:this.column,offset:this.idx}},e.of=function(t){return new e(t)},e.fromPDFRawStream=function(t){return e.of(td(t).decode())},e}(),ef=K.Space,tf=K.CarriageReturn,nf=K.Newline,rf=[K.s,K.t,K.r,K.e,K.a,K.m],af=[K.e,K.n,K.d,K.s,K.t,K.r,K.e,K.a,K.m],of={header:[K.Percent,K.P,K.D,K.F,K.Dash],eof:[K.Percent,K.Percent,K.E,K.O,K.F],obj:[K.o,K.b,K.j],endobj:[K.e,K.n,K.d,K.o,K.b,K.j],xref:[K.x,K.r,K.e,K.f],trailer:[K.t,K.r,K.a,K.i,K.l,K.e,K.r],startxref:[K.s,K.t,K.a,K.r,K.t,K.x,K.r,K.e,K.f],true:[K.t,K.r,K.u,K.e],false:[K.f,K.a,K.l,K.s,K.e],null:[K.n,K.u,K.l,K.l],stream:rf,streamEOF1:Yo(rf,[ef,tf,nf]),streamEOF2:Yo(rf,[tf,nf]),streamEOF3:Yo(rf,[tf]),streamEOF4:Yo(rf,[nf]),endstream:af,EOF1endstream:Yo([tf,nf],af),EOF2endstream:Yo([tf],af),EOF3endstream:Yo([nf],af)},sf=function(e){U(t,e);function t(t,n,r){r===void 0&&(r=!1);var i=e.call(this,t,r)||this;return i.context=n,i}return t.prototype.parseObject=function(){if(this.skipWhitespaceAndComments(),this.matchKeyword(of.true))return Il.True;if(this.matchKeyword(of.false))return Il.False;if(this.matchKeyword(of.null))return Kl;var e=this.bytes.peek();if(e===K.LessThan&&this.bytes.peekAhead(1)===K.LessThan)return this.parseDictOrStream();if(e===K.LessThan)return this.parseHexString();if(e===K.LeftParen)return this.parseString();if(e===K.ForwardSlash)return this.parseName();if(e===K.LeftSquareBracket)return this.parseArray();if(qd[e])return this.parseNumberOrRef();throw new wl(this.bytes.position(),e)},t.prototype.parseNumberOrRef=function(){var e=this.parseRawNumber();this.skipWhitespaceAndComments();var t=this.bytes.offset();if(Gd[this.bytes.peek()]){var n=this.parseRawNumber();if(this.skipWhitespaceAndComments(),this.bytes.peek()===K.R)return this.bytes.assertNext(K.R),Ql.of(e,n)}return this.bytes.moveTo(t),q.of(e)},t.prototype.parseHexString=function(){var e=``;for(this.bytes.assertNext(K.LessThan);!this.bytes.done()&&this.bytes.peek()!==K.GreaterThan;)e+=ss(this.bytes.next());return this.bytes.assertNext(K.GreaterThan),Y.of(e)},t.prototype.parseString=function(){for(var e=0,t=!1,n=``;!this.bytes.done();){var r=this.bytes.next();if(n+=ss(r),t||(r===K.LeftParen&&(e+=1),r===K.RightParen&&--e),r===K.BackSlash?t=!t:t&&(t=!1),e===0)return Eu.of(n.substring(1,n.length-1))}throw new Dl(this.bytes.position())},t.prototype.parseName=function(){this.bytes.assertNext(K.ForwardSlash);for(var e=``;!this.bytes.done();){var t=this.bytes.peek();if(Rl[t]||Ll[t])break;e+=ss(t),this.bytes.next()}return J.of(e)},t.prototype.parseArray=function(){this.bytes.assertNext(K.LeftSquareBracket),this.skipWhitespaceAndComments();for(var e=Pl.withContext(this.context);this.bytes.peek()!==K.RightSquareBracket;){var t=this.parseObject();e.push(t),this.skipWhitespaceAndComments()}return this.bytes.assertNext(K.RightSquareBracket),e},t.prototype.parseDict=function(){this.bytes.assertNext(K.LessThan),this.bytes.assertNext(K.LessThan),this.skipWhitespaceAndComments();for(var e=new Map;!this.bytes.done()&&this.bytes.peek()!==K.GreaterThan&&this.bytes.peekAhead(1)!==K.GreaterThan;){var t=this.parseName(),n=this.parseObject();e.set(t,n),this.skipWhitespaceAndComments()}this.skipWhitespaceAndComments(),this.bytes.assertNext(K.GreaterThan),this.bytes.assertNext(K.GreaterThan);var r=e.get(J.of(`Type`));return r===J.of(`Catalog`)?Ud.fromMapWithContext(e,this.context):r===J.of(`Pages`)?Wd.fromMapWithContext(e,this.context):r===J.of(`Page`)?su.fromMapWithContext(e,this.context):ql.fromMapWithContext(e,this.context)},t.prototype.parseDictOrStream=function(){var e=this.bytes.position(),t=this.parseDict();if(this.skipWhitespaceAndComments(),!this.matchKeyword(of.streamEOF1)&&!this.matchKeyword(of.streamEOF2)&&!this.matchKeyword(of.streamEOF3)&&!this.matchKeyword(of.streamEOF4)&&!this.matchKeyword(of.stream))return t;var n=this.bytes.offset(),r,i=t.get(J.of(`Length`));i instanceof q?(r=n+i.asNumber(),this.bytes.moveTo(r),this.skipWhitespaceAndComments(),this.matchKeyword(of.endstream)||(this.bytes.moveTo(n),r=this.findEndOfStreamFallback(e))):r=this.findEndOfStreamFallback(e);var a=this.bytes.slice(n,r);return Yl.of(t,a)},t.prototype.findEndOfStreamFallback=function(e){for(var t=1,n=this.bytes.offset();!this.bytes.done()&&(n=this.bytes.offset(),this.matchKeyword(of.stream)?t+=1:this.matchKeyword(of.EOF1endstream)||this.matchKeyword(of.EOF2endstream)||this.matchKeyword(of.EOF3endstream)||this.matchKeyword(of.endstream)?--t:this.bytes.next(),t!==0););if(t!==0)throw new El(e);return n},t.forBytes=function(e,n,r){return new t($d.of(e),n,r)},t.forByteStream=function(e,n,r){return r===void 0&&(r=!1),new t(e,n,r)},t}(Qd),cf=function(e){U(t,e);function t(t,n){var r=e.call(this,$d.fromPDFRawStream(t),t.dict.context)||this,i=t.dict;return r.alreadyParsed=!1,r.shouldWaitForTick=n||(function(){return!1}),r.firstOffset=i.lookup(J.of(`First`),q).asNumber(),r.objectCount=i.lookup(J.of(`N`),q).asNumber(),r}return t.prototype.parseIntoContext=function(){return qo(this,void 0,void 0,function(){var e,t,n,r,i,a,o,s;return Jo(this,function(c){switch(c.label){case 0:if(this.alreadyParsed)throw new cl(`PDFObjectStreamParser`,`parseIntoContext`);this.alreadyParsed=!0,e=this.parseOffsetsAndObjectNumbers(),t=0,n=e.length,c.label=1;case 1:return t=K.Space&&t<=K.Tilde&&(this.matchKeyword(of.xref)||this.matchKeyword(of.trailer)||this.matchKeyword(of.startxref)||this.matchIndirectObjectHeader())){this.bytes.moveTo(e);break}this.bytes.next()}},t.prototype.skipBinaryHeaderComment=function(){this.skipWhitespaceAndComments();try{var e=this.bytes.offset();this.parseIndirectObjectHeader(),this.bytes.moveTo(e)}catch{this.bytes.next(),this.skipWhitespaceAndComments()}},t.forBytesWithOptions=function(e,n,r,i){return new t(e,n,r,i)},t}(sf),df=function(e){return 1<0&&(r[r.length]=+i),n[n.length]={cmd:t,args:r},r=[],i=``,a=!1),t=l;else if([` `,`,`].includes(l)||l===`-`&&i.length>0&&i[i.length-1]!==`e`||l===`.`&&a){if(i.length===0)continue;r.length===o?(n[n.length]={cmd:t,args:r},r=[+i],t===`M`&&(t=`L`),t===`m`&&(t=`l`)):r[r.length]=+i,a=l===`.`,i=[`-`,`.`].includes(l)?l:``}else i+=l,l===`.`&&(a=!0)}return i.length>0&&(r.length===o?(n[n.length]={cmd:t,args:r},r=[+i],t===`M`&&(t=`L`),t===`m`&&(t=`l`)):r[r.length]=+i),n[n.length]={cmd:t,args:r},n},Pp=function(e){Q=$=Op=kp=Ap=jp=0;for(var t=[],n=0;n1&&(f=Math.sqrt(f),n*=f,r*=f);var p=d/n,m=u/n,h=-u/r,g=d/r,_=p*s+m*c,v=h*s+g*c,y=p*e+m*t,b=h*e+g*t,x=1/((y-_)*(y-_)+(b-v)*(b-v))-.25;x<0&&(x=0);var S=Math.sqrt(x);a===i&&(S=-S);var C=.5*(_+y)-S*(b-v),w=.5*(v+b)+S*(y-_),T=Math.atan2(v-w,_-C),E=Math.atan2(b-w,y-C)-T;E<0&&a===1?E+=2*Math.PI:E>0&&a===0&&(E-=2*Math.PI);for(var D=Math.ceil(Math.abs(E/(Math.PI*.5+.001))),O=[],k=0;ke.length)return i-1;var m=t.heightAtSize(i);if((m+m*.2)*a>Math.abs(n.height))return i-1;i+=1}return i},bm=function(e,t,n,r){for(var i=n.width/r,a=n.height,o=_m,s=vs(e);oi*.75)return o-1}if(t.heightAtSize(o,{descender:!1})>a)return o-1;o+=1}return o},xm=function(e){for(var t=e.length;t>0;t--)if(/\s/.test(e[t]))return t},Sm=function(e,t,n,r){for(var i=e.length;i>0;){var a=e.substring(0,i),o=n.encodeText(a),s=n.widthOfTextAtSize(a,r);if(sf&&(f=C+x),m+s>p&&(p=m+s),l.push({text:y,encoded:b,width:x,height:s,x:C,y:m}),_=S?.trim()}return{fontSize:r,lineHeight:c,lines:l,bounds:{x:u,y:d,width:f-u,height:p-d}}},wm=function(e,t){var n=t.fontSize,r=t.font,i=t.bounds,a=t.cellCount,o=gs(fs(e));if(o.length>a)throw new pm(o.length,a);(n===void 0||n===0)&&(n=bm(o,r,i,a));for(var s=i.width/a,c=r.heightAtSize(n,{descender:!1}),l=i.y+(i.height/2-c/2),u=[],d=i.x,f=i.y,p=i.x+i.width,m=i.y+i.height,h=0,g=0;hp&&(p=S+x),l+c>m&&(m=l+c),u.push({text:o,encoded:b,width:x,height:c,x:S,y:l}),h+=1,g+=y}return{fontSize:n,cells:u,bounds:{x:d,y:f,width:p-d,height:m-f}}},Tm=function(e,t){var n=t.alignment,r=t.fontSize,i=t.font,a=t.bounds,o=gs(fs(e));(r===void 0||r===0)&&(r=ym([o],i,a));var s=i.encodeText(o),c=i.widthOfTextAtSize(o,r),l=i.heightAtSize(r,{descender:!1}),u=n===gm.Left?a.x:n===gm.Center?a.x+a.width/2-c/2:n===gm.Right?a.x+a.width-c:a.x,d=a.y+(a.height/2-l/2);return{fontSize:r,line:{text:o,encoded:s,width:c,height:l,x:u,y:d},bounds:{x:u,y:d,width:c,height:l}}},Em=function(e){return`normal`in e?e:{normal:e}},Dm=/\/([^\0\t\n\f\r\ ]+)[\0\t\n\f\r\ ]+(\d*\.\d+|\d+)[\0\t\n\f\r\ ]+Tf/,Om=function(e){var t=Cs(e.getDefaultAppearance()??``,Dm).match??[],n=Number(t[2]);return isFinite(n)?n:void 0},km=/(\d*\.\d+|\d+)[\0\t\n\f\r\ ]*(\d*\.\d+|\d+)?[\0\t\n\f\r\ ]*(\d*\.\d+|\d+)?[\0\t\n\f\r\ ]*(\d*\.\d+|\d+)?[\0\t\n\f\r\ ]+(g|rg|k)/,Am=function(e){var t=Cs(e.getDefaultAppearance()??``,km).match??[],n=t[1],r=t[2],i=t[3],a=t[4],o=t[5];if(o===`g`&&n)return vp(Number(n));if(o===`rg`&&n&&r&&i)return yp(Number(n),Number(r),Number(i));if(o===`k`&&n&&r&&i&&a)return bp(Number(n),Number(r),Number(i),Number(a))},jm=function(e,t,n,r){r===void 0&&(r=0);var i=[wp(t).toString(),rp(n?.name??`dummy__noop`,r).toString()].join(` `);e.setDefaultAppearance(i)},Mm=function(e,t){var n=Am(t),r=Am(e.acroField),i=t.getRectangle(),a=t.getAppearanceCharacteristics(),o=t.getBorderStyle()?.getWidth()??0,s=Cf(a?.getRotation()),c=wf(i,s),l=c.width,u=c.height,d=Zp(Go(Go({},i),{rotation:s})),f=yp(0,0,0),p=Ep(a?.getBorderColor())??f,m=Ep(a?.getBackgroundColor()),h=Ep(a?.getBackgroundColor(),.8),g=n??r??f;jm(n?t:e.acroField,g);var _={x:0+o/2,y:0+o/2,width:l-o,height:u-o,thickness:1.5,borderWidth:o,borderColor:p,markColor:g};return{normal:{on:Yo(d,Qp(Go(Go({},_),{color:m,filled:!0}))),off:Yo(d,Qp(Go(Go({},_),{color:m,filled:!1})))},down:{on:Yo(d,Qp(Go(Go({},_),{color:h,filled:!0}))),off:Yo(d,Qp(Go(Go({},_),{color:h,filled:!1})))}}},Nm=function(e,t){var n=Am(t),r=Am(e.acroField),i=t.getRectangle(),a=t.getAppearanceCharacteristics(),o=t.getBorderStyle()?.getWidth()??0,s=Cf(a?.getRotation()),c=wf(i,s),l=c.width,u=c.height,d=Zp(Go(Go({},i),{rotation:s})),f=yp(0,0,0),p=Ep(a?.getBorderColor())??f,m=Ep(a?.getBackgroundColor()),h=Ep(a?.getBackgroundColor(),.8),g=n??r??f;jm(n?t:e.acroField,g);var _={x:l/2,y:u/2,width:l-o,height:u-o,borderWidth:o,borderColor:p,dotColor:g};return{normal:{on:Yo(d,$p(Go(Go({},_),{color:m,filled:!0}))),off:Yo(d,$p(Go(Go({},_),{color:m,filled:!1})))},down:{on:Yo(d,$p(Go(Go({},_),{color:h,filled:!0}))),off:Yo(d,$p(Go(Go({},_),{color:h,filled:!1})))}}},Pm=function(e,t,n){var r=Am(t),i=Am(e.acroField),a=Om(t),o=Om(e.acroField),s=t.getRectangle(),c=t.getAppearanceCharacteristics(),l=t.getBorderStyle(),u=c?.getCaptions(),d=u?.normal??``,f=u?.down??d??``,p=l?.getWidth()??0,m=Cf(c?.getRotation()),h=wf(s,m),g=h.width,_=h.height,v=Zp(Go(Go({},s),{rotation:m})),y=yp(0,0,0),b=Ep(c?.getBorderColor()),x=Ep(c?.getBackgroundColor()),S=Ep(c?.getBackgroundColor(),.8),C={x:p,y:p,width:g-p*2,height:_-p*2},w=Tm(d,{alignment:gm.Center,fontSize:a??o,font:n,bounds:C}),T=Tm(f,{alignment:gm.Center,fontSize:a??o,font:n,bounds:C}),E=Math.min(w.fontSize,T.fontSize),D=r??i??y;jm(r||a!==void 0?t:e.acroField,D,n,E);var O={x:0+p/2,y:0+p/2,width:g-p,height:_-p,borderWidth:p,borderColor:b,textColor:D,font:n.name,fontSize:E};return{normal:Yo(v,em(Go(Go({},O),{color:x,textLines:[w.line]}))),down:Yo(v,em(Go(Go({},O),{color:S,textLines:[T.line]})))}},Fm=function(e,t,n){var r=Am(t),i=Am(e.acroField),a=Om(t),o=Om(e.acroField),s=t.getRectangle(),c=t.getAppearanceCharacteristics(),l=t.getBorderStyle(),u=e.getText()??``,d=l?.getWidth()??0,f=Cf(c?.getRotation()),p=wf(s,f),m=p.width,h=p.height,g=Zp(Go(Go({},s),{rotation:f})),_=yp(0,0,0),v=Ep(c?.getBorderColor()),y=Ep(c?.getBackgroundColor()),b,x,S=+!e.isCombed(),C={x:d+S,y:d+S,width:m-(d+S)*2,height:h-(d+S)*2};if(e.isMultiline()){var w=Cm(u,{alignment:e.getAlignment(),fontSize:a??o,font:n,bounds:C});b=w.lines,x=w.fontSize}else if(e.isCombed()){var w=wm(u,{fontSize:a??o,font:n,bounds:C,cellCount:e.getMaxLength()??0});b=w.cells,x=w.fontSize}else{var w=Tm(u,{alignment:e.getAlignment(),fontSize:a??o,font:n,bounds:C});b=[w.line],x=w.fontSize}var T=r??i??_;return jm(r||a!==void 0?t:e.acroField,T,n,x),Yo(g,nm({x:0+d/2,y:0+d/2,width:m-d,height:h-d,borderWidth:d??0,borderColor:v,textColor:T,font:n.name,fontSize:x,color:y,textLines:b,padding:S}))},Im=function(e,t,n){var r=Am(t),i=Am(e.acroField),a=Om(t),o=Om(e.acroField),s=t.getRectangle(),c=t.getAppearanceCharacteristics(),l=t.getBorderStyle(),u=e.getSelected()[0]??``,d=l?.getWidth()??0,f=Cf(c?.getRotation()),p=wf(s,f),m=p.width,h=p.height,g=Zp(Go(Go({},s),{rotation:f})),_=yp(0,0,0),v=Ep(c?.getBorderColor()),y=Ep(c?.getBackgroundColor()),b=1,x={x:d+b,y:d+b,width:m-(d+b)*2,height:h-(d+b)*2},S=Tm(u,{alignment:gm.Left,fontSize:a??o,font:n,bounds:x}),C=S.line,w=S.fontSize,T=r??i??_;return jm(r||a!==void 0?t:e.acroField,T,n,w),Yo(g,nm({x:0+d/2,y:0+d/2,width:m-d,height:h-d,borderWidth:d??0,borderColor:v,textColor:T,font:n.name,fontSize:w,color:y,textLines:[C],padding:b}))},Lm=function(e,t,n){var r=Am(t),i=Am(e.acroField),a=Om(t),o=Om(e.acroField),s=t.getRectangle(),c=t.getAppearanceCharacteristics(),l=t.getBorderStyle()?.getWidth()??0,u=Cf(c?.getRotation()),d=wf(s,u),f=d.width,p=d.height,m=Zp(Go(Go({},s),{rotation:u})),h=yp(0,0,0),g=Ep(c?.getBorderColor()),_=Ep(c?.getBackgroundColor()),v=e.getOptions(),y=e.getSelected();e.isSorted()&&v.sort();for(var b=``,x=0,S=v.length;x1||n.length===1&&t)&&this.enableMultiselect();for(var i=Array(n.length),a=0,o=n.length;a1||n.length===1&&t)&&this.enableMultiselect();for(var r=Array(n.length),i=0,a=n.length;it)throw new mm(e.length,t,this.getName());this.markAsDirty(),this.disableRichFormatting(),e?this.acroField.setValue(Y.fromText(e)):this.acroField.removeValue()},t.prototype.getAlignment=function(){var e=this.acroField.getQuadding();return e===0?gm.Left:e===1?gm.Center:e===2?gm.Right:gm.Left},t.prototype.setAlignment=function(e){Hc(e,`alignment`,gm),this.markAsDirty(),this.acroField.setQuadding(e)},t.prototype.getMaxLength=function(){return this.acroField.getMaxLength()},t.prototype.setMaxLength=function(e){if(Xc(e,`maxLength`,0,2**53-1),this.markAsDirty(),e===void 0)this.acroField.removeMaxLength();else{var t=this.getText();if(t&&t.length>e)throw new hm(t.length,e,this.getName());this.acroField.setMaxLength(e)}},t.prototype.removeMaxLength=function(){this.markAsDirty(),this.acroField.removeMaxLength()},t.prototype.setImage=function(e){for(var t=this.getAlignment(),n=t===gm.Center?Vm.Center:t===gm.Right?Vm.Right:Vm.Left,r=this.acroField.getWidgets(),i=0,a=r.length;i{let r=e.node.Annots();if(!r)return;let i=r?.size()??0;for(let e=0;e{let a=r.node.Annots();if(!a)return;let o=a?.size()??0;for(let r=0;r{if(e.level>n)return;let[i,a]=t?.[e.key]??[0,0],o={title:e.title,to:[i,0,a],open:!1,children:[]};if(e.children?.length>0)for(let t of e.children){let e=r(t);e&&o.children.push(e)}return o};return r(e)?.children??[]}var hh=(e,t)=>{for(let n of e){let e=t(n);`children`in n&&e!==!1&&hh(n.children,t)}},gh=e=>{let t=[];return hh(e,e=>void t.push(e)),t},_h=e=>{let t=0;return hh(e,e=>(t+=1,!(`open`in e&&!e.open))),t},vh=async(e,t)=>{let n=e.context.nextRef(),r=new WeakMap;for(let n of gh(t))r.set(n,e.context.nextRef());let i=(()=>{let t=[];return e.catalog.Pages().traverse((e,n)=>{e.get(e.context.obj(`Type`))?.toString()===`/Page`&&t.push(n)}),t})(),a=(t,n)=>{let{length:o}=t;for(let s=0;s0?(a(c.children,l),{First:r.get(c.children[0]),Last:r.get(c.children[c.children.length-1]),Count:_h(c.children)*(c.open?1:-1)}):{};e.context.assign(l,e.context.obj({Title:Y.fromText(c.title),Parent:n,...s>0?{Prev:r.get(t[s-1])}:{},...s0?{First:r.get(t[0]),Last:r.get(t[t.length-1])}:{},Count:o})),e.catalog.set(e.context.obj(`Outlines`),n)};async function yh(e,{headings:t,maxLevel:n,frontMatter:r,displayMetadata:i}){let a=await oh.load(e),o=await fh(a);return ph(a,o),vh(a,mh(t,o,n)),i&&bh(a,r??{}),e=await a.save(),e}function bh(e,{title:t,author:n,keywords:r,subject:i,creator:a,created_at:o,updated_at:s}){t&&e.setTitle(t,{showInWindowTitleBar:!0}),n&&(Array.isArray(n)?e.setAuthor(n.join(`, `)):e.setAuthor(n.toString())),r&&e.setKeywords(typeof r==`string`?[r]:r),i&&e.setSubject(i),e.setCreator(a??`Obsidian`),e.setProducer(`Obsidian`),e.setCreationDate(new Date(o??new Date)),e.setModificationDate(new Date(s??new Date))}function xh(e,t,n){let r={...e};return t&&n.forEach(e=>{let n=t[e];n!=null&&(r[e]=n)}),r}function Sh(e,t){e=xh(e,t,[`headerTemplate`,`footerTemplate`]);let n=e.pageSize;e.pageSize==`Custom`&&e.pageWidth&&e.pageHeight&&(n={width:ao(e.pageWidth,210)/25.4,height:ao(e.pageHeight,297)/25.4});let r=e?.scale??100;(r>200||r<10)&&(r=100);let i={landscape:e?.landscape,printBackground:e?.printBackground,generateTaggedPDF:e?.generateTaggedPDF,pageSize:n,scale:r/100,margins:{marginType:`default`},displayHeaderFooter:e.displayHeader||e.displayFooter,headerTemplate:e.displayHeader?no(e.headerTemplate,t??{}):``,footerTemplate:e.displayFooter?no(e.footerTemplate,t??{}):``};return e.marginType==`0`?i.margins={marginType:`custom`,top:0,bottom:0,left:0,right:0}:e.marginType==`1`?i.margins={marginType:`default`}:e.marginType==`2`?i.margins={marginType:`custom`,top:.1,bottom:.1,left:.1,right:.1}:e.marginType==`3`&&(i.margins={marginType:`custom`,top:ao(e.marginTop,0)/25.4,bottom:ao(e.marginBottom,0)/25.4,left:ao(e.marginLeft,0)/25.4,right:ao(e.marginRight,0)/25.4}),i}async function Ch(e,t,n,{doc:r,frontMatter:i}){console.log(`output pdf:`,e);let a=Sh(t,i);try{let o=await n.printToPDF(a);o=await yh(o,{headings:Ja(r),frontMatter:i,displayMetadata:t?.displayMetadata,maxLevel:io(t?.maxLevel,6)}),await dh.writeFile(e,o),t.open&&u.default.remote.shell.openPath(e)}catch(e){console.error(e)}}async function wh(e,t){let n=await u.default.remote.dialog.showSaveDialog({title:`Export to PDF`,defaultPath:e+(t?`-`+Date.now():``)+`.pdf`,filters:[{name:`All Files`,extensions:[`*`]},{name:`PDF`,extensions:[`pdf`]}],properties:[`showOverwriteConfirmation`,`createDirectory`]});if(!n.canceled)return n.filePath}async function Th(e,t){let n=await u.default.remote.dialog.showOpenDialog({title:`Export to PDF`,defaultPath:e,properties:[`openDirectory`]});if(!n.canceled)return n.filePaths[0]}function Eh(e){return e.map(e=>({status:0,filename:e.file.name}))}function Dh(e,t){return e[t].status=1,[...e]}var Oh={A0:[841,1189],A1:[594,841],A2:[420,594],A3:[297,420],A4:[210,297],A5:[148,210],A6:[105,148],Legal:[216,356],Letter:[216,279],Tabloid:[279,432],Ledger:[432,279]},kh=class{constructor(e,t){this.config=e,this.onResize=t}calc(e){let{pageSize:t,pageWidth:n}=this.config,r=Oh?.[t]?.[0]??ao(n,210);return Math.floor($a(r)/e.offsetWidth*100)/100}startObserver(e){this.observer=new ResizeObserver(()=>{this.onResize?.()}),this.observer.observe(e)}stopObserver(){this.observer?.disconnect()}},Ah,jh=class{constructor(e){j(this,`value`,void 0),j(this,`next`,void 0),this.value=e}},Mh=new WeakMap,Nh=new WeakMap,Ph=new WeakMap;Ah=Symbol.iterator;var Fh=class{constructor(){vt(this,Mh,void 0),vt(this,Nh,void 0),vt(this,Ph,void 0),this.clear()}enqueue(e){var t;let n=new jh(e);V(Mh,this)?(V(Nh,this).next=n,B(Nh,this,n)):(B(Mh,this,n),B(Nh,this,n)),B(Ph,this,(t=V(Ph,this),t++,t))}dequeue(){var e;let t=V(Mh,this);if(t)return B(Mh,this,V(Mh,this).next),B(Ph,this,(e=V(Ph,this),e--,e)),t.value}peek(){if(V(Mh,this))return V(Mh,this).value}clear(){B(Mh,this,void 0),B(Nh,this,void 0),B(Ph,this,0)}get size(){return V(Ph,this)}*[Ah](){let e=V(Mh,this);for(;e;)yield e.value,e=e.next}*drain(){for(;V(Mh,this);)yield this.dequeue()}};function Ih(e){let t=!1;if(typeof e==`object`&&({concurrency:e,rejectOnClear:t=!1}=e),Lh(e),typeof t!=`boolean`)throw TypeError("Expected `rejectOnClear` to be a boolean");let n=new Fh,r=0,i=()=>{r0&&(r++,n.dequeue().run())},a=()=>{r--,i()},o=async(e,t,n)=>{let r=(async()=>e(...n))();t(r);try{await r}catch{}a()},s=(t,a,s,c)=>{let l={reject:s};new Promise(e=>{l.run=e,n.enqueue(l)}).then(o.bind(void 0,t,a,c)),rnew Promise((n,r)=>{s(e,n,r,t)});return Object.defineProperties(c,{activeCount:{get:()=>r},pendingCount:{get:()=>n.size},clearQueue:{value(){if(!t){n.clear();return}let e=AbortSignal.abort().reason;for(;n.size>0;)n.dequeue().reject(e)}},concurrency:{get:()=>e,set(t){Lh(t),e=t,queueMicrotask(()=>{for(;r0;)i()})}},map:{async value(e,t){let n=Array.from(e,(e,n)=>this(t,e,n));return Promise.all(n)}}}),c}function Lh(e){if(!((Number.isInteger(e)||e===1/0)&&e>0))throw TypeError("Expected `concurrency` to be a number from 1 and up")}var Rh=Wi(``),zh=Wi(`
`),Bh=Wi(`
Rendering...
`,1),Vh=Wi(`
`),Hh=Wi(`
`,1),Uh=Wi(``);function Wh(e,t){$e(t,!0);let n=require(`fs`).promises,r=tn(()=>t.plugin.settings),i=ar(!1),a=ar(fr([])),o=ar(fr([])),s=ar(.75),c=ar(void 0),u=ar(fr([])),d=new kh(t.config);function f(){H(c)&&sr(s,d.calc(H(c)),!0)}async function p(){await sleep(500),H(o).forEach(async(e,t)=>{let[n,r]=await e.executeJavaScript(`[document.body.offsetWidth, document.body.offsetHeight]`);H(a)[t]={...H(a)[t],printSize:`${n}×${r}px²\n${Qa(n)}×${Qa(r)}mm²`}})}async function m(){await f(),await p()}async function h(e,n,i){let a=Ih(io(H(r).concurrency)||5),o=Ye(t.config);console.log(`file list data:`,e,o);let s=e.map((e,t)=>a(async()=>{let n=await po({...e,config:o});return i?.(t),n})),c=[...n??[],...await Promise.all(s)];return t.modal.file instanceof l.TFile&&await t.modal.app.workspace.getLeaf().openFile(t.modal.file),t.modal.multiplePdf||(c=t.modal.mergeDoc(c)),c.map(({doc:e,...t})=>({...t,doc:vo(e,e.title)}))}async function g(e=!0){if(e){let{data:e,docs:n}=await t.modal.getAllFiles();sr(u,Eh(e),!0),sr(a,await h(e,n,e=>{sr(u,Dh(H(u),e),!0)}),!0)}sr(o,[],!0);let n=H(a).map(e=>new Promise(t=>{e.resolve=t}));await Promise.all(n),f(),await p()}function _(e){H(o).forEach((t,n)=>{t.executeJavaScript(` var _title = document.querySelector("h1.__title__"); if (_title) { _title.style.display = "${e?`block`:`none`}"; } `);let r=H(a)[n]?.doc?.querySelector(`h1.__title__`);r&&(r.style.display=e?`block`:`none`)})}async function v(){let e=t.modal.file?.basename??t.modal.file?.name;if(t.modal.multiplePdf){let n=await Th(e);n&&await Promise.all(H(o).map(async(e,i)=>{await Ch(`${n}/${H(a)[i].file.basename}.pdf`,{...H(r),...t.config},e,H(a)[i])}))}else{let n=await wh(e,H(r).isTimestamp);n&&await Ch(n,{...H(r),...t.config},H(o)[0],H(a)[0])}}function y(){H(o)?.[-1]?.openDevTools()}function b(e,r){H(o).push(e);let a=async()=>{if(sr(i,!0),oo().forEach(async t=>{await e.insertCSS(t)}),t.config.cssSnippet&&t.config.cssSnippet!=`0`)try{let r=await n.readFile(t.config.cssSnippet,{encoding:`utf8`}),i=r.replaceAll(/@media print\s*{([^}]+)}/g,`$1`);await e.insertCSS(i),await e.insertCSS(r)}catch(e){console.warn(e)}await e.executeJavaScript(Co(r.doc)),co().forEach(async t=>{await e.insertCSS(t)}),r.resolve&&r.resolve()};return e.addEventListener(`dom-ready`,a),{destroy(){e.removeEventListener(`dom-ready`,a)}}}Wa(()=>{if(H(c))return d.startObserver(H(c)),g(!0),()=>{d.stopObserver()}});var x={calcPageSize:f,calcWebviewSize:p,handleChangeSize:m,renderPreview:g,toggleTitle:_,handlePrintToPDF:v,handleOpenDevTools:y},S=Uh(),C=xr(S),w=xr(C),T=e=>{var t=Bh();da(Cr(Sr(t),2),17,()=>H(u),sa,(e,t)=>{var n=zh(),r=xr(n),i=e=>{var t=Rh();va(t,(e,t)=>Lo?.(e,t),()=>`check`),Gi(e,t)},a=e=>{var t=Rh();va(t,(e,t)=>Lo?.(e,t),()=>`loader`),Gi(e,t)};oa(r,e=>{H(t).status?e(i):e(a,-1)});var o=Cr(r);ze(n),Br(()=>Ki(o,` ${H(t).filename??``}`)),Gi(e,n)}),Gi(e,t)},E=tn(()=>H(u).length>0&&!H(u).every(e=>e.status));oa(w,e=>{H(E)&&e(T)}),ze(C);var D=Cr(C,2);return da(D,21,()=>H(a),sa,(e,n,r)=>{var i=Hh(),a=Sr(i),o=e=>{var t=Vh(),i=xr(t);ze(t),Br(()=>Ki(i,`${r+1}-${H(n).doc.title??``}`)),Gi(e,t)};oa(a,e=>{t.modal.multiplePdf&&e(o)});var c=Cr(a,2),l=xr(c);let u;var d=xr(l,!0);ze(l);var f=Cr(l,2);Aa(f,`nodeintegration`,!0),va(f,(e,t)=>b?.(e,t),()=>H(n)),ze(c),Br(()=>{u=Ea(l,``,u,{visibility:t.config.pageSize===`Custom`?`visible`:`hidden`}),Ki(d,H(n).printSize??``),Ea(f,`--modal-scale: ${H(s)??``};`)}),Gi(e,i)}),ze(D),Ha(D,e=>sr(c,e),()=>H(c)),ze(S),Gi(e,S),et(x)}var Gh=Wi(`
`),Kh={hash:`svelte-184lr04`,code:`.toggle-container.svelte-184lr04 {display:flex;gap:0px;text-align:right;justify-content:right;position:absolute;top:0;right:0;z-index:99;}button.svelte-184lr04 {height:24px;width:56px;padding:2px 4px;border:1px solid var(--background-modifier-border);background:var(--background-primary);color:var(--text-normal);cursor:pointer;border-radius:0px;display:flex;justify-content:center;line-height:14px;gap:2px;font-size:12px;}button.svelte-184lr04:hover {background:var(--background-modifier-hover);}button.active.svelte-184lr04 {background:var(--interactive-accent);color:var(--text-on-accent);border-color:var(--interactive-accent);}`};function qh(e,t){$e(t,!0),_a(e,Kh);let n=Ua(t,`initialMode`,3,`html`),r=ar(fr(Oi(()=>Ye(n()))));function i(e){H(r)!==e&&(sr(r,e,!0),t.onChange?.(H(r)))}var a=Gh(),o=xr(a);let s;var c=xr(o);va(c,(e,t)=>Lo?.(e,t),()=>`globe`),Ea(Cr(c,2),``,{},{"margin-left":`2px`}),ze(o);var l=Cr(o,2);let u;var d=xr(l);va(d,(e,t)=>Lo?.(e,t),()=>`notebook`),Ea(Cr(d,2),``,{},{"margin-left":`2px`}),ze(l),ze(a),Br(()=>{s=wa(o,1,`svelte-184lr04`,null,s,{active:H(r)===`html`}),u=wa(l,1,`svelte-184lr04`,null,u,{active:H(r)===`pdf`})}),Ii(`click`,o,()=>i(`html`)),Ii(`click`,l,()=>i(`pdf`)),Gi(e,a),et()}Li([`click`]);var Jh=class{constructor(){this.queue=Promise.resolve()}async run(e){let t=this.queue.then(()=>e());return this.queue=t.catch(()=>{}),t}},Yh=Wi(``),Xh=Wi(`
`),Zh=Wi(`
Rendering...
`,1),Qh=Wi(`
Rendering
`),$h=Wi(`
`),eg=Wi(` `,1),tg=Wi(`
`),ng=Wi(``),rg={hash:`svelte-1czt1i6`,code:`.rendering.svelte-1czt1i6 {position:absolute;display:flex;flex-direction:row;align-items:center;justify-content:center;}`};function ig(e,t){$e(t,!0),_a(e,rg);let n=require(`fs`).promises,r=tn(()=>t.plugin.settings),i=ar(!1),a=ar(!1),o=ar(fr([])),s=ar(.75),c=ar(void 0),p=ar(fr([])),m=fr([]),h=fr([]),g=fr({}),_=Ye(t.config),v=tn(()=>Sh({...H(r),...t.config})),y=new kh(t.config);function b(){H(c)&&sr(s,y.calc(H(c)),!0)}async function x(){await b()}async function S(e,n){let i=Ih(io(H(r).concurrency)||5);console.log(`file list data:`,e);let a=e.map((e,r)=>i(async()=>{let i=await mo({app:t.modal.app,file:e.file,config:t.config});return n?.(r),i})),o=[...await Promise.all(a)];return console.log(o,t.modal.multiplePdf),!t.modal.multiplePdf&&o.length>1&&(o=t.modal.mergeDocV2(o)),o.map(({doc:e,...t})=>({...t,doc:yo(e,e.title)}))}async function C(e=!0){if(e){let{data:e}=await t.modal.getAllFilesV2();sr(o,Eh(e),!0),sr(p,await S(e,e=>{sr(o,Dh(H(o),e),!0)}),!0)}b()}async function w(e){sr(p,H(p).map(({doc:t,...n})=>{let r=t?.querySelector(`h1.__title__`);return r&&(r.style.display=e?`block`:`none`),{doc:t,...n}}),!0),H(c)?.querySelectorAll(`h1.__title__`).forEach(t=>{t.style.display=e?`block`:`none`})}function T(e,t){let n=()=>{m[t]={width:e.offsetWidth,height:e.offsetHeight}};n();let r=new ResizeObserver(n);return r.observe(e),{destroy:()=>r.disconnect()}}Wa(()=>{if(H(c))return y.startObserver(H(c)),C(!0),()=>{y.stopObserver()}}),Ga(()=>{document.querySelectorAll(`.print`).forEach(e=>e.remove())}),Pr(()=>{console.log(`config:`,Ye(t.config))});let E=new Jh;async function D({el:e,outputFile:i,title:a,onlyPreview:o=!1}){console.log(`printOptions:`,H(v));let s={...H(v),filepath:i};if(await E.run(async()=>{document.title=a,await To(e,s)}),o)return;let c=await n.readFile(i);c=await yh(c,{headings:Ja(e),frontMatter:H(p)[0].frontMatter,displayMetadata:H(r)?.displayMetadata,maxLevel:io(H(r)?.maxLevel,6)}),await n.writeFile(i,c),t.config.open&&u.remote.shell.openPath(i)}async function O({docs:e,outfiles:t,cb:n,onlyPreview:r}){let i=document.title;e.forEach(({doc:e})=>{e.style.display=`none`});for(let[i,a]of t.entries()){let{doc:t,file:o}=e[i],s=o.basename;t.style.display=`block`,await sleep(200),await D({el:t,outputFile:a,title:s,onlyPreview:r}),t.style.display=`none`,n&&await n(a)}document.title=i}async function k(){let e=t.modal.file?.basename??t.modal.file?.name,n=[];if(t.modal.multiplePdf){let t=await Th(e);if(!t)return!1;n.push(...H(p).map(e=>`${t}/${e.file.basename}.pdf`))}else{let t=await wh(e,H(r).isTimestamp);if(!t)return!1;n.push(t)}return await O({docs:H(p),outfiles:n}),!0}async function ee(){sr(a,!0);let e=await(0,l.loadPdfJs)(),r=f.tmpdir(),i=0;async function o(t){let r=await n.readFile(t),a=await e.getDocument({data:r}).promise;console.log(`loading tmp file`,a.numPages);for(let e=1;e<=a.numPages;e++){let t=await a.getPage(e),n=document.createElement(`canvas`),r=n.getContext(`2d`),o=t.getViewport({scale:5});n.height=o.height,n.width=o.width,await t.render({canvasContext:r,viewport:o}).promise,id.join(r,`obsidian-temp-${e.path.replace(/[/\\]/g,`_`)}-${Date.now()}.pdf`));console.log(`tempFiles`,e),await O({docs:H(p),outfiles:e,cb:o,onlyPreview:!0}),g[s]=e}h.length=i,sr(a,!1),console.log(`loaded tmp canvas pages:`,i)}function A(){document.win.electron.remote.getCurrentWebContents().openDevTools()}async function j(e){e===`pdf`?(sr(i,!0),await ee(),sr(a,!1)):sr(i,!1)}Pr(()=>{let e=Ye(t.config),n=[];console.log(`config changed:`,_,e);for(let t of[`pageSize`,`scale`,`landscape`,`marginBottom`,`marginLeft`,`marginRight`,`marginTop`,`marginType`,`displayHeader`,`displayFooter`,`showTitle`]){let r=t;e?.[r]!=_?.[r]&&n.push({key:r,oldValue:_[r],newValue:e[r]})}if(n.length==0||(_=e,!H(i)))return;sr(a,!0);let r=setTimeout(async()=>{await ee(),sr(a,!1)},300);return()=>clearTimeout(r)});var te={calcPageSize:b,handleChangeSize:x,renderPreview:C,toggleTitle:w,exportToPDF:D,printDocs:O,handlePrintToPDF:k,handleOpenDevTools:A},ne=ng(),re=xr(ne),ie=xr(re),ae=e=>{var t=Zh();da(Cr(Sr(t),2),17,()=>H(o),sa,(e,t)=>{var n=Xh(),r=xr(n),i=e=>{var t=Yh();va(t,(e,t)=>Lo?.(e,t),()=>`check`),Gi(e,t)},a=e=>{var t=Yh();va(t,(e,t)=>Lo?.(e,t),()=>`loader`),Gi(e,t)};oa(r,e=>{H(t).status?e(i):e(a,-1)});var o=Cr(r);ze(n),Br(()=>Ki(o,` ${H(t).filename??``}`)),Gi(e,n)}),Gi(e,t)},oe=tn(()=>H(o).length>0&&!H(o).every(e=>e.status));oa(ie,e=>{H(oe)&&e(ae)}),ze(re);var se=Cr(re,2),ce=e=>{var t=Qh();va(xr(t),(e,t)=>Lo?.(e,t),()=>`loader`),Be(2),ze(t),Gi(e,t)};oa(se,e=>{H(a)&&e(ce)});var le=Cr(se,2);qh(le,{initialMode:`html`,onChange:j});var ue=Cr(le,2),M=xr(ue),N=xr(M);let de;da(N,21,()=>H(p),sa,(e,n,r)=>{var i=eg(),a=Sr(i);let o;var s=xr(a,!0);ze(a);var c=Cr(a,2),l=e=>{var t=$h(),r=xr(t,!0);ze(t),Br(()=>Ki(r,H(n).file.name)),Gi(e,t)};oa(c,e=>{t.modal.multiplePdf&&e(l)});var u=Cr(c,2);va(u,(e,t)=>Ro?.(e,t),()=>H(n).doc),va(u,(e,t)=>T?.(e,t),()=>r),Br(e=>{o=Ea(a,``,o,{visibility:t.config.pageSize===`Custom`?`visible`:`hidden`}),Ki(s,e)},[()=>m[r]?`${m[r].width}×${m[r].height}px\n${Qa(m[r].width)}×${Qa(m[r].height)}mm`:``]),Gi(e,i)}),ze(N);var fe=Cr(N,2);let pe;return da(fe,20,()=>h,e=>e,(e,t)=>{var n=tg();va(n,(e,t)=>zo?.(e,t),()=>t),Gi(e,n)}),ze(fe),ze(M),ze(ue),Ha(ue,e=>sr(c,e),()=>H(c)),ze(ne),Br(()=>{de=Ea(N,`--modal-scale: ${H(s)??``};`,de,{display:H(i)?`none`:`block`}),pe=Ea(fe,``,pe,{display:H(i)?`block`:`none`})}),Gi(e,ne),et(te)}var ag=Wi(`
`);function og(e,t){$e(t,!0);let n=Ua(t,`plugin`,7),r=ar(fr(Oi(()=>Ye(t.modal.defaultConfig)))),i=ar(null);async function a(){await H(i)?.renderPreview(!1)}async function o(){await H(i)?.renderPreview(!0)}async function s(){await H(i)?.handleOpenDevTools()}async function c(){if(n().settings.prevConfig=H(r),await n().saveSettings(),H(r).pageSize==`Custom`&&(!ro(H(r).pageWidth??``)||!ro(H(r).pageHeight??``))){alert(`When the page size is Custom, the Width/Height cannot be empty.`);return}await H(i)?.handlePrintToPDF(),t.modal.close()}var l={onCssSnippetChange:a,refreshPreview:o,handleOpenDevTools:s,handleExport:c},u=ag(),d=xr(u),f=e=>{Ha(Wh(e,{get modal(){return t.modal},get plugin(){return n()},get config(){return H(r)}}),e=>sr(i,e,!0),()=>H(i))},p=e=>{Ha(ig(e,{get modal(){return t.modal},get plugin(){return n()},get config(){return H(r)}}),e=>sr(i,e,!0),()=>H(i))};return oa(d,e=>{n().settings?.version==`1`?e(f):e(p,-1)}),Uo(Cr(d,2),{get modal(){return t.modal},get plugin(){return n()},get pdfPreview(){return H(i)},handleExport:c,refreshPreview:o,get config(){return H(r)},set config(e){sr(r,e,!0)}}),ze(u),Gi(e,u),et(l)}require(`fs`).promises;var sg=class extends l.Modal{constructor(e,t,n){super(e.app),this.plugin=e,this.file=t,this.i18n=m.current,this.multiplePdf=n,this.defaultConfig={pageSize:`A4`,marginType:`1`,showTitle:e.settings.showTitle??!0,open:!0,scale:100,landscape:!1,marginTop:`10`,marginBottom:`10`,marginLeft:`10`,marginRight:`10`,displayHeader:e.settings.displayHeader??!0,displayFooter:e.settings.displayHeader??!0,cssSnippet:`0`,...e.settings.prevConfig??{}}}onOpen(){this.contentEl.empty(),this.containerEl.style.setProperty(`--dialog-width`,`60vw`),this.titleEl.setText(`Export to PDF`),this.component=qi(og,{target:this.contentEl,props:{modal:this,plugin:this.plugin}})}onClose(){this.component&&(Zi(this.component),this.component=void 0),this.contentEl.empty(),document.querySelectorAll(`.print`).forEach(e=>e.remove())}getFileCache(e){return this.app.metadataCache.getFileCache(e)}async getAllFiles(){let e=this.plugin.app,t=[],n=[];if(this.file instanceof l.TFolder){let n=eo(this.file);for(let r of n)t.push({app:e,file:r})}else{let{doc:r,frontMatter:i,file:a}=await po({app:e,file:this.file,config:this.defaultConfig});if(n.push({doc:r,frontMatter:i,file:a}),i.toc){let n=this.parseToc(r);for(let r of n)t.push({app:e,file:r.file,extra:r})}}return{data:t,docs:n}}async getAllFilesV2(){let e=[];if(this.file instanceof l.TFolder){let t=eo(this.file);for(let n of t)e.push({file:n})}else{let{frontmatter:t,links:n}=this.getFileCache(this.file)??{};if(e.push({file:this.file,toc:t?.toc}),t?.toc&&n)for(let t of n){let n=this.app.metadataCache.getFirstLinkpathDest(t.link,this.file.path);n instanceof l.TFile&&e.push({file:n})}}return{data:e,multiplePdf:this.multiplePdf}}parseToc(e){return this.getFileCache(this.file)?.links?.map(({link:t,displayText:n})=>{let r=crypto.randomUUID(),i=e.querySelector(`a[data-href="${t}"]`);return i&&(i.href=`#${r}`),{title:n,file:this.app.metadataCache.getFirstLinkpathDest(t,this.file.path),id:r}}).filter(e=>e.file instanceof l.TFile)??[]}mergeDoc(e){let{doc:t,frontMatter:n,file:r}=e[0],i=[];for(let{doc:n}of e){let e=n.querySelector(`.markdown-preview-view`);if(e){let n=t.createElement(`section`);Array.from(e.children).forEach(e=>{n.appendChild(t.importNode(e,!0))}),i.push(n)}}let a=t.querySelector(`.markdown-preview-view`);return a&&(a.innerHTML=``),i.forEach(e=>{a?.appendChild(e)}),[{doc:t,frontMatter:n,file:r,node:a}]}mergeDocV2(e){let t=document.body.createDiv(`print`);for(let{doc:n}of e){let e=n.querySelector(`.markdown-preview-view`);e&&t.appendChild(e),document.body.removeChild(n)}return[{...e[0],doc:t}]}cssSnippets(){let{snippets:e,enabledSnippets:t}=this.app?.customCss??{},n=this.app.vault.adapter.basePath;return Object.fromEntries(e?.filter(e=>!t.has(e)).map(e=>[d.default.join(n,`.obsidian/snippets`,e+`.css`),e]))}};function cg(e,t){for(let n in t)e.setAttribute(n,t[n])}var lg=(e,t=175)=>{let n=e.createEl(`a`,{href:`https://www.buymeacoffee.com/l1xnan`}).createEl(`img`);n.src=`https://img.buymeacoffee.com/button-api/?text=Buy me a coffee&emoji=&slug=nathangeorge&button_colour=6a8696&font_colour=ffffff&font_family=Poppins&outline_colour=000000&coffee_colour=FFDD00`,n.alt=`Buy me a coffee`,n.width=t},ug=class extends l.PluginSettingTab{constructor(e,t){super(e,t),this.plugin=t,this.i18n=m.current}display(){let{containerEl:e}=this;e.empty();let t=new DocumentFragment;t.createDiv({text:`Support the continued development of this plugin.`}),new l.Setting(e).setDesc(t),lg(e),new l.Setting(e).setName(this.i18n.settings.version).addDropdown(e=>{e.addOptions(Object.fromEntries([`1`,`2`].map(e=>[e,`v${e}`]))).setValue(this.plugin.settings.version).onChange(async e=>{this.plugin.settings.version=e,this.plugin.saveSettings(),s(e)})}),new l.Setting(e).setName(this.i18n.settings.showTitle).addToggle(e=>e.setTooltip(this.i18n.settings.showTitle).setValue(this.plugin.settings.showTitle).onChange(async e=>{this.plugin.settings.showTitle=e,this.plugin.saveSettings()})),new l.Setting(e).setName(this.i18n.settings.displayHeader).addToggle(e=>e.setTooltip(`Display header`).setValue(this.plugin.settings.displayHeader).onChange(async e=>{this.plugin.settings.displayHeader=e,this.plugin.saveSettings()})),new l.Setting(e).setName(this.i18n.settings.displayFooter).addToggle(e=>e.setTooltip(`Display footer`).setValue(this.plugin.settings.displayFooter).onChange(async e=>{this.plugin.settings.displayFooter=e,this.plugin.saveSettings()})),new l.Setting(e).setName(this.i18n.settings.printBackground).setDesc(`Whether to print background graphics`).addToggle(e=>e.setValue(this.plugin.settings.printBackground).onChange(async e=>{this.plugin.settings.printBackground=e,this.plugin.saveSettings()})),new l.Setting(e).setName(`Generate tagged PDF`).setDesc(`Whether or not to generate a tagged (accessible) PDF. Defaults to false. As this property is experimental, the generated PDF may not adhere fully to PDF/UA and WCAG standards.`).addToggle(e=>e.setValue(this.plugin.settings.generateTaggedPDF).onChange(async e=>{this.plugin.settings.generateTaggedPDF=e,this.plugin.saveSettings()})),new l.Setting(e).setName(this.i18n.settings.maxLevel).addDropdown(e=>{e.addOptions(Object.fromEntries([`1`,`2`,`3`,`4`,`5`,`6`].map(e=>[e,`h${e}`]))).setValue(this.plugin.settings.maxLevel).onChange(async e=>{this.plugin.settings.maxLevel=e,this.plugin.saveSettings()})}),new l.Setting(e).setName(this.i18n.settings.displayMetadata).setDesc(`Add frontMatter(title, author, keywords, subject creator, etc) to pdf metadata`).addToggle(e=>e.setValue(this.plugin.settings.displayMetadata).onChange(async e=>{this.plugin.settings.displayMetadata=e,this.plugin.saveSettings()})),new l.Setting(e).setName(`Advanced`).setHeading();let n=new l.Setting(e);n.settingEl.setAttribute(`style`,`display: grid; grid-template-columns: 1fr;`),n.setName(this.i18n.settings.headerTemplate).setDesc(`HTML template for the print header. Should be valid HTML markup with following classes used to inject printing values into them: date (formatted print date), title (document title), url (document location), pageNumber (current page number) and totalPages (total pages in the document). For example, would generate span containing the title.`);let r=new l.TextAreaComponent(n.controlEl);cg(r.inputEl,{style:`margin-top: 12px; width: 100%; height: 6vh;`}),r.setValue(this.plugin.settings.headerTemplate).onChange(async e=>{this.plugin.settings.headerTemplate=e,this.plugin.saveSettings()});let i=new l.Setting(e);i.settingEl.setAttribute(`style`,`display: grid; grid-template-columns: 1fr;`),i.setName(this.i18n.settings.footerTemplate).setDesc(`HTML template for the print footer. Should use the same format as the headerTemplate.`);let a=new l.TextAreaComponent(i.controlEl);cg(a.inputEl,{style:`margin-top: 12px; width: 100%; height: 6vh;`}),a.setValue(this.plugin.settings.footerTemplate).onChange(async e=>{this.plugin.settings.footerTemplate=e,this.plugin.saveSettings()}),new l.Setting(e).setName(this.i18n.settings.isTimestamp).setDesc(`Add timestamp to output file name`).addToggle(e=>{e.setValue(this.plugin.settings.isTimestamp).onChange(async e=>{this.plugin.settings.isTimestamp=e,await this.plugin.saveSettings()})});let o=new l.Setting(e).setName(this.i18n.settings.enabledCss).setDesc(`Select the css snippet that are not enabled`).addToggle(e=>{e.setValue(this.plugin.settings.enabledCss).onChange(async e=>{this.plugin.settings.enabledCss=e,await this.plugin.saveSettings()})}),s=e=>{o.settingEl.hidden=e!==`1`};s(this.plugin.settings.version),new l.Setting(e).setName(this.i18n.settings.concurrency).setDesc(`Limit the number of concurrent renders`).addText(e=>{let t=this.plugin.settings?.concurrency;e.setValue(t?.length>0?t:`5`).onChange(async e=>{this.plugin.settings.concurrency=e,await this.plugin.saveSettings()})}),new l.Setting(e).setName(`Debug`).setHeading(),new l.Setting(e).setName(this.i18n.settings.debugMode).setDesc(`This is useful for troubleshooting.`).addToggle(e=>{e.setValue(this.plugin.settings.debug).onChange(async e=>{this.plugin.settings.debug=e,await this.plugin.saveSettings()})})}},dg=require(`fs`).promises,fg=process.env.NODE_ENV===`development`,pg={showTitle:!0,maxLevel:`6`,displayHeader:!0,displayFooter:!0,headerTemplate:`
`,footerTemplate:`
/
`,printBackground:!1,generateTaggedPDF:!1,displayMetadata:!1,debug:!1,isTimestamp:!1,enabledCss:!1,concurrency:`5`,version:`2`},mg=class extends l.Plugin{constructor(e,t){super(e,t),this.i18n=m.current}async onload(){await this.loadSettings(),this.registerCommand(),this.registerSetting(),this.registerEvents()}registerCommand(){this.addCommand({id:`export-current-file-to-pdf`,name:this.i18n.exportCurrentFile,checkCallback:e=>{let t=this.app.workspace.getActiveViewOfType(l.MarkdownView)?.file;return t?(e||new sg(this,t).open(),!0):!1}})}registerSetting(){this.addSettingTab(new ug(this.app,this))}registerEvents(){this.registerEvent(this.app.workspace.on(`file-menu`,(e,t)=>{let n=t instanceof l.TFolder?`Export folder to PDF`:`Better Export PDF`;fg&&(n=`${n} (dev)`),e.addItem(e=>{e.setTitle(n).setIcon(`download`).setSection(`action`).onClick(async()=>{new sg(this,t).open()})})})),this.registerEvent(this.app.workspace.on(`file-menu`,(e,t)=>{if(t instanceof l.TFolder){let n=`Export to PDF...`;fg&&(n=`${n} (dev)`),e.addItem(e=>{e.setTitle(n).setIcon(`lucide-folder-down`).setSection(`action`);let r=e.setSubmenu();r.addItem(e=>e.setTitle(`Export each file to PDF`).setIcon(`lucide-file-stack`).onClick(async()=>{new sg(this,t,!0).open()})),r.addItem(e=>e.setTitle(`Generate TOC.md file`).setIcon(`lucide-file-text`).onClick(async()=>{await this.generateToc(t)}))})}}))}async generateToc(e){let t=this.app.vault.adapter.basePath,n=d.default.join(t,e.path,`_TOC_.md`),r=`---\ntoc: true\ntitle: ${e.name}\n---\n`;if(await dg.writeFile(n,r),e instanceof l.TFolder){let t=eo(e);for(let e of t)e.name!=`_TOC_.md`&&await dg.appendFile(n,`[[${e.path}]]\n`)}}onunload(){}async loadSettings(){this.settings=Object.assign({},pg,await this.loadData())}async saveSettings(){await this.saveData(this.settings)}changeConfig(){let e=this.app.vault?.getConfig(`theme`)===`obsidian`;e&&(document.body.addClass(`theme-light`),document.body.removeClass(`theme-dark`)),document.body.removeClass(`theme-dark`);let t=document.body.createDiv(`print`);t.addEventListener(`click`,function(){t.detach(),e&&(document.body.removeClass(`theme-light`),document.body.addClass(`theme-dark`))});let n=document.body.createDiv(`print`).createDiv(`markdown-preview-view markdown-rendered`);n.toggleClass(`rtl`,this.app.vault.getConfig(`rightToLeft`)),n.toggleClass(`show-frontmatter`,this.app.vault.getConfig(`showFrontmatter`)),n.createEl(`h1`,{text:`xxxxx`})}};module.exports=mg; /* nosourcemap */