/* THIS IS A GENERATED/BUNDLED FILE BY ESBUILD if you want to view the source, please visit the github repository of this plugin */ var iy=Object.create;var Hc=Object.defineProperty;var ny=Object.getOwnPropertyDescriptor;var ry=Object.getOwnPropertyNames;var oy=Object.getPrototypeOf,sy=Object.prototype.hasOwnProperty;var ye=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports),Yh=(n,t)=>{for(var e in t)Hc(n,e,{get:t[e],enumerable:!0})},yg=(n,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ry(t))!sy.call(n,r)&&r!==e&&Hc(n,r,{get:()=>t[r],enumerable:!(i=ny(t,r))||i.enumerable});return n};var Un=(n,t,e)=>(e=n!=null?iy(oy(n)):{},yg(t||!n||!n.__esModule?Hc(e,"default",{value:n,enumerable:!0}):e,n)),ay=n=>yg(Hc({},"__esModule",{value:!0}),n);var wg=(n,t,e)=>{if(!t.has(n))throw TypeError("Cannot "+e)};var pi=(n,t,e)=>(wg(n,t,"read from private field"),e?e.call(n):t.get(n)),ba=(n,t,e)=>{if(t.has(n))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(n):t.set(n,e)},xa=(n,t,e,i)=>(wg(n,t,"write to private field"),i?i.call(n,e):t.set(n,e),e);var rn=ye(xt=>{"use strict";var my=typeof Uint8Array!="undefined"&&typeof Uint16Array!="undefined"&&typeof Int32Array!="undefined";function by(n,t){return Object.prototype.hasOwnProperty.call(n,t)}xt.assign=function(n){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var e=t.shift();if(e){if(typeof e!="object")throw new TypeError(e+"must be non-object");for(var i in e)by(e,i)&&(n[i]=e[i])}}return n};xt.shrinkBuf=function(n,t){return n.length===t?n:n.subarray?n.subarray(0,t):(n.length=t,n)};var xy={arraySet:function(n,t,e,i,r){if(t.subarray&&n.subarray){n.set(t.subarray(e,e+i),r);return}for(var o=0;o{"use strict";var wy=rn(),vy=4,Cg=0,Tg=1,Fy=2;function Jo(n){for(var t=n.length;--t>=0;)n[t]=0}var Py=0,Mg=1,ky=2,Dy=3,Sy=258,vu=29,Ia=256,Ca=Ia+1+vu,Yo=30,Fu=19,Ng=2*Ca+1,Or=15,gu=16,Cy=7,Pu=256,Rg=16,Vg=17,Bg=18,yu=[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],Kc=[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],Ty=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],Hg=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],Ey=512,on=new Array((Ca+2)*2);Jo(on);var Sa=new Array(Yo*2);Jo(Sa);var Ta=new Array(Ey);Jo(Ta);var Ea=new Array(Sy-Dy+1);Jo(Ea);var ku=new Array(vu);Jo(ku);var Gc=new Array(Yo);Jo(Gc);function mu(n,t,e,i,r){this.static_tree=n,this.extra_bits=t,this.extra_base=e,this.elems=i,this.max_length=r,this.has_stree=n&&n.length}var Ug,zg,qg;function bu(n,t){this.dyn_tree=n,this.max_code=0,this.stat_desc=t}function Wg(n){return n<256?Ta[n]:Ta[256+(n>>>7)]}function Aa(n,t){n.pending_buf[n.pending++]=t&255,n.pending_buf[n.pending++]=t>>>8&255}function St(n,t,e){n.bi_valid>gu-e?(n.bi_buf|=t<>gu-n.bi_valid,n.bi_valid+=e-gu):(n.bi_buf|=t<>>=1,e<<=1;while(--t>0);return e>>>1}function Ay(n){n.bi_valid===16?(Aa(n,n.bi_buf),n.bi_buf=0,n.bi_valid=0):n.bi_valid>=8&&(n.pending_buf[n.pending++]=n.bi_buf&255,n.bi_buf>>=8,n.bi_valid-=8)}function Iy(n,t){var e=t.dyn_tree,i=t.max_code,r=t.stat_desc.static_tree,o=t.stat_desc.has_stree,s=t.stat_desc.extra_bits,a=t.stat_desc.extra_base,c=t.stat_desc.max_length,l,d,h,u,f,p,g=0;for(u=0;u<=Or;u++)n.bl_count[u]=0;for(e[n.heap[n.heap_max]*2+1]=0,l=n.heap_max+1;lc&&(u=c,g++),e[d*2+1]=u,!(d>i)&&(n.bl_count[u]++,f=0,d>=a&&(f=s[d-a]),p=e[d*2],n.opt_len+=p*(u+f),o&&(n.static_len+=p*(r[d*2+1]+f)));if(g!==0){do{for(u=c-1;n.bl_count[u]===0;)u--;n.bl_count[u]--,n.bl_count[u+1]+=2,n.bl_count[c]--,g-=2}while(g>0);for(u=c;u!==0;u--)for(d=n.bl_count[u];d!==0;)h=n.heap[--l],!(h>i)&&(e[h*2+1]!==u&&(n.opt_len+=(u-e[h*2+1])*e[h*2],e[h*2+1]=u),d--)}}function Kg(n,t,e){var i=new Array(Or+1),r=0,o,s;for(o=1;o<=Or;o++)i[o]=r=r+e[o-1]<<1;for(s=0;s<=t;s++){var a=n[s*2+1];a!==0&&(n[s*2]=jg(i[a]++,a))}}function Ly(){var n,t,e,i,r,o=new Array(Or+1);for(e=0,i=0;i>=7;i8?Aa(n,n.bi_buf):n.bi_valid>0&&(n.pending_buf[n.pending++]=n.bi_buf),n.bi_buf=0,n.bi_valid=0}function Oy(n,t,e,i){Xg(n),i&&(Aa(n,e),Aa(n,~e)),wy.arraySet(n.pending_buf,n.window,t,e,n.pending),n.pending+=e}function Eg(n,t,e,i){var r=t*2,o=e*2;return n[r]>1;s>=1;s--)xu(n,e,s);l=o;do s=n.heap[1],n.heap[1]=n.heap[n.heap_len--],xu(n,e,1),a=n.heap[1],n.heap[--n.heap_max]=s,n.heap[--n.heap_max]=a,e[l*2]=e[s*2]+e[a*2],n.depth[l]=(n.depth[s]>=n.depth[a]?n.depth[s]:n.depth[a])+1,e[s*2+1]=e[a*2+1]=l,n.heap[1]=l++,xu(n,e,1);while(n.heap_len>=2);n.heap[--n.heap_max]=n.heap[1],Iy(n,t),Kg(e,c,n.bl_count)}function Ig(n,t,e){var i,r=-1,o,s=t[0*2+1],a=0,c=7,l=4;for(s===0&&(c=138,l=3),t[(e+1)*2+1]=65535,i=0;i<=e;i++)o=s,s=t[(i+1)*2+1],!(++a=3&&n.bl_tree[Hg[t]*2+1]===0;t--);return n.opt_len+=3*(t+1)+5+5+4,t}function Ny(n,t,e,i){var r;for(St(n,t-257,5),St(n,e-1,5),St(n,i-4,4),r=0;r>>=1)if(t&1&&n.dyn_ltree[e*2]!==0)return Cg;if(n.dyn_ltree[9*2]!==0||n.dyn_ltree[10*2]!==0||n.dyn_ltree[13*2]!==0)return Tg;for(e=32;e0?(n.strm.data_type===Fy&&(n.strm.data_type=Ry(n)),wu(n,n.l_desc),wu(n,n.d_desc),s=My(n),r=n.opt_len+3+7>>>3,o=n.static_len+3+7>>>3,o<=r&&(r=o)):r=o=e+5,e+4<=r&&t!==-1?Zg(n,t,e,i):n.strategy===vy||o===r?(St(n,(Mg<<1)+(i?1:0),3),Ag(n,on,Sa)):(St(n,(ky<<1)+(i?1:0),3),Ny(n,n.l_desc.max_code+1,n.d_desc.max_code+1,s+1),Ag(n,n.dyn_ltree,n.dyn_dtree)),Gg(n),i&&Xg(n)}function Uy(n,t,e){return n.pending_buf[n.d_buf+n.last_lit*2]=t>>>8&255,n.pending_buf[n.d_buf+n.last_lit*2+1]=t&255,n.pending_buf[n.l_buf+n.last_lit]=e&255,n.last_lit++,t===0?n.dyn_ltree[e*2]++:(n.matches++,t--,n.dyn_ltree[(Ea[e]+Ia+1)*2]++,n.dyn_dtree[Wg(t)*2]++),n.last_lit===n.lit_bufsize-1}Qo._tr_init=Vy;Qo._tr_stored_block=Zg;Qo._tr_flush_block=Hy;Qo._tr_tally=Uy;Qo._tr_align=By});var Du=ye((tk,Jg)=>{"use strict";function zy(n,t,e,i){for(var r=n&65535|0,o=n>>>16&65535|0,s=0;e!==0;){s=e>2e3?2e3:e,e-=s;do r=r+t[i++]|0,o=o+r|0;while(--s);r%=65521,o%=65521}return r|o<<16|0}Jg.exports=zy});var Su=ye((ik,Qg)=>{"use strict";function qy(){for(var n,t=[],e=0;e<256;e++){n=e;for(var i=0;i<8;i++)n=n&1?3988292384^n>>>1:n>>>1;t[e]=n}return t}var Wy=qy();function jy(n,t,e,i){var r=Wy,o=i+e;n^=-1;for(var s=i;s>>8^r[(n^t[s])&255];return n^-1}Qg.exports=jy});var Xc=ye((nk,_g)=>{"use strict";_g.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"}});var am=ye(Ni=>{"use strict";var yt=rn(),jt=Yg(),im=Du(),Gn=Su(),Ky=Xc(),Vr=0,Gy=1,Xy=3,Qn=4,$g=5,Mi=0,em=1,Kt=-2,Zy=-3,Cu=-5,Yy=-1,Jy=1,Zc=2,Qy=3,_y=4,$y=0,ew=2,_c=8,tw=9,iw=15,nw=8,rw=29,ow=256,Eu=ow+1+rw,sw=30,aw=19,lw=2*Eu+1,cw=15,ae=3,Yn=258,mi=Yn+ae+1,dw=32,$c=42,Au=69,Yc=73,Jc=91,Qc=103,Mr=113,Oa=666,Je=1,Ma=2,Nr=3,es=4,hw=3;function Jn(n,t){return n.msg=Ky[t],t}function tm(n){return(n<<1)-(n>4?9:0)}function Zn(n){for(var t=n.length;--t>=0;)n[t]=0}function Xn(n){var t=n.state,e=t.pending;e>n.avail_out&&(e=n.avail_out),e!==0&&(yt.arraySet(n.output,t.pending_buf,t.pending_out,e,n.next_out),n.next_out+=e,t.pending_out+=e,n.total_out+=e,n.avail_out-=e,t.pending-=e,t.pending===0&&(t.pending_out=0))}function at(n,t){jt._tr_flush_block(n,n.block_start>=0?n.block_start:-1,n.strstart-n.block_start,t),n.block_start=n.strstart,Xn(n.strm)}function ue(n,t){n.pending_buf[n.pending++]=t}function La(n,t){n.pending_buf[n.pending++]=t>>>8&255,n.pending_buf[n.pending++]=t&255}function uw(n,t,e,i){var r=n.avail_in;return r>i&&(r=i),r===0?0:(n.avail_in-=r,yt.arraySet(t,n.input,n.next_in,r,e),n.state.wrap===1?n.adler=im(n.adler,t,r,e):n.state.wrap===2&&(n.adler=Gn(n.adler,t,r,e)),n.next_in+=r,n.total_in+=r,r)}function nm(n,t){var e=n.max_chain_length,i=n.strstart,r,o,s=n.prev_length,a=n.nice_match,c=n.strstart>n.w_size-mi?n.strstart-(n.w_size-mi):0,l=n.window,d=n.w_mask,h=n.prev,u=n.strstart+Yn,f=l[i+s-1],p=l[i+s];n.prev_length>=n.good_match&&(e>>=2),a>n.lookahead&&(a=n.lookahead);do if(r=t,!(l[r+s]!==p||l[r+s-1]!==f||l[r]!==l[i]||l[++r]!==l[i+1])){i+=2,r++;do;while(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]===l[++r]&&is){if(n.match_start=t,s=o,o>=a)break;f=l[i+s-1],p=l[i+s]}}while((t=h[t&d])>c&&--e!==0);return s<=n.lookahead?s:n.lookahead}function Rr(n){var t=n.w_size,e,i,r,o,s;do{if(o=n.window_size-n.lookahead-n.strstart,n.strstart>=t+(t-mi)){yt.arraySet(n.window,n.window,t,t,0),n.match_start-=t,n.strstart-=t,n.block_start-=t,i=n.hash_size,e=i;do r=n.head[--e],n.head[e]=r>=t?r-t:0;while(--i);i=t,e=i;do r=n.prev[--e],n.prev[e]=r>=t?r-t:0;while(--i);o+=t}if(n.strm.avail_in===0)break;if(i=uw(n.strm,n.window,n.strstart+n.lookahead,o),n.lookahead+=i,n.lookahead+n.insert>=ae)for(s=n.strstart-n.insert,n.ins_h=n.window[s],n.ins_h=(n.ins_h<n.pending_buf_size-5&&(e=n.pending_buf_size-5);;){if(n.lookahead<=1){if(Rr(n),n.lookahead===0&&t===Vr)return Je;if(n.lookahead===0)break}n.strstart+=n.lookahead,n.lookahead=0;var i=n.block_start+e;if((n.strstart===0||n.strstart>=i)&&(n.lookahead=n.strstart-i,n.strstart=i,at(n,!1),n.strm.avail_out===0)||n.strstart-n.block_start>=n.w_size-mi&&(at(n,!1),n.strm.avail_out===0))return Je}return n.insert=0,t===Qn?(at(n,!0),n.strm.avail_out===0?Nr:es):(n.strstart>n.block_start&&(at(n,!1),n.strm.avail_out===0),Je)}function Tu(n,t){for(var e,i;;){if(n.lookahead=ae&&(n.ins_h=(n.ins_h<=ae)if(i=jt._tr_tally(n,n.strstart-n.match_start,n.match_length-ae),n.lookahead-=n.match_length,n.match_length<=n.max_lazy_match&&n.lookahead>=ae){n.match_length--;do n.strstart++,n.ins_h=(n.ins_h<=ae&&(n.ins_h=(n.ins_h<4096)&&(n.match_length=ae-1)),n.prev_length>=ae&&n.match_length<=n.prev_length){r=n.strstart+n.lookahead-ae,i=jt._tr_tally(n,n.strstart-1-n.prev_match,n.prev_length-ae),n.lookahead-=n.prev_length-1,n.prev_length-=2;do++n.strstart<=r&&(n.ins_h=(n.ins_h<=ae&&n.strstart>0&&(r=n.strstart-1,i=s[r],i===s[++r]&&i===s[++r]&&i===s[++r])){o=n.strstart+Yn;do;while(i===s[++r]&&i===s[++r]&&i===s[++r]&&i===s[++r]&&i===s[++r]&&i===s[++r]&&i===s[++r]&&i===s[++r]&&rn.lookahead&&(n.match_length=n.lookahead)}if(n.match_length>=ae?(e=jt._tr_tally(n,1,n.match_length-ae),n.lookahead-=n.match_length,n.strstart+=n.match_length,n.match_length=0):(e=jt._tr_tally(n,0,n.window[n.strstart]),n.lookahead--,n.strstart++),e&&(at(n,!1),n.strm.avail_out===0))return Je}return n.insert=0,t===Qn?(at(n,!0),n.strm.avail_out===0?Nr:es):n.last_lit&&(at(n,!1),n.strm.avail_out===0)?Je:Ma}function gw(n,t){for(var e;;){if(n.lookahead===0&&(Rr(n),n.lookahead===0)){if(t===Vr)return Je;break}if(n.match_length=0,e=jt._tr_tally(n,0,n.window[n.strstart]),n.lookahead--,n.strstart++,e&&(at(n,!1),n.strm.avail_out===0))return Je}return n.insert=0,t===Qn?(at(n,!0),n.strm.avail_out===0?Nr:es):n.last_lit&&(at(n,!1),n.strm.avail_out===0)?Je:Ma}function Oi(n,t,e,i,r){this.good_length=n,this.max_lazy=t,this.nice_length=e,this.max_chain=i,this.func=r}var $o;$o=[new Oi(0,0,0,0,fw),new Oi(4,4,8,4,Tu),new Oi(4,5,16,8,Tu),new Oi(4,6,32,32,Tu),new Oi(4,4,16,16,_o),new Oi(8,16,32,32,_o),new Oi(8,16,128,128,_o),new Oi(8,32,128,256,_o),new Oi(32,128,258,1024,_o),new Oi(32,258,258,4096,_o)];function mw(n){n.window_size=2*n.w_size,Zn(n.head),n.max_lazy_match=$o[n.level].max_lazy,n.good_match=$o[n.level].good_length,n.nice_match=$o[n.level].nice_length,n.max_chain_length=$o[n.level].max_chain,n.strstart=0,n.block_start=0,n.lookahead=0,n.insert=0,n.match_length=n.prev_length=ae-1,n.match_available=0,n.ins_h=0}function bw(){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 yt.Buf16(lw*2),this.dyn_dtree=new yt.Buf16((2*sw+1)*2),this.bl_tree=new yt.Buf16((2*aw+1)*2),Zn(this.dyn_ltree),Zn(this.dyn_dtree),Zn(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new yt.Buf16(cw+1),this.heap=new yt.Buf16(2*Eu+1),Zn(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new yt.Buf16(2*Eu+1),Zn(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 rm(n){var t;return!n||!n.state?Jn(n,Kt):(n.total_in=n.total_out=0,n.data_type=ew,t=n.state,t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?$c:Mr,n.adler=t.wrap===2?0:1,t.last_flush=Vr,jt._tr_init(t),Mi)}function om(n){var t=rm(n);return t===Mi&&mw(n.state),t}function xw(n,t){return!n||!n.state||n.state.wrap!==2?Kt:(n.state.gzhead=t,Mi)}function sm(n,t,e,i,r,o){if(!n)return Kt;var s=1;if(t===Yy&&(t=6),i<0?(s=0,i=-i):i>15&&(s=2,i-=16),r<1||r>tw||e!==_c||i<8||i>15||t<0||t>9||o<0||o>_y)return Jn(n,Kt);i===8&&(i=9);var a=new bw;return n.state=a,a.strm=n,a.wrap=s,a.gzhead=null,a.w_bits=i,a.w_size=1<$g||t<0)return n?Jn(n,Kt):Kt;if(i=n.state,!n.output||!n.input&&n.avail_in!==0||i.status===Oa&&t!==Qn)return Jn(n,n.avail_out===0?Cu:Kt);if(i.strm=n,e=i.last_flush,i.last_flush=t,i.status===$c)if(i.wrap===2)n.adler=0,ue(i,31),ue(i,139),ue(i,8),i.gzhead?(ue(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),ue(i,i.gzhead.time&255),ue(i,i.gzhead.time>>8&255),ue(i,i.gzhead.time>>16&255),ue(i,i.gzhead.time>>24&255),ue(i,i.level===9?2:i.strategy>=Zc||i.level<2?4:0),ue(i,i.gzhead.os&255),i.gzhead.extra&&i.gzhead.extra.length&&(ue(i,i.gzhead.extra.length&255),ue(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(n.adler=Gn(n.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=Au):(ue(i,0),ue(i,0),ue(i,0),ue(i,0),ue(i,0),ue(i,i.level===9?2:i.strategy>=Zc||i.level<2?4:0),ue(i,hw),i.status=Mr);else{var s=_c+(i.w_bits-8<<4)<<8,a=-1;i.strategy>=Zc||i.level<2?a=0:i.level<6?a=1:i.level===6?a=2:a=3,s|=a<<6,i.strstart!==0&&(s|=dw),s+=31-s%31,i.status=Mr,La(i,s),i.strstart!==0&&(La(i,n.adler>>>16),La(i,n.adler&65535)),n.adler=1}if(i.status===Au)if(i.gzhead.extra){for(r=i.pending;i.gzindex<(i.gzhead.extra.length&65535)&&!(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(n.adler=Gn(n.adler,i.pending_buf,i.pending-r,r)),Xn(n),r=i.pending,i.pending===i.pending_buf_size));)ue(i,i.gzhead.extra[i.gzindex]&255),i.gzindex++;i.gzhead.hcrc&&i.pending>r&&(n.adler=Gn(n.adler,i.pending_buf,i.pending-r,r)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=Yc)}else i.status=Yc;if(i.status===Yc)if(i.gzhead.name){r=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(n.adler=Gn(n.adler,i.pending_buf,i.pending-r,r)),Xn(n),r=i.pending,i.pending===i.pending_buf_size)){o=1;break}i.gzindexr&&(n.adler=Gn(n.adler,i.pending_buf,i.pending-r,r)),o===0&&(i.gzindex=0,i.status=Jc)}else i.status=Jc;if(i.status===Jc)if(i.gzhead.comment){r=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(n.adler=Gn(n.adler,i.pending_buf,i.pending-r,r)),Xn(n),r=i.pending,i.pending===i.pending_buf_size)){o=1;break}i.gzindexr&&(n.adler=Gn(n.adler,i.pending_buf,i.pending-r,r)),o===0&&(i.status=Qc)}else i.status=Qc;if(i.status===Qc&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&Xn(n),i.pending+2<=i.pending_buf_size&&(ue(i,n.adler&255),ue(i,n.adler>>8&255),n.adler=0,i.status=Mr)):i.status=Mr),i.pending!==0){if(Xn(n),n.avail_out===0)return i.last_flush=-1,Mi}else if(n.avail_in===0&&tm(t)<=tm(e)&&t!==Qn)return Jn(n,Cu);if(i.status===Oa&&n.avail_in!==0)return Jn(n,Cu);if(n.avail_in!==0||i.lookahead!==0||t!==Vr&&i.status!==Oa){var c=i.strategy===Zc?gw(i,t):i.strategy===Qy?pw(i,t):$o[i.level].func(i,t);if((c===Nr||c===es)&&(i.status=Oa),c===Je||c===Nr)return n.avail_out===0&&(i.last_flush=-1),Mi;if(c===Ma&&(t===Gy?jt._tr_align(i):t!==$g&&(jt._tr_stored_block(i,0,0,!1),t===Xy&&(Zn(i.head),i.lookahead===0&&(i.strstart=0,i.block_start=0,i.insert=0))),Xn(n),n.avail_out===0))return i.last_flush=-1,Mi}return t!==Qn?Mi:i.wrap<=0?em:(i.wrap===2?(ue(i,n.adler&255),ue(i,n.adler>>8&255),ue(i,n.adler>>16&255),ue(i,n.adler>>24&255),ue(i,n.total_in&255),ue(i,n.total_in>>8&255),ue(i,n.total_in>>16&255),ue(i,n.total_in>>24&255)):(La(i,n.adler>>>16),La(i,n.adler&65535)),Xn(n),i.wrap>0&&(i.wrap=-i.wrap),i.pending!==0?Mi:em)}function vw(n){var t;return!n||!n.state?Kt:(t=n.state.status,t!==$c&&t!==Au&&t!==Yc&&t!==Jc&&t!==Qc&&t!==Mr&&t!==Oa?Jn(n,Kt):(n.state=null,t===Mr?Jn(n,Zy):Mi))}function Fw(n,t){var e=t.length,i,r,o,s,a,c,l,d;if(!n||!n.state||(i=n.state,s=i.wrap,s===2||s===1&&i.status!==$c||i.lookahead))return Kt;for(s===1&&(n.adler=im(n.adler,t,e,0)),i.wrap=0,e>=i.w_size&&(s===0&&(Zn(i.head),i.strstart=0,i.block_start=0,i.insert=0),d=new yt.Buf8(i.w_size),yt.arraySet(d,t,e-i.w_size,i.w_size,0),t=d,e=i.w_size),a=n.avail_in,c=n.next_in,l=n.input,n.avail_in=e,n.next_in=0,n.input=t,Rr(i);i.lookahead>=ae;){r=i.strstart,o=i.lookahead-(ae-1);do i.ins_h=(i.ins_h<{"use strict";var ed=rn(),lm=!0,cm=!0;try{String.fromCharCode.apply(null,[0])}catch(n){lm=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(n){cm=!1}var Na=new ed.Buf8(256);for(sn=0;sn<256;sn++)Na[sn]=sn>=252?6:sn>=248?5:sn>=240?4:sn>=224?3:sn>=192?2:1;var sn;Na[254]=Na[254]=1;ts.string2buf=function(n){var t,e,i,r,o,s=n.length,a=0;for(r=0;r>>6,t[o++]=128|e&63):e<65536?(t[o++]=224|e>>>12,t[o++]=128|e>>>6&63,t[o++]=128|e&63):(t[o++]=240|e>>>18,t[o++]=128|e>>>12&63,t[o++]=128|e>>>6&63,t[o++]=128|e&63);return t};function dm(n,t){if(t<65534&&(n.subarray&&cm||!n.subarray&&lm))return String.fromCharCode.apply(null,ed.shrinkBuf(n,t));for(var e="",i=0;i4){a[i++]=65533,e+=o-1;continue}for(r&=o===2?31:o===3?15:7;o>1&&e1){a[i++]=65533;continue}r<65536?a[i++]=r:(r-=65536,a[i++]=55296|r>>10&1023,a[i++]=56320|r&1023)}return dm(a,i)};ts.utf8border=function(n,t){var e;for(t=t||n.length,t>n.length&&(t=n.length),e=t-1;e>=0&&(n[e]&192)===128;)e--;return e<0||e===0?t:e+Na[n[e]]>t?e:t}});var Lu=ye((sk,hm)=>{"use strict";function Pw(){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}hm.exports=Pw});var gm=ye(Ba=>{"use strict";var Ra=am(),Va=rn(),Mu=Iu(),Nu=Xc(),kw=Lu(),pm=Object.prototype.toString,Dw=0,Ou=4,is=0,um=1,fm=2,Sw=-1,Cw=0,Tw=8;function Br(n){if(!(this instanceof Br))return new Br(n);this.options=Va.assign({level:Sw,method:Tw,chunkSize:16384,windowBits:15,memLevel:8,strategy:Cw,to:""},n||{});var t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new kw,this.strm.avail_out=0;var e=Ra.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(e!==is)throw new Error(Nu[e]);if(t.header&&Ra.deflateSetHeader(this.strm,t.header),t.dictionary){var i;if(typeof t.dictionary=="string"?i=Mu.string2buf(t.dictionary):pm.call(t.dictionary)==="[object ArrayBuffer]"?i=new Uint8Array(t.dictionary):i=t.dictionary,e=Ra.deflateSetDictionary(this.strm,i),e!==is)throw new Error(Nu[e]);this._dict_set=!0}}Br.prototype.push=function(n,t){var e=this.strm,i=this.options.chunkSize,r,o;if(this.ended)return!1;o=t===~~t?t:t===!0?Ou:Dw,typeof n=="string"?e.input=Mu.string2buf(n):pm.call(n)==="[object ArrayBuffer]"?e.input=new Uint8Array(n):e.input=n,e.next_in=0,e.avail_in=e.input.length;do{if(e.avail_out===0&&(e.output=new Va.Buf8(i),e.next_out=0,e.avail_out=i),r=Ra.deflate(e,o),r!==um&&r!==is)return this.onEnd(r),this.ended=!0,!1;(e.avail_out===0||e.avail_in===0&&(o===Ou||o===fm))&&(this.options.to==="string"?this.onData(Mu.buf2binstring(Va.shrinkBuf(e.output,e.next_out))):this.onData(Va.shrinkBuf(e.output,e.next_out)))}while((e.avail_in>0||e.avail_out===0)&&r!==um);return o===Ou?(r=Ra.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===is):(o===fm&&(this.onEnd(is),e.avail_out=0),!0)};Br.prototype.onData=function(n){this.chunks.push(n)};Br.prototype.onEnd=function(n){n===is&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Va.flattenChunks(this.chunks)),this.chunks=[],this.err=n,this.msg=this.strm.msg};function Ru(n,t){var e=new Br(t);if(e.push(n,!0),e.err)throw e.msg||Nu[e.err];return e.result}function Ew(n,t){return t=t||{},t.raw=!0,Ru(n,t)}function Aw(n,t){return t=t||{},t.gzip=!0,Ru(n,t)}Ba.Deflate=Br;Ba.deflate=Ru;Ba.deflateRaw=Ew;Ba.gzip=Aw});var bm=ye((lk,mm)=>{"use strict";var td=30,Iw=12;mm.exports=function(t,e){var i,r,o,s,a,c,l,d,h,u,f,p,g,m,b,w,F,v,P,k,C,D,T,O,E;i=t.state,r=t.next_in,O=t.input,o=r+(t.avail_in-5),s=t.next_out,E=t.output,a=s-(e-t.avail_out),c=s+(t.avail_out-257),l=i.dmax,d=i.wsize,h=i.whave,u=i.wnext,f=i.window,p=i.hold,g=i.bits,m=i.lencode,b=i.distcode,w=(1<>>24,p>>>=P,g-=P,P=v>>>16&255,P===0)E[s++]=v&65535;else if(P&16){k=v&65535,P&=15,P&&(g>>=P,g-=P),g<15&&(p+=O[r++]<>>24,p>>>=P,g-=P,P=v>>>16&255,P&16){if(C=v&65535,P&=15,gl){t.msg="invalid distance too far back",i.mode=td;break e}if(p>>>=P,g-=P,P=s-a,C>P){if(P=C-P,P>h&&i.sane){t.msg="invalid distance too far back",i.mode=td;break e}if(D=0,T=f,u===0){if(D+=d-P,P2;)E[s++]=T[D++],E[s++]=T[D++],E[s++]=T[D++],k-=3;k&&(E[s++]=T[D++],k>1&&(E[s++]=T[D++]))}else{D=s-C;do E[s++]=E[D++],E[s++]=E[D++],E[s++]=E[D++],k-=3;while(k>2);k&&(E[s++]=E[D++],k>1&&(E[s++]=E[D++]))}}else if(P&64){t.msg="invalid distance code",i.mode=td;break e}else{v=b[(v&65535)+(p&(1<>3,r-=k,g-=k<<3,p&=(1<{"use strict";var xm=rn(),ns=15,ym=852,wm=592,vm=0,Vu=1,Fm=2,Lw=[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],Ow=[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],Mw=[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],Nw=[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];Pm.exports=function(t,e,i,r,o,s,a,c){var l=c.bits,d=0,h=0,u=0,f=0,p=0,g=0,m=0,b=0,w=0,F=0,v,P,k,C,D,T=null,O=0,E,V=new xm.Buf16(ns+1),W=new xm.Buf16(ns+1),B=null,U=0,te,z,re;for(d=0;d<=ns;d++)V[d]=0;for(h=0;h=1&&V[f]===0;f--);if(p>f&&(p=f),f===0)return o[s++]=1<<24|64<<16|0,o[s++]=1<<24|64<<16|0,c.bits=1,0;for(u=1;u0&&(t===vm||f!==1))return-1;for(W[1]=0,d=1;dym||t===Fm&&w>wm)return 1;for(;;){te=d-m,a[h]E?(z=B[U+a[h]],re=T[O+a[h]]):(z=32+64,re=0),v=1<>m)+P]=te<<24|z<<16|re|0;while(P!==0);for(v=1<>=1;if(v!==0?(F&=v-1,F+=v):F=0,h++,--V[d]===0){if(d===f)break;d=e[i+a[h]]}if(d>p&&(F&C)!==k){for(m===0&&(m=p),D+=u,g=d-m,b=1<ym||t===Fm&&w>wm)return 1;k=F&C,o[k]=p<<24|g<<16|D-s|0}}return F!==0&&(o[D+F]=d-m<<24|64<<16|0),c.bits=p,0}});var o0=ye(bi=>{"use strict";var Lt=rn(),Wu=Du(),Ri=Su(),Rw=bm(),Ha=km(),Vw=0,Jm=1,Qm=2,Dm=4,Bw=5,id=6,Hr=0,Hw=1,Uw=2,Gt=-2,_m=-3,ju=-4,zw=-5,Sm=8,$m=1,Cm=2,Tm=3,Em=4,Am=5,Im=6,Lm=7,Om=8,Mm=9,Nm=10,od=11,an=12,Bu=13,Rm=14,Hu=15,Vm=16,Bm=17,Hm=18,Um=19,nd=20,rd=21,zm=22,qm=23,Wm=24,jm=25,Km=26,Uu=27,Gm=28,Xm=29,Oe=30,Ku=31,qw=32,Ww=852,jw=592,Kw=15,Gw=Kw;function Zm(n){return(n>>>24&255)+(n>>>8&65280)+((n&65280)<<8)+((n&255)<<24)}function Xw(){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 Lt.Buf16(320),this.work=new Lt.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function e0(n){var t;return!n||!n.state?Gt:(t=n.state,n.total_in=n.total_out=t.total=0,n.msg="",t.wrap&&(n.adler=t.wrap&1),t.mode=$m,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Lt.Buf32(Ww),t.distcode=t.distdyn=new Lt.Buf32(jw),t.sane=1,t.back=-1,Hr)}function t0(n){var t;return!n||!n.state?Gt:(t=n.state,t.wsize=0,t.whave=0,t.wnext=0,e0(n))}function i0(n,t){var e,i;return!n||!n.state||(i=n.state,t<0?(e=0,t=-t):(e=(t>>4)+1,t<48&&(t&=15)),t&&(t<8||t>15))?Gt:(i.window!==null&&i.wbits!==t&&(i.window=null),i.wrap=e,i.wbits=t,t0(n))}function n0(n,t){var e,i;return n?(i=new Xw,n.state=i,i.window=null,e=i0(n,t),e!==Hr&&(n.state=null),e):Gt}function Zw(n){return n0(n,Gw)}var Ym=!0,zu,qu;function Yw(n){if(Ym){var t;for(zu=new Lt.Buf32(512),qu=new Lt.Buf32(32),t=0;t<144;)n.lens[t++]=8;for(;t<256;)n.lens[t++]=9;for(;t<280;)n.lens[t++]=7;for(;t<288;)n.lens[t++]=8;for(Ha(Jm,n.lens,0,288,zu,0,n.work,{bits:9}),t=0;t<32;)n.lens[t++]=5;Ha(Qm,n.lens,0,32,qu,0,n.work,{bits:5}),Ym=!1}n.lencode=zu,n.lenbits=9,n.distcode=qu,n.distbits=5}function r0(n,t,e,i){var r,o=n.state;return o.window===null&&(o.wsize=1<=o.wsize?(Lt.arraySet(o.window,t,e-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):(r=o.wsize-o.wnext,r>i&&(r=i),Lt.arraySet(o.window,t,e-i,r,o.wnext),i-=r,i?(Lt.arraySet(o.window,t,e-i,i,0),o.wnext=i,o.whave=o.wsize):(o.wnext+=r,o.wnext===o.wsize&&(o.wnext=0),o.whave>>8&255,e.check=Ri(e.check,T,2,0),l=0,d=0,e.mode=Cm;break}if(e.flags=0,e.head&&(e.head.done=!1),!(e.wrap&1)||(((l&255)<<8)+(l>>8))%31){n.msg="incorrect header check",e.mode=Oe;break}if((l&15)!==Sm){n.msg="unknown compression method",e.mode=Oe;break}if(l>>>=4,d-=4,C=(l&15)+8,e.wbits===0)e.wbits=C;else if(C>e.wbits){n.msg="invalid window size",e.mode=Oe;break}e.dmax=1<>8&1),e.flags&512&&(T[0]=l&255,T[1]=l>>>8&255,e.check=Ri(e.check,T,2,0)),l=0,d=0,e.mode=Tm;case Tm:for(;d<32;){if(a===0)break e;a--,l+=i[o++]<>>8&255,T[2]=l>>>16&255,T[3]=l>>>24&255,e.check=Ri(e.check,T,4,0)),l=0,d=0,e.mode=Em;case Em:for(;d<16;){if(a===0)break e;a--,l+=i[o++]<>8),e.flags&512&&(T[0]=l&255,T[1]=l>>>8&255,e.check=Ri(e.check,T,2,0)),l=0,d=0,e.mode=Am;case Am:if(e.flags&1024){for(;d<16;){if(a===0)break e;a--,l+=i[o++]<>>8&255,e.check=Ri(e.check,T,2,0)),l=0,d=0}else e.head&&(e.head.extra=null);e.mode=Im;case Im:if(e.flags&1024&&(f=e.length,f>a&&(f=a),f&&(e.head&&(C=e.head.extra_len-e.length,e.head.extra||(e.head.extra=new Array(e.head.extra_len)),Lt.arraySet(e.head.extra,i,o,f,C)),e.flags&512&&(e.check=Ri(e.check,i,f,o)),a-=f,o+=f,e.length-=f),e.length))break e;e.length=0,e.mode=Lm;case Lm:if(e.flags&2048){if(a===0)break e;f=0;do C=i[o+f++],e.head&&C&&e.length<65536&&(e.head.name+=String.fromCharCode(C));while(C&&f>9&1,e.head.done=!0),n.adler=e.check=0,e.mode=an;break;case Nm:for(;d<32;){if(a===0)break e;a--,l+=i[o++]<>>=d&7,d-=d&7,e.mode=Uu;break}for(;d<3;){if(a===0)break e;a--,l+=i[o++]<>>=1,d-=1,l&3){case 0:e.mode=Rm;break;case 1:if(Yw(e),e.mode=nd,t===id){l>>>=2,d-=2;break e}break;case 2:e.mode=Bm;break;case 3:n.msg="invalid block type",e.mode=Oe}l>>>=2,d-=2;break;case Rm:for(l>>>=d&7,d-=d&7;d<32;){if(a===0)break e;a--,l+=i[o++]<>>16^65535)){n.msg="invalid stored block lengths",e.mode=Oe;break}if(e.length=l&65535,l=0,d=0,e.mode=Hu,t===id)break e;case Hu:e.mode=Vm;case Vm:if(f=e.length,f){if(f>a&&(f=a),f>c&&(f=c),f===0)break e;Lt.arraySet(r,i,o,f,s),a-=f,o+=f,c-=f,s+=f,e.length-=f;break}e.mode=an;break;case Bm:for(;d<14;){if(a===0)break e;a--,l+=i[o++]<>>=5,d-=5,e.ndist=(l&31)+1,l>>>=5,d-=5,e.ncode=(l&15)+4,l>>>=4,d-=4,e.nlen>286||e.ndist>30){n.msg="too many length or distance symbols",e.mode=Oe;break}e.have=0,e.mode=Hm;case Hm:for(;e.have>>=3,d-=3}for(;e.have<19;)e.lens[V[e.have++]]=0;if(e.lencode=e.lendyn,e.lenbits=7,O={bits:e.lenbits},D=Ha(Vw,e.lens,0,19,e.lencode,0,e.work,O),e.lenbits=O.bits,D){n.msg="invalid code lengths set",e.mode=Oe;break}e.have=0,e.mode=Um;case Um:for(;e.have>>24,w=m>>>16&255,F=m&65535,!(b<=d);){if(a===0)break e;a--,l+=i[o++]<>>=b,d-=b,e.lens[e.have++]=F;else{if(F===16){for(E=b+2;d>>=b,d-=b,e.have===0){n.msg="invalid bit length repeat",e.mode=Oe;break}C=e.lens[e.have-1],f=3+(l&3),l>>>=2,d-=2}else if(F===17){for(E=b+3;d>>=b,d-=b,C=0,f=3+(l&7),l>>>=3,d-=3}else{for(E=b+7;d>>=b,d-=b,C=0,f=11+(l&127),l>>>=7,d-=7}if(e.have+f>e.nlen+e.ndist){n.msg="invalid bit length repeat",e.mode=Oe;break}for(;f--;)e.lens[e.have++]=C}}if(e.mode===Oe)break;if(e.lens[256]===0){n.msg="invalid code -- missing end-of-block",e.mode=Oe;break}if(e.lenbits=9,O={bits:e.lenbits},D=Ha(Jm,e.lens,0,e.nlen,e.lencode,0,e.work,O),e.lenbits=O.bits,D){n.msg="invalid literal/lengths set",e.mode=Oe;break}if(e.distbits=6,e.distcode=e.distdyn,O={bits:e.distbits},D=Ha(Qm,e.lens,e.nlen,e.ndist,e.distcode,0,e.work,O),e.distbits=O.bits,D){n.msg="invalid distances set",e.mode=Oe;break}if(e.mode=nd,t===id)break e;case nd:e.mode=rd;case rd:if(a>=6&&c>=258){n.next_out=s,n.avail_out=c,n.next_in=o,n.avail_in=a,e.hold=l,e.bits=d,Rw(n,u),s=n.next_out,r=n.output,c=n.avail_out,o=n.next_in,i=n.input,a=n.avail_in,l=e.hold,d=e.bits,e.mode===an&&(e.back=-1);break}for(e.back=0;m=e.lencode[l&(1<>>24,w=m>>>16&255,F=m&65535,!(b<=d);){if(a===0)break e;a--,l+=i[o++]<>v)],b=m>>>24,w=m>>>16&255,F=m&65535,!(v+b<=d);){if(a===0)break e;a--,l+=i[o++]<>>=v,d-=v,e.back+=v}if(l>>>=b,d-=b,e.back+=b,e.length=F,w===0){e.mode=Km;break}if(w&32){e.back=-1,e.mode=an;break}if(w&64){n.msg="invalid literal/length code",e.mode=Oe;break}e.extra=w&15,e.mode=zm;case zm:if(e.extra){for(E=e.extra;d>>=e.extra,d-=e.extra,e.back+=e.extra}e.was=e.length,e.mode=qm;case qm:for(;m=e.distcode[l&(1<>>24,w=m>>>16&255,F=m&65535,!(b<=d);){if(a===0)break e;a--,l+=i[o++]<>v)],b=m>>>24,w=m>>>16&255,F=m&65535,!(v+b<=d);){if(a===0)break e;a--,l+=i[o++]<>>=v,d-=v,e.back+=v}if(l>>>=b,d-=b,e.back+=b,w&64){n.msg="invalid distance code",e.mode=Oe;break}e.offset=F,e.extra=w&15,e.mode=Wm;case Wm:if(e.extra){for(E=e.extra;d>>=e.extra,d-=e.extra,e.back+=e.extra}if(e.offset>e.dmax){n.msg="invalid distance too far back",e.mode=Oe;break}e.mode=jm;case jm:if(c===0)break e;if(f=u-c,e.offset>f){if(f=e.offset-f,f>e.whave&&e.sane){n.msg="invalid distance too far back",e.mode=Oe;break}f>e.wnext?(f-=e.wnext,p=e.wsize-f):p=e.wnext-f,f>e.length&&(f=e.length),g=e.window}else g=r,p=s-e.offset,f=e.length;f>c&&(f=c),c-=f,e.length-=f;do r[s++]=g[p++];while(--f);e.length===0&&(e.mode=rd);break;case Km:if(c===0)break e;r[s++]=e.length,c--,e.mode=rd;break;case Uu:if(e.wrap){for(;d<32;){if(a===0)break e;a--,l|=i[o++]<{"use strict";s0.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}});var l0=ye((uk,a0)=>{"use strict";function ev(){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}a0.exports=ev});var d0=ye(za=>{"use strict";var rs=o0(),Ua=rn(),sd=Iu(),je=Gu(),Xu=Xc(),tv=Lu(),iv=l0(),c0=Object.prototype.toString;function Ur(n){if(!(this instanceof Ur))return new Ur(n);this.options=Ua.assign({chunkSize:16384,windowBits:0,to:""},n||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(n&&n.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new tv,this.strm.avail_out=0;var e=rs.inflateInit2(this.strm,t.windowBits);if(e!==je.Z_OK)throw new Error(Xu[e]);if(this.header=new iv,rs.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=sd.string2buf(t.dictionary):c0.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(e=rs.inflateSetDictionary(this.strm,t.dictionary),e!==je.Z_OK)))throw new Error(Xu[e])}Ur.prototype.push=function(n,t){var e=this.strm,i=this.options.chunkSize,r=this.options.dictionary,o,s,a,c,l,d=!1;if(this.ended)return!1;s=t===~~t?t:t===!0?je.Z_FINISH:je.Z_NO_FLUSH,typeof n=="string"?e.input=sd.binstring2buf(n):c0.call(n)==="[object ArrayBuffer]"?e.input=new Uint8Array(n):e.input=n,e.next_in=0,e.avail_in=e.input.length;do{if(e.avail_out===0&&(e.output=new Ua.Buf8(i),e.next_out=0,e.avail_out=i),o=rs.inflate(e,je.Z_NO_FLUSH),o===je.Z_NEED_DICT&&r&&(o=rs.inflateSetDictionary(this.strm,r)),o===je.Z_BUF_ERROR&&d===!0&&(o=je.Z_OK,d=!1),o!==je.Z_STREAM_END&&o!==je.Z_OK)return this.onEnd(o),this.ended=!0,!1;e.next_out&&(e.avail_out===0||o===je.Z_STREAM_END||e.avail_in===0&&(s===je.Z_FINISH||s===je.Z_SYNC_FLUSH))&&(this.options.to==="string"?(a=sd.utf8border(e.output,e.next_out),c=e.next_out-a,l=sd.buf2string(e.output,a),e.next_out=c,e.avail_out=i-c,c&&Ua.arraySet(e.output,e.output,a,c,0),this.onData(l)):this.onData(Ua.shrinkBuf(e.output,e.next_out))),e.avail_in===0&&e.avail_out===0&&(d=!0)}while((e.avail_in>0||e.avail_out===0)&&o!==je.Z_STREAM_END);return o===je.Z_STREAM_END&&(s=je.Z_FINISH),s===je.Z_FINISH?(o=rs.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,o===je.Z_OK):(s===je.Z_SYNC_FLUSH&&(this.onEnd(je.Z_OK),e.avail_out=0),!0)};Ur.prototype.onData=function(n){this.chunks.push(n)};Ur.prototype.onEnd=function(n){n===je.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Ua.flattenChunks(this.chunks)),this.chunks=[],this.err=n,this.msg=this.strm.msg};function Zu(n,t){var e=new Ur(t);if(e.push(n,!0),e.err)throw e.msg||Xu[e.err];return e.result}function nv(n,t){return t=t||{},t.raw=!0,Zu(n,t)}za.Inflate=Ur;za.inflate=Zu;za.inflateRaw=nv;za.ungzip=Zu});var qa=ye((pk,u0)=>{"use strict";var rv=rn().assign,ov=gm(),sv=d0(),av=Gu(),h0={};rv(h0,ov,sv,av);u0.exports=h0});var If=ye((FL,pb)=>{"use strict";pb.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}});var mb=ye((PL,gb)=>{gb.exports=function(t){return!t||typeof t=="string"?!1:t instanceof Array||Array.isArray(t)||t.length>=0&&(t.splice instanceof Function||Object.getOwnPropertyDescriptor(t,t.length-1)&&t.constructor.name!=="String")}});var yb=ye((kL,xb)=>{"use strict";var aF=mb(),lF=Array.prototype.concat,cF=Array.prototype.slice,bb=xb.exports=function(t){for(var e=[],i=0,r=t.length;i{var _l=If(),$l=yb(),wb=Object.hasOwnProperty,vb=Object.create(null);for(Id in _l)wb.call(_l,Id)&&(vb[_l[Id]]=Id);var Id,Mt=Fb.exports={to:{},get:{}};Mt.get=function(n){var t=n.substring(0,3).toLowerCase(),e,i;switch(t){case"hsl":e=Mt.get.hsl(n),i="hsl";break;case"hwb":e=Mt.get.hwb(n),i="hwb";break;default:e=Mt.get.rgb(n),i="rgb";break}return e?{model:i,value:e}:null};Mt.get.rgb=function(n){if(!n)return null;var t=/^#([a-f0-9]{3,4})$/i,e=/^#([a-f0-9]{6})([a-f0-9]{2})?$/i,i=/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,r=/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,o=/^(\w+)$/,s=[0,0,0,1],a,c,l;if(a=n.match(e)){for(l=a[2],a=a[1],c=0;c<3;c++){var d=c*2;s[c]=parseInt(a.slice(d,d+2),16)}l&&(s[3]=parseInt(l,16)/255)}else if(a=n.match(t)){for(a=a[1],l=a[3],c=0;c<3;c++)s[c]=parseInt(a[c]+a[c],16);l&&(s[3]=parseInt(l+l,16)/255)}else if(a=n.match(i)){for(c=0;c<3;c++)s[c]=parseInt(a[c+1],0);a[4]&&(a[5]?s[3]=parseFloat(a[4])*.01:s[3]=parseFloat(a[4]))}else if(a=n.match(r)){for(c=0;c<3;c++)s[c]=Math.round(parseFloat(a[c+1])*2.55);a[4]&&(a[5]?s[3]=parseFloat(a[4])*.01:s[3]=parseFloat(a[4]))}else return(a=n.match(o))?a[1]==="transparent"?[0,0,0,0]:wb.call(_l,a[1])?(s=_l[a[1]],s[3]=1,s):null:null;for(c=0;c<3;c++)s[c]=cr(s[c],0,255);return s[3]=cr(s[3],0,1),s};Mt.get.hsl=function(n){if(!n)return null;var t=/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,e=n.match(t);if(e){var i=parseFloat(e[4]),r=(parseFloat(e[1])%360+360)%360,o=cr(parseFloat(e[2]),0,100),s=cr(parseFloat(e[3]),0,100),a=cr(isNaN(i)?1:i,0,1);return[r,o,s,a]}return null};Mt.get.hwb=function(n){if(!n)return null;var t=/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,e=n.match(t);if(e){var i=parseFloat(e[4]),r=(parseFloat(e[1])%360+360)%360,o=cr(parseFloat(e[2]),0,100),s=cr(parseFloat(e[3]),0,100),a=cr(isNaN(i)?1:i,0,1);return[r,o,s,a]}return null};Mt.to.hex=function(){var n=$l(arguments);return"#"+Ld(n[0])+Ld(n[1])+Ld(n[2])+(n[3]<1?Ld(Math.round(n[3]*255)):"")};Mt.to.rgb=function(){var n=$l(arguments);return n.length<4||n[3]===1?"rgb("+Math.round(n[0])+", "+Math.round(n[1])+", "+Math.round(n[2])+")":"rgba("+Math.round(n[0])+", "+Math.round(n[1])+", "+Math.round(n[2])+", "+n[3]+")"};Mt.to.rgb.percent=function(){var n=$l(arguments),t=Math.round(n[0]/255*100),e=Math.round(n[1]/255*100),i=Math.round(n[2]/255*100);return n.length<4||n[3]===1?"rgb("+t+"%, "+e+"%, "+i+"%)":"rgba("+t+"%, "+e+"%, "+i+"%, "+n[3]+")"};Mt.to.hsl=function(){var n=$l(arguments);return n.length<4||n[3]===1?"hsl("+n[0]+", "+n[1]+"%, "+n[2]+"%)":"hsla("+n[0]+", "+n[1]+"%, "+n[2]+"%, "+n[3]+")"};Mt.to.hwb=function(){var n=$l(arguments),t="";return n.length>=4&&n[3]!==1&&(t=", "+n[3]),"hwb("+n[0]+", "+n[1]+"%, "+n[2]+"%"+t+")"};Mt.to.keyword=function(n){return vb[n.slice(0,3)]};function cr(n,t,e){return Math.min(Math.max(t,n),e)}function Ld(n){var t=Math.round(n).toString(16).toUpperCase();return t.length<2?"0"+t:t}});var Lf=ye((SL,Db)=>{var ec=If(),kb={};for(let n of Object.keys(ec))kb[ec[n]]=n;var K={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};Db.exports=K;for(let n of Object.keys(K)){if(!("channels"in K[n]))throw new Error("missing channels property: "+n);if(!("labels"in K[n]))throw new Error("missing channel labels property: "+n);if(K[n].labels.length!==K[n].channels)throw new Error("channel and label counts mismatch: "+n);let{channels:t,labels:e}=K[n];delete K[n].channels,delete K[n].labels,Object.defineProperty(K[n],"channels",{value:t}),Object.defineProperty(K[n],"labels",{value:e})}K.rgb.hsl=function(n){let t=n[0]/255,e=n[1]/255,i=n[2]/255,r=Math.min(t,e,i),o=Math.max(t,e,i),s=o-r,a,c;o===r?a=0:t===o?a=(e-i)/s:e===o?a=2+(i-t)/s:i===o&&(a=4+(t-e)/s),a=Math.min(a*60,360),a<0&&(a+=360);let l=(r+o)/2;return o===r?c=0:l<=.5?c=s/(o+r):c=s/(2-o-r),[a,c*100,l*100]};K.rgb.hsv=function(n){let t,e,i,r,o,s=n[0]/255,a=n[1]/255,c=n[2]/255,l=Math.max(s,a,c),d=l-Math.min(s,a,c),h=function(u){return(l-u)/6/d+1/2};return d===0?(r=0,o=0):(o=d/l,t=h(s),e=h(a),i=h(c),s===l?r=i-e:a===l?r=1/3+t-i:c===l&&(r=2/3+e-t),r<0?r+=1:r>1&&(r-=1)),[r*360,o*100,l*100]};K.rgb.hwb=function(n){let t=n[0],e=n[1],i=n[2],r=K.rgb.hsl(n)[0],o=1/255*Math.min(t,Math.min(e,i));return i=1-1/255*Math.max(t,Math.max(e,i)),[r,o*100,i*100]};K.rgb.cmyk=function(n){let t=n[0]/255,e=n[1]/255,i=n[2]/255,r=Math.min(1-t,1-e,1-i),o=(1-t-r)/(1-r)||0,s=(1-e-r)/(1-r)||0,a=(1-i-r)/(1-r)||0;return[o*100,s*100,a*100,r*100]};function dF(n,t){return(n[0]-t[0])**2+(n[1]-t[1])**2+(n[2]-t[2])**2}K.rgb.keyword=function(n){let t=kb[n];if(t)return t;let e=1/0,i;for(let r of Object.keys(ec)){let o=ec[r],s=dF(n,o);s.04045?((t+.055)/1.055)**2.4:t/12.92,e=e>.04045?((e+.055)/1.055)**2.4:e/12.92,i=i>.04045?((i+.055)/1.055)**2.4:i/12.92;let r=t*.4124+e*.3576+i*.1805,o=t*.2126+e*.7152+i*.0722,s=t*.0193+e*.1192+i*.9505;return[r*100,o*100,s*100]};K.rgb.lab=function(n){let t=K.rgb.xyz(n),e=t[0],i=t[1],r=t[2];e/=95.047,i/=100,r/=108.883,e=e>.008856?e**(1/3):7.787*e+16/116,i=i>.008856?i**(1/3):7.787*i+16/116,r=r>.008856?r**(1/3):7.787*r+16/116;let o=116*i-16,s=500*(e-i),a=200*(i-r);return[o,s,a]};K.hsl.rgb=function(n){let t=n[0]/360,e=n[1]/100,i=n[2]/100,r,o,s;if(e===0)return s=i*255,[s,s,s];i<.5?r=i*(1+e):r=i+e-i*e;let a=2*i-r,c=[0,0,0];for(let l=0;l<3;l++)o=t+1/3*-(l-1),o<0&&o++,o>1&&o--,6*o<1?s=a+(r-a)*6*o:2*o<1?s=r:3*o<2?s=a+(r-a)*(2/3-o)*6:s=a,c[l]=s*255;return c};K.hsl.hsv=function(n){let t=n[0],e=n[1]/100,i=n[2]/100,r=e,o=Math.max(i,.01);i*=2,e*=i<=1?i:2-i,r*=o<=1?o:2-o;let s=(i+e)/2,a=i===0?2*r/(o+r):2*e/(i+e);return[t,a*100,s*100]};K.hsv.rgb=function(n){let t=n[0]/60,e=n[1]/100,i=n[2]/100,r=Math.floor(t)%6,o=t-Math.floor(t),s=255*i*(1-e),a=255*i*(1-e*o),c=255*i*(1-e*(1-o));switch(i*=255,r){case 0:return[i,c,s];case 1:return[a,i,s];case 2:return[s,i,c];case 3:return[s,a,i];case 4:return[c,s,i];case 5:return[i,s,a]}};K.hsv.hsl=function(n){let t=n[0],e=n[1]/100,i=n[2]/100,r=Math.max(i,.01),o,s;s=(2-e)*i;let a=(2-e)*r;return o=e*r,o/=a<=1?a:2-a,o=o||0,s/=2,[t,o*100,s*100]};K.hwb.rgb=function(n){let t=n[0]/360,e=n[1]/100,i=n[2]/100,r=e+i,o;r>1&&(e/=r,i/=r);let s=Math.floor(6*t),a=1-i;o=6*t-s,s&1&&(o=1-o);let c=e+o*(a-e),l,d,h;switch(s){default:case 6:case 0:l=a,d=c,h=e;break;case 1:l=c,d=a,h=e;break;case 2:l=e,d=a,h=c;break;case 3:l=e,d=c,h=a;break;case 4:l=c,d=e,h=a;break;case 5:l=a,d=e,h=c;break}return[l*255,d*255,h*255]};K.cmyk.rgb=function(n){let t=n[0]/100,e=n[1]/100,i=n[2]/100,r=n[3]/100,o=1-Math.min(1,t*(1-r)+r),s=1-Math.min(1,e*(1-r)+r),a=1-Math.min(1,i*(1-r)+r);return[o*255,s*255,a*255]};K.xyz.rgb=function(n){let t=n[0]/100,e=n[1]/100,i=n[2]/100,r,o,s;return r=t*3.2406+e*-1.5372+i*-.4986,o=t*-.9689+e*1.8758+i*.0415,s=t*.0557+e*-.204+i*1.057,r=r>.0031308?1.055*r**(1/2.4)-.055:r*12.92,o=o>.0031308?1.055*o**(1/2.4)-.055:o*12.92,s=s>.0031308?1.055*s**(1/2.4)-.055:s*12.92,r=Math.min(Math.max(0,r),1),o=Math.min(Math.max(0,o),1),s=Math.min(Math.max(0,s),1),[r*255,o*255,s*255]};K.xyz.lab=function(n){let t=n[0],e=n[1],i=n[2];t/=95.047,e/=100,i/=108.883,t=t>.008856?t**(1/3):7.787*t+16/116,e=e>.008856?e**(1/3):7.787*e+16/116,i=i>.008856?i**(1/3):7.787*i+16/116;let r=116*e-16,o=500*(t-e),s=200*(e-i);return[r,o,s]};K.lab.xyz=function(n){let t=n[0],e=n[1],i=n[2],r,o,s;o=(t+16)/116,r=e/500+o,s=o-i/200;let a=o**3,c=r**3,l=s**3;return o=a>.008856?a:(o-16/116)/7.787,r=c>.008856?c:(r-16/116)/7.787,s=l>.008856?l:(s-16/116)/7.787,r*=95.047,o*=100,s*=108.883,[r,o,s]};K.lab.lch=function(n){let t=n[0],e=n[1],i=n[2],r;r=Math.atan2(i,e)*360/2/Math.PI,r<0&&(r+=360);let s=Math.sqrt(e*e+i*i);return[t,s,r]};K.lch.lab=function(n){let t=n[0],e=n[1],r=n[2]/360*2*Math.PI,o=e*Math.cos(r),s=e*Math.sin(r);return[t,o,s]};K.rgb.ansi16=function(n,t=null){let[e,i,r]=n,o=t===null?K.rgb.hsv(n)[2]:t;if(o=Math.round(o/50),o===0)return 30;let s=30+(Math.round(r/255)<<2|Math.round(i/255)<<1|Math.round(e/255));return o===2&&(s+=60),s};K.hsv.ansi16=function(n){return K.rgb.ansi16(K.hsv.rgb(n),n[2])};K.rgb.ansi256=function(n){let t=n[0],e=n[1],i=n[2];return t===e&&e===i?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(e/255*5)+Math.round(i/255*5)};K.ansi16.rgb=function(n){let t=n%10;if(t===0||t===7)return n>50&&(t+=3.5),t=t/10.5*255,[t,t,t];let e=(~~(n>50)+1)*.5,i=(t&1)*e*255,r=(t>>1&1)*e*255,o=(t>>2&1)*e*255;return[i,r,o]};K.ansi256.rgb=function(n){if(n>=232){let o=(n-232)*10+8;return[o,o,o]}n-=16;let t,e=Math.floor(n/36)/5*255,i=Math.floor((t=n%36)/6)/5*255,r=t%6/5*255;return[e,i,r]};K.rgb.hex=function(n){let e=(((Math.round(n[0])&255)<<16)+((Math.round(n[1])&255)<<8)+(Math.round(n[2])&255)).toString(16).toUpperCase();return"000000".substring(e.length)+e};K.hex.rgb=function(n){let t=n.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!t)return[0,0,0];let e=t[0];t[0].length===3&&(e=e.split("").map(a=>a+a).join(""));let i=parseInt(e,16),r=i>>16&255,o=i>>8&255,s=i&255;return[r,o,s]};K.rgb.hcg=function(n){let t=n[0]/255,e=n[1]/255,i=n[2]/255,r=Math.max(Math.max(t,e),i),o=Math.min(Math.min(t,e),i),s=r-o,a,c;return s<1?a=o/(1-s):a=0,s<=0?c=0:r===t?c=(e-i)/s%6:r===e?c=2+(i-t)/s:c=4+(t-e)/s,c/=6,c%=1,[c*360,s*100,a*100]};K.hsl.hcg=function(n){let t=n[1]/100,e=n[2]/100,i=e<.5?2*t*e:2*t*(1-e),r=0;return i<1&&(r=(e-.5*i)/(1-i)),[n[0],i*100,r*100]};K.hsv.hcg=function(n){let t=n[1]/100,e=n[2]/100,i=t*e,r=0;return i<1&&(r=(e-i)/(1-i)),[n[0],i*100,r*100]};K.hcg.rgb=function(n){let t=n[0]/360,e=n[1]/100,i=n[2]/100;if(e===0)return[i*255,i*255,i*255];let r=[0,0,0],o=t%1*6,s=o%1,a=1-s,c=0;switch(Math.floor(o)){case 0:r[0]=1,r[1]=s,r[2]=0;break;case 1:r[0]=a,r[1]=1,r[2]=0;break;case 2:r[0]=0,r[1]=1,r[2]=s;break;case 3:r[0]=0,r[1]=a,r[2]=1;break;case 4:r[0]=s,r[1]=0,r[2]=1;break;default:r[0]=1,r[1]=0,r[2]=a}return c=(1-e)*i,[(e*r[0]+c)*255,(e*r[1]+c)*255,(e*r[2]+c)*255]};K.hcg.hsv=function(n){let t=n[1]/100,e=n[2]/100,i=t+e*(1-t),r=0;return i>0&&(r=t/i),[n[0],r*100,i*100]};K.hcg.hsl=function(n){let t=n[1]/100,i=n[2]/100*(1-t)+.5*t,r=0;return i>0&&i<.5?r=t/(2*i):i>=.5&&i<1&&(r=t/(2*(1-i))),[n[0],r*100,i*100]};K.hcg.hwb=function(n){let t=n[1]/100,e=n[2]/100,i=t+e*(1-t);return[n[0],(i-t)*100,(1-i)*100]};K.hwb.hcg=function(n){let t=n[1]/100,i=1-n[2]/100,r=i-t,o=0;return r<1&&(o=(i-r)/(1-r)),[n[0],r*100,o*100]};K.apple.rgb=function(n){return[n[0]/65535*255,n[1]/65535*255,n[2]/65535*255]};K.rgb.apple=function(n){return[n[0]/255*65535,n[1]/255*65535,n[2]/255*65535]};K.gray.rgb=function(n){return[n[0]/100*255,n[0]/100*255,n[0]/100*255]};K.gray.hsl=function(n){return[0,0,n[0]]};K.gray.hsv=K.gray.hsl;K.gray.hwb=function(n){return[0,100,n[0]]};K.gray.cmyk=function(n){return[0,0,0,n[0]]};K.gray.lab=function(n){return[n[0],0,0]};K.gray.hex=function(n){let t=Math.round(n[0]/100*255)&255,i=((t<<16)+(t<<8)+t).toString(16).toUpperCase();return"000000".substring(i.length)+i};K.rgb.gray=function(n){return[(n[0]+n[1]+n[2])/3/255*100]}});var Cb=ye((CL,Sb)=>{var Od=Lf();function hF(){let n={},t=Object.keys(Od);for(let e=t.length,i=0;i{var Of=Lf(),gF=Cb(),Bs={},mF=Object.keys(Of);function bF(n){let t=function(...e){let i=e[0];return i==null?i:(i.length>1&&(e=i),n(e))};return"conversion"in n&&(t.conversion=n.conversion),t}function xF(n){let t=function(...e){let i=e[0];if(i==null)return i;i.length>1&&(e=i);let r=n(e);if(typeof r=="object")for(let o=r.length,s=0;s{Bs[n]={},Object.defineProperty(Bs[n],"channels",{value:Of[n].channels}),Object.defineProperty(Bs[n],"labels",{value:Of[n].labels});let t=gF(n);Object.keys(t).forEach(i=>{let r=t[i];Bs[n][i]=xF(r),Bs[n][i].raw=bF(r)})});Tb.exports=Bs});var Lb=ye((EL,Ib)=>{var Hs=Pb(),Nt=Eb(),Ab=["keyword","gray","hex"],Mf={};for(let n of Object.keys(Nt))Mf[[...Nt[n].labels].sort().join("")]=n;var Md={};function it(n,t){if(!(this instanceof it))return new it(n,t);if(t&&t in Ab&&(t=null),t&&!(t in Nt))throw new Error("Unknown model: "+t);let e,i;if(n==null)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(n instanceof it)this.model=n.model,this.color=[...n.color],this.valpha=n.valpha;else if(typeof n=="string"){let r=Hs.get(n);if(r===null)throw new Error("Unable to parse color from string: "+n);this.model=r.model,i=Nt[this.model].channels,this.color=r.value.slice(0,i),this.valpha=typeof r.value[i]=="number"?r.value[i]:1}else if(n.length>0){this.model=t||"rgb",i=Nt[this.model].channels;let r=Array.prototype.slice.call(n,0,i);this.color=Nf(r,i),this.valpha=typeof n[i]=="number"?n[i]:1}else if(typeof n=="number")this.model="rgb",this.color=[n>>16&255,n>>8&255,n&255],this.valpha=1;else{this.valpha=1;let r=Object.keys(n);"alpha"in n&&(r.splice(r.indexOf("alpha"),1),this.valpha=typeof n.alpha=="number"?n.alpha:0);let o=r.sort().join("");if(!(o in Mf))throw new Error("Unable to parse color from object: "+JSON.stringify(n));this.model=Mf[o];let{labels:s}=Nt[this.model],a=[];for(e=0;e(n%360+360)%360),saturationl:We("hsl",1,_e(100)),lightness:We("hsl",2,_e(100)),saturationv:We("hsv",1,_e(100)),value:We("hsv",2,_e(100)),chroma:We("hcg",1,_e(100)),gray:We("hcg",2,_e(100)),white:We("hwb",1,_e(100)),wblack:We("hwb",2,_e(100)),cyan:We("cmyk",0,_e(100)),magenta:We("cmyk",1,_e(100)),yellow:We("cmyk",2,_e(100)),black:We("cmyk",3,_e(100)),x:We("xyz",0,_e(95.047)),y:We("xyz",1,_e(100)),z:We("xyz",2,_e(108.833)),l:We("lab",0,_e(100)),a:We("lab",1),b:We("lab",2),keyword(n){return n!==void 0?new it(n):Nt[this.model].keyword(this.color)},hex(n){return n!==void 0?new it(n):Hs.to.hex(this.rgb().round().color)},hexa(n){if(n!==void 0)return new it(n);let t=this.rgb().round().color,e=Math.round(this.valpha*255).toString(16).toUpperCase();return e.length===1&&(e="0"+e),Hs.to.hex(t)+e},rgbNumber(){let n=this.rgb().color;return(n[0]&255)<<16|(n[1]&255)<<8|n[2]&255},luminosity(){let n=this.rgb().color,t=[];for(let[e,i]of n.entries()){let r=i/255;t[e]=r<=.04045?r/12.92:((r+.055)/1.055)**2.4}return .2126*t[0]+.7152*t[1]+.0722*t[2]},contrast(n){let t=this.luminosity(),e=n.luminosity();return t>e?(t+.05)/(e+.05):(e+.05)/(t+.05)},level(n){let t=this.contrast(n);return t>=7?"AAA":t>=4.5?"AA":""},isDark(){let n=this.rgb().color;return(n[0]*2126+n[1]*7152+n[2]*722)/1e4<128},isLight(){return!this.isDark()},negate(){let n=this.rgb();for(let t=0;t<3;t++)n.color[t]=255-n.color[t];return n},lighten(n){let t=this.hsl();return t.color[2]+=t.color[2]*n,t},darken(n){let t=this.hsl();return t.color[2]-=t.color[2]*n,t},saturate(n){let t=this.hsl();return t.color[1]+=t.color[1]*n,t},desaturate(n){let t=this.hsl();return t.color[1]-=t.color[1]*n,t},whiten(n){let t=this.hwb();return t.color[1]+=t.color[1]*n,t},blacken(n){let t=this.hwb();return t.color[2]+=t.color[2]*n,t},grayscale(){let n=this.rgb().color,t=n[0]*.3+n[1]*.59+n[2]*.11;return it.rgb(t,t,t)},fade(n){return this.alpha(this.valpha-this.valpha*n)},opaquer(n){return this.alpha(this.valpha+this.valpha*n)},rotate(n){let t=this.hsl(),e=t.color[0];return e=(e+n)%360,e=e<0?360+e:e,t.color[0]=e,t},mix(n,t){if(!n||!n.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof n);let e=n.rgb(),i=this.rgb(),r=t===void 0?.5:t,o=2*r-1,s=e.alpha()-i.alpha(),a=((o*s===-1?o:(o+s)/(1+o*s))+1)/2,c=1-a;return it.rgb(a*e.red()+c*i.red(),a*e.green()+c*i.green(),a*e.blue()+c*i.blue(),e.alpha()*r+i.alpha()*(1-r))}};for(let n of Object.keys(Nt)){if(Ab.includes(n))continue;let{channels:t}=Nt[n];it.prototype[n]=function(...e){return this.model===n?new it(this):e.length>0?new it(e,n):new it([...vF(Nt[this.model][n].raw(this.color)),this.valpha],n)},it[n]=function(...e){let i=e[0];return typeof i=="number"&&(i=Nf(e,t)),new it(i,n)}}function yF(n,t){return Number(n.toFixed(t))}function wF(n){return function(t){return yF(t,n)}}function We(n,t,e){n=Array.isArray(n)?n:[n];for(let i of n)(Md[i]||(Md[i]=[]))[t]=e;return n=n[0],function(i){let r;return i!==void 0?(e&&(i=e(i)),r=this[n](),r.color[t]=i,r):(r=this[n]().color[t],e&&(r=e(r)),r)}}function _e(n){return function(t){return Math.max(0,Math.min(n,t))}}function vF(n){return Array.isArray(n)?n:[n]}function Nf(n,t){for(let e=0;e{"use strict";Object.defineProperty(Gd,"__esModule",{value:!0});Gd.bodyRegExps={xml:/&(?:#\d+|#[xX][\da-fA-F]+|[0-9a-zA-Z]+);?/g,html4:/∉|&(?:nbsp|iexcl|cent|pound|curren|yen|brvbar|sect|uml|copy|ordf|laquo|not|shy|reg|macr|deg|plusmn|sup2|sup3|acute|micro|para|middot|cedil|sup1|ordm|raquo|frac14|frac12|frac34|iquest|Agrave|Aacute|Acirc|Atilde|Auml|Aring|AElig|Ccedil|Egrave|Eacute|Ecirc|Euml|Igrave|Iacute|Icirc|Iuml|ETH|Ntilde|Ograve|Oacute|Ocirc|Otilde|Ouml|times|Oslash|Ugrave|Uacute|Ucirc|Uuml|Yacute|THORN|szlig|agrave|aacute|acirc|atilde|auml|aring|aelig|ccedil|egrave|eacute|ecirc|euml|igrave|iacute|icirc|iuml|eth|ntilde|ograve|oacute|ocirc|otilde|ouml|divide|oslash|ugrave|uacute|ucirc|uuml|yacute|thorn|yuml|quot|amp|lt|gt|#\d+|#[xX][\da-fA-F]+|[0-9a-zA-Z]+);?/g,html5:/·|℗|⋇|⪧|⩺|⋗|⦕|⩼|⪆|⥸|⋗|⋛|⪌|≷|≳|⪦|⩹|⋖|⋋|⋉|⥶|⩻|⦖|◃|⊴|◂|∉|⋹̸|⋵̸|∉|⋷|⋶|∌|∌|⋾|⋽|∥|⊠|⨱|⨰|&(?:AElig|AMP|Aacute|Acirc|Agrave|Aring|Atilde|Auml|COPY|Ccedil|ETH|Eacute|Ecirc|Egrave|Euml|GT|Iacute|Icirc|Igrave|Iuml|LT|Ntilde|Oacute|Ocirc|Ograve|Oslash|Otilde|Ouml|QUOT|REG|THORN|Uacute|Ucirc|Ugrave|Uuml|Yacute|aacute|acirc|acute|aelig|agrave|amp|aring|atilde|auml|brvbar|ccedil|cedil|cent|copy|curren|deg|divide|eacute|ecirc|egrave|eth|euml|frac12|frac14|frac34|gt|iacute|icirc|iexcl|igrave|iquest|iuml|laquo|lt|macr|micro|middot|nbsp|not|ntilde|oacute|ocirc|ograve|ordf|ordm|oslash|otilde|ouml|para|plusmn|pound|quot|raquo|reg|sect|shy|sup1|sup2|sup3|szlig|thorn|times|uacute|ucirc|ugrave|uml|uuml|yacute|yen|yuml|#\d+|#[xX][\da-fA-F]+|[0-9a-zA-Z]+);?/g};Gd.namedReferences={xml:{entities:{"<":"<",">":">",""":'"',"'":"'","&":"&"},characters:{"<":"<",">":">",'"':""","'":"'","&":"&"}},html4:{entities:{"'":"'"," ":"\xA0"," ":"\xA0","¡":"\xA1","¡":"\xA1","¢":"\xA2","¢":"\xA2","£":"\xA3","£":"\xA3","¤":"\xA4","¤":"\xA4","¥":"\xA5","¥":"\xA5","¦":"\xA6","¦":"\xA6","§":"\xA7","§":"\xA7","¨":"\xA8","¨":"\xA8","©":"\xA9","©":"\xA9","ª":"\xAA","ª":"\xAA","«":"\xAB","«":"\xAB","¬":"\xAC","¬":"\xAC","­":"\xAD","­":"\xAD","®":"\xAE","®":"\xAE","¯":"\xAF","¯":"\xAF","°":"\xB0","°":"\xB0","±":"\xB1","±":"\xB1","²":"\xB2","²":"\xB2","³":"\xB3","³":"\xB3","´":"\xB4","´":"\xB4","µ":"\xB5","µ":"\xB5","¶":"\xB6","¶":"\xB6","·":"\xB7","·":"\xB7","¸":"\xB8","¸":"\xB8","¹":"\xB9","¹":"\xB9","º":"\xBA","º":"\xBA","»":"\xBB","»":"\xBB","¼":"\xBC","¼":"\xBC","½":"\xBD","½":"\xBD","¾":"\xBE","¾":"\xBE","¿":"\xBF","¿":"\xBF","À":"\xC0","À":"\xC0","Á":"\xC1","Á":"\xC1","Â":"\xC2","Â":"\xC2","Ã":"\xC3","Ã":"\xC3","Ä":"\xC4","Ä":"\xC4","Å":"\xC5","Å":"\xC5","Æ":"\xC6","Æ":"\xC6","Ç":"\xC7","Ç":"\xC7","È":"\xC8","È":"\xC8","É":"\xC9","É":"\xC9","Ê":"\xCA","Ê":"\xCA","Ë":"\xCB","Ë":"\xCB","Ì":"\xCC","Ì":"\xCC","Í":"\xCD","Í":"\xCD","Î":"\xCE","Î":"\xCE","Ï":"\xCF","Ï":"\xCF","Ð":"\xD0","Ð":"\xD0","Ñ":"\xD1","Ñ":"\xD1","Ò":"\xD2","Ò":"\xD2","Ó":"\xD3","Ó":"\xD3","Ô":"\xD4","Ô":"\xD4","Õ":"\xD5","Õ":"\xD5","Ö":"\xD6","Ö":"\xD6","×":"\xD7","×":"\xD7","Ø":"\xD8","Ø":"\xD8","Ù":"\xD9","Ù":"\xD9","Ú":"\xDA","Ú":"\xDA","Û":"\xDB","Û":"\xDB","Ü":"\xDC","Ü":"\xDC","Ý":"\xDD","Ý":"\xDD","Þ":"\xDE","Þ":"\xDE","ß":"\xDF","ß":"\xDF","à":"\xE0","à":"\xE0","á":"\xE1","á":"\xE1","â":"\xE2","â":"\xE2","ã":"\xE3","ã":"\xE3","ä":"\xE4","ä":"\xE4","å":"\xE5","å":"\xE5","æ":"\xE6","æ":"\xE6","ç":"\xE7","ç":"\xE7","è":"\xE8","è":"\xE8","é":"\xE9","é":"\xE9","ê":"\xEA","ê":"\xEA","ë":"\xEB","ë":"\xEB","ì":"\xEC","ì":"\xEC","í":"\xED","í":"\xED","î":"\xEE","î":"\xEE","ï":"\xEF","ï":"\xEF","ð":"\xF0","ð":"\xF0","ñ":"\xF1","ñ":"\xF1","ò":"\xF2","ò":"\xF2","ó":"\xF3","ó":"\xF3","ô":"\xF4","ô":"\xF4","õ":"\xF5","õ":"\xF5","ö":"\xF6","ö":"\xF6","÷":"\xF7","÷":"\xF7","ø":"\xF8","ø":"\xF8","ù":"\xF9","ù":"\xF9","ú":"\xFA","ú":"\xFA","û":"\xFB","û":"\xFB","ü":"\xFC","ü":"\xFC","ý":"\xFD","ý":"\xFD","þ":"\xFE","þ":"\xFE","ÿ":"\xFF","ÿ":"\xFF",""":'"',""":'"',"&":"&","&":"&","<":"<","<":"<",">":">",">":">","Œ":"\u0152","œ":"\u0153","Š":"\u0160","š":"\u0161","Ÿ":"\u0178","ˆ":"\u02C6","˜":"\u02DC"," ":"\u2002"," ":"\u2003"," ":"\u2009","‌":"\u200C","‍":"\u200D","‎":"\u200E","‏":"\u200F","–":"\u2013","—":"\u2014","‘":"\u2018","’":"\u2019","‚":"\u201A","“":"\u201C","”":"\u201D","„":"\u201E","†":"\u2020","‡":"\u2021","‰":"\u2030","‹":"\u2039","›":"\u203A","€":"\u20AC","ƒ":"\u0192","Α":"\u0391","Β":"\u0392","Γ":"\u0393","Δ":"\u0394","Ε":"\u0395","Ζ":"\u0396","Η":"\u0397","Θ":"\u0398","Ι":"\u0399","Κ":"\u039A","Λ":"\u039B","Μ":"\u039C","Ν":"\u039D","Ξ":"\u039E","Ο":"\u039F","Π":"\u03A0","Ρ":"\u03A1","Σ":"\u03A3","Τ":"\u03A4","Υ":"\u03A5","Φ":"\u03A6","Χ":"\u03A7","Ψ":"\u03A8","Ω":"\u03A9","α":"\u03B1","β":"\u03B2","γ":"\u03B3","δ":"\u03B4","ε":"\u03B5","ζ":"\u03B6","η":"\u03B7","θ":"\u03B8","ι":"\u03B9","κ":"\u03BA","λ":"\u03BB","μ":"\u03BC","ν":"\u03BD","ξ":"\u03BE","ο":"\u03BF","π":"\u03C0","ρ":"\u03C1","ς":"\u03C2","σ":"\u03C3","τ":"\u03C4","υ":"\u03C5","φ":"\u03C6","χ":"\u03C7","ψ":"\u03C8","ω":"\u03C9","ϑ":"\u03D1","ϒ":"\u03D2","ϖ":"\u03D6","•":"\u2022","…":"\u2026","′":"\u2032","″":"\u2033","‾":"\u203E","⁄":"\u2044","℘":"\u2118","ℑ":"\u2111","ℜ":"\u211C","™":"\u2122","ℵ":"\u2135","←":"\u2190","↑":"\u2191","→":"\u2192","↓":"\u2193","↔":"\u2194","↵":"\u21B5","⇐":"\u21D0","⇑":"\u21D1","⇒":"\u21D2","⇓":"\u21D3","⇔":"\u21D4","∀":"\u2200","∂":"\u2202","∃":"\u2203","∅":"\u2205","∇":"\u2207","∈":"\u2208","∉":"\u2209","∋":"\u220B","∏":"\u220F","∑":"\u2211","−":"\u2212","∗":"\u2217","√":"\u221A","∝":"\u221D","∞":"\u221E","∠":"\u2220","∧":"\u2227","∨":"\u2228","∩":"\u2229","∪":"\u222A","∫":"\u222B","∴":"\u2234","∼":"\u223C","≅":"\u2245","≈":"\u2248","≠":"\u2260","≡":"\u2261","≤":"\u2264","≥":"\u2265","⊂":"\u2282","⊃":"\u2283","⊄":"\u2284","⊆":"\u2286","⊇":"\u2287","⊕":"\u2295","⊗":"\u2297","⊥":"\u22A5","⋅":"\u22C5","⌈":"\u2308","⌉":"\u2309","⌊":"\u230A","⌋":"\u230B","⟨":"\u2329","⟩":"\u232A","◊":"\u25CA","♠":"\u2660","♣":"\u2663","♥":"\u2665","♦":"\u2666"},characters:{"'":"'","\xA0":" ","\xA1":"¡","\xA2":"¢","\xA3":"£","\xA4":"¤","\xA5":"¥","\xA6":"¦","\xA7":"§","\xA8":"¨","\xA9":"©",\u00AA:"ª","\xAB":"«","\xAC":"¬","\xAD":"­","\xAE":"®","\xAF":"¯","\xB0":"°","\xB1":"±","\xB2":"²","\xB3":"³","\xB4":"´",\u00B5:"µ","\xB6":"¶","\xB7":"·","\xB8":"¸","\xB9":"¹",\u00BA:"º","\xBB":"»","\xBC":"¼","\xBD":"½","\xBE":"¾","\xBF":"¿",\u00C0:"À",\u00C1:"Á",\u00C2:"Â",\u00C3:"Ã",\u00C4:"Ä",\u00C5:"Å",\u00C6:"Æ",\u00C7:"Ç",\u00C8:"È",\u00C9:"É",\u00CA:"Ê",\u00CB:"Ë",\u00CC:"Ì",\u00CD:"Í",\u00CE:"Î",\u00CF:"Ï",\u00D0:"Ð",\u00D1:"Ñ",\u00D2:"Ò",\u00D3:"Ó",\u00D4:"Ô",\u00D5:"Õ",\u00D6:"Ö","\xD7":"×",\u00D8:"Ø",\u00D9:"Ù",\u00DA:"Ú",\u00DB:"Û",\u00DC:"Ü",\u00DD:"Ý",\u00DE:"Þ",\u00DF:"ß",\u00E0:"à",\u00E1:"á",\u00E2:"â",\u00E3:"ã",\u00E4:"ä",\u00E5:"å",\u00E6:"æ",\u00E7:"ç",\u00E8:"è",\u00E9:"é",\u00EA:"ê",\u00EB:"ë",\u00EC:"ì",\u00ED:"í",\u00EE:"î",\u00EF:"ï",\u00F0:"ð",\u00F1:"ñ",\u00F2:"ò",\u00F3:"ó",\u00F4:"ô",\u00F5:"õ",\u00F6:"ö","\xF7":"÷",\u00F8:"ø",\u00F9:"ù",\u00FA:"ú",\u00FB:"û",\u00FC:"ü",\u00FD:"ý",\u00FE:"þ",\u00FF:"ÿ",'"':""","&":"&","<":"<",">":">",\u0152:"Œ",\u0153:"œ",\u0160:"Š",\u0161:"š",\u0178:"Ÿ","\u02C6":"ˆ","\u02DC":"˜","\u2002":" ","\u2003":" ","\u2009":" ","\u200C":"‌","\u200D":"‍","\u200E":"‎","\u200F":"‏","\u2013":"–","\u2014":"—","\u2018":"‘","\u2019":"’","\u201A":"‚","\u201C":"“","\u201D":"”","\u201E":"„","\u2020":"†","\u2021":"‡","\u2030":"‰","\u2039":"‹","\u203A":"›","\u20AC":"€",\u0192:"ƒ",\u0391:"Α",\u0392:"Β",\u0393:"Γ",\u0394:"Δ",\u0395:"Ε",\u0396:"Ζ",\u0397:"Η",\u0398:"Θ",\u0399:"Ι",\u039A:"Κ",\u039B:"Λ",\u039C:"Μ",\u039D:"Ν",\u039E:"Ξ",\u039F:"Ο",\u03A0:"Π",\u03A1:"Ρ",\u03A3:"Σ",\u03A4:"Τ",\u03A5:"Υ",\u03A6:"Φ",\u03A7:"Χ",\u03A8:"Ψ",\u03A9:"Ω",\u03B1:"α",\u03B2:"β",\u03B3:"γ",\u03B4:"δ",\u03B5:"ε",\u03B6:"ζ",\u03B7:"η",\u03B8:"θ",\u03B9:"ι",\u03BA:"κ",\u03BB:"λ",\u03BC:"μ",\u03BD:"ν",\u03BE:"ξ",\u03BF:"ο",\u03C0:"π",\u03C1:"ρ",\u03C2:"ς",\u03C3:"σ",\u03C4:"τ",\u03C5:"υ",\u03C6:"φ",\u03C7:"χ",\u03C8:"ψ",\u03C9:"ω",\u03D1:"ϑ",\u03D2:"ϒ",\u03D6:"ϖ","\u2022":"•","\u2026":"…","\u2032":"′","\u2033":"″","\u203E":"‾","\u2044":"⁄","\u2118":"℘",\u2111:"ℑ",\u211C:"ℜ","\u2122":"™",\u2135:"ℵ","\u2190":"←","\u2191":"↑","\u2192":"→","\u2193":"↓","\u2194":"↔","\u21B5":"↵","\u21D0":"⇐","\u21D1":"⇑","\u21D2":"⇒","\u21D3":"⇓","\u21D4":"⇔","\u2200":"∀","\u2202":"∂","\u2203":"∃","\u2205":"∅","\u2207":"∇","\u2208":"∈","\u2209":"∉","\u220B":"∋","\u220F":"∏","\u2211":"∑","\u2212":"−","\u2217":"∗","\u221A":"√","\u221D":"∝","\u221E":"∞","\u2220":"∠","\u2227":"∧","\u2228":"∨","\u2229":"∩","\u222A":"∪","\u222B":"∫","\u2234":"∴","\u223C":"∼","\u2245":"≅","\u2248":"≈","\u2260":"≠","\u2261":"≡","\u2264":"≤","\u2265":"≥","\u2282":"⊂","\u2283":"⊃","\u2284":"⊄","\u2286":"⊆","\u2287":"⊇","\u2295":"⊕","\u2297":"⊗","\u22A5":"⊥","\u22C5":"⋅","\u2308":"⌈","\u2309":"⌉","\u230A":"⌊","\u230B":"⌋","\u2329":"⟨","\u232A":"⟩","\u25CA":"◊","\u2660":"♠","\u2663":"♣","\u2665":"♥","\u2666":"♦"}},html5:{entities:{"Æ":"\xC6","Æ":"\xC6","&":"&","&":"&","Á":"\xC1","Á":"\xC1","Ă":"\u0102","Â":"\xC2","Â":"\xC2","А":"\u0410","𝔄":"\u{1D504}","À":"\xC0","À":"\xC0","Α":"\u0391","Ā":"\u0100","⩓":"\u2A53","Ą":"\u0104","𝔸":"\u{1D538}","⁡":"\u2061","Å":"\xC5","Å":"\xC5","𝒜":"\u{1D49C}","≔":"\u2254","Ã":"\xC3","Ã":"\xC3","Ä":"\xC4","Ä":"\xC4","∖":"\u2216","⫧":"\u2AE7","⌆":"\u2306","Б":"\u0411","∵":"\u2235","ℬ":"\u212C","Β":"\u0392","𝔅":"\u{1D505}","𝔹":"\u{1D539}","˘":"\u02D8","ℬ":"\u212C","≎":"\u224E","Ч":"\u0427","©":"\xA9","©":"\xA9","Ć":"\u0106","⋒":"\u22D2","ⅅ":"\u2145","ℭ":"\u212D","Č":"\u010C","Ç":"\xC7","Ç":"\xC7","Ĉ":"\u0108","∰":"\u2230","Ċ":"\u010A","¸":"\xB8","·":"\xB7","ℭ":"\u212D","Χ":"\u03A7","⊙":"\u2299","⊖":"\u2296","⊕":"\u2295","⊗":"\u2297","∲":"\u2232","”":"\u201D","’":"\u2019","∷":"\u2237","⩴":"\u2A74","≡":"\u2261","∯":"\u222F","∮":"\u222E","ℂ":"\u2102","∐":"\u2210","∳":"\u2233","⨯":"\u2A2F","𝒞":"\u{1D49E}","⋓":"\u22D3","≍":"\u224D","ⅅ":"\u2145","⤑":"\u2911","Ђ":"\u0402","Ѕ":"\u0405","Џ":"\u040F","‡":"\u2021","↡":"\u21A1","⫤":"\u2AE4","Ď":"\u010E","Д":"\u0414","∇":"\u2207","Δ":"\u0394","𝔇":"\u{1D507}","´":"\xB4","˙":"\u02D9","˝":"\u02DD","`":"`","˜":"\u02DC","⋄":"\u22C4","ⅆ":"\u2146","𝔻":"\u{1D53B}","¨":"\xA8","⃜":"\u20DC","≐":"\u2250","∯":"\u222F","¨":"\xA8","⇓":"\u21D3","⇐":"\u21D0","⇔":"\u21D4","⫤":"\u2AE4","⟸":"\u27F8","⟺":"\u27FA","⟹":"\u27F9","⇒":"\u21D2","⊨":"\u22A8","⇑":"\u21D1","⇕":"\u21D5","∥":"\u2225","↓":"\u2193","⤓":"\u2913","⇵":"\u21F5","̑":"\u0311","⥐":"\u2950","⥞":"\u295E","↽":"\u21BD","⥖":"\u2956","⥟":"\u295F","⇁":"\u21C1","⥗":"\u2957","⊤":"\u22A4","↧":"\u21A7","⇓":"\u21D3","𝒟":"\u{1D49F}","Đ":"\u0110","Ŋ":"\u014A","Ð":"\xD0","Ð":"\xD0","É":"\xC9","É":"\xC9","Ě":"\u011A","Ê":"\xCA","Ê":"\xCA","Э":"\u042D","Ė":"\u0116","𝔈":"\u{1D508}","È":"\xC8","È":"\xC8","∈":"\u2208","Ē":"\u0112","◻":"\u25FB","▫":"\u25AB","Ę":"\u0118","𝔼":"\u{1D53C}","Ε":"\u0395","⩵":"\u2A75","≂":"\u2242","⇌":"\u21CC","ℰ":"\u2130","⩳":"\u2A73","Η":"\u0397","Ë":"\xCB","Ë":"\xCB","∃":"\u2203","ⅇ":"\u2147","Ф":"\u0424","𝔉":"\u{1D509}","◼":"\u25FC","▪":"\u25AA","𝔽":"\u{1D53D}","∀":"\u2200","ℱ":"\u2131","ℱ":"\u2131","Ѓ":"\u0403",">":">",">":">","Γ":"\u0393","Ϝ":"\u03DC","Ğ":"\u011E","Ģ":"\u0122","Ĝ":"\u011C","Г":"\u0413","Ġ":"\u0120","𝔊":"\u{1D50A}","⋙":"\u22D9","𝔾":"\u{1D53E}","≥":"\u2265","⋛":"\u22DB","≧":"\u2267","⪢":"\u2AA2","≷":"\u2277","⩾":"\u2A7E","≳":"\u2273","𝒢":"\u{1D4A2}","≫":"\u226B","Ъ":"\u042A","ˇ":"\u02C7","^":"^","Ĥ":"\u0124","ℌ":"\u210C","ℋ":"\u210B","ℍ":"\u210D","─":"\u2500","ℋ":"\u210B","Ħ":"\u0126","≎":"\u224E","≏":"\u224F","Е":"\u0415","IJ":"\u0132","Ё":"\u0401","Í":"\xCD","Í":"\xCD","Î":"\xCE","Î":"\xCE","И":"\u0418","İ":"\u0130","ℑ":"\u2111","Ì":"\xCC","Ì":"\xCC","ℑ":"\u2111","Ī":"\u012A","ⅈ":"\u2148","⇒":"\u21D2","∬":"\u222C","∫":"\u222B","⋂":"\u22C2","⁣":"\u2063","⁢":"\u2062","Į":"\u012E","𝕀":"\u{1D540}","Ι":"\u0399","ℐ":"\u2110","Ĩ":"\u0128","І":"\u0406","Ï":"\xCF","Ï":"\xCF","Ĵ":"\u0134","Й":"\u0419","𝔍":"\u{1D50D}","𝕁":"\u{1D541}","𝒥":"\u{1D4A5}","Ј":"\u0408","Є":"\u0404","Х":"\u0425","Ќ":"\u040C","Κ":"\u039A","Ķ":"\u0136","К":"\u041A","𝔎":"\u{1D50E}","𝕂":"\u{1D542}","𝒦":"\u{1D4A6}","Љ":"\u0409","<":"<","<":"<","Ĺ":"\u0139","Λ":"\u039B","⟪":"\u27EA","ℒ":"\u2112","↞":"\u219E","Ľ":"\u013D","Ļ":"\u013B","Л":"\u041B","⟨":"\u27E8","←":"\u2190","⇤":"\u21E4","⇆":"\u21C6","⌈":"\u2308","⟦":"\u27E6","⥡":"\u2961","⇃":"\u21C3","⥙":"\u2959","⌊":"\u230A","↔":"\u2194","⥎":"\u294E","⊣":"\u22A3","↤":"\u21A4","⥚":"\u295A","⊲":"\u22B2","⧏":"\u29CF","⊴":"\u22B4","⥑":"\u2951","⥠":"\u2960","↿":"\u21BF","⥘":"\u2958","↼":"\u21BC","⥒":"\u2952","⇐":"\u21D0","⇔":"\u21D4","⋚":"\u22DA","≦":"\u2266","≶":"\u2276","⪡":"\u2AA1","⩽":"\u2A7D","≲":"\u2272","𝔏":"\u{1D50F}","⋘":"\u22D8","⇚":"\u21DA","Ŀ":"\u013F","⟵":"\u27F5","⟷":"\u27F7","⟶":"\u27F6","⟸":"\u27F8","⟺":"\u27FA","⟹":"\u27F9","𝕃":"\u{1D543}","↙":"\u2199","↘":"\u2198","ℒ":"\u2112","↰":"\u21B0","Ł":"\u0141","≪":"\u226A","⤅":"\u2905","М":"\u041C"," ":"\u205F","ℳ":"\u2133","𝔐":"\u{1D510}","∓":"\u2213","𝕄":"\u{1D544}","ℳ":"\u2133","Μ":"\u039C","Њ":"\u040A","Ń":"\u0143","Ň":"\u0147","Ņ":"\u0145","Н":"\u041D","​":"\u200B","​":"\u200B","​":"\u200B","​":"\u200B","≫":"\u226B","≪":"\u226A"," ":` `,"𝔑":"\u{1D511}","⁠":"\u2060"," ":"\xA0","ℕ":"\u2115","⫬":"\u2AEC","≢":"\u2262","≭":"\u226D","∦":"\u2226","∉":"\u2209","≠":"\u2260","≂̸":"\u2242\u0338","∄":"\u2204","≯":"\u226F","≱":"\u2271","≧̸":"\u2267\u0338","≫̸":"\u226B\u0338","≹":"\u2279","⩾̸":"\u2A7E\u0338","≵":"\u2275","≎̸":"\u224E\u0338","≏̸":"\u224F\u0338","⋪":"\u22EA","⧏̸":"\u29CF\u0338","⋬":"\u22EC","≮":"\u226E","≰":"\u2270","≸":"\u2278","≪̸":"\u226A\u0338","⩽̸":"\u2A7D\u0338","≴":"\u2274","⪢̸":"\u2AA2\u0338","⪡̸":"\u2AA1\u0338","⊀":"\u2280","⪯̸":"\u2AAF\u0338","⋠":"\u22E0","∌":"\u220C","⋫":"\u22EB","⧐̸":"\u29D0\u0338","⋭":"\u22ED","⊏̸":"\u228F\u0338","⋢":"\u22E2","⊐̸":"\u2290\u0338","⋣":"\u22E3","⊂⃒":"\u2282\u20D2","⊈":"\u2288","⊁":"\u2281","⪰̸":"\u2AB0\u0338","⋡":"\u22E1","≿̸":"\u227F\u0338","⊃⃒":"\u2283\u20D2","⊉":"\u2289","≁":"\u2241","≄":"\u2244","≇":"\u2247","≉":"\u2249","∤":"\u2224","𝒩":"\u{1D4A9}","Ñ":"\xD1","Ñ":"\xD1","Ν":"\u039D","Œ":"\u0152","Ó":"\xD3","Ó":"\xD3","Ô":"\xD4","Ô":"\xD4","О":"\u041E","Ő":"\u0150","𝔒":"\u{1D512}","Ò":"\xD2","Ò":"\xD2","Ō":"\u014C","Ω":"\u03A9","Ο":"\u039F","𝕆":"\u{1D546}","“":"\u201C","‘":"\u2018","⩔":"\u2A54","𝒪":"\u{1D4AA}","Ø":"\xD8","Ø":"\xD8","Õ":"\xD5","Õ":"\xD5","⨷":"\u2A37","Ö":"\xD6","Ö":"\xD6","‾":"\u203E","⏞":"\u23DE","⎴":"\u23B4","⏜":"\u23DC","∂":"\u2202","П":"\u041F","𝔓":"\u{1D513}","Φ":"\u03A6","Π":"\u03A0","±":"\xB1","ℌ":"\u210C","ℙ":"\u2119","⪻":"\u2ABB","≺":"\u227A","⪯":"\u2AAF","≼":"\u227C","≾":"\u227E","″":"\u2033","∏":"\u220F","∷":"\u2237","∝":"\u221D","𝒫":"\u{1D4AB}","Ψ":"\u03A8",""":'"',""":'"',"𝔔":"\u{1D514}","ℚ":"\u211A","𝒬":"\u{1D4AC}","⤐":"\u2910","®":"\xAE","®":"\xAE","Ŕ":"\u0154","⟫":"\u27EB","↠":"\u21A0","⤖":"\u2916","Ř":"\u0158","Ŗ":"\u0156","Р":"\u0420","ℜ":"\u211C","∋":"\u220B","⇋":"\u21CB","⥯":"\u296F","ℜ":"\u211C","Ρ":"\u03A1","⟩":"\u27E9","→":"\u2192","⇥":"\u21E5","⇄":"\u21C4","⌉":"\u2309","⟧":"\u27E7","⥝":"\u295D","⇂":"\u21C2","⥕":"\u2955","⌋":"\u230B","⊢":"\u22A2","↦":"\u21A6","⥛":"\u295B","⊳":"\u22B3","⧐":"\u29D0","⊵":"\u22B5","⥏":"\u294F","⥜":"\u295C","↾":"\u21BE","⥔":"\u2954","⇀":"\u21C0","⥓":"\u2953","⇒":"\u21D2","ℝ":"\u211D","⥰":"\u2970","⇛":"\u21DB","ℛ":"\u211B","↱":"\u21B1","⧴":"\u29F4","Щ":"\u0429","Ш":"\u0428","Ь":"\u042C","Ś":"\u015A","⪼":"\u2ABC","Š":"\u0160","Ş":"\u015E","Ŝ":"\u015C","С":"\u0421","𝔖":"\u{1D516}","↓":"\u2193","←":"\u2190","→":"\u2192","↑":"\u2191","Σ":"\u03A3","∘":"\u2218","𝕊":"\u{1D54A}","√":"\u221A","□":"\u25A1","⊓":"\u2293","⊏":"\u228F","⊑":"\u2291","⊐":"\u2290","⊒":"\u2292","⊔":"\u2294","𝒮":"\u{1D4AE}","⋆":"\u22C6","⋐":"\u22D0","⋐":"\u22D0","⊆":"\u2286","≻":"\u227B","⪰":"\u2AB0","≽":"\u227D","≿":"\u227F","∋":"\u220B","∑":"\u2211","⋑":"\u22D1","⊃":"\u2283","⊇":"\u2287","⋑":"\u22D1","Þ":"\xDE","Þ":"\xDE","™":"\u2122","Ћ":"\u040B","Ц":"\u0426"," ":" ","Τ":"\u03A4","Ť":"\u0164","Ţ":"\u0162","Т":"\u0422","𝔗":"\u{1D517}","∴":"\u2234","Θ":"\u0398","  ":"\u205F\u200A"," ":"\u2009","∼":"\u223C","≃":"\u2243","≅":"\u2245","≈":"\u2248","𝕋":"\u{1D54B}","⃛":"\u20DB","𝒯":"\u{1D4AF}","Ŧ":"\u0166","Ú":"\xDA","Ú":"\xDA","↟":"\u219F","⥉":"\u2949","Ў":"\u040E","Ŭ":"\u016C","Û":"\xDB","Û":"\xDB","У":"\u0423","Ű":"\u0170","𝔘":"\u{1D518}","Ù":"\xD9","Ù":"\xD9","Ū":"\u016A","_":"_","⏟":"\u23DF","⎵":"\u23B5","⏝":"\u23DD","⋃":"\u22C3","⊎":"\u228E","Ų":"\u0172","𝕌":"\u{1D54C}","↑":"\u2191","⤒":"\u2912","⇅":"\u21C5","↕":"\u2195","⥮":"\u296E","⊥":"\u22A5","↥":"\u21A5","⇑":"\u21D1","⇕":"\u21D5","↖":"\u2196","↗":"\u2197","ϒ":"\u03D2","Υ":"\u03A5","Ů":"\u016E","𝒰":"\u{1D4B0}","Ũ":"\u0168","Ü":"\xDC","Ü":"\xDC","⊫":"\u22AB","⫫":"\u2AEB","В":"\u0412","⊩":"\u22A9","⫦":"\u2AE6","⋁":"\u22C1","‖":"\u2016","‖":"\u2016","∣":"\u2223","|":"|","❘":"\u2758","≀":"\u2240"," ":"\u200A","𝔙":"\u{1D519}","𝕍":"\u{1D54D}","𝒱":"\u{1D4B1}","⊪":"\u22AA","Ŵ":"\u0174","⋀":"\u22C0","𝔚":"\u{1D51A}","𝕎":"\u{1D54E}","𝒲":"\u{1D4B2}","𝔛":"\u{1D51B}","Ξ":"\u039E","𝕏":"\u{1D54F}","𝒳":"\u{1D4B3}","Я":"\u042F","Ї":"\u0407","Ю":"\u042E","Ý":"\xDD","Ý":"\xDD","Ŷ":"\u0176","Ы":"\u042B","𝔜":"\u{1D51C}","𝕐":"\u{1D550}","𝒴":"\u{1D4B4}","Ÿ":"\u0178","Ж":"\u0416","Ź":"\u0179","Ž":"\u017D","З":"\u0417","Ż":"\u017B","​":"\u200B","Ζ":"\u0396","ℨ":"\u2128","ℤ":"\u2124","𝒵":"\u{1D4B5}","á":"\xE1","á":"\xE1","ă":"\u0103","∾":"\u223E","∾̳":"\u223E\u0333","∿":"\u223F","â":"\xE2","â":"\xE2","´":"\xB4","´":"\xB4","а":"\u0430","æ":"\xE6","æ":"\xE6","⁡":"\u2061","𝔞":"\u{1D51E}","à":"\xE0","à":"\xE0","ℵ":"\u2135","ℵ":"\u2135","α":"\u03B1","ā":"\u0101","⨿":"\u2A3F","&":"&","&":"&","∧":"\u2227","⩕":"\u2A55","⩜":"\u2A5C","⩘":"\u2A58","⩚":"\u2A5A","∠":"\u2220","⦤":"\u29A4","∠":"\u2220","∡":"\u2221","⦨":"\u29A8","⦩":"\u29A9","⦪":"\u29AA","⦫":"\u29AB","⦬":"\u29AC","⦭":"\u29AD","⦮":"\u29AE","⦯":"\u29AF","∟":"\u221F","⊾":"\u22BE","⦝":"\u299D","∢":"\u2222","Å":"\xC5","⍼":"\u237C","ą":"\u0105","𝕒":"\u{1D552}","≈":"\u2248","⩰":"\u2A70","⩯":"\u2A6F","≊":"\u224A","≋":"\u224B","'":"'","≈":"\u2248","≊":"\u224A","å":"\xE5","å":"\xE5","𝒶":"\u{1D4B6}","*":"*","≈":"\u2248","≍":"\u224D","ã":"\xE3","ã":"\xE3","ä":"\xE4","ä":"\xE4","∳":"\u2233","⨑":"\u2A11","⫭":"\u2AED","≌":"\u224C","϶":"\u03F6","‵":"\u2035","∽":"\u223D","⋍":"\u22CD","⊽":"\u22BD","⌅":"\u2305","⌅":"\u2305","⎵":"\u23B5","⎶":"\u23B6","≌":"\u224C","б":"\u0431","„":"\u201E","∵":"\u2235","∵":"\u2235","⦰":"\u29B0","϶":"\u03F6","ℬ":"\u212C","β":"\u03B2","ℶ":"\u2136","≬":"\u226C","𝔟":"\u{1D51F}","⋂":"\u22C2","◯":"\u25EF","⋃":"\u22C3","⨀":"\u2A00","⨁":"\u2A01","⨂":"\u2A02","⨆":"\u2A06","★":"\u2605","▽":"\u25BD","△":"\u25B3","⨄":"\u2A04","⋁":"\u22C1","⋀":"\u22C0","⤍":"\u290D","⧫":"\u29EB","▪":"\u25AA","▴":"\u25B4","▾":"\u25BE","◂":"\u25C2","▸":"\u25B8","␣":"\u2423","▒":"\u2592","░":"\u2591","▓":"\u2593","█":"\u2588","=⃥":"=\u20E5","≡⃥":"\u2261\u20E5","⌐":"\u2310","𝕓":"\u{1D553}","⊥":"\u22A5","⊥":"\u22A5","⋈":"\u22C8","╗":"\u2557","╔":"\u2554","╖":"\u2556","╓":"\u2553","═":"\u2550","╦":"\u2566","╩":"\u2569","╤":"\u2564","╧":"\u2567","╝":"\u255D","╚":"\u255A","╜":"\u255C","╙":"\u2559","║":"\u2551","╬":"\u256C","╣":"\u2563","╠":"\u2560","╫":"\u256B","╢":"\u2562","╟":"\u255F","⧉":"\u29C9","╕":"\u2555","╒":"\u2552","┐":"\u2510","┌":"\u250C","─":"\u2500","╥":"\u2565","╨":"\u2568","┬":"\u252C","┴":"\u2534","⊟":"\u229F","⊞":"\u229E","⊠":"\u22A0","╛":"\u255B","╘":"\u2558","┘":"\u2518","└":"\u2514","│":"\u2502","╪":"\u256A","╡":"\u2561","╞":"\u255E","┼":"\u253C","┤":"\u2524","├":"\u251C","‵":"\u2035","˘":"\u02D8","¦":"\xA6","¦":"\xA6","𝒷":"\u{1D4B7}","⁏":"\u204F","∽":"\u223D","⋍":"\u22CD","\":"\\","⧅":"\u29C5","⟈":"\u27C8","•":"\u2022","•":"\u2022","≎":"\u224E","⪮":"\u2AAE","≏":"\u224F","≏":"\u224F","ć":"\u0107","∩":"\u2229","⩄":"\u2A44","⩉":"\u2A49","⩋":"\u2A4B","⩇":"\u2A47","⩀":"\u2A40","∩︀":"\u2229\uFE00","⁁":"\u2041","ˇ":"\u02C7","⩍":"\u2A4D","č":"\u010D","ç":"\xE7","ç":"\xE7","ĉ":"\u0109","⩌":"\u2A4C","⩐":"\u2A50","ċ":"\u010B","¸":"\xB8","¸":"\xB8","⦲":"\u29B2","¢":"\xA2","¢":"\xA2","·":"\xB7","𝔠":"\u{1D520}","ч":"\u0447","✓":"\u2713","✓":"\u2713","χ":"\u03C7","○":"\u25CB","⧃":"\u29C3","ˆ":"\u02C6","≗":"\u2257","↺":"\u21BA","↻":"\u21BB","®":"\xAE","Ⓢ":"\u24C8","⊛":"\u229B","⊚":"\u229A","⊝":"\u229D","≗":"\u2257","⨐":"\u2A10","⫯":"\u2AEF","⧂":"\u29C2","♣":"\u2663","♣":"\u2663",":":":","≔":"\u2254","≔":"\u2254",",":",","@":"@","∁":"\u2201","∘":"\u2218","∁":"\u2201","ℂ":"\u2102","≅":"\u2245","⩭":"\u2A6D","∮":"\u222E","𝕔":"\u{1D554}","∐":"\u2210","©":"\xA9","©":"\xA9","℗":"\u2117","↵":"\u21B5","✗":"\u2717","𝒸":"\u{1D4B8}","⫏":"\u2ACF","⫑":"\u2AD1","⫐":"\u2AD0","⫒":"\u2AD2","⋯":"\u22EF","⤸":"\u2938","⤵":"\u2935","⋞":"\u22DE","⋟":"\u22DF","↶":"\u21B6","⤽":"\u293D","∪":"\u222A","⩈":"\u2A48","⩆":"\u2A46","⩊":"\u2A4A","⊍":"\u228D","⩅":"\u2A45","∪︀":"\u222A\uFE00","↷":"\u21B7","⤼":"\u293C","⋞":"\u22DE","⋟":"\u22DF","⋎":"\u22CE","⋏":"\u22CF","¤":"\xA4","¤":"\xA4","↶":"\u21B6","↷":"\u21B7","⋎":"\u22CE","⋏":"\u22CF","∲":"\u2232","∱":"\u2231","⌭":"\u232D","⇓":"\u21D3","⥥":"\u2965","†":"\u2020","ℸ":"\u2138","↓":"\u2193","‐":"\u2010","⊣":"\u22A3","⤏":"\u290F","˝":"\u02DD","ď":"\u010F","д":"\u0434","ⅆ":"\u2146","‡":"\u2021","⇊":"\u21CA","⩷":"\u2A77","°":"\xB0","°":"\xB0","δ":"\u03B4","⦱":"\u29B1","⥿":"\u297F","𝔡":"\u{1D521}","⇃":"\u21C3","⇂":"\u21C2","⋄":"\u22C4","⋄":"\u22C4","♦":"\u2666","♦":"\u2666","¨":"\xA8","ϝ":"\u03DD","⋲":"\u22F2","÷":"\xF7","÷":"\xF7","÷":"\xF7","⋇":"\u22C7","⋇":"\u22C7","ђ":"\u0452","⌞":"\u231E","⌍":"\u230D","$":"$","𝕕":"\u{1D555}","˙":"\u02D9","≐":"\u2250","≑":"\u2251","∸":"\u2238","∔":"\u2214","⊡":"\u22A1","⌆":"\u2306","↓":"\u2193","⇊":"\u21CA","⇃":"\u21C3","⇂":"\u21C2","⤐":"\u2910","⌟":"\u231F","⌌":"\u230C","𝒹":"\u{1D4B9}","ѕ":"\u0455","⧶":"\u29F6","đ":"\u0111","⋱":"\u22F1","▿":"\u25BF","▾":"\u25BE","⇵":"\u21F5","⥯":"\u296F","⦦":"\u29A6","џ":"\u045F","⟿":"\u27FF","⩷":"\u2A77","≑":"\u2251","é":"\xE9","é":"\xE9","⩮":"\u2A6E","ě":"\u011B","≖":"\u2256","ê":"\xEA","ê":"\xEA","≕":"\u2255","э":"\u044D","ė":"\u0117","ⅇ":"\u2147","≒":"\u2252","𝔢":"\u{1D522}","⪚":"\u2A9A","è":"\xE8","è":"\xE8","⪖":"\u2A96","⪘":"\u2A98","⪙":"\u2A99","⏧":"\u23E7","ℓ":"\u2113","⪕":"\u2A95","⪗":"\u2A97","ē":"\u0113","∅":"\u2205","∅":"\u2205","∅":"\u2205"," ":"\u2004"," ":"\u2005"," ":"\u2003","ŋ":"\u014B"," ":"\u2002","ę":"\u0119","𝕖":"\u{1D556}","⋕":"\u22D5","⧣":"\u29E3","⩱":"\u2A71","ε":"\u03B5","ε":"\u03B5","ϵ":"\u03F5","≖":"\u2256","≕":"\u2255","≂":"\u2242","⪖":"\u2A96","⪕":"\u2A95","=":"=","≟":"\u225F","≡":"\u2261","⩸":"\u2A78","⧥":"\u29E5","≓":"\u2253","⥱":"\u2971","ℯ":"\u212F","≐":"\u2250","≂":"\u2242","η":"\u03B7","ð":"\xF0","ð":"\xF0","ë":"\xEB","ë":"\xEB","€":"\u20AC","!":"!","∃":"\u2203","ℰ":"\u2130","ⅇ":"\u2147","≒":"\u2252","ф":"\u0444","♀":"\u2640","ffi":"\uFB03","ff":"\uFB00","ffl":"\uFB04","𝔣":"\u{1D523}","fi":"\uFB01","fj":"fj","♭":"\u266D","fl":"\uFB02","▱":"\u25B1","ƒ":"\u0192","𝕗":"\u{1D557}","∀":"\u2200","⋔":"\u22D4","⫙":"\u2AD9","⨍":"\u2A0D","½":"\xBD","½":"\xBD","⅓":"\u2153","¼":"\xBC","¼":"\xBC","⅕":"\u2155","⅙":"\u2159","⅛":"\u215B","⅔":"\u2154","⅖":"\u2156","¾":"\xBE","¾":"\xBE","⅗":"\u2157","⅜":"\u215C","⅘":"\u2158","⅚":"\u215A","⅝":"\u215D","⅞":"\u215E","⁄":"\u2044","⌢":"\u2322","𝒻":"\u{1D4BB}","≧":"\u2267","⪌":"\u2A8C","ǵ":"\u01F5","γ":"\u03B3","ϝ":"\u03DD","⪆":"\u2A86","ğ":"\u011F","ĝ":"\u011D","г":"\u0433","ġ":"\u0121","≥":"\u2265","⋛":"\u22DB","≥":"\u2265","≧":"\u2267","⩾":"\u2A7E","⩾":"\u2A7E","⪩":"\u2AA9","⪀":"\u2A80","⪂":"\u2A82","⪄":"\u2A84","⋛︀":"\u22DB\uFE00","⪔":"\u2A94","𝔤":"\u{1D524}","≫":"\u226B","⋙":"\u22D9","ℷ":"\u2137","ѓ":"\u0453","≷":"\u2277","⪒":"\u2A92","⪥":"\u2AA5","⪤":"\u2AA4","≩":"\u2269","⪊":"\u2A8A","⪊":"\u2A8A","⪈":"\u2A88","⪈":"\u2A88","≩":"\u2269","⋧":"\u22E7","𝕘":"\u{1D558}","`":"`","ℊ":"\u210A","≳":"\u2273","⪎":"\u2A8E","⪐":"\u2A90",">":">",">":">","⪧":"\u2AA7","⩺":"\u2A7A","⋗":"\u22D7","⦕":"\u2995","⩼":"\u2A7C","⪆":"\u2A86","⥸":"\u2978","⋗":"\u22D7","⋛":"\u22DB","⪌":"\u2A8C","≷":"\u2277","≳":"\u2273","≩︀":"\u2269\uFE00","≩︀":"\u2269\uFE00","⇔":"\u21D4"," ":"\u200A","½":"\xBD","ℋ":"\u210B","ъ":"\u044A","↔":"\u2194","⥈":"\u2948","↭":"\u21AD","ℏ":"\u210F","ĥ":"\u0125","♥":"\u2665","♥":"\u2665","…":"\u2026","⊹":"\u22B9","𝔥":"\u{1D525}","⤥":"\u2925","⤦":"\u2926","⇿":"\u21FF","∻":"\u223B","↩":"\u21A9","↪":"\u21AA","𝕙":"\u{1D559}","―":"\u2015","𝒽":"\u{1D4BD}","ℏ":"\u210F","ħ":"\u0127","⁃":"\u2043","‐":"\u2010","í":"\xED","í":"\xED","⁣":"\u2063","î":"\xEE","î":"\xEE","и":"\u0438","е":"\u0435","¡":"\xA1","¡":"\xA1","⇔":"\u21D4","𝔦":"\u{1D526}","ì":"\xEC","ì":"\xEC","ⅈ":"\u2148","⨌":"\u2A0C","∭":"\u222D","⧜":"\u29DC","℩":"\u2129","ij":"\u0133","ī":"\u012B","ℑ":"\u2111","ℐ":"\u2110","ℑ":"\u2111","ı":"\u0131","⊷":"\u22B7","Ƶ":"\u01B5","∈":"\u2208","℅":"\u2105","∞":"\u221E","⧝":"\u29DD","ı":"\u0131","∫":"\u222B","⊺":"\u22BA","ℤ":"\u2124","⊺":"\u22BA","⨗":"\u2A17","⨼":"\u2A3C","ё":"\u0451","į":"\u012F","𝕚":"\u{1D55A}","ι":"\u03B9","⨼":"\u2A3C","¿":"\xBF","¿":"\xBF","𝒾":"\u{1D4BE}","∈":"\u2208","⋹":"\u22F9","⋵":"\u22F5","⋴":"\u22F4","⋳":"\u22F3","∈":"\u2208","⁢":"\u2062","ĩ":"\u0129","і":"\u0456","ï":"\xEF","ï":"\xEF","ĵ":"\u0135","й":"\u0439","𝔧":"\u{1D527}","ȷ":"\u0237","𝕛":"\u{1D55B}","𝒿":"\u{1D4BF}","ј":"\u0458","є":"\u0454","κ":"\u03BA","ϰ":"\u03F0","ķ":"\u0137","к":"\u043A","𝔨":"\u{1D528}","ĸ":"\u0138","х":"\u0445","ќ":"\u045C","𝕜":"\u{1D55C}","𝓀":"\u{1D4C0}","⇚":"\u21DA","⇐":"\u21D0","⤛":"\u291B","⤎":"\u290E","≦":"\u2266","⪋":"\u2A8B","⥢":"\u2962","ĺ":"\u013A","⦴":"\u29B4","ℒ":"\u2112","λ":"\u03BB","⟨":"\u27E8","⦑":"\u2991","⟨":"\u27E8","⪅":"\u2A85","«":"\xAB","«":"\xAB","←":"\u2190","⇤":"\u21E4","⤟":"\u291F","⤝":"\u291D","↩":"\u21A9","↫":"\u21AB","⤹":"\u2939","⥳":"\u2973","↢":"\u21A2","⪫":"\u2AAB","⤙":"\u2919","⪭":"\u2AAD","⪭︀":"\u2AAD\uFE00","⤌":"\u290C","❲":"\u2772","{":"{","[":"[","⦋":"\u298B","⦏":"\u298F","⦍":"\u298D","ľ":"\u013E","ļ":"\u013C","⌈":"\u2308","{":"{","л":"\u043B","⤶":"\u2936","“":"\u201C","„":"\u201E","⥧":"\u2967","⥋":"\u294B","↲":"\u21B2","≤":"\u2264","←":"\u2190","↢":"\u21A2","↽":"\u21BD","↼":"\u21BC","⇇":"\u21C7","↔":"\u2194","⇆":"\u21C6","⇋":"\u21CB","↭":"\u21AD","⋋":"\u22CB","⋚":"\u22DA","≤":"\u2264","≦":"\u2266","⩽":"\u2A7D","⩽":"\u2A7D","⪨":"\u2AA8","⩿":"\u2A7F","⪁":"\u2A81","⪃":"\u2A83","⋚︀":"\u22DA\uFE00","⪓":"\u2A93","⪅":"\u2A85","⋖":"\u22D6","⋚":"\u22DA","⪋":"\u2A8B","≶":"\u2276","≲":"\u2272","⥼":"\u297C","⌊":"\u230A","𝔩":"\u{1D529}","≶":"\u2276","⪑":"\u2A91","↽":"\u21BD","↼":"\u21BC","⥪":"\u296A","▄":"\u2584","љ":"\u0459","≪":"\u226A","⇇":"\u21C7","⌞":"\u231E","⥫":"\u296B","◺":"\u25FA","ŀ":"\u0140","⎰":"\u23B0","⎰":"\u23B0","≨":"\u2268","⪉":"\u2A89","⪉":"\u2A89","⪇":"\u2A87","⪇":"\u2A87","≨":"\u2268","⋦":"\u22E6","⟬":"\u27EC","⇽":"\u21FD","⟦":"\u27E6","⟵":"\u27F5","⟷":"\u27F7","⟼":"\u27FC","⟶":"\u27F6","↫":"\u21AB","↬":"\u21AC","⦅":"\u2985","𝕝":"\u{1D55D}","⨭":"\u2A2D","⨴":"\u2A34","∗":"\u2217","_":"_","◊":"\u25CA","◊":"\u25CA","⧫":"\u29EB","(":"(","⦓":"\u2993","⇆":"\u21C6","⌟":"\u231F","⇋":"\u21CB","⥭":"\u296D","‎":"\u200E","⊿":"\u22BF","‹":"\u2039","𝓁":"\u{1D4C1}","↰":"\u21B0","≲":"\u2272","⪍":"\u2A8D","⪏":"\u2A8F","[":"[","‘":"\u2018","‚":"\u201A","ł":"\u0142","<":"<","<":"<","⪦":"\u2AA6","⩹":"\u2A79","⋖":"\u22D6","⋋":"\u22CB","⋉":"\u22C9","⥶":"\u2976","⩻":"\u2A7B","⦖":"\u2996","◃":"\u25C3","⊴":"\u22B4","◂":"\u25C2","⥊":"\u294A","⥦":"\u2966","≨︀":"\u2268\uFE00","≨︀":"\u2268\uFE00","∺":"\u223A","¯":"\xAF","¯":"\xAF","♂":"\u2642","✠":"\u2720","✠":"\u2720","↦":"\u21A6","↦":"\u21A6","↧":"\u21A7","↤":"\u21A4","↥":"\u21A5","▮":"\u25AE","⨩":"\u2A29","м":"\u043C","—":"\u2014","∡":"\u2221","𝔪":"\u{1D52A}","℧":"\u2127","µ":"\xB5","µ":"\xB5","∣":"\u2223","*":"*","⫰":"\u2AF0","·":"\xB7","·":"\xB7","−":"\u2212","⊟":"\u229F","∸":"\u2238","⨪":"\u2A2A","⫛":"\u2ADB","…":"\u2026","∓":"\u2213","⊧":"\u22A7","𝕞":"\u{1D55E}","∓":"\u2213","𝓂":"\u{1D4C2}","∾":"\u223E","μ":"\u03BC","⊸":"\u22B8","⊸":"\u22B8","⋙̸":"\u22D9\u0338","≫⃒":"\u226B\u20D2","≫̸":"\u226B\u0338","⇍":"\u21CD","⇎":"\u21CE","⋘̸":"\u22D8\u0338","≪⃒":"\u226A\u20D2","≪̸":"\u226A\u0338","⇏":"\u21CF","⊯":"\u22AF","⊮":"\u22AE","∇":"\u2207","ń":"\u0144","∠⃒":"\u2220\u20D2","≉":"\u2249","⩰̸":"\u2A70\u0338","≋̸":"\u224B\u0338","ʼn":"\u0149","≉":"\u2249","♮":"\u266E","♮":"\u266E","ℕ":"\u2115"," ":"\xA0"," ":"\xA0","≎̸":"\u224E\u0338","≏̸":"\u224F\u0338","⩃":"\u2A43","ň":"\u0148","ņ":"\u0146","≇":"\u2247","⩭̸":"\u2A6D\u0338","⩂":"\u2A42","н":"\u043D","–":"\u2013","≠":"\u2260","⇗":"\u21D7","⤤":"\u2924","↗":"\u2197","↗":"\u2197","≐̸":"\u2250\u0338","≢":"\u2262","⤨":"\u2928","≂̸":"\u2242\u0338","∄":"\u2204","∄":"\u2204","𝔫":"\u{1D52B}","≧̸":"\u2267\u0338","≱":"\u2271","≱":"\u2271","≧̸":"\u2267\u0338","⩾̸":"\u2A7E\u0338","⩾̸":"\u2A7E\u0338","≵":"\u2275","≯":"\u226F","≯":"\u226F","⇎":"\u21CE","↮":"\u21AE","⫲":"\u2AF2","∋":"\u220B","⋼":"\u22FC","⋺":"\u22FA","∋":"\u220B","њ":"\u045A","⇍":"\u21CD","≦̸":"\u2266\u0338","↚":"\u219A","‥":"\u2025","≰":"\u2270","↚":"\u219A","↮":"\u21AE","≰":"\u2270","≦̸":"\u2266\u0338","⩽̸":"\u2A7D\u0338","⩽̸":"\u2A7D\u0338","≮":"\u226E","≴":"\u2274","≮":"\u226E","⋪":"\u22EA","⋬":"\u22EC","∤":"\u2224","𝕟":"\u{1D55F}","¬":"\xAC","¬":"\xAC","∉":"\u2209","⋹̸":"\u22F9\u0338","⋵̸":"\u22F5\u0338","∉":"\u2209","⋷":"\u22F7","⋶":"\u22F6","∌":"\u220C","∌":"\u220C","⋾":"\u22FE","⋽":"\u22FD","∦":"\u2226","∦":"\u2226","⫽⃥":"\u2AFD\u20E5","∂̸":"\u2202\u0338","⨔":"\u2A14","⊀":"\u2280","⋠":"\u22E0","⪯̸":"\u2AAF\u0338","⊀":"\u2280","⪯̸":"\u2AAF\u0338","⇏":"\u21CF","↛":"\u219B","⤳̸":"\u2933\u0338","↝̸":"\u219D\u0338","↛":"\u219B","⋫":"\u22EB","⋭":"\u22ED","⊁":"\u2281","⋡":"\u22E1","⪰̸":"\u2AB0\u0338","𝓃":"\u{1D4C3}","∤":"\u2224","∦":"\u2226","≁":"\u2241","≄":"\u2244","≄":"\u2244","∤":"\u2224","∦":"\u2226","⋢":"\u22E2","⋣":"\u22E3","⊄":"\u2284","⫅̸":"\u2AC5\u0338","⊈":"\u2288","⊂⃒":"\u2282\u20D2","⊈":"\u2288","⫅̸":"\u2AC5\u0338","⊁":"\u2281","⪰̸":"\u2AB0\u0338","⊅":"\u2285","⫆̸":"\u2AC6\u0338","⊉":"\u2289","⊃⃒":"\u2283\u20D2","⊉":"\u2289","⫆̸":"\u2AC6\u0338","≹":"\u2279","ñ":"\xF1","ñ":"\xF1","≸":"\u2278","⋪":"\u22EA","⋬":"\u22EC","⋫":"\u22EB","⋭":"\u22ED","ν":"\u03BD","#":"#","№":"\u2116"," ":"\u2007","⊭":"\u22AD","⤄":"\u2904","≍⃒":"\u224D\u20D2","⊬":"\u22AC","≥⃒":"\u2265\u20D2",">⃒":">\u20D2","⧞":"\u29DE","⤂":"\u2902","≤⃒":"\u2264\u20D2","<⃒":"<\u20D2","⊴⃒":"\u22B4\u20D2","⤃":"\u2903","⊵⃒":"\u22B5\u20D2","∼⃒":"\u223C\u20D2","⇖":"\u21D6","⤣":"\u2923","↖":"\u2196","↖":"\u2196","⤧":"\u2927","Ⓢ":"\u24C8","ó":"\xF3","ó":"\xF3","⊛":"\u229B","⊚":"\u229A","ô":"\xF4","ô":"\xF4","о":"\u043E","⊝":"\u229D","ő":"\u0151","⨸":"\u2A38","⊙":"\u2299","⦼":"\u29BC","œ":"\u0153","⦿":"\u29BF","𝔬":"\u{1D52C}","˛":"\u02DB","ò":"\xF2","ò":"\xF2","⧁":"\u29C1","⦵":"\u29B5","Ω":"\u03A9","∮":"\u222E","↺":"\u21BA","⦾":"\u29BE","⦻":"\u29BB","‾":"\u203E","⧀":"\u29C0","ō":"\u014D","ω":"\u03C9","ο":"\u03BF","⦶":"\u29B6","⊖":"\u2296","𝕠":"\u{1D560}","⦷":"\u29B7","⦹":"\u29B9","⊕":"\u2295","∨":"\u2228","↻":"\u21BB","⩝":"\u2A5D","ℴ":"\u2134","ℴ":"\u2134","ª":"\xAA","ª":"\xAA","º":"\xBA","º":"\xBA","⊶":"\u22B6","⩖":"\u2A56","⩗":"\u2A57","⩛":"\u2A5B","ℴ":"\u2134","ø":"\xF8","ø":"\xF8","⊘":"\u2298","õ":"\xF5","õ":"\xF5","⊗":"\u2297","⨶":"\u2A36","ö":"\xF6","ö":"\xF6","⌽":"\u233D","∥":"\u2225","¶":"\xB6","¶":"\xB6","∥":"\u2225","⫳":"\u2AF3","⫽":"\u2AFD","∂":"\u2202","п":"\u043F","%":"%",".":".","‰":"\u2030","⊥":"\u22A5","‱":"\u2031","𝔭":"\u{1D52D}","φ":"\u03C6","ϕ":"\u03D5","ℳ":"\u2133","☎":"\u260E","π":"\u03C0","⋔":"\u22D4","ϖ":"\u03D6","ℏ":"\u210F","ℎ":"\u210E","ℏ":"\u210F","+":"+","⨣":"\u2A23","⊞":"\u229E","⨢":"\u2A22","∔":"\u2214","⨥":"\u2A25","⩲":"\u2A72","±":"\xB1","±":"\xB1","⨦":"\u2A26","⨧":"\u2A27","±":"\xB1","⨕":"\u2A15","𝕡":"\u{1D561}","£":"\xA3","£":"\xA3","≺":"\u227A","⪳":"\u2AB3","⪷":"\u2AB7","≼":"\u227C","⪯":"\u2AAF","≺":"\u227A","⪷":"\u2AB7","≼":"\u227C","⪯":"\u2AAF","⪹":"\u2AB9","⪵":"\u2AB5","⋨":"\u22E8","≾":"\u227E","′":"\u2032","ℙ":"\u2119","⪵":"\u2AB5","⪹":"\u2AB9","⋨":"\u22E8","∏":"\u220F","⌮":"\u232E","⌒":"\u2312","⌓":"\u2313","∝":"\u221D","∝":"\u221D","≾":"\u227E","⊰":"\u22B0","𝓅":"\u{1D4C5}","ψ":"\u03C8"," ":"\u2008","𝔮":"\u{1D52E}","⨌":"\u2A0C","𝕢":"\u{1D562}","⁗":"\u2057","𝓆":"\u{1D4C6}","ℍ":"\u210D","⨖":"\u2A16","?":"?","≟":"\u225F",""":'"',""":'"',"⇛":"\u21DB","⇒":"\u21D2","⤜":"\u291C","⤏":"\u290F","⥤":"\u2964","∽̱":"\u223D\u0331","ŕ":"\u0155","√":"\u221A","⦳":"\u29B3","⟩":"\u27E9","⦒":"\u2992","⦥":"\u29A5","⟩":"\u27E9","»":"\xBB","»":"\xBB","→":"\u2192","⥵":"\u2975","⇥":"\u21E5","⤠":"\u2920","⤳":"\u2933","⤞":"\u291E","↪":"\u21AA","↬":"\u21AC","⥅":"\u2945","⥴":"\u2974","↣":"\u21A3","↝":"\u219D","⤚":"\u291A","∶":"\u2236","ℚ":"\u211A","⤍":"\u290D","❳":"\u2773","}":"}","]":"]","⦌":"\u298C","⦎":"\u298E","⦐":"\u2990","ř":"\u0159","ŗ":"\u0157","⌉":"\u2309","}":"}","р":"\u0440","⤷":"\u2937","⥩":"\u2969","”":"\u201D","”":"\u201D","↳":"\u21B3","ℜ":"\u211C","ℛ":"\u211B","ℜ":"\u211C","ℝ":"\u211D","▭":"\u25AD","®":"\xAE","®":"\xAE","⥽":"\u297D","⌋":"\u230B","𝔯":"\u{1D52F}","⇁":"\u21C1","⇀":"\u21C0","⥬":"\u296C","ρ":"\u03C1","ϱ":"\u03F1","→":"\u2192","↣":"\u21A3","⇁":"\u21C1","⇀":"\u21C0","⇄":"\u21C4","⇌":"\u21CC","⇉":"\u21C9","↝":"\u219D","⋌":"\u22CC","˚":"\u02DA","≓":"\u2253","⇄":"\u21C4","⇌":"\u21CC","‏":"\u200F","⎱":"\u23B1","⎱":"\u23B1","⫮":"\u2AEE","⟭":"\u27ED","⇾":"\u21FE","⟧":"\u27E7","⦆":"\u2986","𝕣":"\u{1D563}","⨮":"\u2A2E","⨵":"\u2A35",")":")","⦔":"\u2994","⨒":"\u2A12","⇉":"\u21C9","›":"\u203A","𝓇":"\u{1D4C7}","↱":"\u21B1","]":"]","’":"\u2019","’":"\u2019","⋌":"\u22CC","⋊":"\u22CA","▹":"\u25B9","⊵":"\u22B5","▸":"\u25B8","⧎":"\u29CE","⥨":"\u2968","℞":"\u211E","ś":"\u015B","‚":"\u201A","≻":"\u227B","⪴":"\u2AB4","⪸":"\u2AB8","š":"\u0161","≽":"\u227D","⪰":"\u2AB0","ş":"\u015F","ŝ":"\u015D","⪶":"\u2AB6","⪺":"\u2ABA","⋩":"\u22E9","⨓":"\u2A13","≿":"\u227F","с":"\u0441","⋅":"\u22C5","⊡":"\u22A1","⩦":"\u2A66","⇘":"\u21D8","⤥":"\u2925","↘":"\u2198","↘":"\u2198","§":"\xA7","§":"\xA7",";":";","⤩":"\u2929","∖":"\u2216","∖":"\u2216","✶":"\u2736","𝔰":"\u{1D530}","⌢":"\u2322","♯":"\u266F","щ":"\u0449","ш":"\u0448","∣":"\u2223","∥":"\u2225","­":"\xAD","­":"\xAD","σ":"\u03C3","ς":"\u03C2","ς":"\u03C2","∼":"\u223C","⩪":"\u2A6A","≃":"\u2243","≃":"\u2243","⪞":"\u2A9E","⪠":"\u2AA0","⪝":"\u2A9D","⪟":"\u2A9F","≆":"\u2246","⨤":"\u2A24","⥲":"\u2972","←":"\u2190","∖":"\u2216","⨳":"\u2A33","⧤":"\u29E4","∣":"\u2223","⌣":"\u2323","⪪":"\u2AAA","⪬":"\u2AAC","⪬︀":"\u2AAC\uFE00","ь":"\u044C","/":"/","⧄":"\u29C4","⌿":"\u233F","𝕤":"\u{1D564}","♠":"\u2660","♠":"\u2660","∥":"\u2225","⊓":"\u2293","⊓︀":"\u2293\uFE00","⊔":"\u2294","⊔︀":"\u2294\uFE00","⊏":"\u228F","⊑":"\u2291","⊏":"\u228F","⊑":"\u2291","⊐":"\u2290","⊒":"\u2292","⊐":"\u2290","⊒":"\u2292","□":"\u25A1","□":"\u25A1","▪":"\u25AA","▪":"\u25AA","→":"\u2192","𝓈":"\u{1D4C8}","∖":"\u2216","⌣":"\u2323","⋆":"\u22C6","☆":"\u2606","★":"\u2605","ϵ":"\u03F5","ϕ":"\u03D5","¯":"\xAF","⊂":"\u2282","⫅":"\u2AC5","⪽":"\u2ABD","⊆":"\u2286","⫃":"\u2AC3","⫁":"\u2AC1","⫋":"\u2ACB","⊊":"\u228A","⪿":"\u2ABF","⥹":"\u2979","⊂":"\u2282","⊆":"\u2286","⫅":"\u2AC5","⊊":"\u228A","⫋":"\u2ACB","⫇":"\u2AC7","⫕":"\u2AD5","⫓":"\u2AD3","≻":"\u227B","⪸":"\u2AB8","≽":"\u227D","⪰":"\u2AB0","⪺":"\u2ABA","⪶":"\u2AB6","⋩":"\u22E9","≿":"\u227F","∑":"\u2211","♪":"\u266A","¹":"\xB9","¹":"\xB9","²":"\xB2","²":"\xB2","³":"\xB3","³":"\xB3","⊃":"\u2283","⫆":"\u2AC6","⪾":"\u2ABE","⫘":"\u2AD8","⊇":"\u2287","⫄":"\u2AC4","⟉":"\u27C9","⫗":"\u2AD7","⥻":"\u297B","⫂":"\u2AC2","⫌":"\u2ACC","⊋":"\u228B","⫀":"\u2AC0","⊃":"\u2283","⊇":"\u2287","⫆":"\u2AC6","⊋":"\u228B","⫌":"\u2ACC","⫈":"\u2AC8","⫔":"\u2AD4","⫖":"\u2AD6","⇙":"\u21D9","⤦":"\u2926","↙":"\u2199","↙":"\u2199","⤪":"\u292A","ß":"\xDF","ß":"\xDF","⌖":"\u2316","τ":"\u03C4","⎴":"\u23B4","ť":"\u0165","ţ":"\u0163","т":"\u0442","⃛":"\u20DB","⌕":"\u2315","𝔱":"\u{1D531}","∴":"\u2234","∴":"\u2234","θ":"\u03B8","ϑ":"\u03D1","ϑ":"\u03D1","≈":"\u2248","∼":"\u223C"," ":"\u2009","≈":"\u2248","∼":"\u223C","þ":"\xFE","þ":"\xFE","˜":"\u02DC","×":"\xD7","×":"\xD7","⊠":"\u22A0","⨱":"\u2A31","⨰":"\u2A30","∭":"\u222D","⤨":"\u2928","⊤":"\u22A4","⌶":"\u2336","⫱":"\u2AF1","𝕥":"\u{1D565}","⫚":"\u2ADA","⤩":"\u2929","‴":"\u2034","™":"\u2122","▵":"\u25B5","▿":"\u25BF","◃":"\u25C3","⊴":"\u22B4","≜":"\u225C","▹":"\u25B9","⊵":"\u22B5","◬":"\u25EC","≜":"\u225C","⨺":"\u2A3A","⨹":"\u2A39","⧍":"\u29CD","⨻":"\u2A3B","⏢":"\u23E2","𝓉":"\u{1D4C9}","ц":"\u0446","ћ":"\u045B","ŧ":"\u0167","≬":"\u226C","↞":"\u219E","↠":"\u21A0","⇑":"\u21D1","⥣":"\u2963","ú":"\xFA","ú":"\xFA","↑":"\u2191","ў":"\u045E","ŭ":"\u016D","û":"\xFB","û":"\xFB","у":"\u0443","⇅":"\u21C5","ű":"\u0171","⥮":"\u296E","⥾":"\u297E","𝔲":"\u{1D532}","ù":"\xF9","ù":"\xF9","↿":"\u21BF","↾":"\u21BE","▀":"\u2580","⌜":"\u231C","⌜":"\u231C","⌏":"\u230F","◸":"\u25F8","ū":"\u016B","¨":"\xA8","¨":"\xA8","ų":"\u0173","𝕦":"\u{1D566}","↑":"\u2191","↕":"\u2195","↿":"\u21BF","↾":"\u21BE","⊎":"\u228E","υ":"\u03C5","ϒ":"\u03D2","υ":"\u03C5","⇈":"\u21C8","⌝":"\u231D","⌝":"\u231D","⌎":"\u230E","ů":"\u016F","◹":"\u25F9","𝓊":"\u{1D4CA}","⋰":"\u22F0","ũ":"\u0169","▵":"\u25B5","▴":"\u25B4","⇈":"\u21C8","ü":"\xFC","ü":"\xFC","⦧":"\u29A7","⇕":"\u21D5","⫨":"\u2AE8","⫩":"\u2AE9","⊨":"\u22A8","⦜":"\u299C","ϵ":"\u03F5","ϰ":"\u03F0","∅":"\u2205","ϕ":"\u03D5","ϖ":"\u03D6","∝":"\u221D","↕":"\u2195","ϱ":"\u03F1","ς":"\u03C2","⊊︀":"\u228A\uFE00","⫋︀":"\u2ACB\uFE00","⊋︀":"\u228B\uFE00","⫌︀":"\u2ACC\uFE00","ϑ":"\u03D1","⊲":"\u22B2","⊳":"\u22B3","в":"\u0432","⊢":"\u22A2","∨":"\u2228","⊻":"\u22BB","≚":"\u225A","⋮":"\u22EE","|":"|","|":"|","𝔳":"\u{1D533}","⊲":"\u22B2","⊂⃒":"\u2282\u20D2","⊃⃒":"\u2283\u20D2","𝕧":"\u{1D567}","∝":"\u221D","⊳":"\u22B3","𝓋":"\u{1D4CB}","⫋︀":"\u2ACB\uFE00","⊊︀":"\u228A\uFE00","⫌︀":"\u2ACC\uFE00","⊋︀":"\u228B\uFE00","⦚":"\u299A","ŵ":"\u0175","⩟":"\u2A5F","∧":"\u2227","≙":"\u2259","℘":"\u2118","𝔴":"\u{1D534}","𝕨":"\u{1D568}","℘":"\u2118","≀":"\u2240","≀":"\u2240","𝓌":"\u{1D4CC}","⋂":"\u22C2","◯":"\u25EF","⋃":"\u22C3","▽":"\u25BD","𝔵":"\u{1D535}","⟺":"\u27FA","⟷":"\u27F7","ξ":"\u03BE","⟸":"\u27F8","⟵":"\u27F5","⟼":"\u27FC","⋻":"\u22FB","⨀":"\u2A00","𝕩":"\u{1D569}","⨁":"\u2A01","⨂":"\u2A02","⟹":"\u27F9","⟶":"\u27F6","𝓍":"\u{1D4CD}","⨆":"\u2A06","⨄":"\u2A04","△":"\u25B3","⋁":"\u22C1","⋀":"\u22C0","ý":"\xFD","ý":"\xFD","я":"\u044F","ŷ":"\u0177","ы":"\u044B","¥":"\xA5","¥":"\xA5","𝔶":"\u{1D536}","ї":"\u0457","𝕪":"\u{1D56A}","𝓎":"\u{1D4CE}","ю":"\u044E","ÿ":"\xFF","ÿ":"\xFF","ź":"\u017A","ž":"\u017E","з":"\u0437","ż":"\u017C","ℨ":"\u2128","ζ":"\u03B6","𝔷":"\u{1D537}","ж":"\u0436","⇝":"\u21DD","𝕫":"\u{1D56B}","𝓏":"\u{1D4CF}","‍":"\u200D","‌":"\u200C"},characters:{\u00C6:"Æ","&":"&",\u00C1:"Á",\u0102:"Ă",\u00C2:"Â",\u0410:"А","\u{1D504}":"𝔄",\u00C0:"À",\u0391:"Α",\u0100:"Ā","\u2A53":"⩓",\u0104:"Ą","\u{1D538}":"𝔸","\u2061":"⁡",\u00C5:"Å","\u{1D49C}":"𝒜","\u2254":"≔",\u00C3:"Ã",\u00C4:"Ä","\u2216":"∖","\u2AE7":"⫧","\u2306":"⌆",\u0411:"Б","\u2235":"∵",\u212C:"ℬ",\u0392:"Β","\u{1D505}":"𝔅","\u{1D539}":"𝔹","\u02D8":"˘","\u224E":"≎",\u0427:"Ч","\xA9":"©",\u0106:"Ć","\u22D2":"⋒","\u2145":"ⅅ",\u212D:"ℭ",\u010C:"Č",\u00C7:"Ç",\u0108:"Ĉ","\u2230":"∰",\u010A:"Ċ","\xB8":"¸","\xB7":"·",\u03A7:"Χ","\u2299":"⊙","\u2296":"⊖","\u2295":"⊕","\u2297":"⊗","\u2232":"∲","\u201D":"”","\u2019":"’","\u2237":"∷","\u2A74":"⩴","\u2261":"≡","\u222F":"∯","\u222E":"∮",\u2102:"ℂ","\u2210":"∐","\u2233":"∳","\u2A2F":"⨯","\u{1D49E}":"𝒞","\u22D3":"⋓","\u224D":"≍","\u2911":"⤑",\u0402:"Ђ",\u0405:"Ѕ",\u040F:"Џ","\u2021":"‡","\u21A1":"↡","\u2AE4":"⫤",\u010E:"Ď",\u0414:"Д","\u2207":"∇",\u0394:"Δ","\u{1D507}":"𝔇","\xB4":"´","\u02D9":"˙","\u02DD":"˝","`":"`","\u02DC":"˜","\u22C4":"⋄","\u2146":"ⅆ","\u{1D53B}":"𝔻","\xA8":"¨","\u20DC":"⃜","\u2250":"≐","\u21D3":"⇓","\u21D0":"⇐","\u21D4":"⇔","\u27F8":"⟸","\u27FA":"⟺","\u27F9":"⟹","\u21D2":"⇒","\u22A8":"⊨","\u21D1":"⇑","\u21D5":"⇕","\u2225":"∥","\u2193":"↓","\u2913":"⤓","\u21F5":"⇵","\u0311":"̑","\u2950":"⥐","\u295E":"⥞","\u21BD":"↽","\u2956":"⥖","\u295F":"⥟","\u21C1":"⇁","\u2957":"⥗","\u22A4":"⊤","\u21A7":"↧","\u{1D49F}":"𝒟",\u0110:"Đ",\u014A:"Ŋ",\u00D0:"Ð",\u00C9:"É",\u011A:"Ě",\u00CA:"Ê",\u042D:"Э",\u0116:"Ė","\u{1D508}":"𝔈",\u00C8:"È","\u2208":"∈",\u0112:"Ē","\u25FB":"◻","\u25AB":"▫",\u0118:"Ę","\u{1D53C}":"𝔼",\u0395:"Ε","\u2A75":"⩵","\u2242":"≂","\u21CC":"⇌",\u2130:"ℰ","\u2A73":"⩳",\u0397:"Η",\u00CB:"Ë","\u2203":"∃","\u2147":"ⅇ",\u0424:"Ф","\u{1D509}":"𝔉","\u25FC":"◼","\u25AA":"▪","\u{1D53D}":"𝔽","\u2200":"∀",\u2131:"ℱ",\u0403:"Ѓ",">":">",\u0393:"Γ",\u03DC:"Ϝ",\u011E:"Ğ",\u0122:"Ģ",\u011C:"Ĝ",\u0413:"Г",\u0120:"Ġ","\u{1D50A}":"𝔊","\u22D9":"⋙","\u{1D53E}":"𝔾","\u2265":"≥","\u22DB":"⋛","\u2267":"≧","\u2AA2":"⪢","\u2277":"≷","\u2A7E":"⩾","\u2273":"≳","\u{1D4A2}":"𝒢","\u226B":"≫",\u042A:"Ъ","\u02C7":"ˇ","^":"^",\u0124:"Ĥ",\u210C:"ℌ",\u210B:"ℋ",\u210D:"ℍ","\u2500":"─",\u0126:"Ħ","\u224F":"≏",\u0415:"Е",\u0132:"IJ",\u0401:"Ё",\u00CD:"Í",\u00CE:"Î",\u0418:"И",\u0130:"İ",\u2111:"ℑ",\u00CC:"Ì",\u012A:"Ī","\u2148":"ⅈ","\u222C":"∬","\u222B":"∫","\u22C2":"⋂","\u2063":"⁣","\u2062":"⁢",\u012E:"Į","\u{1D540}":"𝕀",\u0399:"Ι",\u2110:"ℐ",\u0128:"Ĩ",\u0406:"І",\u00CF:"Ï",\u0134:"Ĵ",\u0419:"Й","\u{1D50D}":"𝔍","\u{1D541}":"𝕁","\u{1D4A5}":"𝒥",\u0408:"Ј",\u0404:"Є",\u0425:"Х",\u040C:"Ќ",\u039A:"Κ",\u0136:"Ķ",\u041A:"К","\u{1D50E}":"𝔎","\u{1D542}":"𝕂","\u{1D4A6}":"𝒦",\u0409:"Љ","<":"<",\u0139:"Ĺ",\u039B:"Λ","\u27EA":"⟪",\u2112:"ℒ","\u219E":"↞",\u013D:"Ľ",\u013B:"Ļ",\u041B:"Л","\u27E8":"⟨","\u2190":"←","\u21E4":"⇤","\u21C6":"⇆","\u2308":"⌈","\u27E6":"⟦","\u2961":"⥡","\u21C3":"⇃","\u2959":"⥙","\u230A":"⌊","\u2194":"↔","\u294E":"⥎","\u22A3":"⊣","\u21A4":"↤","\u295A":"⥚","\u22B2":"⊲","\u29CF":"⧏","\u22B4":"⊴","\u2951":"⥑","\u2960":"⥠","\u21BF":"↿","\u2958":"⥘","\u21BC":"↼","\u2952":"⥒","\u22DA":"⋚","\u2266":"≦","\u2276":"≶","\u2AA1":"⪡","\u2A7D":"⩽","\u2272":"≲","\u{1D50F}":"𝔏","\u22D8":"⋘","\u21DA":"⇚",\u013F:"Ŀ","\u27F5":"⟵","\u27F7":"⟷","\u27F6":"⟶","\u{1D543}":"𝕃","\u2199":"↙","\u2198":"↘","\u21B0":"↰",\u0141:"Ł","\u226A":"≪","\u2905":"⤅",\u041C:"М","\u205F":" ",\u2133:"ℳ","\u{1D510}":"𝔐","\u2213":"∓","\u{1D544}":"𝕄",\u039C:"Μ",\u040A:"Њ",\u0143:"Ń",\u0147:"Ň",\u0145:"Ņ",\u041D:"Н","\u200B":"​","\n":" ","\u{1D511}":"𝔑","\u2060":"⁠","\xA0":" ",\u2115:"ℕ","\u2AEC":"⫬","\u2262":"≢","\u226D":"≭","\u2226":"∦","\u2209":"∉","\u2260":"≠","\u2242\u0338":"≂̸","\u2204":"∄","\u226F":"≯","\u2271":"≱","\u2267\u0338":"≧̸","\u226B\u0338":"≫̸","\u2279":"≹","\u2A7E\u0338":"⩾̸","\u2275":"≵","\u224E\u0338":"≎̸","\u224F\u0338":"≏̸","\u22EA":"⋪","\u29CF\u0338":"⧏̸","\u22EC":"⋬","\u226E":"≮","\u2270":"≰","\u2278":"≸","\u226A\u0338":"≪̸","\u2A7D\u0338":"⩽̸","\u2274":"≴","\u2AA2\u0338":"⪢̸","\u2AA1\u0338":"⪡̸","\u2280":"⊀","\u2AAF\u0338":"⪯̸","\u22E0":"⋠","\u220C":"∌","\u22EB":"⋫","\u29D0\u0338":"⧐̸","\u22ED":"⋭","\u228F\u0338":"⊏̸","\u22E2":"⋢","\u2290\u0338":"⊐̸","\u22E3":"⋣","\u2282\u20D2":"⊂⃒","\u2288":"⊈","\u2281":"⊁","\u2AB0\u0338":"⪰̸","\u22E1":"⋡","\u227F\u0338":"≿̸","\u2283\u20D2":"⊃⃒","\u2289":"⊉","\u2241":"≁","\u2244":"≄","\u2247":"≇","\u2249":"≉","\u2224":"∤","\u{1D4A9}":"𝒩",\u00D1:"Ñ",\u039D:"Ν",\u0152:"Œ",\u00D3:"Ó",\u00D4:"Ô",\u041E:"О",\u0150:"Ő","\u{1D512}":"𝔒",\u00D2:"Ò",\u014C:"Ō",\u03A9:"Ω",\u039F:"Ο","\u{1D546}":"𝕆","\u201C":"“","\u2018":"‘","\u2A54":"⩔","\u{1D4AA}":"𝒪",\u00D8:"Ø",\u00D5:"Õ","\u2A37":"⨷",\u00D6:"Ö","\u203E":"‾","\u23DE":"⏞","\u23B4":"⎴","\u23DC":"⏜","\u2202":"∂",\u041F:"П","\u{1D513}":"𝔓",\u03A6:"Φ",\u03A0:"Π","\xB1":"±",\u2119:"ℙ","\u2ABB":"⪻","\u227A":"≺","\u2AAF":"⪯","\u227C":"≼","\u227E":"≾","\u2033":"″","\u220F":"∏","\u221D":"∝","\u{1D4AB}":"𝒫",\u03A8:"Ψ",'"':""","\u{1D514}":"𝔔",\u211A:"ℚ","\u{1D4AC}":"𝒬","\u2910":"⤐","\xAE":"®",\u0154:"Ŕ","\u27EB":"⟫","\u21A0":"↠","\u2916":"⤖",\u0158:"Ř",\u0156:"Ŗ",\u0420:"Р",\u211C:"ℜ","\u220B":"∋","\u21CB":"⇋","\u296F":"⥯",\u03A1:"Ρ","\u27E9":"⟩","\u2192":"→","\u21E5":"⇥","\u21C4":"⇄","\u2309":"⌉","\u27E7":"⟧","\u295D":"⥝","\u21C2":"⇂","\u2955":"⥕","\u230B":"⌋","\u22A2":"⊢","\u21A6":"↦","\u295B":"⥛","\u22B3":"⊳","\u29D0":"⧐","\u22B5":"⊵","\u294F":"⥏","\u295C":"⥜","\u21BE":"↾","\u2954":"⥔","\u21C0":"⇀","\u2953":"⥓",\u211D:"ℝ","\u2970":"⥰","\u21DB":"⇛",\u211B:"ℛ","\u21B1":"↱","\u29F4":"⧴",\u0429:"Щ",\u0428:"Ш",\u042C:"Ь",\u015A:"Ś","\u2ABC":"⪼",\u0160:"Š",\u015E:"Ş",\u015C:"Ŝ",\u0421:"С","\u{1D516}":"𝔖","\u2191":"↑",\u03A3:"Σ","\u2218":"∘","\u{1D54A}":"𝕊","\u221A":"√","\u25A1":"□","\u2293":"⊓","\u228F":"⊏","\u2291":"⊑","\u2290":"⊐","\u2292":"⊒","\u2294":"⊔","\u{1D4AE}":"𝒮","\u22C6":"⋆","\u22D0":"⋐","\u2286":"⊆","\u227B":"≻","\u2AB0":"⪰","\u227D":"≽","\u227F":"≿","\u2211":"∑","\u22D1":"⋑","\u2283":"⊃","\u2287":"⊇",\u00DE:"Þ","\u2122":"™",\u040B:"Ћ",\u0426:"Ц"," ":" ",\u03A4:"Τ",\u0164:"Ť",\u0162:"Ţ",\u0422:"Т","\u{1D517}":"𝔗","\u2234":"∴",\u0398:"Θ","\u205F\u200A":"  ","\u2009":" ","\u223C":"∼","\u2243":"≃","\u2245":"≅","\u2248":"≈","\u{1D54B}":"𝕋","\u20DB":"⃛","\u{1D4AF}":"𝒯",\u0166:"Ŧ",\u00DA:"Ú","\u219F":"↟","\u2949":"⥉",\u040E:"Ў",\u016C:"Ŭ",\u00DB:"Û",\u0423:"У",\u0170:"Ű","\u{1D518}":"𝔘",\u00D9:"Ù",\u016A:"Ū",_:"_","\u23DF":"⏟","\u23B5":"⎵","\u23DD":"⏝","\u22C3":"⋃","\u228E":"⊎",\u0172:"Ų","\u{1D54C}":"𝕌","\u2912":"⤒","\u21C5":"⇅","\u2195":"↕","\u296E":"⥮","\u22A5":"⊥","\u21A5":"↥","\u2196":"↖","\u2197":"↗",\u03D2:"ϒ",\u03A5:"Υ",\u016E:"Ů","\u{1D4B0}":"𝒰",\u0168:"Ũ",\u00DC:"Ü","\u22AB":"⊫","\u2AEB":"⫫",\u0412:"В","\u22A9":"⊩","\u2AE6":"⫦","\u22C1":"⋁","\u2016":"‖","\u2223":"∣","|":"|","\u2758":"❘","\u2240":"≀","\u200A":" ","\u{1D519}":"𝔙","\u{1D54D}":"𝕍","\u{1D4B1}":"𝒱","\u22AA":"⊪",\u0174:"Ŵ","\u22C0":"⋀","\u{1D51A}":"𝔚","\u{1D54E}":"𝕎","\u{1D4B2}":"𝒲","\u{1D51B}":"𝔛",\u039E:"Ξ","\u{1D54F}":"𝕏","\u{1D4B3}":"𝒳",\u042F:"Я",\u0407:"Ї",\u042E:"Ю",\u00DD:"Ý",\u0176:"Ŷ",\u042B:"Ы","\u{1D51C}":"𝔜","\u{1D550}":"𝕐","\u{1D4B4}":"𝒴",\u0178:"Ÿ",\u0416:"Ж",\u0179:"Ź",\u017D:"Ž",\u0417:"З",\u017B:"Ż",\u0396:"Ζ",\u2128:"ℨ",\u2124:"ℤ","\u{1D4B5}":"𝒵",\u00E1:"á",\u0103:"ă","\u223E":"∾","\u223E\u0333":"∾̳","\u223F":"∿",\u00E2:"â",\u0430:"а",\u00E6:"æ","\u{1D51E}":"𝔞",\u00E0:"à",\u2135:"ℵ",\u03B1:"α",\u0101:"ā","\u2A3F":"⨿","\u2227":"∧","\u2A55":"⩕","\u2A5C":"⩜","\u2A58":"⩘","\u2A5A":"⩚","\u2220":"∠","\u29A4":"⦤","\u2221":"∡","\u29A8":"⦨","\u29A9":"⦩","\u29AA":"⦪","\u29AB":"⦫","\u29AC":"⦬","\u29AD":"⦭","\u29AE":"⦮","\u29AF":"⦯","\u221F":"∟","\u22BE":"⊾","\u299D":"⦝","\u2222":"∢","\u237C":"⍼",\u0105:"ą","\u{1D552}":"𝕒","\u2A70":"⩰","\u2A6F":"⩯","\u224A":"≊","\u224B":"≋","'":"'",\u00E5:"å","\u{1D4B6}":"𝒶","*":"*",\u00E3:"ã",\u00E4:"ä","\u2A11":"⨑","\u2AED":"⫭","\u224C":"≌","\u03F6":"϶","\u2035":"‵","\u223D":"∽","\u22CD":"⋍","\u22BD":"⊽","\u2305":"⌅","\u23B6":"⎶",\u0431:"б","\u201E":"„","\u29B0":"⦰",\u03B2:"β",\u2136:"ℶ","\u226C":"≬","\u{1D51F}":"𝔟","\u25EF":"◯","\u2A00":"⨀","\u2A01":"⨁","\u2A02":"⨂","\u2A06":"⨆","\u2605":"★","\u25BD":"▽","\u25B3":"△","\u2A04":"⨄","\u290D":"⤍","\u29EB":"⧫","\u25B4":"▴","\u25BE":"▾","\u25C2":"◂","\u25B8":"▸","\u2423":"␣","\u2592":"▒","\u2591":"░","\u2593":"▓","\u2588":"█","=\u20E5":"=⃥","\u2261\u20E5":"≡⃥","\u2310":"⌐","\u{1D553}":"𝕓","\u22C8":"⋈","\u2557":"╗","\u2554":"╔","\u2556":"╖","\u2553":"╓","\u2550":"═","\u2566":"╦","\u2569":"╩","\u2564":"╤","\u2567":"╧","\u255D":"╝","\u255A":"╚","\u255C":"╜","\u2559":"╙","\u2551":"║","\u256C":"╬","\u2563":"╣","\u2560":"╠","\u256B":"╫","\u2562":"╢","\u255F":"╟","\u29C9":"⧉","\u2555":"╕","\u2552":"╒","\u2510":"┐","\u250C":"┌","\u2565":"╥","\u2568":"╨","\u252C":"┬","\u2534":"┴","\u229F":"⊟","\u229E":"⊞","\u22A0":"⊠","\u255B":"╛","\u2558":"╘","\u2518":"┘","\u2514":"└","\u2502":"│","\u256A":"╪","\u2561":"╡","\u255E":"╞","\u253C":"┼","\u2524":"┤","\u251C":"├","\xA6":"¦","\u{1D4B7}":"𝒷","\u204F":"⁏","\\":"\","\u29C5":"⧅","\u27C8":"⟈","\u2022":"•","\u2AAE":"⪮",\u0107:"ć","\u2229":"∩","\u2A44":"⩄","\u2A49":"⩉","\u2A4B":"⩋","\u2A47":"⩇","\u2A40":"⩀","\u2229\uFE00":"∩︀","\u2041":"⁁","\u2A4D":"⩍",\u010D:"č",\u00E7:"ç",\u0109:"ĉ","\u2A4C":"⩌","\u2A50":"⩐",\u010B:"ċ","\u29B2":"⦲","\xA2":"¢","\u{1D520}":"𝔠",\u0447:"ч","\u2713":"✓",\u03C7:"χ","\u25CB":"○","\u29C3":"⧃","\u02C6":"ˆ","\u2257":"≗","\u21BA":"↺","\u21BB":"↻","\u24C8":"Ⓢ","\u229B":"⊛","\u229A":"⊚","\u229D":"⊝","\u2A10":"⨐","\u2AEF":"⫯","\u29C2":"⧂","\u2663":"♣",":":":",",":",","@":"@","\u2201":"∁","\u2A6D":"⩭","\u{1D554}":"𝕔","\u2117":"℗","\u21B5":"↵","\u2717":"✗","\u{1D4B8}":"𝒸","\u2ACF":"⫏","\u2AD1":"⫑","\u2AD0":"⫐","\u2AD2":"⫒","\u22EF":"⋯","\u2938":"⤸","\u2935":"⤵","\u22DE":"⋞","\u22DF":"⋟","\u21B6":"↶","\u293D":"⤽","\u222A":"∪","\u2A48":"⩈","\u2A46":"⩆","\u2A4A":"⩊","\u228D":"⊍","\u2A45":"⩅","\u222A\uFE00":"∪︀","\u21B7":"↷","\u293C":"⤼","\u22CE":"⋎","\u22CF":"⋏","\xA4":"¤","\u2231":"∱","\u232D":"⌭","\u2965":"⥥","\u2020":"†",\u2138:"ℸ","\u2010":"‐","\u290F":"⤏",\u010F:"ď",\u0434:"д","\u21CA":"⇊","\u2A77":"⩷","\xB0":"°",\u03B4:"δ","\u29B1":"⦱","\u297F":"⥿","\u{1D521}":"𝔡","\u2666":"♦",\u03DD:"ϝ","\u22F2":"⋲","\xF7":"÷","\u22C7":"⋇",\u0452:"ђ","\u231E":"⌞","\u230D":"⌍",$:"$","\u{1D555}":"𝕕","\u2251":"≑","\u2238":"∸","\u2214":"∔","\u22A1":"⊡","\u231F":"⌟","\u230C":"⌌","\u{1D4B9}":"𝒹",\u0455:"ѕ","\u29F6":"⧶",\u0111:"đ","\u22F1":"⋱","\u25BF":"▿","\u29A6":"⦦",\u045F:"џ","\u27FF":"⟿",\u00E9:"é","\u2A6E":"⩮",\u011B:"ě","\u2256":"≖",\u00EA:"ê","\u2255":"≕",\u044D:"э",\u0117:"ė","\u2252":"≒","\u{1D522}":"𝔢","\u2A9A":"⪚",\u00E8:"è","\u2A96":"⪖","\u2A98":"⪘","\u2A99":"⪙","\u23E7":"⏧",\u2113:"ℓ","\u2A95":"⪕","\u2A97":"⪗",\u0113:"ē","\u2205":"∅","\u2004":" ","\u2005":" ","\u2003":" ",\u014B:"ŋ","\u2002":" ",\u0119:"ę","\u{1D556}":"𝕖","\u22D5":"⋕","\u29E3":"⧣","\u2A71":"⩱",\u03B5:"ε","\u03F5":"ϵ","=":"=","\u225F":"≟","\u2A78":"⩸","\u29E5":"⧥","\u2253":"≓","\u2971":"⥱",\u212F:"ℯ",\u03B7:"η",\u00F0:"ð",\u00EB:"ë","\u20AC":"€","!":"!",\u0444:"ф","\u2640":"♀",\uFB03:"ffi",\uFB00:"ff",\uFB04:"ffl","\u{1D523}":"𝔣",\uFB01:"fi",fj:"fj","\u266D":"♭",\uFB02:"fl","\u25B1":"▱",\u0192:"ƒ","\u{1D557}":"𝕗","\u22D4":"⋔","\u2AD9":"⫙","\u2A0D":"⨍","\xBD":"½","\u2153":"⅓","\xBC":"¼","\u2155":"⅕","\u2159":"⅙","\u215B":"⅛","\u2154":"⅔","\u2156":"⅖","\xBE":"¾","\u2157":"⅗","\u215C":"⅜","\u2158":"⅘","\u215A":"⅚","\u215D":"⅝","\u215E":"⅞","\u2044":"⁄","\u2322":"⌢","\u{1D4BB}":"𝒻","\u2A8C":"⪌",\u01F5:"ǵ",\u03B3:"γ","\u2A86":"⪆",\u011F:"ğ",\u011D:"ĝ",\u0433:"г",\u0121:"ġ","\u2AA9":"⪩","\u2A80":"⪀","\u2A82":"⪂","\u2A84":"⪄","\u22DB\uFE00":"⋛︀","\u2A94":"⪔","\u{1D524}":"𝔤",\u2137:"ℷ",\u0453:"ѓ","\u2A92":"⪒","\u2AA5":"⪥","\u2AA4":"⪤","\u2269":"≩","\u2A8A":"⪊","\u2A88":"⪈","\u22E7":"⋧","\u{1D558}":"𝕘",\u210A:"ℊ","\u2A8E":"⪎","\u2A90":"⪐","\u2AA7":"⪧","\u2A7A":"⩺","\u22D7":"⋗","\u2995":"⦕","\u2A7C":"⩼","\u2978":"⥸","\u2269\uFE00":"≩︀",\u044A:"ъ","\u2948":"⥈","\u21AD":"↭",\u210F:"ℏ",\u0125:"ĥ","\u2665":"♥","\u2026":"…","\u22B9":"⊹","\u{1D525}":"𝔥","\u2925":"⤥","\u2926":"⤦","\u21FF":"⇿","\u223B":"∻","\u21A9":"↩","\u21AA":"↪","\u{1D559}":"𝕙","\u2015":"―","\u{1D4BD}":"𝒽",\u0127:"ħ","\u2043":"⁃",\u00ED:"í",\u00EE:"î",\u0438:"и",\u0435:"е","\xA1":"¡","\u{1D526}":"𝔦",\u00EC:"ì","\u2A0C":"⨌","\u222D":"∭","\u29DC":"⧜","\u2129":"℩",\u0133:"ij",\u012B:"ī",\u0131:"ı","\u22B7":"⊷",\u01B5:"Ƶ","\u2105":"℅","\u221E":"∞","\u29DD":"⧝","\u22BA":"⊺","\u2A17":"⨗","\u2A3C":"⨼",\u0451:"ё",\u012F:"į","\u{1D55A}":"𝕚",\u03B9:"ι","\xBF":"¿","\u{1D4BE}":"𝒾","\u22F9":"⋹","\u22F5":"⋵","\u22F4":"⋴","\u22F3":"⋳",\u0129:"ĩ",\u0456:"і",\u00EF:"ï",\u0135:"ĵ",\u0439:"й","\u{1D527}":"𝔧","\u0237":"ȷ","\u{1D55B}":"𝕛","\u{1D4BF}":"𝒿",\u0458:"ј",\u0454:"є",\u03BA:"κ",\u03F0:"ϰ",\u0137:"ķ",\u043A:"к","\u{1D528}":"𝔨",\u0138:"ĸ",\u0445:"х",\u045C:"ќ","\u{1D55C}":"𝕜","\u{1D4C0}":"𝓀","\u291B":"⤛","\u290E":"⤎","\u2A8B":"⪋","\u2962":"⥢",\u013A:"ĺ","\u29B4":"⦴",\u03BB:"λ","\u2991":"⦑","\u2A85":"⪅","\xAB":"«","\u291F":"⤟","\u291D":"⤝","\u21AB":"↫","\u2939":"⤹","\u2973":"⥳","\u21A2":"↢","\u2AAB":"⪫","\u2919":"⤙","\u2AAD":"⪭","\u2AAD\uFE00":"⪭︀","\u290C":"⤌","\u2772":"❲","{":"{","[":"[","\u298B":"⦋","\u298F":"⦏","\u298D":"⦍",\u013E:"ľ",\u013C:"ļ",\u043B:"л","\u2936":"⤶","\u2967":"⥧","\u294B":"⥋","\u21B2":"↲","\u2264":"≤","\u21C7":"⇇","\u22CB":"⋋","\u2AA8":"⪨","\u2A7F":"⩿","\u2A81":"⪁","\u2A83":"⪃","\u22DA\uFE00":"⋚︀","\u2A93":"⪓","\u22D6":"⋖","\u297C":"⥼","\u{1D529}":"𝔩","\u2A91":"⪑","\u296A":"⥪","\u2584":"▄",\u0459:"љ","\u296B":"⥫","\u25FA":"◺",\u0140:"ŀ","\u23B0":"⎰","\u2268":"≨","\u2A89":"⪉","\u2A87":"⪇","\u22E6":"⋦","\u27EC":"⟬","\u21FD":"⇽","\u27FC":"⟼","\u21AC":"↬","\u2985":"⦅","\u{1D55D}":"𝕝","\u2A2D":"⨭","\u2A34":"⨴","\u2217":"∗","\u25CA":"◊","(":"(","\u2993":"⦓","\u296D":"⥭","\u200E":"‎","\u22BF":"⊿","\u2039":"‹","\u{1D4C1}":"𝓁","\u2A8D":"⪍","\u2A8F":"⪏","\u201A":"‚",\u0142:"ł","\u2AA6":"⪦","\u2A79":"⩹","\u22C9":"⋉","\u2976":"⥶","\u2A7B":"⩻","\u2996":"⦖","\u25C3":"◃","\u294A":"⥊","\u2966":"⥦","\u2268\uFE00":"≨︀","\u223A":"∺","\xAF":"¯","\u2642":"♂","\u2720":"✠","\u25AE":"▮","\u2A29":"⨩",\u043C:"м","\u2014":"—","\u{1D52A}":"𝔪","\u2127":"℧",\u00B5:"µ","\u2AF0":"⫰","\u2212":"−","\u2A2A":"⨪","\u2ADB":"⫛","\u22A7":"⊧","\u{1D55E}":"𝕞","\u{1D4C2}":"𝓂",\u03BC:"μ","\u22B8":"⊸","\u22D9\u0338":"⋙̸","\u226B\u20D2":"≫⃒","\u21CD":"⇍","\u21CE":"⇎","\u22D8\u0338":"⋘̸","\u226A\u20D2":"≪⃒","\u21CF":"⇏","\u22AF":"⊯","\u22AE":"⊮",\u0144:"ń","\u2220\u20D2":"∠⃒","\u2A70\u0338":"⩰̸","\u224B\u0338":"≋̸",\u0149:"ʼn","\u266E":"♮","\u2A43":"⩃",\u0148:"ň",\u0146:"ņ","\u2A6D\u0338":"⩭̸","\u2A42":"⩂",\u043D:"н","\u2013":"–","\u21D7":"⇗","\u2924":"⤤","\u2250\u0338":"≐̸","\u2928":"⤨","\u{1D52B}":"𝔫","\u21AE":"↮","\u2AF2":"⫲","\u22FC":"⋼","\u22FA":"⋺",\u045A:"њ","\u2266\u0338":"≦̸","\u219A":"↚","\u2025":"‥","\u{1D55F}":"𝕟","\xAC":"¬","\u22F9\u0338":"⋹̸","\u22F5\u0338":"⋵̸","\u22F7":"⋷","\u22F6":"⋶","\u22FE":"⋾","\u22FD":"⋽","\u2AFD\u20E5":"⫽⃥","\u2202\u0338":"∂̸","\u2A14":"⨔","\u219B":"↛","\u2933\u0338":"⤳̸","\u219D\u0338":"↝̸","\u{1D4C3}":"𝓃","\u2284":"⊄","\u2AC5\u0338":"⫅̸","\u2285":"⊅","\u2AC6\u0338":"⫆̸",\u00F1:"ñ",\u03BD:"ν","#":"#","\u2116":"№","\u2007":" ","\u22AD":"⊭","\u2904":"⤄","\u224D\u20D2":"≍⃒","\u22AC":"⊬","\u2265\u20D2":"≥⃒",">\u20D2":">⃒","\u29DE":"⧞","\u2902":"⤂","\u2264\u20D2":"≤⃒","<\u20D2":"<⃒","\u22B4\u20D2":"⊴⃒","\u2903":"⤃","\u22B5\u20D2":"⊵⃒","\u223C\u20D2":"∼⃒","\u21D6":"⇖","\u2923":"⤣","\u2927":"⤧",\u00F3:"ó",\u00F4:"ô",\u043E:"о",\u0151:"ő","\u2A38":"⨸","\u29BC":"⦼",\u0153:"œ","\u29BF":"⦿","\u{1D52C}":"𝔬","\u02DB":"˛",\u00F2:"ò","\u29C1":"⧁","\u29B5":"⦵","\u29BE":"⦾","\u29BB":"⦻","\u29C0":"⧀",\u014D:"ō",\u03C9:"ω",\u03BF:"ο","\u29B6":"⦶","\u{1D560}":"𝕠","\u29B7":"⦷","\u29B9":"⦹","\u2228":"∨","\u2A5D":"⩝",\u2134:"ℴ",\u00AA:"ª",\u00BA:"º","\u22B6":"⊶","\u2A56":"⩖","\u2A57":"⩗","\u2A5B":"⩛",\u00F8:"ø","\u2298":"⊘",\u00F5:"õ","\u2A36":"⨶",\u00F6:"ö","\u233D":"⌽","\xB6":"¶","\u2AF3":"⫳","\u2AFD":"⫽",\u043F:"п","%":"%",".":".","\u2030":"‰","\u2031":"‱","\u{1D52D}":"𝔭",\u03C6:"φ",\u03D5:"ϕ","\u260E":"☎",\u03C0:"π",\u03D6:"ϖ",\u210E:"ℎ","+":"+","\u2A23":"⨣","\u2A22":"⨢","\u2A25":"⨥","\u2A72":"⩲","\u2A26":"⨦","\u2A27":"⨧","\u2A15":"⨕","\u{1D561}":"𝕡","\xA3":"£","\u2AB3":"⪳","\u2AB7":"⪷","\u2AB9":"⪹","\u2AB5":"⪵","\u22E8":"⋨","\u2032":"′","\u232E":"⌮","\u2312":"⌒","\u2313":"⌓","\u22B0":"⊰","\u{1D4C5}":"𝓅",\u03C8:"ψ","\u2008":" ","\u{1D52E}":"𝔮","\u{1D562}":"𝕢","\u2057":"⁗","\u{1D4C6}":"𝓆","\u2A16":"⨖","?":"?","\u291C":"⤜","\u2964":"⥤","\u223D\u0331":"∽̱",\u0155:"ŕ","\u29B3":"⦳","\u2992":"⦒","\u29A5":"⦥","\xBB":"»","\u2975":"⥵","\u2920":"⤠","\u2933":"⤳","\u291E":"⤞","\u2945":"⥅","\u2974":"⥴","\u21A3":"↣","\u219D":"↝","\u291A":"⤚","\u2236":"∶","\u2773":"❳","}":"}","]":"]","\u298C":"⦌","\u298E":"⦎","\u2990":"⦐",\u0159:"ř",\u0157:"ŗ",\u0440:"р","\u2937":"⤷","\u2969":"⥩","\u21B3":"↳","\u25AD":"▭","\u297D":"⥽","\u{1D52F}":"𝔯","\u296C":"⥬",\u03C1:"ρ",\u03F1:"ϱ","\u21C9":"⇉","\u22CC":"⋌","\u02DA":"˚","\u200F":"‏","\u23B1":"⎱","\u2AEE":"⫮","\u27ED":"⟭","\u21FE":"⇾","\u2986":"⦆","\u{1D563}":"𝕣","\u2A2E":"⨮","\u2A35":"⨵",")":")","\u2994":"⦔","\u2A12":"⨒","\u203A":"›","\u{1D4C7}":"𝓇","\u22CA":"⋊","\u25B9":"▹","\u29CE":"⧎","\u2968":"⥨","\u211E":"℞",\u015B:"ś","\u2AB4":"⪴","\u2AB8":"⪸",\u0161:"š",\u015F:"ş",\u015D:"ŝ","\u2AB6":"⪶","\u2ABA":"⪺","\u22E9":"⋩","\u2A13":"⨓",\u0441:"с","\u22C5":"⋅","\u2A66":"⩦","\u21D8":"⇘","\xA7":"§",";":";","\u2929":"⤩","\u2736":"✶","\u{1D530}":"𝔰","\u266F":"♯",\u0449:"щ",\u0448:"ш","\xAD":"­",\u03C3:"σ",\u03C2:"ς","\u2A6A":"⩪","\u2A9E":"⪞","\u2AA0":"⪠","\u2A9D":"⪝","\u2A9F":"⪟","\u2246":"≆","\u2A24":"⨤","\u2972":"⥲","\u2A33":"⨳","\u29E4":"⧤","\u2323":"⌣","\u2AAA":"⪪","\u2AAC":"⪬","\u2AAC\uFE00":"⪬︀",\u044C:"ь","/":"/","\u29C4":"⧄","\u233F":"⌿","\u{1D564}":"𝕤","\u2660":"♠","\u2293\uFE00":"⊓︀","\u2294\uFE00":"⊔︀","\u{1D4C8}":"𝓈","\u2606":"☆","\u2282":"⊂","\u2AC5":"⫅","\u2ABD":"⪽","\u2AC3":"⫃","\u2AC1":"⫁","\u2ACB":"⫋","\u228A":"⊊","\u2ABF":"⪿","\u2979":"⥹","\u2AC7":"⫇","\u2AD5":"⫕","\u2AD3":"⫓","\u266A":"♪","\xB9":"¹","\xB2":"²","\xB3":"³","\u2AC6":"⫆","\u2ABE":"⪾","\u2AD8":"⫘","\u2AC4":"⫄","\u27C9":"⟉","\u2AD7":"⫗","\u297B":"⥻","\u2AC2":"⫂","\u2ACC":"⫌","\u228B":"⊋","\u2AC0":"⫀","\u2AC8":"⫈","\u2AD4":"⫔","\u2AD6":"⫖","\u21D9":"⇙","\u292A":"⤪",\u00DF:"ß","\u2316":"⌖",\u03C4:"τ",\u0165:"ť",\u0163:"ţ",\u0442:"т","\u2315":"⌕","\u{1D531}":"𝔱",\u03B8:"θ",\u03D1:"ϑ",\u00FE:"þ","\xD7":"×","\u2A31":"⨱","\u2A30":"⨰","\u2336":"⌶","\u2AF1":"⫱","\u{1D565}":"𝕥","\u2ADA":"⫚","\u2034":"‴","\u25B5":"▵","\u225C":"≜","\u25EC":"◬","\u2A3A":"⨺","\u2A39":"⨹","\u29CD":"⧍","\u2A3B":"⨻","\u23E2":"⏢","\u{1D4C9}":"𝓉",\u0446:"ц",\u045B:"ћ",\u0167:"ŧ","\u2963":"⥣",\u00FA:"ú",\u045E:"ў",\u016D:"ŭ",\u00FB:"û",\u0443:"у",\u0171:"ű","\u297E":"⥾","\u{1D532}":"𝔲",\u00F9:"ù","\u2580":"▀","\u231C":"⌜","\u230F":"⌏","\u25F8":"◸",\u016B:"ū",\u0173:"ų","\u{1D566}":"𝕦",\u03C5:"υ","\u21C8":"⇈","\u231D":"⌝","\u230E":"⌎",\u016F:"ů","\u25F9":"◹","\u{1D4CA}":"𝓊","\u22F0":"⋰",\u0169:"ũ",\u00FC:"ü","\u29A7":"⦧","\u2AE8":"⫨","\u2AE9":"⫩","\u299C":"⦜","\u228A\uFE00":"⊊︀","\u2ACB\uFE00":"⫋︀","\u228B\uFE00":"⊋︀","\u2ACC\uFE00":"⫌︀",\u0432:"в","\u22BB":"⊻","\u225A":"≚","\u22EE":"⋮","\u{1D533}":"𝔳","\u{1D567}":"𝕧","\u{1D4CB}":"𝓋","\u299A":"⦚",\u0175:"ŵ","\u2A5F":"⩟","\u2259":"≙","\u2118":"℘","\u{1D534}":"𝔴","\u{1D568}":"𝕨","\u{1D4CC}":"𝓌","\u{1D535}":"𝔵",\u03BE:"ξ","\u22FB":"⋻","\u{1D569}":"𝕩","\u{1D4CD}":"𝓍",\u00FD:"ý",\u044F:"я",\u0177:"ŷ",\u044B:"ы","\xA5":"¥","\u{1D536}":"𝔶",\u0457:"ї","\u{1D56A}":"𝕪","\u{1D4CE}":"𝓎",\u044E:"ю",\u00FF:"ÿ",\u017A:"ź",\u017E:"ž",\u0437:"з",\u017C:"ż",\u03B6:"ζ","\u{1D537}":"𝔷",\u0436:"ж","\u21DD":"⇝","\u{1D56B}":"𝕫","\u{1D4CF}":"𝓏","\u200D":"‍","\u200C":"‌"}}}});var Zb=ye(rp=>{"use strict";Object.defineProperty(rp,"__esModule",{value:!0});rp.numericUnicodeMap={0:65533,128:8364,130:8218,131:402,132:8222,133:8230,134:8224,135:8225,136:710,137:8240,138:352,139:8249,140:338,142:381,145:8216,146:8217,147:8220,148:8221,149:8226,150:8211,151:8212,152:732,153:8482,154:353,155:8250,156:339,158:382,159:376}});var Yb=ye(Ys=>{"use strict";Object.defineProperty(Ys,"__esModule",{value:!0});Ys.fromCodePoint=String.fromCodePoint||function(n){return String.fromCharCode(Math.floor((n-65536)/1024)+55296,(n-65536)%1024+56320)};Ys.getCodePoint=String.prototype.codePointAt?function(n,t){return n.codePointAt(t)}:function(n,t){return(n.charCodeAt(t)-55296)*1024+n.charCodeAt(t+1)-56320+65536};Ys.highSurrogateFrom=55296;Ys.highSurrogateTo=56319});var tx=ye(Ao=>{"use strict";var Js=Ao&&Ao.__assign||function(){return Js=Object.assign||function(n){for(var t,e=1,i=arguments.length;e'"&]/g,nonAscii:/[<>'"&\u0080-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/g,nonAsciiPrintable:/[<>'"&\x01-\x08\x11-\x15\x17-\x1F\x7f-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/g,nonAsciiPrintableOnly:/[\x01-\x08\x11-\x15\x17-\x1F\x7f-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/g,extensive:/[\x01-\x0c\x0e-\x1f\x21-\x2c\x2e-\x2f\x3a-\x40\x5b-\x60\x7b-\x7d\x7f-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/g},BF={mode:"specialChars",level:"all",numeric:"decimal"};function HF(n,t){var e=t===void 0?BF:t,i=e.mode,r=i===void 0?"specialChars":i,o=e.numeric,s=o===void 0?"decimal":o,a=e.level,c=a===void 0?"all":a;if(!n)return"";var l=VF[r],d=ap[c].characters,h=s==="hexadecimal";return _b(n,l,function(u){var f=d[u];if(!f){var p=u.length>1?Qb.getCodePoint(u,0):u.charCodeAt(0);f=(h?"&#x"+p.toString(16):"&#"+p)+";"}return f})}Ao.encode=HF;var UF={scope:"body",level:"all"},op=/&(?:#\d+|#[xX][\da-fA-F]+|[0-9a-zA-Z]+);/g,sp=/&(?:#\d+|#[xX][\da-fA-F]+|[0-9a-zA-Z]+)[;=]?/g,Jb={xml:{strict:op,attribute:sp,body:mc.bodyRegExps.xml},html4:{strict:op,attribute:sp,body:mc.bodyRegExps.html4},html5:{strict:op,attribute:sp,body:mc.bodyRegExps.html5}},zF=Js(Js({},Jb),{all:Jb.html5}),$b=String.fromCharCode,qF=$b(65533),WF={level:"all"};function ex(n,t,e,i){var r=n,o=n[n.length-1];if(e&&o==="=")r=n;else if(i&&o!==";")r=n;else{var s=t[n];if(s)r=s;else if(n[0]==="&"&&n[1]==="#"){var a=n[2],c=a=="x"||a=="X"?parseInt(n.substr(3),16):parseInt(n.substr(2));r=c>=1114111?qF:c>65535?Qb.fromCodePoint(c):$b(RF.numericUnicodeMap[c]||c)}}return r}function jF(n,t){var e=(t===void 0?WF:t).level,i=e===void 0?"all":e;return n?ex(n,ap[i].entities,!1,!1):""}Ao.decodeEntity=jF;function KF(n,t){var e=t===void 0?UF:t,i=e.level,r=i===void 0?"all":i,o=e.scope,s=o===void 0?r==="xml"?"strict":"body":o;if(!n)return"";var a=zF[r][s],c=ap[r].entities,l=s==="attribute",d=s==="strict";return _b(n,a,function(h){return ex(h,c,l,d)})}Ao.decode=KF});var rx=ye(nt=>{"use strict";Object.defineProperty(nt,"__esModule",{value:!0});nt.isBlock=nt.parse=nt.Matcher=nt.HTMLElement=nt.CommentNode=nt.TextNode=nt.AbstractNode=nt.NodeType=void 0;var Qs=tx(),Si=!1,wt;(function(n){n[n.ELEMENT_NODE=1]="ELEMENT_NODE",n[n.TEXT_NODE=3]="TEXT_NODE",n[n.COMMENT_NODE=8]="COMMENT_NODE"})(wt||(nt.NodeType=wt={}));var Oo=class{constructor(){this.childNodes=[]}get text(){return(0,Qs.decode)(this.rawText)}remove(){return this.parentNode&&this.parentNode.removeChild(this),this}};nt.AbstractNode=Oo;var Lo=class extends Oo{constructor(t){super(),this.nodeType=wt.TEXT_NODE,this.value=t}get rawText(){return this.value}get isWhitespace(){return/^(\s| )*$/.test(this.rawText)}toString(){return this.rawText}};nt.TextNode=Lo;var Zd=class extends Oo{constructor(t){super(),this.nodeType=wt.COMMENT_NODE,this.value=t}get rawText(){return this.value}toString(){return``}};nt.CommentNode=Zd;var GF={div:!0,p:!0,li:!0,td:!0,section:!0,br:!0};function _s(n){return n[n.length-1]}var ui=class extends Oo{constructor(t,e="",i=null){super(),this.tagName=t,this.rawAttrs=e,this.classNames=[],this.nodeType=wt.ELEMENT_NODE,this.rawAttrs=e,this.parentNode=i,this.childNodes=[];let r={};for(let o;o=XF.exec(e);)r[o[2]]=o[4]||o[5]||o[6];r.id&&(this.id=r.id),r.class&&(this.classNames=r.class.split(/\s+/))}removeChild(t){this.childNodes=this.childNodes.filter(e=>e!==t),t instanceof ui&&(t.parentNode=null)}exchangeChild(t,e){let i=this.childNodes.findIndex(r=>r===t);i>=0&&(this.childNodes[i]=e,t instanceof ui&&(t.parentNode=null))}get rawText(){let t="";for(let e=0;e0&&e.push(t=[]),r.childNodes.forEach(i),t.length>0&&e.push(t=[])):r.childNodes.forEach(i);else if(r.nodeType===wt.TEXT_NODE)if(r.isWhitespace)t.prependWhitespace=!0;else{let o=r.text;t.prependWhitespace&&(o=" "+o,t.prependWhitespace=!1),t.push(o)}}return i(this),e.map(function(r){return r.join("").trim().replace(/\s{2,}/g," ")}).join(` `).replace(/\s+$/,"")}get children(){return this.childNodes.filter(t=>t instanceof ui)}toString(){let t=this.tagName;if(t){let e=/^(img|br|hr|area|base|input|doctype|link|meta)$/i.test(t),i=this.rawAttrs?" "+this.rawAttrs:"";return e?`<${t}${i} />`:`<${t}${i}>${this.innerHTML}`}else return this.innerHTML}get innerHTML(){return this.childNodes.map(t=>t.toString()).join("")}set innerHTML(t){let e=cp(t);this.childNodes.forEach(i=>i.remove()),e.childNodes.forEach(i=>this.appendChild(i))}set_content(t){if(t instanceof Oo)t=[t];else if(typeof t=="string"){let e=cp(t);t=e.childNodes.length?e.childNodes:[new Lo(t)]}this.childNodes=t}get outerHTML(){return this.toString()}trimRight(t){for(let e=0;e-1&&(i.value=i.rawText.substr(0,r),this.childNodes.length=e+1)}}return this}get structure(){let t=[],e=0;function i(o){t.push(" ".repeat(e)+o)}function r(o){let s=o.id?"#"+o.id:"",a=o.classNames.length?"."+o.classNames.join("."):"";i(o.tagName+s+a),e++;for(let c=0;cthis.querySelectorAll(a.trim())).flat());return Array.from(s)}else return this.querySelectorAll(new Io(t));let e=t,i=new Set,r=[];for(this.childNodes.forEach(o=>r.push(o));r.length>0;){let o=r.shift();o.nodeType===wt.ELEMENT_NODE&&(e.advance(o)&&e.matched&&(i.add(o),e.rewind()),o.childNodes.forEach(s=>{r.push(s)}))}return Array.from(i)}querySelector(t){let e;t instanceof Io?(e=t,e.reset()):e=new Io(t);let i=[];for(let r=0;rr+(i[r]===""?"":'="'+(0,Qs.encode)(i[r])+'"')).join(" ")}removeAttribute(t){this.setAttribute(t,void 0)}setAttributes(t){t.id?this.id=t.id:t.class&&(this.classNames=t.class.split(/\s+/)),this.attributes&&(Object.keys(this.attributes).forEach(e=>delete this.attributes[e]),Object.keys(t).forEach(e=>this.attributes[e]=t[e]+"")),this.rawAttributes&&(Object.keys(this.rawAttributes).forEach(e=>delete this.rawAttributes[e]),Object.keys(t).forEach(e=>this.rawAttributes[e]=(0,Qs.encode)(t[e]+""))),this.rawAttrs=Object.keys(t).map(e=>e+(t[e]===""?"":'="'+(0,Qs.encode)(t[e]+"")+'"')).join(" ")}};nt.HTMLElement=ui;var Xd={},lp={f145:function(n,t,e,i,r){"use strict";if(t=t||"",e=e||[],i=i||"",r=r||"",n.id!=t.substr(1))return!1;for(let o=e,s=0;s{if(Xd[e])return Xd[e];let i=e.split("."),r=i[0],o=i.slice(1).sort(),s='"use strict";',a="f",c="",l="";if(r&&r!="*"){let h;if(r[0]=="#")s+="if (el.id != "+JSON.stringify(r.substr(1))+") return false;",a+="1";else if(h=r.match(/^\[\s*(\S+)\s*(=|!=)\s*((((["'])([^\6]*)\6))|(\S*?))\]\s*/)){c=h[1];let u=h[2];if(u!=="="&&u!=="!=")throw new Error("Selector not supported, Expect [key${op}value].op must be =,!=");u==="="&&(u="=="),l=h[7]||h[8],s+=`let attrs = el.attributes;for (let key in attrs){const val = attrs[key]; if (key == "${c}" && val == "${l}"){return true;}} return false;`,a+="2"}else s+="if (el.tagName != "+JSON.stringify(r)+") return false;",a+="3"}o.length>0&&(s+="for (let cls = "+JSON.stringify(o)+", i = 0; i < cls.length; i++) if (el.classNames.indexOf(cls[i]) === -1) return false;",a+="4"),s+="return true;",a+="5";let d={func:lp[a],tagName:r||"",classes:o||"",attr_key:c||"",value:l||""};return s=s||"",Xd[e]=d})}advance(t){return this.nextMatch)-->|<(\/?)([a-z][-.:0-9_a-z]*)((\s+[a-z][-.:0-9_a-z]*(\s*=\s*("[^"]*"|'([^']*')|([^\s\/>]+)))?)*)\s*(\/?)>/ig,XF=/(^|\s)(id|class)\s*=\s*("([^"]+)"|'([^']+)'|(\S+))/ig,ZF=/([a-z][-.:0-9_a-z]*)(\s*=\s*("([^"]*)"|'([^']*)'|(\S+)))?/ig,YF={area:!0,base:!0,br:!0,col:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,source:!0},ix={li:{li:!0},p:{p:!0,div:!0},b:{div:!0},td:{td:!0,th:!0},th:{td:!0,th:!0},h1:{h1:!0},h2:{h2:!0},h3:{h3:!0},h4:{h4:!0},h5:{h5:!0},h6:{h6:!0}},nx={li:{ul:!0,ol:!0},a:{div:!0},b:{div:!0},i:{div:!0},p:{div:!0},td:{tr:!0,table:!0},th:{tr:!0,table:!0}},JF={script:!0,noscript:!0,style:!0,pre:!0};function cp(n,t){let e=new ui(null),i=e,r=[e],o=0;t=t||{};let s;for(;s=En.exec(n);){if(Si&&console.log("match",s[0]),o+s[0].length",c=n.indexOf(a,En.lastIndex);if(t[s[2]]){let l;c==-1?l=n.substr(En.lastIndex):l=n.substring(En.lastIndex,c),l.length>0&&(Si&&console.log("add text node as child of",s[2]),i.appendChild(new Lo(l)))}c==-1?o=En.lastIndex=n.length+1:(o=En.lastIndex=c+a.length,s[1]="true")}if(s[1]||s[9]||YF[s[2]])for(;;)if(i.tagName==s[2]){Si&&console.log("met the end of",s[2]),r.pop(),i=_s(r);break}else{if(nx[i.tagName]&&nx[i.tagName][s[2]]){Si&&console.log("closing",i.tagName,"due to meeting",s[2]),r.pop(),i=_s(r);continue}break}}for(o1;){let a=r.pop(),c=_s(r);a.parentNode&&a.parentNode instanceof ui&&a.parentNode.parentNode&&(a.parentNode===c&&a.tagName===c.tagName?(Si&&console.log(a.tagName,"is probably supposed to close",c.tagName),c.removeChild(a),a.childNodes.forEach(l=>{c.parentNode.appendChild(l)}),r.pop()):(Si&&console.log("no close tag found for",a.tagName,". Removing"),c.removeChild(a),a.childNodes.forEach(l=>{c.appendChild(l)})))}return e}nt.parse=cp;var QF=["html","body","address","article","aside","blockquote","canvas","dd","div","dl","dt","fieldset","figcaption","figure","footer","form","header","hr","li","main","nav","noscript","ol","p","pre","section","tfoot","table","tbody","ul","video","th","td","tr","h1","h2","h3","h4","h5","h6"];function _F(n){return n.nodeType===wt.ELEMENT_NODE&&n.tagName&&QF.includes(n.tagName.toLowerCase())}nt.isBlock=_F});var zP={};Yh(zP,{default:()=>Xh});module.exports=ay(zP);var De=require("obsidian");var fp={};Yh(fp,{AFRelationship:()=>gs,AcroButtonFlags:()=>dt,AcroChoiceFlags:()=>oe,AcroFieldFlags:()=>Ot,AcroTextFlags:()=>Ie,AnnotationFlags:()=>xo,AppearanceCharacteristics:()=>ks,BlendMode:()=>Di,Cache:()=>ct,CharCodes:()=>y,ColorTypes:()=>Po,CombedTextLayoutError:()=>hc,CorruptPageTreeError:()=>ls,CustomFontEmbedder:()=>ir,CustomFontSubsetEmbedder:()=>pd,Duplex:()=>Fs,EncryptedPDFError:()=>ko,ExceededMaxLengthError:()=>uc,FieldAlreadyExistsError:()=>Ws,FieldExistsAsNonTerminalError:()=>Gf,FileEmbedder:()=>gd,FillRule:()=>Wi,FontkitNotRegisteredError:()=>oc,ForeignPageError:()=>sc,ImageAlignment:()=>si,IndexOutOfBoundsError:()=>hn,InvalidAcroFieldValueError:()=>un,InvalidFieldNamePartError:()=>cc,InvalidMaxLengthError:()=>fc,InvalidPDFDateStringError:()=>qr,InvalidTargetIndexError:()=>as,JpegEmbedder:()=>bs,LineCapStyle:()=>_t,LineJoinStyle:()=>yo,MethodNotImplementedError:()=>Ge,MissingCatalogError:()=>$u,MissingDAEntryError:()=>il,MissingKeywordError:()=>hl,MissingOnValueCheckError:()=>Kf,MissingPDFHeaderError:()=>dl,MissingPageContentsEmbeddingError:()=>Qa,MissingTfOperatorError:()=>nl,MultiSelectValueError:()=>tl,NextByteAssertionError:()=>rl,NoSuchFieldError:()=>lc,NonFullScreenPageMode:()=>eo,NumberParsingError:()=>cs,PDFAcroButton:()=>nr,PDFAcroCheckBox:()=>bn,PDFAcroChoice:()=>Ds,PDFAcroComboBox:()=>xn,PDFAcroField:()=>Ps,PDFAcroForm:()=>or,PDFAcroListBox:()=>Pn,PDFAcroNonTerminal:()=>yn,PDFAcroPushButton:()=>vn,PDFAcroRadioButton:()=>Fn,PDFAcroSignature:()=>rr,PDFAcroTerminal:()=>Et,PDFAcroText:()=>wn,PDFAnnotation:()=>yd,PDFArray:()=>H,PDFArrayIsNotRectangleError:()=>el,PDFBool:()=>yi,PDFButton:()=>hi,PDFCatalog:()=>Cs,PDFCheckBox:()=>Vt,PDFContentStream:()=>Hi,PDFContext:()=>Yr,PDFCrossRefSection:()=>hs,PDFCrossRefStream:()=>hd,PDFDict:()=>R,PDFDocument:()=>pe,PDFDropdown:()=>li,PDFEmbeddedPage:()=>Pi,PDFField:()=>$e,PDFFlateStream:()=>_n,PDFFont:()=>Se,PDFForm:()=>Sn,PDFHeader:()=>Bi,PDFHexString:()=>M,PDFImage:()=>oi,PDFInvalidObject:()=>ps,PDFInvalidObjectParsingError:()=>sl,PDFJavaScript:()=>Cn,PDFName:()=>x,PDFNull:()=>Me,PDFNumber:()=>N,PDFObject:()=>fe,PDFObjectCopier:()=>ml,PDFObjectParser:()=>Es,PDFObjectParsingError:()=>ol,PDFObjectStream:()=>us,PDFObjectStreamParser:()=>Pd,PDFOperator:()=>_,PDFOperatorNames:()=>ee,PDFOptionList:()=>ci,PDFPage:()=>Pe,PDFPageEmbedder:()=>vs,PDFPageLeaf:()=>tt,PDFPageTree:()=>Ts,PDFParser:()=>Wl,PDFParsingError:()=>xi,PDFRadioGroup:()=>Bt,PDFRawStream:()=>wi,PDFRef:()=>q,PDFSignature:()=>ki,PDFStream:()=>Fe,PDFStreamParsingError:()=>al,PDFStreamWriter:()=>ud,PDFString:()=>G,PDFTextField:()=>di,PDFTrailer:()=>$n,PDFTrailerDict:()=>dd,PDFWidgetAnnotation:()=>oo,PDFWriter:()=>fs,PDFXRefStreamParser:()=>kd,PageEmbeddingMismatchedContextError:()=>$a,PageSizes:()=>So,ParseSpeeds:()=>pc,PngEmbedder:()=>ys,PrintScaling:()=>io,PrivateConstructorError:()=>cn,ReadingDirection:()=>to,RemovePageFromEmptyDocumentError:()=>ac,ReparseError:()=>dn,RichTextFieldReadError:()=>dc,RotationTypes:()=>Is,StalledParserError:()=>cl,StandardFontEmbedder:()=>tr,StandardFontValues:()=>O0,StandardFonts:()=>Do,TextAlignment:()=>He,TextRenderingMode:()=>vf,UnbalancedParenthesisError:()=>ll,UnexpectedFieldTypeError:()=>Fi,UnexpectedObjectTypeError:()=>Vi,UnrecognizedStreamTypeError:()=>_a,UnsupportedEncodingError:()=>Ja,ViewerPreferences:()=>El,addRandomSuffix:()=>cy,adjustDimsForRotation:()=>qi,appendBezierCurve:()=>bt,appendQuadraticCurve:()=>Ns,arrayAsString:()=>nn,asNumber:()=>$,asPDFName:()=>As,asPDFNumber:()=>j,assertEachIs:()=>Ga,assertInteger:()=>_u,assertIs:()=>S,assertIsOneOf:()=>Xt,assertIsOneOfOrUndefined:()=>gt,assertIsSubset:()=>Qu,assertMultiple:()=>Xa,assertOrUndefined:()=>I,assertPositive:()=>ln,assertRange:()=>lt,assertRangeOrUndefined:()=>Ct,backtick:()=>Ke,beginMarkedContent:()=>Ed,beginText:()=>Jl,breakTextIntoLines:()=>iu,byAscendingId:()=>ou,bytesFor:()=>jn,canBeConvertedToUint8Array:()=>du,charAtIndex:()=>qc,charFromCode:()=>kt,charFromHexCode:()=>$h,charSplit:()=>tu,cleanText:()=>zn,clip:()=>Kl,clipEvenOdd:()=>Jv,closePath:()=>ei,cmyk:()=>Rd,colorString:()=>Rf,colorToComponents:()=>Vd,componentsToColor:()=>ht,concatTransformationMatrix:()=>$t,copyStringIntoBuffer:()=>be,createPDFAcroField:()=>wd,createPDFAcroFields:()=>Ss,createTypeErrorMsg:()=>H0,createValueErrorMsg:()=>R0,decodeFromBase64:()=>Jh,decodeFromBase64DataUri:()=>_h,decodePDFRawStream:()=>ws,defaultButtonAppearanceProvider:()=>Jf,defaultCheckBoxAppearanceProvider:()=>Zf,defaultDropdownAppearanceProvider:()=>_f,defaultOptionListAppearanceProvider:()=>$f,defaultRadioGroupAppearanceProvider:()=>Yf,defaultTextFieldAppearanceProvider:()=>Qf,degrees:()=>X,degreesToRadians:()=>Jt,drawButton:()=>Hd,drawCheckBox:()=>zs,drawCheckMark:()=>Hb,drawEllipse:()=>nc,drawEllipsePath:()=>Bb,drawImage:()=>rc,drawLine:()=>qf,drawLinesOfText:()=>Uf,drawObject:()=>Vs,drawOptionList:()=>jf,drawPage:()=>zf,drawRadioButton:()=>qs,drawRectangle:()=>dr,drawSvgPath:()=>Wf,drawText:()=>CF,drawTextField:()=>zd,drawTextLines:()=>Ud,encodeToBase64:()=>Qh,endMarkedContent:()=>Ad,endPath:()=>Zl,endText:()=>Ql,error:()=>Kn,escapeRegExp:()=>vg,escapedNewlineChars:()=>Fg,fill:()=>Gl,fillAndStroke:()=>Xl,fillEvenOdd:()=>Ff,findLastMatch:()=>Go,getType:()=>V0,grayscale:()=>Nd,hasSurrogates:()=>fu,hasUtf16BOM:()=>Da,highSurrogate:()=>Wc,isArrayEqual:()=>Xo,isNewlineChar:()=>eu,isStandardFont:()=>ld,isType:()=>B0,isWithinBMP:()=>uu,last:()=>Ir,layoutCombedText:()=>Xf,layoutMultilineText:()=>qd,layoutSinglelineText:()=>js,lineSplit:()=>wa,lineTo:()=>Ve,lowSurrogate:()=>jc,mergeIntoTypedArray:()=>nu,mergeLines:()=>zc,mergeUint8Arrays:()=>ru,moveText:()=>tF,moveTo:()=>At,newlineChars:()=>dy,nextLine:()=>Pf,normalizeAppearance:()=>Rt,numberToString:()=>pu,padStart:()=>Dt,parseDate:()=>va,pdfDocEncodingDecode:()=>Za,pluckIndices:()=>cu,popGraphicsState:()=>Re,pushGraphicsState:()=>Ne,radians:()=>Yv,radiansToDegrees:()=>hb,range:()=>lu,rectangle:()=>ub,rectanglesAreEqual:()=>ss,reduceRotation:()=>Qt,restoreDashPattern:()=>_v,reverseArray:()=>qn,rgb:()=>ne,rotateAndSkewTextDegreesAndTranslate:()=>sF,rotateAndSkewTextRadiansAndTranslate:()=>Rs,rotateDegrees:()=>Ls,rotateInPlace:()=>ii,rotateRadians:()=>lr,rotateRectangle:()=>wf,scale:()=>ar,setCharacterSpacing:()=>iF,setCharacterSqueeze:()=>rF,setDashPattern:()=>wo,setFillingCmykColor:()=>Ef,setFillingColor:()=>ti,setFillingGrayscaleColor:()=>Df,setFillingRgbColor:()=>Cf,setFontAndSize:()=>Fo,setGraphicsState:()=>ji,setLineCap:()=>Ms,setLineHeight:()=>kf,setLineJoin:()=>$v,setLineWidth:()=>kn,setStrokingCmykColor:()=>Af,setStrokingColor:()=>Dn,setStrokingGrayscaleColor:()=>Sf,setStrokingRgbColor:()=>Tf,setTextMatrix:()=>fb,setTextRenderingMode:()=>Td,setTextRise:()=>oF,setWordSpacing:()=>nF,showText:()=>Yl,singleQuote:()=>N0,sizeInBytes:()=>Zo,skewDegrees:()=>Qv,skewRadians:()=>Os,sortedUniq:()=>su,square:()=>eF,stringAsByteArray:()=>Ko,stroke:()=>vo,sum:()=>au,toCharCode:()=>Q,toCodePoint:()=>Uc,toDegrees:()=>jl,toHexString:()=>Ii,toHexStringOfMinLength:()=>Ai,toRadians:()=>qe,toUint8Array:()=>Lr,translate:()=>mt,typedArrayFor:()=>Fa,utf16Decode:()=>ka,utf16Encode:()=>hu,utf8Encode:()=>fy,values:()=>os,waitForTick:()=>gi});var jo="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ya=new Uint8Array(256);for(let n=0;n{let t="",e=n.length;for(let i=0;i>2],t+=jo[(n[i]&3)<<4|n[i+1]>>4],t+=jo[(n[i+1]&15)<<2|n[i+2]>>6],t+=jo[n[i+2]&63];return e%3===2?t=t.substring(0,t.length-1)+"=":e%3===1&&(t=t.substring(0,t.length-2)+"=="),t},Jh=n=>{let t=n.length*.75,e=n.length,i,r=0,o,s,a,c;n[n.length-1]==="="&&(t--,n[n.length-2]==="="&&t--);let l=new Uint8Array(t);for(i=0;i>4,l[r++]=(s&15)<<4|a>>2,l[r++]=(a&3)<<6|c&63;return l},ly=/^(data)?:?([\w\/\+]+)?;?(charset=[\w-]+|base64)?.*,/i,_h=n=>{let t=n.trim(),i=t.substring(0,100).match(ly);if(!i)return Jh(t);let[r]=i,o=t.substring(r.length);return Jh(o)};var Q=n=>n.charCodeAt(0),Uc=n=>n.codePointAt(0),Ai=(n,t)=>Dt(n.toString(16),t,"0").toUpperCase(),Ii=n=>Ai(n,2),kt=n=>String.fromCharCode(n),$h=n=>kt(parseInt(n,16)),Dt=(n,t,e)=>{let i="";for(let r=0,o=t-n.length;r{let t=new Uint8Array(n.length);return be(n,t,0),t},be=(n,t,e)=>{let i=n.length;for(let r=0;r`${n}-${Math.floor(Math.random()*10**t)}`,vg=n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),zn=n=>n.replace(/\t|\u0085|\u2028|\u2029/g," ").replace(/[\b\v]/g,""),Fg=["\\n","\\f","\\r","\\u000B"],dy=[` `,"\f","\r","\v"],eu=n=>/^[\n\f\r\u000B]$/.test(n),wa=n=>n.split(/[\n\f\r\u000B]/),zc=n=>n.replace(/[\n\f\r\u000B]/g," "),qc=(n,t)=>{let e=n.charCodeAt(t),i,r=t+1,o=1;return e>=55296&&e<=56319&&n.length>r&&(i=n.charCodeAt(r),i>=56320&&i<=57343&&(o=2)),[n.slice(t,t+o),o]},tu=n=>{let t=[];for(let e=0,i=n.length;e{let t=Fg.join("|"),e=["$"];for(let r=0,o=n.length;r{let r=hy(t),o=zn(n).match(r),s="",a=0,c=[],l=()=>{s!==""&&c.push(s),s="",a=0};for(let d=0,h=o.length;de&&l(),s+=u,a+=f}}return l(),c},uy=/^D:(\d\d\d\d)(\d\d)?(\d\d)?(\d\d)?(\d\d)?(\d\d)?([+\-Z])?(\d\d)?'?(\d\d)?'?$/,va=n=>{let t=n.match(uy);if(!t)return;let[,e,i="01",r="01",o="00",s="00",a="00",c="Z",l="00",d="00"]=t,h=c==="Z"?"Z":`${c}${l}:${d}`;return new Date(`${e}-${i}-${r}T${o}:${s}:${a}${h}`)},Go=(n,t)=>{var e;let i=0,r;for(;in[n.length-1],Fa=n=>{if(n instanceof Uint8Array)return n;let t=n.length,e=new Uint8Array(t);for(let i=0;i{let t=n.length,e=[];for(let s=0;s{let t=0;for(let r=0,o=n.length;r{let t="";for(let e=0,i=n.length;en.id-t.id,su=(n,t)=>{let e=[];for(let i=0,r=n.length;i{if(n.length!==t.length)return!1;for(let e=0,i=n.length;e{let t=n.length;for(let e=0,i=Math.floor(t/2);e{let t=0;for(let e=0,i=n.length;e{let e=new Array(t-n);for(let i=0,r=e.length;i{let e=new Array(t.length);for(let i=0,r=t.length;in instanceof Uint8Array||n instanceof ArrayBuffer||typeof n=="string",Lr=n=>{if(typeof n=="string")return _h(n);if(n instanceof ArrayBuffer)return new Uint8Array(n);if(n instanceof Uint8Array)return n;throw new TypeError("`input` must be one of `string | ArrayBuffer | Uint8Array`")};var gi=()=>new Promise(n=>{setTimeout(()=>n(),0)});var fy=(n,t=!0)=>{let e=[];t&&e.push(239,187,191);for(let i=0,r=n.length;i>6&31|192,a=o&63|128;e.push(s,a),i+=1}else if(o<65536){let s=o>>12&15|224,a=o>>6&63|128,c=o&63|128;e.push(s,a,c),i+=1}else if(o<1114112){let s=o>>18&7|240,a=o>>12&63|128,c=o>>6&63|128,l=o>>0&63|128;e.push(s,a,c,l),i+=2}else throw new Error(`Invalid code point: 0x${Ii(o)}`)}return new Uint8Array(e)},hu=(n,t=!0)=>{let e=[];t&&e.push(65279);for(let i=0,r=n.length;in>=0&&n<=65535,fu=n=>n>=65536&&n<=1114111,Wc=n=>Math.floor((n-65536)/1024)+55296,jc=n=>(n-65536)%1024+56320,Wn;(function(n){n.BigEndian="BigEndian",n.LittleEndian="LittleEndian"})(Wn||(Wn={}));var Pa="\uFFFD".codePointAt(0),ka=(n,t=!0)=>{if(n.length<=1)return String.fromCodePoint(Pa);let e=t?gy(n):Wn.BigEndian,i=t?2:0,r=[];for(;n.length-i>=2;){let o=kg(n[i++],n[i++],e);if(py(o))if(n.length-i<2)r.push(Pa);else{let s=kg(n[i++],n[i++],e);Pg(s)?r.push(o,s):r.push(Pa)}else Pg(o)?(i+=2,r.push(Pa)):r.push(o)}return in>=55296&&n<=56319,Pg=n=>n>=56320&&n<=57343,kg=(n,t,e)=>{if(e===Wn.LittleEndian)return t<<8|n;if(e===Wn.BigEndian)return n<<8|t;throw new Error(`Invalid byteOrder: ${e}`)},gy=n=>Dg(n)?Wn.BigEndian:Sg(n)?Wn.LittleEndian:Wn.BigEndian,Dg=n=>n[0]===254&&n[1]===255,Sg=n=>n[0]===255&&n[1]===254,Da=n=>Dg(n)||Sg(n);var pu=n=>{let t=String(n);if(Math.abs(n)<1){let e=parseInt(n.toString().split("e-")[1]);if(e){let i=n<0;i&&(n*=-1),n*=Math.pow(10,e-1),t="0."+new Array(e).join("0")+n.toString().substring(2),i&&(t="-"+t)}}else{let e=parseInt(n.toString().split("+")[1]);e>20&&(e-=20,n/=Math.pow(10,e),t=n.toString()+new Array(e+1).join("0"))}return t},Zo=n=>Math.ceil(n.toString(2).length/8),jn=n=>{let t=new Uint8Array(Zo(n));for(let e=1;e<=t.length;e++)t[e-1]=n>>(t.length-e)*8;return t};var Kn=n=>{throw new Error(n)};var p0=Un(qa()),f0="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ja=new Uint8Array(256);for(Wa=0;Wa>4,l[r++]=(s&15)<<4|a>>2,l[r++]=(a&3)<<6|c&63;return l},cv=function(n){for(var t="",e=0;eObject.keys(n).map(t=>n[t]),O0=os(zr),ld=n=>O0.includes(n),ss=(n,t)=>n.x===t.x&&n.y===t.y&&n.width===t.width&&n.height===t.height;var Ke=n=>`\`${n}\``,N0=n=>`'${n}'`,M0=n=>{let t=typeof n;return t==="string"?N0(n):t==="undefined"?Ke(n):n},R0=(n,t,e)=>{let i=new Array(e.length);for(let o=0,s=e.length;o{Array.isArray(e)||(e=os(e));for(let i=0,r=e.length;i{Array.isArray(e)||(e=os(e)),Xt(n,t,e.concat(void 0))},Qu=(n,t,e)=>{Array.isArray(e)||(e=os(e));for(let i=0,r=n.length;in===null?"null":n===void 0?"undefined":typeof n=="string"?"string":isNaN(n)?"NaN":typeof n=="number"?"number":typeof n=="boolean"?"boolean":typeof n=="symbol"?"symbol":typeof n=="bigint"?"bigint":n.constructor&&n.constructor.name?n.constructor.name:n.name?n.name:n.constructor?String(n.constructor):String(n),B0=(n,t)=>t==="null"?n===null:t==="undefined"?n===void 0:t==="string"?typeof n=="string":t==="number"?typeof n=="number"&&!isNaN(n):t==="boolean"?typeof n=="boolean":t==="symbol"?typeof n=="symbol":t==="bigint"?typeof n=="bigint":t===Date?n instanceof Date:t===Array?n instanceof Array:t===Uint8Array?n instanceof Uint8Array:t===ArrayBuffer?n instanceof ArrayBuffer:t===Function?n instanceof Function:n instanceof t[0],H0=(n,t,e)=>{let i=new Array(e.length);for(let o=0,s=e.length;o{for(let i=0,r=e.length;i{S(n,t,e.concat("undefined"))},Ga=(n,t,e)=>{for(let i=0,r=n.length;i{if(S(n,t,["number"]),S(e,"min",["number"]),S(i,"max",["number"]),i=Math.max(e,i),ni)throw new Error(`${Ke(t)} must be at least ${e} and at most ${i}, but was actually ${n}`)},Ct=(n,t,e,i)=>{S(n,t,["number","undefined"]),typeof n=="number"&<(n,t,e,i)},Xa=(n,t,e)=>{if(S(n,t,["number"]),n%e!==0)throw new Error(`${Ke(t)} must be a multiple of ${e}, but was actually ${n}`)},_u=(n,t)=>{if(!Number.isInteger(n))throw new Error(`${Ke(t)} must be an integer, but was actually ${n}`)},ln=(n,t)=>{if(![1,0].includes(Math.sign(n)))throw new Error(`${Ke(t)} must be a positive number or 0, but was actually ${n}`)};var ie=new Uint16Array(256);for(let n=0;n<256;n++)ie[n]=n;ie[22]=Q("");ie[24]=Q("\u02D8");ie[25]=Q("\u02C7");ie[26]=Q("\u02C6");ie[27]=Q("\u02D9");ie[28]=Q("\u02DD");ie[29]=Q("\u02DB");ie[30]=Q("\u02DA");ie[31]=Q("\u02DC");ie[127]=Q("\uFFFD");ie[128]=Q("\u2022");ie[129]=Q("\u2020");ie[130]=Q("\u2021");ie[131]=Q("\u2026");ie[132]=Q("\u2014");ie[133]=Q("\u2013");ie[134]=Q("\u0192");ie[135]=Q("\u2044");ie[136]=Q("\u2039");ie[137]=Q("\u203A");ie[138]=Q("\u2212");ie[139]=Q("\u2030");ie[140]=Q("\u201E");ie[141]=Q("\u201C");ie[142]=Q("\u201D");ie[143]=Q("\u2018");ie[144]=Q("\u2019");ie[145]=Q("\u201A");ie[146]=Q("\u2122");ie[147]=Q("\uFB01");ie[148]=Q("\uFB02");ie[149]=Q("\u0141");ie[150]=Q("\u0152");ie[151]=Q("\u0160");ie[152]=Q("\u0178");ie[153]=Q("\u017D");ie[154]=Q("\u0131");ie[155]=Q("\u0142");ie[156]=Q("\u0153");ie[157]=Q("\u0161");ie[158]=Q("\u017E");ie[159]=Q("\uFFFD");ie[160]=Q("\u20AC");ie[173]=Q("\uFFFD");var Za=n=>{let t=new Array(n.length);for(let e=0,i=n.length;enew Ya(n);var ct=Ya;var Ge=class extends Error{constructor(t,e){let i=`Method ${t}.${e}() not implemented`;super(i)}},cn=class extends Error{constructor(t){let e=`Cannot construct ${t} - it has a private constructor`;super(e)}},Vi=class extends Error{constructor(t,e){let i=s=>{var a,c;return(a=s==null?void 0:s.name)!==null&&a!==void 0?a:(c=s==null?void 0:s.constructor)===null||c===void 0?void 0:c.name},o=`Expected instance of ${(Array.isArray(t)?t.map(i):[i(t)]).join(" or ")}, but got instance of ${e&&i(e)}`;super(o)}},Ja=class extends Error{constructor(t){let e=`${t} stream encoding not supported`;super(e)}},dn=class extends Error{constructor(t,e){let i=`Cannot call ${t}.${e}() more than once`;super(i)}},$u=class extends Error{constructor(t){let e=`Missing catalog (ref=${t})`;super(e)}},Qa=class extends Error{constructor(){let t="Can't embed page with missing Contents";super(t)}},_a=class extends Error{constructor(t){var e,i,r;let s=`Unrecognized stream type: ${(r=(i=(e=t==null?void 0:t.contructor)===null||e===void 0?void 0:e.name)!==null&&i!==void 0?i:t==null?void 0:t.name)!==null&&r!==void 0?r:t}`;super(s)}},$a=class extends Error{constructor(){let t="Found mismatched contexts while embedding pages. All pages in the array passed to `PDFDocument.embedPages()` must be from the same document.";super(t)}},el=class extends Error{constructor(t){let e=`Attempted to convert PDFArray with ${t} elements to rectangle, but must have exactly 4 elements.`;super(e)}},qr=class extends Error{constructor(t){let e=`Attempted to convert "${t}" to a date, but it does not match the PDF date string format.`;super(e)}},as=class extends Error{constructor(t,e){let i=`Invalid targetIndex specified: targetIndex=${t} must be less than Count=${e}`;super(i)}},ls=class extends Error{constructor(t,e){let i=`Failed to ${e} at targetIndex=${t} due to corrupt page tree: It is likely that one or more 'Count' entries are invalid`;super(i)}},hn=class extends Error{constructor(t,e,i){let r=`index should be at least ${e} and at most ${i}, but was actually ${t}`;super(r)}},un=class extends Error{constructor(){let t="Attempted to set invalid field value";super(t)}},tl=class extends Error{constructor(){let t="Attempted to select multiple values for single-select field";super(t)}},il=class extends Error{constructor(t){let e=`No /DA (default appearance) entry found for field: ${t}`;super(e)}},nl=class extends Error{constructor(t){let e=`No Tf operator found for DA of field: ${t}`;super(e)}},cs=class extends Error{constructor(t,e){let i=`Failed to parse number (line:${t.line} col:${t.column} offset=${t.offset}): "${e}"`;super(i)}},xi=class extends Error{constructor(t,e){let i=`Failed to parse PDF document (line:${t.line} col:${t.column} offset=${t.offset}): ${e}`;super(i)}},rl=class extends xi{constructor(t,e,i){let r=`Expected next byte to be ${e} but it was actually ${i}`;super(t,r)}},ol=class extends xi{constructor(t,e){let i=`Failed to parse PDF object starting with the following byte: ${e}`;super(t,i)}},sl=class extends xi{constructor(t){let e="Failed to parse invalid PDF object";super(t,e)}},al=class extends xi{constructor(t){let e="Failed to parse PDF stream";super(t,e)}},ll=class extends xi{constructor(t){let e="Failed to parse PDF literal string due to unbalanced parenthesis";super(t,e)}},cl=class extends xi{constructor(t){let e="Parser stalled";super(t,e)}},dl=class extends xi{constructor(t){let e="No PDF header found";super(t,e)}},hl=class extends xi{constructor(t,e){let i=`Did not find expected keyword '${nn(e)}'`;super(t,i)}};var ef;(function(n){n[n.Null=0]="Null",n[n.Backspace=8]="Backspace",n[n.Tab=9]="Tab",n[n.Newline=10]="Newline",n[n.FormFeed=12]="FormFeed",n[n.CarriageReturn=13]="CarriageReturn",n[n.Space=32]="Space",n[n.ExclamationPoint=33]="ExclamationPoint",n[n.Hash=35]="Hash",n[n.Percent=37]="Percent",n[n.LeftParen=40]="LeftParen",n[n.RightParen=41]="RightParen",n[n.Plus=43]="Plus",n[n.Minus=45]="Minus",n[n.Dash=45]="Dash",n[n.Period=46]="Period",n[n.ForwardSlash=47]="ForwardSlash",n[n.Zero=48]="Zero",n[n.One=49]="One",n[n.Two=50]="Two",n[n.Three=51]="Three",n[n.Four=52]="Four",n[n.Five=53]="Five",n[n.Six=54]="Six",n[n.Seven=55]="Seven",n[n.Eight=56]="Eight",n[n.Nine=57]="Nine",n[n.LessThan=60]="LessThan",n[n.GreaterThan=62]="GreaterThan",n[n.A=65]="A",n[n.D=68]="D",n[n.E=69]="E",n[n.F=70]="F",n[n.O=79]="O",n[n.P=80]="P",n[n.R=82]="R",n[n.LeftSquareBracket=91]="LeftSquareBracket",n[n.BackSlash=92]="BackSlash",n[n.RightSquareBracket=93]="RightSquareBracket",n[n.a=97]="a",n[n.b=98]="b",n[n.d=100]="d",n[n.e=101]="e",n[n.f=102]="f",n[n.i=105]="i",n[n.j=106]="j",n[n.l=108]="l",n[n.m=109]="m",n[n.n=110]="n",n[n.o=111]="o",n[n.r=114]="r",n[n.s=115]="s",n[n.t=116]="t",n[n.u=117]="u",n[n.x=120]="x",n[n.LeftCurly=123]="LeftCurly",n[n.RightCurly=125]="RightCurly",n[n.Tilde=126]="Tilde"})(ef||(ef={}));var y=ef;var K0=Un(qa(),1);var ul=class{constructor(t,e){this.major=String(t),this.minor=String(e)}toString(){let t=kt(129);return`%PDF-${this.major}.${this.minor} %${t}${t}${t}${t}`}sizeInBytes(){return 12+this.major.length+this.minor.length}copyBytesInto(t,e){let i=e;return t[e++]=y.Percent,t[e++]=y.P,t[e++]=y.D,t[e++]=y.F,t[e++]=y.Dash,e+=be(this.major,t,e),t[e++]=y.Period,e+=be(this.minor,t,e),t[e++]=y.Newline,t[e++]=y.Percent,t[e++]=129,t[e++]=129,t[e++]=129,t[e++]=129,e-i}};ul.forVersion=(n,t)=>new ul(n,t);var Bi=ul;var tf=class{clone(t){throw new Ge(this.constructor.name,"clone")}toString(){throw new Ge(this.constructor.name,"toString")}sizeInBytes(){throw new Ge(this.constructor.name,"sizeInBytes")}copyBytesInto(t,e){throw new Ge(this.constructor.name,"copyBytesInto")}},fe=tf;var Wr=class extends fe{constructor(t){super(),this.numberValue=t,this.stringValue=pu(t)}asNumber(){return this.numberValue}value(){return this.numberValue}clone(){return Wr.of(this.numberValue)}toString(){return this.stringValue}sizeInBytes(){return this.stringValue.length}copyBytesInto(t,e){return e+=be(this.stringValue,t,e),this.stringValue.length}};Wr.of=n=>new Wr(n);var N=Wr;var jr=class extends fe{constructor(t){super(),this.array=[],this.context=t}size(){return this.array.length}push(t){this.array.push(t)}insert(t,e){this.array.splice(t,0,e)}indexOf(t){let e=this.array.indexOf(t);return e===-1?void 0:e}remove(t){this.array.splice(t,1)}set(t,e){this.array[t]=e}get(t){return this.array[t]}lookupMaybe(t,...e){return this.context.lookupMaybe(this.get(t),...e)}lookup(t,...e){return this.context.lookup(this.get(t),...e)}asRectangle(){if(this.size()!==4)throw new el(this.size());let t=this.lookup(0,N).asNumber(),e=this.lookup(1,N).asNumber(),i=this.lookup(2,N).asNumber(),r=this.lookup(3,N).asNumber(),o=t,s=e,a=i-t,c=r-e;return{x:o,y:s,width:a,height:c}}asArray(){return this.array.slice()}clone(t){let e=jr.withContext(t||this.context);for(let i=0,r=this.size();inew jr(n);var H=jr;var nf={},Kr=class extends fe{constructor(t,e){if(t!==nf)throw new cn("PDFBool");super(),this.value=e}asBoolean(){return this.value}clone(){return this}toString(){return String(this.value)}sizeInBytes(){return this.value?4:5}copyBytesInto(t,e){return this.value?(t[e++]=y.t,t[e++]=y.r,t[e++]=y.u,t[e++]=y.e,4):(t[e++]=y.f,t[e++]=y.a,t[e++]=y.l,t[e++]=y.s,t[e++]=y.e,5)}};Kr.True=new Kr(nf,!0);Kr.False=new Kr(nf,!1);var yi=Kr;var Tt=new Uint8Array(256);Tt[y.LeftParen]=1;Tt[y.RightParen]=1;Tt[y.LessThan]=1;Tt[y.GreaterThan]=1;Tt[y.LeftSquareBracket]=1;Tt[y.RightSquareBracket]=1;Tt[y.LeftCurly]=1;Tt[y.RightCurly]=1;Tt[y.ForwardSlash]=1;Tt[y.Percent]=1;var Zt=new Uint8Array(256);Zt[y.Null]=1;Zt[y.Tab]=1;Zt[y.Newline]=1;Zt[y.FormFeed]=1;Zt[y.CarriageReturn]=1;Zt[y.Space]=1;var cd=new Uint8Array(256);for(let n=0,t=256;nn.replace(/#([\dABCDEF]{2})/g,(t,e)=>$h(e)),Tv=n=>n>=y.ExclamationPoint&&n<=y.Tilde&&!cd[n],z0={},U0=new Map,J=class extends fe{constructor(t,e){if(t!==z0)throw new cn("PDFName");super();let i="/";for(let r=0,o=e.length;r{o!==void 0&&t.push(o),i=!1};for(let o=1,s=this.encodedName.length;o=y.Zero&&c<=y.Nine||c>=y.a&&c<=y.f||c>=y.A&&c<=y.F?(e+=a,(e.length===2||!(l>="0"&&l<="9"||l>="a"&&l<="f"||l>="A"&&l<="F"))&&(r(parseInt(e,16)),e="")):r(c):c===y.Hash?i=!0:r(c)}return new Uint8Array(t)}decodeText(){let t=this.asBytes();return String.fromCharCode(...Array.from(t))}asString(){return this.encodedName}value(){return this.encodedName}clone(){return this}toString(){return this.encodedName}sizeInBytes(){return this.encodedName.length}copyBytesInto(t,e){return e+=be(this.encodedName,t,e),this.encodedName.length}};J.of=n=>{let t=Cv(n),e=U0.get(t);return e||(e=new J(z0,t),U0.set(t,e)),e};J.Length=J.of("Length");J.FlateDecode=J.of("FlateDecode");J.Resources=J.of("Resources");J.Font=J.of("Font");J.XObject=J.of("XObject");J.ExtGState=J.of("ExtGState");J.Contents=J.of("Contents");J.Type=J.of("Type");J.Parent=J.of("Parent");J.MediaBox=J.of("MediaBox");J.Page=J.of("Page");J.Annots=J.of("Annots");J.TrimBox=J.of("TrimBox");J.ArtBox=J.of("ArtBox");J.BleedBox=J.of("BleedBox");J.CropBox=J.of("CropBox");J.Rotate=J.of("Rotate");J.Title=J.of("Title");J.Author=J.of("Author");J.Subject=J.of("Subject");J.Creator=J.of("Creator");J.Keywords=J.of("Keywords");J.Producer=J.of("Producer");J.CreationDate=J.of("CreationDate");J.ModDate=J.of("ModDate");var x=J;var rf=class extends fe{asNull(){return null}clone(){return this}toString(){return"null"}sizeInBytes(){return 4}copyBytesInto(t,e){return t[e++]=y.n,t[e++]=y.u,t[e++]=y.l,t[e++]=y.l,4}},Me=new rf;var fn=class extends fe{constructor(t,e){super(),this.suppressEncryption=!1,this.dict=t,this.context=e}keys(){return Array.from(this.dict.keys())}values(){return Array.from(this.dict.values())}entries(){return Array.from(this.dict.entries())}set(t,e){this.dict.set(t,e)}get(t,e=!1){let i=this.dict.get(t);if(!(i===Me&&!e))return i}has(t){let e=this.dict.get(t);return e!==void 0&&e!==Me}lookupMaybe(t,...e){let i=e.includes(Me),r=this.context.lookupMaybe(this.get(t,i),...e);if(!(r===Me&&!i))return r}lookup(t,...e){let i=e.includes(Me),r=this.context.lookup(this.get(t,i),...e);if(!(r===Me&&!i))return r}delete(t){return this.dict.delete(t)}asMap(){return new Map(this.dict)}uniqueKey(t=""){let e=this.keys(),i=x.of(this.context.addRandomSuffix(t,10));for(;e.includes(i);)i=x.of(this.context.addRandomSuffix(t,10));return i}clone(t){let e=fn.withContext(t||this.context),i=this.entries();for(let r=0,o=i.length;rnew fn(new Map,n);fn.fromMapWithContext=(n,t)=>new fn(n,t);var R=fn;var pn=class extends fe{constructor(t){super(),this.value=t}asBytes(){let t=this.value+(this.value.length%2===1?"0":""),e=t.length,i=new Uint8Array(t.length/2),r=0,o=0;for(;r`}sizeInBytes(){return this.value.length+2}copyBytesInto(t,e){return t[e++]=y.LessThan,e+=be(this.value,t,e),t[e++]=y.GreaterThan,this.value.length+2}};pn.of=n=>new pn(n);pn.fromText=n=>{let t=hu(n),e="";for(let i=0,r=t.length;inew Gr(n,t,e);var wi=Gr;var W0={},q0=new Map,fl=class extends fe{constructor(t,e,i){if(t!==W0)throw new cn("PDFRef");super(),this.objectNumber=e,this.generationNumber=i,this.tag=`${e} ${i} R`}clone(){return this}toString(){return this.tag}sizeInBytes(){return this.tag.length}copyBytesInto(t,e){return e+=be(this.tag,t,e),this.tag.length}};fl.of=(n,t=0)=>{let e=`${n} ${t} R`,i=q0.get(e);return i||(i=new fl(W0,n,t),q0.set(e,i)),i};var q=fl;var gn=class extends fe{constructor(t){super(),this.value=t}asBytes(){let t=[],e="",i=!1,r=o=>{o!==void 0&&t.push(o),i=!1};for(let o=0,s=this.value.length;o=y.Zero&&c<=y.Seven?(e+=a,(e.length===3||!(l>="0"&&l<="7"))&&(r(parseInt(e,8)),e="")):r(c):c===y.BackSlash?i=!0:r(c)}return new Uint8Array(t)}decodeText(){let t=this.asBytes();return Da(t)?ka(t):Za(t)}decodeDate(){let t=this.decodeText(),e=va(t);if(!e)throw new qr(t);return e}asString(){return this.value}clone(){return gn.of(this.value)}toString(){return`(${this.value})`}sizeInBytes(){return this.value.length+2}copyBytesInto(t,e){return t[e++]=y.LeftParen,e+=be(this.value,t,e),t[e++]=y.RightParen,this.value.length+2}};gn.of=n=>new gn(n);gn.fromDate=n=>{let t=Dt(String(n.getUTCFullYear()),4,"0"),e=Dt(String(n.getUTCMonth()+1),2,"0"),i=Dt(String(n.getUTCDate()),2,"0"),r=Dt(String(n.getUTCHours()),2,"0"),o=Dt(String(n.getUTCMinutes()),2,"0"),s=Dt(String(n.getUTCSeconds()),2,"0");return new gn(`D:${t}${e}${i}${r}${o}${s}Z`)};var G=gn;var Xr=class{constructor(t,e){this.name=t,this.args=e||[]}clone(t){let e=new Array(this.args.length);for(let i=0,r=e.length;inew Xr(n,t);var _=Xr;var sf;(function(n){n.NonStrokingColor="sc",n.NonStrokingColorN="scn",n.NonStrokingColorRgb="rg",n.NonStrokingColorGray="g",n.NonStrokingColorCmyk="k",n.NonStrokingColorspace="cs",n.StrokingColor="SC",n.StrokingColorN="SCN",n.StrokingColorRgb="RG",n.StrokingColorGray="G",n.StrokingColorCmyk="K",n.StrokingColorspace="CS",n.BeginMarkedContentSequence="BDC",n.BeginMarkedContent="BMC",n.EndMarkedContent="EMC",n.MarkedContentPointWithProps="DP",n.MarkedContentPoint="MP",n.DrawObject="Do",n.ConcatTransformationMatrix="cm",n.PopGraphicsState="Q",n.PushGraphicsState="q",n.SetFlatness="i",n.SetGraphicsStateParams="gs",n.SetLineCapStyle="J",n.SetLineDashPattern="d",n.SetLineJoinStyle="j",n.SetLineMiterLimit="M",n.SetLineWidth="w",n.SetTextMatrix="Tm",n.SetRenderingIntent="ri",n.AppendRectangle="re",n.BeginInlineImage="BI",n.BeginInlineImageData="ID",n.EndInlineImage="EI",n.ClipEvenOdd="W*",n.ClipNonZero="W",n.CloseAndStroke="s",n.CloseFillEvenOddAndStroke="b*",n.CloseFillNonZeroAndStroke="b",n.ClosePath="h",n.AppendBezierCurve="c",n.CurveToReplicateFinalPoint="y",n.CurveToReplicateInitialPoint="v",n.EndPath="n",n.FillEvenOddAndStroke="B*",n.FillEvenOdd="f*",n.FillNonZeroAndStroke="B",n.FillNonZero="f",n.LegacyFillNonZero="F",n.LineTo="l",n.MoveTo="m",n.ShadingFill="sh",n.StrokePath="S",n.BeginText="BT",n.EndText="ET",n.MoveText="Td",n.MoveTextSetLeading="TD",n.NextLine="T*",n.SetCharacterSpacing="Tc",n.SetFontAndSize="Tf",n.SetTextHorizontalScaling="Tz",n.SetTextLineHeight="TL",n.SetTextRenderingMode="Tr",n.SetTextRise="Ts",n.SetWordSpacing="Tw",n.ShowText="Tj",n.ShowTextAdjusted="TJ",n.ShowTextLine="'",n.ShowTextLineAndSpace='"',n.Type3D0="d0",n.Type3D1="d1",n.BeginCompatibilitySection="BX",n.EndCompatibilitySection="EX"})(sf||(sf={}));var ee=sf;var j0=Un(qa(),1);var af=class extends Fe{constructor(t,e){super(t),this.computeContents=()=>{let i=this.getUnencodedContents();return this.encode?j0.default.deflate(i):i},this.encode=e,e&&t.set(x.of("Filter"),x.of("FlateDecode")),this.contentsCache=ct.populatedBy(this.computeContents)}getContents(){return this.contentsCache.access()}getContentsSize(){return this.contentsCache.access().length}getUnencodedContents(){throw new Ge(this.constructor.name,"getUnencodedContents")}},_n=af;var Zr=class extends _n{constructor(t,e,i=!0){super(t,i),this.operators=e}push(...t){this.operators.push(...t)}clone(t){let e=new Array(this.operators.length);for(let o=0,s=this.operators.length;onew Zr(n,t,e);var Hi=Zr;var ds=class{constructor(t){this.seed=t}nextInt(){let t=Math.sin(this.seed++)*1e4;return t-Math.floor(t)}};ds.withSeed=n=>new ds(n);var Ev=([n],[t])=>n.objectNumber-t.objectNumber,pl=class{constructor(){this.isDecrypted=!0,this.largestObjectNumber=0,this.header=Bi.forVersion(1,7),this.trailerInfo={},this.indirectObjects=new Map,this.rng=ds.withSeed(1)}assign(t,e){this.indirectObjects.set(t,e),t.objectNumber>this.largestObjectNumber&&(this.largestObjectNumber=t.objectNumber)}nextRef(){return this.largestObjectNumber+=1,q.of(this.largestObjectNumber)}register(t){let e=this.nextRef();return this.assign(e,t),e}delete(t){return this.indirectObjects.delete(t)}lookupMaybe(t,...e){let i=e.includes(Me),r=t instanceof q?this.indirectObjects.get(t):t;if(!(!r||r===Me&&!i)){for(let o=0,s=e.length;othis.getLiteral(c,s)):a}else{if(t instanceof yi)return t.asBoolean();if(t instanceof R){let a={},c=t.entries();for(let l=0,d=c.length;lnew pl;var Yr=pl;var Ui=class extends R{constructor(t,e,i=!0){super(t,e),this.normalized=!1,this.autoNormalizeCTM=i}clone(t){let e=Ui.fromMapWithContext(new Map,t||this.context,this.autoNormalizeCTM),i=this.entries();for(let r=0,o=i.length;r{e||(e=i.get(t))}),e}setParent(t){this.set(x.Parent,t)}addContentStream(t){let e=this.normalizedEntries().Contents||this.context.obj([]);this.set(x.Contents,e),e.push(t)}wrapContentStreams(t,e){let i=this.Contents();return i instanceof H?(i.insert(0,t),i.push(e),!0):!1}addAnnot(t){let{Annots:e}=this.normalizedEntries();e.push(t)}removeAnnot(t){let{Annots:e}=this.normalizedEntries(),i=e.indexOf(t);i!==void 0&&e.remove(i)}setFontDictionary(t,e){let{Font:i}=this.normalizedEntries();i.set(t,e)}newFontDictionaryKey(t){let{Font:e}=this.normalizedEntries();return e.uniqueKey(t)}newFontDictionary(t,e){let i=this.newFontDictionaryKey(t);return this.setFontDictionary(i,e),i}setXObject(t,e){let{XObject:i}=this.normalizedEntries();i.set(t,e)}newXObjectKey(t){let{XObject:e}=this.normalizedEntries();return e.uniqueKey(t)}newXObject(t,e){let i=this.newXObjectKey(t);return this.setXObject(i,e),i}setExtGState(t,e){let{ExtGState:i}=this.normalizedEntries();i.set(t,e)}newExtGStateKey(t){let{ExtGState:e}=this.normalizedEntries();return e.uniqueKey(t)}newExtGState(t,e){let i=this.newExtGStateKey(t);return this.setExtGState(i,e),i}ascend(t){t(this);let e=this.Parent();e&&e.ascend(t)}normalize(){if(this.normalized)return;let{context:t}=this,e=this.get(x.Contents);this.context.lookup(e)instanceof Fe&&this.set(x.Contents,t.obj([e])),this.autoNormalizeCTM&&this.wrapContentStreams(this.context.getPushGraphicsStateContentStream(),this.context.getPopGraphicsStateContentStream());let r=this.getInheritableAttribute(x.Resources),o=t.lookupMaybe(r,R)||t.obj({});this.set(x.Resources,o);let s=o.lookupMaybe(x.Font,R)||t.obj({});o.set(x.Font,s);let a=o.lookupMaybe(x.XObject,R)||t.obj({});o.set(x.XObject,a);let c=o.lookupMaybe(x.ExtGState,R)||t.obj({});o.set(x.ExtGState,c);let l=this.Annots()||t.obj([]);this.set(x.Annots,l),this.normalized=!0}normalizedEntries(){this.normalize();let t=this.Annots(),e=this.Resources(),i=this.Contents();return{Annots:t,Resources:e,Contents:i,Font:e.lookup(x.Font,R),XObject:e.lookup(x.XObject,R),ExtGState:e.lookup(x.ExtGState,R)}}};Ui.InheritableEntries=["Resources","MediaBox","CropBox","Rotate"];Ui.withContextAndParent=(n,t)=>{let e=new Map;return e.set(x.Type,x.Page),e.set(x.Parent,t),e.set(x.Resources,n.obj({})),e.set(x.MediaBox,n.obj([0,0,612,792])),new Ui(e,n,!1)};Ui.fromMapWithContext=(n,t,e=!0)=>new Ui(n,t,e);var tt=Ui;var gl=class{constructor(t,e){this.traversedObjects=new Map,this.copy=i=>i instanceof tt?this.copyPDFPage(i):i instanceof R?this.copyPDFDict(i):i instanceof H?this.copyPDFArray(i):i instanceof Fe?this.copyPDFStream(i):i instanceof q?this.copyPDFIndirectObject(i):i.clone(),this.copyPDFPage=i=>{let r=i.clone(),{InheritableEntries:o}=tt;for(let s=0,a=o.length;s{if(this.traversedObjects.has(i))return this.traversedObjects.get(i);let r=i.clone(this.dest);this.traversedObjects.set(i,r);let o=i.entries();for(let s=0,a=o.length;s{if(this.traversedObjects.has(i))return this.traversedObjects.get(i);let r=i.clone(this.dest);this.traversedObjects.set(i,r);for(let o=0,s=i.size();o{if(this.traversedObjects.has(i))return this.traversedObjects.get(i);let r=i.clone(this.dest);this.traversedObjects.set(i,r);let o=i.dict.entries();for(let s=0,a=o.length;s{if(!this.traversedObjects.has(i)){let o=this.dest.nextRef();this.traversedObjects.set(i,o);let s=this.src.lookup(i);if(s){let a=this.copy(s);this.dest.assign(o,a)}}return this.traversedObjects.get(i)},this.src=t,this.dest=e}};gl.for=(n,t)=>new gl(n,t);var ml=gl;var Jr=class{constructor(t){this.subsections=t?[[t]]:[],this.chunkIdx=0,this.chunkLength=t?1:0}addEntry(t,e){this.append({ref:t,offset:e,deleted:!1})}addDeletedEntry(t,e){this.append({ref:t,offset:e,deleted:!0})}toString(){let t=`xref `;for(let e=0,i=this.subsections.length;e1?(this.subsections.push([t]),this.chunkIdx+=1,this.chunkLength=1):(e.push(t),this.chunkLength+=1)}};Jr.create=()=>new Jr({ref:q.of(0,65535),offset:0,deleted:!0});Jr.createEmpty=()=>new Jr;var hs=Jr;var bl=class{constructor(t){this.lastXRefOffset=String(t)}toString(){return`startxref ${this.lastXRefOffset} %%EOF`}sizeInBytes(){return 16+this.lastXRefOffset.length}copyBytesInto(t,e){let i=e;return t[e++]=y.s,t[e++]=y.t,t[e++]=y.a,t[e++]=y.r,t[e++]=y.t,t[e++]=y.x,t[e++]=y.r,t[e++]=y.e,t[e++]=y.f,t[e++]=y.Newline,e+=be(this.lastXRefOffset,t,e),t[e++]=y.Newline,t[e++]=y.Percent,t[e++]=y.Percent,t[e++]=y.E,t[e++]=y.O,t[e++]=y.F,e-i}};bl.forLastCrossRefSectionOffset=n=>new bl(n);var $n=bl;var xl=class{constructor(t){this.dict=t}toString(){return`trailer ${this.dict.toString()}`}sizeInBytes(){return 8+this.dict.sizeInBytes()}copyBytesInto(t,e){let i=e;return t[e++]=y.t,t[e++]=y.r,t[e++]=y.a,t[e++]=y.i,t[e++]=y.l,t[e++]=y.e,t[e++]=y.r,t[e++]=y.Newline,e+=this.dict.copyBytesInto(t,e),e-i}};xl.of=n=>new xl(n);var dd=xl;var Qr=class extends _n{constructor(t,e,i=!0){super(t.obj({}),i),this.objects=e,this.offsets=this.computeObjectOffsets(),this.offsetsString=this.computeOffsetsString(),this.dict.set(x.of("Type"),x.of("ObjStm")),this.dict.set(x.of("N"),N.of(this.objects.length)),this.dict.set(x.of("First"),N.of(this.offsetsString.length))}getObjectsCount(){return this.objects.length}clone(t){return Qr.withContextAndObjects(t||this.dict.context,this.objects.slice(),this.encode)}getContentsString(){let t=this.offsetsString;for(let e=0,i=this.objects.length;enew Qr(n,t,e);var us=Qr;var yl=class{constructor(t,e){this.parsedObjects=0,this.shouldWaitForTick=i=>(this.parsedObjects+=i,this.parsedObjects%this.objectsPerTick===0),this.context=t,this.objectsPerTick=e}async serializeToBuffer(){let{size:t,header:e,indirectObjects:i,xref:r,trailerDict:o,trailer:s}=await this.computeBufferSize(),a=0,c=new Uint8Array(t);a+=e.copyBytesInto(c,a),c[a++]=y.Newline,c[a++]=y.Newline;for(let l=0,d=i.length;lnew yl(n,t);var fs=yl;var _r=class extends fe{constructor(t){super(),this.data=t}clone(){return _r.of(this.data.slice())}toString(){return`PDFInvalidObject(${this.data.length} bytes)`}sizeInBytes(){return this.data.length}copyBytesInto(t,e){let i=this.data.length;for(let r=0;rnew _r(n);var ps=_r;var er;(function(n){n[n.Deleted=0]="Deleted",n[n.Uncompressed=1]="Uncompressed",n[n.Compressed=2]="Compressed"})(er||(er={}));var mn=class extends _n{constructor(t,e,i=!0){super(t,i),this.computeIndex=()=>{let r=[],o=0;for(let s=0,a=this.entries.length;s1&&(r.push(o),r.push(c.ref.objectNumber),o=0),o+=1}return r.push(o),r},this.computeEntryTuples=()=>{let r=new Array(this.entries.length);for(let o=0,s=this.entries.length;o{let r=this.entryTuplesCache.access(),o=[0,0,0];for(let s=0,a=r.length;so[0]&&(o[0]=h),u>o[1]&&(o[1]=u),f>o[2]&&(o[2]=f)}return o},this.entries=e||[],this.entryTuplesCache=ct.populatedBy(this.computeEntryTuples),this.maxByteWidthsCache=ct.populatedBy(this.computeMaxEntryByteWidths),this.indexCache=ct.populatedBy(this.computeIndex),t.set(x.of("Type"),x.of("XRef"))}addDeletedEntry(t,e){let i=er.Deleted;this.entries.push({type:i,ref:t,nextFreeObjectNumber:e}),this.entryTuplesCache.invalidate(),this.maxByteWidthsCache.invalidate(),this.indexCache.invalidate(),this.contentsCache.invalidate()}addUncompressedEntry(t,e){let i=er.Uncompressed;this.entries.push({type:i,ref:t,offset:e}),this.entryTuplesCache.invalidate(),this.maxByteWidthsCache.invalidate(),this.indexCache.invalidate(),this.contentsCache.invalidate()}addCompressedEntry(t,e,i){let r=er.Compressed;this.entries.push({type:r,ref:t,objectStreamRef:e,index:i}),this.entryTuplesCache.invalidate(),this.maxByteWidthsCache.invalidate(),this.indexCache.invalidate(),this.contentsCache.invalidate()}clone(t){let{dict:e,entries:i,encode:r}=this;return mn.of(e.clone(t),i.slice(),r)}getContentsString(){let t=this.entryTuplesCache.access(),e=this.maxByteWidthsCache.access(),i="";for(let r=0,o=t.length;r=0;u--)i+=(l[u]||0).toString(2);for(let u=e[1]-1;u>=0;u--)i+=(d[u]||0).toString(2);for(let u=e[2]-1;u>=0;u--)i+=(h[u]||0).toString(2)}return i}getUnencodedContents(){let t=this.entryTuplesCache.access(),e=this.maxByteWidthsCache.access(),i=new Uint8Array(this.getUnencodedContentsSize()),r=0;for(let o=0,s=t.length;o=0;f--)i[r++]=d[f]||0;for(let f=e[1]-1;f>=0;f--)i[r++]=h[f]||0;for(let f=e[2]-1;f>=0;f--)i[r++]=u[f]||0}return i}getUnencodedContentsSize(){let t=this.maxByteWidthsCache.access();return au(t)*this.entries.length}updateDict(){super.updateDict();let t=this.maxByteWidthsCache.access(),e=this.indexCache.access(),{context:i}=this.dict;this.dict.set(x.of("W"),i.obj(t)),this.dict.set(x.of("Index"),i.obj(e))}};mn.create=(n,t=!0)=>{let e=new mn(n,[],t);return e.addDeletedEntry(q.of(0,65535),0),e};mn.of=(n,t,e=!0)=>new mn(n,t,e);var hd=mn;var wl=class extends fs{constructor(t,e,i,r){super(t,e),this.encodeStreams=i,this.objectsPerStream=r}async computeBufferSize(){let t=this.context.largestObjectNumber+1,e=Bi.forVersion(1,7),i=e.sizeInBytes()+2,r=hd.create(this.createTrailerDict(),this.encodeStreams),o=[],s=[],a=[],c=this.context.enumerateIndirectObjects();for(let u=0,f=c.length;unew wl(n,t,e,i);var ud=wl;var vl=class{constructor(t,e){this.encoding=t===zr.ZapfDingbats?Ka.ZapfDingbats:t===zr.Symbol?Ka.Symbol:Ka.WinAnsi,this.font=I0.load(t),this.fontName=this.font.FontName,this.customName=e}encodeText(t){let e=this.encodeTextAsGlyphs(t),i=new Array(e.length);for(let r=0,o=e.length;rnew vl(n,t);var tr=vl;var X0=(n,t)=>{let e=new Array(n.length);for(let i=0,r=n.length;i`/CIDInit /ProcSet findresource begin 12 dict begin begincmap /CIDSystemInfo << /Registry (Adobe) /Ordering (UCS) /Supplement 0 >> def /CMapName /Adobe-Identity-UCS def /CMapType 2 def 1 begincodespacerange <0000> endcodespacerange ${n.length} beginbfchar ${n.map(([t,e])=>`${t} ${e}`).join(` `)} endbfchar endcmap CMapName currentdict /CMap defineresource pop end end`,G0=(...n)=>`<${n.join("")}>`,fd=n=>Ai(n,4),Iv=n=>{if(uu(n))return fd(n);if(fu(n)){let i=Wc(n),r=jc(n);return`${fd(i)}${fd(r)}`}let e=`0x${Ii(n)} is not a valid UTF-8 or UTF-16 codepoint.`;throw new Error(e)};var Lv=n=>{let t=0,e=i=>{t|=1<{let t=n["OS/2"]?n["OS/2"].sFamilyClass:0;return Lv({fixedPitch:n.post.isFixedPitch,serif:1<=t&&t<=7,symbolic:!0,script:t===10,italic:n.head.macStyle.italic})};var Fl=class{static async for(t,e,i,r){let o=await t.create(e);return new Fl(o,e,i,r)}constructor(t,e,i,r){this.allGlyphsInFontSortedById=()=>{let o=new Array(this.font.characterSet.length);for(let s=0,a=o.length;ss.id)},this.font=t,this.scale=1e3/this.font.unitsPerEm,this.fontData=e,this.fontName=this.font.postscriptName||"Font",this.customName=i,this.fontFeatures=r,this.baseFontName="",this.glyphCache=ct.populatedBy(this.allGlyphsInFontSortedById)}encodeText(t){let{glyphs:e}=this.font.layout(t,this.fontFeatures),i=new Array(e.length);for(let r=0,o=e.length;rthis.glyphs),this.glyphIdMap=new Map}encodeText(t){let{glyphs:e}=this.font.layout(t,this.fontFeatures),i=new Array(e.length);for(let r=0,o=e.length;r{let i=[];this.subset.encodeStream().on("data",r=>i.push(r)).on("end",()=>t(ru(i))).on("error",r=>e(r))})}},pd=Pl;var gs;(function(n){n.Source="Source",n.Data="Data",n.Alternative="Alternative",n.Supplement="Supplement",n.EncryptedPayload="EncryptedPayload",n.FormData="EncryptedPayload",n.Schema="Schema",n.Unspecified="Unspecified"})(gs||(gs={}));var kl=class{static for(t,e,i={}){return new kl(t,e,i)}constructor(t,e,i={}){this.fileData=t,this.fileName=e,this.options=i}async embedIntoContext(t,e){let{mimeType:i,description:r,creationDate:o,modificationDate:s,afRelationship:a}=this.options,c=t.flateStream(this.fileData,{Type:"EmbeddedFile",Subtype:i!=null?i:void 0,Params:{Size:this.fileData.length,CreationDate:o?G.fromDate(o):void 0,ModDate:s?G.fromDate(s):void 0}}),l=t.register(c),d=t.obj({Type:"Filespec",F:G.of(this.fileName),UF:M.fromText(this.fileName),EF:{F:l},Desc:r?M.fromText(r):void 0,AFRelationship:a!=null?a:void 0});return e?(t.assign(e,d),e):t.register(d)}},gd=kl;var Y0=[65472,65473,65474,65475,65477,65478,65479,65480,65481,65482,65483,65484,65485,65486,65487],ms;(function(n){n.DeviceGray="DeviceGray",n.DeviceRGB="DeviceRGB",n.DeviceCMYK="DeviceCMYK"})(ms||(ms={}));var Ov={1:ms.DeviceGray,3:ms.DeviceRGB,4:ms.DeviceCMYK},Dl=class{static async for(t){let e=new DataView(t.buffer);if(e.getUint16(0)!==65496)throw new Error("SOI not found in JPEG");let r=2,o;for(;r>3)]>>7-((p&7)<<0)&1,V=3*E;a[v]=P[V],a[v+1]=P[V+1],a[v+2]=P[V+2],a[v+3]=E>2)]>>6-((p&3)<<1)&3,V=3*E;a[v]=P[V],a[v+1]=P[V+1],a[v+2]=P[V+2],a[v+3]=E>1)]>>4-((p&1)<<2)&15,V=3*E;a[v]=P[V],a[v+1]=P[V+1],a[v+2]=P[V+2],a[v+3]=E>>3)]>>>7-(z&7)&1),re=B==b*255?0:255;c[te+z]=re<<24|B<<16|B<<8|B}else if(d==2)for(var z=0;z>>2)]>>>6-((z&3)<<1)&3),re=B==b*85?0:255;c[te+z]=re<<24|B<<16|B<<8|B}else if(d==4)for(var z=0;z>>1)]>>>4-((z&1)<<2)&15),re=B==b*17?0:255;c[te+z]=re<<24|B<<16|B<<8|B}else if(d==8)for(var z=0;z>>2<<3));r==0;){if(r=m(t,u,1),o=m(t,u+1,2),u+=3,o==0){u&7&&(u+=8-(u&7));var D=(u>>>3)+4,T=t[D-4]|t[D-3]<<8;C&&(e=n.H.W(e,h+T)),e.set(new i(t.buffer,t.byteOffset+D,T),h),u=D+T<<3,h+=T;continue}if(C&&(e=n.H.W(e,h+(1<<17))),o==1&&(f=k.J,p=k.h,l=(1<<9)-1,d=(1<<5)-1),o==2){s=b(t,u,5)+257,a=b(t,u+5,5)+1,c=b(t,u+10,4)+4,u+=14;for(var O=u,E=1,V=0;V<38;V+=2)k.Q[V]=0,k.Q[V+1]=0;for(var V=0;VE&&(E=W)}u+=3*c,F(k.Q,E),v(k.Q,E,k.u),f=k.w,p=k.d,u=w(k.u,(1<>>4;if(!(z>>>8))e[h++]=z;else{if(z==256)break;var re=h+z-254;if(z>264){var Ee=k.q[z-257];re=h+(Ee>>>3)+b(t,u,Ee&7),u+=Ee&7}var Ue=p[P(t,u)&d];u+=Ue&15;var me=Ue>>>4,Ae=k.c[me],we=(Ae>>>4)+m(t,u,Ae&15);for(u+=Ae&15;h>>4;if(h<=15)s[l]=h,l++;else{var u=0,f=0;h==16?(f=3+a(r,o,2),o+=2,u=s[l-1]):h==17?(f=3+a(r,o,3),o+=3):h==18&&(f=11+a(r,o,7),o+=7);for(var p=l+f;l>>1;so&&(o=c),s++}for(;s>1,l=t[a+1],d=c<<4|l,h=e-l,u=t[a]<>>15-e;i[p]=d,u++}},n.H.l=function(t,e){for(var i=n.H.m.r,r=15-e,o=0;o>>r}},n.H.M=function(t,e,i){i=i<<(e&7);var r=e>>>3;t[r]|=i,t[r+1]|=i>>>8},n.H.I=function(t,e,i){i=i<<(e&7);var r=e>>>3;t[r]|=i,t[r+1]|=i>>>8,t[r+2]|=i>>>16},n.H.e=function(t,e,i){return(t[e>>>3]|t[(e>>>3)+1]<<8)>>>(e&7)&(1<>>3]|t[(e>>>3)+1]<<8|t[(e>>>3)+2]<<16)>>>(e&7)&(1<>>3]|t[(e>>>3)+1]<<8|t[(e>>>3)+2]<<16)>>>(e&7)},n.H.i=function(t,e){return(t[e>>>3]|t[(e>>>3)+1]<<8|t[(e>>>3)+2]<<16|t[(e>>>3)+3]<<24)>>>(e&7)},n.H.m=function(){var t=Uint16Array,e=Uint32Array;return{K:new t(16),j:new t(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 t(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 e(32),J:new t(512),_:[],h:new t(32),$:[],w:new t(32768),C:[],v:[],d:new t(32768),D:[],u:new t(512),Q:[],r:new t(1<<15),s:new e(286),Y:new e(30),a:new e(19),t:new e(15e3),k:new t(1<<16),g:new t(1<<15)}}(),function(){for(var t=n.H.m,e=1<<15,i=0;i>>1|(r&1431655765)<<1,r=(r&3435973836)>>>2|(r&858993459)<<2,r=(r&4042322160)>>>4|(r&252645135)<<4,r=(r&4278255360)>>>8|(r&16711935)<<8,t.r[i]=(r>>>16|r<<16)>>>17}function o(s,a,c){for(;a--!=0;)s.push(0,c)}for(var i=0;i<32;i++)t.q[i]=t.S[i]<<3|t.T[i],t.c[i]=t.p[i]<<4|t.z[i];o(t._,144,8),o(t._,255-143,9),o(t._,279-255,7),o(t._,287-279,8),n.H.n(t._,9),n.H.A(t._,9,t.J),n.H.l(t._,9),o(t.$,32,5),n.H.n(t.$,5),n.H.A(t.$,5,t.h),n.H.l(t.$,5),o(t.Q,19,0),o(t.C,286,0),o(t.D,30,0),o(t.v,320,0)}(),n.H.N}();L.decode._readInterlace=function(n,t){for(var e=t.width,i=t.height,r=L.decode._getBPP(t),o=r>>3,s=Math.ceil(e*r/8),a=new Uint8Array(i*s),c=0,l=[0,0,4,0,2,0,1],d=[0,4,0,2,0,1,0],h=[8,8,8,4,4,2,2],u=[8,8,4,4,2,2,1],f=0;f<7;){for(var p=h[f],g=u[f],m=0,b=0,w=l[f];w>3];T=T>>7-(D&7)&1,a[k*s+(C>>3)]|=T<<7-((C&7)<<0)}if(r==2){var T=n[D>>3];T=T>>6-(D&7)&3,a[k*s+(C>>2)]|=T<<6-((C&3)<<1)}if(r==4){var T=n[D>>3];T=T>>4-(D&7)&15,a[k*s+(C>>1)]|=T<<4-((C&1)<<2)}if(r>=8)for(var O=k*s+C*o,E=0;E>3)+E];D+=r,C+=g}P++,k+=p}m*b!=0&&(c+=b*(1+v)),f=f+1}return a};L.decode._getBPP=function(n){var t=[1,null,3,1,2,null,4][n.ctype];return t*n.depth};L.decode._filterZero=function(n,t,e,i,r){var o=L.decode._getBPP(t),s=Math.ceil(i*o/8),a=L.decode._paeth;o=Math.ceil(o/8);var c=0,l=1,d=n[e],h=0;if(d>1&&(n[e]=[0,0,1][d-2]),d==3)for(h=o;h>>1)&255;for(var u=0;u>>1);for(;h>>1)}else{for(;h>8&255,n[t+1]=e&255},readUint:function(n,t){return n[t]*(256*256*256)+(n[t+1]<<16|n[t+2]<<8|n[t+3])},writeUint:function(n,t,e){n[t]=e>>24&255,n[t+1]=e>>16&255,n[t+2]=e>>8&255,n[t+3]=e&255},readASCII:function(n,t,e){for(var i="",r=0;r=0&&a>=0?(h=f*t+p<<2,u=(a+f)*r+s+p<<2):(h=(-a+f)*t-s+p<<2,u=f*r+p<<2),c==0)i[u]=n[h],i[u+1]=n[h+1],i[u+2]=n[h+2],i[u+3]=n[h+3];else if(c==1){var g=n[h+3]*.00392156862745098,m=n[h]*g,b=n[h+1]*g,w=n[h+2]*g,F=i[u+3]*(1/255),v=i[u]*F,P=i[u+1]*F,k=i[u+2]*F,C=1-g,D=g+F*C,T=D==0?0:1/D;i[u+3]=255*D,i[u+0]=(m+v*C)*T,i[u+1]=(b+P*C)*T,i[u+2]=(w+k*C)*T}else if(c==2){var g=n[h+3],m=n[h],b=n[h+1],w=n[h+2],F=i[u+3],v=i[u],P=i[u+1],k=i[u+2];g==F&&m==v&&b==P&&w==k?(i[u]=0,i[u+1]=0,i[u+2]=0,i[u+3]=0):(i[u]=m,i[u+1]=b,i[u+2]=w,i[u+3]=g)}else if(c==3){var g=n[h+3],m=n[h],b=n[h+1],w=n[h+2],F=i[u+3],v=i[u],P=i[u+1],k=i[u+2];if(g==F&&m==v&&b==P&&w==k)continue;if(g<220&&F>20)return!1}return!0};L.encode=function(n,t,e,i,r,o,s){i==null&&(i=0),s==null&&(s=!1);var a=L.encode.compress(n,t,e,i,[!1,!1,!1,0,s]);return L.encode.compressPNG(a,-1),L.encode._main(a,t,e,r,o)};L.encodeLL=function(n,t,e,i,r,o,s,a){for(var c={ctype:0+(i==1?0:2)+(r==0?0:4),depth:o,frames:[]},l=Date.now(),d=(i+r)*o,h=d*t,u=0;u1,h=!1,u=8+(16+5+4)+(d?20:0);if(r.sRGB!=null&&(u+=8+1+4),r.pHYs!=null&&(u+=8+9+4),n.ctype==3){for(var f=n.plte.length,p=0;p>>24!=255&&(h=!0);u+=8+f*3+4+(h?8+f*1+4:0)}for(var g=0;g>>8&255,C=v>>>16&255;b[l+F+0]=P,b[l+F+1]=k,b[l+F+2]=C}if(l+=f*3,s(b,l,o(b,l-f*3-4,f*3+4)),l+=4,h){s(b,l,f),l+=4,c(b,l,"tRNS"),l+=4;for(var p=0;p>>24&255;l+=f,s(b,l,o(b,l-f-4,f+4)),l+=4}}for(var D=0,g=0;g>2,V>>2));for(var f=0;fU&&z==B[m-U])te[m]=te[m-U];else{var re=F[z];if(re==null&&(F[z]=re=v.length,v.push(z),v.length>=300))break;te[m]=re}}}var Ee=v.length;Ee<=256&&l==!1&&(Ee<=2?h=1:Ee<=4?h=2:Ee<=16?h=4:h=8,h=Math.max(h,c));for(var f=0;f>1)]|=Wo[Bc+ze]<<4-(ze&1)*4;else if(h==2)for(var ze=0;ze>2)]|=Wo[Bc+ze]<<6-(ze&3)*2;else if(h==1)for(var ze=0;ze>3)]|=Wo[Bc+ze]<<7-(ze&7)*1}we=Wt,d=3,ma=1}else if(b==!1&&w.length==1){for(var Wt=new Uint8Array(U*Ae*3),ty=U*Ae,m=0;mC&&(C=O),TD&&(D=T))}C==-1&&(P=k=C=D=0),r&&((P&1)==1&&P--,(k&1)==1&&k--);var V=(C-P+1)*(D-k+1);Vm&&(m=v),Pb&&(b=P))}m==-1&&(p=g=m=b=0),s&&((p&1)==1&&p--,(g&1)==1&&g--),o={x:p,y:g,width:m-p+1,height:b-g+1};var D=i[r];D.rect=o,D.blend=1,D.img=new Uint8Array(o.width*o.height*4),i[r-1].dispose==0?(L._copyTile(l,t,e,D.img,o.width,o.height,-o.x,-o.y,0),L.encode._prepareDiff(u,t,e,D.img,o)):L._copyTile(u,t,e,D.img,o.width,o.height,-o.x,-o.y,0)};L.encode._prepareDiff=function(n,t,e,i,r){L._copyTile(n,t,e,i,r.width,r.height,-r.x,-r.y,2)};L.encode._filterZero=function(n,t,e,i,r,o,s){var a=[],c=[0,1,2,3,4];o!=-1?c=[o]:(t*i>5e5||e==1)&&(c=[0]);var l;s&&(l={level:0});for(var d=s&&UZIP!=null?UZIP:J0.default,h=0;h>1)+256&255;if(o==4)for(var l=r;l>1)&255;for(var l=r;l>1)&255}if(o==4){for(var l=0;l>>1:e=e>>>1;n[t]=e}return n}(),update:function(n,t,e,i){for(var r=0;r>>8;return n},crc:function(n,t,e){return L.crc.update(4294967295,n,t,e)^4294967295}};L.quantize=function(n,t){for(var e=new Uint8Array(n),i=e.slice(0),r=new Uint32Array(i.buffer),o=L.quantize.getKDtree(i,t),s=o[0],a=o[1],c=L.quantize.planeDst,l=e,d=r,h=l.length,u=new Uint8Array(e.length>>2),f=0;f>2]=w.ind,d[f>>2]=w.est.rgba}return{abuf:i.buffer,inds:u,plte:a}};L.quantize.getKDtree=function(n,t,e){e==null&&(e=1e-4);var i=new Uint32Array(n.buffer),r={i0:0,i1:n.length,bst:null,est:null,tdst:0,left:null,right:null};r.bst=L.quantize.stats(n,r.i0,r.i1),r.est=L.quantize.estats(r.bst);for(var o=[r];o.lengths&&(s=o[c].est.L,a=c);if(s=d||l.i1<=d;if(h){l.est.L=0;continue}var u={i0:l.i0,i1:d,bst:null,est:null,tdst:0,left:null,right:null};u.bst=L.quantize.stats(n,u.i0,u.i1),u.est=L.quantize.estats(u.bst);var f={i0:d,i1:l.i1,bst:null,est:null,tdst:0,left:null,right:null};f.bst={R:[],m:[],N:l.bst.N-u.bst.N};for(var c=0;c<16;c++)f.bst.R[c]=l.bst.R[c]-u.bst.R[c];for(var c=0;c<4;c++)f.bst.m[c]=l.bst.m[c]-u.bst.m[c];f.est=L.quantize.estats(f.bst),l.left=u,l.right=f,o[a]=u,o.push(f)}o.sort(function(p,g){return g.bst.N-p.bst.N});for(var c=0;c0&&(s=n.right,a=n.left);var c=L.quantize.getNearest(s,t,e,i,r);if(c.tdst<=o*o)return c;var l=L.quantize.getNearest(a,t,e,i,r);return l.tdsto;)i-=4;if(e>=i)break;var c=t[e>>2];t[e>>2]=t[i>>2],t[i>>2]=c,e+=4,i-=4}for(;s(n,e,r)>o;)e-=4;return e+4};L.quantize.vecDot=function(n,t,e){return n[t]*e[0]+n[t+1]*e[1]+n[t+2]*e[2]+n[t+3]*e[3]};L.quantize.stats=function(n,t,e){for(var i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],r=[0,0,0,0],o=e-t>>2,s=t;s>>0}};L.M4={multVec:function(n,t){return[n[0]*t[0]+n[1]*t[1]+n[2]*t[2]+n[3]*t[3],n[4]*t[0]+n[5]*t[1]+n[6]*t[2]+n[7]*t[3],n[8]*t[0]+n[9]*t[1]+n[10]*t[2]+n[11]*t[3],n[12]*t[0]+n[13]*t[1]+n[14]*t[2]+n[15]*t[3]]},dot:function(n,t){return n[0]*t[0]+n[1]*t[1]+n[2]*t[2]+n[3]*t[3]},sml:function(n,t){return[n*t[0],n*t[1],n*t[2],n*t[3]]}};L.encode.concatRGBA=function(n){for(var t=0,e=0;e{if(n===0)return $r.Greyscale;if(n===2)return $r.Truecolour;if(n===3)return $r.IndexedColour;if(n===4)return $r.GreyscaleWithAlpha;if(n===6)return $r.TruecolourWithAlpha;throw new Error(`Unknown color type: ${n}`)},Nv=n=>{let t=Math.floor(n.length/4),e=new Uint8Array(t*3),i=new Uint8Array(t*1),r=0,o=0,s=0;for(;r1)throw new Error("Animated PNGs are not supported");let r=new Uint8Array(i[0]),{rgbChannel:o,alphaChannel:s}=Nv(r);this.rgbChannel=o,s.some(c=>c<255)&&(this.alphaChannel=s),this.type=Mv(e.ctype),this.width=e.width,this.height=e.height,this.bitsPerComponent=8}};xs.load=n=>new xs(n);var Sl=class{static async for(t){let e=xs.load(t);return new Sl(e)}constructor(t){this.image=t,this.bitsPerComponent=t.bitsPerComponent,this.width=t.width,this.height=t.height,this.colorSpace="DeviceRGB"}async embedIntoContext(t,e){let i=this.embedAlphaChannel(t),r=t.flateStream(this.image.rgbChannel,{Type:"XObject",Subtype:"Image",BitsPerComponent:this.image.bitsPerComponent,Width:this.image.width,Height:this.image.height,ColorSpace:this.colorSpace,SMask:i});return e?(t.assign(e,r),e):t.register(r)}embedAlphaChannel(t){if(!this.image.alphaChannel)return;let e=t.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 t.register(e)}},ys=Sl;var Cl=class{constructor(t,e,i){this.bytes=t,this.start=e||0,this.pos=this.start,this.end=e&&i?e+i:this.bytes.length}get length(){return this.end-this.start}get isEmpty(){return this.length===0}getByte(){return this.pos>=this.end?-1:this.bytes[this.pos++]}getUint16(){let t=this.getByte(),e=this.getByte();return t===-1||e===-1?-1:(t<<8)+e}getInt32(){let t=this.getByte(),e=this.getByte(),i=this.getByte(),r=this.getByte();return(t<<24)+(e<<16)+(i<<8)+r}getBytes(t,e=!1){let i=this.bytes,r=this.pos,o=this.end;if(t){let s=r+t;s>o&&(s=o),this.pos=s;let a=i.subarray(r,s);return e?new Uint8ClampedArray(a):a}else{let s=i.subarray(r,o);return e?new Uint8ClampedArray(s):s}}peekByte(){let t=this.getByte();return this.pos--,t}peekBytes(t,e=!1){let i=this.getBytes(t,e);return this.pos-=i.length,i}skip(t){t||(t=1),this.pos+=t}reset(){this.pos=this.start}moveStart(){this.start=this.pos}makeSubStream(t,e){return new Cl(this.bytes,t,e)}decode(){return this.bytes}},md=Cl;var Rv=new Uint8Array(0),cf=class{constructor(t){if(this.pos=0,this.bufferLength=0,this.eof=!1,this.buffer=Rv,this.minBufferLength=512,t)for(;this.minBufferLengths&&(i=s)}else{for(;!this.eof;)this.readBlock();i=this.bufferLength}this.pos=i;let o=this.buffer.subarray(r,i);return e&&!(o instanceof Uint8ClampedArray)?new Uint8ClampedArray(o):o}peekByte(){let t=this.getByte();return this.pos--,t}peekBytes(t,e=!1){let i=this.getBytes(t,e);return this.pos-=i.length,i}skip(t){t||(t=1),this.pos+=t}reset(){this.pos=0}makeSubStream(t,e){let i=t+e;for(;this.bufferLength<=i&&!this.eof;)this.readBlock();return new md(this.buffer,t,e)}decode(){for(;!this.eof;)this.readBlock();return this.buffer.subarray(0,this.bufferLength)}readBlock(){throw new Ge(this.constructor.name,"readBlock")}ensureBuffer(t){let e=this.buffer;if(t<=e.byteLength)return e;let i=this.minBufferLength;for(;in===32||n===9||n===13||n===10,df=class extends Yt{constructor(t,e){super(e),this.stream=t,this.input=new Uint8Array(5),e&&(e=.8*e)}readBlock(){let r=this.stream,o=r.getByte();for(;Q0(o);)o=r.getByte();if(o===-1||o===126){this.eof=!0;return}let s=this.bufferLength,a,c;if(o===122){for(a=this.ensureBuffer(s+4),c=0;c<4;++c)a[s+c]=0;this.bufferLength+=4}else{let l=this.input;for(l[0]=o,c=1;c<5;++c){for(o=r.getByte();Q0(o);)o=r.getByte();if(l[c]=o,o===-1||o===126)break}if(a=this.ensureBuffer(s+c-1),this.bufferLength+=c-1,c<5){for(;c<5;++c)l[c]=33+84;this.eof=!0}let d=0;for(c=0;c<5;++c)d=d*85+(l[c]-33);for(c=3;c>=0;--c)a[s+c]=d&255,d>>=8}}},_0=df;var hf=class extends Yt{constructor(t,e){super(e),this.stream=t,this.firstDigit=-1,e&&(e=.5*e)}readBlock(){let e=this.stream.getBytes(8e3);if(!e.length){this.eof=!0;return}let i=e.length+1>>1,r=this.ensureBuffer(this.bufferLength+i),o=this.bufferLength,s=this.firstDigit;for(let a=0,c=e.length;a=48&&l<=57)d=l&15;else if(l>=65&&l<=70||l>=97&&l<=102)d=(l&15)+9;else if(l===62){this.eof=!0;break}else continue;s<0?s=d:(r[o++]=s<<4|d,s=-1)}s>=0&&this.eof&&(r[o++]=s<<4,s=-1),this.firstDigit=s,this.bufferLength=o}},$0=hf;var eb=new Int32Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Vv=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]),Bv=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]),Hv=[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],Uv=[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],uf=class extends Yt{constructor(t,e){super(e),this.stream=t;let i=t.getByte(),r=t.getByte();if(i===-1||r===-1)throw new Error(`Invalid header in flate stream: ${i}, ${r}`);if((i&15)!==8)throw new Error(`Unknown compression method in flate stream: ${i}, ${r}`);if(((i<<8)+r)%31!==0)throw new Error(`Bad FCHECK in flate stream: ${i}, ${r}`);if(r&32)throw new Error(`FDICT bit set in flate stream: ${i}, ${r}`);this.codeSize=0,this.codeBuf=0}readBlock(){let t,e,i=this.stream,r=this.getBits(3);if(r&1&&(this.eof=!0),r>>=1,r===0){let l;if((l=i.getByte())===-1)throw new Error("Bad block header in flate stream");let d=l;if((l=i.getByte())===-1)throw new Error("Bad block header in flate stream");if(d|=l<<8,(l=i.getByte())===-1)throw new Error("Bad block header in flate stream");let h=l;if((l=i.getByte())===-1)throw new Error("Bad block header in flate stream");if(h|=l<<8,h!==(~d&65535)&&(d!==0||h!==0))throw new Error("Bad uncompressed block length in flate stream");this.codeBuf=0,this.codeSize=0;let u=this.bufferLength;t=this.ensureBuffer(u+d);let f=u+d;if(this.bufferLength=f,d===0)i.peekByte()===-1&&(this.eof=!0);else for(let p=u;p0;)m[f++]=F}o=this.generateHuffmanTable(m.subarray(0,l)),s=this.generateHuffmanTable(m.subarray(l,g))}else throw new Error("Unknown block type in flate stream");t=this.buffer;let a=t?t.length:0,c=this.bufferLength;for(;;){let l=this.getCode(o);if(l<256){c+1>=a&&(t=this.ensureBuffer(c+1),a=t.length),t[c++]=l;continue}if(l===256){this.bufferLength=c;return}l-=257,l=Vv[l];let d=l>>16;d>0&&(d=this.getBits(d)),e=(l&65535)+d,l=this.getCode(s),l=Bv[l],d=l>>16,d>0&&(d=this.getBits(d));let h=(l&65535)+d;c+e>=a&&(t=this.ensureBuffer(c+e),a=t.length);for(let u=0;u>t,this.codeSize=i-=t,o}getCode(t){let e=this.stream,i=t[0],r=t[1],o=this.codeSize,s=this.codeBuf,a;for(;o>16,d=c&65535;if(l<1||o>l,this.codeSize=o-l,d}generateHuffmanTable(t){let e=t.length,i=0,r;for(r=0;ri&&(i=t[r]);let o=1<>=1;for(r=h;r0;if(!v||v<256)g[0]=v,m=1;else if(v>=258)if(v=0;o--)g[o]=d[s],s=u[s];else g[m++]=g[0];else if(v===256){f=9,l=258,m=0;continue}else{this.eof=!0,delete this.lzwState;break}if(P&&(u[l]=p,h[l]=h[p]+1,d[l]=g[0],l++,f=l+c&l+c-1?f:Math.min(Math.log(l+c)/.6931471805599453+1,12)|0),p=v,b+=m,e>>e&(1<0){let o=this.stream.getBytes(r);e.set(o,i),i+=r}}else{r=257-r;let o=t[1];e=this.ensureBuffer(i+r+1);for(let s=0;s{if(t===x.of("FlateDecode"))return new tb(n);if(t===x.of("LZWDecode")){let i=1;if(e instanceof R){let r=e.lookup(x.of("EarlyChange"));r instanceof N&&(i=r.asNumber())}return new ib(n,void 0,i)}if(t===x.of("ASCII85Decode"))return new _0(n);if(t===x.of("ASCIIHexDecode"))return new $0(n);if(t===x.of("RunLengthDecode"))return new nb(n);throw new Ja(t.asString())},ws=({dict:n,contents:t,transform:e})=>{let i=new md(t);e&&(i=e.createStream(i,t.length));let r=n.lookup(x.of("Filter")),o=n.lookup(x.of("DecodeParms"));if(r instanceof x)i=rb(i,r,o);else if(r instanceof H)for(let s=0,a=r.size();s{let t=n.MediaBox(),e=t.lookup(2,N).asNumber()-t.lookup(0,N).asNumber(),i=t.lookup(3,N).asNumber()-t.lookup(1,N).asNumber();return{left:0,bottom:0,right:e,top:i}},qv=n=>[1,0,0,1,-n.left,-n.bottom],Tl=class{static async for(t,e,i){return new Tl(t,e,i)}constructor(t,e,i){this.page=t;let r=e!=null?e:zv(t);this.width=r.right-r.left,this.height=r.top-r.bottom,this.boundingBox=r,this.transformationMatrix=i!=null?i:qv(r)}async embedIntoContext(t,e){let{Contents:i,Resources:r}=this.page.normalizedEntries();if(!i)throw new Qa;let o=this.decodeContents(i),{left:s,bottom:a,right:c,top:l}=this.boundingBox,d=t.flateStream(o,{Type:"XObject",Subtype:"Form",FormType:1,BBox:[s,a,c,l],Matrix:this.transformationMatrix,Resources:r});return e?(t.assign(e,d),e):t.register(d)}decodeContents(t){let e=Uint8Array.of(y.Newline),i=[];for(let r=0,o=t.size();r{if(n!==void 0)return t[n]},eo;(function(n){n.UseNone="UseNone",n.UseOutlines="UseOutlines",n.UseThumbs="UseThumbs",n.UseOC="UseOC"})(eo||(eo={}));var to;(function(n){n.L2R="L2R",n.R2L="R2L"})(to||(to={}));var io;(function(n){n.None="None",n.AppDefault="AppDefault"})(io||(io={}));var Fs;(function(n){n.Simplex="Simplex",n.DuplexFlipShortEdge="DuplexFlipShortEdge",n.DuplexFlipLongEdge="DuplexFlipLongEdge"})(Fs||(Fs={}));var no=class{constructor(t){this.dict=t}lookupBool(t){let e=this.dict.lookup(x.of(t));if(e instanceof yi)return e}lookupName(t){let e=this.dict.lookup(x.of(t));if(e instanceof x)return e}HideToolbar(){return this.lookupBool("HideToolbar")}HideMenubar(){return this.lookupBool("HideMenubar")}HideWindowUI(){return this.lookupBool("HideWindowUI")}FitWindow(){return this.lookupBool("FitWindow")}CenterWindow(){return this.lookupBool("CenterWindow")}DisplayDocTitle(){return this.lookupBool("DisplayDocTitle")}NonFullScreenPageMode(){return this.lookupName("NonFullScreenPageMode")}Direction(){return this.lookupName("Direction")}PrintScaling(){return this.lookupName("PrintScaling")}Duplex(){return this.lookupName("Duplex")}PickTrayByPDFSize(){return this.lookupBool("PickTrayByPDFSize")}PrintPageRange(){let t=this.dict.lookup(x.of("PrintPageRange"));if(t instanceof H)return t}NumCopies(){let t=this.dict.lookup(x.of("NumCopies"));if(t instanceof N)return t}getHideToolbar(){var t,e;return(e=(t=this.HideToolbar())===null||t===void 0?void 0:t.asBoolean())!==null&&e!==void 0?e:!1}getHideMenubar(){var t,e;return(e=(t=this.HideMenubar())===null||t===void 0?void 0:t.asBoolean())!==null&&e!==void 0?e:!1}getHideWindowUI(){var t,e;return(e=(t=this.HideWindowUI())===null||t===void 0?void 0:t.asBoolean())!==null&&e!==void 0?e:!1}getFitWindow(){var t,e;return(e=(t=this.FitWindow())===null||t===void 0?void 0:t.asBoolean())!==null&&e!==void 0?e:!1}getCenterWindow(){var t,e;return(e=(t=this.CenterWindow())===null||t===void 0?void 0:t.asBoolean())!==null&&e!==void 0?e:!1}getDisplayDocTitle(){var t,e;return(e=(t=this.DisplayDocTitle())===null||t===void 0?void 0:t.asBoolean())!==null&&e!==void 0?e:!1}getNonFullScreenPageMode(){var t,e;let i=(t=this.NonFullScreenPageMode())===null||t===void 0?void 0:t.decodeText();return(e=bd(i,eo))!==null&&e!==void 0?e:eo.UseNone}getReadingDirection(){var t,e;let i=(t=this.Direction())===null||t===void 0?void 0:t.decodeText();return(e=bd(i,to))!==null&&e!==void 0?e:to.L2R}getPrintScaling(){var t,e;let i=(t=this.PrintScaling())===null||t===void 0?void 0:t.decodeText();return(e=bd(i,io))!==null&&e!==void 0?e:io.AppDefault}getDuplex(){var t;let e=(t=this.Duplex())===null||t===void 0?void 0:t.decodeText();return bd(e,Fs)}getPickTrayByPDFSize(){var t;return(t=this.PickTrayByPDFSize())===null||t===void 0?void 0:t.asBoolean()}getPrintPageRange(){let t=this.PrintPageRange();if(!t)return[];let e=[];for(let i=0;inew no(n);no.create=n=>{let t=n.obj({});return new no(t)};var El=no;var Wv=/\/([^\0\t\n\f\r\ ]+)[\0\t\n\f\r\ ]*(\d*\.\d+|\d+)?[\0\t\n\f\r\ ]+Tf/,Al=class{constructor(t,e){this.dict=t,this.ref=e}T(){return this.dict.lookupMaybe(x.of("T"),G,M)}Ff(){let t=this.getInheritableAttribute(x.of("Ff"));return this.dict.context.lookupMaybe(t,N)}V(){let t=this.getInheritableAttribute(x.of("V"));return this.dict.context.lookup(t)}Kids(){return this.dict.lookupMaybe(x.of("Kids"),H)}DA(){let t=this.dict.lookup(x.of("DA"));if(t instanceof G||t instanceof M)return t}setKids(t){this.dict.set(x.of("Kids"),this.dict.context.obj(t))}getParent(){let t=this.dict.get(x.of("Parent"));if(t instanceof q){let e=this.dict.lookup(x.of("Parent"),R);return new Al(e,t)}}setParent(t){t?this.dict.set(x.of("Parent"),t):this.dict.delete(x.of("Parent"))}getFullyQualifiedName(){let t=this.getParent();return t?`${t.getFullyQualifiedName()}.${this.getPartialName()}`:this.getPartialName()}getPartialName(){var t;return(t=this.T())===null||t===void 0?void 0:t.decodeText()}setPartialName(t){t?this.dict.set(x.of("T"),M.fromText(t)):this.dict.delete(x.of("T"))}setDefaultAppearance(t){this.dict.set(x.of("DA"),G.of(t))}getDefaultAppearance(){let t=this.DA();return t instanceof M?t.decodeText():t==null?void 0:t.asString()}setFontSize(t){var e;let i=(e=this.getFullyQualifiedName())!==null&&e!==void 0?e:"",r=this.getDefaultAppearance();if(!r)throw new il(i);let o=Go(r,Wv);if(!o.match)throw new nl(i);let s=r.slice(0,o.pos-o.match[0].length),a=o.pos<=r.length?r.slice(o.pos):"",c=o.match[1],l=`${s} /${c} ${t} Tf ${a}`;this.setDefaultAppearance(l)}getFlags(){var t,e;return(e=(t=this.Ff())===null||t===void 0?void 0:t.asNumber())!==null&&e!==void 0?e:0}setFlags(t){this.dict.set(x.of("Ff"),N.of(t))}hasFlag(t){return(this.getFlags()&t)!==0}setFlag(t){let e=this.getFlags();this.setFlags(e|t)}clearFlag(t){let e=this.getFlags();this.setFlags(e&~t)}setFlagTo(t,e){e?this.setFlag(t):this.clearFlag(t)}getInheritableAttribute(t){let e;return this.ascend(i=>{e||(e=i.dict.get(t))}),e}ascend(t){t(this);let e=this.getParent();e&&e.ascend(t)}},Ps=Al;var Il=class{constructor(t){this.dict=t}W(){let t=this.dict.lookup(x.of("W"));if(t instanceof N)return t}getWidth(){var t,e;return(e=(t=this.W())===null||t===void 0?void 0:t.asNumber())!==null&&e!==void 0?e:1}setWidth(t){let e=this.dict.context.obj(t);this.dict.set(x.of("W"),e)}};Il.fromDict=n=>new Il(n);var xd=Il;var Ll=class{constructor(t){this.dict=t}Rect(){return this.dict.lookup(x.of("Rect"),H)}AP(){return this.dict.lookupMaybe(x.of("AP"),R)}F(){let t=this.dict.lookup(x.of("F"));return this.dict.context.lookupMaybe(t,N)}getRectangle(){var t;let e=this.Rect();return(t=e==null?void 0:e.asRectangle())!==null&&t!==void 0?t:{x:0,y:0,width:0,height:0}}setRectangle(t){let{x:e,y:i,width:r,height:o}=t,s=this.dict.context.obj([e,i,e+r,i+o]);this.dict.set(x.of("Rect"),s)}getAppearanceState(){let t=this.dict.lookup(x.of("AS"));if(t instanceof x)return t}setAppearanceState(t){this.dict.set(x.of("AS"),t)}setAppearances(t){this.dict.set(x.of("AP"),t)}ensureAP(){let t=this.AP();return t||(t=this.dict.context.obj({}),this.dict.set(x.of("AP"),t)),t}getNormalAppearance(){let e=this.ensureAP().get(x.of("N"));if(e instanceof q||e instanceof R)return e;throw new Error(`Unexpected N type: ${e==null?void 0:e.constructor.name}`)}setNormalAppearance(t){this.ensureAP().set(x.of("N"),t)}setRolloverAppearance(t){this.ensureAP().set(x.of("R"),t)}setDownAppearance(t){this.ensureAP().set(x.of("D"),t)}removeRolloverAppearance(){let t=this.AP();t==null||t.delete(x.of("R"))}removeDownAppearance(){let t=this.AP();t==null||t.delete(x.of("D"))}getAppearances(){let t=this.AP();if(!t)return;let e=t.lookup(x.of("N"),R,Fe),i=t.lookupMaybe(x.of("R"),R,Fe),r=t.lookupMaybe(x.of("D"),R,Fe);return{normal:e,rollover:i,down:r}}getFlags(){var t,e;return(e=(t=this.F())===null||t===void 0?void 0:t.asNumber())!==null&&e!==void 0?e:0}setFlags(t){this.dict.set(x.of("F"),N.of(t))}hasFlag(t){return(this.getFlags()&t)!==0}setFlag(t){let e=this.getFlags();this.setFlags(e|t)}clearFlag(t){let e=this.getFlags();this.setFlags(e&~t)}setFlagTo(t,e){e?this.setFlag(t):this.clearFlag(t)}};Ll.fromDict=n=>new Ll(n);var yd=Ll;var Ol=class{constructor(t){this.dict=t}R(){let t=this.dict.lookup(x.of("R"));if(t instanceof N)return t}BC(){let t=this.dict.lookup(x.of("BC"));if(t instanceof H)return t}BG(){let t=this.dict.lookup(x.of("BG"));if(t instanceof H)return t}CA(){let t=this.dict.lookup(x.of("CA"));if(t instanceof M||t instanceof G)return t}RC(){let t=this.dict.lookup(x.of("RC"));if(t instanceof M||t instanceof G)return t}AC(){let t=this.dict.lookup(x.of("AC"));if(t instanceof M||t instanceof G)return t}getRotation(){var t;return(t=this.R())===null||t===void 0?void 0:t.asNumber()}getBorderColor(){let t=this.BC();if(!t)return;let e=[];for(let i=0,r=t==null?void 0:t.size();inew Ol(n);var ks=Ol;var ro=class extends yd{MK(){let t=this.dict.lookup(x.of("MK"));if(t instanceof R)return t}BS(){let t=this.dict.lookup(x.of("BS"));if(t instanceof R)return t}DA(){let t=this.dict.lookup(x.of("DA"));if(t instanceof G||t instanceof M)return t}P(){let t=this.dict.get(x.of("P"));if(t instanceof q)return t}setP(t){this.dict.set(x.of("P"),t)}setDefaultAppearance(t){this.dict.set(x.of("DA"),G.of(t))}getDefaultAppearance(){let t=this.DA();return t instanceof M?t.decodeText():t==null?void 0:t.asString()}getAppearanceCharacteristics(){let t=this.MK();if(t)return ks.fromDict(t)}getOrCreateAppearanceCharacteristics(){let t=this.MK();if(t)return ks.fromDict(t);let e=ks.fromDict(this.dict.context.obj({}));return this.dict.set(x.of("MK"),e.dict),e}getBorderStyle(){let t=this.BS();if(t)return xd.fromDict(t)}getOrCreateBorderStyle(){let t=this.BS();if(t)return xd.fromDict(t);let e=xd.fromDict(this.dict.context.obj({}));return this.dict.set(x.of("BS"),e.dict),e}getOnValue(){var t;let e=(t=this.getAppearances())===null||t===void 0?void 0:t.normal;if(e instanceof R){let i=e.keys();for(let r=0,o=i.length;rnew ro(n);ro.create=(n,t)=>{let e=n.obj({Type:"Annot",Subtype:"Widget",Rect:[0,0,0,0],Parent:t});return new ro(e)};var oo=ro;var Ml=class extends Ps{FT(){let t=this.getInheritableAttribute(x.of("FT"));return this.dict.context.lookup(t,x)}getWidgets(){let t=this.Kids();if(!t)return[oo.fromDict(this.dict)];let e=new Array(t.size());for(let i=0,r=t.size();ie.size())throw new hn(t,0,e.size());e.remove(t)}else{if(t!==0)throw new hn(t,0,0);this.setKids([])}}normalizedEntries(){let t=this.Kids();return t||(t=this.dict.context.obj([this.ref]),this.dict.set(x.of("Kids"),t)),{Kids:t}}};Ml.fromDict=(n,t)=>new Ml(n,t);var Et=Ml;var gf=class extends Et{Opt(){return this.dict.lookupMaybe(x.of("Opt"),G,M,H)}setOpt(t){this.dict.set(x.of("Opt"),this.dict.context.obj(t))}getExportValues(){let t=this.Opt();if(!t)return;if(t instanceof G||t instanceof M)return[t];let e=[];for(let i=0,r=t.size();ie.size())throw new hn(t,0,e.size());e.remove(t)}}normalizeExportValues(){var t,e,i,r;let o=(t=this.getExportValues())!==null&&t!==void 0?t:[],s=[],a=this.getWidgets();for(let c=0,l=a.length;cnew so(n,t);so.create=n=>{let t=n.obj({FT:"Btn",Kids:[]}),e=n.register(t);return new so(t,e)};var bn=so;var Xe=n=>1<1){if(!this.hasFlag(oe.MultiSelect))throw new tl;this.dict.set(x.of("V"),this.dict.context.obj(t))}this.updateSelectedIndices(t)}valuesAreValid(t){let e=this.getOptions();for(let i=0,r=t.length;io===(s.display||s.value).decodeText()))return!1}return!0}updateSelectedIndices(t){if(t.length>1){let e=new Array(t.length),i=this.getOptions();for(let r=0,o=t.length;rs===(a.display||a.value).decodeText())}this.dict.set(x.of("I"),this.dict.context.obj(e.sort()))}else this.dict.delete(x.of("I"))}getValues(){let t=this.V();if(t instanceof G||t instanceof M)return[t];if(t instanceof H){let e=[];for(let i=0,r=t.size();i0){let s=o.lookup(0,G,M),a=o.lookupMaybe(1,G,M);e.push({value:s,display:a||s})}}return e}return[]}},Ds=mf;var ao=class extends Ds{};ao.fromDict=(n,t)=>new ao(n,t);ao.create=n=>{let t=n.obj({FT:"Ch",Ff:oe.Combo,Kids:[]}),e=n.register(t);return new ao(t,e)};var xn=ao;var lo=class extends Ps{addField(t){let{Kids:e}=this.normalizedEntries();e==null||e.push(t)}normalizedEntries(){let t=this.Kids();return t||(t=this.dict.context.obj([]),this.dict.set(x.of("Kids"),t)),{Kids:t}}};lo.fromDict=(n,t)=>new lo(n,t);lo.create=n=>{let t=n.obj({}),e=n.register(t);return new lo(t,e)};var yn=lo;var Nl=class extends Et{};Nl.fromDict=(n,t)=>new Nl(n,t);var rr=Nl;var co=class extends Et{MaxLen(){let t=this.dict.lookup(x.of("MaxLen"));if(t instanceof N)return t}Q(){let t=this.dict.lookup(x.of("Q"));if(t instanceof N)return t}setMaxLength(t){this.dict.set(x.of("MaxLen"),N.of(t))}removeMaxLength(){this.dict.delete(x.of("MaxLen"))}getMaxLength(){var t;return(t=this.MaxLen())===null||t===void 0?void 0:t.asNumber()}setQuadding(t){this.dict.set(x.of("Q"),N.of(t))}getQuadding(){var t;return(t=this.Q())===null||t===void 0?void 0:t.asNumber()}setValue(t){this.dict.set(x.of("V"),t)}removeValue(){this.dict.delete(x.of("V"))}getValue(){let t=this.V();if(t instanceof G||t instanceof M)return t}};co.fromDict=(n,t)=>new co(n,t);co.create=n=>{let t=n.obj({FT:"Tx",Kids:[]}),e=n.register(t);return new co(t,e)};var wn=co;var ho=class extends nr{};ho.fromDict=(n,t)=>new ho(n,t);ho.create=n=>{let t=n.obj({FT:"Btn",Ff:dt.PushButton,Kids:[]}),e=n.register(t);return new ho(t,e)};var vn=ho;var uo=class extends nr{setValue(t){if(!this.getOnValues().includes(t)&&t!==x.of("Off"))throw new un;this.dict.set(x.of("V"),t);let i=this.getWidgets();for(let r=0,o=i.length;rnew uo(n,t);uo.create=n=>{let t=n.obj({FT:"Btn",Ff:dt.Radio,Kids:[]}),e=n.register(t);return new uo(t,e)};var Fn=uo;var fo=class extends Ds{};fo.fromDict=(n,t)=>new fo(n,t);fo.create=n=>{let t=n.obj({FT:"Ch",Kids:[]}),e=n.register(t);return new fo(t,e)};var Pn=fo;var Ss=n=>{if(!n)return[];let t=[];for(let e=0,i=n.size();ejv(n)?yn.fromDict(n,t):Kv(n,t),jv=n=>{let t=n.lookup(x.of("Kids"));if(t instanceof H)for(let e=0,i=t.size();e{let e=xf(n,x.of("FT")),i=n.context.lookup(e,x);return i===x.of("Btn")?Gv(n,t):i===x.of("Ch")?Xv(n,t):i===x.of("Tx")?wn.fromDict(n,t):i===x.of("Sig")?rr.fromDict(n,t):Et.fromDict(n,t)},Gv=(n,t)=>{var e;let i=xf(n,x.of("Ff")),r=n.context.lookupMaybe(i,N),o=(e=r==null?void 0:r.asNumber())!==null&&e!==void 0?e:0;return bf(o,dt.PushButton)?vn.fromDict(n,t):bf(o,dt.Radio)?Fn.fromDict(n,t):bn.fromDict(n,t)},Xv=(n,t)=>{var e;let i=xf(n,x.of("Ff")),r=n.context.lookupMaybe(i,N),o=(e=r==null?void 0:r.asNumber())!==null&&e!==void 0?e:0;return bf(o,oe.Combo)?xn.fromDict(n,t):Pn.fromDict(n,t)},bf=(n,t)=>(n&t)!==0,xf=(n,t)=>{let e;return ob(n,i=>{e||(e=i.get(t))}),e},ob=(n,t)=>{t(n);let e=n.lookupMaybe(x.of("Parent"),R);e&&ob(e,t)};var po=class{constructor(t){this.dict=t}Fields(){let t=this.dict.lookup(x.of("Fields"));if(t instanceof H)return t}getFields(){let{Fields:t}=this.normalizedEntries(),e=new Array(t.size());for(let i=0,r=t.size();i{if(i)for(let r=0,o=i.length;rnew po(n);po.create=n=>{let t=n.obj({Fields:[]});return new po(t)};var or=po;var go=class extends R{Pages(){return this.lookup(x.of("Pages"),R)}AcroForm(){return this.lookupMaybe(x.of("AcroForm"),R)}getAcroForm(){let t=this.AcroForm();if(t)return or.fromDict(t)}getOrCreateAcroForm(){let t=this.getAcroForm();if(!t){t=or.create(this.context);let e=this.context.register(t.dict);this.set(x.of("AcroForm"),e)}return t}ViewerPreferences(){return this.lookupMaybe(x.of("ViewerPreferences"),R)}getViewerPreferences(){let t=this.ViewerPreferences();if(t)return El.fromDict(t)}getOrCreateViewerPreferences(){let t=this.getViewerPreferences();if(!t){t=El.create(this.context);let e=this.context.register(t.dict);this.set(x.of("ViewerPreferences"),e)}return t}insertLeafNode(t,e){let i=this.get(x.of("Pages"));return this.Pages().insertLeafNode(t,e)||i}removeLeafNode(t){this.Pages().removeLeafNode(t)}};go.withContextAndPages=(n,t)=>{let e=new Map;return e.set(x.of("Type"),x.of("Catalog")),e.set(x.of("Pages"),t),new go(e,n)};go.fromMapWithContext=(n,t)=>new go(n,t);var Cs=go;var vi=class extends R{Parent(){return this.lookup(x.of("Parent"))}Kids(){return this.lookup(x.of("Kids"),H)}Count(){return this.lookup(x.of("Count"),N)}pushTreeNode(t){this.Kids().push(t)}pushLeafNode(t){let e=this.Kids();this.insertLeafKid(e.size(),t)}insertLeafNode(t,e){let i=this.Kids(),r=this.Count().asNumber();if(e>r)throw new as(e,r);let o=e;for(let s=0,a=i.size();so)return l.insertLeafNode(t,o)||c;o-=l.Count().asNumber()}l instanceof tt&&(o-=1)}if(o===0){this.insertLeafKid(i.size(),t);return}throw new ls(e,"insertLeafNode")}removeLeafNode(t,e=!0){let i=this.Kids(),r=this.Count().asNumber();if(t>=r)throw new as(t,r);let o=t;for(let s=0,a=i.size();so){l.removeLeafNode(o,e),e&&l.Kids().size()===0&&i.remove(s);return}else o-=l.Count().asNumber();if(l instanceof tt)if(o===0){this.removeKid(s);return}else o-=1}throw new ls(t,"removeLeafNode")}ascend(t){t(this);let e=this.Parent();e&&e.ascend(t)}traverse(t){let e=this.Kids();for(let i=0,r=e.size();i{let o=r.Count().asNumber()+1;r.set(x.of("Count"),N.of(o))}),i.insert(t,e)}removeKid(t){let e=this.Kids();e.lookup(t)instanceof tt&&this.ascend(r=>{let o=r.Count().asNumber()-1;r.set(x.of("Count"),N.of(o))}),e.remove(t)}};vi.withContext=(n,t)=>{let e=new Map;return e.set(x.of("Type"),x.of("Pages")),e.set(x.of("Kids"),n.obj([])),e.set(x.of("Count"),n.obj(0)),t&&e.set(x.of("Parent"),t),new vi(e,n)};vi.fromMapWithContext=(n,t)=>new vi(n,t);var Ts=vi;var Qe=new Uint8Array(256);Qe[y.Zero]=1;Qe[y.One]=1;Qe[y.Two]=1;Qe[y.Three]=1;Qe[y.Four]=1;Qe[y.Five]=1;Qe[y.Six]=1;Qe[y.Seven]=1;Qe[y.Eight]=1;Qe[y.Nine]=1;var vd=new Uint8Array(256);vd[y.Period]=1;vd[y.Plus]=1;vd[y.Minus]=1;var Rl=new Uint8Array(256);for(let n=0,t=256;nNumber.MAX_SAFE_INTEGER)if(this.capNumbers){let i=`Parsed number that is too large for some PDF readers: ${t}, using Number.MAX_SAFE_INTEGER instead.`;return console.warn(i),Number.MAX_SAFE_INTEGER}else{let i=`Parsed number that is too large for some PDF readers: ${t}, not capping.`;console.warn(i)}return e}skipWhitespace(){for(;!this.bytes.done()&&Zt[this.bytes.peek()];)this.bytes.next()}skipLine(){for(;!this.bytes.done();){let t=this.bytes.peek();if(t===sb||t===ab)return;this.bytes.next()}}skipComment(){if(this.bytes.peek()!==y.Percent)return!1;for(;!this.bytes.done();){let t=this.bytes.peek();if(t===sb||t===ab)return!0;this.bytes.next()}return!0}skipWhitespaceAndComments(){for(this.skipWhitespace();this.skipComment();)this.skipWhitespace()}matchKeyword(t){let e=this.bytes.offset();for(let i=0,r=t.length;i=this.length}offset(){return this.idx}slice(t,e){return this.bytes.slice(t,e)}position(){return{line:this.line,column:this.column,offset:this.idx}}};mo.of=n=>new mo(n);mo.fromPDFRawStream=n=>mo.of(ws(n).decode());var sr=mo;var{Space:Zv,CarriageReturn:Vl,Newline:Bl}=y,Hl=[y.s,y.t,y.r,y.e,y.a,y.m],Fd=[y.e,y.n,y.d,y.s,y.t,y.r,y.e,y.a,y.m],xe={header:[y.Percent,y.P,y.D,y.F,y.Dash],eof:[y.Percent,y.Percent,y.E,y.O,y.F],obj:[y.o,y.b,y.j],endobj:[y.e,y.n,y.d,y.o,y.b,y.j],xref:[y.x,y.r,y.e,y.f],trailer:[y.t,y.r,y.a,y.i,y.l,y.e,y.r],startxref:[y.s,y.t,y.a,y.r,y.t,y.x,y.r,y.e,y.f],true:[y.t,y.r,y.u,y.e],false:[y.f,y.a,y.l,y.s,y.e],null:[y.n,y.u,y.l,y.l],stream:Hl,streamEOF1:[...Hl,Zv,Vl,Bl],streamEOF2:[...Hl,Vl,Bl],streamEOF3:[...Hl,Vl],streamEOF4:[...Hl,Bl],endstream:Fd,EOF1endstream:[Vl,Bl,...Fd],EOF2endstream:[Vl,...Fd],EOF3endstream:[Bl,...Fd]};var bo=class extends lb{constructor(t,e,i=!1,r){super(t,i),this.context=e,this.cryptoFactory=r}parseObject(t){if(this.skipWhitespaceAndComments(),this.matchKeyword(xe.true))return yi.True;if(this.matchKeyword(xe.false))return yi.False;if(this.matchKeyword(xe.null))return Me;let e=this.bytes.peek();if(e===y.LessThan&&this.bytes.peekAhead(1)===y.LessThan)return this.parseDictOrStream(t);if(e===y.LessThan)return this.parseHexString(t);if(e===y.LeftParen)return this.parseString(t);if(e===y.ForwardSlash)return this.parseName();if(e===y.LeftSquareBracket)return this.parseArray(t);if(Rl[e])return this.parseNumberOrRef();throw new ol(this.bytes.position(),e)}parseNumberOrRef(){let t=this.parseRawNumber();this.skipWhitespaceAndComments();let e=this.bytes.offset();if(Qe[this.bytes.peek()]){let i=this.parseRawNumber();if(this.skipWhitespaceAndComments(),this.bytes.peek()===y.R)return this.bytes.assertNext(y.R),q.of(t,i)}return this.bytes.moveTo(e),N.of(t)}parseHexString(t){let e="";for(this.bytes.assertNext(y.LessThan);!this.bytes.done()&&this.bytes.peek()!==y.GreaterThan;)e+=kt(this.bytes.next());return this.bytes.assertNext(y.GreaterThan),this.cryptoFactory&&t&&(e=this.cryptoFactory.createCipherTransform(t.objectNumber,t.generationNumber).decryptBytes(M.of(e).asBytes()).reduce((o,s)=>o+s.toString(16).padStart(2,"0"),"")),M.of(e)}parseString(t){let e=0,i=!1,r="";for(;!this.bytes.done();){let o=this.bytes.next();if(r+=kt(o),i||(o===y.LeftParen&&(e+=1),o===y.RightParen&&(e-=1)),o===y.BackSlash?i=!i:i&&(i=!1),e===0){let s=r.substring(1,r.length-1);return this.cryptoFactory&&t&&(s=this.cryptoFactory.createCipherTransform(t.objectNumber,t.generationNumber).decryptString(s)),G.of(s)}}throw new ll(this.bytes.position())}parseName(){this.bytes.assertNext(y.ForwardSlash);let t="";for(;!this.bytes.done();){let e=this.bytes.peek();if(Zt[e]||Tt[e])break;t+=kt(e),this.bytes.next()}return x.of(t)}parseArray(t){this.bytes.assertNext(y.LeftSquareBracket),this.skipWhitespaceAndComments();let e=H.withContext(this.context);for(;this.bytes.peek()!==y.RightSquareBracket;){let i=this.parseObject(t);e.push(i),this.skipWhitespaceAndComments()}return this.bytes.assertNext(y.RightSquareBracket),e}parseDict(t){this.bytes.assertNext(y.LessThan),this.bytes.assertNext(y.LessThan),this.skipWhitespaceAndComments();let e=new Map;for(;!this.bytes.done()&&this.bytes.peek()!==y.GreaterThan&&this.bytes.peekAhead(1)!==y.GreaterThan;){let r=this.parseName(),o=this.parseObject(t);e.set(r,o),this.skipWhitespaceAndComments()}this.skipWhitespaceAndComments(),this.bytes.assertNext(y.GreaterThan),this.bytes.assertNext(y.GreaterThan);let i=e.get(x.of("Type"));return i===x.of("Catalog")?Cs.fromMapWithContext(e,this.context):i===x.of("Pages")?Ts.fromMapWithContext(e,this.context):i===x.of("Page")?tt.fromMapWithContext(e,this.context):R.fromMapWithContext(e,this.context)}parseDictOrStream(t){let e=this.bytes.position(),i=this.parseDict(t);if(this.skipWhitespaceAndComments(),!this.matchKeyword(xe.streamEOF1)&&!this.matchKeyword(xe.streamEOF2)&&!this.matchKeyword(xe.streamEOF3)&&!this.matchKeyword(xe.streamEOF4)&&!this.matchKeyword(xe.stream))return i;let r=this.bytes.offset(),o,s=i.get(x.of("Length"));s instanceof N?(o=r+s.asNumber(),this.bytes.moveTo(o),this.skipWhitespaceAndComments(),this.matchKeyword(xe.endstream)||(this.bytes.moveTo(r),o=this.findEndOfStreamFallback(e))):o=this.findEndOfStreamFallback(e);let a=this.bytes.slice(r,o);return this.cryptoFactory&&t&&(a=this.cryptoFactory.createCipherTransform(t.objectNumber,t.generationNumber).decryptBytes(a)),wi.of(i,a)}findEndOfStreamFallback(t){let e=1,i=this.bytes.offset();for(;!this.bytes.done()&&(i=this.bytes.offset(),this.matchKeyword(xe.stream)?e+=1:this.matchKeyword(xe.EOF1endstream)||this.matchKeyword(xe.EOF2endstream)||this.matchKeyword(xe.EOF3endstream)||this.matchKeyword(xe.endstream)?e-=1:this.bytes.next(),e!==0););if(e!==0)throw new al(t);return i}};bo.forBytes=(n,t,e)=>new bo(sr.of(n),t,e);bo.forByteStream=(n,t,e=!1)=>new bo(n,t,e);var Es=bo;var Ul=class extends Es{constructor(t,e){super(sr.fromPDFRawStream(t),t.dict.context);let{dict:i}=t;this.alreadyParsed=!1,this.shouldWaitForTick=e||(()=>!1),this.firstOffset=i.lookup(x.of("First"),N).asNumber(),this.objectCount=i.lookup(x.of("N"),N).asNumber()}async parseIntoContext(){if(this.alreadyParsed)throw new dn("PDFObjectStreamParser","parseIntoContext");this.alreadyParsed=!0;let t=this.parseOffsetsAndObjectNumbers();for(let e=0,i=t.length;enew Ul(n,t);var Pd=Ul;var zl=class{constructor(t){this.alreadyParsed=!1,this.dict=t.dict,this.bytes=sr.fromPDFRawStream(t),this.context=this.dict.context;let e=this.dict.lookup(x.of("Size"),N),i=this.dict.lookup(x.of("Index"));if(i instanceof H){this.subsections=[];for(let o=0,s=i.size();onew zl(n);var kd=zl;var ql=class extends Es{constructor(t,e=1/0,i=!1,r=!1,o=!1,s){super(sr.of(t),Yr.create(),o,s),this.alreadyParsed=!1,this.parsedObjects=0,this.shouldWaitForTick=()=>(this.parsedObjects+=1,this.parsedObjects%this.objectsPerTick===0),this.objectsPerTick=e,this.throwOnInvalidObject=i,this.warnOnInvalidObjects=r,this.context.isDecrypted=!!(s!=null&&s.encryptionKey)}async parseDocument(){if(this.alreadyParsed)throw new dn("PDFParser","parseDocument");this.alreadyParsed=!0,this.context.header=this.parseHeader();let t;for(;!this.bytes.done();){await this.parseDocumentSection();let e=this.bytes.offset();if(e===t)throw new cl(this.bytes.position());t=e}return this.maybeRecoverRoot(),this.context.lookup(q.of(0))&&(console.warn("Removing parsed object: 0 0 R"),this.context.delete(q.of(0))),this.context}maybeRecoverRoot(){let t=i=>i instanceof R&&i.lookup(x.of("Type"))===x.of("Catalog"),e=this.context.lookup(this.context.trailerInfo.Root);if(!t(e)){let i=this.context.enumerateIndirectObjects();for(let r=0,o=i.length;r=y.Space&&e<=y.Tilde&&(this.matchKeyword(xe.xref)||this.matchKeyword(xe.trailer)||this.matchKeyword(xe.startxref)||this.matchIndirectObjectHeader())){this.bytes.moveTo(t);break}this.bytes.next()}}skipBinaryHeaderComment(){this.skipWhitespaceAndComments();try{let t=this.bytes.offset();this.parseIndirectObjectHeader(),this.bytes.moveTo(t)}catch(t){this.bytes.next(),this.skipWhitespaceAndComments()}}};ql.forBytesWithOptions=(n,t,e,i,r,o)=>new ql(n,t,e,i,r,o);var Wl=ql;var zi=n=>1<n instanceof x?n:x.of(n),j=n=>n instanceof N?n:N.of(n),$=n=>n instanceof N?n.asNumber():n;var Is;(function(n){n.Degrees="degrees",n.Radians="radians"})(Is||(Is={}));var Yv=n=>(S(n,"radianAngle",["number"]),{type:Is.Radians,angle:n}),X=n=>(S(n,"degreeAngle",["number"]),{type:Is.Degrees,angle:n}),{Radians:cb,Degrees:db}=Is,Jt=n=>n*Math.PI/180,hb=n=>n*180/Math.PI,qe=n=>n.type===cb?n.angle:n.type===db?Jt(n.angle):Kn(`Invalid rotation: ${JSON.stringify(n)}`),jl=n=>n.type===cb?hb(n.angle):n.type===db?n.angle:Kn(`Invalid rotation: ${JSON.stringify(n)}`),Qt=(n=0)=>{let t=n/90%4;return t===0?0:t===1?90:t===2?180:t===3?270:0},qi=(n,t=0)=>{let e=Qt(t);return e===90||e===270?{width:n.height,height:n.width}:{width:n.width,height:n.height}},wf=(n,t=0,e=0)=>{let{x:i,y:r,width:o,height:s}=n,a=Qt(e),c=t/2;return a===0?{x:i-c,y:r-c,width:o,height:s}:a===90?{x:i-s+c,y:r-c,width:s,height:o}:a===180?{x:i-o+c,y:r-s+c,width:o,height:s}:a===270?{x:i-c,y:r-o+c,width:s,height:o}:{x:i-c,y:r-c,width:o,height:s}};var Kl=()=>_.of(ee.ClipNonZero),Jv=()=>_.of(ee.ClipEvenOdd),{cos:Dd,sin:Sd,tan:Cd}=Math,$t=(n,t,e,i,r,o)=>_.of(ee.ConcatTransformationMatrix,[j(n),j(t),j(e),j(i),j(r),j(o)]),mt=(n,t)=>$t(1,0,0,1,n,t),ar=(n,t)=>$t(n,0,0,t,0,0),lr=n=>$t(Dd($(n)),Sd($(n)),-Sd($(n)),Dd($(n)),0,0),Ls=n=>lr(Jt($(n))),Os=(n,t)=>$t(1,Cd($(n)),Cd($(t)),1,0,0),Qv=(n,t)=>Os(Jt($(n)),Jt($(t))),wo=(n,t)=>_.of(ee.SetLineDashPattern,[`[${n.map(j).join(" ")}]`,j(t)]),_v=()=>wo([],0),_t;(function(n){n[n.Butt=0]="Butt",n[n.Round=1]="Round",n[n.Projecting=2]="Projecting"})(_t||(_t={}));var Ms=n=>_.of(ee.SetLineCapStyle,[j(n)]),yo;(function(n){n[n.Miter=0]="Miter",n[n.Round=1]="Round",n[n.Bevel=2]="Bevel"})(yo||(yo={}));var $v=n=>_.of(ee.SetLineJoinStyle,[j(n)]),ji=n=>_.of(ee.SetGraphicsStateParams,[As(n)]),Ne=()=>_.of(ee.PushGraphicsState),Re=()=>_.of(ee.PopGraphicsState),kn=n=>_.of(ee.SetLineWidth,[j(n)]),bt=(n,t,e,i,r,o)=>_.of(ee.AppendBezierCurve,[j(n),j(t),j(e),j(i),j(r),j(o)]),Ns=(n,t,e,i)=>_.of(ee.CurveToReplicateInitialPoint,[j(n),j(t),j(e),j(i)]),ei=()=>_.of(ee.ClosePath),At=(n,t)=>_.of(ee.MoveTo,[j(n),j(t)]),Ve=(n,t)=>_.of(ee.LineTo,[j(n),j(t)]),ub=(n,t,e,i)=>_.of(ee.AppendRectangle,[j(n),j(t),j(e),j(i)]),eF=(n,t,e)=>ub(n,t,e,e),vo=()=>_.of(ee.StrokePath),Wi;(function(n){n.NonZero="f",n.EvenOdd="f*"})(Wi||(Wi={}));var Gl=()=>_.of(ee.FillNonZero),Ff=()=>_.of(ee.FillEvenOdd),Xl=()=>_.of(ee.FillNonZeroAndStroke),Zl=()=>_.of(ee.EndPath),Pf=()=>_.of(ee.NextLine),tF=(n,t)=>_.of(ee.MoveText,[j(n),j(t)]),Yl=n=>_.of(ee.ShowText,[n]),Jl=()=>_.of(ee.BeginText),Ql=()=>_.of(ee.EndText),Fo=(n,t)=>_.of(ee.SetFontAndSize,[As(n),j(t)]),iF=n=>_.of(ee.SetCharacterSpacing,[j(n)]),nF=n=>_.of(ee.SetWordSpacing,[j(n)]),rF=n=>_.of(ee.SetTextHorizontalScaling,[j(n)]),kf=n=>_.of(ee.SetTextLineHeight,[j(n)]),oF=n=>_.of(ee.SetTextRise,[j(n)]),vf;(function(n){n[n.Fill=0]="Fill",n[n.Outline=1]="Outline",n[n.FillAndOutline=2]="FillAndOutline",n[n.Invisible=3]="Invisible",n[n.FillAndClip=4]="FillAndClip",n[n.OutlineAndClip=5]="OutlineAndClip",n[n.FillAndOutlineAndClip=6]="FillAndOutlineAndClip",n[n.Clip=7]="Clip"})(vf||(vf={}));var Td=n=>_.of(ee.SetTextRenderingMode,[j(n)]),fb=(n,t,e,i,r,o)=>_.of(ee.SetTextMatrix,[j(n),j(t),j(e),j(i),j(r),j(o)]),Rs=(n,t,e,i,r)=>fb(Dd($(n)),Sd($(n))+Cd($(t)),-Sd($(n))+Cd($(e)),Dd($(n)),i,r),sF=(n,t,e,i,r)=>Rs(Jt($(n)),Jt($(t)),Jt($(e)),i,r),Vs=n=>_.of(ee.DrawObject,[As(n)]),Df=n=>_.of(ee.NonStrokingColorGray,[j(n)]),Sf=n=>_.of(ee.StrokingColorGray,[j(n)]),Cf=(n,t,e)=>_.of(ee.NonStrokingColorRgb,[j(n),j(t),j(e)]),Tf=(n,t,e)=>_.of(ee.StrokingColorRgb,[j(n),j(t),j(e)]),Ef=(n,t,e,i)=>_.of(ee.NonStrokingColorCmyk,[j(n),j(t),j(e),j(i)]),Af=(n,t,e,i)=>_.of(ee.StrokingColorCmyk,[j(n),j(t),j(e),j(i)]),Ed=n=>_.of(ee.BeginMarkedContent,[As(n)]),Ad=()=>_.of(ee.EndMarkedContent);var Ob=Un(Lb(),1),Po;(function(n){n.Grayscale="Grayscale",n.RGB="RGB",n.CMYK="CMYK"})(Po||(Po={}));var Nd=n=>(lt(n,"gray",0,1),{type:Po.Grayscale,gray:n}),ne=(n,t,e)=>(lt(n,"red",0,1),lt(t,"green",0,1),lt(e,"blue",0,1),{type:Po.RGB,red:n,green:t,blue:e}),Rd=(n,t,e,i)=>(lt(n,"cyan",0,1),lt(t,"magenta",0,1),lt(e,"yellow",0,1),lt(i,"key",0,1),{type:Po.CMYK,cyan:n,magenta:t,yellow:e,key:i}),Rf=n=>{S(n,"color",["string"]);let t=(0,Ob.default)(n).unitObject();return{rgb:ne(t.r,t.g,t.b),alpha:t.alpha}},{Grayscale:Vf,RGB:Bf,CMYK:Hf}=Po,ti=n=>n.type===Vf?Df(n.gray):n.type===Bf?Cf(n.red,n.green,n.blue):n.type===Hf?Ef(n.cyan,n.magenta,n.yellow,n.key):Kn(`Invalid color: ${JSON.stringify(n)}`),Dn=n=>n.type===Vf?Sf(n.gray):n.type===Bf?Tf(n.red,n.green,n.blue):n.type===Hf?Af(n.cyan,n.magenta,n.yellow,n.key):Kn(`Invalid color: ${JSON.stringify(n)}`),ht=(n,t=1)=>(n==null?void 0:n.length)===1?Nd(n[0]*t):(n==null?void 0:n.length)===3?ne(n[0]*t,n[1]*t,n[2]*t):(n==null?void 0:n.length)===4?Rd(n[0]*t,n[1]*t,n[2]*t,n[3]*t):void 0,Vd=n=>n.type===Vf?[n.gray]:n.type===Bf?[n.red,n.green,n.blue]:n.type===Hf?[n.cyan,n.magenta,n.yellow,n.key]:Kn(`Invalid color: ${JSON.stringify(n)}`);var Z=0,Y=0,le=0,ce=0,tc=0,ic=0,Mb=new Map([["A",7],["a",7],["C",6],["c",6],["H",1],["h",1],["L",2],["l",2],["M",2],["m",2],["Q",4],["q",4],["S",4],["s",4],["T",2],["t",2],["V",1],["v",1],["Z",0],["z",0]]),FF=n=>{let t,e=[],i=[],r="",o=!1,s=0;for(let a of n)if(Mb.has(a))s=Mb.get(a),t&&(r.length>0&&(i[i.length]=+r),e[e.length]={cmd:t,args:i},i=[],r="",o=!1),t=a;else if([" ",","].includes(a)||a==="-"&&r.length>0&&r[r.length-1]!=="e"||a==="."&&o){if(r.length===0)continue;i.length===s?(e[e.length]={cmd:t,args:i},i=[+r],t==="M"&&(t="L"),t==="m"&&(t="l")):i[i.length]=+r,o=a===".",r=["-","."].includes(a)?a:""}else r+=a,a==="."&&(o=!0);return r.length>0&&(i.length===s?(e[e.length]={cmd:t,args:i},i=[+r],t==="M"&&(t="L"),t==="m"&&(t="l")):i[i.length]=+r),e[e.length]={cmd:t,args:i},e},PF=n=>{Z=Y=le=ce=tc=ic=0;let t=[];for(let e=0;e{let[i,r,o,s,a,c,l]=e,d=kF(c,l,i,r,s,a,o,n,t),h=[];for(let u of d){let f=DF(...u);h.push(bt(...f))}return h},kF=(n,t,e,i,r,o,s,a,c)=>{let l=s*(Math.PI/180),d=Math.sin(l),h=Math.cos(l);e=Math.abs(e),i=Math.abs(i),le=h*(a-n)*.5+d*(c-t)*.5,ce=h*(c-t)*.5-d*(a-n)*.5;let u=le*le/(e*e)+ce*ce/(i*i);u>1&&(u=Math.sqrt(u),e*=u,i*=u);let f=h/e,p=d/e,g=-d/i,m=h/i,b=f*a+p*c,w=g*a+m*c,F=f*n+p*t,v=g*n+m*t,k=1/((F-b)*(F-b)+(v-w)*(v-w))-.25;k<0&&(k=0);let C=Math.sqrt(k);o===r&&(C=-C);let D=.5*(b+F)-C*(v-w),T=.5*(w+v)+C*(F-b),O=Math.atan2(w-T,b-D),V=Math.atan2(v-T,F-D)-O;V<0&&o===1?V+=2*Math.PI:V>0&&o===0&&(V-=2*Math.PI);let W=Math.ceil(Math.abs(V/(Math.PI*.5+.001))),B=[];for(let U=0;U{let c=a*r,l=-s*o,d=s*r,h=a*o,u=.5*(i-e),f=8/3*Math.sin(u*.5)*Math.sin(u*.5)/Math.sin(u),p=n+Math.cos(e)-f*Math.sin(e),g=t+Math.sin(e)+f*Math.cos(e),m=n+Math.cos(i),b=t+Math.sin(i),w=m+f*Math.sin(i),F=b-f*Math.cos(i);return[c*p+l*g,d*p+h*g,c*w+l*F,d*w+h*F,c*m+l*b,d*m+h*b]},Vb=n=>PF(FF(n));var SF=({topLeft:n,topRight:t,bottomRight:e,bottomLeft:i})=>[At(n.x,n.y),Ve(t.x,t.y),Ve(e.x,e.y),Ve(i.x,i.y),ei(),Kl(),Zl()],Us=n=>n.flatMap(SF),CF=(n,t)=>[Ne(),t.graphicsState&&ji(t.graphicsState),Jl(),ti(t.color),Fo(t.font,t.size),t.strokeWidth&&kn(t.strokeWidth),t.strokeColor&&Dn(t.strokeColor),t.renderMode&&Td(t.renderMode),Rs(qe(t.rotate),qe(t.xSkew),qe(t.ySkew),t.x,t.y),Yl(n),Ql(),Re()].filter(Boolean),Uf=(n,t)=>{let e=[Ne(),t.graphicsState&&ji(t.graphicsState),...t.clipSpaces?Us(t.clipSpaces):[],t.matrix&&$t(...t.matrix),Jl(),ti(t.color),Fo(t.font,t.size),kf(t.lineHeight),t.strokeWidth&&kn(t.strokeWidth),t.strokeColor&&Dn(t.strokeColor),t.renderMode&&Td(t.renderMode),Rs(qe(t.rotate),qe(t.xSkew),qe(t.ySkew),t.x,t.y)].filter(Boolean);for(let i=0,r=n.length;i[Ne(),t.graphicsState&&ji(t.graphicsState),...t.clipSpaces?Us(t.clipSpaces):[],t.matrix&&$t(...t.matrix),mt(t.x,t.y),lr(qe(t.rotate)),ar(t.width,t.height),Os(qe(t.xSkew),qe(t.ySkew)),Vs(n),Re()].filter(Boolean),zf=(n,t)=>[Ne(),t.graphicsState&&ji(t.graphicsState),mt(t.x,t.y),lr(qe(t.rotate)),ar(t.xScale,t.yScale),Os(qe(t.xSkew),qe(t.ySkew)),Vs(n),Re()].filter(Boolean),qf=n=>{var t,e;return[Ne(),n.graphicsState&&ji(n.graphicsState),...n.clipSpaces?Us(n.clipSpaces):[],n.matrix&&$t(...n.matrix),n.color&&Dn(n.color),kn(n.thickness),wo((t=n.dashArray)!==null&&t!==void 0?t:[],(e=n.dashPhase)!==null&&e!==void 0?e:0),At(n.start.x,n.start.y),n.lineCap&&Ms(n.lineCap),At(n.start.x,n.start.y),Ve(n.end.x,n.end.y),vo(),Re()].filter(Boolean)},dr=n=>{var t,e;return[Ne(),n.graphicsState&&ji(n.graphicsState),n.color&&ti(n.color),n.borderColor&&Dn(n.borderColor),kn(n.borderWidth),n.borderLineCap&&Ms(n.borderLineCap),wo((t=n.borderDashArray)!==null&&t!==void 0?t:[],(e=n.borderDashPhase)!==null&&e!==void 0?e:0),...n.clipSpaces?Us(n.clipSpaces):[],n.matrix&&$t(...n.matrix),mt(n.x,n.y),lr(qe(n.rotate)),Os(qe(n.xSkew),qe(n.ySkew)),At(0,0),Ve(0,n.height),Ve(n.width,n.height),Ve(n.width,0),ei(),n.color&&n.borderWidth?Xl():n.color?Gl():n.borderColor?vo():ei(),Re()].filter(Boolean)},Bd=4*((Math.sqrt(2)-1)/3),Bb=n=>{let t=$(n.x),e=$(n.y),i=$(n.xScale),r=$(n.yScale);t-=i,e-=r;let o=i*Bd,s=r*Bd,a=t+i*2,c=e+r*2,l=t+i,d=e+r;return[Ne(),At(t,d),bt(t,d-s,l-o,e,l,e),bt(l+o,e,a,d-s,a,d),bt(a,d+s,l+o,c,l,c),bt(l-o,c,t,d+s,t,d),Re()]},TF=n=>{let t=$(n.x),e=$(n.y),i=$(n.xScale),r=$(n.yScale),o=-i,s=-r,a=i*Bd,c=r*Bd,l=o+i*2,d=s+r*2,h=o+i,u=s+r;return[mt(t,e),lr(qe(n.rotate)),At(o,u),bt(o,u-c,h-a,s,h,s),bt(h+a,s,l,u-c,l,u),bt(l,u+c,h+a,d,h,d),bt(h-a,d,o,u+c,o,u)]},nc=n=>{var t,e,i;return[Ne(),n.graphicsState&&ji(n.graphicsState),n.color&&ti(n.color),n.borderColor&&Dn(n.borderColor),...n.clipSpaces?Us(n.clipSpaces):[],n.matrix&&$t(...n.matrix),kn(n.borderWidth),n.borderLineCap&&Ms(n.borderLineCap),wo((t=n.borderDashArray)!==null&&t!==void 0?t:[],(e=n.borderDashPhase)!==null&&e!==void 0?e:0),...n.rotate===void 0?Bb({x:n.x,y:n.y,xScale:n.xScale,yScale:n.yScale}):TF({x:n.x,y:n.y,xScale:n.xScale,yScale:n.yScale,rotate:(i=n.rotate)!==null&&i!==void 0?i:X(0)}),n.color&&n.borderWidth?Xl():n.color?Gl():n.borderColor?vo():ei(),Re()].filter(Boolean)},Wf=(n,t)=>{var e,i,r;return[Ne(),t.graphicsState&&ji(t.graphicsState),...t.clipSpaces?Us(t.clipSpaces):[],t.matrix&&$t(...t.matrix),mt(t.x,t.y),lr(qe((e=t.rotate)!==null&&e!==void 0?e:X(0))),t.scale?ar(t.scale,-t.scale):ar(1,-1),t.color&&ti(t.color),t.borderColor&&Dn(t.borderColor),t.borderWidth&&kn(t.borderWidth),t.borderLineCap&&Ms(t.borderLineCap),wo((i=t.borderDashArray)!==null&&i!==void 0?i:[],(r=t.borderDashPhase)!==null&&r!==void 0?r:0),...Vb(n),t.color&&t.borderWidth?Xl():t.color?t.fillRule===Wi.EvenOdd?Ff():Gl():t.borderColor?vo():ei(),Re()].filter(Boolean)},Hb=n=>{let t=$(n.size),e=-1+.75,i=-1+.51,r=1-.525,o=1-.31,s=-1+.325,a=-((s-e)*(o-e))/(r-i)+i;return[Ne(),n.color&&Dn(n.color),kn(n.thickness),mt(n.x,n.y),At(s*t,a*t),Ve(e*t,i*t),Ve(o*t,r*t),vo(),Re()].filter(Boolean)},ii=n=>n.rotation===0?[mt(0,0),Ls(0)]:n.rotation===90?[mt(n.width,0),Ls(90)]:n.rotation===180?[mt(n.width,n.height),Ls(180)]:n.rotation===270?[mt(0,n.height),Ls(270)]:[],zs=n=>{let t=dr({x:n.x,y:n.y,width:n.width,height:n.height,borderWidth:n.borderWidth,color:n.color,borderColor:n.borderColor,rotate:X(0),xSkew:X(0),ySkew:X(0)});if(!n.filled)return t;let e=$(n.width),i=$(n.height),r=Math.min(e,i)/2,o=Hb({x:e/2,y:i/2,size:r,thickness:n.thickness,color:n.markColor});return[Ne(),...t,...o,Re()]},qs=n=>{let t=$(n.width),e=$(n.height),i=Math.min(t,e)/2,r=nc({x:n.x,y:n.y,xScale:i,yScale:i,color:n.color,borderColor:n.borderColor,borderWidth:n.borderWidth});if(!n.filled)return r;let o=nc({x:n.x,y:n.y,xScale:i*.45,yScale:i*.45,color:n.dotColor,borderColor:void 0,borderWidth:0});return[Ne(),...r,...o,Re()]},Hd=n=>{let t=$(n.x),e=$(n.y),i=$(n.width),r=$(n.height),o=dr({x:t,y:e,width:i,height:r,borderWidth:n.borderWidth,color:n.color,borderColor:n.borderColor,rotate:X(0),xSkew:X(0),ySkew:X(0)}),s=Ud(n.textLines,{color:n.textColor,font:n.font,size:n.fontSize,rotate:X(0),xSkew:X(0),ySkew:X(0)});return[Ne(),...o,...s,Re()]},Ud=(n,t)=>{let e=[Jl(),ti(t.color),Fo(t.font,t.size)];for(let i=0,r=n.length;i{let t=$(n.x),e=$(n.y),i=$(n.width),r=$(n.height),o=$(n.borderWidth),s=$(n.padding),a=t+o/2+s,c=e+o/2+s,l=i-(o/2+s)*2,d=r-(o/2+s)*2,h=[At(a,c),Ve(a,c+d),Ve(a+l,c+d),Ve(a+l,c),ei(),Kl(),Zl()],u=dr({x:t,y:e,width:i,height:r,borderWidth:n.borderWidth,color:n.color,borderColor:n.borderColor,rotate:X(0),xSkew:X(0),ySkew:X(0)}),f=Ud(n.textLines,{color:n.textColor,font:n.font,size:n.fontSize,rotate:X(0),xSkew:X(0),ySkew:X(0)}),p=[Ed("Tx"),Ne(),...f,Re(),Ad()];return[Ne(),...u,...h,...p,Re()]},jf=n=>{let t=$(n.x),e=$(n.y),i=$(n.width),r=$(n.height),o=$(n.lineHeight),s=$(n.borderWidth),a=$(n.padding),c=t+s/2+a,l=e+s/2+a,d=i-(s/2+a)*2,h=r-(s/2+a)*2,u=[At(c,l),Ve(c,l+h),Ve(c+d,l+h),Ve(c+d,l),ei(),Kl(),Zl()],f=dr({x:t,y:e,width:i,height:r,borderWidth:n.borderWidth,color:n.color,borderColor:n.borderColor,rotate:X(0),xSkew:X(0),ySkew:X(0)}),p=[];for(let b=0,w=n.selectedLines.length;b{let r=Ub;for(;rn.length)return r-1;let s=t.heightAtSize(r);if((s+s*.2)*o>Math.abs(e.height))return r-1;r+=1}return r},EF=(n,t,e,i)=>{let r=e.width/i,o=e.height,s=Ub,a=tu(n);for(;sr*.75)return s-1}if(t.heightAtSize(s,{descender:!1})>o)return s-1;s+=1}return s},AF=n=>{for(let t=n.length;t>0;t--)if(/\s/.test(n[t]))return t},IF=(n,t,e,i)=>{var r;let o=n.length;for(;o>0;){let s=n.substring(0,o),a=e.encodeText(s),c=e.widthOfTextAtSize(s,i);if(c{let o=wa(zn(n));(e===void 0||e===0)&&(e=qb(o,i,r,!0));let s=i.heightAtSize(e),a=s+s*.2,c=[],l=r.x,d=r.y,h=r.x+r.width,u=r.y+r.height,f=r.y+r.height;for(let p=0,g=o.length;ph&&(h=P+F),f+s>u&&(u=f+s),c.push({text:b,encoded:w,width:F,height:s,x:P,y:f}),m=v==null?void 0:v.trim()}}return{fontSize:e,lineHeight:a,lines:c,bounds:{x:l,y:d,width:h-l,height:u-d}}},Xf=(n,{fontSize:t,font:e,bounds:i,cellCount:r})=>{let o=zc(zn(n));if(o.length>r)throw new hc(o.length,r);(t===void 0||t===0)&&(t=EF(o,e,i,r));let s=i.width/r,a=e.heightAtSize(t,{descender:!1}),c=i.y+(i.height/2-a/2),l=[],d=i.x,h=i.y,u=i.x+i.width,f=i.y+i.height,p=0,g=0;for(;pu&&(u=P+F),c+a>f&&(f=c+a),l.push({text:o,encoded:w,width:F,height:a,x:P,y:c}),p+=1,g+=b}return{fontSize:t,cells:l,bounds:{x:d,y:h,width:u-d,height:f-h}}},js=(n,{alignment:t,fontSize:e,font:i,bounds:r})=>{let o=zc(zn(n));(e===void 0||e===0)&&(e=qb([o],i,r));let s=i.encodeText(o),a=i.widthOfTextAtSize(o,e),c=i.heightAtSize(e,{descender:!1}),l=t===He.Left?r.x:t===He.Center?r.x+r.width/2-a/2:t===He.Right?r.x+r.width-a:r.x,d=r.y+(r.height/2-c/2);return{fontSize:e,line:{text:o,encoded:s,width:a,height:c,x:l,y:d},bounds:{x:l,y:d,width:a,height:c}}};var Rt=n=>"normal"in n?n:{normal:n},LF=/\/([^\0\t\n\f\r\ ]+)[\0\t\n\f\r\ ]+(\d*\.\d+|\d+)[\0\t\n\f\r\ ]+Tf/,hr=n=>{var t,e;let i=(t=n.getDefaultAppearance())!==null&&t!==void 0?t:"",r=(e=Go(i,LF).match)!==null&&e!==void 0?e:[],o=Number(r[2]);return isFinite(o)?o:void 0},OF=/(\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)/,ni=n=>{var t;let e=(t=n.getDefaultAppearance())!==null&&t!==void 0?t:"",i=Go(e,OF).match,[,r,o,s,a,c]=i!=null?i:[];if(c==="g"&&r)return Nd(Number(r));if(c==="rg"&&r&&o&&s)return ne(Number(r),Number(o),Number(s));if(c==="k"&&r&&o&&s&&a)return Rd(Number(r),Number(o),Number(s),Number(a))},ri=(n,t,e,i=0)=>{var r;let o=[ti(t).toString(),Fo((r=e==null?void 0:e.name)!==null&&r!==void 0?r:"dummy__noop",i).toString()].join(` `);n.setDefaultAppearance(o)},Zf=(n,t)=>{var e,i,r;let o=ni(t),s=ni(n.acroField),a=t.getRectangle(),c=t.getAppearanceCharacteristics(),l=t.getBorderStyle(),d=(e=l==null?void 0:l.getWidth())!==null&&e!==void 0?e:0,h=Qt(c==null?void 0:c.getRotation()),{width:u,height:f}=qi(a,h),p=ii({...a,rotation:h}),g=ne(0,0,0),m=(i=ht(c==null?void 0:c.getBorderColor()))!==null&&i!==void 0?i:g,b=ht(c==null?void 0:c.getBackgroundColor()),w=ht(c==null?void 0:c.getBackgroundColor(),.8),F=(r=o!=null?o:s)!==null&&r!==void 0?r:g;ri(o?t:n.acroField,F);let v={x:0+d/2,y:0+d/2,width:u-d,height:f-d,thickness:1.5,borderWidth:d,borderColor:m,markColor:F};return{normal:{on:[...p,...zs({...v,color:b,filled:!0})],off:[...p,...zs({...v,color:b,filled:!1})]},down:{on:[...p,...zs({...v,color:w,filled:!0})],off:[...p,...zs({...v,color:w,filled:!1})]}}},Yf=(n,t)=>{var e,i,r;let o=ni(t),s=ni(n.acroField),a=t.getRectangle(),c=t.getAppearanceCharacteristics(),l=t.getBorderStyle(),d=(e=l==null?void 0:l.getWidth())!==null&&e!==void 0?e:0,h=Qt(c==null?void 0:c.getRotation()),{width:u,height:f}=qi(a,h),p=ii({...a,rotation:h}),g=ne(0,0,0),m=(i=ht(c==null?void 0:c.getBorderColor()))!==null&&i!==void 0?i:g,b=ht(c==null?void 0:c.getBackgroundColor()),w=ht(c==null?void 0:c.getBackgroundColor(),.8),F=(r=o!=null?o:s)!==null&&r!==void 0?r:g;ri(o?t:n.acroField,F);let v={x:u/2,y:f/2,width:u-d,height:f-d,borderWidth:d,borderColor:m,dotColor:F};return{normal:{on:[...p,...qs({...v,color:b,filled:!0})],off:[...p,...qs({...v,color:b,filled:!1})]},down:{on:[...p,...qs({...v,color:w,filled:!0})],off:[...p,...qs({...v,color:w,filled:!1})]}}},Jf=(n,t,e)=>{var i,r,o,s,a;let c=ni(t),l=ni(n.acroField),d=hr(t),h=hr(n.acroField),u=t.getRectangle(),f=t.getAppearanceCharacteristics(),p=t.getBorderStyle(),g=f==null?void 0:f.getCaptions(),m=(i=g==null?void 0:g.normal)!==null&&i!==void 0?i:"",b=(o=(r=g==null?void 0:g.down)!==null&&r!==void 0?r:m)!==null&&o!==void 0?o:"",w=(s=p==null?void 0:p.getWidth())!==null&&s!==void 0?s:0,F=Qt(f==null?void 0:f.getRotation()),{width:v,height:P}=qi(u,F),k=ii({...u,rotation:F}),C=ne(0,0,0),D=ht(f==null?void 0:f.getBorderColor()),T=ht(f==null?void 0:f.getBackgroundColor()),O=ht(f==null?void 0:f.getBackgroundColor(),.8),E={x:w,y:w,width:v-w*2,height:P-w*2},V=js(m,{alignment:He.Center,fontSize:d!=null?d:h,font:e,bounds:E}),W=js(b,{alignment:He.Center,fontSize:d!=null?d:h,font:e,bounds:E}),B=Math.min(V.fontSize,W.fontSize),U=(a=c!=null?c:l)!==null&&a!==void 0?a:C;ri(c||d!==void 0?t:n.acroField,U,e,B);let te={x:0+w/2,y:0+w/2,width:v-w,height:P-w,borderWidth:w,borderColor:D,textColor:U,font:e.name,fontSize:B};return{normal:[...k,...Hd({...te,color:T,textLines:[V.line]})],down:[...k,...Hd({...te,color:O,textLines:[W.line]})]}},Qf=(n,t,e)=>{var i,r,o,s;let a=ni(t),c=ni(n.acroField),l=hr(t),d=hr(n.acroField),h=t.getRectangle(),u=t.getAppearanceCharacteristics(),f=t.getBorderStyle(),p=(i=n.getText())!==null&&i!==void 0?i:"",g=(r=f==null?void 0:f.getWidth())!==null&&r!==void 0?r:0,m=Qt(u==null?void 0:u.getRotation()),{width:b,height:w}=qi(h,m),F=ii({...h,rotation:m}),v=ne(0,0,0),P=ht(u==null?void 0:u.getBorderColor()),k=ht(u==null?void 0:u.getBackgroundColor()),C,D,T=n.isCombed()?0:1,O={x:g+T,y:g+T,width:b-(g+T)*2,height:w-(g+T)*2};if(n.isMultiline()){let W=qd(p,{alignment:n.getAlignment(),fontSize:l!=null?l:d,font:e,bounds:O});C=W.lines,D=W.fontSize}else if(n.isCombed()){let W=Xf(p,{fontSize:l!=null?l:d,font:e,bounds:O,cellCount:(o=n.getMaxLength())!==null&&o!==void 0?o:0});C=W.cells,D=W.fontSize}else{let W=js(p,{alignment:n.getAlignment(),fontSize:l!=null?l:d,font:e,bounds:O});C=[W.line],D=W.fontSize}let E=(s=a!=null?a:c)!==null&&s!==void 0?s:v;ri(a||l!==void 0?t:n.acroField,E,e,D);let V={x:0+g/2,y:0+g/2,width:b-g,height:w-g,borderWidth:g!=null?g:0,borderColor:P,textColor:E,font:e.name,fontSize:D,color:k,textLines:C,padding:T};return[...F,...zd(V)]},_f=(n,t,e)=>{var i,r,o;let s=ni(t),a=ni(n.acroField),c=hr(t),l=hr(n.acroField),d=t.getRectangle(),h=t.getAppearanceCharacteristics(),u=t.getBorderStyle(),f=(i=n.getSelected()[0])!==null&&i!==void 0?i:"",p=(r=u==null?void 0:u.getWidth())!==null&&r!==void 0?r:0,g=Qt(h==null?void 0:h.getRotation()),{width:m,height:b}=qi(d,g),w=ii({...d,rotation:g}),F=ne(0,0,0),v=ht(h==null?void 0:h.getBorderColor()),P=ht(h==null?void 0:h.getBackgroundColor()),k=1,C={x:p+k,y:p+k,width:m-(p+k)*2,height:b-(p+k)*2},{line:D,fontSize:T}=js(f,{alignment:He.Left,fontSize:c!=null?c:l,font:e,bounds:C}),O=(o=s!=null?s:a)!==null&&o!==void 0?o:F;ri(s||c!==void 0?t:n.acroField,O,e,T);let E={x:0+p/2,y:0+p/2,width:m-p,height:b-p,borderWidth:p!=null?p:0,borderColor:v,textColor:O,font:e.name,fontSize:T,color:P,textLines:[D],padding:k};return[...w,...zd(E)]},$f=(n,t,e)=>{var i,r;let o=ni(t),s=ni(n.acroField),a=hr(t),c=hr(n.acroField),l=t.getRectangle(),d=t.getAppearanceCharacteristics(),h=t.getBorderStyle(),u=(i=h==null?void 0:h.getWidth())!==null&&i!==void 0?i:0,f=Qt(d==null?void 0:d.getRotation()),{width:p,height:g}=qi(l,f),m=ii({...l,rotation:f}),b=ne(0,0,0),w=ht(d==null?void 0:d.getBorderColor()),F=ht(d==null?void 0:d.getBackgroundColor()),v=n.getOptions(),P=n.getSelected();n.isSorted()&&v.sort();let k="";for(let U=0,te=v.length;Unew Pi(n,t,e);var Se=class{constructor(t,e,i){this.modified=!0,S(t,"ref",[[q,"PDFRef"]]),S(e,"doc",[[pe,"PDFDocument"]]),S(i,"embedder",[[ir,"CustomFontEmbedder"],[tr,"StandardFontEmbedder"]]),this.ref=t,this.doc=e,this.name=i.fontName,this.embedder=i}encodeText(t){return S(t,"text",["string"]),this.modified=!0,this.embedder.encodeText(t)}widthOfTextAtSize(t,e){return S(t,"text",["string"]),S(e,"size",["number"]),this.embedder.widthOfTextAtSize(t,e)}heightAtSize(t,e){var i;return S(t,"size",["number"]),I(e==null?void 0:e.descender,"options.descender",["boolean"]),this.embedder.heightOfFontAtSize(t,{descender:(i=e==null?void 0:e.descender)!==null&&i!==void 0?i:!0})}sizeAtHeight(t){return S(t,"height",["number"]),this.embedder.sizeOfFontAtHeight(t)}getCharacterSet(){return this.embedder instanceof tr?this.embedder.encoding.supportedCodePoints:this.embedder.font.characterSet}async embed(){this.modified&&(await this.embedder.embedIntoContext(this.doc.context,this.ref),this.modified=!1)}};Se.of=(n,t,e)=>new Se(n,t,e);var oi=class{constructor(t,e,i){S(t,"ref",[[q,"PDFRef"]]),S(e,"doc",[[pe,"PDFDocument"]]),S(i,"embedder",[[bs,"JpegEmbedder"],[ys,"PngEmbedder"]]),this.ref=t,this.doc=e,this.width=i.width,this.height=i.height,this.embedder=i}scale(t){return S(t,"factor",["number"]),{width:this.width*t,height:this.height*t}}scaleToFit(t,e){S(t,"width",["number"]),S(e,"height",["number"]);let i=t/this.width,r=e/this.height,o=Math.min(i,r);return this.scale(o)}size(){return this.scale(1)}async embed(){if(this.embedder){if(!this.embedTask){let{doc:t,ref:e}=this;this.embedTask=this.embedder.embedIntoContext(t.context,e)}await this.embedTask,this.embedder=void 0}}};oi.of=(n,t,e)=>new oi(n,t,e);var si;(function(n){n[n.Left=0]="Left",n[n.Center=1]="Center",n[n.Right=2]="Right"})(si||(si={}));var ai=n=>{I(n==null?void 0:n.x,"options.x",["number"]),I(n==null?void 0:n.y,"options.y",["number"]),I(n==null?void 0:n.width,"options.width",["number"]),I(n==null?void 0:n.height,"options.height",["number"]),I(n==null?void 0:n.textColor,"options.textColor",[[Object,"Color"]]),I(n==null?void 0:n.backgroundColor,"options.backgroundColor",[[Object,"Color"]]),I(n==null?void 0:n.borderColor,"options.borderColor",[[Object,"Color"]]),I(n==null?void 0:n.borderWidth,"options.borderWidth",["number"]),I(n==null?void 0:n.rotate,"options.rotate",[[Object,"Rotation"]])},$e=class{constructor(t,e,i){S(t,"acroField",[[Et,"PDFAcroTerminal"]]),S(e,"ref",[[q,"PDFRef"]]),S(i,"doc",[[pe,"PDFDocument"]]),this.acroField=t,this.ref=e,this.doc=i}getName(){var t;return(t=this.acroField.getFullyQualifiedName())!==null&&t!==void 0?t:""}isReadOnly(){return this.acroField.hasFlag(Ot.ReadOnly)}enableReadOnly(){this.acroField.setFlagTo(Ot.ReadOnly,!0)}disableReadOnly(){this.acroField.setFlagTo(Ot.ReadOnly,!1)}isRequired(){return this.acroField.hasFlag(Ot.Required)}enableRequired(){this.acroField.setFlagTo(Ot.Required,!0)}disableRequired(){this.acroField.setFlagTo(Ot.Required,!1)}isExported(){return!this.acroField.hasFlag(Ot.NoExport)}enableExporting(){this.acroField.setFlagTo(Ot.NoExport,!1)}disableExporting(){this.acroField.setFlagTo(Ot.NoExport,!0)}needsAppearancesUpdate(){throw new Ge(this.constructor.name,"needsAppearancesUpdate")}defaultUpdateAppearances(t){throw new Ge(this.constructor.name,"defaultUpdateAppearances")}markAsDirty(){this.doc.getForm().markFieldAsDirty(this.ref)}markAsClean(){this.doc.getForm().markFieldAsClean(this.ref)}isDirty(){return this.doc.getForm().fieldIsDirty(this.ref)}createWidget(t){var e;let i=t.textColor,r=t.backgroundColor,o=t.borderColor,s=t.borderWidth,a=jl(t.rotate),c=t.caption,l=t.x,d=t.y,h=t.width+s,u=t.height+s,f=Boolean(t.hidden),p=t.page;Xa(a,"degreesAngle",90);let g=oo.create(this.doc.context,this.ref),m=wf({x:l,y:d,width:h,height:u},s,a);g.setRectangle(m),p&&g.setP(p);let b=g.getOrCreateAppearanceCharacteristics();r&&b.setBackgroundColor(Vd(r)),b.setRotation(a),c&&b.setCaptions({normal:c}),o&&b.setBorderColor(Vd(o));let w=g.getOrCreateBorderStyle();if(s!==void 0&&w.setWidth(s),g.setFlagTo(xo.Print,!0),g.setFlagTo(xo.Hidden,f),g.setFlagTo(xo.Invisible,!1),i){let v=((e=this.acroField.getDefaultAppearance())!==null&&e!==void 0?e:"")+` `+ti(i).toString();this.acroField.setDefaultAppearance(v)}return g}updateWidgetAppearanceWithFont(t,e,{normal:i,rollover:r,down:o}){this.updateWidgetAppearances(t,{normal:this.createAppearanceStream(t,i,e),rollover:r&&this.createAppearanceStream(t,r,e),down:o&&this.createAppearanceStream(t,o,e)})}updateOnOffWidgetAppearance(t,e,{normal:i,rollover:r,down:o}){this.updateWidgetAppearances(t,{normal:this.createAppearanceDict(t,i,e),rollover:r&&this.createAppearanceDict(t,r,e),down:o&&this.createAppearanceDict(t,o,e)})}updateWidgetAppearances(t,{normal:e,rollover:i,down:r}){t.setNormalAppearance(e),i?t.setRolloverAppearance(i):t.removeRolloverAppearance(),r?t.setDownAppearance(r):t.removeDownAppearance()}createAppearanceStream(t,e,i){let{context:r}=this.acroField.dict,{width:o,height:s}=t.getRectangle(),a=i&&{Font:{[i.name]:i.ref}},c=r.formXObject(e,{Resources:a,BBox:r.obj([0,0,o,s]),Matrix:r.obj([1,0,0,1,0,0])});return r.register(c)}createImageAppearanceStream(t,e,i){var r;let{context:o}=this.acroField.dict,s=t.getRectangle(),a=t.getAppearanceCharacteristics(),c=t.getBorderStyle(),l=(r=c==null?void 0:c.getWidth())!==null&&r!==void 0?r:0,d=Qt(a==null?void 0:a.getRotation()),h=ii({...s,rotation:d}),u=qi(s,d),f=e.scaleToFit(u.width-l*2,u.height-l*2),p={x:l,y:l,width:f.width,height:f.height,rotate:X(0),xSkew:X(0),ySkew:X(0)};i===si.Center?(p.x+=(u.width-l*2)/2-f.width/2,p.y+=(u.height-l*2)/2-f.height/2):i===si.Right&&(p.x=u.width-l-f.width,p.y=u.height-l-f.height);let g=this.doc.context.addRandomSuffix("Image",10),m=[...h,...rc(g,p)],b={XObject:{[g]:e.ref}},w=o.formXObject(m,{Resources:b,BBox:o.obj([0,0,s.width,s.height]),Matrix:o.obj([1,0,0,1,0,0])});return o.register(w)}createAppearanceDict(t,e,i){let{context:r}=this.acroField.dict,o=this.createAppearanceStream(t,e.on),s=this.createAppearanceStream(t,e.off),a=r.obj({});return a.set(i,o),a.set(x.of("Off"),s),a}};var Vt=class extends $e{constructor(t,e,i){super(t,e,i),S(t,"acroCheckBox",[[bn,"PDFAcroCheckBox"]]),this.acroField=t}check(){var t;let e=(t=this.acroField.getOnValue())!==null&&t!==void 0?t:x.of("Yes");this.markAsDirty(),this.acroField.setValue(e)}uncheck(){this.markAsDirty(),this.acroField.setValue(x.of("Off"))}isChecked(){let t=this.acroField.getOnValue();return!!t&&t===this.acroField.getValue()}addToPage(t,e){var i,r,o,s,a,c;S(t,"page",[[Pe,"PDFPage"]]),ai(e),e||(e={}),"textColor"in e||(e.textColor=ne(0,0,0)),"backgroundColor"in e||(e.backgroundColor=ne(1,1,1)),"borderColor"in e||(e.borderColor=ne(0,0,0)),"borderWidth"in e||(e.borderWidth=1);let l=this.createWidget({x:(i=e.x)!==null&&i!==void 0?i:0,y:(r=e.y)!==null&&r!==void 0?r:0,width:(o=e.width)!==null&&o!==void 0?o:50,height:(s=e.height)!==null&&s!==void 0?s:50,textColor:e.textColor,backgroundColor:e.backgroundColor,borderColor:e.borderColor,borderWidth:(a=e.borderWidth)!==null&&a!==void 0?a:0,rotate:(c=e.rotate)!==null&&c!==void 0?c:X(0),hidden:e.hidden,page:t.ref}),d=this.doc.context.register(l.dict);this.acroField.addWidget(d),l.setAppearanceState(x.of("Off")),this.updateWidgetAppearance(l,x.of("Yes")),t.node.addAnnot(d)}needsAppearancesUpdate(){var t;let e=this.acroField.getWidgets();for(let i=0,r=e.length;inew Vt(n,t,e);var li=class extends $e{constructor(t,e,i){super(t,e,i),S(t,"acroComboBox",[[xn,"PDFAcroComboBox"]]),this.acroField=t}getOptions(){let t=this.acroField.getOptions(),e=new Array(t.length);for(let i=0,r=e.length;i!r.includes(a))&&this.enableEditing(),this.markAsDirty(),(i.length>1||i.length===1&&e)&&this.enableMultiselect();let s=new Array(i.length);for(let a=0,c=i.length;anew li(n,t,e);var ci=class extends $e{constructor(t,e,i){super(t,e,i),S(t,"acroListBox",[[Pn,"PDFAcroListBox"]]),this.acroField=t}getOptions(){let t=this.acroField.getOptions(),e=new Array(t.length);for(let i=0,r=e.length;i1||i.length===1&&e)&&this.enableMultiselect();let o=new Array(i.length);for(let s=0,a=i.length;snew ci(n,t,e);var Bt=class extends $e{constructor(t,e,i){super(t,e,i),S(t,"acroRadioButton",[[Fn,"PDFAcroRadioButton"]]),this.acroField=t}getOptions(){let t=this.acroField.getExportValues();if(t){let r=new Array(t.length);for(let o=0,s=t.length;onew Bt(n,t,e);var ki=class extends $e{constructor(t,e,i){super(t,e,i),S(t,"acroSignature",[[rr,"PDFAcroSignature"]]),this.acroField=t}needsAppearancesUpdate(){return!1}};ki.of=(n,t,e)=>new ki(n,t,e);var di=class extends $e{constructor(t,e,i){super(t,e,i),S(t,"acroText",[[wn,"PDFAcroText"]]),this.acroField=t}getText(){let t=this.acroField.getValue();if(!t&&this.isRichFormatted())throw new dc(this.getName());return t==null?void 0:t.decodeText()}setText(t){I(t,"text",["string"]);let e=this.getMaxLength();if(e!==void 0&&t&&t.length>e)throw new uc(t.length,e,this.getName());this.markAsDirty(),this.disableRichFormatting(),t?this.acroField.setValue(M.fromText(t)):this.acroField.removeValue()}getAlignment(){let t=this.acroField.getQuadding();return t===0?He.Left:t===1?He.Center:t===2?He.Right:He.Left}setAlignment(t){Xt(t,"alignment",He),this.markAsDirty(),this.acroField.setQuadding(t)}getMaxLength(){return this.acroField.getMaxLength()}setMaxLength(t){if(Ct(t,"maxLength",0,Number.MAX_SAFE_INTEGER),this.markAsDirty(),t===void 0)this.acroField.removeMaxLength();else{let e=this.getText();if(e&&e.length>t)throw new fc(e.length,t,this.getName());this.acroField.setMaxLength(t)}}removeMaxLength(){this.markAsDirty(),this.acroField.removeMaxLength()}setImage(t){let e=this.getAlignment(),i=e===He.Center?si.Center:e===He.Right?si.Right:si.Left,r=this.acroField.getWidgets();for(let o=0,s=r.length;onew di(n,t,e);var Do;(function(n){n.Courier="Courier",n.CourierBold="Courier-Bold",n.CourierOblique="Courier-Oblique",n.CourierBoldOblique="Courier-BoldOblique",n.Helvetica="Helvetica",n.HelveticaBold="Helvetica-Bold",n.HelveticaOblique="Helvetica-Oblique",n.HelveticaBoldOblique="Helvetica-BoldOblique",n.TimesRoman="Times-Roman",n.TimesRomanBold="Times-Bold",n.TimesRomanItalic="Times-Italic",n.TimesRomanBoldItalic="Times-BoldItalic",n.Symbol="Symbol",n.ZapfDingbats="ZapfDingbats"})(Do||(Do={}));var Sn=class{constructor(t,e){this.embedDefaultFont=()=>this.doc.embedStandardFont(Do.Helvetica),S(t,"acroForm",[[or,"PDFAcroForm"]]),S(e,"doc",[[pe,"PDFDocument"]]),this.acroForm=t,this.doc=e,this.dirtyFields=new Set,this.defaultFontCache=ct.populatedBy(this.embedDefaultFont)}hasXFA(){return this.acroForm.dict.has(x.of("XFA"))}deleteXFA(){this.acroForm.dict.delete(x.of("XFA"))}getFields(){let t=this.acroForm.getAllFields(),e=[];for(let i=0,r=t.length;is.node.removeAnnot(t.ref)),this.acroForm.removeField(t.acroField);let r=t.acroField.normalizedEntries().Kids,o=r.size();for(let s=0;sr.ref===e);if(i===void 0){let r=this.doc.context.getObjectRef(t.dict);if(r===void 0)throw new Error("Could not find PDFRef for PDFObject");if(i=this.doc.findPageForAnnotationRef(r),i===void 0)throw new Error(`Could not find page for PDFRef ${r}`)}return i}findWidgetAppearanceRef(t,e){var i;let r=e.getNormalAppearance();if(r instanceof R&&(t instanceof Vt||t instanceof Bt)){let o=t.acroField.getValue(),s=(i=r.get(o))!==null&&i!==void 0?i:r.get(x.of("Off"));s instanceof q&&(r=s)}if(!(r instanceof q)){let o=t.getName();throw new Error(`Failed to extract appearance ref for: ${o}`)}return r}findOrCreateNonTerminals(t){let e=[this.acroForm];for(let i=0,r=t.length;inew Sn(n,t);var MF=(n,t,e)=>{if(n instanceof vn)return hi.of(n,t,e);if(n instanceof bn)return Vt.of(n,t,e);if(n instanceof xn)return li.of(n,t,e);if(n instanceof Pn)return ci.of(n,t,e);if(n instanceof wn)return di.of(n,t,e);if(n instanceof Fn)return Bt.of(n,t,e);if(n instanceof rr)return ki.of(n,t,e)},Ks=n=>{if(n.length===0)throw new Error("PDF field names must not be empty strings");let t=n.split(".");for(let e=0,i=t.length;e{let o=n.normalizedEntries(),s=Ss("Kids"in o?o.Kids:o.Fields);for(let a=0,c=s.length;anew Co(n,t,e);var Cn=class{constructor(t,e,i){this.alreadyEmbedded=!1,this.ref=t,this.doc=e,this.embedder=i}async embed(){if(!this.alreadyEmbedded){let{catalog:t,context:e}=this.doc,i=await this.embedder.embedIntoContext(this.doc.context,this.ref);t.has(x.of("Names"))||t.set(x.of("Names"),e.obj({}));let r=t.lookup(x.of("Names"),R);r.has(x.of("JavaScript"))||r.set(x.of("JavaScript"),e.obj({}));let o=r.lookup(x.of("JavaScript"),R);o.has(x.of("Names"))||o.set(x.of("Names"),e.obj([]));let s=o.lookup(x.of("Names"),H);s.push(M.fromText(this.embedder.scriptName)),s.push(i),this.alreadyEmbedded=!0}}};Cn.of=(n,t,e)=>new Cn(n,t,e);var gc=class{static for(t,e){return new gc(t,e)}constructor(t,e){this.script=t,this.scriptName=e}async embedIntoContext(t,e){let i=t.obj({Type:"Action",S:"JavaScript",JS:M.fromText(this.script)});return e?(t.assign(e,i),e):t.register(i)}},Wb=gc;var jb=512,ep=class extends Yt{constructor(t,e,i){super(i),this.stream=t,this.decrypt=e,this.nextChunk=null,this.initialized=!1}readBlock(){let t;if(this.initialized?t=this.nextChunk:(t=this.stream.getBytes(jb),this.initialized=!0),!t||t.length===0){this.eof=!0;return}this.nextChunk=this.stream.getBytes(jb);let e=this.nextChunk&&this.nextChunk.length>0,i=this.decrypt;t=i(t,!e);let r=this.bufferLength,o=r+t.length;this.ensureBuffer(o).set(t,r),this.bufferLength=o}},Kb=ep;var Tn=class{constructor(t){this.a=0,this.b=0;let e=new Uint8Array(256),i=t.length;for(let r=0;r<256;++r)e[r]=r;for(let r=0,o=0;r<256;++r){let s=e[r];o=o+s+t[r%i]&255,e[r]=e[o],e[o]=s}this.s=e}encryptBlock(t){let e=this.a,i=this.b,r=this.s,o=t.length,s=new Uint8Array(o);for(let a=0;a>5&255,u[f++]=s>>13&255,u[f++]=s>>21&255,u[f++]=s>>>29&255,u[f++]=0,u[f++]=0,u[f++]=0;let m=new Int32Array(16);for(f=0;f>>32-T)|0,b=C}a=a+b|0,c=c+w|0,l=l+F|0,d=d+v|0}return new Uint8Array([a&255,a>>8&255,a>>16&255,a>>>24&255,c&255,c>>8&255,c>>16&255,c>>>24&255,l&255,l>>8&255,l>>16&255,l>>>24&255,d&255,d>>8&255,d>>16&255,d>>>24&255])}return i}(),A=class{constructor(t,e){this.high=t|0,this.low=e|0}and(t){this.high&=t.high,this.low&=t.low}xor(t){this.high^=t.high,this.low^=t.low}or(t){this.high|=t.high,this.low|=t.low}shiftRight(t){t>=32?(this.low=this.high>>>t-32|0,this.high=0):(this.low=this.low>>>t|this.high<<32-t,this.high=this.high>>>t|0)}shiftLeft(t){t>=32?(this.high=this.low<>>32-t,this.low<<=t)}rotateRight(t){let e,i;t&32?(i=this.low,e=this.high):(e=this.low,i=this.high),t&=31,this.low=e>>>t|i<<32-t,this.high=i>>>t|e<<32-t}not(){this.high=~this.high,this.low=~this.low}add(t){let e=(this.low>>>0)+(t.low>>>0),i=(this.high>>>0)+(t.high>>>0);e>4294967295&&(i+=1),this.low=e|0,this.high=i|0}copyTo(t,e){t[e]=this.high>>>24&255,t[e+1]=this.high>>16&255,t[e+2]=this.high>>8&255,t[e+3]=this.high&255,t[e+4]=this.low>>>24&255,t[e+5]=this.low>>16&255,t[e+6]=this.low>>8&255,t[e+7]=this.low&255}assign(t){this.high=t.high,this.low=t.low}},Zs=function(){function t(d,h){return d>>>h|d<<32-h}function e(d,h,u){return d&h^~d&u}function i(d,h,u){return d&h^d&u^h&u}function r(d){return t(d,2)^t(d,13)^t(d,22)}function o(d){return t(d,6)^t(d,11)^t(d,25)}function s(d){return t(d,7)^t(d,18)^d>>>3}function a(d){return t(d,17)^t(d,19)^d>>>10}let c=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function l(d,h,u){let f=1779033703,p=3144134277,g=1013904242,m=2773480762,b=1359893119,w=2600822924,F=528734635,v=1541459225,P=Math.ceil((u+9)/64)*64,k=new Uint8Array(P),C,D;for(C=0;C>>29&255,k[C++]=u>>21&255,k[C++]=u>>13&255,k[C++]=u>>5&255,k[C++]=u<<3&255;let O=new Uint32Array(64);for(C=0;C>24&255,f>>16&255,f>>8&255,f&255,p>>24&255,p>>16&255,p>>8&255,p&255,g>>24&255,g>>16&255,g>>8&255,g&255,m>>24&255,m>>16&255,m>>8&255,m&255,b>>24&255,b>>16&255,b>>8&255,b&255,w>>24&255,w>>16&255,w>>8&255,w&255,F>>24&255,F>>16&255,F>>8&255,F&255,v>>24&255,v>>16&255,v>>8&255,v&255])}return l}(),Gb=function(){function t(l,d,h,u,f){l.assign(d),l.and(h),f.assign(d),f.not(),f.and(u),l.xor(f)}function e(l,d,h,u,f){l.assign(d),l.and(h),f.assign(d),f.and(u),l.xor(f),f.assign(h),f.and(u),l.xor(f)}function i(l,d,h){l.assign(d),l.rotateRight(28),h.assign(d),h.rotateRight(34),l.xor(h),h.assign(d),h.rotateRight(39),l.xor(h)}function r(l,d,h){l.assign(d),l.rotateRight(14),h.assign(d),h.rotateRight(18),l.xor(h),h.assign(d),h.rotateRight(41),l.xor(h)}function o(l,d,h){l.assign(d),l.rotateRight(1),h.assign(d),h.rotateRight(8),l.xor(h),h.assign(d),h.shiftRight(7),l.xor(h)}function s(l,d,h){l.assign(d),l.rotateRight(19),h.assign(d),h.rotateRight(61),l.xor(h),h.assign(d),h.shiftRight(6),l.xor(h)}let a=[new A(1116352408,3609767458),new A(1899447441,602891725),new A(3049323471,3964484399),new A(3921009573,2173295548),new A(961987163,4081628472),new A(1508970993,3053834265),new A(2453635748,2937671579),new A(2870763221,3664609560),new A(3624381080,2734883394),new A(310598401,1164996542),new A(607225278,1323610764),new A(1426881987,3590304994),new A(1925078388,4068182383),new A(2162078206,991336113),new A(2614888103,633803317),new A(3248222580,3479774868),new A(3835390401,2666613458),new A(4022224774,944711139),new A(264347078,2341262773),new A(604807628,2007800933),new A(770255983,1495990901),new A(1249150122,1856431235),new A(1555081692,3175218132),new A(1996064986,2198950837),new A(2554220882,3999719339),new A(2821834349,766784016),new A(2952996808,2566594879),new A(3210313671,3203337956),new A(3336571891,1034457026),new A(3584528711,2466948901),new A(113926993,3758326383),new A(338241895,168717936),new A(666307205,1188179964),new A(773529912,1546045734),new A(1294757372,1522805485),new A(1396182291,2643833823),new A(1695183700,2343527390),new A(1986661051,1014477480),new A(2177026350,1206759142),new A(2456956037,344077627),new A(2730485921,1290863460),new A(2820302411,3158454273),new A(3259730800,3505952657),new A(3345764771,106217008),new A(3516065817,3606008344),new A(3600352804,1432725776),new A(4094571909,1467031594),new A(275423344,851169720),new A(430227734,3100823752),new A(506948616,1363258195),new A(659060556,3750685593),new A(883997877,3785050280),new A(958139571,3318307427),new A(1322822218,3812723403),new A(1537002063,2003034995),new A(1747873779,3602036899),new A(1955562222,1575990012),new A(2024104815,1125592928),new A(2227730452,2716904306),new A(2361852424,442776044),new A(2428436474,593698344),new A(2756734187,3733110249),new A(3204031479,2999351573),new A(3329325298,3815920427),new A(3391569614,3928383900),new A(3515267271,566280711),new A(3940187606,3454069534),new A(4118630271,4000239992),new A(116418474,1914138554),new A(174292421,2731055270),new A(289380356,3203993006),new A(460393269,320620315),new A(685471733,587496836),new A(852142971,1086792851),new A(1017036298,365543100),new A(1126000580,2618297676),new A(1288033470,3409855158),new A(1501505948,4234509866),new A(1607167915,987167468),new A(1816402316,1246189591)];function c(l,d,h,u=!1){let f,p,g,m,b,w,F,v;u?(f=new A(3418070365,3238371032),p=new A(1654270250,914150663),g=new A(2438529370,812702999),m=new A(355462360,4144912697),b=new A(1731405415,4290775857),w=new A(2394180231,1750603025),F=new A(3675008525,1694076839),v=new A(1203062813,3204075428)):(f=new A(1779033703,4089235720),p=new A(3144134277,2227873595),g=new A(1013904242,4271175723),m=new A(2773480762,1595750129),b=new A(1359893119,2917565137),w=new A(2600822924,725511199),F=new A(528734635,4215389547),v=new A(1541459225,327033209));let P=Math.ceil((h+17)/128)*128,k=new Uint8Array(P),C,D;for(C=0;C>>29&255,k[C++]=h>>21&255,k[C++]=h>>13&255,k[C++]=h>>5&255,k[C++]=h<<3&255;let O=new Array(80);for(C=0;C<80;C++)O[C]=new A(0,0);let E=new A(0,0),V=new A(0,0),W=new A(0,0),B=new A(0,0),U=new A(0,0),te=new A(0,0),z=new A(0,0),re=new A(0,0),Ee=new A(0,0),Ue=new A(0,0),me=new A(0,0),Ae=new A(0,0),we;for(C=0;C=1;--a){i=s[13],s[13]=s[9],s[9]=s[5],s[5]=s[1],s[1]=i,i=s[14],r=s[10],s[14]=s[6],s[10]=s[2],s[6]=i,s[2]=r,i=s[15],r=s[11],o=s[7],s[15]=s[3],s[11]=i,s[7]=r,s[3]=o;for(let c=0;c<16;++c)s[c]=this._inv_s[s[c]];for(let c=0,l=a*16;c<16;++c,++l)s[c]^=e[l];for(let c=0;c<16;c+=4){let l=this._mix[s[c]],d=this._mix[s[c+1]],h=this._mix[s[c+2]],u=this._mix[s[c+3]];i=l^d>>>8^d<<24^h>>>16^h<<16^u>>>24^u<<8,s[c]=i>>>24&255,s[c+1]=i>>16&255,s[c+2]=i>>8&255,s[c+3]=i&255}}i=s[13],s[13]=s[9],s[9]=s[5],s[5]=s[1],s[1]=i,i=s[14],r=s[10],s[14]=s[6],s[10]=s[2],s[6]=i,s[2]=r,i=s[15],r=s[11],o=s[7],s[15]=s[3],s[11]=i,s[7]=r,s[3]=o;for(let a=0;a<16;++a)s[a]=this._inv_s[s[a]],s[a]^=e[a];return s}_encrypt(t,e){let i=this._s,r,o,s,a=new Uint8Array(16);a.set(t);for(let c=0;c<16;++c)a[c]^=e[c];for(let c=1;c=f;--u)if(d[u]!==h){h=0;break}c-=h,s[s.length-1]=d.subarray(0,16-h)}}let l=new Uint8Array(c);for(let d=0,h=0,u=s.length;d=256&&(o=(o^27)&255));for(let u=0;u<4;++u)r[d]=s^=r[d-32],d++,r[d]=a^=r[d-32],d++,r[d]=c^=r[d-32],d++,r[d]=l^=r[d-32],d++}return r}},ip=class{checkOwnerPassword(t,e,i,r){let o=new Uint8Array(t.length+56);o.set(t,0),o.set(e,t.length),o.set(i,t.length+e.length);let s=Zs(o,0,o.length);return Xo(s,r)}checkUserPassword(t,e,i){let r=new Uint8Array(t.length+8);r.set(t,0),r.set(e,t.length);let o=Zs(r,0,r.length);return Xo(o,i)}getOwnerKey(t,e,i,r){let o=new Uint8Array(t.length+56);o.set(t,0),o.set(e,t.length),o.set(i,t.length+e.length);let s=Zs(o,0,o.length);return new Eo(s).decryptBlock(r,!1,new Uint8Array(16))}getUserKey(t,e,i){let r=new Uint8Array(t.length+8);r.set(t,0),r.set(e,t.length);let o=Zs(r,0,r.length);return new Eo(o).decryptBlock(i,!1,new Uint8Array(16))}},np=class{calculatePDF20Hash(t,e,i){let r=Zs(e,0,e.length).subarray(0,32),o=new Uint8Array([0]),s=0;for(;s<64||o[o.length-1]>s-32;){let a=t.length+r.length+i.length,c=new Uint8Array(a),l=0;c.set(t,l),l+=t.length,c.set(r,l),l+=r.length,c.set(i,l);let d=new Uint8Array(a*64);for(let f=0,p=0;f<64;f++,p+=a)d.set(c,p);o=new Wd(r.subarray(0,16)).encrypt(d,r.subarray(16,32));let u=o.slice(0,16).reduce((f,p)=>f+p,0)%3;u===0?r=Zs(o,0,o.length):u===1?r=NF(o,0,o.length):u===2&&(r=Gb(o,0,o.length)),s++}return r.subarray(0,32)}hash(t,e,i){return this.calculatePDF20Hash(t,e,i)}checkOwnerPassword(t,e,i,r){let o=new Uint8Array(t.length+56);o.set(t,0),o.set(e,t.length),o.set(i,t.length+e.length);let s=this.calculatePDF20Hash(t,o,i);return Xo(s,r)}checkUserPassword(t,e,i){let r=new Uint8Array(t.length+8);r.set(t,0),r.set(e,t.length);let o=this.calculatePDF20Hash(t,r,new Uint8Array);return Xo(o,i)}getOwnerKey(t,e,i,r){let o=new Uint8Array(t.length+56);o.set(t,0),o.set(e,t.length),o.set(i,t.length+e.length);let s=this.calculatePDF20Hash(t,o,i);return new Eo(s).decryptBlock(r,!1,new Uint8Array(16))}getUserKey(t,e,i){let r=new Uint8Array(t.length+8);r.set(t,0),r.set(e,t.length);let o=this.calculatePDF20Hash(t,r,new Uint8Array);return new Eo(o).decryptBlock(i,!1,new Uint8Array(16))}},jd=class{constructor(t,e){this.StringCipherConstructor=t,this.StreamCipherConstructor=e}createStream(t,e){let i=this.StreamCipherConstructor();return new Kb(t,function(o,s){return i.decryptBlock(o,s)},e)}decryptString(t){let e=this.StringCipherConstructor(),i=Ko(t);return i=e.decryptBlock(i,!0),nn(i)}decryptBytes(t){return this.StringCipherConstructor().decryptBlock(t,!0)}encryptString(t){let e=this.StringCipherConstructor();if(e instanceof To){let o=16-t.length%16;t+=String.fromCharCode(o).repeat(o);let s=new Uint8Array(16);if(typeof crypto!="undefined")crypto.getRandomValues(s);else for(let l=0;l<16;l++)s[l]=Math.floor(256*Math.random());let a=Ko(t);a=e.encrypt(a,s);let c=new Uint8Array(16+a.length);return c.set(s),c.set(a,16),nn(c)}let i=Ko(t);return i=e.encrypt(i),nn(i)}},Kd=class{constructor(t,e,i){var r,o;this.defaultPasswordBytes=new Uint8Array([40,191,78,94,78,117,138,65,100,0,78,86,255,250,1,8,46,46,0,182,208,104,62,128,47,12,169,254,100,83,105,122]),this.identityName=x.of("Identity");let s=t.get(x.of("Filter"));if(s.asString()!=="/Standard")throw new Error("unknown encryption method");this.filterName=s.asString(),this.dict=t;let a=t.get(x.of("V")).asNumber();if(!Number.isInteger(a)||a!==1&&a!==2&&a!==4&&a!==5)throw new Error("unsupported encryption algorithm");this.algorithm=a;let c=(r=t.get(x.of("Length")))===null||r===void 0?void 0:r.asNumber();if(!c)if(a<=3)c=40;else{let w=t.get(x.of("CF")),F=t.get(x.of("StmF"));if(w instanceof R&&F instanceof x){w.suppressEncryption=!0;let v=w.get(x.of(F.asString())),P=null;v&&(P=v.get(x.of("Length"))),c=P&&P.asNumber()||128,c<40&&(c<<=3)}}if(c===void 0||!Number.isInteger(c)||c<40||c%8!==0)throw new Error(`invalid key length: ${c}`);let l=t.get(x.of("O")).asBytes(),d=t.get(x.of("U")).asBytes(),h=l.subarray(0,32),u=d.subarray(0,32),f=t.get(x.of("P")).asNumber(),p=t.get(x.of("R")).asNumber(),g=(a===4||a===5)&&((o=t.get(x.of("EncryptMetadata")))===null||o===void 0?void 0:o.asBoolean())!==!1;this.encryptMetadata=g;let m;if(i){if(p===6)try{i=unescape(encodeURIComponent(i))}catch(w){console.warn("CipherTransformFactory: Unable to convert UTF8 encoded password.")}m=Ko(i)}let b;if(a!==5)b=this.prepareKeyData(e,m,h,u,f,p,c,g);else{let w=l.subarray(32,40),F=l.subarray(40,48),v=d.subarray(0,48),P=d.subarray(32,40),k=d.subarray(40,48),C=t.get(x.of("OE")).asBytes(),D=t.get(x.of("UE")).asBytes(),T=t.get(x.of("Perms")).asBytes();b=this.createEncryptionKey20(p,m,h,w,F,v,u,P,k,C,D,T)}if(!b&&!i)throw new Error("NEEDS PASSWORD");if(!b&&i){let w=this.decodeUserPassword(m,h,p,c);b=this.prepareKeyData(e,w,h,u,f,p,c,g)}if(!b)throw new Error("Password incorrect");if(this.encryptionKey=b,a>=4){let w=t.get(x.of("CF"));w instanceof R&&(w.suppressEncryption=!0),this.cf=w,this.stmf=t.get(x.of("StmF"))||this.identityName,this.strf=t.get(x.of("StrF"))||this.identityName,this.eff=t.get(x.of("EFF"))||this.stmf}}createCipherTransform(t,e){if(this.algorithm===4||this.algorithm===5)return new jd(this.buildCipherConstructor(this.cf,this.strf,t,e,this.encryptionKey),this.buildCipherConstructor(this.cf,this.stmf,t,e,this.encryptionKey));let i=this.buildObjectKey(t,e,this.encryptionKey,!1),r=function(){return new Tn(i)};return new jd(r,r)}createEncryptionKey20(t,e,i,r,o,s,a,c,l,d,h,u){if(e){let p=Math.min(127,e.length);e=e.subarray(0,p)}else e=new Uint8Array;let f;return t===6?f=new np:f=new ip,f.checkUserPassword(e,c,a)?f.getUserKey(e,l,h):e.length&&f.checkOwnerPassword(e,r,s,i)?f.getOwnerKey(e,o,s,d):null}prepareKeyData(t,e,i,r,o,s,a,c){let l=40+i.length+t.length,d=new Uint8Array(l),h=0,u,f;if(e)for(f=Math.min(32,e.length);h>8&255,d[h++]=o>>16&255,d[h++]=o>>>24&255,u=0,f=t.length;u=4&&!c&&(d[h++]=255,d[h++]=255,d[h++]=255,d[h++]=255);let p=Xs(d,0,h),g=a>>3;if(s>=3)for(u=0;u<50;++u)p=Xs(p,0,g);let m=p.subarray(0,g),b,w;if(s>=3){for(h=0;h<32;++h)d[h]=this.defaultPasswordBytes[h];for(u=0,f=t.length;u>3;if(i>=3)for(c=0;c<50;++c)l=Xs(l,0,l.length);let h,u;if(i>=3){u=e;let f=new Uint8Array(d);for(c=19;c>=0;c--){for(let p=0;p>8&255,o[a++]=t>>16&255,o[a++]=e&255,o[a++]=e>>8&255,r&&(o[a++]=115,o[a++]=65,o[a++]=108,o[a++]=84),Xs(o,0,a).subarray(0,Math.min(i.length+5,16))}buildCipherConstructor(t,e,i,r,o){if(!(e instanceof x))throw new Error("Invalid crypt filter name.");let s=t.get(x.of(e.asString().replace("/",""))),a;if(s!=null&&(a=s.get(x.of("CFM"))),!a||a.asString()==="/None")return function(){return new tp};if(a.asString()==="/V2")return()=>new Tn(this.buildObjectKey(i,r,o,!1));if(a.asString()==="/AESV2")return()=>new Wd(this.buildObjectKey(i,r,o,!0));if(a.asString()==="/AESV3")return()=>new Eo(o);throw new Error("Unknown crypto method")}};var pe=class{static async load(t,e={}){let{ignoreEncryption:i=!1,parseSpeed:r=pc.Slow,throwOnInvalidObject:o=!1,warnOnInvalidObjects:s=!1,updateMetadata:a=!0,capNumbers:c=!1,password:l}=e;S(t,"pdf",["string",Uint8Array,ArrayBuffer]),S(i,"ignoreEncryption",["boolean"]),S(r,"parseSpeed",["number"]),S(o,"throwOnInvalidObject",["boolean"]),S(s,"warnOnInvalidObjects",["boolean"]),S(l,"password",["string","undefined"]);let d=Lr(t),h=await Wl.forBytesWithOptions(d,r,o,c).parseDocument();if(h.lookup(h.trailerInfo.Encrypt)&&l!==void 0){let u=h.lookup(h.trailerInfo.ID,H),f=h.lookup(h.trailerInfo.Encrypt,R),p=await Wl.forBytesWithOptions(d,r,o,s,c,new Kd(f,u.get(0).asBytes(),l)).parseDocument();return new pe(p,!0,a)}else return new pe(h,i,a)}static async create(t={}){let{updateMetadata:e=!0}=t,i=Yr.create(),r=Ts.withContext(i),o=i.register(r),s=Cs.withContextAndPages(i,o);return i.trailerInfo.Root=i.register(s),new pe(i,!1,e)}constructor(t,e,i){if(this.defaultWordBreaks=[" "],this.computePages=()=>{let r=[];return this.catalog.Pages().traverse((o,s)=>{if(o instanceof tt){let a=this.pageMap.get(o);a||(a=Pe.of(o,s,this),this.pageMap.set(o,a)),r.push(a)}}),r},this.getOrCreateForm=()=>{let r=this.catalog.getOrCreateAcroForm();return Sn.of(r,this)},S(t,"context",[[Yr,"PDFContext"]]),S(e,"ignoreEncryption",["boolean"]),this.context=t,this.catalog=t.lookup(t.trailerInfo.Root),t.lookup(t.trailerInfo.Encrypt)&&t.isDecrypted&&delete t.trailerInfo.Encrypt,this.isEncrypted=!!t.lookup(t.trailerInfo.Encrypt),this.pageCache=ct.populatedBy(this.computePages),this.pageMap=new Map,this.formCache=ct.populatedBy(this.getOrCreateForm),this.fonts=[],this.images=[],this.embeddedPages=[],this.embeddedFiles=[],this.javaScripts=[],!e&&this.isEncrypted)throw new ko;i&&this.updateInfoDict()}registerFontkit(t){this.fontkit=t}getForm(){let t=this.formCache.access();return t.hasXFA()&&(console.warn("Removing XFA form data as pdf-lib does not support reading or writing XFA"),t.deleteXFA()),t}getTitle(){let t=this.getInfoDict().lookup(x.Title);if(t)return ur(t),t.decodeText()}getAuthor(){let t=this.getInfoDict().lookup(x.Author);if(t)return ur(t),t.decodeText()}getSubject(){let t=this.getInfoDict().lookup(x.Subject);if(t)return ur(t),t.decodeText()}getKeywords(){let t=this.getInfoDict().lookup(x.Keywords);if(t)return ur(t),t.decodeText()}getCreator(){let t=this.getInfoDict().lookup(x.Creator);if(t)return ur(t),t.decodeText()}getProducer(){let t=this.getInfoDict().lookup(x.Producer);if(t)return ur(t),t.decodeText()}getCreationDate(){let t=this.getInfoDict().lookup(x.CreationDate);if(t)return ur(t),t.decodeDate()}getModificationDate(){let t=this.getInfoDict().lookup(x.ModDate);if(t)return ur(t),t.decodeDate()}setTitle(t,e){S(t,"title",["string"]);let i=x.of("Title");this.getInfoDict().set(i,M.fromText(t)),e!=null&&e.showInWindowTitleBar&&this.catalog.getOrCreateViewerPreferences().setDisplayDocTitle(!0)}setAuthor(t){S(t,"author",["string"]);let e=x.of("Author");this.getInfoDict().set(e,M.fromText(t))}setSubject(t){S(t,"author",["string"]);let e=x.of("Subject");this.getInfoDict().set(e,M.fromText(t))}setKeywords(t){S(t,"keywords",[Array]);let e=x.of("Keywords");this.getInfoDict().set(e,M.fromText(t.join(" ")))}setCreator(t){S(t,"creator",["string"]);let e=x.of("Creator");this.getInfoDict().set(e,M.fromText(t))}setProducer(t){S(t,"creator",["string"]);let e=x.of("Producer");this.getInfoDict().set(e,M.fromText(t))}setLanguage(t){S(t,"language",["string"]);let e=x.of("Lang");this.catalog.set(e,G.of(t))}setCreationDate(t){S(t,"creationDate",[[Date,"Date"]]);let e=x.of("CreationDate");this.getInfoDict().set(e,G.fromDate(t))}setModificationDate(t){S(t,"modificationDate",[[Date,"Date"]]);let e=x.of("ModDate");this.getInfoDict().set(e,G.fromDate(t))}getPageCount(){return this.pageCount===void 0&&(this.pageCount=this.getPages().length),this.pageCount}getPages(){return this.pageCache.access()}getPage(t){let e=this.getPages();return lt(t,"index",0,e.length-1),e[t]}getPageIndices(){return lu(0,this.getPageCount())}removePage(t){let e=this.getPageCount();if(this.pageCount===0)throw new ac;lt(t,"index",0,e-1),this.catalog.removeLeafNode(t),this.pageCount=e-1}addPage(t){return S(t,"page",["undefined",[Pe,"PDFPage"],Array]),this.insertPage(this.getPageCount(),t)}insertPage(t,e){let i=this.getPageCount();if(lt(t,"index",0,i),S(e,"page",["undefined",[Pe,"PDFPage"],Array]),!e||Array.isArray(e)){let o=Array.isArray(e)?e:So.A4;e=Pe.create(this),e.setSize(...o)}else if(e.doc!==this)throw new sc;let r=this.catalog.insertLeafNode(e.ref,t);return e.node.setParent(r),this.pageMap.set(e.node,e),this.pageCache.invalidate(),this.pageCount=i+1,e}async copyPages(t,e){S(t,"srcDoc",[[pe,"PDFDocument"]]),S(e,"indices",[Array]),await t.flush();let i=ml.for(t.context,this.context),r=t.getPages(),o=e.map(s=>r[s]).map(async s=>i.copy(s.node)).map(s=>s.then(a=>Pe.of(a,this.context.register(a),this)));return Promise.all(o)}async copy(){let t=await pe.create(),e=await t.copyPages(this,this.getPageIndices());for(let i=0,r=e.length;ia:ml.for(r,this.context).copy,s=new Array(t.length);for(let a=0,c=t.length;a[n*s+e*a,t*s+i*a,n*c+e*l,t*c+i*l,n*d+e*h+r,t*d+i*h+o],Yd=([n,t,e,i,r,o],{x:s,y:a})=>({x:n*s+e*a+r,y:t*s+i*a+o}),Jd=(n,t)=>{switch(n){case"scale":case"scaleX":case"scaleY":{let[e,i=e]=t;return[n==="scaleY"?1:e,0,0,n==="scaleX"?1:i,0,0]}case"translate":case"translateX":case"translateY":{let[e,i=e]=t;return[1,0,0,1,n==="translateY"?0:e,n==="translateX"?0:-i]}case"rotate":{let[e,i=0,r=0]=t,o=Jd("translate",[i,r]),s=Jd("translate",[-i,-r]),a=Jt(-e),c=[Math.cos(a),Math.sin(a),-Math.sin(a),Math.cos(a),0,0];return bc(bc(o,c),s)}case"skewY":case"skewX":{let e=Jt(-t[0]),i=Math.tan(e);return[1,n==="skewY"?i:0,n==="skewX"?i:0,1,0,0]}case"matrix":{let[e,i,r,o,s,a]=t,c=Jd("scale",[1,-1]);return bc(bc(c,[e,i,r,o,s,a]),c)}default:return ox}},fr=(n,t,e)=>bc(n,Jd(t,e)),$F={butt:_t.Butt,round:_t.Round,square:_t.Projecting},eP={evenodd:Wi.EvenOdd,nonzero:Wi.NonZero},tP={bevel:yo.Bevel,miter:yo.Miter,round:yo.Round},sx=(n,t)=>({async text(e){let i=e.svgAttributes.textAnchor,r=e.svgAttributes.dominantBaseline,o=e.text.trim().replace(/\s/g," "),s=e.svgAttributes.fontSize||12,a=(f,p)=>{let g=f.fontFamily;if(!g)return;let m=f.fontWeight==="bold"||Number(f.fontWeight)>=700,b=f.fontStyle==="italic",w=(F,v,P)=>p[P+(F?"_bold":"")+(v?"_italic":"")];return w(m,b,g)||w(m,!1,g)||w(!1,b,g)||w(!1,!1,g)||Object.keys(p).find(F=>F.startsWith(g))},c=t.fonts&&a(e.svgAttributes,t.fonts),l=(c||n.getFont()[0]).widthOfTextAtSize(o,s),d=(c||n.getFont()[0]).heightAtSize(s),h=i==="middle"?l/2:i==="end"?l:0,u=r==="text-before-edge"?d:r==="text-after-edge"?-d:r==="middle"?d/2:0;n.drawText(o,{x:-h,y:-u,font:c,size:s,color:e.svgAttributes.fill,opacity:e.svgAttributes.fillOpacity,matrix:e.svgAttributes.matrix,clipSpaces:e.svgAttributes.clipSpaces})},async line(e){n.drawLine({start:{x:e.svgAttributes.x1||0,y:-e.svgAttributes.y1||0},end:{x:e.svgAttributes.x2||0,y:-e.svgAttributes.y2||0},thickness:e.svgAttributes.strokeWidth,color:e.svgAttributes.stroke,opacity:e.svgAttributes.strokeOpacity,lineCap:e.svgAttributes.strokeLineCap,matrix:e.svgAttributes.matrix,clipSpaces:e.svgAttributes.clipSpaces})},async path(e){e.svgAttributes.d&&n.drawSvgPath(e.svgAttributes.d,{x:0,y:0,borderColor:e.svgAttributes.stroke,borderWidth:e.svgAttributes.strokeWidth,borderOpacity:e.svgAttributes.strokeOpacity,borderLineCap:e.svgAttributes.strokeLineCap,color:e.svgAttributes.fill,opacity:e.svgAttributes.fillOpacity,fillRule:e.svgAttributes.fillRule,matrix:fr(e.svgAttributes.matrix,"scale",[1,-1]),clipSpaces:e.svgAttributes.clipSpaces})},async image(e){let{src:i}=e.svgAttributes;if(!i)return;let o=i.match(/\.png(\?|$)|^data:image\/png;base64/gim)?await n.doc.embedPng(i):await n.doc.embedJpg(i),{x:s,y:a,width:c,height:l}=iP(o.width,o.height,e.svgAttributes.width||o.width,e.svgAttributes.height||o.height,e.svgAttributes.preserveAspectRatio);n.drawImage(o,{x:s,y:-a-l,width:c,height:l,opacity:e.svgAttributes.fillOpacity,matrix:e.svgAttributes.matrix,clipSpaces:e.svgAttributes.clipSpaces})},async rect(e){!e.svgAttributes.fill&&!e.svgAttributes.stroke||n.drawRectangle({x:0,y:0,width:e.svgAttributes.width,height:e.svgAttributes.height*-1,borderColor:e.svgAttributes.stroke,borderWidth:e.svgAttributes.strokeWidth,borderOpacity:e.svgAttributes.strokeOpacity,borderLineCap:e.svgAttributes.strokeLineCap,color:e.svgAttributes.fill,opacity:e.svgAttributes.fillOpacity,matrix:e.svgAttributes.matrix,clipSpaces:e.svgAttributes.clipSpaces})},async ellipse(e){n.drawEllipse({x:e.svgAttributes.cx||0,y:-(e.svgAttributes.cy||0),xScale:e.svgAttributes.rx,yScale:e.svgAttributes.ry,borderColor:e.svgAttributes.stroke,borderWidth:e.svgAttributes.strokeWidth,borderOpacity:e.svgAttributes.strokeOpacity,borderLineCap:e.svgAttributes.strokeLineCap,color:e.svgAttributes.fill,opacity:e.svgAttributes.fillOpacity,matrix:e.svgAttributes.matrix,clipSpaces:e.svgAttributes.clipSpaces})},async circle(e){return sx(n,t).ellipse(e)}}),ft=(n,t,e,i)=>{let r=t[e]||n[e];return!r&&typeof i!="undefined"?i:r},ax=n=>{let t=/([^:\s]+)*\s*:\s*([^;]+)/g,e={},i=t.exec(n);for(;i!=null;)e[i[1]]=i[2],i=t.exec(n);return e},dp=(n,t)=>{if(!n||n.length===0||["none","transparent"].includes(n))return;if(n==="currentColor")return t||dp("#000000");let e=Rf(n);return{rgb:e.rgb,alpha:e.alpha?e.alpha+"":void 0}},hp=(n,t,e)=>{var i,r,o,s;let a=n.attributes,c=ax(a.style),l=ft(a,c,"width",""),d=ft(a,c,"height",""),h=dp(ft(a,c,"fill")),u=ft(a,c,"fill-opacity"),f=ft(a,c,"opacity"),p=dp(ft(a,c,"stroke")),g=ft(a,c,"stroke-opacity"),m=ft(a,c,"stroke-linecap"),b=ft(a,c,"stroke-linejoin"),w=ft(a,c,"fill-rule"),F=ft(a,c,"stroke-width"),v=ft(a,c,"font-family"),P=ft(a,c,"font-style"),k=ft(a,c,"font-weight"),C=ft(a,c,"font-size"),D=ut(l,t.width),T=ut(d,t.height),O=ut(a.x,t.width),E=ut(a.y,t.height),V=ut(a.x1,t.width),W=ut(a.x2,t.width),B=ut(a.y1,t.height),U=ut(a.y2,t.height),te=ut(a.cx,t.width),z=ut(a.cy,t.height),re=ut(a.rx||a.r,t.width),Ee=ut(a.ry||a.r,t.height),Ue={fontFamily:v||t.fontFamily,fontStyle:P||t.fontStyle,fontWeight:k||t.fontWeight,fontSize:(i=ut(C))!==null&&i!==void 0?i:t.fontSize,fill:(h==null?void 0:h.rgb)||t.fill,fillOpacity:(r=ut(u||f||(h==null?void 0:h.alpha)))!==null&&r!==void 0?r:t.fillOpacity,fillRule:eP[w]||t.fillRule,stroke:(p==null?void 0:p.rgb)||t.stroke,strokeWidth:(o=ut(F))!==null&&o!==void 0?o:t.strokeWidth,strokeOpacity:(s=ut(g||f||(p==null?void 0:p.alpha)))!==null&&s!==void 0?s:t.strokeOpacity,strokeLineCap:$F[m]||t.strokeLineCap,strokeLineJoin:tP[b]||t.strokeLineJoin,width:D||t.width,height:T||t.height,rotation:t.rotation,viewBox:n.tagName==="svg"&&n.attributes.viewBox?Qd(n.attributes.viewBox):t.viewBox},me={src:a.src||a["xlink:href"],textAnchor:a["text-anchor"],dominantBaseline:a["dominant-baseline"],preserveAspectRatio:a.preserveAspectRatio},Ae=a.transform||"";["translate","translateX","translateY","skewX","skewY","rotate","scale","scaleX","scaleY","matrix"].forEach(ve=>{a[ve]&&(Ae=a[ve]+" "+Ae)}),(O||E)&&(Ae=Ae+`translate(${O||0} ${E||0}) `);let we=e;if(Ae){let ve=/(\w+)\((.+?)\)/g,tn=ve.exec(Ae);for(;tn!==null;){let[,ma,Wt]=tn,Wo=(Wt||"").split(/\s*,\s*|\s+/).filter(Hn=>Hn.length>0).map(Hn=>parseFloat(Hn));we=fr(we,ma,Wo),tn=ve.exec(Ae)}}if(me.x=O,me.y=E,(a.cx||a.cy)&&(me.cx=te,me.cy=z),(a.rx||a.ry||a.r)&&(me.rx=re,me.ry=Ee),(a.x1||a.y1)&&(me.x1=V,me.y1=B),(a.x2||a.y2)&&(me.x2=W,me.y2=U),(a.width||a.height)&&(me.width=D!=null?D:t.width,me.height=T!=null?T:t.height),a.d&&(we=fr(we,"scale",[1,-1]),me.d=a.d),C&&Ue.fontSize&&(Ue.fontSize=Ue.fontSize),Ue.fontFamily){let ve=Ue.fontFamily.match(/^"(.*?)"|^'(.*?)'/);ve&&(Ue.fontFamily=ve[1]||ve[2])}return Ue.strokeWidth&&(me.strokeWidth=Ue.strokeWidth),{inherited:Ue,svgAttributes:me,tagName:n.tagName,matrix:we}},iP=(n,t,e,i,r)=>{if(r==="none")return{x:0,y:0,width:e,height:i};let o=n/t,s=e/i,a=s>o?o*i:e,c=s>=o?i:e/o,l=e-a,d=i-c,[h,u]=(()=>{switch(r){case"xMinYMin":return[0,0];case"xMidYMin":return[l/2,0];case"xMaxYMin":return[l,d/2];case"xMinYMid":return[0,d];case"xMaxYMid":return[l,d/2];case"xMinYMax":return[0,d];case"xMidYMax":return[l/2,d];case"xMaxYMax":return[l,d];case"xMidYMid":default:return[l/2,d/2]}})();return{x:h,y:u,width:a,height:c}},nP=(n,t,e,i,r,o="xMidYMid")=>{let[s,a="meet"]=o.split(" "),c=i/t,l=r/e,d=fr(n,"scale",[c,l]);if(s==="none")return{clipBox:d,content:d};let h=a==="slice"?Math.max(c,l):Math.min(c,l),u=i-t*h,f=r-e*h,[p,g]=(()=>{switch(s){case"xMinYMin":return[0,0];case"xMidYMin":return[u/2,0];case"xMaxYMin":return[u,f/2];case"xMinYMid":return[0,f];case"xMaxYMid":return[u,f/2];case"xMinYMax":return[0,f];case"xMidYMax":return[u/2,f];case"xMaxYMax":return[u,f];case"xMidYMid":default:return[u/2,f/2]}})(),m=fr(fr(n,"translate",[p,g]),"scale",[h]);return{clipBox:d,content:m}},up=(n,t,e,i)=>{if(n.nodeType===$s.NodeType.COMMENT_NODE)return[];if(n.nodeType===$s.NodeType.TEXT_NODE)return[];if(n.tagName==="g")return oP(n,t,e,i);if(n.tagName==="svg")return rP(n,t,e,i);{n.tagName==="polygon"&&(n.tagName="path",n.attributes.d=`M${n.attributes.points}Z`,delete n.attributes.points);let r=hp(n,t,e),o={...r.inherited,...r.svgAttributes,matrix:r.matrix,clipSpaces:i};return Object.assign(n,{svgAttributes:o}),[n]}},rP=(n,t,e,i)=>{var r,o;(r=n.attributes.width)!==null&&r!==void 0||n.setAttribute("width",t.viewBox.width+""),(o=n.attributes.height)!==null&&o!==void 0||n.setAttribute("height",t.viewBox.height+"");let s=hp(n,t,e),a=[],c=n.attributes.viewBox?Qd(n.attributes.viewBox):n.attributes.width&&n.attributes.height?Qd(`0 0 ${n.attributes.width} ${n.attributes.height}`):t.viewBox,l=parseFloat(n.attributes.x)||0,d=parseFloat(n.attributes.y)||0,h=fr(e,"translate",[l,d]),{clipBox:u,content:f}=nP(h,c.width,c.height,parseFloat(n.attributes.width),parseFloat(n.attributes.height),n.attributes.preserveAspectRatio),p=Yd(u,{x:0,y:0}),g=Yd(u,{x:c.width,y:0}),m=Yd(u,{x:c.width,y:-c.height}),b=Yd(u,{x:0,y:-c.height}),w={topLeft:p,topRight:g,bottomRight:m,bottomLeft:b};return h=fr(f,"translate",[-c.x,-c.y]),n.childNodes.forEach(F=>{let v=up(F,{...s.inherited,viewBox:c},h,[...i,w]);a.push(...v)}),a},oP=(n,t,e,i)=>{let r=hp(n,t,e),o=[];return n.childNodes.forEach(s=>{o.push(...up(s,r.inherited,r.matrix,i))}),o},ut=(n,t=1)=>{if(!n)return;let e=parseFloat(n);if(!isNaN(e))return n.endsWith("%")?e*t/100:e},Qd=n=>{if(!n)return;let[t=0,e=0,i=1,r=1]=(n||"").split(" ").map(o=>ut(o));return{x:t,y:e,width:i,height:r}},sP=(n,{width:t,height:e,fontSize:i},r,o)=>{let s=(0,$s.parse)(n).firstChild;return t&&s.setAttribute("width",t+""),e&&s.setAttribute("height",e+""),i&&s.setAttribute("font-size",i+""),up(s,{...r,viewBox:Qd(s.attributes.viewBox||"0 0 1 1")},o,[])},lx=async(n,t,e)=>{if(!t)return;let i=n.getSize(),r=(0,$s.parse)(t).firstChild,o=r.attributes,s=ax(o.style),a=ft(o,s,"width",""),c=ft(o,s,"height",""),l=e.width!==void 0?e.width:parseFloat(a),d=e.height!==void 0?e.height:parseFloat(c);o.viewBox||r.setAttribute("viewBox",`0 0 ${a||l} ${c||d}`),(e.width||e.height)&&(l!==void 0&&(s.width=l+(isNaN(l)?"":"px")),d!==void 0&&(s.height=d+(isNaN(d)?"":"px")),r.setAttribute("style",Object.entries(s).map(([p,g])=>`${p}:${g};`).join("")));let h=[1,0,0,1,e.x||0,e.y||0],u=sx(n,e);await sP(r.outerHTML,e,i,h).reduce(async(p,g)=>{var m;return await p,(m=u[g.tagName])===null||m===void 0?void 0:m.call(u,g)},Promise.resolve())};var Pe=class{constructor(t,e,i){this.fontSize=24,this.fontColor=ne(0,0,0),this.lineHeight=24,this.x=0,this.y=0,S(t,"leafNode",[[tt,"PDFPageLeaf"]]),S(e,"ref",[[q,"PDFRef"]]),S(i,"doc",[[pe,"PDFDocument"]]),this.node=t,this.ref=e,this.doc=i}setRotation(t){let e=jl(t);Xa(e,"degreesAngle",90),this.node.set(x.of("Rotate"),this.doc.context.obj(e))}getRotation(){let t=this.node.Rotate();return X(t?t.asNumber():0)}setSize(t,e){S(t,"width",["number"]),S(e,"height",["number"]);let i=this.getMediaBox();this.setMediaBox(i.x,i.y,t,e);let r=this.getCropBox(),o=this.getBleedBox(),s=this.getTrimBox(),a=this.getArtBox(),c=this.node.CropBox(),l=this.node.BleedBox(),d=this.node.TrimBox(),h=this.node.ArtBox();c&&ss(r,i)&&this.setCropBox(i.x,i.y,t,e),l&&ss(o,i)&&this.setBleedBox(i.x,i.y,t,e),d&&ss(s,i)&&this.setTrimBox(i.x,i.y,t,e),h&&ss(a,i)&&this.setArtBox(i.x,i.y,t,e)}setWidth(t){S(t,"width",["number"]),this.setSize(t,this.getSize().height)}setHeight(t){S(t,"height",["number"]),this.setSize(this.getSize().width,t)}setMediaBox(t,e,i,r){S(t,"x",["number"]),S(e,"y",["number"]),S(i,"width",["number"]),S(r,"height",["number"]);let o=this.doc.context.obj([t,e,t+i,e+r]);this.node.set(x.MediaBox,o)}setCropBox(t,e,i,r){S(t,"x",["number"]),S(e,"y",["number"]),S(i,"width",["number"]),S(r,"height",["number"]);let o=this.doc.context.obj([t,e,t+i,e+r]);this.node.set(x.CropBox,o)}setBleedBox(t,e,i,r){S(t,"x",["number"]),S(e,"y",["number"]),S(i,"width",["number"]),S(r,"height",["number"]);let o=this.doc.context.obj([t,e,t+i,e+r]);this.node.set(x.BleedBox,o)}setTrimBox(t,e,i,r){S(t,"x",["number"]),S(e,"y",["number"]),S(i,"width",["number"]),S(r,"height",["number"]);let o=this.doc.context.obj([t,e,t+i,e+r]);this.node.set(x.TrimBox,o)}setArtBox(t,e,i,r){S(t,"x",["number"]),S(e,"y",["number"]),S(i,"width",["number"]),S(r,"height",["number"]);let o=this.doc.context.obj([t,e,t+i,e+r]);this.node.set(x.ArtBox,o)}getSize(){let{width:t,height:e}=this.getMediaBox();return{width:t,height:e}}getWidth(){return this.getSize().width}getHeight(){return this.getSize().height}getMediaBox(){return this.node.MediaBox().asRectangle()}getCropBox(){var t;let e=this.node.CropBox();return(t=e==null?void 0:e.asRectangle())!==null&&t!==void 0?t:this.getMediaBox()}getBleedBox(){var t;let e=this.node.BleedBox();return(t=e==null?void 0:e.asRectangle())!==null&&t!==void 0?t:this.getCropBox()}getTrimBox(){var t;let e=this.node.TrimBox();return(t=e==null?void 0:e.asRectangle())!==null&&t!==void 0?t:this.getCropBox()}getArtBox(){var t;let e=this.node.ArtBox();return(t=e==null?void 0:e.asRectangle())!==null&&t!==void 0?t:this.getCropBox()}translateContent(t,e){S(t,"x",["number"]),S(e,"y",["number"]),this.node.normalize(),this.getContentStream();let i=this.createContentStream(Ne(),mt(t,e)),r=this.doc.context.register(i),o=this.createContentStream(Re()),s=this.doc.context.register(o);this.node.wrapContentStreams(r,s)}scale(t,e){S(t,"x",["number"]),S(e,"y",["number"]),this.setSize(this.getWidth()*t,this.getHeight()*e),this.scaleContent(t,e),this.scaleAnnotations(t,e)}scaleContent(t,e){S(t,"x",["number"]),S(e,"y",["number"]),this.node.normalize(),this.getContentStream();let i=this.createContentStream(Ne(),ar(t,e)),r=this.doc.context.register(i),o=this.createContentStream(Re()),s=this.doc.context.register(o);this.node.wrapContentStreams(r,s)}scaleAnnotations(t,e){S(t,"x",["number"]),S(e,"y",["number"]);let i=this.node.Annots();if(i)for(let r=0;rh.widthOfTextAtSize(v,f),m=e.maxWidth===void 0?wa(zn(t)):iu(t,p,e.maxWidth,g),b=new Array(m.length);for(let v=0,P=m.length;vnew Pe(n,t,e);Pe.create=n=>{S(n,"doc",[[pe,"PDFDocument"]]);let t=q.of(-1),e=tt.withContextAndParent(n.context,t),i=n.context.register(e);return new Pe(e,i,n)};var hi=class extends $e{constructor(t,e,i){super(t,e,i),S(t,"acroButton",[[vn,"PDFAcroPushButton"]]),this.acroField=t}setImage(t,e=si.Center){let i=this.acroField.getWidgets();for(let r=0,o=i.length;rnew hi(n,t,e);function Ze(n,t){let e=Object.keys(t).map(i=>aP(n,i,t[i]));return e.length===1?e[0]:function(){e.forEach(i=>i())}}function aP(n,t,e){let i=n[t],r=n.hasOwnProperty(t),o=r?i:function(){return Object.getPrototypeOf(n)[t].apply(this,arguments)},s=e(o);return i&&Object.setPrototypeOf(s,i),Object.setPrototypeOf(a,s),n[t]=a,c;function a(...l){return s===o&&n[t]===a&&c(),s.apply(this,l)}function c(){n[t]===a&&(r?n[t]=o:delete n[t]),s!==o&&(s=o,Object.setPrototypeOf(a,i||Function))}}var he=require("obsidian");var _d=require("obsidian"),rt=class extends _d.Modal{constructor(e){super(e.app);this.plugin=e,this.lib=e.lib,this.component=new _d.Component,this.contentEl.addClass("pdf-plus-modal")}onOpen(){this.component.load()}onClose(){this.contentEl.empty(),this.component.unload()}};var Zi=require("obsidian");var Hp={};Yh(Hp,{BidirectionalMultiValuedMap:()=>vc,CommandSuggest:()=>wc,FuzzyFileSuggest:()=>yc,FuzzyFolderSuggest:()=>mr,FuzzyInputSuggest:()=>gr,FuzzyMarkdownFileSuggest:()=>xc,MODIFIERS:()=>Sp,MultiValuedMap:()=>Ut,MutationObservingChild:()=>kc,areOverlapping:()=>Rp,areOverlappingStrictly:()=>Vp,binarySearch:()=>Gi,binarySearchForRangeStartingWith:()=>Np,camelCaseToKebabCase:()=>Fp,capitalize:()=>uP,cropCanvas:()=>bp,dispatchMouseEvent:()=>vp,doubleClick:()=>ih,encodeLinktext:()=>xr,evalInContext:()=>Bp,findReferenceCache:()=>Ip,focusObsidian:()=>Ac,formatAnnotationID:()=>Tc,genId:()=>Pp,getBorderRadius:()=>mp,getCJKRegexp:()=>ux,getCharacterBoundingBoxes:()=>dx,getCharactersWithBoundingBoxesInPDFCoords:()=>Dp,getDirectPDFObj:()=>et,getEventCoords:()=>eh,getFirstTextNodeIn:()=>pP,getInstallerVersion:()=>Ap,getModifierDictInPlatform:()=>Cp,getModifierNameInPlatform:()=>In,getNodeAndOffsetOfTextPos:()=>ea,getObsidianDefaultHighlightColorRGB:()=>lP,getOffsetInTextLayerNode:()=>rh,getPathSeparator:()=>gP,getSubpathWithoutHash:()=>Op,getTextLayerNode:()=>nh,getWordAt:()=>fP,hexToRgb:()=>pr,hookInternalLinkMouseEventHandlers:()=>Fc,hover:()=>dP,isAncestorOf:()=>Mp,isCanvas:()=>ia,isCitationId:()=>sh,isEmbed:()=>Ec,isHexString:()=>Ki,isHoverEditor:()=>hx,isHoverPopover:()=>na,isModifierName:()=>Tp,isMouseEventExternal:()=>fi,isNonEmbedLike:()=>On,isSelectionForward:()=>Xi,isTargetElement:()=>cx,isTargetHTMLElement:()=>vt,isTargetNode:()=>th,isTypable:()=>xp,isVersionNewerThan:()=>Sc,isVersionOlderThan:()=>Ep,kebabCaseToCamelCase:()=>hP,onModKeyPress:()=>wp,paramsToSubpath:()=>Cc,parsePDFSubpath:()=>Ln,range:()=>kp,registerCharacterKeymap:()=>mP,removeExtension:()=>Lp,repeat:()=>No,repeatable:()=>ah,rgbStringToObject:()=>gp,rgbToHex:()=>pp,rotateCanvas:()=>$d,showChildElOnParentElHover:()=>Pc,showMenuUnderParentEl:()=>An,stringCompare:()=>Mo,subpathToParams:()=>ta,swapSelectionAnchorAndFocus:()=>Dc,toPDFCoords:()=>oh,toSingleLine:()=>Ic});var It=require("obsidian");function Ki(n){return n.length===7&&n.startsWith("#")}function pr(n){let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:null}function pp(n){let{r:t,g:e,b:i}=n;return"#"+(1<<24|t<<16|e<<8|i).toString(16).slice(1)}function gp(n){let[t,e,i]=n.split(",").map(r=>parseInt(r.trim()));return{r:t,g:e,b:i}}function lP(){let[n,t,e]=getComputedStyle(document.body).getPropertyValue("--text-highlight-bg-rgb").split(",").map(i=>parseInt(i.trim()));return{r:n,g:t,b:e}}function mp(){let n=getComputedStyle(document.body).getPropertyValue("--radius-s");if(n.endsWith("px")){let t=parseInt(n.slice(0,-2));if(!isNaN(t))return t}return 0}var Ht=require("obsidian"),cP={blurOnSelect:!0,closeOnSelect:!0},gr=class extends Ht.AbstractInputSuggest{constructor(e,i,r){super(e,i);this.inputEl=i,this.options=Object.assign(cP,r)}getSuggestions(e){let i=(0,Ht.prepareFuzzySearch)(e.trim()),r=this.getItems(),o=[];for(let s of r){let a=i(this.getItemText(s));a&&o.push({match:a,item:s})}return(0,Ht.sortSearchResults)(o),o}renderSuggestion(e,i){(0,Ht.renderResults)(i,this.getItemText(e.item),e.match)}selectSuggestion(e,i){super.selectSuggestion(e,i),this.inputEl.value=this.getItemText(e.item),this.options.blurOnSelect&&this.inputEl.blur(),this.options.closeOnSelect&&this.close()}},xc=class extends gr{getItems(){return this.app.vault.getMarkdownFiles()}getItemText(t){return t.path}},yc=class extends gr{getItems(){return this.app.vault.getFiles()}getItemText(t){return t.path}},mr=class extends gr{getItems(){return this.app.vault.getAllLoadedFiles().filter(t=>t instanceof Ht.TFolder)}getItemText(t){return t.path}},wc=class extends Ht.AbstractInputSuggest{constructor(e,i){super(e.plugin.app,i);this.inputEl=i,this.plugin=e.plugin,this.tab=e}getSuggestions(e){let i=(0,Ht.prepareFuzzySearch)(e),r=Object.values(this.plugin.app.commands.commands),o=[];for(let s of r){let a=i(s.name);a&&o.push({match:a,command:s})}return(0,Ht.sortSearchResults)(o),o.map(({command:s})=>s)}renderSuggestion(e,i){i.setText(e.name)}selectSuggestion(e){this.inputEl.blur(),this.plugin.settings.commandToExecuteWhenTargetNotIdentified=e.id,this.inputEl.value=e.name,this.close(),this.plugin.saveSettings(),this.tab.redisplay()}};var Ut=class{constructor(){this.map=new Map}addValue(t,e){let i=this.map.get(t);i||(i=new Set,this.map.set(t,i)),i.add(e)}get(t){var e;return(e=this.map.get(t))!=null?e:new Set}delete(t){this.map.delete(t)}deleteValue(t,e){let i=this.map.get(t);i&&(i.delete(e),i.size===0&&this.map.delete(t))}has(t){return this.map.has(t)&&this.map.get(t).size>0}[Symbol.iterator](){return this.map[Symbol.iterator]()}},vc=class{constructor(){this.keyToValues=new Map;this.valueToKeys=new Map}addValue(t,e){this.keyToValues.has(t)||this.keyToValues.set(t,new Set),this.keyToValues.get(t).add(e),this.valueToKeys.has(e)||this.valueToKeys.set(e,new Set),this.valueToKeys.get(e).add(t)}get(t){var e;return(e=this.keyToValues.get(t))!=null?e:new Set}getKeys(t){var e;return(e=this.valueToKeys.get(t))!=null?e:new Set}delete(t){let e=this.keyToValues.get(t);if(e)for(let i of e){let r=this.valueToKeys.get(i);if(!r)throw new Error("Value has no keys");r.delete(t),r.size===0&&this.valueToKeys.delete(i)}this.keyToValues.delete(t)}deleteValue(t){let e=this.valueToKeys.get(t);if(e)for(let i of e){let r=this.keyToValues.get(i);if(!r)throw new Error("Key has no values");r.delete(t),r.size===0&&this.keyToValues.delete(i)}this.valueToKeys.delete(t)}has(t){return this.keyToValues.has(t)&&this.keyToValues.get(t).size>0}hasValue(t){return this.valueToKeys.has(t)&&this.valueToKeys.get(t).size>0}keys(){return this.keyToValues.keys()}values(){return this.valueToKeys.keys()}};function bp(n,t,e={width:t.width,height:t.height}){let i=createEl("canvas");return i.width=e.width,i.height=e.height,i.getContext("2d").drawImage(n,t.left,t.top,t.width,t.height,0,0,e.width,e.height),i}function $d(n,t){if(t=(t%360+360)%360,![0,90,180,270].includes(t))throw new Error("rotate must be 0, 90, 180, or 270");if(!t)return n;let e=createEl("canvas"),i=e.getContext("2d");return t===90||t===270?(e.width=n.height,e.height=n.width):(e.width=n.width,e.height=n.height),i.translate(e.width/2,e.height/2),i.rotate(t*Math.PI/180),i.drawImage(n,-n.width/2,-n.height/2),e}var br=require("obsidian");function Fc(n,t,e){t.querySelectorAll("a.internal-link").forEach(i=>{i.addEventListener("click",r=>{r.preventDefault();let o=i.getAttribute("href");o&&n.workspace.openLinkText(o,e,br.Keymap.isModEvent(r))}),i.addEventListener("mouseover",r=>{r.preventDefault();let o=i.getAttribute("href");o&&n.workspace.trigger("hover-link",{event:r,source:"preview",hoverParent:{hoverPopover:null},targetEl:r.currentTarget,linktext:o,sourcePath:e})})})}function fi(n,t){return!n.relatedTarget||cx(n,n.relatedTarget)&&!t.contains(n.relatedTarget)}function xp(n){return n.nodeName==="INPUT"||n.instanceOf(HTMLElement)&&n.contentEditable==="true"}function eh(n){return n.instanceOf(MouseEvent)?{x:n.clientX,y:n.clientY}:{x:n.touches[0].clientX,y:n.touches[0].clientY}}function yp(n,t,e){let i=t[e];return n instanceof i}function th(n,t){return!!t&&(t instanceof Node||yp(t,n.win,"Node"))}function cx(n,t){return!!t&&(t instanceof Element||yp(t,n.win,"Element"))}function vt(n,t){return!!t&&(t instanceof HTMLElement||yp(t,n.win,"HTMLElement"))}function wp(n,t,e){if(br.Keymap.isModifier(n,"Mod")){e();return}let i=n.doc,r=!1,o=()=>{r=!0,i.removeEventListener("keydown",s),i.removeEventListener("mouseover",a),i.removeEventListener("mouseleave",c)},s=l=>{r||(i.body.contains(t)?br.Keymap.isModifier(l,"Mod")&&(o(),e()):o())},a=l=>{r||th(l,l.target)&&!t.contains(l.target)&&o()},c=l=>{r||l.target===i&&o()};i.addEventListener("keydown",s),i.addEventListener("mouseover",a),i.addEventListener("mouseleave",c)}function Pc(n){let{parentEl:t,createChildEl:e,removeChildEl:i,component:r,timeout:o}=n,s=a=>{if(fi(a,t)){let c=!0,l=!1,d=e(),h=new br.Component;r==null||r.addChild(h),h.register(()=>d&&i(d)),h.load();let u=()=>setTimeout(()=>{!c&&!l&&h.unload()},o!=null?o:120),f=p=>{fi(p,t)&&(c=!1,u())};h.registerDomEvent(t,"mouseout",f),d&&h.registerDomEvent(d,"mouseover",p=>{if(fi(p,d)){l=!0;let g=m=>{fi(m,d)&&(l=!1,u())};h.registerDomEvent(d,"mouseout",g)}})}};t.addEventListener("mouseover",s)}function vp(n,t,e){n.dispatchEvent(new MouseEvent(t,{bubbles:!0,...e}))}function ih(n,t){vp(n,"dblclick",t)}function dP(n,t,e){e!=null||(e={}),t&&(e[br.Platform.isMacOS?"metaKey":"ctrlKey"]=!0);let{x:i,y:r}=n.getBoundingClientRect();vp(n,"mouseover",{doc:n.doc,clientX:i,clientY:r,...e})}function et(n,t){let e=n.get(x.of(t));return e instanceof q?n.context.lookup(e):e}function An(n,t){let{x:e,bottom:i,width:r}=t.getBoundingClientRect();return n.setParentElement(t).showAtPosition({x:e,y:i,width:r,overlap:!0,left:!1}),n}function Fp(n){return n.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function hP(n){return n.replace(/(-\w)/g,t=>t[1].toUpperCase())}function uP(n){return n.charAt(0).toUpperCase()+n.slice(1)}function fP(n,t){if(t<0||t>=n.length)return"";let e=Math.max(0,n.slice(0,t+1).search(/(?<=[^\s.,][\s.,]+)[^\s.,]*$/));n=n.slice(e),e=Math.max(0,n.search(/[^\s.,]/)),n=n.slice(e);let i=n.search(/[\s.,]/);return i===-1?n:n.slice(0,i)}function Pp(){let n=()=>((1+Math.random())*65536|0).toString(16).substring(1);return n()+n()+"-"+n()+"-"+n()+"-"+n()+"-"+n()+n()+n()}function kp(n,t){return Array.from({length:t-n},(e,i)=>n+i)}function nh(n,t){if(!n.contains(t))return null;if(t.instanceOf(HTMLElement)&&t.hasClass("textLayerNode"))return t;let e=t;for(;e=e.parentNode;){if(e===n)return null;if(e.instanceOf(HTMLElement)&&e.hasClass("textLayerNode"))return e}return null}function rh(n,t,e){if(!n.contains(t))return null;let i=n.doc.createNodeIterator(n,NodeFilter.SHOW_TEXT),r,o=e;for(;(r=i.nextNode())&&t!==r;)o+=r.textContent.length;return o}function ea(n,t){let e=n.doc.createNodeIterator(n,NodeFilter.SHOW_TEXT),i;for(;(i=e.nextNode())&&t>=i.textContent.length;)t-=i.textContent.length;return i?{node:i,offset:t}:null}function*dx(n){let t=n.doc.createNodeIterator(n,NodeFilter.SHOW_TEXT),e;for(;e=t.nextNode();)if(e.instanceOf(Text))for(let i=0;it<=s.position.start.offset&&s.position.end.offset<=e))!=null?o:(r=n.embeds)==null?void 0:r.find(s=>t<=s.position.start.offset&&s.position.end.offset<=e)}function Lp(n){let t=n.lastIndexOf(".");return t===-1||t===n.length-1||t===0?n:n.slice(0,t)}function Op(n){let{subpath:t}=(0,It.parseLinktext)(n);return t.startsWith("#")&&(t=t.slice(1)),t}function ta(n){return n.startsWith("#")&&(n=n.slice(1)),new URLSearchParams(n)}function Ln(n){let t=ta(n);if(!t.has("page"))return null;let e=+t.get("page");if(isNaN(e))return null;if(t.has("selection")){let i=t.get("selection").split(",").map(c=>parseInt(c.trim()));if(i.length!==4||i.some(c=>isNaN(c)))return null;let[r,o,s,a]=i;return{page:e,beginIndex:r,beginOffset:o,endIndex:s,endOffset:a}}if(t.has("annotation")){let i=t.get("annotation");return{page:e,annotation:i}}return{page:e}}function Cc(n){return"#"+Object.entries(n).filter(([t,e])=>t&&(e||e===0)).map(([t,e])=>`${t}=${e}`).join("&")}function Tc(n,t){return t===0?`${n}R`:`${n}R${t}`}var kc=class extends It.Component{constructor(e,i,r){super();this.targetEl=e;this.callback=i;this.options=r;this.observer=new MutationObserver(i)}onload(){this.observer.observe(this.targetEl,this.options)}onunload(){this.observer.disconnect()}};function On(n){return!n.isEmbed&&!hx(n)}function Ec(n){return n.isEmbed&&!ia(n)&&!na(n)}function ia(n){var t;return!!((t=n.dom)!=null&&t.containerEl.hasClass("canvas-node-content"))}function na(n){var t;return!!((t=n.dom)!=null&&t.containerEl.closest(".hover-popover"))}function hx(n){var t;return!!((t=n.dom)!=null&&t.containerEl.closest(".hover-editor"))}function Ac(){activeWindow.open("obsidian://")}function Mp(n,t,e=!1){if(e&&n===t)return!0;let i=t.parent;for(;i;){if(i===n)return!0;i=i.parent}return!1}function ux(n){n={japanese:!0,korean:!0,...n};let t="";return t+="\\u4e00-\\u9fff",t+="\\u3400-\\u4dbf",n.japanese&&(t+="\\u3040-\\u309F",t+="\\u30A0-\\u30FF",t+="\\uFF65-\\uFF9F",t+="\\u31F0-\\u31FF",t+="\\u3000-\\u303F"),n.korean&&(t+="\\u1100-\\u11FF",t+="\\uA960-\\uA97F",t+="\\uD7B0-\\uD7FF",t+="\\u3130-\\u318F",t+="\\uAC00-\\uD7AF"),new RegExp(`[${t}]`)}function Ic(n,t=!1){let e=ux({korean:!1});return n=n.replace(/(.?)([\r\n]+)(.?)/g,(i,r,o,s)=>e.test(r)&&e.test(s)?r+s:r==="-"&&s.match(/[a-zA-Z]/)?s:s?r+" "+s:r),t&&(n=n.replace(new RegExp(`(${e.source}) (?=${e.source})`,"g"),"$1")),window.pdfjsViewer.removeNullCharacters(window.pdfjsLib.normalizeUnicode(n))}function xr(n){return n.replace(/[\\\x00\x08\x0B\x0C\x0E-\x1F ]/g,t=>encodeURIComponent(t))}function sh(n){return typeof n=="string"&&n.startsWith("cite.")}function mP(n,t,e){return n.register(null,t,(i,r)=>{if(r.key===t&&r.modifiers!==null&&["","Shift"].includes(r.modifiers))return e(i,r)})}function Gi(n,t,e){var a,c,l,d;if(e&&e.findFirst&&e.findLast)throw Error("findFirst and findLast cannot be specified at the same time");let i=(a=e==null?void 0:e.findFirst)!=null?a:!1,r=(c=e==null?void 0:e.findLast)!=null?c:!1,o=(l=e==null?void 0:e.from)!=null?l:0,s=(d=e==null?void 0:e.to)!=null?d:n.length-1;if(o>s)return{found:!1,index:o};for(;;){let h=o+s+ +r>>1,u=n[h],f=t(u,h);if(f===0)if(i&&oh)o=h;else return{found:!0,index:h};else f>0?o=h+1:s=h-1;if(o>s)return{found:!1,index:h+ +(f>0)}}}function Mo(n,t){return n===t?0:nMo(t,e(a).slice(0,t.length)),{found:o,index:s}=Gi(n,r,{findFirst:!0,...i});if(o){let{index:a}=Gi(n,r,{findLast:!0,...i,from:s});return{from:s,to:a}}return null}function Rp(n,t){return n.from<=t.to&&n.to>=t.from}function Vp(n,t){return n.fromt.from}function Xi(n){return n.anchorNode===n.focusNode?n.anchorOffsetNo(n,t)}function Bp(n,t){return new Function(n.includes("await")?"(async () => {"+n+"})()":n).call(t)}var lh=class extends rt{constructor(e,i,r,o){super(e);this.file=i,this.page=r,this.id=o}},Ro=class extends lh{constructor(e,...i){super(...i);this.allowNoValue=e,this.supportedKeys=Object.keys(e),this.oldValues={},this.newValues={},this.containerEl.addClass("pdf-plus-annotation-edit-modal"),this.buttonContainerEl=this.modalEl.createDiv()}static isSubtypeSupported(e){return Ro.supportedSubtypes.includes(e)}static forSubtype(e,...i){return e==="Link"?Ro.forLinkAnnotation(...i):Ro.forTextMarkupAnnotation(...i)}static forTextMarkupAnnotation(...e){return new Ro({color:!1,opacity:!1,author:!1,contents:!0},...e)}static forLinkAnnotation(...e){return new Ro({color:!0,borderWidth:!0},...e)}async readOldValues(){let e=this.lib.highlight.writeFile.pdflib,i=await e.getAnnotation(this.file,this.page,this.id);if(!i)throw new Error(`${this.plugin.manifest.name}: Annotation not found.`);for(let r of this.supportedKeys)switch(r){case"color":this.oldValues.color=e.getColorFromAnnotation(i);break;case"opacity":this.oldValues.opacity=e.getOpacityFromAnnotation(i);break;case"borderWidth":this.oldValues.borderWidth=e.getBorderWidthFromAnnotation(i);break;case"author":this.oldValues.author=e.getAuthorFromAnnotation(i);break;case"contents":this.oldValues.contents=e.getContentsFromAnnotation(i);break}}async writeNewValues(){let e=this.lib.highlight.writeFile.pdflib,i=[];for(let r of this.supportedKeys)switch(r){case"color":if(this.newValues.color&&this.newValues.color!==this.oldValues.color){let o=this.newValues.color;i.push(s=>{e.setColorToAnnotation(s,o),this.lib.getLatestBacklinksForAnnotation(this.file,this.page,this.id).then(a=>{a.forEach(c=>this.lib.composer.linkUpdater.updateLinkColor(c.refCache,c.sourcePath,{type:"rgb",rgb:o},{linktext:!1}))})})}break;case"opacity":typeof this.newValues.opacity=="number"&&this.newValues.opacity!==this.oldValues.opacity&&i.push(o=>{e.setOpacityToAnnotation(o,this.newValues.opacity)});break;case"borderWidth":typeof this.newValues.borderWidth=="number"&&this.newValues.borderWidth!==this.oldValues.borderWidth&&i.push(o=>{e.setBorderWidthToAnnotation(o,this.newValues.borderWidth)});break;case"author":this.newValues.author&&this.newValues.author!==this.oldValues.author&&i.push(o=>{e.setAuthorToAnnotation(o,this.newValues.author)});break;case"contents":typeof this.newValues.contents=="string"&&this.newValues.contents!==this.oldValues.contents&&i.push(o=>{e.setContentsToAnnotation(o,this.newValues.contents)});break}i.length&&await e.processAnnotation(this.file,this.page,this.id,async r=>{i.forEach(o=>o(r))})}addColorSetting(){if(this.oldValues.color||this.allowNoValue.color){let e,i;new Zi.Setting(this.contentEl).setName("Color").setDesc("You can choose a color from the color picker or select one from your custom named colors.").addColorPicker(r=>{var o;e=r,e.setValueRgb((o=this.oldValues.color)!=null?o:{r:0,g:0,b:0}).onChange(s=>{let a=pr(s);a&&(this.newValues.color=a,i.setValue(s))})}).addDropdown(r=>{i=r,i.addOptions(Object.fromEntries(Object.entries(this.plugin.settings.colors).map(([o,s])=>[s,o]))).setValue(this.oldValues.color?pp(this.oldValues.color):"").onChange(o=>{let s=pr(o);s&&(this.newValues.color=s,e.setValue(o))})})}}addOpacitySetting(){(this.oldValues.opacity||this.allowNoValue.opacity)&&new Zi.Setting(this.contentEl).setName("Opacity").addSlider(e=>{var i;e.setLimits(0,1,.01).setValue((i=this.oldValues.opacity)!=null?i:1).setDynamicTooltip().onChange(r=>{this.newValues.opacity=r})})}addBorderWidthSetting(){(this.oldValues.borderWidth||this.allowNoValue.borderWidth)&&new Zi.Setting(this.contentEl).setName("Draw border").addToggle(e=>{var i;e.setValue(!!((i=this.oldValues.borderWidth)==null||i)).onChange(r=>{this.newValues.borderWidth=r?1:0})})}addAuthorSetting(){(this.oldValues.author||this.allowNoValue.author)&&new Zi.Setting(this.contentEl).setName("Annotation author").addText(e=>{var i;e.setValue((i=this.oldValues.author)!=null?i:"Author").onChange(r=>{this.newValues.author=r})})}initContentsSetting(){var e;if(this.textarea=null,this.editorEl=null,this.previewEl=null,this.plugin.settings.renderMarkdownInStickyNote){let i=(e=this.app.hotkeyManager.getHotkeys("markdown:toggle-preview"))!=null?e:this.app.hotkeyManager.getDefaultHotkeys("markdown:toggle-preview");if(i&&i.length){let r=i[0];this.scope.register(r.modifiers,r.key,()=>this.togglePreview())}}}addContentsSetting(){(this.oldValues.contents||this.allowNoValue.contents)&&new Zi.Setting(this.contentEl).setName("Contents").then(e=>{this.previewEl=e.controlEl.createDiv("preview-container markdown-rendered"),this.plugin.settings.renderMarkdownInStickyNote?e.setDesc(`Press ${this.app.hotkeyManager.printHotkeyForCommand("markdown:toggle-preview")} to toggle preview.`):e.setDesc('Tip: There is an option called "Render markdown in annotation popups when the annotation has text contents".')}).addTextArea(e=>{var i;this.textarea=e,this.editorEl=e.inputEl,this.editorEl.addClass("editor-container"),e.inputEl.rows=5,e.inputEl.setCssStyles({width:"100%"}),e.setValue((i=this.oldValues.contents)!=null?i:"").onChange(r=>{this.newValues.contents=r})}),this.showEditor()}addButtons(){new Zi.Setting(this.buttonContainerEl).addButton(e=>{e.setButtonText("Save").setCta().onClick(()=>{this.writeNewValues(),this.close()})}).addButton(e=>{e.setButtonText("Cancel").onClick(()=>this.close())}).then(e=>e.setClass("no-border"))}async onOpen(){super.onOpen(),this.titleEl.setText(`${this.plugin.manifest.name}: edit annotation contents`),await this.readOldValues();for(let e of this.supportedKeys)switch(e){case"color":this.addColorSetting();break;case"opacity":this.addOpacitySetting();break;case"borderWidth":this.addBorderWidthSetting();break;case"author":this.addAuthorSetting();break;case"contents":this.initContentsSetting(),this.addContentsSetting();break}this.addButtons()}async showEditor(){var e,i;(e=this.editorEl)==null||e.show(),(i=this.previewEl)==null||i.hide()}async showPreview(){var e,i;this.editorEl&&this.previewEl&&(this.previewEl.setCssStyles({width:`${this.editorEl.clientWidth}px`,height:`${this.editorEl.clientHeight}px`}),this.previewEl.empty(),await Zi.MarkdownRenderer.render(this.app,(i=(e=this.textarea)==null?void 0:e.getValue())!=null?i:"",this.previewEl,"",this.component),Fc(this.app,this.previewEl,this.file.path),this.editorEl.hide(),this.previewEl.show())}async togglePreview(){var e;return(e=this.editorEl)!=null&&e.isShown()?this.showPreview():this.showEditor()}},Mn=Ro;Mn.supportedSubtypes=["Highlight","Underline","Squiggly","StrikeOut","Link"];var ra=class extends lh{onOpen(){super.onOpen(),this.titleEl.setText(`${this.plugin.manifest.name}: delete annotation`),this.contentEl.createEl("p",{text:"Are you sure you want to delete this annotation?"}),this.plugin.settings.warnEveryAnnotationDelete||this.contentEl.createEl("p",{cls:"mod-warning",text:"There are one or more links pointing to this annotation."}),new Zi.Setting(this.contentEl).addButton(t=>{t.setButtonText("Delete").setWarning().onClick(()=>{this.deleteAnnotation(),this.close()})}).addButton(t=>{t.setButtonText("Cancel").onClick(()=>this.close())}).then(t=>t.setClass("no-border"))}openIfNeccessary(){return this.shouldOpen()?this.open():this.deleteAnnotation()}shouldOpen(){return this.plugin.settings.warnEveryAnnotationDelete||this.plugin.settings.warnBacklinkedAnnotationDelete&&this.lib.isBacklinked(this.file,{page:this.page,annotation:this.id})}deleteAnnotation(){this.lib.highlight.writeFile.deleteAnnotation(this.file,this.page,this.id)}};var oa=require("obsidian");var Lc,yr,ch=class extends rt{constructor(e,i,...r){super(...r);ba(this,Lc,void 0);ba(this,yr,void 0);this.file=e,this.page=i,xa(this,Lc,new Promise(o=>{xa(this,yr,o)}))}then(e){return pi(this,Lc).then(i=>{i&&e()}),this}onOpen(){super.onOpen(),this.titleEl.setText(`${this.plugin.manifest.name}: delete page`),this.contentEl.createEl("p",{text:"Are you sure you want to delete this page?"}),this.plugin.settings.warnEveryAnnotationDelete||this.contentEl.createEl("p",{cls:"mod-warning",text:"There are one or more links pointing to this page."}),new oa.Setting(this.contentEl).addButton(e=>{e.setButtonText("Delete").setWarning().onClick(()=>{pi(this,yr).call(this,!0),this.close()})}).addButton(e=>{e.setButtonText("Cancel").onClick(()=>{pi(this,yr).call(this,!1),this.close()})}).then(e=>e.setClass("no-border"))}onClose(){super.onClose(),pi(this,yr).call(this,!1)}openIfNeccessary(){return this.shouldOpen()?(this.open(),this):(pi(this,yr).call(this,!0),this)}shouldOpen(){return this.plugin.settings.warnEveryPageDelete||this.plugin.settings.warnBacklinkedPageDelete&&this.lib.isBacklinked(this.file,{page:this.page})}};Lc=new WeakMap,yr=new WeakMap;var Mc={keep:"Keep labels unchanged",update:"Update"},Oc,wr,Nn=class extends rt{constructor(e,i,r,o,s){super(e);ba(this,Oc,void 0);ba(this,wr,void 0);this.askPageLabelUpdateMethod=i,this.defaultMethod=r,this.askInPlace=o,this.defaultInPlace=s,xa(this,Oc,new Promise(a=>{xa(this,wr,a)}))}ask(){return this.askPageLabelUpdateMethod||this.askInPlace?this.open():pi(this,wr).call(this,{pageLabelUpdateMethod:this.defaultMethod,inPlace:this.defaultInPlace}),this}then(e){pi(this,Oc).then(i=>{if(i){let{pageLabelUpdateMethod:r,inPlace:o}=i;e(r==="keep",o)}})}onOpen(){super.onOpen(),this.titleEl.setText(`${this.plugin.manifest.name}: Page composer`);let e=this.defaultMethod,i=this.defaultInPlace;this.askPageLabelUpdateMethod&&new oa.Setting(this.contentEl).setName("Update the page labels?").setDesc(createFragment(r=>{r.createEl("a",{text:"Learn more",href:"https://github.com/RyotaUshio/obsidian-pdf-plus/wiki/Page-labels"})})).addDropdown(r=>{r.addOptions(Mc).setValue(e).onChange(o=>{e=o})}),this.askInPlace&&new oa.Setting(this.contentEl).setName("Remove pages from original file?").addToggle(r=>{r.setValue(i).onChange(o=>{i=o})}),new oa.Setting(this.contentEl).addButton(r=>{r.setButtonText("Proceed").setCta().onClick(()=>{(e==="keep"||e==="update")&&pi(this,wr).call(this,{pageLabelUpdateMethod:e,inPlace:i}),this.close()}),setTimeout(()=>r.buttonEl.focus())}).addButton(r=>{r.setButtonText("Cancel").onClick(()=>{pi(this,wr).call(this,null),this.close()})})}onClose(){super.onClose(),pi(this,wr).call(this,null)}};Oc=new WeakMap,wr=new WeakMap;var dh=class extends rt{constructor(){super(...arguments);this.pageSize="A4";this.orientation="portrait";this.next=[]}askOptions(){return this.open(),this}onOpen(){super.onOpen(),this.titleEl.setText(`${this.plugin.manifest.name}: Create new PDF`),this.addSetting().setName("Page size").addDropdown(e=>{Object.keys(So).forEach(i=>e.addOption(i,i)),e.setValue(this.pageSize).onChange(i=>{So.hasOwnProperty(i)&&(this.pageSize=i)})}),this.addSetting().setName("Orientation").addDropdown(e=>{e.addOption("portrait","Portrait").addOption("landscape","Landscape").setValue(this.orientation).onChange(i=>{(i==="portrait"||i==="landscape")&&(this.orientation=i)})}),this.addSetting().addButton(e=>{e.setButtonText("Create").setCta().then(i=>{setTimeout(()=>i.buttonEl.focus())}).onClick(async()=>{this.close();let i=await this.createPDFDocument();this.next.forEach(r=>r(i))})}).addButton(e=>{e.setButtonText("Cancel").onClick(()=>{this.close()})})}addSetting(){return new oa.Setting(this.contentEl)}then(e){return this.next.push(e),this}async createPDFDocument(){let e=await pe.create(),[i,r]=So[this.pageSize],o=Math.max(i,r),s=Math.min(i,r),a=this.orientation==="portrait"?[s,o]:[o,s];return e.addPage(a),e}};var Nc=require("obsidian"),vr=class extends rt{constructor(e,i){super(e);this.next=[];this.submitted=!1;this.title=null;this.modalTitle=i,this.component.registerDomEvent(this.modalEl.doc,"keypress",r=>{r.key==="Enter"&&this.submitAndClose()})}presetTitle(e){return this.title=e,this}onOpen(){super.onOpen(),this.titleEl.setText(`${this.plugin.manifest.name}: ${this.modalTitle}`),new Nc.Setting(this.contentEl).setName("Title").addText(e=>{this.title!==null&&(e.setValue(this.title),e.inputEl.select()),e.inputEl.size=30,e.inputEl.id="pdf-plus-outline-title-modal"}),new Nc.Setting(this.contentEl).addButton(e=>{e.setButtonText("Add").setCta().onClick(()=>{this.submitAndClose()})}).addButton(e=>{e.setButtonText("Cancel").onClick(()=>{this.close()})})}ask(){return this.open(),this}then(e){return this.submitted&&this.title!==null?e({title:this.title}):this.next.push(e),this}submitAndClose(){let e=this.contentEl.querySelector("#pdf-plus-outline-title-modal");e instanceof HTMLInputElement&&(this.title=e.value,this.submitted=!0,this.close())}onClose(){this.submitted&&this.title!==null&&this.next.forEach(e=>e({title:this.title}))}},hh=class extends Nc.FuzzySuggestModal{constructor(e,i){super(e.plugin.app);this.next=[];this.outlines=e,this.plugin=e.plugin,this.items=[],this.outlines.iter({enter:r=>{!i.isAncestorOf(r,!0)&&!r.is(i.parent)&&this.items.push(r)}}),this.setPlaceholder("Type an outline item title")}askDestination(){return this.open(),this}then(e){return this.next.push(e),this}getItems(){return this.items}getItemText(e){return e.name}onChooseItem(e){this.next.forEach(i=>i(e))}};var fx=require("obsidian"),zt=require("obsidian");var uh=class{constructor(t){this._rootDict=t}get root(){return this.createNode(this._rootDict)}get(t){return this.root.get(t)}iterLeaves(t){this.root.iterLeaves(t)}getLeaves(){return this.root.getLeaves()}iter(t){this.root.iter(t)}[Symbol.iterator](){return this.root[Symbol.iterator]()}keys(){return this.root.keys()}values(){return this.root.values()}limitLeafSize(t){this.root.limitLeafSize(t)}},sa=class extends uh{createNode(t){return new Up(t)}},Fr=class extends uh{createNode(t){return new zp(t)}},fh=class{constructor(t){this.dict=t}is(t){return this.dict===t.dict}isRoot(){return!this._dictHas("Limits")}isUniqueNode(){return this.isRoot()&&this._dictHas(this.leafKey)}isLeaf(){return this._dictHas("Limits")&&this._dictHas(this.leafKey)}isIntermediate(){return this._dictHas("Limits")&&this._dictHas("Kids")}get kids(){let t=this.dict.get(x.of("Kids"));return t instanceof H?t.asArray().map(e=>{let i=this.dict.context.lookup(e);if(i instanceof R)return new this.constructor(i);throw new Error("Kid is not a PDFDict")}):null}get limits(){let t=this.dict.get(x.of("Limits"));if(!(t instanceof H))return null;if(t.size()!==2)throw new Error("Limits array must have 2 elements");return t.asArray().map(e=>this._toStringOrNumber(e))}get(t){let e=this.getLeafFor(t);if(!e)return null;let i=e._getNamesOrNums();if(!i)throw new Error("Node has no names or nums despite not having kids");let r=0,o=(i.length>>1)-1;for(;r<=o;){let s=r+o>>1,a=i[s*2];if(a===t){let c=i[s*2+1];if(c instanceof fe)return c;throw new Error("Value is not a PDFObject")}a{if(t>=i.length)return{done:!0,value:[]};let o=i[t]._getNamesOrNums();if(!o)throw new Error("Leaf has no names or nums");let s=o[e],a=o[e+1];return e+=2,e>=o.length&&(t++,e=0),{done:!1,value:[s,a]}}}}keys(){return Array.from(this,([t])=>t)}values(){return Array.from(this,([,t])=>t)}size(){let t=0;return this.iterLeaves(e=>{let i=e._getNamesOrNums();if(!i)throw new Error("Leaf has no names or nums");t+=i.length>>1}),t}iterLeaves(t){let e=[this];for(;e.length;){let i=e.shift(),r=i.kids;r?e.push(...r):t(i)}}getLeaves(){let t=[];return this.iterLeaves(e=>t.push(e)),t}sortKids(){let t=this.kids;if(!t)return;t.sort((i,r)=>{let o=i.limits,s=r.limits;if(!o||!s)throw new Error("Kid has no limits");return o[0]s[0]?1:0});let e=H.withContext(this.dict.context);for(let i of t)e.push(i.dict);this.dict.set(x.of("Kids"),e)}flatten(){if(this.isUniqueNode()||this.isLeaf())return;let t=H.withContext(this.dict.context);for(let[e,i]of this)t.push(this._toPDFStringOrPDFNumber(e)),t.push(i);this.dict.set(x.of(this.leafKey),t),this.dict.delete(x.of("Kids"))}iter(t){var e,i,r;(e=t.enter)==null||e.call(t,this),(i=this.kids)==null||i.forEach(o=>o.iter(t)),(r=t.leave)==null||r.call(t,this)}limitLeafSize(t){let e=[],i=[],r=()=>{let o=this.dict.context.obj(e),s=e[0],a=e[e.length-2],c=this.dict.context.obj([s,a]),l=this.dict.context.obj({[this.leafKey]:o,Limits:c}),d=this.dict.context.register(l);i.push(d)};for(let[o,s]of this)e.push(o,s),e.length>>1>=t&&(r(),e.length=0);if(e.length&&r(),i.length===1)this.dict.set(x.of(this.leafKey),this.dict.context.obj(e)),this.dict.delete(x.of("Kids")),this.dict.delete(x.of("Limits"));else{let o=this.dict.context.obj(i);this.dict.set(x.of("Kids"),o)}}getLeafFor(t){if(this.isUniqueNode())return this;let e=this.limits;if(e&&(t{let s=o.limits;if(!s)throw new Error("Kid has no limits");return s[0]<=t&&t<=s[1]}),!i)return null;r=i.kids}return i}_dictHas(t){return this.dict.has(x.of(t))}_getNamesOrNums(){let t=this.dict.get(x.of(this.leafKey));return t instanceof H?t.asArray().map((e,i)=>i%2?e:this._toStringOrNumber(e)):null}},Up=class extends fh{get leafKey(){return"Names"}_toStringOrNumber(t){if(t instanceof G||t instanceof M)return t.decodeText();throw new Error("Key is not a PDFString or a PDFHexString")}_toPDFStringOrPDFNumber(t){return M.fromText(t)}get names(){return this._getNamesOrNums()}},zp=class extends fh{get leafKey(){return"Nums"}_toStringOrNumber(t){if(t instanceof N)return t.asNumber();throw new Error("Key is not a PDFNumber")}_toPDFStringOrPDFNumber(t){return N.of(t)}get nums(){return this._getNamesOrNums()}};var qp={D:"1, 2, 3, ...",R:"I, II, III, ...",r:"i, ii, iii, ...",A:"A, B, C, ...",a:"a, b, c, ..."};function Wp(n){return qp.hasOwnProperty(n)}var Vo=class{static fromPDFDict(t){let e=new Vo,i=t.get(x.of("St"));i instanceof N&&(e.start=i.asNumber());let r=t.get(x.of("S"));if(r instanceof x){let s=r.decodeText();Wp(s)&&(e.style=s)}let o=t.get(x.of("P"));return(o instanceof G||o instanceof M)&&(e.prefix=o.decodeText()),e}},Ft=class{constructor(t,e){this.doc=t;this.ranges=e;this.normalize()}normalize(){var t;if(this.ranges.length){this.ranges.sort((e,i)=>e.pageFrom-i.pageFrom),this.ranges[0].pageFrom=1;for(let e=this.ranges.length-1;e>=0;e--){let i=this.getStartOfRange(e),r=this.getEndOfRange(e);if(i>r){this.ranges.splice(e,1);continue}let o=this.ranges[e],s=this.ranges[e-1];if(s&&typeof o.dict.start=="number"&&o.dict.prefix===s.dict.prefix&&o.dict.style===s.dict.style&&o.pageFrom-s.pageFrom===o.dict.start-((t=s.dict.start)!=null?t:1)){this.ranges.splice(e,1);continue}}}return this}static fromDocument(t){let e=et(t.catalog,"PageLabels");if(!(e instanceof R))return null;let i=new Fr(e),r=[];for(let[o,s]of i){let a=s instanceof q?t.context.lookup(s):s;if(!(a instanceof R))return null;r.push({pageFrom:o+1,dict:Vo.fromPDFDict(a)})}return new Ft(t,r)}setToDocument(t){t||(t=this.doc);let e=[];for(let{pageFrom:r,dict:o}of this.normalize().ranges){e.push(r-1);let s={};o.style!==void 0&&(s.S=o.style),o.prefix!==void 0&&(s.P=M.fromText(o.prefix)),o.start!==void 0&&(s.St=o.start),e.push(t.context.obj(s))}let i=t.context.obj({Nums:e});new Fr(i).limitLeafSize(64),t.catalog.set(x.of("PageLabels"),i)}static removeFromDocument(t){t.catalog.delete(x.of("PageLabels"))}static processDocument(t,e){let i=Ft.fromDocument(t);return i?(e(i),i.setToDocument(),!0):!1}static createEmpty(t){return new Ft(t,[{pageFrom:1,dict:new Vo}])}removeRange(t){return this.ranges.splice(t,1),this.normalize(),this}divideRangeAtPage(t,e,i){var a;let r=this.getRangeIndexAtPage(t);if(r===-1)return this;if(t===this.getStartOfRange(r))return this;let o=this.ranges[r],s=new Vo;return s.prefix=o.dict.prefix,s.style=o.dict.style,e&&(s.start=t-o.pageFrom+((a=o.dict.start)!=null?a:1)),i==null||i(s),this.ranges.splice(r+1,0,{pageFrom:t,dict:s}),this}shiftRangesAfterPage(t,e){for(let i of this.ranges)i.pageFrom>=t&&(i.pageFrom+=e);return this}getStartOfRange(t){return this.ranges[t].pageFrom}getEndOfRange(t){let e=this.ranges[t+1];return e?e.pageFrom-1:this.doc.getPageCount()}getRangeIndexAtPage(t){for(let e=0;e(this.doc=await e.lib.loadPdfLibDocument(i),this.pageLabels=Ft.fromDocument(this.doc),{doc:this.doc,pageLabels:this.pageLabels}))(),this.scope.register([],"Enter",()=>this.redisplay())}},Kp=class{constructor(t,e){this.dict=t;this.containerEl=e;this.addNumberingStyleSetting(),this.addStartSetting(),this.addPrefixSetting()}addSetting(){return new zt.Setting(this.containerEl)}addNumberingStyleSetting(){this.addSetting().setName("Numbering Style").addDropdown(t=>{var e;t.addOptions({...qp,None:"None"}).setValue((e=this.dict.style)!=null?e:"None").onChange(i=>{Wp(i)?this.dict.style=i:delete this.dict.style})})}addStartSetting(){this.addSetting().setName("Start counting from").addText(t=>{t.inputEl.type="number",this.dict.start!==void 0?t.setValue(""+this.dict.start):t.setPlaceholder("1"),t.onChange(e=>{let i=Number(e);Number.isInteger(i)?(t.inputEl.removeClass("error"),i>1?this.dict.start=i:delete this.dict.start):(delete this.dict.start,t.inputEl.addClass("error"))})})}addPrefixSetting(){return this.addSetting().setName("Prefix").addText(t=>{var e;t.setValue((e=this.dict.prefix)!=null?e:"").onChange(i=>{i?this.dict.prefix=i:delete this.dict.prefix})})}},ph=class extends jp{constructor(){super(...arguments);this.buttonSetting=null}async onOpen(){super.onOpen(),this.titleEl.setText(`${this.plugin.manifest.name}: edit page labels`),new zt.Setting(this.contentEl).then(e=>{zt.MarkdownRenderer.render(this.app,["Each page in a PDF document can be assigned a ***page label***, which can be different from the page index.",'For example, a book might have a preface numbered as "i", "ii", "iii", ... and the main content numbered as "1", "2", "3", ...'].join(" "),e.descEl,"",this.component)}).then(e=>this.contentEl.prepend(e.settingEl)),this.controlEl.createDiv({cls:"page-labels-loading",text:"Loading..."}),await this.docLoadingPromise,this.display(),this.addButtons()}redisplay(){this.display()}display(){let{pageLabels:e,doc:i}=this;if(!i)return;if(this.controlEl.empty(),e===null||e.rangeCount()===0){this.addHeading(this.controlEl,"No page labels found","lucide-info").setDesc("This PDF document does not have any page labels.").addButton(o=>{o.setButtonText("Create").setCta().onClick(()=>{this.pageLabels=Ft.createEmpty(i),this.redisplay(),this.updateButtonVisibility()})}).addButton(o=>{o.setButtonText("Cancel").onClick(()=>this.close())});return}let r=i.getPageCount();for(let o=0;o{h>a.pageFrom&&u.addExtraButton(f=>{f.setIcon("lucide-separator-horizontal").setTooltip("Divide this labeling range").onClick(()=>{e.divideRangeAtPage(a.pageFrom+1,!1),this.redisplay()})})}).addExtraButton(u=>{u.setIcon("lucide-x").setTooltip("Label the pages in this range continuing from the previous range").onClick(()=>{e.removeRange(o),this.redisplay()})}),new zt.Setting(s).setName("From").setDesc("The index of the first page in this range.").then(u=>u.controlEl.appendText("Page")).addText(u=>{u.inputEl.type="number",u.setValue(""+a.pageFrom).onChange(f=>{let p=Number(f);Number.isInteger(p)&&(c?c.pageFrom:1)this.redisplay(),{once:!0})}).then(u=>this.addPreviewButton(u,a.pageFrom)),new zt.Setting(s).setName("To").setDesc("The index of the last page in this range.").then(u=>u.controlEl.appendText("Page")).addText(u=>{u.inputEl.type="number",u.setValue(""+h).onChange(f=>{let p=Number(f);Number.isInteger(p)&&a.pageFrom<=p&&p<=(d?d.pageFrom-1:r-1)?(l.pageFrom=p+1,u.inputEl.removeClass("error")):u.inputEl.addClass("error")}).setDisabled(o===e.ranges.length-1).then(f=>{f.disabled&&(0,fx.setTooltip)(f.inputEl,"The last range cannot be extended.")}),u.inputEl.addEventListener("blur",()=>this.redisplay(),{once:!0})}).then(u=>this.addPreviewButton(u,h)),new Kp(a.dict,s)}}addHeading(e,i,r){return new zt.Setting(e).setName(i).setHeading().then(o=>{let s=createDiv();o.settingEl.prepend(s),(0,zt.setIcon)(s,r)})}addPreviewButton(e,i){return e.addExtraButton(r=>{r.setIcon("lucide-message-square").setTooltip(`Hover${this.plugin.requireModKeyForLinkHover()?"+"+In("Mod").toLowerCase():""} to preview`).then(o=>{this.component.registerDomEvent(o.extraSettingsEl,"mouseover",s=>{this.app.workspace.trigger("hover-link",{event:s,source:"pdf-plus",linktext:this.file.path+`#page=${i}`,targetEl:o.extraSettingsEl,hoverParent:this.component})})})})}addButtons(){var e;return(e=this.buttonSetting)!=null?e:new zt.Setting(this.contentEl).addButton(i=>{i.setButtonText("Save").setCta().onClick(async()=>{this.pageLabels&&this.doc?(this.pageLabels.rangeCount()>0?this.pageLabels.setToDocument(this.doc):Ft.removeFromDocument(this.doc),await this.app.vault.modifyBinary(this.file,await this.doc.save())):new zt.Notice(`${this.plugin.manifest.name}: Something went wrong.`),this.close()})}).addButton(i=>{i.setButtonText("Cancel").onClick(()=>this.close())}).then(i=>{this.buttonSetting=i,this.updateButtonVisibility()})}updateButtonVisibility(){this.buttonSetting&&(this.pageLabels&&this.pageLabels.rangeCount()>0?this.buttonSetting.settingEl.show():this.buttonSetting.settingEl.hide())}};var ot=require("obsidian");var Pr=class extends rt{constructor(...e){super(...e);this.source=null;this.urls=[];this.folderPath=null;this.filePath=null;this.scope.register([],"Enter",()=>{var i;((i=activeDocument.activeElement)==null?void 0:i.tagName)==="INPUT"&&this.submit()})}onOpen(){super.onOpen(),this.titleEl.setText(`${this.plugin.manifest.name}: Create dummy file for external PDF`),this.modalEl.createDiv("",e=>{new ot.Setting(e).setDesc(createFragment(i=>{i.createEl("a",{text:"Learn more",href:"https://ryotaushio.github.io/obsidian-pdf-plus/external-pdf-files"})})),setTimeout(()=>{this.modalEl.insertBefore(e,this.contentEl)})}),this.display()}display(){ot.Platform.isDesktopApp?this.displayDesktop():this.displayMobile()}displayDesktop(){this.contentEl.empty(),this.addSourceLocationSetting(),this.source==="file"?this.addLocalFileSetting():this.source==="web"&&this.addWebFileSetting(),this.source&&this.addButtons()}displayMobile(){this.source="web",this.contentEl.empty(),this.addWebFileSetting(),this.addButtons()}addSetting(){return new ot.Setting(this.contentEl)}addSourceLocationSetting(){this.addSetting().setName("Source location").setDesc("Where the external PDF is located.").addDropdown(e=>{var i;e.addOptions({file:"On this computer",web:"Web"}).setValue((i=this.source)!=null?i:"").onChange(r=>{this.source=r,this.display()}),e.selectEl.tabIndex=this.source?-1:0})}addLocalFileSetting(){this.addSetting().setName("Folder to save the dummy files").addText(e=>{var i;e.inputEl.size=30,e.setValue((i=this.folderPath)!=null?i:""),new mr(this.app,e.inputEl).onSelect(({item:r})=>{this.folderPath=r.path})}),this.addSetting().setName("Absolute path to the PDF").setDesc('Type the path in the input box or click the "Browse" button to select the file.').addButton(e=>{e.setButtonText("Browse").setCta().onClick(()=>{var r;let i=(r=window.electron)==null?void 0:r.remote.dialog.showOpenDialogSync({properties:["openFile","multiSelections","dontAddToRecent"],filters:[{name:"PDF files",extensions:["pdf"]}]});i&&i.length>0&&(this.urls=i.map(o=>(o=o.replace(/\\/g,"/").replace(/ /g,"%20"),"file://"+(o.startsWith("/")?"":"/")+o)),this.display())})}).addExtraButton(e=>{e.setIcon("plus").setTooltip("Add another file").onClick(()=>{this.urls.push(""),this.display()})}),this.urls.length||this.urls.push("");for(let e=0;ei.settingEl.addClass("no-border")).addText(i=>{i.inputEl.size=30,i.setValue(this.urls[e]?this.urls[e].replace(/^file:\/\//,""):"").onChange(r=>{this.urls[e]="file://"+r})}).addExtraButton(i=>{i.setIcon("trash").setTooltip("Remove this file").onClick(()=>{this.urls.splice(e,1),this.display()}),this.urls.length===1&&i.extraSettingsEl.hide()})}addWebFileSetting(){this.addSetting().setName("Dummy file path").setDesc('Must end with ".pdf".').addText(e=>{var i;e.inputEl.size=30,e.setPlaceholder("e.g. Folder/File.pdf").setValue((i=this.filePath)!=null?i:""),new mr(this.app,e.inputEl,{blurOnSelect:!1}).onSelect(({item:r})=>{setTimeout(()=>{let o=(0,ot.normalizePath)(r.path+"/Untitled.pdf");e.setValue(o),this.filePath=o,e.inputEl.setSelectionRange(o.lastIndexOf("/")+1,o.lastIndexOf("."))})}),e.onChange(r=>{!r||r.endsWith(".pdf")?(this.filePath=r,e.inputEl.removeClass("error")):(this.filePath=null,e.inputEl.addClass("error"))})}),this.addSetting().setName("URL of the PDF").setDesc('Must start with "https://" or "http://".').addText(e=>{e.inputEl.size=30,this.urls.length&&e.setValue(this.urls[0]),e.onChange(i=>{!i||i.startsWith("https://")||i.startsWith("http://")?(this.urls=[i],e.inputEl.removeClass("error")):(this.urls=[],e.inputEl.addClass("error"))})})}addButtons(){this.contentEl.createDiv("modal-button-container",e=>{e.createEl("button",{text:"Create",cls:"mod-cta"},i=>{i.addEventListener("click",()=>{this.submit()})}),e.createEl("button",{text:"Cancel"},i=>{i.addEventListener("click",()=>{this.close()})})})}submit(){if(this.urls=this.urls.filter(e=>e),!this.urls.length){new ot.Notice(`${this.plugin.manifest.name}: The external PDF location is not specified.`);return}if(this.source==="file"&&!this.folderPath){new ot.Notice(`${this.plugin.manifest.name}: The folder to save the dummy files is not specified.`);return}if(this.source==="web"&&!this.filePath){new ot.Notice(`${this.plugin.manifest.name}: The dummy file path is not specified.`);return}this.createDummyFiles(),this.close()}async createDummyFiles(){var s;let e=[],i=[],r=async(a,c)=>{let l=(0,ot.normalizePath)(c.split("/").slice(0,-1).join("/"));l&&(this.app.vault.getAbstractFileByPath(l)||await this.app.vault.createFolder(l));let d=this.app.vault.getAvailablePath(c.slice(0,-4),"pdf");return await this.app.vault.create(d,a)};if(this.source==="file"&&this.folderPath)for(let a of this.urls){let c=(0,ot.normalizePath)(this.folderPath+"/"+((s=a.split("/").pop())==null?void 0:s.replace(/%20/g," ")));if(!c.endsWith(".pdf")){e.push(a);continue}i.push(r(a,c).catch(l=>(e.push(a),console.error(l),null)))}else if(this.source==="web"&&this.filePath&&this.urls.length){let a=(0,ot.normalizePath)(this.filePath);a.endsWith(".pdf")?i.push(r(this.urls[0],a).catch(c=>(e=this.urls,console.error(c),null))):e=this.urls}else e=this.urls;let o=await Promise.all(i);e.length?new ot.Notice(`${this.plugin.manifest.name}: Failed to create dummy files for the following URLs: ${e.join(", ")}`):new ot.Notice(`${this.plugin.manifest.name}: Dummy files created successfully.`);for(let a of o)a&&await this.app.workspace.getLeaf(!0).openFile(a)}static async createDummyFilesFromObsidianUrl(e,i){let r=i["create-dummy"].replace(/^.*((https?)|(file):\/\/)/,"$1"),o=new Pr(e);if(o.source=r.startsWith("http")?"web":"file",o.urls=[r],"folder"in i){let s=i.folder;o.source==="web"?o.filePath=(0,ot.normalizePath)(s+"/Untitled.pdf"):o.folderPath=(0,ot.normalizePath)(s),await o.createDummyFiles();let a=e.lib.workspace.getActivePDFView();a&&a.setEphemeralState({rename:"all"});return}o.open()}};var Gp=require("obsidian");var kr=class extends rt{static openIfNecessary(t){let e=Ap();e&&Ep(e,t.manifest.minAppVersion)&&new kr(t).open()}onOpen(){super.onOpen();let t=this.plugin.manifest.name;this.setTitle(`${t}: Outdated Obsidian installer`),this.contentEl.appendText(`Your Obsidian installer is outdated and likely to be incompatible with the latest ${t}. Please download the latest installer from Obsidian's website and re-install the Obsidian app.`),this.contentEl.createDiv("modal-button-container",e=>{new Gp.ButtonComponent(e).setButtonText("Get installer from https://obsidian.md").setCta().onClick(()=>{window.open("https://obsidian.md/download","_blank")}),new Gp.ButtonComponent(e).setButtonText('What is "installer version"?').onClick(()=>{window.open("https://help.obsidian.md/Getting+started/Update+Obsidian#Installer%20updates","_blank")})})}};var Te=require("obsidian");var px=require("obsidian");var Rn=class{constructor(){this.tree=null;this.dict=null}static fromDocument(t){if(t.catalog.has(x.of("Dests"))){let i=et(t.catalog,"Dests");if(i instanceof R){let r=new Rn;return r.dict=i,r}}let e=et(t.catalog,"Names");if(e instanceof R){let i=et(e,"Dests");if(i instanceof R){let r=new Rn;return r.tree=new sa(i),r}}return null}getExplicitDest(t){var i,r;let e=null;if(this.dict){let o=et(this.dict,t);e=(i=o instanceof q?this.dict.context.lookup(o):o)!=null?i:null}else if(this.tree){let o=this.tree.get(t);e=(r=o instanceof q?this.tree._rootDict.context.lookup(o):o)!=null?r:null}if(e instanceof H)return e;if(e instanceof R){let o=e.get(x.of("D"));if(o instanceof H)return o}return null}};var Ce=class{constructor(t,e){this.plugin=t,this.doc=e,this.namedDests=Rn.fromDocument(e)}static async fromDocument(t,e){return new Ce(e,t)}static async fromFile(t,e){let{lib:i}=e,r=await i.loadPdfLibDocument(t);return new Ce(e,r)}get lib(){return this.plugin.lib}get root(){let t=et(this.doc.catalog,"Outlines");return t instanceof R?new Dr(this,t):null}set root(t){if(t){let e=this.doc.context.getObjectRef(t.dict);e||(e=this.doc.context.register(t.dict)),this.doc.catalog.set(x.of("Outlines"),e);return}this.doc.catalog.delete(x.of("Outlines"))}ensureRoot(){if(!this.root){let t=this.doc.context.obj({Type:"Outlines"});this.doc.context.register(t),this.root=new Dr(this,t)}return this.root}getLeaves(){let t=[],e=i=>{i.firstChild&&e(i.firstChild),i.nextSibling&&e(i.nextSibling),i.firstChild||t.push(i)};return this.root&&e(this.root),t}iter(t){let e=i=>{var r,o;(r=t.enter)==null||r.call(t,i),i.iterChildren(e),(o=t.leave)==null||o.call(t,i)};this.root&&e(this.root)}async iterAsync(t){let e=async i=>{var r,o;await((r=t.enter)==null?void 0:r.call(t,i)),await i.iterChildrenAsync(e),await((o=t.leave)==null?void 0:o.call(t,i))};this.root&&await e(this.root)}async prune(){await this.iterAsync({leave:async t=>{await t.destNotExistInDoc()&&(t.removeAndLiftUpChildren(),t.updateCountForAllAncestors())}})}stringify(){let t="";return this.iter({enter:e=>{e.isRoot()||(t=t+" ".repeat(e.depth-1)+"- "+e.title+` `)}}),t}async findPDFjsOutlineTreeNode(t){let e=null;return await this.iterAsync({enter:async i=>{if(!(e||i.isRoot())&&t.item.title===i.title){let r=t.item.dest,o=i.getNormalizedDestination();if(typeof r=="string")typeof o=="string"&&r===o&&(e=i);else{let s=await t.getPageNumber();JSON.stringify(this.lib.normalizePDFJsDestArray(r,s))===JSON.stringify(o)&&(e=i)}}}}),e}static async processOutlineRoot(t,e,i){let{app:r}=i,o=await Ce.fromFile(e,i);t(o.ensureRoot());let s=await o.doc.save();await r.vault.modifyBinary(e,s)}static async findAndProcessOutlineItem(t,e,i,r){let{app:o}=r,s=await Ce.fromFile(i,r),a=await s.findPDFjsOutlineTreeNode(t);if(!a){new px.Notice(`${r.manifest.name}: Failed to process the outline item.`);return}e(a);let c=await s.doc.save();await o.vault.modifyBinary(i,c)}},Dr=class{constructor(t,e){this.outlines=t,this.dict=e}get doc(){return this.outlines.doc}get lib(){return this.outlines.plugin.lib}is(t){return t!==null&&this.dict===t.dict}_get(t){let e=et(this.dict,t);return e instanceof R?new Dr(this.outlines,e):null}_setOrDelete(t,e){if(e){let i=this.doc.context.getObjectRef(e.dict);i||(i=this.doc.context.register(e.dict)),this.dict.set(x.of(t),i);return}this.dict.delete(x.of(t))}get firstChild(){return this._get("First")}set firstChild(t){if(t&&!this.is(t.parent))throw new Error(`Item "${t.name}" is not a child of this item "${this.name}"`);this._setOrDelete("First",t)}get lastChild(){return this._get("Last")}set lastChild(t){if(t&&!this.is(t.parent))throw new Error(`Item "${t.name}" is not a child of this item "${this.name}"`);this._setOrDelete("Last",t)}get nextSibling(){return this._get("Next")}set nextSibling(t){if(t&&!(t.parent&&t.parent.is(this.parent)))throw new Error(`Item "${t.name}" is not a sibling of this item "${this.name}"`);this._setOrDelete("Next",t)}get prevSibling(){return this._get("Prev")}set prevSibling(t){if(t&&!(t.parent&&t.parent.is(this.parent)))throw new Error(`Item "${t.name}" is not a sibling of this item "${this.name}"`);this._setOrDelete("Prev",t)}get parent(){return this._get("Parent")}set parent(t){if(t&&this.isRoot())throw new Error("Cannot set parent of the root of outline");this._setOrDelete("Parent",t)}get count(){let t=et(this.dict,"Count");return t instanceof N?t.asNumber():null}set count(t){if(t===null){this.dict.delete(x.of("Count"));return}this.dict.set(x.of("Count"),N.of(t))}get title(){if(this.isRoot())throw new Error("Root of outline does not have a title");let t=et(this.dict,"Title");if(t instanceof G||t instanceof M)return t.decodeText();throw new Error("Title is not a string")}set title(t){if(this.isRoot())throw new Error("Cannot set title of the root of outline");this.dict.set(x.of("Title"),M.fromText(t))}get name(){if(this.isRoot())return"(Root)";let t=this.title;return this.iterAncestors(e=>{e.isRoot()||(t=`${e.title}/${t}`)}),t}get depth(){let t=0;return this.iterAncestors(()=>t++),t}isLeaf(){return!this.firstChild}isRoot(){return this.parent===null}createChild(t,e){let i;if(typeof e=="string")i=M.fromText(e);else{i=H.withContext(this.doc.context),i.push(this.doc.getPage(e[0]).ref),i.push(x.of(e[1]));for(let s of e.slice(2))i.push(typeof s=="number"?N.of(s):Me)}let r=this.doc.context.getObjectRef(this.dict);if(!r)throw new Error("Could not get ref for parent");let o={Title:M.fromText(t),Dest:i,Parent:r};if(this.lastChild){Object.assign(o,{Prev:this.doc.context.getObjectRef(this.lastChild.dict)});let s=new Dr(this.outlines,this.doc.context.obj(o));this.lastChild.nextSibling=s,this.lastChild=s}else{let s=new Dr(this.outlines,this.doc.context.obj(o));this.firstChild=s,this.lastChild=s}return this.lastChild}appendChild(t){if(t.isAncestorOf(this,!0))throw new Error("Cannot append an ancestor as a child");t.remove(),t.updateCountForAllAncestors(),t.parent=this,this.lastChild?(this.lastChild.nextSibling=t,t.prevSibling=this.lastChild,this.lastChild=t):(this.firstChild=t,this.lastChild=t,t.prevSibling=null),t.nextSibling=null,t.updateCountForAllAncestors()}remove(){return this.prevSibling&&(this.prevSibling.nextSibling=this.nextSibling),this.nextSibling&&(this.nextSibling.prevSibling=this.prevSibling),this.parent&&(this.is(this.parent.firstChild)&&(this.parent.firstChild=this.nextSibling),this.is(this.parent.lastChild)&&(this.parent.lastChild=this.prevSibling)),this}removeAndLiftUpChildren(){if(this.remove(),this.firstChild){if(!this.lastChild)throw new Error("Last child is not set despite having children");this.iterChildren(t=>{t.parent=this.parent}),this.prevSibling?(this.prevSibling.nextSibling=this.firstChild,this.firstChild.prevSibling=this.prevSibling):this.parent&&(this.parent.firstChild=this.firstChild,this.firstChild.prevSibling=null),this.nextSibling?(this.nextSibling.prevSibling=this.lastChild,this.lastChild.nextSibling=this.nextSibling):this.parent&&(this.parent.lastChild=this.lastChild,this.lastChild.nextSibling=null)}}iterChildren(t){let e=this.firstChild;for(;e;)t(e),e=e.nextSibling}async iterChildrenAsync(t){let e=this.firstChild;for(;e;)await t(e),e=e.nextSibling}iterAncestors(t,e=!1){e&&t(this);let i=this.parent;for(;i;)t(i),i=i.parent;return this}isAncestorOf(t,e=!1){let i=!1;return t.iterAncestors(r=>{this.is(r)&&(i=!0)},e),i}async sortChildren(){let t=[];await this.iterChildrenAsync(async r=>{let o=r.getExplicitDestination();if(o===null)return 0;let s=o[0],a=o[1]==="XYZ"?o[3]:o[1]==="FitBH"||o[1]==="FitH"?o[2]:void 0;t.push({child:r,page:s,top:a!=null?a:void 0})}),t.sort((r,o)=>{var s,a;return r.page-o.page||((s=r.top)!=null?s:0)-((a=o.top)!=null?a:0)});let e=null,i=t.first();i&&(i.child.prevSibling=null,this.firstChild=i.child);for(let{child:r}of t)e&&(e.nextSibling=r,r.prevSibling=e),e=r;e&&(e.nextSibling=null,this.lastChild=e)}async destNotExistInDoc(){var r,o,s;if(this.isRoot())return!1;let t=this.getDestination(),e=null;if(t instanceof G||t instanceof M){let a=t.decodeText();e=(o=(r=this.outlines.namedDests)==null?void 0:r.getExplicitDest(a))!=null?o:null}else t instanceof H&&(e=t);if(!e)return!0;let i=e.get(0);if(i instanceof q){let a=this.doc.context.lookup(i);if(a instanceof tt)return!((s=a.Parent())!=null&&s.Kids().asArray().includes(i))}throw new Error("The first element of a destination array must be a refernece of a page leaf node.")}countVisibleDescendants(){let t=0;return this.iterChildren(()=>t++),this.iterChildren(e=>{typeof e.count=="number"&&e.count>0&&(t+=e.countVisibleDescendants())}),t}updateCount(t){let e=this.countVisibleDescendants();if(this.isRoot()&&!t)throw new Error("Cannot close the root outline");this.count=t?e:-e}updateCountForAllAncestors(t=!1){return this.iterAncestors(e=>e.updateCount(e.isRoot()),t)}getDestination(){let t=et(this.dict,"Dest");if(t)return t;let e=et(this.dict,"A");if(e instanceof R){let i=et(e,"S");if(i instanceof x&&i.decodeText()==="GoTo"){let r=et(e,"D");return r!=null?r:null}}return null}getNormalizedDestination(){let t=this.getDestination();return t instanceof G||t instanceof M?t.decodeText():t instanceof H?this.lib.normalizePdfLibDestArray(t,this.doc):null}getExplicitDestination(){var e,i;let t=this.getNormalizedDestination();if(typeof t=="string"){let r=(i=(e=this.outlines.namedDests)==null?void 0:e.getExplicitDest(t))!=null?i:null;return r?this.lib.normalizePdfLibDestArray(r,this.doc):null}return t}};var Sr=require("obsidian");function gx(n,t,e){let i=(r,o)=>{if(o>=t.length)return;e.clickableParentItem&&r.setUseNativeMenu(!1);let s=new Set(r.items);t[o](r);let a=r.items.filter(c=>!s.has(c));if(o!=t.length-1){for(let c of a)if(c instanceof Sr.MenuItem){let l=c.callback,d=c.setSubmenu();if(e.vim){Zp(d);let h=d.scope.keys.find(u=>u.key==="Escape"&&u.modifiers==="");h&&(d.scope.unregister(h),d.scope.register([],"Escape",n.hide.bind(n)))}i(d,o+1),e.clickableParentItem&&c.onClick(l)}}};i(n,0)}function mx(n){let t=[],e=[],i=n;for(;i&&i.selected>=0;){e.push(i.selected);let r=i.items[i.selected];r instanceof Sr.MenuItem&&t.push(r),i=r instanceof Sr.MenuItem?r.submenu:null}return{items:t,indices:e}}function Xp(n,t){n.openSubmenu=function(e){return this.parentMenu&&this.closeSubmenu(),Sr.Menu.prototype.openSubmenu.call(this,e)},n.openSubmenuSoon=(0,Sr.debounce)(n.openSubmenu.bind(n),t!=null?t:250,!0)}function Zp(n){n.scope.register([],"j",n.onArrowDown.bind(n)),n.scope.register([],"k",n.onArrowUp.bind(n)),n.scope.register([],"h",n.onArrowLeft.bind(n)),n.scope.register([],"l",n.onArrowRight.bind(n))}var se=require("obsidian");var tg=require("obsidian");var xx=require("obsidian");var pt=require("obsidian");var bx=require("obsidian"),de=class extends bx.Component{constructor(e){super();this.plugin=e}get app(){return this.plugin.app}get lib(){return this.plugin.lib}get settings(){return this.plugin.settings}};var Qp=class extends de{constructor(e,i){super(e);this.child=i,this.destIdToBibText=new Map,this.destIdToParsedBib=new Map,this.events=new pt.Events,this.initialized=!1,this.init()}isEnabled(){let e=this.child.pdfViewer;return this.settings.actionOnCitationHover!=="none"&&(On(e)||this.settings.enableBibInCanvas&&ia(e)||this.settings.enableBibInHoverPopover&&na(e)||this.settings.enableBibInEmbed&&Ec(e))}async init(){this.isEnabled()&&(await this.extractBibText(),await this.parseBibText()),this.initialized=!0}async extractBibText(){return new Promise(e=>{this.lib.onDocumentReady(this.child.pdfViewer,i=>{new Yp(i).onExtracted((r,o)=>{this.destIdToBibText.set(r,o),this.events.trigger("extracted",r,o)}).extract().then(e)})})}async parseBibText(){let e=Array.from(this.destIdToBibText.values()).join(` `),i=await this.parseBibliographyText(e);if(i){let r=Array.from(this.destIdToBibText.keys());for(let o=0;o{let a=new pt.HoverPopover(i,o,200);a.hoverEl.addClass("pdf-plus-bib-popover");let c=a.hoverEl.createDiv();a.addChild(new Jp(this,e,c))};this.plugin.requireModKeyForLinkHover(Qp.HOVER_LINK_SOURCE_ID)?wp(r,o,s):s()}getGoogleScholarSearchUrlFromDest(e){var o;let i="",r=this.destIdToParsedBib.get(e);if(r){let{author:s,title:a,year:c,"container-title":l}=r;a&&(i+=`${a[0]}`),s&&(i+=" "+s.map(d=>d.family).join(" ")),c&&(i+=` ${c}`),l&&(i+=` ${l[0]}`)}else i=(o=this.destIdToBibText.get(e))!=null?o:"";return i?`https://scholar.google.com/scholar?hl=en&as_sdt=0%2C5&q=${encodeURIComponent(i)}`:null}async parseBibliographyText(e){let{app:i,plugin:r,settings:o}=this,s=o.anystylePath;if(!s)return null;let a=r.getAnyStyleInputDir();if(pt.Platform.isDesktopApp&&i.vault.adapter instanceof pt.FileSystemAdapter&&a){let c=i.vault.adapter.getFullPath(a);await pt.FileSystemAdapter.mkdir(c);let l=a+`/${Pp()}.txt`,d=i.vault.adapter.getFullPath(l);await i.vault.adapter.write(l,e),this.register(()=>i.vault.adapter.remove(l));let{spawn:h}=require("child_process");return new Promise(u=>{let f=h(s,["parse",d]),p="";f.stdout.on("data",g=>{if(g){p+=g.toString();return}u(null)}),f.on("error",g=>{if("code"in g&&g.code==="ENOENT"){let m=`${r.manifest.name}: AnyStyle not found at the path "${s}".`;if(r.settings.anystylePath){let b=new pt.Notice(m,8e3);b.noticeEl.appendText(" Click "),b.noticeEl.createEl("a",{text:"here"},w=>{w.addEventListener("click",()=>{r.openSettingTab().scrollTo("anystylePath")})}),b.noticeEl.appendText(" to update the path."),console.error(m)}else console.warn(m);return u(null)}}),f.on("close",g=>{var b;if(g)return u(null);let m=JSON.parse(p);if(Array.isArray(m)){for(let w of m)for(let F of(b=w.date)!=null?b:[]){let v=F.match(/\d{4}/);if(v){w.year=v[0];break}}u(m)}u(null)})})}return null}on(e,i,r){return this.events.on(e,i,r)}},Ci=Qp;Ci.HOVER_LINK_SOURCE_ID="pdf-plus-citation-link";var Yp=class{constructor(t){this.doc=t,this.pageRefToTextContentItemsPromise={}}onExtracted(t){return this.onExtractedCallback=t,this}async extract(){let t=await this.doc.getDestinations(),e=[];for(let i in t)if(i.startsWith("cite.")){let r=t[i];e.push(this.extractBibTextForDest(r).then(o=>{var s;if(o){let a=o.text;(s=this.onExtractedCallback)==null||s.call(this,i,a)}}))}await Promise.all(e)}async getTextContentItemsFromPageRef(t){var i;let e=JSON.stringify(t);return(i=this.pageRefToTextContentItemsPromise[e])!=null?i:this.pageRefToTextContentItemsPromise[e]=(async()=>{let r=await this.doc.getPageIndex(t)+1;return(await(await this.doc.getPage(r)).getTextContent()).items})()}async extractBibTextForDest(t){let e=t[0],i=await this.getTextContentItemsFromPageRef(e),r=-1;if(t[1].name==="XYZ"){let d=t[2],h=t[3];if(d===null||h===null)return null;r=i.findIndex(u=>{if(!u.str)return!1;let f=u.transform[4],p=u.transform[5]+(u.height||u.transform[0])*.8;return d<=f&&p<=h})}else if(t[1].name==="FitBH"){let d=t[2];if(d===null)return null;r=i.findIndex(h=>h.str?h.transform[5]+(h.height||h.transform[0])*.8<=d:!1)}if(r===-1)return null;let o=i[r],s=o.transform[4],a=i[r].str,c=r+1,l=[o];for(;;){let d=i[c];if(!d||d.transform[4]<=s+Math.max(d.height,8)*.1)break;d.str.trimStart().startsWith(".")||d.str.trimStart().startsWith(",")?a=a.trimEnd()+d.str.trimStart():a+=` `+d.str,l.push(d),c++}return a=a.trimStart().replace(/^\[\d+\]/,""),a=a.trimStart().replace(/^\(\d+\)/,""),a=a.trimStart().replace(/^\d+\./,""),{text:Ic(a),items:l}}},Jp=class extends de{constructor(e,i,r){super(e.plugin);this.bib=e,this.destId=i,this.containerEl=r,this.containerEl.addClass("pdf-plus-bib")}get child(){return this.bib.child}renderParsedBib(e){let{author:i,title:r,year:o,"container-title":s}=e;return i?(this.containerEl.createDiv("",a=>{a.createDiv("bib-title",c=>{var l;c.setText((l=r==null?void 0:r[0])!=null?l:"No title")}),a.createDiv("bib-author-year",c=>{let l=i.map(d=>{let h="";return d.given&&(h+=d.given),d.family&&(h+=" "+d.family),h}).filter(d=>d).join(", ");c.appendText(l),o&&c.appendText(` (${o})`)}),s&&a.createDiv("bib-container-title",c=>{c.setText(s[0])})}),!0):!1}async onload(){await this.render()}async render(){this.containerEl.empty();let e=!1,i=this.bib.destIdToParsedBib.get(this.destId);if(i&&(e=this.renderParsedBib(i)),!e){let r=this.bib.destIdToBibText.get(this.destId);r?(this.containerEl.createDiv({text:r}),pt.Platform.isDesktopApp&&this.settings.anystylePath&&this.registerRenderOn("parsed")):this.bib.initialized?this.containerEl.createDiv({text:"No bibliography found"}):(this.containerEl.createDiv({text:"Loading..."}),this.registerRenderOn("extracted"))}this.containerEl.createDiv("button-container",r=>{new pt.ButtonComponent(r).setButtonText("Google Scholar").onClick(()=>{let o=this.bib.getGoogleScholarSearchUrlFromDest(this.destId);if(!o){new pt.Notice(`${this.plugin.manifest.name}: ${this.bib.initialized?"No bibliography found":"Still loading the bibliography information. Please try again later."}`);return}window.open(o)}),new pt.ExtraButtonComponent(r).setIcon("lucide-settings").setTooltip("Customize...").onClick(()=>{this.plugin.openSettingTab().scrollToHeading("citation")})})}registerRenderOn(e){let i=this.bib.on(e,r=>{r===this.destId&&(this.render(),this.bib.events.offref(i))});this.registerEvent(i)}onunload(){this.containerEl.empty()}};var gh=class{get hoverPopover(){return this.child.hoverPopover}set hoverPopover(t){this.child.hoverPopover=t,t&&this.onHoverPopoverSet(t)}onHoverPopoverSet(t){}constructor(t,e,i){this.plugin=t,this.app=t.app,this.lib=t.lib,this.child=e,this.targetEl=i,this.useModifierKey()&&this.registerClickToOpenInNewLeaf(),this.shouldShowHoverPopover()&&this.registerHover(),this.shouldRecordHistory()&&this.registerClickToRecordHistory()}get hoverLinkSourceId(){return this.constructor.HOVER_LINK_SOURCE_ID}get file(){return this.child.file}get sourcePath(){var t,e;return(e=(t=this.file)==null?void 0:t.path)!=null?e:""}registerClickToOpenInNewLeaf(){let{app:t,plugin:e,targetEl:i}=this;e.registerDomEvent(i,"click",async r=>{if(r.defaultPrevented)return;let o=xx.Keymap.isModEvent(r);if(!o)return;r.preventDefault(),r.stopPropagation();let s=await this.getLinkText(r);s!==null&&t.workspace.openLinkText(s,this.sourcePath,o)},{capture:!0})}async customHover(t){return!1}registerHover(){let{app:t,plugin:e,targetEl:i}=this;e.registerDomEvent(i,"mouseover",async r=>{if(await this.customHover(r))return;let o=null;try{o=await this.getLinkText(r)}catch(s){if(s.name==="UnknownErrorException")return console.warn(`${this.plugin.manifest.name}: The destination was not found in this document.`);throw s}o!==null&&t.workspace.trigger("hover-link",{event:r,source:this.hoverLinkSourceId,hoverParent:this,targetEl:i,linktext:o,sourcePath:this.sourcePath})})}registerClickToRecordHistory(){let{plugin:t,targetEl:e}=this;t.registerDomEvent(e,"click",i=>{this.recordLeafHistory()},{capture:!0})}recordLeafHistory(){this.lib.workspace.iteratePDFViews(t=>{if(t.containerEl.contains(this.targetEl)){let e=t.leaf;e.recordHistory(e.getHistoryState())}})}},mh=class extends gh{async getLinkText(t){var c,l,d;let{lib:e,child:i,targetEl:r}=this;if(!fi(t,r))return null;let o=(c=i.pdfViewer.pdfViewer)==null?void 0:c.pdfDocument;if(!o)return null;let s=this.getDest(),a=null;return typeof s=="string"?a=await e.destIdToSubpath(s,o):a=await e.pdfJsDestArrayToSubpath(s,o),a===null?null:((d=(l=this.file)==null?void 0:l.path)!=null?d:"")+a}onHoverPopoverSet(t){let e=t.hoverEl;e.addClass("pdf-plus-pdf-internal-link-popover");let i=this.getDest();typeof i=="string"&&(e.dataset.dest=i)}},bh=class extends mh{constructor(e,i,r){super(e,i,r.container);this.linkAnnotationElement=r}static registerEvents(e,i,r){return r.data.subtype==="Link"?new bh(e,i,r):null}async getLinkText(e){var i,r;if(this.plugin.settings.actionOnCitationHover==="google-scholar-popover"&&this.lib.requirePluginNewerThan("surfing","0.9.5")){let o=this.getDest();if(sh(o)&&((i=this.child.pdfViewer.pdfViewer)==null?void 0:i.pdfDocument)){let a=(r=this.child.bib)==null?void 0:r.getGoogleScholarSearchUrlFromDest(o);if(a)return a}}return super.getLinkText(e)}getDest(){return this.linkAnnotationElement.data.dest}useModifierKey(){return this.plugin.settings.clickPDFInternalLinkWithModifierKey}shouldShowHoverPopover(){return this.plugin.settings.enableHoverPDFInternalLink}isCitationLink(){let e=this.getDest();return sh(e)}get hoverLinkSourceId(){return this.isCitationLink()?Ci.HOVER_LINK_SOURCE_ID:bh.HOVER_LINK_SOURCE_ID}shouldRecordHistory(){return this.plugin.settings.recordPDFInternalLinkHistory&&!this.child.opts.isEmbed}async customHover(e){if(this.plugin.settings.actionOnCitationHover==="pdf-plus-bib-popover"&&this.child.bib&&this.child.bib.isEnabled()){let i=this.getDest();if(typeof i=="string"&&i.startsWith("cite."))return this.child.bib.spawnBibPopoverOnModKeyDown(i,this,e,this.targetEl),!0}return!1}},Yi=bh;Yi.HOVER_LINK_SOURCE_ID="pdf-plus-internal-link";var _p=class extends mh{constructor(e,i,r){super(e,i,r.selfEl);this.item=r}static registerEvents(e,i,r){return new _p(e,i,r)}getDest(){return this.item.item.dest}useModifierKey(){return this.plugin.settings.clickOutlineItemWithModifierKey}shouldShowHoverPopover(){return this.plugin.settings.popoverPreviewOnOutlineHover}shouldRecordHistory(){return this.plugin.settings.recordHistoryOnOutlineClick&&!this.child.opts.isEmbed}},Ji=_p;Ji.HOVER_LINK_SOURCE_ID="pdf-plus-outline";var $p=class extends gh{static registerEvents(t,e){return new $p(t,e,e.pdfViewer.pdfThumbnailViewer.container)}async getLinkText(t){var r,o;let e=vt(t,t.target)&&t.target.closest('.pdf-thumbnail-view > a[href^="#page="]');if(!e)return null;let i=e.getAttribute("href");return((o=(r=this.file)==null?void 0:r.path)!=null?o:"")+i}useModifierKey(){return this.plugin.settings.clickThumbnailWithModifierKey}shouldShowHoverPopover(){return this.plugin.settings.popoverPreviewOnThumbnailHover}shouldRecordHistory(){return this.plugin.settings.recordHistoryOnThumbnailClick&&!this.child.opts.isEmbed}},Qi=$p;Qi.HOVER_LINK_SOURCE_ID="pdf-plus-thumbnail";var xh=class extends de{constructor(e,i,r){super(e);this.child=i,this.annot=r}get hoverPopover(){return this.child.hoverPopover}set hoverPopover(e){this.child.hoverPopover=e}get hoverLinkSourceId(){return xh.HOVER_LINK_SOURCE_ID}onload(){this.settings.popoverPreviewOnExternalLinkHover&&this.registerDomEvent(this.annot.container,"mouseover",e=>{let i=this.annot.data.url;i&&(i.startsWith("http://")||i.startsWith("https://"))&&this.app.workspace.trigger("hover-link",{event:e,source:this.hoverLinkSourceId,hoverParent:this,targetEl:this.annot.container,linktext:i})})}static registerEvents(e,i,r){var o;return r.data.subtype==="Link"&&r.data.url?(o=i.component)==null?void 0:o.addChild(new xh(e,i,r)):null}},Vn=xh;Vn.HOVER_LINK_SOURCE_ID="pdf-plus-external-link";var xP={highlight:"Highlight",underline:"Underline"},yP={open:"Open backlink",preview:"Popover preview of backlink"},yh={"":"Current tab",tab:"New tab",right:"Split right",left:"Split left",down:"Split down",up:"Split up",window:"New window","right-sidebar":"Right sidebar","left-sidebar":"Left sidebar"},yx={"last-paste":"Last pasted .md","last-active":"Last active .md","last-active-and-open":"Last active & open .md","last-paste-then-last-active":"Last pasted .md if any, otherwise last active .md","last-paste-then-last-active-and-open":"Last pasted .md if any, otherwise last active & open .md","last-active-and-open-then-last-paste":"Last active & open .md if any, otherwise last pasted .md"},wP={root:"Vault folder",current:"Same folder as current file",folder:"In the folder specified below"},vP=["png","jpg","webp","bmp"],vx="green",eg={none:"Same as other internal links","pdf-plus-bib-popover":"PDF++'s custom bibliography popover","google-scholar-popover":"Google Scholar popover"},FP={text:"Copy text",obsidian:"Obsidian default (copy as quote)","pdf-plus":"Run PDF++'s copy command"},Ti={displayTextFormats:[{name:"Title & page",template:"{{file.basename}}, p.{{pageLabel}}"},{name:"Page",template:"p.{{pageLabel}}"},{name:"Text",template:"{{text}}"},{name:"Emoji",template:"\u{1F4D6}"},{name:"None",template:""}],defaultDisplayTextFormatIndex:0,syncDisplayTextFormat:!0,syncDefaultDisplayTextFormat:!1,copyCommands:[{name:"Quote",template:`> ({{linkWithDisplay}}) > {{selection}} `},{name:"Link",template:"{{linkWithDisplay}}"},{name:"Embed",template:"!{{link}}"},{name:"Callout",template:`> [!{{calloutType}}|{{color}}] {{linkWithDisplay}} > {{text}} `},{name:"Quote in callout",template:`> [!{{calloutType}}|{{color}}] {{linkWithDisplay}} > > {{text}} > > `}],useAnotherCopyTemplateWhenNoSelection:!1,copyTemplateWhenNoSelection:"{{linkToPageWithDisplay}}",trimSelectionEmbed:!1,embedMargin:50,noSidebarInEmbed:!0,noSpreadModeInEmbed:!0,embedUnscrollable:!1,singleTabForSinglePDF:!0,highlightExistingTab:!1,existingTabHighlightOpacity:.5,existingTabHighlightDuration:.75,paneTypeForFirstPDFLeaf:"left",openLinkNextToExistingPDFTab:!0,openPDFWithDefaultApp:!1,openPDFWithDefaultAppAndObsidian:!0,focusObsidianAfterOpenPDFWithDefaultApp:!0,syncWithDefaultApp:!1,dontActivateAfterOpenPDF:!0,dontActivateAfterOpenMD:!0,highlightDuration:.75,noTextHighlightsInEmbed:!1,noAnnotationHighlightsInEmbed:!0,persistentTextHighlightsInEmbed:!0,persistentAnnotationHighlightsInEmbed:!1,highlightBacklinks:!0,selectionBacklinkVisualizeStyle:"highlight",dblclickEmbedToOpenLink:!0,highlightBacklinksPane:!0,highlightOnHoverBacklinkPane:!0,backlinkHoverColor:"",colors:{Yellow:"#ffd000",Red:"#ea5252",Note:"#086ddd",Important:"#bb61e5"},defaultColor:"",defaultColorPaletteItemIndex:0,syncColorPaletteItem:!0,syncDefaultColorPaletteItem:!1,colorPaletteInToolbar:!0,noColorButtonInColorPalette:!0,colorPaletteInEmbedToolbar:!1,quietColorPaletteTooltip:!1,showStatusInToolbar:!0,highlightColorSpecifiedOnly:!1,doubleClickHighlightToOpenBacklink:!0,hoverHighlightAction:"preview",paneTypeForFirstMDLeaf:"right",singleMDLeafInSidebar:!0,alwaysUseSidebar:!0,ignoreExistingMarkdownTabIn:[],defaultColorPaletteActionIndex:4,syncColorPaletteAction:!0,syncDefaultColorPaletteAction:!1,proxyMDProperty:"PDF",hoverPDFLinkToOpen:!1,ignoreHeightParamInPopoverPreview:!0,filterBacklinksByPageDefault:!0,showBacklinkToPage:!0,enableHoverPDFInternalLink:!0,recordPDFInternalLinkHistory:!0,alwaysRecordHistory:!0,renderMarkdownInStickyNote:!1,enablePDFEdit:!1,author:"",writeHighlightToFileOpacity:.2,defaultWriteFileToggle:!1,syncWriteFileToggle:!0,syncDefaultWriteFileToggle:!1,enableAnnotationDeletion:!0,warnEveryAnnotationDelete:!1,warnBacklinkedAnnotationDelete:!0,enableAnnotationContentEdit:!0,enableEditEncryptedPDF:!1,pdfLinkColor:"#04a802",pdfLinkBorder:!1,replaceContextMenu:!0,showContextMenuOnMouseUpIf:"Mod",contextMenuConfig:[{id:"action",visible:!0},{id:"selection",visible:!0},{id:"write-file",visible:!0},{id:"annotation",visible:!0},{id:"modify-annotation",visible:!0},{id:"link",visible:!0},{id:"text",visible:!0},{id:"search",visible:!0},{id:"speech",visible:!0},{id:"page",visible:!0},{id:"settings",visible:!0}],selectionProductMenuConfig:["color","copy-format","display"],writeFileProductMenuConfig:["color","copy-format","display"],annotationProductMenuConfig:["copy-format","display"],updateColorPaletteStateFromContextMenu:!0,mobileCopyAction:"pdf-plus",showContextMenuOnTablet:!1,executeBuiltinCommandForOutline:!0,executeBuiltinCommandForZoom:!0,executeFontSizeAdjusterCommand:!0,closeSidebarWithShowCommandIfExist:!0,autoHidePDFSidebar:!1,defaultSidebarView:1,outlineDrag:!0,outlineContextMenu:!0,outlineLinkDisplayTextFormat:"{{file.basename}}, {{text}}",outlineLinkCopyFormat:"{{linkWithDisplay}}",recordHistoryOnOutlineClick:!0,popoverPreviewOnOutlineHover:!0,thumbnailDrag:!0,thumbnailContextMenu:!0,thumbnailLinkDisplayTextFormat:"{{file.basename}}, p.{{pageLabel}}",thumbnailLinkCopyFormat:"{{linkWithDisplay}}",recordHistoryOnThumbnailClick:!0,popoverPreviewOnThumbnailHover:!0,annotationPopupDrag:!0,showAnnotationPopupOnHover:!0,useCallout:!0,calloutType:"PDF",calloutIcon:"highlighter",highlightBacklinksInEmbed:!1,highlightBacklinksInHoverPopover:!1,highlightBacklinksInCanvas:!0,clickPDFInternalLinkWithModifierKey:!0,clickOutlineItemWithModifierKey:!0,clickThumbnailWithModifierKey:!0,focusEditorAfterAutoPaste:!0,clearSelectionAfterAutoPaste:!0,respectCursorPositionWhenAutoPaste:!0,autoCopy:!1,autoFocus:!1,autoPaste:!1,autoFocusTarget:"last-active-and-open-then-last-paste",autoPasteTarget:"last-active-and-open-then-last-paste",openAutoFocusTargetIfNotOpened:!0,howToOpenAutoFocusTargetIfNotOpened:"right",closeHoverEditorWhenLostFocus:!0,closeSidebarWhenLostFocus:!1,openAutoFocusTargetInEditingView:!0,executeCommandWhenTargetNotIdentified:!0,commandToExecuteWhenTargetNotIdentified:"switcher:open",autoPasteTargetDialogTimeoutSec:20,autoCopyToggleRibbonIcon:!0,autoCopyIconName:"highlighter",autoFocusToggleRibbonIcon:!0,autoFocusIconName:"zap",autoPasteToggleRibbonIcon:!0,autoPasteIconName:"clipboard-paste",viewSyncFollowPageNumber:!0,viewSyncPageDebounceInterval:.3,openAfterExtractPages:!0,howToOpenExtractedPDF:"tab",warnEveryPageDelete:!1,warnBacklinkedPageDelete:!0,extractPageInPlace:!1,askExtractPageInPlace:!0,pageLabelUpdateWhenInsertPage:"keep",pageLabelUpdateWhenDeletePage:"keep",pageLabelUpdateWhenExtractPage:"keep",askPageLabelUpdateWhenInsertPage:!0,askPageLabelUpdateWhenDeletePage:!0,askPageLabelUpdateWhenExtractPage:!0,copyOutlineAsListFormat:"{{linkWithDisplay}}",copyOutlineAsListDisplayTextFormat:"{{text}}",copyOutlineAsHeadingsFormat:`{{text}} {{linkWithDisplay}}`,copyOutlineAsHeadingsDisplayTextFormat:"p.{{pageLabel}}",copyOutlineAsHeadingsMinLevel:2,newFileNameFormat:"",newFileTemplatePath:"",newPDFLocation:"current",newPDFFolderPath:"",rectEmbedStaticImage:!1,rectImageFormat:"file",rectImageExtension:"webp",zoomToFitRect:!1,rectEmbedResolution:100,includeColorWhenCopyingRectLink:!0,backlinkIconSize:50,showBacklinkIconForSelection:!1,showBacklinkIconForAnnotation:!1,showBacklinkIconForOffset:!0,showBacklinkIconForRect:!1,showBoundingRectForBacklinkedAnnot:!1,hideReplyAnnotation:!1,searchLinkHighlightAll:"true",searchLinkCaseSensitive:"true",searchLinkMatchDiacritics:"default",searchLinkEntireWord:"false",dontFitWidthWhenOpenPDFLink:!0,preserveCurrentLeftOffsetWhenOpenPDFLink:!1,defaultZoomValue:"page-width",scrollModeOnLoad:0,spreadModeOnLoad:0,hoverableDropdownMenuInToolbar:!0,zoomLevelInputBoxInToolbar:!0,popoverPreviewOnExternalLinkHover:!0,actionOnCitationHover:"pdf-plus-bib-popover",anystylePath:"",enableBibInEmbed:!1,enableBibInHoverPopover:!1,enableBibInCanvas:!0,copyAsSingleLine:!0,removeWhitespaceBetweenCJChars:!0,vim:!1,vimrcPath:"",vimVisualMotion:!0,vimScrollSize:40,vimLargerScrollSizeWhenZoomIn:!0,vimContinuousScrollSpeed:1.2,vimSmoothScroll:!0,vimHlsearch:!0,vimIncsearch:!0,enableVimInContextMenu:!0,enableVimOutlineMode:!0,vimSmoothOutlineMode:!0,vimHintChars:"hjklasdfgyuiopqwertnmzxcvb",vimHintArgs:"all",PATH:""};function PP(n){return Ti.hasOwnProperty(n)}var Bn=In("Mod").toLowerCase(),wh=class extends se.PluginSettingTab{constructor(e){super(e.app,e);this.plugin=e;this.events=new se.Events;this.component=new se.Component,this.items={},this.headings=new Map,this.iconHeadings=new Map,this.headerEls=new Map,this.promises=[],this.containerEl.addClass("pdf-plus-settings"),this.headerContainerEl=this.containerEl.createDiv("header-container"),this.contentEl=this.containerEl.createDiv("content")}addSetting(e){let i=new se.Setting(this.contentEl);return e&&(this.items[e]=i,this.component.registerDomEvent(i.settingEl,"contextmenu",r=>{r.preventDefault(),new tg.Menu().addItem(o=>{o.setTitle("Copy link to this setting").setIcon("lucide-link").onClick(()=>{navigator.clipboard.writeText(`obsidian://pdf-plus?setting=${e}`)})}).showAtMouseEvent(r)})),i}addHeading(e,i,r,o){let s=this.addSetting().setName(e).setHeading().then(a=>{if(r){let c=a.settingEl.parentElement;c&&c.insertBefore(createDiv("spacer"),a.settingEl);let l=createDiv();a.settingEl.prepend(l),(0,se.setIcon)(l,r),a.settingEl.addClass("pdf-plus-setting-heading")}});return this.headings.set(i,s),this.component.registerDomEvent(s.settingEl,"contextmenu",a=>{a.preventDefault(),new tg.Menu().addItem(c=>{c.setTitle("Copy link to this heading").setIcon("lucide-link").onClick(()=>{navigator.clipboard.writeText(`obsidian://pdf-plus?setting=heading:${i}`)})}).showAtMouseEvent(a)}),r&&this.headerContainerEl.createDiv("clickable-icon header",a=>{let c=a.createDiv();(0,se.setIcon)(c,r);let l=a.createDiv("header-title");l.setText(e),(0,se.setTooltip)(a,e),this.component.registerDomEvent(a,"click",d=>{var h;((h=s.settingEl.previousElementSibling)!=null?h:s.settingEl).scrollIntoView({behavior:"smooth"}),this.updateHeaderElClassOnScroll(d)}),o==null||o({headerEl:a,iconEl:c,titleEl:l}),this.iconHeadings.set(i,s),this.headerEls.set(i,a)}),s}updateHeaderElClass(){var r,o,s;let e=this.containerEl.getBoundingClientRect().height,i=Array.from(this.iconHeadings.entries());for(let a=0;a=e*.2+this.headerContainerEl.clientHeight,h=i[a][0];(s=this.headerEls.get(h))==null||s.toggleClass("is-active",d)}}updateHeaderElClassOnScroll(e){var o;let i=(o=e==null?void 0:e.win)!=null?o:activeWindow,r=i.setInterval(()=>this.updateHeaderElClass(),50);i.setTimeout(()=>i.clearInterval(r),1500)}scrollTo(e,i){let r=this.items[e];r&&this.scrollToSetting(r,i)}scrollToHeading(e,i){let r=this.headings.get(e);r&&this.scrollToSetting(r,i)}scrollToSetting(e,i){let r=e.settingEl;r&&this.containerEl.scrollTo({top:r.offsetTop-this.headerContainerEl.offsetHeight,...i})}openFromObsidianUrl(e){let i=e.setting;i.startsWith("heading:")?this.plugin.openSettingTab().scrollToHeading(i.slice(8)):PP(i)&&this.plugin.openSettingTab().scrollTo(i)}getVisibilityToggler(e,i){let r=()=>{i()?e.settingEl.show():e.settingEl.hide()};return r(),r}showConditionally(e,i){let r=Array.isArray(e)?e:[e],o=r.map(s=>this.getVisibilityToggler(s,i));return this.events.on("update",()=>o.forEach(s=>s())),r}addTextSetting(e,i,r){let o=this.addSetting(e).addText(s=>{s.setValue(this.plugin.settings[e]).setPlaceholder(i!=null?i:"").then(a=>{i&&(a.inputEl.size=Math.max(a.inputEl.size,a.inputEl.placeholder.length))}).onChange(async a=>{this.plugin.settings[e]=a,await this.plugin.saveSettings()}),r&&(this.component.registerDomEvent(s.inputEl,"blur",()=>{r(o)}),this.component.registerDomEvent(s.inputEl,"keypress",a=>{a.key==="Enter"&&r(o)}))});return o}addTextAreaSetting(e,i,r){return this.addSetting(e).addTextArea(o=>{o.setValue(this.plugin.settings[e]).setPlaceholder(i!=null?i:"").onChange(async s=>{this.plugin.settings[e]=s,await this.plugin.saveSettings()}),r&&this.component.registerDomEvent(o.inputEl,"blur",r)})}addNumberSetting(e){return this.addSetting(e).addText(i=>{i.setValue(""+this.plugin.settings[e]).setPlaceholder(""+Ti[e]).then(r=>r.inputEl.type="number").onChange(async r=>{this.plugin.settings[e]=r===""?Ti[e]:+r,await this.plugin.saveSettings()})})}addToggleSetting(e,i){return this.addSetting(e).addToggle(r=>{r.setValue(this.plugin.settings[e]).onChange(async o=>{this.plugin.settings[e]=o,await this.plugin.saveSettings(),i==null||i(o)})})}addColorPickerSetting(e,i){return this.addSetting(e).addColorPicker(r=>{r.setValue(this.plugin.settings[e]).onChange(async o=>{this.plugin.settings[e]=o,await this.plugin.saveSettings(),i==null||i(o)})})}addDropdownSetting(e,...i){let r=[],o=a=>a,s=a=>{};return Array.isArray(i[0])?(r=i[0],typeof i[1]=="function"&&(o=i[1]),typeof i[2]=="function"&&(s=i[2])):(r=Object.keys(i[0]),o=a=>i[0][a],typeof i[1]=="function"&&(s=i[1])),this.addSetting(e).addDropdown(a=>{var c;for(let l of r){let d=(c=o(l))!=null?c:l;a.addOption(l,d)}a.setValue(this.plugin.settings[e]).onChange(async l=>{this.plugin.settings[e]=l,await this.plugin.saveSettings(),s==null||s(l)})})}addIndexDropdownSetting(e,i,r,o){return this.addSetting(e).addDropdown(s=>{var l;for(let d of i){let h=(l=r==null?void 0:r(d))!=null?l:d;s.addOption(d,h)}let a=this.plugin.settings[e],c=i[a];s.setValue(c).onChange(async d=>{let h=i.indexOf(d);h!==-1&&(this.plugin.settings[e]=h,await this.plugin.saveSettings(),o==null||o(h))})})}addEnumDropdownSetting(e,i,r){return this.addSetting(e).addDropdown(o=>{for(let[s,a]of Object.entries(i))parseInt(s).toString()===s&&o.addOption(s,a);o.setValue(""+this.plugin.settings[e]).onChange(async s=>{this.plugin.settings[e]=+s,await this.plugin.saveSettings(),r==null||r(+s)})})}addSliderSetting(e,i,r,o){return this.addSetting(e).addSlider(s=>{s.setLimits(i,r,o).setValue(this.plugin.settings[e]).setDynamicTooltip().onChange(async a=>{this.plugin.settings[e]=a,await this.plugin.saveSettings()})})}addDesc(e){return this.addSetting().setDesc(e)}addFileLocationSetting(e,i,r,o){return[this.addDropdownSetting(e,wP,()=>this.redisplay()).then(i),this.addSetting().addText(s=>{s.setValue(this.plugin.settings[r]),s.inputEl.size=30,new mr(this.app,s.inputEl).onSelect(({item:a})=>{this.plugin.settings[r]=a.path,this.plugin.saveSettings()})}).then(s=>{o(s),this.plugin.settings[e]!=="folder"&&s.settingEl.hide()})]}addFundingButton(){let e=i=>{let r=i.firstElementChild;(r==null?void 0:r.tagName)==="svg"&&(r.setAttribute("fill","var(--color-red)"),r.setAttribute("stroke","var(--color-red)"))};return this.addHeading("Support development","funding","lucide-heart",({iconEl:i})=>e(i)).setDesc(`If you find PDF++ helpful, please consider supporting the development to help me keep this plugin alive. If you prefer PayPal, please make donations via Ko-fi. Thank you!`).then(i=>{let r=i.infoEl,o=i.settingEl.firstElementChild;if(!o)return;let s=i.settingEl.createDiv();s.appendChild(o),s.appendChild(r),i.settingEl.prepend(s),i.settingEl.id="pdf-plus-funding",s.id="pdf-plus-funding-icon-info-container",o.id="pdf-plus-funding-icon",e(o)}).addButton(i=>{i.setButtonText("GitHub Sponsors").onClick(()=>{open("https://github.com/sponsors/RyotaUshio")})}).addButton(i=>{i.setButtonText("Buy Me a Coffee").onClick(()=>{open("https://www.buymeacoffee.com/ryotaushio")})}).addButton(i=>{i.setButtonText("Ko-fi").onClick(()=>{open("https://ko-fi.com/ryotaushio")})})}async renderMarkdown(e,i){this.promises.push(this._renderMarkdown(e,i)),i.addClass("markdown-rendered")}async _renderMarkdown(e,i){await se.MarkdownRenderer.render(this.app,Array.isArray(e)?e.join(` `):e,i,"",this.component),i.childNodes.length===1&&i.firstChild instanceof HTMLParagraphElement&&i.replaceChildren(...i.firstChild.childNodes)}addColorSetting(e){let i=this.plugin.settings.colors,[r,o]=Object.entries(i)[e],s=this.plugin.settings.defaultColor===r,a=o;return this.addSetting().addText(c=>{c.setPlaceholder("Color name (case-insensitive)").then(l=>{l.inputEl.size=l.inputEl.placeholder.length,(0,se.setTooltip)(l.inputEl,"Color name (case-insensitive)")}).setValue(r).onChange(async l=>{if(l in i){new se.Notice("This color name is already used."),c.inputEl.addClass("error");return}c.inputEl.removeClass("error"),delete i[r];for(let d of["defaultColor","backlinkHoverColor"]){let h=this.items[d];if(h){let u=h.components[0].selectEl.querySelector(`:scope > option:nth-child(${e+2})`);u&&(u.value=l,u.textContent=l)}}r=l,i[r]=o,s&&(this.plugin.settings.defaultColor=r),await this.plugin.saveSettings(),this.plugin.loadStyle()})}).addColorPicker(c=>{c.setValue(o),c.onChange(async l=>{a=o,o=l,i[r]=o,await this.plugin.saveSettings(),this.plugin.loadStyle()})}).addExtraButton(c=>{c.setIcon("rotate-ccw").setTooltip("Return to previous color").onClick(async()=>{o=a,i[r]=o,await this.plugin.saveSettings(),this.plugin.loadStyle(),this.redisplay()})}).addExtraButton(c=>{c.setIcon("trash").setTooltip("Delete").onClick(async()=>{this.plugin.settings.defaultColor===r&&(this.plugin.settings.defaultColor=""),delete i[r],await this.plugin.saveSettings(),this.plugin.loadStyle(),this.redisplay()})})}addNameValuePairListSetting(e,i,r,o,s){let{getName:a,setName:c,getValue:l,setValue:d}=o,h=e[i],u=a(h),f=l(h);return this.addSetting().addText(p=>{p.setPlaceholder(s.name.placeholder).then(g=>{g.inputEl.size=s.name.formSize,(0,se.setTooltip)(g.inputEl,s.name.placeholder)}).setValue(u).onChange(async g=>{if(e.some(b=>a(b)===g)){new se.Notice(s.name.duplicateMessage),p.inputEl.addClass("error");return}p.inputEl.removeClass("error"),c(h,g);let m=this.items[r];if(m){let b=m.components[0].selectEl.querySelector(`:scope > option:nth-child(${i+1})`);b&&(b.value=g,b.textContent=g)}await this.plugin.saveSettings()})}).then(p=>{s.value.hasOwnProperty("formRows")?p.addTextArea(g=>{g.setPlaceholder(s.value.placeholder).then(m=>{m.inputEl.rows=s.value.formRows,m.inputEl.cols=s.value.formSize,(0,se.setTooltip)(m.inputEl,s.value.placeholder)}).setValue(f).onChange(async m=>{d(h,m),await this.plugin.saveSettings()})}):p.addText(g=>{g.setPlaceholder(s.value.placeholder).then(m=>{m.inputEl.size=s.value.formSize,(0,se.setTooltip)(m.inputEl,s.value.placeholder)}).setValue(f).onChange(async m=>{d(h,m),await this.plugin.saveSettings()})})}).addExtraButton(p=>{p.setIcon("trash").setTooltip("Delete").onClick(async()=>{if(e.length===1){new se.Notice(s.delete.deleteLastMessage);return}e.splice(i,1),this.plugin.settings[r]>i?this.plugin.settings[r]--:this.plugin.settings[r]===i&&(this.plugin.settings[r]=0),await this.plugin.saveSettings(),this.redisplay()})}).setClass("no-border")}addNamedTemplatesSetting(e,i,r,o){return this.addNameValuePairListSetting(e,i,r,{getName:s=>s.name,setName:(s,a)=>{s.name=a},getValue:s=>s.template,setValue:(s,a)=>{s.template=a}},o)}addDisplayTextSetting(e){return this.addNamedTemplatesSetting(this.plugin.settings.displayTextFormats,e,"defaultDisplayTextFormatIndex",{name:{placeholder:"Format name",formSize:30,duplicateMessage:"This format name is already used."},value:{placeholder:"Display text format",formSize:50},delete:{deleteLastMessage:"You cannot delete the last display text format."}})}addCopyCommandSetting(e){return this.addNamedTemplatesSetting(this.plugin.settings.copyCommands,e,"defaultColorPaletteActionIndex",{name:{placeholder:"Format name",formSize:30,duplicateMessage:"This format name is already used."},value:{placeholder:"Copied text format",formSize:50,formRows:3},delete:{deleteLastMessage:"You cannot delete the last copy format."}})}addHotkeySettingButton(e,i){e.addButton(r=>{r.setButtonText("Open hotkeys settings").onClick(()=>{this.plugin.openHotkeySettingTab(i)})})}addPagePreviewSettingButton(e){return e.addButton(i=>{i.setButtonText("Open page preview settings").onClick(()=>{this.app.setting.openTabById("page-preview")})})}addRequireModKeyOnHoverSetting(e){let i=this.app.workspace.hoverLinkSources[e].display,r=this.plugin.requireModKeyForLinkHover(e);return this.addSetting().setName(`Require ${Bn} key while hovering`).setDesc(`Currently ${r?"required":"not required"}. You can toggle this on and off in the core Page Preview plugin settings > ${i}.`).then(o=>this.addPagePreviewSettingButton(o))}addIconSetting(e,i){let r=a=>a.startsWith("lucide-")?a.slice(7):a,o=a=>a.startsWith("lucide-")?a:"lucide-"+a,s=a=>{var d;let c=(d=a.controlEl.querySelector(":scope>.icon-preview"))!=null?d:a.controlEl.createDiv("icon-preview");(0,se.setIcon)(c,o(this.plugin.settings[e]));let l=a.components[0];(!i||this.plugin.settings[e])&&!c.childElementCount?(l.inputEl.addClass("error"),(0,se.setTooltip)(l.inputEl,"No icon found")):(l.inputEl.removeClass("error"),(0,se.setTooltip)(l.inputEl,""))};return this.addTextSetting(e,void 0,a=>{this.plugin.settings[e]=r(this.plugin.settings[e]),this.plugin.saveSettings(),s(a)}).then(a=>{this.renderMarkdown(["You can use any icon from [Lucide](https://lucide.dev/icons)."+(i?" Leave blank to remove icons.":"")],a.descEl)}).then(s)}addProductMenuSetting(e,i){let r=Ti[e],o={color:"Colors","copy-format":"Copy format",display:"Display text format"},s=this.plugin.settings[e],a=this.addHeading(i,e);a.addExtraButton(d=>{d.setTooltip("Reset").setIcon("rotate-ccw").onClick(()=>{s.length=0,s.push(...r),this.redisplay()})});let c=[],l=r.slice();for(let d=0;d0){if(!se.Platform.isDesktopApp)return;let h=c[d-1].getValue();if(!h)return;l.remove(h)}this.addSetting().then(h=>{se.Platform.isDesktopApp&&h.setName(d===0?"Top-level menu":d===1?"Submenu":"Subsubmenu")}).addDropdown(h=>{var f;for(let p of l)h.addOption(p,o[p]);d>0&&h.addOption("","None");let u=(f=s[d])!=null?f:"";u&&!l.includes(u)&&l[0]&&(s[d]=l[0],u=s[d]),h.setValue(u).onChange(p=>{if(p)s[d]=p;else for(;s.length>d;)s.pop();this.plugin.saveSettings(),this.redisplay()}),c.push(h)}).then(h=>{h.settingEl.addClasses(["no-border","small-padding"])})}return a}createLinkTo(e,i){return createEl("a","",r=>{r.onclick=o=>{this.scrollTo(e,{behavior:"smooth"}),this.updateHeaderElClassOnScroll(o)},activeWindow.setTimeout(()=>{let o=this.items[e];!i&&o&&(i='"'+o.nameEl.textContent+'"'),r.setText(i!=null?i:"")})})}createLinkToHeading(e,i){return createEl("a","",r=>{r.onclick=o=>{this.scrollToHeading(e,{behavior:"smooth"}),this.updateHeaderElClassOnScroll(o)},activeWindow.setTimeout(()=>{let o=this.headings.get(e);!i&&o&&(i='"'+o.nameEl.textContent+'"'),r.setText(i!=null?i:"")})})}redisplay(){let e=this.contentEl.scrollTop;this.display(),this.contentEl.scroll({top:e}),this.events.trigger("update")}async display(){var c,l;kr.openIfNecessary(this.plugin),this.headerContainerEl.empty(),this.contentEl.empty(),this.promises=[],this.component.load(),activeWindow.setTimeout(()=>this.updateHeaderElClass());for(let d of["wheel","touchmove"])this.component.registerDomEvent(this.contentEl,d,(0,se.debounce)(()=>this.updateHeaderElClass(),100),{passive:!0});this.contentEl.createDiv("top-note",async d=>{await this.renderMarkdown(["> [!TIP]","> - You can easily navigate through the settings by clicking the icons in the header above.","> - Some settings below require reopening tabs or reloading the plugin to take effect.","> - [Visit the docs](https://ryotaushio.github.io/obsidian-pdf-plus/)",'> - '],d);let h=document.getElementById("pdf-plus-funding-link-placeholder");h&&(h.textContent="Help me keep PDF++ alive!",h.onclick=u=>{this.scrollToHeading("funding",{behavior:"smooth"}),this.updateHeaderElClassOnScroll(u)})}),this.addHeading("Editing PDF files","edit","lucide-save").then(d=>{this.renderMarkdown(["By allowing PDF++ to modify PDF files directly, you can:","- Add, edit and delete highlights and links in PDF files.","- Add, insert, delete or extract PDF pages and auto-update links.","- Add, rename, move and delete outline items.","- Edit [page labels](https://ryotaushio.github.io/obsidian-pdf-plus/page-labels.html).","","[Learn more](https://ryotaushio.github.io/obsidian-pdf-plus/editing-pdfs.html)"],d.descEl)}),this.addToggleSetting("enablePDFEdit",()=>this.redisplay()).setName("Enable PDF editing").then(d=>{this.renderMarkdown(['PDF++ will not modify PDF files themselves unless you turn on this option. The author assumes no responsibility for any data corruption. Please make sure you have a backup of your files.'],d.descEl)}),this.plugin.settings.enablePDFEdit&&(this.addTextSetting("author","Your name",d=>{let h=d.components[0].inputEl;h.toggleClass("error",!h.value)}).setName("Annotation author").setDesc("It must contain at least one character in order to make annotations referenceable & editable within Obsidian.").then(d=>{let h=d.components[0].inputEl;h.toggleClass("error",!h.value)}),this.addToggleSetting("enableEditEncryptedPDF").setName("Enable editing encrypted PDF files")),this.addHeading("Backlink highlighting","backlink-highlight","lucide-highlighter").setDesc('Annotate PDF files with highlights just by linking to text selection. You can easily copy links to selections using color palette in the toolbar. See the "Color palette" section for the details.').then(d=>d.settingEl.addClass("normal-margin-top")),this.addToggleSetting("highlightBacklinks").setName("Highlight backlinks in PDF viewer").setDesc("In the PDF viewer, any referenced text will be highlighted for easy identification."),this.addDesc("Try turning off the following options if you experience performance issues."),this.addToggleSetting("highlightBacklinksInEmbed").setName("Highlight backlinks in PDF embeds"),this.addToggleSetting("highlightBacklinksInCanvas").setName("Highlight backlinks in Canvas"),this.addToggleSetting("highlightBacklinksInHoverPopover").setName("Highlight backlinks in hover popover previews"),this.addDropdownSetting("selectionBacklinkVisualizeStyle",xP).setName("Highlight style").setDesc("How backlinks to a text selection should be visualized."),this.addDropdownSetting("hoverHighlightAction",yP,()=>this.redisplay()).setName("Action when hovering over highlighted text").setDesc(`Easily open backlinks or display a popover preview of it by pressing ${In("Mod").toLowerCase()} (by default) while hovering over a highlighted text in PDF viewer.`),this.addRequireModKeyOnHoverSetting("pdf-plus"),this.addToggleSetting("doubleClickHighlightToOpenBacklink").setName("Double click highlighted text to open the corresponding backlink"),this.addHeading("How backlinks are opened","open-backlink").setDesc("Customize how backlinks are opened when "+(this.plugin.settings.hoverHighlightAction==="open"?`${In("Mod").toLowerCase()}+hovering over or `:"")+"double-clicking highlighted text."),this.addDropdownSetting("paneTypeForFirstMDLeaf",yh,()=>this.redisplay()).setName("How to open the markdown file when no markdown file is opened"),(this.plugin.settings.paneTypeForFirstMDLeaf==="left-sidebar"||this.plugin.settings.paneTypeForFirstMDLeaf==="right-sidebar")&&(this.addToggleSetting("alwaysUseSidebar").setName("Always use sidebar to open markdown files from highlighted text").setDesc(`If turned on, the ${this.plugin.settings.paneTypeForFirstMDLeaf==="left-sidebar"?"left":"right"} sidebar will be used whether there is existing markdown tabs or not.`),this.addToggleSetting("singleMDLeafInSidebar").setName("Don't open multiple panes in sidebar").setDesc("Turn this on if you want to open markdown files in a single pane in the sidebar.")),this.addSetting("ignoreExistingMarkdownTabIn").setName("Ignore existing markdown tabs in...").setDesc("If some notes are opened in the ignored splits, PDF++ will still open the backlink in the way specified in the previous setting. For example, you might want to ignore the left sidebar if you are pinning a certain note (e.g. daily note) in it.");let e={leftSplit:"Left sidebar",rightSplit:"Right sidebar",floatingSplit:"Popout windows"},i=this.plugin.settings.ignoreExistingMarkdownTabIn;for(let[d,h]of Object.entries(e)){let u=d;this.addSetting().addToggle(f=>{f.setValue(i.includes(u)).onChange(p=>{p?i.push(u):i.remove(u),this.plugin.saveSettings()})}).then(f=>{f.controlEl.prepend(createEl("span",{text:h})),f.settingEl.addClasses(["no-border","ignore-split-setting"])})}this.addToggleSetting("dontActivateAfterOpenMD").setName("Don't move focus to markdown view after opening a backlink").setDesc("This option will be ignored when you open a link in a tab in the same split as the current tab."),this.addHeading("Colors","color"),this.addSetting("colors").setName("Highlight colors").then(d=>this.renderMarkdown(['You can optionally highlight the selection with **a specified color** by appending "&color=``" to a link text, where `` is one of the colors that you register below. e.g `[[file.pdf#page=1&selection=4,0,5,20&color=red]].` ',"Color names are case-insensitive. ","",'You can ues the color palette in PDF toolbars to easily copy links with "&color=..." appended automatically. See the "Color palette" section for the details.',"",'You can also opt not to use this plugin-dependent notation and apply a single color (the "default highlight color" setting) to all highlights.',"","These colors are also available as CSS variables, e.g. `--pdf-plus-yellow-rgb`. You can use them for various CSS customizations. See [README](https://github.com/RyotaUshio/obsidian-pdf-plus?tab=readme-ov-file#css-customization) for the details."],d.descEl)).addButton(d=>{d.setIcon("plus").setTooltip("Add a new color").onClick(()=>{this.plugin.settings.colors[""]="#",this.redisplay()})});for(let d=0;dd||"Obsidian default",()=>this.plugin.loadStyle()).setName("Default highlight color").setDesc("If no color is specified in link text, this color will be used."),this.addHeading("Backlink indicator bounding rectangles","backlink-bounding-rect"),this.addToggleSetting("showBoundingRectForBacklinkedAnnot").setName("Show bounding rectangles for backlinked annotations").setDesc("Bounding rectangles will be shown for annotations with backlinks."),this.addHeading("Backlink indicator icons","backlink-icon").setDesc("Show icons for text selections, annotations, offsets and rectangular selections with backlinks."),this.addToggleSetting("showBacklinkIconForSelection").setName("Show icon for text selection with backlinks"),this.addToggleSetting("showBacklinkIconForAnnotation").setName("Show icon for annotation with backlinks"),this.addToggleSetting("showBacklinkIconForOffset").setName("Show icon for offset backlinks"),this.addToggleSetting("showBacklinkIconForRect").setName("Show icon for rectangular selection backlinks"),this.addSliderSetting("backlinkIconSize",10,100,5).setName("Icon size"),this.addHeading("Rectangular selection embeds","rect","lucide-box-select").then(d=>{this.renderMarkdown(["You can embed a specified rectangular area from a PDF page into your note. [Learn more](https://ryotaushio.github.io/obsidian-pdf-plus/embedding-rectangular-selections.html)"],d.descEl)}),this.addSliderSetting("rectEmbedResolution",10,200,1).setName("Rendering resolution").setDesc("The higher the value, the better the rendering quality, but the longer time it takes to render. The default value is 100."),this.addToggleSetting("rectEmbedStaticImage",()=>this.redisplay()).setName("Paste as image").setDesc("By default, rectangular selection embeds are re-rendered every time you open the markdown file, which can slow down the loading time. Turn on this option to replace them with static images and improve the performance."),this.plugin.settings.rectEmbedStaticImage&&(this.addDropdownSetting("rectImageFormat",{file:"Create & embed image file","data-url":"Embed as data URL"},()=>this.redisplay()).setName("How to embed the image").then(d=>this.renderMarkdown(['- "Create & embed image file": Create an image file and embed it in the markdown file. The image file will be saved in the folder you specify in the "Default location for new attachments" setting in the core Obsidian settings.',`- "Embed as data URL": Embed the image as a [data URL](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs) without creating a file. This option is useful when you don't want to mess up your attachment folder. It also helps you make your notes self-contained.`],d.descEl)),this.plugin.settings.rectImageFormat==="file"&&this.addDropdownSetting("rectImageExtension",vP).setName("Image file format")),this.addToggleSetting("includeColorWhenCopyingRectLink").setName("Include the selected color's name when copying a link to a rectangular selection").setDesc("When enabled, the name of the color selected in the color palette will be included in the link text. As a result, the rectangular selection will be highlighted with the specified color in the PDF viewer."),this.addToggleSetting("zoomToFitRect").setName("Zoom to fit rectangular selection when opening link").setDesc(createFragment(d=>{d.appendText("When enabled, the PDF viewer will zoom to fit the rectangular selection when you open a link to it. Otherwise, the viewer will keep the current zoom level. "),d.appendText("Note: check out the "),d.appendChild(this.createLinkTo("dblclickEmbedToOpenLink")),d.appendText(" option as well.")})),this.addHeading("PDF++ callouts","callout","lucide-quote").then(d=>{this.renderMarkdown("Create [callouts](https://help.obsidian.md/Editing+and+formatting/Callouts) with the same color as the highlight color without any CSS snippet scripting.",d.descEl)}),this.addToggleSetting("useCallout").setName("Use PDF++ callouts").then(d=>{this.renderMarkdown(["You can also disable this option and choose to use your own custom [CSS snippets](https://help.obsidian.md/Extending+Obsidian/CSS+snippets). See our [README](https://github.com/RyotaUshio/obsidian-pdf-plus?tab=readme-ov-file#css-customization) for the details."],d.descEl)}),this.addTextSetting("calloutType",void 0,()=>this.redisplay()).setName("Callout type name").then(d=>{var f,p;let h=this.plugin.settings.calloutType,u=(p=(f=Object.keys(this.plugin.settings.colors).first())==null?void 0:f.toLowerCase())!=null?p:"yellow";this.renderMarkdown([`For example, if this is set to "${h}", use the following syntax to insert a callout with color "${u}":`,"","```markdown",`> [!${h}|${u}] Title`,"> Content","```","",'You can also use explicit RGB color values like "255, 208, 0" instead of color names.',"I recommend setting this as a custom color palette action in the setting below, like so:","","```markdown","> [!{{calloutType}}|{{color}}] {{linkWithDisplay}}","> {{text}}","```"],d.descEl)}),this.addIconSetting("calloutIcon",!0).setName("Callout icon"),this.addHeading("PDF toolbar","toolbar","lucide-palette"),this.addToggleSetting("hoverableDropdownMenuInToolbar").setName("Hoverable dropdown menus").setDesc("(Not supported on smartphones) When enabled, the dropdown menus (\u2304) in the PDF toolbar will be opened by hovering over the icon, and you don't need to click it."),this.addToggleSetting("zoomLevelInputBoxInToolbar").setName("Show zoom level box").setDesc("A input box will be added to the PDF toolbar, which indicated the current zoom level and allows you to set the zoom level by typing a number."),this.addHeading("Color palette","palette").setDesc('Clicking a color while selecting a range of text will copy a link to the selection with "&color=..." appended.'),this.addToggleSetting("colorPaletteInToolbar",()=>{this.redisplay(),this.plugin.loadStyle()}).setName("Show color palette in the toolbar").setDesc("A color palette will be added to the toolbar of the PDF viewer."),this.plugin.settings.colorPaletteInToolbar&&(this.addToggleSetting("noColorButtonInColorPalette",()=>this.plugin.loadStyle()).setName('Show "without specifying color" button in the color palette'),this.addToggleSetting("colorPaletteInEmbedToolbar",()=>this.plugin.loadStyle()).setName("Show color palette in PDF embeds as well"),this.addIndexDropdownSetting("defaultColorPaletteItemIndex",["",...Object.keys(this.plugin.settings.colors)],d=>d||"Don't specify").setName("Default color selected in color palette").setDesc("This color will be selected in the color palette in a newly opened PDF viewer."),this.addToggleSetting("syncColorPaletteItem",()=>this.redisplay()).setName("Share a single color among all color palettes").setDesc("If disabled, you can specify a different color for each color palette."),this.plugin.settings.syncColorPaletteItem&&this.addToggleSetting("syncDefaultColorPaletteItem").setName("Share the color with newly opened color palettes as well"),this.addToggleSetting("quietColorPaletteTooltip").setName("Quiet tooltips in color palette").setDesc(`When disabled${Ti.quietColorPaletteTooltip?"":" (default)"}, the tooltip will show the color name as well as the selected copy format and display text format. If enabled, only the color name will be shown.`)),this.addHeading("Viewer options","viewer-option","lucide-monitor"),this.addSetting("defaultZoomValue").setName("Default zoom level").addDropdown(d=>{d.addOptions({"page-width":"Fit width","page-height":"Fit height","page-fit":"Fit page",custom:"Custom..."}).setValue(this.plugin.settings.defaultZoomValue.startsWith("page-")?this.plugin.settings.defaultZoomValue:"custom").onChange(async h=>{h==="custom"&&(h="100"),this.plugin.settings.defaultZoomValue=h,r(),await this.plugin.saveSettings()})});let r=this.getVisibilityToggler(this.addSetting().setName("Custom zoom level (%)").addSlider(d=>{d.setLimits(10,400,5).setDynamicTooltip().setValue(this.plugin.settings.defaultZoomValue.startsWith("page-")?100:parseInt(this.plugin.settings.defaultZoomValue)).onChange(async h=>{this.plugin.settings.defaultZoomValue=""+h,await this.plugin.saveSettings()})}),()=>!this.plugin.settings.defaultZoomValue.startsWith("page-"));this.addEnumDropdownSetting("scrollModeOnLoad",{[0]:"Vertical",[1]:"Horizontal",[2]:"Wrapped"},()=>o()).setName("Default scroll mode");let o=this.getVisibilityToggler(this.addEnumDropdownSetting("spreadModeOnLoad",{[0]:"Single page",[1]:"Two page (odd)",[2]:"Two page (even)"}).setName("Default spread mode"),()=>this.plugin.settings.scrollModeOnLoad!==2);if(this.addHeading("Context menu in PDF viewer","context-menu","lucide-mouse-pointer-click").setDesc("(Desktop & tablet only) Customize the behavior of the context menu that pops up when you right-click in the PDF viewer. For mobile users, see also the next section."),this.addToggleSetting("replaceContextMenu",()=>this.redisplay()).setName("Replace the built-in context menu with PDF++'s custom menu"),!this.plugin.settings.replaceContextMenu)this.addSetting().setName("Display text format").setDesc('You can customize the display text format in the setting "Copied text foramt > Display text format" below.');else{this.addToggleSetting("showContextMenuOnTablet").setName("Show context menu on tablet devices as well").setDesc('By default, Obsidian does not show the context menu after text selection on mobile devices, including tablets (iPad, etc.). If you want to show the context menu on tablets, turn this option on. Even if this option is turned off, you copy select the OS-native "Copy" option to run the "'+this.plugin.lib.commands.stripCommandNamePrefix(this.plugin.lib.commands.getCommand("copy-link-to-selection").name)+'" command.');let d=Cp();this.addDropdownSetting("showContextMenuOnMouseUpIf",{always:"Always",...Object.fromEntries(Object.entries(d).map(([h,u])=>[h,`${u} key is pressed`])),never:"Never"}).setName("Show the context menu right after selecting text when...").setDesc(createFragment(h=>{h.appendText("If "),h.appendChild(this.createLinkToHeading("auto-copy","auto-copy")),h.appendText(" is enabled, it will be prioritized and the context menu will not be shown.")}));{this.addHeading("Menu items","context-menu-items").setDesc("Customize which menu items to show.");let h={action:'Look up "(selection)"',selection:"Copy link to selection","write-file":`Add ${this.plugin.settings.selectionBacklinkVisualizeStyle} to file`,annotation:"Copy link to annotation","modify-annotation":"Edit/delete annotation",link:"Copy PDF link / Search on Google Scholar / Paste copied PDF link to selection / Copy URL",text:"Copy selected text / Copy annotated text",search:"Copy link to search",speech:"Read aloud selected text",page:"Copy link to page",settings:"Customize menu..."},u=this.plugin.settings.contextMenuConfig,f=[];for(let p=0;p{b.setValue(g.visible).onChange(w=>{g.visible=w,this.plugin.saveSettings()})}).then(b=>{g.id==="action"?b.setDesc("Available only on macOS."):g.id==="write-file"||g.id==="modify-annotation"?b.setDesc(createFragment(w=>{w.appendText("Requires "),w.appendChild(this.createLinkTo("enablePDFEdit","PDF editing")),w.appendText(" to be enabled.")})):g.id==="link"?b.setDesc('"Search on Google Scholar": Available when right-clicking citation links in PDFs.'):g.id==="speech"?b.setDesc(createFragment(w=>{w.appendText("Requires the "),w.createEl("a",{text:"Text to Speech",href:"obsidian://show-plugin?id=obsidian-tts"}),w.appendText(" plugin to be enabled.")})):g.id==="page"&&b.setDesc("Available when right-clicking with no text selected.")}))}}this.addDesc("Customize nested menus."),this.addProductMenuSetting("selectionProductMenuConfig","Copy link to selection"),this.addProductMenuSetting("writeFileProductMenuConfig",`Add ${this.plugin.settings.selectionBacklinkVisualizeStyle} to file`),this.addProductMenuSetting("annotationProductMenuConfig","Copy link to annotation"),this.addToggleSetting("updateColorPaletteStateFromContextMenu").setName("Update color palette from context menu").setDesc("In the context menu, the items (color, copy format and display text format) set in the color palette are selected by default. If this option is enabled, clicking a menu item will also update the color palette state and hence the default-selected items in the context menu as well.")}this.addHeading("Copying on mobile","mobile-copy","lucide-smartphone"),this.addDropdownSetting("mobileCopyAction",FP).setName('Action triggered by selecting "Copy" option on mobile devices'),this.addHeading("Copying links via hotkeys","copy-hotkeys","lucide-keyboard"),this.addSetting().setName("Set up hotkeys for copying links").then(d=>{this.renderMarkdown(["PDF++ offers two commands for quickly copying links via hotkeys.","","1. **Copy link to selection or annotation:**"," Copies a link to the text selection or focused annotation in the PDF viewer, which is formatted according to the options specified in the PDF toolbar.",'
If the "Add highlights to file directly" toggle switch in the PDF toolbar is on, it first adds a highlight annotation directly to the PDF file, and then copies the link to the created annotation.',"2. **Copy link to current page view:** Copies a link, clicking which will open the PDF file at the current scroll position and zoom level.","",'After running this command, you can add the copied link to the PDF file itself: select a range of text, right-click, and then click "Paste copied link to selection".'],d.descEl)}).then(d=>this.addHotkeySettingButton(d,`${this.plugin.manifest.name}: Copy link`)),this.addSetting().setName("Further workflow enhancements").setDesc(createFragment(d=>{d.appendText("See the "),d.appendChild(this.createLinkToHeading("auto",'"Auto-copy / auto-focus / auto-paste"')),d.appendText(" section below.")})),this.addHeading("Other shortcut commands","other-hotkeys","lucide-layers-2"),this.addSetting().then(d=>{this.renderMarkdown(["PDF++ also offers the following commands for reducing mouse clicks on the PDF toolbar by assigning hotkeys to them.","","- **Show outline** / **show thumbnail**","- **Close PDF siderbar**","- **Zoom in** / **zoom out**","- **Fit width** / **fit height**","- **Go to page**: This command brings the cursor to the page number input field in the PDF toolbar. Enter a page number and press Enter to jump to the page.","- **Show copy format menu** / **show display text format menu**: By running thes commands via hotkeys and then using the arrow keys, you can quickly select a format from the menu without using the mouse.","- **Enable PDF edit** / **disable PDF edit**","- And more..."],d.descEl)}).then(d=>this.addHotkeySettingButton(d)),this.addToggleSetting("executeBuiltinCommandForOutline").setName(`Show outline: when the active file is not PDF, run the core Outline plugin's "Show outline" command`).setDesc("By turning this on, you can use the same hotkey to show the outline of a markdown file and a PDF file without key conflict."),this.addToggleSetting("closeSidebarWithShowCommandIfExist").setName("Show outline / show thumbnail: close the sidebar if it is already open").setDesc("Enabling this will allow you to use the same hotkey to close the sidebar if it is already open."),this.addToggleSetting("executeBuiltinCommandForZoom").setName('Zoom in / zoom out: when the active file is not PDF, run the built-in "Zoom in" / "Zoom out" command').setDesc("By turning this on, you can use the same hotkey to zoom in/out a PDF viewer or any other type of view without key conflict."),this.addToggleSetting("executeFontSizeAdjusterCommand").setName(`Zoom in / zoom out: when the active file is not PDF, run Font Size Adjuster's "Increment font size" / "Decrement font size" command`).then(d=>{this.renderMarkdown(["(Requires the [Font Size Adjuster](obsidian://show-plugin?id=font-size) plugin enabled) ",'If both of this option and the above option are enabled, this option will be prioritized. The built-in "Zoom in" / "Zoom out" command will be executed if Font Size Adjuster is not installed or disabled.'],d.descEl)}),this.addHeading("Copy templates","template","lucide-copy").setDesc("The template format that will be used when copying a link to a selection or an annotation in PDF viewer. "),this.addSetting().then(d=>this.renderMarkdown(["Each `{{...}}` will be evaluated as a JavaScript expression given the variables listed below.","","Available variables are:","","- `file` or `pdf`: The PDF file ([`TFile`](https://docs.obsidian.md/Reference/TypeScript+API/TFile)). Use `file.basename` for the file name without extension, `file.name` for the file name with extension, `file.path` for the full path relative to the vault root, etc.","- `page`: The page number (`Number`). The first page is always page 1.","- `pageLabel`: The page number displayed in the counter in the toolbar (`String`). This can be different from `page`.",` - **Tip**: You can modify page labels with PDF++'s "Edit page labels" command.`,"- `pageCount`: The total number of pages (`Number`).","- `text` or `selection`: The selected text (`String`). In the case of links to annotations written directly in the PDF file, this is the text covered by the annotation.",'- `comment`: In the case of links to annotations written directly in the PDF file, this is the comment associated with the annotation (`String`). Otherwise, it is an empty string `""`.',"- `folder`: The folder containing the PDF file ([`TFolder`](https://docs.obsidian.md/Reference/TypeScript+API/TFolder)). This is an alias for `file.parent`.","- `obsidian`: The Obsidian API. See the [official developer documentation](https://docs.obsidian.md/Home) and the type definition file [`obsidian.d.ts`](https://github.com/obsidianmd/obsidian-api/blob/master/obsidian.d.ts) for the details.","- `dv`: Available if the [Dataview](obsidian://show-plugin?id=dataview) plugin is enabled. See Dataview's [official documentation](https://blacksmithgu.github.io/obsidian-dataview/api/code-reference/) for the details. You can use it almost the same as the `dv` variable available in `dataviewjs` code blocks, but there are some differences. For example, `dv.current()` is not available.","- `quickAddApi`: Available if the [QuickAdd](obsidian://show-plugin?id=quickadd) plugin is enabled. See QuickAdd's [official documentation](https://quickadd.obsidian.guide/docs/QuickAddAPI) for the details.","- `app`: The global Obsidian app object ([`App`](https://docs.obsidian.md/Reference/TypeScript+API/App)).","- and other global variables such as:",' - [`moment`](https://momentjs.com/docs/#/displaying/): For exampe, use `moment().format("YYYY-MM-DD")` to get the current date in the "YYYY-MM-DD" format.',"",`Additionally, you have access to the following variables when the PDF file has a corresponding markdown file specified via the "${this.plugin.settings.proxyMDProperty}" property(see the "Property to associate a markdown file to a PDF file" setting below): `,"","- `md`: The markdown file associated with the PDF file ([`TFile`](https://docs.obsidian.md/Reference/TypeScript+API/TFile)). If there is no such file, this is `null`.","- `properties`: The properties of `md` as an `Object` mapping each property name to the corresponding value. If `md` is `null` or the `md` has no properties, this is an empty object `{}`.","","Furthermore, the following variables are available when the PDF tab is linked to another tab:","","- `linkedFile`: The file opened in the linked tab ([`TFile`](https://docs.obsidian.md/Reference/TypeScript+API/TFile)). If there is no such file, this is `null`.","- `linkedFileProperties`: The properties of `linkedFile` as an `Object` mapping each property name to the corresponding value. If there is no `linkedFile` or the `linkedFile` has no properties, this is an empty object `{}`."],d.descEl)),this.addTextSetting("proxyMDProperty",void 0,()=>this.redisplay()).setName("Property to associate a markdown file to a PDF file").then(d=>{this.renderMarkdown(["Create a markdown file with this property to associate it with a PDF file. The PDF file is specified by a link, e.g. `[[file.pdf]]`.","It can be used to store properties/metadata that can be used when copying links.","","If you have the [Dataview](obsidian://show-plugin?id=dataview) plugin installed, you can use Dataview's inline field syntax such as `"+this.plugin.settings.proxyMDProperty+":: [[file.pdf]]`.","","Remarks:","- Make sure the associated markdown file can be uniquely identified. For example, if you have two markdown files `file1.md` and `file2.md` and both of their `"+this.plugin.settings.proxyMDProperty+"` properties point to the same PDF file, PDF++ cannot determine which markdown file is associated with `file.pdf`.","- If you are in Source Mode and using front matter instead of Dataview inline fields, be sure to enclose the link in double quotes."],d.descEl)}),this.addSetting("displayTextFormats").setName("Display text format").then(d=>this.renderMarkdown(["This format will be also used when copying a link to a selection or an annotation from the context menu."],d.descEl)).addButton(d=>{d.setIcon("plus").setTooltip("Add a new display text format").onClick(()=>{this.plugin.settings.displayTextFormats.push({name:"",template:""}),this.redisplay()})});for(let d=0;dd.name),void 0,()=>{this.plugin.loadStyle()}).setName("Default display text format"),this.addToggleSetting("syncDisplayTextFormat").setName("Share a single display text format among all PDF viewers").setDesc("If disabled, you can specify a different display text format for each PDF viewer from the dropdown menu in the PDF toolbar."),this.plugin.settings.syncDisplayTextFormat&&this.addToggleSetting("syncDefaultDisplayTextFormat").setName("Share the display text format with newly opened PDF viewers as well"),this.addSetting("copyCommands").setName("Custom copy formats").then(d=>this.renderMarkdown(["Customize the format to use when you copy a link by clicking a color palette item or running the commands while selecting a range of text in PDF viewer.","","In addition to the variables listed above, here you can use","","- `link`: The link without display text, e.g. `[[file.pdf#page=1&selection=0,1,2,3&color=red]]`,","- `linkWithDisplay`: The link with display text, e.g. `[[file.pdf#page=1&selection=0,1,2,3&color=red|file, page 1]]`,",'- `linktext`: The text content of the link without brackets and the display text, e.g. `file.pdf#page=1&selection=0,1,2,3&color=red`
(if the "Use \\[\\[Wikilinks\\]\\]" setting is turned off, `linktext` will be properly encoded for use in markdown links),',"- `display`: The display text formatted according to the above setting, e.g. `file, page 1`,","- `linkToPage`: The link to the page without display text, e.g. `[[file.pdf#page=1]]`,","- `linkToPageWithDisplay`: The link to the page with display text, e.g. `[[file.pdf#page=1|file, page 1]]`,",`- \`calloutType\`: The callout type you specify in the "Callout type name" setting above, in this case, "${this.plugin.settings.calloutType}", and`,"- `color` (or `colorName`): In the case of text selections, this is the name of the selected color in lowercase, e.g. `red`. If no color is specified, it will be an empty string. For text markup annotations (e.g. highlights and underlines), this is the RGB value of the color, e.g. `255,208,0`."],d.descEl)).addButton(d=>{d.setIcon("plus").setTooltip("Add a new copy command").onClick(()=>{this.plugin.settings.copyCommands.push({name:"",template:""}),this.redisplay()})});for(let d=0;dd.name),void 0,()=>{this.plugin.loadStyle()}).setName("Default action when clicking on color palette"),this.addToggleSetting("syncColorPaletteAction").setName("Share a single action among all PDF viewers").setDesc("If disabled, you can specify a different action for each PDF viewer from the dropdown menu in the PDF toolbar."),this.plugin.settings.syncColorPaletteAction&&this.addToggleSetting("syncDefaultColorPaletteAction").setName("Share the action with newly opened PDF viewers as well"),this.addToggleSetting("useAnotherCopyTemplateWhenNoSelection",()=>this.redisplay()).setName("Use another template when no text is selected").setDesc("For example, you can use this to copy a link to the page when there is no selection."),this.plugin.settings.useAnotherCopyTemplateWhenNoSelection&&this.addTextSetting("copyTemplateWhenNoSelection").setName("Link copy template used when no text is selected"),this.addHeading("Auto-copy / auto-focus / auto-paste","auto","lucide-zap").setDesc("Speed up the process of copying & pasting PDF links to your notes with some automation. Note that you can't activate both of auto-focus and auto-paste at the same time."),this.addHeading("Auto-copy","auto-copy").setDesc(`If enabled, the "Copy link to selection or annotation" command will be triggered automatically every time you select a range of text in a PDF viewer, meaning you don't even have to press a hotkey to copy a link.`),this.addToggleSetting("autoCopy",()=>this.plugin.autoCopyMode.toggle(this.plugin.settings.autoCopy)).setName("Enable").setDesc("You can also toggle auto-focus via an icon in the left ribbon menu if the next setting is enabled."),this.addToggleSetting("autoCopyToggleRibbonIcon",()=>this.redisplay()).setName("Show an icon to toggle auto-copy in the left ribbon menu").setDesc("You can also toggle this mode via a command. Reload the plugin after changing this setting to take effect."),this.plugin.settings.autoCopyToggleRibbonIcon&&this.addIconSetting("autoCopyIconName",!1).setName("Icon name").then(d=>{d.descEl.appendText(" Reload the plugin after changing this setting to take effect.")}),this.addHeading("Auto-focus","auto-focus").setDesc("If enabled, a markdown file will be focused automatically after copying a link to PDF text selection or annotation."),this.addSetting("autoFocus").setName("Enable").setDesc("Recommended if you prefer something less agressive than auto-paste. You can also toggle auto-focus via an icon in the left ribbon menu if the next setting is enabled.").addToggle(d=>{d.setValue(this.plugin.settings.autoFocus).onChange(h=>{this.plugin.toggleAutoFocus(h),this.redisplay()})}),this.addToggleSetting("autoFocusToggleRibbonIcon",()=>this.redisplay()).setName("Show an icon to toggle auto-focus in the left ribbon menu").setDesc("You can also toggle auto-focus via a command. Reload the plugin after changing this setting to take effect."),this.plugin.settings.autoFocusToggleRibbonIcon&&this.addIconSetting("autoFocusIconName",!1).setName("Icon name").then(d=>{d.descEl.appendText(" Reload the plugin after changing this setting to take effect.")}),this.addDropdownSetting("autoFocusTarget",yx).setName("Target markdown file to focus on"),this.addHeading("Auto-paste","auto-paste").setDesc("If enabled, the copied link to PDF text selection or annotation will be automatically pasted into a markdown file right after copying."),this.addSetting("autoPaste").setName("Enable").setDesc("You can also toggle auto-paste via an icon in the left ribbon menu if the next setting is enabled.").addToggle(d=>{d.setValue(this.plugin.settings.autoPaste).onChange(h=>{this.plugin.toggleAutoPaste(h),this.redisplay()})}),this.addToggleSetting("autoPasteToggleRibbonIcon",()=>this.redisplay()).setName("Show an icon to toggle auto-paste in the left ribbon menu").setDesc("You can also toggle auto-paste via a command. Reload the plugin after changing this setting to take effect."),this.plugin.settings.autoPasteToggleRibbonIcon&&this.addIconSetting("autoPasteIconName",!1).setName("Icon name").then(d=>{d.descEl.appendText(" Reload the plugin after changing this setting to take effect.")}),this.addDropdownSetting("autoPasteTarget",yx).setName("Target markdown file to paste links to"),this.addToggleSetting("focusEditorAfterAutoPaste",()=>this.events.trigger("update")).setName("Focus editor after auto-pasting").setDesc("If enabled, auto-paste will focus on the editor after pasting."),this.showConditionally(this.addToggleSetting("clearSelectionAfterAutoPaste").setName("Clear text selection after auto-pasting").setDesc("If enabled, the text selection in the PDF viewer will be automatically cleared after performing auto-pasting."),()=>!this.plugin.settings.focusEditorAfterAutoPaste),this.addToggleSetting("respectCursorPositionWhenAutoPaste").setName("Respect current cursor position").setDesc("When enabled, triggering auto-pasting will paste the copied text at the current cursor position if the target note is already opened. If disabled, the text will be always appended to the end of the note."),this.addHeading("General","auto-general").setDesc("General settings that apply to both auto-focus and auto-paste."),this.addToggleSetting("openAutoFocusTargetIfNotOpened",()=>this.redisplay()).setName("Open target markdown file if not opened"),this.plugin.settings.openAutoFocusTargetIfNotOpened&&(this.addDropdownSetting("howToOpenAutoFocusTargetIfNotOpened",{...yh,"hover-editor":"Hover Editor"},()=>this.redisplay()).setName("How to open target markdown file when not opened").then(d=>{this.renderMarkdown('The "Hover Editor" option is available if the [Hover Editor](obsidian://show-plugin?id=obsidian-hover-editor) plugin is enabled.',d.descEl),this.plugin.settings.howToOpenAutoFocusTargetIfNotOpened==="hover-editor"&&(this.app.plugins.plugins["obsidian-hover-editor"]||d.descEl.addClass("error"))}),this.showConditionally(this.addToggleSetting("closeHoverEditorWhenLostFocus").setName("Close Hover Editor when it loses focus").setDesc("This option will not affect the behavior of Hover Editor outside of PDF++."),()=>this.plugin.settings.howToOpenAutoFocusTargetIfNotOpened==="hover-editor"),this.addToggleSetting("closeSidebarWhenLostFocus").setName("Auto-hide sidebar when it loses focus after auto-pasting").setDesc("After auto-pasting into a markdown file opened in the left or right sidebar, the sidebar will be automatically collapsed once it loses focus."),this.addToggleSetting("openAutoFocusTargetInEditingView").setName("Always open in editing view").setDesc('This option can be useful especially when you set the previous option to "Hover Editor".')),this.addToggleSetting("executeCommandWhenTargetNotIdentified",()=>this.redisplay()).setName("Execute command when target file cannot be determined").setDesc("When PDF++ cannot determine which markdown file to focus on or paste to, it will execute the command specified in the next option to let you pick a target file.");let s=(l=(c=this.app.commands.findCommand(`${this.plugin.manifest.id}:create-new-note`))==null?void 0:c.name)!=null?l:"PDF++: Create new note for auto-focus or auto-paste";this.plugin.settings.executeCommandWhenTargetNotIdentified&&(this.addSetting("commandToExecuteWhenTargetNotIdentified").setName("Command to execute").then(d=>{var h,u,f,p,g,m;this.renderMarkdown(["Here's some examples of useful commands:","",`- ${(u=(h=this.app.commands.findCommand("file-explorer:new-file"))==null?void 0:h.name)!=null?u:"Create new note"}`,`- ${(p=(f=this.app.commands.findCommand("file-explorer:new-file-in-new-pane"))==null?void 0:f.name)!=null?p:"Create note to the right"}`,`- ${(m=(g=this.app.commands.findCommand("switcher:open"))==null?void 0:g.name)!=null?m:"Quick switcher: Open quick switcher"}`,"- [Omnisearch](obsidian://show-plugin?id=omnisearch): Vault search","- [Hover Editor](obsidian://show-plugin?id=obsidian-hover-editor): Open new Hover Editor",`- **${s}**: See below for the details.`],d.descEl)}).addText(d=>{let h=this.plugin.settings.commandToExecuteWhenTargetNotIdentified,u=this.app.commands.findCommand(h);u?d.setValue(u.name):(d.inputEl.addClass("error"),d.setPlaceholder("Command not found")),d.inputEl.size=30,new wc(this,d.inputEl)}),this.addSliderSetting("autoPasteTargetDialogTimeoutSec",1,60,1).setName("[Auto-paste] Maximum time to wait for the command to open the target file (sec)").setDesc("The link will be auto-pasted into the first markdown file that you open within this time frame after the command is executed. If you don't open any markdown file during this time, the auto-paste will not occur. This option is not related to auto-focus.")),this.addHeading(`The "${s}" command`,"create-new-note-command").setDesc('Creates a new note and opens it in a new pane specified in the "How to open target markdown file when not opened" option.'),this.addTextSetting("newFileNameFormat","Leave blank not to specify").setName("New note title format").then(async d=>{await this.renderMarkdown(['If this option is left blank or the active file is not a PDF, "Untitled \\*" will be used (if the language is set to English). You can use the following variables: `file`, `folder`, `app`, and other global variables such as `moment`.'],d.descEl),d.descEl.createSpan({text:"See "}),d.descEl.appendChild(this.createLinkToHeading("template","above")),d.descEl.createSpan({text:" for the details about these variables."})}),this.addTextSetting("newFileTemplatePath","Leave blank not to use a template").setName("Template file path").then(async d=>{await this.renderMarkdown(["You can leave this blank if you don't want to use a template.","You can use `file`, `folder`, `app`, and other global variables such as `moment`."],d.descEl),d.descEl.createSpan({text:"See "}),d.descEl.appendChild(this.createLinkToHeading("template","above")),d.descEl.createSpan({text:" for the details about these variables."}),await this.renderMarkdown(["You can also include [Templater](obsidian://show-plugin?id=templater-obsidian) syntaxes in the template.",'In that case, make sure the "Trigger templater on new file creation" option is enabled in the Templater settings.',"","Example:","```","---",`${this.plugin.settings.proxyMDProperty}: "[[{{ file.path }}|{{ file.basename }}]]"`,"---",'<%* const title = await tp.system.prompt("Type note tile") -%>',"<%* await tp.file.rename(title) %>","```"],d.descEl);let h=d.components[0].inputEl;new xc(this.app,h).onSelect(({item:u})=>{this.plugin.settings.newFileTemplatePath=u.path,this.plugin.saveSettings()})}),this.addHeading("PDF Annotations","annot","lucide-message-square"),this.addToggleSetting("annotationPopupDrag").setName("Drag & drop annotation popup to insert a link to the annotation").setDesc("Note that turning on this option disables text selection in the annotation popup (e.g. modified date, author, etc)."),this.addToggleSetting("showAnnotationPopupOnHover").setName("If an annotation has a comment, show the annotation popup on hover").setDesc("This is the same behavior as the PDF viewers of some web browsers (e.g. Chrome/Firefox). You may have to reopen the PDF file after changing this option."),this.addToggleSetting("renderMarkdownInStickyNote").setName("Render markdown in annotation popups when the annotation has text contents"),this.plugin.settings.enablePDFEdit&&(this.addSliderSetting("writeHighlightToFileOpacity",0,1,.01).setName("Highlight opacity"),this.addToggleSetting("defaultWriteFileToggle").setName("Write highlight to file by default").setDesc("You can turn this on and off with the toggle button in the PDF viewer toolbar."),this.addToggleSetting("syncWriteFileToggle").setName("Share the same toggle state among all PDF viewers").setDesc("If disabled, you can specify whether to write highlights to files for each PDF viewer."),this.plugin.settings.syncWriteFileToggle&&this.addToggleSetting("syncDefaultWriteFileToggle").setName("Share the state with newly opened PDF viewers as well"),this.addToggleSetting("enableAnnotationContentEdit",()=>this.redisplay()).setName("Enable editing annotation contents").setDesc('If enabled, you can edit the text contents of annotations embedded in PDF files by clicking the "Edit" button in the annotation popup.'),this.addToggleSetting("enableAnnotationDeletion",()=>this.redisplay()).setName("Enable annotation deletion").setDesc('If enabled, you can delete annotations embedded in PDF files by clicking the "Delete" button in the annotation popup.'),this.plugin.settings.enableAnnotationDeletion&&(this.addToggleSetting("warnEveryAnnotationDelete",()=>this.redisplay()).setName("Always warn when deleting an annotation"),this.plugin.settings.warnEveryAnnotationDelete||this.addToggleSetting("warnBacklinkedAnnotationDelete").setName("Warn when deleting an annotation with backlinks"))),this.addHeading("PDF internal links","pdf-link","link").setDesc("Make it easier to work with internal links embedded in PDF files."),this.addToggleSetting("clickPDFInternalLinkWithModifierKey").then(d=>{this.renderMarkdown("Use [modifier keys](https://help.obsidian.md/User+interface/Tabs#Open+a+link) to open PDF internal links in various ways",d.nameEl)}).then(d=>{this.plugin.requireModKeyForLinkHover(Yi.HOVER_LINK_SOURCE_ID)&&d.setDesc(`You may want to turn this off to avoid conflicts with hover+${Bn}.`),d.descEl.appendText("Reopen tabs or reload the app after changing this option.")}),this.addToggleSetting("enableHoverPDFInternalLink",()=>this.events.trigger("update")).setName(`Show a popover preview of PDF internal links by hover(+${Bn})`),this.showConditionally(this.addRequireModKeyOnHoverSetting(Yi.HOVER_LINK_SOURCE_ID),()=>this.plugin.settings.enableHoverPDFInternalLink),this.addToggleSetting("recordPDFInternalLinkHistory").setName("Enable history navigation for PDF internal links").setDesc('When enabled, clicking the "navigate back" (left arrow) button will take you back to the page you were originally viewing before clicking on an internal link in the PDF file.'),this.addSetting().setName("Copy PDF link as Obsidian link").setDesc('(Requires custom context menu enabled) In the PDF viewer, right-click a PDF-embedded link and then click "Copy PDF link as Obsidian link". It will copy the PDF link as an Obsidian link that you can paste into markdown files. Clicking the pasted link will take you to the same destination as the original PDF link.'),this.addSetting().setName('"Copy link to current page view" command').setDesc("Running this command while viewing a PDF file will copy a link, clicking which will open the PDF file at the current scroll position and zoom level."),this.addSetting().setName("Paste copied link to a text selection in a PDF file").setDesc('(Requires custom context menu & PDF editing enabled) After copying a link by the above actions, you can "paste" it to a selection in PDF to create a PDF internal link. To do this, right-click the selection and click "Paste copied link to selection".'),this.plugin.settings.replaceContextMenu&&this.plugin.settings.enablePDFEdit&&(this.addToggleSetting("pdfLinkBorder",()=>this.redisplay()).setName("Draw borders around internal links").setDesc('Specify whether PDF internal links that you create by "Paste copied link to selection" should be surrounded by borders.'),this.plugin.settings.pdfLinkBorder&&this.addColorPickerSetting("pdfLinkColor").setName("Border color of internal links").setDesc('Specify the border color of PDF internal links that you create by "Paste copied link to selection".')),this.addHeading("Citations in PDF (experimental)","citation","lucide-graduation-cap").then(d=>{this.renderMarkdown(["Enjoy supercharged experiences of working with citations in PDF files, just like in [Google Scholar's PDF viewer](https://scholar.googleblog.com/2024/03/supercharge-your-pdf-reading-follow.html).","","The current implementation is based on some pretty primitive hand-crafted rules, and there is a lot of room for improvement. Code contribution is much appreciated!"],d.descEl)}),this.addDropdownSetting("actionOnCitationHover",eg,()=>this.events.trigger("update")).setName(`Hover(+${Bn}) on a citation link to show...`).then(d=>{this.renderMarkdown([`- **${eg["pdf-plus-bib-popover"]}**: Recommended. It works without any additional stuff, but you can further boost the visibility by installing [AnyStyle](https://github.com/inukshuk/anystyle) (desktop only).`,`- **${eg["google-scholar-popover"]}**: Requires [Surfing](obsidian://show-plugin?id=surfing) ver. 0.9.9 or higher enabled. Be careful not to exceed the rate limit of Google Scholar.`],d.descEl)}),this.showConditionally(this.addRequireModKeyOnHoverSetting(Ci.HOVER_LINK_SOURCE_ID),()=>this.plugin.settings.actionOnCitationHover!=="none"),this.showConditionally(this.addSetting("anystylePath").setName("AnyStyle path").addText(d=>{d.setPlaceholder("anystyle").setValue(this.plugin.settings.anystylePath).onChange(h=>{this.plugin.settings.anystylePath=h,this.plugin.saveLocalStorage("anystylePath",h)})}).then(d=>{d.components[0].inputEl.size=35,this.renderMarkdown(["The path to the [AnyStyle](https://github.com/inukshuk/anystyle) executable. ","","PDF++ extracts the bibliography text from the PDF file for each citation link and uses AnyStyle to convert the extracted text into a structured metadata.","It works just fine without AnyStyle, but you can further boost the visibility by installing it and providing its path here.","","Note: This setting is saved in the [local storage](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) instead of `data.json` in the plugin folder."],d.descEl)}),()=>se.Platform.isDesktopApp&&this.plugin.settings.actionOnCitationHover==="pdf-plus-bib-popover"),this.showConditionally([this.addDesc("Try turning off the following options if you experience performance issues."),this.addToggleSetting("enableBibInEmbed").setName("Enable bibliography extraction in PDF embeds"),this.addToggleSetting("enableBibInCanvas").setName("Enable bibliography extraction in Canvas"),this.addToggleSetting("enableBibInHoverPopover").setName("Enable bibliography extraction in hover popover previews")],()=>this.plugin.settings.actionOnCitationHover!=="none"),this.addHeading("External links in PDF","pdf-external-link","external-link").setDesc("Make it easier to work with external links embedded in PDF files."),this.addToggleSetting("popoverPreviewOnExternalLinkHover").setName(`Show a popover preview of external links by hover(+${Bn})`).then(d=>{this.renderMarkdown(["Requires [Surfing](obsidian://show-plugin?id=surfing) ver. 0.9.9 or higher enabled."],d.descEl)}),this.showConditionally(this.addRequireModKeyOnHoverSetting(Vn.HOVER_LINK_SOURCE_ID),()=>this.plugin.settings.popoverPreviewOnExternalLinkHover),this.addHeading("PDF sidebar","sidebar","sidebar-left").setDesc("General settings for the PDF sidebar. The options specific to the outline and thumbnails are located in the corresponding sections below."),this.addToggleSetting("autoHidePDFSidebar").setName("Click on PDF content to hide sidebar").setDesc("Requires reopening the tabs after changing this option."),this.addEnumDropdownSetting("defaultSidebarView",{[1]:"Thumbnails",[2]:"Outline"}).setName("Default sidebar view").setDesc("Reopen PDFs after changing this option."),this.addHeading("PDF outline (table of contents)","outline","lucide-list").setDesc('Power up the outline view of the built-in PDF viewer: add, rename, or delete items via the right-click menu and the "Add to outline" command, drag & drop items to insert a section link, and more.'),this.addToggleSetting("clickOutlineItemWithModifierKey").then(d=>{this.renderMarkdown("Click PDF outline with [modifier keys](https://help.obsidian.md/User+interface/Tabs#Open+a+link) to open target section in various ways",d.nameEl)}).then(d=>{this.plugin.requireModKeyForLinkHover(Ji.HOVER_LINK_SOURCE_ID)&&d.setDesc(`You may want to turn this off to avoid conflicts with hover+${Bn}.`),d.descEl.appendText("Reopen tabs or reload the app after changing this option.")}),this.addToggleSetting("popoverPreviewOnOutlineHover",()=>this.events.trigger("update")).setName(`Show popover preview by hover(+${Bn})`).setDesc("Reopen tabs or reload the app after changing this option."),this.showConditionally(this.addRequireModKeyOnHoverSetting(Ji.HOVER_LINK_SOURCE_ID),()=>this.plugin.settings.popoverPreviewOnOutlineHover),this.addToggleSetting("recordHistoryOnOutlineClick").setName("Record to history when clicking an outline item").setDesc("Reopen tabs or reload the app after changing this option."),this.addToggleSetting("outlineContextMenu").setName("Replace the built-in context menu in the outline with a custom one").setDesc("This enables you to insert a section link with a custom format by right-clicking an item in the outline. Moreover, you will be able to add, rename, or delete outline items if PDF modification is enabled."),this.addToggleSetting("outlineDrag").setName("Drag & drop outline item to insert link to section").setDesc("Grab an item in the outline and drop it to a markdown file to insert a section link. Changing this option requires reopening the tabs or reloading the app."),(this.plugin.settings.outlineContextMenu||this.plugin.settings.outlineDrag)&&(this.addTextSetting("outlineLinkDisplayTextFormat").setName("Display text format").then(d=>{let h=d.components[0];h.inputEl.size=30}),this.addTextAreaSetting("outlineLinkCopyFormat").setName("Copy format").then(d=>{let h=d.components[0];h.inputEl.rows=3,h.inputEl.cols=30})),this.addHeading("Copy outline as markdown","outline-copy").setDesc('You can copy PDF outline as a markdown list or headings using the commands "Copy outline as markdown list" and "Copy outline as markdown headings".'),this.addTextSetting("copyOutlineAsListDisplayTextFormat").setName("List: display text format").then(d=>{let h=d.components[0];h.inputEl.size=30}),this.addTextAreaSetting("copyOutlineAsListFormat").setName("List: copy format").setDesc("You don't need to include leading hyphens in the template.").then(d=>{let h=d.components[0];h.inputEl.rows=3,h.inputEl.cols=30}),this.addTextSetting("copyOutlineAsHeadingsDisplayTextFormat").setName("Headings: display text format").then(d=>{let h=d.components[0];h.inputEl.size=30}),this.addTextAreaSetting("copyOutlineAsHeadingsFormat").setName("Headings: copy format").setDesc("You don't need to include leading hashes in the template.").then(d=>{let h=d.components[0];h.inputEl.rows=3,h.inputEl.cols=30}),this.addSliderSetting("copyOutlineAsHeadingsMinLevel",1,6,1).setName("Headings: minimum level").setDesc("The copied headings will start at this level."),this.addHeading("PDF thumbnails","thumbnail","lucide-gallery-thumbnails"),this.addToggleSetting("clickThumbnailWithModifierKey").then(d=>{this.renderMarkdown("Click PDF thumbnails with [modifier keys](https://help.obsidian.md/User+interface/Tabs#Open+a+link) to open target page in various ways",d.nameEl)}).then(d=>{this.plugin.requireModKeyForLinkHover(Qi.HOVER_LINK_SOURCE_ID)&&d.setDesc(`You may want to turn this off to avoid conflicts with hover+${Bn}`),d.descEl.appendText("Reopen tabs or reload the app after changing this option.")}),this.addToggleSetting("popoverPreviewOnThumbnailHover",()=>this.events.trigger("update")).setName(`Show popover preview by hover(+${Bn})`).setDesc("Reopen tabs or reload the app after changing this option."),this.showConditionally(this.addRequireModKeyOnHoverSetting(Qi.HOVER_LINK_SOURCE_ID),()=>this.plugin.settings.popoverPreviewOnThumbnailHover),this.addToggleSetting("recordHistoryOnThumbnailClick").setName("Record to history when clicking a thumbnail").setDesc("Reopen tabs or reload the app after changing this option."),this.addToggleSetting("thumbnailContextMenu").setName("Replace the built-in context menu in thumbnails with a custom one").setDesc("This enables you to copy a page link with a custom display text format specified in the PDF toolbar by right-clicking a thumbnail. Moreover, you will be able to insert, delete, extract pages if PDF modification is enabled."),this.addToggleSetting("thumbnailDrag").setName("Drag & drop PDF thumbnail to insert link to page").then(d=>{this.renderMarkdown(["Grab a thumbnail image and drop it to a markdown file to insert a page link. Changing this option requires reopening the tabs or reloading the app.","","Note: When disabled, drag-and-drop will cause the thumbnail image to be paste as a data url, which is seemingly Obsidian's bug."],d.descEl)}),(this.plugin.settings.thumbnailContextMenu||this.plugin.settings.thumbnailDrag)&&(this.addTextSetting("thumbnailLinkDisplayTextFormat").setName("Display text format").then(d=>{let h=d.components[0];h.inputEl.size=30}),this.addTextAreaSetting("thumbnailLinkCopyFormat").setName("Copy format").then(d=>{let h=d.components[0];h.inputEl.rows=3,h.inputEl.cols=30})),this.addHeading("PDF page composer (experimental)","composer","lucide-blocks").then(d=>{this.renderMarkdown(['Add, insert, delete or extract PDF pages via commands and **automatically update all the related links in the entire vault**. The "Editing PDF files directly" option has to be enabled to use these features.'],d.descEl)}),this.addToggleSetting("warnEveryPageDelete",()=>this.redisplay()).setName("Always warn when deleting a page"),this.plugin.settings.warnEveryPageDelete||this.addToggleSetting("warnBacklinkedPageDelete").setName("Warn when deleting a page with backlinks"),this.addToggleSetting("extractPageInPlace").setName("Remove the extracted pages from the original PDF by default"),this.addToggleSetting("askExtractPageInPlace").setName("Ask whether to remove the extracted pages from the original PDF before extracting"),this.addToggleSetting("openAfterExtractPages",()=>this.redisplay()).setName("Open extracted PDF file").setDesc('If enabled, the newly created PDF file will be opened after running the commands "Extract this page to a new file" or "Divide this PDF into two files at this page".'),this.plugin.settings.openAfterExtractPages&&this.addDropdownSetting("howToOpenExtractedPDF",yh).setName("How to open"),this.addHeading("Page labels","page-label").then(d=>{this.renderMarkdown(["Each page in a PDF document can be assigned a ***page label***, which can be different from the page indices.",'For example, a book might have a preface numbered as "i", "ii", "iii", ... and the main content numbered as "1", "2", "3", ...',"","PDF++ allows you to choose whether page labels should be kept unchanged or updated when inserting/removing/extracting pages. [Learn more](https://github.com/RyotaUshio/obsidian-pdf-plus/wiki/Page-labels)","",'You can also modify page labels directly using the command "Edit page labels".'],d.descEl)}),this.addDropdownSetting("pageLabelUpdateWhenInsertPage",Mc).setName("Insert: default page label processing").setDesc('Applies to the commands "Insert page before/after this page".'),this.addToggleSetting("askPageLabelUpdateWhenInsertPage").setName("Insert: ask whether to update"),this.addDropdownSetting("pageLabelUpdateWhenDeletePage",Mc).setName("Delete: default page label processing").setDesc('Applies to the command "Delete this page".'),this.addToggleSetting("askPageLabelUpdateWhenDeletePage").setName("Delete: ask whether to update"),this.addDropdownSetting("pageLabelUpdateWhenExtractPage",Mc).setName("Extract: default page label processing").setDesc('Applies to the commands "Extract this page to a new file" and "Divide this PDF into two files at this page".'),this.addToggleSetting("askPageLabelUpdateWhenExtractPage").setName("Extract: ask whether to update"),this.addHeading("Opening links to PDF files","open-link","lucide-book-open"),this.addToggleSetting("alwaysRecordHistory").setName("Always record to history when opening PDF links").setDesc("By default, the history is recorded only when you open a link to a different PDF file. If enabled, the history will be recorded even when you open a link to the same PDF file as the current one, and you will be able to go back and forth the history by clicking the left/right arrow buttons even within a single PDF file."),this.addToggleSetting("singleTabForSinglePDF",()=>this.redisplay()).setName("Don't open a single PDF file in multiple tabs").then(d=>this.renderMarkdown('When opening a link to a PDF file without pressing any [modifier keys](https://help.obsidian.md/User+interface/Use+tabs+in+Obsidian#Open+a+link), a new tab will not be opened if the same file has already been already opened in another tab. Useful for annotating PDFs using a side-by-side view ("Split right"), displaying a PDF in one side and a markdown file in another.',d.descEl)),this.plugin.settings.singleTabForSinglePDF&&(this.addToggleSetting("dontActivateAfterOpenPDF").setName("Don't move focus to PDF viewer after opening a PDF link").setDesc("This option will be ignored when you open a PDF link in a tab in the same split as the PDF viewer."),this.addToggleSetting("highlightExistingTab",()=>this.redisplay()).setName("When opening a link to an already opened PDF file, highlight the tab"),this.plugin.settings.highlightExistingTab&&(this.addSliderSetting("existingTabHighlightOpacity",0,1,.01).setName("Highlight opacity of an existing tab"),this.addSliderSetting("existingTabHighlightDuration",.1,10,.05).setName("Highlight duration of an existing tab (sec)")),this.addToggleSetting("dontFitWidthWhenOpenPDFLink",()=>this.events.trigger("update")).setName("Preserve the current zoom level when opening a link to an already opened PDF file").setDesc("When you open a link to a PDF file that's already opened, Obsidian's default behavior causes the zoom level to be reset to fit the width of the PDF file to the viewer. If enabled, the current zoom level will be preserved. This option will be ignored in PDF embeds."),this.showConditionally(this.addToggleSetting("preserveCurrentLeftOffsetWhenOpenPDFLink").setName("Preserve the current horizontal scroll position").setDesc("This option will be ignored in PDF embeds."),()=>this.plugin.settings.dontFitWidthWhenOpenPDFLink)),this.addDropdownSetting("paneTypeForFirstPDFLeaf",yh).setName("How to open PDF links when there is no open PDF file").then(d=>{this.renderMarkdown("This option will be ignored when you press [modifier keys](https://help.obsidian.md/User+interface/Use+tabs+in+Obsidian#Open+a+link) to explicitly specify how to open the link.",d.descEl)}),this.addToggleSetting("openLinkNextToExistingPDFTab").setName("Open PDF links next to an existing PDF tab").then(d=>this.renderMarkdown("If there is a PDF file opened in a tab, clicking a PDF link will first create a new tab next to it and then open the target PDF file in the created tab. This is especially useful when you are spliting the workspace vertically or horizontally and want PDF files to be always opened in one side. This option will be ignored when you press [modifier keys](https://help.obsidian.md/User+interface/Use+tabs+in+Obsidian#Open+a+link) to explicitly specify how to open the link.",d.descEl)),this.addToggleSetting("hoverPDFLinkToOpen").setName("Open PDF link instead of showing popover preview when target PDF is already opened").setDesc(`Press ${In("Mod").toLowerCase()} while hovering a PDF link to actually open it if the target PDF is already opened in another tab.`),this.addSetting().setName("Open PDF links with an external app").setDesc(createFragment(d=>{d.appendText("See the "),d.appendChild(this.createLinkToHeading("external-app")),d.appendText(" section for the details.")})),this.addSetting().setName("Clear highlights after a certain amount of time").addToggle(d=>{d.setValue(this.plugin.settings.highlightDuration>0).onChange(async h=>{this.plugin.settings.highlightDuration=h?this.plugin.settings.highlightDuration>0?this.plugin.settings.highlightDuration:1:0,await this.plugin.saveSettings(),this.redisplay()})}),this.plugin.settings.highlightDuration>0&&this.addSliderSetting("highlightDuration",.1,10,.05).setName("Highlight duration (sec)"),this.addToggleSetting("ignoreHeightParamInPopoverPreview").setName('Ignore "height" parameter in popover preview').setDesc('Obsidian lets you specify the height of a PDF embed by appending "&height=..." to a link, and this also applies to popover previews. Enable this option if you want to ignore the height parameter in popover previews.'),this.addHeading("Embedding PDF files","embed","picture-in-picture-2"),this.addToggleSetting("dblclickEmbedToOpenLink",()=>this.plugin.loadStyle()).setName("Double click PDF embeds to open links").setDesc("Double-clicking a PDF embed will open the embedded file."),this.addToggleSetting("trimSelectionEmbed",()=>this.redisplay()).setName("Trim selection/annotation embeds").then(d=>{this.renderMarkdown(['(Deprecated in favor of the rectangular selection embed feature introduced in PDF++ 0.36.0)',"When embedding a selection or an annotation from a PDF file, only the target selection/annotation and its surroundings are displayed rather than the entire page."],d.descEl)}),this.plugin.settings.trimSelectionEmbed&&this.addSliderSetting("embedMargin",0,200,1).setName("Selection/annotation embeds margin (px)"),this.addToggleSetting("noSidebarInEmbed").setName("Hide sidebar in PDF embeds embeds or PDF popover previews by default"),this.addToggleSetting("noSpreadModeInEmbed").setName(`Don't display PDF embeds or PDF popover previews in "two page" layout`).setDesc('Regardless of the "two page" layout setting in existing PDF viewer, PDF embeds and PDF popover previews will be always displayed in "single page" layout. You can still turn it on for each embed by clicking the "two page" button in the toolbar, if shown.'),this.addToggleSetting("noTextHighlightsInEmbed").setName("Don't highlight text in a text selection embeds"),this.addToggleSetting("noAnnotationHighlightsInEmbed").setName("Don't highlight annotations in an annotation embeds"),this.addToggleSetting("persistentTextHighlightsInEmbed").setName("Don't clear highlights in a text selection embeds"),this.addToggleSetting("persistentAnnotationHighlightsInEmbed").setName("Don't clear highlights in an annotation embeds"),this.addToggleSetting("embedUnscrollable").setName("Make PDF embeds with a page specified unscrollable").setDesc("After changing this option, you need to reopen tabs or reload the app."),this.addHeading("Backlinks pane for PDF files","backlink-view","links-coming-in").then(d=>this.renderMarkdown("Improve the built-in [backlinks pane](https://help.obsidian.md/Plugins/Backlinks) for better PDF experience.",d.descEl)),this.addToggleSetting("filterBacklinksByPageDefault").setName("Filter backlinks by page by default").setDesc('You can toggle this on and off with the "Show only backlinks in the current page" button at the top right of the backlinks pane.'),this.addToggleSetting("showBacklinkToPage").setName("Show backlinks to the entire page").setDesc("If turned off, only backlinks to specific text selections, annotations or locations will be shown when filtering the backlinks page by page."),this.addToggleSetting("highlightBacklinksPane").setName("Hover sync (PDF viewer \u2192 Backlinks pane)").setDesc("Hovering your mouse over highlighted text or annotation will also highlight the corresponding item in the backlink pane."),this.addToggleSetting("highlightOnHoverBacklinkPane").setName("Hover sync (Backlinks pane \u2192 PDF viewer)").setDesc("In the backlinks pane, hover your mouse over an backlink item to highlight the corresponding text or annotation in the PDF viewer. This option requires reopening or switching tabs to take effect."),this.plugin.settings.highlightOnHoverBacklinkPane&&this.addDropdownSetting("backlinkHoverColor",["",...Object.keys(this.plugin.settings.colors)],d=>d||"PDF++ default",()=>this.plugin.loadStyle()).setName("Highlight color for hover sync (Backlinks pane \u2192 PDF viewer)").setDesc('To add a new color, click the "+" button in the "highlight colors" setting above.'),this.addHeading("Search from links","search-link","lucide-search").then(d=>{this.renderMarkdown(["You can trigger full-text search by opening a link to a PDF file with a search query appended, e.g. `[[file.pdf#search=keyword]]`."],d.descEl)}),this.addHeading("Search options","search-option").then(d=>{this.renderMarkdown(["The behavior of the search links can be customized globally by the following settings. ","Alternatively, you can specify the behavior for each link by including the following query parameters in the link text: ","","- `&case-sensitive=true` or `&case-sensitive=false`","- `&highlight-all=true` or `&highlight-all=false`","- `&match-diacritics=true` or `&match-diacritics=false`","- `&entire-word=true` or `&entire-word=false`"],d.descEl)});let a={true:"Yes",false:"No",default:"Follow default setting"};this.addDropdownSetting("searchLinkCaseSensitive",a).setName("Case sensitive search"),this.addDropdownSetting("searchLinkHighlightAll",a).setName("Highlight all search results"),this.addDropdownSetting("searchLinkMatchDiacritics",a).setName("Match diacritics"),this.addDropdownSetting("searchLinkEntireWord",a).setName("Match whole word"),this.addHeading("Integration with external apps (desktop-only)","external-app","lucide-share"),this.addToggleSetting("openPDFWithDefaultApp",()=>this.redisplay()).setName("Open PDF links with an external app").setDesc("Open PDF links with the OS-defined default application for PDF files."),this.plugin.settings.openPDFWithDefaultApp&&this.addToggleSetting("openPDFWithDefaultAppAndObsidian").setName("Open PDF links in Obsidian as well").setDesc("Open the same PDF file both in the default app and Obsidian at the same time."),this.addToggleSetting("syncWithDefaultApp").setName("Sync the external app with Obsidian").setDesc("When you focus on a PDF file in Obsidian, the external app will also focus on the same file."),this.addToggleSetting("focusObsidianAfterOpenPDFWithDefaultApp").setName("Focus Obsidian after opening a PDF file with an external app").setDesc("Otherwise, the focus will be moved to the external app."),this.addHeading("View Sync","view-sync","lucide-eye").then(d=>{this.renderMarkdown(["Integrate more seamlessly with the [View Sync](https://github.com/RyotaUshio/obsidian-view-sync) plugin."],d.descEl)}),this.addToggleSetting("viewSyncFollowPageNumber",()=>this.redisplay()).setName("Sync page number"),this.plugin.settings.viewSyncFollowPageNumber&&this.addSliderSetting("viewSyncPageDebounceInterval",.1,1,.05).setName("Minimum update interval of the View Sync file (sec)"),this.addHeading("Vim keybindings","vim","vim").then(d=>this.renderMarkdown("Tracked at [this GitHub issue](https://github.com/RyotaUshio/obsidian-pdf-plus/issues/119).",d.descEl)),this.addSetting().then(d=>{this.renderMarkdown(['The default keybindings are as follows. You can customize them be creating a "vimrc" file and providing its path in the setting below.',"","- `j`/`k`/`h`/`l`: Scroll down/up/left/right","- `J`: Go to next page","- `K`: Go to previous page","- `gg`: Go to first page","- `G`: Go to last page","- `0`/`^`/`H`: Go to top of current page","- `$`/`L`: Go to bottom of current page","- ``/``: Scroll down/up as much as the viewer height (`C`=`Ctrl`)","- ``/``: Scroll down/up half as much as the viewer height","- `/`/`?`: Search forward/backward","- `n`/`N`: Go to next/previous match","- `gn`/`gN`: Select search result","- `+`/`zi`: Zoom in","- `-`/`zo`: Zoom out","- `=`/`z0`: Reset zoom","- `r`: Rotate pages clockwise","- `R`: Rotate pages counterclockwise","- `y`: Yank (copy) selected text",`- \`c\`: Run the "${this.plugin.lib.commands.stripCommandNamePrefix(this.plugin.lib.commands.getCommand("copy-link-to-selection").name)}" command`,"- `C`: Show context menu at text selection","- `o`: Swap the start and end of the selection","- `:`: Enter command-line mode (experimental)","- ``: Toggle outline (table of contents)","- ``: Toggle thumbnails (`S`=`Shift`)","- `f`: Enter hint mode by running `:hint` (experimental)","- ``: Go back to normal mode, abort search, etc","","Many of the commands above can be combined with counts. For example:","- `2j` scrolls down the page twice as much as `j`.","- `2J` advances two pages.","- `10G` takes you to page 10.","- `150=` sets the zoom level to 150%."],d.descEl)}),this.addToggleSetting("vim",()=>this.events.trigger("update")).setName("Enable").setDesc("Reopen the PDF viewers after changing this option."),this.showConditionally([this.addTextSetting("vimrcPath",void 0,()=>this.plugin.vimrc=null).setName("Vimrc file path (optional)").then(async d=>{await this.renderMarkdown(["Only the [Ex commands supported by PDF++](https://github.com/RyotaUshio/obsidian-pdf-plus/blob/main/src/vim/ex-commands.ts) are allowed.","","Example (not necessarily recommendations):","```",'" Use j/k, instead of J/K, to go to the next page',"map j J","map k K","",'" JavaScript commands','" - Hit Ctrl-h in Normal mode to show a message','nmap :js alert("Hello, world!")','" - Hit Ctrl-h in Visual mode to run a .js file',"vmap :jsfile filename.js","",'" Obsidian commands','" - Open the current PDF in the OS-default app by hitting d, e, and then f',"map def :obcommand open-with-default-app:open",'" - Go back and forth the history with Ctrl-o and Ctrl-i',"map :obcommand app:go-back","map :obcommand app:go-forward","```","","After changing the path or the file content, you need to reopen the PDF viewer. If the vimrc file is a hidden file or is under a hidden folder, you need to reload PDF++ or the app."],d.descEl);let h=d.components[0].inputEl;new yc(this.app,h).onSelect(({item:u})=>{this.plugin.settings.vimrcPath=u.path,this.plugin.saveSettings()})}),this.addHeading("Visual mode","vim-visual"),this.addToggleSetting("vimVisualMotion").setName("Enter visual mode on text selection").then(d=>{this.renderMarkdown(["When some text is selected, you can modify the range of selection using the `j,` `k`, `h`, `l`, `w`, `e`, `b`, `0`, `^`, `$`, `H`, and `L` keys, similarly to Vim's visual mode (`H`/`L` are mapped to `^`/`$` by default). If disabled, you can use `j`/`k`/`h`/`l`/`0`/`^`/`$`/`H`/`L` keys to scroll the page regardless of text selection. Reload the viewer or the app after changing this option.","","Tips:","- You can use `o` to swap the start and end of the selection.","- As you know, `/` and `?` keys initiate search. Pressing `gn`/`gN` after the search will select the search result. You can also use search to extend the current selection to the search result.","","Note: On mobile, word-wise motions (`w`/`e`/`b`) might not work as expected around punctuations. Contributions to fix this are welcome!"],d.descEl)}),this.addHeading("Outline mode","vim-outline"),this.addToggleSetting("enableVimOutlineMode").setName("Enter outline mode when opening PDF outline view").then(d=>{this.renderMarkdown(["If enabled, you will enter the outline mode by opening the PDF outline view (from the icon in the toolbar or by ``), and you can use the following keybindings, similarly to [Zathura](https://pwmt.org/projects/zathura/)'s index mode.","","- `j`: Move down","- `k`: Move up","- `h`: Collapse & move to parent entry","- `l`: Expand entry & move to child entry","- `H`: Collapse all entries","- `L`: Expand all entries","- `/`: Open the selected entry (``=`Enter`)","- ``: Close sidebar and go back to normal mode","","If disabled, you can use j/k/h/l/H/L keys to scroll the page whether the outline view is opened or not. ","This option requires reload to take effect."],d.descEl)}),this.addToggleSetting("vimSmoothOutlineMode").setName("Smooth motion in outline mode"),this.addHeading("Command-line mode (experimental)","vim-command-line"),this.addSetting().then(d=>{this.renderMarkdown(['By pressing `:`, you can enter the command-line mode, where you can execute various commands called "Ex commands"',"","- You can always go back to normal mode by ``.","- For some commands, you can run `:help :` or `:h :` to see the help message.","- Use `` and `` to navigate through the suggestions (`S`=`Shift`).","- Use arrow down/up keys to go back and forth the command history.","- `` clears the command line, and `` deletes the last word (`C`=`Ctrl`).",'- `:` will take you to the -th page, where the page number always starts from 1. To go to the page with the page label (e.g. "i, ii, ..., x, 1, 2, ..."), use `:gotopage ` (or `:go `/`:goto ` in short).','- `:!` runs the shell command (not supported on mobile). By default, Obsidian does not know the value of the "PATH" environment variable, so you might need to explicitly provide it in the setting below (in the "Misc" section) to run some commands.'],d.descEl)}),this.addHeading("Hint mode (experimental)","vim-hint"),this.addSetting().then(d=>{this.renderMarkdown(["Hitting `f` will enter the hint mode, where you can perform certain actions on links, annotations, and backlink highlighting in the PDF page without using the mouse.",'For example, first press `f` to enter the hint mode, and if the link you want to open gets marked with "HK", then hit `h` and then `k` (without `Shift`) to open it.',"","This is inspired by [Tridactyl](https://github.com/tridactyl/tridactyl)'s hint mode.","","Also check out Style Settings > PDF++ > Vim keybindings > Hint mode."],d.descEl)}),this.addTextSetting("vimHintChars").setName("Characters to use in hint mode").setDesc(`They are used preferentially from left to right, so you might want to put the easier-to-reach keys first. This is the same as Tridactyl's "hintchars" option.`),this.addTextSetting("vimHintArgs").setName('Default arguments for the ":hint" Ex command').setDesc('Space-separated list of "link"/"annot"/"backlink" or "all". Run ":help :hint" for the details.'),this.addHeading("Context menu","vim-context-menu"),this.addToggleSetting("enableVimInContextMenu").setName("Enable Vim keys in PDF context menus").setDesc("If enabled, you can use j/k/h/l keys, instead of the arrow keys, to navigate through context menu items in the PDF viewer."),this.addHeading("Scrolling","vim-scroll"),this.addSliderSetting("vimScrollSize",5,500,5).setName("Scroll size (px) of the jkhl keys").setDesc("The size of scroll when one of the jkhl keys is pressed once."),this.addToggleSetting("vimLargerScrollSizeWhenZoomIn").setName("Increase scroll size when zoomed in"),this.addSliderSetting("vimContinuousScrollSpeed",.1,5,.1).setName("Speed of continuous scroll (px per ms)").setDesc("The speed of scroll when pressing and holding down the jkhl keys."),this.addToggleSetting("vimSmoothScroll").setName("Smooth scroll"),this.addHeading("Search","vim-search"),this.addToggleSetting("vimHlsearch").setName("hlsearch").setDesc("If enabled, all matches will be highlighted."),this.addToggleSetting("vimIncsearch").setName("incsearch").setDesc("Incremental search: while typing the search query, update the search results after every keystroke. If disabled, the results will be shown only after pressing Enter.")],()=>this.plugin.settings.vim),this.addHeading("Misc","misc","lucide-more-horizontal"),this.addToggleSetting("showStatusInToolbar").setName("Show status in PDF toolbar").setDesc('For example, when you copy a link to a text selection in a PDF file, the status "Link copied" will be displayed in the PDF toolbar.'),this.addFileLocationSetting("newPDFLocation",d=>d.setName("Default location for new PDFs").setDesc('The "Create new PDF" command will create a new PDF file in the location specified here.'),"newPDFFolderPath",d=>d.setName("Folder to create new PDFs in").setDesc("Newly created PDFs will appear under this folder.")),this.addToggleSetting("hideReplyAnnotation").setName("Hide reply annotations").then(d=>{this.renderMarkdown(["Hide annotations that are replies to other annotations in the PDF viewer.","","This is a temporary fix for the issue that PDF.js (the library Obsidian's PDF viewer is based on) does not fulfill the PDF specification in that it renders reply annotations as if a standalone annotation."],d.descEl)}),this.addToggleSetting("removeWhitespaceBetweenCJChars").setName("Remove half-width whitespace between two Chinese/Japanese characters when copying text").setDesc("Such whitespace can be introduced as a result of poor post-processing of OCR (optical character recognition). Enable this option to remove it when copying links to text selections."),this.addToggleSetting("copyAsSingleLine").setName("Override the default copy behavior in the PDF viewer").then(d=>{d.descEl.appendText('If enabled, whenever you copy text from the PDF viewer (using Ctrl/Cmd+C or via context menu), the text will go through the same pre-processing as the "'+this.plugin.lib.commands.stripCommandNamePrefix(this.plugin.lib.commands.getCommand("copy-link-to-selection").name)+'" command before written to the clipboard. The pre-processing includes transforming multi-line text into a single line by removing line breaks (if a word is split across lines, it will be concatenated), which is useful because it prevents the copied text from being split into multiple lines unnaturally. If the previous option is enabled, the whitespace removal will also be applied.'),d.descEl.appendText(' Also note that on mobile devices, the action performed by "Copy" depends on the '),d.descEl.appendChild(this.createLinkTo("mobileCopyAction")),d.descEl.appendText(" option.")}),se.Platform.isDesktopApp&&this.addTextAreaSetting("PATH").then(d=>{let h=d.components[0];h instanceof se.TextAreaComponent&&(h.inputEl.rows=8,h.inputEl.cols=30)}).setName('"PATH" environment variable').setDesc('Provide the "PATH" environment variable for PDF++ to run shell commands without the full paths specified. In MacOS and Linux, you can run "echo $PATH" in Terminal and then copy & paste the result here. Currently, it will be used only when you run ":!" in Vim mode.'),this.addHeading("Style settings","style-settings","lucide-settings-2").setDesc("You can find more options in Style Settings > PDF++.").addButton(d=>{d.setButtonText("Open style settings").onClick(()=>{let h=this.app.setting.pluginTabs.find(u=>u.id==="obsidian-style-settings");h?this.app.setting.openTab(h):open("obsidian://show-plugin?id=obsidian-style-settings")})}),this.addFundingButton(),await Promise.all(this.promises)}async hide(){this.plugin.settings.colors=Object.fromEntries(Object.entries(this.plugin.settings.colors).filter(([e,i])=>e&&Ki(i))),this.plugin.settings.defaultColor&&!(this.plugin.settings.defaultColor in this.plugin.settings.colors)&&(this.plugin.settings.defaultColor=""),this.plugin.settings.backlinkHoverColor&&!(this.plugin.settings.backlinkHoverColor in this.plugin.settings.colors)&&(this.plugin.settings.backlinkHoverColor=""),this.plugin.settings.copyCommands=this.plugin.settings.copyCommands.filter(e=>e.name&&e.template),this.plugin.settings.displayTextFormats=this.plugin.settings.displayTextFormats.filter(e=>e.name),this.plugin.settings.enablePDFEdit&&!this.plugin.settings.author&&(this.plugin.settings.enablePDFEdit=!1,new se.Notice(`${this.plugin.manifest.name}: Cannot enable writing highlights into PDF files because the "Annotation author" option is empty.`)),this.plugin.validateAutoFocusAndAutoPasteSettings(),await this.plugin.saveSettings(),this.plugin.loadStyle(),this.promises=[],this.component.unload()}};var Fx=async(n,t,e)=>{if(t.palette){if(Te.Platform.isDesktopApp){let i=window.electron;i&&e.isTrusted&&(e.stopPropagation(),e.stopImmediatePropagation(),await new Promise(r=>{let o=e.win.setTimeout(()=>r(null),1e3);i.ipcRenderer.once("context-menu",(s,a)=>{e.win.clearTimeout(o),r(a)}),i.ipcRenderer.send("context-menu")}))}e.defaultPrevented||await ng(n,t,e)}};async function ng(n,t,e){let i=await aa.fromMouseEvent(n,t,e);t.clearEphemeralUI(),i.showAtMouseEvent(e),t.pdfViewer.isEmbed&&e.preventDefault()}async function Fh(n,t,e){if(!e||!e.focusNode||e.isCollapsed)return;let i=e.focusNode,r=e.focusOffset,o=i.doc,s=o.createRange();s.setStart(i,r),s.setEnd(i,r);let{x:a,y:c}=s.getBoundingClientRect(),l=new aa(n,t);await l.addItems(),t.clearEphemeralUI(),n.shownMenus.forEach(d=>d.hide()),l.showAtPosition({x:a,y:c},o)}var Px=(n,t,e)=>{var o;let{lib:i}=n,r=e.targetNode;if(r&&r.instanceOf(HTMLElement)&&r.hasClass("thumbnail")&&r.dataset.pageNumber!==void 0){let s=parseInt(r.dataset.pageNumber);if(Number.isNaN(s))return;let a=t.getMarkdownLink(`#page=${s}`,t.getPageLinkAlias(s)),l=(o=t.getPage(s).pageLabel)!=null?o:""+s,d=t.pdfViewer.pagesCount,h=""+s===l?`Copy link to page ${s}`:`Copy link to page ${l} (${s}/${d})`,u=new Te.Menu().addItem(f=>{f.setTitle(h).setIcon("lucide-copy").onClick(()=>{var g;((g=e.view)!=null?g:activeWindow).navigator.clipboard.writeText(a);let p=t.file;p&&(n.lastCopiedDestInfo={file:p,destArray:[s-1,"XYZ",null,null,null]})})});i.isEditable(t)&&u.addItem(f=>{f.setTitle("Insert page before this page").setIcon("lucide-plus").onClick(()=>{let p=t.file;if(!p){new Te.Notice(`${n.manifest.name}: Failed to insert the page.`);return}i.commands._insertPage(p,s,s)})}).addItem(f=>{f.setTitle("Insert page after this page").setIcon("lucide-plus").onClick(()=>{let p=t.file;if(!p){new Te.Notice(`${n.manifest.name}: Failed to insert the page.`);return}i.commands._insertPage(p,s+1,s)})}).addItem(f=>{f.setTitle("Delete page").setIcon("lucide-trash").onClick(()=>{let p=t.file;if(!p){new Te.Notice(`${n.manifest.name}: Failed to delete the page.`);return}i.commands._deletePage(p,s)})}).addItem(f=>{f.setTitle("Extract page to new file").setIcon("lucide-file-output").onClick(()=>{let p=t.file;if(!p){new Te.Notice(`${n.manifest.name}: Failed to extract the page.`);return}i.commands._extractPage(p,s)})}).addItem(f=>{f.setTitle("Divide document at this page").setIcon("lucide-split-square-vertical").onClick(()=>{let p=t.file;if(!p){new Te.Notice(`${n.manifest.name}: Failed to divide the document.`);return}i.commands._dividePDF(p,s)})}).addSeparator().addItem(f=>{f.setTitle("Customize...").setIcon("lucide-settings").onClick(()=>{n.openSettingTab().scrollToHeading("thumbnail")})}),u.showAtMouseEvent(e)}},kx=(n,t,e,i,r)=>{let{app:o,lib:s}=n;t.pdfViewer.isEmbed&&r.preventDefault();let a=s.toSingleLine(i.item.title),c=a?`Copy link to "${a.length<=40?a:a.slice(0,39).trim()+"\u2026"}"`:"Copy link to section",l=new Te.Menu().addItem(d=>{d.setTitle(c).setIcon("lucide-copy").onClick(async()=>{var f;let h=await s.copyLink.getTextToCopyForOutlineItem(t,e,i);((f=r.view)!=null?f:activeWindow).navigator.clipboard.writeText(h);let u=i.item.dest;if(typeof u=="string")n.lastCopiedDestInfo={file:e,destName:u};else{let p=await i.getPageNumber(),g=s.normalizePDFJsDestArray(u,p);n.lastCopiedDestInfo={file:e,destArray:g}}})});s.isEditable(t)&&l.addItem(d=>{d.setTitle("Add subitem").setIcon("lucide-plus").onClick(()=>{new vr(n,"Add subitem to outline").ask().then(async({title:h})=>{let u=s.getPDFViewFromChild(t);if(u){let f=u.getState(),p=s.viewStateToDestArray(f,!0);if(p){await Ce.findAndProcessOutlineItem(i,g=>{g.createChild(h,p).updateCountForAllAncestors(),g.sortChildren()},e,n);return}}new Te.Notice(`${n.manifest.name}: Failed to add the subitem.`)})})}).addItem(d=>{d.setTitle("Rename...").setIcon("lucide-pencil").onClick(()=>{new vr(n,"Rename outline item").presetTitle(i.item.title).ask().then(async({title:h})=>{await Ce.findAndProcessOutlineItem(i,u=>{u.title=h},e,n)})})}).addItem(d=>{d.setTitle("Move item to...").setIcon("lucide-folder-tree").onClick(async()=>{let h=await Ce.fromFile(e,n),u=await h.findPDFjsOutlineTreeNode(i);if(!u){new Te.Notice(`${n.manifest.name}: Failed to load the PDF document.`);return}new hh(h,u).askDestination().then(async f=>{f.appendChild(u),f.sortChildren();let p=await h.doc.save();await o.vault.modifyBinary(e,p)})})}).addItem(d=>{d.setTitle("Delete").setIcon("lucide-trash").onClick(async()=>{await Ce.findAndProcessOutlineItem(i,h=>{h.remove(),h.updateCountForAllAncestors()},e,n)})}).addItem(d=>{d.setTitle("Extract to new file").setIcon("lucide-file-output").onClick(async()=>{let{lib:h,settings:u}=n,f=await Ce.fromFile(e,n),p=await f.findPDFjsOutlineTreeNode(i);if(!p){new Te.Notice(`${n.manifest.name}: Failed to process the outline item.`);return}let{doc:g}=f,m=p.getExplicitDestination(),b=m?m[0]+1:null,w=null,F=p;for(;!F.nextSibling&&F.parent;)F=F.parent;let v=F.nextSibling;if(v){let k=v.getExplicitDestination();k&&(w=k[0]+1)}else w=g.getPageCount()+1;if(b===null||w===null){new Te.Notice(`${n.manifest.name}: Failed to fetch page numbers from the outline item.`);return}if(b>w){new Te.Notice(`${n.manifest.name}: The page numbers are invalid: the beginning of this section is page ${b}, whereas the next section starts at page ${w}.`);return}b===w&&(w=b+1);let P=h.getAvailablePathForCopy(e);new Nn(n,u.askPageLabelUpdateWhenExtractPage,u.pageLabelUpdateWhenExtractPage,u.askExtractPageInPlace,u.extractPageInPlace).ask().then((k,C)=>{h.composer.extractPages(e,{from:b,to:w-1},P,!1,k,C).then(async D=>{if(!D){new Te.Notice(`${n.manifest.name}: Failed to extract section from PDF.`);return}if(u.openAfterExtractPages){let T=h.workspace.getLeaf(u.howToOpenExtractedPDF);await T.openFile(D),await h.workspace.revealLeaf(T)}})})})}).addSeparator().addItem(d=>{d.setTitle("Customize...").setIcon("lucide-settings").onClick(()=>{n.openSettingTab().scrollToHeading("outline")})}),l.showAtMouseEvent(r)},Dx=(n,t,e,i)=>{let{lib:r}=n;r.isEditable(t)&&new Te.Menu().addItem(o=>{o.setTitle("Add top-level item").setIcon("lucide-plus").onClick(()=>{new vr(n,"Add item to outline").ask().then(async({title:s})=>{let a=r.getPDFViewFromChild(t);if(a){let c=a.getState(),l=r.viewStateToDestArray(c,!0);if(l){await Ce.processOutlineRoot(d=>{d.createChild(s,l).updateCountForAllAncestors(),d.sortChildren()},e,n);return}}new Te.Notice(`${n.manifest.name}: Failed to add the item.`)})})}).showAtMouseEvent(i)},ig=class extends Te.Menu{constructor(e){super();this.plugin=e}get app(){return this.plugin.app}get settings(){return this.plugin.settings}get lib(){return this.plugin.lib}},aa=class extends ig{constructor(e,i){super(e);this.child=i,this.setUseNativeMenu(!1),this.addSections(Object.keys(Ti.contextMenuConfig)),e.settings.enableVimInContextMenu&&Zp(this)}static async fromMouseEvent(e,i,r){let o=new aa(e,i);return await o.addItems(r),o}get win(){return this.child.containerEl.win}async addItems(e){var b,w;let{child:i,plugin:r,lib:o,app:s}=this,a=i.pdfViewer.pdfViewer,c=this.win.getSelection(),l=(b=o.copyLink.getPageAndTextRangeFromSelection(c))!=null?b:a?{page:a.currentPageNumber}:null;if(!l)return;let{page:d,selection:h}=l,u=o.toSingleLine((w=c==null?void 0:c.toString())!=null?w:""),f=F=>{var v;return(v=this.settings.contextMenuConfig.find(P=>P.id===F))==null?void 0:v.visible};Te.Platform.isMacOS&&Te.Platform.isDesktopApp&&this.win.electron&&u&&f("action")&&this.addItem(F=>F.setSection("action").setTitle(`Look up "${u.length<=25?u:u.slice(0,24).trim()+"\u2026"}"`).setIcon("lucide-library").onClick(()=>{this.win.electron.remote.getCurrentWebContents().showDefinitionForSelection()})),u&&u&&h&&i.palette&&(f("selection")&&Bo.create(this,i.palette).setSection("selection","Copy link to selection","lucide-copy").addItems(r.settings.selectionProductMenuConfig).onItemClick(({copyFormat:F,displayTextFormat:v,colorName:P})=>{o.copyLink.copyLinkToSelection(!1,{copyFormat:F,displayTextFormat:v},P!=null?P:void 0)}),o.isEditable(i)&&f("write-file")&&Bo.create(this,i.palette).setSection("write-file",`Add ${r.settings.selectionBacklinkVisualizeStyle} to file`,"lucide-edit").setShowNoColorButton(!1).addItems(r.settings.writeFileProductMenuConfig).onItemClick(({copyFormat:F,displayTextFormat:v,colorName:P})=>{o.copyLink.writeHighlightAnnotationToSelectionIntoFileAndCopyLink(!1,{copyFormat:F,displayTextFormat:v},P!=null?P:void 0)}));let p=i.getPage(d),g=e&&i.getAnnotationFromEvt(p,e),m=null;if(await(async()=>{var F;if(g){let{id:v}=o.getAnnotationInfoFromAnnotationElement(g);if(m=await i.getAnnotatedText(p,v),i.palette&&f("annotation")&&Bo.create(this,i.palette).setSection("annotation","Copy link to annotation","lucide-copy").addItems(r.settings.annotationProductMenuConfig).onItemClick(({copyFormat:P,displayTextFormat:k})=>{o.copyLink.copyLinkToAnnotation(i,!1,{copyFormat:P,displayTextFormat:k},d,v,!1,!0)}),o.isEditable(i)&&f("modify-annotation")){if(r.settings.enableAnnotationContentEdit&&Mn.isSubtypeSupported(g.data.subtype)){let P=g.data.subtype;this.addItem(k=>k.setSection("modify-annotation").setTitle("Edit annotation").setIcon("lucide-pencil").onClick(()=>{i.file&&Mn.forSubtype(P,r,i.file,d,v).open()}))}r.settings.enableAnnotationDeletion&&this.addItem(P=>P.setSection("modify-annotation").setTitle("Delete annotation").setIcon("lucide-trash").onClick(()=>{i.file&&new ra(r,i.file,d,v).openIfNeccessary()}))}if(g.data.subtype==="Link"&&f("link")){let P=(F=i.pdfViewer.pdfViewer)==null?void 0:F.pdfDocument;if("dest"in g.data&&typeof g.data.dest=="string"&&P&&i.file){let k=g.data.dest,C=i.file;this.addItem(D=>{D.setSection("link").setTitle("Copy PDF link").setIcon("lucide-copy").onClick(async()=>{let T=await o.destIdToSubpath(k,P);if(typeof T=="string"){let O=m;!O&&g.data.rect&&(O=i.getTextByRect(p,g.data.rect));let E=o.generateMarkdownLink(C,"",T,O!=null?O:void 0).slice(1);navigator.clipboard.writeText(E),r.lastCopiedDestInfo={file:C,destName:k}}})}),k.startsWith("cite.")&&this.addItem(D=>{D.setSection("link").setTitle("Search on Google Scholar").setIcon("lucide-search").onClick(()=>{var O;let T=(O=this.child.bib)==null?void 0:O.getGoogleScholarSearchUrlFromDest(k);if(typeof T!="string"){new Te.Notice(`${r.manifest.name}: Failed to find bibliographic information.`);return}window.open(T,"_blank")})})}if("url"in g.data&&typeof g.data.url=="string"){let k=g.data.url;this.addItem(C=>{C.setSection("link").setTitle("Copy URL").setIcon("lucide-copy").onClick(()=>{navigator.clipboard.writeText(k)})})}}}})(),u&&h&&o.isEditable(i)&&r.lastCopiedDestInfo&&r.lastCopiedDestInfo.file===i.file&&f("link")){if("destArray"in r.lastCopiedDestInfo){let F=r.lastCopiedDestInfo.destArray;this.addItem(v=>v.setSection("link").setTitle("Paste copied PDF link to selection").setIcon("lucide-clipboard-paste").onClick(()=>{o.highlight.writeFile.addLinkAnnotationToSelection(F)}))}else if("destName"in r.lastCopiedDestInfo){let F=r.lastCopiedDestInfo.destName;this.addItem(v=>v.setSection("link").setTitle("Paste copied link to selection").setIcon("lucide-clipboard-paste").onClick(()=>{o.highlight.writeFile.addLinkAnnotationToSelection(F)}))}}u&&f("text")&&this.addItem(F=>F.setSection("text").setTitle("Copy selected text").setIcon("lucide-copy").onClick(()=>{var v;navigator.clipboard.writeText(this.plugin.settings.copyAsSingleLine?u:(v=c==null?void 0:c.toString())!=null?v:"")})),m&&f("text")&&this.addItem(F=>F.setSection("text").setTitle("Copy annotated text").setIcon("lucide-copy").onClick(()=>{navigator.clipboard.writeText(m)})),u&&h&&f("search")&&this.addItem(F=>{F.setSection("search").setTitle("Copy link to search").setIcon("lucide-search").onClick(()=>{o.copyLink.copyLinkToSearch(!1,i,d,u.trim())})}),o.speech.isEnabled()&&u&&f("speech")&&this.addItem(F=>{F.setSection("speech").setTitle("Read aloud selected text").setIcon("lucide-speech").onClick(()=>{o.speech.speak(u)})}),!this.items.length&&f("page")&&this.addItem(F=>{F.setSection("page").setTitle("Copy link to page").setIcon("lucide-copy").onClick(v=>{let P=i.getMarkdownLink(`#page=${d}`,i.getPageLinkAlias(d));v.win.navigator.clipboard.writeText(P);let k=i.file;k&&(r.lastCopiedDestInfo={file:k,destArray:[d-1,"XYZ",null,null,null]})})}),this.items.length&&f("settings")&&this.addItem(F=>{F.setSection("settings").setIcon("lucide-settings").setTitle("Customize menu...").onClick(()=>{this.plugin.openSettingTab().scrollToHeading("context-menu")})}),s.workspace.trigger("pdf-menu",this,{pageNumber:d,selection:u,annot:g})}},Bo=class extends de{constructor(e,i){super(i.plugin);this.clickItemCallback=null;this.itemToColorName=new Map;this.itemToCopyFormat=new Map;this.itemToDisplayTextFormat=new Map;this.rootMenu=e,this.palette=i,this.showNoColorButton=this.settings.noColorButtonInColorPalette}static create(e,i){return e.addChild(new Bo(e,i))}then(e){return e(this),this}setShowNoColorButton(e){return this.showNoColorButton=e,this}setSection(e,i,r){return this.section=e,this.sectionTitle=i,this.sectionIcon=r,this}addSectionTitle(){this.section&&this.sectionTitle&&this.rootMenu.addItem(e=>{e.setSection(this.section).setTitle(this.sectionTitle).setDisabled(!0),this.sectionIcon&&e.setIcon(this.sectionIcon)})}addItems(e){return this.addSectionTitle(),Te.Platform.isDesktopApp||(e=e.slice(0,1)),gx(this.rootMenu,e.map(i=>{switch(i){case"color":return this.addColorItems.bind(this);case"copy-format":return this.addCopyFormatItems.bind(this);case"display":return this.addDisplayTextItems.bind(this)}}),{clickableParentItem:!0,vim:this.settings.enableVimInContextMenu}),this}addColorItems(e){let i=Object.keys(this.settings.colors),r=this.palette.getState().selectedColorName,o=r?i.map(s=>s.toLowerCase()).indexOf(r.toLowerCase()):-1;for(let s=this.showNoColorButton?-1:0;s{a.setTitle(s>=0?i[s]:"Don't specify color").onClick(()=>{this.finish({colorName:s>=0?i[s]:null})}),e!==this.rootMenu&&a.setChecked(s===o),this.section&&e===this.rootMenu&&a.setSection(this.section),this.itemToColorName.set(a,s>=0?i[s]:null);let c=this.settings.colors[s>=0?i[s]:"transparent"];a.dom.addClass("pdf-plus-color-menu-item"),a.titleEl.before(createDiv("pdf-plus-color-indicator",l=>{l.setCssStyles({backgroundColor:c})}))});Xp(e,100)}addNamedTemplateItems(e,i,r,o,s){for(let a=0;a{c.setTitle(i[a].name).onClick(()=>{s(i[a])}),e!==this.rootMenu&&c.setChecked(a===r),o.set(c,i[a].template),this.section&&e===this.rootMenu&&c.setSection(this.section)});Xp(e,100)}addDisplayTextItems(e){this.addNamedTemplateItems(e,this.settings.displayTextFormats,this.palette.getState().displayTextFormatIndex,this.itemToDisplayTextFormat,({template:i})=>this.finish({displayTextFormat:i}))}addCopyFormatItems(e){this.addNamedTemplateItems(e,this.settings.copyCommands,this.palette.getState().actionIndex,this.itemToCopyFormat,({template:i})=>this.finish({copyFormat:i}))}getOptionsFromColorPalette(){return{colorName:this.palette.getColorName(),copyFormat:this.palette.getCopyFormat(),displayTextFormat:this.palette.getDisplayTextFormat()}}getOptions(e){let i=this.getOptionsFromColorPalette();if(Te.Platform.isDesktopApp){let{items:r}=mx(this.rootMenu);for(let o of r)this.itemToColorName.has(o)?i.colorName=this.itemToColorName.get(o):this.itemToCopyFormat.has(o)?i.copyFormat=this.itemToCopyFormat.get(o):this.itemToDisplayTextFormat.has(o)&&(i.displayTextFormat=this.itemToDisplayTextFormat.get(o))}return Object.assign(i,e),i}updateColorPaletteState(e){let i=e.colorName,r=this.settings.copyCommands.findIndex(({template:s})=>s===e.copyFormat),o=this.settings.displayTextFormats.findIndex(({template:s})=>s===e.displayTextFormat);this.palette.setState({selectedColorName:i,actionIndex:r,displayTextFormatIndex:o}),this.settings.syncColorPaletteItem&&this.settings.syncDefaultColorPaletteItem&&(this.settings.defaultColorPaletteItemIndex=i?Object.keys(this.settings.colors).indexOf(i)+1:0),this.settings.syncColorPaletteAction&&this.settings.syncDefaultColorPaletteAction&&(this.settings.defaultColorPaletteActionIndex=r),this.plugin.settings.syncDisplayTextFormat&&this.plugin.settings.syncDefaultDisplayTextFormat&&(this.plugin.settings.defaultDisplayTextFormatIndex=o),this.plugin.trigger("color-palette-state-change",{source:this.palette})}finish(e){var r;let i=this.getOptions(e);this.settings.updateColorPaletteStateFromContextMenu&&this.updateColorPaletteState(i),(r=this.clickItemCallback)==null||r.call(this,i),this.rootMenu.hide()}onItemClick(e){this.clickItemCallback=e}},Sx=(n,t,e)=>{var l;if(n.defaultPrevented||(l=activeWindow.getSelection())!=null&&l.toString())return;let{lib:i,settings:r,child:o}=t;if(e.page){let d=o.getPage(e.page);if(o.getAnnotationFromEvt(d,n))return}let s=e.getColor(),a=(s==null?void 0:s.type)==="name"?s.name:void 0,c=new Te.Menu().addSections(["copy","color","image"]);s&&c.addItem(d=>{d.setSection("color").setTitle("Unset color").setIcon("lucide-palette").onClick(()=>{i.composer.linkUpdater.updateLinkColor(e.refCache,e.sourcePath,null)})});for(let d of Object.keys(r.colors))d.toLowerCase()!==(a==null?void 0:a.toLowerCase())&&c.addItem(h=>{h.setSection("color").setTitle(`Change color to "${d}"`).setIcon("lucide-palette").onClick(()=>{i.composer.linkUpdater.updateLinkColor(e.refCache,e.sourcePath,{type:"name",name:d})})});if(e.page&&e.FitR){let d=o.getPage(e.page).pdfPage,{left:h,bottom:u,right:f,top:p}=e.FitR;c.addItem(g=>{g.setSection("image").setTitle("Copy as image").setIcon("lucide-image").onClick(()=>{let m=i.pdfPageToImageArrayBuffer(d,{type:"image/png",encoderOptions:1,cropRect:[h,u,f,p]}).then(b=>new Blob([b],{type:"image/png"}));navigator.clipboard.write([new ClipboardItem({"image/png":m})])})})}c.showAtMouseEvent(n),n.preventDefault()};var rg=require("obsidian");var Cx=async(n,t,e,i)=>{let{app:r,lib:o}=n,s=[];for(let a of t.allItems)s.push((async()=>{let c=await o.copyLink.getTextToCopyForOutlineItemDynamic(e,i,a),l=o.toSingleLine(a.item.title),d=l?`${l.length<=40?l:l.slice(0,39).trim()+"\u2026"}`:"PDF section";r.dragManager.handleDrag(a.selfEl,h=>(r.dragManager.updateSource([a.selfEl],"is-being-dragged"),{source:"pdf-plus",type:"pdf-offset",icon:"lucide-heading",title:d,getText:c,item:a})),r.dragManager.handleDrop(a.selfEl,(h,u,f)=>{if(!o.isEditable(e)||!u||u.source!=="pdf-plus"||u.type!=="pdf-offset")return;let p=u.item;if(p&&!Mp(p,a,!0)&&p.parent!==a&&a.owner===p.owner)return f||(async()=>{let g=await Ce.fromFile(i,n),[m,b]=await Promise.all([g.findPDFjsOutlineTreeNode(a),g.findPDFjsOutlineTreeNode(p)]);if(!m||!b){new rg.Notice(`${n.manifest.name}: Failed to move the outline item.`);return}m.appendChild(b),m.sortChildren();let w=await g.doc.save();await r.vault.modifyBinary(i,w)})(),{action:`Move into "${d}"`,dropEffect:"move",hoverEl:a.el,hoverClass:"is-being-dragged-over"}},!1)})());await Promise.all(s),r.dragManager.handleDrop(t.childrenEl,(a,c,l)=>{if(!o.isEditable(e)||!c||c.source!=="pdf-plus"||c.type!=="pdf-offset"||a.target!==a.currentTarget)return;let d=c.item;if(d&&d.parent&&t===d.owner)return l||(async()=>{let h=await Ce.fromFile(i,n),u=await(h==null?void 0:h.findPDFjsOutlineTreeNode(d));if(!u){new rg.Notice(`${n.manifest.name}: Failed to move the outline item.`);return}let f=h.ensureRoot();f.appendChild(u),f.sortChildren();let p=await h.doc.save();await r.vault.modifyBinary(i,p)})(),{action:"Move to top level",dropEffect:"move",hoverEl:t.childrenEl,hoverClass:"is-being-dragged-over"}},!1)},Tx=(n,t,e)=>{let{app:i,lib:r}=n;t.pdfViewer.pdfThumbnailViewer.container.querySelectorAll("div.thumbnail[data-page-number]").forEach(o=>{var h;let s=parseInt(o.dataset.pageNumber),c=(h=t.getPage(s).pageLabel)!=null?h:""+s,l=t.pdfViewer.pagesCount,d=""+s===c?`Page ${s}`:`Page ${c} (${s}/${l})`;i.dragManager.handleDrag(o,u=>(i.dragManager.updateSource([o],"is-being-dragged"),{source:"pdf-plus",type:"pdf-page",icon:"lucide-book-open",title:d,getText:f=>r.copyLink.getTextToCopy(t,n.settings.thumbnailLinkCopyFormat,n.settings.thumbnailLinkDisplayTextFormat,e,s,`#page=${s}`,"","",f)}))})},Ex=(n,t,e,i,r,o)=>{let{app:s,lib:a}=n,c=e.getPage(r);e.getAnnotatedText(c,o).then(l=>{s.dragManager.handleDrag(t,d=>{s.dragManager.updateSource([t],"is-being-dragged");let h=a.getColorPaletteFromChild(e);if(!h)return null;let u=n.settings.copyCommands[h.actionIndex].template;return{source:"pdf-plus",type:"pdf-annotation",icon:"lucide-highlighter",title:"PDF annotation",getText:f=>a.copyLink.getTextToCopy(e,u,void 0,i,r,`#page=${r}&annotation=${o}`,l!=null?l:"","",f)}})})};var Ph=require("obsidian");var Cr=require("obsidian");var la=class extends de{constructor(e,i){super(e);this.file=i,this.events=new Cr.Events}onload(){this.init(),this.registerEvent(this.app.metadataCache.on("changed",(e,i,r)=>{this.update(e.path,r),this.trigger("update")})),this.registerEvent(this.app.metadataCache.on("deleted",e=>{this.deleteCachesForSourcePath(e.path),this.trigger("update")})),this.registerEvent(this.app.vault.on("rename",(e,i)=>{if(e instanceof Cr.TFile){this.deleteCachesForSourcePath(i);let r=this.app.metadataCache.getFileCache(e);r&&this.update(e.path,r),this.trigger("update")}}))}init(){this.pagesMap=new Map,this.sourcePaths=new Ut,this.backlinks=new Set;let e=this.app.metadataCache.getBacklinksForFile(this.file);for(let i of e.keys()){let r=e.get(i);for(let o of r!=null?r:[])this.createCache(o,i)}}update(e,i){var o,s,a;this.deleteCachesForSourcePath(e);let r=[...(o=i.links)!=null?o:[],...(s=i.embeds)!=null?s:[],...(a=i.frontmatterLinks)!=null?a:[]];for(let c of r){let l=c.link;this.app.metadataCache.getFirstLinkpathDest((0,Cr.getLinkpath)(l),e)===this.file&&this.createCache(c,e)}}delete(e){this.backlinks.delete(e),this.sourcePaths.deleteValue(e.sourcePath,e),e.page&&this.getPageIndex(e.page).delete(e)}deleteCachesForSourcePath(e){let i=this.sourcePaths.get(e);for(let r of i)this.delete(r)}getPageIndex(e){return this.pagesMap.has(e)||this.pagesMap.set(e,new Le(this,e)),this.pagesMap.get(e)}createCache(e,i){let r=new og(this,e);this.backlinks.add(r),r.sourcePath=i;let{subpath:o}=(0,Cr.parseLinktext)(e.link),s=new URLSearchParams(o.startsWith("#")?o.slice(1):o);if(!s.has("page"))return r;let a=+s.get("page");if(!Number.isInteger(a))return r;if(r.page=a,s.has("selection")){let c=s.get("selection").split(",").map(l=>parseInt(l.trim()));if(c.length===4&&c.every(l=>!isNaN(l))){let[l,d,h,u]=c;r.selection={beginIndex:l,beginOffset:d,endIndex:h,endOffset:u}}}if(s.has("annotation")){let c=s.get("annotation");r.annotation={id:c}}if(s.has("offset")){let c=s.get("offset").split(",").map(u=>parseInt(u)),l=c[0],d=c[1],h=c[2];isNaN(h)?r.FitBH={top:d}:r.XYZ={left:l,top:d,zoom:h}}if(s.has("rect")){let c=s.get("rect").split(",").map(f=>parseFloat(f)),[l,d,h,u]=c;r.FitR={left:l,bottom:d,right:h,top:u}}if(s.has("color")){let c=s.get("color"),l=c.split(",").map(d=>parseInt(d));l.length===3&&l.every(d=>!isNaN(d))?r.setColor({rgb:{r:l[0],g:l[1],b:l[2]}}):r.setColor({name:c})}return r}on(e,i,r){return this.events.on(e,i,r)}trigger(e,...i){this.events.trigger(e,...i)}},Le=class{constructor(t,e){this.sourcePaths=new Ut;this.backlinks=new Set;this.selections=new Ut;this.annotations=new Ut;this.XYZs=new Ut;this.FitBHs=new Ut;this.FitRs=new Ut;this.index=t,this.pageNumber=e}add(t){this.backlinks.add(t),this.sourcePaths.addValue(t.sourcePath,t),t.selection&&this.selections.addValue(Le.selectionId(t.selection),t),t.annotation&&this.annotations.addValue(t.annotation.id,t),t.XYZ&&this.XYZs.addValue(Le.XYZId(t.XYZ),t),t.FitBH&&this.FitBHs.addValue(Le.FitBHId(t.FitBH),t),t.FitR&&this.FitRs.addValue(Le.FitRId(t.FitR),t)}delete(t){this.backlinks.delete(t),this.sourcePaths.deleteValue(t.sourcePath,t),t.selection&&this.selections.deleteValue(Le.selectionId(t.selection),t),t.annotation&&this.annotations.deleteValue(t.annotation.id,t),t.XYZ&&this.XYZs.deleteValue(Le.XYZId(t.XYZ),t),t.FitBH&&this.FitBHs.deleteValue(Le.FitBHId(t.FitBH),t),t.FitR&&this.FitRs.deleteValue(Le.FitRId(t.FitR),t)}static selectionId(t){return`${t.beginIndex},${t.beginOffset},${t.endIndex},${t.endOffset}`}static selectionIdToParams(t){let[e,i,r,o]=t.split(",").map(s=>parseInt(s));return{beginIndex:e,beginOffset:i,endIndex:r,endOffset:o}}static XYZId(t){return`${t.left},${t.top},${t.zoom}`}static XYZIdToParams(t){let[e,i,r]=t.split(",").map(o=>parseFloat(o));return{left:e,top:i,zoom:r}}static FitBHId(t){return`${t.top}`}static FitBHIdToParams(t){return{top:parseFloat(t)}}static FitRId(t){return`${t.left},${t.bottom},${t.right},${t.top}`}static FitRIdToParams(t){let[e,i,r,o]=t.split(",").map(s=>parseFloat(s));return{left:e,bottom:i,right:r,top:o}}},og=class{constructor(t,e){this._sourcePath="";this._page=null;this._selection=null;this._annotation=null;this._XYZ=null;this._FitBH=null;this._FitR=null;this._color=null;this.index=t,this.refCache=e}getPageIndex(){return this.page?this.index.getPageIndex(this.page):null}get file(){return this.index.file}get sourcePath(){return this._sourcePath}set sourcePath(t){this._sourcePath=t,this.index.sourcePaths.addValue(t,this),this.page&&this.index.getPageIndex(this.page).sourcePaths.addValue(t,this)}get page(){return this._page}set page(t){this.page&&this.index.getPageIndex(this.page).delete(this),t&&this.index.getPageIndex(t).add(this),this._page=t}get selection(){return this._selection}set selection(t){let e=this.getPageIndex();e&&(this.selection&&(e==null||e.selections.deleteValue(Le.selectionId(this.selection),this)),t&&e.selections.addValue(Le.selectionId(t),this)),this._selection=t}get annotation(){return this._annotation}set annotation(t){let e=this.getPageIndex();e&&(this.annotation&&(e==null||e.annotations.deleteValue(this.annotation.id,this)),t&&e.annotations.addValue(t.id,this)),this._annotation=t}get XYZ(){return this._XYZ}set XYZ(t){let e=this.getPageIndex();e&&(this.XYZ&&(e==null||e.XYZs.deleteValue(Le.XYZId(this.XYZ),this)),t&&e.XYZs.addValue(Le.XYZId(t),this)),this._XYZ=t}get FitBH(){return this._FitBH}set FitBH(t){let e=this.getPageIndex();e&&(this.FitBH&&(e==null||e.FitBHs.deleteValue(Le.FitBHId(this.FitBH),this)),t&&e.FitBHs.addValue(Le.FitBHId(t),this)),this._FitBH=t}get FitR(){return this._FitR}set FitR(t){let e=this.getPageIndex();e&&(this.FitR&&(e==null||e.FitRs.deleteValue(Le.FitRId(this.FitR),this)),t&&e.FitRs.addValue(Le.FitRId(t),this)),this._FitR=t}setColor(t){"rgb"in t?this._color={type:"rgb",rgb:t.rgb}:this._color={type:"name",name:t.name}}getColor(){return this._color}};var sg=class extends de{constructor(e,i){super(e);this.file=i}get index(){var e;return(e=this._index)!=null?e:this._index=this.addChild(new la(this.plugin,this.file))}processSelection(e,i,r){}processAnnotation(e,i,r){}processXYZ(e,i,r){}processFitBH(e,i,r){}processFitR(e,i,r){}},ag=class extends de{constructor(e){super(e.plugin);this.pagewiseCacheToDomsMap=new Map;this.pagewiseStatus=new Map;this.pagewiseOnClearDomCallbacksMap=new Ut;this.visualizer=e}get file(){return this.visualizer.file}getCacheToDomsMap(e){let i=this.pagewiseCacheToDomsMap.get(e);return i||(i=new vc,this.pagewiseCacheToDomsMap.set(e,i)),i}clearDomInPage(e){let i=this.getCacheToDomsMap(e);for(let r of i.values())r.closest(".pdf-plus-backlink-highlight-layer")&&r.remove();this.pagewiseOnClearDomCallbacksMap.get(e).forEach(r=>r()),this.pagewiseCacheToDomsMap.delete(e),this.updateStatus(e,{onPageReady:!1,onTextLayerReady:!1,onAnnotationLayerReady:!1})}clear(){for(let e of this.pagewiseCacheToDomsMap.keys())this.clearDomInPage(e)}getStatus(e){let i=this.pagewiseStatus.get(e);return i||(i={onPageReady:!1,onTextLayerReady:!1,onAnnotationLayerReady:!1},this.pagewiseStatus.set(e,i)),i}isPageProcessed(e){let i=this.getStatus(e);return i.onPageReady&&i.onTextLayerReady&&i.onAnnotationLayerReady}updateStatus(e,i){let r=this.getStatus(e);Object.assign(r,i)}postProcessPageIfReady(e){this.isPageProcessed(e)&&this.postProcessPage(e)}postProcessPage(e){let i=this.getCacheToDomsMap(e);for(let r of i.keys()){let o=r.getColor();for(let s of i.get(r))this.hookBacklinkOpeners(s,r),this.hookBacklinkViewEventHandlers(s,r),this.hookContextMenuHandler(s,r),this.hookClassAdderOnMouseOver(s,r),this.setHighlightColor(s,o)}}hookBacklinkOpeners(e,i){let r="position"in i.refCache?i.refCache.position:void 0,o=r==null?void 0:r.start.line,s={isTriggeredFromBacklinkVisualizer:!0};typeof o=="number"&&(s.scroll=o),this.registerDomEventForCache(i,e,"mouseover",a=>{this.app.workspace.trigger("hover-link",{event:a,source:"pdf-plus",hoverParent:this.visualizer,targetEl:e,linktext:i.sourcePath,sourcePath:this.file.path,state:s})}),this.registerDomEventForCache(i,e,"dblclick",a=>{if(this.plugin.settings.doubleClickHighlightToOpenBacklink){let c=Ph.Keymap.isModEvent(a);this.lib.workspace.openMarkdownLinkFromPDF(i.sourcePath,this.file.path,c,r?{pos:r}:void 0)}})}hookBacklinkViewEventHandlers(e,i){this.registerDomEventForCache(i,e,"mouseover",r=>{this.plugin.settings.highlightBacklinksPane&&this.lib.workspace.iterateBacklinkViews(o=>{if(this.file!==o.file||!o.containerEl.isShown()||!o.pdfManager)return;let s=o.pdfManager.findBacklinkItemEl(i);if(s){s.addClass("hovered-backlink");let a=c=>{fi(c,s)&&(s.removeClass("hovered-backlink"),e.removeEventListener("mouseout",a))};e.addEventListener("mouseout",a)}})})}hookContextMenuHandler(e,i){this.registerDomEventForCache(i,e,"contextmenu",r=>{Sx(r,this.visualizer,i)})}hookClassAdderOnMouseOver(e,i){let r=i.page;if(typeof r=="number"){let o="is-hovered";this.registerDomEventForCache(i,e,"mouseover",()=>{for(let a of this.getCacheToDomsMap(r).get(i))a.addClass(o);let s=()=>{for(let a of this.getCacheToDomsMap(r).get(i))a.removeClass(o);e.removeEventListener("mouseout",s)};e.addEventListener("mouseout",s)})}}setHighlightColor(e,i){if((i==null?void 0:i.type)==="name")e.dataset.highlightColor=i.name.toLowerCase();else if((i==null?void 0:i.type)==="rgb"){let{r,g:o,b:s}=i.rgb;e.setCssProps({"--pdf-plus-color":`rgb(${r}, ${o}, ${s})`,"--pdf-plus-backlink-icon-color":`rgb(${r}, ${o}, ${s})`,"--pdf-plus-rect-color":`rgb(${r}, ${o}, ${s})`})}}onClearDomInPage(e,i){this.pagewiseOnClearDomCallbacksMap.addValue(e,i)}registerDomEventForCache(e,i,r,o,s){this.registerDomEvent(i,r,o,s),e.page&&e.annotation&&this.onClearDomInPage(e.page,()=>{i.removeEventListener(r,o)})}},lg=class extends de{constructor(e){super(e.plugin);this.visualizer=e,this.pagewiseIdToRectsMap=new Map}get file(){return this.visualizer.file}get child(){return this.visualizer.child}onload(){this.registerEvent(this.app.vault.on("modify",e=>{e===this.file&&this.pagewiseIdToRectsMap.clear()}))}getIdToRectsMap(e){let i=this.pagewiseIdToRectsMap.get(e);return i||(i=new Map,this.pagewiseIdToRectsMap.set(e,i)),i}getRectsForSelection(e,i){var s;let r=this.getIdToRectsMap(e),o=(s=r.get(i))!=null?s:null;return o||(o=this.computeRectsForSelection(e,i),o?(r.set(i,o),o):null)}computeRectsForSelection(e,i){let r=this.child.getPage(e),{beginIndex:o,beginOffset:s,endIndex:a,endOffset:c}=Le.selectionIdToParams(i),l=r.textLayer;return!l||!l.textDivs.length?null:this.lib.highlight.geometry.computeMergedHighlightRects(l,o,s,a,c)}},ca=class extends sg{constructor(e,i,r){super(e,i);this.child=r}static create(e,i,r){return e.addChild(new ca(e,i,r))}get hoverPopover(){return this.child.hoverPopover}set hoverPopover(e){this.child.hoverPopover=e}onload(){this.shouldVisualizeBacklinks()&&(this.domManager=this.addChild(new ag(this)),this.rectangleCache=this.addChild(new lg(this)),this.visualize(),this.registerEvent(this.index.on("update",()=>{this.visualize()})))}shouldVisualizeBacklinks(){let e=this.child.pdfViewer;return this.settings.highlightBacklinks&&(On(e)||this.settings.highlightBacklinksInCanvas&&ia(e)||this.settings.highlightBacklinksInHoverPopover&&na(e)||this.settings.highlightBacklinksInEmbed&&Ec(e))}visualize(){let e=this.child.pdfViewer;this.lib.onPageReady(e,this,i=>{this.domManager.clearDomInPage(i);let r=this.index.getPageIndex(i);for(let[o,s]of r.XYZs)this.processXYZ(i,o,s);for(let[o,s]of r.FitBHs)this.processFitBH(i,o,s);for(let[o,s]of r.FitRs)this.processFitR(i,o,s);this.domManager.updateStatus(i,{onPageReady:!0}),this.domManager.postProcessPageIfReady(i)}),this.lib.onTextLayerReady(e,this,i=>{let r=this.domManager.getStatus(i);if(!r.onPageReady||r.onTextLayerReady)return;let o=this.index.getPageIndex(i);for(let[s,a]of o.selections)this.processSelection(i,s,a);this.domManager.updateStatus(i,{onTextLayerReady:!0}),this.domManager.postProcessPageIfReady(i)}),this.lib.onAnnotationLayerReady(e,this,i=>{let r=this.domManager.getStatus(i);if(!r.onPageReady||r.onAnnotationLayerReady)return;let o=this.index.getPageIndex(i);for(let[s,a]of o.annotations)this.processAnnotation(i,s,a);this.domManager.updateStatus(i,{onAnnotationLayerReady:!0}),this.domManager.postProcessPageIfReady(i)})}processSelection(e,i,r){var l;super.processSelection(e,i,r);let o=this.child.getPage(e),s=this.domManager.getCacheToDomsMap(e),a=o.textLayer;if(!a||!a.textDivs.length)return;let c=this.rectangleCache.getRectsForSelection(e,i);if(c){for(let{rect:d,indices:h}of c){let u=this.lib.highlight.viewer.placeRectInPage(d,o);u.addClasses(["pdf-plus-backlink","pdf-plus-backlink-selection"]);let f=a.textDivs[h[0]];u.setCssStyles({fontSize:f.style.fontSize}),u.dataset.backlinkId=i;for(let p of r)s.addValue(p,u)}if(this.settings.showBacklinkIconForSelection){let d=(l=c.last())==null?void 0:l.rect;if(d){let h=this.showIcon(d[2],d[3],o);for(let u of r)s.addValue(u,h)}}}}processAnnotation(e,i,r){var f;super.processAnnotation(e,i,r);let o=this.child.getPage(e),s=(f=o.annotationLayer)==null?void 0:f.annotationLayer;if(!s)return;let a=s.getAnnotation(i);if(!a)return;a.container.addClasses(["pdf-plus-backlink","pdf-plus-backlink-annotation"]);let[,,c,l]=a.data.rect,d;this.settings.showBacklinkIconForAnnotation&&(d=this.showIcon(c,l,o));let h;this.settings.showBoundingRectForBacklinkedAnnot&&(h=this.lib.highlight.viewer.placeRectInPage(a.data.rect,o),h.addClass("pdf-plus-annotation-bounding-rect"));let u=this.domManager.getCacheToDomsMap(e);for(let p of r){u.addValue(p,a.container),d&&u.addValue(p,d),h&&u.addValue(p,h);let[g,m,b]=a.data.color;p.setColor({rgb:{r:g,g:m,b}})}}processXYZ(e,i,r){if(super.processXYZ(e,i,r),this.settings.showBacklinkIconForOffset){let o=this.child.getPage(e),{left:s,top:a}=Le.XYZIdToParams(i),c=this.showIcon(s,a,o,"left"),l=this.domManager.getCacheToDomsMap(e);for(let d of r)l.addValue(d,c)}}processFitBH(e,i,r){if(super.processFitBH(e,i,r),this.settings.showBacklinkIconForOffset){let o=this.child.getPage(e),{top:s}=Le.FitBHIdToParams(i),a=this.showIcon(0,s,o),c=this.domManager.getCacheToDomsMap(e);for(let l of r)c.addValue(l,a)}}processFitR(e,i,r){super.processFitR(e,i,r);let o=this.child.getPage(e),{left:s,bottom:a,right:c,top:l}=Le.FitRIdToParams(i),d=this.lib.highlight.viewer.placeRectInPage([s,a,c,l],o);d.addClasses(["pdf-plus-backlink","pdf-plus-backlink-fit-r"]);let h=this.domManager.getCacheToDomsMap(e);for(let u of r)h.addValue(u,d);if(this.settings.showBacklinkIconForRect){let u=this.showIcon(c,l,o);for(let f of r)h.addValue(f,u)}}showIcon(e,i,r,o="right"){var u;let s=Math.min(r.viewport.rawDims.pageWidth,r.viewport.rawDims.pageWidth)*this.settings.backlinkIconSize/2e3,a=[e,i-s,e+s,i],c=[e-s,i-s,e,i],l=o==="left"&&c[0]>=((u=r.viewport.rawDims.pageX)!=null?u:0)?c:a,d=this.lib.highlight.viewer.placeRectInPage(l,r);d.addClass("pdf-plus-backlink-icon"),(0,Ph.setIcon)(d,"links-coming-in");let h=d.querySelector("svg");return h==null||h.setAttribute("stroke","var(--pdf-plus-backlink-icon-color)"),d}};var Tr=require("obsidian");var Be=require("obsidian");var _i=class extends de{constructor(e,i,r){super(e);this.child=i,this.toolbarLeftEl=r,this.spacerEl=null,this.paletteEl=null,this.itemEls=[],this.actionMenuEl=null,this.displayTextFormatMenuEl=null,this.writeFileButtonEl=null,this.cropButtonEl=null,this.statusContainerEl=null,this.statusEl=null,this.importButtonEl=null,this.selectedColorName=null,this.actionIndex=e.settings.defaultColorPaletteActionIndex,this.displayTextFormatIndex=e.settings.defaultDisplayTextFormatIndex,this.writeFile=this.lib.isEditable(this.child)&&e.settings.defaultWriteFileToggle}onload(){if(this.toolbarLeftEl.querySelectorAll("."+_i.CLS).forEach(e=>{var i;(i=_i.elInstanceMap.get(e))==null||i.unload()}),!(!this.plugin.settings.colorPaletteInEmbedToolbar&&this.toolbarLeftEl.closest(".pdf-embed"))){if(this.spacerEl=this.toolbarLeftEl.createDiv("pdf-toolbar-spacer"),this.paletteEl=this.toolbarLeftEl.createDiv(_i.CLS),_i.elInstanceMap.set(this.paletteEl,this),this.plugin.settings.colorPaletteInToolbar){this.addItem(this.paletteEl,null,"transparent");for(let[e,i]of Object.entries(this.plugin.settings.colors))this.addItem(this.paletteEl,e,i);this.setActiveItem([null,...Object.keys(this.plugin.settings.colors)][this.plugin.settings.defaultColorPaletteItemIndex])}this.actionMenuEl=this.addCopyActionDropdown(this.paletteEl),this.displayTextFormatMenuEl=this.addDisplayTextFormatDropdown(this.paletteEl),this.addCropButton(this.paletteEl),this.child.isFileExternal?this.addImportButton(this.paletteEl):this.addWriteFileToggle(this.paletteEl),this.statusContainerEl=this.paletteEl.createDiv("pdf-plus-color-palette-status-container"),this.statusEl=this.statusContainerEl.createSpan("pdf-plus-color-palette-status"),this.registerEvent(this.plugin.on("color-palette-state-change",({source:e})=>{e!==this&&this.syncTo(e)}))}}onunload(){var e;(e=this.spacerEl)==null||e.remove(),this.paletteEl&&(this.paletteEl.remove(),_i.elInstanceMap.delete(this.paletteEl))}addItem(e,i,r){if(i&&!Ki(r)||i===null&&!this.plugin.settings.noColorButtonInColorPalette)return;let o=e.createDiv({cls:[_i.CLS+"-item","clickable-icon"],attr:i?{"data-highlight-color":i.toLowerCase()}:void 0});this.itemEls.push(o),o.createDiv(_i.CLS+"-item-inner"),this.setTooltipToActionItem(o,i),o.addEventListener("pointerup",a=>this.onItemPointerUp(o,i,a));let s=!1;o.addEventListener("contextmenu",()=>{if(s)return;let a=new Be.Menu().addItem(c=>{c.setIcon("lucide-settings").setTitle("Customize...").onClick(()=>{this.plugin.openSettingTab().scrollTo("colors")})});a.onHide(()=>{s=!1}),An(a,o),s=!0})}onItemPointerUp(e,i,r){let o=!e.hasClass("is-active");this.setActiveItem(i),this.plugin.settings.syncColorPaletteItem&&this.plugin.settings.syncDefaultColorPaletteItem&&(this.plugin.settings.defaultColorPaletteItemIndex=i?Object.keys(this.plugin.settings.colors).indexOf(i)+1:0),o&&this.plugin.trigger("color-palette-state-change",{source:this});let s=this.plugin.settings.copyCommands[this.actionIndex].template;this.writeFile?this.lib.copyLink.writeHighlightAnnotationToSelectionIntoFileAndCopyLink(!1,{copyFormat:s},i!=null?i:void 0):this.lib.copyLink.copyLinkToSelection(!1,{copyFormat:s},i!=null?i:void 0),r.preventDefault()}setActiveItem(e){this.selectedColorName=e?e.toLowerCase():null,this.itemEls.forEach(i=>{i.toggleClass("is-active",this.selectedColorName===i.dataset.highlightColor||this.selectedColorName===null&&i.dataset.highlightColor===void 0)})}addDropdown(e,i,r,o,s,a){return e.createDiv("clickable-icon",c=>{(0,Be.setIcon)(c,"lucide-chevron-down"),(0,Be.setTooltip)(c,o),c.dataset.checkedIndex=""+this[r];let l=!1;c.addEventListener("click",()=>{if(l)return;let d=new Be.Menu;for(let h=0;h{f.setTitle(u).setChecked(this[r]===h).onClick(()=>{let p=this[r]!==h;this.setCheckedIndex(r,h,c),s==null||s(),p&&this.plugin.trigger("color-palette-state-change",{source:this})})})}a==null||a(d),d.onHide(()=>{l=!1}),An(d,c),l=!0})})}setCheckedIndex(e,i,r){this[e]=i,r.dataset.checkedIndex=""+i}setActionIndex(e){this.actionMenuEl&&this.setCheckedIndex("actionIndex",e,this.actionMenuEl),this.updateTooltips()}setDisplayTextFormatIndex(e){this.displayTextFormatMenuEl&&this.setCheckedIndex("displayTextFormatIndex",e,this.displayTextFormatMenuEl)}addCopyActionDropdown(e){let i="Link copy format";this.plugin.settings.colorPaletteInToolbar||(i=`${this.plugin.manifest.name}: link copy options (trigger via hotkeys)`);let r=this.addDropdown(e,this.plugin.settings.copyCommands.map(o=>o.name),"actionIndex",i,()=>{this.updateTooltips(),this.plugin.settings.syncColorPaletteAction&&this.plugin.settings.syncDefaultColorPaletteAction&&(this.plugin.settings.defaultColorPaletteActionIndex=this.actionIndex)},o=>{o.addItem(s=>{s.setTitle("Customize...").setIcon("lucide-settings").onClick(()=>{this.plugin.openSettingTab().scrollTo("copyCommands")})})});return r.addClass("pdf-plus-action-menu"),r}addDisplayTextFormatDropdown(e){let i=this.addDropdown(e,this.plugin.settings.displayTextFormats.map(r=>r.name),"displayTextFormatIndex","Display text format",()=>{this.plugin.settings.syncDisplayTextFormat&&this.plugin.settings.syncDefaultDisplayTextFormat&&(this.plugin.settings.defaultDisplayTextFormatIndex=this.displayTextFormatIndex)},r=>{r.addItem(o=>{o.setTitle("Customize...").setIcon("lucide-settings").onClick(()=>{this.plugin.openSettingTab().scrollTo("displayTextFormats")})})});return i.addClass("pdf-plus-display-text-format-menu"),i}addWriteFileToggle(e){this.removeWriteFileToggle(),this.writeFileButtonEl=e.createDiv("clickable-icon",i=>{(0,Be.setIcon)(i,"lucide-edit"),(0,Be.setTooltip)(i,`Add ${this.plugin.settings.selectionBacklinkVisualizeStyle}s to file directly`),i.toggleClass("is-disabled",!this.lib.isEditable(this.child));let r=!1;i.addEventListener("click",()=>{if(!this.lib.isEditable(this.child)){if(r)return;let o=new Be.Menu().addItem(s=>{s.setIcon("lucide-settings").setTitle("Enable PDF editing...").onClick(()=>{this.plugin.openSettingTab().scrollToHeading("edit")})});o.onHide(()=>{r=!1}),An(o,i),r=!0;return}this.setWriteFile(!this.writeFile),this.plugin.settings.syncWriteFileToggle&&this.plugin.settings.syncDefaultWriteFileToggle&&(this.plugin.settings.defaultWriteFileToggle=this.writeFile),this.plugin.trigger("color-palette-state-change",{source:this})}),i.addEventListener("contextmenu",()=>{if(r)return;let o=new Be.Menu;this.lib.isEditable(this.child)&&o.addItem(s=>{s.setIcon("lucide-settings").setTitle("Customize...").onClick(()=>{this.plugin.openSettingTab().scrollToHeading("annot")})}),o.addItem(s=>{s.setIcon("lucide-settings").setTitle(this.lib.isEditable(this.child)?"Disable PDF editing...":"Enable PDF editing...").onClick(()=>{this.plugin.openSettingTab().scrollToHeading("edit")})}),o.onHide(()=>{r=!1}),An(o,i),r=!0})}),this.cropButtonEl&&e.insertAfter(this.writeFileButtonEl,this.cropButtonEl),this.setWriteFile(this.writeFile)}removeWriteFileToggle(){var e;(e=this.writeFileButtonEl)==null||e.remove(),this.writeFileButtonEl=null}addImportButton(e){this.removeImportButton(),this.importButtonEl=e.createDiv("clickable-icon",i=>{(0,Be.setIcon)(i,"lucide-import"),(0,Be.setTooltip)(i,"Import external PDF into vault"),i.addEventListener("click",()=>{this.importFile()})}),this.cropButtonEl&&e.insertAfter(this.importButtonEl,this.cropButtonEl)}removeImportButton(){var e;(e=this.importButtonEl)==null||e.remove(),this.importButtonEl=null}async importFile(){let e=this.child.externalFileUrl,i=this.child.file;if(!e||!i)return;if(!Be.Platform.isDesktopApp&&e.startsWith(Be.Platform.resourcePathPrefix)){new Be.Notice(`${this.plugin.manifest.name}: Importing local PDFs outside the vault is supported only on the desktop app.`);return}let r=await fetch(e);if(r.ok){let o=await r.arrayBuffer();await this.app.vault.modifyBinary(i,o),this.removeImportButton(),this.paletteEl&&this.addWriteFileToggle(this.paletteEl),new Be.Notice(`${this.plugin.manifest.name}: Successfully imported the PDF file into the vault.`);return}new Be.Notice(`${this.plugin.manifest.name}: Import failed. Response status: ${r.status}`)}setWriteFile(e){var i;this.writeFile=e,(i=this.writeFileButtonEl)==null||i.toggleClass("is-active",e)}addCropButton(e){this.cropButtonEl=e.createDiv("clickable-icon pdf-plus-rect-select",i=>{(0,Be.setIcon)(i,"lucide-box-select"),(0,Be.setTooltip)(i,"Copy embed link to rectangular selection"),i.addEventListener("click",()=>{this.startRectangularSelection(!1)});let r=!1;i.addEventListener("contextmenu",()=>{if(r)return;let o=new Be.Menu().addItem(s=>{s.setIcon("lucide-settings").setTitle("Customize...").onClick(()=>{this.plugin.openSettingTab().scrollToHeading("rect")})});o.onHide(()=>{r=!1}),An(o,i),r=!0})})}startRectangularSelection(e){var l;let i=this.cropButtonEl;if(!i)return;let r=this.lib.getPDFViewerChildAssociatedWithNode(this.paletteEl);if(!r||!((l=r.pdfViewer.dom)!=null&&l.viewerEl))return;let o=r.pdfViewer.dom.viewerEl,s={left:0,top:0,width:0,height:0},a=d=>{if(!vt(d,d.target))return;let h=d.target.closest(".pdf-viewer div.page[data-page-number]");if(!h)return;let u=h.dataset.pageNumber;if(!u)return;let f=r.getPage(+u),{x:p,y:g}=eh(d);s.left=p,s.top=g;let m=h.createDiv("pdf-plus-select-box"),b=h.getBoundingClientRect(),w=getComputedStyle(h),F=parseFloat(w.borderTopWidth),v=parseFloat(w.borderLeftWidth),P=parseFloat(w.paddingTop),k=parseFloat(w.paddingLeft);m.setCssStyles({left:s.left-(b.left+v+k)+"px",top:s.top-(b.top+F+P)+"px"});let C=T=>{let{x:O,y:E}=eh(T),V=h.getBoundingClientRect();s.width=O-s.left-(V.left-b.left),s.height=E-s.top-(V.top-b.top),m.setCssStyles({width:s.width+"px",height:s.height+"px"}),T.preventDefault(),T.stopImmediatePropagation()},D=()=>{var B;if(h.removeEventListener("mousemove",C),h.removeEventListener("touchmove",C),h.removeEventListener("mouseup",D),h.removeEventListener("touchend",D),h.removeChild(m),s.height<=0||s.width<=0)return;let T=s.left-(b.left+v+k),O=s.top-(b.top+F+P),E=T+s.width,V=O+s.height,W=window.pdfjsLib.Util.normalizeRect([...f.getPagePoint(T,V),...f.getPagePoint(E,O)]);this.lib.copyLink.copyEmbedLinkToRect(!1,r,f.id,W,this.plugin.settings.includeColorWhenCopyingRectLink&&(B=this.selectedColorName)!=null?B:void 0,e),c()};this.registerDomEvent(h,"mousemove",C),this.registerDomEvent(h,"touchmove",C),this.registerDomEvent(h,"mouseup",D),this.registerDomEvent(h,"touchend",D)},c=()=>{var d;i.toggleClass("is-active",!i.hasClass("is-active")),o.toggleClass("pdf-plus-selecting",i.hasClass("is-active")),this.register(()=>o.removeClass("pdf-plus-selecting")),(d=activeWindow.getSelection())==null||d.empty(),i.hasClass("is-active")?(this.registerDomEvent(o,"mousedown",a),this.registerDomEvent(o,"touchstart",a)):(o.removeEventListener("mousedown",a),o.removeEventListener("touchstart",a))};c()}setStatus(e,i){this.plugin.settings.showStatusInToolbar&&this.statusEl&&(this.statusEl.setText(e),i>0&&setTimeout(()=>{var r;((r=this.statusEl)==null?void 0:r.getText())===e&&this.statusEl.setText("")},i))}setTooltipToActionItem(e,i){let r=e.querySelector(":scope > ."+_i.CLS+"-item-inner"),o=this.plugin.settings.copyCommands[this.actionIndex].name,s=this.plugin.settings.quietColorPaletteTooltip,a=i!==null?s?i:`Copy link with format "${o}" & add ${i.toLowerCase()} ${this.plugin.settings.selectionBacklinkVisualizeStyle}`:s?"No color specified":`Copy link with "${o}" format without specifying color`;(0,Be.setTooltip)(r,a)}updateTooltips(){this.itemEls.forEach(e=>{var i;this.setTooltipToActionItem(e,(i=e.dataset.highlightColor)!=null?i:null)})}getState(){return{selectedColorName:this.selectedColorName,actionIndex:this.actionIndex,displayTextFormatIndex:this.displayTextFormatIndex,writeFile:this.writeFile}}setState(e){typeof e.selectedColorName=="string"&&this.setActiveItem(e.selectedColorName),typeof e.actionIndex=="number"&&this.setActionIndex(e.actionIndex),typeof e.displayTextFormatIndex=="number"&&this.setDisplayTextFormatIndex(e.displayTextFormatIndex),typeof e.writeFile=="boolean"&&this.setWriteFile(e.writeFile)}getColorName(){return this.getState().selectedColorName}getCopyFormat(){let e=this.getState();return this.plugin.settings.copyCommands[e.actionIndex].template}getDisplayTextFormat(){let e=this.getState();return this.plugin.settings.displayTextFormats[e.displayTextFormatIndex].template}syncTo(e){let i=e.getState();this.plugin.settings.syncColorPaletteItem||delete i.selectedColorName,this.plugin.settings.syncColorPaletteAction||delete i.actionIndex,this.plugin.settings.syncDisplayTextFormat||delete i.displayTextFormatIndex,this.plugin.settings.syncWriteFileToggle||delete i.writeFile,this.setState(i)}},Pt=_i;Pt.CLS="pdf-plus-color-palette",Pt.elInstanceMap=new Map;var da=class extends de{constructor(e,i,r){super(e);this.toolbar=i,this.child=r}onload(){this.addColorPalette(),this.replaceDisplayOptionsDropdown(),this.addZoomLevelInputEl(),this.makeDropdownInToolbarHoverable()}onunload(){}addColorPalette(){this.child.palette=this.addChild(new Pt(this.plugin,this.child,this.toolbar.toolbarLeftEl))}makeDropdownInToolbarHoverable(){let{toolbar:e,plugin:i}=this;!i.settings.hoverableDropdownMenuInToolbar||Tr.Platform.isPhone||e.toolbarLeftEl.querySelectorAll("div.clickable-icon").forEach(r=>{let o=r.firstElementChild;if(o&&o.matches("svg.lucide-chevron-down")){let s=null;Pc({parentEl:r,createChildEl:()=>{if(!r.hasClass("has-active-menu")){r.click();for(let a of i.shownMenus)if(a.parentEl===r)return s=a,a.dom}return s=null},removeChildEl:()=>{s&&(s.hide(),s=null)},component:this.child.component,timeout:200})}})}replaceDisplayOptionsDropdown(){let{app:e,toolbar:i,child:r}=this,o=i.zoomInEl.nextElementSibling;if(!(o!=null&&o.hasClass("clickable-icon")))return;let s=o.firstElementChild;if(!(s!=null&&s.matches("svg.lucide-chevron-down")))return;let a=i.pdfViewer.eventBus,c=i.pdfViewer.pdfViewer;!a||!c||i.zoomInEl.after(createDiv("clickable-icon",l=>{(0,Tr.setIcon)(l,"lucide-chevron-down"),(0,Tr.setTooltip)(l,"Display options");let d=!1;l.addEventListener("click",()=>{if(!d){let h=c.currentScaleValue,u=c.scrollMode,f=c.spreadMode,p=!!e.loadLocalStorage("pdfjs-is-themed"),g=new Tr.Menu().addSections(["zoom","scroll","spread","appearance","settings"]).addItem(m=>{m.setSection("zoom").setIcon("lucide-move-horizontal").setTitle("Fit width").setChecked(h==="page-width").onClick(()=>a.dispatch("scalechanged",{source:i,value:"page-width"}))}).addItem(m=>{m.setSection("zoom").setIcon("lucide-move-vertical").setTitle("Fit height").setChecked(h==="page-height").onClick(()=>a.dispatch("scalechanged",{source:i,value:"page-height"}))}).addItem(m=>{m.setSection("zoom").setIcon("lucide-move").setTitle("Fit page").setChecked(h==="page-fit").onClick(()=>a.dispatch("scalechanged",{source:i,value:"page-fit"}))}).addItem(m=>{m.setSection("scroll").setIcon("lucide-chevrons-up-down").setTitle("Vertical scroll").setChecked(u===0).onClick(()=>{a.dispatch("switchscrollmode",{source:i,mode:0})})}).addItem(m=>{m.setSection("scroll").setIcon("lucide-chevrons-left-right").setTitle("Hotizontal scroll").setChecked(u===1).onClick(()=>{a.dispatch("switchscrollmode",{source:i,mode:1})})}).addItem(m=>{m.setSection("scroll").setIcon("lucide-wrap-text").setTitle("Wrapped scroll").setChecked(u===2).onClick(()=>{a.dispatch("switchscrollmode",{source:i,mode:2})})}).addItem(m=>{m.setSection("spread").setIcon("lucide-rectangle-vertical").setTitle("Single page").setChecked(f===0).onClick(()=>{a.dispatch("switchspreadmode",{source:i,mode:0})})}).addItem(m=>{m.setSection("spread").setIcon("rectangle-vertical-double").setTitle("Two pages (odd)").setChecked(f===1).onClick(()=>{a.dispatch("switchspreadmode",{source:i,mode:1})})}).addItem(m=>{m.setSection("spread").setIcon("rectangle-vertical-double").setTitle("Two pages (even)").setChecked(f===2).onClick(()=>{a.dispatch("switchspreadmode",{source:i,mode:2})})}).addItem(m=>{m.setSection("appearance").setIcon("lucide-palette").setTitle("Adapt to theme").setChecked(p).onClick(()=>{e.saveLocalStorage("pdfjs-is-themed",p?null:"true"),r.onCSSChange()})}).addItem(m=>{m.setSection("settings").setIcon("lucide-settings").setTitle("Customize defaults...").onClick(()=>{this.plugin.openSettingTab().scrollToHeading("viewer-option")})});g.onHide(()=>{d=!1}),An(g,l),d=!0}}),i.toolbarEl.doc.win.setTimeout(()=>{o.remove(),i.toolbarLeftEl.insertAfter(l,i.zoomInEl)})}))}addZoomLevelInputEl(){if(!this.settings.zoomLevelInputBoxInToolbar)return;let{toolbar:e}=this,i=e.pdfViewer.eventBus,r=e.pdfViewer.pdfViewer;if(!i||!r)return;let o=e.zoomOutEl.nextElementSibling;o!=null&&o.hasClass("pdf-toolbar-divider")&&(o.remove(),this.register(()=>e.zoomOutEl.after(createDiv("pdf-toolbar-divider"))),e.zoomOutEl.after(createEl("input","pdf-zoom-level-input",s=>{this.register(()=>s.remove()),s.type="number",s.addEventListener("click",()=>s.select()),s.addEventListener("change",()=>{let a=s.valueAsNumber/100,c=Math.min(Math.max(a,window.pdfjsViewer.MIN_SCALE),window.pdfjsViewer.MAX_SCALE);r.currentScale=c}),i.on("scalechanging",({scale:a})=>{s.value=Math.round(a*100)+""}),r.currentScale&&(s.value=Math.round(r.currentScale*100)+""),s.doc.win.setTimeout(()=>{s.after(createSpan({cls:"pdf-zoom-level-percent",text:"%"},a=>{this.register(()=>a.remove())}))})})))}};da.elInstanceMap=new Map;var cg=Un(require("obsidian"));var Ho=class extends de{constructor(e,i){super(e);this.child=i}get file(){return this.child.file}get pdf(){return this.file}get folder(){var e,i;return(i=(e=this.file)==null?void 0:e.parent)!=null?i:null}get pdfViewer(){return this.child.pdfViewer}get dom(){return this.child.pdfViewer.dom}get doc(){return this.child.containerEl.doc}get obsidian(){return cg}get text(){var i;let e=(i=this.doc.getSelection())==null?void 0:i.toString();return e?this.lib.toSingleLine(e):""}get selection(){return this.text}get page(){var i,r,o,s;let e=this.doc.getSelection();return(s=(o=e&&((i=this.lib.copyLink.getPageAndTextRangeFromSelection(e))==null?void 0:i.page))!=null?o:(r=this.pdfViewer.pdfViewer)==null?void 0:r.currentPageNumber)!=null?s:null}get pageLabel(){let e=this.page;return e!==null?this.child.getPage(e).pageLabel:null}get pageCount(){var e,i;return(i=(e=this.pdfViewer.pdfViewer)==null?void 0:e.pagesCount)!=null?i:null}get color(){var e,i,r;return(r=(i=(e=this.child.palette)==null?void 0:e.getColorName())==null?void 0:i.toLowerCase())!=null?r:null}evaluateTemplate(e,i,r){if(!this.file||typeof this.page!="number")return"";let o=this.lib.copyLink.getPageAndTextRangeFromSelection(this.doc.getSelection());if(!o)return"";let{page:s,selection:a}=o;if(!a)return"";let c=Cc({page:s,selection:`${a.beginIndex},${a.beginOffset},${a.endIndex},${a.endOffset}`,color:r?r.toLowerCase():void 0});return this.lib.copyLink.getTextToCopy(this.child,e,i,this.file,this.page,c,this.text,r?r.toLowerCase():"")}writeFile(e,i,r){var o;return this.lib.write(cg.normalizePath(e),i,(o=r==null?void 0:r.existOk)!=null?o:!1)}async run(e){return Bp("const app=this.app;const api = this;"+e,this)}};var Ax=require("obsidian");var kP=n=>vt(n,n.target)&&xp(n.target),Er=class extends Ax.Scope{constructor(e){super(e);this.modeToKeymaps={};this.currentMode=null;this.currentKeys="";this.searchFrom=0;this.searchTo=-1;this.onEscapeCallbacks=[];this.escapeAliases=[];this.typableModes=[]}registerKeymaps(e,i){let r=(o,s)=>Mo(o.keys,s.keys);for(let o of e){if(!this.modeToKeymaps.hasOwnProperty(o)){this.modeToKeymaps[o]=Object.entries(i).map(([s,a])=>({keys:s,func:a})).sort(r);continue}for(let s in i){let a=i[s],c={keys:s,func:a},l=this.modeToKeymaps[o],{found:d,index:h}=Gi(l,u=>r(c,u));d?l[h]=c:l.splice(h,0,c)}}}unregisterAllKeymaps(e){for(let i of e)this.modeToKeymaps[i]&&(this.modeToKeymaps[i].length=0)}map(e,i){for(let r of e){let o=Object.fromEntries(Object.entries(i).map(([s,a])=>[s,c=>{let{found:l,index:d}=Gi(this.modeToKeymaps[r],h=>Mo(a,h.keys));if(l){let h=this.modeToKeymaps[r][d].func;return h(c)}}]));this.registerKeymaps([r],o)}}noremap(e,i){for(let r of e)if(this.modeToKeymaps.hasOwnProperty(r))for(let o in i){let s=i[o],{found:a,index:c}=Gi(this.modeToKeymaps[r],l=>Mo(s,l.keys));if(a){let l=this.modeToKeymaps[r][c];this.registerKeymaps([r],{[o]:l.func})}}}unmap(e,i){for(let r of e)if(this.modeToKeymaps.hasOwnProperty(r))for(let o of i){let{found:s,index:a}=Gi(this.modeToKeymaps[r],c=>Mo(o,c.keys));s&&this.modeToKeymaps[r].splice(a,1)}}setMode(e){this.currentMode=e,this.reset()}clearKeys(){this.currentKeys=""}reset(){this.clearKeys(),this.searchFrom=0,this.searchTo=-1}onEscape(e){this.onEscapeCallbacks.push(e)}addEscapeAliases(...e){this.escapeAliases.push(...e)}setTypable(...e){this.typableModes.push(...e)}handleKey(e,i){let r=!0;(()=>{if(this.currentMode===null)return this.reset();if(this.typableModes.includes(this.currentMode)!==kP(e))return;let o=Er.canonicalizeKey(i);if(o===null)return this.reset();if(o===""||this.escapeAliases.includes(o))return this.onEscapeCallbacks.forEach(h=>h(o==="")),this.reset();this.currentKeys+=o;let s=this.currentKeys.match(/^([1-9]\d*)?([\D0][\d\D]*)?/);if(!s)return this.reset();let a=s[1]?+s[1]:void 0,c=s[2];if(!c)return;let l=this.modeToKeymaps[this.currentMode];if(!l||l.length===0)return this.reset();let d=Np(l,c,h=>h.keys,{from:(l.length+this.searchFrom)%l.length,to:(l.length+this.searchTo)%l.length});if(!d)return this.reset();if(d.from===d.to){let h=l[d.from];if(h.keys===c){this.reset(),h.func(a),e.preventDefault(),r=!1;return}}this.searchFrom=d.from,this.searchTo=d.to})(),r&&this.parent&&this.parent.handleKey(e,i)}static canonicalizeKey(e){var r;if(e.modifiers===null||e.key===null)return null;let i=Er.canonicalizeSpecialKey(e.key);switch(e.modifiers){case"":return i?`<${i}>`:e.key;case"Shift":return e.key.length===1&&e.key!==" "?e.key:``;case"Ctrl":return``;case"Alt":return``;case"Meta":return``;default:return null}}static canonicalizeSpecialKey(e){switch(e){case"<":return"lt";case"Backspace":return"BS";case"Tab":return"Tab";case"Enter":return"CR";case"Escape":return"Esc";case" ":return"Space";case"\\":return"Bslash";case"|":return"Bar";case"ArrowUp":return"Up";case"ArrowDown":return"Down";case"ArrowLeft":return"Left";case"ArrowRight":return"Right";default:return null}}};var kh=class{constructor(t){this.lastScroll=0;this.lastScrollInterval=0;this.vim=t}get settings(){return this.vim.settings}get viewerContainerEl(){var t,e;return(e=(t=this.vim.obsidianViewer)==null?void 0:t.dom)==null?void 0:e.viewerContainerEl}getPageDiv(t=0){var i;let e=this.vim.pdfViewer;if(e)return(i=e._pages[e.currentPageNumber-1+t])==null?void 0:i.div}scrollTo(t,e){let i=this.viewerContainerEl;if(!i)return;let r=this.isFirstScrollInAWhile(),o=r?this.settings.vimScrollSize:this.settings.vimContinuousScrollSpeed*this.lastScrollInterval;this.vim.pdfViewer&&this.settings.vimLargerScrollSizeWhenZoomIn&&(o*=Math.max(1,this.vim.pdfViewer.currentScale)),e!=null||(e=1),o*=e;let a={behavior:this.settings.vimSmoothScroll&&r?"smooth":"instant"};switch(t){case"left":a.left=-o;break;case"right":a.left=o;break;case"up":a.top=-o;break;case"down":a.top=o;break}i.scrollBy(a)}isFirstScrollInAWhile(){let t=Date.now();return this.lastScrollInterval=t-this.lastScroll,this.lastScroll=t,this.lastScrollInterval>100}scrollToTop(){if(!this.viewerContainerEl)return;let t=this.getPageDiv();t&&this.viewerContainerEl.scrollTo({top:t.offsetTop,behavior:this.settings.vimSmoothScroll?"smooth":"instant"})}scrollToBottom(){if(!this.viewerContainerEl)return;let t=this.getPageDiv();t&&this.viewerContainerEl.scrollTo({top:t.offsetTop+t.offsetHeight-this.viewerContainerEl.clientHeight,behavior:this.settings.vimSmoothScroll?"smooth":"instant"})}scrollVerticallyByVisualPage(t){if(!this.viewerContainerEl)return;let e=this.viewerContainerEl.clientHeight;e*=t,this.viewerContainerEl.scrollBy({top:e,behavior:this.settings.vimSmoothScroll?"smooth":"instant"})}scrollHorizontallyByVisualPage(t){if(!this.viewerContainerEl)return;let e=this.viewerContainerEl.clientWidth;e*=t,this.viewerContainerEl.scrollBy({left:e,behavior:this.settings.vimSmoothScroll?"smooth":"instant"})}};var Lx=require("obsidian");var Ix=200,Dh=class{constructor(t){this.isActive=!1;this.isForward=!0;this.vim=t}get settings(){return this.vim.settings}get lib(){return this.vim.lib}get incsearch(){return this.settings.vimIncsearch}get hlsearch(){return this.settings.vimHlsearch}get findBar(){var t;return(t=this.vim.obsidianViewer)==null?void 0:t.findBar}findNext(t=1,e=!0){if(this.isActive&&this.findBar){for(this.vim.visualMode.rememberSelection();t-- >0;)this.findBar.dispatchEvent("again",e?!this.isForward:this.isForward);this.restoreSelectionAndExtendToMatch()}}findPrevious(t){this.findNext(t,!1)}restoreSelectionAndExtendToMatch(){setTimeout(()=>{let t=this.vim.doc.getSelection();if((!t||t.isCollapsed)&&this.vim.visualMode.restorePreviousSelection(),t=this.vim.doc.getSelection(),t&&!t.isCollapsed){let e=this.getSelectedMatchEl();e&&this.vim.visualMode.extendSelectionToNode(e)}},Ix)}start(t){let e=this.findBar;if(!e)return;if(this.vim.visualMode.rememberSelection(),e.opened){e.searchComponent.inputEl.select();return}this.isActive=!0,this.isForward=t,e.searchSettings.highlightAll=this.hlsearch,this.lib.updateSearchSettingsUI(e);let i=e.searchComponent.changeCallback;this.incsearch?e.searchComponent.onChange((0,Lx.debounce)(()=>{e.dispatchEvent("again")},250,!0)):e.searchComponent.onChange(()=>{}),e.showSearch();let r=o=>{this.isActive&&(o.isComposing||o.key==="Enter"&&(vt(o,o.target)&&o.target.blur(),o.stopPropagation(),this.incsearch?this.restoreSelectionAndExtendToMatch():this.findNext()))};e.searchComponent.inputEl.addEventListener("keypress",r,!0),this.lib.registerPDFEvent("findbarclose",e.eventBus,null,()=>{this.isActive=!1,e.searchComponent.inputEl.removeEventListener("keypress",r,!0),i&&e.searchComponent.onChange(i)})}findAndSelectNextMatch(t,e){this.findNext(t,e),setTimeout(()=>{let i=this.vim.doc.getSelection();if(!i)return;let r=this.getSelectedMatchEl();r&&(i.isCollapsed?i.selectAllChildren(r):this.vim.visualMode.extendSelectionToNode(r,1))},Ix+1)}getSelectedMatchEl(){var i,r;let t=(r=(i=this.vim.obsidianViewer)==null?void 0:i.dom)==null?void 0:r.viewerEl;return t?t.querySelector(".textLayer .textLayerNode > .highlight.selected"):null}};var $i=class extends de{constructor(e){super(e.plugin);this.vim=e}get vimScope(){return this.vim.vimScope}get doc(){return this.vim.doc}get viewer(){return this.vim.viewer}get obsidianViewer(){return this.vim.obsidianViewer}get pdfViewer(){return this.vim.pdfViewer}};var Sh=class extends $i{constructor(e){super(e);this.selectionChangedByVisualMotion=!1;this.previousSelection=null;this.defineKeymaps()}get structureParser(){return this.vim.structureParser}onload(){this.registerDomEvent(this.doc,"selectionchange",()=>{let e=this.doc.getSelection();switch(this.vim.vimScope.currentMode){case"visual":(!e||e.isCollapsed)&&(this.selectionChangedByVisualMotion||this.vim.vimScope.setMode("normal"));break;default:if(e&&!e.isCollapsed&&e.rangeCount>0){let i=e.getRangeAt(0);this.vim.viewer.containerEl.contains(i.commonAncestorContainer)&&this.vim.vimScope.setMode("visual")}}this.selectionChangedByVisualMotion=!1})}defineKeymaps(){let e=i=>r=>(i(r),this.selectionChangedByVisualMotion=!0);this.vimScope.registerKeymaps(["visual"],{...this.settings.vimVisualMotion?{j:e(i=>this.extendSelectionByLine(i!=null?i:1)),k:e(i=>this.extendSelectionByLine(-(i!=null?i:1))),h:e(i=>this.extendSelectionByChar(i!=null?i:1,!1)),l:e(i=>this.extendSelectionByChar(i!=null?i:1,!0)),w:e(i=>{let r=this.doc.getSelection();r&&(No(()=>{r.modify("extend","forward","word"),r.modify("extend","forward","word"),r.modify("extend","backward","word"),Xi(r)&&r.modify("extend","forward","character")},i),this.ensureSelectionHeadAtTextDiv(r,!1))}),e:e(i=>{let r=this.doc.getSelection();r&&(No(()=>{Xi(r)||r.modify("extend","forward","character"),r.modify("extend","forward","word"),Xi(r)||r.modify("extend","backward","character")},i),this.ensureSelectionHeadAtTextDiv(r,!1))}),b:e(i=>{let r=this.doc.getSelection();r&&(No(()=>{Xi(r)&&r.modify("extend","backward","character"),r.modify("extend","backward","word"),Xi(r)&&r.modify("extend","forward","character")},i),this.ensureSelectionHeadAtTextDiv(r,!0))}),0:e(()=>this.extendSelctionToLineBoundary(!1)),"^":e(()=>this.extendSelctionToLineBoundary(!1)),$:e(()=>this.extendSelctionToLineBoundary(!0))}:{},o:e(()=>{let i=this.doc.getSelection();i&&Dc(i)}),y:()=>{let i=this.doc.getSelection();if(i){let r=i.toString();r&&navigator.clipboard.writeText(r),i.empty()}},c:()=>{var i;this.lib.commands.copyLink(!1),(i=this.doc.getSelection())==null||i.empty()},C:()=>{let i=this.doc.getSelection();i&&setTimeout(()=>{this.viewer.then(r=>{Fh(this.plugin,r,i)})})}})}getTextDivContainingNode(e){let i=e.instanceOf(Element)?e:e.parentElement;if(!i)return null;let r=i.closest(".textLayerNode");return r||null}getTextDivAtSelectionHead(e){let{focusNode:i}=e;return i?this.getTextDivContainingNode(i):null}getSelectionPos(e,i){let r=i==="head",o=r?e.focusNode:e.anchorNode;if(!o)return null;let s=this.getTextDivContainingNode(o);if(!s||s.dataset.idx===void 0)return null;let a=+s.dataset.idx,c=(()=>{let d=r?e.focusOffset:e.anchorOffset,h=this.doc.createNodeIterator(s,NodeFilter.SHOW_ALL),u,f=0;for(;u=h.nextNode();){if(u===o)return f+=u.nodeType===Node.TEXT_NODE?d:Array.from(o.childNodes).slice(0,d).map(p=>p.textContent.length).reduce((p,g)=>p+g,0),f;u.nodeType===Node.TEXT_NODE&&(f+=u.textContent.length)}return f})();if(typeof c!="number")return null;Xi(e)===r&&c--;let l=d=>d.instanceOf(HTMLElement)&&d.hasClass("textLayerNode")&&!!d.textContent;if(c<0){let d=s.previousSibling;for(;d&&!l(d);)d=d.previousSibling;d&&l(d)&&d.dataset.idx!==void 0&&(a=+d.dataset.idx,c=d.textContent.length-1)}else if(s.textContent&&c>=s.textContent.length){let d=s.nextSibling;for(;d&&!l(d);)d=d.nextSibling;d&&l(d)&&d.dataset.idx!==void 0&&(a=+d.dataset.idx,c=0)}return{index:a,offset:c}}extendSelection(e){var l,d,h;let i=this.doc.getSelection();if(!i)return;let r=this.lib.getPageElFromSelection(i);if(!r||r.dataset.pageNumber===void 0)return;let o=+r.dataset.pageNumber,s=(l=this.structureParser)==null?void 0:l.getPageParser(o);if(!s)return;let a=this.getSelectionPos(i,"head");if(!a)return;let c=e({currentHeadPos:a,pageNumber:o,pageParser:s});if(c){let u=s.divs[c.index],f=c.offset;f<0&&(f+=(h=(d=u.textContent)==null?void 0:d.length)!=null?h:0);let p=ea(u,f);if(!p)return;this.extendSelectionToNode(p.node,p.offset)}}extendSelectionToNode(e,i){let r=this.doc.getSelection();r&&(r.extend(e,i),Xi(r)&&r.modify("extend","forward","character"))}extendSelectionByLine(e){this.extendSelection(({currentHeadPos:i,pageParser:r})=>r.getLineShiftPosition(i,e))}extendSelctionToLineBoundary(e){this.extendSelection(({currentHeadPos:i,pageParser:r})=>{let o=r.getBoundIndicesOfLine(i.index,0);return o?e?{index:o.end,offset:-1}:{index:o.start,offset:0}:null})}extendSelectionByChar(e,i){let r=this.doc.getSelection();r&&(No(()=>r.modify("extend",i?"forward":"backward","character"),e),this.ensureSelectionHeadAtTextDiv(r,i))}selectMatch(){var i;let e=this.vim.search.getSelectedMatchEl();e&&((i=this.vim.doc.getSelection())==null||i.selectAllChildren(e))}ensureSelectionHeadAtTextDiv(e,i){let r=this.getTextDivAtSelectionHead(e);for(;!r;)e.modify("extend",i?"forward":"backward","character"),r=this.getTextDivAtSelectionHead(e)}setSelectionByPos(e,i){let r=this.doc.getSelection();if(!r)return;let o=c=>{var f,p;let{page:l,pos:d}=c,h=(p=(f=this.vim.child)==null?void 0:f.getPage(l).textLayer)==null?void 0:p.textDivs;if(!h||!h.length)return;let u=h[d.index];return ea(u,d.offset)},s=o(e),a=o(i);if(s&&a){r.setBaseAndExtent(s.node,s.offset,a.node,a.offset);let c=Xi(r);c||Dc(r),r.modify("extend","forward","character"),c||Dc(r)}}rememberSelection(){var i,r;let e=this.doc.getSelection();if(e&&!e.isCollapsed&&e.anchorNode&&e.focusNode){let o=(i=this.lib.getPageElAssociatedWithNode(e.anchorNode))==null?void 0:i.dataset.pageNumber,s=(r=this.lib.getPageElAssociatedWithNode(e.focusNode))==null?void 0:r.dataset.pageNumber;if(o&&s){let a=this.getSelectionPos(e,"anchor"),c=this.getSelectionPos(e,"head");a&&c&&(this.previousSelection={anchor:{page:+o,pos:a},head:{page:+s,pos:c}})}}}restorePreviousSelection(){if(this.vim.doc.getSelection()&&this.vim.visualMode.previousSelection){let{anchor:i,head:r}=this.vim.visualMode.previousSelection;this.setSelectionByPos(i,r)}}forgetPreviousSelection(){this.previousSelection=null}};var Ch=class extends $i{constructor(t){super(t),this.defineKeymaps()}onload(){this.viewer.then(t=>{this.lib.registerPDFEvent("sidebarviewchanged",t.pdfViewer.eventBus,this,({view:e})=>{e===2?this.vim.enterOutlineMode():this.vim.enterNormalMode()}),this.lib.registerPDFEvent("outlineloaded",t.pdfViewer.eventBus,this,({source:e})=>{t.pdfViewer.pdfSidebar.active===2?this.vim.enterOutlineMode():this.vim.enterNormalMode()})})}defineKeymaps(){this.registerOutlineKeymaps({j:(t,e)=>this.navigateOutline(t,!0,e),k:(t,e)=>this.navigateOutline(t,!1,e),h:t=>{let e=t.highlighted;e&&e.parent&&(this.changeActiveItemTo(e.parent),this.collapse(e.parent))},l:t=>{let e=t.highlighted;if(e){this.expand(e);let i=e.children[0];i&&this.changeActiveItemTo(i)}},H:t=>{let e=t.highlighted;if(t.allItems.forEach(i=>{this.collapse(i)}),e){let i=e;for(;i.parent;)i=i.parent;this.changeActiveItemTo(i)}},L:t=>{t.allItems.forEach(e=>{this.expand(e)})},"":t=>{let e=t.highlighted;e&&e.selfEl.click()}}),this.vimScope.noremap(["outline"],{"":"","":"j","":"k","":"h","":"l","":"H","":"L"})}registerOutlineKeymaps(t){let e={};for(let i in t)e[i]=this.toVimCommand(t[i]);this.vimScope.registerKeymaps(["outline"],e)}toVimCommand(t){return e=>{var r;let i=(r=this.obsidianViewer)==null?void 0:r.pdfOutlineViewer;i&&t(i,e)}}changeActiveItemTo(t){var i;let e=t.owner;(i=e.highlighted)==null||i.setActive(!1),t.setActive(!0),e.highlighted=t,t.selfEl.scrollIntoView({block:"center",behavior:this.settings.vimSmoothOutlineMode?"smooth":"instant"})}collapse(t){t.setCollapsed(!0,this.settings.vimSmoothOutlineMode)}expand(t){t.setCollapsed(!1,this.settings.vimSmoothOutlineMode)}navigateOutline(t,e,i){let r=t.highlighted;if(r){let o=(()=>{i!=null||(i=1);let s=1/0,a=t.children.slice().reverse(),c=[];for(;a.length;){let l=a.pop();if(c.push(l),l===r&&(s=c.length-1+(e?i:-i)),c.length>s)return c[s];!l.children.length||l.collapsed||a.push(...l.children.slice().reverse())}})();o&&this.changeActiveItemTo(o)}}};var Uo=require("obsidian");var Vx=require("obsidian");var Nx=require("obsidian");function*Mx(n,t){let e=DP(t),i=Math.max(0,Math.ceil((n-t.length)/(t.length-1)));yield*CP(e,i,n+i)}function*DP(n){for(let t=1;;t++)yield*TP(SP(n,t),e=>e.join(""))}function*SP(n,t){let e=n.length,i=new Array(t).fill(0),r=1;for(let o of dg(Math.pow(e,t))){yield i.map(s=>n[s]);for(let s of dg(i.length))Ox(r,Math.pow(e,i.length-1-s))===0&&(i[s]=Ox(i[s]+1,e));r++}}function*CP(n,t,e){let i=n[Symbol.iterator]();e===void 0&&(e=t,t=0);for(let r of dg(t))if(i.next().done)return;for(let r=t;r section.linkAnnotation:has(> a)",[1]:".annotationLayer > section:not(.linkAnnotation)",[2]:".pdf-plus-backlink-highlight-layer > .pdf-plus-backlink"},en=class extends $i{constructor(){super(...arguments);this.onExitCallbacks=[];this.targets=[]}setTarget(...e){this.targets=e}getTargetSelector(){return this.targets.map(e=>Th[e]).join(",")}enter(){if(this.targets.length===0&&this.setTarget(0),this.pdfViewer){let e=this.pdfViewer.currentPageNumber;if(this.hintPage(e),this.targets.includes(2)){let i=this.vim.eventBus;if(i){let r=()=>this.hintPage(e);i.on("textlayerrendered",r),this.onExit(()=>i.off("textlayerrendered",r))}}}}exit(){this.vimScope.unregisterAllKeymaps(["hint"]),this.onExitCallbacks.forEach(e=>e())}onExit(e){this.onExitCallbacks.push(e)}hintPage(e){if(!this.pdfViewer)return;let i=this.pdfViewer.getPageView(e-1),r=i.div;if(!r)return;let o={},s="pdf-plus-vim-hint-mode",a="pdfPlusVimHint";r.addClass(s),this.onExit(()=>r.removeClass(s));let c=this.getTargetSelector(),l=r.querySelectorAll(c),d=l.length;if(d===0){new Nx.Notice(`${this.plugin.manifest.name} (Vim mode): No hintable element found on this page`),this.exit(),this.vim.enterNormalMode();return}let h=Mx(d,this.settings.vimHintChars),u=null,f=null;l.forEach(p=>{var m;if(en.isLink(p)){let b=p.querySelector(":scope > a");if(u&&u.href===b.href&&EP(u,b))return;u=b}else u=null;if(en.isBacklinkHighlight(p)){let b=(m=p.dataset.backlinkId)!=null?m:null;if(f&&b&&f===b)return;f=b}else f=null;let g=""+h.next().value;p.dataset[a]=g,this.onExit(()=>delete p.dataset[a]),o[g]=()=>{this.openHintableEl(p,i),this.exit(),this.vim.enterNormalMode()}}),this.vimScope.unregisterAllKeymaps(["hint"]),this.vimScope.registerKeymaps(["hint"],o)}openHintableEl(e,i){var r,o;if(en.isLink(e))e.querySelector(":scope > a").click();else if(en.isNonLinkAnnot(e)){ih(e);let s=e.dataset.annotationId,a=s&&((r=i==null?void 0:i.annotationLayer)==null?void 0:r.annotationLayer.getAnnotation(s));a&&((o=this.vim.child)==null||o.renderAnnotationPopup(a))}else en.isBacklinkHighlight(e)&&ih(e)}static isLink(e){return e.matches(Th[0])}static isNonLinkAnnot(e){return e.matches(Th[1])}static isBacklinkHighlight(e){return e.matches(Th[2])}},EP=(n,t)=>{let e=n.getBoundingClientRect(),i=t.getBoundingClientRect(),r=Math.min(i.height,i.width)*.5,o=r*5;return Math.abs((i.top+i.bottom)/2-(e.top+e.bottom)/2)[{id:"nextpage",func:()=>{var t;return(t=n.pdfViewer)==null?void 0:t.nextPage()}},{id:"prevpage",func:()=>{var t;return(t=n.pdfViewer)==null?void 0:t.previousPage()}},{id:"0",description:":0 - Go to the first page (same as :1)",func:()=>n.pdfViewer&&(n.pdfViewer.currentPageNumber=1)},{id:"$",description:":$ - Go to the last page.",func:()=>n.pdfViewer&&(n.pdfViewer.currentPageNumber=n.pdfViewer.pagesCount)},{id:"gotopage",pattern:/^go(to(page)?)?$/,description:":go[to[page]] - Go to the specified page. If the PDF has page labels, the argument is treated as a page label. Otherwise, it is treated as a page number.",minNargs:1,func:async t=>{if(n.pdfViewer){let e=await n.pdfViewer.pdfDocument.getPageLabels();if(e){let i=e.indexOf(t);if(i!==-1){let r=i+1;n.pdfViewer.currentPageNumber=r;return}}n.pdfViewer.currentPageNumber=+t}}},{id:"pagetop",func:()=>n.scroll.scrollToTop()},{id:"pagebottom",func:()=>n.scroll.scrollToBottom()},{id:"searchforward",pattern:/^search(f(orward)?)?$/,func:()=>setTimeout(()=>n.search.start(!0))},{id:"searchbackward",pattern:/^searchb(ackward)?$/,func:()=>setTimeout(()=>n.search.start(!1))},{id:"findnext",func:()=>n.search.findNext()},{id:"findprev",func:()=>n.search.findPrevious()},{id:"zoom",description:":zoom - Set the zoom level to percent.",minNargs:1,func:t=>n.pdfViewer&&(n.pdfViewer.currentScale=.01*+t)},{id:"zoomin",func:()=>{var t;return(t=n.obsidianViewer)==null?void 0:t.zoomIn()}},{id:"zoomout",func:()=>{var t;return(t=n.obsidianViewer)==null?void 0:t.zoomOut()}},{id:"zoomreset",func:()=>{var t;return(t=n.obsidianViewer)==null?void 0:t.zoomReset()}},{id:"rotate",func:()=>{var t;return(t=n.obsidianViewer)==null?void 0:t.rotatePages(90)}},{id:"yank",pattern:/^y(ank)?$/,func:()=>{let t=n.doc.getSelection();if(t){let e=t.toString();e&&navigator.clipboard.writeText(e),n.enterNormalMode()}}},{id:"outline",pattern:/^(outline)|(toc)$/,description:":outline or :toc - Show the outline view.",func:()=>n.lib.commands.showOutline(!1)},{id:"thumbnail",pattern:/^thumb(nail)?$/,description:":thumb[nail] - Show the thumbnails view.",func:()=>n.lib.commands.showThumbnail(!1)},{id:"closesidebar",func:()=>n.lib.commands.closeSidebar(!1)},{id:"help",pattern:/^h(elp)?$/,func:t=>{if(t&&t.startsWith(":")){let e=t.slice(1).split(" ")[0],i=n.commandLineMode.findCommand(e);if(i&&i.description){ha.renderAsModal(n.plugin,AP(i.description));return}}n.plugin.openSettingTab().scrollToHeading("vim")}},{id:"map",minNargs:2,func:(t,...e)=>n.map(["normal","visual","outline"],t,e.join(" ")),description:Ar("map",["normal","visual","outline"])},{id:"noremap",pattern:/^no(remap)$/,minNargs:2,func:(t,...e)=>n.noremap(["normal","visual","outline"],t,e.join(" ")),description:Ar("no[remap]",["normal","visual","outline"],!0)},{id:"nmap",pattern:/^nm(ap)?$/,minNargs:2,func:(t,...e)=>n.map(["normal"],t,e.join(" ")),description:Ar("nm[ap]",["normal"])},{id:"nnoremap",pattern:/^nn(oremap)?$/,minNargs:2,func:(t,...e)=>n.noremap(["normal","visual","outline"],t,e.join(" ")),description:Ar("nn[oremap]",["normal"],!0)},{id:"vmap",pattern:/^vm(ap)?$/,minNargs:2,func:(t,...e)=>n.map(["visual"],t,e.join(" ")),description:Ar("vm[ap]",["visual"])},{id:"vnoremap",pattern:/^vn(oremap)?$/,minNargs:2,func:(t,...e)=>n.noremap(["visual"],t,e.join(" ")),description:Ar("vn[oremap]",["visual"],!0)},{id:"omap",pattern:/^om(ap)?$/,minNargs:2,func:(t,...e)=>n.map(["outline"],t,e.join(" ")),description:Ar("om[ap]",["outline"])},{id:"onoremap",pattern:/^ono(remap)?$/,minNargs:2,func:(t,...e)=>n.noremap(["outline"],t,e.join(" ")),description:Ar("ono[remap]",["outline"],!0)},{id:"unmap",pattern:/^unm(ap)?$/,minNargs:1,func:t=>n.vimScope.unmap(["normal","visual","outline"],[t]),description:":unm[ap] - Unmap in all modes."},{id:"nunmap",pattern:/^nun(map)?$/,minNargs:1,func:t=>n.vimScope.unmap(["normal"],[t]),description:":nun[map] - Unmap in normal mode."},{id:"vunmap",pattern:/^vu(nmap)?$/,minNargs:1,func:t=>n.vimScope.unmap(["visual"],[t]),description:":vu[nmap] - Unmap in visual mode."},{id:"ounmap",pattern:/^ou(nmap)?$/,minNargs:1,func:t=>n.vimScope.unmap(["outline"],[t]),description:":ou[nmap] - Unmap in outline mode."},{id:"js",pattern:/^js(command)?$/,minNargs:1,func:(...t)=>n.evalUserScript(t.join(" ")),description:`:js[command] : Execute the given javascript in a context where "this" points to a "${Ho.name}" object.`},{id:"jsfile",minNargs:1,func:async(...t)=>{var r,o;let e=(0,Vx.normalizePath)(t.join(" ")),i=await n.app.vault.adapter.read((o=(r=n.app.metadataCache.getFirstLinkpathDest(e,""))==null?void 0:r.path)!=null?o:e);return await n.evalUserScript(i)},description:`:jsfile - Execute the javascript code in the file at (relative to the vault root; can be just the filename if it's unique). It can be any plain text file with arbitrary file extension. The code will be evaluated in a context where "this" points to a "${Ho.name}" object.`},{id:"obcommand",description:":obcommand - Execute the Obsidian command with the specified ID. Inspired by esm's awesome Vimrc Support plugin.",minNargs:1,func:t=>n.app.commands.executeCommandById(t)},{id:"hint",description:` :hint [ ...] - Enter hint mode and show hint marks for the specified targets in the current page. Inspired by [Tridactyl](https://github.com/tridactyl/tridactyl)'s hint mode. If no target is specified, the default targets (configured in PDF++ settings) will be used. The accepted targets are: - \`all\`: all of the followings - \`link\`: internal & external links - \`annot\`: (non-link) annotations written in the file - \`backlink\`: backlink highlighting, i.e., highlights that is not written in the file itself `,func:(...t)=>{t.length===0&&(t=n.settings.vimHintArgs.trim().split(/\s+/)),t.includes("all")&&(t=["link","annot","backlink"]),n.hintMode.setTarget(...t.map(e=>{switch(e){case"link":return 0;case"annot":return 1;case"backlink":return 2;default:throw Error(`Unknown hint target: ${e}`)}})),setTimeout(()=>n.enterHintMode())}}],AP=(n,t=12,e=!0)=>(n=n.replace(new RegExp(`^ {${t}}`,"gm"),"").replace(/^\s*/,""),e?n.replace(/([<>])/g,"\\$1"):n),Ar=(n,t,e=!1)=>`:${n} - Map to ${e?"non-recusively ":""}in ${t.length>1?t.slice(0,-1).join(", ")+" and "+t.at(-1)+" modes":t[0]+" mode"}. If is an ex-command, it must be start with ":".`;var Eh=class extends $i{constructor(e){super(e);this.history=[];this.historyIndex=0;this.isActive=!1;this.dom=this.vim.viewer.containerEl.createDiv("pdf-plus-vim-command",i=>{this.register(()=>i.remove()),i.appendText(":"),this.inputEl=i.createEl("input",{cls:"pdf-plus-vim-command-input"},r=>{r.placeholder="type a command or page number...",r.addEventListener("focusout",()=>{setTimeout(()=>{this.isActive&&this.vim.enterNormalMode()})}),r.addEventListener("keydown",o=>{if(!o.isComposing&&o.key==="Enter"){this.submitCommand();return}if(o.key==="Escape"||o.key==="Backspace"&&!r.value){this.vim.enterNormalMode(),o.preventDefault();return}if(o.key==="ArrowUp"||o.key==="ArrowDown"){o.preventDefault(),this.navigateHistory(o.key==="ArrowDown");return}})}),i.hide()}),this.vimScope.registerKeymaps(["command"],{"":()=>this.inputEl.value="","":()=>this.inputEl.value=this.inputEl.value.replace(/\S+\s*$/,"")}),this.excmds=Bx(this.vim),this.suggest=new hg(this).onSelect(({item:{minNargs:i}})=>setTimeout(()=>{if(!i){this.submitCommand();return}this.inputEl.value+=" "})),this.settings.vimrcPath&&this.viewer.then(i=>{let r=i.pdfViewer.eventBus;r&&r.on("pagesloaded",()=>setTimeout(()=>{if(this.plugin.vimrc===null){let o=(0,Uo.normalizePath)(this.settings.vimrcPath);this.app.vault.adapter.read(o).then(s=>this.runScript(this.plugin.vimrc=s))}else this.runScript(this.plugin.vimrc)},{once:!0}))})}async executeCommand(e,i={error:["notice","console.error"],history:!0}){if(i={error:[],history:!0,...i},i.history&&(this.history.push(e),this.history.length>100&&this.history.shift(),this.historyIndex=this.history.length),e.startsWith("!")){if(!Uo.Platform.isDesktopApp){this.reportError(`${this.plugin.manifest.name} (Vim mode): Shell command is not supported on mobile`,i.error);return}let{exec:a}=require("child_process"),c=process.env;return this.settings.PATH&&(c.PATH=this.settings.PATH),new Promise((l,d)=>a(e.slice(1),{env:c},(h,u,f)=>{h&&d(h),u&&(alert(u),l(u)),f&&console.warn(f)}))}if(/^[1-9]\d*$/.test(e)){let a=+e;this.pdfViewer&&(this.pdfViewer.currentPageNumber=a);return}let[r,...o]=e.split(/\s+/),s=this.findCommand(r);if(s){if(s.minNargs&&o.lengthi.pattern&&i.pattern.test(e)||i.id===e)}submitCommand(){let e=this.inputEl.value.trim();if(e){this.history[this.historyIndex]===e&&this.history.splice(this.historyIndex,1);try{this.executeCommand(e)}catch(r){new Uo.Notice(`${this.plugin.manifest.name} (Vim mode): Error occurred while executing the command : ${r}`),console.error(r)}}this.vim.enterNormalMode()}runScript(e){this.parseScript(e).forEach(r=>this.executeCommand(r,{error:["console.warn"],history:!1}))}parseScript(e){return e.split(/\r?\n/).filter(i=>i.trim()&&!i.trimStart().startsWith('"')).join(` `).replace(/\\\n/g,"").split(` `)}enter(){this.inputEl.value="",this.dom.show(),this.inputEl.focus(),this.isActive=!0}exit(){this.isActive=!1,this.inputEl.value="",this.dom.hide()}navigateHistory(e){let i=this.inputEl;if(this.historyIndexs.key==="Escape"&&s.modifiers==="");i&&this.scope.unregister(i);let r=this.scope.keys.find(s=>s.key==="ArrowDown"&&s.modifiers===""),o=this.scope.keys.find(s=>s.key==="ArrowUp"&&s.modifiers==="");r&&(this.scope.unregister(r),this.scope.register([],"Tab",r.func)),o&&(this.scope.unregister(o),this.scope.register(["Shift"],"Tab",o.func))}getItems(){return this.commandLineMode.excmds}getItemText(e){return e.id}};var Ah=class extends de{constructor(e,i,r){super(e);this.pages=new Map;this.pdfViewer=i,this.file=r}onload(){this.registerEvent(this.app.vault.on("modify",e=>{e===this.file&&this.pages.clear()}))}getPageParser(e){var r,o;let i=this.pages.get(e);if(!i){let s=this.pdfViewer.getPageView(e-1);if(s){let a=(r=s.textLayer)==null?void 0:r.textContentItems,c=(o=s.textLayer)==null?void 0:o.textDivs;a&&c&&(i=new ug(s,a,c),this.pages.set(e,i))}}return i}},ug=class{constructor(t,e,i){this.lineStartIndices=null;this.pageView=t,this.items=e,this.divs=i}getBoundIndicesOfLine(t,e){var a;let i=this._getIndexWithinLineStartIndicesForLineContainingItem(t),r=(a=this.lineStartIndices[i+e])!=null?a:null;if(r===null)return null;let o=this.lineStartIndices[i+1+e],s=o===void 0?this.items.length-1:o-1;for(;s>r&&!this.items[s].str.length;)s--;return{start:r,end:s}}getLineShiftPosition(t,e){let i=this.getBoundIndicesOfLine(t.index,e);if(!i)return null;let r=this._getHorizontalRangeOfChar(t);if(!r)return null;let{start:o,end:s}=i,a=o;for(;a<=s;a++){let d=this.items[a],h=this._getHorizontalRangeOfItem(d);if(Rp(r,h))break}for(a>s&&(a=s);a>o&&!this.items[a].str.length;)a--;let c=this.items[a],l=0;for(;;){let d=this._getHorizontalRangeOfChar({index:a,offset:l});if(!d)return null;if(d.from>=r.from||d.to>=r.to)return{index:a,offset:l};if(l+1t-r);return e?i:i-1}parse(){let t=this._findIndexOfFirstNonEmptyItem();if(t===-1){this.lineStartIndices=[0];return}this.lineStartIndices=[t];let e=[this.items[t]];for(let i=t+1;ithis.isItemNonEmpty(t))}isItemNonEmpty(t){let e=this._getVerticalRangeOfItem(t);return e.froms.from)),o=Math.max(...i.map(s=>s.to));return{from:r,to:o}}_getHorizontalRangeOfItem(t){return{from:t.transform[4],to:t.transform[4]+t.width}}_getHorizontalRangeOfChar(t){let e=t.index,i=t.offset,r=this.items[e];if(r.chars&&r.chars.length>=r.str.length){let f=r.chars[i];return{from:f.r[0],to:f.r[2]}}let o=this.divs[e],s=ea(o,i);if(!s)return null;let{node:a,offset:c}=s,l=o.doc.createRange();l.setStart(a,c),l.setEnd(a,c+1);let d=l.getBoundingClientRect(),[[h],[u]]=[...oh(this.pageView,[{x:d.left,y:d.bottom},{x:d.right,y:d.top}])];return{from:h,to:u}}};var ua=class extends de{constructor(e,i){super(e);this._structureParser=null;this.viewer=i,this.vimScope=new Er(this.viewer.scope),this.vimScope.registerKeymaps(["normal","visual","outline"],{":":()=>this.enterCommandMode(),"":()=>{if(this.obsidianViewer){let r=this.obsidianViewer.pdfSidebar;r.isOpen&&r.active===2?r.close():r.switchView(2,!0)}},"":()=>{if(this.obsidianViewer){let r=this.obsidianViewer.pdfSidebar;r.isOpen&&r.active===1?r.close():r.switchView(1,!0)}},f:()=>this.commandLineMode.executeCommand("hint")}),this.vimScope.registerKeymaps(["normal","visual","outline"],{j:r=>this.scroll.scrollTo("down",r),k:r=>this.scroll.scrollTo("up",r),h:r=>this.scroll.scrollTo("left",r),l:r=>this.scroll.scrollTo("right",r),J:ah(()=>{var r;return(r=this.pdfViewer)==null?void 0:r.nextPage()}),K:ah(()=>{var r;return(r=this.pdfViewer)==null?void 0:r.previousPage()}),gg:()=>this.pdfViewer&&(this.pdfViewer.currentPageNumber=1),G:r=>this.pdfViewer&&(this.pdfViewer.currentPageNumber=r!=null?r:this.pdfViewer.pagesCount),0:()=>this.scroll.scrollToTop(),"^":()=>this.scroll.scrollToTop(),$:()=>this.scroll.scrollToBottom(),"":r=>this.scroll.scrollVerticallyByVisualPage(r!=null?r:1),"":r=>this.scroll.scrollVerticallyByVisualPage(-(r!=null?r:1)),"":r=>this.scroll.scrollVerticallyByVisualPage(.5*(r!=null?r:1)),"":r=>this.scroll.scrollVerticallyByVisualPage(-.5*(r!=null?r:1)),"/":()=>this.search.start(!0),"?":()=>this.search.start(!1),n:r=>this.search.findNext(r),N:r=>this.search.findPrevious(r),gn:r=>this.search.findAndSelectNextMatch((r!=null?r:1)-1),gN:r=>this.search.findAndSelectNextMatch((r!=null?r:1)-1,!1),"+":r=>{var o;return(o=this.obsidianViewer)==null?void 0:o.zoomIn(r)},"-":r=>{var o;return(o=this.obsidianViewer)==null?void 0:o.zoomOut(r)},"=":r=>{var o;if(typeof r=="number"&&this.pdfViewer){this.pdfViewer.currentScaleValue=""+.01*r;return}(o=this.obsidianViewer)==null||o.zoomReset()},r:r=>{var o;return(o=this.obsidianViewer)==null?void 0:o.rotatePages(90*(r!=null?r:1))},R:r=>{var o;return(o=this.obsidianViewer)==null?void 0:o.rotatePages(-90*(r!=null?r:1))}}),this.vimScope.noremap(["normal","visual","outline"],{H:"^",L:"$",zi:"+",zo:"-",z0:"="}),this.vimScope.setMode("normal"),this.vimScope.setTypable("command"),this.vimScope.onEscape(r=>{var o,s,a;this.enterNormalMode(),(o=this.obsidianViewer)==null||o.pdfSidebar.close(),(a=(s=this.child)==null?void 0:s.hoverPopover)==null||a.hide(),r||this.viewer.then(c=>{c.clearEphemeralUI(),c.findBar.close()})}),this.vimScope.addEscapeAliases("",""),this.scroll=new kh(this),this.search=new Dh(this),this.visualMode=this.addChild(new Sh(this)),this.commandLineMode=this.addChild(new Eh(this)),this.outlineMode=this.addChild(new Ch(this)),this.hintMode=this.addChild(new en(this))}get child(){return this.viewer.child}get obsidianViewer(){var e;return(e=this.viewer.child)==null?void 0:e.pdfViewer}get pdfViewer(){var e,i;return(i=(e=this.viewer.child)==null?void 0:e.pdfViewer)==null?void 0:i.pdfViewer}get eventBus(){var e;return(e=this.obsidianViewer)==null?void 0:e.eventBus}get file(){var e;return(e=this.viewer.child)==null?void 0:e.file}get structureParser(){var e;return!this._structureParser&&this.pdfViewer&&((e=this.viewer.child)!=null&&e.file)&&(this._structureParser=this.addChild(new Ah(this.plugin,this.pdfViewer,this.viewer.child.file))),this._structureParser}get doc(){return this.viewer.containerEl.doc}onload(){this.lib.workspace.iteratePDFViews(e=>{e.viewer===this.viewer&&(e.scope=this.vimScope)})}onunload(){this.lib.workspace.iteratePDFViews(e=>{e.viewer===this.viewer&&(e.scope=this.viewer.scope)})}static register(e,i){e.settings.vim&&(i.vim=e.addChild(i.addChild(new ua(e,i))))}enterNormalMode(){var e;this.vimScope.setMode("normal"),(e=this.doc.getSelection())==null||e.empty(),this.commandLineMode.exit(),this.hintMode.exit(),this.visualMode.forgetPreviousSelection()}enterCommandMode(){this.vimScope.setMode("command"),this.commandLineMode.enter()}enterOutlineMode(){if(this.settings.enableVimOutlineMode&&this.obsidianViewer){this.vimScope.setMode("outline");let e=this.obsidianViewer.pdfOutlineViewer;if(!e.highlighted){let i=e.children[0];i.setActive(!0),e.highlighted=i}}}enterHintMode(){this.vimScope.setMode("hint"),this.hintMode.enter()}mapOrNoremap(e,i,r,o){r.startsWith(":")?this.vimScope.registerKeymaps(e,{[i]:()=>this.commandLineMode.executeCommand(r.slice(1))}):r===""?this.vimScope.registerKeymaps(e,{[i]:()=>{}}):this.vimScope[o?"noremap":"map"](e,{[i]:r})}map(e,i,r){this.mapOrNoremap(e,i,r,!1)}noremap(e,i,r){this.mapOrNoremap(e,i,r,!0)}async evalUserScript(e){return new Promise(i=>{this.viewer.then(async r=>{let o=this.addChild(new Ho(this.plugin,r));i(await o.run(e))})})}};var fa=async(n,t)=>n.patchStatus.pdfInternals?!0:new Promise(e=>{t.then(i=>{var o;return n.patchStatus.pdfInternals?e(!0):(LP(n,t),!i.toolbar||(OP(n,i),!i.pdfViewer)?e(!1):(MP(n,i.pdfViewer),NP(n),n.patchStatus.pdfInternals=!0,n.classes.PDFViewerComponent=t.constructor,n.classes.PDFViewerChild=i.constructor,n.classes.ObsidianViewer=(o=i.pdfViewer)==null?void 0:o.constructor,IP(n),e(!0)))})});function IP(n){let{lib:t}=n;t.workspace.iteratePDFViewerComponents((e,i)=>{e.unload();let r=e.scope.keys.find(o=>o.modifiers===""&&o.key==="Escape");r&&e.scope.unregister(r),e.load(),i&&e.loadFile(i,n.subpathWhenPatched)})}var LP=(n,t)=>{n.register(Ze(t.constructor.prototype,{loadFile(e){return async function(i,r){let o=await e.call(this,i,r);return this.then(s=>{var a;s.parent=this,(!this.visualizer||this.visualizer.file!==i)&&((a=this.visualizer)==null||a.unload(),this.visualizer=this.addChild(ca.create(n,i,s)))}),o}},onload(e){return async function(){let i=await e.call(this);return ua.register(n,this),i}}}))},OP=(n,t)=>{let{app:e,lib:i}=n;n.register(Ze(t.constructor.prototype,{load(o){return async function(...s){var f,p,g;this.hoverPopover=null,this.isFileExternal=!1,this.externalFileUrl=null,this.palette=null,this.rectHighlight=null,this.bib=null,this.component||(this.component=n.addChild(new he.Component)),this.component.load();let a=await o.call(this,...s),c=(p=(f=this.pdfViewer)==null?void 0:f.dom)==null?void 0:p.viewerContainerEl;if(c){let m=!1,b=F=>{m||(m=Tp(n.settings.showContextMenuOnMouseUpIf)&&he.Keymap.isModifier(F,n.settings.showContextMenuOnMouseUpIf))};this.component.registerDomEvent(c,"pointerdown",F=>{var v;i.highlight.viewer.clearRectHighlight(this),b(F),(v=this.component)==null||v.registerDomEvent(c,"mouseup",w)});let w=F=>{var v;if(b(F),n.settings.autoCopy){i.commands.copyLink(!1,!1);return}n.settings.replaceContextMenu&&(n.settings.showContextMenuOnMouseUpIf==="always"||m)&&(v=F.win.getSelection())!=null&&v.toString()&&F.win.setTimeout(()=>ng(n,this,F),80),c.removeEventListener("mouseup",w),m=!1}}let l=()=>{var m,b;try{if(this.toolbar)n.domManager.addChild(new da(n,this.toolbar,this));else{let F=window.setInterval(()=>{this.toolbar&&(n.domManager.addChild(new da(n,this.toolbar,this)),window.clearInterval(F))},100);window.setTimeout(()=>{window.clearInterval(F)},1e3)}let w=(b=(m=this.pdfViewer)==null?void 0:m.dom)==null?void 0:b.viewerContainerEl;n.settings.autoHidePDFSidebar&&w&&(this.component||(this.component=n.addChild(new he.Component)),this.component.registerDomEvent(w,"click",()=>{this.pdfViewer.pdfSidebar.switchView(0)}))}catch(w){new he.Notice(`${n.manifest.name}: An error occurred while mounting the color palette to the toolbar.`),console.error(w)}};if(l(),n.on("update-dom",l),!he.Platform.isMobile){let m=this.pdfViewer.eventBus;m&&m.on("textlayerrendered",({source:b})=>{var F;let w=(F=b==null?void 0:b.textLayer)==null?void 0:F.div;w&&w.addEventListener("copy",r)})}let d="1.7.0",h=(g=this.findBar)==null?void 0:g.findNextButtonEl,u=h.firstElementChild;return!(0,he.requireApiVersion)(d)&&u&&u.matches("svg.lucide-arrow-up")&&(0,he.setIcon)(h,"lucide-arrow-down"),a}},unload(o){return function(){var s;return(s=this.component)==null||s.unload(),o.call(this)}},onResize(o){return function(){let s=this.containerEl.querySelector(".pdf-viewer");return s&&n.pdfViewerChildren.set(s,this),o.call(this)}},loadFile(o){return async function(s,a){var d;this.component||(this.component=n.addChild(new he.Component));let c=!1;if(s.stat.size<300){let h=await i.getExternalPDFUrl(s);if(h){let u=e.vault.getResourcePath(s).replace(/\?\d+$/,"");this.pdfViewer.pdfPlusRedirect={from:u,to:h},await o.call(this,s,a),this.component.register(()=>URL.revokeObjectURL(h)),c=!0,this.isFileExternal=!0,this.externalFileUrl=h,this.palette&&this.palette.paletteEl&&(this.palette.removeWriteFileToggle(),this.palette.addImportButton(this.palette.paletteEl))}}c||(this.isFileExternal=!1,this.externalFileUrl=null,await o.call(this,s,a));let l=this.containerEl.querySelector(".pdf-viewer");l&&n.pdfViewerChildren.set(l,this),(d=this.bib)==null||d.unload(),this.bib=this.component.addChild(new Ci(n,this)),i.registerPDFEvent("annotationlayerrendered",this.pdfViewer.eventBus,this.component,h=>{var f,p;let{source:u}=h;(p=(f=u.annotationLayer)==null?void 0:f.div)==null||p.querySelectorAll("section[data-annotation-id]").forEach(g=>{var w,F;let m=g.dataset.annotationId;if(!m)return;let b=(w=u.annotationLayer)==null?void 0:w.annotationLayer.getAnnotation(m);b&&b.container.dataset.pdfPlusIsAnnotationPostProcessed!=="true"&&(b.data.subtype==="Link"&&typeof b.container.dataset.internalLink=="string"?Yi.registerEvents(n,this,b):b.data.subtype==="Link"&&b.data.url&&Vn.registerEvents(n,this,b),n.settings.hideReplyAnnotation&&b.data.inReplyTo&&b.data.replyType==="R"&&b.container.hide(),!he.Platform.isPhone&&n.settings.showAnnotationPopupOnHover&&((F=b.data.contentsObj)!=null&&F.str)&&Pc({parentEl:b.container,createChildEl:()=>(this.destroyAnnotationPopup(),this.renderAnnotationPopup(b),this.activeAnnotationPopupEl),removeChildEl:()=>{var v;((v=this.activeAnnotationPopupEl)==null?void 0:v.dataset.annotationId)===b.data.id&&this.destroyAnnotationPopup()},component:this.component}),b.container.dataset.pdfPlusIsAnnotationPostProcessed="true")})}),i.registerPDFEvent("outlineloaded",this.pdfViewer.eventBus,null,async h=>{let u=h.source;if(!n.patchStatus.pdfOutlineViewer){let p=Hx(n,u);n.patchStatus.pdfOutlineViewer=p}if(!h.outlineCount)return;let f=this.file;f&&(n.settings.outlineDrag&&await Cx(n,u,this,f),u.allItems.forEach(p=>Ji.registerEvents(n,this,p)),n.settings.outlineContextMenu&&n.registerDomEvent(u.childrenEl,"contextmenu",p=>{p.target===p.currentTarget&&Dx(n,this,f,p)}))}),i.registerPDFEvent("thumbnailrendered",this.pdfViewer.eventBus,null,()=>{let h=this.file;h&&(n.settings.thumbnailDrag&&Tx(n,this,h),Qi.registerEvents(n,this))}),n.settings.noSpreadModeInEmbed&&!On(this.pdfViewer)&&i.registerPDFEvent("pagerendered",this.pdfViewer.eventBus,null,()=>{this.pdfViewer.eventBus.dispatch("switchspreadmode",{mode:0})}),i.registerPDFEvent("sidebarviewchanged",this.pdfViewer.eventBus,null,h=>{let{source:u}=h;n.settings.noSidebarInEmbed&&!On(this.pdfViewer)&&u.close(),n.settings.defaultSidebarView===2&&u.haveOutline&&u.switchView(2)}),On(this.pdfViewer)&&i.registerPDFEvent("pagechanging",this.pdfViewer.eventBus,this.component,(0,he.debounce)(({pageNumber:h})=>{if(n.settings.viewSyncFollowPageNumber){let u=i.workspace.getActivePDFView();if(u&&u.viewer.child===this){let f={state:{file:this.file.path,page:h}};e.workspace.trigger("view-sync:state-change",u,f)}}},n.settings.viewSyncPageDebounceInterval*1e3))}},applySubpath(o){return function(s){let a=l=>{if(!l)return null;let d=parseInt(l);return Number.isNaN(d)?null:d},c=l=>{if(!l)return null;let d=parseFloat(l);return Number.isNaN(d)?null:d};if(s){s=s.startsWith("#")?s.substring(1):s;let l=this.pdfViewer,d=new URLSearchParams(s);if(d.has("search")&&this.findBar){let p=d.get("search"),g={};n.settings.searchLinkHighlightAll!=="default"&&(g.highlightAll=n.settings.searchLinkHighlightAll==="true"),n.settings.searchLinkCaseSensitive!=="default"&&(g.caseSensitive=n.settings.searchLinkCaseSensitive==="true"),n.settings.searchLinkMatchDiacritics!=="default"&&(g.matchDiacritics=n.settings.searchLinkMatchDiacritics==="true"),n.settings.searchLinkEntireWord!=="default"&&(g.entireWord=n.settings.searchLinkEntireWord==="true");let m=b=>{let w=Fp(b);if(d.has(w)){let F=d.get(w);(F==="true"||F==="false")&&(g[b]=F==="true")}};m("highlightAll"),m("caseSensitive"),m("matchDiacritics"),m("entireWord"),setTimeout(()=>i.search(this.findBar,p,g));return}let{dest:h,highlight:u}=(p=>{var w,F,v;if(!d.has("page"))return{dest:p,highlight:null};let g=(w=a(d.get("page")))!=null?w:1,m=null;if(n.settings.zoomToFitRect&&d.has("rect")){let P=d.get("rect").split(",").map(c);P.length===4&&P.every(k=>k!==null)&&(m=[g-1,{name:"FitR"},...P])}if(!m)if(d.has("offset")){let P=d.get("offset").split(","),k=c(P[0]),C=c(P[1]),D=c(P[2]);m=D===null?[g-1,{name:"FitBH"},C]:[g-1,{name:"XYZ"},k,C,D]}else if(!this.opts.isEmbed&&n.settings.dontFitWidthWhenOpenPDFLink){let P=(F=this.pdfViewer)==null?void 0:F.pdfViewer,k=P==null?void 0:P._location;n.settings.preserveCurrentLeftOffsetWhenOpenPDFLink?m=[g-1,{name:"XYZ"},(v=k==null?void 0:k.left)!=null?v:null,null,null]:m=[g-1,{name:"XYZ"},null,null,null]}else m=[g-1,{name:"FitBH"},null];let b=null;if(d.has("annotation"))b={type:"annotation",page:g,id:d.get("annotation")};else if(d.has("selection")){let P=d.get("selection").split(",").map(a),[k,C,D,T]=P;k!==null&&C!==null&&D!==null&&T!==null&&(b={type:"text",page:g,range:[[k,C],[D,T]]})}else if(d.has("rect")){let P=d.get("rect").split(",").map(c);P.length===4&&P.every(k=>k!==null)&&(b={type:"rect",page:g,rect:P})}return{dest:JSON.stringify(m),highlight:b}})(s),f=l.pdfLoadingTask;f?f.promise.then(()=>l.applySubpath(h)):l.subpath=h,this.subpathHighlight=u}}},getMarkdownLink(o){return function(s,a,c){if(!this.file)return o.call(this,s,a,c);let l=i.generateMarkdownLink(this.file,"",s,a);return c?l:l.slice(1)}},getPageLinkAlias(o){return function(s){var a,c;if(this.file){let l=i.copyLink.getDisplayText(this,void 0,this.file,s,i.toSingleLine((c=(a=activeWindow.getSelection())==null?void 0:a.toString())!=null?c:""));if(l)return l}return o.call(this,s)}},highlightText(o){return function(s,a){var h,u,f,p,g;let c=this.getPage(s),l=a[0][0],d=(h=c.textLayer)==null?void 0:h.textDivs[l];if(n.settings.trimSelectionEmbed&&this.pdfViewer.isEmbed&&this.pdfViewer.dom&&!(n.settings.ignoreHeightParamInPopoverPreview&&((u=this.pdfViewer.dom.containerEl.parentElement)!=null&&u.matches(".hover-popover")))){let m=a[1][0],b=(f=c.textLayer)==null?void 0:f.textDivs[m];d&&b&&setTimeout(()=>{let w=this.pdfViewer.dom.viewerContainerEl.getBoundingClientRect(),F=d.getBoundingClientRect(),P=b.getBoundingClientRect().bottom-F.top+2*Math.abs(F.top-w.top);this.pdfViewer.setHeight(P)},100)}n.settings.noTextHighlightsInEmbed&&this.pdfViewer.isEmbed&&!((g=(p=this.pdfViewer.dom)==null?void 0:p.containerEl.parentElement)!=null&&g.matches(".hover-popover"))||o.call(this,s,a),window.pdfjsViewer.scrollIntoView(d,{top:-n.settings.embedMargin},!0),n.trigger("highlight",{type:"selection",source:"obsidian",pageNumber:s,child:this})}},highlightAnnotation(o){return function(s,a){var d,h,u;let c=()=>{var p;return this.annotationHighlight?this.annotationHighlight:(p=this.getPage(s).annotationLayer)==null?void 0:p.div.querySelector(`[data-annotation-id="${a}"]`)};n.settings.trimSelectionEmbed&&this.pdfViewer.isEmbed&&this.pdfViewer.dom&&!(n.settings.ignoreHeightParamInPopoverPreview&&((d=this.pdfViewer.dom.containerEl.parentElement)!=null&&d.matches(".hover-popover")))&&setTimeout(()=>{let f=c();if(f){let p=this.pdfViewer.dom.viewerContainerEl.getBoundingClientRect(),g=f.getBoundingClientRect(),m=g.bottom-g.top+2*Math.abs(g.top-p.top);this.pdfViewer.setHeight(m)}},100),n.settings.noAnnotationHighlightsInEmbed&&this.pdfViewer.isEmbed&&!((u=(h=this.pdfViewer.dom)==null?void 0:h.containerEl.parentElement)!=null&&u.matches(".hover-popover"))||o.call(this,s,a);let l=c();l&&activeWindow.setTimeout(()=>{window.pdfjsViewer.scrollIntoView(l,{top:-n.settings.embedMargin},!0)}),n.trigger("highlight",{type:"annotation",source:"obsidian",pageNumber:s,child:this})}},clearTextHighlight(o){return function(){var s,a;n.settings.persistentTextHighlightsInEmbed&&((a=(s=this.pdfViewer)==null?void 0:s.isEmbed)!=null?a:this.opts.isEmbed)||o.call(this)}},clearAnnotationHighlight(o){return function(){n.settings.persistentAnnotationHighlightsInEmbed&&this.pdfViewer.isEmbed||o.call(this)}},clearEphemeralUI(o){return function(){o.call(this),i.highlight.viewer.clearRectHighlight(this)}},renderAnnotationPopup(o){return function(s,...a){var u,f;if(s.data.subtype==="Link")return;let c=o.call(this,s,...a);n.lastAnnotationPopupChild=this;let{page:l,id:d}=i.getAnnotationInfoFromAnnotationElement(s);if(n.settings.renderMarkdownInStickyNote&&this.file){let p=(u=this.activeAnnotationPopupEl)==null?void 0:u.querySelector(".popupContent");p&&(p.textContent="",i.highlight.writeFile.getAnnotationContents(this.file,l,d).then(async g=>{var m,b;g&&(p.addClass("markdown-rendered"),this.component||(this.component=n.addChild(new he.Component)),await he.MarkdownRenderer.render(e,g,p,"",this.component),Fc(e,p,(b=(m=this.file)==null?void 0:m.path)!=null?b:""))}))}let h=p=>{p.createDiv("pdf-plus-annotation-icon-container",g=>{let m=p==null?void 0:p.querySelector(".clickable-icon:last-child");if(m&&(m.remove(),g.createDiv("clickable-icon pdf-plus-copy-annotation-link",b=>{(0,he.setIcon)(b,"lucide-copy"),(0,he.setTooltip)(b,"Copy link"),b.addEventListener("click",async()=>{let w=i.getColorPaletteAssociatedWithNode(p);if(!w)return;let F=n.settings.copyCommands[w.actionIndex].template;i.copyLink.copyLinkToAnnotation(this,!1,{copyFormat:F},l,d),(0,he.setIcon)(b,"lucide-check")})})),i.isEditable(this)&&n.settings.enableAnnotationContentEdit&&Mn.isSubtypeSupported(s.data.subtype)){let b=s.data.subtype;g.createDiv("clickable-icon pdf-plus-edit-annotation",w=>{(0,he.setIcon)(w,"lucide-pencil"),(0,he.setTooltip)(w,"Edit"),w.addEventListener("click",async()=>{this.file&&Mn.forSubtype(b,n,this.file,l,d).open()})})}i.isEditable(t)&&n.settings.enableAnnotationDeletion&&g.createDiv("clickable-icon pdf-plus-delete-annotation",b=>{(0,he.setIcon)(b,"lucide-trash"),(0,he.setTooltip)(b,"Delete"),b.addEventListener("click",async()=>{this.file&&new ra(n,this.file,l,d).openIfNeccessary()})})}),p.addEventListener("contextmenu",g=>{new he.Menu().addItem(m=>{m.setTitle("Customize...").setIcon("lucide-settings").onClick(()=>{n.openSettingTab().scrollToHeading("annot")})}).showAtMouseEvent(g),g.preventDefault()})};if(he.Platform.isPhone){let p=new MutationObserver((g,m)=>{for(let b of g)for(let w of b.addedNodes)if(w.instanceOf(HTMLElement)&&w.matches("div.modal-container.pdf-annotation-modal")){let F=w.querySelector(".popupMeta");if(F){h(F),m.disconnect();return}}});activeWindow.setTimeout(()=>p.observe(activeDocument.body,{childList:!0})),activeWindow.setTimeout(()=>p.disconnect(),1e3)}else{let p=(f=this.activeAnnotationPopupEl)==null?void 0:f.querySelector(".popupMeta");p&&h(p)}if(n.settings.annotationPopupDrag&&this.activeAnnotationPopupEl&&this.file){let p=this.activeAnnotationPopupEl,g=this.file;Ex(n,p,this,g,l,d),p.addClass("pdf-plus-draggable")}return c}},destroyAnnotationPopup(o){return function(){return n.lastAnnotationPopupChild=null,o.call(this)}},onContextMenu(o){return async function(s){if(!he.Platform.isPhone&&!(he.Platform.isTablet&&!n.settings.showContextMenuOnTablet)){if(!n.settings.replaceContextMenu)return await o.call(this,s);Fx(n,this,s)}}},onMobileCopy(o){return function(s,a){switch(n.settings.mobileCopyAction){case"text":r(s);return;case"pdf-plus":setTimeout(()=>i.commands.copyLink(!1));return;case"obsidian":return o.call(this,s,a)}}},onThumbnailContextMenu(o){return function(s){if(!n.settings.thumbnailContextMenu)return o.call(this,s);Px(n,this,s)}},getTextByRect(o){return function(s,a){var h,u;let c="",l=(h=s.textLayer)==null?void 0:h.textContentItems,d=(u=s.textLayer)==null?void 0:u.textDivs;if(l){let[f,p,g,m]=a;for(let b=0;b{var c;if(!n.settings.copyAsSingleLine)return;let s=o.clipboardData;if(!s)return;let a=(c=o.target.win.getSelection())==null?void 0:c.toString();a&&(a=i.toSingleLine(a),s.setData("text/plain",a))}},MP=(n,t)=>{n.register(Ze(t.constructor.prototype,{open(e){return async function(i){if(this.pdfPlusRedirect){let{from:r,to:o}=this.pdfPlusRedirect,s=i.url;typeof s=="string"&&s.startsWith(r)&&(i.url=o)}return delete this.pdfPlusRedirect,await e.call(this,i)}},load(e){return function(i,...r){let o=this.pdfPlusCallbacksOnDocumentLoaded;if(o)for(let s of o)s(i);return delete this.pdfPlusCallbacksOnDocumentLoaded,e.call(this,i,...r)}}}))},NP=n=>{n.register(Ze(window.pdfjsViewer.ObsidianServices.prototype,{createPreferences(t){return function(...e){return Object.assign(this.preferences,{defaultZoomValue:n.settings.defaultZoomValue,scrollModeOnLoad:n.settings.scrollModeOnLoad,spreadModeOnLoad:n.settings.spreadModeOnLoad}),t.call(this,...e)}}}))};var Ux=n=>{if(n.patchStatus.pdfView&&n.patchStatus.pdfInternals)return!0;let t=n.lib,e=t.getPDFView();return e&&(n.patchStatus.pdfView||(n.register(Ze(e.constructor.prototype,{getState(i){return function(){var c,l,d,h,u;let r=i.call(this),s=this.viewer.child,a=(c=s==null?void 0:s.pdfViewer)==null?void 0:c.pdfViewer;return a&&(r.page=(d=(l=a._location)==null?void 0:l.pageNumber)!=null?d:a.currentPageNumber,r.left=(h=a._location)==null?void 0:h.left,r.top=(u=a._location)==null?void 0:u.top,r.zoom=a.currentScale),r}},setState(i){return function(r,o){return n.settings.alwaysRecordHistory&&(o.history=!0),i.call(this,r,o).then(()=>{var l;let a=this.viewer.child,c=(l=a==null?void 0:a.pdfViewer)==null?void 0:l.pdfViewer;typeof r.page=="number"&&c&&t.applyPDFViewStateToViewer(c,r)})}},onLoadFile(i){return async function(r){let o=this,s=o.getState(),a=t.viewStateToSubpath(s);return o.viewer.loadFile(r,a!=null?a:void 0)}}})),n.patchStatus.pdfView=!0,n.classes.PDFView=e.constructor),n.patchStatus.pdfInternals||fa(n,e.viewer)),!1};var zx=n=>{if(n.patchStatus.pdfInternals)return!0;let{lib:t}=n,e=t.getPDFEmbed();return e&&fa(n,e.viewer),!1};var Hx=(n,t)=>(n.register(Ze(t.constructor.prototype,{onItemContextMenu(e){return async function(i,r){let o=this,s=o.viewer,a=s.file;if(!n.settings.outlineContextMenu||!a)return await e.call(o,i,r);kx(n,s,a,i,r)}}})),!0);var pa=require("obsidian");var qx=n=>{let t=n.app,e=n.lib;n.register(Ze(pa.Workspace.prototype,{openLinkText(i){return function(r,o,s,a){var c;if((n.settings.openPDFWithDefaultApp||n.settings.singleTabForSinglePDF||n.settings.openLinkNextToExistingPDFTab||n.settings.paneTypeForFirstPDFLeaf)&&!s){let{path:l}=(0,pa.parseLinktext)(r),d=t.metadataCache.getFirstLinkpathDest(l,o);if(d&&d.extension==="pdf"){if(pa.Platform.isDesktopApp&&n.settings.openPDFWithDefaultApp){if(n.settings.openPDFWithDefaultAppAndObsidian&&n.settings.syncWithDefaultApp)return;let h=t.openWithDefaultApp(d.path);if(n.settings.focusObsidianAfterOpenPDFWithDefaultApp&&Ac(),!n.settings.openPDFWithDefaultAppAndObsidian)return h}if(n.settings.singleTabForSinglePDF){let{exists:h,promise:u}=e.workspace.openPDFLinkTextInExistingLeafForTargetPDF(r,o,a,d);if(h)return u}if(n.settings.openLinkNextToExistingPDFTab||n.settings.paneTypeForFirstPDFLeaf){let h=(c=e.getPDFView())==null?void 0:c.leaf;if(h){if(n.settings.openLinkNextToExistingPDFTab&&h.parentSplit){let u=t.workspace.createLeafInParent(h.parentSplit,-1);return e.workspace.openPDFLinkTextInLeaf(u,r,o,a)}}else if(n.settings.paneTypeForFirstPDFLeaf){let u=e.workspace.getLeaf(n.settings.paneTypeForFirstPDFLeaf);return e.workspace.openPDFLinkTextInLeaf(u,r,o,a)}}}}return i.call(this,r,o,s,a)}}})),n.patchStatus.workspace=!0};var Wx=require("obsidian");var jx=n=>{let t=n.app,e=n.lib,i=t.internalPlugins.plugins["page-preview"].instance;return n.register(Ze(i,{onLinkHover(r){return function(o,s,a,c,l){let{path:d,subpath:h}=(0,Wx.parseLinktext)(a),u=t.metadataCache.getFirstLinkpathDest(d,c);if((!c||c.endsWith(".pdf"))&&n.settings.hoverHighlightAction==="open"&&(l!=null&&l.isTriggeredFromBacklinkVisualizer)){e.workspace.openMarkdownLinkFromPDF(a,c,!1,{line:l.scroll});return}if((u==null?void 0:u.extension)==="pdf"&&c.endsWith(".md")){if(n.settings.hoverPDFLinkToOpen){let{exists:f}=e.workspace.openPDFLinkTextInExistingLeafForTargetPDF(a,c,void 0,u);if(f)return}if(n.settings.ignoreHeightParamInPopoverPreview&&h.contains("height=")){let f=new URLSearchParams(h.slice(1));a=d+"#"+Array.from(f.entries()).filter(([p])=>p!=="height").map(([p,g])=>`${p}=${g}`).join("&")}}r.call(this,o,s,a,c,l)}}})),n.patchStatus.pagePreview=!0,!0};var Kx=require("obsidian");var Ih=class extends de{constructor(e,i,r){super(e);this.navButtonEl=null;this.renderer=i,this.file=r,this.pageTracker=new fg(e,i,r),this.isTrackingPage=e.settings.filterBacklinksByPageDefault}onload(){this.navButtonEl=this.renderer.headerDom.addNavButton("lucide-filter","Show only backlinks in the current page",()=>{this.isTrackingPage=!this.isTrackingPage,this.updatePageTracker()}),this.updatePageTracker(),this.registerDomEvent(this.renderer.backlinkDom.el,"mouseover",e=>{this.processBacklinkVisualizerDomForEvent(e,(i,r,o,s)=>{if(!this.settings.highlightOnHoverBacklinkPane||!fi(e,i))return;for(let l of r)l.addClass("hovered-highlight");let a=null;if(o.page&&o.annotation){let l=o.page,d=o.annotation.id;s.then(h=>{var p;let u=h.getPage(l),f=(p=u.annotationLayer)==null?void 0:p.annotationLayer.getAnnotation(d);f&&(a=this.lib.highlight.viewer.placeRectInPage(f.data.rect,u),a.addClass("pdf-plus-annotation-bounding-rect"))})}if(o.page&&o.FitR){let l=o.page,{left:d,bottom:h,right:u,top:f}=o.FitR;s.then(p=>{let g=p.getPage(l);a=this.lib.highlight.viewer.placeRectInPage([d,h,u,f],g),a.addClass("rect-highlight")})}let c=l=>{if(fi(l,i)){for(let d of r)d.removeClass("hovered-highlight");a&&a.remove(),i.removeEventListener("mouseout",c)}};i.addEventListener("mouseout",c)})})}onunload(){var e;(e=this.navButtonEl)==null||e.remove(),this.pageTracker.unload()}setParents(...e){return e.forEach(i=>i.addChild(this)),this.register(()=>e.forEach(i=>i.removeChild(this))),this}updatePageTracker(){this.navButtonEl.toggleClass("is-active",this.isTrackingPage),this.isTrackingPage?this.pageTracker.load():this.pageTracker.unload()}findBacklinkItemEl(e){var l,d;let{refCache:i,sourcePath:r}=e,o=this.renderer.backlinkDom,s=this.app.vault.getAbstractFileByPath(r);if(!(s instanceof Kx.TFile))return null;let a=o.getResult(s);if(!a)return null;if(!!a.childrenEl.querySelector(".better-search-views-tree")){let h=this.app.metadataCache.getFileCache(s);if(!(h!=null&&h.sections)||!("position"in i))return null;let u=new Set;for(let[p,g]of a.result.content){let m=h.sections.find(b=>b.position.start.offset<=p&&g<=b.position.end.offset);if(m&&(u.add(m),p===i.position.start.offset&&i.position.end.offset===g))break}let f=u.size-1;return f===-1?null:(d=a==null?void 0:a.childrenEl.querySelectorAll(".search-result-file-match")[f])!=null?d:null}else{let h=a==null?void 0:a.vChildren.children;if(!h)return null;let u=h.find(f=>{if("position"in i)return f.start<=i.position.start.offset&&i.position.end.offset<=f.end;for(let p of f.matches)return"key"in p&&p.key===i.key;return!1});return(l=u==null?void 0:u.el)!=null?l:null}}processBacklinkVisualizerDomForEvent(e,i){let r=e.target;if(!vt(e,r))return;let o=this.renderer.backlinkDom.vChildren.children.find(s=>s.el.contains(r));if(o){let s=o.file.path;this.lib.workspace.iteratePDFViewerComponents(a=>{if(a.visualizer){let c=a.visualizer.index.sourcePaths.get(s);for(let l of c){if(l.page===null)continue;let d=this.findBacklinkItemEl(l);if(d!=null&&d.contains(r)){let u=a.visualizer.domManager.getCacheToDomsMap(l.page).get(l);i(d,u,l,a)}}}})}}},fg=class extends de{constructor(e,i,r){super(e);this.renderer=i;this.file=r;this.matchCountObserver=new kc(this.renderer.backlinkDom.el,()=>{if(this.updateBacklinkCountEl(o=>`${o} in this page`),this.renderer.collapseAll)for(let o of this.renderer.backlinkDom.el.querySelectorAll(".tree-item.search-result")){let s=o.querySelector(":scope>.tree-item-self.search-result-file-title>.collapse-icon");s?s.style.visibility==="hidden"&&o.remove():o.remove()}else for(let o of this.renderer.backlinkDom.el.querySelectorAll(".tree-item.search-result:not(:has( .search-result-file-match))"))o.hasClass("is-collapsed")||o.remove()},{childList:!0,subtree:!0})}async onload(){this.renderer.backlinkDom.filter=void 0;let e=this.lib.workspace.getExistingLeafForPDFFile(this.file);if(e){await this.lib.workspace.ensureViewLoaded(e);let i=e.view;this.lib.isPDFView(i)&&i.viewer.then(r=>{this.renderer.backlinkDom.filter=(o,s)=>r.pdfViewer.pdfViewer?this.filter(r.pdfViewer.pdfViewer.currentPageNumber,s):!0,this.updateBacklinkDom(),this.lib.registerPDFEvent("pagechanging",r.pdfViewer.eventBus,this,o=>{var a;let s=typeof o.pageNumber=="number"?o.pageNumber:(a=r.pdfViewer.pdfViewer)==null?void 0:a.currentPageNumber;s&&(this.renderer.backlinkDom.filter=(c,l)=>this.filter(s,l)),this.updateBacklinkDom()})})}this.addChild(this.matchCountObserver)}onunload(){this.renderer.backlinkDom.filter=void 0,this.updateBacklinkDom()}updateBacklinkDom(){this.renderer.recomputeBacklink(this.file)}updateBacklinkCountEl(e){var r;let i=Array.from(this.renderer.backlinkDom.el.querySelectorAll("div.search-result-file-title span.tree-item-flair")).map(o=>+o.getText()).reduce((o,s)=>o+s,0);(r=this.renderer.backlinkCountEl)==null||r.setText(e?e(i):`${i}`)}filter(e,i){let r=Op(i.link),o=new URLSearchParams(r);return o.has("page")?!this.settings.showBacklinkToPage&&!o.has("selection")&&!o.has("annotation")&&!o.has("offset")&&!o.has("rect")?!1:+o.get("page")===e:!1}};var Gx=n=>{var o;let{app:t,lib:e}=n,i=(o=t.workspace.getLeavesOfType("backlink").find(s=>e.isBacklinkView(s.view)))==null?void 0:o.view,r=i==null?void 0:i.backlink;return!i||!r?!1:(n.register(Ze(Object.getPrototypeOf(i.constructor.prototype),{onLoadFile(s){return async function(a){await s.call(this,a),this.getViewType()==="backlink"&&a.extension==="pdf"&&(this.pdfManager=new Ih(n,this.backlink,a).setParents(n,this))}},onUnloadFile(s){return async function(a){let c=this;a.extension==="pdf"&&c.pdfManager&&c.pdfManager.unload(),await s.call(this,a)}}})),n.register(Ze(r.backlinkDom.constructor.prototype,{addResult(s){return function(a,c,l,d){var u;let h=this;if(h.filter){let f=t.metadataCache.getFileCache(a);if(f){let p=[];for(let[m,b]of c.content){let w=Ip(f,m,b);w&&h.filter(a,w)&&p.push([m,b])}c.content.length=0,c.content.push(...p);let g=[];for(let m of c.properties){let b=(u=f.frontmatterLinks)==null?void 0:u.find(w=>w.key===m.key);b&&h.filter(a,b)&&g.push(m)}c.properties.length=0,c.properties.push(...g)}}return s.call(this,a,c,l,d)}}})),e.workspace.iterateBacklinkViews(s=>{var a;((a=s.file)==null?void 0:a.extension)==="pdf"&&s.onLoadFile(s.file)}),n.patchStatus.backlink=!0,!0)};var ga=require("obsidian");var Xx=n=>{let t=n.app,e;return t.workspace.iterateAllLeaves(i=>{i.view instanceof ga.MarkdownView&&(e=i.view.editMode.clipboardManager)}),e?(n.register(Ze(e.constructor.prototype,{handleDragOver(i){return function(r){let o=t.dragManager.draggable;if(!o||o.source!=="pdf-plus")return i.call(this,r);(ga.Platform.isMacOS?r.shiftKey:r.altKey)||(VP(r,"link"),t.dragManager.setAction("Insert link here"))}},handleDrop(i){return function(r){let o=t.dragManager.draggable;if(!o||o.source!=="pdf-plus")return i.call(this,r);if(this.info instanceof ga.MarkdownView&&(ga.Platform.isMacOS?r.shiftKey:r.altKey))return r.preventDefault(),this.info.handleDrop(r,o,!1),!0;let s=this.info.editor;if(!s)return!1;let a=o.getText(this.getPath()),c=s.cm.posAtCoords({x:r.clientX,y:r.clientY},!1),l=s.offsetToPos(c);return s.setCursor(l),typeof a=="string"?(s.replaceSelection(a),s.focus(),r.preventDefault(),!0):!1}}})),!0):!1},RP={none:[],copy:["copy"],copyLink:["copy","link"],copyMove:["copy","move"],link:["link"],linkMove:["link","move"],move:["move"],all:["copy","link","move"],uninitialized:[]};function VP(n,t){if(!n.dataTransfer||n.dataTransfer.effectAllowed==="none"||n.dataTransfer.effectAllowed==="uninitialized")return;if(t==="none")return n.dataTransfer.dropEffect=t;RP[n.dataTransfer.effectAllowed].contains(t)&&(n.dataTransfer.dropEffect=t)}var Zx=require("obsidian");var Yx=n=>{n.register(Ze(Zx.Menu.prototype,{showAtPosition(t){return function(...e){var i;return n.settings.hoverableDropdownMenuInToolbar&&((i=this.parentEl)!=null&&i.closest("div.pdf-toolbar"))&&this.setUseNativeMenu(!1),n.shownMenus.add(this),t.call(this,...e)}},hide(t){return function(...e){return n.shownMenus.delete(this),t.call(this,...e)}}}))};var ge=require("obsidian");var Ei=require("obsidian");var ke=class{constructor(t){this.app=t.app,this.plugin=t}get lib(){return this.plugin.lib}get settings(){return this.plugin.settings}};var zo=require("obsidian"),BP=Un(require("obsidian")),Rc=class{constructor(t,e){this.plugin=t;this.variables=e}setVariable(t,e){this.variables[t]=e}evalPart(t){let e=new Function(...Object.keys(this.variables),`return ${t};`)(...Object.values(this.variables));if(e===void 0)throw Error(`The expression "${t}" cannot be evaluated.`);return e}evalTemplate(t){return t.replace(/{{(.*?)}}/g,(e,i)=>this.evalPart(i))}},Vc=class extends Rc{constructor(e,i){var h,u,f,p,g,m;let{app:r}=e;"colorName"in i&&(i.color=i.colorName);super(e,{...i,app:r,obsidian:BP,pdf:i.file,folder:i.file.parent,selection:i.text});this.app=r,this.lib=e.lib;let o=this.findMarkdownFileAssociatedToPDF(i.file),s=(u=o&&((h=r.metadataCache.getFileCache(o))==null?void 0:h.frontmatter))!=null?u:{};this.setVariable("md",o),this.setVariable("properties",s);let a=this.findLinkedFile(i.file),c=(p=a&&((f=r.metadataCache.getFileCache(a))==null?void 0:f.frontmatter))!=null?p:{};this.setVariable("linkedFile",a),this.setVariable("linkedFileProperties",c);let l=(g=r.plugins.plugins.dataview)==null?void 0:g.api,d=(m=r.plugins.plugins.quickadd)==null?void 0:m.api;l&&this.setVariable("dv",l),d&&this.setVariable("quickAddApi",d)}findMarkdownFileAssociatedToPDF(e){var s,a,c;let i=this.plugin.app,r=[],o=(s=i.plugins.plugins.dataview)==null?void 0:s.api;if(o)r=o.pages().where(d=>{var h;return o.array((h=d[this.plugin.settings.proxyMDProperty])!=null?h:[]).path.includes(e.path)}).map(d=>i.vault.getAbstractFileByPath(d.file.path)).filter(d=>d instanceof zo.TFile);else{let l=i.metadataCache.getBacklinksForFile(e);for(let d of l.keys()){let h=i.metadataCache.getCache(d);if(h&&((a=h.frontmatterLinks)==null?void 0:a.some(f=>{if(f.key!==this.plugin.settings.proxyMDProperty&&!new RegExp(`${this.plugin.settings.proxyMDProperty}.\\d+`).test(f.key))return!1;let p=(0,zo.getLinkpath)(f.link),g=i.metadataCache.getFirstLinkpathDest(p,d);return g&&g.path===e.path}))){let f=i.vault.getAbstractFileByPath(d);f instanceof zo.TFile&&r.push(f)}}}if(r.length>1){let l=`Multiple markdown files are associated with this PDF file: ${r.map(d=>"- "+d.path).join(` `)} Aborting.`;throw Error(l)}return(c=r.first())!=null?c:null}findLinkedFile(e){let i=null,r=this.lib.workspace.getActiveGroupLeaves();if(r){for(let o of r)if(o.view instanceof zo.FileView&&o.view.file&&o.view.file!==e){i=o.view.file;break}}return i}};var Lh=class extends ke{constructor(){super(...arguments);this.statusDurationMs=2e3}getPageAndTextRangeFromSelection(e){if(e=e!=null?e:activeWindow.getSelection(),!e)return null;let i=this.lib.getPageElFromSelection(e);if(!i||i.dataset.pageNumber===void 0)return null;let r=+i.dataset.pageNumber,o=e.rangeCount>0?e.getRangeAt(0):null;if(o){let s=this.getTextSelectionRange(i,o);if(s)return{page:r,selection:s}}return{page:r}}getTextSelectionRange(e,i){if(i&&!i.collapsed){let r=nh(e,i.startContainer),o=nh(e,i.endContainer);if(r&&o){let s=r.dataset.idx,a=o.dataset.idx,c=rh(r,i.startContainer,i.startOffset),l=rh(o,i.endContainer,i.endOffset);if(s!==void 0&&a!==void 0&&c!==null&&l!==null)return{beginIndex:+s,beginOffset:c,endIndex:+a,endOffset:l}}}return null}getTemplateVariables(e){var l,d,h;let i=activeWindow.getSelection();if(!i)return null;let r=this.lib.getPageElFromSelection(i);if(!r||r.dataset.pageNumber===void 0)return null;let o=this.lib.getPDFViewerChildAssociatedWithNode(r),s=o==null?void 0:o.file;if(!s)return null;let a=+r.dataset.pageNumber;i.toString()||(a=(d=(l=o.pdfViewer.pdfViewer)==null?void 0:l.currentPageNumber)!=null?d:a);let c=Cc({page:a,selection:o.getTextSelectionRangeStr(r),...e});return{child:o,file:s,subpath:c,page:a,pageCount:o.pdfViewer.pagesCount,pageLabel:(h=o.getPage(a).pageLabel)!=null?h:""+a,text:this.lib.toSingleLine(i.toString())}}getLinkTemplateVariables(e,i,r,o,s,a,c,l){l=l!=null?l:"";let d=this.app.fileManager.generateMarkdownLink(r,l,o).slice(1),h=this.app.metadataCache.fileToLinktext(r,l)+o;this.app.vault.getConfig("useMarkdownLinks")&&(h=xr(h));let u=this.getDisplayText(e,i,r,s,a,c),f=this.lib.generateMarkdownLink(r,l,o,u||void 0).slice(1),p=this.app.fileManager.generateMarkdownLink(r,l,`#page=${s}`).slice(1),g=this.lib.generateMarkdownLink(r,l,`#page=${s}`,u||void 0).slice(1);return{link:d,linktext:h,display:u,linkWithDisplay:f,linkToPage:p,linkToPageWithDisplay:g}}getDisplayText(e,i,r,o,s,a){var c;if(!i){let l=this.lib.getColorPaletteFromChild(e);l?i=this.settings.displayTextFormats[l.displayTextFormatIndex].template:i=this.settings.displayTextFormats[this.settings.defaultDisplayTextFormatIndex].template}try{return new Vc(this.plugin,{file:r,page:o,pageCount:e.pdfViewer.pagesCount,pageLabel:(c=e.getPage(o).pageLabel)!=null?c:""+o,text:s,comment:a!=null?a:""}).evalTemplate(i).trim()}catch(l){console.error(l),new Ei.Notice(`${this.plugin.manifest.name}: Display text format is invalid. Error: ${l.message}`,3e3)}}getTextToCopy(e,i,r,o,s,a,c,l,d,h){var g,m,b,w,F,v;let u=e.getPage(s);if(typeof h!="string"){let P=ta(a).get("annotation");h=typeof P=="string"&&((F=(w=(b=(m=(g=u==null?void 0:u.annotationLayer)==null?void 0:g.annotationLayer)==null?void 0:m.getAnnotation(P))==null?void 0:b.data)==null?void 0:w.contentsObj)==null?void 0:F.str),h=this.lib.toSingleLine(h||"")}return new Vc(this.plugin,{file:o,page:s,pageLabel:(v=u.pageLabel)!=null?v:""+s,pageCount:e.pdfViewer.pagesCount,text:c,comment:h,colorName:l,calloutType:this.settings.calloutType,...this.lib.copyLink.getLinkTemplateVariables(e,r,o,a,s,c,h,d)}).evalTemplate(i)}async getTextToCopyForOutlineItem(e,i,r,o){return(await this.getTextToCopyForOutlineItemDynamic(e,i,r))(o)}async getTextToCopyForOutlineItemDynamic(e,i,r){let o=await r.getExplicitDestination(),s=await r.getPageNumber(),a=this.lib.normalizePDFJsDestArray(o,s),c=this.lib.destArrayToSubpath(a);return l=>this.getTextToCopy(e,this.settings.outlineLinkCopyFormat,this.settings.outlineLinkDisplayTextFormat,i,s,c,r.item.title,"",l)}getSelectionLinkInfo(){var s;let e=this.lib.getColorPaletteAssociatedWithSelection();if(!e)return null;let i=this.settings.copyCommands[e.actionIndex].template,r=(s=e.selectedColorName)!=null?s:void 0,o=e.writeFile;return{template:i,colorName:r,writeFile:o}}getAnnotationLinkInfo(){let e=this.plugin.lastAnnotationPopupChild;if(!e)return null;let i=e.activeAnnotationPopupEl;if(!i)return null;let r=i.querySelector(".popupMeta div.clickable-icon:has(svg.lucide-copy)");if(!r)return null;let o=this.lib.getColorPaletteAssociatedWithNode(r),s;o?s=this.settings.copyCommands[o.actionIndex].template:s=this.settings.copyCommands[this.settings.defaultColorPaletteActionIndex].template;let a=this.lib.getAnnotationInfoFromPopupEl(i);if(!a)return null;let{page:c,id:l}=a;return{child:e,copyButtonEl:r,template:s,page:c,id:l}}copyLinkToSelection(e,i,r,o){let s=this.getTemplateVariables(r?{color:r.toLowerCase()}:{});if(s){let{child:a,file:c,subpath:l,page:d,text:h}=s;if(!h)if(this.settings.useAnotherCopyTemplateWhenNoSelection)i.copyFormat=this.settings.copyTemplateWhenNoSelection;else return!1;return e||(async()=>{var g,m;let u=this.getTextToCopy(a,i.copyFormat,i.displayTextFormat,c,d,l,h,(g=r==null?void 0:r.toLowerCase())!=null?g:"");await navigator.clipboard.writeText(u),this.onCopyFinish(u);let f=this.lib.getColorPaletteFromChild(a);f==null||f.setStatus("Link copied",this.statusDurationMs),this.autoFocusOrAutoPaste(u,o,f!=null?f:void 0);let p=Ln(l);if(p&&"beginIndex"in p){let b=(m=a.getPage(d).textLayer)==null?void 0:m.textContentItems[p.beginIndex];if(b){let w=b.transform[4],F=b.transform[5]+b.height;typeof w=="number"&&typeof F=="number"&&(this.plugin.lastCopiedDestInfo={file:c,destArray:[d-1,"XYZ",w,F,null]})}}})(),!0}return!1}copyLinkToAnnotation(e,i,r,o,s,a,c){let l=e.file;if(!l)return!1;if(!i){let d=e.getPage(o);e.getAnnotatedText(d,s).then(async h=>{var v,P,k,C;let u=(C=(k=(P=(v=d.annotationLayer)==null?void 0:v.annotationLayer)==null?void 0:P.getAnnotation(s))==null?void 0:k.data)!=null?C:(await d.pdfPage.getAnnotations()).find(D=>D.id===s),f=u!=null&&u.color?`${u.color[0]}, ${u.color[1]}, ${u.color[2]}`:"",p=`#page=${o}&annotation=${s}`;if(u.subtype==="Square"){let D=u.rect;p+=`&rect=${D[0]},${D[1]},${D[2]},${D[3]}`}let g=this.getTextToCopy(e,r.copyFormat,r.displayTextFormat,l,o,p,h!=null?h:"",f);await navigator.clipboard.writeText(g),this.onCopyFinish(g);let m=this.lib.getColorPaletteFromChild(e);c&&(m==null||m.setStatus("Link copied",this.statusDurationMs)),this.autoFocusOrAutoPaste(g,a,m!=null?m:void 0);let b=u==null?void 0:u.rect,w=b==null?void 0:b[0],F=b==null?void 0:b[3];typeof w=="number"&&typeof F=="number"&&(this.plugin.lastCopiedDestInfo={file:l,destArray:[o-1,"XYZ",w,F,null]})})}return!0}copyLinkToAnnotationWithGivenTextAndFile(e,i,r,o,s,a,c,l,d){return o||(async()=>{let h=this.getTextToCopy(r,s.copyFormat,s.displayTextFormat,i,a,`#page=${a}&annotation=${c}`,e,l);await navigator.clipboard.writeText(h),this.onCopyFinish(h);let u=this.lib.getColorPaletteFromChild(r);u==null||u.setStatus("Link copied",this.statusDurationMs),this.autoFocusOrAutoPaste(h,d,u!=null?u:void 0)})(),!0}writeHighlightAnnotationToSelectionIntoFileAndCopyLink(e,i,r,o){let s=activeWindow.getSelection();if(!s)return!1;let a=this.lib.toSingleLine(s.toString());if(!a)return!1;if(!e){let c=this.lib.getColorPaletteAssociatedWithSelection();c==null||c.setStatus("Writing highlight annotation into file...",1e4),this.lib.highlight.writeFile.addTextMarkupAnnotationToSelection(this.settings.selectionBacklinkVisualizeStyle==="highlight"?"Highlight":"Underline",r).then(l=>{if(!l)return;let{child:d,file:h,page:u,annotationID:f,rects:p}=l;!f||!h||setTimeout(()=>{let g=this.lib.getColorPaletteFromChild(d);g==null||g.setStatus("Link copied",this.statusDurationMs);let{r:m,g:b,b:w}=this.plugin.domManager.getRgb(r);if(this.copyLinkToAnnotationWithGivenTextAndFile(a,h,d,!1,i,u,f,`${m}, ${b}, ${w}`,o),p){let F=Math.min(...p.map(P=>P[0])),v=Math.max(...p.map(P=>P[3]));typeof F=="number"&&typeof v=="number"&&(this.plugin.lastCopiedDestInfo={file:h,destArray:[u-1,"XYZ",F,v,null]})}},300)})}return!0}copyEmbedLinkToRect(e,i,r,o,s,a,c){if(a||(a=this.settings.autoPaste),!i.file)return!1;let l=i.file,d=this.lib.getColorPaletteFromChild(i);if(o.some(h=>isNaN(h)))return d==null||d.setStatus("Invalid selection",this.statusDurationMs),!1;if(!e){let h=this.getDisplayText(i,void 0,l,r,""),u=`#page=${r}&rect=${o.map(p=>Math.round(p)).join(",")}`;s&&(u+=`&color=${s}`);let f=this.lib.generateMarkdownLink(l,c!=null?c:"",u,h);(async()=>{let p=f,g=i.getPage(r).pdfPage,m=this.settings.rectImageExtension;if(!this.settings.rectEmbedStaticImage)await navigator.clipboard.writeText(p),this.onCopyFinish(p);else if(this.settings.rectImageFormat==="file"){let b=await this.app.fileManager.getAvailablePathForAttachment(l.basename+"."+m,"");p=(!this.app.vault.getConfig("useMarkdownLinks")?`![[${b}]]`:`![](${xr(b)})`)+` `+f.slice(1),await navigator.clipboard.writeText(p);let v=async()=>{let P=await this.lib.pdfPageToImageArrayBuffer(g,{type:`image/${m}`,cropRect:o});return await this.app.vault.createBinary(b,P)};a?(await v(),this.onCopyFinish(p)):this.onCopyFinish(p,v)}else p=`![](${await this.lib.pdfPageToImageDataUrl(g,{type:`image/${m}`,cropRect:o})})`+` `+f.slice(1),await navigator.clipboard.writeText(p),this.onCopyFinish(p);this.plugin.lastCopiedDestInfo={file:l,destArray:[r-1,"FitR",...o]},d==null||d.setStatus("Link copied",this.statusDurationMs),await this.autoFocusOrAutoPaste(p,a,d!=null?d:void 0)})()}return!0}copyLinkToSearch(e,i,r,o,s,a){if(!i.file)return!1;let c=i.file,l=this.lib.getColorPaletteFromChild(i);if(!e){let d=this.lib.copyLink.getDisplayText(i,void 0,c,r,o),h=this.lib.generateMarkdownLink(c,"",`#search=${o}`,d).slice(1);(async()=>(await navigator.clipboard.writeText(h),this.onCopyFinish(h),l==null||l.setStatus("Link copied",this.statusDurationMs),await this.autoFocusOrAutoPaste(h,s,l!=null?l:void 0)))()}return!0}makeCanvasTextNodeFromSelection(e,i,r,o){var a;let s=this.getTemplateVariables(o?{color:o.toLowerCase()}:{});if(s){let{child:c,file:l,subpath:d,page:h,text:u}=s;if(!u)return!1;if(!e){let f=this.getTextToCopy(c,r,void 0,l,h,d,u,(a=o==null?void 0:o.toLowerCase())!=null?a:"");i.createTextNode({pos:i.posCenter(),position:"center",text:f})}return!0}return!1}makeCanvasTextNodeFromAnnotation(e,i,r,o,s,a){let c=r.file;if(!c)return!1;if(!e){let l=r.getPage(s);r.getAnnotatedText(l,a).then(d=>{let h=this.getTextToCopy(r,o,void 0,c,s,`#page=${s}&annotation=${a}`,d!=null?d:"","");i.createTextNode({pos:i.posCenter(),position:"center",text:h})})}return!0}async autoPaste(e){let i=this.getAutoFocusOrAutoPasteTarget(this.settings.autoPasteTarget);if(i)return await this.pasteTextToFile(e,i),!0;if(!this.settings.executeCommandWhenTargetNotIdentified)return!1;let r=this.app.commands.findCommand(this.settings.commandToExecuteWhenTargetNotIdentified);if(!r)return new Ei.Notice(`${this.plugin.manifest.name}: Command "${this.settings.commandToExecuteWhenTargetNotIdentified}" was not found. Please update the "Command to execute when pasting a link for the first time with auto-focus or auto-paste" setting.`),!1;let o=!1;return new Promise(s=>{let a=this.app.workspace.on("file-open",async l=>{l&&l.extension==="md"&&(this.app.workspace.offref(a),await this.pasteTextToFile(e,l,!0),this.plugin.lastPasteFile=l,s(!0))}),c=this.lib.workspace.hoverEditor;this.plugin.registerOneTimeEvent(this.app.workspace,"active-leaf-change",l=>{l&&c.isHoverEditorLeaf(l)&&c.postProcessHoverEditorLeaf(l)}),this.app.commands.executeCommandById(r.id),activeWindow.setTimeout(()=>{if(!o){let{noticeEl:l}=new Ei.Notice(`${this.plugin.manifest.name}: Could not find the auto-paste target markdown file within ${this.settings.autoPasteTargetDialogTimeoutSec} seconds.`);l.appendText(" Click "),l.createEl("a",{text:"here"},d=>{d.addEventListener("click",()=>{this.plugin.openSettingTab().scrollTo("autoPasteTargetDialogTimeoutSec")})}),l.appendText(" to change the timeout duration."),this.app.workspace.offref(a),s(!1)}},this.settings.autoPasteTargetDialogTimeoutSec*1e3)}).then(s=>(o=!0,s))}async autoFocus(){let e=this.getAutoFocusOrAutoPasteTarget(this.settings.autoFocusTarget);if(e){let{leaf:o,isExistingLeaf:s}=await this.prepareMarkdownLeafForPaste(e);return o&&o.view instanceof Ei.MarkdownView&&await this.updateAndRevealCursorInEditor(o.view,{focus:!0,goEnd:!s}),!0}if(!this.settings.executeCommandWhenTargetNotIdentified)return!1;let i=this.app.commands.findCommand(this.settings.commandToExecuteWhenTargetNotIdentified);if(!i)return new Ei.Notice(`${this.plugin.manifest.name}: Command "${this.settings.commandToExecuteWhenTargetNotIdentified}" was not found. Please update the "Command to execute when pasting a link for the first time with auto-focus or auto-paste" setting.`),!1;let r=this.lib.workspace.hoverEditor;return this.plugin.registerOneTimeEvent(this.app.workspace,"active-leaf-change",o=>{o&&r.isHoverEditorLeaf(o)&&r.postProcessHoverEditorLeaf(o)}),this.app.commands.executeCommandById(i.id)}getAutoFocusOrAutoPasteTarget(e){let i=this.plugin.lastActiveMarkdownFile,r=this.plugin.lastPasteFile,o=!!(i&&this.lib.workspace.isMarkdownFileOpened(i)),s=null;return e==="last-paste"?s=r:e==="last-active"?s=i:e==="last-active-and-open"?o&&(s=i):e==="last-paste-then-last-active"?s=r!=null?r:i:e==="last-paste-then-last-active-and-open"?r?s=r:o&&(s=i):e==="last-active-and-open-then-last-paste"&&(o?s=i:r&&(s=r)),s&&s.extension==="md"?s:null}async prepareMarkdownLeafForPaste(e){let i=this.lib.workspace.getExistingLeafForMarkdownFile(e),r=!!i;if(!i&&this.settings.openAutoFocusTargetIfNotOpened){let o=this.settings.howToOpenAutoFocusTargetIfNotOpened;if(o==="hover-editor"){let s=await this.lib.workspace.hoverEditor.createNewHoverEditorLeaf({hoverPopover:null},null,e.path,"");s&&(i=s)}else i=this.lib.workspace.getLeaf(o),await i.openFile(e,{active:!1});if(i&&this.settings.openAutoFocusTargetInEditingView){await this.lib.workspace.ensureViewLoaded(i);let s=i.view;s instanceof Ei.MarkdownView&&(await s.setState({mode:"source"},{history:!1}),s.setEphemeralState({focus:!1}))}}return i&&(await this.lib.workspace.ensureViewLoaded(i),this.lib.workspace.hoverEditor.postProcessHoverEditorLeaf(i),this.settings.closeSidebarWhenLostFocus&&this.lib.workspace.registerHideSidebar(i)),{leaf:i,isExistingLeaf:r}}async pasteTextToFile(e,i,r=!1){let{leaf:o,isExistingLeaf:s}=await this.prepareMarkdownLeafForPaste(i);if(!r&&o&&s&&o.view instanceof Ei.MarkdownView&&o.view.getMode()==="source"){let a=o.view,c=a.editor;if(this.settings.respectCursorPositionWhenAutoPaste)c.replaceSelection(e);else{let l=c.getValue();l=l.trimEnd(),l&&(l+=` `),l+=e,c.setValue(l)}a.save(),await this.updateAndRevealCursorInEditor(o.view,{focus:this.settings.focusEditorAfterAutoPaste,goEnd:!this.settings.respectCursorPositionWhenAutoPaste})}else await this.app.vault.process(i,a=>(a=a.trimEnd(),a&&(a+=` `),a+=e,a)),o&&activeWindow.setTimeout(async()=>{o.view instanceof Ei.MarkdownView&&await this.updateAndRevealCursorInEditor(o.view,{focus:this.settings.focusEditorAfterAutoPaste,goEnd:!0})})}async updateAndRevealCursorInEditor(e,i){let{focus:r,goEnd:o}=i,s=e.editor;r&&(o&&s.exec("goEnd"),await this.lib.workspace.revealLeaf(e.leaf),this.app.workspace.setActiveLeaf(e.leaf),s.focus());let a=s.coordsAtPos(s.getCursor(),!0);if(a){let c=s.getScrollInfo();if(a.topc.top+c.clientHeight){let l={from:s.getCursor("from"),to:s.getCursor("to")};s.scrollIntoView(l,!0)}}}watchPaste(e,i){this.plugin.registerOneTimeEvent(this.app.workspace,"editor-paste",(r,o,s)=>{var d;if(((d=s.file)==null?void 0:d.extension)!=="md"||!r.clipboardData)return;let c=r.clipboardData.getData("text/plain").replace(/\r\n/g,` `),l=e.replace(/\r\n/g,` `);c===l&&(this.plugin.lastPasteFile=s.file,i==null||i()),s instanceof Ei.MarkdownView&&setTimeout(()=>s.save())})}onCopyFinish(e,i){this.watchPaste(e,i),this.plugin.lastCopiedDestInfo=null}async autoFocusOrAutoPaste(e,i,r){if(i||this.settings.autoPaste)if(await this.autoPaste(e)){if(r==null||r.setStatus("Link copied & pasted",this.statusDurationMs),!this.settings.focusEditorAfterAutoPaste&&this.settings.clearSelectionAfterAutoPaste){let s=activeWindow.getSelection();s&&this.lib.copyLink.getPageAndTextRangeFromSelection(s)&&s.empty()}}else r==null||r.setStatus("Link copied but paste target not identified",this.statusDurationMs);else this.settings.autoFocus&&(await this.autoFocus()||r==null||r.setStatus("Link copied but paste target not identified",this.statusDurationMs))}};var Oh=class extends ke{computeMergedHighlightRects(t,e,i,r,o){let{textContentItems:s,textDivs:a,div:c}=t,l=[],d=null,h=[];o===0&&(r--,o=s[r].str.length);for(let u=e;u<=r;u++){let f=s[u],p=a[u];if(!f.str)continue;let g=this.computeHighlightRectForItem(c,f,p,u,e,i,r,o);g&&(d?this.areRectanglesMergeable(d,g)?(d=this.mergeRectangles(d,g),h.push(u)):(l.push({rect:d,indices:h}),d=g,h=[u]):(d=g,h=[u]))}return d&&l.push({rect:d,indices:h}),l}computeHighlightRectForItem(t,e,i,r,o,s,a,c){return e.chars&&e.chars.length>=e.str.length?this.computeHighlightRectForItemFromChars(e,r,o,s,a,c):this.computeHighlightRectForItemFromTextLayer(t,e,i,r,o,s,a,c)}computeHighlightRectForItemFromChars(t,e,i,r,o,s){let a=t.chars.slice(t.chars.findIndex(u=>u.c===t.str.charAt(0)),t.chars.findLastIndex(u=>u.c===t.str.charAt(t.str.length-1))+1),c=e===i?r:0,l=(e===o?Math.min(s,a.length):a.length)-1;if(c>a.length-1||l<0)return null;let d=a[c],h=a[l];return[Math.min(d.r[0],h.r[0]),Math.min(d.r[1],h.r[1]),Math.max(d.r[2],h.r[2]),Math.max(d.r[3],h.r[3])]}computeHighlightRectForItemFromTextLayer(t,e,i,r,o,s,a,c){let l=r===o?s:0,d=r===a?c:void 0,h=e.transform[4],u=e.transform[5],f=e.transform[4]+e.width,p=e.transform[5]+e.height,g=i.cloneNode();t.appendChild(g);let m=e.str.substring(0,l);g.appendText(m);let b=e.str.substring(l,d),w=g.createSpan();if(w.appendText(b),d!==void 0){let P=e.str.substring(d);g.appendText(P)}let F=w.getBoundingClientRect(),v=i.getBoundingClientRect();return g.remove(),[h+(F.left-v.left)/v.width*e.width,u+(F.bottom-v.bottom)/v.height*e.height,f-(v.right-F.right)/v.width*e.width,p-(v.top-F.top)/v.height*e.height]}areRectanglesMergeable(t,e){return this.areRectanglesMergeableHorizontally(t,e)||this.areRectanglesMergeableVertically(t,e)}areRectanglesMergeableHorizontally(t,e){let[i,r,o,s]=t,[a,c,l,d]=e,h=(r+s)/2,u=(c+d)/2,f=Math.abs(s-r),p=Math.abs(d-c),g=Math.max(f,p)*.5;return Math.abs(h-u).85&&p/u>.85}mergeRectangles(...t){let e=t.map(s=>s[0]),i=t.map(s=>s[1]),r=t.map(s=>s[2]),o=t.map(s=>s[3]);return[Math.min(...e),Math.min(...i),Math.max(...r),Math.max(...o)]}rectsToQuadPoints(t){return t.flatMap(([e,i,r,o])=>[e,o,r,o,e,i,r,i])}};var Mh=require("obsidian");var Nh=class extends ke{getPDFPlusBacklinkHighlightLayer(t){var i;let e=t.div;return(i=e.querySelector("div.pdf-plus-backlink-highlight-layer"))!=null?i:e.createDiv("pdf-plus-backlink-highlight-layer",r=>{window.pdfjsLib.setLayerDimensions(r,t.viewport)})}placeRectInPage(t,e){let i=e.pdfPage.view,r=i[0],o=i[1],s=i[2]-i[0],a=i[3]-i[1],c=window.pdfjsLib.Util.normalizeRect([t[0],i[3]-t[1]+i[1],t[2],i[3]-t[3]+i[1]]),d=this.getPDFPlusBacklinkHighlightLayer(e).createDiv("pdf-plus-backlink");return d.setCssStyles({left:`${100*(c[0]-r)/s}%`,top:`${100*(c[1]-o)/a}%`,width:`${100*(c[2]-c[0])/s}%`,height:`${100*(c[3]-c[1])/a}%`}),d}highlightSubpath(t,e){var i,r,o;if(((i=t.subpathHighlight)==null?void 0:i.type)==="text"){let s=new Mh.Component;s.load(),this.lib.onTextLayerReady(t.pdfViewer,s,a=>{var d;if(((d=t.subpathHighlight)==null?void 0:d.type)!=="text")return;let{page:c,range:l}=t.subpathHighlight;c===a&&(t.highlightText(c,l),e>0&&setTimeout(()=>{t.clearTextHighlight()},e*1e3),s.unload())})}else if(((r=t.subpathHighlight)==null?void 0:r.type)==="annotation"){let s=new Mh.Component;s.load(),this.lib.onAnnotationLayerReady(t.pdfViewer,s,a=>{var d;if(((d=t.subpathHighlight)==null?void 0:d.type)!=="annotation")return;let{page:c,id:l}=t.subpathHighlight;c===a&&(t.highlightAnnotation(c,l),e>0&&setTimeout(()=>t.clearAnnotationHighlight(),e*1e3),s.unload())})}else if(((o=t.subpathHighlight)==null?void 0:o.type)==="rect"){let s=new Mh.Component;s.load(),this.lib.onPageReady(t.pdfViewer,s,a=>{var d;if(((d=t.subpathHighlight)==null?void 0:d.type)!=="rect")return;let{page:c,rect:l}=t.subpathHighlight;c===a&&(this.highlightRect(t,c,l),e>0&&setTimeout(()=>{this.clearRectHighlight(t)},e*1e3),s.unload())})}}highlightRect(t,e,i){if(this.clearRectHighlight(t),1<=e&&e<=t.pdfViewer.pagesCount){let r=t.getPage(e);r!=null&&r.div.dataset.loaded&&(t.rectHighlight=this.placeRectInPage(i,r),t.rectHighlight.addClass("rect-highlight"),this.settings.zoomToFitRect||activeWindow.setTimeout(()=>{window.pdfjsViewer.scrollIntoView(t.rectHighlight,{top:-this.settings.embedMargin})}))}}clearRectHighlight(t){t.rectHighlight&&(t.rectHighlight.detach(),t.rectHighlight=null)}};var Jx=require("obsidian");var Rh=class extends ke{async addTextMarkupAnnotation(t,e,i,r,o,s){if(!this.plugin.settings.author)throw new Error(`${this.plugin.manifest.name}: The author name is not set. Please set it in the plugin settings.`);return await this.process(t,a=>{let c=a.getPage(e-1),{r:l,g:d,b:h}=this.plugin.domManager.getRgb(o),u=mp(),f=this.lib.highlight.geometry,p=this.addAnnotation(c,{Subtype:r,Rect:f.mergeRectangles(...i),QuadPoints:f.rectsToQuadPoints(i),Contents:M.fromText(s!=null?s:""),M:G.fromDate(new Date),T:M.fromText(this.plugin.settings.author),CA:r==="Highlight"?this.plugin.settings.writeHighlightToFileOpacity:1,Border:r==="Highlight"?[u,u,0]:void 0,C:[l/255,d/255,h/255]});return Tc(p.objectNumber,p.generationNumber)})}async addHighlightAnnotation(t,e,i,r,o){return await this.addTextMarkupAnnotation(t,e,i,"Highlight",r,o)}async addLinkAnnotation(t,e,i,r,o,s){return await this.process(t,a=>{let c=a.getPage(e-1),l=pr(this.plugin.settings.pdfLinkColor),{r:d,g:h,b:u}=l!=null?l:{r:0,g:0,b:0},f=this.lib.highlight.geometry,p;typeof r=="string"?p=G.of(r):p=[a.getPage(r[0]).ref,r[1],...r.slice(2).map(w=>typeof w=="number"?N.of(w):Me)];let g=this.addAnnotation(c,{Subtype:"Link",Rect:f.mergeRectangles(...i),QuadPoints:f.rectsToQuadPoints(i),Dest:p,M:G.fromDate(new Date),Border:[0,0,this.plugin.settings.pdfLinkBorder?1:0],C:[d/255,h/255,u/255]});return Tc(g.objectNumber,g.generationNumber)})}async process(t,e){let i=await this.lib.loadPdfLibDocument(t),r=await e(i);return await this.app.vault.modifyBinary(t,await i.save()),r}async read(t,e){let i=await this.lib.loadPdfLibDocument(t);return await e(i)}addAnnotation(t,e){let i=t.doc.context,r=i.register(i.obj({Type:"Annot",...e}));return t.node.addAnnot(r),r}async deleteAnnotation(t,e,i){await this.process(t,r=>{let o=r.getPage(e-1),s=this.findAnnotationRef(o,i);s&&o.node.removeAnnot(s)})}async getAnnotationContents(t,e,i){let r=await this.getAnnotation(t,e,i);if(r){let o=this.getContentsFromAnnotation(r);return o!=null?o:null}return null}async setAnnotationContents(t,e,i,r){await this.processAnnotation(t,e,i,o=>{this.setContentsToAnnotation(o,r)})}async getAnnotationColor(t,e,i){var o;let r=await this.getAnnotation(t,e,i);return r&&(o=this.getColorFromAnnotation(r))!=null?o:null}async setAnnotationColor(t,e,i,r){await this.processAnnotation(t,e,i,async o=>{this.setColorToAnnotation(o,r)})}async getAnnotationOpacity(t,e,i){var o;let r=await this.getAnnotation(t,e,i);return r&&(o=this.getOpacityFromAnnotation(r))!=null?o:null}async setAnnotationOpacity(t,e,i,r){await this.processAnnotation(t,e,i,async o=>{this.setOpacityToAnnotation(o,r)})}findAnnotationRef(t,e){var i;return(i=t.node.Annots())==null?void 0:i.asArray().find(r=>r instanceof q&&Tc(r.objectNumber,r.generationNumber)===e)}async getAnnotation(t,e,i){return await this.read(t,r=>{let o=r.getPage(e-1),s=this.findAnnotationRef(o,i);return s?o.node.context.lookup(s,R):null})}async processAnnotation(t,e,i,r){return await this.process(t,async o=>{let s=o.getPage(e-1),a=this.findAnnotationRef(s,i);if(a){let c=s.node.context.lookup(a,R);await r(c)}})}getColorFromAnnotation(t){if(!t.get(x.of("AP"))){let i=t.get(x.of("C"));if(i instanceof H){let r=i.asArray();if(r.length===3){let[o,s,a]=r.map(c=>{if(c instanceof N)return Math.round(c.asNumber()*255);throw new Error(`${this.plugin.manifest.name}: Invalid color`)});return{r:o,g:s,b:a}}}}}setColorToAnnotation(t,e){let i=t.get(x.of("C"));i instanceof H&&(i.set(0,N.of(e.r/255)),i.set(1,N.of(e.g/255)),i.set(2,N.of(e.b/255)))}getContentsFromAnnotation(t){let e=t.get(x.of("Contents"));if(e instanceof G||e instanceof M)return e.decodeText()}setContentsToAnnotation(t,e){t.set(x.of("Contents"),M.fromText(e))}getOpacityFromAnnotation(t){if(!t.get(x.of("AP"))){let i=t.get(x.of("CA"));if(i instanceof N)return i.asNumber()}}setOpacityToAnnotation(t,e){t.set(x.of("CA"),N.of(e))}getAuthorFromAnnotation(t){let e=t.get(x.of("T"));if(e instanceof G||e instanceof M)return e.decodeText()}setAuthorToAnnotation(t,e){t.set(x.of("T"),M.fromText(e))}getBorderWidthFromAnnotation(t){let e=t.get(x.of("Border"));if(e instanceof H){let i=e.asArray()[2];if(i instanceof N)return i.asNumber()}}setBorderWidthToAnnotation(t,e){let i=t.get(x.of("Border"));i instanceof H&&i.set(2,N.of(e))}};var Vh=class extends ke{constructor(e){super(e);this.pdflib=new Rh(e)}getPdfIo(){return this.pdflib}async addTextMarkupAnnotationToSelection(e,i){return this.addAnnotationToSelection(async(r,o,s)=>await this.getPdfIo().addTextMarkupAnnotation(r,o,s,e,i))}async addLinkAnnotationToSelection(e){return this.addAnnotationToSelection(async(i,r,o)=>await this.getPdfIo().addLinkAnnotation(i,r,o,e))}async addAnnotationToSelection(e){let i=this.lib.copyLink.getTemplateVariables({});if(!i)return;let{subpath:r,child:o}=i,s=Ln(r);if(s&&"beginIndex"in s){let{page:a,beginIndex:c,beginOffset:l,endIndex:d,endOffset:h}=s;return{child:o,file:o.file,page:a,...await this.addAnnotationToTextRange(e,o,a,c,l,d,h)}}return null}async addAnnotationToTextRange(e,i,r,o,s,a,c){if(i.file&&1<=r&&r<=i.pdfViewer.pagesCount){let l=i.getPage(r);if(l!=null&&l.textLayer&&l.div.dataset.loaded){let h=this.lib.highlight.geometry.computeMergedHighlightRects(l.textLayer,o,s,a,c).map(({rect:f})=>f),u;try{u=await e(i.file,r,h)}catch(f){new Jx.Notice(`${this.plugin.manifest.name}: An error occurred while attemping to add an annotation.`),console.error(f)}return{annotationID:u,rects:h}}}}async deleteAnnotation(e,i,r){await this.getPdfIo().deleteAnnotation(e,i,r)}async getAnnotationContents(e,i,r){return await this.getPdfIo().getAnnotationContents(e,i,r)}async setAnnotationContents(e,i,r,o){return await this.getPdfIo().setAnnotationContents(e,i,r,o)}};var Bh=class extends ke{async getAnnotatedTextsInDocument(t){let e=new Map;for(let i=1;i<=t.numPages;i++){let r=await t.getPage(i),o=await this.getAnnotatedTextsInPage(r);e.set(i,o)}return e}async getAnnotatedTextsInPage(t){var o;let[{items:e},i]=await Promise.all([t.getTextContent({includeChars:!0}),t.getAnnotations()]),r=[];for(let s of i){if(!["Highlight","Underline","Squiggly","StrikeOut"].includes(s.subtype))continue;let c=[];for(let u of s.quadPoints){let f=u[1],p=u[2],g=[p.x,p.y,f.x,f.y];if(g.some(m=>typeof m!="number"))throw new Error("Invalid rect");g=window.pdfjsLib.Util.normalizeRect(g),c.push(this.getTextByRect(e,g))}let l=s.color?{r:s.color[0],g:s.color[1],b:s.color[2]}:null,d=(o=s.contentsObj)==null?void 0:o.str,h=s.quadPoints[0];r.push({id:s.id,textRanges:c,rgb:l,comment:d,left:h[0].x,top:h[0].y})}return new Map(r.sort((s,a)=>{if(s.textRanges.length&&a.textRanges.length){let c=s.textRanges[0].from,l=a.textRanges[0].from;return c.index-l.index||c.offset-l.offset}return a.top-s.top||s.left-a.left}).map(s=>{let a=s.textRanges.map(c=>c.text).join(` `);return a=this.lib.toSingleLine(a),[s.id,{text:a,rgb:s.rgb,comment:s.comment}]}))}getTextByRect(t,e){let[i,r,o,s]=e,a="",c={index:-1,offset:-1},l={index:-1,offset:-1};for(let d=0;d{let r=i.view;this.lib.isPDFView(r)&&e(r)})}iterateBacklinkViews(e){this.app.workspace.getLeavesOfType("backlink").forEach(i=>e(i.view))}iterateCanvasViews(e){this.app.workspace.iterateAllLeaves(i=>{let r=i.view;this.lib.isCanvasView(r)&&e(r)})}iteratePDFViewerComponents(e){this.app.workspace.iterateAllLeaves(i=>{let r=i.view;this.lib.isPDFView(r)?e(r.viewer,r.file):r instanceof Ye.MarkdownView?this.lib.getAllPDFEmbedInMarkdownView(r).forEach(o=>e(o.viewer,o.file)):this.lib.isCanvasView(r)&&this.lib.getAllPDFEmbedInCanvasView(r).forEach(o=>e(o.viewer,o.file))})}iteratePDFViewerChild(e){this.iteratePDFViewerComponents(i=>{i.then(r=>e(r))})}getActivePDFView(){var i;if(this.plugin.classes.PDFView)return this.app.workspace.getActiveViewOfType(this.plugin.classes.PDFView);let e=(i=this.app.workspace.activeLeaf)==null?void 0:i.view;return e&&this.lib.isPDFView(e)?e:null}getActiveCanvasView(){var i;let e=(i=this.app.workspace.activeLeaf)==null?void 0:i.view;return e&&this.lib.isCanvasView(e)?e:null}getExistingLeafForPDFFile(e){return this.getExistingLeafForFile(e)}getActiveGroupLeaves(){var i;let e=(i=this.app.workspace.activeLeaf)==null?void 0:i.group;return e?this.app.workspace.getGroupLeaves(e):null}async openMarkdownLinkFromPDF(e,i,r,o){var c;let s;r?s=this.app.workspace.getLeaf(r):Qx(this.settings.paneTypeForFirstMDLeaf)&&this.settings.alwaysUseSidebar?s=this.getMarkdownLeafInSidebar(this.settings.paneTypeForFirstMDLeaf):s=this.getMarkdownLeafForLinkFromPDF(e,i);let a={};if(o){if("pos"in o){let{pos:l}=o;a.eState={line:l.start.line,startLoc:l.start,endLoc:l.end}}else{let{line:l}=o;a.eState={line:l}}a.eState.scroll=a.eState.line,a.eState.focus=!this.settings.dontActivateAfterOpenMD}s.parentSplit instanceof Ye.WorkspaceTabs&&s.parentSplit===((c=this.app.workspace.activeLeaf)==null?void 0:c.parentSplit)||(a.active=!this.plugin.settings.dontActivateAfterOpenMD),await s.openLinkText(e,i,a),await this.revealLeaf(s)}getMarkdownLeafInSidebar(e){var i;return this.settings.singleMDLeafInSidebar?(i=this.lib.workspace.getExistingMarkdownLeafInSidebar(e))!=null?i:this.lib.workspace.getNewLeafInSidebar(e):this.lib.workspace.getNewLeafInSidebar(e)}getMarkdownLeafForLinkFromPDF(e,i){var c;let{path:r}=(0,Ye.parseLinktext)(e),o=this.app.metadataCache.getFirstLinkpathDest(r,i),s,a;return this.app.workspace.iterateAllLeaves(l=>{if(s)return;let d=!0;if(l.view.getViewType()==="markdown"){let h=l.getRoot();for(let u of this.settings.ignoreExistingMarkdownTabIn)if(h===this.app.workspace[u])return;l.parentSplit instanceof Ye.WorkspaceTabs&&l.parentSplit.children.some(f=>{if(f instanceof Ye.WorkspaceLeaf&&f.view.getViewType()==="pdf")return this.getFilePathFromView(f.view)===i})&&(d=!1),d&&(a=l.parentSplit),o&&this.getFilePathFromView(l.view)===o.path&&(s=l)}}),s||(Qx(this.settings.paneTypeForFirstMDLeaf)&&this.settings.singleMDLeafInSidebar&&a&&this.isInSidebar(a)?s=(c=this.getExistingMarkdownLeafInSidebar(this.settings.paneTypeForFirstMDLeaf))!=null?c:this.lib.workspace.getNewLeafInSidebar(this.settings.paneTypeForFirstMDLeaf):s=a?this.app.workspace.createLeafInParent(a,-1):this.getLeaf(this.plugin.settings.paneTypeForFirstMDLeaf)),s}isInSidebar(e){let i=e.getRoot();return i===this.app.workspace.rightSplit||i===this.app.workspace.leftSplit}getLeaf(e){return e===""&&(e=!1),typeof e=="boolean"||HP(e)?this.app.workspace.getLeaf(e):UP(e)?this.getLeafBySplit(e):this.getLeafInSidebar(e)}getLeafBySplit(e){let i=this.app.workspace.getMostRecentLeaf();if(i){if(["right","left"].contains(e))return this.app.workspace.createLeafBySplit(i,"vertical",e==="left");if(["down","up"].contains(e))return this.app.workspace.createLeafBySplit(i,"horizontal",e==="up")}return this.app.workspace.createLeafInParent(this.app.workspace.rootSplit,0)}getLeafInSidebar(e){return this.getNewLeafInSidebar(e)}getExistingMarkdownLeafInSidebar(e){let i,r=e==="right-sidebar"?this.app.workspace.rightSplit:this.app.workspace.leftSplit;return this.app.workspace.iterateAllLeaves(o=>{i||o.getRoot()!==r||o.view.getViewType()==="markdown"&&(i=o)}),i!=null?i:null}getNewLeafInSidebar(e){let i=e==="right-sidebar"?this.app.workspace.getRightLeaf(!1):this.app.workspace.getLeftLeaf(!1);if(!i)throw new Error("No sidebar leaf found");return i}async revealLeaf(e){if((0,Ye.requireApiVersion)("1.5.11")){await this.app.workspace.revealLeaf(e);return}if(!Ye.Platform.isDesktopApp){this.app.workspace.revealLeaf(e);return}let i=e.getRoot();i instanceof Ye.WorkspaceSidedock&&i.collapsed&&i.toggle();let r=e.parent;r instanceof Ye.WorkspaceTabs&&r.selectTab(e),e.getContainer().focus()}openPDFLinkTextInLeaf(e,i,r,o){let{subpath:s}=(0,Ye.parseLinktext)(i);return this.plugin.patchStatus.pdfInternals||(this.plugin.subpathWhenPatched=s),e.openLinkText(i,r,o).then(async()=>{await this.revealLeaf(e);let a=e.view;this.lib.isPDFView(a)&&a.viewer.then(c=>{let l=this.plugin.settings.highlightDuration;this.lib.highlight.viewer.highlightSubpath(c,l)})})}openPDFLinkTextInExistingLeafForTargetPDF(e,i,r,o){var c,l;if(!o){let{path:d}=(0,Ye.parseLinktext)(e);o=(c=this.app.metadataCache.getFirstLinkpathDest(d,i))!=null?c:void 0}if(!o)return{exists:!1,promise:Promise.resolve()};let s=this.getExistingLeafForPDFFile(o);return s?(s.parentSplit instanceof Ye.WorkspaceTabs&&s.parentSplit===((l=this.app.workspace.activeLeaf)==null?void 0:l.parentSplit)||(r=r!=null?r:{},r.active=!this.settings.dontActivateAfterOpenPDF),s.isVisible()&&this.settings.highlightExistingTab&&(s.containerEl.addClass("pdf-plus-link-opened","is-highlighted"),setTimeout(()=>s.containerEl.removeClass("pdf-plus-link-opened","is-highlighted"),this.settings.existingTabHighlightDuration*1e3)),{exists:!0,promise:this.openPDFLinkTextInLeaf(s,e,i,r)}):{exists:!1,promise:Promise.resolve()}}getExistingLeafForFile(e){let i=this.app.viewRegistry.getTypeByExtension(e.extension);if(!i)return null;let r=null;return this.app.workspace.iterateAllLeaves(o=>{r||o.view.getViewType()===i&&this.getFilePathFromView(o.view)===e.path&&(r=o)}),r}getExistingLeafForMarkdownFile(e){return this.getExistingLeafForFile(e)}isMarkdownFileOpened(e){return!!this.getExistingLeafForMarkdownFile(e)}registerHideSidebar(e){let i=e.getRoot();if(i===this.app.workspace.leftSplit||i===this.app.workspace.rightSplit){let r=i,o=this.app.workspace.on("active-leaf-change",s=>{s&&s.getRoot()!==r&&(r.collapse(),this.app.workspace.offref(o))})}}getFilePathFromView(e){let i=e.getState().file;return typeof i=="string"?i:null}async ensureViewLoaded(e){(0,Ye.requireApiVersion)("1.7.2")&&await e.loadIfDeferred()}},pg=class extends ke{get hoverEditorPlugin(){var t;return(t=this.app.plugins.plugins["obsidian-hover-editor"])!=null?t:null}get waitTime(){var t;return(t=this.hoverEditorPlugin)==null?void 0:t.settings.triggerDelay}isHoverEditorLeaf(t){return t.containerEl.closest(".popover.hover-popover.hover-editor")!==null}async createNewHoverEditorLeaf(t,e,i,r,o){return this.hoverEditorPlugin?new Promise(s=>{var c;let a=this.app.workspace.on("active-leaf-change",l=>{l&&this.isHoverEditorLeaf(l)&&(this.app.workspace.offref(a),s(l))});this.app.workspace.trigger("link-hover",t,e,i,r,o),window.setTimeout(()=>{this.app.workspace.offref(a),s(null)},((c=this.waitTime)!=null?c:300)+300)}):null}iterateHoverEditorLeaves(t){this.app.workspace.iterateAllLeaves(e=>{this.isHoverEditorLeaf(e)&&t(e)})}getHoverEditorForLeaf(t){var e,i;return(i=(e=this.hoverEditorPlugin)==null?void 0:e.activePopovers.find(r=>r.hoverEl.contains(t.containerEl)))!=null?i:null}postProcessHoverEditorLeaf(t){if(this.isHoverEditorLeaf(t)){let e=this.getHoverEditorForLeaf(t);if(e&&(e.hoverEl.hasClass("is-minimized")&&e.toggleMinimized(),this.settings.closeHoverEditorWhenLostFocus)){let i=this.app.workspace.on("active-leaf-change",r=>{r!==t&&(e.hide(),this.app.workspace.offref(i))})}}}};var st=require("obsidian");var zh=class extends ke{constructor(...e){super(...e);let i=[{id:"copy-link-to-selection",name:"Copy link to selection or annotation",checkCallback:r=>this.copyLink(r,!1)},{id:"rectangular-selection",name:"Start rectangular selection",checkCallback:r=>this.copyEmbedLinkToRectangularSelection(r,!1)},{id:"context-menu",name:"Show context menu at selection",checkCallback:r=>this.showContextMenu(r)},{id:"extract-annotation-and-copy-links",name:"Extract & copy annotations in this PDF",checkCallback:r=>this.extractHighlightedText(r)},{id:"copy-link-to-page-view",name:"Copy link to current page view",checkCallback:r=>this.copyLinkToPageView(r)},{id:"outline",name:"Show outline",checkCallback:r=>this.showOutline(r)},{id:"thumbnail",name:"Show thumbnail",checkCallback:r=>this.showThumbnail(r)},{id:"close-sidebar",name:"Close PDF sidebar",checkCallback:r=>this.closeSidebar(r)},{id:"fit-width",name:"Fit width",checkCallback:r=>this.setScaleValue(r,"page-width")},{id:"fit-height",name:"Fit height",checkCallback:r=>this.setScaleValue(r,"page-height")},{id:"zoom-in",name:"Zoom in",checkCallback:r=>this.zoom(r,!0)},{id:"zoom-out",name:"Zoom out",checkCallback:r=>this.zoom(r,!1)},{id:"adapt-to-theme",name:"Adapt to theme",checkCallback:r=>this.toggleAdaptToTheme(r,!0)},{id:"not-adapt-to-theme",name:"Don't adapt to theme",checkCallback:r=>this.toggleAdaptToTheme(r,!1)},{id:"toggle-adapt-to-theme",name:'Toggle "adapt to theme"',checkCallback:r=>this.toggleAdaptToTheme(r)},{id:"go-to-page",name:"Go to page",checkCallback:r=>this.focusAndSelectPageNumberEl(r)},{id:"copy-format-menu",name:"Show copy format menu",checkCallback:r=>this.showCopyFormatMenu(r)},{id:"display-text-format-menu",name:"Show display text format menu",checkCallback:r=>this.showDisplayTextFormatMenu(r)},{id:"enable-pdf-edit",name:"Enable PDF edit",checkCallback:r=>this.setWriteFile(r,!0)},{id:"disable-pdf-edit",name:"Disable PDF edit",checkCallback:r=>this.setWriteFile(r,!1)},{id:"toggle-auto-focus",name:"Toggle auto-focus",callback:()=>this.toggleAutoFocus()},{id:"toggle-auto-paste",name:"Toggle auto-paste",callback:()=>this.toggleAutoPaste()},{id:"toggle-auto-copy",name:"Toggle auto-copy",callback:()=>this.plugin.autoCopyMode.toggle()},{id:"add-page",name:"Add new page at the end",checkCallback:r=>this.addPage(r)},{id:"insert-page-before",name:"Insert page before this page",checkCallback:r=>this.insertPage(r,!0)},{id:"insert-page-after",name:"Insert page after this page",checkCallback:r=>this.insertPage(r,!1)},{id:"delete-page",name:"Delete this page",checkCallback:r=>this.deletePage(r)},{id:"extract-this-page",name:"Extract this page to a new file",checkCallback:r=>this.extractThisPage(r)},{id:"divide",name:"Divide this PDF into two files at this page",checkCallback:r=>this.dividePDF(r)},{id:"edit-page-labels",name:"Edit page labels",checkCallback:r=>this.editPageLabels(r)},{id:"copy-outline-as-list",name:"Copy PDF outline as markdown list",checkCallback:r=>this.copyOutline(r,"list")},{id:"copy-outline-as-headings",name:"Copy PDF outline as markdown headings",checkCallback:r=>this.copyOutline(r,"heading")},{id:"add-outline-item",name:"Add to outline (bookmark)",checkCallback:r=>this.addOutlineItem(r)},{id:"create-new-note",name:"Create new note for auto-focus or auto-paste",callback:()=>this.createNewNote()},{id:"copy-debug-info",name:"Copy debug info",callback:()=>this.copyDebugInfo()},{id:"load-debug-info",name:"Load debug info",checkCallback:r=>this.loadDebugInfo(r)},{id:"create-pdf",name:"Create new PDF",callback:()=>this.createPDF()},{id:"import",name:"Import this PDF into vault",checkCallback:r=>this.importExternalFileIntoVault(r)},{id:"open-external",name:"Open this PDF in the original location",checkCallback:r=>this.openExternalSource(r)},{id:"create-dummy",name:"Create dummy file for external PDF",callback:()=>this.createDummyForExternalPDF()}];this.commands={};for(let r of i)this.commands[r.id]=r}registerCommands(){Object.values(this.commands).forEach(e=>this.plugin.addCommand(e))}getCommand(e){return e.startsWith(this.plugin.manifest.id+":")&&(e=e.slice(this.plugin.manifest.id.length+1)),this.commands[e]}listCommands(){return Object.values(this.commands)}listCommandNames(){return Object.values(this.commands).map(e=>this.stripCommandNamePrefix(e.name))}stripCommandNamePrefix(e){return e.startsWith(this.plugin.manifest.name+": ")?e.slice(this.plugin.manifest.name.length+2):e}copyLink(e,i=!1){return!this.writeHighlightAnnotationToSelectionIntoFileAndCopyLink(e,i)&&!this.copyLinkToAnnotation(e,i)?this.copyLinkToSelection(e,i):!0}createCanvasCard(e){return this.createCanvasCardFromAnnotation(e)?!0:this.createCanvasCardFromSelection(e)}copyLinkToSelection(e,i=!1){let r=this.lib.copyLink.getSelectionLinkInfo();if(!r)return!1;let{template:o,colorName:s}=r;return this.lib.copyLink.copyLinkToSelection(e,{copyFormat:o},s,i)}copyLinkToAnnotation(e,i=!1){let r=this.lib.copyLink.getAnnotationLinkInfo();if(!r)return!1;let{child:o,copyButtonEl:s,template:a,page:c,id:l}=r,d=this.lib.copyLink.copyLinkToAnnotation(o,e,{copyFormat:a},c,l,i);return!e&&d&&(0,st.setIcon)(s,"lucide-check"),d}writeHighlightAnnotationToSelectionIntoFileAndCopyLink(e,i=!1){var a;let r=this.lib.getColorPaletteAssociatedWithSelection();if(!r||!r.writeFile)return!1;let o=this.settings.copyCommands[r.actionIndex].template,s=(a=r.selectedColorName)!=null?a:void 0;return this.lib.copyLink.writeHighlightAnnotationToSelectionIntoFileAndCopyLink(e,{copyFormat:o},s,i)}copyEmbedLinkToRectangularSelection(e,i){let r=this.lib.getColorPalette();return!r||!r.cropButtonEl?!1:(e||r.startRectangularSelection(i),!0)}createCanvasCardFromSelection(e){var a;let i=(a=this.lib.workspace.getActiveCanvasView())==null?void 0:a.canvas;if(!i)return!1;let r=this.lib.copyLink.getSelectionLinkInfo();if(!r)return!1;let{template:o,colorName:s}=r;return this.lib.copyLink.makeCanvasTextNodeFromSelection(e,i,o,s)}createCanvasCardFromAnnotation(e){var d;let i=(d=this.lib.workspace.getActiveCanvasView())==null?void 0:d.canvas;if(!i)return!1;let r=this.lib.copyLink.getAnnotationLinkInfo();if(!r)return!1;let{child:o,template:s,page:a,id:c}=r;return this.lib.copyLink.makeCanvasTextNodeFromAnnotation(e,i,o,s,a,c)}copyLinkToPageView(e){var o,s,a,c,l;let i=this.lib.getPDFView(!0);if(!i||!i.file)return!1;let r=i.getState();if(typeof r.left!="number"||typeof r.top!="number")return!1;if(!e){let d=`#page=${r.page}`,h;((s=(o=i.viewer.child)==null?void 0:o.pdfViewer.pdfViewer)==null?void 0:s.currentScaleValue)==="page-width"?(d+=`&offset=,${r.top},`,h=[r.page-1,"FitBH",r.top]):(d+=`&offset=${r.left},${r.top},${(a=r.zoom)!=null?a:0}`,h=[r.page-1,"XYZ",r.left,r.top,(c=r.zoom)!=null?c:0]);let f=(l=i.viewer.child)==null?void 0:l.getPageLinkAlias(r.page),p=this.lib.generateMarkdownLink(i.file,"",d,f).slice(1);navigator.clipboard.writeText(p),new st.Notice(`${this.plugin.manifest.name}: Link copied to clipboard`),this.plugin.lastCopiedDestInfo={file:i.file,destArray:h}}return!0}showOutline(e){var o;let i=this.lib.getObsidianViewer(!0);if(!i)return!1;let r=(o=i.dom)==null?void 0:o.containerEl;if(!i.isEmbed||r&&r.contains(r.doc.activeElement)){let s=i==null?void 0:i.pdfSidebar;if(s)return s.haveOutline?s.isOpen&&s.active===2?this.settings.closeSidebarWithShowCommandIfExist?(e||s.close(),!0):!1:(e||s.switchView(2,!0),!0):!1}return this.settings.executeBuiltinCommandForOutline&&this.app.internalPlugins.plugins.outline.enabled?(e||this.app.commands.executeCommandById("outline:open"),!0):!1}showThumbnail(e){var r;let i=(r=this.lib.getObsidianViewer(!0))==null?void 0:r.pdfSidebar;return i?i.isOpen&&i.active===1?this.settings.closeSidebarWithShowCommandIfExist?(e||i.close(),!0):!1:(e||i.switchView(1,!0),!0):!1}closeSidebar(e){var r;let i=(r=this.lib.getObsidianViewer(!0))==null?void 0:r.pdfSidebar;return!i||!i.isOpen?!1:(e||i.close(),!0)}setScaleValue(e,i){let r=this.lib.getPDFViewer(!0);return r?(e||(r.currentScaleValue=i),!0):!1}zoom(e,i){var s;let r=this.lib.getObsidianViewer(!0);if(!r)return!1;let o=(s=r.dom)==null?void 0:s.containerEl;if((!r.isEmbed||o&&o.contains(o.doc.activeElement))&&r)return e||(i?r.zoomIn():r.zoomOut()),!0;if(this.settings.executeFontSizeAdjusterCommand){let a=i?"font-size:increment-font-size":"font-size:decrement-font-size";if(this.app.commands.findCommand(a))return e||this.app.commands.executeCommandById(a),!0}if(this.settings.executeBuiltinCommandForZoom){let a=i?"window:zoom-in":"window:zoom-out";return this.app.commands.findCommand(a)?(e||this.app.commands.executeCommandById(a),!0):!1}return!1}toggleAdaptToTheme(e,i){let r=this.lib.getPDFViewerChild(!0);if(!r)return!1;let o=!!this.app.loadLocalStorage("pdfjs-is-themed");return typeof i=="boolean"&&(i&&o||!i&&!o)?!1:(i=i!=null?i:!o,e||(this.app.saveLocalStorage("pdfjs-is-themed",i?"true":null),r.onCSSChange()),!0)}focusAndSelectPageNumberEl(e){let i=this.lib.getToolbar(!0);return i?(e||(i.pageInputEl.focus(),i.pageInputEl.select()),!0):!1}showCopyFormatMenu(e){let i=this.lib.getColorPalette();return!i||!i.actionMenuEl?!1:(e||i.actionMenuEl.click(),!0)}showDisplayTextFormatMenu(e){let i=this.lib.getColorPalette();return!i||!i.displayTextFormatMenuEl?!1:(e||i.displayTextFormatMenuEl.click(),!0)}setWriteFile(e,i){let r=this.lib.getColorPalette();return!r||!this.lib.isEditable(r.child)||r.writeFile===i?!1:(e||r.setWriteFile(i),!0)}toggleAutoFocus(){this.plugin.toggleAutoFocus()}toggleAutoPaste(){this.plugin.toggleAutoPaste()}addPage(e){if(!this.lib.composer.isEnabled())return!1;let i=this.app.workspace.getActiveFile();return!i||i.extension!=="pdf"?!1:(e||this.lib.composer.addPage(i),!0)}insertPage(e,i){if(!this.lib.composer.isEnabled())return!1;let r=this.lib.workspace.getActivePDFView();if(!r||!r.file)return!1;let o=r.file,s=r.getState().page,a=s+(i?0:1);return e||this._insertPage(o,a,s),!0}_insertPage(e,i,r){new Nn(this.plugin,this.settings.askPageLabelUpdateWhenInsertPage,this.settings.pageLabelUpdateWhenInsertPage,!1,!1).ask().then(o=>{this.lib.composer.insertPage(e,i,r,o)})}deletePage(e){if(!this.lib.composer.isEnabled())return!1;let i=this.lib.workspace.getActivePDFView();if(!i||!i.file)return!1;let r=i.file,o=i.getState().page;return e||this._deletePage(r,o),!0}_deletePage(e,i){new ch(e,i,this.plugin).openIfNeccessary().then(()=>{new Nn(this.plugin,this.settings.askPageLabelUpdateWhenDeletePage,this.settings.pageLabelUpdateWhenDeletePage,!1,!1).ask().then(r=>{this.lib.composer.removePage(e,i,r)})})}extractThisPage(e){if(!this.lib.composer.isEnabled())return!1;let i=this.lib.workspace.getActivePDFView();if(!i)return!1;let r=i.file;if(!r)return!1;if(!e){let o=i.getState().page;this._extractPage(r,o)}return!0}_extractPage(e,i){let r=this.lib.getAvailablePathForCopy(e);new Nn(this.plugin,this.settings.askPageLabelUpdateWhenExtractPage,this.settings.pageLabelUpdateWhenExtractPage,this.settings.askExtractPageInPlace,this.settings.extractPageInPlace).ask().then((o,s)=>{this.lib.composer.extractPages(e,[i],r,!1,o,s).then(async a=>{if(!a){new st.Notice(`${this.plugin.manifest.name}: Failed to extract page.`);return}if(this.settings.openAfterExtractPages){let c=this.lib.workspace.getLeaf(this.settings.howToOpenExtractedPDF);await c.openFile(a),await this.lib.workspace.revealLeaf(c)}})})}dividePDF(e){if(!this.lib.composer.isEnabled())return!1;let i=this.lib.workspace.getActivePDFView();if(!i)return!1;let r=i.file;if(!r)return!1;if(!e){let o=i.getState().page;this._dividePDF(r,o)}return!0}_dividePDF(e,i){let r=this.lib.getAvailablePathForCopy(e);new Nn(this.plugin,this.settings.askPageLabelUpdateWhenExtractPage,this.settings.pageLabelUpdateWhenExtractPage,this.settings.askExtractPageInPlace,this.settings.extractPageInPlace).ask().then((o,s)=>{this.lib.composer.extractPages(e,{from:i},r,!1,o,s).then(async a=>{if(!a){new st.Notice(`${this.plugin.manifest.name}: Failed to divide PDF.`);return}if(this.settings.openAfterExtractPages){let c=this.lib.workspace.getLeaf(this.settings.howToOpenExtractedPDF);await c.openFile(a),await this.lib.workspace.revealLeaf(c)}})})}createPDF(){var a,c,l;let e=this.app.workspace.getActiveFile(),i=this.settings.newPDFLocation,r=i==="root"?"/":i=="current"?(c=(a=e==null?void 0:e.parent)==null?void 0:a.path)!=null?c:"":(0,st.normalizePath)(this.settings.newPDFFolderPath),o=(l=this.app.vault.getAbstractFileByPath(r))!=null?l:this.app.vault.getRoot(),s=this.app.vault.getAvailablePath((0,st.normalizePath)(o.path+"/Untitled"),"pdf");new dh(this.plugin).askOptions().then(async d=>{let h=await this.app.vault.createBinary(s,await d.save());await this.app.workspace.getLeaf("tab").openFile(h)})}editPageLabels(e){let i=this.lib.workspace.getActivePDFView();if(!i||!i.viewer.child||!this.lib.isEditable(i.viewer.child))return!1;let r=i.file;return r?(e||new ph(this.plugin,r).open(),!0):!1}copyOutline(e,i){let r=this.lib.getPDFViewerChild(!0),o=r==null?void 0:r.file;if(!r||!o||!r.pdfViewer.pdfSidebar.haveOutline)return!1;if(!e){let a=i==="list"?this.settings.copyOutlineAsListFormat:this.settings.copyOutlineAsHeadingsFormat,c=i==="list"?this.settings.copyOutlineAsListDisplayTextFormat:this.settings.copyOutlineAsHeadingsDisplayTextFormat,l=this.settings.copyOutlineAsHeadingsMinLevel;(async()=>{let d=await Ce.fromFile(o,this.plugin),h="",u=this.app.vault.getConfig("useTab"),f=this.app.vault.getConfig("tabSize"),p=u?" ":" ".repeat(f);await d.iterAsync({enter:async g=>{var m;if(!g.isRoot()){let b=null,w=g.getExplicitDestination();w&&(b=await this.lib.destArrayToSubpath(w));let F=b?(m=Ln(b))==null?void 0:m.page:void 0,v=b&&F!==void 0?this.lib.copyLink.getTextToCopy(r,a,c,o,F,b,g.title,"",""):g.title;i==="list"?h+=`${p.repeat(g.depth-1)}- ${v} `:i==="heading"&&(h+="#".repeat(g.depth+l-1)+` ${v} `)}}}),navigator.clipboard.writeText(h),new st.Notice(`${this.plugin.manifest.name}: Outline copied to clipboard.`)})()}return!0}addOutlineItem(e){let i=this.lib.workspace.getActivePDFView(),r=i==null?void 0:i.file,o=i==null?void 0:i.viewer.child;if(!i||!r||!o||!this.lib.isEditable(o))return!1;let s=i.getState(),a=this.lib.viewStateToDestArray(s,!0);return a?(e||new vr(this.plugin,"Add to outline").ask().then(async({title:c})=>{let l=await Ce.fromFile(r,this.plugin),d=l.doc;l.ensureRoot().createChild(c,a).updateCountForAllAncestors(),l.ensureRoot().sortChildren(),await this.app.vault.modifyBinary(r,await d.save())}),!0):!1}async createNewNote(){var h;let e=this.app.workspace.getActiveFile(),i=(h=e==null?void 0:e.path)!=null?h:"",r=this.app.fileManager.getNewFileParent(i),o="",s="";if(e&&e.extension==="pdf"){let u=new Rc(this.plugin,{file:e,folder:e.parent,app:this.app}),f=this.settings.newFileNameFormat;f&&(o=u.evalTemplate(f));let p=this.settings.newFileTemplatePath;if(p){let g=this.app.vault.getAbstractFileByPath(p);g instanceof st.TFile&&(s=await this.app.vault.read(g),s=u.evalTemplate(s))}}let a=await this.app.fileManager.createNewMarkdownFile(r,o,s||void 0),c=async()=>{let{leaf:u,isExistingLeaf:f}=await this.lib.copyLink.prepareMarkdownLeafForPaste(a);if(u){await this.lib.workspace.revealLeaf(u),this.app.workspace.setActiveLeaf(u);let p=u.view;if(p instanceof st.MarkdownView){let g=p.editor;g.focus(),f||g.exec("goEnd")}}};if(this.settings.howToOpenAutoFocusTargetIfNotOpened!=="hover-editor"){await c();return}let d=this.app.metadataCache.on("resolve",async u=>{u===a&&(this.app.metadataCache.offref(d),setTimeout(()=>c(),100))})}extractHighlightedText(e){let i=this.lib.getPDFViewerChild();if(!i)return!1;let r=i.file;if(!r)return!1;if(!e){let o=this.lib.getColorPaletteFromChild(i),s=o?this.settings.copyCommands[o.actionIndex].template:this.settings.copyCommands[this.settings.defaultColorPaletteActionIndex].template,a="";(async()=>{var d;let c=(d=this.lib.getPDFDocument(!0))!=null?d:await this.lib.loadPDFDocument(r);(await this.lib.highlight.extract.getAnnotatedTextsInDocument(c)).forEach((h,u)=>{h.forEach(({text:f,rgb:p,comment:g},m)=>{a&&(a=a.trimEnd()+` `);let b=p?`${p.r},${p.g},${p.b}`:"";a+=this.lib.copyLink.getTextToCopy(i,s,void 0,r,u,`#page=${u}&annotation=${m}`,f,b,void 0,g)})}),navigator.clipboard.writeText(a),new st.Notice(`${this.plugin.manifest.name}: Highlighted text copied to clipboard.`)})()}return!0}copyDebugInfo(){var s;let e=Object.assign({},this.settings,{author:"*".repeat(this.settings.author.length)}),i=(s=this.app.plugins.plugins["obsidian-style-settings"])==null?void 0:s.settingsManager.settings,r=i?Object.fromEntries(Object.entries(i).filter(([a])=>a.startsWith("pdf-plus@@"))):null,o=this.plugin.domManager.styleEl.textContent;navigator.clipboard.writeText(JSON.stringify({settings:e,styleSettings:r,styleSheet:o},null,4)),new st.Notice(`${this.plugin.manifest.name}: Debug info copied to clipboard.`)}loadDebugInfo(e){return this.plugin.isDebugMode?(e||(async()=>{try{let{settings:i,styleSettings:r,styleSheet:o}=JSON.parse(await navigator.clipboard.readText());new st.Notice(`${this.plugin.manifest.name}: Debug info loaded from clipboard.`),console.debug("Loaded debug info:"),console.debug("- settings:",i),console.debug("- styleSettings:",r),console.debug("- styleSheet:",o),window.pdfPlusDebugInfo={settings:i,styleSettings:r,styleSheet:o},this.plugin.settings=i;let s=this.app.setting.pluginTabs.find(a=>a.id===this.plugin.manifest.id);s&&await s.hide()}catch(i){new st.Notice(`${this.plugin.manifest.name}: Debug info not found in clipboard.`)}})(),!0):!1}importExternalFileIntoVault(e){let i=this.lib.getPDFViewerChild(!0);return!i||!i.isFileExternal||!i.palette?!1:(e||i.palette.importFile(),!0)}openExternalSource(e){let i=this.lib.getPDFViewerChild(!0),r=i==null?void 0:i.file;return!i||!i.isFileExternal||!r?!1:(e||(async()=>{let o=(await this.app.vault.read(r)).trim();window.open(o,"_blank")})(),!0)}createDummyForExternalPDF(){new Pr(this.plugin).open()}showContextMenu(e){let i=this.lib.getPDFViewerChild(!0);if(!i)return!1;let o=i.containerEl.doc.getSelection();return!o||!o.focusNode||o.isCollapsed?!1:(e||Fh(this.plugin,i,o),!0)}};var qt=require("obsidian");var qh=class extends ke{constructor(...e){super(...e);this.fileOperator=new gg(this.plugin),this.linkUpdater=new mg(this.plugin)}isEnabled(){return this.settings.enablePDFEdit}async addPage(e){return await this.linkUpdater.updateLinks(()=>this.fileOperator.addPage(e),[e],(i,r)=>({}))}async insertPage(e,i,r,o){return await this.linkUpdater.updateLinks(()=>this.fileOperator.insertPage(e,i,r,o),[e],(s,a)=>({pageNumber:typeof a=="number"&&a>=i?a+1:a}))}async removePage(e,i,r){return await this.linkUpdater.updateLinks(()=>this.fileOperator.removePage(e,i,r),[e],(o,s)=>({pageNumber:typeof s=="number"&&s>i?s-1:s}))}async mergeFiles(e,i,r){let o=(await this.fileOperator.read(e)).getPageCount();return await this.linkUpdater.updateLinks(()=>this.fileOperator.mergeFiles(e,i,r),[e,i],(s,a)=>s===e?{}:{file:e,pageNumber:typeof a=="number"?a+o:a})}async extractPages(e,i,r,o,s,a){let c;return Array.isArray(i)?c=i:(i.from===void 0&&(i.from=1),i.to===void 0&&(i.to=(await this.fileOperator.read(e)).getPageCount()),c=kp(i.from,i.to+1)),await this.linkUpdater.updateLinks(()=>this.fileOperator.extractPages(e,c,r,o,s,a),[e],(l,d)=>{if(d===void 0)return{};if(c.includes(d))return{file:r,pageNumber:c.filter(h=>h<=d).length};if(a){let h=c.filter(u=>u0?{pageNumber:d-h}:{}}return{}})}},gg=class extends ke{constructor(...e){super(...e);this.pageLabelUpdater=new bg(this.plugin)}async read(e){return await this.lib.loadPdfLibDocument(e)}async write(e,i,r){let o=await i.save(),s=this.app.vault.getAbstractFileByPath(e);if(s instanceof qt.TFile)return r||new qt.Notice(`${this.plugin.manifest.name}: File already exists: ${e}`),await this.app.vault.modifyBinary(s,o),s;if(s===null){let a=(0,qt.normalizePath)(e.split("/").slice(0,-1).join("/"));return a&&(this.app.vault.getAbstractFileByPath(a)||await this.app.vault.createFolder(a)),await this.app.vault.createBinary(e,o)}return null}async addPage(e){let i=await this.read(e),r=i.getPage(i.getPageCount()-1),{width:o,height:s}=r.getSize();return i.addPage([o,s]),await this.write(e.path,i,!0)}async insertPage(e,i,r,o){let s=await this.read(e);this.pageLabelUpdater.insertPage(s,i,o);let a=s.getPage(r-1),{width:c,height:l}=a.getSize();return s.insertPage(i-1,[c,l]),await this.write(e.path,s,!0)}async removePage(e,i,r){let o=await this.read(e);return this.pageLabelUpdater.removePage(o,i,r),o.removePage(i-1),await(await Ce.fromDocument(o,this.plugin)).prune(),await this.write(e.path,o,!0)}async mergeFiles(e,i,r){let[o,s]=await Promise.all([this.read(e),this.read(i)]);this.pageLabelUpdater.mergeFiles(o,s,r);let a=await o.copyPages(s,s.getPageIndices());for(let l of a)o.addPage(l);let c=await this.write(e.path,o,!0);return c===null?null:(await this.app.vault.delete(i),c)}async extractPages(e,i,r,o,s,a){if(i.length===0)throw new Error("No pages to extract");return a?await this.extractPagesInPlace(e,i,r,o,s):await this.extractPagesAsNewFile(e,i,r,o,s)}async extractPagesInPlace(e,i,r,o,s){let[a,c]=await Promise.all([this.read(e),this.read(e)]),l=[];for(let u=1;u<=a.getPageCount();u++)i.includes(u)||l.push(u);this.pageLabelUpdater.removePages(a,i,s),this.pageLabelUpdater.removePages(c,l,s);for(let u=a.getPageCount();u>=1;u--)i.includes(u)?a.removePage(u-1):c.removePage(u-1);await Promise.all([a,c].map(async u=>{await(await Ce.fromDocument(u,this.plugin)).prune()}));let[d,h]=await Promise.all([this.write(e.path,a,!0),this.write(r,c,o)]);return h}async extractPagesAsNewFile(e,i,r,o,s){let a=await this.read(e),c=[];for(let d=1;d<=a.getPageCount();d++)i.includes(d)||c.push(d);this.pageLabelUpdater.removePages(a,c,s);for(let d of c.sort((h,u)=>u-h))a.removePage(d-1);return await(await Ce.fromDocument(a,this.plugin)).prune(),await this.write(r,a,o)}},mg=class extends ke{async updateLinks(t,e,i){await this.lib.metadataCacheUpdatePromise;let r=new Map;for(let c of e){let l=this.app.metadataCache.getBacklinksForFile(c);for(let d of l.keys()){let h=l.get(d);for(let u of h!=null?h:[]){let f=this.getNewLinkText(u.link,d,c,i);if(typeof f!="string")continue;let p=this.getNewLink(u,f),g=u.position;r.has(d)||r.set(d,[]),r.get(d).push({position:g,newLink:p})}}}let o=await t();if(!o)return null;let s=[],a={files:0,links:0};for(let[c,l]of r){let d=this.app.vault.getAbstractFileByPath(c);d instanceof qt.TFile&&(l.sort((h,u)=>u.position.start.offset-h.position.start.offset),s.push(this.app.vault.process(d,h=>{for(let{position:u,newLink:f}of l)h=h.slice(0,u.start.offset)+f+h.slice(u.end.offset),a.links++;return h})),l.length>0&&a.files++)}return await Promise.all(s),a.links&&new qt.Notice(`${this.plugin.manifest.name}: Updated ${a.links} links in ${a.files} files.`),o}getNewLinkText(t,e,i,r){let{path:o,subpath:s}=(0,qt.parseLinktext)(t),a;s.startsWith("#")&&(s=s.slice(1));let c=new URLSearchParams(s),l=c.get("page");l!==null&&(a=+l);let{file:d,pageNumber:h}=r(i,a);if(d===void 0&&h===void 0)return;let u=o;if(d instanceof qt.TFile){let g=!this.app.vault.getConfig("useMarkdownLinks");u=this.app.metadataCache.fileToLinktext(d,e,g)}else typeof d=="string"&&(u=d);let f=s;if(typeof h=="number"){f="",c.set("page",""+h);for(let[g,m]of c)f+=`${g}=${m}&`;f.endsWith("&")&&(f=f.slice(0,-1))}return u+(f?"#"+f:"")}getNewDisplay(t){return t}getNewLink(t,e){let i=t.original,r=t.displayText,o=t.link,s=i.startsWith("!");s&&(i=i.slice(1));let a="";return i.startsWith("[[")&&i.endsWith("]]")?typeof r=="string"&&i===`[[${o}|${r}]]`?a=`[[${e}|${r}]]`:a=`[[${e}]]`:i.startsWith("[")&&i.endsWith(")")&&(a=`[${r!=null?r:""}](${xr(e)})`),s&&(a="!"+a),a}async updateLinkColor(t,e,i,r){r=Object.assign({linktext:!0,callout:!0},r);let o=this.app.vault.getAbstractFileByPath(e);if(!(o instanceof qt.TFile))return;let s=t.link,{path:a,subpath:c}=(0,qt.parseLinktext)(s),l=new URLSearchParams(c.startsWith("#")?c.slice(1):c);i&&r.linktext?l.set("color",i.type==="name"?i.name.toLowerCase():`${i.rgb.r},${i.rgb.g},${i.rgb.b}`):l.delete("color");let d="";for(let[f,p]of l.entries())d+=d?`&${f}=${p}`:`#${f}=${p}`;let h=a+d,u=this.getNewLink(t,h);if("position"in t){let f=t.position;await this.app.vault.process(o,p=>{var g,m;if(p=p.slice(0,f.start.offset)+u+p.slice(f.end.offset),r.callout){let w=((m=(g=this.app.metadataCache.getFileCache(o))==null?void 0:g.sections)!=null?m:[]).find(F=>F.position.start.offset<=f.start.offset&&f.end.offset<=F.position.end.offset);if(w&&w.type==="callout"){let F=p.split(/\r?\n/),v=w.position.start.line,P=F[v],k=new RegExp(`> *\\[\\! *${this.settings.calloutType} *(\\|(.*?))?\\]`,"i");F[v]=P.replace(k,`> [!${this.settings.calloutType}${i?`|${i.type==="name"?i.name.toLowerCase():`${i.rgb.r},${i.rgb.g},${i.rgb.b}`}`:""}]`),p=F.join(` `)}}return p})}else{let f=t.key;await this.app.fileManager.processFrontMatter(o,p=>{p[f]=u})}}},bg=class extends ke{addPage(t){}insertPage(t,e,i){Ft.processDocument(t,r=>{if(i){r.divideRangeAtPage(e,!0).shiftRangesAfterPage(e,1).divideRangeAtPage(e,!1,o=>{delete o.prefix,delete o.style});return}r.shiftRangesAfterPage(e,1)})}removePage(t,e,i){this.removePages(t,[e],i)}removePages(t,e,i){Ft.processDocument(t,r=>{e.sort((o,s)=>s-o).forEach(o=>{this.removePageFromLabels(r,o,i)})})}removePageFromLabels(t,e,i){if(i){t.divideRangeAtPage(e+1,!0).shiftRangesAfterPage(e+1,-1);return}t.shiftRangesAfterPage(e+1,-1)}mergeFiles(t,e,i){}};var _x=require("obsidian"),qo=class extends _x.Component{constructor(e,i,r,o,s,a,c){super();this.plugin=e;this.ctx=i;this.file=r;this.subpath=o;this.pageNumber=s;this.rect=a;this.width=c;this.app=i.app,this.containerEl=i.containerEl,this.rect=window.pdfjsLib.Util.normalizeRect(a),this.containerEl.addClass("pdf-cropped-embed"),c&&this.containerEl.setAttribute("width",""+c)}get lib(){return this.plugin.lib}async loadFile(){let e=await this.lib.loadPDFDocument(this.file);this.register(()=>e.destroy());let i=await e.getPage(this.pageNumber),r=await this.lib.pdfPageToImageDataUrl(i,{type:"image/bmp",encoderOptions:1,cropRect:this.rect});await new Promise((o,s)=>{this.containerEl.empty(),this.containerEl.createEl("img",{attr:{src:r}},a=>{a.addEventListener("load",()=>o()),a.addEventListener("error",d=>s(d));let c=this.containerEl.getAttribute("width"),l=this.containerEl.getAttribute("height");c&&a.setAttribute("width",c),l&&a.setAttribute("height",l)}),activeWindow.setTimeout(()=>s(),5e3)})}};var Wh=class extends ke{get ttsPlugin(){var t;return(t=this.app.plugins.plugins["obsidian-tts"])!=null?t:null}isEnabled(){return!!this.ttsPlugin}async speak(t){var e;await((e=this.ttsPlugin)==null?void 0:e.say(t))}};var jh=class{constructor(t){this.PDFOutlines=Ce;this.NameTree=sa;this.NumberTree=Fr;this.PDFNamedDestinations=Rn;this.PDFPageLabels=Ft;this.utils=Hp;this.app=t.app,this.plugin=t,this.commands=new zh(t),this.copyLink=new Lh(t),this.highlight=new Hh(t),this.workspace=new Uh(t),this.composer=new qh(t),this.speech=new Wh(t)}registerPDFEvent(t,e,i,r){let o=async s=>{await r(s),i||e.off(t,o)};i==null||i.register(()=>e.off(t,o)),e.on(t,o)}onPageReady(t,e,i){var r;(r=t.pdfViewer)==null||r._pages.forEach((o,s)=>{i(s+1,o,!1)}),this.registerPDFEvent("pagerendered",t.eventBus,e,o=>{i(o.pageNumber,o.source,!0)})}onTextLayerReady(t,e,i){var r;(r=t.pdfViewer)==null||r._pages.forEach((o,s)=>{o.textLayer&&i(s+1,o,!1)}),this.registerPDFEvent("textlayerrendered",t.eventBus,e,o=>{i(o.pageNumber,o.source,!0)})}onAnnotationLayerReady(t,e,i){var r;(r=t.pdfViewer)==null||r._pages.forEach((o,s)=>{o.annotationLayer&&i(s+1,o,!1)}),this.registerPDFEvent("annotationlayerrendered",t.eventBus,e,o=>{i(o.pageNumber,o.source,!0)})}applyPDFViewStateToViewer(t,e){let i=()=>{typeof e.left=="number"&&typeof e.top=="number"&&typeof e.zoom=="number"?t.scrollPageIntoView({pageNumber:e.page,destArray:[e.page,{name:"XYZ"},e.left,e.top,e.zoom]}):t.currentPageNumber=e.page};t.pagesCount?i():this.registerPDFEvent("pagesloaded",t.eventBus,null,()=>i())}getPageElAssociatedWithNode(t){let e=t.instanceOf(HTMLElement)?t:t.parentElement;if(!e)return null;let i=e.closest(".page");return!i||!i.instanceOf(HTMLElement)?null:i}getPageElFromSelection(t){let e=t.rangeCount>0?t.getRangeAt(0):null;return e?this.getPageElAssociatedWithNode(e.startContainer):null}getPageElFromEvent(t){return th(t,t.target)?this.getPageElAssociatedWithNode(t.target):null}getPageNumberFromEvent(t){let e=this.getPageElFromEvent(t),i=e==null?void 0:e.dataset.pageNumber;return i===void 0?null:+i}getToolbarAssociatedWithNode(t){let e=t.instanceOf(HTMLElement)?t:t.parentElement;if(!e)return null;let i=e.closest(".pdf-container"),r=i==null?void 0:i.previousElementSibling;return r&&r.hasClass("pdf-toolbar")?r:null}getToolbarAssociatedWithSelection(){let t=activeWindow.getSelection();if(t&&t.rangeCount>0){let e=t.getRangeAt(0);return this.getToolbarAssociatedWithNode(e.startContainer)}return null}getColorPalette(){var e;let t=(e=this.getPDFViewerChild(!0))!=null?e:this.plugin.lastAnnotationPopupChild;return t?this.getColorPaletteFromChild(t):this.getColorPaletteAssociatedWithSelection()}getColorPaletteOptions(){let t=this.getColorPalette();if(t)return t.getState();let e=this.plugin.settings;return{selectedColorName:[null,...Object.keys(e.colors)][e.defaultColorPaletteItemIndex],actionIndex:e.defaultColorPaletteActionIndex,displayTextFormatIndex:e.defaultDisplayTextFormatIndex,writeFile:e.defaultWriteFileToggle}}getColorPaletteAssociatedWithNode(t){var r;let e=this.getToolbarAssociatedWithNode(t);if(!e)return null;let i=e.querySelector("."+Pt.CLS);return i&&(r=Pt.elInstanceMap.get(i))!=null?r:null}getColorPaletteAssociatedWithSelection(){let t=activeWindow.getSelection();if(t&&t.rangeCount>0){let e=t.getRangeAt(0);return this.getColorPaletteAssociatedWithNode(e.startContainer)}return null}getColorPaletteFromChild(t){var i;let e=(i=t.pdfViewer.dom)==null?void 0:i.viewerEl;return e?this.getColorPaletteAssociatedWithNode(e):null}getColorPaletteContainedIn(t){for(let[e,i]of Pt.elInstanceMap)if(t.contains(e))return i;return null}getPDFViewerChildAssociatedWithNode(t){let e,i=t.instanceOf(HTMLElement)?t:t.parentElement;if(i){let r=i.closest(".pdf-viewer");r&&(e=this.plugin.pdfViewerChildren.get(r))}return e||this.workspace.iteratePDFViewerChild(r=>{!e&&r.containerEl.contains(t)&&(e=r)}),e!=null?e:null}async destIdToSubpath(t,e){let i=await e.getDestination(t);return i?this.pdfJsDestArrayToSubpath(i,e):null}async pdfJsDestArrayToSubpath(t,e){let i=await e.getPageIndex(t[0]);return this.destArrayToSubpath(this.normalizePDFJsDestArray(t,i+1))}normalizePDFJsDestArray(t,e){return[e-1,t[1].name,...t.slice(2)]}normalizePdfLibDestArray(t,e){let i=t.get(0);if(!(i instanceof q))return null;let r=e.getPages().findIndex(s=>s.ref===i);if(r===-1)return null;let o=t.get(1);return o instanceof x?[r,o.decodeText(),...t.asArray().slice(2).map(s=>s instanceof N?s.asNumber():null)]:null}async ensureDestArray(t,e){if(typeof t=="string"){let i=await e.getDestination(t);if(!i)return null;t=this.normalizePDFJsDestArray(i,await e.getPageIndex(i[0])+1)}return t}async destToPageNumber(t,e){if(typeof t=="string"){let i=await e.getDestination(t);return i?await e.getPageIndex(i[0])+1:null}return t[0]+1}destArrayToSubpath(t){var a;let e=t[0],i="",r="",o="";return t[1]==="XYZ"?(typeof t[2]=="number"&&(r+=Math.round(t[2])),typeof t[3]=="number"&&(i+=Math.round(t[3])),o=""+Math.round(((a=t[4])!=null?a:0)*100)/100):t[1]==="FitBH"&&typeof t[2]=="number"&&(i+=t[2]),`#page=${e+1}&offset=${r},${i},${o}`}viewStateToSubpath(t,e=!1){var i;if(typeof t.left=="number"&&typeof t.top=="number"){let r=`#page=${t.page}`;return e?r+=`&offset=,${t.top},`:r+=`&offset=${t.left},${t.top},${(i=t.zoom)!=null?i:0}`,r}return null}viewStateToDestArray(t,e=!1){var i;return typeof t.left=="number"&&typeof t.top=="number"?e?[t.page-1,"FitBH",t.top]:[t.page-1,"XYZ",t.left,t.top,(i=t.zoom)!=null?i:0]:null}getPageLabelTree(t){let e=et(t.catalog,"PageLabels");return e instanceof R?new Fr(e):null}getAnnotationInfoFromAnnotationElement(t){return{page:t.parent.page.pageNumber,id:t.data.id}}getAnnotationInfoFromPopupEl(t){if(!t.matches(".popupWrapper[data-annotation-id]"))return null;let e=t.closest("div.page");if(!e||e.dataset.pageNumber===void 0)return null;let i=+e.dataset.pageNumber,r=t.dataset.annotationId;return r===void 0?null:{page:i,id:r}}registerGlobalDomEvent(t,e,i,r){t.registerDomEvent(document,e,i,r),this.app.workspace.onLayoutReady(()=>{let o=new Set;this.app.workspace.iterateAllLeaves(s=>{let a=s.getContainer().win;a!==window&&o.add(a)}),o.forEach(s=>{t.registerDomEvent(s.document,e,i,r)}),t.registerEvent(this.app.workspace.on("window-open",(s,a)=>{t.registerDomEvent(a.document,e,i,r)}))})}generateMarkdownLink(t,e,i,r){let o=this.app,s=o.vault.getConfig("useMarkdownLinks"),a=!s,l=o.metadataCache.fileToLinktext(t,e,a)+(i||"");t.path===e&&i&&(l=i);let d;return s?d="[".concat(r||t.basename,"](").concat(xr(l),")"):(r&&r.toLowerCase()===l.toLowerCase()&&(l=r,r=void 0),d=r?"[[".concat(l,"|").concat(r,"]]"):"[[".concat(l,"]]")),t.extension!=="md"?"!"+d:d}getBacklinkIndexForFile(t){return new la(this.plugin,t)}async getLatestBacklinkIndexForFile(t){let e=this.getBacklinkIndexForFile(t);return await this.metadataCacheUpdatePromise,e.init(),e}async getLatestBacklinksForAnnotation(t,e,i){return(await this.getLatestBacklinkIndexForFile(t)).getPageIndex(e).annotations.get(i)}isBacklinked(t,e){if(e){let{page:c,selection:l,annotation:d}=e;if(isNaN(c)||c<1)throw new Error("Invalid page number");if(l&&(l.length!==4||l.some(h=>isNaN(h))))throw new Error("Invalid selection");if(l&&typeof d=="string")throw new Error("Selection and annotation cannot be used together")}let i=!e,r=e&&!e.selection&&!e.annotation,o=e&&!!e.selection,s=typeof(e==null?void 0:e.annotation)=="string",a=this.app.metadataCache.getBacklinksForFile(t);if(i)return a.count()>0;for(let c of a.keys()){let l=a.get(c);if(l)for(let d of l){let{subpath:h}=(0,ge.parseLinktext)(d.link),u=Ln(h);if(u&&(r&&u.page===e.page||o&&"beginIndex"in u&&u.page===e.page&&u.beginIndex===e.selection[0]&&u.beginOffset===e.selection[1]&&u.endIndex===e.selection[2]&&u.endOffset===e.selection[3]||s&&"annotation"in u&&u.page===e.page&&u.annotation===e.annotation))return!0}}return!1}getPDFView(t=!1){let e=this.workspace.getActivePDFView();if(e)return e;if(!t){let i;if(this.app.workspace.iterateAllLeaves(r=>{this.isPDFView(r.view)&&(i=r.view)}),i)return i}return null}getPDFEmbedInMarkdownView(t){let i=t.currentMode._children.find(r=>this.isPDFEmbed(r));return i!=null?i:null}getAllPDFEmbedInMarkdownView(t){return t.currentMode._children.filter(i=>this.isPDFEmbed(i))}getPDFEmbedInCanvasView(t){var i;let e=Array.from(t.canvas.nodes.values()).find(r=>this.isCanvasPDFNode(r));return(i=e==null?void 0:e.child)!=null?i:null}getAllPDFEmbedInCanvasView(t){return Array.from(t.canvas.nodes.values()).filter(e=>this.isCanvasPDFNode(e)).map(e=>e.child)}getPDFEmbedInActiveView(){let t=this.app.workspace.getActiveViewOfType(ge.MarkdownView);if(t){let i=this.getPDFEmbedInMarkdownView(t);if(i)return i}let e=this.workspace.getActiveCanvasView();if(e){let i=this.getPDFEmbedInCanvasView(e);if(i)return i}return null}getPDFEmbed(t=!1){let e=this.getPDFEmbedInActiveView();if(e)return e;if(!t){let i=null;if(this.app.workspace.iterateAllLeaves(r=>{if(i)return;let o=r.view;o instanceof ge.MarkdownView?i=this.getPDFEmbedInMarkdownView(o):this.isCanvasView(o)&&(i=this.getPDFEmbedInCanvasView(o))}),i)return i}return null}getPDFViewerComponent(t=!1){var e,i;return(i=(e=this.getPDFView(t))!=null?e:this.getPDFEmbed())==null?void 0:i.viewer}getPDFViewerChild(t=!1){var e;return(e=this.getPDFViewerComponent(t))==null?void 0:e.child}getObsidianViewer(t=!1){var e;return(e=this.getPDFViewerChild(t))==null?void 0:e.pdfViewer}getPDFViewer(t=!1){var e;return(e=this.getObsidianViewer(t))==null?void 0:e.pdfViewer}getToolbar(t=!1){var e;return(e=this.getPDFViewerChild(t))==null?void 0:e.toolbar}getPage(t=!1){let e=this.getPDFViewer(t);return e?e.getPageView(e.currentPageNumber-1):null}getAnnotation(t){var e,i;return(i=(e=this.getPage(!0))==null?void 0:e.annotationLayer)==null?void 0:i.annotationLayer.getAnnotation(t)}getTextContentItems(){var t,e;return(e=(t=this.getPage(!0))==null?void 0:t.textLayer)==null?void 0:e.textContentItems}getPDFDocument(t=!1){var e;return(e=this.getPDFViewer(t))==null?void 0:e.pdfDocument}getBacklinkVisualizer(t=!1){var e;return(e=this.getPDFViewerComponent(t))==null?void 0:e.visualizer}getBibliographyManager(t=!1){var e;return(e=this.getPDFViewerChild(t))==null?void 0:e.bib}getVim(t=!1){var e;return(e=this.getPDFViewerComponent(t))==null?void 0:e.vim}search(t,e,i,r){t.showSearch(),t.searchComponent.setValue(e),Object.assign(t.searchSettings,i),t.dispatchEvent("",r),this.updateSearchSettingsUI(t)}updateSearchSettingsUI(t){let e=t.settingsEl.querySelectorAll("div.checkbox-container"),i=e[0],r=e[1],o=e[2],s=t.searchComponent.containerEl.querySelector(".input-right-decorator.clickable-icon");i&&i.toggleClass("is-enabled",t.searchSettings.highlightAll),r&&r.toggleClass("is-enabled",t.searchSettings.matchDiacritics),o&&o.toggleClass("is-enabled",t.searchSettings.entireWord),s&&s.toggleClass("is-active",t.searchSettings.caseSensitive)}async getExternalPDFUrl(t){if(t.stat.size>300)return null;let e=(await this.app.vault.read(t)).trim();if(e.startsWith("https://")||e.startsWith("http://")){let i=await(0,ge.requestUrl)(e);if(i.status===200)return URL.createObjectURL(new Blob([i.arrayBuffer],{type:"application/pdf"}))}else if(e.startsWith("file:///"))return ge.Platform.resourcePathPrefix+e.substring(8);return null}async loadPDFDocument(t){let e=await this.getExternalPDFUrl(t);if(e)return await this.loadPDFDocumentFromArrayBufferOrUrl({url:e});let i=await this.app.vault.readBinary(t);return await this.loadPDFDocumentFromArrayBufferOrUrl({data:i})}async loadPDFDocumentFromArrayBuffer(t){return await this.loadPDFDocumentFromArrayBufferOrUrl({data:t})}async loadPDFDocumentFromArrayBufferOrUrl(t){return await window.pdfjsLib.getDocument({...t,cMapPacked:!0,cMapUrl:"/lib/pdfjs/cmaps/",standardFontDataUrl:"/lib/pdfjs/standard_fonts/"}).promise}async loadPdfLibDocument(t,e=!1){let i=await this.app.vault.readBinary(t);return await this.loadPdfLibDocumentFromArrayBuffer(i)}async loadPdfLibDocumentFromArrayBuffer(t,e=!1){try{return await pe.load(t,{ignoreEncryption:e||this.plugin.settings.enableEditEncryptedPDF})}catch(i){throw i instanceof ko&&!this.plugin.settings.enableEditEncryptedPDF&&new ge.Notice(`${this.plugin.manifest.name}: The PDF file is encrypted. Please consider enabling "Enable editing encrypted PDF files" in the plugin settings.`),i}}async getPdfLibDocument(t=!1){let e=this.getPDFDocument(t);if(e)return await this.loadPdfLibDocumentFromArrayBuffer(await e.getData())}async getPdfLibPage(t=!1){let e=this.getPDFViewer(t);if(!e)return;let i=e.currentPageNumber;if(i===void 0)return;let r=await this.loadPdfLibDocumentFromArrayBuffer(await e.pdfDocument.getData());if(r)return r.getPage(i-1)}async getPDFOutlines(){let t=await this.getPdfLibDocument();if(t)return new Ce(this.plugin,t)}getPDFViewFromChild(t){let e=null;return this.workspace.iteratePDFViews(i=>{i.viewer.child===t&&(e=i)}),e}isPDFView(t){return this.plugin.classes.PDFView?t instanceof this.plugin.classes.PDFView:t instanceof ge.EditableFileView&&t.getViewType()==="pdf"}isPDFEmbed(t){var e;return"loadFile"in t&&"file"in t&&"containerEl"in t&&t.file instanceof ge.TFile&&t.file.extension==="pdf"&&t.containerEl.instanceOf(HTMLElement)&&((e=t.containerEl)==null?void 0:e.matches(".pdf-embed"))&&t instanceof ge.Component&&!(t instanceof qo)}isCanvasView(t){return t instanceof ge.TextFileView&&t.getViewType()==="canvas"&&"canvas"in t}isCanvasPDFNode(t){return!!("file"in t&&t.file instanceof ge.TFile&&t.file.extension==="pdf"&&t.child instanceof ge.Component&&this.isPDFEmbed(t.child))}isBacklinkView(t){return t instanceof ge.FileView&&t.getViewType()==="backlink"}getAvailablePathForCopy(t){return this.app.vault.getAvailablePath(Lp(t.path),t.extension)}get metadataCacheUpdatePromise(){return new Promise(t=>this.app.metadataCache.onCleanCache(t))}async renderPDFPageToCanvas(t,e){var c;let i=createEl("canvas"),r=i.getContext("2d"),o=t.getViewport({scale:1}),s=(c=e!=null?e:window.devicePixelRatio)!=null?c:1;i.width=Math.floor(o.width*s),i.height=Math.floor(o.height*s),i.setCssStyles({width:Math.floor(o.width)+"px",height:Math.floor(o.height)+"px"});let a=[s,0,0,s,0,0];return await t.render({canvasContext:r,transform:a,viewport:o}).promise,i}async pdfPageToImageDataUrl(t,e){let[i,r,o,s]=t.view,a=o-i,c=s-r,l=e==null?void 0:e.type,d=e==null?void 0:e.encoderOptions,h=e==null?void 0:e.resolution;typeof h!="number"&&(h=(ge.Platform.isDesktop?7:ge.Platform.isTablet?4:window.devicePixelRatio||1)*(this.plugin.settings.rectEmbedResolution/100));let u=e==null?void 0:e.cropRect,f=await this.renderPDFPageToCanvas(t,h);if(!u)return f.toDataURL(l,d);let p=$d(f,360-t.rotate),g=p.width/a,m=p.height/c,b={left:(u[0]-i)*g,top:(r+c-u[3])*m,width:(u[2]-u[0])*g,height:(u[3]-u[1])*m};return $d(bp(p,b),t.rotate).toDataURL(l,d)}async pdfPageToImageArrayBuffer(t,e){var o;let r=(o=(await this.pdfPageToImageDataUrl(t,e)).match(/^data:image\/\w+;base64,(.*)/))==null?void 0:o[1];if(!r)throw new Error("Failed to convert data URL to base64");return(0,ge.base64ToArrayBuffer)(r)}getSelectedText(t,e,i,r,o){if(e===r)return this.toSingleLine(t[e].str.slice(i,o));let s=[];s.push(t[e].str.slice(i));for(let a=e+1;ae(i));return}t.pdfPlusCallbacksOnDocumentLoaded||(t.pdfPlusCallbacksOnDocumentLoaded=[]),t.pdfPlusCallbacksOnDocumentLoaded.push(e)}toSingleLine(t){return Ic(t,this.plugin.settings.removeWhitespaceBetweenCJChars)}async write(t,e,i){let r=this.app.vault.getAbstractFileByPath(t);if(r instanceof ge.TFile)return i||new ge.Notice(`${this.plugin.manifest.name}: File already exists: ${t}`),typeof e=="string"?await this.app.vault.modify(r,e):await this.app.vault.modifyBinary(r,e),r;if(r===null){let o=(0,ge.normalizePath)(t.split("/").slice(0,-1).join("/"));return o&&(this.app.vault.getAbstractFileByPath(o)||await this.app.vault.createFolder(o)),typeof e=="string"?await this.app.vault.create(t,e):await this.app.vault.createBinary(t,e)}return null}};var $x=require("obsidian");var Kh=class extends de{constructor(e){super(e);if(this.settings.autoCopyToggleRibbonIcon){let i=!1;this.iconEl=e.settings.autoCopyToggleRibbonIcon?e.addRibbonIcon(this.settings.autoCopyIconName,`${e.manifest.name}: Toggle auto-copy`,()=>{i||this.toggle()}):null,this.iconEl&&this.registerDomEvent(this.iconEl,"contextmenu",r=>{if(i)return;let o=new $x.Menu;o.addItem(s=>{s.setIcon("lucide-settings").setTitle("Customize...").onClick(()=>{this.plugin.openSettingTab().scrollToHeading("auto-copy")})}),o.onHide(()=>{i=!1}),o.showAtMouseEvent(r),i=!0})}}toggle(e){e=e!=null?e:!this.settings.autoCopy,e?this.enable():this.disable()}enable(){this.settings.autoCopy=!0,this.plugin.saveSettings(),this.load()}disable(){this.settings.autoCopy=!1,this.plugin.saveSettings(),this.unload()}onload(){var e;(e=this.iconEl)==null||e.addClass("is-active")}onunload(){var e;(e=this.iconEl)==null||e.removeClass("is-active")}};var ey=require("obsidian");var Gh=class extends de{constructor(e){super(e);this.styleEl=e.registerEl(createEl("style",{attr:{id:"pdf-plus-style"}})),document.head.append(this.styleEl)}update(){this.unload(),this.plugin.removeChild(this),this.plugin.addChild(this)}registerEl(e){return this.register(()=>e.remove()),e}onload(){this.plugin.trigger("update-dom"),this.updateStyleEl(),this.updateClass("pdf-plus-click-embed-to-open-link",this.settings.dblclickEmbedToOpenLink),this.updateClass("pdf-plus-backlink-selection-highlight",this.settings.selectionBacklinkVisualizeStyle==="highlight"),this.updateClass("pdf-plus-backlink-selection-underline",this.settings.selectionBacklinkVisualizeStyle==="underline"),this.app.workspace.trigger("css-change")}updateClass(e,i){document.body.toggleClass(e,i),this.register(()=>document.body.removeClass(e))}updateStyleEl(){let e=this.plugin.settings;this.styleEl.textContent=Object.entries(e.colors).map(([o,s])=>Ki(s)?[`.pdf-plus-backlink-highlight-layer .pdf-plus-backlink:not(.hovered-highlight)[data-highlight-color="${o.toLowerCase()}"],`,`.pdf-embed[data-highlight-color="${o.toLowerCase()}"] .textLayer .mod-focused {`,` --pdf-plus-color: ${s};`,` --pdf-plus-backlink-icon-color: ${s};`,` --pdf-plus-rect-color: ${s};`,"}"].join(` `):"").join(` `);let i=e.colors[e.defaultColor];(!i||!Ki(i))&&(i="rgb(var(--text-highlight-bg-rgb))"),this.styleEl.textContent+=[` .pdf-plus-backlink-highlight-layer .pdf-plus-backlink:not(.hovered-highlight) {`,` --pdf-plus-color: ${i};`,` --pdf-plus-backlink-icon-color: ${i};`,` --pdf-plus-rect-color: ${i};`,"}"].join(` `);let r=e.colors[e.backlinkHoverColor];(!r||!Ki(r))&&(r=vx),this.styleEl.textContent+=[` .pdf-plus-backlink-highlight-layer .pdf-plus-backlink.hovered-highlight {`,` --pdf-plus-color: ${r};`,` --pdf-plus-backlink-icon-color: ${r};`,` --pdf-plus-rect-color: ${r};`,"}"].join(` `);for(let[o,s]of Object.entries(e.colors))Ki(s)&&(this.styleEl.textContent+=[` .${Pt.CLS}-item[data-highlight-color="${o.toLowerCase()}"] > .${Pt.CLS}-item-inner {`,` background-color: ${s};`,"}"].join(` `));this.styleEl.textContent+=[` .${Pt.CLS}-item:not([data-highlight-color]) > .${Pt.CLS}-item-inner {`," background-color: transparent;","}"].join(` `),this.styleEl.textContent+=[` .workspace-leaf.pdf-plus-link-opened.is-highlighted::before {`,` opacity: ${e.existingTabHighlightOpacity};`,"}"].join(` `),this.setCSSColorVariables(),this.updateCalloutStyle()}updateCalloutStyle(){var r;if(!this.plugin.settings.useCallout)return;let e=this.plugin.settings.calloutType.toLowerCase();for(let o of Object.keys(this.plugin.settings.colors)){let s=(r=this.toCSSVariableName(o))!=null?r:"--pdf-plus-default-color-rgb";this.styleEl.textContent+=[` .callout[data-callout="${e}"][data-callout-metadata="${o.toLowerCase()}"] {`,` --callout-color: var(${s});`," background-color: rgba(var(--callout-color), var(--pdf-plus-highlight-opacity, 0.2))","}"].join(` `)}this.styleEl.textContent+=[` .callout[data-callout="${e}"] {`," --callout-color: var(--pdf-plus-default-color-rgb);"," background-color: rgba(var(--callout-color), var(--pdf-plus-highlight-opacity, 0.2))","}"].join(` `);let i=this.plugin.settings.calloutIcon;i?this.styleEl.textContent+=[` .callout[data-callout="${e}"] {`,` --callout-icon: lucide-${i};`,"}"].join(` `):this.styleEl.textContent+=[` .callout[data-callout="${e}"] .callout-icon {`," display: none;","}"].join(` `)}registerCalloutRenderer(){let e=this.plugin.settings.calloutType.toLowerCase();this.plugin.registerMarkdownPostProcessor((i,r)=>{for(let o of i.querySelectorAll(`.callout[data-callout="${e}"][data-callout-metadata*=","]`))r.addChild(new xg(o))})}setCSSColorVariables(){let e=this.plugin.settings;for(let[r,o]of Object.entries(e.colors)){let s=this.toCSSVariableName(r),a=pr(o);if(s!==null&&a!==null){let{r:c,g:l,b:d}=a;this.styleEl.textContent+=[` body {`,` ${s}: ${c}, ${l}, ${d}`,"}"].join(` `)}}let i=!1;if(e.defaultColor in e.colors){let r=this.toCSSVariableName(e.defaultColor);r!==null&&(this.styleEl.textContent+=[` body {`,` --pdf-plus-default-color-rgb: var(${r})`,"}"].join(` `),i=!0)}i||(this.styleEl.textContent+=[` body {`," --pdf-plus-default-color-rgb: var(--text-highlight-bg-rgb)","}"].join(` `))}toCSSVariableName(e){let i=e.toLowerCase().replace(/[^a-z0-9]+/g,"-");return i=i.replace(/^-+|-+$/g,""),i?"--pdf-plus-"+i+"-rgb":null}getRgb(e){let i="--pdf-plus-default-color-rgb";if(e){let s=this.toCSSVariableName(e);s&&(i=s)}let r=getComputedStyle(document.body).getPropertyValue(i);return gp(r)}},xg=class extends ey.MarkdownRenderChild{onload(){let t=this.containerEl.dataset.calloutMetadata;if(t){let e=t.split(",").map(r=>parseInt(r));e.length===3&&e.every(r=>0<=r&&r<=255)&&this.containerEl.style.setProperty("--callout-color",e.join(", "))}}};var Xh=class extends De.Plugin{constructor(){super(...arguments);this.lib=new jh(this);this.events=new De.Events;this.autoFocusToggleIconEl=null;this.autoPasteToggleIconEl=null;this.patchStatus={workspace:!1,pagePreview:!1,pdfView:!1,pdfInternals:!1,pdfOutlineViewer:!1,backlink:!1};this.classes={};this.lastPasteFile=null;this.lastActiveMarkdownFile=null;this.lastAnnotationPopupChild=null;this.lastCopiedDestInfo=null;this.vimrc=null;this.pdfViewerChildren=new Map;this.shownMenus=new Set;this.isDebugMode=!1}async onload(){this.checkVersion(),this.addIcons(),await(0,De.loadPdfJs)(),await this.loadSettings(),await this.saveSettings(),this.domManager=this.addChild(new Gh(this)),this.domManager.registerCalloutRenderer(),this.registerRibbonIcons(),this.patchObsidian(),this.registerPDFEmbedCreator(),this.registerHoverLinkSources(),this.registerCommands(),this.registerGlobalVariables(),this.registerEvents(),this.startTrackingActiveMarkdownFile(),this.registerObsidianProtocolHandler("pdf-plus",this.obsidianProtocolHandler.bind(this)),this.addSettingTab(this.settingTab=new wh(this)),this.registerStyleSettings()}async onunload(){await this.cleanUpResources()}async cleanUpResources(){await this.cleanUpAnystyleFiles()}async cleanUpAnystyleFiles(){let e=this.app.vault.adapter;if(De.Platform.isDesktopApp&&e instanceof De.FileSystemAdapter){let i=this.getAnyStyleInputDir();if(i)try{await e.rmdir(i,!0)}catch(r){if(r.code!=="ENOENT")throw r}}}checkVersion(){let e="1.8.0";(0,De.requireApiVersion)(e)&&console.warn(`${this.manifest.name}: This plugin has not been tested on Obsidian ${e} or above. Please report any issue you encounter on GitHub (https://github.com/RyotaUshio/obsidian-pdf-plus/issues/new/choose).`),kr.openIfNecessary(this)}addIcons(){(0,De.addIcon)("vim",'VIM')}async restoreDefaultSettings(){this.settings=structuredClone(Ti),await this.saveSettings()}async loadSettings(){if(this.settings=Object.assign(structuredClone(Ti),await this.loadData()),!this.settings.anystylePath){let e=this.loadLocalStorage("anystylePath");typeof e=="string"&&(this.settings.anystylePath=e)}(this.settings.defaultDisplayTextFormatIndex<0||this.settings.defaultDisplayTextFormatIndex>=this.settings.displayTextFormats.length)&&(this.settings.defaultDisplayTextFormatIndex=0),(this.settings.defaultColorPaletteActionIndex<0||this.settings.defaultColorPaletteActionIndex>=this.settings.copyCommands.length)&&(this.settings.defaultColorPaletteActionIndex=0),this.validateAutoFocusAndAutoPasteSettings();for(let[e,i]of Object.entries(this.settings.colors))this.settings.colors[e]=i.toLowerCase();this.settings.paneTypeForFirstMDLeaf==="split"&&(this.settings.paneTypeForFirstMDLeaf="right");for(let e of this.settings.copyCommands)e.hasOwnProperty("format")&&(e.template=e.format,delete e.format);if(this.settings.hasOwnProperty("aliasFormat")&&(this.settings.displayTextFormats.push({name:"Custom",template:this.settings.aliasFormat}),delete this.settings.aliasFormat),this.settings.hasOwnProperty("showCopyLinkToSearchInContextMenu")){let e=this.settings.contextMenuConfig.find(({id:i})=>i==="search");e&&e.visible&&(e.visible=this.settings.showCopyLinkToSearchInContextMenu),delete this.settings.showCopyLinkToSearchInContextMenu}this.settings.showContextMenuOnMouseUpIf==="mod"&&(this.settings.showContextMenuOnMouseUpIf="Mod"),this.renameSetting("enalbeWriteHighlightToFile","enablePDFEdit"),this.renameSetting("selectToCopyToggleRibbonIcon","autoCopyToggleRibbonIcon"),this.renameCommand("pdf-plus:toggle-select-to-copy",`${this.manifest.id}:toggle-auto-copy`),this.renameSetting("removeWhitespaceBetweenCJKChars","removeWhitespaceBetweenCJChars"),this.loadContextMenuConfig()}renameSetting(e,i){this.settings.hasOwnProperty(e)&&(this.settings[i]=this.settings[e],delete this.settings[e])}renameCommand(e,i){let{hotkeyManager:r}=this.app,o=r.getHotkeys(e);o&&(r.removeHotkeys(e),r.setHotkeys(i,o))}loadContextMenuConfig(){let e=Ti.contextMenuConfig,i=[];for(let r of e){let o=this.settings.contextMenuConfig.find(({id:s})=>s===r.id);i.push(o!=null?o:r)}this.settings.contextMenuConfig.length=0,this.settings.contextMenuConfig.push(...i)}validateAutoFocusAndAutoPasteSettings(){this.settings.autoFocus&&this.settings.autoPaste&&(this.settings.autoFocus=!1)}async saveSettings(){let e=Object.assign({},this.settings);this.saveLocalStorage("anystylePath",e.anystylePath),delete e.anystylePath,await this.saveData(e)}loadLocalStorage(e){return this.app.loadLocalStorage(this.manifest.id+"-"+e)}saveLocalStorage(e,i){this.app.saveLocalStorage(this.manifest.id+"-"+e,i)}registerStyleSettings(){this.app.workspace.trigger("parse-style-settings"),this.register(()=>this.app.workspace.trigger("parse-style-settings"))}registerRibbonIcons(){if(this.autoCopyMode=new Kh(this),this.autoCopyMode.toggle(this.settings.autoCopy),this.register(()=>this.autoCopyMode.unload()),this.settings.autoFocusToggleRibbonIcon){let e=!1;this.autoFocusToggleIconEl=this.addRibbonIcon(this.settings.autoFocusIconName,`${this.manifest.name}: Toggle auto-focus`,()=>{e||this.toggleAutoFocus()}),this.autoFocusToggleIconEl.toggleClass("is-active",this.settings.autoFocus),this.registerDomEvent(this.autoFocusToggleIconEl,"contextmenu",i=>{if(e)return;let r=new De.Menu;r.addItem(o=>{o.setIcon("lucide-settings").setTitle("Customize...").onClick(()=>{this.openSettingTab().scrollToHeading("auto-focus")})}),r.onHide(()=>{e=!1}),r.showAtMouseEvent(i),e=!0})}if(this.settings.autoPasteToggleRibbonIcon){let e=!1;this.autoPasteToggleIconEl=this.addRibbonIcon(this.settings.autoPasteIconName,`${this.manifest.name}: Toggle auto-paste`,()=>{e||this.toggleAutoPaste()}),this.autoPasteToggleIconEl.toggleClass("is-active",this.settings.autoPaste),this.registerDomEvent(this.autoPasteToggleIconEl,"contextmenu",i=>{if(e)return;let r=new De.Menu;r.addItem(o=>{o.setIcon("lucide-settings").setTitle("Customize...").onClick(()=>{this.openSettingTab().scrollToHeading("auto-paste")})}),r.onHide(()=>{e=!1}),r.showAtMouseEvent(i),e=!0})}}toggleAutoFocusRibbonIcon(e){let i=this.autoFocusToggleIconEl;i&&(e=e!=null?e:!i.hasClass("is-active"),i.toggleClass("is-active",e))}toggleAutoPasteRibbonIcon(e){let i=this.autoPasteToggleIconEl;i&&(e=e!=null?e:!i.hasClass("is-active"),i.toggleClass("is-active",e))}async toggleAutoFocus(e,i){e=e!=null?e:!this.settings.autoFocus,this.toggleAutoFocusRibbonIcon(e),this.settings.autoFocus=e,this.settings.autoFocus&&this.settings.autoPaste&&this.toggleAutoPaste(!1,!1),(i==null||i)&&await this.saveSettings()}async toggleAutoPaste(e,i){e=e!=null?e:!this.settings.autoPaste,this.toggleAutoPasteRibbonIcon(e),this.settings.autoPaste=e,this.settings.autoPaste&&this.settings.autoFocus&&this.toggleAutoFocus(!1,!1),(i==null||i)&&await this.saveSettings()}patchObsidian(){this.app.workspace.onLayoutReady(()=>{qx(this),jx(this),Yx(this)}),this.tryPatchUntilSuccess(Ux),this.tryPatchUntilSuccess(zx),this.tryPatchUntilSuccess(Gx),this.tryPatchUntilSuccess(Xx)}tryPatchUntilSuccess(e,i){this.app.workspace.onLayoutReady(()=>{if(!e(this)){let o=i==null?void 0:i(),s=this.app.workspace.on("layout-change",()=>{e(this)&&(this.app.workspace.offref(s),o==null||o.hide())});this.registerEvent(s)}})}registerEl(e){return this.register(()=>e.remove()),e}loadStyle(){this.domManager.update()}registerPDFEmbedCreator(){let e=this.app.embedRegistry.embedByExtension.pdf;this.register(()=>{this.app.embedRegistry.unregisterExtension("pdf"),this.app.embedRegistry.registerExtension("pdf",e)}),this.app.embedRegistry.unregisterExtension("pdf"),this.app.embedRegistry.registerExtension("pdf",(i,r,o)=>{let s=ta(o),a=null;if(s.has("rect")&&s.has("page")){let c=parseInt(s.get("page")),l=s.get("rect").split(",").map(h=>parseFloat(h)),d=s.has("width")?parseFloat(s.get("width")):void 0;Number.isInteger(c)&&l.length===4&&(a=new qo(this,i,r,o,c,l,d))}if(a||(a=e(i,r,o),this.classes.PDFEmbed||(this.classes.PDFEmbed=a.constructor),this.patchStatus.pdfInternals||fa(this,a.viewer)),this.registerDomEvent(a.containerEl,"dblclick",c=>{if(this.settings.dblclickEmbedToOpenLink&&vt(c,c.target)&&(c.target.closest(".pdf-embed[src] > .pdf-container")||c.target.closest(".pdf-cropped-embed"))){let l=r.path+o;this.app.workspace.openLinkText(l,"",De.Keymap.isModEvent(c)),c.preventDefault()}}),this.settings.embedUnscrollable)for(let c of["wheel","touchmove"])this.registerDomEvent(a.containerEl,c,l=>{vt(l,l.target)&&l.target.closest('.pdf-embed[src*="#"] .pdf-viewer-container')&&l.preventDefault()},{passive:!1});return a instanceof qo&&this.registerDomEvent(a.containerEl,"click",c=>{vt(c,c.target)&&c.target.closest(".cm-editor")&&c.preventDefault()}),s.has("color")?a.containerEl.dataset.highlightColor=s.get("color").toLowerCase():this.settings.defaultColor&&(a.containerEl.dataset.highlightColor=this.settings.defaultColor.toLowerCase()),a})}registerGlobalVariable(e,i,r=!0){if(e in window){if(r)throw new Error(`${this.manifest.name}: Global variable "${e}" already exists.`);return}window[e]=i,this.register(()=>delete window[e])}registerGlobalVariables(){this.registerGlobalVariable("pdfPlus",this,!1),this.registerGlobalVariable("pdflib",fp,!1)}registerEvents(){this.registerEvent(this.app.workspace.on("layout-change",()=>{for(let e of this.pdfViewerChildren.keys())e!=null&&e.isShown()||this.pdfViewerChildren.delete(e)})),De.Platform.isDesktopApp&&this.registerEvent(this.app.workspace.on("active-leaf-change",e=>{if(this.settings.syncWithDefaultApp&&e&&this.lib.isPDFView(e.view)){let i=e.view.file;i&&(this.app.openWithDefaultApp(i.path),this.settings.focusObsidianAfterOpenPDFWithDefaultApp&&Ac())}})),this.registerEvent(this.app.vault.on("delete",e=>{e instanceof De.TFile&&e===this.lastPasteFile&&(this.lastPasteFile=null)})),this.registerEvent(this.app.vault.on("rename",(e,i)=>{e instanceof De.TFile&&this.settings.newFileTemplatePath===i&&(this.settings.newFileTemplatePath=e.path,this.saveSettings())})),this.registerEvent(this.app.vault.on("delete",e=>{e instanceof De.TFile&&this.settings.newFileTemplatePath===e.path&&(this.settings.newFileTemplatePath="",this.saveSettings())})),this.registerEvent(this.app.vault.on("modify",async e=>{e instanceof De.TFile&&e.path===this.settings.vimrcPath&&(this.vimrc=await this.app.vault.read(e))})),this.registerEvent(this.app.workspace.on("quit",async()=>{await this.cleanUpResources()}))}registerOneTimeEvent(e,...[i,r,o]){let s=e.on(i,(...a)=>{r.call(o,...a),e.offref(s)},o);this.registerEvent(s)}registerHoverLinkSources(){this.registerHoverLinkSource("pdf-plus",{defaultMod:!0,display:"PDF++: backlink highlights"}),this.registerHoverLinkSource(Yi.HOVER_LINK_SOURCE_ID,{defaultMod:!0,display:"PDF++: internal links in PDF (except for citations)"}),this.registerHoverLinkSource(Ci.HOVER_LINK_SOURCE_ID,{defaultMod:!1,display:"PDF++: citation links in PDF"}),this.registerHoverLinkSource(Vn.HOVER_LINK_SOURCE_ID,{defaultMod:!0,display:"PDF++: external links in PDF"}),this.registerHoverLinkSource(Ji.HOVER_LINK_SOURCE_ID,{defaultMod:!0,display:"PDF++: outlines (bookmarks)"}),this.registerHoverLinkSource(Qi.HOVER_LINK_SOURCE_ID,{defaultMod:!0,display:"PDF++: thumbnails"})}registerCommands(){this.lib.commands.registerCommands()}startTrackingActiveMarkdownFile(){let{workspace:e,vault:i}=this.app;e.onLayoutReady(()=>{let r=e.getActiveFile();if(r&&r.extension==="md")this.lastActiveMarkdownFile=r;else{let o=e.recentFileTracker.getRecentFiles({showMarkdown:!0,showCanvas:!1,showNonImageAttachments:!1,showImages:!1,maxCount:1}).first();if(o){let s=i.getAbstractFileByPath(o);s instanceof De.TFile&&s.extension==="md"&&(this.lastActiveMarkdownFile=s)}}this.registerEvent(e.on("file-open",o=>{o instanceof De.TFile&&o.extension==="md"&&(this.lastActiveMarkdownFile=o)})),this.registerEvent(i.on("delete",o=>{o instanceof De.TFile&&o===this.lastActiveMarkdownFile&&(this.lastActiveMarkdownFile=null)}))})}obsidianProtocolHandler(e){if("create-dummy"in e)return Pr.createDummyFilesFromObsidianUrl(this,e);if("setting"in e)return this.settingTab.openFromObsidianUrl(e)}on(e,i,r){return this.events.on(e,i,r)}off(e,i){this.events.off(e,i)}offref(e){this.events.offref(e)}trigger(e,...i){this.events.trigger(e,...i)}requireModKeyForLinkHover(e="pdf-plus"){var i,r,o;return(o=(r=this.app.internalPlugins.plugins["page-preview"].instance.overrides[e])!=null?r:(i=this.app.workspace.hoverLinkSources[e])==null?void 0:i.defaultMod)!=null?o:!1}openSettingTab(){return this.app.setting.open(),this.app.setting.openTabById(this.manifest.id)}openHotkeySettingTab(e){this.app.setting.open();let i=this.app.setting.openTabById("hotkeys");return i.setQuery(e!=null?e:this.manifest.id),i}getAnyStyleInputDir(){let e=this.manifest.dir;return e?e+"/anystyle":null}};